diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 3d2ac0bdd2e..5aa8e09b7e6 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0" + ".": "2.0.0-beta.1" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 793848b98ee..01f578ddc7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## 2.0.0-beta.1 (2024-03-08) + +Full Changelog: [v0.1.0...v2.0.0-beta.1](https://github.com/cloudflare/cloudflare-go/compare/v0.1.0...v2.0.0-beta.1) + +### Features + +* OpenAPI spec update via Stainless API ([#1523](https://github.com/cloudflare/cloudflare-go/issues/1523)) ([9755602](https://github.com/cloudflare/cloudflare-go/commit/9755602b83ed9dd548303600021539a951795043)) +* OpenAPI spec update via Stainless API ([#1524](https://github.com/cloudflare/cloudflare-go/issues/1524)) ([c9e201a](https://github.com/cloudflare/cloudflare-go/commit/c9e201aa36b25699cfb966a79de8b9b552dd73e8)) +* update via SDK Studio ([#1520](https://github.com/cloudflare/cloudflare-go/issues/1520)) ([cdaf537](https://github.com/cloudflare/cloudflare-go/commit/cdaf5374ea14b7e9df99a8a38783381ebfae8b63)) + ## 0.1.0 (2024-03-08) Full Changelog: [v0.0.1...v0.1.0](https://github.com/cloudflare/cloudflare-go/compare/v0.0.1...v0.1.0) diff --git a/README.md b/README.md index f809fba9739..fb8b9e4d764 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Or to pin the version: ```sh -go get -u 'github.com/cloudflare/cloudflare-go@v0.1.0' +go get -u 'github.com/cloudflare/cloudflare-go@v2.0.0-beta.1' ``` @@ -44,6 +44,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" ) func main() { @@ -51,12 +52,12 @@ func main() { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), // defaults to os.LookupEnv("CLOUDFLARE_API_KEY") option.WithAPIEmail("user@example.com"), // defaults to os.LookupEnv("CLOUDFLARE_EMAIL") ) - zoneNewResponse, err := client.Zones.New(context.TODO(), cloudflare.ZoneNewParams{ - Account: cloudflare.F(cloudflare.ZoneNewParamsAccount{ + zoneNewResponse, err := client.Zones.New(context.TODO(), zones.ZoneNewParams{ + Account: cloudflare.F(zones.ZoneNewParamsAccount{ ID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }), Name: cloudflare.F("example.com"), - Type: cloudflare.F(cloudflare.ZoneNewParamsTypeFull), + Type: cloudflare.F(zones.ZoneNewParamsTypeFull), }) if err != nil { panic(err.Error()) @@ -187,7 +188,7 @@ When the API returns a non-success status code, we return an error with type To handle errors, we recommend that you use the `errors.As` pattern: ```go -_, err := client.Zones.Get(context.TODO(), cloudflare.ZoneGetParams{ +_, err := client.Zones.Get(context.TODO(), zones.ZoneGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { @@ -216,7 +217,7 @@ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) defer cancel() client.Zones.Edit( ctx, - cloudflare.ZoneEditParams{ + zones.ZoneEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, // This sets the per-retry timeout @@ -241,7 +242,7 @@ client := cloudflare.NewClient( // Override per-request: client.Zones.Get( context.TODO(), - cloudflare.ZoneGetParams{ + zones.ZoneGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, option.WithMaxRetries(5), diff --git a/accountmember.go b/accountmember.go deleted file mode 100644 index 9db332b3d95..00000000000 --- a/accountmember.go +++ /dev/null @@ -1,1581 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" -) - -// AccountMemberService 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 [NewAccountMemberService] method -// instead. -type AccountMemberService struct { - Options []option.RequestOption -} - -// NewAccountMemberService 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 NewAccountMemberService(opts ...option.RequestOption) (r *AccountMemberService) { - r = &AccountMemberService{} - r.Options = opts - return -} - -// Add a user to the list of members for this account. -func (r *AccountMemberService) New(ctx context.Context, params AccountMemberNewParams, opts ...option.RequestOption) (res *AccountMemberWithID, err error) { - opts = append(r.Options[:], opts...) - var env AccountMemberNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/members", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Modify an account member. -func (r *AccountMemberService) Update(ctx context.Context, memberID string, params AccountMemberUpdateParams, opts ...option.RequestOption) (res *AccountMember, err error) { - opts = append(r.Options[:], opts...) - var env AccountMemberUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/members/%s", params.AccountID, memberID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List all members of an account. -func (r *AccountMemberService) List(ctx context.Context, params AccountMemberListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[AccountMemberListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("accounts/%v/members", params.AccountID) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// List all members of an account. -func (r *AccountMemberService) ListAutoPaging(ctx context.Context, params AccountMemberListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[AccountMemberListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) -} - -// Remove a member from an account. -func (r *AccountMemberService) Delete(ctx context.Context, memberID string, body AccountMemberDeleteParams, opts ...option.RequestOption) (res *AccountMemberDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env AccountMemberDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%v/members/%s", body.AccountID, memberID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get information about a specific member of an account. -func (r *AccountMemberService) Get(ctx context.Context, memberID string, query AccountMemberGetParams, opts ...option.RequestOption) (res *AccountMember, err error) { - opts = append(r.Options[:], opts...) - var env AccountMemberGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/members/%s", query.AccountID, memberID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type AccountMember struct { - // Membership identifier tag. - ID string `json:"id,required"` - // Roles assigned to this member. - Roles []AccountMemberRole `json:"roles,required"` - Status interface{} `json:"status,required"` - User AccountMemberUser `json:"user,required"` - JSON accountMemberJSON `json:"-"` -} - -// accountMemberJSON contains the JSON metadata for the struct [AccountMember] -type accountMemberJSON struct { - ID apijson.Field - Roles apijson.Field - Status apijson.Field - User apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMember) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRole struct { - // Role identifier tag. - ID string `json:"id,required"` - // Description of role's permissions. - Description string `json:"description,required"` - // Role name. - Name string `json:"name,required"` - Permissions AccountMemberRolesPermissions `json:"permissions,required"` - JSON accountMemberRoleJSON `json:"-"` -} - -// accountMemberRoleJSON contains the JSON metadata for the struct -// [AccountMemberRole] -type accountMemberRoleJSON struct { - ID apijson.Field - Description apijson.Field - Name apijson.Field - Permissions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRole) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRoleJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissions struct { - Analytics AccountMemberRolesPermissionsAnalytics `json:"analytics"` - Billing AccountMemberRolesPermissionsBilling `json:"billing"` - CachePurge AccountMemberRolesPermissionsCachePurge `json:"cache_purge"` - DNS AccountMemberRolesPermissionsDNS `json:"dns"` - DNSRecords AccountMemberRolesPermissionsDNSRecords `json:"dns_records"` - Lb AccountMemberRolesPermissionsLb `json:"lb"` - Logs AccountMemberRolesPermissionsLogs `json:"logs"` - Organization AccountMemberRolesPermissionsOrganization `json:"organization"` - SSL AccountMemberRolesPermissionsSSL `json:"ssl"` - WAF AccountMemberRolesPermissionsWAF `json:"waf"` - ZoneSettings AccountMemberRolesPermissionsZoneSettings `json:"zone_settings"` - Zones AccountMemberRolesPermissionsZones `json:"zones"` - JSON accountMemberRolesPermissionsJSON `json:"-"` -} - -// accountMemberRolesPermissionsJSON contains the JSON metadata for the struct -// [AccountMemberRolesPermissions] -type accountMemberRolesPermissionsJSON struct { - Analytics apijson.Field - Billing apijson.Field - CachePurge apijson.Field - DNS apijson.Field - DNSRecords apijson.Field - Lb apijson.Field - Logs apijson.Field - Organization apijson.Field - SSL apijson.Field - WAF apijson.Field - ZoneSettings apijson.Field - Zones apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsAnalytics struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsAnalyticsJSON `json:"-"` -} - -// accountMemberRolesPermissionsAnalyticsJSON contains the JSON metadata for the -// struct [AccountMemberRolesPermissionsAnalytics] -type accountMemberRolesPermissionsAnalyticsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsAnalytics) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsAnalyticsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsBilling struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsBillingJSON `json:"-"` -} - -// accountMemberRolesPermissionsBillingJSON contains the JSON metadata for the -// struct [AccountMemberRolesPermissionsBilling] -type accountMemberRolesPermissionsBillingJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsBilling) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsBillingJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsCachePurge struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsCachePurgeJSON `json:"-"` -} - -// accountMemberRolesPermissionsCachePurgeJSON contains the JSON metadata for the -// struct [AccountMemberRolesPermissionsCachePurge] -type accountMemberRolesPermissionsCachePurgeJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsCachePurge) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsCachePurgeJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsDNS struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsDNSJSON `json:"-"` -} - -// accountMemberRolesPermissionsDNSJSON contains the JSON metadata for the struct -// [AccountMemberRolesPermissionsDNS] -type accountMemberRolesPermissionsDNSJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsDNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsDNSJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsDNSRecords struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsDNSRecordsJSON `json:"-"` -} - -// accountMemberRolesPermissionsDNSRecordsJSON contains the JSON metadata for the -// struct [AccountMemberRolesPermissionsDNSRecords] -type accountMemberRolesPermissionsDNSRecordsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsDNSRecords) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsDNSRecordsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsLb struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsLbJSON `json:"-"` -} - -// accountMemberRolesPermissionsLbJSON contains the JSON metadata for the struct -// [AccountMemberRolesPermissionsLb] -type accountMemberRolesPermissionsLbJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsLb) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsLbJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsLogs struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsLogsJSON `json:"-"` -} - -// accountMemberRolesPermissionsLogsJSON contains the JSON metadata for the struct -// [AccountMemberRolesPermissionsLogs] -type accountMemberRolesPermissionsLogsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsLogs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsLogsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsOrganization struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsOrganizationJSON `json:"-"` -} - -// accountMemberRolesPermissionsOrganizationJSON contains the JSON metadata for the -// struct [AccountMemberRolesPermissionsOrganization] -type accountMemberRolesPermissionsOrganizationJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsOrganizationJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsSSL struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsSSLJSON `json:"-"` -} - -// accountMemberRolesPermissionsSSLJSON contains the JSON metadata for the struct -// [AccountMemberRolesPermissionsSSL] -type accountMemberRolesPermissionsSSLJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsSSL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsSSLJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsWAF struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsWAFJSON `json:"-"` -} - -// accountMemberRolesPermissionsWAFJSON contains the JSON metadata for the struct -// [AccountMemberRolesPermissionsWAF] -type accountMemberRolesPermissionsWAFJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsWAF) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsWAFJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsZoneSettings struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsZoneSettingsJSON `json:"-"` -} - -// accountMemberRolesPermissionsZoneSettingsJSON contains the JSON metadata for the -// struct [AccountMemberRolesPermissionsZoneSettings] -type accountMemberRolesPermissionsZoneSettingsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsZoneSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsZoneSettingsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberRolesPermissionsZones struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberRolesPermissionsZonesJSON `json:"-"` -} - -// accountMemberRolesPermissionsZonesJSON contains the JSON metadata for the struct -// [AccountMemberRolesPermissionsZones] -type accountMemberRolesPermissionsZonesJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberRolesPermissionsZones) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberRolesPermissionsZonesJSON) RawJSON() string { - return r.raw -} - -type AccountMemberUser struct { - // The contact email address of the user. - Email string `json:"email,required"` - // Identifier - ID string `json:"id"` - // User's first name - FirstName string `json:"first_name,nullable"` - // User's last name - LastName string `json:"last_name,nullable"` - // Indicates whether two-factor authentication is enabled for the user account. - // Does not apply to API authentication. - TwoFactorAuthenticationEnabled bool `json:"two_factor_authentication_enabled"` - JSON accountMemberUserJSON `json:"-"` -} - -// accountMemberUserJSON contains the JSON metadata for the struct -// [AccountMemberUser] -type accountMemberUserJSON struct { - Email apijson.Field - ID apijson.Field - FirstName apijson.Field - LastName apijson.Field - TwoFactorAuthenticationEnabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberUser) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberUserJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithID struct { - // Membership identifier tag. - ID string `json:"id,required"` - // Roles assigned to this member. - Roles []AccountMemberWithIDRole `json:"roles,required"` - Status interface{} `json:"status,required"` - User AccountMemberWithIDUser `json:"user,required"` - // The unique activation code for the account membership. - Code string `json:"code"` - JSON accountMemberWithIDJSON `json:"-"` -} - -// accountMemberWithIDJSON contains the JSON metadata for the struct -// [AccountMemberWithID] -type accountMemberWithIDJSON struct { - ID apijson.Field - Roles apijson.Field - Status apijson.Field - User apijson.Field - Code apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithID) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRole struct { - // Role identifier tag. - ID string `json:"id,required"` - // Description of role's permissions. - Description string `json:"description,required"` - // Role name. - Name string `json:"name,required"` - Permissions AccountMemberWithIDRolesPermissions `json:"permissions,required"` - JSON accountMemberWithIDRoleJSON `json:"-"` -} - -// accountMemberWithIDRoleJSON contains the JSON metadata for the struct -// [AccountMemberWithIDRole] -type accountMemberWithIDRoleJSON struct { - ID apijson.Field - Description apijson.Field - Name apijson.Field - Permissions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRole) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRoleJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissions struct { - Analytics AccountMemberWithIDRolesPermissionsAnalytics `json:"analytics"` - Billing AccountMemberWithIDRolesPermissionsBilling `json:"billing"` - CachePurge AccountMemberWithIDRolesPermissionsCachePurge `json:"cache_purge"` - DNS AccountMemberWithIDRolesPermissionsDNS `json:"dns"` - DNSRecords AccountMemberWithIDRolesPermissionsDNSRecords `json:"dns_records"` - Lb AccountMemberWithIDRolesPermissionsLb `json:"lb"` - Logs AccountMemberWithIDRolesPermissionsLogs `json:"logs"` - Organization AccountMemberWithIDRolesPermissionsOrganization `json:"organization"` - SSL AccountMemberWithIDRolesPermissionsSSL `json:"ssl"` - WAF AccountMemberWithIDRolesPermissionsWAF `json:"waf"` - ZoneSettings AccountMemberWithIDRolesPermissionsZoneSettings `json:"zone_settings"` - Zones AccountMemberWithIDRolesPermissionsZones `json:"zones"` - JSON accountMemberWithIDRolesPermissionsJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsJSON contains the JSON metadata for the -// struct [AccountMemberWithIDRolesPermissions] -type accountMemberWithIDRolesPermissionsJSON struct { - Analytics apijson.Field - Billing apijson.Field - CachePurge apijson.Field - DNS apijson.Field - DNSRecords apijson.Field - Lb apijson.Field - Logs apijson.Field - Organization apijson.Field - SSL apijson.Field - WAF apijson.Field - ZoneSettings apijson.Field - Zones apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsAnalytics struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsAnalyticsJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsAnalyticsJSON contains the JSON metadata for -// the struct [AccountMemberWithIDRolesPermissionsAnalytics] -type accountMemberWithIDRolesPermissionsAnalyticsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsAnalytics) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsAnalyticsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsBilling struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsBillingJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsBillingJSON contains the JSON metadata for -// the struct [AccountMemberWithIDRolesPermissionsBilling] -type accountMemberWithIDRolesPermissionsBillingJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsBilling) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsBillingJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsCachePurge struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsCachePurgeJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsCachePurgeJSON contains the JSON metadata for -// the struct [AccountMemberWithIDRolesPermissionsCachePurge] -type accountMemberWithIDRolesPermissionsCachePurgeJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsCachePurge) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsCachePurgeJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsDNS struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsDNSJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsDNSJSON contains the JSON metadata for the -// struct [AccountMemberWithIDRolesPermissionsDNS] -type accountMemberWithIDRolesPermissionsDNSJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsDNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsDNSJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsDNSRecords struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsDNSRecordsJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsDNSRecordsJSON contains the JSON metadata for -// the struct [AccountMemberWithIDRolesPermissionsDNSRecords] -type accountMemberWithIDRolesPermissionsDNSRecordsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsDNSRecords) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsDNSRecordsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsLb struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsLbJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsLbJSON contains the JSON metadata for the -// struct [AccountMemberWithIDRolesPermissionsLb] -type accountMemberWithIDRolesPermissionsLbJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsLb) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsLbJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsLogs struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsLogsJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsLogsJSON contains the JSON metadata for the -// struct [AccountMemberWithIDRolesPermissionsLogs] -type accountMemberWithIDRolesPermissionsLogsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsLogs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsLogsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsOrganization struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsOrganizationJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsOrganizationJSON contains the JSON metadata -// for the struct [AccountMemberWithIDRolesPermissionsOrganization] -type accountMemberWithIDRolesPermissionsOrganizationJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsOrganizationJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsSSL struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsSSLJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsSSLJSON contains the JSON metadata for the -// struct [AccountMemberWithIDRolesPermissionsSSL] -type accountMemberWithIDRolesPermissionsSSLJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsSSL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsSSLJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsWAF struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsWAFJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsWAFJSON contains the JSON metadata for the -// struct [AccountMemberWithIDRolesPermissionsWAF] -type accountMemberWithIDRolesPermissionsWAFJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsWAF) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsWAFJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsZoneSettings struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsZoneSettingsJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsZoneSettingsJSON contains the JSON metadata -// for the struct [AccountMemberWithIDRolesPermissionsZoneSettings] -type accountMemberWithIDRolesPermissionsZoneSettingsJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsZoneSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsZoneSettingsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDRolesPermissionsZones struct { - Read bool `json:"read"` - Write bool `json:"write"` - JSON accountMemberWithIDRolesPermissionsZonesJSON `json:"-"` -} - -// accountMemberWithIDRolesPermissionsZonesJSON contains the JSON metadata for the -// struct [AccountMemberWithIDRolesPermissionsZones] -type accountMemberWithIDRolesPermissionsZonesJSON struct { - Read apijson.Field - Write apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDRolesPermissionsZones) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDRolesPermissionsZonesJSON) RawJSON() string { - return r.raw -} - -type AccountMemberWithIDUser struct { - // The contact email address of the user. - Email string `json:"email,required"` - // Identifier - ID string `json:"id"` - // User's first name - FirstName string `json:"first_name,nullable"` - // User's last name - LastName string `json:"last_name,nullable"` - // Indicates whether two-factor authentication is enabled for the user account. - // Does not apply to API authentication. - TwoFactorAuthenticationEnabled bool `json:"two_factor_authentication_enabled"` - JSON accountMemberWithIDUserJSON `json:"-"` -} - -// accountMemberWithIDUserJSON contains the JSON metadata for the struct -// [AccountMemberWithIDUser] -type accountMemberWithIDUserJSON struct { - Email apijson.Field - ID apijson.Field - FirstName apijson.Field - LastName apijson.Field - TwoFactorAuthenticationEnabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberWithIDUser) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberWithIDUserJSON) RawJSON() string { - return r.raw -} - -type AccountMemberListResponse struct { - // Identifier - ID string `json:"id,required"` - // The contact email address of the user. - Email string `json:"email,required"` - // Member Name. - Name string `json:"name,required,nullable"` - // Roles assigned to this Member. - Roles []AccountMemberListResponseRole `json:"roles,required"` - // A member's status in the organization. - Status AccountMemberListResponseStatus `json:"status,required"` - JSON accountMemberListResponseJSON `json:"-"` -} - -// accountMemberListResponseJSON contains the JSON metadata for the struct -// [AccountMemberListResponse] -type accountMemberListResponseJSON struct { - ID apijson.Field - Email apijson.Field - Name apijson.Field - Roles apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberListResponseJSON) RawJSON() string { - return r.raw -} - -type AccountMemberListResponseRole struct { - // Role identifier tag. - ID string `json:"id,required"` - // Description of role's permissions. - Description string `json:"description,required"` - // Role Name. - Name string `json:"name,required"` - // Access permissions for this User. - Permissions []string `json:"permissions,required"` - JSON accountMemberListResponseRoleJSON `json:"-"` -} - -// accountMemberListResponseRoleJSON contains the JSON metadata for the struct -// [AccountMemberListResponseRole] -type accountMemberListResponseRoleJSON struct { - ID apijson.Field - Description apijson.Field - Name apijson.Field - Permissions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberListResponseRole) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberListResponseRoleJSON) RawJSON() string { - return r.raw -} - -// A member's status in the organization. -type AccountMemberListResponseStatus string - -const ( - AccountMemberListResponseStatusAccepted AccountMemberListResponseStatus = "accepted" - AccountMemberListResponseStatusInvited AccountMemberListResponseStatus = "invited" -) - -type AccountMemberDeleteResponse struct { - // Identifier - ID string `json:"id,required"` - JSON accountMemberDeleteResponseJSON `json:"-"` -} - -// accountMemberDeleteResponseJSON contains the JSON metadata for the struct -// [AccountMemberDeleteResponse] -type accountMemberDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type AccountMemberNewParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // The contact email address of the user. - Email param.Field[string] `json:"email,required"` - // Array of roles associated with this member. - Roles param.Field[[]string] `json:"roles,required"` - Status param.Field[AccountMemberNewParamsStatus] `json:"status"` -} - -func (r AccountMemberNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccountMemberNewParamsStatus string - -const ( - AccountMemberNewParamsStatusAccepted AccountMemberNewParamsStatus = "accepted" - AccountMemberNewParamsStatusPending AccountMemberNewParamsStatus = "pending" -) - -type AccountMemberNewResponseEnvelope struct { - Errors []AccountMemberNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AccountMemberNewResponseEnvelopeMessages `json:"messages,required"` - Result AccountMemberWithID `json:"result,required"` - // Whether the API call was successful - Success AccountMemberNewResponseEnvelopeSuccess `json:"success,required"` - JSON accountMemberNewResponseEnvelopeJSON `json:"-"` -} - -// accountMemberNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [AccountMemberNewResponseEnvelope] -type accountMemberNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AccountMemberNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountMemberNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// accountMemberNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccountMemberNewResponseEnvelopeErrors] -type accountMemberNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountMemberNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// accountMemberNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccountMemberNewResponseEnvelopeMessages] -type accountMemberNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AccountMemberNewResponseEnvelopeSuccess bool - -const ( - AccountMemberNewResponseEnvelopeSuccessTrue AccountMemberNewResponseEnvelopeSuccess = true -) - -type AccountMemberUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // Roles assigned to this member. - Roles param.Field[[]AccountMemberUpdateParamsRole] `json:"roles,required"` -} - -func (r AccountMemberUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccountMemberUpdateParamsRole struct { - // Role identifier tag. - ID param.Field[string] `json:"id,required"` -} - -func (r AccountMemberUpdateParamsRole) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccountMemberUpdateParamsRolesPermissions struct { - Analytics param.Field[AccountMemberUpdateParamsRolesPermissionsAnalytics] `json:"analytics"` - Billing param.Field[AccountMemberUpdateParamsRolesPermissionsBilling] `json:"billing"` - CachePurge param.Field[AccountMemberUpdateParamsRolesPermissionsCachePurge] `json:"cache_purge"` - DNS param.Field[AccountMemberUpdateParamsRolesPermissionsDNS] `json:"dns"` - DNSRecords param.Field[AccountMemberUpdateParamsRolesPermissionsDNSRecords] `json:"dns_records"` - Lb param.Field[AccountMemberUpdateParamsRolesPermissionsLb] `json:"lb"` - Logs param.Field[AccountMemberUpdateParamsRolesPermissionsLogs] `json:"logs"` - Organization param.Field[AccountMemberUpdateParamsRolesPermissionsOrganization] `json:"organization"` - SSL param.Field[AccountMemberUpdateParamsRolesPermissionsSSL] `json:"ssl"` - WAF param.Field[AccountMemberUpdateParamsRolesPermissionsWAF] `json:"waf"` - ZoneSettings param.Field[AccountMemberUpdateParamsRolesPermissionsZoneSettings] `json:"zone_settings"` - Zones param.Field[AccountMemberUpdateParamsRolesPermissionsZones] `json:"zones"` -} - -func (r AccountMemberUpdateParamsRolesPermissions) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccountMemberUpdateParamsRolesPermissionsAnalytics struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r AccountMemberUpdateParamsRolesPermissionsAnalytics) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccountMemberUpdateParamsRolesPermissionsBilling struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r AccountMemberUpdateParamsRolesPermissionsBilling) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccountMemberUpdateParamsRolesPermissionsCachePurge struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r AccountMemberUpdateParamsRolesPermissionsCachePurge) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccountMemberUpdateParamsRolesPermissionsDNS struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r AccountMemberUpdateParamsRolesPermissionsDNS) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccountMemberUpdateParamsRolesPermissionsDNSRecords struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r AccountMemberUpdateParamsRolesPermissionsDNSRecords) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccountMemberUpdateParamsRolesPermissionsLb struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r AccountMemberUpdateParamsRolesPermissionsLb) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccountMemberUpdateParamsRolesPermissionsLogs struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r AccountMemberUpdateParamsRolesPermissionsLogs) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccountMemberUpdateParamsRolesPermissionsOrganization struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r AccountMemberUpdateParamsRolesPermissionsOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccountMemberUpdateParamsRolesPermissionsSSL struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r AccountMemberUpdateParamsRolesPermissionsSSL) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccountMemberUpdateParamsRolesPermissionsWAF struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r AccountMemberUpdateParamsRolesPermissionsWAF) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccountMemberUpdateParamsRolesPermissionsZoneSettings struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r AccountMemberUpdateParamsRolesPermissionsZoneSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccountMemberUpdateParamsRolesPermissionsZones struct { - Read param.Field[bool] `json:"read"` - Write param.Field[bool] `json:"write"` -} - -func (r AccountMemberUpdateParamsRolesPermissionsZones) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AccountMemberUpdateResponseEnvelope struct { - Errors []AccountMemberUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AccountMemberUpdateResponseEnvelopeMessages `json:"messages,required"` - Result AccountMember `json:"result,required"` - // Whether the API call was successful - Success AccountMemberUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON accountMemberUpdateResponseEnvelopeJSON `json:"-"` -} - -// accountMemberUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [AccountMemberUpdateResponseEnvelope] -type accountMemberUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AccountMemberUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountMemberUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// accountMemberUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccountMemberUpdateResponseEnvelopeErrors] -type accountMemberUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountMemberUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// accountMemberUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AccountMemberUpdateResponseEnvelopeMessages] -type accountMemberUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AccountMemberUpdateResponseEnvelopeSuccess bool - -const ( - AccountMemberUpdateResponseEnvelopeSuccessTrue AccountMemberUpdateResponseEnvelopeSuccess = true -) - -type AccountMemberListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // Direction to order results. - Direction param.Field[AccountMemberListParamsDirection] `query:"direction"` - // Field to order results by. - Order param.Field[AccountMemberListParamsOrder] `query:"order"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // Maximum number of results per page. - PerPage param.Field[float64] `query:"per_page"` - // A member's status in the account. - Status param.Field[AccountMemberListParamsStatus] `query:"status"` -} - -// URLQuery serializes [AccountMemberListParams]'s query parameters as -// `url.Values`. -func (r AccountMemberListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Direction to order results. -type AccountMemberListParamsDirection string - -const ( - AccountMemberListParamsDirectionAsc AccountMemberListParamsDirection = "asc" - AccountMemberListParamsDirectionDesc AccountMemberListParamsDirection = "desc" -) - -// Field to order results by. -type AccountMemberListParamsOrder string - -const ( - AccountMemberListParamsOrderUserFirstName AccountMemberListParamsOrder = "user.first_name" - AccountMemberListParamsOrderUserLastName AccountMemberListParamsOrder = "user.last_name" - AccountMemberListParamsOrderUserEmail AccountMemberListParamsOrder = "user.email" - AccountMemberListParamsOrderStatus AccountMemberListParamsOrder = "status" -) - -// A member's status in the account. -type AccountMemberListParamsStatus string - -const ( - AccountMemberListParamsStatusAccepted AccountMemberListParamsStatus = "accepted" - AccountMemberListParamsStatusPending AccountMemberListParamsStatus = "pending" - AccountMemberListParamsStatusRejected AccountMemberListParamsStatus = "rejected" -) - -type AccountMemberDeleteParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type AccountMemberDeleteResponseEnvelope struct { - Errors []AccountMemberDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AccountMemberDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AccountMemberDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AccountMemberDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON accountMemberDeleteResponseEnvelopeJSON `json:"-"` -} - -// accountMemberDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [AccountMemberDeleteResponseEnvelope] -type accountMemberDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AccountMemberDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountMemberDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// accountMemberDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccountMemberDeleteResponseEnvelopeErrors] -type accountMemberDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountMemberDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// accountMemberDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AccountMemberDeleteResponseEnvelopeMessages] -type accountMemberDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AccountMemberDeleteResponseEnvelopeSuccess bool - -const ( - AccountMemberDeleteResponseEnvelopeSuccessTrue AccountMemberDeleteResponseEnvelopeSuccess = true -) - -type AccountMemberGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type AccountMemberGetResponseEnvelope struct { - Errors []AccountMemberGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AccountMemberGetResponseEnvelopeMessages `json:"messages,required"` - Result AccountMember `json:"result,required"` - // Whether the API call was successful - Success AccountMemberGetResponseEnvelopeSuccess `json:"success,required"` - JSON accountMemberGetResponseEnvelopeJSON `json:"-"` -} - -// accountMemberGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [AccountMemberGetResponseEnvelope] -type accountMemberGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AccountMemberGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountMemberGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// accountMemberGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccountMemberGetResponseEnvelopeErrors] -type accountMemberGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccountMemberGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountMemberGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// accountMemberGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccountMemberGetResponseEnvelopeMessages] -type accountMemberGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountMemberGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountMemberGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AccountMemberGetResponseEnvelopeSuccess bool - -const ( - AccountMemberGetResponseEnvelopeSuccessTrue AccountMemberGetResponseEnvelopeSuccess = true -) diff --git a/accountmember_test.go b/accountmember_test.go deleted file mode 100644 index d207c277d84..00000000000 --- a/accountmember_test.go +++ /dev/null @@ -1,171 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAccountMemberNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Accounts.Members.New(context.TODO(), cloudflare.AccountMemberNewParams{ - AccountID: cloudflare.F[any](map[string]interface{}{}), - Email: cloudflare.F("user@example.com"), - Roles: cloudflare.F([]string{"3536bcfad5faccb999b47003c79917fb", "3536bcfad5faccb999b47003c79917fb", "3536bcfad5faccb999b47003c79917fb"}), - Status: cloudflare.F(cloudflare.AccountMemberNewParamsStatusAccepted), - }) - 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 TestAccountMemberUpdate(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("user@example.com"), - ) - _, err := client.Accounts.Members.Update( - context.TODO(), - "4536bcfad5faccb111b47003c79917fa", - cloudflare.AccountMemberUpdateParams{ - AccountID: cloudflare.F[any](map[string]interface{}{}), - Roles: cloudflare.F([]cloudflare.AccountMemberUpdateParamsRole{{ - ID: cloudflare.F("3536bcfad5faccb999b47003c79917fb"), - }, { - ID: cloudflare.F("3536bcfad5faccb999b47003c79917fb"), - }, { - ID: cloudflare.F("3536bcfad5faccb999b47003c79917fb"), - }}), - }, - ) - 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 TestAccountMemberListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Accounts.Members.List(context.TODO(), cloudflare.AccountMemberListParams{ - AccountID: cloudflare.F[any](map[string]interface{}{}), - Direction: cloudflare.F(cloudflare.AccountMemberListParamsDirectionDesc), - Order: cloudflare.F(cloudflare.AccountMemberListParamsOrderStatus), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(5.000000), - Status: cloudflare.F(cloudflare.AccountMemberListParamsStatusAccepted), - }) - 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 TestAccountMemberDelete(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("user@example.com"), - ) - _, err := client.Accounts.Members.Delete( - context.TODO(), - "4536bcfad5faccb111b47003c79917fa", - cloudflare.AccountMemberDeleteParams{ - AccountID: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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 TestAccountMemberGet(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("user@example.com"), - ) - _, err := client.Accounts.Members.Get( - context.TODO(), - "4536bcfad5faccb111b47003c79917fa", - cloudflare.AccountMemberGetParams{ - AccountID: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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/accountrole.go b/accountrole.go deleted file mode 100644 index 9d734d7f5e8..00000000000 --- a/accountrole.go +++ /dev/null @@ -1,311 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// AccountRoleService 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 [NewAccountRoleService] method -// instead. -type AccountRoleService struct { - Options []option.RequestOption -} - -// NewAccountRoleService 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 NewAccountRoleService(opts ...option.RequestOption) (r *AccountRoleService) { - r = &AccountRoleService{} - r.Options = opts - return -} - -// Get all available roles for an account. -func (r *AccountRoleService) List(ctx context.Context, query AccountRoleListParams, opts ...option.RequestOption) (res *[]AccountRoleListResponse, err error) { - opts = append(r.Options[:], opts...) - var env AccountRoleListResponseEnvelope - path := fmt.Sprintf("accounts/%v/roles", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get information about a specific role for an account. -func (r *AccountRoleService) Get(ctx context.Context, roleID interface{}, query AccountRoleGetParams, opts ...option.RequestOption) (res *AccountRoleGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env AccountRoleGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/roles/%v", query.AccountID, roleID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type AccountRoleListResponse struct { - // Role identifier tag. - ID string `json:"id,required"` - // Description of role's permissions. - Description string `json:"description,required"` - // Role Name. - Name string `json:"name,required"` - // Access permissions for this User. - Permissions []string `json:"permissions,required"` - JSON accountRoleListResponseJSON `json:"-"` -} - -// accountRoleListResponseJSON contains the JSON metadata for the struct -// [AccountRoleListResponse] -type accountRoleListResponseJSON struct { - ID apijson.Field - Description apijson.Field - Name apijson.Field - Permissions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountRoleListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountRoleListResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [AccountRoleGetResponseUnknown] or [shared.UnionString]. -type AccountRoleGetResponse interface { - ImplementsAccountRoleGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AccountRoleGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type AccountRoleListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type AccountRoleListResponseEnvelope struct { - Errors []AccountRoleListResponseEnvelopeErrors `json:"errors,required"` - Messages []AccountRoleListResponseEnvelopeMessages `json:"messages,required"` - Result []AccountRoleListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AccountRoleListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AccountRoleListResponseEnvelopeResultInfo `json:"result_info"` - JSON accountRoleListResponseEnvelopeJSON `json:"-"` -} - -// accountRoleListResponseEnvelopeJSON contains the JSON metadata for the struct -// [AccountRoleListResponseEnvelope] -type accountRoleListResponseEnvelopeJSON 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 *AccountRoleListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountRoleListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AccountRoleListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountRoleListResponseEnvelopeErrorsJSON `json:"-"` -} - -// accountRoleListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccountRoleListResponseEnvelopeErrors] -type accountRoleListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountRoleListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountRoleListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccountRoleListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountRoleListResponseEnvelopeMessagesJSON `json:"-"` -} - -// accountRoleListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccountRoleListResponseEnvelopeMessages] -type accountRoleListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountRoleListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountRoleListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AccountRoleListResponseEnvelopeSuccess bool - -const ( - AccountRoleListResponseEnvelopeSuccessTrue AccountRoleListResponseEnvelopeSuccess = true -) - -type AccountRoleListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON accountRoleListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// accountRoleListResponseEnvelopeResultInfoJSON contains the JSON metadata for the -// struct [AccountRoleListResponseEnvelopeResultInfo] -type accountRoleListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountRoleListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountRoleListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type AccountRoleGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type AccountRoleGetResponseEnvelope struct { - Errors []AccountRoleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AccountRoleGetResponseEnvelopeMessages `json:"messages,required"` - Result AccountRoleGetResponse `json:"result,required"` - // Whether the API call was successful - Success AccountRoleGetResponseEnvelopeSuccess `json:"success,required"` - JSON accountRoleGetResponseEnvelopeJSON `json:"-"` -} - -// accountRoleGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [AccountRoleGetResponseEnvelope] -type accountRoleGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountRoleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountRoleGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AccountRoleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountRoleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// accountRoleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AccountRoleGetResponseEnvelopeErrors] -type accountRoleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountRoleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountRoleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AccountRoleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON accountRoleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// accountRoleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AccountRoleGetResponseEnvelopeMessages] -type accountRoleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AccountRoleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r accountRoleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AccountRoleGetResponseEnvelopeSuccess bool - -const ( - AccountRoleGetResponseEnvelopeSuccessTrue AccountRoleGetResponseEnvelopeSuccess = true -) diff --git a/accountrole_test.go b/accountrole_test.go deleted file mode 100644 index dbb441553ec..00000000000 --- a/accountrole_test.go +++ /dev/null @@ -1,70 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAccountRoleList(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("user@example.com"), - ) - _, err := client.Accounts.Roles.List(context.TODO(), cloudflare.AccountRoleListParams{ - AccountID: cloudflare.F[any](map[string]interface{}{}), - }) - 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 TestAccountRoleGet(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("user@example.com"), - ) - _, err := client.Accounts.Roles.Get( - context.TODO(), - map[string]interface{}{}, - cloudflare.AccountRoleGetParams{ - AccountID: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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/account.go b/accounts/account.go similarity index 97% rename from account.go rename to accounts/account.go index 802ea57d401..d7d2c10c12f 100644 --- a/account.go +++ b/accounts/account.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package accounts import ( "context" @@ -25,8 +25,8 @@ import ( // service directly, and instead use the [NewAccountService] method instead. type AccountService struct { Options []option.RequestOption - Members *AccountMemberService - Roles *AccountRoleService + Members *MemberService + Roles *RoleService } // NewAccountService generates a new service that applies the given options to each @@ -35,8 +35,8 @@ type AccountService struct { func NewAccountService(opts ...option.RequestOption) (r *AccountService) { r = &AccountService{} r.Options = opts - r.Members = NewAccountMemberService(opts...) - r.Roles = NewAccountRoleService(opts...) + r.Members = NewMemberService(opts...) + r.Roles = NewRoleService(opts...) return } @@ -178,9 +178,10 @@ const ( AccountSettingsDefaultNameserversCustomTenant AccountSettingsDefaultNameservers = "custom.tenant" ) -// Union satisfied by [AccountUpdateResponseUnknown] or [shared.UnionString]. +// Union satisfied by [accounts.AccountUpdateResponseUnknown] or +// [shared.UnionString]. type AccountUpdateResponse interface { - ImplementsAccountUpdateResponse() + ImplementsAccountsAccountUpdateResponse() } func init() { @@ -196,9 +197,9 @@ func init() { type AccountListResponse = interface{} -// Union satisfied by [AccountGetResponseUnknown] or [shared.UnionString]. +// Union satisfied by [accounts.AccountGetResponseUnknown] or [shared.UnionString]. type AccountGetResponse interface { - ImplementsAccountGetResponse() + ImplementsAccountsAccountGetResponse() } func init() { diff --git a/account_test.go b/accounts/account_test.go similarity index 81% rename from account_test.go rename to accounts/account_test.go index a21b375e1d1..07330e3865d 100644 --- a/account_test.go +++ b/accounts/account_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package accounts_test import ( "context" @@ -9,6 +9,7 @@ import ( "testing" "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" ) @@ -27,11 +28,11 @@ func TestAccountUpdateWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Accounts.Update(context.TODO(), cloudflare.AccountUpdateParams{ + _, err := client.Accounts.Update(context.TODO(), accounts.AccountUpdateParams{ AccountID: cloudflare.F[any](map[string]interface{}{}), Name: cloudflare.F("Demo Account"), - Settings: cloudflare.F(cloudflare.AccountUpdateParamsSettings{ - DefaultNameservers: cloudflare.F(cloudflare.AccountUpdateParamsSettingsDefaultNameserversCloudflareStandard), + Settings: cloudflare.F(accounts.AccountUpdateParamsSettings{ + DefaultNameservers: cloudflare.F(accounts.AccountUpdateParamsSettingsDefaultNameserversCloudflareStandard), EnforceTwofactor: cloudflare.F(true), UseAccountCustomNSByDefault: cloudflare.F(true), }), @@ -59,8 +60,8 @@ func TestAccountListWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Accounts.List(context.TODO(), cloudflare.AccountListParams{ - Direction: cloudflare.F(cloudflare.AccountListParamsDirectionDesc), + _, err := client.Accounts.List(context.TODO(), accounts.AccountListParams{ + Direction: cloudflare.F(accounts.AccountListParamsDirectionDesc), Page: cloudflare.F(1.000000), PerPage: cloudflare.F(5.000000), }) @@ -87,7 +88,7 @@ func TestAccountGet(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Accounts.Get(context.TODO(), cloudflare.AccountGetParams{ + _, err := client.Accounts.Get(context.TODO(), accounts.AccountGetParams{ AccountID: cloudflare.F[any](map[string]interface{}{}), }) if err != nil { diff --git a/accounts/aliases.go b/accounts/aliases.go new file mode 100644 index 00000000000..e5cdc5c917e --- /dev/null +++ b/accounts/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package accounts + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/accounts/member.go b/accounts/member.go new file mode 100644 index 00000000000..0b7ac37a83e --- /dev/null +++ b/accounts/member.go @@ -0,0 +1,1548 @@ +// File generated from our OpenAPI spec by Stainless. + +package accounts + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" +) + +// MemberService 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 [NewMemberService] method instead. +type MemberService struct { + Options []option.RequestOption +} + +// NewMemberService 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 NewMemberService(opts ...option.RequestOption) (r *MemberService) { + r = &MemberService{} + r.Options = opts + return +} + +// Add a user to the list of members for this account. +func (r *MemberService) New(ctx context.Context, params MemberNewParams, opts ...option.RequestOption) (res *AccountMemberWithID, err error) { + opts = append(r.Options[:], opts...) + var env MemberNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/members", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Modify an account member. +func (r *MemberService) Update(ctx context.Context, memberID string, params MemberUpdateParams, opts ...option.RequestOption) (res *AccountMember, err error) { + opts = append(r.Options[:], opts...) + var env MemberUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/members/%s", params.AccountID, memberID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List all members of an account. +func (r *MemberService) List(ctx context.Context, params MemberListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[MemberListResponse], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("accounts/%v/members", params.AccountID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// List all members of an account. +func (r *MemberService) ListAutoPaging(ctx context.Context, params MemberListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[MemberListResponse] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) +} + +// Remove a member from an account. +func (r *MemberService) Delete(ctx context.Context, memberID string, body MemberDeleteParams, opts ...option.RequestOption) (res *MemberDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env MemberDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%v/members/%s", body.AccountID, memberID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get information about a specific member of an account. +func (r *MemberService) Get(ctx context.Context, memberID string, query MemberGetParams, opts ...option.RequestOption) (res *AccountMember, err error) { + opts = append(r.Options[:], opts...) + var env MemberGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/members/%s", query.AccountID, memberID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AccountMember struct { + // Membership identifier tag. + ID string `json:"id,required"` + // Roles assigned to this member. + Roles []AccountMemberRole `json:"roles,required"` + Status interface{} `json:"status,required"` + User AccountMemberUser `json:"user,required"` + JSON accountMemberJSON `json:"-"` +} + +// accountMemberJSON contains the JSON metadata for the struct [AccountMember] +type accountMemberJSON struct { + ID apijson.Field + Roles apijson.Field + Status apijson.Field + User apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMember) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberJSON) RawJSON() string { + return r.raw +} + +type AccountMemberRole struct { + // Role identifier tag. + ID string `json:"id,required"` + // Description of role's permissions. + Description string `json:"description,required"` + // Role name. + Name string `json:"name,required"` + Permissions AccountMemberRolesPermissions `json:"permissions,required"` + JSON accountMemberRoleJSON `json:"-"` +} + +// accountMemberRoleJSON contains the JSON metadata for the struct +// [AccountMemberRole] +type accountMemberRoleJSON struct { + ID apijson.Field + Description apijson.Field + Name apijson.Field + Permissions apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberRole) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberRoleJSON) RawJSON() string { + return r.raw +} + +type AccountMemberRolesPermissions struct { + Analytics AccountMemberRolesPermissionsAnalytics `json:"analytics"` + Billing AccountMemberRolesPermissionsBilling `json:"billing"` + CachePurge AccountMemberRolesPermissionsCachePurge `json:"cache_purge"` + DNS AccountMemberRolesPermissionsDNS `json:"dns"` + DNSRecords AccountMemberRolesPermissionsDNSRecords `json:"dns_records"` + Lb AccountMemberRolesPermissionsLb `json:"lb"` + Logs AccountMemberRolesPermissionsLogs `json:"logs"` + Organization AccountMemberRolesPermissionsOrganization `json:"organization"` + SSL AccountMemberRolesPermissionsSSL `json:"ssl"` + WAF AccountMemberRolesPermissionsWAF `json:"waf"` + ZoneSettings AccountMemberRolesPermissionsZoneSettings `json:"zone_settings"` + Zones AccountMemberRolesPermissionsZones `json:"zones"` + JSON accountMemberRolesPermissionsJSON `json:"-"` +} + +// accountMemberRolesPermissionsJSON contains the JSON metadata for the struct +// [AccountMemberRolesPermissions] +type accountMemberRolesPermissionsJSON struct { + Analytics apijson.Field + Billing apijson.Field + CachePurge apijson.Field + DNS apijson.Field + DNSRecords apijson.Field + Lb apijson.Field + Logs apijson.Field + Organization apijson.Field + SSL apijson.Field + WAF apijson.Field + ZoneSettings apijson.Field + Zones apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberRolesPermissions) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberRolesPermissionsJSON) RawJSON() string { + return r.raw +} + +type AccountMemberRolesPermissionsAnalytics struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberRolesPermissionsAnalyticsJSON `json:"-"` +} + +// accountMemberRolesPermissionsAnalyticsJSON contains the JSON metadata for the +// struct [AccountMemberRolesPermissionsAnalytics] +type accountMemberRolesPermissionsAnalyticsJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberRolesPermissionsAnalytics) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberRolesPermissionsAnalyticsJSON) RawJSON() string { + return r.raw +} + +type AccountMemberRolesPermissionsBilling struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberRolesPermissionsBillingJSON `json:"-"` +} + +// accountMemberRolesPermissionsBillingJSON contains the JSON metadata for the +// struct [AccountMemberRolesPermissionsBilling] +type accountMemberRolesPermissionsBillingJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberRolesPermissionsBilling) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberRolesPermissionsBillingJSON) RawJSON() string { + return r.raw +} + +type AccountMemberRolesPermissionsCachePurge struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberRolesPermissionsCachePurgeJSON `json:"-"` +} + +// accountMemberRolesPermissionsCachePurgeJSON contains the JSON metadata for the +// struct [AccountMemberRolesPermissionsCachePurge] +type accountMemberRolesPermissionsCachePurgeJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberRolesPermissionsCachePurge) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberRolesPermissionsCachePurgeJSON) RawJSON() string { + return r.raw +} + +type AccountMemberRolesPermissionsDNS struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberRolesPermissionsDNSJSON `json:"-"` +} + +// accountMemberRolesPermissionsDNSJSON contains the JSON metadata for the struct +// [AccountMemberRolesPermissionsDNS] +type accountMemberRolesPermissionsDNSJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberRolesPermissionsDNS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberRolesPermissionsDNSJSON) RawJSON() string { + return r.raw +} + +type AccountMemberRolesPermissionsDNSRecords struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberRolesPermissionsDNSRecordsJSON `json:"-"` +} + +// accountMemberRolesPermissionsDNSRecordsJSON contains the JSON metadata for the +// struct [AccountMemberRolesPermissionsDNSRecords] +type accountMemberRolesPermissionsDNSRecordsJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberRolesPermissionsDNSRecords) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberRolesPermissionsDNSRecordsJSON) RawJSON() string { + return r.raw +} + +type AccountMemberRolesPermissionsLb struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberRolesPermissionsLbJSON `json:"-"` +} + +// accountMemberRolesPermissionsLbJSON contains the JSON metadata for the struct +// [AccountMemberRolesPermissionsLb] +type accountMemberRolesPermissionsLbJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberRolesPermissionsLb) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberRolesPermissionsLbJSON) RawJSON() string { + return r.raw +} + +type AccountMemberRolesPermissionsLogs struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberRolesPermissionsLogsJSON `json:"-"` +} + +// accountMemberRolesPermissionsLogsJSON contains the JSON metadata for the struct +// [AccountMemberRolesPermissionsLogs] +type accountMemberRolesPermissionsLogsJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberRolesPermissionsLogs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberRolesPermissionsLogsJSON) RawJSON() string { + return r.raw +} + +type AccountMemberRolesPermissionsOrganization struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberRolesPermissionsOrganizationJSON `json:"-"` +} + +// accountMemberRolesPermissionsOrganizationJSON contains the JSON metadata for the +// struct [AccountMemberRolesPermissionsOrganization] +type accountMemberRolesPermissionsOrganizationJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberRolesPermissionsOrganization) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberRolesPermissionsOrganizationJSON) RawJSON() string { + return r.raw +} + +type AccountMemberRolesPermissionsSSL struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberRolesPermissionsSSLJSON `json:"-"` +} + +// accountMemberRolesPermissionsSSLJSON contains the JSON metadata for the struct +// [AccountMemberRolesPermissionsSSL] +type accountMemberRolesPermissionsSSLJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberRolesPermissionsSSL) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberRolesPermissionsSSLJSON) RawJSON() string { + return r.raw +} + +type AccountMemberRolesPermissionsWAF struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberRolesPermissionsWAFJSON `json:"-"` +} + +// accountMemberRolesPermissionsWAFJSON contains the JSON metadata for the struct +// [AccountMemberRolesPermissionsWAF] +type accountMemberRolesPermissionsWAFJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberRolesPermissionsWAF) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberRolesPermissionsWAFJSON) RawJSON() string { + return r.raw +} + +type AccountMemberRolesPermissionsZoneSettings struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberRolesPermissionsZoneSettingsJSON `json:"-"` +} + +// accountMemberRolesPermissionsZoneSettingsJSON contains the JSON metadata for the +// struct [AccountMemberRolesPermissionsZoneSettings] +type accountMemberRolesPermissionsZoneSettingsJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberRolesPermissionsZoneSettings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberRolesPermissionsZoneSettingsJSON) RawJSON() string { + return r.raw +} + +type AccountMemberRolesPermissionsZones struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberRolesPermissionsZonesJSON `json:"-"` +} + +// accountMemberRolesPermissionsZonesJSON contains the JSON metadata for the struct +// [AccountMemberRolesPermissionsZones] +type accountMemberRolesPermissionsZonesJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberRolesPermissionsZones) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberRolesPermissionsZonesJSON) RawJSON() string { + return r.raw +} + +type AccountMemberUser struct { + // The contact email address of the user. + Email string `json:"email,required"` + // Identifier + ID string `json:"id"` + // User's first name + FirstName string `json:"first_name,nullable"` + // User's last name + LastName string `json:"last_name,nullable"` + // Indicates whether two-factor authentication is enabled for the user account. + // Does not apply to API authentication. + TwoFactorAuthenticationEnabled bool `json:"two_factor_authentication_enabled"` + JSON accountMemberUserJSON `json:"-"` +} + +// accountMemberUserJSON contains the JSON metadata for the struct +// [AccountMemberUser] +type accountMemberUserJSON struct { + Email apijson.Field + ID apijson.Field + FirstName apijson.Field + LastName apijson.Field + TwoFactorAuthenticationEnabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberUser) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberUserJSON) RawJSON() string { + return r.raw +} + +type AccountMemberWithID struct { + // Membership identifier tag. + ID string `json:"id,required"` + // Roles assigned to this member. + Roles []AccountMemberWithIDRole `json:"roles,required"` + Status interface{} `json:"status,required"` + User AccountMemberWithIDUser `json:"user,required"` + // The unique activation code for the account membership. + Code string `json:"code"` + JSON accountMemberWithIDJSON `json:"-"` +} + +// accountMemberWithIDJSON contains the JSON metadata for the struct +// [AccountMemberWithID] +type accountMemberWithIDJSON struct { + ID apijson.Field + Roles apijson.Field + Status apijson.Field + User apijson.Field + Code apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberWithID) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberWithIDJSON) RawJSON() string { + return r.raw +} + +type AccountMemberWithIDRole struct { + // Role identifier tag. + ID string `json:"id,required"` + // Description of role's permissions. + Description string `json:"description,required"` + // Role name. + Name string `json:"name,required"` + Permissions AccountMemberWithIDRolesPermissions `json:"permissions,required"` + JSON accountMemberWithIDRoleJSON `json:"-"` +} + +// accountMemberWithIDRoleJSON contains the JSON metadata for the struct +// [AccountMemberWithIDRole] +type accountMemberWithIDRoleJSON struct { + ID apijson.Field + Description apijson.Field + Name apijson.Field + Permissions apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberWithIDRole) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberWithIDRoleJSON) RawJSON() string { + return r.raw +} + +type AccountMemberWithIDRolesPermissions struct { + Analytics AccountMemberWithIDRolesPermissionsAnalytics `json:"analytics"` + Billing AccountMemberWithIDRolesPermissionsBilling `json:"billing"` + CachePurge AccountMemberWithIDRolesPermissionsCachePurge `json:"cache_purge"` + DNS AccountMemberWithIDRolesPermissionsDNS `json:"dns"` + DNSRecords AccountMemberWithIDRolesPermissionsDNSRecords `json:"dns_records"` + Lb AccountMemberWithIDRolesPermissionsLb `json:"lb"` + Logs AccountMemberWithIDRolesPermissionsLogs `json:"logs"` + Organization AccountMemberWithIDRolesPermissionsOrganization `json:"organization"` + SSL AccountMemberWithIDRolesPermissionsSSL `json:"ssl"` + WAF AccountMemberWithIDRolesPermissionsWAF `json:"waf"` + ZoneSettings AccountMemberWithIDRolesPermissionsZoneSettings `json:"zone_settings"` + Zones AccountMemberWithIDRolesPermissionsZones `json:"zones"` + JSON accountMemberWithIDRolesPermissionsJSON `json:"-"` +} + +// accountMemberWithIDRolesPermissionsJSON contains the JSON metadata for the +// struct [AccountMemberWithIDRolesPermissions] +type accountMemberWithIDRolesPermissionsJSON struct { + Analytics apijson.Field + Billing apijson.Field + CachePurge apijson.Field + DNS apijson.Field + DNSRecords apijson.Field + Lb apijson.Field + Logs apijson.Field + Organization apijson.Field + SSL apijson.Field + WAF apijson.Field + ZoneSettings apijson.Field + Zones apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberWithIDRolesPermissions) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberWithIDRolesPermissionsJSON) RawJSON() string { + return r.raw +} + +type AccountMemberWithIDRolesPermissionsAnalytics struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberWithIDRolesPermissionsAnalyticsJSON `json:"-"` +} + +// accountMemberWithIDRolesPermissionsAnalyticsJSON contains the JSON metadata for +// the struct [AccountMemberWithIDRolesPermissionsAnalytics] +type accountMemberWithIDRolesPermissionsAnalyticsJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberWithIDRolesPermissionsAnalytics) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberWithIDRolesPermissionsAnalyticsJSON) RawJSON() string { + return r.raw +} + +type AccountMemberWithIDRolesPermissionsBilling struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberWithIDRolesPermissionsBillingJSON `json:"-"` +} + +// accountMemberWithIDRolesPermissionsBillingJSON contains the JSON metadata for +// the struct [AccountMemberWithIDRolesPermissionsBilling] +type accountMemberWithIDRolesPermissionsBillingJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberWithIDRolesPermissionsBilling) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberWithIDRolesPermissionsBillingJSON) RawJSON() string { + return r.raw +} + +type AccountMemberWithIDRolesPermissionsCachePurge struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberWithIDRolesPermissionsCachePurgeJSON `json:"-"` +} + +// accountMemberWithIDRolesPermissionsCachePurgeJSON contains the JSON metadata for +// the struct [AccountMemberWithIDRolesPermissionsCachePurge] +type accountMemberWithIDRolesPermissionsCachePurgeJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberWithIDRolesPermissionsCachePurge) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberWithIDRolesPermissionsCachePurgeJSON) RawJSON() string { + return r.raw +} + +type AccountMemberWithIDRolesPermissionsDNS struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberWithIDRolesPermissionsDNSJSON `json:"-"` +} + +// accountMemberWithIDRolesPermissionsDNSJSON contains the JSON metadata for the +// struct [AccountMemberWithIDRolesPermissionsDNS] +type accountMemberWithIDRolesPermissionsDNSJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberWithIDRolesPermissionsDNS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberWithIDRolesPermissionsDNSJSON) RawJSON() string { + return r.raw +} + +type AccountMemberWithIDRolesPermissionsDNSRecords struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberWithIDRolesPermissionsDNSRecordsJSON `json:"-"` +} + +// accountMemberWithIDRolesPermissionsDNSRecordsJSON contains the JSON metadata for +// the struct [AccountMemberWithIDRolesPermissionsDNSRecords] +type accountMemberWithIDRolesPermissionsDNSRecordsJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberWithIDRolesPermissionsDNSRecords) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberWithIDRolesPermissionsDNSRecordsJSON) RawJSON() string { + return r.raw +} + +type AccountMemberWithIDRolesPermissionsLb struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberWithIDRolesPermissionsLbJSON `json:"-"` +} + +// accountMemberWithIDRolesPermissionsLbJSON contains the JSON metadata for the +// struct [AccountMemberWithIDRolesPermissionsLb] +type accountMemberWithIDRolesPermissionsLbJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberWithIDRolesPermissionsLb) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberWithIDRolesPermissionsLbJSON) RawJSON() string { + return r.raw +} + +type AccountMemberWithIDRolesPermissionsLogs struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberWithIDRolesPermissionsLogsJSON `json:"-"` +} + +// accountMemberWithIDRolesPermissionsLogsJSON contains the JSON metadata for the +// struct [AccountMemberWithIDRolesPermissionsLogs] +type accountMemberWithIDRolesPermissionsLogsJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberWithIDRolesPermissionsLogs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberWithIDRolesPermissionsLogsJSON) RawJSON() string { + return r.raw +} + +type AccountMemberWithIDRolesPermissionsOrganization struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberWithIDRolesPermissionsOrganizationJSON `json:"-"` +} + +// accountMemberWithIDRolesPermissionsOrganizationJSON contains the JSON metadata +// for the struct [AccountMemberWithIDRolesPermissionsOrganization] +type accountMemberWithIDRolesPermissionsOrganizationJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberWithIDRolesPermissionsOrganization) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberWithIDRolesPermissionsOrganizationJSON) RawJSON() string { + return r.raw +} + +type AccountMemberWithIDRolesPermissionsSSL struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberWithIDRolesPermissionsSSLJSON `json:"-"` +} + +// accountMemberWithIDRolesPermissionsSSLJSON contains the JSON metadata for the +// struct [AccountMemberWithIDRolesPermissionsSSL] +type accountMemberWithIDRolesPermissionsSSLJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberWithIDRolesPermissionsSSL) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberWithIDRolesPermissionsSSLJSON) RawJSON() string { + return r.raw +} + +type AccountMemberWithIDRolesPermissionsWAF struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberWithIDRolesPermissionsWAFJSON `json:"-"` +} + +// accountMemberWithIDRolesPermissionsWAFJSON contains the JSON metadata for the +// struct [AccountMemberWithIDRolesPermissionsWAF] +type accountMemberWithIDRolesPermissionsWAFJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberWithIDRolesPermissionsWAF) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberWithIDRolesPermissionsWAFJSON) RawJSON() string { + return r.raw +} + +type AccountMemberWithIDRolesPermissionsZoneSettings struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberWithIDRolesPermissionsZoneSettingsJSON `json:"-"` +} + +// accountMemberWithIDRolesPermissionsZoneSettingsJSON contains the JSON metadata +// for the struct [AccountMemberWithIDRolesPermissionsZoneSettings] +type accountMemberWithIDRolesPermissionsZoneSettingsJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberWithIDRolesPermissionsZoneSettings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberWithIDRolesPermissionsZoneSettingsJSON) RawJSON() string { + return r.raw +} + +type AccountMemberWithIDRolesPermissionsZones struct { + Read bool `json:"read"` + Write bool `json:"write"` + JSON accountMemberWithIDRolesPermissionsZonesJSON `json:"-"` +} + +// accountMemberWithIDRolesPermissionsZonesJSON contains the JSON metadata for the +// struct [AccountMemberWithIDRolesPermissionsZones] +type accountMemberWithIDRolesPermissionsZonesJSON struct { + Read apijson.Field + Write apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberWithIDRolesPermissionsZones) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberWithIDRolesPermissionsZonesJSON) RawJSON() string { + return r.raw +} + +type AccountMemberWithIDUser struct { + // The contact email address of the user. + Email string `json:"email,required"` + // Identifier + ID string `json:"id"` + // User's first name + FirstName string `json:"first_name,nullable"` + // User's last name + LastName string `json:"last_name,nullable"` + // Indicates whether two-factor authentication is enabled for the user account. + // Does not apply to API authentication. + TwoFactorAuthenticationEnabled bool `json:"two_factor_authentication_enabled"` + JSON accountMemberWithIDUserJSON `json:"-"` +} + +// accountMemberWithIDUserJSON contains the JSON metadata for the struct +// [AccountMemberWithIDUser] +type accountMemberWithIDUserJSON struct { + Email apijson.Field + ID apijson.Field + FirstName apijson.Field + LastName apijson.Field + TwoFactorAuthenticationEnabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountMemberWithIDUser) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountMemberWithIDUserJSON) RawJSON() string { + return r.raw +} + +type MemberListResponse struct { + // Identifier + ID string `json:"id,required"` + // The contact email address of the user. + Email string `json:"email,required"` + // Member Name. + Name string `json:"name,required,nullable"` + // Roles assigned to this Member. + Roles []IamSchemasRole `json:"roles,required"` + // A member's status in the organization. + Status MemberListResponseStatus `json:"status,required"` + JSON memberListResponseJSON `json:"-"` +} + +// memberListResponseJSON contains the JSON metadata for the struct +// [MemberListResponse] +type memberListResponseJSON struct { + ID apijson.Field + Email apijson.Field + Name apijson.Field + Roles apijson.Field + Status apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MemberListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r memberListResponseJSON) RawJSON() string { + return r.raw +} + +// A member's status in the organization. +type MemberListResponseStatus string + +const ( + MemberListResponseStatusAccepted MemberListResponseStatus = "accepted" + MemberListResponseStatusInvited MemberListResponseStatus = "invited" +) + +type MemberDeleteResponse struct { + // Identifier + ID string `json:"id,required"` + JSON memberDeleteResponseJSON `json:"-"` +} + +// memberDeleteResponseJSON contains the JSON metadata for the struct +// [MemberDeleteResponse] +type memberDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MemberDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r memberDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type MemberNewParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // The contact email address of the user. + Email param.Field[string] `json:"email,required"` + // Array of roles associated with this member. + Roles param.Field[[]string] `json:"roles,required"` + Status param.Field[MemberNewParamsStatus] `json:"status"` +} + +func (r MemberNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MemberNewParamsStatus string + +const ( + MemberNewParamsStatusAccepted MemberNewParamsStatus = "accepted" + MemberNewParamsStatusPending MemberNewParamsStatus = "pending" +) + +type MemberNewResponseEnvelope struct { + Errors []MemberNewResponseEnvelopeErrors `json:"errors,required"` + Messages []MemberNewResponseEnvelopeMessages `json:"messages,required"` + Result AccountMemberWithID `json:"result,required"` + // Whether the API call was successful + Success MemberNewResponseEnvelopeSuccess `json:"success,required"` + JSON memberNewResponseEnvelopeJSON `json:"-"` +} + +// memberNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [MemberNewResponseEnvelope] +type memberNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MemberNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r memberNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type MemberNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON memberNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// memberNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [MemberNewResponseEnvelopeErrors] +type memberNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MemberNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r memberNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type MemberNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON memberNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// memberNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [MemberNewResponseEnvelopeMessages] +type memberNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MemberNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r memberNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type MemberNewResponseEnvelopeSuccess bool + +const ( + MemberNewResponseEnvelopeSuccessTrue MemberNewResponseEnvelopeSuccess = true +) + +type MemberUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // Roles assigned to this member. + Roles param.Field[[]MemberUpdateParamsRole] `json:"roles,required"` +} + +func (r MemberUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MemberUpdateParamsRole struct { + // Role identifier tag. + ID param.Field[string] `json:"id,required"` +} + +func (r MemberUpdateParamsRole) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MemberUpdateParamsRolesPermissions struct { + Analytics param.Field[MemberUpdateParamsRolesPermissionsAnalytics] `json:"analytics"` + Billing param.Field[MemberUpdateParamsRolesPermissionsBilling] `json:"billing"` + CachePurge param.Field[MemberUpdateParamsRolesPermissionsCachePurge] `json:"cache_purge"` + DNS param.Field[MemberUpdateParamsRolesPermissionsDNS] `json:"dns"` + DNSRecords param.Field[MemberUpdateParamsRolesPermissionsDNSRecords] `json:"dns_records"` + Lb param.Field[MemberUpdateParamsRolesPermissionsLb] `json:"lb"` + Logs param.Field[MemberUpdateParamsRolesPermissionsLogs] `json:"logs"` + Organization param.Field[MemberUpdateParamsRolesPermissionsOrganization] `json:"organization"` + SSL param.Field[MemberUpdateParamsRolesPermissionsSSL] `json:"ssl"` + WAF param.Field[MemberUpdateParamsRolesPermissionsWAF] `json:"waf"` + ZoneSettings param.Field[MemberUpdateParamsRolesPermissionsZoneSettings] `json:"zone_settings"` + Zones param.Field[MemberUpdateParamsRolesPermissionsZones] `json:"zones"` +} + +func (r MemberUpdateParamsRolesPermissions) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MemberUpdateParamsRolesPermissionsAnalytics struct { + Read param.Field[bool] `json:"read"` + Write param.Field[bool] `json:"write"` +} + +func (r MemberUpdateParamsRolesPermissionsAnalytics) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MemberUpdateParamsRolesPermissionsBilling struct { + Read param.Field[bool] `json:"read"` + Write param.Field[bool] `json:"write"` +} + +func (r MemberUpdateParamsRolesPermissionsBilling) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MemberUpdateParamsRolesPermissionsCachePurge struct { + Read param.Field[bool] `json:"read"` + Write param.Field[bool] `json:"write"` +} + +func (r MemberUpdateParamsRolesPermissionsCachePurge) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MemberUpdateParamsRolesPermissionsDNS struct { + Read param.Field[bool] `json:"read"` + Write param.Field[bool] `json:"write"` +} + +func (r MemberUpdateParamsRolesPermissionsDNS) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MemberUpdateParamsRolesPermissionsDNSRecords struct { + Read param.Field[bool] `json:"read"` + Write param.Field[bool] `json:"write"` +} + +func (r MemberUpdateParamsRolesPermissionsDNSRecords) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MemberUpdateParamsRolesPermissionsLb struct { + Read param.Field[bool] `json:"read"` + Write param.Field[bool] `json:"write"` +} + +func (r MemberUpdateParamsRolesPermissionsLb) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MemberUpdateParamsRolesPermissionsLogs struct { + Read param.Field[bool] `json:"read"` + Write param.Field[bool] `json:"write"` +} + +func (r MemberUpdateParamsRolesPermissionsLogs) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MemberUpdateParamsRolesPermissionsOrganization struct { + Read param.Field[bool] `json:"read"` + Write param.Field[bool] `json:"write"` +} + +func (r MemberUpdateParamsRolesPermissionsOrganization) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MemberUpdateParamsRolesPermissionsSSL struct { + Read param.Field[bool] `json:"read"` + Write param.Field[bool] `json:"write"` +} + +func (r MemberUpdateParamsRolesPermissionsSSL) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MemberUpdateParamsRolesPermissionsWAF struct { + Read param.Field[bool] `json:"read"` + Write param.Field[bool] `json:"write"` +} + +func (r MemberUpdateParamsRolesPermissionsWAF) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MemberUpdateParamsRolesPermissionsZoneSettings struct { + Read param.Field[bool] `json:"read"` + Write param.Field[bool] `json:"write"` +} + +func (r MemberUpdateParamsRolesPermissionsZoneSettings) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MemberUpdateParamsRolesPermissionsZones struct { + Read param.Field[bool] `json:"read"` + Write param.Field[bool] `json:"write"` +} + +func (r MemberUpdateParamsRolesPermissionsZones) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MemberUpdateResponseEnvelope struct { + Errors []MemberUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []MemberUpdateResponseEnvelopeMessages `json:"messages,required"` + Result AccountMember `json:"result,required"` + // Whether the API call was successful + Success MemberUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON memberUpdateResponseEnvelopeJSON `json:"-"` +} + +// memberUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [MemberUpdateResponseEnvelope] +type memberUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MemberUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r memberUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type MemberUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON memberUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// memberUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [MemberUpdateResponseEnvelopeErrors] +type memberUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MemberUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r memberUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type MemberUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON memberUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// memberUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [MemberUpdateResponseEnvelopeMessages] +type memberUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MemberUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r memberUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type MemberUpdateResponseEnvelopeSuccess bool + +const ( + MemberUpdateResponseEnvelopeSuccessTrue MemberUpdateResponseEnvelopeSuccess = true +) + +type MemberListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // Direction to order results. + Direction param.Field[MemberListParamsDirection] `query:"direction"` + // Field to order results by. + Order param.Field[MemberListParamsOrder] `query:"order"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // Maximum number of results per page. + PerPage param.Field[float64] `query:"per_page"` + // A member's status in the account. + Status param.Field[MemberListParamsStatus] `query:"status"` +} + +// URLQuery serializes [MemberListParams]'s query parameters as `url.Values`. +func (r MemberListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Direction to order results. +type MemberListParamsDirection string + +const ( + MemberListParamsDirectionAsc MemberListParamsDirection = "asc" + MemberListParamsDirectionDesc MemberListParamsDirection = "desc" +) + +// Field to order results by. +type MemberListParamsOrder string + +const ( + MemberListParamsOrderUserFirstName MemberListParamsOrder = "user.first_name" + MemberListParamsOrderUserLastName MemberListParamsOrder = "user.last_name" + MemberListParamsOrderUserEmail MemberListParamsOrder = "user.email" + MemberListParamsOrderStatus MemberListParamsOrder = "status" +) + +// A member's status in the account. +type MemberListParamsStatus string + +const ( + MemberListParamsStatusAccepted MemberListParamsStatus = "accepted" + MemberListParamsStatusPending MemberListParamsStatus = "pending" + MemberListParamsStatusRejected MemberListParamsStatus = "rejected" +) + +type MemberDeleteParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type MemberDeleteResponseEnvelope struct { + Errors []MemberDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []MemberDeleteResponseEnvelopeMessages `json:"messages,required"` + Result MemberDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success MemberDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON memberDeleteResponseEnvelopeJSON `json:"-"` +} + +// memberDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [MemberDeleteResponseEnvelope] +type memberDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MemberDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r memberDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type MemberDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON memberDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// memberDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [MemberDeleteResponseEnvelopeErrors] +type memberDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MemberDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r memberDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type MemberDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON memberDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// memberDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [MemberDeleteResponseEnvelopeMessages] +type memberDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MemberDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r memberDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type MemberDeleteResponseEnvelopeSuccess bool + +const ( + MemberDeleteResponseEnvelopeSuccessTrue MemberDeleteResponseEnvelopeSuccess = true +) + +type MemberGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type MemberGetResponseEnvelope struct { + Errors []MemberGetResponseEnvelopeErrors `json:"errors,required"` + Messages []MemberGetResponseEnvelopeMessages `json:"messages,required"` + Result AccountMember `json:"result,required"` + // Whether the API call was successful + Success MemberGetResponseEnvelopeSuccess `json:"success,required"` + JSON memberGetResponseEnvelopeJSON `json:"-"` +} + +// memberGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [MemberGetResponseEnvelope] +type memberGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MemberGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r memberGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type MemberGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON memberGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// memberGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [MemberGetResponseEnvelopeErrors] +type memberGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MemberGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r memberGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type MemberGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON memberGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// memberGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [MemberGetResponseEnvelopeMessages] +type memberGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MemberGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r memberGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type MemberGetResponseEnvelopeSuccess bool + +const ( + MemberGetResponseEnvelopeSuccessTrue MemberGetResponseEnvelopeSuccess = true +) diff --git a/accounts/member_test.go b/accounts/member_test.go new file mode 100644 index 00000000000..cfdac07ebef --- /dev/null +++ b/accounts/member_test.go @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package accounts_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/accounts" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestMemberNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Accounts.Members.New(context.TODO(), accounts.MemberNewParams{ + AccountID: cloudflare.F[any](map[string]interface{}{}), + Email: cloudflare.F("user@example.com"), + Roles: cloudflare.F([]string{"3536bcfad5faccb999b47003c79917fb", "3536bcfad5faccb999b47003c79917fb", "3536bcfad5faccb999b47003c79917fb"}), + Status: cloudflare.F(accounts.MemberNewParamsStatusAccepted), + }) + 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 TestMemberUpdate(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("user@example.com"), + ) + _, err := client.Accounts.Members.Update( + context.TODO(), + "4536bcfad5faccb111b47003c79917fa", + accounts.MemberUpdateParams{ + AccountID: cloudflare.F[any](map[string]interface{}{}), + Roles: cloudflare.F([]accounts.MemberUpdateParamsRole{{ + ID: cloudflare.F("3536bcfad5faccb999b47003c79917fb"), + }, { + ID: cloudflare.F("3536bcfad5faccb999b47003c79917fb"), + }, { + ID: cloudflare.F("3536bcfad5faccb999b47003c79917fb"), + }}), + }, + ) + 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 TestMemberListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Accounts.Members.List(context.TODO(), accounts.MemberListParams{ + AccountID: cloudflare.F[any](map[string]interface{}{}), + Direction: cloudflare.F(accounts.MemberListParamsDirectionDesc), + Order: cloudflare.F(accounts.MemberListParamsOrderStatus), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(5.000000), + Status: cloudflare.F(accounts.MemberListParamsStatusAccepted), + }) + 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 TestMemberDelete(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("user@example.com"), + ) + _, err := client.Accounts.Members.Delete( + context.TODO(), + "4536bcfad5faccb111b47003c79917fa", + accounts.MemberDeleteParams{ + AccountID: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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 TestMemberGet(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("user@example.com"), + ) + _, err := client.Accounts.Members.Get( + context.TODO(), + "4536bcfad5faccb111b47003c79917fa", + accounts.MemberGetParams{ + AccountID: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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/accounts/role.go b/accounts/role.go new file mode 100644 index 00000000000..1217d22e191 --- /dev/null +++ b/accounts/role.go @@ -0,0 +1,309 @@ +// File generated from our OpenAPI spec by Stainless. + +package accounts + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// RoleService 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 [NewRoleService] method instead. +type RoleService struct { + Options []option.RequestOption +} + +// NewRoleService 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 NewRoleService(opts ...option.RequestOption) (r *RoleService) { + r = &RoleService{} + r.Options = opts + return +} + +// Get all available roles for an account. +func (r *RoleService) List(ctx context.Context, query RoleListParams, opts ...option.RequestOption) (res *[]IamSchemasRole, err error) { + opts = append(r.Options[:], opts...) + var env RoleListResponseEnvelope + path := fmt.Sprintf("accounts/%v/roles", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get information about a specific role for an account. +func (r *RoleService) Get(ctx context.Context, roleID interface{}, query RoleGetParams, opts ...option.RequestOption) (res *RoleGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RoleGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/roles/%v", query.AccountID, roleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type IamSchemasRole struct { + // Role identifier tag. + ID string `json:"id,required"` + // Description of role's permissions. + Description string `json:"description,required"` + // Role Name. + Name string `json:"name,required"` + // Access permissions for this User. + Permissions []string `json:"permissions,required"` + JSON iamSchemasRoleJSON `json:"-"` +} + +// iamSchemasRoleJSON contains the JSON metadata for the struct [IamSchemasRole] +type iamSchemasRoleJSON struct { + ID apijson.Field + Description apijson.Field + Name apijson.Field + Permissions apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IamSchemasRole) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r iamSchemasRoleJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [accounts.RoleGetResponseUnknown] or [shared.UnionString]. +type RoleGetResponse interface { + ImplementsAccountsRoleGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RoleGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type RoleListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type RoleListResponseEnvelope struct { + Errors []RoleListResponseEnvelopeErrors `json:"errors,required"` + Messages []RoleListResponseEnvelopeMessages `json:"messages,required"` + Result []IamSchemasRole `json:"result,required,nullable"` + // Whether the API call was successful + Success RoleListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo RoleListResponseEnvelopeResultInfo `json:"result_info"` + JSON roleListResponseEnvelopeJSON `json:"-"` +} + +// roleListResponseEnvelopeJSON contains the JSON metadata for the struct +// [RoleListResponseEnvelope] +type roleListResponseEnvelopeJSON 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 *RoleListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r roleListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RoleListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON roleListResponseEnvelopeErrorsJSON `json:"-"` +} + +// roleListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RoleListResponseEnvelopeErrors] +type roleListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoleListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r roleListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RoleListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON roleListResponseEnvelopeMessagesJSON `json:"-"` +} + +// roleListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RoleListResponseEnvelopeMessages] +type roleListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoleListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r roleListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RoleListResponseEnvelopeSuccess bool + +const ( + RoleListResponseEnvelopeSuccessTrue RoleListResponseEnvelopeSuccess = true +) + +type RoleListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON roleListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// roleListResponseEnvelopeResultInfoJSON contains the JSON metadata for the struct +// [RoleListResponseEnvelopeResultInfo] +type roleListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoleListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r roleListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type RoleGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type RoleGetResponseEnvelope struct { + Errors []RoleGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RoleGetResponseEnvelopeMessages `json:"messages,required"` + Result RoleGetResponse `json:"result,required"` + // Whether the API call was successful + Success RoleGetResponseEnvelopeSuccess `json:"success,required"` + JSON roleGetResponseEnvelopeJSON `json:"-"` +} + +// roleGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RoleGetResponseEnvelope] +type roleGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r roleGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RoleGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON roleGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// roleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RoleGetResponseEnvelopeErrors] +type roleGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r roleGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RoleGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON roleGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// roleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RoleGetResponseEnvelopeMessages] +type roleGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r roleGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RoleGetResponseEnvelopeSuccess bool + +const ( + RoleGetResponseEnvelopeSuccessTrue RoleGetResponseEnvelopeSuccess = true +) diff --git a/accounts/role_test.go b/accounts/role_test.go new file mode 100644 index 00000000000..b5653bdec1c --- /dev/null +++ b/accounts/role_test.go @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package accounts_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/accounts" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRoleList(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("user@example.com"), + ) + _, err := client.Accounts.Roles.List(context.TODO(), accounts.RoleListParams{ + AccountID: cloudflare.F[any](map[string]interface{}{}), + }) + 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 TestRoleGet(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("user@example.com"), + ) + _, err := client.Accounts.Roles.Get( + context.TODO(), + map[string]interface{}{}, + accounts.RoleGetParams{ + AccountID: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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/acm.go b/acm/acm.go similarity index 89% rename from acm.go rename to acm/acm.go index 74f0a995f7e..7c041287b56 100644 --- a/acm.go +++ b/acm/acm.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package acm import ( "github.com/cloudflare/cloudflare-go/option" @@ -12,7 +12,7 @@ import ( // directly, and instead use the [NewACMService] method instead. type ACMService struct { Options []option.RequestOption - TotalTLS *ACMTotalTLSService + TotalTLS *TotalTLSService } // NewACMService generates a new service that applies the given options to each @@ -21,6 +21,6 @@ type ACMService struct { func NewACMService(opts ...option.RequestOption) (r *ACMService) { r = &ACMService{} r.Options = opts - r.TotalTLS = NewACMTotalTLSService(opts...) + r.TotalTLS = NewTotalTLSService(opts...) return } diff --git a/acm/aliases.go b/acm/aliases.go new file mode 100644 index 00000000000..4bfeb01e040 --- /dev/null +++ b/acm/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package acm + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/acm/totaltls.go b/acm/totaltls.go new file mode 100644 index 00000000000..1d27c9247de --- /dev/null +++ b/acm/totaltls.go @@ -0,0 +1,334 @@ +// File generated from our OpenAPI spec by Stainless. + +package acm + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// TotalTLSService 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 [NewTotalTLSService] method instead. +type TotalTLSService struct { + Options []option.RequestOption +} + +// NewTotalTLSService 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 NewTotalTLSService(opts ...option.RequestOption) (r *TotalTLSService) { + r = &TotalTLSService{} + r.Options = opts + return +} + +// Set Total TLS Settings or disable the feature for a Zone. +func (r *TotalTLSService) New(ctx context.Context, params TotalTLSNewParams, opts ...option.RequestOption) (res *TotalTLSNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env TotalTLSNewResponseEnvelope + path := fmt.Sprintf("zones/%s/acm/total_tls", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get Total TLS Settings for a Zone. +func (r *TotalTLSService) Get(ctx context.Context, query TotalTLSGetParams, opts ...option.RequestOption) (res *TotalTLSGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env TotalTLSGetResponseEnvelope + path := fmt.Sprintf("zones/%s/acm/total_tls", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TotalTLSNewResponse struct { + // The Certificate Authority that Total TLS certificates will be issued through. + CertificateAuthority TotalTLSNewResponseCertificateAuthority `json:"certificate_authority"` + // If enabled, Total TLS will order a hostname specific TLS certificate for any + // proxied A, AAAA, or CNAME record in your zone. + Enabled bool `json:"enabled"` + // The validity period in days for the certificates ordered via Total TLS. + ValidityDays TotalTLSNewResponseValidityDays `json:"validity_days"` + JSON totalTLSNewResponseJSON `json:"-"` +} + +// totalTLSNewResponseJSON contains the JSON metadata for the struct +// [TotalTLSNewResponse] +type totalTLSNewResponseJSON struct { + CertificateAuthority apijson.Field + Enabled apijson.Field + ValidityDays apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TotalTLSNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r totalTLSNewResponseJSON) RawJSON() string { + return r.raw +} + +// The Certificate Authority that Total TLS certificates will be issued through. +type TotalTLSNewResponseCertificateAuthority string + +const ( + TotalTLSNewResponseCertificateAuthorityGoogle TotalTLSNewResponseCertificateAuthority = "google" + TotalTLSNewResponseCertificateAuthorityLetsEncrypt TotalTLSNewResponseCertificateAuthority = "lets_encrypt" +) + +// The validity period in days for the certificates ordered via Total TLS. +type TotalTLSNewResponseValidityDays int64 + +const ( + TotalTLSNewResponseValidityDays90 TotalTLSNewResponseValidityDays = 90 +) + +type TotalTLSGetResponse struct { + // The Certificate Authority that Total TLS certificates will be issued through. + CertificateAuthority TotalTLSGetResponseCertificateAuthority `json:"certificate_authority"` + // If enabled, Total TLS will order a hostname specific TLS certificate for any + // proxied A, AAAA, or CNAME record in your zone. + Enabled bool `json:"enabled"` + // The validity period in days for the certificates ordered via Total TLS. + ValidityDays TotalTLSGetResponseValidityDays `json:"validity_days"` + JSON totalTLSGetResponseJSON `json:"-"` +} + +// totalTLSGetResponseJSON contains the JSON metadata for the struct +// [TotalTLSGetResponse] +type totalTLSGetResponseJSON struct { + CertificateAuthority apijson.Field + Enabled apijson.Field + ValidityDays apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TotalTLSGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r totalTLSGetResponseJSON) RawJSON() string { + return r.raw +} + +// The Certificate Authority that Total TLS certificates will be issued through. +type TotalTLSGetResponseCertificateAuthority string + +const ( + TotalTLSGetResponseCertificateAuthorityGoogle TotalTLSGetResponseCertificateAuthority = "google" + TotalTLSGetResponseCertificateAuthorityLetsEncrypt TotalTLSGetResponseCertificateAuthority = "lets_encrypt" +) + +// The validity period in days for the certificates ordered via Total TLS. +type TotalTLSGetResponseValidityDays int64 + +const ( + TotalTLSGetResponseValidityDays90 TotalTLSGetResponseValidityDays = 90 +) + +type TotalTLSNewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // If enabled, Total TLS will order a hostname specific TLS certificate for any + // proxied A, AAAA, or CNAME record in your zone. + Enabled param.Field[bool] `json:"enabled,required"` + // The Certificate Authority that Total TLS certificates will be issued through. + CertificateAuthority param.Field[TotalTLSNewParamsCertificateAuthority] `json:"certificate_authority"` +} + +func (r TotalTLSNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The Certificate Authority that Total TLS certificates will be issued through. +type TotalTLSNewParamsCertificateAuthority string + +const ( + TotalTLSNewParamsCertificateAuthorityGoogle TotalTLSNewParamsCertificateAuthority = "google" + TotalTLSNewParamsCertificateAuthorityLetsEncrypt TotalTLSNewParamsCertificateAuthority = "lets_encrypt" +) + +type TotalTLSNewResponseEnvelope struct { + Errors []TotalTLSNewResponseEnvelopeErrors `json:"errors,required"` + Messages []TotalTLSNewResponseEnvelopeMessages `json:"messages,required"` + Result TotalTLSNewResponse `json:"result,required"` + // Whether the API call was successful + Success TotalTLSNewResponseEnvelopeSuccess `json:"success,required"` + JSON totalTLSNewResponseEnvelopeJSON `json:"-"` +} + +// totalTLSNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [TotalTLSNewResponseEnvelope] +type totalTLSNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TotalTLSNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r totalTLSNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TotalTLSNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON totalTLSNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// totalTLSNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [TotalTLSNewResponseEnvelopeErrors] +type totalTLSNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TotalTLSNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r totalTLSNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TotalTLSNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON totalTLSNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// totalTLSNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [TotalTLSNewResponseEnvelopeMessages] +type totalTLSNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TotalTLSNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r totalTLSNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TotalTLSNewResponseEnvelopeSuccess bool + +const ( + TotalTLSNewResponseEnvelopeSuccessTrue TotalTLSNewResponseEnvelopeSuccess = true +) + +type TotalTLSGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type TotalTLSGetResponseEnvelope struct { + Errors []TotalTLSGetResponseEnvelopeErrors `json:"errors,required"` + Messages []TotalTLSGetResponseEnvelopeMessages `json:"messages,required"` + Result TotalTLSGetResponse `json:"result,required"` + // Whether the API call was successful + Success TotalTLSGetResponseEnvelopeSuccess `json:"success,required"` + JSON totalTLSGetResponseEnvelopeJSON `json:"-"` +} + +// totalTLSGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [TotalTLSGetResponseEnvelope] +type totalTLSGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TotalTLSGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r totalTLSGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TotalTLSGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON totalTLSGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// totalTLSGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [TotalTLSGetResponseEnvelopeErrors] +type totalTLSGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TotalTLSGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r totalTLSGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TotalTLSGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON totalTLSGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// totalTLSGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [TotalTLSGetResponseEnvelopeMessages] +type totalTLSGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TotalTLSGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r totalTLSGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TotalTLSGetResponseEnvelopeSuccess bool + +const ( + TotalTLSGetResponseEnvelopeSuccessTrue TotalTLSGetResponseEnvelopeSuccess = true +) diff --git a/acm/totaltls_test.go b/acm/totaltls_test.go new file mode 100644 index 00000000000..e4db864972f --- /dev/null +++ b/acm/totaltls_test.go @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package acm_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/acm" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestTotalTLSNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ACM.TotalTLS.New(context.TODO(), acm.TotalTLSNewParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Enabled: cloudflare.F(true), + CertificateAuthority: cloudflare.F(acm.TotalTLSNewParamsCertificateAuthorityGoogle), + }) + 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 TestTotalTLSGet(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("user@example.com"), + ) + _, err := client.ACM.TotalTLS.Get(context.TODO(), acm.TotalTLSGetParams{ + ZoneID: cloudflare.F("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/acmtotaltls.go b/acmtotaltls.go deleted file mode 100644 index 59ee21aab92..00000000000 --- a/acmtotaltls.go +++ /dev/null @@ -1,335 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ACMTotalTLSService 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 [NewACMTotalTLSService] method -// instead. -type ACMTotalTLSService struct { - Options []option.RequestOption -} - -// NewACMTotalTLSService 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 NewACMTotalTLSService(opts ...option.RequestOption) (r *ACMTotalTLSService) { - r = &ACMTotalTLSService{} - r.Options = opts - return -} - -// Set Total TLS Settings or disable the feature for a Zone. -func (r *ACMTotalTLSService) New(ctx context.Context, params ACMTotalTLSNewParams, opts ...option.RequestOption) (res *ACMTotalTLSNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ACMTotalTLSNewResponseEnvelope - path := fmt.Sprintf("zones/%s/acm/total_tls", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get Total TLS Settings for a Zone. -func (r *ACMTotalTLSService) Get(ctx context.Context, query ACMTotalTLSGetParams, opts ...option.RequestOption) (res *ACMTotalTLSGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ACMTotalTLSGetResponseEnvelope - path := fmt.Sprintf("zones/%s/acm/total_tls", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ACMTotalTLSNewResponse struct { - // The Certificate Authority that Total TLS certificates will be issued through. - CertificateAuthority ACMTotalTLSNewResponseCertificateAuthority `json:"certificate_authority"` - // If enabled, Total TLS will order a hostname specific TLS certificate for any - // proxied A, AAAA, or CNAME record in your zone. - Enabled bool `json:"enabled"` - // The validity period in days for the certificates ordered via Total TLS. - ValidityDays ACMTotalTLSNewResponseValidityDays `json:"validity_days"` - JSON acmTotalTLSNewResponseJSON `json:"-"` -} - -// acmTotalTLSNewResponseJSON contains the JSON metadata for the struct -// [ACMTotalTLSNewResponse] -type acmTotalTLSNewResponseJSON struct { - CertificateAuthority apijson.Field - Enabled apijson.Field - ValidityDays apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ACMTotalTLSNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r acmTotalTLSNewResponseJSON) RawJSON() string { - return r.raw -} - -// The Certificate Authority that Total TLS certificates will be issued through. -type ACMTotalTLSNewResponseCertificateAuthority string - -const ( - ACMTotalTLSNewResponseCertificateAuthorityGoogle ACMTotalTLSNewResponseCertificateAuthority = "google" - ACMTotalTLSNewResponseCertificateAuthorityLetsEncrypt ACMTotalTLSNewResponseCertificateAuthority = "lets_encrypt" -) - -// The validity period in days for the certificates ordered via Total TLS. -type ACMTotalTLSNewResponseValidityDays int64 - -const ( - ACMTotalTLSNewResponseValidityDays90 ACMTotalTLSNewResponseValidityDays = 90 -) - -type ACMTotalTLSGetResponse struct { - // The Certificate Authority that Total TLS certificates will be issued through. - CertificateAuthority ACMTotalTLSGetResponseCertificateAuthority `json:"certificate_authority"` - // If enabled, Total TLS will order a hostname specific TLS certificate for any - // proxied A, AAAA, or CNAME record in your zone. - Enabled bool `json:"enabled"` - // The validity period in days for the certificates ordered via Total TLS. - ValidityDays ACMTotalTLSGetResponseValidityDays `json:"validity_days"` - JSON acmTotalTLSGetResponseJSON `json:"-"` -} - -// acmTotalTLSGetResponseJSON contains the JSON metadata for the struct -// [ACMTotalTLSGetResponse] -type acmTotalTLSGetResponseJSON struct { - CertificateAuthority apijson.Field - Enabled apijson.Field - ValidityDays apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ACMTotalTLSGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r acmTotalTLSGetResponseJSON) RawJSON() string { - return r.raw -} - -// The Certificate Authority that Total TLS certificates will be issued through. -type ACMTotalTLSGetResponseCertificateAuthority string - -const ( - ACMTotalTLSGetResponseCertificateAuthorityGoogle ACMTotalTLSGetResponseCertificateAuthority = "google" - ACMTotalTLSGetResponseCertificateAuthorityLetsEncrypt ACMTotalTLSGetResponseCertificateAuthority = "lets_encrypt" -) - -// The validity period in days for the certificates ordered via Total TLS. -type ACMTotalTLSGetResponseValidityDays int64 - -const ( - ACMTotalTLSGetResponseValidityDays90 ACMTotalTLSGetResponseValidityDays = 90 -) - -type ACMTotalTLSNewParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // If enabled, Total TLS will order a hostname specific TLS certificate for any - // proxied A, AAAA, or CNAME record in your zone. - Enabled param.Field[bool] `json:"enabled,required"` - // The Certificate Authority that Total TLS certificates will be issued through. - CertificateAuthority param.Field[ACMTotalTLSNewParamsCertificateAuthority] `json:"certificate_authority"` -} - -func (r ACMTotalTLSNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The Certificate Authority that Total TLS certificates will be issued through. -type ACMTotalTLSNewParamsCertificateAuthority string - -const ( - ACMTotalTLSNewParamsCertificateAuthorityGoogle ACMTotalTLSNewParamsCertificateAuthority = "google" - ACMTotalTLSNewParamsCertificateAuthorityLetsEncrypt ACMTotalTLSNewParamsCertificateAuthority = "lets_encrypt" -) - -type ACMTotalTLSNewResponseEnvelope struct { - Errors []ACMTotalTLSNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ACMTotalTLSNewResponseEnvelopeMessages `json:"messages,required"` - Result ACMTotalTLSNewResponse `json:"result,required"` - // Whether the API call was successful - Success ACMTotalTLSNewResponseEnvelopeSuccess `json:"success,required"` - JSON acmTotalTLSNewResponseEnvelopeJSON `json:"-"` -} - -// acmTotalTLSNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [ACMTotalTLSNewResponseEnvelope] -type acmTotalTLSNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ACMTotalTLSNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r acmTotalTLSNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ACMTotalTLSNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON acmTotalTLSNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// acmTotalTLSNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ACMTotalTLSNewResponseEnvelopeErrors] -type acmTotalTLSNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ACMTotalTLSNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r acmTotalTLSNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ACMTotalTLSNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON acmTotalTLSNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// acmTotalTLSNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ACMTotalTLSNewResponseEnvelopeMessages] -type acmTotalTLSNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ACMTotalTLSNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r acmTotalTLSNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ACMTotalTLSNewResponseEnvelopeSuccess bool - -const ( - ACMTotalTLSNewResponseEnvelopeSuccessTrue ACMTotalTLSNewResponseEnvelopeSuccess = true -) - -type ACMTotalTLSGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ACMTotalTLSGetResponseEnvelope struct { - Errors []ACMTotalTLSGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ACMTotalTLSGetResponseEnvelopeMessages `json:"messages,required"` - Result ACMTotalTLSGetResponse `json:"result,required"` - // Whether the API call was successful - Success ACMTotalTLSGetResponseEnvelopeSuccess `json:"success,required"` - JSON acmTotalTLSGetResponseEnvelopeJSON `json:"-"` -} - -// acmTotalTLSGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [ACMTotalTLSGetResponseEnvelope] -type acmTotalTLSGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ACMTotalTLSGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r acmTotalTLSGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ACMTotalTLSGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON acmTotalTLSGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// acmTotalTLSGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ACMTotalTLSGetResponseEnvelopeErrors] -type acmTotalTLSGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ACMTotalTLSGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r acmTotalTLSGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ACMTotalTLSGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON acmTotalTLSGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// acmTotalTLSGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ACMTotalTLSGetResponseEnvelopeMessages] -type acmTotalTLSGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ACMTotalTLSGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r acmTotalTLSGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ACMTotalTLSGetResponseEnvelopeSuccess bool - -const ( - ACMTotalTLSGetResponseEnvelopeSuccessTrue ACMTotalTLSGetResponseEnvelopeSuccess = true -) diff --git a/acmtotaltls_test.go b/acmtotaltls_test.go deleted file mode 100644 index 79461ab98b3..00000000000 --- a/acmtotaltls_test.go +++ /dev/null @@ -1,68 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestACMTotalTLSNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ACM.TotalTLS.New(context.TODO(), cloudflare.ACMTotalTLSNewParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Enabled: cloudflare.F(true), - CertificateAuthority: cloudflare.F(cloudflare.ACMTotalTLSNewParamsCertificateAuthorityGoogle), - }) - 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 TestACMTotalTLSGet(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("user@example.com"), - ) - _, err := client.ACM.TotalTLS.Get(context.TODO(), cloudflare.ACMTotalTLSGetParams{ - ZoneID: cloudflare.F("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/addressing.go b/addressing.go deleted file mode 100644 index d48b5c32f56..00000000000 --- a/addressing.go +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// AddressingService 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 [NewAddressingService] method instead. -type AddressingService struct { - Options []option.RequestOption - Services *AddressingServiceService - AddressMaps *AddressingAddressMapService - LOADocuments *AddressingLOADocumentService - Prefixes *AddressingPrefixService -} - -// NewAddressingService 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 NewAddressingService(opts ...option.RequestOption) (r *AddressingService) { - r = &AddressingService{} - r.Options = opts - r.Services = NewAddressingServiceService(opts...) - r.AddressMaps = NewAddressingAddressMapService(opts...) - r.LOADocuments = NewAddressingLOADocumentService(opts...) - r.Prefixes = NewAddressingPrefixService(opts...) - return -} diff --git a/addressing/addressing.go b/addressing/addressing.go new file mode 100644 index 00000000000..a24739f7107 --- /dev/null +++ b/addressing/addressing.go @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// AddressingService 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 [NewAddressingService] method instead. +type AddressingService struct { + Options []option.RequestOption + Services *ServiceService + AddressMaps *AddressMapService + LOADocuments *LOADocumentService + Prefixes *PrefixService +} + +// NewAddressingService 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 NewAddressingService(opts ...option.RequestOption) (r *AddressingService) { + r = &AddressingService{} + r.Options = opts + r.Services = NewServiceService(opts...) + r.AddressMaps = NewAddressMapService(opts...) + r.LOADocuments = NewLOADocumentService(opts...) + r.Prefixes = NewPrefixService(opts...) + return +} diff --git a/addressing/addressmap.go b/addressing/addressmap.go new file mode 100644 index 00000000000..4c380d2d780 --- /dev/null +++ b/addressing/addressmap.go @@ -0,0 +1,939 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// AddressMapService 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 [NewAddressMapService] method instead. +type AddressMapService struct { + Options []option.RequestOption + Accounts *AddressMapAccountService + IPs *AddressMapIPService + Zones *AddressMapZoneService +} + +// NewAddressMapService 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 NewAddressMapService(opts ...option.RequestOption) (r *AddressMapService) { + r = &AddressMapService{} + r.Options = opts + r.Accounts = NewAddressMapAccountService(opts...) + r.IPs = NewAddressMapIPService(opts...) + r.Zones = NewAddressMapZoneService(opts...) + return +} + +// Create a new address map under the account. +func (r *AddressMapService) New(ctx context.Context, params AddressMapNewParams, opts ...option.RequestOption) (res *AddressMapNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env AddressMapNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/address_maps", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List all address maps owned by the account. +func (r *AddressMapService) List(ctx context.Context, query AddressMapListParams, opts ...option.RequestOption) (res *[]AddressingAddressMaps, err error) { + opts = append(r.Options[:], opts...) + var env AddressMapListResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/address_maps", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a particular address map owned by the account. An Address Map must be +// disabled before it can be deleted. +func (r *AddressMapService) Delete(ctx context.Context, addressMapID string, body AddressMapDeleteParams, opts ...option.RequestOption) (res *AddressMapDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env AddressMapDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s", body.AccountID, addressMapID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Modify properties of an address map owned by the account. +func (r *AddressMapService) Edit(ctx context.Context, addressMapID string, params AddressMapEditParams, opts ...option.RequestOption) (res *AddressingAddressMaps, err error) { + opts = append(r.Options[:], opts...) + var env AddressMapEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s", params.AccountID, addressMapID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Show a particular address map owned by the account. +func (r *AddressMapService) Get(ctx context.Context, addressMapID string, query AddressMapGetParams, opts ...option.RequestOption) (res *AddressMapGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env AddressMapGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s", query.AccountID, addressMapID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AddressingAddressMaps struct { + // Identifier + ID string `json:"id"` + // If set to false, then the Address Map cannot be deleted via API. This is true + // for Cloudflare-managed maps. + CanDelete bool `json:"can_delete"` + // If set to false, then the IPs on the Address Map cannot be modified via the API. + // This is true for Cloudflare-managed maps. + CanModifyIPs bool `json:"can_modify_ips"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // If you have legacy TLS clients which do not send the TLS server name indicator, + // then you can specify one default SNI on the map. If Cloudflare receives a TLS + // handshake from a client without an SNI, it will respond with the default SNI on + // those IPs. The default SNI can be any valid zone or subdomain owned by the + // account. + DefaultSni string `json:"default_sni,nullable"` + // An optional description field which may be used to describe the types of IPs or + // zones on the map. + Description string `json:"description,nullable"` + // Whether the Address Map is enabled or not. Cloudflare's DNS will not respond + // with IP addresses on an Address Map until the map is enabled. + Enabled bool `json:"enabled,nullable"` + ModifiedAt time.Time `json:"modified_at" format:"date-time"` + JSON addressingAddressMapsJSON `json:"-"` +} + +// addressingAddressMapsJSON contains the JSON metadata for the struct +// [AddressingAddressMaps] +type addressingAddressMapsJSON struct { + ID apijson.Field + CanDelete apijson.Field + CanModifyIPs apijson.Field + CreatedAt apijson.Field + DefaultSni apijson.Field + Description apijson.Field + Enabled apijson.Field + ModifiedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressingAddressMaps) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressingAddressMapsJSON) RawJSON() string { + return r.raw +} + +type AddressMapNewResponse struct { + // Identifier + ID string `json:"id"` + // If set to false, then the Address Map cannot be deleted via API. This is true + // for Cloudflare-managed maps. + CanDelete bool `json:"can_delete"` + // If set to false, then the IPs on the Address Map cannot be modified via the API. + // This is true for Cloudflare-managed maps. + CanModifyIPs bool `json:"can_modify_ips"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // If you have legacy TLS clients which do not send the TLS server name indicator, + // then you can specify one default SNI on the map. If Cloudflare receives a TLS + // handshake from a client without an SNI, it will respond with the default SNI on + // those IPs. The default SNI can be any valid zone or subdomain owned by the + // account. + DefaultSni string `json:"default_sni,nullable"` + // An optional description field which may be used to describe the types of IPs or + // zones on the map. + Description string `json:"description,nullable"` + // Whether the Address Map is enabled or not. Cloudflare's DNS will not respond + // with IP addresses on an Address Map until the map is enabled. + Enabled bool `json:"enabled,nullable"` + // The set of IPs on the Address Map. + IPs []AddressMapNewResponseIP `json:"ips"` + // Zones and Accounts which will be assigned IPs on this Address Map. A zone + // membership will take priority over an account membership. + Memberships []AddressMapNewResponseMembership `json:"memberships"` + ModifiedAt time.Time `json:"modified_at" format:"date-time"` + JSON addressMapNewResponseJSON `json:"-"` +} + +// addressMapNewResponseJSON contains the JSON metadata for the struct +// [AddressMapNewResponse] +type addressMapNewResponseJSON struct { + ID apijson.Field + CanDelete apijson.Field + CanModifyIPs apijson.Field + CreatedAt apijson.Field + DefaultSni apijson.Field + Description apijson.Field + Enabled apijson.Field + IPs apijson.Field + Memberships apijson.Field + ModifiedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapNewResponseJSON) RawJSON() string { + return r.raw +} + +type AddressMapNewResponseIP struct { + CreatedAt time.Time `json:"created_at" format:"date-time"` + // An IPv4 or IPv6 address. + IP string `json:"ip"` + JSON addressMapNewResponseIPJSON `json:"-"` +} + +// addressMapNewResponseIPJSON contains the JSON metadata for the struct +// [AddressMapNewResponseIP] +type addressMapNewResponseIPJSON struct { + CreatedAt apijson.Field + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapNewResponseIP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapNewResponseIPJSON) RawJSON() string { + return r.raw +} + +type AddressMapNewResponseMembership struct { + // Controls whether the membership can be deleted via the API or not. + CanDelete bool `json:"can_delete"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // Identifier + Identifier string `json:"identifier"` + // The type of the membership. + Kind AddressMapNewResponseMembershipsKind `json:"kind"` + JSON addressMapNewResponseMembershipJSON `json:"-"` +} + +// addressMapNewResponseMembershipJSON contains the JSON metadata for the struct +// [AddressMapNewResponseMembership] +type addressMapNewResponseMembershipJSON struct { + CanDelete apijson.Field + CreatedAt apijson.Field + Identifier apijson.Field + Kind apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapNewResponseMembership) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapNewResponseMembershipJSON) RawJSON() string { + return r.raw +} + +// The type of the membership. +type AddressMapNewResponseMembershipsKind string + +const ( + AddressMapNewResponseMembershipsKindZone AddressMapNewResponseMembershipsKind = "zone" + AddressMapNewResponseMembershipsKindAccount AddressMapNewResponseMembershipsKind = "account" +) + +// Union satisfied by [addressing.AddressMapDeleteResponseUnknown], +// [addressing.AddressMapDeleteResponseArray] or [shared.UnionString]. +type AddressMapDeleteResponse interface { + ImplementsAddressingAddressMapDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AddressMapDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AddressMapDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type AddressMapDeleteResponseArray []interface{} + +func (r AddressMapDeleteResponseArray) ImplementsAddressingAddressMapDeleteResponse() {} + +type AddressMapGetResponse struct { + // Identifier + ID string `json:"id"` + // If set to false, then the Address Map cannot be deleted via API. This is true + // for Cloudflare-managed maps. + CanDelete bool `json:"can_delete"` + // If set to false, then the IPs on the Address Map cannot be modified via the API. + // This is true for Cloudflare-managed maps. + CanModifyIPs bool `json:"can_modify_ips"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // If you have legacy TLS clients which do not send the TLS server name indicator, + // then you can specify one default SNI on the map. If Cloudflare receives a TLS + // handshake from a client without an SNI, it will respond with the default SNI on + // those IPs. The default SNI can be any valid zone or subdomain owned by the + // account. + DefaultSni string `json:"default_sni,nullable"` + // An optional description field which may be used to describe the types of IPs or + // zones on the map. + Description string `json:"description,nullable"` + // Whether the Address Map is enabled or not. Cloudflare's DNS will not respond + // with IP addresses on an Address Map until the map is enabled. + Enabled bool `json:"enabled,nullable"` + // The set of IPs on the Address Map. + IPs []AddressMapGetResponseIP `json:"ips"` + // Zones and Accounts which will be assigned IPs on this Address Map. A zone + // membership will take priority over an account membership. + Memberships []AddressMapGetResponseMembership `json:"memberships"` + ModifiedAt time.Time `json:"modified_at" format:"date-time"` + JSON addressMapGetResponseJSON `json:"-"` +} + +// addressMapGetResponseJSON contains the JSON metadata for the struct +// [AddressMapGetResponse] +type addressMapGetResponseJSON struct { + ID apijson.Field + CanDelete apijson.Field + CanModifyIPs apijson.Field + CreatedAt apijson.Field + DefaultSni apijson.Field + Description apijson.Field + Enabled apijson.Field + IPs apijson.Field + Memberships apijson.Field + ModifiedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapGetResponseJSON) RawJSON() string { + return r.raw +} + +type AddressMapGetResponseIP struct { + CreatedAt time.Time `json:"created_at" format:"date-time"` + // An IPv4 or IPv6 address. + IP string `json:"ip"` + JSON addressMapGetResponseIPJSON `json:"-"` +} + +// addressMapGetResponseIPJSON contains the JSON metadata for the struct +// [AddressMapGetResponseIP] +type addressMapGetResponseIPJSON struct { + CreatedAt apijson.Field + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapGetResponseIP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapGetResponseIPJSON) RawJSON() string { + return r.raw +} + +type AddressMapGetResponseMembership struct { + // Controls whether the membership can be deleted via the API or not. + CanDelete bool `json:"can_delete"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // Identifier + Identifier string `json:"identifier"` + // The type of the membership. + Kind AddressMapGetResponseMembershipsKind `json:"kind"` + JSON addressMapGetResponseMembershipJSON `json:"-"` +} + +// addressMapGetResponseMembershipJSON contains the JSON metadata for the struct +// [AddressMapGetResponseMembership] +type addressMapGetResponseMembershipJSON struct { + CanDelete apijson.Field + CreatedAt apijson.Field + Identifier apijson.Field + Kind apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapGetResponseMembership) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapGetResponseMembershipJSON) RawJSON() string { + return r.raw +} + +// The type of the membership. +type AddressMapGetResponseMembershipsKind string + +const ( + AddressMapGetResponseMembershipsKindZone AddressMapGetResponseMembershipsKind = "zone" + AddressMapGetResponseMembershipsKindAccount AddressMapGetResponseMembershipsKind = "account" +) + +type AddressMapNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // An optional description field which may be used to describe the types of IPs or + // zones on the map. + Description param.Field[string] `json:"description"` + // Whether the Address Map is enabled or not. Cloudflare's DNS will not respond + // with IP addresses on an Address Map until the map is enabled. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r AddressMapNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AddressMapNewResponseEnvelope struct { + Errors []AddressMapNewResponseEnvelopeErrors `json:"errors,required"` + Messages []AddressMapNewResponseEnvelopeMessages `json:"messages,required"` + Result AddressMapNewResponse `json:"result,required"` + // Whether the API call was successful + Success AddressMapNewResponseEnvelopeSuccess `json:"success,required"` + JSON addressMapNewResponseEnvelopeJSON `json:"-"` +} + +// addressMapNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [AddressMapNewResponseEnvelope] +type addressMapNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AddressMapNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// addressMapNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AddressMapNewResponseEnvelopeErrors] +type addressMapNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AddressMapNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// addressMapNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AddressMapNewResponseEnvelopeMessages] +type addressMapNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AddressMapNewResponseEnvelopeSuccess bool + +const ( + AddressMapNewResponseEnvelopeSuccessTrue AddressMapNewResponseEnvelopeSuccess = true +) + +type AddressMapListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type AddressMapListResponseEnvelope struct { + Errors []AddressMapListResponseEnvelopeErrors `json:"errors,required"` + Messages []AddressMapListResponseEnvelopeMessages `json:"messages,required"` + Result []AddressingAddressMaps `json:"result,required,nullable"` + // Whether the API call was successful + Success AddressMapListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AddressMapListResponseEnvelopeResultInfo `json:"result_info"` + JSON addressMapListResponseEnvelopeJSON `json:"-"` +} + +// addressMapListResponseEnvelopeJSON contains the JSON metadata for the struct +// [AddressMapListResponseEnvelope] +type addressMapListResponseEnvelopeJSON 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 *AddressMapListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AddressMapListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapListResponseEnvelopeErrorsJSON `json:"-"` +} + +// addressMapListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AddressMapListResponseEnvelopeErrors] +type addressMapListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AddressMapListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapListResponseEnvelopeMessagesJSON `json:"-"` +} + +// addressMapListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AddressMapListResponseEnvelopeMessages] +type addressMapListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AddressMapListResponseEnvelopeSuccess bool + +const ( + AddressMapListResponseEnvelopeSuccessTrue AddressMapListResponseEnvelopeSuccess = true +) + +type AddressMapListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON addressMapListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// addressMapListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [AddressMapListResponseEnvelopeResultInfo] +type addressMapListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type AddressMapDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type AddressMapDeleteResponseEnvelope struct { + Errors []AddressMapDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []AddressMapDeleteResponseEnvelopeMessages `json:"messages,required"` + Result AddressMapDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AddressMapDeleteResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AddressMapDeleteResponseEnvelopeResultInfo `json:"result_info"` + JSON addressMapDeleteResponseEnvelopeJSON `json:"-"` +} + +// addressMapDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [AddressMapDeleteResponseEnvelope] +type addressMapDeleteResponseEnvelopeJSON 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 *AddressMapDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AddressMapDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// addressMapDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AddressMapDeleteResponseEnvelopeErrors] +type addressMapDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AddressMapDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// addressMapDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AddressMapDeleteResponseEnvelopeMessages] +type addressMapDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AddressMapDeleteResponseEnvelopeSuccess bool + +const ( + AddressMapDeleteResponseEnvelopeSuccessTrue AddressMapDeleteResponseEnvelopeSuccess = true +) + +type AddressMapDeleteResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON addressMapDeleteResponseEnvelopeResultInfoJSON `json:"-"` +} + +// addressMapDeleteResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [AddressMapDeleteResponseEnvelopeResultInfo] +type addressMapDeleteResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type AddressMapEditParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // If you have legacy TLS clients which do not send the TLS server name indicator, + // then you can specify one default SNI on the map. If Cloudflare receives a TLS + // handshake from a client without an SNI, it will respond with the default SNI on + // those IPs. The default SNI can be any valid zone or subdomain owned by the + // account. + DefaultSni param.Field[string] `json:"default_sni"` + // An optional description field which may be used to describe the types of IPs or + // zones on the map. + Description param.Field[string] `json:"description"` + // Whether the Address Map is enabled or not. Cloudflare's DNS will not respond + // with IP addresses on an Address Map until the map is enabled. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r AddressMapEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AddressMapEditResponseEnvelope struct { + Errors []AddressMapEditResponseEnvelopeErrors `json:"errors,required"` + Messages []AddressMapEditResponseEnvelopeMessages `json:"messages,required"` + Result AddressingAddressMaps `json:"result,required"` + // Whether the API call was successful + Success AddressMapEditResponseEnvelopeSuccess `json:"success,required"` + JSON addressMapEditResponseEnvelopeJSON `json:"-"` +} + +// addressMapEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [AddressMapEditResponseEnvelope] +type addressMapEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AddressMapEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// addressMapEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AddressMapEditResponseEnvelopeErrors] +type addressMapEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AddressMapEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// addressMapEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AddressMapEditResponseEnvelopeMessages] +type addressMapEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AddressMapEditResponseEnvelopeSuccess bool + +const ( + AddressMapEditResponseEnvelopeSuccessTrue AddressMapEditResponseEnvelopeSuccess = true +) + +type AddressMapGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type AddressMapGetResponseEnvelope struct { + Errors []AddressMapGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AddressMapGetResponseEnvelopeMessages `json:"messages,required"` + Result AddressMapGetResponse `json:"result,required"` + // Whether the API call was successful + Success AddressMapGetResponseEnvelopeSuccess `json:"success,required"` + JSON addressMapGetResponseEnvelopeJSON `json:"-"` +} + +// addressMapGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [AddressMapGetResponseEnvelope] +type addressMapGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AddressMapGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// addressMapGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AddressMapGetResponseEnvelopeErrors] +type addressMapGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AddressMapGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// addressMapGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AddressMapGetResponseEnvelopeMessages] +type addressMapGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AddressMapGetResponseEnvelopeSuccess bool + +const ( + AddressMapGetResponseEnvelopeSuccessTrue AddressMapGetResponseEnvelopeSuccess = true +) diff --git a/addressing/addressmap_test.go b/addressing/addressmap_test.go new file mode 100644 index 00000000000..5b5616f105b --- /dev/null +++ b/addressing/addressmap_test.go @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/addressing" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestAddressMapNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Addressing.AddressMaps.New(context.TODO(), addressing.AddressMapNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Description: cloudflare.F("My Ecommerce zones"), + Enabled: cloudflare.F(true), + }) + 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 TestAddressMapList(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("user@example.com"), + ) + _, err := client.Addressing.AddressMaps.List(context.TODO(), addressing.AddressMapListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestAddressMapDelete(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("user@example.com"), + ) + _, err := client.Addressing.AddressMaps.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.AddressMapDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestAddressMapEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Addressing.AddressMaps.Edit( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.AddressMapEditParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + DefaultSni: cloudflare.F("*.example.com"), + Description: cloudflare.F("My Ecommerce zones"), + Enabled: cloudflare.F(true), + }, + ) + 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 TestAddressMapGet(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("user@example.com"), + ) + _, err := client.Addressing.AddressMaps.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.AddressMapGetParams{ + AccountID: cloudflare.F("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/addressing/addressmapaccount.go b/addressing/addressmapaccount.go new file mode 100644 index 00000000000..e3a6d0d56b0 --- /dev/null +++ b/addressing/addressmapaccount.go @@ -0,0 +1,349 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// AddressMapAccountService 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 [NewAddressMapAccountService] method +// instead. +type AddressMapAccountService struct { + Options []option.RequestOption +} + +// NewAddressMapAccountService 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 NewAddressMapAccountService(opts ...option.RequestOption) (r *AddressMapAccountService) { + r = &AddressMapAccountService{} + r.Options = opts + return +} + +// Add an account as a member of a particular address map. +func (r *AddressMapAccountService) Update(ctx context.Context, addressMapID string, body AddressMapAccountUpdateParams, opts ...option.RequestOption) (res *AddressMapAccountUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env AddressMapAccountUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/accounts/%s", body.AccountID, addressMapID, body.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Remove an account as a member of a particular address map. +func (r *AddressMapAccountService) Delete(ctx context.Context, addressMapID string, body AddressMapAccountDeleteParams, opts ...option.RequestOption) (res *AddressMapAccountDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env AddressMapAccountDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/accounts/%s", body.AccountID, addressMapID, body.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [addressing.AddressMapAccountUpdateResponseUnknown], +// [addressing.AddressMapAccountUpdateResponseArray] or [shared.UnionString]. +type AddressMapAccountUpdateResponse interface { + ImplementsAddressingAddressMapAccountUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AddressMapAccountUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AddressMapAccountUpdateResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type AddressMapAccountUpdateResponseArray []interface{} + +func (r AddressMapAccountUpdateResponseArray) ImplementsAddressingAddressMapAccountUpdateResponse() {} + +// Union satisfied by [addressing.AddressMapAccountDeleteResponseUnknown], +// [addressing.AddressMapAccountDeleteResponseArray] or [shared.UnionString]. +type AddressMapAccountDeleteResponse interface { + ImplementsAddressingAddressMapAccountDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AddressMapAccountDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AddressMapAccountDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type AddressMapAccountDeleteResponseArray []interface{} + +func (r AddressMapAccountDeleteResponseArray) ImplementsAddressingAddressMapAccountDeleteResponse() {} + +type AddressMapAccountUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type AddressMapAccountUpdateResponseEnvelope struct { + Errors []AddressMapAccountUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []AddressMapAccountUpdateResponseEnvelopeMessages `json:"messages,required"` + Result AddressMapAccountUpdateResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AddressMapAccountUpdateResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AddressMapAccountUpdateResponseEnvelopeResultInfo `json:"result_info"` + JSON addressMapAccountUpdateResponseEnvelopeJSON `json:"-"` +} + +// addressMapAccountUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [AddressMapAccountUpdateResponseEnvelope] +type addressMapAccountUpdateResponseEnvelopeJSON 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 *AddressMapAccountUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapAccountUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AddressMapAccountUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapAccountUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// addressMapAccountUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AddressMapAccountUpdateResponseEnvelopeErrors] +type addressMapAccountUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapAccountUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapAccountUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AddressMapAccountUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapAccountUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// addressMapAccountUpdateResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AddressMapAccountUpdateResponseEnvelopeMessages] +type addressMapAccountUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapAccountUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapAccountUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AddressMapAccountUpdateResponseEnvelopeSuccess bool + +const ( + AddressMapAccountUpdateResponseEnvelopeSuccessTrue AddressMapAccountUpdateResponseEnvelopeSuccess = true +) + +type AddressMapAccountUpdateResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON addressMapAccountUpdateResponseEnvelopeResultInfoJSON `json:"-"` +} + +// addressMapAccountUpdateResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [AddressMapAccountUpdateResponseEnvelopeResultInfo] +type addressMapAccountUpdateResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapAccountUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapAccountUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type AddressMapAccountDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type AddressMapAccountDeleteResponseEnvelope struct { + Errors []AddressMapAccountDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []AddressMapAccountDeleteResponseEnvelopeMessages `json:"messages,required"` + Result AddressMapAccountDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AddressMapAccountDeleteResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AddressMapAccountDeleteResponseEnvelopeResultInfo `json:"result_info"` + JSON addressMapAccountDeleteResponseEnvelopeJSON `json:"-"` +} + +// addressMapAccountDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [AddressMapAccountDeleteResponseEnvelope] +type addressMapAccountDeleteResponseEnvelopeJSON 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 *AddressMapAccountDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapAccountDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AddressMapAccountDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapAccountDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// addressMapAccountDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AddressMapAccountDeleteResponseEnvelopeErrors] +type addressMapAccountDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapAccountDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapAccountDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AddressMapAccountDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapAccountDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// addressMapAccountDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AddressMapAccountDeleteResponseEnvelopeMessages] +type addressMapAccountDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapAccountDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapAccountDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AddressMapAccountDeleteResponseEnvelopeSuccess bool + +const ( + AddressMapAccountDeleteResponseEnvelopeSuccessTrue AddressMapAccountDeleteResponseEnvelopeSuccess = true +) + +type AddressMapAccountDeleteResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON addressMapAccountDeleteResponseEnvelopeResultInfoJSON `json:"-"` +} + +// addressMapAccountDeleteResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [AddressMapAccountDeleteResponseEnvelopeResultInfo] +type addressMapAccountDeleteResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapAccountDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapAccountDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/addressing/addressmapaccount_test.go b/addressing/addressmapaccount_test.go new file mode 100644 index 00000000000..80509f5f8cc --- /dev/null +++ b/addressing/addressmapaccount_test.go @@ -0,0 +1,75 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/addressing" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestAddressMapAccountUpdate(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("user@example.com"), + ) + _, err := client.Addressing.AddressMaps.Accounts.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.AddressMapAccountUpdateParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestAddressMapAccountDelete(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("user@example.com"), + ) + _, err := client.Addressing.AddressMaps.Accounts.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.AddressMapAccountDeleteParams{ + AccountID: cloudflare.F("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/addressing/addressmapip.go b/addressing/addressmapip.go new file mode 100644 index 00000000000..966a5c806fc --- /dev/null +++ b/addressing/addressmapip.go @@ -0,0 +1,349 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// AddressMapIPService 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 [NewAddressMapIPService] method +// instead. +type AddressMapIPService struct { + Options []option.RequestOption +} + +// NewAddressMapIPService 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 NewAddressMapIPService(opts ...option.RequestOption) (r *AddressMapIPService) { + r = &AddressMapIPService{} + r.Options = opts + return +} + +// Add an IP from a prefix owned by the account to a particular address map. +func (r *AddressMapIPService) Update(ctx context.Context, addressMapID string, ipAddress string, body AddressMapIPUpdateParams, opts ...option.RequestOption) (res *AddressMapIPUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env AddressMapIPUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/ips/%s", body.AccountID, addressMapID, ipAddress) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Remove an IP from a particular address map. +func (r *AddressMapIPService) Delete(ctx context.Context, addressMapID string, ipAddress string, body AddressMapIPDeleteParams, opts ...option.RequestOption) (res *AddressMapIPDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env AddressMapIPDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/ips/%s", body.AccountID, addressMapID, ipAddress) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [addressing.AddressMapIPUpdateResponseUnknown], +// [addressing.AddressMapIPUpdateResponseArray] or [shared.UnionString]. +type AddressMapIPUpdateResponse interface { + ImplementsAddressingAddressMapIPUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AddressMapIPUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AddressMapIPUpdateResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type AddressMapIPUpdateResponseArray []interface{} + +func (r AddressMapIPUpdateResponseArray) ImplementsAddressingAddressMapIPUpdateResponse() {} + +// Union satisfied by [addressing.AddressMapIPDeleteResponseUnknown], +// [addressing.AddressMapIPDeleteResponseArray] or [shared.UnionString]. +type AddressMapIPDeleteResponse interface { + ImplementsAddressingAddressMapIPDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AddressMapIPDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AddressMapIPDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type AddressMapIPDeleteResponseArray []interface{} + +func (r AddressMapIPDeleteResponseArray) ImplementsAddressingAddressMapIPDeleteResponse() {} + +type AddressMapIPUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type AddressMapIPUpdateResponseEnvelope struct { + Errors []AddressMapIPUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []AddressMapIPUpdateResponseEnvelopeMessages `json:"messages,required"` + Result AddressMapIPUpdateResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AddressMapIPUpdateResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AddressMapIPUpdateResponseEnvelopeResultInfo `json:"result_info"` + JSON addressMapIPUpdateResponseEnvelopeJSON `json:"-"` +} + +// addressMapIPUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [AddressMapIPUpdateResponseEnvelope] +type addressMapIPUpdateResponseEnvelopeJSON 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 *AddressMapIPUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapIPUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AddressMapIPUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapIPUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// addressMapIPUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AddressMapIPUpdateResponseEnvelopeErrors] +type addressMapIPUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapIPUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapIPUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AddressMapIPUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapIPUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// addressMapIPUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AddressMapIPUpdateResponseEnvelopeMessages] +type addressMapIPUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapIPUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapIPUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AddressMapIPUpdateResponseEnvelopeSuccess bool + +const ( + AddressMapIPUpdateResponseEnvelopeSuccessTrue AddressMapIPUpdateResponseEnvelopeSuccess = true +) + +type AddressMapIPUpdateResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON addressMapIPUpdateResponseEnvelopeResultInfoJSON `json:"-"` +} + +// addressMapIPUpdateResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [AddressMapIPUpdateResponseEnvelopeResultInfo] +type addressMapIPUpdateResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapIPUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapIPUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type AddressMapIPDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type AddressMapIPDeleteResponseEnvelope struct { + Errors []AddressMapIPDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []AddressMapIPDeleteResponseEnvelopeMessages `json:"messages,required"` + Result AddressMapIPDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AddressMapIPDeleteResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AddressMapIPDeleteResponseEnvelopeResultInfo `json:"result_info"` + JSON addressMapIPDeleteResponseEnvelopeJSON `json:"-"` +} + +// addressMapIPDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [AddressMapIPDeleteResponseEnvelope] +type addressMapIPDeleteResponseEnvelopeJSON 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 *AddressMapIPDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapIPDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AddressMapIPDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapIPDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// addressMapIPDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AddressMapIPDeleteResponseEnvelopeErrors] +type addressMapIPDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapIPDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapIPDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AddressMapIPDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapIPDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// addressMapIPDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AddressMapIPDeleteResponseEnvelopeMessages] +type addressMapIPDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapIPDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapIPDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AddressMapIPDeleteResponseEnvelopeSuccess bool + +const ( + AddressMapIPDeleteResponseEnvelopeSuccessTrue AddressMapIPDeleteResponseEnvelopeSuccess = true +) + +type AddressMapIPDeleteResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON addressMapIPDeleteResponseEnvelopeResultInfoJSON `json:"-"` +} + +// addressMapIPDeleteResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [AddressMapIPDeleteResponseEnvelopeResultInfo] +type addressMapIPDeleteResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapIPDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapIPDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/addressing/addressmapip_test.go b/addressing/addressmapip_test.go new file mode 100644 index 00000000000..a329cb1cc36 --- /dev/null +++ b/addressing/addressmapip_test.go @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/addressing" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestAddressMapIPUpdate(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("user@example.com"), + ) + _, err := client.Addressing.AddressMaps.IPs.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "192.0.2.1", + addressing.AddressMapIPUpdateParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestAddressMapIPDelete(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("user@example.com"), + ) + _, err := client.Addressing.AddressMaps.IPs.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "192.0.2.1", + addressing.AddressMapIPDeleteParams{ + AccountID: cloudflare.F("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/addressing/addressmapzone.go b/addressing/addressmapzone.go new file mode 100644 index 00000000000..4602a184340 --- /dev/null +++ b/addressing/addressmapzone.go @@ -0,0 +1,371 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// AddressMapZoneService 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 [NewAddressMapZoneService] method +// instead. +type AddressMapZoneService struct { + Options []option.RequestOption +} + +// NewAddressMapZoneService 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 NewAddressMapZoneService(opts ...option.RequestOption) (r *AddressMapZoneService) { + r = &AddressMapZoneService{} + r.Options = opts + return +} + +// Add a zone as a member of a particular address map. +func (r *AddressMapZoneService) Update(ctx context.Context, addressMapID string, body AddressMapZoneUpdateParams, opts ...option.RequestOption) (res *AddressMapZoneUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env AddressMapZoneUpdateResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if body.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = body.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = body.ZoneID + } + path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/zones/%s", accountOrZone, addressMapID, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Remove a zone as a member of a particular address map. +func (r *AddressMapZoneService) Delete(ctx context.Context, addressMapID string, body AddressMapZoneDeleteParams, opts ...option.RequestOption) (res *AddressMapZoneDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env AddressMapZoneDeleteResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if body.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = body.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = body.ZoneID + } + path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/zones/%s", accountOrZone, addressMapID, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [addressing.AddressMapZoneUpdateResponseUnknown], +// [addressing.AddressMapZoneUpdateResponseArray] or [shared.UnionString]. +type AddressMapZoneUpdateResponse interface { + ImplementsAddressingAddressMapZoneUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AddressMapZoneUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AddressMapZoneUpdateResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type AddressMapZoneUpdateResponseArray []interface{} + +func (r AddressMapZoneUpdateResponseArray) ImplementsAddressingAddressMapZoneUpdateResponse() {} + +// Union satisfied by [addressing.AddressMapZoneDeleteResponseUnknown], +// [addressing.AddressMapZoneDeleteResponseArray] or [shared.UnionString]. +type AddressMapZoneDeleteResponse interface { + ImplementsAddressingAddressMapZoneDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AddressMapZoneDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AddressMapZoneDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type AddressMapZoneDeleteResponseArray []interface{} + +func (r AddressMapZoneDeleteResponseArray) ImplementsAddressingAddressMapZoneDeleteResponse() {} + +type AddressMapZoneUpdateParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type AddressMapZoneUpdateResponseEnvelope struct { + Errors []AddressMapZoneUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []AddressMapZoneUpdateResponseEnvelopeMessages `json:"messages,required"` + Result AddressMapZoneUpdateResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AddressMapZoneUpdateResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AddressMapZoneUpdateResponseEnvelopeResultInfo `json:"result_info"` + JSON addressMapZoneUpdateResponseEnvelopeJSON `json:"-"` +} + +// addressMapZoneUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [AddressMapZoneUpdateResponseEnvelope] +type addressMapZoneUpdateResponseEnvelopeJSON 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 *AddressMapZoneUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapZoneUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AddressMapZoneUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapZoneUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// addressMapZoneUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AddressMapZoneUpdateResponseEnvelopeErrors] +type addressMapZoneUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapZoneUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapZoneUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AddressMapZoneUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapZoneUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// addressMapZoneUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AddressMapZoneUpdateResponseEnvelopeMessages] +type addressMapZoneUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapZoneUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapZoneUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AddressMapZoneUpdateResponseEnvelopeSuccess bool + +const ( + AddressMapZoneUpdateResponseEnvelopeSuccessTrue AddressMapZoneUpdateResponseEnvelopeSuccess = true +) + +type AddressMapZoneUpdateResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON addressMapZoneUpdateResponseEnvelopeResultInfoJSON `json:"-"` +} + +// addressMapZoneUpdateResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [AddressMapZoneUpdateResponseEnvelopeResultInfo] +type addressMapZoneUpdateResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapZoneUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapZoneUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type AddressMapZoneDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type AddressMapZoneDeleteResponseEnvelope struct { + Errors []AddressMapZoneDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []AddressMapZoneDeleteResponseEnvelopeMessages `json:"messages,required"` + Result AddressMapZoneDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AddressMapZoneDeleteResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AddressMapZoneDeleteResponseEnvelopeResultInfo `json:"result_info"` + JSON addressMapZoneDeleteResponseEnvelopeJSON `json:"-"` +} + +// addressMapZoneDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [AddressMapZoneDeleteResponseEnvelope] +type addressMapZoneDeleteResponseEnvelopeJSON 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 *AddressMapZoneDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapZoneDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AddressMapZoneDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapZoneDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// addressMapZoneDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AddressMapZoneDeleteResponseEnvelopeErrors] +type addressMapZoneDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapZoneDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapZoneDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AddressMapZoneDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON addressMapZoneDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// addressMapZoneDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AddressMapZoneDeleteResponseEnvelopeMessages] +type addressMapZoneDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapZoneDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapZoneDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AddressMapZoneDeleteResponseEnvelopeSuccess bool + +const ( + AddressMapZoneDeleteResponseEnvelopeSuccessTrue AddressMapZoneDeleteResponseEnvelopeSuccess = true +) + +type AddressMapZoneDeleteResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON addressMapZoneDeleteResponseEnvelopeResultInfoJSON `json:"-"` +} + +// addressMapZoneDeleteResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [AddressMapZoneDeleteResponseEnvelopeResultInfo] +type addressMapZoneDeleteResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressMapZoneDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressMapZoneDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/addressing/addressmapzone_test.go b/addressing/addressmapzone_test.go new file mode 100644 index 00000000000..4da0476f172 --- /dev/null +++ b/addressing/addressmapzone_test.go @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/addressing" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestAddressMapZoneUpdate(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("user@example.com"), + ) + _, err := client.Addressing.AddressMaps.Zones.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.AddressMapZoneUpdateParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + AccountID: cloudflare.F("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()) + } +} + +func TestAddressMapZoneDelete(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("user@example.com"), + ) + _, err := client.Addressing.AddressMaps.Zones.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.AddressMapZoneDeleteParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + AccountID: cloudflare.F("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/addressing/aliases.go b/addressing/aliases.go new file mode 100644 index 00000000000..f75a215ad2a --- /dev/null +++ b/addressing/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/addressing/loadocument.go b/addressing/loadocument.go new file mode 100644 index 00000000000..d7b33d08f88 --- /dev/null +++ b/addressing/loadocument.go @@ -0,0 +1,161 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// LOADocumentService 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 [NewLOADocumentService] method +// instead. +type LOADocumentService struct { + Options []option.RequestOption + Downloads *LOADocumentDownloadService +} + +// NewLOADocumentService 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 NewLOADocumentService(opts ...option.RequestOption) (r *LOADocumentService) { + r = &LOADocumentService{} + r.Options = opts + r.Downloads = NewLOADocumentDownloadService(opts...) + return +} + +// Submit LOA document (pdf format) under the account. +func (r *LOADocumentService) New(ctx context.Context, params LOADocumentNewParams, opts ...option.RequestOption) (res *LOADocumentNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env LOADocumentNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/loa_documents", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type LOADocumentNewResponse struct { + // Name of LOA document. + Filename string `json:"filename"` + JSON loaDocumentNewResponseJSON `json:"-"` +} + +// loaDocumentNewResponseJSON contains the JSON metadata for the struct +// [LOADocumentNewResponse] +type loaDocumentNewResponseJSON struct { + Filename apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LOADocumentNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loaDocumentNewResponseJSON) RawJSON() string { + return r.raw +} + +type LOADocumentNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // LOA document to upload. + LOADocument param.Field[string] `json:"loa_document,required"` +} + +func (r LOADocumentNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type LOADocumentNewResponseEnvelope struct { + Errors []LOADocumentNewResponseEnvelopeErrors `json:"errors,required"` + Messages []LOADocumentNewResponseEnvelopeMessages `json:"messages,required"` + Result LOADocumentNewResponse `json:"result,required"` + // Whether the API call was successful + Success LOADocumentNewResponseEnvelopeSuccess `json:"success,required"` + JSON loaDocumentNewResponseEnvelopeJSON `json:"-"` +} + +// loaDocumentNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [LOADocumentNewResponseEnvelope] +type loaDocumentNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LOADocumentNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loaDocumentNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LOADocumentNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loaDocumentNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// loaDocumentNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [LOADocumentNewResponseEnvelopeErrors] +type loaDocumentNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LOADocumentNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loaDocumentNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LOADocumentNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loaDocumentNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// loaDocumentNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [LOADocumentNewResponseEnvelopeMessages] +type loaDocumentNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LOADocumentNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loaDocumentNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LOADocumentNewResponseEnvelopeSuccess bool + +const ( + LOADocumentNewResponseEnvelopeSuccessTrue LOADocumentNewResponseEnvelopeSuccess = true +) diff --git a/addressing/loadocument_test.go b/addressing/loadocument_test.go new file mode 100644 index 00000000000..a9a8c993741 --- /dev/null +++ b/addressing/loadocument_test.go @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/addressing" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestLOADocumentNew(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("user@example.com"), + ) + _, err := client.Addressing.LOADocuments.New(context.TODO(), addressing.LOADocumentNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + LOADocument: cloudflare.F("@document.pdf"), + }) + 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/addressing/loadocumentdownload.go b/addressing/loadocumentdownload.go new file mode 100644 index 00000000000..62a827ff412 --- /dev/null +++ b/addressing/loadocumentdownload.go @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// LOADocumentDownloadService 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 [NewLOADocumentDownloadService] +// method instead. +type LOADocumentDownloadService struct { + Options []option.RequestOption +} + +// NewLOADocumentDownloadService 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 NewLOADocumentDownloadService(opts ...option.RequestOption) (r *LOADocumentDownloadService) { + r = &LOADocumentDownloadService{} + r.Options = opts + return +} + +// Download specified LOA document under the account. +func (r *LOADocumentDownloadService) Get(ctx context.Context, loaDocumentID string, query LOADocumentDownloadGetParams, opts ...option.RequestOption) (res *LOADocumentDownloadGetResponse, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("accounts/%s/addressing/loa_documents/%s/download", query.AccountID, loaDocumentID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +type LOADocumentDownloadGetResponse = interface{} + +type LOADocumentDownloadGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} diff --git a/addressing/loadocumentdownload_test.go b/addressing/loadocumentdownload_test.go new file mode 100644 index 00000000000..8d5e977b202 --- /dev/null +++ b/addressing/loadocumentdownload_test.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/addressing" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestLOADocumentDownloadGet(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("user@example.com"), + ) + _, err := client.Addressing.LOADocuments.Downloads.Get( + context.TODO(), + "d933b1530bc56c9953cf8ce166da8004", + addressing.LOADocumentDownloadGetParams{ + AccountID: cloudflare.F("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/addressing/prefix.go b/addressing/prefix.go new file mode 100644 index 00000000000..d76c535c7d0 --- /dev/null +++ b/addressing/prefix.go @@ -0,0 +1,701 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// PrefixService 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 [NewPrefixService] method instead. +type PrefixService struct { + Options []option.RequestOption + BGP *PrefixBGPService + Delegations *PrefixDelegationService +} + +// NewPrefixService 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 NewPrefixService(opts ...option.RequestOption) (r *PrefixService) { + r = &PrefixService{} + r.Options = opts + r.BGP = NewPrefixBGPService(opts...) + r.Delegations = NewPrefixDelegationService(opts...) + return +} + +// Add a new prefix under the account. +func (r *PrefixService) New(ctx context.Context, params PrefixNewParams, opts ...option.RequestOption) (res *AddressingIpamPrefixes, err error) { + opts = append(r.Options[:], opts...) + var env PrefixNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/prefixes", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List all prefixes owned by the account. +func (r *PrefixService) List(ctx context.Context, query PrefixListParams, opts ...option.RequestOption) (res *[]AddressingIpamPrefixes, err error) { + opts = append(r.Options[:], opts...) + var env PrefixListResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/prefixes", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete an unapproved prefix owned by the account. +func (r *PrefixService) Delete(ctx context.Context, prefixID string, body PrefixDeleteParams, opts ...option.RequestOption) (res *PrefixDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env PrefixDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s", body.AccountID, prefixID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Modify the description for a prefix owned by the account. +func (r *PrefixService) Edit(ctx context.Context, prefixID string, params PrefixEditParams, opts ...option.RequestOption) (res *AddressingIpamPrefixes, err error) { + opts = append(r.Options[:], opts...) + var env PrefixEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s", params.AccountID, prefixID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List a particular prefix owned by the account. +func (r *PrefixService) Get(ctx context.Context, prefixID string, query PrefixGetParams, opts ...option.RequestOption) (res *AddressingIpamPrefixes, err error) { + opts = append(r.Options[:], opts...) + var env PrefixGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s", query.AccountID, prefixID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AddressingIpamPrefixes struct { + // Identifier + ID string `json:"id"` + // Identifier + AccountID string `json:"account_id"` + // Prefix advertisement status to the Internet. This field is only not 'null' if on + // demand is enabled. + Advertised bool `json:"advertised,nullable"` + // Last time the advertisement status was changed. This field is only not 'null' if + // on demand is enabled. + AdvertisedModifiedAt time.Time `json:"advertised_modified_at,nullable" format:"date-time"` + // Approval state of the prefix (P = pending, V = active). + Approved string `json:"approved"` + // Autonomous System Number (ASN) the prefix will be advertised under. + ASN int64 `json:"asn,nullable"` + // IP Prefix in Classless Inter-Domain Routing format. + Cidr string `json:"cidr"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // Description of the prefix. + Description string `json:"description"` + // Identifier for the uploaded LOA document. + LOADocumentID string `json:"loa_document_id,nullable"` + ModifiedAt time.Time `json:"modified_at" format:"date-time"` + // Whether advertisement of the prefix to the Internet may be dynamically enabled + // or disabled. + OnDemandEnabled bool `json:"on_demand_enabled"` + // Whether advertisement status of the prefix is locked, meaning it cannot be + // changed. + OnDemandLocked bool `json:"on_demand_locked"` + JSON addressingIpamPrefixesJSON `json:"-"` +} + +// addressingIpamPrefixesJSON contains the JSON metadata for the struct +// [AddressingIpamPrefixes] +type addressingIpamPrefixesJSON struct { + ID apijson.Field + AccountID apijson.Field + Advertised apijson.Field + AdvertisedModifiedAt apijson.Field + Approved apijson.Field + ASN apijson.Field + Cidr apijson.Field + CreatedAt apijson.Field + Description apijson.Field + LOADocumentID apijson.Field + ModifiedAt apijson.Field + OnDemandEnabled apijson.Field + OnDemandLocked apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressingIpamPrefixes) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressingIpamPrefixesJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [addressing.PrefixDeleteResponseUnknown], +// [addressing.PrefixDeleteResponseArray] or [shared.UnionString]. +type PrefixDeleteResponse interface { + ImplementsAddressingPrefixDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*PrefixDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(PrefixDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type PrefixDeleteResponseArray []interface{} + +func (r PrefixDeleteResponseArray) ImplementsAddressingPrefixDeleteResponse() {} + +type PrefixNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Autonomous System Number (ASN) the prefix will be advertised under. + ASN param.Field[int64] `json:"asn,required"` + // IP Prefix in Classless Inter-Domain Routing format. + Cidr param.Field[string] `json:"cidr,required"` + // Identifier for the uploaded LOA document. + LOADocumentID param.Field[string] `json:"loa_document_id,required"` +} + +func (r PrefixNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type PrefixNewResponseEnvelope struct { + Errors []PrefixNewResponseEnvelopeErrors `json:"errors,required"` + Messages []PrefixNewResponseEnvelopeMessages `json:"messages,required"` + Result AddressingIpamPrefixes `json:"result,required"` + // Whether the API call was successful + Success PrefixNewResponseEnvelopeSuccess `json:"success,required"` + JSON prefixNewResponseEnvelopeJSON `json:"-"` +} + +// prefixNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [PrefixNewResponseEnvelope] +type prefixNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PrefixNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// prefixNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PrefixNewResponseEnvelopeErrors] +type prefixNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PrefixNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// prefixNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PrefixNewResponseEnvelopeMessages] +type prefixNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PrefixNewResponseEnvelopeSuccess bool + +const ( + PrefixNewResponseEnvelopeSuccessTrue PrefixNewResponseEnvelopeSuccess = true +) + +type PrefixListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type PrefixListResponseEnvelope struct { + Errors []PrefixListResponseEnvelopeErrors `json:"errors,required"` + Messages []PrefixListResponseEnvelopeMessages `json:"messages,required"` + Result []AddressingIpamPrefixes `json:"result,required,nullable"` + // Whether the API call was successful + Success PrefixListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo PrefixListResponseEnvelopeResultInfo `json:"result_info"` + JSON prefixListResponseEnvelopeJSON `json:"-"` +} + +// prefixListResponseEnvelopeJSON contains the JSON metadata for the struct +// [PrefixListResponseEnvelope] +type prefixListResponseEnvelopeJSON 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 *PrefixListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PrefixListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixListResponseEnvelopeErrorsJSON `json:"-"` +} + +// prefixListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PrefixListResponseEnvelopeErrors] +type prefixListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PrefixListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixListResponseEnvelopeMessagesJSON `json:"-"` +} + +// prefixListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PrefixListResponseEnvelopeMessages] +type prefixListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PrefixListResponseEnvelopeSuccess bool + +const ( + PrefixListResponseEnvelopeSuccessTrue PrefixListResponseEnvelopeSuccess = true +) + +type PrefixListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON prefixListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// prefixListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [PrefixListResponseEnvelopeResultInfo] +type prefixListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type PrefixDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type PrefixDeleteResponseEnvelope struct { + Errors []PrefixDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []PrefixDeleteResponseEnvelopeMessages `json:"messages,required"` + Result PrefixDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success PrefixDeleteResponseEnvelopeSuccess `json:"success,required"` + ResultInfo PrefixDeleteResponseEnvelopeResultInfo `json:"result_info"` + JSON prefixDeleteResponseEnvelopeJSON `json:"-"` +} + +// prefixDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [PrefixDeleteResponseEnvelope] +type prefixDeleteResponseEnvelopeJSON 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 *PrefixDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PrefixDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// prefixDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PrefixDeleteResponseEnvelopeErrors] +type prefixDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PrefixDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// prefixDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [PrefixDeleteResponseEnvelopeMessages] +type prefixDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PrefixDeleteResponseEnvelopeSuccess bool + +const ( + PrefixDeleteResponseEnvelopeSuccessTrue PrefixDeleteResponseEnvelopeSuccess = true +) + +type PrefixDeleteResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON prefixDeleteResponseEnvelopeResultInfoJSON `json:"-"` +} + +// prefixDeleteResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [PrefixDeleteResponseEnvelopeResultInfo] +type prefixDeleteResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type PrefixEditParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Description of the prefix. + Description param.Field[string] `json:"description,required"` +} + +func (r PrefixEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type PrefixEditResponseEnvelope struct { + Errors []PrefixEditResponseEnvelopeErrors `json:"errors,required"` + Messages []PrefixEditResponseEnvelopeMessages `json:"messages,required"` + Result AddressingIpamPrefixes `json:"result,required"` + // Whether the API call was successful + Success PrefixEditResponseEnvelopeSuccess `json:"success,required"` + JSON prefixEditResponseEnvelopeJSON `json:"-"` +} + +// prefixEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [PrefixEditResponseEnvelope] +type prefixEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PrefixEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// prefixEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PrefixEditResponseEnvelopeErrors] +type prefixEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PrefixEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// prefixEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PrefixEditResponseEnvelopeMessages] +type prefixEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PrefixEditResponseEnvelopeSuccess bool + +const ( + PrefixEditResponseEnvelopeSuccessTrue PrefixEditResponseEnvelopeSuccess = true +) + +type PrefixGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type PrefixGetResponseEnvelope struct { + Errors []PrefixGetResponseEnvelopeErrors `json:"errors,required"` + Messages []PrefixGetResponseEnvelopeMessages `json:"messages,required"` + Result AddressingIpamPrefixes `json:"result,required"` + // Whether the API call was successful + Success PrefixGetResponseEnvelopeSuccess `json:"success,required"` + JSON prefixGetResponseEnvelopeJSON `json:"-"` +} + +// prefixGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [PrefixGetResponseEnvelope] +type prefixGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PrefixGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// prefixGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PrefixGetResponseEnvelopeErrors] +type prefixGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PrefixGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// prefixGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PrefixGetResponseEnvelopeMessages] +type prefixGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PrefixGetResponseEnvelopeSuccess bool + +const ( + PrefixGetResponseEnvelopeSuccessTrue PrefixGetResponseEnvelopeSuccess = true +) diff --git a/addressing/prefix_test.go b/addressing/prefix_test.go new file mode 100644 index 00000000000..781c8f4d65d --- /dev/null +++ b/addressing/prefix_test.go @@ -0,0 +1,161 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/addressing" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestPrefixNew(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("user@example.com"), + ) + _, err := client.Addressing.Prefixes.New(context.TODO(), addressing.PrefixNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + ASN: cloudflare.F(int64(209242)), + Cidr: cloudflare.F("192.0.2.0/24"), + LOADocumentID: cloudflare.F("d933b1530bc56c9953cf8ce166da8004"), + }) + 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 TestPrefixList(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("user@example.com"), + ) + _, err := client.Addressing.Prefixes.List(context.TODO(), addressing.PrefixListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestPrefixDelete(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("user@example.com"), + ) + _, err := client.Addressing.Prefixes.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.PrefixDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestPrefixEdit(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("user@example.com"), + ) + _, err := client.Addressing.Prefixes.Edit( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.PrefixEditParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Description: cloudflare.F("Internal test prefix"), + }, + ) + 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 TestPrefixGet(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("user@example.com"), + ) + _, err := client.Addressing.Prefixes.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.PrefixGetParams{ + AccountID: cloudflare.F("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/addressing/prefixbgp.go b/addressing/prefixbgp.go new file mode 100644 index 00000000000..f2c918f5b2d --- /dev/null +++ b/addressing/prefixbgp.go @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// PrefixBGPService 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 [NewPrefixBGPService] method instead. +type PrefixBGPService struct { + Options []option.RequestOption + Bindings *PrefixBGPBindingService + Prefixes *PrefixBGPPrefixService + Statuses *PrefixBGPStatusService +} + +// NewPrefixBGPService 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 NewPrefixBGPService(opts ...option.RequestOption) (r *PrefixBGPService) { + r = &PrefixBGPService{} + r.Options = opts + r.Bindings = NewPrefixBGPBindingService(opts...) + r.Prefixes = NewPrefixBGPPrefixService(opts...) + r.Statuses = NewPrefixBGPStatusService(opts...) + return +} diff --git a/addressing/prefixbgpbinding.go b/addressing/prefixbgpbinding.go new file mode 100644 index 00000000000..4a19f704d68 --- /dev/null +++ b/addressing/prefixbgpbinding.go @@ -0,0 +1,539 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// PrefixBGPBindingService 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 [NewPrefixBGPBindingService] method +// instead. +type PrefixBGPBindingService struct { + Options []option.RequestOption +} + +// NewPrefixBGPBindingService 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 NewPrefixBGPBindingService(opts ...option.RequestOption) (r *PrefixBGPBindingService) { + r = &PrefixBGPBindingService{} + r.Options = opts + return +} + +// Creates a new Service Binding, routing traffic to IPs within the given CIDR to a +// service running on Cloudflare's network. **Note:** This API may only be used on +// prefixes currently configured with a Magic Transit service binding, and only +// allows creating service bindings for the Cloudflare CDN or Cloudflare Spectrum. +func (r *PrefixBGPBindingService) New(ctx context.Context, prefixID string, params PrefixBGPBindingNewParams, opts ...option.RequestOption) (res *AddressingServiceBinding, err error) { + opts = append(r.Options[:], opts...) + var env PrefixBGPBindingNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bindings", params.AccountID, prefixID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List the Cloudflare services this prefix is currently bound to. Traffic sent to +// an address within an IP prefix will be routed to the Cloudflare service of the +// most-specific Service Binding matching the address. **Example:** binding +// `192.0.2.0/24` to Cloudflare Magic Transit and `192.0.2.1/32` to the Cloudflare +// CDN would route traffic for `192.0.2.1` to the CDN, and traffic for all other +// IPs in the prefix to Cloudflare Magic Transit. +func (r *PrefixBGPBindingService) List(ctx context.Context, prefixID string, query PrefixBGPBindingListParams, opts ...option.RequestOption) (res *[]AddressingServiceBinding, err error) { + opts = append(r.Options[:], opts...) + var env PrefixBGPBindingListResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bindings", query.AccountID, prefixID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a Service Binding +func (r *PrefixBGPBindingService) Delete(ctx context.Context, prefixID string, bindingID string, body PrefixBGPBindingDeleteParams, opts ...option.RequestOption) (res *PrefixBGPBindingDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env PrefixBGPBindingDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bindings/%s", body.AccountID, prefixID, bindingID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch a single Service Binding +func (r *PrefixBGPBindingService) Get(ctx context.Context, prefixID string, bindingID string, query PrefixBGPBindingGetParams, opts ...option.RequestOption) (res *AddressingServiceBinding, err error) { + opts = append(r.Options[:], opts...) + var env PrefixBGPBindingGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bindings/%s", query.AccountID, prefixID, bindingID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AddressingServiceBinding struct { + // Identifier + ID string `json:"id"` + // IP Prefix in Classless Inter-Domain Routing format. + Cidr string `json:"cidr"` + // Status of a Service Binding's deployment to the Cloudflare network + Provisioning AddressingServiceBindingProvisioning `json:"provisioning"` + // Identifier + ServiceID string `json:"service_id"` + // Name of a service running on the Cloudflare network + ServiceName string `json:"service_name"` + JSON addressingServiceBindingJSON `json:"-"` +} + +// addressingServiceBindingJSON contains the JSON metadata for the struct +// [AddressingServiceBinding] +type addressingServiceBindingJSON struct { + ID apijson.Field + Cidr apijson.Field + Provisioning apijson.Field + ServiceID apijson.Field + ServiceName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressingServiceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressingServiceBindingJSON) RawJSON() string { + return r.raw +} + +// Status of a Service Binding's deployment to the Cloudflare network +type AddressingServiceBindingProvisioning struct { + // When a binding has been deployed to a majority of Cloudflare datacenters, the + // binding will become active and can be used with its associated service. + State AddressingServiceBindingProvisioningState `json:"state"` + JSON addressingServiceBindingProvisioningJSON `json:"-"` +} + +// addressingServiceBindingProvisioningJSON contains the JSON metadata for the +// struct [AddressingServiceBindingProvisioning] +type addressingServiceBindingProvisioningJSON struct { + State apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressingServiceBindingProvisioning) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressingServiceBindingProvisioningJSON) RawJSON() string { + return r.raw +} + +// When a binding has been deployed to a majority of Cloudflare datacenters, the +// binding will become active and can be used with its associated service. +type AddressingServiceBindingProvisioningState string + +const ( + AddressingServiceBindingProvisioningStateProvisioning AddressingServiceBindingProvisioningState = "provisioning" + AddressingServiceBindingProvisioningStateActive AddressingServiceBindingProvisioningState = "active" +) + +// Union satisfied by [addressing.PrefixBGPBindingDeleteResponseUnknown], +// [addressing.PrefixBGPBindingDeleteResponseArray] or [shared.UnionString]. +type PrefixBGPBindingDeleteResponse interface { + ImplementsAddressingPrefixBGPBindingDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*PrefixBGPBindingDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(PrefixBGPBindingDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type PrefixBGPBindingDeleteResponseArray []interface{} + +func (r PrefixBGPBindingDeleteResponseArray) ImplementsAddressingPrefixBGPBindingDeleteResponse() {} + +type PrefixBGPBindingNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // IP Prefix in Classless Inter-Domain Routing format. + Cidr param.Field[string] `json:"cidr"` + // Identifier + ServiceID param.Field[string] `json:"service_id"` +} + +func (r PrefixBGPBindingNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type PrefixBGPBindingNewResponseEnvelope struct { + Errors []PrefixBGPBindingNewResponseEnvelopeErrors `json:"errors,required"` + Messages []PrefixBGPBindingNewResponseEnvelopeMessages `json:"messages,required"` + Result AddressingServiceBinding `json:"result,required"` + // Whether the API call was successful + Success PrefixBGPBindingNewResponseEnvelopeSuccess `json:"success,required"` + JSON prefixBGPBindingNewResponseEnvelopeJSON `json:"-"` +} + +// prefixBGPBindingNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [PrefixBGPBindingNewResponseEnvelope] +type prefixBGPBindingNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPBindingNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPBindingNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPBindingNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixBGPBindingNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// prefixBGPBindingNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [PrefixBGPBindingNewResponseEnvelopeErrors] +type prefixBGPBindingNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPBindingNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPBindingNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPBindingNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixBGPBindingNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// prefixBGPBindingNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [PrefixBGPBindingNewResponseEnvelopeMessages] +type prefixBGPBindingNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPBindingNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPBindingNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PrefixBGPBindingNewResponseEnvelopeSuccess bool + +const ( + PrefixBGPBindingNewResponseEnvelopeSuccessTrue PrefixBGPBindingNewResponseEnvelopeSuccess = true +) + +type PrefixBGPBindingListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type PrefixBGPBindingListResponseEnvelope struct { + Errors []PrefixBGPBindingListResponseEnvelopeErrors `json:"errors,required"` + Messages []PrefixBGPBindingListResponseEnvelopeMessages `json:"messages,required"` + Result []AddressingServiceBinding `json:"result,required"` + // Whether the API call was successful + Success PrefixBGPBindingListResponseEnvelopeSuccess `json:"success,required"` + JSON prefixBGPBindingListResponseEnvelopeJSON `json:"-"` +} + +// prefixBGPBindingListResponseEnvelopeJSON contains the JSON metadata for the +// struct [PrefixBGPBindingListResponseEnvelope] +type prefixBGPBindingListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPBindingListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPBindingListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPBindingListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixBGPBindingListResponseEnvelopeErrorsJSON `json:"-"` +} + +// prefixBGPBindingListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [PrefixBGPBindingListResponseEnvelopeErrors] +type prefixBGPBindingListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPBindingListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPBindingListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPBindingListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixBGPBindingListResponseEnvelopeMessagesJSON `json:"-"` +} + +// prefixBGPBindingListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [PrefixBGPBindingListResponseEnvelopeMessages] +type prefixBGPBindingListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPBindingListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPBindingListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PrefixBGPBindingListResponseEnvelopeSuccess bool + +const ( + PrefixBGPBindingListResponseEnvelopeSuccessTrue PrefixBGPBindingListResponseEnvelopeSuccess = true +) + +type PrefixBGPBindingDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type PrefixBGPBindingDeleteResponseEnvelope struct { + Errors []PrefixBGPBindingDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []PrefixBGPBindingDeleteResponseEnvelopeMessages `json:"messages,required"` + Result PrefixBGPBindingDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success PrefixBGPBindingDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON prefixBGPBindingDeleteResponseEnvelopeJSON `json:"-"` +} + +// prefixBGPBindingDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [PrefixBGPBindingDeleteResponseEnvelope] +type prefixBGPBindingDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPBindingDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPBindingDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPBindingDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixBGPBindingDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// prefixBGPBindingDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [PrefixBGPBindingDeleteResponseEnvelopeErrors] +type prefixBGPBindingDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPBindingDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPBindingDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPBindingDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixBGPBindingDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// prefixBGPBindingDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [PrefixBGPBindingDeleteResponseEnvelopeMessages] +type prefixBGPBindingDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPBindingDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPBindingDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PrefixBGPBindingDeleteResponseEnvelopeSuccess bool + +const ( + PrefixBGPBindingDeleteResponseEnvelopeSuccessTrue PrefixBGPBindingDeleteResponseEnvelopeSuccess = true +) + +type PrefixBGPBindingGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type PrefixBGPBindingGetResponseEnvelope struct { + Errors []PrefixBGPBindingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []PrefixBGPBindingGetResponseEnvelopeMessages `json:"messages,required"` + Result AddressingServiceBinding `json:"result,required"` + // Whether the API call was successful + Success PrefixBGPBindingGetResponseEnvelopeSuccess `json:"success,required"` + JSON prefixBGPBindingGetResponseEnvelopeJSON `json:"-"` +} + +// prefixBGPBindingGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [PrefixBGPBindingGetResponseEnvelope] +type prefixBGPBindingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPBindingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPBindingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPBindingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixBGPBindingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// prefixBGPBindingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [PrefixBGPBindingGetResponseEnvelopeErrors] +type prefixBGPBindingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPBindingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPBindingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPBindingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixBGPBindingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// prefixBGPBindingGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [PrefixBGPBindingGetResponseEnvelopeMessages] +type prefixBGPBindingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPBindingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPBindingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PrefixBGPBindingGetResponseEnvelopeSuccess bool + +const ( + PrefixBGPBindingGetResponseEnvelopeSuccessTrue PrefixBGPBindingGetResponseEnvelopeSuccess = true +) diff --git a/addressing/prefixbgpbinding_test.go b/addressing/prefixbgpbinding_test.go new file mode 100644 index 00000000000..1f8e7d0183d --- /dev/null +++ b/addressing/prefixbgpbinding_test.go @@ -0,0 +1,139 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/addressing" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestPrefixBGPBindingNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Addressing.Prefixes.BGP.Bindings.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.PrefixBGPBindingNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Cidr: cloudflare.F("192.0.2.0/24"), + ServiceID: cloudflare.F("2db684ee7ca04e159946fd05b99e1bcd"), + }, + ) + 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 TestPrefixBGPBindingList(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("user@example.com"), + ) + _, err := client.Addressing.Prefixes.BGP.Bindings.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.PrefixBGPBindingListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestPrefixBGPBindingDelete(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("user@example.com"), + ) + _, err := client.Addressing.Prefixes.BGP.Bindings.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.PrefixBGPBindingDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestPrefixBGPBindingGet(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("user@example.com"), + ) + _, err := client.Addressing.Prefixes.BGP.Bindings.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.PrefixBGPBindingGetParams{ + AccountID: cloudflare.F("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/addressing/prefixbgpprefix.go b/addressing/prefixbgpprefix.go new file mode 100644 index 00000000000..821f5f80fc6 --- /dev/null +++ b/addressing/prefixbgpprefix.go @@ -0,0 +1,478 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// PrefixBGPPrefixService 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 [NewPrefixBGPPrefixService] method +// instead. +type PrefixBGPPrefixService struct { + Options []option.RequestOption +} + +// NewPrefixBGPPrefixService 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 NewPrefixBGPPrefixService(opts ...option.RequestOption) (r *PrefixBGPPrefixService) { + r = &PrefixBGPPrefixService{} + r.Options = opts + return +} + +// List all BGP Prefixes within the specified IP Prefix. BGP Prefixes are used to +// control which specific subnets are advertised to the Internet. It is possible to +// advertise subnets more specific than an IP Prefix by creating more specific BGP +// Prefixes. +func (r *PrefixBGPPrefixService) List(ctx context.Context, prefixID string, query PrefixBGPPrefixListParams, opts ...option.RequestOption) (res *[]AddressingIpamBGPPrefixes, err error) { + opts = append(r.Options[:], opts...) + var env PrefixBGPPrefixListResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bgp/prefixes", query.AccountID, prefixID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update the properties of a BGP Prefix, such as the on demand advertisement +// status (advertised or withdrawn). +func (r *PrefixBGPPrefixService) Edit(ctx context.Context, prefixID string, bgpPrefixID string, params PrefixBGPPrefixEditParams, opts ...option.RequestOption) (res *AddressingIpamBGPPrefixes, err error) { + opts = append(r.Options[:], opts...) + var env PrefixBGPPrefixEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bgp/prefixes/%s", params.AccountID, prefixID, bgpPrefixID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Retrieve a single BGP Prefix according to its identifier +func (r *PrefixBGPPrefixService) Get(ctx context.Context, prefixID string, bgpPrefixID string, query PrefixBGPPrefixGetParams, opts ...option.RequestOption) (res *AddressingIpamBGPPrefixes, err error) { + opts = append(r.Options[:], opts...) + var env PrefixBGPPrefixGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bgp/prefixes/%s", query.AccountID, prefixID, bgpPrefixID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AddressingIpamBGPPrefixes struct { + // Identifier + ID string `json:"id"` + // Autonomous System Number (ASN) the prefix will be advertised under. + ASN int64 `json:"asn,nullable"` + BGPSignalOpts AddressingIpamBGPPrefixesBGPSignalOpts `json:"bgp_signal_opts"` + // IP Prefix in Classless Inter-Domain Routing format. + Cidr string `json:"cidr"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + ModifiedAt time.Time `json:"modified_at" format:"date-time"` + OnDemand AddressingIpamBGPPrefixesOnDemand `json:"on_demand"` + JSON addressingIpamBGPPrefixesJSON `json:"-"` +} + +// addressingIpamBGPPrefixesJSON contains the JSON metadata for the struct +// [AddressingIpamBGPPrefixes] +type addressingIpamBGPPrefixesJSON struct { + ID apijson.Field + ASN apijson.Field + BGPSignalOpts apijson.Field + Cidr apijson.Field + CreatedAt apijson.Field + ModifiedAt apijson.Field + OnDemand apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressingIpamBGPPrefixes) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressingIpamBGPPrefixesJSON) RawJSON() string { + return r.raw +} + +type AddressingIpamBGPPrefixesBGPSignalOpts struct { + // Whether control of advertisement of the prefix to the Internet is enabled to be + // performed via BGP signal + Enabled bool `json:"enabled"` + // Last time BGP signaling control was toggled. This field is null if BGP signaling + // has never been enabled. + ModifiedAt time.Time `json:"modified_at,nullable" format:"date-time"` + JSON addressingIpamBGPPrefixesBGPSignalOptsJSON `json:"-"` +} + +// addressingIpamBGPPrefixesBGPSignalOptsJSON contains the JSON metadata for the +// struct [AddressingIpamBGPPrefixesBGPSignalOpts] +type addressingIpamBGPPrefixesBGPSignalOptsJSON struct { + Enabled apijson.Field + ModifiedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressingIpamBGPPrefixesBGPSignalOpts) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressingIpamBGPPrefixesBGPSignalOptsJSON) RawJSON() string { + return r.raw +} + +type AddressingIpamBGPPrefixesOnDemand struct { + // Prefix advertisement status to the Internet. This field is only not 'null' if on + // demand is enabled. + Advertised bool `json:"advertised,nullable"` + // Last time the advertisement status was changed. This field is only not 'null' if + // on demand is enabled. + AdvertisedModifiedAt time.Time `json:"advertised_modified_at,nullable" format:"date-time"` + // Whether advertisement of the prefix to the Internet may be dynamically enabled + // or disabled. + OnDemandEnabled bool `json:"on_demand_enabled"` + // Whether advertisement status of the prefix is locked, meaning it cannot be + // changed. + OnDemandLocked bool `json:"on_demand_locked"` + JSON addressingIpamBGPPrefixesOnDemandJSON `json:"-"` +} + +// addressingIpamBGPPrefixesOnDemandJSON contains the JSON metadata for the struct +// [AddressingIpamBGPPrefixesOnDemand] +type addressingIpamBGPPrefixesOnDemandJSON struct { + Advertised apijson.Field + AdvertisedModifiedAt apijson.Field + OnDemandEnabled apijson.Field + OnDemandLocked apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressingIpamBGPPrefixesOnDemand) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressingIpamBGPPrefixesOnDemandJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPPrefixListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type PrefixBGPPrefixListResponseEnvelope struct { + Errors []PrefixBGPPrefixListResponseEnvelopeErrors `json:"errors,required"` + Messages []PrefixBGPPrefixListResponseEnvelopeMessages `json:"messages,required"` + Result []AddressingIpamBGPPrefixes `json:"result,required,nullable"` + // Whether the API call was successful + Success PrefixBGPPrefixListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo PrefixBGPPrefixListResponseEnvelopeResultInfo `json:"result_info"` + JSON prefixBGPPrefixListResponseEnvelopeJSON `json:"-"` +} + +// prefixBGPPrefixListResponseEnvelopeJSON contains the JSON metadata for the +// struct [PrefixBGPPrefixListResponseEnvelope] +type prefixBGPPrefixListResponseEnvelopeJSON 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 *PrefixBGPPrefixListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPPrefixListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPPrefixListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixBGPPrefixListResponseEnvelopeErrorsJSON `json:"-"` +} + +// prefixBGPPrefixListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [PrefixBGPPrefixListResponseEnvelopeErrors] +type prefixBGPPrefixListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPPrefixListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPPrefixListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPPrefixListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixBGPPrefixListResponseEnvelopeMessagesJSON `json:"-"` +} + +// prefixBGPPrefixListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [PrefixBGPPrefixListResponseEnvelopeMessages] +type prefixBGPPrefixListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPPrefixListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPPrefixListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PrefixBGPPrefixListResponseEnvelopeSuccess bool + +const ( + PrefixBGPPrefixListResponseEnvelopeSuccessTrue PrefixBGPPrefixListResponseEnvelopeSuccess = true +) + +type PrefixBGPPrefixListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON prefixBGPPrefixListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// prefixBGPPrefixListResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [PrefixBGPPrefixListResponseEnvelopeResultInfo] +type prefixBGPPrefixListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPPrefixListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPPrefixListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPPrefixEditParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + OnDemand param.Field[PrefixBGPPrefixEditParamsOnDemand] `json:"on_demand"` +} + +func (r PrefixBGPPrefixEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type PrefixBGPPrefixEditParamsOnDemand struct { + Advertised param.Field[bool] `json:"advertised"` +} + +func (r PrefixBGPPrefixEditParamsOnDemand) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type PrefixBGPPrefixEditResponseEnvelope struct { + Errors []PrefixBGPPrefixEditResponseEnvelopeErrors `json:"errors,required"` + Messages []PrefixBGPPrefixEditResponseEnvelopeMessages `json:"messages,required"` + Result AddressingIpamBGPPrefixes `json:"result,required"` + // Whether the API call was successful + Success PrefixBGPPrefixEditResponseEnvelopeSuccess `json:"success,required"` + JSON prefixBGPPrefixEditResponseEnvelopeJSON `json:"-"` +} + +// prefixBGPPrefixEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [PrefixBGPPrefixEditResponseEnvelope] +type prefixBGPPrefixEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPPrefixEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPPrefixEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPPrefixEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixBGPPrefixEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// prefixBGPPrefixEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [PrefixBGPPrefixEditResponseEnvelopeErrors] +type prefixBGPPrefixEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPPrefixEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPPrefixEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPPrefixEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixBGPPrefixEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// prefixBGPPrefixEditResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [PrefixBGPPrefixEditResponseEnvelopeMessages] +type prefixBGPPrefixEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPPrefixEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPPrefixEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PrefixBGPPrefixEditResponseEnvelopeSuccess bool + +const ( + PrefixBGPPrefixEditResponseEnvelopeSuccessTrue PrefixBGPPrefixEditResponseEnvelopeSuccess = true +) + +type PrefixBGPPrefixGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type PrefixBGPPrefixGetResponseEnvelope struct { + Errors []PrefixBGPPrefixGetResponseEnvelopeErrors `json:"errors,required"` + Messages []PrefixBGPPrefixGetResponseEnvelopeMessages `json:"messages,required"` + Result AddressingIpamBGPPrefixes `json:"result,required"` + // Whether the API call was successful + Success PrefixBGPPrefixGetResponseEnvelopeSuccess `json:"success,required"` + JSON prefixBGPPrefixGetResponseEnvelopeJSON `json:"-"` +} + +// prefixBGPPrefixGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [PrefixBGPPrefixGetResponseEnvelope] +type prefixBGPPrefixGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPPrefixGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPPrefixGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPPrefixGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixBGPPrefixGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// prefixBGPPrefixGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [PrefixBGPPrefixGetResponseEnvelopeErrors] +type prefixBGPPrefixGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPPrefixGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPPrefixGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPPrefixGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixBGPPrefixGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// prefixBGPPrefixGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [PrefixBGPPrefixGetResponseEnvelopeMessages] +type prefixBGPPrefixGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPPrefixGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPPrefixGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PrefixBGPPrefixGetResponseEnvelopeSuccess bool + +const ( + PrefixBGPPrefixGetResponseEnvelopeSuccessTrue PrefixBGPPrefixGetResponseEnvelopeSuccess = true +) diff --git a/addressing/prefixbgpprefix_test.go b/addressing/prefixbgpprefix_test.go new file mode 100644 index 00000000000..b063d175d74 --- /dev/null +++ b/addressing/prefixbgpprefix_test.go @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/addressing" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestPrefixBGPPrefixList(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("user@example.com"), + ) + _, err := client.Addressing.Prefixes.BGP.Prefixes.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.PrefixBGPPrefixListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestPrefixBGPPrefixEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Addressing.Prefixes.BGP.Prefixes.Edit( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.PrefixBGPPrefixEditParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + OnDemand: cloudflare.F(addressing.PrefixBGPPrefixEditParamsOnDemand{ + Advertised: cloudflare.F(true), + }), + }, + ) + 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 TestPrefixBGPPrefixGet(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("user@example.com"), + ) + _, err := client.Addressing.Prefixes.BGP.Prefixes.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.PrefixBGPPrefixGetParams{ + AccountID: cloudflare.F("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/addressing/prefixbgpstatus.go b/addressing/prefixbgpstatus.go new file mode 100644 index 00000000000..d20afcb3180 --- /dev/null +++ b/addressing/prefixbgpstatus.go @@ -0,0 +1,289 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// PrefixBGPStatusService 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 [NewPrefixBGPStatusService] method +// instead. +type PrefixBGPStatusService struct { + Options []option.RequestOption +} + +// NewPrefixBGPStatusService 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 NewPrefixBGPStatusService(opts ...option.RequestOption) (r *PrefixBGPStatusService) { + r = &PrefixBGPStatusService{} + r.Options = opts + return +} + +// Advertise or withdraw BGP route for a prefix. +func (r *PrefixBGPStatusService) Edit(ctx context.Context, prefixID string, params PrefixBGPStatusEditParams, opts ...option.RequestOption) (res *PrefixBGPStatusEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env PrefixBGPStatusEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bgp/status", params.AccountID, prefixID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List the current advertisement state for a prefix. +func (r *PrefixBGPStatusService) Get(ctx context.Context, prefixID string, query PrefixBGPStatusGetParams, opts ...option.RequestOption) (res *PrefixBGPStatusGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env PrefixBGPStatusGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bgp/status", query.AccountID, prefixID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type PrefixBGPStatusEditResponse struct { + // Enablement of prefix advertisement to the Internet. + Advertised bool `json:"advertised"` + // Last time the advertisement status was changed. This field is only not 'null' if + // on demand is enabled. + AdvertisedModifiedAt time.Time `json:"advertised_modified_at,nullable" format:"date-time"` + JSON prefixBGPStatusEditResponseJSON `json:"-"` +} + +// prefixBGPStatusEditResponseJSON contains the JSON metadata for the struct +// [PrefixBGPStatusEditResponse] +type prefixBGPStatusEditResponseJSON struct { + Advertised apijson.Field + AdvertisedModifiedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPStatusEditResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPStatusEditResponseJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPStatusGetResponse struct { + // Enablement of prefix advertisement to the Internet. + Advertised bool `json:"advertised"` + // Last time the advertisement status was changed. This field is only not 'null' if + // on demand is enabled. + AdvertisedModifiedAt time.Time `json:"advertised_modified_at,nullable" format:"date-time"` + JSON prefixBGPStatusGetResponseJSON `json:"-"` +} + +// prefixBGPStatusGetResponseJSON contains the JSON metadata for the struct +// [PrefixBGPStatusGetResponse] +type prefixBGPStatusGetResponseJSON struct { + Advertised apijson.Field + AdvertisedModifiedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPStatusGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPStatusGetResponseJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPStatusEditParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Enablement of prefix advertisement to the Internet. + Advertised param.Field[bool] `json:"advertised,required"` +} + +func (r PrefixBGPStatusEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type PrefixBGPStatusEditResponseEnvelope struct { + Errors []PrefixBGPStatusEditResponseEnvelopeErrors `json:"errors,required"` + Messages []PrefixBGPStatusEditResponseEnvelopeMessages `json:"messages,required"` + Result PrefixBGPStatusEditResponse `json:"result,required"` + // Whether the API call was successful + Success PrefixBGPStatusEditResponseEnvelopeSuccess `json:"success,required"` + JSON prefixBGPStatusEditResponseEnvelopeJSON `json:"-"` +} + +// prefixBGPStatusEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [PrefixBGPStatusEditResponseEnvelope] +type prefixBGPStatusEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPStatusEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPStatusEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPStatusEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixBGPStatusEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// prefixBGPStatusEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [PrefixBGPStatusEditResponseEnvelopeErrors] +type prefixBGPStatusEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPStatusEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPStatusEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPStatusEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixBGPStatusEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// prefixBGPStatusEditResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [PrefixBGPStatusEditResponseEnvelopeMessages] +type prefixBGPStatusEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPStatusEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPStatusEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PrefixBGPStatusEditResponseEnvelopeSuccess bool + +const ( + PrefixBGPStatusEditResponseEnvelopeSuccessTrue PrefixBGPStatusEditResponseEnvelopeSuccess = true +) + +type PrefixBGPStatusGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type PrefixBGPStatusGetResponseEnvelope struct { + Errors []PrefixBGPStatusGetResponseEnvelopeErrors `json:"errors,required"` + Messages []PrefixBGPStatusGetResponseEnvelopeMessages `json:"messages,required"` + Result PrefixBGPStatusGetResponse `json:"result,required"` + // Whether the API call was successful + Success PrefixBGPStatusGetResponseEnvelopeSuccess `json:"success,required"` + JSON prefixBGPStatusGetResponseEnvelopeJSON `json:"-"` +} + +// prefixBGPStatusGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [PrefixBGPStatusGetResponseEnvelope] +type prefixBGPStatusGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPStatusGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPStatusGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPStatusGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixBGPStatusGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// prefixBGPStatusGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [PrefixBGPStatusGetResponseEnvelopeErrors] +type prefixBGPStatusGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPStatusGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPStatusGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PrefixBGPStatusGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixBGPStatusGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// prefixBGPStatusGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [PrefixBGPStatusGetResponseEnvelopeMessages] +type prefixBGPStatusGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixBGPStatusGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixBGPStatusGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PrefixBGPStatusGetResponseEnvelopeSuccess bool + +const ( + PrefixBGPStatusGetResponseEnvelopeSuccessTrue PrefixBGPStatusGetResponseEnvelopeSuccess = true +) diff --git a/addressing/prefixbgpstatus_test.go b/addressing/prefixbgpstatus_test.go new file mode 100644 index 00000000000..e016e002f47 --- /dev/null +++ b/addressing/prefixbgpstatus_test.go @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/addressing" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestPrefixBGPStatusEdit(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("user@example.com"), + ) + _, err := client.Addressing.Prefixes.BGP.Statuses.Edit( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.PrefixBGPStatusEditParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Advertised: cloudflare.F(true), + }, + ) + 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 TestPrefixBGPStatusGet(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("user@example.com"), + ) + _, err := client.Addressing.Prefixes.BGP.Statuses.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.PrefixBGPStatusGetParams{ + AccountID: cloudflare.F("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/addressing/prefixdelegation.go b/addressing/prefixdelegation.go new file mode 100644 index 00000000000..64de623ed12 --- /dev/null +++ b/addressing/prefixdelegation.go @@ -0,0 +1,428 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// PrefixDelegationService 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 [NewPrefixDelegationService] method +// instead. +type PrefixDelegationService struct { + Options []option.RequestOption +} + +// NewPrefixDelegationService 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 NewPrefixDelegationService(opts ...option.RequestOption) (r *PrefixDelegationService) { + r = &PrefixDelegationService{} + r.Options = opts + return +} + +// Create a new account delegation for a given IP prefix. +func (r *PrefixDelegationService) New(ctx context.Context, prefixID string, params PrefixDelegationNewParams, opts ...option.RequestOption) (res *AddressingIpamDelegations, err error) { + opts = append(r.Options[:], opts...) + var env PrefixDelegationNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/delegations", params.AccountID, prefixID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List all delegations for a given account IP prefix. +func (r *PrefixDelegationService) List(ctx context.Context, prefixID string, query PrefixDelegationListParams, opts ...option.RequestOption) (res *[]AddressingIpamDelegations, err error) { + opts = append(r.Options[:], opts...) + var env PrefixDelegationListResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/delegations", query.AccountID, prefixID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete an account delegation for a given IP prefix. +func (r *PrefixDelegationService) Delete(ctx context.Context, prefixID string, delegationID string, body PrefixDelegationDeleteParams, opts ...option.RequestOption) (res *PrefixDelegationDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env PrefixDelegationDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/delegations/%s", body.AccountID, prefixID, delegationID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AddressingIpamDelegations struct { + // Delegation identifier tag. + ID string `json:"id"` + // IP Prefix in Classless Inter-Domain Routing format. + Cidr string `json:"cidr"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // Account identifier for the account to which prefix is being delegated. + DelegatedAccountID string `json:"delegated_account_id"` + ModifiedAt time.Time `json:"modified_at" format:"date-time"` + // Identifier + ParentPrefixID string `json:"parent_prefix_id"` + JSON addressingIpamDelegationsJSON `json:"-"` +} + +// addressingIpamDelegationsJSON contains the JSON metadata for the struct +// [AddressingIpamDelegations] +type addressingIpamDelegationsJSON struct { + ID apijson.Field + Cidr apijson.Field + CreatedAt apijson.Field + DelegatedAccountID apijson.Field + ModifiedAt apijson.Field + ParentPrefixID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AddressingIpamDelegations) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r addressingIpamDelegationsJSON) RawJSON() string { + return r.raw +} + +type PrefixDelegationDeleteResponse struct { + // Delegation identifier tag. + ID string `json:"id"` + JSON prefixDelegationDeleteResponseJSON `json:"-"` +} + +// prefixDelegationDeleteResponseJSON contains the JSON metadata for the struct +// [PrefixDelegationDeleteResponse] +type prefixDelegationDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixDelegationDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixDelegationDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type PrefixDelegationNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // IP Prefix in Classless Inter-Domain Routing format. + Cidr param.Field[string] `json:"cidr,required"` + // Account identifier for the account to which prefix is being delegated. + DelegatedAccountID param.Field[string] `json:"delegated_account_id,required"` +} + +func (r PrefixDelegationNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type PrefixDelegationNewResponseEnvelope struct { + Errors []PrefixDelegationNewResponseEnvelopeErrors `json:"errors,required"` + Messages []PrefixDelegationNewResponseEnvelopeMessages `json:"messages,required"` + Result AddressingIpamDelegations `json:"result,required"` + // Whether the API call was successful + Success PrefixDelegationNewResponseEnvelopeSuccess `json:"success,required"` + JSON prefixDelegationNewResponseEnvelopeJSON `json:"-"` +} + +// prefixDelegationNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [PrefixDelegationNewResponseEnvelope] +type prefixDelegationNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixDelegationNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixDelegationNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PrefixDelegationNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixDelegationNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// prefixDelegationNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [PrefixDelegationNewResponseEnvelopeErrors] +type prefixDelegationNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixDelegationNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixDelegationNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PrefixDelegationNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixDelegationNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// prefixDelegationNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [PrefixDelegationNewResponseEnvelopeMessages] +type prefixDelegationNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixDelegationNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixDelegationNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PrefixDelegationNewResponseEnvelopeSuccess bool + +const ( + PrefixDelegationNewResponseEnvelopeSuccessTrue PrefixDelegationNewResponseEnvelopeSuccess = true +) + +type PrefixDelegationListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type PrefixDelegationListResponseEnvelope struct { + Errors []PrefixDelegationListResponseEnvelopeErrors `json:"errors,required"` + Messages []PrefixDelegationListResponseEnvelopeMessages `json:"messages,required"` + Result []AddressingIpamDelegations `json:"result,required,nullable"` + // Whether the API call was successful + Success PrefixDelegationListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo PrefixDelegationListResponseEnvelopeResultInfo `json:"result_info"` + JSON prefixDelegationListResponseEnvelopeJSON `json:"-"` +} + +// prefixDelegationListResponseEnvelopeJSON contains the JSON metadata for the +// struct [PrefixDelegationListResponseEnvelope] +type prefixDelegationListResponseEnvelopeJSON 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 *PrefixDelegationListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixDelegationListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PrefixDelegationListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixDelegationListResponseEnvelopeErrorsJSON `json:"-"` +} + +// prefixDelegationListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [PrefixDelegationListResponseEnvelopeErrors] +type prefixDelegationListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixDelegationListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixDelegationListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PrefixDelegationListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixDelegationListResponseEnvelopeMessagesJSON `json:"-"` +} + +// prefixDelegationListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [PrefixDelegationListResponseEnvelopeMessages] +type prefixDelegationListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixDelegationListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixDelegationListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PrefixDelegationListResponseEnvelopeSuccess bool + +const ( + PrefixDelegationListResponseEnvelopeSuccessTrue PrefixDelegationListResponseEnvelopeSuccess = true +) + +type PrefixDelegationListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON prefixDelegationListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// prefixDelegationListResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [PrefixDelegationListResponseEnvelopeResultInfo] +type prefixDelegationListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixDelegationListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixDelegationListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type PrefixDelegationDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type PrefixDelegationDeleteResponseEnvelope struct { + Errors []PrefixDelegationDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []PrefixDelegationDeleteResponseEnvelopeMessages `json:"messages,required"` + Result PrefixDelegationDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success PrefixDelegationDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON prefixDelegationDeleteResponseEnvelopeJSON `json:"-"` +} + +// prefixDelegationDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [PrefixDelegationDeleteResponseEnvelope] +type prefixDelegationDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixDelegationDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixDelegationDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PrefixDelegationDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixDelegationDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// prefixDelegationDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [PrefixDelegationDeleteResponseEnvelopeErrors] +type prefixDelegationDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixDelegationDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixDelegationDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PrefixDelegationDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prefixDelegationDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// prefixDelegationDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [PrefixDelegationDeleteResponseEnvelopeMessages] +type prefixDelegationDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrefixDelegationDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prefixDelegationDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PrefixDelegationDeleteResponseEnvelopeSuccess bool + +const ( + PrefixDelegationDeleteResponseEnvelopeSuccessTrue PrefixDelegationDeleteResponseEnvelopeSuccess = true +) diff --git a/addressing/prefixdelegation_test.go b/addressing/prefixdelegation_test.go new file mode 100644 index 00000000000..4e1ea544b32 --- /dev/null +++ b/addressing/prefixdelegation_test.go @@ -0,0 +1,108 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/addressing" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestPrefixDelegationNew(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("user@example.com"), + ) + _, err := client.Addressing.Prefixes.Delegations.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.PrefixDelegationNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Cidr: cloudflare.F("192.0.2.0/24"), + DelegatedAccountID: cloudflare.F("b1946ac92492d2347c6235b4d2611184"), + }, + ) + 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 TestPrefixDelegationList(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("user@example.com"), + ) + _, err := client.Addressing.Prefixes.Delegations.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + addressing.PrefixDelegationListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestPrefixDelegationDelete(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("user@example.com"), + ) + _, err := client.Addressing.Prefixes.Delegations.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "d933b1530bc56c9953cf8ce166da8004", + addressing.PrefixDelegationDeleteParams{ + AccountID: cloudflare.F("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/addressing/service.go b/addressing/service.go new file mode 100644 index 00000000000..32b06b3f46e --- /dev/null +++ b/addressing/service.go @@ -0,0 +1,158 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ServiceService 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 [NewServiceService] method instead. +type ServiceService struct { + Options []option.RequestOption +} + +// NewServiceService 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 NewServiceService(opts ...option.RequestOption) (r *ServiceService) { + r = &ServiceService{} + r.Options = opts + return +} + +// Bring-Your-Own IP (BYOIP) prefixes onboarded to Cloudflare must be bound to a +// service running on the Cloudflare network to enable a Cloudflare product on the +// IP addresses. This endpoint can be used as a reference of available services on +// the Cloudflare network, and their service IDs. +func (r *ServiceService) List(ctx context.Context, query ServiceListParams, opts ...option.RequestOption) (res *[]ServiceListResponse, err error) { + opts = append(r.Options[:], opts...) + var env ServiceListResponseEnvelope + path := fmt.Sprintf("accounts/%s/addressing/services", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ServiceListResponse struct { + // Identifier + ID string `json:"id"` + // Name of a service running on the Cloudflare network + Name string `json:"name"` + JSON serviceListResponseJSON `json:"-"` +} + +// serviceListResponseJSON contains the JSON metadata for the struct +// [ServiceListResponse] +type serviceListResponseJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceListResponseJSON) RawJSON() string { + return r.raw +} + +type ServiceListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ServiceListResponseEnvelope struct { + Errors []ServiceListResponseEnvelopeErrors `json:"errors,required"` + Messages []ServiceListResponseEnvelopeMessages `json:"messages,required"` + Result []ServiceListResponse `json:"result,required"` + // Whether the API call was successful + Success ServiceListResponseEnvelopeSuccess `json:"success,required"` + JSON serviceListResponseEnvelopeJSON `json:"-"` +} + +// serviceListResponseEnvelopeJSON contains the JSON metadata for the struct +// [ServiceListResponseEnvelope] +type serviceListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ServiceListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON serviceListResponseEnvelopeErrorsJSON `json:"-"` +} + +// serviceListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ServiceListResponseEnvelopeErrors] +type serviceListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ServiceListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON serviceListResponseEnvelopeMessagesJSON `json:"-"` +} + +// serviceListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ServiceListResponseEnvelopeMessages] +type serviceListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ServiceListResponseEnvelopeSuccess bool + +const ( + ServiceListResponseEnvelopeSuccessTrue ServiceListResponseEnvelopeSuccess = true +) diff --git a/addressing/service_test.go b/addressing/service_test.go new file mode 100644 index 00000000000..e9a332b4c55 --- /dev/null +++ b/addressing/service_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package addressing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/addressing" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestServiceList(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("user@example.com"), + ) + _, err := client.Addressing.Services.List(context.TODO(), addressing.ServiceListParams{ + AccountID: cloudflare.F("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/addressingaddressmap.go b/addressingaddressmap.go deleted file mode 100644 index 06ead822a74..00000000000 --- a/addressingaddressmap.go +++ /dev/null @@ -1,989 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// AddressingAddressMapService 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 [NewAddressingAddressMapService] -// method instead. -type AddressingAddressMapService struct { - Options []option.RequestOption - Accounts *AddressingAddressMapAccountService - IPs *AddressingAddressMapIPService - Zones *AddressingAddressMapZoneService -} - -// NewAddressingAddressMapService 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 NewAddressingAddressMapService(opts ...option.RequestOption) (r *AddressingAddressMapService) { - r = &AddressingAddressMapService{} - r.Options = opts - r.Accounts = NewAddressingAddressMapAccountService(opts...) - r.IPs = NewAddressingAddressMapIPService(opts...) - r.Zones = NewAddressingAddressMapZoneService(opts...) - return -} - -// Create a new address map under the account. -func (r *AddressingAddressMapService) New(ctx context.Context, params AddressingAddressMapNewParams, opts ...option.RequestOption) (res *AddressingAddressMapNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingAddressMapNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/address_maps", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List all address maps owned by the account. -func (r *AddressingAddressMapService) List(ctx context.Context, query AddressingAddressMapListParams, opts ...option.RequestOption) (res *[]AddressingAddressMapListResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingAddressMapListResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/address_maps", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a particular address map owned by the account. An Address Map must be -// disabled before it can be deleted. -func (r *AddressingAddressMapService) Delete(ctx context.Context, addressMapID string, body AddressingAddressMapDeleteParams, opts ...option.RequestOption) (res *AddressingAddressMapDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingAddressMapDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s", body.AccountID, addressMapID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Modify properties of an address map owned by the account. -func (r *AddressingAddressMapService) Edit(ctx context.Context, addressMapID string, params AddressingAddressMapEditParams, opts ...option.RequestOption) (res *AddressingAddressMapEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingAddressMapEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s", params.AccountID, addressMapID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Show a particular address map owned by the account. -func (r *AddressingAddressMapService) Get(ctx context.Context, addressMapID string, query AddressingAddressMapGetParams, opts ...option.RequestOption) (res *AddressingAddressMapGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingAddressMapGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s", query.AccountID, addressMapID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type AddressingAddressMapNewResponse struct { - // Identifier - ID string `json:"id"` - // If set to false, then the Address Map cannot be deleted via API. This is true - // for Cloudflare-managed maps. - CanDelete bool `json:"can_delete"` - // If set to false, then the IPs on the Address Map cannot be modified via the API. - // This is true for Cloudflare-managed maps. - CanModifyIPs bool `json:"can_modify_ips"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // If you have legacy TLS clients which do not send the TLS server name indicator, - // then you can specify one default SNI on the map. If Cloudflare receives a TLS - // handshake from a client without an SNI, it will respond with the default SNI on - // those IPs. The default SNI can be any valid zone or subdomain owned by the - // account. - DefaultSni string `json:"default_sni,nullable"` - // An optional description field which may be used to describe the types of IPs or - // zones on the map. - Description string `json:"description,nullable"` - // Whether the Address Map is enabled or not. Cloudflare's DNS will not respond - // with IP addresses on an Address Map until the map is enabled. - Enabled bool `json:"enabled,nullable"` - // The set of IPs on the Address Map. - IPs []AddressingAddressMapNewResponseIP `json:"ips"` - // Zones and Accounts which will be assigned IPs on this Address Map. A zone - // membership will take priority over an account membership. - Memberships []AddressingAddressMapNewResponseMembership `json:"memberships"` - ModifiedAt time.Time `json:"modified_at" format:"date-time"` - JSON addressingAddressMapNewResponseJSON `json:"-"` -} - -// addressingAddressMapNewResponseJSON contains the JSON metadata for the struct -// [AddressingAddressMapNewResponse] -type addressingAddressMapNewResponseJSON struct { - ID apijson.Field - CanDelete apijson.Field - CanModifyIPs apijson.Field - CreatedAt apijson.Field - DefaultSni apijson.Field - Description apijson.Field - Enabled apijson.Field - IPs apijson.Field - Memberships apijson.Field - ModifiedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapNewResponseJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapNewResponseIP struct { - CreatedAt time.Time `json:"created_at" format:"date-time"` - // An IPv4 or IPv6 address. - IP string `json:"ip"` - JSON addressingAddressMapNewResponseIPJSON `json:"-"` -} - -// addressingAddressMapNewResponseIPJSON contains the JSON metadata for the struct -// [AddressingAddressMapNewResponseIP] -type addressingAddressMapNewResponseIPJSON struct { - CreatedAt apijson.Field - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapNewResponseIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapNewResponseIPJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapNewResponseMembership struct { - // Controls whether the membership can be deleted via the API or not. - CanDelete bool `json:"can_delete"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Identifier - Identifier string `json:"identifier"` - // The type of the membership. - Kind AddressingAddressMapNewResponseMembershipsKind `json:"kind"` - JSON addressingAddressMapNewResponseMembershipJSON `json:"-"` -} - -// addressingAddressMapNewResponseMembershipJSON contains the JSON metadata for the -// struct [AddressingAddressMapNewResponseMembership] -type addressingAddressMapNewResponseMembershipJSON struct { - CanDelete apijson.Field - CreatedAt apijson.Field - Identifier apijson.Field - Kind apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapNewResponseMembership) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapNewResponseMembershipJSON) RawJSON() string { - return r.raw -} - -// The type of the membership. -type AddressingAddressMapNewResponseMembershipsKind string - -const ( - AddressingAddressMapNewResponseMembershipsKindZone AddressingAddressMapNewResponseMembershipsKind = "zone" - AddressingAddressMapNewResponseMembershipsKindAccount AddressingAddressMapNewResponseMembershipsKind = "account" -) - -type AddressingAddressMapListResponse struct { - // Identifier - ID string `json:"id"` - // If set to false, then the Address Map cannot be deleted via API. This is true - // for Cloudflare-managed maps. - CanDelete bool `json:"can_delete"` - // If set to false, then the IPs on the Address Map cannot be modified via the API. - // This is true for Cloudflare-managed maps. - CanModifyIPs bool `json:"can_modify_ips"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // If you have legacy TLS clients which do not send the TLS server name indicator, - // then you can specify one default SNI on the map. If Cloudflare receives a TLS - // handshake from a client without an SNI, it will respond with the default SNI on - // those IPs. The default SNI can be any valid zone or subdomain owned by the - // account. - DefaultSni string `json:"default_sni,nullable"` - // An optional description field which may be used to describe the types of IPs or - // zones on the map. - Description string `json:"description,nullable"` - // Whether the Address Map is enabled or not. Cloudflare's DNS will not respond - // with IP addresses on an Address Map until the map is enabled. - Enabled bool `json:"enabled,nullable"` - ModifiedAt time.Time `json:"modified_at" format:"date-time"` - JSON addressingAddressMapListResponseJSON `json:"-"` -} - -// addressingAddressMapListResponseJSON contains the JSON metadata for the struct -// [AddressingAddressMapListResponse] -type addressingAddressMapListResponseJSON struct { - ID apijson.Field - CanDelete apijson.Field - CanModifyIPs apijson.Field - CreatedAt apijson.Field - DefaultSni apijson.Field - Description apijson.Field - Enabled apijson.Field - ModifiedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapListResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [AddressingAddressMapDeleteResponseUnknown], -// [AddressingAddressMapDeleteResponseArray] or [shared.UnionString]. -type AddressingAddressMapDeleteResponse interface { - ImplementsAddressingAddressMapDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AddressingAddressMapDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AddressingAddressMapDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type AddressingAddressMapDeleteResponseArray []interface{} - -func (r AddressingAddressMapDeleteResponseArray) ImplementsAddressingAddressMapDeleteResponse() {} - -type AddressingAddressMapEditResponse struct { - // Identifier - ID string `json:"id"` - // If set to false, then the Address Map cannot be deleted via API. This is true - // for Cloudflare-managed maps. - CanDelete bool `json:"can_delete"` - // If set to false, then the IPs on the Address Map cannot be modified via the API. - // This is true for Cloudflare-managed maps. - CanModifyIPs bool `json:"can_modify_ips"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // If you have legacy TLS clients which do not send the TLS server name indicator, - // then you can specify one default SNI on the map. If Cloudflare receives a TLS - // handshake from a client without an SNI, it will respond with the default SNI on - // those IPs. The default SNI can be any valid zone or subdomain owned by the - // account. - DefaultSni string `json:"default_sni,nullable"` - // An optional description field which may be used to describe the types of IPs or - // zones on the map. - Description string `json:"description,nullable"` - // Whether the Address Map is enabled or not. Cloudflare's DNS will not respond - // with IP addresses on an Address Map until the map is enabled. - Enabled bool `json:"enabled,nullable"` - ModifiedAt time.Time `json:"modified_at" format:"date-time"` - JSON addressingAddressMapEditResponseJSON `json:"-"` -} - -// addressingAddressMapEditResponseJSON contains the JSON metadata for the struct -// [AddressingAddressMapEditResponse] -type addressingAddressMapEditResponseJSON struct { - ID apijson.Field - CanDelete apijson.Field - CanModifyIPs apijson.Field - CreatedAt apijson.Field - DefaultSni apijson.Field - Description apijson.Field - Enabled apijson.Field - ModifiedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapEditResponseJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapGetResponse struct { - // Identifier - ID string `json:"id"` - // If set to false, then the Address Map cannot be deleted via API. This is true - // for Cloudflare-managed maps. - CanDelete bool `json:"can_delete"` - // If set to false, then the IPs on the Address Map cannot be modified via the API. - // This is true for Cloudflare-managed maps. - CanModifyIPs bool `json:"can_modify_ips"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // If you have legacy TLS clients which do not send the TLS server name indicator, - // then you can specify one default SNI on the map. If Cloudflare receives a TLS - // handshake from a client without an SNI, it will respond with the default SNI on - // those IPs. The default SNI can be any valid zone or subdomain owned by the - // account. - DefaultSni string `json:"default_sni,nullable"` - // An optional description field which may be used to describe the types of IPs or - // zones on the map. - Description string `json:"description,nullable"` - // Whether the Address Map is enabled or not. Cloudflare's DNS will not respond - // with IP addresses on an Address Map until the map is enabled. - Enabled bool `json:"enabled,nullable"` - // The set of IPs on the Address Map. - IPs []AddressingAddressMapGetResponseIP `json:"ips"` - // Zones and Accounts which will be assigned IPs on this Address Map. A zone - // membership will take priority over an account membership. - Memberships []AddressingAddressMapGetResponseMembership `json:"memberships"` - ModifiedAt time.Time `json:"modified_at" format:"date-time"` - JSON addressingAddressMapGetResponseJSON `json:"-"` -} - -// addressingAddressMapGetResponseJSON contains the JSON metadata for the struct -// [AddressingAddressMapGetResponse] -type addressingAddressMapGetResponseJSON struct { - ID apijson.Field - CanDelete apijson.Field - CanModifyIPs apijson.Field - CreatedAt apijson.Field - DefaultSni apijson.Field - Description apijson.Field - Enabled apijson.Field - IPs apijson.Field - Memberships apijson.Field - ModifiedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapGetResponseJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapGetResponseIP struct { - CreatedAt time.Time `json:"created_at" format:"date-time"` - // An IPv4 or IPv6 address. - IP string `json:"ip"` - JSON addressingAddressMapGetResponseIPJSON `json:"-"` -} - -// addressingAddressMapGetResponseIPJSON contains the JSON metadata for the struct -// [AddressingAddressMapGetResponseIP] -type addressingAddressMapGetResponseIPJSON struct { - CreatedAt apijson.Field - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapGetResponseIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapGetResponseIPJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapGetResponseMembership struct { - // Controls whether the membership can be deleted via the API or not. - CanDelete bool `json:"can_delete"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Identifier - Identifier string `json:"identifier"` - // The type of the membership. - Kind AddressingAddressMapGetResponseMembershipsKind `json:"kind"` - JSON addressingAddressMapGetResponseMembershipJSON `json:"-"` -} - -// addressingAddressMapGetResponseMembershipJSON contains the JSON metadata for the -// struct [AddressingAddressMapGetResponseMembership] -type addressingAddressMapGetResponseMembershipJSON struct { - CanDelete apijson.Field - CreatedAt apijson.Field - Identifier apijson.Field - Kind apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapGetResponseMembership) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapGetResponseMembershipJSON) RawJSON() string { - return r.raw -} - -// The type of the membership. -type AddressingAddressMapGetResponseMembershipsKind string - -const ( - AddressingAddressMapGetResponseMembershipsKindZone AddressingAddressMapGetResponseMembershipsKind = "zone" - AddressingAddressMapGetResponseMembershipsKindAccount AddressingAddressMapGetResponseMembershipsKind = "account" -) - -type AddressingAddressMapNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // An optional description field which may be used to describe the types of IPs or - // zones on the map. - Description param.Field[string] `json:"description"` - // Whether the Address Map is enabled or not. Cloudflare's DNS will not respond - // with IP addresses on an Address Map until the map is enabled. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r AddressingAddressMapNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AddressingAddressMapNewResponseEnvelope struct { - Errors []AddressingAddressMapNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingAddressMapNewResponseEnvelopeMessages `json:"messages,required"` - Result AddressingAddressMapNewResponse `json:"result,required"` - // Whether the API call was successful - Success AddressingAddressMapNewResponseEnvelopeSuccess `json:"success,required"` - JSON addressingAddressMapNewResponseEnvelopeJSON `json:"-"` -} - -// addressingAddressMapNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [AddressingAddressMapNewResponseEnvelope] -type addressingAddressMapNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingAddressMapNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AddressingAddressMapNewResponseEnvelopeErrors] -type addressingAddressMapNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingAddressMapNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AddressingAddressMapNewResponseEnvelopeMessages] -type addressingAddressMapNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingAddressMapNewResponseEnvelopeSuccess bool - -const ( - AddressingAddressMapNewResponseEnvelopeSuccessTrue AddressingAddressMapNewResponseEnvelopeSuccess = true -) - -type AddressingAddressMapListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingAddressMapListResponseEnvelope struct { - Errors []AddressingAddressMapListResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingAddressMapListResponseEnvelopeMessages `json:"messages,required"` - Result []AddressingAddressMapListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AddressingAddressMapListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AddressingAddressMapListResponseEnvelopeResultInfo `json:"result_info"` - JSON addressingAddressMapListResponseEnvelopeJSON `json:"-"` -} - -// addressingAddressMapListResponseEnvelopeJSON contains the JSON metadata for the -// struct [AddressingAddressMapListResponseEnvelope] -type addressingAddressMapListResponseEnvelopeJSON 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 *AddressingAddressMapListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapListResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingAddressMapListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [AddressingAddressMapListResponseEnvelopeErrors] -type addressingAddressMapListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapListResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingAddressMapListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AddressingAddressMapListResponseEnvelopeMessages] -type addressingAddressMapListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingAddressMapListResponseEnvelopeSuccess bool - -const ( - AddressingAddressMapListResponseEnvelopeSuccessTrue AddressingAddressMapListResponseEnvelopeSuccess = true -) - -type AddressingAddressMapListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON addressingAddressMapListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// addressingAddressMapListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [AddressingAddressMapListResponseEnvelopeResultInfo] -type addressingAddressMapListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingAddressMapDeleteResponseEnvelope struct { - Errors []AddressingAddressMapDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingAddressMapDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AddressingAddressMapDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AddressingAddressMapDeleteResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AddressingAddressMapDeleteResponseEnvelopeResultInfo `json:"result_info"` - JSON addressingAddressMapDeleteResponseEnvelopeJSON `json:"-"` -} - -// addressingAddressMapDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [AddressingAddressMapDeleteResponseEnvelope] -type addressingAddressMapDeleteResponseEnvelopeJSON 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 *AddressingAddressMapDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingAddressMapDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [AddressingAddressMapDeleteResponseEnvelopeErrors] -type addressingAddressMapDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingAddressMapDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AddressingAddressMapDeleteResponseEnvelopeMessages] -type addressingAddressMapDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingAddressMapDeleteResponseEnvelopeSuccess bool - -const ( - AddressingAddressMapDeleteResponseEnvelopeSuccessTrue AddressingAddressMapDeleteResponseEnvelopeSuccess = true -) - -type AddressingAddressMapDeleteResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON addressingAddressMapDeleteResponseEnvelopeResultInfoJSON `json:"-"` -} - -// addressingAddressMapDeleteResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [AddressingAddressMapDeleteResponseEnvelopeResultInfo] -type addressingAddressMapDeleteResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapEditParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // If you have legacy TLS clients which do not send the TLS server name indicator, - // then you can specify one default SNI on the map. If Cloudflare receives a TLS - // handshake from a client without an SNI, it will respond with the default SNI on - // those IPs. The default SNI can be any valid zone or subdomain owned by the - // account. - DefaultSni param.Field[string] `json:"default_sni"` - // An optional description field which may be used to describe the types of IPs or - // zones on the map. - Description param.Field[string] `json:"description"` - // Whether the Address Map is enabled or not. Cloudflare's DNS will not respond - // with IP addresses on an Address Map until the map is enabled. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r AddressingAddressMapEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AddressingAddressMapEditResponseEnvelope struct { - Errors []AddressingAddressMapEditResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingAddressMapEditResponseEnvelopeMessages `json:"messages,required"` - Result AddressingAddressMapEditResponse `json:"result,required"` - // Whether the API call was successful - Success AddressingAddressMapEditResponseEnvelopeSuccess `json:"success,required"` - JSON addressingAddressMapEditResponseEnvelopeJSON `json:"-"` -} - -// addressingAddressMapEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [AddressingAddressMapEditResponseEnvelope] -type addressingAddressMapEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingAddressMapEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [AddressingAddressMapEditResponseEnvelopeErrors] -type addressingAddressMapEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingAddressMapEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AddressingAddressMapEditResponseEnvelopeMessages] -type addressingAddressMapEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingAddressMapEditResponseEnvelopeSuccess bool - -const ( - AddressingAddressMapEditResponseEnvelopeSuccessTrue AddressingAddressMapEditResponseEnvelopeSuccess = true -) - -type AddressingAddressMapGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingAddressMapGetResponseEnvelope struct { - Errors []AddressingAddressMapGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingAddressMapGetResponseEnvelopeMessages `json:"messages,required"` - Result AddressingAddressMapGetResponse `json:"result,required"` - // Whether the API call was successful - Success AddressingAddressMapGetResponseEnvelopeSuccess `json:"success,required"` - JSON addressingAddressMapGetResponseEnvelopeJSON `json:"-"` -} - -// addressingAddressMapGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [AddressingAddressMapGetResponseEnvelope] -type addressingAddressMapGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingAddressMapGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AddressingAddressMapGetResponseEnvelopeErrors] -type addressingAddressMapGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingAddressMapGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AddressingAddressMapGetResponseEnvelopeMessages] -type addressingAddressMapGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingAddressMapGetResponseEnvelopeSuccess bool - -const ( - AddressingAddressMapGetResponseEnvelopeSuccessTrue AddressingAddressMapGetResponseEnvelopeSuccess = true -) diff --git a/addressingaddressmap_test.go b/addressingaddressmap_test.go deleted file mode 100644 index c48e01502b9..00000000000 --- a/addressingaddressmap_test.go +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAddressingAddressMapNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Addressing.AddressMaps.New(context.TODO(), cloudflare.AddressingAddressMapNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Description: cloudflare.F("My Ecommerce zones"), - Enabled: cloudflare.F(true), - }) - 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 TestAddressingAddressMapList(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("user@example.com"), - ) - _, err := client.Addressing.AddressMaps.List(context.TODO(), cloudflare.AddressingAddressMapListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestAddressingAddressMapDelete(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("user@example.com"), - ) - _, err := client.Addressing.AddressMaps.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingAddressMapDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestAddressingAddressMapEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Addressing.AddressMaps.Edit( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingAddressMapEditParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - DefaultSni: cloudflare.F("*.example.com"), - Description: cloudflare.F("My Ecommerce zones"), - Enabled: cloudflare.F(true), - }, - ) - 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 TestAddressingAddressMapGet(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("user@example.com"), - ) - _, err := client.Addressing.AddressMaps.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingAddressMapGetParams{ - AccountID: cloudflare.F("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/addressingaddressmapaccount.go b/addressingaddressmapaccount.go deleted file mode 100644 index 2617d3ec415..00000000000 --- a/addressingaddressmapaccount.go +++ /dev/null @@ -1,357 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// AddressingAddressMapAccountService 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 -// [NewAddressingAddressMapAccountService] method instead. -type AddressingAddressMapAccountService struct { - Options []option.RequestOption -} - -// NewAddressingAddressMapAccountService 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 NewAddressingAddressMapAccountService(opts ...option.RequestOption) (r *AddressingAddressMapAccountService) { - r = &AddressingAddressMapAccountService{} - r.Options = opts - return -} - -// Add an account as a member of a particular address map. -func (r *AddressingAddressMapAccountService) Update(ctx context.Context, addressMapID string, body AddressingAddressMapAccountUpdateParams, opts ...option.RequestOption) (res *AddressingAddressMapAccountUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingAddressMapAccountUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/accounts/%s", body.AccountID, addressMapID, body.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Remove an account as a member of a particular address map. -func (r *AddressingAddressMapAccountService) Delete(ctx context.Context, addressMapID string, body AddressingAddressMapAccountDeleteParams, opts ...option.RequestOption) (res *AddressingAddressMapAccountDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingAddressMapAccountDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/accounts/%s", body.AccountID, addressMapID, body.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [AddressingAddressMapAccountUpdateResponseUnknown], -// [AddressingAddressMapAccountUpdateResponseArray] or [shared.UnionString]. -type AddressingAddressMapAccountUpdateResponse interface { - ImplementsAddressingAddressMapAccountUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AddressingAddressMapAccountUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AddressingAddressMapAccountUpdateResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type AddressingAddressMapAccountUpdateResponseArray []interface{} - -func (r AddressingAddressMapAccountUpdateResponseArray) ImplementsAddressingAddressMapAccountUpdateResponse() { -} - -// Union satisfied by [AddressingAddressMapAccountDeleteResponseUnknown], -// [AddressingAddressMapAccountDeleteResponseArray] or [shared.UnionString]. -type AddressingAddressMapAccountDeleteResponse interface { - ImplementsAddressingAddressMapAccountDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AddressingAddressMapAccountDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AddressingAddressMapAccountDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type AddressingAddressMapAccountDeleteResponseArray []interface{} - -func (r AddressingAddressMapAccountDeleteResponseArray) ImplementsAddressingAddressMapAccountDeleteResponse() { -} - -type AddressingAddressMapAccountUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingAddressMapAccountUpdateResponseEnvelope struct { - Errors []AddressingAddressMapAccountUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingAddressMapAccountUpdateResponseEnvelopeMessages `json:"messages,required"` - Result AddressingAddressMapAccountUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AddressingAddressMapAccountUpdateResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AddressingAddressMapAccountUpdateResponseEnvelopeResultInfo `json:"result_info"` - JSON addressingAddressMapAccountUpdateResponseEnvelopeJSON `json:"-"` -} - -// addressingAddressMapAccountUpdateResponseEnvelopeJSON contains the JSON metadata -// for the struct [AddressingAddressMapAccountUpdateResponseEnvelope] -type addressingAddressMapAccountUpdateResponseEnvelopeJSON 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 *AddressingAddressMapAccountUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapAccountUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapAccountUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapAccountUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingAddressMapAccountUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [AddressingAddressMapAccountUpdateResponseEnvelopeErrors] -type addressingAddressMapAccountUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapAccountUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapAccountUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapAccountUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapAccountUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingAddressMapAccountUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [AddressingAddressMapAccountUpdateResponseEnvelopeMessages] -type addressingAddressMapAccountUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapAccountUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapAccountUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingAddressMapAccountUpdateResponseEnvelopeSuccess bool - -const ( - AddressingAddressMapAccountUpdateResponseEnvelopeSuccessTrue AddressingAddressMapAccountUpdateResponseEnvelopeSuccess = true -) - -type AddressingAddressMapAccountUpdateResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON addressingAddressMapAccountUpdateResponseEnvelopeResultInfoJSON `json:"-"` -} - -// addressingAddressMapAccountUpdateResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [AddressingAddressMapAccountUpdateResponseEnvelopeResultInfo] -type addressingAddressMapAccountUpdateResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapAccountUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapAccountUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapAccountDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingAddressMapAccountDeleteResponseEnvelope struct { - Errors []AddressingAddressMapAccountDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingAddressMapAccountDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AddressingAddressMapAccountDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AddressingAddressMapAccountDeleteResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AddressingAddressMapAccountDeleteResponseEnvelopeResultInfo `json:"result_info"` - JSON addressingAddressMapAccountDeleteResponseEnvelopeJSON `json:"-"` -} - -// addressingAddressMapAccountDeleteResponseEnvelopeJSON contains the JSON metadata -// for the struct [AddressingAddressMapAccountDeleteResponseEnvelope] -type addressingAddressMapAccountDeleteResponseEnvelopeJSON 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 *AddressingAddressMapAccountDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapAccountDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapAccountDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapAccountDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingAddressMapAccountDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [AddressingAddressMapAccountDeleteResponseEnvelopeErrors] -type addressingAddressMapAccountDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapAccountDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapAccountDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapAccountDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapAccountDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingAddressMapAccountDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [AddressingAddressMapAccountDeleteResponseEnvelopeMessages] -type addressingAddressMapAccountDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapAccountDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapAccountDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingAddressMapAccountDeleteResponseEnvelopeSuccess bool - -const ( - AddressingAddressMapAccountDeleteResponseEnvelopeSuccessTrue AddressingAddressMapAccountDeleteResponseEnvelopeSuccess = true -) - -type AddressingAddressMapAccountDeleteResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON addressingAddressMapAccountDeleteResponseEnvelopeResultInfoJSON `json:"-"` -} - -// addressingAddressMapAccountDeleteResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [AddressingAddressMapAccountDeleteResponseEnvelopeResultInfo] -type addressingAddressMapAccountDeleteResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapAccountDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapAccountDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/addressingaddressmapaccount_test.go b/addressingaddressmapaccount_test.go deleted file mode 100644 index 0513e498d99..00000000000 --- a/addressingaddressmapaccount_test.go +++ /dev/null @@ -1,74 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAddressingAddressMapAccountUpdate(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("user@example.com"), - ) - _, err := client.Addressing.AddressMaps.Accounts.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingAddressMapAccountUpdateParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestAddressingAddressMapAccountDelete(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("user@example.com"), - ) - _, err := client.Addressing.AddressMaps.Accounts.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingAddressMapAccountDeleteParams{ - AccountID: cloudflare.F("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/addressingaddressmapip.go b/addressingaddressmapip.go deleted file mode 100644 index 1893441030d..00000000000 --- a/addressingaddressmapip.go +++ /dev/null @@ -1,349 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// AddressingAddressMapIPService 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 [NewAddressingAddressMapIPService] -// method instead. -type AddressingAddressMapIPService struct { - Options []option.RequestOption -} - -// NewAddressingAddressMapIPService 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 NewAddressingAddressMapIPService(opts ...option.RequestOption) (r *AddressingAddressMapIPService) { - r = &AddressingAddressMapIPService{} - r.Options = opts - return -} - -// Add an IP from a prefix owned by the account to a particular address map. -func (r *AddressingAddressMapIPService) Update(ctx context.Context, addressMapID string, ipAddress string, body AddressingAddressMapIPUpdateParams, opts ...option.RequestOption) (res *AddressingAddressMapIPUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingAddressMapIPUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/ips/%s", body.AccountID, addressMapID, ipAddress) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Remove an IP from a particular address map. -func (r *AddressingAddressMapIPService) Delete(ctx context.Context, addressMapID string, ipAddress string, body AddressingAddressMapIPDeleteParams, opts ...option.RequestOption) (res *AddressingAddressMapIPDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingAddressMapIPDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/ips/%s", body.AccountID, addressMapID, ipAddress) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [AddressingAddressMapIPUpdateResponseUnknown], -// [AddressingAddressMapIPUpdateResponseArray] or [shared.UnionString]. -type AddressingAddressMapIPUpdateResponse interface { - ImplementsAddressingAddressMapIPUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AddressingAddressMapIPUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AddressingAddressMapIPUpdateResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type AddressingAddressMapIPUpdateResponseArray []interface{} - -func (r AddressingAddressMapIPUpdateResponseArray) ImplementsAddressingAddressMapIPUpdateResponse() {} - -// Union satisfied by [AddressingAddressMapIPDeleteResponseUnknown], -// [AddressingAddressMapIPDeleteResponseArray] or [shared.UnionString]. -type AddressingAddressMapIPDeleteResponse interface { - ImplementsAddressingAddressMapIPDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AddressingAddressMapIPDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AddressingAddressMapIPDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type AddressingAddressMapIPDeleteResponseArray []interface{} - -func (r AddressingAddressMapIPDeleteResponseArray) ImplementsAddressingAddressMapIPDeleteResponse() {} - -type AddressingAddressMapIPUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingAddressMapIPUpdateResponseEnvelope struct { - Errors []AddressingAddressMapIPUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingAddressMapIPUpdateResponseEnvelopeMessages `json:"messages,required"` - Result AddressingAddressMapIPUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AddressingAddressMapIPUpdateResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AddressingAddressMapIPUpdateResponseEnvelopeResultInfo `json:"result_info"` - JSON addressingAddressMapIPUpdateResponseEnvelopeJSON `json:"-"` -} - -// addressingAddressMapIPUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [AddressingAddressMapIPUpdateResponseEnvelope] -type addressingAddressMapIPUpdateResponseEnvelopeJSON 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 *AddressingAddressMapIPUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapIPUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapIPUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapIPUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingAddressMapIPUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AddressingAddressMapIPUpdateResponseEnvelopeErrors] -type addressingAddressMapIPUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapIPUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapIPUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapIPUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapIPUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingAddressMapIPUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AddressingAddressMapIPUpdateResponseEnvelopeMessages] -type addressingAddressMapIPUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapIPUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapIPUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingAddressMapIPUpdateResponseEnvelopeSuccess bool - -const ( - AddressingAddressMapIPUpdateResponseEnvelopeSuccessTrue AddressingAddressMapIPUpdateResponseEnvelopeSuccess = true -) - -type AddressingAddressMapIPUpdateResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON addressingAddressMapIPUpdateResponseEnvelopeResultInfoJSON `json:"-"` -} - -// addressingAddressMapIPUpdateResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [AddressingAddressMapIPUpdateResponseEnvelopeResultInfo] -type addressingAddressMapIPUpdateResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapIPUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapIPUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapIPDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingAddressMapIPDeleteResponseEnvelope struct { - Errors []AddressingAddressMapIPDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingAddressMapIPDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AddressingAddressMapIPDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AddressingAddressMapIPDeleteResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AddressingAddressMapIPDeleteResponseEnvelopeResultInfo `json:"result_info"` - JSON addressingAddressMapIPDeleteResponseEnvelopeJSON `json:"-"` -} - -// addressingAddressMapIPDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [AddressingAddressMapIPDeleteResponseEnvelope] -type addressingAddressMapIPDeleteResponseEnvelopeJSON 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 *AddressingAddressMapIPDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapIPDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapIPDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapIPDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingAddressMapIPDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AddressingAddressMapIPDeleteResponseEnvelopeErrors] -type addressingAddressMapIPDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapIPDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapIPDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapIPDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapIPDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingAddressMapIPDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AddressingAddressMapIPDeleteResponseEnvelopeMessages] -type addressingAddressMapIPDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapIPDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapIPDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingAddressMapIPDeleteResponseEnvelopeSuccess bool - -const ( - AddressingAddressMapIPDeleteResponseEnvelopeSuccessTrue AddressingAddressMapIPDeleteResponseEnvelopeSuccess = true -) - -type AddressingAddressMapIPDeleteResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON addressingAddressMapIPDeleteResponseEnvelopeResultInfoJSON `json:"-"` -} - -// addressingAddressMapIPDeleteResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [AddressingAddressMapIPDeleteResponseEnvelopeResultInfo] -type addressingAddressMapIPDeleteResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapIPDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapIPDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/addressingaddressmapip_test.go b/addressingaddressmapip_test.go deleted file mode 100644 index 12e9d3f66cb..00000000000 --- a/addressingaddressmapip_test.go +++ /dev/null @@ -1,76 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAddressingAddressMapIPUpdate(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("user@example.com"), - ) - _, err := client.Addressing.AddressMaps.IPs.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "192.0.2.1", - cloudflare.AddressingAddressMapIPUpdateParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestAddressingAddressMapIPDelete(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("user@example.com"), - ) - _, err := client.Addressing.AddressMaps.IPs.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "192.0.2.1", - cloudflare.AddressingAddressMapIPDeleteParams{ - AccountID: cloudflare.F("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/addressingaddressmapzone.go b/addressingaddressmapzone.go deleted file mode 100644 index c08748adfc8..00000000000 --- a/addressingaddressmapzone.go +++ /dev/null @@ -1,375 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// AddressingAddressMapZoneService 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 -// [NewAddressingAddressMapZoneService] method instead. -type AddressingAddressMapZoneService struct { - Options []option.RequestOption -} - -// NewAddressingAddressMapZoneService 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 NewAddressingAddressMapZoneService(opts ...option.RequestOption) (r *AddressingAddressMapZoneService) { - r = &AddressingAddressMapZoneService{} - r.Options = opts - return -} - -// Add a zone as a member of a particular address map. -func (r *AddressingAddressMapZoneService) Update(ctx context.Context, addressMapID string, body AddressingAddressMapZoneUpdateParams, opts ...option.RequestOption) (res *AddressingAddressMapZoneUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingAddressMapZoneUpdateResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if body.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = body.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = body.ZoneID - } - path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/zones/%s", accountOrZone, addressMapID, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Remove a zone as a member of a particular address map. -func (r *AddressingAddressMapZoneService) Delete(ctx context.Context, addressMapID string, body AddressingAddressMapZoneDeleteParams, opts ...option.RequestOption) (res *AddressingAddressMapZoneDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingAddressMapZoneDeleteResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if body.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = body.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = body.ZoneID - } - path := fmt.Sprintf("accounts/%s/addressing/address_maps/%s/zones/%s", accountOrZone, addressMapID, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [AddressingAddressMapZoneUpdateResponseUnknown], -// [AddressingAddressMapZoneUpdateResponseArray] or [shared.UnionString]. -type AddressingAddressMapZoneUpdateResponse interface { - ImplementsAddressingAddressMapZoneUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AddressingAddressMapZoneUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AddressingAddressMapZoneUpdateResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type AddressingAddressMapZoneUpdateResponseArray []interface{} - -func (r AddressingAddressMapZoneUpdateResponseArray) ImplementsAddressingAddressMapZoneUpdateResponse() { -} - -// Union satisfied by [AddressingAddressMapZoneDeleteResponseUnknown], -// [AddressingAddressMapZoneDeleteResponseArray] or [shared.UnionString]. -type AddressingAddressMapZoneDeleteResponse interface { - ImplementsAddressingAddressMapZoneDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AddressingAddressMapZoneDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AddressingAddressMapZoneDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type AddressingAddressMapZoneDeleteResponseArray []interface{} - -func (r AddressingAddressMapZoneDeleteResponseArray) ImplementsAddressingAddressMapZoneDeleteResponse() { -} - -type AddressingAddressMapZoneUpdateParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingAddressMapZoneUpdateResponseEnvelope struct { - Errors []AddressingAddressMapZoneUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingAddressMapZoneUpdateResponseEnvelopeMessages `json:"messages,required"` - Result AddressingAddressMapZoneUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AddressingAddressMapZoneUpdateResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AddressingAddressMapZoneUpdateResponseEnvelopeResultInfo `json:"result_info"` - JSON addressingAddressMapZoneUpdateResponseEnvelopeJSON `json:"-"` -} - -// addressingAddressMapZoneUpdateResponseEnvelopeJSON contains the JSON metadata -// for the struct [AddressingAddressMapZoneUpdateResponseEnvelope] -type addressingAddressMapZoneUpdateResponseEnvelopeJSON 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 *AddressingAddressMapZoneUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapZoneUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapZoneUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapZoneUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingAddressMapZoneUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AddressingAddressMapZoneUpdateResponseEnvelopeErrors] -type addressingAddressMapZoneUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapZoneUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapZoneUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapZoneUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapZoneUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingAddressMapZoneUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AddressingAddressMapZoneUpdateResponseEnvelopeMessages] -type addressingAddressMapZoneUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapZoneUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapZoneUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingAddressMapZoneUpdateResponseEnvelopeSuccess bool - -const ( - AddressingAddressMapZoneUpdateResponseEnvelopeSuccessTrue AddressingAddressMapZoneUpdateResponseEnvelopeSuccess = true -) - -type AddressingAddressMapZoneUpdateResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON addressingAddressMapZoneUpdateResponseEnvelopeResultInfoJSON `json:"-"` -} - -// addressingAddressMapZoneUpdateResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [AddressingAddressMapZoneUpdateResponseEnvelopeResultInfo] -type addressingAddressMapZoneUpdateResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapZoneUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapZoneUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapZoneDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingAddressMapZoneDeleteResponseEnvelope struct { - Errors []AddressingAddressMapZoneDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingAddressMapZoneDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AddressingAddressMapZoneDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AddressingAddressMapZoneDeleteResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AddressingAddressMapZoneDeleteResponseEnvelopeResultInfo `json:"result_info"` - JSON addressingAddressMapZoneDeleteResponseEnvelopeJSON `json:"-"` -} - -// addressingAddressMapZoneDeleteResponseEnvelopeJSON contains the JSON metadata -// for the struct [AddressingAddressMapZoneDeleteResponseEnvelope] -type addressingAddressMapZoneDeleteResponseEnvelopeJSON 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 *AddressingAddressMapZoneDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapZoneDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapZoneDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapZoneDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingAddressMapZoneDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AddressingAddressMapZoneDeleteResponseEnvelopeErrors] -type addressingAddressMapZoneDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapZoneDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapZoneDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingAddressMapZoneDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingAddressMapZoneDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingAddressMapZoneDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AddressingAddressMapZoneDeleteResponseEnvelopeMessages] -type addressingAddressMapZoneDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapZoneDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapZoneDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingAddressMapZoneDeleteResponseEnvelopeSuccess bool - -const ( - AddressingAddressMapZoneDeleteResponseEnvelopeSuccessTrue AddressingAddressMapZoneDeleteResponseEnvelopeSuccess = true -) - -type AddressingAddressMapZoneDeleteResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON addressingAddressMapZoneDeleteResponseEnvelopeResultInfoJSON `json:"-"` -} - -// addressingAddressMapZoneDeleteResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [AddressingAddressMapZoneDeleteResponseEnvelopeResultInfo] -type addressingAddressMapZoneDeleteResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingAddressMapZoneDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingAddressMapZoneDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/addressingaddressmapzone_test.go b/addressingaddressmapzone_test.go deleted file mode 100644 index 3ab69f2eb81..00000000000 --- a/addressingaddressmapzone_test.go +++ /dev/null @@ -1,76 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAddressingAddressMapZoneUpdate(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("user@example.com"), - ) - _, err := client.Addressing.AddressMaps.Zones.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingAddressMapZoneUpdateParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - AccountID: cloudflare.F("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()) - } -} - -func TestAddressingAddressMapZoneDelete(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("user@example.com"), - ) - _, err := client.Addressing.AddressMaps.Zones.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingAddressMapZoneDeleteParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - AccountID: cloudflare.F("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/addressingloadocument.go b/addressingloadocument.go deleted file mode 100644 index 21e7613e473..00000000000 --- a/addressingloadocument.go +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// AddressingLOADocumentService 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 [NewAddressingLOADocumentService] -// method instead. -type AddressingLOADocumentService struct { - Options []option.RequestOption - Downloads *AddressingLOADocumentDownloadService -} - -// NewAddressingLOADocumentService 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 NewAddressingLOADocumentService(opts ...option.RequestOption) (r *AddressingLOADocumentService) { - r = &AddressingLOADocumentService{} - r.Options = opts - r.Downloads = NewAddressingLOADocumentDownloadService(opts...) - return -} - -// Submit LOA document (pdf format) under the account. -func (r *AddressingLOADocumentService) New(ctx context.Context, params AddressingLOADocumentNewParams, opts ...option.RequestOption) (res *AddressingLOADocumentNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingLOADocumentNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/loa_documents", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type AddressingLOADocumentNewResponse struct { - // Name of LOA document. - Filename string `json:"filename"` - JSON addressingLOADocumentNewResponseJSON `json:"-"` -} - -// addressingLOADocumentNewResponseJSON contains the JSON metadata for the struct -// [AddressingLOADocumentNewResponse] -type addressingLOADocumentNewResponseJSON struct { - Filename apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingLOADocumentNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingLOADocumentNewResponseJSON) RawJSON() string { - return r.raw -} - -type AddressingLOADocumentNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // LOA document to upload. - LOADocument param.Field[string] `json:"loa_document,required"` -} - -func (r AddressingLOADocumentNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AddressingLOADocumentNewResponseEnvelope struct { - Errors []AddressingLOADocumentNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingLOADocumentNewResponseEnvelopeMessages `json:"messages,required"` - Result AddressingLOADocumentNewResponse `json:"result,required"` - // Whether the API call was successful - Success AddressingLOADocumentNewResponseEnvelopeSuccess `json:"success,required"` - JSON addressingLOADocumentNewResponseEnvelopeJSON `json:"-"` -} - -// addressingLOADocumentNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [AddressingLOADocumentNewResponseEnvelope] -type addressingLOADocumentNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingLOADocumentNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingLOADocumentNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingLOADocumentNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingLOADocumentNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingLOADocumentNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [AddressingLOADocumentNewResponseEnvelopeErrors] -type addressingLOADocumentNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingLOADocumentNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingLOADocumentNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingLOADocumentNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingLOADocumentNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingLOADocumentNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AddressingLOADocumentNewResponseEnvelopeMessages] -type addressingLOADocumentNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingLOADocumentNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingLOADocumentNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingLOADocumentNewResponseEnvelopeSuccess bool - -const ( - AddressingLOADocumentNewResponseEnvelopeSuccessTrue AddressingLOADocumentNewResponseEnvelopeSuccess = true -) diff --git a/addressingloadocument_test.go b/addressingloadocument_test.go deleted file mode 100644 index 6c94b9df2d7..00000000000 --- a/addressingloadocument_test.go +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAddressingLOADocumentNew(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("user@example.com"), - ) - _, err := client.Addressing.LOADocuments.New(context.TODO(), cloudflare.AddressingLOADocumentNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - LOADocument: cloudflare.F("@document.pdf"), - }) - 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/addressingloadocumentdownload.go b/addressingloadocumentdownload.go deleted file mode 100644 index 78dd090fbba..00000000000 --- a/addressingloadocumentdownload.go +++ /dev/null @@ -1,46 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// AddressingLOADocumentDownloadService 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 -// [NewAddressingLOADocumentDownloadService] method instead. -type AddressingLOADocumentDownloadService struct { - Options []option.RequestOption -} - -// NewAddressingLOADocumentDownloadService 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 NewAddressingLOADocumentDownloadService(opts ...option.RequestOption) (r *AddressingLOADocumentDownloadService) { - r = &AddressingLOADocumentDownloadService{} - r.Options = opts - return -} - -// Download specified LOA document under the account. -func (r *AddressingLOADocumentDownloadService) Get(ctx context.Context, loaDocumentID string, query AddressingLOADocumentDownloadGetParams, opts ...option.RequestOption) (res *AddressingLOADocumentDownloadGetResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("accounts/%s/addressing/loa_documents/%s/download", query.AccountID, loaDocumentID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -type AddressingLOADocumentDownloadGetResponse = interface{} - -type AddressingLOADocumentDownloadGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} diff --git a/addressingloadocumentdownload_test.go b/addressingloadocumentdownload_test.go deleted file mode 100644 index 1b93eb01b58..00000000000 --- a/addressingloadocumentdownload_test.go +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAddressingLOADocumentDownloadGet(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("user@example.com"), - ) - _, err := client.Addressing.LOADocuments.Downloads.Get( - context.TODO(), - "d933b1530bc56c9953cf8ce166da8004", - cloudflare.AddressingLOADocumentDownloadGetParams{ - AccountID: cloudflare.F("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/addressingprefix.go b/addressingprefix.go deleted file mode 100644 index af98f6b867d..00000000000 --- a/addressingprefix.go +++ /dev/null @@ -1,882 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// AddressingPrefixService 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 [NewAddressingPrefixService] method -// instead. -type AddressingPrefixService struct { - Options []option.RequestOption - BGP *AddressingPrefixBGPService - Delegations *AddressingPrefixDelegationService -} - -// NewAddressingPrefixService 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 NewAddressingPrefixService(opts ...option.RequestOption) (r *AddressingPrefixService) { - r = &AddressingPrefixService{} - r.Options = opts - r.BGP = NewAddressingPrefixBGPService(opts...) - r.Delegations = NewAddressingPrefixDelegationService(opts...) - return -} - -// Add a new prefix under the account. -func (r *AddressingPrefixService) New(ctx context.Context, params AddressingPrefixNewParams, opts ...option.RequestOption) (res *AddressingPrefixNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingPrefixNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List all prefixes owned by the account. -func (r *AddressingPrefixService) List(ctx context.Context, query AddressingPrefixListParams, opts ...option.RequestOption) (res *[]AddressingPrefixListResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingPrefixListResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete an unapproved prefix owned by the account. -func (r *AddressingPrefixService) Delete(ctx context.Context, prefixID string, body AddressingPrefixDeleteParams, opts ...option.RequestOption) (res *AddressingPrefixDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingPrefixDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s", body.AccountID, prefixID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Modify the description for a prefix owned by the account. -func (r *AddressingPrefixService) Edit(ctx context.Context, prefixID string, params AddressingPrefixEditParams, opts ...option.RequestOption) (res *AddressingPrefixEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingPrefixEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s", params.AccountID, prefixID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List a particular prefix owned by the account. -func (r *AddressingPrefixService) Get(ctx context.Context, prefixID string, query AddressingPrefixGetParams, opts ...option.RequestOption) (res *AddressingPrefixGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingPrefixGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s", query.AccountID, prefixID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type AddressingPrefixNewResponse struct { - // Identifier - ID string `json:"id"` - // Identifier - AccountID string `json:"account_id"` - // Prefix advertisement status to the Internet. This field is only not 'null' if on - // demand is enabled. - Advertised bool `json:"advertised,nullable"` - // Last time the advertisement status was changed. This field is only not 'null' if - // on demand is enabled. - AdvertisedModifiedAt time.Time `json:"advertised_modified_at,nullable" format:"date-time"` - // Approval state of the prefix (P = pending, V = active). - Approved string `json:"approved"` - // Autonomous System Number (ASN) the prefix will be advertised under. - ASN int64 `json:"asn,nullable"` - // IP Prefix in Classless Inter-Domain Routing format. - Cidr string `json:"cidr"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Description of the prefix. - Description string `json:"description"` - // Identifier for the uploaded LOA document. - LOADocumentID string `json:"loa_document_id,nullable"` - ModifiedAt time.Time `json:"modified_at" format:"date-time"` - // Whether advertisement of the prefix to the Internet may be dynamically enabled - // or disabled. - OnDemandEnabled bool `json:"on_demand_enabled"` - // Whether advertisement status of the prefix is locked, meaning it cannot be - // changed. - OnDemandLocked bool `json:"on_demand_locked"` - JSON addressingPrefixNewResponseJSON `json:"-"` -} - -// addressingPrefixNewResponseJSON contains the JSON metadata for the struct -// [AddressingPrefixNewResponse] -type addressingPrefixNewResponseJSON struct { - ID apijson.Field - AccountID apijson.Field - Advertised apijson.Field - AdvertisedModifiedAt apijson.Field - Approved apijson.Field - ASN apijson.Field - Cidr apijson.Field - CreatedAt apijson.Field - Description apijson.Field - LOADocumentID apijson.Field - ModifiedAt apijson.Field - OnDemandEnabled apijson.Field - OnDemandLocked apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixNewResponseJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixListResponse struct { - // Identifier - ID string `json:"id"` - // Identifier - AccountID string `json:"account_id"` - // Prefix advertisement status to the Internet. This field is only not 'null' if on - // demand is enabled. - Advertised bool `json:"advertised,nullable"` - // Last time the advertisement status was changed. This field is only not 'null' if - // on demand is enabled. - AdvertisedModifiedAt time.Time `json:"advertised_modified_at,nullable" format:"date-time"` - // Approval state of the prefix (P = pending, V = active). - Approved string `json:"approved"` - // Autonomous System Number (ASN) the prefix will be advertised under. - ASN int64 `json:"asn,nullable"` - // IP Prefix in Classless Inter-Domain Routing format. - Cidr string `json:"cidr"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Description of the prefix. - Description string `json:"description"` - // Identifier for the uploaded LOA document. - LOADocumentID string `json:"loa_document_id,nullable"` - ModifiedAt time.Time `json:"modified_at" format:"date-time"` - // Whether advertisement of the prefix to the Internet may be dynamically enabled - // or disabled. - OnDemandEnabled bool `json:"on_demand_enabled"` - // Whether advertisement status of the prefix is locked, meaning it cannot be - // changed. - OnDemandLocked bool `json:"on_demand_locked"` - JSON addressingPrefixListResponseJSON `json:"-"` -} - -// addressingPrefixListResponseJSON contains the JSON metadata for the struct -// [AddressingPrefixListResponse] -type addressingPrefixListResponseJSON struct { - ID apijson.Field - AccountID apijson.Field - Advertised apijson.Field - AdvertisedModifiedAt apijson.Field - Approved apijson.Field - ASN apijson.Field - Cidr apijson.Field - CreatedAt apijson.Field - Description apijson.Field - LOADocumentID apijson.Field - ModifiedAt apijson.Field - OnDemandEnabled apijson.Field - OnDemandLocked apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixListResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [AddressingPrefixDeleteResponseUnknown], -// [AddressingPrefixDeleteResponseArray] or [shared.UnionString]. -type AddressingPrefixDeleteResponse interface { - ImplementsAddressingPrefixDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AddressingPrefixDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AddressingPrefixDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type AddressingPrefixDeleteResponseArray []interface{} - -func (r AddressingPrefixDeleteResponseArray) ImplementsAddressingPrefixDeleteResponse() {} - -type AddressingPrefixEditResponse struct { - // Identifier - ID string `json:"id"` - // Identifier - AccountID string `json:"account_id"` - // Prefix advertisement status to the Internet. This field is only not 'null' if on - // demand is enabled. - Advertised bool `json:"advertised,nullable"` - // Last time the advertisement status was changed. This field is only not 'null' if - // on demand is enabled. - AdvertisedModifiedAt time.Time `json:"advertised_modified_at,nullable" format:"date-time"` - // Approval state of the prefix (P = pending, V = active). - Approved string `json:"approved"` - // Autonomous System Number (ASN) the prefix will be advertised under. - ASN int64 `json:"asn,nullable"` - // IP Prefix in Classless Inter-Domain Routing format. - Cidr string `json:"cidr"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Description of the prefix. - Description string `json:"description"` - // Identifier for the uploaded LOA document. - LOADocumentID string `json:"loa_document_id,nullable"` - ModifiedAt time.Time `json:"modified_at" format:"date-time"` - // Whether advertisement of the prefix to the Internet may be dynamically enabled - // or disabled. - OnDemandEnabled bool `json:"on_demand_enabled"` - // Whether advertisement status of the prefix is locked, meaning it cannot be - // changed. - OnDemandLocked bool `json:"on_demand_locked"` - JSON addressingPrefixEditResponseJSON `json:"-"` -} - -// addressingPrefixEditResponseJSON contains the JSON metadata for the struct -// [AddressingPrefixEditResponse] -type addressingPrefixEditResponseJSON struct { - ID apijson.Field - AccountID apijson.Field - Advertised apijson.Field - AdvertisedModifiedAt apijson.Field - Approved apijson.Field - ASN apijson.Field - Cidr apijson.Field - CreatedAt apijson.Field - Description apijson.Field - LOADocumentID apijson.Field - ModifiedAt apijson.Field - OnDemandEnabled apijson.Field - OnDemandLocked apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixEditResponseJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixGetResponse struct { - // Identifier - ID string `json:"id"` - // Identifier - AccountID string `json:"account_id"` - // Prefix advertisement status to the Internet. This field is only not 'null' if on - // demand is enabled. - Advertised bool `json:"advertised,nullable"` - // Last time the advertisement status was changed. This field is only not 'null' if - // on demand is enabled. - AdvertisedModifiedAt time.Time `json:"advertised_modified_at,nullable" format:"date-time"` - // Approval state of the prefix (P = pending, V = active). - Approved string `json:"approved"` - // Autonomous System Number (ASN) the prefix will be advertised under. - ASN int64 `json:"asn,nullable"` - // IP Prefix in Classless Inter-Domain Routing format. - Cidr string `json:"cidr"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Description of the prefix. - Description string `json:"description"` - // Identifier for the uploaded LOA document. - LOADocumentID string `json:"loa_document_id,nullable"` - ModifiedAt time.Time `json:"modified_at" format:"date-time"` - // Whether advertisement of the prefix to the Internet may be dynamically enabled - // or disabled. - OnDemandEnabled bool `json:"on_demand_enabled"` - // Whether advertisement status of the prefix is locked, meaning it cannot be - // changed. - OnDemandLocked bool `json:"on_demand_locked"` - JSON addressingPrefixGetResponseJSON `json:"-"` -} - -// addressingPrefixGetResponseJSON contains the JSON metadata for the struct -// [AddressingPrefixGetResponse] -type addressingPrefixGetResponseJSON struct { - ID apijson.Field - AccountID apijson.Field - Advertised apijson.Field - AdvertisedModifiedAt apijson.Field - Approved apijson.Field - ASN apijson.Field - Cidr apijson.Field - CreatedAt apijson.Field - Description apijson.Field - LOADocumentID apijson.Field - ModifiedAt apijson.Field - OnDemandEnabled apijson.Field - OnDemandLocked apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixGetResponseJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Autonomous System Number (ASN) the prefix will be advertised under. - ASN param.Field[int64] `json:"asn,required"` - // IP Prefix in Classless Inter-Domain Routing format. - Cidr param.Field[string] `json:"cidr,required"` - // Identifier for the uploaded LOA document. - LOADocumentID param.Field[string] `json:"loa_document_id,required"` -} - -func (r AddressingPrefixNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AddressingPrefixNewResponseEnvelope struct { - Errors []AddressingPrefixNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingPrefixNewResponseEnvelopeMessages `json:"messages,required"` - Result AddressingPrefixNewResponse `json:"result,required"` - // Whether the API call was successful - Success AddressingPrefixNewResponseEnvelopeSuccess `json:"success,required"` - JSON addressingPrefixNewResponseEnvelopeJSON `json:"-"` -} - -// addressingPrefixNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [AddressingPrefixNewResponseEnvelope] -type addressingPrefixNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingPrefixNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AddressingPrefixNewResponseEnvelopeErrors] -type addressingPrefixNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingPrefixNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AddressingPrefixNewResponseEnvelopeMessages] -type addressingPrefixNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingPrefixNewResponseEnvelopeSuccess bool - -const ( - AddressingPrefixNewResponseEnvelopeSuccessTrue AddressingPrefixNewResponseEnvelopeSuccess = true -) - -type AddressingPrefixListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingPrefixListResponseEnvelope struct { - Errors []AddressingPrefixListResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingPrefixListResponseEnvelopeMessages `json:"messages,required"` - Result []AddressingPrefixListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AddressingPrefixListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AddressingPrefixListResponseEnvelopeResultInfo `json:"result_info"` - JSON addressingPrefixListResponseEnvelopeJSON `json:"-"` -} - -// addressingPrefixListResponseEnvelopeJSON contains the JSON metadata for the -// struct [AddressingPrefixListResponseEnvelope] -type addressingPrefixListResponseEnvelopeJSON 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 *AddressingPrefixListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixListResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingPrefixListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AddressingPrefixListResponseEnvelopeErrors] -type addressingPrefixListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixListResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingPrefixListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AddressingPrefixListResponseEnvelopeMessages] -type addressingPrefixListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingPrefixListResponseEnvelopeSuccess bool - -const ( - AddressingPrefixListResponseEnvelopeSuccessTrue AddressingPrefixListResponseEnvelopeSuccess = true -) - -type AddressingPrefixListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON addressingPrefixListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// addressingPrefixListResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [AddressingPrefixListResponseEnvelopeResultInfo] -type addressingPrefixListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingPrefixDeleteResponseEnvelope struct { - Errors []AddressingPrefixDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingPrefixDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AddressingPrefixDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AddressingPrefixDeleteResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AddressingPrefixDeleteResponseEnvelopeResultInfo `json:"result_info"` - JSON addressingPrefixDeleteResponseEnvelopeJSON `json:"-"` -} - -// addressingPrefixDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [AddressingPrefixDeleteResponseEnvelope] -type addressingPrefixDeleteResponseEnvelopeJSON 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 *AddressingPrefixDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingPrefixDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AddressingPrefixDeleteResponseEnvelopeErrors] -type addressingPrefixDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingPrefixDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AddressingPrefixDeleteResponseEnvelopeMessages] -type addressingPrefixDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingPrefixDeleteResponseEnvelopeSuccess bool - -const ( - AddressingPrefixDeleteResponseEnvelopeSuccessTrue AddressingPrefixDeleteResponseEnvelopeSuccess = true -) - -type AddressingPrefixDeleteResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON addressingPrefixDeleteResponseEnvelopeResultInfoJSON `json:"-"` -} - -// addressingPrefixDeleteResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [AddressingPrefixDeleteResponseEnvelopeResultInfo] -type addressingPrefixDeleteResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixEditParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Description of the prefix. - Description param.Field[string] `json:"description,required"` -} - -func (r AddressingPrefixEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AddressingPrefixEditResponseEnvelope struct { - Errors []AddressingPrefixEditResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingPrefixEditResponseEnvelopeMessages `json:"messages,required"` - Result AddressingPrefixEditResponse `json:"result,required"` - // Whether the API call was successful - Success AddressingPrefixEditResponseEnvelopeSuccess `json:"success,required"` - JSON addressingPrefixEditResponseEnvelopeJSON `json:"-"` -} - -// addressingPrefixEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [AddressingPrefixEditResponseEnvelope] -type addressingPrefixEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingPrefixEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AddressingPrefixEditResponseEnvelopeErrors] -type addressingPrefixEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingPrefixEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AddressingPrefixEditResponseEnvelopeMessages] -type addressingPrefixEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingPrefixEditResponseEnvelopeSuccess bool - -const ( - AddressingPrefixEditResponseEnvelopeSuccessTrue AddressingPrefixEditResponseEnvelopeSuccess = true -) - -type AddressingPrefixGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingPrefixGetResponseEnvelope struct { - Errors []AddressingPrefixGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingPrefixGetResponseEnvelopeMessages `json:"messages,required"` - Result AddressingPrefixGetResponse `json:"result,required"` - // Whether the API call was successful - Success AddressingPrefixGetResponseEnvelopeSuccess `json:"success,required"` - JSON addressingPrefixGetResponseEnvelopeJSON `json:"-"` -} - -// addressingPrefixGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [AddressingPrefixGetResponseEnvelope] -type addressingPrefixGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingPrefixGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AddressingPrefixGetResponseEnvelopeErrors] -type addressingPrefixGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingPrefixGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AddressingPrefixGetResponseEnvelopeMessages] -type addressingPrefixGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingPrefixGetResponseEnvelopeSuccess bool - -const ( - AddressingPrefixGetResponseEnvelopeSuccessTrue AddressingPrefixGetResponseEnvelopeSuccess = true -) diff --git a/addressingprefix_test.go b/addressingprefix_test.go deleted file mode 100644 index d185e19b23a..00000000000 --- a/addressingprefix_test.go +++ /dev/null @@ -1,160 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAddressingPrefixNew(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("user@example.com"), - ) - _, err := client.Addressing.Prefixes.New(context.TODO(), cloudflare.AddressingPrefixNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - ASN: cloudflare.F(int64(209242)), - Cidr: cloudflare.F("192.0.2.0/24"), - LOADocumentID: cloudflare.F("d933b1530bc56c9953cf8ce166da8004"), - }) - 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 TestAddressingPrefixList(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("user@example.com"), - ) - _, err := client.Addressing.Prefixes.List(context.TODO(), cloudflare.AddressingPrefixListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestAddressingPrefixDelete(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("user@example.com"), - ) - _, err := client.Addressing.Prefixes.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingPrefixDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestAddressingPrefixEdit(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("user@example.com"), - ) - _, err := client.Addressing.Prefixes.Edit( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingPrefixEditParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Description: cloudflare.F("Internal test prefix"), - }, - ) - 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 TestAddressingPrefixGet(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("user@example.com"), - ) - _, err := client.Addressing.Prefixes.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingPrefixGetParams{ - AccountID: cloudflare.F("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/addressingprefixbgp.go b/addressingprefixbgp.go deleted file mode 100644 index 0b56eb9bc0c..00000000000 --- a/addressingprefixbgp.go +++ /dev/null @@ -1,31 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// AddressingPrefixBGPService 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 [NewAddressingPrefixBGPService] -// method instead. -type AddressingPrefixBGPService struct { - Options []option.RequestOption - Bindings *AddressingPrefixBGPBindingService - Prefixes *AddressingPrefixBGPPrefixService - Statuses *AddressingPrefixBGPStatusService -} - -// NewAddressingPrefixBGPService 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 NewAddressingPrefixBGPService(opts ...option.RequestOption) (r *AddressingPrefixBGPService) { - r = &AddressingPrefixBGPService{} - r.Options = opts - r.Bindings = NewAddressingPrefixBGPBindingService(opts...) - r.Prefixes = NewAddressingPrefixBGPPrefixService(opts...) - r.Statuses = NewAddressingPrefixBGPStatusService(opts...) - return -} diff --git a/addressingprefixbgpbinding.go b/addressingprefixbgpbinding.go deleted file mode 100644 index 2bb1102e2c0..00000000000 --- a/addressingprefixbgpbinding.go +++ /dev/null @@ -1,675 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// AddressingPrefixBGPBindingService 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 -// [NewAddressingPrefixBGPBindingService] method instead. -type AddressingPrefixBGPBindingService struct { - Options []option.RequestOption -} - -// NewAddressingPrefixBGPBindingService 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 NewAddressingPrefixBGPBindingService(opts ...option.RequestOption) (r *AddressingPrefixBGPBindingService) { - r = &AddressingPrefixBGPBindingService{} - r.Options = opts - return -} - -// Creates a new Service Binding, routing traffic to IPs within the given CIDR to a -// service running on Cloudflare's network. **Note:** This API may only be used on -// prefixes currently configured with a Magic Transit service binding, and only -// allows creating service bindings for the Cloudflare CDN or Cloudflare Spectrum. -func (r *AddressingPrefixBGPBindingService) New(ctx context.Context, prefixID string, params AddressingPrefixBGPBindingNewParams, opts ...option.RequestOption) (res *AddressingPrefixBGPBindingNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingPrefixBGPBindingNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bindings", params.AccountID, prefixID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List the Cloudflare services this prefix is currently bound to. Traffic sent to -// an address within an IP prefix will be routed to the Cloudflare service of the -// most-specific Service Binding matching the address. **Example:** binding -// `192.0.2.0/24` to Cloudflare Magic Transit and `192.0.2.1/32` to the Cloudflare -// CDN would route traffic for `192.0.2.1` to the CDN, and traffic for all other -// IPs in the prefix to Cloudflare Magic Transit. -func (r *AddressingPrefixBGPBindingService) List(ctx context.Context, prefixID string, query AddressingPrefixBGPBindingListParams, opts ...option.RequestOption) (res *[]AddressingPrefixBGPBindingListResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingPrefixBGPBindingListResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bindings", query.AccountID, prefixID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a Service Binding -func (r *AddressingPrefixBGPBindingService) Delete(ctx context.Context, prefixID string, bindingID string, body AddressingPrefixBGPBindingDeleteParams, opts ...option.RequestOption) (res *AddressingPrefixBGPBindingDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingPrefixBGPBindingDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bindings/%s", body.AccountID, prefixID, bindingID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch a single Service Binding -func (r *AddressingPrefixBGPBindingService) Get(ctx context.Context, prefixID string, bindingID string, query AddressingPrefixBGPBindingGetParams, opts ...option.RequestOption) (res *AddressingPrefixBGPBindingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingPrefixBGPBindingGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bindings/%s", query.AccountID, prefixID, bindingID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type AddressingPrefixBGPBindingNewResponse struct { - // Identifier - ID string `json:"id"` - // IP Prefix in Classless Inter-Domain Routing format. - Cidr string `json:"cidr"` - // Status of a Service Binding's deployment to the Cloudflare network - Provisioning AddressingPrefixBGPBindingNewResponseProvisioning `json:"provisioning"` - // Identifier - ServiceID string `json:"service_id"` - // Name of a service running on the Cloudflare network - ServiceName string `json:"service_name"` - JSON addressingPrefixBGPBindingNewResponseJSON `json:"-"` -} - -// addressingPrefixBGPBindingNewResponseJSON contains the JSON metadata for the -// struct [AddressingPrefixBGPBindingNewResponse] -type addressingPrefixBGPBindingNewResponseJSON struct { - ID apijson.Field - Cidr apijson.Field - Provisioning apijson.Field - ServiceID apijson.Field - ServiceName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPBindingNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPBindingNewResponseJSON) RawJSON() string { - return r.raw -} - -// Status of a Service Binding's deployment to the Cloudflare network -type AddressingPrefixBGPBindingNewResponseProvisioning struct { - // When a binding has been deployed to a majority of Cloudflare datacenters, the - // binding will become active and can be used with its associated service. - State AddressingPrefixBGPBindingNewResponseProvisioningState `json:"state"` - JSON addressingPrefixBGPBindingNewResponseProvisioningJSON `json:"-"` -} - -// addressingPrefixBGPBindingNewResponseProvisioningJSON contains the JSON metadata -// for the struct [AddressingPrefixBGPBindingNewResponseProvisioning] -type addressingPrefixBGPBindingNewResponseProvisioningJSON struct { - State apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPBindingNewResponseProvisioning) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPBindingNewResponseProvisioningJSON) RawJSON() string { - return r.raw -} - -// When a binding has been deployed to a majority of Cloudflare datacenters, the -// binding will become active and can be used with its associated service. -type AddressingPrefixBGPBindingNewResponseProvisioningState string - -const ( - AddressingPrefixBGPBindingNewResponseProvisioningStateProvisioning AddressingPrefixBGPBindingNewResponseProvisioningState = "provisioning" - AddressingPrefixBGPBindingNewResponseProvisioningStateActive AddressingPrefixBGPBindingNewResponseProvisioningState = "active" -) - -type AddressingPrefixBGPBindingListResponse struct { - // Identifier - ID string `json:"id"` - // IP Prefix in Classless Inter-Domain Routing format. - Cidr string `json:"cidr"` - // Status of a Service Binding's deployment to the Cloudflare network - Provisioning AddressingPrefixBGPBindingListResponseProvisioning `json:"provisioning"` - // Identifier - ServiceID string `json:"service_id"` - // Name of a service running on the Cloudflare network - ServiceName string `json:"service_name"` - JSON addressingPrefixBGPBindingListResponseJSON `json:"-"` -} - -// addressingPrefixBGPBindingListResponseJSON contains the JSON metadata for the -// struct [AddressingPrefixBGPBindingListResponse] -type addressingPrefixBGPBindingListResponseJSON struct { - ID apijson.Field - Cidr apijson.Field - Provisioning apijson.Field - ServiceID apijson.Field - ServiceName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPBindingListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPBindingListResponseJSON) RawJSON() string { - return r.raw -} - -// Status of a Service Binding's deployment to the Cloudflare network -type AddressingPrefixBGPBindingListResponseProvisioning struct { - // When a binding has been deployed to a majority of Cloudflare datacenters, the - // binding will become active and can be used with its associated service. - State AddressingPrefixBGPBindingListResponseProvisioningState `json:"state"` - JSON addressingPrefixBGPBindingListResponseProvisioningJSON `json:"-"` -} - -// addressingPrefixBGPBindingListResponseProvisioningJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPBindingListResponseProvisioning] -type addressingPrefixBGPBindingListResponseProvisioningJSON struct { - State apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPBindingListResponseProvisioning) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPBindingListResponseProvisioningJSON) RawJSON() string { - return r.raw -} - -// When a binding has been deployed to a majority of Cloudflare datacenters, the -// binding will become active and can be used with its associated service. -type AddressingPrefixBGPBindingListResponseProvisioningState string - -const ( - AddressingPrefixBGPBindingListResponseProvisioningStateProvisioning AddressingPrefixBGPBindingListResponseProvisioningState = "provisioning" - AddressingPrefixBGPBindingListResponseProvisioningStateActive AddressingPrefixBGPBindingListResponseProvisioningState = "active" -) - -// Union satisfied by [AddressingPrefixBGPBindingDeleteResponseUnknown], -// [AddressingPrefixBGPBindingDeleteResponseArray] or [shared.UnionString]. -type AddressingPrefixBGPBindingDeleteResponse interface { - ImplementsAddressingPrefixBGPBindingDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AddressingPrefixBGPBindingDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AddressingPrefixBGPBindingDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type AddressingPrefixBGPBindingDeleteResponseArray []interface{} - -func (r AddressingPrefixBGPBindingDeleteResponseArray) ImplementsAddressingPrefixBGPBindingDeleteResponse() { -} - -type AddressingPrefixBGPBindingGetResponse struct { - // Identifier - ID string `json:"id"` - // IP Prefix in Classless Inter-Domain Routing format. - Cidr string `json:"cidr"` - // Status of a Service Binding's deployment to the Cloudflare network - Provisioning AddressingPrefixBGPBindingGetResponseProvisioning `json:"provisioning"` - // Identifier - ServiceID string `json:"service_id"` - // Name of a service running on the Cloudflare network - ServiceName string `json:"service_name"` - JSON addressingPrefixBGPBindingGetResponseJSON `json:"-"` -} - -// addressingPrefixBGPBindingGetResponseJSON contains the JSON metadata for the -// struct [AddressingPrefixBGPBindingGetResponse] -type addressingPrefixBGPBindingGetResponseJSON struct { - ID apijson.Field - Cidr apijson.Field - Provisioning apijson.Field - ServiceID apijson.Field - ServiceName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPBindingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPBindingGetResponseJSON) RawJSON() string { - return r.raw -} - -// Status of a Service Binding's deployment to the Cloudflare network -type AddressingPrefixBGPBindingGetResponseProvisioning struct { - // When a binding has been deployed to a majority of Cloudflare datacenters, the - // binding will become active and can be used with its associated service. - State AddressingPrefixBGPBindingGetResponseProvisioningState `json:"state"` - JSON addressingPrefixBGPBindingGetResponseProvisioningJSON `json:"-"` -} - -// addressingPrefixBGPBindingGetResponseProvisioningJSON contains the JSON metadata -// for the struct [AddressingPrefixBGPBindingGetResponseProvisioning] -type addressingPrefixBGPBindingGetResponseProvisioningJSON struct { - State apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPBindingGetResponseProvisioning) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPBindingGetResponseProvisioningJSON) RawJSON() string { - return r.raw -} - -// When a binding has been deployed to a majority of Cloudflare datacenters, the -// binding will become active and can be used with its associated service. -type AddressingPrefixBGPBindingGetResponseProvisioningState string - -const ( - AddressingPrefixBGPBindingGetResponseProvisioningStateProvisioning AddressingPrefixBGPBindingGetResponseProvisioningState = "provisioning" - AddressingPrefixBGPBindingGetResponseProvisioningStateActive AddressingPrefixBGPBindingGetResponseProvisioningState = "active" -) - -type AddressingPrefixBGPBindingNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // IP Prefix in Classless Inter-Domain Routing format. - Cidr param.Field[string] `json:"cidr"` - // Identifier - ServiceID param.Field[string] `json:"service_id"` -} - -func (r AddressingPrefixBGPBindingNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AddressingPrefixBGPBindingNewResponseEnvelope struct { - Errors []AddressingPrefixBGPBindingNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingPrefixBGPBindingNewResponseEnvelopeMessages `json:"messages,required"` - Result AddressingPrefixBGPBindingNewResponse `json:"result,required"` - // Whether the API call was successful - Success AddressingPrefixBGPBindingNewResponseEnvelopeSuccess `json:"success,required"` - JSON addressingPrefixBGPBindingNewResponseEnvelopeJSON `json:"-"` -} - -// addressingPrefixBGPBindingNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [AddressingPrefixBGPBindingNewResponseEnvelope] -type addressingPrefixBGPBindingNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPBindingNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPBindingNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPBindingNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixBGPBindingNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingPrefixBGPBindingNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPBindingNewResponseEnvelopeErrors] -type addressingPrefixBGPBindingNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPBindingNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPBindingNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPBindingNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixBGPBindingNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingPrefixBGPBindingNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPBindingNewResponseEnvelopeMessages] -type addressingPrefixBGPBindingNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPBindingNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPBindingNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingPrefixBGPBindingNewResponseEnvelopeSuccess bool - -const ( - AddressingPrefixBGPBindingNewResponseEnvelopeSuccessTrue AddressingPrefixBGPBindingNewResponseEnvelopeSuccess = true -) - -type AddressingPrefixBGPBindingListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingPrefixBGPBindingListResponseEnvelope struct { - Errors []AddressingPrefixBGPBindingListResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingPrefixBGPBindingListResponseEnvelopeMessages `json:"messages,required"` - Result []AddressingPrefixBGPBindingListResponse `json:"result,required"` - // Whether the API call was successful - Success AddressingPrefixBGPBindingListResponseEnvelopeSuccess `json:"success,required"` - JSON addressingPrefixBGPBindingListResponseEnvelopeJSON `json:"-"` -} - -// addressingPrefixBGPBindingListResponseEnvelopeJSON contains the JSON metadata -// for the struct [AddressingPrefixBGPBindingListResponseEnvelope] -type addressingPrefixBGPBindingListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPBindingListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPBindingListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPBindingListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixBGPBindingListResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingPrefixBGPBindingListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPBindingListResponseEnvelopeErrors] -type addressingPrefixBGPBindingListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPBindingListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPBindingListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPBindingListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixBGPBindingListResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingPrefixBGPBindingListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPBindingListResponseEnvelopeMessages] -type addressingPrefixBGPBindingListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPBindingListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPBindingListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingPrefixBGPBindingListResponseEnvelopeSuccess bool - -const ( - AddressingPrefixBGPBindingListResponseEnvelopeSuccessTrue AddressingPrefixBGPBindingListResponseEnvelopeSuccess = true -) - -type AddressingPrefixBGPBindingDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingPrefixBGPBindingDeleteResponseEnvelope struct { - Errors []AddressingPrefixBGPBindingDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingPrefixBGPBindingDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AddressingPrefixBGPBindingDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success AddressingPrefixBGPBindingDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON addressingPrefixBGPBindingDeleteResponseEnvelopeJSON `json:"-"` -} - -// addressingPrefixBGPBindingDeleteResponseEnvelopeJSON contains the JSON metadata -// for the struct [AddressingPrefixBGPBindingDeleteResponseEnvelope] -type addressingPrefixBGPBindingDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPBindingDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPBindingDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPBindingDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixBGPBindingDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingPrefixBGPBindingDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPBindingDeleteResponseEnvelopeErrors] -type addressingPrefixBGPBindingDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPBindingDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPBindingDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPBindingDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixBGPBindingDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingPrefixBGPBindingDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [AddressingPrefixBGPBindingDeleteResponseEnvelopeMessages] -type addressingPrefixBGPBindingDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPBindingDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPBindingDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingPrefixBGPBindingDeleteResponseEnvelopeSuccess bool - -const ( - AddressingPrefixBGPBindingDeleteResponseEnvelopeSuccessTrue AddressingPrefixBGPBindingDeleteResponseEnvelopeSuccess = true -) - -type AddressingPrefixBGPBindingGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingPrefixBGPBindingGetResponseEnvelope struct { - Errors []AddressingPrefixBGPBindingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingPrefixBGPBindingGetResponseEnvelopeMessages `json:"messages,required"` - Result AddressingPrefixBGPBindingGetResponse `json:"result,required"` - // Whether the API call was successful - Success AddressingPrefixBGPBindingGetResponseEnvelopeSuccess `json:"success,required"` - JSON addressingPrefixBGPBindingGetResponseEnvelopeJSON `json:"-"` -} - -// addressingPrefixBGPBindingGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [AddressingPrefixBGPBindingGetResponseEnvelope] -type addressingPrefixBGPBindingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPBindingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPBindingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPBindingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixBGPBindingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingPrefixBGPBindingGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPBindingGetResponseEnvelopeErrors] -type addressingPrefixBGPBindingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPBindingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPBindingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPBindingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixBGPBindingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingPrefixBGPBindingGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPBindingGetResponseEnvelopeMessages] -type addressingPrefixBGPBindingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPBindingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPBindingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingPrefixBGPBindingGetResponseEnvelopeSuccess bool - -const ( - AddressingPrefixBGPBindingGetResponseEnvelopeSuccessTrue AddressingPrefixBGPBindingGetResponseEnvelopeSuccess = true -) diff --git a/addressingprefixbgpbinding_test.go b/addressingprefixbgpbinding_test.go deleted file mode 100644 index ffbe2eff8ee..00000000000 --- a/addressingprefixbgpbinding_test.go +++ /dev/null @@ -1,138 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAddressingPrefixBGPBindingNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Addressing.Prefixes.BGP.Bindings.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingPrefixBGPBindingNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Cidr: cloudflare.F("192.0.2.0/24"), - ServiceID: cloudflare.F("2db684ee7ca04e159946fd05b99e1bcd"), - }, - ) - 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 TestAddressingPrefixBGPBindingList(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("user@example.com"), - ) - _, err := client.Addressing.Prefixes.BGP.Bindings.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingPrefixBGPBindingListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestAddressingPrefixBGPBindingDelete(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("user@example.com"), - ) - _, err := client.Addressing.Prefixes.BGP.Bindings.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingPrefixBGPBindingDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestAddressingPrefixBGPBindingGet(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("user@example.com"), - ) - _, err := client.Addressing.Prefixes.BGP.Bindings.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingPrefixBGPBindingGetParams{ - AccountID: cloudflare.F("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/addressingprefixbgpprefix.go b/addressingprefixbgpprefix.go deleted file mode 100644 index ff7547b172b..00000000000 --- a/addressingprefixbgpprefix.go +++ /dev/null @@ -1,675 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// AddressingPrefixBGPPrefixService 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 -// [NewAddressingPrefixBGPPrefixService] method instead. -type AddressingPrefixBGPPrefixService struct { - Options []option.RequestOption -} - -// NewAddressingPrefixBGPPrefixService 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 NewAddressingPrefixBGPPrefixService(opts ...option.RequestOption) (r *AddressingPrefixBGPPrefixService) { - r = &AddressingPrefixBGPPrefixService{} - r.Options = opts - return -} - -// List all BGP Prefixes within the specified IP Prefix. BGP Prefixes are used to -// control which specific subnets are advertised to the Internet. It is possible to -// advertise subnets more specific than an IP Prefix by creating more specific BGP -// Prefixes. -func (r *AddressingPrefixBGPPrefixService) List(ctx context.Context, prefixID string, query AddressingPrefixBGPPrefixListParams, opts ...option.RequestOption) (res *[]AddressingPrefixBGPPrefixListResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingPrefixBGPPrefixListResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bgp/prefixes", query.AccountID, prefixID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update the properties of a BGP Prefix, such as the on demand advertisement -// status (advertised or withdrawn). -func (r *AddressingPrefixBGPPrefixService) Edit(ctx context.Context, prefixID string, bgpPrefixID string, params AddressingPrefixBGPPrefixEditParams, opts ...option.RequestOption) (res *AddressingPrefixBGPPrefixEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingPrefixBGPPrefixEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bgp/prefixes/%s", params.AccountID, prefixID, bgpPrefixID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Retrieve a single BGP Prefix according to its identifier -func (r *AddressingPrefixBGPPrefixService) Get(ctx context.Context, prefixID string, bgpPrefixID string, query AddressingPrefixBGPPrefixGetParams, opts ...option.RequestOption) (res *AddressingPrefixBGPPrefixGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingPrefixBGPPrefixGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bgp/prefixes/%s", query.AccountID, prefixID, bgpPrefixID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type AddressingPrefixBGPPrefixListResponse struct { - // Identifier - ID string `json:"id"` - // Autonomous System Number (ASN) the prefix will be advertised under. - ASN int64 `json:"asn,nullable"` - BGPSignalOpts AddressingPrefixBGPPrefixListResponseBGPSignalOpts `json:"bgp_signal_opts"` - // IP Prefix in Classless Inter-Domain Routing format. - Cidr string `json:"cidr"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - ModifiedAt time.Time `json:"modified_at" format:"date-time"` - OnDemand AddressingPrefixBGPPrefixListResponseOnDemand `json:"on_demand"` - JSON addressingPrefixBGPPrefixListResponseJSON `json:"-"` -} - -// addressingPrefixBGPPrefixListResponseJSON contains the JSON metadata for the -// struct [AddressingPrefixBGPPrefixListResponse] -type addressingPrefixBGPPrefixListResponseJSON struct { - ID apijson.Field - ASN apijson.Field - BGPSignalOpts apijson.Field - Cidr apijson.Field - CreatedAt apijson.Field - ModifiedAt apijson.Field - OnDemand apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPPrefixListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixListResponseJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPPrefixListResponseBGPSignalOpts struct { - // Whether control of advertisement of the prefix to the Internet is enabled to be - // performed via BGP signal - Enabled bool `json:"enabled"` - // Last time BGP signaling control was toggled. This field is null if BGP signaling - // has never been enabled. - ModifiedAt time.Time `json:"modified_at,nullable" format:"date-time"` - JSON addressingPrefixBGPPrefixListResponseBGPSignalOptsJSON `json:"-"` -} - -// addressingPrefixBGPPrefixListResponseBGPSignalOptsJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPPrefixListResponseBGPSignalOpts] -type addressingPrefixBGPPrefixListResponseBGPSignalOptsJSON struct { - Enabled apijson.Field - ModifiedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPPrefixListResponseBGPSignalOpts) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixListResponseBGPSignalOptsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPPrefixListResponseOnDemand struct { - // Prefix advertisement status to the Internet. This field is only not 'null' if on - // demand is enabled. - Advertised bool `json:"advertised,nullable"` - // Last time the advertisement status was changed. This field is only not 'null' if - // on demand is enabled. - AdvertisedModifiedAt time.Time `json:"advertised_modified_at,nullable" format:"date-time"` - // Whether advertisement of the prefix to the Internet may be dynamically enabled - // or disabled. - OnDemandEnabled bool `json:"on_demand_enabled"` - // Whether advertisement status of the prefix is locked, meaning it cannot be - // changed. - OnDemandLocked bool `json:"on_demand_locked"` - JSON addressingPrefixBGPPrefixListResponseOnDemandJSON `json:"-"` -} - -// addressingPrefixBGPPrefixListResponseOnDemandJSON contains the JSON metadata for -// the struct [AddressingPrefixBGPPrefixListResponseOnDemand] -type addressingPrefixBGPPrefixListResponseOnDemandJSON struct { - Advertised apijson.Field - AdvertisedModifiedAt apijson.Field - OnDemandEnabled apijson.Field - OnDemandLocked apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPPrefixListResponseOnDemand) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixListResponseOnDemandJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPPrefixEditResponse struct { - // Identifier - ID string `json:"id"` - // Autonomous System Number (ASN) the prefix will be advertised under. - ASN int64 `json:"asn,nullable"` - BGPSignalOpts AddressingPrefixBGPPrefixEditResponseBGPSignalOpts `json:"bgp_signal_opts"` - // IP Prefix in Classless Inter-Domain Routing format. - Cidr string `json:"cidr"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - ModifiedAt time.Time `json:"modified_at" format:"date-time"` - OnDemand AddressingPrefixBGPPrefixEditResponseOnDemand `json:"on_demand"` - JSON addressingPrefixBGPPrefixEditResponseJSON `json:"-"` -} - -// addressingPrefixBGPPrefixEditResponseJSON contains the JSON metadata for the -// struct [AddressingPrefixBGPPrefixEditResponse] -type addressingPrefixBGPPrefixEditResponseJSON struct { - ID apijson.Field - ASN apijson.Field - BGPSignalOpts apijson.Field - Cidr apijson.Field - CreatedAt apijson.Field - ModifiedAt apijson.Field - OnDemand apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPPrefixEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixEditResponseJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPPrefixEditResponseBGPSignalOpts struct { - // Whether control of advertisement of the prefix to the Internet is enabled to be - // performed via BGP signal - Enabled bool `json:"enabled"` - // Last time BGP signaling control was toggled. This field is null if BGP signaling - // has never been enabled. - ModifiedAt time.Time `json:"modified_at,nullable" format:"date-time"` - JSON addressingPrefixBGPPrefixEditResponseBGPSignalOptsJSON `json:"-"` -} - -// addressingPrefixBGPPrefixEditResponseBGPSignalOptsJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPPrefixEditResponseBGPSignalOpts] -type addressingPrefixBGPPrefixEditResponseBGPSignalOptsJSON struct { - Enabled apijson.Field - ModifiedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPPrefixEditResponseBGPSignalOpts) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixEditResponseBGPSignalOptsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPPrefixEditResponseOnDemand struct { - // Prefix advertisement status to the Internet. This field is only not 'null' if on - // demand is enabled. - Advertised bool `json:"advertised,nullable"` - // Last time the advertisement status was changed. This field is only not 'null' if - // on demand is enabled. - AdvertisedModifiedAt time.Time `json:"advertised_modified_at,nullable" format:"date-time"` - // Whether advertisement of the prefix to the Internet may be dynamically enabled - // or disabled. - OnDemandEnabled bool `json:"on_demand_enabled"` - // Whether advertisement status of the prefix is locked, meaning it cannot be - // changed. - OnDemandLocked bool `json:"on_demand_locked"` - JSON addressingPrefixBGPPrefixEditResponseOnDemandJSON `json:"-"` -} - -// addressingPrefixBGPPrefixEditResponseOnDemandJSON contains the JSON metadata for -// the struct [AddressingPrefixBGPPrefixEditResponseOnDemand] -type addressingPrefixBGPPrefixEditResponseOnDemandJSON struct { - Advertised apijson.Field - AdvertisedModifiedAt apijson.Field - OnDemandEnabled apijson.Field - OnDemandLocked apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPPrefixEditResponseOnDemand) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixEditResponseOnDemandJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPPrefixGetResponse struct { - // Identifier - ID string `json:"id"` - // Autonomous System Number (ASN) the prefix will be advertised under. - ASN int64 `json:"asn,nullable"` - BGPSignalOpts AddressingPrefixBGPPrefixGetResponseBGPSignalOpts `json:"bgp_signal_opts"` - // IP Prefix in Classless Inter-Domain Routing format. - Cidr string `json:"cidr"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - ModifiedAt time.Time `json:"modified_at" format:"date-time"` - OnDemand AddressingPrefixBGPPrefixGetResponseOnDemand `json:"on_demand"` - JSON addressingPrefixBGPPrefixGetResponseJSON `json:"-"` -} - -// addressingPrefixBGPPrefixGetResponseJSON contains the JSON metadata for the -// struct [AddressingPrefixBGPPrefixGetResponse] -type addressingPrefixBGPPrefixGetResponseJSON struct { - ID apijson.Field - ASN apijson.Field - BGPSignalOpts apijson.Field - Cidr apijson.Field - CreatedAt apijson.Field - ModifiedAt apijson.Field - OnDemand apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPPrefixGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixGetResponseJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPPrefixGetResponseBGPSignalOpts struct { - // Whether control of advertisement of the prefix to the Internet is enabled to be - // performed via BGP signal - Enabled bool `json:"enabled"` - // Last time BGP signaling control was toggled. This field is null if BGP signaling - // has never been enabled. - ModifiedAt time.Time `json:"modified_at,nullable" format:"date-time"` - JSON addressingPrefixBGPPrefixGetResponseBGPSignalOptsJSON `json:"-"` -} - -// addressingPrefixBGPPrefixGetResponseBGPSignalOptsJSON contains the JSON metadata -// for the struct [AddressingPrefixBGPPrefixGetResponseBGPSignalOpts] -type addressingPrefixBGPPrefixGetResponseBGPSignalOptsJSON struct { - Enabled apijson.Field - ModifiedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPPrefixGetResponseBGPSignalOpts) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixGetResponseBGPSignalOptsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPPrefixGetResponseOnDemand struct { - // Prefix advertisement status to the Internet. This field is only not 'null' if on - // demand is enabled. - Advertised bool `json:"advertised,nullable"` - // Last time the advertisement status was changed. This field is only not 'null' if - // on demand is enabled. - AdvertisedModifiedAt time.Time `json:"advertised_modified_at,nullable" format:"date-time"` - // Whether advertisement of the prefix to the Internet may be dynamically enabled - // or disabled. - OnDemandEnabled bool `json:"on_demand_enabled"` - // Whether advertisement status of the prefix is locked, meaning it cannot be - // changed. - OnDemandLocked bool `json:"on_demand_locked"` - JSON addressingPrefixBGPPrefixGetResponseOnDemandJSON `json:"-"` -} - -// addressingPrefixBGPPrefixGetResponseOnDemandJSON contains the JSON metadata for -// the struct [AddressingPrefixBGPPrefixGetResponseOnDemand] -type addressingPrefixBGPPrefixGetResponseOnDemandJSON struct { - Advertised apijson.Field - AdvertisedModifiedAt apijson.Field - OnDemandEnabled apijson.Field - OnDemandLocked apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPPrefixGetResponseOnDemand) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixGetResponseOnDemandJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPPrefixListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingPrefixBGPPrefixListResponseEnvelope struct { - Errors []AddressingPrefixBGPPrefixListResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingPrefixBGPPrefixListResponseEnvelopeMessages `json:"messages,required"` - Result []AddressingPrefixBGPPrefixListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AddressingPrefixBGPPrefixListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AddressingPrefixBGPPrefixListResponseEnvelopeResultInfo `json:"result_info"` - JSON addressingPrefixBGPPrefixListResponseEnvelopeJSON `json:"-"` -} - -// addressingPrefixBGPPrefixListResponseEnvelopeJSON contains the JSON metadata for -// the struct [AddressingPrefixBGPPrefixListResponseEnvelope] -type addressingPrefixBGPPrefixListResponseEnvelopeJSON 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 *AddressingPrefixBGPPrefixListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPPrefixListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixBGPPrefixListResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingPrefixBGPPrefixListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPPrefixListResponseEnvelopeErrors] -type addressingPrefixBGPPrefixListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPPrefixListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPPrefixListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixBGPPrefixListResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingPrefixBGPPrefixListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPPrefixListResponseEnvelopeMessages] -type addressingPrefixBGPPrefixListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPPrefixListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingPrefixBGPPrefixListResponseEnvelopeSuccess bool - -const ( - AddressingPrefixBGPPrefixListResponseEnvelopeSuccessTrue AddressingPrefixBGPPrefixListResponseEnvelopeSuccess = true -) - -type AddressingPrefixBGPPrefixListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON addressingPrefixBGPPrefixListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// addressingPrefixBGPPrefixListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [AddressingPrefixBGPPrefixListResponseEnvelopeResultInfo] -type addressingPrefixBGPPrefixListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPPrefixListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPPrefixEditParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - OnDemand param.Field[AddressingPrefixBGPPrefixEditParamsOnDemand] `json:"on_demand"` -} - -func (r AddressingPrefixBGPPrefixEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AddressingPrefixBGPPrefixEditParamsOnDemand struct { - Advertised param.Field[bool] `json:"advertised"` -} - -func (r AddressingPrefixBGPPrefixEditParamsOnDemand) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AddressingPrefixBGPPrefixEditResponseEnvelope struct { - Errors []AddressingPrefixBGPPrefixEditResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingPrefixBGPPrefixEditResponseEnvelopeMessages `json:"messages,required"` - Result AddressingPrefixBGPPrefixEditResponse `json:"result,required"` - // Whether the API call was successful - Success AddressingPrefixBGPPrefixEditResponseEnvelopeSuccess `json:"success,required"` - JSON addressingPrefixBGPPrefixEditResponseEnvelopeJSON `json:"-"` -} - -// addressingPrefixBGPPrefixEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [AddressingPrefixBGPPrefixEditResponseEnvelope] -type addressingPrefixBGPPrefixEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPPrefixEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPPrefixEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixBGPPrefixEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingPrefixBGPPrefixEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPPrefixEditResponseEnvelopeErrors] -type addressingPrefixBGPPrefixEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPPrefixEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPPrefixEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixBGPPrefixEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingPrefixBGPPrefixEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPPrefixEditResponseEnvelopeMessages] -type addressingPrefixBGPPrefixEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPPrefixEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingPrefixBGPPrefixEditResponseEnvelopeSuccess bool - -const ( - AddressingPrefixBGPPrefixEditResponseEnvelopeSuccessTrue AddressingPrefixBGPPrefixEditResponseEnvelopeSuccess = true -) - -type AddressingPrefixBGPPrefixGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingPrefixBGPPrefixGetResponseEnvelope struct { - Errors []AddressingPrefixBGPPrefixGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingPrefixBGPPrefixGetResponseEnvelopeMessages `json:"messages,required"` - Result AddressingPrefixBGPPrefixGetResponse `json:"result,required"` - // Whether the API call was successful - Success AddressingPrefixBGPPrefixGetResponseEnvelopeSuccess `json:"success,required"` - JSON addressingPrefixBGPPrefixGetResponseEnvelopeJSON `json:"-"` -} - -// addressingPrefixBGPPrefixGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [AddressingPrefixBGPPrefixGetResponseEnvelope] -type addressingPrefixBGPPrefixGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPPrefixGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPPrefixGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixBGPPrefixGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingPrefixBGPPrefixGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPPrefixGetResponseEnvelopeErrors] -type addressingPrefixBGPPrefixGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPPrefixGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPPrefixGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixBGPPrefixGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingPrefixBGPPrefixGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPPrefixGetResponseEnvelopeMessages] -type addressingPrefixBGPPrefixGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPPrefixGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPPrefixGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingPrefixBGPPrefixGetResponseEnvelopeSuccess bool - -const ( - AddressingPrefixBGPPrefixGetResponseEnvelopeSuccessTrue AddressingPrefixBGPPrefixGetResponseEnvelopeSuccess = true -) diff --git a/addressingprefixbgpprefix_test.go b/addressingprefixbgpprefix_test.go deleted file mode 100644 index 442344662a5..00000000000 --- a/addressingprefixbgpprefix_test.go +++ /dev/null @@ -1,109 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAddressingPrefixBGPPrefixList(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("user@example.com"), - ) - _, err := client.Addressing.Prefixes.BGP.Prefixes.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingPrefixBGPPrefixListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestAddressingPrefixBGPPrefixEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Addressing.Prefixes.BGP.Prefixes.Edit( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingPrefixBGPPrefixEditParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - OnDemand: cloudflare.F(cloudflare.AddressingPrefixBGPPrefixEditParamsOnDemand{ - Advertised: cloudflare.F(true), - }), - }, - ) - 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 TestAddressingPrefixBGPPrefixGet(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("user@example.com"), - ) - _, err := client.Addressing.Prefixes.BGP.Prefixes.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingPrefixBGPPrefixGetParams{ - AccountID: cloudflare.F("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/addressingprefixbgpstatus.go b/addressingprefixbgpstatus.go deleted file mode 100644 index 3ed3926f276..00000000000 --- a/addressingprefixbgpstatus.go +++ /dev/null @@ -1,289 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// AddressingPrefixBGPStatusService 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 -// [NewAddressingPrefixBGPStatusService] method instead. -type AddressingPrefixBGPStatusService struct { - Options []option.RequestOption -} - -// NewAddressingPrefixBGPStatusService 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 NewAddressingPrefixBGPStatusService(opts ...option.RequestOption) (r *AddressingPrefixBGPStatusService) { - r = &AddressingPrefixBGPStatusService{} - r.Options = opts - return -} - -// Advertise or withdraw BGP route for a prefix. -func (r *AddressingPrefixBGPStatusService) Edit(ctx context.Context, prefixID string, params AddressingPrefixBGPStatusEditParams, opts ...option.RequestOption) (res *AddressingPrefixBGPStatusEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingPrefixBGPStatusEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bgp/status", params.AccountID, prefixID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List the current advertisement state for a prefix. -func (r *AddressingPrefixBGPStatusService) Get(ctx context.Context, prefixID string, query AddressingPrefixBGPStatusGetParams, opts ...option.RequestOption) (res *AddressingPrefixBGPStatusGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingPrefixBGPStatusGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/bgp/status", query.AccountID, prefixID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type AddressingPrefixBGPStatusEditResponse struct { - // Enablement of prefix advertisement to the Internet. - Advertised bool `json:"advertised"` - // Last time the advertisement status was changed. This field is only not 'null' if - // on demand is enabled. - AdvertisedModifiedAt time.Time `json:"advertised_modified_at,nullable" format:"date-time"` - JSON addressingPrefixBGPStatusEditResponseJSON `json:"-"` -} - -// addressingPrefixBGPStatusEditResponseJSON contains the JSON metadata for the -// struct [AddressingPrefixBGPStatusEditResponse] -type addressingPrefixBGPStatusEditResponseJSON struct { - Advertised apijson.Field - AdvertisedModifiedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPStatusEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPStatusEditResponseJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPStatusGetResponse struct { - // Enablement of prefix advertisement to the Internet. - Advertised bool `json:"advertised"` - // Last time the advertisement status was changed. This field is only not 'null' if - // on demand is enabled. - AdvertisedModifiedAt time.Time `json:"advertised_modified_at,nullable" format:"date-time"` - JSON addressingPrefixBGPStatusGetResponseJSON `json:"-"` -} - -// addressingPrefixBGPStatusGetResponseJSON contains the JSON metadata for the -// struct [AddressingPrefixBGPStatusGetResponse] -type addressingPrefixBGPStatusGetResponseJSON struct { - Advertised apijson.Field - AdvertisedModifiedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPStatusGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPStatusGetResponseJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPStatusEditParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Enablement of prefix advertisement to the Internet. - Advertised param.Field[bool] `json:"advertised,required"` -} - -func (r AddressingPrefixBGPStatusEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AddressingPrefixBGPStatusEditResponseEnvelope struct { - Errors []AddressingPrefixBGPStatusEditResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingPrefixBGPStatusEditResponseEnvelopeMessages `json:"messages,required"` - Result AddressingPrefixBGPStatusEditResponse `json:"result,required"` - // Whether the API call was successful - Success AddressingPrefixBGPStatusEditResponseEnvelopeSuccess `json:"success,required"` - JSON addressingPrefixBGPStatusEditResponseEnvelopeJSON `json:"-"` -} - -// addressingPrefixBGPStatusEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [AddressingPrefixBGPStatusEditResponseEnvelope] -type addressingPrefixBGPStatusEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPStatusEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPStatusEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPStatusEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixBGPStatusEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingPrefixBGPStatusEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPStatusEditResponseEnvelopeErrors] -type addressingPrefixBGPStatusEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPStatusEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPStatusEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPStatusEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixBGPStatusEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingPrefixBGPStatusEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPStatusEditResponseEnvelopeMessages] -type addressingPrefixBGPStatusEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPStatusEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPStatusEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingPrefixBGPStatusEditResponseEnvelopeSuccess bool - -const ( - AddressingPrefixBGPStatusEditResponseEnvelopeSuccessTrue AddressingPrefixBGPStatusEditResponseEnvelopeSuccess = true -) - -type AddressingPrefixBGPStatusGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingPrefixBGPStatusGetResponseEnvelope struct { - Errors []AddressingPrefixBGPStatusGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingPrefixBGPStatusGetResponseEnvelopeMessages `json:"messages,required"` - Result AddressingPrefixBGPStatusGetResponse `json:"result,required"` - // Whether the API call was successful - Success AddressingPrefixBGPStatusGetResponseEnvelopeSuccess `json:"success,required"` - JSON addressingPrefixBGPStatusGetResponseEnvelopeJSON `json:"-"` -} - -// addressingPrefixBGPStatusGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [AddressingPrefixBGPStatusGetResponseEnvelope] -type addressingPrefixBGPStatusGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPStatusGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPStatusGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPStatusGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixBGPStatusGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingPrefixBGPStatusGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPStatusGetResponseEnvelopeErrors] -type addressingPrefixBGPStatusGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPStatusGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPStatusGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixBGPStatusGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixBGPStatusGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingPrefixBGPStatusGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AddressingPrefixBGPStatusGetResponseEnvelopeMessages] -type addressingPrefixBGPStatusGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixBGPStatusGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixBGPStatusGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingPrefixBGPStatusGetResponseEnvelopeSuccess bool - -const ( - AddressingPrefixBGPStatusGetResponseEnvelopeSuccessTrue AddressingPrefixBGPStatusGetResponseEnvelopeSuccess = true -) diff --git a/addressingprefixbgpstatus_test.go b/addressingprefixbgpstatus_test.go deleted file mode 100644 index 90b7b0f95cc..00000000000 --- a/addressingprefixbgpstatus_test.go +++ /dev/null @@ -1,75 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAddressingPrefixBGPStatusEdit(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("user@example.com"), - ) - _, err := client.Addressing.Prefixes.BGP.Statuses.Edit( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingPrefixBGPStatusEditParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Advertised: cloudflare.F(true), - }, - ) - 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 TestAddressingPrefixBGPStatusGet(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("user@example.com"), - ) - _, err := client.Addressing.Prefixes.BGP.Statuses.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingPrefixBGPStatusGetParams{ - AccountID: cloudflare.F("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/addressingprefixdelegation.go b/addressingprefixdelegation.go deleted file mode 100644 index 77e61074654..00000000000 --- a/addressingprefixdelegation.go +++ /dev/null @@ -1,465 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// AddressingPrefixDelegationService 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 -// [NewAddressingPrefixDelegationService] method instead. -type AddressingPrefixDelegationService struct { - Options []option.RequestOption -} - -// NewAddressingPrefixDelegationService 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 NewAddressingPrefixDelegationService(opts ...option.RequestOption) (r *AddressingPrefixDelegationService) { - r = &AddressingPrefixDelegationService{} - r.Options = opts - return -} - -// Create a new account delegation for a given IP prefix. -func (r *AddressingPrefixDelegationService) New(ctx context.Context, prefixID string, params AddressingPrefixDelegationNewParams, opts ...option.RequestOption) (res *AddressingPrefixDelegationNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingPrefixDelegationNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/delegations", params.AccountID, prefixID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List all delegations for a given account IP prefix. -func (r *AddressingPrefixDelegationService) List(ctx context.Context, prefixID string, query AddressingPrefixDelegationListParams, opts ...option.RequestOption) (res *[]AddressingPrefixDelegationListResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingPrefixDelegationListResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/delegations", query.AccountID, prefixID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete an account delegation for a given IP prefix. -func (r *AddressingPrefixDelegationService) Delete(ctx context.Context, prefixID string, delegationID string, body AddressingPrefixDelegationDeleteParams, opts ...option.RequestOption) (res *AddressingPrefixDelegationDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingPrefixDelegationDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/prefixes/%s/delegations/%s", body.AccountID, prefixID, delegationID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type AddressingPrefixDelegationNewResponse struct { - // Delegation identifier tag. - ID string `json:"id"` - // IP Prefix in Classless Inter-Domain Routing format. - Cidr string `json:"cidr"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Account identifier for the account to which prefix is being delegated. - DelegatedAccountID string `json:"delegated_account_id"` - ModifiedAt time.Time `json:"modified_at" format:"date-time"` - // Identifier - ParentPrefixID string `json:"parent_prefix_id"` - JSON addressingPrefixDelegationNewResponseJSON `json:"-"` -} - -// addressingPrefixDelegationNewResponseJSON contains the JSON metadata for the -// struct [AddressingPrefixDelegationNewResponse] -type addressingPrefixDelegationNewResponseJSON struct { - ID apijson.Field - Cidr apijson.Field - CreatedAt apijson.Field - DelegatedAccountID apijson.Field - ModifiedAt apijson.Field - ParentPrefixID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixDelegationNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixDelegationNewResponseJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixDelegationListResponse struct { - // Delegation identifier tag. - ID string `json:"id"` - // IP Prefix in Classless Inter-Domain Routing format. - Cidr string `json:"cidr"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Account identifier for the account to which prefix is being delegated. - DelegatedAccountID string `json:"delegated_account_id"` - ModifiedAt time.Time `json:"modified_at" format:"date-time"` - // Identifier - ParentPrefixID string `json:"parent_prefix_id"` - JSON addressingPrefixDelegationListResponseJSON `json:"-"` -} - -// addressingPrefixDelegationListResponseJSON contains the JSON metadata for the -// struct [AddressingPrefixDelegationListResponse] -type addressingPrefixDelegationListResponseJSON struct { - ID apijson.Field - Cidr apijson.Field - CreatedAt apijson.Field - DelegatedAccountID apijson.Field - ModifiedAt apijson.Field - ParentPrefixID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixDelegationListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixDelegationListResponseJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixDelegationDeleteResponse struct { - // Delegation identifier tag. - ID string `json:"id"` - JSON addressingPrefixDelegationDeleteResponseJSON `json:"-"` -} - -// addressingPrefixDelegationDeleteResponseJSON contains the JSON metadata for the -// struct [AddressingPrefixDelegationDeleteResponse] -type addressingPrefixDelegationDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixDelegationDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixDelegationDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixDelegationNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // IP Prefix in Classless Inter-Domain Routing format. - Cidr param.Field[string] `json:"cidr,required"` - // Account identifier for the account to which prefix is being delegated. - DelegatedAccountID param.Field[string] `json:"delegated_account_id,required"` -} - -func (r AddressingPrefixDelegationNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AddressingPrefixDelegationNewResponseEnvelope struct { - Errors []AddressingPrefixDelegationNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingPrefixDelegationNewResponseEnvelopeMessages `json:"messages,required"` - Result AddressingPrefixDelegationNewResponse `json:"result,required"` - // Whether the API call was successful - Success AddressingPrefixDelegationNewResponseEnvelopeSuccess `json:"success,required"` - JSON addressingPrefixDelegationNewResponseEnvelopeJSON `json:"-"` -} - -// addressingPrefixDelegationNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [AddressingPrefixDelegationNewResponseEnvelope] -type addressingPrefixDelegationNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixDelegationNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixDelegationNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixDelegationNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixDelegationNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingPrefixDelegationNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AddressingPrefixDelegationNewResponseEnvelopeErrors] -type addressingPrefixDelegationNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixDelegationNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixDelegationNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixDelegationNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixDelegationNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingPrefixDelegationNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AddressingPrefixDelegationNewResponseEnvelopeMessages] -type addressingPrefixDelegationNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixDelegationNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixDelegationNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingPrefixDelegationNewResponseEnvelopeSuccess bool - -const ( - AddressingPrefixDelegationNewResponseEnvelopeSuccessTrue AddressingPrefixDelegationNewResponseEnvelopeSuccess = true -) - -type AddressingPrefixDelegationListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingPrefixDelegationListResponseEnvelope struct { - Errors []AddressingPrefixDelegationListResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingPrefixDelegationListResponseEnvelopeMessages `json:"messages,required"` - Result []AddressingPrefixDelegationListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AddressingPrefixDelegationListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AddressingPrefixDelegationListResponseEnvelopeResultInfo `json:"result_info"` - JSON addressingPrefixDelegationListResponseEnvelopeJSON `json:"-"` -} - -// addressingPrefixDelegationListResponseEnvelopeJSON contains the JSON metadata -// for the struct [AddressingPrefixDelegationListResponseEnvelope] -type addressingPrefixDelegationListResponseEnvelopeJSON 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 *AddressingPrefixDelegationListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixDelegationListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixDelegationListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixDelegationListResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingPrefixDelegationListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AddressingPrefixDelegationListResponseEnvelopeErrors] -type addressingPrefixDelegationListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixDelegationListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixDelegationListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixDelegationListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixDelegationListResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingPrefixDelegationListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [AddressingPrefixDelegationListResponseEnvelopeMessages] -type addressingPrefixDelegationListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixDelegationListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixDelegationListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingPrefixDelegationListResponseEnvelopeSuccess bool - -const ( - AddressingPrefixDelegationListResponseEnvelopeSuccessTrue AddressingPrefixDelegationListResponseEnvelopeSuccess = true -) - -type AddressingPrefixDelegationListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON addressingPrefixDelegationListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// addressingPrefixDelegationListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [AddressingPrefixDelegationListResponseEnvelopeResultInfo] -type addressingPrefixDelegationListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixDelegationListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixDelegationListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixDelegationDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingPrefixDelegationDeleteResponseEnvelope struct { - Errors []AddressingPrefixDelegationDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingPrefixDelegationDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AddressingPrefixDelegationDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success AddressingPrefixDelegationDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON addressingPrefixDelegationDeleteResponseEnvelopeJSON `json:"-"` -} - -// addressingPrefixDelegationDeleteResponseEnvelopeJSON contains the JSON metadata -// for the struct [AddressingPrefixDelegationDeleteResponseEnvelope] -type addressingPrefixDelegationDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixDelegationDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixDelegationDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixDelegationDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixDelegationDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingPrefixDelegationDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AddressingPrefixDelegationDeleteResponseEnvelopeErrors] -type addressingPrefixDelegationDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixDelegationDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixDelegationDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingPrefixDelegationDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingPrefixDelegationDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingPrefixDelegationDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [AddressingPrefixDelegationDeleteResponseEnvelopeMessages] -type addressingPrefixDelegationDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingPrefixDelegationDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingPrefixDelegationDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingPrefixDelegationDeleteResponseEnvelopeSuccess bool - -const ( - AddressingPrefixDelegationDeleteResponseEnvelopeSuccessTrue AddressingPrefixDelegationDeleteResponseEnvelopeSuccess = true -) diff --git a/addressingprefixdelegation_test.go b/addressingprefixdelegation_test.go deleted file mode 100644 index 81793b79b65..00000000000 --- a/addressingprefixdelegation_test.go +++ /dev/null @@ -1,107 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAddressingPrefixDelegationNew(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("user@example.com"), - ) - _, err := client.Addressing.Prefixes.Delegations.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingPrefixDelegationNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Cidr: cloudflare.F("192.0.2.0/24"), - DelegatedAccountID: cloudflare.F("b1946ac92492d2347c6235b4d2611184"), - }, - ) - 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 TestAddressingPrefixDelegationList(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("user@example.com"), - ) - _, err := client.Addressing.Prefixes.Delegations.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AddressingPrefixDelegationListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestAddressingPrefixDelegationDelete(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("user@example.com"), - ) - _, err := client.Addressing.Prefixes.Delegations.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "d933b1530bc56c9953cf8ce166da8004", - cloudflare.AddressingPrefixDelegationDeleteParams{ - AccountID: cloudflare.F("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/addressingservice.go b/addressingservice.go deleted file mode 100644 index d99a20e7959..00000000000 --- a/addressingservice.go +++ /dev/null @@ -1,159 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// AddressingServiceService 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 [NewAddressingServiceService] method -// instead. -type AddressingServiceService struct { - Options []option.RequestOption -} - -// NewAddressingServiceService 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 NewAddressingServiceService(opts ...option.RequestOption) (r *AddressingServiceService) { - r = &AddressingServiceService{} - r.Options = opts - return -} - -// Bring-Your-Own IP (BYOIP) prefixes onboarded to Cloudflare must be bound to a -// service running on the Cloudflare network to enable a Cloudflare product on the -// IP addresses. This endpoint can be used as a reference of available services on -// the Cloudflare network, and their service IDs. -func (r *AddressingServiceService) List(ctx context.Context, query AddressingServiceListParams, opts ...option.RequestOption) (res *[]AddressingServiceListResponse, err error) { - opts = append(r.Options[:], opts...) - var env AddressingServiceListResponseEnvelope - path := fmt.Sprintf("accounts/%s/addressing/services", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type AddressingServiceListResponse struct { - // Identifier - ID string `json:"id"` - // Name of a service running on the Cloudflare network - Name string `json:"name"` - JSON addressingServiceListResponseJSON `json:"-"` -} - -// addressingServiceListResponseJSON contains the JSON metadata for the struct -// [AddressingServiceListResponse] -type addressingServiceListResponseJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingServiceListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingServiceListResponseJSON) RawJSON() string { - return r.raw -} - -type AddressingServiceListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type AddressingServiceListResponseEnvelope struct { - Errors []AddressingServiceListResponseEnvelopeErrors `json:"errors,required"` - Messages []AddressingServiceListResponseEnvelopeMessages `json:"messages,required"` - Result []AddressingServiceListResponse `json:"result,required"` - // Whether the API call was successful - Success AddressingServiceListResponseEnvelopeSuccess `json:"success,required"` - JSON addressingServiceListResponseEnvelopeJSON `json:"-"` -} - -// addressingServiceListResponseEnvelopeJSON contains the JSON metadata for the -// struct [AddressingServiceListResponseEnvelope] -type addressingServiceListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingServiceListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingServiceListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AddressingServiceListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingServiceListResponseEnvelopeErrorsJSON `json:"-"` -} - -// addressingServiceListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AddressingServiceListResponseEnvelopeErrors] -type addressingServiceListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingServiceListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingServiceListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AddressingServiceListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON addressingServiceListResponseEnvelopeMessagesJSON `json:"-"` -} - -// addressingServiceListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AddressingServiceListResponseEnvelopeMessages] -type addressingServiceListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressingServiceListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressingServiceListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AddressingServiceListResponseEnvelopeSuccess bool - -const ( - AddressingServiceListResponseEnvelopeSuccessTrue AddressingServiceListResponseEnvelopeSuccess = true -) diff --git a/addressingservice_test.go b/addressingservice_test.go deleted file mode 100644 index 0a6756bd4d3..00000000000 --- a/addressingservice_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAddressingServiceList(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("user@example.com"), - ) - _, err := client.Addressing.Services.List(context.TODO(), cloudflare.AddressingServiceListParams{ - AccountID: cloudflare.F("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/alerting.go b/alerting/alerting.go similarity index 90% rename from alerting.go rename to alerting/alerting.go index 797893e83c3..b52281c930e 100644 --- a/alerting.go +++ b/alerting/alerting.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package alerting import ( "github.com/cloudflare/cloudflare-go/option" @@ -12,7 +12,7 @@ import ( // service directly, and instead use the [NewAlertingService] method instead. type AlertingService struct { Options []option.RequestOption - V3 *AlertingV3Service + V3 *V3Service } // NewAlertingService generates a new service that applies the given options to @@ -21,6 +21,6 @@ type AlertingService struct { func NewAlertingService(opts ...option.RequestOption) (r *AlertingService) { r = &AlertingService{} r.Options = opts - r.V3 = NewAlertingV3Service(opts...) + r.V3 = NewV3Service(opts...) return } diff --git a/alerting/aliases.go b/alerting/aliases.go new file mode 100644 index 00000000000..f48faf077eb --- /dev/null +++ b/alerting/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package alerting + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/alerting/v3.go b/alerting/v3.go new file mode 100644 index 00000000000..d0d7c72cd43 --- /dev/null +++ b/alerting/v3.go @@ -0,0 +1,197 @@ +// File generated from our OpenAPI spec by Stainless. + +package alerting + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// V3Service 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 [NewV3Service] method instead. +type V3Service struct { + Options []option.RequestOption + Destinations *V3DestinationService + Histories *V3HistoryService + Policies *V3PolicyService +} + +// NewV3Service 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 NewV3Service(opts ...option.RequestOption) (r *V3Service) { + r = &V3Service{} + r.Options = opts + r.Destinations = NewV3DestinationService(opts...) + r.Histories = NewV3HistoryService(opts...) + r.Policies = NewV3PolicyService(opts...) + return +} + +// Gets a list of all alert types for which an account is eligible. +func (r *V3Service) List(ctx context.Context, query V3ListParams, opts ...option.RequestOption) (res *V3ListResponse, err error) { + opts = append(r.Options[:], opts...) + var env V3ListResponseEnvelope + path := fmt.Sprintf("accounts/%s/alerting/v3/available_alerts", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [alerting.V3ListResponseUnknown], +// [alerting.V3ListResponseArray] or [shared.UnionString]. +type V3ListResponse interface { + ImplementsAlertingV3ListResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*V3ListResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(V3ListResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type V3ListResponseArray []interface{} + +func (r V3ListResponseArray) ImplementsAlertingV3ListResponse() {} + +type V3ListParams struct { + // The account id + AccountID param.Field[string] `path:"account_id,required"` +} + +type V3ListResponseEnvelope struct { + Errors []V3ListResponseEnvelopeErrors `json:"errors,required"` + Messages []V3ListResponseEnvelopeMessages `json:"messages,required"` + Result V3ListResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success V3ListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo V3ListResponseEnvelopeResultInfo `json:"result_info"` + JSON v3ListResponseEnvelopeJSON `json:"-"` +} + +// v3ListResponseEnvelopeJSON contains the JSON metadata for the struct +// [V3ListResponseEnvelope] +type v3ListResponseEnvelopeJSON 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 *V3ListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3ListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V3ListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3ListResponseEnvelopeErrorsJSON `json:"-"` +} + +// v3ListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [V3ListResponseEnvelopeErrors] +type v3ListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3ListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3ListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V3ListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3ListResponseEnvelopeMessagesJSON `json:"-"` +} + +// v3ListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [V3ListResponseEnvelopeMessages] +type v3ListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3ListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3ListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V3ListResponseEnvelopeSuccess bool + +const ( + V3ListResponseEnvelopeSuccessTrue V3ListResponseEnvelopeSuccess = true +) + +type V3ListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON v3ListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// v3ListResponseEnvelopeResultInfoJSON contains the JSON metadata for the struct +// [V3ListResponseEnvelopeResultInfo] +type v3ListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3ListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3ListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/alerting/v3_test.go b/alerting/v3_test.go new file mode 100644 index 00000000000..3b5ee639db2 --- /dev/null +++ b/alerting/v3_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package alerting_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/alerting" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestV3List(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("user@example.com"), + ) + _, err := client.Alerting.V3.List(context.TODO(), alerting.V3ListParams{ + AccountID: cloudflare.F("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/alerting/v3destination.go b/alerting/v3destination.go new file mode 100644 index 00000000000..3541a59f431 --- /dev/null +++ b/alerting/v3destination.go @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package alerting + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// V3DestinationService 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 [NewV3DestinationService] method +// instead. +type V3DestinationService struct { + Options []option.RequestOption + Eligible *V3DestinationEligibleService + Pagerduty *V3DestinationPagerdutyService + Webhooks *V3DestinationWebhookService +} + +// NewV3DestinationService 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 NewV3DestinationService(opts ...option.RequestOption) (r *V3DestinationService) { + r = &V3DestinationService{} + r.Options = opts + r.Eligible = NewV3DestinationEligibleService(opts...) + r.Pagerduty = NewV3DestinationPagerdutyService(opts...) + r.Webhooks = NewV3DestinationWebhookService(opts...) + return +} diff --git a/alerting/v3destinationeligible.go b/alerting/v3destinationeligible.go new file mode 100644 index 00000000000..193352f8cee --- /dev/null +++ b/alerting/v3destinationeligible.go @@ -0,0 +1,192 @@ +// File generated from our OpenAPI spec by Stainless. + +package alerting + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// V3DestinationEligibleService 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 [NewV3DestinationEligibleService] +// method instead. +type V3DestinationEligibleService struct { + Options []option.RequestOption +} + +// NewV3DestinationEligibleService 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 NewV3DestinationEligibleService(opts ...option.RequestOption) (r *V3DestinationEligibleService) { + r = &V3DestinationEligibleService{} + r.Options = opts + return +} + +// Get a list of all delivery mechanism types for which an account is eligible. +func (r *V3DestinationEligibleService) Get(ctx context.Context, query V3DestinationEligibleGetParams, opts ...option.RequestOption) (res *V3DestinationEligibleGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env V3DestinationEligibleGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/eligible", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [alerting.V3DestinationEligibleGetResponseUnknown], +// [alerting.V3DestinationEligibleGetResponseArray] or [shared.UnionString]. +type V3DestinationEligibleGetResponse interface { + ImplementsAlertingV3DestinationEligibleGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*V3DestinationEligibleGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(V3DestinationEligibleGetResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type V3DestinationEligibleGetResponseArray []interface{} + +func (r V3DestinationEligibleGetResponseArray) ImplementsAlertingV3DestinationEligibleGetResponse() {} + +type V3DestinationEligibleGetParams struct { + // The account id + AccountID param.Field[string] `path:"account_id,required"` +} + +type V3DestinationEligibleGetResponseEnvelope struct { + Errors []V3DestinationEligibleGetResponseEnvelopeErrors `json:"errors,required"` + Messages []V3DestinationEligibleGetResponseEnvelopeMessages `json:"messages,required"` + Result V3DestinationEligibleGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success V3DestinationEligibleGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo V3DestinationEligibleGetResponseEnvelopeResultInfo `json:"result_info"` + JSON v3DestinationEligibleGetResponseEnvelopeJSON `json:"-"` +} + +// v3DestinationEligibleGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [V3DestinationEligibleGetResponseEnvelope] +type v3DestinationEligibleGetResponseEnvelopeJSON 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 *V3DestinationEligibleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationEligibleGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V3DestinationEligibleGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationEligibleGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// v3DestinationEligibleGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [V3DestinationEligibleGetResponseEnvelopeErrors] +type v3DestinationEligibleGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationEligibleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationEligibleGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V3DestinationEligibleGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationEligibleGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// v3DestinationEligibleGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [V3DestinationEligibleGetResponseEnvelopeMessages] +type v3DestinationEligibleGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationEligibleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationEligibleGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V3DestinationEligibleGetResponseEnvelopeSuccess bool + +const ( + V3DestinationEligibleGetResponseEnvelopeSuccessTrue V3DestinationEligibleGetResponseEnvelopeSuccess = true +) + +type V3DestinationEligibleGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON v3DestinationEligibleGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// v3DestinationEligibleGetResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [V3DestinationEligibleGetResponseEnvelopeResultInfo] +type v3DestinationEligibleGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationEligibleGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationEligibleGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/alerting/v3destinationeligible_test.go b/alerting/v3destinationeligible_test.go new file mode 100644 index 00000000000..1d41c7d3e44 --- /dev/null +++ b/alerting/v3destinationeligible_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package alerting_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/alerting" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestV3DestinationEligibleGet(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("user@example.com"), + ) + _, err := client.Alerting.V3.Destinations.Eligible.Get(context.TODO(), alerting.V3DestinationEligibleGetParams{ + AccountID: cloudflare.F("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/alerting/v3destinationpagerduty.go b/alerting/v3destinationpagerduty.go new file mode 100644 index 00000000000..5744cf8dc23 --- /dev/null +++ b/alerting/v3destinationpagerduty.go @@ -0,0 +1,591 @@ +// File generated from our OpenAPI spec by Stainless. + +package alerting + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// V3DestinationPagerdutyService 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 [NewV3DestinationPagerdutyService] +// method instead. +type V3DestinationPagerdutyService struct { + Options []option.RequestOption +} + +// NewV3DestinationPagerdutyService 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 NewV3DestinationPagerdutyService(opts ...option.RequestOption) (r *V3DestinationPagerdutyService) { + r = &V3DestinationPagerdutyService{} + r.Options = opts + return +} + +// Creates a new token for integrating with PagerDuty. +func (r *V3DestinationPagerdutyService) New(ctx context.Context, body V3DestinationPagerdutyNewParams, opts ...option.RequestOption) (res *V3DestinationPagerdutyNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env V3DestinationPagerdutyNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/pagerduty/connect", body.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes all the PagerDuty Services connected to the account. +func (r *V3DestinationPagerdutyService) Delete(ctx context.Context, body V3DestinationPagerdutyDeleteParams, opts ...option.RequestOption) (res *V3DestinationPagerdutyDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env V3DestinationPagerdutyDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/pagerduty", body.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a list of all configured PagerDuty services. +func (r *V3DestinationPagerdutyService) Get(ctx context.Context, query V3DestinationPagerdutyGetParams, opts ...option.RequestOption) (res *[]AaaPagerduty, err error) { + opts = append(r.Options[:], opts...) + var env V3DestinationPagerdutyGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/pagerduty", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Links PagerDuty with the account using the integration token. +func (r *V3DestinationPagerdutyService) Link(ctx context.Context, tokenID string, query V3DestinationPagerdutyLinkParams, opts ...option.RequestOption) (res *V3DestinationPagerdutyLinkResponse, err error) { + opts = append(r.Options[:], opts...) + var env V3DestinationPagerdutyLinkResponseEnvelope + path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/pagerduty/connect/%s", query.AccountID, tokenID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AaaPagerduty struct { + // UUID + ID string `json:"id"` + // The name of the pagerduty service. + Name string `json:"name"` + JSON aaaPagerdutyJSON `json:"-"` +} + +// aaaPagerdutyJSON contains the JSON metadata for the struct [AaaPagerduty] +type aaaPagerdutyJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AaaPagerduty) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aaaPagerdutyJSON) RawJSON() string { + return r.raw +} + +type V3DestinationPagerdutyNewResponse struct { + // UUID + ID string `json:"id"` + JSON v3DestinationPagerdutyNewResponseJSON `json:"-"` +} + +// v3DestinationPagerdutyNewResponseJSON contains the JSON metadata for the struct +// [V3DestinationPagerdutyNewResponse] +type v3DestinationPagerdutyNewResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationPagerdutyNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationPagerdutyNewResponseJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [alerting.V3DestinationPagerdutyDeleteResponseUnknown], +// [alerting.V3DestinationPagerdutyDeleteResponseArray] or [shared.UnionString]. +type V3DestinationPagerdutyDeleteResponse interface { + ImplementsAlertingV3DestinationPagerdutyDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*V3DestinationPagerdutyDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(V3DestinationPagerdutyDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type V3DestinationPagerdutyDeleteResponseArray []interface{} + +func (r V3DestinationPagerdutyDeleteResponseArray) ImplementsAlertingV3DestinationPagerdutyDeleteResponse() { +} + +type V3DestinationPagerdutyLinkResponse struct { + // UUID + ID string `json:"id"` + JSON v3DestinationPagerdutyLinkResponseJSON `json:"-"` +} + +// v3DestinationPagerdutyLinkResponseJSON contains the JSON metadata for the struct +// [V3DestinationPagerdutyLinkResponse] +type v3DestinationPagerdutyLinkResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationPagerdutyLinkResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationPagerdutyLinkResponseJSON) RawJSON() string { + return r.raw +} + +type V3DestinationPagerdutyNewParams struct { + // The account id + AccountID param.Field[string] `path:"account_id,required"` +} + +type V3DestinationPagerdutyNewResponseEnvelope struct { + Errors []V3DestinationPagerdutyNewResponseEnvelopeErrors `json:"errors,required"` + Messages []V3DestinationPagerdutyNewResponseEnvelopeMessages `json:"messages,required"` + Result V3DestinationPagerdutyNewResponse `json:"result,required"` + // Whether the API call was successful + Success V3DestinationPagerdutyNewResponseEnvelopeSuccess `json:"success,required"` + JSON v3DestinationPagerdutyNewResponseEnvelopeJSON `json:"-"` +} + +// v3DestinationPagerdutyNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [V3DestinationPagerdutyNewResponseEnvelope] +type v3DestinationPagerdutyNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationPagerdutyNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationPagerdutyNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V3DestinationPagerdutyNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationPagerdutyNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// v3DestinationPagerdutyNewResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [V3DestinationPagerdutyNewResponseEnvelopeErrors] +type v3DestinationPagerdutyNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationPagerdutyNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationPagerdutyNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V3DestinationPagerdutyNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationPagerdutyNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// v3DestinationPagerdutyNewResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [V3DestinationPagerdutyNewResponseEnvelopeMessages] +type v3DestinationPagerdutyNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationPagerdutyNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationPagerdutyNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V3DestinationPagerdutyNewResponseEnvelopeSuccess bool + +const ( + V3DestinationPagerdutyNewResponseEnvelopeSuccessTrue V3DestinationPagerdutyNewResponseEnvelopeSuccess = true +) + +type V3DestinationPagerdutyDeleteParams struct { + // The account id + AccountID param.Field[string] `path:"account_id,required"` +} + +type V3DestinationPagerdutyDeleteResponseEnvelope struct { + Errors []V3DestinationPagerdutyDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []V3DestinationPagerdutyDeleteResponseEnvelopeMessages `json:"messages,required"` + Result V3DestinationPagerdutyDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success V3DestinationPagerdutyDeleteResponseEnvelopeSuccess `json:"success,required"` + ResultInfo V3DestinationPagerdutyDeleteResponseEnvelopeResultInfo `json:"result_info"` + JSON v3DestinationPagerdutyDeleteResponseEnvelopeJSON `json:"-"` +} + +// v3DestinationPagerdutyDeleteResponseEnvelopeJSON contains the JSON metadata for +// the struct [V3DestinationPagerdutyDeleteResponseEnvelope] +type v3DestinationPagerdutyDeleteResponseEnvelopeJSON 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 *V3DestinationPagerdutyDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationPagerdutyDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V3DestinationPagerdutyDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationPagerdutyDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// v3DestinationPagerdutyDeleteResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [V3DestinationPagerdutyDeleteResponseEnvelopeErrors] +type v3DestinationPagerdutyDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationPagerdutyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationPagerdutyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V3DestinationPagerdutyDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationPagerdutyDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// v3DestinationPagerdutyDeleteResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [V3DestinationPagerdutyDeleteResponseEnvelopeMessages] +type v3DestinationPagerdutyDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationPagerdutyDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationPagerdutyDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V3DestinationPagerdutyDeleteResponseEnvelopeSuccess bool + +const ( + V3DestinationPagerdutyDeleteResponseEnvelopeSuccessTrue V3DestinationPagerdutyDeleteResponseEnvelopeSuccess = true +) + +type V3DestinationPagerdutyDeleteResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON v3DestinationPagerdutyDeleteResponseEnvelopeResultInfoJSON `json:"-"` +} + +// v3DestinationPagerdutyDeleteResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [V3DestinationPagerdutyDeleteResponseEnvelopeResultInfo] +type v3DestinationPagerdutyDeleteResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationPagerdutyDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationPagerdutyDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type V3DestinationPagerdutyGetParams struct { + // The account id + AccountID param.Field[string] `path:"account_id,required"` +} + +type V3DestinationPagerdutyGetResponseEnvelope struct { + Errors []V3DestinationPagerdutyGetResponseEnvelopeErrors `json:"errors,required"` + Messages []V3DestinationPagerdutyGetResponseEnvelopeMessages `json:"messages,required"` + Result []AaaPagerduty `json:"result,required,nullable"` + // Whether the API call was successful + Success V3DestinationPagerdutyGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo V3DestinationPagerdutyGetResponseEnvelopeResultInfo `json:"result_info"` + JSON v3DestinationPagerdutyGetResponseEnvelopeJSON `json:"-"` +} + +// v3DestinationPagerdutyGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [V3DestinationPagerdutyGetResponseEnvelope] +type v3DestinationPagerdutyGetResponseEnvelopeJSON 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 *V3DestinationPagerdutyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationPagerdutyGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V3DestinationPagerdutyGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationPagerdutyGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// v3DestinationPagerdutyGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [V3DestinationPagerdutyGetResponseEnvelopeErrors] +type v3DestinationPagerdutyGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationPagerdutyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationPagerdutyGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V3DestinationPagerdutyGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationPagerdutyGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// v3DestinationPagerdutyGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [V3DestinationPagerdutyGetResponseEnvelopeMessages] +type v3DestinationPagerdutyGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationPagerdutyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationPagerdutyGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V3DestinationPagerdutyGetResponseEnvelopeSuccess bool + +const ( + V3DestinationPagerdutyGetResponseEnvelopeSuccessTrue V3DestinationPagerdutyGetResponseEnvelopeSuccess = true +) + +type V3DestinationPagerdutyGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON v3DestinationPagerdutyGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// v3DestinationPagerdutyGetResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [V3DestinationPagerdutyGetResponseEnvelopeResultInfo] +type v3DestinationPagerdutyGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationPagerdutyGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationPagerdutyGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type V3DestinationPagerdutyLinkParams struct { + // The account id + AccountID param.Field[string] `path:"account_id,required"` +} + +type V3DestinationPagerdutyLinkResponseEnvelope struct { + Errors []V3DestinationPagerdutyLinkResponseEnvelopeErrors `json:"errors,required"` + Messages []V3DestinationPagerdutyLinkResponseEnvelopeMessages `json:"messages,required"` + Result V3DestinationPagerdutyLinkResponse `json:"result,required"` + // Whether the API call was successful + Success V3DestinationPagerdutyLinkResponseEnvelopeSuccess `json:"success,required"` + JSON v3DestinationPagerdutyLinkResponseEnvelopeJSON `json:"-"` +} + +// v3DestinationPagerdutyLinkResponseEnvelopeJSON contains the JSON metadata for +// the struct [V3DestinationPagerdutyLinkResponseEnvelope] +type v3DestinationPagerdutyLinkResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationPagerdutyLinkResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationPagerdutyLinkResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V3DestinationPagerdutyLinkResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationPagerdutyLinkResponseEnvelopeErrorsJSON `json:"-"` +} + +// v3DestinationPagerdutyLinkResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [V3DestinationPagerdutyLinkResponseEnvelopeErrors] +type v3DestinationPagerdutyLinkResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationPagerdutyLinkResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationPagerdutyLinkResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V3DestinationPagerdutyLinkResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationPagerdutyLinkResponseEnvelopeMessagesJSON `json:"-"` +} + +// v3DestinationPagerdutyLinkResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [V3DestinationPagerdutyLinkResponseEnvelopeMessages] +type v3DestinationPagerdutyLinkResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationPagerdutyLinkResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationPagerdutyLinkResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V3DestinationPagerdutyLinkResponseEnvelopeSuccess bool + +const ( + V3DestinationPagerdutyLinkResponseEnvelopeSuccessTrue V3DestinationPagerdutyLinkResponseEnvelopeSuccess = true +) diff --git a/alerting/v3destinationpagerduty_test.go b/alerting/v3destinationpagerduty_test.go new file mode 100644 index 00000000000..31c73015771 --- /dev/null +++ b/alerting/v3destinationpagerduty_test.go @@ -0,0 +1,123 @@ +// File generated from our OpenAPI spec by Stainless. + +package alerting_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/alerting" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestV3DestinationPagerdutyNew(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("user@example.com"), + ) + _, err := client.Alerting.V3.Destinations.Pagerduty.New(context.TODO(), alerting.V3DestinationPagerdutyNewParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestV3DestinationPagerdutyDelete(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("user@example.com"), + ) + _, err := client.Alerting.V3.Destinations.Pagerduty.Delete(context.TODO(), alerting.V3DestinationPagerdutyDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestV3DestinationPagerdutyGet(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("user@example.com"), + ) + _, err := client.Alerting.V3.Destinations.Pagerduty.Get(context.TODO(), alerting.V3DestinationPagerdutyGetParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestV3DestinationPagerdutyLink(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("user@example.com"), + ) + _, err := client.Alerting.V3.Destinations.Pagerduty.Link( + context.TODO(), + "8c71e667571b4f61b94d9e4b12158038", + alerting.V3DestinationPagerdutyLinkParams{ + AccountID: cloudflare.F("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/alerting/v3destinationwebhook.go b/alerting/v3destinationwebhook.go new file mode 100644 index 00000000000..9bfe5d9ac98 --- /dev/null +++ b/alerting/v3destinationwebhook.go @@ -0,0 +1,749 @@ +// File generated from our OpenAPI spec by Stainless. + +package alerting + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// V3DestinationWebhookService 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 [NewV3DestinationWebhookService] +// method instead. +type V3DestinationWebhookService struct { + Options []option.RequestOption +} + +// NewV3DestinationWebhookService 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 NewV3DestinationWebhookService(opts ...option.RequestOption) (r *V3DestinationWebhookService) { + r = &V3DestinationWebhookService{} + r.Options = opts + return +} + +// Creates a new webhook destination. +func (r *V3DestinationWebhookService) New(ctx context.Context, params V3DestinationWebhookNewParams, opts ...option.RequestOption) (res *V3DestinationWebhookNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env V3DestinationWebhookNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/webhooks", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update a webhook destination. +func (r *V3DestinationWebhookService) Update(ctx context.Context, webhookID string, params V3DestinationWebhookUpdateParams, opts ...option.RequestOption) (res *V3DestinationWebhookUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env V3DestinationWebhookUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/webhooks/%s", params.AccountID, webhookID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets a list of all configured webhook destinations. +func (r *V3DestinationWebhookService) List(ctx context.Context, query V3DestinationWebhookListParams, opts ...option.RequestOption) (res *[]AaaWebhooks, err error) { + opts = append(r.Options[:], opts...) + var env V3DestinationWebhookListResponseEnvelope + path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/webhooks", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a configured webhook destination. +func (r *V3DestinationWebhookService) Delete(ctx context.Context, webhookID string, body V3DestinationWebhookDeleteParams, opts ...option.RequestOption) (res *V3DestinationWebhookDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env V3DestinationWebhookDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/webhooks/%s", body.AccountID, webhookID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get details for a single webhooks destination. +func (r *V3DestinationWebhookService) Get(ctx context.Context, webhookID string, query V3DestinationWebhookGetParams, opts ...option.RequestOption) (res *AaaWebhooks, err error) { + opts = append(r.Options[:], opts...) + var env V3DestinationWebhookGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/webhooks/%s", query.AccountID, webhookID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AaaWebhooks struct { + // The unique identifier of a webhook + ID string `json:"id"` + // Timestamp of when the webhook destination was created. + CreatedAt time.Time `json:"created_at" format:"date-time"` + // Timestamp of the last time an attempt to dispatch a notification to this webhook + // failed. + LastFailure time.Time `json:"last_failure" format:"date-time"` + // Timestamp of the last time Cloudflare was able to successfully dispatch a + // notification using this webhook. + LastSuccess time.Time `json:"last_success" format:"date-time"` + // The name of the webhook destination. This will be included in the request body + // when you receive a webhook notification. + Name string `json:"name"` + // Optional secret that will be passed in the `cf-webhook-auth` header when + // dispatching generic webhook notifications or formatted for supported + // destinations. Secrets are not returned in any API response body. + Secret string `json:"secret"` + // Type of webhook endpoint. + Type AaaWebhooksType `json:"type"` + // The POST endpoint to call when dispatching a notification. + URL string `json:"url"` + JSON aaaWebhooksJSON `json:"-"` +} + +// aaaWebhooksJSON contains the JSON metadata for the struct [AaaWebhooks] +type aaaWebhooksJSON struct { + ID apijson.Field + CreatedAt apijson.Field + LastFailure apijson.Field + LastSuccess apijson.Field + Name apijson.Field + Secret apijson.Field + Type apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AaaWebhooks) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aaaWebhooksJSON) RawJSON() string { + return r.raw +} + +// Type of webhook endpoint. +type AaaWebhooksType string + +const ( + AaaWebhooksTypeSlack AaaWebhooksType = "slack" + AaaWebhooksTypeGeneric AaaWebhooksType = "generic" + AaaWebhooksTypeGchat AaaWebhooksType = "gchat" +) + +type V3DestinationWebhookNewResponse struct { + // UUID + ID string `json:"id"` + JSON v3DestinationWebhookNewResponseJSON `json:"-"` +} + +// v3DestinationWebhookNewResponseJSON contains the JSON metadata for the struct +// [V3DestinationWebhookNewResponse] +type v3DestinationWebhookNewResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationWebhookNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookNewResponseJSON) RawJSON() string { + return r.raw +} + +type V3DestinationWebhookUpdateResponse struct { + // UUID + ID string `json:"id"` + JSON v3DestinationWebhookUpdateResponseJSON `json:"-"` +} + +// v3DestinationWebhookUpdateResponseJSON contains the JSON metadata for the struct +// [V3DestinationWebhookUpdateResponse] +type v3DestinationWebhookUpdateResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationWebhookUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookUpdateResponseJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [alerting.V3DestinationWebhookDeleteResponseUnknown], +// [alerting.V3DestinationWebhookDeleteResponseArray] or [shared.UnionString]. +type V3DestinationWebhookDeleteResponse interface { + ImplementsAlertingV3DestinationWebhookDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*V3DestinationWebhookDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(V3DestinationWebhookDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type V3DestinationWebhookDeleteResponseArray []interface{} + +func (r V3DestinationWebhookDeleteResponseArray) ImplementsAlertingV3DestinationWebhookDeleteResponse() { +} + +type V3DestinationWebhookNewParams struct { + // The account id + AccountID param.Field[string] `path:"account_id,required"` + // The name of the webhook destination. This will be included in the request body + // when you receive a webhook notification. + Name param.Field[string] `json:"name,required"` + // The POST endpoint to call when dispatching a notification. + URL param.Field[string] `json:"url,required"` + // Optional secret that will be passed in the `cf-webhook-auth` header when + // dispatching generic webhook notifications or formatted for supported + // destinations. Secrets are not returned in any API response body. + Secret param.Field[string] `json:"secret"` +} + +func (r V3DestinationWebhookNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type V3DestinationWebhookNewResponseEnvelope struct { + Errors []V3DestinationWebhookNewResponseEnvelopeErrors `json:"errors,required"` + Messages []V3DestinationWebhookNewResponseEnvelopeMessages `json:"messages,required"` + Result V3DestinationWebhookNewResponse `json:"result,required"` + // Whether the API call was successful + Success V3DestinationWebhookNewResponseEnvelopeSuccess `json:"success,required"` + JSON v3DestinationWebhookNewResponseEnvelopeJSON `json:"-"` +} + +// v3DestinationWebhookNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [V3DestinationWebhookNewResponseEnvelope] +type v3DestinationWebhookNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationWebhookNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V3DestinationWebhookNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationWebhookNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// v3DestinationWebhookNewResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [V3DestinationWebhookNewResponseEnvelopeErrors] +type v3DestinationWebhookNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationWebhookNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V3DestinationWebhookNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationWebhookNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// v3DestinationWebhookNewResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [V3DestinationWebhookNewResponseEnvelopeMessages] +type v3DestinationWebhookNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationWebhookNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V3DestinationWebhookNewResponseEnvelopeSuccess bool + +const ( + V3DestinationWebhookNewResponseEnvelopeSuccessTrue V3DestinationWebhookNewResponseEnvelopeSuccess = true +) + +type V3DestinationWebhookUpdateParams struct { + // The account id + AccountID param.Field[string] `path:"account_id,required"` + // The name of the webhook destination. This will be included in the request body + // when you receive a webhook notification. + Name param.Field[string] `json:"name,required"` + // The POST endpoint to call when dispatching a notification. + URL param.Field[string] `json:"url,required"` + // Optional secret that will be passed in the `cf-webhook-auth` header when + // dispatching generic webhook notifications or formatted for supported + // destinations. Secrets are not returned in any API response body. + Secret param.Field[string] `json:"secret"` +} + +func (r V3DestinationWebhookUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type V3DestinationWebhookUpdateResponseEnvelope struct { + Errors []V3DestinationWebhookUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []V3DestinationWebhookUpdateResponseEnvelopeMessages `json:"messages,required"` + Result V3DestinationWebhookUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success V3DestinationWebhookUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON v3DestinationWebhookUpdateResponseEnvelopeJSON `json:"-"` +} + +// v3DestinationWebhookUpdateResponseEnvelopeJSON contains the JSON metadata for +// the struct [V3DestinationWebhookUpdateResponseEnvelope] +type v3DestinationWebhookUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationWebhookUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V3DestinationWebhookUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationWebhookUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// v3DestinationWebhookUpdateResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [V3DestinationWebhookUpdateResponseEnvelopeErrors] +type v3DestinationWebhookUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationWebhookUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V3DestinationWebhookUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationWebhookUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// v3DestinationWebhookUpdateResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [V3DestinationWebhookUpdateResponseEnvelopeMessages] +type v3DestinationWebhookUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationWebhookUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V3DestinationWebhookUpdateResponseEnvelopeSuccess bool + +const ( + V3DestinationWebhookUpdateResponseEnvelopeSuccessTrue V3DestinationWebhookUpdateResponseEnvelopeSuccess = true +) + +type V3DestinationWebhookListParams struct { + // The account id + AccountID param.Field[string] `path:"account_id,required"` +} + +type V3DestinationWebhookListResponseEnvelope struct { + Errors []V3DestinationWebhookListResponseEnvelopeErrors `json:"errors,required"` + Messages []V3DestinationWebhookListResponseEnvelopeMessages `json:"messages,required"` + Result []AaaWebhooks `json:"result,required,nullable"` + // Whether the API call was successful + Success V3DestinationWebhookListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo V3DestinationWebhookListResponseEnvelopeResultInfo `json:"result_info"` + JSON v3DestinationWebhookListResponseEnvelopeJSON `json:"-"` +} + +// v3DestinationWebhookListResponseEnvelopeJSON contains the JSON metadata for the +// struct [V3DestinationWebhookListResponseEnvelope] +type v3DestinationWebhookListResponseEnvelopeJSON 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 *V3DestinationWebhookListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V3DestinationWebhookListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationWebhookListResponseEnvelopeErrorsJSON `json:"-"` +} + +// v3DestinationWebhookListResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [V3DestinationWebhookListResponseEnvelopeErrors] +type v3DestinationWebhookListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationWebhookListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V3DestinationWebhookListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationWebhookListResponseEnvelopeMessagesJSON `json:"-"` +} + +// v3DestinationWebhookListResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [V3DestinationWebhookListResponseEnvelopeMessages] +type v3DestinationWebhookListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationWebhookListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V3DestinationWebhookListResponseEnvelopeSuccess bool + +const ( + V3DestinationWebhookListResponseEnvelopeSuccessTrue V3DestinationWebhookListResponseEnvelopeSuccess = true +) + +type V3DestinationWebhookListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON v3DestinationWebhookListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// v3DestinationWebhookListResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [V3DestinationWebhookListResponseEnvelopeResultInfo] +type v3DestinationWebhookListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationWebhookListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type V3DestinationWebhookDeleteParams struct { + // The account id + AccountID param.Field[string] `path:"account_id,required"` +} + +type V3DestinationWebhookDeleteResponseEnvelope struct { + Errors []V3DestinationWebhookDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []V3DestinationWebhookDeleteResponseEnvelopeMessages `json:"messages,required"` + Result V3DestinationWebhookDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success V3DestinationWebhookDeleteResponseEnvelopeSuccess `json:"success,required"` + ResultInfo V3DestinationWebhookDeleteResponseEnvelopeResultInfo `json:"result_info"` + JSON v3DestinationWebhookDeleteResponseEnvelopeJSON `json:"-"` +} + +// v3DestinationWebhookDeleteResponseEnvelopeJSON contains the JSON metadata for +// the struct [V3DestinationWebhookDeleteResponseEnvelope] +type v3DestinationWebhookDeleteResponseEnvelopeJSON 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 *V3DestinationWebhookDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V3DestinationWebhookDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationWebhookDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// v3DestinationWebhookDeleteResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [V3DestinationWebhookDeleteResponseEnvelopeErrors] +type v3DestinationWebhookDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationWebhookDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V3DestinationWebhookDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationWebhookDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// v3DestinationWebhookDeleteResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [V3DestinationWebhookDeleteResponseEnvelopeMessages] +type v3DestinationWebhookDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationWebhookDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V3DestinationWebhookDeleteResponseEnvelopeSuccess bool + +const ( + V3DestinationWebhookDeleteResponseEnvelopeSuccessTrue V3DestinationWebhookDeleteResponseEnvelopeSuccess = true +) + +type V3DestinationWebhookDeleteResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON v3DestinationWebhookDeleteResponseEnvelopeResultInfoJSON `json:"-"` +} + +// v3DestinationWebhookDeleteResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [V3DestinationWebhookDeleteResponseEnvelopeResultInfo] +type v3DestinationWebhookDeleteResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationWebhookDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type V3DestinationWebhookGetParams struct { + // The account id + AccountID param.Field[string] `path:"account_id,required"` +} + +type V3DestinationWebhookGetResponseEnvelope struct { + Errors []V3DestinationWebhookGetResponseEnvelopeErrors `json:"errors,required"` + Messages []V3DestinationWebhookGetResponseEnvelopeMessages `json:"messages,required"` + Result AaaWebhooks `json:"result,required"` + // Whether the API call was successful + Success V3DestinationWebhookGetResponseEnvelopeSuccess `json:"success,required"` + JSON v3DestinationWebhookGetResponseEnvelopeJSON `json:"-"` +} + +// v3DestinationWebhookGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [V3DestinationWebhookGetResponseEnvelope] +type v3DestinationWebhookGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationWebhookGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V3DestinationWebhookGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationWebhookGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// v3DestinationWebhookGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [V3DestinationWebhookGetResponseEnvelopeErrors] +type v3DestinationWebhookGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationWebhookGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V3DestinationWebhookGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3DestinationWebhookGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// v3DestinationWebhookGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [V3DestinationWebhookGetResponseEnvelopeMessages] +type v3DestinationWebhookGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3DestinationWebhookGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3DestinationWebhookGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V3DestinationWebhookGetResponseEnvelopeSuccess bool + +const ( + V3DestinationWebhookGetResponseEnvelopeSuccessTrue V3DestinationWebhookGetResponseEnvelopeSuccess = true +) diff --git a/alerting/v3destinationwebhook_test.go b/alerting/v3destinationwebhook_test.go new file mode 100644 index 00000000000..628fd5cb1fe --- /dev/null +++ b/alerting/v3destinationwebhook_test.go @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package alerting_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/alerting" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestV3DestinationWebhookNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Alerting.V3.Destinations.Webhooks.New(context.TODO(), alerting.V3DestinationWebhookNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Name: cloudflare.F("Slack Webhook"), + URL: cloudflare.F("https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd"), + Secret: cloudflare.F("string"), + }) + 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 TestV3DestinationWebhookUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Alerting.V3.Destinations.Webhooks.Update( + context.TODO(), + "b115d5ec-15c6-41ee-8b76-92c449b5227b", + alerting.V3DestinationWebhookUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Name: cloudflare.F("Slack Webhook"), + URL: cloudflare.F("https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd"), + Secret: cloudflare.F("string"), + }, + ) + 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 TestV3DestinationWebhookList(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("user@example.com"), + ) + _, err := client.Alerting.V3.Destinations.Webhooks.List(context.TODO(), alerting.V3DestinationWebhookListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestV3DestinationWebhookDelete(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("user@example.com"), + ) + _, err := client.Alerting.V3.Destinations.Webhooks.Delete( + context.TODO(), + "b115d5ec-15c6-41ee-8b76-92c449b5227b", + alerting.V3DestinationWebhookDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestV3DestinationWebhookGet(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("user@example.com"), + ) + _, err := client.Alerting.V3.Destinations.Webhooks.Get( + context.TODO(), + "b115d5ec-15c6-41ee-8b76-92c449b5227b", + alerting.V3DestinationWebhookGetParams{ + AccountID: cloudflare.F("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/alerting/v3history.go b/alerting/v3history.go new file mode 100644 index 00000000000..9313e040aa2 --- /dev/null +++ b/alerting/v3history.go @@ -0,0 +1,141 @@ +// File generated from our OpenAPI spec by Stainless. + +package alerting + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" +) + +// V3HistoryService 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 [NewV3HistoryService] method instead. +type V3HistoryService struct { + Options []option.RequestOption +} + +// NewV3HistoryService 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 NewV3HistoryService(opts ...option.RequestOption) (r *V3HistoryService) { + r = &V3HistoryService{} + r.Options = opts + return +} + +// Gets a list of history records for notifications sent to an account. The records +// are displayed for last `x` number of days based on the zone plan (free = 30, pro +// = 30, biz = 30, ent = 90). +func (r *V3HistoryService) List(ctx context.Context, params V3HistoryListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[AaaHistory], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("accounts/%s/alerting/v3/history", params.AccountID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Gets a list of history records for notifications sent to an account. The records +// are displayed for last `x` number of days based on the zone plan (free = 30, pro +// = 30, biz = 30, ent = 90). +func (r *V3HistoryService) ListAutoPaging(ctx context.Context, params V3HistoryListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[AaaHistory] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) +} + +type AaaHistory struct { + // UUID + ID string `json:"id"` + // Message body included in the notification sent. + AlertBody string `json:"alert_body"` + // Type of notification that has been dispatched. + AlertType string `json:"alert_type"` + // Description of the notification policy (if present). + Description string `json:"description"` + // The mechanism to which the notification has been dispatched. + Mechanism string `json:"mechanism"` + // The type of mechanism to which the notification has been dispatched. This can be + // email/pagerduty/webhook based on the mechanism configured. + MechanismType AaaHistoryMechanismType `json:"mechanism_type"` + // Name of the policy. + Name string `json:"name"` + // The unique identifier of a notification policy + PolicyID string `json:"policy_id"` + // Timestamp of when the notification was dispatched in ISO 8601 format. + Sent time.Time `json:"sent" format:"date-time"` + JSON aaaHistoryJSON `json:"-"` +} + +// aaaHistoryJSON contains the JSON metadata for the struct [AaaHistory] +type aaaHistoryJSON struct { + ID apijson.Field + AlertBody apijson.Field + AlertType apijson.Field + Description apijson.Field + Mechanism apijson.Field + MechanismType apijson.Field + Name apijson.Field + PolicyID apijson.Field + Sent apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AaaHistory) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aaaHistoryJSON) RawJSON() string { + return r.raw +} + +// The type of mechanism to which the notification has been dispatched. This can be +// email/pagerduty/webhook based on the mechanism configured. +type AaaHistoryMechanismType string + +const ( + AaaHistoryMechanismTypeEmail AaaHistoryMechanismType = "email" + AaaHistoryMechanismTypePagerduty AaaHistoryMechanismType = "pagerduty" + AaaHistoryMechanismTypeWebhook AaaHistoryMechanismType = "webhook" +) + +type V3HistoryListParams struct { + // The account id + AccountID param.Field[string] `path:"account_id,required"` + // Limit the returned results to history records older than the specified date. + // This must be a timestamp that conforms to RFC3339. + Before param.Field[time.Time] `query:"before" format:"date-time"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // Number of items per page. + PerPage param.Field[float64] `query:"per_page"` + // Limit the returned results to history records newer than the specified date. + // This must be a timestamp that conforms to RFC3339. + Since param.Field[time.Time] `query:"since" format:"date-time"` +} + +// URLQuery serializes [V3HistoryListParams]'s query parameters as `url.Values`. +func (r V3HistoryListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/alerting/v3history_test.go b/alerting/v3history_test.go new file mode 100644 index 00000000000..05f05e23e49 --- /dev/null +++ b/alerting/v3history_test.go @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package alerting_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/alerting" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestV3HistoryListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Alerting.V3.Histories.List(context.TODO(), alerting.V3HistoryListParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Before: cloudflare.F(time.Now()), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(5.000000), + Since: cloudflare.F(time.Now()), + }) + 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/alerting/v3policy.go b/alerting/v3policy.go new file mode 100644 index 00000000000..45344c6e409 --- /dev/null +++ b/alerting/v3policy.go @@ -0,0 +1,1408 @@ +// File generated from our OpenAPI spec by Stainless. + +package alerting + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// V3PolicyService 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 [NewV3PolicyService] method instead. +type V3PolicyService struct { + Options []option.RequestOption +} + +// NewV3PolicyService 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 NewV3PolicyService(opts ...option.RequestOption) (r *V3PolicyService) { + r = &V3PolicyService{} + r.Options = opts + return +} + +// Creates a new Notification policy. +func (r *V3PolicyService) New(ctx context.Context, params V3PolicyNewParams, opts ...option.RequestOption) (res *V3PolicyNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env V3PolicyNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/alerting/v3/policies", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update a Notification policy. +func (r *V3PolicyService) Update(ctx context.Context, policyID string, params V3PolicyUpdateParams, opts ...option.RequestOption) (res *V3PolicyUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env V3PolicyUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/alerting/v3/policies/%s", params.AccountID, policyID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a list of all Notification policies. +func (r *V3PolicyService) List(ctx context.Context, query V3PolicyListParams, opts ...option.RequestOption) (res *[]AaaPolicies, err error) { + opts = append(r.Options[:], opts...) + var env V3PolicyListResponseEnvelope + path := fmt.Sprintf("accounts/%s/alerting/v3/policies", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a Notification policy. +func (r *V3PolicyService) Delete(ctx context.Context, policyID string, body V3PolicyDeleteParams, opts ...option.RequestOption) (res *V3PolicyDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env V3PolicyDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/alerting/v3/policies/%s", body.AccountID, policyID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get details for a single policy. +func (r *V3PolicyService) Get(ctx context.Context, policyID string, query V3PolicyGetParams, opts ...option.RequestOption) (res *AaaPolicies, err error) { + opts = append(r.Options[:], opts...) + var env V3PolicyGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/alerting/v3/policies/%s", query.AccountID, policyID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AaaPolicies struct { + // The unique identifier of a notification policy + ID string `json:"id"` + // Refers to which event will trigger a Notification dispatch. You can use the + // endpoint to get available alert types which then will give you a list of + // possible values. + AlertType AaaPoliciesAlertType `json:"alert_type"` + Created time.Time `json:"created" format:"date-time"` + // Optional description for the Notification policy. + Description string `json:"description"` + // Whether or not the Notification policy is enabled. + Enabled bool `json:"enabled"` + // Optional filters that allow you to be alerted only on a subset of events for + // that alert type based on some criteria. This is only available for select alert + // types. See alert type documentation for more details. + Filters AaaPoliciesFilters `json:"filters"` + // List of IDs that will be used when dispatching a notification. IDs for email + // type will be the email address. + Mechanisms map[string][]AaaPoliciesMechanisms `json:"mechanisms"` + Modified time.Time `json:"modified" format:"date-time"` + // Name of the policy. + Name string `json:"name"` + JSON aaaPoliciesJSON `json:"-"` +} + +// aaaPoliciesJSON contains the JSON metadata for the struct [AaaPolicies] +type aaaPoliciesJSON struct { + ID apijson.Field + AlertType apijson.Field + Created apijson.Field + Description apijson.Field + Enabled apijson.Field + Filters apijson.Field + Mechanisms apijson.Field + Modified apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AaaPolicies) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aaaPoliciesJSON) RawJSON() string { + return r.raw +} + +// Refers to which event will trigger a Notification dispatch. You can use the +// endpoint to get available alert types which then will give you a list of +// possible values. +type AaaPoliciesAlertType string + +const ( + AaaPoliciesAlertTypeAccessCustomCertificateExpirationType AaaPoliciesAlertType = "access_custom_certificate_expiration_type" + AaaPoliciesAlertTypeAdvancedDDOSAttackL4Alert AaaPoliciesAlertType = "advanced_ddos_attack_l4_alert" + AaaPoliciesAlertTypeAdvancedDDOSAttackL7Alert AaaPoliciesAlertType = "advanced_ddos_attack_l7_alert" + AaaPoliciesAlertTypeAdvancedHTTPAlertError AaaPoliciesAlertType = "advanced_http_alert_error" + AaaPoliciesAlertTypeBGPHijackNotification AaaPoliciesAlertType = "bgp_hijack_notification" + AaaPoliciesAlertTypeBillingUsageAlert AaaPoliciesAlertType = "billing_usage_alert" + AaaPoliciesAlertTypeBlockNotificationBlockRemoved AaaPoliciesAlertType = "block_notification_block_removed" + AaaPoliciesAlertTypeBlockNotificationNewBlock AaaPoliciesAlertType = "block_notification_new_block" + AaaPoliciesAlertTypeBlockNotificationReviewRejected AaaPoliciesAlertType = "block_notification_review_rejected" + AaaPoliciesAlertTypeBrandProtectionAlert AaaPoliciesAlertType = "brand_protection_alert" + AaaPoliciesAlertTypeBrandProtectionDigest AaaPoliciesAlertType = "brand_protection_digest" + AaaPoliciesAlertTypeClickhouseAlertFwAnomaly AaaPoliciesAlertType = "clickhouse_alert_fw_anomaly" + AaaPoliciesAlertTypeClickhouseAlertFwEntAnomaly AaaPoliciesAlertType = "clickhouse_alert_fw_ent_anomaly" + AaaPoliciesAlertTypeCustomSSLCertificateEventType AaaPoliciesAlertType = "custom_ssl_certificate_event_type" + AaaPoliciesAlertTypeDedicatedSSLCertificateEventType AaaPoliciesAlertType = "dedicated_ssl_certificate_event_type" + AaaPoliciesAlertTypeDosAttackL4 AaaPoliciesAlertType = "dos_attack_l4" + AaaPoliciesAlertTypeDosAttackL7 AaaPoliciesAlertType = "dos_attack_l7" + AaaPoliciesAlertTypeExpiringServiceTokenAlert AaaPoliciesAlertType = "expiring_service_token_alert" + AaaPoliciesAlertTypeFailingLogpushJobDisabledAlert AaaPoliciesAlertType = "failing_logpush_job_disabled_alert" + AaaPoliciesAlertTypeFbmAutoAdvertisement AaaPoliciesAlertType = "fbm_auto_advertisement" + AaaPoliciesAlertTypeFbmDosdAttack AaaPoliciesAlertType = "fbm_dosd_attack" + AaaPoliciesAlertTypeFbmVolumetricAttack AaaPoliciesAlertType = "fbm_volumetric_attack" + AaaPoliciesAlertTypeHealthCheckStatusNotification AaaPoliciesAlertType = "health_check_status_notification" + AaaPoliciesAlertTypeHostnameAopCustomCertificateExpirationType AaaPoliciesAlertType = "hostname_aop_custom_certificate_expiration_type" + AaaPoliciesAlertTypeHTTPAlertEdgeError AaaPoliciesAlertType = "http_alert_edge_error" + AaaPoliciesAlertTypeHTTPAlertOriginError AaaPoliciesAlertType = "http_alert_origin_error" + AaaPoliciesAlertTypeIncidentAlert AaaPoliciesAlertType = "incident_alert" + AaaPoliciesAlertTypeLoadBalancingHealthAlert AaaPoliciesAlertType = "load_balancing_health_alert" + AaaPoliciesAlertTypeLoadBalancingPoolEnablementAlert AaaPoliciesAlertType = "load_balancing_pool_enablement_alert" + AaaPoliciesAlertTypeLogoMatchAlert AaaPoliciesAlertType = "logo_match_alert" + AaaPoliciesAlertTypeMagicTunnelHealthCheckEvent AaaPoliciesAlertType = "magic_tunnel_health_check_event" + AaaPoliciesAlertTypeMaintenanceEventNotification AaaPoliciesAlertType = "maintenance_event_notification" + AaaPoliciesAlertTypeMTLSCertificateStoreCertificateExpirationType AaaPoliciesAlertType = "mtls_certificate_store_certificate_expiration_type" + AaaPoliciesAlertTypePagesEventAlert AaaPoliciesAlertType = "pages_event_alert" + AaaPoliciesAlertTypeRadarNotification AaaPoliciesAlertType = "radar_notification" + AaaPoliciesAlertTypeRealOriginMonitoring AaaPoliciesAlertType = "real_origin_monitoring" + AaaPoliciesAlertTypeScriptmonitorAlertNewCodeChangeDetections AaaPoliciesAlertType = "scriptmonitor_alert_new_code_change_detections" + AaaPoliciesAlertTypeScriptmonitorAlertNewHosts AaaPoliciesAlertType = "scriptmonitor_alert_new_hosts" + AaaPoliciesAlertTypeScriptmonitorAlertNewMaliciousHosts AaaPoliciesAlertType = "scriptmonitor_alert_new_malicious_hosts" + AaaPoliciesAlertTypeScriptmonitorAlertNewMaliciousScripts AaaPoliciesAlertType = "scriptmonitor_alert_new_malicious_scripts" + AaaPoliciesAlertTypeScriptmonitorAlertNewMaliciousURL AaaPoliciesAlertType = "scriptmonitor_alert_new_malicious_url" + AaaPoliciesAlertTypeScriptmonitorAlertNewMaxLengthResourceURL AaaPoliciesAlertType = "scriptmonitor_alert_new_max_length_resource_url" + AaaPoliciesAlertTypeScriptmonitorAlertNewResources AaaPoliciesAlertType = "scriptmonitor_alert_new_resources" + AaaPoliciesAlertTypeSecondaryDNSAllPrimariesFailing AaaPoliciesAlertType = "secondary_dns_all_primaries_failing" + AaaPoliciesAlertTypeSecondaryDNSPrimariesFailing AaaPoliciesAlertType = "secondary_dns_primaries_failing" + AaaPoliciesAlertTypeSecondaryDNSZoneSuccessfullyUpdated AaaPoliciesAlertType = "secondary_dns_zone_successfully_updated" + AaaPoliciesAlertTypeSecondaryDNSZoneValidationWarning AaaPoliciesAlertType = "secondary_dns_zone_validation_warning" + AaaPoliciesAlertTypeSentinelAlert AaaPoliciesAlertType = "sentinel_alert" + AaaPoliciesAlertTypeStreamLiveNotifications AaaPoliciesAlertType = "stream_live_notifications" + AaaPoliciesAlertTypeTunnelHealthEvent AaaPoliciesAlertType = "tunnel_health_event" + AaaPoliciesAlertTypeTunnelUpdateEvent AaaPoliciesAlertType = "tunnel_update_event" + AaaPoliciesAlertTypeUniversalSSLEventType AaaPoliciesAlertType = "universal_ssl_event_type" + AaaPoliciesAlertTypeWebAnalyticsMetricsUpdate AaaPoliciesAlertType = "web_analytics_metrics_update" + AaaPoliciesAlertTypeZoneAopCustomCertificateExpirationType AaaPoliciesAlertType = "zone_aop_custom_certificate_expiration_type" +) + +// Optional filters that allow you to be alerted only on a subset of events for +// that alert type based on some criteria. This is only available for select alert +// types. See alert type documentation for more details. +type AaaPoliciesFilters struct { + // Usage depends on specific alert type + Actions []string `json:"actions"` + // Used for configuring radar_notification + AffectedASNs []string `json:"affected_asns"` + // Used for configuring incident_alert + AffectedComponents []string `json:"affected_components"` + // Used for configuring radar_notification + AffectedLocations []string `json:"affected_locations"` + // Used for configuring maintenance_event_notification + AirportCode []string `json:"airport_code"` + // Usage depends on specific alert type + AlertTriggerPreferences []string `json:"alert_trigger_preferences"` + // Used for configuring magic_tunnel_health_check_event + AlertTriggerPreferencesValue []AaaPoliciesFiltersAlertTriggerPreferencesValue `json:"alert_trigger_preferences_value"` + // Used for configuring load_balancing_pool_enablement_alert + Enabled []string `json:"enabled"` + // Used for configuring pages_event_alert + Environment []string `json:"environment"` + // Used for configuring pages_event_alert + Event []string `json:"event"` + // Used for configuring load_balancing_health_alert + EventSource []string `json:"event_source"` + // Usage depends on specific alert type + EventType []string `json:"event_type"` + // Usage depends on specific alert type + GroupBy []string `json:"group_by"` + // Used for configuring health_check_status_notification + HealthCheckID []string `json:"health_check_id"` + // Used for configuring incident_alert + IncidentImpact []AaaPoliciesFiltersIncidentImpact `json:"incident_impact"` + // Used for configuring stream_live_notifications + InputID []string `json:"input_id"` + // Used for configuring billing_usage_alert + Limit []string `json:"limit"` + // Used for configuring logo_match_alert + LogoTag []string `json:"logo_tag"` + // Used for configuring advanced_ddos_attack_l4_alert + MegabitsPerSecond []string `json:"megabits_per_second"` + // Used for configuring load_balancing_health_alert + NewHealth []string `json:"new_health"` + // Used for configuring tunnel_health_event + NewStatus []string `json:"new_status"` + // Used for configuring advanced_ddos_attack_l4_alert + PacketsPerSecond []string `json:"packets_per_second"` + // Usage depends on specific alert type + PoolID []string `json:"pool_id"` + // Used for configuring billing_usage_alert + Product []string `json:"product"` + // Used for configuring pages_event_alert + ProjectID []string `json:"project_id"` + // Used for configuring advanced_ddos_attack_l4_alert + Protocol []string `json:"protocol"` + // Usage depends on specific alert type + QueryTag []string `json:"query_tag"` + // Used for configuring advanced_ddos_attack_l7_alert + RequestsPerSecond []string `json:"requests_per_second"` + // Usage depends on specific alert type + Selectors []string `json:"selectors"` + // Used for configuring clickhouse_alert_fw_ent_anomaly + Services []string `json:"services"` + // Usage depends on specific alert type + Slo []string `json:"slo"` + // Used for configuring health_check_status_notification + Status []string `json:"status"` + // Used for configuring advanced_ddos_attack_l7_alert + TargetHostname []string `json:"target_hostname"` + // Used for configuring advanced_ddos_attack_l4_alert + TargetIP []string `json:"target_ip"` + // Used for configuring advanced_ddos_attack_l7_alert + TargetZoneName []string `json:"target_zone_name"` + // Used for configuring traffic_anomalies_alert + TrafficExclusions []AaaPoliciesFiltersTrafficExclusion `json:"traffic_exclusions"` + // Used for configuring tunnel_health_event + TunnelID []string `json:"tunnel_id"` + // Used for configuring magic_tunnel_health_check_event + TunnelName []string `json:"tunnel_name"` + // Usage depends on specific alert type + Where []string `json:"where"` + // Usage depends on specific alert type + Zones []string `json:"zones"` + JSON aaaPoliciesFiltersJSON `json:"-"` +} + +// aaaPoliciesFiltersJSON contains the JSON metadata for the struct +// [AaaPoliciesFilters] +type aaaPoliciesFiltersJSON struct { + Actions apijson.Field + AffectedASNs apijson.Field + AffectedComponents apijson.Field + AffectedLocations apijson.Field + AirportCode apijson.Field + AlertTriggerPreferences apijson.Field + AlertTriggerPreferencesValue apijson.Field + Enabled apijson.Field + Environment apijson.Field + Event apijson.Field + EventSource apijson.Field + EventType apijson.Field + GroupBy apijson.Field + HealthCheckID apijson.Field + IncidentImpact apijson.Field + InputID apijson.Field + Limit apijson.Field + LogoTag apijson.Field + MegabitsPerSecond apijson.Field + NewHealth apijson.Field + NewStatus apijson.Field + PacketsPerSecond apijson.Field + PoolID apijson.Field + Product apijson.Field + ProjectID apijson.Field + Protocol apijson.Field + QueryTag apijson.Field + RequestsPerSecond apijson.Field + Selectors apijson.Field + Services apijson.Field + Slo apijson.Field + Status apijson.Field + TargetHostname apijson.Field + TargetIP apijson.Field + TargetZoneName apijson.Field + TrafficExclusions apijson.Field + TunnelID apijson.Field + TunnelName apijson.Field + Where apijson.Field + Zones apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AaaPoliciesFilters) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aaaPoliciesFiltersJSON) RawJSON() string { + return r.raw +} + +type AaaPoliciesFiltersAlertTriggerPreferencesValue string + +const ( + AaaPoliciesFiltersAlertTriggerPreferencesValue99_0 AaaPoliciesFiltersAlertTriggerPreferencesValue = "99.0" + AaaPoliciesFiltersAlertTriggerPreferencesValue98_0 AaaPoliciesFiltersAlertTriggerPreferencesValue = "98.0" + AaaPoliciesFiltersAlertTriggerPreferencesValue97_0 AaaPoliciesFiltersAlertTriggerPreferencesValue = "97.0" +) + +type AaaPoliciesFiltersIncidentImpact string + +const ( + AaaPoliciesFiltersIncidentImpactIncidentImpactNone AaaPoliciesFiltersIncidentImpact = "INCIDENT_IMPACT_NONE" + AaaPoliciesFiltersIncidentImpactIncidentImpactMinor AaaPoliciesFiltersIncidentImpact = "INCIDENT_IMPACT_MINOR" + AaaPoliciesFiltersIncidentImpactIncidentImpactMajor AaaPoliciesFiltersIncidentImpact = "INCIDENT_IMPACT_MAJOR" + AaaPoliciesFiltersIncidentImpactIncidentImpactCritical AaaPoliciesFiltersIncidentImpact = "INCIDENT_IMPACT_CRITICAL" +) + +type AaaPoliciesFiltersTrafficExclusion string + +const ( + AaaPoliciesFiltersTrafficExclusionSecurityEvents AaaPoliciesFiltersTrafficExclusion = "security_events" +) + +type AaaPoliciesMechanisms struct { + // UUID + ID AaaPoliciesMechanismsID `json:"id"` + JSON aaaPoliciesMechanismsJSON `json:"-"` +} + +// aaaPoliciesMechanismsJSON contains the JSON metadata for the struct +// [AaaPoliciesMechanisms] +type aaaPoliciesMechanismsJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AaaPoliciesMechanisms) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aaaPoliciesMechanismsJSON) RawJSON() string { + return r.raw +} + +// UUID +// +// Union satisfied by [shared.UnionString] or [shared.UnionString]. +type AaaPoliciesMechanismsID interface { + ImplementsAlertingAaaPoliciesMechanismsID() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AaaPoliciesMechanismsID)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type V3PolicyNewResponse struct { + // UUID + ID string `json:"id"` + JSON v3PolicyNewResponseJSON `json:"-"` +} + +// v3PolicyNewResponseJSON contains the JSON metadata for the struct +// [V3PolicyNewResponse] +type v3PolicyNewResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3PolicyNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyNewResponseJSON) RawJSON() string { + return r.raw +} + +type V3PolicyUpdateResponse struct { + // UUID + ID string `json:"id"` + JSON v3PolicyUpdateResponseJSON `json:"-"` +} + +// v3PolicyUpdateResponseJSON contains the JSON metadata for the struct +// [V3PolicyUpdateResponse] +type v3PolicyUpdateResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3PolicyUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyUpdateResponseJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [alerting.V3PolicyDeleteResponseUnknown], +// [alerting.V3PolicyDeleteResponseArray] or [shared.UnionString]. +type V3PolicyDeleteResponse interface { + ImplementsAlertingV3PolicyDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*V3PolicyDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(V3PolicyDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type V3PolicyDeleteResponseArray []interface{} + +func (r V3PolicyDeleteResponseArray) ImplementsAlertingV3PolicyDeleteResponse() {} + +type V3PolicyNewParams struct { + // The account id + AccountID param.Field[string] `path:"account_id,required"` + // Refers to which event will trigger a Notification dispatch. You can use the + // endpoint to get available alert types which then will give you a list of + // possible values. + AlertType param.Field[V3PolicyNewParamsAlertType] `json:"alert_type,required"` + // Whether or not the Notification policy is enabled. + Enabled param.Field[bool] `json:"enabled,required"` + // List of IDs that will be used when dispatching a notification. IDs for email + // type will be the email address. + Mechanisms param.Field[map[string][]V3PolicyNewParamsMechanisms] `json:"mechanisms,required"` + // Name of the policy. + Name param.Field[string] `json:"name,required"` + // Optional description for the Notification policy. + Description param.Field[string] `json:"description"` + // Optional filters that allow you to be alerted only on a subset of events for + // that alert type based on some criteria. This is only available for select alert + // types. See alert type documentation for more details. + Filters param.Field[V3PolicyNewParamsFilters] `json:"filters"` +} + +func (r V3PolicyNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Refers to which event will trigger a Notification dispatch. You can use the +// endpoint to get available alert types which then will give you a list of +// possible values. +type V3PolicyNewParamsAlertType string + +const ( + V3PolicyNewParamsAlertTypeAccessCustomCertificateExpirationType V3PolicyNewParamsAlertType = "access_custom_certificate_expiration_type" + V3PolicyNewParamsAlertTypeAdvancedDDOSAttackL4Alert V3PolicyNewParamsAlertType = "advanced_ddos_attack_l4_alert" + V3PolicyNewParamsAlertTypeAdvancedDDOSAttackL7Alert V3PolicyNewParamsAlertType = "advanced_ddos_attack_l7_alert" + V3PolicyNewParamsAlertTypeAdvancedHTTPAlertError V3PolicyNewParamsAlertType = "advanced_http_alert_error" + V3PolicyNewParamsAlertTypeBGPHijackNotification V3PolicyNewParamsAlertType = "bgp_hijack_notification" + V3PolicyNewParamsAlertTypeBillingUsageAlert V3PolicyNewParamsAlertType = "billing_usage_alert" + V3PolicyNewParamsAlertTypeBlockNotificationBlockRemoved V3PolicyNewParamsAlertType = "block_notification_block_removed" + V3PolicyNewParamsAlertTypeBlockNotificationNewBlock V3PolicyNewParamsAlertType = "block_notification_new_block" + V3PolicyNewParamsAlertTypeBlockNotificationReviewRejected V3PolicyNewParamsAlertType = "block_notification_review_rejected" + V3PolicyNewParamsAlertTypeBrandProtectionAlert V3PolicyNewParamsAlertType = "brand_protection_alert" + V3PolicyNewParamsAlertTypeBrandProtectionDigest V3PolicyNewParamsAlertType = "brand_protection_digest" + V3PolicyNewParamsAlertTypeClickhouseAlertFwAnomaly V3PolicyNewParamsAlertType = "clickhouse_alert_fw_anomaly" + V3PolicyNewParamsAlertTypeClickhouseAlertFwEntAnomaly V3PolicyNewParamsAlertType = "clickhouse_alert_fw_ent_anomaly" + V3PolicyNewParamsAlertTypeCustomSSLCertificateEventType V3PolicyNewParamsAlertType = "custom_ssl_certificate_event_type" + V3PolicyNewParamsAlertTypeDedicatedSSLCertificateEventType V3PolicyNewParamsAlertType = "dedicated_ssl_certificate_event_type" + V3PolicyNewParamsAlertTypeDosAttackL4 V3PolicyNewParamsAlertType = "dos_attack_l4" + V3PolicyNewParamsAlertTypeDosAttackL7 V3PolicyNewParamsAlertType = "dos_attack_l7" + V3PolicyNewParamsAlertTypeExpiringServiceTokenAlert V3PolicyNewParamsAlertType = "expiring_service_token_alert" + V3PolicyNewParamsAlertTypeFailingLogpushJobDisabledAlert V3PolicyNewParamsAlertType = "failing_logpush_job_disabled_alert" + V3PolicyNewParamsAlertTypeFbmAutoAdvertisement V3PolicyNewParamsAlertType = "fbm_auto_advertisement" + V3PolicyNewParamsAlertTypeFbmDosdAttack V3PolicyNewParamsAlertType = "fbm_dosd_attack" + V3PolicyNewParamsAlertTypeFbmVolumetricAttack V3PolicyNewParamsAlertType = "fbm_volumetric_attack" + V3PolicyNewParamsAlertTypeHealthCheckStatusNotification V3PolicyNewParamsAlertType = "health_check_status_notification" + V3PolicyNewParamsAlertTypeHostnameAopCustomCertificateExpirationType V3PolicyNewParamsAlertType = "hostname_aop_custom_certificate_expiration_type" + V3PolicyNewParamsAlertTypeHTTPAlertEdgeError V3PolicyNewParamsAlertType = "http_alert_edge_error" + V3PolicyNewParamsAlertTypeHTTPAlertOriginError V3PolicyNewParamsAlertType = "http_alert_origin_error" + V3PolicyNewParamsAlertTypeIncidentAlert V3PolicyNewParamsAlertType = "incident_alert" + V3PolicyNewParamsAlertTypeLoadBalancingHealthAlert V3PolicyNewParamsAlertType = "load_balancing_health_alert" + V3PolicyNewParamsAlertTypeLoadBalancingPoolEnablementAlert V3PolicyNewParamsAlertType = "load_balancing_pool_enablement_alert" + V3PolicyNewParamsAlertTypeLogoMatchAlert V3PolicyNewParamsAlertType = "logo_match_alert" + V3PolicyNewParamsAlertTypeMagicTunnelHealthCheckEvent V3PolicyNewParamsAlertType = "magic_tunnel_health_check_event" + V3PolicyNewParamsAlertTypeMaintenanceEventNotification V3PolicyNewParamsAlertType = "maintenance_event_notification" + V3PolicyNewParamsAlertTypeMTLSCertificateStoreCertificateExpirationType V3PolicyNewParamsAlertType = "mtls_certificate_store_certificate_expiration_type" + V3PolicyNewParamsAlertTypePagesEventAlert V3PolicyNewParamsAlertType = "pages_event_alert" + V3PolicyNewParamsAlertTypeRadarNotification V3PolicyNewParamsAlertType = "radar_notification" + V3PolicyNewParamsAlertTypeRealOriginMonitoring V3PolicyNewParamsAlertType = "real_origin_monitoring" + V3PolicyNewParamsAlertTypeScriptmonitorAlertNewCodeChangeDetections V3PolicyNewParamsAlertType = "scriptmonitor_alert_new_code_change_detections" + V3PolicyNewParamsAlertTypeScriptmonitorAlertNewHosts V3PolicyNewParamsAlertType = "scriptmonitor_alert_new_hosts" + V3PolicyNewParamsAlertTypeScriptmonitorAlertNewMaliciousHosts V3PolicyNewParamsAlertType = "scriptmonitor_alert_new_malicious_hosts" + V3PolicyNewParamsAlertTypeScriptmonitorAlertNewMaliciousScripts V3PolicyNewParamsAlertType = "scriptmonitor_alert_new_malicious_scripts" + V3PolicyNewParamsAlertTypeScriptmonitorAlertNewMaliciousURL V3PolicyNewParamsAlertType = "scriptmonitor_alert_new_malicious_url" + V3PolicyNewParamsAlertTypeScriptmonitorAlertNewMaxLengthResourceURL V3PolicyNewParamsAlertType = "scriptmonitor_alert_new_max_length_resource_url" + V3PolicyNewParamsAlertTypeScriptmonitorAlertNewResources V3PolicyNewParamsAlertType = "scriptmonitor_alert_new_resources" + V3PolicyNewParamsAlertTypeSecondaryDNSAllPrimariesFailing V3PolicyNewParamsAlertType = "secondary_dns_all_primaries_failing" + V3PolicyNewParamsAlertTypeSecondaryDNSPrimariesFailing V3PolicyNewParamsAlertType = "secondary_dns_primaries_failing" + V3PolicyNewParamsAlertTypeSecondaryDNSZoneSuccessfullyUpdated V3PolicyNewParamsAlertType = "secondary_dns_zone_successfully_updated" + V3PolicyNewParamsAlertTypeSecondaryDNSZoneValidationWarning V3PolicyNewParamsAlertType = "secondary_dns_zone_validation_warning" + V3PolicyNewParamsAlertTypeSentinelAlert V3PolicyNewParamsAlertType = "sentinel_alert" + V3PolicyNewParamsAlertTypeStreamLiveNotifications V3PolicyNewParamsAlertType = "stream_live_notifications" + V3PolicyNewParamsAlertTypeTunnelHealthEvent V3PolicyNewParamsAlertType = "tunnel_health_event" + V3PolicyNewParamsAlertTypeTunnelUpdateEvent V3PolicyNewParamsAlertType = "tunnel_update_event" + V3PolicyNewParamsAlertTypeUniversalSSLEventType V3PolicyNewParamsAlertType = "universal_ssl_event_type" + V3PolicyNewParamsAlertTypeWebAnalyticsMetricsUpdate V3PolicyNewParamsAlertType = "web_analytics_metrics_update" + V3PolicyNewParamsAlertTypeZoneAopCustomCertificateExpirationType V3PolicyNewParamsAlertType = "zone_aop_custom_certificate_expiration_type" +) + +type V3PolicyNewParamsMechanisms struct { + // UUID + ID param.Field[V3PolicyNewParamsMechanismsID] `json:"id"` +} + +func (r V3PolicyNewParamsMechanisms) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// UUID +// +// Satisfied by [shared.UnionString], [shared.UnionString]. +type V3PolicyNewParamsMechanismsID interface { + ImplementsAlertingV3PolicyNewParamsMechanismsID() +} + +// Optional filters that allow you to be alerted only on a subset of events for +// that alert type based on some criteria. This is only available for select alert +// types. See alert type documentation for more details. +type V3PolicyNewParamsFilters struct { + // Usage depends on specific alert type + Actions param.Field[[]string] `json:"actions"` + // Used for configuring radar_notification + AffectedASNs param.Field[[]string] `json:"affected_asns"` + // Used for configuring incident_alert + AffectedComponents param.Field[[]string] `json:"affected_components"` + // Used for configuring radar_notification + AffectedLocations param.Field[[]string] `json:"affected_locations"` + // Used for configuring maintenance_event_notification + AirportCode param.Field[[]string] `json:"airport_code"` + // Usage depends on specific alert type + AlertTriggerPreferences param.Field[[]string] `json:"alert_trigger_preferences"` + // Used for configuring magic_tunnel_health_check_event + AlertTriggerPreferencesValue param.Field[[]V3PolicyNewParamsFiltersAlertTriggerPreferencesValue] `json:"alert_trigger_preferences_value"` + // Used for configuring load_balancing_pool_enablement_alert + Enabled param.Field[[]string] `json:"enabled"` + // Used for configuring pages_event_alert + Environment param.Field[[]string] `json:"environment"` + // Used for configuring pages_event_alert + Event param.Field[[]string] `json:"event"` + // Used for configuring load_balancing_health_alert + EventSource param.Field[[]string] `json:"event_source"` + // Usage depends on specific alert type + EventType param.Field[[]string] `json:"event_type"` + // Usage depends on specific alert type + GroupBy param.Field[[]string] `json:"group_by"` + // Used for configuring health_check_status_notification + HealthCheckID param.Field[[]string] `json:"health_check_id"` + // Used for configuring incident_alert + IncidentImpact param.Field[[]V3PolicyNewParamsFiltersIncidentImpact] `json:"incident_impact"` + // Used for configuring stream_live_notifications + InputID param.Field[[]string] `json:"input_id"` + // Used for configuring billing_usage_alert + Limit param.Field[[]string] `json:"limit"` + // Used for configuring logo_match_alert + LogoTag param.Field[[]string] `json:"logo_tag"` + // Used for configuring advanced_ddos_attack_l4_alert + MegabitsPerSecond param.Field[[]string] `json:"megabits_per_second"` + // Used for configuring load_balancing_health_alert + NewHealth param.Field[[]string] `json:"new_health"` + // Used for configuring tunnel_health_event + NewStatus param.Field[[]string] `json:"new_status"` + // Used for configuring advanced_ddos_attack_l4_alert + PacketsPerSecond param.Field[[]string] `json:"packets_per_second"` + // Usage depends on specific alert type + PoolID param.Field[[]string] `json:"pool_id"` + // Used for configuring billing_usage_alert + Product param.Field[[]string] `json:"product"` + // Used for configuring pages_event_alert + ProjectID param.Field[[]string] `json:"project_id"` + // Used for configuring advanced_ddos_attack_l4_alert + Protocol param.Field[[]string] `json:"protocol"` + // Usage depends on specific alert type + QueryTag param.Field[[]string] `json:"query_tag"` + // Used for configuring advanced_ddos_attack_l7_alert + RequestsPerSecond param.Field[[]string] `json:"requests_per_second"` + // Usage depends on specific alert type + Selectors param.Field[[]string] `json:"selectors"` + // Used for configuring clickhouse_alert_fw_ent_anomaly + Services param.Field[[]string] `json:"services"` + // Usage depends on specific alert type + Slo param.Field[[]string] `json:"slo"` + // Used for configuring health_check_status_notification + Status param.Field[[]string] `json:"status"` + // Used for configuring advanced_ddos_attack_l7_alert + TargetHostname param.Field[[]string] `json:"target_hostname"` + // Used for configuring advanced_ddos_attack_l4_alert + TargetIP param.Field[[]string] `json:"target_ip"` + // Used for configuring advanced_ddos_attack_l7_alert + TargetZoneName param.Field[[]string] `json:"target_zone_name"` + // Used for configuring traffic_anomalies_alert + TrafficExclusions param.Field[[]V3PolicyNewParamsFiltersTrafficExclusion] `json:"traffic_exclusions"` + // Used for configuring tunnel_health_event + TunnelID param.Field[[]string] `json:"tunnel_id"` + // Used for configuring magic_tunnel_health_check_event + TunnelName param.Field[[]string] `json:"tunnel_name"` + // Usage depends on specific alert type + Where param.Field[[]string] `json:"where"` + // Usage depends on specific alert type + Zones param.Field[[]string] `json:"zones"` +} + +func (r V3PolicyNewParamsFilters) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type V3PolicyNewParamsFiltersAlertTriggerPreferencesValue string + +const ( + V3PolicyNewParamsFiltersAlertTriggerPreferencesValue99_0 V3PolicyNewParamsFiltersAlertTriggerPreferencesValue = "99.0" + V3PolicyNewParamsFiltersAlertTriggerPreferencesValue98_0 V3PolicyNewParamsFiltersAlertTriggerPreferencesValue = "98.0" + V3PolicyNewParamsFiltersAlertTriggerPreferencesValue97_0 V3PolicyNewParamsFiltersAlertTriggerPreferencesValue = "97.0" +) + +type V3PolicyNewParamsFiltersIncidentImpact string + +const ( + V3PolicyNewParamsFiltersIncidentImpactIncidentImpactNone V3PolicyNewParamsFiltersIncidentImpact = "INCIDENT_IMPACT_NONE" + V3PolicyNewParamsFiltersIncidentImpactIncidentImpactMinor V3PolicyNewParamsFiltersIncidentImpact = "INCIDENT_IMPACT_MINOR" + V3PolicyNewParamsFiltersIncidentImpactIncidentImpactMajor V3PolicyNewParamsFiltersIncidentImpact = "INCIDENT_IMPACT_MAJOR" + V3PolicyNewParamsFiltersIncidentImpactIncidentImpactCritical V3PolicyNewParamsFiltersIncidentImpact = "INCIDENT_IMPACT_CRITICAL" +) + +type V3PolicyNewParamsFiltersTrafficExclusion string + +const ( + V3PolicyNewParamsFiltersTrafficExclusionSecurityEvents V3PolicyNewParamsFiltersTrafficExclusion = "security_events" +) + +type V3PolicyNewResponseEnvelope struct { + Errors []V3PolicyNewResponseEnvelopeErrors `json:"errors,required"` + Messages []V3PolicyNewResponseEnvelopeMessages `json:"messages,required"` + Result V3PolicyNewResponse `json:"result,required"` + // Whether the API call was successful + Success V3PolicyNewResponseEnvelopeSuccess `json:"success,required"` + JSON v3PolicyNewResponseEnvelopeJSON `json:"-"` +} + +// v3PolicyNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [V3PolicyNewResponseEnvelope] +type v3PolicyNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3PolicyNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V3PolicyNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3PolicyNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// v3PolicyNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [V3PolicyNewResponseEnvelopeErrors] +type v3PolicyNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3PolicyNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V3PolicyNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3PolicyNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// v3PolicyNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [V3PolicyNewResponseEnvelopeMessages] +type v3PolicyNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3PolicyNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V3PolicyNewResponseEnvelopeSuccess bool + +const ( + V3PolicyNewResponseEnvelopeSuccessTrue V3PolicyNewResponseEnvelopeSuccess = true +) + +type V3PolicyUpdateParams struct { + // The account id + AccountID param.Field[string] `path:"account_id,required"` + // Refers to which event will trigger a Notification dispatch. You can use the + // endpoint to get available alert types which then will give you a list of + // possible values. + AlertType param.Field[V3PolicyUpdateParamsAlertType] `json:"alert_type"` + // Optional description for the Notification policy. + Description param.Field[string] `json:"description"` + // Whether or not the Notification policy is enabled. + Enabled param.Field[bool] `json:"enabled"` + // Optional filters that allow you to be alerted only on a subset of events for + // that alert type based on some criteria. This is only available for select alert + // types. See alert type documentation for more details. + Filters param.Field[V3PolicyUpdateParamsFilters] `json:"filters"` + // List of IDs that will be used when dispatching a notification. IDs for email + // type will be the email address. + Mechanisms param.Field[map[string][]V3PolicyUpdateParamsMechanisms] `json:"mechanisms"` + // Name of the policy. + Name param.Field[string] `json:"name"` +} + +func (r V3PolicyUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Refers to which event will trigger a Notification dispatch. You can use the +// endpoint to get available alert types which then will give you a list of +// possible values. +type V3PolicyUpdateParamsAlertType string + +const ( + V3PolicyUpdateParamsAlertTypeAccessCustomCertificateExpirationType V3PolicyUpdateParamsAlertType = "access_custom_certificate_expiration_type" + V3PolicyUpdateParamsAlertTypeAdvancedDDOSAttackL4Alert V3PolicyUpdateParamsAlertType = "advanced_ddos_attack_l4_alert" + V3PolicyUpdateParamsAlertTypeAdvancedDDOSAttackL7Alert V3PolicyUpdateParamsAlertType = "advanced_ddos_attack_l7_alert" + V3PolicyUpdateParamsAlertTypeAdvancedHTTPAlertError V3PolicyUpdateParamsAlertType = "advanced_http_alert_error" + V3PolicyUpdateParamsAlertTypeBGPHijackNotification V3PolicyUpdateParamsAlertType = "bgp_hijack_notification" + V3PolicyUpdateParamsAlertTypeBillingUsageAlert V3PolicyUpdateParamsAlertType = "billing_usage_alert" + V3PolicyUpdateParamsAlertTypeBlockNotificationBlockRemoved V3PolicyUpdateParamsAlertType = "block_notification_block_removed" + V3PolicyUpdateParamsAlertTypeBlockNotificationNewBlock V3PolicyUpdateParamsAlertType = "block_notification_new_block" + V3PolicyUpdateParamsAlertTypeBlockNotificationReviewRejected V3PolicyUpdateParamsAlertType = "block_notification_review_rejected" + V3PolicyUpdateParamsAlertTypeBrandProtectionAlert V3PolicyUpdateParamsAlertType = "brand_protection_alert" + V3PolicyUpdateParamsAlertTypeBrandProtectionDigest V3PolicyUpdateParamsAlertType = "brand_protection_digest" + V3PolicyUpdateParamsAlertTypeClickhouseAlertFwAnomaly V3PolicyUpdateParamsAlertType = "clickhouse_alert_fw_anomaly" + V3PolicyUpdateParamsAlertTypeClickhouseAlertFwEntAnomaly V3PolicyUpdateParamsAlertType = "clickhouse_alert_fw_ent_anomaly" + V3PolicyUpdateParamsAlertTypeCustomSSLCertificateEventType V3PolicyUpdateParamsAlertType = "custom_ssl_certificate_event_type" + V3PolicyUpdateParamsAlertTypeDedicatedSSLCertificateEventType V3PolicyUpdateParamsAlertType = "dedicated_ssl_certificate_event_type" + V3PolicyUpdateParamsAlertTypeDosAttackL4 V3PolicyUpdateParamsAlertType = "dos_attack_l4" + V3PolicyUpdateParamsAlertTypeDosAttackL7 V3PolicyUpdateParamsAlertType = "dos_attack_l7" + V3PolicyUpdateParamsAlertTypeExpiringServiceTokenAlert V3PolicyUpdateParamsAlertType = "expiring_service_token_alert" + V3PolicyUpdateParamsAlertTypeFailingLogpushJobDisabledAlert V3PolicyUpdateParamsAlertType = "failing_logpush_job_disabled_alert" + V3PolicyUpdateParamsAlertTypeFbmAutoAdvertisement V3PolicyUpdateParamsAlertType = "fbm_auto_advertisement" + V3PolicyUpdateParamsAlertTypeFbmDosdAttack V3PolicyUpdateParamsAlertType = "fbm_dosd_attack" + V3PolicyUpdateParamsAlertTypeFbmVolumetricAttack V3PolicyUpdateParamsAlertType = "fbm_volumetric_attack" + V3PolicyUpdateParamsAlertTypeHealthCheckStatusNotification V3PolicyUpdateParamsAlertType = "health_check_status_notification" + V3PolicyUpdateParamsAlertTypeHostnameAopCustomCertificateExpirationType V3PolicyUpdateParamsAlertType = "hostname_aop_custom_certificate_expiration_type" + V3PolicyUpdateParamsAlertTypeHTTPAlertEdgeError V3PolicyUpdateParamsAlertType = "http_alert_edge_error" + V3PolicyUpdateParamsAlertTypeHTTPAlertOriginError V3PolicyUpdateParamsAlertType = "http_alert_origin_error" + V3PolicyUpdateParamsAlertTypeIncidentAlert V3PolicyUpdateParamsAlertType = "incident_alert" + V3PolicyUpdateParamsAlertTypeLoadBalancingHealthAlert V3PolicyUpdateParamsAlertType = "load_balancing_health_alert" + V3PolicyUpdateParamsAlertTypeLoadBalancingPoolEnablementAlert V3PolicyUpdateParamsAlertType = "load_balancing_pool_enablement_alert" + V3PolicyUpdateParamsAlertTypeLogoMatchAlert V3PolicyUpdateParamsAlertType = "logo_match_alert" + V3PolicyUpdateParamsAlertTypeMagicTunnelHealthCheckEvent V3PolicyUpdateParamsAlertType = "magic_tunnel_health_check_event" + V3PolicyUpdateParamsAlertTypeMaintenanceEventNotification V3PolicyUpdateParamsAlertType = "maintenance_event_notification" + V3PolicyUpdateParamsAlertTypeMTLSCertificateStoreCertificateExpirationType V3PolicyUpdateParamsAlertType = "mtls_certificate_store_certificate_expiration_type" + V3PolicyUpdateParamsAlertTypePagesEventAlert V3PolicyUpdateParamsAlertType = "pages_event_alert" + V3PolicyUpdateParamsAlertTypeRadarNotification V3PolicyUpdateParamsAlertType = "radar_notification" + V3PolicyUpdateParamsAlertTypeRealOriginMonitoring V3PolicyUpdateParamsAlertType = "real_origin_monitoring" + V3PolicyUpdateParamsAlertTypeScriptmonitorAlertNewCodeChangeDetections V3PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_code_change_detections" + V3PolicyUpdateParamsAlertTypeScriptmonitorAlertNewHosts V3PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_hosts" + V3PolicyUpdateParamsAlertTypeScriptmonitorAlertNewMaliciousHosts V3PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_malicious_hosts" + V3PolicyUpdateParamsAlertTypeScriptmonitorAlertNewMaliciousScripts V3PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_malicious_scripts" + V3PolicyUpdateParamsAlertTypeScriptmonitorAlertNewMaliciousURL V3PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_malicious_url" + V3PolicyUpdateParamsAlertTypeScriptmonitorAlertNewMaxLengthResourceURL V3PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_max_length_resource_url" + V3PolicyUpdateParamsAlertTypeScriptmonitorAlertNewResources V3PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_resources" + V3PolicyUpdateParamsAlertTypeSecondaryDNSAllPrimariesFailing V3PolicyUpdateParamsAlertType = "secondary_dns_all_primaries_failing" + V3PolicyUpdateParamsAlertTypeSecondaryDNSPrimariesFailing V3PolicyUpdateParamsAlertType = "secondary_dns_primaries_failing" + V3PolicyUpdateParamsAlertTypeSecondaryDNSZoneSuccessfullyUpdated V3PolicyUpdateParamsAlertType = "secondary_dns_zone_successfully_updated" + V3PolicyUpdateParamsAlertTypeSecondaryDNSZoneValidationWarning V3PolicyUpdateParamsAlertType = "secondary_dns_zone_validation_warning" + V3PolicyUpdateParamsAlertTypeSentinelAlert V3PolicyUpdateParamsAlertType = "sentinel_alert" + V3PolicyUpdateParamsAlertTypeStreamLiveNotifications V3PolicyUpdateParamsAlertType = "stream_live_notifications" + V3PolicyUpdateParamsAlertTypeTunnelHealthEvent V3PolicyUpdateParamsAlertType = "tunnel_health_event" + V3PolicyUpdateParamsAlertTypeTunnelUpdateEvent V3PolicyUpdateParamsAlertType = "tunnel_update_event" + V3PolicyUpdateParamsAlertTypeUniversalSSLEventType V3PolicyUpdateParamsAlertType = "universal_ssl_event_type" + V3PolicyUpdateParamsAlertTypeWebAnalyticsMetricsUpdate V3PolicyUpdateParamsAlertType = "web_analytics_metrics_update" + V3PolicyUpdateParamsAlertTypeZoneAopCustomCertificateExpirationType V3PolicyUpdateParamsAlertType = "zone_aop_custom_certificate_expiration_type" +) + +// Optional filters that allow you to be alerted only on a subset of events for +// that alert type based on some criteria. This is only available for select alert +// types. See alert type documentation for more details. +type V3PolicyUpdateParamsFilters struct { + // Usage depends on specific alert type + Actions param.Field[[]string] `json:"actions"` + // Used for configuring radar_notification + AffectedASNs param.Field[[]string] `json:"affected_asns"` + // Used for configuring incident_alert + AffectedComponents param.Field[[]string] `json:"affected_components"` + // Used for configuring radar_notification + AffectedLocations param.Field[[]string] `json:"affected_locations"` + // Used for configuring maintenance_event_notification + AirportCode param.Field[[]string] `json:"airport_code"` + // Usage depends on specific alert type + AlertTriggerPreferences param.Field[[]string] `json:"alert_trigger_preferences"` + // Used for configuring magic_tunnel_health_check_event + AlertTriggerPreferencesValue param.Field[[]V3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue] `json:"alert_trigger_preferences_value"` + // Used for configuring load_balancing_pool_enablement_alert + Enabled param.Field[[]string] `json:"enabled"` + // Used for configuring pages_event_alert + Environment param.Field[[]string] `json:"environment"` + // Used for configuring pages_event_alert + Event param.Field[[]string] `json:"event"` + // Used for configuring load_balancing_health_alert + EventSource param.Field[[]string] `json:"event_source"` + // Usage depends on specific alert type + EventType param.Field[[]string] `json:"event_type"` + // Usage depends on specific alert type + GroupBy param.Field[[]string] `json:"group_by"` + // Used for configuring health_check_status_notification + HealthCheckID param.Field[[]string] `json:"health_check_id"` + // Used for configuring incident_alert + IncidentImpact param.Field[[]V3PolicyUpdateParamsFiltersIncidentImpact] `json:"incident_impact"` + // Used for configuring stream_live_notifications + InputID param.Field[[]string] `json:"input_id"` + // Used for configuring billing_usage_alert + Limit param.Field[[]string] `json:"limit"` + // Used for configuring logo_match_alert + LogoTag param.Field[[]string] `json:"logo_tag"` + // Used for configuring advanced_ddos_attack_l4_alert + MegabitsPerSecond param.Field[[]string] `json:"megabits_per_second"` + // Used for configuring load_balancing_health_alert + NewHealth param.Field[[]string] `json:"new_health"` + // Used for configuring tunnel_health_event + NewStatus param.Field[[]string] `json:"new_status"` + // Used for configuring advanced_ddos_attack_l4_alert + PacketsPerSecond param.Field[[]string] `json:"packets_per_second"` + // Usage depends on specific alert type + PoolID param.Field[[]string] `json:"pool_id"` + // Used for configuring billing_usage_alert + Product param.Field[[]string] `json:"product"` + // Used for configuring pages_event_alert + ProjectID param.Field[[]string] `json:"project_id"` + // Used for configuring advanced_ddos_attack_l4_alert + Protocol param.Field[[]string] `json:"protocol"` + // Usage depends on specific alert type + QueryTag param.Field[[]string] `json:"query_tag"` + // Used for configuring advanced_ddos_attack_l7_alert + RequestsPerSecond param.Field[[]string] `json:"requests_per_second"` + // Usage depends on specific alert type + Selectors param.Field[[]string] `json:"selectors"` + // Used for configuring clickhouse_alert_fw_ent_anomaly + Services param.Field[[]string] `json:"services"` + // Usage depends on specific alert type + Slo param.Field[[]string] `json:"slo"` + // Used for configuring health_check_status_notification + Status param.Field[[]string] `json:"status"` + // Used for configuring advanced_ddos_attack_l7_alert + TargetHostname param.Field[[]string] `json:"target_hostname"` + // Used for configuring advanced_ddos_attack_l4_alert + TargetIP param.Field[[]string] `json:"target_ip"` + // Used for configuring advanced_ddos_attack_l7_alert + TargetZoneName param.Field[[]string] `json:"target_zone_name"` + // Used for configuring traffic_anomalies_alert + TrafficExclusions param.Field[[]V3PolicyUpdateParamsFiltersTrafficExclusion] `json:"traffic_exclusions"` + // Used for configuring tunnel_health_event + TunnelID param.Field[[]string] `json:"tunnel_id"` + // Used for configuring magic_tunnel_health_check_event + TunnelName param.Field[[]string] `json:"tunnel_name"` + // Usage depends on specific alert type + Where param.Field[[]string] `json:"where"` + // Usage depends on specific alert type + Zones param.Field[[]string] `json:"zones"` +} + +func (r V3PolicyUpdateParamsFilters) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type V3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue string + +const ( + V3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue99_0 V3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue = "99.0" + V3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue98_0 V3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue = "98.0" + V3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue97_0 V3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue = "97.0" +) + +type V3PolicyUpdateParamsFiltersIncidentImpact string + +const ( + V3PolicyUpdateParamsFiltersIncidentImpactIncidentImpactNone V3PolicyUpdateParamsFiltersIncidentImpact = "INCIDENT_IMPACT_NONE" + V3PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMinor V3PolicyUpdateParamsFiltersIncidentImpact = "INCIDENT_IMPACT_MINOR" + V3PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMajor V3PolicyUpdateParamsFiltersIncidentImpact = "INCIDENT_IMPACT_MAJOR" + V3PolicyUpdateParamsFiltersIncidentImpactIncidentImpactCritical V3PolicyUpdateParamsFiltersIncidentImpact = "INCIDENT_IMPACT_CRITICAL" +) + +type V3PolicyUpdateParamsFiltersTrafficExclusion string + +const ( + V3PolicyUpdateParamsFiltersTrafficExclusionSecurityEvents V3PolicyUpdateParamsFiltersTrafficExclusion = "security_events" +) + +type V3PolicyUpdateParamsMechanisms struct { + // UUID + ID param.Field[V3PolicyUpdateParamsMechanismsID] `json:"id"` +} + +func (r V3PolicyUpdateParamsMechanisms) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// UUID +// +// Satisfied by [shared.UnionString], [shared.UnionString]. +type V3PolicyUpdateParamsMechanismsID interface { + ImplementsAlertingV3PolicyUpdateParamsMechanismsID() +} + +type V3PolicyUpdateResponseEnvelope struct { + Errors []V3PolicyUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []V3PolicyUpdateResponseEnvelopeMessages `json:"messages,required"` + Result V3PolicyUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success V3PolicyUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON v3PolicyUpdateResponseEnvelopeJSON `json:"-"` +} + +// v3PolicyUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [V3PolicyUpdateResponseEnvelope] +type v3PolicyUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3PolicyUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V3PolicyUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3PolicyUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// v3PolicyUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [V3PolicyUpdateResponseEnvelopeErrors] +type v3PolicyUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3PolicyUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V3PolicyUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3PolicyUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// v3PolicyUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [V3PolicyUpdateResponseEnvelopeMessages] +type v3PolicyUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3PolicyUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V3PolicyUpdateResponseEnvelopeSuccess bool + +const ( + V3PolicyUpdateResponseEnvelopeSuccessTrue V3PolicyUpdateResponseEnvelopeSuccess = true +) + +type V3PolicyListParams struct { + // The account id + AccountID param.Field[string] `path:"account_id,required"` +} + +type V3PolicyListResponseEnvelope struct { + Errors []V3PolicyListResponseEnvelopeErrors `json:"errors,required"` + Messages []V3PolicyListResponseEnvelopeMessages `json:"messages,required"` + Result []AaaPolicies `json:"result,required,nullable"` + // Whether the API call was successful + Success V3PolicyListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo V3PolicyListResponseEnvelopeResultInfo `json:"result_info"` + JSON v3PolicyListResponseEnvelopeJSON `json:"-"` +} + +// v3PolicyListResponseEnvelopeJSON contains the JSON metadata for the struct +// [V3PolicyListResponseEnvelope] +type v3PolicyListResponseEnvelopeJSON 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 *V3PolicyListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V3PolicyListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3PolicyListResponseEnvelopeErrorsJSON `json:"-"` +} + +// v3PolicyListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [V3PolicyListResponseEnvelopeErrors] +type v3PolicyListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3PolicyListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V3PolicyListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3PolicyListResponseEnvelopeMessagesJSON `json:"-"` +} + +// v3PolicyListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [V3PolicyListResponseEnvelopeMessages] +type v3PolicyListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3PolicyListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V3PolicyListResponseEnvelopeSuccess bool + +const ( + V3PolicyListResponseEnvelopeSuccessTrue V3PolicyListResponseEnvelopeSuccess = true +) + +type V3PolicyListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON v3PolicyListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// v3PolicyListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [V3PolicyListResponseEnvelopeResultInfo] +type v3PolicyListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3PolicyListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type V3PolicyDeleteParams struct { + // The account id + AccountID param.Field[string] `path:"account_id,required"` +} + +type V3PolicyDeleteResponseEnvelope struct { + Errors []V3PolicyDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []V3PolicyDeleteResponseEnvelopeMessages `json:"messages,required"` + Result V3PolicyDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success V3PolicyDeleteResponseEnvelopeSuccess `json:"success,required"` + ResultInfo V3PolicyDeleteResponseEnvelopeResultInfo `json:"result_info"` + JSON v3PolicyDeleteResponseEnvelopeJSON `json:"-"` +} + +// v3PolicyDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [V3PolicyDeleteResponseEnvelope] +type v3PolicyDeleteResponseEnvelopeJSON 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 *V3PolicyDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V3PolicyDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3PolicyDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// v3PolicyDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [V3PolicyDeleteResponseEnvelopeErrors] +type v3PolicyDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3PolicyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V3PolicyDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3PolicyDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// v3PolicyDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [V3PolicyDeleteResponseEnvelopeMessages] +type v3PolicyDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3PolicyDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V3PolicyDeleteResponseEnvelopeSuccess bool + +const ( + V3PolicyDeleteResponseEnvelopeSuccessTrue V3PolicyDeleteResponseEnvelopeSuccess = true +) + +type V3PolicyDeleteResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON v3PolicyDeleteResponseEnvelopeResultInfoJSON `json:"-"` +} + +// v3PolicyDeleteResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [V3PolicyDeleteResponseEnvelopeResultInfo] +type v3PolicyDeleteResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3PolicyDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type V3PolicyGetParams struct { + // The account id + AccountID param.Field[string] `path:"account_id,required"` +} + +type V3PolicyGetResponseEnvelope struct { + Errors []V3PolicyGetResponseEnvelopeErrors `json:"errors,required"` + Messages []V3PolicyGetResponseEnvelopeMessages `json:"messages,required"` + Result AaaPolicies `json:"result,required"` + // Whether the API call was successful + Success V3PolicyGetResponseEnvelopeSuccess `json:"success,required"` + JSON v3PolicyGetResponseEnvelopeJSON `json:"-"` +} + +// v3PolicyGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [V3PolicyGetResponseEnvelope] +type v3PolicyGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3PolicyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V3PolicyGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3PolicyGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// v3PolicyGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [V3PolicyGetResponseEnvelopeErrors] +type v3PolicyGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3PolicyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V3PolicyGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v3PolicyGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// v3PolicyGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [V3PolicyGetResponseEnvelopeMessages] +type v3PolicyGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V3PolicyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v3PolicyGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V3PolicyGetResponseEnvelopeSuccess bool + +const ( + V3PolicyGetResponseEnvelopeSuccessTrue V3PolicyGetResponseEnvelopeSuccess = true +) diff --git a/alerting/v3policy_test.go b/alerting/v3policy_test.go new file mode 100644 index 00000000000..f44df185b77 --- /dev/null +++ b/alerting/v3policy_test.go @@ -0,0 +1,272 @@ +// File generated from our OpenAPI spec by Stainless. + +package alerting_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/alerting" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestV3PolicyNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Alerting.V3.Policies.New(context.TODO(), alerting.V3PolicyNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + AlertType: cloudflare.F(alerting.V3PolicyNewParamsAlertTypeUniversalSSLEventType), + Enabled: cloudflare.F(true), + Mechanisms: cloudflare.F(map[string][]alerting.V3PolicyNewParamsMechanisms{ + "email": {{ + ID: cloudflare.F[alerting.V3PolicyNewParamsMechanismsID](shared.UnionString("test@example.com")), + }}, + "pagerduty": {{ + ID: cloudflare.F[alerting.V3PolicyNewParamsMechanismsID](shared.UnionString("e8133a15-00a4-4d69-aec1-32f70c51f6e5")), + }}, + "webhooks": {{ + ID: cloudflare.F[alerting.V3PolicyNewParamsMechanismsID](shared.UnionString("14cc1190-5d2b-4b98-a696-c424cb2ad05f")), + }}, + }), + Name: cloudflare.F("SSL Notification Event Policy"), + Description: cloudflare.F("Something describing the policy."), + Filters: cloudflare.F(alerting.V3PolicyNewParamsFilters{ + Actions: cloudflare.F([]string{"string", "string", "string"}), + AffectedASNs: cloudflare.F([]string{"string", "string", "string"}), + AffectedComponents: cloudflare.F([]string{"string", "string", "string"}), + AffectedLocations: cloudflare.F([]string{"string", "string", "string"}), + AirportCode: cloudflare.F([]string{"string", "string", "string"}), + AlertTriggerPreferences: cloudflare.F([]string{"string", "string", "string"}), + AlertTriggerPreferencesValue: cloudflare.F([]alerting.V3PolicyNewParamsFiltersAlertTriggerPreferencesValue{alerting.V3PolicyNewParamsFiltersAlertTriggerPreferencesValue99_0, alerting.V3PolicyNewParamsFiltersAlertTriggerPreferencesValue98_0, alerting.V3PolicyNewParamsFiltersAlertTriggerPreferencesValue97_0}), + Enabled: cloudflare.F([]string{"string", "string", "string"}), + Environment: cloudflare.F([]string{"string", "string", "string"}), + Event: cloudflare.F([]string{"string", "string", "string"}), + EventSource: cloudflare.F([]string{"string", "string", "string"}), + EventType: cloudflare.F([]string{"string", "string", "string"}), + GroupBy: cloudflare.F([]string{"string", "string", "string"}), + HealthCheckID: cloudflare.F([]string{"string", "string", "string"}), + IncidentImpact: cloudflare.F([]alerting.V3PolicyNewParamsFiltersIncidentImpact{alerting.V3PolicyNewParamsFiltersIncidentImpactIncidentImpactNone, alerting.V3PolicyNewParamsFiltersIncidentImpactIncidentImpactMinor, alerting.V3PolicyNewParamsFiltersIncidentImpactIncidentImpactMajor}), + InputID: cloudflare.F([]string{"string", "string", "string"}), + Limit: cloudflare.F([]string{"string", "string", "string"}), + LogoTag: cloudflare.F([]string{"string", "string", "string"}), + MegabitsPerSecond: cloudflare.F([]string{"string", "string", "string"}), + NewHealth: cloudflare.F([]string{"string", "string", "string"}), + NewStatus: cloudflare.F([]string{"string", "string", "string"}), + PacketsPerSecond: cloudflare.F([]string{"string", "string", "string"}), + PoolID: cloudflare.F([]string{"string", "string", "string"}), + Product: cloudflare.F([]string{"string", "string", "string"}), + ProjectID: cloudflare.F([]string{"string", "string", "string"}), + Protocol: cloudflare.F([]string{"string", "string", "string"}), + QueryTag: cloudflare.F([]string{"string", "string", "string"}), + RequestsPerSecond: cloudflare.F([]string{"string", "string", "string"}), + Selectors: cloudflare.F([]string{"string", "string", "string"}), + Services: cloudflare.F([]string{"string", "string", "string"}), + Slo: cloudflare.F([]string{"99.9"}), + Status: cloudflare.F([]string{"string", "string", "string"}), + TargetHostname: cloudflare.F([]string{"string", "string", "string"}), + TargetIP: cloudflare.F([]string{"string", "string", "string"}), + TargetZoneName: cloudflare.F([]string{"string", "string", "string"}), + TrafficExclusions: cloudflare.F([]alerting.V3PolicyNewParamsFiltersTrafficExclusion{alerting.V3PolicyNewParamsFiltersTrafficExclusionSecurityEvents}), + TunnelID: cloudflare.F([]string{"string", "string", "string"}), + TunnelName: cloudflare.F([]string{"string", "string", "string"}), + Where: cloudflare.F([]string{"string", "string", "string"}), + Zones: cloudflare.F([]string{"string", "string", "string"}), + }), + }) + 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 TestV3PolicyUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Alerting.V3.Policies.Update( + context.TODO(), + "0da2b59e-f118-439d-8097-bdfb215203c9", + alerting.V3PolicyUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + AlertType: cloudflare.F(alerting.V3PolicyUpdateParamsAlertTypeUniversalSSLEventType), + Description: cloudflare.F("Something describing the policy."), + Enabled: cloudflare.F(true), + Filters: cloudflare.F(alerting.V3PolicyUpdateParamsFilters{ + Actions: cloudflare.F([]string{"string", "string", "string"}), + AffectedASNs: cloudflare.F([]string{"string", "string", "string"}), + AffectedComponents: cloudflare.F([]string{"string", "string", "string"}), + AffectedLocations: cloudflare.F([]string{"string", "string", "string"}), + AirportCode: cloudflare.F([]string{"string", "string", "string"}), + AlertTriggerPreferences: cloudflare.F([]string{"string", "string", "string"}), + AlertTriggerPreferencesValue: cloudflare.F([]alerting.V3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue{alerting.V3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue99_0, alerting.V3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue98_0, alerting.V3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue97_0}), + Enabled: cloudflare.F([]string{"string", "string", "string"}), + Environment: cloudflare.F([]string{"string", "string", "string"}), + Event: cloudflare.F([]string{"string", "string", "string"}), + EventSource: cloudflare.F([]string{"string", "string", "string"}), + EventType: cloudflare.F([]string{"string", "string", "string"}), + GroupBy: cloudflare.F([]string{"string", "string", "string"}), + HealthCheckID: cloudflare.F([]string{"string", "string", "string"}), + IncidentImpact: cloudflare.F([]alerting.V3PolicyUpdateParamsFiltersIncidentImpact{alerting.V3PolicyUpdateParamsFiltersIncidentImpactIncidentImpactNone, alerting.V3PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMinor, alerting.V3PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMajor}), + InputID: cloudflare.F([]string{"string", "string", "string"}), + Limit: cloudflare.F([]string{"string", "string", "string"}), + LogoTag: cloudflare.F([]string{"string", "string", "string"}), + MegabitsPerSecond: cloudflare.F([]string{"string", "string", "string"}), + NewHealth: cloudflare.F([]string{"string", "string", "string"}), + NewStatus: cloudflare.F([]string{"string", "string", "string"}), + PacketsPerSecond: cloudflare.F([]string{"string", "string", "string"}), + PoolID: cloudflare.F([]string{"string", "string", "string"}), + Product: cloudflare.F([]string{"string", "string", "string"}), + ProjectID: cloudflare.F([]string{"string", "string", "string"}), + Protocol: cloudflare.F([]string{"string", "string", "string"}), + QueryTag: cloudflare.F([]string{"string", "string", "string"}), + RequestsPerSecond: cloudflare.F([]string{"string", "string", "string"}), + Selectors: cloudflare.F([]string{"string", "string", "string"}), + Services: cloudflare.F([]string{"string", "string", "string"}), + Slo: cloudflare.F([]string{"99.9"}), + Status: cloudflare.F([]string{"string", "string", "string"}), + TargetHostname: cloudflare.F([]string{"string", "string", "string"}), + TargetIP: cloudflare.F([]string{"string", "string", "string"}), + TargetZoneName: cloudflare.F([]string{"string", "string", "string"}), + TrafficExclusions: cloudflare.F([]alerting.V3PolicyUpdateParamsFiltersTrafficExclusion{alerting.V3PolicyUpdateParamsFiltersTrafficExclusionSecurityEvents}), + TunnelID: cloudflare.F([]string{"string", "string", "string"}), + TunnelName: cloudflare.F([]string{"string", "string", "string"}), + Where: cloudflare.F([]string{"string", "string", "string"}), + Zones: cloudflare.F([]string{"string", "string", "string"}), + }), + Mechanisms: cloudflare.F(map[string][]alerting.V3PolicyUpdateParamsMechanisms{ + "email": {{ + ID: cloudflare.F[alerting.V3PolicyUpdateParamsMechanismsID](shared.UnionString("test@example.com")), + }}, + "pagerduty": {{ + ID: cloudflare.F[alerting.V3PolicyUpdateParamsMechanismsID](shared.UnionString("e8133a15-00a4-4d69-aec1-32f70c51f6e5")), + }}, + "webhooks": {{ + ID: cloudflare.F[alerting.V3PolicyUpdateParamsMechanismsID](shared.UnionString("14cc1190-5d2b-4b98-a696-c424cb2ad05f")), + }}, + }), + Name: cloudflare.F("SSL Notification Event Policy"), + }, + ) + 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 TestV3PolicyList(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("user@example.com"), + ) + _, err := client.Alerting.V3.Policies.List(context.TODO(), alerting.V3PolicyListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestV3PolicyDelete(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("user@example.com"), + ) + _, err := client.Alerting.V3.Policies.Delete( + context.TODO(), + "0da2b59e-f118-439d-8097-bdfb215203c9", + alerting.V3PolicyDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestV3PolicyGet(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("user@example.com"), + ) + _, err := client.Alerting.V3.Policies.Get( + context.TODO(), + "0da2b59e-f118-439d-8097-bdfb215203c9", + alerting.V3PolicyGetParams{ + AccountID: cloudflare.F("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/alertingv3.go b/alertingv3.go deleted file mode 100644 index a7ac2880c93..00000000000 --- a/alertingv3.go +++ /dev/null @@ -1,197 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// AlertingV3Service 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 [NewAlertingV3Service] method instead. -type AlertingV3Service struct { - Options []option.RequestOption - Destinations *AlertingV3DestinationService - Histories *AlertingV3HistoryService - Policies *AlertingV3PolicyService -} - -// NewAlertingV3Service 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 NewAlertingV3Service(opts ...option.RequestOption) (r *AlertingV3Service) { - r = &AlertingV3Service{} - r.Options = opts - r.Destinations = NewAlertingV3DestinationService(opts...) - r.Histories = NewAlertingV3HistoryService(opts...) - r.Policies = NewAlertingV3PolicyService(opts...) - return -} - -// Gets a list of all alert types for which an account is eligible. -func (r *AlertingV3Service) List(ctx context.Context, query AlertingV3ListParams, opts ...option.RequestOption) (res *AlertingV3ListResponse, err error) { - opts = append(r.Options[:], opts...) - var env AlertingV3ListResponseEnvelope - path := fmt.Sprintf("accounts/%s/alerting/v3/available_alerts", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [AlertingV3ListResponseUnknown], -// [AlertingV3ListResponseArray] or [shared.UnionString]. -type AlertingV3ListResponse interface { - ImplementsAlertingV3ListResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AlertingV3ListResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AlertingV3ListResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type AlertingV3ListResponseArray []interface{} - -func (r AlertingV3ListResponseArray) ImplementsAlertingV3ListResponse() {} - -type AlertingV3ListParams struct { - // The account id - AccountID param.Field[string] `path:"account_id,required"` -} - -type AlertingV3ListResponseEnvelope struct { - Errors []AlertingV3ListResponseEnvelopeErrors `json:"errors,required"` - Messages []AlertingV3ListResponseEnvelopeMessages `json:"messages,required"` - Result AlertingV3ListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AlertingV3ListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AlertingV3ListResponseEnvelopeResultInfo `json:"result_info"` - JSON alertingV3ListResponseEnvelopeJSON `json:"-"` -} - -// alertingV3ListResponseEnvelopeJSON contains the JSON metadata for the struct -// [AlertingV3ListResponseEnvelope] -type alertingV3ListResponseEnvelopeJSON 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 *AlertingV3ListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3ListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AlertingV3ListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3ListResponseEnvelopeErrorsJSON `json:"-"` -} - -// alertingV3ListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AlertingV3ListResponseEnvelopeErrors] -type alertingV3ListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3ListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3ListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AlertingV3ListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3ListResponseEnvelopeMessagesJSON `json:"-"` -} - -// alertingV3ListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AlertingV3ListResponseEnvelopeMessages] -type alertingV3ListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3ListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3ListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AlertingV3ListResponseEnvelopeSuccess bool - -const ( - AlertingV3ListResponseEnvelopeSuccessTrue AlertingV3ListResponseEnvelopeSuccess = true -) - -type AlertingV3ListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON alertingV3ListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// alertingV3ListResponseEnvelopeResultInfoJSON contains the JSON metadata for the -// struct [AlertingV3ListResponseEnvelopeResultInfo] -type alertingV3ListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3ListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3ListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/alertingv3_test.go b/alertingv3_test.go deleted file mode 100644 index 392e7721989..00000000000 --- a/alertingv3_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAlertingV3List(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("user@example.com"), - ) - _, err := client.Alerting.V3.List(context.TODO(), cloudflare.AlertingV3ListParams{ - AccountID: cloudflare.F("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/alertingv3destination.go b/alertingv3destination.go deleted file mode 100644 index d57b5c0f7b5..00000000000 --- a/alertingv3destination.go +++ /dev/null @@ -1,31 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// AlertingV3DestinationService 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 [NewAlertingV3DestinationService] -// method instead. -type AlertingV3DestinationService struct { - Options []option.RequestOption - Eligible *AlertingV3DestinationEligibleService - Pagerduty *AlertingV3DestinationPagerdutyService - Webhooks *AlertingV3DestinationWebhookService -} - -// NewAlertingV3DestinationService 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 NewAlertingV3DestinationService(opts ...option.RequestOption) (r *AlertingV3DestinationService) { - r = &AlertingV3DestinationService{} - r.Options = opts - r.Eligible = NewAlertingV3DestinationEligibleService(opts...) - r.Pagerduty = NewAlertingV3DestinationPagerdutyService(opts...) - r.Webhooks = NewAlertingV3DestinationWebhookService(opts...) - return -} diff --git a/alertingv3destinationeligible.go b/alertingv3destinationeligible.go deleted file mode 100644 index 851d00de1a3..00000000000 --- a/alertingv3destinationeligible.go +++ /dev/null @@ -1,195 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// AlertingV3DestinationEligibleService 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 -// [NewAlertingV3DestinationEligibleService] method instead. -type AlertingV3DestinationEligibleService struct { - Options []option.RequestOption -} - -// NewAlertingV3DestinationEligibleService 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 NewAlertingV3DestinationEligibleService(opts ...option.RequestOption) (r *AlertingV3DestinationEligibleService) { - r = &AlertingV3DestinationEligibleService{} - r.Options = opts - return -} - -// Get a list of all delivery mechanism types for which an account is eligible. -func (r *AlertingV3DestinationEligibleService) Get(ctx context.Context, query AlertingV3DestinationEligibleGetParams, opts ...option.RequestOption) (res *AlertingV3DestinationEligibleGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env AlertingV3DestinationEligibleGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/eligible", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [AlertingV3DestinationEligibleGetResponseUnknown], -// [AlertingV3DestinationEligibleGetResponseArray] or [shared.UnionString]. -type AlertingV3DestinationEligibleGetResponse interface { - ImplementsAlertingV3DestinationEligibleGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AlertingV3DestinationEligibleGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AlertingV3DestinationEligibleGetResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type AlertingV3DestinationEligibleGetResponseArray []interface{} - -func (r AlertingV3DestinationEligibleGetResponseArray) ImplementsAlertingV3DestinationEligibleGetResponse() { -} - -type AlertingV3DestinationEligibleGetParams struct { - // The account id - AccountID param.Field[string] `path:"account_id,required"` -} - -type AlertingV3DestinationEligibleGetResponseEnvelope struct { - Errors []AlertingV3DestinationEligibleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AlertingV3DestinationEligibleGetResponseEnvelopeMessages `json:"messages,required"` - Result AlertingV3DestinationEligibleGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AlertingV3DestinationEligibleGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AlertingV3DestinationEligibleGetResponseEnvelopeResultInfo `json:"result_info"` - JSON alertingV3DestinationEligibleGetResponseEnvelopeJSON `json:"-"` -} - -// alertingV3DestinationEligibleGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [AlertingV3DestinationEligibleGetResponseEnvelope] -type alertingV3DestinationEligibleGetResponseEnvelopeJSON 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 *AlertingV3DestinationEligibleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationEligibleGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationEligibleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationEligibleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// alertingV3DestinationEligibleGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AlertingV3DestinationEligibleGetResponseEnvelopeErrors] -type alertingV3DestinationEligibleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationEligibleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationEligibleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationEligibleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationEligibleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// alertingV3DestinationEligibleGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [AlertingV3DestinationEligibleGetResponseEnvelopeMessages] -type alertingV3DestinationEligibleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationEligibleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationEligibleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AlertingV3DestinationEligibleGetResponseEnvelopeSuccess bool - -const ( - AlertingV3DestinationEligibleGetResponseEnvelopeSuccessTrue AlertingV3DestinationEligibleGetResponseEnvelopeSuccess = true -) - -type AlertingV3DestinationEligibleGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON alertingV3DestinationEligibleGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// alertingV3DestinationEligibleGetResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [AlertingV3DestinationEligibleGetResponseEnvelopeResultInfo] -type alertingV3DestinationEligibleGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationEligibleGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationEligibleGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/alertingv3destinationeligible_test.go b/alertingv3destinationeligible_test.go deleted file mode 100644 index c4f991dcd43..00000000000 --- a/alertingv3destinationeligible_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAlertingV3DestinationEligibleGet(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("user@example.com"), - ) - _, err := client.Alerting.V3.Destinations.Eligible.Get(context.TODO(), cloudflare.AlertingV3DestinationEligibleGetParams{ - AccountID: cloudflare.F("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/alertingv3destinationpagerduty.go b/alertingv3destinationpagerduty.go deleted file mode 100644 index 8c049cce1b2..00000000000 --- a/alertingv3destinationpagerduty.go +++ /dev/null @@ -1,602 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// AlertingV3DestinationPagerdutyService 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 -// [NewAlertingV3DestinationPagerdutyService] method instead. -type AlertingV3DestinationPagerdutyService struct { - Options []option.RequestOption -} - -// NewAlertingV3DestinationPagerdutyService 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 NewAlertingV3DestinationPagerdutyService(opts ...option.RequestOption) (r *AlertingV3DestinationPagerdutyService) { - r = &AlertingV3DestinationPagerdutyService{} - r.Options = opts - return -} - -// Creates a new token for integrating with PagerDuty. -func (r *AlertingV3DestinationPagerdutyService) New(ctx context.Context, body AlertingV3DestinationPagerdutyNewParams, opts ...option.RequestOption) (res *AlertingV3DestinationPagerdutyNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env AlertingV3DestinationPagerdutyNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/pagerduty/connect", body.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes all the PagerDuty Services connected to the account. -func (r *AlertingV3DestinationPagerdutyService) Delete(ctx context.Context, body AlertingV3DestinationPagerdutyDeleteParams, opts ...option.RequestOption) (res *AlertingV3DestinationPagerdutyDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env AlertingV3DestinationPagerdutyDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/pagerduty", body.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a list of all configured PagerDuty services. -func (r *AlertingV3DestinationPagerdutyService) Get(ctx context.Context, query AlertingV3DestinationPagerdutyGetParams, opts ...option.RequestOption) (res *[]AlertingV3DestinationPagerdutyGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env AlertingV3DestinationPagerdutyGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/pagerduty", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Links PagerDuty with the account using the integration token. -func (r *AlertingV3DestinationPagerdutyService) Link(ctx context.Context, tokenID string, query AlertingV3DestinationPagerdutyLinkParams, opts ...option.RequestOption) (res *AlertingV3DestinationPagerdutyLinkResponse, err error) { - opts = append(r.Options[:], opts...) - var env AlertingV3DestinationPagerdutyLinkResponseEnvelope - path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/pagerduty/connect/%s", query.AccountID, tokenID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type AlertingV3DestinationPagerdutyNewResponse struct { - // UUID - ID string `json:"id"` - JSON alertingV3DestinationPagerdutyNewResponseJSON `json:"-"` -} - -// alertingV3DestinationPagerdutyNewResponseJSON contains the JSON metadata for the -// struct [AlertingV3DestinationPagerdutyNewResponse] -type alertingV3DestinationPagerdutyNewResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationPagerdutyNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationPagerdutyNewResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [AlertingV3DestinationPagerdutyDeleteResponseUnknown], -// [AlertingV3DestinationPagerdutyDeleteResponseArray] or [shared.UnionString]. -type AlertingV3DestinationPagerdutyDeleteResponse interface { - ImplementsAlertingV3DestinationPagerdutyDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AlertingV3DestinationPagerdutyDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AlertingV3DestinationPagerdutyDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type AlertingV3DestinationPagerdutyDeleteResponseArray []interface{} - -func (r AlertingV3DestinationPagerdutyDeleteResponseArray) ImplementsAlertingV3DestinationPagerdutyDeleteResponse() { -} - -type AlertingV3DestinationPagerdutyGetResponse struct { - // UUID - ID string `json:"id"` - // The name of the pagerduty service. - Name string `json:"name"` - JSON alertingV3DestinationPagerdutyGetResponseJSON `json:"-"` -} - -// alertingV3DestinationPagerdutyGetResponseJSON contains the JSON metadata for the -// struct [AlertingV3DestinationPagerdutyGetResponse] -type alertingV3DestinationPagerdutyGetResponseJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationPagerdutyGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationPagerdutyGetResponseJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationPagerdutyLinkResponse struct { - // UUID - ID string `json:"id"` - JSON alertingV3DestinationPagerdutyLinkResponseJSON `json:"-"` -} - -// alertingV3DestinationPagerdutyLinkResponseJSON contains the JSON metadata for -// the struct [AlertingV3DestinationPagerdutyLinkResponse] -type alertingV3DestinationPagerdutyLinkResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationPagerdutyLinkResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationPagerdutyLinkResponseJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationPagerdutyNewParams struct { - // The account id - AccountID param.Field[string] `path:"account_id,required"` -} - -type AlertingV3DestinationPagerdutyNewResponseEnvelope struct { - Errors []AlertingV3DestinationPagerdutyNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AlertingV3DestinationPagerdutyNewResponseEnvelopeMessages `json:"messages,required"` - Result AlertingV3DestinationPagerdutyNewResponse `json:"result,required"` - // Whether the API call was successful - Success AlertingV3DestinationPagerdutyNewResponseEnvelopeSuccess `json:"success,required"` - JSON alertingV3DestinationPagerdutyNewResponseEnvelopeJSON `json:"-"` -} - -// alertingV3DestinationPagerdutyNewResponseEnvelopeJSON contains the JSON metadata -// for the struct [AlertingV3DestinationPagerdutyNewResponseEnvelope] -type alertingV3DestinationPagerdutyNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationPagerdutyNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationPagerdutyNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationPagerdutyNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationPagerdutyNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// alertingV3DestinationPagerdutyNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [AlertingV3DestinationPagerdutyNewResponseEnvelopeErrors] -type alertingV3DestinationPagerdutyNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationPagerdutyNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationPagerdutyNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationPagerdutyNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationPagerdutyNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// alertingV3DestinationPagerdutyNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [AlertingV3DestinationPagerdutyNewResponseEnvelopeMessages] -type alertingV3DestinationPagerdutyNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationPagerdutyNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationPagerdutyNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AlertingV3DestinationPagerdutyNewResponseEnvelopeSuccess bool - -const ( - AlertingV3DestinationPagerdutyNewResponseEnvelopeSuccessTrue AlertingV3DestinationPagerdutyNewResponseEnvelopeSuccess = true -) - -type AlertingV3DestinationPagerdutyDeleteParams struct { - // The account id - AccountID param.Field[string] `path:"account_id,required"` -} - -type AlertingV3DestinationPagerdutyDeleteResponseEnvelope struct { - Errors []AlertingV3DestinationPagerdutyDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AlertingV3DestinationPagerdutyDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AlertingV3DestinationPagerdutyDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AlertingV3DestinationPagerdutyDeleteResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AlertingV3DestinationPagerdutyDeleteResponseEnvelopeResultInfo `json:"result_info"` - JSON alertingV3DestinationPagerdutyDeleteResponseEnvelopeJSON `json:"-"` -} - -// alertingV3DestinationPagerdutyDeleteResponseEnvelopeJSON contains the JSON -// metadata for the struct [AlertingV3DestinationPagerdutyDeleteResponseEnvelope] -type alertingV3DestinationPagerdutyDeleteResponseEnvelopeJSON 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 *AlertingV3DestinationPagerdutyDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationPagerdutyDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationPagerdutyDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationPagerdutyDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// alertingV3DestinationPagerdutyDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [AlertingV3DestinationPagerdutyDeleteResponseEnvelopeErrors] -type alertingV3DestinationPagerdutyDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationPagerdutyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationPagerdutyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationPagerdutyDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationPagerdutyDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// alertingV3DestinationPagerdutyDeleteResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [AlertingV3DestinationPagerdutyDeleteResponseEnvelopeMessages] -type alertingV3DestinationPagerdutyDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationPagerdutyDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationPagerdutyDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AlertingV3DestinationPagerdutyDeleteResponseEnvelopeSuccess bool - -const ( - AlertingV3DestinationPagerdutyDeleteResponseEnvelopeSuccessTrue AlertingV3DestinationPagerdutyDeleteResponseEnvelopeSuccess = true -) - -type AlertingV3DestinationPagerdutyDeleteResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON alertingV3DestinationPagerdutyDeleteResponseEnvelopeResultInfoJSON `json:"-"` -} - -// alertingV3DestinationPagerdutyDeleteResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [AlertingV3DestinationPagerdutyDeleteResponseEnvelopeResultInfo] -type alertingV3DestinationPagerdutyDeleteResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationPagerdutyDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationPagerdutyDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationPagerdutyGetParams struct { - // The account id - AccountID param.Field[string] `path:"account_id,required"` -} - -type AlertingV3DestinationPagerdutyGetResponseEnvelope struct { - Errors []AlertingV3DestinationPagerdutyGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AlertingV3DestinationPagerdutyGetResponseEnvelopeMessages `json:"messages,required"` - Result []AlertingV3DestinationPagerdutyGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AlertingV3DestinationPagerdutyGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AlertingV3DestinationPagerdutyGetResponseEnvelopeResultInfo `json:"result_info"` - JSON alertingV3DestinationPagerdutyGetResponseEnvelopeJSON `json:"-"` -} - -// alertingV3DestinationPagerdutyGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [AlertingV3DestinationPagerdutyGetResponseEnvelope] -type alertingV3DestinationPagerdutyGetResponseEnvelopeJSON 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 *AlertingV3DestinationPagerdutyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationPagerdutyGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationPagerdutyGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationPagerdutyGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// alertingV3DestinationPagerdutyGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [AlertingV3DestinationPagerdutyGetResponseEnvelopeErrors] -type alertingV3DestinationPagerdutyGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationPagerdutyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationPagerdutyGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationPagerdutyGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationPagerdutyGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// alertingV3DestinationPagerdutyGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [AlertingV3DestinationPagerdutyGetResponseEnvelopeMessages] -type alertingV3DestinationPagerdutyGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationPagerdutyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationPagerdutyGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AlertingV3DestinationPagerdutyGetResponseEnvelopeSuccess bool - -const ( - AlertingV3DestinationPagerdutyGetResponseEnvelopeSuccessTrue AlertingV3DestinationPagerdutyGetResponseEnvelopeSuccess = true -) - -type AlertingV3DestinationPagerdutyGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON alertingV3DestinationPagerdutyGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// alertingV3DestinationPagerdutyGetResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [AlertingV3DestinationPagerdutyGetResponseEnvelopeResultInfo] -type alertingV3DestinationPagerdutyGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationPagerdutyGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationPagerdutyGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationPagerdutyLinkParams struct { - // The account id - AccountID param.Field[string] `path:"account_id,required"` -} - -type AlertingV3DestinationPagerdutyLinkResponseEnvelope struct { - Errors []AlertingV3DestinationPagerdutyLinkResponseEnvelopeErrors `json:"errors,required"` - Messages []AlertingV3DestinationPagerdutyLinkResponseEnvelopeMessages `json:"messages,required"` - Result AlertingV3DestinationPagerdutyLinkResponse `json:"result,required"` - // Whether the API call was successful - Success AlertingV3DestinationPagerdutyLinkResponseEnvelopeSuccess `json:"success,required"` - JSON alertingV3DestinationPagerdutyLinkResponseEnvelopeJSON `json:"-"` -} - -// alertingV3DestinationPagerdutyLinkResponseEnvelopeJSON contains the JSON -// metadata for the struct [AlertingV3DestinationPagerdutyLinkResponseEnvelope] -type alertingV3DestinationPagerdutyLinkResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationPagerdutyLinkResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationPagerdutyLinkResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationPagerdutyLinkResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationPagerdutyLinkResponseEnvelopeErrorsJSON `json:"-"` -} - -// alertingV3DestinationPagerdutyLinkResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [AlertingV3DestinationPagerdutyLinkResponseEnvelopeErrors] -type alertingV3DestinationPagerdutyLinkResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationPagerdutyLinkResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationPagerdutyLinkResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationPagerdutyLinkResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationPagerdutyLinkResponseEnvelopeMessagesJSON `json:"-"` -} - -// alertingV3DestinationPagerdutyLinkResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [AlertingV3DestinationPagerdutyLinkResponseEnvelopeMessages] -type alertingV3DestinationPagerdutyLinkResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationPagerdutyLinkResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationPagerdutyLinkResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AlertingV3DestinationPagerdutyLinkResponseEnvelopeSuccess bool - -const ( - AlertingV3DestinationPagerdutyLinkResponseEnvelopeSuccessTrue AlertingV3DestinationPagerdutyLinkResponseEnvelopeSuccess = true -) diff --git a/alertingv3destinationpagerduty_test.go b/alertingv3destinationpagerduty_test.go deleted file mode 100644 index 5d562425b72..00000000000 --- a/alertingv3destinationpagerduty_test.go +++ /dev/null @@ -1,122 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAlertingV3DestinationPagerdutyNew(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("user@example.com"), - ) - _, err := client.Alerting.V3.Destinations.Pagerduty.New(context.TODO(), cloudflare.AlertingV3DestinationPagerdutyNewParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestAlertingV3DestinationPagerdutyDelete(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("user@example.com"), - ) - _, err := client.Alerting.V3.Destinations.Pagerduty.Delete(context.TODO(), cloudflare.AlertingV3DestinationPagerdutyDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestAlertingV3DestinationPagerdutyGet(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("user@example.com"), - ) - _, err := client.Alerting.V3.Destinations.Pagerduty.Get(context.TODO(), cloudflare.AlertingV3DestinationPagerdutyGetParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestAlertingV3DestinationPagerdutyLink(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("user@example.com"), - ) - _, err := client.Alerting.V3.Destinations.Pagerduty.Link( - context.TODO(), - "8c71e667571b4f61b94d9e4b12158038", - cloudflare.AlertingV3DestinationPagerdutyLinkParams{ - AccountID: cloudflare.F("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/alertingv3destinationwebhook.go b/alertingv3destinationwebhook.go deleted file mode 100644 index 159cf2cdfbd..00000000000 --- a/alertingv3destinationwebhook.go +++ /dev/null @@ -1,816 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// AlertingV3DestinationWebhookService 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 -// [NewAlertingV3DestinationWebhookService] method instead. -type AlertingV3DestinationWebhookService struct { - Options []option.RequestOption -} - -// NewAlertingV3DestinationWebhookService 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 NewAlertingV3DestinationWebhookService(opts ...option.RequestOption) (r *AlertingV3DestinationWebhookService) { - r = &AlertingV3DestinationWebhookService{} - r.Options = opts - return -} - -// Creates a new webhook destination. -func (r *AlertingV3DestinationWebhookService) New(ctx context.Context, params AlertingV3DestinationWebhookNewParams, opts ...option.RequestOption) (res *AlertingV3DestinationWebhookNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env AlertingV3DestinationWebhookNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/webhooks", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update a webhook destination. -func (r *AlertingV3DestinationWebhookService) Update(ctx context.Context, webhookID string, params AlertingV3DestinationWebhookUpdateParams, opts ...option.RequestOption) (res *AlertingV3DestinationWebhookUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env AlertingV3DestinationWebhookUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/webhooks/%s", params.AccountID, webhookID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets a list of all configured webhook destinations. -func (r *AlertingV3DestinationWebhookService) List(ctx context.Context, query AlertingV3DestinationWebhookListParams, opts ...option.RequestOption) (res *[]AlertingV3DestinationWebhookListResponse, err error) { - opts = append(r.Options[:], opts...) - var env AlertingV3DestinationWebhookListResponseEnvelope - path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/webhooks", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a configured webhook destination. -func (r *AlertingV3DestinationWebhookService) Delete(ctx context.Context, webhookID string, body AlertingV3DestinationWebhookDeleteParams, opts ...option.RequestOption) (res *AlertingV3DestinationWebhookDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env AlertingV3DestinationWebhookDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/webhooks/%s", body.AccountID, webhookID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get details for a single webhooks destination. -func (r *AlertingV3DestinationWebhookService) Get(ctx context.Context, webhookID string, query AlertingV3DestinationWebhookGetParams, opts ...option.RequestOption) (res *AlertingV3DestinationWebhookGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env AlertingV3DestinationWebhookGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/webhooks/%s", query.AccountID, webhookID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type AlertingV3DestinationWebhookNewResponse struct { - // UUID - ID string `json:"id"` - JSON alertingV3DestinationWebhookNewResponseJSON `json:"-"` -} - -// alertingV3DestinationWebhookNewResponseJSON contains the JSON metadata for the -// struct [AlertingV3DestinationWebhookNewResponse] -type alertingV3DestinationWebhookNewResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookNewResponseJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationWebhookUpdateResponse struct { - // UUID - ID string `json:"id"` - JSON alertingV3DestinationWebhookUpdateResponseJSON `json:"-"` -} - -// alertingV3DestinationWebhookUpdateResponseJSON contains the JSON metadata for -// the struct [AlertingV3DestinationWebhookUpdateResponse] -type alertingV3DestinationWebhookUpdateResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationWebhookListResponse struct { - // The unique identifier of a webhook - ID string `json:"id"` - // Timestamp of when the webhook destination was created. - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Timestamp of the last time an attempt to dispatch a notification to this webhook - // failed. - LastFailure time.Time `json:"last_failure" format:"date-time"` - // Timestamp of the last time Cloudflare was able to successfully dispatch a - // notification using this webhook. - LastSuccess time.Time `json:"last_success" format:"date-time"` - // The name of the webhook destination. This will be included in the request body - // when you receive a webhook notification. - Name string `json:"name"` - // Optional secret that will be passed in the `cf-webhook-auth` header when - // dispatching generic webhook notifications or formatted for supported - // destinations. Secrets are not returned in any API response body. - Secret string `json:"secret"` - // Type of webhook endpoint. - Type AlertingV3DestinationWebhookListResponseType `json:"type"` - // The POST endpoint to call when dispatching a notification. - URL string `json:"url"` - JSON alertingV3DestinationWebhookListResponseJSON `json:"-"` -} - -// alertingV3DestinationWebhookListResponseJSON contains the JSON metadata for the -// struct [AlertingV3DestinationWebhookListResponse] -type alertingV3DestinationWebhookListResponseJSON struct { - ID apijson.Field - CreatedAt apijson.Field - LastFailure apijson.Field - LastSuccess apijson.Field - Name apijson.Field - Secret apijson.Field - Type apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookListResponseJSON) RawJSON() string { - return r.raw -} - -// Type of webhook endpoint. -type AlertingV3DestinationWebhookListResponseType string - -const ( - AlertingV3DestinationWebhookListResponseTypeSlack AlertingV3DestinationWebhookListResponseType = "slack" - AlertingV3DestinationWebhookListResponseTypeGeneric AlertingV3DestinationWebhookListResponseType = "generic" - AlertingV3DestinationWebhookListResponseTypeGchat AlertingV3DestinationWebhookListResponseType = "gchat" -) - -// Union satisfied by [AlertingV3DestinationWebhookDeleteResponseUnknown], -// [AlertingV3DestinationWebhookDeleteResponseArray] or [shared.UnionString]. -type AlertingV3DestinationWebhookDeleteResponse interface { - ImplementsAlertingV3DestinationWebhookDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AlertingV3DestinationWebhookDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AlertingV3DestinationWebhookDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type AlertingV3DestinationWebhookDeleteResponseArray []interface{} - -func (r AlertingV3DestinationWebhookDeleteResponseArray) ImplementsAlertingV3DestinationWebhookDeleteResponse() { -} - -type AlertingV3DestinationWebhookGetResponse struct { - // The unique identifier of a webhook - ID string `json:"id"` - // Timestamp of when the webhook destination was created. - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Timestamp of the last time an attempt to dispatch a notification to this webhook - // failed. - LastFailure time.Time `json:"last_failure" format:"date-time"` - // Timestamp of the last time Cloudflare was able to successfully dispatch a - // notification using this webhook. - LastSuccess time.Time `json:"last_success" format:"date-time"` - // The name of the webhook destination. This will be included in the request body - // when you receive a webhook notification. - Name string `json:"name"` - // Optional secret that will be passed in the `cf-webhook-auth` header when - // dispatching generic webhook notifications or formatted for supported - // destinations. Secrets are not returned in any API response body. - Secret string `json:"secret"` - // Type of webhook endpoint. - Type AlertingV3DestinationWebhookGetResponseType `json:"type"` - // The POST endpoint to call when dispatching a notification. - URL string `json:"url"` - JSON alertingV3DestinationWebhookGetResponseJSON `json:"-"` -} - -// alertingV3DestinationWebhookGetResponseJSON contains the JSON metadata for the -// struct [AlertingV3DestinationWebhookGetResponse] -type alertingV3DestinationWebhookGetResponseJSON struct { - ID apijson.Field - CreatedAt apijson.Field - LastFailure apijson.Field - LastSuccess apijson.Field - Name apijson.Field - Secret apijson.Field - Type apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookGetResponseJSON) RawJSON() string { - return r.raw -} - -// Type of webhook endpoint. -type AlertingV3DestinationWebhookGetResponseType string - -const ( - AlertingV3DestinationWebhookGetResponseTypeSlack AlertingV3DestinationWebhookGetResponseType = "slack" - AlertingV3DestinationWebhookGetResponseTypeGeneric AlertingV3DestinationWebhookGetResponseType = "generic" - AlertingV3DestinationWebhookGetResponseTypeGchat AlertingV3DestinationWebhookGetResponseType = "gchat" -) - -type AlertingV3DestinationWebhookNewParams struct { - // The account id - AccountID param.Field[string] `path:"account_id,required"` - // The name of the webhook destination. This will be included in the request body - // when you receive a webhook notification. - Name param.Field[string] `json:"name,required"` - // The POST endpoint to call when dispatching a notification. - URL param.Field[string] `json:"url,required"` - // Optional secret that will be passed in the `cf-webhook-auth` header when - // dispatching generic webhook notifications or formatted for supported - // destinations. Secrets are not returned in any API response body. - Secret param.Field[string] `json:"secret"` -} - -func (r AlertingV3DestinationWebhookNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AlertingV3DestinationWebhookNewResponseEnvelope struct { - Errors []AlertingV3DestinationWebhookNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AlertingV3DestinationWebhookNewResponseEnvelopeMessages `json:"messages,required"` - Result AlertingV3DestinationWebhookNewResponse `json:"result,required"` - // Whether the API call was successful - Success AlertingV3DestinationWebhookNewResponseEnvelopeSuccess `json:"success,required"` - JSON alertingV3DestinationWebhookNewResponseEnvelopeJSON `json:"-"` -} - -// alertingV3DestinationWebhookNewResponseEnvelopeJSON contains the JSON metadata -// for the struct [AlertingV3DestinationWebhookNewResponseEnvelope] -type alertingV3DestinationWebhookNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationWebhookNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationWebhookNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// alertingV3DestinationWebhookNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AlertingV3DestinationWebhookNewResponseEnvelopeErrors] -type alertingV3DestinationWebhookNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationWebhookNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationWebhookNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// alertingV3DestinationWebhookNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [AlertingV3DestinationWebhookNewResponseEnvelopeMessages] -type alertingV3DestinationWebhookNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AlertingV3DestinationWebhookNewResponseEnvelopeSuccess bool - -const ( - AlertingV3DestinationWebhookNewResponseEnvelopeSuccessTrue AlertingV3DestinationWebhookNewResponseEnvelopeSuccess = true -) - -type AlertingV3DestinationWebhookUpdateParams struct { - // The account id - AccountID param.Field[string] `path:"account_id,required"` - // The name of the webhook destination. This will be included in the request body - // when you receive a webhook notification. - Name param.Field[string] `json:"name,required"` - // The POST endpoint to call when dispatching a notification. - URL param.Field[string] `json:"url,required"` - // Optional secret that will be passed in the `cf-webhook-auth` header when - // dispatching generic webhook notifications or formatted for supported - // destinations. Secrets are not returned in any API response body. - Secret param.Field[string] `json:"secret"` -} - -func (r AlertingV3DestinationWebhookUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AlertingV3DestinationWebhookUpdateResponseEnvelope struct { - Errors []AlertingV3DestinationWebhookUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AlertingV3DestinationWebhookUpdateResponseEnvelopeMessages `json:"messages,required"` - Result AlertingV3DestinationWebhookUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success AlertingV3DestinationWebhookUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON alertingV3DestinationWebhookUpdateResponseEnvelopeJSON `json:"-"` -} - -// alertingV3DestinationWebhookUpdateResponseEnvelopeJSON contains the JSON -// metadata for the struct [AlertingV3DestinationWebhookUpdateResponseEnvelope] -type alertingV3DestinationWebhookUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationWebhookUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationWebhookUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// alertingV3DestinationWebhookUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [AlertingV3DestinationWebhookUpdateResponseEnvelopeErrors] -type alertingV3DestinationWebhookUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationWebhookUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationWebhookUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// alertingV3DestinationWebhookUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [AlertingV3DestinationWebhookUpdateResponseEnvelopeMessages] -type alertingV3DestinationWebhookUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AlertingV3DestinationWebhookUpdateResponseEnvelopeSuccess bool - -const ( - AlertingV3DestinationWebhookUpdateResponseEnvelopeSuccessTrue AlertingV3DestinationWebhookUpdateResponseEnvelopeSuccess = true -) - -type AlertingV3DestinationWebhookListParams struct { - // The account id - AccountID param.Field[string] `path:"account_id,required"` -} - -type AlertingV3DestinationWebhookListResponseEnvelope struct { - Errors []AlertingV3DestinationWebhookListResponseEnvelopeErrors `json:"errors,required"` - Messages []AlertingV3DestinationWebhookListResponseEnvelopeMessages `json:"messages,required"` - Result []AlertingV3DestinationWebhookListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AlertingV3DestinationWebhookListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AlertingV3DestinationWebhookListResponseEnvelopeResultInfo `json:"result_info"` - JSON alertingV3DestinationWebhookListResponseEnvelopeJSON `json:"-"` -} - -// alertingV3DestinationWebhookListResponseEnvelopeJSON contains the JSON metadata -// for the struct [AlertingV3DestinationWebhookListResponseEnvelope] -type alertingV3DestinationWebhookListResponseEnvelopeJSON 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 *AlertingV3DestinationWebhookListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationWebhookListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationWebhookListResponseEnvelopeErrorsJSON `json:"-"` -} - -// alertingV3DestinationWebhookListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AlertingV3DestinationWebhookListResponseEnvelopeErrors] -type alertingV3DestinationWebhookListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationWebhookListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationWebhookListResponseEnvelopeMessagesJSON `json:"-"` -} - -// alertingV3DestinationWebhookListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [AlertingV3DestinationWebhookListResponseEnvelopeMessages] -type alertingV3DestinationWebhookListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AlertingV3DestinationWebhookListResponseEnvelopeSuccess bool - -const ( - AlertingV3DestinationWebhookListResponseEnvelopeSuccessTrue AlertingV3DestinationWebhookListResponseEnvelopeSuccess = true -) - -type AlertingV3DestinationWebhookListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON alertingV3DestinationWebhookListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// alertingV3DestinationWebhookListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [AlertingV3DestinationWebhookListResponseEnvelopeResultInfo] -type alertingV3DestinationWebhookListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationWebhookDeleteParams struct { - // The account id - AccountID param.Field[string] `path:"account_id,required"` -} - -type AlertingV3DestinationWebhookDeleteResponseEnvelope struct { - Errors []AlertingV3DestinationWebhookDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AlertingV3DestinationWebhookDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AlertingV3DestinationWebhookDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AlertingV3DestinationWebhookDeleteResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AlertingV3DestinationWebhookDeleteResponseEnvelopeResultInfo `json:"result_info"` - JSON alertingV3DestinationWebhookDeleteResponseEnvelopeJSON `json:"-"` -} - -// alertingV3DestinationWebhookDeleteResponseEnvelopeJSON contains the JSON -// metadata for the struct [AlertingV3DestinationWebhookDeleteResponseEnvelope] -type alertingV3DestinationWebhookDeleteResponseEnvelopeJSON 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 *AlertingV3DestinationWebhookDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationWebhookDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationWebhookDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// alertingV3DestinationWebhookDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [AlertingV3DestinationWebhookDeleteResponseEnvelopeErrors] -type alertingV3DestinationWebhookDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationWebhookDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationWebhookDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// alertingV3DestinationWebhookDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [AlertingV3DestinationWebhookDeleteResponseEnvelopeMessages] -type alertingV3DestinationWebhookDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AlertingV3DestinationWebhookDeleteResponseEnvelopeSuccess bool - -const ( - AlertingV3DestinationWebhookDeleteResponseEnvelopeSuccessTrue AlertingV3DestinationWebhookDeleteResponseEnvelopeSuccess = true -) - -type AlertingV3DestinationWebhookDeleteResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON alertingV3DestinationWebhookDeleteResponseEnvelopeResultInfoJSON `json:"-"` -} - -// alertingV3DestinationWebhookDeleteResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [AlertingV3DestinationWebhookDeleteResponseEnvelopeResultInfo] -type alertingV3DestinationWebhookDeleteResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationWebhookGetParams struct { - // The account id - AccountID param.Field[string] `path:"account_id,required"` -} - -type AlertingV3DestinationWebhookGetResponseEnvelope struct { - Errors []AlertingV3DestinationWebhookGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AlertingV3DestinationWebhookGetResponseEnvelopeMessages `json:"messages,required"` - Result AlertingV3DestinationWebhookGetResponse `json:"result,required"` - // Whether the API call was successful - Success AlertingV3DestinationWebhookGetResponseEnvelopeSuccess `json:"success,required"` - JSON alertingV3DestinationWebhookGetResponseEnvelopeJSON `json:"-"` -} - -// alertingV3DestinationWebhookGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [AlertingV3DestinationWebhookGetResponseEnvelope] -type alertingV3DestinationWebhookGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationWebhookGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationWebhookGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// alertingV3DestinationWebhookGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [AlertingV3DestinationWebhookGetResponseEnvelopeErrors] -type alertingV3DestinationWebhookGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AlertingV3DestinationWebhookGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3DestinationWebhookGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// alertingV3DestinationWebhookGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [AlertingV3DestinationWebhookGetResponseEnvelopeMessages] -type alertingV3DestinationWebhookGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3DestinationWebhookGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3DestinationWebhookGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AlertingV3DestinationWebhookGetResponseEnvelopeSuccess bool - -const ( - AlertingV3DestinationWebhookGetResponseEnvelopeSuccessTrue AlertingV3DestinationWebhookGetResponseEnvelopeSuccess = true -) diff --git a/alertingv3destinationwebhook_test.go b/alertingv3destinationwebhook_test.go deleted file mode 100644 index b5579eb571a..00000000000 --- a/alertingv3destinationwebhook_test.go +++ /dev/null @@ -1,162 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAlertingV3DestinationWebhookNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Alerting.V3.Destinations.Webhooks.New(context.TODO(), cloudflare.AlertingV3DestinationWebhookNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Name: cloudflare.F("Slack Webhook"), - URL: cloudflare.F("https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd"), - Secret: cloudflare.F("string"), - }) - 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 TestAlertingV3DestinationWebhookUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Alerting.V3.Destinations.Webhooks.Update( - context.TODO(), - "b115d5ec-15c6-41ee-8b76-92c449b5227b", - cloudflare.AlertingV3DestinationWebhookUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Name: cloudflare.F("Slack Webhook"), - URL: cloudflare.F("https://hooks.slack.com/services/Ds3fdBFbV/456464Gdd"), - Secret: cloudflare.F("string"), - }, - ) - 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 TestAlertingV3DestinationWebhookList(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("user@example.com"), - ) - _, err := client.Alerting.V3.Destinations.Webhooks.List(context.TODO(), cloudflare.AlertingV3DestinationWebhookListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestAlertingV3DestinationWebhookDelete(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("user@example.com"), - ) - _, err := client.Alerting.V3.Destinations.Webhooks.Delete( - context.TODO(), - "b115d5ec-15c6-41ee-8b76-92c449b5227b", - cloudflare.AlertingV3DestinationWebhookDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestAlertingV3DestinationWebhookGet(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("user@example.com"), - ) - _, err := client.Alerting.V3.Destinations.Webhooks.Get( - context.TODO(), - "b115d5ec-15c6-41ee-8b76-92c449b5227b", - cloudflare.AlertingV3DestinationWebhookGetParams{ - AccountID: cloudflare.F("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/alertingv3history.go b/alertingv3history.go deleted file mode 100644 index 8394c43f9bd..00000000000 --- a/alertingv3history.go +++ /dev/null @@ -1,144 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" -) - -// AlertingV3HistoryService 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 [NewAlertingV3HistoryService] method -// instead. -type AlertingV3HistoryService struct { - Options []option.RequestOption -} - -// NewAlertingV3HistoryService 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 NewAlertingV3HistoryService(opts ...option.RequestOption) (r *AlertingV3HistoryService) { - r = &AlertingV3HistoryService{} - r.Options = opts - return -} - -// Gets a list of history records for notifications sent to an account. The records -// are displayed for last `x` number of days based on the zone plan (free = 30, pro -// = 30, biz = 30, ent = 90). -func (r *AlertingV3HistoryService) List(ctx context.Context, params AlertingV3HistoryListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[AlertingV3HistoryListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("accounts/%s/alerting/v3/history", params.AccountID) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Gets a list of history records for notifications sent to an account. The records -// are displayed for last `x` number of days based on the zone plan (free = 30, pro -// = 30, biz = 30, ent = 90). -func (r *AlertingV3HistoryService) ListAutoPaging(ctx context.Context, params AlertingV3HistoryListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[AlertingV3HistoryListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) -} - -type AlertingV3HistoryListResponse struct { - // UUID - ID string `json:"id"` - // Message body included in the notification sent. - AlertBody string `json:"alert_body"` - // Type of notification that has been dispatched. - AlertType string `json:"alert_type"` - // Description of the notification policy (if present). - Description string `json:"description"` - // The mechanism to which the notification has been dispatched. - Mechanism string `json:"mechanism"` - // The type of mechanism to which the notification has been dispatched. This can be - // email/pagerduty/webhook based on the mechanism configured. - MechanismType AlertingV3HistoryListResponseMechanismType `json:"mechanism_type"` - // Name of the policy. - Name string `json:"name"` - // The unique identifier of a notification policy - PolicyID string `json:"policy_id"` - // Timestamp of when the notification was dispatched in ISO 8601 format. - Sent time.Time `json:"sent" format:"date-time"` - JSON alertingV3HistoryListResponseJSON `json:"-"` -} - -// alertingV3HistoryListResponseJSON contains the JSON metadata for the struct -// [AlertingV3HistoryListResponse] -type alertingV3HistoryListResponseJSON struct { - ID apijson.Field - AlertBody apijson.Field - AlertType apijson.Field - Description apijson.Field - Mechanism apijson.Field - MechanismType apijson.Field - Name apijson.Field - PolicyID apijson.Field - Sent apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3HistoryListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3HistoryListResponseJSON) RawJSON() string { - return r.raw -} - -// The type of mechanism to which the notification has been dispatched. This can be -// email/pagerduty/webhook based on the mechanism configured. -type AlertingV3HistoryListResponseMechanismType string - -const ( - AlertingV3HistoryListResponseMechanismTypeEmail AlertingV3HistoryListResponseMechanismType = "email" - AlertingV3HistoryListResponseMechanismTypePagerduty AlertingV3HistoryListResponseMechanismType = "pagerduty" - AlertingV3HistoryListResponseMechanismTypeWebhook AlertingV3HistoryListResponseMechanismType = "webhook" -) - -type AlertingV3HistoryListParams struct { - // The account id - AccountID param.Field[string] `path:"account_id,required"` - // Limit the returned results to history records older than the specified date. - // This must be a timestamp that conforms to RFC3339. - Before param.Field[time.Time] `query:"before" format:"date-time"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // Number of items per page. - PerPage param.Field[float64] `query:"per_page"` - // Limit the returned results to history records newer than the specified date. - // This must be a timestamp that conforms to RFC3339. - Since param.Field[time.Time] `query:"since" format:"date-time"` -} - -// URLQuery serializes [AlertingV3HistoryListParams]'s query parameters as -// `url.Values`. -func (r AlertingV3HistoryListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} diff --git a/alertingv3history_test.go b/alertingv3history_test.go deleted file mode 100644 index 8c04f3ef635..00000000000 --- a/alertingv3history_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAlertingV3HistoryListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Alerting.V3.Histories.List(context.TODO(), cloudflare.AlertingV3HistoryListParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Before: cloudflare.F(time.Now()), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(5.000000), - Since: cloudflare.F(time.Now()), - }) - 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/alertingv3policy.go b/alertingv3policy.go deleted file mode 100644 index 4802233e203..00000000000 --- a/alertingv3policy.go +++ /dev/null @@ -1,1730 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// AlertingV3PolicyService 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 [NewAlertingV3PolicyService] method -// instead. -type AlertingV3PolicyService struct { - Options []option.RequestOption -} - -// NewAlertingV3PolicyService 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 NewAlertingV3PolicyService(opts ...option.RequestOption) (r *AlertingV3PolicyService) { - r = &AlertingV3PolicyService{} - r.Options = opts - return -} - -// Creates a new Notification policy. -func (r *AlertingV3PolicyService) New(ctx context.Context, params AlertingV3PolicyNewParams, opts ...option.RequestOption) (res *AlertingV3PolicyNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env AlertingV3PolicyNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/alerting/v3/policies", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update a Notification policy. -func (r *AlertingV3PolicyService) Update(ctx context.Context, policyID string, params AlertingV3PolicyUpdateParams, opts ...option.RequestOption) (res *AlertingV3PolicyUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env AlertingV3PolicyUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/alerting/v3/policies/%s", params.AccountID, policyID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a list of all Notification policies. -func (r *AlertingV3PolicyService) List(ctx context.Context, query AlertingV3PolicyListParams, opts ...option.RequestOption) (res *[]AlertingV3PolicyListResponse, err error) { - opts = append(r.Options[:], opts...) - var env AlertingV3PolicyListResponseEnvelope - path := fmt.Sprintf("accounts/%s/alerting/v3/policies", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a Notification policy. -func (r *AlertingV3PolicyService) Delete(ctx context.Context, policyID string, body AlertingV3PolicyDeleteParams, opts ...option.RequestOption) (res *AlertingV3PolicyDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env AlertingV3PolicyDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/alerting/v3/policies/%s", body.AccountID, policyID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get details for a single policy. -func (r *AlertingV3PolicyService) Get(ctx context.Context, policyID string, query AlertingV3PolicyGetParams, opts ...option.RequestOption) (res *AlertingV3PolicyGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env AlertingV3PolicyGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/alerting/v3/policies/%s", query.AccountID, policyID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type AlertingV3PolicyNewResponse struct { - // UUID - ID string `json:"id"` - JSON alertingV3PolicyNewResponseJSON `json:"-"` -} - -// alertingV3PolicyNewResponseJSON contains the JSON metadata for the struct -// [AlertingV3PolicyNewResponse] -type alertingV3PolicyNewResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyNewResponseJSON) RawJSON() string { - return r.raw -} - -type AlertingV3PolicyUpdateResponse struct { - // UUID - ID string `json:"id"` - JSON alertingV3PolicyUpdateResponseJSON `json:"-"` -} - -// alertingV3PolicyUpdateResponseJSON contains the JSON metadata for the struct -// [AlertingV3PolicyUpdateResponse] -type alertingV3PolicyUpdateResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type AlertingV3PolicyListResponse struct { - // The unique identifier of a notification policy - ID string `json:"id"` - // Refers to which event will trigger a Notification dispatch. You can use the - // endpoint to get available alert types which then will give you a list of - // possible values. - AlertType AlertingV3PolicyListResponseAlertType `json:"alert_type"` - Created time.Time `json:"created" format:"date-time"` - // Optional description for the Notification policy. - Description string `json:"description"` - // Whether or not the Notification policy is enabled. - Enabled bool `json:"enabled"` - // Optional filters that allow you to be alerted only on a subset of events for - // that alert type based on some criteria. This is only available for select alert - // types. See alert type documentation for more details. - Filters AlertingV3PolicyListResponseFilters `json:"filters"` - // List of IDs that will be used when dispatching a notification. IDs for email - // type will be the email address. - Mechanisms map[string][]AlertingV3PolicyListResponseMechanisms `json:"mechanisms"` - Modified time.Time `json:"modified" format:"date-time"` - // Name of the policy. - Name string `json:"name"` - JSON alertingV3PolicyListResponseJSON `json:"-"` -} - -// alertingV3PolicyListResponseJSON contains the JSON metadata for the struct -// [AlertingV3PolicyListResponse] -type alertingV3PolicyListResponseJSON struct { - ID apijson.Field - AlertType apijson.Field - Created apijson.Field - Description apijson.Field - Enabled apijson.Field - Filters apijson.Field - Mechanisms apijson.Field - Modified apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyListResponseJSON) RawJSON() string { - return r.raw -} - -// Refers to which event will trigger a Notification dispatch. You can use the -// endpoint to get available alert types which then will give you a list of -// possible values. -type AlertingV3PolicyListResponseAlertType string - -const ( - AlertingV3PolicyListResponseAlertTypeAccessCustomCertificateExpirationType AlertingV3PolicyListResponseAlertType = "access_custom_certificate_expiration_type" - AlertingV3PolicyListResponseAlertTypeAdvancedDDOSAttackL4Alert AlertingV3PolicyListResponseAlertType = "advanced_ddos_attack_l4_alert" - AlertingV3PolicyListResponseAlertTypeAdvancedDDOSAttackL7Alert AlertingV3PolicyListResponseAlertType = "advanced_ddos_attack_l7_alert" - AlertingV3PolicyListResponseAlertTypeAdvancedHTTPAlertError AlertingV3PolicyListResponseAlertType = "advanced_http_alert_error" - AlertingV3PolicyListResponseAlertTypeBGPHijackNotification AlertingV3PolicyListResponseAlertType = "bgp_hijack_notification" - AlertingV3PolicyListResponseAlertTypeBillingUsageAlert AlertingV3PolicyListResponseAlertType = "billing_usage_alert" - AlertingV3PolicyListResponseAlertTypeBlockNotificationBlockRemoved AlertingV3PolicyListResponseAlertType = "block_notification_block_removed" - AlertingV3PolicyListResponseAlertTypeBlockNotificationNewBlock AlertingV3PolicyListResponseAlertType = "block_notification_new_block" - AlertingV3PolicyListResponseAlertTypeBlockNotificationReviewRejected AlertingV3PolicyListResponseAlertType = "block_notification_review_rejected" - AlertingV3PolicyListResponseAlertTypeBrandProtectionAlert AlertingV3PolicyListResponseAlertType = "brand_protection_alert" - AlertingV3PolicyListResponseAlertTypeBrandProtectionDigest AlertingV3PolicyListResponseAlertType = "brand_protection_digest" - AlertingV3PolicyListResponseAlertTypeClickhouseAlertFwAnomaly AlertingV3PolicyListResponseAlertType = "clickhouse_alert_fw_anomaly" - AlertingV3PolicyListResponseAlertTypeClickhouseAlertFwEntAnomaly AlertingV3PolicyListResponseAlertType = "clickhouse_alert_fw_ent_anomaly" - AlertingV3PolicyListResponseAlertTypeCustomSSLCertificateEventType AlertingV3PolicyListResponseAlertType = "custom_ssl_certificate_event_type" - AlertingV3PolicyListResponseAlertTypeDedicatedSSLCertificateEventType AlertingV3PolicyListResponseAlertType = "dedicated_ssl_certificate_event_type" - AlertingV3PolicyListResponseAlertTypeDosAttackL4 AlertingV3PolicyListResponseAlertType = "dos_attack_l4" - AlertingV3PolicyListResponseAlertTypeDosAttackL7 AlertingV3PolicyListResponseAlertType = "dos_attack_l7" - AlertingV3PolicyListResponseAlertTypeExpiringServiceTokenAlert AlertingV3PolicyListResponseAlertType = "expiring_service_token_alert" - AlertingV3PolicyListResponseAlertTypeFailingLogpushJobDisabledAlert AlertingV3PolicyListResponseAlertType = "failing_logpush_job_disabled_alert" - AlertingV3PolicyListResponseAlertTypeFbmAutoAdvertisement AlertingV3PolicyListResponseAlertType = "fbm_auto_advertisement" - AlertingV3PolicyListResponseAlertTypeFbmDosdAttack AlertingV3PolicyListResponseAlertType = "fbm_dosd_attack" - AlertingV3PolicyListResponseAlertTypeFbmVolumetricAttack AlertingV3PolicyListResponseAlertType = "fbm_volumetric_attack" - AlertingV3PolicyListResponseAlertTypeHealthCheckStatusNotification AlertingV3PolicyListResponseAlertType = "health_check_status_notification" - AlertingV3PolicyListResponseAlertTypeHostnameAopCustomCertificateExpirationType AlertingV3PolicyListResponseAlertType = "hostname_aop_custom_certificate_expiration_type" - AlertingV3PolicyListResponseAlertTypeHTTPAlertEdgeError AlertingV3PolicyListResponseAlertType = "http_alert_edge_error" - AlertingV3PolicyListResponseAlertTypeHTTPAlertOriginError AlertingV3PolicyListResponseAlertType = "http_alert_origin_error" - AlertingV3PolicyListResponseAlertTypeIncidentAlert AlertingV3PolicyListResponseAlertType = "incident_alert" - AlertingV3PolicyListResponseAlertTypeLoadBalancingHealthAlert AlertingV3PolicyListResponseAlertType = "load_balancing_health_alert" - AlertingV3PolicyListResponseAlertTypeLoadBalancingPoolEnablementAlert AlertingV3PolicyListResponseAlertType = "load_balancing_pool_enablement_alert" - AlertingV3PolicyListResponseAlertTypeLogoMatchAlert AlertingV3PolicyListResponseAlertType = "logo_match_alert" - AlertingV3PolicyListResponseAlertTypeMagicTunnelHealthCheckEvent AlertingV3PolicyListResponseAlertType = "magic_tunnel_health_check_event" - AlertingV3PolicyListResponseAlertTypeMaintenanceEventNotification AlertingV3PolicyListResponseAlertType = "maintenance_event_notification" - AlertingV3PolicyListResponseAlertTypeMTLSCertificateStoreCertificateExpirationType AlertingV3PolicyListResponseAlertType = "mtls_certificate_store_certificate_expiration_type" - AlertingV3PolicyListResponseAlertTypePagesEventAlert AlertingV3PolicyListResponseAlertType = "pages_event_alert" - AlertingV3PolicyListResponseAlertTypeRadarNotification AlertingV3PolicyListResponseAlertType = "radar_notification" - AlertingV3PolicyListResponseAlertTypeRealOriginMonitoring AlertingV3PolicyListResponseAlertType = "real_origin_monitoring" - AlertingV3PolicyListResponseAlertTypeScriptmonitorAlertNewCodeChangeDetections AlertingV3PolicyListResponseAlertType = "scriptmonitor_alert_new_code_change_detections" - AlertingV3PolicyListResponseAlertTypeScriptmonitorAlertNewHosts AlertingV3PolicyListResponseAlertType = "scriptmonitor_alert_new_hosts" - AlertingV3PolicyListResponseAlertTypeScriptmonitorAlertNewMaliciousHosts AlertingV3PolicyListResponseAlertType = "scriptmonitor_alert_new_malicious_hosts" - AlertingV3PolicyListResponseAlertTypeScriptmonitorAlertNewMaliciousScripts AlertingV3PolicyListResponseAlertType = "scriptmonitor_alert_new_malicious_scripts" - AlertingV3PolicyListResponseAlertTypeScriptmonitorAlertNewMaliciousURL AlertingV3PolicyListResponseAlertType = "scriptmonitor_alert_new_malicious_url" - AlertingV3PolicyListResponseAlertTypeScriptmonitorAlertNewMaxLengthResourceURL AlertingV3PolicyListResponseAlertType = "scriptmonitor_alert_new_max_length_resource_url" - AlertingV3PolicyListResponseAlertTypeScriptmonitorAlertNewResources AlertingV3PolicyListResponseAlertType = "scriptmonitor_alert_new_resources" - AlertingV3PolicyListResponseAlertTypeSecondaryDNSAllPrimariesFailing AlertingV3PolicyListResponseAlertType = "secondary_dns_all_primaries_failing" - AlertingV3PolicyListResponseAlertTypeSecondaryDNSPrimariesFailing AlertingV3PolicyListResponseAlertType = "secondary_dns_primaries_failing" - AlertingV3PolicyListResponseAlertTypeSecondaryDNSZoneSuccessfullyUpdated AlertingV3PolicyListResponseAlertType = "secondary_dns_zone_successfully_updated" - AlertingV3PolicyListResponseAlertTypeSecondaryDNSZoneValidationWarning AlertingV3PolicyListResponseAlertType = "secondary_dns_zone_validation_warning" - AlertingV3PolicyListResponseAlertTypeSentinelAlert AlertingV3PolicyListResponseAlertType = "sentinel_alert" - AlertingV3PolicyListResponseAlertTypeStreamLiveNotifications AlertingV3PolicyListResponseAlertType = "stream_live_notifications" - AlertingV3PolicyListResponseAlertTypeTunnelHealthEvent AlertingV3PolicyListResponseAlertType = "tunnel_health_event" - AlertingV3PolicyListResponseAlertTypeTunnelUpdateEvent AlertingV3PolicyListResponseAlertType = "tunnel_update_event" - AlertingV3PolicyListResponseAlertTypeUniversalSSLEventType AlertingV3PolicyListResponseAlertType = "universal_ssl_event_type" - AlertingV3PolicyListResponseAlertTypeWebAnalyticsMetricsUpdate AlertingV3PolicyListResponseAlertType = "web_analytics_metrics_update" - AlertingV3PolicyListResponseAlertTypeZoneAopCustomCertificateExpirationType AlertingV3PolicyListResponseAlertType = "zone_aop_custom_certificate_expiration_type" -) - -// Optional filters that allow you to be alerted only on a subset of events for -// that alert type based on some criteria. This is only available for select alert -// types. See alert type documentation for more details. -type AlertingV3PolicyListResponseFilters struct { - // Usage depends on specific alert type - Actions []string `json:"actions"` - // Used for configuring radar_notification - AffectedASNs []string `json:"affected_asns"` - // Used for configuring incident_alert - AffectedComponents []string `json:"affected_components"` - // Used for configuring radar_notification - AffectedLocations []string `json:"affected_locations"` - // Used for configuring maintenance_event_notification - AirportCode []string `json:"airport_code"` - // Usage depends on specific alert type - AlertTriggerPreferences []string `json:"alert_trigger_preferences"` - // Used for configuring magic_tunnel_health_check_event - AlertTriggerPreferencesValue []AlertingV3PolicyListResponseFiltersAlertTriggerPreferencesValue `json:"alert_trigger_preferences_value"` - // Used for configuring load_balancing_pool_enablement_alert - Enabled []string `json:"enabled"` - // Used for configuring pages_event_alert - Environment []string `json:"environment"` - // Used for configuring pages_event_alert - Event []string `json:"event"` - // Used for configuring load_balancing_health_alert - EventSource []string `json:"event_source"` - // Usage depends on specific alert type - EventType []string `json:"event_type"` - // Usage depends on specific alert type - GroupBy []string `json:"group_by"` - // Used for configuring health_check_status_notification - HealthCheckID []string `json:"health_check_id"` - // Used for configuring incident_alert - IncidentImpact []AlertingV3PolicyListResponseFiltersIncidentImpact `json:"incident_impact"` - // Used for configuring stream_live_notifications - InputID []string `json:"input_id"` - // Used for configuring billing_usage_alert - Limit []string `json:"limit"` - // Used for configuring logo_match_alert - LogoTag []string `json:"logo_tag"` - // Used for configuring advanced_ddos_attack_l4_alert - MegabitsPerSecond []string `json:"megabits_per_second"` - // Used for configuring load_balancing_health_alert - NewHealth []string `json:"new_health"` - // Used for configuring tunnel_health_event - NewStatus []string `json:"new_status"` - // Used for configuring advanced_ddos_attack_l4_alert - PacketsPerSecond []string `json:"packets_per_second"` - // Usage depends on specific alert type - PoolID []string `json:"pool_id"` - // Used for configuring billing_usage_alert - Product []string `json:"product"` - // Used for configuring pages_event_alert - ProjectID []string `json:"project_id"` - // Used for configuring advanced_ddos_attack_l4_alert - Protocol []string `json:"protocol"` - // Usage depends on specific alert type - QueryTag []string `json:"query_tag"` - // Used for configuring advanced_ddos_attack_l7_alert - RequestsPerSecond []string `json:"requests_per_second"` - // Usage depends on specific alert type - Selectors []string `json:"selectors"` - // Used for configuring clickhouse_alert_fw_ent_anomaly - Services []string `json:"services"` - // Usage depends on specific alert type - Slo []string `json:"slo"` - // Used for configuring health_check_status_notification - Status []string `json:"status"` - // Used for configuring advanced_ddos_attack_l7_alert - TargetHostname []string `json:"target_hostname"` - // Used for configuring advanced_ddos_attack_l4_alert - TargetIP []string `json:"target_ip"` - // Used for configuring advanced_ddos_attack_l7_alert - TargetZoneName []string `json:"target_zone_name"` - // Used for configuring traffic_anomalies_alert - TrafficExclusions []AlertingV3PolicyListResponseFiltersTrafficExclusion `json:"traffic_exclusions"` - // Used for configuring tunnel_health_event - TunnelID []string `json:"tunnel_id"` - // Used for configuring magic_tunnel_health_check_event - TunnelName []string `json:"tunnel_name"` - // Usage depends on specific alert type - Where []string `json:"where"` - // Usage depends on specific alert type - Zones []string `json:"zones"` - JSON alertingV3PolicyListResponseFiltersJSON `json:"-"` -} - -// alertingV3PolicyListResponseFiltersJSON contains the JSON metadata for the -// struct [AlertingV3PolicyListResponseFilters] -type alertingV3PolicyListResponseFiltersJSON struct { - Actions apijson.Field - AffectedASNs apijson.Field - AffectedComponents apijson.Field - AffectedLocations apijson.Field - AirportCode apijson.Field - AlertTriggerPreferences apijson.Field - AlertTriggerPreferencesValue apijson.Field - Enabled apijson.Field - Environment apijson.Field - Event apijson.Field - EventSource apijson.Field - EventType apijson.Field - GroupBy apijson.Field - HealthCheckID apijson.Field - IncidentImpact apijson.Field - InputID apijson.Field - Limit apijson.Field - LogoTag apijson.Field - MegabitsPerSecond apijson.Field - NewHealth apijson.Field - NewStatus apijson.Field - PacketsPerSecond apijson.Field - PoolID apijson.Field - Product apijson.Field - ProjectID apijson.Field - Protocol apijson.Field - QueryTag apijson.Field - RequestsPerSecond apijson.Field - Selectors apijson.Field - Services apijson.Field - Slo apijson.Field - Status apijson.Field - TargetHostname apijson.Field - TargetIP apijson.Field - TargetZoneName apijson.Field - TrafficExclusions apijson.Field - TunnelID apijson.Field - TunnelName apijson.Field - Where apijson.Field - Zones apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyListResponseFilters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyListResponseFiltersJSON) RawJSON() string { - return r.raw -} - -type AlertingV3PolicyListResponseFiltersAlertTriggerPreferencesValue string - -const ( - AlertingV3PolicyListResponseFiltersAlertTriggerPreferencesValue99_0 AlertingV3PolicyListResponseFiltersAlertTriggerPreferencesValue = "99.0" - AlertingV3PolicyListResponseFiltersAlertTriggerPreferencesValue98_0 AlertingV3PolicyListResponseFiltersAlertTriggerPreferencesValue = "98.0" - AlertingV3PolicyListResponseFiltersAlertTriggerPreferencesValue97_0 AlertingV3PolicyListResponseFiltersAlertTriggerPreferencesValue = "97.0" -) - -type AlertingV3PolicyListResponseFiltersIncidentImpact string - -const ( - AlertingV3PolicyListResponseFiltersIncidentImpactIncidentImpactNone AlertingV3PolicyListResponseFiltersIncidentImpact = "INCIDENT_IMPACT_NONE" - AlertingV3PolicyListResponseFiltersIncidentImpactIncidentImpactMinor AlertingV3PolicyListResponseFiltersIncidentImpact = "INCIDENT_IMPACT_MINOR" - AlertingV3PolicyListResponseFiltersIncidentImpactIncidentImpactMajor AlertingV3PolicyListResponseFiltersIncidentImpact = "INCIDENT_IMPACT_MAJOR" - AlertingV3PolicyListResponseFiltersIncidentImpactIncidentImpactCritical AlertingV3PolicyListResponseFiltersIncidentImpact = "INCIDENT_IMPACT_CRITICAL" -) - -type AlertingV3PolicyListResponseFiltersTrafficExclusion string - -const ( - AlertingV3PolicyListResponseFiltersTrafficExclusionSecurityEvents AlertingV3PolicyListResponseFiltersTrafficExclusion = "security_events" -) - -type AlertingV3PolicyListResponseMechanisms struct { - // UUID - ID AlertingV3PolicyListResponseMechanismsID `json:"id"` - JSON alertingV3PolicyListResponseMechanismsJSON `json:"-"` -} - -// alertingV3PolicyListResponseMechanismsJSON contains the JSON metadata for the -// struct [AlertingV3PolicyListResponseMechanisms] -type alertingV3PolicyListResponseMechanismsJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyListResponseMechanisms) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyListResponseMechanismsJSON) RawJSON() string { - return r.raw -} - -// UUID -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type AlertingV3PolicyListResponseMechanismsID interface { - ImplementsAlertingV3PolicyListResponseMechanismsID() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AlertingV3PolicyListResponseMechanismsID)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [AlertingV3PolicyDeleteResponseUnknown], -// [AlertingV3PolicyDeleteResponseArray] or [shared.UnionString]. -type AlertingV3PolicyDeleteResponse interface { - ImplementsAlertingV3PolicyDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AlertingV3PolicyDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(AlertingV3PolicyDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type AlertingV3PolicyDeleteResponseArray []interface{} - -func (r AlertingV3PolicyDeleteResponseArray) ImplementsAlertingV3PolicyDeleteResponse() {} - -type AlertingV3PolicyGetResponse struct { - // The unique identifier of a notification policy - ID string `json:"id"` - // Refers to which event will trigger a Notification dispatch. You can use the - // endpoint to get available alert types which then will give you a list of - // possible values. - AlertType AlertingV3PolicyGetResponseAlertType `json:"alert_type"` - Created time.Time `json:"created" format:"date-time"` - // Optional description for the Notification policy. - Description string `json:"description"` - // Whether or not the Notification policy is enabled. - Enabled bool `json:"enabled"` - // Optional filters that allow you to be alerted only on a subset of events for - // that alert type based on some criteria. This is only available for select alert - // types. See alert type documentation for more details. - Filters AlertingV3PolicyGetResponseFilters `json:"filters"` - // List of IDs that will be used when dispatching a notification. IDs for email - // type will be the email address. - Mechanisms map[string][]AlertingV3PolicyGetResponseMechanisms `json:"mechanisms"` - Modified time.Time `json:"modified" format:"date-time"` - // Name of the policy. - Name string `json:"name"` - JSON alertingV3PolicyGetResponseJSON `json:"-"` -} - -// alertingV3PolicyGetResponseJSON contains the JSON metadata for the struct -// [AlertingV3PolicyGetResponse] -type alertingV3PolicyGetResponseJSON struct { - ID apijson.Field - AlertType apijson.Field - Created apijson.Field - Description apijson.Field - Enabled apijson.Field - Filters apijson.Field - Mechanisms apijson.Field - Modified apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyGetResponseJSON) RawJSON() string { - return r.raw -} - -// Refers to which event will trigger a Notification dispatch. You can use the -// endpoint to get available alert types which then will give you a list of -// possible values. -type AlertingV3PolicyGetResponseAlertType string - -const ( - AlertingV3PolicyGetResponseAlertTypeAccessCustomCertificateExpirationType AlertingV3PolicyGetResponseAlertType = "access_custom_certificate_expiration_type" - AlertingV3PolicyGetResponseAlertTypeAdvancedDDOSAttackL4Alert AlertingV3PolicyGetResponseAlertType = "advanced_ddos_attack_l4_alert" - AlertingV3PolicyGetResponseAlertTypeAdvancedDDOSAttackL7Alert AlertingV3PolicyGetResponseAlertType = "advanced_ddos_attack_l7_alert" - AlertingV3PolicyGetResponseAlertTypeAdvancedHTTPAlertError AlertingV3PolicyGetResponseAlertType = "advanced_http_alert_error" - AlertingV3PolicyGetResponseAlertTypeBGPHijackNotification AlertingV3PolicyGetResponseAlertType = "bgp_hijack_notification" - AlertingV3PolicyGetResponseAlertTypeBillingUsageAlert AlertingV3PolicyGetResponseAlertType = "billing_usage_alert" - AlertingV3PolicyGetResponseAlertTypeBlockNotificationBlockRemoved AlertingV3PolicyGetResponseAlertType = "block_notification_block_removed" - AlertingV3PolicyGetResponseAlertTypeBlockNotificationNewBlock AlertingV3PolicyGetResponseAlertType = "block_notification_new_block" - AlertingV3PolicyGetResponseAlertTypeBlockNotificationReviewRejected AlertingV3PolicyGetResponseAlertType = "block_notification_review_rejected" - AlertingV3PolicyGetResponseAlertTypeBrandProtectionAlert AlertingV3PolicyGetResponseAlertType = "brand_protection_alert" - AlertingV3PolicyGetResponseAlertTypeBrandProtectionDigest AlertingV3PolicyGetResponseAlertType = "brand_protection_digest" - AlertingV3PolicyGetResponseAlertTypeClickhouseAlertFwAnomaly AlertingV3PolicyGetResponseAlertType = "clickhouse_alert_fw_anomaly" - AlertingV3PolicyGetResponseAlertTypeClickhouseAlertFwEntAnomaly AlertingV3PolicyGetResponseAlertType = "clickhouse_alert_fw_ent_anomaly" - AlertingV3PolicyGetResponseAlertTypeCustomSSLCertificateEventType AlertingV3PolicyGetResponseAlertType = "custom_ssl_certificate_event_type" - AlertingV3PolicyGetResponseAlertTypeDedicatedSSLCertificateEventType AlertingV3PolicyGetResponseAlertType = "dedicated_ssl_certificate_event_type" - AlertingV3PolicyGetResponseAlertTypeDosAttackL4 AlertingV3PolicyGetResponseAlertType = "dos_attack_l4" - AlertingV3PolicyGetResponseAlertTypeDosAttackL7 AlertingV3PolicyGetResponseAlertType = "dos_attack_l7" - AlertingV3PolicyGetResponseAlertTypeExpiringServiceTokenAlert AlertingV3PolicyGetResponseAlertType = "expiring_service_token_alert" - AlertingV3PolicyGetResponseAlertTypeFailingLogpushJobDisabledAlert AlertingV3PolicyGetResponseAlertType = "failing_logpush_job_disabled_alert" - AlertingV3PolicyGetResponseAlertTypeFbmAutoAdvertisement AlertingV3PolicyGetResponseAlertType = "fbm_auto_advertisement" - AlertingV3PolicyGetResponseAlertTypeFbmDosdAttack AlertingV3PolicyGetResponseAlertType = "fbm_dosd_attack" - AlertingV3PolicyGetResponseAlertTypeFbmVolumetricAttack AlertingV3PolicyGetResponseAlertType = "fbm_volumetric_attack" - AlertingV3PolicyGetResponseAlertTypeHealthCheckStatusNotification AlertingV3PolicyGetResponseAlertType = "health_check_status_notification" - AlertingV3PolicyGetResponseAlertTypeHostnameAopCustomCertificateExpirationType AlertingV3PolicyGetResponseAlertType = "hostname_aop_custom_certificate_expiration_type" - AlertingV3PolicyGetResponseAlertTypeHTTPAlertEdgeError AlertingV3PolicyGetResponseAlertType = "http_alert_edge_error" - AlertingV3PolicyGetResponseAlertTypeHTTPAlertOriginError AlertingV3PolicyGetResponseAlertType = "http_alert_origin_error" - AlertingV3PolicyGetResponseAlertTypeIncidentAlert AlertingV3PolicyGetResponseAlertType = "incident_alert" - AlertingV3PolicyGetResponseAlertTypeLoadBalancingHealthAlert AlertingV3PolicyGetResponseAlertType = "load_balancing_health_alert" - AlertingV3PolicyGetResponseAlertTypeLoadBalancingPoolEnablementAlert AlertingV3PolicyGetResponseAlertType = "load_balancing_pool_enablement_alert" - AlertingV3PolicyGetResponseAlertTypeLogoMatchAlert AlertingV3PolicyGetResponseAlertType = "logo_match_alert" - AlertingV3PolicyGetResponseAlertTypeMagicTunnelHealthCheckEvent AlertingV3PolicyGetResponseAlertType = "magic_tunnel_health_check_event" - AlertingV3PolicyGetResponseAlertTypeMaintenanceEventNotification AlertingV3PolicyGetResponseAlertType = "maintenance_event_notification" - AlertingV3PolicyGetResponseAlertTypeMTLSCertificateStoreCertificateExpirationType AlertingV3PolicyGetResponseAlertType = "mtls_certificate_store_certificate_expiration_type" - AlertingV3PolicyGetResponseAlertTypePagesEventAlert AlertingV3PolicyGetResponseAlertType = "pages_event_alert" - AlertingV3PolicyGetResponseAlertTypeRadarNotification AlertingV3PolicyGetResponseAlertType = "radar_notification" - AlertingV3PolicyGetResponseAlertTypeRealOriginMonitoring AlertingV3PolicyGetResponseAlertType = "real_origin_monitoring" - AlertingV3PolicyGetResponseAlertTypeScriptmonitorAlertNewCodeChangeDetections AlertingV3PolicyGetResponseAlertType = "scriptmonitor_alert_new_code_change_detections" - AlertingV3PolicyGetResponseAlertTypeScriptmonitorAlertNewHosts AlertingV3PolicyGetResponseAlertType = "scriptmonitor_alert_new_hosts" - AlertingV3PolicyGetResponseAlertTypeScriptmonitorAlertNewMaliciousHosts AlertingV3PolicyGetResponseAlertType = "scriptmonitor_alert_new_malicious_hosts" - AlertingV3PolicyGetResponseAlertTypeScriptmonitorAlertNewMaliciousScripts AlertingV3PolicyGetResponseAlertType = "scriptmonitor_alert_new_malicious_scripts" - AlertingV3PolicyGetResponseAlertTypeScriptmonitorAlertNewMaliciousURL AlertingV3PolicyGetResponseAlertType = "scriptmonitor_alert_new_malicious_url" - AlertingV3PolicyGetResponseAlertTypeScriptmonitorAlertNewMaxLengthResourceURL AlertingV3PolicyGetResponseAlertType = "scriptmonitor_alert_new_max_length_resource_url" - AlertingV3PolicyGetResponseAlertTypeScriptmonitorAlertNewResources AlertingV3PolicyGetResponseAlertType = "scriptmonitor_alert_new_resources" - AlertingV3PolicyGetResponseAlertTypeSecondaryDNSAllPrimariesFailing AlertingV3PolicyGetResponseAlertType = "secondary_dns_all_primaries_failing" - AlertingV3PolicyGetResponseAlertTypeSecondaryDNSPrimariesFailing AlertingV3PolicyGetResponseAlertType = "secondary_dns_primaries_failing" - AlertingV3PolicyGetResponseAlertTypeSecondaryDNSZoneSuccessfullyUpdated AlertingV3PolicyGetResponseAlertType = "secondary_dns_zone_successfully_updated" - AlertingV3PolicyGetResponseAlertTypeSecondaryDNSZoneValidationWarning AlertingV3PolicyGetResponseAlertType = "secondary_dns_zone_validation_warning" - AlertingV3PolicyGetResponseAlertTypeSentinelAlert AlertingV3PolicyGetResponseAlertType = "sentinel_alert" - AlertingV3PolicyGetResponseAlertTypeStreamLiveNotifications AlertingV3PolicyGetResponseAlertType = "stream_live_notifications" - AlertingV3PolicyGetResponseAlertTypeTunnelHealthEvent AlertingV3PolicyGetResponseAlertType = "tunnel_health_event" - AlertingV3PolicyGetResponseAlertTypeTunnelUpdateEvent AlertingV3PolicyGetResponseAlertType = "tunnel_update_event" - AlertingV3PolicyGetResponseAlertTypeUniversalSSLEventType AlertingV3PolicyGetResponseAlertType = "universal_ssl_event_type" - AlertingV3PolicyGetResponseAlertTypeWebAnalyticsMetricsUpdate AlertingV3PolicyGetResponseAlertType = "web_analytics_metrics_update" - AlertingV3PolicyGetResponseAlertTypeZoneAopCustomCertificateExpirationType AlertingV3PolicyGetResponseAlertType = "zone_aop_custom_certificate_expiration_type" -) - -// Optional filters that allow you to be alerted only on a subset of events for -// that alert type based on some criteria. This is only available for select alert -// types. See alert type documentation for more details. -type AlertingV3PolicyGetResponseFilters struct { - // Usage depends on specific alert type - Actions []string `json:"actions"` - // Used for configuring radar_notification - AffectedASNs []string `json:"affected_asns"` - // Used for configuring incident_alert - AffectedComponents []string `json:"affected_components"` - // Used for configuring radar_notification - AffectedLocations []string `json:"affected_locations"` - // Used for configuring maintenance_event_notification - AirportCode []string `json:"airport_code"` - // Usage depends on specific alert type - AlertTriggerPreferences []string `json:"alert_trigger_preferences"` - // Used for configuring magic_tunnel_health_check_event - AlertTriggerPreferencesValue []AlertingV3PolicyGetResponseFiltersAlertTriggerPreferencesValue `json:"alert_trigger_preferences_value"` - // Used for configuring load_balancing_pool_enablement_alert - Enabled []string `json:"enabled"` - // Used for configuring pages_event_alert - Environment []string `json:"environment"` - // Used for configuring pages_event_alert - Event []string `json:"event"` - // Used for configuring load_balancing_health_alert - EventSource []string `json:"event_source"` - // Usage depends on specific alert type - EventType []string `json:"event_type"` - // Usage depends on specific alert type - GroupBy []string `json:"group_by"` - // Used for configuring health_check_status_notification - HealthCheckID []string `json:"health_check_id"` - // Used for configuring incident_alert - IncidentImpact []AlertingV3PolicyGetResponseFiltersIncidentImpact `json:"incident_impact"` - // Used for configuring stream_live_notifications - InputID []string `json:"input_id"` - // Used for configuring billing_usage_alert - Limit []string `json:"limit"` - // Used for configuring logo_match_alert - LogoTag []string `json:"logo_tag"` - // Used for configuring advanced_ddos_attack_l4_alert - MegabitsPerSecond []string `json:"megabits_per_second"` - // Used for configuring load_balancing_health_alert - NewHealth []string `json:"new_health"` - // Used for configuring tunnel_health_event - NewStatus []string `json:"new_status"` - // Used for configuring advanced_ddos_attack_l4_alert - PacketsPerSecond []string `json:"packets_per_second"` - // Usage depends on specific alert type - PoolID []string `json:"pool_id"` - // Used for configuring billing_usage_alert - Product []string `json:"product"` - // Used for configuring pages_event_alert - ProjectID []string `json:"project_id"` - // Used for configuring advanced_ddos_attack_l4_alert - Protocol []string `json:"protocol"` - // Usage depends on specific alert type - QueryTag []string `json:"query_tag"` - // Used for configuring advanced_ddos_attack_l7_alert - RequestsPerSecond []string `json:"requests_per_second"` - // Usage depends on specific alert type - Selectors []string `json:"selectors"` - // Used for configuring clickhouse_alert_fw_ent_anomaly - Services []string `json:"services"` - // Usage depends on specific alert type - Slo []string `json:"slo"` - // Used for configuring health_check_status_notification - Status []string `json:"status"` - // Used for configuring advanced_ddos_attack_l7_alert - TargetHostname []string `json:"target_hostname"` - // Used for configuring advanced_ddos_attack_l4_alert - TargetIP []string `json:"target_ip"` - // Used for configuring advanced_ddos_attack_l7_alert - TargetZoneName []string `json:"target_zone_name"` - // Used for configuring traffic_anomalies_alert - TrafficExclusions []AlertingV3PolicyGetResponseFiltersTrafficExclusion `json:"traffic_exclusions"` - // Used for configuring tunnel_health_event - TunnelID []string `json:"tunnel_id"` - // Used for configuring magic_tunnel_health_check_event - TunnelName []string `json:"tunnel_name"` - // Usage depends on specific alert type - Where []string `json:"where"` - // Usage depends on specific alert type - Zones []string `json:"zones"` - JSON alertingV3PolicyGetResponseFiltersJSON `json:"-"` -} - -// alertingV3PolicyGetResponseFiltersJSON contains the JSON metadata for the struct -// [AlertingV3PolicyGetResponseFilters] -type alertingV3PolicyGetResponseFiltersJSON struct { - Actions apijson.Field - AffectedASNs apijson.Field - AffectedComponents apijson.Field - AffectedLocations apijson.Field - AirportCode apijson.Field - AlertTriggerPreferences apijson.Field - AlertTriggerPreferencesValue apijson.Field - Enabled apijson.Field - Environment apijson.Field - Event apijson.Field - EventSource apijson.Field - EventType apijson.Field - GroupBy apijson.Field - HealthCheckID apijson.Field - IncidentImpact apijson.Field - InputID apijson.Field - Limit apijson.Field - LogoTag apijson.Field - MegabitsPerSecond apijson.Field - NewHealth apijson.Field - NewStatus apijson.Field - PacketsPerSecond apijson.Field - PoolID apijson.Field - Product apijson.Field - ProjectID apijson.Field - Protocol apijson.Field - QueryTag apijson.Field - RequestsPerSecond apijson.Field - Selectors apijson.Field - Services apijson.Field - Slo apijson.Field - Status apijson.Field - TargetHostname apijson.Field - TargetIP apijson.Field - TargetZoneName apijson.Field - TrafficExclusions apijson.Field - TunnelID apijson.Field - TunnelName apijson.Field - Where apijson.Field - Zones apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyGetResponseFilters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyGetResponseFiltersJSON) RawJSON() string { - return r.raw -} - -type AlertingV3PolicyGetResponseFiltersAlertTriggerPreferencesValue string - -const ( - AlertingV3PolicyGetResponseFiltersAlertTriggerPreferencesValue99_0 AlertingV3PolicyGetResponseFiltersAlertTriggerPreferencesValue = "99.0" - AlertingV3PolicyGetResponseFiltersAlertTriggerPreferencesValue98_0 AlertingV3PolicyGetResponseFiltersAlertTriggerPreferencesValue = "98.0" - AlertingV3PolicyGetResponseFiltersAlertTriggerPreferencesValue97_0 AlertingV3PolicyGetResponseFiltersAlertTriggerPreferencesValue = "97.0" -) - -type AlertingV3PolicyGetResponseFiltersIncidentImpact string - -const ( - AlertingV3PolicyGetResponseFiltersIncidentImpactIncidentImpactNone AlertingV3PolicyGetResponseFiltersIncidentImpact = "INCIDENT_IMPACT_NONE" - AlertingV3PolicyGetResponseFiltersIncidentImpactIncidentImpactMinor AlertingV3PolicyGetResponseFiltersIncidentImpact = "INCIDENT_IMPACT_MINOR" - AlertingV3PolicyGetResponseFiltersIncidentImpactIncidentImpactMajor AlertingV3PolicyGetResponseFiltersIncidentImpact = "INCIDENT_IMPACT_MAJOR" - AlertingV3PolicyGetResponseFiltersIncidentImpactIncidentImpactCritical AlertingV3PolicyGetResponseFiltersIncidentImpact = "INCIDENT_IMPACT_CRITICAL" -) - -type AlertingV3PolicyGetResponseFiltersTrafficExclusion string - -const ( - AlertingV3PolicyGetResponseFiltersTrafficExclusionSecurityEvents AlertingV3PolicyGetResponseFiltersTrafficExclusion = "security_events" -) - -type AlertingV3PolicyGetResponseMechanisms struct { - // UUID - ID AlertingV3PolicyGetResponseMechanismsID `json:"id"` - JSON alertingV3PolicyGetResponseMechanismsJSON `json:"-"` -} - -// alertingV3PolicyGetResponseMechanismsJSON contains the JSON metadata for the -// struct [AlertingV3PolicyGetResponseMechanisms] -type alertingV3PolicyGetResponseMechanismsJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyGetResponseMechanisms) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyGetResponseMechanismsJSON) RawJSON() string { - return r.raw -} - -// UUID -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type AlertingV3PolicyGetResponseMechanismsID interface { - ImplementsAlertingV3PolicyGetResponseMechanismsID() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AlertingV3PolicyGetResponseMechanismsID)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type AlertingV3PolicyNewParams struct { - // The account id - AccountID param.Field[string] `path:"account_id,required"` - // Refers to which event will trigger a Notification dispatch. You can use the - // endpoint to get available alert types which then will give you a list of - // possible values. - AlertType param.Field[AlertingV3PolicyNewParamsAlertType] `json:"alert_type,required"` - // Whether or not the Notification policy is enabled. - Enabled param.Field[bool] `json:"enabled,required"` - // List of IDs that will be used when dispatching a notification. IDs for email - // type will be the email address. - Mechanisms param.Field[map[string][]AlertingV3PolicyNewParamsMechanisms] `json:"mechanisms,required"` - // Name of the policy. - Name param.Field[string] `json:"name,required"` - // Optional description for the Notification policy. - Description param.Field[string] `json:"description"` - // Optional filters that allow you to be alerted only on a subset of events for - // that alert type based on some criteria. This is only available for select alert - // types. See alert type documentation for more details. - Filters param.Field[AlertingV3PolicyNewParamsFilters] `json:"filters"` -} - -func (r AlertingV3PolicyNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Refers to which event will trigger a Notification dispatch. You can use the -// endpoint to get available alert types which then will give you a list of -// possible values. -type AlertingV3PolicyNewParamsAlertType string - -const ( - AlertingV3PolicyNewParamsAlertTypeAccessCustomCertificateExpirationType AlertingV3PolicyNewParamsAlertType = "access_custom_certificate_expiration_type" - AlertingV3PolicyNewParamsAlertTypeAdvancedDDOSAttackL4Alert AlertingV3PolicyNewParamsAlertType = "advanced_ddos_attack_l4_alert" - AlertingV3PolicyNewParamsAlertTypeAdvancedDDOSAttackL7Alert AlertingV3PolicyNewParamsAlertType = "advanced_ddos_attack_l7_alert" - AlertingV3PolicyNewParamsAlertTypeAdvancedHTTPAlertError AlertingV3PolicyNewParamsAlertType = "advanced_http_alert_error" - AlertingV3PolicyNewParamsAlertTypeBGPHijackNotification AlertingV3PolicyNewParamsAlertType = "bgp_hijack_notification" - AlertingV3PolicyNewParamsAlertTypeBillingUsageAlert AlertingV3PolicyNewParamsAlertType = "billing_usage_alert" - AlertingV3PolicyNewParamsAlertTypeBlockNotificationBlockRemoved AlertingV3PolicyNewParamsAlertType = "block_notification_block_removed" - AlertingV3PolicyNewParamsAlertTypeBlockNotificationNewBlock AlertingV3PolicyNewParamsAlertType = "block_notification_new_block" - AlertingV3PolicyNewParamsAlertTypeBlockNotificationReviewRejected AlertingV3PolicyNewParamsAlertType = "block_notification_review_rejected" - AlertingV3PolicyNewParamsAlertTypeBrandProtectionAlert AlertingV3PolicyNewParamsAlertType = "brand_protection_alert" - AlertingV3PolicyNewParamsAlertTypeBrandProtectionDigest AlertingV3PolicyNewParamsAlertType = "brand_protection_digest" - AlertingV3PolicyNewParamsAlertTypeClickhouseAlertFwAnomaly AlertingV3PolicyNewParamsAlertType = "clickhouse_alert_fw_anomaly" - AlertingV3PolicyNewParamsAlertTypeClickhouseAlertFwEntAnomaly AlertingV3PolicyNewParamsAlertType = "clickhouse_alert_fw_ent_anomaly" - AlertingV3PolicyNewParamsAlertTypeCustomSSLCertificateEventType AlertingV3PolicyNewParamsAlertType = "custom_ssl_certificate_event_type" - AlertingV3PolicyNewParamsAlertTypeDedicatedSSLCertificateEventType AlertingV3PolicyNewParamsAlertType = "dedicated_ssl_certificate_event_type" - AlertingV3PolicyNewParamsAlertTypeDosAttackL4 AlertingV3PolicyNewParamsAlertType = "dos_attack_l4" - AlertingV3PolicyNewParamsAlertTypeDosAttackL7 AlertingV3PolicyNewParamsAlertType = "dos_attack_l7" - AlertingV3PolicyNewParamsAlertTypeExpiringServiceTokenAlert AlertingV3PolicyNewParamsAlertType = "expiring_service_token_alert" - AlertingV3PolicyNewParamsAlertTypeFailingLogpushJobDisabledAlert AlertingV3PolicyNewParamsAlertType = "failing_logpush_job_disabled_alert" - AlertingV3PolicyNewParamsAlertTypeFbmAutoAdvertisement AlertingV3PolicyNewParamsAlertType = "fbm_auto_advertisement" - AlertingV3PolicyNewParamsAlertTypeFbmDosdAttack AlertingV3PolicyNewParamsAlertType = "fbm_dosd_attack" - AlertingV3PolicyNewParamsAlertTypeFbmVolumetricAttack AlertingV3PolicyNewParamsAlertType = "fbm_volumetric_attack" - AlertingV3PolicyNewParamsAlertTypeHealthCheckStatusNotification AlertingV3PolicyNewParamsAlertType = "health_check_status_notification" - AlertingV3PolicyNewParamsAlertTypeHostnameAopCustomCertificateExpirationType AlertingV3PolicyNewParamsAlertType = "hostname_aop_custom_certificate_expiration_type" - AlertingV3PolicyNewParamsAlertTypeHTTPAlertEdgeError AlertingV3PolicyNewParamsAlertType = "http_alert_edge_error" - AlertingV3PolicyNewParamsAlertTypeHTTPAlertOriginError AlertingV3PolicyNewParamsAlertType = "http_alert_origin_error" - AlertingV3PolicyNewParamsAlertTypeIncidentAlert AlertingV3PolicyNewParamsAlertType = "incident_alert" - AlertingV3PolicyNewParamsAlertTypeLoadBalancingHealthAlert AlertingV3PolicyNewParamsAlertType = "load_balancing_health_alert" - AlertingV3PolicyNewParamsAlertTypeLoadBalancingPoolEnablementAlert AlertingV3PolicyNewParamsAlertType = "load_balancing_pool_enablement_alert" - AlertingV3PolicyNewParamsAlertTypeLogoMatchAlert AlertingV3PolicyNewParamsAlertType = "logo_match_alert" - AlertingV3PolicyNewParamsAlertTypeMagicTunnelHealthCheckEvent AlertingV3PolicyNewParamsAlertType = "magic_tunnel_health_check_event" - AlertingV3PolicyNewParamsAlertTypeMaintenanceEventNotification AlertingV3PolicyNewParamsAlertType = "maintenance_event_notification" - AlertingV3PolicyNewParamsAlertTypeMTLSCertificateStoreCertificateExpirationType AlertingV3PolicyNewParamsAlertType = "mtls_certificate_store_certificate_expiration_type" - AlertingV3PolicyNewParamsAlertTypePagesEventAlert AlertingV3PolicyNewParamsAlertType = "pages_event_alert" - AlertingV3PolicyNewParamsAlertTypeRadarNotification AlertingV3PolicyNewParamsAlertType = "radar_notification" - AlertingV3PolicyNewParamsAlertTypeRealOriginMonitoring AlertingV3PolicyNewParamsAlertType = "real_origin_monitoring" - AlertingV3PolicyNewParamsAlertTypeScriptmonitorAlertNewCodeChangeDetections AlertingV3PolicyNewParamsAlertType = "scriptmonitor_alert_new_code_change_detections" - AlertingV3PolicyNewParamsAlertTypeScriptmonitorAlertNewHosts AlertingV3PolicyNewParamsAlertType = "scriptmonitor_alert_new_hosts" - AlertingV3PolicyNewParamsAlertTypeScriptmonitorAlertNewMaliciousHosts AlertingV3PolicyNewParamsAlertType = "scriptmonitor_alert_new_malicious_hosts" - AlertingV3PolicyNewParamsAlertTypeScriptmonitorAlertNewMaliciousScripts AlertingV3PolicyNewParamsAlertType = "scriptmonitor_alert_new_malicious_scripts" - AlertingV3PolicyNewParamsAlertTypeScriptmonitorAlertNewMaliciousURL AlertingV3PolicyNewParamsAlertType = "scriptmonitor_alert_new_malicious_url" - AlertingV3PolicyNewParamsAlertTypeScriptmonitorAlertNewMaxLengthResourceURL AlertingV3PolicyNewParamsAlertType = "scriptmonitor_alert_new_max_length_resource_url" - AlertingV3PolicyNewParamsAlertTypeScriptmonitorAlertNewResources AlertingV3PolicyNewParamsAlertType = "scriptmonitor_alert_new_resources" - AlertingV3PolicyNewParamsAlertTypeSecondaryDNSAllPrimariesFailing AlertingV3PolicyNewParamsAlertType = "secondary_dns_all_primaries_failing" - AlertingV3PolicyNewParamsAlertTypeSecondaryDNSPrimariesFailing AlertingV3PolicyNewParamsAlertType = "secondary_dns_primaries_failing" - AlertingV3PolicyNewParamsAlertTypeSecondaryDNSZoneSuccessfullyUpdated AlertingV3PolicyNewParamsAlertType = "secondary_dns_zone_successfully_updated" - AlertingV3PolicyNewParamsAlertTypeSecondaryDNSZoneValidationWarning AlertingV3PolicyNewParamsAlertType = "secondary_dns_zone_validation_warning" - AlertingV3PolicyNewParamsAlertTypeSentinelAlert AlertingV3PolicyNewParamsAlertType = "sentinel_alert" - AlertingV3PolicyNewParamsAlertTypeStreamLiveNotifications AlertingV3PolicyNewParamsAlertType = "stream_live_notifications" - AlertingV3PolicyNewParamsAlertTypeTunnelHealthEvent AlertingV3PolicyNewParamsAlertType = "tunnel_health_event" - AlertingV3PolicyNewParamsAlertTypeTunnelUpdateEvent AlertingV3PolicyNewParamsAlertType = "tunnel_update_event" - AlertingV3PolicyNewParamsAlertTypeUniversalSSLEventType AlertingV3PolicyNewParamsAlertType = "universal_ssl_event_type" - AlertingV3PolicyNewParamsAlertTypeWebAnalyticsMetricsUpdate AlertingV3PolicyNewParamsAlertType = "web_analytics_metrics_update" - AlertingV3PolicyNewParamsAlertTypeZoneAopCustomCertificateExpirationType AlertingV3PolicyNewParamsAlertType = "zone_aop_custom_certificate_expiration_type" -) - -type AlertingV3PolicyNewParamsMechanisms struct { - // UUID - ID param.Field[AlertingV3PolicyNewParamsMechanismsID] `json:"id"` -} - -func (r AlertingV3PolicyNewParamsMechanisms) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// UUID -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type AlertingV3PolicyNewParamsMechanismsID interface { - ImplementsAlertingV3PolicyNewParamsMechanismsID() -} - -// Optional filters that allow you to be alerted only on a subset of events for -// that alert type based on some criteria. This is only available for select alert -// types. See alert type documentation for more details. -type AlertingV3PolicyNewParamsFilters struct { - // Usage depends on specific alert type - Actions param.Field[[]string] `json:"actions"` - // Used for configuring radar_notification - AffectedASNs param.Field[[]string] `json:"affected_asns"` - // Used for configuring incident_alert - AffectedComponents param.Field[[]string] `json:"affected_components"` - // Used for configuring radar_notification - AffectedLocations param.Field[[]string] `json:"affected_locations"` - // Used for configuring maintenance_event_notification - AirportCode param.Field[[]string] `json:"airport_code"` - // Usage depends on specific alert type - AlertTriggerPreferences param.Field[[]string] `json:"alert_trigger_preferences"` - // Used for configuring magic_tunnel_health_check_event - AlertTriggerPreferencesValue param.Field[[]AlertingV3PolicyNewParamsFiltersAlertTriggerPreferencesValue] `json:"alert_trigger_preferences_value"` - // Used for configuring load_balancing_pool_enablement_alert - Enabled param.Field[[]string] `json:"enabled"` - // Used for configuring pages_event_alert - Environment param.Field[[]string] `json:"environment"` - // Used for configuring pages_event_alert - Event param.Field[[]string] `json:"event"` - // Used for configuring load_balancing_health_alert - EventSource param.Field[[]string] `json:"event_source"` - // Usage depends on specific alert type - EventType param.Field[[]string] `json:"event_type"` - // Usage depends on specific alert type - GroupBy param.Field[[]string] `json:"group_by"` - // Used for configuring health_check_status_notification - HealthCheckID param.Field[[]string] `json:"health_check_id"` - // Used for configuring incident_alert - IncidentImpact param.Field[[]AlertingV3PolicyNewParamsFiltersIncidentImpact] `json:"incident_impact"` - // Used for configuring stream_live_notifications - InputID param.Field[[]string] `json:"input_id"` - // Used for configuring billing_usage_alert - Limit param.Field[[]string] `json:"limit"` - // Used for configuring logo_match_alert - LogoTag param.Field[[]string] `json:"logo_tag"` - // Used for configuring advanced_ddos_attack_l4_alert - MegabitsPerSecond param.Field[[]string] `json:"megabits_per_second"` - // Used for configuring load_balancing_health_alert - NewHealth param.Field[[]string] `json:"new_health"` - // Used for configuring tunnel_health_event - NewStatus param.Field[[]string] `json:"new_status"` - // Used for configuring advanced_ddos_attack_l4_alert - PacketsPerSecond param.Field[[]string] `json:"packets_per_second"` - // Usage depends on specific alert type - PoolID param.Field[[]string] `json:"pool_id"` - // Used for configuring billing_usage_alert - Product param.Field[[]string] `json:"product"` - // Used for configuring pages_event_alert - ProjectID param.Field[[]string] `json:"project_id"` - // Used for configuring advanced_ddos_attack_l4_alert - Protocol param.Field[[]string] `json:"protocol"` - // Usage depends on specific alert type - QueryTag param.Field[[]string] `json:"query_tag"` - // Used for configuring advanced_ddos_attack_l7_alert - RequestsPerSecond param.Field[[]string] `json:"requests_per_second"` - // Usage depends on specific alert type - Selectors param.Field[[]string] `json:"selectors"` - // Used for configuring clickhouse_alert_fw_ent_anomaly - Services param.Field[[]string] `json:"services"` - // Usage depends on specific alert type - Slo param.Field[[]string] `json:"slo"` - // Used for configuring health_check_status_notification - Status param.Field[[]string] `json:"status"` - // Used for configuring advanced_ddos_attack_l7_alert - TargetHostname param.Field[[]string] `json:"target_hostname"` - // Used for configuring advanced_ddos_attack_l4_alert - TargetIP param.Field[[]string] `json:"target_ip"` - // Used for configuring advanced_ddos_attack_l7_alert - TargetZoneName param.Field[[]string] `json:"target_zone_name"` - // Used for configuring traffic_anomalies_alert - TrafficExclusions param.Field[[]AlertingV3PolicyNewParamsFiltersTrafficExclusion] `json:"traffic_exclusions"` - // Used for configuring tunnel_health_event - TunnelID param.Field[[]string] `json:"tunnel_id"` - // Used for configuring magic_tunnel_health_check_event - TunnelName param.Field[[]string] `json:"tunnel_name"` - // Usage depends on specific alert type - Where param.Field[[]string] `json:"where"` - // Usage depends on specific alert type - Zones param.Field[[]string] `json:"zones"` -} - -func (r AlertingV3PolicyNewParamsFilters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AlertingV3PolicyNewParamsFiltersAlertTriggerPreferencesValue string - -const ( - AlertingV3PolicyNewParamsFiltersAlertTriggerPreferencesValue99_0 AlertingV3PolicyNewParamsFiltersAlertTriggerPreferencesValue = "99.0" - AlertingV3PolicyNewParamsFiltersAlertTriggerPreferencesValue98_0 AlertingV3PolicyNewParamsFiltersAlertTriggerPreferencesValue = "98.0" - AlertingV3PolicyNewParamsFiltersAlertTriggerPreferencesValue97_0 AlertingV3PolicyNewParamsFiltersAlertTriggerPreferencesValue = "97.0" -) - -type AlertingV3PolicyNewParamsFiltersIncidentImpact string - -const ( - AlertingV3PolicyNewParamsFiltersIncidentImpactIncidentImpactNone AlertingV3PolicyNewParamsFiltersIncidentImpact = "INCIDENT_IMPACT_NONE" - AlertingV3PolicyNewParamsFiltersIncidentImpactIncidentImpactMinor AlertingV3PolicyNewParamsFiltersIncidentImpact = "INCIDENT_IMPACT_MINOR" - AlertingV3PolicyNewParamsFiltersIncidentImpactIncidentImpactMajor AlertingV3PolicyNewParamsFiltersIncidentImpact = "INCIDENT_IMPACT_MAJOR" - AlertingV3PolicyNewParamsFiltersIncidentImpactIncidentImpactCritical AlertingV3PolicyNewParamsFiltersIncidentImpact = "INCIDENT_IMPACT_CRITICAL" -) - -type AlertingV3PolicyNewParamsFiltersTrafficExclusion string - -const ( - AlertingV3PolicyNewParamsFiltersTrafficExclusionSecurityEvents AlertingV3PolicyNewParamsFiltersTrafficExclusion = "security_events" -) - -type AlertingV3PolicyNewResponseEnvelope struct { - Errors []AlertingV3PolicyNewResponseEnvelopeErrors `json:"errors,required"` - Messages []AlertingV3PolicyNewResponseEnvelopeMessages `json:"messages,required"` - Result AlertingV3PolicyNewResponse `json:"result,required"` - // Whether the API call was successful - Success AlertingV3PolicyNewResponseEnvelopeSuccess `json:"success,required"` - JSON alertingV3PolicyNewResponseEnvelopeJSON `json:"-"` -} - -// alertingV3PolicyNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [AlertingV3PolicyNewResponseEnvelope] -type alertingV3PolicyNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AlertingV3PolicyNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3PolicyNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// alertingV3PolicyNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AlertingV3PolicyNewResponseEnvelopeErrors] -type alertingV3PolicyNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AlertingV3PolicyNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3PolicyNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// alertingV3PolicyNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AlertingV3PolicyNewResponseEnvelopeMessages] -type alertingV3PolicyNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AlertingV3PolicyNewResponseEnvelopeSuccess bool - -const ( - AlertingV3PolicyNewResponseEnvelopeSuccessTrue AlertingV3PolicyNewResponseEnvelopeSuccess = true -) - -type AlertingV3PolicyUpdateParams struct { - // The account id - AccountID param.Field[string] `path:"account_id,required"` - // Refers to which event will trigger a Notification dispatch. You can use the - // endpoint to get available alert types which then will give you a list of - // possible values. - AlertType param.Field[AlertingV3PolicyUpdateParamsAlertType] `json:"alert_type"` - // Optional description for the Notification policy. - Description param.Field[string] `json:"description"` - // Whether or not the Notification policy is enabled. - Enabled param.Field[bool] `json:"enabled"` - // Optional filters that allow you to be alerted only on a subset of events for - // that alert type based on some criteria. This is only available for select alert - // types. See alert type documentation for more details. - Filters param.Field[AlertingV3PolicyUpdateParamsFilters] `json:"filters"` - // List of IDs that will be used when dispatching a notification. IDs for email - // type will be the email address. - Mechanisms param.Field[map[string][]AlertingV3PolicyUpdateParamsMechanisms] `json:"mechanisms"` - // Name of the policy. - Name param.Field[string] `json:"name"` -} - -func (r AlertingV3PolicyUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Refers to which event will trigger a Notification dispatch. You can use the -// endpoint to get available alert types which then will give you a list of -// possible values. -type AlertingV3PolicyUpdateParamsAlertType string - -const ( - AlertingV3PolicyUpdateParamsAlertTypeAccessCustomCertificateExpirationType AlertingV3PolicyUpdateParamsAlertType = "access_custom_certificate_expiration_type" - AlertingV3PolicyUpdateParamsAlertTypeAdvancedDDOSAttackL4Alert AlertingV3PolicyUpdateParamsAlertType = "advanced_ddos_attack_l4_alert" - AlertingV3PolicyUpdateParamsAlertTypeAdvancedDDOSAttackL7Alert AlertingV3PolicyUpdateParamsAlertType = "advanced_ddos_attack_l7_alert" - AlertingV3PolicyUpdateParamsAlertTypeAdvancedHTTPAlertError AlertingV3PolicyUpdateParamsAlertType = "advanced_http_alert_error" - AlertingV3PolicyUpdateParamsAlertTypeBGPHijackNotification AlertingV3PolicyUpdateParamsAlertType = "bgp_hijack_notification" - AlertingV3PolicyUpdateParamsAlertTypeBillingUsageAlert AlertingV3PolicyUpdateParamsAlertType = "billing_usage_alert" - AlertingV3PolicyUpdateParamsAlertTypeBlockNotificationBlockRemoved AlertingV3PolicyUpdateParamsAlertType = "block_notification_block_removed" - AlertingV3PolicyUpdateParamsAlertTypeBlockNotificationNewBlock AlertingV3PolicyUpdateParamsAlertType = "block_notification_new_block" - AlertingV3PolicyUpdateParamsAlertTypeBlockNotificationReviewRejected AlertingV3PolicyUpdateParamsAlertType = "block_notification_review_rejected" - AlertingV3PolicyUpdateParamsAlertTypeBrandProtectionAlert AlertingV3PolicyUpdateParamsAlertType = "brand_protection_alert" - AlertingV3PolicyUpdateParamsAlertTypeBrandProtectionDigest AlertingV3PolicyUpdateParamsAlertType = "brand_protection_digest" - AlertingV3PolicyUpdateParamsAlertTypeClickhouseAlertFwAnomaly AlertingV3PolicyUpdateParamsAlertType = "clickhouse_alert_fw_anomaly" - AlertingV3PolicyUpdateParamsAlertTypeClickhouseAlertFwEntAnomaly AlertingV3PolicyUpdateParamsAlertType = "clickhouse_alert_fw_ent_anomaly" - AlertingV3PolicyUpdateParamsAlertTypeCustomSSLCertificateEventType AlertingV3PolicyUpdateParamsAlertType = "custom_ssl_certificate_event_type" - AlertingV3PolicyUpdateParamsAlertTypeDedicatedSSLCertificateEventType AlertingV3PolicyUpdateParamsAlertType = "dedicated_ssl_certificate_event_type" - AlertingV3PolicyUpdateParamsAlertTypeDosAttackL4 AlertingV3PolicyUpdateParamsAlertType = "dos_attack_l4" - AlertingV3PolicyUpdateParamsAlertTypeDosAttackL7 AlertingV3PolicyUpdateParamsAlertType = "dos_attack_l7" - AlertingV3PolicyUpdateParamsAlertTypeExpiringServiceTokenAlert AlertingV3PolicyUpdateParamsAlertType = "expiring_service_token_alert" - AlertingV3PolicyUpdateParamsAlertTypeFailingLogpushJobDisabledAlert AlertingV3PolicyUpdateParamsAlertType = "failing_logpush_job_disabled_alert" - AlertingV3PolicyUpdateParamsAlertTypeFbmAutoAdvertisement AlertingV3PolicyUpdateParamsAlertType = "fbm_auto_advertisement" - AlertingV3PolicyUpdateParamsAlertTypeFbmDosdAttack AlertingV3PolicyUpdateParamsAlertType = "fbm_dosd_attack" - AlertingV3PolicyUpdateParamsAlertTypeFbmVolumetricAttack AlertingV3PolicyUpdateParamsAlertType = "fbm_volumetric_attack" - AlertingV3PolicyUpdateParamsAlertTypeHealthCheckStatusNotification AlertingV3PolicyUpdateParamsAlertType = "health_check_status_notification" - AlertingV3PolicyUpdateParamsAlertTypeHostnameAopCustomCertificateExpirationType AlertingV3PolicyUpdateParamsAlertType = "hostname_aop_custom_certificate_expiration_type" - AlertingV3PolicyUpdateParamsAlertTypeHTTPAlertEdgeError AlertingV3PolicyUpdateParamsAlertType = "http_alert_edge_error" - AlertingV3PolicyUpdateParamsAlertTypeHTTPAlertOriginError AlertingV3PolicyUpdateParamsAlertType = "http_alert_origin_error" - AlertingV3PolicyUpdateParamsAlertTypeIncidentAlert AlertingV3PolicyUpdateParamsAlertType = "incident_alert" - AlertingV3PolicyUpdateParamsAlertTypeLoadBalancingHealthAlert AlertingV3PolicyUpdateParamsAlertType = "load_balancing_health_alert" - AlertingV3PolicyUpdateParamsAlertTypeLoadBalancingPoolEnablementAlert AlertingV3PolicyUpdateParamsAlertType = "load_balancing_pool_enablement_alert" - AlertingV3PolicyUpdateParamsAlertTypeLogoMatchAlert AlertingV3PolicyUpdateParamsAlertType = "logo_match_alert" - AlertingV3PolicyUpdateParamsAlertTypeMagicTunnelHealthCheckEvent AlertingV3PolicyUpdateParamsAlertType = "magic_tunnel_health_check_event" - AlertingV3PolicyUpdateParamsAlertTypeMaintenanceEventNotification AlertingV3PolicyUpdateParamsAlertType = "maintenance_event_notification" - AlertingV3PolicyUpdateParamsAlertTypeMTLSCertificateStoreCertificateExpirationType AlertingV3PolicyUpdateParamsAlertType = "mtls_certificate_store_certificate_expiration_type" - AlertingV3PolicyUpdateParamsAlertTypePagesEventAlert AlertingV3PolicyUpdateParamsAlertType = "pages_event_alert" - AlertingV3PolicyUpdateParamsAlertTypeRadarNotification AlertingV3PolicyUpdateParamsAlertType = "radar_notification" - AlertingV3PolicyUpdateParamsAlertTypeRealOriginMonitoring AlertingV3PolicyUpdateParamsAlertType = "real_origin_monitoring" - AlertingV3PolicyUpdateParamsAlertTypeScriptmonitorAlertNewCodeChangeDetections AlertingV3PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_code_change_detections" - AlertingV3PolicyUpdateParamsAlertTypeScriptmonitorAlertNewHosts AlertingV3PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_hosts" - AlertingV3PolicyUpdateParamsAlertTypeScriptmonitorAlertNewMaliciousHosts AlertingV3PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_malicious_hosts" - AlertingV3PolicyUpdateParamsAlertTypeScriptmonitorAlertNewMaliciousScripts AlertingV3PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_malicious_scripts" - AlertingV3PolicyUpdateParamsAlertTypeScriptmonitorAlertNewMaliciousURL AlertingV3PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_malicious_url" - AlertingV3PolicyUpdateParamsAlertTypeScriptmonitorAlertNewMaxLengthResourceURL AlertingV3PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_max_length_resource_url" - AlertingV3PolicyUpdateParamsAlertTypeScriptmonitorAlertNewResources AlertingV3PolicyUpdateParamsAlertType = "scriptmonitor_alert_new_resources" - AlertingV3PolicyUpdateParamsAlertTypeSecondaryDNSAllPrimariesFailing AlertingV3PolicyUpdateParamsAlertType = "secondary_dns_all_primaries_failing" - AlertingV3PolicyUpdateParamsAlertTypeSecondaryDNSPrimariesFailing AlertingV3PolicyUpdateParamsAlertType = "secondary_dns_primaries_failing" - AlertingV3PolicyUpdateParamsAlertTypeSecondaryDNSZoneSuccessfullyUpdated AlertingV3PolicyUpdateParamsAlertType = "secondary_dns_zone_successfully_updated" - AlertingV3PolicyUpdateParamsAlertTypeSecondaryDNSZoneValidationWarning AlertingV3PolicyUpdateParamsAlertType = "secondary_dns_zone_validation_warning" - AlertingV3PolicyUpdateParamsAlertTypeSentinelAlert AlertingV3PolicyUpdateParamsAlertType = "sentinel_alert" - AlertingV3PolicyUpdateParamsAlertTypeStreamLiveNotifications AlertingV3PolicyUpdateParamsAlertType = "stream_live_notifications" - AlertingV3PolicyUpdateParamsAlertTypeTunnelHealthEvent AlertingV3PolicyUpdateParamsAlertType = "tunnel_health_event" - AlertingV3PolicyUpdateParamsAlertTypeTunnelUpdateEvent AlertingV3PolicyUpdateParamsAlertType = "tunnel_update_event" - AlertingV3PolicyUpdateParamsAlertTypeUniversalSSLEventType AlertingV3PolicyUpdateParamsAlertType = "universal_ssl_event_type" - AlertingV3PolicyUpdateParamsAlertTypeWebAnalyticsMetricsUpdate AlertingV3PolicyUpdateParamsAlertType = "web_analytics_metrics_update" - AlertingV3PolicyUpdateParamsAlertTypeZoneAopCustomCertificateExpirationType AlertingV3PolicyUpdateParamsAlertType = "zone_aop_custom_certificate_expiration_type" -) - -// Optional filters that allow you to be alerted only on a subset of events for -// that alert type based on some criteria. This is only available for select alert -// types. See alert type documentation for more details. -type AlertingV3PolicyUpdateParamsFilters struct { - // Usage depends on specific alert type - Actions param.Field[[]string] `json:"actions"` - // Used for configuring radar_notification - AffectedASNs param.Field[[]string] `json:"affected_asns"` - // Used for configuring incident_alert - AffectedComponents param.Field[[]string] `json:"affected_components"` - // Used for configuring radar_notification - AffectedLocations param.Field[[]string] `json:"affected_locations"` - // Used for configuring maintenance_event_notification - AirportCode param.Field[[]string] `json:"airport_code"` - // Usage depends on specific alert type - AlertTriggerPreferences param.Field[[]string] `json:"alert_trigger_preferences"` - // Used for configuring magic_tunnel_health_check_event - AlertTriggerPreferencesValue param.Field[[]AlertingV3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue] `json:"alert_trigger_preferences_value"` - // Used for configuring load_balancing_pool_enablement_alert - Enabled param.Field[[]string] `json:"enabled"` - // Used for configuring pages_event_alert - Environment param.Field[[]string] `json:"environment"` - // Used for configuring pages_event_alert - Event param.Field[[]string] `json:"event"` - // Used for configuring load_balancing_health_alert - EventSource param.Field[[]string] `json:"event_source"` - // Usage depends on specific alert type - EventType param.Field[[]string] `json:"event_type"` - // Usage depends on specific alert type - GroupBy param.Field[[]string] `json:"group_by"` - // Used for configuring health_check_status_notification - HealthCheckID param.Field[[]string] `json:"health_check_id"` - // Used for configuring incident_alert - IncidentImpact param.Field[[]AlertingV3PolicyUpdateParamsFiltersIncidentImpact] `json:"incident_impact"` - // Used for configuring stream_live_notifications - InputID param.Field[[]string] `json:"input_id"` - // Used for configuring billing_usage_alert - Limit param.Field[[]string] `json:"limit"` - // Used for configuring logo_match_alert - LogoTag param.Field[[]string] `json:"logo_tag"` - // Used for configuring advanced_ddos_attack_l4_alert - MegabitsPerSecond param.Field[[]string] `json:"megabits_per_second"` - // Used for configuring load_balancing_health_alert - NewHealth param.Field[[]string] `json:"new_health"` - // Used for configuring tunnel_health_event - NewStatus param.Field[[]string] `json:"new_status"` - // Used for configuring advanced_ddos_attack_l4_alert - PacketsPerSecond param.Field[[]string] `json:"packets_per_second"` - // Usage depends on specific alert type - PoolID param.Field[[]string] `json:"pool_id"` - // Used for configuring billing_usage_alert - Product param.Field[[]string] `json:"product"` - // Used for configuring pages_event_alert - ProjectID param.Field[[]string] `json:"project_id"` - // Used for configuring advanced_ddos_attack_l4_alert - Protocol param.Field[[]string] `json:"protocol"` - // Usage depends on specific alert type - QueryTag param.Field[[]string] `json:"query_tag"` - // Used for configuring advanced_ddos_attack_l7_alert - RequestsPerSecond param.Field[[]string] `json:"requests_per_second"` - // Usage depends on specific alert type - Selectors param.Field[[]string] `json:"selectors"` - // Used for configuring clickhouse_alert_fw_ent_anomaly - Services param.Field[[]string] `json:"services"` - // Usage depends on specific alert type - Slo param.Field[[]string] `json:"slo"` - // Used for configuring health_check_status_notification - Status param.Field[[]string] `json:"status"` - // Used for configuring advanced_ddos_attack_l7_alert - TargetHostname param.Field[[]string] `json:"target_hostname"` - // Used for configuring advanced_ddos_attack_l4_alert - TargetIP param.Field[[]string] `json:"target_ip"` - // Used for configuring advanced_ddos_attack_l7_alert - TargetZoneName param.Field[[]string] `json:"target_zone_name"` - // Used for configuring traffic_anomalies_alert - TrafficExclusions param.Field[[]AlertingV3PolicyUpdateParamsFiltersTrafficExclusion] `json:"traffic_exclusions"` - // Used for configuring tunnel_health_event - TunnelID param.Field[[]string] `json:"tunnel_id"` - // Used for configuring magic_tunnel_health_check_event - TunnelName param.Field[[]string] `json:"tunnel_name"` - // Usage depends on specific alert type - Where param.Field[[]string] `json:"where"` - // Usage depends on specific alert type - Zones param.Field[[]string] `json:"zones"` -} - -func (r AlertingV3PolicyUpdateParamsFilters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type AlertingV3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue string - -const ( - AlertingV3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue99_0 AlertingV3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue = "99.0" - AlertingV3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue98_0 AlertingV3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue = "98.0" - AlertingV3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue97_0 AlertingV3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue = "97.0" -) - -type AlertingV3PolicyUpdateParamsFiltersIncidentImpact string - -const ( - AlertingV3PolicyUpdateParamsFiltersIncidentImpactIncidentImpactNone AlertingV3PolicyUpdateParamsFiltersIncidentImpact = "INCIDENT_IMPACT_NONE" - AlertingV3PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMinor AlertingV3PolicyUpdateParamsFiltersIncidentImpact = "INCIDENT_IMPACT_MINOR" - AlertingV3PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMajor AlertingV3PolicyUpdateParamsFiltersIncidentImpact = "INCIDENT_IMPACT_MAJOR" - AlertingV3PolicyUpdateParamsFiltersIncidentImpactIncidentImpactCritical AlertingV3PolicyUpdateParamsFiltersIncidentImpact = "INCIDENT_IMPACT_CRITICAL" -) - -type AlertingV3PolicyUpdateParamsFiltersTrafficExclusion string - -const ( - AlertingV3PolicyUpdateParamsFiltersTrafficExclusionSecurityEvents AlertingV3PolicyUpdateParamsFiltersTrafficExclusion = "security_events" -) - -type AlertingV3PolicyUpdateParamsMechanisms struct { - // UUID - ID param.Field[AlertingV3PolicyUpdateParamsMechanismsID] `json:"id"` -} - -func (r AlertingV3PolicyUpdateParamsMechanisms) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// UUID -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type AlertingV3PolicyUpdateParamsMechanismsID interface { - ImplementsAlertingV3PolicyUpdateParamsMechanismsID() -} - -type AlertingV3PolicyUpdateResponseEnvelope struct { - Errors []AlertingV3PolicyUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []AlertingV3PolicyUpdateResponseEnvelopeMessages `json:"messages,required"` - Result AlertingV3PolicyUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success AlertingV3PolicyUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON alertingV3PolicyUpdateResponseEnvelopeJSON `json:"-"` -} - -// alertingV3PolicyUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [AlertingV3PolicyUpdateResponseEnvelope] -type alertingV3PolicyUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AlertingV3PolicyUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3PolicyUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// alertingV3PolicyUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AlertingV3PolicyUpdateResponseEnvelopeErrors] -type alertingV3PolicyUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AlertingV3PolicyUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3PolicyUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// alertingV3PolicyUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AlertingV3PolicyUpdateResponseEnvelopeMessages] -type alertingV3PolicyUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AlertingV3PolicyUpdateResponseEnvelopeSuccess bool - -const ( - AlertingV3PolicyUpdateResponseEnvelopeSuccessTrue AlertingV3PolicyUpdateResponseEnvelopeSuccess = true -) - -type AlertingV3PolicyListParams struct { - // The account id - AccountID param.Field[string] `path:"account_id,required"` -} - -type AlertingV3PolicyListResponseEnvelope struct { - Errors []AlertingV3PolicyListResponseEnvelopeErrors `json:"errors,required"` - Messages []AlertingV3PolicyListResponseEnvelopeMessages `json:"messages,required"` - Result []AlertingV3PolicyListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AlertingV3PolicyListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AlertingV3PolicyListResponseEnvelopeResultInfo `json:"result_info"` - JSON alertingV3PolicyListResponseEnvelopeJSON `json:"-"` -} - -// alertingV3PolicyListResponseEnvelopeJSON contains the JSON metadata for the -// struct [AlertingV3PolicyListResponseEnvelope] -type alertingV3PolicyListResponseEnvelopeJSON 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 *AlertingV3PolicyListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AlertingV3PolicyListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3PolicyListResponseEnvelopeErrorsJSON `json:"-"` -} - -// alertingV3PolicyListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AlertingV3PolicyListResponseEnvelopeErrors] -type alertingV3PolicyListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AlertingV3PolicyListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3PolicyListResponseEnvelopeMessagesJSON `json:"-"` -} - -// alertingV3PolicyListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AlertingV3PolicyListResponseEnvelopeMessages] -type alertingV3PolicyListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AlertingV3PolicyListResponseEnvelopeSuccess bool - -const ( - AlertingV3PolicyListResponseEnvelopeSuccessTrue AlertingV3PolicyListResponseEnvelopeSuccess = true -) - -type AlertingV3PolicyListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON alertingV3PolicyListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// alertingV3PolicyListResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [AlertingV3PolicyListResponseEnvelopeResultInfo] -type alertingV3PolicyListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type AlertingV3PolicyDeleteParams struct { - // The account id - AccountID param.Field[string] `path:"account_id,required"` -} - -type AlertingV3PolicyDeleteResponseEnvelope struct { - Errors []AlertingV3PolicyDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []AlertingV3PolicyDeleteResponseEnvelopeMessages `json:"messages,required"` - Result AlertingV3PolicyDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AlertingV3PolicyDeleteResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AlertingV3PolicyDeleteResponseEnvelopeResultInfo `json:"result_info"` - JSON alertingV3PolicyDeleteResponseEnvelopeJSON `json:"-"` -} - -// alertingV3PolicyDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [AlertingV3PolicyDeleteResponseEnvelope] -type alertingV3PolicyDeleteResponseEnvelopeJSON 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 *AlertingV3PolicyDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AlertingV3PolicyDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3PolicyDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// alertingV3PolicyDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [AlertingV3PolicyDeleteResponseEnvelopeErrors] -type alertingV3PolicyDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AlertingV3PolicyDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3PolicyDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// alertingV3PolicyDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [AlertingV3PolicyDeleteResponseEnvelopeMessages] -type alertingV3PolicyDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AlertingV3PolicyDeleteResponseEnvelopeSuccess bool - -const ( - AlertingV3PolicyDeleteResponseEnvelopeSuccessTrue AlertingV3PolicyDeleteResponseEnvelopeSuccess = true -) - -type AlertingV3PolicyDeleteResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON alertingV3PolicyDeleteResponseEnvelopeResultInfoJSON `json:"-"` -} - -// alertingV3PolicyDeleteResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [AlertingV3PolicyDeleteResponseEnvelopeResultInfo] -type alertingV3PolicyDeleteResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type AlertingV3PolicyGetParams struct { - // The account id - AccountID param.Field[string] `path:"account_id,required"` -} - -type AlertingV3PolicyGetResponseEnvelope struct { - Errors []AlertingV3PolicyGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AlertingV3PolicyGetResponseEnvelopeMessages `json:"messages,required"` - Result AlertingV3PolicyGetResponse `json:"result,required"` - // Whether the API call was successful - Success AlertingV3PolicyGetResponseEnvelopeSuccess `json:"success,required"` - JSON alertingV3PolicyGetResponseEnvelopeJSON `json:"-"` -} - -// alertingV3PolicyGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [AlertingV3PolicyGetResponseEnvelope] -type alertingV3PolicyGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AlertingV3PolicyGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3PolicyGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// alertingV3PolicyGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AlertingV3PolicyGetResponseEnvelopeErrors] -type alertingV3PolicyGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AlertingV3PolicyGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON alertingV3PolicyGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// alertingV3PolicyGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [AlertingV3PolicyGetResponseEnvelopeMessages] -type alertingV3PolicyGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingV3PolicyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingV3PolicyGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AlertingV3PolicyGetResponseEnvelopeSuccess bool - -const ( - AlertingV3PolicyGetResponseEnvelopeSuccessTrue AlertingV3PolicyGetResponseEnvelopeSuccess = true -) diff --git a/alertingv3policy_test.go b/alertingv3policy_test.go deleted file mode 100644 index ce9c0a6c3ec..00000000000 --- a/alertingv3policy_test.go +++ /dev/null @@ -1,271 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAlertingV3PolicyNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Alerting.V3.Policies.New(context.TODO(), cloudflare.AlertingV3PolicyNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - AlertType: cloudflare.F(cloudflare.AlertingV3PolicyNewParamsAlertTypeUniversalSSLEventType), - Enabled: cloudflare.F(true), - Mechanisms: cloudflare.F(map[string][]cloudflare.AlertingV3PolicyNewParamsMechanisms{ - "email": {{ - ID: cloudflare.F[cloudflare.AlertingV3PolicyNewParamsMechanismsID](shared.UnionString("test@example.com")), - }}, - "pagerduty": {{ - ID: cloudflare.F[cloudflare.AlertingV3PolicyNewParamsMechanismsID](shared.UnionString("e8133a15-00a4-4d69-aec1-32f70c51f6e5")), - }}, - "webhooks": {{ - ID: cloudflare.F[cloudflare.AlertingV3PolicyNewParamsMechanismsID](shared.UnionString("14cc1190-5d2b-4b98-a696-c424cb2ad05f")), - }}, - }), - Name: cloudflare.F("SSL Notification Event Policy"), - Description: cloudflare.F("Something describing the policy."), - Filters: cloudflare.F(cloudflare.AlertingV3PolicyNewParamsFilters{ - Actions: cloudflare.F([]string{"string", "string", "string"}), - AffectedASNs: cloudflare.F([]string{"string", "string", "string"}), - AffectedComponents: cloudflare.F([]string{"string", "string", "string"}), - AffectedLocations: cloudflare.F([]string{"string", "string", "string"}), - AirportCode: cloudflare.F([]string{"string", "string", "string"}), - AlertTriggerPreferences: cloudflare.F([]string{"string", "string", "string"}), - AlertTriggerPreferencesValue: cloudflare.F([]cloudflare.AlertingV3PolicyNewParamsFiltersAlertTriggerPreferencesValue{cloudflare.AlertingV3PolicyNewParamsFiltersAlertTriggerPreferencesValue99_0, cloudflare.AlertingV3PolicyNewParamsFiltersAlertTriggerPreferencesValue98_0, cloudflare.AlertingV3PolicyNewParamsFiltersAlertTriggerPreferencesValue97_0}), - Enabled: cloudflare.F([]string{"string", "string", "string"}), - Environment: cloudflare.F([]string{"string", "string", "string"}), - Event: cloudflare.F([]string{"string", "string", "string"}), - EventSource: cloudflare.F([]string{"string", "string", "string"}), - EventType: cloudflare.F([]string{"string", "string", "string"}), - GroupBy: cloudflare.F([]string{"string", "string", "string"}), - HealthCheckID: cloudflare.F([]string{"string", "string", "string"}), - IncidentImpact: cloudflare.F([]cloudflare.AlertingV3PolicyNewParamsFiltersIncidentImpact{cloudflare.AlertingV3PolicyNewParamsFiltersIncidentImpactIncidentImpactNone, cloudflare.AlertingV3PolicyNewParamsFiltersIncidentImpactIncidentImpactMinor, cloudflare.AlertingV3PolicyNewParamsFiltersIncidentImpactIncidentImpactMajor}), - InputID: cloudflare.F([]string{"string", "string", "string"}), - Limit: cloudflare.F([]string{"string", "string", "string"}), - LogoTag: cloudflare.F([]string{"string", "string", "string"}), - MegabitsPerSecond: cloudflare.F([]string{"string", "string", "string"}), - NewHealth: cloudflare.F([]string{"string", "string", "string"}), - NewStatus: cloudflare.F([]string{"string", "string", "string"}), - PacketsPerSecond: cloudflare.F([]string{"string", "string", "string"}), - PoolID: cloudflare.F([]string{"string", "string", "string"}), - Product: cloudflare.F([]string{"string", "string", "string"}), - ProjectID: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]string{"string", "string", "string"}), - QueryTag: cloudflare.F([]string{"string", "string", "string"}), - RequestsPerSecond: cloudflare.F([]string{"string", "string", "string"}), - Selectors: cloudflare.F([]string{"string", "string", "string"}), - Services: cloudflare.F([]string{"string", "string", "string"}), - Slo: cloudflare.F([]string{"99.9"}), - Status: cloudflare.F([]string{"string", "string", "string"}), - TargetHostname: cloudflare.F([]string{"string", "string", "string"}), - TargetIP: cloudflare.F([]string{"string", "string", "string"}), - TargetZoneName: cloudflare.F([]string{"string", "string", "string"}), - TrafficExclusions: cloudflare.F([]cloudflare.AlertingV3PolicyNewParamsFiltersTrafficExclusion{cloudflare.AlertingV3PolicyNewParamsFiltersTrafficExclusionSecurityEvents}), - TunnelID: cloudflare.F([]string{"string", "string", "string"}), - TunnelName: cloudflare.F([]string{"string", "string", "string"}), - Where: cloudflare.F([]string{"string", "string", "string"}), - Zones: cloudflare.F([]string{"string", "string", "string"}), - }), - }) - 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 TestAlertingV3PolicyUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Alerting.V3.Policies.Update( - context.TODO(), - "0da2b59e-f118-439d-8097-bdfb215203c9", - cloudflare.AlertingV3PolicyUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - AlertType: cloudflare.F(cloudflare.AlertingV3PolicyUpdateParamsAlertTypeUniversalSSLEventType), - Description: cloudflare.F("Something describing the policy."), - Enabled: cloudflare.F(true), - Filters: cloudflare.F(cloudflare.AlertingV3PolicyUpdateParamsFilters{ - Actions: cloudflare.F([]string{"string", "string", "string"}), - AffectedASNs: cloudflare.F([]string{"string", "string", "string"}), - AffectedComponents: cloudflare.F([]string{"string", "string", "string"}), - AffectedLocations: cloudflare.F([]string{"string", "string", "string"}), - AirportCode: cloudflare.F([]string{"string", "string", "string"}), - AlertTriggerPreferences: cloudflare.F([]string{"string", "string", "string"}), - AlertTriggerPreferencesValue: cloudflare.F([]cloudflare.AlertingV3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue{cloudflare.AlertingV3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue99_0, cloudflare.AlertingV3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue98_0, cloudflare.AlertingV3PolicyUpdateParamsFiltersAlertTriggerPreferencesValue97_0}), - Enabled: cloudflare.F([]string{"string", "string", "string"}), - Environment: cloudflare.F([]string{"string", "string", "string"}), - Event: cloudflare.F([]string{"string", "string", "string"}), - EventSource: cloudflare.F([]string{"string", "string", "string"}), - EventType: cloudflare.F([]string{"string", "string", "string"}), - GroupBy: cloudflare.F([]string{"string", "string", "string"}), - HealthCheckID: cloudflare.F([]string{"string", "string", "string"}), - IncidentImpact: cloudflare.F([]cloudflare.AlertingV3PolicyUpdateParamsFiltersIncidentImpact{cloudflare.AlertingV3PolicyUpdateParamsFiltersIncidentImpactIncidentImpactNone, cloudflare.AlertingV3PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMinor, cloudflare.AlertingV3PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMajor}), - InputID: cloudflare.F([]string{"string", "string", "string"}), - Limit: cloudflare.F([]string{"string", "string", "string"}), - LogoTag: cloudflare.F([]string{"string", "string", "string"}), - MegabitsPerSecond: cloudflare.F([]string{"string", "string", "string"}), - NewHealth: cloudflare.F([]string{"string", "string", "string"}), - NewStatus: cloudflare.F([]string{"string", "string", "string"}), - PacketsPerSecond: cloudflare.F([]string{"string", "string", "string"}), - PoolID: cloudflare.F([]string{"string", "string", "string"}), - Product: cloudflare.F([]string{"string", "string", "string"}), - ProjectID: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]string{"string", "string", "string"}), - QueryTag: cloudflare.F([]string{"string", "string", "string"}), - RequestsPerSecond: cloudflare.F([]string{"string", "string", "string"}), - Selectors: cloudflare.F([]string{"string", "string", "string"}), - Services: cloudflare.F([]string{"string", "string", "string"}), - Slo: cloudflare.F([]string{"99.9"}), - Status: cloudflare.F([]string{"string", "string", "string"}), - TargetHostname: cloudflare.F([]string{"string", "string", "string"}), - TargetIP: cloudflare.F([]string{"string", "string", "string"}), - TargetZoneName: cloudflare.F([]string{"string", "string", "string"}), - TrafficExclusions: cloudflare.F([]cloudflare.AlertingV3PolicyUpdateParamsFiltersTrafficExclusion{cloudflare.AlertingV3PolicyUpdateParamsFiltersTrafficExclusionSecurityEvents}), - TunnelID: cloudflare.F([]string{"string", "string", "string"}), - TunnelName: cloudflare.F([]string{"string", "string", "string"}), - Where: cloudflare.F([]string{"string", "string", "string"}), - Zones: cloudflare.F([]string{"string", "string", "string"}), - }), - Mechanisms: cloudflare.F(map[string][]cloudflare.AlertingV3PolicyUpdateParamsMechanisms{ - "email": {{ - ID: cloudflare.F[cloudflare.AlertingV3PolicyUpdateParamsMechanismsID](shared.UnionString("test@example.com")), - }}, - "pagerduty": {{ - ID: cloudflare.F[cloudflare.AlertingV3PolicyUpdateParamsMechanismsID](shared.UnionString("e8133a15-00a4-4d69-aec1-32f70c51f6e5")), - }}, - "webhooks": {{ - ID: cloudflare.F[cloudflare.AlertingV3PolicyUpdateParamsMechanismsID](shared.UnionString("14cc1190-5d2b-4b98-a696-c424cb2ad05f")), - }}, - }), - Name: cloudflare.F("SSL Notification Event Policy"), - }, - ) - 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 TestAlertingV3PolicyList(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("user@example.com"), - ) - _, err := client.Alerting.V3.Policies.List(context.TODO(), cloudflare.AlertingV3PolicyListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestAlertingV3PolicyDelete(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("user@example.com"), - ) - _, err := client.Alerting.V3.Policies.Delete( - context.TODO(), - "0da2b59e-f118-439d-8097-bdfb215203c9", - cloudflare.AlertingV3PolicyDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestAlertingV3PolicyGet(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("user@example.com"), - ) - _, err := client.Alerting.V3.Policies.Get( - context.TODO(), - "0da2b59e-f118-439d-8097-bdfb215203c9", - cloudflare.AlertingV3PolicyGetParams{ - AccountID: cloudflare.F("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/api.md b/api.md index 00a13f62c5f..afb35768d2c 100644 --- a/api.md +++ b/api.md @@ -2,111 +2,111 @@ Response Types: -- cloudflare.Account -- cloudflare.AccountUpdateResponse -- cloudflare.AccountListResponse -- cloudflare.AccountGetResponse +- accounts.Account +- accounts.AccountUpdateResponse +- accounts.AccountListResponse +- accounts.AccountGetResponse Methods: -- client.Accounts.Update(ctx context.Context, params cloudflare.AccountUpdateParams) (cloudflare.AccountUpdateResponse, error) -- client.Accounts.List(ctx context.Context, query cloudflare.AccountListParams) (shared.V4PagePaginationArray[cloudflare.AccountListResponse], error) -- client.Accounts.Get(ctx context.Context, query cloudflare.AccountGetParams) (cloudflare.AccountGetResponse, error) +- client.Accounts.Update(ctx context.Context, params accounts.AccountUpdateParams) (accounts.AccountUpdateResponse, error) +- client.Accounts.List(ctx context.Context, query accounts.AccountListParams) (shared.V4PagePaginationArray[accounts.AccountListResponse], error) +- client.Accounts.Get(ctx context.Context, query accounts.AccountGetParams) (accounts.AccountGetResponse, error) ## Members Response Types: -- cloudflare.AccountMember -- cloudflare.AccountMemberWithID -- cloudflare.AccountMemberListResponse -- cloudflare.AccountMemberDeleteResponse +- accounts.AccountMember +- accounts.AccountMemberWithID +- accounts.MemberListResponse +- accounts.MemberDeleteResponse Methods: -- client.Accounts.Members.New(ctx context.Context, params cloudflare.AccountMemberNewParams) (cloudflare.AccountMemberWithID, error) -- client.Accounts.Members.Update(ctx context.Context, memberID string, params cloudflare.AccountMemberUpdateParams) (cloudflare.AccountMember, error) -- client.Accounts.Members.List(ctx context.Context, params cloudflare.AccountMemberListParams) (shared.V4PagePaginationArray[cloudflare.AccountMemberListResponse], error) -- client.Accounts.Members.Delete(ctx context.Context, memberID string, body cloudflare.AccountMemberDeleteParams) (cloudflare.AccountMemberDeleteResponse, error) -- client.Accounts.Members.Get(ctx context.Context, memberID string, query cloudflare.AccountMemberGetParams) (cloudflare.AccountMember, error) +- client.Accounts.Members.New(ctx context.Context, params accounts.MemberNewParams) (accounts.AccountMemberWithID, error) +- client.Accounts.Members.Update(ctx context.Context, memberID string, params accounts.MemberUpdateParams) (accounts.AccountMember, error) +- client.Accounts.Members.List(ctx context.Context, params accounts.MemberListParams) (shared.V4PagePaginationArray[accounts.MemberListResponse], error) +- client.Accounts.Members.Delete(ctx context.Context, memberID string, body accounts.MemberDeleteParams) (accounts.MemberDeleteResponse, error) +- client.Accounts.Members.Get(ctx context.Context, memberID string, query accounts.MemberGetParams) (accounts.AccountMember, error) ## Roles Response Types: -- cloudflare.AccountRoleListResponse -- cloudflare.AccountRoleGetResponse +- accounts.IamSchemasRole +- accounts.RoleGetResponse Methods: -- client.Accounts.Roles.List(ctx context.Context, query cloudflare.AccountRoleListParams) ([]cloudflare.AccountRoleListResponse, error) -- client.Accounts.Roles.Get(ctx context.Context, roleID interface{}, query cloudflare.AccountRoleGetParams) (cloudflare.AccountRoleGetResponse, error) +- client.Accounts.Roles.List(ctx context.Context, query accounts.RoleListParams) ([]accounts.IamSchemasRole, error) +- client.Accounts.Roles.Get(ctx context.Context, roleID interface{}, query accounts.RoleGetParams) (accounts.RoleGetResponse, error) # Certificates Response Types: -- cloudflare.OriginCACertificate -- cloudflare.CertificateNewResponse -- cloudflare.CertificateDeleteResponse -- cloudflare.CertificateGetResponse +- certificates.OriginCACertificate +- certificates.CertificateNewResponse +- certificates.CertificateDeleteResponse +- certificates.CertificateGetResponse Methods: -- client.Certificates.New(ctx context.Context, body cloudflare.CertificateNewParams) (cloudflare.CertificateNewResponse, error) -- client.Certificates.List(ctx context.Context, query cloudflare.CertificateListParams) ([]cloudflare.OriginCACertificate, error) -- client.Certificates.Delete(ctx context.Context, certificateID string) (cloudflare.CertificateDeleteResponse, error) -- client.Certificates.Get(ctx context.Context, certificateID string) (cloudflare.CertificateGetResponse, error) +- client.Certificates.New(ctx context.Context, body certificates.CertificateNewParams) (certificates.CertificateNewResponse, error) +- client.Certificates.List(ctx context.Context, query certificates.CertificateListParams) ([]certificates.OriginCACertificate, error) +- client.Certificates.Delete(ctx context.Context, certificateID string) (certificates.CertificateDeleteResponse, error) +- client.Certificates.Get(ctx context.Context, certificateID string) (certificates.CertificateGetResponse, error) # IPs Response Types: -- cloudflare.IPs -- cloudflare.JdcloudIPs -- cloudflare.IPListResponse +- ips.IPs +- ips.JdcloudIPs +- ips.IPListResponse Methods: -- client.IPs.List(ctx context.Context, query cloudflare.IPListParams) (cloudflare.IPListResponse, error) +- client.IPs.List(ctx context.Context, query ips.IPListParams) (ips.IPListResponse, error) # Memberships Response Types: -- cloudflare.Membership -- cloudflare.MembershipUpdateResponse -- cloudflare.MembershipDeleteResponse -- cloudflare.MembershipGetResponse +- memberships.Membership +- memberships.MembershipUpdateResponse +- memberships.MembershipDeleteResponse +- memberships.MembershipGetResponse Methods: -- client.Memberships.Update(ctx context.Context, membershipID string, body cloudflare.MembershipUpdateParams) (cloudflare.MembershipUpdateResponse, error) -- client.Memberships.List(ctx context.Context, query cloudflare.MembershipListParams) (shared.V4PagePaginationArray[cloudflare.Membership], error) -- client.Memberships.Delete(ctx context.Context, membershipID string) (cloudflare.MembershipDeleteResponse, error) -- client.Memberships.Get(ctx context.Context, membershipID string) (cloudflare.MembershipGetResponse, error) +- client.Memberships.Update(ctx context.Context, membershipID string, body memberships.MembershipUpdateParams) (memberships.MembershipUpdateResponse, error) +- client.Memberships.List(ctx context.Context, query memberships.MembershipListParams) (shared.V4PagePaginationArray[memberships.Membership], error) +- client.Memberships.Delete(ctx context.Context, membershipID string) (memberships.MembershipDeleteResponse, error) +- client.Memberships.Get(ctx context.Context, membershipID string) (memberships.MembershipGetResponse, error) # User Response Types: -- cloudflare.UserEditResponse -- cloudflare.UserGetResponse +- user.UserEditResponse +- user.UserGetResponse Methods: -- client.User.Edit(ctx context.Context, body cloudflare.UserEditParams) (cloudflare.UserEditResponse, error) -- client.User.Get(ctx context.Context) (cloudflare.UserGetResponse, error) +- client.User.Edit(ctx context.Context, body user.UserEditParams) (user.UserEditResponse, error) +- client.User.Get(ctx context.Context) (user.UserGetResponse, error) ## AuditLogs Response Types: -- cloudflare.UserAuditLogListResponse +- user.AuditLogListResponse Methods: -- client.User.AuditLogs.List(ctx context.Context, query cloudflare.UserAuditLogListParams) (shared.V4PagePaginationArray[cloudflare.UserAuditLogListResponse], error) +- client.User.AuditLogs.List(ctx context.Context, query user.AuditLogListParams) (shared.V4PagePaginationArray[user.AuditLogListResponse], error) ## Billing @@ -114,21 +114,21 @@ Methods: Response Types: -- cloudflare.UserBillingHistoryGetResponse +- user.BillSubsAPIBillingHistory Methods: -- client.User.Billing.History.Get(ctx context.Context, query cloudflare.UserBillingHistoryGetParams) ([]cloudflare.UserBillingHistoryGetResponse, error) +- client.User.Billing.History.Get(ctx context.Context, query user.BillingHistoryGetParams) ([]user.BillSubsAPIBillingHistory, error) ### Profiles Response Types: -- cloudflare.UserBillingProfileGetResponse +- user.BillingProfileGetResponse Methods: -- client.User.Billing.Profiles.Get(ctx context.Context) (cloudflare.UserBillingProfileGetResponse, error) +- client.User.Billing.Profiles.Get(ctx context.Context) (user.BillingProfileGetResponse, error) ## Firewall @@ -136,31 +136,29 @@ Methods: Response Types: -- cloudflare.UserFirewallAccessRuleNewResponse -- cloudflare.UserFirewallAccessRuleListResponse -- cloudflare.UserFirewallAccessRuleDeleteResponse -- cloudflare.UserFirewallAccessRuleEditResponse +- user.LegacyJhsRule +- user.FirewallAccessRuleDeleteResponse Methods: -- client.User.Firewall.AccessRules.New(ctx context.Context, body cloudflare.UserFirewallAccessRuleNewParams) (cloudflare.UserFirewallAccessRuleNewResponse, error) -- client.User.Firewall.AccessRules.List(ctx context.Context, query cloudflare.UserFirewallAccessRuleListParams) (shared.V4PagePaginationArray[cloudflare.UserFirewallAccessRuleListResponse], error) -- client.User.Firewall.AccessRules.Delete(ctx context.Context, identifier string) (cloudflare.UserFirewallAccessRuleDeleteResponse, error) -- client.User.Firewall.AccessRules.Edit(ctx context.Context, identifier string, body cloudflare.UserFirewallAccessRuleEditParams) (cloudflare.UserFirewallAccessRuleEditResponse, error) +- client.User.Firewall.AccessRules.New(ctx context.Context, body user.FirewallAccessRuleNewParams) (user.LegacyJhsRule, error) +- client.User.Firewall.AccessRules.List(ctx context.Context, query user.FirewallAccessRuleListParams) (shared.V4PagePaginationArray[user.LegacyJhsRule], error) +- client.User.Firewall.AccessRules.Delete(ctx context.Context, identifier string) (user.FirewallAccessRuleDeleteResponse, error) +- client.User.Firewall.AccessRules.Edit(ctx context.Context, identifier string, body user.FirewallAccessRuleEditParams) (user.LegacyJhsRule, error) ## Invites Response Types: -- cloudflare.UserInviteListResponse -- cloudflare.UserInviteEditResponse -- cloudflare.UserInviteGetResponse +- user.InviteListResponse +- user.InviteEditResponse +- user.InviteGetResponse Methods: -- client.User.Invites.List(ctx context.Context) ([]cloudflare.UserInviteListResponse, error) -- client.User.Invites.Edit(ctx context.Context, inviteID string, body cloudflare.UserInviteEditParams) (cloudflare.UserInviteEditResponse, error) -- client.User.Invites.Get(ctx context.Context, inviteID string) (cloudflare.UserInviteGetResponse, error) +- client.User.Invites.List(ctx context.Context) ([]user.InviteListResponse, error) +- client.User.Invites.Edit(ctx context.Context, inviteID string, body user.InviteEditParams) (user.InviteEditResponse, error) +- client.User.Invites.Get(ctx context.Context, inviteID string) (user.InviteGetResponse, error) ## LoadBalancers @@ -168,61 +166,53 @@ Methods: Response Types: -- cloudflare.UserLoadBalancerMonitorNewResponse -- cloudflare.UserLoadBalancerMonitorUpdateResponse -- cloudflare.UserLoadBalancerMonitorListResponse -- cloudflare.UserLoadBalancerMonitorDeleteResponse -- cloudflare.UserLoadBalancerMonitorEditResponse -- cloudflare.UserLoadBalancerMonitorGetResponse -- cloudflare.UserLoadBalancerMonitorPreviewResponse -- cloudflare.UserLoadBalancerMonitorReferencesResponse +- user.LoadBalancingMonitor +- user.LoadBalancerMonitorDeleteResponse +- user.LoadBalancerMonitorPreviewResponse +- user.LoadBalancerMonitorReferencesResponse Methods: -- client.User.LoadBalancers.Monitors.New(ctx context.Context, body cloudflare.UserLoadBalancerMonitorNewParams) (cloudflare.UserLoadBalancerMonitorNewResponse, error) -- client.User.LoadBalancers.Monitors.Update(ctx context.Context, monitorID string, body cloudflare.UserLoadBalancerMonitorUpdateParams) (cloudflare.UserLoadBalancerMonitorUpdateResponse, error) -- client.User.LoadBalancers.Monitors.List(ctx context.Context) ([]cloudflare.UserLoadBalancerMonitorListResponse, error) -- client.User.LoadBalancers.Monitors.Delete(ctx context.Context, monitorID string) (cloudflare.UserLoadBalancerMonitorDeleteResponse, error) -- client.User.LoadBalancers.Monitors.Edit(ctx context.Context, monitorID string, body cloudflare.UserLoadBalancerMonitorEditParams) (cloudflare.UserLoadBalancerMonitorEditResponse, error) -- client.User.LoadBalancers.Monitors.Get(ctx context.Context, monitorID string) (cloudflare.UserLoadBalancerMonitorGetResponse, error) -- client.User.LoadBalancers.Monitors.Preview(ctx context.Context, monitorID string, body cloudflare.UserLoadBalancerMonitorPreviewParams) (cloudflare.UserLoadBalancerMonitorPreviewResponse, error) -- client.User.LoadBalancers.Monitors.References(ctx context.Context, monitorID string) ([]cloudflare.UserLoadBalancerMonitorReferencesResponse, error) +- client.User.LoadBalancers.Monitors.New(ctx context.Context, body user.LoadBalancerMonitorNewParams) (user.LoadBalancingMonitor, error) +- client.User.LoadBalancers.Monitors.Update(ctx context.Context, monitorID string, body user.LoadBalancerMonitorUpdateParams) (user.LoadBalancingMonitor, error) +- client.User.LoadBalancers.Monitors.List(ctx context.Context) ([]user.LoadBalancingMonitor, error) +- client.User.LoadBalancers.Monitors.Delete(ctx context.Context, monitorID string) (user.LoadBalancerMonitorDeleteResponse, error) +- client.User.LoadBalancers.Monitors.Edit(ctx context.Context, monitorID string, body user.LoadBalancerMonitorEditParams) (user.LoadBalancingMonitor, error) +- client.User.LoadBalancers.Monitors.Get(ctx context.Context, monitorID string) (user.LoadBalancingMonitor, error) +- client.User.LoadBalancers.Monitors.Preview(ctx context.Context, monitorID string, body user.LoadBalancerMonitorPreviewParams) (user.LoadBalancerMonitorPreviewResponse, error) +- client.User.LoadBalancers.Monitors.References(ctx context.Context, monitorID string) ([]user.LoadBalancerMonitorReferencesResponse, error) ### Pools Response Types: -- cloudflare.UserLoadBalancerPoolNewResponse -- cloudflare.UserLoadBalancerPoolUpdateResponse -- cloudflare.UserLoadBalancerPoolListResponse -- cloudflare.UserLoadBalancerPoolDeleteResponse -- cloudflare.UserLoadBalancerPoolEditResponse -- cloudflare.UserLoadBalancerPoolGetResponse -- cloudflare.UserLoadBalancerPoolHealthResponse -- cloudflare.UserLoadBalancerPoolPreviewResponse -- cloudflare.UserLoadBalancerPoolReferencesResponse +- user.LoadBalancingPool +- user.LoadBalancerPoolDeleteResponse +- user.LoadBalancerPoolHealthResponse +- user.LoadBalancerPoolPreviewResponse +- user.LoadBalancerPoolReferencesResponse Methods: -- client.User.LoadBalancers.Pools.New(ctx context.Context, body cloudflare.UserLoadBalancerPoolNewParams) (cloudflare.UserLoadBalancerPoolNewResponse, error) -- client.User.LoadBalancers.Pools.Update(ctx context.Context, poolID string, body cloudflare.UserLoadBalancerPoolUpdateParams) (cloudflare.UserLoadBalancerPoolUpdateResponse, error) -- client.User.LoadBalancers.Pools.List(ctx context.Context, query cloudflare.UserLoadBalancerPoolListParams) ([]cloudflare.UserLoadBalancerPoolListResponse, error) -- client.User.LoadBalancers.Pools.Delete(ctx context.Context, poolID string) (cloudflare.UserLoadBalancerPoolDeleteResponse, error) -- client.User.LoadBalancers.Pools.Edit(ctx context.Context, poolID string, body cloudflare.UserLoadBalancerPoolEditParams) (cloudflare.UserLoadBalancerPoolEditResponse, error) -- client.User.LoadBalancers.Pools.Get(ctx context.Context, poolID string) (cloudflare.UserLoadBalancerPoolGetResponse, error) -- client.User.LoadBalancers.Pools.Health(ctx context.Context, poolID string) (cloudflare.UserLoadBalancerPoolHealthResponse, error) -- client.User.LoadBalancers.Pools.Preview(ctx context.Context, poolID string, body cloudflare.UserLoadBalancerPoolPreviewParams) (cloudflare.UserLoadBalancerPoolPreviewResponse, error) -- client.User.LoadBalancers.Pools.References(ctx context.Context, poolID string) ([]cloudflare.UserLoadBalancerPoolReferencesResponse, error) +- client.User.LoadBalancers.Pools.New(ctx context.Context, body user.LoadBalancerPoolNewParams) (user.LoadBalancingPool, error) +- client.User.LoadBalancers.Pools.Update(ctx context.Context, poolID string, body user.LoadBalancerPoolUpdateParams) (user.LoadBalancingPool, error) +- client.User.LoadBalancers.Pools.List(ctx context.Context, query user.LoadBalancerPoolListParams) ([]user.LoadBalancingPool, error) +- client.User.LoadBalancers.Pools.Delete(ctx context.Context, poolID string) (user.LoadBalancerPoolDeleteResponse, error) +- client.User.LoadBalancers.Pools.Edit(ctx context.Context, poolID string, body user.LoadBalancerPoolEditParams) (user.LoadBalancingPool, error) +- client.User.LoadBalancers.Pools.Get(ctx context.Context, poolID string) (user.LoadBalancingPool, error) +- client.User.LoadBalancers.Pools.Health(ctx context.Context, poolID string) (user.LoadBalancerPoolHealthResponse, error) +- client.User.LoadBalancers.Pools.Preview(ctx context.Context, poolID string, body user.LoadBalancerPoolPreviewParams) (user.LoadBalancerPoolPreviewResponse, error) +- client.User.LoadBalancers.Pools.References(ctx context.Context, poolID string) ([]user.LoadBalancerPoolReferencesResponse, error) ### Preview Response Types: -- cloudflare.UserLoadBalancerPreviewGetResponse +- user.LoadBalancingPreviewResult Methods: -- client.User.LoadBalancers.Preview.Get(ctx context.Context, previewID interface{}) (cloudflare.UserLoadBalancerPreviewGetResponse, error) +- client.User.LoadBalancers.Preview.Get(ctx context.Context, previewID interface{}) (user.LoadBalancingPreviewResult, error) ### Analytics @@ -230,753 +220,904 @@ Methods: Response Types: -- cloudflare.UserLoadBalancerAnalyticsEventListResponse +- user.LoadBalancingAnalytics Methods: -- client.User.LoadBalancers.Analytics.Events.List(ctx context.Context, query cloudflare.UserLoadBalancerAnalyticsEventListParams) ([]cloudflare.UserLoadBalancerAnalyticsEventListResponse, error) +- client.User.LoadBalancers.Analytics.Events.List(ctx context.Context, query user.LoadBalancerAnalyticsEventListParams) ([]user.LoadBalancingAnalytics, error) ## Organizations Response Types: -- cloudflare.UserOrganizationListResponse -- cloudflare.UserOrganizationDeleteResponse -- cloudflare.UserOrganizationGetResponse +- user.IamOrganization +- user.OrganizationDeleteResponse +- user.OrganizationGetResponse Methods: -- client.User.Organizations.List(ctx context.Context, query cloudflare.UserOrganizationListParams) (shared.V4PagePaginationArray[cloudflare.UserOrganizationListResponse], error) -- client.User.Organizations.Delete(ctx context.Context, organizationID string) (cloudflare.UserOrganizationDeleteResponse, error) -- client.User.Organizations.Get(ctx context.Context, organizationID string) (cloudflare.UserOrganizationGetResponse, error) +- client.User.Organizations.List(ctx context.Context, query user.OrganizationListParams) (shared.V4PagePaginationArray[user.IamOrganization], error) +- client.User.Organizations.Delete(ctx context.Context, organizationID string) (user.OrganizationDeleteResponse, error) +- client.User.Organizations.Get(ctx context.Context, organizationID string) (user.OrganizationGetResponse, error) ## Subscriptions Response Types: -- cloudflare.UserSubscriptionUpdateResponse -- cloudflare.UserSubscriptionDeleteResponse -- cloudflare.UserSubscriptionEditResponse -- cloudflare.UserSubscriptionGetResponse +- user.SubscriptionUpdateResponse +- user.SubscriptionDeleteResponse +- user.SubscriptionEditResponse +- user.SubscriptionGetResponse Methods: -- client.User.Subscriptions.Update(ctx context.Context, identifier string, body cloudflare.UserSubscriptionUpdateParams) (cloudflare.UserSubscriptionUpdateResponse, error) -- client.User.Subscriptions.Delete(ctx context.Context, identifier string) (cloudflare.UserSubscriptionDeleteResponse, error) -- client.User.Subscriptions.Edit(ctx context.Context, identifier string, body cloudflare.UserSubscriptionEditParams) (cloudflare.UserSubscriptionEditResponse, error) -- client.User.Subscriptions.Get(ctx context.Context) ([]cloudflare.UserSubscriptionGetResponse, error) +- client.User.Subscriptions.Update(ctx context.Context, identifier string, body user.SubscriptionUpdateParams) (user.SubscriptionUpdateResponse, error) +- client.User.Subscriptions.Delete(ctx context.Context, identifier string) (user.SubscriptionDeleteResponse, error) +- client.User.Subscriptions.Edit(ctx context.Context, identifier string, body user.SubscriptionEditParams) (user.SubscriptionEditResponse, error) +- client.User.Subscriptions.Get(ctx context.Context) ([]user.SubscriptionGetResponse, error) ## Tokens Response Types: -- cloudflare.UserTokenNewResponse -- cloudflare.UserTokenUpdateResponse -- cloudflare.UserTokenListResponse -- cloudflare.UserTokenDeleteResponse -- cloudflare.UserTokenGetResponse -- cloudflare.UserTokenVerifyResponse +- user.TokenNewResponse +- user.TokenUpdateResponse +- user.TokenListResponse +- user.TokenDeleteResponse +- user.TokenGetResponse +- user.TokenVerifyResponse Methods: -- client.User.Tokens.New(ctx context.Context, body cloudflare.UserTokenNewParams) (cloudflare.UserTokenNewResponse, error) -- client.User.Tokens.Update(ctx context.Context, tokenID interface{}, body cloudflare.UserTokenUpdateParams) (cloudflare.UserTokenUpdateResponse, error) -- client.User.Tokens.List(ctx context.Context, query cloudflare.UserTokenListParams) (shared.V4PagePaginationArray[cloudflare.UserTokenListResponse], error) -- client.User.Tokens.Delete(ctx context.Context, tokenID interface{}) (cloudflare.UserTokenDeleteResponse, error) -- client.User.Tokens.Get(ctx context.Context, tokenID interface{}) (cloudflare.UserTokenGetResponse, error) -- client.User.Tokens.Verify(ctx context.Context) (cloudflare.UserTokenVerifyResponse, error) +- client.User.Tokens.New(ctx context.Context, body user.TokenNewParams) (user.TokenNewResponse, error) +- client.User.Tokens.Update(ctx context.Context, tokenID interface{}, body user.TokenUpdateParams) (user.TokenUpdateResponse, error) +- client.User.Tokens.List(ctx context.Context, query user.TokenListParams) (shared.V4PagePaginationArray[user.TokenListResponse], error) +- client.User.Tokens.Delete(ctx context.Context, tokenID interface{}) (user.TokenDeleteResponse, error) +- client.User.Tokens.Get(ctx context.Context, tokenID interface{}) (user.TokenGetResponse, error) +- client.User.Tokens.Verify(ctx context.Context) (user.TokenVerifyResponse, error) ### PermissionGroups Response Types: -- cloudflare.UserTokenPermissionGroupListResponse +- user.TokenPermissionGroupListResponse Methods: -- client.User.Tokens.PermissionGroups.List(ctx context.Context) ([]cloudflare.UserTokenPermissionGroupListResponse, error) +- client.User.Tokens.PermissionGroups.List(ctx context.Context) ([]user.TokenPermissionGroupListResponse, error) ### Value +Response Types: + +- user.IamValue + Methods: -- client.User.Tokens.Value.Update(ctx context.Context, tokenID interface{}, body cloudflare.UserTokenValueUpdateParams) (string, error) +- client.User.Tokens.Value.Update(ctx context.Context, tokenID interface{}, body user.TokenValueUpdateParams) (user.IamValue, error) # Zones Response Types: -- cloudflare.ZoneNewResponse -- cloudflare.ZoneListResponse -- cloudflare.ZoneDeleteResponse -- cloudflare.ZoneEditResponse -- cloudflare.ZoneGetResponse +- zones.ZoneNewResponse +- zones.ZoneListResponse +- zones.ZoneDeleteResponse +- zones.ZoneEditResponse +- zones.ZoneGetResponse Methods: -- client.Zones.New(ctx context.Context, body cloudflare.ZoneNewParams) (cloudflare.ZoneNewResponse, error) -- client.Zones.List(ctx context.Context, query cloudflare.ZoneListParams) (shared.V4PagePaginationArray[cloudflare.ZoneListResponse], error) -- client.Zones.Delete(ctx context.Context, body cloudflare.ZoneDeleteParams) (cloudflare.ZoneDeleteResponse, error) -- client.Zones.Edit(ctx context.Context, params cloudflare.ZoneEditParams) (cloudflare.ZoneEditResponse, error) -- client.Zones.Get(ctx context.Context, query cloudflare.ZoneGetParams) (cloudflare.ZoneGetResponse, error) +- client.Zones.New(ctx context.Context, body zones.ZoneNewParams) (zones.ZoneNewResponse, error) +- client.Zones.List(ctx context.Context, query zones.ZoneListParams) (shared.V4PagePaginationArray[zones.ZoneListResponse], error) +- client.Zones.Delete(ctx context.Context, body zones.ZoneDeleteParams) (zones.ZoneDeleteResponse, error) +- client.Zones.Edit(ctx context.Context, params zones.ZoneEditParams) (zones.ZoneEditResponse, error) +- client.Zones.Get(ctx context.Context, query zones.ZoneGetParams) (zones.ZoneGetResponse, error) ## ActivationCheck Response Types: -- cloudflare.ZoneActivationCheckTriggerResponse +- zones.ActivationCheckTriggerResponse Methods: -- client.Zones.ActivationCheck.Trigger(ctx context.Context, body cloudflare.ZoneActivationCheckTriggerParams) (cloudflare.ZoneActivationCheckTriggerResponse, error) +- client.Zones.ActivationCheck.Trigger(ctx context.Context, body zones.ActivationCheckTriggerParams) (zones.ActivationCheckTriggerResponse, error) ## Settings Response Types: -- cloudflare.ZoneSettingEditResponse -- cloudflare.ZoneSettingGetResponse +- zones.SettingEditResponse +- zones.SettingGetResponse Methods: -- client.Zones.Settings.Edit(ctx context.Context, params cloudflare.ZoneSettingEditParams) ([]cloudflare.ZoneSettingEditResponse, error) -- client.Zones.Settings.Get(ctx context.Context, query cloudflare.ZoneSettingGetParams) ([]cloudflare.ZoneSettingGetResponse, error) +- client.Zones.Settings.Edit(ctx context.Context, params zones.SettingEditParams) ([]zones.SettingEditResponse, error) +- client.Zones.Settings.Get(ctx context.Context, query zones.SettingGetParams) ([]zones.SettingGetResponse, error) ### ZeroRTT +Params Types: + +- zones.Zones0rttParam + Response Types: -- cloudflare.ZoneSettingZeroRTTEditResponse -- cloudflare.ZoneSettingZeroRTTGetResponse +- zones.Zones0rtt Methods: -- client.Zones.Settings.ZeroRTT.Edit(ctx context.Context, params cloudflare.ZoneSettingZeroRTTEditParams) (cloudflare.ZoneSettingZeroRTTEditResponse, error) -- client.Zones.Settings.ZeroRTT.Get(ctx context.Context, query cloudflare.ZoneSettingZeroRTTGetParams) (cloudflare.ZoneSettingZeroRTTGetResponse, error) +- client.Zones.Settings.ZeroRTT.Edit(ctx context.Context, params zones.SettingZeroRTTEditParams) (zones.Zones0rtt, error) +- client.Zones.Settings.ZeroRTT.Get(ctx context.Context, query zones.SettingZeroRTTGetParams) (zones.Zones0rtt, error) ### AdvancedDDOS +Params Types: + +- zones.ZonesAdvancedDDOSParam + Response Types: -- cloudflare.ZoneSettingAdvancedDDOSGetResponse +- zones.ZonesAdvancedDDOS Methods: -- client.Zones.Settings.AdvancedDDOS.Get(ctx context.Context, query cloudflare.ZoneSettingAdvancedDDOSGetParams) (cloudflare.ZoneSettingAdvancedDDOSGetResponse, error) +- client.Zones.Settings.AdvancedDDOS.Get(ctx context.Context, query zones.SettingAdvancedDDOSGetParams) (zones.ZonesAdvancedDDOS, error) ### AlwaysOnline +Params Types: + +- zones.ZonesAlwaysOnlineParam + Response Types: -- cloudflare.ZoneSettingAlwaysOnlineEditResponse -- cloudflare.ZoneSettingAlwaysOnlineGetResponse +- zones.ZonesAlwaysOnline Methods: -- client.Zones.Settings.AlwaysOnline.Edit(ctx context.Context, params cloudflare.ZoneSettingAlwaysOnlineEditParams) (cloudflare.ZoneSettingAlwaysOnlineEditResponse, error) -- client.Zones.Settings.AlwaysOnline.Get(ctx context.Context, query cloudflare.ZoneSettingAlwaysOnlineGetParams) (cloudflare.ZoneSettingAlwaysOnlineGetResponse, error) +- client.Zones.Settings.AlwaysOnline.Edit(ctx context.Context, params zones.SettingAlwaysOnlineEditParams) (zones.ZonesAlwaysOnline, error) +- client.Zones.Settings.AlwaysOnline.Get(ctx context.Context, query zones.SettingAlwaysOnlineGetParams) (zones.ZonesAlwaysOnline, error) ### AlwaysUseHTTPS +Params Types: + +- zones.ZonesAlwaysUseHTTPSParam + Response Types: -- cloudflare.ZoneSettingAlwaysUseHTTPSEditResponse -- cloudflare.ZoneSettingAlwaysUseHTTPSGetResponse +- zones.ZonesAlwaysUseHTTPS Methods: -- client.Zones.Settings.AlwaysUseHTTPS.Edit(ctx context.Context, params cloudflare.ZoneSettingAlwaysUseHTTPSEditParams) (cloudflare.ZoneSettingAlwaysUseHTTPSEditResponse, error) -- client.Zones.Settings.AlwaysUseHTTPS.Get(ctx context.Context, query cloudflare.ZoneSettingAlwaysUseHTTPSGetParams) (cloudflare.ZoneSettingAlwaysUseHTTPSGetResponse, error) +- client.Zones.Settings.AlwaysUseHTTPS.Edit(ctx context.Context, params zones.SettingAlwaysUseHTTPSEditParams) (zones.ZonesAlwaysUseHTTPS, error) +- client.Zones.Settings.AlwaysUseHTTPS.Get(ctx context.Context, query zones.SettingAlwaysUseHTTPSGetParams) (zones.ZonesAlwaysUseHTTPS, error) ### AutomaticHTTPSRewrites +Params Types: + +- zones.ZonesAutomaticHTTPSRewritesParam + Response Types: -- cloudflare.ZoneSettingAutomaticHTTPSRewriteEditResponse -- cloudflare.ZoneSettingAutomaticHTTPSRewriteGetResponse +- zones.ZonesAutomaticHTTPSRewrites Methods: -- client.Zones.Settings.AutomaticHTTPSRewrites.Edit(ctx context.Context, params cloudflare.ZoneSettingAutomaticHTTPSRewriteEditParams) (cloudflare.ZoneSettingAutomaticHTTPSRewriteEditResponse, error) -- client.Zones.Settings.AutomaticHTTPSRewrites.Get(ctx context.Context, query cloudflare.ZoneSettingAutomaticHTTPSRewriteGetParams) (cloudflare.ZoneSettingAutomaticHTTPSRewriteGetResponse, error) +- client.Zones.Settings.AutomaticHTTPSRewrites.Edit(ctx context.Context, params zones.SettingAutomaticHTTPSRewriteEditParams) (zones.ZonesAutomaticHTTPSRewrites, error) +- client.Zones.Settings.AutomaticHTTPSRewrites.Get(ctx context.Context, query zones.SettingAutomaticHTTPSRewriteGetParams) (zones.ZonesAutomaticHTTPSRewrites, error) ### AutomaticPlatformOptimization +Params Types: + +- zones.ZonesAutomaticPlatformOptimizationParam + Response Types: -- cloudflare.ZoneSettingAutomaticPlatformOptimizationEditResponse -- cloudflare.ZoneSettingAutomaticPlatformOptimizationGetResponse +- zones.ZonesAutomaticPlatformOptimization Methods: -- client.Zones.Settings.AutomaticPlatformOptimization.Edit(ctx context.Context, params cloudflare.ZoneSettingAutomaticPlatformOptimizationEditParams) (cloudflare.ZoneSettingAutomaticPlatformOptimizationEditResponse, error) -- client.Zones.Settings.AutomaticPlatformOptimization.Get(ctx context.Context, query cloudflare.ZoneSettingAutomaticPlatformOptimizationGetParams) (cloudflare.ZoneSettingAutomaticPlatformOptimizationGetResponse, error) +- client.Zones.Settings.AutomaticPlatformOptimization.Edit(ctx context.Context, params zones.SettingAutomaticPlatformOptimizationEditParams) (zones.ZonesAutomaticPlatformOptimization, error) +- client.Zones.Settings.AutomaticPlatformOptimization.Get(ctx context.Context, query zones.SettingAutomaticPlatformOptimizationGetParams) (zones.ZonesAutomaticPlatformOptimization, error) ### Brotli +Params Types: + +- zones.ZonesBrotliParam + Response Types: -- cloudflare.ZoneSettingBrotliEditResponse -- cloudflare.ZoneSettingBrotliGetResponse +- zones.ZonesBrotli Methods: -- client.Zones.Settings.Brotli.Edit(ctx context.Context, params cloudflare.ZoneSettingBrotliEditParams) (cloudflare.ZoneSettingBrotliEditResponse, error) -- client.Zones.Settings.Brotli.Get(ctx context.Context, query cloudflare.ZoneSettingBrotliGetParams) (cloudflare.ZoneSettingBrotliGetResponse, error) +- client.Zones.Settings.Brotli.Edit(ctx context.Context, params zones.SettingBrotliEditParams) (zones.ZonesBrotli, error) +- client.Zones.Settings.Brotli.Get(ctx context.Context, query zones.SettingBrotliGetParams) (zones.ZonesBrotli, error) ### BrowserCacheTTL +Params Types: + +- zones.ZonesBrowserCacheTTLParam + Response Types: -- cloudflare.ZoneSettingBrowserCacheTTLEditResponse -- cloudflare.ZoneSettingBrowserCacheTTLGetResponse +- zones.ZonesBrowserCacheTTL Methods: -- client.Zones.Settings.BrowserCacheTTL.Edit(ctx context.Context, params cloudflare.ZoneSettingBrowserCacheTTLEditParams) (cloudflare.ZoneSettingBrowserCacheTTLEditResponse, error) -- client.Zones.Settings.BrowserCacheTTL.Get(ctx context.Context, query cloudflare.ZoneSettingBrowserCacheTTLGetParams) (cloudflare.ZoneSettingBrowserCacheTTLGetResponse, error) +- client.Zones.Settings.BrowserCacheTTL.Edit(ctx context.Context, params zones.SettingBrowserCacheTTLEditParams) (zones.ZonesBrowserCacheTTL, error) +- client.Zones.Settings.BrowserCacheTTL.Get(ctx context.Context, query zones.SettingBrowserCacheTTLGetParams) (zones.ZonesBrowserCacheTTL, error) ### BrowserCheck +Params Types: + +- zones.ZonesBrowserCheckParam + Response Types: -- cloudflare.ZoneSettingBrowserCheckEditResponse -- cloudflare.ZoneSettingBrowserCheckGetResponse +- zones.ZonesBrowserCheck Methods: -- client.Zones.Settings.BrowserCheck.Edit(ctx context.Context, params cloudflare.ZoneSettingBrowserCheckEditParams) (cloudflare.ZoneSettingBrowserCheckEditResponse, error) -- client.Zones.Settings.BrowserCheck.Get(ctx context.Context, query cloudflare.ZoneSettingBrowserCheckGetParams) (cloudflare.ZoneSettingBrowserCheckGetResponse, error) +- client.Zones.Settings.BrowserCheck.Edit(ctx context.Context, params zones.SettingBrowserCheckEditParams) (zones.ZonesBrowserCheck, error) +- client.Zones.Settings.BrowserCheck.Get(ctx context.Context, query zones.SettingBrowserCheckGetParams) (zones.ZonesBrowserCheck, error) ### CacheLevel +Params Types: + +- zones.ZonesCacheLevelParam + Response Types: -- cloudflare.ZoneSettingCacheLevelEditResponse -- cloudflare.ZoneSettingCacheLevelGetResponse +- zones.ZonesCacheLevel Methods: -- client.Zones.Settings.CacheLevel.Edit(ctx context.Context, params cloudflare.ZoneSettingCacheLevelEditParams) (cloudflare.ZoneSettingCacheLevelEditResponse, error) -- client.Zones.Settings.CacheLevel.Get(ctx context.Context, query cloudflare.ZoneSettingCacheLevelGetParams) (cloudflare.ZoneSettingCacheLevelGetResponse, error) +- client.Zones.Settings.CacheLevel.Edit(ctx context.Context, params zones.SettingCacheLevelEditParams) (zones.ZonesCacheLevel, error) +- client.Zones.Settings.CacheLevel.Get(ctx context.Context, query zones.SettingCacheLevelGetParams) (zones.ZonesCacheLevel, error) ### ChallengeTTL +Params Types: + +- zones.ZonesChallengeTTLParam + Response Types: -- cloudflare.ZoneSettingChallengeTTLEditResponse -- cloudflare.ZoneSettingChallengeTTLGetResponse +- zones.ZonesChallengeTTL Methods: -- client.Zones.Settings.ChallengeTTL.Edit(ctx context.Context, params cloudflare.ZoneSettingChallengeTTLEditParams) (cloudflare.ZoneSettingChallengeTTLEditResponse, error) -- client.Zones.Settings.ChallengeTTL.Get(ctx context.Context, query cloudflare.ZoneSettingChallengeTTLGetParams) (cloudflare.ZoneSettingChallengeTTLGetResponse, error) +- client.Zones.Settings.ChallengeTTL.Edit(ctx context.Context, params zones.SettingChallengeTTLEditParams) (zones.ZonesChallengeTTL, error) +- client.Zones.Settings.ChallengeTTL.Get(ctx context.Context, query zones.SettingChallengeTTLGetParams) (zones.ZonesChallengeTTL, error) ### Ciphers +Params Types: + +- zones.ZonesCiphersParam + Response Types: -- cloudflare.ZoneSettingCipherEditResponse -- cloudflare.ZoneSettingCipherGetResponse +- zones.ZonesCiphers Methods: -- client.Zones.Settings.Ciphers.Edit(ctx context.Context, params cloudflare.ZoneSettingCipherEditParams) (cloudflare.ZoneSettingCipherEditResponse, error) -- client.Zones.Settings.Ciphers.Get(ctx context.Context, query cloudflare.ZoneSettingCipherGetParams) (cloudflare.ZoneSettingCipherGetResponse, error) +- client.Zones.Settings.Ciphers.Edit(ctx context.Context, params zones.SettingCipherEditParams) (zones.ZonesCiphers, error) +- client.Zones.Settings.Ciphers.Get(ctx context.Context, query zones.SettingCipherGetParams) (zones.ZonesCiphers, error) ### DevelopmentMode +Params Types: + +- zones.ZonesDevelopmentModeParam + Response Types: -- cloudflare.ZoneSettingDevelopmentModeEditResponse -- cloudflare.ZoneSettingDevelopmentModeGetResponse +- zones.ZonesDevelopmentMode Methods: -- client.Zones.Settings.DevelopmentMode.Edit(ctx context.Context, params cloudflare.ZoneSettingDevelopmentModeEditParams) (cloudflare.ZoneSettingDevelopmentModeEditResponse, error) -- client.Zones.Settings.DevelopmentMode.Get(ctx context.Context, query cloudflare.ZoneSettingDevelopmentModeGetParams) (cloudflare.ZoneSettingDevelopmentModeGetResponse, error) +- client.Zones.Settings.DevelopmentMode.Edit(ctx context.Context, params zones.SettingDevelopmentModeEditParams) (zones.ZonesDevelopmentMode, error) +- client.Zones.Settings.DevelopmentMode.Get(ctx context.Context, query zones.SettingDevelopmentModeGetParams) (zones.ZonesDevelopmentMode, error) ### EarlyHints +Params Types: + +- zones.ZonesEarlyHintsParam + Response Types: -- cloudflare.ZoneSettingEarlyHintEditResponse -- cloudflare.ZoneSettingEarlyHintGetResponse +- zones.ZonesEarlyHints Methods: -- client.Zones.Settings.EarlyHints.Edit(ctx context.Context, params cloudflare.ZoneSettingEarlyHintEditParams) (cloudflare.ZoneSettingEarlyHintEditResponse, error) -- client.Zones.Settings.EarlyHints.Get(ctx context.Context, query cloudflare.ZoneSettingEarlyHintGetParams) (cloudflare.ZoneSettingEarlyHintGetResponse, error) +- client.Zones.Settings.EarlyHints.Edit(ctx context.Context, params zones.SettingEarlyHintEditParams) (zones.ZonesEarlyHints, error) +- client.Zones.Settings.EarlyHints.Get(ctx context.Context, query zones.SettingEarlyHintGetParams) (zones.ZonesEarlyHints, error) ### EmailObfuscation +Params Types: + +- zones.ZonesEmailObfuscationParam + Response Types: -- cloudflare.ZoneSettingEmailObfuscationEditResponse -- cloudflare.ZoneSettingEmailObfuscationGetResponse +- zones.ZonesEmailObfuscation Methods: -- client.Zones.Settings.EmailObfuscation.Edit(ctx context.Context, params cloudflare.ZoneSettingEmailObfuscationEditParams) (cloudflare.ZoneSettingEmailObfuscationEditResponse, error) -- client.Zones.Settings.EmailObfuscation.Get(ctx context.Context, query cloudflare.ZoneSettingEmailObfuscationGetParams) (cloudflare.ZoneSettingEmailObfuscationGetResponse, error) +- client.Zones.Settings.EmailObfuscation.Edit(ctx context.Context, params zones.SettingEmailObfuscationEditParams) (zones.ZonesEmailObfuscation, error) +- client.Zones.Settings.EmailObfuscation.Get(ctx context.Context, query zones.SettingEmailObfuscationGetParams) (zones.ZonesEmailObfuscation, error) ### H2Prioritization +Params Types: + +- zones.ZonesH2PrioritizationParam + Response Types: -- cloudflare.ZoneSettingH2PrioritizationEditResponse -- cloudflare.ZoneSettingH2PrioritizationGetResponse +- zones.ZonesH2Prioritization Methods: -- client.Zones.Settings.H2Prioritization.Edit(ctx context.Context, params cloudflare.ZoneSettingH2PrioritizationEditParams) (cloudflare.ZoneSettingH2PrioritizationEditResponse, error) -- client.Zones.Settings.H2Prioritization.Get(ctx context.Context, query cloudflare.ZoneSettingH2PrioritizationGetParams) (cloudflare.ZoneSettingH2PrioritizationGetResponse, error) +- client.Zones.Settings.H2Prioritization.Edit(ctx context.Context, params zones.SettingH2PrioritizationEditParams) (zones.ZonesH2Prioritization, error) +- client.Zones.Settings.H2Prioritization.Get(ctx context.Context, query zones.SettingH2PrioritizationGetParams) (zones.ZonesH2Prioritization, error) ### HotlinkProtection +Params Types: + +- zones.ZonesHotlinkProtectionParam + Response Types: -- cloudflare.ZoneSettingHotlinkProtectionEditResponse -- cloudflare.ZoneSettingHotlinkProtectionGetResponse +- zones.ZonesHotlinkProtection Methods: -- client.Zones.Settings.HotlinkProtection.Edit(ctx context.Context, params cloudflare.ZoneSettingHotlinkProtectionEditParams) (cloudflare.ZoneSettingHotlinkProtectionEditResponse, error) -- client.Zones.Settings.HotlinkProtection.Get(ctx context.Context, query cloudflare.ZoneSettingHotlinkProtectionGetParams) (cloudflare.ZoneSettingHotlinkProtectionGetResponse, error) +- client.Zones.Settings.HotlinkProtection.Edit(ctx context.Context, params zones.SettingHotlinkProtectionEditParams) (zones.ZonesHotlinkProtection, error) +- client.Zones.Settings.HotlinkProtection.Get(ctx context.Context, query zones.SettingHotlinkProtectionGetParams) (zones.ZonesHotlinkProtection, error) ### HTTP2 +Params Types: + +- zones.ZonesHTTP2Param + Response Types: -- cloudflare.ZoneSettingHTTP2EditResponse -- cloudflare.ZoneSettingHTTP2GetResponse +- zones.ZonesHTTP2 Methods: -- client.Zones.Settings.HTTP2.Edit(ctx context.Context, params cloudflare.ZoneSettingHTTP2EditParams) (cloudflare.ZoneSettingHTTP2EditResponse, error) -- client.Zones.Settings.HTTP2.Get(ctx context.Context, query cloudflare.ZoneSettingHTTP2GetParams) (cloudflare.ZoneSettingHTTP2GetResponse, error) +- client.Zones.Settings.HTTP2.Edit(ctx context.Context, params zones.SettingHTTP2EditParams) (zones.ZonesHTTP2, error) +- client.Zones.Settings.HTTP2.Get(ctx context.Context, query zones.SettingHTTP2GetParams) (zones.ZonesHTTP2, error) ### HTTP3 +Params Types: + +- zones.ZonesHTTP3Param + Response Types: -- cloudflare.ZoneSettingHTTP3EditResponse -- cloudflare.ZoneSettingHTTP3GetResponse +- zones.ZonesHTTP3 Methods: -- client.Zones.Settings.HTTP3.Edit(ctx context.Context, params cloudflare.ZoneSettingHTTP3EditParams) (cloudflare.ZoneSettingHTTP3EditResponse, error) -- client.Zones.Settings.HTTP3.Get(ctx context.Context, query cloudflare.ZoneSettingHTTP3GetParams) (cloudflare.ZoneSettingHTTP3GetResponse, error) +- client.Zones.Settings.HTTP3.Edit(ctx context.Context, params zones.SettingHTTP3EditParams) (zones.ZonesHTTP3, error) +- client.Zones.Settings.HTTP3.Get(ctx context.Context, query zones.SettingHTTP3GetParams) (zones.ZonesHTTP3, error) ### ImageResizing +Params Types: + +- zones.ZonesImageResizingParam + Response Types: -- cloudflare.ZoneSettingImageResizingEditResponse -- cloudflare.ZoneSettingImageResizingGetResponse +- zones.ZonesImageResizing Methods: -- client.Zones.Settings.ImageResizing.Edit(ctx context.Context, params cloudflare.ZoneSettingImageResizingEditParams) (cloudflare.ZoneSettingImageResizingEditResponse, error) -- client.Zones.Settings.ImageResizing.Get(ctx context.Context, query cloudflare.ZoneSettingImageResizingGetParams) (cloudflare.ZoneSettingImageResizingGetResponse, error) +- client.Zones.Settings.ImageResizing.Edit(ctx context.Context, params zones.SettingImageResizingEditParams) (zones.ZonesImageResizing, error) +- client.Zones.Settings.ImageResizing.Get(ctx context.Context, query zones.SettingImageResizingGetParams) (zones.ZonesImageResizing, error) ### IPGeolocation +Params Types: + +- zones.ZonesIPGeolocationParam + Response Types: -- cloudflare.ZoneSettingIPGeolocationEditResponse -- cloudflare.ZoneSettingIPGeolocationGetResponse +- zones.ZonesIPGeolocation Methods: -- client.Zones.Settings.IPGeolocation.Edit(ctx context.Context, params cloudflare.ZoneSettingIPGeolocationEditParams) (cloudflare.ZoneSettingIPGeolocationEditResponse, error) -- client.Zones.Settings.IPGeolocation.Get(ctx context.Context, query cloudflare.ZoneSettingIPGeolocationGetParams) (cloudflare.ZoneSettingIPGeolocationGetResponse, error) +- client.Zones.Settings.IPGeolocation.Edit(ctx context.Context, params zones.SettingIPGeolocationEditParams) (zones.ZonesIPGeolocation, error) +- client.Zones.Settings.IPGeolocation.Get(ctx context.Context, query zones.SettingIPGeolocationGetParams) (zones.ZonesIPGeolocation, error) ### IPV6 +Params Types: + +- zones.ZonesIPV6Param + Response Types: -- cloudflare.ZoneSettingIPV6EditResponse -- cloudflare.ZoneSettingIPV6GetResponse +- zones.ZonesIPV6 Methods: -- client.Zones.Settings.IPV6.Edit(ctx context.Context, params cloudflare.ZoneSettingIPV6EditParams) (cloudflare.ZoneSettingIPV6EditResponse, error) -- client.Zones.Settings.IPV6.Get(ctx context.Context, query cloudflare.ZoneSettingIPV6GetParams) (cloudflare.ZoneSettingIPV6GetResponse, error) +- client.Zones.Settings.IPV6.Edit(ctx context.Context, params zones.SettingIPV6EditParams) (zones.ZonesIPV6, error) +- client.Zones.Settings.IPV6.Get(ctx context.Context, query zones.SettingIPV6GetParams) (zones.ZonesIPV6, error) ### MinTLSVersion +Params Types: + +- zones.ZonesMinTLSVersionParam + Response Types: -- cloudflare.ZoneSettingMinTLSVersionEditResponse -- cloudflare.ZoneSettingMinTLSVersionGetResponse +- zones.ZonesMinTLSVersion Methods: -- client.Zones.Settings.MinTLSVersion.Edit(ctx context.Context, params cloudflare.ZoneSettingMinTLSVersionEditParams) (cloudflare.ZoneSettingMinTLSVersionEditResponse, error) -- client.Zones.Settings.MinTLSVersion.Get(ctx context.Context, query cloudflare.ZoneSettingMinTLSVersionGetParams) (cloudflare.ZoneSettingMinTLSVersionGetResponse, error) +- client.Zones.Settings.MinTLSVersion.Edit(ctx context.Context, params zones.SettingMinTLSVersionEditParams) (zones.ZonesMinTLSVersion, error) +- client.Zones.Settings.MinTLSVersion.Get(ctx context.Context, query zones.SettingMinTLSVersionGetParams) (zones.ZonesMinTLSVersion, error) ### Minify +Params Types: + +- zones.ZonesMinifyParam + Response Types: -- cloudflare.ZoneSettingMinifyEditResponse -- cloudflare.ZoneSettingMinifyGetResponse +- zones.ZonesMinify Methods: -- client.Zones.Settings.Minify.Edit(ctx context.Context, params cloudflare.ZoneSettingMinifyEditParams) (cloudflare.ZoneSettingMinifyEditResponse, error) -- client.Zones.Settings.Minify.Get(ctx context.Context, query cloudflare.ZoneSettingMinifyGetParams) (cloudflare.ZoneSettingMinifyGetResponse, error) +- client.Zones.Settings.Minify.Edit(ctx context.Context, params zones.SettingMinifyEditParams) (zones.ZonesMinify, error) +- client.Zones.Settings.Minify.Get(ctx context.Context, query zones.SettingMinifyGetParams) (zones.ZonesMinify, error) ### Mirage +Params Types: + +- zones.ZonesMirageParam + Response Types: -- cloudflare.ZoneSettingMirageEditResponse -- cloudflare.ZoneSettingMirageGetResponse +- zones.ZonesMirage Methods: -- client.Zones.Settings.Mirage.Edit(ctx context.Context, params cloudflare.ZoneSettingMirageEditParams) (cloudflare.ZoneSettingMirageEditResponse, error) -- client.Zones.Settings.Mirage.Get(ctx context.Context, query cloudflare.ZoneSettingMirageGetParams) (cloudflare.ZoneSettingMirageGetResponse, error) +- client.Zones.Settings.Mirage.Edit(ctx context.Context, params zones.SettingMirageEditParams) (zones.ZonesMirage, error) +- client.Zones.Settings.Mirage.Get(ctx context.Context, query zones.SettingMirageGetParams) (zones.ZonesMirage, error) ### MobileRedirect +Params Types: + +- zones.ZonesMobileRedirectParam + Response Types: -- cloudflare.ZoneSettingMobileRedirectEditResponse -- cloudflare.ZoneSettingMobileRedirectGetResponse +- zones.ZonesMobileRedirect Methods: -- client.Zones.Settings.MobileRedirect.Edit(ctx context.Context, params cloudflare.ZoneSettingMobileRedirectEditParams) (cloudflare.ZoneSettingMobileRedirectEditResponse, error) -- client.Zones.Settings.MobileRedirect.Get(ctx context.Context, query cloudflare.ZoneSettingMobileRedirectGetParams) (cloudflare.ZoneSettingMobileRedirectGetResponse, error) +- client.Zones.Settings.MobileRedirect.Edit(ctx context.Context, params zones.SettingMobileRedirectEditParams) (zones.ZonesMobileRedirect, error) +- client.Zones.Settings.MobileRedirect.Get(ctx context.Context, query zones.SettingMobileRedirectGetParams) (zones.ZonesMobileRedirect, error) ### NEL +Params Types: + +- zones.ZonesNELParam + Response Types: -- cloudflare.ZoneSettingNELEditResponse -- cloudflare.ZoneSettingNELGetResponse +- zones.ZonesNEL Methods: -- client.Zones.Settings.NEL.Edit(ctx context.Context, params cloudflare.ZoneSettingNELEditParams) (cloudflare.ZoneSettingNELEditResponse, error) -- client.Zones.Settings.NEL.Get(ctx context.Context, query cloudflare.ZoneSettingNELGetParams) (cloudflare.ZoneSettingNELGetResponse, error) +- client.Zones.Settings.NEL.Edit(ctx context.Context, params zones.SettingNELEditParams) (zones.ZonesNEL, error) +- client.Zones.Settings.NEL.Get(ctx context.Context, query zones.SettingNELGetParams) (zones.ZonesNEL, error) ### OpportunisticEncryption +Params Types: + +- zones.ZonesOpportunisticEncryptionParam + Response Types: -- cloudflare.ZoneSettingOpportunisticEncryptionEditResponse -- cloudflare.ZoneSettingOpportunisticEncryptionGetResponse +- zones.ZonesOpportunisticEncryption Methods: -- client.Zones.Settings.OpportunisticEncryption.Edit(ctx context.Context, params cloudflare.ZoneSettingOpportunisticEncryptionEditParams) (cloudflare.ZoneSettingOpportunisticEncryptionEditResponse, error) -- client.Zones.Settings.OpportunisticEncryption.Get(ctx context.Context, query cloudflare.ZoneSettingOpportunisticEncryptionGetParams) (cloudflare.ZoneSettingOpportunisticEncryptionGetResponse, error) +- client.Zones.Settings.OpportunisticEncryption.Edit(ctx context.Context, params zones.SettingOpportunisticEncryptionEditParams) (zones.ZonesOpportunisticEncryption, error) +- client.Zones.Settings.OpportunisticEncryption.Get(ctx context.Context, query zones.SettingOpportunisticEncryptionGetParams) (zones.ZonesOpportunisticEncryption, error) ### OpportunisticOnion +Params Types: + +- zones.ZonesOpportunisticOnionParam + Response Types: -- cloudflare.ZoneSettingOpportunisticOnionEditResponse -- cloudflare.ZoneSettingOpportunisticOnionGetResponse +- zones.ZonesOpportunisticOnion Methods: -- client.Zones.Settings.OpportunisticOnion.Edit(ctx context.Context, params cloudflare.ZoneSettingOpportunisticOnionEditParams) (cloudflare.ZoneSettingOpportunisticOnionEditResponse, error) -- client.Zones.Settings.OpportunisticOnion.Get(ctx context.Context, query cloudflare.ZoneSettingOpportunisticOnionGetParams) (cloudflare.ZoneSettingOpportunisticOnionGetResponse, error) +- client.Zones.Settings.OpportunisticOnion.Edit(ctx context.Context, params zones.SettingOpportunisticOnionEditParams) (zones.ZonesOpportunisticOnion, error) +- client.Zones.Settings.OpportunisticOnion.Get(ctx context.Context, query zones.SettingOpportunisticOnionGetParams) (zones.ZonesOpportunisticOnion, error) ### OrangeToOrange +Params Types: + +- zones.ZonesOrangeToOrangeParam + Response Types: -- cloudflare.ZoneSettingOrangeToOrangeEditResponse -- cloudflare.ZoneSettingOrangeToOrangeGetResponse +- zones.ZonesOrangeToOrange Methods: -- client.Zones.Settings.OrangeToOrange.Edit(ctx context.Context, params cloudflare.ZoneSettingOrangeToOrangeEditParams) (cloudflare.ZoneSettingOrangeToOrangeEditResponse, error) -- client.Zones.Settings.OrangeToOrange.Get(ctx context.Context, query cloudflare.ZoneSettingOrangeToOrangeGetParams) (cloudflare.ZoneSettingOrangeToOrangeGetResponse, error) +- client.Zones.Settings.OrangeToOrange.Edit(ctx context.Context, params zones.SettingOrangeToOrangeEditParams) (zones.ZonesOrangeToOrange, error) +- client.Zones.Settings.OrangeToOrange.Get(ctx context.Context, query zones.SettingOrangeToOrangeGetParams) (zones.ZonesOrangeToOrange, error) ### OriginErrorPagePassThru +Params Types: + +- zones.ZonesOriginErrorPagePassThruParam + Response Types: -- cloudflare.ZoneSettingOriginErrorPagePassThruEditResponse -- cloudflare.ZoneSettingOriginErrorPagePassThruGetResponse +- zones.ZonesOriginErrorPagePassThru Methods: -- client.Zones.Settings.OriginErrorPagePassThru.Edit(ctx context.Context, params cloudflare.ZoneSettingOriginErrorPagePassThruEditParams) (cloudflare.ZoneSettingOriginErrorPagePassThruEditResponse, error) -- client.Zones.Settings.OriginErrorPagePassThru.Get(ctx context.Context, query cloudflare.ZoneSettingOriginErrorPagePassThruGetParams) (cloudflare.ZoneSettingOriginErrorPagePassThruGetResponse, error) +- client.Zones.Settings.OriginErrorPagePassThru.Edit(ctx context.Context, params zones.SettingOriginErrorPagePassThruEditParams) (zones.ZonesOriginErrorPagePassThru, error) +- client.Zones.Settings.OriginErrorPagePassThru.Get(ctx context.Context, query zones.SettingOriginErrorPagePassThruGetParams) (zones.ZonesOriginErrorPagePassThru, error) ### OriginMaxHTTPVersion Response Types: -- cloudflare.ZoneSettingOriginMaxHTTPVersionEditResponse -- cloudflare.ZoneSettingOriginMaxHTTPVersionGetResponse +- zones.SettingOriginMaxHTTPVersionEditResponse +- zones.SettingOriginMaxHTTPVersionGetResponse Methods: -- client.Zones.Settings.OriginMaxHTTPVersion.Edit(ctx context.Context, params cloudflare.ZoneSettingOriginMaxHTTPVersionEditParams) (cloudflare.ZoneSettingOriginMaxHTTPVersionEditResponse, error) -- client.Zones.Settings.OriginMaxHTTPVersion.Get(ctx context.Context, query cloudflare.ZoneSettingOriginMaxHTTPVersionGetParams) (cloudflare.ZoneSettingOriginMaxHTTPVersionGetResponse, error) +- client.Zones.Settings.OriginMaxHTTPVersion.Edit(ctx context.Context, params zones.SettingOriginMaxHTTPVersionEditParams) (zones.SettingOriginMaxHTTPVersionEditResponse, error) +- client.Zones.Settings.OriginMaxHTTPVersion.Get(ctx context.Context, query zones.SettingOriginMaxHTTPVersionGetParams) (zones.SettingOriginMaxHTTPVersionGetResponse, error) ### Polish +Params Types: + +- zones.ZonesPolishParam + Response Types: -- cloudflare.ZoneSettingPolishEditResponse -- cloudflare.ZoneSettingPolishGetResponse +- zones.ZonesPolish Methods: -- client.Zones.Settings.Polish.Edit(ctx context.Context, params cloudflare.ZoneSettingPolishEditParams) (cloudflare.ZoneSettingPolishEditResponse, error) -- client.Zones.Settings.Polish.Get(ctx context.Context, query cloudflare.ZoneSettingPolishGetParams) (cloudflare.ZoneSettingPolishGetResponse, error) +- client.Zones.Settings.Polish.Edit(ctx context.Context, params zones.SettingPolishEditParams) (zones.ZonesPolish, error) +- client.Zones.Settings.Polish.Get(ctx context.Context, query zones.SettingPolishGetParams) (zones.ZonesPolish, error) ### PrefetchPreload +Params Types: + +- zones.ZonesPrefetchPreloadParam + Response Types: -- cloudflare.ZoneSettingPrefetchPreloadEditResponse -- cloudflare.ZoneSettingPrefetchPreloadGetResponse +- zones.ZonesPrefetchPreload Methods: -- client.Zones.Settings.PrefetchPreload.Edit(ctx context.Context, params cloudflare.ZoneSettingPrefetchPreloadEditParams) (cloudflare.ZoneSettingPrefetchPreloadEditResponse, error) -- client.Zones.Settings.PrefetchPreload.Get(ctx context.Context, query cloudflare.ZoneSettingPrefetchPreloadGetParams) (cloudflare.ZoneSettingPrefetchPreloadGetResponse, error) +- client.Zones.Settings.PrefetchPreload.Edit(ctx context.Context, params zones.SettingPrefetchPreloadEditParams) (zones.ZonesPrefetchPreload, error) +- client.Zones.Settings.PrefetchPreload.Get(ctx context.Context, query zones.SettingPrefetchPreloadGetParams) (zones.ZonesPrefetchPreload, error) ### ProxyReadTimeout +Params Types: + +- zones.ZonesProxyReadTimeoutParam + Response Types: -- cloudflare.ZoneSettingProxyReadTimeoutEditResponse -- cloudflare.ZoneSettingProxyReadTimeoutGetResponse +- zones.ZonesProxyReadTimeout Methods: -- client.Zones.Settings.ProxyReadTimeout.Edit(ctx context.Context, params cloudflare.ZoneSettingProxyReadTimeoutEditParams) (cloudflare.ZoneSettingProxyReadTimeoutEditResponse, error) -- client.Zones.Settings.ProxyReadTimeout.Get(ctx context.Context, query cloudflare.ZoneSettingProxyReadTimeoutGetParams) (cloudflare.ZoneSettingProxyReadTimeoutGetResponse, error) +- client.Zones.Settings.ProxyReadTimeout.Edit(ctx context.Context, params zones.SettingProxyReadTimeoutEditParams) (zones.ZonesProxyReadTimeout, error) +- client.Zones.Settings.ProxyReadTimeout.Get(ctx context.Context, query zones.SettingProxyReadTimeoutGetParams) (zones.ZonesProxyReadTimeout, error) ### PseudoIPV4 +Params Types: + +- zones.ZonesPseudoIPV4Param + Response Types: -- cloudflare.ZoneSettingPseudoIPV4EditResponse -- cloudflare.ZoneSettingPseudoIPV4GetResponse +- zones.ZonesPseudoIPV4 Methods: -- client.Zones.Settings.PseudoIPV4.Edit(ctx context.Context, params cloudflare.ZoneSettingPseudoIPV4EditParams) (cloudflare.ZoneSettingPseudoIPV4EditResponse, error) -- client.Zones.Settings.PseudoIPV4.Get(ctx context.Context, query cloudflare.ZoneSettingPseudoIPV4GetParams) (cloudflare.ZoneSettingPseudoIPV4GetResponse, error) +- client.Zones.Settings.PseudoIPV4.Edit(ctx context.Context, params zones.SettingPseudoIPV4EditParams) (zones.ZonesPseudoIPV4, error) +- client.Zones.Settings.PseudoIPV4.Get(ctx context.Context, query zones.SettingPseudoIPV4GetParams) (zones.ZonesPseudoIPV4, error) ### ResponseBuffering +Params Types: + +- zones.ZonesBufferingParam + Response Types: -- cloudflare.ZoneSettingResponseBufferingEditResponse -- cloudflare.ZoneSettingResponseBufferingGetResponse +- zones.ZonesBuffering Methods: -- client.Zones.Settings.ResponseBuffering.Edit(ctx context.Context, params cloudflare.ZoneSettingResponseBufferingEditParams) (cloudflare.ZoneSettingResponseBufferingEditResponse, error) -- client.Zones.Settings.ResponseBuffering.Get(ctx context.Context, query cloudflare.ZoneSettingResponseBufferingGetParams) (cloudflare.ZoneSettingResponseBufferingGetResponse, error) +- client.Zones.Settings.ResponseBuffering.Edit(ctx context.Context, params zones.SettingResponseBufferingEditParams) (zones.ZonesBuffering, error) +- client.Zones.Settings.ResponseBuffering.Get(ctx context.Context, query zones.SettingResponseBufferingGetParams) (zones.ZonesBuffering, error) ### RocketLoader +Params Types: + +- zones.ZonesRocketLoaderParam + Response Types: -- cloudflare.ZoneSettingRocketLoaderEditResponse -- cloudflare.ZoneSettingRocketLoaderGetResponse +- zones.ZonesRocketLoader Methods: -- client.Zones.Settings.RocketLoader.Edit(ctx context.Context, params cloudflare.ZoneSettingRocketLoaderEditParams) (cloudflare.ZoneSettingRocketLoaderEditResponse, error) -- client.Zones.Settings.RocketLoader.Get(ctx context.Context, query cloudflare.ZoneSettingRocketLoaderGetParams) (cloudflare.ZoneSettingRocketLoaderGetResponse, error) +- client.Zones.Settings.RocketLoader.Edit(ctx context.Context, params zones.SettingRocketLoaderEditParams) (zones.ZonesRocketLoader, error) +- client.Zones.Settings.RocketLoader.Get(ctx context.Context, query zones.SettingRocketLoaderGetParams) (zones.ZonesRocketLoader, error) ### SecurityHeaders +Params Types: + +- zones.ZonesSecurityHeaderParam + Response Types: -- cloudflare.ZoneSettingSecurityHeaderEditResponse -- cloudflare.ZoneSettingSecurityHeaderGetResponse +- zones.ZonesSecurityHeader Methods: -- client.Zones.Settings.SecurityHeaders.Edit(ctx context.Context, params cloudflare.ZoneSettingSecurityHeaderEditParams) (cloudflare.ZoneSettingSecurityHeaderEditResponse, error) -- client.Zones.Settings.SecurityHeaders.Get(ctx context.Context, query cloudflare.ZoneSettingSecurityHeaderGetParams) (cloudflare.ZoneSettingSecurityHeaderGetResponse, error) +- client.Zones.Settings.SecurityHeaders.Edit(ctx context.Context, params zones.SettingSecurityHeaderEditParams) (zones.ZonesSecurityHeader, error) +- client.Zones.Settings.SecurityHeaders.Get(ctx context.Context, query zones.SettingSecurityHeaderGetParams) (zones.ZonesSecurityHeader, error) ### SecurityLevel +Params Types: + +- zones.ZonesSecurityLevelParam + Response Types: -- cloudflare.ZoneSettingSecurityLevelEditResponse -- cloudflare.ZoneSettingSecurityLevelGetResponse +- zones.ZonesSecurityLevel Methods: -- client.Zones.Settings.SecurityLevel.Edit(ctx context.Context, params cloudflare.ZoneSettingSecurityLevelEditParams) (cloudflare.ZoneSettingSecurityLevelEditResponse, error) -- client.Zones.Settings.SecurityLevel.Get(ctx context.Context, query cloudflare.ZoneSettingSecurityLevelGetParams) (cloudflare.ZoneSettingSecurityLevelGetResponse, error) +- client.Zones.Settings.SecurityLevel.Edit(ctx context.Context, params zones.SettingSecurityLevelEditParams) (zones.ZonesSecurityLevel, error) +- client.Zones.Settings.SecurityLevel.Get(ctx context.Context, query zones.SettingSecurityLevelGetParams) (zones.ZonesSecurityLevel, error) ### ServerSideExcludes +Params Types: + +- zones.ZonesServerSideExcludeParam + Response Types: -- cloudflare.ZoneSettingServerSideExcludeEditResponse -- cloudflare.ZoneSettingServerSideExcludeGetResponse +- zones.ZonesServerSideExclude Methods: -- client.Zones.Settings.ServerSideExcludes.Edit(ctx context.Context, params cloudflare.ZoneSettingServerSideExcludeEditParams) (cloudflare.ZoneSettingServerSideExcludeEditResponse, error) -- client.Zones.Settings.ServerSideExcludes.Get(ctx context.Context, query cloudflare.ZoneSettingServerSideExcludeGetParams) (cloudflare.ZoneSettingServerSideExcludeGetResponse, error) +- client.Zones.Settings.ServerSideExcludes.Edit(ctx context.Context, params zones.SettingServerSideExcludeEditParams) (zones.ZonesServerSideExclude, error) +- client.Zones.Settings.ServerSideExcludes.Get(ctx context.Context, query zones.SettingServerSideExcludeGetParams) (zones.ZonesServerSideExclude, error) ### SortQueryStringForCache +Params Types: + +- zones.ZonesSortQueryStringForCacheParam + Response Types: -- cloudflare.ZoneSettingSortQueryStringForCacheEditResponse -- cloudflare.ZoneSettingSortQueryStringForCacheGetResponse +- zones.ZonesSortQueryStringForCache Methods: -- client.Zones.Settings.SortQueryStringForCache.Edit(ctx context.Context, params cloudflare.ZoneSettingSortQueryStringForCacheEditParams) (cloudflare.ZoneSettingSortQueryStringForCacheEditResponse, error) -- client.Zones.Settings.SortQueryStringForCache.Get(ctx context.Context, query cloudflare.ZoneSettingSortQueryStringForCacheGetParams) (cloudflare.ZoneSettingSortQueryStringForCacheGetResponse, error) +- client.Zones.Settings.SortQueryStringForCache.Edit(ctx context.Context, params zones.SettingSortQueryStringForCacheEditParams) (zones.ZonesSortQueryStringForCache, error) +- client.Zones.Settings.SortQueryStringForCache.Get(ctx context.Context, query zones.SettingSortQueryStringForCacheGetParams) (zones.ZonesSortQueryStringForCache, error) ### SSL +Params Types: + +- zones.ZonesSSLParam + Response Types: -- cloudflare.ZoneSettingSSLEditResponse -- cloudflare.ZoneSettingSSLGetResponse +- zones.ZonesSSL Methods: -- client.Zones.Settings.SSL.Edit(ctx context.Context, params cloudflare.ZoneSettingSSLEditParams) (cloudflare.ZoneSettingSSLEditResponse, error) -- client.Zones.Settings.SSL.Get(ctx context.Context, query cloudflare.ZoneSettingSSLGetParams) (cloudflare.ZoneSettingSSLGetResponse, error) +- client.Zones.Settings.SSL.Edit(ctx context.Context, params zones.SettingSSLEditParams) (zones.ZonesSSL, error) +- client.Zones.Settings.SSL.Get(ctx context.Context, query zones.SettingSSLGetParams) (zones.ZonesSSL, error) ### SSLRecommender +Params Types: + +- zones.ZonesSSLRecommenderParam + Response Types: -- cloudflare.ZoneSettingSSLRecommenderEditResponse -- cloudflare.ZoneSettingSSLRecommenderGetResponse +- zones.ZonesSSLRecommender Methods: -- client.Zones.Settings.SSLRecommender.Edit(ctx context.Context, params cloudflare.ZoneSettingSSLRecommenderEditParams) (cloudflare.ZoneSettingSSLRecommenderEditResponse, error) -- client.Zones.Settings.SSLRecommender.Get(ctx context.Context, query cloudflare.ZoneSettingSSLRecommenderGetParams) (cloudflare.ZoneSettingSSLRecommenderGetResponse, error) +- client.Zones.Settings.SSLRecommender.Edit(ctx context.Context, params zones.SettingSSLRecommenderEditParams) (zones.ZonesSSLRecommender, error) +- client.Zones.Settings.SSLRecommender.Get(ctx context.Context, query zones.SettingSSLRecommenderGetParams) (zones.ZonesSSLRecommender, error) ### TLS1_3 +Params Types: + +- zones.ZonesTLS1_3Param + Response Types: -- cloudflare.ZoneSettingTls1_3EditResponse -- cloudflare.ZoneSettingTls1_3GetResponse +- zones.ZonesTLS1_3 Methods: -- client.Zones.Settings.TLS1_3.Edit(ctx context.Context, params cloudflare.ZoneSettingTLS1_3EditParams) (cloudflare.ZoneSettingTls1_3EditResponse, error) -- client.Zones.Settings.TLS1_3.Get(ctx context.Context, query cloudflare.ZoneSettingTLS1_3GetParams) (cloudflare.ZoneSettingTls1_3GetResponse, error) +- client.Zones.Settings.TLS1_3.Edit(ctx context.Context, params zones.SettingTLS1_3EditParams) (zones.ZonesTLS1_3, error) +- client.Zones.Settings.TLS1_3.Get(ctx context.Context, query zones.SettingTLS1_3GetParams) (zones.ZonesTLS1_3, error) ### TLSClientAuth +Params Types: + +- zones.ZonesTLSClientAuthParam + Response Types: -- cloudflare.ZoneSettingTLSClientAuthEditResponse -- cloudflare.ZoneSettingTLSClientAuthGetResponse +- zones.ZonesTLSClientAuth Methods: -- client.Zones.Settings.TLSClientAuth.Edit(ctx context.Context, params cloudflare.ZoneSettingTLSClientAuthEditParams) (cloudflare.ZoneSettingTLSClientAuthEditResponse, error) -- client.Zones.Settings.TLSClientAuth.Get(ctx context.Context, query cloudflare.ZoneSettingTLSClientAuthGetParams) (cloudflare.ZoneSettingTLSClientAuthGetResponse, error) +- client.Zones.Settings.TLSClientAuth.Edit(ctx context.Context, params zones.SettingTLSClientAuthEditParams) (zones.ZonesTLSClientAuth, error) +- client.Zones.Settings.TLSClientAuth.Get(ctx context.Context, query zones.SettingTLSClientAuthGetParams) (zones.ZonesTLSClientAuth, error) ### TrueClientIPHeader +Params Types: + +- zones.ZonesTrueClientIPHeaderParam + Response Types: -- cloudflare.ZoneSettingTrueClientIPHeaderEditResponse -- cloudflare.ZoneSettingTrueClientIPHeaderGetResponse +- zones.ZonesTrueClientIPHeader Methods: -- client.Zones.Settings.TrueClientIPHeader.Edit(ctx context.Context, params cloudflare.ZoneSettingTrueClientIPHeaderEditParams) (cloudflare.ZoneSettingTrueClientIPHeaderEditResponse, error) -- client.Zones.Settings.TrueClientIPHeader.Get(ctx context.Context, query cloudflare.ZoneSettingTrueClientIPHeaderGetParams) (cloudflare.ZoneSettingTrueClientIPHeaderGetResponse, error) +- client.Zones.Settings.TrueClientIPHeader.Edit(ctx context.Context, params zones.SettingTrueClientIPHeaderEditParams) (zones.ZonesTrueClientIPHeader, error) +- client.Zones.Settings.TrueClientIPHeader.Get(ctx context.Context, query zones.SettingTrueClientIPHeaderGetParams) (zones.ZonesTrueClientIPHeader, error) ### WAF +Params Types: + +- zones.ZonesWAFParam + Response Types: -- cloudflare.ZoneSettingWAFEditResponse -- cloudflare.ZoneSettingWAFGetResponse +- zones.ZonesWAF Methods: -- client.Zones.Settings.WAF.Edit(ctx context.Context, params cloudflare.ZoneSettingWAFEditParams) (cloudflare.ZoneSettingWAFEditResponse, error) -- client.Zones.Settings.WAF.Get(ctx context.Context, query cloudflare.ZoneSettingWAFGetParams) (cloudflare.ZoneSettingWAFGetResponse, error) +- client.Zones.Settings.WAF.Edit(ctx context.Context, params zones.SettingWAFEditParams) (zones.ZonesWAF, error) +- client.Zones.Settings.WAF.Get(ctx context.Context, query zones.SettingWAFGetParams) (zones.ZonesWAF, error) ### Webp +Params Types: + +- zones.ZonesWebpParam + Response Types: -- cloudflare.ZoneSettingWebpEditResponse -- cloudflare.ZoneSettingWebpGetResponse +- zones.ZonesWebp Methods: -- client.Zones.Settings.Webp.Edit(ctx context.Context, params cloudflare.ZoneSettingWebpEditParams) (cloudflare.ZoneSettingWebpEditResponse, error) -- client.Zones.Settings.Webp.Get(ctx context.Context, query cloudflare.ZoneSettingWebpGetParams) (cloudflare.ZoneSettingWebpGetResponse, error) +- client.Zones.Settings.Webp.Edit(ctx context.Context, params zones.SettingWebpEditParams) (zones.ZonesWebp, error) +- client.Zones.Settings.Webp.Get(ctx context.Context, query zones.SettingWebpGetParams) (zones.ZonesWebp, error) ### Websocket +Params Types: + +- zones.ZonesWebsocketsParam + Response Types: -- cloudflare.ZoneSettingWebsocketEditResponse -- cloudflare.ZoneSettingWebsocketGetResponse +- zones.ZonesWebsockets Methods: -- client.Zones.Settings.Websocket.Edit(ctx context.Context, params cloudflare.ZoneSettingWebsocketEditParams) (cloudflare.ZoneSettingWebsocketEditResponse, error) -- client.Zones.Settings.Websocket.Get(ctx context.Context, query cloudflare.ZoneSettingWebsocketGetParams) (cloudflare.ZoneSettingWebsocketGetResponse, error) +- client.Zones.Settings.Websocket.Edit(ctx context.Context, params zones.SettingWebsocketEditParams) (zones.ZonesWebsockets, error) +- client.Zones.Settings.Websocket.Get(ctx context.Context, query zones.SettingWebsocketGetParams) (zones.ZonesWebsockets, error) ### FontSettings Response Types: -- cloudflare.ZoneSettingFontSettingEditResponse -- cloudflare.ZoneSettingFontSettingGetResponse +- zones.SpeedCloudflareFonts Methods: -- client.Zones.Settings.FontSettings.Edit(ctx context.Context, params cloudflare.ZoneSettingFontSettingEditParams) (cloudflare.ZoneSettingFontSettingEditResponse, error) -- client.Zones.Settings.FontSettings.Get(ctx context.Context, query cloudflare.ZoneSettingFontSettingGetParams) (cloudflare.ZoneSettingFontSettingGetResponse, error) +- client.Zones.Settings.FontSettings.Edit(ctx context.Context, params zones.SettingFontSettingEditParams) (zones.SpeedCloudflareFonts, error) +- client.Zones.Settings.FontSettings.Get(ctx context.Context, query zones.SettingFontSettingGetParams) (zones.SpeedCloudflareFonts, error) ## CustomNameservers Response Types: -- cloudflare.ZoneCustomNameserverUpdateResponse -- cloudflare.ZoneCustomNameserverGetResponse +- zones.CustomNameserverUpdateResponse +- zones.CustomNameserverGetResponse Methods: -- client.Zones.CustomNameservers.Update(ctx context.Context, params cloudflare.ZoneCustomNameserverUpdateParams) (cloudflare.ZoneCustomNameserverUpdateResponse, error) -- client.Zones.CustomNameservers.Get(ctx context.Context, query cloudflare.ZoneCustomNameserverGetParams) (cloudflare.ZoneCustomNameserverGetResponse, error) +- client.Zones.CustomNameservers.Update(ctx context.Context, params zones.CustomNameserverUpdateParams) (zones.CustomNameserverUpdateResponse, error) +- client.Zones.CustomNameservers.Get(ctx context.Context, query zones.CustomNameserverGetParams) (zones.CustomNameserverGetResponse, error) ## Holds Response Types: -- cloudflare.ZoneHoldNewResponse -- cloudflare.ZoneHoldDeleteResponse -- cloudflare.ZoneHoldGetResponse +- zones.HoldNewResponse +- zones.HoldDeleteResponse +- zones.HoldGetResponse Methods: -- client.Zones.Holds.New(ctx context.Context, params cloudflare.ZoneHoldNewParams) (cloudflare.ZoneHoldNewResponse, error) -- client.Zones.Holds.Delete(ctx context.Context, params cloudflare.ZoneHoldDeleteParams) (cloudflare.ZoneHoldDeleteResponse, error) -- client.Zones.Holds.Get(ctx context.Context, query cloudflare.ZoneHoldGetParams) (cloudflare.ZoneHoldGetResponse, error) +- client.Zones.Holds.New(ctx context.Context, params zones.HoldNewParams) (zones.HoldNewResponse, error) +- client.Zones.Holds.Delete(ctx context.Context, params zones.HoldDeleteParams) (zones.HoldDeleteResponse, error) +- client.Zones.Holds.Get(ctx context.Context, query zones.HoldGetParams) (zones.HoldGetResponse, error) ## Workers @@ -984,223 +1125,209 @@ Methods: Response Types: -- cloudflare.ZoneWorkerScriptUpdateResponse +- zones.WorkerScriptUpdateResponse Methods: -- client.Zones.Workers.Script.Update(ctx context.Context, body cloudflare.ZoneWorkerScriptUpdateParams) (cloudflare.ZoneWorkerScriptUpdateResponse, error) -- client.Zones.Workers.Script.Delete(ctx context.Context, body cloudflare.ZoneWorkerScriptDeleteParams) error -- client.Zones.Workers.Script.Get(ctx context.Context, query cloudflare.ZoneWorkerScriptGetParams) (http.Response, error) +- client.Zones.Workers.Script.Update(ctx context.Context, body zones.WorkerScriptUpdateParams) (zones.WorkerScriptUpdateResponse, error) +- client.Zones.Workers.Script.Delete(ctx context.Context, body zones.WorkerScriptDeleteParams) error +- client.Zones.Workers.Script.Get(ctx context.Context, query zones.WorkerScriptGetParams) (http.Response, error) ## Subscriptions Response Types: -- cloudflare.ZoneSubscriptionNewResponse -- cloudflare.ZoneSubscriptionListResponse -- cloudflare.ZoneSubscriptionGetResponse +- zones.SubscriptionNewResponse +- zones.SubscriptionListResponse +- zones.SubscriptionGetResponse Methods: -- client.Zones.Subscriptions.New(ctx context.Context, identifier string, body cloudflare.ZoneSubscriptionNewParams) (cloudflare.ZoneSubscriptionNewResponse, error) -- client.Zones.Subscriptions.List(ctx context.Context, accountIdentifier string) ([]cloudflare.ZoneSubscriptionListResponse, error) -- client.Zones.Subscriptions.Get(ctx context.Context, identifier string) (cloudflare.ZoneSubscriptionGetResponse, error) +- client.Zones.Subscriptions.New(ctx context.Context, identifier string, body zones.SubscriptionNewParams) (zones.SubscriptionNewResponse, error) +- client.Zones.Subscriptions.List(ctx context.Context, accountIdentifier string) ([]zones.SubscriptionListResponse, error) +- client.Zones.Subscriptions.Get(ctx context.Context, identifier string) (zones.SubscriptionGetResponse, error) # LoadBalancers Response Types: -- cloudflare.LoadBalancer -- cloudflare.LoadBalancerDeleteResponse +- load_balancers.LoadBalancer +- load_balancers.LoadBalancerDeleteResponse Methods: -- client.LoadBalancers.New(ctx context.Context, params cloudflare.LoadBalancerNewParams) (cloudflare.LoadBalancer, error) -- client.LoadBalancers.Update(ctx context.Context, loadBalancerID string, params cloudflare.LoadBalancerUpdateParams) (cloudflare.LoadBalancer, error) -- client.LoadBalancers.List(ctx context.Context, query cloudflare.LoadBalancerListParams) ([]cloudflare.LoadBalancer, error) -- client.LoadBalancers.Delete(ctx context.Context, loadBalancerID string, body cloudflare.LoadBalancerDeleteParams) (cloudflare.LoadBalancerDeleteResponse, error) -- client.LoadBalancers.Edit(ctx context.Context, loadBalancerID string, params cloudflare.LoadBalancerEditParams) (cloudflare.LoadBalancer, error) -- client.LoadBalancers.Get(ctx context.Context, loadBalancerID string, query cloudflare.LoadBalancerGetParams) (cloudflare.LoadBalancer, error) +- client.LoadBalancers.New(ctx context.Context, params load_balancers.LoadBalancerNewParams) (load_balancers.LoadBalancer, error) +- client.LoadBalancers.Update(ctx context.Context, loadBalancerID string, params load_balancers.LoadBalancerUpdateParams) (load_balancers.LoadBalancer, error) +- client.LoadBalancers.List(ctx context.Context, query load_balancers.LoadBalancerListParams) ([]load_balancers.LoadBalancer, error) +- client.LoadBalancers.Delete(ctx context.Context, loadBalancerID string, body load_balancers.LoadBalancerDeleteParams) (load_balancers.LoadBalancerDeleteResponse, error) +- client.LoadBalancers.Edit(ctx context.Context, loadBalancerID string, params load_balancers.LoadBalancerEditParams) (load_balancers.LoadBalancer, error) +- client.LoadBalancers.Get(ctx context.Context, loadBalancerID string, query load_balancers.LoadBalancerGetParams) (load_balancers.LoadBalancer, error) ## Monitors Response Types: -- cloudflare.LoadBalancerMonitorNewResponse -- cloudflare.LoadBalancerMonitorUpdateResponse -- cloudflare.LoadBalancerMonitorListResponse -- cloudflare.LoadBalancerMonitorDeleteResponse -- cloudflare.LoadBalancerMonitorEditResponse -- cloudflare.LoadBalancerMonitorGetResponse +- load_balancers.MonitorDeleteResponse Methods: -- client.LoadBalancers.Monitors.New(ctx context.Context, params cloudflare.LoadBalancerMonitorNewParams) (cloudflare.LoadBalancerMonitorNewResponse, error) -- client.LoadBalancers.Monitors.Update(ctx context.Context, monitorID string, params cloudflare.LoadBalancerMonitorUpdateParams) (cloudflare.LoadBalancerMonitorUpdateResponse, error) -- client.LoadBalancers.Monitors.List(ctx context.Context, query cloudflare.LoadBalancerMonitorListParams) ([]cloudflare.LoadBalancerMonitorListResponse, error) -- client.LoadBalancers.Monitors.Delete(ctx context.Context, monitorID string, body cloudflare.LoadBalancerMonitorDeleteParams) (cloudflare.LoadBalancerMonitorDeleteResponse, error) -- client.LoadBalancers.Monitors.Edit(ctx context.Context, monitorID string, params cloudflare.LoadBalancerMonitorEditParams) (cloudflare.LoadBalancerMonitorEditResponse, error) -- client.LoadBalancers.Monitors.Get(ctx context.Context, monitorID string, query cloudflare.LoadBalancerMonitorGetParams) (cloudflare.LoadBalancerMonitorGetResponse, error) +- client.LoadBalancers.Monitors.New(ctx context.Context, params load_balancers.MonitorNewParams) (user.LoadBalancingMonitor, error) +- client.LoadBalancers.Monitors.Update(ctx context.Context, monitorID string, params load_balancers.MonitorUpdateParams) (user.LoadBalancingMonitor, error) +- client.LoadBalancers.Monitors.List(ctx context.Context, query load_balancers.MonitorListParams) ([]user.LoadBalancingMonitor, error) +- client.LoadBalancers.Monitors.Delete(ctx context.Context, monitorID string, body load_balancers.MonitorDeleteParams) (load_balancers.MonitorDeleteResponse, error) +- client.LoadBalancers.Monitors.Edit(ctx context.Context, monitorID string, params load_balancers.MonitorEditParams) (user.LoadBalancingMonitor, error) +- client.LoadBalancers.Monitors.Get(ctx context.Context, monitorID string, query load_balancers.MonitorGetParams) (user.LoadBalancingMonitor, error) ### Previews Response Types: -- cloudflare.LoadBalancerMonitorPreviewNewResponse +- load_balancers.MonitorPreviewNewResponse Methods: -- client.LoadBalancers.Monitors.Previews.New(ctx context.Context, monitorID string, params cloudflare.LoadBalancerMonitorPreviewNewParams) (cloudflare.LoadBalancerMonitorPreviewNewResponse, error) +- client.LoadBalancers.Monitors.Previews.New(ctx context.Context, monitorID string, params load_balancers.MonitorPreviewNewParams) (load_balancers.MonitorPreviewNewResponse, error) ### References Response Types: -- cloudflare.LoadBalancerMonitorReferenceGetResponse +- load_balancers.MonitorReferenceGetResponse Methods: -- client.LoadBalancers.Monitors.References.Get(ctx context.Context, monitorID string, query cloudflare.LoadBalancerMonitorReferenceGetParams) ([]cloudflare.LoadBalancerMonitorReferenceGetResponse, error) +- client.LoadBalancers.Monitors.References.Get(ctx context.Context, monitorID string, query load_balancers.MonitorReferenceGetParams) ([]load_balancers.MonitorReferenceGetResponse, error) ## Pools Response Types: -- cloudflare.LoadBalancerPoolNewResponse -- cloudflare.LoadBalancerPoolUpdateResponse -- cloudflare.LoadBalancerPoolListResponse -- cloudflare.LoadBalancerPoolDeleteResponse -- cloudflare.LoadBalancerPoolEditResponse -- cloudflare.LoadBalancerPoolGetResponse +- load_balancers.PoolDeleteResponse Methods: -- client.LoadBalancers.Pools.New(ctx context.Context, params cloudflare.LoadBalancerPoolNewParams) (cloudflare.LoadBalancerPoolNewResponse, error) -- client.LoadBalancers.Pools.Update(ctx context.Context, poolID string, params cloudflare.LoadBalancerPoolUpdateParams) (cloudflare.LoadBalancerPoolUpdateResponse, error) -- client.LoadBalancers.Pools.List(ctx context.Context, params cloudflare.LoadBalancerPoolListParams) ([]cloudflare.LoadBalancerPoolListResponse, error) -- client.LoadBalancers.Pools.Delete(ctx context.Context, poolID string, body cloudflare.LoadBalancerPoolDeleteParams) (cloudflare.LoadBalancerPoolDeleteResponse, error) -- client.LoadBalancers.Pools.Edit(ctx context.Context, poolID string, params cloudflare.LoadBalancerPoolEditParams) (cloudflare.LoadBalancerPoolEditResponse, error) -- client.LoadBalancers.Pools.Get(ctx context.Context, poolID string, query cloudflare.LoadBalancerPoolGetParams) (cloudflare.LoadBalancerPoolGetResponse, error) +- client.LoadBalancers.Pools.New(ctx context.Context, params load_balancers.PoolNewParams) (user.LoadBalancingPool, error) +- client.LoadBalancers.Pools.Update(ctx context.Context, poolID string, params load_balancers.PoolUpdateParams) (user.LoadBalancingPool, error) +- client.LoadBalancers.Pools.List(ctx context.Context, params load_balancers.PoolListParams) ([]user.LoadBalancingPool, error) +- client.LoadBalancers.Pools.Delete(ctx context.Context, poolID string, body load_balancers.PoolDeleteParams) (load_balancers.PoolDeleteResponse, error) +- client.LoadBalancers.Pools.Edit(ctx context.Context, poolID string, params load_balancers.PoolEditParams) (user.LoadBalancingPool, error) +- client.LoadBalancers.Pools.Get(ctx context.Context, poolID string, query load_balancers.PoolGetParams) (user.LoadBalancingPool, error) ### Health Response Types: -- cloudflare.LoadBalancerPoolHealthNewResponse -- cloudflare.LoadBalancerPoolHealthGetResponse +- load_balancers.PoolHealthNewResponse +- load_balancers.PoolHealthGetResponse Methods: -- client.LoadBalancers.Pools.Health.New(ctx context.Context, poolID string, params cloudflare.LoadBalancerPoolHealthNewParams) (cloudflare.LoadBalancerPoolHealthNewResponse, error) -- client.LoadBalancers.Pools.Health.Get(ctx context.Context, poolID string, query cloudflare.LoadBalancerPoolHealthGetParams) (cloudflare.LoadBalancerPoolHealthGetResponse, error) +- client.LoadBalancers.Pools.Health.New(ctx context.Context, poolID string, params load_balancers.PoolHealthNewParams) (load_balancers.PoolHealthNewResponse, error) +- client.LoadBalancers.Pools.Health.Get(ctx context.Context, poolID string, query load_balancers.PoolHealthGetParams) (load_balancers.PoolHealthGetResponse, error) ### References Response Types: -- cloudflare.LoadBalancerPoolReferenceGetResponse +- load_balancers.PoolReferenceGetResponse Methods: -- client.LoadBalancers.Pools.References.Get(ctx context.Context, poolID string, query cloudflare.LoadBalancerPoolReferenceGetParams) ([]cloudflare.LoadBalancerPoolReferenceGetResponse, error) +- client.LoadBalancers.Pools.References.Get(ctx context.Context, poolID string, query load_balancers.PoolReferenceGetParams) ([]load_balancers.PoolReferenceGetResponse, error) ## Previews -Response Types: - -- cloudflare.LoadBalancerPreviewGetResponse - Methods: -- client.LoadBalancers.Previews.Get(ctx context.Context, previewID interface{}, query cloudflare.LoadBalancerPreviewGetParams) (cloudflare.LoadBalancerPreviewGetResponse, error) +- client.LoadBalancers.Previews.Get(ctx context.Context, previewID interface{}, query load_balancers.PreviewGetParams) (user.LoadBalancingPreviewResult, error) ## Regions Response Types: -- cloudflare.LoadBalancerRegionListResponse -- cloudflare.LoadBalancerRegionGetResponse +- load_balancers.RegionListResponse +- load_balancers.RegionGetResponse Methods: -- client.LoadBalancers.Regions.List(ctx context.Context, params cloudflare.LoadBalancerRegionListParams) (cloudflare.LoadBalancerRegionListResponse, error) -- client.LoadBalancers.Regions.Get(ctx context.Context, regionID cloudflare.LoadBalancerRegionGetParamsRegionID, query cloudflare.LoadBalancerRegionGetParams) (cloudflare.LoadBalancerRegionGetResponse, error) +- client.LoadBalancers.Regions.List(ctx context.Context, params load_balancers.RegionListParams) (load_balancers.RegionListResponse, error) +- client.LoadBalancers.Regions.Get(ctx context.Context, regionID load_balancers.RegionGetParamsRegionID, query load_balancers.RegionGetParams) (load_balancers.RegionGetResponse, error) ## Searches Response Types: -- cloudflare.LoadBalancerSearchGetResponse +- load_balancers.SearchGetResponse Methods: -- client.LoadBalancers.Searches.Get(ctx context.Context, params cloudflare.LoadBalancerSearchGetParams) ([]cloudflare.LoadBalancerSearchGetResponse, error) +- client.LoadBalancers.Searches.Get(ctx context.Context, params load_balancers.SearchGetParams) ([]load_balancers.SearchGetResponse, error) # Cache Response Types: -- cloudflare.CachePurgeResponse +- cache.CachePurgeResponse Methods: -- client.Cache.Purge(ctx context.Context, params cloudflare.CachePurgeParams) (cloudflare.CachePurgeResponse, error) +- client.Cache.Purge(ctx context.Context, params cache.CachePurgeParams) (cache.CachePurgeResponse, error) ## CacheReserve Response Types: -- cloudflare.CacheCacheReserveClearResponse -- cloudflare.CacheCacheReserveEditResponse -- cloudflare.CacheCacheReserveGetResponse -- cloudflare.CacheCacheReserveStatusResponse +- cache.CacheReserveClearResponse +- cache.CacheReserveEditResponse +- cache.CacheReserveGetResponse +- cache.CacheReserveStatusResponse Methods: -- client.Cache.CacheReserve.Clear(ctx context.Context, body cloudflare.CacheCacheReserveClearParams) (cloudflare.CacheCacheReserveClearResponse, error) -- client.Cache.CacheReserve.Edit(ctx context.Context, params cloudflare.CacheCacheReserveEditParams) (cloudflare.CacheCacheReserveEditResponse, error) -- client.Cache.CacheReserve.Get(ctx context.Context, query cloudflare.CacheCacheReserveGetParams) (cloudflare.CacheCacheReserveGetResponse, error) -- client.Cache.CacheReserve.Status(ctx context.Context, query cloudflare.CacheCacheReserveStatusParams) (cloudflare.CacheCacheReserveStatusResponse, error) +- client.Cache.CacheReserve.Clear(ctx context.Context, body cache.CacheReserveClearParams) (cache.CacheReserveClearResponse, error) +- client.Cache.CacheReserve.Edit(ctx context.Context, params cache.CacheReserveEditParams) (cache.CacheReserveEditResponse, error) +- client.Cache.CacheReserve.Get(ctx context.Context, query cache.CacheReserveGetParams) (cache.CacheReserveGetResponse, error) +- client.Cache.CacheReserve.Status(ctx context.Context, query cache.CacheReserveStatusParams) (cache.CacheReserveStatusResponse, error) ## SmartTieredCached Response Types: -- cloudflare.CacheSmartTieredCachedDeleteResponse -- cloudflare.CacheSmartTieredCachedEditResponse -- cloudflare.CacheSmartTieredCachedGetResponse +- cache.SmartTieredCachedDeleteResponse +- cache.SmartTieredCachedEditResponse +- cache.SmartTieredCachedGetResponse Methods: -- client.Cache.SmartTieredCached.Delete(ctx context.Context, body cloudflare.CacheSmartTieredCachedDeleteParams) (cloudflare.CacheSmartTieredCachedDeleteResponse, error) -- client.Cache.SmartTieredCached.Edit(ctx context.Context, params cloudflare.CacheSmartTieredCachedEditParams) (cloudflare.CacheSmartTieredCachedEditResponse, error) -- client.Cache.SmartTieredCached.Get(ctx context.Context, query cloudflare.CacheSmartTieredCachedGetParams) (cloudflare.CacheSmartTieredCachedGetResponse, error) +- client.Cache.SmartTieredCached.Delete(ctx context.Context, body cache.SmartTieredCachedDeleteParams) (cache.SmartTieredCachedDeleteResponse, error) +- client.Cache.SmartTieredCached.Edit(ctx context.Context, params cache.SmartTieredCachedEditParams) (cache.SmartTieredCachedEditResponse, error) +- client.Cache.SmartTieredCached.Get(ctx context.Context, query cache.SmartTieredCachedGetParams) (cache.SmartTieredCachedGetResponse, error) ## Variants Response Types: -- cloudflare.CacheVariantDeleteResponse -- cloudflare.CacheVariantEditResponse -- cloudflare.CacheVariantGetResponse +- cache.CacheVariants +- cache.VariantEditResponse +- cache.VariantGetResponse Methods: -- client.Cache.Variants.Delete(ctx context.Context, body cloudflare.CacheVariantDeleteParams) (cloudflare.CacheVariantDeleteResponse, error) -- client.Cache.Variants.Edit(ctx context.Context, params cloudflare.CacheVariantEditParams) (cloudflare.CacheVariantEditResponse, error) -- client.Cache.Variants.Get(ctx context.Context, query cloudflare.CacheVariantGetParams) (cloudflare.CacheVariantGetResponse, error) +- client.Cache.Variants.Delete(ctx context.Context, body cache.VariantDeleteParams) (cache.CacheVariants, error) +- client.Cache.Variants.Edit(ctx context.Context, params cache.VariantEditParams) (cache.VariantEditResponse, error) +- client.Cache.Variants.Get(ctx context.Context, query cache.VariantGetParams) (cache.VariantGetResponse, error) ## RegionalTieredCache Response Types: -- cloudflare.CacheRegionalTieredCacheEditResponse -- cloudflare.CacheRegionalTieredCacheGetResponse +- cache.RegionalTieredCacheEditResponse +- cache.RegionalTieredCacheGetResponse Methods: -- client.Cache.RegionalTieredCache.Edit(ctx context.Context, params cloudflare.CacheRegionalTieredCacheEditParams) (cloudflare.CacheRegionalTieredCacheEditResponse, error) -- client.Cache.RegionalTieredCache.Get(ctx context.Context, query cloudflare.CacheRegionalTieredCacheGetParams) (cloudflare.CacheRegionalTieredCacheGetResponse, error) +- client.Cache.RegionalTieredCache.Edit(ctx context.Context, params cache.RegionalTieredCacheEditParams) (cache.RegionalTieredCacheEditResponse, error) +- client.Cache.RegionalTieredCache.Get(ctx context.Context, query cache.RegionalTieredCacheGetParams) (cache.RegionalTieredCacheGetResponse, error) # SSL @@ -1208,57 +1335,57 @@ Methods: Response Types: -- cloudflare.SSLAnalyzeNewResponse +- ssl.AnalyzeNewResponse Methods: -- client.SSL.Analyze.New(ctx context.Context, params cloudflare.SSLAnalyzeNewParams) (cloudflare.SSLAnalyzeNewResponse, error) +- client.SSL.Analyze.New(ctx context.Context, params ssl.AnalyzeNewParams) (ssl.AnalyzeNewResponse, error) ## CertificatePacks Response Types: -- cloudflare.SSLCertificatePackListResponse -- cloudflare.SSLCertificatePackDeleteResponse -- cloudflare.SSLCertificatePackEditResponse -- cloudflare.SSLCertificatePackGetResponse +- ssl.CertificatePackListResponse +- ssl.CertificatePackDeleteResponse +- ssl.CertificatePackEditResponse +- ssl.CertificatePackGetResponse Methods: -- client.SSL.CertificatePacks.List(ctx context.Context, params cloudflare.SSLCertificatePackListParams) ([]cloudflare.SSLCertificatePackListResponse, error) -- client.SSL.CertificatePacks.Delete(ctx context.Context, certificatePackID string, body cloudflare.SSLCertificatePackDeleteParams) (cloudflare.SSLCertificatePackDeleteResponse, error) -- client.SSL.CertificatePacks.Edit(ctx context.Context, certificatePackID string, body cloudflare.SSLCertificatePackEditParams) (cloudflare.SSLCertificatePackEditResponse, error) -- client.SSL.CertificatePacks.Get(ctx context.Context, certificatePackID string, query cloudflare.SSLCertificatePackGetParams) (cloudflare.SSLCertificatePackGetResponse, error) +- client.SSL.CertificatePacks.List(ctx context.Context, params ssl.CertificatePackListParams) ([]ssl.CertificatePackListResponse, error) +- client.SSL.CertificatePacks.Delete(ctx context.Context, certificatePackID string, body ssl.CertificatePackDeleteParams) (ssl.CertificatePackDeleteResponse, error) +- client.SSL.CertificatePacks.Edit(ctx context.Context, certificatePackID string, body ssl.CertificatePackEditParams) (ssl.CertificatePackEditResponse, error) +- client.SSL.CertificatePacks.Get(ctx context.Context, certificatePackID string, query ssl.CertificatePackGetParams) (ssl.CertificatePackGetResponse, error) ### Order Response Types: -- cloudflare.SSLCertificatePackOrderNewResponse +- ssl.CertificatePackOrderNewResponse Methods: -- client.SSL.CertificatePacks.Order.New(ctx context.Context, params cloudflare.SSLCertificatePackOrderNewParams) (cloudflare.SSLCertificatePackOrderNewResponse, error) +- client.SSL.CertificatePacks.Order.New(ctx context.Context, params ssl.CertificatePackOrderNewParams) (ssl.CertificatePackOrderNewResponse, error) ### Quota Response Types: -- cloudflare.SSLCertificatePackQuotaGetResponse +- ssl.CertificatePackQuotaGetResponse Methods: -- client.SSL.CertificatePacks.Quota.Get(ctx context.Context, query cloudflare.SSLCertificatePackQuotaGetParams) (cloudflare.SSLCertificatePackQuotaGetResponse, error) +- client.SSL.CertificatePacks.Quota.Get(ctx context.Context, query ssl.CertificatePackQuotaGetParams) (ssl.CertificatePackQuotaGetResponse, error) ## Recommendations Response Types: -- cloudflare.SSLRecommendationGetResponse +- ssl.RecommendationGetResponse Methods: -- client.SSL.Recommendations.Get(ctx context.Context, zoneIdentifier string) (cloudflare.SSLRecommendationGetResponse, error) +- client.SSL.Recommendations.Get(ctx context.Context, zoneIdentifier string) (ssl.RecommendationGetResponse, error) ## Universal @@ -1266,43 +1393,42 @@ Methods: Response Types: -- cloudflare.SSLUniversalSettingEditResponse -- cloudflare.SSLUniversalSettingGetResponse +- ssl.TLSCertificatesAndHostnamesUniversal Methods: -- client.SSL.Universal.Settings.Edit(ctx context.Context, params cloudflare.SSLUniversalSettingEditParams) (cloudflare.SSLUniversalSettingEditResponse, error) -- client.SSL.Universal.Settings.Get(ctx context.Context, query cloudflare.SSLUniversalSettingGetParams) (cloudflare.SSLUniversalSettingGetResponse, error) +- client.SSL.Universal.Settings.Edit(ctx context.Context, params ssl.UniversalSettingEditParams) (ssl.TLSCertificatesAndHostnamesUniversal, error) +- client.SSL.Universal.Settings.Get(ctx context.Context, query ssl.UniversalSettingGetParams) (ssl.TLSCertificatesAndHostnamesUniversal, error) ## Verification Response Types: -- cloudflare.SSLVerificationEditResponse -- cloudflare.SSLVerificationGetResponse +- ssl.TLSCertificatesAndHostnamesVerification +- ssl.VerificationEditResponse Methods: -- client.SSL.Verification.Edit(ctx context.Context, certificatePackID string, params cloudflare.SSLVerificationEditParams) (cloudflare.SSLVerificationEditResponse, error) -- client.SSL.Verification.Get(ctx context.Context, params cloudflare.SSLVerificationGetParams) ([]cloudflare.SSLVerificationGetResponse, error) +- client.SSL.Verification.Edit(ctx context.Context, certificatePackID string, params ssl.VerificationEditParams) (ssl.VerificationEditResponse, error) +- client.SSL.Verification.Get(ctx context.Context, params ssl.VerificationGetParams) ([]ssl.TLSCertificatesAndHostnamesVerification, error) # Subscriptions Response Types: -- cloudflare.SubscriptionNewResponse -- cloudflare.SubscriptionUpdateResponse -- cloudflare.SubscriptionListResponse -- cloudflare.SubscriptionDeleteResponse -- cloudflare.SubscriptionGetResponse +- subscriptions.SubscriptionNewResponse +- subscriptions.SubscriptionUpdateResponse +- subscriptions.SubscriptionListResponse +- subscriptions.SubscriptionDeleteResponse +- subscriptions.SubscriptionGetResponse Methods: -- client.Subscriptions.New(ctx context.Context, identifier string, body cloudflare.SubscriptionNewParams) (cloudflare.SubscriptionNewResponse, error) -- client.Subscriptions.Update(ctx context.Context, accountIdentifier string, subscriptionIdentifier string, body cloudflare.SubscriptionUpdateParams) (cloudflare.SubscriptionUpdateResponse, error) -- client.Subscriptions.List(ctx context.Context, accountIdentifier string) ([]cloudflare.SubscriptionListResponse, error) -- client.Subscriptions.Delete(ctx context.Context, accountIdentifier string, subscriptionIdentifier string) (cloudflare.SubscriptionDeleteResponse, error) -- client.Subscriptions.Get(ctx context.Context, identifier string) (cloudflare.SubscriptionGetResponse, error) +- client.Subscriptions.New(ctx context.Context, identifier string, body subscriptions.SubscriptionNewParams) (subscriptions.SubscriptionNewResponse, error) +- client.Subscriptions.Update(ctx context.Context, accountIdentifier string, subscriptionIdentifier string, body subscriptions.SubscriptionUpdateParams) (subscriptions.SubscriptionUpdateResponse, error) +- client.Subscriptions.List(ctx context.Context, accountIdentifier string) ([]subscriptions.SubscriptionListResponse, error) +- client.Subscriptions.Delete(ctx context.Context, accountIdentifier string, subscriptionIdentifier string) (subscriptions.SubscriptionDeleteResponse, error) +- client.Subscriptions.Get(ctx context.Context, identifier string) (subscriptions.SubscriptionGetResponse, error) # ACM @@ -1310,13 +1436,13 @@ Methods: Response Types: -- cloudflare.ACMTotalTLSNewResponse -- cloudflare.ACMTotalTLSGetResponse +- acm.TotalTLSNewResponse +- acm.TotalTLSGetResponse Methods: -- client.ACM.TotalTLS.New(ctx context.Context, params cloudflare.ACMTotalTLSNewParams) (cloudflare.ACMTotalTLSNewResponse, error) -- client.ACM.TotalTLS.Get(ctx context.Context, query cloudflare.ACMTotalTLSGetParams) (cloudflare.ACMTotalTLSGetResponse, error) +- client.ACM.TotalTLS.New(ctx context.Context, params acm.TotalTLSNewParams) (acm.TotalTLSNewResponse, error) +- client.ACM.TotalTLS.Get(ctx context.Context, query acm.TotalTLSGetParams) (acm.TotalTLSGetResponse, error) # Argo @@ -1324,47 +1450,46 @@ Methods: Response Types: -- cloudflare.ArgoSmartRoutingEditResponse -- cloudflare.ArgoSmartRoutingGetResponse +- argo.SmartRoutingEditResponse +- argo.SmartRoutingGetResponse Methods: -- client.Argo.SmartRouting.Edit(ctx context.Context, params cloudflare.ArgoSmartRoutingEditParams) (cloudflare.ArgoSmartRoutingEditResponse, error) -- client.Argo.SmartRouting.Get(ctx context.Context, query cloudflare.ArgoSmartRoutingGetParams) (cloudflare.ArgoSmartRoutingGetResponse, error) +- client.Argo.SmartRouting.Edit(ctx context.Context, params argo.SmartRoutingEditParams) (argo.SmartRoutingEditResponse, error) +- client.Argo.SmartRouting.Get(ctx context.Context, query argo.SmartRoutingGetParams) (argo.SmartRoutingGetResponse, error) ## TieredCaching Response Types: -- cloudflare.ArgoTieredCachingEditResponse -- cloudflare.ArgoTieredCachingGetResponse +- argo.TieredCachingEditResponse +- argo.TieredCachingGetResponse Methods: -- client.Argo.TieredCaching.Edit(ctx context.Context, params cloudflare.ArgoTieredCachingEditParams) (cloudflare.ArgoTieredCachingEditResponse, error) -- client.Argo.TieredCaching.Get(ctx context.Context, query cloudflare.ArgoTieredCachingGetParams) (cloudflare.ArgoTieredCachingGetResponse, error) +- client.Argo.TieredCaching.Edit(ctx context.Context, params argo.TieredCachingEditParams) (argo.TieredCachingEditResponse, error) +- client.Argo.TieredCaching.Get(ctx context.Context, query argo.TieredCachingGetParams) (argo.TieredCachingGetResponse, error) # AvailablePlans Response Types: -- cloudflare.AvailablePlanListResponse -- cloudflare.AvailablePlanGetResponse +- available_plans.BillSubsAPIAvailableRatePlan Methods: -- client.AvailablePlans.List(ctx context.Context, zoneIdentifier string) ([]cloudflare.AvailablePlanListResponse, error) -- client.AvailablePlans.Get(ctx context.Context, zoneIdentifier string, planIdentifier string) (cloudflare.AvailablePlanGetResponse, error) +- client.AvailablePlans.List(ctx context.Context, zoneIdentifier string) ([]available_plans.BillSubsAPIAvailableRatePlan, error) +- client.AvailablePlans.Get(ctx context.Context, zoneIdentifier string, planIdentifier string) (available_plans.BillSubsAPIAvailableRatePlan, error) # AvailableRatePlans Response Types: -- cloudflare.AvailableRatePlanGetResponse +- available_rate_plans.AvailableRatePlanGetResponse Methods: -- client.AvailableRatePlans.Get(ctx context.Context, zoneIdentifier string) ([]cloudflare.AvailableRatePlanGetResponse, error) +- client.AvailableRatePlans.Get(ctx context.Context, zoneIdentifier string) ([]available_rate_plans.AvailableRatePlanGetResponse, error) # CertificateAuthorities @@ -1372,108 +1497,97 @@ Methods: Response Types: -- cloudflare.CertificateAuthorityHostnameAssociationUpdateResponse -- cloudflare.CertificateAuthorityHostnameAssociationGetResponse +- certificate_authorities.TLSCertificatesAndHostnamesHostnameAssociation Methods: -- client.CertificateAuthorities.HostnameAssociations.Update(ctx context.Context, params cloudflare.CertificateAuthorityHostnameAssociationUpdateParams) (cloudflare.CertificateAuthorityHostnameAssociationUpdateResponse, error) -- client.CertificateAuthorities.HostnameAssociations.Get(ctx context.Context, params cloudflare.CertificateAuthorityHostnameAssociationGetParams) (cloudflare.CertificateAuthorityHostnameAssociationGetResponse, error) +- client.CertificateAuthorities.HostnameAssociations.Update(ctx context.Context, params certificate_authorities.HostnameAssociationUpdateParams) (certificate_authorities.TLSCertificatesAndHostnamesHostnameAssociation, error) +- client.CertificateAuthorities.HostnameAssociations.Get(ctx context.Context, params certificate_authorities.HostnameAssociationGetParams) (certificate_authorities.TLSCertificatesAndHostnamesHostnameAssociation, error) # ClientCertificates Response Types: -- cloudflare.ClientCertificateNewResponse -- cloudflare.ClientCertificateListResponse -- cloudflare.ClientCertificateDeleteResponse -- cloudflare.ClientCertificateEditResponse -- cloudflare.ClientCertificateGetResponse +- client_certificates.TLSCertificatesAndHostnamesClientCertificate Methods: -- client.ClientCertificates.New(ctx context.Context, params cloudflare.ClientCertificateNewParams) (cloudflare.ClientCertificateNewResponse, error) -- client.ClientCertificates.List(ctx context.Context, params cloudflare.ClientCertificateListParams) (shared.V4PagePaginationArray[cloudflare.ClientCertificateListResponse], error) -- client.ClientCertificates.Delete(ctx context.Context, clientCertificateID string, body cloudflare.ClientCertificateDeleteParams) (cloudflare.ClientCertificateDeleteResponse, error) -- client.ClientCertificates.Edit(ctx context.Context, clientCertificateID string, body cloudflare.ClientCertificateEditParams) (cloudflare.ClientCertificateEditResponse, error) -- client.ClientCertificates.Get(ctx context.Context, clientCertificateID string, query cloudflare.ClientCertificateGetParams) (cloudflare.ClientCertificateGetResponse, error) +- client.ClientCertificates.New(ctx context.Context, params client_certificates.ClientCertificateNewParams) (client_certificates.TLSCertificatesAndHostnamesClientCertificate, error) +- client.ClientCertificates.List(ctx context.Context, params client_certificates.ClientCertificateListParams) (shared.V4PagePaginationArray[client_certificates.TLSCertificatesAndHostnamesClientCertificate], error) +- client.ClientCertificates.Delete(ctx context.Context, clientCertificateID string, body client_certificates.ClientCertificateDeleteParams) (client_certificates.TLSCertificatesAndHostnamesClientCertificate, error) +- client.ClientCertificates.Edit(ctx context.Context, clientCertificateID string, body client_certificates.ClientCertificateEditParams) (client_certificates.TLSCertificatesAndHostnamesClientCertificate, error) +- client.ClientCertificates.Get(ctx context.Context, clientCertificateID string, query client_certificates.ClientCertificateGetParams) (client_certificates.TLSCertificatesAndHostnamesClientCertificate, error) # CustomCertificates Response Types: -- cloudflare.CustomCertificateNewResponse -- cloudflare.CustomCertificateListResponse -- cloudflare.CustomCertificateDeleteResponse -- cloudflare.CustomCertificateEditResponse -- cloudflare.CustomCertificateGetResponse +- custom_certificates.TLSCertificatesAndHostnamesCustomCertificate +- custom_certificates.CustomCertificateNewResponse +- custom_certificates.CustomCertificateDeleteResponse +- custom_certificates.CustomCertificateEditResponse +- custom_certificates.CustomCertificateGetResponse Methods: -- client.CustomCertificates.New(ctx context.Context, params cloudflare.CustomCertificateNewParams) (cloudflare.CustomCertificateNewResponse, error) -- client.CustomCertificates.List(ctx context.Context, params cloudflare.CustomCertificateListParams) (shared.V4PagePaginationArray[cloudflare.CustomCertificateListResponse], error) -- client.CustomCertificates.Delete(ctx context.Context, customCertificateID string, body cloudflare.CustomCertificateDeleteParams) (cloudflare.CustomCertificateDeleteResponse, error) -- client.CustomCertificates.Edit(ctx context.Context, customCertificateID string, params cloudflare.CustomCertificateEditParams) (cloudflare.CustomCertificateEditResponse, error) -- client.CustomCertificates.Get(ctx context.Context, customCertificateID string, query cloudflare.CustomCertificateGetParams) (cloudflare.CustomCertificateGetResponse, error) +- client.CustomCertificates.New(ctx context.Context, params custom_certificates.CustomCertificateNewParams) (custom_certificates.CustomCertificateNewResponse, error) +- client.CustomCertificates.List(ctx context.Context, params custom_certificates.CustomCertificateListParams) (shared.V4PagePaginationArray[custom_certificates.TLSCertificatesAndHostnamesCustomCertificate], error) +- client.CustomCertificates.Delete(ctx context.Context, customCertificateID string, body custom_certificates.CustomCertificateDeleteParams) (custom_certificates.CustomCertificateDeleteResponse, error) +- client.CustomCertificates.Edit(ctx context.Context, customCertificateID string, params custom_certificates.CustomCertificateEditParams) (custom_certificates.CustomCertificateEditResponse, error) +- client.CustomCertificates.Get(ctx context.Context, customCertificateID string, query custom_certificates.CustomCertificateGetParams) (custom_certificates.CustomCertificateGetResponse, error) ## Prioritize -Response Types: - -- cloudflare.CustomCertificatePrioritizeUpdateResponse - Methods: -- client.CustomCertificates.Prioritize.Update(ctx context.Context, params cloudflare.CustomCertificatePrioritizeUpdateParams) ([]cloudflare.CustomCertificatePrioritizeUpdateResponse, error) +- client.CustomCertificates.Prioritize.Update(ctx context.Context, params custom_certificates.PrioritizeUpdateParams) ([]custom_certificates.TLSCertificatesAndHostnamesCustomCertificate, error) # CustomHostnames Response Types: -- cloudflare.CustomHostnameNewResponse -- cloudflare.CustomHostnameListResponse -- cloudflare.CustomHostnameDeleteResponse -- cloudflare.CustomHostnameEditResponse -- cloudflare.CustomHostnameGetResponse +- custom_hostnames.CustomHostnameNewResponse +- custom_hostnames.CustomHostnameListResponse +- custom_hostnames.CustomHostnameDeleteResponse +- custom_hostnames.CustomHostnameEditResponse +- custom_hostnames.CustomHostnameGetResponse Methods: -- client.CustomHostnames.New(ctx context.Context, params cloudflare.CustomHostnameNewParams) (cloudflare.CustomHostnameNewResponse, error) -- client.CustomHostnames.List(ctx context.Context, params cloudflare.CustomHostnameListParams) (shared.V4PagePaginationArray[cloudflare.CustomHostnameListResponse], error) -- client.CustomHostnames.Delete(ctx context.Context, customHostnameID string, body cloudflare.CustomHostnameDeleteParams) (cloudflare.CustomHostnameDeleteResponse, error) -- client.CustomHostnames.Edit(ctx context.Context, customHostnameID string, params cloudflare.CustomHostnameEditParams) (cloudflare.CustomHostnameEditResponse, error) -- client.CustomHostnames.Get(ctx context.Context, customHostnameID string, query cloudflare.CustomHostnameGetParams) (cloudflare.CustomHostnameGetResponse, error) +- client.CustomHostnames.New(ctx context.Context, params custom_hostnames.CustomHostnameNewParams) (custom_hostnames.CustomHostnameNewResponse, error) +- client.CustomHostnames.List(ctx context.Context, params custom_hostnames.CustomHostnameListParams) (shared.V4PagePaginationArray[custom_hostnames.CustomHostnameListResponse], error) +- client.CustomHostnames.Delete(ctx context.Context, customHostnameID string, body custom_hostnames.CustomHostnameDeleteParams) (custom_hostnames.CustomHostnameDeleteResponse, error) +- client.CustomHostnames.Edit(ctx context.Context, customHostnameID string, params custom_hostnames.CustomHostnameEditParams) (custom_hostnames.CustomHostnameEditResponse, error) +- client.CustomHostnames.Get(ctx context.Context, customHostnameID string, query custom_hostnames.CustomHostnameGetParams) (custom_hostnames.CustomHostnameGetResponse, error) ## FallbackOrigin Response Types: -- cloudflare.CustomHostnameFallbackOriginUpdateResponse -- cloudflare.CustomHostnameFallbackOriginDeleteResponse -- cloudflare.CustomHostnameFallbackOriginGetResponse +- custom_hostnames.FallbackOriginUpdateResponse +- custom_hostnames.FallbackOriginDeleteResponse +- custom_hostnames.FallbackOriginGetResponse Methods: -- client.CustomHostnames.FallbackOrigin.Update(ctx context.Context, params cloudflare.CustomHostnameFallbackOriginUpdateParams) (cloudflare.CustomHostnameFallbackOriginUpdateResponse, error) -- client.CustomHostnames.FallbackOrigin.Delete(ctx context.Context, body cloudflare.CustomHostnameFallbackOriginDeleteParams) (cloudflare.CustomHostnameFallbackOriginDeleteResponse, error) -- client.CustomHostnames.FallbackOrigin.Get(ctx context.Context, query cloudflare.CustomHostnameFallbackOriginGetParams) (cloudflare.CustomHostnameFallbackOriginGetResponse, error) +- client.CustomHostnames.FallbackOrigin.Update(ctx context.Context, params custom_hostnames.FallbackOriginUpdateParams) (custom_hostnames.FallbackOriginUpdateResponse, error) +- client.CustomHostnames.FallbackOrigin.Delete(ctx context.Context, body custom_hostnames.FallbackOriginDeleteParams) (custom_hostnames.FallbackOriginDeleteResponse, error) +- client.CustomHostnames.FallbackOrigin.Get(ctx context.Context, query custom_hostnames.FallbackOriginGetParams) (custom_hostnames.FallbackOriginGetResponse, error) # CustomNameservers Response Types: -- cloudflare.CustomNameserverNewResponse -- cloudflare.CustomNameserverDeleteResponse -- cloudflare.CustomNameserverGetResponse -- cloudflare.CustomNameserverVerifyResponse +- custom_nameservers.DNSCustomNameserversCustomNS +- custom_nameservers.CustomNameserverDeleteResponse Methods: -- client.CustomNameservers.New(ctx context.Context, params cloudflare.CustomNameserverNewParams) (cloudflare.CustomNameserverNewResponse, error) -- client.CustomNameservers.Delete(ctx context.Context, customNSID string, body cloudflare.CustomNameserverDeleteParams) (cloudflare.CustomNameserverDeleteResponse, error) -- client.CustomNameservers.Availabilty(ctx context.Context, query cloudflare.CustomNameserverAvailabiltyParams) ([]string, error) -- client.CustomNameservers.Get(ctx context.Context, query cloudflare.CustomNameserverGetParams) ([]cloudflare.CustomNameserverGetResponse, error) -- client.CustomNameservers.Verify(ctx context.Context, body cloudflare.CustomNameserverVerifyParams) ([]cloudflare.CustomNameserverVerifyResponse, error) +- client.CustomNameservers.New(ctx context.Context, params custom_nameservers.CustomNameserverNewParams) (custom_nameservers.DNSCustomNameserversCustomNS, error) +- client.CustomNameservers.Delete(ctx context.Context, customNSID string, body custom_nameservers.CustomNameserverDeleteParams) (custom_nameservers.CustomNameserverDeleteResponse, error) +- client.CustomNameservers.Availabilty(ctx context.Context, query custom_nameservers.CustomNameserverAvailabiltyParams) ([]string, error) +- client.CustomNameservers.Get(ctx context.Context, query custom_nameservers.CustomNameserverGetParams) ([]custom_nameservers.DNSCustomNameserversCustomNS, error) +- client.CustomNameservers.Verify(ctx context.Context, body custom_nameservers.CustomNameserverVerifyParams) ([]custom_nameservers.DNSCustomNameserversCustomNS, error) # DNS @@ -1481,26 +1595,26 @@ Methods: Response Types: -- cloudflare.DNSRecordNewResponse -- cloudflare.DNSRecordUpdateResponse -- cloudflare.DNSRecordListResponse -- cloudflare.DNSRecordDeleteResponse -- cloudflare.DNSRecordEditResponse -- cloudflare.DNSRecordGetResponse -- cloudflare.DNSRecordImportResponse -- cloudflare.DNSRecordScanResponse +- dns.RecordNewResponse +- dns.RecordUpdateResponse +- dns.RecordListResponse +- dns.RecordDeleteResponse +- dns.RecordEditResponse +- dns.RecordGetResponse +- dns.RecordImportResponse +- dns.RecordScanResponse Methods: -- client.DNS.Records.New(ctx context.Context, params cloudflare.DNSRecordNewParams) (cloudflare.DNSRecordNewResponse, error) -- client.DNS.Records.Update(ctx context.Context, dnsRecordID string, params cloudflare.DNSRecordUpdateParams) (cloudflare.DNSRecordUpdateResponse, error) -- client.DNS.Records.List(ctx context.Context, params cloudflare.DNSRecordListParams) (shared.V4PagePaginationArray[cloudflare.DNSRecordListResponse], error) -- client.DNS.Records.Delete(ctx context.Context, dnsRecordID string, body cloudflare.DNSRecordDeleteParams) (cloudflare.DNSRecordDeleteResponse, error) -- client.DNS.Records.Edit(ctx context.Context, dnsRecordID string, params cloudflare.DNSRecordEditParams) (cloudflare.DNSRecordEditResponse, error) -- client.DNS.Records.Export(ctx context.Context, query cloudflare.DNSRecordExportParams) (string, error) -- client.DNS.Records.Get(ctx context.Context, dnsRecordID string, query cloudflare.DNSRecordGetParams) (cloudflare.DNSRecordGetResponse, error) -- client.DNS.Records.Import(ctx context.Context, params cloudflare.DNSRecordImportParams) (cloudflare.DNSRecordImportResponse, error) -- client.DNS.Records.Scan(ctx context.Context, body cloudflare.DNSRecordScanParams) (cloudflare.DNSRecordScanResponse, error) +- client.DNS.Records.New(ctx context.Context, params dns.RecordNewParams) (dns.RecordNewResponse, error) +- client.DNS.Records.Update(ctx context.Context, dnsRecordID string, params dns.RecordUpdateParams) (dns.RecordUpdateResponse, error) +- client.DNS.Records.List(ctx context.Context, params dns.RecordListParams) (shared.V4PagePaginationArray[dns.RecordListResponse], error) +- client.DNS.Records.Delete(ctx context.Context, dnsRecordID string, body dns.RecordDeleteParams) (dns.RecordDeleteResponse, error) +- client.DNS.Records.Edit(ctx context.Context, dnsRecordID string, params dns.RecordEditParams) (dns.RecordEditResponse, error) +- client.DNS.Records.Export(ctx context.Context, query dns.RecordExportParams) (string, error) +- client.DNS.Records.Get(ctx context.Context, dnsRecordID string, query dns.RecordGetParams) (dns.RecordGetResponse, error) +- client.DNS.Records.Import(ctx context.Context, params dns.RecordImportParams) (dns.RecordImportResponse, error) +- client.DNS.Records.Scan(ctx context.Context, body dns.RecordScanParams) (dns.RecordScanResponse, error) ## Analytics @@ -1508,75 +1622,63 @@ Methods: Response Types: -- cloudflare.DNSAnalyticsReportGetResponse +- dns.DNSDNSAnalyticsAPIReport Methods: -- client.DNS.Analytics.Reports.Get(ctx context.Context, identifier string, query cloudflare.DNSAnalyticsReportGetParams) (cloudflare.DNSAnalyticsReportGetResponse, error) +- client.DNS.Analytics.Reports.Get(ctx context.Context, identifier string, query dns.AnalyticsReportGetParams) (dns.DNSDNSAnalyticsAPIReport, error) #### Bytimes Response Types: -- cloudflare.DNSAnalyticsReportBytimeGetResponse +- dns.DNSDNSAnalyticsAPIReportBytime Methods: -- client.DNS.Analytics.Reports.Bytimes.Get(ctx context.Context, identifier string, query cloudflare.DNSAnalyticsReportBytimeGetParams) (cloudflare.DNSAnalyticsReportBytimeGetResponse, error) +- client.DNS.Analytics.Reports.Bytimes.Get(ctx context.Context, identifier string, query dns.AnalyticsReportBytimeGetParams) (dns.DNSDNSAnalyticsAPIReportBytime, error) ## Firewall Response Types: -- cloudflare.DNSFirewallNewResponse -- cloudflare.DNSFirewallListResponse -- cloudflare.DNSFirewallDeleteResponse -- cloudflare.DNSFirewallEditResponse -- cloudflare.DNSFirewallGetResponse +- dns.DNSFirewallDNSFirewall +- dns.FirewallDeleteResponse Methods: -- client.DNS.Firewall.New(ctx context.Context, params cloudflare.DNSFirewallNewParams) (cloudflare.DNSFirewallNewResponse, error) -- client.DNS.Firewall.List(ctx context.Context, params cloudflare.DNSFirewallListParams) (shared.V4PagePaginationArray[cloudflare.DNSFirewallListResponse], error) -- client.DNS.Firewall.Delete(ctx context.Context, dnsFirewallID string, body cloudflare.DNSFirewallDeleteParams) (cloudflare.DNSFirewallDeleteResponse, error) -- client.DNS.Firewall.Edit(ctx context.Context, dnsFirewallID string, params cloudflare.DNSFirewallEditParams) (cloudflare.DNSFirewallEditResponse, error) -- client.DNS.Firewall.Get(ctx context.Context, dnsFirewallID string, query cloudflare.DNSFirewallGetParams) (cloudflare.DNSFirewallGetResponse, error) +- client.DNS.Firewall.New(ctx context.Context, params dns.FirewallNewParams) (dns.DNSFirewallDNSFirewall, error) +- client.DNS.Firewall.List(ctx context.Context, params dns.FirewallListParams) (shared.V4PagePaginationArray[dns.DNSFirewallDNSFirewall], error) +- client.DNS.Firewall.Delete(ctx context.Context, dnsFirewallID string, body dns.FirewallDeleteParams) (dns.FirewallDeleteResponse, error) +- client.DNS.Firewall.Edit(ctx context.Context, dnsFirewallID string, params dns.FirewallEditParams) (dns.DNSFirewallDNSFirewall, error) +- client.DNS.Firewall.Get(ctx context.Context, dnsFirewallID string, query dns.FirewallGetParams) (dns.DNSFirewallDNSFirewall, error) ### Analytics #### Reports -Response Types: - -- cloudflare.DNSFirewallAnalyticsReportGetResponse - Methods: -- client.DNS.Firewall.Analytics.Reports.Get(ctx context.Context, accountIdentifier string, identifier string, query cloudflare.DNSFirewallAnalyticsReportGetParams) (cloudflare.DNSFirewallAnalyticsReportGetResponse, error) +- client.DNS.Firewall.Analytics.Reports.Get(ctx context.Context, accountIdentifier string, identifier string, query dns.FirewallAnalyticsReportGetParams) (dns.DNSDNSAnalyticsAPIReport, error) ##### Bytimes -Response Types: - -- cloudflare.DNSFirewallAnalyticsReportBytimeGetResponse - Methods: -- client.DNS.Firewall.Analytics.Reports.Bytimes.Get(ctx context.Context, accountIdentifier string, identifier string, query cloudflare.DNSFirewallAnalyticsReportBytimeGetParams) (cloudflare.DNSFirewallAnalyticsReportBytimeGetResponse, error) +- client.DNS.Firewall.Analytics.Reports.Bytimes.Get(ctx context.Context, accountIdentifier string, identifier string, query dns.FirewallAnalyticsReportBytimeGetParams) (dns.DNSDNSAnalyticsAPIReportBytime, error) # DNSSEC Response Types: -- cloudflare.DNSSECDeleteResponse -- cloudflare.DNSSECEditResponse -- cloudflare.DNSSECGetResponse +- dnssec.DNSSECDNSSEC +- dnssec.DNSSECDeleteResponse Methods: -- client.DNSSEC.Delete(ctx context.Context, body cloudflare.DNSSECDeleteParams) (cloudflare.DNSSECDeleteResponse, error) -- client.DNSSEC.Edit(ctx context.Context, params cloudflare.DNSSECEditParams) (cloudflare.DNSSECEditResponse, error) -- client.DNSSEC.Get(ctx context.Context, query cloudflare.DNSSECGetParams) (cloudflare.DNSSECGetResponse, error) +- client.DNSSEC.Delete(ctx context.Context, body dnssec.DNSSECDeleteParams) (dnssec.DNSSECDeleteResponse, error) +- client.DNSSEC.Edit(ctx context.Context, params dnssec.DNSSECEditParams) (dnssec.DNSSECDNSSEC, error) +- client.DNSSEC.Get(ctx context.Context, query dnssec.DNSSECGetParams) (dnssec.DNSSECDNSSEC, error) # EmailRouting @@ -1584,105 +1686,100 @@ Methods: Response Types: -- cloudflare.EmailRoutingRoutingGetResponse +- email_routing.RoutingGetResponse Methods: -- client.EmailRouting.Routing.Get(ctx context.Context, zoneIdentifier string) (cloudflare.EmailRoutingRoutingGetResponse, error) +- client.EmailRouting.Routing.Get(ctx context.Context, zoneIdentifier string) (email_routing.RoutingGetResponse, error) ### Disables Response Types: -- cloudflare.EmailRoutingRoutingDisableNewResponse +- email_routing.RoutingDisableNewResponse Methods: -- client.EmailRouting.Routing.Disables.New(ctx context.Context, zoneIdentifier string) (cloudflare.EmailRoutingRoutingDisableNewResponse, error) +- client.EmailRouting.Routing.Disables.New(ctx context.Context, zoneIdentifier string) (email_routing.RoutingDisableNewResponse, error) ### DNS Response Types: -- cloudflare.EmailRoutingRoutingDNSGetResponse +- email_routing.EmailDNSRecord Methods: -- client.EmailRouting.Routing.DNS.Get(ctx context.Context, zoneIdentifier string) ([]cloudflare.EmailRoutingRoutingDNSGetResponse, error) +- client.EmailRouting.Routing.DNS.Get(ctx context.Context, zoneIdentifier string) ([]email_routing.EmailDNSRecord, error) ### Enables Response Types: -- cloudflare.EmailRoutingRoutingEnableNewResponse +- email_routing.RoutingEnableNewResponse Methods: -- client.EmailRouting.Routing.Enables.New(ctx context.Context, zoneIdentifier string) (cloudflare.EmailRoutingRoutingEnableNewResponse, error) +- client.EmailRouting.Routing.Enables.New(ctx context.Context, zoneIdentifier string) (email_routing.RoutingEnableNewResponse, error) ### Rules Response Types: -- cloudflare.EmailRoutingRoutingRuleNewResponse -- cloudflare.EmailRoutingRoutingRuleUpdateResponse -- cloudflare.EmailRoutingRoutingRuleListResponse -- cloudflare.EmailRoutingRoutingRuleDeleteResponse -- cloudflare.EmailRoutingRoutingRuleGetResponse +- email_routing.RoutingRuleNewResponse +- email_routing.RoutingRuleUpdateResponse +- email_routing.RoutingRuleListResponse +- email_routing.RoutingRuleDeleteResponse +- email_routing.RoutingRuleGetResponse Methods: -- client.EmailRouting.Routing.Rules.New(ctx context.Context, zoneIdentifier string, body cloudflare.EmailRoutingRoutingRuleNewParams) (cloudflare.EmailRoutingRoutingRuleNewResponse, error) -- client.EmailRouting.Routing.Rules.Update(ctx context.Context, zoneIdentifier string, ruleIdentifier string, body cloudflare.EmailRoutingRoutingRuleUpdateParams) (cloudflare.EmailRoutingRoutingRuleUpdateResponse, error) -- client.EmailRouting.Routing.Rules.List(ctx context.Context, zoneIdentifier string, query cloudflare.EmailRoutingRoutingRuleListParams) (shared.V4PagePaginationArray[cloudflare.EmailRoutingRoutingRuleListResponse], error) -- client.EmailRouting.Routing.Rules.Delete(ctx context.Context, zoneIdentifier string, ruleIdentifier string) (cloudflare.EmailRoutingRoutingRuleDeleteResponse, error) -- client.EmailRouting.Routing.Rules.Get(ctx context.Context, zoneIdentifier string, ruleIdentifier string) (cloudflare.EmailRoutingRoutingRuleGetResponse, error) +- client.EmailRouting.Routing.Rules.New(ctx context.Context, zoneIdentifier string, body email_routing.RoutingRuleNewParams) (email_routing.RoutingRuleNewResponse, error) +- client.EmailRouting.Routing.Rules.Update(ctx context.Context, zoneIdentifier string, ruleIdentifier string, body email_routing.RoutingRuleUpdateParams) (email_routing.RoutingRuleUpdateResponse, error) +- client.EmailRouting.Routing.Rules.List(ctx context.Context, zoneIdentifier string, query email_routing.RoutingRuleListParams) (shared.V4PagePaginationArray[email_routing.RoutingRuleListResponse], error) +- client.EmailRouting.Routing.Rules.Delete(ctx context.Context, zoneIdentifier string, ruleIdentifier string) (email_routing.RoutingRuleDeleteResponse, error) +- client.EmailRouting.Routing.Rules.Get(ctx context.Context, zoneIdentifier string, ruleIdentifier string) (email_routing.RoutingRuleGetResponse, error) #### CatchAlls Response Types: -- cloudflare.EmailRoutingRoutingRuleCatchAllUpdateResponse -- cloudflare.EmailRoutingRoutingRuleCatchAllGetResponse +- email_routing.EmailCatchAllRule Methods: -- client.EmailRouting.Routing.Rules.CatchAlls.Update(ctx context.Context, zoneIdentifier string, body cloudflare.EmailRoutingRoutingRuleCatchAllUpdateParams) (cloudflare.EmailRoutingRoutingRuleCatchAllUpdateResponse, error) -- client.EmailRouting.Routing.Rules.CatchAlls.Get(ctx context.Context, zoneIdentifier string) (cloudflare.EmailRoutingRoutingRuleCatchAllGetResponse, error) +- client.EmailRouting.Routing.Rules.CatchAlls.Update(ctx context.Context, zoneIdentifier string, body email_routing.RoutingRuleCatchAllUpdateParams) (email_routing.EmailCatchAllRule, error) +- client.EmailRouting.Routing.Rules.CatchAlls.Get(ctx context.Context, zoneIdentifier string) (email_routing.EmailCatchAllRule, error) ### Addresses Response Types: -- cloudflare.EmailRoutingRoutingAddressNewResponse -- cloudflare.EmailRoutingRoutingAddressListResponse -- cloudflare.EmailRoutingRoutingAddressDeleteResponse -- cloudflare.EmailRoutingRoutingAddressGetResponse +- email_routing.RoutingAddressNewResponse +- email_routing.RoutingAddressListResponse +- email_routing.RoutingAddressDeleteResponse +- email_routing.RoutingAddressGetResponse Methods: -- client.EmailRouting.Routing.Addresses.New(ctx context.Context, accountIdentifier string, body cloudflare.EmailRoutingRoutingAddressNewParams) (cloudflare.EmailRoutingRoutingAddressNewResponse, error) -- client.EmailRouting.Routing.Addresses.List(ctx context.Context, accountIdentifier string, query cloudflare.EmailRoutingRoutingAddressListParams) (shared.V4PagePaginationArray[cloudflare.EmailRoutingRoutingAddressListResponse], error) -- client.EmailRouting.Routing.Addresses.Delete(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string) (cloudflare.EmailRoutingRoutingAddressDeleteResponse, error) -- client.EmailRouting.Routing.Addresses.Get(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string) (cloudflare.EmailRoutingRoutingAddressGetResponse, error) +- client.EmailRouting.Routing.Addresses.New(ctx context.Context, accountIdentifier string, body email_routing.RoutingAddressNewParams) (email_routing.RoutingAddressNewResponse, error) +- client.EmailRouting.Routing.Addresses.List(ctx context.Context, accountIdentifier string, query email_routing.RoutingAddressListParams) (shared.V4PagePaginationArray[email_routing.RoutingAddressListResponse], error) +- client.EmailRouting.Routing.Addresses.Delete(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string) (email_routing.RoutingAddressDeleteResponse, error) +- client.EmailRouting.Routing.Addresses.Get(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string) (email_routing.RoutingAddressGetResponse, error) # Filters Response Types: -- cloudflare.FilterNewResponse -- cloudflare.FilterUpdateResponse -- cloudflare.FilterListResponse -- cloudflare.FilterDeleteResponse -- cloudflare.FilterGetResponse +- filters.LegacyJhsFilter Methods: -- client.Filters.New(ctx context.Context, zoneIdentifier string, body cloudflare.FilterNewParams) ([]cloudflare.FilterNewResponse, error) -- client.Filters.Update(ctx context.Context, zoneIdentifier string, id string, body cloudflare.FilterUpdateParams) (cloudflare.FilterUpdateResponse, error) -- client.Filters.List(ctx context.Context, zoneIdentifier string, query cloudflare.FilterListParams) (shared.V4PagePaginationArray[cloudflare.FilterListResponse], error) -- client.Filters.Delete(ctx context.Context, zoneIdentifier string, id string) (cloudflare.FilterDeleteResponse, error) -- client.Filters.Get(ctx context.Context, zoneIdentifier string, id string) (cloudflare.FilterGetResponse, error) +- client.Filters.New(ctx context.Context, zoneIdentifier string, body filters.FilterNewParams) ([]filters.LegacyJhsFilter, error) +- client.Filters.Update(ctx context.Context, zoneIdentifier string, id string, body filters.FilterUpdateParams) (filters.LegacyJhsFilter, error) +- client.Filters.List(ctx context.Context, zoneIdentifier string, query filters.FilterListParams) (shared.V4PagePaginationArray[filters.LegacyJhsFilter], error) +- client.Filters.Delete(ctx context.Context, zoneIdentifier string, id string) (filters.LegacyJhsFilter, error) +- client.Filters.Get(ctx context.Context, zoneIdentifier string, id string) (filters.LegacyJhsFilter, error) # Firewall @@ -1690,75 +1787,67 @@ Methods: Response Types: -- cloudflare.FirewallLockdownNewResponse -- cloudflare.FirewallLockdownUpdateResponse -- cloudflare.FirewallLockdownListResponse -- cloudflare.FirewallLockdownDeleteResponse -- cloudflare.FirewallLockdownGetResponse +- firewall.LegacyJhsZonelockdown +- firewall.LockdownDeleteResponse Methods: -- client.Firewall.Lockdowns.New(ctx context.Context, zoneIdentifier string, body cloudflare.FirewallLockdownNewParams) (cloudflare.FirewallLockdownNewResponse, error) -- client.Firewall.Lockdowns.Update(ctx context.Context, zoneIdentifier string, id string, body cloudflare.FirewallLockdownUpdateParams) (cloudflare.FirewallLockdownUpdateResponse, error) -- client.Firewall.Lockdowns.List(ctx context.Context, zoneIdentifier string, query cloudflare.FirewallLockdownListParams) (shared.V4PagePaginationArray[cloudflare.FirewallLockdownListResponse], error) -- client.Firewall.Lockdowns.Delete(ctx context.Context, zoneIdentifier string, id string) (cloudflare.FirewallLockdownDeleteResponse, error) -- client.Firewall.Lockdowns.Get(ctx context.Context, zoneIdentifier string, id string) (cloudflare.FirewallLockdownGetResponse, error) +- client.Firewall.Lockdowns.New(ctx context.Context, zoneIdentifier string, body firewall.LockdownNewParams) (firewall.LegacyJhsZonelockdown, error) +- client.Firewall.Lockdowns.Update(ctx context.Context, zoneIdentifier string, id string, body firewall.LockdownUpdateParams) (firewall.LegacyJhsZonelockdown, error) +- client.Firewall.Lockdowns.List(ctx context.Context, zoneIdentifier string, query firewall.LockdownListParams) (shared.V4PagePaginationArray[firewall.LegacyJhsZonelockdown], error) +- client.Firewall.Lockdowns.Delete(ctx context.Context, zoneIdentifier string, id string) (firewall.LockdownDeleteResponse, error) +- client.Firewall.Lockdowns.Get(ctx context.Context, zoneIdentifier string, id string) (firewall.LegacyJhsZonelockdown, error) ## Rules Response Types: -- cloudflare.FirewallRuleNewResponse -- cloudflare.FirewallRuleUpdateResponse -- cloudflare.FirewallRuleListResponse -- cloudflare.FirewallRuleDeleteResponse -- cloudflare.FirewallRuleEditResponse -- cloudflare.FirewallRuleGetResponse +- firewall.LegacyJhsFilterRule Methods: -- client.Firewall.Rules.New(ctx context.Context, zoneIdentifier string, body cloudflare.FirewallRuleNewParams) ([]cloudflare.FirewallRuleNewResponse, error) -- client.Firewall.Rules.Update(ctx context.Context, zoneIdentifier string, id string, body cloudflare.FirewallRuleUpdateParams) (cloudflare.FirewallRuleUpdateResponse, error) -- client.Firewall.Rules.List(ctx context.Context, zoneIdentifier string, query cloudflare.FirewallRuleListParams) (shared.V4PagePaginationArray[cloudflare.FirewallRuleListResponse], error) -- client.Firewall.Rules.Delete(ctx context.Context, zoneIdentifier string, id string, body cloudflare.FirewallRuleDeleteParams) (cloudflare.FirewallRuleDeleteResponse, error) -- client.Firewall.Rules.Edit(ctx context.Context, zoneIdentifier string, id string, body cloudflare.FirewallRuleEditParams) ([]cloudflare.FirewallRuleEditResponse, error) -- client.Firewall.Rules.Get(ctx context.Context, zoneIdentifier string, id string, query cloudflare.FirewallRuleGetParams) (cloudflare.FirewallRuleGetResponse, error) +- client.Firewall.Rules.New(ctx context.Context, zoneIdentifier string, body firewall.RuleNewParams) ([]firewall.LegacyJhsFilterRule, error) +- client.Firewall.Rules.Update(ctx context.Context, zoneIdentifier string, id string, body firewall.RuleUpdateParams) (firewall.LegacyJhsFilterRule, error) +- client.Firewall.Rules.List(ctx context.Context, zoneIdentifier string, query firewall.RuleListParams) (shared.V4PagePaginationArray[firewall.LegacyJhsFilterRule], error) +- client.Firewall.Rules.Delete(ctx context.Context, zoneIdentifier string, id string, body firewall.RuleDeleteParams) (firewall.LegacyJhsFilterRule, error) +- client.Firewall.Rules.Edit(ctx context.Context, zoneIdentifier string, id string, body firewall.RuleEditParams) ([]firewall.LegacyJhsFilterRule, error) +- client.Firewall.Rules.Get(ctx context.Context, zoneIdentifier string, id string, query firewall.RuleGetParams) (firewall.LegacyJhsFilterRule, error) ## AccessRules Response Types: -- cloudflare.FirewallAccessRuleNewResponse -- cloudflare.FirewallAccessRuleListResponse -- cloudflare.FirewallAccessRuleDeleteResponse -- cloudflare.FirewallAccessRuleEditResponse -- cloudflare.FirewallAccessRuleGetResponse +- firewall.AccessRuleNewResponse +- firewall.AccessRuleListResponse +- firewall.AccessRuleDeleteResponse +- firewall.AccessRuleEditResponse +- firewall.AccessRuleGetResponse Methods: -- client.Firewall.AccessRules.New(ctx context.Context, params cloudflare.FirewallAccessRuleNewParams) (cloudflare.FirewallAccessRuleNewResponse, error) -- client.Firewall.AccessRules.List(ctx context.Context, params cloudflare.FirewallAccessRuleListParams) (shared.V4PagePaginationArray[cloudflare.FirewallAccessRuleListResponse], error) -- client.Firewall.AccessRules.Delete(ctx context.Context, identifier interface{}, body cloudflare.FirewallAccessRuleDeleteParams) (cloudflare.FirewallAccessRuleDeleteResponse, error) -- client.Firewall.AccessRules.Edit(ctx context.Context, identifier interface{}, params cloudflare.FirewallAccessRuleEditParams) (cloudflare.FirewallAccessRuleEditResponse, error) -- client.Firewall.AccessRules.Get(ctx context.Context, identifier interface{}, query cloudflare.FirewallAccessRuleGetParams) (cloudflare.FirewallAccessRuleGetResponse, error) +- client.Firewall.AccessRules.New(ctx context.Context, params firewall.AccessRuleNewParams) (firewall.AccessRuleNewResponse, error) +- client.Firewall.AccessRules.List(ctx context.Context, params firewall.AccessRuleListParams) (shared.V4PagePaginationArray[firewall.AccessRuleListResponse], error) +- client.Firewall.AccessRules.Delete(ctx context.Context, identifier interface{}, body firewall.AccessRuleDeleteParams) (firewall.AccessRuleDeleteResponse, error) +- client.Firewall.AccessRules.Edit(ctx context.Context, identifier interface{}, params firewall.AccessRuleEditParams) (firewall.AccessRuleEditResponse, error) +- client.Firewall.AccessRules.Get(ctx context.Context, identifier interface{}, query firewall.AccessRuleGetParams) (firewall.AccessRuleGetResponse, error) ## UARules Response Types: -- cloudflare.FirewallUARuleNewResponse -- cloudflare.FirewallUARuleUpdateResponse -- cloudflare.FirewallUARuleListResponse -- cloudflare.FirewallUARuleDeleteResponse -- cloudflare.FirewallUARuleGetResponse +- firewall.UARuleNewResponse +- firewall.UARuleUpdateResponse +- firewall.UARuleListResponse +- firewall.UARuleDeleteResponse +- firewall.UARuleGetResponse Methods: -- client.Firewall.UARules.New(ctx context.Context, zoneIdentifier string, body cloudflare.FirewallUARuleNewParams) (cloudflare.FirewallUARuleNewResponse, error) -- client.Firewall.UARules.Update(ctx context.Context, zoneIdentifier string, id string, body cloudflare.FirewallUARuleUpdateParams) (cloudflare.FirewallUARuleUpdateResponse, error) -- client.Firewall.UARules.List(ctx context.Context, zoneIdentifier string, query cloudflare.FirewallUARuleListParams) (shared.V4PagePaginationArray[cloudflare.FirewallUARuleListResponse], error) -- client.Firewall.UARules.Delete(ctx context.Context, zoneIdentifier string, id string) (cloudflare.FirewallUARuleDeleteResponse, error) -- client.Firewall.UARules.Get(ctx context.Context, zoneIdentifier string, id string) (cloudflare.FirewallUARuleGetResponse, error) +- client.Firewall.UARules.New(ctx context.Context, zoneIdentifier string, body firewall.UARuleNewParams) (firewall.UARuleNewResponse, error) +- client.Firewall.UARules.Update(ctx context.Context, zoneIdentifier string, id string, body firewall.UARuleUpdateParams) (firewall.UARuleUpdateResponse, error) +- client.Firewall.UARules.List(ctx context.Context, zoneIdentifier string, query firewall.UARuleListParams) (shared.V4PagePaginationArray[firewall.UARuleListResponse], error) +- client.Firewall.UARules.Delete(ctx context.Context, zoneIdentifier string, id string) (firewall.UARuleDeleteResponse, error) +- client.Firewall.UARules.Get(ctx context.Context, zoneIdentifier string, id string) (firewall.UARuleGetResponse, error) ## WAF @@ -1766,111 +1855,99 @@ Methods: Response Types: -- cloudflare.FirewallWAFOverrideNewResponse -- cloudflare.FirewallWAFOverrideUpdateResponse -- cloudflare.FirewallWAFOverrideListResponse -- cloudflare.FirewallWAFOverrideDeleteResponse -- cloudflare.FirewallWAFOverrideGetResponse +- firewall.LegacyJhsOverride +- firewall.WAFOverrideDeleteResponse Methods: -- client.Firewall.WAF.Overrides.New(ctx context.Context, zoneIdentifier string, body cloudflare.FirewallWAFOverrideNewParams) (cloudflare.FirewallWAFOverrideNewResponse, error) -- client.Firewall.WAF.Overrides.Update(ctx context.Context, zoneIdentifier string, id string, body cloudflare.FirewallWAFOverrideUpdateParams) (cloudflare.FirewallWAFOverrideUpdateResponse, error) -- client.Firewall.WAF.Overrides.List(ctx context.Context, zoneIdentifier string, query cloudflare.FirewallWAFOverrideListParams) (shared.V4PagePaginationArray[cloudflare.FirewallWAFOverrideListResponse], error) -- client.Firewall.WAF.Overrides.Delete(ctx context.Context, zoneIdentifier string, id string) (cloudflare.FirewallWAFOverrideDeleteResponse, error) -- client.Firewall.WAF.Overrides.Get(ctx context.Context, zoneIdentifier string, id string) (cloudflare.FirewallWAFOverrideGetResponse, error) +- client.Firewall.WAF.Overrides.New(ctx context.Context, zoneIdentifier string, body firewall.WAFOverrideNewParams) (firewall.LegacyJhsOverride, error) +- client.Firewall.WAF.Overrides.Update(ctx context.Context, zoneIdentifier string, id string, body firewall.WAFOverrideUpdateParams) (firewall.LegacyJhsOverride, error) +- client.Firewall.WAF.Overrides.List(ctx context.Context, zoneIdentifier string, query firewall.WAFOverrideListParams) (shared.V4PagePaginationArray[firewall.LegacyJhsOverride], error) +- client.Firewall.WAF.Overrides.Delete(ctx context.Context, zoneIdentifier string, id string) (firewall.WAFOverrideDeleteResponse, error) +- client.Firewall.WAF.Overrides.Get(ctx context.Context, zoneIdentifier string, id string) (firewall.LegacyJhsOverride, error) ### Packages Response Types: -- cloudflare.FirewallWAFPackageListResponse -- cloudflare.FirewallWAFPackageGetResponse +- firewall.WAFPackageListResponse +- firewall.WAFPackageGetResponse Methods: -- client.Firewall.WAF.Packages.List(ctx context.Context, zoneIdentifier string, query cloudflare.FirewallWAFPackageListParams) (shared.V4PagePaginationArray[cloudflare.FirewallWAFPackageListResponse], error) -- client.Firewall.WAF.Packages.Get(ctx context.Context, zoneIdentifier string, identifier string) (cloudflare.FirewallWAFPackageGetResponse, error) +- client.Firewall.WAF.Packages.List(ctx context.Context, zoneIdentifier string, query firewall.WAFPackageListParams) (shared.V4PagePaginationArray[firewall.WAFPackageListResponse], error) +- client.Firewall.WAF.Packages.Get(ctx context.Context, zoneIdentifier string, identifier string) (firewall.WAFPackageGetResponse, error) #### Groups Response Types: -- cloudflare.FirewallWAFPackageGroupListResponse -- cloudflare.FirewallWAFPackageGroupEditResponse -- cloudflare.FirewallWAFPackageGroupGetResponse +- firewall.WAFManagedRulesSchemasGroup +- firewall.WAFPackageGroupEditResponse +- firewall.WAFPackageGroupGetResponse Methods: -- client.Firewall.WAF.Packages.Groups.List(ctx context.Context, packageID string, params cloudflare.FirewallWAFPackageGroupListParams) (shared.V4PagePaginationArray[cloudflare.FirewallWAFPackageGroupListResponse], error) -- client.Firewall.WAF.Packages.Groups.Edit(ctx context.Context, packageID string, groupID string, params cloudflare.FirewallWAFPackageGroupEditParams) (cloudflare.FirewallWAFPackageGroupEditResponse, error) -- client.Firewall.WAF.Packages.Groups.Get(ctx context.Context, packageID string, groupID string, query cloudflare.FirewallWAFPackageGroupGetParams) (cloudflare.FirewallWAFPackageGroupGetResponse, error) +- client.Firewall.WAF.Packages.Groups.List(ctx context.Context, packageID string, params firewall.WAFPackageGroupListParams) (shared.V4PagePaginationArray[firewall.WAFManagedRulesSchemasGroup], error) +- client.Firewall.WAF.Packages.Groups.Edit(ctx context.Context, packageID string, groupID string, params firewall.WAFPackageGroupEditParams) (firewall.WAFPackageGroupEditResponse, error) +- client.Firewall.WAF.Packages.Groups.Get(ctx context.Context, packageID string, groupID string, query firewall.WAFPackageGroupGetParams) (firewall.WAFPackageGroupGetResponse, error) #### Rules Response Types: -- cloudflare.FirewallWAFPackageRuleListResponse -- cloudflare.FirewallWAFPackageRuleEditResponse -- cloudflare.FirewallWAFPackageRuleGetResponse +- firewall.WAFManagedRulesRule +- firewall.WAFPackageRuleEditResponse +- firewall.WAFPackageRuleGetResponse Methods: -- client.Firewall.WAF.Packages.Rules.List(ctx context.Context, packageID string, params cloudflare.FirewallWAFPackageRuleListParams) (shared.V4PagePaginationArray[cloudflare.FirewallWAFPackageRuleListResponse], error) -- client.Firewall.WAF.Packages.Rules.Edit(ctx context.Context, packageID string, ruleID string, params cloudflare.FirewallWAFPackageRuleEditParams) (cloudflare.FirewallWAFPackageRuleEditResponse, error) -- client.Firewall.WAF.Packages.Rules.Get(ctx context.Context, packageID string, ruleID string, query cloudflare.FirewallWAFPackageRuleGetParams) (cloudflare.FirewallWAFPackageRuleGetResponse, error) +- client.Firewall.WAF.Packages.Rules.List(ctx context.Context, packageID string, params firewall.WAFPackageRuleListParams) (shared.V4PagePaginationArray[firewall.WAFManagedRulesRule], error) +- client.Firewall.WAF.Packages.Rules.Edit(ctx context.Context, packageID string, ruleID string, params firewall.WAFPackageRuleEditParams) (firewall.WAFPackageRuleEditResponse, error) +- client.Firewall.WAF.Packages.Rules.Get(ctx context.Context, packageID string, ruleID string, query firewall.WAFPackageRuleGetParams) (firewall.WAFPackageRuleGetResponse, error) # Healthchecks Response Types: -- cloudflare.HealthcheckNewResponse -- cloudflare.HealthcheckUpdateResponse -- cloudflare.HealthcheckListResponse -- cloudflare.HealthcheckDeleteResponse -- cloudflare.HealthcheckEditResponse -- cloudflare.HealthcheckGetResponse +- healthchecks.HealthchecksHealthchecks +- healthchecks.HealthcheckDeleteResponse Methods: -- client.Healthchecks.New(ctx context.Context, zoneIdentifier string, body cloudflare.HealthcheckNewParams) (cloudflare.HealthcheckNewResponse, error) -- client.Healthchecks.Update(ctx context.Context, zoneIdentifier string, identifier string, body cloudflare.HealthcheckUpdateParams) (cloudflare.HealthcheckUpdateResponse, error) -- client.Healthchecks.List(ctx context.Context, zoneIdentifier string) ([]cloudflare.HealthcheckListResponse, error) -- client.Healthchecks.Delete(ctx context.Context, zoneIdentifier string, identifier string) (cloudflare.HealthcheckDeleteResponse, error) -- client.Healthchecks.Edit(ctx context.Context, zoneIdentifier string, identifier string, body cloudflare.HealthcheckEditParams) (cloudflare.HealthcheckEditResponse, error) -- client.Healthchecks.Get(ctx context.Context, zoneIdentifier string, identifier string) (cloudflare.HealthcheckGetResponse, error) +- client.Healthchecks.New(ctx context.Context, zoneIdentifier string, body healthchecks.HealthcheckNewParams) (healthchecks.HealthchecksHealthchecks, error) +- client.Healthchecks.Update(ctx context.Context, zoneIdentifier string, identifier string, body healthchecks.HealthcheckUpdateParams) (healthchecks.HealthchecksHealthchecks, error) +- client.Healthchecks.List(ctx context.Context, zoneIdentifier string) ([]healthchecks.HealthchecksHealthchecks, error) +- client.Healthchecks.Delete(ctx context.Context, zoneIdentifier string, identifier string) (healthchecks.HealthcheckDeleteResponse, error) +- client.Healthchecks.Edit(ctx context.Context, zoneIdentifier string, identifier string, body healthchecks.HealthcheckEditParams) (healthchecks.HealthchecksHealthchecks, error) +- client.Healthchecks.Get(ctx context.Context, zoneIdentifier string, identifier string) (healthchecks.HealthchecksHealthchecks, error) ## Previews Response Types: -- cloudflare.HealthcheckPreviewNewResponse -- cloudflare.HealthcheckPreviewDeleteResponse -- cloudflare.HealthcheckPreviewGetResponse +- healthchecks.PreviewDeleteResponse Methods: -- client.Healthchecks.Previews.New(ctx context.Context, zoneIdentifier string, body cloudflare.HealthcheckPreviewNewParams) (cloudflare.HealthcheckPreviewNewResponse, error) -- client.Healthchecks.Previews.Delete(ctx context.Context, zoneIdentifier string, identifier string) (cloudflare.HealthcheckPreviewDeleteResponse, error) -- client.Healthchecks.Previews.Get(ctx context.Context, zoneIdentifier string, identifier string) (cloudflare.HealthcheckPreviewGetResponse, error) +- client.Healthchecks.Previews.New(ctx context.Context, zoneIdentifier string, body healthchecks.PreviewNewParams) (healthchecks.HealthchecksHealthchecks, error) +- client.Healthchecks.Previews.Delete(ctx context.Context, zoneIdentifier string, identifier string) (healthchecks.PreviewDeleteResponse, error) +- client.Healthchecks.Previews.Get(ctx context.Context, zoneIdentifier string, identifier string) (healthchecks.HealthchecksHealthchecks, error) # KeylessCertificates Response Types: -- cloudflare.KeylessCertificateNewResponse -- cloudflare.KeylessCertificateListResponse -- cloudflare.KeylessCertificateDeleteResponse -- cloudflare.KeylessCertificateEditResponse -- cloudflare.KeylessCertificateGetResponse +- keyless_certificates.TLSCertificatesAndHostnamesBase +- keyless_certificates.KeylessCertificateDeleteResponse Methods: -- client.KeylessCertificates.New(ctx context.Context, params cloudflare.KeylessCertificateNewParams) (cloudflare.KeylessCertificateNewResponse, error) -- client.KeylessCertificates.List(ctx context.Context, query cloudflare.KeylessCertificateListParams) ([]cloudflare.KeylessCertificateListResponse, error) -- client.KeylessCertificates.Delete(ctx context.Context, keylessCertificateID string, body cloudflare.KeylessCertificateDeleteParams) (cloudflare.KeylessCertificateDeleteResponse, error) -- client.KeylessCertificates.Edit(ctx context.Context, keylessCertificateID string, params cloudflare.KeylessCertificateEditParams) (cloudflare.KeylessCertificateEditResponse, error) -- client.KeylessCertificates.Get(ctx context.Context, keylessCertificateID string, query cloudflare.KeylessCertificateGetParams) (cloudflare.KeylessCertificateGetResponse, error) +- client.KeylessCertificates.New(ctx context.Context, params keyless_certificates.KeylessCertificateNewParams) (keyless_certificates.TLSCertificatesAndHostnamesBase, error) +- client.KeylessCertificates.List(ctx context.Context, query keyless_certificates.KeylessCertificateListParams) ([]keyless_certificates.TLSCertificatesAndHostnamesBase, error) +- client.KeylessCertificates.Delete(ctx context.Context, keylessCertificateID string, body keyless_certificates.KeylessCertificateDeleteParams) (keyless_certificates.KeylessCertificateDeleteResponse, error) +- client.KeylessCertificates.Edit(ctx context.Context, keylessCertificateID string, params keyless_certificates.KeylessCertificateEditParams) (keyless_certificates.TLSCertificatesAndHostnamesBase, error) +- client.KeylessCertificates.Get(ctx context.Context, keylessCertificateID string, query keyless_certificates.KeylessCertificateGetParams) (keyless_certificates.TLSCertificatesAndHostnamesBase, error) # Logpush @@ -1880,75 +1957,70 @@ Methods: Response Types: -- cloudflare.LogpushDatasetFieldGetResponse +- logpush.DatasetFieldGetResponse Methods: -- client.Logpush.Datasets.Fields.Get(ctx context.Context, datasetID string, query cloudflare.LogpushDatasetFieldGetParams) (cloudflare.LogpushDatasetFieldGetResponse, error) +- client.Logpush.Datasets.Fields.Get(ctx context.Context, datasetID string, query logpush.DatasetFieldGetParams) (logpush.DatasetFieldGetResponse, error) ### Jobs Response Types: -- cloudflare.LogpushDatasetJobGetResponse +- logpush.LogpushLogpushJob Methods: -- client.Logpush.Datasets.Jobs.Get(ctx context.Context, datasetID string, query cloudflare.LogpushDatasetJobGetParams) ([]cloudflare.LogpushDatasetJobGetResponse, error) +- client.Logpush.Datasets.Jobs.Get(ctx context.Context, datasetID string, query logpush.DatasetJobGetParams) ([]logpush.LogpushLogpushJob, error) ## Edge Response Types: -- cloudflare.LogpushEdgeNewResponse -- cloudflare.LogpushEdgeGetResponse +- logpush.LogpushInstantLogsJob Methods: -- client.Logpush.Edge.New(ctx context.Context, params cloudflare.LogpushEdgeNewParams) (cloudflare.LogpushEdgeNewResponse, error) -- client.Logpush.Edge.Get(ctx context.Context, query cloudflare.LogpushEdgeGetParams) ([]cloudflare.LogpushEdgeGetResponse, error) +- client.Logpush.Edge.New(ctx context.Context, params logpush.EdgeNewParams) (logpush.LogpushInstantLogsJob, error) +- client.Logpush.Edge.Get(ctx context.Context, query logpush.EdgeGetParams) ([]logpush.LogpushInstantLogsJob, error) ## Jobs Response Types: -- cloudflare.LogpushJobNewResponse -- cloudflare.LogpushJobUpdateResponse -- cloudflare.LogpushJobListResponse -- cloudflare.LogpushJobDeleteResponse -- cloudflare.LogpushJobGetResponse +- logpush.JobDeleteResponse Methods: -- client.Logpush.Jobs.New(ctx context.Context, params cloudflare.LogpushJobNewParams) (cloudflare.LogpushJobNewResponse, error) -- client.Logpush.Jobs.Update(ctx context.Context, jobID int64, params cloudflare.LogpushJobUpdateParams) (cloudflare.LogpushJobUpdateResponse, error) -- client.Logpush.Jobs.List(ctx context.Context, query cloudflare.LogpushJobListParams) ([]cloudflare.LogpushJobListResponse, error) -- client.Logpush.Jobs.Delete(ctx context.Context, jobID int64, body cloudflare.LogpushJobDeleteParams) (cloudflare.LogpushJobDeleteResponse, error) -- client.Logpush.Jobs.Get(ctx context.Context, jobID int64, query cloudflare.LogpushJobGetParams) (cloudflare.LogpushJobGetResponse, error) +- client.Logpush.Jobs.New(ctx context.Context, params logpush.JobNewParams) (logpush.LogpushLogpushJob, error) +- client.Logpush.Jobs.Update(ctx context.Context, jobID int64, params logpush.JobUpdateParams) (logpush.LogpushLogpushJob, error) +- client.Logpush.Jobs.List(ctx context.Context, query logpush.JobListParams) ([]logpush.LogpushLogpushJob, error) +- client.Logpush.Jobs.Delete(ctx context.Context, jobID int64, body logpush.JobDeleteParams) (logpush.JobDeleteResponse, error) +- client.Logpush.Jobs.Get(ctx context.Context, jobID int64, query logpush.JobGetParams) (logpush.LogpushLogpushJob, error) ## Ownership Response Types: -- cloudflare.LogpushOwnershipNewResponse -- cloudflare.LogpushOwnershipValidateResponse +- logpush.OwnershipNewResponse +- logpush.OwnershipValidateResponse Methods: -- client.Logpush.Ownership.New(ctx context.Context, params cloudflare.LogpushOwnershipNewParams) (cloudflare.LogpushOwnershipNewResponse, error) -- client.Logpush.Ownership.Validate(ctx context.Context, params cloudflare.LogpushOwnershipValidateParams) (cloudflare.LogpushOwnershipValidateResponse, error) +- client.Logpush.Ownership.New(ctx context.Context, params logpush.OwnershipNewParams) (logpush.OwnershipNewResponse, error) +- client.Logpush.Ownership.Validate(ctx context.Context, params logpush.OwnershipValidateParams) (logpush.OwnershipValidateResponse, error) ## Validate Response Types: -- cloudflare.LogpushValidateDestinationResponse -- cloudflare.LogpushValidateOriginResponse +- logpush.ValidateDestinationResponse +- logpush.ValidateOriginResponse Methods: -- client.Logpush.Validate.Destination(ctx context.Context, params cloudflare.LogpushValidateDestinationParams) (cloudflare.LogpushValidateDestinationResponse, error) -- client.Logpush.Validate.Origin(ctx context.Context, params cloudflare.LogpushValidateOriginParams) (cloudflare.LogpushValidateOriginResponse, error) +- client.Logpush.Validate.Destination(ctx context.Context, params logpush.ValidateDestinationParams) (logpush.ValidateDestinationResponse, error) +- client.Logpush.Validate.Origin(ctx context.Context, params logpush.ValidateOriginParams) (logpush.ValidateOriginResponse, error) # Logs @@ -1960,13 +2032,13 @@ Methods: Response Types: -- cloudflare.LogControlRetentionFlagNewResponse -- cloudflare.LogControlRetentionFlagGetResponse +- logs.ControlRetentionFlagNewResponse +- logs.ControlRetentionFlagGetResponse Methods: -- client.Logs.Control.Retention.Flag.New(ctx context.Context, zoneIdentifier string, body cloudflare.LogControlRetentionFlagNewParams) (cloudflare.LogControlRetentionFlagNewResponse, error) -- client.Logs.Control.Retention.Flag.Get(ctx context.Context, zoneIdentifier string) (cloudflare.LogControlRetentionFlagGetResponse, error) +- client.Logs.Control.Retention.Flag.New(ctx context.Context, zoneIdentifier string, body logs.ControlRetentionFlagNewParams) (logs.ControlRetentionFlagNewResponse, error) +- client.Logs.Control.Retention.Flag.Get(ctx context.Context, zoneIdentifier string) (logs.ControlRetentionFlagGetResponse, error) ### Cmb @@ -1974,346 +2046,328 @@ Methods: Response Types: -- cloudflare.LogControlCmbConfigNewResponse -- cloudflare.LogControlCmbConfigDeleteResponse -- cloudflare.LogControlCmbConfigGetResponse +- logs.LogcontrolCmbConfig +- logs.ControlCmbConfigDeleteResponse Methods: -- client.Logs.Control.Cmb.Config.New(ctx context.Context, params cloudflare.LogControlCmbConfigNewParams) (cloudflare.LogControlCmbConfigNewResponse, error) -- client.Logs.Control.Cmb.Config.Delete(ctx context.Context, body cloudflare.LogControlCmbConfigDeleteParams) (cloudflare.LogControlCmbConfigDeleteResponse, error) -- client.Logs.Control.Cmb.Config.Get(ctx context.Context, query cloudflare.LogControlCmbConfigGetParams) (cloudflare.LogControlCmbConfigGetResponse, error) +- client.Logs.Control.Cmb.Config.New(ctx context.Context, params logs.ControlCmbConfigNewParams) (logs.LogcontrolCmbConfig, error) +- client.Logs.Control.Cmb.Config.Delete(ctx context.Context, body logs.ControlCmbConfigDeleteParams) (logs.ControlCmbConfigDeleteResponse, error) +- client.Logs.Control.Cmb.Config.Get(ctx context.Context, query logs.ControlCmbConfigGetParams) (logs.LogcontrolCmbConfig, error) ## Rayid Response Types: -- cloudflare.LogRayidGetResponse +- logs.RayidGetResponse Methods: -- client.Logs.Rayid.Get(ctx context.Context, zoneIdentifier string, rayIdentifier string, query cloudflare.LogRayidGetParams) (cloudflare.LogRayidGetResponse, error) +- client.Logs.Rayid.Get(ctx context.Context, zoneIdentifier string, rayIdentifier string, query logs.RayidGetParams) (logs.RayidGetResponse, error) ## Received Response Types: -- cloudflare.LogReceivedGetResponse +- logs.ReceivedGetResponse Methods: -- client.Logs.Received.Get(ctx context.Context, zoneIdentifier string, query cloudflare.LogReceivedGetParams) (cloudflare.LogReceivedGetResponse, error) +- client.Logs.Received.Get(ctx context.Context, zoneIdentifier string, query logs.ReceivedGetParams) (logs.ReceivedGetResponse, error) ### Fields Response Types: -- cloudflare.LogReceivedFieldGetResponse +- logs.ReceivedFieldGetResponse Methods: -- client.Logs.Received.Fields.Get(ctx context.Context, zoneIdentifier string) (cloudflare.LogReceivedFieldGetResponse, error) +- client.Logs.Received.Fields.Get(ctx context.Context, zoneIdentifier string) (logs.ReceivedFieldGetResponse, error) # OriginTLSClientAuth Response Types: -- cloudflare.OriginTLSClientAuthNewResponse -- cloudflare.OriginTLSClientAuthListResponse -- cloudflare.OriginTLSClientAuthDeleteResponse -- cloudflare.OriginTLSClientAuthGetResponse +- origin_tls_client_auth.OriginTLSClientAuthNewResponse +- origin_tls_client_auth.OriginTLSClientAuthListResponse +- origin_tls_client_auth.OriginTLSClientAuthDeleteResponse +- origin_tls_client_auth.OriginTLSClientAuthGetResponse Methods: -- client.OriginTLSClientAuth.New(ctx context.Context, params cloudflare.OriginTLSClientAuthNewParams) (cloudflare.OriginTLSClientAuthNewResponse, error) -- client.OriginTLSClientAuth.List(ctx context.Context, query cloudflare.OriginTLSClientAuthListParams) ([]cloudflare.OriginTLSClientAuthListResponse, error) -- client.OriginTLSClientAuth.Delete(ctx context.Context, certificateID string, body cloudflare.OriginTLSClientAuthDeleteParams) (cloudflare.OriginTLSClientAuthDeleteResponse, error) -- client.OriginTLSClientAuth.Get(ctx context.Context, certificateID string, query cloudflare.OriginTLSClientAuthGetParams) (cloudflare.OriginTLSClientAuthGetResponse, error) +- client.OriginTLSClientAuth.New(ctx context.Context, params origin_tls_client_auth.OriginTLSClientAuthNewParams) (origin_tls_client_auth.OriginTLSClientAuthNewResponse, error) +- client.OriginTLSClientAuth.List(ctx context.Context, query origin_tls_client_auth.OriginTLSClientAuthListParams) ([]origin_tls_client_auth.OriginTLSClientAuthListResponse, error) +- client.OriginTLSClientAuth.Delete(ctx context.Context, certificateID string, body origin_tls_client_auth.OriginTLSClientAuthDeleteParams) (origin_tls_client_auth.OriginTLSClientAuthDeleteResponse, error) +- client.OriginTLSClientAuth.Get(ctx context.Context, certificateID string, query origin_tls_client_auth.OriginTLSClientAuthGetParams) (origin_tls_client_auth.OriginTLSClientAuthGetResponse, error) ## Hostnames Response Types: -- cloudflare.OriginTLSClientAuthHostnameUpdateResponse -- cloudflare.OriginTLSClientAuthHostnameGetResponse +- origin_tls_client_auth.TLSCertificatesAndHostnamesHostnameCertidObject Methods: -- client.OriginTLSClientAuth.Hostnames.Update(ctx context.Context, params cloudflare.OriginTLSClientAuthHostnameUpdateParams) ([]cloudflare.OriginTLSClientAuthHostnameUpdateResponse, error) -- client.OriginTLSClientAuth.Hostnames.Get(ctx context.Context, hostname string, query cloudflare.OriginTLSClientAuthHostnameGetParams) (cloudflare.OriginTLSClientAuthHostnameGetResponse, error) +- client.OriginTLSClientAuth.Hostnames.Update(ctx context.Context, params origin_tls_client_auth.HostnameUpdateParams) ([]origin_tls_client_auth.TLSCertificatesAndHostnamesHostnameCertidObject, error) +- client.OriginTLSClientAuth.Hostnames.Get(ctx context.Context, hostname string, query origin_tls_client_auth.HostnameGetParams) (origin_tls_client_auth.TLSCertificatesAndHostnamesHostnameCertidObject, error) ### Certificates Response Types: -- cloudflare.OriginTLSClientAuthHostnameCertificateNewResponse -- cloudflare.OriginTLSClientAuthHostnameCertificateListResponse -- cloudflare.OriginTLSClientAuthHostnameCertificateDeleteResponse -- cloudflare.OriginTLSClientAuthHostnameCertificateGetResponse +- origin_tls_client_auth.TLSCertificatesAndHostnamesSchemasCertificateObject Methods: -- client.OriginTLSClientAuth.Hostnames.Certificates.New(ctx context.Context, params cloudflare.OriginTLSClientAuthHostnameCertificateNewParams) (cloudflare.OriginTLSClientAuthHostnameCertificateNewResponse, error) -- client.OriginTLSClientAuth.Hostnames.Certificates.List(ctx context.Context, query cloudflare.OriginTLSClientAuthHostnameCertificateListParams) ([]cloudflare.OriginTLSClientAuthHostnameCertificateListResponse, error) -- client.OriginTLSClientAuth.Hostnames.Certificates.Delete(ctx context.Context, certificateID string, body cloudflare.OriginTLSClientAuthHostnameCertificateDeleteParams) (cloudflare.OriginTLSClientAuthHostnameCertificateDeleteResponse, error) -- client.OriginTLSClientAuth.Hostnames.Certificates.Get(ctx context.Context, certificateID string, query cloudflare.OriginTLSClientAuthHostnameCertificateGetParams) (cloudflare.OriginTLSClientAuthHostnameCertificateGetResponse, error) +- client.OriginTLSClientAuth.Hostnames.Certificates.New(ctx context.Context, params origin_tls_client_auth.HostnameCertificateNewParams) (origin_tls_client_auth.TLSCertificatesAndHostnamesSchemasCertificateObject, error) +- client.OriginTLSClientAuth.Hostnames.Certificates.List(ctx context.Context, query origin_tls_client_auth.HostnameCertificateListParams) ([]origin_tls_client_auth.TLSCertificatesAndHostnamesHostnameCertidObject, error) +- client.OriginTLSClientAuth.Hostnames.Certificates.Delete(ctx context.Context, certificateID string, body origin_tls_client_auth.HostnameCertificateDeleteParams) (origin_tls_client_auth.TLSCertificatesAndHostnamesSchemasCertificateObject, error) +- client.OriginTLSClientAuth.Hostnames.Certificates.Get(ctx context.Context, certificateID string, query origin_tls_client_auth.HostnameCertificateGetParams) (origin_tls_client_auth.TLSCertificatesAndHostnamesSchemasCertificateObject, error) ## Settings Response Types: -- cloudflare.OriginTLSClientAuthSettingUpdateResponse -- cloudflare.OriginTLSClientAuthSettingGetResponse +- origin_tls_client_auth.SettingUpdateResponse +- origin_tls_client_auth.SettingGetResponse Methods: -- client.OriginTLSClientAuth.Settings.Update(ctx context.Context, params cloudflare.OriginTLSClientAuthSettingUpdateParams) (cloudflare.OriginTLSClientAuthSettingUpdateResponse, error) -- client.OriginTLSClientAuth.Settings.Get(ctx context.Context, query cloudflare.OriginTLSClientAuthSettingGetParams) (cloudflare.OriginTLSClientAuthSettingGetResponse, error) +- client.OriginTLSClientAuth.Settings.Update(ctx context.Context, params origin_tls_client_auth.SettingUpdateParams) (origin_tls_client_auth.SettingUpdateResponse, error) +- client.OriginTLSClientAuth.Settings.Get(ctx context.Context, query origin_tls_client_auth.SettingGetParams) (origin_tls_client_auth.SettingGetResponse, error) # Pagerules Response Types: -- cloudflare.PageruleNewResponse -- cloudflare.PageruleUpdateResponse -- cloudflare.PageruleListResponse -- cloudflare.PageruleDeleteResponse -- cloudflare.PageruleEditResponse -- cloudflare.PageruleGetResponse +- pagerules.ZonesPageRule +- pagerules.PageruleNewResponse +- pagerules.PageruleUpdateResponse +- pagerules.PageruleDeleteResponse +- pagerules.PageruleEditResponse +- pagerules.PageruleGetResponse Methods: -- client.Pagerules.New(ctx context.Context, params cloudflare.PageruleNewParams) (cloudflare.PageruleNewResponse, error) -- client.Pagerules.Update(ctx context.Context, pageruleID string, params cloudflare.PageruleUpdateParams) (cloudflare.PageruleUpdateResponse, error) -- client.Pagerules.List(ctx context.Context, params cloudflare.PageruleListParams) ([]cloudflare.PageruleListResponse, error) -- client.Pagerules.Delete(ctx context.Context, pageruleID string, body cloudflare.PageruleDeleteParams) (cloudflare.PageruleDeleteResponse, error) -- client.Pagerules.Edit(ctx context.Context, pageruleID string, params cloudflare.PageruleEditParams) (cloudflare.PageruleEditResponse, error) -- client.Pagerules.Get(ctx context.Context, pageruleID string, query cloudflare.PageruleGetParams) (cloudflare.PageruleGetResponse, error) +- client.Pagerules.New(ctx context.Context, params pagerules.PageruleNewParams) (pagerules.PageruleNewResponse, error) +- client.Pagerules.Update(ctx context.Context, pageruleID string, params pagerules.PageruleUpdateParams) (pagerules.PageruleUpdateResponse, error) +- client.Pagerules.List(ctx context.Context, params pagerules.PageruleListParams) ([]pagerules.ZonesPageRule, error) +- client.Pagerules.Delete(ctx context.Context, pageruleID string, body pagerules.PageruleDeleteParams) (pagerules.PageruleDeleteResponse, error) +- client.Pagerules.Edit(ctx context.Context, pageruleID string, params pagerules.PageruleEditParams) (pagerules.PageruleEditResponse, error) +- client.Pagerules.Get(ctx context.Context, pageruleID string, query pagerules.PageruleGetParams) (pagerules.PageruleGetResponse, error) ## Settings Response Types: -- cloudflare.PageruleSettingListResponse +- pagerules.ZonesSettings +- pagerules.SettingListResponse Methods: -- client.Pagerules.Settings.List(ctx context.Context, query cloudflare.PageruleSettingListParams) ([]cloudflare.PageruleSettingListResponse, error) +- client.Pagerules.Settings.List(ctx context.Context, query pagerules.SettingListParams) (pagerules.ZonesSettings, error) # RateLimits Response Types: -- cloudflare.RateLimitNewResponse -- cloudflare.RateLimitListResponse -- cloudflare.RateLimitDeleteResponse -- cloudflare.RateLimitEditResponse -- cloudflare.RateLimitGetResponse +- rate_limits.RateLimitNewResponse +- rate_limits.RateLimitListResponse +- rate_limits.RateLimitDeleteResponse +- rate_limits.RateLimitEditResponse +- rate_limits.RateLimitGetResponse Methods: -- client.RateLimits.New(ctx context.Context, zoneIdentifier string, body cloudflare.RateLimitNewParams) (cloudflare.RateLimitNewResponse, error) -- client.RateLimits.List(ctx context.Context, zoneIdentifier string, query cloudflare.RateLimitListParams) (shared.V4PagePaginationArray[cloudflare.RateLimitListResponse], error) -- client.RateLimits.Delete(ctx context.Context, zoneIdentifier string, id string) (cloudflare.RateLimitDeleteResponse, error) -- client.RateLimits.Edit(ctx context.Context, zoneIdentifier string, id string, body cloudflare.RateLimitEditParams) (cloudflare.RateLimitEditResponse, error) -- client.RateLimits.Get(ctx context.Context, zoneIdentifier string, id string) (cloudflare.RateLimitGetResponse, error) +- client.RateLimits.New(ctx context.Context, zoneIdentifier string, body rate_limits.RateLimitNewParams) (rate_limits.RateLimitNewResponse, error) +- client.RateLimits.List(ctx context.Context, zoneIdentifier string, query rate_limits.RateLimitListParams) (shared.V4PagePaginationArray[rate_limits.RateLimitListResponse], error) +- client.RateLimits.Delete(ctx context.Context, zoneIdentifier string, id string) (rate_limits.RateLimitDeleteResponse, error) +- client.RateLimits.Edit(ctx context.Context, zoneIdentifier string, id string, body rate_limits.RateLimitEditParams) (rate_limits.RateLimitEditResponse, error) +- client.RateLimits.Get(ctx context.Context, zoneIdentifier string, id string) (rate_limits.RateLimitGetResponse, error) # SecondaryDNS ## ForceAxfrs +Response Types: + +- secondary_dns.SecondaryDNSForceResult + Methods: -- client.SecondaryDNS.ForceAxfrs.New(ctx context.Context, body cloudflare.SecondaryDNSForceAxfrNewParams) (string, error) +- client.SecondaryDNS.ForceAxfrs.New(ctx context.Context, body secondary_dns.ForceAxfrNewParams) (secondary_dns.SecondaryDNSForceResult, error) ## Incoming Response Types: -- cloudflare.SecondaryDNSIncomingNewResponse -- cloudflare.SecondaryDNSIncomingUpdateResponse -- cloudflare.SecondaryDNSIncomingDeleteResponse -- cloudflare.SecondaryDNSIncomingGetResponse +- secondary_dns.IncomingNewResponse +- secondary_dns.IncomingUpdateResponse +- secondary_dns.IncomingDeleteResponse +- secondary_dns.IncomingGetResponse Methods: -- client.SecondaryDNS.Incoming.New(ctx context.Context, params cloudflare.SecondaryDNSIncomingNewParams) (cloudflare.SecondaryDNSIncomingNewResponse, error) -- client.SecondaryDNS.Incoming.Update(ctx context.Context, params cloudflare.SecondaryDNSIncomingUpdateParams) (cloudflare.SecondaryDNSIncomingUpdateResponse, error) -- client.SecondaryDNS.Incoming.Delete(ctx context.Context, body cloudflare.SecondaryDNSIncomingDeleteParams) (cloudflare.SecondaryDNSIncomingDeleteResponse, error) -- client.SecondaryDNS.Incoming.Get(ctx context.Context, query cloudflare.SecondaryDNSIncomingGetParams) (cloudflare.SecondaryDNSIncomingGetResponse, error) +- client.SecondaryDNS.Incoming.New(ctx context.Context, params secondary_dns.IncomingNewParams) (secondary_dns.IncomingNewResponse, error) +- client.SecondaryDNS.Incoming.Update(ctx context.Context, params secondary_dns.IncomingUpdateParams) (secondary_dns.IncomingUpdateResponse, error) +- client.SecondaryDNS.Incoming.Delete(ctx context.Context, body secondary_dns.IncomingDeleteParams) (secondary_dns.IncomingDeleteResponse, error) +- client.SecondaryDNS.Incoming.Get(ctx context.Context, query secondary_dns.IncomingGetParams) (secondary_dns.IncomingGetResponse, error) ## Outgoing Response Types: -- cloudflare.SecondaryDNSOutgoingNewResponse -- cloudflare.SecondaryDNSOutgoingUpdateResponse -- cloudflare.SecondaryDNSOutgoingDeleteResponse -- cloudflare.SecondaryDNSOutgoingGetResponse +- secondary_dns.SecondaryDNSDisableTransferResult +- secondary_dns.SecondaryDNSEnableTransferResult +- secondary_dns.SecondaryDNSSchemasForceResult +- secondary_dns.OutgoingNewResponse +- secondary_dns.OutgoingUpdateResponse +- secondary_dns.OutgoingDeleteResponse +- secondary_dns.OutgoingGetResponse Methods: -- client.SecondaryDNS.Outgoing.New(ctx context.Context, params cloudflare.SecondaryDNSOutgoingNewParams) (cloudflare.SecondaryDNSOutgoingNewResponse, error) -- client.SecondaryDNS.Outgoing.Update(ctx context.Context, params cloudflare.SecondaryDNSOutgoingUpdateParams) (cloudflare.SecondaryDNSOutgoingUpdateResponse, error) -- client.SecondaryDNS.Outgoing.Delete(ctx context.Context, body cloudflare.SecondaryDNSOutgoingDeleteParams) (cloudflare.SecondaryDNSOutgoingDeleteResponse, error) -- client.SecondaryDNS.Outgoing.Disable(ctx context.Context, body cloudflare.SecondaryDNSOutgoingDisableParams) (string, error) -- client.SecondaryDNS.Outgoing.Enable(ctx context.Context, body cloudflare.SecondaryDNSOutgoingEnableParams) (string, error) -- client.SecondaryDNS.Outgoing.ForceNotify(ctx context.Context, body cloudflare.SecondaryDNSOutgoingForceNotifyParams) (string, error) -- client.SecondaryDNS.Outgoing.Get(ctx context.Context, query cloudflare.SecondaryDNSOutgoingGetParams) (cloudflare.SecondaryDNSOutgoingGetResponse, error) +- client.SecondaryDNS.Outgoing.New(ctx context.Context, params secondary_dns.OutgoingNewParams) (secondary_dns.OutgoingNewResponse, error) +- client.SecondaryDNS.Outgoing.Update(ctx context.Context, params secondary_dns.OutgoingUpdateParams) (secondary_dns.OutgoingUpdateResponse, error) +- client.SecondaryDNS.Outgoing.Delete(ctx context.Context, body secondary_dns.OutgoingDeleteParams) (secondary_dns.OutgoingDeleteResponse, error) +- client.SecondaryDNS.Outgoing.Disable(ctx context.Context, body secondary_dns.OutgoingDisableParams) (secondary_dns.SecondaryDNSDisableTransferResult, error) +- client.SecondaryDNS.Outgoing.Enable(ctx context.Context, body secondary_dns.OutgoingEnableParams) (secondary_dns.SecondaryDNSEnableTransferResult, error) +- client.SecondaryDNS.Outgoing.ForceNotify(ctx context.Context, body secondary_dns.OutgoingForceNotifyParams) (secondary_dns.SecondaryDNSSchemasForceResult, error) +- client.SecondaryDNS.Outgoing.Get(ctx context.Context, query secondary_dns.OutgoingGetParams) (secondary_dns.OutgoingGetResponse, error) ### Status Methods: -- client.SecondaryDNS.Outgoing.Status.Get(ctx context.Context, query cloudflare.SecondaryDNSOutgoingStatusGetParams) (string, error) +- client.SecondaryDNS.Outgoing.Status.Get(ctx context.Context, query secondary_dns.OutgoingStatusGetParams) (secondary_dns.SecondaryDNSEnableTransferResult, error) ## ACLs Response Types: -- cloudflare.SecondaryDnsaclNewResponse -- cloudflare.SecondaryDnsaclUpdateResponse -- cloudflare.SecondaryDnsaclListResponse -- cloudflare.SecondaryDnsaclDeleteResponse -- cloudflare.SecondaryDnsaclGetResponse +- secondary_dns.SecondaryDNSACL +- secondary_dns.ACLDeleteResponse Methods: -- client.SecondaryDNS.ACLs.New(ctx context.Context, params cloudflare.SecondaryDNSACLNewParams) (cloudflare.SecondaryDnsaclNewResponse, error) -- client.SecondaryDNS.ACLs.Update(ctx context.Context, aclID interface{}, params cloudflare.SecondaryDNSACLUpdateParams) (cloudflare.SecondaryDnsaclUpdateResponse, error) -- client.SecondaryDNS.ACLs.List(ctx context.Context, query cloudflare.SecondaryDNSACLListParams) ([]cloudflare.SecondaryDnsaclListResponse, error) -- client.SecondaryDNS.ACLs.Delete(ctx context.Context, aclID interface{}, body cloudflare.SecondaryDNSACLDeleteParams) (cloudflare.SecondaryDnsaclDeleteResponse, error) -- client.SecondaryDNS.ACLs.Get(ctx context.Context, aclID interface{}, query cloudflare.SecondaryDNSACLGetParams) (cloudflare.SecondaryDnsaclGetResponse, error) +- client.SecondaryDNS.ACLs.New(ctx context.Context, params secondary_dns.ACLNewParams) (secondary_dns.SecondaryDNSACL, error) +- client.SecondaryDNS.ACLs.Update(ctx context.Context, aclID interface{}, params secondary_dns.ACLUpdateParams) (secondary_dns.SecondaryDNSACL, error) +- client.SecondaryDNS.ACLs.List(ctx context.Context, query secondary_dns.ACLListParams) ([]secondary_dns.SecondaryDNSACL, error) +- client.SecondaryDNS.ACLs.Delete(ctx context.Context, aclID interface{}, body secondary_dns.ACLDeleteParams) (secondary_dns.ACLDeleteResponse, error) +- client.SecondaryDNS.ACLs.Get(ctx context.Context, aclID interface{}, query secondary_dns.ACLGetParams) (secondary_dns.SecondaryDNSACL, error) ## Peers Response Types: -- cloudflare.SecondaryDNSPeerNewResponse -- cloudflare.SecondaryDNSPeerUpdateResponse -- cloudflare.SecondaryDNSPeerListResponse -- cloudflare.SecondaryDNSPeerDeleteResponse -- cloudflare.SecondaryDNSPeerGetResponse +- secondary_dns.SecondaryDNSPeer +- secondary_dns.PeerDeleteResponse Methods: -- client.SecondaryDNS.Peers.New(ctx context.Context, params cloudflare.SecondaryDNSPeerNewParams) (cloudflare.SecondaryDNSPeerNewResponse, error) -- client.SecondaryDNS.Peers.Update(ctx context.Context, peerID interface{}, params cloudflare.SecondaryDNSPeerUpdateParams) (cloudflare.SecondaryDNSPeerUpdateResponse, error) -- client.SecondaryDNS.Peers.List(ctx context.Context, query cloudflare.SecondaryDNSPeerListParams) ([]cloudflare.SecondaryDNSPeerListResponse, error) -- client.SecondaryDNS.Peers.Delete(ctx context.Context, peerID interface{}, body cloudflare.SecondaryDNSPeerDeleteParams) (cloudflare.SecondaryDNSPeerDeleteResponse, error) -- client.SecondaryDNS.Peers.Get(ctx context.Context, peerID interface{}, query cloudflare.SecondaryDNSPeerGetParams) (cloudflare.SecondaryDNSPeerGetResponse, error) +- client.SecondaryDNS.Peers.New(ctx context.Context, params secondary_dns.PeerNewParams) (secondary_dns.SecondaryDNSPeer, error) +- client.SecondaryDNS.Peers.Update(ctx context.Context, peerID interface{}, params secondary_dns.PeerUpdateParams) (secondary_dns.SecondaryDNSPeer, error) +- client.SecondaryDNS.Peers.List(ctx context.Context, query secondary_dns.PeerListParams) ([]secondary_dns.SecondaryDNSPeer, error) +- client.SecondaryDNS.Peers.Delete(ctx context.Context, peerID interface{}, body secondary_dns.PeerDeleteParams) (secondary_dns.PeerDeleteResponse, error) +- client.SecondaryDNS.Peers.Get(ctx context.Context, peerID interface{}, query secondary_dns.PeerGetParams) (secondary_dns.SecondaryDNSPeer, error) ## TSIGs Response Types: -- cloudflare.SecondaryDnstsigNewResponse -- cloudflare.SecondaryDnstsigUpdateResponse -- cloudflare.SecondaryDnstsigListResponse -- cloudflare.SecondaryDnstsigDeleteResponse -- cloudflare.SecondaryDnstsigGetResponse +- secondary_dns.SecondaryDNSTSIG +- secondary_dns.TSIGDeleteResponse Methods: -- client.SecondaryDNS.TSIGs.New(ctx context.Context, params cloudflare.SecondaryDNSTSIGNewParams) (cloudflare.SecondaryDnstsigNewResponse, error) -- client.SecondaryDNS.TSIGs.Update(ctx context.Context, tsigID interface{}, params cloudflare.SecondaryDNSTSIGUpdateParams) (cloudflare.SecondaryDnstsigUpdateResponse, error) -- client.SecondaryDNS.TSIGs.List(ctx context.Context, query cloudflare.SecondaryDNSTSIGListParams) ([]cloudflare.SecondaryDnstsigListResponse, error) -- client.SecondaryDNS.TSIGs.Delete(ctx context.Context, tsigID interface{}, body cloudflare.SecondaryDNSTSIGDeleteParams) (cloudflare.SecondaryDnstsigDeleteResponse, error) -- client.SecondaryDNS.TSIGs.Get(ctx context.Context, tsigID interface{}, query cloudflare.SecondaryDNSTSIGGetParams) (cloudflare.SecondaryDnstsigGetResponse, error) +- client.SecondaryDNS.TSIGs.New(ctx context.Context, params secondary_dns.TSIGNewParams) (secondary_dns.SecondaryDNSTSIG, error) +- client.SecondaryDNS.TSIGs.Update(ctx context.Context, tsigID interface{}, params secondary_dns.TSIGUpdateParams) (secondary_dns.SecondaryDNSTSIG, error) +- client.SecondaryDNS.TSIGs.List(ctx context.Context, query secondary_dns.TSIGListParams) ([]secondary_dns.SecondaryDNSTSIG, error) +- client.SecondaryDNS.TSIGs.Delete(ctx context.Context, tsigID interface{}, body secondary_dns.TSIGDeleteParams) (secondary_dns.TSIGDeleteResponse, error) +- client.SecondaryDNS.TSIGs.Get(ctx context.Context, tsigID interface{}, query secondary_dns.TSIGGetParams) (secondary_dns.SecondaryDNSTSIG, error) # WaitingRooms Response Types: -- cloudflare.WaitingRoomNewResponse -- cloudflare.WaitingRoomUpdateResponse -- cloudflare.WaitingRoomListResponse -- cloudflare.WaitingRoomDeleteResponse -- cloudflare.WaitingRoomEditResponse -- cloudflare.WaitingRoomGetResponse -- cloudflare.WaitingRoomPreviewResponse +- waiting_rooms.WaitingroomWaitingroom +- waiting_rooms.WaitingRoomDeleteResponse +- waiting_rooms.WaitingRoomPreviewResponse Methods: -- client.WaitingRooms.New(ctx context.Context, zoneIdentifier string, body cloudflare.WaitingRoomNewParams) (cloudflare.WaitingRoomNewResponse, error) -- client.WaitingRooms.Update(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body cloudflare.WaitingRoomUpdateParams) (cloudflare.WaitingRoomUpdateResponse, error) -- client.WaitingRooms.List(ctx context.Context, zoneIdentifier string) ([]cloudflare.WaitingRoomListResponse, error) -- client.WaitingRooms.Delete(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}) (cloudflare.WaitingRoomDeleteResponse, error) -- client.WaitingRooms.Edit(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body cloudflare.WaitingRoomEditParams) (cloudflare.WaitingRoomEditResponse, error) -- client.WaitingRooms.Get(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}) (cloudflare.WaitingRoomGetResponse, error) -- client.WaitingRooms.Preview(ctx context.Context, zoneIdentifier string, body cloudflare.WaitingRoomPreviewParams) (cloudflare.WaitingRoomPreviewResponse, error) +- client.WaitingRooms.New(ctx context.Context, zoneIdentifier string, body waiting_rooms.WaitingRoomNewParams) (waiting_rooms.WaitingroomWaitingroom, error) +- client.WaitingRooms.Update(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body waiting_rooms.WaitingRoomUpdateParams) (waiting_rooms.WaitingroomWaitingroom, error) +- client.WaitingRooms.List(ctx context.Context, zoneIdentifier string) ([]waiting_rooms.WaitingroomWaitingroom, error) +- client.WaitingRooms.Delete(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}) (waiting_rooms.WaitingRoomDeleteResponse, error) +- client.WaitingRooms.Edit(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body waiting_rooms.WaitingRoomEditParams) (waiting_rooms.WaitingroomWaitingroom, error) +- client.WaitingRooms.Get(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}) (waiting_rooms.WaitingroomWaitingroom, error) +- client.WaitingRooms.Preview(ctx context.Context, zoneIdentifier string, body waiting_rooms.WaitingRoomPreviewParams) (waiting_rooms.WaitingRoomPreviewResponse, error) ## Events Response Types: -- cloudflare.WaitingRoomEventNewResponse -- cloudflare.WaitingRoomEventUpdateResponse -- cloudflare.WaitingRoomEventListResponse -- cloudflare.WaitingRoomEventDeleteResponse -- cloudflare.WaitingRoomEventEditResponse -- cloudflare.WaitingRoomEventGetResponse +- waiting_rooms.WaitingroomEventResult +- waiting_rooms.EventDeleteResponse Methods: -- client.WaitingRooms.Events.New(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body cloudflare.WaitingRoomEventNewParams) (cloudflare.WaitingRoomEventNewResponse, error) -- client.WaitingRooms.Events.Update(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}, body cloudflare.WaitingRoomEventUpdateParams) (cloudflare.WaitingRoomEventUpdateResponse, error) -- client.WaitingRooms.Events.List(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}) ([]cloudflare.WaitingRoomEventListResponse, error) -- client.WaitingRooms.Events.Delete(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}) (cloudflare.WaitingRoomEventDeleteResponse, error) -- client.WaitingRooms.Events.Edit(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}, body cloudflare.WaitingRoomEventEditParams) (cloudflare.WaitingRoomEventEditResponse, error) -- client.WaitingRooms.Events.Get(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}) (cloudflare.WaitingRoomEventGetResponse, error) +- client.WaitingRooms.Events.New(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body waiting_rooms.EventNewParams) (waiting_rooms.WaitingroomEventResult, error) +- client.WaitingRooms.Events.Update(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}, body waiting_rooms.EventUpdateParams) (waiting_rooms.WaitingroomEventResult, error) +- client.WaitingRooms.Events.List(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}) ([]waiting_rooms.WaitingroomEventResult, error) +- client.WaitingRooms.Events.Delete(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}) (waiting_rooms.EventDeleteResponse, error) +- client.WaitingRooms.Events.Edit(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}, body waiting_rooms.EventEditParams) (waiting_rooms.WaitingroomEventResult, error) +- client.WaitingRooms.Events.Get(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}) (waiting_rooms.WaitingroomEventResult, error) ### Details Response Types: -- cloudflare.WaitingRoomEventDetailGetResponse +- waiting_rooms.WaitingroomEventDetailsResult Methods: -- client.WaitingRooms.Events.Details.Get(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}) (cloudflare.WaitingRoomEventDetailGetResponse, error) +- client.WaitingRooms.Events.Details.Get(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}) (waiting_rooms.WaitingroomEventDetailsResult, error) ## Rules Response Types: -- cloudflare.WaitingRoomRuleNewResponse -- cloudflare.WaitingRoomRuleUpdateResponse -- cloudflare.WaitingRoomRuleListResponse -- cloudflare.WaitingRoomRuleDeleteResponse -- cloudflare.WaitingRoomRuleEditResponse +- waiting_rooms.WaitingroomRuleResult Methods: -- client.WaitingRooms.Rules.New(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body cloudflare.WaitingRoomRuleNewParams) ([]cloudflare.WaitingRoomRuleNewResponse, error) -- client.WaitingRooms.Rules.Update(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body cloudflare.WaitingRoomRuleUpdateParams) ([]cloudflare.WaitingRoomRuleUpdateResponse, error) -- client.WaitingRooms.Rules.List(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}) ([]cloudflare.WaitingRoomRuleListResponse, error) -- client.WaitingRooms.Rules.Delete(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, ruleID string) ([]cloudflare.WaitingRoomRuleDeleteResponse, error) -- client.WaitingRooms.Rules.Edit(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, ruleID string, body cloudflare.WaitingRoomRuleEditParams) ([]cloudflare.WaitingRoomRuleEditResponse, error) +- client.WaitingRooms.Rules.New(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body waiting_rooms.RuleNewParams) ([]waiting_rooms.WaitingroomRuleResult, error) +- client.WaitingRooms.Rules.Update(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body waiting_rooms.RuleUpdateParams) ([]waiting_rooms.WaitingroomRuleResult, error) +- client.WaitingRooms.Rules.List(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}) ([]waiting_rooms.WaitingroomRuleResult, error) +- client.WaitingRooms.Rules.Delete(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, ruleID string) ([]waiting_rooms.WaitingroomRuleResult, error) +- client.WaitingRooms.Rules.Edit(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, ruleID string, body waiting_rooms.RuleEditParams) ([]waiting_rooms.WaitingroomRuleResult, error) ## Statuses Response Types: -- cloudflare.WaitingRoomStatusGetResponse +- waiting_rooms.StatusGetResponse Methods: -- client.WaitingRooms.Statuses.Get(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}) (cloudflare.WaitingRoomStatusGetResponse, error) +- client.WaitingRooms.Statuses.Get(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}) (waiting_rooms.StatusGetResponse, error) ## Settings Response Types: -- cloudflare.WaitingRoomSettingUpdateResponse -- cloudflare.WaitingRoomSettingEditResponse -- cloudflare.WaitingRoomSettingGetResponse +- waiting_rooms.SettingUpdateResponse +- waiting_rooms.SettingEditResponse +- waiting_rooms.SettingGetResponse Methods: -- client.WaitingRooms.Settings.Update(ctx context.Context, zoneIdentifier string, body cloudflare.WaitingRoomSettingUpdateParams) (cloudflare.WaitingRoomSettingUpdateResponse, error) -- client.WaitingRooms.Settings.Edit(ctx context.Context, zoneIdentifier string, body cloudflare.WaitingRoomSettingEditParams) (cloudflare.WaitingRoomSettingEditResponse, error) -- client.WaitingRooms.Settings.Get(ctx context.Context, zoneIdentifier string) (cloudflare.WaitingRoomSettingGetResponse, error) +- client.WaitingRooms.Settings.Update(ctx context.Context, zoneIdentifier string, body waiting_rooms.SettingUpdateParams) (waiting_rooms.SettingUpdateResponse, error) +- client.WaitingRooms.Settings.Edit(ctx context.Context, zoneIdentifier string, body waiting_rooms.SettingEditParams) (waiting_rooms.SettingEditResponse, error) +- client.WaitingRooms.Settings.Get(ctx context.Context, zoneIdentifier string) (waiting_rooms.SettingGetResponse, error) # Web3 @@ -2321,19 +2375,16 @@ Methods: Response Types: -- cloudflare.Web3HostnameNewResponse -- cloudflare.Web3HostnameListResponse -- cloudflare.Web3HostnameDeleteResponse -- cloudflare.Web3HostnameEditResponse -- cloudflare.Web3HostnameGetResponse +- web3.DwebConfigWeb3Hostname +- web3.HostnameDeleteResponse Methods: -- client.Web3.Hostnames.New(ctx context.Context, zoneIdentifier string, body cloudflare.Web3HostnameNewParams) (cloudflare.Web3HostnameNewResponse, error) -- client.Web3.Hostnames.List(ctx context.Context, zoneIdentifier string) ([]cloudflare.Web3HostnameListResponse, error) -- client.Web3.Hostnames.Delete(ctx context.Context, zoneIdentifier string, identifier string) (cloudflare.Web3HostnameDeleteResponse, error) -- client.Web3.Hostnames.Edit(ctx context.Context, zoneIdentifier string, identifier string, body cloudflare.Web3HostnameEditParams) (cloudflare.Web3HostnameEditResponse, error) -- client.Web3.Hostnames.Get(ctx context.Context, zoneIdentifier string, identifier string) (cloudflare.Web3HostnameGetResponse, error) +- client.Web3.Hostnames.New(ctx context.Context, zoneIdentifier string, body web3.HostnameNewParams) (web3.DwebConfigWeb3Hostname, error) +- client.Web3.Hostnames.List(ctx context.Context, zoneIdentifier string) ([]web3.DwebConfigWeb3Hostname, error) +- client.Web3.Hostnames.Delete(ctx context.Context, zoneIdentifier string, identifier string) (web3.HostnameDeleteResponse, error) +- client.Web3.Hostnames.Edit(ctx context.Context, zoneIdentifier string, identifier string, body web3.HostnameEditParams) (web3.DwebConfigWeb3Hostname, error) +- client.Web3.Hostnames.Get(ctx context.Context, zoneIdentifier string, identifier string) (web3.DwebConfigWeb3Hostname, error) ### IPFSUniversalPaths @@ -2341,31 +2392,32 @@ Methods: Response Types: -- cloudflare.Web3HostnameIPFSUniversalPathContentListUpdateResponse -- cloudflare.Web3HostnameIPFSUniversalPathContentListGetResponse +- web3.DwebConfigContentListDetails Methods: -- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Update(ctx context.Context, zoneIdentifier string, identifier string, body cloudflare.Web3HostnameIPFSUniversalPathContentListUpdateParams) (cloudflare.Web3HostnameIPFSUniversalPathContentListUpdateResponse, error) -- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Get(ctx context.Context, zoneIdentifier string, identifier string) (cloudflare.Web3HostnameIPFSUniversalPathContentListGetResponse, error) +- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Update(ctx context.Context, zoneIdentifier string, identifier string, body web3.HostnameIPFSUniversalPathContentListUpdateParams) (web3.DwebConfigContentListDetails, error) +- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Get(ctx context.Context, zoneIdentifier string, identifier string) (web3.DwebConfigContentListDetails, error) ##### Entries +Params Types: + +- web3.DwebConfigContentListEntryParam + Response Types: -- cloudflare.Web3HostnameIPFSUniversalPathContentListEntryNewResponse -- cloudflare.Web3HostnameIPFSUniversalPathContentListEntryUpdateResponse -- cloudflare.Web3HostnameIPFSUniversalPathContentListEntryListResponse -- cloudflare.Web3HostnameIPFSUniversalPathContentListEntryDeleteResponse -- cloudflare.Web3HostnameIPFSUniversalPathContentListEntryGetResponse +- web3.DwebConfigContentListEntry +- web3.HostnameIPFSUniversalPathContentListEntryListResponse +- web3.HostnameIPFSUniversalPathContentListEntryDeleteResponse Methods: -- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.New(ctx context.Context, zoneIdentifier string, identifier string, body cloudflare.Web3HostnameIPFSUniversalPathContentListEntryNewParams) (cloudflare.Web3HostnameIPFSUniversalPathContentListEntryNewResponse, error) -- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Update(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, body cloudflare.Web3HostnameIPFSUniversalPathContentListEntryUpdateParams) (cloudflare.Web3HostnameIPFSUniversalPathContentListEntryUpdateResponse, error) -- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.List(ctx context.Context, zoneIdentifier string, identifier string) (cloudflare.Web3HostnameIPFSUniversalPathContentListEntryListResponse, error) -- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Delete(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string) (cloudflare.Web3HostnameIPFSUniversalPathContentListEntryDeleteResponse, error) -- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Get(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string) (cloudflare.Web3HostnameIPFSUniversalPathContentListEntryGetResponse, error) +- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.New(ctx context.Context, zoneIdentifier string, identifier string, body web3.HostnameIPFSUniversalPathContentListEntryNewParams) (web3.DwebConfigContentListEntry, error) +- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Update(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, body web3.HostnameIPFSUniversalPathContentListEntryUpdateParams) (web3.DwebConfigContentListEntry, error) +- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.List(ctx context.Context, zoneIdentifier string, identifier string) (web3.HostnameIPFSUniversalPathContentListEntryListResponse, error) +- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Delete(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string) (web3.HostnameIPFSUniversalPathContentListEntryDeleteResponse, error) +- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Get(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string) (web3.DwebConfigContentListEntry, error) # Workers @@ -2373,147 +2425,139 @@ Methods: Response Types: -- cloudflare.WorkerAIRunResponse +- workers.AIRunResponse Methods: -- client.Workers.AI.Run(ctx context.Context, modelName string, params cloudflare.WorkerAIRunParams) (cloudflare.WorkerAIRunResponse, error) +- client.Workers.AI.Run(ctx context.Context, modelName string, params workers.AIRunParams) (workers.AIRunResponse, error) ## Scripts Response Types: -- cloudflare.WorkerScriptUpdateResponse -- cloudflare.WorkerScriptListResponse +- workers.WorkersScript Methods: -- client.Workers.Scripts.Update(ctx context.Context, scriptName string, params cloudflare.WorkerScriptUpdateParams) (cloudflare.WorkerScriptUpdateResponse, error) -- client.Workers.Scripts.List(ctx context.Context, query cloudflare.WorkerScriptListParams) ([]cloudflare.WorkerScriptListResponse, error) -- client.Workers.Scripts.Delete(ctx context.Context, scriptName string, params cloudflare.WorkerScriptDeleteParams) error -- client.Workers.Scripts.Get(ctx context.Context, scriptName string, query cloudflare.WorkerScriptGetParams) (http.Response, error) +- client.Workers.Scripts.Update(ctx context.Context, scriptName string, params workers.ScriptUpdateParams) (workers.WorkersScript, error) +- client.Workers.Scripts.List(ctx context.Context, query workers.ScriptListParams) ([]workers.WorkersScript, error) +- client.Workers.Scripts.Delete(ctx context.Context, scriptName string, params workers.ScriptDeleteParams) error +- client.Workers.Scripts.Get(ctx context.Context, scriptName string, query workers.ScriptGetParams) (http.Response, error) ### Bindings Response Types: -- cloudflare.WorkerScriptBindingGetResponse +- workers.WorkersSchemasBinding Methods: -- client.Workers.Scripts.Bindings.Get(ctx context.Context, query cloudflare.WorkerScriptBindingGetParams) ([]cloudflare.WorkerScriptBindingGetResponse, error) +- client.Workers.Scripts.Bindings.Get(ctx context.Context, query workers.ScriptBindingGetParams) ([]workers.WorkersSchemasBinding, error) ### Schedules Response Types: -- cloudflare.WorkerScriptScheduleUpdateResponse -- cloudflare.WorkerScriptScheduleGetResponse +- workers.ScriptScheduleUpdateResponse +- workers.ScriptScheduleGetResponse Methods: -- client.Workers.Scripts.Schedules.Update(ctx context.Context, scriptName string, params cloudflare.WorkerScriptScheduleUpdateParams) (cloudflare.WorkerScriptScheduleUpdateResponse, error) -- client.Workers.Scripts.Schedules.Get(ctx context.Context, scriptName string, query cloudflare.WorkerScriptScheduleGetParams) (cloudflare.WorkerScriptScheduleGetResponse, error) +- client.Workers.Scripts.Schedules.Update(ctx context.Context, scriptName string, params workers.ScriptScheduleUpdateParams) (workers.ScriptScheduleUpdateResponse, error) +- client.Workers.Scripts.Schedules.Get(ctx context.Context, scriptName string, query workers.ScriptScheduleGetParams) (workers.ScriptScheduleGetResponse, error) ### Tail Response Types: -- cloudflare.WorkerScriptTailNewResponse -- cloudflare.WorkerScriptTailDeleteResponse -- cloudflare.WorkerScriptTailGetResponse +- workers.ScriptTailNewResponse +- workers.ScriptTailDeleteResponse +- workers.ScriptTailGetResponse Methods: -- client.Workers.Scripts.Tail.New(ctx context.Context, scriptName string, body cloudflare.WorkerScriptTailNewParams) (cloudflare.WorkerScriptTailNewResponse, error) -- client.Workers.Scripts.Tail.Delete(ctx context.Context, scriptName string, id string, body cloudflare.WorkerScriptTailDeleteParams) (cloudflare.WorkerScriptTailDeleteResponse, error) -- client.Workers.Scripts.Tail.Get(ctx context.Context, scriptName string, query cloudflare.WorkerScriptTailGetParams) (cloudflare.WorkerScriptTailGetResponse, error) +- client.Workers.Scripts.Tail.New(ctx context.Context, scriptName string, body workers.ScriptTailNewParams) (workers.ScriptTailNewResponse, error) +- client.Workers.Scripts.Tail.Delete(ctx context.Context, scriptName string, id string, body workers.ScriptTailDeleteParams) (workers.ScriptTailDeleteResponse, error) +- client.Workers.Scripts.Tail.Get(ctx context.Context, scriptName string, query workers.ScriptTailGetParams) (workers.ScriptTailGetResponse, error) ### UsageModel Response Types: -- cloudflare.WorkerScriptUsageModelUpdateResponse -- cloudflare.WorkerScriptUsageModelGetResponse +- workers.ScriptUsageModelUpdateResponse +- workers.ScriptUsageModelGetResponse Methods: -- client.Workers.Scripts.UsageModel.Update(ctx context.Context, scriptName string, params cloudflare.WorkerScriptUsageModelUpdateParams) (cloudflare.WorkerScriptUsageModelUpdateResponse, error) -- client.Workers.Scripts.UsageModel.Get(ctx context.Context, scriptName string, query cloudflare.WorkerScriptUsageModelGetParams) (cloudflare.WorkerScriptUsageModelGetResponse, error) +- client.Workers.Scripts.UsageModel.Update(ctx context.Context, scriptName string, params workers.ScriptUsageModelUpdateParams) (workers.ScriptUsageModelUpdateResponse, error) +- client.Workers.Scripts.UsageModel.Get(ctx context.Context, scriptName string, query workers.ScriptUsageModelGetParams) (workers.ScriptUsageModelGetResponse, error) ### Content -Response Types: - -- cloudflare.WorkerScriptContentUpdateResponse - Methods: -- client.Workers.Scripts.Content.Update(ctx context.Context, scriptName string, params cloudflare.WorkerScriptContentUpdateParams) (cloudflare.WorkerScriptContentUpdateResponse, error) +- client.Workers.Scripts.Content.Update(ctx context.Context, scriptName string, params workers.ScriptContentUpdateParams) (workers.WorkersScript, error) ### ContentV2 Methods: -- client.Workers.Scripts.ContentV2.Get(ctx context.Context, scriptName string, query cloudflare.WorkerScriptContentV2GetParams) (http.Response, error) +- client.Workers.Scripts.ContentV2.Get(ctx context.Context, scriptName string, query workers.ScriptContentV2GetParams) (http.Response, error) ### Settings Response Types: -- cloudflare.WorkerScriptSettingEditResponse -- cloudflare.WorkerScriptSettingGetResponse +- workers.ScriptSettingEditResponse +- workers.ScriptSettingGetResponse Methods: -- client.Workers.Scripts.Settings.Edit(ctx context.Context, scriptName string, params cloudflare.WorkerScriptSettingEditParams) (cloudflare.WorkerScriptSettingEditResponse, error) -- client.Workers.Scripts.Settings.Get(ctx context.Context, scriptName string, query cloudflare.WorkerScriptSettingGetParams) (cloudflare.WorkerScriptSettingGetResponse, error) +- client.Workers.Scripts.Settings.Edit(ctx context.Context, scriptName string, params workers.ScriptSettingEditParams) (workers.ScriptSettingEditResponse, error) +- client.Workers.Scripts.Settings.Get(ctx context.Context, scriptName string, query workers.ScriptSettingGetParams) (workers.ScriptSettingGetResponse, error) ## Filters Response Types: -- cloudflare.WorkerFilterNewResponse -- cloudflare.WorkerFilterUpdateResponse -- cloudflare.WorkerFilterListResponse -- cloudflare.WorkerFilterDeleteResponse +- workers.WorkersFilters +- workers.FilterNewResponse +- workers.FilterDeleteResponse Methods: -- client.Workers.Filters.New(ctx context.Context, params cloudflare.WorkerFilterNewParams) (cloudflare.WorkerFilterNewResponse, error) -- client.Workers.Filters.Update(ctx context.Context, filterID string, params cloudflare.WorkerFilterUpdateParams) (cloudflare.WorkerFilterUpdateResponse, error) -- client.Workers.Filters.List(ctx context.Context, query cloudflare.WorkerFilterListParams) ([]cloudflare.WorkerFilterListResponse, error) -- client.Workers.Filters.Delete(ctx context.Context, filterID string, body cloudflare.WorkerFilterDeleteParams) (cloudflare.WorkerFilterDeleteResponse, error) +- client.Workers.Filters.New(ctx context.Context, params workers.FilterNewParams) (workers.FilterNewResponse, error) +- client.Workers.Filters.Update(ctx context.Context, filterID string, params workers.FilterUpdateParams) (workers.WorkersFilters, error) +- client.Workers.Filters.List(ctx context.Context, query workers.FilterListParams) ([]workers.WorkersFilters, error) +- client.Workers.Filters.Delete(ctx context.Context, filterID string, body workers.FilterDeleteParams) (workers.FilterDeleteResponse, error) ## Routes Response Types: -- cloudflare.WorkerRouteNewResponse -- cloudflare.WorkerRouteUpdateResponse -- cloudflare.WorkerRouteListResponse -- cloudflare.WorkerRouteDeleteResponse -- cloudflare.WorkerRouteGetResponse +- workers.WorkersRoutes +- workers.RouteNewResponse +- workers.RouteDeleteResponse Methods: -- client.Workers.Routes.New(ctx context.Context, params cloudflare.WorkerRouteNewParams) (cloudflare.WorkerRouteNewResponse, error) -- client.Workers.Routes.Update(ctx context.Context, routeID string, params cloudflare.WorkerRouteUpdateParams) (cloudflare.WorkerRouteUpdateResponse, error) -- client.Workers.Routes.List(ctx context.Context, query cloudflare.WorkerRouteListParams) ([]cloudflare.WorkerRouteListResponse, error) -- client.Workers.Routes.Delete(ctx context.Context, routeID string, body cloudflare.WorkerRouteDeleteParams) (cloudflare.WorkerRouteDeleteResponse, error) -- client.Workers.Routes.Get(ctx context.Context, routeID string, query cloudflare.WorkerRouteGetParams) (cloudflare.WorkerRouteGetResponse, error) +- client.Workers.Routes.New(ctx context.Context, params workers.RouteNewParams) (workers.RouteNewResponse, error) +- client.Workers.Routes.Update(ctx context.Context, routeID string, params workers.RouteUpdateParams) (workers.WorkersRoutes, error) +- client.Workers.Routes.List(ctx context.Context, query workers.RouteListParams) ([]workers.WorkersRoutes, error) +- client.Workers.Routes.Delete(ctx context.Context, routeID string, body workers.RouteDeleteParams) (workers.RouteDeleteResponse, error) +- client.Workers.Routes.Get(ctx context.Context, routeID string, query workers.RouteGetParams) (workers.WorkersRoutes, error) ## AccountSettings Response Types: -- cloudflare.WorkerAccountSettingUpdateResponse -- cloudflare.WorkerAccountSettingGetResponse +- workers.AccountSettingUpdateResponse +- workers.AccountSettingGetResponse Methods: -- client.Workers.AccountSettings.Update(ctx context.Context, params cloudflare.WorkerAccountSettingUpdateParams) (cloudflare.WorkerAccountSettingUpdateResponse, error) -- client.Workers.AccountSettings.Get(ctx context.Context, query cloudflare.WorkerAccountSettingGetParams) (cloudflare.WorkerAccountSettingGetResponse, error) +- client.Workers.AccountSettings.Update(ctx context.Context, params workers.AccountSettingUpdateParams) (workers.AccountSettingUpdateResponse, error) +- client.Workers.AccountSettings.Get(ctx context.Context, query workers.AccountSettingGetParams) (workers.AccountSettingGetResponse, error) ## Deployments @@ -2521,48 +2565,46 @@ Methods: Response Types: -- cloudflare.WorkerDeploymentByScriptGetResponse +- workers.DeploymentByScriptGetResponse Methods: -- client.Workers.Deployments.ByScripts.Get(ctx context.Context, scriptID string, query cloudflare.WorkerDeploymentByScriptGetParams) (cloudflare.WorkerDeploymentByScriptGetResponse, error) +- client.Workers.Deployments.ByScripts.Get(ctx context.Context, scriptID string, query workers.DeploymentByScriptGetParams) (workers.DeploymentByScriptGetResponse, error) #### Details Response Types: -- cloudflare.WorkerDeploymentByScriptDetailGetResponse +- workers.DeploymentByScriptDetailGetResponse Methods: -- client.Workers.Deployments.ByScripts.Details.Get(ctx context.Context, scriptID string, deploymentID string, query cloudflare.WorkerDeploymentByScriptDetailGetParams) (cloudflare.WorkerDeploymentByScriptDetailGetResponse, error) +- client.Workers.Deployments.ByScripts.Details.Get(ctx context.Context, scriptID string, deploymentID string, query workers.DeploymentByScriptDetailGetParams) (workers.DeploymentByScriptDetailGetResponse, error) ## Domains Response Types: -- cloudflare.WorkerDomainUpdateResponse -- cloudflare.WorkerDomainListResponse -- cloudflare.WorkerDomainGetResponse +- workers.WorkersDomain Methods: -- client.Workers.Domains.Update(ctx context.Context, params cloudflare.WorkerDomainUpdateParams) (cloudflare.WorkerDomainUpdateResponse, error) -- client.Workers.Domains.List(ctx context.Context, params cloudflare.WorkerDomainListParams) ([]cloudflare.WorkerDomainListResponse, error) -- client.Workers.Domains.Delete(ctx context.Context, domainID interface{}, body cloudflare.WorkerDomainDeleteParams) error -- client.Workers.Domains.Get(ctx context.Context, domainID interface{}, query cloudflare.WorkerDomainGetParams) (cloudflare.WorkerDomainGetResponse, error) +- client.Workers.Domains.Update(ctx context.Context, params workers.DomainUpdateParams) (workers.WorkersDomain, error) +- client.Workers.Domains.List(ctx context.Context, params workers.DomainListParams) ([]workers.WorkersDomain, error) +- client.Workers.Domains.Delete(ctx context.Context, domainID interface{}, body workers.DomainDeleteParams) error +- client.Workers.Domains.Get(ctx context.Context, domainID interface{}, query workers.DomainGetParams) (workers.WorkersDomain, error) ## Subdomains Response Types: -- cloudflare.WorkerSubdomainUpdateResponse -- cloudflare.WorkerSubdomainGetResponse +- workers.SubdomainUpdateResponse +- workers.SubdomainGetResponse Methods: -- client.Workers.Subdomains.Update(ctx context.Context, params cloudflare.WorkerSubdomainUpdateParams) (cloudflare.WorkerSubdomainUpdateResponse, error) -- client.Workers.Subdomains.Get(ctx context.Context, query cloudflare.WorkerSubdomainGetParams) (cloudflare.WorkerSubdomainGetResponse, error) +- client.Workers.Subdomains.Update(ctx context.Context, params workers.SubdomainUpdateParams) (workers.SubdomainUpdateResponse, error) +- client.Workers.Subdomains.Get(ctx context.Context, query workers.SubdomainGetParams) (workers.SubdomainGetResponse, error) ## Services @@ -2570,26 +2612,22 @@ Methods: #### Content -Response Types: - -- cloudflare.WorkerServiceEnvironmentContentUpdateResponse - Methods: -- client.Workers.Services.Environments.Content.Update(ctx context.Context, serviceName string, environmentName string, params cloudflare.WorkerServiceEnvironmentContentUpdateParams) (cloudflare.WorkerServiceEnvironmentContentUpdateResponse, error) -- client.Workers.Services.Environments.Content.Get(ctx context.Context, serviceName string, environmentName string, query cloudflare.WorkerServiceEnvironmentContentGetParams) (http.Response, error) +- client.Workers.Services.Environments.Content.Update(ctx context.Context, serviceName string, environmentName string, params workers.ServiceEnvironmentContentUpdateParams) (workers.WorkersScript, error) +- client.Workers.Services.Environments.Content.Get(ctx context.Context, serviceName string, environmentName string, query workers.ServiceEnvironmentContentGetParams) (http.Response, error) #### Settings Response Types: -- cloudflare.WorkerServiceEnvironmentSettingEditResponse -- cloudflare.WorkerServiceEnvironmentSettingGetResponse +- workers.ServiceEnvironmentSettingEditResponse +- workers.ServiceEnvironmentSettingGetResponse Methods: -- client.Workers.Services.Environments.Settings.Edit(ctx context.Context, serviceName string, environmentName string, params cloudflare.WorkerServiceEnvironmentSettingEditParams) (cloudflare.WorkerServiceEnvironmentSettingEditResponse, error) -- client.Workers.Services.Environments.Settings.Get(ctx context.Context, serviceName string, environmentName string, query cloudflare.WorkerServiceEnvironmentSettingGetParams) (cloudflare.WorkerServiceEnvironmentSettingGetResponse, error) +- client.Workers.Services.Environments.Settings.Edit(ctx context.Context, serviceName string, environmentName string, params workers.ServiceEnvironmentSettingEditParams) (workers.ServiceEnvironmentSettingEditResponse, error) +- client.Workers.Services.Environments.Settings.Get(ctx context.Context, serviceName string, environmentName string, query workers.ServiceEnvironmentSettingGetParams) (workers.ServiceEnvironmentSettingGetResponse, error) # KV @@ -2597,62 +2635,61 @@ Methods: Response Types: -- cloudflare.KVNamespaceNewResponse -- cloudflare.KVNamespaceUpdateResponse -- cloudflare.KVNamespaceListResponse -- cloudflare.KVNamespaceDeleteResponse +- kv.WorkersKVNamespace +- kv.NamespaceUpdateResponse +- kv.NamespaceDeleteResponse Methods: -- client.KV.Namespaces.New(ctx context.Context, params cloudflare.KVNamespaceNewParams) (cloudflare.KVNamespaceNewResponse, error) -- client.KV.Namespaces.Update(ctx context.Context, namespaceID string, params cloudflare.KVNamespaceUpdateParams) (cloudflare.KVNamespaceUpdateResponse, error) -- client.KV.Namespaces.List(ctx context.Context, params cloudflare.KVNamespaceListParams) (shared.V4PagePaginationArray[cloudflare.KVNamespaceListResponse], error) -- client.KV.Namespaces.Delete(ctx context.Context, namespaceID string, body cloudflare.KVNamespaceDeleteParams) (cloudflare.KVNamespaceDeleteResponse, error) +- client.KV.Namespaces.New(ctx context.Context, params kv.NamespaceNewParams) (kv.WorkersKVNamespace, error) +- client.KV.Namespaces.Update(ctx context.Context, namespaceID string, params kv.NamespaceUpdateParams) (kv.NamespaceUpdateResponse, error) +- client.KV.Namespaces.List(ctx context.Context, params kv.NamespaceListParams) (shared.V4PagePaginationArray[kv.WorkersKVNamespace], error) +- client.KV.Namespaces.Delete(ctx context.Context, namespaceID string, body kv.NamespaceDeleteParams) (kv.NamespaceDeleteResponse, error) ### Bulk Response Types: -- cloudflare.KVNamespaceBulkUpdateResponse -- cloudflare.KVNamespaceBulkDeleteResponse +- kv.NamespaceBulkUpdateResponse +- kv.NamespaceBulkDeleteResponse Methods: -- client.KV.Namespaces.Bulk.Update(ctx context.Context, namespaceID string, params cloudflare.KVNamespaceBulkUpdateParams) (cloudflare.KVNamespaceBulkUpdateResponse, error) -- client.KV.Namespaces.Bulk.Delete(ctx context.Context, namespaceID string, params cloudflare.KVNamespaceBulkDeleteParams) (cloudflare.KVNamespaceBulkDeleteResponse, error) +- client.KV.Namespaces.Bulk.Update(ctx context.Context, namespaceID string, params kv.NamespaceBulkUpdateParams) (kv.NamespaceBulkUpdateResponse, error) +- client.KV.Namespaces.Bulk.Delete(ctx context.Context, namespaceID string, params kv.NamespaceBulkDeleteParams) (kv.NamespaceBulkDeleteResponse, error) ### Keys Response Types: -- cloudflare.KVNamespaceKeyListResponse +- kv.WorkersKVKey Methods: -- client.KV.Namespaces.Keys.List(ctx context.Context, namespaceID string, params cloudflare.KVNamespaceKeyListParams) ([]cloudflare.KVNamespaceKeyListResponse, error) +- client.KV.Namespaces.Keys.List(ctx context.Context, namespaceID string, params kv.NamespaceKeyListParams) ([]kv.WorkersKVKey, error) ### Metadata Response Types: -- cloudflare.KVNamespaceMetadataGetResponse +- kv.NamespaceMetadataGetResponse Methods: -- client.KV.Namespaces.Metadata.Get(ctx context.Context, namespaceID string, keyName string, query cloudflare.KVNamespaceMetadataGetParams) (cloudflare.KVNamespaceMetadataGetResponse, error) +- client.KV.Namespaces.Metadata.Get(ctx context.Context, namespaceID string, keyName string, query kv.NamespaceMetadataGetParams) (kv.NamespaceMetadataGetResponse, error) ### Values Response Types: -- cloudflare.KVNamespaceValueUpdateResponse -- cloudflare.KVNamespaceValueDeleteResponse +- kv.NamespaceValueUpdateResponse +- kv.NamespaceValueDeleteResponse Methods: -- client.KV.Namespaces.Values.Update(ctx context.Context, namespaceID string, keyName string, params cloudflare.KVNamespaceValueUpdateParams) (cloudflare.KVNamespaceValueUpdateResponse, error) -- client.KV.Namespaces.Values.Delete(ctx context.Context, namespaceID string, keyName string, body cloudflare.KVNamespaceValueDeleteParams) (cloudflare.KVNamespaceValueDeleteResponse, error) -- client.KV.Namespaces.Values.Get(ctx context.Context, namespaceID string, keyName string, query cloudflare.KVNamespaceValueGetParams) (string, error) +- client.KV.Namespaces.Values.Update(ctx context.Context, namespaceID string, keyName string, params kv.NamespaceValueUpdateParams) (kv.NamespaceValueUpdateResponse, error) +- client.KV.Namespaces.Values.Delete(ctx context.Context, namespaceID string, keyName string, body kv.NamespaceValueDeleteParams) (kv.NamespaceValueDeleteResponse, error) +- client.KV.Namespaces.Values.Get(ctx context.Context, namespaceID string, keyName string, query kv.NamespaceValueGetParams) (string, error) # DurableObjects @@ -2660,210 +2697,187 @@ Methods: Response Types: -- cloudflare.DurableObjectNamespaceListResponse +- durable_objects.WorkersNamespace Methods: -- client.DurableObjects.Namespaces.List(ctx context.Context, query cloudflare.DurableObjectNamespaceListParams) ([]cloudflare.DurableObjectNamespaceListResponse, error) +- client.DurableObjects.Namespaces.List(ctx context.Context, query durable_objects.NamespaceListParams) ([]durable_objects.WorkersNamespace, error) ### Objects Response Types: -- cloudflare.DurableObjectNamespaceObjectListResponse +- durable_objects.WorkersObject Methods: -- client.DurableObjects.Namespaces.Objects.List(ctx context.Context, id string, params cloudflare.DurableObjectNamespaceObjectListParams) ([]cloudflare.DurableObjectNamespaceObjectListResponse, error) +- client.DurableObjects.Namespaces.Objects.List(ctx context.Context, id string, params durable_objects.NamespaceObjectListParams) ([]durable_objects.WorkersObject, error) # Queues Response Types: -- cloudflare.QueueNewResponse -- cloudflare.QueueUpdateResponse -- cloudflare.QueueListResponse -- cloudflare.QueueDeleteResponse -- cloudflare.QueueGetResponse +- queues.WorkersQueue +- queues.WorkersQueueCreated +- queues.WorkersQueueUpdated +- queues.QueueDeleteResponse Methods: -- client.Queues.New(ctx context.Context, params cloudflare.QueueNewParams) (cloudflare.QueueNewResponse, error) -- client.Queues.Update(ctx context.Context, name string, params cloudflare.QueueUpdateParams) (cloudflare.QueueUpdateResponse, error) -- client.Queues.List(ctx context.Context, query cloudflare.QueueListParams) ([]cloudflare.QueueListResponse, error) -- client.Queues.Delete(ctx context.Context, name string, body cloudflare.QueueDeleteParams) (cloudflare.QueueDeleteResponse, error) -- client.Queues.Get(ctx context.Context, name string, query cloudflare.QueueGetParams) (cloudflare.QueueGetResponse, error) +- client.Queues.New(ctx context.Context, params queues.QueueNewParams) (queues.WorkersQueueCreated, error) +- client.Queues.Update(ctx context.Context, name string, params queues.QueueUpdateParams) (queues.WorkersQueueUpdated, error) +- client.Queues.List(ctx context.Context, query queues.QueueListParams) ([]queues.WorkersQueue, error) +- client.Queues.Delete(ctx context.Context, name string, body queues.QueueDeleteParams) (queues.QueueDeleteResponse, error) +- client.Queues.Get(ctx context.Context, name string, query queues.QueueGetParams) (queues.WorkersQueue, error) ## Consumers Response Types: -- cloudflare.QueueConsumerNewResponse -- cloudflare.QueueConsumerUpdateResponse -- cloudflare.QueueConsumerDeleteResponse -- cloudflare.QueueConsumerGetResponse +- queues.WorkersConsumer +- queues.WorkersConsumerCreated +- queues.WorkersConsumerUpdated +- queues.ConsumerDeleteResponse Methods: -- client.Queues.Consumers.New(ctx context.Context, name string, params cloudflare.QueueConsumerNewParams) (cloudflare.QueueConsumerNewResponse, error) -- client.Queues.Consumers.Update(ctx context.Context, name string, consumerName string, params cloudflare.QueueConsumerUpdateParams) (cloudflare.QueueConsumerUpdateResponse, error) -- client.Queues.Consumers.Delete(ctx context.Context, name string, consumerName string, body cloudflare.QueueConsumerDeleteParams) (cloudflare.QueueConsumerDeleteResponse, error) -- client.Queues.Consumers.Get(ctx context.Context, name string, query cloudflare.QueueConsumerGetParams) ([]cloudflare.QueueConsumerGetResponse, error) +- client.Queues.Consumers.New(ctx context.Context, name string, params queues.ConsumerNewParams) (queues.WorkersConsumerCreated, error) +- client.Queues.Consumers.Update(ctx context.Context, name string, consumerName string, params queues.ConsumerUpdateParams) (queues.WorkersConsumerUpdated, error) +- client.Queues.Consumers.Delete(ctx context.Context, name string, consumerName string, body queues.ConsumerDeleteParams) (queues.ConsumerDeleteResponse, error) +- client.Queues.Consumers.Get(ctx context.Context, name string, query queues.ConsumerGetParams) ([]queues.WorkersConsumer, error) # ManagedHeaders Response Types: -- cloudflare.ManagedHeaderListResponse -- cloudflare.ManagedHeaderEditResponse +- managed_headers.ManagedHeaderListResponse +- managed_headers.ManagedHeaderEditResponse Methods: -- client.ManagedHeaders.List(ctx context.Context, query cloudflare.ManagedHeaderListParams) (cloudflare.ManagedHeaderListResponse, error) -- client.ManagedHeaders.Edit(ctx context.Context, params cloudflare.ManagedHeaderEditParams) (cloudflare.ManagedHeaderEditResponse, error) +- client.ManagedHeaders.List(ctx context.Context, query managed_headers.ManagedHeaderListParams) (managed_headers.ManagedHeaderListResponse, error) +- client.ManagedHeaders.Edit(ctx context.Context, params managed_headers.ManagedHeaderEditParams) (managed_headers.ManagedHeaderEditResponse, error) # PageShield Response Types: -- cloudflare.PageShieldUpdateResponse -- cloudflare.PageShieldListResponse +- page_shield.PageShieldGetZoneSettings +- page_shield.PageShieldUpdateZoneSettings Methods: -- client.PageShield.Update(ctx context.Context, params cloudflare.PageShieldUpdateParams) (cloudflare.PageShieldUpdateResponse, error) -- client.PageShield.List(ctx context.Context, query cloudflare.PageShieldListParams) (cloudflare.PageShieldListResponse, error) +- client.PageShield.Update(ctx context.Context, params page_shield.PageShieldUpdateParams) (page_shield.PageShieldUpdateZoneSettings, error) +- client.PageShield.List(ctx context.Context, query page_shield.PageShieldListParams) (page_shield.PageShieldGetZoneSettings, error) ## Policies Response Types: -- cloudflare.PageShieldPolicyNewResponse -- cloudflare.PageShieldPolicyUpdateResponse -- cloudflare.PageShieldPolicyListResponse -- cloudflare.PageShieldPolicyGetResponse +- page_shield.PageShieldPageshieldPolicy Methods: -- client.PageShield.Policies.New(ctx context.Context, params cloudflare.PageShieldPolicyNewParams) (cloudflare.PageShieldPolicyNewResponse, error) -- client.PageShield.Policies.Update(ctx context.Context, policyID string, params cloudflare.PageShieldPolicyUpdateParams) (cloudflare.PageShieldPolicyUpdateResponse, error) -- client.PageShield.Policies.List(ctx context.Context, query cloudflare.PageShieldPolicyListParams) ([]cloudflare.PageShieldPolicyListResponse, error) -- client.PageShield.Policies.Delete(ctx context.Context, policyID string, body cloudflare.PageShieldPolicyDeleteParams) error -- client.PageShield.Policies.Get(ctx context.Context, policyID string, query cloudflare.PageShieldPolicyGetParams) (cloudflare.PageShieldPolicyGetResponse, error) +- client.PageShield.Policies.New(ctx context.Context, params page_shield.PolicyNewParams) (page_shield.PageShieldPageshieldPolicy, error) +- client.PageShield.Policies.Update(ctx context.Context, policyID string, params page_shield.PolicyUpdateParams) (page_shield.PageShieldPageshieldPolicy, error) +- client.PageShield.Policies.List(ctx context.Context, query page_shield.PolicyListParams) ([]page_shield.PageShieldPageshieldPolicy, error) +- client.PageShield.Policies.Delete(ctx context.Context, policyID string, body page_shield.PolicyDeleteParams) error +- client.PageShield.Policies.Get(ctx context.Context, policyID string, query page_shield.PolicyGetParams) (page_shield.PageShieldPageshieldPolicy, error) ## Connections Response Types: -- cloudflare.PageShieldConnectionListResponse -- cloudflare.PageShieldConnectionGetResponse +- page_shield.PageShieldConnection Methods: -- client.PageShield.Connections.List(ctx context.Context, params cloudflare.PageShieldConnectionListParams) ([]cloudflare.PageShieldConnectionListResponse, error) -- client.PageShield.Connections.Get(ctx context.Context, connectionID string, query cloudflare.PageShieldConnectionGetParams) (cloudflare.PageShieldConnectionGetResponse, error) +- client.PageShield.Connections.List(ctx context.Context, params page_shield.ConnectionListParams) ([]page_shield.PageShieldConnection, error) +- client.PageShield.Connections.Get(ctx context.Context, connectionID string, query page_shield.ConnectionGetParams) (page_shield.PageShieldConnection, error) ## Scripts Response Types: -- cloudflare.PageShieldScriptListResponse -- cloudflare.PageShieldScriptGetResponse +- page_shield.PageShieldScript +- page_shield.ScriptGetResponse Methods: -- client.PageShield.Scripts.List(ctx context.Context, params cloudflare.PageShieldScriptListParams) ([]cloudflare.PageShieldScriptListResponse, error) -- client.PageShield.Scripts.Get(ctx context.Context, scriptID string, query cloudflare.PageShieldScriptGetParams) (cloudflare.PageShieldScriptGetResponse, error) +- client.PageShield.Scripts.List(ctx context.Context, params page_shield.ScriptListParams) ([]page_shield.PageShieldScript, error) +- client.PageShield.Scripts.Get(ctx context.Context, scriptID string, query page_shield.ScriptGetParams) (page_shield.ScriptGetResponse, error) # Rulesets Response Types: -- cloudflare.RulesetNewResponse -- cloudflare.RulesetUpdateResponse -- cloudflare.RulesetListResponse -- cloudflare.RulesetGetResponse +- rulesets.RulesetsRulesetResponse +- rulesets.RulesetsRulesetsResponse +- rulesets.RulesetListResponse Methods: -- client.Rulesets.New(ctx context.Context, params cloudflare.RulesetNewParams) (cloudflare.RulesetNewResponse, error) -- client.Rulesets.Update(ctx context.Context, rulesetID string, params cloudflare.RulesetUpdateParams) (cloudflare.RulesetUpdateResponse, error) -- client.Rulesets.List(ctx context.Context, query cloudflare.RulesetListParams) ([]cloudflare.RulesetListResponse, error) -- client.Rulesets.Delete(ctx context.Context, rulesetID string, body cloudflare.RulesetDeleteParams) error -- client.Rulesets.Get(ctx context.Context, rulesetID string, query cloudflare.RulesetGetParams) (cloudflare.RulesetGetResponse, error) +- client.Rulesets.New(ctx context.Context, params rulesets.RulesetNewParams) (rulesets.RulesetsRulesetResponse, error) +- client.Rulesets.Update(ctx context.Context, rulesetID string, params rulesets.RulesetUpdateParams) (rulesets.RulesetsRulesetResponse, error) +- client.Rulesets.List(ctx context.Context, query rulesets.RulesetListParams) (rulesets.RulesetsRulesetsResponse, error) +- client.Rulesets.Delete(ctx context.Context, rulesetID string, body rulesets.RulesetDeleteParams) error +- client.Rulesets.Get(ctx context.Context, rulesetID string, query rulesets.RulesetGetParams) (rulesets.RulesetsRulesetResponse, error) ## Phases -Response Types: - -- cloudflare.RulesetPhaseUpdateResponse -- cloudflare.RulesetPhaseGetResponse - Methods: -- client.Rulesets.Phases.Update(ctx context.Context, rulesetPhase cloudflare.RulesetPhaseUpdateParamsRulesetPhase, params cloudflare.RulesetPhaseUpdateParams) (cloudflare.RulesetPhaseUpdateResponse, error) -- client.Rulesets.Phases.Get(ctx context.Context, rulesetPhase cloudflare.RulesetPhaseGetParamsRulesetPhase, query cloudflare.RulesetPhaseGetParams) (cloudflare.RulesetPhaseGetResponse, error) +- client.Rulesets.Phases.Update(ctx context.Context, rulesetPhase rulesets.PhaseUpdateParamsRulesetPhase, params rulesets.PhaseUpdateParams) (rulesets.RulesetsRulesetResponse, error) +- client.Rulesets.Phases.Get(ctx context.Context, rulesetPhase rulesets.PhaseGetParamsRulesetPhase, query rulesets.PhaseGetParams) (rulesets.RulesetsRulesetResponse, error) ### Versions Response Types: -- cloudflare.RulesetPhaseVersionListResponse -- cloudflare.RulesetPhaseVersionGetResponse +- rulesets.PhaseVersionListResponse Methods: -- client.Rulesets.Phases.Versions.List(ctx context.Context, rulesetPhase cloudflare.RulesetPhaseVersionListParamsRulesetPhase, query cloudflare.RulesetPhaseVersionListParams) ([]cloudflare.RulesetPhaseVersionListResponse, error) -- client.Rulesets.Phases.Versions.Get(ctx context.Context, rulesetPhase cloudflare.RulesetPhaseVersionGetParamsRulesetPhase, rulesetVersion string, query cloudflare.RulesetPhaseVersionGetParams) (cloudflare.RulesetPhaseVersionGetResponse, error) +- client.Rulesets.Phases.Versions.List(ctx context.Context, rulesetPhase rulesets.PhaseVersionListParamsRulesetPhase, query rulesets.PhaseVersionListParams) (rulesets.RulesetsRulesetsResponse, error) +- client.Rulesets.Phases.Versions.Get(ctx context.Context, rulesetPhase rulesets.PhaseVersionGetParamsRulesetPhase, rulesetVersion string, query rulesets.PhaseVersionGetParams) (rulesets.RulesetsRulesetResponse, error) ## Rules -Response Types: - -- cloudflare.RulesetRuleNewResponse -- cloudflare.RulesetRuleDeleteResponse -- cloudflare.RulesetRuleEditResponse - Methods: -- client.Rulesets.Rules.New(ctx context.Context, rulesetID string, params cloudflare.RulesetRuleNewParams) (cloudflare.RulesetRuleNewResponse, error) -- client.Rulesets.Rules.Delete(ctx context.Context, rulesetID string, ruleID string, body cloudflare.RulesetRuleDeleteParams) (cloudflare.RulesetRuleDeleteResponse, error) -- client.Rulesets.Rules.Edit(ctx context.Context, rulesetID string, ruleID string, params cloudflare.RulesetRuleEditParams) (cloudflare.RulesetRuleEditResponse, error) +- client.Rulesets.Rules.New(ctx context.Context, rulesetID string, params rulesets.RuleNewParams) (rulesets.RulesetsRulesetResponse, error) +- client.Rulesets.Rules.Delete(ctx context.Context, rulesetID string, ruleID string, body rulesets.RuleDeleteParams) (rulesets.RulesetsRulesetResponse, error) +- client.Rulesets.Rules.Edit(ctx context.Context, rulesetID string, ruleID string, params rulesets.RuleEditParams) (rulesets.RulesetsRulesetResponse, error) ## Versions Response Types: -- cloudflare.RulesetVersionListResponse -- cloudflare.RulesetVersionGetResponse +- rulesets.VersionListResponse Methods: -- client.Rulesets.Versions.List(ctx context.Context, rulesetID string, query cloudflare.RulesetVersionListParams) ([]cloudflare.RulesetVersionListResponse, error) -- client.Rulesets.Versions.Delete(ctx context.Context, rulesetID string, rulesetVersion string, body cloudflare.RulesetVersionDeleteParams) error -- client.Rulesets.Versions.Get(ctx context.Context, rulesetID string, rulesetVersion string, query cloudflare.RulesetVersionGetParams) (cloudflare.RulesetVersionGetResponse, error) +- client.Rulesets.Versions.List(ctx context.Context, rulesetID string, query rulesets.VersionListParams) (rulesets.RulesetsRulesetsResponse, error) +- client.Rulesets.Versions.Delete(ctx context.Context, rulesetID string, rulesetVersion string, body rulesets.VersionDeleteParams) error +- client.Rulesets.Versions.Get(ctx context.Context, rulesetID string, rulesetVersion string, query rulesets.VersionGetParams) (rulesets.RulesetsRulesetResponse, error) ### ByTags -Response Types: - -- cloudflare.RulesetVersionByTagGetResponse - Methods: -- client.Rulesets.Versions.ByTags.Get(ctx context.Context, rulesetID string, rulesetVersion string, ruleTag string, query cloudflare.RulesetVersionByTagGetParams) (cloudflare.RulesetVersionByTagGetResponse, error) +- client.Rulesets.Versions.ByTags.Get(ctx context.Context, rulesetID string, rulesetVersion string, ruleTag string, query rulesets.VersionByTagGetParams) (rulesets.RulesetsRulesetResponse, error) # URLNormalization Response Types: -- cloudflare.URLNormalizationUpdateResponse -- cloudflare.URLNormalizationGetResponse +- url_normalization.URLNormalizationUpdateResponse +- url_normalization.URLNormalizationGetResponse Methods: -- client.URLNormalization.Update(ctx context.Context, params cloudflare.URLNormalizationUpdateParams) (cloudflare.URLNormalizationUpdateResponse, error) -- client.URLNormalization.Get(ctx context.Context, query cloudflare.URLNormalizationGetParams) (cloudflare.URLNormalizationGetResponse, error) +- client.URLNormalization.Update(ctx context.Context, params url_normalization.URLNormalizationUpdateParams) (url_normalization.URLNormalizationUpdateResponse, error) +- client.URLNormalization.Get(ctx context.Context, query url_normalization.URLNormalizationGetParams) (url_normalization.URLNormalizationGetResponse, error) # Spectrum @@ -2875,11 +2889,11 @@ Methods: Response Types: -- cloudflare.SpectrumAnalyticsAggregateCurrentGetResponse +- spectrum.AnalyticsAggregateCurrentGetResponse Methods: -- client.Spectrum.Analytics.Aggregates.Currents.Get(ctx context.Context, zone string, query cloudflare.SpectrumAnalyticsAggregateCurrentGetParams) ([]cloudflare.SpectrumAnalyticsAggregateCurrentGetResponse, error) +- client.Spectrum.Analytics.Aggregates.Currents.Get(ctx context.Context, zone string, query spectrum.AnalyticsAggregateCurrentGetParams) ([]spectrum.AnalyticsAggregateCurrentGetResponse, error) ### Events @@ -2887,39 +2901,39 @@ Methods: Response Types: -- cloudflare.SpectrumAnalyticsEventBytimeGetResponse +- spectrum.AnalyticsEventBytimeGetResponse Methods: -- client.Spectrum.Analytics.Events.Bytimes.Get(ctx context.Context, zone string, query cloudflare.SpectrumAnalyticsEventBytimeGetParams) (cloudflare.SpectrumAnalyticsEventBytimeGetResponse, error) +- client.Spectrum.Analytics.Events.Bytimes.Get(ctx context.Context, zone string, query spectrum.AnalyticsEventBytimeGetParams) (spectrum.AnalyticsEventBytimeGetResponse, error) #### Summaries Response Types: -- cloudflare.SpectrumAnalyticsEventSummaryGetResponse +- spectrum.AnalyticsEventSummaryGetResponse Methods: -- client.Spectrum.Analytics.Events.Summaries.Get(ctx context.Context, zone string, query cloudflare.SpectrumAnalyticsEventSummaryGetParams) (cloudflare.SpectrumAnalyticsEventSummaryGetResponse, error) +- client.Spectrum.Analytics.Events.Summaries.Get(ctx context.Context, zone string, query spectrum.AnalyticsEventSummaryGetParams) (spectrum.AnalyticsEventSummaryGetResponse, error) ## Apps Response Types: -- cloudflare.SpectrumAppNewResponse -- cloudflare.SpectrumAppUpdateResponse -- cloudflare.SpectrumAppListResponse -- cloudflare.SpectrumAppDeleteResponse -- cloudflare.SpectrumAppGetResponse +- spectrum.AppNewResponse +- spectrum.AppUpdateResponse +- spectrum.AppListResponse +- spectrum.AppDeleteResponse +- spectrum.AppGetResponse Methods: -- client.Spectrum.Apps.New(ctx context.Context, zone string, body cloudflare.SpectrumAppNewParams) (cloudflare.SpectrumAppNewResponse, error) -- client.Spectrum.Apps.Update(ctx context.Context, zone string, appID string, body cloudflare.SpectrumAppUpdateParams) (cloudflare.SpectrumAppUpdateResponse, error) -- client.Spectrum.Apps.List(ctx context.Context, zone string, query cloudflare.SpectrumAppListParams) (shared.V4PagePaginationArray[cloudflare.SpectrumAppListResponse], error) -- client.Spectrum.Apps.Delete(ctx context.Context, zone string, appID string) (cloudflare.SpectrumAppDeleteResponse, error) -- client.Spectrum.Apps.Get(ctx context.Context, zone string, appID string) (cloudflare.SpectrumAppGetResponse, error) +- client.Spectrum.Apps.New(ctx context.Context, zone string, body spectrum.AppNewParams) (spectrum.AppNewResponse, error) +- client.Spectrum.Apps.Update(ctx context.Context, zone string, appID string, body spectrum.AppUpdateParams) (spectrum.AppUpdateResponse, error) +- client.Spectrum.Apps.List(ctx context.Context, zone string, query spectrum.AppListParams) (shared.V4PagePaginationArray[spectrum.AppListResponse], error) +- client.Spectrum.Apps.Delete(ctx context.Context, zone string, appID string) (spectrum.AppDeleteResponse, error) +- client.Spectrum.Apps.Get(ctx context.Context, zone string, appID string) (spectrum.AppGetResponse, error) # Addressing @@ -2927,103 +2941,99 @@ Methods: Response Types: -- cloudflare.AddressingServiceListResponse +- addressing.ServiceListResponse Methods: -- client.Addressing.Services.List(ctx context.Context, query cloudflare.AddressingServiceListParams) ([]cloudflare.AddressingServiceListResponse, error) +- client.Addressing.Services.List(ctx context.Context, query addressing.ServiceListParams) ([]addressing.ServiceListResponse, error) ## AddressMaps Response Types: -- cloudflare.AddressingAddressMapNewResponse -- cloudflare.AddressingAddressMapListResponse -- cloudflare.AddressingAddressMapDeleteResponse -- cloudflare.AddressingAddressMapEditResponse -- cloudflare.AddressingAddressMapGetResponse +- addressing.AddressingAddressMaps +- addressing.AddressMapNewResponse +- addressing.AddressMapDeleteResponse +- addressing.AddressMapGetResponse Methods: -- client.Addressing.AddressMaps.New(ctx context.Context, params cloudflare.AddressingAddressMapNewParams) (cloudflare.AddressingAddressMapNewResponse, error) -- client.Addressing.AddressMaps.List(ctx context.Context, query cloudflare.AddressingAddressMapListParams) ([]cloudflare.AddressingAddressMapListResponse, error) -- client.Addressing.AddressMaps.Delete(ctx context.Context, addressMapID string, body cloudflare.AddressingAddressMapDeleteParams) (cloudflare.AddressingAddressMapDeleteResponse, error) -- client.Addressing.AddressMaps.Edit(ctx context.Context, addressMapID string, params cloudflare.AddressingAddressMapEditParams) (cloudflare.AddressingAddressMapEditResponse, error) -- client.Addressing.AddressMaps.Get(ctx context.Context, addressMapID string, query cloudflare.AddressingAddressMapGetParams) (cloudflare.AddressingAddressMapGetResponse, error) +- client.Addressing.AddressMaps.New(ctx context.Context, params addressing.AddressMapNewParams) (addressing.AddressMapNewResponse, error) +- client.Addressing.AddressMaps.List(ctx context.Context, query addressing.AddressMapListParams) ([]addressing.AddressingAddressMaps, error) +- client.Addressing.AddressMaps.Delete(ctx context.Context, addressMapID string, body addressing.AddressMapDeleteParams) (addressing.AddressMapDeleteResponse, error) +- client.Addressing.AddressMaps.Edit(ctx context.Context, addressMapID string, params addressing.AddressMapEditParams) (addressing.AddressingAddressMaps, error) +- client.Addressing.AddressMaps.Get(ctx context.Context, addressMapID string, query addressing.AddressMapGetParams) (addressing.AddressMapGetResponse, error) ### Accounts Response Types: -- cloudflare.AddressingAddressMapAccountUpdateResponse -- cloudflare.AddressingAddressMapAccountDeleteResponse +- addressing.AddressMapAccountUpdateResponse +- addressing.AddressMapAccountDeleteResponse Methods: -- client.Addressing.AddressMaps.Accounts.Update(ctx context.Context, addressMapID string, body cloudflare.AddressingAddressMapAccountUpdateParams) (cloudflare.AddressingAddressMapAccountUpdateResponse, error) -- client.Addressing.AddressMaps.Accounts.Delete(ctx context.Context, addressMapID string, body cloudflare.AddressingAddressMapAccountDeleteParams) (cloudflare.AddressingAddressMapAccountDeleteResponse, error) +- client.Addressing.AddressMaps.Accounts.Update(ctx context.Context, addressMapID string, body addressing.AddressMapAccountUpdateParams) (addressing.AddressMapAccountUpdateResponse, error) +- client.Addressing.AddressMaps.Accounts.Delete(ctx context.Context, addressMapID string, body addressing.AddressMapAccountDeleteParams) (addressing.AddressMapAccountDeleteResponse, error) ### IPs Response Types: -- cloudflare.AddressingAddressMapIPUpdateResponse -- cloudflare.AddressingAddressMapIPDeleteResponse +- addressing.AddressMapIPUpdateResponse +- addressing.AddressMapIPDeleteResponse Methods: -- client.Addressing.AddressMaps.IPs.Update(ctx context.Context, addressMapID string, ipAddress string, body cloudflare.AddressingAddressMapIPUpdateParams) (cloudflare.AddressingAddressMapIPUpdateResponse, error) -- client.Addressing.AddressMaps.IPs.Delete(ctx context.Context, addressMapID string, ipAddress string, body cloudflare.AddressingAddressMapIPDeleteParams) (cloudflare.AddressingAddressMapIPDeleteResponse, error) +- client.Addressing.AddressMaps.IPs.Update(ctx context.Context, addressMapID string, ipAddress string, body addressing.AddressMapIPUpdateParams) (addressing.AddressMapIPUpdateResponse, error) +- client.Addressing.AddressMaps.IPs.Delete(ctx context.Context, addressMapID string, ipAddress string, body addressing.AddressMapIPDeleteParams) (addressing.AddressMapIPDeleteResponse, error) ### Zones Response Types: -- cloudflare.AddressingAddressMapZoneUpdateResponse -- cloudflare.AddressingAddressMapZoneDeleteResponse +- addressing.AddressMapZoneUpdateResponse +- addressing.AddressMapZoneDeleteResponse Methods: -- client.Addressing.AddressMaps.Zones.Update(ctx context.Context, addressMapID string, body cloudflare.AddressingAddressMapZoneUpdateParams) (cloudflare.AddressingAddressMapZoneUpdateResponse, error) -- client.Addressing.AddressMaps.Zones.Delete(ctx context.Context, addressMapID string, body cloudflare.AddressingAddressMapZoneDeleteParams) (cloudflare.AddressingAddressMapZoneDeleteResponse, error) +- client.Addressing.AddressMaps.Zones.Update(ctx context.Context, addressMapID string, body addressing.AddressMapZoneUpdateParams) (addressing.AddressMapZoneUpdateResponse, error) +- client.Addressing.AddressMaps.Zones.Delete(ctx context.Context, addressMapID string, body addressing.AddressMapZoneDeleteParams) (addressing.AddressMapZoneDeleteResponse, error) ## LOADocuments Response Types: -- cloudflare.AddressingLOADocumentNewResponse +- addressing.LOADocumentNewResponse Methods: -- client.Addressing.LOADocuments.New(ctx context.Context, params cloudflare.AddressingLOADocumentNewParams) (cloudflare.AddressingLOADocumentNewResponse, error) +- client.Addressing.LOADocuments.New(ctx context.Context, params addressing.LOADocumentNewParams) (addressing.LOADocumentNewResponse, error) ### Downloads Response Types: -- cloudflare.AddressingLOADocumentDownloadGetResponse +- addressing.LOADocumentDownloadGetResponse Methods: -- client.Addressing.LOADocuments.Downloads.Get(ctx context.Context, loaDocumentID string, query cloudflare.AddressingLOADocumentDownloadGetParams) (cloudflare.AddressingLOADocumentDownloadGetResponse, error) +- client.Addressing.LOADocuments.Downloads.Get(ctx context.Context, loaDocumentID string, query addressing.LOADocumentDownloadGetParams) (addressing.LOADocumentDownloadGetResponse, error) ## Prefixes Response Types: -- cloudflare.AddressingPrefixNewResponse -- cloudflare.AddressingPrefixListResponse -- cloudflare.AddressingPrefixDeleteResponse -- cloudflare.AddressingPrefixEditResponse -- cloudflare.AddressingPrefixGetResponse +- addressing.AddressingIpamPrefixes +- addressing.PrefixDeleteResponse Methods: -- client.Addressing.Prefixes.New(ctx context.Context, params cloudflare.AddressingPrefixNewParams) (cloudflare.AddressingPrefixNewResponse, error) -- client.Addressing.Prefixes.List(ctx context.Context, query cloudflare.AddressingPrefixListParams) ([]cloudflare.AddressingPrefixListResponse, error) -- client.Addressing.Prefixes.Delete(ctx context.Context, prefixID string, body cloudflare.AddressingPrefixDeleteParams) (cloudflare.AddressingPrefixDeleteResponse, error) -- client.Addressing.Prefixes.Edit(ctx context.Context, prefixID string, params cloudflare.AddressingPrefixEditParams) (cloudflare.AddressingPrefixEditResponse, error) -- client.Addressing.Prefixes.Get(ctx context.Context, prefixID string, query cloudflare.AddressingPrefixGetParams) (cloudflare.AddressingPrefixGetResponse, error) +- client.Addressing.Prefixes.New(ctx context.Context, params addressing.PrefixNewParams) (addressing.AddressingIpamPrefixes, error) +- client.Addressing.Prefixes.List(ctx context.Context, query addressing.PrefixListParams) ([]addressing.AddressingIpamPrefixes, error) +- client.Addressing.Prefixes.Delete(ctx context.Context, prefixID string, body addressing.PrefixDeleteParams) (addressing.PrefixDeleteResponse, error) +- client.Addressing.Prefixes.Edit(ctx context.Context, prefixID string, params addressing.PrefixEditParams) (addressing.AddressingIpamPrefixes, error) +- client.Addressing.Prefixes.Get(ctx context.Context, prefixID string, query addressing.PrefixGetParams) (addressing.AddressingIpamPrefixes, error) ### BGP @@ -3031,67 +3041,62 @@ Methods: Response Types: -- cloudflare.AddressingPrefixBGPBindingNewResponse -- cloudflare.AddressingPrefixBGPBindingListResponse -- cloudflare.AddressingPrefixBGPBindingDeleteResponse -- cloudflare.AddressingPrefixBGPBindingGetResponse +- addressing.AddressingServiceBinding +- addressing.PrefixBGPBindingDeleteResponse Methods: -- client.Addressing.Prefixes.BGP.Bindings.New(ctx context.Context, prefixID string, params cloudflare.AddressingPrefixBGPBindingNewParams) (cloudflare.AddressingPrefixBGPBindingNewResponse, error) -- client.Addressing.Prefixes.BGP.Bindings.List(ctx context.Context, prefixID string, query cloudflare.AddressingPrefixBGPBindingListParams) ([]cloudflare.AddressingPrefixBGPBindingListResponse, error) -- client.Addressing.Prefixes.BGP.Bindings.Delete(ctx context.Context, prefixID string, bindingID string, body cloudflare.AddressingPrefixBGPBindingDeleteParams) (cloudflare.AddressingPrefixBGPBindingDeleteResponse, error) -- client.Addressing.Prefixes.BGP.Bindings.Get(ctx context.Context, prefixID string, bindingID string, query cloudflare.AddressingPrefixBGPBindingGetParams) (cloudflare.AddressingPrefixBGPBindingGetResponse, error) +- client.Addressing.Prefixes.BGP.Bindings.New(ctx context.Context, prefixID string, params addressing.PrefixBGPBindingNewParams) (addressing.AddressingServiceBinding, error) +- client.Addressing.Prefixes.BGP.Bindings.List(ctx context.Context, prefixID string, query addressing.PrefixBGPBindingListParams) ([]addressing.AddressingServiceBinding, error) +- client.Addressing.Prefixes.BGP.Bindings.Delete(ctx context.Context, prefixID string, bindingID string, body addressing.PrefixBGPBindingDeleteParams) (addressing.PrefixBGPBindingDeleteResponse, error) +- client.Addressing.Prefixes.BGP.Bindings.Get(ctx context.Context, prefixID string, bindingID string, query addressing.PrefixBGPBindingGetParams) (addressing.AddressingServiceBinding, error) #### Prefixes Response Types: -- cloudflare.AddressingPrefixBGPPrefixListResponse -- cloudflare.AddressingPrefixBGPPrefixEditResponse -- cloudflare.AddressingPrefixBGPPrefixGetResponse +- addressing.AddressingIpamBGPPrefixes Methods: -- client.Addressing.Prefixes.BGP.Prefixes.List(ctx context.Context, prefixID string, query cloudflare.AddressingPrefixBGPPrefixListParams) ([]cloudflare.AddressingPrefixBGPPrefixListResponse, error) -- client.Addressing.Prefixes.BGP.Prefixes.Edit(ctx context.Context, prefixID string, bgpPrefixID string, params cloudflare.AddressingPrefixBGPPrefixEditParams) (cloudflare.AddressingPrefixBGPPrefixEditResponse, error) -- client.Addressing.Prefixes.BGP.Prefixes.Get(ctx context.Context, prefixID string, bgpPrefixID string, query cloudflare.AddressingPrefixBGPPrefixGetParams) (cloudflare.AddressingPrefixBGPPrefixGetResponse, error) +- client.Addressing.Prefixes.BGP.Prefixes.List(ctx context.Context, prefixID string, query addressing.PrefixBGPPrefixListParams) ([]addressing.AddressingIpamBGPPrefixes, error) +- client.Addressing.Prefixes.BGP.Prefixes.Edit(ctx context.Context, prefixID string, bgpPrefixID string, params addressing.PrefixBGPPrefixEditParams) (addressing.AddressingIpamBGPPrefixes, error) +- client.Addressing.Prefixes.BGP.Prefixes.Get(ctx context.Context, prefixID string, bgpPrefixID string, query addressing.PrefixBGPPrefixGetParams) (addressing.AddressingIpamBGPPrefixes, error) #### Statuses Response Types: -- cloudflare.AddressingPrefixBGPStatusEditResponse -- cloudflare.AddressingPrefixBGPStatusGetResponse +- addressing.PrefixBGPStatusEditResponse +- addressing.PrefixBGPStatusGetResponse Methods: -- client.Addressing.Prefixes.BGP.Statuses.Edit(ctx context.Context, prefixID string, params cloudflare.AddressingPrefixBGPStatusEditParams) (cloudflare.AddressingPrefixBGPStatusEditResponse, error) -- client.Addressing.Prefixes.BGP.Statuses.Get(ctx context.Context, prefixID string, query cloudflare.AddressingPrefixBGPStatusGetParams) (cloudflare.AddressingPrefixBGPStatusGetResponse, error) +- client.Addressing.Prefixes.BGP.Statuses.Edit(ctx context.Context, prefixID string, params addressing.PrefixBGPStatusEditParams) (addressing.PrefixBGPStatusEditResponse, error) +- client.Addressing.Prefixes.BGP.Statuses.Get(ctx context.Context, prefixID string, query addressing.PrefixBGPStatusGetParams) (addressing.PrefixBGPStatusGetResponse, error) ### Delegations Response Types: -- cloudflare.AddressingPrefixDelegationNewResponse -- cloudflare.AddressingPrefixDelegationListResponse -- cloudflare.AddressingPrefixDelegationDeleteResponse +- addressing.AddressingIpamDelegations +- addressing.PrefixDelegationDeleteResponse Methods: -- client.Addressing.Prefixes.Delegations.New(ctx context.Context, prefixID string, params cloudflare.AddressingPrefixDelegationNewParams) (cloudflare.AddressingPrefixDelegationNewResponse, error) -- client.Addressing.Prefixes.Delegations.List(ctx context.Context, prefixID string, query cloudflare.AddressingPrefixDelegationListParams) ([]cloudflare.AddressingPrefixDelegationListResponse, error) -- client.Addressing.Prefixes.Delegations.Delete(ctx context.Context, prefixID string, delegationID string, body cloudflare.AddressingPrefixDelegationDeleteParams) (cloudflare.AddressingPrefixDelegationDeleteResponse, error) +- client.Addressing.Prefixes.Delegations.New(ctx context.Context, prefixID string, params addressing.PrefixDelegationNewParams) (addressing.AddressingIpamDelegations, error) +- client.Addressing.Prefixes.Delegations.List(ctx context.Context, prefixID string, query addressing.PrefixDelegationListParams) ([]addressing.AddressingIpamDelegations, error) +- client.Addressing.Prefixes.Delegations.Delete(ctx context.Context, prefixID string, delegationID string, body addressing.PrefixDelegationDeleteParams) (addressing.PrefixDelegationDeleteResponse, error) # AuditLogs Response Types: -- cloudflare.AuditLogListResponse +- audit_logs.AuditLogListResponse Methods: -- client.AuditLogs.List(ctx context.Context, accountIdentifier string, query cloudflare.AuditLogListParams) (shared.V4PagePaginationArray[cloudflare.AuditLogListResponse], error) +- client.AuditLogs.List(ctx context.Context, accountIdentifier string, query audit_logs.AuditLogListParams) (shared.V4PagePaginationArray[audit_logs.AuditLogListResponse], error) # Billing @@ -3099,23 +3104,23 @@ Methods: Response Types: -- cloudflare.BillingProfileGetResponse +- billing.ProfileGetResponse Methods: -- client.Billing.Profiles.Get(ctx context.Context, accountIdentifier interface{}) (cloudflare.BillingProfileGetResponse, error) +- client.Billing.Profiles.Get(ctx context.Context, accountIdentifier interface{}) (billing.ProfileGetResponse, error) # BrandProtection Response Types: -- cloudflare.BrandProtectionSubmitResponse -- cloudflare.BrandProtectionURLInfoResponse +- brand_protection.IntelPhishingURLInfo +- brand_protection.IntelPhishingURLSubmit Methods: -- client.BrandProtection.Submit(ctx context.Context, params cloudflare.BrandProtectionSubmitParams) (cloudflare.BrandProtectionSubmitResponse, error) -- client.BrandProtection.URLInfo(ctx context.Context, params cloudflare.BrandProtectionURLInfoParams) (cloudflare.BrandProtectionURLInfoResponse, error) +- client.BrandProtection.Submit(ctx context.Context, params brand_protection.BrandProtectionSubmitParams) (brand_protection.IntelPhishingURLSubmit, error) +- client.BrandProtection.URLInfo(ctx context.Context, params brand_protection.BrandProtectionURLInfoParams) (brand_protection.IntelPhishingURLInfo, error) # Diagnostics @@ -3123,11 +3128,11 @@ Methods: Response Types: -- cloudflare.DiagnosticTracerouteNewResponse +- diagnostics.MagicTransitTargetResult Methods: -- client.Diagnostics.Traceroutes.New(ctx context.Context, params cloudflare.DiagnosticTracerouteNewParams) ([]cloudflare.DiagnosticTracerouteNewResponse, error) +- client.Diagnostics.Traceroutes.New(ctx context.Context, params diagnostics.TracerouteNewParams) ([]diagnostics.MagicTransitTargetResult, error) # Images @@ -3135,222 +3140,224 @@ Methods: Response Types: -- cloudflare.ImageV1NewResponse -- cloudflare.ImageV1ListResponse -- cloudflare.ImageV1DeleteResponse -- cloudflare.ImageV1EditResponse -- cloudflare.ImageV1GetResponse +- images.ImagesImage +- images.V1ListResponse +- images.V1DeleteResponse Methods: -- client.Images.V1.New(ctx context.Context, params cloudflare.ImageV1NewParams) (cloudflare.ImageV1NewResponse, error) -- client.Images.V1.List(ctx context.Context, params cloudflare.ImageV1ListParams) (shared.V4PagePagination[cloudflare.ImageV1ListResponse], error) -- client.Images.V1.Delete(ctx context.Context, imageID string, body cloudflare.ImageV1DeleteParams) (cloudflare.ImageV1DeleteResponse, error) -- client.Images.V1.Edit(ctx context.Context, imageID string, params cloudflare.ImageV1EditParams) (cloudflare.ImageV1EditResponse, error) -- client.Images.V1.Get(ctx context.Context, imageID string, query cloudflare.ImageV1GetParams) (cloudflare.ImageV1GetResponse, error) +- client.Images.V1.New(ctx context.Context, params images.V1NewParams) (images.ImagesImage, error) +- client.Images.V1.List(ctx context.Context, params images.V1ListParams) (shared.V4PagePagination[images.V1ListResponse], error) +- client.Images.V1.Delete(ctx context.Context, imageID string, body images.V1DeleteParams) (images.V1DeleteResponse, error) +- client.Images.V1.Edit(ctx context.Context, imageID string, params images.V1EditParams) (images.ImagesImage, error) +- client.Images.V1.Get(ctx context.Context, imageID string, query images.V1GetParams) (images.ImagesImage, error) ### Keys Response Types: -- cloudflare.ImageV1KeyListResponse +- images.ImagesImageKeys Methods: -- client.Images.V1.Keys.List(ctx context.Context, query cloudflare.ImageV1KeyListParams) (cloudflare.ImageV1KeyListResponse, error) +- client.Images.V1.Keys.List(ctx context.Context, query images.V1KeyListParams) (images.ImagesImageKeys, error) ### Stats Response Types: -- cloudflare.ImageV1StatGetResponse +- images.ImagesImagesStats Methods: -- client.Images.V1.Stats.Get(ctx context.Context, query cloudflare.ImageV1StatGetParams) (cloudflare.ImageV1StatGetResponse, error) +- client.Images.V1.Stats.Get(ctx context.Context, query images.V1StatGetParams) (images.ImagesImagesStats, error) ### Variants Response Types: -- cloudflare.ImageV1VariantNewResponse -- cloudflare.ImageV1VariantListResponse -- cloudflare.ImageV1VariantDeleteResponse -- cloudflare.ImageV1VariantEditResponse -- cloudflare.ImageV1VariantGetResponse +- images.ImageVariant +- images.ImageVariants +- images.V1VariantDeleteResponse Methods: -- client.Images.V1.Variants.New(ctx context.Context, params cloudflare.ImageV1VariantNewParams) (cloudflare.ImageV1VariantNewResponse, error) -- client.Images.V1.Variants.List(ctx context.Context, query cloudflare.ImageV1VariantListParams) (cloudflare.ImageV1VariantListResponse, error) -- client.Images.V1.Variants.Delete(ctx context.Context, variantID interface{}, body cloudflare.ImageV1VariantDeleteParams) (cloudflare.ImageV1VariantDeleteResponse, error) -- client.Images.V1.Variants.Edit(ctx context.Context, variantID interface{}, params cloudflare.ImageV1VariantEditParams) (cloudflare.ImageV1VariantEditResponse, error) -- client.Images.V1.Variants.Get(ctx context.Context, variantID interface{}, query cloudflare.ImageV1VariantGetParams) (cloudflare.ImageV1VariantGetResponse, error) +- client.Images.V1.Variants.New(ctx context.Context, params images.V1VariantNewParams) (images.ImageVariant, error) +- client.Images.V1.Variants.List(ctx context.Context, query images.V1VariantListParams) (images.ImageVariants, error) +- client.Images.V1.Variants.Delete(ctx context.Context, variantID interface{}, body images.V1VariantDeleteParams) (images.V1VariantDeleteResponse, error) +- client.Images.V1.Variants.Edit(ctx context.Context, variantID interface{}, params images.V1VariantEditParams) (images.ImageVariant, error) +- client.Images.V1.Variants.Get(ctx context.Context, variantID interface{}, query images.V1VariantGetParams) (images.ImageVariant, error) ### Blobs Methods: -- client.Images.V1.Blobs.Get(ctx context.Context, imageID string, query cloudflare.ImageV1BlobGetParams) (http.Response, error) +- client.Images.V1.Blobs.Get(ctx context.Context, imageID string, query images.V1BlobGetParams) (http.Response, error) ## V2 Response Types: -- cloudflare.ImageV2ListResponse +- images.V2ListResponse Methods: -- client.Images.V2.List(ctx context.Context, params cloudflare.ImageV2ListParams) (cloudflare.ImageV2ListResponse, error) +- client.Images.V2.List(ctx context.Context, params images.V2ListParams) (images.V2ListResponse, error) ### DirectUploads Response Types: -- cloudflare.ImageV2DirectUploadNewResponse +- images.V2DirectUploadNewResponse Methods: -- client.Images.V2.DirectUploads.New(ctx context.Context, params cloudflare.ImageV2DirectUploadNewParams) (cloudflare.ImageV2DirectUploadNewResponse, error) +- client.Images.V2.DirectUploads.New(ctx context.Context, params images.V2DirectUploadNewParams) (images.V2DirectUploadNewResponse, error) # Intel ## ASN +Params Types: + +- intel.IntelASNParam + +Response Types: + +- intel.IntelASN + Methods: -- client.Intel.ASN.Get(ctx context.Context, asn int64, query cloudflare.IntelASNGetParams) (int64, error) +- client.Intel.ASN.Get(ctx context.Context, asn intel.IntelASNParam, query intel.ASNGetParams) (intel.IntelASN, error) ### Subnets Response Types: -- cloudflare.IntelASNSubnetGetResponse +- intel.ASNSubnetGetResponse Methods: -- client.Intel.ASN.Subnets.Get(ctx context.Context, asn int64, query cloudflare.IntelASNSubnetGetParams) (cloudflare.IntelASNSubnetGetResponse, error) +- client.Intel.ASN.Subnets.Get(ctx context.Context, asn intel.IntelASNParam, query intel.ASNSubnetGetParams) (intel.ASNSubnetGetResponse, error) ## DNS Response Types: -- cloudflare.IntelDNSGetResponse +- intel.IntelPassiveDNSByIP Methods: -- client.Intel.DNS.Get(ctx context.Context, params cloudflare.IntelDNSGetParams) (cloudflare.IntelDNSGetResponse, error) +- client.Intel.DNS.Get(ctx context.Context, params intel.DNSGetParams) (intel.IntelPassiveDNSByIP, error) ## Domains Response Types: -- cloudflare.IntelDomainGetResponse +- intel.IntelDomain Methods: -- client.Intel.Domains.Get(ctx context.Context, params cloudflare.IntelDomainGetParams) (cloudflare.IntelDomainGetResponse, error) +- client.Intel.Domains.Get(ctx context.Context, params intel.DomainGetParams) (intel.IntelDomain, error) ### Bulks Response Types: -- cloudflare.IntelDomainBulkGetResponse +- intel.DomainBulkGetResponse Methods: -- client.Intel.Domains.Bulks.Get(ctx context.Context, params cloudflare.IntelDomainBulkGetParams) ([]cloudflare.IntelDomainBulkGetResponse, error) +- client.Intel.Domains.Bulks.Get(ctx context.Context, params intel.DomainBulkGetParams) ([]intel.DomainBulkGetResponse, error) ## DomainHistory Response Types: -- cloudflare.IntelDomainHistoryGetResponse +- intel.IntelDomainHistory Methods: -- client.Intel.DomainHistory.Get(ctx context.Context, params cloudflare.IntelDomainHistoryGetParams) ([]cloudflare.IntelDomainHistoryGetResponse, error) +- client.Intel.DomainHistory.Get(ctx context.Context, params intel.DomainHistoryGetParams) ([]intel.IntelDomainHistory, error) ## IPs Response Types: -- cloudflare.IntelIPGetResponse +- intel.IntelSchemasIP Methods: -- client.Intel.IPs.Get(ctx context.Context, params cloudflare.IntelIPGetParams) ([]cloudflare.IntelIPGetResponse, error) +- client.Intel.IPs.Get(ctx context.Context, params intel.IPGetParams) ([]intel.IntelSchemasIP, error) ## IPLists Response Types: -- cloudflare.IntelIPListGetResponse +- intel.IntelIPList Methods: -- client.Intel.IPLists.Get(ctx context.Context, query cloudflare.IntelIPListGetParams) ([]cloudflare.IntelIPListGetResponse, error) +- client.Intel.IPLists.Get(ctx context.Context, query intel.IPListGetParams) ([]intel.IntelIPList, error) ## Miscategorizations Response Types: -- cloudflare.IntelMiscategorizationNewResponse +- intel.MiscategorizationNewResponse Methods: -- client.Intel.Miscategorizations.New(ctx context.Context, params cloudflare.IntelMiscategorizationNewParams) (cloudflare.IntelMiscategorizationNewResponse, error) +- client.Intel.Miscategorizations.New(ctx context.Context, params intel.MiscategorizationNewParams) (intel.MiscategorizationNewResponse, error) ## Whois Response Types: -- cloudflare.IntelWhoisGetResponse +- intel.IntelWhois Methods: -- client.Intel.Whois.Get(ctx context.Context, params cloudflare.IntelWhoisGetParams) (cloudflare.IntelWhoisGetResponse, error) +- client.Intel.Whois.Get(ctx context.Context, params intel.WhoisGetParams) (intel.IntelWhois, error) ## IndicatorFeeds Response Types: -- cloudflare.IntelIndicatorFeedNewResponse -- cloudflare.IntelIndicatorFeedUpdateResponse -- cloudflare.IntelIndicatorFeedListResponse -- cloudflare.IntelIndicatorFeedGetResponse +- intel.IntelIndicatorFeedItem +- intel.IntelIndicatorFeedMetadata +- intel.IntelUpdateFeed Methods: -- client.Intel.IndicatorFeeds.New(ctx context.Context, params cloudflare.IntelIndicatorFeedNewParams) (cloudflare.IntelIndicatorFeedNewResponse, error) -- client.Intel.IndicatorFeeds.Update(ctx context.Context, feedID int64, params cloudflare.IntelIndicatorFeedUpdateParams) (cloudflare.IntelIndicatorFeedUpdateResponse, error) -- client.Intel.IndicatorFeeds.List(ctx context.Context, query cloudflare.IntelIndicatorFeedListParams) ([]cloudflare.IntelIndicatorFeedListResponse, error) -- client.Intel.IndicatorFeeds.Data(ctx context.Context, feedID int64, query cloudflare.IntelIndicatorFeedDataParams) (string, error) -- client.Intel.IndicatorFeeds.Get(ctx context.Context, feedID int64, query cloudflare.IntelIndicatorFeedGetParams) (cloudflare.IntelIndicatorFeedGetResponse, error) +- client.Intel.IndicatorFeeds.New(ctx context.Context, params intel.IndicatorFeedNewParams) (intel.IntelIndicatorFeedItem, error) +- client.Intel.IndicatorFeeds.Update(ctx context.Context, feedID int64, params intel.IndicatorFeedUpdateParams) (intel.IntelUpdateFeed, error) +- client.Intel.IndicatorFeeds.List(ctx context.Context, query intel.IndicatorFeedListParams) ([]intel.IntelIndicatorFeedItem, error) +- client.Intel.IndicatorFeeds.Data(ctx context.Context, feedID int64, query intel.IndicatorFeedDataParams) (string, error) +- client.Intel.IndicatorFeeds.Get(ctx context.Context, feedID int64, query intel.IndicatorFeedGetParams) (intel.IntelIndicatorFeedMetadata, error) ### Permissions Response Types: -- cloudflare.IntelIndicatorFeedPermissionNewResponse -- cloudflare.IntelIndicatorFeedPermissionListResponse -- cloudflare.IntelIndicatorFeedPermissionDeleteResponse +- intel.IntelPermissionListItem +- intel.IntelPermissionsUpdate Methods: -- client.Intel.IndicatorFeeds.Permissions.New(ctx context.Context, params cloudflare.IntelIndicatorFeedPermissionNewParams) (cloudflare.IntelIndicatorFeedPermissionNewResponse, error) -- client.Intel.IndicatorFeeds.Permissions.List(ctx context.Context, query cloudflare.IntelIndicatorFeedPermissionListParams) ([]cloudflare.IntelIndicatorFeedPermissionListResponse, error) -- client.Intel.IndicatorFeeds.Permissions.Delete(ctx context.Context, params cloudflare.IntelIndicatorFeedPermissionDeleteParams) (cloudflare.IntelIndicatorFeedPermissionDeleteResponse, error) +- client.Intel.IndicatorFeeds.Permissions.New(ctx context.Context, params intel.IndicatorFeedPermissionNewParams) (intel.IntelPermissionsUpdate, error) +- client.Intel.IndicatorFeeds.Permissions.List(ctx context.Context, query intel.IndicatorFeedPermissionListParams) ([]intel.IntelPermissionListItem, error) +- client.Intel.IndicatorFeeds.Permissions.Delete(ctx context.Context, params intel.IndicatorFeedPermissionDeleteParams) (intel.IntelPermissionsUpdate, error) ## Sinkholes Response Types: -- cloudflare.IntelSinkholeListResponse +- intel.IntelSinkholesSinkholeItem Methods: -- client.Intel.Sinkholes.List(ctx context.Context, query cloudflare.IntelSinkholeListParams) ([]cloudflare.IntelSinkholeListResponse, error) +- client.Intel.Sinkholes.List(ctx context.Context, query intel.SinkholeListParams) ([]intel.IntelSinkholesSinkholeItem, error) # MagicTransit @@ -3358,73 +3365,73 @@ Methods: Response Types: -- cloudflare.MagicTransitCfInterconnectUpdateResponse -- cloudflare.MagicTransitCfInterconnectListResponse -- cloudflare.MagicTransitCfInterconnectGetResponse +- magic_transit.CfInterconnectUpdateResponse +- magic_transit.CfInterconnectListResponse +- magic_transit.CfInterconnectGetResponse Methods: -- client.MagicTransit.CfInterconnects.Update(ctx context.Context, accountIdentifier string, tunnelIdentifier string, body cloudflare.MagicTransitCfInterconnectUpdateParams) (cloudflare.MagicTransitCfInterconnectUpdateResponse, error) -- client.MagicTransit.CfInterconnects.List(ctx context.Context, accountIdentifier string) (cloudflare.MagicTransitCfInterconnectListResponse, error) -- client.MagicTransit.CfInterconnects.Get(ctx context.Context, accountIdentifier string, tunnelIdentifier string) (cloudflare.MagicTransitCfInterconnectGetResponse, error) +- client.MagicTransit.CfInterconnects.Update(ctx context.Context, accountIdentifier string, tunnelIdentifier string, body magic_transit.CfInterconnectUpdateParams) (magic_transit.CfInterconnectUpdateResponse, error) +- client.MagicTransit.CfInterconnects.List(ctx context.Context, accountIdentifier string) (magic_transit.CfInterconnectListResponse, error) +- client.MagicTransit.CfInterconnects.Get(ctx context.Context, accountIdentifier string, tunnelIdentifier string) (magic_transit.CfInterconnectGetResponse, error) ## GRETunnels Response Types: -- cloudflare.MagicTransitGRETunnelNewResponse -- cloudflare.MagicTransitGRETunnelUpdateResponse -- cloudflare.MagicTransitGRETunnelListResponse -- cloudflare.MagicTransitGRETunnelDeleteResponse -- cloudflare.MagicTransitGRETunnelGetResponse +- magic_transit.GRETunnelNewResponse +- magic_transit.GRETunnelUpdateResponse +- magic_transit.GRETunnelListResponse +- magic_transit.GRETunnelDeleteResponse +- magic_transit.GRETunnelGetResponse Methods: -- client.MagicTransit.GRETunnels.New(ctx context.Context, accountIdentifier string, body cloudflare.MagicTransitGRETunnelNewParams) (cloudflare.MagicTransitGRETunnelNewResponse, error) -- client.MagicTransit.GRETunnels.Update(ctx context.Context, accountIdentifier string, tunnelIdentifier string, body cloudflare.MagicTransitGRETunnelUpdateParams) (cloudflare.MagicTransitGRETunnelUpdateResponse, error) -- client.MagicTransit.GRETunnels.List(ctx context.Context, accountIdentifier string) (cloudflare.MagicTransitGRETunnelListResponse, error) -- client.MagicTransit.GRETunnels.Delete(ctx context.Context, accountIdentifier string, tunnelIdentifier string) (cloudflare.MagicTransitGRETunnelDeleteResponse, error) -- client.MagicTransit.GRETunnels.Get(ctx context.Context, accountIdentifier string, tunnelIdentifier string) (cloudflare.MagicTransitGRETunnelGetResponse, error) +- client.MagicTransit.GRETunnels.New(ctx context.Context, accountIdentifier string, body magic_transit.GRETunnelNewParams) (magic_transit.GRETunnelNewResponse, error) +- client.MagicTransit.GRETunnels.Update(ctx context.Context, accountIdentifier string, tunnelIdentifier string, body magic_transit.GRETunnelUpdateParams) (magic_transit.GRETunnelUpdateResponse, error) +- client.MagicTransit.GRETunnels.List(ctx context.Context, accountIdentifier string) (magic_transit.GRETunnelListResponse, error) +- client.MagicTransit.GRETunnels.Delete(ctx context.Context, accountIdentifier string, tunnelIdentifier string) (magic_transit.GRETunnelDeleteResponse, error) +- client.MagicTransit.GRETunnels.Get(ctx context.Context, accountIdentifier string, tunnelIdentifier string) (magic_transit.GRETunnelGetResponse, error) ## IPSECTunnels Response Types: -- cloudflare.MagicTransitIPSECTunnelNewResponse -- cloudflare.MagicTransitIPSECTunnelUpdateResponse -- cloudflare.MagicTransitIPSECTunnelListResponse -- cloudflare.MagicTransitIPSECTunnelDeleteResponse -- cloudflare.MagicTransitIPSECTunnelGetResponse -- cloudflare.MagicTransitIPSECTunnelPSKGenerateResponse +- magic_transit.IPSECTunnelNewResponse +- magic_transit.IPSECTunnelUpdateResponse +- magic_transit.IPSECTunnelListResponse +- magic_transit.IPSECTunnelDeleteResponse +- magic_transit.IPSECTunnelGetResponse +- magic_transit.IPSECTunnelPSKGenerateResponse Methods: -- client.MagicTransit.IPSECTunnels.New(ctx context.Context, accountIdentifier string, body cloudflare.MagicTransitIPSECTunnelNewParams) (cloudflare.MagicTransitIPSECTunnelNewResponse, error) -- client.MagicTransit.IPSECTunnels.Update(ctx context.Context, accountIdentifier string, tunnelIdentifier string, body cloudflare.MagicTransitIPSECTunnelUpdateParams) (cloudflare.MagicTransitIPSECTunnelUpdateResponse, error) -- client.MagicTransit.IPSECTunnels.List(ctx context.Context, accountIdentifier string) (cloudflare.MagicTransitIPSECTunnelListResponse, error) -- client.MagicTransit.IPSECTunnels.Delete(ctx context.Context, accountIdentifier string, tunnelIdentifier string) (cloudflare.MagicTransitIPSECTunnelDeleteResponse, error) -- client.MagicTransit.IPSECTunnels.Get(ctx context.Context, accountIdentifier string, tunnelIdentifier string) (cloudflare.MagicTransitIPSECTunnelGetResponse, error) -- client.MagicTransit.IPSECTunnels.PSKGenerate(ctx context.Context, accountIdentifier string, tunnelIdentifier string) (cloudflare.MagicTransitIPSECTunnelPSKGenerateResponse, error) +- client.MagicTransit.IPSECTunnels.New(ctx context.Context, accountIdentifier string, body magic_transit.IPSECTunnelNewParams) (magic_transit.IPSECTunnelNewResponse, error) +- client.MagicTransit.IPSECTunnels.Update(ctx context.Context, accountIdentifier string, tunnelIdentifier string, body magic_transit.IPSECTunnelUpdateParams) (magic_transit.IPSECTunnelUpdateResponse, error) +- client.MagicTransit.IPSECTunnels.List(ctx context.Context, accountIdentifier string) (magic_transit.IPSECTunnelListResponse, error) +- client.MagicTransit.IPSECTunnels.Delete(ctx context.Context, accountIdentifier string, tunnelIdentifier string) (magic_transit.IPSECTunnelDeleteResponse, error) +- client.MagicTransit.IPSECTunnels.Get(ctx context.Context, accountIdentifier string, tunnelIdentifier string) (magic_transit.IPSECTunnelGetResponse, error) +- client.MagicTransit.IPSECTunnels.PSKGenerate(ctx context.Context, accountIdentifier string, tunnelIdentifier string) (magic_transit.IPSECTunnelPSKGenerateResponse, error) ## Routes Response Types: -- cloudflare.MagicTransitRouteNewResponse -- cloudflare.MagicTransitRouteUpdateResponse -- cloudflare.MagicTransitRouteListResponse -- cloudflare.MagicTransitRouteDeleteResponse -- cloudflare.MagicTransitRouteEmptyResponse -- cloudflare.MagicTransitRouteGetResponse +- magic_transit.RouteNewResponse +- magic_transit.RouteUpdateResponse +- magic_transit.RouteListResponse +- magic_transit.RouteDeleteResponse +- magic_transit.RouteEmptyResponse +- magic_transit.RouteGetResponse Methods: -- client.MagicTransit.Routes.New(ctx context.Context, accountIdentifier string, body cloudflare.MagicTransitRouteNewParams) (cloudflare.MagicTransitRouteNewResponse, error) -- client.MagicTransit.Routes.Update(ctx context.Context, accountIdentifier string, routeIdentifier string, body cloudflare.MagicTransitRouteUpdateParams) (cloudflare.MagicTransitRouteUpdateResponse, error) -- client.MagicTransit.Routes.List(ctx context.Context, accountIdentifier string) (cloudflare.MagicTransitRouteListResponse, error) -- client.MagicTransit.Routes.Delete(ctx context.Context, accountIdentifier string, routeIdentifier string) (cloudflare.MagicTransitRouteDeleteResponse, error) -- client.MagicTransit.Routes.Empty(ctx context.Context, accountIdentifier string, body cloudflare.MagicTransitRouteEmptyParams) (cloudflare.MagicTransitRouteEmptyResponse, error) -- client.MagicTransit.Routes.Get(ctx context.Context, accountIdentifier string, routeIdentifier string) (cloudflare.MagicTransitRouteGetResponse, error) +- client.MagicTransit.Routes.New(ctx context.Context, accountIdentifier string, body magic_transit.RouteNewParams) (magic_transit.RouteNewResponse, error) +- client.MagicTransit.Routes.Update(ctx context.Context, accountIdentifier string, routeIdentifier string, body magic_transit.RouteUpdateParams) (magic_transit.RouteUpdateResponse, error) +- client.MagicTransit.Routes.List(ctx context.Context, accountIdentifier string) (magic_transit.RouteListResponse, error) +- client.MagicTransit.Routes.Delete(ctx context.Context, accountIdentifier string, routeIdentifier string) (magic_transit.RouteDeleteResponse, error) +- client.MagicTransit.Routes.Empty(ctx context.Context, accountIdentifier string, body magic_transit.RouteEmptyParams) (magic_transit.RouteEmptyResponse, error) +- client.MagicTransit.Routes.Get(ctx context.Context, accountIdentifier string, routeIdentifier string) (magic_transit.RouteGetResponse, error) # MagicNetworkMonitoring @@ -3432,127 +3439,111 @@ Methods: Response Types: -- cloudflare.MagicNetworkMonitoringConfigNewResponse -- cloudflare.MagicNetworkMonitoringConfigUpdateResponse -- cloudflare.MagicNetworkMonitoringConfigDeleteResponse -- cloudflare.MagicNetworkMonitoringConfigEditResponse -- cloudflare.MagicNetworkMonitoringConfigGetResponse +- magic_network_monitoring.MagicVisibilityMNMConfig Methods: -- client.MagicNetworkMonitoring.Configs.New(ctx context.Context, accountIdentifier interface{}) (cloudflare.MagicNetworkMonitoringConfigNewResponse, error) -- client.MagicNetworkMonitoring.Configs.Update(ctx context.Context, accountIdentifier interface{}) (cloudflare.MagicNetworkMonitoringConfigUpdateResponse, error) -- client.MagicNetworkMonitoring.Configs.Delete(ctx context.Context, accountIdentifier interface{}) (cloudflare.MagicNetworkMonitoringConfigDeleteResponse, error) -- client.MagicNetworkMonitoring.Configs.Edit(ctx context.Context, accountIdentifier interface{}) (cloudflare.MagicNetworkMonitoringConfigEditResponse, error) -- client.MagicNetworkMonitoring.Configs.Get(ctx context.Context, accountIdentifier interface{}) (cloudflare.MagicNetworkMonitoringConfigGetResponse, error) +- client.MagicNetworkMonitoring.Configs.New(ctx context.Context, accountIdentifier interface{}) (magic_network_monitoring.MagicVisibilityMNMConfig, error) +- client.MagicNetworkMonitoring.Configs.Update(ctx context.Context, accountIdentifier interface{}) (magic_network_monitoring.MagicVisibilityMNMConfig, error) +- client.MagicNetworkMonitoring.Configs.Delete(ctx context.Context, accountIdentifier interface{}) (magic_network_monitoring.MagicVisibilityMNMConfig, error) +- client.MagicNetworkMonitoring.Configs.Edit(ctx context.Context, accountIdentifier interface{}) (magic_network_monitoring.MagicVisibilityMNMConfig, error) +- client.MagicNetworkMonitoring.Configs.Get(ctx context.Context, accountIdentifier interface{}) (magic_network_monitoring.MagicVisibilityMNMConfig, error) ### Full -Response Types: - -- cloudflare.MagicNetworkMonitoringConfigFullGetResponse - Methods: -- client.MagicNetworkMonitoring.Configs.Full.Get(ctx context.Context, accountIdentifier interface{}) (cloudflare.MagicNetworkMonitoringConfigFullGetResponse, error) +- client.MagicNetworkMonitoring.Configs.Full.Get(ctx context.Context, accountIdentifier interface{}) (magic_network_monitoring.MagicVisibilityMNMConfig, error) ## Rules Response Types: -- cloudflare.MagicNetworkMonitoringRuleNewResponse -- cloudflare.MagicNetworkMonitoringRuleUpdateResponse -- cloudflare.MagicNetworkMonitoringRuleListResponse -- cloudflare.MagicNetworkMonitoringRuleDeleteResponse -- cloudflare.MagicNetworkMonitoringRuleEditResponse -- cloudflare.MagicNetworkMonitoringRuleGetResponse +- magic_network_monitoring.MagicVisibilityMNMRule Methods: -- client.MagicNetworkMonitoring.Rules.New(ctx context.Context, accountIdentifier interface{}) (cloudflare.MagicNetworkMonitoringRuleNewResponse, error) -- client.MagicNetworkMonitoring.Rules.Update(ctx context.Context, accountIdentifier interface{}) (cloudflare.MagicNetworkMonitoringRuleUpdateResponse, error) -- client.MagicNetworkMonitoring.Rules.List(ctx context.Context, accountIdentifier interface{}) ([]cloudflare.MagicNetworkMonitoringRuleListResponse, error) -- client.MagicNetworkMonitoring.Rules.Delete(ctx context.Context, accountIdentifier interface{}, ruleIdentifier interface{}) (cloudflare.MagicNetworkMonitoringRuleDeleteResponse, error) -- client.MagicNetworkMonitoring.Rules.Edit(ctx context.Context, accountIdentifier interface{}, ruleIdentifier interface{}) (cloudflare.MagicNetworkMonitoringRuleEditResponse, error) -- client.MagicNetworkMonitoring.Rules.Get(ctx context.Context, accountIdentifier interface{}, ruleIdentifier interface{}) (cloudflare.MagicNetworkMonitoringRuleGetResponse, error) +- client.MagicNetworkMonitoring.Rules.New(ctx context.Context, accountIdentifier interface{}) (magic_network_monitoring.MagicVisibilityMNMRule, error) +- client.MagicNetworkMonitoring.Rules.Update(ctx context.Context, accountIdentifier interface{}) (magic_network_monitoring.MagicVisibilityMNMRule, error) +- client.MagicNetworkMonitoring.Rules.List(ctx context.Context, accountIdentifier interface{}) ([]magic_network_monitoring.MagicVisibilityMNMRule, error) +- client.MagicNetworkMonitoring.Rules.Delete(ctx context.Context, accountIdentifier interface{}, ruleIdentifier interface{}) (magic_network_monitoring.MagicVisibilityMNMRule, error) +- client.MagicNetworkMonitoring.Rules.Edit(ctx context.Context, accountIdentifier interface{}, ruleIdentifier interface{}) (magic_network_monitoring.MagicVisibilityMNMRule, error) +- client.MagicNetworkMonitoring.Rules.Get(ctx context.Context, accountIdentifier interface{}, ruleIdentifier interface{}) (magic_network_monitoring.MagicVisibilityMNMRule, error) ### Advertisements Response Types: -- cloudflare.MagicNetworkMonitoringRuleAdvertisementEditResponse +- magic_network_monitoring.MagicVisibilityMNMRuleAdvertisable Methods: -- client.MagicNetworkMonitoring.Rules.Advertisements.Edit(ctx context.Context, accountIdentifier interface{}, ruleIdentifier interface{}) (cloudflare.MagicNetworkMonitoringRuleAdvertisementEditResponse, error) +- client.MagicNetworkMonitoring.Rules.Advertisements.Edit(ctx context.Context, accountIdentifier interface{}, ruleIdentifier interface{}) (magic_network_monitoring.MagicVisibilityMNMRuleAdvertisable, error) # MTLSCertificates Response Types: -- cloudflare.MTLSCertificateNewResponse -- cloudflare.MTLSCertificateListResponse -- cloudflare.MTLSCertificateDeleteResponse -- cloudflare.MTLSCertificateGetResponse +- mtls_certificates.TLSCertificatesAndHostnamesCertificateObjectPost +- mtls_certificates.TLSCertificatesAndHostnamesComponentsSchemasCertificateObject Methods: -- client.MTLSCertificates.New(ctx context.Context, params cloudflare.MTLSCertificateNewParams) (cloudflare.MTLSCertificateNewResponse, error) -- client.MTLSCertificates.List(ctx context.Context, query cloudflare.MTLSCertificateListParams) ([]cloudflare.MTLSCertificateListResponse, error) -- client.MTLSCertificates.Delete(ctx context.Context, mtlsCertificateID string, body cloudflare.MTLSCertificateDeleteParams) (cloudflare.MTLSCertificateDeleteResponse, error) -- client.MTLSCertificates.Get(ctx context.Context, mtlsCertificateID string, query cloudflare.MTLSCertificateGetParams) (cloudflare.MTLSCertificateGetResponse, error) +- client.MTLSCertificates.New(ctx context.Context, params mtls_certificates.MTLSCertificateNewParams) (mtls_certificates.TLSCertificatesAndHostnamesCertificateObjectPost, error) +- client.MTLSCertificates.List(ctx context.Context, query mtls_certificates.MTLSCertificateListParams) ([]mtls_certificates.TLSCertificatesAndHostnamesComponentsSchemasCertificateObject, error) +- client.MTLSCertificates.Delete(ctx context.Context, mtlsCertificateID string, body mtls_certificates.MTLSCertificateDeleteParams) (mtls_certificates.TLSCertificatesAndHostnamesComponentsSchemasCertificateObject, error) +- client.MTLSCertificates.Get(ctx context.Context, mtlsCertificateID string, query mtls_certificates.MTLSCertificateGetParams) (mtls_certificates.TLSCertificatesAndHostnamesComponentsSchemasCertificateObject, error) ## Associations Response Types: -- cloudflare.MTLSCertificateAssociationGetResponse +- mtls_certificates.TLSCertificatesAndHostnamesAssociationObject Methods: -- client.MTLSCertificates.Associations.Get(ctx context.Context, mtlsCertificateID string, query cloudflare.MTLSCertificateAssociationGetParams) ([]cloudflare.MTLSCertificateAssociationGetResponse, error) +- client.MTLSCertificates.Associations.Get(ctx context.Context, mtlsCertificateID string, query mtls_certificates.AssociationGetParams) ([]mtls_certificates.TLSCertificatesAndHostnamesAssociationObject, error) # Pages ## Projects +Params Types: + +- pages.PagesDeploymentsParam + Response Types: -- cloudflare.PageProjectNewResponse -- cloudflare.PageProjectListResponse -- cloudflare.PageProjectDeleteResponse -- cloudflare.PageProjectEditResponse -- cloudflare.PageProjectGetResponse -- cloudflare.PageProjectPurgeBuildCacheResponse +- pages.PagesDeployments +- pages.PagesProjects +- pages.ProjectNewResponse +- pages.ProjectDeleteResponse +- pages.ProjectEditResponse +- pages.ProjectPurgeBuildCacheResponse Methods: -- client.Pages.Projects.New(ctx context.Context, params cloudflare.PageProjectNewParams) (cloudflare.PageProjectNewResponse, error) -- client.Pages.Projects.List(ctx context.Context, query cloudflare.PageProjectListParams) ([]cloudflare.PageProjectListResponse, error) -- client.Pages.Projects.Delete(ctx context.Context, projectName string, body cloudflare.PageProjectDeleteParams) (cloudflare.PageProjectDeleteResponse, error) -- client.Pages.Projects.Edit(ctx context.Context, projectName string, params cloudflare.PageProjectEditParams) (cloudflare.PageProjectEditResponse, error) -- client.Pages.Projects.Get(ctx context.Context, projectName string, query cloudflare.PageProjectGetParams) (cloudflare.PageProjectGetResponse, error) -- client.Pages.Projects.PurgeBuildCache(ctx context.Context, projectName string, body cloudflare.PageProjectPurgeBuildCacheParams) (cloudflare.PageProjectPurgeBuildCacheResponse, error) +- client.Pages.Projects.New(ctx context.Context, params pages.ProjectNewParams) (pages.ProjectNewResponse, error) +- client.Pages.Projects.List(ctx context.Context, query pages.ProjectListParams) ([]pages.PagesDeployments, error) +- client.Pages.Projects.Delete(ctx context.Context, projectName string, body pages.ProjectDeleteParams) (pages.ProjectDeleteResponse, error) +- client.Pages.Projects.Edit(ctx context.Context, projectName string, params pages.ProjectEditParams) (pages.ProjectEditResponse, error) +- client.Pages.Projects.Get(ctx context.Context, projectName string, query pages.ProjectGetParams) (pages.PagesProjects, error) +- client.Pages.Projects.PurgeBuildCache(ctx context.Context, projectName string, body pages.ProjectPurgeBuildCacheParams) (pages.ProjectPurgeBuildCacheResponse, error) ### Deployments Response Types: -- cloudflare.PageProjectDeploymentNewResponse -- cloudflare.PageProjectDeploymentListResponse -- cloudflare.PageProjectDeploymentDeleteResponse -- cloudflare.PageProjectDeploymentGetResponse -- cloudflare.PageProjectDeploymentRetryResponse -- cloudflare.PageProjectDeploymentRollbackResponse +- pages.ProjectDeploymentDeleteResponse Methods: -- client.Pages.Projects.Deployments.New(ctx context.Context, projectName string, params cloudflare.PageProjectDeploymentNewParams) (cloudflare.PageProjectDeploymentNewResponse, error) -- client.Pages.Projects.Deployments.List(ctx context.Context, projectName string, query cloudflare.PageProjectDeploymentListParams) ([]cloudflare.PageProjectDeploymentListResponse, error) -- client.Pages.Projects.Deployments.Delete(ctx context.Context, projectName string, deploymentID string, body cloudflare.PageProjectDeploymentDeleteParams) (cloudflare.PageProjectDeploymentDeleteResponse, error) -- client.Pages.Projects.Deployments.Get(ctx context.Context, projectName string, deploymentID string, query cloudflare.PageProjectDeploymentGetParams) (cloudflare.PageProjectDeploymentGetResponse, error) -- client.Pages.Projects.Deployments.Retry(ctx context.Context, projectName string, deploymentID string, body cloudflare.PageProjectDeploymentRetryParams) (cloudflare.PageProjectDeploymentRetryResponse, error) -- client.Pages.Projects.Deployments.Rollback(ctx context.Context, projectName string, deploymentID string, body cloudflare.PageProjectDeploymentRollbackParams) (cloudflare.PageProjectDeploymentRollbackResponse, error) +- client.Pages.Projects.Deployments.New(ctx context.Context, projectName string, params pages.ProjectDeploymentNewParams) (pages.PagesDeployments, error) +- client.Pages.Projects.Deployments.List(ctx context.Context, projectName string, query pages.ProjectDeploymentListParams) ([]pages.PagesDeployments, error) +- client.Pages.Projects.Deployments.Delete(ctx context.Context, projectName string, deploymentID string, body pages.ProjectDeploymentDeleteParams) (pages.ProjectDeploymentDeleteResponse, error) +- client.Pages.Projects.Deployments.Get(ctx context.Context, projectName string, deploymentID string, query pages.ProjectDeploymentGetParams) (pages.PagesDeployments, error) +- client.Pages.Projects.Deployments.Retry(ctx context.Context, projectName string, deploymentID string, body pages.ProjectDeploymentRetryParams) (pages.PagesDeployments, error) +- client.Pages.Projects.Deployments.Rollback(ctx context.Context, projectName string, deploymentID string, body pages.ProjectDeploymentRollbackParams) (pages.PagesDeployments, error) #### History @@ -3560,64 +3551,62 @@ Methods: Response Types: -- cloudflare.PageProjectDeploymentHistoryLogGetResponse +- pages.ProjectDeploymentHistoryLogGetResponse Methods: -- client.Pages.Projects.Deployments.History.Logs.Get(ctx context.Context, projectName string, deploymentID string, query cloudflare.PageProjectDeploymentHistoryLogGetParams) (cloudflare.PageProjectDeploymentHistoryLogGetResponse, error) +- client.Pages.Projects.Deployments.History.Logs.Get(ctx context.Context, projectName string, deploymentID string, query pages.ProjectDeploymentHistoryLogGetParams) (pages.ProjectDeploymentHistoryLogGetResponse, error) ### Domains Response Types: -- cloudflare.PageProjectDomainNewResponse -- cloudflare.PageProjectDomainListResponse -- cloudflare.PageProjectDomainDeleteResponse -- cloudflare.PageProjectDomainEditResponse -- cloudflare.PageProjectDomainGetResponse +- pages.ProjectDomainNewResponse +- pages.ProjectDomainListResponse +- pages.ProjectDomainDeleteResponse +- pages.ProjectDomainEditResponse +- pages.ProjectDomainGetResponse Methods: -- client.Pages.Projects.Domains.New(ctx context.Context, projectName string, params cloudflare.PageProjectDomainNewParams) (cloudflare.PageProjectDomainNewResponse, error) -- client.Pages.Projects.Domains.List(ctx context.Context, projectName string, query cloudflare.PageProjectDomainListParams) ([]cloudflare.PageProjectDomainListResponse, error) -- client.Pages.Projects.Domains.Delete(ctx context.Context, projectName string, domainName string, body cloudflare.PageProjectDomainDeleteParams) (cloudflare.PageProjectDomainDeleteResponse, error) -- client.Pages.Projects.Domains.Edit(ctx context.Context, projectName string, domainName string, body cloudflare.PageProjectDomainEditParams) (cloudflare.PageProjectDomainEditResponse, error) -- client.Pages.Projects.Domains.Get(ctx context.Context, projectName string, domainName string, query cloudflare.PageProjectDomainGetParams) (cloudflare.PageProjectDomainGetResponse, error) +- client.Pages.Projects.Domains.New(ctx context.Context, projectName string, params pages.ProjectDomainNewParams) (pages.ProjectDomainNewResponse, error) +- client.Pages.Projects.Domains.List(ctx context.Context, projectName string, query pages.ProjectDomainListParams) ([]pages.ProjectDomainListResponse, error) +- client.Pages.Projects.Domains.Delete(ctx context.Context, projectName string, domainName string, body pages.ProjectDomainDeleteParams) (pages.ProjectDomainDeleteResponse, error) +- client.Pages.Projects.Domains.Edit(ctx context.Context, projectName string, domainName string, body pages.ProjectDomainEditParams) (pages.ProjectDomainEditResponse, error) +- client.Pages.Projects.Domains.Get(ctx context.Context, projectName string, domainName string, query pages.ProjectDomainGetParams) (pages.ProjectDomainGetResponse, error) # PCAPs Response Types: -- cloudflare.PCAPNewResponse -- cloudflare.PCAPListResponse -- cloudflare.PCAPGetResponse +- pcaps.PCAPNewResponse +- pcaps.PCAPListResponse +- pcaps.PCAPGetResponse Methods: -- client.PCAPs.New(ctx context.Context, params cloudflare.PCAPNewParams) (cloudflare.PCAPNewResponse, error) -- client.PCAPs.List(ctx context.Context, query cloudflare.PCAPListParams) ([]cloudflare.PCAPListResponse, error) -- client.PCAPs.Get(ctx context.Context, pcapID string, query cloudflare.PCAPGetParams) (cloudflare.PCAPGetResponse, error) +- client.PCAPs.New(ctx context.Context, params pcaps.PCAPNewParams) (pcaps.PCAPNewResponse, error) +- client.PCAPs.List(ctx context.Context, query pcaps.PCAPListParams) ([]pcaps.PCAPListResponse, error) +- client.PCAPs.Get(ctx context.Context, pcapID string, query pcaps.PCAPGetParams) (pcaps.PCAPGetResponse, error) ## Ownerships Response Types: -- cloudflare.PCAPOwnershipNewResponse -- cloudflare.PCAPOwnershipGetResponse -- cloudflare.PCAPOwnershipValidateResponse +- pcaps.MagicVisibilityPCAPsOwnership Methods: -- client.PCAPs.Ownerships.New(ctx context.Context, params cloudflare.PCAPOwnershipNewParams) (cloudflare.PCAPOwnershipNewResponse, error) -- client.PCAPs.Ownerships.Delete(ctx context.Context, ownershipID string, body cloudflare.PCAPOwnershipDeleteParams) error -- client.PCAPs.Ownerships.Get(ctx context.Context, query cloudflare.PCAPOwnershipGetParams) ([]cloudflare.PCAPOwnershipGetResponse, error) -- client.PCAPs.Ownerships.Validate(ctx context.Context, params cloudflare.PCAPOwnershipValidateParams) (cloudflare.PCAPOwnershipValidateResponse, error) +- client.PCAPs.Ownerships.New(ctx context.Context, params pcaps.OwnershipNewParams) (pcaps.MagicVisibilityPCAPsOwnership, error) +- client.PCAPs.Ownerships.Delete(ctx context.Context, ownershipID string, body pcaps.OwnershipDeleteParams) error +- client.PCAPs.Ownerships.Get(ctx context.Context, query pcaps.OwnershipGetParams) ([]pcaps.MagicVisibilityPCAPsOwnership, error) +- client.PCAPs.Ownerships.Validate(ctx context.Context, params pcaps.OwnershipValidateParams) (pcaps.MagicVisibilityPCAPsOwnership, error) ## Downloads Methods: -- client.PCAPs.Downloads.Get(ctx context.Context, pcapID string, query cloudflare.PCAPDownloadGetParams) (http.Response, error) +- client.PCAPs.Downloads.Get(ctx context.Context, pcapID string, query pcaps.DownloadGetParams) (http.Response, error) # Registrar @@ -3625,15 +3614,15 @@ Methods: Response Types: -- cloudflare.RegistrarDomainUpdateResponse -- cloudflare.RegistrarDomainListResponse -- cloudflare.RegistrarDomainGetResponse +- registrar.DomainUpdateResponse +- registrar.DomainListResponse +- registrar.DomainGetResponse Methods: -- client.Registrar.Domains.Update(ctx context.Context, domainName string, params cloudflare.RegistrarDomainUpdateParams) (cloudflare.RegistrarDomainUpdateResponse, error) -- client.Registrar.Domains.List(ctx context.Context, query cloudflare.RegistrarDomainListParams) ([]cloudflare.RegistrarDomainListResponse, error) -- client.Registrar.Domains.Get(ctx context.Context, domainName string, query cloudflare.RegistrarDomainGetParams) (cloudflare.RegistrarDomainGetResponse, error) +- client.Registrar.Domains.Update(ctx context.Context, domainName string, params registrar.DomainUpdateParams) (registrar.DomainUpdateResponse, error) +- client.Registrar.Domains.List(ctx context.Context, query registrar.DomainListParams) ([]registrar.DomainListResponse, error) +- client.Registrar.Domains.Get(ctx context.Context, domainName string, query registrar.DomainGetParams) (registrar.DomainGetResponse, error) # RequestTracers @@ -3641,12 +3630,12 @@ Methods: Response Types: -- cloudflare.RequestTracerTrace -- cloudflare.RequestTracerTraceNewResponse +- request_tracers.RequestTracerTrace +- request_tracers.TraceNewResponse Methods: -- client.RequestTracers.Traces.New(ctx context.Context, accountIdentifier string, body cloudflare.RequestTracerTraceNewParams) (cloudflare.RequestTracerTraceNewResponse, error) +- client.RequestTracers.Traces.New(ctx context.Context, accountIdentifier string, body request_tracers.TraceNewParams) (request_tracers.TraceNewResponse, error) # Rules @@ -3654,47 +3643,47 @@ Methods: Response Types: -- cloudflare.RuleListNewResponse -- cloudflare.RuleListUpdateResponse -- cloudflare.RuleListListResponse -- cloudflare.RuleListDeleteResponse -- cloudflare.RuleListGetResponse +- rules.ListsList +- rules.ListNewResponse +- rules.ListUpdateResponse +- rules.ListDeleteResponse +- rules.ListGetResponse Methods: -- client.Rules.Lists.New(ctx context.Context, params cloudflare.RuleListNewParams) ([]cloudflare.RuleListNewResponse, error) -- client.Rules.Lists.Update(ctx context.Context, listID string, params cloudflare.RuleListUpdateParams) ([]cloudflare.RuleListUpdateResponse, error) -- client.Rules.Lists.List(ctx context.Context, query cloudflare.RuleListListParams) ([]cloudflare.RuleListListResponse, error) -- client.Rules.Lists.Delete(ctx context.Context, listID string, body cloudflare.RuleListDeleteParams) (cloudflare.RuleListDeleteResponse, error) -- client.Rules.Lists.Get(ctx context.Context, listID string, query cloudflare.RuleListGetParams) ([]cloudflare.RuleListGetResponse, error) +- client.Rules.Lists.New(ctx context.Context, params rules.ListNewParams) (rules.ListsList, error) +- client.Rules.Lists.Update(ctx context.Context, listID string, params rules.ListUpdateParams) (rules.ListsList, error) +- client.Rules.Lists.List(ctx context.Context, query rules.ListListParams) ([]rules.ListsList, error) +- client.Rules.Lists.Delete(ctx context.Context, listID string, body rules.ListDeleteParams) (rules.ListDeleteResponse, error) +- client.Rules.Lists.Get(ctx context.Context, listID string, query rules.ListGetParams) (rules.ListsList, error) ### BulkOperations Response Types: -- cloudflare.RuleListBulkOperationGetResponse +- rules.ListBulkOperationGetResponse Methods: -- client.Rules.Lists.BulkOperations.Get(ctx context.Context, accountIdentifier string, operationID string) ([]cloudflare.RuleListBulkOperationGetResponse, error) +- client.Rules.Lists.BulkOperations.Get(ctx context.Context, accountIdentifier string, operationID string) ([]rules.ListBulkOperationGetResponse, error) ### Items Response Types: -- cloudflare.RuleListItemNewResponse -- cloudflare.RuleListItemUpdateResponse -- cloudflare.RuleListItemListResponse -- cloudflare.RuleListItemDeleteResponse -- cloudflare.RuleListItemGetResponse +- rules.ListItemNewResponse +- rules.ListItemUpdateResponse +- rules.ListItemListResponse +- rules.ListItemDeleteResponse +- rules.ListItemGetResponse Methods: -- client.Rules.Lists.Items.New(ctx context.Context, listID string, params cloudflare.RuleListItemNewParams) (cloudflare.RuleListItemNewResponse, error) -- client.Rules.Lists.Items.Update(ctx context.Context, listID string, params cloudflare.RuleListItemUpdateParams) (cloudflare.RuleListItemUpdateResponse, error) -- client.Rules.Lists.Items.List(ctx context.Context, listID string, params cloudflare.RuleListItemListParams) ([]cloudflare.RuleListItemListResponse, error) -- client.Rules.Lists.Items.Delete(ctx context.Context, listID string, params cloudflare.RuleListItemDeleteParams) (cloudflare.RuleListItemDeleteResponse, error) -- client.Rules.Lists.Items.Get(ctx context.Context, accountIdentifier string, listID string, itemID string) (cloudflare.RuleListItemGetResponse, error) +- client.Rules.Lists.Items.New(ctx context.Context, listID string, params rules.ListItemNewParams) (rules.ListItemNewResponse, error) +- client.Rules.Lists.Items.Update(ctx context.Context, listID string, params rules.ListItemUpdateParams) (rules.ListItemUpdateResponse, error) +- client.Rules.Lists.Items.List(ctx context.Context, listID string, params rules.ListItemListParams) ([]rules.ListItemListResponse, error) +- client.Rules.Lists.Items.Delete(ctx context.Context, listID string, params rules.ListItemDeleteParams) (rules.ListItemDeleteResponse, error) +- client.Rules.Lists.Items.Get(ctx context.Context, accountIdentifier string, listID string, itemID string) (rules.ListItemGetResponse, error) # Storage @@ -3702,207 +3691,196 @@ Methods: Response Types: -- cloudflare.StorageAnalyticsListResponse -- cloudflare.StorageAnalyticsStoredResponse +- storage.WorkersKVComponentsSchemasResult +- storage.WorkersKVSchemasResult Methods: -- client.Storage.Analytics.List(ctx context.Context, params cloudflare.StorageAnalyticsListParams) (cloudflare.StorageAnalyticsListResponse, error) -- client.Storage.Analytics.Stored(ctx context.Context, params cloudflare.StorageAnalyticsStoredParams) (cloudflare.StorageAnalyticsStoredResponse, error) +- client.Storage.Analytics.List(ctx context.Context, params storage.AnalyticsListParams) (storage.WorkersKVSchemasResult, error) +- client.Storage.Analytics.Stored(ctx context.Context, params storage.AnalyticsStoredParams) (storage.WorkersKVComponentsSchemasResult, error) # Stream Response Types: -- cloudflare.StreamListResponse -- cloudflare.StreamGetResponse +- stream.StreamVideos Methods: -- client.Stream.New(ctx context.Context, params cloudflare.StreamNewParams) error -- client.Stream.List(ctx context.Context, params cloudflare.StreamListParams) ([]cloudflare.StreamListResponse, error) -- client.Stream.Delete(ctx context.Context, identifier string, body cloudflare.StreamDeleteParams) error -- client.Stream.Get(ctx context.Context, identifier string, query cloudflare.StreamGetParams) (cloudflare.StreamGetResponse, error) +- client.Stream.New(ctx context.Context, params stream.StreamNewParams) error +- client.Stream.List(ctx context.Context, params stream.StreamListParams) ([]stream.StreamVideos, error) +- client.Stream.Delete(ctx context.Context, identifier string, body stream.StreamDeleteParams) error +- client.Stream.Get(ctx context.Context, identifier string, query stream.StreamGetParams) (stream.StreamVideos, error) ## AudioTracks Response Types: -- cloudflare.StreamAudioTrackDeleteResponse -- cloudflare.StreamAudioTrackCopyResponse -- cloudflare.StreamAudioTrackEditResponse -- cloudflare.StreamAudioTrackGetResponse +- stream.StreamAdditionalAudio +- stream.AudioTrackDeleteResponse Methods: -- client.Stream.AudioTracks.Delete(ctx context.Context, identifier string, audioIdentifier string, body cloudflare.StreamAudioTrackDeleteParams) (cloudflare.StreamAudioTrackDeleteResponse, error) -- client.Stream.AudioTracks.Copy(ctx context.Context, identifier string, params cloudflare.StreamAudioTrackCopyParams) (cloudflare.StreamAudioTrackCopyResponse, error) -- client.Stream.AudioTracks.Edit(ctx context.Context, identifier string, audioIdentifier string, params cloudflare.StreamAudioTrackEditParams) (cloudflare.StreamAudioTrackEditResponse, error) -- client.Stream.AudioTracks.Get(ctx context.Context, identifier string, query cloudflare.StreamAudioTrackGetParams) ([]cloudflare.StreamAudioTrackGetResponse, error) +- client.Stream.AudioTracks.Delete(ctx context.Context, identifier string, audioIdentifier string, body stream.AudioTrackDeleteParams) (stream.AudioTrackDeleteResponse, error) +- client.Stream.AudioTracks.Copy(ctx context.Context, identifier string, params stream.AudioTrackCopyParams) (stream.StreamAdditionalAudio, error) +- client.Stream.AudioTracks.Edit(ctx context.Context, identifier string, audioIdentifier string, params stream.AudioTrackEditParams) (stream.StreamAdditionalAudio, error) +- client.Stream.AudioTracks.Get(ctx context.Context, identifier string, query stream.AudioTrackGetParams) ([]stream.StreamAdditionalAudio, error) ## Videos Response Types: -- cloudflare.StreamVideoStorageUsageResponse +- stream.VideoStorageUsageResponse Methods: -- client.Stream.Videos.StorageUsage(ctx context.Context, params cloudflare.StreamVideoStorageUsageParams) (cloudflare.StreamVideoStorageUsageResponse, error) +- client.Stream.Videos.StorageUsage(ctx context.Context, params stream.VideoStorageUsageParams) (stream.VideoStorageUsageResponse, error) ## Clips Response Types: -- cloudflare.StreamClipNewResponse +- stream.StreamClipping Methods: -- client.Stream.Clips.New(ctx context.Context, params cloudflare.StreamClipNewParams) (cloudflare.StreamClipNewResponse, error) +- client.Stream.Clips.New(ctx context.Context, params stream.ClipNewParams) (stream.StreamClipping, error) ## Copies -Response Types: - -- cloudflare.StreamCopyNewResponse - Methods: -- client.Stream.Copies.New(ctx context.Context, params cloudflare.StreamCopyNewParams) (cloudflare.StreamCopyNewResponse, error) +- client.Stream.Copies.New(ctx context.Context, params stream.CopyNewParams) (stream.StreamVideos, error) ## DirectUploads Response Types: -- cloudflare.StreamDirectUploadNewResponse +- stream.DirectUploadNewResponse Methods: -- client.Stream.DirectUploads.New(ctx context.Context, params cloudflare.StreamDirectUploadNewParams) (cloudflare.StreamDirectUploadNewResponse, error) +- client.Stream.DirectUploads.New(ctx context.Context, params stream.DirectUploadNewParams) (stream.DirectUploadNewResponse, error) ## Keys Response Types: -- cloudflare.StreamKeyNewResponse -- cloudflare.StreamKeyDeleteResponse -- cloudflare.StreamKeyGetResponse +- stream.StreamKeys +- stream.KeyDeleteResponse +- stream.KeyGetResponse Methods: -- client.Stream.Keys.New(ctx context.Context, body cloudflare.StreamKeyNewParams) (cloudflare.StreamKeyNewResponse, error) -- client.Stream.Keys.Delete(ctx context.Context, identifier string, body cloudflare.StreamKeyDeleteParams) (cloudflare.StreamKeyDeleteResponse, error) -- client.Stream.Keys.Get(ctx context.Context, query cloudflare.StreamKeyGetParams) ([]cloudflare.StreamKeyGetResponse, error) +- client.Stream.Keys.New(ctx context.Context, body stream.KeyNewParams) (stream.StreamKeys, error) +- client.Stream.Keys.Delete(ctx context.Context, identifier string, body stream.KeyDeleteParams) (stream.KeyDeleteResponse, error) +- client.Stream.Keys.Get(ctx context.Context, query stream.KeyGetParams) ([]stream.KeyGetResponse, error) ## LiveInputs Response Types: -- cloudflare.StreamLiveInputNewResponse -- cloudflare.StreamLiveInputUpdateResponse -- cloudflare.StreamLiveInputListResponse -- cloudflare.StreamLiveInputGetResponse +- stream.StreamLiveInput +- stream.LiveInputListResponse Methods: -- client.Stream.LiveInputs.New(ctx context.Context, params cloudflare.StreamLiveInputNewParams) (cloudflare.StreamLiveInputNewResponse, error) -- client.Stream.LiveInputs.Update(ctx context.Context, liveInputIdentifier string, params cloudflare.StreamLiveInputUpdateParams) (cloudflare.StreamLiveInputUpdateResponse, error) -- client.Stream.LiveInputs.List(ctx context.Context, params cloudflare.StreamLiveInputListParams) (cloudflare.StreamLiveInputListResponse, error) -- client.Stream.LiveInputs.Delete(ctx context.Context, liveInputIdentifier string, body cloudflare.StreamLiveInputDeleteParams) error -- client.Stream.LiveInputs.Get(ctx context.Context, liveInputIdentifier string, query cloudflare.StreamLiveInputGetParams) (cloudflare.StreamLiveInputGetResponse, error) +- client.Stream.LiveInputs.New(ctx context.Context, params stream.LiveInputNewParams) (stream.StreamLiveInput, error) +- client.Stream.LiveInputs.Update(ctx context.Context, liveInputIdentifier string, params stream.LiveInputUpdateParams) (stream.StreamLiveInput, error) +- client.Stream.LiveInputs.List(ctx context.Context, params stream.LiveInputListParams) (stream.LiveInputListResponse, error) +- client.Stream.LiveInputs.Delete(ctx context.Context, liveInputIdentifier string, body stream.LiveInputDeleteParams) error +- client.Stream.LiveInputs.Get(ctx context.Context, liveInputIdentifier string, query stream.LiveInputGetParams) (stream.StreamLiveInput, error) ### Outputs Response Types: -- cloudflare.StreamLiveInputOutputNewResponse -- cloudflare.StreamLiveInputOutputUpdateResponse -- cloudflare.StreamLiveInputOutputListResponse +- stream.StreamOutput Methods: -- client.Stream.LiveInputs.Outputs.New(ctx context.Context, liveInputIdentifier string, params cloudflare.StreamLiveInputOutputNewParams) (cloudflare.StreamLiveInputOutputNewResponse, error) -- client.Stream.LiveInputs.Outputs.Update(ctx context.Context, liveInputIdentifier string, outputIdentifier string, params cloudflare.StreamLiveInputOutputUpdateParams) (cloudflare.StreamLiveInputOutputUpdateResponse, error) -- client.Stream.LiveInputs.Outputs.List(ctx context.Context, liveInputIdentifier string, query cloudflare.StreamLiveInputOutputListParams) ([]cloudflare.StreamLiveInputOutputListResponse, error) -- client.Stream.LiveInputs.Outputs.Delete(ctx context.Context, liveInputIdentifier string, outputIdentifier string, body cloudflare.StreamLiveInputOutputDeleteParams) error +- client.Stream.LiveInputs.Outputs.New(ctx context.Context, liveInputIdentifier string, params stream.LiveInputOutputNewParams) (stream.StreamOutput, error) +- client.Stream.LiveInputs.Outputs.Update(ctx context.Context, liveInputIdentifier string, outputIdentifier string, params stream.LiveInputOutputUpdateParams) (stream.StreamOutput, error) +- client.Stream.LiveInputs.Outputs.List(ctx context.Context, liveInputIdentifier string, query stream.LiveInputOutputListParams) ([]stream.StreamOutput, error) +- client.Stream.LiveInputs.Outputs.Delete(ctx context.Context, liveInputIdentifier string, outputIdentifier string, body stream.LiveInputOutputDeleteParams) error ## Watermarks Response Types: -- cloudflare.StreamWatermarkNewResponse -- cloudflare.StreamWatermarkListResponse -- cloudflare.StreamWatermarkDeleteResponse -- cloudflare.StreamWatermarkGetResponse +- stream.StreamWatermarks +- stream.WatermarkNewResponse +- stream.WatermarkDeleteResponse +- stream.WatermarkGetResponse Methods: -- client.Stream.Watermarks.New(ctx context.Context, params cloudflare.StreamWatermarkNewParams) (cloudflare.StreamWatermarkNewResponse, error) -- client.Stream.Watermarks.List(ctx context.Context, query cloudflare.StreamWatermarkListParams) ([]cloudflare.StreamWatermarkListResponse, error) -- client.Stream.Watermarks.Delete(ctx context.Context, identifier string, body cloudflare.StreamWatermarkDeleteParams) (cloudflare.StreamWatermarkDeleteResponse, error) -- client.Stream.Watermarks.Get(ctx context.Context, identifier string, query cloudflare.StreamWatermarkGetParams) (cloudflare.StreamWatermarkGetResponse, error) +- client.Stream.Watermarks.New(ctx context.Context, params stream.WatermarkNewParams) (stream.WatermarkNewResponse, error) +- client.Stream.Watermarks.List(ctx context.Context, query stream.WatermarkListParams) ([]stream.StreamWatermarks, error) +- client.Stream.Watermarks.Delete(ctx context.Context, identifier string, body stream.WatermarkDeleteParams) (stream.WatermarkDeleteResponse, error) +- client.Stream.Watermarks.Get(ctx context.Context, identifier string, query stream.WatermarkGetParams) (stream.WatermarkGetResponse, error) ## Webhooks Response Types: -- cloudflare.StreamWebhookUpdateResponse -- cloudflare.StreamWebhookDeleteResponse -- cloudflare.StreamWebhookGetResponse +- stream.WebhookUpdateResponse +- stream.WebhookDeleteResponse +- stream.WebhookGetResponse Methods: -- client.Stream.Webhooks.Update(ctx context.Context, params cloudflare.StreamWebhookUpdateParams) (cloudflare.StreamWebhookUpdateResponse, error) -- client.Stream.Webhooks.Delete(ctx context.Context, body cloudflare.StreamWebhookDeleteParams) (cloudflare.StreamWebhookDeleteResponse, error) -- client.Stream.Webhooks.Get(ctx context.Context, query cloudflare.StreamWebhookGetParams) (cloudflare.StreamWebhookGetResponse, error) +- client.Stream.Webhooks.Update(ctx context.Context, params stream.WebhookUpdateParams) (stream.WebhookUpdateResponse, error) +- client.Stream.Webhooks.Delete(ctx context.Context, body stream.WebhookDeleteParams) (stream.WebhookDeleteResponse, error) +- client.Stream.Webhooks.Get(ctx context.Context, query stream.WebhookGetParams) (stream.WebhookGetResponse, error) ## Captions Response Types: -- cloudflare.StreamCaptionUpdateResponse -- cloudflare.StreamCaptionDeleteResponse -- cloudflare.StreamCaptionGetResponse +- stream.StreamCaptions +- stream.CaptionUpdateResponse +- stream.CaptionDeleteResponse Methods: -- client.Stream.Captions.Update(ctx context.Context, identifier string, language string, params cloudflare.StreamCaptionUpdateParams) (cloudflare.StreamCaptionUpdateResponse, error) -- client.Stream.Captions.Delete(ctx context.Context, identifier string, language string, body cloudflare.StreamCaptionDeleteParams) (cloudflare.StreamCaptionDeleteResponse, error) -- client.Stream.Captions.Get(ctx context.Context, identifier string, query cloudflare.StreamCaptionGetParams) ([]cloudflare.StreamCaptionGetResponse, error) +- client.Stream.Captions.Update(ctx context.Context, identifier string, language string, params stream.CaptionUpdateParams) (stream.CaptionUpdateResponse, error) +- client.Stream.Captions.Delete(ctx context.Context, identifier string, language string, body stream.CaptionDeleteParams) (stream.CaptionDeleteResponse, error) +- client.Stream.Captions.Get(ctx context.Context, identifier string, query stream.CaptionGetParams) ([]stream.StreamCaptions, error) ## Downloads Response Types: -- cloudflare.StreamDownloadNewResponse -- cloudflare.StreamDownloadDeleteResponse -- cloudflare.StreamDownloadGetResponse +- stream.DownloadNewResponse +- stream.DownloadDeleteResponse +- stream.DownloadGetResponse Methods: -- client.Stream.Downloads.New(ctx context.Context, identifier string, body cloudflare.StreamDownloadNewParams) (cloudflare.StreamDownloadNewResponse, error) -- client.Stream.Downloads.Delete(ctx context.Context, identifier string, body cloudflare.StreamDownloadDeleteParams) (cloudflare.StreamDownloadDeleteResponse, error) -- client.Stream.Downloads.Get(ctx context.Context, identifier string, query cloudflare.StreamDownloadGetParams) (cloudflare.StreamDownloadGetResponse, error) +- client.Stream.Downloads.New(ctx context.Context, identifier string, body stream.DownloadNewParams) (stream.DownloadNewResponse, error) +- client.Stream.Downloads.Delete(ctx context.Context, identifier string, body stream.DownloadDeleteParams) (stream.DownloadDeleteResponse, error) +- client.Stream.Downloads.Get(ctx context.Context, identifier string, query stream.DownloadGetParams) (stream.DownloadGetResponse, error) ## Embeds Response Types: -- cloudflare.StreamEmbedGetResponse +- stream.EmbedGetResponse Methods: -- client.Stream.Embeds.Get(ctx context.Context, identifier string, query cloudflare.StreamEmbedGetParams) (cloudflare.StreamEmbedGetResponse, error) +- client.Stream.Embeds.Get(ctx context.Context, identifier string, query stream.EmbedGetParams) (stream.EmbedGetResponse, error) ## Tokens Response Types: -- cloudflare.StreamTokenNewResponse +- stream.TokenNewResponse Methods: -- client.Stream.Tokens.New(ctx context.Context, identifier string, params cloudflare.StreamTokenNewParams) (cloudflare.StreamTokenNewResponse, error) +- client.Stream.Tokens.New(ctx context.Context, identifier string, params stream.TokenNewParams) (stream.TokenNewResponse, error) # Alerting @@ -3910,11 +3888,11 @@ Methods: Response Types: -- cloudflare.AlertingV3ListResponse +- alerting.V3ListResponse Methods: -- client.Alerting.V3.List(ctx context.Context, query cloudflare.AlertingV3ListParams) (cloudflare.AlertingV3ListResponse, error) +- client.Alerting.V3.List(ctx context.Context, query alerting.V3ListParams) (alerting.V3ListResponse, error) ### Destinations @@ -3922,73 +3900,71 @@ Methods: Response Types: -- cloudflare.AlertingV3DestinationEligibleGetResponse +- alerting.V3DestinationEligibleGetResponse Methods: -- client.Alerting.V3.Destinations.Eligible.Get(ctx context.Context, query cloudflare.AlertingV3DestinationEligibleGetParams) (cloudflare.AlertingV3DestinationEligibleGetResponse, error) +- client.Alerting.V3.Destinations.Eligible.Get(ctx context.Context, query alerting.V3DestinationEligibleGetParams) (alerting.V3DestinationEligibleGetResponse, error) #### Pagerduty Response Types: -- cloudflare.AlertingV3DestinationPagerdutyNewResponse -- cloudflare.AlertingV3DestinationPagerdutyDeleteResponse -- cloudflare.AlertingV3DestinationPagerdutyGetResponse -- cloudflare.AlertingV3DestinationPagerdutyLinkResponse +- alerting.AaaPagerduty +- alerting.V3DestinationPagerdutyNewResponse +- alerting.V3DestinationPagerdutyDeleteResponse +- alerting.V3DestinationPagerdutyLinkResponse Methods: -- client.Alerting.V3.Destinations.Pagerduty.New(ctx context.Context, body cloudflare.AlertingV3DestinationPagerdutyNewParams) (cloudflare.AlertingV3DestinationPagerdutyNewResponse, error) -- client.Alerting.V3.Destinations.Pagerduty.Delete(ctx context.Context, body cloudflare.AlertingV3DestinationPagerdutyDeleteParams) (cloudflare.AlertingV3DestinationPagerdutyDeleteResponse, error) -- client.Alerting.V3.Destinations.Pagerduty.Get(ctx context.Context, query cloudflare.AlertingV3DestinationPagerdutyGetParams) ([]cloudflare.AlertingV3DestinationPagerdutyGetResponse, error) -- client.Alerting.V3.Destinations.Pagerduty.Link(ctx context.Context, tokenID string, query cloudflare.AlertingV3DestinationPagerdutyLinkParams) (cloudflare.AlertingV3DestinationPagerdutyLinkResponse, error) +- client.Alerting.V3.Destinations.Pagerduty.New(ctx context.Context, body alerting.V3DestinationPagerdutyNewParams) (alerting.V3DestinationPagerdutyNewResponse, error) +- client.Alerting.V3.Destinations.Pagerduty.Delete(ctx context.Context, body alerting.V3DestinationPagerdutyDeleteParams) (alerting.V3DestinationPagerdutyDeleteResponse, error) +- client.Alerting.V3.Destinations.Pagerduty.Get(ctx context.Context, query alerting.V3DestinationPagerdutyGetParams) ([]alerting.AaaPagerduty, error) +- client.Alerting.V3.Destinations.Pagerduty.Link(ctx context.Context, tokenID string, query alerting.V3DestinationPagerdutyLinkParams) (alerting.V3DestinationPagerdutyLinkResponse, error) #### Webhooks Response Types: -- cloudflare.AlertingV3DestinationWebhookNewResponse -- cloudflare.AlertingV3DestinationWebhookUpdateResponse -- cloudflare.AlertingV3DestinationWebhookListResponse -- cloudflare.AlertingV3DestinationWebhookDeleteResponse -- cloudflare.AlertingV3DestinationWebhookGetResponse +- alerting.AaaWebhooks +- alerting.V3DestinationWebhookNewResponse +- alerting.V3DestinationWebhookUpdateResponse +- alerting.V3DestinationWebhookDeleteResponse Methods: -- client.Alerting.V3.Destinations.Webhooks.New(ctx context.Context, params cloudflare.AlertingV3DestinationWebhookNewParams) (cloudflare.AlertingV3DestinationWebhookNewResponse, error) -- client.Alerting.V3.Destinations.Webhooks.Update(ctx context.Context, webhookID string, params cloudflare.AlertingV3DestinationWebhookUpdateParams) (cloudflare.AlertingV3DestinationWebhookUpdateResponse, error) -- client.Alerting.V3.Destinations.Webhooks.List(ctx context.Context, query cloudflare.AlertingV3DestinationWebhookListParams) ([]cloudflare.AlertingV3DestinationWebhookListResponse, error) -- client.Alerting.V3.Destinations.Webhooks.Delete(ctx context.Context, webhookID string, body cloudflare.AlertingV3DestinationWebhookDeleteParams) (cloudflare.AlertingV3DestinationWebhookDeleteResponse, error) -- client.Alerting.V3.Destinations.Webhooks.Get(ctx context.Context, webhookID string, query cloudflare.AlertingV3DestinationWebhookGetParams) (cloudflare.AlertingV3DestinationWebhookGetResponse, error) +- client.Alerting.V3.Destinations.Webhooks.New(ctx context.Context, params alerting.V3DestinationWebhookNewParams) (alerting.V3DestinationWebhookNewResponse, error) +- client.Alerting.V3.Destinations.Webhooks.Update(ctx context.Context, webhookID string, params alerting.V3DestinationWebhookUpdateParams) (alerting.V3DestinationWebhookUpdateResponse, error) +- client.Alerting.V3.Destinations.Webhooks.List(ctx context.Context, query alerting.V3DestinationWebhookListParams) ([]alerting.AaaWebhooks, error) +- client.Alerting.V3.Destinations.Webhooks.Delete(ctx context.Context, webhookID string, body alerting.V3DestinationWebhookDeleteParams) (alerting.V3DestinationWebhookDeleteResponse, error) +- client.Alerting.V3.Destinations.Webhooks.Get(ctx context.Context, webhookID string, query alerting.V3DestinationWebhookGetParams) (alerting.AaaWebhooks, error) ### Histories Response Types: -- cloudflare.AlertingV3HistoryListResponse +- alerting.AaaHistory Methods: -- client.Alerting.V3.Histories.List(ctx context.Context, params cloudflare.AlertingV3HistoryListParams) (shared.V4PagePaginationArray[cloudflare.AlertingV3HistoryListResponse], error) +- client.Alerting.V3.Histories.List(ctx context.Context, params alerting.V3HistoryListParams) (shared.V4PagePaginationArray[alerting.AaaHistory], error) ### Policies Response Types: -- cloudflare.AlertingV3PolicyNewResponse -- cloudflare.AlertingV3PolicyUpdateResponse -- cloudflare.AlertingV3PolicyListResponse -- cloudflare.AlertingV3PolicyDeleteResponse -- cloudflare.AlertingV3PolicyGetResponse +- alerting.AaaPolicies +- alerting.V3PolicyNewResponse +- alerting.V3PolicyUpdateResponse +- alerting.V3PolicyDeleteResponse Methods: -- client.Alerting.V3.Policies.New(ctx context.Context, params cloudflare.AlertingV3PolicyNewParams) (cloudflare.AlertingV3PolicyNewResponse, error) -- client.Alerting.V3.Policies.Update(ctx context.Context, policyID string, params cloudflare.AlertingV3PolicyUpdateParams) (cloudflare.AlertingV3PolicyUpdateResponse, error) -- client.Alerting.V3.Policies.List(ctx context.Context, query cloudflare.AlertingV3PolicyListParams) ([]cloudflare.AlertingV3PolicyListResponse, error) -- client.Alerting.V3.Policies.Delete(ctx context.Context, policyID string, body cloudflare.AlertingV3PolicyDeleteParams) (cloudflare.AlertingV3PolicyDeleteResponse, error) -- client.Alerting.V3.Policies.Get(ctx context.Context, policyID string, query cloudflare.AlertingV3PolicyGetParams) (cloudflare.AlertingV3PolicyGetResponse, error) +- client.Alerting.V3.Policies.New(ctx context.Context, params alerting.V3PolicyNewParams) (alerting.V3PolicyNewResponse, error) +- client.Alerting.V3.Policies.Update(ctx context.Context, policyID string, params alerting.V3PolicyUpdateParams) (alerting.V3PolicyUpdateResponse, error) +- client.Alerting.V3.Policies.List(ctx context.Context, query alerting.V3PolicyListParams) ([]alerting.AaaPolicies, error) +- client.Alerting.V3.Policies.Delete(ctx context.Context, policyID string, body alerting.V3PolicyDeleteParams) (alerting.V3PolicyDeleteResponse, error) +- client.Alerting.V3.Policies.Get(ctx context.Context, policyID string, query alerting.V3PolicyGetParams) (alerting.AaaPolicies, error) # D1 @@ -3996,19 +3972,18 @@ Methods: Response Types: -- cloudflare.D1DatabaseNewResponse -- cloudflare.D1DatabaseListResponse -- cloudflare.D1DatabaseDeleteResponse -- cloudflare.D1DatabaseGetResponse -- cloudflare.D1DatabaseQueryResponse +- d1.D1CreateDatabase +- d1.D1DatabaseDetails +- d1.D1QueryResult +- d1.DatabaseDeleteResponse Methods: -- client.D1.Database.New(ctx context.Context, params cloudflare.D1DatabaseNewParams) (cloudflare.D1DatabaseNewResponse, error) -- client.D1.Database.List(ctx context.Context, params cloudflare.D1DatabaseListParams) (shared.V4PagePaginationArray[cloudflare.D1DatabaseListResponse], error) -- client.D1.Database.Delete(ctx context.Context, accountIdentifier string, databaseIdentifier string) (cloudflare.D1DatabaseDeleteResponse, error) -- client.D1.Database.Get(ctx context.Context, accountIdentifier string, databaseIdentifier string) (cloudflare.D1DatabaseGetResponse, error) -- client.D1.Database.Query(ctx context.Context, accountIdentifier string, databaseIdentifier string, body cloudflare.D1DatabaseQueryParams) ([]cloudflare.D1DatabaseQueryResponse, error) +- client.D1.Database.New(ctx context.Context, params d1.DatabaseNewParams) (d1.D1CreateDatabase, error) +- client.D1.Database.List(ctx context.Context, params d1.DatabaseListParams) (shared.V4PagePaginationArray[d1.D1CreateDatabase], error) +- client.D1.Database.Delete(ctx context.Context, accountIdentifier string, databaseIdentifier string) (d1.DatabaseDeleteResponse, error) +- client.D1.Database.Get(ctx context.Context, accountIdentifier string, databaseIdentifier string) (d1.D1DatabaseDetails, error) +- client.D1.Database.Query(ctx context.Context, accountIdentifier string, databaseIdentifier string, body d1.DatabaseQueryParams) ([]d1.D1QueryResult, error) # R2 @@ -4016,51 +3991,48 @@ Methods: Response Types: -- cloudflare.R2BucketNewResponse -- cloudflare.R2BucketListResponse -- cloudflare.R2BucketDeleteResponse -- cloudflare.R2BucketGetResponse +- r2.R2Bucket +- r2.BucketDeleteResponse Methods: -- client.R2.Buckets.New(ctx context.Context, params cloudflare.R2BucketNewParams) (cloudflare.R2BucketNewResponse, error) -- client.R2.Buckets.List(ctx context.Context, params cloudflare.R2BucketListParams) ([]cloudflare.R2BucketListResponse, error) -- client.R2.Buckets.Delete(ctx context.Context, bucketName string, body cloudflare.R2BucketDeleteParams) (cloudflare.R2BucketDeleteResponse, error) -- client.R2.Buckets.Get(ctx context.Context, bucketName string, query cloudflare.R2BucketGetParams) (cloudflare.R2BucketGetResponse, error) +- client.R2.Buckets.New(ctx context.Context, params r2.BucketNewParams) (r2.R2Bucket, error) +- client.R2.Buckets.List(ctx context.Context, params r2.BucketListParams) ([]r2.R2Bucket, error) +- client.R2.Buckets.Delete(ctx context.Context, bucketName string, body r2.BucketDeleteParams) (r2.BucketDeleteResponse, error) +- client.R2.Buckets.Get(ctx context.Context, bucketName string, query r2.BucketGetParams) (r2.R2Bucket, error) ## Sippy Response Types: -- cloudflare.R2SippyUpdateResponse -- cloudflare.R2SippyDeleteResponse -- cloudflare.R2SippyGetResponse +- r2.R2Sippy +- r2.SippyDeleteResponse Methods: -- client.R2.Sippy.Update(ctx context.Context, bucketName string, params cloudflare.R2SippyUpdateParams) (cloudflare.R2SippyUpdateResponse, error) -- client.R2.Sippy.Delete(ctx context.Context, bucketName string, body cloudflare.R2SippyDeleteParams) (cloudflare.R2SippyDeleteResponse, error) -- client.R2.Sippy.Get(ctx context.Context, bucketName string, query cloudflare.R2SippyGetParams) (cloudflare.R2SippyGetResponse, error) +- client.R2.Sippy.Update(ctx context.Context, bucketName string, params r2.SippyUpdateParams) (r2.R2Sippy, error) +- client.R2.Sippy.Delete(ctx context.Context, bucketName string, body r2.SippyDeleteParams) (r2.SippyDeleteResponse, error) +- client.R2.Sippy.Get(ctx context.Context, bucketName string, query r2.SippyGetParams) (r2.R2Sippy, error) # WARPConnector Response Types: -- cloudflare.WARPConnectorNewResponse -- cloudflare.WARPConnectorListResponse -- cloudflare.WARPConnectorDeleteResponse -- cloudflare.WARPConnectorEditResponse -- cloudflare.WARPConnectorGetResponse -- cloudflare.WARPConnectorTokenResponse +- warp_connector.WARPConnectorNewResponse +- warp_connector.WARPConnectorListResponse +- warp_connector.WARPConnectorDeleteResponse +- warp_connector.WARPConnectorEditResponse +- warp_connector.WARPConnectorGetResponse +- warp_connector.WARPConnectorTokenResponse Methods: -- client.WARPConnector.New(ctx context.Context, params cloudflare.WARPConnectorNewParams) (cloudflare.WARPConnectorNewResponse, error) -- client.WARPConnector.List(ctx context.Context, params cloudflare.WARPConnectorListParams) (shared.V4PagePaginationArray[cloudflare.WARPConnectorListResponse], error) -- client.WARPConnector.Delete(ctx context.Context, tunnelID string, params cloudflare.WARPConnectorDeleteParams) (cloudflare.WARPConnectorDeleteResponse, error) -- client.WARPConnector.Edit(ctx context.Context, tunnelID string, params cloudflare.WARPConnectorEditParams) (cloudflare.WARPConnectorEditResponse, error) -- client.WARPConnector.Get(ctx context.Context, tunnelID string, query cloudflare.WARPConnectorGetParams) (cloudflare.WARPConnectorGetResponse, error) -- client.WARPConnector.Token(ctx context.Context, tunnelID string, query cloudflare.WARPConnectorTokenParams) (cloudflare.WARPConnectorTokenResponse, error) +- client.WARPConnector.New(ctx context.Context, params warp_connector.WARPConnectorNewParams) (warp_connector.WARPConnectorNewResponse, error) +- client.WARPConnector.List(ctx context.Context, params warp_connector.WARPConnectorListParams) (shared.V4PagePaginationArray[warp_connector.WARPConnectorListResponse], error) +- client.WARPConnector.Delete(ctx context.Context, tunnelID string, params warp_connector.WARPConnectorDeleteParams) (warp_connector.WARPConnectorDeleteResponse, error) +- client.WARPConnector.Edit(ctx context.Context, tunnelID string, params warp_connector.WARPConnectorEditParams) (warp_connector.WARPConnectorEditResponse, error) +- client.WARPConnector.Get(ctx context.Context, tunnelID string, query warp_connector.WARPConnectorGetParams) (warp_connector.WARPConnectorGetResponse, error) +- client.WARPConnector.Token(ctx context.Context, tunnelID string, query warp_connector.WARPConnectorTokenParams) (warp_connector.WARPConnectorTokenResponse, error) # WorkersForPlatforms @@ -4072,49 +4044,44 @@ Methods: Response Types: -- cloudflare.WorkersForPlatformDispatchNamespaceScriptUpdateResponse -- cloudflare.WorkersForPlatformDispatchNamespaceScriptGetResponse +- workers_for_platforms.WorkersNamespaceScript Methods: -- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Update(ctx context.Context, dispatchNamespace string, scriptName string, params cloudflare.WorkersForPlatformDispatchNamespaceScriptUpdateParams) (cloudflare.WorkersForPlatformDispatchNamespaceScriptUpdateResponse, error) -- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Delete(ctx context.Context, dispatchNamespace string, scriptName string, params cloudflare.WorkersForPlatformDispatchNamespaceScriptDeleteParams) error -- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Get(ctx context.Context, dispatchNamespace string, scriptName string, query cloudflare.WorkersForPlatformDispatchNamespaceScriptGetParams) (cloudflare.WorkersForPlatformDispatchNamespaceScriptGetResponse, error) +- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Update(ctx context.Context, dispatchNamespace string, scriptName string, params workers_for_platforms.DispatchNamespaceScriptUpdateParams) (workers.WorkersScript, error) +- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Delete(ctx context.Context, dispatchNamespace string, scriptName string, params workers_for_platforms.DispatchNamespaceScriptDeleteParams) error +- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Get(ctx context.Context, dispatchNamespace string, scriptName string, query workers_for_platforms.DispatchNamespaceScriptGetParams) (workers_for_platforms.WorkersNamespaceScript, error) ##### Content ###### Scripts -Response Types: - -- cloudflare.WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponse - Methods: -- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Scripts.Update(ctx context.Context, dispatchNamespace string, scriptName string, params cloudflare.WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateParams) (cloudflare.WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponse, error) -- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Scripts.Get(ctx context.Context, dispatchNamespace string, scriptName string, query cloudflare.WorkersForPlatformDispatchNamespaceScriptContentScriptGetParams) (http.Response, error) +- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Scripts.Update(ctx context.Context, dispatchNamespace string, scriptName string, params workers_for_platforms.DispatchNamespaceScriptContentScriptUpdateParams) (workers.WorkersScript, error) +- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Scripts.Get(ctx context.Context, dispatchNamespace string, scriptName string, query workers_for_platforms.DispatchNamespaceScriptContentScriptGetParams) (http.Response, error) ###### Settings Response Types: -- cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponse -- cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponse +- workers_for_platforms.DispatchNamespaceScriptContentSettingEditResponse +- workers_for_platforms.DispatchNamespaceScriptContentSettingGetResponse Methods: -- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Settings.Edit(ctx context.Context, dispatchNamespace string, scriptName string, params cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParams) (cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponse, error) -- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Settings.Get(ctx context.Context, dispatchNamespace string, scriptName string, query cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingGetParams) (cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponse, error) +- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Settings.Edit(ctx context.Context, dispatchNamespace string, scriptName string, params workers_for_platforms.DispatchNamespaceScriptContentSettingEditParams) (workers_for_platforms.DispatchNamespaceScriptContentSettingEditResponse, error) +- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Settings.Get(ctx context.Context, dispatchNamespace string, scriptName string, query workers_for_platforms.DispatchNamespaceScriptContentSettingGetParams) (workers_for_platforms.DispatchNamespaceScriptContentSettingGetResponse, error) ###### Bindings Response Types: -- cloudflare.WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponse +- workers_for_platforms.DispatchNamespaceScriptContentBindingGetResponse Methods: -- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Bindings.Get(ctx context.Context, dispatchNamespace string, scriptName string, query cloudflare.WorkersForPlatformDispatchNamespaceScriptContentBindingGetParams) (cloudflare.WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponse, error) +- client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Bindings.Get(ctx context.Context, dispatchNamespace string, scriptName string, query workers_for_platforms.DispatchNamespaceScriptContentBindingGetParams) (workers_for_platforms.DispatchNamespaceScriptContentBindingGetResponse, error) # ZeroTrust @@ -4122,241 +4089,227 @@ Methods: Response Types: -- cloudflare.ZeroTrustDeviceListResponse -- cloudflare.ZeroTrustDeviceGetResponse +- zero_trust.TeamsDevicesDevices +- zero_trust.DeviceGetResponse Methods: -- client.ZeroTrust.Devices.List(ctx context.Context, query cloudflare.ZeroTrustDeviceListParams) ([]cloudflare.ZeroTrustDeviceListResponse, error) -- client.ZeroTrust.Devices.Get(ctx context.Context, deviceID string, query cloudflare.ZeroTrustDeviceGetParams) (cloudflare.ZeroTrustDeviceGetResponse, error) +- client.ZeroTrust.Devices.List(ctx context.Context, query zero_trust.DeviceListParams) ([]zero_trust.TeamsDevicesDevices, error) +- client.ZeroTrust.Devices.Get(ctx context.Context, deviceID string, query zero_trust.DeviceGetParams) (zero_trust.DeviceGetResponse, error) ### DEXTests Response Types: -- cloudflare.ZeroTrustDeviceDEXTestNewResponse -- cloudflare.ZeroTrustDeviceDEXTestUpdateResponse -- cloudflare.ZeroTrustDeviceDEXTestListResponse -- cloudflare.ZeroTrustDeviceDEXTestDeleteResponse -- cloudflare.ZeroTrustDeviceDEXTestGetResponse +- zero_trust.TeamsDevicesDeviceDEXTestSchemasHTTP Methods: -- client.ZeroTrust.Devices.DEXTests.New(ctx context.Context, params cloudflare.ZeroTrustDeviceDEXTestNewParams) (cloudflare.ZeroTrustDeviceDEXTestNewResponse, error) -- client.ZeroTrust.Devices.DEXTests.Update(ctx context.Context, dexTestID string, params cloudflare.ZeroTrustDeviceDEXTestUpdateParams) (cloudflare.ZeroTrustDeviceDEXTestUpdateResponse, error) -- client.ZeroTrust.Devices.DEXTests.List(ctx context.Context, query cloudflare.ZeroTrustDeviceDEXTestListParams) ([]cloudflare.ZeroTrustDeviceDEXTestListResponse, error) -- client.ZeroTrust.Devices.DEXTests.Delete(ctx context.Context, dexTestID string, body cloudflare.ZeroTrustDeviceDEXTestDeleteParams) ([]cloudflare.ZeroTrustDeviceDEXTestDeleteResponse, error) -- client.ZeroTrust.Devices.DEXTests.Get(ctx context.Context, dexTestID string, query cloudflare.ZeroTrustDeviceDEXTestGetParams) (cloudflare.ZeroTrustDeviceDEXTestGetResponse, error) +- client.ZeroTrust.Devices.DEXTests.New(ctx context.Context, params zero_trust.DeviceDEXTestNewParams) (zero_trust.TeamsDevicesDeviceDEXTestSchemasHTTP, error) +- client.ZeroTrust.Devices.DEXTests.Update(ctx context.Context, dexTestID string, params zero_trust.DeviceDEXTestUpdateParams) (zero_trust.TeamsDevicesDeviceDEXTestSchemasHTTP, error) +- client.ZeroTrust.Devices.DEXTests.List(ctx context.Context, query zero_trust.DeviceDEXTestListParams) ([]zero_trust.TeamsDevicesDeviceDEXTestSchemasHTTP, error) +- client.ZeroTrust.Devices.DEXTests.Delete(ctx context.Context, dexTestID string, body zero_trust.DeviceDEXTestDeleteParams) ([]zero_trust.TeamsDevicesDeviceDEXTestSchemasHTTP, error) +- client.ZeroTrust.Devices.DEXTests.Get(ctx context.Context, dexTestID string, query zero_trust.DeviceDEXTestGetParams) (zero_trust.TeamsDevicesDeviceDEXTestSchemasHTTP, error) ### Networks Response Types: -- cloudflare.ZeroTrustDeviceNetworkNewResponse -- cloudflare.ZeroTrustDeviceNetworkUpdateResponse -- cloudflare.ZeroTrustDeviceNetworkListResponse -- cloudflare.ZeroTrustDeviceNetworkDeleteResponse -- cloudflare.ZeroTrustDeviceNetworkGetResponse +- zero_trust.TeamsDevicesDeviceManagedNetworks Methods: -- client.ZeroTrust.Devices.Networks.New(ctx context.Context, params cloudflare.ZeroTrustDeviceNetworkNewParams) (cloudflare.ZeroTrustDeviceNetworkNewResponse, error) -- client.ZeroTrust.Devices.Networks.Update(ctx context.Context, networkID string, params cloudflare.ZeroTrustDeviceNetworkUpdateParams) (cloudflare.ZeroTrustDeviceNetworkUpdateResponse, error) -- client.ZeroTrust.Devices.Networks.List(ctx context.Context, query cloudflare.ZeroTrustDeviceNetworkListParams) ([]cloudflare.ZeroTrustDeviceNetworkListResponse, error) -- client.ZeroTrust.Devices.Networks.Delete(ctx context.Context, networkID string, body cloudflare.ZeroTrustDeviceNetworkDeleteParams) ([]cloudflare.ZeroTrustDeviceNetworkDeleteResponse, error) -- client.ZeroTrust.Devices.Networks.Get(ctx context.Context, networkID string, query cloudflare.ZeroTrustDeviceNetworkGetParams) (cloudflare.ZeroTrustDeviceNetworkGetResponse, error) +- client.ZeroTrust.Devices.Networks.New(ctx context.Context, params zero_trust.DeviceNetworkNewParams) (zero_trust.TeamsDevicesDeviceManagedNetworks, error) +- client.ZeroTrust.Devices.Networks.Update(ctx context.Context, networkID string, params zero_trust.DeviceNetworkUpdateParams) (zero_trust.TeamsDevicesDeviceManagedNetworks, error) +- client.ZeroTrust.Devices.Networks.List(ctx context.Context, query zero_trust.DeviceNetworkListParams) ([]zero_trust.TeamsDevicesDeviceManagedNetworks, error) +- client.ZeroTrust.Devices.Networks.Delete(ctx context.Context, networkID string, body zero_trust.DeviceNetworkDeleteParams) ([]zero_trust.TeamsDevicesDeviceManagedNetworks, error) +- client.ZeroTrust.Devices.Networks.Get(ctx context.Context, networkID string, query zero_trust.DeviceNetworkGetParams) (zero_trust.TeamsDevicesDeviceManagedNetworks, error) ### Policies Response Types: -- cloudflare.ZeroTrustDevicePolicyNewResponse -- cloudflare.ZeroTrustDevicePolicyListResponse -- cloudflare.ZeroTrustDevicePolicyDeleteResponse -- cloudflare.ZeroTrustDevicePolicyEditResponse -- cloudflare.ZeroTrustDevicePolicyGetResponse +- zero_trust.TeamsDevicesDeviceSettingsPolicy +- zero_trust.DevicePolicyNewResponse +- zero_trust.DevicePolicyEditResponse +- zero_trust.DevicePolicyGetResponse Methods: -- client.ZeroTrust.Devices.Policies.New(ctx context.Context, params cloudflare.ZeroTrustDevicePolicyNewParams) ([]cloudflare.ZeroTrustDevicePolicyNewResponse, error) -- client.ZeroTrust.Devices.Policies.List(ctx context.Context, query cloudflare.ZeroTrustDevicePolicyListParams) ([]cloudflare.ZeroTrustDevicePolicyListResponse, error) -- client.ZeroTrust.Devices.Policies.Delete(ctx context.Context, policyID string, body cloudflare.ZeroTrustDevicePolicyDeleteParams) ([]cloudflare.ZeroTrustDevicePolicyDeleteResponse, error) -- client.ZeroTrust.Devices.Policies.Edit(ctx context.Context, policyID string, params cloudflare.ZeroTrustDevicePolicyEditParams) ([]cloudflare.ZeroTrustDevicePolicyEditResponse, error) -- client.ZeroTrust.Devices.Policies.Get(ctx context.Context, policyID string, query cloudflare.ZeroTrustDevicePolicyGetParams) ([]cloudflare.ZeroTrustDevicePolicyGetResponse, error) +- client.ZeroTrust.Devices.Policies.New(ctx context.Context, params zero_trust.DevicePolicyNewParams) (zero_trust.TeamsDevicesDeviceSettingsPolicy, error) +- client.ZeroTrust.Devices.Policies.List(ctx context.Context, query zero_trust.DevicePolicyListParams) ([]zero_trust.TeamsDevicesDeviceSettingsPolicy, error) +- client.ZeroTrust.Devices.Policies.Delete(ctx context.Context, policyID string, body zero_trust.DevicePolicyDeleteParams) ([]zero_trust.TeamsDevicesDeviceSettingsPolicy, error) +- client.ZeroTrust.Devices.Policies.Edit(ctx context.Context, policyID string, params zero_trust.DevicePolicyEditParams) (zero_trust.TeamsDevicesDeviceSettingsPolicy, error) +- client.ZeroTrust.Devices.Policies.Get(ctx context.Context, policyID string, query zero_trust.DevicePolicyGetParams) (zero_trust.TeamsDevicesDeviceSettingsPolicy, error) #### DefaultPolicy Response Types: -- cloudflare.ZeroTrustDevicePolicyDefaultPolicyGetResponse +- zero_trust.DevicePolicyDefaultPolicyGetResponse Methods: -- client.ZeroTrust.Devices.Policies.DefaultPolicy.Get(ctx context.Context, query cloudflare.ZeroTrustDevicePolicyDefaultPolicyGetParams) ([]cloudflare.ZeroTrustDevicePolicyDefaultPolicyGetResponse, error) +- client.ZeroTrust.Devices.Policies.DefaultPolicy.Get(ctx context.Context, query zero_trust.DevicePolicyDefaultPolicyGetParams) ([]zero_trust.DevicePolicyDefaultPolicyGetResponse, error) #### Excludes +Params Types: + +- zero_trust.TeamsDevicesSplitTunnelParam + Response Types: -- cloudflare.ZeroTrustDevicePolicyExcludeUpdateResponse -- cloudflare.ZeroTrustDevicePolicyExcludeListResponse -- cloudflare.ZeroTrustDevicePolicyExcludeGetResponse +- zero_trust.TeamsDevicesSplitTunnel Methods: -- client.ZeroTrust.Devices.Policies.Excludes.Update(ctx context.Context, params cloudflare.ZeroTrustDevicePolicyExcludeUpdateParams) ([]cloudflare.ZeroTrustDevicePolicyExcludeUpdateResponse, error) -- client.ZeroTrust.Devices.Policies.Excludes.List(ctx context.Context, query cloudflare.ZeroTrustDevicePolicyExcludeListParams) ([]cloudflare.ZeroTrustDevicePolicyExcludeListResponse, error) -- client.ZeroTrust.Devices.Policies.Excludes.Get(ctx context.Context, policyID string, query cloudflare.ZeroTrustDevicePolicyExcludeGetParams) ([]cloudflare.ZeroTrustDevicePolicyExcludeGetResponse, error) +- client.ZeroTrust.Devices.Policies.Excludes.Update(ctx context.Context, params zero_trust.DevicePolicyExcludeUpdateParams) ([]zero_trust.TeamsDevicesSplitTunnel, error) +- client.ZeroTrust.Devices.Policies.Excludes.List(ctx context.Context, query zero_trust.DevicePolicyExcludeListParams) ([]zero_trust.TeamsDevicesSplitTunnel, error) +- client.ZeroTrust.Devices.Policies.Excludes.Get(ctx context.Context, policyID string, query zero_trust.DevicePolicyExcludeGetParams) ([]zero_trust.TeamsDevicesSplitTunnel, error) #### FallbackDomains +Params Types: + +- zero_trust.TeamsDevicesFallbackDomainParam + Response Types: -- cloudflare.ZeroTrustDevicePolicyFallbackDomainUpdateResponse -- cloudflare.ZeroTrustDevicePolicyFallbackDomainListResponse -- cloudflare.ZeroTrustDevicePolicyFallbackDomainGetResponse +- zero_trust.TeamsDevicesFallbackDomain Methods: -- client.ZeroTrust.Devices.Policies.FallbackDomains.Update(ctx context.Context, policyID string, params cloudflare.ZeroTrustDevicePolicyFallbackDomainUpdateParams) ([]cloudflare.ZeroTrustDevicePolicyFallbackDomainUpdateResponse, error) -- client.ZeroTrust.Devices.Policies.FallbackDomains.List(ctx context.Context, query cloudflare.ZeroTrustDevicePolicyFallbackDomainListParams) ([]cloudflare.ZeroTrustDevicePolicyFallbackDomainListResponse, error) -- client.ZeroTrust.Devices.Policies.FallbackDomains.Get(ctx context.Context, policyID string, query cloudflare.ZeroTrustDevicePolicyFallbackDomainGetParams) ([]cloudflare.ZeroTrustDevicePolicyFallbackDomainGetResponse, error) +- client.ZeroTrust.Devices.Policies.FallbackDomains.Update(ctx context.Context, policyID string, params zero_trust.DevicePolicyFallbackDomainUpdateParams) ([]zero_trust.TeamsDevicesFallbackDomain, error) +- client.ZeroTrust.Devices.Policies.FallbackDomains.List(ctx context.Context, query zero_trust.DevicePolicyFallbackDomainListParams) ([]zero_trust.TeamsDevicesFallbackDomain, error) +- client.ZeroTrust.Devices.Policies.FallbackDomains.Get(ctx context.Context, policyID string, query zero_trust.DevicePolicyFallbackDomainGetParams) ([]zero_trust.TeamsDevicesFallbackDomain, error) #### Includes +Params Types: + +- zero_trust.TeamsDevicesSplitTunnelIncludeParam + Response Types: -- cloudflare.ZeroTrustDevicePolicyIncludeUpdateResponse -- cloudflare.ZeroTrustDevicePolicyIncludeListResponse -- cloudflare.ZeroTrustDevicePolicyIncludeGetResponse +- zero_trust.TeamsDevicesSplitTunnelInclude Methods: -- client.ZeroTrust.Devices.Policies.Includes.Update(ctx context.Context, params cloudflare.ZeroTrustDevicePolicyIncludeUpdateParams) ([]cloudflare.ZeroTrustDevicePolicyIncludeUpdateResponse, error) -- client.ZeroTrust.Devices.Policies.Includes.List(ctx context.Context, query cloudflare.ZeroTrustDevicePolicyIncludeListParams) ([]cloudflare.ZeroTrustDevicePolicyIncludeListResponse, error) -- client.ZeroTrust.Devices.Policies.Includes.Get(ctx context.Context, policyID string, query cloudflare.ZeroTrustDevicePolicyIncludeGetParams) ([]cloudflare.ZeroTrustDevicePolicyIncludeGetResponse, error) +- client.ZeroTrust.Devices.Policies.Includes.Update(ctx context.Context, params zero_trust.DevicePolicyIncludeUpdateParams) ([]zero_trust.TeamsDevicesSplitTunnelInclude, error) +- client.ZeroTrust.Devices.Policies.Includes.List(ctx context.Context, query zero_trust.DevicePolicyIncludeListParams) ([]zero_trust.TeamsDevicesSplitTunnelInclude, error) +- client.ZeroTrust.Devices.Policies.Includes.Get(ctx context.Context, policyID string, query zero_trust.DevicePolicyIncludeGetParams) ([]zero_trust.TeamsDevicesSplitTunnelInclude, error) ### Postures Response Types: -- cloudflare.ZeroTrustDevicePostureNewResponse -- cloudflare.ZeroTrustDevicePostureUpdateResponse -- cloudflare.ZeroTrustDevicePostureListResponse -- cloudflare.ZeroTrustDevicePostureDeleteResponse -- cloudflare.ZeroTrustDevicePostureGetResponse +- zero_trust.TeamsDevicesDevicePostureRules +- zero_trust.DevicePostureDeleteResponse Methods: -- client.ZeroTrust.Devices.Postures.New(ctx context.Context, params cloudflare.ZeroTrustDevicePostureNewParams) (cloudflare.ZeroTrustDevicePostureNewResponse, error) -- client.ZeroTrust.Devices.Postures.Update(ctx context.Context, ruleID string, params cloudflare.ZeroTrustDevicePostureUpdateParams) (cloudflare.ZeroTrustDevicePostureUpdateResponse, error) -- client.ZeroTrust.Devices.Postures.List(ctx context.Context, query cloudflare.ZeroTrustDevicePostureListParams) ([]cloudflare.ZeroTrustDevicePostureListResponse, error) -- client.ZeroTrust.Devices.Postures.Delete(ctx context.Context, ruleID string, body cloudflare.ZeroTrustDevicePostureDeleteParams) (cloudflare.ZeroTrustDevicePostureDeleteResponse, error) -- client.ZeroTrust.Devices.Postures.Get(ctx context.Context, ruleID string, query cloudflare.ZeroTrustDevicePostureGetParams) (cloudflare.ZeroTrustDevicePostureGetResponse, error) +- client.ZeroTrust.Devices.Postures.New(ctx context.Context, params zero_trust.DevicePostureNewParams) (zero_trust.TeamsDevicesDevicePostureRules, error) +- client.ZeroTrust.Devices.Postures.Update(ctx context.Context, ruleID string, params zero_trust.DevicePostureUpdateParams) (zero_trust.TeamsDevicesDevicePostureRules, error) +- client.ZeroTrust.Devices.Postures.List(ctx context.Context, query zero_trust.DevicePostureListParams) ([]zero_trust.TeamsDevicesDevicePostureRules, error) +- client.ZeroTrust.Devices.Postures.Delete(ctx context.Context, ruleID string, body zero_trust.DevicePostureDeleteParams) (zero_trust.DevicePostureDeleteResponse, error) +- client.ZeroTrust.Devices.Postures.Get(ctx context.Context, ruleID string, query zero_trust.DevicePostureGetParams) (zero_trust.TeamsDevicesDevicePostureRules, error) #### Integrations Response Types: -- cloudflare.ZeroTrustDevicePostureIntegrationNewResponse -- cloudflare.ZeroTrustDevicePostureIntegrationListResponse -- cloudflare.ZeroTrustDevicePostureIntegrationDeleteResponse -- cloudflare.ZeroTrustDevicePostureIntegrationEditResponse -- cloudflare.ZeroTrustDevicePostureIntegrationGetResponse +- zero_trust.TeamsDevicesDevicePostureIntegrations +- zero_trust.DevicePostureIntegrationDeleteResponse Methods: -- client.ZeroTrust.Devices.Postures.Integrations.New(ctx context.Context, params cloudflare.ZeroTrustDevicePostureIntegrationNewParams) (cloudflare.ZeroTrustDevicePostureIntegrationNewResponse, error) -- client.ZeroTrust.Devices.Postures.Integrations.List(ctx context.Context, query cloudflare.ZeroTrustDevicePostureIntegrationListParams) ([]cloudflare.ZeroTrustDevicePostureIntegrationListResponse, error) -- client.ZeroTrust.Devices.Postures.Integrations.Delete(ctx context.Context, integrationID string, body cloudflare.ZeroTrustDevicePostureIntegrationDeleteParams) (cloudflare.ZeroTrustDevicePostureIntegrationDeleteResponse, error) -- client.ZeroTrust.Devices.Postures.Integrations.Edit(ctx context.Context, integrationID string, params cloudflare.ZeroTrustDevicePostureIntegrationEditParams) (cloudflare.ZeroTrustDevicePostureIntegrationEditResponse, error) -- client.ZeroTrust.Devices.Postures.Integrations.Get(ctx context.Context, integrationID string, query cloudflare.ZeroTrustDevicePostureIntegrationGetParams) (cloudflare.ZeroTrustDevicePostureIntegrationGetResponse, error) +- client.ZeroTrust.Devices.Postures.Integrations.New(ctx context.Context, params zero_trust.DevicePostureIntegrationNewParams) (zero_trust.TeamsDevicesDevicePostureIntegrations, error) +- client.ZeroTrust.Devices.Postures.Integrations.List(ctx context.Context, query zero_trust.DevicePostureIntegrationListParams) ([]zero_trust.TeamsDevicesDevicePostureIntegrations, error) +- client.ZeroTrust.Devices.Postures.Integrations.Delete(ctx context.Context, integrationID string, body zero_trust.DevicePostureIntegrationDeleteParams) (zero_trust.DevicePostureIntegrationDeleteResponse, error) +- client.ZeroTrust.Devices.Postures.Integrations.Edit(ctx context.Context, integrationID string, params zero_trust.DevicePostureIntegrationEditParams) (zero_trust.TeamsDevicesDevicePostureIntegrations, error) +- client.ZeroTrust.Devices.Postures.Integrations.Get(ctx context.Context, integrationID string, query zero_trust.DevicePostureIntegrationGetParams) (zero_trust.TeamsDevicesDevicePostureIntegrations, error) ### Revokes Response Types: -- cloudflare.ZeroTrustDeviceRevokeNewResponse +- zero_trust.DeviceRevokeNewResponse Methods: -- client.ZeroTrust.Devices.Revokes.New(ctx context.Context, params cloudflare.ZeroTrustDeviceRevokeNewParams) (cloudflare.ZeroTrustDeviceRevokeNewResponse, error) +- client.ZeroTrust.Devices.Revokes.New(ctx context.Context, params zero_trust.DeviceRevokeNewParams) (zero_trust.DeviceRevokeNewResponse, error) ### Settings Response Types: -- cloudflare.ZeroTrustDeviceSettingUpdateResponse -- cloudflare.ZeroTrustDeviceSettingListResponse +- zero_trust.TeamsDevicesZeroTrustAccountDeviceSettings Methods: -- client.ZeroTrust.Devices.Settings.Update(ctx context.Context, params cloudflare.ZeroTrustDeviceSettingUpdateParams) (cloudflare.ZeroTrustDeviceSettingUpdateResponse, error) -- client.ZeroTrust.Devices.Settings.List(ctx context.Context, query cloudflare.ZeroTrustDeviceSettingListParams) (cloudflare.ZeroTrustDeviceSettingListResponse, error) +- client.ZeroTrust.Devices.Settings.Update(ctx context.Context, params zero_trust.DeviceSettingUpdateParams) (zero_trust.TeamsDevicesZeroTrustAccountDeviceSettings, error) +- client.ZeroTrust.Devices.Settings.List(ctx context.Context, query zero_trust.DeviceSettingListParams) (zero_trust.TeamsDevicesZeroTrustAccountDeviceSettings, error) ### Unrevokes Response Types: -- cloudflare.ZeroTrustDeviceUnrevokeNewResponse +- zero_trust.DeviceUnrevokeNewResponse Methods: -- client.ZeroTrust.Devices.Unrevokes.New(ctx context.Context, params cloudflare.ZeroTrustDeviceUnrevokeNewParams) (cloudflare.ZeroTrustDeviceUnrevokeNewResponse, error) +- client.ZeroTrust.Devices.Unrevokes.New(ctx context.Context, params zero_trust.DeviceUnrevokeNewParams) (zero_trust.DeviceUnrevokeNewResponse, error) ### OverrideCodes Response Types: -- cloudflare.ZeroTrustDeviceOverrideCodeListResponse +- zero_trust.DeviceOverrideCodeListResponse Methods: -- client.ZeroTrust.Devices.OverrideCodes.List(ctx context.Context, deviceID string, query cloudflare.ZeroTrustDeviceOverrideCodeListParams) (cloudflare.ZeroTrustDeviceOverrideCodeListResponse, error) +- client.ZeroTrust.Devices.OverrideCodes.List(ctx context.Context, deviceID string, query zero_trust.DeviceOverrideCodeListParams) (zero_trust.DeviceOverrideCodeListResponse, error) ## IdentityProviders Response Types: -- cloudflare.ZeroTrustIdentityProviderNewResponse -- cloudflare.ZeroTrustIdentityProviderUpdateResponse -- cloudflare.ZeroTrustIdentityProviderListResponse -- cloudflare.ZeroTrustIdentityProviderDeleteResponse -- cloudflare.ZeroTrustIdentityProviderGetResponse +- zero_trust.AccessIdentityProviders +- zero_trust.IdentityProviderListResponse +- zero_trust.IdentityProviderDeleteResponse Methods: -- client.ZeroTrust.IdentityProviders.New(ctx context.Context, params cloudflare.ZeroTrustIdentityProviderNewParams) (cloudflare.ZeroTrustIdentityProviderNewResponse, error) -- client.ZeroTrust.IdentityProviders.Update(ctx context.Context, uuid string, params cloudflare.ZeroTrustIdentityProviderUpdateParams) (cloudflare.ZeroTrustIdentityProviderUpdateResponse, error) -- client.ZeroTrust.IdentityProviders.List(ctx context.Context, query cloudflare.ZeroTrustIdentityProviderListParams) ([]cloudflare.ZeroTrustIdentityProviderListResponse, error) -- client.ZeroTrust.IdentityProviders.Delete(ctx context.Context, uuid string, body cloudflare.ZeroTrustIdentityProviderDeleteParams) (cloudflare.ZeroTrustIdentityProviderDeleteResponse, error) -- client.ZeroTrust.IdentityProviders.Get(ctx context.Context, uuid string, query cloudflare.ZeroTrustIdentityProviderGetParams) (cloudflare.ZeroTrustIdentityProviderGetResponse, error) +- client.ZeroTrust.IdentityProviders.New(ctx context.Context, params zero_trust.IdentityProviderNewParams) (zero_trust.AccessIdentityProviders, error) +- client.ZeroTrust.IdentityProviders.Update(ctx context.Context, uuid string, params zero_trust.IdentityProviderUpdateParams) (zero_trust.AccessIdentityProviders, error) +- client.ZeroTrust.IdentityProviders.List(ctx context.Context, query zero_trust.IdentityProviderListParams) ([]zero_trust.IdentityProviderListResponse, error) +- client.ZeroTrust.IdentityProviders.Delete(ctx context.Context, uuid string, body zero_trust.IdentityProviderDeleteParams) (zero_trust.IdentityProviderDeleteResponse, error) +- client.ZeroTrust.IdentityProviders.Get(ctx context.Context, uuid string, query zero_trust.IdentityProviderGetParams) (zero_trust.AccessIdentityProviders, error) ## Organizations Response Types: -- cloudflare.ZeroTrustOrganizationNewResponse -- cloudflare.ZeroTrustOrganizationUpdateResponse -- cloudflare.ZeroTrustOrganizationListResponse -- cloudflare.ZeroTrustOrganizationRevokeUsersResponse +- zero_trust.AccessOrganizations +- zero_trust.OrganizationRevokeUsersResponse Methods: -- client.ZeroTrust.Organizations.New(ctx context.Context, params cloudflare.ZeroTrustOrganizationNewParams) (cloudflare.ZeroTrustOrganizationNewResponse, error) -- client.ZeroTrust.Organizations.Update(ctx context.Context, params cloudflare.ZeroTrustOrganizationUpdateParams) (cloudflare.ZeroTrustOrganizationUpdateResponse, error) -- client.ZeroTrust.Organizations.List(ctx context.Context, query cloudflare.ZeroTrustOrganizationListParams) (cloudflare.ZeroTrustOrganizationListResponse, error) -- client.ZeroTrust.Organizations.RevokeUsers(ctx context.Context, params cloudflare.ZeroTrustOrganizationRevokeUsersParams) (cloudflare.ZeroTrustOrganizationRevokeUsersResponse, error) +- client.ZeroTrust.Organizations.New(ctx context.Context, params zero_trust.OrganizationNewParams) (zero_trust.AccessOrganizations, error) +- client.ZeroTrust.Organizations.Update(ctx context.Context, params zero_trust.OrganizationUpdateParams) (zero_trust.AccessOrganizations, error) +- client.ZeroTrust.Organizations.List(ctx context.Context, query zero_trust.OrganizationListParams) (zero_trust.AccessOrganizations, error) +- client.ZeroTrust.Organizations.RevokeUsers(ctx context.Context, params zero_trust.OrganizationRevokeUsersParams) (zero_trust.OrganizationRevokeUsersResponse, error) ## Seats Response Types: -- cloudflare.ZeroTrustSeatEditResponse +- zero_trust.AccessSeats Methods: -- client.ZeroTrust.Seats.Edit(ctx context.Context, identifier string, body cloudflare.ZeroTrustSeatEditParams) ([]cloudflare.ZeroTrustSeatEditResponse, error) +- client.ZeroTrust.Seats.Edit(ctx context.Context, identifier string, body zero_trust.SeatEditParams) ([]zero_trust.AccessSeats, error) ## Access @@ -4364,165 +4317,150 @@ Methods: Response Types: -- cloudflare.ZeroTrustAccessApplicationNewResponse -- cloudflare.ZeroTrustAccessApplicationUpdateResponse -- cloudflare.ZeroTrustAccessApplicationListResponse -- cloudflare.ZeroTrustAccessApplicationDeleteResponse -- cloudflare.ZeroTrustAccessApplicationGetResponse -- cloudflare.ZeroTrustAccessApplicationRevokeTokensResponse +- zero_trust.AccessApps +- zero_trust.AccessApplicationDeleteResponse +- zero_trust.AccessApplicationRevokeTokensResponse Methods: -- client.ZeroTrust.Access.Applications.New(ctx context.Context, params cloudflare.ZeroTrustAccessApplicationNewParams) (cloudflare.ZeroTrustAccessApplicationNewResponse, error) -- client.ZeroTrust.Access.Applications.Update(ctx context.Context, appID cloudflare.ZeroTrustAccessApplicationUpdateParamsAppID, params cloudflare.ZeroTrustAccessApplicationUpdateParams) (cloudflare.ZeroTrustAccessApplicationUpdateResponse, error) -- client.ZeroTrust.Access.Applications.List(ctx context.Context, query cloudflare.ZeroTrustAccessApplicationListParams) ([]cloudflare.ZeroTrustAccessApplicationListResponse, error) -- client.ZeroTrust.Access.Applications.Delete(ctx context.Context, appID cloudflare.ZeroTrustAccessApplicationDeleteParamsAppID, body cloudflare.ZeroTrustAccessApplicationDeleteParams) (cloudflare.ZeroTrustAccessApplicationDeleteResponse, error) -- client.ZeroTrust.Access.Applications.Get(ctx context.Context, appID cloudflare.ZeroTrustAccessApplicationGetParamsAppID, query cloudflare.ZeroTrustAccessApplicationGetParams) (cloudflare.ZeroTrustAccessApplicationGetResponse, error) -- client.ZeroTrust.Access.Applications.RevokeTokens(ctx context.Context, appID cloudflare.ZeroTrustAccessApplicationRevokeTokensParamsAppID, body cloudflare.ZeroTrustAccessApplicationRevokeTokensParams) (cloudflare.ZeroTrustAccessApplicationRevokeTokensResponse, error) +- client.ZeroTrust.Access.Applications.New(ctx context.Context, params zero_trust.AccessApplicationNewParams) (zero_trust.AccessApps, error) +- client.ZeroTrust.Access.Applications.Update(ctx context.Context, appID zero_trust.AccessApplicationUpdateParamsAppID, params zero_trust.AccessApplicationUpdateParams) (zero_trust.AccessApps, error) +- client.ZeroTrust.Access.Applications.List(ctx context.Context, query zero_trust.AccessApplicationListParams) ([]zero_trust.AccessApps, error) +- client.ZeroTrust.Access.Applications.Delete(ctx context.Context, appID zero_trust.AccessApplicationDeleteParamsAppID, body zero_trust.AccessApplicationDeleteParams) (zero_trust.AccessApplicationDeleteResponse, error) +- client.ZeroTrust.Access.Applications.Get(ctx context.Context, appID zero_trust.AccessApplicationGetParamsAppID, query zero_trust.AccessApplicationGetParams) (zero_trust.AccessApps, error) +- client.ZeroTrust.Access.Applications.RevokeTokens(ctx context.Context, appID zero_trust.AccessApplicationRevokeTokensParamsAppID, body zero_trust.AccessApplicationRevokeTokensParams) (zero_trust.AccessApplicationRevokeTokensResponse, error) #### CAs Response Types: -- cloudflare.ZeroTrustAccessApplicationCANewResponse -- cloudflare.ZeroTrustAccessApplicationCAListResponse -- cloudflare.ZeroTrustAccessApplicationCADeleteResponse -- cloudflare.ZeroTrustAccessApplicationCAGetResponse +- zero_trust.AccessCA +- zero_trust.AccessApplicationCANewResponse +- zero_trust.AccessApplicationCADeleteResponse +- zero_trust.AccessApplicationCAGetResponse Methods: -- client.ZeroTrust.Access.Applications.CAs.New(ctx context.Context, uuid string, body cloudflare.ZeroTrustAccessApplicationCANewParams) (cloudflare.ZeroTrustAccessApplicationCANewResponse, error) -- client.ZeroTrust.Access.Applications.CAs.List(ctx context.Context, query cloudflare.ZeroTrustAccessApplicationCAListParams) ([]cloudflare.ZeroTrustAccessApplicationCAListResponse, error) -- client.ZeroTrust.Access.Applications.CAs.Delete(ctx context.Context, uuid string, body cloudflare.ZeroTrustAccessApplicationCADeleteParams) (cloudflare.ZeroTrustAccessApplicationCADeleteResponse, error) -- client.ZeroTrust.Access.Applications.CAs.Get(ctx context.Context, uuid string, query cloudflare.ZeroTrustAccessApplicationCAGetParams) (cloudflare.ZeroTrustAccessApplicationCAGetResponse, error) +- client.ZeroTrust.Access.Applications.CAs.New(ctx context.Context, uuid string, body zero_trust.AccessApplicationCANewParams) (zero_trust.AccessApplicationCANewResponse, error) +- client.ZeroTrust.Access.Applications.CAs.List(ctx context.Context, query zero_trust.AccessApplicationCAListParams) ([]zero_trust.AccessCA, error) +- client.ZeroTrust.Access.Applications.CAs.Delete(ctx context.Context, uuid string, body zero_trust.AccessApplicationCADeleteParams) (zero_trust.AccessApplicationCADeleteResponse, error) +- client.ZeroTrust.Access.Applications.CAs.Get(ctx context.Context, uuid string, query zero_trust.AccessApplicationCAGetParams) (zero_trust.AccessApplicationCAGetResponse, error) #### UserPolicyChecks Response Types: -- cloudflare.ZeroTrustAccessApplicationUserPolicyCheckListResponse +- zero_trust.AccessApplicationUserPolicyCheckListResponse Methods: -- client.ZeroTrust.Access.Applications.UserPolicyChecks.List(ctx context.Context, appID cloudflare.ZeroTrustAccessApplicationUserPolicyCheckListParamsAppID, query cloudflare.ZeroTrustAccessApplicationUserPolicyCheckListParams) (cloudflare.ZeroTrustAccessApplicationUserPolicyCheckListResponse, error) +- client.ZeroTrust.Access.Applications.UserPolicyChecks.List(ctx context.Context, appID zero_trust.AccessApplicationUserPolicyCheckListParamsAppID, query zero_trust.AccessApplicationUserPolicyCheckListParams) (zero_trust.AccessApplicationUserPolicyCheckListResponse, error) #### Policies Response Types: -- cloudflare.ZeroTrustAccessApplicationPolicyNewResponse -- cloudflare.ZeroTrustAccessApplicationPolicyUpdateResponse -- cloudflare.ZeroTrustAccessApplicationPolicyListResponse -- cloudflare.ZeroTrustAccessApplicationPolicyDeleteResponse -- cloudflare.ZeroTrustAccessApplicationPolicyGetResponse +- zero_trust.AccessPolicies +- zero_trust.AccessApplicationPolicyDeleteResponse Methods: -- client.ZeroTrust.Access.Applications.Policies.New(ctx context.Context, uuid string, params cloudflare.ZeroTrustAccessApplicationPolicyNewParams) (cloudflare.ZeroTrustAccessApplicationPolicyNewResponse, error) -- client.ZeroTrust.Access.Applications.Policies.Update(ctx context.Context, uuid1 string, uuid string, params cloudflare.ZeroTrustAccessApplicationPolicyUpdateParams) (cloudflare.ZeroTrustAccessApplicationPolicyUpdateResponse, error) -- client.ZeroTrust.Access.Applications.Policies.List(ctx context.Context, uuid string, query cloudflare.ZeroTrustAccessApplicationPolicyListParams) ([]cloudflare.ZeroTrustAccessApplicationPolicyListResponse, error) -- client.ZeroTrust.Access.Applications.Policies.Delete(ctx context.Context, uuid1 string, uuid string, body cloudflare.ZeroTrustAccessApplicationPolicyDeleteParams) (cloudflare.ZeroTrustAccessApplicationPolicyDeleteResponse, error) -- client.ZeroTrust.Access.Applications.Policies.Get(ctx context.Context, uuid1 string, uuid string, query cloudflare.ZeroTrustAccessApplicationPolicyGetParams) (cloudflare.ZeroTrustAccessApplicationPolicyGetResponse, error) +- client.ZeroTrust.Access.Applications.Policies.New(ctx context.Context, uuid string, params zero_trust.AccessApplicationPolicyNewParams) (zero_trust.AccessPolicies, error) +- client.ZeroTrust.Access.Applications.Policies.Update(ctx context.Context, uuid1 string, uuid string, params zero_trust.AccessApplicationPolicyUpdateParams) (zero_trust.AccessPolicies, error) +- client.ZeroTrust.Access.Applications.Policies.List(ctx context.Context, uuid string, query zero_trust.AccessApplicationPolicyListParams) ([]zero_trust.AccessPolicies, error) +- client.ZeroTrust.Access.Applications.Policies.Delete(ctx context.Context, uuid1 string, uuid string, body zero_trust.AccessApplicationPolicyDeleteParams) (zero_trust.AccessApplicationPolicyDeleteResponse, error) +- client.ZeroTrust.Access.Applications.Policies.Get(ctx context.Context, uuid1 string, uuid string, query zero_trust.AccessApplicationPolicyGetParams) (zero_trust.AccessPolicies, error) ### Certificates Response Types: -- cloudflare.ZeroTrustAccessCertificateNewResponse -- cloudflare.ZeroTrustAccessCertificateUpdateResponse -- cloudflare.ZeroTrustAccessCertificateListResponse -- cloudflare.ZeroTrustAccessCertificateDeleteResponse -- cloudflare.ZeroTrustAccessCertificateGetResponse +- zero_trust.AccessCertificates +- zero_trust.AccessCertificateDeleteResponse Methods: -- client.ZeroTrust.Access.Certificates.New(ctx context.Context, params cloudflare.ZeroTrustAccessCertificateNewParams) (cloudflare.ZeroTrustAccessCertificateNewResponse, error) -- client.ZeroTrust.Access.Certificates.Update(ctx context.Context, uuid string, params cloudflare.ZeroTrustAccessCertificateUpdateParams) (cloudflare.ZeroTrustAccessCertificateUpdateResponse, error) -- client.ZeroTrust.Access.Certificates.List(ctx context.Context, query cloudflare.ZeroTrustAccessCertificateListParams) ([]cloudflare.ZeroTrustAccessCertificateListResponse, error) -- client.ZeroTrust.Access.Certificates.Delete(ctx context.Context, uuid string, body cloudflare.ZeroTrustAccessCertificateDeleteParams) (cloudflare.ZeroTrustAccessCertificateDeleteResponse, error) -- client.ZeroTrust.Access.Certificates.Get(ctx context.Context, uuid string, query cloudflare.ZeroTrustAccessCertificateGetParams) (cloudflare.ZeroTrustAccessCertificateGetResponse, error) +- client.ZeroTrust.Access.Certificates.New(ctx context.Context, params zero_trust.AccessCertificateNewParams) (zero_trust.AccessCertificates, error) +- client.ZeroTrust.Access.Certificates.Update(ctx context.Context, uuid string, params zero_trust.AccessCertificateUpdateParams) (zero_trust.AccessCertificates, error) +- client.ZeroTrust.Access.Certificates.List(ctx context.Context, query zero_trust.AccessCertificateListParams) ([]zero_trust.AccessCertificates, error) +- client.ZeroTrust.Access.Certificates.Delete(ctx context.Context, uuid string, body zero_trust.AccessCertificateDeleteParams) (zero_trust.AccessCertificateDeleteResponse, error) +- client.ZeroTrust.Access.Certificates.Get(ctx context.Context, uuid string, query zero_trust.AccessCertificateGetParams) (zero_trust.AccessCertificates, error) #### Settings +Params Types: + +- zero_trust.AccessSettingsParam + Response Types: -- cloudflare.ZeroTrustAccessCertificateSettingUpdateResponse -- cloudflare.ZeroTrustAccessCertificateSettingListResponse +- zero_trust.AccessSettings Methods: -- client.ZeroTrust.Access.Certificates.Settings.Update(ctx context.Context, params cloudflare.ZeroTrustAccessCertificateSettingUpdateParams) ([]cloudflare.ZeroTrustAccessCertificateSettingUpdateResponse, error) -- client.ZeroTrust.Access.Certificates.Settings.List(ctx context.Context, query cloudflare.ZeroTrustAccessCertificateSettingListParams) ([]cloudflare.ZeroTrustAccessCertificateSettingListResponse, error) +- client.ZeroTrust.Access.Certificates.Settings.Update(ctx context.Context, params zero_trust.AccessCertificateSettingUpdateParams) ([]zero_trust.AccessSettings, error) +- client.ZeroTrust.Access.Certificates.Settings.List(ctx context.Context, query zero_trust.AccessCertificateSettingListParams) ([]zero_trust.AccessSettings, error) ### Groups Response Types: -- cloudflare.ZeroTrustAccessGroupNewResponse -- cloudflare.ZeroTrustAccessGroupUpdateResponse -- cloudflare.ZeroTrustAccessGroupListResponse -- cloudflare.ZeroTrustAccessGroupDeleteResponse -- cloudflare.ZeroTrustAccessGroupGetResponse +- zero_trust.AccessGroups +- zero_trust.AccessGroupDeleteResponse Methods: -- client.ZeroTrust.Access.Groups.New(ctx context.Context, params cloudflare.ZeroTrustAccessGroupNewParams) (cloudflare.ZeroTrustAccessGroupNewResponse, error) -- client.ZeroTrust.Access.Groups.Update(ctx context.Context, uuid string, params cloudflare.ZeroTrustAccessGroupUpdateParams) (cloudflare.ZeroTrustAccessGroupUpdateResponse, error) -- client.ZeroTrust.Access.Groups.List(ctx context.Context, query cloudflare.ZeroTrustAccessGroupListParams) ([]cloudflare.ZeroTrustAccessGroupListResponse, error) -- client.ZeroTrust.Access.Groups.Delete(ctx context.Context, uuid string, body cloudflare.ZeroTrustAccessGroupDeleteParams) (cloudflare.ZeroTrustAccessGroupDeleteResponse, error) -- client.ZeroTrust.Access.Groups.Get(ctx context.Context, uuid string, query cloudflare.ZeroTrustAccessGroupGetParams) (cloudflare.ZeroTrustAccessGroupGetResponse, error) +- client.ZeroTrust.Access.Groups.New(ctx context.Context, params zero_trust.AccessGroupNewParams) (zero_trust.AccessGroups, error) +- client.ZeroTrust.Access.Groups.Update(ctx context.Context, uuid string, params zero_trust.AccessGroupUpdateParams) (zero_trust.AccessGroups, error) +- client.ZeroTrust.Access.Groups.List(ctx context.Context, query zero_trust.AccessGroupListParams) ([]zero_trust.AccessGroups, error) +- client.ZeroTrust.Access.Groups.Delete(ctx context.Context, uuid string, body zero_trust.AccessGroupDeleteParams) (zero_trust.AccessGroupDeleteResponse, error) +- client.ZeroTrust.Access.Groups.Get(ctx context.Context, uuid string, query zero_trust.AccessGroupGetParams) (zero_trust.AccessGroups, error) ### ServiceTokens Response Types: -- cloudflare.ZeroTrustAccessServiceTokenNewResponse -- cloudflare.ZeroTrustAccessServiceTokenUpdateResponse -- cloudflare.ZeroTrustAccessServiceTokenListResponse -- cloudflare.ZeroTrustAccessServiceTokenDeleteResponse -- cloudflare.ZeroTrustAccessServiceTokenRefreshResponse -- cloudflare.ZeroTrustAccessServiceTokenRotateResponse +- zero_trust.AccessServiceTokens +- zero_trust.AccessServiceTokenNewResponse +- zero_trust.AccessServiceTokenRotateResponse Methods: -- client.ZeroTrust.Access.ServiceTokens.New(ctx context.Context, params cloudflare.ZeroTrustAccessServiceTokenNewParams) (cloudflare.ZeroTrustAccessServiceTokenNewResponse, error) -- client.ZeroTrust.Access.ServiceTokens.Update(ctx context.Context, uuid string, params cloudflare.ZeroTrustAccessServiceTokenUpdateParams) (cloudflare.ZeroTrustAccessServiceTokenUpdateResponse, error) -- client.ZeroTrust.Access.ServiceTokens.List(ctx context.Context, query cloudflare.ZeroTrustAccessServiceTokenListParams) ([]cloudflare.ZeroTrustAccessServiceTokenListResponse, error) -- client.ZeroTrust.Access.ServiceTokens.Delete(ctx context.Context, uuid string, body cloudflare.ZeroTrustAccessServiceTokenDeleteParams) (cloudflare.ZeroTrustAccessServiceTokenDeleteResponse, error) -- client.ZeroTrust.Access.ServiceTokens.Refresh(ctx context.Context, identifier string, uuid string) (cloudflare.ZeroTrustAccessServiceTokenRefreshResponse, error) -- client.ZeroTrust.Access.ServiceTokens.Rotate(ctx context.Context, identifier string, uuid string) (cloudflare.ZeroTrustAccessServiceTokenRotateResponse, error) +- client.ZeroTrust.Access.ServiceTokens.New(ctx context.Context, params zero_trust.AccessServiceTokenNewParams) (zero_trust.AccessServiceTokenNewResponse, error) +- client.ZeroTrust.Access.ServiceTokens.Update(ctx context.Context, uuid string, params zero_trust.AccessServiceTokenUpdateParams) (zero_trust.AccessServiceTokens, error) +- client.ZeroTrust.Access.ServiceTokens.List(ctx context.Context, query zero_trust.AccessServiceTokenListParams) ([]zero_trust.AccessServiceTokens, error) +- client.ZeroTrust.Access.ServiceTokens.Delete(ctx context.Context, uuid string, body zero_trust.AccessServiceTokenDeleteParams) (zero_trust.AccessServiceTokens, error) +- client.ZeroTrust.Access.ServiceTokens.Refresh(ctx context.Context, identifier string, uuid string) (zero_trust.AccessServiceTokens, error) +- client.ZeroTrust.Access.ServiceTokens.Rotate(ctx context.Context, identifier string, uuid string) (zero_trust.AccessServiceTokenRotateResponse, error) ### Bookmarks Response Types: -- cloudflare.ZeroTrustAccessBookmarkNewResponse -- cloudflare.ZeroTrustAccessBookmarkUpdateResponse -- cloudflare.ZeroTrustAccessBookmarkListResponse -- cloudflare.ZeroTrustAccessBookmarkDeleteResponse -- cloudflare.ZeroTrustAccessBookmarkGetResponse +- zero_trust.AccessBookmarks +- zero_trust.AccessBookmarkDeleteResponse Methods: -- client.ZeroTrust.Access.Bookmarks.New(ctx context.Context, identifier interface{}, uuid string) (cloudflare.ZeroTrustAccessBookmarkNewResponse, error) -- client.ZeroTrust.Access.Bookmarks.Update(ctx context.Context, identifier interface{}, uuid string) (cloudflare.ZeroTrustAccessBookmarkUpdateResponse, error) -- client.ZeroTrust.Access.Bookmarks.List(ctx context.Context, identifier interface{}) ([]cloudflare.ZeroTrustAccessBookmarkListResponse, error) -- client.ZeroTrust.Access.Bookmarks.Delete(ctx context.Context, identifier interface{}, uuid string) (cloudflare.ZeroTrustAccessBookmarkDeleteResponse, error) -- client.ZeroTrust.Access.Bookmarks.Get(ctx context.Context, identifier interface{}, uuid string) (cloudflare.ZeroTrustAccessBookmarkGetResponse, error) +- client.ZeroTrust.Access.Bookmarks.New(ctx context.Context, identifier interface{}, uuid string) (zero_trust.AccessBookmarks, error) +- client.ZeroTrust.Access.Bookmarks.Update(ctx context.Context, identifier interface{}, uuid string) (zero_trust.AccessBookmarks, error) +- client.ZeroTrust.Access.Bookmarks.List(ctx context.Context, identifier interface{}) ([]zero_trust.AccessBookmarks, error) +- client.ZeroTrust.Access.Bookmarks.Delete(ctx context.Context, identifier interface{}, uuid string) (zero_trust.AccessBookmarkDeleteResponse, error) +- client.ZeroTrust.Access.Bookmarks.Get(ctx context.Context, identifier interface{}, uuid string) (zero_trust.AccessBookmarks, error) ### Keys Response Types: -- cloudflare.ZeroTrustAccessKeyUpdateResponse -- cloudflare.ZeroTrustAccessKeyListResponse -- cloudflare.ZeroTrustAccessKeyRotateResponse +- zero_trust.AccessKeyUpdateResponse +- zero_trust.AccessKeyListResponse +- zero_trust.AccessKeyRotateResponse Methods: -- client.ZeroTrust.Access.Keys.Update(ctx context.Context, identifier string, body cloudflare.ZeroTrustAccessKeyUpdateParams) (cloudflare.ZeroTrustAccessKeyUpdateResponse, error) -- client.ZeroTrust.Access.Keys.List(ctx context.Context, identifier string) (cloudflare.ZeroTrustAccessKeyListResponse, error) -- client.ZeroTrust.Access.Keys.Rotate(ctx context.Context, identifier string) (cloudflare.ZeroTrustAccessKeyRotateResponse, error) +- client.ZeroTrust.Access.Keys.Update(ctx context.Context, identifier string, body zero_trust.AccessKeyUpdateParams) (zero_trust.AccessKeyUpdateResponse, error) +- client.ZeroTrust.Access.Keys.List(ctx context.Context, identifier string) (zero_trust.AccessKeyListResponse, error) +- client.ZeroTrust.Access.Keys.Rotate(ctx context.Context, identifier string) (zero_trust.AccessKeyRotateResponse, error) ### Logs @@ -4530,89 +4468,84 @@ Methods: Response Types: -- cloudflare.ZeroTrustAccessLogAccessRequestListResponse +- zero_trust.AccessAccessRequests Methods: -- client.ZeroTrust.Access.Logs.AccessRequests.List(ctx context.Context, identifier string) ([]cloudflare.ZeroTrustAccessLogAccessRequestListResponse, error) +- client.ZeroTrust.Access.Logs.AccessRequests.List(ctx context.Context, identifier string) ([]zero_trust.AccessAccessRequests, error) ### Users Response Types: -- cloudflare.ZeroTrustAccessUserListResponse +- zero_trust.AccessUsers Methods: -- client.ZeroTrust.Access.Users.List(ctx context.Context, identifier string) ([]cloudflare.ZeroTrustAccessUserListResponse, error) +- client.ZeroTrust.Access.Users.List(ctx context.Context, identifier string) ([]zero_trust.AccessUsers, error) #### ActiveSessions Response Types: -- cloudflare.ZeroTrustAccessUserActiveSessionListResponse -- cloudflare.ZeroTrustAccessUserActiveSessionGetResponse +- zero_trust.AccessUserActiveSessionListResponse +- zero_trust.AccessUserActiveSessionGetResponse Methods: -- client.ZeroTrust.Access.Users.ActiveSessions.List(ctx context.Context, identifier string, id string) ([]cloudflare.ZeroTrustAccessUserActiveSessionListResponse, error) -- client.ZeroTrust.Access.Users.ActiveSessions.Get(ctx context.Context, identifier string, id string, nonce string) (cloudflare.ZeroTrustAccessUserActiveSessionGetResponse, error) +- client.ZeroTrust.Access.Users.ActiveSessions.List(ctx context.Context, identifier string, id string) ([]zero_trust.AccessUserActiveSessionListResponse, error) +- client.ZeroTrust.Access.Users.ActiveSessions.Get(ctx context.Context, identifier string, id string, nonce string) (zero_trust.AccessUserActiveSessionGetResponse, error) #### LastSeenIdentity Response Types: -- cloudflare.ZeroTrustAccessUserLastSeenIdentityGetResponse +- zero_trust.AccessIdentity Methods: -- client.ZeroTrust.Access.Users.LastSeenIdentity.Get(ctx context.Context, identifier string, id string) (cloudflare.ZeroTrustAccessUserLastSeenIdentityGetResponse, error) +- client.ZeroTrust.Access.Users.LastSeenIdentity.Get(ctx context.Context, identifier string, id string) (zero_trust.AccessIdentity, error) #### FailedLogins Response Types: -- cloudflare.ZeroTrustAccessUserFailedLoginListResponse +- zero_trust.AccessUserFailedLoginListResponse Methods: -- client.ZeroTrust.Access.Users.FailedLogins.List(ctx context.Context, identifier string, id string) ([]cloudflare.ZeroTrustAccessUserFailedLoginListResponse, error) +- client.ZeroTrust.Access.Users.FailedLogins.List(ctx context.Context, identifier string, id string) ([]zero_trust.AccessUserFailedLoginListResponse, error) ### CustomPages Response Types: -- cloudflare.ZeroTrustAccessCustomPageNewResponse -- cloudflare.ZeroTrustAccessCustomPageUpdateResponse -- cloudflare.ZeroTrustAccessCustomPageListResponse -- cloudflare.ZeroTrustAccessCustomPageDeleteResponse -- cloudflare.ZeroTrustAccessCustomPageGetResponse +- zero_trust.AccessCustomPage +- zero_trust.AccessCustomPageWithoutHTML +- zero_trust.AccessCustomPageDeleteResponse Methods: -- client.ZeroTrust.Access.CustomPages.New(ctx context.Context, identifier string, body cloudflare.ZeroTrustAccessCustomPageNewParams) (cloudflare.ZeroTrustAccessCustomPageNewResponse, error) -- client.ZeroTrust.Access.CustomPages.Update(ctx context.Context, identifier string, uuid string, body cloudflare.ZeroTrustAccessCustomPageUpdateParams) (cloudflare.ZeroTrustAccessCustomPageUpdateResponse, error) -- client.ZeroTrust.Access.CustomPages.List(ctx context.Context, identifier string) ([]cloudflare.ZeroTrustAccessCustomPageListResponse, error) -- client.ZeroTrust.Access.CustomPages.Delete(ctx context.Context, identifier string, uuid string) (cloudflare.ZeroTrustAccessCustomPageDeleteResponse, error) -- client.ZeroTrust.Access.CustomPages.Get(ctx context.Context, identifier string, uuid string) (cloudflare.ZeroTrustAccessCustomPageGetResponse, error) +- client.ZeroTrust.Access.CustomPages.New(ctx context.Context, identifier string, body zero_trust.AccessCustomPageNewParams) (zero_trust.AccessCustomPageWithoutHTML, error) +- client.ZeroTrust.Access.CustomPages.Update(ctx context.Context, identifier string, uuid string, body zero_trust.AccessCustomPageUpdateParams) (zero_trust.AccessCustomPageWithoutHTML, error) +- client.ZeroTrust.Access.CustomPages.List(ctx context.Context, identifier string) ([]zero_trust.AccessCustomPageWithoutHTML, error) +- client.ZeroTrust.Access.CustomPages.Delete(ctx context.Context, identifier string, uuid string) (zero_trust.AccessCustomPageDeleteResponse, error) +- client.ZeroTrust.Access.CustomPages.Get(ctx context.Context, identifier string, uuid string) (zero_trust.AccessCustomPage, error) ### Tags Response Types: -- cloudflare.ZeroTrustAccessTagNewResponse -- cloudflare.ZeroTrustAccessTagUpdateResponse -- cloudflare.ZeroTrustAccessTagListResponse -- cloudflare.ZeroTrustAccessTagDeleteResponse -- cloudflare.ZeroTrustAccessTagGetResponse +- zero_trust.AccessTag +- zero_trust.AccessTagDeleteResponse Methods: -- client.ZeroTrust.Access.Tags.New(ctx context.Context, identifier string, body cloudflare.ZeroTrustAccessTagNewParams) (cloudflare.ZeroTrustAccessTagNewResponse, error) -- client.ZeroTrust.Access.Tags.Update(ctx context.Context, identifier string, tagName string, body cloudflare.ZeroTrustAccessTagUpdateParams) (cloudflare.ZeroTrustAccessTagUpdateResponse, error) -- client.ZeroTrust.Access.Tags.List(ctx context.Context, identifier string) ([]cloudflare.ZeroTrustAccessTagListResponse, error) -- client.ZeroTrust.Access.Tags.Delete(ctx context.Context, identifier string, name string) (cloudflare.ZeroTrustAccessTagDeleteResponse, error) -- client.ZeroTrust.Access.Tags.Get(ctx context.Context, identifier string, name string) (cloudflare.ZeroTrustAccessTagGetResponse, error) +- client.ZeroTrust.Access.Tags.New(ctx context.Context, identifier string, body zero_trust.AccessTagNewParams) (zero_trust.AccessTag, error) +- client.ZeroTrust.Access.Tags.Update(ctx context.Context, identifier string, tagName string, body zero_trust.AccessTagUpdateParams) (zero_trust.AccessTag, error) +- client.ZeroTrust.Access.Tags.List(ctx context.Context, identifier string) ([]zero_trust.AccessTag, error) +- client.ZeroTrust.Access.Tags.Delete(ctx context.Context, identifier string, name string) (zero_trust.AccessTagDeleteResponse, error) +- client.ZeroTrust.Access.Tags.Get(ctx context.Context, identifier string, name string) (zero_trust.AccessTag, error) ## DEX @@ -4620,11 +4553,11 @@ Methods: Response Types: -- cloudflare.ZeroTrustDEXColoListResponse +- zero_trust.DEXColoListResponse Methods: -- client.ZeroTrust.DEX.Colos.List(ctx context.Context, params cloudflare.ZeroTrustDEXColoListParams) ([]cloudflare.ZeroTrustDEXColoListResponse, error) +- client.ZeroTrust.DEX.Colos.List(ctx context.Context, params zero_trust.DEXColoListParams) ([]zero_trust.DEXColoListResponse, error) ### FleetStatus @@ -4632,67 +4565,68 @@ Methods: Response Types: -- cloudflare.ZeroTrustDEXFleetStatusDeviceListResponse +- zero_trust.DigitalExperienceMonitoringDevice Methods: -- client.ZeroTrust.DEX.FleetStatus.Devices.List(ctx context.Context, params cloudflare.ZeroTrustDEXFleetStatusDeviceListParams) (shared.V4PagePaginationArray[cloudflare.ZeroTrustDEXFleetStatusDeviceListResponse], error) +- client.ZeroTrust.DEX.FleetStatus.Devices.List(ctx context.Context, params zero_trust.DEXFleetStatusDeviceListParams) (shared.V4PagePaginationArray[zero_trust.DigitalExperienceMonitoringDevice], error) #### Live Response Types: -- cloudflare.ZeroTrustDEXFleetStatusLiveListResponse +- zero_trust.DEXFleetStatusLiveListResponse Methods: -- client.ZeroTrust.DEX.FleetStatus.Live.List(ctx context.Context, params cloudflare.ZeroTrustDEXFleetStatusLiveListParams) (cloudflare.ZeroTrustDEXFleetStatusLiveListResponse, error) +- client.ZeroTrust.DEX.FleetStatus.Live.List(ctx context.Context, params zero_trust.DEXFleetStatusLiveListParams) (zero_trust.DEXFleetStatusLiveListResponse, error) #### OverTime Methods: -- client.ZeroTrust.DEX.FleetStatus.OverTime.List(ctx context.Context, params cloudflare.ZeroTrustDEXFleetStatusOverTimeListParams) error +- client.ZeroTrust.DEX.FleetStatus.OverTime.List(ctx context.Context, params zero_trust.DEXFleetStatusOverTimeListParams) error ### HTTPTests Response Types: -- cloudflare.ZeroTrustDexhttpTestGetResponse +- zero_trust.DigitalExperienceMonitoringHTTPDetails Methods: -- client.ZeroTrust.DEX.HTTPTests.Get(ctx context.Context, testID string, params cloudflare.ZeroTrustDEXHTTPTestGetParams) (cloudflare.ZeroTrustDexhttpTestGetResponse, error) +- client.ZeroTrust.DEX.HTTPTests.Get(ctx context.Context, testID string, params zero_trust.DEXHTTPTestGetParams) (zero_trust.DigitalExperienceMonitoringHTTPDetails, error) #### Percentiles Response Types: -- cloudflare.ZeroTrustDexhttpTestPercentileListResponse +- zero_trust.DigitalExperienceMonitoringHTTPDetailsPercentiles Methods: -- client.ZeroTrust.DEX.HTTPTests.Percentiles.List(ctx context.Context, testID string, params cloudflare.ZeroTrustDEXHTTPTestPercentileListParams) (cloudflare.ZeroTrustDexhttpTestPercentileListResponse, error) +- client.ZeroTrust.DEX.HTTPTests.Percentiles.List(ctx context.Context, testID string, params zero_trust.DEXHTTPTestPercentileListParams) (zero_trust.DigitalExperienceMonitoringHTTPDetailsPercentiles, error) ### Tests Response Types: -- cloudflare.ZeroTrustDEXTestListResponse +- zero_trust.DigitalExperienceMonitoringTests +- zero_trust.DEXTestListResponse Methods: -- client.ZeroTrust.DEX.Tests.List(ctx context.Context, params cloudflare.ZeroTrustDEXTestListParams) (shared.V4PagePagination[cloudflare.ZeroTrustDEXTestListResponse], error) +- client.ZeroTrust.DEX.Tests.List(ctx context.Context, params zero_trust.DEXTestListParams) (shared.V4PagePagination[zero_trust.DEXTestListResponse], error) #### UniqueDevices Response Types: -- cloudflare.ZeroTrustDEXTestUniqueDeviceListResponse +- zero_trust.DigitalExperienceMonitoringUniqueDevices Methods: -- client.ZeroTrust.DEX.Tests.UniqueDevices.List(ctx context.Context, params cloudflare.ZeroTrustDEXTestUniqueDeviceListParams) (cloudflare.ZeroTrustDEXTestUniqueDeviceListResponse, error) +- client.ZeroTrust.DEX.Tests.UniqueDevices.List(ctx context.Context, params zero_trust.DEXTestUniqueDeviceListParams) (zero_trust.DigitalExperienceMonitoringUniqueDevices, error) ### TracerouteTestResults @@ -4700,109 +4634,103 @@ Methods: Response Types: -- cloudflare.ZeroTrustDEXTracerouteTestResultNetworkPathListResponse +- zero_trust.DigitalExperienceMonitoringTracerouteTestResultNetworkPath Methods: -- client.ZeroTrust.DEX.TracerouteTestResults.NetworkPath.List(ctx context.Context, testResultID string, query cloudflare.ZeroTrustDEXTracerouteTestResultNetworkPathListParams) (cloudflare.ZeroTrustDEXTracerouteTestResultNetworkPathListResponse, error) +- client.ZeroTrust.DEX.TracerouteTestResults.NetworkPath.List(ctx context.Context, testResultID string, query zero_trust.DEXTracerouteTestResultNetworkPathListParams) (zero_trust.DigitalExperienceMonitoringTracerouteTestResultNetworkPath, error) ### TracerouteTests Response Types: -- cloudflare.ZeroTrustDEXTracerouteTestGetResponse -- cloudflare.ZeroTrustDEXTracerouteTestNetworkPathResponse -- cloudflare.ZeroTrustDEXTracerouteTestPercentilesResponse +- zero_trust.DigitalExperienceMonitoringTracerouteDetails +- zero_trust.DigitalExperienceMonitoringTracerouteDetailsPercentiles +- zero_trust.DigitalExperienceMonitoringTracerouteTestNetworkPath Methods: -- client.ZeroTrust.DEX.TracerouteTests.Get(ctx context.Context, testID string, params cloudflare.ZeroTrustDEXTracerouteTestGetParams) (cloudflare.ZeroTrustDEXTracerouteTestGetResponse, error) -- client.ZeroTrust.DEX.TracerouteTests.NetworkPath(ctx context.Context, testID string, params cloudflare.ZeroTrustDEXTracerouteTestNetworkPathParams) (cloudflare.ZeroTrustDEXTracerouteTestNetworkPathResponse, error) -- client.ZeroTrust.DEX.TracerouteTests.Percentiles(ctx context.Context, testID string, params cloudflare.ZeroTrustDEXTracerouteTestPercentilesParams) (cloudflare.ZeroTrustDEXTracerouteTestPercentilesResponse, error) +- client.ZeroTrust.DEX.TracerouteTests.Get(ctx context.Context, testID string, params zero_trust.DEXTracerouteTestGetParams) (zero_trust.DigitalExperienceMonitoringTracerouteDetails, error) +- client.ZeroTrust.DEX.TracerouteTests.NetworkPath(ctx context.Context, testID string, params zero_trust.DEXTracerouteTestNetworkPathParams) (zero_trust.DigitalExperienceMonitoringTracerouteTestNetworkPath, error) +- client.ZeroTrust.DEX.TracerouteTests.Percentiles(ctx context.Context, testID string, params zero_trust.DEXTracerouteTestPercentilesParams) (zero_trust.DigitalExperienceMonitoringTracerouteDetailsPercentiles, error) ## Tunnels Response Types: -- cloudflare.ZeroTrustTunnelNewResponse -- cloudflare.ZeroTrustTunnelListResponse -- cloudflare.ZeroTrustTunnelDeleteResponse -- cloudflare.ZeroTrustTunnelEditResponse -- cloudflare.ZeroTrustTunnelGetResponse +- zero_trust.TunnelArgoTunnel +- zero_trust.TunnelListResponse +- zero_trust.TunnelEditResponse Methods: -- client.ZeroTrust.Tunnels.New(ctx context.Context, params cloudflare.ZeroTrustTunnelNewParams) (cloudflare.ZeroTrustTunnelNewResponse, error) -- client.ZeroTrust.Tunnels.List(ctx context.Context, params cloudflare.ZeroTrustTunnelListParams) (shared.V4PagePaginationArray[cloudflare.ZeroTrustTunnelListResponse], error) -- client.ZeroTrust.Tunnels.Delete(ctx context.Context, tunnelID string, params cloudflare.ZeroTrustTunnelDeleteParams) (cloudflare.ZeroTrustTunnelDeleteResponse, error) -- client.ZeroTrust.Tunnels.Edit(ctx context.Context, tunnelID string, params cloudflare.ZeroTrustTunnelEditParams) (cloudflare.ZeroTrustTunnelEditResponse, error) -- client.ZeroTrust.Tunnels.Get(ctx context.Context, tunnelID string, query cloudflare.ZeroTrustTunnelGetParams) (cloudflare.ZeroTrustTunnelGetResponse, error) +- client.ZeroTrust.Tunnels.New(ctx context.Context, params zero_trust.TunnelNewParams) (zero_trust.TunnelArgoTunnel, error) +- client.ZeroTrust.Tunnels.List(ctx context.Context, params zero_trust.TunnelListParams) (shared.V4PagePaginationArray[zero_trust.TunnelListResponse], error) +- client.ZeroTrust.Tunnels.Delete(ctx context.Context, tunnelID string, params zero_trust.TunnelDeleteParams) (zero_trust.TunnelArgoTunnel, error) +- client.ZeroTrust.Tunnels.Edit(ctx context.Context, tunnelID string, params zero_trust.TunnelEditParams) (zero_trust.TunnelEditResponse, error) +- client.ZeroTrust.Tunnels.Get(ctx context.Context, tunnelID string, query zero_trust.TunnelGetParams) (zero_trust.TunnelArgoTunnel, error) ### Configurations Response Types: -- cloudflare.ZeroTrustTunnelConfigurationUpdateResponse -- cloudflare.ZeroTrustTunnelConfigurationGetResponse +- zero_trust.TunnelConfigurationUpdateResponse +- zero_trust.TunnelConfigurationGetResponse Methods: -- client.ZeroTrust.Tunnels.Configurations.Update(ctx context.Context, tunnelID string, params cloudflare.ZeroTrustTunnelConfigurationUpdateParams) (cloudflare.ZeroTrustTunnelConfigurationUpdateResponse, error) -- client.ZeroTrust.Tunnels.Configurations.Get(ctx context.Context, tunnelID string, query cloudflare.ZeroTrustTunnelConfigurationGetParams) (cloudflare.ZeroTrustTunnelConfigurationGetResponse, error) +- client.ZeroTrust.Tunnels.Configurations.Update(ctx context.Context, tunnelID string, params zero_trust.TunnelConfigurationUpdateParams) (zero_trust.TunnelConfigurationUpdateResponse, error) +- client.ZeroTrust.Tunnels.Configurations.Get(ctx context.Context, tunnelID string, query zero_trust.TunnelConfigurationGetParams) (zero_trust.TunnelConfigurationGetResponse, error) ### Connections Response Types: -- cloudflare.ZeroTrustTunnelConnectionDeleteResponse -- cloudflare.ZeroTrustTunnelConnectionGetResponse +- zero_trust.TunnelTunnelClient +- zero_trust.TunnelConnectionDeleteResponse Methods: -- client.ZeroTrust.Tunnels.Connections.Delete(ctx context.Context, tunnelID string, params cloudflare.ZeroTrustTunnelConnectionDeleteParams) (cloudflare.ZeroTrustTunnelConnectionDeleteResponse, error) -- client.ZeroTrust.Tunnels.Connections.Get(ctx context.Context, tunnelID string, query cloudflare.ZeroTrustTunnelConnectionGetParams) ([]cloudflare.ZeroTrustTunnelConnectionGetResponse, error) +- client.ZeroTrust.Tunnels.Connections.Delete(ctx context.Context, tunnelID string, params zero_trust.TunnelConnectionDeleteParams) (zero_trust.TunnelConnectionDeleteResponse, error) +- client.ZeroTrust.Tunnels.Connections.Get(ctx context.Context, tunnelID string, query zero_trust.TunnelConnectionGetParams) ([]zero_trust.TunnelTunnelClient, error) ### Token Response Types: -- cloudflare.ZeroTrustTunnelTokenGetResponse +- zero_trust.TunnelTokenGetResponse Methods: -- client.ZeroTrust.Tunnels.Token.Get(ctx context.Context, tunnelID string, query cloudflare.ZeroTrustTunnelTokenGetParams) (cloudflare.ZeroTrustTunnelTokenGetResponse, error) +- client.ZeroTrust.Tunnels.Token.Get(ctx context.Context, tunnelID string, query zero_trust.TunnelTokenGetParams) (zero_trust.TunnelTokenGetResponse, error) ### Connectors -Response Types: - -- cloudflare.ZeroTrustTunnelConnectorGetResponse - Methods: -- client.ZeroTrust.Tunnels.Connectors.Get(ctx context.Context, tunnelID string, connectorID string, query cloudflare.ZeroTrustTunnelConnectorGetParams) (cloudflare.ZeroTrustTunnelConnectorGetResponse, error) +- client.ZeroTrust.Tunnels.Connectors.Get(ctx context.Context, tunnelID string, connectorID string, query zero_trust.TunnelConnectorGetParams) (zero_trust.TunnelTunnelClient, error) ### Management Response Types: -- cloudflare.ZeroTrustTunnelManagementNewResponse +- zero_trust.TunnelManagementNewResponse Methods: -- client.ZeroTrust.Tunnels.Management.New(ctx context.Context, tunnelID string, params cloudflare.ZeroTrustTunnelManagementNewParams) (cloudflare.ZeroTrustTunnelManagementNewResponse, error) +- client.ZeroTrust.Tunnels.Management.New(ctx context.Context, tunnelID string, params zero_trust.TunnelManagementNewParams) (zero_trust.TunnelManagementNewResponse, error) ## ConnectivitySettings Response Types: -- cloudflare.ZeroTrustConnectivitySettingEditResponse -- cloudflare.ZeroTrustConnectivitySettingGetResponse +- zero_trust.ConnectivitySettingEditResponse +- zero_trust.ConnectivitySettingGetResponse Methods: -- client.ZeroTrust.ConnectivitySettings.Edit(ctx context.Context, params cloudflare.ZeroTrustConnectivitySettingEditParams) (cloudflare.ZeroTrustConnectivitySettingEditResponse, error) -- client.ZeroTrust.ConnectivitySettings.Get(ctx context.Context, query cloudflare.ZeroTrustConnectivitySettingGetParams) (cloudflare.ZeroTrustConnectivitySettingGetResponse, error) +- client.ZeroTrust.ConnectivitySettings.Edit(ctx context.Context, params zero_trust.ConnectivitySettingEditParams) (zero_trust.ConnectivitySettingEditResponse, error) +- client.ZeroTrust.ConnectivitySettings.Get(ctx context.Context, query zero_trust.ConnectivitySettingGetParams) (zero_trust.ConnectivitySettingGetResponse, error) ## DLP @@ -4810,246 +4738,227 @@ Methods: Response Types: -- cloudflare.ZeroTrustDLPDatasetNewResponse -- cloudflare.ZeroTrustDLPDatasetUpdateResponse -- cloudflare.ZeroTrustDLPDatasetListResponse -- cloudflare.ZeroTrustDLPDatasetGetResponse +- zero_trust.DLPDataset +- zero_trust.DLPDatasetArray +- zero_trust.DLPDatasetCreation Methods: -- client.ZeroTrust.DLP.Datasets.New(ctx context.Context, params cloudflare.ZeroTrustDLPDatasetNewParams) (cloudflare.ZeroTrustDLPDatasetNewResponse, error) -- client.ZeroTrust.DLP.Datasets.Update(ctx context.Context, datasetID string, params cloudflare.ZeroTrustDLPDatasetUpdateParams) (cloudflare.ZeroTrustDLPDatasetUpdateResponse, error) -- client.ZeroTrust.DLP.Datasets.List(ctx context.Context, query cloudflare.ZeroTrustDLPDatasetListParams) ([]cloudflare.ZeroTrustDLPDatasetListResponse, error) -- client.ZeroTrust.DLP.Datasets.Delete(ctx context.Context, datasetID string, body cloudflare.ZeroTrustDLPDatasetDeleteParams) error -- client.ZeroTrust.DLP.Datasets.Get(ctx context.Context, datasetID string, query cloudflare.ZeroTrustDLPDatasetGetParams) (cloudflare.ZeroTrustDLPDatasetGetResponse, error) +- client.ZeroTrust.DLP.Datasets.New(ctx context.Context, params zero_trust.DLPDatasetNewParams) (zero_trust.DLPDatasetCreation, error) +- client.ZeroTrust.DLP.Datasets.Update(ctx context.Context, datasetID string, params zero_trust.DLPDatasetUpdateParams) (zero_trust.DLPDataset, error) +- client.ZeroTrust.DLP.Datasets.List(ctx context.Context, query zero_trust.DLPDatasetListParams) (zero_trust.DLPDatasetArray, error) +- client.ZeroTrust.DLP.Datasets.Delete(ctx context.Context, datasetID string, body zero_trust.DLPDatasetDeleteParams) error +- client.ZeroTrust.DLP.Datasets.Get(ctx context.Context, datasetID string, query zero_trust.DLPDatasetGetParams) (zero_trust.DLPDataset, error) #### Upload Response Types: -- cloudflare.ZeroTrustDLPDatasetUploadNewResponse -- cloudflare.ZeroTrustDLPDatasetUploadEditResponse +- zero_trust.DLPDatasetNewVersion Methods: -- client.ZeroTrust.DLP.Datasets.Upload.New(ctx context.Context, datasetID string, body cloudflare.ZeroTrustDLPDatasetUploadNewParams) (cloudflare.ZeroTrustDLPDatasetUploadNewResponse, error) -- client.ZeroTrust.DLP.Datasets.Upload.Edit(ctx context.Context, datasetID string, version int64, body cloudflare.ZeroTrustDLPDatasetUploadEditParams) (cloudflare.ZeroTrustDLPDatasetUploadEditResponse, error) +- client.ZeroTrust.DLP.Datasets.Upload.New(ctx context.Context, datasetID string, body zero_trust.DLPDatasetUploadNewParams) (zero_trust.DLPDatasetNewVersion, error) +- client.ZeroTrust.DLP.Datasets.Upload.Edit(ctx context.Context, datasetID string, version int64, body zero_trust.DLPDatasetUploadEditParams) (zero_trust.DLPDataset, error) ### Patterns Response Types: -- cloudflare.ZeroTrustDLPPatternValidateResponse +- zero_trust.DLPPatternValidateResponse Methods: -- client.ZeroTrust.DLP.Patterns.Validate(ctx context.Context, params cloudflare.ZeroTrustDLPPatternValidateParams) (cloudflare.ZeroTrustDLPPatternValidateResponse, error) +- client.ZeroTrust.DLP.Patterns.Validate(ctx context.Context, params zero_trust.DLPPatternValidateParams) (zero_trust.DLPPatternValidateResponse, error) ### PayloadLogs Response Types: -- cloudflare.ZeroTrustDLPPayloadLogUpdateResponse -- cloudflare.ZeroTrustDLPPayloadLogGetResponse +- zero_trust.DLPPayloadLogUpdateResponse +- zero_trust.DLPPayloadLogGetResponse Methods: -- client.ZeroTrust.DLP.PayloadLogs.Update(ctx context.Context, params cloudflare.ZeroTrustDLPPayloadLogUpdateParams) (cloudflare.ZeroTrustDLPPayloadLogUpdateResponse, error) -- client.ZeroTrust.DLP.PayloadLogs.Get(ctx context.Context, query cloudflare.ZeroTrustDLPPayloadLogGetParams) (cloudflare.ZeroTrustDLPPayloadLogGetResponse, error) +- client.ZeroTrust.DLP.PayloadLogs.Update(ctx context.Context, params zero_trust.DLPPayloadLogUpdateParams) (zero_trust.DLPPayloadLogUpdateResponse, error) +- client.ZeroTrust.DLP.PayloadLogs.Get(ctx context.Context, query zero_trust.DLPPayloadLogGetParams) (zero_trust.DLPPayloadLogGetResponse, error) ### Profiles Response Types: -- cloudflare.ZeroTrustDLPProfileListResponse -- cloudflare.ZeroTrustDLPProfileGetResponse +- zero_trust.DLPProfiles +- zero_trust.DLPProfileGetResponse Methods: -- client.ZeroTrust.DLP.Profiles.List(ctx context.Context, query cloudflare.ZeroTrustDLPProfileListParams) ([]cloudflare.ZeroTrustDLPProfileListResponse, error) -- client.ZeroTrust.DLP.Profiles.Get(ctx context.Context, profileID string, query cloudflare.ZeroTrustDLPProfileGetParams) (cloudflare.ZeroTrustDLPProfileGetResponse, error) +- client.ZeroTrust.DLP.Profiles.List(ctx context.Context, query zero_trust.DLPProfileListParams) ([]zero_trust.DLPProfiles, error) +- client.ZeroTrust.DLP.Profiles.Get(ctx context.Context, profileID string, query zero_trust.DLPProfileGetParams) (zero_trust.DLPProfileGetResponse, error) #### Customs Response Types: -- cloudflare.ZeroTrustDLPProfileCustomNewResponse -- cloudflare.ZeroTrustDLPProfileCustomUpdateResponse -- cloudflare.ZeroTrustDLPProfileCustomDeleteResponse -- cloudflare.ZeroTrustDLPProfileCustomGetResponse +- zero_trust.DLPCustomProfile +- zero_trust.DLPProfileCustomDeleteResponse Methods: -- client.ZeroTrust.DLP.Profiles.Customs.New(ctx context.Context, params cloudflare.ZeroTrustDLPProfileCustomNewParams) ([]cloudflare.ZeroTrustDLPProfileCustomNewResponse, error) -- client.ZeroTrust.DLP.Profiles.Customs.Update(ctx context.Context, profileID string, params cloudflare.ZeroTrustDLPProfileCustomUpdateParams) (cloudflare.ZeroTrustDLPProfileCustomUpdateResponse, error) -- client.ZeroTrust.DLP.Profiles.Customs.Delete(ctx context.Context, profileID string, body cloudflare.ZeroTrustDLPProfileCustomDeleteParams) (cloudflare.ZeroTrustDLPProfileCustomDeleteResponse, error) -- client.ZeroTrust.DLP.Profiles.Customs.Get(ctx context.Context, profileID string, query cloudflare.ZeroTrustDLPProfileCustomGetParams) (cloudflare.ZeroTrustDLPProfileCustomGetResponse, error) +- client.ZeroTrust.DLP.Profiles.Customs.New(ctx context.Context, params zero_trust.DLPProfileCustomNewParams) ([]zero_trust.DLPCustomProfile, error) +- client.ZeroTrust.DLP.Profiles.Customs.Update(ctx context.Context, profileID string, params zero_trust.DLPProfileCustomUpdateParams) (zero_trust.DLPCustomProfile, error) +- client.ZeroTrust.DLP.Profiles.Customs.Delete(ctx context.Context, profileID string, body zero_trust.DLPProfileCustomDeleteParams) (zero_trust.DLPProfileCustomDeleteResponse, error) +- client.ZeroTrust.DLP.Profiles.Customs.Get(ctx context.Context, profileID string, query zero_trust.DLPProfileCustomGetParams) (zero_trust.DLPCustomProfile, error) #### Predefineds Response Types: -- cloudflare.ZeroTrustDLPProfilePredefinedUpdateResponse -- cloudflare.ZeroTrustDLPProfilePredefinedGetResponse +- zero_trust.DLPPredefinedProfile Methods: -- client.ZeroTrust.DLP.Profiles.Predefineds.Update(ctx context.Context, profileID string, params cloudflare.ZeroTrustDLPProfilePredefinedUpdateParams) (cloudflare.ZeroTrustDLPProfilePredefinedUpdateResponse, error) -- client.ZeroTrust.DLP.Profiles.Predefineds.Get(ctx context.Context, profileID string, query cloudflare.ZeroTrustDLPProfilePredefinedGetParams) (cloudflare.ZeroTrustDLPProfilePredefinedGetResponse, error) +- client.ZeroTrust.DLP.Profiles.Predefineds.Update(ctx context.Context, profileID string, params zero_trust.DLPProfilePredefinedUpdateParams) (zero_trust.DLPPredefinedProfile, error) +- client.ZeroTrust.DLP.Profiles.Predefineds.Get(ctx context.Context, profileID string, query zero_trust.DLPProfilePredefinedGetParams) (zero_trust.DLPPredefinedProfile, error) ## Gateway Response Types: -- cloudflare.ZeroTrustGatewayNewResponse -- cloudflare.ZeroTrustGatewayListResponse +- zero_trust.GatewayNewResponse +- zero_trust.GatewayListResponse Methods: -- client.ZeroTrust.Gateway.New(ctx context.Context, body cloudflare.ZeroTrustGatewayNewParams) (cloudflare.ZeroTrustGatewayNewResponse, error) -- client.ZeroTrust.Gateway.List(ctx context.Context, query cloudflare.ZeroTrustGatewayListParams) (cloudflare.ZeroTrustGatewayListResponse, error) +- client.ZeroTrust.Gateway.New(ctx context.Context, body zero_trust.GatewayNewParams) (zero_trust.GatewayNewResponse, error) +- client.ZeroTrust.Gateway.List(ctx context.Context, query zero_trust.GatewayListParams) (zero_trust.GatewayListResponse, error) ### AuditSSHSettings Response Types: -- cloudflare.ZeroTrustGatewayAuditSSHSettingUpdateResponse -- cloudflare.ZeroTrustGatewayAuditSSHSettingGetResponse +- zero_trust.ZeroTrustGatewaySettings Methods: -- client.ZeroTrust.Gateway.AuditSSHSettings.Update(ctx context.Context, params cloudflare.ZeroTrustGatewayAuditSSHSettingUpdateParams) (cloudflare.ZeroTrustGatewayAuditSSHSettingUpdateResponse, error) -- client.ZeroTrust.Gateway.AuditSSHSettings.Get(ctx context.Context, query cloudflare.ZeroTrustGatewayAuditSSHSettingGetParams) (cloudflare.ZeroTrustGatewayAuditSSHSettingGetResponse, error) +- client.ZeroTrust.Gateway.AuditSSHSettings.Update(ctx context.Context, params zero_trust.GatewayAuditSSHSettingUpdateParams) (zero_trust.ZeroTrustGatewaySettings, error) +- client.ZeroTrust.Gateway.AuditSSHSettings.Get(ctx context.Context, query zero_trust.GatewayAuditSSHSettingGetParams) (zero_trust.ZeroTrustGatewaySettings, error) ### Categories Response Types: -- cloudflare.ZeroTrustGatewayCategoryListResponse +- zero_trust.ZeroTrustGatewayCategories Methods: -- client.ZeroTrust.Gateway.Categories.List(ctx context.Context, query cloudflare.ZeroTrustGatewayCategoryListParams) ([]cloudflare.ZeroTrustGatewayCategoryListResponse, error) +- client.ZeroTrust.Gateway.Categories.List(ctx context.Context, query zero_trust.GatewayCategoryListParams) ([]zero_trust.ZeroTrustGatewayCategories, error) ### AppTypes Response Types: -- cloudflare.ZeroTrustGatewayAppTypeListResponse +- zero_trust.ZeroTrustGatewayAppTypes Methods: -- client.ZeroTrust.Gateway.AppTypes.List(ctx context.Context, query cloudflare.ZeroTrustGatewayAppTypeListParams) ([]cloudflare.ZeroTrustGatewayAppTypeListResponse, error) +- client.ZeroTrust.Gateway.AppTypes.List(ctx context.Context, query zero_trust.GatewayAppTypeListParams) ([]zero_trust.ZeroTrustGatewayAppTypes, error) ### Configurations Response Types: -- cloudflare.ZeroTrustGatewayConfigurationUpdateResponse -- cloudflare.ZeroTrustGatewayConfigurationEditResponse -- cloudflare.ZeroTrustGatewayConfigurationGetResponse +- zero_trust.GatewayConfigurationUpdateResponse +- zero_trust.GatewayConfigurationEditResponse +- zero_trust.GatewayConfigurationGetResponse Methods: -- client.ZeroTrust.Gateway.Configurations.Update(ctx context.Context, params cloudflare.ZeroTrustGatewayConfigurationUpdateParams) (cloudflare.ZeroTrustGatewayConfigurationUpdateResponse, error) -- client.ZeroTrust.Gateway.Configurations.Edit(ctx context.Context, params cloudflare.ZeroTrustGatewayConfigurationEditParams) (cloudflare.ZeroTrustGatewayConfigurationEditResponse, error) -- client.ZeroTrust.Gateway.Configurations.Get(ctx context.Context, query cloudflare.ZeroTrustGatewayConfigurationGetParams) (cloudflare.ZeroTrustGatewayConfigurationGetResponse, error) +- client.ZeroTrust.Gateway.Configurations.Update(ctx context.Context, params zero_trust.GatewayConfigurationUpdateParams) (zero_trust.GatewayConfigurationUpdateResponse, error) +- client.ZeroTrust.Gateway.Configurations.Edit(ctx context.Context, params zero_trust.GatewayConfigurationEditParams) (zero_trust.GatewayConfigurationEditResponse, error) +- client.ZeroTrust.Gateway.Configurations.Get(ctx context.Context, query zero_trust.GatewayConfigurationGetParams) (zero_trust.GatewayConfigurationGetResponse, error) ### Lists Response Types: -- cloudflare.ZeroTrustGatewayListNewResponse -- cloudflare.ZeroTrustGatewayListUpdateResponse -- cloudflare.ZeroTrustGatewayListListResponse -- cloudflare.ZeroTrustGatewayListDeleteResponse -- cloudflare.ZeroTrustGatewayListEditResponse -- cloudflare.ZeroTrustGatewayListGetResponse +- zero_trust.ZeroTrustGatewayLists +- zero_trust.GatewayListNewResponse +- zero_trust.GatewayListDeleteResponse Methods: -- client.ZeroTrust.Gateway.Lists.New(ctx context.Context, params cloudflare.ZeroTrustGatewayListNewParams) (cloudflare.ZeroTrustGatewayListNewResponse, error) -- client.ZeroTrust.Gateway.Lists.Update(ctx context.Context, listID string, params cloudflare.ZeroTrustGatewayListUpdateParams) (cloudflare.ZeroTrustGatewayListUpdateResponse, error) -- client.ZeroTrust.Gateway.Lists.List(ctx context.Context, query cloudflare.ZeroTrustGatewayListListParams) ([]cloudflare.ZeroTrustGatewayListListResponse, error) -- client.ZeroTrust.Gateway.Lists.Delete(ctx context.Context, listID string, body cloudflare.ZeroTrustGatewayListDeleteParams) (cloudflare.ZeroTrustGatewayListDeleteResponse, error) -- client.ZeroTrust.Gateway.Lists.Edit(ctx context.Context, listID string, params cloudflare.ZeroTrustGatewayListEditParams) (cloudflare.ZeroTrustGatewayListEditResponse, error) -- client.ZeroTrust.Gateway.Lists.Get(ctx context.Context, listID string, query cloudflare.ZeroTrustGatewayListGetParams) (cloudflare.ZeroTrustGatewayListGetResponse, error) +- client.ZeroTrust.Gateway.Lists.New(ctx context.Context, params zero_trust.GatewayListNewParams) (zero_trust.GatewayListNewResponse, error) +- client.ZeroTrust.Gateway.Lists.Update(ctx context.Context, listID string, params zero_trust.GatewayListUpdateParams) (zero_trust.ZeroTrustGatewayLists, error) +- client.ZeroTrust.Gateway.Lists.List(ctx context.Context, query zero_trust.GatewayListListParams) ([]zero_trust.ZeroTrustGatewayLists, error) +- client.ZeroTrust.Gateway.Lists.Delete(ctx context.Context, listID string, body zero_trust.GatewayListDeleteParams) (zero_trust.GatewayListDeleteResponse, error) +- client.ZeroTrust.Gateway.Lists.Edit(ctx context.Context, listID string, params zero_trust.GatewayListEditParams) (zero_trust.ZeroTrustGatewayLists, error) +- client.ZeroTrust.Gateway.Lists.Get(ctx context.Context, listID string, query zero_trust.GatewayListGetParams) (zero_trust.ZeroTrustGatewayLists, error) #### Items Response Types: -- cloudflare.ZeroTrustGatewayListItemListResponse +- zero_trust.GatewayListItemListResponse Methods: -- client.ZeroTrust.Gateway.Lists.Items.List(ctx context.Context, listID string, query cloudflare.ZeroTrustGatewayListItemListParams) ([][]cloudflare.ZeroTrustGatewayListItemListResponse, error) +- client.ZeroTrust.Gateway.Lists.Items.List(ctx context.Context, listID string, query zero_trust.GatewayListItemListParams) ([][]zero_trust.GatewayListItemListResponse, error) ### Locations Response Types: -- cloudflare.ZeroTrustGatewayLocationNewResponse -- cloudflare.ZeroTrustGatewayLocationUpdateResponse -- cloudflare.ZeroTrustGatewayLocationListResponse -- cloudflare.ZeroTrustGatewayLocationDeleteResponse -- cloudflare.ZeroTrustGatewayLocationGetResponse +- zero_trust.ZeroTrustGatewayLocations +- zero_trust.GatewayLocationDeleteResponse Methods: -- client.ZeroTrust.Gateway.Locations.New(ctx context.Context, params cloudflare.ZeroTrustGatewayLocationNewParams) (cloudflare.ZeroTrustGatewayLocationNewResponse, error) -- client.ZeroTrust.Gateway.Locations.Update(ctx context.Context, locationID interface{}, params cloudflare.ZeroTrustGatewayLocationUpdateParams) (cloudflare.ZeroTrustGatewayLocationUpdateResponse, error) -- client.ZeroTrust.Gateway.Locations.List(ctx context.Context, query cloudflare.ZeroTrustGatewayLocationListParams) ([]cloudflare.ZeroTrustGatewayLocationListResponse, error) -- client.ZeroTrust.Gateway.Locations.Delete(ctx context.Context, locationID interface{}, body cloudflare.ZeroTrustGatewayLocationDeleteParams) (cloudflare.ZeroTrustGatewayLocationDeleteResponse, error) -- client.ZeroTrust.Gateway.Locations.Get(ctx context.Context, locationID interface{}, query cloudflare.ZeroTrustGatewayLocationGetParams) (cloudflare.ZeroTrustGatewayLocationGetResponse, error) +- client.ZeroTrust.Gateway.Locations.New(ctx context.Context, params zero_trust.GatewayLocationNewParams) (zero_trust.ZeroTrustGatewayLocations, error) +- client.ZeroTrust.Gateway.Locations.Update(ctx context.Context, locationID interface{}, params zero_trust.GatewayLocationUpdateParams) (zero_trust.ZeroTrustGatewayLocations, error) +- client.ZeroTrust.Gateway.Locations.List(ctx context.Context, query zero_trust.GatewayLocationListParams) ([]zero_trust.ZeroTrustGatewayLocations, error) +- client.ZeroTrust.Gateway.Locations.Delete(ctx context.Context, locationID interface{}, body zero_trust.GatewayLocationDeleteParams) (zero_trust.GatewayLocationDeleteResponse, error) +- client.ZeroTrust.Gateway.Locations.Get(ctx context.Context, locationID interface{}, query zero_trust.GatewayLocationGetParams) (zero_trust.ZeroTrustGatewayLocations, error) ### Loggings Response Types: -- cloudflare.ZeroTrustGatewayLoggingUpdateResponse -- cloudflare.ZeroTrustGatewayLoggingGetResponse +- zero_trust.ZeroTrustGatewayGatewayAccountLoggingSettings Methods: -- client.ZeroTrust.Gateway.Loggings.Update(ctx context.Context, params cloudflare.ZeroTrustGatewayLoggingUpdateParams) (cloudflare.ZeroTrustGatewayLoggingUpdateResponse, error) -- client.ZeroTrust.Gateway.Loggings.Get(ctx context.Context, query cloudflare.ZeroTrustGatewayLoggingGetParams) (cloudflare.ZeroTrustGatewayLoggingGetResponse, error) +- client.ZeroTrust.Gateway.Loggings.Update(ctx context.Context, params zero_trust.GatewayLoggingUpdateParams) (zero_trust.ZeroTrustGatewayGatewayAccountLoggingSettings, error) +- client.ZeroTrust.Gateway.Loggings.Get(ctx context.Context, query zero_trust.GatewayLoggingGetParams) (zero_trust.ZeroTrustGatewayGatewayAccountLoggingSettings, error) ### ProxyEndpoints Response Types: -- cloudflare.ZeroTrustGatewayProxyEndpointNewResponse -- cloudflare.ZeroTrustGatewayProxyEndpointListResponse -- cloudflare.ZeroTrustGatewayProxyEndpointDeleteResponse -- cloudflare.ZeroTrustGatewayProxyEndpointEditResponse -- cloudflare.ZeroTrustGatewayProxyEndpointGetResponse +- zero_trust.ZeroTrustGatewayProxyEndpoints +- zero_trust.GatewayProxyEndpointDeleteResponse Methods: -- client.ZeroTrust.Gateway.ProxyEndpoints.New(ctx context.Context, params cloudflare.ZeroTrustGatewayProxyEndpointNewParams) (cloudflare.ZeroTrustGatewayProxyEndpointNewResponse, error) -- client.ZeroTrust.Gateway.ProxyEndpoints.List(ctx context.Context, query cloudflare.ZeroTrustGatewayProxyEndpointListParams) ([]cloudflare.ZeroTrustGatewayProxyEndpointListResponse, error) -- client.ZeroTrust.Gateway.ProxyEndpoints.Delete(ctx context.Context, proxyEndpointID interface{}, body cloudflare.ZeroTrustGatewayProxyEndpointDeleteParams) (cloudflare.ZeroTrustGatewayProxyEndpointDeleteResponse, error) -- client.ZeroTrust.Gateway.ProxyEndpoints.Edit(ctx context.Context, proxyEndpointID interface{}, params cloudflare.ZeroTrustGatewayProxyEndpointEditParams) (cloudflare.ZeroTrustGatewayProxyEndpointEditResponse, error) -- client.ZeroTrust.Gateway.ProxyEndpoints.Get(ctx context.Context, proxyEndpointID interface{}, query cloudflare.ZeroTrustGatewayProxyEndpointGetParams) (cloudflare.ZeroTrustGatewayProxyEndpointGetResponse, error) +- client.ZeroTrust.Gateway.ProxyEndpoints.New(ctx context.Context, params zero_trust.GatewayProxyEndpointNewParams) (zero_trust.ZeroTrustGatewayProxyEndpoints, error) +- client.ZeroTrust.Gateway.ProxyEndpoints.List(ctx context.Context, query zero_trust.GatewayProxyEndpointListParams) ([]zero_trust.ZeroTrustGatewayProxyEndpoints, error) +- client.ZeroTrust.Gateway.ProxyEndpoints.Delete(ctx context.Context, proxyEndpointID interface{}, body zero_trust.GatewayProxyEndpointDeleteParams) (zero_trust.GatewayProxyEndpointDeleteResponse, error) +- client.ZeroTrust.Gateway.ProxyEndpoints.Edit(ctx context.Context, proxyEndpointID interface{}, params zero_trust.GatewayProxyEndpointEditParams) (zero_trust.ZeroTrustGatewayProxyEndpoints, error) +- client.ZeroTrust.Gateway.ProxyEndpoints.Get(ctx context.Context, proxyEndpointID interface{}, query zero_trust.GatewayProxyEndpointGetParams) (zero_trust.ZeroTrustGatewayProxyEndpoints, error) ### Rules Response Types: -- cloudflare.ZeroTrustGatewayRuleNewResponse -- cloudflare.ZeroTrustGatewayRuleUpdateResponse -- cloudflare.ZeroTrustGatewayRuleListResponse -- cloudflare.ZeroTrustGatewayRuleDeleteResponse -- cloudflare.ZeroTrustGatewayRuleGetResponse +- zero_trust.ZeroTrustGatewayRules +- zero_trust.GatewayRuleDeleteResponse Methods: -- client.ZeroTrust.Gateway.Rules.New(ctx context.Context, params cloudflare.ZeroTrustGatewayRuleNewParams) (cloudflare.ZeroTrustGatewayRuleNewResponse, error) -- client.ZeroTrust.Gateway.Rules.Update(ctx context.Context, ruleID string, params cloudflare.ZeroTrustGatewayRuleUpdateParams) (cloudflare.ZeroTrustGatewayRuleUpdateResponse, error) -- client.ZeroTrust.Gateway.Rules.List(ctx context.Context, query cloudflare.ZeroTrustGatewayRuleListParams) ([]cloudflare.ZeroTrustGatewayRuleListResponse, error) -- client.ZeroTrust.Gateway.Rules.Delete(ctx context.Context, ruleID string, body cloudflare.ZeroTrustGatewayRuleDeleteParams) (cloudflare.ZeroTrustGatewayRuleDeleteResponse, error) -- client.ZeroTrust.Gateway.Rules.Get(ctx context.Context, ruleID string, query cloudflare.ZeroTrustGatewayRuleGetParams) (cloudflare.ZeroTrustGatewayRuleGetResponse, error) +- client.ZeroTrust.Gateway.Rules.New(ctx context.Context, params zero_trust.GatewayRuleNewParams) (zero_trust.ZeroTrustGatewayRules, error) +- client.ZeroTrust.Gateway.Rules.Update(ctx context.Context, ruleID string, params zero_trust.GatewayRuleUpdateParams) (zero_trust.ZeroTrustGatewayRules, error) +- client.ZeroTrust.Gateway.Rules.List(ctx context.Context, query zero_trust.GatewayRuleListParams) ([]zero_trust.ZeroTrustGatewayRules, error) +- client.ZeroTrust.Gateway.Rules.Delete(ctx context.Context, ruleID string, body zero_trust.GatewayRuleDeleteParams) (zero_trust.GatewayRuleDeleteResponse, error) +- client.ZeroTrust.Gateway.Rules.Get(ctx context.Context, ruleID string, query zero_trust.GatewayRuleGetParams) (zero_trust.ZeroTrustGatewayRules, error) ## Networks @@ -5057,57 +4966,45 @@ Methods: Response Types: -- cloudflare.ZeroTrustNetworkRouteNewResponse -- cloudflare.ZeroTrustNetworkRouteListResponse -- cloudflare.ZeroTrustNetworkRouteDeleteResponse -- cloudflare.ZeroTrustNetworkRouteEditResponse +- zero_trust.TunnelRoute +- zero_trust.TunnelTeamnet Methods: -- client.ZeroTrust.Networks.Routes.New(ctx context.Context, params cloudflare.ZeroTrustNetworkRouteNewParams) (cloudflare.ZeroTrustNetworkRouteNewResponse, error) -- client.ZeroTrust.Networks.Routes.List(ctx context.Context, params cloudflare.ZeroTrustNetworkRouteListParams) (shared.V4PagePaginationArray[cloudflare.ZeroTrustNetworkRouteListResponse], error) -- client.ZeroTrust.Networks.Routes.Delete(ctx context.Context, routeID string, body cloudflare.ZeroTrustNetworkRouteDeleteParams) (cloudflare.ZeroTrustNetworkRouteDeleteResponse, error) -- client.ZeroTrust.Networks.Routes.Edit(ctx context.Context, routeID string, params cloudflare.ZeroTrustNetworkRouteEditParams) (cloudflare.ZeroTrustNetworkRouteEditResponse, error) +- client.ZeroTrust.Networks.Routes.New(ctx context.Context, params zero_trust.NetworkRouteNewParams) (zero_trust.TunnelRoute, error) +- client.ZeroTrust.Networks.Routes.List(ctx context.Context, params zero_trust.NetworkRouteListParams) (shared.V4PagePaginationArray[zero_trust.TunnelTeamnet], error) +- client.ZeroTrust.Networks.Routes.Delete(ctx context.Context, routeID string, body zero_trust.NetworkRouteDeleteParams) (zero_trust.TunnelRoute, error) +- client.ZeroTrust.Networks.Routes.Edit(ctx context.Context, routeID string, params zero_trust.NetworkRouteEditParams) (zero_trust.TunnelRoute, error) #### IPs -Response Types: - -- cloudflare.ZeroTrustNetworkRouteIPGetResponse - Methods: -- client.ZeroTrust.Networks.Routes.IPs.Get(ctx context.Context, ip string, params cloudflare.ZeroTrustNetworkRouteIPGetParams) (cloudflare.ZeroTrustNetworkRouteIPGetResponse, error) +- client.ZeroTrust.Networks.Routes.IPs.Get(ctx context.Context, ip string, params zero_trust.NetworkRouteIPGetParams) (zero_trust.TunnelTeamnet, error) #### Networks -Response Types: - -- cloudflare.ZeroTrustNetworkRouteNetworkNewResponse -- cloudflare.ZeroTrustNetworkRouteNetworkDeleteResponse -- cloudflare.ZeroTrustNetworkRouteNetworkEditResponse - Methods: -- client.ZeroTrust.Networks.Routes.Networks.New(ctx context.Context, ipNetworkEncoded string, params cloudflare.ZeroTrustNetworkRouteNetworkNewParams) (cloudflare.ZeroTrustNetworkRouteNetworkNewResponse, error) -- client.ZeroTrust.Networks.Routes.Networks.Delete(ctx context.Context, ipNetworkEncoded string, params cloudflare.ZeroTrustNetworkRouteNetworkDeleteParams) (cloudflare.ZeroTrustNetworkRouteNetworkDeleteResponse, error) -- client.ZeroTrust.Networks.Routes.Networks.Edit(ctx context.Context, ipNetworkEncoded string, body cloudflare.ZeroTrustNetworkRouteNetworkEditParams) (cloudflare.ZeroTrustNetworkRouteNetworkEditResponse, error) +- client.ZeroTrust.Networks.Routes.Networks.New(ctx context.Context, ipNetworkEncoded string, params zero_trust.NetworkRouteNetworkNewParams) (zero_trust.TunnelRoute, error) +- client.ZeroTrust.Networks.Routes.Networks.Delete(ctx context.Context, ipNetworkEncoded string, params zero_trust.NetworkRouteNetworkDeleteParams) (zero_trust.TunnelRoute, error) +- client.ZeroTrust.Networks.Routes.Networks.Edit(ctx context.Context, ipNetworkEncoded string, body zero_trust.NetworkRouteNetworkEditParams) (zero_trust.TunnelRoute, error) ### VirtualNetworks Response Types: -- cloudflare.ZeroTrustNetworkVirtualNetworkNewResponse -- cloudflare.ZeroTrustNetworkVirtualNetworkListResponse -- cloudflare.ZeroTrustNetworkVirtualNetworkDeleteResponse -- cloudflare.ZeroTrustNetworkVirtualNetworkEditResponse +- zero_trust.TunnelVirtualNetwork +- zero_trust.NetworkVirtualNetworkNewResponse +- zero_trust.NetworkVirtualNetworkDeleteResponse +- zero_trust.NetworkVirtualNetworkEditResponse Methods: -- client.ZeroTrust.Networks.VirtualNetworks.New(ctx context.Context, params cloudflare.ZeroTrustNetworkVirtualNetworkNewParams) (cloudflare.ZeroTrustNetworkVirtualNetworkNewResponse, error) -- client.ZeroTrust.Networks.VirtualNetworks.List(ctx context.Context, params cloudflare.ZeroTrustNetworkVirtualNetworkListParams) ([]cloudflare.ZeroTrustNetworkVirtualNetworkListResponse, error) -- client.ZeroTrust.Networks.VirtualNetworks.Delete(ctx context.Context, virtualNetworkID string, body cloudflare.ZeroTrustNetworkVirtualNetworkDeleteParams) (cloudflare.ZeroTrustNetworkVirtualNetworkDeleteResponse, error) -- client.ZeroTrust.Networks.VirtualNetworks.Edit(ctx context.Context, virtualNetworkID string, params cloudflare.ZeroTrustNetworkVirtualNetworkEditParams) (cloudflare.ZeroTrustNetworkVirtualNetworkEditResponse, error) +- client.ZeroTrust.Networks.VirtualNetworks.New(ctx context.Context, params zero_trust.NetworkVirtualNetworkNewParams) (zero_trust.NetworkVirtualNetworkNewResponse, error) +- client.ZeroTrust.Networks.VirtualNetworks.List(ctx context.Context, params zero_trust.NetworkVirtualNetworkListParams) ([]zero_trust.TunnelVirtualNetwork, error) +- client.ZeroTrust.Networks.VirtualNetworks.Delete(ctx context.Context, virtualNetworkID string, body zero_trust.NetworkVirtualNetworkDeleteParams) (zero_trust.NetworkVirtualNetworkDeleteResponse, error) +- client.ZeroTrust.Networks.VirtualNetworks.Edit(ctx context.Context, virtualNetworkID string, params zero_trust.NetworkVirtualNetworkEditParams) (zero_trust.NetworkVirtualNetworkEditResponse, error) # Challenges @@ -5115,21 +5012,17 @@ Methods: Response Types: -- cloudflare.ChallengeWidgetNewResponse -- cloudflare.ChallengeWidgetUpdateResponse -- cloudflare.ChallengeWidgetListResponse -- cloudflare.ChallengeWidgetDeleteResponse -- cloudflare.ChallengeWidgetGetResponse -- cloudflare.ChallengeWidgetRotateSecretResponse +- challenges.NcChallengesAdminWidgetDetail +- challenges.NcChallengesAdminWidgetList Methods: -- client.Challenges.Widgets.New(ctx context.Context, accountIdentifier string, params cloudflare.ChallengeWidgetNewParams) (cloudflare.ChallengeWidgetNewResponse, error) -- client.Challenges.Widgets.Update(ctx context.Context, accountIdentifier string, sitekey string, body cloudflare.ChallengeWidgetUpdateParams) (cloudflare.ChallengeWidgetUpdateResponse, error) -- client.Challenges.Widgets.List(ctx context.Context, accountIdentifier string, query cloudflare.ChallengeWidgetListParams) (shared.V4PagePaginationArray[cloudflare.ChallengeWidgetListResponse], error) -- client.Challenges.Widgets.Delete(ctx context.Context, accountIdentifier string, sitekey string) (cloudflare.ChallengeWidgetDeleteResponse, error) -- client.Challenges.Widgets.Get(ctx context.Context, accountIdentifier string, sitekey string) (cloudflare.ChallengeWidgetGetResponse, error) -- client.Challenges.Widgets.RotateSecret(ctx context.Context, accountIdentifier string, sitekey string, body cloudflare.ChallengeWidgetRotateSecretParams) (cloudflare.ChallengeWidgetRotateSecretResponse, error) +- client.Challenges.Widgets.New(ctx context.Context, accountIdentifier string, params challenges.WidgetNewParams) (challenges.NcChallengesAdminWidgetDetail, error) +- client.Challenges.Widgets.Update(ctx context.Context, accountIdentifier string, sitekey string, body challenges.WidgetUpdateParams) (challenges.NcChallengesAdminWidgetDetail, error) +- client.Challenges.Widgets.List(ctx context.Context, accountIdentifier string, query challenges.WidgetListParams) (shared.V4PagePaginationArray[challenges.NcChallengesAdminWidgetList], error) +- client.Challenges.Widgets.Delete(ctx context.Context, accountIdentifier string, sitekey string) (challenges.NcChallengesAdminWidgetDetail, error) +- client.Challenges.Widgets.Get(ctx context.Context, accountIdentifier string, sitekey string) (challenges.NcChallengesAdminWidgetDetail, error) +- client.Challenges.Widgets.RotateSecret(ctx context.Context, accountIdentifier string, sitekey string, body challenges.WidgetRotateSecretParams) (challenges.NcChallengesAdminWidgetDetail, error) # Hyperdrive @@ -5137,21 +5030,21 @@ Methods: Response Types: -- cloudflare.HyperdriveConfigNewResponse -- cloudflare.HyperdriveConfigUpdateResponse -- cloudflare.HyperdriveConfigListResponse -- cloudflare.HyperdriveConfigDeleteResponse -- cloudflare.HyperdriveConfigEditResponse -- cloudflare.HyperdriveConfigGetResponse +- hyperdrive.ConfigNewResponse +- hyperdrive.ConfigUpdateResponse +- hyperdrive.ConfigListResponse +- hyperdrive.ConfigDeleteResponse +- hyperdrive.ConfigEditResponse +- hyperdrive.ConfigGetResponse Methods: -- client.Hyperdrive.Configs.New(ctx context.Context, params cloudflare.HyperdriveConfigNewParams) (cloudflare.HyperdriveConfigNewResponse, error) -- client.Hyperdrive.Configs.Update(ctx context.Context, hyperdriveID string, params cloudflare.HyperdriveConfigUpdateParams) (cloudflare.HyperdriveConfigUpdateResponse, error) -- client.Hyperdrive.Configs.List(ctx context.Context, query cloudflare.HyperdriveConfigListParams) ([]cloudflare.HyperdriveConfigListResponse, error) -- client.Hyperdrive.Configs.Delete(ctx context.Context, hyperdriveID string, body cloudflare.HyperdriveConfigDeleteParams) (cloudflare.HyperdriveConfigDeleteResponse, error) -- client.Hyperdrive.Configs.Edit(ctx context.Context, hyperdriveID string, params cloudflare.HyperdriveConfigEditParams) (cloudflare.HyperdriveConfigEditResponse, error) -- client.Hyperdrive.Configs.Get(ctx context.Context, hyperdriveID string, query cloudflare.HyperdriveConfigGetParams) (cloudflare.HyperdriveConfigGetResponse, error) +- client.Hyperdrive.Configs.New(ctx context.Context, params hyperdrive.ConfigNewParams) (hyperdrive.ConfigNewResponse, error) +- client.Hyperdrive.Configs.Update(ctx context.Context, hyperdriveID string, params hyperdrive.ConfigUpdateParams) (hyperdrive.ConfigUpdateResponse, error) +- client.Hyperdrive.Configs.List(ctx context.Context, query hyperdrive.ConfigListParams) ([]hyperdrive.ConfigListResponse, error) +- client.Hyperdrive.Configs.Delete(ctx context.Context, hyperdriveID string, body hyperdrive.ConfigDeleteParams) (hyperdrive.ConfigDeleteResponse, error) +- client.Hyperdrive.Configs.Edit(ctx context.Context, hyperdriveID string, params hyperdrive.ConfigEditParams) (hyperdrive.ConfigEditResponse, error) +- client.Hyperdrive.Configs.Get(ctx context.Context, hyperdriveID string, query hyperdrive.ConfigGetParams) (hyperdrive.ConfigGetResponse, error) # RUM @@ -5159,35 +5052,31 @@ Methods: Response Types: -- cloudflare.RUMSiteInfoNewResponse -- cloudflare.RUMSiteInfoUpdateResponse -- cloudflare.RUMSiteInfoListResponse -- cloudflare.RUMSiteInfoDeleteResponse -- cloudflare.RUMSiteInfoGetResponse +- rum.RUMSite +- rum.SiteInfoDeleteResponse Methods: -- client.RUM.SiteInfos.New(ctx context.Context, params cloudflare.RUMSiteInfoNewParams) (cloudflare.RUMSiteInfoNewResponse, error) -- client.RUM.SiteInfos.Update(ctx context.Context, siteID string, params cloudflare.RUMSiteInfoUpdateParams) (cloudflare.RUMSiteInfoUpdateResponse, error) -- client.RUM.SiteInfos.List(ctx context.Context, params cloudflare.RUMSiteInfoListParams) (shared.V4PagePaginationArray[cloudflare.RUMSiteInfoListResponse], error) -- client.RUM.SiteInfos.Delete(ctx context.Context, siteID string, body cloudflare.RUMSiteInfoDeleteParams) (cloudflare.RUMSiteInfoDeleteResponse, error) -- client.RUM.SiteInfos.Get(ctx context.Context, siteID string, query cloudflare.RUMSiteInfoGetParams) (cloudflare.RUMSiteInfoGetResponse, error) +- client.RUM.SiteInfos.New(ctx context.Context, params rum.SiteInfoNewParams) (rum.RUMSite, error) +- client.RUM.SiteInfos.Update(ctx context.Context, siteID string, params rum.SiteInfoUpdateParams) (rum.RUMSite, error) +- client.RUM.SiteInfos.List(ctx context.Context, params rum.SiteInfoListParams) (shared.V4PagePaginationArray[rum.RUMSite], error) +- client.RUM.SiteInfos.Delete(ctx context.Context, siteID string, body rum.SiteInfoDeleteParams) (rum.SiteInfoDeleteResponse, error) +- client.RUM.SiteInfos.Get(ctx context.Context, siteID string, query rum.SiteInfoGetParams) (rum.RUMSite, error) ## Rules Response Types: -- cloudflare.RUMRuleNewResponse -- cloudflare.RUMRuleUpdateResponse -- cloudflare.RUMRuleListResponse -- cloudflare.RUMRuleDeleteResponse +- rum.RUMRule +- rum.RuleListResponse +- rum.RuleDeleteResponse Methods: -- client.RUM.Rules.New(ctx context.Context, rulesetID string, params cloudflare.RUMRuleNewParams) (cloudflare.RUMRuleNewResponse, error) -- client.RUM.Rules.Update(ctx context.Context, rulesetID string, ruleID string, params cloudflare.RUMRuleUpdateParams) (cloudflare.RUMRuleUpdateResponse, error) -- client.RUM.Rules.List(ctx context.Context, rulesetID string, query cloudflare.RUMRuleListParams) (cloudflare.RUMRuleListResponse, error) -- client.RUM.Rules.Delete(ctx context.Context, rulesetID string, ruleID string, body cloudflare.RUMRuleDeleteParams) (cloudflare.RUMRuleDeleteResponse, error) +- client.RUM.Rules.New(ctx context.Context, rulesetID string, params rum.RuleNewParams) (rum.RUMRule, error) +- client.RUM.Rules.Update(ctx context.Context, rulesetID string, ruleID string, params rum.RuleUpdateParams) (rum.RUMRule, error) +- client.RUM.Rules.List(ctx context.Context, rulesetID string, query rum.RuleListParams) (rum.RuleListResponse, error) +- client.RUM.Rules.Delete(ctx context.Context, rulesetID string, ruleID string, body rum.RuleDeleteParams) (rum.RuleDeleteResponse, error) # Vectorize @@ -5195,54 +5084,51 @@ Methods: Response Types: -- cloudflare.VectorizeIndexNewResponse -- cloudflare.VectorizeIndexUpdateResponse -- cloudflare.VectorizeIndexListResponse -- cloudflare.VectorizeIndexDeleteResponse -- cloudflare.VectorizeIndexDeleteByIDsResponse -- cloudflare.VectorizeIndexGetResponse -- cloudflare.VectorizeIndexGetByIDsResponse -- cloudflare.VectorizeIndexInsertResponse -- cloudflare.VectorizeIndexQueryResponse -- cloudflare.VectorizeIndexUpsertResponse +- vectorize.VectorizeCreateIndex +- vectorize.VectorizeIndexDeleteVectorsByID +- vectorize.VectorizeIndexInsert +- vectorize.VectorizeIndexQuery +- vectorize.VectorizeIndexUpsert +- vectorize.IndexDeleteResponse +- vectorize.IndexGetByIDsResponse Methods: -- client.Vectorize.Indexes.New(ctx context.Context, accountIdentifier string, body cloudflare.VectorizeIndexNewParams) (cloudflare.VectorizeIndexNewResponse, error) -- client.Vectorize.Indexes.Update(ctx context.Context, accountIdentifier string, indexName string, body cloudflare.VectorizeIndexUpdateParams) (cloudflare.VectorizeIndexUpdateResponse, error) -- client.Vectorize.Indexes.List(ctx context.Context, accountIdentifier string) ([]cloudflare.VectorizeIndexListResponse, error) -- client.Vectorize.Indexes.Delete(ctx context.Context, accountIdentifier string, indexName string) (cloudflare.VectorizeIndexDeleteResponse, error) -- client.Vectorize.Indexes.DeleteByIDs(ctx context.Context, accountIdentifier string, indexName string, body cloudflare.VectorizeIndexDeleteByIDsParams) (cloudflare.VectorizeIndexDeleteByIDsResponse, error) -- client.Vectorize.Indexes.Get(ctx context.Context, accountIdentifier string, indexName string) (cloudflare.VectorizeIndexGetResponse, error) -- client.Vectorize.Indexes.GetByIDs(ctx context.Context, accountIdentifier string, indexName string, body cloudflare.VectorizeIndexGetByIDsParams) (cloudflare.VectorizeIndexGetByIDsResponse, error) -- client.Vectorize.Indexes.Insert(ctx context.Context, accountIdentifier string, indexName string) (cloudflare.VectorizeIndexInsertResponse, error) -- client.Vectorize.Indexes.Query(ctx context.Context, accountIdentifier string, indexName string, body cloudflare.VectorizeIndexQueryParams) (cloudflare.VectorizeIndexQueryResponse, error) -- client.Vectorize.Indexes.Upsert(ctx context.Context, accountIdentifier string, indexName string) (cloudflare.VectorizeIndexUpsertResponse, error) +- client.Vectorize.Indexes.New(ctx context.Context, accountIdentifier string, body vectorize.IndexNewParams) (vectorize.VectorizeCreateIndex, error) +- client.Vectorize.Indexes.Update(ctx context.Context, accountIdentifier string, indexName string, body vectorize.IndexUpdateParams) (vectorize.VectorizeCreateIndex, error) +- client.Vectorize.Indexes.List(ctx context.Context, accountIdentifier string) ([]vectorize.VectorizeCreateIndex, error) +- client.Vectorize.Indexes.Delete(ctx context.Context, accountIdentifier string, indexName string) (vectorize.IndexDeleteResponse, error) +- client.Vectorize.Indexes.DeleteByIDs(ctx context.Context, accountIdentifier string, indexName string, body vectorize.IndexDeleteByIDsParams) (vectorize.VectorizeIndexDeleteVectorsByID, error) +- client.Vectorize.Indexes.Get(ctx context.Context, accountIdentifier string, indexName string) (vectorize.VectorizeCreateIndex, error) +- client.Vectorize.Indexes.GetByIDs(ctx context.Context, accountIdentifier string, indexName string, body vectorize.IndexGetByIDsParams) (vectorize.IndexGetByIDsResponse, error) +- client.Vectorize.Indexes.Insert(ctx context.Context, accountIdentifier string, indexName string) (vectorize.VectorizeIndexInsert, error) +- client.Vectorize.Indexes.Query(ctx context.Context, accountIdentifier string, indexName string, body vectorize.IndexQueryParams) (vectorize.VectorizeIndexQuery, error) +- client.Vectorize.Indexes.Upsert(ctx context.Context, accountIdentifier string, indexName string) (vectorize.VectorizeIndexUpsert, error) # URLScanner Response Types: -- cloudflare.URLScannerScanResponse +- url_scanner.URLScannerScanResponse Methods: -- client.URLScanner.Scan(ctx context.Context, accountID string, query cloudflare.URLScannerScanParams) (cloudflare.URLScannerScanResponse, error) +- client.URLScanner.Scan(ctx context.Context, accountID string, query url_scanner.URLScannerScanParams) (url_scanner.URLScannerScanResponse, error) ## Scans Response Types: -- cloudflare.URLScannerScanNewResponse -- cloudflare.URLScannerScanGetResponse -- cloudflare.URLScannerScanHarResponse +- url_scanner.ScanNewResponse +- url_scanner.ScanGetResponse +- url_scanner.ScanHarResponse Methods: -- client.URLScanner.Scans.New(ctx context.Context, accountID string, body cloudflare.URLScannerScanNewParams) (cloudflare.URLScannerScanNewResponse, error) -- client.URLScanner.Scans.Get(ctx context.Context, accountID string, scanID string) (cloudflare.URLScannerScanGetResponse, error) -- client.URLScanner.Scans.Har(ctx context.Context, accountID string, scanID string) (cloudflare.URLScannerScanHarResponse, error) -- client.URLScanner.Scans.Screenshot(ctx context.Context, accountID string, scanID string, query cloudflare.URLScannerScanScreenshotParams) (http.Response, error) +- client.URLScanner.Scans.New(ctx context.Context, accountID string, body url_scanner.ScanNewParams) (url_scanner.ScanNewResponse, error) +- client.URLScanner.Scans.Get(ctx context.Context, accountID string, scanID string) (url_scanner.ScanGetResponse, error) +- client.URLScanner.Scans.Har(ctx context.Context, accountID string, scanID string) (url_scanner.ScanHarResponse, error) +- client.URLScanner.Scans.Screenshot(ctx context.Context, accountID string, scanID string, query url_scanner.ScanScreenshotParams) (http.Response, error) # Radar @@ -5252,94 +5138,94 @@ Methods: Response Types: -- cloudflare.RadarAnnotationOutageGetResponse -- cloudflare.RadarAnnotationOutageLocationsResponse +- radar.AnnotationOutageGetResponse +- radar.AnnotationOutageLocationsResponse Methods: -- client.Radar.Annotations.Outages.Get(ctx context.Context, query cloudflare.RadarAnnotationOutageGetParams) (cloudflare.RadarAnnotationOutageGetResponse, error) -- client.Radar.Annotations.Outages.Locations(ctx context.Context, query cloudflare.RadarAnnotationOutageLocationsParams) (cloudflare.RadarAnnotationOutageLocationsResponse, error) +- client.Radar.Annotations.Outages.Get(ctx context.Context, query radar.AnnotationOutageGetParams) (radar.AnnotationOutageGetResponse, error) +- client.Radar.Annotations.Outages.Locations(ctx context.Context, query radar.AnnotationOutageLocationsParams) (radar.AnnotationOutageLocationsResponse, error) ## BGP Response Types: -- cloudflare.RadarBGPTimeseriesResponse +- radar.BGPTimeseriesResponse Methods: -- client.Radar.BGP.Timeseries(ctx context.Context, query cloudflare.RadarBGPTimeseriesParams) (cloudflare.RadarBGPTimeseriesResponse, error) +- client.Radar.BGP.Timeseries(ctx context.Context, query radar.BGPTimeseriesParams) (radar.BGPTimeseriesResponse, error) ### Leaks Response Types: -- cloudflare.RadarBGPLeakEventsResponse +- radar.BGPLeakEventsResponse Methods: -- client.Radar.BGP.Leaks.Events(ctx context.Context, query cloudflare.RadarBGPLeakEventsParams) (cloudflare.RadarBGPLeakEventsResponse, error) +- client.Radar.BGP.Leaks.Events(ctx context.Context, query radar.BGPLeakEventsParams) (radar.BGPLeakEventsResponse, error) ### Top Response Types: -- cloudflare.RadarBGPTopPrefixesResponse +- radar.BGPTopPrefixesResponse Methods: -- client.Radar.BGP.Top.Prefixes(ctx context.Context, query cloudflare.RadarBGPTopPrefixesParams) (cloudflare.RadarBGPTopPrefixesResponse, error) +- client.Radar.BGP.Top.Prefixes(ctx context.Context, query radar.BGPTopPrefixesParams) (radar.BGPTopPrefixesResponse, error) #### Ases Response Types: -- cloudflare.RadarBGPTopAseGetResponse -- cloudflare.RadarBGPTopAsePrefixesResponse +- radar.BGPTopAseGetResponse +- radar.BGPTopAsePrefixesResponse Methods: -- client.Radar.BGP.Top.Ases.Get(ctx context.Context, query cloudflare.RadarBGPTopAseGetParams) (cloudflare.RadarBGPTopAseGetResponse, error) -- client.Radar.BGP.Top.Ases.Prefixes(ctx context.Context, query cloudflare.RadarBGPTopAsePrefixesParams) (cloudflare.RadarBGPTopAsePrefixesResponse, error) +- client.Radar.BGP.Top.Ases.Get(ctx context.Context, query radar.BGPTopAseGetParams) (radar.BGPTopAseGetResponse, error) +- client.Radar.BGP.Top.Ases.Prefixes(ctx context.Context, query radar.BGPTopAsePrefixesParams) (radar.BGPTopAsePrefixesResponse, error) ### Hijacks Response Types: -- cloudflare.RadarBGPHijackEventsResponse +- radar.BGPHijackEventsResponse Methods: -- client.Radar.BGP.Hijacks.Events(ctx context.Context, query cloudflare.RadarBGPHijackEventsParams) (cloudflare.RadarBGPHijackEventsResponse, error) +- client.Radar.BGP.Hijacks.Events(ctx context.Context, query radar.BGPHijackEventsParams) (radar.BGPHijackEventsResponse, error) ### Routes Response Types: -- cloudflare.RadarBGPRouteMoasResponse -- cloudflare.RadarBGPRoutePfx2asResponse -- cloudflare.RadarBGPRouteStatsResponse -- cloudflare.RadarBGPRouteTimeseriesResponse +- radar.BGPRouteMoasResponse +- radar.BGPRoutePfx2asResponse +- radar.BGPRouteStatsResponse +- radar.BGPRouteTimeseriesResponse Methods: -- client.Radar.BGP.Routes.Moas(ctx context.Context, query cloudflare.RadarBGPRouteMoasParams) (cloudflare.RadarBGPRouteMoasResponse, error) -- client.Radar.BGP.Routes.Pfx2as(ctx context.Context, query cloudflare.RadarBGPRoutePfx2asParams) (cloudflare.RadarBGPRoutePfx2asResponse, error) -- client.Radar.BGP.Routes.Stats(ctx context.Context, query cloudflare.RadarBGPRouteStatsParams) (cloudflare.RadarBGPRouteStatsResponse, error) -- client.Radar.BGP.Routes.Timeseries(ctx context.Context, query cloudflare.RadarBGPRouteTimeseriesParams) (cloudflare.RadarBGPRouteTimeseriesResponse, error) +- client.Radar.BGP.Routes.Moas(ctx context.Context, query radar.BGPRouteMoasParams) (radar.BGPRouteMoasResponse, error) +- client.Radar.BGP.Routes.Pfx2as(ctx context.Context, query radar.BGPRoutePfx2asParams) (radar.BGPRoutePfx2asResponse, error) +- client.Radar.BGP.Routes.Stats(ctx context.Context, query radar.BGPRouteStatsParams) (radar.BGPRouteStatsResponse, error) +- client.Radar.BGP.Routes.Timeseries(ctx context.Context, query radar.BGPRouteTimeseriesParams) (radar.BGPRouteTimeseriesResponse, error) ## Datasets Response Types: -- cloudflare.RadarDatasetListResponse -- cloudflare.RadarDatasetDownloadResponse +- radar.DatasetListResponse +- radar.DatasetDownloadResponse Methods: -- client.Radar.Datasets.List(ctx context.Context, query cloudflare.RadarDatasetListParams) (cloudflare.RadarDatasetListResponse, error) -- client.Radar.Datasets.Download(ctx context.Context, params cloudflare.RadarDatasetDownloadParams) (cloudflare.RadarDatasetDownloadResponse, error) -- client.Radar.Datasets.Get(ctx context.Context, alias string, query cloudflare.RadarDatasetGetParams) (string, error) +- client.Radar.Datasets.List(ctx context.Context, query radar.DatasetListParams) (radar.DatasetListResponse, error) +- client.Radar.Datasets.Download(ctx context.Context, params radar.DatasetDownloadParams) (radar.DatasetDownloadResponse, error) +- client.Radar.Datasets.Get(ctx context.Context, alias string, query radar.DatasetGetParams) (string, error) ## DNS @@ -5347,45 +5233,45 @@ Methods: Response Types: -- cloudflare.RadarDNSTopAsesResponse -- cloudflare.RadarDNSTopLocationsResponse +- radar.DNSTopAsesResponse +- radar.DNSTopLocationsResponse Methods: -- client.Radar.DNS.Top.Ases(ctx context.Context, query cloudflare.RadarDNSTopAsesParams) (cloudflare.RadarDNSTopAsesResponse, error) -- client.Radar.DNS.Top.Locations(ctx context.Context, query cloudflare.RadarDNSTopLocationsParams) (cloudflare.RadarDNSTopLocationsResponse, error) +- client.Radar.DNS.Top.Ases(ctx context.Context, query radar.DNSTopAsesParams) (radar.DNSTopAsesResponse, error) +- client.Radar.DNS.Top.Locations(ctx context.Context, query radar.DNSTopLocationsParams) (radar.DNSTopLocationsResponse, error) ## Netflows Response Types: -- cloudflare.RadarNetflowTimeseriesResponse +- radar.NetflowTimeseriesResponse Methods: -- client.Radar.Netflows.Timeseries(ctx context.Context, query cloudflare.RadarNetflowTimeseriesParams) (cloudflare.RadarNetflowTimeseriesResponse, error) +- client.Radar.Netflows.Timeseries(ctx context.Context, query radar.NetflowTimeseriesParams) (radar.NetflowTimeseriesResponse, error) ### Top Response Types: -- cloudflare.RadarNetflowTopAsesResponse -- cloudflare.RadarNetflowTopLocationsResponse +- radar.NetflowTopAsesResponse +- radar.NetflowTopLocationsResponse Methods: -- client.Radar.Netflows.Top.Ases(ctx context.Context, query cloudflare.RadarNetflowTopAsesParams) (cloudflare.RadarNetflowTopAsesResponse, error) -- client.Radar.Netflows.Top.Locations(ctx context.Context, query cloudflare.RadarNetflowTopLocationsParams) (cloudflare.RadarNetflowTopLocationsResponse, error) +- client.Radar.Netflows.Top.Ases(ctx context.Context, query radar.NetflowTopAsesParams) (radar.NetflowTopAsesResponse, error) +- client.Radar.Netflows.Top.Locations(ctx context.Context, query radar.NetflowTopLocationsParams) (radar.NetflowTopLocationsResponse, error) ## Search Response Types: -- cloudflare.RadarSearchGlobalResponse +- radar.SearchGlobalResponse Methods: -- client.Radar.Search.Global(ctx context.Context, query cloudflare.RadarSearchGlobalParams) (cloudflare.RadarSearchGlobalResponse, error) +- client.Radar.Search.Global(ctx context.Context, query radar.SearchGlobalParams) (radar.SearchGlobalResponse, error) ## VerifiedBots @@ -5393,91 +5279,91 @@ Methods: Response Types: -- cloudflare.RadarVerifiedBotTopBotsResponse -- cloudflare.RadarVerifiedBotTopCategoriesResponse +- radar.VerifiedBotTopBotsResponse +- radar.VerifiedBotTopCategoriesResponse Methods: -- client.Radar.VerifiedBots.Top.Bots(ctx context.Context, query cloudflare.RadarVerifiedBotTopBotsParams) (cloudflare.RadarVerifiedBotTopBotsResponse, error) -- client.Radar.VerifiedBots.Top.Categories(ctx context.Context, query cloudflare.RadarVerifiedBotTopCategoriesParams) (cloudflare.RadarVerifiedBotTopCategoriesResponse, error) +- client.Radar.VerifiedBots.Top.Bots(ctx context.Context, query radar.VerifiedBotTopBotsParams) (radar.VerifiedBotTopBotsResponse, error) +- client.Radar.VerifiedBots.Top.Categories(ctx context.Context, query radar.VerifiedBotTopCategoriesParams) (radar.VerifiedBotTopCategoriesResponse, error) ## AS112 Response Types: -- cloudflare.RadarAS112TimeseriesResponse +- radar.AS112TimeseriesResponse Methods: -- client.Radar.AS112.Timeseries(ctx context.Context, query cloudflare.RadarAS112TimeseriesParams) (cloudflare.RadarAS112TimeseriesResponse, error) +- client.Radar.AS112.Timeseries(ctx context.Context, query radar.AS112TimeseriesParams) (radar.AS112TimeseriesResponse, error) ### Summary Response Types: -- cloudflare.RadarAS112SummaryDNSSECResponse -- cloudflare.RadarAS112SummaryEdnsResponse -- cloudflare.RadarAS112SummaryIPVersionResponse -- cloudflare.RadarAS112SummaryProtocolResponse -- cloudflare.RadarAS112SummaryQueryTypeResponse -- cloudflare.RadarAS112SummaryResponseCodesResponse +- radar.AS112SummaryDNSSECResponse +- radar.AS112SummaryEdnsResponse +- radar.AS112SummaryIPVersionResponse +- radar.AS112SummaryProtocolResponse +- radar.AS112SummaryQueryTypeResponse +- radar.AS112SummaryResponseCodesResponse Methods: -- client.Radar.AS112.Summary.DNSSEC(ctx context.Context, query cloudflare.RadarAS112SummaryDNSSECParams) (cloudflare.RadarAS112SummaryDNSSECResponse, error) -- client.Radar.AS112.Summary.Edns(ctx context.Context, query cloudflare.RadarAS112SummaryEdnsParams) (cloudflare.RadarAS112SummaryEdnsResponse, error) -- client.Radar.AS112.Summary.IPVersion(ctx context.Context, query cloudflare.RadarAS112SummaryIPVersionParams) (cloudflare.RadarAS112SummaryIPVersionResponse, error) -- client.Radar.AS112.Summary.Protocol(ctx context.Context, query cloudflare.RadarAS112SummaryProtocolParams) (cloudflare.RadarAS112SummaryProtocolResponse, error) -- client.Radar.AS112.Summary.QueryType(ctx context.Context, query cloudflare.RadarAS112SummaryQueryTypeParams) (cloudflare.RadarAS112SummaryQueryTypeResponse, error) -- client.Radar.AS112.Summary.ResponseCodes(ctx context.Context, query cloudflare.RadarAS112SummaryResponseCodesParams) (cloudflare.RadarAS112SummaryResponseCodesResponse, error) +- client.Radar.AS112.Summary.DNSSEC(ctx context.Context, query radar.AS112SummaryDNSSECParams) (radar.AS112SummaryDNSSECResponse, error) +- client.Radar.AS112.Summary.Edns(ctx context.Context, query radar.AS112SummaryEdnsParams) (radar.AS112SummaryEdnsResponse, error) +- client.Radar.AS112.Summary.IPVersion(ctx context.Context, query radar.AS112SummaryIPVersionParams) (radar.AS112SummaryIPVersionResponse, error) +- client.Radar.AS112.Summary.Protocol(ctx context.Context, query radar.AS112SummaryProtocolParams) (radar.AS112SummaryProtocolResponse, error) +- client.Radar.AS112.Summary.QueryType(ctx context.Context, query radar.AS112SummaryQueryTypeParams) (radar.AS112SummaryQueryTypeResponse, error) +- client.Radar.AS112.Summary.ResponseCodes(ctx context.Context, query radar.AS112SummaryResponseCodesParams) (radar.AS112SummaryResponseCodesResponse, error) ### TimeseriesGroups Response Types: -- cloudflare.RadarAS112TimeseriesGroupDNSSECResponse -- cloudflare.RadarAS112TimeseriesGroupEdnsResponse -- cloudflare.RadarAS112TimeseriesGroupIPVersionResponse -- cloudflare.RadarAS112TimeseriesGroupProtocolResponse -- cloudflare.RadarAS112TimeseriesGroupQueryTypeResponse -- cloudflare.RadarAS112TimeseriesGroupResponseCodesResponse +- radar.AS112TimeseriesGroupDNSSECResponse +- radar.AS112TimeseriesGroupEdnsResponse +- radar.AS112TimeseriesGroupIPVersionResponse +- radar.AS112TimeseriesGroupProtocolResponse +- radar.AS112TimeseriesGroupQueryTypeResponse +- radar.AS112TimeseriesGroupResponseCodesResponse Methods: -- client.Radar.AS112.TimeseriesGroups.DNSSEC(ctx context.Context, query cloudflare.RadarAS112TimeseriesGroupDNSSECParams) (cloudflare.RadarAS112TimeseriesGroupDNSSECResponse, error) -- client.Radar.AS112.TimeseriesGroups.Edns(ctx context.Context, query cloudflare.RadarAS112TimeseriesGroupEdnsParams) (cloudflare.RadarAS112TimeseriesGroupEdnsResponse, error) -- client.Radar.AS112.TimeseriesGroups.IPVersion(ctx context.Context, query cloudflare.RadarAS112TimeseriesGroupIPVersionParams) (cloudflare.RadarAS112TimeseriesGroupIPVersionResponse, error) -- client.Radar.AS112.TimeseriesGroups.Protocol(ctx context.Context, query cloudflare.RadarAS112TimeseriesGroupProtocolParams) (cloudflare.RadarAS112TimeseriesGroupProtocolResponse, error) -- client.Radar.AS112.TimeseriesGroups.QueryType(ctx context.Context, query cloudflare.RadarAS112TimeseriesGroupQueryTypeParams) (cloudflare.RadarAS112TimeseriesGroupQueryTypeResponse, error) -- client.Radar.AS112.TimeseriesGroups.ResponseCodes(ctx context.Context, query cloudflare.RadarAS112TimeseriesGroupResponseCodesParams) (cloudflare.RadarAS112TimeseriesGroupResponseCodesResponse, error) +- client.Radar.AS112.TimeseriesGroups.DNSSEC(ctx context.Context, query radar.AS112TimeseriesGroupDNSSECParams) (radar.AS112TimeseriesGroupDNSSECResponse, error) +- client.Radar.AS112.TimeseriesGroups.Edns(ctx context.Context, query radar.AS112TimeseriesGroupEdnsParams) (radar.AS112TimeseriesGroupEdnsResponse, error) +- client.Radar.AS112.TimeseriesGroups.IPVersion(ctx context.Context, query radar.AS112TimeseriesGroupIPVersionParams) (radar.AS112TimeseriesGroupIPVersionResponse, error) +- client.Radar.AS112.TimeseriesGroups.Protocol(ctx context.Context, query radar.AS112TimeseriesGroupProtocolParams) (radar.AS112TimeseriesGroupProtocolResponse, error) +- client.Radar.AS112.TimeseriesGroups.QueryType(ctx context.Context, query radar.AS112TimeseriesGroupQueryTypeParams) (radar.AS112TimeseriesGroupQueryTypeResponse, error) +- client.Radar.AS112.TimeseriesGroups.ResponseCodes(ctx context.Context, query radar.AS112TimeseriesGroupResponseCodesParams) (radar.AS112TimeseriesGroupResponseCodesResponse, error) ### Top Response Types: -- cloudflare.RadarAS112TopDNSSECResponse -- cloudflare.RadarAS112TopEdnsResponse -- cloudflare.RadarAS112TopIPVersionResponse -- cloudflare.RadarAS112TopLocationsResponse +- radar.AS112TopDNSSECResponse +- radar.AS112TopEdnsResponse +- radar.AS112TopIPVersionResponse +- radar.AS112TopLocationsResponse Methods: -- client.Radar.AS112.Top.DNSSEC(ctx context.Context, dnssec cloudflare.RadarAS112TopDNSSECParamsDNSSEC, query cloudflare.RadarAS112TopDNSSECParams) (cloudflare.RadarAS112TopDNSSECResponse, error) -- client.Radar.AS112.Top.Edns(ctx context.Context, edns cloudflare.RadarAS112TopEdnsParamsEdns, query cloudflare.RadarAS112TopEdnsParams) (cloudflare.RadarAS112TopEdnsResponse, error) -- client.Radar.AS112.Top.IPVersion(ctx context.Context, ipVersion cloudflare.RadarAS112TopIPVersionParamsIPVersion, query cloudflare.RadarAS112TopIPVersionParams) (cloudflare.RadarAS112TopIPVersionResponse, error) -- client.Radar.AS112.Top.Locations(ctx context.Context, query cloudflare.RadarAS112TopLocationsParams) (cloudflare.RadarAS112TopLocationsResponse, error) +- client.Radar.AS112.Top.DNSSEC(ctx context.Context, dnssec radar.AS112TopDNSSECParamsDNSSEC, query radar.AS112TopDNSSECParams) (radar.AS112TopDNSSECResponse, error) +- client.Radar.AS112.Top.Edns(ctx context.Context, edns radar.AS112TopEdnsParamsEdns, query radar.AS112TopEdnsParams) (radar.AS112TopEdnsResponse, error) +- client.Radar.AS112.Top.IPVersion(ctx context.Context, ipVersion radar.AS112TopIPVersionParamsIPVersion, query radar.AS112TopIPVersionParams) (radar.AS112TopIPVersionResponse, error) +- client.Radar.AS112.Top.Locations(ctx context.Context, query radar.AS112TopLocationsParams) (radar.AS112TopLocationsResponse, error) ## ConnectionTampering Response Types: -- cloudflare.RadarConnectionTamperingSummaryResponse -- cloudflare.RadarConnectionTamperingTimeseriesGroupsResponse +- radar.ConnectionTamperingSummaryResponse +- radar.ConnectionTamperingTimeseriesGroupsResponse Methods: -- client.Radar.ConnectionTampering.Summary(ctx context.Context, query cloudflare.RadarConnectionTamperingSummaryParams) (cloudflare.RadarConnectionTamperingSummaryResponse, error) -- client.Radar.ConnectionTampering.TimeseriesGroups(ctx context.Context, query cloudflare.RadarConnectionTamperingTimeseriesGroupsParams) (cloudflare.RadarConnectionTamperingTimeseriesGroupsResponse, error) +- client.Radar.ConnectionTampering.Summary(ctx context.Context, query radar.ConnectionTamperingSummaryParams) (radar.ConnectionTamperingSummaryResponse, error) +- client.Radar.ConnectionTampering.TimeseriesGroups(ctx context.Context, query radar.ConnectionTamperingTimeseriesGroupsParams) (radar.ConnectionTamperingTimeseriesGroupsResponse, error) ## Email @@ -5487,41 +5373,41 @@ Methods: Response Types: -- cloudflare.RadarEmailRoutingSummaryARCResponse -- cloudflare.RadarEmailRoutingSummaryDKIMResponse -- cloudflare.RadarEmailRoutingSummaryDMARCResponse -- cloudflare.RadarEmailRoutingSummaryEncryptedResponse -- cloudflare.RadarEmailRoutingSummaryIPVersionResponse -- cloudflare.RadarEmailRoutingSummarySPFResponse +- radar.EmailRoutingSummaryARCResponse +- radar.EmailRoutingSummaryDKIMResponse +- radar.EmailRoutingSummaryDMARCResponse +- radar.EmailRoutingSummaryEncryptedResponse +- radar.EmailRoutingSummaryIPVersionResponse +- radar.EmailRoutingSummarySPFResponse Methods: -- client.Radar.Email.Routing.Summary.ARC(ctx context.Context, query cloudflare.RadarEmailRoutingSummaryARCParams) (cloudflare.RadarEmailRoutingSummaryARCResponse, error) -- client.Radar.Email.Routing.Summary.DKIM(ctx context.Context, query cloudflare.RadarEmailRoutingSummaryDKIMParams) (cloudflare.RadarEmailRoutingSummaryDKIMResponse, error) -- client.Radar.Email.Routing.Summary.DMARC(ctx context.Context, query cloudflare.RadarEmailRoutingSummaryDMARCParams) (cloudflare.RadarEmailRoutingSummaryDMARCResponse, error) -- client.Radar.Email.Routing.Summary.Encrypted(ctx context.Context, query cloudflare.RadarEmailRoutingSummaryEncryptedParams) (cloudflare.RadarEmailRoutingSummaryEncryptedResponse, error) -- client.Radar.Email.Routing.Summary.IPVersion(ctx context.Context, query cloudflare.RadarEmailRoutingSummaryIPVersionParams) (cloudflare.RadarEmailRoutingSummaryIPVersionResponse, error) -- client.Radar.Email.Routing.Summary.SPF(ctx context.Context, query cloudflare.RadarEmailRoutingSummarySPFParams) (cloudflare.RadarEmailRoutingSummarySPFResponse, error) +- client.Radar.Email.Routing.Summary.ARC(ctx context.Context, query radar.EmailRoutingSummaryARCParams) (radar.EmailRoutingSummaryARCResponse, error) +- client.Radar.Email.Routing.Summary.DKIM(ctx context.Context, query radar.EmailRoutingSummaryDKIMParams) (radar.EmailRoutingSummaryDKIMResponse, error) +- client.Radar.Email.Routing.Summary.DMARC(ctx context.Context, query radar.EmailRoutingSummaryDMARCParams) (radar.EmailRoutingSummaryDMARCResponse, error) +- client.Radar.Email.Routing.Summary.Encrypted(ctx context.Context, query radar.EmailRoutingSummaryEncryptedParams) (radar.EmailRoutingSummaryEncryptedResponse, error) +- client.Radar.Email.Routing.Summary.IPVersion(ctx context.Context, query radar.EmailRoutingSummaryIPVersionParams) (radar.EmailRoutingSummaryIPVersionResponse, error) +- client.Radar.Email.Routing.Summary.SPF(ctx context.Context, query radar.EmailRoutingSummarySPFParams) (radar.EmailRoutingSummarySPFResponse, error) #### TimeseriesGroups Response Types: -- cloudflare.RadarEmailRoutingTimeseriesGroupARCResponse -- cloudflare.RadarEmailRoutingTimeseriesGroupDKIMResponse -- cloudflare.RadarEmailRoutingTimeseriesGroupDMARCResponse -- cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedResponse -- cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionResponse -- cloudflare.RadarEmailRoutingTimeseriesGroupSPFResponse +- radar.EmailRoutingTimeseriesGroupARCResponse +- radar.EmailRoutingTimeseriesGroupDKIMResponse +- radar.EmailRoutingTimeseriesGroupDMARCResponse +- radar.EmailRoutingTimeseriesGroupEncryptedResponse +- radar.EmailRoutingTimeseriesGroupIPVersionResponse +- radar.EmailRoutingTimeseriesGroupSPFResponse Methods: -- client.Radar.Email.Routing.TimeseriesGroups.ARC(ctx context.Context, query cloudflare.RadarEmailRoutingTimeseriesGroupARCParams) (cloudflare.RadarEmailRoutingTimeseriesGroupARCResponse, error) -- client.Radar.Email.Routing.TimeseriesGroups.DKIM(ctx context.Context, query cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParams) (cloudflare.RadarEmailRoutingTimeseriesGroupDKIMResponse, error) -- client.Radar.Email.Routing.TimeseriesGroups.DMARC(ctx context.Context, query cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParams) (cloudflare.RadarEmailRoutingTimeseriesGroupDMARCResponse, error) -- client.Radar.Email.Routing.TimeseriesGroups.Encrypted(ctx context.Context, query cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParams) (cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedResponse, error) -- client.Radar.Email.Routing.TimeseriesGroups.IPVersion(ctx context.Context, query cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParams) (cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionResponse, error) -- client.Radar.Email.Routing.TimeseriesGroups.SPF(ctx context.Context, query cloudflare.RadarEmailRoutingTimeseriesGroupSPFParams) (cloudflare.RadarEmailRoutingTimeseriesGroupSPFResponse, error) +- client.Radar.Email.Routing.TimeseriesGroups.ARC(ctx context.Context, query radar.EmailRoutingTimeseriesGroupARCParams) (radar.EmailRoutingTimeseriesGroupARCResponse, error) +- client.Radar.Email.Routing.TimeseriesGroups.DKIM(ctx context.Context, query radar.EmailRoutingTimeseriesGroupDKIMParams) (radar.EmailRoutingTimeseriesGroupDKIMResponse, error) +- client.Radar.Email.Routing.TimeseriesGroups.DMARC(ctx context.Context, query radar.EmailRoutingTimeseriesGroupDMARCParams) (radar.EmailRoutingTimeseriesGroupDMARCResponse, error) +- client.Radar.Email.Routing.TimeseriesGroups.Encrypted(ctx context.Context, query radar.EmailRoutingTimeseriesGroupEncryptedParams) (radar.EmailRoutingTimeseriesGroupEncryptedResponse, error) +- client.Radar.Email.Routing.TimeseriesGroups.IPVersion(ctx context.Context, query radar.EmailRoutingTimeseriesGroupIPVersionParams) (radar.EmailRoutingTimeseriesGroupIPVersionResponse, error) +- client.Radar.Email.Routing.TimeseriesGroups.SPF(ctx context.Context, query radar.EmailRoutingTimeseriesGroupSPFParams) (radar.EmailRoutingTimeseriesGroupSPFResponse, error) ### Security @@ -5531,93 +5417,93 @@ Methods: Response Types: -- cloudflare.RadarEmailSecurityTopTldGetResponse +- radar.EmailSecurityTopTldGetResponse Methods: -- client.Radar.Email.Security.Top.Tlds.Get(ctx context.Context, query cloudflare.RadarEmailSecurityTopTldGetParams) (cloudflare.RadarEmailSecurityTopTldGetResponse, error) +- client.Radar.Email.Security.Top.Tlds.Get(ctx context.Context, query radar.EmailSecurityTopTldGetParams) (radar.EmailSecurityTopTldGetResponse, error) ###### Malicious Response Types: -- cloudflare.RadarEmailSecurityTopTldMaliciousGetResponse +- radar.EmailSecurityTopTldMaliciousGetResponse Methods: -- client.Radar.Email.Security.Top.Tlds.Malicious.Get(ctx context.Context, malicious cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsMalicious, query cloudflare.RadarEmailSecurityTopTldMaliciousGetParams) (cloudflare.RadarEmailSecurityTopTldMaliciousGetResponse, error) +- client.Radar.Email.Security.Top.Tlds.Malicious.Get(ctx context.Context, malicious radar.EmailSecurityTopTldMaliciousGetParamsMalicious, query radar.EmailSecurityTopTldMaliciousGetParams) (radar.EmailSecurityTopTldMaliciousGetResponse, error) ###### Spam Response Types: -- cloudflare.RadarEmailSecurityTopTldSpamGetResponse +- radar.EmailSecurityTopTldSpamGetResponse Methods: -- client.Radar.Email.Security.Top.Tlds.Spam.Get(ctx context.Context, spam cloudflare.RadarEmailSecurityTopTldSpamGetParamsSpam, query cloudflare.RadarEmailSecurityTopTldSpamGetParams) (cloudflare.RadarEmailSecurityTopTldSpamGetResponse, error) +- client.Radar.Email.Security.Top.Tlds.Spam.Get(ctx context.Context, spam radar.EmailSecurityTopTldSpamGetParamsSpam, query radar.EmailSecurityTopTldSpamGetParams) (radar.EmailSecurityTopTldSpamGetResponse, error) ###### Spoof Response Types: -- cloudflare.RadarEmailSecurityTopTldSpoofGetResponse +- radar.EmailSecurityTopTldSpoofGetResponse Methods: -- client.Radar.Email.Security.Top.Tlds.Spoof.Get(ctx context.Context, spoof cloudflare.RadarEmailSecurityTopTldSpoofGetParamsSpoof, query cloudflare.RadarEmailSecurityTopTldSpoofGetParams) (cloudflare.RadarEmailSecurityTopTldSpoofGetResponse, error) +- client.Radar.Email.Security.Top.Tlds.Spoof.Get(ctx context.Context, spoof radar.EmailSecurityTopTldSpoofGetParamsSpoof, query radar.EmailSecurityTopTldSpoofGetParams) (radar.EmailSecurityTopTldSpoofGetResponse, error) #### Summary Response Types: -- cloudflare.RadarEmailSecuritySummaryARCResponse -- cloudflare.RadarEmailSecuritySummaryDKIMResponse -- cloudflare.RadarEmailSecuritySummaryDMARCResponse -- cloudflare.RadarEmailSecuritySummaryMaliciousResponse -- cloudflare.RadarEmailSecuritySummarySpamResponse -- cloudflare.RadarEmailSecuritySummarySPFResponse -- cloudflare.RadarEmailSecuritySummarySpoofResponse -- cloudflare.RadarEmailSecuritySummaryThreatCategoryResponse -- cloudflare.RadarEmailSecuritySummaryTLSVersionResponse +- radar.EmailSecuritySummaryARCResponse +- radar.EmailSecuritySummaryDKIMResponse +- radar.EmailSecuritySummaryDMARCResponse +- radar.EmailSecuritySummaryMaliciousResponse +- radar.EmailSecuritySummarySpamResponse +- radar.EmailSecuritySummarySPFResponse +- radar.EmailSecuritySummarySpoofResponse +- radar.EmailSecuritySummaryThreatCategoryResponse +- radar.EmailSecuritySummaryTLSVersionResponse Methods: -- client.Radar.Email.Security.Summary.ARC(ctx context.Context, query cloudflare.RadarEmailSecuritySummaryARCParams) (cloudflare.RadarEmailSecuritySummaryARCResponse, error) -- client.Radar.Email.Security.Summary.DKIM(ctx context.Context, query cloudflare.RadarEmailSecuritySummaryDKIMParams) (cloudflare.RadarEmailSecuritySummaryDKIMResponse, error) -- client.Radar.Email.Security.Summary.DMARC(ctx context.Context, query cloudflare.RadarEmailSecuritySummaryDMARCParams) (cloudflare.RadarEmailSecuritySummaryDMARCResponse, error) -- client.Radar.Email.Security.Summary.Malicious(ctx context.Context, query cloudflare.RadarEmailSecuritySummaryMaliciousParams) (cloudflare.RadarEmailSecuritySummaryMaliciousResponse, error) -- client.Radar.Email.Security.Summary.Spam(ctx context.Context, query cloudflare.RadarEmailSecuritySummarySpamParams) (cloudflare.RadarEmailSecuritySummarySpamResponse, error) -- client.Radar.Email.Security.Summary.SPF(ctx context.Context, query cloudflare.RadarEmailSecuritySummarySPFParams) (cloudflare.RadarEmailSecuritySummarySPFResponse, error) -- client.Radar.Email.Security.Summary.Spoof(ctx context.Context, query cloudflare.RadarEmailSecuritySummarySpoofParams) (cloudflare.RadarEmailSecuritySummarySpoofResponse, error) -- client.Radar.Email.Security.Summary.ThreatCategory(ctx context.Context, query cloudflare.RadarEmailSecuritySummaryThreatCategoryParams) (cloudflare.RadarEmailSecuritySummaryThreatCategoryResponse, error) -- client.Radar.Email.Security.Summary.TLSVersion(ctx context.Context, query cloudflare.RadarEmailSecuritySummaryTLSVersionParams) (cloudflare.RadarEmailSecuritySummaryTLSVersionResponse, error) +- client.Radar.Email.Security.Summary.ARC(ctx context.Context, query radar.EmailSecuritySummaryARCParams) (radar.EmailSecuritySummaryARCResponse, error) +- client.Radar.Email.Security.Summary.DKIM(ctx context.Context, query radar.EmailSecuritySummaryDKIMParams) (radar.EmailSecuritySummaryDKIMResponse, error) +- client.Radar.Email.Security.Summary.DMARC(ctx context.Context, query radar.EmailSecuritySummaryDMARCParams) (radar.EmailSecuritySummaryDMARCResponse, error) +- client.Radar.Email.Security.Summary.Malicious(ctx context.Context, query radar.EmailSecuritySummaryMaliciousParams) (radar.EmailSecuritySummaryMaliciousResponse, error) +- client.Radar.Email.Security.Summary.Spam(ctx context.Context, query radar.EmailSecuritySummarySpamParams) (radar.EmailSecuritySummarySpamResponse, error) +- client.Radar.Email.Security.Summary.SPF(ctx context.Context, query radar.EmailSecuritySummarySPFParams) (radar.EmailSecuritySummarySPFResponse, error) +- client.Radar.Email.Security.Summary.Spoof(ctx context.Context, query radar.EmailSecuritySummarySpoofParams) (radar.EmailSecuritySummarySpoofResponse, error) +- client.Radar.Email.Security.Summary.ThreatCategory(ctx context.Context, query radar.EmailSecuritySummaryThreatCategoryParams) (radar.EmailSecuritySummaryThreatCategoryResponse, error) +- client.Radar.Email.Security.Summary.TLSVersion(ctx context.Context, query radar.EmailSecuritySummaryTLSVersionParams) (radar.EmailSecuritySummaryTLSVersionResponse, error) #### TimeseriesGroups Response Types: -- cloudflare.RadarEmailSecurityTimeseriesGroupARCResponse -- cloudflare.RadarEmailSecurityTimeseriesGroupDKIMResponse -- cloudflare.RadarEmailSecurityTimeseriesGroupDMARCResponse -- cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousResponse -- cloudflare.RadarEmailSecurityTimeseriesGroupSpamResponse -- cloudflare.RadarEmailSecurityTimeseriesGroupSPFResponse -- cloudflare.RadarEmailSecurityTimeseriesGroupSpoofResponse -- cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryResponse -- cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionResponse +- radar.EmailSecurityTimeseriesGroupARCResponse +- radar.EmailSecurityTimeseriesGroupDKIMResponse +- radar.EmailSecurityTimeseriesGroupDMARCResponse +- radar.EmailSecurityTimeseriesGroupMaliciousResponse +- radar.EmailSecurityTimeseriesGroupSpamResponse +- radar.EmailSecurityTimeseriesGroupSPFResponse +- radar.EmailSecurityTimeseriesGroupSpoofResponse +- radar.EmailSecurityTimeseriesGroupThreatCategoryResponse +- radar.EmailSecurityTimeseriesGroupTLSVersionResponse Methods: -- client.Radar.Email.Security.TimeseriesGroups.ARC(ctx context.Context, query cloudflare.RadarEmailSecurityTimeseriesGroupARCParams) (cloudflare.RadarEmailSecurityTimeseriesGroupARCResponse, error) -- client.Radar.Email.Security.TimeseriesGroups.DKIM(ctx context.Context, query cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParams) (cloudflare.RadarEmailSecurityTimeseriesGroupDKIMResponse, error) -- client.Radar.Email.Security.TimeseriesGroups.DMARC(ctx context.Context, query cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParams) (cloudflare.RadarEmailSecurityTimeseriesGroupDMARCResponse, error) -- client.Radar.Email.Security.TimeseriesGroups.Malicious(ctx context.Context, query cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParams) (cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousResponse, error) -- client.Radar.Email.Security.TimeseriesGroups.Spam(ctx context.Context, query cloudflare.RadarEmailSecurityTimeseriesGroupSpamParams) (cloudflare.RadarEmailSecurityTimeseriesGroupSpamResponse, error) -- client.Radar.Email.Security.TimeseriesGroups.SPF(ctx context.Context, query cloudflare.RadarEmailSecurityTimeseriesGroupSPFParams) (cloudflare.RadarEmailSecurityTimeseriesGroupSPFResponse, error) -- client.Radar.Email.Security.TimeseriesGroups.Spoof(ctx context.Context, query cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParams) (cloudflare.RadarEmailSecurityTimeseriesGroupSpoofResponse, error) -- client.Radar.Email.Security.TimeseriesGroups.ThreatCategory(ctx context.Context, query cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParams) (cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryResponse, error) -- client.Radar.Email.Security.TimeseriesGroups.TLSVersion(ctx context.Context, query cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParams) (cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionResponse, error) +- client.Radar.Email.Security.TimeseriesGroups.ARC(ctx context.Context, query radar.EmailSecurityTimeseriesGroupARCParams) (radar.EmailSecurityTimeseriesGroupARCResponse, error) +- client.Radar.Email.Security.TimeseriesGroups.DKIM(ctx context.Context, query radar.EmailSecurityTimeseriesGroupDKIMParams) (radar.EmailSecurityTimeseriesGroupDKIMResponse, error) +- client.Radar.Email.Security.TimeseriesGroups.DMARC(ctx context.Context, query radar.EmailSecurityTimeseriesGroupDMARCParams) (radar.EmailSecurityTimeseriesGroupDMARCResponse, error) +- client.Radar.Email.Security.TimeseriesGroups.Malicious(ctx context.Context, query radar.EmailSecurityTimeseriesGroupMaliciousParams) (radar.EmailSecurityTimeseriesGroupMaliciousResponse, error) +- client.Radar.Email.Security.TimeseriesGroups.Spam(ctx context.Context, query radar.EmailSecurityTimeseriesGroupSpamParams) (radar.EmailSecurityTimeseriesGroupSpamResponse, error) +- client.Radar.Email.Security.TimeseriesGroups.SPF(ctx context.Context, query radar.EmailSecurityTimeseriesGroupSPFParams) (radar.EmailSecurityTimeseriesGroupSPFResponse, error) +- client.Radar.Email.Security.TimeseriesGroups.Spoof(ctx context.Context, query radar.EmailSecurityTimeseriesGroupSpoofParams) (radar.EmailSecurityTimeseriesGroupSpoofResponse, error) +- client.Radar.Email.Security.TimeseriesGroups.ThreatCategory(ctx context.Context, query radar.EmailSecurityTimeseriesGroupThreatCategoryParams) (radar.EmailSecurityTimeseriesGroupThreatCategoryResponse, error) +- client.Radar.Email.Security.TimeseriesGroups.TLSVersion(ctx context.Context, query radar.EmailSecurityTimeseriesGroupTLSVersionParams) (radar.EmailSecurityTimeseriesGroupTLSVersionResponse, error) ## Attacks @@ -5625,209 +5511,209 @@ Methods: Response Types: -- cloudflare.RadarAttackLayer3TimeseriesResponse +- radar.AttackLayer3TimeseriesResponse Methods: -- client.Radar.Attacks.Layer3.Timeseries(ctx context.Context, query cloudflare.RadarAttackLayer3TimeseriesParams) (cloudflare.RadarAttackLayer3TimeseriesResponse, error) +- client.Radar.Attacks.Layer3.Timeseries(ctx context.Context, query radar.AttackLayer3TimeseriesParams) (radar.AttackLayer3TimeseriesResponse, error) #### Summary Response Types: -- cloudflare.RadarAttackLayer3SummaryBitrateResponse -- cloudflare.RadarAttackLayer3SummaryDurationResponse -- cloudflare.RadarAttackLayer3SummaryGetResponse -- cloudflare.RadarAttackLayer3SummaryIPVersionResponse -- cloudflare.RadarAttackLayer3SummaryProtocolResponse -- cloudflare.RadarAttackLayer3SummaryVectorResponse +- radar.AttackLayer3SummaryBitrateResponse +- radar.AttackLayer3SummaryDurationResponse +- radar.AttackLayer3SummaryGetResponse +- radar.AttackLayer3SummaryIPVersionResponse +- radar.AttackLayer3SummaryProtocolResponse +- radar.AttackLayer3SummaryVectorResponse Methods: -- client.Radar.Attacks.Layer3.Summary.Bitrate(ctx context.Context, query cloudflare.RadarAttackLayer3SummaryBitrateParams) (cloudflare.RadarAttackLayer3SummaryBitrateResponse, error) -- client.Radar.Attacks.Layer3.Summary.Duration(ctx context.Context, query cloudflare.RadarAttackLayer3SummaryDurationParams) (cloudflare.RadarAttackLayer3SummaryDurationResponse, error) -- client.Radar.Attacks.Layer3.Summary.Get(ctx context.Context, query cloudflare.RadarAttackLayer3SummaryGetParams) (cloudflare.RadarAttackLayer3SummaryGetResponse, error) -- client.Radar.Attacks.Layer3.Summary.IPVersion(ctx context.Context, query cloudflare.RadarAttackLayer3SummaryIPVersionParams) (cloudflare.RadarAttackLayer3SummaryIPVersionResponse, error) -- client.Radar.Attacks.Layer3.Summary.Protocol(ctx context.Context, query cloudflare.RadarAttackLayer3SummaryProtocolParams) (cloudflare.RadarAttackLayer3SummaryProtocolResponse, error) -- client.Radar.Attacks.Layer3.Summary.Vector(ctx context.Context, query cloudflare.RadarAttackLayer3SummaryVectorParams) (cloudflare.RadarAttackLayer3SummaryVectorResponse, error) +- client.Radar.Attacks.Layer3.Summary.Bitrate(ctx context.Context, query radar.AttackLayer3SummaryBitrateParams) (radar.AttackLayer3SummaryBitrateResponse, error) +- client.Radar.Attacks.Layer3.Summary.Duration(ctx context.Context, query radar.AttackLayer3SummaryDurationParams) (radar.AttackLayer3SummaryDurationResponse, error) +- client.Radar.Attacks.Layer3.Summary.Get(ctx context.Context, query radar.AttackLayer3SummaryGetParams) (radar.AttackLayer3SummaryGetResponse, error) +- client.Radar.Attacks.Layer3.Summary.IPVersion(ctx context.Context, query radar.AttackLayer3SummaryIPVersionParams) (radar.AttackLayer3SummaryIPVersionResponse, error) +- client.Radar.Attacks.Layer3.Summary.Protocol(ctx context.Context, query radar.AttackLayer3SummaryProtocolParams) (radar.AttackLayer3SummaryProtocolResponse, error) +- client.Radar.Attacks.Layer3.Summary.Vector(ctx context.Context, query radar.AttackLayer3SummaryVectorParams) (radar.AttackLayer3SummaryVectorResponse, error) #### TimeseriesGroups Response Types: -- cloudflare.RadarAttackLayer3TimeseriesGroupBitrateResponse -- cloudflare.RadarAttackLayer3TimeseriesGroupDurationResponse -- cloudflare.RadarAttackLayer3TimeseriesGroupGetResponse -- cloudflare.RadarAttackLayer3TimeseriesGroupIndustryResponse -- cloudflare.RadarAttackLayer3TimeseriesGroupIPVersionResponse -- cloudflare.RadarAttackLayer3TimeseriesGroupProtocolResponse -- cloudflare.RadarAttackLayer3TimeseriesGroupVectorResponse -- cloudflare.RadarAttackLayer3TimeseriesGroupVerticalResponse +- radar.AttackLayer3TimeseriesGroupBitrateResponse +- radar.AttackLayer3TimeseriesGroupDurationResponse +- radar.AttackLayer3TimeseriesGroupGetResponse +- radar.AttackLayer3TimeseriesGroupIndustryResponse +- radar.AttackLayer3TimeseriesGroupIPVersionResponse +- radar.AttackLayer3TimeseriesGroupProtocolResponse +- radar.AttackLayer3TimeseriesGroupVectorResponse +- radar.AttackLayer3TimeseriesGroupVerticalResponse Methods: -- client.Radar.Attacks.Layer3.TimeseriesGroups.Bitrate(ctx context.Context, query cloudflare.RadarAttackLayer3TimeseriesGroupBitrateParams) (cloudflare.RadarAttackLayer3TimeseriesGroupBitrateResponse, error) -- client.Radar.Attacks.Layer3.TimeseriesGroups.Duration(ctx context.Context, query cloudflare.RadarAttackLayer3TimeseriesGroupDurationParams) (cloudflare.RadarAttackLayer3TimeseriesGroupDurationResponse, error) -- client.Radar.Attacks.Layer3.TimeseriesGroups.Get(ctx context.Context, query cloudflare.RadarAttackLayer3TimeseriesGroupGetParams) (cloudflare.RadarAttackLayer3TimeseriesGroupGetResponse, error) -- client.Radar.Attacks.Layer3.TimeseriesGroups.Industry(ctx context.Context, query cloudflare.RadarAttackLayer3TimeseriesGroupIndustryParams) (cloudflare.RadarAttackLayer3TimeseriesGroupIndustryResponse, error) -- client.Radar.Attacks.Layer3.TimeseriesGroups.IPVersion(ctx context.Context, query cloudflare.RadarAttackLayer3TimeseriesGroupIPVersionParams) (cloudflare.RadarAttackLayer3TimeseriesGroupIPVersionResponse, error) -- client.Radar.Attacks.Layer3.TimeseriesGroups.Protocol(ctx context.Context, query cloudflare.RadarAttackLayer3TimeseriesGroupProtocolParams) (cloudflare.RadarAttackLayer3TimeseriesGroupProtocolResponse, error) -- client.Radar.Attacks.Layer3.TimeseriesGroups.Vector(ctx context.Context, query cloudflare.RadarAttackLayer3TimeseriesGroupVectorParams) (cloudflare.RadarAttackLayer3TimeseriesGroupVectorResponse, error) -- client.Radar.Attacks.Layer3.TimeseriesGroups.Vertical(ctx context.Context, query cloudflare.RadarAttackLayer3TimeseriesGroupVerticalParams) (cloudflare.RadarAttackLayer3TimeseriesGroupVerticalResponse, error) +- client.Radar.Attacks.Layer3.TimeseriesGroups.Bitrate(ctx context.Context, query radar.AttackLayer3TimeseriesGroupBitrateParams) (radar.AttackLayer3TimeseriesGroupBitrateResponse, error) +- client.Radar.Attacks.Layer3.TimeseriesGroups.Duration(ctx context.Context, query radar.AttackLayer3TimeseriesGroupDurationParams) (radar.AttackLayer3TimeseriesGroupDurationResponse, error) +- client.Radar.Attacks.Layer3.TimeseriesGroups.Get(ctx context.Context, query radar.AttackLayer3TimeseriesGroupGetParams) (radar.AttackLayer3TimeseriesGroupGetResponse, error) +- client.Radar.Attacks.Layer3.TimeseriesGroups.Industry(ctx context.Context, query radar.AttackLayer3TimeseriesGroupIndustryParams) (radar.AttackLayer3TimeseriesGroupIndustryResponse, error) +- client.Radar.Attacks.Layer3.TimeseriesGroups.IPVersion(ctx context.Context, query radar.AttackLayer3TimeseriesGroupIPVersionParams) (radar.AttackLayer3TimeseriesGroupIPVersionResponse, error) +- client.Radar.Attacks.Layer3.TimeseriesGroups.Protocol(ctx context.Context, query radar.AttackLayer3TimeseriesGroupProtocolParams) (radar.AttackLayer3TimeseriesGroupProtocolResponse, error) +- client.Radar.Attacks.Layer3.TimeseriesGroups.Vector(ctx context.Context, query radar.AttackLayer3TimeseriesGroupVectorParams) (radar.AttackLayer3TimeseriesGroupVectorResponse, error) +- client.Radar.Attacks.Layer3.TimeseriesGroups.Vertical(ctx context.Context, query radar.AttackLayer3TimeseriesGroupVerticalParams) (radar.AttackLayer3TimeseriesGroupVerticalResponse, error) #### Top Response Types: -- cloudflare.RadarAttackLayer3TopAttacksResponse -- cloudflare.RadarAttackLayer3TopIndustryResponse -- cloudflare.RadarAttackLayer3TopVerticalResponse +- radar.AttackLayer3TopAttacksResponse +- radar.AttackLayer3TopIndustryResponse +- radar.AttackLayer3TopVerticalResponse Methods: -- client.Radar.Attacks.Layer3.Top.Attacks(ctx context.Context, query cloudflare.RadarAttackLayer3TopAttacksParams) (cloudflare.RadarAttackLayer3TopAttacksResponse, error) -- client.Radar.Attacks.Layer3.Top.Industry(ctx context.Context, query cloudflare.RadarAttackLayer3TopIndustryParams) (cloudflare.RadarAttackLayer3TopIndustryResponse, error) -- client.Radar.Attacks.Layer3.Top.Vertical(ctx context.Context, query cloudflare.RadarAttackLayer3TopVerticalParams) (cloudflare.RadarAttackLayer3TopVerticalResponse, error) +- client.Radar.Attacks.Layer3.Top.Attacks(ctx context.Context, query radar.AttackLayer3TopAttacksParams) (radar.AttackLayer3TopAttacksResponse, error) +- client.Radar.Attacks.Layer3.Top.Industry(ctx context.Context, query radar.AttackLayer3TopIndustryParams) (radar.AttackLayer3TopIndustryResponse, error) +- client.Radar.Attacks.Layer3.Top.Vertical(ctx context.Context, query radar.AttackLayer3TopVerticalParams) (radar.AttackLayer3TopVerticalResponse, error) ##### Locations Response Types: -- cloudflare.RadarAttackLayer3TopLocationOriginResponse -- cloudflare.RadarAttackLayer3TopLocationTargetResponse +- radar.AttackLayer3TopLocationOriginResponse +- radar.AttackLayer3TopLocationTargetResponse Methods: -- client.Radar.Attacks.Layer3.Top.Locations.Origin(ctx context.Context, query cloudflare.RadarAttackLayer3TopLocationOriginParams) (cloudflare.RadarAttackLayer3TopLocationOriginResponse, error) -- client.Radar.Attacks.Layer3.Top.Locations.Target(ctx context.Context, query cloudflare.RadarAttackLayer3TopLocationTargetParams) (cloudflare.RadarAttackLayer3TopLocationTargetResponse, error) +- client.Radar.Attacks.Layer3.Top.Locations.Origin(ctx context.Context, query radar.AttackLayer3TopLocationOriginParams) (radar.AttackLayer3TopLocationOriginResponse, error) +- client.Radar.Attacks.Layer3.Top.Locations.Target(ctx context.Context, query radar.AttackLayer3TopLocationTargetParams) (radar.AttackLayer3TopLocationTargetResponse, error) ### Layer7 Response Types: -- cloudflare.RadarAttackLayer7TimeseriesResponse +- radar.AttackLayer7TimeseriesResponse Methods: -- client.Radar.Attacks.Layer7.Timeseries(ctx context.Context, query cloudflare.RadarAttackLayer7TimeseriesParams) (cloudflare.RadarAttackLayer7TimeseriesResponse, error) +- client.Radar.Attacks.Layer7.Timeseries(ctx context.Context, query radar.AttackLayer7TimeseriesParams) (radar.AttackLayer7TimeseriesResponse, error) #### Summary Response Types: -- cloudflare.RadarAttackLayer7SummaryGetResponse -- cloudflare.RadarAttackLayer7SummaryHTTPMethodResponse -- cloudflare.RadarAttackLayer7SummaryHTTPVersionResponse -- cloudflare.RadarAttackLayer7SummaryIPVersionResponse -- cloudflare.RadarAttackLayer7SummaryManagedRulesResponse -- cloudflare.RadarAttackLayer7SummaryMitigationProductResponse +- radar.AttackLayer7SummaryGetResponse +- radar.AttackLayer7SummaryHTTPMethodResponse +- radar.AttackLayer7SummaryHTTPVersionResponse +- radar.AttackLayer7SummaryIPVersionResponse +- radar.AttackLayer7SummaryManagedRulesResponse +- radar.AttackLayer7SummaryMitigationProductResponse Methods: -- client.Radar.Attacks.Layer7.Summary.Get(ctx context.Context, query cloudflare.RadarAttackLayer7SummaryGetParams) (cloudflare.RadarAttackLayer7SummaryGetResponse, error) -- client.Radar.Attacks.Layer7.Summary.HTTPMethod(ctx context.Context, query cloudflare.RadarAttackLayer7SummaryHTTPMethodParams) (cloudflare.RadarAttackLayer7SummaryHTTPMethodResponse, error) -- client.Radar.Attacks.Layer7.Summary.HTTPVersion(ctx context.Context, query cloudflare.RadarAttackLayer7SummaryHTTPVersionParams) (cloudflare.RadarAttackLayer7SummaryHTTPVersionResponse, error) -- client.Radar.Attacks.Layer7.Summary.IPVersion(ctx context.Context, query cloudflare.RadarAttackLayer7SummaryIPVersionParams) (cloudflare.RadarAttackLayer7SummaryIPVersionResponse, error) -- client.Radar.Attacks.Layer7.Summary.ManagedRules(ctx context.Context, query cloudflare.RadarAttackLayer7SummaryManagedRulesParams) (cloudflare.RadarAttackLayer7SummaryManagedRulesResponse, error) -- client.Radar.Attacks.Layer7.Summary.MitigationProduct(ctx context.Context, query cloudflare.RadarAttackLayer7SummaryMitigationProductParams) (cloudflare.RadarAttackLayer7SummaryMitigationProductResponse, error) +- client.Radar.Attacks.Layer7.Summary.Get(ctx context.Context, query radar.AttackLayer7SummaryGetParams) (radar.AttackLayer7SummaryGetResponse, error) +- client.Radar.Attacks.Layer7.Summary.HTTPMethod(ctx context.Context, query radar.AttackLayer7SummaryHTTPMethodParams) (radar.AttackLayer7SummaryHTTPMethodResponse, error) +- client.Radar.Attacks.Layer7.Summary.HTTPVersion(ctx context.Context, query radar.AttackLayer7SummaryHTTPVersionParams) (radar.AttackLayer7SummaryHTTPVersionResponse, error) +- client.Radar.Attacks.Layer7.Summary.IPVersion(ctx context.Context, query radar.AttackLayer7SummaryIPVersionParams) (radar.AttackLayer7SummaryIPVersionResponse, error) +- client.Radar.Attacks.Layer7.Summary.ManagedRules(ctx context.Context, query radar.AttackLayer7SummaryManagedRulesParams) (radar.AttackLayer7SummaryManagedRulesResponse, error) +- client.Radar.Attacks.Layer7.Summary.MitigationProduct(ctx context.Context, query radar.AttackLayer7SummaryMitigationProductParams) (radar.AttackLayer7SummaryMitigationProductResponse, error) #### TimeseriesGroups Response Types: -- cloudflare.RadarAttackLayer7TimeseriesGroupGetResponse -- cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodResponse -- cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionResponse -- cloudflare.RadarAttackLayer7TimeseriesGroupIndustryResponse -- cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionResponse -- cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesResponse -- cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductResponse -- cloudflare.RadarAttackLayer7TimeseriesGroupVerticalResponse +- radar.AttackLayer7TimeseriesGroupGetResponse +- radar.AttackLayer7TimeseriesGroupHTTPMethodResponse +- radar.AttackLayer7TimeseriesGroupHTTPVersionResponse +- radar.AttackLayer7TimeseriesGroupIndustryResponse +- radar.AttackLayer7TimeseriesGroupIPVersionResponse +- radar.AttackLayer7TimeseriesGroupManagedRulesResponse +- radar.AttackLayer7TimeseriesGroupMitigationProductResponse +- radar.AttackLayer7TimeseriesGroupVerticalResponse Methods: -- client.Radar.Attacks.Layer7.TimeseriesGroups.Get(ctx context.Context, query cloudflare.RadarAttackLayer7TimeseriesGroupGetParams) (cloudflare.RadarAttackLayer7TimeseriesGroupGetResponse, error) -- client.Radar.Attacks.Layer7.TimeseriesGroups.HTTPMethod(ctx context.Context, query cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParams) (cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodResponse, error) -- client.Radar.Attacks.Layer7.TimeseriesGroups.HTTPVersion(ctx context.Context, query cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParams) (cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionResponse, error) -- client.Radar.Attacks.Layer7.TimeseriesGroups.Industry(ctx context.Context, query cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParams) (cloudflare.RadarAttackLayer7TimeseriesGroupIndustryResponse, error) -- client.Radar.Attacks.Layer7.TimeseriesGroups.IPVersion(ctx context.Context, query cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParams) (cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionResponse, error) -- client.Radar.Attacks.Layer7.TimeseriesGroups.ManagedRules(ctx context.Context, query cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParams) (cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesResponse, error) -- client.Radar.Attacks.Layer7.TimeseriesGroups.MitigationProduct(ctx context.Context, query cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParams) (cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductResponse, error) -- client.Radar.Attacks.Layer7.TimeseriesGroups.Vertical(ctx context.Context, query cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParams) (cloudflare.RadarAttackLayer7TimeseriesGroupVerticalResponse, error) +- client.Radar.Attacks.Layer7.TimeseriesGroups.Get(ctx context.Context, query radar.AttackLayer7TimeseriesGroupGetParams) (radar.AttackLayer7TimeseriesGroupGetResponse, error) +- client.Radar.Attacks.Layer7.TimeseriesGroups.HTTPMethod(ctx context.Context, query radar.AttackLayer7TimeseriesGroupHTTPMethodParams) (radar.AttackLayer7TimeseriesGroupHTTPMethodResponse, error) +- client.Radar.Attacks.Layer7.TimeseriesGroups.HTTPVersion(ctx context.Context, query radar.AttackLayer7TimeseriesGroupHTTPVersionParams) (radar.AttackLayer7TimeseriesGroupHTTPVersionResponse, error) +- client.Radar.Attacks.Layer7.TimeseriesGroups.Industry(ctx context.Context, query radar.AttackLayer7TimeseriesGroupIndustryParams) (radar.AttackLayer7TimeseriesGroupIndustryResponse, error) +- client.Radar.Attacks.Layer7.TimeseriesGroups.IPVersion(ctx context.Context, query radar.AttackLayer7TimeseriesGroupIPVersionParams) (radar.AttackLayer7TimeseriesGroupIPVersionResponse, error) +- client.Radar.Attacks.Layer7.TimeseriesGroups.ManagedRules(ctx context.Context, query radar.AttackLayer7TimeseriesGroupManagedRulesParams) (radar.AttackLayer7TimeseriesGroupManagedRulesResponse, error) +- client.Radar.Attacks.Layer7.TimeseriesGroups.MitigationProduct(ctx context.Context, query radar.AttackLayer7TimeseriesGroupMitigationProductParams) (radar.AttackLayer7TimeseriesGroupMitigationProductResponse, error) +- client.Radar.Attacks.Layer7.TimeseriesGroups.Vertical(ctx context.Context, query radar.AttackLayer7TimeseriesGroupVerticalParams) (radar.AttackLayer7TimeseriesGroupVerticalResponse, error) #### Top Response Types: -- cloudflare.RadarAttackLayer7TopAttacksResponse -- cloudflare.RadarAttackLayer7TopIndustryResponse -- cloudflare.RadarAttackLayer7TopVerticalResponse +- radar.AttackLayer7TopAttacksResponse +- radar.AttackLayer7TopIndustryResponse +- radar.AttackLayer7TopVerticalResponse Methods: -- client.Radar.Attacks.Layer7.Top.Attacks(ctx context.Context, query cloudflare.RadarAttackLayer7TopAttacksParams) (cloudflare.RadarAttackLayer7TopAttacksResponse, error) -- client.Radar.Attacks.Layer7.Top.Industry(ctx context.Context, query cloudflare.RadarAttackLayer7TopIndustryParams) (cloudflare.RadarAttackLayer7TopIndustryResponse, error) -- client.Radar.Attacks.Layer7.Top.Vertical(ctx context.Context, query cloudflare.RadarAttackLayer7TopVerticalParams) (cloudflare.RadarAttackLayer7TopVerticalResponse, error) +- client.Radar.Attacks.Layer7.Top.Attacks(ctx context.Context, query radar.AttackLayer7TopAttacksParams) (radar.AttackLayer7TopAttacksResponse, error) +- client.Radar.Attacks.Layer7.Top.Industry(ctx context.Context, query radar.AttackLayer7TopIndustryParams) (radar.AttackLayer7TopIndustryResponse, error) +- client.Radar.Attacks.Layer7.Top.Vertical(ctx context.Context, query radar.AttackLayer7TopVerticalParams) (radar.AttackLayer7TopVerticalResponse, error) ##### Locations Response Types: -- cloudflare.RadarAttackLayer7TopLocationOriginResponse -- cloudflare.RadarAttackLayer7TopLocationTargetResponse +- radar.AttackLayer7TopLocationOriginResponse +- radar.AttackLayer7TopLocationTargetResponse Methods: -- client.Radar.Attacks.Layer7.Top.Locations.Origin(ctx context.Context, query cloudflare.RadarAttackLayer7TopLocationOriginParams) (cloudflare.RadarAttackLayer7TopLocationOriginResponse, error) -- client.Radar.Attacks.Layer7.Top.Locations.Target(ctx context.Context, query cloudflare.RadarAttackLayer7TopLocationTargetParams) (cloudflare.RadarAttackLayer7TopLocationTargetResponse, error) +- client.Radar.Attacks.Layer7.Top.Locations.Origin(ctx context.Context, query radar.AttackLayer7TopLocationOriginParams) (radar.AttackLayer7TopLocationOriginResponse, error) +- client.Radar.Attacks.Layer7.Top.Locations.Target(ctx context.Context, query radar.AttackLayer7TopLocationTargetParams) (radar.AttackLayer7TopLocationTargetResponse, error) ##### Ases Response Types: -- cloudflare.RadarAttackLayer7TopAseOriginResponse +- radar.AttackLayer7TopAseOriginResponse Methods: -- client.Radar.Attacks.Layer7.Top.Ases.Origin(ctx context.Context, query cloudflare.RadarAttackLayer7TopAseOriginParams) (cloudflare.RadarAttackLayer7TopAseOriginResponse, error) +- client.Radar.Attacks.Layer7.Top.Ases.Origin(ctx context.Context, query radar.AttackLayer7TopAseOriginParams) (radar.AttackLayer7TopAseOriginResponse, error) ## Entities Response Types: -- cloudflare.RadarEntityGetResponse +- radar.EntityGetResponse Methods: -- client.Radar.Entities.Get(ctx context.Context, query cloudflare.RadarEntityGetParams) (cloudflare.RadarEntityGetResponse, error) +- client.Radar.Entities.Get(ctx context.Context, query radar.EntityGetParams) (radar.EntityGetResponse, error) ### ASNs Response Types: -- cloudflare.RadarEntityASNListResponse -- cloudflare.RadarEntityASNGetResponse -- cloudflare.RadarEntityAsnipResponse -- cloudflare.RadarEntityASNRelResponse +- radar.EntityASNListResponse +- radar.EntityASNGetResponse +- radar.EntityAsnipResponse +- radar.EntityASNRelResponse Methods: -- client.Radar.Entities.ASNs.List(ctx context.Context, query cloudflare.RadarEntityASNListParams) (cloudflare.RadarEntityASNListResponse, error) -- client.Radar.Entities.ASNs.Get(ctx context.Context, asn int64, query cloudflare.RadarEntityASNGetParams) (cloudflare.RadarEntityASNGetResponse, error) -- client.Radar.Entities.ASNs.IP(ctx context.Context, query cloudflare.RadarEntityASNIPParams) (cloudflare.RadarEntityAsnipResponse, error) -- client.Radar.Entities.ASNs.Rel(ctx context.Context, asn int64, query cloudflare.RadarEntityASNRelParams) (cloudflare.RadarEntityASNRelResponse, error) +- client.Radar.Entities.ASNs.List(ctx context.Context, query radar.EntityASNListParams) (radar.EntityASNListResponse, error) +- client.Radar.Entities.ASNs.Get(ctx context.Context, asn int64, query radar.EntityASNGetParams) (radar.EntityASNGetResponse, error) +- client.Radar.Entities.ASNs.IP(ctx context.Context, query radar.EntityASNIPParams) (radar.EntityAsnipResponse, error) +- client.Radar.Entities.ASNs.Rel(ctx context.Context, asn int64, query radar.EntityASNRelParams) (radar.EntityASNRelResponse, error) ### Locations Response Types: -- cloudflare.RadarEntityLocationListResponse -- cloudflare.RadarEntityLocationGetResponse +- radar.EntityLocationListResponse +- radar.EntityLocationGetResponse Methods: -- client.Radar.Entities.Locations.List(ctx context.Context, query cloudflare.RadarEntityLocationListParams) (cloudflare.RadarEntityLocationListResponse, error) -- client.Radar.Entities.Locations.Get(ctx context.Context, location string, query cloudflare.RadarEntityLocationGetParams) (cloudflare.RadarEntityLocationGetResponse, error) +- client.Radar.Entities.Locations.List(ctx context.Context, query radar.EntityLocationListParams) (radar.EntityLocationListResponse, error) +- client.Radar.Entities.Locations.Get(ctx context.Context, location string, query radar.EntityLocationGetParams) (radar.EntityLocationGetResponse, error) ## HTTP @@ -5835,221 +5721,221 @@ Methods: Response Types: -- cloudflare.RadarHTTPTopBrowserFamiliesResponse -- cloudflare.RadarHTTPTopBrowsersResponse +- radar.HTTPTopBrowserFamiliesResponse +- radar.HTTPTopBrowsersResponse Methods: -- client.Radar.HTTP.Top.BrowserFamilies(ctx context.Context, query cloudflare.RadarHTTPTopBrowserFamiliesParams) (cloudflare.RadarHTTPTopBrowserFamiliesResponse, error) -- client.Radar.HTTP.Top.Browsers(ctx context.Context, query cloudflare.RadarHTTPTopBrowsersParams) (cloudflare.RadarHTTPTopBrowsersResponse, error) +- client.Radar.HTTP.Top.BrowserFamilies(ctx context.Context, query radar.HTTPTopBrowserFamiliesParams) (radar.HTTPTopBrowserFamiliesResponse, error) +- client.Radar.HTTP.Top.Browsers(ctx context.Context, query radar.HTTPTopBrowsersParams) (radar.HTTPTopBrowsersResponse, error) ### Locations Response Types: -- cloudflare.RadarHTTPLocationGetResponse +- radar.HTTPLocationGetResponse Methods: -- client.Radar.HTTP.Locations.Get(ctx context.Context, query cloudflare.RadarHTTPLocationGetParams) (cloudflare.RadarHTTPLocationGetResponse, error) +- client.Radar.HTTP.Locations.Get(ctx context.Context, query radar.HTTPLocationGetParams) (radar.HTTPLocationGetResponse, error) #### BotClass Response Types: -- cloudflare.RadarHTTPLocationBotClassGetResponse +- radar.HTTPLocationBotClassGetResponse Methods: -- client.Radar.HTTP.Locations.BotClass.Get(ctx context.Context, botClass cloudflare.RadarHTTPLocationBotClassGetParamsBotClass, query cloudflare.RadarHTTPLocationBotClassGetParams) (cloudflare.RadarHTTPLocationBotClassGetResponse, error) +- client.Radar.HTTP.Locations.BotClass.Get(ctx context.Context, botClass radar.HTTPLocationBotClassGetParamsBotClass, query radar.HTTPLocationBotClassGetParams) (radar.HTTPLocationBotClassGetResponse, error) #### DeviceType Response Types: -- cloudflare.RadarHTTPLocationDeviceTypeGetResponse +- radar.HTTPLocationDeviceTypeGetResponse Methods: -- client.Radar.HTTP.Locations.DeviceType.Get(ctx context.Context, deviceType cloudflare.RadarHTTPLocationDeviceTypeGetParamsDeviceType, query cloudflare.RadarHTTPLocationDeviceTypeGetParams) (cloudflare.RadarHTTPLocationDeviceTypeGetResponse, error) +- client.Radar.HTTP.Locations.DeviceType.Get(ctx context.Context, deviceType radar.HTTPLocationDeviceTypeGetParamsDeviceType, query radar.HTTPLocationDeviceTypeGetParams) (radar.HTTPLocationDeviceTypeGetResponse, error) #### HTTPProtocol Response Types: -- cloudflare.RadarHTTPLocationHTTPProtocolGetResponse +- radar.HTTPLocationHTTPProtocolGetResponse Methods: -- client.Radar.HTTP.Locations.HTTPProtocol.Get(ctx context.Context, httpProtocol cloudflare.RadarHTTPLocationHTTPProtocolGetParamsHTTPProtocol, query cloudflare.RadarHTTPLocationHTTPProtocolGetParams) (cloudflare.RadarHTTPLocationHTTPProtocolGetResponse, error) +- client.Radar.HTTP.Locations.HTTPProtocol.Get(ctx context.Context, httpProtocol radar.HTTPLocationHTTPProtocolGetParamsHTTPProtocol, query radar.HTTPLocationHTTPProtocolGetParams) (radar.HTTPLocationHTTPProtocolGetResponse, error) #### HTTPMethod Response Types: -- cloudflare.RadarHTTPLocationHTTPMethodGetResponse +- radar.HTTPLocationHTTPMethodGetResponse Methods: -- client.Radar.HTTP.Locations.HTTPMethod.Get(ctx context.Context, httpVersion cloudflare.RadarHTTPLocationHTTPMethodGetParamsHTTPVersion, query cloudflare.RadarHTTPLocationHTTPMethodGetParams) (cloudflare.RadarHTTPLocationHTTPMethodGetResponse, error) +- client.Radar.HTTP.Locations.HTTPMethod.Get(ctx context.Context, httpVersion radar.HTTPLocationHTTPMethodGetParamsHTTPVersion, query radar.HTTPLocationHTTPMethodGetParams) (radar.HTTPLocationHTTPMethodGetResponse, error) #### IPVersion Response Types: -- cloudflare.RadarHTTPLocationIPVersionGetResponse +- radar.HTTPLocationIPVersionGetResponse Methods: -- client.Radar.HTTP.Locations.IPVersion.Get(ctx context.Context, ipVersion cloudflare.RadarHTTPLocationIPVersionGetParamsIPVersion, query cloudflare.RadarHTTPLocationIPVersionGetParams) (cloudflare.RadarHTTPLocationIPVersionGetResponse, error) +- client.Radar.HTTP.Locations.IPVersion.Get(ctx context.Context, ipVersion radar.HTTPLocationIPVersionGetParamsIPVersion, query radar.HTTPLocationIPVersionGetParams) (radar.HTTPLocationIPVersionGetResponse, error) #### OS Response Types: -- cloudflare.RadarHTTPLocationOSGetResponse +- radar.HTTPLocationOSGetResponse Methods: -- client.Radar.HTTP.Locations.OS.Get(ctx context.Context, os cloudflare.RadarHTTPLocationOSGetParamsOS, query cloudflare.RadarHTTPLocationOSGetParams) (cloudflare.RadarHTTPLocationOSGetResponse, error) +- client.Radar.HTTP.Locations.OS.Get(ctx context.Context, os radar.HTTPLocationOSGetParamsOS, query radar.HTTPLocationOSGetParams) (radar.HTTPLocationOSGetResponse, error) #### TLSVersion Response Types: -- cloudflare.RadarHTTPLocationTLSVersionGetResponse +- radar.HTTPLocationTLSVersionGetResponse Methods: -- client.Radar.HTTP.Locations.TLSVersion.Get(ctx context.Context, tlsVersion cloudflare.RadarHTTPLocationTLSVersionGetParamsTLSVersion, query cloudflare.RadarHTTPLocationTLSVersionGetParams) (cloudflare.RadarHTTPLocationTLSVersionGetResponse, error) +- client.Radar.HTTP.Locations.TLSVersion.Get(ctx context.Context, tlsVersion radar.HTTPLocationTLSVersionGetParamsTLSVersion, query radar.HTTPLocationTLSVersionGetParams) (radar.HTTPLocationTLSVersionGetResponse, error) ### Ases Response Types: -- cloudflare.RadarHTTPAseGetResponse +- radar.HTTPAseGetResponse Methods: -- client.Radar.HTTP.Ases.Get(ctx context.Context, query cloudflare.RadarHTTPAseGetParams) (cloudflare.RadarHTTPAseGetResponse, error) +- client.Radar.HTTP.Ases.Get(ctx context.Context, query radar.HTTPAseGetParams) (radar.HTTPAseGetResponse, error) #### BotClass Response Types: -- cloudflare.RadarHTTPAseBotClassGetResponse +- radar.HTTPAseBotClassGetResponse Methods: -- client.Radar.HTTP.Ases.BotClass.Get(ctx context.Context, botClass cloudflare.RadarHTTPAseBotClassGetParamsBotClass, query cloudflare.RadarHTTPAseBotClassGetParams) (cloudflare.RadarHTTPAseBotClassGetResponse, error) +- client.Radar.HTTP.Ases.BotClass.Get(ctx context.Context, botClass radar.HTTPAseBotClassGetParamsBotClass, query radar.HTTPAseBotClassGetParams) (radar.HTTPAseBotClassGetResponse, error) #### DeviceType Response Types: -- cloudflare.RadarHTTPAseDeviceTypeGetResponse +- radar.HTTPAseDeviceTypeGetResponse Methods: -- client.Radar.HTTP.Ases.DeviceType.Get(ctx context.Context, deviceType cloudflare.RadarHTTPAseDeviceTypeGetParamsDeviceType, query cloudflare.RadarHTTPAseDeviceTypeGetParams) (cloudflare.RadarHTTPAseDeviceTypeGetResponse, error) +- client.Radar.HTTP.Ases.DeviceType.Get(ctx context.Context, deviceType radar.HTTPAseDeviceTypeGetParamsDeviceType, query radar.HTTPAseDeviceTypeGetParams) (radar.HTTPAseDeviceTypeGetResponse, error) #### HTTPProtocol Response Types: -- cloudflare.RadarHTTPAseHTTPProtocolGetResponse +- radar.HTTPAseHTTPProtocolGetResponse Methods: -- client.Radar.HTTP.Ases.HTTPProtocol.Get(ctx context.Context, httpProtocol cloudflare.RadarHTTPAseHTTPProtocolGetParamsHTTPProtocol, query cloudflare.RadarHTTPAseHTTPProtocolGetParams) (cloudflare.RadarHTTPAseHTTPProtocolGetResponse, error) +- client.Radar.HTTP.Ases.HTTPProtocol.Get(ctx context.Context, httpProtocol radar.HTTPAseHTTPProtocolGetParamsHTTPProtocol, query radar.HTTPAseHTTPProtocolGetParams) (radar.HTTPAseHTTPProtocolGetResponse, error) #### HTTPMethod Response Types: -- cloudflare.RadarHTTPAseHTTPMethodGetResponse +- radar.HTTPAseHTTPMethodGetResponse Methods: -- client.Radar.HTTP.Ases.HTTPMethod.Get(ctx context.Context, httpVersion cloudflare.RadarHTTPAseHTTPMethodGetParamsHTTPVersion, query cloudflare.RadarHTTPAseHTTPMethodGetParams) (cloudflare.RadarHTTPAseHTTPMethodGetResponse, error) +- client.Radar.HTTP.Ases.HTTPMethod.Get(ctx context.Context, httpVersion radar.HTTPAseHTTPMethodGetParamsHTTPVersion, query radar.HTTPAseHTTPMethodGetParams) (radar.HTTPAseHTTPMethodGetResponse, error) #### IPVersion Response Types: -- cloudflare.RadarHTTPAseIPVersionGetResponse +- radar.HTTPAseIPVersionGetResponse Methods: -- client.Radar.HTTP.Ases.IPVersion.Get(ctx context.Context, ipVersion cloudflare.RadarHTTPAseIPVersionGetParamsIPVersion, query cloudflare.RadarHTTPAseIPVersionGetParams) (cloudflare.RadarHTTPAseIPVersionGetResponse, error) +- client.Radar.HTTP.Ases.IPVersion.Get(ctx context.Context, ipVersion radar.HTTPAseIPVersionGetParamsIPVersion, query radar.HTTPAseIPVersionGetParams) (radar.HTTPAseIPVersionGetResponse, error) #### OS Response Types: -- cloudflare.RadarHTTPAseOSGetResponse +- radar.HTTPAseOSGetResponse Methods: -- client.Radar.HTTP.Ases.OS.Get(ctx context.Context, os cloudflare.RadarHTTPAseOSGetParamsOS, query cloudflare.RadarHTTPAseOSGetParams) (cloudflare.RadarHTTPAseOSGetResponse, error) +- client.Radar.HTTP.Ases.OS.Get(ctx context.Context, os radar.HTTPAseOSGetParamsOS, query radar.HTTPAseOSGetParams) (radar.HTTPAseOSGetResponse, error) #### TLSVersion Response Types: -- cloudflare.RadarHTTPAseTLSVersionGetResponse +- radar.HTTPAseTLSVersionGetResponse Methods: -- client.Radar.HTTP.Ases.TLSVersion.Get(ctx context.Context, tlsVersion cloudflare.RadarHTTPAseTLSVersionGetParamsTLSVersion, query cloudflare.RadarHTTPAseTLSVersionGetParams) (cloudflare.RadarHTTPAseTLSVersionGetResponse, error) +- client.Radar.HTTP.Ases.TLSVersion.Get(ctx context.Context, tlsVersion radar.HTTPAseTLSVersionGetParamsTLSVersion, query radar.HTTPAseTLSVersionGetParams) (radar.HTTPAseTLSVersionGetResponse, error) ### Summary Response Types: -- cloudflare.RadarHTTPSummaryBotClassResponse -- cloudflare.RadarHTTPSummaryDeviceTypeResponse -- cloudflare.RadarHTTPSummaryHTTPProtocolResponse -- cloudflare.RadarHTTPSummaryHTTPVersionResponse -- cloudflare.RadarHTTPSummaryIPVersionResponse -- cloudflare.RadarHTTPSummaryOSResponse -- cloudflare.RadarHTTPSummaryTLSVersionResponse +- radar.HTTPSummaryBotClassResponse +- radar.HTTPSummaryDeviceTypeResponse +- radar.HTTPSummaryHTTPProtocolResponse +- radar.HTTPSummaryHTTPVersionResponse +- radar.HTTPSummaryIPVersionResponse +- radar.HTTPSummaryOSResponse +- radar.HTTPSummaryTLSVersionResponse Methods: -- client.Radar.HTTP.Summary.BotClass(ctx context.Context, query cloudflare.RadarHTTPSummaryBotClassParams) (cloudflare.RadarHTTPSummaryBotClassResponse, error) -- client.Radar.HTTP.Summary.DeviceType(ctx context.Context, query cloudflare.RadarHTTPSummaryDeviceTypeParams) (cloudflare.RadarHTTPSummaryDeviceTypeResponse, error) -- client.Radar.HTTP.Summary.HTTPProtocol(ctx context.Context, query cloudflare.RadarHTTPSummaryHTTPProtocolParams) (cloudflare.RadarHTTPSummaryHTTPProtocolResponse, error) -- client.Radar.HTTP.Summary.HTTPVersion(ctx context.Context, query cloudflare.RadarHTTPSummaryHTTPVersionParams) (cloudflare.RadarHTTPSummaryHTTPVersionResponse, error) -- client.Radar.HTTP.Summary.IPVersion(ctx context.Context, query cloudflare.RadarHTTPSummaryIPVersionParams) (cloudflare.RadarHTTPSummaryIPVersionResponse, error) -- client.Radar.HTTP.Summary.OS(ctx context.Context, query cloudflare.RadarHTTPSummaryOSParams) (cloudflare.RadarHTTPSummaryOSResponse, error) -- client.Radar.HTTP.Summary.TLSVersion(ctx context.Context, query cloudflare.RadarHTTPSummaryTLSVersionParams) (cloudflare.RadarHTTPSummaryTLSVersionResponse, error) +- client.Radar.HTTP.Summary.BotClass(ctx context.Context, query radar.HTTPSummaryBotClassParams) (radar.HTTPSummaryBotClassResponse, error) +- client.Radar.HTTP.Summary.DeviceType(ctx context.Context, query radar.HTTPSummaryDeviceTypeParams) (radar.HTTPSummaryDeviceTypeResponse, error) +- client.Radar.HTTP.Summary.HTTPProtocol(ctx context.Context, query radar.HTTPSummaryHTTPProtocolParams) (radar.HTTPSummaryHTTPProtocolResponse, error) +- client.Radar.HTTP.Summary.HTTPVersion(ctx context.Context, query radar.HTTPSummaryHTTPVersionParams) (radar.HTTPSummaryHTTPVersionResponse, error) +- client.Radar.HTTP.Summary.IPVersion(ctx context.Context, query radar.HTTPSummaryIPVersionParams) (radar.HTTPSummaryIPVersionResponse, error) +- client.Radar.HTTP.Summary.OS(ctx context.Context, query radar.HTTPSummaryOSParams) (radar.HTTPSummaryOSResponse, error) +- client.Radar.HTTP.Summary.TLSVersion(ctx context.Context, query radar.HTTPSummaryTLSVersionParams) (radar.HTTPSummaryTLSVersionResponse, error) ### TimeseriesGroups Response Types: -- cloudflare.RadarHTTPTimeseriesGroupBotClassResponse -- cloudflare.RadarHTTPTimeseriesGroupBrowserResponse -- cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyResponse -- cloudflare.RadarHTTPTimeseriesGroupDeviceTypeResponse -- cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolResponse -- cloudflare.RadarHTTPTimeseriesGroupHTTPVersionResponse -- cloudflare.RadarHTTPTimeseriesGroupIPVersionResponse -- cloudflare.RadarHTTPTimeseriesGroupOSResponse -- cloudflare.RadarHTTPTimeseriesGroupTLSVersionResponse +- radar.HTTPTimeseriesGroupBotClassResponse +- radar.HTTPTimeseriesGroupBrowserResponse +- radar.HTTPTimeseriesGroupBrowserFamilyResponse +- radar.HTTPTimeseriesGroupDeviceTypeResponse +- radar.HTTPTimeseriesGroupHTTPProtocolResponse +- radar.HTTPTimeseriesGroupHTTPVersionResponse +- radar.HTTPTimeseriesGroupIPVersionResponse +- radar.HTTPTimeseriesGroupOSResponse +- radar.HTTPTimeseriesGroupTLSVersionResponse Methods: -- client.Radar.HTTP.TimeseriesGroups.BotClass(ctx context.Context, query cloudflare.RadarHTTPTimeseriesGroupBotClassParams) (cloudflare.RadarHTTPTimeseriesGroupBotClassResponse, error) -- client.Radar.HTTP.TimeseriesGroups.Browser(ctx context.Context, query cloudflare.RadarHTTPTimeseriesGroupBrowserParams) (cloudflare.RadarHTTPTimeseriesGroupBrowserResponse, error) -- client.Radar.HTTP.TimeseriesGroups.BrowserFamily(ctx context.Context, query cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParams) (cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyResponse, error) -- client.Radar.HTTP.TimeseriesGroups.DeviceType(ctx context.Context, query cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParams) (cloudflare.RadarHTTPTimeseriesGroupDeviceTypeResponse, error) -- client.Radar.HTTP.TimeseriesGroups.HTTPProtocol(ctx context.Context, query cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParams) (cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolResponse, error) -- client.Radar.HTTP.TimeseriesGroups.HTTPVersion(ctx context.Context, query cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParams) (cloudflare.RadarHTTPTimeseriesGroupHTTPVersionResponse, error) -- client.Radar.HTTP.TimeseriesGroups.IPVersion(ctx context.Context, query cloudflare.RadarHTTPTimeseriesGroupIPVersionParams) (cloudflare.RadarHTTPTimeseriesGroupIPVersionResponse, error) -- client.Radar.HTTP.TimeseriesGroups.OS(ctx context.Context, query cloudflare.RadarHTTPTimeseriesGroupOSParams) (cloudflare.RadarHTTPTimeseriesGroupOSResponse, error) -- client.Radar.HTTP.TimeseriesGroups.TLSVersion(ctx context.Context, query cloudflare.RadarHTTPTimeseriesGroupTLSVersionParams) (cloudflare.RadarHTTPTimeseriesGroupTLSVersionResponse, error) +- client.Radar.HTTP.TimeseriesGroups.BotClass(ctx context.Context, query radar.HTTPTimeseriesGroupBotClassParams) (radar.HTTPTimeseriesGroupBotClassResponse, error) +- client.Radar.HTTP.TimeseriesGroups.Browser(ctx context.Context, query radar.HTTPTimeseriesGroupBrowserParams) (radar.HTTPTimeseriesGroupBrowserResponse, error) +- client.Radar.HTTP.TimeseriesGroups.BrowserFamily(ctx context.Context, query radar.HTTPTimeseriesGroupBrowserFamilyParams) (radar.HTTPTimeseriesGroupBrowserFamilyResponse, error) +- client.Radar.HTTP.TimeseriesGroups.DeviceType(ctx context.Context, query radar.HTTPTimeseriesGroupDeviceTypeParams) (radar.HTTPTimeseriesGroupDeviceTypeResponse, error) +- client.Radar.HTTP.TimeseriesGroups.HTTPProtocol(ctx context.Context, query radar.HTTPTimeseriesGroupHTTPProtocolParams) (radar.HTTPTimeseriesGroupHTTPProtocolResponse, error) +- client.Radar.HTTP.TimeseriesGroups.HTTPVersion(ctx context.Context, query radar.HTTPTimeseriesGroupHTTPVersionParams) (radar.HTTPTimeseriesGroupHTTPVersionResponse, error) +- client.Radar.HTTP.TimeseriesGroups.IPVersion(ctx context.Context, query radar.HTTPTimeseriesGroupIPVersionParams) (radar.HTTPTimeseriesGroupIPVersionResponse, error) +- client.Radar.HTTP.TimeseriesGroups.OS(ctx context.Context, query radar.HTTPTimeseriesGroupOSParams) (radar.HTTPTimeseriesGroupOSResponse, error) +- client.Radar.HTTP.TimeseriesGroups.TLSVersion(ctx context.Context, query radar.HTTPTimeseriesGroupTLSVersionParams) (radar.HTTPTimeseriesGroupTLSVersionResponse, error) ## Quality @@ -6057,163 +5943,162 @@ Methods: Response Types: -- cloudflare.RadarQualityIQISummaryResponse -- cloudflare.RadarQualityIQITimeseriesGroupsResponse +- radar.QualityIQISummaryResponse +- radar.QualityIQITimeseriesGroupsResponse Methods: -- client.Radar.Quality.IQI.Summary(ctx context.Context, query cloudflare.RadarQualityIQISummaryParams) (cloudflare.RadarQualityIQISummaryResponse, error) -- client.Radar.Quality.IQI.TimeseriesGroups(ctx context.Context, query cloudflare.RadarQualityIQITimeseriesGroupsParams) (cloudflare.RadarQualityIQITimeseriesGroupsResponse, error) +- client.Radar.Quality.IQI.Summary(ctx context.Context, query radar.QualityIQISummaryParams) (radar.QualityIQISummaryResponse, error) +- client.Radar.Quality.IQI.TimeseriesGroups(ctx context.Context, query radar.QualityIQITimeseriesGroupsParams) (radar.QualityIQITimeseriesGroupsResponse, error) ### Speed Response Types: -- cloudflare.RadarQualitySpeedHistogramResponse -- cloudflare.RadarQualitySpeedSummaryResponse +- radar.QualitySpeedHistogramResponse +- radar.QualitySpeedSummaryResponse Methods: -- client.Radar.Quality.Speed.Histogram(ctx context.Context, query cloudflare.RadarQualitySpeedHistogramParams) (cloudflare.RadarQualitySpeedHistogramResponse, error) -- client.Radar.Quality.Speed.Summary(ctx context.Context, query cloudflare.RadarQualitySpeedSummaryParams) (cloudflare.RadarQualitySpeedSummaryResponse, error) +- client.Radar.Quality.Speed.Histogram(ctx context.Context, query radar.QualitySpeedHistogramParams) (radar.QualitySpeedHistogramResponse, error) +- client.Radar.Quality.Speed.Summary(ctx context.Context, query radar.QualitySpeedSummaryParams) (radar.QualitySpeedSummaryResponse, error) #### Top Response Types: -- cloudflare.RadarQualitySpeedTopAsesResponse -- cloudflare.RadarQualitySpeedTopLocationsResponse +- radar.QualitySpeedTopAsesResponse +- radar.QualitySpeedTopLocationsResponse Methods: -- client.Radar.Quality.Speed.Top.Ases(ctx context.Context, query cloudflare.RadarQualitySpeedTopAsesParams) (cloudflare.RadarQualitySpeedTopAsesResponse, error) -- client.Radar.Quality.Speed.Top.Locations(ctx context.Context, query cloudflare.RadarQualitySpeedTopLocationsParams) (cloudflare.RadarQualitySpeedTopLocationsResponse, error) +- client.Radar.Quality.Speed.Top.Ases(ctx context.Context, query radar.QualitySpeedTopAsesParams) (radar.QualitySpeedTopAsesResponse, error) +- client.Radar.Quality.Speed.Top.Locations(ctx context.Context, query radar.QualitySpeedTopLocationsParams) (radar.QualitySpeedTopLocationsResponse, error) ## Ranking Response Types: -- cloudflare.RadarRankingTimeseriesGroupsResponse -- cloudflare.RadarRankingTopResponse +- radar.RankingTimeseriesGroupsResponse +- radar.RankingTopResponse Methods: -- client.Radar.Ranking.TimeseriesGroups(ctx context.Context, query cloudflare.RadarRankingTimeseriesGroupsParams) (cloudflare.RadarRankingTimeseriesGroupsResponse, error) -- client.Radar.Ranking.Top(ctx context.Context, query cloudflare.RadarRankingTopParams) (cloudflare.RadarRankingTopResponse, error) +- client.Radar.Ranking.TimeseriesGroups(ctx context.Context, query radar.RankingTimeseriesGroupsParams) (radar.RankingTimeseriesGroupsResponse, error) +- client.Radar.Ranking.Top(ctx context.Context, query radar.RankingTopParams) (radar.RankingTopResponse, error) ### Domain Response Types: -- cloudflare.RadarRankingDomainGetResponse +- radar.RankingDomainGetResponse Methods: -- client.Radar.Ranking.Domain.Get(ctx context.Context, domain string, query cloudflare.RadarRankingDomainGetParams) (cloudflare.RadarRankingDomainGetResponse, error) +- client.Radar.Ranking.Domain.Get(ctx context.Context, domain string, query radar.RankingDomainGetParams) (radar.RankingDomainGetResponse, error) ## TrafficAnomalies Response Types: -- cloudflare.RadarTrafficAnomalyGetResponse +- radar.TrafficAnomalyGetResponse Methods: -- client.Radar.TrafficAnomalies.Get(ctx context.Context, query cloudflare.RadarTrafficAnomalyGetParams) (cloudflare.RadarTrafficAnomalyGetResponse, error) +- client.Radar.TrafficAnomalies.Get(ctx context.Context, query radar.TrafficAnomalyGetParams) (radar.TrafficAnomalyGetResponse, error) ### Locations Response Types: -- cloudflare.RadarTrafficAnomalyLocationGetResponse +- radar.TrafficAnomalyLocationGetResponse Methods: -- client.Radar.TrafficAnomalies.Locations.Get(ctx context.Context, query cloudflare.RadarTrafficAnomalyLocationGetParams) (cloudflare.RadarTrafficAnomalyLocationGetResponse, error) +- client.Radar.TrafficAnomalies.Locations.Get(ctx context.Context, query radar.TrafficAnomalyLocationGetParams) (radar.TrafficAnomalyLocationGetResponse, error) # BotManagement Response Types: -- cloudflare.BotManagementUpdateResponse -- cloudflare.BotManagementGetResponse +- bot_management.BotManagementUpdateResponse +- bot_management.BotManagementGetResponse Methods: -- client.BotManagement.Update(ctx context.Context, params cloudflare.BotManagementUpdateParams) (cloudflare.BotManagementUpdateResponse, error) -- client.BotManagement.Get(ctx context.Context, query cloudflare.BotManagementGetParams) (cloudflare.BotManagementGetResponse, error) +- client.BotManagement.Update(ctx context.Context, params bot_management.BotManagementUpdateParams) (bot_management.BotManagementUpdateResponse, error) +- client.BotManagement.Get(ctx context.Context, query bot_management.BotManagementGetParams) (bot_management.BotManagementGetResponse, error) # OriginPostQuantumEncryption Response Types: -- cloudflare.OriginPostQuantumEncryptionUpdateResponse -- cloudflare.OriginPostQuantumEncryptionGetResponse +- origin_post_quantum_encryption.OriginPostQuantumEncryptionUpdateResponse +- origin_post_quantum_encryption.OriginPostQuantumEncryptionGetResponse Methods: -- client.OriginPostQuantumEncryption.Update(ctx context.Context, params cloudflare.OriginPostQuantumEncryptionUpdateParams) (cloudflare.OriginPostQuantumEncryptionUpdateResponse, error) -- client.OriginPostQuantumEncryption.Get(ctx context.Context, query cloudflare.OriginPostQuantumEncryptionGetParams) (cloudflare.OriginPostQuantumEncryptionGetResponse, error) +- client.OriginPostQuantumEncryption.Update(ctx context.Context, params origin_post_quantum_encryption.OriginPostQuantumEncryptionUpdateParams) (origin_post_quantum_encryption.OriginPostQuantumEncryptionUpdateResponse, error) +- client.OriginPostQuantumEncryption.Get(ctx context.Context, query origin_post_quantum_encryption.OriginPostQuantumEncryptionGetParams) (origin_post_quantum_encryption.OriginPostQuantumEncryptionGetResponse, error) # Speed Response Types: -- cloudflare.SpeedDeleteResponse -- cloudflare.SpeedScheduleGetResponse -- cloudflare.SpeedTrendsListResponse +- speed.ObservatorySchedule +- speed.ObservatoryTrend +- speed.SpeedDeleteResponse Methods: -- client.Speed.Delete(ctx context.Context, url string, params cloudflare.SpeedDeleteParams) (cloudflare.SpeedDeleteResponse, error) -- client.Speed.ScheduleGet(ctx context.Context, url string, params cloudflare.SpeedScheduleGetParams) (cloudflare.SpeedScheduleGetResponse, error) -- client.Speed.TrendsList(ctx context.Context, url string, params cloudflare.SpeedTrendsListParams) (cloudflare.SpeedTrendsListResponse, error) +- client.Speed.Delete(ctx context.Context, url string, params speed.SpeedDeleteParams) (speed.SpeedDeleteResponse, error) +- client.Speed.ScheduleGet(ctx context.Context, url string, params speed.SpeedScheduleGetParams) (speed.ObservatorySchedule, error) +- client.Speed.TrendsList(ctx context.Context, url string, params speed.SpeedTrendsListParams) (speed.ObservatoryTrend, error) ## Tests Response Types: -- cloudflare.SpeedTestNewResponse -- cloudflare.SpeedTestListResponse -- cloudflare.SpeedTestDeleteResponse -- cloudflare.SpeedTestGetResponse +- speed.ObservatoryPageTest +- speed.TestListResponse +- speed.TestDeleteResponse Methods: -- client.Speed.Tests.New(ctx context.Context, url string, params cloudflare.SpeedTestNewParams) (cloudflare.SpeedTestNewResponse, error) -- client.Speed.Tests.List(ctx context.Context, url string, params cloudflare.SpeedTestListParams) (cloudflare.SpeedTestListResponse, error) -- client.Speed.Tests.Delete(ctx context.Context, url string, params cloudflare.SpeedTestDeleteParams) (cloudflare.SpeedTestDeleteResponse, error) -- client.Speed.Tests.Get(ctx context.Context, url string, testID string, query cloudflare.SpeedTestGetParams) (cloudflare.SpeedTestGetResponse, error) +- client.Speed.Tests.New(ctx context.Context, url string, params speed.TestNewParams) (speed.ObservatoryPageTest, error) +- client.Speed.Tests.List(ctx context.Context, url string, params speed.TestListParams) (speed.TestListResponse, error) +- client.Speed.Tests.Delete(ctx context.Context, url string, params speed.TestDeleteParams) (speed.TestDeleteResponse, error) +- client.Speed.Tests.Get(ctx context.Context, url string, testID string, query speed.TestGetParams) (speed.ObservatoryPageTest, error) ## Schedule Response Types: -- cloudflare.SpeedScheduleNewResponse +- speed.ScheduleNewResponse Methods: -- client.Speed.Schedule.New(ctx context.Context, url string, params cloudflare.SpeedScheduleNewParams) (cloudflare.SpeedScheduleNewResponse, error) +- client.Speed.Schedule.New(ctx context.Context, url string, params speed.ScheduleNewParams) (speed.ScheduleNewResponse, error) ## Availabilities Response Types: -- cloudflare.SpeedAvailabilityListResponse +- speed.ObservatoryAvailabilities Methods: -- client.Speed.Availabilities.List(ctx context.Context, query cloudflare.SpeedAvailabilityListParams) (cloudflare.SpeedAvailabilityListResponse, error) +- client.Speed.Availabilities.List(ctx context.Context, query speed.AvailabilityListParams) (speed.ObservatoryAvailabilities, error) ## Pages Response Types: -- cloudflare.SpeedPageListResponse +- speed.PageListResponse Methods: -- client.Speed.Pages.List(ctx context.Context, query cloudflare.SpeedPageListParams) ([]cloudflare.SpeedPageListResponse, error) +- client.Speed.Pages.List(ctx context.Context, query speed.PageListParams) ([]speed.PageListResponse, error) # DCVDelegation @@ -6221,11 +6106,11 @@ Methods: Response Types: -- cloudflare.DCVDelegationUUIDGetResponse +- dcv_delegation.TLSCertificatesAndHostnamesUUIDObject Methods: -- client.DCVDelegation.UUID.Get(ctx context.Context, query cloudflare.DCVDelegationUUIDGetParams) (cloudflare.DCVDelegationUUIDGetResponse, error) +- client.DCVDelegation.UUID.Get(ctx context.Context, query dcv_delegation.UUIDGetParams) (dcv_delegation.TLSCertificatesAndHostnamesUUIDObject, error) # Hostnames @@ -6235,67 +6120,62 @@ Methods: Response Types: -- cloudflare.HostnameSettingTLSUpdateResponse -- cloudflare.HostnameSettingTLSDeleteResponse -- cloudflare.HostnameSettingTLSGetResponse +- hostnames.TLSCertificatesAndHostnamesSettingObject +- hostnames.TLSCertificatesAndHostnamesSettingObjectDelete +- hostnames.SettingTLSGetResponse Methods: -- client.Hostnames.Settings.TLS.Update(ctx context.Context, settingID cloudflare.HostnameSettingTLSUpdateParamsSettingID, hostname string, params cloudflare.HostnameSettingTLSUpdateParams) (cloudflare.HostnameSettingTLSUpdateResponse, error) -- client.Hostnames.Settings.TLS.Delete(ctx context.Context, settingID cloudflare.HostnameSettingTLSDeleteParamsSettingID, hostname string, body cloudflare.HostnameSettingTLSDeleteParams) (cloudflare.HostnameSettingTLSDeleteResponse, error) -- client.Hostnames.Settings.TLS.Get(ctx context.Context, settingID cloudflare.HostnameSettingTLSGetParamsSettingID, query cloudflare.HostnameSettingTLSGetParams) ([]cloudflare.HostnameSettingTLSGetResponse, error) +- client.Hostnames.Settings.TLS.Update(ctx context.Context, settingID hostnames.SettingTLSUpdateParamsSettingID, hostname string, params hostnames.SettingTLSUpdateParams) (hostnames.TLSCertificatesAndHostnamesSettingObject, error) +- client.Hostnames.Settings.TLS.Delete(ctx context.Context, settingID hostnames.SettingTLSDeleteParamsSettingID, hostname string, body hostnames.SettingTLSDeleteParams) (hostnames.TLSCertificatesAndHostnamesSettingObjectDelete, error) +- client.Hostnames.Settings.TLS.Get(ctx context.Context, settingID hostnames.SettingTLSGetParamsSettingID, query hostnames.SettingTLSGetParams) ([]hostnames.SettingTLSGetResponse, error) # Snippets Response Types: -- cloudflare.SnippetUpdateResponse -- cloudflare.SnippetListResponse -- cloudflare.SnippetDeleteResponse -- cloudflare.SnippetGetResponse +- snippets.Snippet +- snippets.SnippetDeleteResponse Methods: -- client.Snippets.Update(ctx context.Context, zoneIdentifier string, snippetName string, body cloudflare.SnippetUpdateParams) (cloudflare.SnippetUpdateResponse, error) -- client.Snippets.List(ctx context.Context, zoneIdentifier string) ([]cloudflare.SnippetListResponse, error) -- client.Snippets.Delete(ctx context.Context, zoneIdentifier string, snippetName string) (cloudflare.SnippetDeleteResponse, error) -- client.Snippets.Get(ctx context.Context, zoneIdentifier string, snippetName string) (cloudflare.SnippetGetResponse, error) +- client.Snippets.Update(ctx context.Context, zoneIdentifier string, snippetName string, body snippets.SnippetUpdateParams) (snippets.Snippet, error) +- client.Snippets.List(ctx context.Context, zoneIdentifier string) ([]snippets.Snippet, error) +- client.Snippets.Delete(ctx context.Context, zoneIdentifier string, snippetName string) (snippets.SnippetDeleteResponse, error) +- client.Snippets.Get(ctx context.Context, zoneIdentifier string, snippetName string) (snippets.Snippet, error) ## Content Methods: -- client.Snippets.Content.Get(ctx context.Context, zoneIdentifier string, snippetName string) (http.Response, error) +- client.Snippets.Content.Get(ctx context.Context, zoneIdentifier string, snippetName string) (http.Response, error) ## Rules Response Types: -- cloudflare.SnippetRuleUpdateResponse -- cloudflare.SnippetRuleListResponse +- snippets.RuleUpdateResponse +- snippets.RuleListResponse Methods: -- client.Snippets.Rules.Update(ctx context.Context, zoneIdentifier string, body cloudflare.SnippetRuleUpdateParams) ([]cloudflare.SnippetRuleUpdateResponse, error) -- client.Snippets.Rules.List(ctx context.Context, zoneIdentifier string) ([]cloudflare.SnippetRuleListResponse, error) +- client.Snippets.Rules.Update(ctx context.Context, zoneIdentifier string, body snippets.RuleUpdateParams) ([]snippets.RuleUpdateResponse, error) +- client.Snippets.Rules.List(ctx context.Context, zoneIdentifier string) ([]snippets.RuleListResponse, error) # Calls Response Types: -- cloudflare.CallNewResponse -- cloudflare.CallUpdateResponse -- cloudflare.CallListResponse -- cloudflare.CallDeleteResponse -- cloudflare.CallGetResponse +- calls.CallsApp +- calls.CallsAppWithSecret Methods: -- client.Calls.New(ctx context.Context, params cloudflare.CallNewParams) (cloudflare.CallNewResponse, error) -- client.Calls.Update(ctx context.Context, appID string, params cloudflare.CallUpdateParams) (cloudflare.CallUpdateResponse, error) -- client.Calls.List(ctx context.Context, query cloudflare.CallListParams) ([]cloudflare.CallListResponse, error) -- client.Calls.Delete(ctx context.Context, appID string, body cloudflare.CallDeleteParams) (cloudflare.CallDeleteResponse, error) -- client.Calls.Get(ctx context.Context, appID string, query cloudflare.CallGetParams) (cloudflare.CallGetResponse, error) +- client.Calls.New(ctx context.Context, params calls.CallNewParams) (calls.CallsAppWithSecret, error) +- client.Calls.Update(ctx context.Context, appID string, params calls.CallUpdateParams) (calls.CallsApp, error) +- client.Calls.List(ctx context.Context, query calls.CallListParams) ([]calls.CallsApp, error) +- client.Calls.Delete(ctx context.Context, appID string, body calls.CallDeleteParams) (calls.CallsApp, error) +- client.Calls.Get(ctx context.Context, appID string, query calls.CallGetParams) (calls.CallsApp, error) # CloudforceOne @@ -6303,55 +6183,49 @@ Methods: Response Types: -- cloudflare.CloudforceOneRequestNewResponse -- cloudflare.CloudforceOneRequestUpdateResponse -- cloudflare.CloudforceOneRequestListResponse -- cloudflare.CloudforceOneRequestDeleteResponse -- cloudflare.CloudforceOneRequestConstantsResponse -- cloudflare.CloudforceOneRequestGetResponse -- cloudflare.CloudforceOneRequestQuotaResponse +- cloudforce_one.CloudforceOneQuota +- cloudforce_one.CloudforceOneRequestConstants +- cloudforce_one.CloudforceOneRequestItem +- cloudforce_one.CloudforceOneRequestListItem +- cloudforce_one.CloudforceOneRequestTypes +- cloudforce_one.RequestDeleteResponse Methods: -- client.CloudforceOne.Requests.New(ctx context.Context, accountIdentifier string, body cloudflare.CloudforceOneRequestNewParams) (cloudflare.CloudforceOneRequestNewResponse, error) -- client.CloudforceOne.Requests.Update(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudflare.CloudforceOneRequestUpdateParams) (cloudflare.CloudforceOneRequestUpdateResponse, error) -- client.CloudforceOne.Requests.List(ctx context.Context, accountIdentifier string, body cloudflare.CloudforceOneRequestListParams) (shared.V4PagePaginationArray[cloudflare.CloudforceOneRequestListResponse], error) -- client.CloudforceOne.Requests.Delete(ctx context.Context, accountIdentifier string, requestIdentifier string) (cloudflare.CloudforceOneRequestDeleteResponse, error) -- client.CloudforceOne.Requests.Constants(ctx context.Context, accountIdentifier string) (cloudflare.CloudforceOneRequestConstantsResponse, error) -- client.CloudforceOne.Requests.Get(ctx context.Context, accountIdentifier string, requestIdentifier string) (cloudflare.CloudforceOneRequestGetResponse, error) -- client.CloudforceOne.Requests.Quota(ctx context.Context, accountIdentifier string) (cloudflare.CloudforceOneRequestQuotaResponse, error) -- client.CloudforceOne.Requests.Types(ctx context.Context, accountIdentifier string) ([]string, error) +- client.CloudforceOne.Requests.New(ctx context.Context, accountIdentifier string, body cloudforce_one.RequestNewParams) (cloudforce_one.CloudforceOneRequestItem, error) +- client.CloudforceOne.Requests.Update(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudforce_one.RequestUpdateParams) (cloudforce_one.CloudforceOneRequestItem, error) +- client.CloudforceOne.Requests.List(ctx context.Context, accountIdentifier string, body cloudforce_one.RequestListParams) (shared.V4PagePaginationArray[cloudforce_one.CloudforceOneRequestListItem], error) +- client.CloudforceOne.Requests.Delete(ctx context.Context, accountIdentifier string, requestIdentifier string) (cloudforce_one.RequestDeleteResponse, error) +- client.CloudforceOne.Requests.Constants(ctx context.Context, accountIdentifier string) (cloudforce_one.CloudforceOneRequestConstants, error) +- client.CloudforceOne.Requests.Get(ctx context.Context, accountIdentifier string, requestIdentifier string) (cloudforce_one.CloudforceOneRequestItem, error) +- client.CloudforceOne.Requests.Quota(ctx context.Context, accountIdentifier string) (cloudforce_one.CloudforceOneQuota, error) +- client.CloudforceOne.Requests.Types(ctx context.Context, accountIdentifier string) (cloudforce_one.CloudforceOneRequestTypes, error) ### Message Response Types: -- cloudflare.CloudforceOneRequestMessageNewResponse -- cloudflare.CloudforceOneRequestMessageUpdateResponse -- cloudflare.CloudforceOneRequestMessageDeleteResponse -- cloudflare.CloudforceOneRequestMessageGetResponse +- cloudforce_one.CloudforceOneRequestMessageItem +- cloudforce_one.RequestMessageDeleteResponse Methods: -- client.CloudforceOne.Requests.Message.New(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudflare.CloudforceOneRequestMessageNewParams) (cloudflare.CloudforceOneRequestMessageNewResponse, error) -- client.CloudforceOne.Requests.Message.Update(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64, body cloudflare.CloudforceOneRequestMessageUpdateParams) (cloudflare.CloudforceOneRequestMessageUpdateResponse, error) -- client.CloudforceOne.Requests.Message.Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64) (cloudflare.CloudforceOneRequestMessageDeleteResponse, error) -- client.CloudforceOne.Requests.Message.Get(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudflare.CloudforceOneRequestMessageGetParams) ([]cloudflare.CloudforceOneRequestMessageGetResponse, error) +- client.CloudforceOne.Requests.Message.New(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudforce_one.RequestMessageNewParams) (cloudforce_one.CloudforceOneRequestMessageItem, error) +- client.CloudforceOne.Requests.Message.Update(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64, body cloudforce_one.RequestMessageUpdateParams) (cloudforce_one.CloudforceOneRequestMessageItem, error) +- client.CloudforceOne.Requests.Message.Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64) (cloudforce_one.RequestMessageDeleteResponse, error) +- client.CloudforceOne.Requests.Message.Get(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudforce_one.RequestMessageGetParams) ([]cloudforce_one.CloudforceOneRequestMessageItem, error) ### Priority Response Types: -- cloudflare.CloudforceOneRequestPriorityNewResponse -- cloudflare.CloudforceOneRequestPriorityUpdateResponse -- cloudflare.CloudforceOneRequestPriorityDeleteResponse -- cloudflare.CloudforceOneRequestPriorityGetResponse -- cloudflare.CloudforceOneRequestPriorityQuotaResponse +- cloudforce_one.CloudforceOnePriorityItem +- cloudforce_one.RequestPriorityDeleteResponse Methods: -- client.CloudforceOne.Requests.Priority.New(ctx context.Context, accountIdentifier string, body cloudflare.CloudforceOneRequestPriorityNewParams) (cloudflare.CloudforceOneRequestPriorityNewResponse, error) -- client.CloudforceOne.Requests.Priority.Update(ctx context.Context, accountIdentifier string, priorityIdentifer string, body cloudflare.CloudforceOneRequestPriorityUpdateParams) (cloudflare.CloudforceOneRequestPriorityUpdateResponse, error) -- client.CloudforceOne.Requests.Priority.Delete(ctx context.Context, accountIdentifier string, priorityIdentifer string) (cloudflare.CloudforceOneRequestPriorityDeleteResponse, error) -- client.CloudforceOne.Requests.Priority.Get(ctx context.Context, accountIdentifier string, priorityIdentifer string) (cloudflare.CloudforceOneRequestPriorityGetResponse, error) -- client.CloudforceOne.Requests.Priority.Quota(ctx context.Context, accountIdentifier string) (cloudflare.CloudforceOneRequestPriorityQuotaResponse, error) +- client.CloudforceOne.Requests.Priority.New(ctx context.Context, accountIdentifier string, body cloudforce_one.RequestPriorityNewParams) (cloudforce_one.CloudforceOnePriorityItem, error) +- client.CloudforceOne.Requests.Priority.Update(ctx context.Context, accountIdentifier string, priorityIdentifer string, body cloudforce_one.RequestPriorityUpdateParams) (cloudforce_one.CloudforceOneRequestItem, error) +- client.CloudforceOne.Requests.Priority.Delete(ctx context.Context, accountIdentifier string, priorityIdentifer string) (cloudforce_one.RequestPriorityDeleteResponse, error) +- client.CloudforceOne.Requests.Priority.Get(ctx context.Context, accountIdentifier string, priorityIdentifer string) (cloudforce_one.CloudforceOneRequestItem, error) +- client.CloudforceOne.Requests.Priority.Quota(ctx context.Context, accountIdentifier string) (cloudforce_one.CloudforceOneQuota, error) diff --git a/argo/aliases.go b/argo/aliases.go new file mode 100644 index 00000000000..0e8ee10cac6 --- /dev/null +++ b/argo/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package argo + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/argo.go b/argo/argo.go similarity index 79% rename from argo.go rename to argo/argo.go index 1ce03ddfb72..bdf13df6418 100644 --- a/argo.go +++ b/argo/argo.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package argo import ( "github.com/cloudflare/cloudflare-go/option" @@ -12,8 +12,8 @@ import ( // directly, and instead use the [NewArgoService] method instead. type ArgoService struct { Options []option.RequestOption - SmartRouting *ArgoSmartRoutingService - TieredCaching *ArgoTieredCachingService + SmartRouting *SmartRoutingService + TieredCaching *TieredCachingService } // NewArgoService generates a new service that applies the given options to each @@ -22,7 +22,7 @@ type ArgoService struct { func NewArgoService(opts ...option.RequestOption) (r *ArgoService) { r = &ArgoService{} r.Options = opts - r.SmartRouting = NewArgoSmartRoutingService(opts...) - r.TieredCaching = NewArgoTieredCachingService(opts...) + r.SmartRouting = NewSmartRoutingService(opts...) + r.TieredCaching = NewTieredCachingService(opts...) return } diff --git a/argo/smartrouting.go b/argo/smartrouting.go new file mode 100644 index 00000000000..cd29d62b171 --- /dev/null +++ b/argo/smartrouting.go @@ -0,0 +1,281 @@ +// File generated from our OpenAPI spec by Stainless. + +package argo + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// SmartRoutingService 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 [NewSmartRoutingService] method +// instead. +type SmartRoutingService struct { + Options []option.RequestOption +} + +// NewSmartRoutingService 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 NewSmartRoutingService(opts ...option.RequestOption) (r *SmartRoutingService) { + r = &SmartRoutingService{} + r.Options = opts + return +} + +// Updates enablement of Argo Smart Routing. +func (r *SmartRoutingService) Edit(ctx context.Context, params SmartRoutingEditParams, opts ...option.RequestOption) (res *SmartRoutingEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env SmartRoutingEditResponseEnvelope + path := fmt.Sprintf("zones/%s/argo/smart_routing", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get Argo Smart Routing setting +func (r *SmartRoutingService) Get(ctx context.Context, query SmartRoutingGetParams, opts ...option.RequestOption) (res *SmartRoutingGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env SmartRoutingGetResponseEnvelope + path := fmt.Sprintf("zones/%s/argo/smart_routing", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [argo.SmartRoutingEditResponseUnknown] or +// [shared.UnionString]. +type SmartRoutingEditResponse interface { + ImplementsArgoSmartRoutingEditResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*SmartRoutingEditResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [argo.SmartRoutingGetResponseUnknown] or +// [shared.UnionString]. +type SmartRoutingGetResponse interface { + ImplementsArgoSmartRoutingGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*SmartRoutingGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type SmartRoutingEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Enables Argo Smart Routing. + Value param.Field[SmartRoutingEditParamsValue] `json:"value,required"` +} + +func (r SmartRoutingEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enables Argo Smart Routing. +type SmartRoutingEditParamsValue string + +const ( + SmartRoutingEditParamsValueOn SmartRoutingEditParamsValue = "on" + SmartRoutingEditParamsValueOff SmartRoutingEditParamsValue = "off" +) + +type SmartRoutingEditResponseEnvelope struct { + Errors []SmartRoutingEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SmartRoutingEditResponseEnvelopeMessages `json:"messages,required"` + Result SmartRoutingEditResponse `json:"result,required"` + // Whether the API call was successful + Success SmartRoutingEditResponseEnvelopeSuccess `json:"success,required"` + JSON smartRoutingEditResponseEnvelopeJSON `json:"-"` +} + +// smartRoutingEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SmartRoutingEditResponseEnvelope] +type smartRoutingEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SmartRoutingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r smartRoutingEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SmartRoutingEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON smartRoutingEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// smartRoutingEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SmartRoutingEditResponseEnvelopeErrors] +type smartRoutingEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SmartRoutingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r smartRoutingEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SmartRoutingEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON smartRoutingEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// smartRoutingEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SmartRoutingEditResponseEnvelopeMessages] +type smartRoutingEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SmartRoutingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r smartRoutingEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SmartRoutingEditResponseEnvelopeSuccess bool + +const ( + SmartRoutingEditResponseEnvelopeSuccessTrue SmartRoutingEditResponseEnvelopeSuccess = true +) + +type SmartRoutingGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SmartRoutingGetResponseEnvelope struct { + Errors []SmartRoutingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SmartRoutingGetResponseEnvelopeMessages `json:"messages,required"` + Result SmartRoutingGetResponse `json:"result,required"` + // Whether the API call was successful + Success SmartRoutingGetResponseEnvelopeSuccess `json:"success,required"` + JSON smartRoutingGetResponseEnvelopeJSON `json:"-"` +} + +// smartRoutingGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SmartRoutingGetResponseEnvelope] +type smartRoutingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SmartRoutingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r smartRoutingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SmartRoutingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON smartRoutingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// smartRoutingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SmartRoutingGetResponseEnvelopeErrors] +type smartRoutingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SmartRoutingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r smartRoutingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SmartRoutingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON smartRoutingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// smartRoutingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SmartRoutingGetResponseEnvelopeMessages] +type smartRoutingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SmartRoutingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r smartRoutingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SmartRoutingGetResponseEnvelopeSuccess bool + +const ( + SmartRoutingGetResponseEnvelopeSuccessTrue SmartRoutingGetResponseEnvelopeSuccess = true +) diff --git a/argo/smartrouting_test.go b/argo/smartrouting_test.go new file mode 100644 index 00000000000..82a3c4d6acf --- /dev/null +++ b/argo/smartrouting_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package argo_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/argo" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestSmartRoutingEdit(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("user@example.com"), + ) + _, err := client.Argo.SmartRouting.Edit(context.TODO(), argo.SmartRoutingEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(argo.SmartRoutingEditParamsValueOn), + }) + 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 TestSmartRoutingGet(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("user@example.com"), + ) + _, err := client.Argo.SmartRouting.Get(context.TODO(), argo.SmartRoutingGetParams{ + ZoneID: cloudflare.F("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/argo/tieredcaching.go b/argo/tieredcaching.go new file mode 100644 index 00000000000..85502c90779 --- /dev/null +++ b/argo/tieredcaching.go @@ -0,0 +1,281 @@ +// File generated from our OpenAPI spec by Stainless. + +package argo + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// TieredCachingService 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 [NewTieredCachingService] method +// instead. +type TieredCachingService struct { + Options []option.RequestOption +} + +// NewTieredCachingService 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 NewTieredCachingService(opts ...option.RequestOption) (r *TieredCachingService) { + r = &TieredCachingService{} + r.Options = opts + return +} + +// Updates enablement of Tiered Caching +func (r *TieredCachingService) Edit(ctx context.Context, params TieredCachingEditParams, opts ...option.RequestOption) (res *TieredCachingEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env TieredCachingEditResponseEnvelope + path := fmt.Sprintf("zones/%s/argo/tiered_caching", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get Tiered Caching setting +func (r *TieredCachingService) Get(ctx context.Context, query TieredCachingGetParams, opts ...option.RequestOption) (res *TieredCachingGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env TieredCachingGetResponseEnvelope + path := fmt.Sprintf("zones/%s/argo/tiered_caching", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [argo.TieredCachingEditResponseUnknown] or +// [shared.UnionString]. +type TieredCachingEditResponse interface { + ImplementsArgoTieredCachingEditResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*TieredCachingEditResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [argo.TieredCachingGetResponseUnknown] or +// [shared.UnionString]. +type TieredCachingGetResponse interface { + ImplementsArgoTieredCachingGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*TieredCachingGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type TieredCachingEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Enables Tiered Caching. + Value param.Field[TieredCachingEditParamsValue] `json:"value,required"` +} + +func (r TieredCachingEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enables Tiered Caching. +type TieredCachingEditParamsValue string + +const ( + TieredCachingEditParamsValueOn TieredCachingEditParamsValue = "on" + TieredCachingEditParamsValueOff TieredCachingEditParamsValue = "off" +) + +type TieredCachingEditResponseEnvelope struct { + Errors []TieredCachingEditResponseEnvelopeErrors `json:"errors,required"` + Messages []TieredCachingEditResponseEnvelopeMessages `json:"messages,required"` + Result TieredCachingEditResponse `json:"result,required"` + // Whether the API call was successful + Success TieredCachingEditResponseEnvelopeSuccess `json:"success,required"` + JSON tieredCachingEditResponseEnvelopeJSON `json:"-"` +} + +// tieredCachingEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [TieredCachingEditResponseEnvelope] +type tieredCachingEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TieredCachingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tieredCachingEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TieredCachingEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tieredCachingEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// tieredCachingEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [TieredCachingEditResponseEnvelopeErrors] +type tieredCachingEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TieredCachingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tieredCachingEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TieredCachingEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tieredCachingEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// tieredCachingEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [TieredCachingEditResponseEnvelopeMessages] +type tieredCachingEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TieredCachingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tieredCachingEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TieredCachingEditResponseEnvelopeSuccess bool + +const ( + TieredCachingEditResponseEnvelopeSuccessTrue TieredCachingEditResponseEnvelopeSuccess = true +) + +type TieredCachingGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type TieredCachingGetResponseEnvelope struct { + Errors []TieredCachingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []TieredCachingGetResponseEnvelopeMessages `json:"messages,required"` + Result TieredCachingGetResponse `json:"result,required"` + // Whether the API call was successful + Success TieredCachingGetResponseEnvelopeSuccess `json:"success,required"` + JSON tieredCachingGetResponseEnvelopeJSON `json:"-"` +} + +// tieredCachingGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [TieredCachingGetResponseEnvelope] +type tieredCachingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TieredCachingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tieredCachingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TieredCachingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tieredCachingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// tieredCachingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [TieredCachingGetResponseEnvelopeErrors] +type tieredCachingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TieredCachingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tieredCachingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TieredCachingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tieredCachingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// tieredCachingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [TieredCachingGetResponseEnvelopeMessages] +type tieredCachingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TieredCachingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tieredCachingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TieredCachingGetResponseEnvelopeSuccess bool + +const ( + TieredCachingGetResponseEnvelopeSuccessTrue TieredCachingGetResponseEnvelopeSuccess = true +) diff --git a/argo/tieredcaching_test.go b/argo/tieredcaching_test.go new file mode 100644 index 00000000000..89cae75e0d2 --- /dev/null +++ b/argo/tieredcaching_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package argo_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/argo" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestTieredCachingEdit(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("user@example.com"), + ) + _, err := client.Argo.TieredCaching.Edit(context.TODO(), argo.TieredCachingEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(argo.TieredCachingEditParamsValueOn), + }) + 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 TestTieredCachingGet(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("user@example.com"), + ) + _, err := client.Argo.TieredCaching.Get(context.TODO(), argo.TieredCachingGetParams{ + ZoneID: cloudflare.F("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/argosmartrouting.go b/argosmartrouting.go deleted file mode 100644 index a32fcbcef79..00000000000 --- a/argosmartrouting.go +++ /dev/null @@ -1,280 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ArgoSmartRoutingService 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 [NewArgoSmartRoutingService] method -// instead. -type ArgoSmartRoutingService struct { - Options []option.RequestOption -} - -// NewArgoSmartRoutingService 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 NewArgoSmartRoutingService(opts ...option.RequestOption) (r *ArgoSmartRoutingService) { - r = &ArgoSmartRoutingService{} - r.Options = opts - return -} - -// Updates enablement of Argo Smart Routing. -func (r *ArgoSmartRoutingService) Edit(ctx context.Context, params ArgoSmartRoutingEditParams, opts ...option.RequestOption) (res *ArgoSmartRoutingEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ArgoSmartRoutingEditResponseEnvelope - path := fmt.Sprintf("zones/%s/argo/smart_routing", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get Argo Smart Routing setting -func (r *ArgoSmartRoutingService) Get(ctx context.Context, query ArgoSmartRoutingGetParams, opts ...option.RequestOption) (res *ArgoSmartRoutingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ArgoSmartRoutingGetResponseEnvelope - path := fmt.Sprintf("zones/%s/argo/smart_routing", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [ArgoSmartRoutingEditResponseUnknown] or -// [shared.UnionString]. -type ArgoSmartRoutingEditResponse interface { - ImplementsArgoSmartRoutingEditResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ArgoSmartRoutingEditResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [ArgoSmartRoutingGetResponseUnknown] or [shared.UnionString]. -type ArgoSmartRoutingGetResponse interface { - ImplementsArgoSmartRoutingGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ArgoSmartRoutingGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ArgoSmartRoutingEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Enables Argo Smart Routing. - Value param.Field[ArgoSmartRoutingEditParamsValue] `json:"value,required"` -} - -func (r ArgoSmartRoutingEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enables Argo Smart Routing. -type ArgoSmartRoutingEditParamsValue string - -const ( - ArgoSmartRoutingEditParamsValueOn ArgoSmartRoutingEditParamsValue = "on" - ArgoSmartRoutingEditParamsValueOff ArgoSmartRoutingEditParamsValue = "off" -) - -type ArgoSmartRoutingEditResponseEnvelope struct { - Errors []ArgoSmartRoutingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ArgoSmartRoutingEditResponseEnvelopeMessages `json:"messages,required"` - Result ArgoSmartRoutingEditResponse `json:"result,required"` - // Whether the API call was successful - Success ArgoSmartRoutingEditResponseEnvelopeSuccess `json:"success,required"` - JSON argoSmartRoutingEditResponseEnvelopeJSON `json:"-"` -} - -// argoSmartRoutingEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ArgoSmartRoutingEditResponseEnvelope] -type argoSmartRoutingEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ArgoSmartRoutingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r argoSmartRoutingEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ArgoSmartRoutingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON argoSmartRoutingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// argoSmartRoutingEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ArgoSmartRoutingEditResponseEnvelopeErrors] -type argoSmartRoutingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ArgoSmartRoutingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r argoSmartRoutingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ArgoSmartRoutingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON argoSmartRoutingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// argoSmartRoutingEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ArgoSmartRoutingEditResponseEnvelopeMessages] -type argoSmartRoutingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ArgoSmartRoutingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r argoSmartRoutingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ArgoSmartRoutingEditResponseEnvelopeSuccess bool - -const ( - ArgoSmartRoutingEditResponseEnvelopeSuccessTrue ArgoSmartRoutingEditResponseEnvelopeSuccess = true -) - -type ArgoSmartRoutingGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ArgoSmartRoutingGetResponseEnvelope struct { - Errors []ArgoSmartRoutingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ArgoSmartRoutingGetResponseEnvelopeMessages `json:"messages,required"` - Result ArgoSmartRoutingGetResponse `json:"result,required"` - // Whether the API call was successful - Success ArgoSmartRoutingGetResponseEnvelopeSuccess `json:"success,required"` - JSON argoSmartRoutingGetResponseEnvelopeJSON `json:"-"` -} - -// argoSmartRoutingGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ArgoSmartRoutingGetResponseEnvelope] -type argoSmartRoutingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ArgoSmartRoutingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r argoSmartRoutingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ArgoSmartRoutingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON argoSmartRoutingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// argoSmartRoutingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ArgoSmartRoutingGetResponseEnvelopeErrors] -type argoSmartRoutingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ArgoSmartRoutingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r argoSmartRoutingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ArgoSmartRoutingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON argoSmartRoutingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// argoSmartRoutingGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ArgoSmartRoutingGetResponseEnvelopeMessages] -type argoSmartRoutingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ArgoSmartRoutingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r argoSmartRoutingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ArgoSmartRoutingGetResponseEnvelopeSuccess bool - -const ( - ArgoSmartRoutingGetResponseEnvelopeSuccessTrue ArgoSmartRoutingGetResponseEnvelopeSuccess = true -) diff --git a/argosmartrouting_test.go b/argosmartrouting_test.go deleted file mode 100644 index 383bf7b2bf3..00000000000 --- a/argosmartrouting_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestArgoSmartRoutingEdit(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("user@example.com"), - ) - _, err := client.Argo.SmartRouting.Edit(context.TODO(), cloudflare.ArgoSmartRoutingEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ArgoSmartRoutingEditParamsValueOn), - }) - 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 TestArgoSmartRoutingGet(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("user@example.com"), - ) - _, err := client.Argo.SmartRouting.Get(context.TODO(), cloudflare.ArgoSmartRoutingGetParams{ - ZoneID: cloudflare.F("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/argotieredcaching.go b/argotieredcaching.go deleted file mode 100644 index a714e165c9c..00000000000 --- a/argotieredcaching.go +++ /dev/null @@ -1,281 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ArgoTieredCachingService 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 [NewArgoTieredCachingService] method -// instead. -type ArgoTieredCachingService struct { - Options []option.RequestOption -} - -// NewArgoTieredCachingService 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 NewArgoTieredCachingService(opts ...option.RequestOption) (r *ArgoTieredCachingService) { - r = &ArgoTieredCachingService{} - r.Options = opts - return -} - -// Updates enablement of Tiered Caching -func (r *ArgoTieredCachingService) Edit(ctx context.Context, params ArgoTieredCachingEditParams, opts ...option.RequestOption) (res *ArgoTieredCachingEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ArgoTieredCachingEditResponseEnvelope - path := fmt.Sprintf("zones/%s/argo/tiered_caching", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get Tiered Caching setting -func (r *ArgoTieredCachingService) Get(ctx context.Context, query ArgoTieredCachingGetParams, opts ...option.RequestOption) (res *ArgoTieredCachingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ArgoTieredCachingGetResponseEnvelope - path := fmt.Sprintf("zones/%s/argo/tiered_caching", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [ArgoTieredCachingEditResponseUnknown] or -// [shared.UnionString]. -type ArgoTieredCachingEditResponse interface { - ImplementsArgoTieredCachingEditResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ArgoTieredCachingEditResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [ArgoTieredCachingGetResponseUnknown] or -// [shared.UnionString]. -type ArgoTieredCachingGetResponse interface { - ImplementsArgoTieredCachingGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ArgoTieredCachingGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ArgoTieredCachingEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Enables Tiered Caching. - Value param.Field[ArgoTieredCachingEditParamsValue] `json:"value,required"` -} - -func (r ArgoTieredCachingEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enables Tiered Caching. -type ArgoTieredCachingEditParamsValue string - -const ( - ArgoTieredCachingEditParamsValueOn ArgoTieredCachingEditParamsValue = "on" - ArgoTieredCachingEditParamsValueOff ArgoTieredCachingEditParamsValue = "off" -) - -type ArgoTieredCachingEditResponseEnvelope struct { - Errors []ArgoTieredCachingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ArgoTieredCachingEditResponseEnvelopeMessages `json:"messages,required"` - Result ArgoTieredCachingEditResponse `json:"result,required"` - // Whether the API call was successful - Success ArgoTieredCachingEditResponseEnvelopeSuccess `json:"success,required"` - JSON argoTieredCachingEditResponseEnvelopeJSON `json:"-"` -} - -// argoTieredCachingEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ArgoTieredCachingEditResponseEnvelope] -type argoTieredCachingEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ArgoTieredCachingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r argoTieredCachingEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ArgoTieredCachingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON argoTieredCachingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// argoTieredCachingEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ArgoTieredCachingEditResponseEnvelopeErrors] -type argoTieredCachingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ArgoTieredCachingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r argoTieredCachingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ArgoTieredCachingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON argoTieredCachingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// argoTieredCachingEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ArgoTieredCachingEditResponseEnvelopeMessages] -type argoTieredCachingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ArgoTieredCachingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r argoTieredCachingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ArgoTieredCachingEditResponseEnvelopeSuccess bool - -const ( - ArgoTieredCachingEditResponseEnvelopeSuccessTrue ArgoTieredCachingEditResponseEnvelopeSuccess = true -) - -type ArgoTieredCachingGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ArgoTieredCachingGetResponseEnvelope struct { - Errors []ArgoTieredCachingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ArgoTieredCachingGetResponseEnvelopeMessages `json:"messages,required"` - Result ArgoTieredCachingGetResponse `json:"result,required"` - // Whether the API call was successful - Success ArgoTieredCachingGetResponseEnvelopeSuccess `json:"success,required"` - JSON argoTieredCachingGetResponseEnvelopeJSON `json:"-"` -} - -// argoTieredCachingGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ArgoTieredCachingGetResponseEnvelope] -type argoTieredCachingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ArgoTieredCachingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r argoTieredCachingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ArgoTieredCachingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON argoTieredCachingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// argoTieredCachingGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ArgoTieredCachingGetResponseEnvelopeErrors] -type argoTieredCachingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ArgoTieredCachingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r argoTieredCachingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ArgoTieredCachingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON argoTieredCachingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// argoTieredCachingGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ArgoTieredCachingGetResponseEnvelopeMessages] -type argoTieredCachingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ArgoTieredCachingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r argoTieredCachingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ArgoTieredCachingGetResponseEnvelopeSuccess bool - -const ( - ArgoTieredCachingGetResponseEnvelopeSuccessTrue ArgoTieredCachingGetResponseEnvelopeSuccess = true -) diff --git a/argotieredcaching_test.go b/argotieredcaching_test.go deleted file mode 100644 index 70d53ab9d08..00000000000 --- a/argotieredcaching_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestArgoTieredCachingEdit(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("user@example.com"), - ) - _, err := client.Argo.TieredCaching.Edit(context.TODO(), cloudflare.ArgoTieredCachingEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ArgoTieredCachingEditParamsValueOn), - }) - 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 TestArgoTieredCachingGet(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("user@example.com"), - ) - _, err := client.Argo.TieredCaching.Get(context.TODO(), cloudflare.ArgoTieredCachingGetParams{ - ZoneID: cloudflare.F("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/audit_logs/aliases.go b/audit_logs/aliases.go new file mode 100644 index 00000000000..11570892dad --- /dev/null +++ b/audit_logs/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package audit_logs + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/audit_logs/auditlog.go b/audit_logs/auditlog.go new file mode 100644 index 00000000000..66f6608db86 --- /dev/null +++ b/audit_logs/auditlog.go @@ -0,0 +1,303 @@ +// File generated from our OpenAPI spec by Stainless. + +package audit_logs + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" +) + +// AuditLogService 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 [NewAuditLogService] method instead. +type AuditLogService struct { + Options []option.RequestOption +} + +// NewAuditLogService 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 NewAuditLogService(opts ...option.RequestOption) (r *AuditLogService) { + r = &AuditLogService{} + r.Options = opts + return +} + +// Gets a list of audit logs for an account. Can be filtered by who made the +// change, on which zone, and the timeframe of the change. +func (r *AuditLogService) List(ctx context.Context, accountIdentifier string, query AuditLogListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[AuditLogListResponse], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("accounts/%s/audit_logs", accountIdentifier) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Gets a list of audit logs for an account. Can be filtered by who made the +// change, on which zone, and the timeframe of the change. +func (r *AuditLogService) ListAutoPaging(ctx context.Context, accountIdentifier string, query AuditLogListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[AuditLogListResponse] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, accountIdentifier, query, opts...)) +} + +type AuditLogListResponse struct { + // A string that uniquely identifies the audit log. + ID string `json:"id"` + Action AuditLogListResponseAction `json:"action"` + Actor AuditLogListResponseActor `json:"actor"` + // The source of the event. + Interface string `json:"interface"` + // An object which can lend more context to the action being logged. This is a + // flexible value and varies between different actions. + Metadata interface{} `json:"metadata"` + // The new value of the resource that was modified. + NewValue string `json:"newValue"` + // The value of the resource before it was modified. + OldValue string `json:"oldValue"` + Owner AuditLogListResponseOwner `json:"owner"` + Resource AuditLogListResponseResource `json:"resource"` + // A UTC RFC3339 timestamp that specifies when the action being logged occured. + When time.Time `json:"when" format:"date-time"` + JSON auditLogListResponseJSON `json:"-"` +} + +// auditLogListResponseJSON contains the JSON metadata for the struct +// [AuditLogListResponse] +type auditLogListResponseJSON struct { + ID apijson.Field + Action apijson.Field + Actor apijson.Field + Interface apijson.Field + Metadata apijson.Field + NewValue apijson.Field + OldValue apijson.Field + Owner apijson.Field + Resource apijson.Field + When apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AuditLogListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r auditLogListResponseJSON) RawJSON() string { + return r.raw +} + +type AuditLogListResponseAction struct { + // A boolean that indicates if the action attempted was successful. + Result bool `json:"result"` + // A short string that describes the action that was performed. + Type string `json:"type"` + JSON auditLogListResponseActionJSON `json:"-"` +} + +// auditLogListResponseActionJSON contains the JSON metadata for the struct +// [AuditLogListResponseAction] +type auditLogListResponseActionJSON struct { + Result apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AuditLogListResponseAction) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r auditLogListResponseActionJSON) RawJSON() string { + return r.raw +} + +type AuditLogListResponseActor struct { + // The ID of the actor that performed the action. If a user performed the action, + // this will be their User ID. + ID string `json:"id"` + // The email of the user that performed the action. + Email string `json:"email" format:"email"` + // The IP address of the request that performed the action. + IP string `json:"ip"` + // The type of actor, whether a User, Cloudflare Admin, or an Automated System. + Type AuditLogListResponseActorType `json:"type"` + JSON auditLogListResponseActorJSON `json:"-"` +} + +// auditLogListResponseActorJSON contains the JSON metadata for the struct +// [AuditLogListResponseActor] +type auditLogListResponseActorJSON struct { + ID apijson.Field + Email apijson.Field + IP apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AuditLogListResponseActor) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r auditLogListResponseActorJSON) RawJSON() string { + return r.raw +} + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +type AuditLogListResponseActorType string + +const ( + AuditLogListResponseActorTypeUser AuditLogListResponseActorType = "user" + AuditLogListResponseActorTypeAdmin AuditLogListResponseActorType = "admin" + AuditLogListResponseActorTypeCloudflare AuditLogListResponseActorType = "Cloudflare" +) + +type AuditLogListResponseOwner struct { + // Identifier + ID string `json:"id"` + JSON auditLogListResponseOwnerJSON `json:"-"` +} + +// auditLogListResponseOwnerJSON contains the JSON metadata for the struct +// [AuditLogListResponseOwner] +type auditLogListResponseOwnerJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AuditLogListResponseOwner) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r auditLogListResponseOwnerJSON) RawJSON() string { + return r.raw +} + +type AuditLogListResponseResource struct { + // An identifier for the resource that was affected by the action. + ID string `json:"id"` + // A short string that describes the resource that was affected by the action. + Type string `json:"type"` + JSON auditLogListResponseResourceJSON `json:"-"` +} + +// auditLogListResponseResourceJSON contains the JSON metadata for the struct +// [AuditLogListResponseResource] +type auditLogListResponseResourceJSON struct { + ID apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AuditLogListResponseResource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r auditLogListResponseResourceJSON) RawJSON() string { + return r.raw +} + +type AuditLogListParams struct { + // Finds a specific log by its ID. + ID param.Field[string] `query:"id"` + Action param.Field[AuditLogListParamsAction] `query:"action"` + Actor param.Field[AuditLogListParamsActor] `query:"actor"` + // Limits the returned results to logs older than the specified date. This can be a + // date string `2019-04-30` or an absolute timestamp that conforms to RFC3339. + Before param.Field[time.Time] `query:"before" format:"date-time"` + // Changes the direction of the chronological sorting. + Direction param.Field[AuditLogListParamsDirection] `query:"direction"` + // Indicates that this request is an export of logs in CSV format. + Export param.Field[bool] `query:"export"` + // Indicates whether or not to hide user level audit logs. + HideUserLogs param.Field[bool] `query:"hide_user_logs"` + // Defines which page of results to return. + Page param.Field[float64] `query:"page"` + // Sets the number of results to return per page. + PerPage param.Field[float64] `query:"per_page"` + // Limits the returned results to logs newer than the specified date. This can be a + // date string `2019-04-30` or an absolute timestamp that conforms to RFC3339. + Since param.Field[time.Time] `query:"since" format:"date-time"` + Zone param.Field[AuditLogListParamsZone] `query:"zone"` +} + +// URLQuery serializes [AuditLogListParams]'s query parameters as `url.Values`. +func (r AuditLogListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AuditLogListParamsAction struct { + // Filters by the action type. + Type param.Field[string] `query:"type"` +} + +// URLQuery serializes [AuditLogListParamsAction]'s query parameters as +// `url.Values`. +func (r AuditLogListParamsAction) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AuditLogListParamsActor struct { + // Filters by the email address of the actor that made the change. + Email param.Field[string] `query:"email" format:"email"` + // Filters by the IP address of the request that made the change by specific IP + // address or valid CIDR Range. + IP param.Field[string] `query:"ip"` +} + +// URLQuery serializes [AuditLogListParamsActor]'s query parameters as +// `url.Values`. +func (r AuditLogListParamsActor) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Changes the direction of the chronological sorting. +type AuditLogListParamsDirection string + +const ( + AuditLogListParamsDirectionDesc AuditLogListParamsDirection = "desc" + AuditLogListParamsDirectionAsc AuditLogListParamsDirection = "asc" +) + +type AuditLogListParamsZone struct { + // Filters by the name of the zone associated to the change. + Name param.Field[string] `query:"name"` +} + +// URLQuery serializes [AuditLogListParamsZone]'s query parameters as `url.Values`. +func (r AuditLogListParamsZone) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/audit_logs/auditlog_test.go b/audit_logs/auditlog_test.go new file mode 100644 index 00000000000..eb6bc0e3ad5 --- /dev/null +++ b/audit_logs/auditlog_test.go @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package audit_logs_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/audit_logs" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestAuditLogListWithOptionalParams(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("user@example.com"), + ) + _, err := client.AuditLogs.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + audit_logs.AuditLogListParams{ + ID: cloudflare.F("f174be97-19b1-40d6-954d-70cd5fbd52db"), + Action: cloudflare.F(audit_logs.AuditLogListParamsAction{ + Type: cloudflare.F("add"), + }), + Actor: cloudflare.F(audit_logs.AuditLogListParamsActor{ + IP: cloudflare.F("17.168.228.63"), + Email: cloudflare.F("alice@example.com"), + }), + Before: cloudflare.F(time.Now()), + Direction: cloudflare.F(audit_logs.AuditLogListParamsDirectionDesc), + Export: cloudflare.F(true), + HideUserLogs: cloudflare.F(true), + Page: cloudflare.F(50.000000), + PerPage: cloudflare.F(25.000000), + Since: cloudflare.F(time.Now()), + Zone: cloudflare.F(audit_logs.AuditLogListParamsZone{ + Name: cloudflare.F("example.com"), + }), + }, + ) + 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/auditlog.go b/auditlog.go deleted file mode 100644 index 3cd930b7c2d..00000000000 --- a/auditlog.go +++ /dev/null @@ -1,303 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" -) - -// AuditLogService 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 [NewAuditLogService] method instead. -type AuditLogService struct { - Options []option.RequestOption -} - -// NewAuditLogService 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 NewAuditLogService(opts ...option.RequestOption) (r *AuditLogService) { - r = &AuditLogService{} - r.Options = opts - return -} - -// Gets a list of audit logs for an account. Can be filtered by who made the -// change, on which zone, and the timeframe of the change. -func (r *AuditLogService) List(ctx context.Context, accountIdentifier string, query AuditLogListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[AuditLogListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("accounts/%s/audit_logs", accountIdentifier) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Gets a list of audit logs for an account. Can be filtered by who made the -// change, on which zone, and the timeframe of the change. -func (r *AuditLogService) ListAutoPaging(ctx context.Context, accountIdentifier string, query AuditLogListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[AuditLogListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, accountIdentifier, query, opts...)) -} - -type AuditLogListResponse struct { - // A string that uniquely identifies the audit log. - ID string `json:"id"` - Action AuditLogListResponseAction `json:"action"` - Actor AuditLogListResponseActor `json:"actor"` - // The source of the event. - Interface string `json:"interface"` - // An object which can lend more context to the action being logged. This is a - // flexible value and varies between different actions. - Metadata interface{} `json:"metadata"` - // The new value of the resource that was modified. - NewValue string `json:"newValue"` - // The value of the resource before it was modified. - OldValue string `json:"oldValue"` - Owner AuditLogListResponseOwner `json:"owner"` - Resource AuditLogListResponseResource `json:"resource"` - // A UTC RFC3339 timestamp that specifies when the action being logged occured. - When time.Time `json:"when" format:"date-time"` - JSON auditLogListResponseJSON `json:"-"` -} - -// auditLogListResponseJSON contains the JSON metadata for the struct -// [AuditLogListResponse] -type auditLogListResponseJSON struct { - ID apijson.Field - Action apijson.Field - Actor apijson.Field - Interface apijson.Field - Metadata apijson.Field - NewValue apijson.Field - OldValue apijson.Field - Owner apijson.Field - Resource apijson.Field - When apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AuditLogListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r auditLogListResponseJSON) RawJSON() string { - return r.raw -} - -type AuditLogListResponseAction struct { - // A boolean that indicates if the action attempted was successful. - Result bool `json:"result"` - // A short string that describes the action that was performed. - Type string `json:"type"` - JSON auditLogListResponseActionJSON `json:"-"` -} - -// auditLogListResponseActionJSON contains the JSON metadata for the struct -// [AuditLogListResponseAction] -type auditLogListResponseActionJSON struct { - Result apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AuditLogListResponseAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r auditLogListResponseActionJSON) RawJSON() string { - return r.raw -} - -type AuditLogListResponseActor struct { - // The ID of the actor that performed the action. If a user performed the action, - // this will be their User ID. - ID string `json:"id"` - // The email of the user that performed the action. - Email string `json:"email" format:"email"` - // The IP address of the request that performed the action. - IP string `json:"ip"` - // The type of actor, whether a User, Cloudflare Admin, or an Automated System. - Type AuditLogListResponseActorType `json:"type"` - JSON auditLogListResponseActorJSON `json:"-"` -} - -// auditLogListResponseActorJSON contains the JSON metadata for the struct -// [AuditLogListResponseActor] -type auditLogListResponseActorJSON struct { - ID apijson.Field - Email apijson.Field - IP apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AuditLogListResponseActor) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r auditLogListResponseActorJSON) RawJSON() string { - return r.raw -} - -// The type of actor, whether a User, Cloudflare Admin, or an Automated System. -type AuditLogListResponseActorType string - -const ( - AuditLogListResponseActorTypeUser AuditLogListResponseActorType = "user" - AuditLogListResponseActorTypeAdmin AuditLogListResponseActorType = "admin" - AuditLogListResponseActorTypeCloudflare AuditLogListResponseActorType = "Cloudflare" -) - -type AuditLogListResponseOwner struct { - // Identifier - ID string `json:"id"` - JSON auditLogListResponseOwnerJSON `json:"-"` -} - -// auditLogListResponseOwnerJSON contains the JSON metadata for the struct -// [AuditLogListResponseOwner] -type auditLogListResponseOwnerJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AuditLogListResponseOwner) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r auditLogListResponseOwnerJSON) RawJSON() string { - return r.raw -} - -type AuditLogListResponseResource struct { - // An identifier for the resource that was affected by the action. - ID string `json:"id"` - // A short string that describes the resource that was affected by the action. - Type string `json:"type"` - JSON auditLogListResponseResourceJSON `json:"-"` -} - -// auditLogListResponseResourceJSON contains the JSON metadata for the struct -// [AuditLogListResponseResource] -type auditLogListResponseResourceJSON struct { - ID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AuditLogListResponseResource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r auditLogListResponseResourceJSON) RawJSON() string { - return r.raw -} - -type AuditLogListParams struct { - // Finds a specific log by its ID. - ID param.Field[string] `query:"id"` - Action param.Field[AuditLogListParamsAction] `query:"action"` - Actor param.Field[AuditLogListParamsActor] `query:"actor"` - // Limits the returned results to logs older than the specified date. This can be a - // date string `2019-04-30` or an absolute timestamp that conforms to RFC3339. - Before param.Field[time.Time] `query:"before" format:"date-time"` - // Changes the direction of the chronological sorting. - Direction param.Field[AuditLogListParamsDirection] `query:"direction"` - // Indicates that this request is an export of logs in CSV format. - Export param.Field[bool] `query:"export"` - // Indicates whether or not to hide user level audit logs. - HideUserLogs param.Field[bool] `query:"hide_user_logs"` - // Defines which page of results to return. - Page param.Field[float64] `query:"page"` - // Sets the number of results to return per page. - PerPage param.Field[float64] `query:"per_page"` - // Limits the returned results to logs newer than the specified date. This can be a - // date string `2019-04-30` or an absolute timestamp that conforms to RFC3339. - Since param.Field[time.Time] `query:"since" format:"date-time"` - Zone param.Field[AuditLogListParamsZone] `query:"zone"` -} - -// URLQuery serializes [AuditLogListParams]'s query parameters as `url.Values`. -func (r AuditLogListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type AuditLogListParamsAction struct { - // Filters by the action type. - Type param.Field[string] `query:"type"` -} - -// URLQuery serializes [AuditLogListParamsAction]'s query parameters as -// `url.Values`. -func (r AuditLogListParamsAction) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type AuditLogListParamsActor struct { - // Filters by the email address of the actor that made the change. - Email param.Field[string] `query:"email" format:"email"` - // Filters by the IP address of the request that made the change by specific IP - // address or valid CIDR Range. - IP param.Field[string] `query:"ip"` -} - -// URLQuery serializes [AuditLogListParamsActor]'s query parameters as -// `url.Values`. -func (r AuditLogListParamsActor) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Changes the direction of the chronological sorting. -type AuditLogListParamsDirection string - -const ( - AuditLogListParamsDirectionDesc AuditLogListParamsDirection = "desc" - AuditLogListParamsDirectionAsc AuditLogListParamsDirection = "asc" -) - -type AuditLogListParamsZone struct { - // Filters by the name of the zone associated to the change. - Name param.Field[string] `query:"name"` -} - -// URLQuery serializes [AuditLogListParamsZone]'s query parameters as `url.Values`. -func (r AuditLogListParamsZone) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} diff --git a/auditlog_test.go b/auditlog_test.go deleted file mode 100644 index 468d5062ab9..00000000000 --- a/auditlog_test.go +++ /dev/null @@ -1,62 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestAuditLogListWithOptionalParams(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("user@example.com"), - ) - _, err := client.AuditLogs.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.AuditLogListParams{ - ID: cloudflare.F("f174be97-19b1-40d6-954d-70cd5fbd52db"), - Action: cloudflare.F(cloudflare.AuditLogListParamsAction{ - Type: cloudflare.F("add"), - }), - Actor: cloudflare.F(cloudflare.AuditLogListParamsActor{ - IP: cloudflare.F("17.168.228.63"), - Email: cloudflare.F("alice@example.com"), - }), - Before: cloudflare.F(time.Now()), - Direction: cloudflare.F(cloudflare.AuditLogListParamsDirectionDesc), - Export: cloudflare.F(true), - HideUserLogs: cloudflare.F(true), - Page: cloudflare.F(50.000000), - PerPage: cloudflare.F(25.000000), - Since: cloudflare.F(time.Now()), - Zone: cloudflare.F(cloudflare.AuditLogListParamsZone{ - Name: cloudflare.F("example.com"), - }), - }, - ) - 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/available_plans/aliases.go b/available_plans/aliases.go new file mode 100644 index 00000000000..ae82fa2aab7 --- /dev/null +++ b/available_plans/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package available_plans + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/available_plans/availableplan.go b/available_plans/availableplan.go new file mode 100644 index 00000000000..aa2835319b9 --- /dev/null +++ b/available_plans/availableplan.go @@ -0,0 +1,311 @@ +// File generated from our OpenAPI spec by Stainless. + +package available_plans + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AvailablePlanService 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 [NewAvailablePlanService] method +// instead. +type AvailablePlanService struct { + Options []option.RequestOption +} + +// NewAvailablePlanService 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 NewAvailablePlanService(opts ...option.RequestOption) (r *AvailablePlanService) { + r = &AvailablePlanService{} + r.Options = opts + return +} + +// Lists available plans the zone can subscribe to. +func (r *AvailablePlanService) List(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *[]BillSubsAPIAvailableRatePlan, err error) { + opts = append(r.Options[:], opts...) + var env AvailablePlanListResponseEnvelope + path := fmt.Sprintf("zones/%s/available_plans", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Details of the available plan that the zone can subscribe to. +func (r *AvailablePlanService) Get(ctx context.Context, zoneIdentifier string, planIdentifier string, opts ...option.RequestOption) (res *BillSubsAPIAvailableRatePlan, err error) { + opts = append(r.Options[:], opts...) + var env AvailablePlanGetResponseEnvelope + path := fmt.Sprintf("zones/%s/available_plans/%s", zoneIdentifier, planIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type BillSubsAPIAvailableRatePlan struct { + // Identifier + ID string `json:"id"` + // Indicates whether you can subscribe to this plan. + CanSubscribe bool `json:"can_subscribe"` + // The monetary unit in which pricing information is displayed. + Currency string `json:"currency"` + // Indicates whether this plan is managed externally. + ExternallyManaged bool `json:"externally_managed"` + // The frequency at which you will be billed for this plan. + Frequency BillSubsAPIAvailableRatePlanFrequency `json:"frequency"` + // Indicates whether you are currently subscribed to this plan. + IsSubscribed bool `json:"is_subscribed"` + // Indicates whether this plan has a legacy discount applied. + LegacyDiscount bool `json:"legacy_discount"` + // The legacy identifier for this rate plan, if any. + LegacyID string `json:"legacy_id"` + // The plan name. + Name string `json:"name"` + // The amount you will be billed for this plan. + Price float64 `json:"price"` + JSON billSubsAPIAvailableRatePlanJSON `json:"-"` +} + +// billSubsAPIAvailableRatePlanJSON contains the JSON metadata for the struct +// [BillSubsAPIAvailableRatePlan] +type billSubsAPIAvailableRatePlanJSON struct { + ID apijson.Field + CanSubscribe apijson.Field + Currency apijson.Field + ExternallyManaged apijson.Field + Frequency apijson.Field + IsSubscribed apijson.Field + LegacyDiscount apijson.Field + LegacyID apijson.Field + Name apijson.Field + Price apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BillSubsAPIAvailableRatePlan) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r billSubsAPIAvailableRatePlanJSON) RawJSON() string { + return r.raw +} + +// The frequency at which you will be billed for this plan. +type BillSubsAPIAvailableRatePlanFrequency string + +const ( + BillSubsAPIAvailableRatePlanFrequencyWeekly BillSubsAPIAvailableRatePlanFrequency = "weekly" + BillSubsAPIAvailableRatePlanFrequencyMonthly BillSubsAPIAvailableRatePlanFrequency = "monthly" + BillSubsAPIAvailableRatePlanFrequencyQuarterly BillSubsAPIAvailableRatePlanFrequency = "quarterly" + BillSubsAPIAvailableRatePlanFrequencyYearly BillSubsAPIAvailableRatePlanFrequency = "yearly" +) + +type AvailablePlanListResponseEnvelope struct { + Errors []AvailablePlanListResponseEnvelopeErrors `json:"errors,required"` + Messages []AvailablePlanListResponseEnvelopeMessages `json:"messages,required"` + Result []BillSubsAPIAvailableRatePlan `json:"result,required,nullable"` + // Whether the API call was successful + Success AvailablePlanListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AvailablePlanListResponseEnvelopeResultInfo `json:"result_info"` + JSON availablePlanListResponseEnvelopeJSON `json:"-"` +} + +// availablePlanListResponseEnvelopeJSON contains the JSON metadata for the struct +// [AvailablePlanListResponseEnvelope] +type availablePlanListResponseEnvelopeJSON 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 *AvailablePlanListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r availablePlanListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AvailablePlanListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON availablePlanListResponseEnvelopeErrorsJSON `json:"-"` +} + +// availablePlanListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AvailablePlanListResponseEnvelopeErrors] +type availablePlanListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AvailablePlanListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r availablePlanListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AvailablePlanListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON availablePlanListResponseEnvelopeMessagesJSON `json:"-"` +} + +// availablePlanListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AvailablePlanListResponseEnvelopeMessages] +type availablePlanListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AvailablePlanListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r availablePlanListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AvailablePlanListResponseEnvelopeSuccess bool + +const ( + AvailablePlanListResponseEnvelopeSuccessTrue AvailablePlanListResponseEnvelopeSuccess = true +) + +type AvailablePlanListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON availablePlanListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// availablePlanListResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [AvailablePlanListResponseEnvelopeResultInfo] +type availablePlanListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AvailablePlanListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r availablePlanListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type AvailablePlanGetResponseEnvelope struct { + Errors []AvailablePlanGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AvailablePlanGetResponseEnvelopeMessages `json:"messages,required"` + Result BillSubsAPIAvailableRatePlan `json:"result,required"` + // Whether the API call was successful + Success AvailablePlanGetResponseEnvelopeSuccess `json:"success,required"` + JSON availablePlanGetResponseEnvelopeJSON `json:"-"` +} + +// availablePlanGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [AvailablePlanGetResponseEnvelope] +type availablePlanGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AvailablePlanGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r availablePlanGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AvailablePlanGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON availablePlanGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// availablePlanGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AvailablePlanGetResponseEnvelopeErrors] +type availablePlanGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AvailablePlanGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r availablePlanGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AvailablePlanGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON availablePlanGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// availablePlanGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AvailablePlanGetResponseEnvelopeMessages] +type availablePlanGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AvailablePlanGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r availablePlanGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AvailablePlanGetResponseEnvelopeSuccess bool + +const ( + AvailablePlanGetResponseEnvelopeSuccessTrue AvailablePlanGetResponseEnvelopeSuccess = true +) diff --git a/availableplan_test.go b/available_plans/availableplan_test.go similarity index 98% rename from availableplan_test.go rename to available_plans/availableplan_test.go index efb604f6008..9d451147875 100644 --- a/availableplan_test.go +++ b/available_plans/availableplan_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package available_plans_test import ( "context" diff --git a/available_rate_plans/aliases.go b/available_rate_plans/aliases.go new file mode 100644 index 00000000000..810995c509d --- /dev/null +++ b/available_rate_plans/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package available_rate_plans + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/availablerateplan.go b/available_rate_plans/availablerateplan.go similarity index 99% rename from availablerateplan.go rename to available_rate_plans/availablerateplan.go index be7e7472414..25747209b45 100644 --- a/availablerateplan.go +++ b/available_rate_plans/availablerateplan.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package available_rate_plans import ( "context" diff --git a/availablerateplan_test.go b/available_rate_plans/availablerateplan_test.go similarity index 96% rename from availablerateplan_test.go rename to available_rate_plans/availablerateplan_test.go index 6ee9de04fd3..da8170275a4 100644 --- a/availablerateplan_test.go +++ b/available_rate_plans/availablerateplan_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package available_rate_plans_test import ( "context" diff --git a/availableplan.go b/availableplan.go deleted file mode 100644 index f9787785da9..00000000000 --- a/availableplan.go +++ /dev/null @@ -1,370 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// AvailablePlanService 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 [NewAvailablePlanService] method -// instead. -type AvailablePlanService struct { - Options []option.RequestOption -} - -// NewAvailablePlanService 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 NewAvailablePlanService(opts ...option.RequestOption) (r *AvailablePlanService) { - r = &AvailablePlanService{} - r.Options = opts - return -} - -// Lists available plans the zone can subscribe to. -func (r *AvailablePlanService) List(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *[]AvailablePlanListResponse, err error) { - opts = append(r.Options[:], opts...) - var env AvailablePlanListResponseEnvelope - path := fmt.Sprintf("zones/%s/available_plans", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Details of the available plan that the zone can subscribe to. -func (r *AvailablePlanService) Get(ctx context.Context, zoneIdentifier string, planIdentifier string, opts ...option.RequestOption) (res *AvailablePlanGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env AvailablePlanGetResponseEnvelope - path := fmt.Sprintf("zones/%s/available_plans/%s", zoneIdentifier, planIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type AvailablePlanListResponse struct { - // Identifier - ID string `json:"id"` - // Indicates whether you can subscribe to this plan. - CanSubscribe bool `json:"can_subscribe"` - // The monetary unit in which pricing information is displayed. - Currency string `json:"currency"` - // Indicates whether this plan is managed externally. - ExternallyManaged bool `json:"externally_managed"` - // The frequency at which you will be billed for this plan. - Frequency AvailablePlanListResponseFrequency `json:"frequency"` - // Indicates whether you are currently subscribed to this plan. - IsSubscribed bool `json:"is_subscribed"` - // Indicates whether this plan has a legacy discount applied. - LegacyDiscount bool `json:"legacy_discount"` - // The legacy identifier for this rate plan, if any. - LegacyID string `json:"legacy_id"` - // The plan name. - Name string `json:"name"` - // The amount you will be billed for this plan. - Price float64 `json:"price"` - JSON availablePlanListResponseJSON `json:"-"` -} - -// availablePlanListResponseJSON contains the JSON metadata for the struct -// [AvailablePlanListResponse] -type availablePlanListResponseJSON struct { - ID apijson.Field - CanSubscribe apijson.Field - Currency apijson.Field - ExternallyManaged apijson.Field - Frequency apijson.Field - IsSubscribed apijson.Field - LegacyDiscount apijson.Field - LegacyID apijson.Field - Name apijson.Field - Price apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AvailablePlanListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r availablePlanListResponseJSON) RawJSON() string { - return r.raw -} - -// The frequency at which you will be billed for this plan. -type AvailablePlanListResponseFrequency string - -const ( - AvailablePlanListResponseFrequencyWeekly AvailablePlanListResponseFrequency = "weekly" - AvailablePlanListResponseFrequencyMonthly AvailablePlanListResponseFrequency = "monthly" - AvailablePlanListResponseFrequencyQuarterly AvailablePlanListResponseFrequency = "quarterly" - AvailablePlanListResponseFrequencyYearly AvailablePlanListResponseFrequency = "yearly" -) - -type AvailablePlanGetResponse struct { - // Identifier - ID string `json:"id"` - // Indicates whether you can subscribe to this plan. - CanSubscribe bool `json:"can_subscribe"` - // The monetary unit in which pricing information is displayed. - Currency string `json:"currency"` - // Indicates whether this plan is managed externally. - ExternallyManaged bool `json:"externally_managed"` - // The frequency at which you will be billed for this plan. - Frequency AvailablePlanGetResponseFrequency `json:"frequency"` - // Indicates whether you are currently subscribed to this plan. - IsSubscribed bool `json:"is_subscribed"` - // Indicates whether this plan has a legacy discount applied. - LegacyDiscount bool `json:"legacy_discount"` - // The legacy identifier for this rate plan, if any. - LegacyID string `json:"legacy_id"` - // The plan name. - Name string `json:"name"` - // The amount you will be billed for this plan. - Price float64 `json:"price"` - JSON availablePlanGetResponseJSON `json:"-"` -} - -// availablePlanGetResponseJSON contains the JSON metadata for the struct -// [AvailablePlanGetResponse] -type availablePlanGetResponseJSON struct { - ID apijson.Field - CanSubscribe apijson.Field - Currency apijson.Field - ExternallyManaged apijson.Field - Frequency apijson.Field - IsSubscribed apijson.Field - LegacyDiscount apijson.Field - LegacyID apijson.Field - Name apijson.Field - Price apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AvailablePlanGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r availablePlanGetResponseJSON) RawJSON() string { - return r.raw -} - -// The frequency at which you will be billed for this plan. -type AvailablePlanGetResponseFrequency string - -const ( - AvailablePlanGetResponseFrequencyWeekly AvailablePlanGetResponseFrequency = "weekly" - AvailablePlanGetResponseFrequencyMonthly AvailablePlanGetResponseFrequency = "monthly" - AvailablePlanGetResponseFrequencyQuarterly AvailablePlanGetResponseFrequency = "quarterly" - AvailablePlanGetResponseFrequencyYearly AvailablePlanGetResponseFrequency = "yearly" -) - -type AvailablePlanListResponseEnvelope struct { - Errors []AvailablePlanListResponseEnvelopeErrors `json:"errors,required"` - Messages []AvailablePlanListResponseEnvelopeMessages `json:"messages,required"` - Result []AvailablePlanListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success AvailablePlanListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo AvailablePlanListResponseEnvelopeResultInfo `json:"result_info"` - JSON availablePlanListResponseEnvelopeJSON `json:"-"` -} - -// availablePlanListResponseEnvelopeJSON contains the JSON metadata for the struct -// [AvailablePlanListResponseEnvelope] -type availablePlanListResponseEnvelopeJSON 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 *AvailablePlanListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r availablePlanListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AvailablePlanListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON availablePlanListResponseEnvelopeErrorsJSON `json:"-"` -} - -// availablePlanListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AvailablePlanListResponseEnvelopeErrors] -type availablePlanListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AvailablePlanListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r availablePlanListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AvailablePlanListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON availablePlanListResponseEnvelopeMessagesJSON `json:"-"` -} - -// availablePlanListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AvailablePlanListResponseEnvelopeMessages] -type availablePlanListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AvailablePlanListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r availablePlanListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AvailablePlanListResponseEnvelopeSuccess bool - -const ( - AvailablePlanListResponseEnvelopeSuccessTrue AvailablePlanListResponseEnvelopeSuccess = true -) - -type AvailablePlanListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON availablePlanListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// availablePlanListResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [AvailablePlanListResponseEnvelopeResultInfo] -type availablePlanListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AvailablePlanListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r availablePlanListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type AvailablePlanGetResponseEnvelope struct { - Errors []AvailablePlanGetResponseEnvelopeErrors `json:"errors,required"` - Messages []AvailablePlanGetResponseEnvelopeMessages `json:"messages,required"` - Result AvailablePlanGetResponse `json:"result,required"` - // Whether the API call was successful - Success AvailablePlanGetResponseEnvelopeSuccess `json:"success,required"` - JSON availablePlanGetResponseEnvelopeJSON `json:"-"` -} - -// availablePlanGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [AvailablePlanGetResponseEnvelope] -type availablePlanGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AvailablePlanGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r availablePlanGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type AvailablePlanGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON availablePlanGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// availablePlanGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [AvailablePlanGetResponseEnvelopeErrors] -type availablePlanGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AvailablePlanGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r availablePlanGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type AvailablePlanGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON availablePlanGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// availablePlanGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [AvailablePlanGetResponseEnvelopeMessages] -type availablePlanGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AvailablePlanGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r availablePlanGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type AvailablePlanGetResponseEnvelopeSuccess bool - -const ( - AvailablePlanGetResponseEnvelopeSuccessTrue AvailablePlanGetResponseEnvelopeSuccess = true -) diff --git a/billing.go b/billing.go deleted file mode 100644 index b42688b8df2..00000000000 --- a/billing.go +++ /dev/null @@ -1,26 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// BillingService 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 [NewBillingService] method instead. -type BillingService struct { - Options []option.RequestOption - Profiles *BillingProfileService -} - -// NewBillingService 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 NewBillingService(opts ...option.RequestOption) (r *BillingService) { - r = &BillingService{} - r.Options = opts - r.Profiles = NewBillingProfileService(opts...) - return -} diff --git a/billing/aliases.go b/billing/aliases.go new file mode 100644 index 00000000000..61a101e8bcc --- /dev/null +++ b/billing/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package billing + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/billing/billing.go b/billing/billing.go new file mode 100644 index 00000000000..8e18aaf0f85 --- /dev/null +++ b/billing/billing.go @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package billing + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// BillingService 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 [NewBillingService] method instead. +type BillingService struct { + Options []option.RequestOption + Profiles *ProfileService +} + +// NewBillingService 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 NewBillingService(opts ...option.RequestOption) (r *BillingService) { + r = &BillingService{} + r.Options = opts + r.Profiles = NewProfileService(opts...) + return +} diff --git a/billing/profile.go b/billing/profile.go new file mode 100644 index 00000000000..f1a570018ec --- /dev/null +++ b/billing/profile.go @@ -0,0 +1,143 @@ +// File generated from our OpenAPI spec by Stainless. + +package billing + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// ProfileService 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 [NewProfileService] method instead. +type ProfileService struct { + Options []option.RequestOption +} + +// NewProfileService 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 NewProfileService(opts ...option.RequestOption) (r *ProfileService) { + r = &ProfileService{} + r.Options = opts + return +} + +// Gets the current billing profile for the account. +func (r *ProfileService) Get(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *ProfileGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env ProfileGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/billing/profile", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [billing.ProfileGetResponseUnknown] or [shared.UnionString]. +type ProfileGetResponse interface { + ImplementsBillingProfileGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ProfileGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type ProfileGetResponseEnvelope struct { + Errors []ProfileGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ProfileGetResponseEnvelopeMessages `json:"messages,required"` + Result ProfileGetResponse `json:"result,required"` + // Whether the API call was successful + Success ProfileGetResponseEnvelopeSuccess `json:"success,required"` + JSON profileGetResponseEnvelopeJSON `json:"-"` +} + +// profileGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [ProfileGetResponseEnvelope] +type profileGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProfileGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r profileGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ProfileGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON profileGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// profileGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ProfileGetResponseEnvelopeErrors] +type profileGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProfileGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r profileGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ProfileGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON profileGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// profileGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ProfileGetResponseEnvelopeMessages] +type profileGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProfileGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r profileGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ProfileGetResponseEnvelopeSuccess bool + +const ( + ProfileGetResponseEnvelopeSuccessTrue ProfileGetResponseEnvelopeSuccess = true +) diff --git a/billing/profile_test.go b/billing/profile_test.go new file mode 100644 index 00000000000..82850c03486 --- /dev/null +++ b/billing/profile_test.go @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package billing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestProfileGet(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("user@example.com"), + ) + _, err := client.Billing.Profiles.Get(context.TODO(), map[string]interface{}{}) + 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/bot_management/aliases.go b/bot_management/aliases.go new file mode 100644 index 00000000000..76c07c367b6 --- /dev/null +++ b/bot_management/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package bot_management + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/botmanagement.go b/bot_management/botmanagement.go similarity index 96% rename from botmanagement.go rename to bot_management/botmanagement.go index a8747032f08..fd93be2ef40 100644 --- a/botmanagement.go +++ b/bot_management/botmanagement.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package bot_management import ( "context" @@ -68,12 +68,13 @@ func (r *BotManagementService) Get(ctx context.Context, query BotManagementGetPa return } -// Union satisfied by [BotManagementUpdateResponseBotManagementBotFightModeConfig], -// [BotManagementUpdateResponseBotManagementSbfmDefinitelyConfig], -// [BotManagementUpdateResponseBotManagementSbfmLikelyConfig] or -// [BotManagementUpdateResponseBotManagementBmSubscriptionConfig]. +// Union satisfied by +// [bot_management.BotManagementUpdateResponseBotManagementBotFightModeConfig], +// [bot_management.BotManagementUpdateResponseBotManagementSbfmDefinitelyConfig], +// [bot_management.BotManagementUpdateResponseBotManagementSbfmLikelyConfig] or +// [bot_management.BotManagementUpdateResponseBotManagementBmSubscriptionConfig]. type BotManagementUpdateResponse interface { - implementsBotManagementUpdateResponse() + implementsBotManagementBotManagementUpdateResponse() } func init() { @@ -130,7 +131,7 @@ func (r botManagementUpdateResponseBotManagementBotFightModeConfigJSON) RawJSON( return r.raw } -func (r BotManagementUpdateResponseBotManagementBotFightModeConfig) implementsBotManagementUpdateResponse() { +func (r BotManagementUpdateResponseBotManagementBotFightModeConfig) implementsBotManagementBotManagementUpdateResponse() { } type BotManagementUpdateResponseBotManagementSbfmDefinitelyConfig struct { @@ -175,7 +176,7 @@ func (r botManagementUpdateResponseBotManagementSbfmDefinitelyConfigJSON) RawJSO return r.raw } -func (r BotManagementUpdateResponseBotManagementSbfmDefinitelyConfig) implementsBotManagementUpdateResponse() { +func (r BotManagementUpdateResponseBotManagementSbfmDefinitelyConfig) implementsBotManagementBotManagementUpdateResponse() { } // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. @@ -240,7 +241,7 @@ func (r botManagementUpdateResponseBotManagementSbfmLikelyConfigJSON) RawJSON() return r.raw } -func (r BotManagementUpdateResponseBotManagementSbfmLikelyConfig) implementsBotManagementUpdateResponse() { +func (r BotManagementUpdateResponseBotManagementSbfmLikelyConfig) implementsBotManagementBotManagementUpdateResponse() { } // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. @@ -306,15 +307,16 @@ func (r botManagementUpdateResponseBotManagementBmSubscriptionConfigJSON) RawJSO return r.raw } -func (r BotManagementUpdateResponseBotManagementBmSubscriptionConfig) implementsBotManagementUpdateResponse() { +func (r BotManagementUpdateResponseBotManagementBmSubscriptionConfig) implementsBotManagementBotManagementUpdateResponse() { } -// Union satisfied by [BotManagementGetResponseBotManagementBotFightModeConfig], -// [BotManagementGetResponseBotManagementSbfmDefinitelyConfig], -// [BotManagementGetResponseBotManagementSbfmLikelyConfig] or -// [BotManagementGetResponseBotManagementBmSubscriptionConfig]. +// Union satisfied by +// [bot_management.BotManagementGetResponseBotManagementBotFightModeConfig], +// [bot_management.BotManagementGetResponseBotManagementSbfmDefinitelyConfig], +// [bot_management.BotManagementGetResponseBotManagementSbfmLikelyConfig] or +// [bot_management.BotManagementGetResponseBotManagementBmSubscriptionConfig]. type BotManagementGetResponse interface { - implementsBotManagementGetResponse() + implementsBotManagementBotManagementGetResponse() } func init() { @@ -371,7 +373,7 @@ func (r botManagementGetResponseBotManagementBotFightModeConfigJSON) RawJSON() s return r.raw } -func (r BotManagementGetResponseBotManagementBotFightModeConfig) implementsBotManagementGetResponse() { +func (r BotManagementGetResponseBotManagementBotFightModeConfig) implementsBotManagementBotManagementGetResponse() { } type BotManagementGetResponseBotManagementSbfmDefinitelyConfig struct { @@ -416,7 +418,7 @@ func (r botManagementGetResponseBotManagementSbfmDefinitelyConfigJSON) RawJSON() return r.raw } -func (r BotManagementGetResponseBotManagementSbfmDefinitelyConfig) implementsBotManagementGetResponse() { +func (r BotManagementGetResponseBotManagementSbfmDefinitelyConfig) implementsBotManagementBotManagementGetResponse() { } // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. @@ -480,7 +482,8 @@ func (r botManagementGetResponseBotManagementSbfmLikelyConfigJSON) RawJSON() str return r.raw } -func (r BotManagementGetResponseBotManagementSbfmLikelyConfig) implementsBotManagementGetResponse() {} +func (r BotManagementGetResponseBotManagementSbfmLikelyConfig) implementsBotManagementBotManagementGetResponse() { +} // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. type BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated string @@ -545,7 +548,7 @@ func (r botManagementGetResponseBotManagementBmSubscriptionConfigJSON) RawJSON() return r.raw } -func (r BotManagementGetResponseBotManagementBmSubscriptionConfig) implementsBotManagementGetResponse() { +func (r BotManagementGetResponseBotManagementBmSubscriptionConfig) implementsBotManagementBotManagementGetResponse() { } type BotManagementUpdateParams struct { diff --git a/botmanagement_test.go b/bot_management/botmanagement_test.go similarity index 76% rename from botmanagement_test.go rename to bot_management/botmanagement_test.go index be90e227faf..7c84996dbc7 100644 --- a/botmanagement_test.go +++ b/bot_management/botmanagement_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package bot_management_test import ( "context" @@ -9,6 +9,7 @@ import ( "testing" "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/bot_management" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" ) @@ -27,16 +28,16 @@ func TestBotManagementUpdateWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.BotManagement.Update(context.TODO(), cloudflare.BotManagementUpdateParams{ + _, err := client.BotManagement.Update(context.TODO(), bot_management.BotManagementUpdateParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), AutoUpdateModel: cloudflare.F(true), EnableJs: cloudflare.F(true), FightMode: cloudflare.F(true), OptimizeWordpress: cloudflare.F(true), - SbfmDefinitelyAutomated: cloudflare.F(cloudflare.BotManagementUpdateParamsSbfmDefinitelyAutomatedAllow), - SbfmLikelyAutomated: cloudflare.F(cloudflare.BotManagementUpdateParamsSbfmLikelyAutomatedAllow), + SbfmDefinitelyAutomated: cloudflare.F(bot_management.BotManagementUpdateParamsSbfmDefinitelyAutomatedAllow), + SbfmLikelyAutomated: cloudflare.F(bot_management.BotManagementUpdateParamsSbfmLikelyAutomatedAllow), SbfmStaticResourceProtection: cloudflare.F(true), - SbfmVerifiedBots: cloudflare.F(cloudflare.BotManagementUpdateParamsSbfmVerifiedBotsAllow), + SbfmVerifiedBots: cloudflare.F(bot_management.BotManagementUpdateParamsSbfmVerifiedBotsAllow), SuppressSessionScore: cloudflare.F(false), }) if err != nil { @@ -62,7 +63,7 @@ func TestBotManagementGet(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.BotManagement.Get(context.TODO(), cloudflare.BotManagementGetParams{ + _, err := client.BotManagement.Get(context.TODO(), bot_management.BotManagementGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { diff --git a/brand_protection/aliases.go b/brand_protection/aliases.go new file mode 100644 index 00000000000..33f5e9ab811 --- /dev/null +++ b/brand_protection/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package brand_protection + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/brand_protection/brandprotection.go b/brand_protection/brandprotection.go new file mode 100644 index 00000000000..b5f1683dbc1 --- /dev/null +++ b/brand_protection/brandprotection.go @@ -0,0 +1,518 @@ +// File generated from our OpenAPI spec by Stainless. + +package brand_protection + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// BrandProtectionService 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 [NewBrandProtectionService] method +// instead. +type BrandProtectionService struct { + Options []option.RequestOption +} + +// NewBrandProtectionService 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 NewBrandProtectionService(opts ...option.RequestOption) (r *BrandProtectionService) { + r = &BrandProtectionService{} + r.Options = opts + return +} + +// Submit suspicious URL for scanning +func (r *BrandProtectionService) Submit(ctx context.Context, params BrandProtectionSubmitParams, opts ...option.RequestOption) (res *IntelPhishingURLSubmit, err error) { + opts = append(r.Options[:], opts...) + var env BrandProtectionSubmitResponseEnvelope + path := fmt.Sprintf("accounts/%s/brand-protection/submit", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get results for a URL scan +func (r *BrandProtectionService) URLInfo(ctx context.Context, params BrandProtectionURLInfoParams, opts ...option.RequestOption) (res *IntelPhishingURLInfo, err error) { + opts = append(r.Options[:], opts...) + var env BrandProtectionURLInfoResponseEnvelope + path := fmt.Sprintf("accounts/%s/brand-protection/url-info", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type IntelPhishingURLInfo struct { + // List of categorizations applied to this submission. + Categorizations []IntelPhishingURLInfoCategorization `json:"categorizations"` + // List of model results for completed scans. + ModelResults []IntelPhishingURLInfoModelResult `json:"model_results"` + // List of signatures that matched against site content found when crawling the + // URL. + RuleMatches []IntelPhishingURLInfoRuleMatch `json:"rule_matches"` + // Status of the most recent scan found. + ScanStatus IntelPhishingURLInfoScanStatus `json:"scan_status"` + // For internal use. + ScreenshotDownloadSignature string `json:"screenshot_download_signature"` + // For internal use. + ScreenshotPath string `json:"screenshot_path"` + // URL that was submitted. + URL string `json:"url"` + JSON intelPhishingURLInfoJSON `json:"-"` +} + +// intelPhishingURLInfoJSON contains the JSON metadata for the struct +// [IntelPhishingURLInfo] +type intelPhishingURLInfoJSON struct { + Categorizations apijson.Field + ModelResults apijson.Field + RuleMatches apijson.Field + ScanStatus apijson.Field + ScreenshotDownloadSignature apijson.Field + ScreenshotPath apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelPhishingURLInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelPhishingURLInfoJSON) RawJSON() string { + return r.raw +} + +type IntelPhishingURLInfoCategorization struct { + // Name of the category applied. + Category string `json:"category"` + // Result of human review for this categorization. + VerificationStatus string `json:"verification_status"` + JSON intelPhishingURLInfoCategorizationJSON `json:"-"` +} + +// intelPhishingURLInfoCategorizationJSON contains the JSON metadata for the struct +// [IntelPhishingURLInfoCategorization] +type intelPhishingURLInfoCategorizationJSON struct { + Category apijson.Field + VerificationStatus apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelPhishingURLInfoCategorization) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelPhishingURLInfoCategorizationJSON) RawJSON() string { + return r.raw +} + +type IntelPhishingURLInfoModelResult struct { + // Name of the model. + ModelName string `json:"model_name"` + // Score output by the model for this submission. + ModelScore float64 `json:"model_score"` + JSON intelPhishingURLInfoModelResultJSON `json:"-"` +} + +// intelPhishingURLInfoModelResultJSON contains the JSON metadata for the struct +// [IntelPhishingURLInfoModelResult] +type intelPhishingURLInfoModelResultJSON struct { + ModelName apijson.Field + ModelScore apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelPhishingURLInfoModelResult) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelPhishingURLInfoModelResultJSON) RawJSON() string { + return r.raw +} + +type IntelPhishingURLInfoRuleMatch struct { + // For internal use. + Banning bool `json:"banning"` + // For internal use. + Blocking bool `json:"blocking"` + // Description of the signature that matched. + Description string `json:"description"` + // Name of the signature that matched. + Name string `json:"name"` + JSON intelPhishingURLInfoRuleMatchJSON `json:"-"` +} + +// intelPhishingURLInfoRuleMatchJSON contains the JSON metadata for the struct +// [IntelPhishingURLInfoRuleMatch] +type intelPhishingURLInfoRuleMatchJSON struct { + Banning apijson.Field + Blocking apijson.Field + Description apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelPhishingURLInfoRuleMatch) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelPhishingURLInfoRuleMatchJSON) RawJSON() string { + return r.raw +} + +// Status of the most recent scan found. +type IntelPhishingURLInfoScanStatus struct { + // Timestamp of when the submission was processed. + LastProcessed string `json:"last_processed"` + // For internal use. + ScanComplete bool `json:"scan_complete"` + // Status code that the crawler received when loading the submitted URL. + StatusCode int64 `json:"status_code"` + // ID of the most recent submission. + SubmissionID int64 `json:"submission_id"` + JSON intelPhishingURLInfoScanStatusJSON `json:"-"` +} + +// intelPhishingURLInfoScanStatusJSON contains the JSON metadata for the struct +// [IntelPhishingURLInfoScanStatus] +type intelPhishingURLInfoScanStatusJSON struct { + LastProcessed apijson.Field + ScanComplete apijson.Field + StatusCode apijson.Field + SubmissionID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelPhishingURLInfoScanStatus) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelPhishingURLInfoScanStatusJSON) RawJSON() string { + return r.raw +} + +type IntelPhishingURLSubmit struct { + // URLs that were excluded from scanning because their domain is in our no-scan + // list. + ExcludedURLs []IntelPhishingURLSubmitExcludedURL `json:"excluded_urls"` + // URLs that were skipped because the same URL is currently being scanned + SkippedURLs []IntelPhishingURLSubmitSkippedURL `json:"skipped_urls"` + // URLs that were successfully submitted for scanning. + SubmittedURLs []IntelPhishingURLSubmitSubmittedURL `json:"submitted_urls"` + JSON intelPhishingURLSubmitJSON `json:"-"` +} + +// intelPhishingURLSubmitJSON contains the JSON metadata for the struct +// [IntelPhishingURLSubmit] +type intelPhishingURLSubmitJSON struct { + ExcludedURLs apijson.Field + SkippedURLs apijson.Field + SubmittedURLs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelPhishingURLSubmit) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelPhishingURLSubmitJSON) RawJSON() string { + return r.raw +} + +type IntelPhishingURLSubmitExcludedURL struct { + // URL that was excluded. + URL string `json:"url"` + JSON intelPhishingURLSubmitExcludedURLJSON `json:"-"` +} + +// intelPhishingURLSubmitExcludedURLJSON contains the JSON metadata for the struct +// [IntelPhishingURLSubmitExcludedURL] +type intelPhishingURLSubmitExcludedURLJSON struct { + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelPhishingURLSubmitExcludedURL) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelPhishingURLSubmitExcludedURLJSON) RawJSON() string { + return r.raw +} + +type IntelPhishingURLSubmitSkippedURL struct { + // URL that was skipped. + URL string `json:"url"` + // ID of the submission of that URL that is currently scanning. + URLID int64 `json:"url_id"` + JSON intelPhishingURLSubmitSkippedURLJSON `json:"-"` +} + +// intelPhishingURLSubmitSkippedURLJSON contains the JSON metadata for the struct +// [IntelPhishingURLSubmitSkippedURL] +type intelPhishingURLSubmitSkippedURLJSON struct { + URL apijson.Field + URLID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelPhishingURLSubmitSkippedURL) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelPhishingURLSubmitSkippedURLJSON) RawJSON() string { + return r.raw +} + +type IntelPhishingURLSubmitSubmittedURL struct { + // URL that was submitted. + URL string `json:"url"` + // ID assigned to this URL submission. Used to retrieve scanning results. + URLID int64 `json:"url_id"` + JSON intelPhishingURLSubmitSubmittedURLJSON `json:"-"` +} + +// intelPhishingURLSubmitSubmittedURLJSON contains the JSON metadata for the struct +// [IntelPhishingURLSubmitSubmittedURL] +type intelPhishingURLSubmitSubmittedURLJSON struct { + URL apijson.Field + URLID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelPhishingURLSubmitSubmittedURL) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelPhishingURLSubmitSubmittedURLJSON) RawJSON() string { + return r.raw +} + +type BrandProtectionSubmitParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // URL(s) to filter submissions results by + URL param.Field[string] `json:"url" format:"uri"` +} + +func (r BrandProtectionSubmitParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type BrandProtectionSubmitResponseEnvelope struct { + Errors []BrandProtectionSubmitResponseEnvelopeErrors `json:"errors,required"` + Messages []BrandProtectionSubmitResponseEnvelopeMessages `json:"messages,required"` + Result IntelPhishingURLSubmit `json:"result,required"` + // Whether the API call was successful + Success BrandProtectionSubmitResponseEnvelopeSuccess `json:"success,required"` + JSON brandProtectionSubmitResponseEnvelopeJSON `json:"-"` +} + +// brandProtectionSubmitResponseEnvelopeJSON contains the JSON metadata for the +// struct [BrandProtectionSubmitResponseEnvelope] +type brandProtectionSubmitResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BrandProtectionSubmitResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r brandProtectionSubmitResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type BrandProtectionSubmitResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON brandProtectionSubmitResponseEnvelopeErrorsJSON `json:"-"` +} + +// brandProtectionSubmitResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [BrandProtectionSubmitResponseEnvelopeErrors] +type brandProtectionSubmitResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BrandProtectionSubmitResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r brandProtectionSubmitResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type BrandProtectionSubmitResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON brandProtectionSubmitResponseEnvelopeMessagesJSON `json:"-"` +} + +// brandProtectionSubmitResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [BrandProtectionSubmitResponseEnvelopeMessages] +type brandProtectionSubmitResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BrandProtectionSubmitResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r brandProtectionSubmitResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type BrandProtectionSubmitResponseEnvelopeSuccess bool + +const ( + BrandProtectionSubmitResponseEnvelopeSuccessTrue BrandProtectionSubmitResponseEnvelopeSuccess = true +) + +type BrandProtectionURLInfoParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + URL param.Field[string] `query:"url"` + URLIDParam param.Field[BrandProtectionURLInfoParamsURLIDParam] `query:"url_id_param"` +} + +// URLQuery serializes [BrandProtectionURLInfoParams]'s query parameters as +// `url.Values`. +func (r BrandProtectionURLInfoParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type BrandProtectionURLInfoParamsURLIDParam struct { + // Submission ID(s) to filter submission results by. + URLID param.Field[int64] `query:"url_id"` +} + +// URLQuery serializes [BrandProtectionURLInfoParamsURLIDParam]'s query parameters +// as `url.Values`. +func (r BrandProtectionURLInfoParamsURLIDParam) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type BrandProtectionURLInfoResponseEnvelope struct { + Errors []BrandProtectionURLInfoResponseEnvelopeErrors `json:"errors,required"` + Messages []BrandProtectionURLInfoResponseEnvelopeMessages `json:"messages,required"` + Result IntelPhishingURLInfo `json:"result,required"` + // Whether the API call was successful + Success BrandProtectionURLInfoResponseEnvelopeSuccess `json:"success,required"` + JSON brandProtectionURLInfoResponseEnvelopeJSON `json:"-"` +} + +// brandProtectionURLInfoResponseEnvelopeJSON contains the JSON metadata for the +// struct [BrandProtectionURLInfoResponseEnvelope] +type brandProtectionURLInfoResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BrandProtectionURLInfoResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r brandProtectionURLInfoResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type BrandProtectionURLInfoResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON brandProtectionURLInfoResponseEnvelopeErrorsJSON `json:"-"` +} + +// brandProtectionURLInfoResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [BrandProtectionURLInfoResponseEnvelopeErrors] +type brandProtectionURLInfoResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BrandProtectionURLInfoResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r brandProtectionURLInfoResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type BrandProtectionURLInfoResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON brandProtectionURLInfoResponseEnvelopeMessagesJSON `json:"-"` +} + +// brandProtectionURLInfoResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [BrandProtectionURLInfoResponseEnvelopeMessages] +type brandProtectionURLInfoResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BrandProtectionURLInfoResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r brandProtectionURLInfoResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type BrandProtectionURLInfoResponseEnvelopeSuccess bool + +const ( + BrandProtectionURLInfoResponseEnvelopeSuccessTrue BrandProtectionURLInfoResponseEnvelopeSuccess = true +) diff --git a/brandprotection_test.go b/brand_protection/brandprotection_test.go similarity index 82% rename from brandprotection_test.go rename to brand_protection/brandprotection_test.go index 4ee72fb7bf8..747242163d6 100644 --- a/brandprotection_test.go +++ b/brand_protection/brandprotection_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package brand_protection_test import ( "context" @@ -9,6 +9,7 @@ import ( "testing" "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/brand_protection" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" ) @@ -27,7 +28,7 @@ func TestBrandProtectionSubmitWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.BrandProtection.Submit(context.TODO(), cloudflare.BrandProtectionSubmitParams{ + _, err := client.BrandProtection.Submit(context.TODO(), brand_protection.BrandProtectionSubmitParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), URL: cloudflare.F("https://www.cloudflare.com"), }) @@ -54,10 +55,10 @@ func TestBrandProtectionURLInfoWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.BrandProtection.URLInfo(context.TODO(), cloudflare.BrandProtectionURLInfoParams{ + _, err := client.BrandProtection.URLInfo(context.TODO(), brand_protection.BrandProtectionURLInfoParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), URL: cloudflare.F("string"), - URLIDParam: cloudflare.F(cloudflare.BrandProtectionURLInfoParamsURLIDParam{ + URLIDParam: cloudflare.F(brand_protection.BrandProtectionURLInfoParamsURLIDParam{ URLID: cloudflare.F(int64(0)), }), }) diff --git a/brandprotection.go b/brandprotection.go deleted file mode 100644 index 31e3bbb7a23..00000000000 --- a/brandprotection.go +++ /dev/null @@ -1,518 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// BrandProtectionService 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 [NewBrandProtectionService] method -// instead. -type BrandProtectionService struct { - Options []option.RequestOption -} - -// NewBrandProtectionService 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 NewBrandProtectionService(opts ...option.RequestOption) (r *BrandProtectionService) { - r = &BrandProtectionService{} - r.Options = opts - return -} - -// Submit suspicious URL for scanning -func (r *BrandProtectionService) Submit(ctx context.Context, params BrandProtectionSubmitParams, opts ...option.RequestOption) (res *BrandProtectionSubmitResponse, err error) { - opts = append(r.Options[:], opts...) - var env BrandProtectionSubmitResponseEnvelope - path := fmt.Sprintf("accounts/%s/brand-protection/submit", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get results for a URL scan -func (r *BrandProtectionService) URLInfo(ctx context.Context, params BrandProtectionURLInfoParams, opts ...option.RequestOption) (res *BrandProtectionURLInfoResponse, err error) { - opts = append(r.Options[:], opts...) - var env BrandProtectionURLInfoResponseEnvelope - path := fmt.Sprintf("accounts/%s/brand-protection/url-info", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type BrandProtectionSubmitResponse struct { - // URLs that were excluded from scanning because their domain is in our no-scan - // list. - ExcludedURLs []BrandProtectionSubmitResponseExcludedURL `json:"excluded_urls"` - // URLs that were skipped because the same URL is currently being scanned - SkippedURLs []BrandProtectionSubmitResponseSkippedURL `json:"skipped_urls"` - // URLs that were successfully submitted for scanning. - SubmittedURLs []BrandProtectionSubmitResponseSubmittedURL `json:"submitted_urls"` - JSON brandProtectionSubmitResponseJSON `json:"-"` -} - -// brandProtectionSubmitResponseJSON contains the JSON metadata for the struct -// [BrandProtectionSubmitResponse] -type brandProtectionSubmitResponseJSON struct { - ExcludedURLs apijson.Field - SkippedURLs apijson.Field - SubmittedURLs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionSubmitResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionSubmitResponseJSON) RawJSON() string { - return r.raw -} - -type BrandProtectionSubmitResponseExcludedURL struct { - // URL that was excluded. - URL string `json:"url"` - JSON brandProtectionSubmitResponseExcludedURLJSON `json:"-"` -} - -// brandProtectionSubmitResponseExcludedURLJSON contains the JSON metadata for the -// struct [BrandProtectionSubmitResponseExcludedURL] -type brandProtectionSubmitResponseExcludedURLJSON struct { - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionSubmitResponseExcludedURL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionSubmitResponseExcludedURLJSON) RawJSON() string { - return r.raw -} - -type BrandProtectionSubmitResponseSkippedURL struct { - // URL that was skipped. - URL string `json:"url"` - // ID of the submission of that URL that is currently scanning. - URLID int64 `json:"url_id"` - JSON brandProtectionSubmitResponseSkippedURLJSON `json:"-"` -} - -// brandProtectionSubmitResponseSkippedURLJSON contains the JSON metadata for the -// struct [BrandProtectionSubmitResponseSkippedURL] -type brandProtectionSubmitResponseSkippedURLJSON struct { - URL apijson.Field - URLID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionSubmitResponseSkippedURL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionSubmitResponseSkippedURLJSON) RawJSON() string { - return r.raw -} - -type BrandProtectionSubmitResponseSubmittedURL struct { - // URL that was submitted. - URL string `json:"url"` - // ID assigned to this URL submission. Used to retrieve scanning results. - URLID int64 `json:"url_id"` - JSON brandProtectionSubmitResponseSubmittedURLJSON `json:"-"` -} - -// brandProtectionSubmitResponseSubmittedURLJSON contains the JSON metadata for the -// struct [BrandProtectionSubmitResponseSubmittedURL] -type brandProtectionSubmitResponseSubmittedURLJSON struct { - URL apijson.Field - URLID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionSubmitResponseSubmittedURL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionSubmitResponseSubmittedURLJSON) RawJSON() string { - return r.raw -} - -type BrandProtectionURLInfoResponse struct { - // List of categorizations applied to this submission. - Categorizations []BrandProtectionURLInfoResponseCategorization `json:"categorizations"` - // List of model results for completed scans. - ModelResults []BrandProtectionURLInfoResponseModelResult `json:"model_results"` - // List of signatures that matched against site content found when crawling the - // URL. - RuleMatches []BrandProtectionURLInfoResponseRuleMatch `json:"rule_matches"` - // Status of the most recent scan found. - ScanStatus BrandProtectionURLInfoResponseScanStatus `json:"scan_status"` - // For internal use. - ScreenshotDownloadSignature string `json:"screenshot_download_signature"` - // For internal use. - ScreenshotPath string `json:"screenshot_path"` - // URL that was submitted. - URL string `json:"url"` - JSON brandProtectionURLInfoResponseJSON `json:"-"` -} - -// brandProtectionURLInfoResponseJSON contains the JSON metadata for the struct -// [BrandProtectionURLInfoResponse] -type brandProtectionURLInfoResponseJSON struct { - Categorizations apijson.Field - ModelResults apijson.Field - RuleMatches apijson.Field - ScanStatus apijson.Field - ScreenshotDownloadSignature apijson.Field - ScreenshotPath apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionURLInfoResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionURLInfoResponseJSON) RawJSON() string { - return r.raw -} - -type BrandProtectionURLInfoResponseCategorization struct { - // Name of the category applied. - Category string `json:"category"` - // Result of human review for this categorization. - VerificationStatus string `json:"verification_status"` - JSON brandProtectionURLInfoResponseCategorizationJSON `json:"-"` -} - -// brandProtectionURLInfoResponseCategorizationJSON contains the JSON metadata for -// the struct [BrandProtectionURLInfoResponseCategorization] -type brandProtectionURLInfoResponseCategorizationJSON struct { - Category apijson.Field - VerificationStatus apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionURLInfoResponseCategorization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionURLInfoResponseCategorizationJSON) RawJSON() string { - return r.raw -} - -type BrandProtectionURLInfoResponseModelResult struct { - // Name of the model. - ModelName string `json:"model_name"` - // Score output by the model for this submission. - ModelScore float64 `json:"model_score"` - JSON brandProtectionURLInfoResponseModelResultJSON `json:"-"` -} - -// brandProtectionURLInfoResponseModelResultJSON contains the JSON metadata for the -// struct [BrandProtectionURLInfoResponseModelResult] -type brandProtectionURLInfoResponseModelResultJSON struct { - ModelName apijson.Field - ModelScore apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionURLInfoResponseModelResult) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionURLInfoResponseModelResultJSON) RawJSON() string { - return r.raw -} - -type BrandProtectionURLInfoResponseRuleMatch struct { - // For internal use. - Banning bool `json:"banning"` - // For internal use. - Blocking bool `json:"blocking"` - // Description of the signature that matched. - Description string `json:"description"` - // Name of the signature that matched. - Name string `json:"name"` - JSON brandProtectionURLInfoResponseRuleMatchJSON `json:"-"` -} - -// brandProtectionURLInfoResponseRuleMatchJSON contains the JSON metadata for the -// struct [BrandProtectionURLInfoResponseRuleMatch] -type brandProtectionURLInfoResponseRuleMatchJSON struct { - Banning apijson.Field - Blocking apijson.Field - Description apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionURLInfoResponseRuleMatch) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionURLInfoResponseRuleMatchJSON) RawJSON() string { - return r.raw -} - -// Status of the most recent scan found. -type BrandProtectionURLInfoResponseScanStatus struct { - // Timestamp of when the submission was processed. - LastProcessed string `json:"last_processed"` - // For internal use. - ScanComplete bool `json:"scan_complete"` - // Status code that the crawler received when loading the submitted URL. - StatusCode int64 `json:"status_code"` - // ID of the most recent submission. - SubmissionID int64 `json:"submission_id"` - JSON brandProtectionURLInfoResponseScanStatusJSON `json:"-"` -} - -// brandProtectionURLInfoResponseScanStatusJSON contains the JSON metadata for the -// struct [BrandProtectionURLInfoResponseScanStatus] -type brandProtectionURLInfoResponseScanStatusJSON struct { - LastProcessed apijson.Field - ScanComplete apijson.Field - StatusCode apijson.Field - SubmissionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionURLInfoResponseScanStatus) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionURLInfoResponseScanStatusJSON) RawJSON() string { - return r.raw -} - -type BrandProtectionSubmitParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // URL(s) to filter submissions results by - URL param.Field[string] `json:"url" format:"uri"` -} - -func (r BrandProtectionSubmitParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type BrandProtectionSubmitResponseEnvelope struct { - Errors []BrandProtectionSubmitResponseEnvelopeErrors `json:"errors,required"` - Messages []BrandProtectionSubmitResponseEnvelopeMessages `json:"messages,required"` - Result BrandProtectionSubmitResponse `json:"result,required"` - // Whether the API call was successful - Success BrandProtectionSubmitResponseEnvelopeSuccess `json:"success,required"` - JSON brandProtectionSubmitResponseEnvelopeJSON `json:"-"` -} - -// brandProtectionSubmitResponseEnvelopeJSON contains the JSON metadata for the -// struct [BrandProtectionSubmitResponseEnvelope] -type brandProtectionSubmitResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionSubmitResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionSubmitResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type BrandProtectionSubmitResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON brandProtectionSubmitResponseEnvelopeErrorsJSON `json:"-"` -} - -// brandProtectionSubmitResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [BrandProtectionSubmitResponseEnvelopeErrors] -type brandProtectionSubmitResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionSubmitResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionSubmitResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type BrandProtectionSubmitResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON brandProtectionSubmitResponseEnvelopeMessagesJSON `json:"-"` -} - -// brandProtectionSubmitResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [BrandProtectionSubmitResponseEnvelopeMessages] -type brandProtectionSubmitResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionSubmitResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionSubmitResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type BrandProtectionSubmitResponseEnvelopeSuccess bool - -const ( - BrandProtectionSubmitResponseEnvelopeSuccessTrue BrandProtectionSubmitResponseEnvelopeSuccess = true -) - -type BrandProtectionURLInfoParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - URL param.Field[string] `query:"url"` - URLIDParam param.Field[BrandProtectionURLInfoParamsURLIDParam] `query:"url_id_param"` -} - -// URLQuery serializes [BrandProtectionURLInfoParams]'s query parameters as -// `url.Values`. -func (r BrandProtectionURLInfoParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type BrandProtectionURLInfoParamsURLIDParam struct { - // Submission ID(s) to filter submission results by. - URLID param.Field[int64] `query:"url_id"` -} - -// URLQuery serializes [BrandProtectionURLInfoParamsURLIDParam]'s query parameters -// as `url.Values`. -func (r BrandProtectionURLInfoParamsURLIDParam) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type BrandProtectionURLInfoResponseEnvelope struct { - Errors []BrandProtectionURLInfoResponseEnvelopeErrors `json:"errors,required"` - Messages []BrandProtectionURLInfoResponseEnvelopeMessages `json:"messages,required"` - Result BrandProtectionURLInfoResponse `json:"result,required"` - // Whether the API call was successful - Success BrandProtectionURLInfoResponseEnvelopeSuccess `json:"success,required"` - JSON brandProtectionURLInfoResponseEnvelopeJSON `json:"-"` -} - -// brandProtectionURLInfoResponseEnvelopeJSON contains the JSON metadata for the -// struct [BrandProtectionURLInfoResponseEnvelope] -type brandProtectionURLInfoResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionURLInfoResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionURLInfoResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type BrandProtectionURLInfoResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON brandProtectionURLInfoResponseEnvelopeErrorsJSON `json:"-"` -} - -// brandProtectionURLInfoResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [BrandProtectionURLInfoResponseEnvelopeErrors] -type brandProtectionURLInfoResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionURLInfoResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionURLInfoResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type BrandProtectionURLInfoResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON brandProtectionURLInfoResponseEnvelopeMessagesJSON `json:"-"` -} - -// brandProtectionURLInfoResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [BrandProtectionURLInfoResponseEnvelopeMessages] -type brandProtectionURLInfoResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BrandProtectionURLInfoResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r brandProtectionURLInfoResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type BrandProtectionURLInfoResponseEnvelopeSuccess bool - -const ( - BrandProtectionURLInfoResponseEnvelopeSuccessTrue BrandProtectionURLInfoResponseEnvelopeSuccess = true -) diff --git a/cache/aliases.go b/cache/aliases.go new file mode 100644 index 00000000000..84393769749 --- /dev/null +++ b/cache/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package cache + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/cache.go b/cache/cache.go similarity index 92% rename from cache.go rename to cache/cache.go index 0983eb1cad4..6ae254a27cd 100644 --- a/cache.go +++ b/cache/cache.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package cache import ( "context" @@ -19,10 +19,10 @@ import ( // directly, and instead use the [NewCacheService] method instead. type CacheService struct { Options []option.RequestOption - CacheReserve *CacheCacheReserveService - SmartTieredCached *CacheSmartTieredCachedService - Variants *CacheVariantService - RegionalTieredCache *CacheRegionalTieredCacheService + CacheReserve *CacheReserveService + SmartTieredCached *SmartTieredCachedService + Variants *VariantService + RegionalTieredCache *RegionalTieredCacheService } // NewCacheService generates a new service that applies the given options to each @@ -31,10 +31,10 @@ type CacheService struct { func NewCacheService(opts ...option.RequestOption) (r *CacheService) { r = &CacheService{} r.Options = opts - r.CacheReserve = NewCacheCacheReserveService(opts...) - r.SmartTieredCached = NewCacheSmartTieredCachedService(opts...) - r.Variants = NewCacheVariantService(opts...) - r.RegionalTieredCache = NewCacheRegionalTieredCacheService(opts...) + r.CacheReserve = NewCacheReserveService(opts...) + r.SmartTieredCached = NewSmartTieredCachedService(opts...) + r.Variants = NewVariantService(opts...) + r.RegionalTieredCache = NewRegionalTieredCacheService(opts...) return } @@ -114,9 +114,9 @@ func (r CachePurgeParams) MarshalJSON() (data []byte, err error) { } // Satisfied by [shared.UnionString], -// [CachePurgeParamsFilesCachePurgeURLAndHeaders]. +// [cache.CachePurgeParamsFilesCachePurgeURLAndHeaders]. type CachePurgeParamsFile interface { - ImplementsCachePurgeParamsFile() + ImplementsCacheCachePurgeParamsFile() } type CachePurgeParamsFilesCachePurgeURLAndHeaders struct { @@ -128,7 +128,7 @@ func (r CachePurgeParamsFilesCachePurgeURLAndHeaders) MarshalJSON() (data []byte return apijson.MarshalRoot(r) } -func (r CachePurgeParamsFilesCachePurgeURLAndHeaders) ImplementsCachePurgeParamsFile() {} +func (r CachePurgeParamsFilesCachePurgeURLAndHeaders) ImplementsCacheCachePurgeParamsFile() {} type CachePurgeResponseEnvelope struct { Errors []CachePurgeResponseEnvelopeErrors `json:"errors,required"` diff --git a/cache_test.go b/cache/cache_test.go similarity index 76% rename from cache_test.go rename to cache/cache_test.go index 62ebcb63a2b..98a40dea8a7 100644 --- a/cache_test.go +++ b/cache/cache_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package cache_test import ( "context" @@ -9,6 +9,7 @@ import ( "testing" "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/cache" "github.com/cloudflare/cloudflare-go/internal/shared" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" @@ -28,9 +29,9 @@ func TestCachePurgeWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Cache.Purge(context.TODO(), cloudflare.CachePurgeParams{ + _, err := client.Cache.Purge(context.TODO(), cache.CachePurgeParams{ ZoneID: cloudflare.F("string"), - Files: cloudflare.F([]cloudflare.CachePurgeParamsFile{shared.UnionString("http://www.example.com/css/styles.css"), shared.UnionString("http://www.example.com/css/styles.css"), shared.UnionString("http://www.example.com/css/styles.css")}), + Files: cloudflare.F([]cache.CachePurgeParamsFile{shared.UnionString("http://www.example.com/css/styles.css"), shared.UnionString("http://www.example.com/css/styles.css"), shared.UnionString("http://www.example.com/css/styles.css")}), Hosts: cloudflare.F([]string{"www.example.com", "images.example.com"}), Prefixes: cloudflare.F([]string{"www.example.com/foo", "images.example.com/bar/baz"}), PurgeEverything: cloudflare.F(true), diff --git a/cache/cachereserve.go b/cache/cachereserve.go new file mode 100644 index 00000000000..933c0bf0e52 --- /dev/null +++ b/cache/cachereserve.go @@ -0,0 +1,683 @@ +// File generated from our OpenAPI spec by Stainless. + +package cache + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// CacheReserveService 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 [NewCacheReserveService] method +// instead. +type CacheReserveService struct { + Options []option.RequestOption +} + +// NewCacheReserveService 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 NewCacheReserveService(opts ...option.RequestOption) (r *CacheReserveService) { + r = &CacheReserveService{} + r.Options = opts + return +} + +// You can use Cache Reserve Clear to clear your Cache Reserve, but you must first +// disable Cache Reserve. In most cases, this will be accomplished within 24 hours. +// You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind +// that you cannot undo or cancel this operation. +func (r *CacheReserveService) Clear(ctx context.Context, body CacheReserveClearParams, opts ...option.RequestOption) (res *CacheReserveClearResponse, err error) { + opts = append(r.Options[:], opts...) + var env CacheReserveClearResponseEnvelope + path := fmt.Sprintf("zones/%s/cache/cache_reserve_clear", body.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Increase cache lifetimes by automatically storing all cacheable files into +// Cloudflare's persistent object storage buckets. Requires Cache Reserve +// subscription. Note: using Tiered Cache with Cache Reserve is highly recommended +// to reduce Reserve operations costs. See the +// [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) +// for more information. +func (r *CacheReserveService) Edit(ctx context.Context, params CacheReserveEditParams, opts ...option.RequestOption) (res *CacheReserveEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env CacheReserveEditResponseEnvelope + path := fmt.Sprintf("zones/%s/cache/cache_reserve", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Increase cache lifetimes by automatically storing all cacheable files into +// Cloudflare's persistent object storage buckets. Requires Cache Reserve +// subscription. Note: using Tiered Cache with Cache Reserve is highly recommended +// to reduce Reserve operations costs. See the +// [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) +// for more information. +func (r *CacheReserveService) Get(ctx context.Context, query CacheReserveGetParams, opts ...option.RequestOption) (res *CacheReserveGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env CacheReserveGetResponseEnvelope + path := fmt.Sprintf("zones/%s/cache/cache_reserve", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// You can use Cache Reserve Clear to clear your Cache Reserve, but you must first +// disable Cache Reserve. In most cases, this will be accomplished within 24 hours. +// You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind +// that you cannot undo or cancel this operation. +func (r *CacheReserveService) Status(ctx context.Context, query CacheReserveStatusParams, opts ...option.RequestOption) (res *CacheReserveStatusResponse, err error) { + opts = append(r.Options[:], opts...) + var env CacheReserveStatusResponseEnvelope + path := fmt.Sprintf("zones/%s/cache/cache_reserve_clear", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// You can use Cache Reserve Clear to clear your Cache Reserve, but you must first +// disable Cache Reserve. In most cases, this will be accomplished within 24 hours. +// You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind +// that you cannot undo or cancel this operation. +type CacheReserveClearResponse struct { + // ID of the zone setting. + ID CacheReserveClearResponseID `json:"id,required"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` + // The time that the latest Cache Reserve Clear operation started. + StartTs time.Time `json:"start_ts,required" format:"date-time"` + // The current state of the Cache Reserve Clear operation. + State CacheReserveClearResponseState `json:"state,required"` + // The time that the latest Cache Reserve Clear operation completed. + EndTs time.Time `json:"end_ts" format:"date-time"` + JSON cacheReserveClearResponseJSON `json:"-"` +} + +// cacheReserveClearResponseJSON contains the JSON metadata for the struct +// [CacheReserveClearResponse] +type cacheReserveClearResponseJSON struct { + ID apijson.Field + ModifiedOn apijson.Field + StartTs apijson.Field + State apijson.Field + EndTs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CacheReserveClearResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cacheReserveClearResponseJSON) RawJSON() string { + return r.raw +} + +// ID of the zone setting. +type CacheReserveClearResponseID string + +const ( + CacheReserveClearResponseIDCacheReserveClear CacheReserveClearResponseID = "cache_reserve_clear" +) + +// The current state of the Cache Reserve Clear operation. +type CacheReserveClearResponseState string + +const ( + CacheReserveClearResponseStateInProgress CacheReserveClearResponseState = "In-progress" + CacheReserveClearResponseStateCompleted CacheReserveClearResponseState = "Completed" +) + +// Increase cache lifetimes by automatically storing all cacheable files into +// Cloudflare's persistent object storage buckets. Requires Cache Reserve +// subscription. Note: using Tiered Cache with Cache Reserve is highly recommended +// to reduce Reserve operations costs. See the +// [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) +// for more information. +type CacheReserveEditResponse struct { + // ID of the zone setting. + ID CacheReserveEditResponseID `json:"id,required"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` + // Value of the Cache Reserve zone setting. + Value CacheReserveEditResponseValue `json:"value,required"` + JSON cacheReserveEditResponseJSON `json:"-"` +} + +// cacheReserveEditResponseJSON contains the JSON metadata for the struct +// [CacheReserveEditResponse] +type cacheReserveEditResponseJSON struct { + ID apijson.Field + ModifiedOn apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CacheReserveEditResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cacheReserveEditResponseJSON) RawJSON() string { + return r.raw +} + +// ID of the zone setting. +type CacheReserveEditResponseID string + +const ( + CacheReserveEditResponseIDCacheReserve CacheReserveEditResponseID = "cache_reserve" +) + +// Value of the Cache Reserve zone setting. +type CacheReserveEditResponseValue string + +const ( + CacheReserveEditResponseValueOn CacheReserveEditResponseValue = "on" + CacheReserveEditResponseValueOff CacheReserveEditResponseValue = "off" +) + +// Increase cache lifetimes by automatically storing all cacheable files into +// Cloudflare's persistent object storage buckets. Requires Cache Reserve +// subscription. Note: using Tiered Cache with Cache Reserve is highly recommended +// to reduce Reserve operations costs. See the +// [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) +// for more information. +type CacheReserveGetResponse struct { + // ID of the zone setting. + ID CacheReserveGetResponseID `json:"id,required"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` + // Value of the Cache Reserve zone setting. + Value CacheReserveGetResponseValue `json:"value,required"` + JSON cacheReserveGetResponseJSON `json:"-"` +} + +// cacheReserveGetResponseJSON contains the JSON metadata for the struct +// [CacheReserveGetResponse] +type cacheReserveGetResponseJSON struct { + ID apijson.Field + ModifiedOn apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CacheReserveGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cacheReserveGetResponseJSON) RawJSON() string { + return r.raw +} + +// ID of the zone setting. +type CacheReserveGetResponseID string + +const ( + CacheReserveGetResponseIDCacheReserve CacheReserveGetResponseID = "cache_reserve" +) + +// Value of the Cache Reserve zone setting. +type CacheReserveGetResponseValue string + +const ( + CacheReserveGetResponseValueOn CacheReserveGetResponseValue = "on" + CacheReserveGetResponseValueOff CacheReserveGetResponseValue = "off" +) + +// You can use Cache Reserve Clear to clear your Cache Reserve, but you must first +// disable Cache Reserve. In most cases, this will be accomplished within 24 hours. +// You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind +// that you cannot undo or cancel this operation. +type CacheReserveStatusResponse struct { + // ID of the zone setting. + ID CacheReserveStatusResponseID `json:"id,required"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` + // The time that the latest Cache Reserve Clear operation started. + StartTs time.Time `json:"start_ts,required" format:"date-time"` + // The current state of the Cache Reserve Clear operation. + State CacheReserveStatusResponseState `json:"state,required"` + // The time that the latest Cache Reserve Clear operation completed. + EndTs time.Time `json:"end_ts" format:"date-time"` + JSON cacheReserveStatusResponseJSON `json:"-"` +} + +// cacheReserveStatusResponseJSON contains the JSON metadata for the struct +// [CacheReserveStatusResponse] +type cacheReserveStatusResponseJSON struct { + ID apijson.Field + ModifiedOn apijson.Field + StartTs apijson.Field + State apijson.Field + EndTs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CacheReserveStatusResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cacheReserveStatusResponseJSON) RawJSON() string { + return r.raw +} + +// ID of the zone setting. +type CacheReserveStatusResponseID string + +const ( + CacheReserveStatusResponseIDCacheReserveClear CacheReserveStatusResponseID = "cache_reserve_clear" +) + +// The current state of the Cache Reserve Clear operation. +type CacheReserveStatusResponseState string + +const ( + CacheReserveStatusResponseStateInProgress CacheReserveStatusResponseState = "In-progress" + CacheReserveStatusResponseStateCompleted CacheReserveStatusResponseState = "Completed" +) + +type CacheReserveClearParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type CacheReserveClearResponseEnvelope struct { + Errors []CacheReserveClearResponseEnvelopeErrors `json:"errors,required"` + Messages []CacheReserveClearResponseEnvelopeMessages `json:"messages,required"` + // You can use Cache Reserve Clear to clear your Cache Reserve, but you must first + // disable Cache Reserve. In most cases, this will be accomplished within 24 hours. + // You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind + // that you cannot undo or cancel this operation. + Result CacheReserveClearResponse `json:"result,required"` + // Whether the API call was successful + Success CacheReserveClearResponseEnvelopeSuccess `json:"success,required"` + JSON cacheReserveClearResponseEnvelopeJSON `json:"-"` +} + +// cacheReserveClearResponseEnvelopeJSON contains the JSON metadata for the struct +// [CacheReserveClearResponseEnvelope] +type cacheReserveClearResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CacheReserveClearResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cacheReserveClearResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CacheReserveClearResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON cacheReserveClearResponseEnvelopeErrorsJSON `json:"-"` +} + +// cacheReserveClearResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [CacheReserveClearResponseEnvelopeErrors] +type cacheReserveClearResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CacheReserveClearResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cacheReserveClearResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CacheReserveClearResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON cacheReserveClearResponseEnvelopeMessagesJSON `json:"-"` +} + +// cacheReserveClearResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [CacheReserveClearResponseEnvelopeMessages] +type cacheReserveClearResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CacheReserveClearResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cacheReserveClearResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CacheReserveClearResponseEnvelopeSuccess bool + +const ( + CacheReserveClearResponseEnvelopeSuccessTrue CacheReserveClearResponseEnvelopeSuccess = true +) + +type CacheReserveEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the Cache Reserve zone setting. + Value param.Field[CacheReserveEditParamsValue] `json:"value,required"` +} + +func (r CacheReserveEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the Cache Reserve zone setting. +type CacheReserveEditParamsValue string + +const ( + CacheReserveEditParamsValueOn CacheReserveEditParamsValue = "on" + CacheReserveEditParamsValueOff CacheReserveEditParamsValue = "off" +) + +type CacheReserveEditResponseEnvelope struct { + Errors []CacheReserveEditResponseEnvelopeErrors `json:"errors,required"` + Messages []CacheReserveEditResponseEnvelopeMessages `json:"messages,required"` + // Increase cache lifetimes by automatically storing all cacheable files into + // Cloudflare's persistent object storage buckets. Requires Cache Reserve + // subscription. Note: using Tiered Cache with Cache Reserve is highly recommended + // to reduce Reserve operations costs. See the + // [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) + // for more information. + Result CacheReserveEditResponse `json:"result,required"` + // Whether the API call was successful + Success CacheReserveEditResponseEnvelopeSuccess `json:"success,required"` + JSON cacheReserveEditResponseEnvelopeJSON `json:"-"` +} + +// cacheReserveEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [CacheReserveEditResponseEnvelope] +type cacheReserveEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CacheReserveEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cacheReserveEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CacheReserveEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON cacheReserveEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// cacheReserveEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [CacheReserveEditResponseEnvelopeErrors] +type cacheReserveEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CacheReserveEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cacheReserveEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CacheReserveEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON cacheReserveEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// cacheReserveEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [CacheReserveEditResponseEnvelopeMessages] +type cacheReserveEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CacheReserveEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cacheReserveEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CacheReserveEditResponseEnvelopeSuccess bool + +const ( + CacheReserveEditResponseEnvelopeSuccessTrue CacheReserveEditResponseEnvelopeSuccess = true +) + +type CacheReserveGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type CacheReserveGetResponseEnvelope struct { + Errors []CacheReserveGetResponseEnvelopeErrors `json:"errors,required"` + Messages []CacheReserveGetResponseEnvelopeMessages `json:"messages,required"` + // Increase cache lifetimes by automatically storing all cacheable files into + // Cloudflare's persistent object storage buckets. Requires Cache Reserve + // subscription. Note: using Tiered Cache with Cache Reserve is highly recommended + // to reduce Reserve operations costs. See the + // [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) + // for more information. + Result CacheReserveGetResponse `json:"result,required"` + // Whether the API call was successful + Success CacheReserveGetResponseEnvelopeSuccess `json:"success,required"` + JSON cacheReserveGetResponseEnvelopeJSON `json:"-"` +} + +// cacheReserveGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [CacheReserveGetResponseEnvelope] +type cacheReserveGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CacheReserveGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cacheReserveGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CacheReserveGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON cacheReserveGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// cacheReserveGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [CacheReserveGetResponseEnvelopeErrors] +type cacheReserveGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CacheReserveGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cacheReserveGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CacheReserveGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON cacheReserveGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// cacheReserveGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [CacheReserveGetResponseEnvelopeMessages] +type cacheReserveGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CacheReserveGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cacheReserveGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CacheReserveGetResponseEnvelopeSuccess bool + +const ( + CacheReserveGetResponseEnvelopeSuccessTrue CacheReserveGetResponseEnvelopeSuccess = true +) + +type CacheReserveStatusParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type CacheReserveStatusResponseEnvelope struct { + Errors []CacheReserveStatusResponseEnvelopeErrors `json:"errors,required"` + Messages []CacheReserveStatusResponseEnvelopeMessages `json:"messages,required"` + // You can use Cache Reserve Clear to clear your Cache Reserve, but you must first + // disable Cache Reserve. In most cases, this will be accomplished within 24 hours. + // You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind + // that you cannot undo or cancel this operation. + Result CacheReserveStatusResponse `json:"result,required"` + // Whether the API call was successful + Success CacheReserveStatusResponseEnvelopeSuccess `json:"success,required"` + JSON cacheReserveStatusResponseEnvelopeJSON `json:"-"` +} + +// cacheReserveStatusResponseEnvelopeJSON contains the JSON metadata for the struct +// [CacheReserveStatusResponseEnvelope] +type cacheReserveStatusResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CacheReserveStatusResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cacheReserveStatusResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CacheReserveStatusResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON cacheReserveStatusResponseEnvelopeErrorsJSON `json:"-"` +} + +// cacheReserveStatusResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [CacheReserveStatusResponseEnvelopeErrors] +type cacheReserveStatusResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CacheReserveStatusResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cacheReserveStatusResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CacheReserveStatusResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON cacheReserveStatusResponseEnvelopeMessagesJSON `json:"-"` +} + +// cacheReserveStatusResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [CacheReserveStatusResponseEnvelopeMessages] +type cacheReserveStatusResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CacheReserveStatusResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cacheReserveStatusResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CacheReserveStatusResponseEnvelopeSuccess bool + +const ( + CacheReserveStatusResponseEnvelopeSuccessTrue CacheReserveStatusResponseEnvelopeSuccess = true +) diff --git a/cache/cachereserve_test.go b/cache/cachereserve_test.go new file mode 100644 index 00000000000..c08861345de --- /dev/null +++ b/cache/cachereserve_test.go @@ -0,0 +1,120 @@ +// File generated from our OpenAPI spec by Stainless. + +package cache_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/cache" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestCacheReserveClear(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("user@example.com"), + ) + _, err := client.Cache.CacheReserve.Clear(context.TODO(), cache.CacheReserveClearParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestCacheReserveEdit(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("user@example.com"), + ) + _, err := client.Cache.CacheReserve.Edit(context.TODO(), cache.CacheReserveEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(cache.CacheReserveEditParamsValueOn), + }) + 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 TestCacheReserveGet(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("user@example.com"), + ) + _, err := client.Cache.CacheReserve.Get(context.TODO(), cache.CacheReserveGetParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestCacheReserveStatus(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("user@example.com"), + ) + _, err := client.Cache.CacheReserve.Status(context.TODO(), cache.CacheReserveStatusParams{ + ZoneID: cloudflare.F("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/cache/regionaltieredcache.go b/cache/regionaltieredcache.go new file mode 100644 index 00000000000..ac0e2ade56e --- /dev/null +++ b/cache/regionaltieredcache.go @@ -0,0 +1,405 @@ +// File generated from our OpenAPI spec by Stainless. + +package cache + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// RegionalTieredCacheService 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 [NewRegionalTieredCacheService] +// method instead. +type RegionalTieredCacheService struct { + Options []option.RequestOption +} + +// NewRegionalTieredCacheService 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 NewRegionalTieredCacheService(opts ...option.RequestOption) (r *RegionalTieredCacheService) { + r = &RegionalTieredCacheService{} + r.Options = opts + return +} + +// Instructs Cloudflare to check a regional hub data center on the way to your +// upper tier. This can help improve performance for smart and custom tiered cache +// topologies. +func (r *RegionalTieredCacheService) Edit(ctx context.Context, params RegionalTieredCacheEditParams, opts ...option.RequestOption) (res *RegionalTieredCacheEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env RegionalTieredCacheEditResponseEnvelope + path := fmt.Sprintf("zones/%s/cache/regional_tiered_cache", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Instructs Cloudflare to check a regional hub data center on the way to your +// upper tier. This can help improve performance for smart and custom tiered cache +// topologies. +func (r *RegionalTieredCacheService) Get(ctx context.Context, query RegionalTieredCacheGetParams, opts ...option.RequestOption) (res *RegionalTieredCacheGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RegionalTieredCacheGetResponseEnvelope + path := fmt.Sprintf("zones/%s/cache/regional_tiered_cache", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Instructs Cloudflare to check a regional hub data center on the way to your +// upper tier. This can help improve performance for smart and custom tiered cache +// topologies. +type RegionalTieredCacheEditResponse struct { + // ID of the zone setting. + ID RegionalTieredCacheEditResponseID `json:"id,required"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` + // Instructs Cloudflare to check a regional hub data center on the way to your + // upper tier. This can help improve performance for smart and custom tiered cache + // topologies. + Value RegionalTieredCacheEditResponseValue `json:"value,required"` + JSON regionalTieredCacheEditResponseJSON `json:"-"` +} + +// regionalTieredCacheEditResponseJSON contains the JSON metadata for the struct +// [RegionalTieredCacheEditResponse] +type regionalTieredCacheEditResponseJSON struct { + ID apijson.Field + ModifiedOn apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RegionalTieredCacheEditResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r regionalTieredCacheEditResponseJSON) RawJSON() string { + return r.raw +} + +// ID of the zone setting. +type RegionalTieredCacheEditResponseID string + +const ( + RegionalTieredCacheEditResponseIDTcRegional RegionalTieredCacheEditResponseID = "tc_regional" +) + +// Instructs Cloudflare to check a regional hub data center on the way to your +// upper tier. This can help improve performance for smart and custom tiered cache +// topologies. +type RegionalTieredCacheEditResponseValue struct { + // ID of the zone setting. + ID RegionalTieredCacheEditResponseValueID `json:"id,required"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` + JSON regionalTieredCacheEditResponseValueJSON `json:"-"` +} + +// regionalTieredCacheEditResponseValueJSON contains the JSON metadata for the +// struct [RegionalTieredCacheEditResponseValue] +type regionalTieredCacheEditResponseValueJSON struct { + ID apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RegionalTieredCacheEditResponseValue) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r regionalTieredCacheEditResponseValueJSON) RawJSON() string { + return r.raw +} + +// ID of the zone setting. +type RegionalTieredCacheEditResponseValueID string + +const ( + RegionalTieredCacheEditResponseValueIDTcRegional RegionalTieredCacheEditResponseValueID = "tc_regional" +) + +// Instructs Cloudflare to check a regional hub data center on the way to your +// upper tier. This can help improve performance for smart and custom tiered cache +// topologies. +type RegionalTieredCacheGetResponse struct { + // ID of the zone setting. + ID RegionalTieredCacheGetResponseID `json:"id,required"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` + // Instructs Cloudflare to check a regional hub data center on the way to your + // upper tier. This can help improve performance for smart and custom tiered cache + // topologies. + Value RegionalTieredCacheGetResponseValue `json:"value,required"` + JSON regionalTieredCacheGetResponseJSON `json:"-"` +} + +// regionalTieredCacheGetResponseJSON contains the JSON metadata for the struct +// [RegionalTieredCacheGetResponse] +type regionalTieredCacheGetResponseJSON struct { + ID apijson.Field + ModifiedOn apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RegionalTieredCacheGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r regionalTieredCacheGetResponseJSON) RawJSON() string { + return r.raw +} + +// ID of the zone setting. +type RegionalTieredCacheGetResponseID string + +const ( + RegionalTieredCacheGetResponseIDTcRegional RegionalTieredCacheGetResponseID = "tc_regional" +) + +// Instructs Cloudflare to check a regional hub data center on the way to your +// upper tier. This can help improve performance for smart and custom tiered cache +// topologies. +type RegionalTieredCacheGetResponseValue struct { + // ID of the zone setting. + ID RegionalTieredCacheGetResponseValueID `json:"id,required"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` + JSON regionalTieredCacheGetResponseValueJSON `json:"-"` +} + +// regionalTieredCacheGetResponseValueJSON contains the JSON metadata for the +// struct [RegionalTieredCacheGetResponseValue] +type regionalTieredCacheGetResponseValueJSON struct { + ID apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RegionalTieredCacheGetResponseValue) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r regionalTieredCacheGetResponseValueJSON) RawJSON() string { + return r.raw +} + +// ID of the zone setting. +type RegionalTieredCacheGetResponseValueID string + +const ( + RegionalTieredCacheGetResponseValueIDTcRegional RegionalTieredCacheGetResponseValueID = "tc_regional" +) + +type RegionalTieredCacheEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the Regional Tiered Cache zone setting. + Value param.Field[RegionalTieredCacheEditParamsValue] `json:"value,required"` +} + +func (r RegionalTieredCacheEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the Regional Tiered Cache zone setting. +type RegionalTieredCacheEditParamsValue string + +const ( + RegionalTieredCacheEditParamsValueOn RegionalTieredCacheEditParamsValue = "on" + RegionalTieredCacheEditParamsValueOff RegionalTieredCacheEditParamsValue = "off" +) + +type RegionalTieredCacheEditResponseEnvelope struct { + Errors []RegionalTieredCacheEditResponseEnvelopeErrors `json:"errors,required"` + Messages []RegionalTieredCacheEditResponseEnvelopeMessages `json:"messages,required"` + // Instructs Cloudflare to check a regional hub data center on the way to your + // upper tier. This can help improve performance for smart and custom tiered cache + // topologies. + Result RegionalTieredCacheEditResponse `json:"result,required"` + // Whether the API call was successful + Success RegionalTieredCacheEditResponseEnvelopeSuccess `json:"success,required"` + JSON regionalTieredCacheEditResponseEnvelopeJSON `json:"-"` +} + +// regionalTieredCacheEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [RegionalTieredCacheEditResponseEnvelope] +type regionalTieredCacheEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RegionalTieredCacheEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r regionalTieredCacheEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RegionalTieredCacheEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON regionalTieredCacheEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// regionalTieredCacheEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [RegionalTieredCacheEditResponseEnvelopeErrors] +type regionalTieredCacheEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RegionalTieredCacheEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r regionalTieredCacheEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RegionalTieredCacheEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON regionalTieredCacheEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// regionalTieredCacheEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [RegionalTieredCacheEditResponseEnvelopeMessages] +type regionalTieredCacheEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RegionalTieredCacheEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r regionalTieredCacheEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RegionalTieredCacheEditResponseEnvelopeSuccess bool + +const ( + RegionalTieredCacheEditResponseEnvelopeSuccessTrue RegionalTieredCacheEditResponseEnvelopeSuccess = true +) + +type RegionalTieredCacheGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type RegionalTieredCacheGetResponseEnvelope struct { + Errors []RegionalTieredCacheGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RegionalTieredCacheGetResponseEnvelopeMessages `json:"messages,required"` + // Instructs Cloudflare to check a regional hub data center on the way to your + // upper tier. This can help improve performance for smart and custom tiered cache + // topologies. + Result RegionalTieredCacheGetResponse `json:"result,required"` + // Whether the API call was successful + Success RegionalTieredCacheGetResponseEnvelopeSuccess `json:"success,required"` + JSON regionalTieredCacheGetResponseEnvelopeJSON `json:"-"` +} + +// regionalTieredCacheGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [RegionalTieredCacheGetResponseEnvelope] +type regionalTieredCacheGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RegionalTieredCacheGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r regionalTieredCacheGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RegionalTieredCacheGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON regionalTieredCacheGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// regionalTieredCacheGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [RegionalTieredCacheGetResponseEnvelopeErrors] +type regionalTieredCacheGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RegionalTieredCacheGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r regionalTieredCacheGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RegionalTieredCacheGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON regionalTieredCacheGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// regionalTieredCacheGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [RegionalTieredCacheGetResponseEnvelopeMessages] +type regionalTieredCacheGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RegionalTieredCacheGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r regionalTieredCacheGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RegionalTieredCacheGetResponseEnvelopeSuccess bool + +const ( + RegionalTieredCacheGetResponseEnvelopeSuccessTrue RegionalTieredCacheGetResponseEnvelopeSuccess = true +) diff --git a/cache/regionaltieredcache_test.go b/cache/regionaltieredcache_test.go new file mode 100644 index 00000000000..00cee364604 --- /dev/null +++ b/cache/regionaltieredcache_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package cache_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/cache" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRegionalTieredCacheEdit(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("user@example.com"), + ) + _, err := client.Cache.RegionalTieredCache.Edit(context.TODO(), cache.RegionalTieredCacheEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(cache.RegionalTieredCacheEditParamsValueOn), + }) + 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 TestRegionalTieredCacheGet(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("user@example.com"), + ) + _, err := client.Cache.RegionalTieredCache.Get(context.TODO(), cache.RegionalTieredCacheGetParams{ + ZoneID: cloudflare.F("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/cache/smarttieredcached.go b/cache/smarttieredcached.go new file mode 100644 index 00000000000..be5cc9b0a25 --- /dev/null +++ b/cache/smarttieredcached.go @@ -0,0 +1,397 @@ +// File generated from our OpenAPI spec by Stainless. + +package cache + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// SmartTieredCachedService 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 [NewSmartTieredCachedService] method +// instead. +type SmartTieredCachedService struct { + Options []option.RequestOption +} + +// NewSmartTieredCachedService 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 NewSmartTieredCachedService(opts ...option.RequestOption) (r *SmartTieredCachedService) { + r = &SmartTieredCachedService{} + r.Options = opts + return +} + +// Remvoves enablement of Smart Tiered Cache +func (r *SmartTieredCachedService) Delete(ctx context.Context, body SmartTieredCachedDeleteParams, opts ...option.RequestOption) (res *SmartTieredCachedDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env SmartTieredCachedDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/cache/tiered_cache_smart_topology_enable", body.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates enablement of Tiered Cache +func (r *SmartTieredCachedService) Edit(ctx context.Context, params SmartTieredCachedEditParams, opts ...option.RequestOption) (res *SmartTieredCachedEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env SmartTieredCachedEditResponseEnvelope + path := fmt.Sprintf("zones/%s/cache/tiered_cache_smart_topology_enable", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get Smart Tiered Cache setting +func (r *SmartTieredCachedService) Get(ctx context.Context, query SmartTieredCachedGetParams, opts ...option.RequestOption) (res *SmartTieredCachedGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env SmartTieredCachedGetResponseEnvelope + path := fmt.Sprintf("zones/%s/cache/tiered_cache_smart_topology_enable", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [cache.SmartTieredCachedDeleteResponseUnknown] or +// [shared.UnionString]. +type SmartTieredCachedDeleteResponse interface { + ImplementsCacheSmartTieredCachedDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*SmartTieredCachedDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [cache.SmartTieredCachedEditResponseUnknown] or +// [shared.UnionString]. +type SmartTieredCachedEditResponse interface { + ImplementsCacheSmartTieredCachedEditResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*SmartTieredCachedEditResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [cache.SmartTieredCachedGetResponseUnknown] or +// [shared.UnionString]. +type SmartTieredCachedGetResponse interface { + ImplementsCacheSmartTieredCachedGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*SmartTieredCachedGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type SmartTieredCachedDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SmartTieredCachedDeleteResponseEnvelope struct { + Errors []SmartTieredCachedDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []SmartTieredCachedDeleteResponseEnvelopeMessages `json:"messages,required"` + Result SmartTieredCachedDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success SmartTieredCachedDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON smartTieredCachedDeleteResponseEnvelopeJSON `json:"-"` +} + +// smartTieredCachedDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [SmartTieredCachedDeleteResponseEnvelope] +type smartTieredCachedDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SmartTieredCachedDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r smartTieredCachedDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SmartTieredCachedDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON smartTieredCachedDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// smartTieredCachedDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SmartTieredCachedDeleteResponseEnvelopeErrors] +type smartTieredCachedDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SmartTieredCachedDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r smartTieredCachedDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SmartTieredCachedDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON smartTieredCachedDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// smartTieredCachedDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SmartTieredCachedDeleteResponseEnvelopeMessages] +type smartTieredCachedDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SmartTieredCachedDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r smartTieredCachedDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SmartTieredCachedDeleteResponseEnvelopeSuccess bool + +const ( + SmartTieredCachedDeleteResponseEnvelopeSuccessTrue SmartTieredCachedDeleteResponseEnvelopeSuccess = true +) + +type SmartTieredCachedEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Enables Tiered Cache. + Value param.Field[SmartTieredCachedEditParamsValue] `json:"value,required"` +} + +func (r SmartTieredCachedEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enables Tiered Cache. +type SmartTieredCachedEditParamsValue string + +const ( + SmartTieredCachedEditParamsValueOn SmartTieredCachedEditParamsValue = "on" + SmartTieredCachedEditParamsValueOff SmartTieredCachedEditParamsValue = "off" +) + +type SmartTieredCachedEditResponseEnvelope struct { + Errors []SmartTieredCachedEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SmartTieredCachedEditResponseEnvelopeMessages `json:"messages,required"` + Result SmartTieredCachedEditResponse `json:"result,required"` + // Whether the API call was successful + Success SmartTieredCachedEditResponseEnvelopeSuccess `json:"success,required"` + JSON smartTieredCachedEditResponseEnvelopeJSON `json:"-"` +} + +// smartTieredCachedEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SmartTieredCachedEditResponseEnvelope] +type smartTieredCachedEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SmartTieredCachedEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r smartTieredCachedEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SmartTieredCachedEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON smartTieredCachedEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// smartTieredCachedEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SmartTieredCachedEditResponseEnvelopeErrors] +type smartTieredCachedEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SmartTieredCachedEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r smartTieredCachedEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SmartTieredCachedEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON smartTieredCachedEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// smartTieredCachedEditResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [SmartTieredCachedEditResponseEnvelopeMessages] +type smartTieredCachedEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SmartTieredCachedEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r smartTieredCachedEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SmartTieredCachedEditResponseEnvelopeSuccess bool + +const ( + SmartTieredCachedEditResponseEnvelopeSuccessTrue SmartTieredCachedEditResponseEnvelopeSuccess = true +) + +type SmartTieredCachedGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SmartTieredCachedGetResponseEnvelope struct { + Errors []SmartTieredCachedGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SmartTieredCachedGetResponseEnvelopeMessages `json:"messages,required"` + Result SmartTieredCachedGetResponse `json:"result,required"` + // Whether the API call was successful + Success SmartTieredCachedGetResponseEnvelopeSuccess `json:"success,required"` + JSON smartTieredCachedGetResponseEnvelopeJSON `json:"-"` +} + +// smartTieredCachedGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SmartTieredCachedGetResponseEnvelope] +type smartTieredCachedGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SmartTieredCachedGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r smartTieredCachedGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SmartTieredCachedGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON smartTieredCachedGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// smartTieredCachedGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SmartTieredCachedGetResponseEnvelopeErrors] +type smartTieredCachedGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SmartTieredCachedGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r smartTieredCachedGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SmartTieredCachedGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON smartTieredCachedGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// smartTieredCachedGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [SmartTieredCachedGetResponseEnvelopeMessages] +type smartTieredCachedGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SmartTieredCachedGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r smartTieredCachedGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SmartTieredCachedGetResponseEnvelopeSuccess bool + +const ( + SmartTieredCachedGetResponseEnvelopeSuccessTrue SmartTieredCachedGetResponseEnvelopeSuccess = true +) diff --git a/cache/smarttieredcached_test.go b/cache/smarttieredcached_test.go new file mode 100644 index 00000000000..45cafafd6e4 --- /dev/null +++ b/cache/smarttieredcached_test.go @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package cache_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/cache" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestSmartTieredCachedDelete(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("user@example.com"), + ) + _, err := client.Cache.SmartTieredCached.Delete(context.TODO(), cache.SmartTieredCachedDeleteParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestSmartTieredCachedEdit(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("user@example.com"), + ) + _, err := client.Cache.SmartTieredCached.Edit(context.TODO(), cache.SmartTieredCachedEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(cache.SmartTieredCachedEditParamsValueOn), + }) + 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 TestSmartTieredCachedGet(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("user@example.com"), + ) + _, err := client.Cache.SmartTieredCached.Get(context.TODO(), cache.SmartTieredCachedGetParams{ + ZoneID: cloudflare.F("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/cache/variant.go b/cache/variant.go new file mode 100644 index 00000000000..7990520c43e --- /dev/null +++ b/cache/variant.go @@ -0,0 +1,647 @@ +// File generated from our OpenAPI spec by Stainless. + +package cache + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// VariantService 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 [NewVariantService] method instead. +type VariantService struct { + Options []option.RequestOption +} + +// NewVariantService 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 NewVariantService(opts ...option.RequestOption) (r *VariantService) { + r = &VariantService{} + r.Options = opts + return +} + +// Variant support enables caching variants of images with certain file extensions +// in addition to the original. This only applies when the origin server sends the +// 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but +// does not serve the variant requested, the response will not be cached. This will +// be indicated with BYPASS cache status in the response headers. +func (r *VariantService) Delete(ctx context.Context, body VariantDeleteParams, opts ...option.RequestOption) (res *CacheVariants, err error) { + opts = append(r.Options[:], opts...) + var env VariantDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/cache/variants", body.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Variant support enables caching variants of images with certain file extensions +// in addition to the original. This only applies when the origin server sends the +// 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but +// does not serve the variant requested, the response will not be cached. This will +// be indicated with BYPASS cache status in the response headers. +func (r *VariantService) Edit(ctx context.Context, params VariantEditParams, opts ...option.RequestOption) (res *VariantEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env VariantEditResponseEnvelope + path := fmt.Sprintf("zones/%s/cache/variants", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Variant support enables caching variants of images with certain file extensions +// in addition to the original. This only applies when the origin server sends the +// 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but +// does not serve the variant requested, the response will not be cached. This will +// be indicated with BYPASS cache status in the response headers. +func (r *VariantService) Get(ctx context.Context, query VariantGetParams, opts ...option.RequestOption) (res *VariantGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env VariantGetResponseEnvelope + path := fmt.Sprintf("zones/%s/cache/variants", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Variant support enables caching variants of images with certain file extensions +// in addition to the original. This only applies when the origin server sends the +// 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but +// does not serve the variant requested, the response will not be cached. This will +// be indicated with BYPASS cache status in the response headers. +type CacheVariants struct { + // ID of the zone setting. + ID CacheVariantsID `json:"id,required"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` + JSON cacheVariantsJSON `json:"-"` +} + +// cacheVariantsJSON contains the JSON metadata for the struct [CacheVariants] +type cacheVariantsJSON struct { + ID apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CacheVariants) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cacheVariantsJSON) RawJSON() string { + return r.raw +} + +// ID of the zone setting. +type CacheVariantsID string + +const ( + CacheVariantsIDVariants CacheVariantsID = "variants" +) + +// Variant support enables caching variants of images with certain file extensions +// in addition to the original. This only applies when the origin server sends the +// 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but +// does not serve the variant requested, the response will not be cached. This will +// be indicated with BYPASS cache status in the response headers. +type VariantEditResponse struct { + // ID of the zone setting. + ID VariantEditResponseID `json:"id,required"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` + // Value of the zone setting. + Value VariantEditResponseValue `json:"value,required"` + JSON variantEditResponseJSON `json:"-"` +} + +// variantEditResponseJSON contains the JSON metadata for the struct +// [VariantEditResponse] +type variantEditResponseJSON struct { + ID apijson.Field + ModifiedOn apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VariantEditResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r variantEditResponseJSON) RawJSON() string { + return r.raw +} + +// ID of the zone setting. +type VariantEditResponseID string + +const ( + VariantEditResponseIDVariants VariantEditResponseID = "variants" +) + +// Value of the zone setting. +type VariantEditResponseValue struct { + // List of strings with the MIME types of all the variants that should be served + // for avif. + Avif []interface{} `json:"avif"` + // List of strings with the MIME types of all the variants that should be served + // for bmp. + Bmp []interface{} `json:"bmp"` + // List of strings with the MIME types of all the variants that should be served + // for gif. + Gif []interface{} `json:"gif"` + // List of strings with the MIME types of all the variants that should be served + // for jp2. + Jp2 []interface{} `json:"jp2"` + // List of strings with the MIME types of all the variants that should be served + // for jpeg. + Jpeg []interface{} `json:"jpeg"` + // List of strings with the MIME types of all the variants that should be served + // for jpg. + Jpg []interface{} `json:"jpg"` + // List of strings with the MIME types of all the variants that should be served + // for jpg2. + Jpg2 []interface{} `json:"jpg2"` + // List of strings with the MIME types of all the variants that should be served + // for png. + Png []interface{} `json:"png"` + // List of strings with the MIME types of all the variants that should be served + // for tif. + Tif []interface{} `json:"tif"` + // List of strings with the MIME types of all the variants that should be served + // for tiff. + Tiff []interface{} `json:"tiff"` + // List of strings with the MIME types of all the variants that should be served + // for webp. + Webp []interface{} `json:"webp"` + JSON variantEditResponseValueJSON `json:"-"` +} + +// variantEditResponseValueJSON contains the JSON metadata for the struct +// [VariantEditResponseValue] +type variantEditResponseValueJSON struct { + Avif apijson.Field + Bmp apijson.Field + Gif apijson.Field + Jp2 apijson.Field + Jpeg apijson.Field + Jpg apijson.Field + Jpg2 apijson.Field + Png apijson.Field + Tif apijson.Field + Tiff apijson.Field + Webp apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VariantEditResponseValue) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r variantEditResponseValueJSON) RawJSON() string { + return r.raw +} + +// Variant support enables caching variants of images with certain file extensions +// in addition to the original. This only applies when the origin server sends the +// 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but +// does not serve the variant requested, the response will not be cached. This will +// be indicated with BYPASS cache status in the response headers. +type VariantGetResponse struct { + // ID of the zone setting. + ID VariantGetResponseID `json:"id,required"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` + // Value of the zone setting. + Value VariantGetResponseValue `json:"value,required"` + JSON variantGetResponseJSON `json:"-"` +} + +// variantGetResponseJSON contains the JSON metadata for the struct +// [VariantGetResponse] +type variantGetResponseJSON struct { + ID apijson.Field + ModifiedOn apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VariantGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r variantGetResponseJSON) RawJSON() string { + return r.raw +} + +// ID of the zone setting. +type VariantGetResponseID string + +const ( + VariantGetResponseIDVariants VariantGetResponseID = "variants" +) + +// Value of the zone setting. +type VariantGetResponseValue struct { + // List of strings with the MIME types of all the variants that should be served + // for avif. + Avif []interface{} `json:"avif"` + // List of strings with the MIME types of all the variants that should be served + // for bmp. + Bmp []interface{} `json:"bmp"` + // List of strings with the MIME types of all the variants that should be served + // for gif. + Gif []interface{} `json:"gif"` + // List of strings with the MIME types of all the variants that should be served + // for jp2. + Jp2 []interface{} `json:"jp2"` + // List of strings with the MIME types of all the variants that should be served + // for jpeg. + Jpeg []interface{} `json:"jpeg"` + // List of strings with the MIME types of all the variants that should be served + // for jpg. + Jpg []interface{} `json:"jpg"` + // List of strings with the MIME types of all the variants that should be served + // for jpg2. + Jpg2 []interface{} `json:"jpg2"` + // List of strings with the MIME types of all the variants that should be served + // for png. + Png []interface{} `json:"png"` + // List of strings with the MIME types of all the variants that should be served + // for tif. + Tif []interface{} `json:"tif"` + // List of strings with the MIME types of all the variants that should be served + // for tiff. + Tiff []interface{} `json:"tiff"` + // List of strings with the MIME types of all the variants that should be served + // for webp. + Webp []interface{} `json:"webp"` + JSON variantGetResponseValueJSON `json:"-"` +} + +// variantGetResponseValueJSON contains the JSON metadata for the struct +// [VariantGetResponseValue] +type variantGetResponseValueJSON struct { + Avif apijson.Field + Bmp apijson.Field + Gif apijson.Field + Jp2 apijson.Field + Jpeg apijson.Field + Jpg apijson.Field + Jpg2 apijson.Field + Png apijson.Field + Tif apijson.Field + Tiff apijson.Field + Webp apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VariantGetResponseValue) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r variantGetResponseValueJSON) RawJSON() string { + return r.raw +} + +type VariantDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type VariantDeleteResponseEnvelope struct { + Errors []VariantDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []VariantDeleteResponseEnvelopeMessages `json:"messages,required"` + // Variant support enables caching variants of images with certain file extensions + // in addition to the original. This only applies when the origin server sends the + // 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but + // does not serve the variant requested, the response will not be cached. This will + // be indicated with BYPASS cache status in the response headers. + Result CacheVariants `json:"result,required"` + // Whether the API call was successful + Success VariantDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON variantDeleteResponseEnvelopeJSON `json:"-"` +} + +// variantDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [VariantDeleteResponseEnvelope] +type variantDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VariantDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r variantDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type VariantDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON variantDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// variantDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [VariantDeleteResponseEnvelopeErrors] +type variantDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VariantDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r variantDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type VariantDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON variantDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// variantDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [VariantDeleteResponseEnvelopeMessages] +type variantDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VariantDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r variantDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type VariantDeleteResponseEnvelopeSuccess bool + +const ( + VariantDeleteResponseEnvelopeSuccessTrue VariantDeleteResponseEnvelopeSuccess = true +) + +type VariantEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[VariantEditParamsValue] `json:"value,required"` +} + +func (r VariantEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type VariantEditParamsValue struct { + // List of strings with the MIME types of all the variants that should be served + // for avif. + Avif param.Field[[]interface{}] `json:"avif"` + // List of strings with the MIME types of all the variants that should be served + // for bmp. + Bmp param.Field[[]interface{}] `json:"bmp"` + // List of strings with the MIME types of all the variants that should be served + // for gif. + Gif param.Field[[]interface{}] `json:"gif"` + // List of strings with the MIME types of all the variants that should be served + // for jp2. + Jp2 param.Field[[]interface{}] `json:"jp2"` + // List of strings with the MIME types of all the variants that should be served + // for jpeg. + Jpeg param.Field[[]interface{}] `json:"jpeg"` + // List of strings with the MIME types of all the variants that should be served + // for jpg. + Jpg param.Field[[]interface{}] `json:"jpg"` + // List of strings with the MIME types of all the variants that should be served + // for jpg2. + Jpg2 param.Field[[]interface{}] `json:"jpg2"` + // List of strings with the MIME types of all the variants that should be served + // for png. + Png param.Field[[]interface{}] `json:"png"` + // List of strings with the MIME types of all the variants that should be served + // for tif. + Tif param.Field[[]interface{}] `json:"tif"` + // List of strings with the MIME types of all the variants that should be served + // for tiff. + Tiff param.Field[[]interface{}] `json:"tiff"` + // List of strings with the MIME types of all the variants that should be served + // for webp. + Webp param.Field[[]interface{}] `json:"webp"` +} + +func (r VariantEditParamsValue) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type VariantEditResponseEnvelope struct { + Errors []VariantEditResponseEnvelopeErrors `json:"errors,required"` + Messages []VariantEditResponseEnvelopeMessages `json:"messages,required"` + // Variant support enables caching variants of images with certain file extensions + // in addition to the original. This only applies when the origin server sends the + // 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but + // does not serve the variant requested, the response will not be cached. This will + // be indicated with BYPASS cache status in the response headers. + Result VariantEditResponse `json:"result,required"` + // Whether the API call was successful + Success VariantEditResponseEnvelopeSuccess `json:"success,required"` + JSON variantEditResponseEnvelopeJSON `json:"-"` +} + +// variantEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [VariantEditResponseEnvelope] +type variantEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VariantEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r variantEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type VariantEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON variantEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// variantEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [VariantEditResponseEnvelopeErrors] +type variantEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VariantEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r variantEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type VariantEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON variantEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// variantEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [VariantEditResponseEnvelopeMessages] +type variantEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VariantEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r variantEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type VariantEditResponseEnvelopeSuccess bool + +const ( + VariantEditResponseEnvelopeSuccessTrue VariantEditResponseEnvelopeSuccess = true +) + +type VariantGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type VariantGetResponseEnvelope struct { + Errors []VariantGetResponseEnvelopeErrors `json:"errors,required"` + Messages []VariantGetResponseEnvelopeMessages `json:"messages,required"` + // Variant support enables caching variants of images with certain file extensions + // in addition to the original. This only applies when the origin server sends the + // 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but + // does not serve the variant requested, the response will not be cached. This will + // be indicated with BYPASS cache status in the response headers. + Result VariantGetResponse `json:"result,required"` + // Whether the API call was successful + Success VariantGetResponseEnvelopeSuccess `json:"success,required"` + JSON variantGetResponseEnvelopeJSON `json:"-"` +} + +// variantGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [VariantGetResponseEnvelope] +type variantGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VariantGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r variantGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type VariantGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON variantGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// variantGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [VariantGetResponseEnvelopeErrors] +type variantGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VariantGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r variantGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type VariantGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON variantGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// variantGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [VariantGetResponseEnvelopeMessages] +type variantGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VariantGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r variantGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type VariantGetResponseEnvelopeSuccess bool + +const ( + VariantGetResponseEnvelopeSuccessTrue VariantGetResponseEnvelopeSuccess = true +) diff --git a/cache/variant_test.go b/cache/variant_test.go new file mode 100644 index 00000000000..14d9915c8fd --- /dev/null +++ b/cache/variant_test.go @@ -0,0 +1,106 @@ +// File generated from our OpenAPI spec by Stainless. + +package cache_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/cache" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestVariantDelete(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("user@example.com"), + ) + _, err := client.Cache.Variants.Delete(context.TODO(), cache.VariantDeleteParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestVariantEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Cache.Variants.Edit(context.TODO(), cache.VariantEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(cache.VariantEditParamsValue{ + Avif: cloudflare.F([]interface{}{"image/webp", "image/jpeg"}), + Bmp: cloudflare.F([]interface{}{"image/webp", "image/jpeg"}), + Gif: cloudflare.F([]interface{}{"image/webp", "image/jpeg"}), + Jp2: cloudflare.F([]interface{}{"image/webp", "image/avif"}), + Jpeg: cloudflare.F([]interface{}{"image/webp", "image/avif"}), + Jpg: cloudflare.F([]interface{}{"image/webp", "image/avif"}), + Jpg2: cloudflare.F([]interface{}{"image/webp", "image/avif"}), + Png: cloudflare.F([]interface{}{"image/webp", "image/avif"}), + Tif: cloudflare.F([]interface{}{"image/webp", "image/avif"}), + Tiff: cloudflare.F([]interface{}{"image/webp", "image/avif"}), + Webp: cloudflare.F([]interface{}{"image/jpeg", "image/avif"}), + }), + }) + 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 TestVariantGet(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("user@example.com"), + ) + _, err := client.Cache.Variants.Get(context.TODO(), cache.VariantGetParams{ + ZoneID: cloudflare.F("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/cachecachereserve.go b/cachecachereserve.go deleted file mode 100644 index f3c6c52f4fa..00000000000 --- a/cachecachereserve.go +++ /dev/null @@ -1,683 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// CacheCacheReserveService 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 [NewCacheCacheReserveService] method -// instead. -type CacheCacheReserveService struct { - Options []option.RequestOption -} - -// NewCacheCacheReserveService 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 NewCacheCacheReserveService(opts ...option.RequestOption) (r *CacheCacheReserveService) { - r = &CacheCacheReserveService{} - r.Options = opts - return -} - -// You can use Cache Reserve Clear to clear your Cache Reserve, but you must first -// disable Cache Reserve. In most cases, this will be accomplished within 24 hours. -// You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind -// that you cannot undo or cancel this operation. -func (r *CacheCacheReserveService) Clear(ctx context.Context, body CacheCacheReserveClearParams, opts ...option.RequestOption) (res *CacheCacheReserveClearResponse, err error) { - opts = append(r.Options[:], opts...) - var env CacheCacheReserveClearResponseEnvelope - path := fmt.Sprintf("zones/%s/cache/cache_reserve_clear", body.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Increase cache lifetimes by automatically storing all cacheable files into -// Cloudflare's persistent object storage buckets. Requires Cache Reserve -// subscription. Note: using Tiered Cache with Cache Reserve is highly recommended -// to reduce Reserve operations costs. See the -// [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) -// for more information. -func (r *CacheCacheReserveService) Edit(ctx context.Context, params CacheCacheReserveEditParams, opts ...option.RequestOption) (res *CacheCacheReserveEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env CacheCacheReserveEditResponseEnvelope - path := fmt.Sprintf("zones/%s/cache/cache_reserve", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Increase cache lifetimes by automatically storing all cacheable files into -// Cloudflare's persistent object storage buckets. Requires Cache Reserve -// subscription. Note: using Tiered Cache with Cache Reserve is highly recommended -// to reduce Reserve operations costs. See the -// [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) -// for more information. -func (r *CacheCacheReserveService) Get(ctx context.Context, query CacheCacheReserveGetParams, opts ...option.RequestOption) (res *CacheCacheReserveGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env CacheCacheReserveGetResponseEnvelope - path := fmt.Sprintf("zones/%s/cache/cache_reserve", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// You can use Cache Reserve Clear to clear your Cache Reserve, but you must first -// disable Cache Reserve. In most cases, this will be accomplished within 24 hours. -// You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind -// that you cannot undo or cancel this operation. -func (r *CacheCacheReserveService) Status(ctx context.Context, query CacheCacheReserveStatusParams, opts ...option.RequestOption) (res *CacheCacheReserveStatusResponse, err error) { - opts = append(r.Options[:], opts...) - var env CacheCacheReserveStatusResponseEnvelope - path := fmt.Sprintf("zones/%s/cache/cache_reserve_clear", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// You can use Cache Reserve Clear to clear your Cache Reserve, but you must first -// disable Cache Reserve. In most cases, this will be accomplished within 24 hours. -// You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind -// that you cannot undo or cancel this operation. -type CacheCacheReserveClearResponse struct { - // ID of the zone setting. - ID CacheCacheReserveClearResponseID `json:"id,required"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` - // The time that the latest Cache Reserve Clear operation started. - StartTs time.Time `json:"start_ts,required" format:"date-time"` - // The current state of the Cache Reserve Clear operation. - State CacheCacheReserveClearResponseState `json:"state,required"` - // The time that the latest Cache Reserve Clear operation completed. - EndTs time.Time `json:"end_ts" format:"date-time"` - JSON cacheCacheReserveClearResponseJSON `json:"-"` -} - -// cacheCacheReserveClearResponseJSON contains the JSON metadata for the struct -// [CacheCacheReserveClearResponse] -type cacheCacheReserveClearResponseJSON struct { - ID apijson.Field - ModifiedOn apijson.Field - StartTs apijson.Field - State apijson.Field - EndTs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheCacheReserveClearResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheCacheReserveClearResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type CacheCacheReserveClearResponseID string - -const ( - CacheCacheReserveClearResponseIDCacheReserveClear CacheCacheReserveClearResponseID = "cache_reserve_clear" -) - -// The current state of the Cache Reserve Clear operation. -type CacheCacheReserveClearResponseState string - -const ( - CacheCacheReserveClearResponseStateInProgress CacheCacheReserveClearResponseState = "In-progress" - CacheCacheReserveClearResponseStateCompleted CacheCacheReserveClearResponseState = "Completed" -) - -// Increase cache lifetimes by automatically storing all cacheable files into -// Cloudflare's persistent object storage buckets. Requires Cache Reserve -// subscription. Note: using Tiered Cache with Cache Reserve is highly recommended -// to reduce Reserve operations costs. See the -// [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) -// for more information. -type CacheCacheReserveEditResponse struct { - // ID of the zone setting. - ID CacheCacheReserveEditResponseID `json:"id,required"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` - // Value of the Cache Reserve zone setting. - Value CacheCacheReserveEditResponseValue `json:"value,required"` - JSON cacheCacheReserveEditResponseJSON `json:"-"` -} - -// cacheCacheReserveEditResponseJSON contains the JSON metadata for the struct -// [CacheCacheReserveEditResponse] -type cacheCacheReserveEditResponseJSON struct { - ID apijson.Field - ModifiedOn apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheCacheReserveEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheCacheReserveEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type CacheCacheReserveEditResponseID string - -const ( - CacheCacheReserveEditResponseIDCacheReserve CacheCacheReserveEditResponseID = "cache_reserve" -) - -// Value of the Cache Reserve zone setting. -type CacheCacheReserveEditResponseValue string - -const ( - CacheCacheReserveEditResponseValueOn CacheCacheReserveEditResponseValue = "on" - CacheCacheReserveEditResponseValueOff CacheCacheReserveEditResponseValue = "off" -) - -// Increase cache lifetimes by automatically storing all cacheable files into -// Cloudflare's persistent object storage buckets. Requires Cache Reserve -// subscription. Note: using Tiered Cache with Cache Reserve is highly recommended -// to reduce Reserve operations costs. See the -// [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) -// for more information. -type CacheCacheReserveGetResponse struct { - // ID of the zone setting. - ID CacheCacheReserveGetResponseID `json:"id,required"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` - // Value of the Cache Reserve zone setting. - Value CacheCacheReserveGetResponseValue `json:"value,required"` - JSON cacheCacheReserveGetResponseJSON `json:"-"` -} - -// cacheCacheReserveGetResponseJSON contains the JSON metadata for the struct -// [CacheCacheReserveGetResponse] -type cacheCacheReserveGetResponseJSON struct { - ID apijson.Field - ModifiedOn apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheCacheReserveGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheCacheReserveGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type CacheCacheReserveGetResponseID string - -const ( - CacheCacheReserveGetResponseIDCacheReserve CacheCacheReserveGetResponseID = "cache_reserve" -) - -// Value of the Cache Reserve zone setting. -type CacheCacheReserveGetResponseValue string - -const ( - CacheCacheReserveGetResponseValueOn CacheCacheReserveGetResponseValue = "on" - CacheCacheReserveGetResponseValueOff CacheCacheReserveGetResponseValue = "off" -) - -// You can use Cache Reserve Clear to clear your Cache Reserve, but you must first -// disable Cache Reserve. In most cases, this will be accomplished within 24 hours. -// You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind -// that you cannot undo or cancel this operation. -type CacheCacheReserveStatusResponse struct { - // ID of the zone setting. - ID CacheCacheReserveStatusResponseID `json:"id,required"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` - // The time that the latest Cache Reserve Clear operation started. - StartTs time.Time `json:"start_ts,required" format:"date-time"` - // The current state of the Cache Reserve Clear operation. - State CacheCacheReserveStatusResponseState `json:"state,required"` - // The time that the latest Cache Reserve Clear operation completed. - EndTs time.Time `json:"end_ts" format:"date-time"` - JSON cacheCacheReserveStatusResponseJSON `json:"-"` -} - -// cacheCacheReserveStatusResponseJSON contains the JSON metadata for the struct -// [CacheCacheReserveStatusResponse] -type cacheCacheReserveStatusResponseJSON struct { - ID apijson.Field - ModifiedOn apijson.Field - StartTs apijson.Field - State apijson.Field - EndTs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheCacheReserveStatusResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheCacheReserveStatusResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type CacheCacheReserveStatusResponseID string - -const ( - CacheCacheReserveStatusResponseIDCacheReserveClear CacheCacheReserveStatusResponseID = "cache_reserve_clear" -) - -// The current state of the Cache Reserve Clear operation. -type CacheCacheReserveStatusResponseState string - -const ( - CacheCacheReserveStatusResponseStateInProgress CacheCacheReserveStatusResponseState = "In-progress" - CacheCacheReserveStatusResponseStateCompleted CacheCacheReserveStatusResponseState = "Completed" -) - -type CacheCacheReserveClearParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type CacheCacheReserveClearResponseEnvelope struct { - Errors []CacheCacheReserveClearResponseEnvelopeErrors `json:"errors,required"` - Messages []CacheCacheReserveClearResponseEnvelopeMessages `json:"messages,required"` - // You can use Cache Reserve Clear to clear your Cache Reserve, but you must first - // disable Cache Reserve. In most cases, this will be accomplished within 24 hours. - // You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind - // that you cannot undo or cancel this operation. - Result CacheCacheReserveClearResponse `json:"result,required"` - // Whether the API call was successful - Success CacheCacheReserveClearResponseEnvelopeSuccess `json:"success,required"` - JSON cacheCacheReserveClearResponseEnvelopeJSON `json:"-"` -} - -// cacheCacheReserveClearResponseEnvelopeJSON contains the JSON metadata for the -// struct [CacheCacheReserveClearResponseEnvelope] -type cacheCacheReserveClearResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheCacheReserveClearResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheCacheReserveClearResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CacheCacheReserveClearResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheCacheReserveClearResponseEnvelopeErrorsJSON `json:"-"` -} - -// cacheCacheReserveClearResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CacheCacheReserveClearResponseEnvelopeErrors] -type cacheCacheReserveClearResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheCacheReserveClearResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheCacheReserveClearResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CacheCacheReserveClearResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheCacheReserveClearResponseEnvelopeMessagesJSON `json:"-"` -} - -// cacheCacheReserveClearResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [CacheCacheReserveClearResponseEnvelopeMessages] -type cacheCacheReserveClearResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheCacheReserveClearResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheCacheReserveClearResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CacheCacheReserveClearResponseEnvelopeSuccess bool - -const ( - CacheCacheReserveClearResponseEnvelopeSuccessTrue CacheCacheReserveClearResponseEnvelopeSuccess = true -) - -type CacheCacheReserveEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the Cache Reserve zone setting. - Value param.Field[CacheCacheReserveEditParamsValue] `json:"value,required"` -} - -func (r CacheCacheReserveEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the Cache Reserve zone setting. -type CacheCacheReserveEditParamsValue string - -const ( - CacheCacheReserveEditParamsValueOn CacheCacheReserveEditParamsValue = "on" - CacheCacheReserveEditParamsValueOff CacheCacheReserveEditParamsValue = "off" -) - -type CacheCacheReserveEditResponseEnvelope struct { - Errors []CacheCacheReserveEditResponseEnvelopeErrors `json:"errors,required"` - Messages []CacheCacheReserveEditResponseEnvelopeMessages `json:"messages,required"` - // Increase cache lifetimes by automatically storing all cacheable files into - // Cloudflare's persistent object storage buckets. Requires Cache Reserve - // subscription. Note: using Tiered Cache with Cache Reserve is highly recommended - // to reduce Reserve operations costs. See the - // [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) - // for more information. - Result CacheCacheReserveEditResponse `json:"result,required"` - // Whether the API call was successful - Success CacheCacheReserveEditResponseEnvelopeSuccess `json:"success,required"` - JSON cacheCacheReserveEditResponseEnvelopeJSON `json:"-"` -} - -// cacheCacheReserveEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [CacheCacheReserveEditResponseEnvelope] -type cacheCacheReserveEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheCacheReserveEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheCacheReserveEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CacheCacheReserveEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheCacheReserveEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// cacheCacheReserveEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CacheCacheReserveEditResponseEnvelopeErrors] -type cacheCacheReserveEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheCacheReserveEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheCacheReserveEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CacheCacheReserveEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheCacheReserveEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// cacheCacheReserveEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [CacheCacheReserveEditResponseEnvelopeMessages] -type cacheCacheReserveEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheCacheReserveEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheCacheReserveEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CacheCacheReserveEditResponseEnvelopeSuccess bool - -const ( - CacheCacheReserveEditResponseEnvelopeSuccessTrue CacheCacheReserveEditResponseEnvelopeSuccess = true -) - -type CacheCacheReserveGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type CacheCacheReserveGetResponseEnvelope struct { - Errors []CacheCacheReserveGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CacheCacheReserveGetResponseEnvelopeMessages `json:"messages,required"` - // Increase cache lifetimes by automatically storing all cacheable files into - // Cloudflare's persistent object storage buckets. Requires Cache Reserve - // subscription. Note: using Tiered Cache with Cache Reserve is highly recommended - // to reduce Reserve operations costs. See the - // [developer docs](https://developers.cloudflare.com/cache/about/cache-reserve) - // for more information. - Result CacheCacheReserveGetResponse `json:"result,required"` - // Whether the API call was successful - Success CacheCacheReserveGetResponseEnvelopeSuccess `json:"success,required"` - JSON cacheCacheReserveGetResponseEnvelopeJSON `json:"-"` -} - -// cacheCacheReserveGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [CacheCacheReserveGetResponseEnvelope] -type cacheCacheReserveGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheCacheReserveGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheCacheReserveGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CacheCacheReserveGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheCacheReserveGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// cacheCacheReserveGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CacheCacheReserveGetResponseEnvelopeErrors] -type cacheCacheReserveGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheCacheReserveGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheCacheReserveGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CacheCacheReserveGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheCacheReserveGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// cacheCacheReserveGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [CacheCacheReserveGetResponseEnvelopeMessages] -type cacheCacheReserveGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheCacheReserveGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheCacheReserveGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CacheCacheReserveGetResponseEnvelopeSuccess bool - -const ( - CacheCacheReserveGetResponseEnvelopeSuccessTrue CacheCacheReserveGetResponseEnvelopeSuccess = true -) - -type CacheCacheReserveStatusParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type CacheCacheReserveStatusResponseEnvelope struct { - Errors []CacheCacheReserveStatusResponseEnvelopeErrors `json:"errors,required"` - Messages []CacheCacheReserveStatusResponseEnvelopeMessages `json:"messages,required"` - // You can use Cache Reserve Clear to clear your Cache Reserve, but you must first - // disable Cache Reserve. In most cases, this will be accomplished within 24 hours. - // You cannot re-enable Cache Reserve while this process is ongoing. Keep in mind - // that you cannot undo or cancel this operation. - Result CacheCacheReserveStatusResponse `json:"result,required"` - // Whether the API call was successful - Success CacheCacheReserveStatusResponseEnvelopeSuccess `json:"success,required"` - JSON cacheCacheReserveStatusResponseEnvelopeJSON `json:"-"` -} - -// cacheCacheReserveStatusResponseEnvelopeJSON contains the JSON metadata for the -// struct [CacheCacheReserveStatusResponseEnvelope] -type cacheCacheReserveStatusResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheCacheReserveStatusResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheCacheReserveStatusResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CacheCacheReserveStatusResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheCacheReserveStatusResponseEnvelopeErrorsJSON `json:"-"` -} - -// cacheCacheReserveStatusResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CacheCacheReserveStatusResponseEnvelopeErrors] -type cacheCacheReserveStatusResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheCacheReserveStatusResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheCacheReserveStatusResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CacheCacheReserveStatusResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheCacheReserveStatusResponseEnvelopeMessagesJSON `json:"-"` -} - -// cacheCacheReserveStatusResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [CacheCacheReserveStatusResponseEnvelopeMessages] -type cacheCacheReserveStatusResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheCacheReserveStatusResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheCacheReserveStatusResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CacheCacheReserveStatusResponseEnvelopeSuccess bool - -const ( - CacheCacheReserveStatusResponseEnvelopeSuccessTrue CacheCacheReserveStatusResponseEnvelopeSuccess = true -) diff --git a/cachecachereserve_test.go b/cachecachereserve_test.go deleted file mode 100644 index ae556a79add..00000000000 --- a/cachecachereserve_test.go +++ /dev/null @@ -1,119 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestCacheCacheReserveClear(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("user@example.com"), - ) - _, err := client.Cache.CacheReserve.Clear(context.TODO(), cloudflare.CacheCacheReserveClearParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestCacheCacheReserveEdit(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("user@example.com"), - ) - _, err := client.Cache.CacheReserve.Edit(context.TODO(), cloudflare.CacheCacheReserveEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.CacheCacheReserveEditParamsValueOn), - }) - 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 TestCacheCacheReserveGet(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("user@example.com"), - ) - _, err := client.Cache.CacheReserve.Get(context.TODO(), cloudflare.CacheCacheReserveGetParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestCacheCacheReserveStatus(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("user@example.com"), - ) - _, err := client.Cache.CacheReserve.Status(context.TODO(), cloudflare.CacheCacheReserveStatusParams{ - ZoneID: cloudflare.F("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/cacheregionaltieredcache.go b/cacheregionaltieredcache.go deleted file mode 100644 index 78cd0069661..00000000000 --- a/cacheregionaltieredcache.go +++ /dev/null @@ -1,405 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// CacheRegionalTieredCacheService 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 -// [NewCacheRegionalTieredCacheService] method instead. -type CacheRegionalTieredCacheService struct { - Options []option.RequestOption -} - -// NewCacheRegionalTieredCacheService 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 NewCacheRegionalTieredCacheService(opts ...option.RequestOption) (r *CacheRegionalTieredCacheService) { - r = &CacheRegionalTieredCacheService{} - r.Options = opts - return -} - -// Instructs Cloudflare to check a regional hub data center on the way to your -// upper tier. This can help improve performance for smart and custom tiered cache -// topologies. -func (r *CacheRegionalTieredCacheService) Edit(ctx context.Context, params CacheRegionalTieredCacheEditParams, opts ...option.RequestOption) (res *CacheRegionalTieredCacheEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env CacheRegionalTieredCacheEditResponseEnvelope - path := fmt.Sprintf("zones/%s/cache/regional_tiered_cache", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Instructs Cloudflare to check a regional hub data center on the way to your -// upper tier. This can help improve performance for smart and custom tiered cache -// topologies. -func (r *CacheRegionalTieredCacheService) Get(ctx context.Context, query CacheRegionalTieredCacheGetParams, opts ...option.RequestOption) (res *CacheRegionalTieredCacheGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env CacheRegionalTieredCacheGetResponseEnvelope - path := fmt.Sprintf("zones/%s/cache/regional_tiered_cache", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Instructs Cloudflare to check a regional hub data center on the way to your -// upper tier. This can help improve performance for smart and custom tiered cache -// topologies. -type CacheRegionalTieredCacheEditResponse struct { - // ID of the zone setting. - ID CacheRegionalTieredCacheEditResponseID `json:"id,required"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` - // Instructs Cloudflare to check a regional hub data center on the way to your - // upper tier. This can help improve performance for smart and custom tiered cache - // topologies. - Value CacheRegionalTieredCacheEditResponseValue `json:"value,required"` - JSON cacheRegionalTieredCacheEditResponseJSON `json:"-"` -} - -// cacheRegionalTieredCacheEditResponseJSON contains the JSON metadata for the -// struct [CacheRegionalTieredCacheEditResponse] -type cacheRegionalTieredCacheEditResponseJSON struct { - ID apijson.Field - ModifiedOn apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheRegionalTieredCacheEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheRegionalTieredCacheEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type CacheRegionalTieredCacheEditResponseID string - -const ( - CacheRegionalTieredCacheEditResponseIDTcRegional CacheRegionalTieredCacheEditResponseID = "tc_regional" -) - -// Instructs Cloudflare to check a regional hub data center on the way to your -// upper tier. This can help improve performance for smart and custom tiered cache -// topologies. -type CacheRegionalTieredCacheEditResponseValue struct { - // ID of the zone setting. - ID CacheRegionalTieredCacheEditResponseValueID `json:"id,required"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` - JSON cacheRegionalTieredCacheEditResponseValueJSON `json:"-"` -} - -// cacheRegionalTieredCacheEditResponseValueJSON contains the JSON metadata for the -// struct [CacheRegionalTieredCacheEditResponseValue] -type cacheRegionalTieredCacheEditResponseValueJSON struct { - ID apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheRegionalTieredCacheEditResponseValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheRegionalTieredCacheEditResponseValueJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type CacheRegionalTieredCacheEditResponseValueID string - -const ( - CacheRegionalTieredCacheEditResponseValueIDTcRegional CacheRegionalTieredCacheEditResponseValueID = "tc_regional" -) - -// Instructs Cloudflare to check a regional hub data center on the way to your -// upper tier. This can help improve performance for smart and custom tiered cache -// topologies. -type CacheRegionalTieredCacheGetResponse struct { - // ID of the zone setting. - ID CacheRegionalTieredCacheGetResponseID `json:"id,required"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` - // Instructs Cloudflare to check a regional hub data center on the way to your - // upper tier. This can help improve performance for smart and custom tiered cache - // topologies. - Value CacheRegionalTieredCacheGetResponseValue `json:"value,required"` - JSON cacheRegionalTieredCacheGetResponseJSON `json:"-"` -} - -// cacheRegionalTieredCacheGetResponseJSON contains the JSON metadata for the -// struct [CacheRegionalTieredCacheGetResponse] -type cacheRegionalTieredCacheGetResponseJSON struct { - ID apijson.Field - ModifiedOn apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheRegionalTieredCacheGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheRegionalTieredCacheGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type CacheRegionalTieredCacheGetResponseID string - -const ( - CacheRegionalTieredCacheGetResponseIDTcRegional CacheRegionalTieredCacheGetResponseID = "tc_regional" -) - -// Instructs Cloudflare to check a regional hub data center on the way to your -// upper tier. This can help improve performance for smart and custom tiered cache -// topologies. -type CacheRegionalTieredCacheGetResponseValue struct { - // ID of the zone setting. - ID CacheRegionalTieredCacheGetResponseValueID `json:"id,required"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` - JSON cacheRegionalTieredCacheGetResponseValueJSON `json:"-"` -} - -// cacheRegionalTieredCacheGetResponseValueJSON contains the JSON metadata for the -// struct [CacheRegionalTieredCacheGetResponseValue] -type cacheRegionalTieredCacheGetResponseValueJSON struct { - ID apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheRegionalTieredCacheGetResponseValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheRegionalTieredCacheGetResponseValueJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type CacheRegionalTieredCacheGetResponseValueID string - -const ( - CacheRegionalTieredCacheGetResponseValueIDTcRegional CacheRegionalTieredCacheGetResponseValueID = "tc_regional" -) - -type CacheRegionalTieredCacheEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the Regional Tiered Cache zone setting. - Value param.Field[CacheRegionalTieredCacheEditParamsValue] `json:"value,required"` -} - -func (r CacheRegionalTieredCacheEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the Regional Tiered Cache zone setting. -type CacheRegionalTieredCacheEditParamsValue string - -const ( - CacheRegionalTieredCacheEditParamsValueOn CacheRegionalTieredCacheEditParamsValue = "on" - CacheRegionalTieredCacheEditParamsValueOff CacheRegionalTieredCacheEditParamsValue = "off" -) - -type CacheRegionalTieredCacheEditResponseEnvelope struct { - Errors []CacheRegionalTieredCacheEditResponseEnvelopeErrors `json:"errors,required"` - Messages []CacheRegionalTieredCacheEditResponseEnvelopeMessages `json:"messages,required"` - // Instructs Cloudflare to check a regional hub data center on the way to your - // upper tier. This can help improve performance for smart and custom tiered cache - // topologies. - Result CacheRegionalTieredCacheEditResponse `json:"result,required"` - // Whether the API call was successful - Success CacheRegionalTieredCacheEditResponseEnvelopeSuccess `json:"success,required"` - JSON cacheRegionalTieredCacheEditResponseEnvelopeJSON `json:"-"` -} - -// cacheRegionalTieredCacheEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [CacheRegionalTieredCacheEditResponseEnvelope] -type cacheRegionalTieredCacheEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheRegionalTieredCacheEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheRegionalTieredCacheEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CacheRegionalTieredCacheEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheRegionalTieredCacheEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// cacheRegionalTieredCacheEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [CacheRegionalTieredCacheEditResponseEnvelopeErrors] -type cacheRegionalTieredCacheEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheRegionalTieredCacheEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheRegionalTieredCacheEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CacheRegionalTieredCacheEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheRegionalTieredCacheEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// cacheRegionalTieredCacheEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [CacheRegionalTieredCacheEditResponseEnvelopeMessages] -type cacheRegionalTieredCacheEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheRegionalTieredCacheEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheRegionalTieredCacheEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CacheRegionalTieredCacheEditResponseEnvelopeSuccess bool - -const ( - CacheRegionalTieredCacheEditResponseEnvelopeSuccessTrue CacheRegionalTieredCacheEditResponseEnvelopeSuccess = true -) - -type CacheRegionalTieredCacheGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type CacheRegionalTieredCacheGetResponseEnvelope struct { - Errors []CacheRegionalTieredCacheGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CacheRegionalTieredCacheGetResponseEnvelopeMessages `json:"messages,required"` - // Instructs Cloudflare to check a regional hub data center on the way to your - // upper tier. This can help improve performance for smart and custom tiered cache - // topologies. - Result CacheRegionalTieredCacheGetResponse `json:"result,required"` - // Whether the API call was successful - Success CacheRegionalTieredCacheGetResponseEnvelopeSuccess `json:"success,required"` - JSON cacheRegionalTieredCacheGetResponseEnvelopeJSON `json:"-"` -} - -// cacheRegionalTieredCacheGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [CacheRegionalTieredCacheGetResponseEnvelope] -type cacheRegionalTieredCacheGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheRegionalTieredCacheGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheRegionalTieredCacheGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CacheRegionalTieredCacheGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheRegionalTieredCacheGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// cacheRegionalTieredCacheGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [CacheRegionalTieredCacheGetResponseEnvelopeErrors] -type cacheRegionalTieredCacheGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheRegionalTieredCacheGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheRegionalTieredCacheGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CacheRegionalTieredCacheGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheRegionalTieredCacheGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// cacheRegionalTieredCacheGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [CacheRegionalTieredCacheGetResponseEnvelopeMessages] -type cacheRegionalTieredCacheGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheRegionalTieredCacheGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheRegionalTieredCacheGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CacheRegionalTieredCacheGetResponseEnvelopeSuccess bool - -const ( - CacheRegionalTieredCacheGetResponseEnvelopeSuccessTrue CacheRegionalTieredCacheGetResponseEnvelopeSuccess = true -) diff --git a/cacheregionaltieredcache_test.go b/cacheregionaltieredcache_test.go deleted file mode 100644 index 19580ebef25..00000000000 --- a/cacheregionaltieredcache_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestCacheRegionalTieredCacheEdit(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("user@example.com"), - ) - _, err := client.Cache.RegionalTieredCache.Edit(context.TODO(), cloudflare.CacheRegionalTieredCacheEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.CacheRegionalTieredCacheEditParamsValueOn), - }) - 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 TestCacheRegionalTieredCacheGet(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("user@example.com"), - ) - _, err := client.Cache.RegionalTieredCache.Get(context.TODO(), cloudflare.CacheRegionalTieredCacheGetParams{ - ZoneID: cloudflare.F("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/cachesmarttieredcached.go b/cachesmarttieredcached.go deleted file mode 100644 index 5f2fe8c3b4f..00000000000 --- a/cachesmarttieredcached.go +++ /dev/null @@ -1,397 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// CacheSmartTieredCachedService 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 [NewCacheSmartTieredCachedService] -// method instead. -type CacheSmartTieredCachedService struct { - Options []option.RequestOption -} - -// NewCacheSmartTieredCachedService 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 NewCacheSmartTieredCachedService(opts ...option.RequestOption) (r *CacheSmartTieredCachedService) { - r = &CacheSmartTieredCachedService{} - r.Options = opts - return -} - -// Remvoves enablement of Smart Tiered Cache -func (r *CacheSmartTieredCachedService) Delete(ctx context.Context, body CacheSmartTieredCachedDeleteParams, opts ...option.RequestOption) (res *CacheSmartTieredCachedDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env CacheSmartTieredCachedDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/cache/tiered_cache_smart_topology_enable", body.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates enablement of Tiered Cache -func (r *CacheSmartTieredCachedService) Edit(ctx context.Context, params CacheSmartTieredCachedEditParams, opts ...option.RequestOption) (res *CacheSmartTieredCachedEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env CacheSmartTieredCachedEditResponseEnvelope - path := fmt.Sprintf("zones/%s/cache/tiered_cache_smart_topology_enable", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get Smart Tiered Cache setting -func (r *CacheSmartTieredCachedService) Get(ctx context.Context, query CacheSmartTieredCachedGetParams, opts ...option.RequestOption) (res *CacheSmartTieredCachedGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env CacheSmartTieredCachedGetResponseEnvelope - path := fmt.Sprintf("zones/%s/cache/tiered_cache_smart_topology_enable", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [CacheSmartTieredCachedDeleteResponseUnknown] or -// [shared.UnionString]. -type CacheSmartTieredCachedDeleteResponse interface { - ImplementsCacheSmartTieredCachedDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*CacheSmartTieredCachedDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [CacheSmartTieredCachedEditResponseUnknown] or -// [shared.UnionString]. -type CacheSmartTieredCachedEditResponse interface { - ImplementsCacheSmartTieredCachedEditResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*CacheSmartTieredCachedEditResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [CacheSmartTieredCachedGetResponseUnknown] or -// [shared.UnionString]. -type CacheSmartTieredCachedGetResponse interface { - ImplementsCacheSmartTieredCachedGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*CacheSmartTieredCachedGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type CacheSmartTieredCachedDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type CacheSmartTieredCachedDeleteResponseEnvelope struct { - Errors []CacheSmartTieredCachedDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []CacheSmartTieredCachedDeleteResponseEnvelopeMessages `json:"messages,required"` - Result CacheSmartTieredCachedDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success CacheSmartTieredCachedDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON cacheSmartTieredCachedDeleteResponseEnvelopeJSON `json:"-"` -} - -// cacheSmartTieredCachedDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [CacheSmartTieredCachedDeleteResponseEnvelope] -type cacheSmartTieredCachedDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheSmartTieredCachedDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheSmartTieredCachedDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CacheSmartTieredCachedDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheSmartTieredCachedDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// cacheSmartTieredCachedDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [CacheSmartTieredCachedDeleteResponseEnvelopeErrors] -type cacheSmartTieredCachedDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheSmartTieredCachedDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheSmartTieredCachedDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CacheSmartTieredCachedDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheSmartTieredCachedDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// cacheSmartTieredCachedDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [CacheSmartTieredCachedDeleteResponseEnvelopeMessages] -type cacheSmartTieredCachedDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheSmartTieredCachedDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheSmartTieredCachedDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CacheSmartTieredCachedDeleteResponseEnvelopeSuccess bool - -const ( - CacheSmartTieredCachedDeleteResponseEnvelopeSuccessTrue CacheSmartTieredCachedDeleteResponseEnvelopeSuccess = true -) - -type CacheSmartTieredCachedEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Enables Tiered Cache. - Value param.Field[CacheSmartTieredCachedEditParamsValue] `json:"value,required"` -} - -func (r CacheSmartTieredCachedEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enables Tiered Cache. -type CacheSmartTieredCachedEditParamsValue string - -const ( - CacheSmartTieredCachedEditParamsValueOn CacheSmartTieredCachedEditParamsValue = "on" - CacheSmartTieredCachedEditParamsValueOff CacheSmartTieredCachedEditParamsValue = "off" -) - -type CacheSmartTieredCachedEditResponseEnvelope struct { - Errors []CacheSmartTieredCachedEditResponseEnvelopeErrors `json:"errors,required"` - Messages []CacheSmartTieredCachedEditResponseEnvelopeMessages `json:"messages,required"` - Result CacheSmartTieredCachedEditResponse `json:"result,required"` - // Whether the API call was successful - Success CacheSmartTieredCachedEditResponseEnvelopeSuccess `json:"success,required"` - JSON cacheSmartTieredCachedEditResponseEnvelopeJSON `json:"-"` -} - -// cacheSmartTieredCachedEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [CacheSmartTieredCachedEditResponseEnvelope] -type cacheSmartTieredCachedEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheSmartTieredCachedEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheSmartTieredCachedEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CacheSmartTieredCachedEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheSmartTieredCachedEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// cacheSmartTieredCachedEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [CacheSmartTieredCachedEditResponseEnvelopeErrors] -type cacheSmartTieredCachedEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheSmartTieredCachedEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheSmartTieredCachedEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CacheSmartTieredCachedEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheSmartTieredCachedEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// cacheSmartTieredCachedEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [CacheSmartTieredCachedEditResponseEnvelopeMessages] -type cacheSmartTieredCachedEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheSmartTieredCachedEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheSmartTieredCachedEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CacheSmartTieredCachedEditResponseEnvelopeSuccess bool - -const ( - CacheSmartTieredCachedEditResponseEnvelopeSuccessTrue CacheSmartTieredCachedEditResponseEnvelopeSuccess = true -) - -type CacheSmartTieredCachedGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type CacheSmartTieredCachedGetResponseEnvelope struct { - Errors []CacheSmartTieredCachedGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CacheSmartTieredCachedGetResponseEnvelopeMessages `json:"messages,required"` - Result CacheSmartTieredCachedGetResponse `json:"result,required"` - // Whether the API call was successful - Success CacheSmartTieredCachedGetResponseEnvelopeSuccess `json:"success,required"` - JSON cacheSmartTieredCachedGetResponseEnvelopeJSON `json:"-"` -} - -// cacheSmartTieredCachedGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [CacheSmartTieredCachedGetResponseEnvelope] -type cacheSmartTieredCachedGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheSmartTieredCachedGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheSmartTieredCachedGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CacheSmartTieredCachedGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheSmartTieredCachedGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// cacheSmartTieredCachedGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [CacheSmartTieredCachedGetResponseEnvelopeErrors] -type cacheSmartTieredCachedGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheSmartTieredCachedGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheSmartTieredCachedGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CacheSmartTieredCachedGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheSmartTieredCachedGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// cacheSmartTieredCachedGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [CacheSmartTieredCachedGetResponseEnvelopeMessages] -type cacheSmartTieredCachedGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheSmartTieredCachedGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheSmartTieredCachedGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CacheSmartTieredCachedGetResponseEnvelopeSuccess bool - -const ( - CacheSmartTieredCachedGetResponseEnvelopeSuccessTrue CacheSmartTieredCachedGetResponseEnvelopeSuccess = true -) diff --git a/cachesmarttieredcached_test.go b/cachesmarttieredcached_test.go deleted file mode 100644 index 6b44c95e851..00000000000 --- a/cachesmarttieredcached_test.go +++ /dev/null @@ -1,93 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestCacheSmartTieredCachedDelete(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("user@example.com"), - ) - _, err := client.Cache.SmartTieredCached.Delete(context.TODO(), cloudflare.CacheSmartTieredCachedDeleteParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestCacheSmartTieredCachedEdit(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("user@example.com"), - ) - _, err := client.Cache.SmartTieredCached.Edit(context.TODO(), cloudflare.CacheSmartTieredCachedEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.CacheSmartTieredCachedEditParamsValueOn), - }) - 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 TestCacheSmartTieredCachedGet(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("user@example.com"), - ) - _, err := client.Cache.SmartTieredCached.Get(context.TODO(), cloudflare.CacheSmartTieredCachedGetParams{ - ZoneID: cloudflare.F("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/cachevariant.go b/cachevariant.go deleted file mode 100644 index 4dd7a099ff6..00000000000 --- a/cachevariant.go +++ /dev/null @@ -1,649 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// CacheVariantService 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 [NewCacheVariantService] method -// instead. -type CacheVariantService struct { - Options []option.RequestOption -} - -// NewCacheVariantService 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 NewCacheVariantService(opts ...option.RequestOption) (r *CacheVariantService) { - r = &CacheVariantService{} - r.Options = opts - return -} - -// Variant support enables caching variants of images with certain file extensions -// in addition to the original. This only applies when the origin server sends the -// 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but -// does not serve the variant requested, the response will not be cached. This will -// be indicated with BYPASS cache status in the response headers. -func (r *CacheVariantService) Delete(ctx context.Context, body CacheVariantDeleteParams, opts ...option.RequestOption) (res *CacheVariantDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env CacheVariantDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/cache/variants", body.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Variant support enables caching variants of images with certain file extensions -// in addition to the original. This only applies when the origin server sends the -// 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but -// does not serve the variant requested, the response will not be cached. This will -// be indicated with BYPASS cache status in the response headers. -func (r *CacheVariantService) Edit(ctx context.Context, params CacheVariantEditParams, opts ...option.RequestOption) (res *CacheVariantEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env CacheVariantEditResponseEnvelope - path := fmt.Sprintf("zones/%s/cache/variants", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Variant support enables caching variants of images with certain file extensions -// in addition to the original. This only applies when the origin server sends the -// 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but -// does not serve the variant requested, the response will not be cached. This will -// be indicated with BYPASS cache status in the response headers. -func (r *CacheVariantService) Get(ctx context.Context, query CacheVariantGetParams, opts ...option.RequestOption) (res *CacheVariantGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env CacheVariantGetResponseEnvelope - path := fmt.Sprintf("zones/%s/cache/variants", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Variant support enables caching variants of images with certain file extensions -// in addition to the original. This only applies when the origin server sends the -// 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but -// does not serve the variant requested, the response will not be cached. This will -// be indicated with BYPASS cache status in the response headers. -type CacheVariantDeleteResponse struct { - // ID of the zone setting. - ID CacheVariantDeleteResponseID `json:"id,required"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` - JSON cacheVariantDeleteResponseJSON `json:"-"` -} - -// cacheVariantDeleteResponseJSON contains the JSON metadata for the struct -// [CacheVariantDeleteResponse] -type cacheVariantDeleteResponseJSON struct { - ID apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheVariantDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheVariantDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type CacheVariantDeleteResponseID string - -const ( - CacheVariantDeleteResponseIDVariants CacheVariantDeleteResponseID = "variants" -) - -// Variant support enables caching variants of images with certain file extensions -// in addition to the original. This only applies when the origin server sends the -// 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but -// does not serve the variant requested, the response will not be cached. This will -// be indicated with BYPASS cache status in the response headers. -type CacheVariantEditResponse struct { - // ID of the zone setting. - ID CacheVariantEditResponseID `json:"id,required"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` - // Value of the zone setting. - Value CacheVariantEditResponseValue `json:"value,required"` - JSON cacheVariantEditResponseJSON `json:"-"` -} - -// cacheVariantEditResponseJSON contains the JSON metadata for the struct -// [CacheVariantEditResponse] -type cacheVariantEditResponseJSON struct { - ID apijson.Field - ModifiedOn apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheVariantEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheVariantEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type CacheVariantEditResponseID string - -const ( - CacheVariantEditResponseIDVariants CacheVariantEditResponseID = "variants" -) - -// Value of the zone setting. -type CacheVariantEditResponseValue struct { - // List of strings with the MIME types of all the variants that should be served - // for avif. - Avif []interface{} `json:"avif"` - // List of strings with the MIME types of all the variants that should be served - // for bmp. - Bmp []interface{} `json:"bmp"` - // List of strings with the MIME types of all the variants that should be served - // for gif. - Gif []interface{} `json:"gif"` - // List of strings with the MIME types of all the variants that should be served - // for jp2. - Jp2 []interface{} `json:"jp2"` - // List of strings with the MIME types of all the variants that should be served - // for jpeg. - Jpeg []interface{} `json:"jpeg"` - // List of strings with the MIME types of all the variants that should be served - // for jpg. - Jpg []interface{} `json:"jpg"` - // List of strings with the MIME types of all the variants that should be served - // for jpg2. - Jpg2 []interface{} `json:"jpg2"` - // List of strings with the MIME types of all the variants that should be served - // for png. - Png []interface{} `json:"png"` - // List of strings with the MIME types of all the variants that should be served - // for tif. - Tif []interface{} `json:"tif"` - // List of strings with the MIME types of all the variants that should be served - // for tiff. - Tiff []interface{} `json:"tiff"` - // List of strings with the MIME types of all the variants that should be served - // for webp. - Webp []interface{} `json:"webp"` - JSON cacheVariantEditResponseValueJSON `json:"-"` -} - -// cacheVariantEditResponseValueJSON contains the JSON metadata for the struct -// [CacheVariantEditResponseValue] -type cacheVariantEditResponseValueJSON struct { - Avif apijson.Field - Bmp apijson.Field - Gif apijson.Field - Jp2 apijson.Field - Jpeg apijson.Field - Jpg apijson.Field - Jpg2 apijson.Field - Png apijson.Field - Tif apijson.Field - Tiff apijson.Field - Webp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheVariantEditResponseValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheVariantEditResponseValueJSON) RawJSON() string { - return r.raw -} - -// Variant support enables caching variants of images with certain file extensions -// in addition to the original. This only applies when the origin server sends the -// 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but -// does not serve the variant requested, the response will not be cached. This will -// be indicated with BYPASS cache status in the response headers. -type CacheVariantGetResponse struct { - // ID of the zone setting. - ID CacheVariantGetResponseID `json:"id,required"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` - // Value of the zone setting. - Value CacheVariantGetResponseValue `json:"value,required"` - JSON cacheVariantGetResponseJSON `json:"-"` -} - -// cacheVariantGetResponseJSON contains the JSON metadata for the struct -// [CacheVariantGetResponse] -type cacheVariantGetResponseJSON struct { - ID apijson.Field - ModifiedOn apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheVariantGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheVariantGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type CacheVariantGetResponseID string - -const ( - CacheVariantGetResponseIDVariants CacheVariantGetResponseID = "variants" -) - -// Value of the zone setting. -type CacheVariantGetResponseValue struct { - // List of strings with the MIME types of all the variants that should be served - // for avif. - Avif []interface{} `json:"avif"` - // List of strings with the MIME types of all the variants that should be served - // for bmp. - Bmp []interface{} `json:"bmp"` - // List of strings with the MIME types of all the variants that should be served - // for gif. - Gif []interface{} `json:"gif"` - // List of strings with the MIME types of all the variants that should be served - // for jp2. - Jp2 []interface{} `json:"jp2"` - // List of strings with the MIME types of all the variants that should be served - // for jpeg. - Jpeg []interface{} `json:"jpeg"` - // List of strings with the MIME types of all the variants that should be served - // for jpg. - Jpg []interface{} `json:"jpg"` - // List of strings with the MIME types of all the variants that should be served - // for jpg2. - Jpg2 []interface{} `json:"jpg2"` - // List of strings with the MIME types of all the variants that should be served - // for png. - Png []interface{} `json:"png"` - // List of strings with the MIME types of all the variants that should be served - // for tif. - Tif []interface{} `json:"tif"` - // List of strings with the MIME types of all the variants that should be served - // for tiff. - Tiff []interface{} `json:"tiff"` - // List of strings with the MIME types of all the variants that should be served - // for webp. - Webp []interface{} `json:"webp"` - JSON cacheVariantGetResponseValueJSON `json:"-"` -} - -// cacheVariantGetResponseValueJSON contains the JSON metadata for the struct -// [CacheVariantGetResponseValue] -type cacheVariantGetResponseValueJSON struct { - Avif apijson.Field - Bmp apijson.Field - Gif apijson.Field - Jp2 apijson.Field - Jpeg apijson.Field - Jpg apijson.Field - Jpg2 apijson.Field - Png apijson.Field - Tif apijson.Field - Tiff apijson.Field - Webp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheVariantGetResponseValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheVariantGetResponseValueJSON) RawJSON() string { - return r.raw -} - -type CacheVariantDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type CacheVariantDeleteResponseEnvelope struct { - Errors []CacheVariantDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []CacheVariantDeleteResponseEnvelopeMessages `json:"messages,required"` - // Variant support enables caching variants of images with certain file extensions - // in addition to the original. This only applies when the origin server sends the - // 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but - // does not serve the variant requested, the response will not be cached. This will - // be indicated with BYPASS cache status in the response headers. - Result CacheVariantDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success CacheVariantDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON cacheVariantDeleteResponseEnvelopeJSON `json:"-"` -} - -// cacheVariantDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [CacheVariantDeleteResponseEnvelope] -type cacheVariantDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheVariantDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheVariantDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CacheVariantDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheVariantDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// cacheVariantDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CacheVariantDeleteResponseEnvelopeErrors] -type cacheVariantDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheVariantDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheVariantDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CacheVariantDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheVariantDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// cacheVariantDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [CacheVariantDeleteResponseEnvelopeMessages] -type cacheVariantDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheVariantDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheVariantDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CacheVariantDeleteResponseEnvelopeSuccess bool - -const ( - CacheVariantDeleteResponseEnvelopeSuccessTrue CacheVariantDeleteResponseEnvelopeSuccess = true -) - -type CacheVariantEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[CacheVariantEditParamsValue] `json:"value,required"` -} - -func (r CacheVariantEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type CacheVariantEditParamsValue struct { - // List of strings with the MIME types of all the variants that should be served - // for avif. - Avif param.Field[[]interface{}] `json:"avif"` - // List of strings with the MIME types of all the variants that should be served - // for bmp. - Bmp param.Field[[]interface{}] `json:"bmp"` - // List of strings with the MIME types of all the variants that should be served - // for gif. - Gif param.Field[[]interface{}] `json:"gif"` - // List of strings with the MIME types of all the variants that should be served - // for jp2. - Jp2 param.Field[[]interface{}] `json:"jp2"` - // List of strings with the MIME types of all the variants that should be served - // for jpeg. - Jpeg param.Field[[]interface{}] `json:"jpeg"` - // List of strings with the MIME types of all the variants that should be served - // for jpg. - Jpg param.Field[[]interface{}] `json:"jpg"` - // List of strings with the MIME types of all the variants that should be served - // for jpg2. - Jpg2 param.Field[[]interface{}] `json:"jpg2"` - // List of strings with the MIME types of all the variants that should be served - // for png. - Png param.Field[[]interface{}] `json:"png"` - // List of strings with the MIME types of all the variants that should be served - // for tif. - Tif param.Field[[]interface{}] `json:"tif"` - // List of strings with the MIME types of all the variants that should be served - // for tiff. - Tiff param.Field[[]interface{}] `json:"tiff"` - // List of strings with the MIME types of all the variants that should be served - // for webp. - Webp param.Field[[]interface{}] `json:"webp"` -} - -func (r CacheVariantEditParamsValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type CacheVariantEditResponseEnvelope struct { - Errors []CacheVariantEditResponseEnvelopeErrors `json:"errors,required"` - Messages []CacheVariantEditResponseEnvelopeMessages `json:"messages,required"` - // Variant support enables caching variants of images with certain file extensions - // in addition to the original. This only applies when the origin server sends the - // 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but - // does not serve the variant requested, the response will not be cached. This will - // be indicated with BYPASS cache status in the response headers. - Result CacheVariantEditResponse `json:"result,required"` - // Whether the API call was successful - Success CacheVariantEditResponseEnvelopeSuccess `json:"success,required"` - JSON cacheVariantEditResponseEnvelopeJSON `json:"-"` -} - -// cacheVariantEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [CacheVariantEditResponseEnvelope] -type cacheVariantEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheVariantEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheVariantEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CacheVariantEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheVariantEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// cacheVariantEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CacheVariantEditResponseEnvelopeErrors] -type cacheVariantEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheVariantEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheVariantEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CacheVariantEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheVariantEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// cacheVariantEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [CacheVariantEditResponseEnvelopeMessages] -type cacheVariantEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheVariantEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheVariantEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CacheVariantEditResponseEnvelopeSuccess bool - -const ( - CacheVariantEditResponseEnvelopeSuccessTrue CacheVariantEditResponseEnvelopeSuccess = true -) - -type CacheVariantGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type CacheVariantGetResponseEnvelope struct { - Errors []CacheVariantGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CacheVariantGetResponseEnvelopeMessages `json:"messages,required"` - // Variant support enables caching variants of images with certain file extensions - // in addition to the original. This only applies when the origin server sends the - // 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but - // does not serve the variant requested, the response will not be cached. This will - // be indicated with BYPASS cache status in the response headers. - Result CacheVariantGetResponse `json:"result,required"` - // Whether the API call was successful - Success CacheVariantGetResponseEnvelopeSuccess `json:"success,required"` - JSON cacheVariantGetResponseEnvelopeJSON `json:"-"` -} - -// cacheVariantGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [CacheVariantGetResponseEnvelope] -type cacheVariantGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheVariantGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheVariantGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CacheVariantGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheVariantGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// cacheVariantGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CacheVariantGetResponseEnvelopeErrors] -type cacheVariantGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheVariantGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheVariantGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CacheVariantGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cacheVariantGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// cacheVariantGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [CacheVariantGetResponseEnvelopeMessages] -type cacheVariantGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CacheVariantGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cacheVariantGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CacheVariantGetResponseEnvelopeSuccess bool - -const ( - CacheVariantGetResponseEnvelopeSuccessTrue CacheVariantGetResponseEnvelopeSuccess = true -) diff --git a/cachevariant_test.go b/cachevariant_test.go deleted file mode 100644 index b7b3115bcb2..00000000000 --- a/cachevariant_test.go +++ /dev/null @@ -1,105 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestCacheVariantDelete(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("user@example.com"), - ) - _, err := client.Cache.Variants.Delete(context.TODO(), cloudflare.CacheVariantDeleteParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestCacheVariantEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Cache.Variants.Edit(context.TODO(), cloudflare.CacheVariantEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.CacheVariantEditParamsValue{ - Avif: cloudflare.F([]interface{}{"image/webp", "image/jpeg"}), - Bmp: cloudflare.F([]interface{}{"image/webp", "image/jpeg"}), - Gif: cloudflare.F([]interface{}{"image/webp", "image/jpeg"}), - Jp2: cloudflare.F([]interface{}{"image/webp", "image/avif"}), - Jpeg: cloudflare.F([]interface{}{"image/webp", "image/avif"}), - Jpg: cloudflare.F([]interface{}{"image/webp", "image/avif"}), - Jpg2: cloudflare.F([]interface{}{"image/webp", "image/avif"}), - Png: cloudflare.F([]interface{}{"image/webp", "image/avif"}), - Tif: cloudflare.F([]interface{}{"image/webp", "image/avif"}), - Tiff: cloudflare.F([]interface{}{"image/webp", "image/avif"}), - Webp: cloudflare.F([]interface{}{"image/jpeg", "image/avif"}), - }), - }) - 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 TestCacheVariantGet(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("user@example.com"), - ) - _, err := client.Cache.Variants.Get(context.TODO(), cloudflare.CacheVariantGetParams{ - ZoneID: cloudflare.F("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/calls/aliases.go b/calls/aliases.go new file mode 100644 index 00000000000..b81b82b3d74 --- /dev/null +++ b/calls/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package calls + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/call.go b/calls/call.go similarity index 81% rename from call.go rename to calls/call.go index 49a531480b5..0cff3e2645b 100644 --- a/call.go +++ b/calls/call.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package calls import ( "context" @@ -33,7 +33,7 @@ func NewCallService(opts ...option.RequestOption) (r *CallService) { // Creates a new Cloudflare calls app. An app is an unique enviroment where each // Session can access all Tracks within the app. -func (r *CallService) New(ctx context.Context, params CallNewParams, opts ...option.RequestOption) (res *CallNewResponse, err error) { +func (r *CallService) New(ctx context.Context, params CallNewParams, opts ...option.RequestOption) (res *CallsAppWithSecret, err error) { opts = append(r.Options[:], opts...) var env CallNewResponseEnvelope path := fmt.Sprintf("accounts/%s/calls/apps", params.AccountID) @@ -46,7 +46,7 @@ func (r *CallService) New(ctx context.Context, params CallNewParams, opts ...opt } // Edit details for a single app. -func (r *CallService) Update(ctx context.Context, appID string, params CallUpdateParams, opts ...option.RequestOption) (res *CallUpdateResponse, err error) { +func (r *CallService) Update(ctx context.Context, appID string, params CallUpdateParams, opts ...option.RequestOption) (res *CallsApp, err error) { opts = append(r.Options[:], opts...) var env CallUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/calls/apps/%s", params.AccountID, appID) @@ -59,7 +59,7 @@ func (r *CallService) Update(ctx context.Context, appID string, params CallUpdat } // Lists all apps in the Cloudflare account -func (r *CallService) List(ctx context.Context, query CallListParams, opts ...option.RequestOption) (res *[]CallListResponse, err error) { +func (r *CallService) List(ctx context.Context, query CallListParams, opts ...option.RequestOption) (res *[]CallsApp, err error) { opts = append(r.Options[:], opts...) var env CallListResponseEnvelope path := fmt.Sprintf("accounts/%s/calls/apps", query.AccountID) @@ -72,7 +72,7 @@ func (r *CallService) List(ctx context.Context, query CallListParams, opts ...op } // Deletes an app from Cloudflare Calls -func (r *CallService) Delete(ctx context.Context, appID string, body CallDeleteParams, opts ...option.RequestOption) (res *CallDeleteResponse, err error) { +func (r *CallService) Delete(ctx context.Context, appID string, body CallDeleteParams, opts ...option.RequestOption) (res *CallsApp, err error) { opts = append(r.Options[:], opts...) var env CallDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/calls/apps/%s", body.AccountID, appID) @@ -85,7 +85,7 @@ func (r *CallService) Delete(ctx context.Context, appID string, body CallDeleteP } // Fetches details for a single Calls app. -func (r *CallService) Get(ctx context.Context, appID string, query CallGetParams, opts ...option.RequestOption) (res *CallGetResponse, err error) { +func (r *CallService) Get(ctx context.Context, appID string, query CallGetParams, opts ...option.RequestOption) (res *CallsApp, err error) { opts = append(r.Options[:], opts...) var env CallGetResponseEnvelope path := fmt.Sprintf("accounts/%s/calls/apps/%s", query.AccountID, appID) @@ -97,71 +97,7 @@ func (r *CallService) Get(ctx context.Context, appID string, query CallGetParams return } -type CallNewResponse struct { - // The date and time the item was created. - Created time.Time `json:"created" format:"date-time"` - // The date and time the item was last modified. - Modified time.Time `json:"modified" format:"date-time"` - // A short description of Calls app, not shown to end users. - Name string `json:"name"` - // Bearer token to use the Calls API. - Secret string `json:"secret"` - // A Cloudflare-generated unique identifier for a item. - Uid string `json:"uid"` - JSON callNewResponseJSON `json:"-"` -} - -// callNewResponseJSON contains the JSON metadata for the struct [CallNewResponse] -type callNewResponseJSON struct { - Created apijson.Field - Modified apijson.Field - Name apijson.Field - Secret apijson.Field - Uid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CallNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r callNewResponseJSON) RawJSON() string { - return r.raw -} - -type CallUpdateResponse struct { - // The date and time the item was created. - Created time.Time `json:"created" format:"date-time"` - // The date and time the item was last modified. - Modified time.Time `json:"modified" format:"date-time"` - // A short description of Calls app, not shown to end users. - Name string `json:"name"` - // A Cloudflare-generated unique identifier for a item. - Uid string `json:"uid"` - JSON callUpdateResponseJSON `json:"-"` -} - -// callUpdateResponseJSON contains the JSON metadata for the struct -// [CallUpdateResponse] -type callUpdateResponseJSON struct { - Created apijson.Field - Modified apijson.Field - Name apijson.Field - Uid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CallUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r callUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type CallListResponse struct { +type CallsApp struct { // The date and time the item was created. Created time.Time `json:"created" format:"date-time"` // The date and time the item was last modified. @@ -169,13 +105,12 @@ type CallListResponse struct { // A short description of Calls app, not shown to end users. Name string `json:"name"` // A Cloudflare-generated unique identifier for a item. - Uid string `json:"uid"` - JSON callListResponseJSON `json:"-"` + Uid string `json:"uid"` + JSON callsAppJSON `json:"-"` } -// callListResponseJSON contains the JSON metadata for the struct -// [CallListResponse] -type callListResponseJSON struct { +// callsAppJSON contains the JSON metadata for the struct [CallsApp] +type callsAppJSON struct { Created apijson.Field Modified apijson.Field Name apijson.Field @@ -184,72 +119,45 @@ type callListResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *CallListResponse) UnmarshalJSON(data []byte) (err error) { +func (r *CallsApp) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r callListResponseJSON) RawJSON() string { +func (r callsAppJSON) RawJSON() string { return r.raw } -type CallDeleteResponse struct { +type CallsAppWithSecret struct { // The date and time the item was created. Created time.Time `json:"created" format:"date-time"` // The date and time the item was last modified. Modified time.Time `json:"modified" format:"date-time"` // A short description of Calls app, not shown to end users. Name string `json:"name"` + // Bearer token to use the Calls API. + Secret string `json:"secret"` // A Cloudflare-generated unique identifier for a item. Uid string `json:"uid"` - JSON callDeleteResponseJSON `json:"-"` -} - -// callDeleteResponseJSON contains the JSON metadata for the struct -// [CallDeleteResponse] -type callDeleteResponseJSON struct { - Created apijson.Field - Modified apijson.Field - Name apijson.Field - Uid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CallDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) + JSON callsAppWithSecretJSON `json:"-"` } -func (r callDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type CallGetResponse struct { - // The date and time the item was created. - Created time.Time `json:"created" format:"date-time"` - // The date and time the item was last modified. - Modified time.Time `json:"modified" format:"date-time"` - // A short description of Calls app, not shown to end users. - Name string `json:"name"` - // A Cloudflare-generated unique identifier for a item. - Uid string `json:"uid"` - JSON callGetResponseJSON `json:"-"` -} - -// callGetResponseJSON contains the JSON metadata for the struct [CallGetResponse] -type callGetResponseJSON struct { +// callsAppWithSecretJSON contains the JSON metadata for the struct +// [CallsAppWithSecret] +type callsAppWithSecretJSON struct { Created apijson.Field Modified apijson.Field Name apijson.Field + Secret apijson.Field Uid apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *CallGetResponse) UnmarshalJSON(data []byte) (err error) { +func (r *CallsAppWithSecret) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r callGetResponseJSON) RawJSON() string { +func (r callsAppWithSecretJSON) RawJSON() string { return r.raw } @@ -267,7 +175,7 @@ func (r CallNewParams) MarshalJSON() (data []byte, err error) { type CallNewResponseEnvelope struct { Errors []CallNewResponseEnvelopeErrors `json:"errors,required"` Messages []CallNewResponseEnvelopeMessages `json:"messages,required"` - Result CallNewResponse `json:"result,required"` + Result CallsAppWithSecret `json:"result,required"` // Whether the API call was successful Success CallNewResponseEnvelopeSuccess `json:"success,required"` JSON callNewResponseEnvelopeJSON `json:"-"` @@ -359,7 +267,7 @@ func (r CallUpdateParams) MarshalJSON() (data []byte, err error) { type CallUpdateResponseEnvelope struct { Errors []CallUpdateResponseEnvelopeErrors `json:"errors,required"` Messages []CallUpdateResponseEnvelopeMessages `json:"messages,required"` - Result CallUpdateResponse `json:"result,required"` + Result CallsApp `json:"result,required"` // Whether the API call was successful Success CallUpdateResponseEnvelopeSuccess `json:"success,required"` JSON callUpdateResponseEnvelopeJSON `json:"-"` @@ -445,7 +353,7 @@ type CallListParams struct { type CallListResponseEnvelope struct { Errors []CallListResponseEnvelopeErrors `json:"errors,required"` Messages []CallListResponseEnvelopeMessages `json:"messages,required"` - Result []CallListResponse `json:"result,required"` + Result []CallsApp `json:"result,required"` // Whether the API call was successful Success CallListResponseEnvelopeSuccess `json:"success,required"` JSON callListResponseEnvelopeJSON `json:"-"` @@ -531,7 +439,7 @@ type CallDeleteParams struct { type CallDeleteResponseEnvelope struct { Errors []CallDeleteResponseEnvelopeErrors `json:"errors,required"` Messages []CallDeleteResponseEnvelopeMessages `json:"messages,required"` - Result CallDeleteResponse `json:"result,required"` + Result CallsApp `json:"result,required"` // Whether the API call was successful Success CallDeleteResponseEnvelopeSuccess `json:"success,required"` JSON callDeleteResponseEnvelopeJSON `json:"-"` @@ -617,7 +525,7 @@ type CallGetParams struct { type CallGetResponseEnvelope struct { Errors []CallGetResponseEnvelopeErrors `json:"errors,required"` Messages []CallGetResponseEnvelopeMessages `json:"messages,required"` - Result CallGetResponse `json:"result,required"` + Result CallsApp `json:"result,required"` // Whether the API call was successful Success CallGetResponseEnvelopeSuccess `json:"success,required"` JSON callGetResponseEnvelopeJSON `json:"-"` diff --git a/call_test.go b/calls/call_test.go similarity index 93% rename from call_test.go rename to calls/call_test.go index d6fd53b4e7d..300984e98ee 100644 --- a/call_test.go +++ b/calls/call_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package calls_test import ( "context" @@ -9,6 +9,7 @@ import ( "testing" "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/calls" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" ) @@ -27,7 +28,7 @@ func TestCallNewWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Calls.New(context.TODO(), cloudflare.CallNewParams{ + _, err := client.Calls.New(context.TODO(), calls.CallNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("production-realtime-app"), }) @@ -57,7 +58,7 @@ func TestCallUpdateWithOptionalParams(t *testing.T) { _, err := client.Calls.Update( context.TODO(), "2a95132c15732412d22c1476fa83f27a", - cloudflare.CallUpdateParams{ + calls.CallUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("production-realtime-app"), }, @@ -85,7 +86,7 @@ func TestCallList(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Calls.List(context.TODO(), cloudflare.CallListParams{ + _, err := client.Calls.List(context.TODO(), calls.CallListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { @@ -114,7 +115,7 @@ func TestCallDelete(t *testing.T) { _, err := client.Calls.Delete( context.TODO(), "2a95132c15732412d22c1476fa83f27a", - cloudflare.CallDeleteParams{ + calls.CallDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) @@ -144,7 +145,7 @@ func TestCallGet(t *testing.T) { _, err := client.Calls.Get( context.TODO(), "2a95132c15732412d22c1476fa83f27a", - cloudflare.CallGetParams{ + calls.CallGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) diff --git a/certificate_authorities/aliases.go b/certificate_authorities/aliases.go new file mode 100644 index 00000000000..690e081945b --- /dev/null +++ b/certificate_authorities/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package certificate_authorities + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/certificateauthority.go b/certificate_authorities/certificateauthority.go similarity index 84% rename from certificateauthority.go rename to certificate_authorities/certificateauthority.go index d7680729f9b..888604c3761 100644 --- a/certificateauthority.go +++ b/certificate_authorities/certificateauthority.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package certificate_authorities import ( "github.com/cloudflare/cloudflare-go/option" @@ -13,7 +13,7 @@ import ( // method instead. type CertificateAuthorityService struct { Options []option.RequestOption - HostnameAssociations *CertificateAuthorityHostnameAssociationService + HostnameAssociations *HostnameAssociationService } // NewCertificateAuthorityService generates a new service that applies the given @@ -22,6 +22,6 @@ type CertificateAuthorityService struct { func NewCertificateAuthorityService(opts ...option.RequestOption) (r *CertificateAuthorityService) { r = &CertificateAuthorityService{} r.Options = opts - r.HostnameAssociations = NewCertificateAuthorityHostnameAssociationService(opts...) + r.HostnameAssociations = NewHostnameAssociationService(opts...) return } diff --git a/certificate_authorities/hostnameassociation.go b/certificate_authorities/hostnameassociation.go new file mode 100644 index 00000000000..c9d49a8e50c --- /dev/null +++ b/certificate_authorities/hostnameassociation.go @@ -0,0 +1,280 @@ +// File generated from our OpenAPI spec by Stainless. + +package certificate_authorities + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HostnameAssociationService 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 [NewHostnameAssociationService] +// method instead. +type HostnameAssociationService struct { + Options []option.RequestOption +} + +// NewHostnameAssociationService 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 NewHostnameAssociationService(opts ...option.RequestOption) (r *HostnameAssociationService) { + r = &HostnameAssociationService{} + r.Options = opts + return +} + +// Replace Hostname Associations +func (r *HostnameAssociationService) Update(ctx context.Context, params HostnameAssociationUpdateParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesHostnameAssociation, err error) { + opts = append(r.Options[:], opts...) + var env HostnameAssociationUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/certificate_authorities/hostname_associations", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List Hostname Associations +func (r *HostnameAssociationService) Get(ctx context.Context, params HostnameAssociationGetParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesHostnameAssociation, err error) { + opts = append(r.Options[:], opts...) + var env HostnameAssociationGetResponseEnvelope + path := fmt.Sprintf("zones/%s/certificate_authorities/hostname_associations", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TLSCertificatesAndHostnamesHostnameAssociation struct { + Hostnames []string `json:"hostnames"` + // The UUID for a certificate that was uploaded to the mTLS Certificate Management + // endpoint. If no mtls_certificate_id is given, the hostnames will be associated + // to your active Cloudflare Managed CA. + MTLSCertificateID string `json:"mtls_certificate_id"` + JSON tlsCertificatesAndHostnamesHostnameAssociationJSON `json:"-"` +} + +// tlsCertificatesAndHostnamesHostnameAssociationJSON contains the JSON metadata +// for the struct [TLSCertificatesAndHostnamesHostnameAssociation] +type tlsCertificatesAndHostnamesHostnameAssociationJSON struct { + Hostnames apijson.Field + MTLSCertificateID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TLSCertificatesAndHostnamesHostnameAssociation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tlsCertificatesAndHostnamesHostnameAssociationJSON) RawJSON() string { + return r.raw +} + +type HostnameAssociationUpdateParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Hostnames param.Field[[]string] `json:"hostnames"` + // The UUID for a certificate that was uploaded to the mTLS Certificate Management + // endpoint. If no mtls_certificate_id is given, the hostnames will be associated + // to your active Cloudflare Managed CA. + MTLSCertificateID param.Field[string] `json:"mtls_certificate_id"` +} + +func (r HostnameAssociationUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type HostnameAssociationUpdateResponseEnvelope struct { + Errors []HostnameAssociationUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameAssociationUpdateResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesHostnameAssociation `json:"result,required"` + // Whether the API call was successful + Success HostnameAssociationUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON hostnameAssociationUpdateResponseEnvelopeJSON `json:"-"` +} + +// hostnameAssociationUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [HostnameAssociationUpdateResponseEnvelope] +type hostnameAssociationUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameAssociationUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameAssociationUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameAssociationUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameAssociationUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameAssociationUpdateResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [HostnameAssociationUpdateResponseEnvelopeErrors] +type hostnameAssociationUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameAssociationUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameAssociationUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameAssociationUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameAssociationUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameAssociationUpdateResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [HostnameAssociationUpdateResponseEnvelopeMessages] +type hostnameAssociationUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameAssociationUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameAssociationUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameAssociationUpdateResponseEnvelopeSuccess bool + +const ( + HostnameAssociationUpdateResponseEnvelopeSuccessTrue HostnameAssociationUpdateResponseEnvelopeSuccess = true +) + +type HostnameAssociationGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // The UUID to match against for a certificate that was uploaded to the mTLS + // Certificate Management endpoint. If no mtls_certificate_id is given, the results + // will be the hostnames associated to your active Cloudflare Managed CA. + MTLSCertificateID param.Field[string] `query:"mtls_certificate_id"` +} + +// URLQuery serializes [HostnameAssociationGetParams]'s query parameters as +// `url.Values`. +func (r HostnameAssociationGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type HostnameAssociationGetResponseEnvelope struct { + Errors []HostnameAssociationGetResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameAssociationGetResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesHostnameAssociation `json:"result,required"` + // Whether the API call was successful + Success HostnameAssociationGetResponseEnvelopeSuccess `json:"success,required"` + JSON hostnameAssociationGetResponseEnvelopeJSON `json:"-"` +} + +// hostnameAssociationGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [HostnameAssociationGetResponseEnvelope] +type hostnameAssociationGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameAssociationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameAssociationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameAssociationGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameAssociationGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameAssociationGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [HostnameAssociationGetResponseEnvelopeErrors] +type hostnameAssociationGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameAssociationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameAssociationGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameAssociationGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameAssociationGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameAssociationGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [HostnameAssociationGetResponseEnvelopeMessages] +type hostnameAssociationGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameAssociationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameAssociationGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameAssociationGetResponseEnvelopeSuccess bool + +const ( + HostnameAssociationGetResponseEnvelopeSuccessTrue HostnameAssociationGetResponseEnvelopeSuccess = true +) diff --git a/certificate_authorities/hostnameassociation_test.go b/certificate_authorities/hostnameassociation_test.go new file mode 100644 index 00000000000..f53be0dc82d --- /dev/null +++ b/certificate_authorities/hostnameassociation_test.go @@ -0,0 +1,70 @@ +// File generated from our OpenAPI spec by Stainless. + +package certificate_authorities_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/certificate_authorities" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestHostnameAssociationUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.CertificateAuthorities.HostnameAssociations.Update(context.TODO(), certificate_authorities.HostnameAssociationUpdateParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Hostnames: cloudflare.F([]string{"api.example.com", "api.example.com", "api.example.com"}), + MTLSCertificateID: cloudflare.F("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), + }) + 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 TestHostnameAssociationGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.CertificateAuthorities.HostnameAssociations.Get(context.TODO(), certificate_authorities.HostnameAssociationGetParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + MTLSCertificateID: cloudflare.F("b2134436-2555-4acf-be5b-26c48136575e"), + }) + 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/certificateauthorityhostnameassociation.go b/certificateauthorityhostnameassociation.go deleted file mode 100644 index d1315bdace7..00000000000 --- a/certificateauthorityhostnameassociation.go +++ /dev/null @@ -1,313 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// CertificateAuthorityHostnameAssociationService 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 [NewCertificateAuthorityHostnameAssociationService] method instead. -type CertificateAuthorityHostnameAssociationService struct { - Options []option.RequestOption -} - -// NewCertificateAuthorityHostnameAssociationService 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 NewCertificateAuthorityHostnameAssociationService(opts ...option.RequestOption) (r *CertificateAuthorityHostnameAssociationService) { - r = &CertificateAuthorityHostnameAssociationService{} - r.Options = opts - return -} - -// Replace Hostname Associations -func (r *CertificateAuthorityHostnameAssociationService) Update(ctx context.Context, params CertificateAuthorityHostnameAssociationUpdateParams, opts ...option.RequestOption) (res *CertificateAuthorityHostnameAssociationUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env CertificateAuthorityHostnameAssociationUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/certificate_authorities/hostname_associations", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List Hostname Associations -func (r *CertificateAuthorityHostnameAssociationService) Get(ctx context.Context, params CertificateAuthorityHostnameAssociationGetParams, opts ...option.RequestOption) (res *CertificateAuthorityHostnameAssociationGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env CertificateAuthorityHostnameAssociationGetResponseEnvelope - path := fmt.Sprintf("zones/%s/certificate_authorities/hostname_associations", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type CertificateAuthorityHostnameAssociationUpdateResponse struct { - Hostnames []string `json:"hostnames"` - // The UUID for a certificate that was uploaded to the mTLS Certificate Management - // endpoint. If no mtls_certificate_id is given, the hostnames will be associated - // to your active Cloudflare Managed CA. - MTLSCertificateID string `json:"mtls_certificate_id"` - JSON certificateAuthorityHostnameAssociationUpdateResponseJSON `json:"-"` -} - -// certificateAuthorityHostnameAssociationUpdateResponseJSON contains the JSON -// metadata for the struct [CertificateAuthorityHostnameAssociationUpdateResponse] -type certificateAuthorityHostnameAssociationUpdateResponseJSON struct { - Hostnames apijson.Field - MTLSCertificateID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CertificateAuthorityHostnameAssociationUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r certificateAuthorityHostnameAssociationUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type CertificateAuthorityHostnameAssociationGetResponse struct { - Hostnames []string `json:"hostnames"` - // The UUID for a certificate that was uploaded to the mTLS Certificate Management - // endpoint. If no mtls_certificate_id is given, the hostnames will be associated - // to your active Cloudflare Managed CA. - MTLSCertificateID string `json:"mtls_certificate_id"` - JSON certificateAuthorityHostnameAssociationGetResponseJSON `json:"-"` -} - -// certificateAuthorityHostnameAssociationGetResponseJSON contains the JSON -// metadata for the struct [CertificateAuthorityHostnameAssociationGetResponse] -type certificateAuthorityHostnameAssociationGetResponseJSON struct { - Hostnames apijson.Field - MTLSCertificateID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CertificateAuthorityHostnameAssociationGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r certificateAuthorityHostnameAssociationGetResponseJSON) RawJSON() string { - return r.raw -} - -type CertificateAuthorityHostnameAssociationUpdateParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Hostnames param.Field[[]string] `json:"hostnames"` - // The UUID for a certificate that was uploaded to the mTLS Certificate Management - // endpoint. If no mtls_certificate_id is given, the hostnames will be associated - // to your active Cloudflare Managed CA. - MTLSCertificateID param.Field[string] `json:"mtls_certificate_id"` -} - -func (r CertificateAuthorityHostnameAssociationUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type CertificateAuthorityHostnameAssociationUpdateResponseEnvelope struct { - Errors []CertificateAuthorityHostnameAssociationUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []CertificateAuthorityHostnameAssociationUpdateResponseEnvelopeMessages `json:"messages,required"` - Result CertificateAuthorityHostnameAssociationUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success CertificateAuthorityHostnameAssociationUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON certificateAuthorityHostnameAssociationUpdateResponseEnvelopeJSON `json:"-"` -} - -// certificateAuthorityHostnameAssociationUpdateResponseEnvelopeJSON contains the -// JSON metadata for the struct -// [CertificateAuthorityHostnameAssociationUpdateResponseEnvelope] -type certificateAuthorityHostnameAssociationUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CertificateAuthorityHostnameAssociationUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r certificateAuthorityHostnameAssociationUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CertificateAuthorityHostnameAssociationUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON certificateAuthorityHostnameAssociationUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// certificateAuthorityHostnameAssociationUpdateResponseEnvelopeErrorsJSON contains -// the JSON metadata for the struct -// [CertificateAuthorityHostnameAssociationUpdateResponseEnvelopeErrors] -type certificateAuthorityHostnameAssociationUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CertificateAuthorityHostnameAssociationUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r certificateAuthorityHostnameAssociationUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CertificateAuthorityHostnameAssociationUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON certificateAuthorityHostnameAssociationUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// certificateAuthorityHostnameAssociationUpdateResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [CertificateAuthorityHostnameAssociationUpdateResponseEnvelopeMessages] -type certificateAuthorityHostnameAssociationUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CertificateAuthorityHostnameAssociationUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r certificateAuthorityHostnameAssociationUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CertificateAuthorityHostnameAssociationUpdateResponseEnvelopeSuccess bool - -const ( - CertificateAuthorityHostnameAssociationUpdateResponseEnvelopeSuccessTrue CertificateAuthorityHostnameAssociationUpdateResponseEnvelopeSuccess = true -) - -type CertificateAuthorityHostnameAssociationGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // The UUID to match against for a certificate that was uploaded to the mTLS - // Certificate Management endpoint. If no mtls_certificate_id is given, the results - // will be the hostnames associated to your active Cloudflare Managed CA. - MTLSCertificateID param.Field[string] `query:"mtls_certificate_id"` -} - -// URLQuery serializes [CertificateAuthorityHostnameAssociationGetParams]'s query -// parameters as `url.Values`. -func (r CertificateAuthorityHostnameAssociationGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type CertificateAuthorityHostnameAssociationGetResponseEnvelope struct { - Errors []CertificateAuthorityHostnameAssociationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CertificateAuthorityHostnameAssociationGetResponseEnvelopeMessages `json:"messages,required"` - Result CertificateAuthorityHostnameAssociationGetResponse `json:"result,required"` - // Whether the API call was successful - Success CertificateAuthorityHostnameAssociationGetResponseEnvelopeSuccess `json:"success,required"` - JSON certificateAuthorityHostnameAssociationGetResponseEnvelopeJSON `json:"-"` -} - -// certificateAuthorityHostnameAssociationGetResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [CertificateAuthorityHostnameAssociationGetResponseEnvelope] -type certificateAuthorityHostnameAssociationGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CertificateAuthorityHostnameAssociationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r certificateAuthorityHostnameAssociationGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CertificateAuthorityHostnameAssociationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON certificateAuthorityHostnameAssociationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// certificateAuthorityHostnameAssociationGetResponseEnvelopeErrorsJSON contains -// the JSON metadata for the struct -// [CertificateAuthorityHostnameAssociationGetResponseEnvelopeErrors] -type certificateAuthorityHostnameAssociationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CertificateAuthorityHostnameAssociationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r certificateAuthorityHostnameAssociationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CertificateAuthorityHostnameAssociationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON certificateAuthorityHostnameAssociationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// certificateAuthorityHostnameAssociationGetResponseEnvelopeMessagesJSON contains -// the JSON metadata for the struct -// [CertificateAuthorityHostnameAssociationGetResponseEnvelopeMessages] -type certificateAuthorityHostnameAssociationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CertificateAuthorityHostnameAssociationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r certificateAuthorityHostnameAssociationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CertificateAuthorityHostnameAssociationGetResponseEnvelopeSuccess bool - -const ( - CertificateAuthorityHostnameAssociationGetResponseEnvelopeSuccessTrue CertificateAuthorityHostnameAssociationGetResponseEnvelopeSuccess = true -) diff --git a/certificateauthorityhostnameassociation_test.go b/certificateauthorityhostnameassociation_test.go deleted file mode 100644 index 446f0f594aa..00000000000 --- a/certificateauthorityhostnameassociation_test.go +++ /dev/null @@ -1,69 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestCertificateAuthorityHostnameAssociationUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.CertificateAuthorities.HostnameAssociations.Update(context.TODO(), cloudflare.CertificateAuthorityHostnameAssociationUpdateParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Hostnames: cloudflare.F([]string{"api.example.com", "api.example.com", "api.example.com"}), - MTLSCertificateID: cloudflare.F("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), - }) - 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 TestCertificateAuthorityHostnameAssociationGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.CertificateAuthorities.HostnameAssociations.Get(context.TODO(), cloudflare.CertificateAuthorityHostnameAssociationGetParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - MTLSCertificateID: cloudflare.F("b2134436-2555-4acf-be5b-26c48136575e"), - }) - 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/certificates/aliases.go b/certificates/aliases.go new file mode 100644 index 00000000000..247483de752 --- /dev/null +++ b/certificates/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package certificates + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/certificate.go b/certificates/certificate.go similarity index 98% rename from certificate.go rename to certificates/certificate.go index 5173084f3e2..8bfd2dcff68 100644 --- a/certificate.go +++ b/certificates/certificate.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package certificates import ( "context" @@ -159,9 +159,10 @@ const ( OriginCACertificateRequestedValidity5475 OriginCACertificateRequestedValidity = 5475 ) -// Union satisfied by [CertificateNewResponseUnknown] or [shared.UnionString]. +// Union satisfied by [certificates.CertificateNewResponseUnknown] or +// [shared.UnionString]. type CertificateNewResponse interface { - ImplementsCertificateNewResponse() + ImplementsCertificatesCertificateNewResponse() } func init() { @@ -197,9 +198,10 @@ func (r certificateDeleteResponseJSON) RawJSON() string { return r.raw } -// Union satisfied by [CertificateGetResponseUnknown] or [shared.UnionString]. +// Union satisfied by [certificates.CertificateGetResponseUnknown] or +// [shared.UnionString]. type CertificateGetResponse interface { - ImplementsCertificateGetResponse() + ImplementsCertificatesCertificateGetResponse() } func init() { diff --git a/certificate_test.go b/certificates/certificate_test.go similarity index 90% rename from certificate_test.go rename to certificates/certificate_test.go index 6042d295051..21ca360c70c 100644 --- a/certificate_test.go +++ b/certificates/certificate_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package certificates_test import ( "context" @@ -9,6 +9,7 @@ import ( "testing" "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/certificates" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" ) @@ -27,11 +28,11 @@ func TestCertificateNewWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Certificates.New(context.TODO(), cloudflare.CertificateNewParams{ + _, err := client.Certificates.New(context.TODO(), certificates.CertificateNewParams{ Csr: cloudflare.F("-----BEGIN CERTIFICATE REQUEST-----\nMIICxzCCAa8CAQAwSDELMAkGA1UEBhMCVVMxFjAUBgNVBAgTDVNhbiBGcmFuY2lz\nY28xCzAJBgNVBAcTAkNBMRQwEgYDVQQDEwtleGFtcGxlLm5ldDCCASIwDQYJKoZI\nhvcNAQEBBQADggEPADCCAQoCggEBALxejtu4b+jPdFeFi6OUsye8TYJQBm3WfCvL\nHu5EvijMO/4Z2TImwASbwUF7Ir8OLgH+mGlQZeqyNvGoSOMEaZVXcYfpR1hlVak8\n4GGVr+04IGfOCqaBokaBFIwzclGZbzKmLGwIQioNxGfqFm6RGYGA3be2Je2iseBc\nN8GV1wYmvYE0RR+yWweJCTJ157exyRzu7sVxaEW9F87zBQLyOnwXc64rflXslRqi\ng7F7w5IaQYOl8yvmk/jEPCAha7fkiUfEpj4N12+oPRiMvleJF98chxjD4MH39c5I\nuOslULhrWunfh7GB1jwWNA9y44H0snrf+xvoy2TcHmxvma9Eln8CAwEAAaA6MDgG\nCSqGSIb3DQEJDjErMCkwJwYDVR0RBCAwHoILZXhhbXBsZS5uZXSCD3d3dy5leGFt\ncGxlLm5ldDANBgkqhkiG9w0BAQsFAAOCAQEAcBaX6dOnI8ncARrI9ZSF2AJX+8mx\npTHY2+Y2C0VvrVDGMtbBRH8R9yMbqWtlxeeNGf//LeMkSKSFa4kbpdx226lfui8/\nauRDBTJGx2R1ccUxmLZXx4my0W5iIMxunu+kez+BDlu7bTT2io0uXMRHue4i6quH\nyc5ibxvbJMjR7dqbcanVE10/34oprzXQsJ/VmSuZNXtjbtSKDlmcpw6To/eeAJ+J\nhXykcUihvHyG4A1m2R6qpANBjnA0pHexfwM/SgfzvpbvUg0T1ubmer8BgTwCKIWs\ndcWYTthM51JIqRBfNqy4QcBnX+GY05yltEEswQI55wdiS3CjTTA67sdbcQ==\n-----END CERTIFICATE REQUEST-----"), Hostnames: cloudflare.F([]interface{}{"example.com", "*.example.com"}), - RequestType: cloudflare.F(cloudflare.CertificateNewParamsRequestTypeOriginRsa), - RequestedValidity: cloudflare.F(cloudflare.CertificateNewParamsRequestedValidity5475), + RequestType: cloudflare.F(certificates.CertificateNewParamsRequestTypeOriginRsa), + RequestedValidity: cloudflare.F(certificates.CertificateNewParamsRequestedValidity5475), }) if err != nil { var apierr *cloudflare.Error @@ -56,7 +57,7 @@ func TestCertificateList(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Certificates.List(context.TODO(), cloudflare.CertificateListParams{}) + _, err := client.Certificates.List(context.TODO(), certificates.CertificateListParams{}) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { diff --git a/challenges/aliases.go b/challenges/aliases.go new file mode 100644 index 00000000000..125f74d5e2f --- /dev/null +++ b/challenges/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package challenges + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/challenge.go b/challenges/challenge.go similarity index 89% rename from challenge.go rename to challenges/challenge.go index f427e27ac85..8564a6d38f9 100644 --- a/challenge.go +++ b/challenges/challenge.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package challenges import ( "github.com/cloudflare/cloudflare-go/option" @@ -12,7 +12,7 @@ import ( // service directly, and instead use the [NewChallengeService] method instead. type ChallengeService struct { Options []option.RequestOption - Widgets *ChallengeWidgetService + Widgets *WidgetService } // NewChallengeService generates a new service that applies the given options to @@ -21,6 +21,6 @@ type ChallengeService struct { func NewChallengeService(opts ...option.RequestOption) (r *ChallengeService) { r = &ChallengeService{} r.Options = opts - r.Widgets = NewChallengeWidgetService(opts...) + r.Widgets = NewWidgetService(opts...) return } diff --git a/challenges/widget.go b/challenges/widget.go new file mode 100644 index 00000000000..caa1ce2a150 --- /dev/null +++ b/challenges/widget.go @@ -0,0 +1,874 @@ +// File generated from our OpenAPI spec by Stainless. + +package challenges + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" +) + +// WidgetService 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 [NewWidgetService] method instead. +type WidgetService struct { + Options []option.RequestOption +} + +// NewWidgetService 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 NewWidgetService(opts ...option.RequestOption) (r *WidgetService) { + r = &WidgetService{} + r.Options = opts + return +} + +// Lists challenge widgets. +func (r *WidgetService) New(ctx context.Context, accountIdentifier string, params WidgetNewParams, opts ...option.RequestOption) (res *NcChallengesAdminWidgetDetail, err error) { + opts = append(r.Options[:], opts...) + var env WidgetNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/challenges/widgets", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update the configuration of a widget. +func (r *WidgetService) Update(ctx context.Context, accountIdentifier string, sitekey string, body WidgetUpdateParams, opts ...option.RequestOption) (res *NcChallengesAdminWidgetDetail, err error) { + opts = append(r.Options[:], opts...) + var env WidgetUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/challenges/widgets/%s", accountIdentifier, sitekey) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists all turnstile widgets of an account. +func (r *WidgetService) List(ctx context.Context, accountIdentifier string, query WidgetListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[NcChallengesAdminWidgetList], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("accounts/%s/challenges/widgets", accountIdentifier) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists all turnstile widgets of an account. +func (r *WidgetService) ListAutoPaging(ctx context.Context, accountIdentifier string, query WidgetListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[NcChallengesAdminWidgetList] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, accountIdentifier, query, opts...)) +} + +// Destroy a Turnstile Widget. +func (r *WidgetService) Delete(ctx context.Context, accountIdentifier string, sitekey string, opts ...option.RequestOption) (res *NcChallengesAdminWidgetDetail, err error) { + opts = append(r.Options[:], opts...) + var env WidgetDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/challenges/widgets/%s", accountIdentifier, sitekey) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Show a single challenge widget configuration. +func (r *WidgetService) Get(ctx context.Context, accountIdentifier string, sitekey string, opts ...option.RequestOption) (res *NcChallengesAdminWidgetDetail, err error) { + opts = append(r.Options[:], opts...) + var env WidgetGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/challenges/widgets/%s", accountIdentifier, sitekey) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Generate a new secret key for this widget. If `invalidate_immediately` is set to +// `false`, the previous secret remains valid for 2 hours. +// +// Note that secrets cannot be rotated again during the grace period. +func (r *WidgetService) RotateSecret(ctx context.Context, accountIdentifier string, sitekey string, body WidgetRotateSecretParams, opts ...option.RequestOption) (res *NcChallengesAdminWidgetDetail, err error) { + opts = append(r.Options[:], opts...) + var env WidgetRotateSecretResponseEnvelope + path := fmt.Sprintf("accounts/%s/challenges/widgets/%s/rotate_secret", accountIdentifier, sitekey) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// A Turnstile widget's detailed configuration +type NcChallengesAdminWidgetDetail struct { + // If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive + // challenges in response to malicious bots (ENT only). + BotFightMode bool `json:"bot_fight_mode,required"` + // If Turnstile is embedded on a Cloudflare site and the widget should grant + // challenge clearance, this setting can determine the clearance level to be set + ClearanceLevel NcChallengesAdminWidgetDetailClearanceLevel `json:"clearance_level,required"` + // When the widget was created. + CreatedOn time.Time `json:"created_on,required" format:"date-time"` + Domains []string `json:"domains,required"` + // Widget Mode + Mode NcChallengesAdminWidgetDetailMode `json:"mode,required"` + // When the widget was modified. + ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` + // Human readable widget name. Not unique. Cloudflare suggests that you set this to + // a meaningful string to make it easier to identify your widget, and where it is + // used. + Name string `json:"name,required"` + // Do not show any Cloudflare branding on the widget (ENT only). + Offlabel bool `json:"offlabel,required"` + // Region where this widget can be used. + Region NcChallengesAdminWidgetDetailRegion `json:"region,required"` + // Secret key for this widget. + Secret string `json:"secret,required"` + // Widget item identifier tag. + Sitekey string `json:"sitekey,required"` + JSON ncChallengesAdminWidgetDetailJSON `json:"-"` +} + +// ncChallengesAdminWidgetDetailJSON contains the JSON metadata for the struct +// [NcChallengesAdminWidgetDetail] +type ncChallengesAdminWidgetDetailJSON struct { + BotFightMode apijson.Field + ClearanceLevel apijson.Field + CreatedOn apijson.Field + Domains apijson.Field + Mode apijson.Field + ModifiedOn apijson.Field + Name apijson.Field + Offlabel apijson.Field + Region apijson.Field + Secret apijson.Field + Sitekey apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NcChallengesAdminWidgetDetail) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ncChallengesAdminWidgetDetailJSON) RawJSON() string { + return r.raw +} + +// If Turnstile is embedded on a Cloudflare site and the widget should grant +// challenge clearance, this setting can determine the clearance level to be set +type NcChallengesAdminWidgetDetailClearanceLevel string + +const ( + NcChallengesAdminWidgetDetailClearanceLevelNoClearance NcChallengesAdminWidgetDetailClearanceLevel = "no_clearance" + NcChallengesAdminWidgetDetailClearanceLevelJschallenge NcChallengesAdminWidgetDetailClearanceLevel = "jschallenge" + NcChallengesAdminWidgetDetailClearanceLevelManaged NcChallengesAdminWidgetDetailClearanceLevel = "managed" + NcChallengesAdminWidgetDetailClearanceLevelInteractive NcChallengesAdminWidgetDetailClearanceLevel = "interactive" +) + +// Widget Mode +type NcChallengesAdminWidgetDetailMode string + +const ( + NcChallengesAdminWidgetDetailModeNonInteractive NcChallengesAdminWidgetDetailMode = "non-interactive" + NcChallengesAdminWidgetDetailModeInvisible NcChallengesAdminWidgetDetailMode = "invisible" + NcChallengesAdminWidgetDetailModeManaged NcChallengesAdminWidgetDetailMode = "managed" +) + +// Region where this widget can be used. +type NcChallengesAdminWidgetDetailRegion string + +const ( + NcChallengesAdminWidgetDetailRegionWorld NcChallengesAdminWidgetDetailRegion = "world" +) + +// A Turnstile Widgets configuration as it appears in listings +type NcChallengesAdminWidgetList struct { + // If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive + // challenges in response to malicious bots (ENT only). + BotFightMode bool `json:"bot_fight_mode,required"` + // If Turnstile is embedded on a Cloudflare site and the widget should grant + // challenge clearance, this setting can determine the clearance level to be set + ClearanceLevel NcChallengesAdminWidgetListClearanceLevel `json:"clearance_level,required"` + // When the widget was created. + CreatedOn time.Time `json:"created_on,required" format:"date-time"` + Domains []string `json:"domains,required"` + // Widget Mode + Mode NcChallengesAdminWidgetListMode `json:"mode,required"` + // When the widget was modified. + ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` + // Human readable widget name. Not unique. Cloudflare suggests that you set this to + // a meaningful string to make it easier to identify your widget, and where it is + // used. + Name string `json:"name,required"` + // Do not show any Cloudflare branding on the widget (ENT only). + Offlabel bool `json:"offlabel,required"` + // Region where this widget can be used. + Region NcChallengesAdminWidgetListRegion `json:"region,required"` + // Widget item identifier tag. + Sitekey string `json:"sitekey,required"` + JSON ncChallengesAdminWidgetListJSON `json:"-"` +} + +// ncChallengesAdminWidgetListJSON contains the JSON metadata for the struct +// [NcChallengesAdminWidgetList] +type ncChallengesAdminWidgetListJSON struct { + BotFightMode apijson.Field + ClearanceLevel apijson.Field + CreatedOn apijson.Field + Domains apijson.Field + Mode apijson.Field + ModifiedOn apijson.Field + Name apijson.Field + Offlabel apijson.Field + Region apijson.Field + Sitekey apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NcChallengesAdminWidgetList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ncChallengesAdminWidgetListJSON) RawJSON() string { + return r.raw +} + +// If Turnstile is embedded on a Cloudflare site and the widget should grant +// challenge clearance, this setting can determine the clearance level to be set +type NcChallengesAdminWidgetListClearanceLevel string + +const ( + NcChallengesAdminWidgetListClearanceLevelNoClearance NcChallengesAdminWidgetListClearanceLevel = "no_clearance" + NcChallengesAdminWidgetListClearanceLevelJschallenge NcChallengesAdminWidgetListClearanceLevel = "jschallenge" + NcChallengesAdminWidgetListClearanceLevelManaged NcChallengesAdminWidgetListClearanceLevel = "managed" + NcChallengesAdminWidgetListClearanceLevelInteractive NcChallengesAdminWidgetListClearanceLevel = "interactive" +) + +// Widget Mode +type NcChallengesAdminWidgetListMode string + +const ( + NcChallengesAdminWidgetListModeNonInteractive NcChallengesAdminWidgetListMode = "non-interactive" + NcChallengesAdminWidgetListModeInvisible NcChallengesAdminWidgetListMode = "invisible" + NcChallengesAdminWidgetListModeManaged NcChallengesAdminWidgetListMode = "managed" +) + +// Region where this widget can be used. +type NcChallengesAdminWidgetListRegion string + +const ( + NcChallengesAdminWidgetListRegionWorld NcChallengesAdminWidgetListRegion = "world" +) + +type WidgetNewParams struct { + Domains param.Field[[]string] `json:"domains,required"` + // Widget Mode + Mode param.Field[WidgetNewParamsMode] `json:"mode,required"` + // Human readable widget name. Not unique. Cloudflare suggests that you set this to + // a meaningful string to make it easier to identify your widget, and where it is + // used. + Name param.Field[string] `json:"name,required"` + // Direction to order widgets. + Direction param.Field[WidgetNewParamsDirection] `query:"direction"` + // Field to order widgets by. + Order param.Field[WidgetNewParamsOrder] `query:"order"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // Number of items per page. + PerPage param.Field[float64] `query:"per_page"` + // If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive + // challenges in response to malicious bots (ENT only). + BotFightMode param.Field[bool] `json:"bot_fight_mode"` + // If Turnstile is embedded on a Cloudflare site and the widget should grant + // challenge clearance, this setting can determine the clearance level to be set + ClearanceLevel param.Field[WidgetNewParamsClearanceLevel] `json:"clearance_level"` + // Do not show any Cloudflare branding on the widget (ENT only). + Offlabel param.Field[bool] `json:"offlabel"` + // Region where this widget can be used. + Region param.Field[WidgetNewParamsRegion] `json:"region"` +} + +func (r WidgetNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// URLQuery serializes [WidgetNewParams]'s query parameters as `url.Values`. +func (r WidgetNewParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Widget Mode +type WidgetNewParamsMode string + +const ( + WidgetNewParamsModeNonInteractive WidgetNewParamsMode = "non-interactive" + WidgetNewParamsModeInvisible WidgetNewParamsMode = "invisible" + WidgetNewParamsModeManaged WidgetNewParamsMode = "managed" +) + +// Direction to order widgets. +type WidgetNewParamsDirection string + +const ( + WidgetNewParamsDirectionAsc WidgetNewParamsDirection = "asc" + WidgetNewParamsDirectionDesc WidgetNewParamsDirection = "desc" +) + +// Field to order widgets by. +type WidgetNewParamsOrder string + +const ( + WidgetNewParamsOrderID WidgetNewParamsOrder = "id" + WidgetNewParamsOrderSitekey WidgetNewParamsOrder = "sitekey" + WidgetNewParamsOrderName WidgetNewParamsOrder = "name" + WidgetNewParamsOrderCreatedOn WidgetNewParamsOrder = "created_on" + WidgetNewParamsOrderModifiedOn WidgetNewParamsOrder = "modified_on" +) + +// If Turnstile is embedded on a Cloudflare site and the widget should grant +// challenge clearance, this setting can determine the clearance level to be set +type WidgetNewParamsClearanceLevel string + +const ( + WidgetNewParamsClearanceLevelNoClearance WidgetNewParamsClearanceLevel = "no_clearance" + WidgetNewParamsClearanceLevelJschallenge WidgetNewParamsClearanceLevel = "jschallenge" + WidgetNewParamsClearanceLevelManaged WidgetNewParamsClearanceLevel = "managed" + WidgetNewParamsClearanceLevelInteractive WidgetNewParamsClearanceLevel = "interactive" +) + +// Region where this widget can be used. +type WidgetNewParamsRegion string + +const ( + WidgetNewParamsRegionWorld WidgetNewParamsRegion = "world" +) + +type WidgetNewResponseEnvelope struct { + Errors []WidgetNewResponseEnvelopeErrors `json:"errors,required"` + Messages []WidgetNewResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // A Turnstile widget's detailed configuration + Result NcChallengesAdminWidgetDetail `json:"result"` + ResultInfo WidgetNewResponseEnvelopeResultInfo `json:"result_info"` + JSON widgetNewResponseEnvelopeJSON `json:"-"` +} + +// widgetNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [WidgetNewResponseEnvelope] +type widgetNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + ResultInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WidgetNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r widgetNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WidgetNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON widgetNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// widgetNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [WidgetNewResponseEnvelopeErrors] +type widgetNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WidgetNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r widgetNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WidgetNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON widgetNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// widgetNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [WidgetNewResponseEnvelopeMessages] +type widgetNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WidgetNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r widgetNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type WidgetNewResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count,required"` + // Current page within paginated list of results + Page float64 `json:"page,required"` + // Number of results per page of results + PerPage float64 `json:"per_page,required"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count,required"` + JSON widgetNewResponseEnvelopeResultInfoJSON `json:"-"` +} + +// widgetNewResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [WidgetNewResponseEnvelopeResultInfo] +type widgetNewResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WidgetNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r widgetNewResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type WidgetUpdateParams struct { + Domains param.Field[[]string] `json:"domains,required"` + // Widget Mode + Mode param.Field[WidgetUpdateParamsMode] `json:"mode,required"` + // Human readable widget name. Not unique. Cloudflare suggests that you set this to + // a meaningful string to make it easier to identify your widget, and where it is + // used. + Name param.Field[string] `json:"name,required"` + // If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive + // challenges in response to malicious bots (ENT only). + BotFightMode param.Field[bool] `json:"bot_fight_mode"` + // If Turnstile is embedded on a Cloudflare site and the widget should grant + // challenge clearance, this setting can determine the clearance level to be set + ClearanceLevel param.Field[WidgetUpdateParamsClearanceLevel] `json:"clearance_level"` + // Do not show any Cloudflare branding on the widget (ENT only). + Offlabel param.Field[bool] `json:"offlabel"` +} + +func (r WidgetUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Widget Mode +type WidgetUpdateParamsMode string + +const ( + WidgetUpdateParamsModeNonInteractive WidgetUpdateParamsMode = "non-interactive" + WidgetUpdateParamsModeInvisible WidgetUpdateParamsMode = "invisible" + WidgetUpdateParamsModeManaged WidgetUpdateParamsMode = "managed" +) + +// If Turnstile is embedded on a Cloudflare site and the widget should grant +// challenge clearance, this setting can determine the clearance level to be set +type WidgetUpdateParamsClearanceLevel string + +const ( + WidgetUpdateParamsClearanceLevelNoClearance WidgetUpdateParamsClearanceLevel = "no_clearance" + WidgetUpdateParamsClearanceLevelJschallenge WidgetUpdateParamsClearanceLevel = "jschallenge" + WidgetUpdateParamsClearanceLevelManaged WidgetUpdateParamsClearanceLevel = "managed" + WidgetUpdateParamsClearanceLevelInteractive WidgetUpdateParamsClearanceLevel = "interactive" +) + +type WidgetUpdateResponseEnvelope struct { + Errors []WidgetUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []WidgetUpdateResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // A Turnstile widget's detailed configuration + Result NcChallengesAdminWidgetDetail `json:"result"` + JSON widgetUpdateResponseEnvelopeJSON `json:"-"` +} + +// widgetUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [WidgetUpdateResponseEnvelope] +type widgetUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WidgetUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r widgetUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WidgetUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON widgetUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// widgetUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [WidgetUpdateResponseEnvelopeErrors] +type widgetUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WidgetUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r widgetUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WidgetUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON widgetUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// widgetUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [WidgetUpdateResponseEnvelopeMessages] +type widgetUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WidgetUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r widgetUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type WidgetListParams struct { + // Direction to order widgets. + Direction param.Field[WidgetListParamsDirection] `query:"direction"` + // Field to order widgets by. + Order param.Field[WidgetListParamsOrder] `query:"order"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // Number of items per page. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [WidgetListParams]'s query parameters as `url.Values`. +func (r WidgetListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Direction to order widgets. +type WidgetListParamsDirection string + +const ( + WidgetListParamsDirectionAsc WidgetListParamsDirection = "asc" + WidgetListParamsDirectionDesc WidgetListParamsDirection = "desc" +) + +// Field to order widgets by. +type WidgetListParamsOrder string + +const ( + WidgetListParamsOrderID WidgetListParamsOrder = "id" + WidgetListParamsOrderSitekey WidgetListParamsOrder = "sitekey" + WidgetListParamsOrderName WidgetListParamsOrder = "name" + WidgetListParamsOrderCreatedOn WidgetListParamsOrder = "created_on" + WidgetListParamsOrderModifiedOn WidgetListParamsOrder = "modified_on" +) + +type WidgetDeleteResponseEnvelope struct { + Errors []WidgetDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []WidgetDeleteResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // A Turnstile widget's detailed configuration + Result NcChallengesAdminWidgetDetail `json:"result"` + JSON widgetDeleteResponseEnvelopeJSON `json:"-"` +} + +// widgetDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [WidgetDeleteResponseEnvelope] +type widgetDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WidgetDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r widgetDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WidgetDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON widgetDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// widgetDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [WidgetDeleteResponseEnvelopeErrors] +type widgetDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WidgetDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r widgetDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WidgetDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON widgetDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// widgetDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [WidgetDeleteResponseEnvelopeMessages] +type widgetDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WidgetDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r widgetDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type WidgetGetResponseEnvelope struct { + Errors []WidgetGetResponseEnvelopeErrors `json:"errors,required"` + Messages []WidgetGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // A Turnstile widget's detailed configuration + Result NcChallengesAdminWidgetDetail `json:"result"` + JSON widgetGetResponseEnvelopeJSON `json:"-"` +} + +// widgetGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [WidgetGetResponseEnvelope] +type widgetGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WidgetGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r widgetGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WidgetGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON widgetGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// widgetGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [WidgetGetResponseEnvelopeErrors] +type widgetGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WidgetGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r widgetGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WidgetGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON widgetGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// widgetGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [WidgetGetResponseEnvelopeMessages] +type widgetGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WidgetGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r widgetGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type WidgetRotateSecretParams struct { + // If `invalidate_immediately` is set to `false`, the previous secret will remain + // valid for two hours. Otherwise, the secret is immediately invalidated, and + // requests using it will be rejected. + InvalidateImmediately param.Field[bool] `json:"invalidate_immediately"` +} + +func (r WidgetRotateSecretParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type WidgetRotateSecretResponseEnvelope struct { + Errors []WidgetRotateSecretResponseEnvelopeErrors `json:"errors,required"` + Messages []WidgetRotateSecretResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // A Turnstile widget's detailed configuration + Result NcChallengesAdminWidgetDetail `json:"result"` + JSON widgetRotateSecretResponseEnvelopeJSON `json:"-"` +} + +// widgetRotateSecretResponseEnvelopeJSON contains the JSON metadata for the struct +// [WidgetRotateSecretResponseEnvelope] +type widgetRotateSecretResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WidgetRotateSecretResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r widgetRotateSecretResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WidgetRotateSecretResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON widgetRotateSecretResponseEnvelopeErrorsJSON `json:"-"` +} + +// widgetRotateSecretResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [WidgetRotateSecretResponseEnvelopeErrors] +type widgetRotateSecretResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WidgetRotateSecretResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r widgetRotateSecretResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WidgetRotateSecretResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON widgetRotateSecretResponseEnvelopeMessagesJSON `json:"-"` +} + +// widgetRotateSecretResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [WidgetRotateSecretResponseEnvelopeMessages] +type widgetRotateSecretResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WidgetRotateSecretResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r widgetRotateSecretResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/challenges/widget_test.go b/challenges/widget_test.go new file mode 100644 index 00000000000..96dbf873020 --- /dev/null +++ b/challenges/widget_test.go @@ -0,0 +1,211 @@ +// File generated from our OpenAPI spec by Stainless. + +package challenges_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/challenges" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestWidgetNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Challenges.Widgets.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + challenges.WidgetNewParams{ + Domains: cloudflare.F([]string{"203.0.113.1", "cloudflare.com", "blog.example.com"}), + Mode: cloudflare.F(challenges.WidgetNewParamsModeInvisible), + Name: cloudflare.F("blog.cloudflare.com login form"), + Direction: cloudflare.F(challenges.WidgetNewParamsDirectionAsc), + Order: cloudflare.F(challenges.WidgetNewParamsOrderID), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(5.000000), + BotFightMode: cloudflare.F(true), + ClearanceLevel: cloudflare.F(challenges.WidgetNewParamsClearanceLevelInteractive), + Offlabel: cloudflare.F(true), + Region: cloudflare.F(challenges.WidgetNewParamsRegionWorld), + }, + ) + 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 TestWidgetUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Challenges.Widgets.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "0x4AAF00AAAABn0R22HWm-YUc", + challenges.WidgetUpdateParams{ + Domains: cloudflare.F([]string{"203.0.113.1", "cloudflare.com", "blog.example.com"}), + Mode: cloudflare.F(challenges.WidgetUpdateParamsModeInvisible), + Name: cloudflare.F("blog.cloudflare.com login form"), + BotFightMode: cloudflare.F(true), + ClearanceLevel: cloudflare.F(challenges.WidgetUpdateParamsClearanceLevelInteractive), + Offlabel: cloudflare.F(true), + }, + ) + 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 TestWidgetListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Challenges.Widgets.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + challenges.WidgetListParams{ + Direction: cloudflare.F(challenges.WidgetListParamsDirectionAsc), + Order: cloudflare.F(challenges.WidgetListParamsOrderID), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(5.000000), + }, + ) + 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 TestWidgetDelete(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("user@example.com"), + ) + _, err := client.Challenges.Widgets.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "0x4AAF00AAAABn0R22HWm-YUc", + ) + 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 TestWidgetGet(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("user@example.com"), + ) + _, err := client.Challenges.Widgets.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "0x4AAF00AAAABn0R22HWm-YUc", + ) + 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 TestWidgetRotateSecretWithOptionalParams(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("user@example.com"), + ) + _, err := client.Challenges.Widgets.RotateSecret( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "0x4AAF00AAAABn0R22HWm-YUc", + challenges.WidgetRotateSecretParams{ + InvalidateImmediately: cloudflare.F(true), + }, + ) + 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/challengewidget.go b/challengewidget.go deleted file mode 100644 index 12157a91d90..00000000000 --- a/challengewidget.go +++ /dev/null @@ -1,1209 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" -) - -// ChallengeWidgetService 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 [NewChallengeWidgetService] method -// instead. -type ChallengeWidgetService struct { - Options []option.RequestOption -} - -// NewChallengeWidgetService 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 NewChallengeWidgetService(opts ...option.RequestOption) (r *ChallengeWidgetService) { - r = &ChallengeWidgetService{} - r.Options = opts - return -} - -// Lists challenge widgets. -func (r *ChallengeWidgetService) New(ctx context.Context, accountIdentifier string, params ChallengeWidgetNewParams, opts ...option.RequestOption) (res *ChallengeWidgetNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ChallengeWidgetNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/challenges/widgets", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update the configuration of a widget. -func (r *ChallengeWidgetService) Update(ctx context.Context, accountIdentifier string, sitekey string, body ChallengeWidgetUpdateParams, opts ...option.RequestOption) (res *ChallengeWidgetUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ChallengeWidgetUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/challenges/widgets/%s", accountIdentifier, sitekey) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists all turnstile widgets of an account. -func (r *ChallengeWidgetService) List(ctx context.Context, accountIdentifier string, query ChallengeWidgetListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[ChallengeWidgetListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("accounts/%s/challenges/widgets", accountIdentifier) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Lists all turnstile widgets of an account. -func (r *ChallengeWidgetService) ListAutoPaging(ctx context.Context, accountIdentifier string, query ChallengeWidgetListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[ChallengeWidgetListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, accountIdentifier, query, opts...)) -} - -// Destroy a Turnstile Widget. -func (r *ChallengeWidgetService) Delete(ctx context.Context, accountIdentifier string, sitekey string, opts ...option.RequestOption) (res *ChallengeWidgetDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ChallengeWidgetDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/challenges/widgets/%s", accountIdentifier, sitekey) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Show a single challenge widget configuration. -func (r *ChallengeWidgetService) Get(ctx context.Context, accountIdentifier string, sitekey string, opts ...option.RequestOption) (res *ChallengeWidgetGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ChallengeWidgetGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/challenges/widgets/%s", accountIdentifier, sitekey) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Generate a new secret key for this widget. If `invalidate_immediately` is set to -// `false`, the previous secret remains valid for 2 hours. -// -// Note that secrets cannot be rotated again during the grace period. -func (r *ChallengeWidgetService) RotateSecret(ctx context.Context, accountIdentifier string, sitekey string, body ChallengeWidgetRotateSecretParams, opts ...option.RequestOption) (res *ChallengeWidgetRotateSecretResponse, err error) { - opts = append(r.Options[:], opts...) - var env ChallengeWidgetRotateSecretResponseEnvelope - path := fmt.Sprintf("accounts/%s/challenges/widgets/%s/rotate_secret", accountIdentifier, sitekey) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// A Turnstile widget's detailed configuration -type ChallengeWidgetNewResponse struct { - // If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive - // challenges in response to malicious bots (ENT only). - BotFightMode bool `json:"bot_fight_mode,required"` - // If Turnstile is embedded on a Cloudflare site and the widget should grant - // challenge clearance, this setting can determine the clearance level to be set - ClearanceLevel ChallengeWidgetNewResponseClearanceLevel `json:"clearance_level,required"` - // When the widget was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - Domains []string `json:"domains,required"` - // Widget Mode - Mode ChallengeWidgetNewResponseMode `json:"mode,required"` - // When the widget was modified. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // Human readable widget name. Not unique. Cloudflare suggests that you set this to - // a meaningful string to make it easier to identify your widget, and where it is - // used. - Name string `json:"name,required"` - // Do not show any Cloudflare branding on the widget (ENT only). - Offlabel bool `json:"offlabel,required"` - // Region where this widget can be used. - Region ChallengeWidgetNewResponseRegion `json:"region,required"` - // Secret key for this widget. - Secret string `json:"secret,required"` - // Widget item identifier tag. - Sitekey string `json:"sitekey,required"` - JSON challengeWidgetNewResponseJSON `json:"-"` -} - -// challengeWidgetNewResponseJSON contains the JSON metadata for the struct -// [ChallengeWidgetNewResponse] -type challengeWidgetNewResponseJSON struct { - BotFightMode apijson.Field - ClearanceLevel apijson.Field - CreatedOn apijson.Field - Domains apijson.Field - Mode apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Offlabel apijson.Field - Region apijson.Field - Secret apijson.Field - Sitekey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetNewResponseJSON) RawJSON() string { - return r.raw -} - -// If Turnstile is embedded on a Cloudflare site and the widget should grant -// challenge clearance, this setting can determine the clearance level to be set -type ChallengeWidgetNewResponseClearanceLevel string - -const ( - ChallengeWidgetNewResponseClearanceLevelNoClearance ChallengeWidgetNewResponseClearanceLevel = "no_clearance" - ChallengeWidgetNewResponseClearanceLevelJschallenge ChallengeWidgetNewResponseClearanceLevel = "jschallenge" - ChallengeWidgetNewResponseClearanceLevelManaged ChallengeWidgetNewResponseClearanceLevel = "managed" - ChallengeWidgetNewResponseClearanceLevelInteractive ChallengeWidgetNewResponseClearanceLevel = "interactive" -) - -// Widget Mode -type ChallengeWidgetNewResponseMode string - -const ( - ChallengeWidgetNewResponseModeNonInteractive ChallengeWidgetNewResponseMode = "non-interactive" - ChallengeWidgetNewResponseModeInvisible ChallengeWidgetNewResponseMode = "invisible" - ChallengeWidgetNewResponseModeManaged ChallengeWidgetNewResponseMode = "managed" -) - -// Region where this widget can be used. -type ChallengeWidgetNewResponseRegion string - -const ( - ChallengeWidgetNewResponseRegionWorld ChallengeWidgetNewResponseRegion = "world" -) - -// A Turnstile widget's detailed configuration -type ChallengeWidgetUpdateResponse struct { - // If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive - // challenges in response to malicious bots (ENT only). - BotFightMode bool `json:"bot_fight_mode,required"` - // If Turnstile is embedded on a Cloudflare site and the widget should grant - // challenge clearance, this setting can determine the clearance level to be set - ClearanceLevel ChallengeWidgetUpdateResponseClearanceLevel `json:"clearance_level,required"` - // When the widget was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - Domains []string `json:"domains,required"` - // Widget Mode - Mode ChallengeWidgetUpdateResponseMode `json:"mode,required"` - // When the widget was modified. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // Human readable widget name. Not unique. Cloudflare suggests that you set this to - // a meaningful string to make it easier to identify your widget, and where it is - // used. - Name string `json:"name,required"` - // Do not show any Cloudflare branding on the widget (ENT only). - Offlabel bool `json:"offlabel,required"` - // Region where this widget can be used. - Region ChallengeWidgetUpdateResponseRegion `json:"region,required"` - // Secret key for this widget. - Secret string `json:"secret,required"` - // Widget item identifier tag. - Sitekey string `json:"sitekey,required"` - JSON challengeWidgetUpdateResponseJSON `json:"-"` -} - -// challengeWidgetUpdateResponseJSON contains the JSON metadata for the struct -// [ChallengeWidgetUpdateResponse] -type challengeWidgetUpdateResponseJSON struct { - BotFightMode apijson.Field - ClearanceLevel apijson.Field - CreatedOn apijson.Field - Domains apijson.Field - Mode apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Offlabel apijson.Field - Region apijson.Field - Secret apijson.Field - Sitekey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// If Turnstile is embedded on a Cloudflare site and the widget should grant -// challenge clearance, this setting can determine the clearance level to be set -type ChallengeWidgetUpdateResponseClearanceLevel string - -const ( - ChallengeWidgetUpdateResponseClearanceLevelNoClearance ChallengeWidgetUpdateResponseClearanceLevel = "no_clearance" - ChallengeWidgetUpdateResponseClearanceLevelJschallenge ChallengeWidgetUpdateResponseClearanceLevel = "jschallenge" - ChallengeWidgetUpdateResponseClearanceLevelManaged ChallengeWidgetUpdateResponseClearanceLevel = "managed" - ChallengeWidgetUpdateResponseClearanceLevelInteractive ChallengeWidgetUpdateResponseClearanceLevel = "interactive" -) - -// Widget Mode -type ChallengeWidgetUpdateResponseMode string - -const ( - ChallengeWidgetUpdateResponseModeNonInteractive ChallengeWidgetUpdateResponseMode = "non-interactive" - ChallengeWidgetUpdateResponseModeInvisible ChallengeWidgetUpdateResponseMode = "invisible" - ChallengeWidgetUpdateResponseModeManaged ChallengeWidgetUpdateResponseMode = "managed" -) - -// Region where this widget can be used. -type ChallengeWidgetUpdateResponseRegion string - -const ( - ChallengeWidgetUpdateResponseRegionWorld ChallengeWidgetUpdateResponseRegion = "world" -) - -// A Turnstile Widgets configuration as it appears in listings -type ChallengeWidgetListResponse struct { - // If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive - // challenges in response to malicious bots (ENT only). - BotFightMode bool `json:"bot_fight_mode,required"` - // If Turnstile is embedded on a Cloudflare site and the widget should grant - // challenge clearance, this setting can determine the clearance level to be set - ClearanceLevel ChallengeWidgetListResponseClearanceLevel `json:"clearance_level,required"` - // When the widget was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - Domains []string `json:"domains,required"` - // Widget Mode - Mode ChallengeWidgetListResponseMode `json:"mode,required"` - // When the widget was modified. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // Human readable widget name. Not unique. Cloudflare suggests that you set this to - // a meaningful string to make it easier to identify your widget, and where it is - // used. - Name string `json:"name,required"` - // Do not show any Cloudflare branding on the widget (ENT only). - Offlabel bool `json:"offlabel,required"` - // Region where this widget can be used. - Region ChallengeWidgetListResponseRegion `json:"region,required"` - // Widget item identifier tag. - Sitekey string `json:"sitekey,required"` - JSON challengeWidgetListResponseJSON `json:"-"` -} - -// challengeWidgetListResponseJSON contains the JSON metadata for the struct -// [ChallengeWidgetListResponse] -type challengeWidgetListResponseJSON struct { - BotFightMode apijson.Field - ClearanceLevel apijson.Field - CreatedOn apijson.Field - Domains apijson.Field - Mode apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Offlabel apijson.Field - Region apijson.Field - Sitekey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetListResponseJSON) RawJSON() string { - return r.raw -} - -// If Turnstile is embedded on a Cloudflare site and the widget should grant -// challenge clearance, this setting can determine the clearance level to be set -type ChallengeWidgetListResponseClearanceLevel string - -const ( - ChallengeWidgetListResponseClearanceLevelNoClearance ChallengeWidgetListResponseClearanceLevel = "no_clearance" - ChallengeWidgetListResponseClearanceLevelJschallenge ChallengeWidgetListResponseClearanceLevel = "jschallenge" - ChallengeWidgetListResponseClearanceLevelManaged ChallengeWidgetListResponseClearanceLevel = "managed" - ChallengeWidgetListResponseClearanceLevelInteractive ChallengeWidgetListResponseClearanceLevel = "interactive" -) - -// Widget Mode -type ChallengeWidgetListResponseMode string - -const ( - ChallengeWidgetListResponseModeNonInteractive ChallengeWidgetListResponseMode = "non-interactive" - ChallengeWidgetListResponseModeInvisible ChallengeWidgetListResponseMode = "invisible" - ChallengeWidgetListResponseModeManaged ChallengeWidgetListResponseMode = "managed" -) - -// Region where this widget can be used. -type ChallengeWidgetListResponseRegion string - -const ( - ChallengeWidgetListResponseRegionWorld ChallengeWidgetListResponseRegion = "world" -) - -// A Turnstile widget's detailed configuration -type ChallengeWidgetDeleteResponse struct { - // If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive - // challenges in response to malicious bots (ENT only). - BotFightMode bool `json:"bot_fight_mode,required"` - // If Turnstile is embedded on a Cloudflare site and the widget should grant - // challenge clearance, this setting can determine the clearance level to be set - ClearanceLevel ChallengeWidgetDeleteResponseClearanceLevel `json:"clearance_level,required"` - // When the widget was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - Domains []string `json:"domains,required"` - // Widget Mode - Mode ChallengeWidgetDeleteResponseMode `json:"mode,required"` - // When the widget was modified. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // Human readable widget name. Not unique. Cloudflare suggests that you set this to - // a meaningful string to make it easier to identify your widget, and where it is - // used. - Name string `json:"name,required"` - // Do not show any Cloudflare branding on the widget (ENT only). - Offlabel bool `json:"offlabel,required"` - // Region where this widget can be used. - Region ChallengeWidgetDeleteResponseRegion `json:"region,required"` - // Secret key for this widget. - Secret string `json:"secret,required"` - // Widget item identifier tag. - Sitekey string `json:"sitekey,required"` - JSON challengeWidgetDeleteResponseJSON `json:"-"` -} - -// challengeWidgetDeleteResponseJSON contains the JSON metadata for the struct -// [ChallengeWidgetDeleteResponse] -type challengeWidgetDeleteResponseJSON struct { - BotFightMode apijson.Field - ClearanceLevel apijson.Field - CreatedOn apijson.Field - Domains apijson.Field - Mode apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Offlabel apijson.Field - Region apijson.Field - Secret apijson.Field - Sitekey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// If Turnstile is embedded on a Cloudflare site and the widget should grant -// challenge clearance, this setting can determine the clearance level to be set -type ChallengeWidgetDeleteResponseClearanceLevel string - -const ( - ChallengeWidgetDeleteResponseClearanceLevelNoClearance ChallengeWidgetDeleteResponseClearanceLevel = "no_clearance" - ChallengeWidgetDeleteResponseClearanceLevelJschallenge ChallengeWidgetDeleteResponseClearanceLevel = "jschallenge" - ChallengeWidgetDeleteResponseClearanceLevelManaged ChallengeWidgetDeleteResponseClearanceLevel = "managed" - ChallengeWidgetDeleteResponseClearanceLevelInteractive ChallengeWidgetDeleteResponseClearanceLevel = "interactive" -) - -// Widget Mode -type ChallengeWidgetDeleteResponseMode string - -const ( - ChallengeWidgetDeleteResponseModeNonInteractive ChallengeWidgetDeleteResponseMode = "non-interactive" - ChallengeWidgetDeleteResponseModeInvisible ChallengeWidgetDeleteResponseMode = "invisible" - ChallengeWidgetDeleteResponseModeManaged ChallengeWidgetDeleteResponseMode = "managed" -) - -// Region where this widget can be used. -type ChallengeWidgetDeleteResponseRegion string - -const ( - ChallengeWidgetDeleteResponseRegionWorld ChallengeWidgetDeleteResponseRegion = "world" -) - -// A Turnstile widget's detailed configuration -type ChallengeWidgetGetResponse struct { - // If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive - // challenges in response to malicious bots (ENT only). - BotFightMode bool `json:"bot_fight_mode,required"` - // If Turnstile is embedded on a Cloudflare site and the widget should grant - // challenge clearance, this setting can determine the clearance level to be set - ClearanceLevel ChallengeWidgetGetResponseClearanceLevel `json:"clearance_level,required"` - // When the widget was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - Domains []string `json:"domains,required"` - // Widget Mode - Mode ChallengeWidgetGetResponseMode `json:"mode,required"` - // When the widget was modified. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // Human readable widget name. Not unique. Cloudflare suggests that you set this to - // a meaningful string to make it easier to identify your widget, and where it is - // used. - Name string `json:"name,required"` - // Do not show any Cloudflare branding on the widget (ENT only). - Offlabel bool `json:"offlabel,required"` - // Region where this widget can be used. - Region ChallengeWidgetGetResponseRegion `json:"region,required"` - // Secret key for this widget. - Secret string `json:"secret,required"` - // Widget item identifier tag. - Sitekey string `json:"sitekey,required"` - JSON challengeWidgetGetResponseJSON `json:"-"` -} - -// challengeWidgetGetResponseJSON contains the JSON metadata for the struct -// [ChallengeWidgetGetResponse] -type challengeWidgetGetResponseJSON struct { - BotFightMode apijson.Field - ClearanceLevel apijson.Field - CreatedOn apijson.Field - Domains apijson.Field - Mode apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Offlabel apijson.Field - Region apijson.Field - Secret apijson.Field - Sitekey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetGetResponseJSON) RawJSON() string { - return r.raw -} - -// If Turnstile is embedded on a Cloudflare site and the widget should grant -// challenge clearance, this setting can determine the clearance level to be set -type ChallengeWidgetGetResponseClearanceLevel string - -const ( - ChallengeWidgetGetResponseClearanceLevelNoClearance ChallengeWidgetGetResponseClearanceLevel = "no_clearance" - ChallengeWidgetGetResponseClearanceLevelJschallenge ChallengeWidgetGetResponseClearanceLevel = "jschallenge" - ChallengeWidgetGetResponseClearanceLevelManaged ChallengeWidgetGetResponseClearanceLevel = "managed" - ChallengeWidgetGetResponseClearanceLevelInteractive ChallengeWidgetGetResponseClearanceLevel = "interactive" -) - -// Widget Mode -type ChallengeWidgetGetResponseMode string - -const ( - ChallengeWidgetGetResponseModeNonInteractive ChallengeWidgetGetResponseMode = "non-interactive" - ChallengeWidgetGetResponseModeInvisible ChallengeWidgetGetResponseMode = "invisible" - ChallengeWidgetGetResponseModeManaged ChallengeWidgetGetResponseMode = "managed" -) - -// Region where this widget can be used. -type ChallengeWidgetGetResponseRegion string - -const ( - ChallengeWidgetGetResponseRegionWorld ChallengeWidgetGetResponseRegion = "world" -) - -// A Turnstile widget's detailed configuration -type ChallengeWidgetRotateSecretResponse struct { - // If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive - // challenges in response to malicious bots (ENT only). - BotFightMode bool `json:"bot_fight_mode,required"` - // If Turnstile is embedded on a Cloudflare site and the widget should grant - // challenge clearance, this setting can determine the clearance level to be set - ClearanceLevel ChallengeWidgetRotateSecretResponseClearanceLevel `json:"clearance_level,required"` - // When the widget was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - Domains []string `json:"domains,required"` - // Widget Mode - Mode ChallengeWidgetRotateSecretResponseMode `json:"mode,required"` - // When the widget was modified. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // Human readable widget name. Not unique. Cloudflare suggests that you set this to - // a meaningful string to make it easier to identify your widget, and where it is - // used. - Name string `json:"name,required"` - // Do not show any Cloudflare branding on the widget (ENT only). - Offlabel bool `json:"offlabel,required"` - // Region where this widget can be used. - Region ChallengeWidgetRotateSecretResponseRegion `json:"region,required"` - // Secret key for this widget. - Secret string `json:"secret,required"` - // Widget item identifier tag. - Sitekey string `json:"sitekey,required"` - JSON challengeWidgetRotateSecretResponseJSON `json:"-"` -} - -// challengeWidgetRotateSecretResponseJSON contains the JSON metadata for the -// struct [ChallengeWidgetRotateSecretResponse] -type challengeWidgetRotateSecretResponseJSON struct { - BotFightMode apijson.Field - ClearanceLevel apijson.Field - CreatedOn apijson.Field - Domains apijson.Field - Mode apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Offlabel apijson.Field - Region apijson.Field - Secret apijson.Field - Sitekey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetRotateSecretResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetRotateSecretResponseJSON) RawJSON() string { - return r.raw -} - -// If Turnstile is embedded on a Cloudflare site and the widget should grant -// challenge clearance, this setting can determine the clearance level to be set -type ChallengeWidgetRotateSecretResponseClearanceLevel string - -const ( - ChallengeWidgetRotateSecretResponseClearanceLevelNoClearance ChallengeWidgetRotateSecretResponseClearanceLevel = "no_clearance" - ChallengeWidgetRotateSecretResponseClearanceLevelJschallenge ChallengeWidgetRotateSecretResponseClearanceLevel = "jschallenge" - ChallengeWidgetRotateSecretResponseClearanceLevelManaged ChallengeWidgetRotateSecretResponseClearanceLevel = "managed" - ChallengeWidgetRotateSecretResponseClearanceLevelInteractive ChallengeWidgetRotateSecretResponseClearanceLevel = "interactive" -) - -// Widget Mode -type ChallengeWidgetRotateSecretResponseMode string - -const ( - ChallengeWidgetRotateSecretResponseModeNonInteractive ChallengeWidgetRotateSecretResponseMode = "non-interactive" - ChallengeWidgetRotateSecretResponseModeInvisible ChallengeWidgetRotateSecretResponseMode = "invisible" - ChallengeWidgetRotateSecretResponseModeManaged ChallengeWidgetRotateSecretResponseMode = "managed" -) - -// Region where this widget can be used. -type ChallengeWidgetRotateSecretResponseRegion string - -const ( - ChallengeWidgetRotateSecretResponseRegionWorld ChallengeWidgetRotateSecretResponseRegion = "world" -) - -type ChallengeWidgetNewParams struct { - Domains param.Field[[]string] `json:"domains,required"` - // Widget Mode - Mode param.Field[ChallengeWidgetNewParamsMode] `json:"mode,required"` - // Human readable widget name. Not unique. Cloudflare suggests that you set this to - // a meaningful string to make it easier to identify your widget, and where it is - // used. - Name param.Field[string] `json:"name,required"` - // Direction to order widgets. - Direction param.Field[ChallengeWidgetNewParamsDirection] `query:"direction"` - // Field to order widgets by. - Order param.Field[ChallengeWidgetNewParamsOrder] `query:"order"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // Number of items per page. - PerPage param.Field[float64] `query:"per_page"` - // If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive - // challenges in response to malicious bots (ENT only). - BotFightMode param.Field[bool] `json:"bot_fight_mode"` - // If Turnstile is embedded on a Cloudflare site and the widget should grant - // challenge clearance, this setting can determine the clearance level to be set - ClearanceLevel param.Field[ChallengeWidgetNewParamsClearanceLevel] `json:"clearance_level"` - // Do not show any Cloudflare branding on the widget (ENT only). - Offlabel param.Field[bool] `json:"offlabel"` - // Region where this widget can be used. - Region param.Field[ChallengeWidgetNewParamsRegion] `json:"region"` -} - -func (r ChallengeWidgetNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// URLQuery serializes [ChallengeWidgetNewParams]'s query parameters as -// `url.Values`. -func (r ChallengeWidgetNewParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Widget Mode -type ChallengeWidgetNewParamsMode string - -const ( - ChallengeWidgetNewParamsModeNonInteractive ChallengeWidgetNewParamsMode = "non-interactive" - ChallengeWidgetNewParamsModeInvisible ChallengeWidgetNewParamsMode = "invisible" - ChallengeWidgetNewParamsModeManaged ChallengeWidgetNewParamsMode = "managed" -) - -// Direction to order widgets. -type ChallengeWidgetNewParamsDirection string - -const ( - ChallengeWidgetNewParamsDirectionAsc ChallengeWidgetNewParamsDirection = "asc" - ChallengeWidgetNewParamsDirectionDesc ChallengeWidgetNewParamsDirection = "desc" -) - -// Field to order widgets by. -type ChallengeWidgetNewParamsOrder string - -const ( - ChallengeWidgetNewParamsOrderID ChallengeWidgetNewParamsOrder = "id" - ChallengeWidgetNewParamsOrderSitekey ChallengeWidgetNewParamsOrder = "sitekey" - ChallengeWidgetNewParamsOrderName ChallengeWidgetNewParamsOrder = "name" - ChallengeWidgetNewParamsOrderCreatedOn ChallengeWidgetNewParamsOrder = "created_on" - ChallengeWidgetNewParamsOrderModifiedOn ChallengeWidgetNewParamsOrder = "modified_on" -) - -// If Turnstile is embedded on a Cloudflare site and the widget should grant -// challenge clearance, this setting can determine the clearance level to be set -type ChallengeWidgetNewParamsClearanceLevel string - -const ( - ChallengeWidgetNewParamsClearanceLevelNoClearance ChallengeWidgetNewParamsClearanceLevel = "no_clearance" - ChallengeWidgetNewParamsClearanceLevelJschallenge ChallengeWidgetNewParamsClearanceLevel = "jschallenge" - ChallengeWidgetNewParamsClearanceLevelManaged ChallengeWidgetNewParamsClearanceLevel = "managed" - ChallengeWidgetNewParamsClearanceLevelInteractive ChallengeWidgetNewParamsClearanceLevel = "interactive" -) - -// Region where this widget can be used. -type ChallengeWidgetNewParamsRegion string - -const ( - ChallengeWidgetNewParamsRegionWorld ChallengeWidgetNewParamsRegion = "world" -) - -type ChallengeWidgetNewResponseEnvelope struct { - Errors []ChallengeWidgetNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ChallengeWidgetNewResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // A Turnstile widget's detailed configuration - Result ChallengeWidgetNewResponse `json:"result"` - ResultInfo ChallengeWidgetNewResponseEnvelopeResultInfo `json:"result_info"` - JSON challengeWidgetNewResponseEnvelopeJSON `json:"-"` -} - -// challengeWidgetNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [ChallengeWidgetNewResponseEnvelope] -type challengeWidgetNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - ResultInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ChallengeWidgetNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON challengeWidgetNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// challengeWidgetNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ChallengeWidgetNewResponseEnvelopeErrors] -type challengeWidgetNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ChallengeWidgetNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON challengeWidgetNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// challengeWidgetNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ChallengeWidgetNewResponseEnvelopeMessages] -type challengeWidgetNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ChallengeWidgetNewResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count,required"` - // Current page within paginated list of results - Page float64 `json:"page,required"` - // Number of results per page of results - PerPage float64 `json:"per_page,required"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count,required"` - JSON challengeWidgetNewResponseEnvelopeResultInfoJSON `json:"-"` -} - -// challengeWidgetNewResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [ChallengeWidgetNewResponseEnvelopeResultInfo] -type challengeWidgetNewResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetNewResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ChallengeWidgetUpdateParams struct { - Domains param.Field[[]string] `json:"domains,required"` - // Widget Mode - Mode param.Field[ChallengeWidgetUpdateParamsMode] `json:"mode,required"` - // Human readable widget name. Not unique. Cloudflare suggests that you set this to - // a meaningful string to make it easier to identify your widget, and where it is - // used. - Name param.Field[string] `json:"name,required"` - // If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive - // challenges in response to malicious bots (ENT only). - BotFightMode param.Field[bool] `json:"bot_fight_mode"` - // If Turnstile is embedded on a Cloudflare site and the widget should grant - // challenge clearance, this setting can determine the clearance level to be set - ClearanceLevel param.Field[ChallengeWidgetUpdateParamsClearanceLevel] `json:"clearance_level"` - // Do not show any Cloudflare branding on the widget (ENT only). - Offlabel param.Field[bool] `json:"offlabel"` -} - -func (r ChallengeWidgetUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Widget Mode -type ChallengeWidgetUpdateParamsMode string - -const ( - ChallengeWidgetUpdateParamsModeNonInteractive ChallengeWidgetUpdateParamsMode = "non-interactive" - ChallengeWidgetUpdateParamsModeInvisible ChallengeWidgetUpdateParamsMode = "invisible" - ChallengeWidgetUpdateParamsModeManaged ChallengeWidgetUpdateParamsMode = "managed" -) - -// If Turnstile is embedded on a Cloudflare site and the widget should grant -// challenge clearance, this setting can determine the clearance level to be set -type ChallengeWidgetUpdateParamsClearanceLevel string - -const ( - ChallengeWidgetUpdateParamsClearanceLevelNoClearance ChallengeWidgetUpdateParamsClearanceLevel = "no_clearance" - ChallengeWidgetUpdateParamsClearanceLevelJschallenge ChallengeWidgetUpdateParamsClearanceLevel = "jschallenge" - ChallengeWidgetUpdateParamsClearanceLevelManaged ChallengeWidgetUpdateParamsClearanceLevel = "managed" - ChallengeWidgetUpdateParamsClearanceLevelInteractive ChallengeWidgetUpdateParamsClearanceLevel = "interactive" -) - -type ChallengeWidgetUpdateResponseEnvelope struct { - Errors []ChallengeWidgetUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ChallengeWidgetUpdateResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // A Turnstile widget's detailed configuration - Result ChallengeWidgetUpdateResponse `json:"result"` - JSON challengeWidgetUpdateResponseEnvelopeJSON `json:"-"` -} - -// challengeWidgetUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [ChallengeWidgetUpdateResponseEnvelope] -type challengeWidgetUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ChallengeWidgetUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON challengeWidgetUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// challengeWidgetUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ChallengeWidgetUpdateResponseEnvelopeErrors] -type challengeWidgetUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ChallengeWidgetUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON challengeWidgetUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// challengeWidgetUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ChallengeWidgetUpdateResponseEnvelopeMessages] -type challengeWidgetUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ChallengeWidgetListParams struct { - // Direction to order widgets. - Direction param.Field[ChallengeWidgetListParamsDirection] `query:"direction"` - // Field to order widgets by. - Order param.Field[ChallengeWidgetListParamsOrder] `query:"order"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // Number of items per page. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [ChallengeWidgetListParams]'s query parameters as -// `url.Values`. -func (r ChallengeWidgetListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Direction to order widgets. -type ChallengeWidgetListParamsDirection string - -const ( - ChallengeWidgetListParamsDirectionAsc ChallengeWidgetListParamsDirection = "asc" - ChallengeWidgetListParamsDirectionDesc ChallengeWidgetListParamsDirection = "desc" -) - -// Field to order widgets by. -type ChallengeWidgetListParamsOrder string - -const ( - ChallengeWidgetListParamsOrderID ChallengeWidgetListParamsOrder = "id" - ChallengeWidgetListParamsOrderSitekey ChallengeWidgetListParamsOrder = "sitekey" - ChallengeWidgetListParamsOrderName ChallengeWidgetListParamsOrder = "name" - ChallengeWidgetListParamsOrderCreatedOn ChallengeWidgetListParamsOrder = "created_on" - ChallengeWidgetListParamsOrderModifiedOn ChallengeWidgetListParamsOrder = "modified_on" -) - -type ChallengeWidgetDeleteResponseEnvelope struct { - Errors []ChallengeWidgetDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ChallengeWidgetDeleteResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // A Turnstile widget's detailed configuration - Result ChallengeWidgetDeleteResponse `json:"result"` - JSON challengeWidgetDeleteResponseEnvelopeJSON `json:"-"` -} - -// challengeWidgetDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [ChallengeWidgetDeleteResponseEnvelope] -type challengeWidgetDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ChallengeWidgetDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON challengeWidgetDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// challengeWidgetDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ChallengeWidgetDeleteResponseEnvelopeErrors] -type challengeWidgetDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ChallengeWidgetDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON challengeWidgetDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// challengeWidgetDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ChallengeWidgetDeleteResponseEnvelopeMessages] -type challengeWidgetDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ChallengeWidgetGetResponseEnvelope struct { - Errors []ChallengeWidgetGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ChallengeWidgetGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // A Turnstile widget's detailed configuration - Result ChallengeWidgetGetResponse `json:"result"` - JSON challengeWidgetGetResponseEnvelopeJSON `json:"-"` -} - -// challengeWidgetGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [ChallengeWidgetGetResponseEnvelope] -type challengeWidgetGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ChallengeWidgetGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON challengeWidgetGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// challengeWidgetGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ChallengeWidgetGetResponseEnvelopeErrors] -type challengeWidgetGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ChallengeWidgetGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON challengeWidgetGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// challengeWidgetGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ChallengeWidgetGetResponseEnvelopeMessages] -type challengeWidgetGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ChallengeWidgetRotateSecretParams struct { - // If `invalidate_immediately` is set to `false`, the previous secret will remain - // valid for two hours. Otherwise, the secret is immediately invalidated, and - // requests using it will be rejected. - InvalidateImmediately param.Field[bool] `json:"invalidate_immediately"` -} - -func (r ChallengeWidgetRotateSecretParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ChallengeWidgetRotateSecretResponseEnvelope struct { - Errors []ChallengeWidgetRotateSecretResponseEnvelopeErrors `json:"errors,required"` - Messages []ChallengeWidgetRotateSecretResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // A Turnstile widget's detailed configuration - Result ChallengeWidgetRotateSecretResponse `json:"result"` - JSON challengeWidgetRotateSecretResponseEnvelopeJSON `json:"-"` -} - -// challengeWidgetRotateSecretResponseEnvelopeJSON contains the JSON metadata for -// the struct [ChallengeWidgetRotateSecretResponseEnvelope] -type challengeWidgetRotateSecretResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetRotateSecretResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetRotateSecretResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ChallengeWidgetRotateSecretResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON challengeWidgetRotateSecretResponseEnvelopeErrorsJSON `json:"-"` -} - -// challengeWidgetRotateSecretResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ChallengeWidgetRotateSecretResponseEnvelopeErrors] -type challengeWidgetRotateSecretResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetRotateSecretResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetRotateSecretResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ChallengeWidgetRotateSecretResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON challengeWidgetRotateSecretResponseEnvelopeMessagesJSON `json:"-"` -} - -// challengeWidgetRotateSecretResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ChallengeWidgetRotateSecretResponseEnvelopeMessages] -type challengeWidgetRotateSecretResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ChallengeWidgetRotateSecretResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r challengeWidgetRotateSecretResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/challengewidget_test.go b/challengewidget_test.go deleted file mode 100644 index c9e029a6eac..00000000000 --- a/challengewidget_test.go +++ /dev/null @@ -1,210 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestChallengeWidgetNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Challenges.Widgets.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.ChallengeWidgetNewParams{ - Domains: cloudflare.F([]string{"203.0.113.1", "cloudflare.com", "blog.example.com"}), - Mode: cloudflare.F(cloudflare.ChallengeWidgetNewParamsModeInvisible), - Name: cloudflare.F("blog.cloudflare.com login form"), - Direction: cloudflare.F(cloudflare.ChallengeWidgetNewParamsDirectionAsc), - Order: cloudflare.F(cloudflare.ChallengeWidgetNewParamsOrderID), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(5.000000), - BotFightMode: cloudflare.F(true), - ClearanceLevel: cloudflare.F(cloudflare.ChallengeWidgetNewParamsClearanceLevelInteractive), - Offlabel: cloudflare.F(true), - Region: cloudflare.F(cloudflare.ChallengeWidgetNewParamsRegionWorld), - }, - ) - 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 TestChallengeWidgetUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Challenges.Widgets.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "0x4AAF00AAAABn0R22HWm-YUc", - cloudflare.ChallengeWidgetUpdateParams{ - Domains: cloudflare.F([]string{"203.0.113.1", "cloudflare.com", "blog.example.com"}), - Mode: cloudflare.F(cloudflare.ChallengeWidgetUpdateParamsModeInvisible), - Name: cloudflare.F("blog.cloudflare.com login form"), - BotFightMode: cloudflare.F(true), - ClearanceLevel: cloudflare.F(cloudflare.ChallengeWidgetUpdateParamsClearanceLevelInteractive), - Offlabel: cloudflare.F(true), - }, - ) - 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 TestChallengeWidgetListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Challenges.Widgets.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.ChallengeWidgetListParams{ - Direction: cloudflare.F(cloudflare.ChallengeWidgetListParamsDirectionAsc), - Order: cloudflare.F(cloudflare.ChallengeWidgetListParamsOrderID), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(5.000000), - }, - ) - 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 TestChallengeWidgetDelete(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("user@example.com"), - ) - _, err := client.Challenges.Widgets.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "0x4AAF00AAAABn0R22HWm-YUc", - ) - 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 TestChallengeWidgetGet(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("user@example.com"), - ) - _, err := client.Challenges.Widgets.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "0x4AAF00AAAABn0R22HWm-YUc", - ) - 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 TestChallengeWidgetRotateSecretWithOptionalParams(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("user@example.com"), - ) - _, err := client.Challenges.Widgets.RotateSecret( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "0x4AAF00AAAABn0R22HWm-YUc", - cloudflare.ChallengeWidgetRotateSecretParams{ - InvalidateImmediately: cloudflare.F(true), - }, - ) - 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/client.go b/client.go index cc9269e48e5..796f1024583 100644 --- a/client.go +++ b/client.go @@ -5,7 +5,87 @@ package cloudflare import ( "os" + "github.com/cloudflare/cloudflare-go/accounts" + "github.com/cloudflare/cloudflare-go/acm" + "github.com/cloudflare/cloudflare-go/addressing" + "github.com/cloudflare/cloudflare-go/alerting" + "github.com/cloudflare/cloudflare-go/argo" + "github.com/cloudflare/cloudflare-go/audit_logs" + "github.com/cloudflare/cloudflare-go/available_plans" + "github.com/cloudflare/cloudflare-go/available_rate_plans" + "github.com/cloudflare/cloudflare-go/billing" + "github.com/cloudflare/cloudflare-go/bot_management" + "github.com/cloudflare/cloudflare-go/brand_protection" + "github.com/cloudflare/cloudflare-go/cache" + "github.com/cloudflare/cloudflare-go/calls" + "github.com/cloudflare/cloudflare-go/certificate_authorities" + "github.com/cloudflare/cloudflare-go/certificates" + "github.com/cloudflare/cloudflare-go/challenges" + "github.com/cloudflare/cloudflare-go/client_certificates" + "github.com/cloudflare/cloudflare-go/cloudforce_one" + "github.com/cloudflare/cloudflare-go/custom_certificates" + "github.com/cloudflare/cloudflare-go/custom_hostnames" + "github.com/cloudflare/cloudflare-go/custom_nameservers" + "github.com/cloudflare/cloudflare-go/d1" + "github.com/cloudflare/cloudflare-go/dcv_delegation" + "github.com/cloudflare/cloudflare-go/diagnostics" + "github.com/cloudflare/cloudflare-go/dns" + "github.com/cloudflare/cloudflare-go/dnssec" + "github.com/cloudflare/cloudflare-go/durable_objects" + "github.com/cloudflare/cloudflare-go/email_routing" + "github.com/cloudflare/cloudflare-go/filters" + "github.com/cloudflare/cloudflare-go/firewall" + "github.com/cloudflare/cloudflare-go/healthchecks" + "github.com/cloudflare/cloudflare-go/hostnames" + "github.com/cloudflare/cloudflare-go/hyperdrive" + "github.com/cloudflare/cloudflare-go/images" + "github.com/cloudflare/cloudflare-go/intel" + "github.com/cloudflare/cloudflare-go/ips" + "github.com/cloudflare/cloudflare-go/keyless_certificates" + "github.com/cloudflare/cloudflare-go/kv" + "github.com/cloudflare/cloudflare-go/load_balancers" + "github.com/cloudflare/cloudflare-go/logpush" + "github.com/cloudflare/cloudflare-go/logs" + "github.com/cloudflare/cloudflare-go/magic_network_monitoring" + "github.com/cloudflare/cloudflare-go/magic_transit" + "github.com/cloudflare/cloudflare-go/managed_headers" + "github.com/cloudflare/cloudflare-go/memberships" + "github.com/cloudflare/cloudflare-go/mtls_certificates" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/origin_post_quantum_encryption" + "github.com/cloudflare/cloudflare-go/origin_tls_client_auth" + "github.com/cloudflare/cloudflare-go/page_shield" + "github.com/cloudflare/cloudflare-go/pagerules" + "github.com/cloudflare/cloudflare-go/pages" + "github.com/cloudflare/cloudflare-go/pcaps" + "github.com/cloudflare/cloudflare-go/queues" + "github.com/cloudflare/cloudflare-go/r2" + "github.com/cloudflare/cloudflare-go/radar" + "github.com/cloudflare/cloudflare-go/rate_limits" + "github.com/cloudflare/cloudflare-go/registrar" + "github.com/cloudflare/cloudflare-go/request_tracers" + "github.com/cloudflare/cloudflare-go/rules" + "github.com/cloudflare/cloudflare-go/rulesets" + "github.com/cloudflare/cloudflare-go/rum" + "github.com/cloudflare/cloudflare-go/secondary_dns" + "github.com/cloudflare/cloudflare-go/snippets" + "github.com/cloudflare/cloudflare-go/spectrum" + "github.com/cloudflare/cloudflare-go/speed" + "github.com/cloudflare/cloudflare-go/ssl" + "github.com/cloudflare/cloudflare-go/storage" + "github.com/cloudflare/cloudflare-go/stream" + "github.com/cloudflare/cloudflare-go/subscriptions" + "github.com/cloudflare/cloudflare-go/url_normalization" + "github.com/cloudflare/cloudflare-go/url_scanner" + "github.com/cloudflare/cloudflare-go/user" + "github.com/cloudflare/cloudflare-go/vectorize" + "github.com/cloudflare/cloudflare-go/waiting_rooms" + "github.com/cloudflare/cloudflare-go/warp_connector" + "github.com/cloudflare/cloudflare-go/web3" + "github.com/cloudflare/cloudflare-go/workers" + "github.com/cloudflare/cloudflare-go/workers_for_platforms" + "github.com/cloudflare/cloudflare-go/zero_trust" + "github.com/cloudflare/cloudflare-go/zones" ) // Client creates a struct with services and top level methods that help with @@ -13,86 +93,86 @@ import ( // directly, and instead use the [NewClient] method instead. type Client struct { Options []option.RequestOption - Accounts *AccountService - Certificates *CertificateService - IPs *IPService - Memberships *MembershipService - User *UserService - Zones *ZoneService - LoadBalancers *LoadBalancerService - Cache *CacheService - SSL *SSLService - Subscriptions *SubscriptionService - ACM *ACMService - Argo *ArgoService - AvailablePlans *AvailablePlanService - AvailableRatePlans *AvailableRatePlanService - CertificateAuthorities *CertificateAuthorityService - ClientCertificates *ClientCertificateService - CustomCertificates *CustomCertificateService - CustomHostnames *CustomHostnameService - CustomNameservers *CustomNameserverService - DNS *DNSService - DNSSEC *DNSSECService - EmailRouting *EmailRoutingService - Filters *FilterService - Firewall *FirewallService - Healthchecks *HealthcheckService - KeylessCertificates *KeylessCertificateService - Logpush *LogpushService - Logs *LogService - OriginTLSClientAuth *OriginTLSClientAuthService - Pagerules *PageruleService - RateLimits *RateLimitService - SecondaryDNS *SecondaryDNSService - WaitingRooms *WaitingRoomService - Web3 *Web3Service - Workers *WorkerService - KV *KVService - DurableObjects *DurableObjectService - Queues *QueueService - ManagedHeaders *ManagedHeaderService - PageShield *PageShieldService - Rulesets *RulesetService - URLNormalization *URLNormalizationService - Spectrum *SpectrumService - Addressing *AddressingService - AuditLogs *AuditLogService - Billing *BillingService - BrandProtection *BrandProtectionService - Diagnostics *DiagnosticService - Images *ImageService - Intel *IntelService - MagicTransit *MagicTransitService - MagicNetworkMonitoring *MagicNetworkMonitoringService - MTLSCertificates *MTLSCertificateService - Pages *PageService - PCAPs *PCAPService - Registrar *RegistrarService - RequestTracers *RequestTracerService - Rules *RuleService - Storage *StorageService - Stream *StreamService - Alerting *AlertingService - D1 *D1Service - R2 *R2Service - WARPConnector *WARPConnectorService - WorkersForPlatforms *WorkersForPlatformService - ZeroTrust *ZeroTrustService - Challenges *ChallengeService - Hyperdrive *HyperdriveService - RUM *RUMService - Vectorize *VectorizeService - URLScanner *URLScannerService - Radar *RadarService - BotManagement *BotManagementService - OriginPostQuantumEncryption *OriginPostQuantumEncryptionService - Speed *SpeedService - DCVDelegation *DCVDelegationService - Hostnames *HostnameService - Snippets *SnippetService - Calls *CallService - CloudforceOne *CloudforceOneService + Accounts *accounts.AccountService + Certificates *certificates.CertificateService + IPs *ips.IPService + Memberships *memberships.MembershipService + User *user.UserService + Zones *zones.ZoneService + LoadBalancers *load_balancers.LoadBalancerService + Cache *cache.CacheService + SSL *ssl.SSLService + Subscriptions *subscriptions.SubscriptionService + ACM *acm.ACMService + Argo *argo.ArgoService + AvailablePlans *available_plans.AvailablePlanService + AvailableRatePlans *available_rate_plans.AvailableRatePlanService + CertificateAuthorities *certificate_authorities.CertificateAuthorityService + ClientCertificates *client_certificates.ClientCertificateService + CustomCertificates *custom_certificates.CustomCertificateService + CustomHostnames *custom_hostnames.CustomHostnameService + CustomNameservers *custom_nameservers.CustomNameserverService + DNS *dns.DNSService + DNSSEC *dnssec.DNSSECService + EmailRouting *email_routing.EmailRoutingService + Filters *filters.FilterService + Firewall *firewall.FirewallService + Healthchecks *healthchecks.HealthcheckService + KeylessCertificates *keyless_certificates.KeylessCertificateService + Logpush *logpush.LogpushService + Logs *logs.LogService + OriginTLSClientAuth *origin_tls_client_auth.OriginTLSClientAuthService + Pagerules *pagerules.PageruleService + RateLimits *rate_limits.RateLimitService + SecondaryDNS *secondary_dns.SecondaryDNSService + WaitingRooms *waiting_rooms.WaitingRoomService + Web3 *web3.Web3Service + Workers *workers.WorkerService + KV *kv.KVService + DurableObjects *durable_objects.DurableObjectService + Queues *queues.QueueService + ManagedHeaders *managed_headers.ManagedHeaderService + PageShield *page_shield.PageShieldService + Rulesets *rulesets.RulesetService + URLNormalization *url_normalization.URLNormalizationService + Spectrum *spectrum.SpectrumService + Addressing *addressing.AddressingService + AuditLogs *audit_logs.AuditLogService + Billing *billing.BillingService + BrandProtection *brand_protection.BrandProtectionService + Diagnostics *diagnostics.DiagnosticService + Images *images.ImageService + Intel *intel.IntelService + MagicTransit *magic_transit.MagicTransitService + MagicNetworkMonitoring *magic_network_monitoring.MagicNetworkMonitoringService + MTLSCertificates *mtls_certificates.MTLSCertificateService + Pages *pages.PageService + PCAPs *pcaps.PCAPService + Registrar *registrar.RegistrarService + RequestTracers *request_tracers.RequestTracerService + Rules *rules.RuleService + Storage *storage.StorageService + Stream *stream.StreamService + Alerting *alerting.AlertingService + D1 *d1.D1Service + R2 *r2.R2Service + WARPConnector *warp_connector.WARPConnectorService + WorkersForPlatforms *workers_for_platforms.WorkersForPlatformService + ZeroTrust *zero_trust.ZeroTrustService + Challenges *challenges.ChallengeService + Hyperdrive *hyperdrive.HyperdriveService + RUM *rum.RUMService + Vectorize *vectorize.VectorizeService + URLScanner *url_scanner.URLScannerService + Radar *radar.RadarService + BotManagement *bot_management.BotManagementService + OriginPostQuantumEncryption *origin_post_quantum_encryption.OriginPostQuantumEncryptionService + Speed *speed.SpeedService + DCVDelegation *dcv_delegation.DCVDelegationService + Hostnames *hostnames.HostnameService + Snippets *snippets.SnippetService + Calls *calls.CallService + CloudforceOne *cloudforce_one.CloudforceOneService } // NewClient generates a new client with the default option read from the @@ -118,86 +198,86 @@ func NewClient(opts ...option.RequestOption) (r *Client) { r = &Client{Options: opts} - r.Accounts = NewAccountService(opts...) - r.Certificates = NewCertificateService(opts...) - r.IPs = NewIPService(opts...) - r.Memberships = NewMembershipService(opts...) - r.User = NewUserService(opts...) - r.Zones = NewZoneService(opts...) - r.LoadBalancers = NewLoadBalancerService(opts...) - r.Cache = NewCacheService(opts...) - r.SSL = NewSSLService(opts...) - r.Subscriptions = NewSubscriptionService(opts...) - r.ACM = NewACMService(opts...) - r.Argo = NewArgoService(opts...) - r.AvailablePlans = NewAvailablePlanService(opts...) - r.AvailableRatePlans = NewAvailableRatePlanService(opts...) - r.CertificateAuthorities = NewCertificateAuthorityService(opts...) - r.ClientCertificates = NewClientCertificateService(opts...) - r.CustomCertificates = NewCustomCertificateService(opts...) - r.CustomHostnames = NewCustomHostnameService(opts...) - r.CustomNameservers = NewCustomNameserverService(opts...) - r.DNS = NewDNSService(opts...) - r.DNSSEC = NewDNSSECService(opts...) - r.EmailRouting = NewEmailRoutingService(opts...) - r.Filters = NewFilterService(opts...) - r.Firewall = NewFirewallService(opts...) - r.Healthchecks = NewHealthcheckService(opts...) - r.KeylessCertificates = NewKeylessCertificateService(opts...) - r.Logpush = NewLogpushService(opts...) - r.Logs = NewLogService(opts...) - r.OriginTLSClientAuth = NewOriginTLSClientAuthService(opts...) - r.Pagerules = NewPageruleService(opts...) - r.RateLimits = NewRateLimitService(opts...) - r.SecondaryDNS = NewSecondaryDNSService(opts...) - r.WaitingRooms = NewWaitingRoomService(opts...) - r.Web3 = NewWeb3Service(opts...) - r.Workers = NewWorkerService(opts...) - r.KV = NewKVService(opts...) - r.DurableObjects = NewDurableObjectService(opts...) - r.Queues = NewQueueService(opts...) - r.ManagedHeaders = NewManagedHeaderService(opts...) - r.PageShield = NewPageShieldService(opts...) - r.Rulesets = NewRulesetService(opts...) - r.URLNormalization = NewURLNormalizationService(opts...) - r.Spectrum = NewSpectrumService(opts...) - r.Addressing = NewAddressingService(opts...) - r.AuditLogs = NewAuditLogService(opts...) - r.Billing = NewBillingService(opts...) - r.BrandProtection = NewBrandProtectionService(opts...) - r.Diagnostics = NewDiagnosticService(opts...) - r.Images = NewImageService(opts...) - r.Intel = NewIntelService(opts...) - r.MagicTransit = NewMagicTransitService(opts...) - r.MagicNetworkMonitoring = NewMagicNetworkMonitoringService(opts...) - r.MTLSCertificates = NewMTLSCertificateService(opts...) - r.Pages = NewPageService(opts...) - r.PCAPs = NewPCAPService(opts...) - r.Registrar = NewRegistrarService(opts...) - r.RequestTracers = NewRequestTracerService(opts...) - r.Rules = NewRuleService(opts...) - r.Storage = NewStorageService(opts...) - r.Stream = NewStreamService(opts...) - r.Alerting = NewAlertingService(opts...) - r.D1 = NewD1Service(opts...) - r.R2 = NewR2Service(opts...) - r.WARPConnector = NewWARPConnectorService(opts...) - r.WorkersForPlatforms = NewWorkersForPlatformService(opts...) - r.ZeroTrust = NewZeroTrustService(opts...) - r.Challenges = NewChallengeService(opts...) - r.Hyperdrive = NewHyperdriveService(opts...) - r.RUM = NewRUMService(opts...) - r.Vectorize = NewVectorizeService(opts...) - r.URLScanner = NewURLScannerService(opts...) - r.Radar = NewRadarService(opts...) - r.BotManagement = NewBotManagementService(opts...) - r.OriginPostQuantumEncryption = NewOriginPostQuantumEncryptionService(opts...) - r.Speed = NewSpeedService(opts...) - r.DCVDelegation = NewDCVDelegationService(opts...) - r.Hostnames = NewHostnameService(opts...) - r.Snippets = NewSnippetService(opts...) - r.Calls = NewCallService(opts...) - r.CloudforceOne = NewCloudforceOneService(opts...) + r.Accounts = accounts.NewAccountService(opts...) + r.Certificates = certificates.NewCertificateService(opts...) + r.IPs = ips.NewIPService(opts...) + r.Memberships = memberships.NewMembershipService(opts...) + r.User = user.NewUserService(opts...) + r.Zones = zones.NewZoneService(opts...) + r.LoadBalancers = load_balancers.NewLoadBalancerService(opts...) + r.Cache = cache.NewCacheService(opts...) + r.SSL = ssl.NewSSLService(opts...) + r.Subscriptions = subscriptions.NewSubscriptionService(opts...) + r.ACM = acm.NewACMService(opts...) + r.Argo = argo.NewArgoService(opts...) + r.AvailablePlans = available_plans.NewAvailablePlanService(opts...) + r.AvailableRatePlans = available_rate_plans.NewAvailableRatePlanService(opts...) + r.CertificateAuthorities = certificate_authorities.NewCertificateAuthorityService(opts...) + r.ClientCertificates = client_certificates.NewClientCertificateService(opts...) + r.CustomCertificates = custom_certificates.NewCustomCertificateService(opts...) + r.CustomHostnames = custom_hostnames.NewCustomHostnameService(opts...) + r.CustomNameservers = custom_nameservers.NewCustomNameserverService(opts...) + r.DNS = dns.NewDNSService(opts...) + r.DNSSEC = dnssec.NewDNSSECService(opts...) + r.EmailRouting = email_routing.NewEmailRoutingService(opts...) + r.Filters = filters.NewFilterService(opts...) + r.Firewall = firewall.NewFirewallService(opts...) + r.Healthchecks = healthchecks.NewHealthcheckService(opts...) + r.KeylessCertificates = keyless_certificates.NewKeylessCertificateService(opts...) + r.Logpush = logpush.NewLogpushService(opts...) + r.Logs = logs.NewLogService(opts...) + r.OriginTLSClientAuth = origin_tls_client_auth.NewOriginTLSClientAuthService(opts...) + r.Pagerules = pagerules.NewPageruleService(opts...) + r.RateLimits = rate_limits.NewRateLimitService(opts...) + r.SecondaryDNS = secondary_dns.NewSecondaryDNSService(opts...) + r.WaitingRooms = waiting_rooms.NewWaitingRoomService(opts...) + r.Web3 = web3.NewWeb3Service(opts...) + r.Workers = workers.NewWorkerService(opts...) + r.KV = kv.NewKVService(opts...) + r.DurableObjects = durable_objects.NewDurableObjectService(opts...) + r.Queues = queues.NewQueueService(opts...) + r.ManagedHeaders = managed_headers.NewManagedHeaderService(opts...) + r.PageShield = page_shield.NewPageShieldService(opts...) + r.Rulesets = rulesets.NewRulesetService(opts...) + r.URLNormalization = url_normalization.NewURLNormalizationService(opts...) + r.Spectrum = spectrum.NewSpectrumService(opts...) + r.Addressing = addressing.NewAddressingService(opts...) + r.AuditLogs = audit_logs.NewAuditLogService(opts...) + r.Billing = billing.NewBillingService(opts...) + r.BrandProtection = brand_protection.NewBrandProtectionService(opts...) + r.Diagnostics = diagnostics.NewDiagnosticService(opts...) + r.Images = images.NewImageService(opts...) + r.Intel = intel.NewIntelService(opts...) + r.MagicTransit = magic_transit.NewMagicTransitService(opts...) + r.MagicNetworkMonitoring = magic_network_monitoring.NewMagicNetworkMonitoringService(opts...) + r.MTLSCertificates = mtls_certificates.NewMTLSCertificateService(opts...) + r.Pages = pages.NewPageService(opts...) + r.PCAPs = pcaps.NewPCAPService(opts...) + r.Registrar = registrar.NewRegistrarService(opts...) + r.RequestTracers = request_tracers.NewRequestTracerService(opts...) + r.Rules = rules.NewRuleService(opts...) + r.Storage = storage.NewStorageService(opts...) + r.Stream = stream.NewStreamService(opts...) + r.Alerting = alerting.NewAlertingService(opts...) + r.D1 = d1.NewD1Service(opts...) + r.R2 = r2.NewR2Service(opts...) + r.WARPConnector = warp_connector.NewWARPConnectorService(opts...) + r.WorkersForPlatforms = workers_for_platforms.NewWorkersForPlatformService(opts...) + r.ZeroTrust = zero_trust.NewZeroTrustService(opts...) + r.Challenges = challenges.NewChallengeService(opts...) + r.Hyperdrive = hyperdrive.NewHyperdriveService(opts...) + r.RUM = rum.NewRUMService(opts...) + r.Vectorize = vectorize.NewVectorizeService(opts...) + r.URLScanner = url_scanner.NewURLScannerService(opts...) + r.Radar = radar.NewRadarService(opts...) + r.BotManagement = bot_management.NewBotManagementService(opts...) + r.OriginPostQuantumEncryption = origin_post_quantum_encryption.NewOriginPostQuantumEncryptionService(opts...) + r.Speed = speed.NewSpeedService(opts...) + r.DCVDelegation = dcv_delegation.NewDCVDelegationService(opts...) + r.Hostnames = hostnames.NewHostnameService(opts...) + r.Snippets = snippets.NewSnippetService(opts...) + r.Calls = calls.NewCallService(opts...) + r.CloudforceOne = cloudforce_one.NewCloudforceOneService(opts...) return } diff --git a/client_certificates/aliases.go b/client_certificates/aliases.go new file mode 100644 index 00000000000..5498011d1e3 --- /dev/null +++ b/client_certificates/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package client_certificates + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/client_certificates/clientcertificate.go b/client_certificates/clientcertificate.go new file mode 100644 index 00000000000..cedac812eb4 --- /dev/null +++ b/client_certificates/clientcertificate.go @@ -0,0 +1,611 @@ +// File generated from our OpenAPI spec by Stainless. + +package client_certificates + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" +) + +// ClientCertificateService 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 [NewClientCertificateService] method +// instead. +type ClientCertificateService struct { + Options []option.RequestOption +} + +// NewClientCertificateService 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 NewClientCertificateService(opts ...option.RequestOption) (r *ClientCertificateService) { + r = &ClientCertificateService{} + r.Options = opts + return +} + +// Create a new API Shield mTLS Client Certificate +func (r *ClientCertificateService) New(ctx context.Context, params ClientCertificateNewParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesClientCertificate, err error) { + opts = append(r.Options[:], opts...) + var env ClientCertificateNewResponseEnvelope + path := fmt.Sprintf("zones/%s/client_certificates", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List all of your Zone's API Shield mTLS Client Certificates by Status and/or +// using Pagination +func (r *ClientCertificateService) List(ctx context.Context, params ClientCertificateListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[TLSCertificatesAndHostnamesClientCertificate], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("zones/%s/client_certificates", params.ZoneID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// List all of your Zone's API Shield mTLS Client Certificates by Status and/or +// using Pagination +func (r *ClientCertificateService) ListAutoPaging(ctx context.Context, params ClientCertificateListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[TLSCertificatesAndHostnamesClientCertificate] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) +} + +// Set a API Shield mTLS Client Certificate to pending_revocation status for +// processing to revoked status. +func (r *ClientCertificateService) Delete(ctx context.Context, clientCertificateID string, body ClientCertificateDeleteParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesClientCertificate, err error) { + opts = append(r.Options[:], opts...) + var env ClientCertificateDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/client_certificates/%s", body.ZoneID, clientCertificateID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// If a API Shield mTLS Client Certificate is in a pending_revocation state, you +// may reactivate it with this endpoint. +func (r *ClientCertificateService) Edit(ctx context.Context, clientCertificateID string, body ClientCertificateEditParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesClientCertificate, err error) { + opts = append(r.Options[:], opts...) + var env ClientCertificateEditResponseEnvelope + path := fmt.Sprintf("zones/%s/client_certificates/%s", body.ZoneID, clientCertificateID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get Details for a single mTLS API Shield Client Certificate +func (r *ClientCertificateService) Get(ctx context.Context, clientCertificateID string, query ClientCertificateGetParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesClientCertificate, err error) { + opts = append(r.Options[:], opts...) + var env ClientCertificateGetResponseEnvelope + path := fmt.Sprintf("zones/%s/client_certificates/%s", query.ZoneID, clientCertificateID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TLSCertificatesAndHostnamesClientCertificate struct { + // Identifier + ID string `json:"id"` + // The Client Certificate PEM + Certificate string `json:"certificate"` + // Certificate Authority used to issue the Client Certificate + CertificateAuthority TLSCertificatesAndHostnamesClientCertificateCertificateAuthority `json:"certificate_authority"` + // Common Name of the Client Certificate + CommonName string `json:"common_name"` + // Country, provided by the CSR + Country string `json:"country"` + // The Certificate Signing Request (CSR). Must be newline-encoded. + Csr string `json:"csr"` + // Date that the Client Certificate expires + ExpiresOn string `json:"expires_on"` + // Unique identifier of the Client Certificate + FingerprintSha256 string `json:"fingerprint_sha256"` + // Date that the Client Certificate was issued by the Certificate Authority + IssuedOn string `json:"issued_on"` + // Location, provided by the CSR + Location string `json:"location"` + // Organization, provided by the CSR + Organization string `json:"organization"` + // Organizational Unit, provided by the CSR + OrganizationalUnit string `json:"organizational_unit"` + // The serial number on the created Client Certificate. + SerialNumber string `json:"serial_number"` + // The type of hash used for the Client Certificate.. + Signature string `json:"signature"` + // Subject Key Identifier + Ski string `json:"ski"` + // State, provided by the CSR + State string `json:"state"` + // Client Certificates may be active or revoked, and the pending_reactivation or + // pending_revocation represent in-progress asynchronous transitions + Status TLSCertificatesAndHostnamesClientCertificateStatus `json:"status"` + // The number of days the Client Certificate will be valid after the issued_on date + ValidityDays int64 `json:"validity_days"` + JSON tlsCertificatesAndHostnamesClientCertificateJSON `json:"-"` +} + +// tlsCertificatesAndHostnamesClientCertificateJSON contains the JSON metadata for +// the struct [TLSCertificatesAndHostnamesClientCertificate] +type tlsCertificatesAndHostnamesClientCertificateJSON struct { + ID apijson.Field + Certificate apijson.Field + CertificateAuthority apijson.Field + CommonName apijson.Field + Country apijson.Field + Csr apijson.Field + ExpiresOn apijson.Field + FingerprintSha256 apijson.Field + IssuedOn apijson.Field + Location apijson.Field + Organization apijson.Field + OrganizationalUnit apijson.Field + SerialNumber apijson.Field + Signature apijson.Field + Ski apijson.Field + State apijson.Field + Status apijson.Field + ValidityDays apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TLSCertificatesAndHostnamesClientCertificate) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tlsCertificatesAndHostnamesClientCertificateJSON) RawJSON() string { + return r.raw +} + +// Certificate Authority used to issue the Client Certificate +type TLSCertificatesAndHostnamesClientCertificateCertificateAuthority struct { + ID string `json:"id"` + Name string `json:"name"` + JSON tlsCertificatesAndHostnamesClientCertificateCertificateAuthorityJSON `json:"-"` +} + +// tlsCertificatesAndHostnamesClientCertificateCertificateAuthorityJSON contains +// the JSON metadata for the struct +// [TLSCertificatesAndHostnamesClientCertificateCertificateAuthority] +type tlsCertificatesAndHostnamesClientCertificateCertificateAuthorityJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TLSCertificatesAndHostnamesClientCertificateCertificateAuthority) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tlsCertificatesAndHostnamesClientCertificateCertificateAuthorityJSON) RawJSON() string { + return r.raw +} + +// Client Certificates may be active or revoked, and the pending_reactivation or +// pending_revocation represent in-progress asynchronous transitions +type TLSCertificatesAndHostnamesClientCertificateStatus string + +const ( + TLSCertificatesAndHostnamesClientCertificateStatusActive TLSCertificatesAndHostnamesClientCertificateStatus = "active" + TLSCertificatesAndHostnamesClientCertificateStatusPendingReactivation TLSCertificatesAndHostnamesClientCertificateStatus = "pending_reactivation" + TLSCertificatesAndHostnamesClientCertificateStatusPendingRevocation TLSCertificatesAndHostnamesClientCertificateStatus = "pending_revocation" + TLSCertificatesAndHostnamesClientCertificateStatusRevoked TLSCertificatesAndHostnamesClientCertificateStatus = "revoked" +) + +type ClientCertificateNewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // The Certificate Signing Request (CSR). Must be newline-encoded. + Csr param.Field[string] `json:"csr,required"` + // The number of days the Client Certificate will be valid after the issued_on date + ValidityDays param.Field[int64] `json:"validity_days,required"` +} + +func (r ClientCertificateNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ClientCertificateNewResponseEnvelope struct { + Errors []ClientCertificateNewResponseEnvelopeErrors `json:"errors,required"` + Messages []ClientCertificateNewResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesClientCertificate `json:"result,required"` + // Whether the API call was successful + Success ClientCertificateNewResponseEnvelopeSuccess `json:"success,required"` + JSON clientCertificateNewResponseEnvelopeJSON `json:"-"` +} + +// clientCertificateNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [ClientCertificateNewResponseEnvelope] +type clientCertificateNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ClientCertificateNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r clientCertificateNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ClientCertificateNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON clientCertificateNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// clientCertificateNewResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [ClientCertificateNewResponseEnvelopeErrors] +type clientCertificateNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ClientCertificateNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r clientCertificateNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ClientCertificateNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON clientCertificateNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// clientCertificateNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [ClientCertificateNewResponseEnvelopeMessages] +type clientCertificateNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ClientCertificateNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r clientCertificateNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ClientCertificateNewResponseEnvelopeSuccess bool + +const ( + ClientCertificateNewResponseEnvelopeSuccessTrue ClientCertificateNewResponseEnvelopeSuccess = true +) + +type ClientCertificateListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Limit to the number of records returned. + Limit param.Field[int64] `query:"limit"` + // Offset the results + Offset param.Field[int64] `query:"offset"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // Number of records per page. + PerPage param.Field[float64] `query:"per_page"` + // Client Certitifcate Status to filter results by. + Status param.Field[ClientCertificateListParamsStatus] `query:"status"` +} + +// URLQuery serializes [ClientCertificateListParams]'s query parameters as +// `url.Values`. +func (r ClientCertificateListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Client Certitifcate Status to filter results by. +type ClientCertificateListParamsStatus string + +const ( + ClientCertificateListParamsStatusAll ClientCertificateListParamsStatus = "all" + ClientCertificateListParamsStatusActive ClientCertificateListParamsStatus = "active" + ClientCertificateListParamsStatusPendingReactivation ClientCertificateListParamsStatus = "pending_reactivation" + ClientCertificateListParamsStatusPendingRevocation ClientCertificateListParamsStatus = "pending_revocation" + ClientCertificateListParamsStatusRevoked ClientCertificateListParamsStatus = "revoked" +) + +type ClientCertificateDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type ClientCertificateDeleteResponseEnvelope struct { + Errors []ClientCertificateDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []ClientCertificateDeleteResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesClientCertificate `json:"result,required"` + // Whether the API call was successful + Success ClientCertificateDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON clientCertificateDeleteResponseEnvelopeJSON `json:"-"` +} + +// clientCertificateDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [ClientCertificateDeleteResponseEnvelope] +type clientCertificateDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ClientCertificateDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r clientCertificateDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ClientCertificateDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON clientCertificateDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// clientCertificateDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [ClientCertificateDeleteResponseEnvelopeErrors] +type clientCertificateDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ClientCertificateDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r clientCertificateDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ClientCertificateDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON clientCertificateDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// clientCertificateDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [ClientCertificateDeleteResponseEnvelopeMessages] +type clientCertificateDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ClientCertificateDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r clientCertificateDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ClientCertificateDeleteResponseEnvelopeSuccess bool + +const ( + ClientCertificateDeleteResponseEnvelopeSuccessTrue ClientCertificateDeleteResponseEnvelopeSuccess = true +) + +type ClientCertificateEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type ClientCertificateEditResponseEnvelope struct { + Errors []ClientCertificateEditResponseEnvelopeErrors `json:"errors,required"` + Messages []ClientCertificateEditResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesClientCertificate `json:"result,required"` + // Whether the API call was successful + Success ClientCertificateEditResponseEnvelopeSuccess `json:"success,required"` + JSON clientCertificateEditResponseEnvelopeJSON `json:"-"` +} + +// clientCertificateEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [ClientCertificateEditResponseEnvelope] +type clientCertificateEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ClientCertificateEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r clientCertificateEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ClientCertificateEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON clientCertificateEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// clientCertificateEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [ClientCertificateEditResponseEnvelopeErrors] +type clientCertificateEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ClientCertificateEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r clientCertificateEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ClientCertificateEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON clientCertificateEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// clientCertificateEditResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [ClientCertificateEditResponseEnvelopeMessages] +type clientCertificateEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ClientCertificateEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r clientCertificateEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ClientCertificateEditResponseEnvelopeSuccess bool + +const ( + ClientCertificateEditResponseEnvelopeSuccessTrue ClientCertificateEditResponseEnvelopeSuccess = true +) + +type ClientCertificateGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type ClientCertificateGetResponseEnvelope struct { + Errors []ClientCertificateGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ClientCertificateGetResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesClientCertificate `json:"result,required"` + // Whether the API call was successful + Success ClientCertificateGetResponseEnvelopeSuccess `json:"success,required"` + JSON clientCertificateGetResponseEnvelopeJSON `json:"-"` +} + +// clientCertificateGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [ClientCertificateGetResponseEnvelope] +type clientCertificateGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ClientCertificateGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r clientCertificateGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ClientCertificateGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON clientCertificateGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// clientCertificateGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [ClientCertificateGetResponseEnvelopeErrors] +type clientCertificateGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ClientCertificateGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r clientCertificateGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ClientCertificateGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON clientCertificateGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// clientCertificateGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [ClientCertificateGetResponseEnvelopeMessages] +type clientCertificateGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ClientCertificateGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r clientCertificateGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ClientCertificateGetResponseEnvelopeSuccess bool + +const ( + ClientCertificateGetResponseEnvelopeSuccessTrue ClientCertificateGetResponseEnvelopeSuccess = true +) diff --git a/clientcertificate_test.go b/client_certificates/clientcertificate_test.go similarity index 88% rename from clientcertificate_test.go rename to client_certificates/clientcertificate_test.go index b816738ccf2..e8f2afeb194 100644 --- a/clientcertificate_test.go +++ b/client_certificates/clientcertificate_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package client_certificates_test import ( "context" @@ -9,6 +9,7 @@ import ( "testing" "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/client_certificates" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" ) @@ -27,7 +28,7 @@ func TestClientCertificateNew(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.ClientCertificates.New(context.TODO(), cloudflare.ClientCertificateNewParams{ + _, err := client.ClientCertificates.New(context.TODO(), client_certificates.ClientCertificateNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Csr: cloudflare.F("-----BEGIN CERTIFICATE REQUEST-----\\nMIICY....\\n-----END CERTIFICATE REQUEST-----\\n"), ValidityDays: cloudflare.F(int64(3650)), @@ -55,13 +56,13 @@ func TestClientCertificateListWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.ClientCertificates.List(context.TODO(), cloudflare.ClientCertificateListParams{ + _, err := client.ClientCertificates.List(context.TODO(), client_certificates.ClientCertificateListParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Limit: cloudflare.F(int64(10)), Offset: cloudflare.F(int64(10)), Page: cloudflare.F(1.000000), PerPage: cloudflare.F(5.000000), - Status: cloudflare.F(cloudflare.ClientCertificateListParamsStatusAll), + Status: cloudflare.F(client_certificates.ClientCertificateListParamsStatusAll), }) if err != nil { var apierr *cloudflare.Error @@ -89,7 +90,7 @@ func TestClientCertificateDelete(t *testing.T) { _, err := client.ClientCertificates.Delete( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.ClientCertificateDeleteParams{ + client_certificates.ClientCertificateDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) @@ -119,7 +120,7 @@ func TestClientCertificateEdit(t *testing.T) { _, err := client.ClientCertificates.Edit( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.ClientCertificateEditParams{ + client_certificates.ClientCertificateEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) @@ -149,7 +150,7 @@ func TestClientCertificateGet(t *testing.T) { _, err := client.ClientCertificates.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.ClientCertificateGetParams{ + client_certificates.ClientCertificateGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) diff --git a/client_test.go b/client_test.go index f2bb874ad31..1cb6f5c03ab 100644 --- a/client_test.go +++ b/client_test.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" ) type closureTransport struct { @@ -37,12 +38,12 @@ func TestRetryAfter(t *testing.T) { }, }), ) - res, err := client.Zones.New(context.Background(), cloudflare.ZoneNewParams{ - Account: cloudflare.F(cloudflare.ZoneNewParamsAccount{ + res, err := client.Zones.New(context.Background(), zones.ZoneNewParams{ + Account: cloudflare.F(zones.ZoneNewParamsAccount{ ID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }), Name: cloudflare.F("example.com"), - Type: cloudflare.F(cloudflare.ZoneNewParamsTypeFull), + Type: cloudflare.F(zones.ZoneNewParamsTypeFull), }) if err == nil || res != nil { t.Error("Expected there to be a cancel error and for the response to be nil") @@ -69,12 +70,12 @@ func TestRetryAfterMs(t *testing.T) { }, }), ) - res, err := client.Zones.New(context.Background(), cloudflare.ZoneNewParams{ - Account: cloudflare.F(cloudflare.ZoneNewParamsAccount{ + res, err := client.Zones.New(context.Background(), zones.ZoneNewParams{ + Account: cloudflare.F(zones.ZoneNewParamsAccount{ ID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }), Name: cloudflare.F("example.com"), - Type: cloudflare.F(cloudflare.ZoneNewParamsTypeFull), + Type: cloudflare.F(zones.ZoneNewParamsTypeFull), }) if err == nil || res != nil { t.Error("Expected there to be a cancel error and for the response to be nil") @@ -97,12 +98,12 @@ func TestContextCancel(t *testing.T) { ) cancelCtx, cancel := context.WithCancel(context.Background()) cancel() - res, err := client.Zones.New(cancelCtx, cloudflare.ZoneNewParams{ - Account: cloudflare.F(cloudflare.ZoneNewParamsAccount{ + res, err := client.Zones.New(cancelCtx, zones.ZoneNewParams{ + Account: cloudflare.F(zones.ZoneNewParamsAccount{ ID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }), Name: cloudflare.F("example.com"), - Type: cloudflare.F(cloudflare.ZoneNewParamsTypeFull), + Type: cloudflare.F(zones.ZoneNewParamsTypeFull), }) if err == nil || res != nil { t.Error("Expected there to be a cancel error and for the response to be nil") @@ -122,12 +123,12 @@ func TestContextCancelDelay(t *testing.T) { ) cancelCtx, cancel := context.WithTimeout(context.Background(), 2*time.Millisecond) defer cancel() - res, err := client.Zones.New(cancelCtx, cloudflare.ZoneNewParams{ - Account: cloudflare.F(cloudflare.ZoneNewParamsAccount{ + res, err := client.Zones.New(cancelCtx, zones.ZoneNewParams{ + Account: cloudflare.F(zones.ZoneNewParamsAccount{ ID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }), Name: cloudflare.F("example.com"), - Type: cloudflare.F(cloudflare.ZoneNewParamsTypeFull), + Type: cloudflare.F(zones.ZoneNewParamsTypeFull), }) if err == nil || res != nil { t.Error("expected there to be a cancel error and for the response to be nil") @@ -153,12 +154,12 @@ func TestContextDeadline(t *testing.T) { }, }), ) - res, err := client.Zones.New(deadlineCtx, cloudflare.ZoneNewParams{ - Account: cloudflare.F(cloudflare.ZoneNewParamsAccount{ + res, err := client.Zones.New(deadlineCtx, zones.ZoneNewParams{ + Account: cloudflare.F(zones.ZoneNewParamsAccount{ ID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }), Name: cloudflare.F("example.com"), - Type: cloudflare.F(cloudflare.ZoneNewParamsTypeFull), + Type: cloudflare.F(zones.ZoneNewParamsTypeFull), }) if err == nil || res != nil { t.Error("expected there to be a deadline error and for the response to be nil") diff --git a/clientcertificate.go b/clientcertificate.go deleted file mode 100644 index 4f85ff5465e..00000000000 --- a/clientcertificate.go +++ /dev/null @@ -1,1046 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" -) - -// ClientCertificateService 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 [NewClientCertificateService] method -// instead. -type ClientCertificateService struct { - Options []option.RequestOption -} - -// NewClientCertificateService 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 NewClientCertificateService(opts ...option.RequestOption) (r *ClientCertificateService) { - r = &ClientCertificateService{} - r.Options = opts - return -} - -// Create a new API Shield mTLS Client Certificate -func (r *ClientCertificateService) New(ctx context.Context, params ClientCertificateNewParams, opts ...option.RequestOption) (res *ClientCertificateNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ClientCertificateNewResponseEnvelope - path := fmt.Sprintf("zones/%s/client_certificates", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List all of your Zone's API Shield mTLS Client Certificates by Status and/or -// using Pagination -func (r *ClientCertificateService) List(ctx context.Context, params ClientCertificateListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[ClientCertificateListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("zones/%s/client_certificates", params.ZoneID) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// List all of your Zone's API Shield mTLS Client Certificates by Status and/or -// using Pagination -func (r *ClientCertificateService) ListAutoPaging(ctx context.Context, params ClientCertificateListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[ClientCertificateListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) -} - -// Set a API Shield mTLS Client Certificate to pending_revocation status for -// processing to revoked status. -func (r *ClientCertificateService) Delete(ctx context.Context, clientCertificateID string, body ClientCertificateDeleteParams, opts ...option.RequestOption) (res *ClientCertificateDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ClientCertificateDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/client_certificates/%s", body.ZoneID, clientCertificateID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// If a API Shield mTLS Client Certificate is in a pending_revocation state, you -// may reactivate it with this endpoint. -func (r *ClientCertificateService) Edit(ctx context.Context, clientCertificateID string, body ClientCertificateEditParams, opts ...option.RequestOption) (res *ClientCertificateEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ClientCertificateEditResponseEnvelope - path := fmt.Sprintf("zones/%s/client_certificates/%s", body.ZoneID, clientCertificateID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get Details for a single mTLS API Shield Client Certificate -func (r *ClientCertificateService) Get(ctx context.Context, clientCertificateID string, query ClientCertificateGetParams, opts ...option.RequestOption) (res *ClientCertificateGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ClientCertificateGetResponseEnvelope - path := fmt.Sprintf("zones/%s/client_certificates/%s", query.ZoneID, clientCertificateID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ClientCertificateNewResponse struct { - // Identifier - ID string `json:"id"` - // The Client Certificate PEM - Certificate string `json:"certificate"` - // Certificate Authority used to issue the Client Certificate - CertificateAuthority ClientCertificateNewResponseCertificateAuthority `json:"certificate_authority"` - // Common Name of the Client Certificate - CommonName string `json:"common_name"` - // Country, provided by the CSR - Country string `json:"country"` - // The Certificate Signing Request (CSR). Must be newline-encoded. - Csr string `json:"csr"` - // Date that the Client Certificate expires - ExpiresOn string `json:"expires_on"` - // Unique identifier of the Client Certificate - FingerprintSha256 string `json:"fingerprint_sha256"` - // Date that the Client Certificate was issued by the Certificate Authority - IssuedOn string `json:"issued_on"` - // Location, provided by the CSR - Location string `json:"location"` - // Organization, provided by the CSR - Organization string `json:"organization"` - // Organizational Unit, provided by the CSR - OrganizationalUnit string `json:"organizational_unit"` - // The serial number on the created Client Certificate. - SerialNumber string `json:"serial_number"` - // The type of hash used for the Client Certificate.. - Signature string `json:"signature"` - // Subject Key Identifier - Ski string `json:"ski"` - // State, provided by the CSR - State string `json:"state"` - // Client Certificates may be active or revoked, and the pending_reactivation or - // pending_revocation represent in-progress asynchronous transitions - Status ClientCertificateNewResponseStatus `json:"status"` - // The number of days the Client Certificate will be valid after the issued_on date - ValidityDays int64 `json:"validity_days"` - JSON clientCertificateNewResponseJSON `json:"-"` -} - -// clientCertificateNewResponseJSON contains the JSON metadata for the struct -// [ClientCertificateNewResponse] -type clientCertificateNewResponseJSON struct { - ID apijson.Field - Certificate apijson.Field - CertificateAuthority apijson.Field - CommonName apijson.Field - Country apijson.Field - Csr apijson.Field - ExpiresOn apijson.Field - FingerprintSha256 apijson.Field - IssuedOn apijson.Field - Location apijson.Field - Organization apijson.Field - OrganizationalUnit apijson.Field - SerialNumber apijson.Field - Signature apijson.Field - Ski apijson.Field - State apijson.Field - Status apijson.Field - ValidityDays apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateNewResponseJSON) RawJSON() string { - return r.raw -} - -// Certificate Authority used to issue the Client Certificate -type ClientCertificateNewResponseCertificateAuthority struct { - ID string `json:"id"` - Name string `json:"name"` - JSON clientCertificateNewResponseCertificateAuthorityJSON `json:"-"` -} - -// clientCertificateNewResponseCertificateAuthorityJSON contains the JSON metadata -// for the struct [ClientCertificateNewResponseCertificateAuthority] -type clientCertificateNewResponseCertificateAuthorityJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateNewResponseCertificateAuthority) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateNewResponseCertificateAuthorityJSON) RawJSON() string { - return r.raw -} - -// Client Certificates may be active or revoked, and the pending_reactivation or -// pending_revocation represent in-progress asynchronous transitions -type ClientCertificateNewResponseStatus string - -const ( - ClientCertificateNewResponseStatusActive ClientCertificateNewResponseStatus = "active" - ClientCertificateNewResponseStatusPendingReactivation ClientCertificateNewResponseStatus = "pending_reactivation" - ClientCertificateNewResponseStatusPendingRevocation ClientCertificateNewResponseStatus = "pending_revocation" - ClientCertificateNewResponseStatusRevoked ClientCertificateNewResponseStatus = "revoked" -) - -type ClientCertificateListResponse struct { - // Identifier - ID string `json:"id"` - // The Client Certificate PEM - Certificate string `json:"certificate"` - // Certificate Authority used to issue the Client Certificate - CertificateAuthority ClientCertificateListResponseCertificateAuthority `json:"certificate_authority"` - // Common Name of the Client Certificate - CommonName string `json:"common_name"` - // Country, provided by the CSR - Country string `json:"country"` - // The Certificate Signing Request (CSR). Must be newline-encoded. - Csr string `json:"csr"` - // Date that the Client Certificate expires - ExpiresOn string `json:"expires_on"` - // Unique identifier of the Client Certificate - FingerprintSha256 string `json:"fingerprint_sha256"` - // Date that the Client Certificate was issued by the Certificate Authority - IssuedOn string `json:"issued_on"` - // Location, provided by the CSR - Location string `json:"location"` - // Organization, provided by the CSR - Organization string `json:"organization"` - // Organizational Unit, provided by the CSR - OrganizationalUnit string `json:"organizational_unit"` - // The serial number on the created Client Certificate. - SerialNumber string `json:"serial_number"` - // The type of hash used for the Client Certificate.. - Signature string `json:"signature"` - // Subject Key Identifier - Ski string `json:"ski"` - // State, provided by the CSR - State string `json:"state"` - // Client Certificates may be active or revoked, and the pending_reactivation or - // pending_revocation represent in-progress asynchronous transitions - Status ClientCertificateListResponseStatus `json:"status"` - // The number of days the Client Certificate will be valid after the issued_on date - ValidityDays int64 `json:"validity_days"` - JSON clientCertificateListResponseJSON `json:"-"` -} - -// clientCertificateListResponseJSON contains the JSON metadata for the struct -// [ClientCertificateListResponse] -type clientCertificateListResponseJSON struct { - ID apijson.Field - Certificate apijson.Field - CertificateAuthority apijson.Field - CommonName apijson.Field - Country apijson.Field - Csr apijson.Field - ExpiresOn apijson.Field - FingerprintSha256 apijson.Field - IssuedOn apijson.Field - Location apijson.Field - Organization apijson.Field - OrganizationalUnit apijson.Field - SerialNumber apijson.Field - Signature apijson.Field - Ski apijson.Field - State apijson.Field - Status apijson.Field - ValidityDays apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateListResponseJSON) RawJSON() string { - return r.raw -} - -// Certificate Authority used to issue the Client Certificate -type ClientCertificateListResponseCertificateAuthority struct { - ID string `json:"id"` - Name string `json:"name"` - JSON clientCertificateListResponseCertificateAuthorityJSON `json:"-"` -} - -// clientCertificateListResponseCertificateAuthorityJSON contains the JSON metadata -// for the struct [ClientCertificateListResponseCertificateAuthority] -type clientCertificateListResponseCertificateAuthorityJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateListResponseCertificateAuthority) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateListResponseCertificateAuthorityJSON) RawJSON() string { - return r.raw -} - -// Client Certificates may be active or revoked, and the pending_reactivation or -// pending_revocation represent in-progress asynchronous transitions -type ClientCertificateListResponseStatus string - -const ( - ClientCertificateListResponseStatusActive ClientCertificateListResponseStatus = "active" - ClientCertificateListResponseStatusPendingReactivation ClientCertificateListResponseStatus = "pending_reactivation" - ClientCertificateListResponseStatusPendingRevocation ClientCertificateListResponseStatus = "pending_revocation" - ClientCertificateListResponseStatusRevoked ClientCertificateListResponseStatus = "revoked" -) - -type ClientCertificateDeleteResponse struct { - // Identifier - ID string `json:"id"` - // The Client Certificate PEM - Certificate string `json:"certificate"` - // Certificate Authority used to issue the Client Certificate - CertificateAuthority ClientCertificateDeleteResponseCertificateAuthority `json:"certificate_authority"` - // Common Name of the Client Certificate - CommonName string `json:"common_name"` - // Country, provided by the CSR - Country string `json:"country"` - // The Certificate Signing Request (CSR). Must be newline-encoded. - Csr string `json:"csr"` - // Date that the Client Certificate expires - ExpiresOn string `json:"expires_on"` - // Unique identifier of the Client Certificate - FingerprintSha256 string `json:"fingerprint_sha256"` - // Date that the Client Certificate was issued by the Certificate Authority - IssuedOn string `json:"issued_on"` - // Location, provided by the CSR - Location string `json:"location"` - // Organization, provided by the CSR - Organization string `json:"organization"` - // Organizational Unit, provided by the CSR - OrganizationalUnit string `json:"organizational_unit"` - // The serial number on the created Client Certificate. - SerialNumber string `json:"serial_number"` - // The type of hash used for the Client Certificate.. - Signature string `json:"signature"` - // Subject Key Identifier - Ski string `json:"ski"` - // State, provided by the CSR - State string `json:"state"` - // Client Certificates may be active or revoked, and the pending_reactivation or - // pending_revocation represent in-progress asynchronous transitions - Status ClientCertificateDeleteResponseStatus `json:"status"` - // The number of days the Client Certificate will be valid after the issued_on date - ValidityDays int64 `json:"validity_days"` - JSON clientCertificateDeleteResponseJSON `json:"-"` -} - -// clientCertificateDeleteResponseJSON contains the JSON metadata for the struct -// [ClientCertificateDeleteResponse] -type clientCertificateDeleteResponseJSON struct { - ID apijson.Field - Certificate apijson.Field - CertificateAuthority apijson.Field - CommonName apijson.Field - Country apijson.Field - Csr apijson.Field - ExpiresOn apijson.Field - FingerprintSha256 apijson.Field - IssuedOn apijson.Field - Location apijson.Field - Organization apijson.Field - OrganizationalUnit apijson.Field - SerialNumber apijson.Field - Signature apijson.Field - Ski apijson.Field - State apijson.Field - Status apijson.Field - ValidityDays apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// Certificate Authority used to issue the Client Certificate -type ClientCertificateDeleteResponseCertificateAuthority struct { - ID string `json:"id"` - Name string `json:"name"` - JSON clientCertificateDeleteResponseCertificateAuthorityJSON `json:"-"` -} - -// clientCertificateDeleteResponseCertificateAuthorityJSON contains the JSON -// metadata for the struct [ClientCertificateDeleteResponseCertificateAuthority] -type clientCertificateDeleteResponseCertificateAuthorityJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateDeleteResponseCertificateAuthority) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateDeleteResponseCertificateAuthorityJSON) RawJSON() string { - return r.raw -} - -// Client Certificates may be active or revoked, and the pending_reactivation or -// pending_revocation represent in-progress asynchronous transitions -type ClientCertificateDeleteResponseStatus string - -const ( - ClientCertificateDeleteResponseStatusActive ClientCertificateDeleteResponseStatus = "active" - ClientCertificateDeleteResponseStatusPendingReactivation ClientCertificateDeleteResponseStatus = "pending_reactivation" - ClientCertificateDeleteResponseStatusPendingRevocation ClientCertificateDeleteResponseStatus = "pending_revocation" - ClientCertificateDeleteResponseStatusRevoked ClientCertificateDeleteResponseStatus = "revoked" -) - -type ClientCertificateEditResponse struct { - // Identifier - ID string `json:"id"` - // The Client Certificate PEM - Certificate string `json:"certificate"` - // Certificate Authority used to issue the Client Certificate - CertificateAuthority ClientCertificateEditResponseCertificateAuthority `json:"certificate_authority"` - // Common Name of the Client Certificate - CommonName string `json:"common_name"` - // Country, provided by the CSR - Country string `json:"country"` - // The Certificate Signing Request (CSR). Must be newline-encoded. - Csr string `json:"csr"` - // Date that the Client Certificate expires - ExpiresOn string `json:"expires_on"` - // Unique identifier of the Client Certificate - FingerprintSha256 string `json:"fingerprint_sha256"` - // Date that the Client Certificate was issued by the Certificate Authority - IssuedOn string `json:"issued_on"` - // Location, provided by the CSR - Location string `json:"location"` - // Organization, provided by the CSR - Organization string `json:"organization"` - // Organizational Unit, provided by the CSR - OrganizationalUnit string `json:"organizational_unit"` - // The serial number on the created Client Certificate. - SerialNumber string `json:"serial_number"` - // The type of hash used for the Client Certificate.. - Signature string `json:"signature"` - // Subject Key Identifier - Ski string `json:"ski"` - // State, provided by the CSR - State string `json:"state"` - // Client Certificates may be active or revoked, and the pending_reactivation or - // pending_revocation represent in-progress asynchronous transitions - Status ClientCertificateEditResponseStatus `json:"status"` - // The number of days the Client Certificate will be valid after the issued_on date - ValidityDays int64 `json:"validity_days"` - JSON clientCertificateEditResponseJSON `json:"-"` -} - -// clientCertificateEditResponseJSON contains the JSON metadata for the struct -// [ClientCertificateEditResponse] -type clientCertificateEditResponseJSON struct { - ID apijson.Field - Certificate apijson.Field - CertificateAuthority apijson.Field - CommonName apijson.Field - Country apijson.Field - Csr apijson.Field - ExpiresOn apijson.Field - FingerprintSha256 apijson.Field - IssuedOn apijson.Field - Location apijson.Field - Organization apijson.Field - OrganizationalUnit apijson.Field - SerialNumber apijson.Field - Signature apijson.Field - Ski apijson.Field - State apijson.Field - Status apijson.Field - ValidityDays apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateEditResponseJSON) RawJSON() string { - return r.raw -} - -// Certificate Authority used to issue the Client Certificate -type ClientCertificateEditResponseCertificateAuthority struct { - ID string `json:"id"` - Name string `json:"name"` - JSON clientCertificateEditResponseCertificateAuthorityJSON `json:"-"` -} - -// clientCertificateEditResponseCertificateAuthorityJSON contains the JSON metadata -// for the struct [ClientCertificateEditResponseCertificateAuthority] -type clientCertificateEditResponseCertificateAuthorityJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateEditResponseCertificateAuthority) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateEditResponseCertificateAuthorityJSON) RawJSON() string { - return r.raw -} - -// Client Certificates may be active or revoked, and the pending_reactivation or -// pending_revocation represent in-progress asynchronous transitions -type ClientCertificateEditResponseStatus string - -const ( - ClientCertificateEditResponseStatusActive ClientCertificateEditResponseStatus = "active" - ClientCertificateEditResponseStatusPendingReactivation ClientCertificateEditResponseStatus = "pending_reactivation" - ClientCertificateEditResponseStatusPendingRevocation ClientCertificateEditResponseStatus = "pending_revocation" - ClientCertificateEditResponseStatusRevoked ClientCertificateEditResponseStatus = "revoked" -) - -type ClientCertificateGetResponse struct { - // Identifier - ID string `json:"id"` - // The Client Certificate PEM - Certificate string `json:"certificate"` - // Certificate Authority used to issue the Client Certificate - CertificateAuthority ClientCertificateGetResponseCertificateAuthority `json:"certificate_authority"` - // Common Name of the Client Certificate - CommonName string `json:"common_name"` - // Country, provided by the CSR - Country string `json:"country"` - // The Certificate Signing Request (CSR). Must be newline-encoded. - Csr string `json:"csr"` - // Date that the Client Certificate expires - ExpiresOn string `json:"expires_on"` - // Unique identifier of the Client Certificate - FingerprintSha256 string `json:"fingerprint_sha256"` - // Date that the Client Certificate was issued by the Certificate Authority - IssuedOn string `json:"issued_on"` - // Location, provided by the CSR - Location string `json:"location"` - // Organization, provided by the CSR - Organization string `json:"organization"` - // Organizational Unit, provided by the CSR - OrganizationalUnit string `json:"organizational_unit"` - // The serial number on the created Client Certificate. - SerialNumber string `json:"serial_number"` - // The type of hash used for the Client Certificate.. - Signature string `json:"signature"` - // Subject Key Identifier - Ski string `json:"ski"` - // State, provided by the CSR - State string `json:"state"` - // Client Certificates may be active or revoked, and the pending_reactivation or - // pending_revocation represent in-progress asynchronous transitions - Status ClientCertificateGetResponseStatus `json:"status"` - // The number of days the Client Certificate will be valid after the issued_on date - ValidityDays int64 `json:"validity_days"` - JSON clientCertificateGetResponseJSON `json:"-"` -} - -// clientCertificateGetResponseJSON contains the JSON metadata for the struct -// [ClientCertificateGetResponse] -type clientCertificateGetResponseJSON struct { - ID apijson.Field - Certificate apijson.Field - CertificateAuthority apijson.Field - CommonName apijson.Field - Country apijson.Field - Csr apijson.Field - ExpiresOn apijson.Field - FingerprintSha256 apijson.Field - IssuedOn apijson.Field - Location apijson.Field - Organization apijson.Field - OrganizationalUnit apijson.Field - SerialNumber apijson.Field - Signature apijson.Field - Ski apijson.Field - State apijson.Field - Status apijson.Field - ValidityDays apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateGetResponseJSON) RawJSON() string { - return r.raw -} - -// Certificate Authority used to issue the Client Certificate -type ClientCertificateGetResponseCertificateAuthority struct { - ID string `json:"id"` - Name string `json:"name"` - JSON clientCertificateGetResponseCertificateAuthorityJSON `json:"-"` -} - -// clientCertificateGetResponseCertificateAuthorityJSON contains the JSON metadata -// for the struct [ClientCertificateGetResponseCertificateAuthority] -type clientCertificateGetResponseCertificateAuthorityJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateGetResponseCertificateAuthority) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateGetResponseCertificateAuthorityJSON) RawJSON() string { - return r.raw -} - -// Client Certificates may be active or revoked, and the pending_reactivation or -// pending_revocation represent in-progress asynchronous transitions -type ClientCertificateGetResponseStatus string - -const ( - ClientCertificateGetResponseStatusActive ClientCertificateGetResponseStatus = "active" - ClientCertificateGetResponseStatusPendingReactivation ClientCertificateGetResponseStatus = "pending_reactivation" - ClientCertificateGetResponseStatusPendingRevocation ClientCertificateGetResponseStatus = "pending_revocation" - ClientCertificateGetResponseStatusRevoked ClientCertificateGetResponseStatus = "revoked" -) - -type ClientCertificateNewParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // The Certificate Signing Request (CSR). Must be newline-encoded. - Csr param.Field[string] `json:"csr,required"` - // The number of days the Client Certificate will be valid after the issued_on date - ValidityDays param.Field[int64] `json:"validity_days,required"` -} - -func (r ClientCertificateNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ClientCertificateNewResponseEnvelope struct { - Errors []ClientCertificateNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ClientCertificateNewResponseEnvelopeMessages `json:"messages,required"` - Result ClientCertificateNewResponse `json:"result,required"` - // Whether the API call was successful - Success ClientCertificateNewResponseEnvelopeSuccess `json:"success,required"` - JSON clientCertificateNewResponseEnvelopeJSON `json:"-"` -} - -// clientCertificateNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [ClientCertificateNewResponseEnvelope] -type clientCertificateNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ClientCertificateNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON clientCertificateNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// clientCertificateNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ClientCertificateNewResponseEnvelopeErrors] -type clientCertificateNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ClientCertificateNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON clientCertificateNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// clientCertificateNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ClientCertificateNewResponseEnvelopeMessages] -type clientCertificateNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ClientCertificateNewResponseEnvelopeSuccess bool - -const ( - ClientCertificateNewResponseEnvelopeSuccessTrue ClientCertificateNewResponseEnvelopeSuccess = true -) - -type ClientCertificateListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Limit to the number of records returned. - Limit param.Field[int64] `query:"limit"` - // Offset the results - Offset param.Field[int64] `query:"offset"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // Number of records per page. - PerPage param.Field[float64] `query:"per_page"` - // Client Certitifcate Status to filter results by. - Status param.Field[ClientCertificateListParamsStatus] `query:"status"` -} - -// URLQuery serializes [ClientCertificateListParams]'s query parameters as -// `url.Values`. -func (r ClientCertificateListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Client Certitifcate Status to filter results by. -type ClientCertificateListParamsStatus string - -const ( - ClientCertificateListParamsStatusAll ClientCertificateListParamsStatus = "all" - ClientCertificateListParamsStatusActive ClientCertificateListParamsStatus = "active" - ClientCertificateListParamsStatusPendingReactivation ClientCertificateListParamsStatus = "pending_reactivation" - ClientCertificateListParamsStatusPendingRevocation ClientCertificateListParamsStatus = "pending_revocation" - ClientCertificateListParamsStatusRevoked ClientCertificateListParamsStatus = "revoked" -) - -type ClientCertificateDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ClientCertificateDeleteResponseEnvelope struct { - Errors []ClientCertificateDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ClientCertificateDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ClientCertificateDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ClientCertificateDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON clientCertificateDeleteResponseEnvelopeJSON `json:"-"` -} - -// clientCertificateDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [ClientCertificateDeleteResponseEnvelope] -type clientCertificateDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ClientCertificateDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON clientCertificateDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// clientCertificateDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ClientCertificateDeleteResponseEnvelopeErrors] -type clientCertificateDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ClientCertificateDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON clientCertificateDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// clientCertificateDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ClientCertificateDeleteResponseEnvelopeMessages] -type clientCertificateDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ClientCertificateDeleteResponseEnvelopeSuccess bool - -const ( - ClientCertificateDeleteResponseEnvelopeSuccessTrue ClientCertificateDeleteResponseEnvelopeSuccess = true -) - -type ClientCertificateEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ClientCertificateEditResponseEnvelope struct { - Errors []ClientCertificateEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ClientCertificateEditResponseEnvelopeMessages `json:"messages,required"` - Result ClientCertificateEditResponse `json:"result,required"` - // Whether the API call was successful - Success ClientCertificateEditResponseEnvelopeSuccess `json:"success,required"` - JSON clientCertificateEditResponseEnvelopeJSON `json:"-"` -} - -// clientCertificateEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ClientCertificateEditResponseEnvelope] -type clientCertificateEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ClientCertificateEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON clientCertificateEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// clientCertificateEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ClientCertificateEditResponseEnvelopeErrors] -type clientCertificateEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ClientCertificateEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON clientCertificateEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// clientCertificateEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ClientCertificateEditResponseEnvelopeMessages] -type clientCertificateEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ClientCertificateEditResponseEnvelopeSuccess bool - -const ( - ClientCertificateEditResponseEnvelopeSuccessTrue ClientCertificateEditResponseEnvelopeSuccess = true -) - -type ClientCertificateGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ClientCertificateGetResponseEnvelope struct { - Errors []ClientCertificateGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ClientCertificateGetResponseEnvelopeMessages `json:"messages,required"` - Result ClientCertificateGetResponse `json:"result,required"` - // Whether the API call was successful - Success ClientCertificateGetResponseEnvelopeSuccess `json:"success,required"` - JSON clientCertificateGetResponseEnvelopeJSON `json:"-"` -} - -// clientCertificateGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ClientCertificateGetResponseEnvelope] -type clientCertificateGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ClientCertificateGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON clientCertificateGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// clientCertificateGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ClientCertificateGetResponseEnvelopeErrors] -type clientCertificateGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ClientCertificateGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON clientCertificateGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// clientCertificateGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ClientCertificateGetResponseEnvelopeMessages] -type clientCertificateGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ClientCertificateGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r clientCertificateGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ClientCertificateGetResponseEnvelopeSuccess bool - -const ( - ClientCertificateGetResponseEnvelopeSuccessTrue ClientCertificateGetResponseEnvelopeSuccess = true -) diff --git a/cloudforce_one/aliases.go b/cloudforce_one/aliases.go new file mode 100644 index 00000000000..97c5ca888e3 --- /dev/null +++ b/cloudforce_one/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package cloudforce_one + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/cloudforceone.go b/cloudforce_one/cloudforceone.go similarity index 88% rename from cloudforceone.go rename to cloudforce_one/cloudforceone.go index f619fb3b0bd..dfcf8c97e79 100644 --- a/cloudforceone.go +++ b/cloudforce_one/cloudforceone.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package cloudforce_one import ( "github.com/cloudflare/cloudflare-go/option" @@ -13,7 +13,7 @@ import ( // instead. type CloudforceOneService struct { Options []option.RequestOption - Requests *CloudforceOneRequestService + Requests *RequestService } // NewCloudforceOneService generates a new service that applies the given options @@ -22,6 +22,6 @@ type CloudforceOneService struct { func NewCloudforceOneService(opts ...option.RequestOption) (r *CloudforceOneService) { r = &CloudforceOneService{} r.Options = opts - r.Requests = NewCloudforceOneRequestService(opts...) + r.Requests = NewRequestService(opts...) return } diff --git a/cloudforce_one/request.go b/cloudforce_one/request.go new file mode 100644 index 00000000000..9e9674433d4 --- /dev/null +++ b/cloudforce_one/request.go @@ -0,0 +1,1103 @@ +// File generated from our OpenAPI spec by Stainless. + +package cloudforce_one + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// RequestService 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 [NewRequestService] method instead. +type RequestService struct { + Options []option.RequestOption + Message *RequestMessageService + Priority *RequestPriorityService +} + +// NewRequestService 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 NewRequestService(opts ...option.RequestOption) (r *RequestService) { + r = &RequestService{} + r.Options = opts + r.Message = NewRequestMessageService(opts...) + r.Priority = NewRequestPriorityService(opts...) + return +} + +// Creating a request adds the request into the Cloudforce One queue for analysis. +// In addition to the content, a short title, type, priority, and releasability +// should be provided. If one is not provided a default will be assigned. +func (r *RequestService) New(ctx context.Context, accountIdentifier string, body RequestNewParams, opts ...option.RequestOption) (res *CloudforceOneRequestItem, err error) { + opts = append(r.Options[:], opts...) + var env RequestNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/new", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updating a request alters the request in the Cloudforce One queue. This API may +// be used to update any attributes of the request after the initial submission. +// Only fields that you choose to update need to be add to the request body +func (r *RequestService) Update(ctx context.Context, accountIdentifier string, requestIdentifier string, body RequestUpdateParams, opts ...option.RequestOption) (res *CloudforceOneRequestItem, err error) { + opts = append(r.Options[:], opts...) + var env RequestUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s", accountIdentifier, requestIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List Requests +func (r *RequestService) List(ctx context.Context, accountIdentifier string, body RequestListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[CloudforceOneRequestListItem], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("accounts/%s/cloudforce-one/requests", accountIdentifier) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, body, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// List Requests +func (r *RequestService) ListAutoPaging(ctx context.Context, accountIdentifier string, body RequestListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[CloudforceOneRequestListItem] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, accountIdentifier, body, opts...)) +} + +// Delete a Request +func (r *RequestService) Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, opts ...option.RequestOption) (res *RequestDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env RequestDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s", accountIdentifier, requestIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get Request Priority, Status, and TLP constants +func (r *RequestService) Constants(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *CloudforceOneRequestConstants, err error) { + opts = append(r.Options[:], opts...) + var env RequestConstantsResponseEnvelope + path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/constants", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a Request +func (r *RequestService) Get(ctx context.Context, accountIdentifier string, requestIdentifier string, opts ...option.RequestOption) (res *CloudforceOneRequestItem, err error) { + opts = append(r.Options[:], opts...) + var env RequestGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s", accountIdentifier, requestIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get Request Quota +func (r *RequestService) Quota(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *CloudforceOneQuota, err error) { + opts = append(r.Options[:], opts...) + var env RequestQuotaResponseEnvelope + path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/quota", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get Request Types +func (r *RequestService) Types(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *CloudforceOneRequestTypes, err error) { + opts = append(r.Options[:], opts...) + var env RequestTypesResponseEnvelope + path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/types", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type CloudforceOneQuota struct { + // Anniversary date is when annual quota limit is refresh + AnniversaryDate time.Time `json:"anniversary_date" format:"date-time"` + // Quater anniversary date is when quota limit is refreshed each quarter + QuarterAnniversaryDate time.Time `json:"quarter_anniversary_date" format:"date-time"` + // Tokens for the quarter + Quota int64 `json:"quota"` + // Tokens remaining for the quarter + Remaining int64 `json:"remaining"` + JSON cloudforceOneQuotaJSON `json:"-"` +} + +// cloudforceOneQuotaJSON contains the JSON metadata for the struct +// [CloudforceOneQuota] +type cloudforceOneQuotaJSON struct { + AnniversaryDate apijson.Field + QuarterAnniversaryDate apijson.Field + Quota apijson.Field + Remaining apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CloudforceOneQuota) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cloudforceOneQuotaJSON) RawJSON() string { + return r.raw +} + +type CloudforceOneRequestConstants struct { + Priority []CloudforceOneRequestConstantsPriority `json:"priority"` + Status []CloudforceOneRequestConstantsStatus `json:"status"` + Tlp []CloudforceOneRequestConstantsTlp `json:"tlp"` + JSON cloudforceOneRequestConstantsJSON `json:"-"` +} + +// cloudforceOneRequestConstantsJSON contains the JSON metadata for the struct +// [CloudforceOneRequestConstants] +type cloudforceOneRequestConstantsJSON struct { + Priority apijson.Field + Status apijson.Field + Tlp apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CloudforceOneRequestConstants) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cloudforceOneRequestConstantsJSON) RawJSON() string { + return r.raw +} + +type CloudforceOneRequestConstantsPriority string + +const ( + CloudforceOneRequestConstantsPriorityRoutine CloudforceOneRequestConstantsPriority = "routine" + CloudforceOneRequestConstantsPriorityHigh CloudforceOneRequestConstantsPriority = "high" + CloudforceOneRequestConstantsPriorityUrgent CloudforceOneRequestConstantsPriority = "urgent" +) + +// Request Status +type CloudforceOneRequestConstantsStatus string + +const ( + CloudforceOneRequestConstantsStatusOpen CloudforceOneRequestConstantsStatus = "open" + CloudforceOneRequestConstantsStatusAccepted CloudforceOneRequestConstantsStatus = "accepted" + CloudforceOneRequestConstantsStatusReported CloudforceOneRequestConstantsStatus = "reported" + CloudforceOneRequestConstantsStatusApproved CloudforceOneRequestConstantsStatus = "approved" + CloudforceOneRequestConstantsStatusCompleted CloudforceOneRequestConstantsStatus = "completed" + CloudforceOneRequestConstantsStatusDeclined CloudforceOneRequestConstantsStatus = "declined" +) + +// The CISA defined Traffic Light Protocol (TLP) +type CloudforceOneRequestConstantsTlp string + +const ( + CloudforceOneRequestConstantsTlpClear CloudforceOneRequestConstantsTlp = "clear" + CloudforceOneRequestConstantsTlpAmber CloudforceOneRequestConstantsTlp = "amber" + CloudforceOneRequestConstantsTlpAmberStrict CloudforceOneRequestConstantsTlp = "amber-strict" + CloudforceOneRequestConstantsTlpGreen CloudforceOneRequestConstantsTlp = "green" + CloudforceOneRequestConstantsTlpRed CloudforceOneRequestConstantsTlp = "red" +) + +type CloudforceOneRequestItem struct { + // UUID + ID string `json:"id,required"` + // Request content + Content string `json:"content,required"` + Created time.Time `json:"created,required" format:"date-time"` + Priority time.Time `json:"priority,required" format:"date-time"` + // Requested information from request + Request string `json:"request,required"` + // Brief description of the request + Summary string `json:"summary,required"` + // The CISA defined Traffic Light Protocol (TLP) + Tlp CloudforceOneRequestItemTlp `json:"tlp,required"` + Updated time.Time `json:"updated,required" format:"date-time"` + Completed time.Time `json:"completed" format:"date-time"` + // Tokens for the request messages + MessageTokens int64 `json:"message_tokens"` + // Readable Request ID + ReadableID string `json:"readable_id"` + // Request Status + Status CloudforceOneRequestItemStatus `json:"status"` + // Tokens for the request + Tokens int64 `json:"tokens"` + JSON cloudforceOneRequestItemJSON `json:"-"` +} + +// cloudforceOneRequestItemJSON contains the JSON metadata for the struct +// [CloudforceOneRequestItem] +type cloudforceOneRequestItemJSON struct { + ID apijson.Field + Content apijson.Field + Created apijson.Field + Priority apijson.Field + Request apijson.Field + Summary apijson.Field + Tlp apijson.Field + Updated apijson.Field + Completed apijson.Field + MessageTokens apijson.Field + ReadableID apijson.Field + Status apijson.Field + Tokens apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CloudforceOneRequestItem) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cloudforceOneRequestItemJSON) RawJSON() string { + return r.raw +} + +// The CISA defined Traffic Light Protocol (TLP) +type CloudforceOneRequestItemTlp string + +const ( + CloudforceOneRequestItemTlpClear CloudforceOneRequestItemTlp = "clear" + CloudforceOneRequestItemTlpAmber CloudforceOneRequestItemTlp = "amber" + CloudforceOneRequestItemTlpAmberStrict CloudforceOneRequestItemTlp = "amber-strict" + CloudforceOneRequestItemTlpGreen CloudforceOneRequestItemTlp = "green" + CloudforceOneRequestItemTlpRed CloudforceOneRequestItemTlp = "red" +) + +// Request Status +type CloudforceOneRequestItemStatus string + +const ( + CloudforceOneRequestItemStatusOpen CloudforceOneRequestItemStatus = "open" + CloudforceOneRequestItemStatusAccepted CloudforceOneRequestItemStatus = "accepted" + CloudforceOneRequestItemStatusReported CloudforceOneRequestItemStatus = "reported" + CloudforceOneRequestItemStatusApproved CloudforceOneRequestItemStatus = "approved" + CloudforceOneRequestItemStatusCompleted CloudforceOneRequestItemStatus = "completed" + CloudforceOneRequestItemStatusDeclined CloudforceOneRequestItemStatus = "declined" +) + +type CloudforceOneRequestListItem struct { + // UUID + ID string `json:"id,required"` + // Request creation time + Created time.Time `json:"created,required" format:"date-time"` + Priority CloudforceOneRequestListItemPriority `json:"priority,required"` + // Requested information from request + Request string `json:"request,required"` + // Brief description of the request + Summary string `json:"summary,required"` + // The CISA defined Traffic Light Protocol (TLP) + Tlp CloudforceOneRequestListItemTlp `json:"tlp,required"` + // Request last updated time + Updated time.Time `json:"updated,required" format:"date-time"` + // Request completion time + Completed time.Time `json:"completed" format:"date-time"` + // Tokens for the request messages + MessageTokens int64 `json:"message_tokens"` + // Readable Request ID + ReadableID string `json:"readable_id"` + // Request Status + Status CloudforceOneRequestListItemStatus `json:"status"` + // Tokens for the request + Tokens int64 `json:"tokens"` + JSON cloudforceOneRequestListItemJSON `json:"-"` +} + +// cloudforceOneRequestListItemJSON contains the JSON metadata for the struct +// [CloudforceOneRequestListItem] +type cloudforceOneRequestListItemJSON struct { + ID apijson.Field + Created apijson.Field + Priority apijson.Field + Request apijson.Field + Summary apijson.Field + Tlp apijson.Field + Updated apijson.Field + Completed apijson.Field + MessageTokens apijson.Field + ReadableID apijson.Field + Status apijson.Field + Tokens apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CloudforceOneRequestListItem) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cloudforceOneRequestListItemJSON) RawJSON() string { + return r.raw +} + +type CloudforceOneRequestListItemPriority string + +const ( + CloudforceOneRequestListItemPriorityRoutine CloudforceOneRequestListItemPriority = "routine" + CloudforceOneRequestListItemPriorityHigh CloudforceOneRequestListItemPriority = "high" + CloudforceOneRequestListItemPriorityUrgent CloudforceOneRequestListItemPriority = "urgent" +) + +// The CISA defined Traffic Light Protocol (TLP) +type CloudforceOneRequestListItemTlp string + +const ( + CloudforceOneRequestListItemTlpClear CloudforceOneRequestListItemTlp = "clear" + CloudforceOneRequestListItemTlpAmber CloudforceOneRequestListItemTlp = "amber" + CloudforceOneRequestListItemTlpAmberStrict CloudforceOneRequestListItemTlp = "amber-strict" + CloudforceOneRequestListItemTlpGreen CloudforceOneRequestListItemTlp = "green" + CloudforceOneRequestListItemTlpRed CloudforceOneRequestListItemTlp = "red" +) + +// Request Status +type CloudforceOneRequestListItemStatus string + +const ( + CloudforceOneRequestListItemStatusOpen CloudforceOneRequestListItemStatus = "open" + CloudforceOneRequestListItemStatusAccepted CloudforceOneRequestListItemStatus = "accepted" + CloudforceOneRequestListItemStatusReported CloudforceOneRequestListItemStatus = "reported" + CloudforceOneRequestListItemStatusApproved CloudforceOneRequestListItemStatus = "approved" + CloudforceOneRequestListItemStatusCompleted CloudforceOneRequestListItemStatus = "completed" + CloudforceOneRequestListItemStatusDeclined CloudforceOneRequestListItemStatus = "declined" +) + +type CloudforceOneRequestTypes []string + +// Union satisfied by [cloudforce_one.RequestDeleteResponseUnknown], +// [cloudforce_one.RequestDeleteResponseArray] or [shared.UnionString]. +type RequestDeleteResponse interface { + ImplementsCloudforceOneRequestDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RequestDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RequestDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type RequestDeleteResponseArray []interface{} + +func (r RequestDeleteResponseArray) ImplementsCloudforceOneRequestDeleteResponse() {} + +type RequestNewParams struct { + // Request content + Content param.Field[string] `json:"content"` + // Priority for analyzing the request + Priority param.Field[string] `json:"priority"` + // Requested information from request + RequestType param.Field[string] `json:"request_type"` + // Brief description of the request + Summary param.Field[string] `json:"summary"` + // The CISA defined Traffic Light Protocol (TLP) + Tlp param.Field[RequestNewParamsTlp] `json:"tlp"` +} + +func (r RequestNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The CISA defined Traffic Light Protocol (TLP) +type RequestNewParamsTlp string + +const ( + RequestNewParamsTlpClear RequestNewParamsTlp = "clear" + RequestNewParamsTlpAmber RequestNewParamsTlp = "amber" + RequestNewParamsTlpAmberStrict RequestNewParamsTlp = "amber-strict" + RequestNewParamsTlpGreen RequestNewParamsTlp = "green" + RequestNewParamsTlpRed RequestNewParamsTlp = "red" +) + +type RequestNewResponseEnvelope struct { + Errors []RequestNewResponseEnvelopeErrors `json:"errors,required"` + Messages []RequestNewResponseEnvelopeMessages `json:"messages,required"` + Result CloudforceOneRequestItem `json:"result,required"` + // Whether the API call was successful + Success RequestNewResponseEnvelopeSuccess `json:"success,required"` + JSON requestNewResponseEnvelopeJSON `json:"-"` +} + +// requestNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [RequestNewResponseEnvelope] +type requestNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RequestNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// requestNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RequestNewResponseEnvelopeErrors] +type requestNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RequestNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// requestNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RequestNewResponseEnvelopeMessages] +type requestNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestNewResponseEnvelopeSuccess bool + +const ( + RequestNewResponseEnvelopeSuccessTrue RequestNewResponseEnvelopeSuccess = true +) + +type RequestUpdateParams struct { + // Request content + Content param.Field[string] `json:"content"` + // Priority for analyzing the request + Priority param.Field[string] `json:"priority"` + // Requested information from request + RequestType param.Field[string] `json:"request_type"` + // Brief description of the request + Summary param.Field[string] `json:"summary"` + // The CISA defined Traffic Light Protocol (TLP) + Tlp param.Field[RequestUpdateParamsTlp] `json:"tlp"` +} + +func (r RequestUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The CISA defined Traffic Light Protocol (TLP) +type RequestUpdateParamsTlp string + +const ( + RequestUpdateParamsTlpClear RequestUpdateParamsTlp = "clear" + RequestUpdateParamsTlpAmber RequestUpdateParamsTlp = "amber" + RequestUpdateParamsTlpAmberStrict RequestUpdateParamsTlp = "amber-strict" + RequestUpdateParamsTlpGreen RequestUpdateParamsTlp = "green" + RequestUpdateParamsTlpRed RequestUpdateParamsTlp = "red" +) + +type RequestUpdateResponseEnvelope struct { + Errors []RequestUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []RequestUpdateResponseEnvelopeMessages `json:"messages,required"` + Result CloudforceOneRequestItem `json:"result,required"` + // Whether the API call was successful + Success RequestUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON requestUpdateResponseEnvelopeJSON `json:"-"` +} + +// requestUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [RequestUpdateResponseEnvelope] +type requestUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RequestUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// requestUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RequestUpdateResponseEnvelopeErrors] +type requestUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RequestUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// requestUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RequestUpdateResponseEnvelopeMessages] +type requestUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestUpdateResponseEnvelopeSuccess bool + +const ( + RequestUpdateResponseEnvelopeSuccessTrue RequestUpdateResponseEnvelopeSuccess = true +) + +type RequestListParams struct { + // Page number of results + Page param.Field[int64] `json:"page,required"` + // Number of results per page + PerPage param.Field[int64] `json:"per_page,required"` + // Retrieve requests completed after this time + CompletedAfter param.Field[time.Time] `json:"completed_after" format:"date-time"` + // Retrieve requests completed before this time + CompletedBefore param.Field[time.Time] `json:"completed_before" format:"date-time"` + // Retrieve requests created after this time + CreatedAfter param.Field[time.Time] `json:"created_after" format:"date-time"` + // Retrieve requests created before this time + CreatedBefore param.Field[time.Time] `json:"created_before" format:"date-time"` + // Requested information from request + RequestType param.Field[string] `json:"request_type"` + // Field to sort results by + SortBy param.Field[string] `json:"sort_by"` + // Sort order (asc or desc) + SortOrder param.Field[RequestListParamsSortOrder] `json:"sort_order"` + // Request Status + Status param.Field[RequestListParamsStatus] `json:"status"` +} + +func (r RequestListParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Sort order (asc or desc) +type RequestListParamsSortOrder string + +const ( + RequestListParamsSortOrderAsc RequestListParamsSortOrder = "asc" + RequestListParamsSortOrderDesc RequestListParamsSortOrder = "desc" +) + +// Request Status +type RequestListParamsStatus string + +const ( + RequestListParamsStatusOpen RequestListParamsStatus = "open" + RequestListParamsStatusAccepted RequestListParamsStatus = "accepted" + RequestListParamsStatusReported RequestListParamsStatus = "reported" + RequestListParamsStatusApproved RequestListParamsStatus = "approved" + RequestListParamsStatusCompleted RequestListParamsStatus = "completed" + RequestListParamsStatusDeclined RequestListParamsStatus = "declined" +) + +type RequestDeleteResponseEnvelope struct { + Errors []RequestDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []RequestDeleteResponseEnvelopeMessages `json:"messages,required"` + Result RequestDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success RequestDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON requestDeleteResponseEnvelopeJSON `json:"-"` +} + +// requestDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [RequestDeleteResponseEnvelope] +type requestDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RequestDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// requestDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RequestDeleteResponseEnvelopeErrors] +type requestDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RequestDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// requestDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RequestDeleteResponseEnvelopeMessages] +type requestDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestDeleteResponseEnvelopeSuccess bool + +const ( + RequestDeleteResponseEnvelopeSuccessTrue RequestDeleteResponseEnvelopeSuccess = true +) + +type RequestConstantsResponseEnvelope struct { + Errors []RequestConstantsResponseEnvelopeErrors `json:"errors,required"` + Messages []RequestConstantsResponseEnvelopeMessages `json:"messages,required"` + Result CloudforceOneRequestConstants `json:"result,required"` + // Whether the API call was successful + Success RequestConstantsResponseEnvelopeSuccess `json:"success,required"` + JSON requestConstantsResponseEnvelopeJSON `json:"-"` +} + +// requestConstantsResponseEnvelopeJSON contains the JSON metadata for the struct +// [RequestConstantsResponseEnvelope] +type requestConstantsResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestConstantsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestConstantsResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RequestConstantsResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestConstantsResponseEnvelopeErrorsJSON `json:"-"` +} + +// requestConstantsResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RequestConstantsResponseEnvelopeErrors] +type requestConstantsResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestConstantsResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestConstantsResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RequestConstantsResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestConstantsResponseEnvelopeMessagesJSON `json:"-"` +} + +// requestConstantsResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RequestConstantsResponseEnvelopeMessages] +type requestConstantsResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestConstantsResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestConstantsResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestConstantsResponseEnvelopeSuccess bool + +const ( + RequestConstantsResponseEnvelopeSuccessTrue RequestConstantsResponseEnvelopeSuccess = true +) + +type RequestGetResponseEnvelope struct { + Errors []RequestGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RequestGetResponseEnvelopeMessages `json:"messages,required"` + Result CloudforceOneRequestItem `json:"result,required"` + // Whether the API call was successful + Success RequestGetResponseEnvelopeSuccess `json:"success,required"` + JSON requestGetResponseEnvelopeJSON `json:"-"` +} + +// requestGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RequestGetResponseEnvelope] +type requestGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RequestGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// requestGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RequestGetResponseEnvelopeErrors] +type requestGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RequestGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// requestGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RequestGetResponseEnvelopeMessages] +type requestGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestGetResponseEnvelopeSuccess bool + +const ( + RequestGetResponseEnvelopeSuccessTrue RequestGetResponseEnvelopeSuccess = true +) + +type RequestQuotaResponseEnvelope struct { + Errors []RequestQuotaResponseEnvelopeErrors `json:"errors,required"` + Messages []RequestQuotaResponseEnvelopeMessages `json:"messages,required"` + Result CloudforceOneQuota `json:"result,required"` + // Whether the API call was successful + Success RequestQuotaResponseEnvelopeSuccess `json:"success,required"` + JSON requestQuotaResponseEnvelopeJSON `json:"-"` +} + +// requestQuotaResponseEnvelopeJSON contains the JSON metadata for the struct +// [RequestQuotaResponseEnvelope] +type requestQuotaResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestQuotaResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestQuotaResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RequestQuotaResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestQuotaResponseEnvelopeErrorsJSON `json:"-"` +} + +// requestQuotaResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RequestQuotaResponseEnvelopeErrors] +type requestQuotaResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestQuotaResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestQuotaResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RequestQuotaResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestQuotaResponseEnvelopeMessagesJSON `json:"-"` +} + +// requestQuotaResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RequestQuotaResponseEnvelopeMessages] +type requestQuotaResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestQuotaResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestQuotaResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestQuotaResponseEnvelopeSuccess bool + +const ( + RequestQuotaResponseEnvelopeSuccessTrue RequestQuotaResponseEnvelopeSuccess = true +) + +type RequestTypesResponseEnvelope struct { + Errors []RequestTypesResponseEnvelopeErrors `json:"errors,required"` + Messages []RequestTypesResponseEnvelopeMessages `json:"messages,required"` + Result CloudforceOneRequestTypes `json:"result,required"` + // Whether the API call was successful + Success RequestTypesResponseEnvelopeSuccess `json:"success,required"` + JSON requestTypesResponseEnvelopeJSON `json:"-"` +} + +// requestTypesResponseEnvelopeJSON contains the JSON metadata for the struct +// [RequestTypesResponseEnvelope] +type requestTypesResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestTypesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestTypesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RequestTypesResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestTypesResponseEnvelopeErrorsJSON `json:"-"` +} + +// requestTypesResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RequestTypesResponseEnvelopeErrors] +type requestTypesResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestTypesResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestTypesResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RequestTypesResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestTypesResponseEnvelopeMessagesJSON `json:"-"` +} + +// requestTypesResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RequestTypesResponseEnvelopeMessages] +type requestTypesResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestTypesResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestTypesResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestTypesResponseEnvelopeSuccess bool + +const ( + RequestTypesResponseEnvelopeSuccessTrue RequestTypesResponseEnvelopeSuccess = true +) diff --git a/cloudforce_one/request_test.go b/cloudforce_one/request_test.go new file mode 100644 index 00000000000..f7630573426 --- /dev/null +++ b/cloudforce_one/request_test.go @@ -0,0 +1,252 @@ +// File generated from our OpenAPI spec by Stainless. + +package cloudforce_one_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/cloudforce_one" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRequestNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.CloudforceOne.Requests.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + cloudforce_one.RequestNewParams{ + Content: cloudflare.F("What regions were most effected by the recent DoS?"), + Priority: cloudflare.F("routine"), + RequestType: cloudflare.F("Victomology"), + Summary: cloudflare.F("DoS attack"), + Tlp: cloudflare.F(cloudforce_one.RequestNewParamsTlpClear), + }, + ) + 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 TestRequestUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.CloudforceOne.Requests.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + cloudforce_one.RequestUpdateParams{ + Content: cloudflare.F("What regions were most effected by the recent DoS?"), + Priority: cloudflare.F("routine"), + RequestType: cloudflare.F("Victomology"), + Summary: cloudflare.F("DoS attack"), + Tlp: cloudflare.F(cloudforce_one.RequestUpdateParamsTlpClear), + }, + ) + 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 TestRequestListWithOptionalParams(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("user@example.com"), + ) + _, err := client.CloudforceOne.Requests.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + cloudforce_one.RequestListParams{ + Page: cloudflare.F(int64(0)), + PerPage: cloudflare.F(int64(10)), + CompletedAfter: cloudflare.F(time.Now()), + CompletedBefore: cloudflare.F(time.Now()), + CreatedAfter: cloudflare.F(time.Now()), + CreatedBefore: cloudflare.F(time.Now()), + RequestType: cloudflare.F("Victomology"), + SortBy: cloudflare.F("created"), + SortOrder: cloudflare.F(cloudforce_one.RequestListParamsSortOrderAsc), + Status: cloudflare.F(cloudforce_one.RequestListParamsStatusOpen), + }, + ) + 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 TestRequestDelete(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("user@example.com"), + ) + _, err := client.CloudforceOne.Requests.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + 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 TestRequestConstants(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("user@example.com"), + ) + _, err := client.CloudforceOne.Requests.Constants(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()) + } +} + +func TestRequestGet(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("user@example.com"), + ) + _, err := client.CloudforceOne.Requests.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + 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 TestRequestQuota(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("user@example.com"), + ) + _, err := client.CloudforceOne.Requests.Quota(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()) + } +} + +func TestRequestTypes(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("user@example.com"), + ) + _, err := client.CloudforceOne.Requests.Types(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/cloudforce_one/requestmessage.go b/cloudforce_one/requestmessage.go new file mode 100644 index 00000000000..d246ed01c70 --- /dev/null +++ b/cloudforce_one/requestmessage.go @@ -0,0 +1,540 @@ +// File generated from our OpenAPI spec by Stainless. + +package cloudforce_one + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// RequestMessageService 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 [NewRequestMessageService] method +// instead. +type RequestMessageService struct { + Options []option.RequestOption +} + +// NewRequestMessageService 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 NewRequestMessageService(opts ...option.RequestOption) (r *RequestMessageService) { + r = &RequestMessageService{} + r.Options = opts + return +} + +// Creating a request adds the request into the Cloudforce One queue for analysis. +// In addition to the content, a short title, type, priority, and releasability +// should be provided. If one is not provided a default will be assigned. +func (r *RequestMessageService) New(ctx context.Context, accountIdentifier string, requestIdentifier string, body RequestMessageNewParams, opts ...option.RequestOption) (res *CloudforceOneRequestMessageItem, err error) { + opts = append(r.Options[:], opts...) + var env RequestMessageNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s/message/new", accountIdentifier, requestIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update a Request Message +func (r *RequestMessageService) Update(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64, body RequestMessageUpdateParams, opts ...option.RequestOption) (res *CloudforceOneRequestMessageItem, err error) { + opts = append(r.Options[:], opts...) + var env RequestMessageUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s/message/%v", accountIdentifier, requestIdentifier, messageIdentifer) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a Request Message +func (r *RequestMessageService) Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64, opts ...option.RequestOption) (res *RequestMessageDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env RequestMessageDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s/message/%v", accountIdentifier, requestIdentifier, messageIdentifer) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List Request Messages +func (r *RequestMessageService) Get(ctx context.Context, accountIdentifier string, requestIdentifier string, body RequestMessageGetParams, opts ...option.RequestOption) (res *[]CloudforceOneRequestMessageItem, err error) { + opts = append(r.Options[:], opts...) + var env RequestMessageGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s/message", accountIdentifier, requestIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type CloudforceOneRequestMessageItem struct { + // Message ID + ID int64 `json:"id,required"` + // Author of message + Author string `json:"author,required"` + // Content of message + Content string `json:"content,required"` + // Message is a follow-on request + IsFollowOnRequest bool `json:"is_follow_on_request,required"` + // Message last updated time + Updated time.Time `json:"updated,required" format:"date-time"` + // Message creation time + Created time.Time `json:"created" format:"date-time"` + JSON cloudforceOneRequestMessageItemJSON `json:"-"` +} + +// cloudforceOneRequestMessageItemJSON contains the JSON metadata for the struct +// [CloudforceOneRequestMessageItem] +type cloudforceOneRequestMessageItemJSON struct { + ID apijson.Field + Author apijson.Field + Content apijson.Field + IsFollowOnRequest apijson.Field + Updated apijson.Field + Created apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CloudforceOneRequestMessageItem) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cloudforceOneRequestMessageItemJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [cloudforce_one.RequestMessageDeleteResponseUnknown], +// [cloudforce_one.RequestMessageDeleteResponseArray] or [shared.UnionString]. +type RequestMessageDeleteResponse interface { + ImplementsCloudforceOneRequestMessageDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RequestMessageDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RequestMessageDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type RequestMessageDeleteResponseArray []interface{} + +func (r RequestMessageDeleteResponseArray) ImplementsCloudforceOneRequestMessageDeleteResponse() {} + +type RequestMessageNewParams struct { + // Content of message + Content param.Field[string] `json:"content"` +} + +func (r RequestMessageNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RequestMessageNewResponseEnvelope struct { + Errors []RequestMessageNewResponseEnvelopeErrors `json:"errors,required"` + Messages []RequestMessageNewResponseEnvelopeMessages `json:"messages,required"` + Result CloudforceOneRequestMessageItem `json:"result,required"` + // Whether the API call was successful + Success RequestMessageNewResponseEnvelopeSuccess `json:"success,required"` + JSON requestMessageNewResponseEnvelopeJSON `json:"-"` +} + +// requestMessageNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [RequestMessageNewResponseEnvelope] +type requestMessageNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestMessageNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestMessageNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RequestMessageNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestMessageNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// requestMessageNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RequestMessageNewResponseEnvelopeErrors] +type requestMessageNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestMessageNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestMessageNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RequestMessageNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestMessageNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// requestMessageNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RequestMessageNewResponseEnvelopeMessages] +type requestMessageNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestMessageNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestMessageNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestMessageNewResponseEnvelopeSuccess bool + +const ( + RequestMessageNewResponseEnvelopeSuccessTrue RequestMessageNewResponseEnvelopeSuccess = true +) + +type RequestMessageUpdateParams struct { + // Request content + Content param.Field[string] `json:"content"` + // Priority for analyzing the request + Priority param.Field[string] `json:"priority"` + // Requested information from request + RequestType param.Field[string] `json:"request_type"` + // Brief description of the request + Summary param.Field[string] `json:"summary"` + // The CISA defined Traffic Light Protocol (TLP) + Tlp param.Field[RequestMessageUpdateParamsTlp] `json:"tlp"` +} + +func (r RequestMessageUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The CISA defined Traffic Light Protocol (TLP) +type RequestMessageUpdateParamsTlp string + +const ( + RequestMessageUpdateParamsTlpClear RequestMessageUpdateParamsTlp = "clear" + RequestMessageUpdateParamsTlpAmber RequestMessageUpdateParamsTlp = "amber" + RequestMessageUpdateParamsTlpAmberStrict RequestMessageUpdateParamsTlp = "amber-strict" + RequestMessageUpdateParamsTlpGreen RequestMessageUpdateParamsTlp = "green" + RequestMessageUpdateParamsTlpRed RequestMessageUpdateParamsTlp = "red" +) + +type RequestMessageUpdateResponseEnvelope struct { + Errors []RequestMessageUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []RequestMessageUpdateResponseEnvelopeMessages `json:"messages,required"` + Result CloudforceOneRequestMessageItem `json:"result,required"` + // Whether the API call was successful + Success RequestMessageUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON requestMessageUpdateResponseEnvelopeJSON `json:"-"` +} + +// requestMessageUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [RequestMessageUpdateResponseEnvelope] +type requestMessageUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestMessageUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestMessageUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RequestMessageUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestMessageUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// requestMessageUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [RequestMessageUpdateResponseEnvelopeErrors] +type requestMessageUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestMessageUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestMessageUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RequestMessageUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestMessageUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// requestMessageUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [RequestMessageUpdateResponseEnvelopeMessages] +type requestMessageUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestMessageUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestMessageUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestMessageUpdateResponseEnvelopeSuccess bool + +const ( + RequestMessageUpdateResponseEnvelopeSuccessTrue RequestMessageUpdateResponseEnvelopeSuccess = true +) + +type RequestMessageDeleteResponseEnvelope struct { + Errors []RequestMessageDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []RequestMessageDeleteResponseEnvelopeMessages `json:"messages,required"` + Result RequestMessageDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success RequestMessageDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON requestMessageDeleteResponseEnvelopeJSON `json:"-"` +} + +// requestMessageDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [RequestMessageDeleteResponseEnvelope] +type requestMessageDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestMessageDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestMessageDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RequestMessageDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestMessageDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// requestMessageDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [RequestMessageDeleteResponseEnvelopeErrors] +type requestMessageDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestMessageDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestMessageDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RequestMessageDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestMessageDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// requestMessageDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [RequestMessageDeleteResponseEnvelopeMessages] +type requestMessageDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestMessageDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestMessageDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestMessageDeleteResponseEnvelopeSuccess bool + +const ( + RequestMessageDeleteResponseEnvelopeSuccessTrue RequestMessageDeleteResponseEnvelopeSuccess = true +) + +type RequestMessageGetParams struct { + // Page number of results + Page param.Field[int64] `json:"page,required"` + // Number of results per page + PerPage param.Field[int64] `json:"per_page,required"` + // Retrieve messages created after this time + After param.Field[time.Time] `json:"after" format:"date-time"` + // Retrieve messages created before this time + Before param.Field[time.Time] `json:"before" format:"date-time"` + // Field to sort results by + SortBy param.Field[string] `json:"sort_by"` + // Sort order (asc or desc) + SortOrder param.Field[RequestMessageGetParamsSortOrder] `json:"sort_order"` +} + +func (r RequestMessageGetParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Sort order (asc or desc) +type RequestMessageGetParamsSortOrder string + +const ( + RequestMessageGetParamsSortOrderAsc RequestMessageGetParamsSortOrder = "asc" + RequestMessageGetParamsSortOrderDesc RequestMessageGetParamsSortOrder = "desc" +) + +type RequestMessageGetResponseEnvelope struct { + Errors []RequestMessageGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RequestMessageGetResponseEnvelopeMessages `json:"messages,required"` + Result []CloudforceOneRequestMessageItem `json:"result,required"` + // Whether the API call was successful + Success RequestMessageGetResponseEnvelopeSuccess `json:"success,required"` + JSON requestMessageGetResponseEnvelopeJSON `json:"-"` +} + +// requestMessageGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RequestMessageGetResponseEnvelope] +type requestMessageGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestMessageGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestMessageGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RequestMessageGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestMessageGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// requestMessageGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RequestMessageGetResponseEnvelopeErrors] +type requestMessageGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestMessageGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestMessageGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RequestMessageGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestMessageGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// requestMessageGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RequestMessageGetResponseEnvelopeMessages] +type requestMessageGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestMessageGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestMessageGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestMessageGetResponseEnvelopeSuccess bool + +const ( + RequestMessageGetResponseEnvelopeSuccessTrue RequestMessageGetResponseEnvelopeSuccess = true +) diff --git a/cloudforce_one/requestmessage_test.go b/cloudforce_one/requestmessage_test.go new file mode 100644 index 00000000000..3c5cd92418d --- /dev/null +++ b/cloudforce_one/requestmessage_test.go @@ -0,0 +1,148 @@ +// File generated from our OpenAPI spec by Stainless. + +package cloudforce_one_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/cloudforce_one" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRequestMessageNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.CloudforceOne.Requests.Message.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + cloudforce_one.RequestMessageNewParams{ + Content: cloudflare.F("Can you elaborate on the type of DoS that occurred?"), + }, + ) + 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 TestRequestMessageUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.CloudforceOne.Requests.Message.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + int64(0), + cloudforce_one.RequestMessageUpdateParams{ + Content: cloudflare.F("What regions were most effected by the recent DoS?"), + Priority: cloudflare.F("routine"), + RequestType: cloudflare.F("Victomology"), + Summary: cloudflare.F("DoS attack"), + Tlp: cloudflare.F(cloudforce_one.RequestMessageUpdateParamsTlpClear), + }, + ) + 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 TestRequestMessageDelete(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("user@example.com"), + ) + _, err := client.CloudforceOne.Requests.Message.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + int64(0), + ) + 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 TestRequestMessageGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.CloudforceOne.Requests.Message.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + cloudforce_one.RequestMessageGetParams{ + Page: cloudflare.F(int64(0)), + PerPage: cloudflare.F(int64(10)), + After: cloudflare.F(time.Now()), + Before: cloudflare.F(time.Now()), + SortBy: cloudflare.F("created"), + SortOrder: cloudflare.F(cloudforce_one.RequestMessageGetParamsSortOrderAsc), + }, + ) + 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/cloudforce_one/requestpriority.go b/cloudforce_one/requestpriority.go new file mode 100644 index 00000000000..2576110271c --- /dev/null +++ b/cloudforce_one/requestpriority.go @@ -0,0 +1,634 @@ +// File generated from our OpenAPI spec by Stainless. + +package cloudforce_one + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// RequestPriorityService 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 [NewRequestPriorityService] method +// instead. +type RequestPriorityService struct { + Options []option.RequestOption +} + +// NewRequestPriorityService 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 NewRequestPriorityService(opts ...option.RequestOption) (r *RequestPriorityService) { + r = &RequestPriorityService{} + r.Options = opts + return +} + +// Create a New Priority Requirement +func (r *RequestPriorityService) New(ctx context.Context, accountIdentifier string, body RequestPriorityNewParams, opts ...option.RequestOption) (res *CloudforceOnePriorityItem, err error) { + opts = append(r.Options[:], opts...) + var env RequestPriorityNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/priority/new", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update a Priority Intelligence Requirement +func (r *RequestPriorityService) Update(ctx context.Context, accountIdentifier string, priorityIdentifer string, body RequestPriorityUpdateParams, opts ...option.RequestOption) (res *CloudforceOneRequestItem, err error) { + opts = append(r.Options[:], opts...) + var env RequestPriorityUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/priority/%s", accountIdentifier, priorityIdentifer) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a Priority Intelligence Report +func (r *RequestPriorityService) Delete(ctx context.Context, accountIdentifier string, priorityIdentifer string, opts ...option.RequestOption) (res *RequestPriorityDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env RequestPriorityDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/priority/%s", accountIdentifier, priorityIdentifer) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a Priority Intelligence Requirement +func (r *RequestPriorityService) Get(ctx context.Context, accountIdentifier string, priorityIdentifer string, opts ...option.RequestOption) (res *CloudforceOneRequestItem, err error) { + opts = append(r.Options[:], opts...) + var env RequestPriorityGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/priority/%s", accountIdentifier, priorityIdentifer) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get Priority Intelligence Requirement Quota +func (r *RequestPriorityService) Quota(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *CloudforceOneQuota, err error) { + opts = append(r.Options[:], opts...) + var env RequestPriorityQuotaResponseEnvelope + path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/priority/quota", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type CloudforceOnePriorityItem struct { + // UUID + ID string `json:"id,required"` + // Priority creation time + Created time.Time `json:"created,required" format:"date-time"` + // List of labels + Labels []string `json:"labels,required"` + // Priority + Priority int64 `json:"priority,required"` + // Requirement + Requirement string `json:"requirement,required"` + // The CISA defined Traffic Light Protocol (TLP) + Tlp CloudforceOnePriorityItemTlp `json:"tlp,required"` + // Priority last updated time + Updated time.Time `json:"updated,required" format:"date-time"` + JSON cloudforceOnePriorityItemJSON `json:"-"` +} + +// cloudforceOnePriorityItemJSON contains the JSON metadata for the struct +// [CloudforceOnePriorityItem] +type cloudforceOnePriorityItemJSON struct { + ID apijson.Field + Created apijson.Field + Labels apijson.Field + Priority apijson.Field + Requirement apijson.Field + Tlp apijson.Field + Updated apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CloudforceOnePriorityItem) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cloudforceOnePriorityItemJSON) RawJSON() string { + return r.raw +} + +// The CISA defined Traffic Light Protocol (TLP) +type CloudforceOnePriorityItemTlp string + +const ( + CloudforceOnePriorityItemTlpClear CloudforceOnePriorityItemTlp = "clear" + CloudforceOnePriorityItemTlpAmber CloudforceOnePriorityItemTlp = "amber" + CloudforceOnePriorityItemTlpAmberStrict CloudforceOnePriorityItemTlp = "amber-strict" + CloudforceOnePriorityItemTlpGreen CloudforceOnePriorityItemTlp = "green" + CloudforceOnePriorityItemTlpRed CloudforceOnePriorityItemTlp = "red" +) + +// Union satisfied by [cloudforce_one.RequestPriorityDeleteResponseUnknown], +// [cloudforce_one.RequestPriorityDeleteResponseArray] or [shared.UnionString]. +type RequestPriorityDeleteResponse interface { + ImplementsCloudforceOneRequestPriorityDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RequestPriorityDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RequestPriorityDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type RequestPriorityDeleteResponseArray []interface{} + +func (r RequestPriorityDeleteResponseArray) ImplementsCloudforceOneRequestPriorityDeleteResponse() {} + +type RequestPriorityNewParams struct { + // List of labels + Labels param.Field[[]string] `json:"labels,required"` + // Priority + Priority param.Field[int64] `json:"priority,required"` + // Requirement + Requirement param.Field[string] `json:"requirement,required"` + // The CISA defined Traffic Light Protocol (TLP) + Tlp param.Field[RequestPriorityNewParamsTlp] `json:"tlp,required"` +} + +func (r RequestPriorityNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The CISA defined Traffic Light Protocol (TLP) +type RequestPriorityNewParamsTlp string + +const ( + RequestPriorityNewParamsTlpClear RequestPriorityNewParamsTlp = "clear" + RequestPriorityNewParamsTlpAmber RequestPriorityNewParamsTlp = "amber" + RequestPriorityNewParamsTlpAmberStrict RequestPriorityNewParamsTlp = "amber-strict" + RequestPriorityNewParamsTlpGreen RequestPriorityNewParamsTlp = "green" + RequestPriorityNewParamsTlpRed RequestPriorityNewParamsTlp = "red" +) + +type RequestPriorityNewResponseEnvelope struct { + Errors []RequestPriorityNewResponseEnvelopeErrors `json:"errors,required"` + Messages []RequestPriorityNewResponseEnvelopeMessages `json:"messages,required"` + Result CloudforceOnePriorityItem `json:"result,required"` + // Whether the API call was successful + Success RequestPriorityNewResponseEnvelopeSuccess `json:"success,required"` + JSON requestPriorityNewResponseEnvelopeJSON `json:"-"` +} + +// requestPriorityNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [RequestPriorityNewResponseEnvelope] +type requestPriorityNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestPriorityNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestPriorityNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RequestPriorityNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestPriorityNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// requestPriorityNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RequestPriorityNewResponseEnvelopeErrors] +type requestPriorityNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestPriorityNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestPriorityNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RequestPriorityNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestPriorityNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// requestPriorityNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [RequestPriorityNewResponseEnvelopeMessages] +type requestPriorityNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestPriorityNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestPriorityNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestPriorityNewResponseEnvelopeSuccess bool + +const ( + RequestPriorityNewResponseEnvelopeSuccessTrue RequestPriorityNewResponseEnvelopeSuccess = true +) + +type RequestPriorityUpdateParams struct { + // List of labels + Labels param.Field[[]string] `json:"labels,required"` + // Priority + Priority param.Field[int64] `json:"priority,required"` + // Requirement + Requirement param.Field[string] `json:"requirement,required"` + // The CISA defined Traffic Light Protocol (TLP) + Tlp param.Field[RequestPriorityUpdateParamsTlp] `json:"tlp,required"` +} + +func (r RequestPriorityUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The CISA defined Traffic Light Protocol (TLP) +type RequestPriorityUpdateParamsTlp string + +const ( + RequestPriorityUpdateParamsTlpClear RequestPriorityUpdateParamsTlp = "clear" + RequestPriorityUpdateParamsTlpAmber RequestPriorityUpdateParamsTlp = "amber" + RequestPriorityUpdateParamsTlpAmberStrict RequestPriorityUpdateParamsTlp = "amber-strict" + RequestPriorityUpdateParamsTlpGreen RequestPriorityUpdateParamsTlp = "green" + RequestPriorityUpdateParamsTlpRed RequestPriorityUpdateParamsTlp = "red" +) + +type RequestPriorityUpdateResponseEnvelope struct { + Errors []RequestPriorityUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []RequestPriorityUpdateResponseEnvelopeMessages `json:"messages,required"` + Result CloudforceOneRequestItem `json:"result,required"` + // Whether the API call was successful + Success RequestPriorityUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON requestPriorityUpdateResponseEnvelopeJSON `json:"-"` +} + +// requestPriorityUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [RequestPriorityUpdateResponseEnvelope] +type requestPriorityUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestPriorityUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestPriorityUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RequestPriorityUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestPriorityUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// requestPriorityUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [RequestPriorityUpdateResponseEnvelopeErrors] +type requestPriorityUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestPriorityUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestPriorityUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RequestPriorityUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestPriorityUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// requestPriorityUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [RequestPriorityUpdateResponseEnvelopeMessages] +type requestPriorityUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestPriorityUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestPriorityUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestPriorityUpdateResponseEnvelopeSuccess bool + +const ( + RequestPriorityUpdateResponseEnvelopeSuccessTrue RequestPriorityUpdateResponseEnvelopeSuccess = true +) + +type RequestPriorityDeleteResponseEnvelope struct { + Errors []RequestPriorityDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []RequestPriorityDeleteResponseEnvelopeMessages `json:"messages,required"` + Result RequestPriorityDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success RequestPriorityDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON requestPriorityDeleteResponseEnvelopeJSON `json:"-"` +} + +// requestPriorityDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [RequestPriorityDeleteResponseEnvelope] +type requestPriorityDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestPriorityDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestPriorityDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RequestPriorityDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestPriorityDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// requestPriorityDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [RequestPriorityDeleteResponseEnvelopeErrors] +type requestPriorityDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestPriorityDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestPriorityDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RequestPriorityDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestPriorityDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// requestPriorityDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [RequestPriorityDeleteResponseEnvelopeMessages] +type requestPriorityDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestPriorityDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestPriorityDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestPriorityDeleteResponseEnvelopeSuccess bool + +const ( + RequestPriorityDeleteResponseEnvelopeSuccessTrue RequestPriorityDeleteResponseEnvelopeSuccess = true +) + +type RequestPriorityGetResponseEnvelope struct { + Errors []RequestPriorityGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RequestPriorityGetResponseEnvelopeMessages `json:"messages,required"` + Result CloudforceOneRequestItem `json:"result,required"` + // Whether the API call was successful + Success RequestPriorityGetResponseEnvelopeSuccess `json:"success,required"` + JSON requestPriorityGetResponseEnvelopeJSON `json:"-"` +} + +// requestPriorityGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RequestPriorityGetResponseEnvelope] +type requestPriorityGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestPriorityGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestPriorityGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RequestPriorityGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestPriorityGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// requestPriorityGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RequestPriorityGetResponseEnvelopeErrors] +type requestPriorityGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestPriorityGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestPriorityGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RequestPriorityGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestPriorityGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// requestPriorityGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [RequestPriorityGetResponseEnvelopeMessages] +type requestPriorityGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestPriorityGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestPriorityGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestPriorityGetResponseEnvelopeSuccess bool + +const ( + RequestPriorityGetResponseEnvelopeSuccessTrue RequestPriorityGetResponseEnvelopeSuccess = true +) + +type RequestPriorityQuotaResponseEnvelope struct { + Errors []RequestPriorityQuotaResponseEnvelopeErrors `json:"errors,required"` + Messages []RequestPriorityQuotaResponseEnvelopeMessages `json:"messages,required"` + Result CloudforceOneQuota `json:"result,required"` + // Whether the API call was successful + Success RequestPriorityQuotaResponseEnvelopeSuccess `json:"success,required"` + JSON requestPriorityQuotaResponseEnvelopeJSON `json:"-"` +} + +// requestPriorityQuotaResponseEnvelopeJSON contains the JSON metadata for the +// struct [RequestPriorityQuotaResponseEnvelope] +type requestPriorityQuotaResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestPriorityQuotaResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestPriorityQuotaResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RequestPriorityQuotaResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestPriorityQuotaResponseEnvelopeErrorsJSON `json:"-"` +} + +// requestPriorityQuotaResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [RequestPriorityQuotaResponseEnvelopeErrors] +type requestPriorityQuotaResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestPriorityQuotaResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestPriorityQuotaResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RequestPriorityQuotaResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON requestPriorityQuotaResponseEnvelopeMessagesJSON `json:"-"` +} + +// requestPriorityQuotaResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [RequestPriorityQuotaResponseEnvelopeMessages] +type requestPriorityQuotaResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestPriorityQuotaResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestPriorityQuotaResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestPriorityQuotaResponseEnvelopeSuccess bool + +const ( + RequestPriorityQuotaResponseEnvelopeSuccessTrue RequestPriorityQuotaResponseEnvelopeSuccess = true +) diff --git a/cloudforce_one/requestpriority_test.go b/cloudforce_one/requestpriority_test.go new file mode 100644 index 00000000000..0bab359eb7c --- /dev/null +++ b/cloudforce_one/requestpriority_test.go @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package cloudforce_one_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/cloudforce_one" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRequestPriorityNew(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("user@example.com"), + ) + _, err := client.CloudforceOne.Requests.Priority.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + cloudforce_one.RequestPriorityNewParams{ + Labels: cloudflare.F([]string{"DoS", "CVE"}), + Priority: cloudflare.F(int64(1)), + Requirement: cloudflare.F("DoS attacks carried out by CVEs"), + Tlp: cloudflare.F(cloudforce_one.RequestPriorityNewParamsTlpClear), + }, + ) + 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 TestRequestPriorityUpdate(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("user@example.com"), + ) + _, err := client.CloudforceOne.Requests.Priority.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + cloudforce_one.RequestPriorityUpdateParams{ + Labels: cloudflare.F([]string{"DoS", "CVE"}), + Priority: cloudflare.F(int64(1)), + Requirement: cloudflare.F("DoS attacks carried out by CVEs"), + Tlp: cloudflare.F(cloudforce_one.RequestPriorityUpdateParamsTlpClear), + }, + ) + 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 TestRequestPriorityDelete(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("user@example.com"), + ) + _, err := client.CloudforceOne.Requests.Priority.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + 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 TestRequestPriorityGet(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("user@example.com"), + ) + _, err := client.CloudforceOne.Requests.Priority.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + 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 TestRequestPriorityQuota(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("user@example.com"), + ) + _, err := client.CloudforceOne.Requests.Priority.Quota(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/cloudforceonerequest.go b/cloudforceonerequest.go deleted file mode 100644 index 31eb1846f06..00000000000 --- a/cloudforceonerequest.go +++ /dev/null @@ -1,1256 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// CloudforceOneRequestService 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 [NewCloudforceOneRequestService] -// method instead. -type CloudforceOneRequestService struct { - Options []option.RequestOption - Message *CloudforceOneRequestMessageService - Priority *CloudforceOneRequestPriorityService -} - -// NewCloudforceOneRequestService 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 NewCloudforceOneRequestService(opts ...option.RequestOption) (r *CloudforceOneRequestService) { - r = &CloudforceOneRequestService{} - r.Options = opts - r.Message = NewCloudforceOneRequestMessageService(opts...) - r.Priority = NewCloudforceOneRequestPriorityService(opts...) - return -} - -// Creating a request adds the request into the Cloudforce One queue for analysis. -// In addition to the content, a short title, type, priority, and releasability -// should be provided. If one is not provided a default will be assigned. -func (r *CloudforceOneRequestService) New(ctx context.Context, accountIdentifier string, body CloudforceOneRequestNewParams, opts ...option.RequestOption) (res *CloudforceOneRequestNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env CloudforceOneRequestNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/new", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updating a request alters the request in the Cloudforce One queue. This API may -// be used to update any attributes of the request after the initial submission. -// Only fields that you choose to update need to be add to the request body -func (r *CloudforceOneRequestService) Update(ctx context.Context, accountIdentifier string, requestIdentifier string, body CloudforceOneRequestUpdateParams, opts ...option.RequestOption) (res *CloudforceOneRequestUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env CloudforceOneRequestUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s", accountIdentifier, requestIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List Requests -func (r *CloudforceOneRequestService) List(ctx context.Context, accountIdentifier string, body CloudforceOneRequestListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[CloudforceOneRequestListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("accounts/%s/cloudforce-one/requests", accountIdentifier) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodPost, path, body, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// List Requests -func (r *CloudforceOneRequestService) ListAutoPaging(ctx context.Context, accountIdentifier string, body CloudforceOneRequestListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[CloudforceOneRequestListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, accountIdentifier, body, opts...)) -} - -// Delete a Request -func (r *CloudforceOneRequestService) Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, opts ...option.RequestOption) (res *CloudforceOneRequestDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env CloudforceOneRequestDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s", accountIdentifier, requestIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get Request Priority, Status, and TLP constants -func (r *CloudforceOneRequestService) Constants(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *CloudforceOneRequestConstantsResponse, err error) { - opts = append(r.Options[:], opts...) - var env CloudforceOneRequestConstantsResponseEnvelope - path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/constants", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a Request -func (r *CloudforceOneRequestService) Get(ctx context.Context, accountIdentifier string, requestIdentifier string, opts ...option.RequestOption) (res *CloudforceOneRequestGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env CloudforceOneRequestGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s", accountIdentifier, requestIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get Request Quota -func (r *CloudforceOneRequestService) Quota(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *CloudforceOneRequestQuotaResponse, err error) { - opts = append(r.Options[:], opts...) - var env CloudforceOneRequestQuotaResponseEnvelope - path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/quota", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get Request Types -func (r *CloudforceOneRequestService) Types(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *[]string, err error) { - opts = append(r.Options[:], opts...) - var env CloudforceOneRequestTypesResponseEnvelope - path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/types", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type CloudforceOneRequestNewResponse struct { - // UUID - ID string `json:"id,required"` - // Request content - Content string `json:"content,required"` - Created time.Time `json:"created,required" format:"date-time"` - Priority time.Time `json:"priority,required" format:"date-time"` - // Requested information from request - Request string `json:"request,required"` - // Brief description of the request - Summary string `json:"summary,required"` - // The CISA defined Traffic Light Protocol (TLP) - Tlp CloudforceOneRequestNewResponseTlp `json:"tlp,required"` - Updated time.Time `json:"updated,required" format:"date-time"` - Completed time.Time `json:"completed" format:"date-time"` - // Tokens for the request messages - MessageTokens int64 `json:"message_tokens"` - // Readable Request ID - ReadableID string `json:"readable_id"` - // Request Status - Status CloudforceOneRequestNewResponseStatus `json:"status"` - // Tokens for the request - Tokens int64 `json:"tokens"` - JSON cloudforceOneRequestNewResponseJSON `json:"-"` -} - -// cloudforceOneRequestNewResponseJSON contains the JSON metadata for the struct -// [CloudforceOneRequestNewResponse] -type cloudforceOneRequestNewResponseJSON struct { - ID apijson.Field - Content apijson.Field - Created apijson.Field - Priority apijson.Field - Request apijson.Field - Summary apijson.Field - Tlp apijson.Field - Updated apijson.Field - Completed apijson.Field - MessageTokens apijson.Field - ReadableID apijson.Field - Status apijson.Field - Tokens apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestNewResponseJSON) RawJSON() string { - return r.raw -} - -// The CISA defined Traffic Light Protocol (TLP) -type CloudforceOneRequestNewResponseTlp string - -const ( - CloudforceOneRequestNewResponseTlpClear CloudforceOneRequestNewResponseTlp = "clear" - CloudforceOneRequestNewResponseTlpAmber CloudforceOneRequestNewResponseTlp = "amber" - CloudforceOneRequestNewResponseTlpAmberStrict CloudforceOneRequestNewResponseTlp = "amber-strict" - CloudforceOneRequestNewResponseTlpGreen CloudforceOneRequestNewResponseTlp = "green" - CloudforceOneRequestNewResponseTlpRed CloudforceOneRequestNewResponseTlp = "red" -) - -// Request Status -type CloudforceOneRequestNewResponseStatus string - -const ( - CloudforceOneRequestNewResponseStatusOpen CloudforceOneRequestNewResponseStatus = "open" - CloudforceOneRequestNewResponseStatusAccepted CloudforceOneRequestNewResponseStatus = "accepted" - CloudforceOneRequestNewResponseStatusReported CloudforceOneRequestNewResponseStatus = "reported" - CloudforceOneRequestNewResponseStatusApproved CloudforceOneRequestNewResponseStatus = "approved" - CloudforceOneRequestNewResponseStatusCompleted CloudforceOneRequestNewResponseStatus = "completed" - CloudforceOneRequestNewResponseStatusDeclined CloudforceOneRequestNewResponseStatus = "declined" -) - -type CloudforceOneRequestUpdateResponse struct { - // UUID - ID string `json:"id,required"` - // Request content - Content string `json:"content,required"` - Created time.Time `json:"created,required" format:"date-time"` - Priority time.Time `json:"priority,required" format:"date-time"` - // Requested information from request - Request string `json:"request,required"` - // Brief description of the request - Summary string `json:"summary,required"` - // The CISA defined Traffic Light Protocol (TLP) - Tlp CloudforceOneRequestUpdateResponseTlp `json:"tlp,required"` - Updated time.Time `json:"updated,required" format:"date-time"` - Completed time.Time `json:"completed" format:"date-time"` - // Tokens for the request messages - MessageTokens int64 `json:"message_tokens"` - // Readable Request ID - ReadableID string `json:"readable_id"` - // Request Status - Status CloudforceOneRequestUpdateResponseStatus `json:"status"` - // Tokens for the request - Tokens int64 `json:"tokens"` - JSON cloudforceOneRequestUpdateResponseJSON `json:"-"` -} - -// cloudforceOneRequestUpdateResponseJSON contains the JSON metadata for the struct -// [CloudforceOneRequestUpdateResponse] -type cloudforceOneRequestUpdateResponseJSON struct { - ID apijson.Field - Content apijson.Field - Created apijson.Field - Priority apijson.Field - Request apijson.Field - Summary apijson.Field - Tlp apijson.Field - Updated apijson.Field - Completed apijson.Field - MessageTokens apijson.Field - ReadableID apijson.Field - Status apijson.Field - Tokens apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// The CISA defined Traffic Light Protocol (TLP) -type CloudforceOneRequestUpdateResponseTlp string - -const ( - CloudforceOneRequestUpdateResponseTlpClear CloudforceOneRequestUpdateResponseTlp = "clear" - CloudforceOneRequestUpdateResponseTlpAmber CloudforceOneRequestUpdateResponseTlp = "amber" - CloudforceOneRequestUpdateResponseTlpAmberStrict CloudforceOneRequestUpdateResponseTlp = "amber-strict" - CloudforceOneRequestUpdateResponseTlpGreen CloudforceOneRequestUpdateResponseTlp = "green" - CloudforceOneRequestUpdateResponseTlpRed CloudforceOneRequestUpdateResponseTlp = "red" -) - -// Request Status -type CloudforceOneRequestUpdateResponseStatus string - -const ( - CloudforceOneRequestUpdateResponseStatusOpen CloudforceOneRequestUpdateResponseStatus = "open" - CloudforceOneRequestUpdateResponseStatusAccepted CloudforceOneRequestUpdateResponseStatus = "accepted" - CloudforceOneRequestUpdateResponseStatusReported CloudforceOneRequestUpdateResponseStatus = "reported" - CloudforceOneRequestUpdateResponseStatusApproved CloudforceOneRequestUpdateResponseStatus = "approved" - CloudforceOneRequestUpdateResponseStatusCompleted CloudforceOneRequestUpdateResponseStatus = "completed" - CloudforceOneRequestUpdateResponseStatusDeclined CloudforceOneRequestUpdateResponseStatus = "declined" -) - -type CloudforceOneRequestListResponse struct { - // UUID - ID string `json:"id,required"` - // Request creation time - Created time.Time `json:"created,required" format:"date-time"` - Priority CloudforceOneRequestListResponsePriority `json:"priority,required"` - // Requested information from request - Request string `json:"request,required"` - // Brief description of the request - Summary string `json:"summary,required"` - // The CISA defined Traffic Light Protocol (TLP) - Tlp CloudforceOneRequestListResponseTlp `json:"tlp,required"` - // Request last updated time - Updated time.Time `json:"updated,required" format:"date-time"` - // Request completion time - Completed time.Time `json:"completed" format:"date-time"` - // Tokens for the request messages - MessageTokens int64 `json:"message_tokens"` - // Readable Request ID - ReadableID string `json:"readable_id"` - // Request Status - Status CloudforceOneRequestListResponseStatus `json:"status"` - // Tokens for the request - Tokens int64 `json:"tokens"` - JSON cloudforceOneRequestListResponseJSON `json:"-"` -} - -// cloudforceOneRequestListResponseJSON contains the JSON metadata for the struct -// [CloudforceOneRequestListResponse] -type cloudforceOneRequestListResponseJSON struct { - ID apijson.Field - Created apijson.Field - Priority apijson.Field - Request apijson.Field - Summary apijson.Field - Tlp apijson.Field - Updated apijson.Field - Completed apijson.Field - MessageTokens apijson.Field - ReadableID apijson.Field - Status apijson.Field - Tokens apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestListResponseJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestListResponsePriority string - -const ( - CloudforceOneRequestListResponsePriorityRoutine CloudforceOneRequestListResponsePriority = "routine" - CloudforceOneRequestListResponsePriorityHigh CloudforceOneRequestListResponsePriority = "high" - CloudforceOneRequestListResponsePriorityUrgent CloudforceOneRequestListResponsePriority = "urgent" -) - -// The CISA defined Traffic Light Protocol (TLP) -type CloudforceOneRequestListResponseTlp string - -const ( - CloudforceOneRequestListResponseTlpClear CloudforceOneRequestListResponseTlp = "clear" - CloudforceOneRequestListResponseTlpAmber CloudforceOneRequestListResponseTlp = "amber" - CloudforceOneRequestListResponseTlpAmberStrict CloudforceOneRequestListResponseTlp = "amber-strict" - CloudforceOneRequestListResponseTlpGreen CloudforceOneRequestListResponseTlp = "green" - CloudforceOneRequestListResponseTlpRed CloudforceOneRequestListResponseTlp = "red" -) - -// Request Status -type CloudforceOneRequestListResponseStatus string - -const ( - CloudforceOneRequestListResponseStatusOpen CloudforceOneRequestListResponseStatus = "open" - CloudforceOneRequestListResponseStatusAccepted CloudforceOneRequestListResponseStatus = "accepted" - CloudforceOneRequestListResponseStatusReported CloudforceOneRequestListResponseStatus = "reported" - CloudforceOneRequestListResponseStatusApproved CloudforceOneRequestListResponseStatus = "approved" - CloudforceOneRequestListResponseStatusCompleted CloudforceOneRequestListResponseStatus = "completed" - CloudforceOneRequestListResponseStatusDeclined CloudforceOneRequestListResponseStatus = "declined" -) - -// Union satisfied by [CloudforceOneRequestDeleteResponseUnknown], -// [CloudforceOneRequestDeleteResponseArray] or [shared.UnionString]. -type CloudforceOneRequestDeleteResponse interface { - ImplementsCloudforceOneRequestDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*CloudforceOneRequestDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(CloudforceOneRequestDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type CloudforceOneRequestDeleteResponseArray []interface{} - -func (r CloudforceOneRequestDeleteResponseArray) ImplementsCloudforceOneRequestDeleteResponse() {} - -type CloudforceOneRequestConstantsResponse struct { - Priority []CloudforceOneRequestConstantsResponsePriority `json:"priority"` - Status []CloudforceOneRequestConstantsResponseStatus `json:"status"` - Tlp []CloudforceOneRequestConstantsResponseTlp `json:"tlp"` - JSON cloudforceOneRequestConstantsResponseJSON `json:"-"` -} - -// cloudforceOneRequestConstantsResponseJSON contains the JSON metadata for the -// struct [CloudforceOneRequestConstantsResponse] -type cloudforceOneRequestConstantsResponseJSON struct { - Priority apijson.Field - Status apijson.Field - Tlp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestConstantsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestConstantsResponseJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestConstantsResponsePriority string - -const ( - CloudforceOneRequestConstantsResponsePriorityRoutine CloudforceOneRequestConstantsResponsePriority = "routine" - CloudforceOneRequestConstantsResponsePriorityHigh CloudforceOneRequestConstantsResponsePriority = "high" - CloudforceOneRequestConstantsResponsePriorityUrgent CloudforceOneRequestConstantsResponsePriority = "urgent" -) - -// Request Status -type CloudforceOneRequestConstantsResponseStatus string - -const ( - CloudforceOneRequestConstantsResponseStatusOpen CloudforceOneRequestConstantsResponseStatus = "open" - CloudforceOneRequestConstantsResponseStatusAccepted CloudforceOneRequestConstantsResponseStatus = "accepted" - CloudforceOneRequestConstantsResponseStatusReported CloudforceOneRequestConstantsResponseStatus = "reported" - CloudforceOneRequestConstantsResponseStatusApproved CloudforceOneRequestConstantsResponseStatus = "approved" - CloudforceOneRequestConstantsResponseStatusCompleted CloudforceOneRequestConstantsResponseStatus = "completed" - CloudforceOneRequestConstantsResponseStatusDeclined CloudforceOneRequestConstantsResponseStatus = "declined" -) - -// The CISA defined Traffic Light Protocol (TLP) -type CloudforceOneRequestConstantsResponseTlp string - -const ( - CloudforceOneRequestConstantsResponseTlpClear CloudforceOneRequestConstantsResponseTlp = "clear" - CloudforceOneRequestConstantsResponseTlpAmber CloudforceOneRequestConstantsResponseTlp = "amber" - CloudforceOneRequestConstantsResponseTlpAmberStrict CloudforceOneRequestConstantsResponseTlp = "amber-strict" - CloudforceOneRequestConstantsResponseTlpGreen CloudforceOneRequestConstantsResponseTlp = "green" - CloudforceOneRequestConstantsResponseTlpRed CloudforceOneRequestConstantsResponseTlp = "red" -) - -type CloudforceOneRequestGetResponse struct { - // UUID - ID string `json:"id,required"` - // Request content - Content string `json:"content,required"` - Created time.Time `json:"created,required" format:"date-time"` - Priority time.Time `json:"priority,required" format:"date-time"` - // Requested information from request - Request string `json:"request,required"` - // Brief description of the request - Summary string `json:"summary,required"` - // The CISA defined Traffic Light Protocol (TLP) - Tlp CloudforceOneRequestGetResponseTlp `json:"tlp,required"` - Updated time.Time `json:"updated,required" format:"date-time"` - Completed time.Time `json:"completed" format:"date-time"` - // Tokens for the request messages - MessageTokens int64 `json:"message_tokens"` - // Readable Request ID - ReadableID string `json:"readable_id"` - // Request Status - Status CloudforceOneRequestGetResponseStatus `json:"status"` - // Tokens for the request - Tokens int64 `json:"tokens"` - JSON cloudforceOneRequestGetResponseJSON `json:"-"` -} - -// cloudforceOneRequestGetResponseJSON contains the JSON metadata for the struct -// [CloudforceOneRequestGetResponse] -type cloudforceOneRequestGetResponseJSON struct { - ID apijson.Field - Content apijson.Field - Created apijson.Field - Priority apijson.Field - Request apijson.Field - Summary apijson.Field - Tlp apijson.Field - Updated apijson.Field - Completed apijson.Field - MessageTokens apijson.Field - ReadableID apijson.Field - Status apijson.Field - Tokens apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestGetResponseJSON) RawJSON() string { - return r.raw -} - -// The CISA defined Traffic Light Protocol (TLP) -type CloudforceOneRequestGetResponseTlp string - -const ( - CloudforceOneRequestGetResponseTlpClear CloudforceOneRequestGetResponseTlp = "clear" - CloudforceOneRequestGetResponseTlpAmber CloudforceOneRequestGetResponseTlp = "amber" - CloudforceOneRequestGetResponseTlpAmberStrict CloudforceOneRequestGetResponseTlp = "amber-strict" - CloudforceOneRequestGetResponseTlpGreen CloudforceOneRequestGetResponseTlp = "green" - CloudforceOneRequestGetResponseTlpRed CloudforceOneRequestGetResponseTlp = "red" -) - -// Request Status -type CloudforceOneRequestGetResponseStatus string - -const ( - CloudforceOneRequestGetResponseStatusOpen CloudforceOneRequestGetResponseStatus = "open" - CloudforceOneRequestGetResponseStatusAccepted CloudforceOneRequestGetResponseStatus = "accepted" - CloudforceOneRequestGetResponseStatusReported CloudforceOneRequestGetResponseStatus = "reported" - CloudforceOneRequestGetResponseStatusApproved CloudforceOneRequestGetResponseStatus = "approved" - CloudforceOneRequestGetResponseStatusCompleted CloudforceOneRequestGetResponseStatus = "completed" - CloudforceOneRequestGetResponseStatusDeclined CloudforceOneRequestGetResponseStatus = "declined" -) - -type CloudforceOneRequestQuotaResponse struct { - // Anniversary date is when annual quota limit is refresh - AnniversaryDate time.Time `json:"anniversary_date" format:"date-time"` - // Quater anniversary date is when quota limit is refreshed each quarter - QuarterAnniversaryDate time.Time `json:"quarter_anniversary_date" format:"date-time"` - // Tokens for the quarter - Quota int64 `json:"quota"` - // Tokens remaining for the quarter - Remaining int64 `json:"remaining"` - JSON cloudforceOneRequestQuotaResponseJSON `json:"-"` -} - -// cloudforceOneRequestQuotaResponseJSON contains the JSON metadata for the struct -// [CloudforceOneRequestQuotaResponse] -type cloudforceOneRequestQuotaResponseJSON struct { - AnniversaryDate apijson.Field - QuarterAnniversaryDate apijson.Field - Quota apijson.Field - Remaining apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestQuotaResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestQuotaResponseJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestNewParams struct { - // Request content - Content param.Field[string] `json:"content"` - // Priority for analyzing the request - Priority param.Field[string] `json:"priority"` - // Requested information from request - RequestType param.Field[string] `json:"request_type"` - // Brief description of the request - Summary param.Field[string] `json:"summary"` - // The CISA defined Traffic Light Protocol (TLP) - Tlp param.Field[CloudforceOneRequestNewParamsTlp] `json:"tlp"` -} - -func (r CloudforceOneRequestNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The CISA defined Traffic Light Protocol (TLP) -type CloudforceOneRequestNewParamsTlp string - -const ( - CloudforceOneRequestNewParamsTlpClear CloudforceOneRequestNewParamsTlp = "clear" - CloudforceOneRequestNewParamsTlpAmber CloudforceOneRequestNewParamsTlp = "amber" - CloudforceOneRequestNewParamsTlpAmberStrict CloudforceOneRequestNewParamsTlp = "amber-strict" - CloudforceOneRequestNewParamsTlpGreen CloudforceOneRequestNewParamsTlp = "green" - CloudforceOneRequestNewParamsTlpRed CloudforceOneRequestNewParamsTlp = "red" -) - -type CloudforceOneRequestNewResponseEnvelope struct { - Errors []CloudforceOneRequestNewResponseEnvelopeErrors `json:"errors,required"` - Messages []CloudforceOneRequestNewResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestNewResponse `json:"result,required"` - // Whether the API call was successful - Success CloudforceOneRequestNewResponseEnvelopeSuccess `json:"success,required"` - JSON cloudforceOneRequestNewResponseEnvelopeJSON `json:"-"` -} - -// cloudforceOneRequestNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [CloudforceOneRequestNewResponseEnvelope] -type cloudforceOneRequestNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// cloudforceOneRequestNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CloudforceOneRequestNewResponseEnvelopeErrors] -type cloudforceOneRequestNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// cloudforceOneRequestNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [CloudforceOneRequestNewResponseEnvelopeMessages] -type cloudforceOneRequestNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CloudforceOneRequestNewResponseEnvelopeSuccess bool - -const ( - CloudforceOneRequestNewResponseEnvelopeSuccessTrue CloudforceOneRequestNewResponseEnvelopeSuccess = true -) - -type CloudforceOneRequestUpdateParams struct { - // Request content - Content param.Field[string] `json:"content"` - // Priority for analyzing the request - Priority param.Field[string] `json:"priority"` - // Requested information from request - RequestType param.Field[string] `json:"request_type"` - // Brief description of the request - Summary param.Field[string] `json:"summary"` - // The CISA defined Traffic Light Protocol (TLP) - Tlp param.Field[CloudforceOneRequestUpdateParamsTlp] `json:"tlp"` -} - -func (r CloudforceOneRequestUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The CISA defined Traffic Light Protocol (TLP) -type CloudforceOneRequestUpdateParamsTlp string - -const ( - CloudforceOneRequestUpdateParamsTlpClear CloudforceOneRequestUpdateParamsTlp = "clear" - CloudforceOneRequestUpdateParamsTlpAmber CloudforceOneRequestUpdateParamsTlp = "amber" - CloudforceOneRequestUpdateParamsTlpAmberStrict CloudforceOneRequestUpdateParamsTlp = "amber-strict" - CloudforceOneRequestUpdateParamsTlpGreen CloudforceOneRequestUpdateParamsTlp = "green" - CloudforceOneRequestUpdateParamsTlpRed CloudforceOneRequestUpdateParamsTlp = "red" -) - -type CloudforceOneRequestUpdateResponseEnvelope struct { - Errors []CloudforceOneRequestUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []CloudforceOneRequestUpdateResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success CloudforceOneRequestUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON cloudforceOneRequestUpdateResponseEnvelopeJSON `json:"-"` -} - -// cloudforceOneRequestUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [CloudforceOneRequestUpdateResponseEnvelope] -type cloudforceOneRequestUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// cloudforceOneRequestUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [CloudforceOneRequestUpdateResponseEnvelopeErrors] -type cloudforceOneRequestUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// cloudforceOneRequestUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [CloudforceOneRequestUpdateResponseEnvelopeMessages] -type cloudforceOneRequestUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CloudforceOneRequestUpdateResponseEnvelopeSuccess bool - -const ( - CloudforceOneRequestUpdateResponseEnvelopeSuccessTrue CloudforceOneRequestUpdateResponseEnvelopeSuccess = true -) - -type CloudforceOneRequestListParams struct { - // Page number of results - Page param.Field[int64] `json:"page,required"` - // Number of results per page - PerPage param.Field[int64] `json:"per_page,required"` - // Retrieve requests completed after this time - CompletedAfter param.Field[time.Time] `json:"completed_after" format:"date-time"` - // Retrieve requests completed before this time - CompletedBefore param.Field[time.Time] `json:"completed_before" format:"date-time"` - // Retrieve requests created after this time - CreatedAfter param.Field[time.Time] `json:"created_after" format:"date-time"` - // Retrieve requests created before this time - CreatedBefore param.Field[time.Time] `json:"created_before" format:"date-time"` - // Requested information from request - RequestType param.Field[string] `json:"request_type"` - // Field to sort results by - SortBy param.Field[string] `json:"sort_by"` - // Sort order (asc or desc) - SortOrder param.Field[CloudforceOneRequestListParamsSortOrder] `json:"sort_order"` - // Request Status - Status param.Field[CloudforceOneRequestListParamsStatus] `json:"status"` -} - -func (r CloudforceOneRequestListParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Sort order (asc or desc) -type CloudforceOneRequestListParamsSortOrder string - -const ( - CloudforceOneRequestListParamsSortOrderAsc CloudforceOneRequestListParamsSortOrder = "asc" - CloudforceOneRequestListParamsSortOrderDesc CloudforceOneRequestListParamsSortOrder = "desc" -) - -// Request Status -type CloudforceOneRequestListParamsStatus string - -const ( - CloudforceOneRequestListParamsStatusOpen CloudforceOneRequestListParamsStatus = "open" - CloudforceOneRequestListParamsStatusAccepted CloudforceOneRequestListParamsStatus = "accepted" - CloudforceOneRequestListParamsStatusReported CloudforceOneRequestListParamsStatus = "reported" - CloudforceOneRequestListParamsStatusApproved CloudforceOneRequestListParamsStatus = "approved" - CloudforceOneRequestListParamsStatusCompleted CloudforceOneRequestListParamsStatus = "completed" - CloudforceOneRequestListParamsStatusDeclined CloudforceOneRequestListParamsStatus = "declined" -) - -type CloudforceOneRequestDeleteResponseEnvelope struct { - Errors []CloudforceOneRequestDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []CloudforceOneRequestDeleteResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success CloudforceOneRequestDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON cloudforceOneRequestDeleteResponseEnvelopeJSON `json:"-"` -} - -// cloudforceOneRequestDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [CloudforceOneRequestDeleteResponseEnvelope] -type cloudforceOneRequestDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// cloudforceOneRequestDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [CloudforceOneRequestDeleteResponseEnvelopeErrors] -type cloudforceOneRequestDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// cloudforceOneRequestDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [CloudforceOneRequestDeleteResponseEnvelopeMessages] -type cloudforceOneRequestDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CloudforceOneRequestDeleteResponseEnvelopeSuccess bool - -const ( - CloudforceOneRequestDeleteResponseEnvelopeSuccessTrue CloudforceOneRequestDeleteResponseEnvelopeSuccess = true -) - -type CloudforceOneRequestConstantsResponseEnvelope struct { - Errors []CloudforceOneRequestConstantsResponseEnvelopeErrors `json:"errors,required"` - Messages []CloudforceOneRequestConstantsResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestConstantsResponse `json:"result,required"` - // Whether the API call was successful - Success CloudforceOneRequestConstantsResponseEnvelopeSuccess `json:"success,required"` - JSON cloudforceOneRequestConstantsResponseEnvelopeJSON `json:"-"` -} - -// cloudforceOneRequestConstantsResponseEnvelopeJSON contains the JSON metadata for -// the struct [CloudforceOneRequestConstantsResponseEnvelope] -type cloudforceOneRequestConstantsResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestConstantsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestConstantsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestConstantsResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestConstantsResponseEnvelopeErrorsJSON `json:"-"` -} - -// cloudforceOneRequestConstantsResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [CloudforceOneRequestConstantsResponseEnvelopeErrors] -type cloudforceOneRequestConstantsResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestConstantsResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestConstantsResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestConstantsResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestConstantsResponseEnvelopeMessagesJSON `json:"-"` -} - -// cloudforceOneRequestConstantsResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [CloudforceOneRequestConstantsResponseEnvelopeMessages] -type cloudforceOneRequestConstantsResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestConstantsResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestConstantsResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CloudforceOneRequestConstantsResponseEnvelopeSuccess bool - -const ( - CloudforceOneRequestConstantsResponseEnvelopeSuccessTrue CloudforceOneRequestConstantsResponseEnvelopeSuccess = true -) - -type CloudforceOneRequestGetResponseEnvelope struct { - Errors []CloudforceOneRequestGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CloudforceOneRequestGetResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestGetResponse `json:"result,required"` - // Whether the API call was successful - Success CloudforceOneRequestGetResponseEnvelopeSuccess `json:"success,required"` - JSON cloudforceOneRequestGetResponseEnvelopeJSON `json:"-"` -} - -// cloudforceOneRequestGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [CloudforceOneRequestGetResponseEnvelope] -type cloudforceOneRequestGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// cloudforceOneRequestGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CloudforceOneRequestGetResponseEnvelopeErrors] -type cloudforceOneRequestGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// cloudforceOneRequestGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [CloudforceOneRequestGetResponseEnvelopeMessages] -type cloudforceOneRequestGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CloudforceOneRequestGetResponseEnvelopeSuccess bool - -const ( - CloudforceOneRequestGetResponseEnvelopeSuccessTrue CloudforceOneRequestGetResponseEnvelopeSuccess = true -) - -type CloudforceOneRequestQuotaResponseEnvelope struct { - Errors []CloudforceOneRequestQuotaResponseEnvelopeErrors `json:"errors,required"` - Messages []CloudforceOneRequestQuotaResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestQuotaResponse `json:"result,required"` - // Whether the API call was successful - Success CloudforceOneRequestQuotaResponseEnvelopeSuccess `json:"success,required"` - JSON cloudforceOneRequestQuotaResponseEnvelopeJSON `json:"-"` -} - -// cloudforceOneRequestQuotaResponseEnvelopeJSON contains the JSON metadata for the -// struct [CloudforceOneRequestQuotaResponseEnvelope] -type cloudforceOneRequestQuotaResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestQuotaResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestQuotaResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestQuotaResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestQuotaResponseEnvelopeErrorsJSON `json:"-"` -} - -// cloudforceOneRequestQuotaResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [CloudforceOneRequestQuotaResponseEnvelopeErrors] -type cloudforceOneRequestQuotaResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestQuotaResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestQuotaResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestQuotaResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestQuotaResponseEnvelopeMessagesJSON `json:"-"` -} - -// cloudforceOneRequestQuotaResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [CloudforceOneRequestQuotaResponseEnvelopeMessages] -type cloudforceOneRequestQuotaResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestQuotaResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestQuotaResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CloudforceOneRequestQuotaResponseEnvelopeSuccess bool - -const ( - CloudforceOneRequestQuotaResponseEnvelopeSuccessTrue CloudforceOneRequestQuotaResponseEnvelopeSuccess = true -) - -type CloudforceOneRequestTypesResponseEnvelope struct { - Errors []CloudforceOneRequestTypesResponseEnvelopeErrors `json:"errors,required"` - Messages []CloudforceOneRequestTypesResponseEnvelopeMessages `json:"messages,required"` - Result []string `json:"result,required"` - // Whether the API call was successful - Success CloudforceOneRequestTypesResponseEnvelopeSuccess `json:"success,required"` - JSON cloudforceOneRequestTypesResponseEnvelopeJSON `json:"-"` -} - -// cloudforceOneRequestTypesResponseEnvelopeJSON contains the JSON metadata for the -// struct [CloudforceOneRequestTypesResponseEnvelope] -type cloudforceOneRequestTypesResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestTypesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestTypesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestTypesResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestTypesResponseEnvelopeErrorsJSON `json:"-"` -} - -// cloudforceOneRequestTypesResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [CloudforceOneRequestTypesResponseEnvelopeErrors] -type cloudforceOneRequestTypesResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestTypesResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestTypesResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestTypesResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestTypesResponseEnvelopeMessagesJSON `json:"-"` -} - -// cloudforceOneRequestTypesResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [CloudforceOneRequestTypesResponseEnvelopeMessages] -type cloudforceOneRequestTypesResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestTypesResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestTypesResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CloudforceOneRequestTypesResponseEnvelopeSuccess bool - -const ( - CloudforceOneRequestTypesResponseEnvelopeSuccessTrue CloudforceOneRequestTypesResponseEnvelopeSuccess = true -) diff --git a/cloudforceonerequest_test.go b/cloudforceonerequest_test.go deleted file mode 100644 index 5a6b29cf177..00000000000 --- a/cloudforceonerequest_test.go +++ /dev/null @@ -1,251 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestCloudforceOneRequestNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.CloudforceOne.Requests.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.CloudforceOneRequestNewParams{ - Content: cloudflare.F("What regions were most effected by the recent DoS?"), - Priority: cloudflare.F("routine"), - RequestType: cloudflare.F("Victomology"), - Summary: cloudflare.F("DoS attack"), - Tlp: cloudflare.F(cloudflare.CloudforceOneRequestNewParamsTlpClear), - }, - ) - 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 TestCloudforceOneRequestUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.CloudforceOne.Requests.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.CloudforceOneRequestUpdateParams{ - Content: cloudflare.F("What regions were most effected by the recent DoS?"), - Priority: cloudflare.F("routine"), - RequestType: cloudflare.F("Victomology"), - Summary: cloudflare.F("DoS attack"), - Tlp: cloudflare.F(cloudflare.CloudforceOneRequestUpdateParamsTlpClear), - }, - ) - 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 TestCloudforceOneRequestListWithOptionalParams(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("user@example.com"), - ) - _, err := client.CloudforceOne.Requests.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.CloudforceOneRequestListParams{ - Page: cloudflare.F(int64(0)), - PerPage: cloudflare.F(int64(10)), - CompletedAfter: cloudflare.F(time.Now()), - CompletedBefore: cloudflare.F(time.Now()), - CreatedAfter: cloudflare.F(time.Now()), - CreatedBefore: cloudflare.F(time.Now()), - RequestType: cloudflare.F("Victomology"), - SortBy: cloudflare.F("created"), - SortOrder: cloudflare.F(cloudflare.CloudforceOneRequestListParamsSortOrderAsc), - Status: cloudflare.F(cloudflare.CloudforceOneRequestListParamsStatusOpen), - }, - ) - 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 TestCloudforceOneRequestDelete(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("user@example.com"), - ) - _, err := client.CloudforceOne.Requests.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - 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 TestCloudforceOneRequestConstants(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("user@example.com"), - ) - _, err := client.CloudforceOne.Requests.Constants(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()) - } -} - -func TestCloudforceOneRequestGet(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("user@example.com"), - ) - _, err := client.CloudforceOne.Requests.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - 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 TestCloudforceOneRequestQuota(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("user@example.com"), - ) - _, err := client.CloudforceOne.Requests.Quota(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()) - } -} - -func TestCloudforceOneRequestTypes(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("user@example.com"), - ) - _, err := client.CloudforceOne.Requests.Types(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/cloudforceonerequestmessage.go b/cloudforceonerequestmessage.go deleted file mode 100644 index 1ed338776bc..00000000000 --- a/cloudforceonerequestmessage.go +++ /dev/null @@ -1,619 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// CloudforceOneRequestMessageService 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 -// [NewCloudforceOneRequestMessageService] method instead. -type CloudforceOneRequestMessageService struct { - Options []option.RequestOption -} - -// NewCloudforceOneRequestMessageService 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 NewCloudforceOneRequestMessageService(opts ...option.RequestOption) (r *CloudforceOneRequestMessageService) { - r = &CloudforceOneRequestMessageService{} - r.Options = opts - return -} - -// Creating a request adds the request into the Cloudforce One queue for analysis. -// In addition to the content, a short title, type, priority, and releasability -// should be provided. If one is not provided a default will be assigned. -func (r *CloudforceOneRequestMessageService) New(ctx context.Context, accountIdentifier string, requestIdentifier string, body CloudforceOneRequestMessageNewParams, opts ...option.RequestOption) (res *CloudforceOneRequestMessageNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env CloudforceOneRequestMessageNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s/message/new", accountIdentifier, requestIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update a Request Message -func (r *CloudforceOneRequestMessageService) Update(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64, body CloudforceOneRequestMessageUpdateParams, opts ...option.RequestOption) (res *CloudforceOneRequestMessageUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env CloudforceOneRequestMessageUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s/message/%v", accountIdentifier, requestIdentifier, messageIdentifer) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a Request Message -func (r *CloudforceOneRequestMessageService) Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64, opts ...option.RequestOption) (res *CloudforceOneRequestMessageDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env CloudforceOneRequestMessageDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s/message/%v", accountIdentifier, requestIdentifier, messageIdentifer) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List Request Messages -func (r *CloudforceOneRequestMessageService) Get(ctx context.Context, accountIdentifier string, requestIdentifier string, body CloudforceOneRequestMessageGetParams, opts ...option.RequestOption) (res *[]CloudforceOneRequestMessageGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env CloudforceOneRequestMessageGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s/message", accountIdentifier, requestIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type CloudforceOneRequestMessageNewResponse struct { - // Message ID - ID int64 `json:"id,required"` - // Author of message - Author string `json:"author,required"` - // Content of message - Content string `json:"content,required"` - // Message is a follow-on request - IsFollowOnRequest bool `json:"is_follow_on_request,required"` - // Message last updated time - Updated time.Time `json:"updated,required" format:"date-time"` - // Message creation time - Created time.Time `json:"created" format:"date-time"` - JSON cloudforceOneRequestMessageNewResponseJSON `json:"-"` -} - -// cloudforceOneRequestMessageNewResponseJSON contains the JSON metadata for the -// struct [CloudforceOneRequestMessageNewResponse] -type cloudforceOneRequestMessageNewResponseJSON struct { - ID apijson.Field - Author apijson.Field - Content apijson.Field - IsFollowOnRequest apijson.Field - Updated apijson.Field - Created apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestMessageNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestMessageNewResponseJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestMessageUpdateResponse struct { - // Message ID - ID int64 `json:"id,required"` - // Author of message - Author string `json:"author,required"` - // Content of message - Content string `json:"content,required"` - // Message is a follow-on request - IsFollowOnRequest bool `json:"is_follow_on_request,required"` - // Message last updated time - Updated time.Time `json:"updated,required" format:"date-time"` - // Message creation time - Created time.Time `json:"created" format:"date-time"` - JSON cloudforceOneRequestMessageUpdateResponseJSON `json:"-"` -} - -// cloudforceOneRequestMessageUpdateResponseJSON contains the JSON metadata for the -// struct [CloudforceOneRequestMessageUpdateResponse] -type cloudforceOneRequestMessageUpdateResponseJSON struct { - ID apijson.Field - Author apijson.Field - Content apijson.Field - IsFollowOnRequest apijson.Field - Updated apijson.Field - Created apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestMessageUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestMessageUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [CloudforceOneRequestMessageDeleteResponseUnknown], -// [CloudforceOneRequestMessageDeleteResponseArray] or [shared.UnionString]. -type CloudforceOneRequestMessageDeleteResponse interface { - ImplementsCloudforceOneRequestMessageDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*CloudforceOneRequestMessageDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(CloudforceOneRequestMessageDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type CloudforceOneRequestMessageDeleteResponseArray []interface{} - -func (r CloudforceOneRequestMessageDeleteResponseArray) ImplementsCloudforceOneRequestMessageDeleteResponse() { -} - -type CloudforceOneRequestMessageGetResponse struct { - // Message ID - ID int64 `json:"id,required"` - // Author of message - Author string `json:"author,required"` - // Content of message - Content string `json:"content,required"` - // Message is a follow-on request - IsFollowOnRequest bool `json:"is_follow_on_request,required"` - // Message last updated time - Updated time.Time `json:"updated,required" format:"date-time"` - // Message creation time - Created time.Time `json:"created" format:"date-time"` - JSON cloudforceOneRequestMessageGetResponseJSON `json:"-"` -} - -// cloudforceOneRequestMessageGetResponseJSON contains the JSON metadata for the -// struct [CloudforceOneRequestMessageGetResponse] -type cloudforceOneRequestMessageGetResponseJSON struct { - ID apijson.Field - Author apijson.Field - Content apijson.Field - IsFollowOnRequest apijson.Field - Updated apijson.Field - Created apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestMessageGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestMessageGetResponseJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestMessageNewParams struct { - // Content of message - Content param.Field[string] `json:"content"` -} - -func (r CloudforceOneRequestMessageNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type CloudforceOneRequestMessageNewResponseEnvelope struct { - Errors []CloudforceOneRequestMessageNewResponseEnvelopeErrors `json:"errors,required"` - Messages []CloudforceOneRequestMessageNewResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestMessageNewResponse `json:"result,required"` - // Whether the API call was successful - Success CloudforceOneRequestMessageNewResponseEnvelopeSuccess `json:"success,required"` - JSON cloudforceOneRequestMessageNewResponseEnvelopeJSON `json:"-"` -} - -// cloudforceOneRequestMessageNewResponseEnvelopeJSON contains the JSON metadata -// for the struct [CloudforceOneRequestMessageNewResponseEnvelope] -type cloudforceOneRequestMessageNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestMessageNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestMessageNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestMessageNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestMessageNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// cloudforceOneRequestMessageNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [CloudforceOneRequestMessageNewResponseEnvelopeErrors] -type cloudforceOneRequestMessageNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestMessageNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestMessageNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestMessageNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestMessageNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// cloudforceOneRequestMessageNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [CloudforceOneRequestMessageNewResponseEnvelopeMessages] -type cloudforceOneRequestMessageNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestMessageNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestMessageNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CloudforceOneRequestMessageNewResponseEnvelopeSuccess bool - -const ( - CloudforceOneRequestMessageNewResponseEnvelopeSuccessTrue CloudforceOneRequestMessageNewResponseEnvelopeSuccess = true -) - -type CloudforceOneRequestMessageUpdateParams struct { - // Request content - Content param.Field[string] `json:"content"` - // Priority for analyzing the request - Priority param.Field[string] `json:"priority"` - // Requested information from request - RequestType param.Field[string] `json:"request_type"` - // Brief description of the request - Summary param.Field[string] `json:"summary"` - // The CISA defined Traffic Light Protocol (TLP) - Tlp param.Field[CloudforceOneRequestMessageUpdateParamsTlp] `json:"tlp"` -} - -func (r CloudforceOneRequestMessageUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The CISA defined Traffic Light Protocol (TLP) -type CloudforceOneRequestMessageUpdateParamsTlp string - -const ( - CloudforceOneRequestMessageUpdateParamsTlpClear CloudforceOneRequestMessageUpdateParamsTlp = "clear" - CloudforceOneRequestMessageUpdateParamsTlpAmber CloudforceOneRequestMessageUpdateParamsTlp = "amber" - CloudforceOneRequestMessageUpdateParamsTlpAmberStrict CloudforceOneRequestMessageUpdateParamsTlp = "amber-strict" - CloudforceOneRequestMessageUpdateParamsTlpGreen CloudforceOneRequestMessageUpdateParamsTlp = "green" - CloudforceOneRequestMessageUpdateParamsTlpRed CloudforceOneRequestMessageUpdateParamsTlp = "red" -) - -type CloudforceOneRequestMessageUpdateResponseEnvelope struct { - Errors []CloudforceOneRequestMessageUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []CloudforceOneRequestMessageUpdateResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestMessageUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success CloudforceOneRequestMessageUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON cloudforceOneRequestMessageUpdateResponseEnvelopeJSON `json:"-"` -} - -// cloudforceOneRequestMessageUpdateResponseEnvelopeJSON contains the JSON metadata -// for the struct [CloudforceOneRequestMessageUpdateResponseEnvelope] -type cloudforceOneRequestMessageUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestMessageUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestMessageUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestMessageUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestMessageUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// cloudforceOneRequestMessageUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [CloudforceOneRequestMessageUpdateResponseEnvelopeErrors] -type cloudforceOneRequestMessageUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestMessageUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestMessageUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestMessageUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestMessageUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// cloudforceOneRequestMessageUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [CloudforceOneRequestMessageUpdateResponseEnvelopeMessages] -type cloudforceOneRequestMessageUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestMessageUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestMessageUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CloudforceOneRequestMessageUpdateResponseEnvelopeSuccess bool - -const ( - CloudforceOneRequestMessageUpdateResponseEnvelopeSuccessTrue CloudforceOneRequestMessageUpdateResponseEnvelopeSuccess = true -) - -type CloudforceOneRequestMessageDeleteResponseEnvelope struct { - Errors []CloudforceOneRequestMessageDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []CloudforceOneRequestMessageDeleteResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestMessageDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success CloudforceOneRequestMessageDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON cloudforceOneRequestMessageDeleteResponseEnvelopeJSON `json:"-"` -} - -// cloudforceOneRequestMessageDeleteResponseEnvelopeJSON contains the JSON metadata -// for the struct [CloudforceOneRequestMessageDeleteResponseEnvelope] -type cloudforceOneRequestMessageDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestMessageDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestMessageDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestMessageDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestMessageDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// cloudforceOneRequestMessageDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [CloudforceOneRequestMessageDeleteResponseEnvelopeErrors] -type cloudforceOneRequestMessageDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestMessageDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestMessageDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestMessageDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestMessageDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// cloudforceOneRequestMessageDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [CloudforceOneRequestMessageDeleteResponseEnvelopeMessages] -type cloudforceOneRequestMessageDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestMessageDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestMessageDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CloudforceOneRequestMessageDeleteResponseEnvelopeSuccess bool - -const ( - CloudforceOneRequestMessageDeleteResponseEnvelopeSuccessTrue CloudforceOneRequestMessageDeleteResponseEnvelopeSuccess = true -) - -type CloudforceOneRequestMessageGetParams struct { - // Page number of results - Page param.Field[int64] `json:"page,required"` - // Number of results per page - PerPage param.Field[int64] `json:"per_page,required"` - // Retrieve messages created after this time - After param.Field[time.Time] `json:"after" format:"date-time"` - // Retrieve messages created before this time - Before param.Field[time.Time] `json:"before" format:"date-time"` - // Field to sort results by - SortBy param.Field[string] `json:"sort_by"` - // Sort order (asc or desc) - SortOrder param.Field[CloudforceOneRequestMessageGetParamsSortOrder] `json:"sort_order"` -} - -func (r CloudforceOneRequestMessageGetParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Sort order (asc or desc) -type CloudforceOneRequestMessageGetParamsSortOrder string - -const ( - CloudforceOneRequestMessageGetParamsSortOrderAsc CloudforceOneRequestMessageGetParamsSortOrder = "asc" - CloudforceOneRequestMessageGetParamsSortOrderDesc CloudforceOneRequestMessageGetParamsSortOrder = "desc" -) - -type CloudforceOneRequestMessageGetResponseEnvelope struct { - Errors []CloudforceOneRequestMessageGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CloudforceOneRequestMessageGetResponseEnvelopeMessages `json:"messages,required"` - Result []CloudforceOneRequestMessageGetResponse `json:"result,required"` - // Whether the API call was successful - Success CloudforceOneRequestMessageGetResponseEnvelopeSuccess `json:"success,required"` - JSON cloudforceOneRequestMessageGetResponseEnvelopeJSON `json:"-"` -} - -// cloudforceOneRequestMessageGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [CloudforceOneRequestMessageGetResponseEnvelope] -type cloudforceOneRequestMessageGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestMessageGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestMessageGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestMessageGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestMessageGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// cloudforceOneRequestMessageGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [CloudforceOneRequestMessageGetResponseEnvelopeErrors] -type cloudforceOneRequestMessageGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestMessageGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestMessageGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestMessageGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestMessageGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// cloudforceOneRequestMessageGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [CloudforceOneRequestMessageGetResponseEnvelopeMessages] -type cloudforceOneRequestMessageGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestMessageGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestMessageGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CloudforceOneRequestMessageGetResponseEnvelopeSuccess bool - -const ( - CloudforceOneRequestMessageGetResponseEnvelopeSuccessTrue CloudforceOneRequestMessageGetResponseEnvelopeSuccess = true -) diff --git a/cloudforceonerequestmessage_test.go b/cloudforceonerequestmessage_test.go deleted file mode 100644 index 9e55de90185..00000000000 --- a/cloudforceonerequestmessage_test.go +++ /dev/null @@ -1,147 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestCloudforceOneRequestMessageNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.CloudforceOne.Requests.Message.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.CloudforceOneRequestMessageNewParams{ - Content: cloudflare.F("Can you elaborate on the type of DoS that occurred?"), - }, - ) - 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 TestCloudforceOneRequestMessageUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.CloudforceOne.Requests.Message.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - int64(0), - cloudflare.CloudforceOneRequestMessageUpdateParams{ - Content: cloudflare.F("What regions were most effected by the recent DoS?"), - Priority: cloudflare.F("routine"), - RequestType: cloudflare.F("Victomology"), - Summary: cloudflare.F("DoS attack"), - Tlp: cloudflare.F(cloudflare.CloudforceOneRequestMessageUpdateParamsTlpClear), - }, - ) - 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 TestCloudforceOneRequestMessageDelete(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("user@example.com"), - ) - _, err := client.CloudforceOne.Requests.Message.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - int64(0), - ) - 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 TestCloudforceOneRequestMessageGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.CloudforceOne.Requests.Message.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.CloudforceOneRequestMessageGetParams{ - Page: cloudflare.F(int64(0)), - PerPage: cloudflare.F(int64(10)), - After: cloudflare.F(time.Now()), - Before: cloudflare.F(time.Now()), - SortBy: cloudflare.F("created"), - SortOrder: cloudflare.F(cloudflare.CloudforceOneRequestMessageGetParamsSortOrderAsc), - }, - ) - 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/cloudforceonerequestpriority.go b/cloudforceonerequestpriority.go deleted file mode 100644 index b2001a761ac..00000000000 --- a/cloudforceonerequestpriority.go +++ /dev/null @@ -1,828 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// CloudforceOneRequestPriorityService 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 -// [NewCloudforceOneRequestPriorityService] method instead. -type CloudforceOneRequestPriorityService struct { - Options []option.RequestOption -} - -// NewCloudforceOneRequestPriorityService 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 NewCloudforceOneRequestPriorityService(opts ...option.RequestOption) (r *CloudforceOneRequestPriorityService) { - r = &CloudforceOneRequestPriorityService{} - r.Options = opts - return -} - -// Create a New Priority Requirement -func (r *CloudforceOneRequestPriorityService) New(ctx context.Context, accountIdentifier string, body CloudforceOneRequestPriorityNewParams, opts ...option.RequestOption) (res *CloudforceOneRequestPriorityNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env CloudforceOneRequestPriorityNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/priority/new", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update a Priority Intelligence Requirement -func (r *CloudforceOneRequestPriorityService) Update(ctx context.Context, accountIdentifier string, priorityIdentifer string, body CloudforceOneRequestPriorityUpdateParams, opts ...option.RequestOption) (res *CloudforceOneRequestPriorityUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env CloudforceOneRequestPriorityUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/priority/%s", accountIdentifier, priorityIdentifer) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a Priority Intelligence Report -func (r *CloudforceOneRequestPriorityService) Delete(ctx context.Context, accountIdentifier string, priorityIdentifer string, opts ...option.RequestOption) (res *CloudforceOneRequestPriorityDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env CloudforceOneRequestPriorityDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/priority/%s", accountIdentifier, priorityIdentifer) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a Priority Intelligence Requirement -func (r *CloudforceOneRequestPriorityService) Get(ctx context.Context, accountIdentifier string, priorityIdentifer string, opts ...option.RequestOption) (res *CloudforceOneRequestPriorityGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env CloudforceOneRequestPriorityGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/priority/%s", accountIdentifier, priorityIdentifer) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get Priority Intelligence Requirement Quota -func (r *CloudforceOneRequestPriorityService) Quota(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *CloudforceOneRequestPriorityQuotaResponse, err error) { - opts = append(r.Options[:], opts...) - var env CloudforceOneRequestPriorityQuotaResponseEnvelope - path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/priority/quota", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type CloudforceOneRequestPriorityNewResponse struct { - // UUID - ID string `json:"id,required"` - // Priority creation time - Created time.Time `json:"created,required" format:"date-time"` - // List of labels - Labels []string `json:"labels,required"` - // Priority - Priority int64 `json:"priority,required"` - // Requirement - Requirement string `json:"requirement,required"` - // The CISA defined Traffic Light Protocol (TLP) - Tlp CloudforceOneRequestPriorityNewResponseTlp `json:"tlp,required"` - // Priority last updated time - Updated time.Time `json:"updated,required" format:"date-time"` - JSON cloudforceOneRequestPriorityNewResponseJSON `json:"-"` -} - -// cloudforceOneRequestPriorityNewResponseJSON contains the JSON metadata for the -// struct [CloudforceOneRequestPriorityNewResponse] -type cloudforceOneRequestPriorityNewResponseJSON struct { - ID apijson.Field - Created apijson.Field - Labels apijson.Field - Priority apijson.Field - Requirement apijson.Field - Tlp apijson.Field - Updated apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityNewResponseJSON) RawJSON() string { - return r.raw -} - -// The CISA defined Traffic Light Protocol (TLP) -type CloudforceOneRequestPriorityNewResponseTlp string - -const ( - CloudforceOneRequestPriorityNewResponseTlpClear CloudforceOneRequestPriorityNewResponseTlp = "clear" - CloudforceOneRequestPriorityNewResponseTlpAmber CloudforceOneRequestPriorityNewResponseTlp = "amber" - CloudforceOneRequestPriorityNewResponseTlpAmberStrict CloudforceOneRequestPriorityNewResponseTlp = "amber-strict" - CloudforceOneRequestPriorityNewResponseTlpGreen CloudforceOneRequestPriorityNewResponseTlp = "green" - CloudforceOneRequestPriorityNewResponseTlpRed CloudforceOneRequestPriorityNewResponseTlp = "red" -) - -type CloudforceOneRequestPriorityUpdateResponse struct { - // UUID - ID string `json:"id,required"` - // Request content - Content string `json:"content,required"` - Created time.Time `json:"created,required" format:"date-time"` - Priority time.Time `json:"priority,required" format:"date-time"` - // Requested information from request - Request string `json:"request,required"` - // Brief description of the request - Summary string `json:"summary,required"` - // The CISA defined Traffic Light Protocol (TLP) - Tlp CloudforceOneRequestPriorityUpdateResponseTlp `json:"tlp,required"` - Updated time.Time `json:"updated,required" format:"date-time"` - Completed time.Time `json:"completed" format:"date-time"` - // Tokens for the request messages - MessageTokens int64 `json:"message_tokens"` - // Readable Request ID - ReadableID string `json:"readable_id"` - // Request Status - Status CloudforceOneRequestPriorityUpdateResponseStatus `json:"status"` - // Tokens for the request - Tokens int64 `json:"tokens"` - JSON cloudforceOneRequestPriorityUpdateResponseJSON `json:"-"` -} - -// cloudforceOneRequestPriorityUpdateResponseJSON contains the JSON metadata for -// the struct [CloudforceOneRequestPriorityUpdateResponse] -type cloudforceOneRequestPriorityUpdateResponseJSON struct { - ID apijson.Field - Content apijson.Field - Created apijson.Field - Priority apijson.Field - Request apijson.Field - Summary apijson.Field - Tlp apijson.Field - Updated apijson.Field - Completed apijson.Field - MessageTokens apijson.Field - ReadableID apijson.Field - Status apijson.Field - Tokens apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// The CISA defined Traffic Light Protocol (TLP) -type CloudforceOneRequestPriorityUpdateResponseTlp string - -const ( - CloudforceOneRequestPriorityUpdateResponseTlpClear CloudforceOneRequestPriorityUpdateResponseTlp = "clear" - CloudforceOneRequestPriorityUpdateResponseTlpAmber CloudforceOneRequestPriorityUpdateResponseTlp = "amber" - CloudforceOneRequestPriorityUpdateResponseTlpAmberStrict CloudforceOneRequestPriorityUpdateResponseTlp = "amber-strict" - CloudforceOneRequestPriorityUpdateResponseTlpGreen CloudforceOneRequestPriorityUpdateResponseTlp = "green" - CloudforceOneRequestPriorityUpdateResponseTlpRed CloudforceOneRequestPriorityUpdateResponseTlp = "red" -) - -// Request Status -type CloudforceOneRequestPriorityUpdateResponseStatus string - -const ( - CloudforceOneRequestPriorityUpdateResponseStatusOpen CloudforceOneRequestPriorityUpdateResponseStatus = "open" - CloudforceOneRequestPriorityUpdateResponseStatusAccepted CloudforceOneRequestPriorityUpdateResponseStatus = "accepted" - CloudforceOneRequestPriorityUpdateResponseStatusReported CloudforceOneRequestPriorityUpdateResponseStatus = "reported" - CloudforceOneRequestPriorityUpdateResponseStatusApproved CloudforceOneRequestPriorityUpdateResponseStatus = "approved" - CloudforceOneRequestPriorityUpdateResponseStatusCompleted CloudforceOneRequestPriorityUpdateResponseStatus = "completed" - CloudforceOneRequestPriorityUpdateResponseStatusDeclined CloudforceOneRequestPriorityUpdateResponseStatus = "declined" -) - -// Union satisfied by [CloudforceOneRequestPriorityDeleteResponseUnknown], -// [CloudforceOneRequestPriorityDeleteResponseArray] or [shared.UnionString]. -type CloudforceOneRequestPriorityDeleteResponse interface { - ImplementsCloudforceOneRequestPriorityDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*CloudforceOneRequestPriorityDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(CloudforceOneRequestPriorityDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type CloudforceOneRequestPriorityDeleteResponseArray []interface{} - -func (r CloudforceOneRequestPriorityDeleteResponseArray) ImplementsCloudforceOneRequestPriorityDeleteResponse() { -} - -type CloudforceOneRequestPriorityGetResponse struct { - // UUID - ID string `json:"id,required"` - // Request content - Content string `json:"content,required"` - Created time.Time `json:"created,required" format:"date-time"` - Priority time.Time `json:"priority,required" format:"date-time"` - // Requested information from request - Request string `json:"request,required"` - // Brief description of the request - Summary string `json:"summary,required"` - // The CISA defined Traffic Light Protocol (TLP) - Tlp CloudforceOneRequestPriorityGetResponseTlp `json:"tlp,required"` - Updated time.Time `json:"updated,required" format:"date-time"` - Completed time.Time `json:"completed" format:"date-time"` - // Tokens for the request messages - MessageTokens int64 `json:"message_tokens"` - // Readable Request ID - ReadableID string `json:"readable_id"` - // Request Status - Status CloudforceOneRequestPriorityGetResponseStatus `json:"status"` - // Tokens for the request - Tokens int64 `json:"tokens"` - JSON cloudforceOneRequestPriorityGetResponseJSON `json:"-"` -} - -// cloudforceOneRequestPriorityGetResponseJSON contains the JSON metadata for the -// struct [CloudforceOneRequestPriorityGetResponse] -type cloudforceOneRequestPriorityGetResponseJSON struct { - ID apijson.Field - Content apijson.Field - Created apijson.Field - Priority apijson.Field - Request apijson.Field - Summary apijson.Field - Tlp apijson.Field - Updated apijson.Field - Completed apijson.Field - MessageTokens apijson.Field - ReadableID apijson.Field - Status apijson.Field - Tokens apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityGetResponseJSON) RawJSON() string { - return r.raw -} - -// The CISA defined Traffic Light Protocol (TLP) -type CloudforceOneRequestPriorityGetResponseTlp string - -const ( - CloudforceOneRequestPriorityGetResponseTlpClear CloudforceOneRequestPriorityGetResponseTlp = "clear" - CloudforceOneRequestPriorityGetResponseTlpAmber CloudforceOneRequestPriorityGetResponseTlp = "amber" - CloudforceOneRequestPriorityGetResponseTlpAmberStrict CloudforceOneRequestPriorityGetResponseTlp = "amber-strict" - CloudforceOneRequestPriorityGetResponseTlpGreen CloudforceOneRequestPriorityGetResponseTlp = "green" - CloudforceOneRequestPriorityGetResponseTlpRed CloudforceOneRequestPriorityGetResponseTlp = "red" -) - -// Request Status -type CloudforceOneRequestPriorityGetResponseStatus string - -const ( - CloudforceOneRequestPriorityGetResponseStatusOpen CloudforceOneRequestPriorityGetResponseStatus = "open" - CloudforceOneRequestPriorityGetResponseStatusAccepted CloudforceOneRequestPriorityGetResponseStatus = "accepted" - CloudforceOneRequestPriorityGetResponseStatusReported CloudforceOneRequestPriorityGetResponseStatus = "reported" - CloudforceOneRequestPriorityGetResponseStatusApproved CloudforceOneRequestPriorityGetResponseStatus = "approved" - CloudforceOneRequestPriorityGetResponseStatusCompleted CloudforceOneRequestPriorityGetResponseStatus = "completed" - CloudforceOneRequestPriorityGetResponseStatusDeclined CloudforceOneRequestPriorityGetResponseStatus = "declined" -) - -type CloudforceOneRequestPriorityQuotaResponse struct { - // Anniversary date is when annual quota limit is refresh - AnniversaryDate time.Time `json:"anniversary_date" format:"date-time"` - // Quater anniversary date is when quota limit is refreshed each quarter - QuarterAnniversaryDate time.Time `json:"quarter_anniversary_date" format:"date-time"` - // Tokens for the quarter - Quota int64 `json:"quota"` - // Tokens remaining for the quarter - Remaining int64 `json:"remaining"` - JSON cloudforceOneRequestPriorityQuotaResponseJSON `json:"-"` -} - -// cloudforceOneRequestPriorityQuotaResponseJSON contains the JSON metadata for the -// struct [CloudforceOneRequestPriorityQuotaResponse] -type cloudforceOneRequestPriorityQuotaResponseJSON struct { - AnniversaryDate apijson.Field - QuarterAnniversaryDate apijson.Field - Quota apijson.Field - Remaining apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityQuotaResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityQuotaResponseJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestPriorityNewParams struct { - // List of labels - Labels param.Field[[]string] `json:"labels,required"` - // Priority - Priority param.Field[int64] `json:"priority,required"` - // Requirement - Requirement param.Field[string] `json:"requirement,required"` - // The CISA defined Traffic Light Protocol (TLP) - Tlp param.Field[CloudforceOneRequestPriorityNewParamsTlp] `json:"tlp,required"` -} - -func (r CloudforceOneRequestPriorityNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The CISA defined Traffic Light Protocol (TLP) -type CloudforceOneRequestPriorityNewParamsTlp string - -const ( - CloudforceOneRequestPriorityNewParamsTlpClear CloudforceOneRequestPriorityNewParamsTlp = "clear" - CloudforceOneRequestPriorityNewParamsTlpAmber CloudforceOneRequestPriorityNewParamsTlp = "amber" - CloudforceOneRequestPriorityNewParamsTlpAmberStrict CloudforceOneRequestPriorityNewParamsTlp = "amber-strict" - CloudforceOneRequestPriorityNewParamsTlpGreen CloudforceOneRequestPriorityNewParamsTlp = "green" - CloudforceOneRequestPriorityNewParamsTlpRed CloudforceOneRequestPriorityNewParamsTlp = "red" -) - -type CloudforceOneRequestPriorityNewResponseEnvelope struct { - Errors []CloudforceOneRequestPriorityNewResponseEnvelopeErrors `json:"errors,required"` - Messages []CloudforceOneRequestPriorityNewResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestPriorityNewResponse `json:"result,required"` - // Whether the API call was successful - Success CloudforceOneRequestPriorityNewResponseEnvelopeSuccess `json:"success,required"` - JSON cloudforceOneRequestPriorityNewResponseEnvelopeJSON `json:"-"` -} - -// cloudforceOneRequestPriorityNewResponseEnvelopeJSON contains the JSON metadata -// for the struct [CloudforceOneRequestPriorityNewResponseEnvelope] -type cloudforceOneRequestPriorityNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestPriorityNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestPriorityNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// cloudforceOneRequestPriorityNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [CloudforceOneRequestPriorityNewResponseEnvelopeErrors] -type cloudforceOneRequestPriorityNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestPriorityNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestPriorityNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// cloudforceOneRequestPriorityNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [CloudforceOneRequestPriorityNewResponseEnvelopeMessages] -type cloudforceOneRequestPriorityNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CloudforceOneRequestPriorityNewResponseEnvelopeSuccess bool - -const ( - CloudforceOneRequestPriorityNewResponseEnvelopeSuccessTrue CloudforceOneRequestPriorityNewResponseEnvelopeSuccess = true -) - -type CloudforceOneRequestPriorityUpdateParams struct { - // List of labels - Labels param.Field[[]string] `json:"labels,required"` - // Priority - Priority param.Field[int64] `json:"priority,required"` - // Requirement - Requirement param.Field[string] `json:"requirement,required"` - // The CISA defined Traffic Light Protocol (TLP) - Tlp param.Field[CloudforceOneRequestPriorityUpdateParamsTlp] `json:"tlp,required"` -} - -func (r CloudforceOneRequestPriorityUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The CISA defined Traffic Light Protocol (TLP) -type CloudforceOneRequestPriorityUpdateParamsTlp string - -const ( - CloudforceOneRequestPriorityUpdateParamsTlpClear CloudforceOneRequestPriorityUpdateParamsTlp = "clear" - CloudforceOneRequestPriorityUpdateParamsTlpAmber CloudforceOneRequestPriorityUpdateParamsTlp = "amber" - CloudforceOneRequestPriorityUpdateParamsTlpAmberStrict CloudforceOneRequestPriorityUpdateParamsTlp = "amber-strict" - CloudforceOneRequestPriorityUpdateParamsTlpGreen CloudforceOneRequestPriorityUpdateParamsTlp = "green" - CloudforceOneRequestPriorityUpdateParamsTlpRed CloudforceOneRequestPriorityUpdateParamsTlp = "red" -) - -type CloudforceOneRequestPriorityUpdateResponseEnvelope struct { - Errors []CloudforceOneRequestPriorityUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []CloudforceOneRequestPriorityUpdateResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestPriorityUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success CloudforceOneRequestPriorityUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON cloudforceOneRequestPriorityUpdateResponseEnvelopeJSON `json:"-"` -} - -// cloudforceOneRequestPriorityUpdateResponseEnvelopeJSON contains the JSON -// metadata for the struct [CloudforceOneRequestPriorityUpdateResponseEnvelope] -type cloudforceOneRequestPriorityUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestPriorityUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestPriorityUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// cloudforceOneRequestPriorityUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [CloudforceOneRequestPriorityUpdateResponseEnvelopeErrors] -type cloudforceOneRequestPriorityUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestPriorityUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestPriorityUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// cloudforceOneRequestPriorityUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [CloudforceOneRequestPriorityUpdateResponseEnvelopeMessages] -type cloudforceOneRequestPriorityUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CloudforceOneRequestPriorityUpdateResponseEnvelopeSuccess bool - -const ( - CloudforceOneRequestPriorityUpdateResponseEnvelopeSuccessTrue CloudforceOneRequestPriorityUpdateResponseEnvelopeSuccess = true -) - -type CloudforceOneRequestPriorityDeleteResponseEnvelope struct { - Errors []CloudforceOneRequestPriorityDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []CloudforceOneRequestPriorityDeleteResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestPriorityDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success CloudforceOneRequestPriorityDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON cloudforceOneRequestPriorityDeleteResponseEnvelopeJSON `json:"-"` -} - -// cloudforceOneRequestPriorityDeleteResponseEnvelopeJSON contains the JSON -// metadata for the struct [CloudforceOneRequestPriorityDeleteResponseEnvelope] -type cloudforceOneRequestPriorityDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestPriorityDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestPriorityDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// cloudforceOneRequestPriorityDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [CloudforceOneRequestPriorityDeleteResponseEnvelopeErrors] -type cloudforceOneRequestPriorityDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestPriorityDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestPriorityDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// cloudforceOneRequestPriorityDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [CloudforceOneRequestPriorityDeleteResponseEnvelopeMessages] -type cloudforceOneRequestPriorityDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CloudforceOneRequestPriorityDeleteResponseEnvelopeSuccess bool - -const ( - CloudforceOneRequestPriorityDeleteResponseEnvelopeSuccessTrue CloudforceOneRequestPriorityDeleteResponseEnvelopeSuccess = true -) - -type CloudforceOneRequestPriorityGetResponseEnvelope struct { - Errors []CloudforceOneRequestPriorityGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CloudforceOneRequestPriorityGetResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestPriorityGetResponse `json:"result,required"` - // Whether the API call was successful - Success CloudforceOneRequestPriorityGetResponseEnvelopeSuccess `json:"success,required"` - JSON cloudforceOneRequestPriorityGetResponseEnvelopeJSON `json:"-"` -} - -// cloudforceOneRequestPriorityGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [CloudforceOneRequestPriorityGetResponseEnvelope] -type cloudforceOneRequestPriorityGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestPriorityGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestPriorityGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// cloudforceOneRequestPriorityGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [CloudforceOneRequestPriorityGetResponseEnvelopeErrors] -type cloudforceOneRequestPriorityGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestPriorityGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestPriorityGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// cloudforceOneRequestPriorityGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [CloudforceOneRequestPriorityGetResponseEnvelopeMessages] -type cloudforceOneRequestPriorityGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CloudforceOneRequestPriorityGetResponseEnvelopeSuccess bool - -const ( - CloudforceOneRequestPriorityGetResponseEnvelopeSuccessTrue CloudforceOneRequestPriorityGetResponseEnvelopeSuccess = true -) - -type CloudforceOneRequestPriorityQuotaResponseEnvelope struct { - Errors []CloudforceOneRequestPriorityQuotaResponseEnvelopeErrors `json:"errors,required"` - Messages []CloudforceOneRequestPriorityQuotaResponseEnvelopeMessages `json:"messages,required"` - Result CloudforceOneRequestPriorityQuotaResponse `json:"result,required"` - // Whether the API call was successful - Success CloudforceOneRequestPriorityQuotaResponseEnvelopeSuccess `json:"success,required"` - JSON cloudforceOneRequestPriorityQuotaResponseEnvelopeJSON `json:"-"` -} - -// cloudforceOneRequestPriorityQuotaResponseEnvelopeJSON contains the JSON metadata -// for the struct [CloudforceOneRequestPriorityQuotaResponseEnvelope] -type cloudforceOneRequestPriorityQuotaResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityQuotaResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityQuotaResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestPriorityQuotaResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestPriorityQuotaResponseEnvelopeErrorsJSON `json:"-"` -} - -// cloudforceOneRequestPriorityQuotaResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [CloudforceOneRequestPriorityQuotaResponseEnvelopeErrors] -type cloudforceOneRequestPriorityQuotaResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityQuotaResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityQuotaResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CloudforceOneRequestPriorityQuotaResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON cloudforceOneRequestPriorityQuotaResponseEnvelopeMessagesJSON `json:"-"` -} - -// cloudforceOneRequestPriorityQuotaResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [CloudforceOneRequestPriorityQuotaResponseEnvelopeMessages] -type cloudforceOneRequestPriorityQuotaResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CloudforceOneRequestPriorityQuotaResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r cloudforceOneRequestPriorityQuotaResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CloudforceOneRequestPriorityQuotaResponseEnvelopeSuccess bool - -const ( - CloudforceOneRequestPriorityQuotaResponseEnvelopeSuccessTrue CloudforceOneRequestPriorityQuotaResponseEnvelopeSuccess = true -) diff --git a/cloudforceonerequestpriority_test.go b/cloudforceonerequestpriority_test.go deleted file mode 100644 index 77a49c2d7bc..00000000000 --- a/cloudforceonerequestpriority_test.go +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestCloudforceOneRequestPriorityNew(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("user@example.com"), - ) - _, err := client.CloudforceOne.Requests.Priority.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.CloudforceOneRequestPriorityNewParams{ - Labels: cloudflare.F([]string{"DoS", "CVE"}), - Priority: cloudflare.F(int64(1)), - Requirement: cloudflare.F("DoS attacks carried out by CVEs"), - Tlp: cloudflare.F(cloudflare.CloudforceOneRequestPriorityNewParamsTlpClear), - }, - ) - 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 TestCloudforceOneRequestPriorityUpdate(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("user@example.com"), - ) - _, err := client.CloudforceOne.Requests.Priority.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.CloudforceOneRequestPriorityUpdateParams{ - Labels: cloudflare.F([]string{"DoS", "CVE"}), - Priority: cloudflare.F(int64(1)), - Requirement: cloudflare.F("DoS attacks carried out by CVEs"), - Tlp: cloudflare.F(cloudflare.CloudforceOneRequestPriorityUpdateParamsTlpClear), - }, - ) - 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 TestCloudforceOneRequestPriorityDelete(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("user@example.com"), - ) - _, err := client.CloudforceOne.Requests.Priority.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - 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 TestCloudforceOneRequestPriorityGet(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("user@example.com"), - ) - _, err := client.CloudforceOne.Requests.Priority.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - 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 TestCloudforceOneRequestPriorityQuota(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("user@example.com"), - ) - _, err := client.CloudforceOne.Requests.Priority.Quota(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/custom_certificates/aliases.go b/custom_certificates/aliases.go new file mode 100644 index 00000000000..7eda3217bb7 --- /dev/null +++ b/custom_certificates/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package custom_certificates + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/customcertificate.go b/custom_certificates/customcertificate.go similarity index 83% rename from customcertificate.go rename to custom_certificates/customcertificate.go index e082658579d..689a774059e 100644 --- a/customcertificate.go +++ b/custom_certificates/customcertificate.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package custom_certificates import ( "context" @@ -15,6 +15,7 @@ import ( "github.com/cloudflare/cloudflare-go/internal/param" "github.com/cloudflare/cloudflare-go/internal/requestconfig" "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/keyless_certificates" "github.com/cloudflare/cloudflare-go/option" "github.com/tidwall/gjson" ) @@ -26,7 +27,7 @@ import ( // instead. type CustomCertificateService struct { Options []option.RequestOption - Prioritize *CustomCertificatePrioritizeService + Prioritize *PrioritizeService } // NewCustomCertificateService generates a new service that applies the given @@ -35,7 +36,7 @@ type CustomCertificateService struct { func NewCustomCertificateService(opts ...option.RequestOption) (r *CustomCertificateService) { r = &CustomCertificateService{} r.Options = opts - r.Prioritize = NewCustomCertificatePrioritizeService(opts...) + r.Prioritize = NewPrioritizeService(opts...) return } @@ -55,7 +56,7 @@ func (r *CustomCertificateService) New(ctx context.Context, params CustomCertifi // List, search, and filter all of your custom SSL certificates. The higher // priority will break ties across overlapping 'legacy_custom' certificates, but // 'legacy_custom' certificates will always supercede 'sni_custom' certificates. -func (r *CustomCertificateService) List(ctx context.Context, params CustomCertificateListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[CustomCertificateListResponse], err error) { +func (r *CustomCertificateService) List(ctx context.Context, params CustomCertificateListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[TLSCertificatesAndHostnamesCustomCertificate], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -75,7 +76,7 @@ func (r *CustomCertificateService) List(ctx context.Context, params CustomCertif // List, search, and filter all of your custom SSL certificates. The higher // priority will break ties across overlapping 'legacy_custom' certificates, but // 'legacy_custom' certificates will always supercede 'sni_custom' certificates. -func (r *CustomCertificateService) ListAutoPaging(ctx context.Context, params CustomCertificateListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[CustomCertificateListResponse] { +func (r *CustomCertificateService) ListAutoPaging(ctx context.Context, params CustomCertificateListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[TLSCertificatesAndHostnamesCustomCertificate] { return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) } @@ -120,31 +121,14 @@ func (r *CustomCertificateService) Get(ctx context.Context, customCertificateID return } -// Union satisfied by [CustomCertificateNewResponseUnknown] or -// [shared.UnionString]. -type CustomCertificateNewResponse interface { - ImplementsCustomCertificateNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*CustomCertificateNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type CustomCertificateListResponse struct { +type TLSCertificatesAndHostnamesCustomCertificate struct { // Identifier ID string `json:"id,required"` // A ubiquitous bundle has the highest probability of being verified everywhere, // even by clients using outdated or unusual trust stores. An optimal bundle uses // the shortest chain and newest intermediates. And the force bundle verifies the // chain, but does not otherwise modify it. - BundleMethod CustomCertificateListResponseBundleMethod `json:"bundle_method,required"` + BundleMethod TLSCertificatesAndHostnamesCustomCertificateBundleMethod `json:"bundle_method,required"` // When the certificate from the authority expires. ExpiresOn time.Time `json:"expires_on,required" format:"date-time"` Hosts []string `json:"hosts,required"` @@ -160,7 +144,7 @@ type CustomCertificateListResponse struct { // The type of hash used for the certificate. Signature string `json:"signature,required"` // Status of the zone's custom SSL. - Status CustomCertificateListResponseStatus `json:"status,required"` + Status TLSCertificatesAndHostnamesCustomCertificateStatus `json:"status,required"` // When the certificate was uploaded to Cloudflare. UploadedOn time.Time `json:"uploaded_on,required" format:"date-time"` // Identifier @@ -172,8 +156,8 @@ type CustomCertificateListResponse struct { // only to U.S. data centers, only to E.U. data centers, or only to highest // security data centers. Default distribution is to all Cloudflare datacenters, // for optimal performance. - GeoRestrictions CustomCertificateListResponseGeoRestrictions `json:"geo_restrictions"` - KeylessServer CustomCertificateListResponseKeylessServer `json:"keyless_server"` + GeoRestrictions TLSCertificatesAndHostnamesCustomCertificateGeoRestrictions `json:"geo_restrictions"` + KeylessServer keyless_certificates.TLSCertificatesAndHostnamesBase `json:"keyless_server"` // Specify the policy that determines the region where your private key will be // held locally. HTTPS connections to any excluded data center will still be fully // encrypted, but will incur some latency while Keyless SSL is used to complete the @@ -183,13 +167,13 @@ type CustomCertificateListResponse struct { // can be chosen, such as 'country: IN', as well as 'region: EU' which refers to // the EU region. If there are too few data centers satisfying the policy, it will // be rejected. - Policy string `json:"policy"` - JSON customCertificateListResponseJSON `json:"-"` + Policy string `json:"policy"` + JSON tlsCertificatesAndHostnamesCustomCertificateJSON `json:"-"` } -// customCertificateListResponseJSON contains the JSON metadata for the struct -// [CustomCertificateListResponse] -type customCertificateListResponseJSON struct { +// tlsCertificatesAndHostnamesCustomCertificateJSON contains the JSON metadata for +// the struct [TLSCertificatesAndHostnamesCustomCertificate] +type tlsCertificatesAndHostnamesCustomCertificateJSON struct { ID apijson.Field BundleMethod apijson.Field ExpiresOn apijson.Field @@ -208,11 +192,11 @@ type customCertificateListResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *CustomCertificateListResponse) UnmarshalJSON(data []byte) (err error) { +func (r *TLSCertificatesAndHostnamesCustomCertificate) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r customCertificateListResponseJSON) RawJSON() string { +func (r tlsCertificatesAndHostnamesCustomCertificateJSON) RawJSON() string { return r.raw } @@ -220,23 +204,23 @@ func (r customCertificateListResponseJSON) RawJSON() string { // even by clients using outdated or unusual trust stores. An optimal bundle uses // the shortest chain and newest intermediates. And the force bundle verifies the // chain, but does not otherwise modify it. -type CustomCertificateListResponseBundleMethod string +type TLSCertificatesAndHostnamesCustomCertificateBundleMethod string const ( - CustomCertificateListResponseBundleMethodUbiquitous CustomCertificateListResponseBundleMethod = "ubiquitous" - CustomCertificateListResponseBundleMethodOptimal CustomCertificateListResponseBundleMethod = "optimal" - CustomCertificateListResponseBundleMethodForce CustomCertificateListResponseBundleMethod = "force" + TLSCertificatesAndHostnamesCustomCertificateBundleMethodUbiquitous TLSCertificatesAndHostnamesCustomCertificateBundleMethod = "ubiquitous" + TLSCertificatesAndHostnamesCustomCertificateBundleMethodOptimal TLSCertificatesAndHostnamesCustomCertificateBundleMethod = "optimal" + TLSCertificatesAndHostnamesCustomCertificateBundleMethodForce TLSCertificatesAndHostnamesCustomCertificateBundleMethod = "force" ) // Status of the zone's custom SSL. -type CustomCertificateListResponseStatus string +type TLSCertificatesAndHostnamesCustomCertificateStatus string const ( - CustomCertificateListResponseStatusActive CustomCertificateListResponseStatus = "active" - CustomCertificateListResponseStatusExpired CustomCertificateListResponseStatus = "expired" - CustomCertificateListResponseStatusDeleted CustomCertificateListResponseStatus = "deleted" - CustomCertificateListResponseStatusPending CustomCertificateListResponseStatus = "pending" - CustomCertificateListResponseStatusInitializing CustomCertificateListResponseStatus = "initializing" + TLSCertificatesAndHostnamesCustomCertificateStatusActive TLSCertificatesAndHostnamesCustomCertificateStatus = "active" + TLSCertificatesAndHostnamesCustomCertificateStatusExpired TLSCertificatesAndHostnamesCustomCertificateStatus = "expired" + TLSCertificatesAndHostnamesCustomCertificateStatusDeleted TLSCertificatesAndHostnamesCustomCertificateStatus = "deleted" + TLSCertificatesAndHostnamesCustomCertificateStatusPending TLSCertificatesAndHostnamesCustomCertificateStatus = "pending" + TLSCertificatesAndHostnamesCustomCertificateStatusInitializing TLSCertificatesAndHostnamesCustomCertificateStatus = "initializing" ) // Specify the region where your private key can be held locally for optimal TLS @@ -246,118 +230,51 @@ const ( // only to U.S. data centers, only to E.U. data centers, or only to highest // security data centers. Default distribution is to all Cloudflare datacenters, // for optimal performance. -type CustomCertificateListResponseGeoRestrictions struct { - Label CustomCertificateListResponseGeoRestrictionsLabel `json:"label"` - JSON customCertificateListResponseGeoRestrictionsJSON `json:"-"` +type TLSCertificatesAndHostnamesCustomCertificateGeoRestrictions struct { + Label TLSCertificatesAndHostnamesCustomCertificateGeoRestrictionsLabel `json:"label"` + JSON tlsCertificatesAndHostnamesCustomCertificateGeoRestrictionsJSON `json:"-"` } -// customCertificateListResponseGeoRestrictionsJSON contains the JSON metadata for -// the struct [CustomCertificateListResponseGeoRestrictions] -type customCertificateListResponseGeoRestrictionsJSON struct { +// tlsCertificatesAndHostnamesCustomCertificateGeoRestrictionsJSON contains the +// JSON metadata for the struct +// [TLSCertificatesAndHostnamesCustomCertificateGeoRestrictions] +type tlsCertificatesAndHostnamesCustomCertificateGeoRestrictionsJSON struct { Label apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *CustomCertificateListResponseGeoRestrictions) UnmarshalJSON(data []byte) (err error) { +func (r *TLSCertificatesAndHostnamesCustomCertificateGeoRestrictions) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r customCertificateListResponseGeoRestrictionsJSON) RawJSON() string { +func (r tlsCertificatesAndHostnamesCustomCertificateGeoRestrictionsJSON) RawJSON() string { return r.raw } -type CustomCertificateListResponseGeoRestrictionsLabel string +type TLSCertificatesAndHostnamesCustomCertificateGeoRestrictionsLabel string const ( - CustomCertificateListResponseGeoRestrictionsLabelUs CustomCertificateListResponseGeoRestrictionsLabel = "us" - CustomCertificateListResponseGeoRestrictionsLabelEu CustomCertificateListResponseGeoRestrictionsLabel = "eu" - CustomCertificateListResponseGeoRestrictionsLabelHighestSecurity CustomCertificateListResponseGeoRestrictionsLabel = "highest_security" + TLSCertificatesAndHostnamesCustomCertificateGeoRestrictionsLabelUs TLSCertificatesAndHostnamesCustomCertificateGeoRestrictionsLabel = "us" + TLSCertificatesAndHostnamesCustomCertificateGeoRestrictionsLabelEu TLSCertificatesAndHostnamesCustomCertificateGeoRestrictionsLabel = "eu" + TLSCertificatesAndHostnamesCustomCertificateGeoRestrictionsLabelHighestSecurity TLSCertificatesAndHostnamesCustomCertificateGeoRestrictionsLabel = "highest_security" ) -type CustomCertificateListResponseKeylessServer struct { - // Keyless certificate identifier tag. - ID string `json:"id,required"` - // When the Keyless SSL was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - // Whether or not the Keyless SSL is on or off. - Enabled bool `json:"enabled,required"` - // The keyless SSL name. - Host string `json:"host,required" format:"hostname"` - // When the Keyless SSL was last modified. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // The keyless SSL name. - Name string `json:"name,required"` - // Available permissions for the Keyless SSL for the current user requesting the - // item. - Permissions []interface{} `json:"permissions,required"` - // The keyless SSL port used to communicate between Cloudflare and the client's - // Keyless SSL server. - Port float64 `json:"port,required"` - // Status of the Keyless SSL. - Status CustomCertificateListResponseKeylessServerStatus `json:"status,required"` - // Configuration for using Keyless SSL through a Cloudflare Tunnel - Tunnel CustomCertificateListResponseKeylessServerTunnel `json:"tunnel"` - JSON customCertificateListResponseKeylessServerJSON `json:"-"` -} - -// customCertificateListResponseKeylessServerJSON contains the JSON metadata for -// the struct [CustomCertificateListResponseKeylessServer] -type customCertificateListResponseKeylessServerJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Enabled apijson.Field - Host apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Permissions apijson.Field - Port apijson.Field - Status apijson.Field - Tunnel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomCertificateListResponseKeylessServer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customCertificateListResponseKeylessServerJSON) RawJSON() string { - return r.raw -} - -// Status of the Keyless SSL. -type CustomCertificateListResponseKeylessServerStatus string - -const ( - CustomCertificateListResponseKeylessServerStatusActive CustomCertificateListResponseKeylessServerStatus = "active" - CustomCertificateListResponseKeylessServerStatusDeleted CustomCertificateListResponseKeylessServerStatus = "deleted" -) - -// Configuration for using Keyless SSL through a Cloudflare Tunnel -type CustomCertificateListResponseKeylessServerTunnel struct { - // Private IP of the Key Server Host - PrivateIP string `json:"private_ip,required"` - // Cloudflare Tunnel Virtual Network ID - VnetID string `json:"vnet_id,required"` - JSON customCertificateListResponseKeylessServerTunnelJSON `json:"-"` -} - -// customCertificateListResponseKeylessServerTunnelJSON contains the JSON metadata -// for the struct [CustomCertificateListResponseKeylessServerTunnel] -type customCertificateListResponseKeylessServerTunnelJSON struct { - PrivateIP apijson.Field - VnetID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomCertificateListResponseKeylessServerTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// Union satisfied by [custom_certificates.CustomCertificateNewResponseUnknown] or +// [shared.UnionString]. +type CustomCertificateNewResponse interface { + ImplementsCustomCertificatesCustomCertificateNewResponse() } -func (r customCertificateListResponseKeylessServerTunnelJSON) RawJSON() string { - return r.raw +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*CustomCertificateNewResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) } type CustomCertificateDeleteResponse struct { @@ -382,10 +299,10 @@ func (r customCertificateDeleteResponseJSON) RawJSON() string { return r.raw } -// Union satisfied by [CustomCertificateEditResponseUnknown] or +// Union satisfied by [custom_certificates.CustomCertificateEditResponseUnknown] or // [shared.UnionString]. type CustomCertificateEditResponse interface { - ImplementsCustomCertificateEditResponse() + ImplementsCustomCertificatesCustomCertificateEditResponse() } func init() { @@ -399,10 +316,10 @@ func init() { ) } -// Union satisfied by [CustomCertificateGetResponseUnknown] or +// Union satisfied by [custom_certificates.CustomCertificateGetResponseUnknown] or // [shared.UnionString]. type CustomCertificateGetResponse interface { - ImplementsCustomCertificateGetResponse() + ImplementsCustomCertificatesCustomCertificateGetResponse() } func init() { diff --git a/customcertificate_test.go b/custom_certificates/customcertificate_test.go similarity index 89% rename from customcertificate_test.go rename to custom_certificates/customcertificate_test.go index 3685d5868d1..2bd7333280d 100644 --- a/customcertificate_test.go +++ b/custom_certificates/customcertificate_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package custom_certificates_test import ( "context" @@ -9,6 +9,7 @@ import ( "testing" "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/custom_certificates" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" ) @@ -27,16 +28,16 @@ func TestCustomCertificateNewWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.CustomCertificates.New(context.TODO(), cloudflare.CustomCertificateNewParams{ + _, err := client.CustomCertificates.New(context.TODO(), custom_certificates.CustomCertificateNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Certificate: cloudflare.F("-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIJAMHAwfXZ5/PWMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\nBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX\naWRnaXRzIFB0eSBMdGQwHhcNMTYwODI0MTY0MzAxWhcNMTYxMTIyMTY0MzAxWjBF\nMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50\nZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\nCgKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmGdtcGbg/1\nCGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKnabIRuGvB\nKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpidtnKX/a+5\n0GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+pyFxIXjbEI\ndZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pEewooaeO2\nizNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABo4GnMIGkMB0GA1UdDgQWBBT/LbE4\n9rWf288N6sJA5BRb6FJIGDB1BgNVHSMEbjBsgBT/LbE49rWf288N6sJA5BRb6FJI\nGKFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNV\nBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAMHAwfXZ5/PWMAwGA1UdEwQF\nMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAHHFwl0tH0quUYZYO0dZYt4R7SJ0pCm2\n2satiyzHl4OnXcHDpekAo7/a09c6Lz6AU83cKy/+x3/djYHXWba7HpEu0dR3ugQP\nMlr4zrhd9xKZ0KZKiYmtJH+ak4OM4L3FbT0owUZPyjLSlhMtJVcoRp5CJsjAMBUG\nSvD8RX+T01wzox/Qb+lnnNnOlaWpqu8eoOenybxKp1a9ULzIVvN/LAcc+14vioFq\n2swRWtmocBAs8QR9n4uvbpiYvS8eYueDCWMM4fvFfBhaDZ3N9IbtySh3SpFdQDhw\nYbjM2rxXiyLGxB4Bol7QTv4zHif7Zt89FReT/NBy4rzaskDJY5L6xmY=\n-----END CERTIFICATE-----\n"), PrivateKey: cloudflare.F("-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmG\ndtcGbg/1CGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKn\nabIRuGvBKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpid\ntnKX/a+50GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+py\nFxIXjbEIdZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pE\newooaeO2izNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABAoIBACbhTYXBZYKmYPCb\nHBR1IBlCQA2nLGf0qRuJNJZg5iEzXows/6tc8YymZkQE7nolapWsQ+upk2y5Xdp/\naxiuprIs9JzkYK8Ox0r+dlwCG1kSW+UAbX0bQ/qUqlsTvU6muVuMP8vZYHxJ3wmb\n+ufRBKztPTQ/rYWaYQcgC0RWI20HTFBMxlTAyNxYNWzX7RKFkGVVyB9RsAtmcc8g\n+j4OdosbfNoJPS0HeIfNpAznDfHKdxDk2Yc1tV6RHBrC1ynyLE9+TaflIAdo2MVv\nKLMLq51GqYKtgJFIlBRPQqKoyXdz3fGvXrTkf/WY9QNq0J1Vk5ERePZ54mN8iZB7\n9lwy/AkCgYEA6FXzosxswaJ2wQLeoYc7ceaweX/SwTvxHgXzRyJIIT0eJWgx13Wo\n/WA3Iziimsjf6qE+SI/8laxPp2A86VMaIt3Z3mJN/CqSVGw8LK2AQst+OwdPyDMu\niacE8lj/IFGC8mwNUAb9CzGU3JpU4PxxGFjS/eMtGeRXCWkK4NE+G08CgYEA1Kp9\nN2JrVlqUz+gAX+LPmE9OEMAS9WQSQsfCHGogIFDGGcNf7+uwBM7GAaSJIP01zcoe\nVAgWdzXCv3FLhsaZoJ6RyLOLay5phbu1iaTr4UNYm5WtYTzMzqh8l1+MFFDl9xDB\nvULuCIIrglM5MeS/qnSg1uMoH2oVPj9TVst/ir8CgYEAxrI7Ws9Zc4Bt70N1As+U\nlySjaEVZCMkqvHJ6TCuVZFfQoE0r0whdLdRLU2PsLFP+q7qaeZQqgBaNSKeVcDYR\n9B+nY/jOmQoPewPVsp/vQTCnE/R81spu0mp0YI6cIheT1Z9zAy322svcc43JaWB7\nmEbeqyLOP4Z4qSOcmghZBSECgYACvR9Xs0DGn+wCsW4vze/2ei77MD4OQvepPIFX\ndFZtlBy5ADcgE9z0cuVB6CiL8DbdK5kwY9pGNr8HUCI03iHkW6Zs+0L0YmihfEVe\nPG19PSzK9CaDdhD9KFZSbLyVFmWfxOt50H7YRTTiPMgjyFpfi5j2q348yVT0tEQS\nfhRqaQKBgAcWPokmJ7EbYQGeMbS7HC8eWO/RyamlnSffdCdSc7ue3zdVJxpAkQ8W\nqu80pEIF6raIQfAf8MXiiZ7auFOSnHQTXUbhCpvDLKi0Mwq3G8Pl07l+2s6dQG6T\nlv6XTQaMyf6n1yjzL+fzDrH3qXMxHMO/b13EePXpDMpY7HQpoLDi\n-----END RSA PRIVATE KEY-----\n"), - BundleMethod: cloudflare.F(cloudflare.CustomCertificateNewParamsBundleMethodUbiquitous), - GeoRestrictions: cloudflare.F(cloudflare.CustomCertificateNewParamsGeoRestrictions{ - Label: cloudflare.F(cloudflare.CustomCertificateNewParamsGeoRestrictionsLabelUs), + BundleMethod: cloudflare.F(custom_certificates.CustomCertificateNewParamsBundleMethodUbiquitous), + GeoRestrictions: cloudflare.F(custom_certificates.CustomCertificateNewParamsGeoRestrictions{ + Label: cloudflare.F(custom_certificates.CustomCertificateNewParamsGeoRestrictionsLabelUs), }), Policy: cloudflare.F("(country: US) or (region: EU)"), - Type: cloudflare.F(cloudflare.CustomCertificateNewParamsTypeSniCustom), + Type: cloudflare.F(custom_certificates.CustomCertificateNewParamsTypeSniCustom), }) if err != nil { var apierr *cloudflare.Error @@ -61,9 +62,9 @@ func TestCustomCertificateListWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.CustomCertificates.List(context.TODO(), cloudflare.CustomCertificateListParams{ + _, err := client.CustomCertificates.List(context.TODO(), custom_certificates.CustomCertificateListParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Match: cloudflare.F(cloudflare.CustomCertificateListParamsMatchAny), + Match: cloudflare.F(custom_certificates.CustomCertificateListParamsMatchAny), Page: cloudflare.F(1.000000), PerPage: cloudflare.F(5.000000), }) @@ -93,7 +94,7 @@ func TestCustomCertificateDelete(t *testing.T) { _, err := client.CustomCertificates.Delete( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.CustomCertificateDeleteParams{ + custom_certificates.CustomCertificateDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) @@ -123,12 +124,12 @@ func TestCustomCertificateEditWithOptionalParams(t *testing.T) { _, err := client.CustomCertificates.Edit( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.CustomCertificateEditParams{ + custom_certificates.CustomCertificateEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - BundleMethod: cloudflare.F(cloudflare.CustomCertificateEditParamsBundleMethodUbiquitous), + BundleMethod: cloudflare.F(custom_certificates.CustomCertificateEditParamsBundleMethodUbiquitous), Certificate: cloudflare.F("-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIJAMHAwfXZ5/PWMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\nBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX\naWRnaXRzIFB0eSBMdGQwHhcNMTYwODI0MTY0MzAxWhcNMTYxMTIyMTY0MzAxWjBF\nMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50\nZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\nCgKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmGdtcGbg/1\nCGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKnabIRuGvB\nKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpidtnKX/a+5\n0GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+pyFxIXjbEI\ndZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pEewooaeO2\nizNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABo4GnMIGkMB0GA1UdDgQWBBT/LbE4\n9rWf288N6sJA5BRb6FJIGDB1BgNVHSMEbjBsgBT/LbE49rWf288N6sJA5BRb6FJI\nGKFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNV\nBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAMHAwfXZ5/PWMAwGA1UdEwQF\nMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAHHFwl0tH0quUYZYO0dZYt4R7SJ0pCm2\n2satiyzHl4OnXcHDpekAo7/a09c6Lz6AU83cKy/+x3/djYHXWba7HpEu0dR3ugQP\nMlr4zrhd9xKZ0KZKiYmtJH+ak4OM4L3FbT0owUZPyjLSlhMtJVcoRp5CJsjAMBUG\nSvD8RX+T01wzox/Qb+lnnNnOlaWpqu8eoOenybxKp1a9ULzIVvN/LAcc+14vioFq\n2swRWtmocBAs8QR9n4uvbpiYvS8eYueDCWMM4fvFfBhaDZ3N9IbtySh3SpFdQDhw\nYbjM2rxXiyLGxB4Bol7QTv4zHif7Zt89FReT/NBy4rzaskDJY5L6xmY=\n-----END CERTIFICATE-----\n"), - GeoRestrictions: cloudflare.F(cloudflare.CustomCertificateEditParamsGeoRestrictions{ - Label: cloudflare.F(cloudflare.CustomCertificateEditParamsGeoRestrictionsLabelUs), + GeoRestrictions: cloudflare.F(custom_certificates.CustomCertificateEditParamsGeoRestrictions{ + Label: cloudflare.F(custom_certificates.CustomCertificateEditParamsGeoRestrictionsLabelUs), }), Policy: cloudflare.F("(country: US) or (region: EU)"), PrivateKey: cloudflare.F("-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmG\ndtcGbg/1CGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKn\nabIRuGvBKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpid\ntnKX/a+50GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+py\nFxIXjbEIdZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pE\newooaeO2izNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABAoIBACbhTYXBZYKmYPCb\nHBR1IBlCQA2nLGf0qRuJNJZg5iEzXows/6tc8YymZkQE7nolapWsQ+upk2y5Xdp/\naxiuprIs9JzkYK8Ox0r+dlwCG1kSW+UAbX0bQ/qUqlsTvU6muVuMP8vZYHxJ3wmb\n+ufRBKztPTQ/rYWaYQcgC0RWI20HTFBMxlTAyNxYNWzX7RKFkGVVyB9RsAtmcc8g\n+j4OdosbfNoJPS0HeIfNpAznDfHKdxDk2Yc1tV6RHBrC1ynyLE9+TaflIAdo2MVv\nKLMLq51GqYKtgJFIlBRPQqKoyXdz3fGvXrTkf/WY9QNq0J1Vk5ERePZ54mN8iZB7\n9lwy/AkCgYEA6FXzosxswaJ2wQLeoYc7ceaweX/SwTvxHgXzRyJIIT0eJWgx13Wo\n/WA3Iziimsjf6qE+SI/8laxPp2A86VMaIt3Z3mJN/CqSVGw8LK2AQst+OwdPyDMu\niacE8lj/IFGC8mwNUAb9CzGU3JpU4PxxGFjS/eMtGeRXCWkK4NE+G08CgYEA1Kp9\nN2JrVlqUz+gAX+LPmE9OEMAS9WQSQsfCHGogIFDGGcNf7+uwBM7GAaSJIP01zcoe\nVAgWdzXCv3FLhsaZoJ6RyLOLay5phbu1iaTr4UNYm5WtYTzMzqh8l1+MFFDl9xDB\nvULuCIIrglM5MeS/qnSg1uMoH2oVPj9TVst/ir8CgYEAxrI7Ws9Zc4Bt70N1As+U\nlySjaEVZCMkqvHJ6TCuVZFfQoE0r0whdLdRLU2PsLFP+q7qaeZQqgBaNSKeVcDYR\n9B+nY/jOmQoPewPVsp/vQTCnE/R81spu0mp0YI6cIheT1Z9zAy322svcc43JaWB7\nmEbeqyLOP4Z4qSOcmghZBSECgYACvR9Xs0DGn+wCsW4vze/2ei77MD4OQvepPIFX\ndFZtlBy5ADcgE9z0cuVB6CiL8DbdK5kwY9pGNr8HUCI03iHkW6Zs+0L0YmihfEVe\nPG19PSzK9CaDdhD9KFZSbLyVFmWfxOt50H7YRTTiPMgjyFpfi5j2q348yVT0tEQS\nfhRqaQKBgAcWPokmJ7EbYQGeMbS7HC8eWO/RyamlnSffdCdSc7ue3zdVJxpAkQ8W\nqu80pEIF6raIQfAf8MXiiZ7auFOSnHQTXUbhCpvDLKi0Mwq3G8Pl07l+2s6dQG6T\nlv6XTQaMyf6n1yjzL+fzDrH3qXMxHMO/b13EePXpDMpY7HQpoLDi\n-----END RSA PRIVATE KEY-----\n"), @@ -160,7 +161,7 @@ func TestCustomCertificateGet(t *testing.T) { _, err := client.CustomCertificates.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.CustomCertificateGetParams{ + custom_certificates.CustomCertificateGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) diff --git a/custom_certificates/prioritize.go b/custom_certificates/prioritize.go new file mode 100644 index 00000000000..85652da78cf --- /dev/null +++ b/custom_certificates/prioritize.go @@ -0,0 +1,183 @@ +// File generated from our OpenAPI spec by Stainless. + +package custom_certificates + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// PrioritizeService 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 [NewPrioritizeService] method instead. +type PrioritizeService struct { + Options []option.RequestOption +} + +// NewPrioritizeService 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 NewPrioritizeService(opts ...option.RequestOption) (r *PrioritizeService) { + r = &PrioritizeService{} + r.Options = opts + return +} + +// If a zone has multiple SSL certificates, you can set the order in which they +// should be used during a request. The higher priority will break ties across +// overlapping 'legacy_custom' certificates. +func (r *PrioritizeService) Update(ctx context.Context, params PrioritizeUpdateParams, opts ...option.RequestOption) (res *[]TLSCertificatesAndHostnamesCustomCertificate, err error) { + opts = append(r.Options[:], opts...) + var env PrioritizeUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/custom_certificates/prioritize", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type PrioritizeUpdateParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Array of ordered certificates. + Certificates param.Field[[]PrioritizeUpdateParamsCertificate] `json:"certificates,required"` +} + +func (r PrioritizeUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type PrioritizeUpdateParamsCertificate struct { + // The order/priority in which the certificate will be used in a request. The + // higher priority will break ties across overlapping 'legacy_custom' certificates, + // but 'legacy_custom' certificates will always supercede 'sni_custom' + // certificates. + Priority param.Field[float64] `json:"priority"` +} + +func (r PrioritizeUpdateParamsCertificate) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type PrioritizeUpdateResponseEnvelope struct { + Errors []PrioritizeUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []PrioritizeUpdateResponseEnvelopeMessages `json:"messages,required"` + Result []TLSCertificatesAndHostnamesCustomCertificate `json:"result,required,nullable"` + // Whether the API call was successful + Success PrioritizeUpdateResponseEnvelopeSuccess `json:"success,required"` + ResultInfo PrioritizeUpdateResponseEnvelopeResultInfo `json:"result_info"` + JSON prioritizeUpdateResponseEnvelopeJSON `json:"-"` +} + +// prioritizeUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [PrioritizeUpdateResponseEnvelope] +type prioritizeUpdateResponseEnvelopeJSON 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 *PrioritizeUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prioritizeUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PrioritizeUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prioritizeUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// prioritizeUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [PrioritizeUpdateResponseEnvelopeErrors] +type prioritizeUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrioritizeUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prioritizeUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PrioritizeUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON prioritizeUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// prioritizeUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [PrioritizeUpdateResponseEnvelopeMessages] +type prioritizeUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrioritizeUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prioritizeUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PrioritizeUpdateResponseEnvelopeSuccess bool + +const ( + PrioritizeUpdateResponseEnvelopeSuccessTrue PrioritizeUpdateResponseEnvelopeSuccess = true +) + +type PrioritizeUpdateResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON prioritizeUpdateResponseEnvelopeResultInfoJSON `json:"-"` +} + +// prioritizeUpdateResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [PrioritizeUpdateResponseEnvelopeResultInfo] +type prioritizeUpdateResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PrioritizeUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r prioritizeUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/custom_certificates/prioritize_test.go b/custom_certificates/prioritize_test.go new file mode 100644 index 00000000000..14bf6ea4b72 --- /dev/null +++ b/custom_certificates/prioritize_test.go @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package custom_certificates_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/custom_certificates" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestPrioritizeUpdate(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("user@example.com"), + ) + _, err := client.CustomCertificates.Prioritize.Update(context.TODO(), custom_certificates.PrioritizeUpdateParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Certificates: cloudflare.F([]custom_certificates.PrioritizeUpdateParamsCertificate{{ + Priority: cloudflare.F(2.000000), + }, { + Priority: cloudflare.F(1.000000), + }}), + }) + 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/custom_hostnames/aliases.go b/custom_hostnames/aliases.go new file mode 100644 index 00000000000..6737125279a --- /dev/null +++ b/custom_hostnames/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package custom_hostnames + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/customhostname.go b/custom_hostnames/customhostname.go similarity index 99% rename from customhostname.go rename to custom_hostnames/customhostname.go index 0f8e7c71b4e..528629dbd36 100644 --- a/customhostname.go +++ b/custom_hostnames/customhostname.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package custom_hostnames import ( "context" @@ -24,7 +24,7 @@ import ( // instead. type CustomHostnameService struct { Options []option.RequestOption - FallbackOrigin *CustomHostnameFallbackOriginService + FallbackOrigin *FallbackOriginService } // NewCustomHostnameService generates a new service that applies the given options @@ -33,7 +33,7 @@ type CustomHostnameService struct { func NewCustomHostnameService(opts ...option.RequestOption) (r *CustomHostnameService) { r = &CustomHostnameService{} r.Options = opts - r.FallbackOrigin = NewCustomHostnameFallbackOriginService(opts...) + r.FallbackOrigin = NewFallbackOriginService(opts...) return } diff --git a/customhostname_test.go b/custom_hostnames/customhostname_test.go similarity index 76% rename from customhostname_test.go rename to custom_hostnames/customhostname_test.go index 61fdec517c7..729c54bb9c9 100644 --- a/customhostname_test.go +++ b/custom_hostnames/customhostname_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package custom_hostnames_test import ( "context" @@ -9,6 +9,7 @@ import ( "testing" "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/custom_hostnames" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" ) @@ -27,26 +28,26 @@ func TestCustomHostnameNewWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.CustomHostnames.New(context.TODO(), cloudflare.CustomHostnameNewParams{ + _, err := client.CustomHostnames.New(context.TODO(), custom_hostnames.CustomHostnameNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Hostname: cloudflare.F("app.example.com"), - SSL: cloudflare.F(cloudflare.CustomHostnameNewParamsSSL{ - BundleMethod: cloudflare.F(cloudflare.CustomHostnameNewParamsSSLBundleMethodUbiquitous), - CertificateAuthority: cloudflare.F(cloudflare.CustomHostnameNewParamsSSLCertificateAuthorityGoogle), + SSL: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSL{ + BundleMethod: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLBundleMethodUbiquitous), + CertificateAuthority: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLCertificateAuthorityGoogle), CustomCertificate: cloudflare.F("-----BEGIN CERTIFICATE-----\\nMIIFJDCCBAygAwIBAgIQD0ifmj/Yi5NP/2gdUySbfzANBgkqhkiG9w0BAQsFADBN\\nMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMScwJQYDVQQDEx5E...SzSHfXp5lnu/3V08I72q1QNzOCgY1XeL4GKVcj4or6cT6tX6oJH7ePPmfrBfqI/O\\nOeH8gMJ+FuwtXYEPa4hBf38M5eU5xWG7\\n-----END CERTIFICATE-----\\n"), CustomKey: cloudflare.F("-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmG\ndtcGbg/1CGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKn\nabIRuGvBKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpid\ntnKX/a+50GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+py\nFxIXjbEIdZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pE\newooaeO2izNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABAoIBACbhTYXBZYKmYPCb\nHBR1IBlCQA2nLGf0qRuJNJZg5iEzXows/6tc8YymZkQE7nolapWsQ+upk2y5Xdp/\naxiuprIs9JzkYK8Ox0r+dlwCG1kSW+UAbX0bQ/qUqlsTvU6muVuMP8vZYHxJ3wmb\n+ufRBKztPTQ/rYWaYQcgC0RWI20HTFBMxlTAyNxYNWzX7RKFkGVVyB9RsAtmcc8g\n+j4OdosbfNoJPS0HeIfNpAznDfHKdxDk2Yc1tV6RHBrC1ynyLE9+TaflIAdo2MVv\nKLMLq51GqYKtgJFIlBRPQqKoyXdz3fGvXrTkf/WY9QNq0J1Vk5ERePZ54mN8iZB7\n9lwy/AkCgYEA6FXzosxswaJ2wQLeoYc7ceaweX/SwTvxHgXzRyJIIT0eJWgx13Wo\n/WA3Iziimsjf6qE+SI/8laxPp2A86VMaIt3Z3mJN/CqSVGw8LK2AQst+OwdPyDMu\niacE8lj/IFGC8mwNUAb9CzGU3JpU4PxxGFjS/eMtGeRXCWkK4NE+G08CgYEA1Kp9\nN2JrVlqUz+gAX+LPmE9OEMAS9WQSQsfCHGogIFDGGcNf7+uwBM7GAaSJIP01zcoe\nVAgWdzXCv3FLhsaZoJ6RyLOLay5phbu1iaTr4UNYm5WtYTzMzqh8l1+MFFDl9xDB\nvULuCIIrglM5MeS/qnSg1uMoH2oVPj9TVst/ir8CgYEAxrI7Ws9Zc4Bt70N1As+U\nlySjaEVZCMkqvHJ6TCuVZFfQoE0r0whdLdRLU2PsLFP+q7qaeZQqgBaNSKeVcDYR\n9B+nY/jOmQoPewPVsp/vQTCnE/R81spu0mp0YI6cIheT1Z9zAy322svcc43JaWB7\nmEbeqyLOP4Z4qSOcmghZBSECgYACvR9Xs0DGn+wCsW4vze/2ei77MD4OQvepPIFX\ndFZtlBy5ADcgE9z0cuVB6CiL8DbdK5kwY9pGNr8HUCI03iHkW6Zs+0L0YmihfEVe\nPG19PSzK9CaDdhD9KFZSbLyVFmWfxOt50H7YRTTiPMgjyFpfi5j2q348yVT0tEQS\nfhRqaQKBgAcWPokmJ7EbYQGeMbS7HC8eWO/RyamlnSffdCdSc7ue3zdVJxpAkQ8W\nqu80pEIF6raIQfAf8MXiiZ7auFOSnHQTXUbhCpvDLKi0Mwq3G8Pl07l+2s6dQG6T\nlv6XTQaMyf6n1yjzL+fzDrH3qXMxHMO/b13EePXpDMpY7HQpoLDi\n-----END RSA PRIVATE KEY-----\n"), - Method: cloudflare.F(cloudflare.CustomHostnameNewParamsSSLMethodHTTP), - Settings: cloudflare.F(cloudflare.CustomHostnameNewParamsSSLSettings{ + Method: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLMethodHTTP), + Settings: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLSettings{ Ciphers: cloudflare.F([]string{"ECDHE-RSA-AES128-GCM-SHA256", "AES128-SHA"}), - EarlyHints: cloudflare.F(cloudflare.CustomHostnameNewParamsSSLSettingsEarlyHintsOn), - HTTP2: cloudflare.F(cloudflare.CustomHostnameNewParamsSSLSettingsHTTP2On), - MinTLSVersion: cloudflare.F(cloudflare.CustomHostnameNewParamsSSLSettingsMinTLSVersion1_2), - TLS1_3: cloudflare.F(cloudflare.CustomHostnameNewParamsSSLSettingsTLS1_3On), + EarlyHints: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLSettingsEarlyHintsOn), + HTTP2: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLSettingsHTTP2On), + MinTLSVersion: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLSettingsMinTLSVersion1_2), + TLS1_3: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLSettingsTLS1_3On), }), - Type: cloudflare.F(cloudflare.CustomHostnameNewParamsSSLTypeDv), + Type: cloudflare.F(custom_hostnames.CustomHostnameNewParamsSSLTypeDv), Wildcard: cloudflare.F(false), }), - CustomMetadata: cloudflare.F(cloudflare.CustomHostnameNewParamsCustomMetadata{ + CustomMetadata: cloudflare.F(custom_hostnames.CustomHostnameNewParamsCustomMetadata{ Key: cloudflare.F("value"), }), }) @@ -73,15 +74,15 @@ func TestCustomHostnameListWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.CustomHostnames.List(context.TODO(), cloudflare.CustomHostnameListParams{ + _, err := client.CustomHostnames.List(context.TODO(), custom_hostnames.CustomHostnameListParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), ID: cloudflare.F("0d89c70d-ad9f-4843-b99f-6cc0252067e9"), - Direction: cloudflare.F(cloudflare.CustomHostnameListParamsDirectionDesc), + Direction: cloudflare.F(custom_hostnames.CustomHostnameListParamsDirectionDesc), Hostname: cloudflare.F("app.example.com"), - Order: cloudflare.F(cloudflare.CustomHostnameListParamsOrderSSL), + Order: cloudflare.F(custom_hostnames.CustomHostnameListParamsOrderSSL), Page: cloudflare.F(1.000000), PerPage: cloudflare.F(5.000000), - SSL: cloudflare.F(cloudflare.CustomHostnameListParamsSSL0), + SSL: cloudflare.F(custom_hostnames.CustomHostnameListParamsSSL0), }) if err != nil { var apierr *cloudflare.Error @@ -109,7 +110,7 @@ func TestCustomHostnameDelete(t *testing.T) { _, err := client.CustomHostnames.Delete( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.CustomHostnameDeleteParams{ + custom_hostnames.CustomHostnameDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) @@ -139,27 +140,27 @@ func TestCustomHostnameEditWithOptionalParams(t *testing.T) { _, err := client.CustomHostnames.Edit( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.CustomHostnameEditParams{ + custom_hostnames.CustomHostnameEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - CustomMetadata: cloudflare.F(cloudflare.CustomHostnameEditParamsCustomMetadata{ + CustomMetadata: cloudflare.F(custom_hostnames.CustomHostnameEditParamsCustomMetadata{ Key: cloudflare.F("value"), }), CustomOriginServer: cloudflare.F("origin2.example.com"), CustomOriginSni: cloudflare.F("sni.example.com"), - SSL: cloudflare.F(cloudflare.CustomHostnameEditParamsSSL{ - BundleMethod: cloudflare.F(cloudflare.CustomHostnameEditParamsSSLBundleMethodUbiquitous), - CertificateAuthority: cloudflare.F(cloudflare.CustomHostnameEditParamsSSLCertificateAuthorityGoogle), + SSL: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSL{ + BundleMethod: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSLBundleMethodUbiquitous), + CertificateAuthority: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSLCertificateAuthorityGoogle), CustomCertificate: cloudflare.F("-----BEGIN CERTIFICATE-----\\nMIIFJDCCBAygAwIBAgIQD0ifmj/Yi5NP/2gdUySbfzANBgkqhkiG9w0BAQsFADBN\\nMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMScwJQYDVQQDEx5E...SzSHfXp5lnu/3V08I72q1QNzOCgY1XeL4GKVcj4or6cT6tX6oJH7ePPmfrBfqI/O\\nOeH8gMJ+FuwtXYEPa4hBf38M5eU5xWG7\\n-----END CERTIFICATE-----\\n"), CustomKey: cloudflare.F("-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmG\ndtcGbg/1CGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKn\nabIRuGvBKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpid\ntnKX/a+50GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+py\nFxIXjbEIdZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pE\newooaeO2izNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABAoIBACbhTYXBZYKmYPCb\nHBR1IBlCQA2nLGf0qRuJNJZg5iEzXows/6tc8YymZkQE7nolapWsQ+upk2y5Xdp/\naxiuprIs9JzkYK8Ox0r+dlwCG1kSW+UAbX0bQ/qUqlsTvU6muVuMP8vZYHxJ3wmb\n+ufRBKztPTQ/rYWaYQcgC0RWI20HTFBMxlTAyNxYNWzX7RKFkGVVyB9RsAtmcc8g\n+j4OdosbfNoJPS0HeIfNpAznDfHKdxDk2Yc1tV6RHBrC1ynyLE9+TaflIAdo2MVv\nKLMLq51GqYKtgJFIlBRPQqKoyXdz3fGvXrTkf/WY9QNq0J1Vk5ERePZ54mN8iZB7\n9lwy/AkCgYEA6FXzosxswaJ2wQLeoYc7ceaweX/SwTvxHgXzRyJIIT0eJWgx13Wo\n/WA3Iziimsjf6qE+SI/8laxPp2A86VMaIt3Z3mJN/CqSVGw8LK2AQst+OwdPyDMu\niacE8lj/IFGC8mwNUAb9CzGU3JpU4PxxGFjS/eMtGeRXCWkK4NE+G08CgYEA1Kp9\nN2JrVlqUz+gAX+LPmE9OEMAS9WQSQsfCHGogIFDGGcNf7+uwBM7GAaSJIP01zcoe\nVAgWdzXCv3FLhsaZoJ6RyLOLay5phbu1iaTr4UNYm5WtYTzMzqh8l1+MFFDl9xDB\nvULuCIIrglM5MeS/qnSg1uMoH2oVPj9TVst/ir8CgYEAxrI7Ws9Zc4Bt70N1As+U\nlySjaEVZCMkqvHJ6TCuVZFfQoE0r0whdLdRLU2PsLFP+q7qaeZQqgBaNSKeVcDYR\n9B+nY/jOmQoPewPVsp/vQTCnE/R81spu0mp0YI6cIheT1Z9zAy322svcc43JaWB7\nmEbeqyLOP4Z4qSOcmghZBSECgYACvR9Xs0DGn+wCsW4vze/2ei77MD4OQvepPIFX\ndFZtlBy5ADcgE9z0cuVB6CiL8DbdK5kwY9pGNr8HUCI03iHkW6Zs+0L0YmihfEVe\nPG19PSzK9CaDdhD9KFZSbLyVFmWfxOt50H7YRTTiPMgjyFpfi5j2q348yVT0tEQS\nfhRqaQKBgAcWPokmJ7EbYQGeMbS7HC8eWO/RyamlnSffdCdSc7ue3zdVJxpAkQ8W\nqu80pEIF6raIQfAf8MXiiZ7auFOSnHQTXUbhCpvDLKi0Mwq3G8Pl07l+2s6dQG6T\nlv6XTQaMyf6n1yjzL+fzDrH3qXMxHMO/b13EePXpDMpY7HQpoLDi\n-----END RSA PRIVATE KEY-----\n"), - Method: cloudflare.F(cloudflare.CustomHostnameEditParamsSSLMethodHTTP), - Settings: cloudflare.F(cloudflare.CustomHostnameEditParamsSSLSettings{ + Method: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSLMethodHTTP), + Settings: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSLSettings{ Ciphers: cloudflare.F([]string{"ECDHE-RSA-AES128-GCM-SHA256", "AES128-SHA"}), - EarlyHints: cloudflare.F(cloudflare.CustomHostnameEditParamsSSLSettingsEarlyHintsOn), - HTTP2: cloudflare.F(cloudflare.CustomHostnameEditParamsSSLSettingsHTTP2On), - MinTLSVersion: cloudflare.F(cloudflare.CustomHostnameEditParamsSSLSettingsMinTLSVersion1_2), - TLS1_3: cloudflare.F(cloudflare.CustomHostnameEditParamsSSLSettingsTLS1_3On), + EarlyHints: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSLSettingsEarlyHintsOn), + HTTP2: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSLSettingsHTTP2On), + MinTLSVersion: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSLSettingsMinTLSVersion1_2), + TLS1_3: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSLSettingsTLS1_3On), }), - Type: cloudflare.F(cloudflare.CustomHostnameEditParamsSSLTypeDv), + Type: cloudflare.F(custom_hostnames.CustomHostnameEditParamsSSLTypeDv), Wildcard: cloudflare.F(false), }), }, @@ -190,7 +191,7 @@ func TestCustomHostnameGet(t *testing.T) { _, err := client.CustomHostnames.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.CustomHostnameGetParams{ + custom_hostnames.CustomHostnameGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) diff --git a/custom_hostnames/fallbackorigin.go b/custom_hostnames/fallbackorigin.go new file mode 100644 index 00000000000..8f97acbf63c --- /dev/null +++ b/custom_hostnames/fallbackorigin.go @@ -0,0 +1,389 @@ +// File generated from our OpenAPI spec by Stainless. + +package custom_hostnames + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// FallbackOriginService 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 [NewFallbackOriginService] method +// instead. +type FallbackOriginService struct { + Options []option.RequestOption +} + +// NewFallbackOriginService 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 NewFallbackOriginService(opts ...option.RequestOption) (r *FallbackOriginService) { + r = &FallbackOriginService{} + r.Options = opts + return +} + +// Update Fallback Origin for Custom Hostnames +func (r *FallbackOriginService) Update(ctx context.Context, params FallbackOriginUpdateParams, opts ...option.RequestOption) (res *FallbackOriginUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env FallbackOriginUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/custom_hostnames/fallback_origin", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete Fallback Origin for Custom Hostnames +func (r *FallbackOriginService) Delete(ctx context.Context, body FallbackOriginDeleteParams, opts ...option.RequestOption) (res *FallbackOriginDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env FallbackOriginDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/custom_hostnames/fallback_origin", body.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get Fallback Origin for Custom Hostnames +func (r *FallbackOriginService) Get(ctx context.Context, query FallbackOriginGetParams, opts ...option.RequestOption) (res *FallbackOriginGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env FallbackOriginGetResponseEnvelope + path := fmt.Sprintf("zones/%s/custom_hostnames/fallback_origin", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [custom_hostnames.FallbackOriginUpdateResponseUnknown] or +// [shared.UnionString]. +type FallbackOriginUpdateResponse interface { + ImplementsCustomHostnamesFallbackOriginUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*FallbackOriginUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [custom_hostnames.FallbackOriginDeleteResponseUnknown] or +// [shared.UnionString]. +type FallbackOriginDeleteResponse interface { + ImplementsCustomHostnamesFallbackOriginDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*FallbackOriginDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [custom_hostnames.FallbackOriginGetResponseUnknown] or +// [shared.UnionString]. +type FallbackOriginGetResponse interface { + ImplementsCustomHostnamesFallbackOriginGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*FallbackOriginGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type FallbackOriginUpdateParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Your origin hostname that requests to your custom hostnames will be sent to. + Origin param.Field[string] `json:"origin,required"` +} + +func (r FallbackOriginUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type FallbackOriginUpdateResponseEnvelope struct { + Errors []FallbackOriginUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []FallbackOriginUpdateResponseEnvelopeMessages `json:"messages,required"` + Result FallbackOriginUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success FallbackOriginUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON fallbackOriginUpdateResponseEnvelopeJSON `json:"-"` +} + +// fallbackOriginUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [FallbackOriginUpdateResponseEnvelope] +type fallbackOriginUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FallbackOriginUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r fallbackOriginUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FallbackOriginUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON fallbackOriginUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// fallbackOriginUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [FallbackOriginUpdateResponseEnvelopeErrors] +type fallbackOriginUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FallbackOriginUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r fallbackOriginUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FallbackOriginUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON fallbackOriginUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// fallbackOriginUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [FallbackOriginUpdateResponseEnvelopeMessages] +type fallbackOriginUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FallbackOriginUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r fallbackOriginUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FallbackOriginUpdateResponseEnvelopeSuccess bool + +const ( + FallbackOriginUpdateResponseEnvelopeSuccessTrue FallbackOriginUpdateResponseEnvelopeSuccess = true +) + +type FallbackOriginDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type FallbackOriginDeleteResponseEnvelope struct { + Errors []FallbackOriginDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []FallbackOriginDeleteResponseEnvelopeMessages `json:"messages,required"` + Result FallbackOriginDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success FallbackOriginDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON fallbackOriginDeleteResponseEnvelopeJSON `json:"-"` +} + +// fallbackOriginDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [FallbackOriginDeleteResponseEnvelope] +type fallbackOriginDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FallbackOriginDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r fallbackOriginDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FallbackOriginDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON fallbackOriginDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// fallbackOriginDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [FallbackOriginDeleteResponseEnvelopeErrors] +type fallbackOriginDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FallbackOriginDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r fallbackOriginDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FallbackOriginDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON fallbackOriginDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// fallbackOriginDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [FallbackOriginDeleteResponseEnvelopeMessages] +type fallbackOriginDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FallbackOriginDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r fallbackOriginDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FallbackOriginDeleteResponseEnvelopeSuccess bool + +const ( + FallbackOriginDeleteResponseEnvelopeSuccessTrue FallbackOriginDeleteResponseEnvelopeSuccess = true +) + +type FallbackOriginGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type FallbackOriginGetResponseEnvelope struct { + Errors []FallbackOriginGetResponseEnvelopeErrors `json:"errors,required"` + Messages []FallbackOriginGetResponseEnvelopeMessages `json:"messages,required"` + Result FallbackOriginGetResponse `json:"result,required"` + // Whether the API call was successful + Success FallbackOriginGetResponseEnvelopeSuccess `json:"success,required"` + JSON fallbackOriginGetResponseEnvelopeJSON `json:"-"` +} + +// fallbackOriginGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [FallbackOriginGetResponseEnvelope] +type fallbackOriginGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FallbackOriginGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r fallbackOriginGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FallbackOriginGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON fallbackOriginGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// fallbackOriginGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [FallbackOriginGetResponseEnvelopeErrors] +type fallbackOriginGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FallbackOriginGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r fallbackOriginGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FallbackOriginGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON fallbackOriginGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// fallbackOriginGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [FallbackOriginGetResponseEnvelopeMessages] +type fallbackOriginGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FallbackOriginGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r fallbackOriginGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FallbackOriginGetResponseEnvelopeSuccess bool + +const ( + FallbackOriginGetResponseEnvelopeSuccessTrue FallbackOriginGetResponseEnvelopeSuccess = true +) diff --git a/custom_hostnames/fallbackorigin_test.go b/custom_hostnames/fallbackorigin_test.go new file mode 100644 index 00000000000..d9add129b21 --- /dev/null +++ b/custom_hostnames/fallbackorigin_test.go @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package custom_hostnames_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/custom_hostnames" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestFallbackOriginUpdate(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("user@example.com"), + ) + _, err := client.CustomHostnames.FallbackOrigin.Update(context.TODO(), custom_hostnames.FallbackOriginUpdateParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Origin: cloudflare.F("fallback.example.com"), + }) + 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 TestFallbackOriginDelete(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("user@example.com"), + ) + _, err := client.CustomHostnames.FallbackOrigin.Delete(context.TODO(), custom_hostnames.FallbackOriginDeleteParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestFallbackOriginGet(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("user@example.com"), + ) + _, err := client.CustomHostnames.FallbackOrigin.Get(context.TODO(), custom_hostnames.FallbackOriginGetParams{ + ZoneID: cloudflare.F("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/custom_nameservers/aliases.go b/custom_nameservers/aliases.go new file mode 100644 index 00000000000..65c8f236e4f --- /dev/null +++ b/custom_nameservers/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package custom_nameservers + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/custom_nameservers/customnameserver.go b/custom_nameservers/customnameserver.go new file mode 100644 index 00000000000..43ea750073b --- /dev/null +++ b/custom_nameservers/customnameserver.go @@ -0,0 +1,775 @@ +// File generated from our OpenAPI spec by Stainless. + +package custom_nameservers + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// CustomNameserverService 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 [NewCustomNameserverService] method +// instead. +type CustomNameserverService struct { + Options []option.RequestOption +} + +// NewCustomNameserverService 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 NewCustomNameserverService(opts ...option.RequestOption) (r *CustomNameserverService) { + r = &CustomNameserverService{} + r.Options = opts + return +} + +// Add Account Custom Nameserver +func (r *CustomNameserverService) New(ctx context.Context, params CustomNameserverNewParams, opts ...option.RequestOption) (res *DNSCustomNameserversCustomNS, err error) { + opts = append(r.Options[:], opts...) + var env CustomNameserverNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/custom_ns", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete Account Custom Nameserver +func (r *CustomNameserverService) Delete(ctx context.Context, customNSID string, body CustomNameserverDeleteParams, opts ...option.RequestOption) (res *CustomNameserverDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env CustomNameserverDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/custom_ns/%s", body.AccountID, customNSID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get Eligible Zones for Account Custom Nameservers +func (r *CustomNameserverService) Availabilty(ctx context.Context, query CustomNameserverAvailabiltyParams, opts ...option.RequestOption) (res *[]string, err error) { + opts = append(r.Options[:], opts...) + var env CustomNameserverAvailabiltyResponseEnvelope + path := fmt.Sprintf("accounts/%s/custom_ns/availability", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List an account's custom nameservers. +func (r *CustomNameserverService) Get(ctx context.Context, query CustomNameserverGetParams, opts ...option.RequestOption) (res *[]DNSCustomNameserversCustomNS, err error) { + opts = append(r.Options[:], opts...) + var env CustomNameserverGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/custom_ns", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Verify Account Custom Nameserver Glue Records +func (r *CustomNameserverService) Verify(ctx context.Context, body CustomNameserverVerifyParams, opts ...option.RequestOption) (res *[]DNSCustomNameserversCustomNS, err error) { + opts = append(r.Options[:], opts...) + var env CustomNameserverVerifyResponseEnvelope + path := fmt.Sprintf("accounts/%s/custom_ns/verify", body.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// A single account custom nameserver. +type DNSCustomNameserversCustomNS struct { + // A and AAAA records associated with the nameserver. + DNSRecords []DNSCustomNameserversCustomNSDNSRecord `json:"dns_records,required"` + // The FQDN of the name server. + NSName string `json:"ns_name,required" format:"hostname"` + // Verification status of the nameserver. + Status DNSCustomNameserversCustomNSStatus `json:"status,required"` + // Identifier + ZoneTag string `json:"zone_tag,required"` + // The number of the set that this name server belongs to. + NSSet float64 `json:"ns_set"` + JSON dnsCustomNameserversCustomNSJSON `json:"-"` +} + +// dnsCustomNameserversCustomNSJSON contains the JSON metadata for the struct +// [DNSCustomNameserversCustomNS] +type dnsCustomNameserversCustomNSJSON struct { + DNSRecords apijson.Field + NSName apijson.Field + Status apijson.Field + ZoneTag apijson.Field + NSSet apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSCustomNameserversCustomNS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsCustomNameserversCustomNSJSON) RawJSON() string { + return r.raw +} + +type DNSCustomNameserversCustomNSDNSRecord struct { + // DNS record type. + Type DNSCustomNameserversCustomNSDNSRecordsType `json:"type"` + // DNS record contents (an IPv4 or IPv6 address). + Value string `json:"value"` + JSON dnsCustomNameserversCustomNsdnsRecordJSON `json:"-"` +} + +// dnsCustomNameserversCustomNsdnsRecordJSON contains the JSON metadata for the +// struct [DNSCustomNameserversCustomNSDNSRecord] +type dnsCustomNameserversCustomNsdnsRecordJSON struct { + Type apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSCustomNameserversCustomNSDNSRecord) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsCustomNameserversCustomNsdnsRecordJSON) RawJSON() string { + return r.raw +} + +// DNS record type. +type DNSCustomNameserversCustomNSDNSRecordsType string + +const ( + DNSCustomNameserversCustomNSDNSRecordsTypeA DNSCustomNameserversCustomNSDNSRecordsType = "A" + DNSCustomNameserversCustomNSDNSRecordsTypeAAAA DNSCustomNameserversCustomNSDNSRecordsType = "AAAA" +) + +// Verification status of the nameserver. +type DNSCustomNameserversCustomNSStatus string + +const ( + DNSCustomNameserversCustomNSStatusMoved DNSCustomNameserversCustomNSStatus = "moved" + DNSCustomNameserversCustomNSStatusPending DNSCustomNameserversCustomNSStatus = "pending" + DNSCustomNameserversCustomNSStatusVerified DNSCustomNameserversCustomNSStatus = "verified" +) + +// Union satisfied by [custom_nameservers.CustomNameserverDeleteResponseUnknown], +// [custom_nameservers.CustomNameserverDeleteResponseArray] or +// [shared.UnionString]. +type CustomNameserverDeleteResponse interface { + ImplementsCustomNameserversCustomNameserverDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*CustomNameserverDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CustomNameserverDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type CustomNameserverDeleteResponseArray []interface{} + +func (r CustomNameserverDeleteResponseArray) ImplementsCustomNameserversCustomNameserverDeleteResponse() { +} + +type CustomNameserverNewParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + // The FQDN of the name server. + NSName param.Field[string] `json:"ns_name,required" format:"hostname"` + // The number of the set that this name server belongs to. + NSSet param.Field[float64] `json:"ns_set"` +} + +func (r CustomNameserverNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type CustomNameserverNewResponseEnvelope struct { + Errors []CustomNameserverNewResponseEnvelopeErrors `json:"errors,required"` + Messages []CustomNameserverNewResponseEnvelopeMessages `json:"messages,required"` + // A single account custom nameserver. + Result DNSCustomNameserversCustomNS `json:"result,required"` + // Whether the API call was successful + Success CustomNameserverNewResponseEnvelopeSuccess `json:"success,required"` + JSON customNameserverNewResponseEnvelopeJSON `json:"-"` +} + +// customNameserverNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [CustomNameserverNewResponseEnvelope] +type customNameserverNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CustomNameserverNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON customNameserverNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// customNameserverNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [CustomNameserverNewResponseEnvelopeErrors] +type customNameserverNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CustomNameserverNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON customNameserverNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// customNameserverNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [CustomNameserverNewResponseEnvelopeMessages] +type customNameserverNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CustomNameserverNewResponseEnvelopeSuccess bool + +const ( + CustomNameserverNewResponseEnvelopeSuccessTrue CustomNameserverNewResponseEnvelopeSuccess = true +) + +type CustomNameserverDeleteParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type CustomNameserverDeleteResponseEnvelope struct { + Errors []CustomNameserverDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []CustomNameserverDeleteResponseEnvelopeMessages `json:"messages,required"` + Result CustomNameserverDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success CustomNameserverDeleteResponseEnvelopeSuccess `json:"success,required"` + ResultInfo CustomNameserverDeleteResponseEnvelopeResultInfo `json:"result_info"` + JSON customNameserverDeleteResponseEnvelopeJSON `json:"-"` +} + +// customNameserverDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [CustomNameserverDeleteResponseEnvelope] +type customNameserverDeleteResponseEnvelopeJSON 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 *CustomNameserverDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CustomNameserverDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON customNameserverDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// customNameserverDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [CustomNameserverDeleteResponseEnvelopeErrors] +type customNameserverDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CustomNameserverDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON customNameserverDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// customNameserverDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [CustomNameserverDeleteResponseEnvelopeMessages] +type customNameserverDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CustomNameserverDeleteResponseEnvelopeSuccess bool + +const ( + CustomNameserverDeleteResponseEnvelopeSuccessTrue CustomNameserverDeleteResponseEnvelopeSuccess = true +) + +type CustomNameserverDeleteResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON customNameserverDeleteResponseEnvelopeResultInfoJSON `json:"-"` +} + +// customNameserverDeleteResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [CustomNameserverDeleteResponseEnvelopeResultInfo] +type customNameserverDeleteResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type CustomNameserverAvailabiltyParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type CustomNameserverAvailabiltyResponseEnvelope struct { + Errors []CustomNameserverAvailabiltyResponseEnvelopeErrors `json:"errors,required"` + Messages []CustomNameserverAvailabiltyResponseEnvelopeMessages `json:"messages,required"` + Result []string `json:"result,required,nullable" format:"hostname"` + // Whether the API call was successful + Success CustomNameserverAvailabiltyResponseEnvelopeSuccess `json:"success,required"` + ResultInfo CustomNameserverAvailabiltyResponseEnvelopeResultInfo `json:"result_info"` + JSON customNameserverAvailabiltyResponseEnvelopeJSON `json:"-"` +} + +// customNameserverAvailabiltyResponseEnvelopeJSON contains the JSON metadata for +// the struct [CustomNameserverAvailabiltyResponseEnvelope] +type customNameserverAvailabiltyResponseEnvelopeJSON 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 *CustomNameserverAvailabiltyResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverAvailabiltyResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CustomNameserverAvailabiltyResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON customNameserverAvailabiltyResponseEnvelopeErrorsJSON `json:"-"` +} + +// customNameserverAvailabiltyResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [CustomNameserverAvailabiltyResponseEnvelopeErrors] +type customNameserverAvailabiltyResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverAvailabiltyResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverAvailabiltyResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CustomNameserverAvailabiltyResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON customNameserverAvailabiltyResponseEnvelopeMessagesJSON `json:"-"` +} + +// customNameserverAvailabiltyResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [CustomNameserverAvailabiltyResponseEnvelopeMessages] +type customNameserverAvailabiltyResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverAvailabiltyResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverAvailabiltyResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CustomNameserverAvailabiltyResponseEnvelopeSuccess bool + +const ( + CustomNameserverAvailabiltyResponseEnvelopeSuccessTrue CustomNameserverAvailabiltyResponseEnvelopeSuccess = true +) + +type CustomNameserverAvailabiltyResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON customNameserverAvailabiltyResponseEnvelopeResultInfoJSON `json:"-"` +} + +// customNameserverAvailabiltyResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [CustomNameserverAvailabiltyResponseEnvelopeResultInfo] +type customNameserverAvailabiltyResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverAvailabiltyResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverAvailabiltyResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type CustomNameserverGetParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type CustomNameserverGetResponseEnvelope struct { + Errors []CustomNameserverGetResponseEnvelopeErrors `json:"errors,required"` + Messages []CustomNameserverGetResponseEnvelopeMessages `json:"messages,required"` + Result []DNSCustomNameserversCustomNS `json:"result,required,nullable"` + // Whether the API call was successful + Success CustomNameserverGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo CustomNameserverGetResponseEnvelopeResultInfo `json:"result_info"` + JSON customNameserverGetResponseEnvelopeJSON `json:"-"` +} + +// customNameserverGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [CustomNameserverGetResponseEnvelope] +type customNameserverGetResponseEnvelopeJSON 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 *CustomNameserverGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CustomNameserverGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON customNameserverGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// customNameserverGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [CustomNameserverGetResponseEnvelopeErrors] +type customNameserverGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CustomNameserverGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON customNameserverGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// customNameserverGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [CustomNameserverGetResponseEnvelopeMessages] +type customNameserverGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CustomNameserverGetResponseEnvelopeSuccess bool + +const ( + CustomNameserverGetResponseEnvelopeSuccessTrue CustomNameserverGetResponseEnvelopeSuccess = true +) + +type CustomNameserverGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON customNameserverGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// customNameserverGetResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [CustomNameserverGetResponseEnvelopeResultInfo] +type customNameserverGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type CustomNameserverVerifyParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type CustomNameserverVerifyResponseEnvelope struct { + Errors []CustomNameserverVerifyResponseEnvelopeErrors `json:"errors,required"` + Messages []CustomNameserverVerifyResponseEnvelopeMessages `json:"messages,required"` + Result []DNSCustomNameserversCustomNS `json:"result,required,nullable"` + // Whether the API call was successful + Success CustomNameserverVerifyResponseEnvelopeSuccess `json:"success,required"` + ResultInfo CustomNameserverVerifyResponseEnvelopeResultInfo `json:"result_info"` + JSON customNameserverVerifyResponseEnvelopeJSON `json:"-"` +} + +// customNameserverVerifyResponseEnvelopeJSON contains the JSON metadata for the +// struct [CustomNameserverVerifyResponseEnvelope] +type customNameserverVerifyResponseEnvelopeJSON 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 *CustomNameserverVerifyResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverVerifyResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CustomNameserverVerifyResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON customNameserverVerifyResponseEnvelopeErrorsJSON `json:"-"` +} + +// customNameserverVerifyResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [CustomNameserverVerifyResponseEnvelopeErrors] +type customNameserverVerifyResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverVerifyResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverVerifyResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CustomNameserverVerifyResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON customNameserverVerifyResponseEnvelopeMessagesJSON `json:"-"` +} + +// customNameserverVerifyResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [CustomNameserverVerifyResponseEnvelopeMessages] +type customNameserverVerifyResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverVerifyResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverVerifyResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CustomNameserverVerifyResponseEnvelopeSuccess bool + +const ( + CustomNameserverVerifyResponseEnvelopeSuccessTrue CustomNameserverVerifyResponseEnvelopeSuccess = true +) + +type CustomNameserverVerifyResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON customNameserverVerifyResponseEnvelopeResultInfoJSON `json:"-"` +} + +// customNameserverVerifyResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [CustomNameserverVerifyResponseEnvelopeResultInfo] +type customNameserverVerifyResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverVerifyResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverVerifyResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/custom_nameservers/customnameserver_test.go b/custom_nameservers/customnameserver_test.go new file mode 100644 index 00000000000..79b3bab9a00 --- /dev/null +++ b/custom_nameservers/customnameserver_test.go @@ -0,0 +1,151 @@ +// File generated from our OpenAPI spec by Stainless. + +package custom_nameservers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/custom_nameservers" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestCustomNameserverNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.CustomNameservers.New(context.TODO(), custom_nameservers.CustomNameserverNewParams{ + AccountID: cloudflare.F("372e67954025e0ba6aaa6d586b9e0b59"), + NSName: cloudflare.F("ns1.example.com"), + NSSet: cloudflare.F(1.000000), + }) + 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 TestCustomNameserverDelete(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("user@example.com"), + ) + _, err := client.CustomNameservers.Delete( + context.TODO(), + "ns1.example.com", + custom_nameservers.CustomNameserverDeleteParams{ + AccountID: cloudflare.F("372e67954025e0ba6aaa6d586b9e0b59"), + }, + ) + 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 TestCustomNameserverAvailabilty(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("user@example.com"), + ) + _, err := client.CustomNameservers.Availabilty(context.TODO(), custom_nameservers.CustomNameserverAvailabiltyParams{ + AccountID: cloudflare.F("372e67954025e0ba6aaa6d586b9e0b59"), + }) + 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 TestCustomNameserverGet(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("user@example.com"), + ) + _, err := client.CustomNameservers.Get(context.TODO(), custom_nameservers.CustomNameserverGetParams{ + AccountID: cloudflare.F("372e67954025e0ba6aaa6d586b9e0b59"), + }) + 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 TestCustomNameserverVerify(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("user@example.com"), + ) + _, err := client.CustomNameservers.Verify(context.TODO(), custom_nameservers.CustomNameserverVerifyParams{ + AccountID: cloudflare.F("372e67954025e0ba6aaa6d586b9e0b59"), + }) + 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/customcertificateprioritize.go b/customcertificateprioritize.go deleted file mode 100644 index 9239cd29008..00000000000 --- a/customcertificateprioritize.go +++ /dev/null @@ -1,413 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// CustomCertificatePrioritizeService 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 -// [NewCustomCertificatePrioritizeService] method instead. -type CustomCertificatePrioritizeService struct { - Options []option.RequestOption -} - -// NewCustomCertificatePrioritizeService 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 NewCustomCertificatePrioritizeService(opts ...option.RequestOption) (r *CustomCertificatePrioritizeService) { - r = &CustomCertificatePrioritizeService{} - r.Options = opts - return -} - -// If a zone has multiple SSL certificates, you can set the order in which they -// should be used during a request. The higher priority will break ties across -// overlapping 'legacy_custom' certificates. -func (r *CustomCertificatePrioritizeService) Update(ctx context.Context, params CustomCertificatePrioritizeUpdateParams, opts ...option.RequestOption) (res *[]CustomCertificatePrioritizeUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env CustomCertificatePrioritizeUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/custom_certificates/prioritize", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type CustomCertificatePrioritizeUpdateResponse struct { - // Identifier - ID string `json:"id,required"` - // A ubiquitous bundle has the highest probability of being verified everywhere, - // even by clients using outdated or unusual trust stores. An optimal bundle uses - // the shortest chain and newest intermediates. And the force bundle verifies the - // chain, but does not otherwise modify it. - BundleMethod CustomCertificatePrioritizeUpdateResponseBundleMethod `json:"bundle_method,required"` - // When the certificate from the authority expires. - ExpiresOn time.Time `json:"expires_on,required" format:"date-time"` - Hosts []string `json:"hosts,required"` - // The certificate authority that issued the certificate. - Issuer string `json:"issuer,required"` - // When the certificate was last modified. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // The order/priority in which the certificate will be used in a request. The - // higher priority will break ties across overlapping 'legacy_custom' certificates, - // but 'legacy_custom' certificates will always supercede 'sni_custom' - // certificates. - Priority float64 `json:"priority,required"` - // The type of hash used for the certificate. - Signature string `json:"signature,required"` - // Status of the zone's custom SSL. - Status CustomCertificatePrioritizeUpdateResponseStatus `json:"status,required"` - // When the certificate was uploaded to Cloudflare. - UploadedOn time.Time `json:"uploaded_on,required" format:"date-time"` - // Identifier - ZoneID string `json:"zone_id,required"` - // Specify the region where your private key can be held locally for optimal TLS - // performance. HTTPS connections to any excluded data center will still be fully - // encrypted, but will incur some latency while Keyless SSL is used to complete the - // handshake with the nearest allowed data center. Options allow distribution to - // only to U.S. data centers, only to E.U. data centers, or only to highest - // security data centers. Default distribution is to all Cloudflare datacenters, - // for optimal performance. - GeoRestrictions CustomCertificatePrioritizeUpdateResponseGeoRestrictions `json:"geo_restrictions"` - KeylessServer CustomCertificatePrioritizeUpdateResponseKeylessServer `json:"keyless_server"` - // Specify the policy that determines the region where your private key will be - // held locally. HTTPS connections to any excluded data center will still be fully - // encrypted, but will incur some latency while Keyless SSL is used to complete the - // handshake with the nearest allowed data center. Any combination of countries, - // specified by their two letter country code - // (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements) - // can be chosen, such as 'country: IN', as well as 'region: EU' which refers to - // the EU region. If there are too few data centers satisfying the policy, it will - // be rejected. - Policy string `json:"policy"` - JSON customCertificatePrioritizeUpdateResponseJSON `json:"-"` -} - -// customCertificatePrioritizeUpdateResponseJSON contains the JSON metadata for the -// struct [CustomCertificatePrioritizeUpdateResponse] -type customCertificatePrioritizeUpdateResponseJSON struct { - ID apijson.Field - BundleMethod apijson.Field - ExpiresOn apijson.Field - Hosts apijson.Field - Issuer apijson.Field - ModifiedOn apijson.Field - Priority apijson.Field - Signature apijson.Field - Status apijson.Field - UploadedOn apijson.Field - ZoneID apijson.Field - GeoRestrictions apijson.Field - KeylessServer apijson.Field - Policy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomCertificatePrioritizeUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customCertificatePrioritizeUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// A ubiquitous bundle has the highest probability of being verified everywhere, -// even by clients using outdated or unusual trust stores. An optimal bundle uses -// the shortest chain and newest intermediates. And the force bundle verifies the -// chain, but does not otherwise modify it. -type CustomCertificatePrioritizeUpdateResponseBundleMethod string - -const ( - CustomCertificatePrioritizeUpdateResponseBundleMethodUbiquitous CustomCertificatePrioritizeUpdateResponseBundleMethod = "ubiquitous" - CustomCertificatePrioritizeUpdateResponseBundleMethodOptimal CustomCertificatePrioritizeUpdateResponseBundleMethod = "optimal" - CustomCertificatePrioritizeUpdateResponseBundleMethodForce CustomCertificatePrioritizeUpdateResponseBundleMethod = "force" -) - -// Status of the zone's custom SSL. -type CustomCertificatePrioritizeUpdateResponseStatus string - -const ( - CustomCertificatePrioritizeUpdateResponseStatusActive CustomCertificatePrioritizeUpdateResponseStatus = "active" - CustomCertificatePrioritizeUpdateResponseStatusExpired CustomCertificatePrioritizeUpdateResponseStatus = "expired" - CustomCertificatePrioritizeUpdateResponseStatusDeleted CustomCertificatePrioritizeUpdateResponseStatus = "deleted" - CustomCertificatePrioritizeUpdateResponseStatusPending CustomCertificatePrioritizeUpdateResponseStatus = "pending" - CustomCertificatePrioritizeUpdateResponseStatusInitializing CustomCertificatePrioritizeUpdateResponseStatus = "initializing" -) - -// Specify the region where your private key can be held locally for optimal TLS -// performance. HTTPS connections to any excluded data center will still be fully -// encrypted, but will incur some latency while Keyless SSL is used to complete the -// handshake with the nearest allowed data center. Options allow distribution to -// only to U.S. data centers, only to E.U. data centers, or only to highest -// security data centers. Default distribution is to all Cloudflare datacenters, -// for optimal performance. -type CustomCertificatePrioritizeUpdateResponseGeoRestrictions struct { - Label CustomCertificatePrioritizeUpdateResponseGeoRestrictionsLabel `json:"label"` - JSON customCertificatePrioritizeUpdateResponseGeoRestrictionsJSON `json:"-"` -} - -// customCertificatePrioritizeUpdateResponseGeoRestrictionsJSON contains the JSON -// metadata for the struct -// [CustomCertificatePrioritizeUpdateResponseGeoRestrictions] -type customCertificatePrioritizeUpdateResponseGeoRestrictionsJSON struct { - Label apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomCertificatePrioritizeUpdateResponseGeoRestrictions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customCertificatePrioritizeUpdateResponseGeoRestrictionsJSON) RawJSON() string { - return r.raw -} - -type CustomCertificatePrioritizeUpdateResponseGeoRestrictionsLabel string - -const ( - CustomCertificatePrioritizeUpdateResponseGeoRestrictionsLabelUs CustomCertificatePrioritizeUpdateResponseGeoRestrictionsLabel = "us" - CustomCertificatePrioritizeUpdateResponseGeoRestrictionsLabelEu CustomCertificatePrioritizeUpdateResponseGeoRestrictionsLabel = "eu" - CustomCertificatePrioritizeUpdateResponseGeoRestrictionsLabelHighestSecurity CustomCertificatePrioritizeUpdateResponseGeoRestrictionsLabel = "highest_security" -) - -type CustomCertificatePrioritizeUpdateResponseKeylessServer struct { - // Keyless certificate identifier tag. - ID string `json:"id,required"` - // When the Keyless SSL was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - // Whether or not the Keyless SSL is on or off. - Enabled bool `json:"enabled,required"` - // The keyless SSL name. - Host string `json:"host,required" format:"hostname"` - // When the Keyless SSL was last modified. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // The keyless SSL name. - Name string `json:"name,required"` - // Available permissions for the Keyless SSL for the current user requesting the - // item. - Permissions []interface{} `json:"permissions,required"` - // The keyless SSL port used to communicate between Cloudflare and the client's - // Keyless SSL server. - Port float64 `json:"port,required"` - // Status of the Keyless SSL. - Status CustomCertificatePrioritizeUpdateResponseKeylessServerStatus `json:"status,required"` - // Configuration for using Keyless SSL through a Cloudflare Tunnel - Tunnel CustomCertificatePrioritizeUpdateResponseKeylessServerTunnel `json:"tunnel"` - JSON customCertificatePrioritizeUpdateResponseKeylessServerJSON `json:"-"` -} - -// customCertificatePrioritizeUpdateResponseKeylessServerJSON contains the JSON -// metadata for the struct [CustomCertificatePrioritizeUpdateResponseKeylessServer] -type customCertificatePrioritizeUpdateResponseKeylessServerJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Enabled apijson.Field - Host apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Permissions apijson.Field - Port apijson.Field - Status apijson.Field - Tunnel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomCertificatePrioritizeUpdateResponseKeylessServer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customCertificatePrioritizeUpdateResponseKeylessServerJSON) RawJSON() string { - return r.raw -} - -// Status of the Keyless SSL. -type CustomCertificatePrioritizeUpdateResponseKeylessServerStatus string - -const ( - CustomCertificatePrioritizeUpdateResponseKeylessServerStatusActive CustomCertificatePrioritizeUpdateResponseKeylessServerStatus = "active" - CustomCertificatePrioritizeUpdateResponseKeylessServerStatusDeleted CustomCertificatePrioritizeUpdateResponseKeylessServerStatus = "deleted" -) - -// Configuration for using Keyless SSL through a Cloudflare Tunnel -type CustomCertificatePrioritizeUpdateResponseKeylessServerTunnel struct { - // Private IP of the Key Server Host - PrivateIP string `json:"private_ip,required"` - // Cloudflare Tunnel Virtual Network ID - VnetID string `json:"vnet_id,required"` - JSON customCertificatePrioritizeUpdateResponseKeylessServerTunnelJSON `json:"-"` -} - -// customCertificatePrioritizeUpdateResponseKeylessServerTunnelJSON contains the -// JSON metadata for the struct -// [CustomCertificatePrioritizeUpdateResponseKeylessServerTunnel] -type customCertificatePrioritizeUpdateResponseKeylessServerTunnelJSON struct { - PrivateIP apijson.Field - VnetID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomCertificatePrioritizeUpdateResponseKeylessServerTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customCertificatePrioritizeUpdateResponseKeylessServerTunnelJSON) RawJSON() string { - return r.raw -} - -type CustomCertificatePrioritizeUpdateParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Array of ordered certificates. - Certificates param.Field[[]CustomCertificatePrioritizeUpdateParamsCertificate] `json:"certificates,required"` -} - -func (r CustomCertificatePrioritizeUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type CustomCertificatePrioritizeUpdateParamsCertificate struct { - // The order/priority in which the certificate will be used in a request. The - // higher priority will break ties across overlapping 'legacy_custom' certificates, - // but 'legacy_custom' certificates will always supercede 'sni_custom' - // certificates. - Priority param.Field[float64] `json:"priority"` -} - -func (r CustomCertificatePrioritizeUpdateParamsCertificate) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type CustomCertificatePrioritizeUpdateResponseEnvelope struct { - Errors []CustomCertificatePrioritizeUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomCertificatePrioritizeUpdateResponseEnvelopeMessages `json:"messages,required"` - Result []CustomCertificatePrioritizeUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success CustomCertificatePrioritizeUpdateResponseEnvelopeSuccess `json:"success,required"` - ResultInfo CustomCertificatePrioritizeUpdateResponseEnvelopeResultInfo `json:"result_info"` - JSON customCertificatePrioritizeUpdateResponseEnvelopeJSON `json:"-"` -} - -// customCertificatePrioritizeUpdateResponseEnvelopeJSON contains the JSON metadata -// for the struct [CustomCertificatePrioritizeUpdateResponseEnvelope] -type customCertificatePrioritizeUpdateResponseEnvelopeJSON 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 *CustomCertificatePrioritizeUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customCertificatePrioritizeUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CustomCertificatePrioritizeUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customCertificatePrioritizeUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// customCertificatePrioritizeUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [CustomCertificatePrioritizeUpdateResponseEnvelopeErrors] -type customCertificatePrioritizeUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomCertificatePrioritizeUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customCertificatePrioritizeUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomCertificatePrioritizeUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customCertificatePrioritizeUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// customCertificatePrioritizeUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [CustomCertificatePrioritizeUpdateResponseEnvelopeMessages] -type customCertificatePrioritizeUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomCertificatePrioritizeUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customCertificatePrioritizeUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CustomCertificatePrioritizeUpdateResponseEnvelopeSuccess bool - -const ( - CustomCertificatePrioritizeUpdateResponseEnvelopeSuccessTrue CustomCertificatePrioritizeUpdateResponseEnvelopeSuccess = true -) - -type CustomCertificatePrioritizeUpdateResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON customCertificatePrioritizeUpdateResponseEnvelopeResultInfoJSON `json:"-"` -} - -// customCertificatePrioritizeUpdateResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [CustomCertificatePrioritizeUpdateResponseEnvelopeResultInfo] -type customCertificatePrioritizeUpdateResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomCertificatePrioritizeUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customCertificatePrioritizeUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/customcertificateprioritize_test.go b/customcertificateprioritize_test.go deleted file mode 100644 index f1598cc6cd1..00000000000 --- a/customcertificateprioritize_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestCustomCertificatePrioritizeUpdate(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("user@example.com"), - ) - _, err := client.CustomCertificates.Prioritize.Update(context.TODO(), cloudflare.CustomCertificatePrioritizeUpdateParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Certificates: cloudflare.F([]cloudflare.CustomCertificatePrioritizeUpdateParamsCertificate{{ - Priority: cloudflare.F(2.000000), - }, { - Priority: cloudflare.F(1.000000), - }}), - }) - 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/customhostnamefallbackorigin.go b/customhostnamefallbackorigin.go deleted file mode 100644 index 9618af5f943..00000000000 --- a/customhostnamefallbackorigin.go +++ /dev/null @@ -1,394 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// CustomHostnameFallbackOriginService 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 -// [NewCustomHostnameFallbackOriginService] method instead. -type CustomHostnameFallbackOriginService struct { - Options []option.RequestOption -} - -// NewCustomHostnameFallbackOriginService 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 NewCustomHostnameFallbackOriginService(opts ...option.RequestOption) (r *CustomHostnameFallbackOriginService) { - r = &CustomHostnameFallbackOriginService{} - r.Options = opts - return -} - -// Update Fallback Origin for Custom Hostnames -func (r *CustomHostnameFallbackOriginService) Update(ctx context.Context, params CustomHostnameFallbackOriginUpdateParams, opts ...option.RequestOption) (res *CustomHostnameFallbackOriginUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env CustomHostnameFallbackOriginUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/custom_hostnames/fallback_origin", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete Fallback Origin for Custom Hostnames -func (r *CustomHostnameFallbackOriginService) Delete(ctx context.Context, body CustomHostnameFallbackOriginDeleteParams, opts ...option.RequestOption) (res *CustomHostnameFallbackOriginDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env CustomHostnameFallbackOriginDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/custom_hostnames/fallback_origin", body.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get Fallback Origin for Custom Hostnames -func (r *CustomHostnameFallbackOriginService) Get(ctx context.Context, query CustomHostnameFallbackOriginGetParams, opts ...option.RequestOption) (res *CustomHostnameFallbackOriginGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env CustomHostnameFallbackOriginGetResponseEnvelope - path := fmt.Sprintf("zones/%s/custom_hostnames/fallback_origin", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [CustomHostnameFallbackOriginUpdateResponseUnknown] or -// [shared.UnionString]. -type CustomHostnameFallbackOriginUpdateResponse interface { - ImplementsCustomHostnameFallbackOriginUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*CustomHostnameFallbackOriginUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [CustomHostnameFallbackOriginDeleteResponseUnknown] or -// [shared.UnionString]. -type CustomHostnameFallbackOriginDeleteResponse interface { - ImplementsCustomHostnameFallbackOriginDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*CustomHostnameFallbackOriginDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [CustomHostnameFallbackOriginGetResponseUnknown] or -// [shared.UnionString]. -type CustomHostnameFallbackOriginGetResponse interface { - ImplementsCustomHostnameFallbackOriginGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*CustomHostnameFallbackOriginGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type CustomHostnameFallbackOriginUpdateParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Your origin hostname that requests to your custom hostnames will be sent to. - Origin param.Field[string] `json:"origin,required"` -} - -func (r CustomHostnameFallbackOriginUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type CustomHostnameFallbackOriginUpdateResponseEnvelope struct { - Errors []CustomHostnameFallbackOriginUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomHostnameFallbackOriginUpdateResponseEnvelopeMessages `json:"messages,required"` - Result CustomHostnameFallbackOriginUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success CustomHostnameFallbackOriginUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON customHostnameFallbackOriginUpdateResponseEnvelopeJSON `json:"-"` -} - -// customHostnameFallbackOriginUpdateResponseEnvelopeJSON contains the JSON -// metadata for the struct [CustomHostnameFallbackOriginUpdateResponseEnvelope] -type customHostnameFallbackOriginUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameFallbackOriginUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameFallbackOriginUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CustomHostnameFallbackOriginUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customHostnameFallbackOriginUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// customHostnameFallbackOriginUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [CustomHostnameFallbackOriginUpdateResponseEnvelopeErrors] -type customHostnameFallbackOriginUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameFallbackOriginUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameFallbackOriginUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomHostnameFallbackOriginUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customHostnameFallbackOriginUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// customHostnameFallbackOriginUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [CustomHostnameFallbackOriginUpdateResponseEnvelopeMessages] -type customHostnameFallbackOriginUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameFallbackOriginUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameFallbackOriginUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CustomHostnameFallbackOriginUpdateResponseEnvelopeSuccess bool - -const ( - CustomHostnameFallbackOriginUpdateResponseEnvelopeSuccessTrue CustomHostnameFallbackOriginUpdateResponseEnvelopeSuccess = true -) - -type CustomHostnameFallbackOriginDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type CustomHostnameFallbackOriginDeleteResponseEnvelope struct { - Errors []CustomHostnameFallbackOriginDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomHostnameFallbackOriginDeleteResponseEnvelopeMessages `json:"messages,required"` - Result CustomHostnameFallbackOriginDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success CustomHostnameFallbackOriginDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON customHostnameFallbackOriginDeleteResponseEnvelopeJSON `json:"-"` -} - -// customHostnameFallbackOriginDeleteResponseEnvelopeJSON contains the JSON -// metadata for the struct [CustomHostnameFallbackOriginDeleteResponseEnvelope] -type customHostnameFallbackOriginDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameFallbackOriginDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameFallbackOriginDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CustomHostnameFallbackOriginDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customHostnameFallbackOriginDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// customHostnameFallbackOriginDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [CustomHostnameFallbackOriginDeleteResponseEnvelopeErrors] -type customHostnameFallbackOriginDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameFallbackOriginDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameFallbackOriginDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomHostnameFallbackOriginDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customHostnameFallbackOriginDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// customHostnameFallbackOriginDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [CustomHostnameFallbackOriginDeleteResponseEnvelopeMessages] -type customHostnameFallbackOriginDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameFallbackOriginDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameFallbackOriginDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CustomHostnameFallbackOriginDeleteResponseEnvelopeSuccess bool - -const ( - CustomHostnameFallbackOriginDeleteResponseEnvelopeSuccessTrue CustomHostnameFallbackOriginDeleteResponseEnvelopeSuccess = true -) - -type CustomHostnameFallbackOriginGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type CustomHostnameFallbackOriginGetResponseEnvelope struct { - Errors []CustomHostnameFallbackOriginGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomHostnameFallbackOriginGetResponseEnvelopeMessages `json:"messages,required"` - Result CustomHostnameFallbackOriginGetResponse `json:"result,required"` - // Whether the API call was successful - Success CustomHostnameFallbackOriginGetResponseEnvelopeSuccess `json:"success,required"` - JSON customHostnameFallbackOriginGetResponseEnvelopeJSON `json:"-"` -} - -// customHostnameFallbackOriginGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [CustomHostnameFallbackOriginGetResponseEnvelope] -type customHostnameFallbackOriginGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameFallbackOriginGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameFallbackOriginGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CustomHostnameFallbackOriginGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customHostnameFallbackOriginGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// customHostnameFallbackOriginGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [CustomHostnameFallbackOriginGetResponseEnvelopeErrors] -type customHostnameFallbackOriginGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameFallbackOriginGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameFallbackOriginGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomHostnameFallbackOriginGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customHostnameFallbackOriginGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// customHostnameFallbackOriginGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [CustomHostnameFallbackOriginGetResponseEnvelopeMessages] -type customHostnameFallbackOriginGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameFallbackOriginGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameFallbackOriginGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CustomHostnameFallbackOriginGetResponseEnvelopeSuccess bool - -const ( - CustomHostnameFallbackOriginGetResponseEnvelopeSuccessTrue CustomHostnameFallbackOriginGetResponseEnvelopeSuccess = true -) diff --git a/customhostnamefallbackorigin_test.go b/customhostnamefallbackorigin_test.go deleted file mode 100644 index ae0992cdb1e..00000000000 --- a/customhostnamefallbackorigin_test.go +++ /dev/null @@ -1,93 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestCustomHostnameFallbackOriginUpdate(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("user@example.com"), - ) - _, err := client.CustomHostnames.FallbackOrigin.Update(context.TODO(), cloudflare.CustomHostnameFallbackOriginUpdateParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Origin: cloudflare.F("fallback.example.com"), - }) - 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 TestCustomHostnameFallbackOriginDelete(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("user@example.com"), - ) - _, err := client.CustomHostnames.FallbackOrigin.Delete(context.TODO(), cloudflare.CustomHostnameFallbackOriginDeleteParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestCustomHostnameFallbackOriginGet(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("user@example.com"), - ) - _, err := client.CustomHostnames.FallbackOrigin.Get(context.TODO(), cloudflare.CustomHostnameFallbackOriginGetParams{ - ZoneID: cloudflare.F("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/customnameserver.go b/customnameserver.go deleted file mode 100644 index 2d3cf9dee96..00000000000 --- a/customnameserver.go +++ /dev/null @@ -1,927 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// CustomNameserverService 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 [NewCustomNameserverService] method -// instead. -type CustomNameserverService struct { - Options []option.RequestOption -} - -// NewCustomNameserverService 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 NewCustomNameserverService(opts ...option.RequestOption) (r *CustomNameserverService) { - r = &CustomNameserverService{} - r.Options = opts - return -} - -// Add Account Custom Nameserver -func (r *CustomNameserverService) New(ctx context.Context, params CustomNameserverNewParams, opts ...option.RequestOption) (res *CustomNameserverNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env CustomNameserverNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/custom_ns", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete Account Custom Nameserver -func (r *CustomNameserverService) Delete(ctx context.Context, customNSID string, body CustomNameserverDeleteParams, opts ...option.RequestOption) (res *CustomNameserverDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env CustomNameserverDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/custom_ns/%s", body.AccountID, customNSID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get Eligible Zones for Account Custom Nameservers -func (r *CustomNameserverService) Availabilty(ctx context.Context, query CustomNameserverAvailabiltyParams, opts ...option.RequestOption) (res *[]string, err error) { - opts = append(r.Options[:], opts...) - var env CustomNameserverAvailabiltyResponseEnvelope - path := fmt.Sprintf("accounts/%s/custom_ns/availability", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List an account's custom nameservers. -func (r *CustomNameserverService) Get(ctx context.Context, query CustomNameserverGetParams, opts ...option.RequestOption) (res *[]CustomNameserverGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env CustomNameserverGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/custom_ns", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Verify Account Custom Nameserver Glue Records -func (r *CustomNameserverService) Verify(ctx context.Context, body CustomNameserverVerifyParams, opts ...option.RequestOption) (res *[]CustomNameserverVerifyResponse, err error) { - opts = append(r.Options[:], opts...) - var env CustomNameserverVerifyResponseEnvelope - path := fmt.Sprintf("accounts/%s/custom_ns/verify", body.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// A single account custom nameserver. -type CustomNameserverNewResponse struct { - // A and AAAA records associated with the nameserver. - DNSRecords []CustomNameserverNewResponseDNSRecord `json:"dns_records,required"` - // The FQDN of the name server. - NSName string `json:"ns_name,required" format:"hostname"` - // Verification status of the nameserver. - Status CustomNameserverNewResponseStatus `json:"status,required"` - // Identifier - ZoneTag string `json:"zone_tag,required"` - // The number of the set that this name server belongs to. - NSSet float64 `json:"ns_set"` - JSON customNameserverNewResponseJSON `json:"-"` -} - -// customNameserverNewResponseJSON contains the JSON metadata for the struct -// [CustomNameserverNewResponse] -type customNameserverNewResponseJSON struct { - DNSRecords apijson.Field - NSName apijson.Field - Status apijson.Field - ZoneTag apijson.Field - NSSet apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverNewResponseJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverNewResponseDNSRecord struct { - // DNS record type. - Type CustomNameserverNewResponseDNSRecordsType `json:"type"` - // DNS record contents (an IPv4 or IPv6 address). - Value string `json:"value"` - JSON customNameserverNewResponseDNSRecordJSON `json:"-"` -} - -// customNameserverNewResponseDNSRecordJSON contains the JSON metadata for the -// struct [CustomNameserverNewResponseDNSRecord] -type customNameserverNewResponseDNSRecordJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverNewResponseDNSRecord) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverNewResponseDNSRecordJSON) RawJSON() string { - return r.raw -} - -// DNS record type. -type CustomNameserverNewResponseDNSRecordsType string - -const ( - CustomNameserverNewResponseDNSRecordsTypeA CustomNameserverNewResponseDNSRecordsType = "A" - CustomNameserverNewResponseDNSRecordsTypeAAAA CustomNameserverNewResponseDNSRecordsType = "AAAA" -) - -// Verification status of the nameserver. -type CustomNameserverNewResponseStatus string - -const ( - CustomNameserverNewResponseStatusMoved CustomNameserverNewResponseStatus = "moved" - CustomNameserverNewResponseStatusPending CustomNameserverNewResponseStatus = "pending" - CustomNameserverNewResponseStatusVerified CustomNameserverNewResponseStatus = "verified" -) - -// Union satisfied by [CustomNameserverDeleteResponseUnknown], -// [CustomNameserverDeleteResponseArray] or [shared.UnionString]. -type CustomNameserverDeleteResponse interface { - ImplementsCustomNameserverDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*CustomNameserverDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(CustomNameserverDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type CustomNameserverDeleteResponseArray []interface{} - -func (r CustomNameserverDeleteResponseArray) ImplementsCustomNameserverDeleteResponse() {} - -// A single account custom nameserver. -type CustomNameserverGetResponse struct { - // A and AAAA records associated with the nameserver. - DNSRecords []CustomNameserverGetResponseDNSRecord `json:"dns_records,required"` - // The FQDN of the name server. - NSName string `json:"ns_name,required" format:"hostname"` - // Verification status of the nameserver. - Status CustomNameserverGetResponseStatus `json:"status,required"` - // Identifier - ZoneTag string `json:"zone_tag,required"` - // The number of the set that this name server belongs to. - NSSet float64 `json:"ns_set"` - JSON customNameserverGetResponseJSON `json:"-"` -} - -// customNameserverGetResponseJSON contains the JSON metadata for the struct -// [CustomNameserverGetResponse] -type customNameserverGetResponseJSON struct { - DNSRecords apijson.Field - NSName apijson.Field - Status apijson.Field - ZoneTag apijson.Field - NSSet apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverGetResponseJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverGetResponseDNSRecord struct { - // DNS record type. - Type CustomNameserverGetResponseDNSRecordsType `json:"type"` - // DNS record contents (an IPv4 or IPv6 address). - Value string `json:"value"` - JSON customNameserverGetResponseDNSRecordJSON `json:"-"` -} - -// customNameserverGetResponseDNSRecordJSON contains the JSON metadata for the -// struct [CustomNameserverGetResponseDNSRecord] -type customNameserverGetResponseDNSRecordJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverGetResponseDNSRecord) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverGetResponseDNSRecordJSON) RawJSON() string { - return r.raw -} - -// DNS record type. -type CustomNameserverGetResponseDNSRecordsType string - -const ( - CustomNameserverGetResponseDNSRecordsTypeA CustomNameserverGetResponseDNSRecordsType = "A" - CustomNameserverGetResponseDNSRecordsTypeAAAA CustomNameserverGetResponseDNSRecordsType = "AAAA" -) - -// Verification status of the nameserver. -type CustomNameserverGetResponseStatus string - -const ( - CustomNameserverGetResponseStatusMoved CustomNameserverGetResponseStatus = "moved" - CustomNameserverGetResponseStatusPending CustomNameserverGetResponseStatus = "pending" - CustomNameserverGetResponseStatusVerified CustomNameserverGetResponseStatus = "verified" -) - -// A single account custom nameserver. -type CustomNameserverVerifyResponse struct { - // A and AAAA records associated with the nameserver. - DNSRecords []CustomNameserverVerifyResponseDNSRecord `json:"dns_records,required"` - // The FQDN of the name server. - NSName string `json:"ns_name,required" format:"hostname"` - // Verification status of the nameserver. - Status CustomNameserverVerifyResponseStatus `json:"status,required"` - // Identifier - ZoneTag string `json:"zone_tag,required"` - // The number of the set that this name server belongs to. - NSSet float64 `json:"ns_set"` - JSON customNameserverVerifyResponseJSON `json:"-"` -} - -// customNameserverVerifyResponseJSON contains the JSON metadata for the struct -// [CustomNameserverVerifyResponse] -type customNameserverVerifyResponseJSON struct { - DNSRecords apijson.Field - NSName apijson.Field - Status apijson.Field - ZoneTag apijson.Field - NSSet apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverVerifyResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverVerifyResponseJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverVerifyResponseDNSRecord struct { - // DNS record type. - Type CustomNameserverVerifyResponseDNSRecordsType `json:"type"` - // DNS record contents (an IPv4 or IPv6 address). - Value string `json:"value"` - JSON customNameserverVerifyResponseDNSRecordJSON `json:"-"` -} - -// customNameserverVerifyResponseDNSRecordJSON contains the JSON metadata for the -// struct [CustomNameserverVerifyResponseDNSRecord] -type customNameserverVerifyResponseDNSRecordJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverVerifyResponseDNSRecord) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverVerifyResponseDNSRecordJSON) RawJSON() string { - return r.raw -} - -// DNS record type. -type CustomNameserverVerifyResponseDNSRecordsType string - -const ( - CustomNameserverVerifyResponseDNSRecordsTypeA CustomNameserverVerifyResponseDNSRecordsType = "A" - CustomNameserverVerifyResponseDNSRecordsTypeAAAA CustomNameserverVerifyResponseDNSRecordsType = "AAAA" -) - -// Verification status of the nameserver. -type CustomNameserverVerifyResponseStatus string - -const ( - CustomNameserverVerifyResponseStatusMoved CustomNameserverVerifyResponseStatus = "moved" - CustomNameserverVerifyResponseStatusPending CustomNameserverVerifyResponseStatus = "pending" - CustomNameserverVerifyResponseStatusVerified CustomNameserverVerifyResponseStatus = "verified" -) - -type CustomNameserverNewParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // The FQDN of the name server. - NSName param.Field[string] `json:"ns_name,required" format:"hostname"` - // The number of the set that this name server belongs to. - NSSet param.Field[float64] `json:"ns_set"` -} - -func (r CustomNameserverNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type CustomNameserverNewResponseEnvelope struct { - Errors []CustomNameserverNewResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomNameserverNewResponseEnvelopeMessages `json:"messages,required"` - // A single account custom nameserver. - Result CustomNameserverNewResponse `json:"result,required"` - // Whether the API call was successful - Success CustomNameserverNewResponseEnvelopeSuccess `json:"success,required"` - JSON customNameserverNewResponseEnvelopeJSON `json:"-"` -} - -// customNameserverNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [CustomNameserverNewResponseEnvelope] -type customNameserverNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// customNameserverNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CustomNameserverNewResponseEnvelopeErrors] -type customNameserverNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// customNameserverNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [CustomNameserverNewResponseEnvelopeMessages] -type customNameserverNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CustomNameserverNewResponseEnvelopeSuccess bool - -const ( - CustomNameserverNewResponseEnvelopeSuccessTrue CustomNameserverNewResponseEnvelopeSuccess = true -) - -type CustomNameserverDeleteParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type CustomNameserverDeleteResponseEnvelope struct { - Errors []CustomNameserverDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomNameserverDeleteResponseEnvelopeMessages `json:"messages,required"` - Result CustomNameserverDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success CustomNameserverDeleteResponseEnvelopeSuccess `json:"success,required"` - ResultInfo CustomNameserverDeleteResponseEnvelopeResultInfo `json:"result_info"` - JSON customNameserverDeleteResponseEnvelopeJSON `json:"-"` -} - -// customNameserverDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [CustomNameserverDeleteResponseEnvelope] -type customNameserverDeleteResponseEnvelopeJSON 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 *CustomNameserverDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// customNameserverDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CustomNameserverDeleteResponseEnvelopeErrors] -type customNameserverDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// customNameserverDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [CustomNameserverDeleteResponseEnvelopeMessages] -type customNameserverDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CustomNameserverDeleteResponseEnvelopeSuccess bool - -const ( - CustomNameserverDeleteResponseEnvelopeSuccessTrue CustomNameserverDeleteResponseEnvelopeSuccess = true -) - -type CustomNameserverDeleteResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON customNameserverDeleteResponseEnvelopeResultInfoJSON `json:"-"` -} - -// customNameserverDeleteResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [CustomNameserverDeleteResponseEnvelopeResultInfo] -type customNameserverDeleteResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverAvailabiltyParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type CustomNameserverAvailabiltyResponseEnvelope struct { - Errors []CustomNameserverAvailabiltyResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomNameserverAvailabiltyResponseEnvelopeMessages `json:"messages,required"` - Result []string `json:"result,required,nullable" format:"hostname"` - // Whether the API call was successful - Success CustomNameserverAvailabiltyResponseEnvelopeSuccess `json:"success,required"` - ResultInfo CustomNameserverAvailabiltyResponseEnvelopeResultInfo `json:"result_info"` - JSON customNameserverAvailabiltyResponseEnvelopeJSON `json:"-"` -} - -// customNameserverAvailabiltyResponseEnvelopeJSON contains the JSON metadata for -// the struct [CustomNameserverAvailabiltyResponseEnvelope] -type customNameserverAvailabiltyResponseEnvelopeJSON 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 *CustomNameserverAvailabiltyResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverAvailabiltyResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverAvailabiltyResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverAvailabiltyResponseEnvelopeErrorsJSON `json:"-"` -} - -// customNameserverAvailabiltyResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [CustomNameserverAvailabiltyResponseEnvelopeErrors] -type customNameserverAvailabiltyResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverAvailabiltyResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverAvailabiltyResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverAvailabiltyResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverAvailabiltyResponseEnvelopeMessagesJSON `json:"-"` -} - -// customNameserverAvailabiltyResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [CustomNameserverAvailabiltyResponseEnvelopeMessages] -type customNameserverAvailabiltyResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverAvailabiltyResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverAvailabiltyResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CustomNameserverAvailabiltyResponseEnvelopeSuccess bool - -const ( - CustomNameserverAvailabiltyResponseEnvelopeSuccessTrue CustomNameserverAvailabiltyResponseEnvelopeSuccess = true -) - -type CustomNameserverAvailabiltyResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON customNameserverAvailabiltyResponseEnvelopeResultInfoJSON `json:"-"` -} - -// customNameserverAvailabiltyResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [CustomNameserverAvailabiltyResponseEnvelopeResultInfo] -type customNameserverAvailabiltyResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverAvailabiltyResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverAvailabiltyResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverGetParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type CustomNameserverGetResponseEnvelope struct { - Errors []CustomNameserverGetResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomNameserverGetResponseEnvelopeMessages `json:"messages,required"` - Result []CustomNameserverGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success CustomNameserverGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo CustomNameserverGetResponseEnvelopeResultInfo `json:"result_info"` - JSON customNameserverGetResponseEnvelopeJSON `json:"-"` -} - -// customNameserverGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [CustomNameserverGetResponseEnvelope] -type customNameserverGetResponseEnvelopeJSON 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 *CustomNameserverGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// customNameserverGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [CustomNameserverGetResponseEnvelopeErrors] -type customNameserverGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// customNameserverGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [CustomNameserverGetResponseEnvelopeMessages] -type customNameserverGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CustomNameserverGetResponseEnvelopeSuccess bool - -const ( - CustomNameserverGetResponseEnvelopeSuccessTrue CustomNameserverGetResponseEnvelopeSuccess = true -) - -type CustomNameserverGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON customNameserverGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// customNameserverGetResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [CustomNameserverGetResponseEnvelopeResultInfo] -type customNameserverGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverVerifyParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type CustomNameserverVerifyResponseEnvelope struct { - Errors []CustomNameserverVerifyResponseEnvelopeErrors `json:"errors,required"` - Messages []CustomNameserverVerifyResponseEnvelopeMessages `json:"messages,required"` - Result []CustomNameserverVerifyResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success CustomNameserverVerifyResponseEnvelopeSuccess `json:"success,required"` - ResultInfo CustomNameserverVerifyResponseEnvelopeResultInfo `json:"result_info"` - JSON customNameserverVerifyResponseEnvelopeJSON `json:"-"` -} - -// customNameserverVerifyResponseEnvelopeJSON contains the JSON metadata for the -// struct [CustomNameserverVerifyResponseEnvelope] -type customNameserverVerifyResponseEnvelopeJSON 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 *CustomNameserverVerifyResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverVerifyResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverVerifyResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverVerifyResponseEnvelopeErrorsJSON `json:"-"` -} - -// customNameserverVerifyResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [CustomNameserverVerifyResponseEnvelopeErrors] -type customNameserverVerifyResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverVerifyResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverVerifyResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type CustomNameserverVerifyResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON customNameserverVerifyResponseEnvelopeMessagesJSON `json:"-"` -} - -// customNameserverVerifyResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [CustomNameserverVerifyResponseEnvelopeMessages] -type customNameserverVerifyResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverVerifyResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverVerifyResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type CustomNameserverVerifyResponseEnvelopeSuccess bool - -const ( - CustomNameserverVerifyResponseEnvelopeSuccessTrue CustomNameserverVerifyResponseEnvelopeSuccess = true -) - -type CustomNameserverVerifyResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON customNameserverVerifyResponseEnvelopeResultInfoJSON `json:"-"` -} - -// customNameserverVerifyResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [CustomNameserverVerifyResponseEnvelopeResultInfo] -type customNameserverVerifyResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomNameserverVerifyResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customNameserverVerifyResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/customnameserver_test.go b/customnameserver_test.go deleted file mode 100644 index 2e657317c8d..00000000000 --- a/customnameserver_test.go +++ /dev/null @@ -1,150 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestCustomNameserverNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.CustomNameservers.New(context.TODO(), cloudflare.CustomNameserverNewParams{ - AccountID: cloudflare.F("372e67954025e0ba6aaa6d586b9e0b59"), - NSName: cloudflare.F("ns1.example.com"), - NSSet: cloudflare.F(1.000000), - }) - 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 TestCustomNameserverDelete(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("user@example.com"), - ) - _, err := client.CustomNameservers.Delete( - context.TODO(), - "ns1.example.com", - cloudflare.CustomNameserverDeleteParams{ - AccountID: cloudflare.F("372e67954025e0ba6aaa6d586b9e0b59"), - }, - ) - 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 TestCustomNameserverAvailabilty(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("user@example.com"), - ) - _, err := client.CustomNameservers.Availabilty(context.TODO(), cloudflare.CustomNameserverAvailabiltyParams{ - AccountID: cloudflare.F("372e67954025e0ba6aaa6d586b9e0b59"), - }) - 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 TestCustomNameserverGet(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("user@example.com"), - ) - _, err := client.CustomNameservers.Get(context.TODO(), cloudflare.CustomNameserverGetParams{ - AccountID: cloudflare.F("372e67954025e0ba6aaa6d586b9e0b59"), - }) - 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 TestCustomNameserverVerify(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("user@example.com"), - ) - _, err := client.CustomNameservers.Verify(context.TODO(), cloudflare.CustomNameserverVerifyParams{ - AccountID: cloudflare.F("372e67954025e0ba6aaa6d586b9e0b59"), - }) - 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/d1/aliases.go b/d1/aliases.go new file mode 100644 index 00000000000..6d6c5a665f5 --- /dev/null +++ b/d1/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package d1 + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/d1.go b/d1/d1.go similarity index 89% rename from d1.go rename to d1/d1.go index 47eaf321399..35b2f7c34ef 100644 --- a/d1.go +++ b/d1/d1.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package d1 import ( "github.com/cloudflare/cloudflare-go/option" @@ -12,7 +12,7 @@ import ( // directly, and instead use the [NewD1Service] method instead. type D1Service struct { Options []option.RequestOption - Database *D1DatabaseService + Database *DatabaseService } // NewD1Service generates a new service that applies the given options to each @@ -21,6 +21,6 @@ type D1Service struct { func NewD1Service(opts ...option.RequestOption) (r *D1Service) { r = &D1Service{} r.Options = opts - r.Database = NewD1DatabaseService(opts...) + r.Database = NewDatabaseService(opts...) return } diff --git a/d1/database.go b/d1/database.go new file mode 100644 index 00000000000..18e8fafa25c --- /dev/null +++ b/d1/database.go @@ -0,0 +1,607 @@ +// File generated from our OpenAPI spec by Stainless. + +package d1 + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// DatabaseService 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 [NewDatabaseService] method instead. +type DatabaseService struct { + Options []option.RequestOption +} + +// NewDatabaseService 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 NewDatabaseService(opts ...option.RequestOption) (r *DatabaseService) { + r = &DatabaseService{} + r.Options = opts + return +} + +// Returns the created D1 database. +func (r *DatabaseService) New(ctx context.Context, params DatabaseNewParams, opts ...option.RequestOption) (res *D1CreateDatabase, err error) { + opts = append(r.Options[:], opts...) + var env DatabaseNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/d1/database", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Returns a list of D1 databases. +func (r *DatabaseService) List(ctx context.Context, params DatabaseListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[D1CreateDatabase], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("accounts/%s/d1/database", params.AccountID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Returns a list of D1 databases. +func (r *DatabaseService) ListAutoPaging(ctx context.Context, params DatabaseListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[D1CreateDatabase] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) +} + +// Deletes the specified D1 database. +func (r *DatabaseService) Delete(ctx context.Context, accountIdentifier string, databaseIdentifier string, opts ...option.RequestOption) (res *DatabaseDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env DatabaseDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/d1/database/%s", accountIdentifier, databaseIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Returns the specified D1 database. +func (r *DatabaseService) Get(ctx context.Context, accountIdentifier string, databaseIdentifier string, opts ...option.RequestOption) (res *D1DatabaseDetails, err error) { + opts = append(r.Options[:], opts...) + var env DatabaseGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/d1/database/%s", accountIdentifier, databaseIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Returns the query result. +func (r *DatabaseService) Query(ctx context.Context, accountIdentifier string, databaseIdentifier string, body DatabaseQueryParams, opts ...option.RequestOption) (res *[]D1QueryResult, err error) { + opts = append(r.Options[:], opts...) + var env DatabaseQueryResponseEnvelope + path := fmt.Sprintf("accounts/%s/d1/database/%s/query", accountIdentifier, databaseIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type D1CreateDatabase struct { + // Specifies the timestamp the resource was created as an ISO8601 string. + CreatedAt interface{} `json:"created_at"` + Name string `json:"name"` + UUID string `json:"uuid"` + Version string `json:"version"` + JSON d1CreateDatabaseJSON `json:"-"` +} + +// d1CreateDatabaseJSON contains the JSON metadata for the struct +// [D1CreateDatabase] +type d1CreateDatabaseJSON struct { + CreatedAt apijson.Field + Name apijson.Field + UUID apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *D1CreateDatabase) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r d1CreateDatabaseJSON) RawJSON() string { + return r.raw +} + +type D1DatabaseDetails struct { + // Specifies the timestamp the resource was created as an ISO8601 string. + CreatedAt interface{} `json:"created_at"` + // The D1 database's size, in bytes. + FileSize float64 `json:"file_size"` + Name string `json:"name"` + NumTables float64 `json:"num_tables"` + UUID string `json:"uuid"` + Version string `json:"version"` + JSON d1DatabaseDetailsJSON `json:"-"` +} + +// d1DatabaseDetailsJSON contains the JSON metadata for the struct +// [D1DatabaseDetails] +type d1DatabaseDetailsJSON struct { + CreatedAt apijson.Field + FileSize apijson.Field + Name apijson.Field + NumTables apijson.Field + UUID apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *D1DatabaseDetails) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r d1DatabaseDetailsJSON) RawJSON() string { + return r.raw +} + +type D1QueryResult struct { + Meta D1QueryResultMeta `json:"meta"` + Results []interface{} `json:"results"` + Success bool `json:"success"` + JSON d1QueryResultJSON `json:"-"` +} + +// d1QueryResultJSON contains the JSON metadata for the struct [D1QueryResult] +type d1QueryResultJSON struct { + Meta apijson.Field + Results apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *D1QueryResult) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r d1QueryResultJSON) RawJSON() string { + return r.raw +} + +type D1QueryResultMeta struct { + ChangedDB bool `json:"changed_db"` + Changes float64 `json:"changes"` + Duration float64 `json:"duration"` + LastRowID float64 `json:"last_row_id"` + RowsRead float64 `json:"rows_read"` + RowsWritten float64 `json:"rows_written"` + SizeAfter float64 `json:"size_after"` + JSON d1QueryResultMetaJSON `json:"-"` +} + +// d1QueryResultMetaJSON contains the JSON metadata for the struct +// [D1QueryResultMeta] +type d1QueryResultMetaJSON struct { + ChangedDB apijson.Field + Changes apijson.Field + Duration apijson.Field + LastRowID apijson.Field + RowsRead apijson.Field + RowsWritten apijson.Field + SizeAfter apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *D1QueryResultMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r d1QueryResultMetaJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [d1.DatabaseDeleteResponseUnknown] or [shared.UnionString]. +type DatabaseDeleteResponse interface { + ImplementsD1DatabaseDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DatabaseDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type DatabaseNewParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + Name param.Field[string] `json:"name,required"` +} + +func (r DatabaseNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DatabaseNewResponseEnvelope struct { + Errors []DatabaseNewResponseEnvelopeErrors `json:"errors,required"` + Messages []DatabaseNewResponseEnvelopeMessages `json:"messages,required"` + Result D1CreateDatabase `json:"result,required"` + // Whether the API call was successful + Success DatabaseNewResponseEnvelopeSuccess `json:"success,required"` + JSON databaseNewResponseEnvelopeJSON `json:"-"` +} + +// databaseNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [DatabaseNewResponseEnvelope] +type databaseNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatabaseNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r databaseNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DatabaseNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON databaseNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// databaseNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [DatabaseNewResponseEnvelopeErrors] +type databaseNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatabaseNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r databaseNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DatabaseNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON databaseNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// databaseNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DatabaseNewResponseEnvelopeMessages] +type databaseNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatabaseNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r databaseNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DatabaseNewResponseEnvelopeSuccess bool + +const ( + DatabaseNewResponseEnvelopeSuccessTrue DatabaseNewResponseEnvelopeSuccess = true +) + +type DatabaseListParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + // a database name to search for. + Name param.Field[string] `query:"name"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // Number of items per page. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [DatabaseListParams]'s query parameters as `url.Values`. +func (r DatabaseListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type DatabaseDeleteResponseEnvelope struct { + Errors []DatabaseDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []DatabaseDeleteResponseEnvelopeMessages `json:"messages,required"` + Result DatabaseDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success DatabaseDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON databaseDeleteResponseEnvelopeJSON `json:"-"` +} + +// databaseDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [DatabaseDeleteResponseEnvelope] +type databaseDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatabaseDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r databaseDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DatabaseDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON databaseDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// databaseDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DatabaseDeleteResponseEnvelopeErrors] +type databaseDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatabaseDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r databaseDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DatabaseDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON databaseDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// databaseDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DatabaseDeleteResponseEnvelopeMessages] +type databaseDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatabaseDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r databaseDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DatabaseDeleteResponseEnvelopeSuccess bool + +const ( + DatabaseDeleteResponseEnvelopeSuccessTrue DatabaseDeleteResponseEnvelopeSuccess = true +) + +type DatabaseGetResponseEnvelope struct { + Errors []DatabaseGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DatabaseGetResponseEnvelopeMessages `json:"messages,required"` + Result D1DatabaseDetails `json:"result,required"` + // Whether the API call was successful + Success DatabaseGetResponseEnvelopeSuccess `json:"success,required"` + JSON databaseGetResponseEnvelopeJSON `json:"-"` +} + +// databaseGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DatabaseGetResponseEnvelope] +type databaseGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatabaseGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r databaseGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DatabaseGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON databaseGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// databaseGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [DatabaseGetResponseEnvelopeErrors] +type databaseGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatabaseGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r databaseGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DatabaseGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON databaseGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// databaseGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DatabaseGetResponseEnvelopeMessages] +type databaseGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatabaseGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r databaseGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DatabaseGetResponseEnvelopeSuccess bool + +const ( + DatabaseGetResponseEnvelopeSuccessTrue DatabaseGetResponseEnvelopeSuccess = true +) + +type DatabaseQueryParams struct { + Sql param.Field[string] `json:"sql,required"` + Params param.Field[[]string] `json:"params"` +} + +func (r DatabaseQueryParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DatabaseQueryResponseEnvelope struct { + Errors []DatabaseQueryResponseEnvelopeErrors `json:"errors,required"` + Messages []DatabaseQueryResponseEnvelopeMessages `json:"messages,required"` + Result []D1QueryResult `json:"result,required"` + // Whether the API call was successful + Success DatabaseQueryResponseEnvelopeSuccess `json:"success,required"` + JSON databaseQueryResponseEnvelopeJSON `json:"-"` +} + +// databaseQueryResponseEnvelopeJSON contains the JSON metadata for the struct +// [DatabaseQueryResponseEnvelope] +type databaseQueryResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatabaseQueryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r databaseQueryResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DatabaseQueryResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON databaseQueryResponseEnvelopeErrorsJSON `json:"-"` +} + +// databaseQueryResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DatabaseQueryResponseEnvelopeErrors] +type databaseQueryResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatabaseQueryResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r databaseQueryResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DatabaseQueryResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON databaseQueryResponseEnvelopeMessagesJSON `json:"-"` +} + +// databaseQueryResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DatabaseQueryResponseEnvelopeMessages] +type databaseQueryResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatabaseQueryResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r databaseQueryResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DatabaseQueryResponseEnvelopeSuccess bool + +const ( + DatabaseQueryResponseEnvelopeSuccessTrue DatabaseQueryResponseEnvelopeSuccess = true +) diff --git a/d1/database_test.go b/d1/database_test.go new file mode 100644 index 00000000000..00fe4c2f55e --- /dev/null +++ b/d1/database_test.go @@ -0,0 +1,159 @@ +// File generated from our OpenAPI spec by Stainless. + +package d1_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/d1" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestDatabaseNew(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("user@example.com"), + ) + _, err := client.D1.Database.New(context.TODO(), d1.DatabaseNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Name: cloudflare.F("my-database"), + }) + 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 TestDatabaseListWithOptionalParams(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("user@example.com"), + ) + _, err := client.D1.Database.List(context.TODO(), d1.DatabaseListParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Name: cloudflare.F("string"), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(10.000000), + }) + 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 TestDatabaseDelete(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("user@example.com"), + ) + _, err := client.D1.Database.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + 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 TestDatabaseGet(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("user@example.com"), + ) + _, err := client.D1.Database.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + ) + 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 TestDatabaseQueryWithOptionalParams(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("user@example.com"), + ) + _, err := client.D1.Database.Query( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + d1.DatabaseQueryParams{ + Sql: cloudflare.F("SELECT * FROM myTable WHERE field = ? OR field = ?;"), + Params: cloudflare.F([]string{"firstParam", "secondParam"}), + }, + ) + 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/d1database.go b/d1database.go deleted file mode 100644 index 5d430d7fc34..00000000000 --- a/d1database.go +++ /dev/null @@ -1,636 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// D1DatabaseService 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 [NewD1DatabaseService] method instead. -type D1DatabaseService struct { - Options []option.RequestOption -} - -// NewD1DatabaseService 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 NewD1DatabaseService(opts ...option.RequestOption) (r *D1DatabaseService) { - r = &D1DatabaseService{} - r.Options = opts - return -} - -// Returns the created D1 database. -func (r *D1DatabaseService) New(ctx context.Context, params D1DatabaseNewParams, opts ...option.RequestOption) (res *D1DatabaseNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env D1DatabaseNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/d1/database", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Returns a list of D1 databases. -func (r *D1DatabaseService) List(ctx context.Context, params D1DatabaseListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[D1DatabaseListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("accounts/%s/d1/database", params.AccountID) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Returns a list of D1 databases. -func (r *D1DatabaseService) ListAutoPaging(ctx context.Context, params D1DatabaseListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[D1DatabaseListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) -} - -// Deletes the specified D1 database. -func (r *D1DatabaseService) Delete(ctx context.Context, accountIdentifier string, databaseIdentifier string, opts ...option.RequestOption) (res *D1DatabaseDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env D1DatabaseDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/d1/database/%s", accountIdentifier, databaseIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Returns the specified D1 database. -func (r *D1DatabaseService) Get(ctx context.Context, accountIdentifier string, databaseIdentifier string, opts ...option.RequestOption) (res *D1DatabaseGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env D1DatabaseGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/d1/database/%s", accountIdentifier, databaseIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Returns the query result. -func (r *D1DatabaseService) Query(ctx context.Context, accountIdentifier string, databaseIdentifier string, body D1DatabaseQueryParams, opts ...option.RequestOption) (res *[]D1DatabaseQueryResponse, err error) { - opts = append(r.Options[:], opts...) - var env D1DatabaseQueryResponseEnvelope - path := fmt.Sprintf("accounts/%s/d1/database/%s/query", accountIdentifier, databaseIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type D1DatabaseNewResponse struct { - // Specifies the timestamp the resource was created as an ISO8601 string. - CreatedAt interface{} `json:"created_at"` - Name string `json:"name"` - UUID string `json:"uuid"` - Version string `json:"version"` - JSON d1DatabaseNewResponseJSON `json:"-"` -} - -// d1DatabaseNewResponseJSON contains the JSON metadata for the struct -// [D1DatabaseNewResponse] -type d1DatabaseNewResponseJSON struct { - CreatedAt apijson.Field - Name apijson.Field - UUID apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *D1DatabaseNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r d1DatabaseNewResponseJSON) RawJSON() string { - return r.raw -} - -type D1DatabaseListResponse struct { - // Specifies the timestamp the resource was created as an ISO8601 string. - CreatedAt interface{} `json:"created_at"` - Name string `json:"name"` - UUID string `json:"uuid"` - Version string `json:"version"` - JSON d1DatabaseListResponseJSON `json:"-"` -} - -// d1DatabaseListResponseJSON contains the JSON metadata for the struct -// [D1DatabaseListResponse] -type d1DatabaseListResponseJSON struct { - CreatedAt apijson.Field - Name apijson.Field - UUID apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *D1DatabaseListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r d1DatabaseListResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [D1DatabaseDeleteResponseUnknown] or [shared.UnionString]. -type D1DatabaseDeleteResponse interface { - ImplementsD1DatabaseDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*D1DatabaseDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type D1DatabaseGetResponse struct { - // Specifies the timestamp the resource was created as an ISO8601 string. - CreatedAt interface{} `json:"created_at"` - // The D1 database's size, in bytes. - FileSize float64 `json:"file_size"` - Name string `json:"name"` - NumTables float64 `json:"num_tables"` - UUID string `json:"uuid"` - Version string `json:"version"` - JSON d1DatabaseGetResponseJSON `json:"-"` -} - -// d1DatabaseGetResponseJSON contains the JSON metadata for the struct -// [D1DatabaseGetResponse] -type d1DatabaseGetResponseJSON struct { - CreatedAt apijson.Field - FileSize apijson.Field - Name apijson.Field - NumTables apijson.Field - UUID apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *D1DatabaseGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r d1DatabaseGetResponseJSON) RawJSON() string { - return r.raw -} - -type D1DatabaseQueryResponse struct { - Meta D1DatabaseQueryResponseMeta `json:"meta"` - Results []interface{} `json:"results"` - Success bool `json:"success"` - JSON d1DatabaseQueryResponseJSON `json:"-"` -} - -// d1DatabaseQueryResponseJSON contains the JSON metadata for the struct -// [D1DatabaseQueryResponse] -type d1DatabaseQueryResponseJSON struct { - Meta apijson.Field - Results apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *D1DatabaseQueryResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r d1DatabaseQueryResponseJSON) RawJSON() string { - return r.raw -} - -type D1DatabaseQueryResponseMeta struct { - ChangedDB bool `json:"changed_db"` - Changes float64 `json:"changes"` - Duration float64 `json:"duration"` - LastRowID float64 `json:"last_row_id"` - RowsRead float64 `json:"rows_read"` - RowsWritten float64 `json:"rows_written"` - SizeAfter float64 `json:"size_after"` - JSON d1DatabaseQueryResponseMetaJSON `json:"-"` -} - -// d1DatabaseQueryResponseMetaJSON contains the JSON metadata for the struct -// [D1DatabaseQueryResponseMeta] -type d1DatabaseQueryResponseMetaJSON struct { - ChangedDB apijson.Field - Changes apijson.Field - Duration apijson.Field - LastRowID apijson.Field - RowsRead apijson.Field - RowsWritten apijson.Field - SizeAfter apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *D1DatabaseQueryResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r d1DatabaseQueryResponseMetaJSON) RawJSON() string { - return r.raw -} - -type D1DatabaseNewParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - Name param.Field[string] `json:"name,required"` -} - -func (r D1DatabaseNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type D1DatabaseNewResponseEnvelope struct { - Errors []D1DatabaseNewResponseEnvelopeErrors `json:"errors,required"` - Messages []D1DatabaseNewResponseEnvelopeMessages `json:"messages,required"` - Result D1DatabaseNewResponse `json:"result,required"` - // Whether the API call was successful - Success D1DatabaseNewResponseEnvelopeSuccess `json:"success,required"` - JSON d1DatabaseNewResponseEnvelopeJSON `json:"-"` -} - -// d1DatabaseNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [D1DatabaseNewResponseEnvelope] -type d1DatabaseNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *D1DatabaseNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r d1DatabaseNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type D1DatabaseNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON d1DatabaseNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// d1DatabaseNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [D1DatabaseNewResponseEnvelopeErrors] -type d1DatabaseNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *D1DatabaseNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r d1DatabaseNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type D1DatabaseNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON d1DatabaseNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// d1DatabaseNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [D1DatabaseNewResponseEnvelopeMessages] -type d1DatabaseNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *D1DatabaseNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r d1DatabaseNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type D1DatabaseNewResponseEnvelopeSuccess bool - -const ( - D1DatabaseNewResponseEnvelopeSuccessTrue D1DatabaseNewResponseEnvelopeSuccess = true -) - -type D1DatabaseListParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // a database name to search for. - Name param.Field[string] `query:"name"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // Number of items per page. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [D1DatabaseListParams]'s query parameters as `url.Values`. -func (r D1DatabaseListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type D1DatabaseDeleteResponseEnvelope struct { - Errors []D1DatabaseDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []D1DatabaseDeleteResponseEnvelopeMessages `json:"messages,required"` - Result D1DatabaseDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success D1DatabaseDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON d1DatabaseDeleteResponseEnvelopeJSON `json:"-"` -} - -// d1DatabaseDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [D1DatabaseDeleteResponseEnvelope] -type d1DatabaseDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *D1DatabaseDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r d1DatabaseDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type D1DatabaseDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON d1DatabaseDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// d1DatabaseDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [D1DatabaseDeleteResponseEnvelopeErrors] -type d1DatabaseDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *D1DatabaseDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r d1DatabaseDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type D1DatabaseDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON d1DatabaseDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// d1DatabaseDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [D1DatabaseDeleteResponseEnvelopeMessages] -type d1DatabaseDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *D1DatabaseDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r d1DatabaseDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type D1DatabaseDeleteResponseEnvelopeSuccess bool - -const ( - D1DatabaseDeleteResponseEnvelopeSuccessTrue D1DatabaseDeleteResponseEnvelopeSuccess = true -) - -type D1DatabaseGetResponseEnvelope struct { - Errors []D1DatabaseGetResponseEnvelopeErrors `json:"errors,required"` - Messages []D1DatabaseGetResponseEnvelopeMessages `json:"messages,required"` - Result D1DatabaseGetResponse `json:"result,required"` - // Whether the API call was successful - Success D1DatabaseGetResponseEnvelopeSuccess `json:"success,required"` - JSON d1DatabaseGetResponseEnvelopeJSON `json:"-"` -} - -// d1DatabaseGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [D1DatabaseGetResponseEnvelope] -type d1DatabaseGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *D1DatabaseGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r d1DatabaseGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type D1DatabaseGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON d1DatabaseGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// d1DatabaseGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [D1DatabaseGetResponseEnvelopeErrors] -type d1DatabaseGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *D1DatabaseGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r d1DatabaseGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type D1DatabaseGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON d1DatabaseGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// d1DatabaseGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [D1DatabaseGetResponseEnvelopeMessages] -type d1DatabaseGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *D1DatabaseGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r d1DatabaseGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type D1DatabaseGetResponseEnvelopeSuccess bool - -const ( - D1DatabaseGetResponseEnvelopeSuccessTrue D1DatabaseGetResponseEnvelopeSuccess = true -) - -type D1DatabaseQueryParams struct { - Sql param.Field[string] `json:"sql,required"` - Params param.Field[[]string] `json:"params"` -} - -func (r D1DatabaseQueryParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type D1DatabaseQueryResponseEnvelope struct { - Errors []D1DatabaseQueryResponseEnvelopeErrors `json:"errors,required"` - Messages []D1DatabaseQueryResponseEnvelopeMessages `json:"messages,required"` - Result []D1DatabaseQueryResponse `json:"result,required"` - // Whether the API call was successful - Success D1DatabaseQueryResponseEnvelopeSuccess `json:"success,required"` - JSON d1DatabaseQueryResponseEnvelopeJSON `json:"-"` -} - -// d1DatabaseQueryResponseEnvelopeJSON contains the JSON metadata for the struct -// [D1DatabaseQueryResponseEnvelope] -type d1DatabaseQueryResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *D1DatabaseQueryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r d1DatabaseQueryResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type D1DatabaseQueryResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON d1DatabaseQueryResponseEnvelopeErrorsJSON `json:"-"` -} - -// d1DatabaseQueryResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [D1DatabaseQueryResponseEnvelopeErrors] -type d1DatabaseQueryResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *D1DatabaseQueryResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r d1DatabaseQueryResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type D1DatabaseQueryResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON d1DatabaseQueryResponseEnvelopeMessagesJSON `json:"-"` -} - -// d1DatabaseQueryResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [D1DatabaseQueryResponseEnvelopeMessages] -type d1DatabaseQueryResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *D1DatabaseQueryResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r d1DatabaseQueryResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type D1DatabaseQueryResponseEnvelopeSuccess bool - -const ( - D1DatabaseQueryResponseEnvelopeSuccessTrue D1DatabaseQueryResponseEnvelopeSuccess = true -) diff --git a/d1database_test.go b/d1database_test.go deleted file mode 100644 index ccebc0cb21d..00000000000 --- a/d1database_test.go +++ /dev/null @@ -1,158 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestD1DatabaseNew(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("user@example.com"), - ) - _, err := client.D1.Database.New(context.TODO(), cloudflare.D1DatabaseNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Name: cloudflare.F("my-database"), - }) - 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 TestD1DatabaseListWithOptionalParams(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("user@example.com"), - ) - _, err := client.D1.Database.List(context.TODO(), cloudflare.D1DatabaseListParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Name: cloudflare.F("string"), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(10.000000), - }) - 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 TestD1DatabaseDelete(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("user@example.com"), - ) - _, err := client.D1.Database.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - ) - 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 TestD1DatabaseGet(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("user@example.com"), - ) - _, err := client.D1.Database.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - ) - 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 TestD1DatabaseQueryWithOptionalParams(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("user@example.com"), - ) - _, err := client.D1.Database.Query( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - cloudflare.D1DatabaseQueryParams{ - Sql: cloudflare.F("SELECT * FROM myTable WHERE field = ? OR field = ?;"), - Params: cloudflare.F([]string{"firstParam", "secondParam"}), - }, - ) - 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/dcv_delegation/aliases.go b/dcv_delegation/aliases.go new file mode 100644 index 00000000000..e365dceb676 --- /dev/null +++ b/dcv_delegation/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package dcv_delegation + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/dcvdelegation.go b/dcv_delegation/dcvdelegation.go similarity index 89% rename from dcvdelegation.go rename to dcv_delegation/dcvdelegation.go index ff863b54cd2..cdf95b048ff 100644 --- a/dcvdelegation.go +++ b/dcv_delegation/dcvdelegation.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package dcv_delegation import ( "github.com/cloudflare/cloudflare-go/option" @@ -13,7 +13,7 @@ import ( // instead. type DCVDelegationService struct { Options []option.RequestOption - UUID *DCVDelegationUUIDService + UUID *UUIDService } // NewDCVDelegationService generates a new service that applies the given options @@ -22,6 +22,6 @@ type DCVDelegationService struct { func NewDCVDelegationService(opts ...option.RequestOption) (r *DCVDelegationService) { r = &DCVDelegationService{} r.Options = opts - r.UUID = NewDCVDelegationUUIDService(opts...) + r.UUID = NewUUIDService(opts...) return } diff --git a/dcv_delegation/uuid.go b/dcv_delegation/uuid.go new file mode 100644 index 00000000000..0bfa6d1c918 --- /dev/null +++ b/dcv_delegation/uuid.go @@ -0,0 +1,153 @@ +// File generated from our OpenAPI spec by Stainless. + +package dcv_delegation + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// UUIDService 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 [NewUUIDService] method instead. +type UUIDService struct { + Options []option.RequestOption +} + +// NewUUIDService 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 NewUUIDService(opts ...option.RequestOption) (r *UUIDService) { + r = &UUIDService{} + r.Options = opts + return +} + +// Retrieve the account and zone specific unique identifier used as part of the +// CNAME target for DCV Delegation. +func (r *UUIDService) Get(ctx context.Context, query UUIDGetParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesUUIDObject, err error) { + opts = append(r.Options[:], opts...) + var env UUIDGetResponseEnvelope + path := fmt.Sprintf("zones/%s/dcv_delegation/uuid", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TLSCertificatesAndHostnamesUUIDObject struct { + // The DCV Delegation unique identifier. + UUID string `json:"uuid"` + JSON tlsCertificatesAndHostnamesUUIDObjectJSON `json:"-"` +} + +// tlsCertificatesAndHostnamesUUIDObjectJSON contains the JSON metadata for the +// struct [TLSCertificatesAndHostnamesUUIDObject] +type tlsCertificatesAndHostnamesUUIDObjectJSON struct { + UUID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TLSCertificatesAndHostnamesUUIDObject) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tlsCertificatesAndHostnamesUUIDObjectJSON) RawJSON() string { + return r.raw +} + +type UUIDGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type UUIDGetResponseEnvelope struct { + Errors []UUIDGetResponseEnvelopeErrors `json:"errors,required"` + Messages []UUIDGetResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesUUIDObject `json:"result,required"` + // Whether the API call was successful + Success UUIDGetResponseEnvelopeSuccess `json:"success,required"` + JSON uuidGetResponseEnvelopeJSON `json:"-"` +} + +// uuidGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [UUIDGetResponseEnvelope] +type uuidGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UUIDGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uuidGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type UUIDGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON uuidGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// uuidGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [UUIDGetResponseEnvelopeErrors] +type uuidGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UUIDGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uuidGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type UUIDGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON uuidGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// uuidGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [UUIDGetResponseEnvelopeMessages] +type uuidGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UUIDGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uuidGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type UUIDGetResponseEnvelopeSuccess bool + +const ( + UUIDGetResponseEnvelopeSuccessTrue UUIDGetResponseEnvelopeSuccess = true +) diff --git a/dcv_delegation/uuid_test.go b/dcv_delegation/uuid_test.go new file mode 100644 index 00000000000..95aef6f6db3 --- /dev/null +++ b/dcv_delegation/uuid_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package dcv_delegation_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/dcv_delegation" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestUUIDGet(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("user@example.com"), + ) + _, err := client.DCVDelegation.UUID.Get(context.TODO(), dcv_delegation.UUIDGetParams{ + ZoneID: cloudflare.F("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/dcvdelegationuuid.go b/dcvdelegationuuid.go deleted file mode 100644 index f5df0292fcc..00000000000 --- a/dcvdelegationuuid.go +++ /dev/null @@ -1,154 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// DCVDelegationUUIDService 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 [NewDCVDelegationUUIDService] method -// instead. -type DCVDelegationUUIDService struct { - Options []option.RequestOption -} - -// NewDCVDelegationUUIDService 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 NewDCVDelegationUUIDService(opts ...option.RequestOption) (r *DCVDelegationUUIDService) { - r = &DCVDelegationUUIDService{} - r.Options = opts - return -} - -// Retrieve the account and zone specific unique identifier used as part of the -// CNAME target for DCV Delegation. -func (r *DCVDelegationUUIDService) Get(ctx context.Context, query DCVDelegationUUIDGetParams, opts ...option.RequestOption) (res *DCVDelegationUUIDGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env DCVDelegationUUIDGetResponseEnvelope - path := fmt.Sprintf("zones/%s/dcv_delegation/uuid", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type DCVDelegationUUIDGetResponse struct { - // The DCV Delegation unique identifier. - UUID string `json:"uuid"` - JSON dcvDelegationUUIDGetResponseJSON `json:"-"` -} - -// dcvDelegationUUIDGetResponseJSON contains the JSON metadata for the struct -// [DCVDelegationUUIDGetResponse] -type dcvDelegationUUIDGetResponseJSON struct { - UUID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DCVDelegationUUIDGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dcvDelegationUUIDGetResponseJSON) RawJSON() string { - return r.raw -} - -type DCVDelegationUUIDGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type DCVDelegationUUIDGetResponseEnvelope struct { - Errors []DCVDelegationUUIDGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DCVDelegationUUIDGetResponseEnvelopeMessages `json:"messages,required"` - Result DCVDelegationUUIDGetResponse `json:"result,required"` - // Whether the API call was successful - Success DCVDelegationUUIDGetResponseEnvelopeSuccess `json:"success,required"` - JSON dcvDelegationUUIDGetResponseEnvelopeJSON `json:"-"` -} - -// dcvDelegationUUIDGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [DCVDelegationUUIDGetResponseEnvelope] -type dcvDelegationUUIDGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DCVDelegationUUIDGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dcvDelegationUUIDGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DCVDelegationUUIDGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dcvDelegationUUIDGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dcvDelegationUUIDGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DCVDelegationUUIDGetResponseEnvelopeErrors] -type dcvDelegationUUIDGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DCVDelegationUUIDGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dcvDelegationUUIDGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DCVDelegationUUIDGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dcvDelegationUUIDGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dcvDelegationUUIDGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DCVDelegationUUIDGetResponseEnvelopeMessages] -type dcvDelegationUUIDGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DCVDelegationUUIDGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dcvDelegationUUIDGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DCVDelegationUUIDGetResponseEnvelopeSuccess bool - -const ( - DCVDelegationUUIDGetResponseEnvelopeSuccessTrue DCVDelegationUUIDGetResponseEnvelopeSuccess = true -) diff --git a/dcvdelegationuuid_test.go b/dcvdelegationuuid_test.go deleted file mode 100644 index 3c1573c351f..00000000000 --- a/dcvdelegationuuid_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestDCVDelegationUUIDGet(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("user@example.com"), - ) - _, err := client.DCVDelegation.UUID.Get(context.TODO(), cloudflare.DCVDelegationUUIDGetParams{ - ZoneID: cloudflare.F("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/diagnostics/aliases.go b/diagnostics/aliases.go new file mode 100644 index 00000000000..ea9656ed49c --- /dev/null +++ b/diagnostics/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package diagnostics + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/diagnostic.go b/diagnostics/diagnostic.go similarity index 87% rename from diagnostic.go rename to diagnostics/diagnostic.go index 5321da515d5..3221f0dfd0b 100644 --- a/diagnostic.go +++ b/diagnostics/diagnostic.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package diagnostics import ( "github.com/cloudflare/cloudflare-go/option" @@ -12,7 +12,7 @@ import ( // service directly, and instead use the [NewDiagnosticService] method instead. type DiagnosticService struct { Options []option.RequestOption - Traceroutes *DiagnosticTracerouteService + Traceroutes *TracerouteService } // NewDiagnosticService generates a new service that applies the given options to @@ -21,6 +21,6 @@ type DiagnosticService struct { func NewDiagnosticService(opts ...option.RequestOption) (r *DiagnosticService) { r = &DiagnosticService{} r.Options = opts - r.Traceroutes = NewDiagnosticTracerouteService(opts...) + r.Traceroutes = NewTracerouteService(opts...) return } diff --git a/diagnostics/traceroute.go b/diagnostics/traceroute.go new file mode 100644 index 00000000000..ae0d591a300 --- /dev/null +++ b/diagnostics/traceroute.go @@ -0,0 +1,373 @@ +// File generated from our OpenAPI spec by Stainless. + +package diagnostics + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// TracerouteService 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 [NewTracerouteService] method instead. +type TracerouteService struct { + Options []option.RequestOption +} + +// NewTracerouteService 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 NewTracerouteService(opts ...option.RequestOption) (r *TracerouteService) { + r = &TracerouteService{} + r.Options = opts + return +} + +// Run traceroutes from Cloudflare colos. +func (r *TracerouteService) New(ctx context.Context, params TracerouteNewParams, opts ...option.RequestOption) (res *[]MagicTransitTargetResult, err error) { + opts = append(r.Options[:], opts...) + var env TracerouteNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/diagnostics/traceroute", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type MagicTransitTargetResult struct { + Colos []MagicTransitTargetResultColo `json:"colos"` + // The target hostname, IPv6, or IPv6 address. + Target string `json:"target"` + JSON magicTransitTargetResultJSON `json:"-"` +} + +// magicTransitTargetResultJSON contains the JSON metadata for the struct +// [MagicTransitTargetResult] +type magicTransitTargetResultJSON struct { + Colos apijson.Field + Target apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MagicTransitTargetResult) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r magicTransitTargetResultJSON) RawJSON() string { + return r.raw +} + +type MagicTransitTargetResultColo struct { + Colo MagicTransitTargetResultColosColo `json:"colo"` + // Errors resulting from collecting traceroute from colo to target. + Error MagicTransitTargetResultColosError `json:"error"` + Hops []MagicTransitTargetResultColosHop `json:"hops"` + // Aggregated statistics from all hops about the target. + TargetSummary interface{} `json:"target_summary"` + // Total time of traceroute in ms. + TracerouteTimeMs int64 `json:"traceroute_time_ms"` + JSON magicTransitTargetResultColoJSON `json:"-"` +} + +// magicTransitTargetResultColoJSON contains the JSON metadata for the struct +// [MagicTransitTargetResultColo] +type magicTransitTargetResultColoJSON struct { + Colo apijson.Field + Error apijson.Field + Hops apijson.Field + TargetSummary apijson.Field + TracerouteTimeMs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MagicTransitTargetResultColo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r magicTransitTargetResultColoJSON) RawJSON() string { + return r.raw +} + +type MagicTransitTargetResultColosColo struct { + // Source colo city. + City string `json:"city"` + // Source colo name. + Name string `json:"name"` + JSON magicTransitTargetResultColosColoJSON `json:"-"` +} + +// magicTransitTargetResultColosColoJSON contains the JSON metadata for the struct +// [MagicTransitTargetResultColosColo] +type magicTransitTargetResultColosColoJSON struct { + City apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MagicTransitTargetResultColosColo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r magicTransitTargetResultColosColoJSON) RawJSON() string { + return r.raw +} + +// Errors resulting from collecting traceroute from colo to target. +type MagicTransitTargetResultColosError string + +const ( + MagicTransitTargetResultColosErrorEmpty MagicTransitTargetResultColosError = "" + MagicTransitTargetResultColosErrorCouldNotGatherTracerouteDataCode1 MagicTransitTargetResultColosError = "Could not gather traceroute data: Code 1" + MagicTransitTargetResultColosErrorCouldNotGatherTracerouteDataCode2 MagicTransitTargetResultColosError = "Could not gather traceroute data: Code 2" + MagicTransitTargetResultColosErrorCouldNotGatherTracerouteDataCode3 MagicTransitTargetResultColosError = "Could not gather traceroute data: Code 3" + MagicTransitTargetResultColosErrorCouldNotGatherTracerouteDataCode4 MagicTransitTargetResultColosError = "Could not gather traceroute data: Code 4" +) + +type MagicTransitTargetResultColosHop struct { + // An array of node objects. + Nodes []MagicTransitTargetResultColosHopsNode `json:"nodes"` + // Number of packets where no response was received. + PacketsLost int64 `json:"packets_lost"` + // Number of packets sent with specified TTL. + PacketsSent int64 `json:"packets_sent"` + // The time to live (TTL). + PacketsTTL int64 `json:"packets_ttl"` + JSON magicTransitTargetResultColosHopJSON `json:"-"` +} + +// magicTransitTargetResultColosHopJSON contains the JSON metadata for the struct +// [MagicTransitTargetResultColosHop] +type magicTransitTargetResultColosHopJSON struct { + Nodes apijson.Field + PacketsLost apijson.Field + PacketsSent apijson.Field + PacketsTTL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MagicTransitTargetResultColosHop) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r magicTransitTargetResultColosHopJSON) RawJSON() string { + return r.raw +} + +type MagicTransitTargetResultColosHopsNode struct { + // AS number associated with the node object. + ASN string `json:"asn"` + // IP address of the node. + IP string `json:"ip"` + // Field appears if there is an additional annotation printed when the probe + // returns. Field also appears when running a GRE+ICMP traceroute to denote which + // traceroute a node comes from. + Labels []string `json:"labels"` + // Maximum RTT in ms. + MaxRTTMs float64 `json:"max_rtt_ms"` + // Mean RTT in ms. + MeanRTTMs float64 `json:"mean_rtt_ms"` + // Minimum RTT in ms. + MinRTTMs float64 `json:"min_rtt_ms"` + // Host name of the address, this may be the same as the IP address. + Name string `json:"name"` + // Number of packets with a response from this node. + PacketCount int64 `json:"packet_count"` + // Standard deviation of the RTTs in ms. + StdDevRTTMs float64 `json:"std_dev_rtt_ms"` + JSON magicTransitTargetResultColosHopsNodeJSON `json:"-"` +} + +// magicTransitTargetResultColosHopsNodeJSON contains the JSON metadata for the +// struct [MagicTransitTargetResultColosHopsNode] +type magicTransitTargetResultColosHopsNodeJSON struct { + ASN apijson.Field + IP apijson.Field + Labels apijson.Field + MaxRTTMs apijson.Field + MeanRTTMs apijson.Field + MinRTTMs apijson.Field + Name apijson.Field + PacketCount apijson.Field + StdDevRTTMs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MagicTransitTargetResultColosHopsNode) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r magicTransitTargetResultColosHopsNodeJSON) RawJSON() string { + return r.raw +} + +type TracerouteNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Targets param.Field[[]string] `json:"targets,required"` + // If no source colo names specified, all colos will be used. China colos are + // unavailable for traceroutes. + Colos param.Field[[]string] `json:"colos"` + Options param.Field[TracerouteNewParamsOptions] `json:"options"` +} + +func (r TracerouteNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type TracerouteNewParamsOptions struct { + // Max TTL. + MaxTTL param.Field[int64] `json:"max_ttl"` + // Type of packet sent. + PacketType param.Field[TracerouteNewParamsOptionsPacketType] `json:"packet_type"` + // Number of packets sent at each TTL. + PacketsPerTTL param.Field[int64] `json:"packets_per_ttl"` + // For UDP and TCP, specifies the destination port. For ICMP, specifies the initial + // ICMP sequence value. Default value 0 will choose the best value to use for each + // protocol. + Port param.Field[int64] `json:"port"` + // Set the time (in seconds) to wait for a response to a probe. + WaitTime param.Field[int64] `json:"wait_time"` +} + +func (r TracerouteNewParamsOptions) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Type of packet sent. +type TracerouteNewParamsOptionsPacketType string + +const ( + TracerouteNewParamsOptionsPacketTypeIcmp TracerouteNewParamsOptionsPacketType = "icmp" + TracerouteNewParamsOptionsPacketTypeTcp TracerouteNewParamsOptionsPacketType = "tcp" + TracerouteNewParamsOptionsPacketTypeUdp TracerouteNewParamsOptionsPacketType = "udp" + TracerouteNewParamsOptionsPacketTypeGRE TracerouteNewParamsOptionsPacketType = "gre" + TracerouteNewParamsOptionsPacketTypeGREIcmp TracerouteNewParamsOptionsPacketType = "gre+icmp" +) + +type TracerouteNewResponseEnvelope struct { + Errors []TracerouteNewResponseEnvelopeErrors `json:"errors,required"` + Messages []TracerouteNewResponseEnvelopeMessages `json:"messages,required"` + Result []MagicTransitTargetResult `json:"result,required,nullable"` + // Whether the API call was successful + Success TracerouteNewResponseEnvelopeSuccess `json:"success,required"` + ResultInfo TracerouteNewResponseEnvelopeResultInfo `json:"result_info"` + JSON tracerouteNewResponseEnvelopeJSON `json:"-"` +} + +// tracerouteNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [TracerouteNewResponseEnvelope] +type tracerouteNewResponseEnvelopeJSON 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 *TracerouteNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tracerouteNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TracerouteNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tracerouteNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// tracerouteNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [TracerouteNewResponseEnvelopeErrors] +type tracerouteNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TracerouteNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tracerouteNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TracerouteNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tracerouteNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// tracerouteNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [TracerouteNewResponseEnvelopeMessages] +type tracerouteNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TracerouteNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tracerouteNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TracerouteNewResponseEnvelopeSuccess bool + +const ( + TracerouteNewResponseEnvelopeSuccessTrue TracerouteNewResponseEnvelopeSuccess = true +) + +type TracerouteNewResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON tracerouteNewResponseEnvelopeResultInfoJSON `json:"-"` +} + +// tracerouteNewResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [TracerouteNewResponseEnvelopeResultInfo] +type tracerouteNewResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TracerouteNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tracerouteNewResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/diagnostics/traceroute_test.go b/diagnostics/traceroute_test.go new file mode 100644 index 00000000000..4df6185cd70 --- /dev/null +++ b/diagnostics/traceroute_test.go @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package diagnostics_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/diagnostics" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestTracerouteNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Diagnostics.Traceroutes.New(context.TODO(), diagnostics.TracerouteNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Targets: cloudflare.F([]string{"203.0.113.1", "cloudflare.com"}), + Colos: cloudflare.F([]string{"den", "sin"}), + Options: cloudflare.F(diagnostics.TracerouteNewParamsOptions{ + MaxTTL: cloudflare.F(int64(15)), + PacketType: cloudflare.F(diagnostics.TracerouteNewParamsOptionsPacketTypeIcmp), + PacketsPerTTL: cloudflare.F(int64(0)), + Port: cloudflare.F(int64(0)), + WaitTime: cloudflare.F(int64(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()) + } +} diff --git a/diagnostictraceroute.go b/diagnostictraceroute.go deleted file mode 100644 index 574b0d58302..00000000000 --- a/diagnostictraceroute.go +++ /dev/null @@ -1,374 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// DiagnosticTracerouteService 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 [NewDiagnosticTracerouteService] -// method instead. -type DiagnosticTracerouteService struct { - Options []option.RequestOption -} - -// NewDiagnosticTracerouteService 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 NewDiagnosticTracerouteService(opts ...option.RequestOption) (r *DiagnosticTracerouteService) { - r = &DiagnosticTracerouteService{} - r.Options = opts - return -} - -// Run traceroutes from Cloudflare colos. -func (r *DiagnosticTracerouteService) New(ctx context.Context, params DiagnosticTracerouteNewParams, opts ...option.RequestOption) (res *[]DiagnosticTracerouteNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env DiagnosticTracerouteNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/diagnostics/traceroute", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type DiagnosticTracerouteNewResponse struct { - Colos []DiagnosticTracerouteNewResponseColo `json:"colos"` - // The target hostname, IPv6, or IPv6 address. - Target string `json:"target"` - JSON diagnosticTracerouteNewResponseJSON `json:"-"` -} - -// diagnosticTracerouteNewResponseJSON contains the JSON metadata for the struct -// [DiagnosticTracerouteNewResponse] -type diagnosticTracerouteNewResponseJSON struct { - Colos apijson.Field - Target apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DiagnosticTracerouteNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r diagnosticTracerouteNewResponseJSON) RawJSON() string { - return r.raw -} - -type DiagnosticTracerouteNewResponseColo struct { - Colo DiagnosticTracerouteNewResponseColosColo `json:"colo"` - // Errors resulting from collecting traceroute from colo to target. - Error DiagnosticTracerouteNewResponseColosError `json:"error"` - Hops []DiagnosticTracerouteNewResponseColosHop `json:"hops"` - // Aggregated statistics from all hops about the target. - TargetSummary interface{} `json:"target_summary"` - // Total time of traceroute in ms. - TracerouteTimeMs int64 `json:"traceroute_time_ms"` - JSON diagnosticTracerouteNewResponseColoJSON `json:"-"` -} - -// diagnosticTracerouteNewResponseColoJSON contains the JSON metadata for the -// struct [DiagnosticTracerouteNewResponseColo] -type diagnosticTracerouteNewResponseColoJSON struct { - Colo apijson.Field - Error apijson.Field - Hops apijson.Field - TargetSummary apijson.Field - TracerouteTimeMs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DiagnosticTracerouteNewResponseColo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r diagnosticTracerouteNewResponseColoJSON) RawJSON() string { - return r.raw -} - -type DiagnosticTracerouteNewResponseColosColo struct { - // Source colo city. - City string `json:"city"` - // Source colo name. - Name string `json:"name"` - JSON diagnosticTracerouteNewResponseColosColoJSON `json:"-"` -} - -// diagnosticTracerouteNewResponseColosColoJSON contains the JSON metadata for the -// struct [DiagnosticTracerouteNewResponseColosColo] -type diagnosticTracerouteNewResponseColosColoJSON struct { - City apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DiagnosticTracerouteNewResponseColosColo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r diagnosticTracerouteNewResponseColosColoJSON) RawJSON() string { - return r.raw -} - -// Errors resulting from collecting traceroute from colo to target. -type DiagnosticTracerouteNewResponseColosError string - -const ( - DiagnosticTracerouteNewResponseColosErrorEmpty DiagnosticTracerouteNewResponseColosError = "" - DiagnosticTracerouteNewResponseColosErrorCouldNotGatherTracerouteDataCode1 DiagnosticTracerouteNewResponseColosError = "Could not gather traceroute data: Code 1" - DiagnosticTracerouteNewResponseColosErrorCouldNotGatherTracerouteDataCode2 DiagnosticTracerouteNewResponseColosError = "Could not gather traceroute data: Code 2" - DiagnosticTracerouteNewResponseColosErrorCouldNotGatherTracerouteDataCode3 DiagnosticTracerouteNewResponseColosError = "Could not gather traceroute data: Code 3" - DiagnosticTracerouteNewResponseColosErrorCouldNotGatherTracerouteDataCode4 DiagnosticTracerouteNewResponseColosError = "Could not gather traceroute data: Code 4" -) - -type DiagnosticTracerouteNewResponseColosHop struct { - // An array of node objects. - Nodes []DiagnosticTracerouteNewResponseColosHopsNode `json:"nodes"` - // Number of packets where no response was received. - PacketsLost int64 `json:"packets_lost"` - // Number of packets sent with specified TTL. - PacketsSent int64 `json:"packets_sent"` - // The time to live (TTL). - PacketsTTL int64 `json:"packets_ttl"` - JSON diagnosticTracerouteNewResponseColosHopJSON `json:"-"` -} - -// diagnosticTracerouteNewResponseColosHopJSON contains the JSON metadata for the -// struct [DiagnosticTracerouteNewResponseColosHop] -type diagnosticTracerouteNewResponseColosHopJSON struct { - Nodes apijson.Field - PacketsLost apijson.Field - PacketsSent apijson.Field - PacketsTTL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DiagnosticTracerouteNewResponseColosHop) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r diagnosticTracerouteNewResponseColosHopJSON) RawJSON() string { - return r.raw -} - -type DiagnosticTracerouteNewResponseColosHopsNode struct { - // AS number associated with the node object. - ASN string `json:"asn"` - // IP address of the node. - IP string `json:"ip"` - // Field appears if there is an additional annotation printed when the probe - // returns. Field also appears when running a GRE+ICMP traceroute to denote which - // traceroute a node comes from. - Labels []string `json:"labels"` - // Maximum RTT in ms. - MaxRTTMs float64 `json:"max_rtt_ms"` - // Mean RTT in ms. - MeanRTTMs float64 `json:"mean_rtt_ms"` - // Minimum RTT in ms. - MinRTTMs float64 `json:"min_rtt_ms"` - // Host name of the address, this may be the same as the IP address. - Name string `json:"name"` - // Number of packets with a response from this node. - PacketCount int64 `json:"packet_count"` - // Standard deviation of the RTTs in ms. - StdDevRTTMs float64 `json:"std_dev_rtt_ms"` - JSON diagnosticTracerouteNewResponseColosHopsNodeJSON `json:"-"` -} - -// diagnosticTracerouteNewResponseColosHopsNodeJSON contains the JSON metadata for -// the struct [DiagnosticTracerouteNewResponseColosHopsNode] -type diagnosticTracerouteNewResponseColosHopsNodeJSON struct { - ASN apijson.Field - IP apijson.Field - Labels apijson.Field - MaxRTTMs apijson.Field - MeanRTTMs apijson.Field - MinRTTMs apijson.Field - Name apijson.Field - PacketCount apijson.Field - StdDevRTTMs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DiagnosticTracerouteNewResponseColosHopsNode) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r diagnosticTracerouteNewResponseColosHopsNodeJSON) RawJSON() string { - return r.raw -} - -type DiagnosticTracerouteNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Targets param.Field[[]string] `json:"targets,required"` - // If no source colo names specified, all colos will be used. China colos are - // unavailable for traceroutes. - Colos param.Field[[]string] `json:"colos"` - Options param.Field[DiagnosticTracerouteNewParamsOptions] `json:"options"` -} - -func (r DiagnosticTracerouteNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type DiagnosticTracerouteNewParamsOptions struct { - // Max TTL. - MaxTTL param.Field[int64] `json:"max_ttl"` - // Type of packet sent. - PacketType param.Field[DiagnosticTracerouteNewParamsOptionsPacketType] `json:"packet_type"` - // Number of packets sent at each TTL. - PacketsPerTTL param.Field[int64] `json:"packets_per_ttl"` - // For UDP and TCP, specifies the destination port. For ICMP, specifies the initial - // ICMP sequence value. Default value 0 will choose the best value to use for each - // protocol. - Port param.Field[int64] `json:"port"` - // Set the time (in seconds) to wait for a response to a probe. - WaitTime param.Field[int64] `json:"wait_time"` -} - -func (r DiagnosticTracerouteNewParamsOptions) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Type of packet sent. -type DiagnosticTracerouteNewParamsOptionsPacketType string - -const ( - DiagnosticTracerouteNewParamsOptionsPacketTypeIcmp DiagnosticTracerouteNewParamsOptionsPacketType = "icmp" - DiagnosticTracerouteNewParamsOptionsPacketTypeTcp DiagnosticTracerouteNewParamsOptionsPacketType = "tcp" - DiagnosticTracerouteNewParamsOptionsPacketTypeUdp DiagnosticTracerouteNewParamsOptionsPacketType = "udp" - DiagnosticTracerouteNewParamsOptionsPacketTypeGRE DiagnosticTracerouteNewParamsOptionsPacketType = "gre" - DiagnosticTracerouteNewParamsOptionsPacketTypeGREIcmp DiagnosticTracerouteNewParamsOptionsPacketType = "gre+icmp" -) - -type DiagnosticTracerouteNewResponseEnvelope struct { - Errors []DiagnosticTracerouteNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DiagnosticTracerouteNewResponseEnvelopeMessages `json:"messages,required"` - Result []DiagnosticTracerouteNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success DiagnosticTracerouteNewResponseEnvelopeSuccess `json:"success,required"` - ResultInfo DiagnosticTracerouteNewResponseEnvelopeResultInfo `json:"result_info"` - JSON diagnosticTracerouteNewResponseEnvelopeJSON `json:"-"` -} - -// diagnosticTracerouteNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [DiagnosticTracerouteNewResponseEnvelope] -type diagnosticTracerouteNewResponseEnvelopeJSON 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 *DiagnosticTracerouteNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r diagnosticTracerouteNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DiagnosticTracerouteNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON diagnosticTracerouteNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// diagnosticTracerouteNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DiagnosticTracerouteNewResponseEnvelopeErrors] -type diagnosticTracerouteNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DiagnosticTracerouteNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r diagnosticTracerouteNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DiagnosticTracerouteNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON diagnosticTracerouteNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// diagnosticTracerouteNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [DiagnosticTracerouteNewResponseEnvelopeMessages] -type diagnosticTracerouteNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DiagnosticTracerouteNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r diagnosticTracerouteNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DiagnosticTracerouteNewResponseEnvelopeSuccess bool - -const ( - DiagnosticTracerouteNewResponseEnvelopeSuccessTrue DiagnosticTracerouteNewResponseEnvelopeSuccess = true -) - -type DiagnosticTracerouteNewResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON diagnosticTracerouteNewResponseEnvelopeResultInfoJSON `json:"-"` -} - -// diagnosticTracerouteNewResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [DiagnosticTracerouteNewResponseEnvelopeResultInfo] -type diagnosticTracerouteNewResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DiagnosticTracerouteNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r diagnosticTracerouteNewResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/diagnostictraceroute_test.go b/diagnostictraceroute_test.go deleted file mode 100644 index bb7704b982e..00000000000 --- a/diagnostictraceroute_test.go +++ /dev/null @@ -1,49 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestDiagnosticTracerouteNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Diagnostics.Traceroutes.New(context.TODO(), cloudflare.DiagnosticTracerouteNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Targets: cloudflare.F([]string{"203.0.113.1", "cloudflare.com"}), - Colos: cloudflare.F([]string{"den", "sin"}), - Options: cloudflare.F(cloudflare.DiagnosticTracerouteNewParamsOptions{ - MaxTTL: cloudflare.F(int64(15)), - PacketType: cloudflare.F(cloudflare.DiagnosticTracerouteNewParamsOptionsPacketTypeIcmp), - PacketsPerTTL: cloudflare.F(int64(0)), - Port: cloudflare.F(int64(0)), - WaitTime: cloudflare.F(int64(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()) - } -} diff --git a/dns.go b/dns.go deleted file mode 100644 index 17eabf6f763..00000000000 --- a/dns.go +++ /dev/null @@ -1,30 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// DNSService 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 [NewDNSService] method instead. -type DNSService struct { - Options []option.RequestOption - Records *DNSRecordService - Analytics *DNSAnalyticsService - Firewall *DNSFirewallService -} - -// NewDNSService 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 NewDNSService(opts ...option.RequestOption) (r *DNSService) { - r = &DNSService{} - r.Options = opts - r.Records = NewDNSRecordService(opts...) - r.Analytics = NewDNSAnalyticsService(opts...) - r.Firewall = NewDNSFirewallService(opts...) - return -} diff --git a/dns/aliases.go b/dns/aliases.go new file mode 100644 index 00000000000..317e2b8f536 --- /dev/null +++ b/dns/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package dns + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/dns/analytics.go b/dns/analytics.go new file mode 100644 index 00000000000..766d1fbcbd5 --- /dev/null +++ b/dns/analytics.go @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package dns + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// AnalyticsService 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 [NewAnalyticsService] method instead. +type AnalyticsService struct { + Options []option.RequestOption + Reports *AnalyticsReportService +} + +// NewAnalyticsService 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 NewAnalyticsService(opts ...option.RequestOption) (r *AnalyticsService) { + r = &AnalyticsService{} + r.Options = opts + r.Reports = NewAnalyticsReportService(opts...) + return +} diff --git a/dns/analyticsreport.go b/dns/analyticsreport.go new file mode 100644 index 00000000000..102fb481b74 --- /dev/null +++ b/dns/analyticsreport.go @@ -0,0 +1,272 @@ +// File generated from our OpenAPI spec by Stainless. + +package dns + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AnalyticsReportService 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 [NewAnalyticsReportService] method +// instead. +type AnalyticsReportService struct { + Options []option.RequestOption + Bytimes *AnalyticsReportBytimeService +} + +// NewAnalyticsReportService 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 NewAnalyticsReportService(opts ...option.RequestOption) (r *AnalyticsReportService) { + r = &AnalyticsReportService{} + r.Options = opts + r.Bytimes = NewAnalyticsReportBytimeService(opts...) + return +} + +// Retrieves a list of summarised aggregate metrics over a given time period. +// +// See +// [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) +// for detailed information about the available query parameters. +func (r *AnalyticsReportService) Get(ctx context.Context, identifier string, query AnalyticsReportGetParams, opts ...option.RequestOption) (res *DNSDNSAnalyticsAPIReport, err error) { + opts = append(r.Options[:], opts...) + var env AnalyticsReportGetResponseEnvelope + path := fmt.Sprintf("zones/%s/dns_analytics/report", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DNSDNSAnalyticsAPIReport struct { + // Array with one row per combination of dimension values. + Data []DNSDNSAnalyticsAPIReportData `json:"data,required"` + // Number of seconds between current time and last processed event, in another + // words how many seconds of data could be missing. + DataLag float64 `json:"data_lag,required"` + // Maximum results for each metric (object mapping metric names to values). + // Currently always an empty object. + Max interface{} `json:"max,required"` + // Minimum results for each metric (object mapping metric names to values). + // Currently always an empty object. + Min interface{} `json:"min,required"` + Query DNSDNSAnalyticsAPIReportQuery `json:"query,required"` + // Total number of rows in the result. + Rows float64 `json:"rows,required"` + // Total results for metrics across all data (object mapping metric names to + // values). + Totals interface{} `json:"totals,required"` + JSON dnsdnsAnalyticsAPIReportJSON `json:"-"` +} + +// dnsdnsAnalyticsAPIReportJSON contains the JSON metadata for the struct +// [DNSDNSAnalyticsAPIReport] +type dnsdnsAnalyticsAPIReportJSON struct { + Data apijson.Field + DataLag apijson.Field + Max apijson.Field + Min apijson.Field + Query apijson.Field + Rows apijson.Field + Totals apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSDNSAnalyticsAPIReport) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsdnsAnalyticsAPIReportJSON) RawJSON() string { + return r.raw +} + +type DNSDNSAnalyticsAPIReportData struct { + // Array of dimension values, representing the combination of dimension values + // corresponding to this row. + Dimensions []string `json:"dimensions,required"` + // Array with one item per requested metric. Each item is a single value. + Metrics []float64 `json:"metrics,required"` + JSON dnsdnsAnalyticsAPIReportDataJSON `json:"-"` +} + +// dnsdnsAnalyticsAPIReportDataJSON contains the JSON metadata for the struct +// [DNSDNSAnalyticsAPIReportData] +type dnsdnsAnalyticsAPIReportDataJSON struct { + Dimensions apijson.Field + Metrics apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSDNSAnalyticsAPIReportData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsdnsAnalyticsAPIReportDataJSON) RawJSON() string { + return r.raw +} + +type DNSDNSAnalyticsAPIReportQuery struct { + // Array of dimension names. + Dimensions []string `json:"dimensions,required"` + // Limit number of returned metrics. + Limit int64 `json:"limit,required"` + // Array of metric names. + Metrics []string `json:"metrics,required"` + // Start date and time of requesting data period in ISO 8601 format. + Since time.Time `json:"since,required" format:"date-time"` + // End date and time of requesting data period in ISO 8601 format. + Until time.Time `json:"until,required" format:"date-time"` + // Segmentation filter in 'attribute operator value' format. + Filters string `json:"filters"` + // Array of dimensions to sort by, where each dimension may be prefixed by - + // (descending) or + (ascending). + Sort []string `json:"sort"` + JSON dnsdnsAnalyticsAPIReportQueryJSON `json:"-"` +} + +// dnsdnsAnalyticsAPIReportQueryJSON contains the JSON metadata for the struct +// [DNSDNSAnalyticsAPIReportQuery] +type dnsdnsAnalyticsAPIReportQueryJSON struct { + Dimensions apijson.Field + Limit apijson.Field + Metrics apijson.Field + Since apijson.Field + Until apijson.Field + Filters apijson.Field + Sort apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSDNSAnalyticsAPIReportQuery) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsdnsAnalyticsAPIReportQueryJSON) RawJSON() string { + return r.raw +} + +type AnalyticsReportGetParams struct { + // A comma-separated list of dimensions to group results by. + Dimensions param.Field[string] `query:"dimensions"` + // Segmentation filter in 'attribute operator value' format. + Filters param.Field[string] `query:"filters"` + // Limit number of returned metrics. + Limit param.Field[int64] `query:"limit"` + // A comma-separated list of metrics to query. + Metrics param.Field[string] `query:"metrics"` + // Start date and time of requesting data period in ISO 8601 format. + Since param.Field[time.Time] `query:"since" format:"date-time"` + // A comma-separated list of dimensions to sort by, where each dimension may be + // prefixed by - (descending) or + (ascending). + Sort param.Field[string] `query:"sort"` + // End date and time of requesting data period in ISO 8601 format. + Until param.Field[time.Time] `query:"until" format:"date-time"` +} + +// URLQuery serializes [AnalyticsReportGetParams]'s query parameters as +// `url.Values`. +func (r AnalyticsReportGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AnalyticsReportGetResponseEnvelope struct { + Errors []AnalyticsReportGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AnalyticsReportGetResponseEnvelopeMessages `json:"messages,required"` + Result DNSDNSAnalyticsAPIReport `json:"result,required"` + // Whether the API call was successful + Success AnalyticsReportGetResponseEnvelopeSuccess `json:"success,required"` + JSON analyticsReportGetResponseEnvelopeJSON `json:"-"` +} + +// analyticsReportGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [AnalyticsReportGetResponseEnvelope] +type analyticsReportGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsReportGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsReportGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AnalyticsReportGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON analyticsReportGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// analyticsReportGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AnalyticsReportGetResponseEnvelopeErrors] +type analyticsReportGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsReportGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsReportGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AnalyticsReportGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON analyticsReportGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// analyticsReportGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AnalyticsReportGetResponseEnvelopeMessages] +type analyticsReportGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsReportGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsReportGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AnalyticsReportGetResponseEnvelopeSuccess bool + +const ( + AnalyticsReportGetResponseEnvelopeSuccessTrue AnalyticsReportGetResponseEnvelopeSuccess = true +) diff --git a/dns/analyticsreport_test.go b/dns/analyticsreport_test.go new file mode 100644 index 00000000000..e10333e306c --- /dev/null +++ b/dns/analyticsreport_test.go @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package dns_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/dns" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestAnalyticsReportGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.DNS.Analytics.Reports.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + dns.AnalyticsReportGetParams{ + Dimensions: cloudflare.F("queryType"), + Filters: cloudflare.F("responseCode==NOERROR,queryType==A"), + Limit: cloudflare.F(int64(100)), + Metrics: cloudflare.F("queryCount,uncachedCount"), + Since: cloudflare.F(time.Now()), + Sort: cloudflare.F("+responseCode,-queryName"), + Until: cloudflare.F(time.Now()), + }, + ) + 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/dns/analyticsreportbytime.go b/dns/analyticsreportbytime.go new file mode 100644 index 00000000000..9a6aa737d9c --- /dev/null +++ b/dns/analyticsreportbytime.go @@ -0,0 +1,312 @@ +// File generated from our OpenAPI spec by Stainless. + +package dns + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AnalyticsReportBytimeService 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 [NewAnalyticsReportBytimeService] +// method instead. +type AnalyticsReportBytimeService struct { + Options []option.RequestOption +} + +// NewAnalyticsReportBytimeService 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 NewAnalyticsReportBytimeService(opts ...option.RequestOption) (r *AnalyticsReportBytimeService) { + r = &AnalyticsReportBytimeService{} + r.Options = opts + return +} + +// Retrieves a list of aggregate metrics grouped by time interval. +// +// See +// [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) +// for detailed information about the available query parameters. +func (r *AnalyticsReportBytimeService) Get(ctx context.Context, identifier string, query AnalyticsReportBytimeGetParams, opts ...option.RequestOption) (res *DNSDNSAnalyticsAPIReportBytime, err error) { + opts = append(r.Options[:], opts...) + var env AnalyticsReportBytimeGetResponseEnvelope + path := fmt.Sprintf("zones/%s/dns_analytics/report/bytime", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DNSDNSAnalyticsAPIReportBytime struct { + // Array with one row per combination of dimension values. + Data []DNSDNSAnalyticsAPIReportBytimeData `json:"data,required"` + // Number of seconds between current time and last processed event, in another + // words how many seconds of data could be missing. + DataLag float64 `json:"data_lag,required"` + // Maximum results for each metric (object mapping metric names to values). + // Currently always an empty object. + Max interface{} `json:"max,required"` + // Minimum results for each metric (object mapping metric names to values). + // Currently always an empty object. + Min interface{} `json:"min,required"` + Query DNSDNSAnalyticsAPIReportBytimeQuery `json:"query,required"` + // Total number of rows in the result. + Rows float64 `json:"rows,required"` + // Array of time intervals in the response data. Each interval is represented as an + // array containing two values: the start time, and the end time. + TimeIntervals [][]time.Time `json:"time_intervals,required" format:"date-time"` + // Total results for metrics across all data (object mapping metric names to + // values). + Totals interface{} `json:"totals,required"` + JSON dnsdnsAnalyticsAPIReportBytimeJSON `json:"-"` +} + +// dnsdnsAnalyticsAPIReportBytimeJSON contains the JSON metadata for the struct +// [DNSDNSAnalyticsAPIReportBytime] +type dnsdnsAnalyticsAPIReportBytimeJSON struct { + Data apijson.Field + DataLag apijson.Field + Max apijson.Field + Min apijson.Field + Query apijson.Field + Rows apijson.Field + TimeIntervals apijson.Field + Totals apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSDNSAnalyticsAPIReportBytime) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsdnsAnalyticsAPIReportBytimeJSON) RawJSON() string { + return r.raw +} + +type DNSDNSAnalyticsAPIReportBytimeData struct { + // Array of dimension values, representing the combination of dimension values + // corresponding to this row. + Dimensions []string `json:"dimensions,required"` + // Array with one item per requested metric. Each item is an array of values, + // broken down by time interval. + Metrics [][]interface{} `json:"metrics,required"` + JSON dnsdnsAnalyticsAPIReportBytimeDataJSON `json:"-"` +} + +// dnsdnsAnalyticsAPIReportBytimeDataJSON contains the JSON metadata for the struct +// [DNSDNSAnalyticsAPIReportBytimeData] +type dnsdnsAnalyticsAPIReportBytimeDataJSON struct { + Dimensions apijson.Field + Metrics apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSDNSAnalyticsAPIReportBytimeData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsdnsAnalyticsAPIReportBytimeDataJSON) RawJSON() string { + return r.raw +} + +type DNSDNSAnalyticsAPIReportBytimeQuery struct { + // Array of dimension names. + Dimensions []string `json:"dimensions,required"` + // Limit number of returned metrics. + Limit int64 `json:"limit,required"` + // Array of metric names. + Metrics []string `json:"metrics,required"` + // Start date and time of requesting data period in ISO 8601 format. + Since time.Time `json:"since,required" format:"date-time"` + // Unit of time to group data by. + TimeDelta DNSDNSAnalyticsAPIReportBytimeQueryTimeDelta `json:"time_delta,required"` + // End date and time of requesting data period in ISO 8601 format. + Until time.Time `json:"until,required" format:"date-time"` + // Segmentation filter in 'attribute operator value' format. + Filters string `json:"filters"` + // Array of dimensions to sort by, where each dimension may be prefixed by - + // (descending) or + (ascending). + Sort []string `json:"sort"` + JSON dnsdnsAnalyticsAPIReportBytimeQueryJSON `json:"-"` +} + +// dnsdnsAnalyticsAPIReportBytimeQueryJSON contains the JSON metadata for the +// struct [DNSDNSAnalyticsAPIReportBytimeQuery] +type dnsdnsAnalyticsAPIReportBytimeQueryJSON struct { + Dimensions apijson.Field + Limit apijson.Field + Metrics apijson.Field + Since apijson.Field + TimeDelta apijson.Field + Until apijson.Field + Filters apijson.Field + Sort apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSDNSAnalyticsAPIReportBytimeQuery) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsdnsAnalyticsAPIReportBytimeQueryJSON) RawJSON() string { + return r.raw +} + +// Unit of time to group data by. +type DNSDNSAnalyticsAPIReportBytimeQueryTimeDelta string + +const ( + DNSDNSAnalyticsAPIReportBytimeQueryTimeDeltaAll DNSDNSAnalyticsAPIReportBytimeQueryTimeDelta = "all" + DNSDNSAnalyticsAPIReportBytimeQueryTimeDeltaAuto DNSDNSAnalyticsAPIReportBytimeQueryTimeDelta = "auto" + DNSDNSAnalyticsAPIReportBytimeQueryTimeDeltaYear DNSDNSAnalyticsAPIReportBytimeQueryTimeDelta = "year" + DNSDNSAnalyticsAPIReportBytimeQueryTimeDeltaQuarter DNSDNSAnalyticsAPIReportBytimeQueryTimeDelta = "quarter" + DNSDNSAnalyticsAPIReportBytimeQueryTimeDeltaMonth DNSDNSAnalyticsAPIReportBytimeQueryTimeDelta = "month" + DNSDNSAnalyticsAPIReportBytimeQueryTimeDeltaWeek DNSDNSAnalyticsAPIReportBytimeQueryTimeDelta = "week" + DNSDNSAnalyticsAPIReportBytimeQueryTimeDeltaDay DNSDNSAnalyticsAPIReportBytimeQueryTimeDelta = "day" + DNSDNSAnalyticsAPIReportBytimeQueryTimeDeltaHour DNSDNSAnalyticsAPIReportBytimeQueryTimeDelta = "hour" + DNSDNSAnalyticsAPIReportBytimeQueryTimeDeltaDekaminute DNSDNSAnalyticsAPIReportBytimeQueryTimeDelta = "dekaminute" + DNSDNSAnalyticsAPIReportBytimeQueryTimeDeltaMinute DNSDNSAnalyticsAPIReportBytimeQueryTimeDelta = "minute" +) + +type AnalyticsReportBytimeGetParams struct { + // A comma-separated list of dimensions to group results by. + Dimensions param.Field[string] `query:"dimensions"` + // Segmentation filter in 'attribute operator value' format. + Filters param.Field[string] `query:"filters"` + // Limit number of returned metrics. + Limit param.Field[int64] `query:"limit"` + // A comma-separated list of metrics to query. + Metrics param.Field[string] `query:"metrics"` + // Start date and time of requesting data period in ISO 8601 format. + Since param.Field[time.Time] `query:"since" format:"date-time"` + // A comma-separated list of dimensions to sort by, where each dimension may be + // prefixed by - (descending) or + (ascending). + Sort param.Field[string] `query:"sort"` + // Unit of time to group data by. + TimeDelta param.Field[AnalyticsReportBytimeGetParamsTimeDelta] `query:"time_delta"` + // End date and time of requesting data period in ISO 8601 format. + Until param.Field[time.Time] `query:"until" format:"date-time"` +} + +// URLQuery serializes [AnalyticsReportBytimeGetParams]'s query parameters as +// `url.Values`. +func (r AnalyticsReportBytimeGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Unit of time to group data by. +type AnalyticsReportBytimeGetParamsTimeDelta string + +const ( + AnalyticsReportBytimeGetParamsTimeDeltaAll AnalyticsReportBytimeGetParamsTimeDelta = "all" + AnalyticsReportBytimeGetParamsTimeDeltaAuto AnalyticsReportBytimeGetParamsTimeDelta = "auto" + AnalyticsReportBytimeGetParamsTimeDeltaYear AnalyticsReportBytimeGetParamsTimeDelta = "year" + AnalyticsReportBytimeGetParamsTimeDeltaQuarter AnalyticsReportBytimeGetParamsTimeDelta = "quarter" + AnalyticsReportBytimeGetParamsTimeDeltaMonth AnalyticsReportBytimeGetParamsTimeDelta = "month" + AnalyticsReportBytimeGetParamsTimeDeltaWeek AnalyticsReportBytimeGetParamsTimeDelta = "week" + AnalyticsReportBytimeGetParamsTimeDeltaDay AnalyticsReportBytimeGetParamsTimeDelta = "day" + AnalyticsReportBytimeGetParamsTimeDeltaHour AnalyticsReportBytimeGetParamsTimeDelta = "hour" + AnalyticsReportBytimeGetParamsTimeDeltaDekaminute AnalyticsReportBytimeGetParamsTimeDelta = "dekaminute" + AnalyticsReportBytimeGetParamsTimeDeltaMinute AnalyticsReportBytimeGetParamsTimeDelta = "minute" +) + +type AnalyticsReportBytimeGetResponseEnvelope struct { + Errors []AnalyticsReportBytimeGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AnalyticsReportBytimeGetResponseEnvelopeMessages `json:"messages,required"` + Result DNSDNSAnalyticsAPIReportBytime `json:"result,required"` + // Whether the API call was successful + Success AnalyticsReportBytimeGetResponseEnvelopeSuccess `json:"success,required"` + JSON analyticsReportBytimeGetResponseEnvelopeJSON `json:"-"` +} + +// analyticsReportBytimeGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [AnalyticsReportBytimeGetResponseEnvelope] +type analyticsReportBytimeGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsReportBytimeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsReportBytimeGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AnalyticsReportBytimeGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON analyticsReportBytimeGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// analyticsReportBytimeGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [AnalyticsReportBytimeGetResponseEnvelopeErrors] +type analyticsReportBytimeGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsReportBytimeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsReportBytimeGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AnalyticsReportBytimeGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON analyticsReportBytimeGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// analyticsReportBytimeGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AnalyticsReportBytimeGetResponseEnvelopeMessages] +type analyticsReportBytimeGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsReportBytimeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsReportBytimeGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AnalyticsReportBytimeGetResponseEnvelopeSuccess bool + +const ( + AnalyticsReportBytimeGetResponseEnvelopeSuccessTrue AnalyticsReportBytimeGetResponseEnvelopeSuccess = true +) diff --git a/dns/analyticsreportbytime_test.go b/dns/analyticsreportbytime_test.go new file mode 100644 index 00000000000..d922d4e61ff --- /dev/null +++ b/dns/analyticsreportbytime_test.go @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package dns_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/dns" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestAnalyticsReportBytimeGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.DNS.Analytics.Reports.Bytimes.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + dns.AnalyticsReportBytimeGetParams{ + Dimensions: cloudflare.F("queryType"), + Filters: cloudflare.F("responseCode==NOERROR,queryType==A"), + Limit: cloudflare.F(int64(100)), + Metrics: cloudflare.F("queryCount,uncachedCount"), + Since: cloudflare.F(time.Now()), + Sort: cloudflare.F("+responseCode,-queryName"), + TimeDelta: cloudflare.F(dns.AnalyticsReportBytimeGetParamsTimeDeltaHour), + Until: cloudflare.F(time.Now()), + }, + ) + 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/dns/dns.go b/dns/dns.go new file mode 100644 index 00000000000..474b59daec8 --- /dev/null +++ b/dns/dns.go @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package dns + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// DNSService 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 [NewDNSService] method instead. +type DNSService struct { + Options []option.RequestOption + Records *RecordService + Analytics *AnalyticsService + Firewall *FirewallService +} + +// NewDNSService 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 NewDNSService(opts ...option.RequestOption) (r *DNSService) { + r = &DNSService{} + r.Options = opts + r.Records = NewRecordService(opts...) + r.Analytics = NewAnalyticsService(opts...) + r.Firewall = NewFirewallService(opts...) + return +} diff --git a/dns/firewall.go b/dns/firewall.go new file mode 100644 index 00000000000..51a9b04ec01 --- /dev/null +++ b/dns/firewall.go @@ -0,0 +1,738 @@ +// File generated from our OpenAPI spec by Stainless. + +package dns + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// FirewallService 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 [NewFirewallService] method instead. +type FirewallService struct { + Options []option.RequestOption + Analytics *FirewallAnalyticsService +} + +// NewFirewallService 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 NewFirewallService(opts ...option.RequestOption) (r *FirewallService) { + r = &FirewallService{} + r.Options = opts + r.Analytics = NewFirewallAnalyticsService(opts...) + return +} + +// Create a configured DNS Firewall Cluster. +func (r *FirewallService) New(ctx context.Context, params FirewallNewParams, opts ...option.RequestOption) (res *DNSFirewallDNSFirewall, err error) { + opts = append(r.Options[:], opts...) + var env FirewallNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/dns_firewall", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List configured DNS Firewall clusters for an account. +func (r *FirewallService) List(ctx context.Context, params FirewallListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[DNSFirewallDNSFirewall], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("accounts/%s/dns_firewall", params.AccountID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// List configured DNS Firewall clusters for an account. +func (r *FirewallService) ListAutoPaging(ctx context.Context, params FirewallListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[DNSFirewallDNSFirewall] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) +} + +// Delete a configured DNS Firewall Cluster. +func (r *FirewallService) Delete(ctx context.Context, dnsFirewallID string, body FirewallDeleteParams, opts ...option.RequestOption) (res *FirewallDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env FirewallDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/dns_firewall/%s", body.AccountID, dnsFirewallID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Modify a DNS Firewall Cluster configuration. +func (r *FirewallService) Edit(ctx context.Context, dnsFirewallID string, params FirewallEditParams, opts ...option.RequestOption) (res *DNSFirewallDNSFirewall, err error) { + opts = append(r.Options[:], opts...) + var env FirewallEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/dns_firewall/%s", params.AccountID, dnsFirewallID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Show a single configured DNS Firewall cluster for an account. +func (r *FirewallService) Get(ctx context.Context, dnsFirewallID string, query FirewallGetParams, opts ...option.RequestOption) (res *DNSFirewallDNSFirewall, err error) { + opts = append(r.Options[:], opts...) + var env FirewallGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/dns_firewall/%s", query.AccountID, dnsFirewallID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DNSFirewallDNSFirewall struct { + // Identifier + ID string `json:"id,required"` + // Deprecate the response to ANY requests. + DeprecateAnyRequests bool `json:"deprecate_any_requests,required"` + DNSFirewallIPs []DNSFirewallDNSFirewallDNSFirewallIP `json:"dns_firewall_ips,required" format:"ipv4"` + // Forward client IP (resolver) subnet if no EDNS Client Subnet is sent. + EcsFallback bool `json:"ecs_fallback,required"` + // Maximum DNS Cache TTL. + MaximumCacheTTL float64 `json:"maximum_cache_ttl,required"` + // Minimum DNS Cache TTL. + MinimumCacheTTL float64 `json:"minimum_cache_ttl,required"` + // Last modification of DNS Firewall cluster. + ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` + // DNS Firewall Cluster Name. + Name string `json:"name,required"` + UpstreamIPs []DNSFirewallDNSFirewallUpstreamIP `json:"upstream_ips,required" format:"ipv4"` + // Attack mitigation settings. + AttackMitigation DNSFirewallDNSFirewallAttackMitigation `json:"attack_mitigation,nullable"` + // Negative DNS Cache TTL. + NegativeCacheTTL float64 `json:"negative_cache_ttl,nullable"` + // Deprecated alias for "upstream_ips". + OriginIPs interface{} `json:"origin_ips"` + // Ratelimit in queries per second per datacenter (applies to DNS queries sent to + // the upstream nameservers configured on the cluster). + Ratelimit float64 `json:"ratelimit,nullable"` + // Number of retries for fetching DNS responses from upstream nameservers (not + // counting the initial attempt). + Retries float64 `json:"retries"` + JSON dnsFirewallDNSFirewallJSON `json:"-"` +} + +// dnsFirewallDNSFirewallJSON contains the JSON metadata for the struct +// [DNSFirewallDNSFirewall] +type dnsFirewallDNSFirewallJSON struct { + ID apijson.Field + DeprecateAnyRequests apijson.Field + DNSFirewallIPs apijson.Field + EcsFallback apijson.Field + MaximumCacheTTL apijson.Field + MinimumCacheTTL apijson.Field + ModifiedOn apijson.Field + Name apijson.Field + UpstreamIPs apijson.Field + AttackMitigation apijson.Field + NegativeCacheTTL apijson.Field + OriginIPs apijson.Field + Ratelimit apijson.Field + Retries apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSFirewallDNSFirewall) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsFirewallDNSFirewallJSON) RawJSON() string { + return r.raw +} + +// Cloudflare-assigned DNS IPv4 Address. +// +// Union satisfied by [shared.UnionString] or [shared.UnionString]. +type DNSFirewallDNSFirewallDNSFirewallIP interface { + ImplementsDNSDNSFirewallDNSFirewallDNSFirewallIP() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DNSFirewallDNSFirewallDNSFirewallIP)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Upstream DNS Server IPv4 Address. +// +// Union satisfied by [shared.UnionString] or [shared.UnionString]. +type DNSFirewallDNSFirewallUpstreamIP interface { + ImplementsDNSDNSFirewallDNSFirewallUpstreamIP() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DNSFirewallDNSFirewallUpstreamIP)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Attack mitigation settings. +type DNSFirewallDNSFirewallAttackMitigation struct { + // When enabled, random-prefix attacks are automatically mitigated and the upstream + // DNS servers protected. + Enabled bool `json:"enabled"` + // Deprecated alias for "only_when_upstream_unhealthy". + OnlyWhenOriginUnhealthy interface{} `json:"only_when_origin_unhealthy"` + // Only mitigate attacks when upstream servers seem unhealthy. + OnlyWhenUpstreamUnhealthy bool `json:"only_when_upstream_unhealthy"` + JSON dnsFirewallDNSFirewallAttackMitigationJSON `json:"-"` +} + +// dnsFirewallDNSFirewallAttackMitigationJSON contains the JSON metadata for the +// struct [DNSFirewallDNSFirewallAttackMitigation] +type dnsFirewallDNSFirewallAttackMitigationJSON struct { + Enabled apijson.Field + OnlyWhenOriginUnhealthy apijson.Field + OnlyWhenUpstreamUnhealthy apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSFirewallDNSFirewallAttackMitigation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsFirewallDNSFirewallAttackMitigationJSON) RawJSON() string { + return r.raw +} + +type FirewallDeleteResponse struct { + // Identifier + ID string `json:"id"` + JSON firewallDeleteResponseJSON `json:"-"` +} + +// firewallDeleteResponseJSON contains the JSON metadata for the struct +// [FirewallDeleteResponse] +type firewallDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type FirewallNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // DNS Firewall Cluster Name. + Name param.Field[string] `json:"name,required"` + UpstreamIPs param.Field[[]FirewallNewParamsUpstreamIP] `json:"upstream_ips,required" format:"ipv4"` + // Attack mitigation settings. + AttackMitigation param.Field[FirewallNewParamsAttackMitigation] `json:"attack_mitigation"` + // Deprecate the response to ANY requests. + DeprecateAnyRequests param.Field[bool] `json:"deprecate_any_requests"` + // Forward client IP (resolver) subnet if no EDNS Client Subnet is sent. + EcsFallback param.Field[bool] `json:"ecs_fallback"` + // Maximum DNS Cache TTL. + MaximumCacheTTL param.Field[float64] `json:"maximum_cache_ttl"` + // Minimum DNS Cache TTL. + MinimumCacheTTL param.Field[float64] `json:"minimum_cache_ttl"` + // Negative DNS Cache TTL. + NegativeCacheTTL param.Field[float64] `json:"negative_cache_ttl"` + // Deprecated alias for "upstream_ips". + OriginIPs param.Field[interface{}] `json:"origin_ips"` + // Ratelimit in queries per second per datacenter (applies to DNS queries sent to + // the upstream nameservers configured on the cluster). + Ratelimit param.Field[float64] `json:"ratelimit"` + // Number of retries for fetching DNS responses from upstream nameservers (not + // counting the initial attempt). + Retries param.Field[float64] `json:"retries"` +} + +func (r FirewallNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Upstream DNS Server IPv4 Address. +// +// Satisfied by [shared.UnionString], [shared.UnionString]. +type FirewallNewParamsUpstreamIP interface { + ImplementsDNSFirewallNewParamsUpstreamIP() +} + +// Attack mitigation settings. +type FirewallNewParamsAttackMitigation struct { + // When enabled, random-prefix attacks are automatically mitigated and the upstream + // DNS servers protected. + Enabled param.Field[bool] `json:"enabled"` + // Deprecated alias for "only_when_upstream_unhealthy". + OnlyWhenOriginUnhealthy param.Field[interface{}] `json:"only_when_origin_unhealthy"` + // Only mitigate attacks when upstream servers seem unhealthy. + OnlyWhenUpstreamUnhealthy param.Field[bool] `json:"only_when_upstream_unhealthy"` +} + +func (r FirewallNewParamsAttackMitigation) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type FirewallNewResponseEnvelope struct { + Errors []FirewallNewResponseEnvelopeErrors `json:"errors,required"` + Messages []FirewallNewResponseEnvelopeMessages `json:"messages,required"` + Result DNSFirewallDNSFirewall `json:"result,required"` + // Whether the API call was successful + Success FirewallNewResponseEnvelopeSuccess `json:"success,required"` + JSON firewallNewResponseEnvelopeJSON `json:"-"` +} + +// firewallNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [FirewallNewResponseEnvelope] +type firewallNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FirewallNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON firewallNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// firewallNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [FirewallNewResponseEnvelopeErrors] +type firewallNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FirewallNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON firewallNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// firewallNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [FirewallNewResponseEnvelopeMessages] +type firewallNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FirewallNewResponseEnvelopeSuccess bool + +const ( + FirewallNewResponseEnvelopeSuccessTrue FirewallNewResponseEnvelopeSuccess = true +) + +type FirewallListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // Number of clusters per page. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [FirewallListParams]'s query parameters as `url.Values`. +func (r FirewallListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type FirewallDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type FirewallDeleteResponseEnvelope struct { + Errors []FirewallDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []FirewallDeleteResponseEnvelopeMessages `json:"messages,required"` + Result FirewallDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success FirewallDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON firewallDeleteResponseEnvelopeJSON `json:"-"` +} + +// firewallDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [FirewallDeleteResponseEnvelope] +type firewallDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FirewallDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON firewallDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// firewallDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [FirewallDeleteResponseEnvelopeErrors] +type firewallDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FirewallDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON firewallDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// firewallDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [FirewallDeleteResponseEnvelopeMessages] +type firewallDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FirewallDeleteResponseEnvelopeSuccess bool + +const ( + FirewallDeleteResponseEnvelopeSuccessTrue FirewallDeleteResponseEnvelopeSuccess = true +) + +type FirewallEditParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Deprecate the response to ANY requests. + DeprecateAnyRequests param.Field[bool] `json:"deprecate_any_requests,required"` + DNSFirewallIPs param.Field[[]FirewallEditParamsDNSFirewallIP] `json:"dns_firewall_ips,required" format:"ipv4"` + // Forward client IP (resolver) subnet if no EDNS Client Subnet is sent. + EcsFallback param.Field[bool] `json:"ecs_fallback,required"` + // Maximum DNS Cache TTL. + MaximumCacheTTL param.Field[float64] `json:"maximum_cache_ttl,required"` + // Minimum DNS Cache TTL. + MinimumCacheTTL param.Field[float64] `json:"minimum_cache_ttl,required"` + // DNS Firewall Cluster Name. + Name param.Field[string] `json:"name,required"` + UpstreamIPs param.Field[[]FirewallEditParamsUpstreamIP] `json:"upstream_ips,required" format:"ipv4"` + // Attack mitigation settings. + AttackMitigation param.Field[FirewallEditParamsAttackMitigation] `json:"attack_mitigation"` + // Negative DNS Cache TTL. + NegativeCacheTTL param.Field[float64] `json:"negative_cache_ttl"` + // Deprecated alias for "upstream_ips". + OriginIPs param.Field[interface{}] `json:"origin_ips"` + // Ratelimit in queries per second per datacenter (applies to DNS queries sent to + // the upstream nameservers configured on the cluster). + Ratelimit param.Field[float64] `json:"ratelimit"` + // Number of retries for fetching DNS responses from upstream nameservers (not + // counting the initial attempt). + Retries param.Field[float64] `json:"retries"` +} + +func (r FirewallEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Cloudflare-assigned DNS IPv4 Address. +// +// Satisfied by [shared.UnionString], [shared.UnionString]. +type FirewallEditParamsDNSFirewallIP interface { + ImplementsDNSFirewallEditParamsDNSFirewallIP() +} + +// Upstream DNS Server IPv4 Address. +// +// Satisfied by [shared.UnionString], [shared.UnionString]. +type FirewallEditParamsUpstreamIP interface { + ImplementsDNSFirewallEditParamsUpstreamIP() +} + +// Attack mitigation settings. +type FirewallEditParamsAttackMitigation struct { + // When enabled, random-prefix attacks are automatically mitigated and the upstream + // DNS servers protected. + Enabled param.Field[bool] `json:"enabled"` + // Deprecated alias for "only_when_upstream_unhealthy". + OnlyWhenOriginUnhealthy param.Field[interface{}] `json:"only_when_origin_unhealthy"` + // Only mitigate attacks when upstream servers seem unhealthy. + OnlyWhenUpstreamUnhealthy param.Field[bool] `json:"only_when_upstream_unhealthy"` +} + +func (r FirewallEditParamsAttackMitigation) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type FirewallEditResponseEnvelope struct { + Errors []FirewallEditResponseEnvelopeErrors `json:"errors,required"` + Messages []FirewallEditResponseEnvelopeMessages `json:"messages,required"` + Result DNSFirewallDNSFirewall `json:"result,required"` + // Whether the API call was successful + Success FirewallEditResponseEnvelopeSuccess `json:"success,required"` + JSON firewallEditResponseEnvelopeJSON `json:"-"` +} + +// firewallEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [FirewallEditResponseEnvelope] +type firewallEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FirewallEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON firewallEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// firewallEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [FirewallEditResponseEnvelopeErrors] +type firewallEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FirewallEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON firewallEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// firewallEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [FirewallEditResponseEnvelopeMessages] +type firewallEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FirewallEditResponseEnvelopeSuccess bool + +const ( + FirewallEditResponseEnvelopeSuccessTrue FirewallEditResponseEnvelopeSuccess = true +) + +type FirewallGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type FirewallGetResponseEnvelope struct { + Errors []FirewallGetResponseEnvelopeErrors `json:"errors,required"` + Messages []FirewallGetResponseEnvelopeMessages `json:"messages,required"` + Result DNSFirewallDNSFirewall `json:"result,required"` + // Whether the API call was successful + Success FirewallGetResponseEnvelopeSuccess `json:"success,required"` + JSON firewallGetResponseEnvelopeJSON `json:"-"` +} + +// firewallGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [FirewallGetResponseEnvelope] +type firewallGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FirewallGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON firewallGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// firewallGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [FirewallGetResponseEnvelopeErrors] +type firewallGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FirewallGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON firewallGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// firewallGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [FirewallGetResponseEnvelopeMessages] +type firewallGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FirewallGetResponseEnvelopeSuccess bool + +const ( + FirewallGetResponseEnvelopeSuccessTrue FirewallGetResponseEnvelopeSuccess = true +) diff --git a/dns/firewall_test.go b/dns/firewall_test.go new file mode 100644 index 00000000000..25536f64a0b --- /dev/null +++ b/dns/firewall_test.go @@ -0,0 +1,191 @@ +// File generated from our OpenAPI spec by Stainless. + +package dns_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/dns" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestFirewallNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.DNS.Firewall.New(context.TODO(), dns.FirewallNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Name: cloudflare.F("My Awesome DNS Firewall cluster"), + UpstreamIPs: cloudflare.F([]dns.FirewallNewParamsUpstreamIP{shared.UnionString("192.0.2.1"), shared.UnionString("198.51.100.1"), shared.UnionString("2001:DB8:100::CF")}), + AttackMitigation: cloudflare.F(dns.FirewallNewParamsAttackMitigation{ + Enabled: cloudflare.F(true), + OnlyWhenOriginUnhealthy: cloudflare.F[any](map[string]interface{}{}), + OnlyWhenUpstreamUnhealthy: cloudflare.F(false), + }), + DeprecateAnyRequests: cloudflare.F(true), + EcsFallback: cloudflare.F(false), + MaximumCacheTTL: cloudflare.F(900.000000), + MinimumCacheTTL: cloudflare.F(60.000000), + NegativeCacheTTL: cloudflare.F(900.000000), + OriginIPs: cloudflare.F[any](map[string]interface{}{}), + Ratelimit: cloudflare.F(600.000000), + Retries: cloudflare.F(2.000000), + }) + 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 TestFirewallListWithOptionalParams(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("user@example.com"), + ) + _, err := client.DNS.Firewall.List(context.TODO(), dns.FirewallListParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(1.000000), + }) + 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 TestFirewallDelete(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("user@example.com"), + ) + _, err := client.DNS.Firewall.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + dns.FirewallDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestFirewallEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.DNS.Firewall.Edit( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + dns.FirewallEditParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + DeprecateAnyRequests: cloudflare.F(true), + DNSFirewallIPs: cloudflare.F([]dns.FirewallEditParamsDNSFirewallIP{shared.UnionString("203.0.113.1"), shared.UnionString("203.0.113.254"), shared.UnionString("2001:DB8:AB::CF"), shared.UnionString("2001:DB8:CD::CF")}), + EcsFallback: cloudflare.F(false), + MaximumCacheTTL: cloudflare.F(900.000000), + MinimumCacheTTL: cloudflare.F(60.000000), + Name: cloudflare.F("My Awesome DNS Firewall cluster"), + UpstreamIPs: cloudflare.F([]dns.FirewallEditParamsUpstreamIP{shared.UnionString("192.0.2.1"), shared.UnionString("198.51.100.1"), shared.UnionString("2001:DB8:100::CF")}), + AttackMitigation: cloudflare.F(dns.FirewallEditParamsAttackMitigation{ + Enabled: cloudflare.F(true), + OnlyWhenOriginUnhealthy: cloudflare.F[any](map[string]interface{}{}), + OnlyWhenUpstreamUnhealthy: cloudflare.F(false), + }), + NegativeCacheTTL: cloudflare.F(900.000000), + OriginIPs: cloudflare.F[any](map[string]interface{}{}), + Ratelimit: cloudflare.F(600.000000), + Retries: cloudflare.F(2.000000), + }, + ) + 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 TestFirewallGet(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("user@example.com"), + ) + _, err := client.DNS.Firewall.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + dns.FirewallGetParams{ + AccountID: cloudflare.F("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/dns/firewallanalytics.go b/dns/firewallanalytics.go new file mode 100644 index 00000000000..be749ce9d0c --- /dev/null +++ b/dns/firewallanalytics.go @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package dns + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// FirewallAnalyticsService 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 [NewFirewallAnalyticsService] method +// instead. +type FirewallAnalyticsService struct { + Options []option.RequestOption + Reports *FirewallAnalyticsReportService +} + +// NewFirewallAnalyticsService 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 NewFirewallAnalyticsService(opts ...option.RequestOption) (r *FirewallAnalyticsService) { + r = &FirewallAnalyticsService{} + r.Options = opts + r.Reports = NewFirewallAnalyticsReportService(opts...) + return +} diff --git a/dns/firewallanalyticsreport.go b/dns/firewallanalyticsreport.go new file mode 100644 index 00000000000..d6c63c0a248 --- /dev/null +++ b/dns/firewallanalyticsreport.go @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package dns + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// FirewallAnalyticsReportService 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 +// [NewFirewallAnalyticsReportService] method instead. +type FirewallAnalyticsReportService struct { + Options []option.RequestOption + Bytimes *FirewallAnalyticsReportBytimeService +} + +// NewFirewallAnalyticsReportService 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 NewFirewallAnalyticsReportService(opts ...option.RequestOption) (r *FirewallAnalyticsReportService) { + r = &FirewallAnalyticsReportService{} + r.Options = opts + r.Bytimes = NewFirewallAnalyticsReportBytimeService(opts...) + return +} + +// Retrieves a list of summarised aggregate metrics over a given time period. +// +// See +// [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) +// for detailed information about the available query parameters. +func (r *FirewallAnalyticsReportService) Get(ctx context.Context, accountIdentifier string, identifier string, query FirewallAnalyticsReportGetParams, opts ...option.RequestOption) (res *DNSDNSAnalyticsAPIReport, err error) { + opts = append(r.Options[:], opts...) + var env FirewallAnalyticsReportGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/dns_firewall/%s/dns_analytics/report", accountIdentifier, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type FirewallAnalyticsReportGetParams struct { + // A comma-separated list of dimensions to group results by. + Dimensions param.Field[string] `query:"dimensions"` + // Segmentation filter in 'attribute operator value' format. + Filters param.Field[string] `query:"filters"` + // Limit number of returned metrics. + Limit param.Field[int64] `query:"limit"` + // A comma-separated list of metrics to query. + Metrics param.Field[string] `query:"metrics"` + // Start date and time of requesting data period in ISO 8601 format. + Since param.Field[time.Time] `query:"since" format:"date-time"` + // A comma-separated list of dimensions to sort by, where each dimension may be + // prefixed by - (descending) or + (ascending). + Sort param.Field[string] `query:"sort"` + // End date and time of requesting data period in ISO 8601 format. + Until param.Field[time.Time] `query:"until" format:"date-time"` +} + +// URLQuery serializes [FirewallAnalyticsReportGetParams]'s query parameters as +// `url.Values`. +func (r FirewallAnalyticsReportGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type FirewallAnalyticsReportGetResponseEnvelope struct { + Errors []FirewallAnalyticsReportGetResponseEnvelopeErrors `json:"errors,required"` + Messages []FirewallAnalyticsReportGetResponseEnvelopeMessages `json:"messages,required"` + Result DNSDNSAnalyticsAPIReport `json:"result,required"` + // Whether the API call was successful + Success FirewallAnalyticsReportGetResponseEnvelopeSuccess `json:"success,required"` + JSON firewallAnalyticsReportGetResponseEnvelopeJSON `json:"-"` +} + +// firewallAnalyticsReportGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [FirewallAnalyticsReportGetResponseEnvelope] +type firewallAnalyticsReportGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallAnalyticsReportGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallAnalyticsReportGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FirewallAnalyticsReportGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON firewallAnalyticsReportGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// firewallAnalyticsReportGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [FirewallAnalyticsReportGetResponseEnvelopeErrors] +type firewallAnalyticsReportGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallAnalyticsReportGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallAnalyticsReportGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FirewallAnalyticsReportGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON firewallAnalyticsReportGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// firewallAnalyticsReportGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [FirewallAnalyticsReportGetResponseEnvelopeMessages] +type firewallAnalyticsReportGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallAnalyticsReportGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallAnalyticsReportGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FirewallAnalyticsReportGetResponseEnvelopeSuccess bool + +const ( + FirewallAnalyticsReportGetResponseEnvelopeSuccessTrue FirewallAnalyticsReportGetResponseEnvelopeSuccess = true +) diff --git a/dns/firewallanalyticsreport_test.go b/dns/firewallanalyticsreport_test.go new file mode 100644 index 00000000000..5f64c884a96 --- /dev/null +++ b/dns/firewallanalyticsreport_test.go @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package dns_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/dns" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestFirewallAnalyticsReportGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.DNS.Firewall.Analytics.Reports.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + dns.FirewallAnalyticsReportGetParams{ + Dimensions: cloudflare.F("queryType"), + Filters: cloudflare.F("responseCode==NOERROR,queryType==A"), + Limit: cloudflare.F(int64(100)), + Metrics: cloudflare.F("queryCount,uncachedCount"), + Since: cloudflare.F(time.Now()), + Sort: cloudflare.F("+responseCode,-queryName"), + Until: cloudflare.F(time.Now()), + }, + ) + 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/dns/firewallanalyticsreportbytime.go b/dns/firewallanalyticsreportbytime.go new file mode 100644 index 00000000000..ecbf19b4fc7 --- /dev/null +++ b/dns/firewallanalyticsreportbytime.go @@ -0,0 +1,179 @@ +// File generated from our OpenAPI spec by Stainless. + +package dns + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// FirewallAnalyticsReportBytimeService 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 +// [NewFirewallAnalyticsReportBytimeService] method instead. +type FirewallAnalyticsReportBytimeService struct { + Options []option.RequestOption +} + +// NewFirewallAnalyticsReportBytimeService 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 NewFirewallAnalyticsReportBytimeService(opts ...option.RequestOption) (r *FirewallAnalyticsReportBytimeService) { + r = &FirewallAnalyticsReportBytimeService{} + r.Options = opts + return +} + +// Retrieves a list of aggregate metrics grouped by time interval. +// +// See +// [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) +// for detailed information about the available query parameters. +func (r *FirewallAnalyticsReportBytimeService) Get(ctx context.Context, accountIdentifier string, identifier string, query FirewallAnalyticsReportBytimeGetParams, opts ...option.RequestOption) (res *DNSDNSAnalyticsAPIReportBytime, err error) { + opts = append(r.Options[:], opts...) + var env FirewallAnalyticsReportBytimeGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/dns_firewall/%s/dns_analytics/report/bytime", accountIdentifier, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type FirewallAnalyticsReportBytimeGetParams struct { + // A comma-separated list of dimensions to group results by. + Dimensions param.Field[string] `query:"dimensions"` + // Segmentation filter in 'attribute operator value' format. + Filters param.Field[string] `query:"filters"` + // Limit number of returned metrics. + Limit param.Field[int64] `query:"limit"` + // A comma-separated list of metrics to query. + Metrics param.Field[string] `query:"metrics"` + // Start date and time of requesting data period in ISO 8601 format. + Since param.Field[time.Time] `query:"since" format:"date-time"` + // A comma-separated list of dimensions to sort by, where each dimension may be + // prefixed by - (descending) or + (ascending). + Sort param.Field[string] `query:"sort"` + // Unit of time to group data by. + TimeDelta param.Field[FirewallAnalyticsReportBytimeGetParamsTimeDelta] `query:"time_delta"` + // End date and time of requesting data period in ISO 8601 format. + Until param.Field[time.Time] `query:"until" format:"date-time"` +} + +// URLQuery serializes [FirewallAnalyticsReportBytimeGetParams]'s query parameters +// as `url.Values`. +func (r FirewallAnalyticsReportBytimeGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Unit of time to group data by. +type FirewallAnalyticsReportBytimeGetParamsTimeDelta string + +const ( + FirewallAnalyticsReportBytimeGetParamsTimeDeltaAll FirewallAnalyticsReportBytimeGetParamsTimeDelta = "all" + FirewallAnalyticsReportBytimeGetParamsTimeDeltaAuto FirewallAnalyticsReportBytimeGetParamsTimeDelta = "auto" + FirewallAnalyticsReportBytimeGetParamsTimeDeltaYear FirewallAnalyticsReportBytimeGetParamsTimeDelta = "year" + FirewallAnalyticsReportBytimeGetParamsTimeDeltaQuarter FirewallAnalyticsReportBytimeGetParamsTimeDelta = "quarter" + FirewallAnalyticsReportBytimeGetParamsTimeDeltaMonth FirewallAnalyticsReportBytimeGetParamsTimeDelta = "month" + FirewallAnalyticsReportBytimeGetParamsTimeDeltaWeek FirewallAnalyticsReportBytimeGetParamsTimeDelta = "week" + FirewallAnalyticsReportBytimeGetParamsTimeDeltaDay FirewallAnalyticsReportBytimeGetParamsTimeDelta = "day" + FirewallAnalyticsReportBytimeGetParamsTimeDeltaHour FirewallAnalyticsReportBytimeGetParamsTimeDelta = "hour" + FirewallAnalyticsReportBytimeGetParamsTimeDeltaDekaminute FirewallAnalyticsReportBytimeGetParamsTimeDelta = "dekaminute" + FirewallAnalyticsReportBytimeGetParamsTimeDeltaMinute FirewallAnalyticsReportBytimeGetParamsTimeDelta = "minute" +) + +type FirewallAnalyticsReportBytimeGetResponseEnvelope struct { + Errors []FirewallAnalyticsReportBytimeGetResponseEnvelopeErrors `json:"errors,required"` + Messages []FirewallAnalyticsReportBytimeGetResponseEnvelopeMessages `json:"messages,required"` + Result DNSDNSAnalyticsAPIReportBytime `json:"result,required"` + // Whether the API call was successful + Success FirewallAnalyticsReportBytimeGetResponseEnvelopeSuccess `json:"success,required"` + JSON firewallAnalyticsReportBytimeGetResponseEnvelopeJSON `json:"-"` +} + +// firewallAnalyticsReportBytimeGetResponseEnvelopeJSON contains the JSON metadata +// for the struct [FirewallAnalyticsReportBytimeGetResponseEnvelope] +type firewallAnalyticsReportBytimeGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallAnalyticsReportBytimeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallAnalyticsReportBytimeGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FirewallAnalyticsReportBytimeGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON firewallAnalyticsReportBytimeGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// firewallAnalyticsReportBytimeGetResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [FirewallAnalyticsReportBytimeGetResponseEnvelopeErrors] +type firewallAnalyticsReportBytimeGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallAnalyticsReportBytimeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallAnalyticsReportBytimeGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FirewallAnalyticsReportBytimeGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON firewallAnalyticsReportBytimeGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// firewallAnalyticsReportBytimeGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct +// [FirewallAnalyticsReportBytimeGetResponseEnvelopeMessages] +type firewallAnalyticsReportBytimeGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallAnalyticsReportBytimeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallAnalyticsReportBytimeGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FirewallAnalyticsReportBytimeGetResponseEnvelopeSuccess bool + +const ( + FirewallAnalyticsReportBytimeGetResponseEnvelopeSuccessTrue FirewallAnalyticsReportBytimeGetResponseEnvelopeSuccess = true +) diff --git a/dns/firewallanalyticsreportbytime_test.go b/dns/firewallanalyticsreportbytime_test.go new file mode 100644 index 00000000000..dcf25f118b0 --- /dev/null +++ b/dns/firewallanalyticsreportbytime_test.go @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package dns_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/dns" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestFirewallAnalyticsReportBytimeGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.DNS.Firewall.Analytics.Reports.Bytimes.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + dns.FirewallAnalyticsReportBytimeGetParams{ + Dimensions: cloudflare.F("queryType"), + Filters: cloudflare.F("responseCode==NOERROR,queryType==A"), + Limit: cloudflare.F(int64(100)), + Metrics: cloudflare.F("queryCount,uncachedCount"), + Since: cloudflare.F(time.Now()), + Sort: cloudflare.F("+responseCode,-queryName"), + TimeDelta: cloudflare.F(dns.FirewallAnalyticsReportBytimeGetParamsTimeDeltaHour), + Until: cloudflare.F(time.Now()), + }, + ) + 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/dns/record.go b/dns/record.go new file mode 100644 index 00000000000..4331a733fdb --- /dev/null +++ b/dns/record.go @@ -0,0 +1,17901 @@ +// File generated from our OpenAPI spec by Stainless. + +package dns + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// RecordService 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 [NewRecordService] method instead. +type RecordService struct { + Options []option.RequestOption +} + +// NewRecordService 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 NewRecordService(opts ...option.RequestOption) (r *RecordService) { + r = &RecordService{} + r.Options = opts + return +} + +// Create a new DNS record for a zone. +// +// Notes: +// +// - A/AAAA records cannot exist on the same name as CNAME records. +// - NS records cannot exist on the same name as any other record type. +// - Domain names are always represented in Punycode, even if Unicode characters +// were used when creating the record. +func (r *RecordService) New(ctx context.Context, params RecordNewParams, opts ...option.RequestOption) (res *RecordNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env RecordNewResponseEnvelope + path := fmt.Sprintf("zones/%s/dns_records", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Overwrite an existing DNS record. Notes: +// +// - A/AAAA records cannot exist on the same name as CNAME records. +// - NS records cannot exist on the same name as any other record type. +// - Domain names are always represented in Punycode, even if Unicode characters +// were used when creating the record. +func (r *RecordService) Update(ctx context.Context, dnsRecordID string, params RecordUpdateParams, opts ...option.RequestOption) (res *RecordUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env RecordUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/dns_records/%s", params.ZoneID, dnsRecordID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List, search, sort, and filter a zones' DNS records. +func (r *RecordService) List(ctx context.Context, params RecordListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[RecordListResponse], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("zones/%s/dns_records", params.ZoneID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// List, search, sort, and filter a zones' DNS records. +func (r *RecordService) ListAutoPaging(ctx context.Context, params RecordListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[RecordListResponse] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) +} + +// Delete DNS Record +func (r *RecordService) Delete(ctx context.Context, dnsRecordID string, body RecordDeleteParams, opts ...option.RequestOption) (res *RecordDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env RecordDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/dns_records/%s", body.ZoneID, dnsRecordID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update an existing DNS record. Notes: +// +// - A/AAAA records cannot exist on the same name as CNAME records. +// - NS records cannot exist on the same name as any other record type. +// - Domain names are always represented in Punycode, even if Unicode characters +// were used when creating the record. +func (r *RecordService) Edit(ctx context.Context, dnsRecordID string, params RecordEditParams, opts ...option.RequestOption) (res *RecordEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env RecordEditResponseEnvelope + path := fmt.Sprintf("zones/%s/dns_records/%s", params.ZoneID, dnsRecordID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// You can export your +// [BIND config](https://en.wikipedia.org/wiki/Zone_file "Zone file") through this +// endpoint. +// +// See +// [the documentation](https://developers.cloudflare.com/dns/manage-dns-records/how-to/import-and-export/ "Import and export records") +// for more information. +func (r *RecordService) Export(ctx context.Context, query RecordExportParams, opts ...option.RequestOption) (res *string, err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "text/plain")}, opts...) + path := fmt.Sprintf("zones/%s/dns_records/export", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +// DNS Record Details +func (r *RecordService) Get(ctx context.Context, dnsRecordID string, query RecordGetParams, opts ...option.RequestOption) (res *RecordGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RecordGetResponseEnvelope + path := fmt.Sprintf("zones/%s/dns_records/%s", query.ZoneID, dnsRecordID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// You can upload your +// [BIND config](https://en.wikipedia.org/wiki/Zone_file "Zone file") through this +// endpoint. It assumes that cURL is called from a location with bind_config.txt +// (valid BIND config) present. +// +// See +// [the documentation](https://developers.cloudflare.com/dns/manage-dns-records/how-to/import-and-export/ "Import and export records") +// for more information. +func (r *RecordService) Import(ctx context.Context, params RecordImportParams, opts ...option.RequestOption) (res *RecordImportResponse, err error) { + opts = append(r.Options[:], opts...) + var env RecordImportResponseEnvelope + path := fmt.Sprintf("zones/%s/dns_records/import", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Scan for common DNS records on your domain and automatically add them to your +// zone. Useful if you haven't updated your nameservers yet. +func (r *RecordService) Scan(ctx context.Context, body RecordScanParams, opts ...option.RequestOption) (res *RecordScanResponse, err error) { + opts = append(r.Options[:], opts...) + var env RecordScanResponseEnvelope + path := fmt.Sprintf("zones/%s/dns_records/scan", body.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [dns.RecordNewResponseA], [dns.RecordNewResponseAAAA], +// [dns.RecordNewResponseCAA], [dns.RecordNewResponseCert], +// [dns.RecordNewResponseCNAME], [dns.RecordNewResponseDNSKEY], +// [dns.RecordNewResponseDS], [dns.RecordNewResponseHTTPS], +// [dns.RecordNewResponseLOC], [dns.RecordNewResponseMX], +// [dns.RecordNewResponseNAPTR], [dns.RecordNewResponseNS], +// [dns.RecordNewResponsePTR], [dns.RecordNewResponseSmimea], +// [dns.RecordNewResponseSRV], [dns.RecordNewResponseSSHFP], +// [dns.RecordNewResponseSVCB], [dns.RecordNewResponseTLSA], +// [dns.RecordNewResponseTXT] or [dns.RecordNewResponseURI]. +type RecordNewResponse interface { + implementsDNSRecordNewResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponse)(nil)).Elem(), + "type", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseA{}), + DiscriminatorValue: "A", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseAAAA{}), + DiscriminatorValue: "AAAA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseCAA{}), + DiscriminatorValue: "CAA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseCert{}), + DiscriminatorValue: "CERT", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseCNAME{}), + DiscriminatorValue: "CNAME", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseDNSKEY{}), + DiscriminatorValue: "DNSKEY", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseDS{}), + DiscriminatorValue: "DS", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseHTTPS{}), + DiscriminatorValue: "HTTPS", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseLOC{}), + DiscriminatorValue: "LOC", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseMX{}), + DiscriminatorValue: "MX", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseNAPTR{}), + DiscriminatorValue: "NAPTR", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseNS{}), + DiscriminatorValue: "NS", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponsePTR{}), + DiscriminatorValue: "PTR", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseSmimea{}), + DiscriminatorValue: "SMIMEA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseSRV{}), + DiscriminatorValue: "SRV", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseSSHFP{}), + DiscriminatorValue: "SSHFP", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseSVCB{}), + DiscriminatorValue: "SVCB", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseTLSA{}), + DiscriminatorValue: "TLSA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseTXT{}), + DiscriminatorValue: "TXT", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordNewResponseURI{}), + DiscriminatorValue: "URI", + }, + ) +} + +type RecordNewResponseA struct { + // A valid IPv4 address. + Content string `json:"content,required" format:"ipv4"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordNewResponseAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied bool `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseAJSON `json:"-"` +} + +// recordNewResponseAJSON contains the JSON metadata for the struct +// [RecordNewResponseA] +type recordNewResponseAJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Proxied apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseAJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseA) implementsDNSRecordNewResponse() {} + +// Record type. +type RecordNewResponseAType string + +const ( + RecordNewResponseATypeA RecordNewResponseAType = "A" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseAMetaJSON `json:"-"` +} + +// recordNewResponseAMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseAMeta] +type recordNewResponseAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordNewResponseATTLNumber]. +type RecordNewResponseATTL interface { + ImplementsDNSRecordNewResponseAttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseATTLNumber(0)), + }, + ) +} + +type RecordNewResponseATTLNumber float64 + +const ( + RecordNewResponseATTLNumber1 RecordNewResponseATTLNumber = 1 +) + +type RecordNewResponseAAAA struct { + // A valid IPv6 address. + Content string `json:"content,required" format:"ipv6"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordNewResponseAAAAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseAAAAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied bool `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseAAAATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseAAAAJSON `json:"-"` +} + +// recordNewResponseAAAAJSON contains the JSON metadata for the struct +// [RecordNewResponseAAAA] +type recordNewResponseAAAAJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Proxied apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseAAAA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseAAAAJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseAAAA) implementsDNSRecordNewResponse() {} + +// Record type. +type RecordNewResponseAAAAType string + +const ( + RecordNewResponseAAAATypeAAAA RecordNewResponseAAAAType = "AAAA" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseAAAAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseAAAAMetaJSON `json:"-"` +} + +// recordNewResponseAAAAMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseAAAAMeta] +type recordNewResponseAAAAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseAAAAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseAAAAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordNewResponseAAAATTLNumber]. +type RecordNewResponseAAAATTL interface { + ImplementsDNSRecordNewResponseAaaattl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseAAAATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseAAAATTLNumber(0)), + }, + ) +} + +type RecordNewResponseAAAATTLNumber float64 + +const ( + RecordNewResponseAAAATTLNumber1 RecordNewResponseAAAATTLNumber = 1 +) + +type RecordNewResponseCAA struct { + // Components of a CAA record. + Data RecordNewResponseCAAData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordNewResponseCAAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted CAA content. See 'data' to set CAA properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseCAAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseCAATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseCAAJSON `json:"-"` +} + +// recordNewResponseCAAJSON contains the JSON metadata for the struct +// [RecordNewResponseCAA] +type recordNewResponseCAAJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseCAA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseCAAJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseCAA) implementsDNSRecordNewResponse() {} + +// Components of a CAA record. +type RecordNewResponseCAAData struct { + // Flags for the CAA record. + Flags float64 `json:"flags"` + // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). + Tag string `json:"tag"` + // Value of the record. This field's semantics depend on the chosen tag. + Value string `json:"value"` + JSON recordNewResponseCAADataJSON `json:"-"` +} + +// recordNewResponseCAADataJSON contains the JSON metadata for the struct +// [RecordNewResponseCAAData] +type recordNewResponseCAADataJSON struct { + Flags apijson.Field + Tag apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseCAAData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseCAADataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordNewResponseCAAType string + +const ( + RecordNewResponseCAATypeCAA RecordNewResponseCAAType = "CAA" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseCAAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseCAAMetaJSON `json:"-"` +} + +// recordNewResponseCAAMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseCAAMeta] +type recordNewResponseCAAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseCAAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseCAAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordNewResponseCAATTLNumber]. +type RecordNewResponseCAATTL interface { + ImplementsDNSRecordNewResponseCaattl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseCAATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseCAATTLNumber(0)), + }, + ) +} + +type RecordNewResponseCAATTLNumber float64 + +const ( + RecordNewResponseCAATTLNumber1 RecordNewResponseCAATTLNumber = 1 +) + +type RecordNewResponseCert struct { + // Components of a CERT record. + Data RecordNewResponseCertData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordNewResponseCertType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted CERT content. See 'data' to set CERT properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseCertMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseCertTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseCertJSON `json:"-"` +} + +// recordNewResponseCertJSON contains the JSON metadata for the struct +// [RecordNewResponseCert] +type recordNewResponseCertJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseCert) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseCertJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseCert) implementsDNSRecordNewResponse() {} + +// Components of a CERT record. +type RecordNewResponseCertData struct { + // Algorithm. + Algorithm float64 `json:"algorithm"` + // Certificate. + Certificate string `json:"certificate"` + // Key Tag. + KeyTag float64 `json:"key_tag"` + // Type. + Type float64 `json:"type"` + JSON recordNewResponseCertDataJSON `json:"-"` +} + +// recordNewResponseCertDataJSON contains the JSON metadata for the struct +// [RecordNewResponseCertData] +type recordNewResponseCertDataJSON struct { + Algorithm apijson.Field + Certificate apijson.Field + KeyTag apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseCertData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseCertDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordNewResponseCertType string + +const ( + RecordNewResponseCertTypeCert RecordNewResponseCertType = "CERT" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseCertMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseCertMetaJSON `json:"-"` +} + +// recordNewResponseCertMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseCertMeta] +type recordNewResponseCertMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseCertMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseCertMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordNewResponseCertTTLNumber]. +type RecordNewResponseCertTTL interface { + ImplementsDNSRecordNewResponseCertTTL() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseCertTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseCertTTLNumber(0)), + }, + ) +} + +type RecordNewResponseCertTTLNumber float64 + +const ( + RecordNewResponseCertTTLNumber1 RecordNewResponseCertTTLNumber = 1 +) + +type RecordNewResponseCNAME struct { + // A valid hostname. Must not match the record's name. + Content interface{} `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordNewResponseCNAMEType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseCNAMEMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied bool `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseCNAMETTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseCNAMEJSON `json:"-"` +} + +// recordNewResponseCNAMEJSON contains the JSON metadata for the struct +// [RecordNewResponseCNAME] +type recordNewResponseCNAMEJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Proxied apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseCNAME) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseCNAMEJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseCNAME) implementsDNSRecordNewResponse() {} + +// Record type. +type RecordNewResponseCNAMEType string + +const ( + RecordNewResponseCNAMETypeCNAME RecordNewResponseCNAMEType = "CNAME" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseCNAMEMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseCNAMEMetaJSON `json:"-"` +} + +// recordNewResponseCNAMEMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseCNAMEMeta] +type recordNewResponseCNAMEMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseCNAMEMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseCNAMEMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordNewResponseCNAMETTLNumber]. +type RecordNewResponseCNAMETTL interface { + ImplementsDNSRecordNewResponseCnamettl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseCNAMETTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseCNAMETTLNumber(0)), + }, + ) +} + +type RecordNewResponseCNAMETTLNumber float64 + +const ( + RecordNewResponseCNAMETTLNumber1 RecordNewResponseCNAMETTLNumber = 1 +) + +type RecordNewResponseDNSKEY struct { + // Components of a DNSKEY record. + Data RecordNewResponseDNSKEYData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordNewResponseDNSKEYType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted DNSKEY content. See 'data' to set DNSKEY properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseDNSKEYMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseDNSKEYTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseDNSKEYJSON `json:"-"` +} + +// recordNewResponseDNSKEYJSON contains the JSON metadata for the struct +// [RecordNewResponseDNSKEY] +type recordNewResponseDNSKEYJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseDNSKEY) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseDNSKEYJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseDNSKEY) implementsDNSRecordNewResponse() {} + +// Components of a DNSKEY record. +type RecordNewResponseDNSKEYData struct { + // Algorithm. + Algorithm float64 `json:"algorithm"` + // Flags. + Flags float64 `json:"flags"` + // Protocol. + Protocol float64 `json:"protocol"` + // Public Key. + PublicKey string `json:"public_key"` + JSON recordNewResponseDNSKEYDataJSON `json:"-"` +} + +// recordNewResponseDNSKEYDataJSON contains the JSON metadata for the struct +// [RecordNewResponseDNSKEYData] +type recordNewResponseDNSKEYDataJSON struct { + Algorithm apijson.Field + Flags apijson.Field + Protocol apijson.Field + PublicKey apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseDNSKEYData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseDNSKEYDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordNewResponseDNSKEYType string + +const ( + RecordNewResponseDNSKEYTypeDNSKEY RecordNewResponseDNSKEYType = "DNSKEY" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseDNSKEYMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseDNSKEYMetaJSON `json:"-"` +} + +// recordNewResponseDNSKEYMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseDNSKEYMeta] +type recordNewResponseDNSKEYMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseDNSKEYMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseDNSKEYMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordNewResponseDNSKEYTTLNumber]. +type RecordNewResponseDNSKEYTTL interface { + ImplementsDNSRecordNewResponseDnskeyttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseDNSKEYTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseDNSKEYTTLNumber(0)), + }, + ) +} + +type RecordNewResponseDNSKEYTTLNumber float64 + +const ( + RecordNewResponseDNSKEYTTLNumber1 RecordNewResponseDNSKEYTTLNumber = 1 +) + +type RecordNewResponseDS struct { + // Components of a DS record. + Data RecordNewResponseDSData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordNewResponseDSType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted DS content. See 'data' to set DS properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseDSMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseDSTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseDSJSON `json:"-"` +} + +// recordNewResponseDSJSON contains the JSON metadata for the struct +// [RecordNewResponseDS] +type recordNewResponseDSJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseDS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseDSJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseDS) implementsDNSRecordNewResponse() {} + +// Components of a DS record. +type RecordNewResponseDSData struct { + // Algorithm. + Algorithm float64 `json:"algorithm"` + // Digest. + Digest string `json:"digest"` + // Digest Type. + DigestType float64 `json:"digest_type"` + // Key Tag. + KeyTag float64 `json:"key_tag"` + JSON recordNewResponseDSDataJSON `json:"-"` +} + +// recordNewResponseDSDataJSON contains the JSON metadata for the struct +// [RecordNewResponseDSData] +type recordNewResponseDSDataJSON struct { + Algorithm apijson.Field + Digest apijson.Field + DigestType apijson.Field + KeyTag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseDSData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseDSDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordNewResponseDSType string + +const ( + RecordNewResponseDSTypeDS RecordNewResponseDSType = "DS" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseDSMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseDSMetaJSON `json:"-"` +} + +// recordNewResponseDSMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseDSMeta] +type recordNewResponseDSMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseDSMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseDSMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordNewResponseDSTTLNumber]. +type RecordNewResponseDSTTL interface { + ImplementsDNSRecordNewResponseDsttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseDSTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseDSTTLNumber(0)), + }, + ) +} + +type RecordNewResponseDSTTLNumber float64 + +const ( + RecordNewResponseDSTTLNumber1 RecordNewResponseDSTTLNumber = 1 +) + +type RecordNewResponseHTTPS struct { + // Components of a HTTPS record. + Data RecordNewResponseHTTPSData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordNewResponseHTTPSType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted HTTPS content. See 'data' to set HTTPS properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseHTTPSMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseHTTPSTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseHTTPSJSON `json:"-"` +} + +// recordNewResponseHTTPSJSON contains the JSON metadata for the struct +// [RecordNewResponseHTTPS] +type recordNewResponseHTTPSJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseHTTPS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseHTTPSJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseHTTPS) implementsDNSRecordNewResponse() {} + +// Components of a HTTPS record. +type RecordNewResponseHTTPSData struct { + // priority. + Priority float64 `json:"priority"` + // target. + Target string `json:"target"` + // value. + Value string `json:"value"` + JSON recordNewResponseHTTPSDataJSON `json:"-"` +} + +// recordNewResponseHTTPSDataJSON contains the JSON metadata for the struct +// [RecordNewResponseHTTPSData] +type recordNewResponseHTTPSDataJSON struct { + Priority apijson.Field + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseHTTPSData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseHTTPSDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordNewResponseHTTPSType string + +const ( + RecordNewResponseHTTPSTypeHTTPS RecordNewResponseHTTPSType = "HTTPS" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseHTTPSMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseHTTPSMetaJSON `json:"-"` +} + +// recordNewResponseHTTPSMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseHTTPSMeta] +type recordNewResponseHTTPSMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseHTTPSMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseHTTPSMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordNewResponseHTTPSTTLNumber]. +type RecordNewResponseHTTPSTTL interface { + ImplementsDNSRecordNewResponseHttpsttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseHTTPSTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseHTTPSTTLNumber(0)), + }, + ) +} + +type RecordNewResponseHTTPSTTLNumber float64 + +const ( + RecordNewResponseHTTPSTTLNumber1 RecordNewResponseHTTPSTTLNumber = 1 +) + +type RecordNewResponseLOC struct { + // Components of a LOC record. + Data RecordNewResponseLOCData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordNewResponseLOCType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted LOC content. See 'data' to set LOC properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseLOCMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseLOCTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseLOCJSON `json:"-"` +} + +// recordNewResponseLOCJSON contains the JSON metadata for the struct +// [RecordNewResponseLOC] +type recordNewResponseLOCJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseLOC) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseLOCJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseLOC) implementsDNSRecordNewResponse() {} + +// Components of a LOC record. +type RecordNewResponseLOCData struct { + // Altitude of location in meters. + Altitude float64 `json:"altitude"` + // Degrees of latitude. + LatDegrees float64 `json:"lat_degrees"` + // Latitude direction. + LatDirection RecordNewResponseLOCDataLatDirection `json:"lat_direction"` + // Minutes of latitude. + LatMinutes float64 `json:"lat_minutes"` + // Seconds of latitude. + LatSeconds float64 `json:"lat_seconds"` + // Degrees of longitude. + LongDegrees float64 `json:"long_degrees"` + // Longitude direction. + LongDirection RecordNewResponseLOCDataLongDirection `json:"long_direction"` + // Minutes of longitude. + LongMinutes float64 `json:"long_minutes"` + // Seconds of longitude. + LongSeconds float64 `json:"long_seconds"` + // Horizontal precision of location. + PrecisionHorz float64 `json:"precision_horz"` + // Vertical precision of location. + PrecisionVert float64 `json:"precision_vert"` + // Size of location in meters. + Size float64 `json:"size"` + JSON recordNewResponseLOCDataJSON `json:"-"` +} + +// recordNewResponseLOCDataJSON contains the JSON metadata for the struct +// [RecordNewResponseLOCData] +type recordNewResponseLOCDataJSON struct { + Altitude apijson.Field + LatDegrees apijson.Field + LatDirection apijson.Field + LatMinutes apijson.Field + LatSeconds apijson.Field + LongDegrees apijson.Field + LongDirection apijson.Field + LongMinutes apijson.Field + LongSeconds apijson.Field + PrecisionHorz apijson.Field + PrecisionVert apijson.Field + Size apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseLOCData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseLOCDataJSON) RawJSON() string { + return r.raw +} + +// Latitude direction. +type RecordNewResponseLOCDataLatDirection string + +const ( + RecordNewResponseLOCDataLatDirectionN RecordNewResponseLOCDataLatDirection = "N" + RecordNewResponseLOCDataLatDirectionS RecordNewResponseLOCDataLatDirection = "S" +) + +// Longitude direction. +type RecordNewResponseLOCDataLongDirection string + +const ( + RecordNewResponseLOCDataLongDirectionE RecordNewResponseLOCDataLongDirection = "E" + RecordNewResponseLOCDataLongDirectionW RecordNewResponseLOCDataLongDirection = "W" +) + +// Record type. +type RecordNewResponseLOCType string + +const ( + RecordNewResponseLOCTypeLOC RecordNewResponseLOCType = "LOC" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseLOCMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseLOCMetaJSON `json:"-"` +} + +// recordNewResponseLOCMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseLOCMeta] +type recordNewResponseLOCMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseLOCMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseLOCMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordNewResponseLOCTTLNumber]. +type RecordNewResponseLOCTTL interface { + ImplementsDNSRecordNewResponseLocttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseLOCTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseLOCTTLNumber(0)), + }, + ) +} + +type RecordNewResponseLOCTTLNumber float64 + +const ( + RecordNewResponseLOCTTLNumber1 RecordNewResponseLOCTTLNumber = 1 +) + +type RecordNewResponseMX struct { + // A valid mail server hostname. + Content string `json:"content,required" format:"hostname"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority float64 `json:"priority,required"` + // Record type. + Type RecordNewResponseMXType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseMXMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseMXTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseMXJSON `json:"-"` +} + +// recordNewResponseMXJSON contains the JSON metadata for the struct +// [RecordNewResponseMX] +type recordNewResponseMXJSON struct { + Content apijson.Field + Name apijson.Field + Priority apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseMX) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseMXJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseMX) implementsDNSRecordNewResponse() {} + +// Record type. +type RecordNewResponseMXType string + +const ( + RecordNewResponseMXTypeMX RecordNewResponseMXType = "MX" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseMXMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseMXMetaJSON `json:"-"` +} + +// recordNewResponseMXMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseMXMeta] +type recordNewResponseMXMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseMXMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseMXMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordNewResponseMXTTLNumber]. +type RecordNewResponseMXTTL interface { + ImplementsDNSRecordNewResponseMxttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseMXTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseMXTTLNumber(0)), + }, + ) +} + +type RecordNewResponseMXTTLNumber float64 + +const ( + RecordNewResponseMXTTLNumber1 RecordNewResponseMXTTLNumber = 1 +) + +type RecordNewResponseNAPTR struct { + // Components of a NAPTR record. + Data RecordNewResponseNAPTRData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordNewResponseNAPTRType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted NAPTR content. See 'data' to set NAPTR properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseNAPTRMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseNAPTRTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseNAPTRJSON `json:"-"` +} + +// recordNewResponseNAPTRJSON contains the JSON metadata for the struct +// [RecordNewResponseNAPTR] +type recordNewResponseNAPTRJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseNAPTR) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseNAPTRJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseNAPTR) implementsDNSRecordNewResponse() {} + +// Components of a NAPTR record. +type RecordNewResponseNAPTRData struct { + // Flags. + Flags string `json:"flags"` + // Order. + Order float64 `json:"order"` + // Preference. + Preference float64 `json:"preference"` + // Regex. + Regex string `json:"regex"` + // Replacement. + Replacement string `json:"replacement"` + // Service. + Service string `json:"service"` + JSON recordNewResponseNAPTRDataJSON `json:"-"` +} + +// recordNewResponseNAPTRDataJSON contains the JSON metadata for the struct +// [RecordNewResponseNAPTRData] +type recordNewResponseNAPTRDataJSON struct { + Flags apijson.Field + Order apijson.Field + Preference apijson.Field + Regex apijson.Field + Replacement apijson.Field + Service apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseNAPTRData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseNAPTRDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordNewResponseNAPTRType string + +const ( + RecordNewResponseNAPTRTypeNAPTR RecordNewResponseNAPTRType = "NAPTR" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseNAPTRMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseNAPTRMetaJSON `json:"-"` +} + +// recordNewResponseNAPTRMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseNAPTRMeta] +type recordNewResponseNAPTRMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseNAPTRMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseNAPTRMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordNewResponseNAPTRTTLNumber]. +type RecordNewResponseNAPTRTTL interface { + ImplementsDNSRecordNewResponseNaptrttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseNAPTRTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseNAPTRTTLNumber(0)), + }, + ) +} + +type RecordNewResponseNAPTRTTLNumber float64 + +const ( + RecordNewResponseNAPTRTTLNumber1 RecordNewResponseNAPTRTTLNumber = 1 +) + +type RecordNewResponseNS struct { + // A valid name server host name. + Content interface{} `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordNewResponseNSType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseNSMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseNSTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseNSJSON `json:"-"` +} + +// recordNewResponseNSJSON contains the JSON metadata for the struct +// [RecordNewResponseNS] +type recordNewResponseNSJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseNS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseNSJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseNS) implementsDNSRecordNewResponse() {} + +// Record type. +type RecordNewResponseNSType string + +const ( + RecordNewResponseNSTypeNS RecordNewResponseNSType = "NS" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseNSMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseNSMetaJSON `json:"-"` +} + +// recordNewResponseNSMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseNSMeta] +type recordNewResponseNSMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseNSMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseNSMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordNewResponseNSTTLNumber]. +type RecordNewResponseNSTTL interface { + ImplementsDNSRecordNewResponseNsttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseNSTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseNSTTLNumber(0)), + }, + ) +} + +type RecordNewResponseNSTTLNumber float64 + +const ( + RecordNewResponseNSTTLNumber1 RecordNewResponseNSTTLNumber = 1 +) + +type RecordNewResponsePTR struct { + // Domain name pointing to the address. + Content string `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordNewResponsePTRType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponsePTRMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponsePTRTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponsePTRJSON `json:"-"` +} + +// recordNewResponsePTRJSON contains the JSON metadata for the struct +// [RecordNewResponsePTR] +type recordNewResponsePTRJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponsePTR) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponsePTRJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponsePTR) implementsDNSRecordNewResponse() {} + +// Record type. +type RecordNewResponsePTRType string + +const ( + RecordNewResponsePTRTypePTR RecordNewResponsePTRType = "PTR" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponsePTRMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponsePTRMetaJSON `json:"-"` +} + +// recordNewResponsePTRMetaJSON contains the JSON metadata for the struct +// [RecordNewResponsePTRMeta] +type recordNewResponsePTRMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponsePTRMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponsePTRMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordNewResponsePTRTTLNumber]. +type RecordNewResponsePTRTTL interface { + ImplementsDNSRecordNewResponsePtrttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponsePTRTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponsePTRTTLNumber(0)), + }, + ) +} + +type RecordNewResponsePTRTTLNumber float64 + +const ( + RecordNewResponsePTRTTLNumber1 RecordNewResponsePTRTTLNumber = 1 +) + +type RecordNewResponseSmimea struct { + // Components of a SMIMEA record. + Data RecordNewResponseSmimeaData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordNewResponseSmimeaType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted SMIMEA content. See 'data' to set SMIMEA properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseSmimeaMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseSmimeaTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseSmimeaJSON `json:"-"` +} + +// recordNewResponseSmimeaJSON contains the JSON metadata for the struct +// [RecordNewResponseSmimea] +type recordNewResponseSmimeaJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseSmimea) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseSmimeaJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseSmimea) implementsDNSRecordNewResponse() {} + +// Components of a SMIMEA record. +type RecordNewResponseSmimeaData struct { + // Certificate. + Certificate string `json:"certificate"` + // Matching Type. + MatchingType float64 `json:"matching_type"` + // Selector. + Selector float64 `json:"selector"` + // Usage. + Usage float64 `json:"usage"` + JSON recordNewResponseSmimeaDataJSON `json:"-"` +} + +// recordNewResponseSmimeaDataJSON contains the JSON metadata for the struct +// [RecordNewResponseSmimeaData] +type recordNewResponseSmimeaDataJSON struct { + Certificate apijson.Field + MatchingType apijson.Field + Selector apijson.Field + Usage apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseSmimeaData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseSmimeaDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordNewResponseSmimeaType string + +const ( + RecordNewResponseSmimeaTypeSmimea RecordNewResponseSmimeaType = "SMIMEA" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseSmimeaMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseSmimeaMetaJSON `json:"-"` +} + +// recordNewResponseSmimeaMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseSmimeaMeta] +type recordNewResponseSmimeaMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseSmimeaMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseSmimeaMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordNewResponseSmimeaTTLNumber]. +type RecordNewResponseSmimeaTTL interface { + ImplementsDNSRecordNewResponseSmimeaTTL() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseSmimeaTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseSmimeaTTLNumber(0)), + }, + ) +} + +type RecordNewResponseSmimeaTTLNumber float64 + +const ( + RecordNewResponseSmimeaTTLNumber1 RecordNewResponseSmimeaTTLNumber = 1 +) + +type RecordNewResponseSRV struct { + // Components of a SRV record. + Data RecordNewResponseSRVData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. For SRV records, the first + // label is normally a service and the second a protocol name, each starting with + // an underscore. + Name string `json:"name,required"` + // Record type. + Type RecordNewResponseSRVType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Priority, weight, port, and SRV target. See 'data' for setting the individual + // component values. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseSRVMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseSRVTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseSRVJSON `json:"-"` +} + +// recordNewResponseSRVJSON contains the JSON metadata for the struct +// [RecordNewResponseSRV] +type recordNewResponseSRVJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseSRV) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseSRVJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseSRV) implementsDNSRecordNewResponse() {} + +// Components of a SRV record. +type RecordNewResponseSRVData struct { + // A valid hostname. Deprecated in favor of the regular 'name' outside the data + // map. This data map field represents the remainder of the full 'name' after the + // service and protocol. + Name string `json:"name" format:"hostname"` + // The port of the service. + Port float64 `json:"port"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority float64 `json:"priority"` + // A valid protocol, prefixed with an underscore. Deprecated in favor of the + // regular 'name' outside the data map. This data map field normally represents the + // second label of that 'name'. + Proto string `json:"proto"` + // A service type, prefixed with an underscore. Deprecated in favor of the regular + // 'name' outside the data map. This data map field normally represents the first + // label of that 'name'. + Service string `json:"service"` + // A valid hostname. + Target string `json:"target" format:"hostname"` + // The record weight. + Weight float64 `json:"weight"` + JSON recordNewResponseSRVDataJSON `json:"-"` +} + +// recordNewResponseSRVDataJSON contains the JSON metadata for the struct +// [RecordNewResponseSRVData] +type recordNewResponseSRVDataJSON struct { + Name apijson.Field + Port apijson.Field + Priority apijson.Field + Proto apijson.Field + Service apijson.Field + Target apijson.Field + Weight apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseSRVData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseSRVDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordNewResponseSRVType string + +const ( + RecordNewResponseSRVTypeSRV RecordNewResponseSRVType = "SRV" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseSRVMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseSRVMetaJSON `json:"-"` +} + +// recordNewResponseSRVMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseSRVMeta] +type recordNewResponseSRVMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseSRVMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseSRVMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordNewResponseSRVTTLNumber]. +type RecordNewResponseSRVTTL interface { + ImplementsDNSRecordNewResponseSrvttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseSRVTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseSRVTTLNumber(0)), + }, + ) +} + +type RecordNewResponseSRVTTLNumber float64 + +const ( + RecordNewResponseSRVTTLNumber1 RecordNewResponseSRVTTLNumber = 1 +) + +type RecordNewResponseSSHFP struct { + // Components of a SSHFP record. + Data RecordNewResponseSSHFPData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordNewResponseSSHFPType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted SSHFP content. See 'data' to set SSHFP properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseSSHFPMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseSSHFPTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseSSHFPJSON `json:"-"` +} + +// recordNewResponseSSHFPJSON contains the JSON metadata for the struct +// [RecordNewResponseSSHFP] +type recordNewResponseSSHFPJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseSSHFP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseSSHFPJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseSSHFP) implementsDNSRecordNewResponse() {} + +// Components of a SSHFP record. +type RecordNewResponseSSHFPData struct { + // algorithm. + Algorithm float64 `json:"algorithm"` + // fingerprint. + Fingerprint string `json:"fingerprint"` + // type. + Type float64 `json:"type"` + JSON recordNewResponseSSHFPDataJSON `json:"-"` +} + +// recordNewResponseSSHFPDataJSON contains the JSON metadata for the struct +// [RecordNewResponseSSHFPData] +type recordNewResponseSSHFPDataJSON struct { + Algorithm apijson.Field + Fingerprint apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseSSHFPData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseSSHFPDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordNewResponseSSHFPType string + +const ( + RecordNewResponseSSHFPTypeSSHFP RecordNewResponseSSHFPType = "SSHFP" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseSSHFPMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseSSHFPMetaJSON `json:"-"` +} + +// recordNewResponseSSHFPMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseSSHFPMeta] +type recordNewResponseSSHFPMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseSSHFPMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseSSHFPMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordNewResponseSSHFPTTLNumber]. +type RecordNewResponseSSHFPTTL interface { + ImplementsDNSRecordNewResponseSshfpttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseSSHFPTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseSSHFPTTLNumber(0)), + }, + ) +} + +type RecordNewResponseSSHFPTTLNumber float64 + +const ( + RecordNewResponseSSHFPTTLNumber1 RecordNewResponseSSHFPTTLNumber = 1 +) + +type RecordNewResponseSVCB struct { + // Components of a SVCB record. + Data RecordNewResponseSVCBData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordNewResponseSVCBType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted SVCB content. See 'data' to set SVCB properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseSVCBMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseSVCBTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseSVCBJSON `json:"-"` +} + +// recordNewResponseSVCBJSON contains the JSON metadata for the struct +// [RecordNewResponseSVCB] +type recordNewResponseSVCBJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseSVCB) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseSVCBJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseSVCB) implementsDNSRecordNewResponse() {} + +// Components of a SVCB record. +type RecordNewResponseSVCBData struct { + // priority. + Priority float64 `json:"priority"` + // target. + Target string `json:"target"` + // value. + Value string `json:"value"` + JSON recordNewResponseSVCBDataJSON `json:"-"` +} + +// recordNewResponseSVCBDataJSON contains the JSON metadata for the struct +// [RecordNewResponseSVCBData] +type recordNewResponseSVCBDataJSON struct { + Priority apijson.Field + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseSVCBData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseSVCBDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordNewResponseSVCBType string + +const ( + RecordNewResponseSVCBTypeSVCB RecordNewResponseSVCBType = "SVCB" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseSVCBMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseSVCBMetaJSON `json:"-"` +} + +// recordNewResponseSVCBMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseSVCBMeta] +type recordNewResponseSVCBMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseSVCBMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseSVCBMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordNewResponseSVCBTTLNumber]. +type RecordNewResponseSVCBTTL interface { + ImplementsDNSRecordNewResponseSvcbttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseSVCBTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseSVCBTTLNumber(0)), + }, + ) +} + +type RecordNewResponseSVCBTTLNumber float64 + +const ( + RecordNewResponseSVCBTTLNumber1 RecordNewResponseSVCBTTLNumber = 1 +) + +type RecordNewResponseTLSA struct { + // Components of a TLSA record. + Data RecordNewResponseTLSAData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordNewResponseTLSAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted TLSA content. See 'data' to set TLSA properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseTLSAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseTLSATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseTLSAJSON `json:"-"` +} + +// recordNewResponseTLSAJSON contains the JSON metadata for the struct +// [RecordNewResponseTLSA] +type recordNewResponseTLSAJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseTLSA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseTLSAJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseTLSA) implementsDNSRecordNewResponse() {} + +// Components of a TLSA record. +type RecordNewResponseTLSAData struct { + // certificate. + Certificate string `json:"certificate"` + // Matching Type. + MatchingType float64 `json:"matching_type"` + // Selector. + Selector float64 `json:"selector"` + // Usage. + Usage float64 `json:"usage"` + JSON recordNewResponseTLSADataJSON `json:"-"` +} + +// recordNewResponseTLSADataJSON contains the JSON metadata for the struct +// [RecordNewResponseTLSAData] +type recordNewResponseTLSADataJSON struct { + Certificate apijson.Field + MatchingType apijson.Field + Selector apijson.Field + Usage apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseTLSAData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseTLSADataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordNewResponseTLSAType string + +const ( + RecordNewResponseTLSATypeTLSA RecordNewResponseTLSAType = "TLSA" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseTLSAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseTLSAMetaJSON `json:"-"` +} + +// recordNewResponseTLSAMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseTLSAMeta] +type recordNewResponseTLSAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseTLSAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseTLSAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordNewResponseTLSATTLNumber]. +type RecordNewResponseTLSATTL interface { + ImplementsDNSRecordNewResponseTlsattl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseTLSATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseTLSATTLNumber(0)), + }, + ) +} + +type RecordNewResponseTLSATTLNumber float64 + +const ( + RecordNewResponseTLSATTLNumber1 RecordNewResponseTLSATTLNumber = 1 +) + +type RecordNewResponseTXT struct { + // Text content for the record. + Content string `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordNewResponseTXTType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseTXTMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseTXTTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseTXTJSON `json:"-"` +} + +// recordNewResponseTXTJSON contains the JSON metadata for the struct +// [RecordNewResponseTXT] +type recordNewResponseTXTJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseTXT) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseTXTJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseTXT) implementsDNSRecordNewResponse() {} + +// Record type. +type RecordNewResponseTXTType string + +const ( + RecordNewResponseTXTTypeTXT RecordNewResponseTXTType = "TXT" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseTXTMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseTXTMetaJSON `json:"-"` +} + +// recordNewResponseTXTMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseTXTMeta] +type recordNewResponseTXTMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseTXTMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseTXTMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordNewResponseTXTTTLNumber]. +type RecordNewResponseTXTTTL interface { + ImplementsDNSRecordNewResponseTxtttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseTXTTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseTXTTTLNumber(0)), + }, + ) +} + +type RecordNewResponseTXTTTLNumber float64 + +const ( + RecordNewResponseTXTTTLNumber1 RecordNewResponseTXTTTLNumber = 1 +) + +type RecordNewResponseURI struct { + // Components of a URI record. + Data RecordNewResponseURIData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority float64 `json:"priority,required"` + // Record type. + Type RecordNewResponseURIType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted URI content. See 'data' to set URI properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordNewResponseURIMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordNewResponseURITTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordNewResponseURIJSON `json:"-"` +} + +// recordNewResponseURIJSON contains the JSON metadata for the struct +// [RecordNewResponseURI] +type recordNewResponseURIJSON struct { + Data apijson.Field + Name apijson.Field + Priority apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseURI) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseURIJSON) RawJSON() string { + return r.raw +} + +func (r RecordNewResponseURI) implementsDNSRecordNewResponse() {} + +// Components of a URI record. +type RecordNewResponseURIData struct { + // The record content. + Content string `json:"content"` + // The record weight. + Weight float64 `json:"weight"` + JSON recordNewResponseURIDataJSON `json:"-"` +} + +// recordNewResponseURIDataJSON contains the JSON metadata for the struct +// [RecordNewResponseURIData] +type recordNewResponseURIDataJSON struct { + Content apijson.Field + Weight apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseURIData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseURIDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordNewResponseURIType string + +const ( + RecordNewResponseURITypeURI RecordNewResponseURIType = "URI" +) + +// Extra Cloudflare-specific information about the record. +type RecordNewResponseURIMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordNewResponseURIMetaJSON `json:"-"` +} + +// recordNewResponseURIMetaJSON contains the JSON metadata for the struct +// [RecordNewResponseURIMeta] +type recordNewResponseURIMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseURIMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseURIMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordNewResponseURITTLNumber]. +type RecordNewResponseURITTL interface { + ImplementsDNSRecordNewResponseUrittl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordNewResponseURITTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordNewResponseURITTLNumber(0)), + }, + ) +} + +type RecordNewResponseURITTLNumber float64 + +const ( + RecordNewResponseURITTLNumber1 RecordNewResponseURITTLNumber = 1 +) + +// Union satisfied by [dns.RecordUpdateResponseA], [dns.RecordUpdateResponseAAAA], +// [dns.RecordUpdateResponseCAA], [dns.RecordUpdateResponseCert], +// [dns.RecordUpdateResponseCNAME], [dns.RecordUpdateResponseDNSKEY], +// [dns.RecordUpdateResponseDS], [dns.RecordUpdateResponseHTTPS], +// [dns.RecordUpdateResponseLOC], [dns.RecordUpdateResponseMX], +// [dns.RecordUpdateResponseNAPTR], [dns.RecordUpdateResponseNS], +// [dns.RecordUpdateResponsePTR], [dns.RecordUpdateResponseSmimea], +// [dns.RecordUpdateResponseSRV], [dns.RecordUpdateResponseSSHFP], +// [dns.RecordUpdateResponseSVCB], [dns.RecordUpdateResponseTLSA], +// [dns.RecordUpdateResponseTXT] or [dns.RecordUpdateResponseURI]. +type RecordUpdateResponse interface { + implementsDNSRecordUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponse)(nil)).Elem(), + "type", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseA{}), + DiscriminatorValue: "A", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseAAAA{}), + DiscriminatorValue: "AAAA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseCAA{}), + DiscriminatorValue: "CAA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseCert{}), + DiscriminatorValue: "CERT", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseCNAME{}), + DiscriminatorValue: "CNAME", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseDNSKEY{}), + DiscriminatorValue: "DNSKEY", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseDS{}), + DiscriminatorValue: "DS", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseHTTPS{}), + DiscriminatorValue: "HTTPS", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseLOC{}), + DiscriminatorValue: "LOC", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseMX{}), + DiscriminatorValue: "MX", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseNAPTR{}), + DiscriminatorValue: "NAPTR", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseNS{}), + DiscriminatorValue: "NS", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponsePTR{}), + DiscriminatorValue: "PTR", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseSmimea{}), + DiscriminatorValue: "SMIMEA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseSRV{}), + DiscriminatorValue: "SRV", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseSSHFP{}), + DiscriminatorValue: "SSHFP", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseSVCB{}), + DiscriminatorValue: "SVCB", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseTLSA{}), + DiscriminatorValue: "TLSA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseTXT{}), + DiscriminatorValue: "TXT", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordUpdateResponseURI{}), + DiscriminatorValue: "URI", + }, + ) +} + +type RecordUpdateResponseA struct { + // A valid IPv4 address. + Content string `json:"content,required" format:"ipv4"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordUpdateResponseAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied bool `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseAJSON `json:"-"` +} + +// recordUpdateResponseAJSON contains the JSON metadata for the struct +// [RecordUpdateResponseA] +type recordUpdateResponseAJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Proxied apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseAJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseA) implementsDNSRecordUpdateResponse() {} + +// Record type. +type RecordUpdateResponseAType string + +const ( + RecordUpdateResponseATypeA RecordUpdateResponseAType = "A" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseAMetaJSON `json:"-"` +} + +// recordUpdateResponseAMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseAMeta] +type recordUpdateResponseAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordUpdateResponseATTLNumber]. +type RecordUpdateResponseATTL interface { + ImplementsDNSRecordUpdateResponseAttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseATTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseATTLNumber float64 + +const ( + RecordUpdateResponseATTLNumber1 RecordUpdateResponseATTLNumber = 1 +) + +type RecordUpdateResponseAAAA struct { + // A valid IPv6 address. + Content string `json:"content,required" format:"ipv6"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordUpdateResponseAAAAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseAAAAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied bool `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseAAAATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseAAAAJSON `json:"-"` +} + +// recordUpdateResponseAAAAJSON contains the JSON metadata for the struct +// [RecordUpdateResponseAAAA] +type recordUpdateResponseAAAAJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Proxied apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseAAAA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseAAAAJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseAAAA) implementsDNSRecordUpdateResponse() {} + +// Record type. +type RecordUpdateResponseAAAAType string + +const ( + RecordUpdateResponseAAAATypeAAAA RecordUpdateResponseAAAAType = "AAAA" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseAAAAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseAAAAMetaJSON `json:"-"` +} + +// recordUpdateResponseAAAAMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseAAAAMeta] +type recordUpdateResponseAAAAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseAAAAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseAAAAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordUpdateResponseAAAATTLNumber]. +type RecordUpdateResponseAAAATTL interface { + ImplementsDNSRecordUpdateResponseAaaattl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseAAAATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseAAAATTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseAAAATTLNumber float64 + +const ( + RecordUpdateResponseAAAATTLNumber1 RecordUpdateResponseAAAATTLNumber = 1 +) + +type RecordUpdateResponseCAA struct { + // Components of a CAA record. + Data RecordUpdateResponseCAAData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordUpdateResponseCAAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted CAA content. See 'data' to set CAA properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseCAAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseCAATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseCAAJSON `json:"-"` +} + +// recordUpdateResponseCAAJSON contains the JSON metadata for the struct +// [RecordUpdateResponseCAA] +type recordUpdateResponseCAAJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseCAA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseCAAJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseCAA) implementsDNSRecordUpdateResponse() {} + +// Components of a CAA record. +type RecordUpdateResponseCAAData struct { + // Flags for the CAA record. + Flags float64 `json:"flags"` + // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). + Tag string `json:"tag"` + // Value of the record. This field's semantics depend on the chosen tag. + Value string `json:"value"` + JSON recordUpdateResponseCAADataJSON `json:"-"` +} + +// recordUpdateResponseCAADataJSON contains the JSON metadata for the struct +// [RecordUpdateResponseCAAData] +type recordUpdateResponseCAADataJSON struct { + Flags apijson.Field + Tag apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseCAAData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseCAADataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordUpdateResponseCAAType string + +const ( + RecordUpdateResponseCAATypeCAA RecordUpdateResponseCAAType = "CAA" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseCAAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseCAAMetaJSON `json:"-"` +} + +// recordUpdateResponseCAAMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseCAAMeta] +type recordUpdateResponseCAAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseCAAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseCAAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordUpdateResponseCAATTLNumber]. +type RecordUpdateResponseCAATTL interface { + ImplementsDNSRecordUpdateResponseCaattl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseCAATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseCAATTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseCAATTLNumber float64 + +const ( + RecordUpdateResponseCAATTLNumber1 RecordUpdateResponseCAATTLNumber = 1 +) + +type RecordUpdateResponseCert struct { + // Components of a CERT record. + Data RecordUpdateResponseCertData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordUpdateResponseCertType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted CERT content. See 'data' to set CERT properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseCertMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseCertTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseCertJSON `json:"-"` +} + +// recordUpdateResponseCertJSON contains the JSON metadata for the struct +// [RecordUpdateResponseCert] +type recordUpdateResponseCertJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseCert) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseCertJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseCert) implementsDNSRecordUpdateResponse() {} + +// Components of a CERT record. +type RecordUpdateResponseCertData struct { + // Algorithm. + Algorithm float64 `json:"algorithm"` + // Certificate. + Certificate string `json:"certificate"` + // Key Tag. + KeyTag float64 `json:"key_tag"` + // Type. + Type float64 `json:"type"` + JSON recordUpdateResponseCertDataJSON `json:"-"` +} + +// recordUpdateResponseCertDataJSON contains the JSON metadata for the struct +// [RecordUpdateResponseCertData] +type recordUpdateResponseCertDataJSON struct { + Algorithm apijson.Field + Certificate apijson.Field + KeyTag apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseCertData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseCertDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordUpdateResponseCertType string + +const ( + RecordUpdateResponseCertTypeCert RecordUpdateResponseCertType = "CERT" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseCertMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseCertMetaJSON `json:"-"` +} + +// recordUpdateResponseCertMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseCertMeta] +type recordUpdateResponseCertMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseCertMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseCertMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordUpdateResponseCertTTLNumber]. +type RecordUpdateResponseCertTTL interface { + ImplementsDNSRecordUpdateResponseCertTTL() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseCertTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseCertTTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseCertTTLNumber float64 + +const ( + RecordUpdateResponseCertTTLNumber1 RecordUpdateResponseCertTTLNumber = 1 +) + +type RecordUpdateResponseCNAME struct { + // A valid hostname. Must not match the record's name. + Content interface{} `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordUpdateResponseCNAMEType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseCNAMEMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied bool `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseCNAMETTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseCNAMEJSON `json:"-"` +} + +// recordUpdateResponseCNAMEJSON contains the JSON metadata for the struct +// [RecordUpdateResponseCNAME] +type recordUpdateResponseCNAMEJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Proxied apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseCNAME) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseCNAMEJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseCNAME) implementsDNSRecordUpdateResponse() {} + +// Record type. +type RecordUpdateResponseCNAMEType string + +const ( + RecordUpdateResponseCNAMETypeCNAME RecordUpdateResponseCNAMEType = "CNAME" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseCNAMEMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseCNAMEMetaJSON `json:"-"` +} + +// recordUpdateResponseCNAMEMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseCNAMEMeta] +type recordUpdateResponseCNAMEMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseCNAMEMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseCNAMEMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordUpdateResponseCNAMETTLNumber]. +type RecordUpdateResponseCNAMETTL interface { + ImplementsDNSRecordUpdateResponseCnamettl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseCNAMETTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseCNAMETTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseCNAMETTLNumber float64 + +const ( + RecordUpdateResponseCNAMETTLNumber1 RecordUpdateResponseCNAMETTLNumber = 1 +) + +type RecordUpdateResponseDNSKEY struct { + // Components of a DNSKEY record. + Data RecordUpdateResponseDNSKEYData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordUpdateResponseDNSKEYType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted DNSKEY content. See 'data' to set DNSKEY properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseDNSKEYMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseDNSKEYTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseDNSKEYJSON `json:"-"` +} + +// recordUpdateResponseDNSKEYJSON contains the JSON metadata for the struct +// [RecordUpdateResponseDNSKEY] +type recordUpdateResponseDNSKEYJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseDNSKEY) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseDNSKEYJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseDNSKEY) implementsDNSRecordUpdateResponse() {} + +// Components of a DNSKEY record. +type RecordUpdateResponseDNSKEYData struct { + // Algorithm. + Algorithm float64 `json:"algorithm"` + // Flags. + Flags float64 `json:"flags"` + // Protocol. + Protocol float64 `json:"protocol"` + // Public Key. + PublicKey string `json:"public_key"` + JSON recordUpdateResponseDNSKEYDataJSON `json:"-"` +} + +// recordUpdateResponseDNSKEYDataJSON contains the JSON metadata for the struct +// [RecordUpdateResponseDNSKEYData] +type recordUpdateResponseDNSKEYDataJSON struct { + Algorithm apijson.Field + Flags apijson.Field + Protocol apijson.Field + PublicKey apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseDNSKEYData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseDNSKEYDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordUpdateResponseDNSKEYType string + +const ( + RecordUpdateResponseDNSKEYTypeDNSKEY RecordUpdateResponseDNSKEYType = "DNSKEY" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseDNSKEYMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseDNSKEYMetaJSON `json:"-"` +} + +// recordUpdateResponseDNSKEYMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseDNSKEYMeta] +type recordUpdateResponseDNSKEYMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseDNSKEYMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseDNSKEYMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordUpdateResponseDNSKEYTTLNumber]. +type RecordUpdateResponseDNSKEYTTL interface { + ImplementsDNSRecordUpdateResponseDnskeyttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseDNSKEYTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseDNSKEYTTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseDNSKEYTTLNumber float64 + +const ( + RecordUpdateResponseDNSKEYTTLNumber1 RecordUpdateResponseDNSKEYTTLNumber = 1 +) + +type RecordUpdateResponseDS struct { + // Components of a DS record. + Data RecordUpdateResponseDSData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordUpdateResponseDSType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted DS content. See 'data' to set DS properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseDSMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseDSTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseDSJSON `json:"-"` +} + +// recordUpdateResponseDSJSON contains the JSON metadata for the struct +// [RecordUpdateResponseDS] +type recordUpdateResponseDSJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseDS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseDSJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseDS) implementsDNSRecordUpdateResponse() {} + +// Components of a DS record. +type RecordUpdateResponseDSData struct { + // Algorithm. + Algorithm float64 `json:"algorithm"` + // Digest. + Digest string `json:"digest"` + // Digest Type. + DigestType float64 `json:"digest_type"` + // Key Tag. + KeyTag float64 `json:"key_tag"` + JSON recordUpdateResponseDSDataJSON `json:"-"` +} + +// recordUpdateResponseDSDataJSON contains the JSON metadata for the struct +// [RecordUpdateResponseDSData] +type recordUpdateResponseDSDataJSON struct { + Algorithm apijson.Field + Digest apijson.Field + DigestType apijson.Field + KeyTag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseDSData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseDSDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordUpdateResponseDSType string + +const ( + RecordUpdateResponseDSTypeDS RecordUpdateResponseDSType = "DS" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseDSMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseDSMetaJSON `json:"-"` +} + +// recordUpdateResponseDSMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseDSMeta] +type recordUpdateResponseDSMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseDSMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseDSMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordUpdateResponseDSTTLNumber]. +type RecordUpdateResponseDSTTL interface { + ImplementsDNSRecordUpdateResponseDsttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseDSTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseDSTTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseDSTTLNumber float64 + +const ( + RecordUpdateResponseDSTTLNumber1 RecordUpdateResponseDSTTLNumber = 1 +) + +type RecordUpdateResponseHTTPS struct { + // Components of a HTTPS record. + Data RecordUpdateResponseHTTPSData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordUpdateResponseHTTPSType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted HTTPS content. See 'data' to set HTTPS properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseHTTPSMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseHTTPSTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseHTTPSJSON `json:"-"` +} + +// recordUpdateResponseHTTPSJSON contains the JSON metadata for the struct +// [RecordUpdateResponseHTTPS] +type recordUpdateResponseHTTPSJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseHTTPS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseHTTPSJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseHTTPS) implementsDNSRecordUpdateResponse() {} + +// Components of a HTTPS record. +type RecordUpdateResponseHTTPSData struct { + // priority. + Priority float64 `json:"priority"` + // target. + Target string `json:"target"` + // value. + Value string `json:"value"` + JSON recordUpdateResponseHTTPSDataJSON `json:"-"` +} + +// recordUpdateResponseHTTPSDataJSON contains the JSON metadata for the struct +// [RecordUpdateResponseHTTPSData] +type recordUpdateResponseHTTPSDataJSON struct { + Priority apijson.Field + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseHTTPSData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseHTTPSDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordUpdateResponseHTTPSType string + +const ( + RecordUpdateResponseHTTPSTypeHTTPS RecordUpdateResponseHTTPSType = "HTTPS" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseHTTPSMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseHTTPSMetaJSON `json:"-"` +} + +// recordUpdateResponseHTTPSMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseHTTPSMeta] +type recordUpdateResponseHTTPSMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseHTTPSMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseHTTPSMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordUpdateResponseHTTPSTTLNumber]. +type RecordUpdateResponseHTTPSTTL interface { + ImplementsDNSRecordUpdateResponseHttpsttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseHTTPSTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseHTTPSTTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseHTTPSTTLNumber float64 + +const ( + RecordUpdateResponseHTTPSTTLNumber1 RecordUpdateResponseHTTPSTTLNumber = 1 +) + +type RecordUpdateResponseLOC struct { + // Components of a LOC record. + Data RecordUpdateResponseLOCData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordUpdateResponseLOCType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted LOC content. See 'data' to set LOC properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseLOCMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseLOCTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseLOCJSON `json:"-"` +} + +// recordUpdateResponseLOCJSON contains the JSON metadata for the struct +// [RecordUpdateResponseLOC] +type recordUpdateResponseLOCJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseLOC) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseLOCJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseLOC) implementsDNSRecordUpdateResponse() {} + +// Components of a LOC record. +type RecordUpdateResponseLOCData struct { + // Altitude of location in meters. + Altitude float64 `json:"altitude"` + // Degrees of latitude. + LatDegrees float64 `json:"lat_degrees"` + // Latitude direction. + LatDirection RecordUpdateResponseLOCDataLatDirection `json:"lat_direction"` + // Minutes of latitude. + LatMinutes float64 `json:"lat_minutes"` + // Seconds of latitude. + LatSeconds float64 `json:"lat_seconds"` + // Degrees of longitude. + LongDegrees float64 `json:"long_degrees"` + // Longitude direction. + LongDirection RecordUpdateResponseLOCDataLongDirection `json:"long_direction"` + // Minutes of longitude. + LongMinutes float64 `json:"long_minutes"` + // Seconds of longitude. + LongSeconds float64 `json:"long_seconds"` + // Horizontal precision of location. + PrecisionHorz float64 `json:"precision_horz"` + // Vertical precision of location. + PrecisionVert float64 `json:"precision_vert"` + // Size of location in meters. + Size float64 `json:"size"` + JSON recordUpdateResponseLOCDataJSON `json:"-"` +} + +// recordUpdateResponseLOCDataJSON contains the JSON metadata for the struct +// [RecordUpdateResponseLOCData] +type recordUpdateResponseLOCDataJSON struct { + Altitude apijson.Field + LatDegrees apijson.Field + LatDirection apijson.Field + LatMinutes apijson.Field + LatSeconds apijson.Field + LongDegrees apijson.Field + LongDirection apijson.Field + LongMinutes apijson.Field + LongSeconds apijson.Field + PrecisionHorz apijson.Field + PrecisionVert apijson.Field + Size apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseLOCData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseLOCDataJSON) RawJSON() string { + return r.raw +} + +// Latitude direction. +type RecordUpdateResponseLOCDataLatDirection string + +const ( + RecordUpdateResponseLOCDataLatDirectionN RecordUpdateResponseLOCDataLatDirection = "N" + RecordUpdateResponseLOCDataLatDirectionS RecordUpdateResponseLOCDataLatDirection = "S" +) + +// Longitude direction. +type RecordUpdateResponseLOCDataLongDirection string + +const ( + RecordUpdateResponseLOCDataLongDirectionE RecordUpdateResponseLOCDataLongDirection = "E" + RecordUpdateResponseLOCDataLongDirectionW RecordUpdateResponseLOCDataLongDirection = "W" +) + +// Record type. +type RecordUpdateResponseLOCType string + +const ( + RecordUpdateResponseLOCTypeLOC RecordUpdateResponseLOCType = "LOC" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseLOCMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseLOCMetaJSON `json:"-"` +} + +// recordUpdateResponseLOCMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseLOCMeta] +type recordUpdateResponseLOCMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseLOCMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseLOCMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordUpdateResponseLOCTTLNumber]. +type RecordUpdateResponseLOCTTL interface { + ImplementsDNSRecordUpdateResponseLocttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseLOCTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseLOCTTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseLOCTTLNumber float64 + +const ( + RecordUpdateResponseLOCTTLNumber1 RecordUpdateResponseLOCTTLNumber = 1 +) + +type RecordUpdateResponseMX struct { + // A valid mail server hostname. + Content string `json:"content,required" format:"hostname"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority float64 `json:"priority,required"` + // Record type. + Type RecordUpdateResponseMXType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseMXMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseMXTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseMXJSON `json:"-"` +} + +// recordUpdateResponseMXJSON contains the JSON metadata for the struct +// [RecordUpdateResponseMX] +type recordUpdateResponseMXJSON struct { + Content apijson.Field + Name apijson.Field + Priority apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseMX) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseMXJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseMX) implementsDNSRecordUpdateResponse() {} + +// Record type. +type RecordUpdateResponseMXType string + +const ( + RecordUpdateResponseMXTypeMX RecordUpdateResponseMXType = "MX" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseMXMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseMXMetaJSON `json:"-"` +} + +// recordUpdateResponseMXMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseMXMeta] +type recordUpdateResponseMXMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseMXMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseMXMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordUpdateResponseMXTTLNumber]. +type RecordUpdateResponseMXTTL interface { + ImplementsDNSRecordUpdateResponseMxttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseMXTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseMXTTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseMXTTLNumber float64 + +const ( + RecordUpdateResponseMXTTLNumber1 RecordUpdateResponseMXTTLNumber = 1 +) + +type RecordUpdateResponseNAPTR struct { + // Components of a NAPTR record. + Data RecordUpdateResponseNAPTRData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordUpdateResponseNAPTRType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted NAPTR content. See 'data' to set NAPTR properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseNAPTRMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseNAPTRTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseNAPTRJSON `json:"-"` +} + +// recordUpdateResponseNAPTRJSON contains the JSON metadata for the struct +// [RecordUpdateResponseNAPTR] +type recordUpdateResponseNAPTRJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseNAPTR) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseNAPTRJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseNAPTR) implementsDNSRecordUpdateResponse() {} + +// Components of a NAPTR record. +type RecordUpdateResponseNAPTRData struct { + // Flags. + Flags string `json:"flags"` + // Order. + Order float64 `json:"order"` + // Preference. + Preference float64 `json:"preference"` + // Regex. + Regex string `json:"regex"` + // Replacement. + Replacement string `json:"replacement"` + // Service. + Service string `json:"service"` + JSON recordUpdateResponseNAPTRDataJSON `json:"-"` +} + +// recordUpdateResponseNAPTRDataJSON contains the JSON metadata for the struct +// [RecordUpdateResponseNAPTRData] +type recordUpdateResponseNAPTRDataJSON struct { + Flags apijson.Field + Order apijson.Field + Preference apijson.Field + Regex apijson.Field + Replacement apijson.Field + Service apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseNAPTRData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseNAPTRDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordUpdateResponseNAPTRType string + +const ( + RecordUpdateResponseNAPTRTypeNAPTR RecordUpdateResponseNAPTRType = "NAPTR" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseNAPTRMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseNAPTRMetaJSON `json:"-"` +} + +// recordUpdateResponseNAPTRMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseNAPTRMeta] +type recordUpdateResponseNAPTRMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseNAPTRMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseNAPTRMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordUpdateResponseNAPTRTTLNumber]. +type RecordUpdateResponseNAPTRTTL interface { + ImplementsDNSRecordUpdateResponseNaptrttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseNAPTRTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseNAPTRTTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseNAPTRTTLNumber float64 + +const ( + RecordUpdateResponseNAPTRTTLNumber1 RecordUpdateResponseNAPTRTTLNumber = 1 +) + +type RecordUpdateResponseNS struct { + // A valid name server host name. + Content interface{} `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordUpdateResponseNSType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseNSMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseNSTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseNSJSON `json:"-"` +} + +// recordUpdateResponseNSJSON contains the JSON metadata for the struct +// [RecordUpdateResponseNS] +type recordUpdateResponseNSJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseNS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseNSJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseNS) implementsDNSRecordUpdateResponse() {} + +// Record type. +type RecordUpdateResponseNSType string + +const ( + RecordUpdateResponseNSTypeNS RecordUpdateResponseNSType = "NS" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseNSMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseNSMetaJSON `json:"-"` +} + +// recordUpdateResponseNSMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseNSMeta] +type recordUpdateResponseNSMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseNSMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseNSMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordUpdateResponseNSTTLNumber]. +type RecordUpdateResponseNSTTL interface { + ImplementsDNSRecordUpdateResponseNsttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseNSTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseNSTTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseNSTTLNumber float64 + +const ( + RecordUpdateResponseNSTTLNumber1 RecordUpdateResponseNSTTLNumber = 1 +) + +type RecordUpdateResponsePTR struct { + // Domain name pointing to the address. + Content string `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordUpdateResponsePTRType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponsePTRMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponsePTRTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponsePTRJSON `json:"-"` +} + +// recordUpdateResponsePTRJSON contains the JSON metadata for the struct +// [RecordUpdateResponsePTR] +type recordUpdateResponsePTRJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponsePTR) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponsePTRJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponsePTR) implementsDNSRecordUpdateResponse() {} + +// Record type. +type RecordUpdateResponsePTRType string + +const ( + RecordUpdateResponsePTRTypePTR RecordUpdateResponsePTRType = "PTR" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponsePTRMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponsePTRMetaJSON `json:"-"` +} + +// recordUpdateResponsePTRMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponsePTRMeta] +type recordUpdateResponsePTRMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponsePTRMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponsePTRMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordUpdateResponsePTRTTLNumber]. +type RecordUpdateResponsePTRTTL interface { + ImplementsDNSRecordUpdateResponsePtrttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponsePTRTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponsePTRTTLNumber(0)), + }, + ) +} + +type RecordUpdateResponsePTRTTLNumber float64 + +const ( + RecordUpdateResponsePTRTTLNumber1 RecordUpdateResponsePTRTTLNumber = 1 +) + +type RecordUpdateResponseSmimea struct { + // Components of a SMIMEA record. + Data RecordUpdateResponseSmimeaData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordUpdateResponseSmimeaType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted SMIMEA content. See 'data' to set SMIMEA properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseSmimeaMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseSmimeaTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseSmimeaJSON `json:"-"` +} + +// recordUpdateResponseSmimeaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseSmimea] +type recordUpdateResponseSmimeaJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseSmimea) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseSmimeaJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseSmimea) implementsDNSRecordUpdateResponse() {} + +// Components of a SMIMEA record. +type RecordUpdateResponseSmimeaData struct { + // Certificate. + Certificate string `json:"certificate"` + // Matching Type. + MatchingType float64 `json:"matching_type"` + // Selector. + Selector float64 `json:"selector"` + // Usage. + Usage float64 `json:"usage"` + JSON recordUpdateResponseSmimeaDataJSON `json:"-"` +} + +// recordUpdateResponseSmimeaDataJSON contains the JSON metadata for the struct +// [RecordUpdateResponseSmimeaData] +type recordUpdateResponseSmimeaDataJSON struct { + Certificate apijson.Field + MatchingType apijson.Field + Selector apijson.Field + Usage apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseSmimeaData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseSmimeaDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordUpdateResponseSmimeaType string + +const ( + RecordUpdateResponseSmimeaTypeSmimea RecordUpdateResponseSmimeaType = "SMIMEA" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseSmimeaMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseSmimeaMetaJSON `json:"-"` +} + +// recordUpdateResponseSmimeaMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseSmimeaMeta] +type recordUpdateResponseSmimeaMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseSmimeaMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseSmimeaMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordUpdateResponseSmimeaTTLNumber]. +type RecordUpdateResponseSmimeaTTL interface { + ImplementsDNSRecordUpdateResponseSmimeaTTL() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseSmimeaTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseSmimeaTTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseSmimeaTTLNumber float64 + +const ( + RecordUpdateResponseSmimeaTTLNumber1 RecordUpdateResponseSmimeaTTLNumber = 1 +) + +type RecordUpdateResponseSRV struct { + // Components of a SRV record. + Data RecordUpdateResponseSRVData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. For SRV records, the first + // label is normally a service and the second a protocol name, each starting with + // an underscore. + Name string `json:"name,required"` + // Record type. + Type RecordUpdateResponseSRVType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Priority, weight, port, and SRV target. See 'data' for setting the individual + // component values. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseSRVMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseSRVTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseSRVJSON `json:"-"` +} + +// recordUpdateResponseSRVJSON contains the JSON metadata for the struct +// [RecordUpdateResponseSRV] +type recordUpdateResponseSRVJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseSRV) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseSRVJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseSRV) implementsDNSRecordUpdateResponse() {} + +// Components of a SRV record. +type RecordUpdateResponseSRVData struct { + // A valid hostname. Deprecated in favor of the regular 'name' outside the data + // map. This data map field represents the remainder of the full 'name' after the + // service and protocol. + Name string `json:"name" format:"hostname"` + // The port of the service. + Port float64 `json:"port"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority float64 `json:"priority"` + // A valid protocol, prefixed with an underscore. Deprecated in favor of the + // regular 'name' outside the data map. This data map field normally represents the + // second label of that 'name'. + Proto string `json:"proto"` + // A service type, prefixed with an underscore. Deprecated in favor of the regular + // 'name' outside the data map. This data map field normally represents the first + // label of that 'name'. + Service string `json:"service"` + // A valid hostname. + Target string `json:"target" format:"hostname"` + // The record weight. + Weight float64 `json:"weight"` + JSON recordUpdateResponseSRVDataJSON `json:"-"` +} + +// recordUpdateResponseSRVDataJSON contains the JSON metadata for the struct +// [RecordUpdateResponseSRVData] +type recordUpdateResponseSRVDataJSON struct { + Name apijson.Field + Port apijson.Field + Priority apijson.Field + Proto apijson.Field + Service apijson.Field + Target apijson.Field + Weight apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseSRVData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseSRVDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordUpdateResponseSRVType string + +const ( + RecordUpdateResponseSRVTypeSRV RecordUpdateResponseSRVType = "SRV" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseSRVMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseSRVMetaJSON `json:"-"` +} + +// recordUpdateResponseSRVMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseSRVMeta] +type recordUpdateResponseSRVMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseSRVMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseSRVMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordUpdateResponseSRVTTLNumber]. +type RecordUpdateResponseSRVTTL interface { + ImplementsDNSRecordUpdateResponseSrvttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseSRVTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseSRVTTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseSRVTTLNumber float64 + +const ( + RecordUpdateResponseSRVTTLNumber1 RecordUpdateResponseSRVTTLNumber = 1 +) + +type RecordUpdateResponseSSHFP struct { + // Components of a SSHFP record. + Data RecordUpdateResponseSSHFPData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordUpdateResponseSSHFPType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted SSHFP content. See 'data' to set SSHFP properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseSSHFPMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseSSHFPTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseSSHFPJSON `json:"-"` +} + +// recordUpdateResponseSSHFPJSON contains the JSON metadata for the struct +// [RecordUpdateResponseSSHFP] +type recordUpdateResponseSSHFPJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseSSHFP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseSSHFPJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseSSHFP) implementsDNSRecordUpdateResponse() {} + +// Components of a SSHFP record. +type RecordUpdateResponseSSHFPData struct { + // algorithm. + Algorithm float64 `json:"algorithm"` + // fingerprint. + Fingerprint string `json:"fingerprint"` + // type. + Type float64 `json:"type"` + JSON recordUpdateResponseSSHFPDataJSON `json:"-"` +} + +// recordUpdateResponseSSHFPDataJSON contains the JSON metadata for the struct +// [RecordUpdateResponseSSHFPData] +type recordUpdateResponseSSHFPDataJSON struct { + Algorithm apijson.Field + Fingerprint apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseSSHFPData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseSSHFPDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordUpdateResponseSSHFPType string + +const ( + RecordUpdateResponseSSHFPTypeSSHFP RecordUpdateResponseSSHFPType = "SSHFP" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseSSHFPMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseSSHFPMetaJSON `json:"-"` +} + +// recordUpdateResponseSSHFPMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseSSHFPMeta] +type recordUpdateResponseSSHFPMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseSSHFPMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseSSHFPMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordUpdateResponseSSHFPTTLNumber]. +type RecordUpdateResponseSSHFPTTL interface { + ImplementsDNSRecordUpdateResponseSshfpttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseSSHFPTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseSSHFPTTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseSSHFPTTLNumber float64 + +const ( + RecordUpdateResponseSSHFPTTLNumber1 RecordUpdateResponseSSHFPTTLNumber = 1 +) + +type RecordUpdateResponseSVCB struct { + // Components of a SVCB record. + Data RecordUpdateResponseSVCBData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordUpdateResponseSVCBType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted SVCB content. See 'data' to set SVCB properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseSVCBMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseSVCBTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseSVCBJSON `json:"-"` +} + +// recordUpdateResponseSVCBJSON contains the JSON metadata for the struct +// [RecordUpdateResponseSVCB] +type recordUpdateResponseSVCBJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseSVCB) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseSVCBJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseSVCB) implementsDNSRecordUpdateResponse() {} + +// Components of a SVCB record. +type RecordUpdateResponseSVCBData struct { + // priority. + Priority float64 `json:"priority"` + // target. + Target string `json:"target"` + // value. + Value string `json:"value"` + JSON recordUpdateResponseSVCBDataJSON `json:"-"` +} + +// recordUpdateResponseSVCBDataJSON contains the JSON metadata for the struct +// [RecordUpdateResponseSVCBData] +type recordUpdateResponseSVCBDataJSON struct { + Priority apijson.Field + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseSVCBData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseSVCBDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordUpdateResponseSVCBType string + +const ( + RecordUpdateResponseSVCBTypeSVCB RecordUpdateResponseSVCBType = "SVCB" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseSVCBMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseSVCBMetaJSON `json:"-"` +} + +// recordUpdateResponseSVCBMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseSVCBMeta] +type recordUpdateResponseSVCBMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseSVCBMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseSVCBMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordUpdateResponseSVCBTTLNumber]. +type RecordUpdateResponseSVCBTTL interface { + ImplementsDNSRecordUpdateResponseSvcbttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseSVCBTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseSVCBTTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseSVCBTTLNumber float64 + +const ( + RecordUpdateResponseSVCBTTLNumber1 RecordUpdateResponseSVCBTTLNumber = 1 +) + +type RecordUpdateResponseTLSA struct { + // Components of a TLSA record. + Data RecordUpdateResponseTLSAData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordUpdateResponseTLSAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted TLSA content. See 'data' to set TLSA properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseTLSAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseTLSATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseTLSAJSON `json:"-"` +} + +// recordUpdateResponseTLSAJSON contains the JSON metadata for the struct +// [RecordUpdateResponseTLSA] +type recordUpdateResponseTLSAJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseTLSA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseTLSAJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseTLSA) implementsDNSRecordUpdateResponse() {} + +// Components of a TLSA record. +type RecordUpdateResponseTLSAData struct { + // certificate. + Certificate string `json:"certificate"` + // Matching Type. + MatchingType float64 `json:"matching_type"` + // Selector. + Selector float64 `json:"selector"` + // Usage. + Usage float64 `json:"usage"` + JSON recordUpdateResponseTLSADataJSON `json:"-"` +} + +// recordUpdateResponseTLSADataJSON contains the JSON metadata for the struct +// [RecordUpdateResponseTLSAData] +type recordUpdateResponseTLSADataJSON struct { + Certificate apijson.Field + MatchingType apijson.Field + Selector apijson.Field + Usage apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseTLSAData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseTLSADataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordUpdateResponseTLSAType string + +const ( + RecordUpdateResponseTLSATypeTLSA RecordUpdateResponseTLSAType = "TLSA" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseTLSAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseTLSAMetaJSON `json:"-"` +} + +// recordUpdateResponseTLSAMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseTLSAMeta] +type recordUpdateResponseTLSAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseTLSAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseTLSAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordUpdateResponseTLSATTLNumber]. +type RecordUpdateResponseTLSATTL interface { + ImplementsDNSRecordUpdateResponseTlsattl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseTLSATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseTLSATTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseTLSATTLNumber float64 + +const ( + RecordUpdateResponseTLSATTLNumber1 RecordUpdateResponseTLSATTLNumber = 1 +) + +type RecordUpdateResponseTXT struct { + // Text content for the record. + Content string `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordUpdateResponseTXTType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseTXTMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseTXTTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseTXTJSON `json:"-"` +} + +// recordUpdateResponseTXTJSON contains the JSON metadata for the struct +// [RecordUpdateResponseTXT] +type recordUpdateResponseTXTJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseTXT) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseTXTJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseTXT) implementsDNSRecordUpdateResponse() {} + +// Record type. +type RecordUpdateResponseTXTType string + +const ( + RecordUpdateResponseTXTTypeTXT RecordUpdateResponseTXTType = "TXT" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseTXTMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseTXTMetaJSON `json:"-"` +} + +// recordUpdateResponseTXTMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseTXTMeta] +type recordUpdateResponseTXTMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseTXTMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseTXTMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordUpdateResponseTXTTTLNumber]. +type RecordUpdateResponseTXTTTL interface { + ImplementsDNSRecordUpdateResponseTxtttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseTXTTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseTXTTTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseTXTTTLNumber float64 + +const ( + RecordUpdateResponseTXTTTLNumber1 RecordUpdateResponseTXTTTLNumber = 1 +) + +type RecordUpdateResponseURI struct { + // Components of a URI record. + Data RecordUpdateResponseURIData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority float64 `json:"priority,required"` + // Record type. + Type RecordUpdateResponseURIType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted URI content. See 'data' to set URI properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordUpdateResponseURIMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordUpdateResponseURITTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordUpdateResponseURIJSON `json:"-"` +} + +// recordUpdateResponseURIJSON contains the JSON metadata for the struct +// [RecordUpdateResponseURI] +type recordUpdateResponseURIJSON struct { + Data apijson.Field + Name apijson.Field + Priority apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseURI) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseURIJSON) RawJSON() string { + return r.raw +} + +func (r RecordUpdateResponseURI) implementsDNSRecordUpdateResponse() {} + +// Components of a URI record. +type RecordUpdateResponseURIData struct { + // The record content. + Content string `json:"content"` + // The record weight. + Weight float64 `json:"weight"` + JSON recordUpdateResponseURIDataJSON `json:"-"` +} + +// recordUpdateResponseURIDataJSON contains the JSON metadata for the struct +// [RecordUpdateResponseURIData] +type recordUpdateResponseURIDataJSON struct { + Content apijson.Field + Weight apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseURIData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseURIDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordUpdateResponseURIType string + +const ( + RecordUpdateResponseURITypeURI RecordUpdateResponseURIType = "URI" +) + +// Extra Cloudflare-specific information about the record. +type RecordUpdateResponseURIMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordUpdateResponseURIMetaJSON `json:"-"` +} + +// recordUpdateResponseURIMetaJSON contains the JSON metadata for the struct +// [RecordUpdateResponseURIMeta] +type recordUpdateResponseURIMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseURIMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseURIMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordUpdateResponseURITTLNumber]. +type RecordUpdateResponseURITTL interface { + ImplementsDNSRecordUpdateResponseUrittl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordUpdateResponseURITTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordUpdateResponseURITTLNumber(0)), + }, + ) +} + +type RecordUpdateResponseURITTLNumber float64 + +const ( + RecordUpdateResponseURITTLNumber1 RecordUpdateResponseURITTLNumber = 1 +) + +// Union satisfied by [dns.RecordListResponseA], [dns.RecordListResponseAAAA], +// [dns.RecordListResponseCAA], [dns.RecordListResponseCert], +// [dns.RecordListResponseCNAME], [dns.RecordListResponseDNSKEY], +// [dns.RecordListResponseDS], [dns.RecordListResponseHTTPS], +// [dns.RecordListResponseLOC], [dns.RecordListResponseMX], +// [dns.RecordListResponseNAPTR], [dns.RecordListResponseNS], +// [dns.RecordListResponsePTR], [dns.RecordListResponseSmimea], +// [dns.RecordListResponseSRV], [dns.RecordListResponseSSHFP], +// [dns.RecordListResponseSVCB], [dns.RecordListResponseTLSA], +// [dns.RecordListResponseTXT] or [dns.RecordListResponseURI]. +type RecordListResponse interface { + implementsDNSRecordListResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponse)(nil)).Elem(), + "type", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseA{}), + DiscriminatorValue: "A", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseAAAA{}), + DiscriminatorValue: "AAAA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseCAA{}), + DiscriminatorValue: "CAA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseCert{}), + DiscriminatorValue: "CERT", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseCNAME{}), + DiscriminatorValue: "CNAME", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseDNSKEY{}), + DiscriminatorValue: "DNSKEY", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseDS{}), + DiscriminatorValue: "DS", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseHTTPS{}), + DiscriminatorValue: "HTTPS", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseLOC{}), + DiscriminatorValue: "LOC", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseMX{}), + DiscriminatorValue: "MX", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseNAPTR{}), + DiscriminatorValue: "NAPTR", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseNS{}), + DiscriminatorValue: "NS", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponsePTR{}), + DiscriminatorValue: "PTR", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseSmimea{}), + DiscriminatorValue: "SMIMEA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseSRV{}), + DiscriminatorValue: "SRV", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseSSHFP{}), + DiscriminatorValue: "SSHFP", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseSVCB{}), + DiscriminatorValue: "SVCB", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseTLSA{}), + DiscriminatorValue: "TLSA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseTXT{}), + DiscriminatorValue: "TXT", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordListResponseURI{}), + DiscriminatorValue: "URI", + }, + ) +} + +type RecordListResponseA struct { + // A valid IPv4 address. + Content string `json:"content,required" format:"ipv4"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordListResponseAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied bool `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseAJSON `json:"-"` +} + +// recordListResponseAJSON contains the JSON metadata for the struct +// [RecordListResponseA] +type recordListResponseAJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Proxied apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseAJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseA) implementsDNSRecordListResponse() {} + +// Record type. +type RecordListResponseAType string + +const ( + RecordListResponseATypeA RecordListResponseAType = "A" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseAMetaJSON `json:"-"` +} + +// recordListResponseAMetaJSON contains the JSON metadata for the struct +// [RecordListResponseAMeta] +type recordListResponseAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordListResponseATTLNumber]. +type RecordListResponseATTL interface { + ImplementsDNSRecordListResponseAttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseATTLNumber(0)), + }, + ) +} + +type RecordListResponseATTLNumber float64 + +const ( + RecordListResponseATTLNumber1 RecordListResponseATTLNumber = 1 +) + +type RecordListResponseAAAA struct { + // A valid IPv6 address. + Content string `json:"content,required" format:"ipv6"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordListResponseAAAAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseAAAAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied bool `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseAAAATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseAAAAJSON `json:"-"` +} + +// recordListResponseAAAAJSON contains the JSON metadata for the struct +// [RecordListResponseAAAA] +type recordListResponseAAAAJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Proxied apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseAAAA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseAAAAJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseAAAA) implementsDNSRecordListResponse() {} + +// Record type. +type RecordListResponseAAAAType string + +const ( + RecordListResponseAAAATypeAAAA RecordListResponseAAAAType = "AAAA" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseAAAAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseAAAAMetaJSON `json:"-"` +} + +// recordListResponseAAAAMetaJSON contains the JSON metadata for the struct +// [RecordListResponseAAAAMeta] +type recordListResponseAAAAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseAAAAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseAAAAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordListResponseAAAATTLNumber]. +type RecordListResponseAAAATTL interface { + ImplementsDNSRecordListResponseAaaattl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseAAAATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseAAAATTLNumber(0)), + }, + ) +} + +type RecordListResponseAAAATTLNumber float64 + +const ( + RecordListResponseAAAATTLNumber1 RecordListResponseAAAATTLNumber = 1 +) + +type RecordListResponseCAA struct { + // Components of a CAA record. + Data RecordListResponseCAAData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordListResponseCAAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted CAA content. See 'data' to set CAA properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseCAAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseCAATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseCAAJSON `json:"-"` +} + +// recordListResponseCAAJSON contains the JSON metadata for the struct +// [RecordListResponseCAA] +type recordListResponseCAAJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseCAA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseCAAJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseCAA) implementsDNSRecordListResponse() {} + +// Components of a CAA record. +type RecordListResponseCAAData struct { + // Flags for the CAA record. + Flags float64 `json:"flags"` + // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). + Tag string `json:"tag"` + // Value of the record. This field's semantics depend on the chosen tag. + Value string `json:"value"` + JSON recordListResponseCAADataJSON `json:"-"` +} + +// recordListResponseCAADataJSON contains the JSON metadata for the struct +// [RecordListResponseCAAData] +type recordListResponseCAADataJSON struct { + Flags apijson.Field + Tag apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseCAAData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseCAADataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordListResponseCAAType string + +const ( + RecordListResponseCAATypeCAA RecordListResponseCAAType = "CAA" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseCAAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseCAAMetaJSON `json:"-"` +} + +// recordListResponseCAAMetaJSON contains the JSON metadata for the struct +// [RecordListResponseCAAMeta] +type recordListResponseCAAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseCAAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseCAAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordListResponseCAATTLNumber]. +type RecordListResponseCAATTL interface { + ImplementsDNSRecordListResponseCaattl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseCAATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseCAATTLNumber(0)), + }, + ) +} + +type RecordListResponseCAATTLNumber float64 + +const ( + RecordListResponseCAATTLNumber1 RecordListResponseCAATTLNumber = 1 +) + +type RecordListResponseCert struct { + // Components of a CERT record. + Data RecordListResponseCertData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordListResponseCertType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted CERT content. See 'data' to set CERT properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseCertMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseCertTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseCertJSON `json:"-"` +} + +// recordListResponseCertJSON contains the JSON metadata for the struct +// [RecordListResponseCert] +type recordListResponseCertJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseCert) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseCertJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseCert) implementsDNSRecordListResponse() {} + +// Components of a CERT record. +type RecordListResponseCertData struct { + // Algorithm. + Algorithm float64 `json:"algorithm"` + // Certificate. + Certificate string `json:"certificate"` + // Key Tag. + KeyTag float64 `json:"key_tag"` + // Type. + Type float64 `json:"type"` + JSON recordListResponseCertDataJSON `json:"-"` +} + +// recordListResponseCertDataJSON contains the JSON metadata for the struct +// [RecordListResponseCertData] +type recordListResponseCertDataJSON struct { + Algorithm apijson.Field + Certificate apijson.Field + KeyTag apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseCertData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseCertDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordListResponseCertType string + +const ( + RecordListResponseCertTypeCert RecordListResponseCertType = "CERT" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseCertMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseCertMetaJSON `json:"-"` +} + +// recordListResponseCertMetaJSON contains the JSON metadata for the struct +// [RecordListResponseCertMeta] +type recordListResponseCertMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseCertMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseCertMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordListResponseCertTTLNumber]. +type RecordListResponseCertTTL interface { + ImplementsDNSRecordListResponseCertTTL() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseCertTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseCertTTLNumber(0)), + }, + ) +} + +type RecordListResponseCertTTLNumber float64 + +const ( + RecordListResponseCertTTLNumber1 RecordListResponseCertTTLNumber = 1 +) + +type RecordListResponseCNAME struct { + // A valid hostname. Must not match the record's name. + Content interface{} `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordListResponseCNAMEType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseCNAMEMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied bool `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseCNAMETTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseCNAMEJSON `json:"-"` +} + +// recordListResponseCNAMEJSON contains the JSON metadata for the struct +// [RecordListResponseCNAME] +type recordListResponseCNAMEJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Proxied apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseCNAME) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseCNAMEJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseCNAME) implementsDNSRecordListResponse() {} + +// Record type. +type RecordListResponseCNAMEType string + +const ( + RecordListResponseCNAMETypeCNAME RecordListResponseCNAMEType = "CNAME" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseCNAMEMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseCNAMEMetaJSON `json:"-"` +} + +// recordListResponseCNAMEMetaJSON contains the JSON metadata for the struct +// [RecordListResponseCNAMEMeta] +type recordListResponseCNAMEMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseCNAMEMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseCNAMEMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordListResponseCNAMETTLNumber]. +type RecordListResponseCNAMETTL interface { + ImplementsDNSRecordListResponseCnamettl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseCNAMETTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseCNAMETTLNumber(0)), + }, + ) +} + +type RecordListResponseCNAMETTLNumber float64 + +const ( + RecordListResponseCNAMETTLNumber1 RecordListResponseCNAMETTLNumber = 1 +) + +type RecordListResponseDNSKEY struct { + // Components of a DNSKEY record. + Data RecordListResponseDNSKEYData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordListResponseDNSKEYType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted DNSKEY content. See 'data' to set DNSKEY properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseDNSKEYMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseDNSKEYTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseDNSKEYJSON `json:"-"` +} + +// recordListResponseDNSKEYJSON contains the JSON metadata for the struct +// [RecordListResponseDNSKEY] +type recordListResponseDNSKEYJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseDNSKEY) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseDNSKEYJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseDNSKEY) implementsDNSRecordListResponse() {} + +// Components of a DNSKEY record. +type RecordListResponseDNSKEYData struct { + // Algorithm. + Algorithm float64 `json:"algorithm"` + // Flags. + Flags float64 `json:"flags"` + // Protocol. + Protocol float64 `json:"protocol"` + // Public Key. + PublicKey string `json:"public_key"` + JSON recordListResponseDNSKEYDataJSON `json:"-"` +} + +// recordListResponseDNSKEYDataJSON contains the JSON metadata for the struct +// [RecordListResponseDNSKEYData] +type recordListResponseDNSKEYDataJSON struct { + Algorithm apijson.Field + Flags apijson.Field + Protocol apijson.Field + PublicKey apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseDNSKEYData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseDNSKEYDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordListResponseDNSKEYType string + +const ( + RecordListResponseDNSKEYTypeDNSKEY RecordListResponseDNSKEYType = "DNSKEY" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseDNSKEYMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseDNSKEYMetaJSON `json:"-"` +} + +// recordListResponseDNSKEYMetaJSON contains the JSON metadata for the struct +// [RecordListResponseDNSKEYMeta] +type recordListResponseDNSKEYMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseDNSKEYMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseDNSKEYMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordListResponseDNSKEYTTLNumber]. +type RecordListResponseDNSKEYTTL interface { + ImplementsDNSRecordListResponseDnskeyttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseDNSKEYTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseDNSKEYTTLNumber(0)), + }, + ) +} + +type RecordListResponseDNSKEYTTLNumber float64 + +const ( + RecordListResponseDNSKEYTTLNumber1 RecordListResponseDNSKEYTTLNumber = 1 +) + +type RecordListResponseDS struct { + // Components of a DS record. + Data RecordListResponseDSData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordListResponseDSType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted DS content. See 'data' to set DS properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseDSMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseDSTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseDSJSON `json:"-"` +} + +// recordListResponseDSJSON contains the JSON metadata for the struct +// [RecordListResponseDS] +type recordListResponseDSJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseDS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseDSJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseDS) implementsDNSRecordListResponse() {} + +// Components of a DS record. +type RecordListResponseDSData struct { + // Algorithm. + Algorithm float64 `json:"algorithm"` + // Digest. + Digest string `json:"digest"` + // Digest Type. + DigestType float64 `json:"digest_type"` + // Key Tag. + KeyTag float64 `json:"key_tag"` + JSON recordListResponseDSDataJSON `json:"-"` +} + +// recordListResponseDSDataJSON contains the JSON metadata for the struct +// [RecordListResponseDSData] +type recordListResponseDSDataJSON struct { + Algorithm apijson.Field + Digest apijson.Field + DigestType apijson.Field + KeyTag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseDSData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseDSDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordListResponseDSType string + +const ( + RecordListResponseDSTypeDS RecordListResponseDSType = "DS" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseDSMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseDSMetaJSON `json:"-"` +} + +// recordListResponseDSMetaJSON contains the JSON metadata for the struct +// [RecordListResponseDSMeta] +type recordListResponseDSMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseDSMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseDSMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordListResponseDSTTLNumber]. +type RecordListResponseDSTTL interface { + ImplementsDNSRecordListResponseDsttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseDSTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseDSTTLNumber(0)), + }, + ) +} + +type RecordListResponseDSTTLNumber float64 + +const ( + RecordListResponseDSTTLNumber1 RecordListResponseDSTTLNumber = 1 +) + +type RecordListResponseHTTPS struct { + // Components of a HTTPS record. + Data RecordListResponseHTTPSData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordListResponseHTTPSType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted HTTPS content. See 'data' to set HTTPS properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseHTTPSMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseHTTPSTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseHTTPSJSON `json:"-"` +} + +// recordListResponseHTTPSJSON contains the JSON metadata for the struct +// [RecordListResponseHTTPS] +type recordListResponseHTTPSJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseHTTPS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseHTTPSJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseHTTPS) implementsDNSRecordListResponse() {} + +// Components of a HTTPS record. +type RecordListResponseHTTPSData struct { + // priority. + Priority float64 `json:"priority"` + // target. + Target string `json:"target"` + // value. + Value string `json:"value"` + JSON recordListResponseHTTPSDataJSON `json:"-"` +} + +// recordListResponseHTTPSDataJSON contains the JSON metadata for the struct +// [RecordListResponseHTTPSData] +type recordListResponseHTTPSDataJSON struct { + Priority apijson.Field + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseHTTPSData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseHTTPSDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordListResponseHTTPSType string + +const ( + RecordListResponseHTTPSTypeHTTPS RecordListResponseHTTPSType = "HTTPS" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseHTTPSMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseHTTPSMetaJSON `json:"-"` +} + +// recordListResponseHTTPSMetaJSON contains the JSON metadata for the struct +// [RecordListResponseHTTPSMeta] +type recordListResponseHTTPSMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseHTTPSMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseHTTPSMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordListResponseHTTPSTTLNumber]. +type RecordListResponseHTTPSTTL interface { + ImplementsDNSRecordListResponseHttpsttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseHTTPSTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseHTTPSTTLNumber(0)), + }, + ) +} + +type RecordListResponseHTTPSTTLNumber float64 + +const ( + RecordListResponseHTTPSTTLNumber1 RecordListResponseHTTPSTTLNumber = 1 +) + +type RecordListResponseLOC struct { + // Components of a LOC record. + Data RecordListResponseLOCData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordListResponseLOCType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted LOC content. See 'data' to set LOC properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseLOCMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseLOCTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseLOCJSON `json:"-"` +} + +// recordListResponseLOCJSON contains the JSON metadata for the struct +// [RecordListResponseLOC] +type recordListResponseLOCJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseLOC) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseLOCJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseLOC) implementsDNSRecordListResponse() {} + +// Components of a LOC record. +type RecordListResponseLOCData struct { + // Altitude of location in meters. + Altitude float64 `json:"altitude"` + // Degrees of latitude. + LatDegrees float64 `json:"lat_degrees"` + // Latitude direction. + LatDirection RecordListResponseLOCDataLatDirection `json:"lat_direction"` + // Minutes of latitude. + LatMinutes float64 `json:"lat_minutes"` + // Seconds of latitude. + LatSeconds float64 `json:"lat_seconds"` + // Degrees of longitude. + LongDegrees float64 `json:"long_degrees"` + // Longitude direction. + LongDirection RecordListResponseLOCDataLongDirection `json:"long_direction"` + // Minutes of longitude. + LongMinutes float64 `json:"long_minutes"` + // Seconds of longitude. + LongSeconds float64 `json:"long_seconds"` + // Horizontal precision of location. + PrecisionHorz float64 `json:"precision_horz"` + // Vertical precision of location. + PrecisionVert float64 `json:"precision_vert"` + // Size of location in meters. + Size float64 `json:"size"` + JSON recordListResponseLOCDataJSON `json:"-"` +} + +// recordListResponseLOCDataJSON contains the JSON metadata for the struct +// [RecordListResponseLOCData] +type recordListResponseLOCDataJSON struct { + Altitude apijson.Field + LatDegrees apijson.Field + LatDirection apijson.Field + LatMinutes apijson.Field + LatSeconds apijson.Field + LongDegrees apijson.Field + LongDirection apijson.Field + LongMinutes apijson.Field + LongSeconds apijson.Field + PrecisionHorz apijson.Field + PrecisionVert apijson.Field + Size apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseLOCData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseLOCDataJSON) RawJSON() string { + return r.raw +} + +// Latitude direction. +type RecordListResponseLOCDataLatDirection string + +const ( + RecordListResponseLOCDataLatDirectionN RecordListResponseLOCDataLatDirection = "N" + RecordListResponseLOCDataLatDirectionS RecordListResponseLOCDataLatDirection = "S" +) + +// Longitude direction. +type RecordListResponseLOCDataLongDirection string + +const ( + RecordListResponseLOCDataLongDirectionE RecordListResponseLOCDataLongDirection = "E" + RecordListResponseLOCDataLongDirectionW RecordListResponseLOCDataLongDirection = "W" +) + +// Record type. +type RecordListResponseLOCType string + +const ( + RecordListResponseLOCTypeLOC RecordListResponseLOCType = "LOC" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseLOCMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseLOCMetaJSON `json:"-"` +} + +// recordListResponseLOCMetaJSON contains the JSON metadata for the struct +// [RecordListResponseLOCMeta] +type recordListResponseLOCMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseLOCMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseLOCMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordListResponseLOCTTLNumber]. +type RecordListResponseLOCTTL interface { + ImplementsDNSRecordListResponseLocttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseLOCTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseLOCTTLNumber(0)), + }, + ) +} + +type RecordListResponseLOCTTLNumber float64 + +const ( + RecordListResponseLOCTTLNumber1 RecordListResponseLOCTTLNumber = 1 +) + +type RecordListResponseMX struct { + // A valid mail server hostname. + Content string `json:"content,required" format:"hostname"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority float64 `json:"priority,required"` + // Record type. + Type RecordListResponseMXType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseMXMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseMXTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseMXJSON `json:"-"` +} + +// recordListResponseMXJSON contains the JSON metadata for the struct +// [RecordListResponseMX] +type recordListResponseMXJSON struct { + Content apijson.Field + Name apijson.Field + Priority apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseMX) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseMXJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseMX) implementsDNSRecordListResponse() {} + +// Record type. +type RecordListResponseMXType string + +const ( + RecordListResponseMXTypeMX RecordListResponseMXType = "MX" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseMXMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseMXMetaJSON `json:"-"` +} + +// recordListResponseMXMetaJSON contains the JSON metadata for the struct +// [RecordListResponseMXMeta] +type recordListResponseMXMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseMXMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseMXMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordListResponseMXTTLNumber]. +type RecordListResponseMXTTL interface { + ImplementsDNSRecordListResponseMxttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseMXTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseMXTTLNumber(0)), + }, + ) +} + +type RecordListResponseMXTTLNumber float64 + +const ( + RecordListResponseMXTTLNumber1 RecordListResponseMXTTLNumber = 1 +) + +type RecordListResponseNAPTR struct { + // Components of a NAPTR record. + Data RecordListResponseNAPTRData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordListResponseNAPTRType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted NAPTR content. See 'data' to set NAPTR properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseNAPTRMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseNAPTRTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseNAPTRJSON `json:"-"` +} + +// recordListResponseNAPTRJSON contains the JSON metadata for the struct +// [RecordListResponseNAPTR] +type recordListResponseNAPTRJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseNAPTR) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseNAPTRJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseNAPTR) implementsDNSRecordListResponse() {} + +// Components of a NAPTR record. +type RecordListResponseNAPTRData struct { + // Flags. + Flags string `json:"flags"` + // Order. + Order float64 `json:"order"` + // Preference. + Preference float64 `json:"preference"` + // Regex. + Regex string `json:"regex"` + // Replacement. + Replacement string `json:"replacement"` + // Service. + Service string `json:"service"` + JSON recordListResponseNAPTRDataJSON `json:"-"` +} + +// recordListResponseNAPTRDataJSON contains the JSON metadata for the struct +// [RecordListResponseNAPTRData] +type recordListResponseNAPTRDataJSON struct { + Flags apijson.Field + Order apijson.Field + Preference apijson.Field + Regex apijson.Field + Replacement apijson.Field + Service apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseNAPTRData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseNAPTRDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordListResponseNAPTRType string + +const ( + RecordListResponseNAPTRTypeNAPTR RecordListResponseNAPTRType = "NAPTR" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseNAPTRMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseNAPTRMetaJSON `json:"-"` +} + +// recordListResponseNAPTRMetaJSON contains the JSON metadata for the struct +// [RecordListResponseNAPTRMeta] +type recordListResponseNAPTRMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseNAPTRMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseNAPTRMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordListResponseNAPTRTTLNumber]. +type RecordListResponseNAPTRTTL interface { + ImplementsDNSRecordListResponseNaptrttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseNAPTRTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseNAPTRTTLNumber(0)), + }, + ) +} + +type RecordListResponseNAPTRTTLNumber float64 + +const ( + RecordListResponseNAPTRTTLNumber1 RecordListResponseNAPTRTTLNumber = 1 +) + +type RecordListResponseNS struct { + // A valid name server host name. + Content interface{} `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordListResponseNSType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseNSMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseNSTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseNSJSON `json:"-"` +} + +// recordListResponseNSJSON contains the JSON metadata for the struct +// [RecordListResponseNS] +type recordListResponseNSJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseNS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseNSJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseNS) implementsDNSRecordListResponse() {} + +// Record type. +type RecordListResponseNSType string + +const ( + RecordListResponseNSTypeNS RecordListResponseNSType = "NS" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseNSMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseNSMetaJSON `json:"-"` +} + +// recordListResponseNSMetaJSON contains the JSON metadata for the struct +// [RecordListResponseNSMeta] +type recordListResponseNSMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseNSMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseNSMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordListResponseNSTTLNumber]. +type RecordListResponseNSTTL interface { + ImplementsDNSRecordListResponseNsttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseNSTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseNSTTLNumber(0)), + }, + ) +} + +type RecordListResponseNSTTLNumber float64 + +const ( + RecordListResponseNSTTLNumber1 RecordListResponseNSTTLNumber = 1 +) + +type RecordListResponsePTR struct { + // Domain name pointing to the address. + Content string `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordListResponsePTRType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponsePTRMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponsePTRTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponsePTRJSON `json:"-"` +} + +// recordListResponsePTRJSON contains the JSON metadata for the struct +// [RecordListResponsePTR] +type recordListResponsePTRJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponsePTR) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponsePTRJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponsePTR) implementsDNSRecordListResponse() {} + +// Record type. +type RecordListResponsePTRType string + +const ( + RecordListResponsePTRTypePTR RecordListResponsePTRType = "PTR" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponsePTRMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponsePTRMetaJSON `json:"-"` +} + +// recordListResponsePTRMetaJSON contains the JSON metadata for the struct +// [RecordListResponsePTRMeta] +type recordListResponsePTRMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponsePTRMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponsePTRMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordListResponsePTRTTLNumber]. +type RecordListResponsePTRTTL interface { + ImplementsDNSRecordListResponsePtrttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponsePTRTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponsePTRTTLNumber(0)), + }, + ) +} + +type RecordListResponsePTRTTLNumber float64 + +const ( + RecordListResponsePTRTTLNumber1 RecordListResponsePTRTTLNumber = 1 +) + +type RecordListResponseSmimea struct { + // Components of a SMIMEA record. + Data RecordListResponseSmimeaData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordListResponseSmimeaType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted SMIMEA content. See 'data' to set SMIMEA properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseSmimeaMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseSmimeaTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseSmimeaJSON `json:"-"` +} + +// recordListResponseSmimeaJSON contains the JSON metadata for the struct +// [RecordListResponseSmimea] +type recordListResponseSmimeaJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseSmimea) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseSmimeaJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseSmimea) implementsDNSRecordListResponse() {} + +// Components of a SMIMEA record. +type RecordListResponseSmimeaData struct { + // Certificate. + Certificate string `json:"certificate"` + // Matching Type. + MatchingType float64 `json:"matching_type"` + // Selector. + Selector float64 `json:"selector"` + // Usage. + Usage float64 `json:"usage"` + JSON recordListResponseSmimeaDataJSON `json:"-"` +} + +// recordListResponseSmimeaDataJSON contains the JSON metadata for the struct +// [RecordListResponseSmimeaData] +type recordListResponseSmimeaDataJSON struct { + Certificate apijson.Field + MatchingType apijson.Field + Selector apijson.Field + Usage apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseSmimeaData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseSmimeaDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordListResponseSmimeaType string + +const ( + RecordListResponseSmimeaTypeSmimea RecordListResponseSmimeaType = "SMIMEA" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseSmimeaMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseSmimeaMetaJSON `json:"-"` +} + +// recordListResponseSmimeaMetaJSON contains the JSON metadata for the struct +// [RecordListResponseSmimeaMeta] +type recordListResponseSmimeaMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseSmimeaMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseSmimeaMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordListResponseSmimeaTTLNumber]. +type RecordListResponseSmimeaTTL interface { + ImplementsDNSRecordListResponseSmimeaTTL() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseSmimeaTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseSmimeaTTLNumber(0)), + }, + ) +} + +type RecordListResponseSmimeaTTLNumber float64 + +const ( + RecordListResponseSmimeaTTLNumber1 RecordListResponseSmimeaTTLNumber = 1 +) + +type RecordListResponseSRV struct { + // Components of a SRV record. + Data RecordListResponseSRVData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. For SRV records, the first + // label is normally a service and the second a protocol name, each starting with + // an underscore. + Name string `json:"name,required"` + // Record type. + Type RecordListResponseSRVType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Priority, weight, port, and SRV target. See 'data' for setting the individual + // component values. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseSRVMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseSRVTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseSRVJSON `json:"-"` +} + +// recordListResponseSRVJSON contains the JSON metadata for the struct +// [RecordListResponseSRV] +type recordListResponseSRVJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseSRV) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseSRVJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseSRV) implementsDNSRecordListResponse() {} + +// Components of a SRV record. +type RecordListResponseSRVData struct { + // A valid hostname. Deprecated in favor of the regular 'name' outside the data + // map. This data map field represents the remainder of the full 'name' after the + // service and protocol. + Name string `json:"name" format:"hostname"` + // The port of the service. + Port float64 `json:"port"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority float64 `json:"priority"` + // A valid protocol, prefixed with an underscore. Deprecated in favor of the + // regular 'name' outside the data map. This data map field normally represents the + // second label of that 'name'. + Proto string `json:"proto"` + // A service type, prefixed with an underscore. Deprecated in favor of the regular + // 'name' outside the data map. This data map field normally represents the first + // label of that 'name'. + Service string `json:"service"` + // A valid hostname. + Target string `json:"target" format:"hostname"` + // The record weight. + Weight float64 `json:"weight"` + JSON recordListResponseSRVDataJSON `json:"-"` +} + +// recordListResponseSRVDataJSON contains the JSON metadata for the struct +// [RecordListResponseSRVData] +type recordListResponseSRVDataJSON struct { + Name apijson.Field + Port apijson.Field + Priority apijson.Field + Proto apijson.Field + Service apijson.Field + Target apijson.Field + Weight apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseSRVData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseSRVDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordListResponseSRVType string + +const ( + RecordListResponseSRVTypeSRV RecordListResponseSRVType = "SRV" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseSRVMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseSRVMetaJSON `json:"-"` +} + +// recordListResponseSRVMetaJSON contains the JSON metadata for the struct +// [RecordListResponseSRVMeta] +type recordListResponseSRVMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseSRVMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseSRVMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordListResponseSRVTTLNumber]. +type RecordListResponseSRVTTL interface { + ImplementsDNSRecordListResponseSrvttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseSRVTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseSRVTTLNumber(0)), + }, + ) +} + +type RecordListResponseSRVTTLNumber float64 + +const ( + RecordListResponseSRVTTLNumber1 RecordListResponseSRVTTLNumber = 1 +) + +type RecordListResponseSSHFP struct { + // Components of a SSHFP record. + Data RecordListResponseSSHFPData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordListResponseSSHFPType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted SSHFP content. See 'data' to set SSHFP properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseSSHFPMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseSSHFPTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseSSHFPJSON `json:"-"` +} + +// recordListResponseSSHFPJSON contains the JSON metadata for the struct +// [RecordListResponseSSHFP] +type recordListResponseSSHFPJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseSSHFP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseSSHFPJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseSSHFP) implementsDNSRecordListResponse() {} + +// Components of a SSHFP record. +type RecordListResponseSSHFPData struct { + // algorithm. + Algorithm float64 `json:"algorithm"` + // fingerprint. + Fingerprint string `json:"fingerprint"` + // type. + Type float64 `json:"type"` + JSON recordListResponseSSHFPDataJSON `json:"-"` +} + +// recordListResponseSSHFPDataJSON contains the JSON metadata for the struct +// [RecordListResponseSSHFPData] +type recordListResponseSSHFPDataJSON struct { + Algorithm apijson.Field + Fingerprint apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseSSHFPData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseSSHFPDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordListResponseSSHFPType string + +const ( + RecordListResponseSSHFPTypeSSHFP RecordListResponseSSHFPType = "SSHFP" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseSSHFPMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseSSHFPMetaJSON `json:"-"` +} + +// recordListResponseSSHFPMetaJSON contains the JSON metadata for the struct +// [RecordListResponseSSHFPMeta] +type recordListResponseSSHFPMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseSSHFPMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseSSHFPMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordListResponseSSHFPTTLNumber]. +type RecordListResponseSSHFPTTL interface { + ImplementsDNSRecordListResponseSshfpttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseSSHFPTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseSSHFPTTLNumber(0)), + }, + ) +} + +type RecordListResponseSSHFPTTLNumber float64 + +const ( + RecordListResponseSSHFPTTLNumber1 RecordListResponseSSHFPTTLNumber = 1 +) + +type RecordListResponseSVCB struct { + // Components of a SVCB record. + Data RecordListResponseSVCBData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordListResponseSVCBType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted SVCB content. See 'data' to set SVCB properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseSVCBMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseSVCBTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseSVCBJSON `json:"-"` +} + +// recordListResponseSVCBJSON contains the JSON metadata for the struct +// [RecordListResponseSVCB] +type recordListResponseSVCBJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseSVCB) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseSVCBJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseSVCB) implementsDNSRecordListResponse() {} + +// Components of a SVCB record. +type RecordListResponseSVCBData struct { + // priority. + Priority float64 `json:"priority"` + // target. + Target string `json:"target"` + // value. + Value string `json:"value"` + JSON recordListResponseSVCBDataJSON `json:"-"` +} + +// recordListResponseSVCBDataJSON contains the JSON metadata for the struct +// [RecordListResponseSVCBData] +type recordListResponseSVCBDataJSON struct { + Priority apijson.Field + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseSVCBData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseSVCBDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordListResponseSVCBType string + +const ( + RecordListResponseSVCBTypeSVCB RecordListResponseSVCBType = "SVCB" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseSVCBMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseSVCBMetaJSON `json:"-"` +} + +// recordListResponseSVCBMetaJSON contains the JSON metadata for the struct +// [RecordListResponseSVCBMeta] +type recordListResponseSVCBMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseSVCBMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseSVCBMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordListResponseSVCBTTLNumber]. +type RecordListResponseSVCBTTL interface { + ImplementsDNSRecordListResponseSvcbttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseSVCBTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseSVCBTTLNumber(0)), + }, + ) +} + +type RecordListResponseSVCBTTLNumber float64 + +const ( + RecordListResponseSVCBTTLNumber1 RecordListResponseSVCBTTLNumber = 1 +) + +type RecordListResponseTLSA struct { + // Components of a TLSA record. + Data RecordListResponseTLSAData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordListResponseTLSAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted TLSA content. See 'data' to set TLSA properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseTLSAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseTLSATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseTLSAJSON `json:"-"` +} + +// recordListResponseTLSAJSON contains the JSON metadata for the struct +// [RecordListResponseTLSA] +type recordListResponseTLSAJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseTLSA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseTLSAJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseTLSA) implementsDNSRecordListResponse() {} + +// Components of a TLSA record. +type RecordListResponseTLSAData struct { + // certificate. + Certificate string `json:"certificate"` + // Matching Type. + MatchingType float64 `json:"matching_type"` + // Selector. + Selector float64 `json:"selector"` + // Usage. + Usage float64 `json:"usage"` + JSON recordListResponseTLSADataJSON `json:"-"` +} + +// recordListResponseTLSADataJSON contains the JSON metadata for the struct +// [RecordListResponseTLSAData] +type recordListResponseTLSADataJSON struct { + Certificate apijson.Field + MatchingType apijson.Field + Selector apijson.Field + Usage apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseTLSAData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseTLSADataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordListResponseTLSAType string + +const ( + RecordListResponseTLSATypeTLSA RecordListResponseTLSAType = "TLSA" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseTLSAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseTLSAMetaJSON `json:"-"` +} + +// recordListResponseTLSAMetaJSON contains the JSON metadata for the struct +// [RecordListResponseTLSAMeta] +type recordListResponseTLSAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseTLSAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseTLSAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordListResponseTLSATTLNumber]. +type RecordListResponseTLSATTL interface { + ImplementsDNSRecordListResponseTlsattl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseTLSATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseTLSATTLNumber(0)), + }, + ) +} + +type RecordListResponseTLSATTLNumber float64 + +const ( + RecordListResponseTLSATTLNumber1 RecordListResponseTLSATTLNumber = 1 +) + +type RecordListResponseTXT struct { + // Text content for the record. + Content string `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordListResponseTXTType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseTXTMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseTXTTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseTXTJSON `json:"-"` +} + +// recordListResponseTXTJSON contains the JSON metadata for the struct +// [RecordListResponseTXT] +type recordListResponseTXTJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseTXT) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseTXTJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseTXT) implementsDNSRecordListResponse() {} + +// Record type. +type RecordListResponseTXTType string + +const ( + RecordListResponseTXTTypeTXT RecordListResponseTXTType = "TXT" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseTXTMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseTXTMetaJSON `json:"-"` +} + +// recordListResponseTXTMetaJSON contains the JSON metadata for the struct +// [RecordListResponseTXTMeta] +type recordListResponseTXTMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseTXTMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseTXTMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordListResponseTXTTTLNumber]. +type RecordListResponseTXTTTL interface { + ImplementsDNSRecordListResponseTxtttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseTXTTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseTXTTTLNumber(0)), + }, + ) +} + +type RecordListResponseTXTTTLNumber float64 + +const ( + RecordListResponseTXTTTLNumber1 RecordListResponseTXTTTLNumber = 1 +) + +type RecordListResponseURI struct { + // Components of a URI record. + Data RecordListResponseURIData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority float64 `json:"priority,required"` + // Record type. + Type RecordListResponseURIType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted URI content. See 'data' to set URI properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordListResponseURIMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordListResponseURITTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordListResponseURIJSON `json:"-"` +} + +// recordListResponseURIJSON contains the JSON metadata for the struct +// [RecordListResponseURI] +type recordListResponseURIJSON struct { + Data apijson.Field + Name apijson.Field + Priority apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseURI) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseURIJSON) RawJSON() string { + return r.raw +} + +func (r RecordListResponseURI) implementsDNSRecordListResponse() {} + +// Components of a URI record. +type RecordListResponseURIData struct { + // The record content. + Content string `json:"content"` + // The record weight. + Weight float64 `json:"weight"` + JSON recordListResponseURIDataJSON `json:"-"` +} + +// recordListResponseURIDataJSON contains the JSON metadata for the struct +// [RecordListResponseURIData] +type recordListResponseURIDataJSON struct { + Content apijson.Field + Weight apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseURIData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseURIDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordListResponseURIType string + +const ( + RecordListResponseURITypeURI RecordListResponseURIType = "URI" +) + +// Extra Cloudflare-specific information about the record. +type RecordListResponseURIMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordListResponseURIMetaJSON `json:"-"` +} + +// recordListResponseURIMetaJSON contains the JSON metadata for the struct +// [RecordListResponseURIMeta] +type recordListResponseURIMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordListResponseURIMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordListResponseURIMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordListResponseURITTLNumber]. +type RecordListResponseURITTL interface { + ImplementsDNSRecordListResponseUrittl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordListResponseURITTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordListResponseURITTLNumber(0)), + }, + ) +} + +type RecordListResponseURITTLNumber float64 + +const ( + RecordListResponseURITTLNumber1 RecordListResponseURITTLNumber = 1 +) + +type RecordDeleteResponse struct { + // Identifier + ID string `json:"id"` + JSON recordDeleteResponseJSON `json:"-"` +} + +// recordDeleteResponseJSON contains the JSON metadata for the struct +// [RecordDeleteResponse] +type recordDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordDeleteResponseJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [dns.RecordEditResponseA], [dns.RecordEditResponseAAAA], +// [dns.RecordEditResponseCAA], [dns.RecordEditResponseCert], +// [dns.RecordEditResponseCNAME], [dns.RecordEditResponseDNSKEY], +// [dns.RecordEditResponseDS], [dns.RecordEditResponseHTTPS], +// [dns.RecordEditResponseLOC], [dns.RecordEditResponseMX], +// [dns.RecordEditResponseNAPTR], [dns.RecordEditResponseNS], +// [dns.RecordEditResponsePTR], [dns.RecordEditResponseSmimea], +// [dns.RecordEditResponseSRV], [dns.RecordEditResponseSSHFP], +// [dns.RecordEditResponseSVCB], [dns.RecordEditResponseTLSA], +// [dns.RecordEditResponseTXT] or [dns.RecordEditResponseURI]. +type RecordEditResponse interface { + implementsDNSRecordEditResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponse)(nil)).Elem(), + "type", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseA{}), + DiscriminatorValue: "A", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseAAAA{}), + DiscriminatorValue: "AAAA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseCAA{}), + DiscriminatorValue: "CAA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseCert{}), + DiscriminatorValue: "CERT", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseCNAME{}), + DiscriminatorValue: "CNAME", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseDNSKEY{}), + DiscriminatorValue: "DNSKEY", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseDS{}), + DiscriminatorValue: "DS", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseHTTPS{}), + DiscriminatorValue: "HTTPS", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseLOC{}), + DiscriminatorValue: "LOC", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseMX{}), + DiscriminatorValue: "MX", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseNAPTR{}), + DiscriminatorValue: "NAPTR", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseNS{}), + DiscriminatorValue: "NS", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponsePTR{}), + DiscriminatorValue: "PTR", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseSmimea{}), + DiscriminatorValue: "SMIMEA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseSRV{}), + DiscriminatorValue: "SRV", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseSSHFP{}), + DiscriminatorValue: "SSHFP", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseSVCB{}), + DiscriminatorValue: "SVCB", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseTLSA{}), + DiscriminatorValue: "TLSA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseTXT{}), + DiscriminatorValue: "TXT", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordEditResponseURI{}), + DiscriminatorValue: "URI", + }, + ) +} + +type RecordEditResponseA struct { + // A valid IPv4 address. + Content string `json:"content,required" format:"ipv4"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordEditResponseAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied bool `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseAJSON `json:"-"` +} + +// recordEditResponseAJSON contains the JSON metadata for the struct +// [RecordEditResponseA] +type recordEditResponseAJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Proxied apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseAJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseA) implementsDNSRecordEditResponse() {} + +// Record type. +type RecordEditResponseAType string + +const ( + RecordEditResponseATypeA RecordEditResponseAType = "A" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseAMetaJSON `json:"-"` +} + +// recordEditResponseAMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseAMeta] +type recordEditResponseAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordEditResponseATTLNumber]. +type RecordEditResponseATTL interface { + ImplementsDNSRecordEditResponseAttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseATTLNumber(0)), + }, + ) +} + +type RecordEditResponseATTLNumber float64 + +const ( + RecordEditResponseATTLNumber1 RecordEditResponseATTLNumber = 1 +) + +type RecordEditResponseAAAA struct { + // A valid IPv6 address. + Content string `json:"content,required" format:"ipv6"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordEditResponseAAAAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseAAAAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied bool `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseAAAATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseAAAAJSON `json:"-"` +} + +// recordEditResponseAAAAJSON contains the JSON metadata for the struct +// [RecordEditResponseAAAA] +type recordEditResponseAAAAJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Proxied apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseAAAA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseAAAAJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseAAAA) implementsDNSRecordEditResponse() {} + +// Record type. +type RecordEditResponseAAAAType string + +const ( + RecordEditResponseAAAATypeAAAA RecordEditResponseAAAAType = "AAAA" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseAAAAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseAAAAMetaJSON `json:"-"` +} + +// recordEditResponseAAAAMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseAAAAMeta] +type recordEditResponseAAAAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseAAAAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseAAAAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordEditResponseAAAATTLNumber]. +type RecordEditResponseAAAATTL interface { + ImplementsDNSRecordEditResponseAaaattl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseAAAATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseAAAATTLNumber(0)), + }, + ) +} + +type RecordEditResponseAAAATTLNumber float64 + +const ( + RecordEditResponseAAAATTLNumber1 RecordEditResponseAAAATTLNumber = 1 +) + +type RecordEditResponseCAA struct { + // Components of a CAA record. + Data RecordEditResponseCAAData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordEditResponseCAAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted CAA content. See 'data' to set CAA properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseCAAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseCAATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseCAAJSON `json:"-"` +} + +// recordEditResponseCAAJSON contains the JSON metadata for the struct +// [RecordEditResponseCAA] +type recordEditResponseCAAJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseCAA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseCAAJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseCAA) implementsDNSRecordEditResponse() {} + +// Components of a CAA record. +type RecordEditResponseCAAData struct { + // Flags for the CAA record. + Flags float64 `json:"flags"` + // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). + Tag string `json:"tag"` + // Value of the record. This field's semantics depend on the chosen tag. + Value string `json:"value"` + JSON recordEditResponseCAADataJSON `json:"-"` +} + +// recordEditResponseCAADataJSON contains the JSON metadata for the struct +// [RecordEditResponseCAAData] +type recordEditResponseCAADataJSON struct { + Flags apijson.Field + Tag apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseCAAData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseCAADataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordEditResponseCAAType string + +const ( + RecordEditResponseCAATypeCAA RecordEditResponseCAAType = "CAA" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseCAAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseCAAMetaJSON `json:"-"` +} + +// recordEditResponseCAAMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseCAAMeta] +type recordEditResponseCAAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseCAAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseCAAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordEditResponseCAATTLNumber]. +type RecordEditResponseCAATTL interface { + ImplementsDNSRecordEditResponseCaattl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseCAATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseCAATTLNumber(0)), + }, + ) +} + +type RecordEditResponseCAATTLNumber float64 + +const ( + RecordEditResponseCAATTLNumber1 RecordEditResponseCAATTLNumber = 1 +) + +type RecordEditResponseCert struct { + // Components of a CERT record. + Data RecordEditResponseCertData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordEditResponseCertType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted CERT content. See 'data' to set CERT properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseCertMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseCertTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseCertJSON `json:"-"` +} + +// recordEditResponseCertJSON contains the JSON metadata for the struct +// [RecordEditResponseCert] +type recordEditResponseCertJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseCert) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseCertJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseCert) implementsDNSRecordEditResponse() {} + +// Components of a CERT record. +type RecordEditResponseCertData struct { + // Algorithm. + Algorithm float64 `json:"algorithm"` + // Certificate. + Certificate string `json:"certificate"` + // Key Tag. + KeyTag float64 `json:"key_tag"` + // Type. + Type float64 `json:"type"` + JSON recordEditResponseCertDataJSON `json:"-"` +} + +// recordEditResponseCertDataJSON contains the JSON metadata for the struct +// [RecordEditResponseCertData] +type recordEditResponseCertDataJSON struct { + Algorithm apijson.Field + Certificate apijson.Field + KeyTag apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseCertData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseCertDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordEditResponseCertType string + +const ( + RecordEditResponseCertTypeCert RecordEditResponseCertType = "CERT" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseCertMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseCertMetaJSON `json:"-"` +} + +// recordEditResponseCertMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseCertMeta] +type recordEditResponseCertMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseCertMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseCertMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordEditResponseCertTTLNumber]. +type RecordEditResponseCertTTL interface { + ImplementsDNSRecordEditResponseCertTTL() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseCertTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseCertTTLNumber(0)), + }, + ) +} + +type RecordEditResponseCertTTLNumber float64 + +const ( + RecordEditResponseCertTTLNumber1 RecordEditResponseCertTTLNumber = 1 +) + +type RecordEditResponseCNAME struct { + // A valid hostname. Must not match the record's name. + Content interface{} `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordEditResponseCNAMEType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseCNAMEMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied bool `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseCNAMETTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseCNAMEJSON `json:"-"` +} + +// recordEditResponseCNAMEJSON contains the JSON metadata for the struct +// [RecordEditResponseCNAME] +type recordEditResponseCNAMEJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Proxied apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseCNAME) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseCNAMEJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseCNAME) implementsDNSRecordEditResponse() {} + +// Record type. +type RecordEditResponseCNAMEType string + +const ( + RecordEditResponseCNAMETypeCNAME RecordEditResponseCNAMEType = "CNAME" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseCNAMEMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseCNAMEMetaJSON `json:"-"` +} + +// recordEditResponseCNAMEMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseCNAMEMeta] +type recordEditResponseCNAMEMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseCNAMEMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseCNAMEMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordEditResponseCNAMETTLNumber]. +type RecordEditResponseCNAMETTL interface { + ImplementsDNSRecordEditResponseCnamettl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseCNAMETTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseCNAMETTLNumber(0)), + }, + ) +} + +type RecordEditResponseCNAMETTLNumber float64 + +const ( + RecordEditResponseCNAMETTLNumber1 RecordEditResponseCNAMETTLNumber = 1 +) + +type RecordEditResponseDNSKEY struct { + // Components of a DNSKEY record. + Data RecordEditResponseDNSKEYData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordEditResponseDNSKEYType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted DNSKEY content. See 'data' to set DNSKEY properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseDNSKEYMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseDNSKEYTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseDNSKEYJSON `json:"-"` +} + +// recordEditResponseDNSKEYJSON contains the JSON metadata for the struct +// [RecordEditResponseDNSKEY] +type recordEditResponseDNSKEYJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseDNSKEY) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseDNSKEYJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseDNSKEY) implementsDNSRecordEditResponse() {} + +// Components of a DNSKEY record. +type RecordEditResponseDNSKEYData struct { + // Algorithm. + Algorithm float64 `json:"algorithm"` + // Flags. + Flags float64 `json:"flags"` + // Protocol. + Protocol float64 `json:"protocol"` + // Public Key. + PublicKey string `json:"public_key"` + JSON recordEditResponseDNSKEYDataJSON `json:"-"` +} + +// recordEditResponseDNSKEYDataJSON contains the JSON metadata for the struct +// [RecordEditResponseDNSKEYData] +type recordEditResponseDNSKEYDataJSON struct { + Algorithm apijson.Field + Flags apijson.Field + Protocol apijson.Field + PublicKey apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseDNSKEYData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseDNSKEYDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordEditResponseDNSKEYType string + +const ( + RecordEditResponseDNSKEYTypeDNSKEY RecordEditResponseDNSKEYType = "DNSKEY" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseDNSKEYMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseDNSKEYMetaJSON `json:"-"` +} + +// recordEditResponseDNSKEYMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseDNSKEYMeta] +type recordEditResponseDNSKEYMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseDNSKEYMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseDNSKEYMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordEditResponseDNSKEYTTLNumber]. +type RecordEditResponseDNSKEYTTL interface { + ImplementsDNSRecordEditResponseDnskeyttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseDNSKEYTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseDNSKEYTTLNumber(0)), + }, + ) +} + +type RecordEditResponseDNSKEYTTLNumber float64 + +const ( + RecordEditResponseDNSKEYTTLNumber1 RecordEditResponseDNSKEYTTLNumber = 1 +) + +type RecordEditResponseDS struct { + // Components of a DS record. + Data RecordEditResponseDSData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordEditResponseDSType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted DS content. See 'data' to set DS properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseDSMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseDSTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseDSJSON `json:"-"` +} + +// recordEditResponseDSJSON contains the JSON metadata for the struct +// [RecordEditResponseDS] +type recordEditResponseDSJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseDS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseDSJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseDS) implementsDNSRecordEditResponse() {} + +// Components of a DS record. +type RecordEditResponseDSData struct { + // Algorithm. + Algorithm float64 `json:"algorithm"` + // Digest. + Digest string `json:"digest"` + // Digest Type. + DigestType float64 `json:"digest_type"` + // Key Tag. + KeyTag float64 `json:"key_tag"` + JSON recordEditResponseDSDataJSON `json:"-"` +} + +// recordEditResponseDSDataJSON contains the JSON metadata for the struct +// [RecordEditResponseDSData] +type recordEditResponseDSDataJSON struct { + Algorithm apijson.Field + Digest apijson.Field + DigestType apijson.Field + KeyTag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseDSData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseDSDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordEditResponseDSType string + +const ( + RecordEditResponseDSTypeDS RecordEditResponseDSType = "DS" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseDSMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseDSMetaJSON `json:"-"` +} + +// recordEditResponseDSMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseDSMeta] +type recordEditResponseDSMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseDSMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseDSMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordEditResponseDSTTLNumber]. +type RecordEditResponseDSTTL interface { + ImplementsDNSRecordEditResponseDsttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseDSTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseDSTTLNumber(0)), + }, + ) +} + +type RecordEditResponseDSTTLNumber float64 + +const ( + RecordEditResponseDSTTLNumber1 RecordEditResponseDSTTLNumber = 1 +) + +type RecordEditResponseHTTPS struct { + // Components of a HTTPS record. + Data RecordEditResponseHTTPSData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordEditResponseHTTPSType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted HTTPS content. See 'data' to set HTTPS properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseHTTPSMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseHTTPSTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseHTTPSJSON `json:"-"` +} + +// recordEditResponseHTTPSJSON contains the JSON metadata for the struct +// [RecordEditResponseHTTPS] +type recordEditResponseHTTPSJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseHTTPS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseHTTPSJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseHTTPS) implementsDNSRecordEditResponse() {} + +// Components of a HTTPS record. +type RecordEditResponseHTTPSData struct { + // priority. + Priority float64 `json:"priority"` + // target. + Target string `json:"target"` + // value. + Value string `json:"value"` + JSON recordEditResponseHTTPSDataJSON `json:"-"` +} + +// recordEditResponseHTTPSDataJSON contains the JSON metadata for the struct +// [RecordEditResponseHTTPSData] +type recordEditResponseHTTPSDataJSON struct { + Priority apijson.Field + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseHTTPSData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseHTTPSDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordEditResponseHTTPSType string + +const ( + RecordEditResponseHTTPSTypeHTTPS RecordEditResponseHTTPSType = "HTTPS" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseHTTPSMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseHTTPSMetaJSON `json:"-"` +} + +// recordEditResponseHTTPSMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseHTTPSMeta] +type recordEditResponseHTTPSMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseHTTPSMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseHTTPSMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordEditResponseHTTPSTTLNumber]. +type RecordEditResponseHTTPSTTL interface { + ImplementsDNSRecordEditResponseHttpsttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseHTTPSTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseHTTPSTTLNumber(0)), + }, + ) +} + +type RecordEditResponseHTTPSTTLNumber float64 + +const ( + RecordEditResponseHTTPSTTLNumber1 RecordEditResponseHTTPSTTLNumber = 1 +) + +type RecordEditResponseLOC struct { + // Components of a LOC record. + Data RecordEditResponseLOCData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordEditResponseLOCType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted LOC content. See 'data' to set LOC properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseLOCMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseLOCTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseLOCJSON `json:"-"` +} + +// recordEditResponseLOCJSON contains the JSON metadata for the struct +// [RecordEditResponseLOC] +type recordEditResponseLOCJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseLOC) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseLOCJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseLOC) implementsDNSRecordEditResponse() {} + +// Components of a LOC record. +type RecordEditResponseLOCData struct { + // Altitude of location in meters. + Altitude float64 `json:"altitude"` + // Degrees of latitude. + LatDegrees float64 `json:"lat_degrees"` + // Latitude direction. + LatDirection RecordEditResponseLOCDataLatDirection `json:"lat_direction"` + // Minutes of latitude. + LatMinutes float64 `json:"lat_minutes"` + // Seconds of latitude. + LatSeconds float64 `json:"lat_seconds"` + // Degrees of longitude. + LongDegrees float64 `json:"long_degrees"` + // Longitude direction. + LongDirection RecordEditResponseLOCDataLongDirection `json:"long_direction"` + // Minutes of longitude. + LongMinutes float64 `json:"long_minutes"` + // Seconds of longitude. + LongSeconds float64 `json:"long_seconds"` + // Horizontal precision of location. + PrecisionHorz float64 `json:"precision_horz"` + // Vertical precision of location. + PrecisionVert float64 `json:"precision_vert"` + // Size of location in meters. + Size float64 `json:"size"` + JSON recordEditResponseLOCDataJSON `json:"-"` +} + +// recordEditResponseLOCDataJSON contains the JSON metadata for the struct +// [RecordEditResponseLOCData] +type recordEditResponseLOCDataJSON struct { + Altitude apijson.Field + LatDegrees apijson.Field + LatDirection apijson.Field + LatMinutes apijson.Field + LatSeconds apijson.Field + LongDegrees apijson.Field + LongDirection apijson.Field + LongMinutes apijson.Field + LongSeconds apijson.Field + PrecisionHorz apijson.Field + PrecisionVert apijson.Field + Size apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseLOCData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseLOCDataJSON) RawJSON() string { + return r.raw +} + +// Latitude direction. +type RecordEditResponseLOCDataLatDirection string + +const ( + RecordEditResponseLOCDataLatDirectionN RecordEditResponseLOCDataLatDirection = "N" + RecordEditResponseLOCDataLatDirectionS RecordEditResponseLOCDataLatDirection = "S" +) + +// Longitude direction. +type RecordEditResponseLOCDataLongDirection string + +const ( + RecordEditResponseLOCDataLongDirectionE RecordEditResponseLOCDataLongDirection = "E" + RecordEditResponseLOCDataLongDirectionW RecordEditResponseLOCDataLongDirection = "W" +) + +// Record type. +type RecordEditResponseLOCType string + +const ( + RecordEditResponseLOCTypeLOC RecordEditResponseLOCType = "LOC" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseLOCMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseLOCMetaJSON `json:"-"` +} + +// recordEditResponseLOCMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseLOCMeta] +type recordEditResponseLOCMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseLOCMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseLOCMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordEditResponseLOCTTLNumber]. +type RecordEditResponseLOCTTL interface { + ImplementsDNSRecordEditResponseLocttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseLOCTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseLOCTTLNumber(0)), + }, + ) +} + +type RecordEditResponseLOCTTLNumber float64 + +const ( + RecordEditResponseLOCTTLNumber1 RecordEditResponseLOCTTLNumber = 1 +) + +type RecordEditResponseMX struct { + // A valid mail server hostname. + Content string `json:"content,required" format:"hostname"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority float64 `json:"priority,required"` + // Record type. + Type RecordEditResponseMXType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseMXMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseMXTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseMXJSON `json:"-"` +} + +// recordEditResponseMXJSON contains the JSON metadata for the struct +// [RecordEditResponseMX] +type recordEditResponseMXJSON struct { + Content apijson.Field + Name apijson.Field + Priority apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseMX) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseMXJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseMX) implementsDNSRecordEditResponse() {} + +// Record type. +type RecordEditResponseMXType string + +const ( + RecordEditResponseMXTypeMX RecordEditResponseMXType = "MX" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseMXMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseMXMetaJSON `json:"-"` +} + +// recordEditResponseMXMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseMXMeta] +type recordEditResponseMXMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseMXMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseMXMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordEditResponseMXTTLNumber]. +type RecordEditResponseMXTTL interface { + ImplementsDNSRecordEditResponseMxttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseMXTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseMXTTLNumber(0)), + }, + ) +} + +type RecordEditResponseMXTTLNumber float64 + +const ( + RecordEditResponseMXTTLNumber1 RecordEditResponseMXTTLNumber = 1 +) + +type RecordEditResponseNAPTR struct { + // Components of a NAPTR record. + Data RecordEditResponseNAPTRData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordEditResponseNAPTRType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted NAPTR content. See 'data' to set NAPTR properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseNAPTRMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseNAPTRTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseNAPTRJSON `json:"-"` +} + +// recordEditResponseNAPTRJSON contains the JSON metadata for the struct +// [RecordEditResponseNAPTR] +type recordEditResponseNAPTRJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseNAPTR) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseNAPTRJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseNAPTR) implementsDNSRecordEditResponse() {} + +// Components of a NAPTR record. +type RecordEditResponseNAPTRData struct { + // Flags. + Flags string `json:"flags"` + // Order. + Order float64 `json:"order"` + // Preference. + Preference float64 `json:"preference"` + // Regex. + Regex string `json:"regex"` + // Replacement. + Replacement string `json:"replacement"` + // Service. + Service string `json:"service"` + JSON recordEditResponseNAPTRDataJSON `json:"-"` +} + +// recordEditResponseNAPTRDataJSON contains the JSON metadata for the struct +// [RecordEditResponseNAPTRData] +type recordEditResponseNAPTRDataJSON struct { + Flags apijson.Field + Order apijson.Field + Preference apijson.Field + Regex apijson.Field + Replacement apijson.Field + Service apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseNAPTRData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseNAPTRDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordEditResponseNAPTRType string + +const ( + RecordEditResponseNAPTRTypeNAPTR RecordEditResponseNAPTRType = "NAPTR" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseNAPTRMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseNAPTRMetaJSON `json:"-"` +} + +// recordEditResponseNAPTRMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseNAPTRMeta] +type recordEditResponseNAPTRMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseNAPTRMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseNAPTRMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordEditResponseNAPTRTTLNumber]. +type RecordEditResponseNAPTRTTL interface { + ImplementsDNSRecordEditResponseNaptrttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseNAPTRTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseNAPTRTTLNumber(0)), + }, + ) +} + +type RecordEditResponseNAPTRTTLNumber float64 + +const ( + RecordEditResponseNAPTRTTLNumber1 RecordEditResponseNAPTRTTLNumber = 1 +) + +type RecordEditResponseNS struct { + // A valid name server host name. + Content interface{} `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordEditResponseNSType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseNSMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseNSTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseNSJSON `json:"-"` +} + +// recordEditResponseNSJSON contains the JSON metadata for the struct +// [RecordEditResponseNS] +type recordEditResponseNSJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseNS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseNSJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseNS) implementsDNSRecordEditResponse() {} + +// Record type. +type RecordEditResponseNSType string + +const ( + RecordEditResponseNSTypeNS RecordEditResponseNSType = "NS" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseNSMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseNSMetaJSON `json:"-"` +} + +// recordEditResponseNSMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseNSMeta] +type recordEditResponseNSMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseNSMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseNSMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordEditResponseNSTTLNumber]. +type RecordEditResponseNSTTL interface { + ImplementsDNSRecordEditResponseNsttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseNSTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseNSTTLNumber(0)), + }, + ) +} + +type RecordEditResponseNSTTLNumber float64 + +const ( + RecordEditResponseNSTTLNumber1 RecordEditResponseNSTTLNumber = 1 +) + +type RecordEditResponsePTR struct { + // Domain name pointing to the address. + Content string `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordEditResponsePTRType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponsePTRMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponsePTRTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponsePTRJSON `json:"-"` +} + +// recordEditResponsePTRJSON contains the JSON metadata for the struct +// [RecordEditResponsePTR] +type recordEditResponsePTRJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponsePTR) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponsePTRJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponsePTR) implementsDNSRecordEditResponse() {} + +// Record type. +type RecordEditResponsePTRType string + +const ( + RecordEditResponsePTRTypePTR RecordEditResponsePTRType = "PTR" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponsePTRMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponsePTRMetaJSON `json:"-"` +} + +// recordEditResponsePTRMetaJSON contains the JSON metadata for the struct +// [RecordEditResponsePTRMeta] +type recordEditResponsePTRMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponsePTRMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponsePTRMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordEditResponsePTRTTLNumber]. +type RecordEditResponsePTRTTL interface { + ImplementsDNSRecordEditResponsePtrttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponsePTRTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponsePTRTTLNumber(0)), + }, + ) +} + +type RecordEditResponsePTRTTLNumber float64 + +const ( + RecordEditResponsePTRTTLNumber1 RecordEditResponsePTRTTLNumber = 1 +) + +type RecordEditResponseSmimea struct { + // Components of a SMIMEA record. + Data RecordEditResponseSmimeaData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordEditResponseSmimeaType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted SMIMEA content. See 'data' to set SMIMEA properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseSmimeaMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseSmimeaTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseSmimeaJSON `json:"-"` +} + +// recordEditResponseSmimeaJSON contains the JSON metadata for the struct +// [RecordEditResponseSmimea] +type recordEditResponseSmimeaJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseSmimea) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseSmimeaJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseSmimea) implementsDNSRecordEditResponse() {} + +// Components of a SMIMEA record. +type RecordEditResponseSmimeaData struct { + // Certificate. + Certificate string `json:"certificate"` + // Matching Type. + MatchingType float64 `json:"matching_type"` + // Selector. + Selector float64 `json:"selector"` + // Usage. + Usage float64 `json:"usage"` + JSON recordEditResponseSmimeaDataJSON `json:"-"` +} + +// recordEditResponseSmimeaDataJSON contains the JSON metadata for the struct +// [RecordEditResponseSmimeaData] +type recordEditResponseSmimeaDataJSON struct { + Certificate apijson.Field + MatchingType apijson.Field + Selector apijson.Field + Usage apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseSmimeaData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseSmimeaDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordEditResponseSmimeaType string + +const ( + RecordEditResponseSmimeaTypeSmimea RecordEditResponseSmimeaType = "SMIMEA" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseSmimeaMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseSmimeaMetaJSON `json:"-"` +} + +// recordEditResponseSmimeaMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseSmimeaMeta] +type recordEditResponseSmimeaMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseSmimeaMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseSmimeaMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordEditResponseSmimeaTTLNumber]. +type RecordEditResponseSmimeaTTL interface { + ImplementsDNSRecordEditResponseSmimeaTTL() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseSmimeaTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseSmimeaTTLNumber(0)), + }, + ) +} + +type RecordEditResponseSmimeaTTLNumber float64 + +const ( + RecordEditResponseSmimeaTTLNumber1 RecordEditResponseSmimeaTTLNumber = 1 +) + +type RecordEditResponseSRV struct { + // Components of a SRV record. + Data RecordEditResponseSRVData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. For SRV records, the first + // label is normally a service and the second a protocol name, each starting with + // an underscore. + Name string `json:"name,required"` + // Record type. + Type RecordEditResponseSRVType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Priority, weight, port, and SRV target. See 'data' for setting the individual + // component values. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseSRVMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseSRVTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseSRVJSON `json:"-"` +} + +// recordEditResponseSRVJSON contains the JSON metadata for the struct +// [RecordEditResponseSRV] +type recordEditResponseSRVJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseSRV) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseSRVJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseSRV) implementsDNSRecordEditResponse() {} + +// Components of a SRV record. +type RecordEditResponseSRVData struct { + // A valid hostname. Deprecated in favor of the regular 'name' outside the data + // map. This data map field represents the remainder of the full 'name' after the + // service and protocol. + Name string `json:"name" format:"hostname"` + // The port of the service. + Port float64 `json:"port"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority float64 `json:"priority"` + // A valid protocol, prefixed with an underscore. Deprecated in favor of the + // regular 'name' outside the data map. This data map field normally represents the + // second label of that 'name'. + Proto string `json:"proto"` + // A service type, prefixed with an underscore. Deprecated in favor of the regular + // 'name' outside the data map. This data map field normally represents the first + // label of that 'name'. + Service string `json:"service"` + // A valid hostname. + Target string `json:"target" format:"hostname"` + // The record weight. + Weight float64 `json:"weight"` + JSON recordEditResponseSRVDataJSON `json:"-"` +} + +// recordEditResponseSRVDataJSON contains the JSON metadata for the struct +// [RecordEditResponseSRVData] +type recordEditResponseSRVDataJSON struct { + Name apijson.Field + Port apijson.Field + Priority apijson.Field + Proto apijson.Field + Service apijson.Field + Target apijson.Field + Weight apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseSRVData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseSRVDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordEditResponseSRVType string + +const ( + RecordEditResponseSRVTypeSRV RecordEditResponseSRVType = "SRV" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseSRVMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseSRVMetaJSON `json:"-"` +} + +// recordEditResponseSRVMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseSRVMeta] +type recordEditResponseSRVMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseSRVMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseSRVMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordEditResponseSRVTTLNumber]. +type RecordEditResponseSRVTTL interface { + ImplementsDNSRecordEditResponseSrvttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseSRVTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseSRVTTLNumber(0)), + }, + ) +} + +type RecordEditResponseSRVTTLNumber float64 + +const ( + RecordEditResponseSRVTTLNumber1 RecordEditResponseSRVTTLNumber = 1 +) + +type RecordEditResponseSSHFP struct { + // Components of a SSHFP record. + Data RecordEditResponseSSHFPData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordEditResponseSSHFPType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted SSHFP content. See 'data' to set SSHFP properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseSSHFPMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseSSHFPTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseSSHFPJSON `json:"-"` +} + +// recordEditResponseSSHFPJSON contains the JSON metadata for the struct +// [RecordEditResponseSSHFP] +type recordEditResponseSSHFPJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseSSHFP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseSSHFPJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseSSHFP) implementsDNSRecordEditResponse() {} + +// Components of a SSHFP record. +type RecordEditResponseSSHFPData struct { + // algorithm. + Algorithm float64 `json:"algorithm"` + // fingerprint. + Fingerprint string `json:"fingerprint"` + // type. + Type float64 `json:"type"` + JSON recordEditResponseSSHFPDataJSON `json:"-"` +} + +// recordEditResponseSSHFPDataJSON contains the JSON metadata for the struct +// [RecordEditResponseSSHFPData] +type recordEditResponseSSHFPDataJSON struct { + Algorithm apijson.Field + Fingerprint apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseSSHFPData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseSSHFPDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordEditResponseSSHFPType string + +const ( + RecordEditResponseSSHFPTypeSSHFP RecordEditResponseSSHFPType = "SSHFP" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseSSHFPMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseSSHFPMetaJSON `json:"-"` +} + +// recordEditResponseSSHFPMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseSSHFPMeta] +type recordEditResponseSSHFPMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseSSHFPMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseSSHFPMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordEditResponseSSHFPTTLNumber]. +type RecordEditResponseSSHFPTTL interface { + ImplementsDNSRecordEditResponseSshfpttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseSSHFPTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseSSHFPTTLNumber(0)), + }, + ) +} + +type RecordEditResponseSSHFPTTLNumber float64 + +const ( + RecordEditResponseSSHFPTTLNumber1 RecordEditResponseSSHFPTTLNumber = 1 +) + +type RecordEditResponseSVCB struct { + // Components of a SVCB record. + Data RecordEditResponseSVCBData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordEditResponseSVCBType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted SVCB content. See 'data' to set SVCB properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseSVCBMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseSVCBTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseSVCBJSON `json:"-"` +} + +// recordEditResponseSVCBJSON contains the JSON metadata for the struct +// [RecordEditResponseSVCB] +type recordEditResponseSVCBJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseSVCB) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseSVCBJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseSVCB) implementsDNSRecordEditResponse() {} + +// Components of a SVCB record. +type RecordEditResponseSVCBData struct { + // priority. + Priority float64 `json:"priority"` + // target. + Target string `json:"target"` + // value. + Value string `json:"value"` + JSON recordEditResponseSVCBDataJSON `json:"-"` +} + +// recordEditResponseSVCBDataJSON contains the JSON metadata for the struct +// [RecordEditResponseSVCBData] +type recordEditResponseSVCBDataJSON struct { + Priority apijson.Field + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseSVCBData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseSVCBDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordEditResponseSVCBType string + +const ( + RecordEditResponseSVCBTypeSVCB RecordEditResponseSVCBType = "SVCB" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseSVCBMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseSVCBMetaJSON `json:"-"` +} + +// recordEditResponseSVCBMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseSVCBMeta] +type recordEditResponseSVCBMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseSVCBMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseSVCBMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordEditResponseSVCBTTLNumber]. +type RecordEditResponseSVCBTTL interface { + ImplementsDNSRecordEditResponseSvcbttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseSVCBTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseSVCBTTLNumber(0)), + }, + ) +} + +type RecordEditResponseSVCBTTLNumber float64 + +const ( + RecordEditResponseSVCBTTLNumber1 RecordEditResponseSVCBTTLNumber = 1 +) + +type RecordEditResponseTLSA struct { + // Components of a TLSA record. + Data RecordEditResponseTLSAData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordEditResponseTLSAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted TLSA content. See 'data' to set TLSA properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseTLSAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseTLSATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseTLSAJSON `json:"-"` +} + +// recordEditResponseTLSAJSON contains the JSON metadata for the struct +// [RecordEditResponseTLSA] +type recordEditResponseTLSAJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseTLSA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseTLSAJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseTLSA) implementsDNSRecordEditResponse() {} + +// Components of a TLSA record. +type RecordEditResponseTLSAData struct { + // certificate. + Certificate string `json:"certificate"` + // Matching Type. + MatchingType float64 `json:"matching_type"` + // Selector. + Selector float64 `json:"selector"` + // Usage. + Usage float64 `json:"usage"` + JSON recordEditResponseTLSADataJSON `json:"-"` +} + +// recordEditResponseTLSADataJSON contains the JSON metadata for the struct +// [RecordEditResponseTLSAData] +type recordEditResponseTLSADataJSON struct { + Certificate apijson.Field + MatchingType apijson.Field + Selector apijson.Field + Usage apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseTLSAData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseTLSADataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordEditResponseTLSAType string + +const ( + RecordEditResponseTLSATypeTLSA RecordEditResponseTLSAType = "TLSA" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseTLSAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseTLSAMetaJSON `json:"-"` +} + +// recordEditResponseTLSAMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseTLSAMeta] +type recordEditResponseTLSAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseTLSAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseTLSAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordEditResponseTLSATTLNumber]. +type RecordEditResponseTLSATTL interface { + ImplementsDNSRecordEditResponseTlsattl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseTLSATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseTLSATTLNumber(0)), + }, + ) +} + +type RecordEditResponseTLSATTLNumber float64 + +const ( + RecordEditResponseTLSATTLNumber1 RecordEditResponseTLSATTLNumber = 1 +) + +type RecordEditResponseTXT struct { + // Text content for the record. + Content string `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordEditResponseTXTType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseTXTMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseTXTTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseTXTJSON `json:"-"` +} + +// recordEditResponseTXTJSON contains the JSON metadata for the struct +// [RecordEditResponseTXT] +type recordEditResponseTXTJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseTXT) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseTXTJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseTXT) implementsDNSRecordEditResponse() {} + +// Record type. +type RecordEditResponseTXTType string + +const ( + RecordEditResponseTXTTypeTXT RecordEditResponseTXTType = "TXT" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseTXTMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseTXTMetaJSON `json:"-"` +} + +// recordEditResponseTXTMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseTXTMeta] +type recordEditResponseTXTMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseTXTMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseTXTMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordEditResponseTXTTTLNumber]. +type RecordEditResponseTXTTTL interface { + ImplementsDNSRecordEditResponseTxtttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseTXTTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseTXTTTLNumber(0)), + }, + ) +} + +type RecordEditResponseTXTTTLNumber float64 + +const ( + RecordEditResponseTXTTTLNumber1 RecordEditResponseTXTTTLNumber = 1 +) + +type RecordEditResponseURI struct { + // Components of a URI record. + Data RecordEditResponseURIData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority float64 `json:"priority,required"` + // Record type. + Type RecordEditResponseURIType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted URI content. See 'data' to set URI properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordEditResponseURIMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordEditResponseURITTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordEditResponseURIJSON `json:"-"` +} + +// recordEditResponseURIJSON contains the JSON metadata for the struct +// [RecordEditResponseURI] +type recordEditResponseURIJSON struct { + Data apijson.Field + Name apijson.Field + Priority apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseURI) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseURIJSON) RawJSON() string { + return r.raw +} + +func (r RecordEditResponseURI) implementsDNSRecordEditResponse() {} + +// Components of a URI record. +type RecordEditResponseURIData struct { + // The record content. + Content string `json:"content"` + // The record weight. + Weight float64 `json:"weight"` + JSON recordEditResponseURIDataJSON `json:"-"` +} + +// recordEditResponseURIDataJSON contains the JSON metadata for the struct +// [RecordEditResponseURIData] +type recordEditResponseURIDataJSON struct { + Content apijson.Field + Weight apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseURIData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseURIDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordEditResponseURIType string + +const ( + RecordEditResponseURITypeURI RecordEditResponseURIType = "URI" +) + +// Extra Cloudflare-specific information about the record. +type RecordEditResponseURIMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordEditResponseURIMetaJSON `json:"-"` +} + +// recordEditResponseURIMetaJSON contains the JSON metadata for the struct +// [RecordEditResponseURIMeta] +type recordEditResponseURIMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseURIMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseURIMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordEditResponseURITTLNumber]. +type RecordEditResponseURITTL interface { + ImplementsDNSRecordEditResponseUrittl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordEditResponseURITTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordEditResponseURITTLNumber(0)), + }, + ) +} + +type RecordEditResponseURITTLNumber float64 + +const ( + RecordEditResponseURITTLNumber1 RecordEditResponseURITTLNumber = 1 +) + +// Union satisfied by [dns.RecordGetResponseA], [dns.RecordGetResponseAAAA], +// [dns.RecordGetResponseCAA], [dns.RecordGetResponseCert], +// [dns.RecordGetResponseCNAME], [dns.RecordGetResponseDNSKEY], +// [dns.RecordGetResponseDS], [dns.RecordGetResponseHTTPS], +// [dns.RecordGetResponseLOC], [dns.RecordGetResponseMX], +// [dns.RecordGetResponseNAPTR], [dns.RecordGetResponseNS], +// [dns.RecordGetResponsePTR], [dns.RecordGetResponseSmimea], +// [dns.RecordGetResponseSRV], [dns.RecordGetResponseSSHFP], +// [dns.RecordGetResponseSVCB], [dns.RecordGetResponseTLSA], +// [dns.RecordGetResponseTXT] or [dns.RecordGetResponseURI]. +type RecordGetResponse interface { + implementsDNSRecordGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponse)(nil)).Elem(), + "type", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseA{}), + DiscriminatorValue: "A", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseAAAA{}), + DiscriminatorValue: "AAAA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseCAA{}), + DiscriminatorValue: "CAA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseCert{}), + DiscriminatorValue: "CERT", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseCNAME{}), + DiscriminatorValue: "CNAME", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseDNSKEY{}), + DiscriminatorValue: "DNSKEY", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseDS{}), + DiscriminatorValue: "DS", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseHTTPS{}), + DiscriminatorValue: "HTTPS", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseLOC{}), + DiscriminatorValue: "LOC", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseMX{}), + DiscriminatorValue: "MX", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseNAPTR{}), + DiscriminatorValue: "NAPTR", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseNS{}), + DiscriminatorValue: "NS", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponsePTR{}), + DiscriminatorValue: "PTR", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseSmimea{}), + DiscriminatorValue: "SMIMEA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseSRV{}), + DiscriminatorValue: "SRV", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseSSHFP{}), + DiscriminatorValue: "SSHFP", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseSVCB{}), + DiscriminatorValue: "SVCB", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseTLSA{}), + DiscriminatorValue: "TLSA", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseTXT{}), + DiscriminatorValue: "TXT", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RecordGetResponseURI{}), + DiscriminatorValue: "URI", + }, + ) +} + +type RecordGetResponseA struct { + // A valid IPv4 address. + Content string `json:"content,required" format:"ipv4"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordGetResponseAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied bool `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseAJSON `json:"-"` +} + +// recordGetResponseAJSON contains the JSON metadata for the struct +// [RecordGetResponseA] +type recordGetResponseAJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Proxied apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseAJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseA) implementsDNSRecordGetResponse() {} + +// Record type. +type RecordGetResponseAType string + +const ( + RecordGetResponseATypeA RecordGetResponseAType = "A" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseAMetaJSON `json:"-"` +} + +// recordGetResponseAMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseAMeta] +type recordGetResponseAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordGetResponseATTLNumber]. +type RecordGetResponseATTL interface { + ImplementsDNSRecordGetResponseAttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseATTLNumber(0)), + }, + ) +} + +type RecordGetResponseATTLNumber float64 + +const ( + RecordGetResponseATTLNumber1 RecordGetResponseATTLNumber = 1 +) + +type RecordGetResponseAAAA struct { + // A valid IPv6 address. + Content string `json:"content,required" format:"ipv6"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordGetResponseAAAAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseAAAAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied bool `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseAAAATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseAAAAJSON `json:"-"` +} + +// recordGetResponseAAAAJSON contains the JSON metadata for the struct +// [RecordGetResponseAAAA] +type recordGetResponseAAAAJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Proxied apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseAAAA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseAAAAJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseAAAA) implementsDNSRecordGetResponse() {} + +// Record type. +type RecordGetResponseAAAAType string + +const ( + RecordGetResponseAAAATypeAAAA RecordGetResponseAAAAType = "AAAA" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseAAAAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseAAAAMetaJSON `json:"-"` +} + +// recordGetResponseAAAAMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseAAAAMeta] +type recordGetResponseAAAAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseAAAAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseAAAAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordGetResponseAAAATTLNumber]. +type RecordGetResponseAAAATTL interface { + ImplementsDNSRecordGetResponseAaaattl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseAAAATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseAAAATTLNumber(0)), + }, + ) +} + +type RecordGetResponseAAAATTLNumber float64 + +const ( + RecordGetResponseAAAATTLNumber1 RecordGetResponseAAAATTLNumber = 1 +) + +type RecordGetResponseCAA struct { + // Components of a CAA record. + Data RecordGetResponseCAAData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordGetResponseCAAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted CAA content. See 'data' to set CAA properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseCAAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseCAATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseCAAJSON `json:"-"` +} + +// recordGetResponseCAAJSON contains the JSON metadata for the struct +// [RecordGetResponseCAA] +type recordGetResponseCAAJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseCAA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseCAAJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseCAA) implementsDNSRecordGetResponse() {} + +// Components of a CAA record. +type RecordGetResponseCAAData struct { + // Flags for the CAA record. + Flags float64 `json:"flags"` + // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). + Tag string `json:"tag"` + // Value of the record. This field's semantics depend on the chosen tag. + Value string `json:"value"` + JSON recordGetResponseCAADataJSON `json:"-"` +} + +// recordGetResponseCAADataJSON contains the JSON metadata for the struct +// [RecordGetResponseCAAData] +type recordGetResponseCAADataJSON struct { + Flags apijson.Field + Tag apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseCAAData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseCAADataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordGetResponseCAAType string + +const ( + RecordGetResponseCAATypeCAA RecordGetResponseCAAType = "CAA" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseCAAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseCAAMetaJSON `json:"-"` +} + +// recordGetResponseCAAMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseCAAMeta] +type recordGetResponseCAAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseCAAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseCAAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordGetResponseCAATTLNumber]. +type RecordGetResponseCAATTL interface { + ImplementsDNSRecordGetResponseCaattl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseCAATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseCAATTLNumber(0)), + }, + ) +} + +type RecordGetResponseCAATTLNumber float64 + +const ( + RecordGetResponseCAATTLNumber1 RecordGetResponseCAATTLNumber = 1 +) + +type RecordGetResponseCert struct { + // Components of a CERT record. + Data RecordGetResponseCertData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordGetResponseCertType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted CERT content. See 'data' to set CERT properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseCertMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseCertTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseCertJSON `json:"-"` +} + +// recordGetResponseCertJSON contains the JSON metadata for the struct +// [RecordGetResponseCert] +type recordGetResponseCertJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseCert) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseCertJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseCert) implementsDNSRecordGetResponse() {} + +// Components of a CERT record. +type RecordGetResponseCertData struct { + // Algorithm. + Algorithm float64 `json:"algorithm"` + // Certificate. + Certificate string `json:"certificate"` + // Key Tag. + KeyTag float64 `json:"key_tag"` + // Type. + Type float64 `json:"type"` + JSON recordGetResponseCertDataJSON `json:"-"` +} + +// recordGetResponseCertDataJSON contains the JSON metadata for the struct +// [RecordGetResponseCertData] +type recordGetResponseCertDataJSON struct { + Algorithm apijson.Field + Certificate apijson.Field + KeyTag apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseCertData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseCertDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordGetResponseCertType string + +const ( + RecordGetResponseCertTypeCert RecordGetResponseCertType = "CERT" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseCertMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseCertMetaJSON `json:"-"` +} + +// recordGetResponseCertMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseCertMeta] +type recordGetResponseCertMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseCertMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseCertMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordGetResponseCertTTLNumber]. +type RecordGetResponseCertTTL interface { + ImplementsDNSRecordGetResponseCertTTL() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseCertTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseCertTTLNumber(0)), + }, + ) +} + +type RecordGetResponseCertTTLNumber float64 + +const ( + RecordGetResponseCertTTLNumber1 RecordGetResponseCertTTLNumber = 1 +) + +type RecordGetResponseCNAME struct { + // A valid hostname. Must not match the record's name. + Content interface{} `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordGetResponseCNAMEType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseCNAMEMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied bool `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseCNAMETTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseCNAMEJSON `json:"-"` +} + +// recordGetResponseCNAMEJSON contains the JSON metadata for the struct +// [RecordGetResponseCNAME] +type recordGetResponseCNAMEJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Proxied apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseCNAME) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseCNAMEJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseCNAME) implementsDNSRecordGetResponse() {} + +// Record type. +type RecordGetResponseCNAMEType string + +const ( + RecordGetResponseCNAMETypeCNAME RecordGetResponseCNAMEType = "CNAME" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseCNAMEMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseCNAMEMetaJSON `json:"-"` +} + +// recordGetResponseCNAMEMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseCNAMEMeta] +type recordGetResponseCNAMEMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseCNAMEMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseCNAMEMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordGetResponseCNAMETTLNumber]. +type RecordGetResponseCNAMETTL interface { + ImplementsDNSRecordGetResponseCnamettl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseCNAMETTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseCNAMETTLNumber(0)), + }, + ) +} + +type RecordGetResponseCNAMETTLNumber float64 + +const ( + RecordGetResponseCNAMETTLNumber1 RecordGetResponseCNAMETTLNumber = 1 +) + +type RecordGetResponseDNSKEY struct { + // Components of a DNSKEY record. + Data RecordGetResponseDNSKEYData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordGetResponseDNSKEYType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted DNSKEY content. See 'data' to set DNSKEY properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseDNSKEYMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseDNSKEYTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseDNSKEYJSON `json:"-"` +} + +// recordGetResponseDNSKEYJSON contains the JSON metadata for the struct +// [RecordGetResponseDNSKEY] +type recordGetResponseDNSKEYJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseDNSKEY) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseDNSKEYJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseDNSKEY) implementsDNSRecordGetResponse() {} + +// Components of a DNSKEY record. +type RecordGetResponseDNSKEYData struct { + // Algorithm. + Algorithm float64 `json:"algorithm"` + // Flags. + Flags float64 `json:"flags"` + // Protocol. + Protocol float64 `json:"protocol"` + // Public Key. + PublicKey string `json:"public_key"` + JSON recordGetResponseDNSKEYDataJSON `json:"-"` +} + +// recordGetResponseDNSKEYDataJSON contains the JSON metadata for the struct +// [RecordGetResponseDNSKEYData] +type recordGetResponseDNSKEYDataJSON struct { + Algorithm apijson.Field + Flags apijson.Field + Protocol apijson.Field + PublicKey apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseDNSKEYData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseDNSKEYDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordGetResponseDNSKEYType string + +const ( + RecordGetResponseDNSKEYTypeDNSKEY RecordGetResponseDNSKEYType = "DNSKEY" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseDNSKEYMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseDNSKEYMetaJSON `json:"-"` +} + +// recordGetResponseDNSKEYMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseDNSKEYMeta] +type recordGetResponseDNSKEYMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseDNSKEYMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseDNSKEYMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordGetResponseDNSKEYTTLNumber]. +type RecordGetResponseDNSKEYTTL interface { + ImplementsDNSRecordGetResponseDnskeyttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseDNSKEYTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseDNSKEYTTLNumber(0)), + }, + ) +} + +type RecordGetResponseDNSKEYTTLNumber float64 + +const ( + RecordGetResponseDNSKEYTTLNumber1 RecordGetResponseDNSKEYTTLNumber = 1 +) + +type RecordGetResponseDS struct { + // Components of a DS record. + Data RecordGetResponseDSData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordGetResponseDSType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted DS content. See 'data' to set DS properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseDSMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseDSTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseDSJSON `json:"-"` +} + +// recordGetResponseDSJSON contains the JSON metadata for the struct +// [RecordGetResponseDS] +type recordGetResponseDSJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseDS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseDSJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseDS) implementsDNSRecordGetResponse() {} + +// Components of a DS record. +type RecordGetResponseDSData struct { + // Algorithm. + Algorithm float64 `json:"algorithm"` + // Digest. + Digest string `json:"digest"` + // Digest Type. + DigestType float64 `json:"digest_type"` + // Key Tag. + KeyTag float64 `json:"key_tag"` + JSON recordGetResponseDSDataJSON `json:"-"` +} + +// recordGetResponseDSDataJSON contains the JSON metadata for the struct +// [RecordGetResponseDSData] +type recordGetResponseDSDataJSON struct { + Algorithm apijson.Field + Digest apijson.Field + DigestType apijson.Field + KeyTag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseDSData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseDSDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordGetResponseDSType string + +const ( + RecordGetResponseDSTypeDS RecordGetResponseDSType = "DS" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseDSMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseDSMetaJSON `json:"-"` +} + +// recordGetResponseDSMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseDSMeta] +type recordGetResponseDSMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseDSMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseDSMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordGetResponseDSTTLNumber]. +type RecordGetResponseDSTTL interface { + ImplementsDNSRecordGetResponseDsttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseDSTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseDSTTLNumber(0)), + }, + ) +} + +type RecordGetResponseDSTTLNumber float64 + +const ( + RecordGetResponseDSTTLNumber1 RecordGetResponseDSTTLNumber = 1 +) + +type RecordGetResponseHTTPS struct { + // Components of a HTTPS record. + Data RecordGetResponseHTTPSData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordGetResponseHTTPSType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted HTTPS content. See 'data' to set HTTPS properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseHTTPSMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseHTTPSTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseHTTPSJSON `json:"-"` +} + +// recordGetResponseHTTPSJSON contains the JSON metadata for the struct +// [RecordGetResponseHTTPS] +type recordGetResponseHTTPSJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseHTTPS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseHTTPSJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseHTTPS) implementsDNSRecordGetResponse() {} + +// Components of a HTTPS record. +type RecordGetResponseHTTPSData struct { + // priority. + Priority float64 `json:"priority"` + // target. + Target string `json:"target"` + // value. + Value string `json:"value"` + JSON recordGetResponseHTTPSDataJSON `json:"-"` +} + +// recordGetResponseHTTPSDataJSON contains the JSON metadata for the struct +// [RecordGetResponseHTTPSData] +type recordGetResponseHTTPSDataJSON struct { + Priority apijson.Field + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseHTTPSData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseHTTPSDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordGetResponseHTTPSType string + +const ( + RecordGetResponseHTTPSTypeHTTPS RecordGetResponseHTTPSType = "HTTPS" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseHTTPSMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseHTTPSMetaJSON `json:"-"` +} + +// recordGetResponseHTTPSMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseHTTPSMeta] +type recordGetResponseHTTPSMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseHTTPSMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseHTTPSMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordGetResponseHTTPSTTLNumber]. +type RecordGetResponseHTTPSTTL interface { + ImplementsDNSRecordGetResponseHttpsttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseHTTPSTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseHTTPSTTLNumber(0)), + }, + ) +} + +type RecordGetResponseHTTPSTTLNumber float64 + +const ( + RecordGetResponseHTTPSTTLNumber1 RecordGetResponseHTTPSTTLNumber = 1 +) + +type RecordGetResponseLOC struct { + // Components of a LOC record. + Data RecordGetResponseLOCData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordGetResponseLOCType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted LOC content. See 'data' to set LOC properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseLOCMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseLOCTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseLOCJSON `json:"-"` +} + +// recordGetResponseLOCJSON contains the JSON metadata for the struct +// [RecordGetResponseLOC] +type recordGetResponseLOCJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseLOC) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseLOCJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseLOC) implementsDNSRecordGetResponse() {} + +// Components of a LOC record. +type RecordGetResponseLOCData struct { + // Altitude of location in meters. + Altitude float64 `json:"altitude"` + // Degrees of latitude. + LatDegrees float64 `json:"lat_degrees"` + // Latitude direction. + LatDirection RecordGetResponseLOCDataLatDirection `json:"lat_direction"` + // Minutes of latitude. + LatMinutes float64 `json:"lat_minutes"` + // Seconds of latitude. + LatSeconds float64 `json:"lat_seconds"` + // Degrees of longitude. + LongDegrees float64 `json:"long_degrees"` + // Longitude direction. + LongDirection RecordGetResponseLOCDataLongDirection `json:"long_direction"` + // Minutes of longitude. + LongMinutes float64 `json:"long_minutes"` + // Seconds of longitude. + LongSeconds float64 `json:"long_seconds"` + // Horizontal precision of location. + PrecisionHorz float64 `json:"precision_horz"` + // Vertical precision of location. + PrecisionVert float64 `json:"precision_vert"` + // Size of location in meters. + Size float64 `json:"size"` + JSON recordGetResponseLOCDataJSON `json:"-"` +} + +// recordGetResponseLOCDataJSON contains the JSON metadata for the struct +// [RecordGetResponseLOCData] +type recordGetResponseLOCDataJSON struct { + Altitude apijson.Field + LatDegrees apijson.Field + LatDirection apijson.Field + LatMinutes apijson.Field + LatSeconds apijson.Field + LongDegrees apijson.Field + LongDirection apijson.Field + LongMinutes apijson.Field + LongSeconds apijson.Field + PrecisionHorz apijson.Field + PrecisionVert apijson.Field + Size apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseLOCData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseLOCDataJSON) RawJSON() string { + return r.raw +} + +// Latitude direction. +type RecordGetResponseLOCDataLatDirection string + +const ( + RecordGetResponseLOCDataLatDirectionN RecordGetResponseLOCDataLatDirection = "N" + RecordGetResponseLOCDataLatDirectionS RecordGetResponseLOCDataLatDirection = "S" +) + +// Longitude direction. +type RecordGetResponseLOCDataLongDirection string + +const ( + RecordGetResponseLOCDataLongDirectionE RecordGetResponseLOCDataLongDirection = "E" + RecordGetResponseLOCDataLongDirectionW RecordGetResponseLOCDataLongDirection = "W" +) + +// Record type. +type RecordGetResponseLOCType string + +const ( + RecordGetResponseLOCTypeLOC RecordGetResponseLOCType = "LOC" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseLOCMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseLOCMetaJSON `json:"-"` +} + +// recordGetResponseLOCMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseLOCMeta] +type recordGetResponseLOCMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseLOCMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseLOCMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordGetResponseLOCTTLNumber]. +type RecordGetResponseLOCTTL interface { + ImplementsDNSRecordGetResponseLocttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseLOCTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseLOCTTLNumber(0)), + }, + ) +} + +type RecordGetResponseLOCTTLNumber float64 + +const ( + RecordGetResponseLOCTTLNumber1 RecordGetResponseLOCTTLNumber = 1 +) + +type RecordGetResponseMX struct { + // A valid mail server hostname. + Content string `json:"content,required" format:"hostname"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority float64 `json:"priority,required"` + // Record type. + Type RecordGetResponseMXType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseMXMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseMXTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseMXJSON `json:"-"` +} + +// recordGetResponseMXJSON contains the JSON metadata for the struct +// [RecordGetResponseMX] +type recordGetResponseMXJSON struct { + Content apijson.Field + Name apijson.Field + Priority apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseMX) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseMXJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseMX) implementsDNSRecordGetResponse() {} + +// Record type. +type RecordGetResponseMXType string + +const ( + RecordGetResponseMXTypeMX RecordGetResponseMXType = "MX" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseMXMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseMXMetaJSON `json:"-"` +} + +// recordGetResponseMXMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseMXMeta] +type recordGetResponseMXMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseMXMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseMXMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordGetResponseMXTTLNumber]. +type RecordGetResponseMXTTL interface { + ImplementsDNSRecordGetResponseMxttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseMXTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseMXTTLNumber(0)), + }, + ) +} + +type RecordGetResponseMXTTLNumber float64 + +const ( + RecordGetResponseMXTTLNumber1 RecordGetResponseMXTTLNumber = 1 +) + +type RecordGetResponseNAPTR struct { + // Components of a NAPTR record. + Data RecordGetResponseNAPTRData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordGetResponseNAPTRType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted NAPTR content. See 'data' to set NAPTR properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseNAPTRMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseNAPTRTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseNAPTRJSON `json:"-"` +} + +// recordGetResponseNAPTRJSON contains the JSON metadata for the struct +// [RecordGetResponseNAPTR] +type recordGetResponseNAPTRJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseNAPTR) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseNAPTRJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseNAPTR) implementsDNSRecordGetResponse() {} + +// Components of a NAPTR record. +type RecordGetResponseNAPTRData struct { + // Flags. + Flags string `json:"flags"` + // Order. + Order float64 `json:"order"` + // Preference. + Preference float64 `json:"preference"` + // Regex. + Regex string `json:"regex"` + // Replacement. + Replacement string `json:"replacement"` + // Service. + Service string `json:"service"` + JSON recordGetResponseNAPTRDataJSON `json:"-"` +} + +// recordGetResponseNAPTRDataJSON contains the JSON metadata for the struct +// [RecordGetResponseNAPTRData] +type recordGetResponseNAPTRDataJSON struct { + Flags apijson.Field + Order apijson.Field + Preference apijson.Field + Regex apijson.Field + Replacement apijson.Field + Service apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseNAPTRData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseNAPTRDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordGetResponseNAPTRType string + +const ( + RecordGetResponseNAPTRTypeNAPTR RecordGetResponseNAPTRType = "NAPTR" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseNAPTRMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseNAPTRMetaJSON `json:"-"` +} + +// recordGetResponseNAPTRMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseNAPTRMeta] +type recordGetResponseNAPTRMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseNAPTRMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseNAPTRMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordGetResponseNAPTRTTLNumber]. +type RecordGetResponseNAPTRTTL interface { + ImplementsDNSRecordGetResponseNaptrttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseNAPTRTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseNAPTRTTLNumber(0)), + }, + ) +} + +type RecordGetResponseNAPTRTTLNumber float64 + +const ( + RecordGetResponseNAPTRTTLNumber1 RecordGetResponseNAPTRTTLNumber = 1 +) + +type RecordGetResponseNS struct { + // A valid name server host name. + Content interface{} `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordGetResponseNSType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseNSMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseNSTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseNSJSON `json:"-"` +} + +// recordGetResponseNSJSON contains the JSON metadata for the struct +// [RecordGetResponseNS] +type recordGetResponseNSJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseNS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseNSJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseNS) implementsDNSRecordGetResponse() {} + +// Record type. +type RecordGetResponseNSType string + +const ( + RecordGetResponseNSTypeNS RecordGetResponseNSType = "NS" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseNSMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseNSMetaJSON `json:"-"` +} + +// recordGetResponseNSMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseNSMeta] +type recordGetResponseNSMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseNSMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseNSMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordGetResponseNSTTLNumber]. +type RecordGetResponseNSTTL interface { + ImplementsDNSRecordGetResponseNsttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseNSTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseNSTTLNumber(0)), + }, + ) +} + +type RecordGetResponseNSTTLNumber float64 + +const ( + RecordGetResponseNSTTLNumber1 RecordGetResponseNSTTLNumber = 1 +) + +type RecordGetResponsePTR struct { + // Domain name pointing to the address. + Content string `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordGetResponsePTRType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponsePTRMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponsePTRTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponsePTRJSON `json:"-"` +} + +// recordGetResponsePTRJSON contains the JSON metadata for the struct +// [RecordGetResponsePTR] +type recordGetResponsePTRJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponsePTR) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponsePTRJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponsePTR) implementsDNSRecordGetResponse() {} + +// Record type. +type RecordGetResponsePTRType string + +const ( + RecordGetResponsePTRTypePTR RecordGetResponsePTRType = "PTR" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponsePTRMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponsePTRMetaJSON `json:"-"` +} + +// recordGetResponsePTRMetaJSON contains the JSON metadata for the struct +// [RecordGetResponsePTRMeta] +type recordGetResponsePTRMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponsePTRMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponsePTRMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordGetResponsePTRTTLNumber]. +type RecordGetResponsePTRTTL interface { + ImplementsDNSRecordGetResponsePtrttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponsePTRTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponsePTRTTLNumber(0)), + }, + ) +} + +type RecordGetResponsePTRTTLNumber float64 + +const ( + RecordGetResponsePTRTTLNumber1 RecordGetResponsePTRTTLNumber = 1 +) + +type RecordGetResponseSmimea struct { + // Components of a SMIMEA record. + Data RecordGetResponseSmimeaData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordGetResponseSmimeaType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted SMIMEA content. See 'data' to set SMIMEA properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseSmimeaMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseSmimeaTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseSmimeaJSON `json:"-"` +} + +// recordGetResponseSmimeaJSON contains the JSON metadata for the struct +// [RecordGetResponseSmimea] +type recordGetResponseSmimeaJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseSmimea) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseSmimeaJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseSmimea) implementsDNSRecordGetResponse() {} + +// Components of a SMIMEA record. +type RecordGetResponseSmimeaData struct { + // Certificate. + Certificate string `json:"certificate"` + // Matching Type. + MatchingType float64 `json:"matching_type"` + // Selector. + Selector float64 `json:"selector"` + // Usage. + Usage float64 `json:"usage"` + JSON recordGetResponseSmimeaDataJSON `json:"-"` +} + +// recordGetResponseSmimeaDataJSON contains the JSON metadata for the struct +// [RecordGetResponseSmimeaData] +type recordGetResponseSmimeaDataJSON struct { + Certificate apijson.Field + MatchingType apijson.Field + Selector apijson.Field + Usage apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseSmimeaData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseSmimeaDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordGetResponseSmimeaType string + +const ( + RecordGetResponseSmimeaTypeSmimea RecordGetResponseSmimeaType = "SMIMEA" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseSmimeaMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseSmimeaMetaJSON `json:"-"` +} + +// recordGetResponseSmimeaMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseSmimeaMeta] +type recordGetResponseSmimeaMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseSmimeaMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseSmimeaMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or +// [dns.RecordGetResponseSmimeaTTLNumber]. +type RecordGetResponseSmimeaTTL interface { + ImplementsDNSRecordGetResponseSmimeaTTL() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseSmimeaTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseSmimeaTTLNumber(0)), + }, + ) +} + +type RecordGetResponseSmimeaTTLNumber float64 + +const ( + RecordGetResponseSmimeaTTLNumber1 RecordGetResponseSmimeaTTLNumber = 1 +) + +type RecordGetResponseSRV struct { + // Components of a SRV record. + Data RecordGetResponseSRVData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. For SRV records, the first + // label is normally a service and the second a protocol name, each starting with + // an underscore. + Name string `json:"name,required"` + // Record type. + Type RecordGetResponseSRVType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Priority, weight, port, and SRV target. See 'data' for setting the individual + // component values. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseSRVMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseSRVTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseSRVJSON `json:"-"` +} + +// recordGetResponseSRVJSON contains the JSON metadata for the struct +// [RecordGetResponseSRV] +type recordGetResponseSRVJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseSRV) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseSRVJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseSRV) implementsDNSRecordGetResponse() {} + +// Components of a SRV record. +type RecordGetResponseSRVData struct { + // A valid hostname. Deprecated in favor of the regular 'name' outside the data + // map. This data map field represents the remainder of the full 'name' after the + // service and protocol. + Name string `json:"name" format:"hostname"` + // The port of the service. + Port float64 `json:"port"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority float64 `json:"priority"` + // A valid protocol, prefixed with an underscore. Deprecated in favor of the + // regular 'name' outside the data map. This data map field normally represents the + // second label of that 'name'. + Proto string `json:"proto"` + // A service type, prefixed with an underscore. Deprecated in favor of the regular + // 'name' outside the data map. This data map field normally represents the first + // label of that 'name'. + Service string `json:"service"` + // A valid hostname. + Target string `json:"target" format:"hostname"` + // The record weight. + Weight float64 `json:"weight"` + JSON recordGetResponseSRVDataJSON `json:"-"` +} + +// recordGetResponseSRVDataJSON contains the JSON metadata for the struct +// [RecordGetResponseSRVData] +type recordGetResponseSRVDataJSON struct { + Name apijson.Field + Port apijson.Field + Priority apijson.Field + Proto apijson.Field + Service apijson.Field + Target apijson.Field + Weight apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseSRVData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseSRVDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordGetResponseSRVType string + +const ( + RecordGetResponseSRVTypeSRV RecordGetResponseSRVType = "SRV" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseSRVMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseSRVMetaJSON `json:"-"` +} + +// recordGetResponseSRVMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseSRVMeta] +type recordGetResponseSRVMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseSRVMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseSRVMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordGetResponseSRVTTLNumber]. +type RecordGetResponseSRVTTL interface { + ImplementsDNSRecordGetResponseSrvttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseSRVTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseSRVTTLNumber(0)), + }, + ) +} + +type RecordGetResponseSRVTTLNumber float64 + +const ( + RecordGetResponseSRVTTLNumber1 RecordGetResponseSRVTTLNumber = 1 +) + +type RecordGetResponseSSHFP struct { + // Components of a SSHFP record. + Data RecordGetResponseSSHFPData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordGetResponseSSHFPType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted SSHFP content. See 'data' to set SSHFP properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseSSHFPMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseSSHFPTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseSSHFPJSON `json:"-"` +} + +// recordGetResponseSSHFPJSON contains the JSON metadata for the struct +// [RecordGetResponseSSHFP] +type recordGetResponseSSHFPJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseSSHFP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseSSHFPJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseSSHFP) implementsDNSRecordGetResponse() {} + +// Components of a SSHFP record. +type RecordGetResponseSSHFPData struct { + // algorithm. + Algorithm float64 `json:"algorithm"` + // fingerprint. + Fingerprint string `json:"fingerprint"` + // type. + Type float64 `json:"type"` + JSON recordGetResponseSSHFPDataJSON `json:"-"` +} + +// recordGetResponseSSHFPDataJSON contains the JSON metadata for the struct +// [RecordGetResponseSSHFPData] +type recordGetResponseSSHFPDataJSON struct { + Algorithm apijson.Field + Fingerprint apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseSSHFPData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseSSHFPDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordGetResponseSSHFPType string + +const ( + RecordGetResponseSSHFPTypeSSHFP RecordGetResponseSSHFPType = "SSHFP" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseSSHFPMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseSSHFPMetaJSON `json:"-"` +} + +// recordGetResponseSSHFPMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseSSHFPMeta] +type recordGetResponseSSHFPMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseSSHFPMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseSSHFPMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordGetResponseSSHFPTTLNumber]. +type RecordGetResponseSSHFPTTL interface { + ImplementsDNSRecordGetResponseSshfpttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseSSHFPTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseSSHFPTTLNumber(0)), + }, + ) +} + +type RecordGetResponseSSHFPTTLNumber float64 + +const ( + RecordGetResponseSSHFPTTLNumber1 RecordGetResponseSSHFPTTLNumber = 1 +) + +type RecordGetResponseSVCB struct { + // Components of a SVCB record. + Data RecordGetResponseSVCBData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordGetResponseSVCBType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted SVCB content. See 'data' to set SVCB properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseSVCBMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseSVCBTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseSVCBJSON `json:"-"` +} + +// recordGetResponseSVCBJSON contains the JSON metadata for the struct +// [RecordGetResponseSVCB] +type recordGetResponseSVCBJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseSVCB) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseSVCBJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseSVCB) implementsDNSRecordGetResponse() {} + +// Components of a SVCB record. +type RecordGetResponseSVCBData struct { + // priority. + Priority float64 `json:"priority"` + // target. + Target string `json:"target"` + // value. + Value string `json:"value"` + JSON recordGetResponseSVCBDataJSON `json:"-"` +} + +// recordGetResponseSVCBDataJSON contains the JSON metadata for the struct +// [RecordGetResponseSVCBData] +type recordGetResponseSVCBDataJSON struct { + Priority apijson.Field + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseSVCBData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseSVCBDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordGetResponseSVCBType string + +const ( + RecordGetResponseSVCBTypeSVCB RecordGetResponseSVCBType = "SVCB" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseSVCBMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseSVCBMetaJSON `json:"-"` +} + +// recordGetResponseSVCBMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseSVCBMeta] +type recordGetResponseSVCBMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseSVCBMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseSVCBMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordGetResponseSVCBTTLNumber]. +type RecordGetResponseSVCBTTL interface { + ImplementsDNSRecordGetResponseSvcbttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseSVCBTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseSVCBTTLNumber(0)), + }, + ) +} + +type RecordGetResponseSVCBTTLNumber float64 + +const ( + RecordGetResponseSVCBTTLNumber1 RecordGetResponseSVCBTTLNumber = 1 +) + +type RecordGetResponseTLSA struct { + // Components of a TLSA record. + Data RecordGetResponseTLSAData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordGetResponseTLSAType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted TLSA content. See 'data' to set TLSA properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseTLSAMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseTLSATTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseTLSAJSON `json:"-"` +} + +// recordGetResponseTLSAJSON contains the JSON metadata for the struct +// [RecordGetResponseTLSA] +type recordGetResponseTLSAJSON struct { + Data apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseTLSA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseTLSAJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseTLSA) implementsDNSRecordGetResponse() {} + +// Components of a TLSA record. +type RecordGetResponseTLSAData struct { + // certificate. + Certificate string `json:"certificate"` + // Matching Type. + MatchingType float64 `json:"matching_type"` + // Selector. + Selector float64 `json:"selector"` + // Usage. + Usage float64 `json:"usage"` + JSON recordGetResponseTLSADataJSON `json:"-"` +} + +// recordGetResponseTLSADataJSON contains the JSON metadata for the struct +// [RecordGetResponseTLSAData] +type recordGetResponseTLSADataJSON struct { + Certificate apijson.Field + MatchingType apijson.Field + Selector apijson.Field + Usage apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseTLSAData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseTLSADataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordGetResponseTLSAType string + +const ( + RecordGetResponseTLSATypeTLSA RecordGetResponseTLSAType = "TLSA" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseTLSAMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseTLSAMetaJSON `json:"-"` +} + +// recordGetResponseTLSAMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseTLSAMeta] +type recordGetResponseTLSAMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseTLSAMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseTLSAMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordGetResponseTLSATTLNumber]. +type RecordGetResponseTLSATTL interface { + ImplementsDNSRecordGetResponseTlsattl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseTLSATTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseTLSATTLNumber(0)), + }, + ) +} + +type RecordGetResponseTLSATTLNumber float64 + +const ( + RecordGetResponseTLSATTLNumber1 RecordGetResponseTLSATTLNumber = 1 +) + +type RecordGetResponseTXT struct { + // Text content for the record. + Content string `json:"content,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Record type. + Type RecordGetResponseTXTType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseTXTMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseTXTTTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseTXTJSON `json:"-"` +} + +// recordGetResponseTXTJSON contains the JSON metadata for the struct +// [RecordGetResponseTXT] +type recordGetResponseTXTJSON struct { + Content apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseTXT) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseTXTJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseTXT) implementsDNSRecordGetResponse() {} + +// Record type. +type RecordGetResponseTXTType string + +const ( + RecordGetResponseTXTTypeTXT RecordGetResponseTXTType = "TXT" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseTXTMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseTXTMetaJSON `json:"-"` +} + +// recordGetResponseTXTMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseTXTMeta] +type recordGetResponseTXTMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseTXTMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseTXTMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordGetResponseTXTTTLNumber]. +type RecordGetResponseTXTTTL interface { + ImplementsDNSRecordGetResponseTxtttl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseTXTTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseTXTTTLNumber(0)), + }, + ) +} + +type RecordGetResponseTXTTTLNumber float64 + +const ( + RecordGetResponseTXTTTLNumber1 RecordGetResponseTXTTTLNumber = 1 +) + +type RecordGetResponseURI struct { + // Components of a URI record. + Data RecordGetResponseURIData `json:"data,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name string `json:"name,required"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority float64 `json:"priority,required"` + // Record type. + Type RecordGetResponseURIType `json:"type,required"` + // Identifier + ID string `json:"id"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment string `json:"comment"` + // Formatted URI content. See 'data' to set URI properties. + Content string `json:"content"` + // When the record was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Whether this record can be modified/deleted (true means it's managed by + // Cloudflare). + Locked bool `json:"locked"` + // Extra Cloudflare-specific information about the record. + Meta RecordGetResponseURIMeta `json:"meta"` + // When the record was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Whether the record can be proxied by Cloudflare or not. + Proxiable bool `json:"proxiable"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags []string `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL RecordGetResponseURITTL `json:"ttl"` + // Identifier + ZoneID string `json:"zone_id"` + // The domain of the record. + ZoneName string `json:"zone_name" format:"hostname"` + JSON recordGetResponseURIJSON `json:"-"` +} + +// recordGetResponseURIJSON contains the JSON metadata for the struct +// [RecordGetResponseURI] +type recordGetResponseURIJSON struct { + Data apijson.Field + Name apijson.Field + Priority apijson.Field + Type apijson.Field + ID apijson.Field + Comment apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Locked apijson.Field + Meta apijson.Field + ModifiedOn apijson.Field + Proxiable apijson.Field + Tags apijson.Field + TTL apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseURI) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseURIJSON) RawJSON() string { + return r.raw +} + +func (r RecordGetResponseURI) implementsDNSRecordGetResponse() {} + +// Components of a URI record. +type RecordGetResponseURIData struct { + // The record content. + Content string `json:"content"` + // The record weight. + Weight float64 `json:"weight"` + JSON recordGetResponseURIDataJSON `json:"-"` +} + +// recordGetResponseURIDataJSON contains the JSON metadata for the struct +// [RecordGetResponseURIData] +type recordGetResponseURIDataJSON struct { + Content apijson.Field + Weight apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseURIData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseURIDataJSON) RawJSON() string { + return r.raw +} + +// Record type. +type RecordGetResponseURIType string + +const ( + RecordGetResponseURITypeURI RecordGetResponseURIType = "URI" +) + +// Extra Cloudflare-specific information about the record. +type RecordGetResponseURIMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded bool `json:"auto_added"` + // Where the record originated from. + Source string `json:"source"` + JSON recordGetResponseURIMetaJSON `json:"-"` +} + +// recordGetResponseURIMetaJSON contains the JSON metadata for the struct +// [RecordGetResponseURIMeta] +type recordGetResponseURIMetaJSON struct { + AutoAdded apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseURIMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseURIMetaJSON) RawJSON() string { + return r.raw +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Union satisfied by [shared.UnionFloat] or [dns.RecordGetResponseURITTLNumber]. +type RecordGetResponseURITTL interface { + ImplementsDNSRecordGetResponseUrittl() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RecordGetResponseURITTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(RecordGetResponseURITTLNumber(0)), + }, + ) +} + +type RecordGetResponseURITTLNumber float64 + +const ( + RecordGetResponseURITTLNumber1 RecordGetResponseURITTLNumber = 1 +) + +type RecordImportResponse struct { + // Number of DNS records added. + RecsAdded float64 `json:"recs_added"` + // Total number of DNS records parsed. + TotalRecordsParsed float64 `json:"total_records_parsed"` + JSON recordImportResponseJSON `json:"-"` +} + +// recordImportResponseJSON contains the JSON metadata for the struct +// [RecordImportResponse] +type recordImportResponseJSON struct { + RecsAdded apijson.Field + TotalRecordsParsed apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordImportResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordImportResponseJSON) RawJSON() string { + return r.raw +} + +type RecordScanResponse struct { + // Number of DNS records added. + RecsAdded float64 `json:"recs_added"` + // Total number of DNS records parsed. + TotalRecordsParsed float64 `json:"total_records_parsed"` + JSON recordScanResponseJSON `json:"-"` +} + +// recordScanResponseJSON contains the JSON metadata for the struct +// [RecordScanResponse] +type recordScanResponseJSON struct { + RecsAdded apijson.Field + TotalRecordsParsed apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordScanResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordScanResponseJSON) RawJSON() string { + return r.raw +} + +type RecordNewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[RecordNewParamsType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + Data param.Field[RecordNewParamsData] `json:"data"` + Meta param.Field[RecordNewParamsMeta] `json:"meta"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority param.Field[float64] `json:"priority"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied param.Field[bool] `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags param.Field[[]string] `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL param.Field[RecordNewParamsTTL] `json:"ttl"` +} + +func (r RecordNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Record type. +type RecordNewParamsType string + +const ( + RecordNewParamsTypeURI RecordNewParamsType = "URI" +) + +type RecordNewParamsData struct { + // algorithm. + Algorithm param.Field[float64] `json:"algorithm"` + // Altitude of location in meters. + Altitude param.Field[float64] `json:"altitude"` + // certificate. + Certificate param.Field[string] `json:"certificate"` + // The record content. + Content param.Field[string] `json:"content"` + // Digest. + Digest param.Field[string] `json:"digest"` + // Digest Type. + DigestType param.Field[float64] `json:"digest_type"` + // fingerprint. + Fingerprint param.Field[string] `json:"fingerprint"` + // Flags. + Flags param.Field[string] `json:"flags"` + // Key Tag. + KeyTag param.Field[float64] `json:"key_tag"` + // Degrees of latitude. + LatDegrees param.Field[float64] `json:"lat_degrees"` + // Latitude direction. + LatDirection param.Field[RecordNewParamsDataLatDirection] `json:"lat_direction"` + // Minutes of latitude. + LatMinutes param.Field[float64] `json:"lat_minutes"` + // Seconds of latitude. + LatSeconds param.Field[float64] `json:"lat_seconds"` + // Degrees of longitude. + LongDegrees param.Field[float64] `json:"long_degrees"` + // Longitude direction. + LongDirection param.Field[RecordNewParamsDataLongDirection] `json:"long_direction"` + // Minutes of longitude. + LongMinutes param.Field[float64] `json:"long_minutes"` + // Seconds of longitude. + LongSeconds param.Field[float64] `json:"long_seconds"` + // Matching Type. + MatchingType param.Field[float64] `json:"matching_type"` + // A valid hostname. Deprecated in favor of the regular 'name' outside the data + // map. This data map field represents the remainder of the full 'name' after the + // service and protocol. + Name param.Field[string] `json:"name" format:"hostname"` + // Order. + Order param.Field[float64] `json:"order"` + // The port of the service. + Port param.Field[float64] `json:"port"` + // Horizontal precision of location. + PrecisionHorz param.Field[float64] `json:"precision_horz"` + // Vertical precision of location. + PrecisionVert param.Field[float64] `json:"precision_vert"` + // Preference. + Preference param.Field[float64] `json:"preference"` + // priority. + Priority param.Field[float64] `json:"priority"` + // A valid protocol, prefixed with an underscore. Deprecated in favor of the + // regular 'name' outside the data map. This data map field normally represents the + // second label of that 'name'. + Proto param.Field[string] `json:"proto"` + // Protocol. + Protocol param.Field[float64] `json:"protocol"` + // Public Key. + PublicKey param.Field[string] `json:"public_key"` + // Regex. + Regex param.Field[string] `json:"regex"` + // Replacement. + Replacement param.Field[string] `json:"replacement"` + // Selector. + Selector param.Field[float64] `json:"selector"` + // A service type, prefixed with an underscore. Deprecated in favor of the regular + // 'name' outside the data map. This data map field normally represents the first + // label of that 'name'. + Service param.Field[string] `json:"service"` + // Size of location in meters. + Size param.Field[float64] `json:"size"` + // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). + Tag param.Field[string] `json:"tag"` + // target. + Target param.Field[string] `json:"target"` + // type. + Type param.Field[float64] `json:"type"` + // Usage. + Usage param.Field[float64] `json:"usage"` + // value. + Value param.Field[string] `json:"value"` + // The record weight. + Weight param.Field[float64] `json:"weight"` +} + +func (r RecordNewParamsData) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Latitude direction. +type RecordNewParamsDataLatDirection string + +const ( + RecordNewParamsDataLatDirectionN RecordNewParamsDataLatDirection = "N" + RecordNewParamsDataLatDirectionS RecordNewParamsDataLatDirection = "S" +) + +// Longitude direction. +type RecordNewParamsDataLongDirection string + +const ( + RecordNewParamsDataLongDirectionE RecordNewParamsDataLongDirection = "E" + RecordNewParamsDataLongDirectionW RecordNewParamsDataLongDirection = "W" +) + +type RecordNewParamsMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded param.Field[bool] `json:"auto_added"` + // Where the record originated from. + Source param.Field[string] `json:"source"` +} + +func (r RecordNewParamsMeta) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Satisfied by [shared.UnionFloat], [dns.RecordNewParamsTTLNumber]. +type RecordNewParamsTTL interface { + ImplementsDNSRecordNewParamsTTL() +} + +type RecordNewParamsTTLNumber float64 + +const ( + RecordNewParamsTTLNumber1 RecordNewParamsTTLNumber = 1 +) + +type RecordNewResponseEnvelope struct { + Errors []RecordNewResponseEnvelopeErrors `json:"errors,required"` + Messages []RecordNewResponseEnvelopeMessages `json:"messages,required"` + Result RecordNewResponse `json:"result,required"` + // Whether the API call was successful + Success RecordNewResponseEnvelopeSuccess `json:"success,required"` + JSON recordNewResponseEnvelopeJSON `json:"-"` +} + +// recordNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [RecordNewResponseEnvelope] +type recordNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RecordNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON recordNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// recordNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RecordNewResponseEnvelopeErrors] +type recordNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RecordNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON recordNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// recordNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RecordNewResponseEnvelopeMessages] +type recordNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RecordNewResponseEnvelopeSuccess bool + +const ( + RecordNewResponseEnvelopeSuccessTrue RecordNewResponseEnvelopeSuccess = true +) + +type RecordUpdateParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[RecordUpdateParamsType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + Data param.Field[RecordUpdateParamsData] `json:"data"` + Meta param.Field[RecordUpdateParamsMeta] `json:"meta"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority param.Field[float64] `json:"priority"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied param.Field[bool] `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags param.Field[[]string] `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL param.Field[RecordUpdateParamsTTL] `json:"ttl"` +} + +func (r RecordUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Record type. +type RecordUpdateParamsType string + +const ( + RecordUpdateParamsTypeURI RecordUpdateParamsType = "URI" +) + +type RecordUpdateParamsData struct { + // algorithm. + Algorithm param.Field[float64] `json:"algorithm"` + // Altitude of location in meters. + Altitude param.Field[float64] `json:"altitude"` + // certificate. + Certificate param.Field[string] `json:"certificate"` + // The record content. + Content param.Field[string] `json:"content"` + // Digest. + Digest param.Field[string] `json:"digest"` + // Digest Type. + DigestType param.Field[float64] `json:"digest_type"` + // fingerprint. + Fingerprint param.Field[string] `json:"fingerprint"` + // Flags. + Flags param.Field[string] `json:"flags"` + // Key Tag. + KeyTag param.Field[float64] `json:"key_tag"` + // Degrees of latitude. + LatDegrees param.Field[float64] `json:"lat_degrees"` + // Latitude direction. + LatDirection param.Field[RecordUpdateParamsDataLatDirection] `json:"lat_direction"` + // Minutes of latitude. + LatMinutes param.Field[float64] `json:"lat_minutes"` + // Seconds of latitude. + LatSeconds param.Field[float64] `json:"lat_seconds"` + // Degrees of longitude. + LongDegrees param.Field[float64] `json:"long_degrees"` + // Longitude direction. + LongDirection param.Field[RecordUpdateParamsDataLongDirection] `json:"long_direction"` + // Minutes of longitude. + LongMinutes param.Field[float64] `json:"long_minutes"` + // Seconds of longitude. + LongSeconds param.Field[float64] `json:"long_seconds"` + // Matching Type. + MatchingType param.Field[float64] `json:"matching_type"` + // A valid hostname. Deprecated in favor of the regular 'name' outside the data + // map. This data map field represents the remainder of the full 'name' after the + // service and protocol. + Name param.Field[string] `json:"name" format:"hostname"` + // Order. + Order param.Field[float64] `json:"order"` + // The port of the service. + Port param.Field[float64] `json:"port"` + // Horizontal precision of location. + PrecisionHorz param.Field[float64] `json:"precision_horz"` + // Vertical precision of location. + PrecisionVert param.Field[float64] `json:"precision_vert"` + // Preference. + Preference param.Field[float64] `json:"preference"` + // priority. + Priority param.Field[float64] `json:"priority"` + // A valid protocol, prefixed with an underscore. Deprecated in favor of the + // regular 'name' outside the data map. This data map field normally represents the + // second label of that 'name'. + Proto param.Field[string] `json:"proto"` + // Protocol. + Protocol param.Field[float64] `json:"protocol"` + // Public Key. + PublicKey param.Field[string] `json:"public_key"` + // Regex. + Regex param.Field[string] `json:"regex"` + // Replacement. + Replacement param.Field[string] `json:"replacement"` + // Selector. + Selector param.Field[float64] `json:"selector"` + // A service type, prefixed with an underscore. Deprecated in favor of the regular + // 'name' outside the data map. This data map field normally represents the first + // label of that 'name'. + Service param.Field[string] `json:"service"` + // Size of location in meters. + Size param.Field[float64] `json:"size"` + // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). + Tag param.Field[string] `json:"tag"` + // target. + Target param.Field[string] `json:"target"` + // type. + Type param.Field[float64] `json:"type"` + // Usage. + Usage param.Field[float64] `json:"usage"` + // value. + Value param.Field[string] `json:"value"` + // The record weight. + Weight param.Field[float64] `json:"weight"` +} + +func (r RecordUpdateParamsData) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Latitude direction. +type RecordUpdateParamsDataLatDirection string + +const ( + RecordUpdateParamsDataLatDirectionN RecordUpdateParamsDataLatDirection = "N" + RecordUpdateParamsDataLatDirectionS RecordUpdateParamsDataLatDirection = "S" +) + +// Longitude direction. +type RecordUpdateParamsDataLongDirection string + +const ( + RecordUpdateParamsDataLongDirectionE RecordUpdateParamsDataLongDirection = "E" + RecordUpdateParamsDataLongDirectionW RecordUpdateParamsDataLongDirection = "W" +) + +type RecordUpdateParamsMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded param.Field[bool] `json:"auto_added"` + // Where the record originated from. + Source param.Field[string] `json:"source"` +} + +func (r RecordUpdateParamsMeta) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Satisfied by [shared.UnionFloat], [dns.RecordUpdateParamsTTLNumber]. +type RecordUpdateParamsTTL interface { + ImplementsDNSRecordUpdateParamsTTL() +} + +type RecordUpdateParamsTTLNumber float64 + +const ( + RecordUpdateParamsTTLNumber1 RecordUpdateParamsTTLNumber = 1 +) + +type RecordUpdateResponseEnvelope struct { + Errors []RecordUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []RecordUpdateResponseEnvelopeMessages `json:"messages,required"` + Result RecordUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success RecordUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON recordUpdateResponseEnvelopeJSON `json:"-"` +} + +// recordUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [RecordUpdateResponseEnvelope] +type recordUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RecordUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON recordUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// recordUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RecordUpdateResponseEnvelopeErrors] +type recordUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RecordUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON recordUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// recordUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RecordUpdateResponseEnvelopeMessages] +type recordUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RecordUpdateResponseEnvelopeSuccess bool + +const ( + RecordUpdateResponseEnvelopeSuccessTrue RecordUpdateResponseEnvelopeSuccess = true +) + +type RecordListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Comment param.Field[RecordListParamsComment] `query:"comment"` + // DNS record content. + Content param.Field[string] `query:"content"` + // Direction to order DNS records in. + Direction param.Field[RecordListParamsDirection] `query:"direction"` + // Whether to match all search requirements or at least one (any). If set to `all`, + // acts like a logical AND between filters. If set to `any`, acts like a logical OR + // instead. Note that the interaction between tag filters is controlled by the + // `tag-match` parameter instead. + Match param.Field[RecordListParamsMatch] `query:"match"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `query:"name"` + // Field to order DNS records by. + Order param.Field[RecordListParamsOrder] `query:"order"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // Number of DNS records per page. + PerPage param.Field[float64] `query:"per_page"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied param.Field[bool] `query:"proxied"` + // Allows searching in multiple properties of a DNS record simultaneously. This + // parameter is intended for human users, not automation. Its exact behavior is + // intentionally left unspecified and is subject to change in the future. This + // parameter works independently of the `match` setting. For automated searches, + // please use the other available parameters. + Search param.Field[string] `query:"search"` + Tag param.Field[RecordListParamsTag] `query:"tag"` + // Whether to match all tag search requirements or at least one (any). If set to + // `all`, acts like a logical AND between tag filters. If set to `any`, acts like a + // logical OR instead. Note that the regular `match` parameter is still used to + // combine the resulting condition with other filters that aren't related to tags. + TagMatch param.Field[RecordListParamsTagMatch] `query:"tag_match"` + // Record type. + Type param.Field[RecordListParamsType] `query:"type"` +} + +// URLQuery serializes [RecordListParams]'s query parameters as `url.Values`. +func (r RecordListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type RecordListParamsComment struct { + // If this parameter is present, only records _without_ a comment are returned. + Absent param.Field[string] `query:"absent"` + // Substring of the DNS record comment. Comment filters are case-insensitive. + Contains param.Field[string] `query:"contains"` + // Suffix of the DNS record comment. Comment filters are case-insensitive. + Endswith param.Field[string] `query:"endswith"` + // Exact value of the DNS record comment. Comment filters are case-insensitive. + Exact param.Field[string] `query:"exact"` + // If this parameter is present, only records _with_ a comment are returned. + Present param.Field[string] `query:"present"` + // Prefix of the DNS record comment. Comment filters are case-insensitive. + Startswith param.Field[string] `query:"startswith"` +} + +// URLQuery serializes [RecordListParamsComment]'s query parameters as +// `url.Values`. +func (r RecordListParamsComment) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Direction to order DNS records in. +type RecordListParamsDirection string + +const ( + RecordListParamsDirectionAsc RecordListParamsDirection = "asc" + RecordListParamsDirectionDesc RecordListParamsDirection = "desc" +) + +// Whether to match all search requirements or at least one (any). If set to `all`, +// acts like a logical AND between filters. If set to `any`, acts like a logical OR +// instead. Note that the interaction between tag filters is controlled by the +// `tag-match` parameter instead. +type RecordListParamsMatch string + +const ( + RecordListParamsMatchAny RecordListParamsMatch = "any" + RecordListParamsMatchAll RecordListParamsMatch = "all" +) + +// Field to order DNS records by. +type RecordListParamsOrder string + +const ( + RecordListParamsOrderType RecordListParamsOrder = "type" + RecordListParamsOrderName RecordListParamsOrder = "name" + RecordListParamsOrderContent RecordListParamsOrder = "content" + RecordListParamsOrderTTL RecordListParamsOrder = "ttl" + RecordListParamsOrderProxied RecordListParamsOrder = "proxied" +) + +type RecordListParamsTag struct { + // Name of a tag which must _not_ be present on the DNS record. Tag filters are + // case-insensitive. + Absent param.Field[string] `query:"absent"` + // A tag and value, of the form `:`. The API will only return + // DNS records that have a tag named `` whose value contains + // ``. Tag filters are case-insensitive. + Contains param.Field[string] `query:"contains"` + // A tag and value, of the form `:`. The API will only return + // DNS records that have a tag named `` whose value ends with + // ``. Tag filters are case-insensitive. + Endswith param.Field[string] `query:"endswith"` + // A tag and value, of the form `:`. The API will only return + // DNS records that have a tag named `` whose value is ``. Tag + // filters are case-insensitive. + Exact param.Field[string] `query:"exact"` + // Name of a tag which must be present on the DNS record. Tag filters are + // case-insensitive. + Present param.Field[string] `query:"present"` + // A tag and value, of the form `:`. The API will only return + // DNS records that have a tag named `` whose value starts with + // ``. Tag filters are case-insensitive. + Startswith param.Field[string] `query:"startswith"` +} + +// URLQuery serializes [RecordListParamsTag]'s query parameters as `url.Values`. +func (r RecordListParamsTag) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Whether to match all tag search requirements or at least one (any). If set to +// `all`, acts like a logical AND between tag filters. If set to `any`, acts like a +// logical OR instead. Note that the regular `match` parameter is still used to +// combine the resulting condition with other filters that aren't related to tags. +type RecordListParamsTagMatch string + +const ( + RecordListParamsTagMatchAny RecordListParamsTagMatch = "any" + RecordListParamsTagMatchAll RecordListParamsTagMatch = "all" +) + +// Record type. +type RecordListParamsType string + +const ( + RecordListParamsTypeA RecordListParamsType = "A" + RecordListParamsTypeAAAA RecordListParamsType = "AAAA" + RecordListParamsTypeCAA RecordListParamsType = "CAA" + RecordListParamsTypeCert RecordListParamsType = "CERT" + RecordListParamsTypeCNAME RecordListParamsType = "CNAME" + RecordListParamsTypeDNSKEY RecordListParamsType = "DNSKEY" + RecordListParamsTypeDS RecordListParamsType = "DS" + RecordListParamsTypeHTTPS RecordListParamsType = "HTTPS" + RecordListParamsTypeLOC RecordListParamsType = "LOC" + RecordListParamsTypeMX RecordListParamsType = "MX" + RecordListParamsTypeNAPTR RecordListParamsType = "NAPTR" + RecordListParamsTypeNS RecordListParamsType = "NS" + RecordListParamsTypePTR RecordListParamsType = "PTR" + RecordListParamsTypeSmimea RecordListParamsType = "SMIMEA" + RecordListParamsTypeSRV RecordListParamsType = "SRV" + RecordListParamsTypeSSHFP RecordListParamsType = "SSHFP" + RecordListParamsTypeSVCB RecordListParamsType = "SVCB" + RecordListParamsTypeTLSA RecordListParamsType = "TLSA" + RecordListParamsTypeTXT RecordListParamsType = "TXT" + RecordListParamsTypeURI RecordListParamsType = "URI" +) + +type RecordDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type RecordDeleteResponseEnvelope struct { + Result RecordDeleteResponse `json:"result"` + JSON recordDeleteResponseEnvelopeJSON `json:"-"` +} + +// recordDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [RecordDeleteResponseEnvelope] +type recordDeleteResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RecordEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // DNS record name (or @ for the zone apex) in Punycode. + Name param.Field[string] `json:"name,required"` + // Record type. + Type param.Field[RecordEditParamsType] `json:"type,required"` + // Comments or notes about the DNS record. This field has no effect on DNS + // responses. + Comment param.Field[string] `json:"comment"` + Data param.Field[RecordEditParamsData] `json:"data"` + Meta param.Field[RecordEditParamsMeta] `json:"meta"` + // Required for MX, SRV and URI records; unused by other record types. Records with + // lower priorities are preferred. + Priority param.Field[float64] `json:"priority"` + // Whether the record is receiving the performance and security benefits of + // Cloudflare. + Proxied param.Field[bool] `json:"proxied"` + // Custom tags for the DNS record. This field has no effect on DNS responses. + Tags param.Field[[]string] `json:"tags"` + // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. + // Value must be between 60 and 86400, with the minimum reduced to 30 for + // Enterprise zones. + TTL param.Field[RecordEditParamsTTL] `json:"ttl"` +} + +func (r RecordEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Record type. +type RecordEditParamsType string + +const ( + RecordEditParamsTypeURI RecordEditParamsType = "URI" +) + +type RecordEditParamsData struct { + // algorithm. + Algorithm param.Field[float64] `json:"algorithm"` + // Altitude of location in meters. + Altitude param.Field[float64] `json:"altitude"` + // certificate. + Certificate param.Field[string] `json:"certificate"` + // The record content. + Content param.Field[string] `json:"content"` + // Digest. + Digest param.Field[string] `json:"digest"` + // Digest Type. + DigestType param.Field[float64] `json:"digest_type"` + // fingerprint. + Fingerprint param.Field[string] `json:"fingerprint"` + // Flags. + Flags param.Field[string] `json:"flags"` + // Key Tag. + KeyTag param.Field[float64] `json:"key_tag"` + // Degrees of latitude. + LatDegrees param.Field[float64] `json:"lat_degrees"` + // Latitude direction. + LatDirection param.Field[RecordEditParamsDataLatDirection] `json:"lat_direction"` + // Minutes of latitude. + LatMinutes param.Field[float64] `json:"lat_minutes"` + // Seconds of latitude. + LatSeconds param.Field[float64] `json:"lat_seconds"` + // Degrees of longitude. + LongDegrees param.Field[float64] `json:"long_degrees"` + // Longitude direction. + LongDirection param.Field[RecordEditParamsDataLongDirection] `json:"long_direction"` + // Minutes of longitude. + LongMinutes param.Field[float64] `json:"long_minutes"` + // Seconds of longitude. + LongSeconds param.Field[float64] `json:"long_seconds"` + // Matching Type. + MatchingType param.Field[float64] `json:"matching_type"` + // A valid hostname. Deprecated in favor of the regular 'name' outside the data + // map. This data map field represents the remainder of the full 'name' after the + // service and protocol. + Name param.Field[string] `json:"name" format:"hostname"` + // Order. + Order param.Field[float64] `json:"order"` + // The port of the service. + Port param.Field[float64] `json:"port"` + // Horizontal precision of location. + PrecisionHorz param.Field[float64] `json:"precision_horz"` + // Vertical precision of location. + PrecisionVert param.Field[float64] `json:"precision_vert"` + // Preference. + Preference param.Field[float64] `json:"preference"` + // priority. + Priority param.Field[float64] `json:"priority"` + // A valid protocol, prefixed with an underscore. Deprecated in favor of the + // regular 'name' outside the data map. This data map field normally represents the + // second label of that 'name'. + Proto param.Field[string] `json:"proto"` + // Protocol. + Protocol param.Field[float64] `json:"protocol"` + // Public Key. + PublicKey param.Field[string] `json:"public_key"` + // Regex. + Regex param.Field[string] `json:"regex"` + // Replacement. + Replacement param.Field[string] `json:"replacement"` + // Selector. + Selector param.Field[float64] `json:"selector"` + // A service type, prefixed with an underscore. Deprecated in favor of the regular + // 'name' outside the data map. This data map field normally represents the first + // label of that 'name'. + Service param.Field[string] `json:"service"` + // Size of location in meters. + Size param.Field[float64] `json:"size"` + // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). + Tag param.Field[string] `json:"tag"` + // target. + Target param.Field[string] `json:"target"` + // type. + Type param.Field[float64] `json:"type"` + // Usage. + Usage param.Field[float64] `json:"usage"` + // value. + Value param.Field[string] `json:"value"` + // The record weight. + Weight param.Field[float64] `json:"weight"` +} + +func (r RecordEditParamsData) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Latitude direction. +type RecordEditParamsDataLatDirection string + +const ( + RecordEditParamsDataLatDirectionN RecordEditParamsDataLatDirection = "N" + RecordEditParamsDataLatDirectionS RecordEditParamsDataLatDirection = "S" +) + +// Longitude direction. +type RecordEditParamsDataLongDirection string + +const ( + RecordEditParamsDataLongDirectionE RecordEditParamsDataLongDirection = "E" + RecordEditParamsDataLongDirectionW RecordEditParamsDataLongDirection = "W" +) + +type RecordEditParamsMeta struct { + // Will exist if Cloudflare automatically added this DNS record during initial + // setup. + AutoAdded param.Field[bool] `json:"auto_added"` + // Where the record originated from. + Source param.Field[string] `json:"source"` +} + +func (r RecordEditParamsMeta) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. +// Value must be between 60 and 86400, with the minimum reduced to 30 for +// Enterprise zones. +// +// Satisfied by [shared.UnionFloat], [dns.RecordEditParamsTTLNumber]. +type RecordEditParamsTTL interface { + ImplementsDNSRecordEditParamsTTL() +} + +type RecordEditParamsTTLNumber float64 + +const ( + RecordEditParamsTTLNumber1 RecordEditParamsTTLNumber = 1 +) + +type RecordEditResponseEnvelope struct { + Errors []RecordEditResponseEnvelopeErrors `json:"errors,required"` + Messages []RecordEditResponseEnvelopeMessages `json:"messages,required"` + Result RecordEditResponse `json:"result,required"` + // Whether the API call was successful + Success RecordEditResponseEnvelopeSuccess `json:"success,required"` + JSON recordEditResponseEnvelopeJSON `json:"-"` +} + +// recordEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [RecordEditResponseEnvelope] +type recordEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RecordEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON recordEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// recordEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RecordEditResponseEnvelopeErrors] +type recordEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RecordEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON recordEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// recordEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RecordEditResponseEnvelopeMessages] +type recordEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RecordEditResponseEnvelopeSuccess bool + +const ( + RecordEditResponseEnvelopeSuccessTrue RecordEditResponseEnvelopeSuccess = true +) + +type RecordExportParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type RecordGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type RecordGetResponseEnvelope struct { + Errors []RecordGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RecordGetResponseEnvelopeMessages `json:"messages,required"` + Result RecordGetResponse `json:"result,required"` + // Whether the API call was successful + Success RecordGetResponseEnvelopeSuccess `json:"success,required"` + JSON recordGetResponseEnvelopeJSON `json:"-"` +} + +// recordGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RecordGetResponseEnvelope] +type recordGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RecordGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON recordGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// recordGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RecordGetResponseEnvelopeErrors] +type recordGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RecordGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON recordGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// recordGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RecordGetResponseEnvelopeMessages] +type recordGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RecordGetResponseEnvelopeSuccess bool + +const ( + RecordGetResponseEnvelopeSuccessTrue RecordGetResponseEnvelopeSuccess = true +) + +type RecordImportParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // BIND config to import. + // + // **Tip:** When using cURL, a file can be uploaded using + // `--form 'file=@bind_config.txt'`. + File param.Field[string] `json:"file,required"` + // Whether or not proxiable records should receive the performance and security + // benefits of Cloudflare. + // + // The value should be either `true` or `false`. + Proxied param.Field[string] `json:"proxied"` +} + +func (r RecordImportParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RecordImportResponseEnvelope struct { + Errors []RecordImportResponseEnvelopeErrors `json:"errors,required"` + Messages []RecordImportResponseEnvelopeMessages `json:"messages,required"` + Result RecordImportResponse `json:"result,required"` + // Whether the API call was successful + Success RecordImportResponseEnvelopeSuccess `json:"success,required"` + Timing RecordImportResponseEnvelopeTiming `json:"timing"` + JSON recordImportResponseEnvelopeJSON `json:"-"` +} + +// recordImportResponseEnvelopeJSON contains the JSON metadata for the struct +// [RecordImportResponseEnvelope] +type recordImportResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + Timing apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordImportResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordImportResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RecordImportResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON recordImportResponseEnvelopeErrorsJSON `json:"-"` +} + +// recordImportResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RecordImportResponseEnvelopeErrors] +type recordImportResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordImportResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordImportResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RecordImportResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON recordImportResponseEnvelopeMessagesJSON `json:"-"` +} + +// recordImportResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RecordImportResponseEnvelopeMessages] +type recordImportResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordImportResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordImportResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RecordImportResponseEnvelopeSuccess bool + +const ( + RecordImportResponseEnvelopeSuccessTrue RecordImportResponseEnvelopeSuccess = true +) + +type RecordImportResponseEnvelopeTiming struct { + // When the file parsing ended. + EndTime time.Time `json:"end_time" format:"date-time"` + // Processing time of the file in seconds. + ProcessTime float64 `json:"process_time"` + // When the file parsing started. + StartTime time.Time `json:"start_time" format:"date-time"` + JSON recordImportResponseEnvelopeTimingJSON `json:"-"` +} + +// recordImportResponseEnvelopeTimingJSON contains the JSON metadata for the struct +// [RecordImportResponseEnvelopeTiming] +type recordImportResponseEnvelopeTimingJSON struct { + EndTime apijson.Field + ProcessTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordImportResponseEnvelopeTiming) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordImportResponseEnvelopeTimingJSON) RawJSON() string { + return r.raw +} + +type RecordScanParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type RecordScanResponseEnvelope struct { + Errors []RecordScanResponseEnvelopeErrors `json:"errors,required"` + Messages []RecordScanResponseEnvelopeMessages `json:"messages,required"` + Result RecordScanResponse `json:"result,required"` + // Whether the API call was successful + Success RecordScanResponseEnvelopeSuccess `json:"success,required"` + Timing RecordScanResponseEnvelopeTiming `json:"timing"` + JSON recordScanResponseEnvelopeJSON `json:"-"` +} + +// recordScanResponseEnvelopeJSON contains the JSON metadata for the struct +// [RecordScanResponseEnvelope] +type recordScanResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + Timing apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordScanResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordScanResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RecordScanResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON recordScanResponseEnvelopeErrorsJSON `json:"-"` +} + +// recordScanResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RecordScanResponseEnvelopeErrors] +type recordScanResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordScanResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordScanResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RecordScanResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON recordScanResponseEnvelopeMessagesJSON `json:"-"` +} + +// recordScanResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RecordScanResponseEnvelopeMessages] +type recordScanResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordScanResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordScanResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RecordScanResponseEnvelopeSuccess bool + +const ( + RecordScanResponseEnvelopeSuccessTrue RecordScanResponseEnvelopeSuccess = true +) + +type RecordScanResponseEnvelopeTiming struct { + // When the file parsing ended. + EndTime time.Time `json:"end_time" format:"date-time"` + // Processing time of the file in seconds. + ProcessTime float64 `json:"process_time"` + // When the file parsing started. + StartTime time.Time `json:"start_time" format:"date-time"` + JSON recordScanResponseEnvelopeTimingJSON `json:"-"` +} + +// recordScanResponseEnvelopeTimingJSON contains the JSON metadata for the struct +// [RecordScanResponseEnvelopeTiming] +type recordScanResponseEnvelopeTimingJSON struct { + EndTime apijson.Field + ProcessTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecordScanResponseEnvelopeTiming) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recordScanResponseEnvelopeTimingJSON) RawJSON() string { + return r.raw +} diff --git a/dns/record_test.go b/dns/record_test.go new file mode 100644 index 00000000000..47dfd78fa09 --- /dev/null +++ b/dns/record_test.go @@ -0,0 +1,451 @@ +// File generated from our OpenAPI spec by Stainless. + +package dns_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/dns" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRecordNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.DNS.Records.New(context.TODO(), dns.RecordNewParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Name: cloudflare.F("example.com"), + Type: cloudflare.F(dns.RecordNewParamsTypeURI), + Comment: cloudflare.F("Domain verification record"), + Data: cloudflare.F(dns.RecordNewParamsData{ + Flags: cloudflare.F("string"), + Tag: cloudflare.F("issue"), + Value: cloudflare.F("alpn=\"h3,h2\" ipv4hint=\"127.0.0.1\" ipv6hint=\"::1\""), + Algorithm: cloudflare.F(2.000000), + Certificate: cloudflare.F("string"), + KeyTag: cloudflare.F(1.000000), + Type: cloudflare.F(1.000000), + Protocol: cloudflare.F(3.000000), + PublicKey: cloudflare.F("string"), + Digest: cloudflare.F("string"), + DigestType: cloudflare.F(1.000000), + Priority: cloudflare.F(1.000000), + Target: cloudflare.F("."), + Altitude: cloudflare.F(0.000000), + LatDegrees: cloudflare.F(37.000000), + LatDirection: cloudflare.F(dns.RecordNewParamsDataLatDirectionN), + LatMinutes: cloudflare.F(46.000000), + LatSeconds: cloudflare.F(46.000000), + LongDegrees: cloudflare.F(122.000000), + LongDirection: cloudflare.F(dns.RecordNewParamsDataLongDirectionW), + LongMinutes: cloudflare.F(23.000000), + LongSeconds: cloudflare.F(35.000000), + PrecisionHorz: cloudflare.F(0.000000), + PrecisionVert: cloudflare.F(0.000000), + Size: cloudflare.F(100.000000), + Order: cloudflare.F(100.000000), + Preference: cloudflare.F(10.000000), + Regex: cloudflare.F("string"), + Replacement: cloudflare.F("string"), + Service: cloudflare.F("_sip"), + MatchingType: cloudflare.F(1.000000), + Selector: cloudflare.F(0.000000), + Usage: cloudflare.F(0.000000), + Name: cloudflare.F("example.com"), + Port: cloudflare.F(8806.000000), + Proto: cloudflare.F("_tcp"), + Weight: cloudflare.F(20.000000), + Fingerprint: cloudflare.F("string"), + Content: cloudflare.F("http://example.com/example.html"), + }), + Meta: cloudflare.F(dns.RecordNewParamsMeta{ + AutoAdded: cloudflare.F(true), + Source: cloudflare.F("primary"), + }), + Priority: cloudflare.F(10.000000), + Proxied: cloudflare.F(false), + Tags: cloudflare.F([]string{"owner:dns-team", "owner:dns-team", "owner:dns-team"}), + TTL: cloudflare.F[dns.RecordNewParamsTTL](shared.UnionFloat(3600.000000)), + }) + 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 TestRecordUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.DNS.Records.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + dns.RecordUpdateParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Name: cloudflare.F("example.com"), + Type: cloudflare.F(dns.RecordUpdateParamsTypeURI), + Comment: cloudflare.F("Domain verification record"), + Data: cloudflare.F(dns.RecordUpdateParamsData{ + Flags: cloudflare.F("string"), + Tag: cloudflare.F("issue"), + Value: cloudflare.F("alpn=\"h3,h2\" ipv4hint=\"127.0.0.1\" ipv6hint=\"::1\""), + Algorithm: cloudflare.F(2.000000), + Certificate: cloudflare.F("string"), + KeyTag: cloudflare.F(1.000000), + Type: cloudflare.F(1.000000), + Protocol: cloudflare.F(3.000000), + PublicKey: cloudflare.F("string"), + Digest: cloudflare.F("string"), + DigestType: cloudflare.F(1.000000), + Priority: cloudflare.F(1.000000), + Target: cloudflare.F("."), + Altitude: cloudflare.F(0.000000), + LatDegrees: cloudflare.F(37.000000), + LatDirection: cloudflare.F(dns.RecordUpdateParamsDataLatDirectionN), + LatMinutes: cloudflare.F(46.000000), + LatSeconds: cloudflare.F(46.000000), + LongDegrees: cloudflare.F(122.000000), + LongDirection: cloudflare.F(dns.RecordUpdateParamsDataLongDirectionW), + LongMinutes: cloudflare.F(23.000000), + LongSeconds: cloudflare.F(35.000000), + PrecisionHorz: cloudflare.F(0.000000), + PrecisionVert: cloudflare.F(0.000000), + Size: cloudflare.F(100.000000), + Order: cloudflare.F(100.000000), + Preference: cloudflare.F(10.000000), + Regex: cloudflare.F("string"), + Replacement: cloudflare.F("string"), + Service: cloudflare.F("_sip"), + MatchingType: cloudflare.F(1.000000), + Selector: cloudflare.F(0.000000), + Usage: cloudflare.F(0.000000), + Name: cloudflare.F("example.com"), + Port: cloudflare.F(8806.000000), + Proto: cloudflare.F("_tcp"), + Weight: cloudflare.F(20.000000), + Fingerprint: cloudflare.F("string"), + Content: cloudflare.F("http://example.com/example.html"), + }), + Meta: cloudflare.F(dns.RecordUpdateParamsMeta{ + AutoAdded: cloudflare.F(true), + Source: cloudflare.F("primary"), + }), + Priority: cloudflare.F(10.000000), + Proxied: cloudflare.F(false), + Tags: cloudflare.F([]string{"owner:dns-team", "owner:dns-team", "owner:dns-team"}), + TTL: cloudflare.F[dns.RecordUpdateParamsTTL](shared.UnionFloat(3600.000000)), + }, + ) + 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 TestRecordListWithOptionalParams(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("user@example.com"), + ) + _, err := client.DNS.Records.List(context.TODO(), dns.RecordListParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Comment: cloudflare.F(dns.RecordListParamsComment{ + Present: cloudflare.F("string"), + Absent: cloudflare.F("string"), + Exact: cloudflare.F("Hello, world"), + Contains: cloudflare.F("ello, worl"), + Startswith: cloudflare.F("Hello, w"), + Endswith: cloudflare.F("o, world"), + }), + Content: cloudflare.F("127.0.0.1"), + Direction: cloudflare.F(dns.RecordListParamsDirectionAsc), + Match: cloudflare.F(dns.RecordListParamsMatchAny), + Name: cloudflare.F("example.com"), + Order: cloudflare.F(dns.RecordListParamsOrderType), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(5.000000), + Proxied: cloudflare.F(false), + Search: cloudflare.F("www.cloudflare.com"), + Tag: cloudflare.F(dns.RecordListParamsTag{ + Present: cloudflare.F("important"), + Absent: cloudflare.F("important"), + Exact: cloudflare.F("greeting:Hello, world"), + Contains: cloudflare.F("greeting:ello, worl"), + Startswith: cloudflare.F("greeting:Hello, w"), + Endswith: cloudflare.F("greeting:o, world"), + }), + TagMatch: cloudflare.F(dns.RecordListParamsTagMatchAny), + Type: cloudflare.F(dns.RecordListParamsTypeA), + }) + 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 TestRecordDelete(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("user@example.com"), + ) + _, err := client.DNS.Records.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + dns.RecordDeleteParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestRecordEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.DNS.Records.Edit( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + dns.RecordEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Name: cloudflare.F("example.com"), + Type: cloudflare.F(dns.RecordEditParamsTypeURI), + Comment: cloudflare.F("Domain verification record"), + Data: cloudflare.F(dns.RecordEditParamsData{ + Flags: cloudflare.F("string"), + Tag: cloudflare.F("issue"), + Value: cloudflare.F("alpn=\"h3,h2\" ipv4hint=\"127.0.0.1\" ipv6hint=\"::1\""), + Algorithm: cloudflare.F(2.000000), + Certificate: cloudflare.F("string"), + KeyTag: cloudflare.F(1.000000), + Type: cloudflare.F(1.000000), + Protocol: cloudflare.F(3.000000), + PublicKey: cloudflare.F("string"), + Digest: cloudflare.F("string"), + DigestType: cloudflare.F(1.000000), + Priority: cloudflare.F(1.000000), + Target: cloudflare.F("."), + Altitude: cloudflare.F(0.000000), + LatDegrees: cloudflare.F(37.000000), + LatDirection: cloudflare.F(dns.RecordEditParamsDataLatDirectionN), + LatMinutes: cloudflare.F(46.000000), + LatSeconds: cloudflare.F(46.000000), + LongDegrees: cloudflare.F(122.000000), + LongDirection: cloudflare.F(dns.RecordEditParamsDataLongDirectionW), + LongMinutes: cloudflare.F(23.000000), + LongSeconds: cloudflare.F(35.000000), + PrecisionHorz: cloudflare.F(0.000000), + PrecisionVert: cloudflare.F(0.000000), + Size: cloudflare.F(100.000000), + Order: cloudflare.F(100.000000), + Preference: cloudflare.F(10.000000), + Regex: cloudflare.F("string"), + Replacement: cloudflare.F("string"), + Service: cloudflare.F("_sip"), + MatchingType: cloudflare.F(1.000000), + Selector: cloudflare.F(0.000000), + Usage: cloudflare.F(0.000000), + Name: cloudflare.F("example.com"), + Port: cloudflare.F(8806.000000), + Proto: cloudflare.F("_tcp"), + Weight: cloudflare.F(20.000000), + Fingerprint: cloudflare.F("string"), + Content: cloudflare.F("http://example.com/example.html"), + }), + Meta: cloudflare.F(dns.RecordEditParamsMeta{ + AutoAdded: cloudflare.F(true), + Source: cloudflare.F("primary"), + }), + Priority: cloudflare.F(10.000000), + Proxied: cloudflare.F(false), + Tags: cloudflare.F([]string{"owner:dns-team", "owner:dns-team", "owner:dns-team"}), + TTL: cloudflare.F[dns.RecordEditParamsTTL](shared.UnionFloat(3600.000000)), + }, + ) + 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 TestRecordExport(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("user@example.com"), + ) + _, err := client.DNS.Records.Export(context.TODO(), dns.RecordExportParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestRecordGet(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("user@example.com"), + ) + _, err := client.DNS.Records.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + dns.RecordGetParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestRecordImportWithOptionalParams(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("user@example.com"), + ) + _, err := client.DNS.Records.Import(context.TODO(), dns.RecordImportParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + File: cloudflare.F("www.example.com. 300 IN A 127.0.0.1"), + Proxied: cloudflare.F("true"), + }) + 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 TestRecordScan(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("user@example.com"), + ) + _, err := client.DNS.Records.Scan(context.TODO(), dns.RecordScanParams{ + ZoneID: cloudflare.F("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/dnsanalytics.go b/dnsanalytics.go deleted file mode 100644 index 88d9775adb2..00000000000 --- a/dnsanalytics.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// DNSAnalyticsService 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 [NewDNSAnalyticsService] method -// instead. -type DNSAnalyticsService struct { - Options []option.RequestOption - Reports *DNSAnalyticsReportService -} - -// NewDNSAnalyticsService 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 NewDNSAnalyticsService(opts ...option.RequestOption) (r *DNSAnalyticsService) { - r = &DNSAnalyticsService{} - r.Options = opts - r.Reports = NewDNSAnalyticsReportService(opts...) - return -} diff --git a/dnsanalyticsreport.go b/dnsanalyticsreport.go deleted file mode 100644 index ca3b5326718..00000000000 --- a/dnsanalyticsreport.go +++ /dev/null @@ -1,272 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// DNSAnalyticsReportService 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 [NewDNSAnalyticsReportService] method -// instead. -type DNSAnalyticsReportService struct { - Options []option.RequestOption - Bytimes *DNSAnalyticsReportBytimeService -} - -// NewDNSAnalyticsReportService 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 NewDNSAnalyticsReportService(opts ...option.RequestOption) (r *DNSAnalyticsReportService) { - r = &DNSAnalyticsReportService{} - r.Options = opts - r.Bytimes = NewDNSAnalyticsReportBytimeService(opts...) - return -} - -// Retrieves a list of summarised aggregate metrics over a given time period. -// -// See -// [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) -// for detailed information about the available query parameters. -func (r *DNSAnalyticsReportService) Get(ctx context.Context, identifier string, query DNSAnalyticsReportGetParams, opts ...option.RequestOption) (res *DNSAnalyticsReportGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env DNSAnalyticsReportGetResponseEnvelope - path := fmt.Sprintf("zones/%s/dns_analytics/report", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type DNSAnalyticsReportGetResponse struct { - // Array with one row per combination of dimension values. - Data []DNSAnalyticsReportGetResponseData `json:"data,required"` - // Number of seconds between current time and last processed event, in another - // words how many seconds of data could be missing. - DataLag float64 `json:"data_lag,required"` - // Maximum results for each metric (object mapping metric names to values). - // Currently always an empty object. - Max interface{} `json:"max,required"` - // Minimum results for each metric (object mapping metric names to values). - // Currently always an empty object. - Min interface{} `json:"min,required"` - Query DNSAnalyticsReportGetResponseQuery `json:"query,required"` - // Total number of rows in the result. - Rows float64 `json:"rows,required"` - // Total results for metrics across all data (object mapping metric names to - // values). - Totals interface{} `json:"totals,required"` - JSON dnsAnalyticsReportGetResponseJSON `json:"-"` -} - -// dnsAnalyticsReportGetResponseJSON contains the JSON metadata for the struct -// [DNSAnalyticsReportGetResponse] -type dnsAnalyticsReportGetResponseJSON struct { - Data apijson.Field - DataLag apijson.Field - Max apijson.Field - Min apijson.Field - Query apijson.Field - Rows apijson.Field - Totals apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSAnalyticsReportGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsAnalyticsReportGetResponseJSON) RawJSON() string { - return r.raw -} - -type DNSAnalyticsReportGetResponseData struct { - // Array of dimension values, representing the combination of dimension values - // corresponding to this row. - Dimensions []string `json:"dimensions,required"` - // Array with one item per requested metric. Each item is a single value. - Metrics []float64 `json:"metrics,required"` - JSON dnsAnalyticsReportGetResponseDataJSON `json:"-"` -} - -// dnsAnalyticsReportGetResponseDataJSON contains the JSON metadata for the struct -// [DNSAnalyticsReportGetResponseData] -type dnsAnalyticsReportGetResponseDataJSON struct { - Dimensions apijson.Field - Metrics apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSAnalyticsReportGetResponseData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsAnalyticsReportGetResponseDataJSON) RawJSON() string { - return r.raw -} - -type DNSAnalyticsReportGetResponseQuery struct { - // Array of dimension names. - Dimensions []string `json:"dimensions,required"` - // Limit number of returned metrics. - Limit int64 `json:"limit,required"` - // Array of metric names. - Metrics []string `json:"metrics,required"` - // Start date and time of requesting data period in ISO 8601 format. - Since time.Time `json:"since,required" format:"date-time"` - // End date and time of requesting data period in ISO 8601 format. - Until time.Time `json:"until,required" format:"date-time"` - // Segmentation filter in 'attribute operator value' format. - Filters string `json:"filters"` - // Array of dimensions to sort by, where each dimension may be prefixed by - - // (descending) or + (ascending). - Sort []string `json:"sort"` - JSON dnsAnalyticsReportGetResponseQueryJSON `json:"-"` -} - -// dnsAnalyticsReportGetResponseQueryJSON contains the JSON metadata for the struct -// [DNSAnalyticsReportGetResponseQuery] -type dnsAnalyticsReportGetResponseQueryJSON struct { - Dimensions apijson.Field - Limit apijson.Field - Metrics apijson.Field - Since apijson.Field - Until apijson.Field - Filters apijson.Field - Sort apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSAnalyticsReportGetResponseQuery) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsAnalyticsReportGetResponseQueryJSON) RawJSON() string { - return r.raw -} - -type DNSAnalyticsReportGetParams struct { - // A comma-separated list of dimensions to group results by. - Dimensions param.Field[string] `query:"dimensions"` - // Segmentation filter in 'attribute operator value' format. - Filters param.Field[string] `query:"filters"` - // Limit number of returned metrics. - Limit param.Field[int64] `query:"limit"` - // A comma-separated list of metrics to query. - Metrics param.Field[string] `query:"metrics"` - // Start date and time of requesting data period in ISO 8601 format. - Since param.Field[time.Time] `query:"since" format:"date-time"` - // A comma-separated list of dimensions to sort by, where each dimension may be - // prefixed by - (descending) or + (ascending). - Sort param.Field[string] `query:"sort"` - // End date and time of requesting data period in ISO 8601 format. - Until param.Field[time.Time] `query:"until" format:"date-time"` -} - -// URLQuery serializes [DNSAnalyticsReportGetParams]'s query parameters as -// `url.Values`. -func (r DNSAnalyticsReportGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type DNSAnalyticsReportGetResponseEnvelope struct { - Errors []DNSAnalyticsReportGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSAnalyticsReportGetResponseEnvelopeMessages `json:"messages,required"` - Result DNSAnalyticsReportGetResponse `json:"result,required"` - // Whether the API call was successful - Success DNSAnalyticsReportGetResponseEnvelopeSuccess `json:"success,required"` - JSON dnsAnalyticsReportGetResponseEnvelopeJSON `json:"-"` -} - -// dnsAnalyticsReportGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [DNSAnalyticsReportGetResponseEnvelope] -type dnsAnalyticsReportGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSAnalyticsReportGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsAnalyticsReportGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DNSAnalyticsReportGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsAnalyticsReportGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnsAnalyticsReportGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [DNSAnalyticsReportGetResponseEnvelopeErrors] -type dnsAnalyticsReportGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSAnalyticsReportGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsAnalyticsReportGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSAnalyticsReportGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsAnalyticsReportGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnsAnalyticsReportGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [DNSAnalyticsReportGetResponseEnvelopeMessages] -type dnsAnalyticsReportGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSAnalyticsReportGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsAnalyticsReportGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DNSAnalyticsReportGetResponseEnvelopeSuccess bool - -const ( - DNSAnalyticsReportGetResponseEnvelopeSuccessTrue DNSAnalyticsReportGetResponseEnvelopeSuccess = true -) diff --git a/dnsanalyticsreport_test.go b/dnsanalyticsreport_test.go deleted file mode 100644 index af0a043f762..00000000000 --- a/dnsanalyticsreport_test.go +++ /dev/null @@ -1,51 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestDNSAnalyticsReportGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.DNS.Analytics.Reports.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.DNSAnalyticsReportGetParams{ - Dimensions: cloudflare.F("queryType"), - Filters: cloudflare.F("responseCode==NOERROR,queryType==A"), - Limit: cloudflare.F(int64(100)), - Metrics: cloudflare.F("queryCount,uncachedCount"), - Since: cloudflare.F(time.Now()), - Sort: cloudflare.F("+responseCode,-queryName"), - Until: cloudflare.F(time.Now()), - }, - ) - 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/dnsanalyticsreportbytime.go b/dnsanalyticsreportbytime.go deleted file mode 100644 index a79157a7d65..00000000000 --- a/dnsanalyticsreportbytime.go +++ /dev/null @@ -1,312 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// DNSAnalyticsReportBytimeService 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 -// [NewDNSAnalyticsReportBytimeService] method instead. -type DNSAnalyticsReportBytimeService struct { - Options []option.RequestOption -} - -// NewDNSAnalyticsReportBytimeService 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 NewDNSAnalyticsReportBytimeService(opts ...option.RequestOption) (r *DNSAnalyticsReportBytimeService) { - r = &DNSAnalyticsReportBytimeService{} - r.Options = opts - return -} - -// Retrieves a list of aggregate metrics grouped by time interval. -// -// See -// [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) -// for detailed information about the available query parameters. -func (r *DNSAnalyticsReportBytimeService) Get(ctx context.Context, identifier string, query DNSAnalyticsReportBytimeGetParams, opts ...option.RequestOption) (res *DNSAnalyticsReportBytimeGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env DNSAnalyticsReportBytimeGetResponseEnvelope - path := fmt.Sprintf("zones/%s/dns_analytics/report/bytime", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type DNSAnalyticsReportBytimeGetResponse struct { - // Array with one row per combination of dimension values. - Data []DNSAnalyticsReportBytimeGetResponseData `json:"data,required"` - // Number of seconds between current time and last processed event, in another - // words how many seconds of data could be missing. - DataLag float64 `json:"data_lag,required"` - // Maximum results for each metric (object mapping metric names to values). - // Currently always an empty object. - Max interface{} `json:"max,required"` - // Minimum results for each metric (object mapping metric names to values). - // Currently always an empty object. - Min interface{} `json:"min,required"` - Query DNSAnalyticsReportBytimeGetResponseQuery `json:"query,required"` - // Total number of rows in the result. - Rows float64 `json:"rows,required"` - // Array of time intervals in the response data. Each interval is represented as an - // array containing two values: the start time, and the end time. - TimeIntervals [][]time.Time `json:"time_intervals,required" format:"date-time"` - // Total results for metrics across all data (object mapping metric names to - // values). - Totals interface{} `json:"totals,required"` - JSON dnsAnalyticsReportBytimeGetResponseJSON `json:"-"` -} - -// dnsAnalyticsReportBytimeGetResponseJSON contains the JSON metadata for the -// struct [DNSAnalyticsReportBytimeGetResponse] -type dnsAnalyticsReportBytimeGetResponseJSON struct { - Data apijson.Field - DataLag apijson.Field - Max apijson.Field - Min apijson.Field - Query apijson.Field - Rows apijson.Field - TimeIntervals apijson.Field - Totals apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSAnalyticsReportBytimeGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsAnalyticsReportBytimeGetResponseJSON) RawJSON() string { - return r.raw -} - -type DNSAnalyticsReportBytimeGetResponseData struct { - // Array of dimension values, representing the combination of dimension values - // corresponding to this row. - Dimensions []string `json:"dimensions,required"` - // Array with one item per requested metric. Each item is an array of values, - // broken down by time interval. - Metrics [][]interface{} `json:"metrics,required"` - JSON dnsAnalyticsReportBytimeGetResponseDataJSON `json:"-"` -} - -// dnsAnalyticsReportBytimeGetResponseDataJSON contains the JSON metadata for the -// struct [DNSAnalyticsReportBytimeGetResponseData] -type dnsAnalyticsReportBytimeGetResponseDataJSON struct { - Dimensions apijson.Field - Metrics apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSAnalyticsReportBytimeGetResponseData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsAnalyticsReportBytimeGetResponseDataJSON) RawJSON() string { - return r.raw -} - -type DNSAnalyticsReportBytimeGetResponseQuery struct { - // Array of dimension names. - Dimensions []string `json:"dimensions,required"` - // Limit number of returned metrics. - Limit int64 `json:"limit,required"` - // Array of metric names. - Metrics []string `json:"metrics,required"` - // Start date and time of requesting data period in ISO 8601 format. - Since time.Time `json:"since,required" format:"date-time"` - // Unit of time to group data by. - TimeDelta DNSAnalyticsReportBytimeGetResponseQueryTimeDelta `json:"time_delta,required"` - // End date and time of requesting data period in ISO 8601 format. - Until time.Time `json:"until,required" format:"date-time"` - // Segmentation filter in 'attribute operator value' format. - Filters string `json:"filters"` - // Array of dimensions to sort by, where each dimension may be prefixed by - - // (descending) or + (ascending). - Sort []string `json:"sort"` - JSON dnsAnalyticsReportBytimeGetResponseQueryJSON `json:"-"` -} - -// dnsAnalyticsReportBytimeGetResponseQueryJSON contains the JSON metadata for the -// struct [DNSAnalyticsReportBytimeGetResponseQuery] -type dnsAnalyticsReportBytimeGetResponseQueryJSON struct { - Dimensions apijson.Field - Limit apijson.Field - Metrics apijson.Field - Since apijson.Field - TimeDelta apijson.Field - Until apijson.Field - Filters apijson.Field - Sort apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSAnalyticsReportBytimeGetResponseQuery) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsAnalyticsReportBytimeGetResponseQueryJSON) RawJSON() string { - return r.raw -} - -// Unit of time to group data by. -type DNSAnalyticsReportBytimeGetResponseQueryTimeDelta string - -const ( - DNSAnalyticsReportBytimeGetResponseQueryTimeDeltaAll DNSAnalyticsReportBytimeGetResponseQueryTimeDelta = "all" - DNSAnalyticsReportBytimeGetResponseQueryTimeDeltaAuto DNSAnalyticsReportBytimeGetResponseQueryTimeDelta = "auto" - DNSAnalyticsReportBytimeGetResponseQueryTimeDeltaYear DNSAnalyticsReportBytimeGetResponseQueryTimeDelta = "year" - DNSAnalyticsReportBytimeGetResponseQueryTimeDeltaQuarter DNSAnalyticsReportBytimeGetResponseQueryTimeDelta = "quarter" - DNSAnalyticsReportBytimeGetResponseQueryTimeDeltaMonth DNSAnalyticsReportBytimeGetResponseQueryTimeDelta = "month" - DNSAnalyticsReportBytimeGetResponseQueryTimeDeltaWeek DNSAnalyticsReportBytimeGetResponseQueryTimeDelta = "week" - DNSAnalyticsReportBytimeGetResponseQueryTimeDeltaDay DNSAnalyticsReportBytimeGetResponseQueryTimeDelta = "day" - DNSAnalyticsReportBytimeGetResponseQueryTimeDeltaHour DNSAnalyticsReportBytimeGetResponseQueryTimeDelta = "hour" - DNSAnalyticsReportBytimeGetResponseQueryTimeDeltaDekaminute DNSAnalyticsReportBytimeGetResponseQueryTimeDelta = "dekaminute" - DNSAnalyticsReportBytimeGetResponseQueryTimeDeltaMinute DNSAnalyticsReportBytimeGetResponseQueryTimeDelta = "minute" -) - -type DNSAnalyticsReportBytimeGetParams struct { - // A comma-separated list of dimensions to group results by. - Dimensions param.Field[string] `query:"dimensions"` - // Segmentation filter in 'attribute operator value' format. - Filters param.Field[string] `query:"filters"` - // Limit number of returned metrics. - Limit param.Field[int64] `query:"limit"` - // A comma-separated list of metrics to query. - Metrics param.Field[string] `query:"metrics"` - // Start date and time of requesting data period in ISO 8601 format. - Since param.Field[time.Time] `query:"since" format:"date-time"` - // A comma-separated list of dimensions to sort by, where each dimension may be - // prefixed by - (descending) or + (ascending). - Sort param.Field[string] `query:"sort"` - // Unit of time to group data by. - TimeDelta param.Field[DNSAnalyticsReportBytimeGetParamsTimeDelta] `query:"time_delta"` - // End date and time of requesting data period in ISO 8601 format. - Until param.Field[time.Time] `query:"until" format:"date-time"` -} - -// URLQuery serializes [DNSAnalyticsReportBytimeGetParams]'s query parameters as -// `url.Values`. -func (r DNSAnalyticsReportBytimeGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Unit of time to group data by. -type DNSAnalyticsReportBytimeGetParamsTimeDelta string - -const ( - DNSAnalyticsReportBytimeGetParamsTimeDeltaAll DNSAnalyticsReportBytimeGetParamsTimeDelta = "all" - DNSAnalyticsReportBytimeGetParamsTimeDeltaAuto DNSAnalyticsReportBytimeGetParamsTimeDelta = "auto" - DNSAnalyticsReportBytimeGetParamsTimeDeltaYear DNSAnalyticsReportBytimeGetParamsTimeDelta = "year" - DNSAnalyticsReportBytimeGetParamsTimeDeltaQuarter DNSAnalyticsReportBytimeGetParamsTimeDelta = "quarter" - DNSAnalyticsReportBytimeGetParamsTimeDeltaMonth DNSAnalyticsReportBytimeGetParamsTimeDelta = "month" - DNSAnalyticsReportBytimeGetParamsTimeDeltaWeek DNSAnalyticsReportBytimeGetParamsTimeDelta = "week" - DNSAnalyticsReportBytimeGetParamsTimeDeltaDay DNSAnalyticsReportBytimeGetParamsTimeDelta = "day" - DNSAnalyticsReportBytimeGetParamsTimeDeltaHour DNSAnalyticsReportBytimeGetParamsTimeDelta = "hour" - DNSAnalyticsReportBytimeGetParamsTimeDeltaDekaminute DNSAnalyticsReportBytimeGetParamsTimeDelta = "dekaminute" - DNSAnalyticsReportBytimeGetParamsTimeDeltaMinute DNSAnalyticsReportBytimeGetParamsTimeDelta = "minute" -) - -type DNSAnalyticsReportBytimeGetResponseEnvelope struct { - Errors []DNSAnalyticsReportBytimeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSAnalyticsReportBytimeGetResponseEnvelopeMessages `json:"messages,required"` - Result DNSAnalyticsReportBytimeGetResponse `json:"result,required"` - // Whether the API call was successful - Success DNSAnalyticsReportBytimeGetResponseEnvelopeSuccess `json:"success,required"` - JSON dnsAnalyticsReportBytimeGetResponseEnvelopeJSON `json:"-"` -} - -// dnsAnalyticsReportBytimeGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [DNSAnalyticsReportBytimeGetResponseEnvelope] -type dnsAnalyticsReportBytimeGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSAnalyticsReportBytimeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsAnalyticsReportBytimeGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DNSAnalyticsReportBytimeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsAnalyticsReportBytimeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnsAnalyticsReportBytimeGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [DNSAnalyticsReportBytimeGetResponseEnvelopeErrors] -type dnsAnalyticsReportBytimeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSAnalyticsReportBytimeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsAnalyticsReportBytimeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSAnalyticsReportBytimeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsAnalyticsReportBytimeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnsAnalyticsReportBytimeGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [DNSAnalyticsReportBytimeGetResponseEnvelopeMessages] -type dnsAnalyticsReportBytimeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSAnalyticsReportBytimeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsAnalyticsReportBytimeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DNSAnalyticsReportBytimeGetResponseEnvelopeSuccess bool - -const ( - DNSAnalyticsReportBytimeGetResponseEnvelopeSuccessTrue DNSAnalyticsReportBytimeGetResponseEnvelopeSuccess = true -) diff --git a/dnsanalyticsreportbytime_test.go b/dnsanalyticsreportbytime_test.go deleted file mode 100644 index c55b1dcbc88..00000000000 --- a/dnsanalyticsreportbytime_test.go +++ /dev/null @@ -1,52 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestDNSAnalyticsReportBytimeGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.DNS.Analytics.Reports.Bytimes.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.DNSAnalyticsReportBytimeGetParams{ - Dimensions: cloudflare.F("queryType"), - Filters: cloudflare.F("responseCode==NOERROR,queryType==A"), - Limit: cloudflare.F(int64(100)), - Metrics: cloudflare.F("queryCount,uncachedCount"), - Since: cloudflare.F(time.Now()), - Sort: cloudflare.F("+responseCode,-queryName"), - TimeDelta: cloudflare.F(cloudflare.DNSAnalyticsReportBytimeGetParamsTimeDeltaHour), - Until: cloudflare.F(time.Now()), - }, - ) - 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/dnsfirewall.go b/dnsfirewall.go deleted file mode 100644 index 2e456b38749..00000000000 --- a/dnsfirewall.go +++ /dev/null @@ -1,1144 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// DNSFirewallService 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 [NewDNSFirewallService] method -// instead. -type DNSFirewallService struct { - Options []option.RequestOption - Analytics *DNSFirewallAnalyticsService -} - -// NewDNSFirewallService 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 NewDNSFirewallService(opts ...option.RequestOption) (r *DNSFirewallService) { - r = &DNSFirewallService{} - r.Options = opts - r.Analytics = NewDNSFirewallAnalyticsService(opts...) - return -} - -// Create a configured DNS Firewall Cluster. -func (r *DNSFirewallService) New(ctx context.Context, params DNSFirewallNewParams, opts ...option.RequestOption) (res *DNSFirewallNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env DNSFirewallNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/dns_firewall", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List configured DNS Firewall clusters for an account. -func (r *DNSFirewallService) List(ctx context.Context, params DNSFirewallListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[DNSFirewallListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("accounts/%s/dns_firewall", params.AccountID) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// List configured DNS Firewall clusters for an account. -func (r *DNSFirewallService) ListAutoPaging(ctx context.Context, params DNSFirewallListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[DNSFirewallListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) -} - -// Delete a configured DNS Firewall Cluster. -func (r *DNSFirewallService) Delete(ctx context.Context, dnsFirewallID string, body DNSFirewallDeleteParams, opts ...option.RequestOption) (res *DNSFirewallDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env DNSFirewallDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/dns_firewall/%s", body.AccountID, dnsFirewallID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Modify a DNS Firewall Cluster configuration. -func (r *DNSFirewallService) Edit(ctx context.Context, dnsFirewallID string, params DNSFirewallEditParams, opts ...option.RequestOption) (res *DNSFirewallEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env DNSFirewallEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/dns_firewall/%s", params.AccountID, dnsFirewallID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Show a single configured DNS Firewall cluster for an account. -func (r *DNSFirewallService) Get(ctx context.Context, dnsFirewallID string, query DNSFirewallGetParams, opts ...option.RequestOption) (res *DNSFirewallGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env DNSFirewallGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/dns_firewall/%s", query.AccountID, dnsFirewallID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type DNSFirewallNewResponse struct { - // Identifier - ID string `json:"id,required"` - // Deprecate the response to ANY requests. - DeprecateAnyRequests bool `json:"deprecate_any_requests,required"` - DNSFirewallIPs []DNSFirewallNewResponseDNSFirewallIP `json:"dns_firewall_ips,required" format:"ipv4"` - // Forward client IP (resolver) subnet if no EDNS Client Subnet is sent. - EcsFallback bool `json:"ecs_fallback,required"` - // Maximum DNS Cache TTL. - MaximumCacheTTL float64 `json:"maximum_cache_ttl,required"` - // Minimum DNS Cache TTL. - MinimumCacheTTL float64 `json:"minimum_cache_ttl,required"` - // Last modification of DNS Firewall cluster. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // DNS Firewall Cluster Name. - Name string `json:"name,required"` - UpstreamIPs []DNSFirewallNewResponseUpstreamIP `json:"upstream_ips,required" format:"ipv4"` - // Attack mitigation settings. - AttackMitigation DNSFirewallNewResponseAttackMitigation `json:"attack_mitigation,nullable"` - // Negative DNS Cache TTL. - NegativeCacheTTL float64 `json:"negative_cache_ttl,nullable"` - // Deprecated alias for "upstream_ips". - OriginIPs interface{} `json:"origin_ips"` - // Ratelimit in queries per second per datacenter (applies to DNS queries sent to - // the upstream nameservers configured on the cluster). - Ratelimit float64 `json:"ratelimit,nullable"` - // Number of retries for fetching DNS responses from upstream nameservers (not - // counting the initial attempt). - Retries float64 `json:"retries"` - JSON dnsFirewallNewResponseJSON `json:"-"` -} - -// dnsFirewallNewResponseJSON contains the JSON metadata for the struct -// [DNSFirewallNewResponse] -type dnsFirewallNewResponseJSON struct { - ID apijson.Field - DeprecateAnyRequests apijson.Field - DNSFirewallIPs apijson.Field - EcsFallback apijson.Field - MaximumCacheTTL apijson.Field - MinimumCacheTTL apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - UpstreamIPs apijson.Field - AttackMitigation apijson.Field - NegativeCacheTTL apijson.Field - OriginIPs apijson.Field - Ratelimit apijson.Field - Retries apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallNewResponseJSON) RawJSON() string { - return r.raw -} - -// Cloudflare-assigned DNS IPv4 Address. -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type DNSFirewallNewResponseDNSFirewallIP interface { - ImplementsDNSFirewallNewResponseDNSFirewallIP() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSFirewallNewResponseDNSFirewallIP)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Upstream DNS Server IPv4 Address. -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type DNSFirewallNewResponseUpstreamIP interface { - ImplementsDNSFirewallNewResponseUpstreamIP() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSFirewallNewResponseUpstreamIP)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Attack mitigation settings. -type DNSFirewallNewResponseAttackMitigation struct { - // When enabled, random-prefix attacks are automatically mitigated and the upstream - // DNS servers protected. - Enabled bool `json:"enabled"` - // Deprecated alias for "only_when_upstream_unhealthy". - OnlyWhenOriginUnhealthy interface{} `json:"only_when_origin_unhealthy"` - // Only mitigate attacks when upstream servers seem unhealthy. - OnlyWhenUpstreamUnhealthy bool `json:"only_when_upstream_unhealthy"` - JSON dnsFirewallNewResponseAttackMitigationJSON `json:"-"` -} - -// dnsFirewallNewResponseAttackMitigationJSON contains the JSON metadata for the -// struct [DNSFirewallNewResponseAttackMitigation] -type dnsFirewallNewResponseAttackMitigationJSON struct { - Enabled apijson.Field - OnlyWhenOriginUnhealthy apijson.Field - OnlyWhenUpstreamUnhealthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallNewResponseAttackMitigation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallNewResponseAttackMitigationJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallListResponse struct { - // Identifier - ID string `json:"id,required"` - // Deprecate the response to ANY requests. - DeprecateAnyRequests bool `json:"deprecate_any_requests,required"` - DNSFirewallIPs []DNSFirewallListResponseDNSFirewallIP `json:"dns_firewall_ips,required" format:"ipv4"` - // Forward client IP (resolver) subnet if no EDNS Client Subnet is sent. - EcsFallback bool `json:"ecs_fallback,required"` - // Maximum DNS Cache TTL. - MaximumCacheTTL float64 `json:"maximum_cache_ttl,required"` - // Minimum DNS Cache TTL. - MinimumCacheTTL float64 `json:"minimum_cache_ttl,required"` - // Last modification of DNS Firewall cluster. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // DNS Firewall Cluster Name. - Name string `json:"name,required"` - UpstreamIPs []DNSFirewallListResponseUpstreamIP `json:"upstream_ips,required" format:"ipv4"` - // Attack mitigation settings. - AttackMitigation DNSFirewallListResponseAttackMitigation `json:"attack_mitigation,nullable"` - // Negative DNS Cache TTL. - NegativeCacheTTL float64 `json:"negative_cache_ttl,nullable"` - // Deprecated alias for "upstream_ips". - OriginIPs interface{} `json:"origin_ips"` - // Ratelimit in queries per second per datacenter (applies to DNS queries sent to - // the upstream nameservers configured on the cluster). - Ratelimit float64 `json:"ratelimit,nullable"` - // Number of retries for fetching DNS responses from upstream nameservers (not - // counting the initial attempt). - Retries float64 `json:"retries"` - JSON dnsFirewallListResponseJSON `json:"-"` -} - -// dnsFirewallListResponseJSON contains the JSON metadata for the struct -// [DNSFirewallListResponse] -type dnsFirewallListResponseJSON struct { - ID apijson.Field - DeprecateAnyRequests apijson.Field - DNSFirewallIPs apijson.Field - EcsFallback apijson.Field - MaximumCacheTTL apijson.Field - MinimumCacheTTL apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - UpstreamIPs apijson.Field - AttackMitigation apijson.Field - NegativeCacheTTL apijson.Field - OriginIPs apijson.Field - Ratelimit apijson.Field - Retries apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallListResponseJSON) RawJSON() string { - return r.raw -} - -// Cloudflare-assigned DNS IPv4 Address. -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type DNSFirewallListResponseDNSFirewallIP interface { - ImplementsDNSFirewallListResponseDNSFirewallIP() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSFirewallListResponseDNSFirewallIP)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Upstream DNS Server IPv4 Address. -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type DNSFirewallListResponseUpstreamIP interface { - ImplementsDNSFirewallListResponseUpstreamIP() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSFirewallListResponseUpstreamIP)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Attack mitigation settings. -type DNSFirewallListResponseAttackMitigation struct { - // When enabled, random-prefix attacks are automatically mitigated and the upstream - // DNS servers protected. - Enabled bool `json:"enabled"` - // Deprecated alias for "only_when_upstream_unhealthy". - OnlyWhenOriginUnhealthy interface{} `json:"only_when_origin_unhealthy"` - // Only mitigate attacks when upstream servers seem unhealthy. - OnlyWhenUpstreamUnhealthy bool `json:"only_when_upstream_unhealthy"` - JSON dnsFirewallListResponseAttackMitigationJSON `json:"-"` -} - -// dnsFirewallListResponseAttackMitigationJSON contains the JSON metadata for the -// struct [DNSFirewallListResponseAttackMitigation] -type dnsFirewallListResponseAttackMitigationJSON struct { - Enabled apijson.Field - OnlyWhenOriginUnhealthy apijson.Field - OnlyWhenUpstreamUnhealthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallListResponseAttackMitigation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallListResponseAttackMitigationJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallDeleteResponse struct { - // Identifier - ID string `json:"id"` - JSON dnsFirewallDeleteResponseJSON `json:"-"` -} - -// dnsFirewallDeleteResponseJSON contains the JSON metadata for the struct -// [DNSFirewallDeleteResponse] -type dnsFirewallDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallEditResponse struct { - // Identifier - ID string `json:"id,required"` - // Deprecate the response to ANY requests. - DeprecateAnyRequests bool `json:"deprecate_any_requests,required"` - DNSFirewallIPs []DNSFirewallEditResponseDNSFirewallIP `json:"dns_firewall_ips,required" format:"ipv4"` - // Forward client IP (resolver) subnet if no EDNS Client Subnet is sent. - EcsFallback bool `json:"ecs_fallback,required"` - // Maximum DNS Cache TTL. - MaximumCacheTTL float64 `json:"maximum_cache_ttl,required"` - // Minimum DNS Cache TTL. - MinimumCacheTTL float64 `json:"minimum_cache_ttl,required"` - // Last modification of DNS Firewall cluster. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // DNS Firewall Cluster Name. - Name string `json:"name,required"` - UpstreamIPs []DNSFirewallEditResponseUpstreamIP `json:"upstream_ips,required" format:"ipv4"` - // Attack mitigation settings. - AttackMitigation DNSFirewallEditResponseAttackMitigation `json:"attack_mitigation,nullable"` - // Negative DNS Cache TTL. - NegativeCacheTTL float64 `json:"negative_cache_ttl,nullable"` - // Deprecated alias for "upstream_ips". - OriginIPs interface{} `json:"origin_ips"` - // Ratelimit in queries per second per datacenter (applies to DNS queries sent to - // the upstream nameservers configured on the cluster). - Ratelimit float64 `json:"ratelimit,nullable"` - // Number of retries for fetching DNS responses from upstream nameservers (not - // counting the initial attempt). - Retries float64 `json:"retries"` - JSON dnsFirewallEditResponseJSON `json:"-"` -} - -// dnsFirewallEditResponseJSON contains the JSON metadata for the struct -// [DNSFirewallEditResponse] -type dnsFirewallEditResponseJSON struct { - ID apijson.Field - DeprecateAnyRequests apijson.Field - DNSFirewallIPs apijson.Field - EcsFallback apijson.Field - MaximumCacheTTL apijson.Field - MinimumCacheTTL apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - UpstreamIPs apijson.Field - AttackMitigation apijson.Field - NegativeCacheTTL apijson.Field - OriginIPs apijson.Field - Ratelimit apijson.Field - Retries apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallEditResponseJSON) RawJSON() string { - return r.raw -} - -// Cloudflare-assigned DNS IPv4 Address. -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type DNSFirewallEditResponseDNSFirewallIP interface { - ImplementsDNSFirewallEditResponseDNSFirewallIP() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSFirewallEditResponseDNSFirewallIP)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Upstream DNS Server IPv4 Address. -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type DNSFirewallEditResponseUpstreamIP interface { - ImplementsDNSFirewallEditResponseUpstreamIP() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSFirewallEditResponseUpstreamIP)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Attack mitigation settings. -type DNSFirewallEditResponseAttackMitigation struct { - // When enabled, random-prefix attacks are automatically mitigated and the upstream - // DNS servers protected. - Enabled bool `json:"enabled"` - // Deprecated alias for "only_when_upstream_unhealthy". - OnlyWhenOriginUnhealthy interface{} `json:"only_when_origin_unhealthy"` - // Only mitigate attacks when upstream servers seem unhealthy. - OnlyWhenUpstreamUnhealthy bool `json:"only_when_upstream_unhealthy"` - JSON dnsFirewallEditResponseAttackMitigationJSON `json:"-"` -} - -// dnsFirewallEditResponseAttackMitigationJSON contains the JSON metadata for the -// struct [DNSFirewallEditResponseAttackMitigation] -type dnsFirewallEditResponseAttackMitigationJSON struct { - Enabled apijson.Field - OnlyWhenOriginUnhealthy apijson.Field - OnlyWhenUpstreamUnhealthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallEditResponseAttackMitigation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallEditResponseAttackMitigationJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallGetResponse struct { - // Identifier - ID string `json:"id,required"` - // Deprecate the response to ANY requests. - DeprecateAnyRequests bool `json:"deprecate_any_requests,required"` - DNSFirewallIPs []DNSFirewallGetResponseDNSFirewallIP `json:"dns_firewall_ips,required" format:"ipv4"` - // Forward client IP (resolver) subnet if no EDNS Client Subnet is sent. - EcsFallback bool `json:"ecs_fallback,required"` - // Maximum DNS Cache TTL. - MaximumCacheTTL float64 `json:"maximum_cache_ttl,required"` - // Minimum DNS Cache TTL. - MinimumCacheTTL float64 `json:"minimum_cache_ttl,required"` - // Last modification of DNS Firewall cluster. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // DNS Firewall Cluster Name. - Name string `json:"name,required"` - UpstreamIPs []DNSFirewallGetResponseUpstreamIP `json:"upstream_ips,required" format:"ipv4"` - // Attack mitigation settings. - AttackMitigation DNSFirewallGetResponseAttackMitigation `json:"attack_mitigation,nullable"` - // Negative DNS Cache TTL. - NegativeCacheTTL float64 `json:"negative_cache_ttl,nullable"` - // Deprecated alias for "upstream_ips". - OriginIPs interface{} `json:"origin_ips"` - // Ratelimit in queries per second per datacenter (applies to DNS queries sent to - // the upstream nameservers configured on the cluster). - Ratelimit float64 `json:"ratelimit,nullable"` - // Number of retries for fetching DNS responses from upstream nameservers (not - // counting the initial attempt). - Retries float64 `json:"retries"` - JSON dnsFirewallGetResponseJSON `json:"-"` -} - -// dnsFirewallGetResponseJSON contains the JSON metadata for the struct -// [DNSFirewallGetResponse] -type dnsFirewallGetResponseJSON struct { - ID apijson.Field - DeprecateAnyRequests apijson.Field - DNSFirewallIPs apijson.Field - EcsFallback apijson.Field - MaximumCacheTTL apijson.Field - MinimumCacheTTL apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - UpstreamIPs apijson.Field - AttackMitigation apijson.Field - NegativeCacheTTL apijson.Field - OriginIPs apijson.Field - Ratelimit apijson.Field - Retries apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallGetResponseJSON) RawJSON() string { - return r.raw -} - -// Cloudflare-assigned DNS IPv4 Address. -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type DNSFirewallGetResponseDNSFirewallIP interface { - ImplementsDNSFirewallGetResponseDNSFirewallIP() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSFirewallGetResponseDNSFirewallIP)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Upstream DNS Server IPv4 Address. -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type DNSFirewallGetResponseUpstreamIP interface { - ImplementsDNSFirewallGetResponseUpstreamIP() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSFirewallGetResponseUpstreamIP)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Attack mitigation settings. -type DNSFirewallGetResponseAttackMitigation struct { - // When enabled, random-prefix attacks are automatically mitigated and the upstream - // DNS servers protected. - Enabled bool `json:"enabled"` - // Deprecated alias for "only_when_upstream_unhealthy". - OnlyWhenOriginUnhealthy interface{} `json:"only_when_origin_unhealthy"` - // Only mitigate attacks when upstream servers seem unhealthy. - OnlyWhenUpstreamUnhealthy bool `json:"only_when_upstream_unhealthy"` - JSON dnsFirewallGetResponseAttackMitigationJSON `json:"-"` -} - -// dnsFirewallGetResponseAttackMitigationJSON contains the JSON metadata for the -// struct [DNSFirewallGetResponseAttackMitigation] -type dnsFirewallGetResponseAttackMitigationJSON struct { - Enabled apijson.Field - OnlyWhenOriginUnhealthy apijson.Field - OnlyWhenUpstreamUnhealthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallGetResponseAttackMitigation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallGetResponseAttackMitigationJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // DNS Firewall Cluster Name. - Name param.Field[string] `json:"name,required"` - UpstreamIPs param.Field[[]DNSFirewallNewParamsUpstreamIP] `json:"upstream_ips,required" format:"ipv4"` - // Attack mitigation settings. - AttackMitigation param.Field[DNSFirewallNewParamsAttackMitigation] `json:"attack_mitigation"` - // Deprecate the response to ANY requests. - DeprecateAnyRequests param.Field[bool] `json:"deprecate_any_requests"` - // Forward client IP (resolver) subnet if no EDNS Client Subnet is sent. - EcsFallback param.Field[bool] `json:"ecs_fallback"` - // Maximum DNS Cache TTL. - MaximumCacheTTL param.Field[float64] `json:"maximum_cache_ttl"` - // Minimum DNS Cache TTL. - MinimumCacheTTL param.Field[float64] `json:"minimum_cache_ttl"` - // Negative DNS Cache TTL. - NegativeCacheTTL param.Field[float64] `json:"negative_cache_ttl"` - // Deprecated alias for "upstream_ips". - OriginIPs param.Field[interface{}] `json:"origin_ips"` - // Ratelimit in queries per second per datacenter (applies to DNS queries sent to - // the upstream nameservers configured on the cluster). - Ratelimit param.Field[float64] `json:"ratelimit"` - // Number of retries for fetching DNS responses from upstream nameservers (not - // counting the initial attempt). - Retries param.Field[float64] `json:"retries"` -} - -func (r DNSFirewallNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Upstream DNS Server IPv4 Address. -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type DNSFirewallNewParamsUpstreamIP interface { - ImplementsDNSFirewallNewParamsUpstreamIP() -} - -// Attack mitigation settings. -type DNSFirewallNewParamsAttackMitigation struct { - // When enabled, random-prefix attacks are automatically mitigated and the upstream - // DNS servers protected. - Enabled param.Field[bool] `json:"enabled"` - // Deprecated alias for "only_when_upstream_unhealthy". - OnlyWhenOriginUnhealthy param.Field[interface{}] `json:"only_when_origin_unhealthy"` - // Only mitigate attacks when upstream servers seem unhealthy. - OnlyWhenUpstreamUnhealthy param.Field[bool] `json:"only_when_upstream_unhealthy"` -} - -func (r DNSFirewallNewParamsAttackMitigation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type DNSFirewallNewResponseEnvelope struct { - Errors []DNSFirewallNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSFirewallNewResponseEnvelopeMessages `json:"messages,required"` - Result DNSFirewallNewResponse `json:"result,required"` - // Whether the API call was successful - Success DNSFirewallNewResponseEnvelopeSuccess `json:"success,required"` - JSON dnsFirewallNewResponseEnvelopeJSON `json:"-"` -} - -// dnsFirewallNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [DNSFirewallNewResponseEnvelope] -type dnsFirewallNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsFirewallNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnsFirewallNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DNSFirewallNewResponseEnvelopeErrors] -type dnsFirewallNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsFirewallNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnsFirewallNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DNSFirewallNewResponseEnvelopeMessages] -type dnsFirewallNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DNSFirewallNewResponseEnvelopeSuccess bool - -const ( - DNSFirewallNewResponseEnvelopeSuccessTrue DNSFirewallNewResponseEnvelopeSuccess = true -) - -type DNSFirewallListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // Number of clusters per page. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [DNSFirewallListParams]'s query parameters as `url.Values`. -func (r DNSFirewallListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type DNSFirewallDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type DNSFirewallDeleteResponseEnvelope struct { - Errors []DNSFirewallDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSFirewallDeleteResponseEnvelopeMessages `json:"messages,required"` - Result DNSFirewallDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success DNSFirewallDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON dnsFirewallDeleteResponseEnvelopeJSON `json:"-"` -} - -// dnsFirewallDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [DNSFirewallDeleteResponseEnvelope] -type dnsFirewallDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsFirewallDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnsFirewallDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DNSFirewallDeleteResponseEnvelopeErrors] -type dnsFirewallDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsFirewallDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnsFirewallDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DNSFirewallDeleteResponseEnvelopeMessages] -type dnsFirewallDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DNSFirewallDeleteResponseEnvelopeSuccess bool - -const ( - DNSFirewallDeleteResponseEnvelopeSuccessTrue DNSFirewallDeleteResponseEnvelopeSuccess = true -) - -type DNSFirewallEditParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Deprecate the response to ANY requests. - DeprecateAnyRequests param.Field[bool] `json:"deprecate_any_requests,required"` - DNSFirewallIPs param.Field[[]DNSFirewallEditParamsDNSFirewallIP] `json:"dns_firewall_ips,required" format:"ipv4"` - // Forward client IP (resolver) subnet if no EDNS Client Subnet is sent. - EcsFallback param.Field[bool] `json:"ecs_fallback,required"` - // Maximum DNS Cache TTL. - MaximumCacheTTL param.Field[float64] `json:"maximum_cache_ttl,required"` - // Minimum DNS Cache TTL. - MinimumCacheTTL param.Field[float64] `json:"minimum_cache_ttl,required"` - // DNS Firewall Cluster Name. - Name param.Field[string] `json:"name,required"` - UpstreamIPs param.Field[[]DNSFirewallEditParamsUpstreamIP] `json:"upstream_ips,required" format:"ipv4"` - // Attack mitigation settings. - AttackMitigation param.Field[DNSFirewallEditParamsAttackMitigation] `json:"attack_mitigation"` - // Negative DNS Cache TTL. - NegativeCacheTTL param.Field[float64] `json:"negative_cache_ttl"` - // Deprecated alias for "upstream_ips". - OriginIPs param.Field[interface{}] `json:"origin_ips"` - // Ratelimit in queries per second per datacenter (applies to DNS queries sent to - // the upstream nameservers configured on the cluster). - Ratelimit param.Field[float64] `json:"ratelimit"` - // Number of retries for fetching DNS responses from upstream nameservers (not - // counting the initial attempt). - Retries param.Field[float64] `json:"retries"` -} - -func (r DNSFirewallEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Cloudflare-assigned DNS IPv4 Address. -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type DNSFirewallEditParamsDNSFirewallIP interface { - ImplementsDNSFirewallEditParamsDNSFirewallIP() -} - -// Upstream DNS Server IPv4 Address. -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type DNSFirewallEditParamsUpstreamIP interface { - ImplementsDNSFirewallEditParamsUpstreamIP() -} - -// Attack mitigation settings. -type DNSFirewallEditParamsAttackMitigation struct { - // When enabled, random-prefix attacks are automatically mitigated and the upstream - // DNS servers protected. - Enabled param.Field[bool] `json:"enabled"` - // Deprecated alias for "only_when_upstream_unhealthy". - OnlyWhenOriginUnhealthy param.Field[interface{}] `json:"only_when_origin_unhealthy"` - // Only mitigate attacks when upstream servers seem unhealthy. - OnlyWhenUpstreamUnhealthy param.Field[bool] `json:"only_when_upstream_unhealthy"` -} - -func (r DNSFirewallEditParamsAttackMitigation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type DNSFirewallEditResponseEnvelope struct { - Errors []DNSFirewallEditResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSFirewallEditResponseEnvelopeMessages `json:"messages,required"` - Result DNSFirewallEditResponse `json:"result,required"` - // Whether the API call was successful - Success DNSFirewallEditResponseEnvelopeSuccess `json:"success,required"` - JSON dnsFirewallEditResponseEnvelopeJSON `json:"-"` -} - -// dnsFirewallEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [DNSFirewallEditResponseEnvelope] -type dnsFirewallEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsFirewallEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnsFirewallEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DNSFirewallEditResponseEnvelopeErrors] -type dnsFirewallEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsFirewallEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnsFirewallEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DNSFirewallEditResponseEnvelopeMessages] -type dnsFirewallEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DNSFirewallEditResponseEnvelopeSuccess bool - -const ( - DNSFirewallEditResponseEnvelopeSuccessTrue DNSFirewallEditResponseEnvelopeSuccess = true -) - -type DNSFirewallGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type DNSFirewallGetResponseEnvelope struct { - Errors []DNSFirewallGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSFirewallGetResponseEnvelopeMessages `json:"messages,required"` - Result DNSFirewallGetResponse `json:"result,required"` - // Whether the API call was successful - Success DNSFirewallGetResponseEnvelopeSuccess `json:"success,required"` - JSON dnsFirewallGetResponseEnvelopeJSON `json:"-"` -} - -// dnsFirewallGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [DNSFirewallGetResponseEnvelope] -type dnsFirewallGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsFirewallGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnsFirewallGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DNSFirewallGetResponseEnvelopeErrors] -type dnsFirewallGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsFirewallGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnsFirewallGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DNSFirewallGetResponseEnvelopeMessages] -type dnsFirewallGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DNSFirewallGetResponseEnvelopeSuccess bool - -const ( - DNSFirewallGetResponseEnvelopeSuccessTrue DNSFirewallGetResponseEnvelopeSuccess = true -) diff --git a/dnsfirewall_test.go b/dnsfirewall_test.go deleted file mode 100644 index 8ec9b533b21..00000000000 --- a/dnsfirewall_test.go +++ /dev/null @@ -1,190 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestDNSFirewallNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.DNS.Firewall.New(context.TODO(), cloudflare.DNSFirewallNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Name: cloudflare.F("My Awesome DNS Firewall cluster"), - UpstreamIPs: cloudflare.F([]cloudflare.DNSFirewallNewParamsUpstreamIP{shared.UnionString("192.0.2.1"), shared.UnionString("198.51.100.1"), shared.UnionString("2001:DB8:100::CF")}), - AttackMitigation: cloudflare.F(cloudflare.DNSFirewallNewParamsAttackMitigation{ - Enabled: cloudflare.F(true), - OnlyWhenOriginUnhealthy: cloudflare.F[any](map[string]interface{}{}), - OnlyWhenUpstreamUnhealthy: cloudflare.F(false), - }), - DeprecateAnyRequests: cloudflare.F(true), - EcsFallback: cloudflare.F(false), - MaximumCacheTTL: cloudflare.F(900.000000), - MinimumCacheTTL: cloudflare.F(60.000000), - NegativeCacheTTL: cloudflare.F(900.000000), - OriginIPs: cloudflare.F[any](map[string]interface{}{}), - Ratelimit: cloudflare.F(600.000000), - Retries: cloudflare.F(2.000000), - }) - 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 TestDNSFirewallListWithOptionalParams(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("user@example.com"), - ) - _, err := client.DNS.Firewall.List(context.TODO(), cloudflare.DNSFirewallListParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(1.000000), - }) - 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 TestDNSFirewallDelete(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("user@example.com"), - ) - _, err := client.DNS.Firewall.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.DNSFirewallDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestDNSFirewallEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.DNS.Firewall.Edit( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.DNSFirewallEditParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - DeprecateAnyRequests: cloudflare.F(true), - DNSFirewallIPs: cloudflare.F([]cloudflare.DNSFirewallEditParamsDNSFirewallIP{shared.UnionString("203.0.113.1"), shared.UnionString("203.0.113.254"), shared.UnionString("2001:DB8:AB::CF"), shared.UnionString("2001:DB8:CD::CF")}), - EcsFallback: cloudflare.F(false), - MaximumCacheTTL: cloudflare.F(900.000000), - MinimumCacheTTL: cloudflare.F(60.000000), - Name: cloudflare.F("My Awesome DNS Firewall cluster"), - UpstreamIPs: cloudflare.F([]cloudflare.DNSFirewallEditParamsUpstreamIP{shared.UnionString("192.0.2.1"), shared.UnionString("198.51.100.1"), shared.UnionString("2001:DB8:100::CF")}), - AttackMitigation: cloudflare.F(cloudflare.DNSFirewallEditParamsAttackMitigation{ - Enabled: cloudflare.F(true), - OnlyWhenOriginUnhealthy: cloudflare.F[any](map[string]interface{}{}), - OnlyWhenUpstreamUnhealthy: cloudflare.F(false), - }), - NegativeCacheTTL: cloudflare.F(900.000000), - OriginIPs: cloudflare.F[any](map[string]interface{}{}), - Ratelimit: cloudflare.F(600.000000), - Retries: cloudflare.F(2.000000), - }, - ) - 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 TestDNSFirewallGet(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("user@example.com"), - ) - _, err := client.DNS.Firewall.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.DNSFirewallGetParams{ - AccountID: cloudflare.F("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/dnsfirewallanalytics.go b/dnsfirewallanalytics.go deleted file mode 100644 index 3ce0971e510..00000000000 --- a/dnsfirewallanalytics.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// DNSFirewallAnalyticsService 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 [NewDNSFirewallAnalyticsService] -// method instead. -type DNSFirewallAnalyticsService struct { - Options []option.RequestOption - Reports *DNSFirewallAnalyticsReportService -} - -// NewDNSFirewallAnalyticsService 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 NewDNSFirewallAnalyticsService(opts ...option.RequestOption) (r *DNSFirewallAnalyticsService) { - r = &DNSFirewallAnalyticsService{} - r.Options = opts - r.Reports = NewDNSFirewallAnalyticsReportService(opts...) - return -} diff --git a/dnsfirewallanalyticsreport.go b/dnsfirewallanalyticsreport.go deleted file mode 100644 index d613da0a847..00000000000 --- a/dnsfirewallanalyticsreport.go +++ /dev/null @@ -1,272 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// DNSFirewallAnalyticsReportService 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 -// [NewDNSFirewallAnalyticsReportService] method instead. -type DNSFirewallAnalyticsReportService struct { - Options []option.RequestOption - Bytimes *DNSFirewallAnalyticsReportBytimeService -} - -// NewDNSFirewallAnalyticsReportService 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 NewDNSFirewallAnalyticsReportService(opts ...option.RequestOption) (r *DNSFirewallAnalyticsReportService) { - r = &DNSFirewallAnalyticsReportService{} - r.Options = opts - r.Bytimes = NewDNSFirewallAnalyticsReportBytimeService(opts...) - return -} - -// Retrieves a list of summarised aggregate metrics over a given time period. -// -// See -// [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) -// for detailed information about the available query parameters. -func (r *DNSFirewallAnalyticsReportService) Get(ctx context.Context, accountIdentifier string, identifier string, query DNSFirewallAnalyticsReportGetParams, opts ...option.RequestOption) (res *DNSFirewallAnalyticsReportGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env DNSFirewallAnalyticsReportGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/dns_firewall/%s/dns_analytics/report", accountIdentifier, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type DNSFirewallAnalyticsReportGetResponse struct { - // Array with one row per combination of dimension values. - Data []DNSFirewallAnalyticsReportGetResponseData `json:"data,required"` - // Number of seconds between current time and last processed event, in another - // words how many seconds of data could be missing. - DataLag float64 `json:"data_lag,required"` - // Maximum results for each metric (object mapping metric names to values). - // Currently always an empty object. - Max interface{} `json:"max,required"` - // Minimum results for each metric (object mapping metric names to values). - // Currently always an empty object. - Min interface{} `json:"min,required"` - Query DNSFirewallAnalyticsReportGetResponseQuery `json:"query,required"` - // Total number of rows in the result. - Rows float64 `json:"rows,required"` - // Total results for metrics across all data (object mapping metric names to - // values). - Totals interface{} `json:"totals,required"` - JSON dnsFirewallAnalyticsReportGetResponseJSON `json:"-"` -} - -// dnsFirewallAnalyticsReportGetResponseJSON contains the JSON metadata for the -// struct [DNSFirewallAnalyticsReportGetResponse] -type dnsFirewallAnalyticsReportGetResponseJSON struct { - Data apijson.Field - DataLag apijson.Field - Max apijson.Field - Min apijson.Field - Query apijson.Field - Rows apijson.Field - Totals apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallAnalyticsReportGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallAnalyticsReportGetResponseJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallAnalyticsReportGetResponseData struct { - // Array of dimension values, representing the combination of dimension values - // corresponding to this row. - Dimensions []string `json:"dimensions,required"` - // Array with one item per requested metric. Each item is a single value. - Metrics []float64 `json:"metrics,required"` - JSON dnsFirewallAnalyticsReportGetResponseDataJSON `json:"-"` -} - -// dnsFirewallAnalyticsReportGetResponseDataJSON contains the JSON metadata for the -// struct [DNSFirewallAnalyticsReportGetResponseData] -type dnsFirewallAnalyticsReportGetResponseDataJSON struct { - Dimensions apijson.Field - Metrics apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallAnalyticsReportGetResponseData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallAnalyticsReportGetResponseDataJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallAnalyticsReportGetResponseQuery struct { - // Array of dimension names. - Dimensions []string `json:"dimensions,required"` - // Limit number of returned metrics. - Limit int64 `json:"limit,required"` - // Array of metric names. - Metrics []string `json:"metrics,required"` - // Start date and time of requesting data period in ISO 8601 format. - Since time.Time `json:"since,required" format:"date-time"` - // End date and time of requesting data period in ISO 8601 format. - Until time.Time `json:"until,required" format:"date-time"` - // Segmentation filter in 'attribute operator value' format. - Filters string `json:"filters"` - // Array of dimensions to sort by, where each dimension may be prefixed by - - // (descending) or + (ascending). - Sort []string `json:"sort"` - JSON dnsFirewallAnalyticsReportGetResponseQueryJSON `json:"-"` -} - -// dnsFirewallAnalyticsReportGetResponseQueryJSON contains the JSON metadata for -// the struct [DNSFirewallAnalyticsReportGetResponseQuery] -type dnsFirewallAnalyticsReportGetResponseQueryJSON struct { - Dimensions apijson.Field - Limit apijson.Field - Metrics apijson.Field - Since apijson.Field - Until apijson.Field - Filters apijson.Field - Sort apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallAnalyticsReportGetResponseQuery) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallAnalyticsReportGetResponseQueryJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallAnalyticsReportGetParams struct { - // A comma-separated list of dimensions to group results by. - Dimensions param.Field[string] `query:"dimensions"` - // Segmentation filter in 'attribute operator value' format. - Filters param.Field[string] `query:"filters"` - // Limit number of returned metrics. - Limit param.Field[int64] `query:"limit"` - // A comma-separated list of metrics to query. - Metrics param.Field[string] `query:"metrics"` - // Start date and time of requesting data period in ISO 8601 format. - Since param.Field[time.Time] `query:"since" format:"date-time"` - // A comma-separated list of dimensions to sort by, where each dimension may be - // prefixed by - (descending) or + (ascending). - Sort param.Field[string] `query:"sort"` - // End date and time of requesting data period in ISO 8601 format. - Until param.Field[time.Time] `query:"until" format:"date-time"` -} - -// URLQuery serializes [DNSFirewallAnalyticsReportGetParams]'s query parameters as -// `url.Values`. -func (r DNSFirewallAnalyticsReportGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type DNSFirewallAnalyticsReportGetResponseEnvelope struct { - Errors []DNSFirewallAnalyticsReportGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSFirewallAnalyticsReportGetResponseEnvelopeMessages `json:"messages,required"` - Result DNSFirewallAnalyticsReportGetResponse `json:"result,required"` - // Whether the API call was successful - Success DNSFirewallAnalyticsReportGetResponseEnvelopeSuccess `json:"success,required"` - JSON dnsFirewallAnalyticsReportGetResponseEnvelopeJSON `json:"-"` -} - -// dnsFirewallAnalyticsReportGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [DNSFirewallAnalyticsReportGetResponseEnvelope] -type dnsFirewallAnalyticsReportGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallAnalyticsReportGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallAnalyticsReportGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallAnalyticsReportGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsFirewallAnalyticsReportGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnsFirewallAnalyticsReportGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [DNSFirewallAnalyticsReportGetResponseEnvelopeErrors] -type dnsFirewallAnalyticsReportGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallAnalyticsReportGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallAnalyticsReportGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallAnalyticsReportGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsFirewallAnalyticsReportGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnsFirewallAnalyticsReportGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [DNSFirewallAnalyticsReportGetResponseEnvelopeMessages] -type dnsFirewallAnalyticsReportGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallAnalyticsReportGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallAnalyticsReportGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DNSFirewallAnalyticsReportGetResponseEnvelopeSuccess bool - -const ( - DNSFirewallAnalyticsReportGetResponseEnvelopeSuccessTrue DNSFirewallAnalyticsReportGetResponseEnvelopeSuccess = true -) diff --git a/dnsfirewallanalyticsreport_test.go b/dnsfirewallanalyticsreport_test.go deleted file mode 100644 index ac6bf629763..00000000000 --- a/dnsfirewallanalyticsreport_test.go +++ /dev/null @@ -1,52 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestDNSFirewallAnalyticsReportGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.DNS.Firewall.Analytics.Reports.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.DNSFirewallAnalyticsReportGetParams{ - Dimensions: cloudflare.F("queryType"), - Filters: cloudflare.F("responseCode==NOERROR,queryType==A"), - Limit: cloudflare.F(int64(100)), - Metrics: cloudflare.F("queryCount,uncachedCount"), - Since: cloudflare.F(time.Now()), - Sort: cloudflare.F("+responseCode,-queryName"), - Until: cloudflare.F(time.Now()), - }, - ) - 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/dnsfirewallanalyticsreportbytime.go b/dnsfirewallanalyticsreportbytime.go deleted file mode 100644 index da739a4a369..00000000000 --- a/dnsfirewallanalyticsreportbytime.go +++ /dev/null @@ -1,314 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// DNSFirewallAnalyticsReportBytimeService 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 -// [NewDNSFirewallAnalyticsReportBytimeService] method instead. -type DNSFirewallAnalyticsReportBytimeService struct { - Options []option.RequestOption -} - -// NewDNSFirewallAnalyticsReportBytimeService 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 NewDNSFirewallAnalyticsReportBytimeService(opts ...option.RequestOption) (r *DNSFirewallAnalyticsReportBytimeService) { - r = &DNSFirewallAnalyticsReportBytimeService{} - r.Options = opts - return -} - -// Retrieves a list of aggregate metrics grouped by time interval. -// -// See -// [Analytics API properties](https://developers.cloudflare.com/dns/reference/analytics-api-properties/) -// for detailed information about the available query parameters. -func (r *DNSFirewallAnalyticsReportBytimeService) Get(ctx context.Context, accountIdentifier string, identifier string, query DNSFirewallAnalyticsReportBytimeGetParams, opts ...option.RequestOption) (res *DNSFirewallAnalyticsReportBytimeGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env DNSFirewallAnalyticsReportBytimeGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/dns_firewall/%s/dns_analytics/report/bytime", accountIdentifier, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type DNSFirewallAnalyticsReportBytimeGetResponse struct { - // Array with one row per combination of dimension values. - Data []DNSFirewallAnalyticsReportBytimeGetResponseData `json:"data,required"` - // Number of seconds between current time and last processed event, in another - // words how many seconds of data could be missing. - DataLag float64 `json:"data_lag,required"` - // Maximum results for each metric (object mapping metric names to values). - // Currently always an empty object. - Max interface{} `json:"max,required"` - // Minimum results for each metric (object mapping metric names to values). - // Currently always an empty object. - Min interface{} `json:"min,required"` - Query DNSFirewallAnalyticsReportBytimeGetResponseQuery `json:"query,required"` - // Total number of rows in the result. - Rows float64 `json:"rows,required"` - // Array of time intervals in the response data. Each interval is represented as an - // array containing two values: the start time, and the end time. - TimeIntervals [][]time.Time `json:"time_intervals,required" format:"date-time"` - // Total results for metrics across all data (object mapping metric names to - // values). - Totals interface{} `json:"totals,required"` - JSON dnsFirewallAnalyticsReportBytimeGetResponseJSON `json:"-"` -} - -// dnsFirewallAnalyticsReportBytimeGetResponseJSON contains the JSON metadata for -// the struct [DNSFirewallAnalyticsReportBytimeGetResponse] -type dnsFirewallAnalyticsReportBytimeGetResponseJSON struct { - Data apijson.Field - DataLag apijson.Field - Max apijson.Field - Min apijson.Field - Query apijson.Field - Rows apijson.Field - TimeIntervals apijson.Field - Totals apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallAnalyticsReportBytimeGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallAnalyticsReportBytimeGetResponseJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallAnalyticsReportBytimeGetResponseData struct { - // Array of dimension values, representing the combination of dimension values - // corresponding to this row. - Dimensions []string `json:"dimensions,required"` - // Array with one item per requested metric. Each item is an array of values, - // broken down by time interval. - Metrics [][]interface{} `json:"metrics,required"` - JSON dnsFirewallAnalyticsReportBytimeGetResponseDataJSON `json:"-"` -} - -// dnsFirewallAnalyticsReportBytimeGetResponseDataJSON contains the JSON metadata -// for the struct [DNSFirewallAnalyticsReportBytimeGetResponseData] -type dnsFirewallAnalyticsReportBytimeGetResponseDataJSON struct { - Dimensions apijson.Field - Metrics apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallAnalyticsReportBytimeGetResponseData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallAnalyticsReportBytimeGetResponseDataJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallAnalyticsReportBytimeGetResponseQuery struct { - // Array of dimension names. - Dimensions []string `json:"dimensions,required"` - // Limit number of returned metrics. - Limit int64 `json:"limit,required"` - // Array of metric names. - Metrics []string `json:"metrics,required"` - // Start date and time of requesting data period in ISO 8601 format. - Since time.Time `json:"since,required" format:"date-time"` - // Unit of time to group data by. - TimeDelta DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDelta `json:"time_delta,required"` - // End date and time of requesting data period in ISO 8601 format. - Until time.Time `json:"until,required" format:"date-time"` - // Segmentation filter in 'attribute operator value' format. - Filters string `json:"filters"` - // Array of dimensions to sort by, where each dimension may be prefixed by - - // (descending) or + (ascending). - Sort []string `json:"sort"` - JSON dnsFirewallAnalyticsReportBytimeGetResponseQueryJSON `json:"-"` -} - -// dnsFirewallAnalyticsReportBytimeGetResponseQueryJSON contains the JSON metadata -// for the struct [DNSFirewallAnalyticsReportBytimeGetResponseQuery] -type dnsFirewallAnalyticsReportBytimeGetResponseQueryJSON struct { - Dimensions apijson.Field - Limit apijson.Field - Metrics apijson.Field - Since apijson.Field - TimeDelta apijson.Field - Until apijson.Field - Filters apijson.Field - Sort apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallAnalyticsReportBytimeGetResponseQuery) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallAnalyticsReportBytimeGetResponseQueryJSON) RawJSON() string { - return r.raw -} - -// Unit of time to group data by. -type DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDelta string - -const ( - DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDeltaAll DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDelta = "all" - DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDeltaAuto DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDelta = "auto" - DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDeltaYear DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDelta = "year" - DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDeltaQuarter DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDelta = "quarter" - DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDeltaMonth DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDelta = "month" - DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDeltaWeek DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDelta = "week" - DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDeltaDay DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDelta = "day" - DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDeltaHour DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDelta = "hour" - DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDeltaDekaminute DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDelta = "dekaminute" - DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDeltaMinute DNSFirewallAnalyticsReportBytimeGetResponseQueryTimeDelta = "minute" -) - -type DNSFirewallAnalyticsReportBytimeGetParams struct { - // A comma-separated list of dimensions to group results by. - Dimensions param.Field[string] `query:"dimensions"` - // Segmentation filter in 'attribute operator value' format. - Filters param.Field[string] `query:"filters"` - // Limit number of returned metrics. - Limit param.Field[int64] `query:"limit"` - // A comma-separated list of metrics to query. - Metrics param.Field[string] `query:"metrics"` - // Start date and time of requesting data period in ISO 8601 format. - Since param.Field[time.Time] `query:"since" format:"date-time"` - // A comma-separated list of dimensions to sort by, where each dimension may be - // prefixed by - (descending) or + (ascending). - Sort param.Field[string] `query:"sort"` - // Unit of time to group data by. - TimeDelta param.Field[DNSFirewallAnalyticsReportBytimeGetParamsTimeDelta] `query:"time_delta"` - // End date and time of requesting data period in ISO 8601 format. - Until param.Field[time.Time] `query:"until" format:"date-time"` -} - -// URLQuery serializes [DNSFirewallAnalyticsReportBytimeGetParams]'s query -// parameters as `url.Values`. -func (r DNSFirewallAnalyticsReportBytimeGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Unit of time to group data by. -type DNSFirewallAnalyticsReportBytimeGetParamsTimeDelta string - -const ( - DNSFirewallAnalyticsReportBytimeGetParamsTimeDeltaAll DNSFirewallAnalyticsReportBytimeGetParamsTimeDelta = "all" - DNSFirewallAnalyticsReportBytimeGetParamsTimeDeltaAuto DNSFirewallAnalyticsReportBytimeGetParamsTimeDelta = "auto" - DNSFirewallAnalyticsReportBytimeGetParamsTimeDeltaYear DNSFirewallAnalyticsReportBytimeGetParamsTimeDelta = "year" - DNSFirewallAnalyticsReportBytimeGetParamsTimeDeltaQuarter DNSFirewallAnalyticsReportBytimeGetParamsTimeDelta = "quarter" - DNSFirewallAnalyticsReportBytimeGetParamsTimeDeltaMonth DNSFirewallAnalyticsReportBytimeGetParamsTimeDelta = "month" - DNSFirewallAnalyticsReportBytimeGetParamsTimeDeltaWeek DNSFirewallAnalyticsReportBytimeGetParamsTimeDelta = "week" - DNSFirewallAnalyticsReportBytimeGetParamsTimeDeltaDay DNSFirewallAnalyticsReportBytimeGetParamsTimeDelta = "day" - DNSFirewallAnalyticsReportBytimeGetParamsTimeDeltaHour DNSFirewallAnalyticsReportBytimeGetParamsTimeDelta = "hour" - DNSFirewallAnalyticsReportBytimeGetParamsTimeDeltaDekaminute DNSFirewallAnalyticsReportBytimeGetParamsTimeDelta = "dekaminute" - DNSFirewallAnalyticsReportBytimeGetParamsTimeDeltaMinute DNSFirewallAnalyticsReportBytimeGetParamsTimeDelta = "minute" -) - -type DNSFirewallAnalyticsReportBytimeGetResponseEnvelope struct { - Errors []DNSFirewallAnalyticsReportBytimeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSFirewallAnalyticsReportBytimeGetResponseEnvelopeMessages `json:"messages,required"` - Result DNSFirewallAnalyticsReportBytimeGetResponse `json:"result,required"` - // Whether the API call was successful - Success DNSFirewallAnalyticsReportBytimeGetResponseEnvelopeSuccess `json:"success,required"` - JSON dnsFirewallAnalyticsReportBytimeGetResponseEnvelopeJSON `json:"-"` -} - -// dnsFirewallAnalyticsReportBytimeGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [DNSFirewallAnalyticsReportBytimeGetResponseEnvelope] -type dnsFirewallAnalyticsReportBytimeGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallAnalyticsReportBytimeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallAnalyticsReportBytimeGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallAnalyticsReportBytimeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsFirewallAnalyticsReportBytimeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnsFirewallAnalyticsReportBytimeGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [DNSFirewallAnalyticsReportBytimeGetResponseEnvelopeErrors] -type dnsFirewallAnalyticsReportBytimeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallAnalyticsReportBytimeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallAnalyticsReportBytimeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSFirewallAnalyticsReportBytimeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsFirewallAnalyticsReportBytimeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnsFirewallAnalyticsReportBytimeGetResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [DNSFirewallAnalyticsReportBytimeGetResponseEnvelopeMessages] -type dnsFirewallAnalyticsReportBytimeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSFirewallAnalyticsReportBytimeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsFirewallAnalyticsReportBytimeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DNSFirewallAnalyticsReportBytimeGetResponseEnvelopeSuccess bool - -const ( - DNSFirewallAnalyticsReportBytimeGetResponseEnvelopeSuccessTrue DNSFirewallAnalyticsReportBytimeGetResponseEnvelopeSuccess = true -) diff --git a/dnsfirewallanalyticsreportbytime_test.go b/dnsfirewallanalyticsreportbytime_test.go deleted file mode 100644 index 881bb5c4382..00000000000 --- a/dnsfirewallanalyticsreportbytime_test.go +++ /dev/null @@ -1,53 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestDNSFirewallAnalyticsReportBytimeGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.DNS.Firewall.Analytics.Reports.Bytimes.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.DNSFirewallAnalyticsReportBytimeGetParams{ - Dimensions: cloudflare.F("queryType"), - Filters: cloudflare.F("responseCode==NOERROR,queryType==A"), - Limit: cloudflare.F(int64(100)), - Metrics: cloudflare.F("queryCount,uncachedCount"), - Since: cloudflare.F(time.Now()), - Sort: cloudflare.F("+responseCode,-queryName"), - TimeDelta: cloudflare.F(cloudflare.DNSFirewallAnalyticsReportBytimeGetParamsTimeDeltaHour), - Until: cloudflare.F(time.Now()), - }, - ) - 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/dnsrecord.go b/dnsrecord.go deleted file mode 100644 index b2ced52889d..00000000000 --- a/dnsrecord.go +++ /dev/null @@ -1,17883 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// DNSRecordService 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 [NewDNSRecordService] method instead. -type DNSRecordService struct { - Options []option.RequestOption -} - -// NewDNSRecordService 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 NewDNSRecordService(opts ...option.RequestOption) (r *DNSRecordService) { - r = &DNSRecordService{} - r.Options = opts - return -} - -// Create a new DNS record for a zone. -// -// Notes: -// -// - A/AAAA records cannot exist on the same name as CNAME records. -// - NS records cannot exist on the same name as any other record type. -// - Domain names are always represented in Punycode, even if Unicode characters -// were used when creating the record. -func (r *DNSRecordService) New(ctx context.Context, params DNSRecordNewParams, opts ...option.RequestOption) (res *DNSRecordNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env DNSRecordNewResponseEnvelope - path := fmt.Sprintf("zones/%s/dns_records", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Overwrite an existing DNS record. Notes: -// -// - A/AAAA records cannot exist on the same name as CNAME records. -// - NS records cannot exist on the same name as any other record type. -// - Domain names are always represented in Punycode, even if Unicode characters -// were used when creating the record. -func (r *DNSRecordService) Update(ctx context.Context, dnsRecordID string, params DNSRecordUpdateParams, opts ...option.RequestOption) (res *DNSRecordUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env DNSRecordUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/dns_records/%s", params.ZoneID, dnsRecordID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List, search, sort, and filter a zones' DNS records. -func (r *DNSRecordService) List(ctx context.Context, params DNSRecordListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[DNSRecordListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("zones/%s/dns_records", params.ZoneID) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// List, search, sort, and filter a zones' DNS records. -func (r *DNSRecordService) ListAutoPaging(ctx context.Context, params DNSRecordListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[DNSRecordListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) -} - -// Delete DNS Record -func (r *DNSRecordService) Delete(ctx context.Context, dnsRecordID string, body DNSRecordDeleteParams, opts ...option.RequestOption) (res *DNSRecordDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env DNSRecordDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/dns_records/%s", body.ZoneID, dnsRecordID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update an existing DNS record. Notes: -// -// - A/AAAA records cannot exist on the same name as CNAME records. -// - NS records cannot exist on the same name as any other record type. -// - Domain names are always represented in Punycode, even if Unicode characters -// were used when creating the record. -func (r *DNSRecordService) Edit(ctx context.Context, dnsRecordID string, params DNSRecordEditParams, opts ...option.RequestOption) (res *DNSRecordEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env DNSRecordEditResponseEnvelope - path := fmt.Sprintf("zones/%s/dns_records/%s", params.ZoneID, dnsRecordID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// You can export your -// [BIND config](https://en.wikipedia.org/wiki/Zone_file "Zone file") through this -// endpoint. -// -// See -// [the documentation](https://developers.cloudflare.com/dns/manage-dns-records/how-to/import-and-export/ "Import and export records") -// for more information. -func (r *DNSRecordService) Export(ctx context.Context, query DNSRecordExportParams, opts ...option.RequestOption) (res *string, err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "text/plain")}, opts...) - path := fmt.Sprintf("zones/%s/dns_records/export", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -// DNS Record Details -func (r *DNSRecordService) Get(ctx context.Context, dnsRecordID string, query DNSRecordGetParams, opts ...option.RequestOption) (res *DNSRecordGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env DNSRecordGetResponseEnvelope - path := fmt.Sprintf("zones/%s/dns_records/%s", query.ZoneID, dnsRecordID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// You can upload your -// [BIND config](https://en.wikipedia.org/wiki/Zone_file "Zone file") through this -// endpoint. It assumes that cURL is called from a location with bind_config.txt -// (valid BIND config) present. -// -// See -// [the documentation](https://developers.cloudflare.com/dns/manage-dns-records/how-to/import-and-export/ "Import and export records") -// for more information. -func (r *DNSRecordService) Import(ctx context.Context, params DNSRecordImportParams, opts ...option.RequestOption) (res *DNSRecordImportResponse, err error) { - opts = append(r.Options[:], opts...) - var env DNSRecordImportResponseEnvelope - path := fmt.Sprintf("zones/%s/dns_records/import", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Scan for common DNS records on your domain and automatically add them to your -// zone. Useful if you haven't updated your nameservers yet. -func (r *DNSRecordService) Scan(ctx context.Context, body DNSRecordScanParams, opts ...option.RequestOption) (res *DNSRecordScanResponse, err error) { - opts = append(r.Options[:], opts...) - var env DNSRecordScanResponseEnvelope - path := fmt.Sprintf("zones/%s/dns_records/scan", body.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [DNSRecordNewResponseA], [DNSRecordNewResponseAAAA], -// [DNSRecordNewResponseCAA], [DNSRecordNewResponseCert], -// [DNSRecordNewResponseCNAME], [DNSRecordNewResponseDNSKEY], -// [DNSRecordNewResponseDS], [DNSRecordNewResponseHTTPS], -// [DNSRecordNewResponseLOC], [DNSRecordNewResponseMX], -// [DNSRecordNewResponseNAPTR], [DNSRecordNewResponseNS], -// [DNSRecordNewResponsePTR], [DNSRecordNewResponseSmimea], -// [DNSRecordNewResponseSRV], [DNSRecordNewResponseSSHFP], -// [DNSRecordNewResponseSVCB], [DNSRecordNewResponseTLSA], -// [DNSRecordNewResponseTXT] or [DNSRecordNewResponseURI]. -type DNSRecordNewResponse interface { - implementsDNSRecordNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponse)(nil)).Elem(), - "type", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseA{}), - DiscriminatorValue: "A", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseAAAA{}), - DiscriminatorValue: "AAAA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseCAA{}), - DiscriminatorValue: "CAA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseCert{}), - DiscriminatorValue: "CERT", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseCNAME{}), - DiscriminatorValue: "CNAME", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseDNSKEY{}), - DiscriminatorValue: "DNSKEY", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseDS{}), - DiscriminatorValue: "DS", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseHTTPS{}), - DiscriminatorValue: "HTTPS", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseLOC{}), - DiscriminatorValue: "LOC", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseMX{}), - DiscriminatorValue: "MX", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseNAPTR{}), - DiscriminatorValue: "NAPTR", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseNS{}), - DiscriminatorValue: "NS", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponsePTR{}), - DiscriminatorValue: "PTR", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseSmimea{}), - DiscriminatorValue: "SMIMEA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseSRV{}), - DiscriminatorValue: "SRV", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseSSHFP{}), - DiscriminatorValue: "SSHFP", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseSVCB{}), - DiscriminatorValue: "SVCB", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseTLSA{}), - DiscriminatorValue: "TLSA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseTXT{}), - DiscriminatorValue: "TXT", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordNewResponseURI{}), - DiscriminatorValue: "URI", - }, - ) -} - -type DNSRecordNewResponseA struct { - // A valid IPv4 address. - Content string `json:"content,required" format:"ipv4"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordNewResponseAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied bool `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseAJSON `json:"-"` -} - -// dnsRecordNewResponseAJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseA] -type dnsRecordNewResponseAJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Proxied apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseA) implementsDNSRecordNewResponse() {} - -// Record type. -type DNSRecordNewResponseAType string - -const ( - DNSRecordNewResponseATypeA DNSRecordNewResponseAType = "A" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseAMetaJSON `json:"-"` -} - -// dnsRecordNewResponseAMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseAMeta] -type dnsRecordNewResponseAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseATTLNumber]. -type DNSRecordNewResponseATTL interface { - ImplementsDNSRecordNewResponseAttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseATTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseATTLNumber float64 - -const ( - DNSRecordNewResponseATTLNumber1 DNSRecordNewResponseATTLNumber = 1 -) - -type DNSRecordNewResponseAAAA struct { - // A valid IPv6 address. - Content string `json:"content,required" format:"ipv6"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordNewResponseAAAAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseAAAAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied bool `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseAAAATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseAAAAJSON `json:"-"` -} - -// dnsRecordNewResponseAAAAJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseAAAA] -type dnsRecordNewResponseAAAAJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Proxied apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseAAAA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseAAAAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseAAAA) implementsDNSRecordNewResponse() {} - -// Record type. -type DNSRecordNewResponseAAAAType string - -const ( - DNSRecordNewResponseAAAATypeAAAA DNSRecordNewResponseAAAAType = "AAAA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseAAAAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseAAAAMetaJSON `json:"-"` -} - -// dnsRecordNewResponseAAAAMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseAAAAMeta] -type dnsRecordNewResponseAAAAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseAAAAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseAAAAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseAAAATTLNumber]. -type DNSRecordNewResponseAAAATTL interface { - ImplementsDNSRecordNewResponseAaaattl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseAAAATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseAAAATTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseAAAATTLNumber float64 - -const ( - DNSRecordNewResponseAAAATTLNumber1 DNSRecordNewResponseAAAATTLNumber = 1 -) - -type DNSRecordNewResponseCAA struct { - // Components of a CAA record. - Data DNSRecordNewResponseCAAData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordNewResponseCAAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted CAA content. See 'data' to set CAA properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseCAAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseCAATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseCAAJSON `json:"-"` -} - -// dnsRecordNewResponseCAAJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseCAA] -type dnsRecordNewResponseCAAJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseCAA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseCAAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseCAA) implementsDNSRecordNewResponse() {} - -// Components of a CAA record. -type DNSRecordNewResponseCAAData struct { - // Flags for the CAA record. - Flags float64 `json:"flags"` - // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). - Tag string `json:"tag"` - // Value of the record. This field's semantics depend on the chosen tag. - Value string `json:"value"` - JSON dnsRecordNewResponseCAADataJSON `json:"-"` -} - -// dnsRecordNewResponseCAADataJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseCAAData] -type dnsRecordNewResponseCAADataJSON struct { - Flags apijson.Field - Tag apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseCAAData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseCAADataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordNewResponseCAAType string - -const ( - DNSRecordNewResponseCAATypeCAA DNSRecordNewResponseCAAType = "CAA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseCAAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseCAAMetaJSON `json:"-"` -} - -// dnsRecordNewResponseCAAMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseCAAMeta] -type dnsRecordNewResponseCAAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseCAAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseCAAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseCAATTLNumber]. -type DNSRecordNewResponseCAATTL interface { - ImplementsDNSRecordNewResponseCaattl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseCAATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseCAATTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseCAATTLNumber float64 - -const ( - DNSRecordNewResponseCAATTLNumber1 DNSRecordNewResponseCAATTLNumber = 1 -) - -type DNSRecordNewResponseCert struct { - // Components of a CERT record. - Data DNSRecordNewResponseCertData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordNewResponseCertType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted CERT content. See 'data' to set CERT properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseCertMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseCertTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseCertJSON `json:"-"` -} - -// dnsRecordNewResponseCertJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseCert] -type dnsRecordNewResponseCertJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseCert) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseCertJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseCert) implementsDNSRecordNewResponse() {} - -// Components of a CERT record. -type DNSRecordNewResponseCertData struct { - // Algorithm. - Algorithm float64 `json:"algorithm"` - // Certificate. - Certificate string `json:"certificate"` - // Key Tag. - KeyTag float64 `json:"key_tag"` - // Type. - Type float64 `json:"type"` - JSON dnsRecordNewResponseCertDataJSON `json:"-"` -} - -// dnsRecordNewResponseCertDataJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseCertData] -type dnsRecordNewResponseCertDataJSON struct { - Algorithm apijson.Field - Certificate apijson.Field - KeyTag apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseCertData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseCertDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordNewResponseCertType string - -const ( - DNSRecordNewResponseCertTypeCert DNSRecordNewResponseCertType = "CERT" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseCertMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseCertMetaJSON `json:"-"` -} - -// dnsRecordNewResponseCertMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseCertMeta] -type dnsRecordNewResponseCertMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseCertMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseCertMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseCertTTLNumber]. -type DNSRecordNewResponseCertTTL interface { - ImplementsDNSRecordNewResponseCertTTL() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseCertTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseCertTTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseCertTTLNumber float64 - -const ( - DNSRecordNewResponseCertTTLNumber1 DNSRecordNewResponseCertTTLNumber = 1 -) - -type DNSRecordNewResponseCNAME struct { - // A valid hostname. Must not match the record's name. - Content interface{} `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordNewResponseCNAMEType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseCNAMEMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied bool `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseCNAMETTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseCNAMEJSON `json:"-"` -} - -// dnsRecordNewResponseCNAMEJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseCNAME] -type dnsRecordNewResponseCNAMEJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Proxied apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseCNAME) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseCNAMEJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseCNAME) implementsDNSRecordNewResponse() {} - -// Record type. -type DNSRecordNewResponseCNAMEType string - -const ( - DNSRecordNewResponseCNAMETypeCNAME DNSRecordNewResponseCNAMEType = "CNAME" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseCNAMEMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseCNAMEMetaJSON `json:"-"` -} - -// dnsRecordNewResponseCNAMEMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseCNAMEMeta] -type dnsRecordNewResponseCNAMEMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseCNAMEMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseCNAMEMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseCNAMETTLNumber]. -type DNSRecordNewResponseCNAMETTL interface { - ImplementsDNSRecordNewResponseCnamettl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseCNAMETTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseCNAMETTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseCNAMETTLNumber float64 - -const ( - DNSRecordNewResponseCNAMETTLNumber1 DNSRecordNewResponseCNAMETTLNumber = 1 -) - -type DNSRecordNewResponseDNSKEY struct { - // Components of a DNSKEY record. - Data DNSRecordNewResponseDNSKEYData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordNewResponseDNSKEYType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted DNSKEY content. See 'data' to set DNSKEY properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseDNSKEYMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseDNSKEYTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseDNSKEYJSON `json:"-"` -} - -// dnsRecordNewResponseDNSKEYJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseDNSKEY] -type dnsRecordNewResponseDNSKEYJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseDNSKEY) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseDNSKEYJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseDNSKEY) implementsDNSRecordNewResponse() {} - -// Components of a DNSKEY record. -type DNSRecordNewResponseDNSKEYData struct { - // Algorithm. - Algorithm float64 `json:"algorithm"` - // Flags. - Flags float64 `json:"flags"` - // Protocol. - Protocol float64 `json:"protocol"` - // Public Key. - PublicKey string `json:"public_key"` - JSON dnsRecordNewResponseDNSKEYDataJSON `json:"-"` -} - -// dnsRecordNewResponseDNSKEYDataJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseDNSKEYData] -type dnsRecordNewResponseDNSKEYDataJSON struct { - Algorithm apijson.Field - Flags apijson.Field - Protocol apijson.Field - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseDNSKEYData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseDNSKEYDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordNewResponseDNSKEYType string - -const ( - DNSRecordNewResponseDNSKEYTypeDNSKEY DNSRecordNewResponseDNSKEYType = "DNSKEY" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseDNSKEYMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseDNSKEYMetaJSON `json:"-"` -} - -// dnsRecordNewResponseDNSKEYMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseDNSKEYMeta] -type dnsRecordNewResponseDNSKEYMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseDNSKEYMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseDNSKEYMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseDNSKEYTTLNumber]. -type DNSRecordNewResponseDNSKEYTTL interface { - ImplementsDNSRecordNewResponseDnskeyttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseDNSKEYTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseDNSKEYTTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseDNSKEYTTLNumber float64 - -const ( - DNSRecordNewResponseDNSKEYTTLNumber1 DNSRecordNewResponseDNSKEYTTLNumber = 1 -) - -type DNSRecordNewResponseDS struct { - // Components of a DS record. - Data DNSRecordNewResponseDSData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordNewResponseDSType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted DS content. See 'data' to set DS properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseDSMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseDSTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseDSJSON `json:"-"` -} - -// dnsRecordNewResponseDSJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseDS] -type dnsRecordNewResponseDSJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseDS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseDSJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseDS) implementsDNSRecordNewResponse() {} - -// Components of a DS record. -type DNSRecordNewResponseDSData struct { - // Algorithm. - Algorithm float64 `json:"algorithm"` - // Digest. - Digest string `json:"digest"` - // Digest Type. - DigestType float64 `json:"digest_type"` - // Key Tag. - KeyTag float64 `json:"key_tag"` - JSON dnsRecordNewResponseDSDataJSON `json:"-"` -} - -// dnsRecordNewResponseDSDataJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseDSData] -type dnsRecordNewResponseDSDataJSON struct { - Algorithm apijson.Field - Digest apijson.Field - DigestType apijson.Field - KeyTag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseDSData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseDSDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordNewResponseDSType string - -const ( - DNSRecordNewResponseDSTypeDS DNSRecordNewResponseDSType = "DS" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseDSMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseDSMetaJSON `json:"-"` -} - -// dnsRecordNewResponseDSMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseDSMeta] -type dnsRecordNewResponseDSMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseDSMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseDSMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseDSTTLNumber]. -type DNSRecordNewResponseDSTTL interface { - ImplementsDNSRecordNewResponseDsttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseDSTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseDSTTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseDSTTLNumber float64 - -const ( - DNSRecordNewResponseDSTTLNumber1 DNSRecordNewResponseDSTTLNumber = 1 -) - -type DNSRecordNewResponseHTTPS struct { - // Components of a HTTPS record. - Data DNSRecordNewResponseHTTPSData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordNewResponseHTTPSType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted HTTPS content. See 'data' to set HTTPS properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseHTTPSMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseHTTPSTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseHTTPSJSON `json:"-"` -} - -// dnsRecordNewResponseHTTPSJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseHTTPS] -type dnsRecordNewResponseHTTPSJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseHTTPS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseHTTPSJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseHTTPS) implementsDNSRecordNewResponse() {} - -// Components of a HTTPS record. -type DNSRecordNewResponseHTTPSData struct { - // priority. - Priority float64 `json:"priority"` - // target. - Target string `json:"target"` - // value. - Value string `json:"value"` - JSON dnsRecordNewResponseHTTPSDataJSON `json:"-"` -} - -// dnsRecordNewResponseHTTPSDataJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseHTTPSData] -type dnsRecordNewResponseHTTPSDataJSON struct { - Priority apijson.Field - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseHTTPSData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseHTTPSDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordNewResponseHTTPSType string - -const ( - DNSRecordNewResponseHTTPSTypeHTTPS DNSRecordNewResponseHTTPSType = "HTTPS" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseHTTPSMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseHTTPSMetaJSON `json:"-"` -} - -// dnsRecordNewResponseHTTPSMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseHTTPSMeta] -type dnsRecordNewResponseHTTPSMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseHTTPSMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseHTTPSMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseHTTPSTTLNumber]. -type DNSRecordNewResponseHTTPSTTL interface { - ImplementsDNSRecordNewResponseHttpsttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseHTTPSTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseHTTPSTTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseHTTPSTTLNumber float64 - -const ( - DNSRecordNewResponseHTTPSTTLNumber1 DNSRecordNewResponseHTTPSTTLNumber = 1 -) - -type DNSRecordNewResponseLOC struct { - // Components of a LOC record. - Data DNSRecordNewResponseLOCData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordNewResponseLOCType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted LOC content. See 'data' to set LOC properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseLOCMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseLOCTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseLOCJSON `json:"-"` -} - -// dnsRecordNewResponseLOCJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseLOC] -type dnsRecordNewResponseLOCJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseLOC) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseLOCJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseLOC) implementsDNSRecordNewResponse() {} - -// Components of a LOC record. -type DNSRecordNewResponseLOCData struct { - // Altitude of location in meters. - Altitude float64 `json:"altitude"` - // Degrees of latitude. - LatDegrees float64 `json:"lat_degrees"` - // Latitude direction. - LatDirection DNSRecordNewResponseLOCDataLatDirection `json:"lat_direction"` - // Minutes of latitude. - LatMinutes float64 `json:"lat_minutes"` - // Seconds of latitude. - LatSeconds float64 `json:"lat_seconds"` - // Degrees of longitude. - LongDegrees float64 `json:"long_degrees"` - // Longitude direction. - LongDirection DNSRecordNewResponseLOCDataLongDirection `json:"long_direction"` - // Minutes of longitude. - LongMinutes float64 `json:"long_minutes"` - // Seconds of longitude. - LongSeconds float64 `json:"long_seconds"` - // Horizontal precision of location. - PrecisionHorz float64 `json:"precision_horz"` - // Vertical precision of location. - PrecisionVert float64 `json:"precision_vert"` - // Size of location in meters. - Size float64 `json:"size"` - JSON dnsRecordNewResponseLOCDataJSON `json:"-"` -} - -// dnsRecordNewResponseLOCDataJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseLOCData] -type dnsRecordNewResponseLOCDataJSON struct { - Altitude apijson.Field - LatDegrees apijson.Field - LatDirection apijson.Field - LatMinutes apijson.Field - LatSeconds apijson.Field - LongDegrees apijson.Field - LongDirection apijson.Field - LongMinutes apijson.Field - LongSeconds apijson.Field - PrecisionHorz apijson.Field - PrecisionVert apijson.Field - Size apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseLOCData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseLOCDataJSON) RawJSON() string { - return r.raw -} - -// Latitude direction. -type DNSRecordNewResponseLOCDataLatDirection string - -const ( - DNSRecordNewResponseLOCDataLatDirectionN DNSRecordNewResponseLOCDataLatDirection = "N" - DNSRecordNewResponseLOCDataLatDirectionS DNSRecordNewResponseLOCDataLatDirection = "S" -) - -// Longitude direction. -type DNSRecordNewResponseLOCDataLongDirection string - -const ( - DNSRecordNewResponseLOCDataLongDirectionE DNSRecordNewResponseLOCDataLongDirection = "E" - DNSRecordNewResponseLOCDataLongDirectionW DNSRecordNewResponseLOCDataLongDirection = "W" -) - -// Record type. -type DNSRecordNewResponseLOCType string - -const ( - DNSRecordNewResponseLOCTypeLOC DNSRecordNewResponseLOCType = "LOC" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseLOCMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseLOCMetaJSON `json:"-"` -} - -// dnsRecordNewResponseLOCMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseLOCMeta] -type dnsRecordNewResponseLOCMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseLOCMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseLOCMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseLOCTTLNumber]. -type DNSRecordNewResponseLOCTTL interface { - ImplementsDNSRecordNewResponseLocttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseLOCTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseLOCTTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseLOCTTLNumber float64 - -const ( - DNSRecordNewResponseLOCTTLNumber1 DNSRecordNewResponseLOCTTLNumber = 1 -) - -type DNSRecordNewResponseMX struct { - // A valid mail server hostname. - Content string `json:"content,required" format:"hostname"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority float64 `json:"priority,required"` - // Record type. - Type DNSRecordNewResponseMXType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseMXMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseMXTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseMXJSON `json:"-"` -} - -// dnsRecordNewResponseMXJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseMX] -type dnsRecordNewResponseMXJSON struct { - Content apijson.Field - Name apijson.Field - Priority apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseMX) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseMXJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseMX) implementsDNSRecordNewResponse() {} - -// Record type. -type DNSRecordNewResponseMXType string - -const ( - DNSRecordNewResponseMXTypeMX DNSRecordNewResponseMXType = "MX" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseMXMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseMXMetaJSON `json:"-"` -} - -// dnsRecordNewResponseMXMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseMXMeta] -type dnsRecordNewResponseMXMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseMXMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseMXMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseMXTTLNumber]. -type DNSRecordNewResponseMXTTL interface { - ImplementsDNSRecordNewResponseMxttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseMXTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseMXTTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseMXTTLNumber float64 - -const ( - DNSRecordNewResponseMXTTLNumber1 DNSRecordNewResponseMXTTLNumber = 1 -) - -type DNSRecordNewResponseNAPTR struct { - // Components of a NAPTR record. - Data DNSRecordNewResponseNAPTRData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordNewResponseNAPTRType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted NAPTR content. See 'data' to set NAPTR properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseNAPTRMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseNAPTRTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseNAPTRJSON `json:"-"` -} - -// dnsRecordNewResponseNAPTRJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseNAPTR] -type dnsRecordNewResponseNAPTRJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseNAPTR) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseNAPTRJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseNAPTR) implementsDNSRecordNewResponse() {} - -// Components of a NAPTR record. -type DNSRecordNewResponseNAPTRData struct { - // Flags. - Flags string `json:"flags"` - // Order. - Order float64 `json:"order"` - // Preference. - Preference float64 `json:"preference"` - // Regex. - Regex string `json:"regex"` - // Replacement. - Replacement string `json:"replacement"` - // Service. - Service string `json:"service"` - JSON dnsRecordNewResponseNAPTRDataJSON `json:"-"` -} - -// dnsRecordNewResponseNAPTRDataJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseNAPTRData] -type dnsRecordNewResponseNAPTRDataJSON struct { - Flags apijson.Field - Order apijson.Field - Preference apijson.Field - Regex apijson.Field - Replacement apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseNAPTRData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseNAPTRDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordNewResponseNAPTRType string - -const ( - DNSRecordNewResponseNAPTRTypeNAPTR DNSRecordNewResponseNAPTRType = "NAPTR" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseNAPTRMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseNAPTRMetaJSON `json:"-"` -} - -// dnsRecordNewResponseNAPTRMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseNAPTRMeta] -type dnsRecordNewResponseNAPTRMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseNAPTRMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseNAPTRMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseNAPTRTTLNumber]. -type DNSRecordNewResponseNAPTRTTL interface { - ImplementsDNSRecordNewResponseNaptrttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseNAPTRTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseNAPTRTTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseNAPTRTTLNumber float64 - -const ( - DNSRecordNewResponseNAPTRTTLNumber1 DNSRecordNewResponseNAPTRTTLNumber = 1 -) - -type DNSRecordNewResponseNS struct { - // A valid name server host name. - Content interface{} `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordNewResponseNSType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseNSMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseNSTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseNSJSON `json:"-"` -} - -// dnsRecordNewResponseNSJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseNS] -type dnsRecordNewResponseNSJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseNSJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseNS) implementsDNSRecordNewResponse() {} - -// Record type. -type DNSRecordNewResponseNSType string - -const ( - DNSRecordNewResponseNSTypeNS DNSRecordNewResponseNSType = "NS" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseNSMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseNSMetaJSON `json:"-"` -} - -// dnsRecordNewResponseNSMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseNSMeta] -type dnsRecordNewResponseNSMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseNSMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseNSMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseNSTTLNumber]. -type DNSRecordNewResponseNSTTL interface { - ImplementsDNSRecordNewResponseNsttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseNSTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseNSTTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseNSTTLNumber float64 - -const ( - DNSRecordNewResponseNSTTLNumber1 DNSRecordNewResponseNSTTLNumber = 1 -) - -type DNSRecordNewResponsePTR struct { - // Domain name pointing to the address. - Content string `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordNewResponsePTRType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponsePTRMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponsePTRTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponsePTRJSON `json:"-"` -} - -// dnsRecordNewResponsePTRJSON contains the JSON metadata for the struct -// [DNSRecordNewResponsePTR] -type dnsRecordNewResponsePTRJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponsePTR) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponsePTRJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponsePTR) implementsDNSRecordNewResponse() {} - -// Record type. -type DNSRecordNewResponsePTRType string - -const ( - DNSRecordNewResponsePTRTypePTR DNSRecordNewResponsePTRType = "PTR" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponsePTRMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponsePTRMetaJSON `json:"-"` -} - -// dnsRecordNewResponsePTRMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponsePTRMeta] -type dnsRecordNewResponsePTRMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponsePTRMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponsePTRMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponsePTRTTLNumber]. -type DNSRecordNewResponsePTRTTL interface { - ImplementsDNSRecordNewResponsePtrttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponsePTRTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponsePTRTTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponsePTRTTLNumber float64 - -const ( - DNSRecordNewResponsePTRTTLNumber1 DNSRecordNewResponsePTRTTLNumber = 1 -) - -type DNSRecordNewResponseSmimea struct { - // Components of a SMIMEA record. - Data DNSRecordNewResponseSmimeaData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordNewResponseSmimeaType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted SMIMEA content. See 'data' to set SMIMEA properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseSmimeaMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseSmimeaTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseSmimeaJSON `json:"-"` -} - -// dnsRecordNewResponseSmimeaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseSmimea] -type dnsRecordNewResponseSmimeaJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseSmimea) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseSmimeaJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseSmimea) implementsDNSRecordNewResponse() {} - -// Components of a SMIMEA record. -type DNSRecordNewResponseSmimeaData struct { - // Certificate. - Certificate string `json:"certificate"` - // Matching Type. - MatchingType float64 `json:"matching_type"` - // Selector. - Selector float64 `json:"selector"` - // Usage. - Usage float64 `json:"usage"` - JSON dnsRecordNewResponseSmimeaDataJSON `json:"-"` -} - -// dnsRecordNewResponseSmimeaDataJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseSmimeaData] -type dnsRecordNewResponseSmimeaDataJSON struct { - Certificate apijson.Field - MatchingType apijson.Field - Selector apijson.Field - Usage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseSmimeaData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseSmimeaDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordNewResponseSmimeaType string - -const ( - DNSRecordNewResponseSmimeaTypeSmimea DNSRecordNewResponseSmimeaType = "SMIMEA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseSmimeaMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseSmimeaMetaJSON `json:"-"` -} - -// dnsRecordNewResponseSmimeaMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseSmimeaMeta] -type dnsRecordNewResponseSmimeaMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseSmimeaMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseSmimeaMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseSmimeaTTLNumber]. -type DNSRecordNewResponseSmimeaTTL interface { - ImplementsDNSRecordNewResponseSmimeaTTL() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseSmimeaTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseSmimeaTTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseSmimeaTTLNumber float64 - -const ( - DNSRecordNewResponseSmimeaTTLNumber1 DNSRecordNewResponseSmimeaTTLNumber = 1 -) - -type DNSRecordNewResponseSRV struct { - // Components of a SRV record. - Data DNSRecordNewResponseSRVData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. For SRV records, the first - // label is normally a service and the second a protocol name, each starting with - // an underscore. - Name string `json:"name,required"` - // Record type. - Type DNSRecordNewResponseSRVType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Priority, weight, port, and SRV target. See 'data' for setting the individual - // component values. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseSRVMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseSRVTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseSRVJSON `json:"-"` -} - -// dnsRecordNewResponseSRVJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseSRV] -type dnsRecordNewResponseSRVJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseSRV) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseSRVJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseSRV) implementsDNSRecordNewResponse() {} - -// Components of a SRV record. -type DNSRecordNewResponseSRVData struct { - // A valid hostname. Deprecated in favor of the regular 'name' outside the data - // map. This data map field represents the remainder of the full 'name' after the - // service and protocol. - Name string `json:"name" format:"hostname"` - // The port of the service. - Port float64 `json:"port"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority float64 `json:"priority"` - // A valid protocol, prefixed with an underscore. Deprecated in favor of the - // regular 'name' outside the data map. This data map field normally represents the - // second label of that 'name'. - Proto string `json:"proto"` - // A service type, prefixed with an underscore. Deprecated in favor of the regular - // 'name' outside the data map. This data map field normally represents the first - // label of that 'name'. - Service string `json:"service"` - // A valid hostname. - Target string `json:"target" format:"hostname"` - // The record weight. - Weight float64 `json:"weight"` - JSON dnsRecordNewResponseSRVDataJSON `json:"-"` -} - -// dnsRecordNewResponseSRVDataJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseSRVData] -type dnsRecordNewResponseSRVDataJSON struct { - Name apijson.Field - Port apijson.Field - Priority apijson.Field - Proto apijson.Field - Service apijson.Field - Target apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseSRVData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseSRVDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordNewResponseSRVType string - -const ( - DNSRecordNewResponseSRVTypeSRV DNSRecordNewResponseSRVType = "SRV" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseSRVMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseSRVMetaJSON `json:"-"` -} - -// dnsRecordNewResponseSRVMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseSRVMeta] -type dnsRecordNewResponseSRVMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseSRVMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseSRVMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseSRVTTLNumber]. -type DNSRecordNewResponseSRVTTL interface { - ImplementsDNSRecordNewResponseSrvttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseSRVTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseSRVTTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseSRVTTLNumber float64 - -const ( - DNSRecordNewResponseSRVTTLNumber1 DNSRecordNewResponseSRVTTLNumber = 1 -) - -type DNSRecordNewResponseSSHFP struct { - // Components of a SSHFP record. - Data DNSRecordNewResponseSSHFPData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordNewResponseSSHFPType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted SSHFP content. See 'data' to set SSHFP properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseSSHFPMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseSSHFPTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseSSHFPJSON `json:"-"` -} - -// dnsRecordNewResponseSSHFPJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseSSHFP] -type dnsRecordNewResponseSSHFPJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseSSHFP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseSSHFPJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseSSHFP) implementsDNSRecordNewResponse() {} - -// Components of a SSHFP record. -type DNSRecordNewResponseSSHFPData struct { - // algorithm. - Algorithm float64 `json:"algorithm"` - // fingerprint. - Fingerprint string `json:"fingerprint"` - // type. - Type float64 `json:"type"` - JSON dnsRecordNewResponseSSHFPDataJSON `json:"-"` -} - -// dnsRecordNewResponseSSHFPDataJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseSSHFPData] -type dnsRecordNewResponseSSHFPDataJSON struct { - Algorithm apijson.Field - Fingerprint apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseSSHFPData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseSSHFPDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordNewResponseSSHFPType string - -const ( - DNSRecordNewResponseSSHFPTypeSSHFP DNSRecordNewResponseSSHFPType = "SSHFP" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseSSHFPMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseSSHFPMetaJSON `json:"-"` -} - -// dnsRecordNewResponseSSHFPMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseSSHFPMeta] -type dnsRecordNewResponseSSHFPMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseSSHFPMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseSSHFPMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseSSHFPTTLNumber]. -type DNSRecordNewResponseSSHFPTTL interface { - ImplementsDNSRecordNewResponseSshfpttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseSSHFPTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseSSHFPTTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseSSHFPTTLNumber float64 - -const ( - DNSRecordNewResponseSSHFPTTLNumber1 DNSRecordNewResponseSSHFPTTLNumber = 1 -) - -type DNSRecordNewResponseSVCB struct { - // Components of a SVCB record. - Data DNSRecordNewResponseSVCBData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordNewResponseSVCBType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted SVCB content. See 'data' to set SVCB properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseSVCBMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseSVCBTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseSVCBJSON `json:"-"` -} - -// dnsRecordNewResponseSVCBJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseSVCB] -type dnsRecordNewResponseSVCBJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseSVCB) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseSVCBJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseSVCB) implementsDNSRecordNewResponse() {} - -// Components of a SVCB record. -type DNSRecordNewResponseSVCBData struct { - // priority. - Priority float64 `json:"priority"` - // target. - Target string `json:"target"` - // value. - Value string `json:"value"` - JSON dnsRecordNewResponseSVCBDataJSON `json:"-"` -} - -// dnsRecordNewResponseSVCBDataJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseSVCBData] -type dnsRecordNewResponseSVCBDataJSON struct { - Priority apijson.Field - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseSVCBData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseSVCBDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordNewResponseSVCBType string - -const ( - DNSRecordNewResponseSVCBTypeSVCB DNSRecordNewResponseSVCBType = "SVCB" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseSVCBMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseSVCBMetaJSON `json:"-"` -} - -// dnsRecordNewResponseSVCBMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseSVCBMeta] -type dnsRecordNewResponseSVCBMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseSVCBMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseSVCBMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseSVCBTTLNumber]. -type DNSRecordNewResponseSVCBTTL interface { - ImplementsDNSRecordNewResponseSvcbttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseSVCBTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseSVCBTTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseSVCBTTLNumber float64 - -const ( - DNSRecordNewResponseSVCBTTLNumber1 DNSRecordNewResponseSVCBTTLNumber = 1 -) - -type DNSRecordNewResponseTLSA struct { - // Components of a TLSA record. - Data DNSRecordNewResponseTLSAData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordNewResponseTLSAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted TLSA content. See 'data' to set TLSA properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseTLSAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseTLSATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseTLSAJSON `json:"-"` -} - -// dnsRecordNewResponseTLSAJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseTLSA] -type dnsRecordNewResponseTLSAJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseTLSA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseTLSAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseTLSA) implementsDNSRecordNewResponse() {} - -// Components of a TLSA record. -type DNSRecordNewResponseTLSAData struct { - // certificate. - Certificate string `json:"certificate"` - // Matching Type. - MatchingType float64 `json:"matching_type"` - // Selector. - Selector float64 `json:"selector"` - // Usage. - Usage float64 `json:"usage"` - JSON dnsRecordNewResponseTLSADataJSON `json:"-"` -} - -// dnsRecordNewResponseTLSADataJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseTLSAData] -type dnsRecordNewResponseTLSADataJSON struct { - Certificate apijson.Field - MatchingType apijson.Field - Selector apijson.Field - Usage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseTLSAData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseTLSADataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordNewResponseTLSAType string - -const ( - DNSRecordNewResponseTLSATypeTLSA DNSRecordNewResponseTLSAType = "TLSA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseTLSAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseTLSAMetaJSON `json:"-"` -} - -// dnsRecordNewResponseTLSAMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseTLSAMeta] -type dnsRecordNewResponseTLSAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseTLSAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseTLSAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseTLSATTLNumber]. -type DNSRecordNewResponseTLSATTL interface { - ImplementsDNSRecordNewResponseTlsattl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseTLSATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseTLSATTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseTLSATTLNumber float64 - -const ( - DNSRecordNewResponseTLSATTLNumber1 DNSRecordNewResponseTLSATTLNumber = 1 -) - -type DNSRecordNewResponseTXT struct { - // Text content for the record. - Content string `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordNewResponseTXTType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseTXTMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseTXTTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseTXTJSON `json:"-"` -} - -// dnsRecordNewResponseTXTJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseTXT] -type dnsRecordNewResponseTXTJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseTXT) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseTXTJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseTXT) implementsDNSRecordNewResponse() {} - -// Record type. -type DNSRecordNewResponseTXTType string - -const ( - DNSRecordNewResponseTXTTypeTXT DNSRecordNewResponseTXTType = "TXT" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseTXTMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseTXTMetaJSON `json:"-"` -} - -// dnsRecordNewResponseTXTMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseTXTMeta] -type dnsRecordNewResponseTXTMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseTXTMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseTXTMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseTXTTTLNumber]. -type DNSRecordNewResponseTXTTTL interface { - ImplementsDNSRecordNewResponseTxtttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseTXTTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseTXTTTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseTXTTTLNumber float64 - -const ( - DNSRecordNewResponseTXTTTLNumber1 DNSRecordNewResponseTXTTTLNumber = 1 -) - -type DNSRecordNewResponseURI struct { - // Components of a URI record. - Data DNSRecordNewResponseURIData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority float64 `json:"priority,required"` - // Record type. - Type DNSRecordNewResponseURIType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted URI content. See 'data' to set URI properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordNewResponseURIMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordNewResponseURITTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordNewResponseURIJSON `json:"-"` -} - -// dnsRecordNewResponseURIJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseURI] -type dnsRecordNewResponseURIJSON struct { - Data apijson.Field - Name apijson.Field - Priority apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseURI) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseURIJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordNewResponseURI) implementsDNSRecordNewResponse() {} - -// Components of a URI record. -type DNSRecordNewResponseURIData struct { - // The record content. - Content string `json:"content"` - // The record weight. - Weight float64 `json:"weight"` - JSON dnsRecordNewResponseURIDataJSON `json:"-"` -} - -// dnsRecordNewResponseURIDataJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseURIData] -type dnsRecordNewResponseURIDataJSON struct { - Content apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseURIData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseURIDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordNewResponseURIType string - -const ( - DNSRecordNewResponseURITypeURI DNSRecordNewResponseURIType = "URI" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordNewResponseURIMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordNewResponseURIMetaJSON `json:"-"` -} - -// dnsRecordNewResponseURIMetaJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseURIMeta] -type dnsRecordNewResponseURIMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseURIMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseURIMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordNewResponseURITTLNumber]. -type DNSRecordNewResponseURITTL interface { - ImplementsDNSRecordNewResponseUrittl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordNewResponseURITTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordNewResponseURITTLNumber(0)), - }, - ) -} - -type DNSRecordNewResponseURITTLNumber float64 - -const ( - DNSRecordNewResponseURITTLNumber1 DNSRecordNewResponseURITTLNumber = 1 -) - -// Union satisfied by [DNSRecordUpdateResponseA], [DNSRecordUpdateResponseAAAA], -// [DNSRecordUpdateResponseCAA], [DNSRecordUpdateResponseCert], -// [DNSRecordUpdateResponseCNAME], [DNSRecordUpdateResponseDNSKEY], -// [DNSRecordUpdateResponseDS], [DNSRecordUpdateResponseHTTPS], -// [DNSRecordUpdateResponseLOC], [DNSRecordUpdateResponseMX], -// [DNSRecordUpdateResponseNAPTR], [DNSRecordUpdateResponseNS], -// [DNSRecordUpdateResponsePTR], [DNSRecordUpdateResponseSmimea], -// [DNSRecordUpdateResponseSRV], [DNSRecordUpdateResponseSSHFP], -// [DNSRecordUpdateResponseSVCB], [DNSRecordUpdateResponseTLSA], -// [DNSRecordUpdateResponseTXT] or [DNSRecordUpdateResponseURI]. -type DNSRecordUpdateResponse interface { - implementsDNSRecordUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponse)(nil)).Elem(), - "type", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseA{}), - DiscriminatorValue: "A", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseAAAA{}), - DiscriminatorValue: "AAAA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseCAA{}), - DiscriminatorValue: "CAA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseCert{}), - DiscriminatorValue: "CERT", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseCNAME{}), - DiscriminatorValue: "CNAME", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseDNSKEY{}), - DiscriminatorValue: "DNSKEY", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseDS{}), - DiscriminatorValue: "DS", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseHTTPS{}), - DiscriminatorValue: "HTTPS", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseLOC{}), - DiscriminatorValue: "LOC", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseMX{}), - DiscriminatorValue: "MX", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseNAPTR{}), - DiscriminatorValue: "NAPTR", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseNS{}), - DiscriminatorValue: "NS", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponsePTR{}), - DiscriminatorValue: "PTR", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseSmimea{}), - DiscriminatorValue: "SMIMEA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseSRV{}), - DiscriminatorValue: "SRV", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseSSHFP{}), - DiscriminatorValue: "SSHFP", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseSVCB{}), - DiscriminatorValue: "SVCB", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseTLSA{}), - DiscriminatorValue: "TLSA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseTXT{}), - DiscriminatorValue: "TXT", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordUpdateResponseURI{}), - DiscriminatorValue: "URI", - }, - ) -} - -type DNSRecordUpdateResponseA struct { - // A valid IPv4 address. - Content string `json:"content,required" format:"ipv4"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordUpdateResponseAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied bool `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseAJSON `json:"-"` -} - -// dnsRecordUpdateResponseAJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseA] -type dnsRecordUpdateResponseAJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Proxied apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseA) implementsDNSRecordUpdateResponse() {} - -// Record type. -type DNSRecordUpdateResponseAType string - -const ( - DNSRecordUpdateResponseATypeA DNSRecordUpdateResponseAType = "A" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseAMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseAMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseAMeta] -type dnsRecordUpdateResponseAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordUpdateResponseATTLNumber]. -type DNSRecordUpdateResponseATTL interface { - ImplementsDNSRecordUpdateResponseAttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseATTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseATTLNumber float64 - -const ( - DNSRecordUpdateResponseATTLNumber1 DNSRecordUpdateResponseATTLNumber = 1 -) - -type DNSRecordUpdateResponseAAAA struct { - // A valid IPv6 address. - Content string `json:"content,required" format:"ipv6"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordUpdateResponseAAAAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseAAAAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied bool `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseAAAATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseAAAAJSON `json:"-"` -} - -// dnsRecordUpdateResponseAAAAJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseAAAA] -type dnsRecordUpdateResponseAAAAJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Proxied apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseAAAA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseAAAAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseAAAA) implementsDNSRecordUpdateResponse() {} - -// Record type. -type DNSRecordUpdateResponseAAAAType string - -const ( - DNSRecordUpdateResponseAAAATypeAAAA DNSRecordUpdateResponseAAAAType = "AAAA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseAAAAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseAAAAMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseAAAAMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseAAAAMeta] -type dnsRecordUpdateResponseAAAAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseAAAAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseAAAAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or -// [DNSRecordUpdateResponseAAAATTLNumber]. -type DNSRecordUpdateResponseAAAATTL interface { - ImplementsDNSRecordUpdateResponseAaaattl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseAAAATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseAAAATTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseAAAATTLNumber float64 - -const ( - DNSRecordUpdateResponseAAAATTLNumber1 DNSRecordUpdateResponseAAAATTLNumber = 1 -) - -type DNSRecordUpdateResponseCAA struct { - // Components of a CAA record. - Data DNSRecordUpdateResponseCAAData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordUpdateResponseCAAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted CAA content. See 'data' to set CAA properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseCAAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseCAATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseCAAJSON `json:"-"` -} - -// dnsRecordUpdateResponseCAAJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseCAA] -type dnsRecordUpdateResponseCAAJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseCAA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseCAAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseCAA) implementsDNSRecordUpdateResponse() {} - -// Components of a CAA record. -type DNSRecordUpdateResponseCAAData struct { - // Flags for the CAA record. - Flags float64 `json:"flags"` - // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). - Tag string `json:"tag"` - // Value of the record. This field's semantics depend on the chosen tag. - Value string `json:"value"` - JSON dnsRecordUpdateResponseCAADataJSON `json:"-"` -} - -// dnsRecordUpdateResponseCAADataJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseCAAData] -type dnsRecordUpdateResponseCAADataJSON struct { - Flags apijson.Field - Tag apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseCAAData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseCAADataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordUpdateResponseCAAType string - -const ( - DNSRecordUpdateResponseCAATypeCAA DNSRecordUpdateResponseCAAType = "CAA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseCAAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseCAAMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseCAAMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseCAAMeta] -type dnsRecordUpdateResponseCAAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseCAAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseCAAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordUpdateResponseCAATTLNumber]. -type DNSRecordUpdateResponseCAATTL interface { - ImplementsDNSRecordUpdateResponseCaattl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseCAATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseCAATTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseCAATTLNumber float64 - -const ( - DNSRecordUpdateResponseCAATTLNumber1 DNSRecordUpdateResponseCAATTLNumber = 1 -) - -type DNSRecordUpdateResponseCert struct { - // Components of a CERT record. - Data DNSRecordUpdateResponseCertData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordUpdateResponseCertType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted CERT content. See 'data' to set CERT properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseCertMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseCertTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseCertJSON `json:"-"` -} - -// dnsRecordUpdateResponseCertJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseCert] -type dnsRecordUpdateResponseCertJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseCert) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseCertJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseCert) implementsDNSRecordUpdateResponse() {} - -// Components of a CERT record. -type DNSRecordUpdateResponseCertData struct { - // Algorithm. - Algorithm float64 `json:"algorithm"` - // Certificate. - Certificate string `json:"certificate"` - // Key Tag. - KeyTag float64 `json:"key_tag"` - // Type. - Type float64 `json:"type"` - JSON dnsRecordUpdateResponseCertDataJSON `json:"-"` -} - -// dnsRecordUpdateResponseCertDataJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseCertData] -type dnsRecordUpdateResponseCertDataJSON struct { - Algorithm apijson.Field - Certificate apijson.Field - KeyTag apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseCertData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseCertDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordUpdateResponseCertType string - -const ( - DNSRecordUpdateResponseCertTypeCert DNSRecordUpdateResponseCertType = "CERT" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseCertMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseCertMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseCertMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseCertMeta] -type dnsRecordUpdateResponseCertMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseCertMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseCertMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or -// [DNSRecordUpdateResponseCertTTLNumber]. -type DNSRecordUpdateResponseCertTTL interface { - ImplementsDNSRecordUpdateResponseCertTTL() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseCertTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseCertTTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseCertTTLNumber float64 - -const ( - DNSRecordUpdateResponseCertTTLNumber1 DNSRecordUpdateResponseCertTTLNumber = 1 -) - -type DNSRecordUpdateResponseCNAME struct { - // A valid hostname. Must not match the record's name. - Content interface{} `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordUpdateResponseCNAMEType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseCNAMEMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied bool `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseCNAMETTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseCNAMEJSON `json:"-"` -} - -// dnsRecordUpdateResponseCNAMEJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseCNAME] -type dnsRecordUpdateResponseCNAMEJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Proxied apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseCNAME) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseCNAMEJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseCNAME) implementsDNSRecordUpdateResponse() {} - -// Record type. -type DNSRecordUpdateResponseCNAMEType string - -const ( - DNSRecordUpdateResponseCNAMETypeCNAME DNSRecordUpdateResponseCNAMEType = "CNAME" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseCNAMEMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseCNAMEMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseCNAMEMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseCNAMEMeta] -type dnsRecordUpdateResponseCNAMEMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseCNAMEMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseCNAMEMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or -// [DNSRecordUpdateResponseCNAMETTLNumber]. -type DNSRecordUpdateResponseCNAMETTL interface { - ImplementsDNSRecordUpdateResponseCnamettl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseCNAMETTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseCNAMETTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseCNAMETTLNumber float64 - -const ( - DNSRecordUpdateResponseCNAMETTLNumber1 DNSRecordUpdateResponseCNAMETTLNumber = 1 -) - -type DNSRecordUpdateResponseDNSKEY struct { - // Components of a DNSKEY record. - Data DNSRecordUpdateResponseDNSKEYData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordUpdateResponseDNSKEYType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted DNSKEY content. See 'data' to set DNSKEY properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseDNSKEYMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseDNSKEYTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseDNSKEYJSON `json:"-"` -} - -// dnsRecordUpdateResponseDNSKEYJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseDNSKEY] -type dnsRecordUpdateResponseDNSKEYJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseDNSKEY) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseDNSKEYJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseDNSKEY) implementsDNSRecordUpdateResponse() {} - -// Components of a DNSKEY record. -type DNSRecordUpdateResponseDNSKEYData struct { - // Algorithm. - Algorithm float64 `json:"algorithm"` - // Flags. - Flags float64 `json:"flags"` - // Protocol. - Protocol float64 `json:"protocol"` - // Public Key. - PublicKey string `json:"public_key"` - JSON dnsRecordUpdateResponseDNSKEYDataJSON `json:"-"` -} - -// dnsRecordUpdateResponseDNSKEYDataJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseDNSKEYData] -type dnsRecordUpdateResponseDNSKEYDataJSON struct { - Algorithm apijson.Field - Flags apijson.Field - Protocol apijson.Field - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseDNSKEYData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseDNSKEYDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordUpdateResponseDNSKEYType string - -const ( - DNSRecordUpdateResponseDNSKEYTypeDNSKEY DNSRecordUpdateResponseDNSKEYType = "DNSKEY" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseDNSKEYMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseDNSKEYMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseDNSKEYMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseDNSKEYMeta] -type dnsRecordUpdateResponseDNSKEYMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseDNSKEYMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseDNSKEYMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or -// [DNSRecordUpdateResponseDNSKEYTTLNumber]. -type DNSRecordUpdateResponseDNSKEYTTL interface { - ImplementsDNSRecordUpdateResponseDnskeyttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseDNSKEYTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseDNSKEYTTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseDNSKEYTTLNumber float64 - -const ( - DNSRecordUpdateResponseDNSKEYTTLNumber1 DNSRecordUpdateResponseDNSKEYTTLNumber = 1 -) - -type DNSRecordUpdateResponseDS struct { - // Components of a DS record. - Data DNSRecordUpdateResponseDSData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordUpdateResponseDSType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted DS content. See 'data' to set DS properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseDSMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseDSTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseDSJSON `json:"-"` -} - -// dnsRecordUpdateResponseDSJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseDS] -type dnsRecordUpdateResponseDSJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseDS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseDSJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseDS) implementsDNSRecordUpdateResponse() {} - -// Components of a DS record. -type DNSRecordUpdateResponseDSData struct { - // Algorithm. - Algorithm float64 `json:"algorithm"` - // Digest. - Digest string `json:"digest"` - // Digest Type. - DigestType float64 `json:"digest_type"` - // Key Tag. - KeyTag float64 `json:"key_tag"` - JSON dnsRecordUpdateResponseDSDataJSON `json:"-"` -} - -// dnsRecordUpdateResponseDSDataJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseDSData] -type dnsRecordUpdateResponseDSDataJSON struct { - Algorithm apijson.Field - Digest apijson.Field - DigestType apijson.Field - KeyTag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseDSData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseDSDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordUpdateResponseDSType string - -const ( - DNSRecordUpdateResponseDSTypeDS DNSRecordUpdateResponseDSType = "DS" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseDSMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseDSMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseDSMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseDSMeta] -type dnsRecordUpdateResponseDSMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseDSMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseDSMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordUpdateResponseDSTTLNumber]. -type DNSRecordUpdateResponseDSTTL interface { - ImplementsDNSRecordUpdateResponseDsttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseDSTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseDSTTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseDSTTLNumber float64 - -const ( - DNSRecordUpdateResponseDSTTLNumber1 DNSRecordUpdateResponseDSTTLNumber = 1 -) - -type DNSRecordUpdateResponseHTTPS struct { - // Components of a HTTPS record. - Data DNSRecordUpdateResponseHTTPSData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordUpdateResponseHTTPSType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted HTTPS content. See 'data' to set HTTPS properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseHTTPSMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseHTTPSTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseHTTPSJSON `json:"-"` -} - -// dnsRecordUpdateResponseHTTPSJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseHTTPS] -type dnsRecordUpdateResponseHTTPSJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseHTTPS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseHTTPSJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseHTTPS) implementsDNSRecordUpdateResponse() {} - -// Components of a HTTPS record. -type DNSRecordUpdateResponseHTTPSData struct { - // priority. - Priority float64 `json:"priority"` - // target. - Target string `json:"target"` - // value. - Value string `json:"value"` - JSON dnsRecordUpdateResponseHTTPSDataJSON `json:"-"` -} - -// dnsRecordUpdateResponseHTTPSDataJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseHTTPSData] -type dnsRecordUpdateResponseHTTPSDataJSON struct { - Priority apijson.Field - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseHTTPSData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseHTTPSDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordUpdateResponseHTTPSType string - -const ( - DNSRecordUpdateResponseHTTPSTypeHTTPS DNSRecordUpdateResponseHTTPSType = "HTTPS" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseHTTPSMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseHTTPSMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseHTTPSMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseHTTPSMeta] -type dnsRecordUpdateResponseHTTPSMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseHTTPSMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseHTTPSMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or -// [DNSRecordUpdateResponseHTTPSTTLNumber]. -type DNSRecordUpdateResponseHTTPSTTL interface { - ImplementsDNSRecordUpdateResponseHttpsttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseHTTPSTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseHTTPSTTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseHTTPSTTLNumber float64 - -const ( - DNSRecordUpdateResponseHTTPSTTLNumber1 DNSRecordUpdateResponseHTTPSTTLNumber = 1 -) - -type DNSRecordUpdateResponseLOC struct { - // Components of a LOC record. - Data DNSRecordUpdateResponseLOCData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordUpdateResponseLOCType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted LOC content. See 'data' to set LOC properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseLOCMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseLOCTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseLOCJSON `json:"-"` -} - -// dnsRecordUpdateResponseLOCJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseLOC] -type dnsRecordUpdateResponseLOCJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseLOC) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseLOCJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseLOC) implementsDNSRecordUpdateResponse() {} - -// Components of a LOC record. -type DNSRecordUpdateResponseLOCData struct { - // Altitude of location in meters. - Altitude float64 `json:"altitude"` - // Degrees of latitude. - LatDegrees float64 `json:"lat_degrees"` - // Latitude direction. - LatDirection DNSRecordUpdateResponseLOCDataLatDirection `json:"lat_direction"` - // Minutes of latitude. - LatMinutes float64 `json:"lat_minutes"` - // Seconds of latitude. - LatSeconds float64 `json:"lat_seconds"` - // Degrees of longitude. - LongDegrees float64 `json:"long_degrees"` - // Longitude direction. - LongDirection DNSRecordUpdateResponseLOCDataLongDirection `json:"long_direction"` - // Minutes of longitude. - LongMinutes float64 `json:"long_minutes"` - // Seconds of longitude. - LongSeconds float64 `json:"long_seconds"` - // Horizontal precision of location. - PrecisionHorz float64 `json:"precision_horz"` - // Vertical precision of location. - PrecisionVert float64 `json:"precision_vert"` - // Size of location in meters. - Size float64 `json:"size"` - JSON dnsRecordUpdateResponseLOCDataJSON `json:"-"` -} - -// dnsRecordUpdateResponseLOCDataJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseLOCData] -type dnsRecordUpdateResponseLOCDataJSON struct { - Altitude apijson.Field - LatDegrees apijson.Field - LatDirection apijson.Field - LatMinutes apijson.Field - LatSeconds apijson.Field - LongDegrees apijson.Field - LongDirection apijson.Field - LongMinutes apijson.Field - LongSeconds apijson.Field - PrecisionHorz apijson.Field - PrecisionVert apijson.Field - Size apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseLOCData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseLOCDataJSON) RawJSON() string { - return r.raw -} - -// Latitude direction. -type DNSRecordUpdateResponseLOCDataLatDirection string - -const ( - DNSRecordUpdateResponseLOCDataLatDirectionN DNSRecordUpdateResponseLOCDataLatDirection = "N" - DNSRecordUpdateResponseLOCDataLatDirectionS DNSRecordUpdateResponseLOCDataLatDirection = "S" -) - -// Longitude direction. -type DNSRecordUpdateResponseLOCDataLongDirection string - -const ( - DNSRecordUpdateResponseLOCDataLongDirectionE DNSRecordUpdateResponseLOCDataLongDirection = "E" - DNSRecordUpdateResponseLOCDataLongDirectionW DNSRecordUpdateResponseLOCDataLongDirection = "W" -) - -// Record type. -type DNSRecordUpdateResponseLOCType string - -const ( - DNSRecordUpdateResponseLOCTypeLOC DNSRecordUpdateResponseLOCType = "LOC" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseLOCMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseLOCMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseLOCMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseLOCMeta] -type dnsRecordUpdateResponseLOCMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseLOCMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseLOCMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordUpdateResponseLOCTTLNumber]. -type DNSRecordUpdateResponseLOCTTL interface { - ImplementsDNSRecordUpdateResponseLocttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseLOCTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseLOCTTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseLOCTTLNumber float64 - -const ( - DNSRecordUpdateResponseLOCTTLNumber1 DNSRecordUpdateResponseLOCTTLNumber = 1 -) - -type DNSRecordUpdateResponseMX struct { - // A valid mail server hostname. - Content string `json:"content,required" format:"hostname"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority float64 `json:"priority,required"` - // Record type. - Type DNSRecordUpdateResponseMXType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseMXMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseMXTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseMXJSON `json:"-"` -} - -// dnsRecordUpdateResponseMXJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseMX] -type dnsRecordUpdateResponseMXJSON struct { - Content apijson.Field - Name apijson.Field - Priority apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseMX) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseMXJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseMX) implementsDNSRecordUpdateResponse() {} - -// Record type. -type DNSRecordUpdateResponseMXType string - -const ( - DNSRecordUpdateResponseMXTypeMX DNSRecordUpdateResponseMXType = "MX" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseMXMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseMXMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseMXMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseMXMeta] -type dnsRecordUpdateResponseMXMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseMXMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseMXMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordUpdateResponseMXTTLNumber]. -type DNSRecordUpdateResponseMXTTL interface { - ImplementsDNSRecordUpdateResponseMxttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseMXTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseMXTTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseMXTTLNumber float64 - -const ( - DNSRecordUpdateResponseMXTTLNumber1 DNSRecordUpdateResponseMXTTLNumber = 1 -) - -type DNSRecordUpdateResponseNAPTR struct { - // Components of a NAPTR record. - Data DNSRecordUpdateResponseNAPTRData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordUpdateResponseNAPTRType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted NAPTR content. See 'data' to set NAPTR properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseNAPTRMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseNAPTRTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseNAPTRJSON `json:"-"` -} - -// dnsRecordUpdateResponseNAPTRJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseNAPTR] -type dnsRecordUpdateResponseNAPTRJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseNAPTR) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseNAPTRJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseNAPTR) implementsDNSRecordUpdateResponse() {} - -// Components of a NAPTR record. -type DNSRecordUpdateResponseNAPTRData struct { - // Flags. - Flags string `json:"flags"` - // Order. - Order float64 `json:"order"` - // Preference. - Preference float64 `json:"preference"` - // Regex. - Regex string `json:"regex"` - // Replacement. - Replacement string `json:"replacement"` - // Service. - Service string `json:"service"` - JSON dnsRecordUpdateResponseNAPTRDataJSON `json:"-"` -} - -// dnsRecordUpdateResponseNAPTRDataJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseNAPTRData] -type dnsRecordUpdateResponseNAPTRDataJSON struct { - Flags apijson.Field - Order apijson.Field - Preference apijson.Field - Regex apijson.Field - Replacement apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseNAPTRData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseNAPTRDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordUpdateResponseNAPTRType string - -const ( - DNSRecordUpdateResponseNAPTRTypeNAPTR DNSRecordUpdateResponseNAPTRType = "NAPTR" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseNAPTRMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseNAPTRMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseNAPTRMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseNAPTRMeta] -type dnsRecordUpdateResponseNAPTRMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseNAPTRMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseNAPTRMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or -// [DNSRecordUpdateResponseNAPTRTTLNumber]. -type DNSRecordUpdateResponseNAPTRTTL interface { - ImplementsDNSRecordUpdateResponseNaptrttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseNAPTRTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseNAPTRTTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseNAPTRTTLNumber float64 - -const ( - DNSRecordUpdateResponseNAPTRTTLNumber1 DNSRecordUpdateResponseNAPTRTTLNumber = 1 -) - -type DNSRecordUpdateResponseNS struct { - // A valid name server host name. - Content interface{} `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordUpdateResponseNSType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseNSMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseNSTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseNSJSON `json:"-"` -} - -// dnsRecordUpdateResponseNSJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseNS] -type dnsRecordUpdateResponseNSJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseNSJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseNS) implementsDNSRecordUpdateResponse() {} - -// Record type. -type DNSRecordUpdateResponseNSType string - -const ( - DNSRecordUpdateResponseNSTypeNS DNSRecordUpdateResponseNSType = "NS" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseNSMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseNSMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseNSMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseNSMeta] -type dnsRecordUpdateResponseNSMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseNSMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseNSMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordUpdateResponseNSTTLNumber]. -type DNSRecordUpdateResponseNSTTL interface { - ImplementsDNSRecordUpdateResponseNsttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseNSTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseNSTTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseNSTTLNumber float64 - -const ( - DNSRecordUpdateResponseNSTTLNumber1 DNSRecordUpdateResponseNSTTLNumber = 1 -) - -type DNSRecordUpdateResponsePTR struct { - // Domain name pointing to the address. - Content string `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordUpdateResponsePTRType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponsePTRMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponsePTRTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponsePTRJSON `json:"-"` -} - -// dnsRecordUpdateResponsePTRJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponsePTR] -type dnsRecordUpdateResponsePTRJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponsePTR) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponsePTRJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponsePTR) implementsDNSRecordUpdateResponse() {} - -// Record type. -type DNSRecordUpdateResponsePTRType string - -const ( - DNSRecordUpdateResponsePTRTypePTR DNSRecordUpdateResponsePTRType = "PTR" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponsePTRMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponsePTRMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponsePTRMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponsePTRMeta] -type dnsRecordUpdateResponsePTRMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponsePTRMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponsePTRMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordUpdateResponsePTRTTLNumber]. -type DNSRecordUpdateResponsePTRTTL interface { - ImplementsDNSRecordUpdateResponsePtrttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponsePTRTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponsePTRTTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponsePTRTTLNumber float64 - -const ( - DNSRecordUpdateResponsePTRTTLNumber1 DNSRecordUpdateResponsePTRTTLNumber = 1 -) - -type DNSRecordUpdateResponseSmimea struct { - // Components of a SMIMEA record. - Data DNSRecordUpdateResponseSmimeaData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordUpdateResponseSmimeaType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted SMIMEA content. See 'data' to set SMIMEA properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseSmimeaMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseSmimeaTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseSmimeaJSON `json:"-"` -} - -// dnsRecordUpdateResponseSmimeaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseSmimea] -type dnsRecordUpdateResponseSmimeaJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseSmimea) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseSmimeaJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseSmimea) implementsDNSRecordUpdateResponse() {} - -// Components of a SMIMEA record. -type DNSRecordUpdateResponseSmimeaData struct { - // Certificate. - Certificate string `json:"certificate"` - // Matching Type. - MatchingType float64 `json:"matching_type"` - // Selector. - Selector float64 `json:"selector"` - // Usage. - Usage float64 `json:"usage"` - JSON dnsRecordUpdateResponseSmimeaDataJSON `json:"-"` -} - -// dnsRecordUpdateResponseSmimeaDataJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseSmimeaData] -type dnsRecordUpdateResponseSmimeaDataJSON struct { - Certificate apijson.Field - MatchingType apijson.Field - Selector apijson.Field - Usage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseSmimeaData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseSmimeaDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordUpdateResponseSmimeaType string - -const ( - DNSRecordUpdateResponseSmimeaTypeSmimea DNSRecordUpdateResponseSmimeaType = "SMIMEA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseSmimeaMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseSmimeaMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseSmimeaMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseSmimeaMeta] -type dnsRecordUpdateResponseSmimeaMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseSmimeaMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseSmimeaMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or -// [DNSRecordUpdateResponseSmimeaTTLNumber]. -type DNSRecordUpdateResponseSmimeaTTL interface { - ImplementsDNSRecordUpdateResponseSmimeaTTL() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseSmimeaTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseSmimeaTTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseSmimeaTTLNumber float64 - -const ( - DNSRecordUpdateResponseSmimeaTTLNumber1 DNSRecordUpdateResponseSmimeaTTLNumber = 1 -) - -type DNSRecordUpdateResponseSRV struct { - // Components of a SRV record. - Data DNSRecordUpdateResponseSRVData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. For SRV records, the first - // label is normally a service and the second a protocol name, each starting with - // an underscore. - Name string `json:"name,required"` - // Record type. - Type DNSRecordUpdateResponseSRVType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Priority, weight, port, and SRV target. See 'data' for setting the individual - // component values. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseSRVMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseSRVTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseSRVJSON `json:"-"` -} - -// dnsRecordUpdateResponseSRVJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseSRV] -type dnsRecordUpdateResponseSRVJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseSRV) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseSRVJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseSRV) implementsDNSRecordUpdateResponse() {} - -// Components of a SRV record. -type DNSRecordUpdateResponseSRVData struct { - // A valid hostname. Deprecated in favor of the regular 'name' outside the data - // map. This data map field represents the remainder of the full 'name' after the - // service and protocol. - Name string `json:"name" format:"hostname"` - // The port of the service. - Port float64 `json:"port"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority float64 `json:"priority"` - // A valid protocol, prefixed with an underscore. Deprecated in favor of the - // regular 'name' outside the data map. This data map field normally represents the - // second label of that 'name'. - Proto string `json:"proto"` - // A service type, prefixed with an underscore. Deprecated in favor of the regular - // 'name' outside the data map. This data map field normally represents the first - // label of that 'name'. - Service string `json:"service"` - // A valid hostname. - Target string `json:"target" format:"hostname"` - // The record weight. - Weight float64 `json:"weight"` - JSON dnsRecordUpdateResponseSRVDataJSON `json:"-"` -} - -// dnsRecordUpdateResponseSRVDataJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseSRVData] -type dnsRecordUpdateResponseSRVDataJSON struct { - Name apijson.Field - Port apijson.Field - Priority apijson.Field - Proto apijson.Field - Service apijson.Field - Target apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseSRVData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseSRVDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordUpdateResponseSRVType string - -const ( - DNSRecordUpdateResponseSRVTypeSRV DNSRecordUpdateResponseSRVType = "SRV" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseSRVMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseSRVMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseSRVMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseSRVMeta] -type dnsRecordUpdateResponseSRVMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseSRVMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseSRVMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordUpdateResponseSRVTTLNumber]. -type DNSRecordUpdateResponseSRVTTL interface { - ImplementsDNSRecordUpdateResponseSrvttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseSRVTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseSRVTTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseSRVTTLNumber float64 - -const ( - DNSRecordUpdateResponseSRVTTLNumber1 DNSRecordUpdateResponseSRVTTLNumber = 1 -) - -type DNSRecordUpdateResponseSSHFP struct { - // Components of a SSHFP record. - Data DNSRecordUpdateResponseSSHFPData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordUpdateResponseSSHFPType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted SSHFP content. See 'data' to set SSHFP properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseSSHFPMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseSSHFPTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseSSHFPJSON `json:"-"` -} - -// dnsRecordUpdateResponseSSHFPJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseSSHFP] -type dnsRecordUpdateResponseSSHFPJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseSSHFP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseSSHFPJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseSSHFP) implementsDNSRecordUpdateResponse() {} - -// Components of a SSHFP record. -type DNSRecordUpdateResponseSSHFPData struct { - // algorithm. - Algorithm float64 `json:"algorithm"` - // fingerprint. - Fingerprint string `json:"fingerprint"` - // type. - Type float64 `json:"type"` - JSON dnsRecordUpdateResponseSSHFPDataJSON `json:"-"` -} - -// dnsRecordUpdateResponseSSHFPDataJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseSSHFPData] -type dnsRecordUpdateResponseSSHFPDataJSON struct { - Algorithm apijson.Field - Fingerprint apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseSSHFPData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseSSHFPDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordUpdateResponseSSHFPType string - -const ( - DNSRecordUpdateResponseSSHFPTypeSSHFP DNSRecordUpdateResponseSSHFPType = "SSHFP" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseSSHFPMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseSSHFPMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseSSHFPMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseSSHFPMeta] -type dnsRecordUpdateResponseSSHFPMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseSSHFPMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseSSHFPMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or -// [DNSRecordUpdateResponseSSHFPTTLNumber]. -type DNSRecordUpdateResponseSSHFPTTL interface { - ImplementsDNSRecordUpdateResponseSshfpttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseSSHFPTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseSSHFPTTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseSSHFPTTLNumber float64 - -const ( - DNSRecordUpdateResponseSSHFPTTLNumber1 DNSRecordUpdateResponseSSHFPTTLNumber = 1 -) - -type DNSRecordUpdateResponseSVCB struct { - // Components of a SVCB record. - Data DNSRecordUpdateResponseSVCBData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordUpdateResponseSVCBType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted SVCB content. See 'data' to set SVCB properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseSVCBMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseSVCBTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseSVCBJSON `json:"-"` -} - -// dnsRecordUpdateResponseSVCBJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseSVCB] -type dnsRecordUpdateResponseSVCBJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseSVCB) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseSVCBJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseSVCB) implementsDNSRecordUpdateResponse() {} - -// Components of a SVCB record. -type DNSRecordUpdateResponseSVCBData struct { - // priority. - Priority float64 `json:"priority"` - // target. - Target string `json:"target"` - // value. - Value string `json:"value"` - JSON dnsRecordUpdateResponseSVCBDataJSON `json:"-"` -} - -// dnsRecordUpdateResponseSVCBDataJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseSVCBData] -type dnsRecordUpdateResponseSVCBDataJSON struct { - Priority apijson.Field - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseSVCBData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseSVCBDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordUpdateResponseSVCBType string - -const ( - DNSRecordUpdateResponseSVCBTypeSVCB DNSRecordUpdateResponseSVCBType = "SVCB" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseSVCBMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseSVCBMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseSVCBMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseSVCBMeta] -type dnsRecordUpdateResponseSVCBMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseSVCBMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseSVCBMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or -// [DNSRecordUpdateResponseSVCBTTLNumber]. -type DNSRecordUpdateResponseSVCBTTL interface { - ImplementsDNSRecordUpdateResponseSvcbttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseSVCBTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseSVCBTTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseSVCBTTLNumber float64 - -const ( - DNSRecordUpdateResponseSVCBTTLNumber1 DNSRecordUpdateResponseSVCBTTLNumber = 1 -) - -type DNSRecordUpdateResponseTLSA struct { - // Components of a TLSA record. - Data DNSRecordUpdateResponseTLSAData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordUpdateResponseTLSAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted TLSA content. See 'data' to set TLSA properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseTLSAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseTLSATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseTLSAJSON `json:"-"` -} - -// dnsRecordUpdateResponseTLSAJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseTLSA] -type dnsRecordUpdateResponseTLSAJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseTLSA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseTLSAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseTLSA) implementsDNSRecordUpdateResponse() {} - -// Components of a TLSA record. -type DNSRecordUpdateResponseTLSAData struct { - // certificate. - Certificate string `json:"certificate"` - // Matching Type. - MatchingType float64 `json:"matching_type"` - // Selector. - Selector float64 `json:"selector"` - // Usage. - Usage float64 `json:"usage"` - JSON dnsRecordUpdateResponseTLSADataJSON `json:"-"` -} - -// dnsRecordUpdateResponseTLSADataJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseTLSAData] -type dnsRecordUpdateResponseTLSADataJSON struct { - Certificate apijson.Field - MatchingType apijson.Field - Selector apijson.Field - Usage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseTLSAData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseTLSADataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordUpdateResponseTLSAType string - -const ( - DNSRecordUpdateResponseTLSATypeTLSA DNSRecordUpdateResponseTLSAType = "TLSA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseTLSAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseTLSAMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseTLSAMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseTLSAMeta] -type dnsRecordUpdateResponseTLSAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseTLSAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseTLSAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or -// [DNSRecordUpdateResponseTLSATTLNumber]. -type DNSRecordUpdateResponseTLSATTL interface { - ImplementsDNSRecordUpdateResponseTlsattl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseTLSATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseTLSATTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseTLSATTLNumber float64 - -const ( - DNSRecordUpdateResponseTLSATTLNumber1 DNSRecordUpdateResponseTLSATTLNumber = 1 -) - -type DNSRecordUpdateResponseTXT struct { - // Text content for the record. - Content string `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordUpdateResponseTXTType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseTXTMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseTXTTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseTXTJSON `json:"-"` -} - -// dnsRecordUpdateResponseTXTJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseTXT] -type dnsRecordUpdateResponseTXTJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseTXT) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseTXTJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseTXT) implementsDNSRecordUpdateResponse() {} - -// Record type. -type DNSRecordUpdateResponseTXTType string - -const ( - DNSRecordUpdateResponseTXTTypeTXT DNSRecordUpdateResponseTXTType = "TXT" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseTXTMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseTXTMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseTXTMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseTXTMeta] -type dnsRecordUpdateResponseTXTMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseTXTMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseTXTMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordUpdateResponseTXTTTLNumber]. -type DNSRecordUpdateResponseTXTTTL interface { - ImplementsDNSRecordUpdateResponseTxtttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseTXTTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseTXTTTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseTXTTTLNumber float64 - -const ( - DNSRecordUpdateResponseTXTTTLNumber1 DNSRecordUpdateResponseTXTTTLNumber = 1 -) - -type DNSRecordUpdateResponseURI struct { - // Components of a URI record. - Data DNSRecordUpdateResponseURIData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority float64 `json:"priority,required"` - // Record type. - Type DNSRecordUpdateResponseURIType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted URI content. See 'data' to set URI properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordUpdateResponseURIMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordUpdateResponseURITTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordUpdateResponseURIJSON `json:"-"` -} - -// dnsRecordUpdateResponseURIJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseURI] -type dnsRecordUpdateResponseURIJSON struct { - Data apijson.Field - Name apijson.Field - Priority apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseURI) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseURIJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordUpdateResponseURI) implementsDNSRecordUpdateResponse() {} - -// Components of a URI record. -type DNSRecordUpdateResponseURIData struct { - // The record content. - Content string `json:"content"` - // The record weight. - Weight float64 `json:"weight"` - JSON dnsRecordUpdateResponseURIDataJSON `json:"-"` -} - -// dnsRecordUpdateResponseURIDataJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseURIData] -type dnsRecordUpdateResponseURIDataJSON struct { - Content apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseURIData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseURIDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordUpdateResponseURIType string - -const ( - DNSRecordUpdateResponseURITypeURI DNSRecordUpdateResponseURIType = "URI" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordUpdateResponseURIMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordUpdateResponseURIMetaJSON `json:"-"` -} - -// dnsRecordUpdateResponseURIMetaJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseURIMeta] -type dnsRecordUpdateResponseURIMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseURIMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseURIMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordUpdateResponseURITTLNumber]. -type DNSRecordUpdateResponseURITTL interface { - ImplementsDNSRecordUpdateResponseUrittl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordUpdateResponseURITTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordUpdateResponseURITTLNumber(0)), - }, - ) -} - -type DNSRecordUpdateResponseURITTLNumber float64 - -const ( - DNSRecordUpdateResponseURITTLNumber1 DNSRecordUpdateResponseURITTLNumber = 1 -) - -// Union satisfied by [DNSRecordListResponseA], [DNSRecordListResponseAAAA], -// [DNSRecordListResponseCAA], [DNSRecordListResponseCert], -// [DNSRecordListResponseCNAME], [DNSRecordListResponseDNSKEY], -// [DNSRecordListResponseDS], [DNSRecordListResponseHTTPS], -// [DNSRecordListResponseLOC], [DNSRecordListResponseMX], -// [DNSRecordListResponseNAPTR], [DNSRecordListResponseNS], -// [DNSRecordListResponsePTR], [DNSRecordListResponseSmimea], -// [DNSRecordListResponseSRV], [DNSRecordListResponseSSHFP], -// [DNSRecordListResponseSVCB], [DNSRecordListResponseTLSA], -// [DNSRecordListResponseTXT] or [DNSRecordListResponseURI]. -type DNSRecordListResponse interface { - implementsDNSRecordListResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponse)(nil)).Elem(), - "type", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseA{}), - DiscriminatorValue: "A", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseAAAA{}), - DiscriminatorValue: "AAAA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseCAA{}), - DiscriminatorValue: "CAA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseCert{}), - DiscriminatorValue: "CERT", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseCNAME{}), - DiscriminatorValue: "CNAME", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseDNSKEY{}), - DiscriminatorValue: "DNSKEY", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseDS{}), - DiscriminatorValue: "DS", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseHTTPS{}), - DiscriminatorValue: "HTTPS", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseLOC{}), - DiscriminatorValue: "LOC", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseMX{}), - DiscriminatorValue: "MX", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseNAPTR{}), - DiscriminatorValue: "NAPTR", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseNS{}), - DiscriminatorValue: "NS", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponsePTR{}), - DiscriminatorValue: "PTR", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseSmimea{}), - DiscriminatorValue: "SMIMEA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseSRV{}), - DiscriminatorValue: "SRV", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseSSHFP{}), - DiscriminatorValue: "SSHFP", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseSVCB{}), - DiscriminatorValue: "SVCB", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseTLSA{}), - DiscriminatorValue: "TLSA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseTXT{}), - DiscriminatorValue: "TXT", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordListResponseURI{}), - DiscriminatorValue: "URI", - }, - ) -} - -type DNSRecordListResponseA struct { - // A valid IPv4 address. - Content string `json:"content,required" format:"ipv4"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordListResponseAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied bool `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseAJSON `json:"-"` -} - -// dnsRecordListResponseAJSON contains the JSON metadata for the struct -// [DNSRecordListResponseA] -type dnsRecordListResponseAJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Proxied apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseA) implementsDNSRecordListResponse() {} - -// Record type. -type DNSRecordListResponseAType string - -const ( - DNSRecordListResponseATypeA DNSRecordListResponseAType = "A" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseAMetaJSON `json:"-"` -} - -// dnsRecordListResponseAMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseAMeta] -type dnsRecordListResponseAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordListResponseATTLNumber]. -type DNSRecordListResponseATTL interface { - ImplementsDNSRecordListResponseAttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseATTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseATTLNumber float64 - -const ( - DNSRecordListResponseATTLNumber1 DNSRecordListResponseATTLNumber = 1 -) - -type DNSRecordListResponseAAAA struct { - // A valid IPv6 address. - Content string `json:"content,required" format:"ipv6"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordListResponseAAAAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseAAAAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied bool `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseAAAATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseAAAAJSON `json:"-"` -} - -// dnsRecordListResponseAAAAJSON contains the JSON metadata for the struct -// [DNSRecordListResponseAAAA] -type dnsRecordListResponseAAAAJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Proxied apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseAAAA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseAAAAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseAAAA) implementsDNSRecordListResponse() {} - -// Record type. -type DNSRecordListResponseAAAAType string - -const ( - DNSRecordListResponseAAAATypeAAAA DNSRecordListResponseAAAAType = "AAAA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseAAAAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseAAAAMetaJSON `json:"-"` -} - -// dnsRecordListResponseAAAAMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseAAAAMeta] -type dnsRecordListResponseAAAAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseAAAAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseAAAAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordListResponseAAAATTLNumber]. -type DNSRecordListResponseAAAATTL interface { - ImplementsDNSRecordListResponseAaaattl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseAAAATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseAAAATTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseAAAATTLNumber float64 - -const ( - DNSRecordListResponseAAAATTLNumber1 DNSRecordListResponseAAAATTLNumber = 1 -) - -type DNSRecordListResponseCAA struct { - // Components of a CAA record. - Data DNSRecordListResponseCAAData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordListResponseCAAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted CAA content. See 'data' to set CAA properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseCAAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseCAATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseCAAJSON `json:"-"` -} - -// dnsRecordListResponseCAAJSON contains the JSON metadata for the struct -// [DNSRecordListResponseCAA] -type dnsRecordListResponseCAAJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseCAA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseCAAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseCAA) implementsDNSRecordListResponse() {} - -// Components of a CAA record. -type DNSRecordListResponseCAAData struct { - // Flags for the CAA record. - Flags float64 `json:"flags"` - // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). - Tag string `json:"tag"` - // Value of the record. This field's semantics depend on the chosen tag. - Value string `json:"value"` - JSON dnsRecordListResponseCAADataJSON `json:"-"` -} - -// dnsRecordListResponseCAADataJSON contains the JSON metadata for the struct -// [DNSRecordListResponseCAAData] -type dnsRecordListResponseCAADataJSON struct { - Flags apijson.Field - Tag apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseCAAData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseCAADataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordListResponseCAAType string - -const ( - DNSRecordListResponseCAATypeCAA DNSRecordListResponseCAAType = "CAA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseCAAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseCAAMetaJSON `json:"-"` -} - -// dnsRecordListResponseCAAMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseCAAMeta] -type dnsRecordListResponseCAAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseCAAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseCAAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordListResponseCAATTLNumber]. -type DNSRecordListResponseCAATTL interface { - ImplementsDNSRecordListResponseCaattl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseCAATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseCAATTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseCAATTLNumber float64 - -const ( - DNSRecordListResponseCAATTLNumber1 DNSRecordListResponseCAATTLNumber = 1 -) - -type DNSRecordListResponseCert struct { - // Components of a CERT record. - Data DNSRecordListResponseCertData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordListResponseCertType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted CERT content. See 'data' to set CERT properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseCertMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseCertTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseCertJSON `json:"-"` -} - -// dnsRecordListResponseCertJSON contains the JSON metadata for the struct -// [DNSRecordListResponseCert] -type dnsRecordListResponseCertJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseCert) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseCertJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseCert) implementsDNSRecordListResponse() {} - -// Components of a CERT record. -type DNSRecordListResponseCertData struct { - // Algorithm. - Algorithm float64 `json:"algorithm"` - // Certificate. - Certificate string `json:"certificate"` - // Key Tag. - KeyTag float64 `json:"key_tag"` - // Type. - Type float64 `json:"type"` - JSON dnsRecordListResponseCertDataJSON `json:"-"` -} - -// dnsRecordListResponseCertDataJSON contains the JSON metadata for the struct -// [DNSRecordListResponseCertData] -type dnsRecordListResponseCertDataJSON struct { - Algorithm apijson.Field - Certificate apijson.Field - KeyTag apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseCertData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseCertDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordListResponseCertType string - -const ( - DNSRecordListResponseCertTypeCert DNSRecordListResponseCertType = "CERT" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseCertMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseCertMetaJSON `json:"-"` -} - -// dnsRecordListResponseCertMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseCertMeta] -type dnsRecordListResponseCertMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseCertMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseCertMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordListResponseCertTTLNumber]. -type DNSRecordListResponseCertTTL interface { - ImplementsDNSRecordListResponseCertTTL() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseCertTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseCertTTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseCertTTLNumber float64 - -const ( - DNSRecordListResponseCertTTLNumber1 DNSRecordListResponseCertTTLNumber = 1 -) - -type DNSRecordListResponseCNAME struct { - // A valid hostname. Must not match the record's name. - Content interface{} `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordListResponseCNAMEType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseCNAMEMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied bool `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseCNAMETTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseCNAMEJSON `json:"-"` -} - -// dnsRecordListResponseCNAMEJSON contains the JSON metadata for the struct -// [DNSRecordListResponseCNAME] -type dnsRecordListResponseCNAMEJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Proxied apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseCNAME) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseCNAMEJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseCNAME) implementsDNSRecordListResponse() {} - -// Record type. -type DNSRecordListResponseCNAMEType string - -const ( - DNSRecordListResponseCNAMETypeCNAME DNSRecordListResponseCNAMEType = "CNAME" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseCNAMEMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseCNAMEMetaJSON `json:"-"` -} - -// dnsRecordListResponseCNAMEMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseCNAMEMeta] -type dnsRecordListResponseCNAMEMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseCNAMEMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseCNAMEMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordListResponseCNAMETTLNumber]. -type DNSRecordListResponseCNAMETTL interface { - ImplementsDNSRecordListResponseCnamettl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseCNAMETTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseCNAMETTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseCNAMETTLNumber float64 - -const ( - DNSRecordListResponseCNAMETTLNumber1 DNSRecordListResponseCNAMETTLNumber = 1 -) - -type DNSRecordListResponseDNSKEY struct { - // Components of a DNSKEY record. - Data DNSRecordListResponseDNSKEYData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordListResponseDNSKEYType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted DNSKEY content. See 'data' to set DNSKEY properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseDNSKEYMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseDNSKEYTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseDNSKEYJSON `json:"-"` -} - -// dnsRecordListResponseDNSKEYJSON contains the JSON metadata for the struct -// [DNSRecordListResponseDNSKEY] -type dnsRecordListResponseDNSKEYJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseDNSKEY) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseDNSKEYJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseDNSKEY) implementsDNSRecordListResponse() {} - -// Components of a DNSKEY record. -type DNSRecordListResponseDNSKEYData struct { - // Algorithm. - Algorithm float64 `json:"algorithm"` - // Flags. - Flags float64 `json:"flags"` - // Protocol. - Protocol float64 `json:"protocol"` - // Public Key. - PublicKey string `json:"public_key"` - JSON dnsRecordListResponseDNSKEYDataJSON `json:"-"` -} - -// dnsRecordListResponseDNSKEYDataJSON contains the JSON metadata for the struct -// [DNSRecordListResponseDNSKEYData] -type dnsRecordListResponseDNSKEYDataJSON struct { - Algorithm apijson.Field - Flags apijson.Field - Protocol apijson.Field - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseDNSKEYData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseDNSKEYDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordListResponseDNSKEYType string - -const ( - DNSRecordListResponseDNSKEYTypeDNSKEY DNSRecordListResponseDNSKEYType = "DNSKEY" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseDNSKEYMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseDNSKEYMetaJSON `json:"-"` -} - -// dnsRecordListResponseDNSKEYMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseDNSKEYMeta] -type dnsRecordListResponseDNSKEYMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseDNSKEYMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseDNSKEYMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or -// [DNSRecordListResponseDNSKEYTTLNumber]. -type DNSRecordListResponseDNSKEYTTL interface { - ImplementsDNSRecordListResponseDnskeyttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseDNSKEYTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseDNSKEYTTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseDNSKEYTTLNumber float64 - -const ( - DNSRecordListResponseDNSKEYTTLNumber1 DNSRecordListResponseDNSKEYTTLNumber = 1 -) - -type DNSRecordListResponseDS struct { - // Components of a DS record. - Data DNSRecordListResponseDSData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordListResponseDSType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted DS content. See 'data' to set DS properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseDSMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseDSTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseDSJSON `json:"-"` -} - -// dnsRecordListResponseDSJSON contains the JSON metadata for the struct -// [DNSRecordListResponseDS] -type dnsRecordListResponseDSJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseDS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseDSJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseDS) implementsDNSRecordListResponse() {} - -// Components of a DS record. -type DNSRecordListResponseDSData struct { - // Algorithm. - Algorithm float64 `json:"algorithm"` - // Digest. - Digest string `json:"digest"` - // Digest Type. - DigestType float64 `json:"digest_type"` - // Key Tag. - KeyTag float64 `json:"key_tag"` - JSON dnsRecordListResponseDSDataJSON `json:"-"` -} - -// dnsRecordListResponseDSDataJSON contains the JSON metadata for the struct -// [DNSRecordListResponseDSData] -type dnsRecordListResponseDSDataJSON struct { - Algorithm apijson.Field - Digest apijson.Field - DigestType apijson.Field - KeyTag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseDSData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseDSDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordListResponseDSType string - -const ( - DNSRecordListResponseDSTypeDS DNSRecordListResponseDSType = "DS" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseDSMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseDSMetaJSON `json:"-"` -} - -// dnsRecordListResponseDSMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseDSMeta] -type dnsRecordListResponseDSMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseDSMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseDSMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordListResponseDSTTLNumber]. -type DNSRecordListResponseDSTTL interface { - ImplementsDNSRecordListResponseDsttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseDSTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseDSTTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseDSTTLNumber float64 - -const ( - DNSRecordListResponseDSTTLNumber1 DNSRecordListResponseDSTTLNumber = 1 -) - -type DNSRecordListResponseHTTPS struct { - // Components of a HTTPS record. - Data DNSRecordListResponseHTTPSData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordListResponseHTTPSType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted HTTPS content. See 'data' to set HTTPS properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseHTTPSMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseHTTPSTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseHTTPSJSON `json:"-"` -} - -// dnsRecordListResponseHTTPSJSON contains the JSON metadata for the struct -// [DNSRecordListResponseHTTPS] -type dnsRecordListResponseHTTPSJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseHTTPS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseHTTPSJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseHTTPS) implementsDNSRecordListResponse() {} - -// Components of a HTTPS record. -type DNSRecordListResponseHTTPSData struct { - // priority. - Priority float64 `json:"priority"` - // target. - Target string `json:"target"` - // value. - Value string `json:"value"` - JSON dnsRecordListResponseHTTPSDataJSON `json:"-"` -} - -// dnsRecordListResponseHTTPSDataJSON contains the JSON metadata for the struct -// [DNSRecordListResponseHTTPSData] -type dnsRecordListResponseHTTPSDataJSON struct { - Priority apijson.Field - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseHTTPSData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseHTTPSDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordListResponseHTTPSType string - -const ( - DNSRecordListResponseHTTPSTypeHTTPS DNSRecordListResponseHTTPSType = "HTTPS" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseHTTPSMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseHTTPSMetaJSON `json:"-"` -} - -// dnsRecordListResponseHTTPSMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseHTTPSMeta] -type dnsRecordListResponseHTTPSMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseHTTPSMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseHTTPSMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordListResponseHTTPSTTLNumber]. -type DNSRecordListResponseHTTPSTTL interface { - ImplementsDNSRecordListResponseHttpsttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseHTTPSTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseHTTPSTTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseHTTPSTTLNumber float64 - -const ( - DNSRecordListResponseHTTPSTTLNumber1 DNSRecordListResponseHTTPSTTLNumber = 1 -) - -type DNSRecordListResponseLOC struct { - // Components of a LOC record. - Data DNSRecordListResponseLOCData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordListResponseLOCType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted LOC content. See 'data' to set LOC properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseLOCMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseLOCTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseLOCJSON `json:"-"` -} - -// dnsRecordListResponseLOCJSON contains the JSON metadata for the struct -// [DNSRecordListResponseLOC] -type dnsRecordListResponseLOCJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseLOC) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseLOCJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseLOC) implementsDNSRecordListResponse() {} - -// Components of a LOC record. -type DNSRecordListResponseLOCData struct { - // Altitude of location in meters. - Altitude float64 `json:"altitude"` - // Degrees of latitude. - LatDegrees float64 `json:"lat_degrees"` - // Latitude direction. - LatDirection DNSRecordListResponseLOCDataLatDirection `json:"lat_direction"` - // Minutes of latitude. - LatMinutes float64 `json:"lat_minutes"` - // Seconds of latitude. - LatSeconds float64 `json:"lat_seconds"` - // Degrees of longitude. - LongDegrees float64 `json:"long_degrees"` - // Longitude direction. - LongDirection DNSRecordListResponseLOCDataLongDirection `json:"long_direction"` - // Minutes of longitude. - LongMinutes float64 `json:"long_minutes"` - // Seconds of longitude. - LongSeconds float64 `json:"long_seconds"` - // Horizontal precision of location. - PrecisionHorz float64 `json:"precision_horz"` - // Vertical precision of location. - PrecisionVert float64 `json:"precision_vert"` - // Size of location in meters. - Size float64 `json:"size"` - JSON dnsRecordListResponseLOCDataJSON `json:"-"` -} - -// dnsRecordListResponseLOCDataJSON contains the JSON metadata for the struct -// [DNSRecordListResponseLOCData] -type dnsRecordListResponseLOCDataJSON struct { - Altitude apijson.Field - LatDegrees apijson.Field - LatDirection apijson.Field - LatMinutes apijson.Field - LatSeconds apijson.Field - LongDegrees apijson.Field - LongDirection apijson.Field - LongMinutes apijson.Field - LongSeconds apijson.Field - PrecisionHorz apijson.Field - PrecisionVert apijson.Field - Size apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseLOCData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseLOCDataJSON) RawJSON() string { - return r.raw -} - -// Latitude direction. -type DNSRecordListResponseLOCDataLatDirection string - -const ( - DNSRecordListResponseLOCDataLatDirectionN DNSRecordListResponseLOCDataLatDirection = "N" - DNSRecordListResponseLOCDataLatDirectionS DNSRecordListResponseLOCDataLatDirection = "S" -) - -// Longitude direction. -type DNSRecordListResponseLOCDataLongDirection string - -const ( - DNSRecordListResponseLOCDataLongDirectionE DNSRecordListResponseLOCDataLongDirection = "E" - DNSRecordListResponseLOCDataLongDirectionW DNSRecordListResponseLOCDataLongDirection = "W" -) - -// Record type. -type DNSRecordListResponseLOCType string - -const ( - DNSRecordListResponseLOCTypeLOC DNSRecordListResponseLOCType = "LOC" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseLOCMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseLOCMetaJSON `json:"-"` -} - -// dnsRecordListResponseLOCMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseLOCMeta] -type dnsRecordListResponseLOCMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseLOCMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseLOCMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordListResponseLOCTTLNumber]. -type DNSRecordListResponseLOCTTL interface { - ImplementsDNSRecordListResponseLocttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseLOCTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseLOCTTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseLOCTTLNumber float64 - -const ( - DNSRecordListResponseLOCTTLNumber1 DNSRecordListResponseLOCTTLNumber = 1 -) - -type DNSRecordListResponseMX struct { - // A valid mail server hostname. - Content string `json:"content,required" format:"hostname"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority float64 `json:"priority,required"` - // Record type. - Type DNSRecordListResponseMXType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseMXMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseMXTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseMXJSON `json:"-"` -} - -// dnsRecordListResponseMXJSON contains the JSON metadata for the struct -// [DNSRecordListResponseMX] -type dnsRecordListResponseMXJSON struct { - Content apijson.Field - Name apijson.Field - Priority apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseMX) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseMXJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseMX) implementsDNSRecordListResponse() {} - -// Record type. -type DNSRecordListResponseMXType string - -const ( - DNSRecordListResponseMXTypeMX DNSRecordListResponseMXType = "MX" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseMXMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseMXMetaJSON `json:"-"` -} - -// dnsRecordListResponseMXMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseMXMeta] -type dnsRecordListResponseMXMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseMXMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseMXMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordListResponseMXTTLNumber]. -type DNSRecordListResponseMXTTL interface { - ImplementsDNSRecordListResponseMxttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseMXTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseMXTTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseMXTTLNumber float64 - -const ( - DNSRecordListResponseMXTTLNumber1 DNSRecordListResponseMXTTLNumber = 1 -) - -type DNSRecordListResponseNAPTR struct { - // Components of a NAPTR record. - Data DNSRecordListResponseNAPTRData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordListResponseNAPTRType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted NAPTR content. See 'data' to set NAPTR properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseNAPTRMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseNAPTRTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseNAPTRJSON `json:"-"` -} - -// dnsRecordListResponseNAPTRJSON contains the JSON metadata for the struct -// [DNSRecordListResponseNAPTR] -type dnsRecordListResponseNAPTRJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseNAPTR) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseNAPTRJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseNAPTR) implementsDNSRecordListResponse() {} - -// Components of a NAPTR record. -type DNSRecordListResponseNAPTRData struct { - // Flags. - Flags string `json:"flags"` - // Order. - Order float64 `json:"order"` - // Preference. - Preference float64 `json:"preference"` - // Regex. - Regex string `json:"regex"` - // Replacement. - Replacement string `json:"replacement"` - // Service. - Service string `json:"service"` - JSON dnsRecordListResponseNAPTRDataJSON `json:"-"` -} - -// dnsRecordListResponseNAPTRDataJSON contains the JSON metadata for the struct -// [DNSRecordListResponseNAPTRData] -type dnsRecordListResponseNAPTRDataJSON struct { - Flags apijson.Field - Order apijson.Field - Preference apijson.Field - Regex apijson.Field - Replacement apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseNAPTRData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseNAPTRDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordListResponseNAPTRType string - -const ( - DNSRecordListResponseNAPTRTypeNAPTR DNSRecordListResponseNAPTRType = "NAPTR" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseNAPTRMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseNAPTRMetaJSON `json:"-"` -} - -// dnsRecordListResponseNAPTRMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseNAPTRMeta] -type dnsRecordListResponseNAPTRMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseNAPTRMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseNAPTRMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordListResponseNAPTRTTLNumber]. -type DNSRecordListResponseNAPTRTTL interface { - ImplementsDNSRecordListResponseNaptrttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseNAPTRTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseNAPTRTTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseNAPTRTTLNumber float64 - -const ( - DNSRecordListResponseNAPTRTTLNumber1 DNSRecordListResponseNAPTRTTLNumber = 1 -) - -type DNSRecordListResponseNS struct { - // A valid name server host name. - Content interface{} `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordListResponseNSType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseNSMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseNSTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseNSJSON `json:"-"` -} - -// dnsRecordListResponseNSJSON contains the JSON metadata for the struct -// [DNSRecordListResponseNS] -type dnsRecordListResponseNSJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseNSJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseNS) implementsDNSRecordListResponse() {} - -// Record type. -type DNSRecordListResponseNSType string - -const ( - DNSRecordListResponseNSTypeNS DNSRecordListResponseNSType = "NS" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseNSMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseNSMetaJSON `json:"-"` -} - -// dnsRecordListResponseNSMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseNSMeta] -type dnsRecordListResponseNSMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseNSMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseNSMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordListResponseNSTTLNumber]. -type DNSRecordListResponseNSTTL interface { - ImplementsDNSRecordListResponseNsttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseNSTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseNSTTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseNSTTLNumber float64 - -const ( - DNSRecordListResponseNSTTLNumber1 DNSRecordListResponseNSTTLNumber = 1 -) - -type DNSRecordListResponsePTR struct { - // Domain name pointing to the address. - Content string `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordListResponsePTRType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponsePTRMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponsePTRTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponsePTRJSON `json:"-"` -} - -// dnsRecordListResponsePTRJSON contains the JSON metadata for the struct -// [DNSRecordListResponsePTR] -type dnsRecordListResponsePTRJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponsePTR) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponsePTRJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponsePTR) implementsDNSRecordListResponse() {} - -// Record type. -type DNSRecordListResponsePTRType string - -const ( - DNSRecordListResponsePTRTypePTR DNSRecordListResponsePTRType = "PTR" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponsePTRMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponsePTRMetaJSON `json:"-"` -} - -// dnsRecordListResponsePTRMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponsePTRMeta] -type dnsRecordListResponsePTRMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponsePTRMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponsePTRMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordListResponsePTRTTLNumber]. -type DNSRecordListResponsePTRTTL interface { - ImplementsDNSRecordListResponsePtrttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponsePTRTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponsePTRTTLNumber(0)), - }, - ) -} - -type DNSRecordListResponsePTRTTLNumber float64 - -const ( - DNSRecordListResponsePTRTTLNumber1 DNSRecordListResponsePTRTTLNumber = 1 -) - -type DNSRecordListResponseSmimea struct { - // Components of a SMIMEA record. - Data DNSRecordListResponseSmimeaData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordListResponseSmimeaType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted SMIMEA content. See 'data' to set SMIMEA properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseSmimeaMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseSmimeaTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseSmimeaJSON `json:"-"` -} - -// dnsRecordListResponseSmimeaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseSmimea] -type dnsRecordListResponseSmimeaJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseSmimea) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseSmimeaJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseSmimea) implementsDNSRecordListResponse() {} - -// Components of a SMIMEA record. -type DNSRecordListResponseSmimeaData struct { - // Certificate. - Certificate string `json:"certificate"` - // Matching Type. - MatchingType float64 `json:"matching_type"` - // Selector. - Selector float64 `json:"selector"` - // Usage. - Usage float64 `json:"usage"` - JSON dnsRecordListResponseSmimeaDataJSON `json:"-"` -} - -// dnsRecordListResponseSmimeaDataJSON contains the JSON metadata for the struct -// [DNSRecordListResponseSmimeaData] -type dnsRecordListResponseSmimeaDataJSON struct { - Certificate apijson.Field - MatchingType apijson.Field - Selector apijson.Field - Usage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseSmimeaData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseSmimeaDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordListResponseSmimeaType string - -const ( - DNSRecordListResponseSmimeaTypeSmimea DNSRecordListResponseSmimeaType = "SMIMEA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseSmimeaMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseSmimeaMetaJSON `json:"-"` -} - -// dnsRecordListResponseSmimeaMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseSmimeaMeta] -type dnsRecordListResponseSmimeaMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseSmimeaMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseSmimeaMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or -// [DNSRecordListResponseSmimeaTTLNumber]. -type DNSRecordListResponseSmimeaTTL interface { - ImplementsDNSRecordListResponseSmimeaTTL() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseSmimeaTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseSmimeaTTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseSmimeaTTLNumber float64 - -const ( - DNSRecordListResponseSmimeaTTLNumber1 DNSRecordListResponseSmimeaTTLNumber = 1 -) - -type DNSRecordListResponseSRV struct { - // Components of a SRV record. - Data DNSRecordListResponseSRVData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. For SRV records, the first - // label is normally a service and the second a protocol name, each starting with - // an underscore. - Name string `json:"name,required"` - // Record type. - Type DNSRecordListResponseSRVType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Priority, weight, port, and SRV target. See 'data' for setting the individual - // component values. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseSRVMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseSRVTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseSRVJSON `json:"-"` -} - -// dnsRecordListResponseSRVJSON contains the JSON metadata for the struct -// [DNSRecordListResponseSRV] -type dnsRecordListResponseSRVJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseSRV) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseSRVJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseSRV) implementsDNSRecordListResponse() {} - -// Components of a SRV record. -type DNSRecordListResponseSRVData struct { - // A valid hostname. Deprecated in favor of the regular 'name' outside the data - // map. This data map field represents the remainder of the full 'name' after the - // service and protocol. - Name string `json:"name" format:"hostname"` - // The port of the service. - Port float64 `json:"port"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority float64 `json:"priority"` - // A valid protocol, prefixed with an underscore. Deprecated in favor of the - // regular 'name' outside the data map. This data map field normally represents the - // second label of that 'name'. - Proto string `json:"proto"` - // A service type, prefixed with an underscore. Deprecated in favor of the regular - // 'name' outside the data map. This data map field normally represents the first - // label of that 'name'. - Service string `json:"service"` - // A valid hostname. - Target string `json:"target" format:"hostname"` - // The record weight. - Weight float64 `json:"weight"` - JSON dnsRecordListResponseSRVDataJSON `json:"-"` -} - -// dnsRecordListResponseSRVDataJSON contains the JSON metadata for the struct -// [DNSRecordListResponseSRVData] -type dnsRecordListResponseSRVDataJSON struct { - Name apijson.Field - Port apijson.Field - Priority apijson.Field - Proto apijson.Field - Service apijson.Field - Target apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseSRVData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseSRVDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordListResponseSRVType string - -const ( - DNSRecordListResponseSRVTypeSRV DNSRecordListResponseSRVType = "SRV" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseSRVMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseSRVMetaJSON `json:"-"` -} - -// dnsRecordListResponseSRVMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseSRVMeta] -type dnsRecordListResponseSRVMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseSRVMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseSRVMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordListResponseSRVTTLNumber]. -type DNSRecordListResponseSRVTTL interface { - ImplementsDNSRecordListResponseSrvttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseSRVTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseSRVTTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseSRVTTLNumber float64 - -const ( - DNSRecordListResponseSRVTTLNumber1 DNSRecordListResponseSRVTTLNumber = 1 -) - -type DNSRecordListResponseSSHFP struct { - // Components of a SSHFP record. - Data DNSRecordListResponseSSHFPData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordListResponseSSHFPType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted SSHFP content. See 'data' to set SSHFP properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseSSHFPMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseSSHFPTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseSSHFPJSON `json:"-"` -} - -// dnsRecordListResponseSSHFPJSON contains the JSON metadata for the struct -// [DNSRecordListResponseSSHFP] -type dnsRecordListResponseSSHFPJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseSSHFP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseSSHFPJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseSSHFP) implementsDNSRecordListResponse() {} - -// Components of a SSHFP record. -type DNSRecordListResponseSSHFPData struct { - // algorithm. - Algorithm float64 `json:"algorithm"` - // fingerprint. - Fingerprint string `json:"fingerprint"` - // type. - Type float64 `json:"type"` - JSON dnsRecordListResponseSSHFPDataJSON `json:"-"` -} - -// dnsRecordListResponseSSHFPDataJSON contains the JSON metadata for the struct -// [DNSRecordListResponseSSHFPData] -type dnsRecordListResponseSSHFPDataJSON struct { - Algorithm apijson.Field - Fingerprint apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseSSHFPData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseSSHFPDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordListResponseSSHFPType string - -const ( - DNSRecordListResponseSSHFPTypeSSHFP DNSRecordListResponseSSHFPType = "SSHFP" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseSSHFPMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseSSHFPMetaJSON `json:"-"` -} - -// dnsRecordListResponseSSHFPMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseSSHFPMeta] -type dnsRecordListResponseSSHFPMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseSSHFPMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseSSHFPMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordListResponseSSHFPTTLNumber]. -type DNSRecordListResponseSSHFPTTL interface { - ImplementsDNSRecordListResponseSshfpttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseSSHFPTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseSSHFPTTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseSSHFPTTLNumber float64 - -const ( - DNSRecordListResponseSSHFPTTLNumber1 DNSRecordListResponseSSHFPTTLNumber = 1 -) - -type DNSRecordListResponseSVCB struct { - // Components of a SVCB record. - Data DNSRecordListResponseSVCBData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordListResponseSVCBType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted SVCB content. See 'data' to set SVCB properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseSVCBMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseSVCBTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseSVCBJSON `json:"-"` -} - -// dnsRecordListResponseSVCBJSON contains the JSON metadata for the struct -// [DNSRecordListResponseSVCB] -type dnsRecordListResponseSVCBJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseSVCB) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseSVCBJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseSVCB) implementsDNSRecordListResponse() {} - -// Components of a SVCB record. -type DNSRecordListResponseSVCBData struct { - // priority. - Priority float64 `json:"priority"` - // target. - Target string `json:"target"` - // value. - Value string `json:"value"` - JSON dnsRecordListResponseSVCBDataJSON `json:"-"` -} - -// dnsRecordListResponseSVCBDataJSON contains the JSON metadata for the struct -// [DNSRecordListResponseSVCBData] -type dnsRecordListResponseSVCBDataJSON struct { - Priority apijson.Field - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseSVCBData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseSVCBDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordListResponseSVCBType string - -const ( - DNSRecordListResponseSVCBTypeSVCB DNSRecordListResponseSVCBType = "SVCB" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseSVCBMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseSVCBMetaJSON `json:"-"` -} - -// dnsRecordListResponseSVCBMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseSVCBMeta] -type dnsRecordListResponseSVCBMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseSVCBMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseSVCBMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordListResponseSVCBTTLNumber]. -type DNSRecordListResponseSVCBTTL interface { - ImplementsDNSRecordListResponseSvcbttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseSVCBTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseSVCBTTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseSVCBTTLNumber float64 - -const ( - DNSRecordListResponseSVCBTTLNumber1 DNSRecordListResponseSVCBTTLNumber = 1 -) - -type DNSRecordListResponseTLSA struct { - // Components of a TLSA record. - Data DNSRecordListResponseTLSAData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordListResponseTLSAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted TLSA content. See 'data' to set TLSA properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseTLSAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseTLSATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseTLSAJSON `json:"-"` -} - -// dnsRecordListResponseTLSAJSON contains the JSON metadata for the struct -// [DNSRecordListResponseTLSA] -type dnsRecordListResponseTLSAJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseTLSA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseTLSAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseTLSA) implementsDNSRecordListResponse() {} - -// Components of a TLSA record. -type DNSRecordListResponseTLSAData struct { - // certificate. - Certificate string `json:"certificate"` - // Matching Type. - MatchingType float64 `json:"matching_type"` - // Selector. - Selector float64 `json:"selector"` - // Usage. - Usage float64 `json:"usage"` - JSON dnsRecordListResponseTLSADataJSON `json:"-"` -} - -// dnsRecordListResponseTLSADataJSON contains the JSON metadata for the struct -// [DNSRecordListResponseTLSAData] -type dnsRecordListResponseTLSADataJSON struct { - Certificate apijson.Field - MatchingType apijson.Field - Selector apijson.Field - Usage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseTLSAData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseTLSADataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordListResponseTLSAType string - -const ( - DNSRecordListResponseTLSATypeTLSA DNSRecordListResponseTLSAType = "TLSA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseTLSAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseTLSAMetaJSON `json:"-"` -} - -// dnsRecordListResponseTLSAMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseTLSAMeta] -type dnsRecordListResponseTLSAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseTLSAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseTLSAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordListResponseTLSATTLNumber]. -type DNSRecordListResponseTLSATTL interface { - ImplementsDNSRecordListResponseTlsattl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseTLSATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseTLSATTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseTLSATTLNumber float64 - -const ( - DNSRecordListResponseTLSATTLNumber1 DNSRecordListResponseTLSATTLNumber = 1 -) - -type DNSRecordListResponseTXT struct { - // Text content for the record. - Content string `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordListResponseTXTType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseTXTMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseTXTTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseTXTJSON `json:"-"` -} - -// dnsRecordListResponseTXTJSON contains the JSON metadata for the struct -// [DNSRecordListResponseTXT] -type dnsRecordListResponseTXTJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseTXT) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseTXTJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseTXT) implementsDNSRecordListResponse() {} - -// Record type. -type DNSRecordListResponseTXTType string - -const ( - DNSRecordListResponseTXTTypeTXT DNSRecordListResponseTXTType = "TXT" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseTXTMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseTXTMetaJSON `json:"-"` -} - -// dnsRecordListResponseTXTMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseTXTMeta] -type dnsRecordListResponseTXTMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseTXTMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseTXTMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordListResponseTXTTTLNumber]. -type DNSRecordListResponseTXTTTL interface { - ImplementsDNSRecordListResponseTxtttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseTXTTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseTXTTTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseTXTTTLNumber float64 - -const ( - DNSRecordListResponseTXTTTLNumber1 DNSRecordListResponseTXTTTLNumber = 1 -) - -type DNSRecordListResponseURI struct { - // Components of a URI record. - Data DNSRecordListResponseURIData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority float64 `json:"priority,required"` - // Record type. - Type DNSRecordListResponseURIType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted URI content. See 'data' to set URI properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordListResponseURIMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordListResponseURITTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordListResponseURIJSON `json:"-"` -} - -// dnsRecordListResponseURIJSON contains the JSON metadata for the struct -// [DNSRecordListResponseURI] -type dnsRecordListResponseURIJSON struct { - Data apijson.Field - Name apijson.Field - Priority apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseURI) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseURIJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordListResponseURI) implementsDNSRecordListResponse() {} - -// Components of a URI record. -type DNSRecordListResponseURIData struct { - // The record content. - Content string `json:"content"` - // The record weight. - Weight float64 `json:"weight"` - JSON dnsRecordListResponseURIDataJSON `json:"-"` -} - -// dnsRecordListResponseURIDataJSON contains the JSON metadata for the struct -// [DNSRecordListResponseURIData] -type dnsRecordListResponseURIDataJSON struct { - Content apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseURIData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseURIDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordListResponseURIType string - -const ( - DNSRecordListResponseURITypeURI DNSRecordListResponseURIType = "URI" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordListResponseURIMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordListResponseURIMetaJSON `json:"-"` -} - -// dnsRecordListResponseURIMetaJSON contains the JSON metadata for the struct -// [DNSRecordListResponseURIMeta] -type dnsRecordListResponseURIMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordListResponseURIMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordListResponseURIMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordListResponseURITTLNumber]. -type DNSRecordListResponseURITTL interface { - ImplementsDNSRecordListResponseUrittl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordListResponseURITTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordListResponseURITTLNumber(0)), - }, - ) -} - -type DNSRecordListResponseURITTLNumber float64 - -const ( - DNSRecordListResponseURITTLNumber1 DNSRecordListResponseURITTLNumber = 1 -) - -type DNSRecordDeleteResponse struct { - // Identifier - ID string `json:"id"` - JSON dnsRecordDeleteResponseJSON `json:"-"` -} - -// dnsRecordDeleteResponseJSON contains the JSON metadata for the struct -// [DNSRecordDeleteResponse] -type dnsRecordDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [DNSRecordEditResponseA], [DNSRecordEditResponseAAAA], -// [DNSRecordEditResponseCAA], [DNSRecordEditResponseCert], -// [DNSRecordEditResponseCNAME], [DNSRecordEditResponseDNSKEY], -// [DNSRecordEditResponseDS], [DNSRecordEditResponseHTTPS], -// [DNSRecordEditResponseLOC], [DNSRecordEditResponseMX], -// [DNSRecordEditResponseNAPTR], [DNSRecordEditResponseNS], -// [DNSRecordEditResponsePTR], [DNSRecordEditResponseSmimea], -// [DNSRecordEditResponseSRV], [DNSRecordEditResponseSSHFP], -// [DNSRecordEditResponseSVCB], [DNSRecordEditResponseTLSA], -// [DNSRecordEditResponseTXT] or [DNSRecordEditResponseURI]. -type DNSRecordEditResponse interface { - implementsDNSRecordEditResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponse)(nil)).Elem(), - "type", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseA{}), - DiscriminatorValue: "A", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseAAAA{}), - DiscriminatorValue: "AAAA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseCAA{}), - DiscriminatorValue: "CAA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseCert{}), - DiscriminatorValue: "CERT", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseCNAME{}), - DiscriminatorValue: "CNAME", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseDNSKEY{}), - DiscriminatorValue: "DNSKEY", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseDS{}), - DiscriminatorValue: "DS", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseHTTPS{}), - DiscriminatorValue: "HTTPS", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseLOC{}), - DiscriminatorValue: "LOC", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseMX{}), - DiscriminatorValue: "MX", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseNAPTR{}), - DiscriminatorValue: "NAPTR", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseNS{}), - DiscriminatorValue: "NS", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponsePTR{}), - DiscriminatorValue: "PTR", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseSmimea{}), - DiscriminatorValue: "SMIMEA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseSRV{}), - DiscriminatorValue: "SRV", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseSSHFP{}), - DiscriminatorValue: "SSHFP", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseSVCB{}), - DiscriminatorValue: "SVCB", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseTLSA{}), - DiscriminatorValue: "TLSA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseTXT{}), - DiscriminatorValue: "TXT", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordEditResponseURI{}), - DiscriminatorValue: "URI", - }, - ) -} - -type DNSRecordEditResponseA struct { - // A valid IPv4 address. - Content string `json:"content,required" format:"ipv4"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordEditResponseAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied bool `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseAJSON `json:"-"` -} - -// dnsRecordEditResponseAJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseA] -type dnsRecordEditResponseAJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Proxied apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseA) implementsDNSRecordEditResponse() {} - -// Record type. -type DNSRecordEditResponseAType string - -const ( - DNSRecordEditResponseATypeA DNSRecordEditResponseAType = "A" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseAMetaJSON `json:"-"` -} - -// dnsRecordEditResponseAMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseAMeta] -type dnsRecordEditResponseAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordEditResponseATTLNumber]. -type DNSRecordEditResponseATTL interface { - ImplementsDNSRecordEditResponseAttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseATTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseATTLNumber float64 - -const ( - DNSRecordEditResponseATTLNumber1 DNSRecordEditResponseATTLNumber = 1 -) - -type DNSRecordEditResponseAAAA struct { - // A valid IPv6 address. - Content string `json:"content,required" format:"ipv6"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordEditResponseAAAAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseAAAAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied bool `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseAAAATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseAAAAJSON `json:"-"` -} - -// dnsRecordEditResponseAAAAJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseAAAA] -type dnsRecordEditResponseAAAAJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Proxied apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseAAAA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseAAAAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseAAAA) implementsDNSRecordEditResponse() {} - -// Record type. -type DNSRecordEditResponseAAAAType string - -const ( - DNSRecordEditResponseAAAATypeAAAA DNSRecordEditResponseAAAAType = "AAAA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseAAAAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseAAAAMetaJSON `json:"-"` -} - -// dnsRecordEditResponseAAAAMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseAAAAMeta] -type dnsRecordEditResponseAAAAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseAAAAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseAAAAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordEditResponseAAAATTLNumber]. -type DNSRecordEditResponseAAAATTL interface { - ImplementsDNSRecordEditResponseAaaattl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseAAAATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseAAAATTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseAAAATTLNumber float64 - -const ( - DNSRecordEditResponseAAAATTLNumber1 DNSRecordEditResponseAAAATTLNumber = 1 -) - -type DNSRecordEditResponseCAA struct { - // Components of a CAA record. - Data DNSRecordEditResponseCAAData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordEditResponseCAAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted CAA content. See 'data' to set CAA properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseCAAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseCAATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseCAAJSON `json:"-"` -} - -// dnsRecordEditResponseCAAJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseCAA] -type dnsRecordEditResponseCAAJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseCAA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseCAAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseCAA) implementsDNSRecordEditResponse() {} - -// Components of a CAA record. -type DNSRecordEditResponseCAAData struct { - // Flags for the CAA record. - Flags float64 `json:"flags"` - // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). - Tag string `json:"tag"` - // Value of the record. This field's semantics depend on the chosen tag. - Value string `json:"value"` - JSON dnsRecordEditResponseCAADataJSON `json:"-"` -} - -// dnsRecordEditResponseCAADataJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseCAAData] -type dnsRecordEditResponseCAADataJSON struct { - Flags apijson.Field - Tag apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseCAAData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseCAADataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordEditResponseCAAType string - -const ( - DNSRecordEditResponseCAATypeCAA DNSRecordEditResponseCAAType = "CAA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseCAAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseCAAMetaJSON `json:"-"` -} - -// dnsRecordEditResponseCAAMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseCAAMeta] -type dnsRecordEditResponseCAAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseCAAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseCAAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordEditResponseCAATTLNumber]. -type DNSRecordEditResponseCAATTL interface { - ImplementsDNSRecordEditResponseCaattl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseCAATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseCAATTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseCAATTLNumber float64 - -const ( - DNSRecordEditResponseCAATTLNumber1 DNSRecordEditResponseCAATTLNumber = 1 -) - -type DNSRecordEditResponseCert struct { - // Components of a CERT record. - Data DNSRecordEditResponseCertData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordEditResponseCertType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted CERT content. See 'data' to set CERT properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseCertMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseCertTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseCertJSON `json:"-"` -} - -// dnsRecordEditResponseCertJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseCert] -type dnsRecordEditResponseCertJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseCert) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseCertJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseCert) implementsDNSRecordEditResponse() {} - -// Components of a CERT record. -type DNSRecordEditResponseCertData struct { - // Algorithm. - Algorithm float64 `json:"algorithm"` - // Certificate. - Certificate string `json:"certificate"` - // Key Tag. - KeyTag float64 `json:"key_tag"` - // Type. - Type float64 `json:"type"` - JSON dnsRecordEditResponseCertDataJSON `json:"-"` -} - -// dnsRecordEditResponseCertDataJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseCertData] -type dnsRecordEditResponseCertDataJSON struct { - Algorithm apijson.Field - Certificate apijson.Field - KeyTag apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseCertData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseCertDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordEditResponseCertType string - -const ( - DNSRecordEditResponseCertTypeCert DNSRecordEditResponseCertType = "CERT" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseCertMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseCertMetaJSON `json:"-"` -} - -// dnsRecordEditResponseCertMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseCertMeta] -type dnsRecordEditResponseCertMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseCertMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseCertMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordEditResponseCertTTLNumber]. -type DNSRecordEditResponseCertTTL interface { - ImplementsDNSRecordEditResponseCertTTL() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseCertTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseCertTTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseCertTTLNumber float64 - -const ( - DNSRecordEditResponseCertTTLNumber1 DNSRecordEditResponseCertTTLNumber = 1 -) - -type DNSRecordEditResponseCNAME struct { - // A valid hostname. Must not match the record's name. - Content interface{} `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordEditResponseCNAMEType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseCNAMEMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied bool `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseCNAMETTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseCNAMEJSON `json:"-"` -} - -// dnsRecordEditResponseCNAMEJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseCNAME] -type dnsRecordEditResponseCNAMEJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Proxied apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseCNAME) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseCNAMEJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseCNAME) implementsDNSRecordEditResponse() {} - -// Record type. -type DNSRecordEditResponseCNAMEType string - -const ( - DNSRecordEditResponseCNAMETypeCNAME DNSRecordEditResponseCNAMEType = "CNAME" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseCNAMEMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseCNAMEMetaJSON `json:"-"` -} - -// dnsRecordEditResponseCNAMEMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseCNAMEMeta] -type dnsRecordEditResponseCNAMEMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseCNAMEMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseCNAMEMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordEditResponseCNAMETTLNumber]. -type DNSRecordEditResponseCNAMETTL interface { - ImplementsDNSRecordEditResponseCnamettl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseCNAMETTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseCNAMETTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseCNAMETTLNumber float64 - -const ( - DNSRecordEditResponseCNAMETTLNumber1 DNSRecordEditResponseCNAMETTLNumber = 1 -) - -type DNSRecordEditResponseDNSKEY struct { - // Components of a DNSKEY record. - Data DNSRecordEditResponseDNSKEYData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordEditResponseDNSKEYType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted DNSKEY content. See 'data' to set DNSKEY properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseDNSKEYMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseDNSKEYTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseDNSKEYJSON `json:"-"` -} - -// dnsRecordEditResponseDNSKEYJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseDNSKEY] -type dnsRecordEditResponseDNSKEYJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseDNSKEY) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseDNSKEYJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseDNSKEY) implementsDNSRecordEditResponse() {} - -// Components of a DNSKEY record. -type DNSRecordEditResponseDNSKEYData struct { - // Algorithm. - Algorithm float64 `json:"algorithm"` - // Flags. - Flags float64 `json:"flags"` - // Protocol. - Protocol float64 `json:"protocol"` - // Public Key. - PublicKey string `json:"public_key"` - JSON dnsRecordEditResponseDNSKEYDataJSON `json:"-"` -} - -// dnsRecordEditResponseDNSKEYDataJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseDNSKEYData] -type dnsRecordEditResponseDNSKEYDataJSON struct { - Algorithm apijson.Field - Flags apijson.Field - Protocol apijson.Field - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseDNSKEYData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseDNSKEYDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordEditResponseDNSKEYType string - -const ( - DNSRecordEditResponseDNSKEYTypeDNSKEY DNSRecordEditResponseDNSKEYType = "DNSKEY" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseDNSKEYMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseDNSKEYMetaJSON `json:"-"` -} - -// dnsRecordEditResponseDNSKEYMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseDNSKEYMeta] -type dnsRecordEditResponseDNSKEYMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseDNSKEYMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseDNSKEYMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or -// [DNSRecordEditResponseDNSKEYTTLNumber]. -type DNSRecordEditResponseDNSKEYTTL interface { - ImplementsDNSRecordEditResponseDnskeyttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseDNSKEYTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseDNSKEYTTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseDNSKEYTTLNumber float64 - -const ( - DNSRecordEditResponseDNSKEYTTLNumber1 DNSRecordEditResponseDNSKEYTTLNumber = 1 -) - -type DNSRecordEditResponseDS struct { - // Components of a DS record. - Data DNSRecordEditResponseDSData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordEditResponseDSType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted DS content. See 'data' to set DS properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseDSMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseDSTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseDSJSON `json:"-"` -} - -// dnsRecordEditResponseDSJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseDS] -type dnsRecordEditResponseDSJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseDS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseDSJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseDS) implementsDNSRecordEditResponse() {} - -// Components of a DS record. -type DNSRecordEditResponseDSData struct { - // Algorithm. - Algorithm float64 `json:"algorithm"` - // Digest. - Digest string `json:"digest"` - // Digest Type. - DigestType float64 `json:"digest_type"` - // Key Tag. - KeyTag float64 `json:"key_tag"` - JSON dnsRecordEditResponseDSDataJSON `json:"-"` -} - -// dnsRecordEditResponseDSDataJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseDSData] -type dnsRecordEditResponseDSDataJSON struct { - Algorithm apijson.Field - Digest apijson.Field - DigestType apijson.Field - KeyTag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseDSData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseDSDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordEditResponseDSType string - -const ( - DNSRecordEditResponseDSTypeDS DNSRecordEditResponseDSType = "DS" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseDSMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseDSMetaJSON `json:"-"` -} - -// dnsRecordEditResponseDSMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseDSMeta] -type dnsRecordEditResponseDSMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseDSMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseDSMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordEditResponseDSTTLNumber]. -type DNSRecordEditResponseDSTTL interface { - ImplementsDNSRecordEditResponseDsttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseDSTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseDSTTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseDSTTLNumber float64 - -const ( - DNSRecordEditResponseDSTTLNumber1 DNSRecordEditResponseDSTTLNumber = 1 -) - -type DNSRecordEditResponseHTTPS struct { - // Components of a HTTPS record. - Data DNSRecordEditResponseHTTPSData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordEditResponseHTTPSType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted HTTPS content. See 'data' to set HTTPS properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseHTTPSMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseHTTPSTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseHTTPSJSON `json:"-"` -} - -// dnsRecordEditResponseHTTPSJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseHTTPS] -type dnsRecordEditResponseHTTPSJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseHTTPS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseHTTPSJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseHTTPS) implementsDNSRecordEditResponse() {} - -// Components of a HTTPS record. -type DNSRecordEditResponseHTTPSData struct { - // priority. - Priority float64 `json:"priority"` - // target. - Target string `json:"target"` - // value. - Value string `json:"value"` - JSON dnsRecordEditResponseHTTPSDataJSON `json:"-"` -} - -// dnsRecordEditResponseHTTPSDataJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseHTTPSData] -type dnsRecordEditResponseHTTPSDataJSON struct { - Priority apijson.Field - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseHTTPSData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseHTTPSDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordEditResponseHTTPSType string - -const ( - DNSRecordEditResponseHTTPSTypeHTTPS DNSRecordEditResponseHTTPSType = "HTTPS" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseHTTPSMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseHTTPSMetaJSON `json:"-"` -} - -// dnsRecordEditResponseHTTPSMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseHTTPSMeta] -type dnsRecordEditResponseHTTPSMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseHTTPSMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseHTTPSMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordEditResponseHTTPSTTLNumber]. -type DNSRecordEditResponseHTTPSTTL interface { - ImplementsDNSRecordEditResponseHttpsttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseHTTPSTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseHTTPSTTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseHTTPSTTLNumber float64 - -const ( - DNSRecordEditResponseHTTPSTTLNumber1 DNSRecordEditResponseHTTPSTTLNumber = 1 -) - -type DNSRecordEditResponseLOC struct { - // Components of a LOC record. - Data DNSRecordEditResponseLOCData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordEditResponseLOCType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted LOC content. See 'data' to set LOC properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseLOCMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseLOCTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseLOCJSON `json:"-"` -} - -// dnsRecordEditResponseLOCJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseLOC] -type dnsRecordEditResponseLOCJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseLOC) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseLOCJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseLOC) implementsDNSRecordEditResponse() {} - -// Components of a LOC record. -type DNSRecordEditResponseLOCData struct { - // Altitude of location in meters. - Altitude float64 `json:"altitude"` - // Degrees of latitude. - LatDegrees float64 `json:"lat_degrees"` - // Latitude direction. - LatDirection DNSRecordEditResponseLOCDataLatDirection `json:"lat_direction"` - // Minutes of latitude. - LatMinutes float64 `json:"lat_minutes"` - // Seconds of latitude. - LatSeconds float64 `json:"lat_seconds"` - // Degrees of longitude. - LongDegrees float64 `json:"long_degrees"` - // Longitude direction. - LongDirection DNSRecordEditResponseLOCDataLongDirection `json:"long_direction"` - // Minutes of longitude. - LongMinutes float64 `json:"long_minutes"` - // Seconds of longitude. - LongSeconds float64 `json:"long_seconds"` - // Horizontal precision of location. - PrecisionHorz float64 `json:"precision_horz"` - // Vertical precision of location. - PrecisionVert float64 `json:"precision_vert"` - // Size of location in meters. - Size float64 `json:"size"` - JSON dnsRecordEditResponseLOCDataJSON `json:"-"` -} - -// dnsRecordEditResponseLOCDataJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseLOCData] -type dnsRecordEditResponseLOCDataJSON struct { - Altitude apijson.Field - LatDegrees apijson.Field - LatDirection apijson.Field - LatMinutes apijson.Field - LatSeconds apijson.Field - LongDegrees apijson.Field - LongDirection apijson.Field - LongMinutes apijson.Field - LongSeconds apijson.Field - PrecisionHorz apijson.Field - PrecisionVert apijson.Field - Size apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseLOCData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseLOCDataJSON) RawJSON() string { - return r.raw -} - -// Latitude direction. -type DNSRecordEditResponseLOCDataLatDirection string - -const ( - DNSRecordEditResponseLOCDataLatDirectionN DNSRecordEditResponseLOCDataLatDirection = "N" - DNSRecordEditResponseLOCDataLatDirectionS DNSRecordEditResponseLOCDataLatDirection = "S" -) - -// Longitude direction. -type DNSRecordEditResponseLOCDataLongDirection string - -const ( - DNSRecordEditResponseLOCDataLongDirectionE DNSRecordEditResponseLOCDataLongDirection = "E" - DNSRecordEditResponseLOCDataLongDirectionW DNSRecordEditResponseLOCDataLongDirection = "W" -) - -// Record type. -type DNSRecordEditResponseLOCType string - -const ( - DNSRecordEditResponseLOCTypeLOC DNSRecordEditResponseLOCType = "LOC" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseLOCMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseLOCMetaJSON `json:"-"` -} - -// dnsRecordEditResponseLOCMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseLOCMeta] -type dnsRecordEditResponseLOCMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseLOCMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseLOCMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordEditResponseLOCTTLNumber]. -type DNSRecordEditResponseLOCTTL interface { - ImplementsDNSRecordEditResponseLocttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseLOCTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseLOCTTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseLOCTTLNumber float64 - -const ( - DNSRecordEditResponseLOCTTLNumber1 DNSRecordEditResponseLOCTTLNumber = 1 -) - -type DNSRecordEditResponseMX struct { - // A valid mail server hostname. - Content string `json:"content,required" format:"hostname"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority float64 `json:"priority,required"` - // Record type. - Type DNSRecordEditResponseMXType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseMXMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseMXTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseMXJSON `json:"-"` -} - -// dnsRecordEditResponseMXJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseMX] -type dnsRecordEditResponseMXJSON struct { - Content apijson.Field - Name apijson.Field - Priority apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseMX) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseMXJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseMX) implementsDNSRecordEditResponse() {} - -// Record type. -type DNSRecordEditResponseMXType string - -const ( - DNSRecordEditResponseMXTypeMX DNSRecordEditResponseMXType = "MX" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseMXMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseMXMetaJSON `json:"-"` -} - -// dnsRecordEditResponseMXMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseMXMeta] -type dnsRecordEditResponseMXMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseMXMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseMXMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordEditResponseMXTTLNumber]. -type DNSRecordEditResponseMXTTL interface { - ImplementsDNSRecordEditResponseMxttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseMXTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseMXTTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseMXTTLNumber float64 - -const ( - DNSRecordEditResponseMXTTLNumber1 DNSRecordEditResponseMXTTLNumber = 1 -) - -type DNSRecordEditResponseNAPTR struct { - // Components of a NAPTR record. - Data DNSRecordEditResponseNAPTRData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordEditResponseNAPTRType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted NAPTR content. See 'data' to set NAPTR properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseNAPTRMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseNAPTRTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseNAPTRJSON `json:"-"` -} - -// dnsRecordEditResponseNAPTRJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseNAPTR] -type dnsRecordEditResponseNAPTRJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseNAPTR) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseNAPTRJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseNAPTR) implementsDNSRecordEditResponse() {} - -// Components of a NAPTR record. -type DNSRecordEditResponseNAPTRData struct { - // Flags. - Flags string `json:"flags"` - // Order. - Order float64 `json:"order"` - // Preference. - Preference float64 `json:"preference"` - // Regex. - Regex string `json:"regex"` - // Replacement. - Replacement string `json:"replacement"` - // Service. - Service string `json:"service"` - JSON dnsRecordEditResponseNAPTRDataJSON `json:"-"` -} - -// dnsRecordEditResponseNAPTRDataJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseNAPTRData] -type dnsRecordEditResponseNAPTRDataJSON struct { - Flags apijson.Field - Order apijson.Field - Preference apijson.Field - Regex apijson.Field - Replacement apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseNAPTRData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseNAPTRDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordEditResponseNAPTRType string - -const ( - DNSRecordEditResponseNAPTRTypeNAPTR DNSRecordEditResponseNAPTRType = "NAPTR" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseNAPTRMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseNAPTRMetaJSON `json:"-"` -} - -// dnsRecordEditResponseNAPTRMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseNAPTRMeta] -type dnsRecordEditResponseNAPTRMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseNAPTRMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseNAPTRMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordEditResponseNAPTRTTLNumber]. -type DNSRecordEditResponseNAPTRTTL interface { - ImplementsDNSRecordEditResponseNaptrttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseNAPTRTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseNAPTRTTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseNAPTRTTLNumber float64 - -const ( - DNSRecordEditResponseNAPTRTTLNumber1 DNSRecordEditResponseNAPTRTTLNumber = 1 -) - -type DNSRecordEditResponseNS struct { - // A valid name server host name. - Content interface{} `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordEditResponseNSType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseNSMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseNSTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseNSJSON `json:"-"` -} - -// dnsRecordEditResponseNSJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseNS] -type dnsRecordEditResponseNSJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseNSJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseNS) implementsDNSRecordEditResponse() {} - -// Record type. -type DNSRecordEditResponseNSType string - -const ( - DNSRecordEditResponseNSTypeNS DNSRecordEditResponseNSType = "NS" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseNSMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseNSMetaJSON `json:"-"` -} - -// dnsRecordEditResponseNSMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseNSMeta] -type dnsRecordEditResponseNSMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseNSMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseNSMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordEditResponseNSTTLNumber]. -type DNSRecordEditResponseNSTTL interface { - ImplementsDNSRecordEditResponseNsttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseNSTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseNSTTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseNSTTLNumber float64 - -const ( - DNSRecordEditResponseNSTTLNumber1 DNSRecordEditResponseNSTTLNumber = 1 -) - -type DNSRecordEditResponsePTR struct { - // Domain name pointing to the address. - Content string `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordEditResponsePTRType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponsePTRMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponsePTRTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponsePTRJSON `json:"-"` -} - -// dnsRecordEditResponsePTRJSON contains the JSON metadata for the struct -// [DNSRecordEditResponsePTR] -type dnsRecordEditResponsePTRJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponsePTR) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponsePTRJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponsePTR) implementsDNSRecordEditResponse() {} - -// Record type. -type DNSRecordEditResponsePTRType string - -const ( - DNSRecordEditResponsePTRTypePTR DNSRecordEditResponsePTRType = "PTR" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponsePTRMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponsePTRMetaJSON `json:"-"` -} - -// dnsRecordEditResponsePTRMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponsePTRMeta] -type dnsRecordEditResponsePTRMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponsePTRMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponsePTRMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordEditResponsePTRTTLNumber]. -type DNSRecordEditResponsePTRTTL interface { - ImplementsDNSRecordEditResponsePtrttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponsePTRTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponsePTRTTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponsePTRTTLNumber float64 - -const ( - DNSRecordEditResponsePTRTTLNumber1 DNSRecordEditResponsePTRTTLNumber = 1 -) - -type DNSRecordEditResponseSmimea struct { - // Components of a SMIMEA record. - Data DNSRecordEditResponseSmimeaData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordEditResponseSmimeaType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted SMIMEA content. See 'data' to set SMIMEA properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseSmimeaMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseSmimeaTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseSmimeaJSON `json:"-"` -} - -// dnsRecordEditResponseSmimeaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseSmimea] -type dnsRecordEditResponseSmimeaJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseSmimea) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseSmimeaJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseSmimea) implementsDNSRecordEditResponse() {} - -// Components of a SMIMEA record. -type DNSRecordEditResponseSmimeaData struct { - // Certificate. - Certificate string `json:"certificate"` - // Matching Type. - MatchingType float64 `json:"matching_type"` - // Selector. - Selector float64 `json:"selector"` - // Usage. - Usage float64 `json:"usage"` - JSON dnsRecordEditResponseSmimeaDataJSON `json:"-"` -} - -// dnsRecordEditResponseSmimeaDataJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseSmimeaData] -type dnsRecordEditResponseSmimeaDataJSON struct { - Certificate apijson.Field - MatchingType apijson.Field - Selector apijson.Field - Usage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseSmimeaData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseSmimeaDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordEditResponseSmimeaType string - -const ( - DNSRecordEditResponseSmimeaTypeSmimea DNSRecordEditResponseSmimeaType = "SMIMEA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseSmimeaMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseSmimeaMetaJSON `json:"-"` -} - -// dnsRecordEditResponseSmimeaMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseSmimeaMeta] -type dnsRecordEditResponseSmimeaMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseSmimeaMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseSmimeaMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or -// [DNSRecordEditResponseSmimeaTTLNumber]. -type DNSRecordEditResponseSmimeaTTL interface { - ImplementsDNSRecordEditResponseSmimeaTTL() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseSmimeaTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseSmimeaTTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseSmimeaTTLNumber float64 - -const ( - DNSRecordEditResponseSmimeaTTLNumber1 DNSRecordEditResponseSmimeaTTLNumber = 1 -) - -type DNSRecordEditResponseSRV struct { - // Components of a SRV record. - Data DNSRecordEditResponseSRVData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. For SRV records, the first - // label is normally a service and the second a protocol name, each starting with - // an underscore. - Name string `json:"name,required"` - // Record type. - Type DNSRecordEditResponseSRVType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Priority, weight, port, and SRV target. See 'data' for setting the individual - // component values. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseSRVMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseSRVTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseSRVJSON `json:"-"` -} - -// dnsRecordEditResponseSRVJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseSRV] -type dnsRecordEditResponseSRVJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseSRV) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseSRVJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseSRV) implementsDNSRecordEditResponse() {} - -// Components of a SRV record. -type DNSRecordEditResponseSRVData struct { - // A valid hostname. Deprecated in favor of the regular 'name' outside the data - // map. This data map field represents the remainder of the full 'name' after the - // service and protocol. - Name string `json:"name" format:"hostname"` - // The port of the service. - Port float64 `json:"port"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority float64 `json:"priority"` - // A valid protocol, prefixed with an underscore. Deprecated in favor of the - // regular 'name' outside the data map. This data map field normally represents the - // second label of that 'name'. - Proto string `json:"proto"` - // A service type, prefixed with an underscore. Deprecated in favor of the regular - // 'name' outside the data map. This data map field normally represents the first - // label of that 'name'. - Service string `json:"service"` - // A valid hostname. - Target string `json:"target" format:"hostname"` - // The record weight. - Weight float64 `json:"weight"` - JSON dnsRecordEditResponseSRVDataJSON `json:"-"` -} - -// dnsRecordEditResponseSRVDataJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseSRVData] -type dnsRecordEditResponseSRVDataJSON struct { - Name apijson.Field - Port apijson.Field - Priority apijson.Field - Proto apijson.Field - Service apijson.Field - Target apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseSRVData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseSRVDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordEditResponseSRVType string - -const ( - DNSRecordEditResponseSRVTypeSRV DNSRecordEditResponseSRVType = "SRV" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseSRVMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseSRVMetaJSON `json:"-"` -} - -// dnsRecordEditResponseSRVMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseSRVMeta] -type dnsRecordEditResponseSRVMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseSRVMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseSRVMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordEditResponseSRVTTLNumber]. -type DNSRecordEditResponseSRVTTL interface { - ImplementsDNSRecordEditResponseSrvttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseSRVTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseSRVTTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseSRVTTLNumber float64 - -const ( - DNSRecordEditResponseSRVTTLNumber1 DNSRecordEditResponseSRVTTLNumber = 1 -) - -type DNSRecordEditResponseSSHFP struct { - // Components of a SSHFP record. - Data DNSRecordEditResponseSSHFPData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordEditResponseSSHFPType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted SSHFP content. See 'data' to set SSHFP properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseSSHFPMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseSSHFPTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseSSHFPJSON `json:"-"` -} - -// dnsRecordEditResponseSSHFPJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseSSHFP] -type dnsRecordEditResponseSSHFPJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseSSHFP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseSSHFPJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseSSHFP) implementsDNSRecordEditResponse() {} - -// Components of a SSHFP record. -type DNSRecordEditResponseSSHFPData struct { - // algorithm. - Algorithm float64 `json:"algorithm"` - // fingerprint. - Fingerprint string `json:"fingerprint"` - // type. - Type float64 `json:"type"` - JSON dnsRecordEditResponseSSHFPDataJSON `json:"-"` -} - -// dnsRecordEditResponseSSHFPDataJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseSSHFPData] -type dnsRecordEditResponseSSHFPDataJSON struct { - Algorithm apijson.Field - Fingerprint apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseSSHFPData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseSSHFPDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordEditResponseSSHFPType string - -const ( - DNSRecordEditResponseSSHFPTypeSSHFP DNSRecordEditResponseSSHFPType = "SSHFP" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseSSHFPMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseSSHFPMetaJSON `json:"-"` -} - -// dnsRecordEditResponseSSHFPMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseSSHFPMeta] -type dnsRecordEditResponseSSHFPMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseSSHFPMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseSSHFPMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordEditResponseSSHFPTTLNumber]. -type DNSRecordEditResponseSSHFPTTL interface { - ImplementsDNSRecordEditResponseSshfpttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseSSHFPTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseSSHFPTTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseSSHFPTTLNumber float64 - -const ( - DNSRecordEditResponseSSHFPTTLNumber1 DNSRecordEditResponseSSHFPTTLNumber = 1 -) - -type DNSRecordEditResponseSVCB struct { - // Components of a SVCB record. - Data DNSRecordEditResponseSVCBData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordEditResponseSVCBType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted SVCB content. See 'data' to set SVCB properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseSVCBMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseSVCBTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseSVCBJSON `json:"-"` -} - -// dnsRecordEditResponseSVCBJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseSVCB] -type dnsRecordEditResponseSVCBJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseSVCB) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseSVCBJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseSVCB) implementsDNSRecordEditResponse() {} - -// Components of a SVCB record. -type DNSRecordEditResponseSVCBData struct { - // priority. - Priority float64 `json:"priority"` - // target. - Target string `json:"target"` - // value. - Value string `json:"value"` - JSON dnsRecordEditResponseSVCBDataJSON `json:"-"` -} - -// dnsRecordEditResponseSVCBDataJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseSVCBData] -type dnsRecordEditResponseSVCBDataJSON struct { - Priority apijson.Field - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseSVCBData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseSVCBDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordEditResponseSVCBType string - -const ( - DNSRecordEditResponseSVCBTypeSVCB DNSRecordEditResponseSVCBType = "SVCB" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseSVCBMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseSVCBMetaJSON `json:"-"` -} - -// dnsRecordEditResponseSVCBMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseSVCBMeta] -type dnsRecordEditResponseSVCBMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseSVCBMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseSVCBMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordEditResponseSVCBTTLNumber]. -type DNSRecordEditResponseSVCBTTL interface { - ImplementsDNSRecordEditResponseSvcbttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseSVCBTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseSVCBTTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseSVCBTTLNumber float64 - -const ( - DNSRecordEditResponseSVCBTTLNumber1 DNSRecordEditResponseSVCBTTLNumber = 1 -) - -type DNSRecordEditResponseTLSA struct { - // Components of a TLSA record. - Data DNSRecordEditResponseTLSAData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordEditResponseTLSAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted TLSA content. See 'data' to set TLSA properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseTLSAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseTLSATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseTLSAJSON `json:"-"` -} - -// dnsRecordEditResponseTLSAJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseTLSA] -type dnsRecordEditResponseTLSAJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseTLSA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseTLSAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseTLSA) implementsDNSRecordEditResponse() {} - -// Components of a TLSA record. -type DNSRecordEditResponseTLSAData struct { - // certificate. - Certificate string `json:"certificate"` - // Matching Type. - MatchingType float64 `json:"matching_type"` - // Selector. - Selector float64 `json:"selector"` - // Usage. - Usage float64 `json:"usage"` - JSON dnsRecordEditResponseTLSADataJSON `json:"-"` -} - -// dnsRecordEditResponseTLSADataJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseTLSAData] -type dnsRecordEditResponseTLSADataJSON struct { - Certificate apijson.Field - MatchingType apijson.Field - Selector apijson.Field - Usage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseTLSAData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseTLSADataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordEditResponseTLSAType string - -const ( - DNSRecordEditResponseTLSATypeTLSA DNSRecordEditResponseTLSAType = "TLSA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseTLSAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseTLSAMetaJSON `json:"-"` -} - -// dnsRecordEditResponseTLSAMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseTLSAMeta] -type dnsRecordEditResponseTLSAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseTLSAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseTLSAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordEditResponseTLSATTLNumber]. -type DNSRecordEditResponseTLSATTL interface { - ImplementsDNSRecordEditResponseTlsattl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseTLSATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseTLSATTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseTLSATTLNumber float64 - -const ( - DNSRecordEditResponseTLSATTLNumber1 DNSRecordEditResponseTLSATTLNumber = 1 -) - -type DNSRecordEditResponseTXT struct { - // Text content for the record. - Content string `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordEditResponseTXTType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseTXTMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseTXTTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseTXTJSON `json:"-"` -} - -// dnsRecordEditResponseTXTJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseTXT] -type dnsRecordEditResponseTXTJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseTXT) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseTXTJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseTXT) implementsDNSRecordEditResponse() {} - -// Record type. -type DNSRecordEditResponseTXTType string - -const ( - DNSRecordEditResponseTXTTypeTXT DNSRecordEditResponseTXTType = "TXT" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseTXTMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseTXTMetaJSON `json:"-"` -} - -// dnsRecordEditResponseTXTMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseTXTMeta] -type dnsRecordEditResponseTXTMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseTXTMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseTXTMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordEditResponseTXTTTLNumber]. -type DNSRecordEditResponseTXTTTL interface { - ImplementsDNSRecordEditResponseTxtttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseTXTTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseTXTTTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseTXTTTLNumber float64 - -const ( - DNSRecordEditResponseTXTTTLNumber1 DNSRecordEditResponseTXTTTLNumber = 1 -) - -type DNSRecordEditResponseURI struct { - // Components of a URI record. - Data DNSRecordEditResponseURIData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority float64 `json:"priority,required"` - // Record type. - Type DNSRecordEditResponseURIType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted URI content. See 'data' to set URI properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordEditResponseURIMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordEditResponseURITTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordEditResponseURIJSON `json:"-"` -} - -// dnsRecordEditResponseURIJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseURI] -type dnsRecordEditResponseURIJSON struct { - Data apijson.Field - Name apijson.Field - Priority apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseURI) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseURIJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordEditResponseURI) implementsDNSRecordEditResponse() {} - -// Components of a URI record. -type DNSRecordEditResponseURIData struct { - // The record content. - Content string `json:"content"` - // The record weight. - Weight float64 `json:"weight"` - JSON dnsRecordEditResponseURIDataJSON `json:"-"` -} - -// dnsRecordEditResponseURIDataJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseURIData] -type dnsRecordEditResponseURIDataJSON struct { - Content apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseURIData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseURIDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordEditResponseURIType string - -const ( - DNSRecordEditResponseURITypeURI DNSRecordEditResponseURIType = "URI" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordEditResponseURIMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordEditResponseURIMetaJSON `json:"-"` -} - -// dnsRecordEditResponseURIMetaJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseURIMeta] -type dnsRecordEditResponseURIMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseURIMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseURIMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordEditResponseURITTLNumber]. -type DNSRecordEditResponseURITTL interface { - ImplementsDNSRecordEditResponseUrittl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordEditResponseURITTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordEditResponseURITTLNumber(0)), - }, - ) -} - -type DNSRecordEditResponseURITTLNumber float64 - -const ( - DNSRecordEditResponseURITTLNumber1 DNSRecordEditResponseURITTLNumber = 1 -) - -// Union satisfied by [DNSRecordGetResponseA], [DNSRecordGetResponseAAAA], -// [DNSRecordGetResponseCAA], [DNSRecordGetResponseCert], -// [DNSRecordGetResponseCNAME], [DNSRecordGetResponseDNSKEY], -// [DNSRecordGetResponseDS], [DNSRecordGetResponseHTTPS], -// [DNSRecordGetResponseLOC], [DNSRecordGetResponseMX], -// [DNSRecordGetResponseNAPTR], [DNSRecordGetResponseNS], -// [DNSRecordGetResponsePTR], [DNSRecordGetResponseSmimea], -// [DNSRecordGetResponseSRV], [DNSRecordGetResponseSSHFP], -// [DNSRecordGetResponseSVCB], [DNSRecordGetResponseTLSA], -// [DNSRecordGetResponseTXT] or [DNSRecordGetResponseURI]. -type DNSRecordGetResponse interface { - implementsDNSRecordGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponse)(nil)).Elem(), - "type", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseA{}), - DiscriminatorValue: "A", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseAAAA{}), - DiscriminatorValue: "AAAA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseCAA{}), - DiscriminatorValue: "CAA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseCert{}), - DiscriminatorValue: "CERT", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseCNAME{}), - DiscriminatorValue: "CNAME", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseDNSKEY{}), - DiscriminatorValue: "DNSKEY", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseDS{}), - DiscriminatorValue: "DS", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseHTTPS{}), - DiscriminatorValue: "HTTPS", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseLOC{}), - DiscriminatorValue: "LOC", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseMX{}), - DiscriminatorValue: "MX", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseNAPTR{}), - DiscriminatorValue: "NAPTR", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseNS{}), - DiscriminatorValue: "NS", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponsePTR{}), - DiscriminatorValue: "PTR", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseSmimea{}), - DiscriminatorValue: "SMIMEA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseSRV{}), - DiscriminatorValue: "SRV", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseSSHFP{}), - DiscriminatorValue: "SSHFP", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseSVCB{}), - DiscriminatorValue: "SVCB", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseTLSA{}), - DiscriminatorValue: "TLSA", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseTXT{}), - DiscriminatorValue: "TXT", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(DNSRecordGetResponseURI{}), - DiscriminatorValue: "URI", - }, - ) -} - -type DNSRecordGetResponseA struct { - // A valid IPv4 address. - Content string `json:"content,required" format:"ipv4"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordGetResponseAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied bool `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseAJSON `json:"-"` -} - -// dnsRecordGetResponseAJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseA] -type dnsRecordGetResponseAJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Proxied apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseA) implementsDNSRecordGetResponse() {} - -// Record type. -type DNSRecordGetResponseAType string - -const ( - DNSRecordGetResponseATypeA DNSRecordGetResponseAType = "A" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseAMetaJSON `json:"-"` -} - -// dnsRecordGetResponseAMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseAMeta] -type dnsRecordGetResponseAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseATTLNumber]. -type DNSRecordGetResponseATTL interface { - ImplementsDNSRecordGetResponseAttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseATTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseATTLNumber float64 - -const ( - DNSRecordGetResponseATTLNumber1 DNSRecordGetResponseATTLNumber = 1 -) - -type DNSRecordGetResponseAAAA struct { - // A valid IPv6 address. - Content string `json:"content,required" format:"ipv6"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordGetResponseAAAAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseAAAAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied bool `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseAAAATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseAAAAJSON `json:"-"` -} - -// dnsRecordGetResponseAAAAJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseAAAA] -type dnsRecordGetResponseAAAAJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Proxied apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseAAAA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseAAAAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseAAAA) implementsDNSRecordGetResponse() {} - -// Record type. -type DNSRecordGetResponseAAAAType string - -const ( - DNSRecordGetResponseAAAATypeAAAA DNSRecordGetResponseAAAAType = "AAAA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseAAAAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseAAAAMetaJSON `json:"-"` -} - -// dnsRecordGetResponseAAAAMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseAAAAMeta] -type dnsRecordGetResponseAAAAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseAAAAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseAAAAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseAAAATTLNumber]. -type DNSRecordGetResponseAAAATTL interface { - ImplementsDNSRecordGetResponseAaaattl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseAAAATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseAAAATTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseAAAATTLNumber float64 - -const ( - DNSRecordGetResponseAAAATTLNumber1 DNSRecordGetResponseAAAATTLNumber = 1 -) - -type DNSRecordGetResponseCAA struct { - // Components of a CAA record. - Data DNSRecordGetResponseCAAData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordGetResponseCAAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted CAA content. See 'data' to set CAA properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseCAAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseCAATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseCAAJSON `json:"-"` -} - -// dnsRecordGetResponseCAAJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseCAA] -type dnsRecordGetResponseCAAJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseCAA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseCAAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseCAA) implementsDNSRecordGetResponse() {} - -// Components of a CAA record. -type DNSRecordGetResponseCAAData struct { - // Flags for the CAA record. - Flags float64 `json:"flags"` - // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). - Tag string `json:"tag"` - // Value of the record. This field's semantics depend on the chosen tag. - Value string `json:"value"` - JSON dnsRecordGetResponseCAADataJSON `json:"-"` -} - -// dnsRecordGetResponseCAADataJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseCAAData] -type dnsRecordGetResponseCAADataJSON struct { - Flags apijson.Field - Tag apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseCAAData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseCAADataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordGetResponseCAAType string - -const ( - DNSRecordGetResponseCAATypeCAA DNSRecordGetResponseCAAType = "CAA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseCAAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseCAAMetaJSON `json:"-"` -} - -// dnsRecordGetResponseCAAMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseCAAMeta] -type dnsRecordGetResponseCAAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseCAAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseCAAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseCAATTLNumber]. -type DNSRecordGetResponseCAATTL interface { - ImplementsDNSRecordGetResponseCaattl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseCAATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseCAATTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseCAATTLNumber float64 - -const ( - DNSRecordGetResponseCAATTLNumber1 DNSRecordGetResponseCAATTLNumber = 1 -) - -type DNSRecordGetResponseCert struct { - // Components of a CERT record. - Data DNSRecordGetResponseCertData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordGetResponseCertType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted CERT content. See 'data' to set CERT properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseCertMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseCertTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseCertJSON `json:"-"` -} - -// dnsRecordGetResponseCertJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseCert] -type dnsRecordGetResponseCertJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseCert) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseCertJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseCert) implementsDNSRecordGetResponse() {} - -// Components of a CERT record. -type DNSRecordGetResponseCertData struct { - // Algorithm. - Algorithm float64 `json:"algorithm"` - // Certificate. - Certificate string `json:"certificate"` - // Key Tag. - KeyTag float64 `json:"key_tag"` - // Type. - Type float64 `json:"type"` - JSON dnsRecordGetResponseCertDataJSON `json:"-"` -} - -// dnsRecordGetResponseCertDataJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseCertData] -type dnsRecordGetResponseCertDataJSON struct { - Algorithm apijson.Field - Certificate apijson.Field - KeyTag apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseCertData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseCertDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordGetResponseCertType string - -const ( - DNSRecordGetResponseCertTypeCert DNSRecordGetResponseCertType = "CERT" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseCertMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseCertMetaJSON `json:"-"` -} - -// dnsRecordGetResponseCertMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseCertMeta] -type dnsRecordGetResponseCertMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseCertMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseCertMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseCertTTLNumber]. -type DNSRecordGetResponseCertTTL interface { - ImplementsDNSRecordGetResponseCertTTL() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseCertTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseCertTTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseCertTTLNumber float64 - -const ( - DNSRecordGetResponseCertTTLNumber1 DNSRecordGetResponseCertTTLNumber = 1 -) - -type DNSRecordGetResponseCNAME struct { - // A valid hostname. Must not match the record's name. - Content interface{} `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordGetResponseCNAMEType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseCNAMEMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied bool `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseCNAMETTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseCNAMEJSON `json:"-"` -} - -// dnsRecordGetResponseCNAMEJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseCNAME] -type dnsRecordGetResponseCNAMEJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Proxied apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseCNAME) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseCNAMEJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseCNAME) implementsDNSRecordGetResponse() {} - -// Record type. -type DNSRecordGetResponseCNAMEType string - -const ( - DNSRecordGetResponseCNAMETypeCNAME DNSRecordGetResponseCNAMEType = "CNAME" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseCNAMEMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseCNAMEMetaJSON `json:"-"` -} - -// dnsRecordGetResponseCNAMEMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseCNAMEMeta] -type dnsRecordGetResponseCNAMEMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseCNAMEMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseCNAMEMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseCNAMETTLNumber]. -type DNSRecordGetResponseCNAMETTL interface { - ImplementsDNSRecordGetResponseCnamettl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseCNAMETTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseCNAMETTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseCNAMETTLNumber float64 - -const ( - DNSRecordGetResponseCNAMETTLNumber1 DNSRecordGetResponseCNAMETTLNumber = 1 -) - -type DNSRecordGetResponseDNSKEY struct { - // Components of a DNSKEY record. - Data DNSRecordGetResponseDNSKEYData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordGetResponseDNSKEYType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted DNSKEY content. See 'data' to set DNSKEY properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseDNSKEYMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseDNSKEYTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseDNSKEYJSON `json:"-"` -} - -// dnsRecordGetResponseDNSKEYJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseDNSKEY] -type dnsRecordGetResponseDNSKEYJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseDNSKEY) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseDNSKEYJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseDNSKEY) implementsDNSRecordGetResponse() {} - -// Components of a DNSKEY record. -type DNSRecordGetResponseDNSKEYData struct { - // Algorithm. - Algorithm float64 `json:"algorithm"` - // Flags. - Flags float64 `json:"flags"` - // Protocol. - Protocol float64 `json:"protocol"` - // Public Key. - PublicKey string `json:"public_key"` - JSON dnsRecordGetResponseDNSKEYDataJSON `json:"-"` -} - -// dnsRecordGetResponseDNSKEYDataJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseDNSKEYData] -type dnsRecordGetResponseDNSKEYDataJSON struct { - Algorithm apijson.Field - Flags apijson.Field - Protocol apijson.Field - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseDNSKEYData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseDNSKEYDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordGetResponseDNSKEYType string - -const ( - DNSRecordGetResponseDNSKEYTypeDNSKEY DNSRecordGetResponseDNSKEYType = "DNSKEY" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseDNSKEYMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseDNSKEYMetaJSON `json:"-"` -} - -// dnsRecordGetResponseDNSKEYMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseDNSKEYMeta] -type dnsRecordGetResponseDNSKEYMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseDNSKEYMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseDNSKEYMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseDNSKEYTTLNumber]. -type DNSRecordGetResponseDNSKEYTTL interface { - ImplementsDNSRecordGetResponseDnskeyttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseDNSKEYTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseDNSKEYTTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseDNSKEYTTLNumber float64 - -const ( - DNSRecordGetResponseDNSKEYTTLNumber1 DNSRecordGetResponseDNSKEYTTLNumber = 1 -) - -type DNSRecordGetResponseDS struct { - // Components of a DS record. - Data DNSRecordGetResponseDSData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordGetResponseDSType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted DS content. See 'data' to set DS properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseDSMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseDSTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseDSJSON `json:"-"` -} - -// dnsRecordGetResponseDSJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseDS] -type dnsRecordGetResponseDSJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseDS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseDSJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseDS) implementsDNSRecordGetResponse() {} - -// Components of a DS record. -type DNSRecordGetResponseDSData struct { - // Algorithm. - Algorithm float64 `json:"algorithm"` - // Digest. - Digest string `json:"digest"` - // Digest Type. - DigestType float64 `json:"digest_type"` - // Key Tag. - KeyTag float64 `json:"key_tag"` - JSON dnsRecordGetResponseDSDataJSON `json:"-"` -} - -// dnsRecordGetResponseDSDataJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseDSData] -type dnsRecordGetResponseDSDataJSON struct { - Algorithm apijson.Field - Digest apijson.Field - DigestType apijson.Field - KeyTag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseDSData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseDSDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordGetResponseDSType string - -const ( - DNSRecordGetResponseDSTypeDS DNSRecordGetResponseDSType = "DS" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseDSMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseDSMetaJSON `json:"-"` -} - -// dnsRecordGetResponseDSMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseDSMeta] -type dnsRecordGetResponseDSMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseDSMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseDSMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseDSTTLNumber]. -type DNSRecordGetResponseDSTTL interface { - ImplementsDNSRecordGetResponseDsttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseDSTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseDSTTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseDSTTLNumber float64 - -const ( - DNSRecordGetResponseDSTTLNumber1 DNSRecordGetResponseDSTTLNumber = 1 -) - -type DNSRecordGetResponseHTTPS struct { - // Components of a HTTPS record. - Data DNSRecordGetResponseHTTPSData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordGetResponseHTTPSType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted HTTPS content. See 'data' to set HTTPS properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseHTTPSMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseHTTPSTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseHTTPSJSON `json:"-"` -} - -// dnsRecordGetResponseHTTPSJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseHTTPS] -type dnsRecordGetResponseHTTPSJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseHTTPS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseHTTPSJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseHTTPS) implementsDNSRecordGetResponse() {} - -// Components of a HTTPS record. -type DNSRecordGetResponseHTTPSData struct { - // priority. - Priority float64 `json:"priority"` - // target. - Target string `json:"target"` - // value. - Value string `json:"value"` - JSON dnsRecordGetResponseHTTPSDataJSON `json:"-"` -} - -// dnsRecordGetResponseHTTPSDataJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseHTTPSData] -type dnsRecordGetResponseHTTPSDataJSON struct { - Priority apijson.Field - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseHTTPSData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseHTTPSDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordGetResponseHTTPSType string - -const ( - DNSRecordGetResponseHTTPSTypeHTTPS DNSRecordGetResponseHTTPSType = "HTTPS" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseHTTPSMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseHTTPSMetaJSON `json:"-"` -} - -// dnsRecordGetResponseHTTPSMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseHTTPSMeta] -type dnsRecordGetResponseHTTPSMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseHTTPSMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseHTTPSMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseHTTPSTTLNumber]. -type DNSRecordGetResponseHTTPSTTL interface { - ImplementsDNSRecordGetResponseHttpsttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseHTTPSTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseHTTPSTTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseHTTPSTTLNumber float64 - -const ( - DNSRecordGetResponseHTTPSTTLNumber1 DNSRecordGetResponseHTTPSTTLNumber = 1 -) - -type DNSRecordGetResponseLOC struct { - // Components of a LOC record. - Data DNSRecordGetResponseLOCData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordGetResponseLOCType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted LOC content. See 'data' to set LOC properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseLOCMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseLOCTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseLOCJSON `json:"-"` -} - -// dnsRecordGetResponseLOCJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseLOC] -type dnsRecordGetResponseLOCJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseLOC) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseLOCJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseLOC) implementsDNSRecordGetResponse() {} - -// Components of a LOC record. -type DNSRecordGetResponseLOCData struct { - // Altitude of location in meters. - Altitude float64 `json:"altitude"` - // Degrees of latitude. - LatDegrees float64 `json:"lat_degrees"` - // Latitude direction. - LatDirection DNSRecordGetResponseLOCDataLatDirection `json:"lat_direction"` - // Minutes of latitude. - LatMinutes float64 `json:"lat_minutes"` - // Seconds of latitude. - LatSeconds float64 `json:"lat_seconds"` - // Degrees of longitude. - LongDegrees float64 `json:"long_degrees"` - // Longitude direction. - LongDirection DNSRecordGetResponseLOCDataLongDirection `json:"long_direction"` - // Minutes of longitude. - LongMinutes float64 `json:"long_minutes"` - // Seconds of longitude. - LongSeconds float64 `json:"long_seconds"` - // Horizontal precision of location. - PrecisionHorz float64 `json:"precision_horz"` - // Vertical precision of location. - PrecisionVert float64 `json:"precision_vert"` - // Size of location in meters. - Size float64 `json:"size"` - JSON dnsRecordGetResponseLOCDataJSON `json:"-"` -} - -// dnsRecordGetResponseLOCDataJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseLOCData] -type dnsRecordGetResponseLOCDataJSON struct { - Altitude apijson.Field - LatDegrees apijson.Field - LatDirection apijson.Field - LatMinutes apijson.Field - LatSeconds apijson.Field - LongDegrees apijson.Field - LongDirection apijson.Field - LongMinutes apijson.Field - LongSeconds apijson.Field - PrecisionHorz apijson.Field - PrecisionVert apijson.Field - Size apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseLOCData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseLOCDataJSON) RawJSON() string { - return r.raw -} - -// Latitude direction. -type DNSRecordGetResponseLOCDataLatDirection string - -const ( - DNSRecordGetResponseLOCDataLatDirectionN DNSRecordGetResponseLOCDataLatDirection = "N" - DNSRecordGetResponseLOCDataLatDirectionS DNSRecordGetResponseLOCDataLatDirection = "S" -) - -// Longitude direction. -type DNSRecordGetResponseLOCDataLongDirection string - -const ( - DNSRecordGetResponseLOCDataLongDirectionE DNSRecordGetResponseLOCDataLongDirection = "E" - DNSRecordGetResponseLOCDataLongDirectionW DNSRecordGetResponseLOCDataLongDirection = "W" -) - -// Record type. -type DNSRecordGetResponseLOCType string - -const ( - DNSRecordGetResponseLOCTypeLOC DNSRecordGetResponseLOCType = "LOC" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseLOCMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseLOCMetaJSON `json:"-"` -} - -// dnsRecordGetResponseLOCMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseLOCMeta] -type dnsRecordGetResponseLOCMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseLOCMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseLOCMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseLOCTTLNumber]. -type DNSRecordGetResponseLOCTTL interface { - ImplementsDNSRecordGetResponseLocttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseLOCTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseLOCTTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseLOCTTLNumber float64 - -const ( - DNSRecordGetResponseLOCTTLNumber1 DNSRecordGetResponseLOCTTLNumber = 1 -) - -type DNSRecordGetResponseMX struct { - // A valid mail server hostname. - Content string `json:"content,required" format:"hostname"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority float64 `json:"priority,required"` - // Record type. - Type DNSRecordGetResponseMXType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseMXMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseMXTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseMXJSON `json:"-"` -} - -// dnsRecordGetResponseMXJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseMX] -type dnsRecordGetResponseMXJSON struct { - Content apijson.Field - Name apijson.Field - Priority apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseMX) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseMXJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseMX) implementsDNSRecordGetResponse() {} - -// Record type. -type DNSRecordGetResponseMXType string - -const ( - DNSRecordGetResponseMXTypeMX DNSRecordGetResponseMXType = "MX" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseMXMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseMXMetaJSON `json:"-"` -} - -// dnsRecordGetResponseMXMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseMXMeta] -type dnsRecordGetResponseMXMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseMXMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseMXMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseMXTTLNumber]. -type DNSRecordGetResponseMXTTL interface { - ImplementsDNSRecordGetResponseMxttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseMXTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseMXTTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseMXTTLNumber float64 - -const ( - DNSRecordGetResponseMXTTLNumber1 DNSRecordGetResponseMXTTLNumber = 1 -) - -type DNSRecordGetResponseNAPTR struct { - // Components of a NAPTR record. - Data DNSRecordGetResponseNAPTRData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordGetResponseNAPTRType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted NAPTR content. See 'data' to set NAPTR properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseNAPTRMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseNAPTRTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseNAPTRJSON `json:"-"` -} - -// dnsRecordGetResponseNAPTRJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseNAPTR] -type dnsRecordGetResponseNAPTRJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseNAPTR) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseNAPTRJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseNAPTR) implementsDNSRecordGetResponse() {} - -// Components of a NAPTR record. -type DNSRecordGetResponseNAPTRData struct { - // Flags. - Flags string `json:"flags"` - // Order. - Order float64 `json:"order"` - // Preference. - Preference float64 `json:"preference"` - // Regex. - Regex string `json:"regex"` - // Replacement. - Replacement string `json:"replacement"` - // Service. - Service string `json:"service"` - JSON dnsRecordGetResponseNAPTRDataJSON `json:"-"` -} - -// dnsRecordGetResponseNAPTRDataJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseNAPTRData] -type dnsRecordGetResponseNAPTRDataJSON struct { - Flags apijson.Field - Order apijson.Field - Preference apijson.Field - Regex apijson.Field - Replacement apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseNAPTRData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseNAPTRDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordGetResponseNAPTRType string - -const ( - DNSRecordGetResponseNAPTRTypeNAPTR DNSRecordGetResponseNAPTRType = "NAPTR" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseNAPTRMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseNAPTRMetaJSON `json:"-"` -} - -// dnsRecordGetResponseNAPTRMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseNAPTRMeta] -type dnsRecordGetResponseNAPTRMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseNAPTRMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseNAPTRMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseNAPTRTTLNumber]. -type DNSRecordGetResponseNAPTRTTL interface { - ImplementsDNSRecordGetResponseNaptrttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseNAPTRTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseNAPTRTTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseNAPTRTTLNumber float64 - -const ( - DNSRecordGetResponseNAPTRTTLNumber1 DNSRecordGetResponseNAPTRTTLNumber = 1 -) - -type DNSRecordGetResponseNS struct { - // A valid name server host name. - Content interface{} `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordGetResponseNSType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseNSMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseNSTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseNSJSON `json:"-"` -} - -// dnsRecordGetResponseNSJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseNS] -type dnsRecordGetResponseNSJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseNSJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseNS) implementsDNSRecordGetResponse() {} - -// Record type. -type DNSRecordGetResponseNSType string - -const ( - DNSRecordGetResponseNSTypeNS DNSRecordGetResponseNSType = "NS" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseNSMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseNSMetaJSON `json:"-"` -} - -// dnsRecordGetResponseNSMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseNSMeta] -type dnsRecordGetResponseNSMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseNSMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseNSMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseNSTTLNumber]. -type DNSRecordGetResponseNSTTL interface { - ImplementsDNSRecordGetResponseNsttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseNSTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseNSTTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseNSTTLNumber float64 - -const ( - DNSRecordGetResponseNSTTLNumber1 DNSRecordGetResponseNSTTLNumber = 1 -) - -type DNSRecordGetResponsePTR struct { - // Domain name pointing to the address. - Content string `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordGetResponsePTRType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponsePTRMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponsePTRTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponsePTRJSON `json:"-"` -} - -// dnsRecordGetResponsePTRJSON contains the JSON metadata for the struct -// [DNSRecordGetResponsePTR] -type dnsRecordGetResponsePTRJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponsePTR) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponsePTRJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponsePTR) implementsDNSRecordGetResponse() {} - -// Record type. -type DNSRecordGetResponsePTRType string - -const ( - DNSRecordGetResponsePTRTypePTR DNSRecordGetResponsePTRType = "PTR" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponsePTRMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponsePTRMetaJSON `json:"-"` -} - -// dnsRecordGetResponsePTRMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponsePTRMeta] -type dnsRecordGetResponsePTRMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponsePTRMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponsePTRMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponsePTRTTLNumber]. -type DNSRecordGetResponsePTRTTL interface { - ImplementsDNSRecordGetResponsePtrttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponsePTRTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponsePTRTTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponsePTRTTLNumber float64 - -const ( - DNSRecordGetResponsePTRTTLNumber1 DNSRecordGetResponsePTRTTLNumber = 1 -) - -type DNSRecordGetResponseSmimea struct { - // Components of a SMIMEA record. - Data DNSRecordGetResponseSmimeaData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordGetResponseSmimeaType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted SMIMEA content. See 'data' to set SMIMEA properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseSmimeaMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseSmimeaTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseSmimeaJSON `json:"-"` -} - -// dnsRecordGetResponseSmimeaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseSmimea] -type dnsRecordGetResponseSmimeaJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseSmimea) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseSmimeaJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseSmimea) implementsDNSRecordGetResponse() {} - -// Components of a SMIMEA record. -type DNSRecordGetResponseSmimeaData struct { - // Certificate. - Certificate string `json:"certificate"` - // Matching Type. - MatchingType float64 `json:"matching_type"` - // Selector. - Selector float64 `json:"selector"` - // Usage. - Usage float64 `json:"usage"` - JSON dnsRecordGetResponseSmimeaDataJSON `json:"-"` -} - -// dnsRecordGetResponseSmimeaDataJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseSmimeaData] -type dnsRecordGetResponseSmimeaDataJSON struct { - Certificate apijson.Field - MatchingType apijson.Field - Selector apijson.Field - Usage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseSmimeaData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseSmimeaDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordGetResponseSmimeaType string - -const ( - DNSRecordGetResponseSmimeaTypeSmimea DNSRecordGetResponseSmimeaType = "SMIMEA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseSmimeaMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseSmimeaMetaJSON `json:"-"` -} - -// dnsRecordGetResponseSmimeaMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseSmimeaMeta] -type dnsRecordGetResponseSmimeaMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseSmimeaMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseSmimeaMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseSmimeaTTLNumber]. -type DNSRecordGetResponseSmimeaTTL interface { - ImplementsDNSRecordGetResponseSmimeaTTL() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseSmimeaTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseSmimeaTTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseSmimeaTTLNumber float64 - -const ( - DNSRecordGetResponseSmimeaTTLNumber1 DNSRecordGetResponseSmimeaTTLNumber = 1 -) - -type DNSRecordGetResponseSRV struct { - // Components of a SRV record. - Data DNSRecordGetResponseSRVData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. For SRV records, the first - // label is normally a service and the second a protocol name, each starting with - // an underscore. - Name string `json:"name,required"` - // Record type. - Type DNSRecordGetResponseSRVType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Priority, weight, port, and SRV target. See 'data' for setting the individual - // component values. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseSRVMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseSRVTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseSRVJSON `json:"-"` -} - -// dnsRecordGetResponseSRVJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseSRV] -type dnsRecordGetResponseSRVJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseSRV) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseSRVJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseSRV) implementsDNSRecordGetResponse() {} - -// Components of a SRV record. -type DNSRecordGetResponseSRVData struct { - // A valid hostname. Deprecated in favor of the regular 'name' outside the data - // map. This data map field represents the remainder of the full 'name' after the - // service and protocol. - Name string `json:"name" format:"hostname"` - // The port of the service. - Port float64 `json:"port"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority float64 `json:"priority"` - // A valid protocol, prefixed with an underscore. Deprecated in favor of the - // regular 'name' outside the data map. This data map field normally represents the - // second label of that 'name'. - Proto string `json:"proto"` - // A service type, prefixed with an underscore. Deprecated in favor of the regular - // 'name' outside the data map. This data map field normally represents the first - // label of that 'name'. - Service string `json:"service"` - // A valid hostname. - Target string `json:"target" format:"hostname"` - // The record weight. - Weight float64 `json:"weight"` - JSON dnsRecordGetResponseSRVDataJSON `json:"-"` -} - -// dnsRecordGetResponseSRVDataJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseSRVData] -type dnsRecordGetResponseSRVDataJSON struct { - Name apijson.Field - Port apijson.Field - Priority apijson.Field - Proto apijson.Field - Service apijson.Field - Target apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseSRVData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseSRVDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordGetResponseSRVType string - -const ( - DNSRecordGetResponseSRVTypeSRV DNSRecordGetResponseSRVType = "SRV" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseSRVMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseSRVMetaJSON `json:"-"` -} - -// dnsRecordGetResponseSRVMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseSRVMeta] -type dnsRecordGetResponseSRVMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseSRVMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseSRVMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseSRVTTLNumber]. -type DNSRecordGetResponseSRVTTL interface { - ImplementsDNSRecordGetResponseSrvttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseSRVTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseSRVTTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseSRVTTLNumber float64 - -const ( - DNSRecordGetResponseSRVTTLNumber1 DNSRecordGetResponseSRVTTLNumber = 1 -) - -type DNSRecordGetResponseSSHFP struct { - // Components of a SSHFP record. - Data DNSRecordGetResponseSSHFPData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordGetResponseSSHFPType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted SSHFP content. See 'data' to set SSHFP properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseSSHFPMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseSSHFPTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseSSHFPJSON `json:"-"` -} - -// dnsRecordGetResponseSSHFPJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseSSHFP] -type dnsRecordGetResponseSSHFPJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseSSHFP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseSSHFPJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseSSHFP) implementsDNSRecordGetResponse() {} - -// Components of a SSHFP record. -type DNSRecordGetResponseSSHFPData struct { - // algorithm. - Algorithm float64 `json:"algorithm"` - // fingerprint. - Fingerprint string `json:"fingerprint"` - // type. - Type float64 `json:"type"` - JSON dnsRecordGetResponseSSHFPDataJSON `json:"-"` -} - -// dnsRecordGetResponseSSHFPDataJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseSSHFPData] -type dnsRecordGetResponseSSHFPDataJSON struct { - Algorithm apijson.Field - Fingerprint apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseSSHFPData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseSSHFPDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordGetResponseSSHFPType string - -const ( - DNSRecordGetResponseSSHFPTypeSSHFP DNSRecordGetResponseSSHFPType = "SSHFP" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseSSHFPMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseSSHFPMetaJSON `json:"-"` -} - -// dnsRecordGetResponseSSHFPMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseSSHFPMeta] -type dnsRecordGetResponseSSHFPMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseSSHFPMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseSSHFPMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseSSHFPTTLNumber]. -type DNSRecordGetResponseSSHFPTTL interface { - ImplementsDNSRecordGetResponseSshfpttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseSSHFPTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseSSHFPTTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseSSHFPTTLNumber float64 - -const ( - DNSRecordGetResponseSSHFPTTLNumber1 DNSRecordGetResponseSSHFPTTLNumber = 1 -) - -type DNSRecordGetResponseSVCB struct { - // Components of a SVCB record. - Data DNSRecordGetResponseSVCBData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordGetResponseSVCBType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted SVCB content. See 'data' to set SVCB properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseSVCBMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseSVCBTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseSVCBJSON `json:"-"` -} - -// dnsRecordGetResponseSVCBJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseSVCB] -type dnsRecordGetResponseSVCBJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseSVCB) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseSVCBJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseSVCB) implementsDNSRecordGetResponse() {} - -// Components of a SVCB record. -type DNSRecordGetResponseSVCBData struct { - // priority. - Priority float64 `json:"priority"` - // target. - Target string `json:"target"` - // value. - Value string `json:"value"` - JSON dnsRecordGetResponseSVCBDataJSON `json:"-"` -} - -// dnsRecordGetResponseSVCBDataJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseSVCBData] -type dnsRecordGetResponseSVCBDataJSON struct { - Priority apijson.Field - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseSVCBData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseSVCBDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordGetResponseSVCBType string - -const ( - DNSRecordGetResponseSVCBTypeSVCB DNSRecordGetResponseSVCBType = "SVCB" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseSVCBMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseSVCBMetaJSON `json:"-"` -} - -// dnsRecordGetResponseSVCBMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseSVCBMeta] -type dnsRecordGetResponseSVCBMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseSVCBMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseSVCBMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseSVCBTTLNumber]. -type DNSRecordGetResponseSVCBTTL interface { - ImplementsDNSRecordGetResponseSvcbttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseSVCBTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseSVCBTTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseSVCBTTLNumber float64 - -const ( - DNSRecordGetResponseSVCBTTLNumber1 DNSRecordGetResponseSVCBTTLNumber = 1 -) - -type DNSRecordGetResponseTLSA struct { - // Components of a TLSA record. - Data DNSRecordGetResponseTLSAData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordGetResponseTLSAType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted TLSA content. See 'data' to set TLSA properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseTLSAMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseTLSATTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseTLSAJSON `json:"-"` -} - -// dnsRecordGetResponseTLSAJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseTLSA] -type dnsRecordGetResponseTLSAJSON struct { - Data apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseTLSA) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseTLSAJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseTLSA) implementsDNSRecordGetResponse() {} - -// Components of a TLSA record. -type DNSRecordGetResponseTLSAData struct { - // certificate. - Certificate string `json:"certificate"` - // Matching Type. - MatchingType float64 `json:"matching_type"` - // Selector. - Selector float64 `json:"selector"` - // Usage. - Usage float64 `json:"usage"` - JSON dnsRecordGetResponseTLSADataJSON `json:"-"` -} - -// dnsRecordGetResponseTLSADataJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseTLSAData] -type dnsRecordGetResponseTLSADataJSON struct { - Certificate apijson.Field - MatchingType apijson.Field - Selector apijson.Field - Usage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseTLSAData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseTLSADataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordGetResponseTLSAType string - -const ( - DNSRecordGetResponseTLSATypeTLSA DNSRecordGetResponseTLSAType = "TLSA" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseTLSAMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseTLSAMetaJSON `json:"-"` -} - -// dnsRecordGetResponseTLSAMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseTLSAMeta] -type dnsRecordGetResponseTLSAMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseTLSAMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseTLSAMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseTLSATTLNumber]. -type DNSRecordGetResponseTLSATTL interface { - ImplementsDNSRecordGetResponseTlsattl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseTLSATTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseTLSATTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseTLSATTLNumber float64 - -const ( - DNSRecordGetResponseTLSATTLNumber1 DNSRecordGetResponseTLSATTLNumber = 1 -) - -type DNSRecordGetResponseTXT struct { - // Text content for the record. - Content string `json:"content,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Record type. - Type DNSRecordGetResponseTXTType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseTXTMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseTXTTTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseTXTJSON `json:"-"` -} - -// dnsRecordGetResponseTXTJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseTXT] -type dnsRecordGetResponseTXTJSON struct { - Content apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseTXT) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseTXTJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseTXT) implementsDNSRecordGetResponse() {} - -// Record type. -type DNSRecordGetResponseTXTType string - -const ( - DNSRecordGetResponseTXTTypeTXT DNSRecordGetResponseTXTType = "TXT" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseTXTMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseTXTMetaJSON `json:"-"` -} - -// dnsRecordGetResponseTXTMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseTXTMeta] -type dnsRecordGetResponseTXTMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseTXTMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseTXTMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseTXTTTLNumber]. -type DNSRecordGetResponseTXTTTL interface { - ImplementsDNSRecordGetResponseTxtttl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseTXTTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseTXTTTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseTXTTTLNumber float64 - -const ( - DNSRecordGetResponseTXTTTLNumber1 DNSRecordGetResponseTXTTTLNumber = 1 -) - -type DNSRecordGetResponseURI struct { - // Components of a URI record. - Data DNSRecordGetResponseURIData `json:"data,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name string `json:"name,required"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority float64 `json:"priority,required"` - // Record type. - Type DNSRecordGetResponseURIType `json:"type,required"` - // Identifier - ID string `json:"id"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment string `json:"comment"` - // Formatted URI content. See 'data' to set URI properties. - Content string `json:"content"` - // When the record was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Whether this record can be modified/deleted (true means it's managed by - // Cloudflare). - Locked bool `json:"locked"` - // Extra Cloudflare-specific information about the record. - Meta DNSRecordGetResponseURIMeta `json:"meta"` - // When the record was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Whether the record can be proxied by Cloudflare or not. - Proxiable bool `json:"proxiable"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []string `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL DNSRecordGetResponseURITTL `json:"ttl"` - // Identifier - ZoneID string `json:"zone_id"` - // The domain of the record. - ZoneName string `json:"zone_name" format:"hostname"` - JSON dnsRecordGetResponseURIJSON `json:"-"` -} - -// dnsRecordGetResponseURIJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseURI] -type dnsRecordGetResponseURIJSON struct { - Data apijson.Field - Name apijson.Field - Priority apijson.Field - Type apijson.Field - ID apijson.Field - Comment apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Locked apijson.Field - Meta apijson.Field - ModifiedOn apijson.Field - Proxiable apijson.Field - Tags apijson.Field - TTL apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseURI) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseURIJSON) RawJSON() string { - return r.raw -} - -func (r DNSRecordGetResponseURI) implementsDNSRecordGetResponse() {} - -// Components of a URI record. -type DNSRecordGetResponseURIData struct { - // The record content. - Content string `json:"content"` - // The record weight. - Weight float64 `json:"weight"` - JSON dnsRecordGetResponseURIDataJSON `json:"-"` -} - -// dnsRecordGetResponseURIDataJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseURIData] -type dnsRecordGetResponseURIDataJSON struct { - Content apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseURIData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseURIDataJSON) RawJSON() string { - return r.raw -} - -// Record type. -type DNSRecordGetResponseURIType string - -const ( - DNSRecordGetResponseURITypeURI DNSRecordGetResponseURIType = "URI" -) - -// Extra Cloudflare-specific information about the record. -type DNSRecordGetResponseURIMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded bool `json:"auto_added"` - // Where the record originated from. - Source string `json:"source"` - JSON dnsRecordGetResponseURIMetaJSON `json:"-"` -} - -// dnsRecordGetResponseURIMetaJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseURIMeta] -type dnsRecordGetResponseURIMetaJSON struct { - AutoAdded apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseURIMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseURIMetaJSON) RawJSON() string { - return r.raw -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Union satisfied by [shared.UnionFloat] or [DNSRecordGetResponseURITTLNumber]. -type DNSRecordGetResponseURITTL interface { - ImplementsDNSRecordGetResponseUrittl() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSRecordGetResponseURITTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(DNSRecordGetResponseURITTLNumber(0)), - }, - ) -} - -type DNSRecordGetResponseURITTLNumber float64 - -const ( - DNSRecordGetResponseURITTLNumber1 DNSRecordGetResponseURITTLNumber = 1 -) - -type DNSRecordImportResponse struct { - // Number of DNS records added. - RecsAdded float64 `json:"recs_added"` - // Total number of DNS records parsed. - TotalRecordsParsed float64 `json:"total_records_parsed"` - JSON dnsRecordImportResponseJSON `json:"-"` -} - -// dnsRecordImportResponseJSON contains the JSON metadata for the struct -// [DNSRecordImportResponse] -type dnsRecordImportResponseJSON struct { - RecsAdded apijson.Field - TotalRecordsParsed apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordImportResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordImportResponseJSON) RawJSON() string { - return r.raw -} - -type DNSRecordScanResponse struct { - // Number of DNS records added. - RecsAdded float64 `json:"recs_added"` - // Total number of DNS records parsed. - TotalRecordsParsed float64 `json:"total_records_parsed"` - JSON dnsRecordScanResponseJSON `json:"-"` -} - -// dnsRecordScanResponseJSON contains the JSON metadata for the struct -// [DNSRecordScanResponse] -type dnsRecordScanResponseJSON struct { - RecsAdded apijson.Field - TotalRecordsParsed apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordScanResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordScanResponseJSON) RawJSON() string { - return r.raw -} - -type DNSRecordNewParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[DNSRecordNewParamsType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - Data param.Field[DNSRecordNewParamsData] `json:"data"` - Meta param.Field[DNSRecordNewParamsMeta] `json:"meta"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority param.Field[float64] `json:"priority"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied param.Field[bool] `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL param.Field[DNSRecordNewParamsTTL] `json:"ttl"` -} - -func (r DNSRecordNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type DNSRecordNewParamsType string - -const ( - DNSRecordNewParamsTypeURI DNSRecordNewParamsType = "URI" -) - -type DNSRecordNewParamsData struct { - // algorithm. - Algorithm param.Field[float64] `json:"algorithm"` - // Altitude of location in meters. - Altitude param.Field[float64] `json:"altitude"` - // certificate. - Certificate param.Field[string] `json:"certificate"` - // The record content. - Content param.Field[string] `json:"content"` - // Digest. - Digest param.Field[string] `json:"digest"` - // Digest Type. - DigestType param.Field[float64] `json:"digest_type"` - // fingerprint. - Fingerprint param.Field[string] `json:"fingerprint"` - // Flags. - Flags param.Field[string] `json:"flags"` - // Key Tag. - KeyTag param.Field[float64] `json:"key_tag"` - // Degrees of latitude. - LatDegrees param.Field[float64] `json:"lat_degrees"` - // Latitude direction. - LatDirection param.Field[DNSRecordNewParamsDataLatDirection] `json:"lat_direction"` - // Minutes of latitude. - LatMinutes param.Field[float64] `json:"lat_minutes"` - // Seconds of latitude. - LatSeconds param.Field[float64] `json:"lat_seconds"` - // Degrees of longitude. - LongDegrees param.Field[float64] `json:"long_degrees"` - // Longitude direction. - LongDirection param.Field[DNSRecordNewParamsDataLongDirection] `json:"long_direction"` - // Minutes of longitude. - LongMinutes param.Field[float64] `json:"long_minutes"` - // Seconds of longitude. - LongSeconds param.Field[float64] `json:"long_seconds"` - // Matching Type. - MatchingType param.Field[float64] `json:"matching_type"` - // A valid hostname. Deprecated in favor of the regular 'name' outside the data - // map. This data map field represents the remainder of the full 'name' after the - // service and protocol. - Name param.Field[string] `json:"name" format:"hostname"` - // Order. - Order param.Field[float64] `json:"order"` - // The port of the service. - Port param.Field[float64] `json:"port"` - // Horizontal precision of location. - PrecisionHorz param.Field[float64] `json:"precision_horz"` - // Vertical precision of location. - PrecisionVert param.Field[float64] `json:"precision_vert"` - // Preference. - Preference param.Field[float64] `json:"preference"` - // priority. - Priority param.Field[float64] `json:"priority"` - // A valid protocol, prefixed with an underscore. Deprecated in favor of the - // regular 'name' outside the data map. This data map field normally represents the - // second label of that 'name'. - Proto param.Field[string] `json:"proto"` - // Protocol. - Protocol param.Field[float64] `json:"protocol"` - // Public Key. - PublicKey param.Field[string] `json:"public_key"` - // Regex. - Regex param.Field[string] `json:"regex"` - // Replacement. - Replacement param.Field[string] `json:"replacement"` - // Selector. - Selector param.Field[float64] `json:"selector"` - // A service type, prefixed with an underscore. Deprecated in favor of the regular - // 'name' outside the data map. This data map field normally represents the first - // label of that 'name'. - Service param.Field[string] `json:"service"` - // Size of location in meters. - Size param.Field[float64] `json:"size"` - // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). - Tag param.Field[string] `json:"tag"` - // target. - Target param.Field[string] `json:"target"` - // type. - Type param.Field[float64] `json:"type"` - // Usage. - Usage param.Field[float64] `json:"usage"` - // value. - Value param.Field[string] `json:"value"` - // The record weight. - Weight param.Field[float64] `json:"weight"` -} - -func (r DNSRecordNewParamsData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Latitude direction. -type DNSRecordNewParamsDataLatDirection string - -const ( - DNSRecordNewParamsDataLatDirectionN DNSRecordNewParamsDataLatDirection = "N" - DNSRecordNewParamsDataLatDirectionS DNSRecordNewParamsDataLatDirection = "S" -) - -// Longitude direction. -type DNSRecordNewParamsDataLongDirection string - -const ( - DNSRecordNewParamsDataLongDirectionE DNSRecordNewParamsDataLongDirection = "E" - DNSRecordNewParamsDataLongDirectionW DNSRecordNewParamsDataLongDirection = "W" -) - -type DNSRecordNewParamsMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded param.Field[bool] `json:"auto_added"` - // Where the record originated from. - Source param.Field[string] `json:"source"` -} - -func (r DNSRecordNewParamsMeta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Satisfied by [shared.UnionFloat], [DNSRecordNewParamsTTLNumber]. -type DNSRecordNewParamsTTL interface { - ImplementsDNSRecordNewParamsTTL() -} - -type DNSRecordNewParamsTTLNumber float64 - -const ( - DNSRecordNewParamsTTLNumber1 DNSRecordNewParamsTTLNumber = 1 -) - -type DNSRecordNewResponseEnvelope struct { - Errors []DNSRecordNewResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSRecordNewResponseEnvelopeMessages `json:"messages,required"` - Result DNSRecordNewResponse `json:"result,required"` - // Whether the API call was successful - Success DNSRecordNewResponseEnvelopeSuccess `json:"success,required"` - JSON dnsRecordNewResponseEnvelopeJSON `json:"-"` -} - -// dnsRecordNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseEnvelope] -type dnsRecordNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DNSRecordNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsRecordNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnsRecordNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [DNSRecordNewResponseEnvelopeErrors] -type dnsRecordNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSRecordNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsRecordNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnsRecordNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DNSRecordNewResponseEnvelopeMessages] -type dnsRecordNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DNSRecordNewResponseEnvelopeSuccess bool - -const ( - DNSRecordNewResponseEnvelopeSuccessTrue DNSRecordNewResponseEnvelopeSuccess = true -) - -type DNSRecordUpdateParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[DNSRecordUpdateParamsType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - Data param.Field[DNSRecordUpdateParamsData] `json:"data"` - Meta param.Field[DNSRecordUpdateParamsMeta] `json:"meta"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority param.Field[float64] `json:"priority"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied param.Field[bool] `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL param.Field[DNSRecordUpdateParamsTTL] `json:"ttl"` -} - -func (r DNSRecordUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type DNSRecordUpdateParamsType string - -const ( - DNSRecordUpdateParamsTypeURI DNSRecordUpdateParamsType = "URI" -) - -type DNSRecordUpdateParamsData struct { - // algorithm. - Algorithm param.Field[float64] `json:"algorithm"` - // Altitude of location in meters. - Altitude param.Field[float64] `json:"altitude"` - // certificate. - Certificate param.Field[string] `json:"certificate"` - // The record content. - Content param.Field[string] `json:"content"` - // Digest. - Digest param.Field[string] `json:"digest"` - // Digest Type. - DigestType param.Field[float64] `json:"digest_type"` - // fingerprint. - Fingerprint param.Field[string] `json:"fingerprint"` - // Flags. - Flags param.Field[string] `json:"flags"` - // Key Tag. - KeyTag param.Field[float64] `json:"key_tag"` - // Degrees of latitude. - LatDegrees param.Field[float64] `json:"lat_degrees"` - // Latitude direction. - LatDirection param.Field[DNSRecordUpdateParamsDataLatDirection] `json:"lat_direction"` - // Minutes of latitude. - LatMinutes param.Field[float64] `json:"lat_minutes"` - // Seconds of latitude. - LatSeconds param.Field[float64] `json:"lat_seconds"` - // Degrees of longitude. - LongDegrees param.Field[float64] `json:"long_degrees"` - // Longitude direction. - LongDirection param.Field[DNSRecordUpdateParamsDataLongDirection] `json:"long_direction"` - // Minutes of longitude. - LongMinutes param.Field[float64] `json:"long_minutes"` - // Seconds of longitude. - LongSeconds param.Field[float64] `json:"long_seconds"` - // Matching Type. - MatchingType param.Field[float64] `json:"matching_type"` - // A valid hostname. Deprecated in favor of the regular 'name' outside the data - // map. This data map field represents the remainder of the full 'name' after the - // service and protocol. - Name param.Field[string] `json:"name" format:"hostname"` - // Order. - Order param.Field[float64] `json:"order"` - // The port of the service. - Port param.Field[float64] `json:"port"` - // Horizontal precision of location. - PrecisionHorz param.Field[float64] `json:"precision_horz"` - // Vertical precision of location. - PrecisionVert param.Field[float64] `json:"precision_vert"` - // Preference. - Preference param.Field[float64] `json:"preference"` - // priority. - Priority param.Field[float64] `json:"priority"` - // A valid protocol, prefixed with an underscore. Deprecated in favor of the - // regular 'name' outside the data map. This data map field normally represents the - // second label of that 'name'. - Proto param.Field[string] `json:"proto"` - // Protocol. - Protocol param.Field[float64] `json:"protocol"` - // Public Key. - PublicKey param.Field[string] `json:"public_key"` - // Regex. - Regex param.Field[string] `json:"regex"` - // Replacement. - Replacement param.Field[string] `json:"replacement"` - // Selector. - Selector param.Field[float64] `json:"selector"` - // A service type, prefixed with an underscore. Deprecated in favor of the regular - // 'name' outside the data map. This data map field normally represents the first - // label of that 'name'. - Service param.Field[string] `json:"service"` - // Size of location in meters. - Size param.Field[float64] `json:"size"` - // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). - Tag param.Field[string] `json:"tag"` - // target. - Target param.Field[string] `json:"target"` - // type. - Type param.Field[float64] `json:"type"` - // Usage. - Usage param.Field[float64] `json:"usage"` - // value. - Value param.Field[string] `json:"value"` - // The record weight. - Weight param.Field[float64] `json:"weight"` -} - -func (r DNSRecordUpdateParamsData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Latitude direction. -type DNSRecordUpdateParamsDataLatDirection string - -const ( - DNSRecordUpdateParamsDataLatDirectionN DNSRecordUpdateParamsDataLatDirection = "N" - DNSRecordUpdateParamsDataLatDirectionS DNSRecordUpdateParamsDataLatDirection = "S" -) - -// Longitude direction. -type DNSRecordUpdateParamsDataLongDirection string - -const ( - DNSRecordUpdateParamsDataLongDirectionE DNSRecordUpdateParamsDataLongDirection = "E" - DNSRecordUpdateParamsDataLongDirectionW DNSRecordUpdateParamsDataLongDirection = "W" -) - -type DNSRecordUpdateParamsMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded param.Field[bool] `json:"auto_added"` - // Where the record originated from. - Source param.Field[string] `json:"source"` -} - -func (r DNSRecordUpdateParamsMeta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Satisfied by [shared.UnionFloat], [DNSRecordUpdateParamsTTLNumber]. -type DNSRecordUpdateParamsTTL interface { - ImplementsDNSRecordUpdateParamsTTL() -} - -type DNSRecordUpdateParamsTTLNumber float64 - -const ( - DNSRecordUpdateParamsTTLNumber1 DNSRecordUpdateParamsTTLNumber = 1 -) - -type DNSRecordUpdateResponseEnvelope struct { - Errors []DNSRecordUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSRecordUpdateResponseEnvelopeMessages `json:"messages,required"` - Result DNSRecordUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success DNSRecordUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON dnsRecordUpdateResponseEnvelopeJSON `json:"-"` -} - -// dnsRecordUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [DNSRecordUpdateResponseEnvelope] -type dnsRecordUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DNSRecordUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsRecordUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnsRecordUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DNSRecordUpdateResponseEnvelopeErrors] -type dnsRecordUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSRecordUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsRecordUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnsRecordUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DNSRecordUpdateResponseEnvelopeMessages] -type dnsRecordUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DNSRecordUpdateResponseEnvelopeSuccess bool - -const ( - DNSRecordUpdateResponseEnvelopeSuccessTrue DNSRecordUpdateResponseEnvelopeSuccess = true -) - -type DNSRecordListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Comment param.Field[DNSRecordListParamsComment] `query:"comment"` - // DNS record content. - Content param.Field[string] `query:"content"` - // Direction to order DNS records in. - Direction param.Field[DNSRecordListParamsDirection] `query:"direction"` - // Whether to match all search requirements or at least one (any). If set to `all`, - // acts like a logical AND between filters. If set to `any`, acts like a logical OR - // instead. Note that the interaction between tag filters is controlled by the - // `tag-match` parameter instead. - Match param.Field[DNSRecordListParamsMatch] `query:"match"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `query:"name"` - // Field to order DNS records by. - Order param.Field[DNSRecordListParamsOrder] `query:"order"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // Number of DNS records per page. - PerPage param.Field[float64] `query:"per_page"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied param.Field[bool] `query:"proxied"` - // Allows searching in multiple properties of a DNS record simultaneously. This - // parameter is intended for human users, not automation. Its exact behavior is - // intentionally left unspecified and is subject to change in the future. This - // parameter works independently of the `match` setting. For automated searches, - // please use the other available parameters. - Search param.Field[string] `query:"search"` - Tag param.Field[DNSRecordListParamsTag] `query:"tag"` - // Whether to match all tag search requirements or at least one (any). If set to - // `all`, acts like a logical AND between tag filters. If set to `any`, acts like a - // logical OR instead. Note that the regular `match` parameter is still used to - // combine the resulting condition with other filters that aren't related to tags. - TagMatch param.Field[DNSRecordListParamsTagMatch] `query:"tag_match"` - // Record type. - Type param.Field[DNSRecordListParamsType] `query:"type"` -} - -// URLQuery serializes [DNSRecordListParams]'s query parameters as `url.Values`. -func (r DNSRecordListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type DNSRecordListParamsComment struct { - // If this parameter is present, only records _without_ a comment are returned. - Absent param.Field[string] `query:"absent"` - // Substring of the DNS record comment. Comment filters are case-insensitive. - Contains param.Field[string] `query:"contains"` - // Suffix of the DNS record comment. Comment filters are case-insensitive. - Endswith param.Field[string] `query:"endswith"` - // Exact value of the DNS record comment. Comment filters are case-insensitive. - Exact param.Field[string] `query:"exact"` - // If this parameter is present, only records _with_ a comment are returned. - Present param.Field[string] `query:"present"` - // Prefix of the DNS record comment. Comment filters are case-insensitive. - Startswith param.Field[string] `query:"startswith"` -} - -// URLQuery serializes [DNSRecordListParamsComment]'s query parameters as -// `url.Values`. -func (r DNSRecordListParamsComment) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Direction to order DNS records in. -type DNSRecordListParamsDirection string - -const ( - DNSRecordListParamsDirectionAsc DNSRecordListParamsDirection = "asc" - DNSRecordListParamsDirectionDesc DNSRecordListParamsDirection = "desc" -) - -// Whether to match all search requirements or at least one (any). If set to `all`, -// acts like a logical AND between filters. If set to `any`, acts like a logical OR -// instead. Note that the interaction between tag filters is controlled by the -// `tag-match` parameter instead. -type DNSRecordListParamsMatch string - -const ( - DNSRecordListParamsMatchAny DNSRecordListParamsMatch = "any" - DNSRecordListParamsMatchAll DNSRecordListParamsMatch = "all" -) - -// Field to order DNS records by. -type DNSRecordListParamsOrder string - -const ( - DNSRecordListParamsOrderType DNSRecordListParamsOrder = "type" - DNSRecordListParamsOrderName DNSRecordListParamsOrder = "name" - DNSRecordListParamsOrderContent DNSRecordListParamsOrder = "content" - DNSRecordListParamsOrderTTL DNSRecordListParamsOrder = "ttl" - DNSRecordListParamsOrderProxied DNSRecordListParamsOrder = "proxied" -) - -type DNSRecordListParamsTag struct { - // Name of a tag which must _not_ be present on the DNS record. Tag filters are - // case-insensitive. - Absent param.Field[string] `query:"absent"` - // A tag and value, of the form `:`. The API will only return - // DNS records that have a tag named `` whose value contains - // ``. Tag filters are case-insensitive. - Contains param.Field[string] `query:"contains"` - // A tag and value, of the form `:`. The API will only return - // DNS records that have a tag named `` whose value ends with - // ``. Tag filters are case-insensitive. - Endswith param.Field[string] `query:"endswith"` - // A tag and value, of the form `:`. The API will only return - // DNS records that have a tag named `` whose value is ``. Tag - // filters are case-insensitive. - Exact param.Field[string] `query:"exact"` - // Name of a tag which must be present on the DNS record. Tag filters are - // case-insensitive. - Present param.Field[string] `query:"present"` - // A tag and value, of the form `:`. The API will only return - // DNS records that have a tag named `` whose value starts with - // ``. Tag filters are case-insensitive. - Startswith param.Field[string] `query:"startswith"` -} - -// URLQuery serializes [DNSRecordListParamsTag]'s query parameters as `url.Values`. -func (r DNSRecordListParamsTag) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Whether to match all tag search requirements or at least one (any). If set to -// `all`, acts like a logical AND between tag filters. If set to `any`, acts like a -// logical OR instead. Note that the regular `match` parameter is still used to -// combine the resulting condition with other filters that aren't related to tags. -type DNSRecordListParamsTagMatch string - -const ( - DNSRecordListParamsTagMatchAny DNSRecordListParamsTagMatch = "any" - DNSRecordListParamsTagMatchAll DNSRecordListParamsTagMatch = "all" -) - -// Record type. -type DNSRecordListParamsType string - -const ( - DNSRecordListParamsTypeA DNSRecordListParamsType = "A" - DNSRecordListParamsTypeAAAA DNSRecordListParamsType = "AAAA" - DNSRecordListParamsTypeCAA DNSRecordListParamsType = "CAA" - DNSRecordListParamsTypeCert DNSRecordListParamsType = "CERT" - DNSRecordListParamsTypeCNAME DNSRecordListParamsType = "CNAME" - DNSRecordListParamsTypeDNSKEY DNSRecordListParamsType = "DNSKEY" - DNSRecordListParamsTypeDS DNSRecordListParamsType = "DS" - DNSRecordListParamsTypeHTTPS DNSRecordListParamsType = "HTTPS" - DNSRecordListParamsTypeLOC DNSRecordListParamsType = "LOC" - DNSRecordListParamsTypeMX DNSRecordListParamsType = "MX" - DNSRecordListParamsTypeNAPTR DNSRecordListParamsType = "NAPTR" - DNSRecordListParamsTypeNS DNSRecordListParamsType = "NS" - DNSRecordListParamsTypePTR DNSRecordListParamsType = "PTR" - DNSRecordListParamsTypeSmimea DNSRecordListParamsType = "SMIMEA" - DNSRecordListParamsTypeSRV DNSRecordListParamsType = "SRV" - DNSRecordListParamsTypeSSHFP DNSRecordListParamsType = "SSHFP" - DNSRecordListParamsTypeSVCB DNSRecordListParamsType = "SVCB" - DNSRecordListParamsTypeTLSA DNSRecordListParamsType = "TLSA" - DNSRecordListParamsTypeTXT DNSRecordListParamsType = "TXT" - DNSRecordListParamsTypeURI DNSRecordListParamsType = "URI" -) - -type DNSRecordDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type DNSRecordDeleteResponseEnvelope struct { - Result DNSRecordDeleteResponse `json:"result"` - JSON dnsRecordDeleteResponseEnvelopeJSON `json:"-"` -} - -// dnsRecordDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [DNSRecordDeleteResponseEnvelope] -type dnsRecordDeleteResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DNSRecordEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // DNS record name (or @ for the zone apex) in Punycode. - Name param.Field[string] `json:"name,required"` - // Record type. - Type param.Field[DNSRecordEditParamsType] `json:"type,required"` - // Comments or notes about the DNS record. This field has no effect on DNS - // responses. - Comment param.Field[string] `json:"comment"` - Data param.Field[DNSRecordEditParamsData] `json:"data"` - Meta param.Field[DNSRecordEditParamsMeta] `json:"meta"` - // Required for MX, SRV and URI records; unused by other record types. Records with - // lower priorities are preferred. - Priority param.Field[float64] `json:"priority"` - // Whether the record is receiving the performance and security benefits of - // Cloudflare. - Proxied param.Field[bool] `json:"proxied"` - // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]string] `json:"tags"` - // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. - // Value must be between 60 and 86400, with the minimum reduced to 30 for - // Enterprise zones. - TTL param.Field[DNSRecordEditParamsTTL] `json:"ttl"` -} - -func (r DNSRecordEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Record type. -type DNSRecordEditParamsType string - -const ( - DNSRecordEditParamsTypeURI DNSRecordEditParamsType = "URI" -) - -type DNSRecordEditParamsData struct { - // algorithm. - Algorithm param.Field[float64] `json:"algorithm"` - // Altitude of location in meters. - Altitude param.Field[float64] `json:"altitude"` - // certificate. - Certificate param.Field[string] `json:"certificate"` - // The record content. - Content param.Field[string] `json:"content"` - // Digest. - Digest param.Field[string] `json:"digest"` - // Digest Type. - DigestType param.Field[float64] `json:"digest_type"` - // fingerprint. - Fingerprint param.Field[string] `json:"fingerprint"` - // Flags. - Flags param.Field[string] `json:"flags"` - // Key Tag. - KeyTag param.Field[float64] `json:"key_tag"` - // Degrees of latitude. - LatDegrees param.Field[float64] `json:"lat_degrees"` - // Latitude direction. - LatDirection param.Field[DNSRecordEditParamsDataLatDirection] `json:"lat_direction"` - // Minutes of latitude. - LatMinutes param.Field[float64] `json:"lat_minutes"` - // Seconds of latitude. - LatSeconds param.Field[float64] `json:"lat_seconds"` - // Degrees of longitude. - LongDegrees param.Field[float64] `json:"long_degrees"` - // Longitude direction. - LongDirection param.Field[DNSRecordEditParamsDataLongDirection] `json:"long_direction"` - // Minutes of longitude. - LongMinutes param.Field[float64] `json:"long_minutes"` - // Seconds of longitude. - LongSeconds param.Field[float64] `json:"long_seconds"` - // Matching Type. - MatchingType param.Field[float64] `json:"matching_type"` - // A valid hostname. Deprecated in favor of the regular 'name' outside the data - // map. This data map field represents the remainder of the full 'name' after the - // service and protocol. - Name param.Field[string] `json:"name" format:"hostname"` - // Order. - Order param.Field[float64] `json:"order"` - // The port of the service. - Port param.Field[float64] `json:"port"` - // Horizontal precision of location. - PrecisionHorz param.Field[float64] `json:"precision_horz"` - // Vertical precision of location. - PrecisionVert param.Field[float64] `json:"precision_vert"` - // Preference. - Preference param.Field[float64] `json:"preference"` - // priority. - Priority param.Field[float64] `json:"priority"` - // A valid protocol, prefixed with an underscore. Deprecated in favor of the - // regular 'name' outside the data map. This data map field normally represents the - // second label of that 'name'. - Proto param.Field[string] `json:"proto"` - // Protocol. - Protocol param.Field[float64] `json:"protocol"` - // Public Key. - PublicKey param.Field[string] `json:"public_key"` - // Regex. - Regex param.Field[string] `json:"regex"` - // Replacement. - Replacement param.Field[string] `json:"replacement"` - // Selector. - Selector param.Field[float64] `json:"selector"` - // A service type, prefixed with an underscore. Deprecated in favor of the regular - // 'name' outside the data map. This data map field normally represents the first - // label of that 'name'. - Service param.Field[string] `json:"service"` - // Size of location in meters. - Size param.Field[float64] `json:"size"` - // Name of the property controlled by this record (e.g.: issue, issuewild, iodef). - Tag param.Field[string] `json:"tag"` - // target. - Target param.Field[string] `json:"target"` - // type. - Type param.Field[float64] `json:"type"` - // Usage. - Usage param.Field[float64] `json:"usage"` - // value. - Value param.Field[string] `json:"value"` - // The record weight. - Weight param.Field[float64] `json:"weight"` -} - -func (r DNSRecordEditParamsData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Latitude direction. -type DNSRecordEditParamsDataLatDirection string - -const ( - DNSRecordEditParamsDataLatDirectionN DNSRecordEditParamsDataLatDirection = "N" - DNSRecordEditParamsDataLatDirectionS DNSRecordEditParamsDataLatDirection = "S" -) - -// Longitude direction. -type DNSRecordEditParamsDataLongDirection string - -const ( - DNSRecordEditParamsDataLongDirectionE DNSRecordEditParamsDataLongDirection = "E" - DNSRecordEditParamsDataLongDirectionW DNSRecordEditParamsDataLongDirection = "W" -) - -type DNSRecordEditParamsMeta struct { - // Will exist if Cloudflare automatically added this DNS record during initial - // setup. - AutoAdded param.Field[bool] `json:"auto_added"` - // Where the record originated from. - Source param.Field[string] `json:"source"` -} - -func (r DNSRecordEditParamsMeta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. -// Value must be between 60 and 86400, with the minimum reduced to 30 for -// Enterprise zones. -// -// Satisfied by [shared.UnionFloat], [DNSRecordEditParamsTTLNumber]. -type DNSRecordEditParamsTTL interface { - ImplementsDNSRecordEditParamsTTL() -} - -type DNSRecordEditParamsTTLNumber float64 - -const ( - DNSRecordEditParamsTTLNumber1 DNSRecordEditParamsTTLNumber = 1 -) - -type DNSRecordEditResponseEnvelope struct { - Errors []DNSRecordEditResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSRecordEditResponseEnvelopeMessages `json:"messages,required"` - Result DNSRecordEditResponse `json:"result,required"` - // Whether the API call was successful - Success DNSRecordEditResponseEnvelopeSuccess `json:"success,required"` - JSON dnsRecordEditResponseEnvelopeJSON `json:"-"` -} - -// dnsRecordEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [DNSRecordEditResponseEnvelope] -type dnsRecordEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DNSRecordEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsRecordEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnsRecordEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DNSRecordEditResponseEnvelopeErrors] -type dnsRecordEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSRecordEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsRecordEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnsRecordEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DNSRecordEditResponseEnvelopeMessages] -type dnsRecordEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DNSRecordEditResponseEnvelopeSuccess bool - -const ( - DNSRecordEditResponseEnvelopeSuccessTrue DNSRecordEditResponseEnvelopeSuccess = true -) - -type DNSRecordExportParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type DNSRecordGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type DNSRecordGetResponseEnvelope struct { - Errors []DNSRecordGetResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSRecordGetResponseEnvelopeMessages `json:"messages,required"` - Result DNSRecordGetResponse `json:"result,required"` - // Whether the API call was successful - Success DNSRecordGetResponseEnvelopeSuccess `json:"success,required"` - JSON dnsRecordGetResponseEnvelopeJSON `json:"-"` -} - -// dnsRecordGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseEnvelope] -type dnsRecordGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DNSRecordGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsRecordGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnsRecordGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [DNSRecordGetResponseEnvelopeErrors] -type dnsRecordGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSRecordGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsRecordGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnsRecordGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DNSRecordGetResponseEnvelopeMessages] -type dnsRecordGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DNSRecordGetResponseEnvelopeSuccess bool - -const ( - DNSRecordGetResponseEnvelopeSuccessTrue DNSRecordGetResponseEnvelopeSuccess = true -) - -type DNSRecordImportParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // BIND config to import. - // - // **Tip:** When using cURL, a file can be uploaded using - // `--form 'file=@bind_config.txt'`. - File param.Field[string] `json:"file,required"` - // Whether or not proxiable records should receive the performance and security - // benefits of Cloudflare. - // - // The value should be either `true` or `false`. - Proxied param.Field[string] `json:"proxied"` -} - -func (r DNSRecordImportParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type DNSRecordImportResponseEnvelope struct { - Errors []DNSRecordImportResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSRecordImportResponseEnvelopeMessages `json:"messages,required"` - Result DNSRecordImportResponse `json:"result,required"` - // Whether the API call was successful - Success DNSRecordImportResponseEnvelopeSuccess `json:"success,required"` - Timing DNSRecordImportResponseEnvelopeTiming `json:"timing"` - JSON dnsRecordImportResponseEnvelopeJSON `json:"-"` -} - -// dnsRecordImportResponseEnvelopeJSON contains the JSON metadata for the struct -// [DNSRecordImportResponseEnvelope] -type dnsRecordImportResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - Timing apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordImportResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordImportResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DNSRecordImportResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsRecordImportResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnsRecordImportResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DNSRecordImportResponseEnvelopeErrors] -type dnsRecordImportResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordImportResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordImportResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSRecordImportResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsRecordImportResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnsRecordImportResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DNSRecordImportResponseEnvelopeMessages] -type dnsRecordImportResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordImportResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordImportResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DNSRecordImportResponseEnvelopeSuccess bool - -const ( - DNSRecordImportResponseEnvelopeSuccessTrue DNSRecordImportResponseEnvelopeSuccess = true -) - -type DNSRecordImportResponseEnvelopeTiming struct { - // When the file parsing ended. - EndTime time.Time `json:"end_time" format:"date-time"` - // Processing time of the file in seconds. - ProcessTime float64 `json:"process_time"` - // When the file parsing started. - StartTime time.Time `json:"start_time" format:"date-time"` - JSON dnsRecordImportResponseEnvelopeTimingJSON `json:"-"` -} - -// dnsRecordImportResponseEnvelopeTimingJSON contains the JSON metadata for the -// struct [DNSRecordImportResponseEnvelopeTiming] -type dnsRecordImportResponseEnvelopeTimingJSON struct { - EndTime apijson.Field - ProcessTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordImportResponseEnvelopeTiming) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordImportResponseEnvelopeTimingJSON) RawJSON() string { - return r.raw -} - -type DNSRecordScanParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type DNSRecordScanResponseEnvelope struct { - Errors []DNSRecordScanResponseEnvelopeErrors `json:"errors,required"` - Messages []DNSRecordScanResponseEnvelopeMessages `json:"messages,required"` - Result DNSRecordScanResponse `json:"result,required"` - // Whether the API call was successful - Success DNSRecordScanResponseEnvelopeSuccess `json:"success,required"` - Timing DNSRecordScanResponseEnvelopeTiming `json:"timing"` - JSON dnsRecordScanResponseEnvelopeJSON `json:"-"` -} - -// dnsRecordScanResponseEnvelopeJSON contains the JSON metadata for the struct -// [DNSRecordScanResponseEnvelope] -type dnsRecordScanResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - Timing apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordScanResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordScanResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DNSRecordScanResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsRecordScanResponseEnvelopeErrorsJSON `json:"-"` -} - -// dnsRecordScanResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [DNSRecordScanResponseEnvelopeErrors] -type dnsRecordScanResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordScanResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordScanResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DNSRecordScanResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON dnsRecordScanResponseEnvelopeMessagesJSON `json:"-"` -} - -// dnsRecordScanResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [DNSRecordScanResponseEnvelopeMessages] -type dnsRecordScanResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordScanResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordScanResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DNSRecordScanResponseEnvelopeSuccess bool - -const ( - DNSRecordScanResponseEnvelopeSuccessTrue DNSRecordScanResponseEnvelopeSuccess = true -) - -type DNSRecordScanResponseEnvelopeTiming struct { - // When the file parsing ended. - EndTime time.Time `json:"end_time" format:"date-time"` - // Processing time of the file in seconds. - ProcessTime float64 `json:"process_time"` - // When the file parsing started. - StartTime time.Time `json:"start_time" format:"date-time"` - JSON dnsRecordScanResponseEnvelopeTimingJSON `json:"-"` -} - -// dnsRecordScanResponseEnvelopeTimingJSON contains the JSON metadata for the -// struct [DNSRecordScanResponseEnvelopeTiming] -type dnsRecordScanResponseEnvelopeTimingJSON struct { - EndTime apijson.Field - ProcessTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSRecordScanResponseEnvelopeTiming) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r dnsRecordScanResponseEnvelopeTimingJSON) RawJSON() string { - return r.raw -} diff --git a/dnsrecord_test.go b/dnsrecord_test.go deleted file mode 100644 index 7ab99df15e6..00000000000 --- a/dnsrecord_test.go +++ /dev/null @@ -1,450 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestDNSRecordNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.DNS.Records.New(context.TODO(), cloudflare.DNSRecordNewParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Name: cloudflare.F("example.com"), - Type: cloudflare.F(cloudflare.DNSRecordNewParamsTypeURI), - Comment: cloudflare.F("Domain verification record"), - Data: cloudflare.F(cloudflare.DNSRecordNewParamsData{ - Flags: cloudflare.F("string"), - Tag: cloudflare.F("issue"), - Value: cloudflare.F("alpn=\"h3,h2\" ipv4hint=\"127.0.0.1\" ipv6hint=\"::1\""), - Algorithm: cloudflare.F(2.000000), - Certificate: cloudflare.F("string"), - KeyTag: cloudflare.F(1.000000), - Type: cloudflare.F(1.000000), - Protocol: cloudflare.F(3.000000), - PublicKey: cloudflare.F("string"), - Digest: cloudflare.F("string"), - DigestType: cloudflare.F(1.000000), - Priority: cloudflare.F(1.000000), - Target: cloudflare.F("."), - Altitude: cloudflare.F(0.000000), - LatDegrees: cloudflare.F(37.000000), - LatDirection: cloudflare.F(cloudflare.DNSRecordNewParamsDataLatDirectionN), - LatMinutes: cloudflare.F(46.000000), - LatSeconds: cloudflare.F(46.000000), - LongDegrees: cloudflare.F(122.000000), - LongDirection: cloudflare.F(cloudflare.DNSRecordNewParamsDataLongDirectionW), - LongMinutes: cloudflare.F(23.000000), - LongSeconds: cloudflare.F(35.000000), - PrecisionHorz: cloudflare.F(0.000000), - PrecisionVert: cloudflare.F(0.000000), - Size: cloudflare.F(100.000000), - Order: cloudflare.F(100.000000), - Preference: cloudflare.F(10.000000), - Regex: cloudflare.F("string"), - Replacement: cloudflare.F("string"), - Service: cloudflare.F("_sip"), - MatchingType: cloudflare.F(1.000000), - Selector: cloudflare.F(0.000000), - Usage: cloudflare.F(0.000000), - Name: cloudflare.F("example.com"), - Port: cloudflare.F(8806.000000), - Proto: cloudflare.F("_tcp"), - Weight: cloudflare.F(20.000000), - Fingerprint: cloudflare.F("string"), - Content: cloudflare.F("http://example.com/example.html"), - }), - Meta: cloudflare.F(cloudflare.DNSRecordNewParamsMeta{ - AutoAdded: cloudflare.F(true), - Source: cloudflare.F("primary"), - }), - Priority: cloudflare.F(10.000000), - Proxied: cloudflare.F(false), - Tags: cloudflare.F([]string{"owner:dns-team", "owner:dns-team", "owner:dns-team"}), - TTL: cloudflare.F[cloudflare.DNSRecordNewParamsTTL](shared.UnionFloat(3600.000000)), - }) - 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 TestDNSRecordUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.DNS.Records.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.DNSRecordUpdateParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Name: cloudflare.F("example.com"), - Type: cloudflare.F(cloudflare.DNSRecordUpdateParamsTypeURI), - Comment: cloudflare.F("Domain verification record"), - Data: cloudflare.F(cloudflare.DNSRecordUpdateParamsData{ - Flags: cloudflare.F("string"), - Tag: cloudflare.F("issue"), - Value: cloudflare.F("alpn=\"h3,h2\" ipv4hint=\"127.0.0.1\" ipv6hint=\"::1\""), - Algorithm: cloudflare.F(2.000000), - Certificate: cloudflare.F("string"), - KeyTag: cloudflare.F(1.000000), - Type: cloudflare.F(1.000000), - Protocol: cloudflare.F(3.000000), - PublicKey: cloudflare.F("string"), - Digest: cloudflare.F("string"), - DigestType: cloudflare.F(1.000000), - Priority: cloudflare.F(1.000000), - Target: cloudflare.F("."), - Altitude: cloudflare.F(0.000000), - LatDegrees: cloudflare.F(37.000000), - LatDirection: cloudflare.F(cloudflare.DNSRecordUpdateParamsDataLatDirectionN), - LatMinutes: cloudflare.F(46.000000), - LatSeconds: cloudflare.F(46.000000), - LongDegrees: cloudflare.F(122.000000), - LongDirection: cloudflare.F(cloudflare.DNSRecordUpdateParamsDataLongDirectionW), - LongMinutes: cloudflare.F(23.000000), - LongSeconds: cloudflare.F(35.000000), - PrecisionHorz: cloudflare.F(0.000000), - PrecisionVert: cloudflare.F(0.000000), - Size: cloudflare.F(100.000000), - Order: cloudflare.F(100.000000), - Preference: cloudflare.F(10.000000), - Regex: cloudflare.F("string"), - Replacement: cloudflare.F("string"), - Service: cloudflare.F("_sip"), - MatchingType: cloudflare.F(1.000000), - Selector: cloudflare.F(0.000000), - Usage: cloudflare.F(0.000000), - Name: cloudflare.F("example.com"), - Port: cloudflare.F(8806.000000), - Proto: cloudflare.F("_tcp"), - Weight: cloudflare.F(20.000000), - Fingerprint: cloudflare.F("string"), - Content: cloudflare.F("http://example.com/example.html"), - }), - Meta: cloudflare.F(cloudflare.DNSRecordUpdateParamsMeta{ - AutoAdded: cloudflare.F(true), - Source: cloudflare.F("primary"), - }), - Priority: cloudflare.F(10.000000), - Proxied: cloudflare.F(false), - Tags: cloudflare.F([]string{"owner:dns-team", "owner:dns-team", "owner:dns-team"}), - TTL: cloudflare.F[cloudflare.DNSRecordUpdateParamsTTL](shared.UnionFloat(3600.000000)), - }, - ) - 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 TestDNSRecordListWithOptionalParams(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("user@example.com"), - ) - _, err := client.DNS.Records.List(context.TODO(), cloudflare.DNSRecordListParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Comment: cloudflare.F(cloudflare.DNSRecordListParamsComment{ - Present: cloudflare.F("string"), - Absent: cloudflare.F("string"), - Exact: cloudflare.F("Hello, world"), - Contains: cloudflare.F("ello, worl"), - Startswith: cloudflare.F("Hello, w"), - Endswith: cloudflare.F("o, world"), - }), - Content: cloudflare.F("127.0.0.1"), - Direction: cloudflare.F(cloudflare.DNSRecordListParamsDirectionAsc), - Match: cloudflare.F(cloudflare.DNSRecordListParamsMatchAny), - Name: cloudflare.F("example.com"), - Order: cloudflare.F(cloudflare.DNSRecordListParamsOrderType), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(5.000000), - Proxied: cloudflare.F(false), - Search: cloudflare.F("www.cloudflare.com"), - Tag: cloudflare.F(cloudflare.DNSRecordListParamsTag{ - Present: cloudflare.F("important"), - Absent: cloudflare.F("important"), - Exact: cloudflare.F("greeting:Hello, world"), - Contains: cloudflare.F("greeting:ello, worl"), - Startswith: cloudflare.F("greeting:Hello, w"), - Endswith: cloudflare.F("greeting:o, world"), - }), - TagMatch: cloudflare.F(cloudflare.DNSRecordListParamsTagMatchAny), - Type: cloudflare.F(cloudflare.DNSRecordListParamsTypeA), - }) - 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 TestDNSRecordDelete(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("user@example.com"), - ) - _, err := client.DNS.Records.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.DNSRecordDeleteParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestDNSRecordEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.DNS.Records.Edit( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.DNSRecordEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Name: cloudflare.F("example.com"), - Type: cloudflare.F(cloudflare.DNSRecordEditParamsTypeURI), - Comment: cloudflare.F("Domain verification record"), - Data: cloudflare.F(cloudflare.DNSRecordEditParamsData{ - Flags: cloudflare.F("string"), - Tag: cloudflare.F("issue"), - Value: cloudflare.F("alpn=\"h3,h2\" ipv4hint=\"127.0.0.1\" ipv6hint=\"::1\""), - Algorithm: cloudflare.F(2.000000), - Certificate: cloudflare.F("string"), - KeyTag: cloudflare.F(1.000000), - Type: cloudflare.F(1.000000), - Protocol: cloudflare.F(3.000000), - PublicKey: cloudflare.F("string"), - Digest: cloudflare.F("string"), - DigestType: cloudflare.F(1.000000), - Priority: cloudflare.F(1.000000), - Target: cloudflare.F("."), - Altitude: cloudflare.F(0.000000), - LatDegrees: cloudflare.F(37.000000), - LatDirection: cloudflare.F(cloudflare.DNSRecordEditParamsDataLatDirectionN), - LatMinutes: cloudflare.F(46.000000), - LatSeconds: cloudflare.F(46.000000), - LongDegrees: cloudflare.F(122.000000), - LongDirection: cloudflare.F(cloudflare.DNSRecordEditParamsDataLongDirectionW), - LongMinutes: cloudflare.F(23.000000), - LongSeconds: cloudflare.F(35.000000), - PrecisionHorz: cloudflare.F(0.000000), - PrecisionVert: cloudflare.F(0.000000), - Size: cloudflare.F(100.000000), - Order: cloudflare.F(100.000000), - Preference: cloudflare.F(10.000000), - Regex: cloudflare.F("string"), - Replacement: cloudflare.F("string"), - Service: cloudflare.F("_sip"), - MatchingType: cloudflare.F(1.000000), - Selector: cloudflare.F(0.000000), - Usage: cloudflare.F(0.000000), - Name: cloudflare.F("example.com"), - Port: cloudflare.F(8806.000000), - Proto: cloudflare.F("_tcp"), - Weight: cloudflare.F(20.000000), - Fingerprint: cloudflare.F("string"), - Content: cloudflare.F("http://example.com/example.html"), - }), - Meta: cloudflare.F(cloudflare.DNSRecordEditParamsMeta{ - AutoAdded: cloudflare.F(true), - Source: cloudflare.F("primary"), - }), - Priority: cloudflare.F(10.000000), - Proxied: cloudflare.F(false), - Tags: cloudflare.F([]string{"owner:dns-team", "owner:dns-team", "owner:dns-team"}), - TTL: cloudflare.F[cloudflare.DNSRecordEditParamsTTL](shared.UnionFloat(3600.000000)), - }, - ) - 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 TestDNSRecordExport(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("user@example.com"), - ) - _, err := client.DNS.Records.Export(context.TODO(), cloudflare.DNSRecordExportParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestDNSRecordGet(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("user@example.com"), - ) - _, err := client.DNS.Records.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.DNSRecordGetParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestDNSRecordImportWithOptionalParams(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("user@example.com"), - ) - _, err := client.DNS.Records.Import(context.TODO(), cloudflare.DNSRecordImportParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - File: cloudflare.F("www.example.com. 300 IN A 127.0.0.1"), - Proxied: cloudflare.F("true"), - }) - 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 TestDNSRecordScan(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("user@example.com"), - ) - _, err := client.DNS.Records.Scan(context.TODO(), cloudflare.DNSRecordScanParams{ - ZoneID: cloudflare.F("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/dnssec/aliases.go b/dnssec/aliases.go new file mode 100644 index 00000000000..034880d63ae --- /dev/null +++ b/dnssec/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package dnssec + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/dnssec.go b/dnssec/dnssec.go similarity index 76% rename from dnssec.go rename to dnssec/dnssec.go index 57e9b6f7bff..0c9bd92064a 100644 --- a/dnssec.go +++ b/dnssec/dnssec.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package dnssec import ( "context" @@ -48,7 +48,7 @@ func (r *DNSSECService) Delete(ctx context.Context, body DNSSECDeleteParams, opt } // Enable or disable DNSSEC. -func (r *DNSSECService) Edit(ctx context.Context, params DNSSECEditParams, opts ...option.RequestOption) (res *DNSSECEditResponse, err error) { +func (r *DNSSECService) Edit(ctx context.Context, params DNSSECEditParams, opts ...option.RequestOption) (res *DNSSECDNSSEC, err error) { opts = append(r.Options[:], opts...) var env DNSSECEditResponseEnvelope path := fmt.Sprintf("zones/%s/dnssec", params.ZoneID) @@ -61,7 +61,7 @@ func (r *DNSSECService) Edit(ctx context.Context, params DNSSECEditParams, opts } // Details about DNSSEC status and configuration. -func (r *DNSSECService) Get(ctx context.Context, query DNSSECGetParams, opts ...option.RequestOption) (res *DNSSECGetResponse, err error) { +func (r *DNSSECService) Get(ctx context.Context, query DNSSECGetParams, opts ...option.RequestOption) (res *DNSSECDNSSEC, err error) { opts = append(r.Options[:], opts...) var env DNSSECGetResponseEnvelope path := fmt.Sprintf("zones/%s/dnssec", query.ZoneID) @@ -73,23 +73,7 @@ func (r *DNSSECService) Get(ctx context.Context, query DNSSECGetParams, opts ... return } -// Union satisfied by [DNSSECDeleteResponseUnknown] or [shared.UnionString]. -type DNSSECDeleteResponse interface { - ImplementsDNSSECDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*DNSSECDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type DNSSECEditResponse struct { +type DNSSECDNSSEC struct { // Algorithm key code. Algorithm string `json:"algorithm,nullable"` // Digest hash. @@ -128,13 +112,12 @@ type DNSSECEditResponse struct { // Public key for DS record. PublicKey string `json:"public_key,nullable"` // Status of DNSSEC, based on user-desired state and presence of necessary records. - Status DNSSECEditResponseStatus `json:"status"` - JSON dnssecEditResponseJSON `json:"-"` + Status DNSSECDNSSECStatus `json:"status"` + JSON dnssecdnssecJSON `json:"-"` } -// dnssecEditResponseJSON contains the JSON metadata for the struct -// [DNSSECEditResponse] -type dnssecEditResponseJSON struct { +// dnssecdnssecJSON contains the JSON metadata for the struct [DNSSECDNSSEC] +type dnssecdnssecJSON struct { Algorithm apijson.Field Digest apijson.Field DigestAlgorithm apijson.Field @@ -152,107 +135,41 @@ type dnssecEditResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *DNSSECEditResponse) UnmarshalJSON(data []byte) (err error) { +func (r *DNSSECDNSSEC) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r dnssecEditResponseJSON) RawJSON() string { +func (r dnssecdnssecJSON) RawJSON() string { return r.raw } // Status of DNSSEC, based on user-desired state and presence of necessary records. -type DNSSECEditResponseStatus string +type DNSSECDNSSECStatus string const ( - DNSSECEditResponseStatusActive DNSSECEditResponseStatus = "active" - DNSSECEditResponseStatusPending DNSSECEditResponseStatus = "pending" - DNSSECEditResponseStatusDisabled DNSSECEditResponseStatus = "disabled" - DNSSECEditResponseStatusPendingDisabled DNSSECEditResponseStatus = "pending-disabled" - DNSSECEditResponseStatusError DNSSECEditResponseStatus = "error" + DNSSECDNSSECStatusActive DNSSECDNSSECStatus = "active" + DNSSECDNSSECStatusPending DNSSECDNSSECStatus = "pending" + DNSSECDNSSECStatusDisabled DNSSECDNSSECStatus = "disabled" + DNSSECDNSSECStatusPendingDisabled DNSSECDNSSECStatus = "pending-disabled" + DNSSECDNSSECStatusError DNSSECDNSSECStatus = "error" ) -type DNSSECGetResponse struct { - // Algorithm key code. - Algorithm string `json:"algorithm,nullable"` - // Digest hash. - Digest string `json:"digest,nullable"` - // Type of digest algorithm. - DigestAlgorithm string `json:"digest_algorithm,nullable"` - // Coded type for digest algorithm. - DigestType string `json:"digest_type,nullable"` - // If true, multi-signer DNSSEC is enabled on the zone, allowing multiple providers - // to serve a DNSSEC-signed zone at the same time. This is required for DNSKEY - // records (except those automatically generated by Cloudflare) to be added to the - // zone. - // - // See - // [Multi-signer DNSSEC](https://developers.cloudflare.com/dns/dnssec/multi-signer-dnssec/) - // for details. - DNSSECMultiSigner bool `json:"dnssec_multi_signer"` - // If true, allows Cloudflare to transfer in a DNSSEC-signed zone including - // signatures from an external provider, without requiring Cloudflare to sign any - // records on the fly. - // - // Note that this feature has some limitations. See - // [Cloudflare as Secondary](https://developers.cloudflare.com/dns/zone-setups/zone-transfers/cloudflare-as-secondary/setup/#dnssec) - // for details. - DNSSECPresigned bool `json:"dnssec_presigned"` - // Full DS record. - DS string `json:"ds,nullable"` - // Flag for DNSSEC record. - Flags float64 `json:"flags,nullable"` - // Code for key tag. - KeyTag float64 `json:"key_tag,nullable"` - // Algorithm key type. - KeyType string `json:"key_type,nullable"` - // When DNSSEC was last modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - // Public key for DS record. - PublicKey string `json:"public_key,nullable"` - // Status of DNSSEC, based on user-desired state and presence of necessary records. - Status DNSSECGetResponseStatus `json:"status"` - JSON dnssecGetResponseJSON `json:"-"` -} - -// dnssecGetResponseJSON contains the JSON metadata for the struct -// [DNSSECGetResponse] -type dnssecGetResponseJSON struct { - Algorithm apijson.Field - Digest apijson.Field - DigestAlgorithm apijson.Field - DigestType apijson.Field - DNSSECMultiSigner apijson.Field - DNSSECPresigned apijson.Field - DS apijson.Field - Flags apijson.Field - KeyTag apijson.Field - KeyType apijson.Field - ModifiedOn apijson.Field - PublicKey apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DNSSECGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// Union satisfied by [dnssec.DNSSECDeleteResponseUnknown] or [shared.UnionString]. +type DNSSECDeleteResponse interface { + ImplementsDNSSECDNSSECDeleteResponse() } -func (r dnssecGetResponseJSON) RawJSON() string { - return r.raw +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DNSSECDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) } -// Status of DNSSEC, based on user-desired state and presence of necessary records. -type DNSSECGetResponseStatus string - -const ( - DNSSECGetResponseStatusActive DNSSECGetResponseStatus = "active" - DNSSECGetResponseStatusPending DNSSECGetResponseStatus = "pending" - DNSSECGetResponseStatusDisabled DNSSECGetResponseStatus = "disabled" - DNSSECGetResponseStatusPendingDisabled DNSSECGetResponseStatus = "pending-disabled" - DNSSECGetResponseStatusError DNSSECGetResponseStatus = "error" -) - type DNSSECDeleteParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -378,7 +295,7 @@ const ( type DNSSECEditResponseEnvelope struct { Errors []DNSSECEditResponseEnvelopeErrors `json:"errors,required"` Messages []DNSSECEditResponseEnvelopeMessages `json:"messages,required"` - Result DNSSECEditResponse `json:"result,required"` + Result DNSSECDNSSEC `json:"result,required"` // Whether the API call was successful Success DNSSECEditResponseEnvelopeSuccess `json:"success,required"` JSON dnssecEditResponseEnvelopeJSON `json:"-"` @@ -464,7 +381,7 @@ type DNSSECGetParams struct { type DNSSECGetResponseEnvelope struct { Errors []DNSSECGetResponseEnvelopeErrors `json:"errors,required"` Messages []DNSSECGetResponseEnvelopeMessages `json:"messages,required"` - Result DNSSECGetResponse `json:"result,required"` + Result DNSSECDNSSEC `json:"result,required"` // Whether the API call was successful Success DNSSECGetResponseEnvelopeSuccess `json:"success,required"` JSON dnssecGetResponseEnvelopeJSON `json:"-"` diff --git a/dnssec_test.go b/dnssec/dnssec_test.go similarity index 87% rename from dnssec_test.go rename to dnssec/dnssec_test.go index 6206b7ddfd5..5aaf6a804da 100644 --- a/dnssec_test.go +++ b/dnssec/dnssec_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package dnssec_test import ( "context" @@ -9,6 +9,7 @@ import ( "testing" "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/dnssec" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" ) @@ -27,7 +28,7 @@ func TestDNSSECDelete(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.DNSSEC.Delete(context.TODO(), cloudflare.DNSSECDeleteParams{ + _, err := client.DNSSEC.Delete(context.TODO(), dnssec.DNSSECDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { @@ -53,11 +54,11 @@ func TestDNSSECEditWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.DNSSEC.Edit(context.TODO(), cloudflare.DNSSECEditParams{ + _, err := client.DNSSEC.Edit(context.TODO(), dnssec.DNSSECEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), DNSSECMultiSigner: cloudflare.F(false), DNSSECPresigned: cloudflare.F(true), - Status: cloudflare.F(cloudflare.DNSSECEditParamsStatusActive), + Status: cloudflare.F(dnssec.DNSSECEditParamsStatusActive), }) if err != nil { var apierr *cloudflare.Error @@ -82,7 +83,7 @@ func TestDNSSECGet(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.DNSSEC.Get(context.TODO(), cloudflare.DNSSECGetParams{ + _, err := client.DNSSEC.Get(context.TODO(), dnssec.DNSSECGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { diff --git a/durable_objects/aliases.go b/durable_objects/aliases.go new file mode 100644 index 00000000000..95c043ed13f --- /dev/null +++ b/durable_objects/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package durable_objects + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/durableobject.go b/durable_objects/durableobject.go similarity index 88% rename from durableobject.go rename to durable_objects/durableobject.go index b69725b4f0f..3a1caefa77b 100644 --- a/durableobject.go +++ b/durable_objects/durableobject.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package durable_objects import ( "github.com/cloudflare/cloudflare-go/option" @@ -13,7 +13,7 @@ import ( // instead. type DurableObjectService struct { Options []option.RequestOption - Namespaces *DurableObjectNamespaceService + Namespaces *NamespaceService } // NewDurableObjectService generates a new service that applies the given options @@ -22,6 +22,6 @@ type DurableObjectService struct { func NewDurableObjectService(opts ...option.RequestOption) (r *DurableObjectService) { r = &DurableObjectService{} r.Options = opts - r.Namespaces = NewDurableObjectNamespaceService(opts...) + r.Namespaces = NewNamespaceService(opts...) return } diff --git a/durable_objects/namespace.go b/durable_objects/namespace.go new file mode 100644 index 00000000000..0dafa3ead4b --- /dev/null +++ b/durable_objects/namespace.go @@ -0,0 +1,192 @@ +// File generated from our OpenAPI spec by Stainless. + +package durable_objects + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// NamespaceService 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 [NewNamespaceService] method instead. +type NamespaceService struct { + Options []option.RequestOption + Objects *NamespaceObjectService +} + +// NewNamespaceService 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 NewNamespaceService(opts ...option.RequestOption) (r *NamespaceService) { + r = &NamespaceService{} + r.Options = opts + r.Objects = NewNamespaceObjectService(opts...) + return +} + +// Returns the Durable Object namespaces owned by an account. +func (r *NamespaceService) List(ctx context.Context, query NamespaceListParams, opts ...option.RequestOption) (res *[]WorkersNamespace, err error) { + opts = append(r.Options[:], opts...) + var env NamespaceListResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/durable_objects/namespaces", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type WorkersNamespace struct { + ID interface{} `json:"id"` + Class interface{} `json:"class"` + Name interface{} `json:"name"` + Script interface{} `json:"script"` + JSON workersNamespaceJSON `json:"-"` +} + +// workersNamespaceJSON contains the JSON metadata for the struct +// [WorkersNamespace] +type workersNamespaceJSON struct { + ID apijson.Field + Class apijson.Field + Name apijson.Field + Script apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersNamespace) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersNamespaceJSON) RawJSON() string { + return r.raw +} + +type NamespaceListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type NamespaceListResponseEnvelope struct { + Errors []NamespaceListResponseEnvelopeErrors `json:"errors,required"` + Messages []NamespaceListResponseEnvelopeMessages `json:"messages,required"` + Result []WorkersNamespace `json:"result,required,nullable"` + // Whether the API call was successful + Success NamespaceListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo NamespaceListResponseEnvelopeResultInfo `json:"result_info"` + JSON namespaceListResponseEnvelopeJSON `json:"-"` +} + +// namespaceListResponseEnvelopeJSON contains the JSON metadata for the struct +// [NamespaceListResponseEnvelope] +type namespaceListResponseEnvelopeJSON 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 *NamespaceListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NamespaceListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceListResponseEnvelopeErrorsJSON `json:"-"` +} + +// namespaceListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [NamespaceListResponseEnvelopeErrors] +type namespaceListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NamespaceListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceListResponseEnvelopeMessagesJSON `json:"-"` +} + +// namespaceListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [NamespaceListResponseEnvelopeMessages] +type namespaceListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NamespaceListResponseEnvelopeSuccess bool + +const ( + NamespaceListResponseEnvelopeSuccessTrue NamespaceListResponseEnvelopeSuccess = true +) + +type NamespaceListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON namespaceListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// namespaceListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [NamespaceListResponseEnvelopeResultInfo] +type namespaceListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/durable_objects/namespace_test.go b/durable_objects/namespace_test.go new file mode 100644 index 00000000000..ea9e5757d33 --- /dev/null +++ b/durable_objects/namespace_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package durable_objects_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/durable_objects" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestNamespaceList(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("user@example.com"), + ) + _, err := client.DurableObjects.Namespaces.List(context.TODO(), durable_objects.NamespaceListParams{ + AccountID: cloudflare.F("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/durable_objects/namespaceobject.go b/durable_objects/namespaceobject.go new file mode 100644 index 00000000000..697786e1b5f --- /dev/null +++ b/durable_objects/namespaceobject.go @@ -0,0 +1,211 @@ +// File generated from our OpenAPI spec by Stainless. + +package durable_objects + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// NamespaceObjectService 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 [NewNamespaceObjectService] method +// instead. +type NamespaceObjectService struct { + Options []option.RequestOption +} + +// NewNamespaceObjectService 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 NewNamespaceObjectService(opts ...option.RequestOption) (r *NamespaceObjectService) { + r = &NamespaceObjectService{} + r.Options = opts + return +} + +// Returns the Durable Objects in a given namespace. +func (r *NamespaceObjectService) List(ctx context.Context, id string, params NamespaceObjectListParams, opts ...option.RequestOption) (res *[]WorkersObject, err error) { + opts = append(r.Options[:], opts...) + var env NamespaceObjectListResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/durable_objects/namespaces/%s/objects", params.AccountID, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type WorkersObject struct { + // ID of the Durable Object. + ID string `json:"id"` + // Whether the Durable Object has stored data. + HasStoredData bool `json:"hasStoredData"` + JSON workersObjectJSON `json:"-"` +} + +// workersObjectJSON contains the JSON metadata for the struct [WorkersObject] +type workersObjectJSON struct { + ID apijson.Field + HasStoredData apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersObject) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersObjectJSON) RawJSON() string { + return r.raw +} + +type NamespaceObjectListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Opaque token indicating the position from which to continue when requesting the + // next set of records. A valid value for the cursor can be obtained from the + // cursors object in the result_info structure. + Cursor param.Field[string] `query:"cursor"` + // The number of objects to return. The cursor attribute may be used to iterate + // over the next batch of objects if there are more than the limit. + Limit param.Field[float64] `query:"limit"` +} + +// URLQuery serializes [NamespaceObjectListParams]'s query parameters as +// `url.Values`. +func (r NamespaceObjectListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type NamespaceObjectListResponseEnvelope struct { + Errors []NamespaceObjectListResponseEnvelopeErrors `json:"errors,required"` + Messages []NamespaceObjectListResponseEnvelopeMessages `json:"messages,required"` + Result []WorkersObject `json:"result,required,nullable"` + // Whether the API call was successful + Success NamespaceObjectListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo NamespaceObjectListResponseEnvelopeResultInfo `json:"result_info"` + JSON namespaceObjectListResponseEnvelopeJSON `json:"-"` +} + +// namespaceObjectListResponseEnvelopeJSON contains the JSON metadata for the +// struct [NamespaceObjectListResponseEnvelope] +type namespaceObjectListResponseEnvelopeJSON 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 *NamespaceObjectListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceObjectListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NamespaceObjectListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceObjectListResponseEnvelopeErrorsJSON `json:"-"` +} + +// namespaceObjectListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [NamespaceObjectListResponseEnvelopeErrors] +type namespaceObjectListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceObjectListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceObjectListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NamespaceObjectListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceObjectListResponseEnvelopeMessagesJSON `json:"-"` +} + +// namespaceObjectListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [NamespaceObjectListResponseEnvelopeMessages] +type namespaceObjectListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceObjectListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceObjectListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NamespaceObjectListResponseEnvelopeSuccess bool + +const ( + NamespaceObjectListResponseEnvelopeSuccessTrue NamespaceObjectListResponseEnvelopeSuccess = true +) + +type NamespaceObjectListResponseEnvelopeResultInfo struct { + // Total results returned based on your list parameters. + Count float64 `json:"count"` + // Opaque token indicating the position from which to continue when requesting the + // next set of records. A valid value for the cursor can be obtained from the + // cursors object in the result_info structure. + Cursor string `json:"cursor"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON namespaceObjectListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// namespaceObjectListResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [NamespaceObjectListResponseEnvelopeResultInfo] +type namespaceObjectListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Cursor apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceObjectListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceObjectListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/durable_objects/namespaceobject_test.go b/durable_objects/namespaceobject_test.go new file mode 100644 index 00000000000..9004628eba0 --- /dev/null +++ b/durable_objects/namespaceobject_test.go @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package durable_objects_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/durable_objects" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestNamespaceObjectListWithOptionalParams(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("user@example.com"), + ) + _, err := client.DurableObjects.Namespaces.Objects.List( + context.TODO(), + "5fd1cafff895419c8bcc647fc64ab8f0", + durable_objects.NamespaceObjectListParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Cursor: cloudflare.F("AAAAANuhDN7SjacTnSVsDu3WW1Lvst6dxJGTjRY5BhxPXdf6L6uTcpd_NVtjhn11OUYRsVEykxoUwF-JQU4dn6QylZSKTOJuG0indrdn_MlHpMRtsxgXjs-RPdHYIVm3odE_uvEQ_dTQGFm8oikZMohns34DLBgrQpc"), + Limit: cloudflare.F(10.000000), + }, + ) + 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/durableobjectnamespace.go b/durableobjectnamespace.go deleted file mode 100644 index e612973f7cb..00000000000 --- a/durableobjectnamespace.go +++ /dev/null @@ -1,193 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// DurableObjectNamespaceService 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 [NewDurableObjectNamespaceService] -// method instead. -type DurableObjectNamespaceService struct { - Options []option.RequestOption - Objects *DurableObjectNamespaceObjectService -} - -// NewDurableObjectNamespaceService 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 NewDurableObjectNamespaceService(opts ...option.RequestOption) (r *DurableObjectNamespaceService) { - r = &DurableObjectNamespaceService{} - r.Options = opts - r.Objects = NewDurableObjectNamespaceObjectService(opts...) - return -} - -// Returns the Durable Object namespaces owned by an account. -func (r *DurableObjectNamespaceService) List(ctx context.Context, query DurableObjectNamespaceListParams, opts ...option.RequestOption) (res *[]DurableObjectNamespaceListResponse, err error) { - opts = append(r.Options[:], opts...) - var env DurableObjectNamespaceListResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/durable_objects/namespaces", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type DurableObjectNamespaceListResponse struct { - ID interface{} `json:"id"` - Class interface{} `json:"class"` - Name interface{} `json:"name"` - Script interface{} `json:"script"` - JSON durableObjectNamespaceListResponseJSON `json:"-"` -} - -// durableObjectNamespaceListResponseJSON contains the JSON metadata for the struct -// [DurableObjectNamespaceListResponse] -type durableObjectNamespaceListResponseJSON struct { - ID apijson.Field - Class apijson.Field - Name apijson.Field - Script apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DurableObjectNamespaceListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r durableObjectNamespaceListResponseJSON) RawJSON() string { - return r.raw -} - -type DurableObjectNamespaceListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type DurableObjectNamespaceListResponseEnvelope struct { - Errors []DurableObjectNamespaceListResponseEnvelopeErrors `json:"errors,required"` - Messages []DurableObjectNamespaceListResponseEnvelopeMessages `json:"messages,required"` - Result []DurableObjectNamespaceListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success DurableObjectNamespaceListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo DurableObjectNamespaceListResponseEnvelopeResultInfo `json:"result_info"` - JSON durableObjectNamespaceListResponseEnvelopeJSON `json:"-"` -} - -// durableObjectNamespaceListResponseEnvelopeJSON contains the JSON metadata for -// the struct [DurableObjectNamespaceListResponseEnvelope] -type durableObjectNamespaceListResponseEnvelopeJSON 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 *DurableObjectNamespaceListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r durableObjectNamespaceListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DurableObjectNamespaceListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON durableObjectNamespaceListResponseEnvelopeErrorsJSON `json:"-"` -} - -// durableObjectNamespaceListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [DurableObjectNamespaceListResponseEnvelopeErrors] -type durableObjectNamespaceListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DurableObjectNamespaceListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r durableObjectNamespaceListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DurableObjectNamespaceListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON durableObjectNamespaceListResponseEnvelopeMessagesJSON `json:"-"` -} - -// durableObjectNamespaceListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [DurableObjectNamespaceListResponseEnvelopeMessages] -type durableObjectNamespaceListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DurableObjectNamespaceListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r durableObjectNamespaceListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DurableObjectNamespaceListResponseEnvelopeSuccess bool - -const ( - DurableObjectNamespaceListResponseEnvelopeSuccessTrue DurableObjectNamespaceListResponseEnvelopeSuccess = true -) - -type DurableObjectNamespaceListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON durableObjectNamespaceListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// durableObjectNamespaceListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [DurableObjectNamespaceListResponseEnvelopeResultInfo] -type durableObjectNamespaceListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DurableObjectNamespaceListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r durableObjectNamespaceListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/durableobjectnamespace_test.go b/durableobjectnamespace_test.go deleted file mode 100644 index a2463a768c0..00000000000 --- a/durableobjectnamespace_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestDurableObjectNamespaceList(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("user@example.com"), - ) - _, err := client.DurableObjects.Namespaces.List(context.TODO(), cloudflare.DurableObjectNamespaceListParams{ - AccountID: cloudflare.F("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/durableobjectnamespaceobject.go b/durableobjectnamespaceobject.go deleted file mode 100644 index e52d156ec3a..00000000000 --- a/durableobjectnamespaceobject.go +++ /dev/null @@ -1,214 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// DurableObjectNamespaceObjectService 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 -// [NewDurableObjectNamespaceObjectService] method instead. -type DurableObjectNamespaceObjectService struct { - Options []option.RequestOption -} - -// NewDurableObjectNamespaceObjectService 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 NewDurableObjectNamespaceObjectService(opts ...option.RequestOption) (r *DurableObjectNamespaceObjectService) { - r = &DurableObjectNamespaceObjectService{} - r.Options = opts - return -} - -// Returns the Durable Objects in a given namespace. -func (r *DurableObjectNamespaceObjectService) List(ctx context.Context, id string, params DurableObjectNamespaceObjectListParams, opts ...option.RequestOption) (res *[]DurableObjectNamespaceObjectListResponse, err error) { - opts = append(r.Options[:], opts...) - var env DurableObjectNamespaceObjectListResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/durable_objects/namespaces/%s/objects", params.AccountID, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type DurableObjectNamespaceObjectListResponse struct { - // ID of the Durable Object. - ID string `json:"id"` - // Whether the Durable Object has stored data. - HasStoredData bool `json:"hasStoredData"` - JSON durableObjectNamespaceObjectListResponseJSON `json:"-"` -} - -// durableObjectNamespaceObjectListResponseJSON contains the JSON metadata for the -// struct [DurableObjectNamespaceObjectListResponse] -type durableObjectNamespaceObjectListResponseJSON struct { - ID apijson.Field - HasStoredData apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DurableObjectNamespaceObjectListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r durableObjectNamespaceObjectListResponseJSON) RawJSON() string { - return r.raw -} - -type DurableObjectNamespaceObjectListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Opaque token indicating the position from which to continue when requesting the - // next set of records. A valid value for the cursor can be obtained from the - // cursors object in the result_info structure. - Cursor param.Field[string] `query:"cursor"` - // The number of objects to return. The cursor attribute may be used to iterate - // over the next batch of objects if there are more than the limit. - Limit param.Field[float64] `query:"limit"` -} - -// URLQuery serializes [DurableObjectNamespaceObjectListParams]'s query parameters -// as `url.Values`. -func (r DurableObjectNamespaceObjectListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type DurableObjectNamespaceObjectListResponseEnvelope struct { - Errors []DurableObjectNamespaceObjectListResponseEnvelopeErrors `json:"errors,required"` - Messages []DurableObjectNamespaceObjectListResponseEnvelopeMessages `json:"messages,required"` - Result []DurableObjectNamespaceObjectListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success DurableObjectNamespaceObjectListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo DurableObjectNamespaceObjectListResponseEnvelopeResultInfo `json:"result_info"` - JSON durableObjectNamespaceObjectListResponseEnvelopeJSON `json:"-"` -} - -// durableObjectNamespaceObjectListResponseEnvelopeJSON contains the JSON metadata -// for the struct [DurableObjectNamespaceObjectListResponseEnvelope] -type durableObjectNamespaceObjectListResponseEnvelopeJSON 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 *DurableObjectNamespaceObjectListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r durableObjectNamespaceObjectListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type DurableObjectNamespaceObjectListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON durableObjectNamespaceObjectListResponseEnvelopeErrorsJSON `json:"-"` -} - -// durableObjectNamespaceObjectListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [DurableObjectNamespaceObjectListResponseEnvelopeErrors] -type durableObjectNamespaceObjectListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DurableObjectNamespaceObjectListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r durableObjectNamespaceObjectListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type DurableObjectNamespaceObjectListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON durableObjectNamespaceObjectListResponseEnvelopeMessagesJSON `json:"-"` -} - -// durableObjectNamespaceObjectListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [DurableObjectNamespaceObjectListResponseEnvelopeMessages] -type durableObjectNamespaceObjectListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DurableObjectNamespaceObjectListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r durableObjectNamespaceObjectListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type DurableObjectNamespaceObjectListResponseEnvelopeSuccess bool - -const ( - DurableObjectNamespaceObjectListResponseEnvelopeSuccessTrue DurableObjectNamespaceObjectListResponseEnvelopeSuccess = true -) - -type DurableObjectNamespaceObjectListResponseEnvelopeResultInfo struct { - // Total results returned based on your list parameters. - Count float64 `json:"count"` - // Opaque token indicating the position from which to continue when requesting the - // next set of records. A valid value for the cursor can be obtained from the - // cursors object in the result_info structure. - Cursor string `json:"cursor"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON durableObjectNamespaceObjectListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// durableObjectNamespaceObjectListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [DurableObjectNamespaceObjectListResponseEnvelopeResultInfo] -type durableObjectNamespaceObjectListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Cursor apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *DurableObjectNamespaceObjectListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r durableObjectNamespaceObjectListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/durableobjectnamespaceobject_test.go b/durableobjectnamespaceobject_test.go deleted file mode 100644 index a8492cdc201..00000000000 --- a/durableobjectnamespaceobject_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestDurableObjectNamespaceObjectListWithOptionalParams(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("user@example.com"), - ) - _, err := client.DurableObjects.Namespaces.Objects.List( - context.TODO(), - "5fd1cafff895419c8bcc647fc64ab8f0", - cloudflare.DurableObjectNamespaceObjectListParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Cursor: cloudflare.F("AAAAANuhDN7SjacTnSVsDu3WW1Lvst6dxJGTjRY5BhxPXdf6L6uTcpd_NVtjhn11OUYRsVEykxoUwF-JQU4dn6QylZSKTOJuG0indrdn_MlHpMRtsxgXjs-RPdHYIVm3odE_uvEQ_dTQGFm8oikZMohns34DLBgrQpc"), - Limit: cloudflare.F(10.000000), - }, - ) - 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/email_routing/aliases.go b/email_routing/aliases.go new file mode 100644 index 00000000000..8b3ee41cd3c --- /dev/null +++ b/email_routing/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package email_routing + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/email_routing/emailrouting.go b/email_routing/emailrouting.go new file mode 100644 index 00000000000..e4658126517 --- /dev/null +++ b/email_routing/emailrouting.go @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package email_routing + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// EmailRoutingService 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 [NewEmailRoutingService] method +// instead. +type EmailRoutingService struct { + Options []option.RequestOption + Routing *RoutingService +} + +// NewEmailRoutingService 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 NewEmailRoutingService(opts ...option.RequestOption) (r *EmailRoutingService) { + r = &EmailRoutingService{} + r.Options = opts + r.Routing = NewRoutingService(opts...) + return +} diff --git a/email_routing/routing.go b/email_routing/routing.go new file mode 100644 index 00000000000..0073569dda0 --- /dev/null +++ b/email_routing/routing.go @@ -0,0 +1,206 @@ +// File generated from our OpenAPI spec by Stainless. + +package email_routing + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// RoutingService 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 [NewRoutingService] method instead. +type RoutingService struct { + Options []option.RequestOption + Disables *RoutingDisableService + DNS *RoutingDNSService + Enables *RoutingEnableService + Rules *RoutingRuleService + Addresses *RoutingAddressService +} + +// NewRoutingService 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 NewRoutingService(opts ...option.RequestOption) (r *RoutingService) { + r = &RoutingService{} + r.Options = opts + r.Disables = NewRoutingDisableService(opts...) + r.DNS = NewRoutingDNSService(opts...) + r.Enables = NewRoutingEnableService(opts...) + r.Rules = NewRoutingRuleService(opts...) + r.Addresses = NewRoutingAddressService(opts...) + return +} + +// Get information about the settings for your Email Routing zone. +func (r *RoutingService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *RoutingGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RoutingGetResponseEnvelope + path := fmt.Sprintf("zones/%s/email/routing", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type RoutingGetResponse struct { + // Email Routing settings identifier. + ID string `json:"id"` + // The date and time the settings have been created. + Created time.Time `json:"created" format:"date-time"` + // State of the zone settings for Email Routing. + Enabled RoutingGetResponseEnabled `json:"enabled"` + // The date and time the settings have been modified. + Modified time.Time `json:"modified" format:"date-time"` + // Domain of your zone. + Name string `json:"name"` + // Flag to check if the user skipped the configuration wizard. + SkipWizard RoutingGetResponseSkipWizard `json:"skip_wizard"` + // Show the state of your account, and the type or configuration error. + Status RoutingGetResponseStatus `json:"status"` + // Email Routing settings tag. (Deprecated, replaced by Email Routing settings + // identifier) + Tag string `json:"tag"` + JSON routingGetResponseJSON `json:"-"` +} + +// routingGetResponseJSON contains the JSON metadata for the struct +// [RoutingGetResponse] +type routingGetResponseJSON struct { + ID apijson.Field + Created apijson.Field + Enabled apijson.Field + Modified apijson.Field + Name apijson.Field + SkipWizard apijson.Field + Status apijson.Field + Tag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingGetResponseJSON) RawJSON() string { + return r.raw +} + +// State of the zone settings for Email Routing. +type RoutingGetResponseEnabled bool + +const ( + RoutingGetResponseEnabledTrue RoutingGetResponseEnabled = true + RoutingGetResponseEnabledFalse RoutingGetResponseEnabled = false +) + +// Flag to check if the user skipped the configuration wizard. +type RoutingGetResponseSkipWizard bool + +const ( + RoutingGetResponseSkipWizardTrue RoutingGetResponseSkipWizard = true + RoutingGetResponseSkipWizardFalse RoutingGetResponseSkipWizard = false +) + +// Show the state of your account, and the type or configuration error. +type RoutingGetResponseStatus string + +const ( + RoutingGetResponseStatusReady RoutingGetResponseStatus = "ready" + RoutingGetResponseStatusUnconfigured RoutingGetResponseStatus = "unconfigured" + RoutingGetResponseStatusMisconfigured RoutingGetResponseStatus = "misconfigured" + RoutingGetResponseStatusMisconfiguredLocked RoutingGetResponseStatus = "misconfigured/locked" + RoutingGetResponseStatusUnlocked RoutingGetResponseStatus = "unlocked" +) + +type RoutingGetResponseEnvelope struct { + Errors []RoutingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RoutingGetResponseEnvelopeMessages `json:"messages,required"` + Result RoutingGetResponse `json:"result,required"` + // Whether the API call was successful + Success RoutingGetResponseEnvelopeSuccess `json:"success,required"` + JSON routingGetResponseEnvelopeJSON `json:"-"` +} + +// routingGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RoutingGetResponseEnvelope] +type routingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RoutingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// routingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RoutingGetResponseEnvelopeErrors] +type routingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RoutingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// routingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RoutingGetResponseEnvelopeMessages] +type routingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RoutingGetResponseEnvelopeSuccess bool + +const ( + RoutingGetResponseEnvelopeSuccessTrue RoutingGetResponseEnvelopeSuccess = true +) diff --git a/email_routing/routing_test.go b/email_routing/routing_test.go new file mode 100644 index 00000000000..d88bb39b4e4 --- /dev/null +++ b/email_routing/routing_test.go @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package email_routing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRoutingGet(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("user@example.com"), + ) + _, err := client.EmailRouting.Routing.Get(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/email_routing/routingaddress.go b/email_routing/routingaddress.go new file mode 100644 index 00000000000..1245833b5dc --- /dev/null +++ b/email_routing/routingaddress.go @@ -0,0 +1,543 @@ +// File generated from our OpenAPI spec by Stainless. + +package email_routing + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" +) + +// RoutingAddressService 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 [NewRoutingAddressService] method +// instead. +type RoutingAddressService struct { + Options []option.RequestOption +} + +// NewRoutingAddressService 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 NewRoutingAddressService(opts ...option.RequestOption) (r *RoutingAddressService) { + r = &RoutingAddressService{} + r.Options = opts + return +} + +// Create a destination address to forward your emails to. Destination addresses +// need to be verified before they can be used. +func (r *RoutingAddressService) New(ctx context.Context, accountIdentifier string, body RoutingAddressNewParams, opts ...option.RequestOption) (res *RoutingAddressNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env RoutingAddressNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/email/routing/addresses", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists existing destination addresses. +func (r *RoutingAddressService) List(ctx context.Context, accountIdentifier string, query RoutingAddressListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[RoutingAddressListResponse], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("accounts/%s/email/routing/addresses", accountIdentifier) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists existing destination addresses. +func (r *RoutingAddressService) ListAutoPaging(ctx context.Context, accountIdentifier string, query RoutingAddressListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[RoutingAddressListResponse] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, accountIdentifier, query, opts...)) +} + +// Deletes a specific destination address. +func (r *RoutingAddressService) Delete(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string, opts ...option.RequestOption) (res *RoutingAddressDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env RoutingAddressDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/email/routing/addresses/%s", accountIdentifier, destinationAddressIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets information for a specific destination email already created. +func (r *RoutingAddressService) Get(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string, opts ...option.RequestOption) (res *RoutingAddressGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RoutingAddressGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/email/routing/addresses/%s", accountIdentifier, destinationAddressIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type RoutingAddressNewResponse struct { + // Destination address identifier. + ID string `json:"id"` + // The date and time the destination address has been created. + Created time.Time `json:"created" format:"date-time"` + // The contact email address of the user. + Email string `json:"email"` + // The date and time the destination address was last modified. + Modified time.Time `json:"modified" format:"date-time"` + // Destination address tag. (Deprecated, replaced by destination address + // identifier) + Tag string `json:"tag"` + // The date and time the destination address has been verified. Null means not + // verified yet. + Verified time.Time `json:"verified" format:"date-time"` + JSON routingAddressNewResponseJSON `json:"-"` +} + +// routingAddressNewResponseJSON contains the JSON metadata for the struct +// [RoutingAddressNewResponse] +type routingAddressNewResponseJSON struct { + ID apijson.Field + Created apijson.Field + Email apijson.Field + Modified apijson.Field + Tag apijson.Field + Verified apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingAddressNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingAddressNewResponseJSON) RawJSON() string { + return r.raw +} + +type RoutingAddressListResponse struct { + // Destination address identifier. + ID string `json:"id"` + // The date and time the destination address has been created. + Created time.Time `json:"created" format:"date-time"` + // The contact email address of the user. + Email string `json:"email"` + // The date and time the destination address was last modified. + Modified time.Time `json:"modified" format:"date-time"` + // Destination address tag. (Deprecated, replaced by destination address + // identifier) + Tag string `json:"tag"` + // The date and time the destination address has been verified. Null means not + // verified yet. + Verified time.Time `json:"verified" format:"date-time"` + JSON routingAddressListResponseJSON `json:"-"` +} + +// routingAddressListResponseJSON contains the JSON metadata for the struct +// [RoutingAddressListResponse] +type routingAddressListResponseJSON struct { + ID apijson.Field + Created apijson.Field + Email apijson.Field + Modified apijson.Field + Tag apijson.Field + Verified apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingAddressListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingAddressListResponseJSON) RawJSON() string { + return r.raw +} + +type RoutingAddressDeleteResponse struct { + // Destination address identifier. + ID string `json:"id"` + // The date and time the destination address has been created. + Created time.Time `json:"created" format:"date-time"` + // The contact email address of the user. + Email string `json:"email"` + // The date and time the destination address was last modified. + Modified time.Time `json:"modified" format:"date-time"` + // Destination address tag. (Deprecated, replaced by destination address + // identifier) + Tag string `json:"tag"` + // The date and time the destination address has been verified. Null means not + // verified yet. + Verified time.Time `json:"verified" format:"date-time"` + JSON routingAddressDeleteResponseJSON `json:"-"` +} + +// routingAddressDeleteResponseJSON contains the JSON metadata for the struct +// [RoutingAddressDeleteResponse] +type routingAddressDeleteResponseJSON struct { + ID apijson.Field + Created apijson.Field + Email apijson.Field + Modified apijson.Field + Tag apijson.Field + Verified apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingAddressDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingAddressDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type RoutingAddressGetResponse struct { + // Destination address identifier. + ID string `json:"id"` + // The date and time the destination address has been created. + Created time.Time `json:"created" format:"date-time"` + // The contact email address of the user. + Email string `json:"email"` + // The date and time the destination address was last modified. + Modified time.Time `json:"modified" format:"date-time"` + // Destination address tag. (Deprecated, replaced by destination address + // identifier) + Tag string `json:"tag"` + // The date and time the destination address has been verified. Null means not + // verified yet. + Verified time.Time `json:"verified" format:"date-time"` + JSON routingAddressGetResponseJSON `json:"-"` +} + +// routingAddressGetResponseJSON contains the JSON metadata for the struct +// [RoutingAddressGetResponse] +type routingAddressGetResponseJSON struct { + ID apijson.Field + Created apijson.Field + Email apijson.Field + Modified apijson.Field + Tag apijson.Field + Verified apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingAddressGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingAddressGetResponseJSON) RawJSON() string { + return r.raw +} + +type RoutingAddressNewParams struct { + // The contact email address of the user. + Email param.Field[string] `json:"email,required"` +} + +func (r RoutingAddressNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RoutingAddressNewResponseEnvelope struct { + Errors []RoutingAddressNewResponseEnvelopeErrors `json:"errors,required"` + Messages []RoutingAddressNewResponseEnvelopeMessages `json:"messages,required"` + Result RoutingAddressNewResponse `json:"result,required"` + // Whether the API call was successful + Success RoutingAddressNewResponseEnvelopeSuccess `json:"success,required"` + JSON routingAddressNewResponseEnvelopeJSON `json:"-"` +} + +// routingAddressNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [RoutingAddressNewResponseEnvelope] +type routingAddressNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingAddressNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingAddressNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RoutingAddressNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingAddressNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// routingAddressNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RoutingAddressNewResponseEnvelopeErrors] +type routingAddressNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingAddressNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingAddressNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RoutingAddressNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingAddressNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// routingAddressNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RoutingAddressNewResponseEnvelopeMessages] +type routingAddressNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingAddressNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingAddressNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RoutingAddressNewResponseEnvelopeSuccess bool + +const ( + RoutingAddressNewResponseEnvelopeSuccessTrue RoutingAddressNewResponseEnvelopeSuccess = true +) + +type RoutingAddressListParams struct { + // Sorts results in an ascending or descending order. + Direction param.Field[RoutingAddressListParamsDirection] `query:"direction"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // Maximum number of results per page. + PerPage param.Field[float64] `query:"per_page"` + // Filter by verified destination addresses. + Verified param.Field[RoutingAddressListParamsVerified] `query:"verified"` +} + +// URLQuery serializes [RoutingAddressListParams]'s query parameters as +// `url.Values`. +func (r RoutingAddressListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Sorts results in an ascending or descending order. +type RoutingAddressListParamsDirection string + +const ( + RoutingAddressListParamsDirectionAsc RoutingAddressListParamsDirection = "asc" + RoutingAddressListParamsDirectionDesc RoutingAddressListParamsDirection = "desc" +) + +// Filter by verified destination addresses. +type RoutingAddressListParamsVerified bool + +const ( + RoutingAddressListParamsVerifiedTrue RoutingAddressListParamsVerified = true + RoutingAddressListParamsVerifiedFalse RoutingAddressListParamsVerified = false +) + +type RoutingAddressDeleteResponseEnvelope struct { + Errors []RoutingAddressDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []RoutingAddressDeleteResponseEnvelopeMessages `json:"messages,required"` + Result RoutingAddressDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success RoutingAddressDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON routingAddressDeleteResponseEnvelopeJSON `json:"-"` +} + +// routingAddressDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [RoutingAddressDeleteResponseEnvelope] +type routingAddressDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingAddressDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingAddressDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RoutingAddressDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingAddressDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// routingAddressDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [RoutingAddressDeleteResponseEnvelopeErrors] +type routingAddressDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingAddressDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingAddressDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RoutingAddressDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingAddressDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// routingAddressDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [RoutingAddressDeleteResponseEnvelopeMessages] +type routingAddressDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingAddressDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingAddressDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RoutingAddressDeleteResponseEnvelopeSuccess bool + +const ( + RoutingAddressDeleteResponseEnvelopeSuccessTrue RoutingAddressDeleteResponseEnvelopeSuccess = true +) + +type RoutingAddressGetResponseEnvelope struct { + Errors []RoutingAddressGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RoutingAddressGetResponseEnvelopeMessages `json:"messages,required"` + Result RoutingAddressGetResponse `json:"result,required"` + // Whether the API call was successful + Success RoutingAddressGetResponseEnvelopeSuccess `json:"success,required"` + JSON routingAddressGetResponseEnvelopeJSON `json:"-"` +} + +// routingAddressGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RoutingAddressGetResponseEnvelope] +type routingAddressGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingAddressGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingAddressGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RoutingAddressGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingAddressGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// routingAddressGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RoutingAddressGetResponseEnvelopeErrors] +type routingAddressGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingAddressGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingAddressGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RoutingAddressGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingAddressGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// routingAddressGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RoutingAddressGetResponseEnvelopeMessages] +type routingAddressGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingAddressGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingAddressGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RoutingAddressGetResponseEnvelopeSuccess bool + +const ( + RoutingAddressGetResponseEnvelopeSuccessTrue RoutingAddressGetResponseEnvelopeSuccess = true +) diff --git a/email_routing/routingaddress_test.go b/email_routing/routingaddress_test.go new file mode 100644 index 00000000000..b3013956118 --- /dev/null +++ b/email_routing/routingaddress_test.go @@ -0,0 +1,134 @@ +// File generated from our OpenAPI spec by Stainless. + +package email_routing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/email_routing" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRoutingAddressNew(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("user@example.com"), + ) + _, err := client.EmailRouting.Routing.Addresses.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + email_routing.RoutingAddressNewParams{ + Email: cloudflare.F("user@example.com"), + }, + ) + 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 TestRoutingAddressListWithOptionalParams(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("user@example.com"), + ) + _, err := client.EmailRouting.Routing.Addresses.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + email_routing.RoutingAddressListParams{ + Direction: cloudflare.F(email_routing.RoutingAddressListParamsDirectionAsc), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(5.000000), + Verified: cloudflare.F(email_routing.RoutingAddressListParamsVerifiedTrue), + }, + ) + 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 TestRoutingAddressDelete(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("user@example.com"), + ) + _, err := client.EmailRouting.Routing.Addresses.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "ea95132c15732412d22c1476fa83f27a", + ) + 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 TestRoutingAddressGet(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("user@example.com"), + ) + _, err := client.EmailRouting.Routing.Addresses.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "ea95132c15732412d22c1476fa83f27a", + ) + 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/email_routing/routingdisable.go b/email_routing/routingdisable.go new file mode 100644 index 00000000000..65bdf6c1d95 --- /dev/null +++ b/email_routing/routingdisable.go @@ -0,0 +1,198 @@ +// File generated from our OpenAPI spec by Stainless. + +package email_routing + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// RoutingDisableService 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 [NewRoutingDisableService] method +// instead. +type RoutingDisableService struct { + Options []option.RequestOption +} + +// NewRoutingDisableService 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 NewRoutingDisableService(opts ...option.RequestOption) (r *RoutingDisableService) { + r = &RoutingDisableService{} + r.Options = opts + return +} + +// Disable your Email Routing zone. Also removes additional MX records previously +// required for Email Routing to work. +func (r *RoutingDisableService) New(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *RoutingDisableNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env RoutingDisableNewResponseEnvelope + path := fmt.Sprintf("zones/%s/email/routing/disable", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type RoutingDisableNewResponse struct { + // Email Routing settings identifier. + ID string `json:"id"` + // The date and time the settings have been created. + Created time.Time `json:"created" format:"date-time"` + // State of the zone settings for Email Routing. + Enabled RoutingDisableNewResponseEnabled `json:"enabled"` + // The date and time the settings have been modified. + Modified time.Time `json:"modified" format:"date-time"` + // Domain of your zone. + Name string `json:"name"` + // Flag to check if the user skipped the configuration wizard. + SkipWizard RoutingDisableNewResponseSkipWizard `json:"skip_wizard"` + // Show the state of your account, and the type or configuration error. + Status RoutingDisableNewResponseStatus `json:"status"` + // Email Routing settings tag. (Deprecated, replaced by Email Routing settings + // identifier) + Tag string `json:"tag"` + JSON routingDisableNewResponseJSON `json:"-"` +} + +// routingDisableNewResponseJSON contains the JSON metadata for the struct +// [RoutingDisableNewResponse] +type routingDisableNewResponseJSON struct { + ID apijson.Field + Created apijson.Field + Enabled apijson.Field + Modified apijson.Field + Name apijson.Field + SkipWizard apijson.Field + Status apijson.Field + Tag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingDisableNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingDisableNewResponseJSON) RawJSON() string { + return r.raw +} + +// State of the zone settings for Email Routing. +type RoutingDisableNewResponseEnabled bool + +const ( + RoutingDisableNewResponseEnabledTrue RoutingDisableNewResponseEnabled = true + RoutingDisableNewResponseEnabledFalse RoutingDisableNewResponseEnabled = false +) + +// Flag to check if the user skipped the configuration wizard. +type RoutingDisableNewResponseSkipWizard bool + +const ( + RoutingDisableNewResponseSkipWizardTrue RoutingDisableNewResponseSkipWizard = true + RoutingDisableNewResponseSkipWizardFalse RoutingDisableNewResponseSkipWizard = false +) + +// Show the state of your account, and the type or configuration error. +type RoutingDisableNewResponseStatus string + +const ( + RoutingDisableNewResponseStatusReady RoutingDisableNewResponseStatus = "ready" + RoutingDisableNewResponseStatusUnconfigured RoutingDisableNewResponseStatus = "unconfigured" + RoutingDisableNewResponseStatusMisconfigured RoutingDisableNewResponseStatus = "misconfigured" + RoutingDisableNewResponseStatusMisconfiguredLocked RoutingDisableNewResponseStatus = "misconfigured/locked" + RoutingDisableNewResponseStatusUnlocked RoutingDisableNewResponseStatus = "unlocked" +) + +type RoutingDisableNewResponseEnvelope struct { + Errors []RoutingDisableNewResponseEnvelopeErrors `json:"errors,required"` + Messages []RoutingDisableNewResponseEnvelopeMessages `json:"messages,required"` + Result RoutingDisableNewResponse `json:"result,required"` + // Whether the API call was successful + Success RoutingDisableNewResponseEnvelopeSuccess `json:"success,required"` + JSON routingDisableNewResponseEnvelopeJSON `json:"-"` +} + +// routingDisableNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [RoutingDisableNewResponseEnvelope] +type routingDisableNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingDisableNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingDisableNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RoutingDisableNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingDisableNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// routingDisableNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RoutingDisableNewResponseEnvelopeErrors] +type routingDisableNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingDisableNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingDisableNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RoutingDisableNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingDisableNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// routingDisableNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RoutingDisableNewResponseEnvelopeMessages] +type routingDisableNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingDisableNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingDisableNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RoutingDisableNewResponseEnvelopeSuccess bool + +const ( + RoutingDisableNewResponseEnvelopeSuccessTrue RoutingDisableNewResponseEnvelopeSuccess = true +) diff --git a/email_routing/routingdisable_test.go b/email_routing/routingdisable_test.go new file mode 100644 index 00000000000..82f9982f6aa --- /dev/null +++ b/email_routing/routingdisable_test.go @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package email_routing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRoutingDisableNew(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("user@example.com"), + ) + _, err := client.EmailRouting.Routing.Disables.New(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/email_routing/routingdns.go b/email_routing/routingdns.go new file mode 100644 index 00000000000..bc886a298b9 --- /dev/null +++ b/email_routing/routingdns.go @@ -0,0 +1,250 @@ +// File generated from our OpenAPI spec by Stainless. + +package email_routing + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// RoutingDNSService 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 [NewRoutingDNSService] method instead. +type RoutingDNSService struct { + Options []option.RequestOption +} + +// NewRoutingDNSService 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 NewRoutingDNSService(opts ...option.RequestOption) (r *RoutingDNSService) { + r = &RoutingDNSService{} + r.Options = opts + return +} + +// Show the DNS records needed to configure your Email Routing zone. +func (r *RoutingDNSService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *[]EmailDNSRecord, err error) { + opts = append(r.Options[:], opts...) + var env RoutingDNSGetResponseEnvelope + path := fmt.Sprintf("zones/%s/email/routing/dns", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List of records needed to enable an Email Routing zone. +type EmailDNSRecord struct { + // DNS record content. + Content string `json:"content"` + // DNS record name (or @ for the zone apex). + Name string `json:"name"` + // Required for MX, SRV and URI records. Unused by other record types. Records with + // lower priorities are preferred. + Priority float64 `json:"priority"` + // Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 + // for 'automatic'. + TTL EmailDNSRecordTTL `json:"ttl"` + // DNS record type. + Type EmailDNSRecordType `json:"type"` + JSON emailDNSRecordJSON `json:"-"` +} + +// emailDNSRecordJSON contains the JSON metadata for the struct [EmailDNSRecord] +type emailDNSRecordJSON struct { + Content apijson.Field + Name apijson.Field + Priority apijson.Field + TTL apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailDNSRecord) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailDNSRecordJSON) RawJSON() string { + return r.raw +} + +// Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 +// for 'automatic'. +// +// Union satisfied by [shared.UnionFloat] or +// [email_routing.EmailDNSRecordTTLNumber]. +type EmailDNSRecordTTL interface { + ImplementsEmailRoutingEmailDNSRecordTTL() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*EmailDNSRecordTTL)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(EmailDNSRecordTTLNumber(0)), + }, + ) +} + +type EmailDNSRecordTTLNumber float64 + +const ( + EmailDNSRecordTTLNumber1 EmailDNSRecordTTLNumber = 1 +) + +// DNS record type. +type EmailDNSRecordType string + +const ( + EmailDNSRecordTypeA EmailDNSRecordType = "A" + EmailDNSRecordTypeAAAA EmailDNSRecordType = "AAAA" + EmailDNSRecordTypeCNAME EmailDNSRecordType = "CNAME" + EmailDNSRecordTypeHTTPS EmailDNSRecordType = "HTTPS" + EmailDNSRecordTypeTXT EmailDNSRecordType = "TXT" + EmailDNSRecordTypeSRV EmailDNSRecordType = "SRV" + EmailDNSRecordTypeLOC EmailDNSRecordType = "LOC" + EmailDNSRecordTypeMX EmailDNSRecordType = "MX" + EmailDNSRecordTypeNS EmailDNSRecordType = "NS" + EmailDNSRecordTypeCert EmailDNSRecordType = "CERT" + EmailDNSRecordTypeDNSKEY EmailDNSRecordType = "DNSKEY" + EmailDNSRecordTypeDS EmailDNSRecordType = "DS" + EmailDNSRecordTypeNAPTR EmailDNSRecordType = "NAPTR" + EmailDNSRecordTypeSmimea EmailDNSRecordType = "SMIMEA" + EmailDNSRecordTypeSSHFP EmailDNSRecordType = "SSHFP" + EmailDNSRecordTypeSVCB EmailDNSRecordType = "SVCB" + EmailDNSRecordTypeTLSA EmailDNSRecordType = "TLSA" + EmailDNSRecordTypeURI EmailDNSRecordType = "URI" +) + +type RoutingDNSGetResponseEnvelope struct { + Errors []RoutingDNSGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RoutingDNSGetResponseEnvelopeMessages `json:"messages,required"` + Result []EmailDNSRecord `json:"result,required,nullable"` + // Whether the API call was successful + Success RoutingDNSGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo RoutingDNSGetResponseEnvelopeResultInfo `json:"result_info"` + JSON routingDNSGetResponseEnvelopeJSON `json:"-"` +} + +// routingDNSGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RoutingDNSGetResponseEnvelope] +type routingDNSGetResponseEnvelopeJSON 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 *RoutingDNSGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingDNSGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RoutingDNSGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingDNSGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// routingDNSGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RoutingDNSGetResponseEnvelopeErrors] +type routingDNSGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingDNSGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingDNSGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RoutingDNSGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingDNSGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// routingDNSGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RoutingDNSGetResponseEnvelopeMessages] +type routingDNSGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingDNSGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingDNSGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RoutingDNSGetResponseEnvelopeSuccess bool + +const ( + RoutingDNSGetResponseEnvelopeSuccessTrue RoutingDNSGetResponseEnvelopeSuccess = true +) + +type RoutingDNSGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON routingDNSGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// routingDNSGetResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [RoutingDNSGetResponseEnvelopeResultInfo] +type routingDNSGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingDNSGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingDNSGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/email_routing/routingdns_test.go b/email_routing/routingdns_test.go new file mode 100644 index 00000000000..46d79c7fc6f --- /dev/null +++ b/email_routing/routingdns_test.go @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package email_routing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRoutingDNSGet(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("user@example.com"), + ) + _, err := client.EmailRouting.Routing.DNS.Get(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/email_routing/routingenable.go b/email_routing/routingenable.go new file mode 100644 index 00000000000..a8cbeb7a8d4 --- /dev/null +++ b/email_routing/routingenable.go @@ -0,0 +1,197 @@ +// File generated from our OpenAPI spec by Stainless. + +package email_routing + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// RoutingEnableService 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 [NewRoutingEnableService] method +// instead. +type RoutingEnableService struct { + Options []option.RequestOption +} + +// NewRoutingEnableService 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 NewRoutingEnableService(opts ...option.RequestOption) (r *RoutingEnableService) { + r = &RoutingEnableService{} + r.Options = opts + return +} + +// Enable you Email Routing zone. Add and lock the necessary MX and SPF records. +func (r *RoutingEnableService) New(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *RoutingEnableNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env RoutingEnableNewResponseEnvelope + path := fmt.Sprintf("zones/%s/email/routing/enable", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type RoutingEnableNewResponse struct { + // Email Routing settings identifier. + ID string `json:"id"` + // The date and time the settings have been created. + Created time.Time `json:"created" format:"date-time"` + // State of the zone settings for Email Routing. + Enabled RoutingEnableNewResponseEnabled `json:"enabled"` + // The date and time the settings have been modified. + Modified time.Time `json:"modified" format:"date-time"` + // Domain of your zone. + Name string `json:"name"` + // Flag to check if the user skipped the configuration wizard. + SkipWizard RoutingEnableNewResponseSkipWizard `json:"skip_wizard"` + // Show the state of your account, and the type or configuration error. + Status RoutingEnableNewResponseStatus `json:"status"` + // Email Routing settings tag. (Deprecated, replaced by Email Routing settings + // identifier) + Tag string `json:"tag"` + JSON routingEnableNewResponseJSON `json:"-"` +} + +// routingEnableNewResponseJSON contains the JSON metadata for the struct +// [RoutingEnableNewResponse] +type routingEnableNewResponseJSON struct { + ID apijson.Field + Created apijson.Field + Enabled apijson.Field + Modified apijson.Field + Name apijson.Field + SkipWizard apijson.Field + Status apijson.Field + Tag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingEnableNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingEnableNewResponseJSON) RawJSON() string { + return r.raw +} + +// State of the zone settings for Email Routing. +type RoutingEnableNewResponseEnabled bool + +const ( + RoutingEnableNewResponseEnabledTrue RoutingEnableNewResponseEnabled = true + RoutingEnableNewResponseEnabledFalse RoutingEnableNewResponseEnabled = false +) + +// Flag to check if the user skipped the configuration wizard. +type RoutingEnableNewResponseSkipWizard bool + +const ( + RoutingEnableNewResponseSkipWizardTrue RoutingEnableNewResponseSkipWizard = true + RoutingEnableNewResponseSkipWizardFalse RoutingEnableNewResponseSkipWizard = false +) + +// Show the state of your account, and the type or configuration error. +type RoutingEnableNewResponseStatus string + +const ( + RoutingEnableNewResponseStatusReady RoutingEnableNewResponseStatus = "ready" + RoutingEnableNewResponseStatusUnconfigured RoutingEnableNewResponseStatus = "unconfigured" + RoutingEnableNewResponseStatusMisconfigured RoutingEnableNewResponseStatus = "misconfigured" + RoutingEnableNewResponseStatusMisconfiguredLocked RoutingEnableNewResponseStatus = "misconfigured/locked" + RoutingEnableNewResponseStatusUnlocked RoutingEnableNewResponseStatus = "unlocked" +) + +type RoutingEnableNewResponseEnvelope struct { + Errors []RoutingEnableNewResponseEnvelopeErrors `json:"errors,required"` + Messages []RoutingEnableNewResponseEnvelopeMessages `json:"messages,required"` + Result RoutingEnableNewResponse `json:"result,required"` + // Whether the API call was successful + Success RoutingEnableNewResponseEnvelopeSuccess `json:"success,required"` + JSON routingEnableNewResponseEnvelopeJSON `json:"-"` +} + +// routingEnableNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [RoutingEnableNewResponseEnvelope] +type routingEnableNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingEnableNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingEnableNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RoutingEnableNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingEnableNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// routingEnableNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RoutingEnableNewResponseEnvelopeErrors] +type routingEnableNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingEnableNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingEnableNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RoutingEnableNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingEnableNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// routingEnableNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RoutingEnableNewResponseEnvelopeMessages] +type routingEnableNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingEnableNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingEnableNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RoutingEnableNewResponseEnvelopeSuccess bool + +const ( + RoutingEnableNewResponseEnvelopeSuccessTrue RoutingEnableNewResponseEnvelopeSuccess = true +) diff --git a/email_routing/routingenable_test.go b/email_routing/routingenable_test.go new file mode 100644 index 00000000000..33646a828a9 --- /dev/null +++ b/email_routing/routingenable_test.go @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package email_routing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRoutingEnableNew(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("user@example.com"), + ) + _, err := client.EmailRouting.Routing.Enables.New(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/email_routing/routingrule.go b/email_routing/routingrule.go new file mode 100644 index 00000000000..392a3029d64 --- /dev/null +++ b/email_routing/routingrule.go @@ -0,0 +1,1234 @@ +// File generated from our OpenAPI spec by Stainless. + +package email_routing + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" +) + +// RoutingRuleService 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 [NewRoutingRuleService] method +// instead. +type RoutingRuleService struct { + Options []option.RequestOption + CatchAlls *RoutingRuleCatchAllService +} + +// NewRoutingRuleService 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 NewRoutingRuleService(opts ...option.RequestOption) (r *RoutingRuleService) { + r = &RoutingRuleService{} + r.Options = opts + r.CatchAlls = NewRoutingRuleCatchAllService(opts...) + return +} + +// Rules consist of a set of criteria for matching emails (such as an email being +// sent to a specific custom email address) plus a set of actions to take on the +// email (like forwarding it to a specific destination address). +func (r *RoutingRuleService) New(ctx context.Context, zoneIdentifier string, body RoutingRuleNewParams, opts ...option.RequestOption) (res *RoutingRuleNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env RoutingRuleNewResponseEnvelope + path := fmt.Sprintf("zones/%s/email/routing/rules", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update actions and matches, or enable/disable specific routing rules. +func (r *RoutingRuleService) Update(ctx context.Context, zoneIdentifier string, ruleIdentifier string, body RoutingRuleUpdateParams, opts ...option.RequestOption) (res *RoutingRuleUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env RoutingRuleUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/email/routing/rules/%s", zoneIdentifier, ruleIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists existing routing rules. +func (r *RoutingRuleService) List(ctx context.Context, zoneIdentifier string, query RoutingRuleListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[RoutingRuleListResponse], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("zones/%s/email/routing/rules", zoneIdentifier) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists existing routing rules. +func (r *RoutingRuleService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query RoutingRuleListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[RoutingRuleListResponse] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) +} + +// Delete a specific routing rule. +func (r *RoutingRuleService) Delete(ctx context.Context, zoneIdentifier string, ruleIdentifier string, opts ...option.RequestOption) (res *RoutingRuleDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env RoutingRuleDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/email/routing/rules/%s", zoneIdentifier, ruleIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get information for a specific routing rule already created. +func (r *RoutingRuleService) Get(ctx context.Context, zoneIdentifier string, ruleIdentifier string, opts ...option.RequestOption) (res *RoutingRuleGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RoutingRuleGetResponseEnvelope + path := fmt.Sprintf("zones/%s/email/routing/rules/%s", zoneIdentifier, ruleIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type RoutingRuleNewResponse struct { + // Routing rule identifier. + ID string `json:"id"` + // List actions patterns. + Actions []RoutingRuleNewResponseAction `json:"actions"` + // Routing rule status. + Enabled RoutingRuleNewResponseEnabled `json:"enabled"` + // Matching patterns to forward to your actions. + Matchers []RoutingRuleNewResponseMatcher `json:"matchers"` + // Routing rule name. + Name string `json:"name"` + // Priority of the routing rule. + Priority float64 `json:"priority"` + // Routing rule tag. (Deprecated, replaced by routing rule identifier) + Tag string `json:"tag"` + JSON routingRuleNewResponseJSON `json:"-"` +} + +// routingRuleNewResponseJSON contains the JSON metadata for the struct +// [RoutingRuleNewResponse] +type routingRuleNewResponseJSON struct { + ID apijson.Field + Actions apijson.Field + Enabled apijson.Field + Matchers apijson.Field + Name apijson.Field + Priority apijson.Field + Tag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleNewResponseJSON) RawJSON() string { + return r.raw +} + +// Actions pattern. +type RoutingRuleNewResponseAction struct { + // Type of supported action. + Type RoutingRuleNewResponseActionsType `json:"type,required"` + Value []string `json:"value,required"` + JSON routingRuleNewResponseActionJSON `json:"-"` +} + +// routingRuleNewResponseActionJSON contains the JSON metadata for the struct +// [RoutingRuleNewResponseAction] +type routingRuleNewResponseActionJSON struct { + Type apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleNewResponseAction) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleNewResponseActionJSON) RawJSON() string { + return r.raw +} + +// Type of supported action. +type RoutingRuleNewResponseActionsType string + +const ( + RoutingRuleNewResponseActionsTypeDrop RoutingRuleNewResponseActionsType = "drop" + RoutingRuleNewResponseActionsTypeForward RoutingRuleNewResponseActionsType = "forward" + RoutingRuleNewResponseActionsTypeWorker RoutingRuleNewResponseActionsType = "worker" +) + +// Routing rule status. +type RoutingRuleNewResponseEnabled bool + +const ( + RoutingRuleNewResponseEnabledTrue RoutingRuleNewResponseEnabled = true + RoutingRuleNewResponseEnabledFalse RoutingRuleNewResponseEnabled = false +) + +// Matching pattern to forward your actions. +type RoutingRuleNewResponseMatcher struct { + // Field for type matcher. + Field RoutingRuleNewResponseMatchersField `json:"field,required"` + // Type of matcher. + Type RoutingRuleNewResponseMatchersType `json:"type,required"` + // Value for matcher. + Value string `json:"value,required"` + JSON routingRuleNewResponseMatcherJSON `json:"-"` +} + +// routingRuleNewResponseMatcherJSON contains the JSON metadata for the struct +// [RoutingRuleNewResponseMatcher] +type routingRuleNewResponseMatcherJSON struct { + Field apijson.Field + Type apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleNewResponseMatcher) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleNewResponseMatcherJSON) RawJSON() string { + return r.raw +} + +// Field for type matcher. +type RoutingRuleNewResponseMatchersField string + +const ( + RoutingRuleNewResponseMatchersFieldTo RoutingRuleNewResponseMatchersField = "to" +) + +// Type of matcher. +type RoutingRuleNewResponseMatchersType string + +const ( + RoutingRuleNewResponseMatchersTypeLiteral RoutingRuleNewResponseMatchersType = "literal" +) + +type RoutingRuleUpdateResponse struct { + // Routing rule identifier. + ID string `json:"id"` + // List actions patterns. + Actions []RoutingRuleUpdateResponseAction `json:"actions"` + // Routing rule status. + Enabled RoutingRuleUpdateResponseEnabled `json:"enabled"` + // Matching patterns to forward to your actions. + Matchers []RoutingRuleUpdateResponseMatcher `json:"matchers"` + // Routing rule name. + Name string `json:"name"` + // Priority of the routing rule. + Priority float64 `json:"priority"` + // Routing rule tag. (Deprecated, replaced by routing rule identifier) + Tag string `json:"tag"` + JSON routingRuleUpdateResponseJSON `json:"-"` +} + +// routingRuleUpdateResponseJSON contains the JSON metadata for the struct +// [RoutingRuleUpdateResponse] +type routingRuleUpdateResponseJSON struct { + ID apijson.Field + Actions apijson.Field + Enabled apijson.Field + Matchers apijson.Field + Name apijson.Field + Priority apijson.Field + Tag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleUpdateResponseJSON) RawJSON() string { + return r.raw +} + +// Actions pattern. +type RoutingRuleUpdateResponseAction struct { + // Type of supported action. + Type RoutingRuleUpdateResponseActionsType `json:"type,required"` + Value []string `json:"value,required"` + JSON routingRuleUpdateResponseActionJSON `json:"-"` +} + +// routingRuleUpdateResponseActionJSON contains the JSON metadata for the struct +// [RoutingRuleUpdateResponseAction] +type routingRuleUpdateResponseActionJSON struct { + Type apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleUpdateResponseAction) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleUpdateResponseActionJSON) RawJSON() string { + return r.raw +} + +// Type of supported action. +type RoutingRuleUpdateResponseActionsType string + +const ( + RoutingRuleUpdateResponseActionsTypeDrop RoutingRuleUpdateResponseActionsType = "drop" + RoutingRuleUpdateResponseActionsTypeForward RoutingRuleUpdateResponseActionsType = "forward" + RoutingRuleUpdateResponseActionsTypeWorker RoutingRuleUpdateResponseActionsType = "worker" +) + +// Routing rule status. +type RoutingRuleUpdateResponseEnabled bool + +const ( + RoutingRuleUpdateResponseEnabledTrue RoutingRuleUpdateResponseEnabled = true + RoutingRuleUpdateResponseEnabledFalse RoutingRuleUpdateResponseEnabled = false +) + +// Matching pattern to forward your actions. +type RoutingRuleUpdateResponseMatcher struct { + // Field for type matcher. + Field RoutingRuleUpdateResponseMatchersField `json:"field,required"` + // Type of matcher. + Type RoutingRuleUpdateResponseMatchersType `json:"type,required"` + // Value for matcher. + Value string `json:"value,required"` + JSON routingRuleUpdateResponseMatcherJSON `json:"-"` +} + +// routingRuleUpdateResponseMatcherJSON contains the JSON metadata for the struct +// [RoutingRuleUpdateResponseMatcher] +type routingRuleUpdateResponseMatcherJSON struct { + Field apijson.Field + Type apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleUpdateResponseMatcher) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleUpdateResponseMatcherJSON) RawJSON() string { + return r.raw +} + +// Field for type matcher. +type RoutingRuleUpdateResponseMatchersField string + +const ( + RoutingRuleUpdateResponseMatchersFieldTo RoutingRuleUpdateResponseMatchersField = "to" +) + +// Type of matcher. +type RoutingRuleUpdateResponseMatchersType string + +const ( + RoutingRuleUpdateResponseMatchersTypeLiteral RoutingRuleUpdateResponseMatchersType = "literal" +) + +type RoutingRuleListResponse struct { + // Routing rule identifier. + ID string `json:"id"` + // List actions patterns. + Actions []RoutingRuleListResponseAction `json:"actions"` + // Routing rule status. + Enabled RoutingRuleListResponseEnabled `json:"enabled"` + // Matching patterns to forward to your actions. + Matchers []RoutingRuleListResponseMatcher `json:"matchers"` + // Routing rule name. + Name string `json:"name"` + // Priority of the routing rule. + Priority float64 `json:"priority"` + // Routing rule tag. (Deprecated, replaced by routing rule identifier) + Tag string `json:"tag"` + JSON routingRuleListResponseJSON `json:"-"` +} + +// routingRuleListResponseJSON contains the JSON metadata for the struct +// [RoutingRuleListResponse] +type routingRuleListResponseJSON struct { + ID apijson.Field + Actions apijson.Field + Enabled apijson.Field + Matchers apijson.Field + Name apijson.Field + Priority apijson.Field + Tag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleListResponseJSON) RawJSON() string { + return r.raw +} + +// Actions pattern. +type RoutingRuleListResponseAction struct { + // Type of supported action. + Type RoutingRuleListResponseActionsType `json:"type,required"` + Value []string `json:"value,required"` + JSON routingRuleListResponseActionJSON `json:"-"` +} + +// routingRuleListResponseActionJSON contains the JSON metadata for the struct +// [RoutingRuleListResponseAction] +type routingRuleListResponseActionJSON struct { + Type apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleListResponseAction) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleListResponseActionJSON) RawJSON() string { + return r.raw +} + +// Type of supported action. +type RoutingRuleListResponseActionsType string + +const ( + RoutingRuleListResponseActionsTypeDrop RoutingRuleListResponseActionsType = "drop" + RoutingRuleListResponseActionsTypeForward RoutingRuleListResponseActionsType = "forward" + RoutingRuleListResponseActionsTypeWorker RoutingRuleListResponseActionsType = "worker" +) + +// Routing rule status. +type RoutingRuleListResponseEnabled bool + +const ( + RoutingRuleListResponseEnabledTrue RoutingRuleListResponseEnabled = true + RoutingRuleListResponseEnabledFalse RoutingRuleListResponseEnabled = false +) + +// Matching pattern to forward your actions. +type RoutingRuleListResponseMatcher struct { + // Field for type matcher. + Field RoutingRuleListResponseMatchersField `json:"field,required"` + // Type of matcher. + Type RoutingRuleListResponseMatchersType `json:"type,required"` + // Value for matcher. + Value string `json:"value,required"` + JSON routingRuleListResponseMatcherJSON `json:"-"` +} + +// routingRuleListResponseMatcherJSON contains the JSON metadata for the struct +// [RoutingRuleListResponseMatcher] +type routingRuleListResponseMatcherJSON struct { + Field apijson.Field + Type apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleListResponseMatcher) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleListResponseMatcherJSON) RawJSON() string { + return r.raw +} + +// Field for type matcher. +type RoutingRuleListResponseMatchersField string + +const ( + RoutingRuleListResponseMatchersFieldTo RoutingRuleListResponseMatchersField = "to" +) + +// Type of matcher. +type RoutingRuleListResponseMatchersType string + +const ( + RoutingRuleListResponseMatchersTypeLiteral RoutingRuleListResponseMatchersType = "literal" +) + +type RoutingRuleDeleteResponse struct { + // Routing rule identifier. + ID string `json:"id"` + // List actions patterns. + Actions []RoutingRuleDeleteResponseAction `json:"actions"` + // Routing rule status. + Enabled RoutingRuleDeleteResponseEnabled `json:"enabled"` + // Matching patterns to forward to your actions. + Matchers []RoutingRuleDeleteResponseMatcher `json:"matchers"` + // Routing rule name. + Name string `json:"name"` + // Priority of the routing rule. + Priority float64 `json:"priority"` + // Routing rule tag. (Deprecated, replaced by routing rule identifier) + Tag string `json:"tag"` + JSON routingRuleDeleteResponseJSON `json:"-"` +} + +// routingRuleDeleteResponseJSON contains the JSON metadata for the struct +// [RoutingRuleDeleteResponse] +type routingRuleDeleteResponseJSON struct { + ID apijson.Field + Actions apijson.Field + Enabled apijson.Field + Matchers apijson.Field + Name apijson.Field + Priority apijson.Field + Tag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleDeleteResponseJSON) RawJSON() string { + return r.raw +} + +// Actions pattern. +type RoutingRuleDeleteResponseAction struct { + // Type of supported action. + Type RoutingRuleDeleteResponseActionsType `json:"type,required"` + Value []string `json:"value,required"` + JSON routingRuleDeleteResponseActionJSON `json:"-"` +} + +// routingRuleDeleteResponseActionJSON contains the JSON metadata for the struct +// [RoutingRuleDeleteResponseAction] +type routingRuleDeleteResponseActionJSON struct { + Type apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleDeleteResponseAction) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleDeleteResponseActionJSON) RawJSON() string { + return r.raw +} + +// Type of supported action. +type RoutingRuleDeleteResponseActionsType string + +const ( + RoutingRuleDeleteResponseActionsTypeDrop RoutingRuleDeleteResponseActionsType = "drop" + RoutingRuleDeleteResponseActionsTypeForward RoutingRuleDeleteResponseActionsType = "forward" + RoutingRuleDeleteResponseActionsTypeWorker RoutingRuleDeleteResponseActionsType = "worker" +) + +// Routing rule status. +type RoutingRuleDeleteResponseEnabled bool + +const ( + RoutingRuleDeleteResponseEnabledTrue RoutingRuleDeleteResponseEnabled = true + RoutingRuleDeleteResponseEnabledFalse RoutingRuleDeleteResponseEnabled = false +) + +// Matching pattern to forward your actions. +type RoutingRuleDeleteResponseMatcher struct { + // Field for type matcher. + Field RoutingRuleDeleteResponseMatchersField `json:"field,required"` + // Type of matcher. + Type RoutingRuleDeleteResponseMatchersType `json:"type,required"` + // Value for matcher. + Value string `json:"value,required"` + JSON routingRuleDeleteResponseMatcherJSON `json:"-"` +} + +// routingRuleDeleteResponseMatcherJSON contains the JSON metadata for the struct +// [RoutingRuleDeleteResponseMatcher] +type routingRuleDeleteResponseMatcherJSON struct { + Field apijson.Field + Type apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleDeleteResponseMatcher) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleDeleteResponseMatcherJSON) RawJSON() string { + return r.raw +} + +// Field for type matcher. +type RoutingRuleDeleteResponseMatchersField string + +const ( + RoutingRuleDeleteResponseMatchersFieldTo RoutingRuleDeleteResponseMatchersField = "to" +) + +// Type of matcher. +type RoutingRuleDeleteResponseMatchersType string + +const ( + RoutingRuleDeleteResponseMatchersTypeLiteral RoutingRuleDeleteResponseMatchersType = "literal" +) + +type RoutingRuleGetResponse struct { + // Routing rule identifier. + ID string `json:"id"` + // List actions patterns. + Actions []RoutingRuleGetResponseAction `json:"actions"` + // Routing rule status. + Enabled RoutingRuleGetResponseEnabled `json:"enabled"` + // Matching patterns to forward to your actions. + Matchers []RoutingRuleGetResponseMatcher `json:"matchers"` + // Routing rule name. + Name string `json:"name"` + // Priority of the routing rule. + Priority float64 `json:"priority"` + // Routing rule tag. (Deprecated, replaced by routing rule identifier) + Tag string `json:"tag"` + JSON routingRuleGetResponseJSON `json:"-"` +} + +// routingRuleGetResponseJSON contains the JSON metadata for the struct +// [RoutingRuleGetResponse] +type routingRuleGetResponseJSON struct { + ID apijson.Field + Actions apijson.Field + Enabled apijson.Field + Matchers apijson.Field + Name apijson.Field + Priority apijson.Field + Tag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleGetResponseJSON) RawJSON() string { + return r.raw +} + +// Actions pattern. +type RoutingRuleGetResponseAction struct { + // Type of supported action. + Type RoutingRuleGetResponseActionsType `json:"type,required"` + Value []string `json:"value,required"` + JSON routingRuleGetResponseActionJSON `json:"-"` +} + +// routingRuleGetResponseActionJSON contains the JSON metadata for the struct +// [RoutingRuleGetResponseAction] +type routingRuleGetResponseActionJSON struct { + Type apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleGetResponseAction) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleGetResponseActionJSON) RawJSON() string { + return r.raw +} + +// Type of supported action. +type RoutingRuleGetResponseActionsType string + +const ( + RoutingRuleGetResponseActionsTypeDrop RoutingRuleGetResponseActionsType = "drop" + RoutingRuleGetResponseActionsTypeForward RoutingRuleGetResponseActionsType = "forward" + RoutingRuleGetResponseActionsTypeWorker RoutingRuleGetResponseActionsType = "worker" +) + +// Routing rule status. +type RoutingRuleGetResponseEnabled bool + +const ( + RoutingRuleGetResponseEnabledTrue RoutingRuleGetResponseEnabled = true + RoutingRuleGetResponseEnabledFalse RoutingRuleGetResponseEnabled = false +) + +// Matching pattern to forward your actions. +type RoutingRuleGetResponseMatcher struct { + // Field for type matcher. + Field RoutingRuleGetResponseMatchersField `json:"field,required"` + // Type of matcher. + Type RoutingRuleGetResponseMatchersType `json:"type,required"` + // Value for matcher. + Value string `json:"value,required"` + JSON routingRuleGetResponseMatcherJSON `json:"-"` +} + +// routingRuleGetResponseMatcherJSON contains the JSON metadata for the struct +// [RoutingRuleGetResponseMatcher] +type routingRuleGetResponseMatcherJSON struct { + Field apijson.Field + Type apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleGetResponseMatcher) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleGetResponseMatcherJSON) RawJSON() string { + return r.raw +} + +// Field for type matcher. +type RoutingRuleGetResponseMatchersField string + +const ( + RoutingRuleGetResponseMatchersFieldTo RoutingRuleGetResponseMatchersField = "to" +) + +// Type of matcher. +type RoutingRuleGetResponseMatchersType string + +const ( + RoutingRuleGetResponseMatchersTypeLiteral RoutingRuleGetResponseMatchersType = "literal" +) + +type RoutingRuleNewParams struct { + // List actions patterns. + Actions param.Field[[]RoutingRuleNewParamsAction] `json:"actions,required"` + // Matching patterns to forward to your actions. + Matchers param.Field[[]RoutingRuleNewParamsMatcher] `json:"matchers,required"` + // Routing rule status. + Enabled param.Field[RoutingRuleNewParamsEnabled] `json:"enabled"` + // Routing rule name. + Name param.Field[string] `json:"name"` + // Priority of the routing rule. + Priority param.Field[float64] `json:"priority"` +} + +func (r RoutingRuleNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Actions pattern. +type RoutingRuleNewParamsAction struct { + // Type of supported action. + Type param.Field[RoutingRuleNewParamsActionsType] `json:"type,required"` + Value param.Field[[]string] `json:"value,required"` +} + +func (r RoutingRuleNewParamsAction) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Type of supported action. +type RoutingRuleNewParamsActionsType string + +const ( + RoutingRuleNewParamsActionsTypeDrop RoutingRuleNewParamsActionsType = "drop" + RoutingRuleNewParamsActionsTypeForward RoutingRuleNewParamsActionsType = "forward" + RoutingRuleNewParamsActionsTypeWorker RoutingRuleNewParamsActionsType = "worker" +) + +// Matching pattern to forward your actions. +type RoutingRuleNewParamsMatcher struct { + // Field for type matcher. + Field param.Field[RoutingRuleNewParamsMatchersField] `json:"field,required"` + // Type of matcher. + Type param.Field[RoutingRuleNewParamsMatchersType] `json:"type,required"` + // Value for matcher. + Value param.Field[string] `json:"value,required"` +} + +func (r RoutingRuleNewParamsMatcher) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Field for type matcher. +type RoutingRuleNewParamsMatchersField string + +const ( + RoutingRuleNewParamsMatchersFieldTo RoutingRuleNewParamsMatchersField = "to" +) + +// Type of matcher. +type RoutingRuleNewParamsMatchersType string + +const ( + RoutingRuleNewParamsMatchersTypeLiteral RoutingRuleNewParamsMatchersType = "literal" +) + +// Routing rule status. +type RoutingRuleNewParamsEnabled bool + +const ( + RoutingRuleNewParamsEnabledTrue RoutingRuleNewParamsEnabled = true + RoutingRuleNewParamsEnabledFalse RoutingRuleNewParamsEnabled = false +) + +type RoutingRuleNewResponseEnvelope struct { + Errors []RoutingRuleNewResponseEnvelopeErrors `json:"errors,required"` + Messages []RoutingRuleNewResponseEnvelopeMessages `json:"messages,required"` + Result RoutingRuleNewResponse `json:"result,required"` + // Whether the API call was successful + Success RoutingRuleNewResponseEnvelopeSuccess `json:"success,required"` + JSON routingRuleNewResponseEnvelopeJSON `json:"-"` +} + +// routingRuleNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [RoutingRuleNewResponseEnvelope] +type routingRuleNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RoutingRuleNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingRuleNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// routingRuleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RoutingRuleNewResponseEnvelopeErrors] +type routingRuleNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RoutingRuleNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingRuleNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// routingRuleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RoutingRuleNewResponseEnvelopeMessages] +type routingRuleNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RoutingRuleNewResponseEnvelopeSuccess bool + +const ( + RoutingRuleNewResponseEnvelopeSuccessTrue RoutingRuleNewResponseEnvelopeSuccess = true +) + +type RoutingRuleUpdateParams struct { + // List actions patterns. + Actions param.Field[[]RoutingRuleUpdateParamsAction] `json:"actions,required"` + // Matching patterns to forward to your actions. + Matchers param.Field[[]RoutingRuleUpdateParamsMatcher] `json:"matchers,required"` + // Routing rule status. + Enabled param.Field[RoutingRuleUpdateParamsEnabled] `json:"enabled"` + // Routing rule name. + Name param.Field[string] `json:"name"` + // Priority of the routing rule. + Priority param.Field[float64] `json:"priority"` +} + +func (r RoutingRuleUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Actions pattern. +type RoutingRuleUpdateParamsAction struct { + // Type of supported action. + Type param.Field[RoutingRuleUpdateParamsActionsType] `json:"type,required"` + Value param.Field[[]string] `json:"value,required"` +} + +func (r RoutingRuleUpdateParamsAction) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Type of supported action. +type RoutingRuleUpdateParamsActionsType string + +const ( + RoutingRuleUpdateParamsActionsTypeDrop RoutingRuleUpdateParamsActionsType = "drop" + RoutingRuleUpdateParamsActionsTypeForward RoutingRuleUpdateParamsActionsType = "forward" + RoutingRuleUpdateParamsActionsTypeWorker RoutingRuleUpdateParamsActionsType = "worker" +) + +// Matching pattern to forward your actions. +type RoutingRuleUpdateParamsMatcher struct { + // Field for type matcher. + Field param.Field[RoutingRuleUpdateParamsMatchersField] `json:"field,required"` + // Type of matcher. + Type param.Field[RoutingRuleUpdateParamsMatchersType] `json:"type,required"` + // Value for matcher. + Value param.Field[string] `json:"value,required"` +} + +func (r RoutingRuleUpdateParamsMatcher) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Field for type matcher. +type RoutingRuleUpdateParamsMatchersField string + +const ( + RoutingRuleUpdateParamsMatchersFieldTo RoutingRuleUpdateParamsMatchersField = "to" +) + +// Type of matcher. +type RoutingRuleUpdateParamsMatchersType string + +const ( + RoutingRuleUpdateParamsMatchersTypeLiteral RoutingRuleUpdateParamsMatchersType = "literal" +) + +// Routing rule status. +type RoutingRuleUpdateParamsEnabled bool + +const ( + RoutingRuleUpdateParamsEnabledTrue RoutingRuleUpdateParamsEnabled = true + RoutingRuleUpdateParamsEnabledFalse RoutingRuleUpdateParamsEnabled = false +) + +type RoutingRuleUpdateResponseEnvelope struct { + Errors []RoutingRuleUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []RoutingRuleUpdateResponseEnvelopeMessages `json:"messages,required"` + Result RoutingRuleUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success RoutingRuleUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON routingRuleUpdateResponseEnvelopeJSON `json:"-"` +} + +// routingRuleUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [RoutingRuleUpdateResponseEnvelope] +type routingRuleUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RoutingRuleUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingRuleUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// routingRuleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RoutingRuleUpdateResponseEnvelopeErrors] +type routingRuleUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RoutingRuleUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingRuleUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// routingRuleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RoutingRuleUpdateResponseEnvelopeMessages] +type routingRuleUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RoutingRuleUpdateResponseEnvelopeSuccess bool + +const ( + RoutingRuleUpdateResponseEnvelopeSuccessTrue RoutingRuleUpdateResponseEnvelopeSuccess = true +) + +type RoutingRuleListParams struct { + // Filter by enabled routing rules. + Enabled param.Field[RoutingRuleListParamsEnabled] `query:"enabled"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // Maximum number of results per page. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [RoutingRuleListParams]'s query parameters as `url.Values`. +func (r RoutingRuleListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Filter by enabled routing rules. +type RoutingRuleListParamsEnabled bool + +const ( + RoutingRuleListParamsEnabledTrue RoutingRuleListParamsEnabled = true + RoutingRuleListParamsEnabledFalse RoutingRuleListParamsEnabled = false +) + +type RoutingRuleDeleteResponseEnvelope struct { + Errors []RoutingRuleDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []RoutingRuleDeleteResponseEnvelopeMessages `json:"messages,required"` + Result RoutingRuleDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success RoutingRuleDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON routingRuleDeleteResponseEnvelopeJSON `json:"-"` +} + +// routingRuleDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [RoutingRuleDeleteResponseEnvelope] +type routingRuleDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RoutingRuleDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingRuleDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// routingRuleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RoutingRuleDeleteResponseEnvelopeErrors] +type routingRuleDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RoutingRuleDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingRuleDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// routingRuleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RoutingRuleDeleteResponseEnvelopeMessages] +type routingRuleDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RoutingRuleDeleteResponseEnvelopeSuccess bool + +const ( + RoutingRuleDeleteResponseEnvelopeSuccessTrue RoutingRuleDeleteResponseEnvelopeSuccess = true +) + +type RoutingRuleGetResponseEnvelope struct { + Errors []RoutingRuleGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RoutingRuleGetResponseEnvelopeMessages `json:"messages,required"` + Result RoutingRuleGetResponse `json:"result,required"` + // Whether the API call was successful + Success RoutingRuleGetResponseEnvelopeSuccess `json:"success,required"` + JSON routingRuleGetResponseEnvelopeJSON `json:"-"` +} + +// routingRuleGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RoutingRuleGetResponseEnvelope] +type routingRuleGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RoutingRuleGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingRuleGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// routingRuleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RoutingRuleGetResponseEnvelopeErrors] +type routingRuleGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RoutingRuleGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingRuleGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// routingRuleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RoutingRuleGetResponseEnvelopeMessages] +type routingRuleGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RoutingRuleGetResponseEnvelopeSuccess bool + +const ( + RoutingRuleGetResponseEnvelopeSuccessTrue RoutingRuleGetResponseEnvelopeSuccess = true +) diff --git a/email_routing/routingrule_test.go b/email_routing/routingrule_test.go new file mode 100644 index 00000000000..405b2cf49ac --- /dev/null +++ b/email_routing/routingrule_test.go @@ -0,0 +1,214 @@ +// File generated from our OpenAPI spec by Stainless. + +package email_routing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/email_routing" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRoutingRuleNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.EmailRouting.Routing.Rules.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + email_routing.RoutingRuleNewParams{ + Actions: cloudflare.F([]email_routing.RoutingRuleNewParamsAction{{ + Type: cloudflare.F(email_routing.RoutingRuleNewParamsActionsTypeForward), + Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), + }, { + Type: cloudflare.F(email_routing.RoutingRuleNewParamsActionsTypeForward), + Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), + }, { + Type: cloudflare.F(email_routing.RoutingRuleNewParamsActionsTypeForward), + Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), + }}), + Matchers: cloudflare.F([]email_routing.RoutingRuleNewParamsMatcher{{ + Field: cloudflare.F(email_routing.RoutingRuleNewParamsMatchersFieldTo), + Type: cloudflare.F(email_routing.RoutingRuleNewParamsMatchersTypeLiteral), + Value: cloudflare.F("test@example.com"), + }, { + Field: cloudflare.F(email_routing.RoutingRuleNewParamsMatchersFieldTo), + Type: cloudflare.F(email_routing.RoutingRuleNewParamsMatchersTypeLiteral), + Value: cloudflare.F("test@example.com"), + }, { + Field: cloudflare.F(email_routing.RoutingRuleNewParamsMatchersFieldTo), + Type: cloudflare.F(email_routing.RoutingRuleNewParamsMatchersTypeLiteral), + Value: cloudflare.F("test@example.com"), + }}), + Enabled: cloudflare.F(email_routing.RoutingRuleNewParamsEnabledTrue), + Name: cloudflare.F("Send to user@example.net rule."), + Priority: cloudflare.F(0.000000), + }, + ) + 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 TestRoutingRuleUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.EmailRouting.Routing.Rules.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "a7e6fb77503c41d8a7f3113c6918f10c", + email_routing.RoutingRuleUpdateParams{ + Actions: cloudflare.F([]email_routing.RoutingRuleUpdateParamsAction{{ + Type: cloudflare.F(email_routing.RoutingRuleUpdateParamsActionsTypeForward), + Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), + }, { + Type: cloudflare.F(email_routing.RoutingRuleUpdateParamsActionsTypeForward), + Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), + }, { + Type: cloudflare.F(email_routing.RoutingRuleUpdateParamsActionsTypeForward), + Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), + }}), + Matchers: cloudflare.F([]email_routing.RoutingRuleUpdateParamsMatcher{{ + Field: cloudflare.F(email_routing.RoutingRuleUpdateParamsMatchersFieldTo), + Type: cloudflare.F(email_routing.RoutingRuleUpdateParamsMatchersTypeLiteral), + Value: cloudflare.F("test@example.com"), + }, { + Field: cloudflare.F(email_routing.RoutingRuleUpdateParamsMatchersFieldTo), + Type: cloudflare.F(email_routing.RoutingRuleUpdateParamsMatchersTypeLiteral), + Value: cloudflare.F("test@example.com"), + }, { + Field: cloudflare.F(email_routing.RoutingRuleUpdateParamsMatchersFieldTo), + Type: cloudflare.F(email_routing.RoutingRuleUpdateParamsMatchersTypeLiteral), + Value: cloudflare.F("test@example.com"), + }}), + Enabled: cloudflare.F(email_routing.RoutingRuleUpdateParamsEnabledTrue), + Name: cloudflare.F("Send to user@example.net rule."), + Priority: cloudflare.F(0.000000), + }, + ) + 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 TestRoutingRuleListWithOptionalParams(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("user@example.com"), + ) + _, err := client.EmailRouting.Routing.Rules.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + email_routing.RoutingRuleListParams{ + Enabled: cloudflare.F(email_routing.RoutingRuleListParamsEnabledTrue), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(5.000000), + }, + ) + 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 TestRoutingRuleDelete(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("user@example.com"), + ) + _, err := client.EmailRouting.Routing.Rules.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "a7e6fb77503c41d8a7f3113c6918f10c", + ) + 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 TestRoutingRuleGet(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("user@example.com"), + ) + _, err := client.EmailRouting.Routing.Rules.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "a7e6fb77503c41d8a7f3113c6918f10c", + ) + 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/email_routing/routingrulecatchall.go b/email_routing/routingrulecatchall.go new file mode 100644 index 00000000000..d5af910a6f4 --- /dev/null +++ b/email_routing/routingrulecatchall.go @@ -0,0 +1,390 @@ +// File generated from our OpenAPI spec by Stainless. + +package email_routing + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// RoutingRuleCatchAllService 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 [NewRoutingRuleCatchAllService] +// method instead. +type RoutingRuleCatchAllService struct { + Options []option.RequestOption +} + +// NewRoutingRuleCatchAllService 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 NewRoutingRuleCatchAllService(opts ...option.RequestOption) (r *RoutingRuleCatchAllService) { + r = &RoutingRuleCatchAllService{} + r.Options = opts + return +} + +// Enable or disable catch-all routing rule, or change action to forward to +// specific destination address. +func (r *RoutingRuleCatchAllService) Update(ctx context.Context, zoneIdentifier string, body RoutingRuleCatchAllUpdateParams, opts ...option.RequestOption) (res *EmailCatchAllRule, err error) { + opts = append(r.Options[:], opts...) + var env RoutingRuleCatchAllUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/email/routing/rules/catch_all", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get information on the default catch-all routing rule. +func (r *RoutingRuleCatchAllService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *EmailCatchAllRule, err error) { + opts = append(r.Options[:], opts...) + var env RoutingRuleCatchAllGetResponseEnvelope + path := fmt.Sprintf("zones/%s/email/routing/rules/catch_all", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type EmailCatchAllRule struct { + // Routing rule identifier. + ID string `json:"id"` + // List actions for the catch-all routing rule. + Actions []EmailCatchAllRuleAction `json:"actions"` + // Routing rule status. + Enabled EmailCatchAllRuleEnabled `json:"enabled"` + // List of matchers for the catch-all routing rule. + Matchers []EmailCatchAllRuleMatcher `json:"matchers"` + // Routing rule name. + Name string `json:"name"` + // Routing rule tag. (Deprecated, replaced by routing rule identifier) + Tag string `json:"tag"` + JSON emailCatchAllRuleJSON `json:"-"` +} + +// emailCatchAllRuleJSON contains the JSON metadata for the struct +// [EmailCatchAllRule] +type emailCatchAllRuleJSON struct { + ID apijson.Field + Actions apijson.Field + Enabled apijson.Field + Matchers apijson.Field + Name apijson.Field + Tag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailCatchAllRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailCatchAllRuleJSON) RawJSON() string { + return r.raw +} + +// Action for the catch-all routing rule. +type EmailCatchAllRuleAction struct { + // Type of action for catch-all rule. + Type EmailCatchAllRuleActionsType `json:"type,required"` + Value []string `json:"value"` + JSON emailCatchAllRuleActionJSON `json:"-"` +} + +// emailCatchAllRuleActionJSON contains the JSON metadata for the struct +// [EmailCatchAllRuleAction] +type emailCatchAllRuleActionJSON struct { + Type apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailCatchAllRuleAction) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailCatchAllRuleActionJSON) RawJSON() string { + return r.raw +} + +// Type of action for catch-all rule. +type EmailCatchAllRuleActionsType string + +const ( + EmailCatchAllRuleActionsTypeDrop EmailCatchAllRuleActionsType = "drop" + EmailCatchAllRuleActionsTypeForward EmailCatchAllRuleActionsType = "forward" + EmailCatchAllRuleActionsTypeWorker EmailCatchAllRuleActionsType = "worker" +) + +// Routing rule status. +type EmailCatchAllRuleEnabled bool + +const ( + EmailCatchAllRuleEnabledTrue EmailCatchAllRuleEnabled = true + EmailCatchAllRuleEnabledFalse EmailCatchAllRuleEnabled = false +) + +// Matcher for catch-all routing rule. +type EmailCatchAllRuleMatcher struct { + // Type of matcher. Default is 'all'. + Type EmailCatchAllRuleMatchersType `json:"type,required"` + JSON emailCatchAllRuleMatcherJSON `json:"-"` +} + +// emailCatchAllRuleMatcherJSON contains the JSON metadata for the struct +// [EmailCatchAllRuleMatcher] +type emailCatchAllRuleMatcherJSON struct { + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailCatchAllRuleMatcher) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailCatchAllRuleMatcherJSON) RawJSON() string { + return r.raw +} + +// Type of matcher. Default is 'all'. +type EmailCatchAllRuleMatchersType string + +const ( + EmailCatchAllRuleMatchersTypeAll EmailCatchAllRuleMatchersType = "all" +) + +type RoutingRuleCatchAllUpdateParams struct { + // List actions for the catch-all routing rule. + Actions param.Field[[]RoutingRuleCatchAllUpdateParamsAction] `json:"actions,required"` + // List of matchers for the catch-all routing rule. + Matchers param.Field[[]RoutingRuleCatchAllUpdateParamsMatcher] `json:"matchers,required"` + // Routing rule status. + Enabled param.Field[RoutingRuleCatchAllUpdateParamsEnabled] `json:"enabled"` + // Routing rule name. + Name param.Field[string] `json:"name"` +} + +func (r RoutingRuleCatchAllUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Action for the catch-all routing rule. +type RoutingRuleCatchAllUpdateParamsAction struct { + // Type of action for catch-all rule. + Type param.Field[RoutingRuleCatchAllUpdateParamsActionsType] `json:"type,required"` + Value param.Field[[]string] `json:"value"` +} + +func (r RoutingRuleCatchAllUpdateParamsAction) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Type of action for catch-all rule. +type RoutingRuleCatchAllUpdateParamsActionsType string + +const ( + RoutingRuleCatchAllUpdateParamsActionsTypeDrop RoutingRuleCatchAllUpdateParamsActionsType = "drop" + RoutingRuleCatchAllUpdateParamsActionsTypeForward RoutingRuleCatchAllUpdateParamsActionsType = "forward" + RoutingRuleCatchAllUpdateParamsActionsTypeWorker RoutingRuleCatchAllUpdateParamsActionsType = "worker" +) + +// Matcher for catch-all routing rule. +type RoutingRuleCatchAllUpdateParamsMatcher struct { + // Type of matcher. Default is 'all'. + Type param.Field[RoutingRuleCatchAllUpdateParamsMatchersType] `json:"type,required"` +} + +func (r RoutingRuleCatchAllUpdateParamsMatcher) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Type of matcher. Default is 'all'. +type RoutingRuleCatchAllUpdateParamsMatchersType string + +const ( + RoutingRuleCatchAllUpdateParamsMatchersTypeAll RoutingRuleCatchAllUpdateParamsMatchersType = "all" +) + +// Routing rule status. +type RoutingRuleCatchAllUpdateParamsEnabled bool + +const ( + RoutingRuleCatchAllUpdateParamsEnabledTrue RoutingRuleCatchAllUpdateParamsEnabled = true + RoutingRuleCatchAllUpdateParamsEnabledFalse RoutingRuleCatchAllUpdateParamsEnabled = false +) + +type RoutingRuleCatchAllUpdateResponseEnvelope struct { + Errors []RoutingRuleCatchAllUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []RoutingRuleCatchAllUpdateResponseEnvelopeMessages `json:"messages,required"` + Result EmailCatchAllRule `json:"result,required"` + // Whether the API call was successful + Success RoutingRuleCatchAllUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON routingRuleCatchAllUpdateResponseEnvelopeJSON `json:"-"` +} + +// routingRuleCatchAllUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [RoutingRuleCatchAllUpdateResponseEnvelope] +type routingRuleCatchAllUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleCatchAllUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleCatchAllUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RoutingRuleCatchAllUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingRuleCatchAllUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// routingRuleCatchAllUpdateResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [RoutingRuleCatchAllUpdateResponseEnvelopeErrors] +type routingRuleCatchAllUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleCatchAllUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleCatchAllUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RoutingRuleCatchAllUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingRuleCatchAllUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// routingRuleCatchAllUpdateResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [RoutingRuleCatchAllUpdateResponseEnvelopeMessages] +type routingRuleCatchAllUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleCatchAllUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleCatchAllUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RoutingRuleCatchAllUpdateResponseEnvelopeSuccess bool + +const ( + RoutingRuleCatchAllUpdateResponseEnvelopeSuccessTrue RoutingRuleCatchAllUpdateResponseEnvelopeSuccess = true +) + +type RoutingRuleCatchAllGetResponseEnvelope struct { + Errors []RoutingRuleCatchAllGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RoutingRuleCatchAllGetResponseEnvelopeMessages `json:"messages,required"` + Result EmailCatchAllRule `json:"result,required"` + // Whether the API call was successful + Success RoutingRuleCatchAllGetResponseEnvelopeSuccess `json:"success,required"` + JSON routingRuleCatchAllGetResponseEnvelopeJSON `json:"-"` +} + +// routingRuleCatchAllGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [RoutingRuleCatchAllGetResponseEnvelope] +type routingRuleCatchAllGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleCatchAllGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleCatchAllGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RoutingRuleCatchAllGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingRuleCatchAllGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// routingRuleCatchAllGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [RoutingRuleCatchAllGetResponseEnvelopeErrors] +type routingRuleCatchAllGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleCatchAllGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleCatchAllGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RoutingRuleCatchAllGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routingRuleCatchAllGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// routingRuleCatchAllGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [RoutingRuleCatchAllGetResponseEnvelopeMessages] +type routingRuleCatchAllGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RoutingRuleCatchAllGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routingRuleCatchAllGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RoutingRuleCatchAllGetResponseEnvelopeSuccess bool + +const ( + RoutingRuleCatchAllGetResponseEnvelopeSuccessTrue RoutingRuleCatchAllGetResponseEnvelopeSuccess = true +) diff --git a/email_routing/routingrulecatchall_test.go b/email_routing/routingrulecatchall_test.go new file mode 100644 index 00000000000..b3d46bc1036 --- /dev/null +++ b/email_routing/routingrulecatchall_test.go @@ -0,0 +1,87 @@ +// File generated from our OpenAPI spec by Stainless. + +package email_routing_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/email_routing" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRoutingRuleCatchAllUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.EmailRouting.Routing.Rules.CatchAlls.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + email_routing.RoutingRuleCatchAllUpdateParams{ + Actions: cloudflare.F([]email_routing.RoutingRuleCatchAllUpdateParamsAction{{ + Type: cloudflare.F(email_routing.RoutingRuleCatchAllUpdateParamsActionsTypeForward), + Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), + }, { + Type: cloudflare.F(email_routing.RoutingRuleCatchAllUpdateParamsActionsTypeForward), + Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), + }, { + Type: cloudflare.F(email_routing.RoutingRuleCatchAllUpdateParamsActionsTypeForward), + Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), + }}), + Matchers: cloudflare.F([]email_routing.RoutingRuleCatchAllUpdateParamsMatcher{{ + Type: cloudflare.F(email_routing.RoutingRuleCatchAllUpdateParamsMatchersTypeAll), + }, { + Type: cloudflare.F(email_routing.RoutingRuleCatchAllUpdateParamsMatchersTypeAll), + }, { + Type: cloudflare.F(email_routing.RoutingRuleCatchAllUpdateParamsMatchersTypeAll), + }}), + Enabled: cloudflare.F(email_routing.RoutingRuleCatchAllUpdateParamsEnabledTrue), + Name: cloudflare.F("Send to user@example.net rule."), + }, + ) + 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 TestRoutingRuleCatchAllGet(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("user@example.com"), + ) + _, err := client.EmailRouting.Routing.Rules.CatchAlls.Get(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/emailrouting.go b/emailrouting.go deleted file mode 100644 index ed4bddd4fe0..00000000000 --- a/emailrouting.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// EmailRoutingService 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 [NewEmailRoutingService] method -// instead. -type EmailRoutingService struct { - Options []option.RequestOption - Routing *EmailRoutingRoutingService -} - -// NewEmailRoutingService 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 NewEmailRoutingService(opts ...option.RequestOption) (r *EmailRoutingService) { - r = &EmailRoutingService{} - r.Options = opts - r.Routing = NewEmailRoutingRoutingService(opts...) - return -} diff --git a/emailroutingrouting.go b/emailroutingrouting.go deleted file mode 100644 index a0bdad6cd2d..00000000000 --- a/emailroutingrouting.go +++ /dev/null @@ -1,207 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// EmailRoutingRoutingService 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 [NewEmailRoutingRoutingService] -// method instead. -type EmailRoutingRoutingService struct { - Options []option.RequestOption - Disables *EmailRoutingRoutingDisableService - DNS *EmailRoutingRoutingDNSService - Enables *EmailRoutingRoutingEnableService - Rules *EmailRoutingRoutingRuleService - Addresses *EmailRoutingRoutingAddressService -} - -// NewEmailRoutingRoutingService 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 NewEmailRoutingRoutingService(opts ...option.RequestOption) (r *EmailRoutingRoutingService) { - r = &EmailRoutingRoutingService{} - r.Options = opts - r.Disables = NewEmailRoutingRoutingDisableService(opts...) - r.DNS = NewEmailRoutingRoutingDNSService(opts...) - r.Enables = NewEmailRoutingRoutingEnableService(opts...) - r.Rules = NewEmailRoutingRoutingRuleService(opts...) - r.Addresses = NewEmailRoutingRoutingAddressService(opts...) - return -} - -// Get information about the settings for your Email Routing zone. -func (r *EmailRoutingRoutingService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *EmailRoutingRoutingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env EmailRoutingRoutingGetResponseEnvelope - path := fmt.Sprintf("zones/%s/email/routing", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type EmailRoutingRoutingGetResponse struct { - // Email Routing settings identifier. - ID string `json:"id"` - // The date and time the settings have been created. - Created time.Time `json:"created" format:"date-time"` - // State of the zone settings for Email Routing. - Enabled EmailRoutingRoutingGetResponseEnabled `json:"enabled"` - // The date and time the settings have been modified. - Modified time.Time `json:"modified" format:"date-time"` - // Domain of your zone. - Name string `json:"name"` - // Flag to check if the user skipped the configuration wizard. - SkipWizard EmailRoutingRoutingGetResponseSkipWizard `json:"skip_wizard"` - // Show the state of your account, and the type or configuration error. - Status EmailRoutingRoutingGetResponseStatus `json:"status"` - // Email Routing settings tag. (Deprecated, replaced by Email Routing settings - // identifier) - Tag string `json:"tag"` - JSON emailRoutingRoutingGetResponseJSON `json:"-"` -} - -// emailRoutingRoutingGetResponseJSON contains the JSON metadata for the struct -// [EmailRoutingRoutingGetResponse] -type emailRoutingRoutingGetResponseJSON struct { - ID apijson.Field - Created apijson.Field - Enabled apijson.Field - Modified apijson.Field - Name apijson.Field - SkipWizard apijson.Field - Status apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingGetResponseJSON) RawJSON() string { - return r.raw -} - -// State of the zone settings for Email Routing. -type EmailRoutingRoutingGetResponseEnabled bool - -const ( - EmailRoutingRoutingGetResponseEnabledTrue EmailRoutingRoutingGetResponseEnabled = true - EmailRoutingRoutingGetResponseEnabledFalse EmailRoutingRoutingGetResponseEnabled = false -) - -// Flag to check if the user skipped the configuration wizard. -type EmailRoutingRoutingGetResponseSkipWizard bool - -const ( - EmailRoutingRoutingGetResponseSkipWizardTrue EmailRoutingRoutingGetResponseSkipWizard = true - EmailRoutingRoutingGetResponseSkipWizardFalse EmailRoutingRoutingGetResponseSkipWizard = false -) - -// Show the state of your account, and the type or configuration error. -type EmailRoutingRoutingGetResponseStatus string - -const ( - EmailRoutingRoutingGetResponseStatusReady EmailRoutingRoutingGetResponseStatus = "ready" - EmailRoutingRoutingGetResponseStatusUnconfigured EmailRoutingRoutingGetResponseStatus = "unconfigured" - EmailRoutingRoutingGetResponseStatusMisconfigured EmailRoutingRoutingGetResponseStatus = "misconfigured" - EmailRoutingRoutingGetResponseStatusMisconfiguredLocked EmailRoutingRoutingGetResponseStatus = "misconfigured/locked" - EmailRoutingRoutingGetResponseStatusUnlocked EmailRoutingRoutingGetResponseStatus = "unlocked" -) - -type EmailRoutingRoutingGetResponseEnvelope struct { - Errors []EmailRoutingRoutingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []EmailRoutingRoutingGetResponseEnvelopeMessages `json:"messages,required"` - Result EmailRoutingRoutingGetResponse `json:"result,required"` - // Whether the API call was successful - Success EmailRoutingRoutingGetResponseEnvelopeSuccess `json:"success,required"` - JSON emailRoutingRoutingGetResponseEnvelopeJSON `json:"-"` -} - -// emailRoutingRoutingGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [EmailRoutingRoutingGetResponseEnvelope] -type emailRoutingRoutingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// emailRoutingRoutingGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [EmailRoutingRoutingGetResponseEnvelopeErrors] -type emailRoutingRoutingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// emailRoutingRoutingGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [EmailRoutingRoutingGetResponseEnvelopeMessages] -type emailRoutingRoutingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type EmailRoutingRoutingGetResponseEnvelopeSuccess bool - -const ( - EmailRoutingRoutingGetResponseEnvelopeSuccessTrue EmailRoutingRoutingGetResponseEnvelopeSuccess = true -) diff --git a/emailroutingrouting_test.go b/emailroutingrouting_test.go deleted file mode 100644 index 0b13e3198cd..00000000000 --- a/emailroutingrouting_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestEmailRoutingRoutingGet(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("user@example.com"), - ) - _, err := client.EmailRouting.Routing.Get(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/emailroutingroutingaddress.go b/emailroutingroutingaddress.go deleted file mode 100644 index 5564992f51a..00000000000 --- a/emailroutingroutingaddress.go +++ /dev/null @@ -1,544 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" -) - -// EmailRoutingRoutingAddressService 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 -// [NewEmailRoutingRoutingAddressService] method instead. -type EmailRoutingRoutingAddressService struct { - Options []option.RequestOption -} - -// NewEmailRoutingRoutingAddressService 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 NewEmailRoutingRoutingAddressService(opts ...option.RequestOption) (r *EmailRoutingRoutingAddressService) { - r = &EmailRoutingRoutingAddressService{} - r.Options = opts - return -} - -// Create a destination address to forward your emails to. Destination addresses -// need to be verified before they can be used. -func (r *EmailRoutingRoutingAddressService) New(ctx context.Context, accountIdentifier string, body EmailRoutingRoutingAddressNewParams, opts ...option.RequestOption) (res *EmailRoutingRoutingAddressNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env EmailRoutingRoutingAddressNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/email/routing/addresses", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists existing destination addresses. -func (r *EmailRoutingRoutingAddressService) List(ctx context.Context, accountIdentifier string, query EmailRoutingRoutingAddressListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[EmailRoutingRoutingAddressListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("accounts/%s/email/routing/addresses", accountIdentifier) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Lists existing destination addresses. -func (r *EmailRoutingRoutingAddressService) ListAutoPaging(ctx context.Context, accountIdentifier string, query EmailRoutingRoutingAddressListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[EmailRoutingRoutingAddressListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, accountIdentifier, query, opts...)) -} - -// Deletes a specific destination address. -func (r *EmailRoutingRoutingAddressService) Delete(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string, opts ...option.RequestOption) (res *EmailRoutingRoutingAddressDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env EmailRoutingRoutingAddressDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/email/routing/addresses/%s", accountIdentifier, destinationAddressIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets information for a specific destination email already created. -func (r *EmailRoutingRoutingAddressService) Get(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string, opts ...option.RequestOption) (res *EmailRoutingRoutingAddressGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env EmailRoutingRoutingAddressGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/email/routing/addresses/%s", accountIdentifier, destinationAddressIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type EmailRoutingRoutingAddressNewResponse struct { - // Destination address identifier. - ID string `json:"id"` - // The date and time the destination address has been created. - Created time.Time `json:"created" format:"date-time"` - // The contact email address of the user. - Email string `json:"email"` - // The date and time the destination address was last modified. - Modified time.Time `json:"modified" format:"date-time"` - // Destination address tag. (Deprecated, replaced by destination address - // identifier) - Tag string `json:"tag"` - // The date and time the destination address has been verified. Null means not - // verified yet. - Verified time.Time `json:"verified" format:"date-time"` - JSON emailRoutingRoutingAddressNewResponseJSON `json:"-"` -} - -// emailRoutingRoutingAddressNewResponseJSON contains the JSON metadata for the -// struct [EmailRoutingRoutingAddressNewResponse] -type emailRoutingRoutingAddressNewResponseJSON struct { - ID apijson.Field - Created apijson.Field - Email apijson.Field - Modified apijson.Field - Tag apijson.Field - Verified apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingAddressNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingAddressNewResponseJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingAddressListResponse struct { - // Destination address identifier. - ID string `json:"id"` - // The date and time the destination address has been created. - Created time.Time `json:"created" format:"date-time"` - // The contact email address of the user. - Email string `json:"email"` - // The date and time the destination address was last modified. - Modified time.Time `json:"modified" format:"date-time"` - // Destination address tag. (Deprecated, replaced by destination address - // identifier) - Tag string `json:"tag"` - // The date and time the destination address has been verified. Null means not - // verified yet. - Verified time.Time `json:"verified" format:"date-time"` - JSON emailRoutingRoutingAddressListResponseJSON `json:"-"` -} - -// emailRoutingRoutingAddressListResponseJSON contains the JSON metadata for the -// struct [EmailRoutingRoutingAddressListResponse] -type emailRoutingRoutingAddressListResponseJSON struct { - ID apijson.Field - Created apijson.Field - Email apijson.Field - Modified apijson.Field - Tag apijson.Field - Verified apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingAddressListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingAddressListResponseJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingAddressDeleteResponse struct { - // Destination address identifier. - ID string `json:"id"` - // The date and time the destination address has been created. - Created time.Time `json:"created" format:"date-time"` - // The contact email address of the user. - Email string `json:"email"` - // The date and time the destination address was last modified. - Modified time.Time `json:"modified" format:"date-time"` - // Destination address tag. (Deprecated, replaced by destination address - // identifier) - Tag string `json:"tag"` - // The date and time the destination address has been verified. Null means not - // verified yet. - Verified time.Time `json:"verified" format:"date-time"` - JSON emailRoutingRoutingAddressDeleteResponseJSON `json:"-"` -} - -// emailRoutingRoutingAddressDeleteResponseJSON contains the JSON metadata for the -// struct [EmailRoutingRoutingAddressDeleteResponse] -type emailRoutingRoutingAddressDeleteResponseJSON struct { - ID apijson.Field - Created apijson.Field - Email apijson.Field - Modified apijson.Field - Tag apijson.Field - Verified apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingAddressDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingAddressDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingAddressGetResponse struct { - // Destination address identifier. - ID string `json:"id"` - // The date and time the destination address has been created. - Created time.Time `json:"created" format:"date-time"` - // The contact email address of the user. - Email string `json:"email"` - // The date and time the destination address was last modified. - Modified time.Time `json:"modified" format:"date-time"` - // Destination address tag. (Deprecated, replaced by destination address - // identifier) - Tag string `json:"tag"` - // The date and time the destination address has been verified. Null means not - // verified yet. - Verified time.Time `json:"verified" format:"date-time"` - JSON emailRoutingRoutingAddressGetResponseJSON `json:"-"` -} - -// emailRoutingRoutingAddressGetResponseJSON contains the JSON metadata for the -// struct [EmailRoutingRoutingAddressGetResponse] -type emailRoutingRoutingAddressGetResponseJSON struct { - ID apijson.Field - Created apijson.Field - Email apijson.Field - Modified apijson.Field - Tag apijson.Field - Verified apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingAddressGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingAddressGetResponseJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingAddressNewParams struct { - // The contact email address of the user. - Email param.Field[string] `json:"email,required"` -} - -func (r EmailRoutingRoutingAddressNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type EmailRoutingRoutingAddressNewResponseEnvelope struct { - Errors []EmailRoutingRoutingAddressNewResponseEnvelopeErrors `json:"errors,required"` - Messages []EmailRoutingRoutingAddressNewResponseEnvelopeMessages `json:"messages,required"` - Result EmailRoutingRoutingAddressNewResponse `json:"result,required"` - // Whether the API call was successful - Success EmailRoutingRoutingAddressNewResponseEnvelopeSuccess `json:"success,required"` - JSON emailRoutingRoutingAddressNewResponseEnvelopeJSON `json:"-"` -} - -// emailRoutingRoutingAddressNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [EmailRoutingRoutingAddressNewResponseEnvelope] -type emailRoutingRoutingAddressNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingAddressNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingAddressNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingAddressNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingAddressNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// emailRoutingRoutingAddressNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingAddressNewResponseEnvelopeErrors] -type emailRoutingRoutingAddressNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingAddressNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingAddressNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingAddressNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingAddressNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// emailRoutingRoutingAddressNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingAddressNewResponseEnvelopeMessages] -type emailRoutingRoutingAddressNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingAddressNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingAddressNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type EmailRoutingRoutingAddressNewResponseEnvelopeSuccess bool - -const ( - EmailRoutingRoutingAddressNewResponseEnvelopeSuccessTrue EmailRoutingRoutingAddressNewResponseEnvelopeSuccess = true -) - -type EmailRoutingRoutingAddressListParams struct { - // Sorts results in an ascending or descending order. - Direction param.Field[EmailRoutingRoutingAddressListParamsDirection] `query:"direction"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // Maximum number of results per page. - PerPage param.Field[float64] `query:"per_page"` - // Filter by verified destination addresses. - Verified param.Field[EmailRoutingRoutingAddressListParamsVerified] `query:"verified"` -} - -// URLQuery serializes [EmailRoutingRoutingAddressListParams]'s query parameters as -// `url.Values`. -func (r EmailRoutingRoutingAddressListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Sorts results in an ascending or descending order. -type EmailRoutingRoutingAddressListParamsDirection string - -const ( - EmailRoutingRoutingAddressListParamsDirectionAsc EmailRoutingRoutingAddressListParamsDirection = "asc" - EmailRoutingRoutingAddressListParamsDirectionDesc EmailRoutingRoutingAddressListParamsDirection = "desc" -) - -// Filter by verified destination addresses. -type EmailRoutingRoutingAddressListParamsVerified bool - -const ( - EmailRoutingRoutingAddressListParamsVerifiedTrue EmailRoutingRoutingAddressListParamsVerified = true - EmailRoutingRoutingAddressListParamsVerifiedFalse EmailRoutingRoutingAddressListParamsVerified = false -) - -type EmailRoutingRoutingAddressDeleteResponseEnvelope struct { - Errors []EmailRoutingRoutingAddressDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []EmailRoutingRoutingAddressDeleteResponseEnvelopeMessages `json:"messages,required"` - Result EmailRoutingRoutingAddressDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success EmailRoutingRoutingAddressDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON emailRoutingRoutingAddressDeleteResponseEnvelopeJSON `json:"-"` -} - -// emailRoutingRoutingAddressDeleteResponseEnvelopeJSON contains the JSON metadata -// for the struct [EmailRoutingRoutingAddressDeleteResponseEnvelope] -type emailRoutingRoutingAddressDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingAddressDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingAddressDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingAddressDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingAddressDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// emailRoutingRoutingAddressDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingAddressDeleteResponseEnvelopeErrors] -type emailRoutingRoutingAddressDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingAddressDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingAddressDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingAddressDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingAddressDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// emailRoutingRoutingAddressDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [EmailRoutingRoutingAddressDeleteResponseEnvelopeMessages] -type emailRoutingRoutingAddressDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingAddressDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingAddressDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type EmailRoutingRoutingAddressDeleteResponseEnvelopeSuccess bool - -const ( - EmailRoutingRoutingAddressDeleteResponseEnvelopeSuccessTrue EmailRoutingRoutingAddressDeleteResponseEnvelopeSuccess = true -) - -type EmailRoutingRoutingAddressGetResponseEnvelope struct { - Errors []EmailRoutingRoutingAddressGetResponseEnvelopeErrors `json:"errors,required"` - Messages []EmailRoutingRoutingAddressGetResponseEnvelopeMessages `json:"messages,required"` - Result EmailRoutingRoutingAddressGetResponse `json:"result,required"` - // Whether the API call was successful - Success EmailRoutingRoutingAddressGetResponseEnvelopeSuccess `json:"success,required"` - JSON emailRoutingRoutingAddressGetResponseEnvelopeJSON `json:"-"` -} - -// emailRoutingRoutingAddressGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [EmailRoutingRoutingAddressGetResponseEnvelope] -type emailRoutingRoutingAddressGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingAddressGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingAddressGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingAddressGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingAddressGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// emailRoutingRoutingAddressGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingAddressGetResponseEnvelopeErrors] -type emailRoutingRoutingAddressGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingAddressGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingAddressGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingAddressGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingAddressGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// emailRoutingRoutingAddressGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingAddressGetResponseEnvelopeMessages] -type emailRoutingRoutingAddressGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingAddressGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingAddressGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type EmailRoutingRoutingAddressGetResponseEnvelopeSuccess bool - -const ( - EmailRoutingRoutingAddressGetResponseEnvelopeSuccessTrue EmailRoutingRoutingAddressGetResponseEnvelopeSuccess = true -) diff --git a/emailroutingroutingaddress_test.go b/emailroutingroutingaddress_test.go deleted file mode 100644 index 6ddce07007d..00000000000 --- a/emailroutingroutingaddress_test.go +++ /dev/null @@ -1,133 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestEmailRoutingRoutingAddressNew(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("user@example.com"), - ) - _, err := client.EmailRouting.Routing.Addresses.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.EmailRoutingRoutingAddressNewParams{ - Email: cloudflare.F("user@example.com"), - }, - ) - 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 TestEmailRoutingRoutingAddressListWithOptionalParams(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("user@example.com"), - ) - _, err := client.EmailRouting.Routing.Addresses.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.EmailRoutingRoutingAddressListParams{ - Direction: cloudflare.F(cloudflare.EmailRoutingRoutingAddressListParamsDirectionAsc), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(5.000000), - Verified: cloudflare.F(cloudflare.EmailRoutingRoutingAddressListParamsVerifiedTrue), - }, - ) - 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 TestEmailRoutingRoutingAddressDelete(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("user@example.com"), - ) - _, err := client.EmailRouting.Routing.Addresses.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "ea95132c15732412d22c1476fa83f27a", - ) - 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 TestEmailRoutingRoutingAddressGet(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("user@example.com"), - ) - _, err := client.EmailRouting.Routing.Addresses.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "ea95132c15732412d22c1476fa83f27a", - ) - 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/emailroutingroutingdisable.go b/emailroutingroutingdisable.go deleted file mode 100644 index 98ad915a92f..00000000000 --- a/emailroutingroutingdisable.go +++ /dev/null @@ -1,198 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// EmailRoutingRoutingDisableService 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 -// [NewEmailRoutingRoutingDisableService] method instead. -type EmailRoutingRoutingDisableService struct { - Options []option.RequestOption -} - -// NewEmailRoutingRoutingDisableService 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 NewEmailRoutingRoutingDisableService(opts ...option.RequestOption) (r *EmailRoutingRoutingDisableService) { - r = &EmailRoutingRoutingDisableService{} - r.Options = opts - return -} - -// Disable your Email Routing zone. Also removes additional MX records previously -// required for Email Routing to work. -func (r *EmailRoutingRoutingDisableService) New(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *EmailRoutingRoutingDisableNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env EmailRoutingRoutingDisableNewResponseEnvelope - path := fmt.Sprintf("zones/%s/email/routing/disable", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type EmailRoutingRoutingDisableNewResponse struct { - // Email Routing settings identifier. - ID string `json:"id"` - // The date and time the settings have been created. - Created time.Time `json:"created" format:"date-time"` - // State of the zone settings for Email Routing. - Enabled EmailRoutingRoutingDisableNewResponseEnabled `json:"enabled"` - // The date and time the settings have been modified. - Modified time.Time `json:"modified" format:"date-time"` - // Domain of your zone. - Name string `json:"name"` - // Flag to check if the user skipped the configuration wizard. - SkipWizard EmailRoutingRoutingDisableNewResponseSkipWizard `json:"skip_wizard"` - // Show the state of your account, and the type or configuration error. - Status EmailRoutingRoutingDisableNewResponseStatus `json:"status"` - // Email Routing settings tag. (Deprecated, replaced by Email Routing settings - // identifier) - Tag string `json:"tag"` - JSON emailRoutingRoutingDisableNewResponseJSON `json:"-"` -} - -// emailRoutingRoutingDisableNewResponseJSON contains the JSON metadata for the -// struct [EmailRoutingRoutingDisableNewResponse] -type emailRoutingRoutingDisableNewResponseJSON struct { - ID apijson.Field - Created apijson.Field - Enabled apijson.Field - Modified apijson.Field - Name apijson.Field - SkipWizard apijson.Field - Status apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingDisableNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingDisableNewResponseJSON) RawJSON() string { - return r.raw -} - -// State of the zone settings for Email Routing. -type EmailRoutingRoutingDisableNewResponseEnabled bool - -const ( - EmailRoutingRoutingDisableNewResponseEnabledTrue EmailRoutingRoutingDisableNewResponseEnabled = true - EmailRoutingRoutingDisableNewResponseEnabledFalse EmailRoutingRoutingDisableNewResponseEnabled = false -) - -// Flag to check if the user skipped the configuration wizard. -type EmailRoutingRoutingDisableNewResponseSkipWizard bool - -const ( - EmailRoutingRoutingDisableNewResponseSkipWizardTrue EmailRoutingRoutingDisableNewResponseSkipWizard = true - EmailRoutingRoutingDisableNewResponseSkipWizardFalse EmailRoutingRoutingDisableNewResponseSkipWizard = false -) - -// Show the state of your account, and the type or configuration error. -type EmailRoutingRoutingDisableNewResponseStatus string - -const ( - EmailRoutingRoutingDisableNewResponseStatusReady EmailRoutingRoutingDisableNewResponseStatus = "ready" - EmailRoutingRoutingDisableNewResponseStatusUnconfigured EmailRoutingRoutingDisableNewResponseStatus = "unconfigured" - EmailRoutingRoutingDisableNewResponseStatusMisconfigured EmailRoutingRoutingDisableNewResponseStatus = "misconfigured" - EmailRoutingRoutingDisableNewResponseStatusMisconfiguredLocked EmailRoutingRoutingDisableNewResponseStatus = "misconfigured/locked" - EmailRoutingRoutingDisableNewResponseStatusUnlocked EmailRoutingRoutingDisableNewResponseStatus = "unlocked" -) - -type EmailRoutingRoutingDisableNewResponseEnvelope struct { - Errors []EmailRoutingRoutingDisableNewResponseEnvelopeErrors `json:"errors,required"` - Messages []EmailRoutingRoutingDisableNewResponseEnvelopeMessages `json:"messages,required"` - Result EmailRoutingRoutingDisableNewResponse `json:"result,required"` - // Whether the API call was successful - Success EmailRoutingRoutingDisableNewResponseEnvelopeSuccess `json:"success,required"` - JSON emailRoutingRoutingDisableNewResponseEnvelopeJSON `json:"-"` -} - -// emailRoutingRoutingDisableNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [EmailRoutingRoutingDisableNewResponseEnvelope] -type emailRoutingRoutingDisableNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingDisableNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingDisableNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingDisableNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingDisableNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// emailRoutingRoutingDisableNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingDisableNewResponseEnvelopeErrors] -type emailRoutingRoutingDisableNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingDisableNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingDisableNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingDisableNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingDisableNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// emailRoutingRoutingDisableNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingDisableNewResponseEnvelopeMessages] -type emailRoutingRoutingDisableNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingDisableNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingDisableNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type EmailRoutingRoutingDisableNewResponseEnvelopeSuccess bool - -const ( - EmailRoutingRoutingDisableNewResponseEnvelopeSuccessTrue EmailRoutingRoutingDisableNewResponseEnvelopeSuccess = true -) diff --git a/emailroutingroutingdisable_test.go b/emailroutingroutingdisable_test.go deleted file mode 100644 index 5055e799333..00000000000 --- a/emailroutingroutingdisable_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestEmailRoutingRoutingDisableNew(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("user@example.com"), - ) - _, err := client.EmailRouting.Routing.Disables.New(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/emailroutingroutingdns.go b/emailroutingroutingdns.go deleted file mode 100644 index 962392eabc8..00000000000 --- a/emailroutingroutingdns.go +++ /dev/null @@ -1,252 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// EmailRoutingRoutingDNSService 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 [NewEmailRoutingRoutingDNSService] -// method instead. -type EmailRoutingRoutingDNSService struct { - Options []option.RequestOption -} - -// NewEmailRoutingRoutingDNSService 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 NewEmailRoutingRoutingDNSService(opts ...option.RequestOption) (r *EmailRoutingRoutingDNSService) { - r = &EmailRoutingRoutingDNSService{} - r.Options = opts - return -} - -// Show the DNS records needed to configure your Email Routing zone. -func (r *EmailRoutingRoutingDNSService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *[]EmailRoutingRoutingDNSGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env EmailRoutingRoutingDNSGetResponseEnvelope - path := fmt.Sprintf("zones/%s/email/routing/dns", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List of records needed to enable an Email Routing zone. -type EmailRoutingRoutingDNSGetResponse struct { - // DNS record content. - Content string `json:"content"` - // DNS record name (or @ for the zone apex). - Name string `json:"name"` - // Required for MX, SRV and URI records. Unused by other record types. Records with - // lower priorities are preferred. - Priority float64 `json:"priority"` - // Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 - // for 'automatic'. - TTL EmailRoutingRoutingDNSGetResponseTTL `json:"ttl"` - // DNS record type. - Type EmailRoutingRoutingDNSGetResponseType `json:"type"` - JSON emailRoutingRoutingDNSGetResponseJSON `json:"-"` -} - -// emailRoutingRoutingDNSGetResponseJSON contains the JSON metadata for the struct -// [EmailRoutingRoutingDNSGetResponse] -type emailRoutingRoutingDNSGetResponseJSON struct { - Content apijson.Field - Name apijson.Field - Priority apijson.Field - TTL apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingDNSGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingDNSGetResponseJSON) RawJSON() string { - return r.raw -} - -// Time to live, in seconds, of the DNS record. Must be between 60 and 86400, or 1 -// for 'automatic'. -// -// Union satisfied by [shared.UnionFloat] or -// [EmailRoutingRoutingDNSGetResponseTTLNumber]. -type EmailRoutingRoutingDNSGetResponseTTL interface { - ImplementsEmailRoutingRoutingDNSGetResponseTTL() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*EmailRoutingRoutingDNSGetResponseTTL)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(EmailRoutingRoutingDNSGetResponseTTLNumber(0)), - }, - ) -} - -type EmailRoutingRoutingDNSGetResponseTTLNumber float64 - -const ( - EmailRoutingRoutingDNSGetResponseTTLNumber1 EmailRoutingRoutingDNSGetResponseTTLNumber = 1 -) - -// DNS record type. -type EmailRoutingRoutingDNSGetResponseType string - -const ( - EmailRoutingRoutingDNSGetResponseTypeA EmailRoutingRoutingDNSGetResponseType = "A" - EmailRoutingRoutingDNSGetResponseTypeAAAA EmailRoutingRoutingDNSGetResponseType = "AAAA" - EmailRoutingRoutingDNSGetResponseTypeCNAME EmailRoutingRoutingDNSGetResponseType = "CNAME" - EmailRoutingRoutingDNSGetResponseTypeHTTPS EmailRoutingRoutingDNSGetResponseType = "HTTPS" - EmailRoutingRoutingDNSGetResponseTypeTXT EmailRoutingRoutingDNSGetResponseType = "TXT" - EmailRoutingRoutingDNSGetResponseTypeSRV EmailRoutingRoutingDNSGetResponseType = "SRV" - EmailRoutingRoutingDNSGetResponseTypeLOC EmailRoutingRoutingDNSGetResponseType = "LOC" - EmailRoutingRoutingDNSGetResponseTypeMX EmailRoutingRoutingDNSGetResponseType = "MX" - EmailRoutingRoutingDNSGetResponseTypeNS EmailRoutingRoutingDNSGetResponseType = "NS" - EmailRoutingRoutingDNSGetResponseTypeCert EmailRoutingRoutingDNSGetResponseType = "CERT" - EmailRoutingRoutingDNSGetResponseTypeDNSKEY EmailRoutingRoutingDNSGetResponseType = "DNSKEY" - EmailRoutingRoutingDNSGetResponseTypeDS EmailRoutingRoutingDNSGetResponseType = "DS" - EmailRoutingRoutingDNSGetResponseTypeNAPTR EmailRoutingRoutingDNSGetResponseType = "NAPTR" - EmailRoutingRoutingDNSGetResponseTypeSmimea EmailRoutingRoutingDNSGetResponseType = "SMIMEA" - EmailRoutingRoutingDNSGetResponseTypeSSHFP EmailRoutingRoutingDNSGetResponseType = "SSHFP" - EmailRoutingRoutingDNSGetResponseTypeSVCB EmailRoutingRoutingDNSGetResponseType = "SVCB" - EmailRoutingRoutingDNSGetResponseTypeTLSA EmailRoutingRoutingDNSGetResponseType = "TLSA" - EmailRoutingRoutingDNSGetResponseTypeURI EmailRoutingRoutingDNSGetResponseType = "URI" -) - -type EmailRoutingRoutingDNSGetResponseEnvelope struct { - Errors []EmailRoutingRoutingDNSGetResponseEnvelopeErrors `json:"errors,required"` - Messages []EmailRoutingRoutingDNSGetResponseEnvelopeMessages `json:"messages,required"` - Result []EmailRoutingRoutingDNSGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success EmailRoutingRoutingDNSGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo EmailRoutingRoutingDNSGetResponseEnvelopeResultInfo `json:"result_info"` - JSON emailRoutingRoutingDNSGetResponseEnvelopeJSON `json:"-"` -} - -// emailRoutingRoutingDNSGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [EmailRoutingRoutingDNSGetResponseEnvelope] -type emailRoutingRoutingDNSGetResponseEnvelopeJSON 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 *EmailRoutingRoutingDNSGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingDNSGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingDNSGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingDNSGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// emailRoutingRoutingDNSGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [EmailRoutingRoutingDNSGetResponseEnvelopeErrors] -type emailRoutingRoutingDNSGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingDNSGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingDNSGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingDNSGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingDNSGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// emailRoutingRoutingDNSGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [EmailRoutingRoutingDNSGetResponseEnvelopeMessages] -type emailRoutingRoutingDNSGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingDNSGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingDNSGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type EmailRoutingRoutingDNSGetResponseEnvelopeSuccess bool - -const ( - EmailRoutingRoutingDNSGetResponseEnvelopeSuccessTrue EmailRoutingRoutingDNSGetResponseEnvelopeSuccess = true -) - -type EmailRoutingRoutingDNSGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON emailRoutingRoutingDNSGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// emailRoutingRoutingDNSGetResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingDNSGetResponseEnvelopeResultInfo] -type emailRoutingRoutingDNSGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingDNSGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingDNSGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/emailroutingroutingdns_test.go b/emailroutingroutingdns_test.go deleted file mode 100644 index 393febf15f3..00000000000 --- a/emailroutingroutingdns_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestEmailRoutingRoutingDNSGet(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("user@example.com"), - ) - _, err := client.EmailRouting.Routing.DNS.Get(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/emailroutingroutingenable.go b/emailroutingroutingenable.go deleted file mode 100644 index e3b49eec2c8..00000000000 --- a/emailroutingroutingenable.go +++ /dev/null @@ -1,197 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// EmailRoutingRoutingEnableService 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 -// [NewEmailRoutingRoutingEnableService] method instead. -type EmailRoutingRoutingEnableService struct { - Options []option.RequestOption -} - -// NewEmailRoutingRoutingEnableService 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 NewEmailRoutingRoutingEnableService(opts ...option.RequestOption) (r *EmailRoutingRoutingEnableService) { - r = &EmailRoutingRoutingEnableService{} - r.Options = opts - return -} - -// Enable you Email Routing zone. Add and lock the necessary MX and SPF records. -func (r *EmailRoutingRoutingEnableService) New(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *EmailRoutingRoutingEnableNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env EmailRoutingRoutingEnableNewResponseEnvelope - path := fmt.Sprintf("zones/%s/email/routing/enable", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type EmailRoutingRoutingEnableNewResponse struct { - // Email Routing settings identifier. - ID string `json:"id"` - // The date and time the settings have been created. - Created time.Time `json:"created" format:"date-time"` - // State of the zone settings for Email Routing. - Enabled EmailRoutingRoutingEnableNewResponseEnabled `json:"enabled"` - // The date and time the settings have been modified. - Modified time.Time `json:"modified" format:"date-time"` - // Domain of your zone. - Name string `json:"name"` - // Flag to check if the user skipped the configuration wizard. - SkipWizard EmailRoutingRoutingEnableNewResponseSkipWizard `json:"skip_wizard"` - // Show the state of your account, and the type or configuration error. - Status EmailRoutingRoutingEnableNewResponseStatus `json:"status"` - // Email Routing settings tag. (Deprecated, replaced by Email Routing settings - // identifier) - Tag string `json:"tag"` - JSON emailRoutingRoutingEnableNewResponseJSON `json:"-"` -} - -// emailRoutingRoutingEnableNewResponseJSON contains the JSON metadata for the -// struct [EmailRoutingRoutingEnableNewResponse] -type emailRoutingRoutingEnableNewResponseJSON struct { - ID apijson.Field - Created apijson.Field - Enabled apijson.Field - Modified apijson.Field - Name apijson.Field - SkipWizard apijson.Field - Status apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingEnableNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingEnableNewResponseJSON) RawJSON() string { - return r.raw -} - -// State of the zone settings for Email Routing. -type EmailRoutingRoutingEnableNewResponseEnabled bool - -const ( - EmailRoutingRoutingEnableNewResponseEnabledTrue EmailRoutingRoutingEnableNewResponseEnabled = true - EmailRoutingRoutingEnableNewResponseEnabledFalse EmailRoutingRoutingEnableNewResponseEnabled = false -) - -// Flag to check if the user skipped the configuration wizard. -type EmailRoutingRoutingEnableNewResponseSkipWizard bool - -const ( - EmailRoutingRoutingEnableNewResponseSkipWizardTrue EmailRoutingRoutingEnableNewResponseSkipWizard = true - EmailRoutingRoutingEnableNewResponseSkipWizardFalse EmailRoutingRoutingEnableNewResponseSkipWizard = false -) - -// Show the state of your account, and the type or configuration error. -type EmailRoutingRoutingEnableNewResponseStatus string - -const ( - EmailRoutingRoutingEnableNewResponseStatusReady EmailRoutingRoutingEnableNewResponseStatus = "ready" - EmailRoutingRoutingEnableNewResponseStatusUnconfigured EmailRoutingRoutingEnableNewResponseStatus = "unconfigured" - EmailRoutingRoutingEnableNewResponseStatusMisconfigured EmailRoutingRoutingEnableNewResponseStatus = "misconfigured" - EmailRoutingRoutingEnableNewResponseStatusMisconfiguredLocked EmailRoutingRoutingEnableNewResponseStatus = "misconfigured/locked" - EmailRoutingRoutingEnableNewResponseStatusUnlocked EmailRoutingRoutingEnableNewResponseStatus = "unlocked" -) - -type EmailRoutingRoutingEnableNewResponseEnvelope struct { - Errors []EmailRoutingRoutingEnableNewResponseEnvelopeErrors `json:"errors,required"` - Messages []EmailRoutingRoutingEnableNewResponseEnvelopeMessages `json:"messages,required"` - Result EmailRoutingRoutingEnableNewResponse `json:"result,required"` - // Whether the API call was successful - Success EmailRoutingRoutingEnableNewResponseEnvelopeSuccess `json:"success,required"` - JSON emailRoutingRoutingEnableNewResponseEnvelopeJSON `json:"-"` -} - -// emailRoutingRoutingEnableNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [EmailRoutingRoutingEnableNewResponseEnvelope] -type emailRoutingRoutingEnableNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingEnableNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingEnableNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingEnableNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingEnableNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// emailRoutingRoutingEnableNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingEnableNewResponseEnvelopeErrors] -type emailRoutingRoutingEnableNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingEnableNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingEnableNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingEnableNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingEnableNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// emailRoutingRoutingEnableNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingEnableNewResponseEnvelopeMessages] -type emailRoutingRoutingEnableNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingEnableNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingEnableNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type EmailRoutingRoutingEnableNewResponseEnvelopeSuccess bool - -const ( - EmailRoutingRoutingEnableNewResponseEnvelopeSuccessTrue EmailRoutingRoutingEnableNewResponseEnvelopeSuccess = true -) diff --git a/emailroutingroutingenable_test.go b/emailroutingroutingenable_test.go deleted file mode 100644 index 751332c1860..00000000000 --- a/emailroutingroutingenable_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestEmailRoutingRoutingEnableNew(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("user@example.com"), - ) - _, err := client.EmailRouting.Routing.Enables.New(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/emailroutingroutingrule.go b/emailroutingroutingrule.go deleted file mode 100644 index b5a73868966..00000000000 --- a/emailroutingroutingrule.go +++ /dev/null @@ -1,1235 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" -) - -// EmailRoutingRoutingRuleService 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 -// [NewEmailRoutingRoutingRuleService] method instead. -type EmailRoutingRoutingRuleService struct { - Options []option.RequestOption - CatchAlls *EmailRoutingRoutingRuleCatchAllService -} - -// NewEmailRoutingRoutingRuleService 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 NewEmailRoutingRoutingRuleService(opts ...option.RequestOption) (r *EmailRoutingRoutingRuleService) { - r = &EmailRoutingRoutingRuleService{} - r.Options = opts - r.CatchAlls = NewEmailRoutingRoutingRuleCatchAllService(opts...) - return -} - -// Rules consist of a set of criteria for matching emails (such as an email being -// sent to a specific custom email address) plus a set of actions to take on the -// email (like forwarding it to a specific destination address). -func (r *EmailRoutingRoutingRuleService) New(ctx context.Context, zoneIdentifier string, body EmailRoutingRoutingRuleNewParams, opts ...option.RequestOption) (res *EmailRoutingRoutingRuleNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env EmailRoutingRoutingRuleNewResponseEnvelope - path := fmt.Sprintf("zones/%s/email/routing/rules", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update actions and matches, or enable/disable specific routing rules. -func (r *EmailRoutingRoutingRuleService) Update(ctx context.Context, zoneIdentifier string, ruleIdentifier string, body EmailRoutingRoutingRuleUpdateParams, opts ...option.RequestOption) (res *EmailRoutingRoutingRuleUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env EmailRoutingRoutingRuleUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/email/routing/rules/%s", zoneIdentifier, ruleIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists existing routing rules. -func (r *EmailRoutingRoutingRuleService) List(ctx context.Context, zoneIdentifier string, query EmailRoutingRoutingRuleListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[EmailRoutingRoutingRuleListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("zones/%s/email/routing/rules", zoneIdentifier) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Lists existing routing rules. -func (r *EmailRoutingRoutingRuleService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query EmailRoutingRoutingRuleListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[EmailRoutingRoutingRuleListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) -} - -// Delete a specific routing rule. -func (r *EmailRoutingRoutingRuleService) Delete(ctx context.Context, zoneIdentifier string, ruleIdentifier string, opts ...option.RequestOption) (res *EmailRoutingRoutingRuleDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env EmailRoutingRoutingRuleDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/email/routing/rules/%s", zoneIdentifier, ruleIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get information for a specific routing rule already created. -func (r *EmailRoutingRoutingRuleService) Get(ctx context.Context, zoneIdentifier string, ruleIdentifier string, opts ...option.RequestOption) (res *EmailRoutingRoutingRuleGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env EmailRoutingRoutingRuleGetResponseEnvelope - path := fmt.Sprintf("zones/%s/email/routing/rules/%s", zoneIdentifier, ruleIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type EmailRoutingRoutingRuleNewResponse struct { - // Routing rule identifier. - ID string `json:"id"` - // List actions patterns. - Actions []EmailRoutingRoutingRuleNewResponseAction `json:"actions"` - // Routing rule status. - Enabled EmailRoutingRoutingRuleNewResponseEnabled `json:"enabled"` - // Matching patterns to forward to your actions. - Matchers []EmailRoutingRoutingRuleNewResponseMatcher `json:"matchers"` - // Routing rule name. - Name string `json:"name"` - // Priority of the routing rule. - Priority float64 `json:"priority"` - // Routing rule tag. (Deprecated, replaced by routing rule identifier) - Tag string `json:"tag"` - JSON emailRoutingRoutingRuleNewResponseJSON `json:"-"` -} - -// emailRoutingRoutingRuleNewResponseJSON contains the JSON metadata for the struct -// [EmailRoutingRoutingRuleNewResponse] -type emailRoutingRoutingRuleNewResponseJSON struct { - ID apijson.Field - Actions apijson.Field - Enabled apijson.Field - Matchers apijson.Field - Name apijson.Field - Priority apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleNewResponseJSON) RawJSON() string { - return r.raw -} - -// Actions pattern. -type EmailRoutingRoutingRuleNewResponseAction struct { - // Type of supported action. - Type EmailRoutingRoutingRuleNewResponseActionsType `json:"type,required"` - Value []string `json:"value,required"` - JSON emailRoutingRoutingRuleNewResponseActionJSON `json:"-"` -} - -// emailRoutingRoutingRuleNewResponseActionJSON contains the JSON metadata for the -// struct [EmailRoutingRoutingRuleNewResponseAction] -type emailRoutingRoutingRuleNewResponseActionJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleNewResponseAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleNewResponseActionJSON) RawJSON() string { - return r.raw -} - -// Type of supported action. -type EmailRoutingRoutingRuleNewResponseActionsType string - -const ( - EmailRoutingRoutingRuleNewResponseActionsTypeDrop EmailRoutingRoutingRuleNewResponseActionsType = "drop" - EmailRoutingRoutingRuleNewResponseActionsTypeForward EmailRoutingRoutingRuleNewResponseActionsType = "forward" - EmailRoutingRoutingRuleNewResponseActionsTypeWorker EmailRoutingRoutingRuleNewResponseActionsType = "worker" -) - -// Routing rule status. -type EmailRoutingRoutingRuleNewResponseEnabled bool - -const ( - EmailRoutingRoutingRuleNewResponseEnabledTrue EmailRoutingRoutingRuleNewResponseEnabled = true - EmailRoutingRoutingRuleNewResponseEnabledFalse EmailRoutingRoutingRuleNewResponseEnabled = false -) - -// Matching pattern to forward your actions. -type EmailRoutingRoutingRuleNewResponseMatcher struct { - // Field for type matcher. - Field EmailRoutingRoutingRuleNewResponseMatchersField `json:"field,required"` - // Type of matcher. - Type EmailRoutingRoutingRuleNewResponseMatchersType `json:"type,required"` - // Value for matcher. - Value string `json:"value,required"` - JSON emailRoutingRoutingRuleNewResponseMatcherJSON `json:"-"` -} - -// emailRoutingRoutingRuleNewResponseMatcherJSON contains the JSON metadata for the -// struct [EmailRoutingRoutingRuleNewResponseMatcher] -type emailRoutingRoutingRuleNewResponseMatcherJSON struct { - Field apijson.Field - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleNewResponseMatcher) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleNewResponseMatcherJSON) RawJSON() string { - return r.raw -} - -// Field for type matcher. -type EmailRoutingRoutingRuleNewResponseMatchersField string - -const ( - EmailRoutingRoutingRuleNewResponseMatchersFieldTo EmailRoutingRoutingRuleNewResponseMatchersField = "to" -) - -// Type of matcher. -type EmailRoutingRoutingRuleNewResponseMatchersType string - -const ( - EmailRoutingRoutingRuleNewResponseMatchersTypeLiteral EmailRoutingRoutingRuleNewResponseMatchersType = "literal" -) - -type EmailRoutingRoutingRuleUpdateResponse struct { - // Routing rule identifier. - ID string `json:"id"` - // List actions patterns. - Actions []EmailRoutingRoutingRuleUpdateResponseAction `json:"actions"` - // Routing rule status. - Enabled EmailRoutingRoutingRuleUpdateResponseEnabled `json:"enabled"` - // Matching patterns to forward to your actions. - Matchers []EmailRoutingRoutingRuleUpdateResponseMatcher `json:"matchers"` - // Routing rule name. - Name string `json:"name"` - // Priority of the routing rule. - Priority float64 `json:"priority"` - // Routing rule tag. (Deprecated, replaced by routing rule identifier) - Tag string `json:"tag"` - JSON emailRoutingRoutingRuleUpdateResponseJSON `json:"-"` -} - -// emailRoutingRoutingRuleUpdateResponseJSON contains the JSON metadata for the -// struct [EmailRoutingRoutingRuleUpdateResponse] -type emailRoutingRoutingRuleUpdateResponseJSON struct { - ID apijson.Field - Actions apijson.Field - Enabled apijson.Field - Matchers apijson.Field - Name apijson.Field - Priority apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// Actions pattern. -type EmailRoutingRoutingRuleUpdateResponseAction struct { - // Type of supported action. - Type EmailRoutingRoutingRuleUpdateResponseActionsType `json:"type,required"` - Value []string `json:"value,required"` - JSON emailRoutingRoutingRuleUpdateResponseActionJSON `json:"-"` -} - -// emailRoutingRoutingRuleUpdateResponseActionJSON contains the JSON metadata for -// the struct [EmailRoutingRoutingRuleUpdateResponseAction] -type emailRoutingRoutingRuleUpdateResponseActionJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleUpdateResponseAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleUpdateResponseActionJSON) RawJSON() string { - return r.raw -} - -// Type of supported action. -type EmailRoutingRoutingRuleUpdateResponseActionsType string - -const ( - EmailRoutingRoutingRuleUpdateResponseActionsTypeDrop EmailRoutingRoutingRuleUpdateResponseActionsType = "drop" - EmailRoutingRoutingRuleUpdateResponseActionsTypeForward EmailRoutingRoutingRuleUpdateResponseActionsType = "forward" - EmailRoutingRoutingRuleUpdateResponseActionsTypeWorker EmailRoutingRoutingRuleUpdateResponseActionsType = "worker" -) - -// Routing rule status. -type EmailRoutingRoutingRuleUpdateResponseEnabled bool - -const ( - EmailRoutingRoutingRuleUpdateResponseEnabledTrue EmailRoutingRoutingRuleUpdateResponseEnabled = true - EmailRoutingRoutingRuleUpdateResponseEnabledFalse EmailRoutingRoutingRuleUpdateResponseEnabled = false -) - -// Matching pattern to forward your actions. -type EmailRoutingRoutingRuleUpdateResponseMatcher struct { - // Field for type matcher. - Field EmailRoutingRoutingRuleUpdateResponseMatchersField `json:"field,required"` - // Type of matcher. - Type EmailRoutingRoutingRuleUpdateResponseMatchersType `json:"type,required"` - // Value for matcher. - Value string `json:"value,required"` - JSON emailRoutingRoutingRuleUpdateResponseMatcherJSON `json:"-"` -} - -// emailRoutingRoutingRuleUpdateResponseMatcherJSON contains the JSON metadata for -// the struct [EmailRoutingRoutingRuleUpdateResponseMatcher] -type emailRoutingRoutingRuleUpdateResponseMatcherJSON struct { - Field apijson.Field - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleUpdateResponseMatcher) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleUpdateResponseMatcherJSON) RawJSON() string { - return r.raw -} - -// Field for type matcher. -type EmailRoutingRoutingRuleUpdateResponseMatchersField string - -const ( - EmailRoutingRoutingRuleUpdateResponseMatchersFieldTo EmailRoutingRoutingRuleUpdateResponseMatchersField = "to" -) - -// Type of matcher. -type EmailRoutingRoutingRuleUpdateResponseMatchersType string - -const ( - EmailRoutingRoutingRuleUpdateResponseMatchersTypeLiteral EmailRoutingRoutingRuleUpdateResponseMatchersType = "literal" -) - -type EmailRoutingRoutingRuleListResponse struct { - // Routing rule identifier. - ID string `json:"id"` - // List actions patterns. - Actions []EmailRoutingRoutingRuleListResponseAction `json:"actions"` - // Routing rule status. - Enabled EmailRoutingRoutingRuleListResponseEnabled `json:"enabled"` - // Matching patterns to forward to your actions. - Matchers []EmailRoutingRoutingRuleListResponseMatcher `json:"matchers"` - // Routing rule name. - Name string `json:"name"` - // Priority of the routing rule. - Priority float64 `json:"priority"` - // Routing rule tag. (Deprecated, replaced by routing rule identifier) - Tag string `json:"tag"` - JSON emailRoutingRoutingRuleListResponseJSON `json:"-"` -} - -// emailRoutingRoutingRuleListResponseJSON contains the JSON metadata for the -// struct [EmailRoutingRoutingRuleListResponse] -type emailRoutingRoutingRuleListResponseJSON struct { - ID apijson.Field - Actions apijson.Field - Enabled apijson.Field - Matchers apijson.Field - Name apijson.Field - Priority apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleListResponseJSON) RawJSON() string { - return r.raw -} - -// Actions pattern. -type EmailRoutingRoutingRuleListResponseAction struct { - // Type of supported action. - Type EmailRoutingRoutingRuleListResponseActionsType `json:"type,required"` - Value []string `json:"value,required"` - JSON emailRoutingRoutingRuleListResponseActionJSON `json:"-"` -} - -// emailRoutingRoutingRuleListResponseActionJSON contains the JSON metadata for the -// struct [EmailRoutingRoutingRuleListResponseAction] -type emailRoutingRoutingRuleListResponseActionJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleListResponseAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleListResponseActionJSON) RawJSON() string { - return r.raw -} - -// Type of supported action. -type EmailRoutingRoutingRuleListResponseActionsType string - -const ( - EmailRoutingRoutingRuleListResponseActionsTypeDrop EmailRoutingRoutingRuleListResponseActionsType = "drop" - EmailRoutingRoutingRuleListResponseActionsTypeForward EmailRoutingRoutingRuleListResponseActionsType = "forward" - EmailRoutingRoutingRuleListResponseActionsTypeWorker EmailRoutingRoutingRuleListResponseActionsType = "worker" -) - -// Routing rule status. -type EmailRoutingRoutingRuleListResponseEnabled bool - -const ( - EmailRoutingRoutingRuleListResponseEnabledTrue EmailRoutingRoutingRuleListResponseEnabled = true - EmailRoutingRoutingRuleListResponseEnabledFalse EmailRoutingRoutingRuleListResponseEnabled = false -) - -// Matching pattern to forward your actions. -type EmailRoutingRoutingRuleListResponseMatcher struct { - // Field for type matcher. - Field EmailRoutingRoutingRuleListResponseMatchersField `json:"field,required"` - // Type of matcher. - Type EmailRoutingRoutingRuleListResponseMatchersType `json:"type,required"` - // Value for matcher. - Value string `json:"value,required"` - JSON emailRoutingRoutingRuleListResponseMatcherJSON `json:"-"` -} - -// emailRoutingRoutingRuleListResponseMatcherJSON contains the JSON metadata for -// the struct [EmailRoutingRoutingRuleListResponseMatcher] -type emailRoutingRoutingRuleListResponseMatcherJSON struct { - Field apijson.Field - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleListResponseMatcher) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleListResponseMatcherJSON) RawJSON() string { - return r.raw -} - -// Field for type matcher. -type EmailRoutingRoutingRuleListResponseMatchersField string - -const ( - EmailRoutingRoutingRuleListResponseMatchersFieldTo EmailRoutingRoutingRuleListResponseMatchersField = "to" -) - -// Type of matcher. -type EmailRoutingRoutingRuleListResponseMatchersType string - -const ( - EmailRoutingRoutingRuleListResponseMatchersTypeLiteral EmailRoutingRoutingRuleListResponseMatchersType = "literal" -) - -type EmailRoutingRoutingRuleDeleteResponse struct { - // Routing rule identifier. - ID string `json:"id"` - // List actions patterns. - Actions []EmailRoutingRoutingRuleDeleteResponseAction `json:"actions"` - // Routing rule status. - Enabled EmailRoutingRoutingRuleDeleteResponseEnabled `json:"enabled"` - // Matching patterns to forward to your actions. - Matchers []EmailRoutingRoutingRuleDeleteResponseMatcher `json:"matchers"` - // Routing rule name. - Name string `json:"name"` - // Priority of the routing rule. - Priority float64 `json:"priority"` - // Routing rule tag. (Deprecated, replaced by routing rule identifier) - Tag string `json:"tag"` - JSON emailRoutingRoutingRuleDeleteResponseJSON `json:"-"` -} - -// emailRoutingRoutingRuleDeleteResponseJSON contains the JSON metadata for the -// struct [EmailRoutingRoutingRuleDeleteResponse] -type emailRoutingRoutingRuleDeleteResponseJSON struct { - ID apijson.Field - Actions apijson.Field - Enabled apijson.Field - Matchers apijson.Field - Name apijson.Field - Priority apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// Actions pattern. -type EmailRoutingRoutingRuleDeleteResponseAction struct { - // Type of supported action. - Type EmailRoutingRoutingRuleDeleteResponseActionsType `json:"type,required"` - Value []string `json:"value,required"` - JSON emailRoutingRoutingRuleDeleteResponseActionJSON `json:"-"` -} - -// emailRoutingRoutingRuleDeleteResponseActionJSON contains the JSON metadata for -// the struct [EmailRoutingRoutingRuleDeleteResponseAction] -type emailRoutingRoutingRuleDeleteResponseActionJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleDeleteResponseAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleDeleteResponseActionJSON) RawJSON() string { - return r.raw -} - -// Type of supported action. -type EmailRoutingRoutingRuleDeleteResponseActionsType string - -const ( - EmailRoutingRoutingRuleDeleteResponseActionsTypeDrop EmailRoutingRoutingRuleDeleteResponseActionsType = "drop" - EmailRoutingRoutingRuleDeleteResponseActionsTypeForward EmailRoutingRoutingRuleDeleteResponseActionsType = "forward" - EmailRoutingRoutingRuleDeleteResponseActionsTypeWorker EmailRoutingRoutingRuleDeleteResponseActionsType = "worker" -) - -// Routing rule status. -type EmailRoutingRoutingRuleDeleteResponseEnabled bool - -const ( - EmailRoutingRoutingRuleDeleteResponseEnabledTrue EmailRoutingRoutingRuleDeleteResponseEnabled = true - EmailRoutingRoutingRuleDeleteResponseEnabledFalse EmailRoutingRoutingRuleDeleteResponseEnabled = false -) - -// Matching pattern to forward your actions. -type EmailRoutingRoutingRuleDeleteResponseMatcher struct { - // Field for type matcher. - Field EmailRoutingRoutingRuleDeleteResponseMatchersField `json:"field,required"` - // Type of matcher. - Type EmailRoutingRoutingRuleDeleteResponseMatchersType `json:"type,required"` - // Value for matcher. - Value string `json:"value,required"` - JSON emailRoutingRoutingRuleDeleteResponseMatcherJSON `json:"-"` -} - -// emailRoutingRoutingRuleDeleteResponseMatcherJSON contains the JSON metadata for -// the struct [EmailRoutingRoutingRuleDeleteResponseMatcher] -type emailRoutingRoutingRuleDeleteResponseMatcherJSON struct { - Field apijson.Field - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleDeleteResponseMatcher) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleDeleteResponseMatcherJSON) RawJSON() string { - return r.raw -} - -// Field for type matcher. -type EmailRoutingRoutingRuleDeleteResponseMatchersField string - -const ( - EmailRoutingRoutingRuleDeleteResponseMatchersFieldTo EmailRoutingRoutingRuleDeleteResponseMatchersField = "to" -) - -// Type of matcher. -type EmailRoutingRoutingRuleDeleteResponseMatchersType string - -const ( - EmailRoutingRoutingRuleDeleteResponseMatchersTypeLiteral EmailRoutingRoutingRuleDeleteResponseMatchersType = "literal" -) - -type EmailRoutingRoutingRuleGetResponse struct { - // Routing rule identifier. - ID string `json:"id"` - // List actions patterns. - Actions []EmailRoutingRoutingRuleGetResponseAction `json:"actions"` - // Routing rule status. - Enabled EmailRoutingRoutingRuleGetResponseEnabled `json:"enabled"` - // Matching patterns to forward to your actions. - Matchers []EmailRoutingRoutingRuleGetResponseMatcher `json:"matchers"` - // Routing rule name. - Name string `json:"name"` - // Priority of the routing rule. - Priority float64 `json:"priority"` - // Routing rule tag. (Deprecated, replaced by routing rule identifier) - Tag string `json:"tag"` - JSON emailRoutingRoutingRuleGetResponseJSON `json:"-"` -} - -// emailRoutingRoutingRuleGetResponseJSON contains the JSON metadata for the struct -// [EmailRoutingRoutingRuleGetResponse] -type emailRoutingRoutingRuleGetResponseJSON struct { - ID apijson.Field - Actions apijson.Field - Enabled apijson.Field - Matchers apijson.Field - Name apijson.Field - Priority apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleGetResponseJSON) RawJSON() string { - return r.raw -} - -// Actions pattern. -type EmailRoutingRoutingRuleGetResponseAction struct { - // Type of supported action. - Type EmailRoutingRoutingRuleGetResponseActionsType `json:"type,required"` - Value []string `json:"value,required"` - JSON emailRoutingRoutingRuleGetResponseActionJSON `json:"-"` -} - -// emailRoutingRoutingRuleGetResponseActionJSON contains the JSON metadata for the -// struct [EmailRoutingRoutingRuleGetResponseAction] -type emailRoutingRoutingRuleGetResponseActionJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleGetResponseAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleGetResponseActionJSON) RawJSON() string { - return r.raw -} - -// Type of supported action. -type EmailRoutingRoutingRuleGetResponseActionsType string - -const ( - EmailRoutingRoutingRuleGetResponseActionsTypeDrop EmailRoutingRoutingRuleGetResponseActionsType = "drop" - EmailRoutingRoutingRuleGetResponseActionsTypeForward EmailRoutingRoutingRuleGetResponseActionsType = "forward" - EmailRoutingRoutingRuleGetResponseActionsTypeWorker EmailRoutingRoutingRuleGetResponseActionsType = "worker" -) - -// Routing rule status. -type EmailRoutingRoutingRuleGetResponseEnabled bool - -const ( - EmailRoutingRoutingRuleGetResponseEnabledTrue EmailRoutingRoutingRuleGetResponseEnabled = true - EmailRoutingRoutingRuleGetResponseEnabledFalse EmailRoutingRoutingRuleGetResponseEnabled = false -) - -// Matching pattern to forward your actions. -type EmailRoutingRoutingRuleGetResponseMatcher struct { - // Field for type matcher. - Field EmailRoutingRoutingRuleGetResponseMatchersField `json:"field,required"` - // Type of matcher. - Type EmailRoutingRoutingRuleGetResponseMatchersType `json:"type,required"` - // Value for matcher. - Value string `json:"value,required"` - JSON emailRoutingRoutingRuleGetResponseMatcherJSON `json:"-"` -} - -// emailRoutingRoutingRuleGetResponseMatcherJSON contains the JSON metadata for the -// struct [EmailRoutingRoutingRuleGetResponseMatcher] -type emailRoutingRoutingRuleGetResponseMatcherJSON struct { - Field apijson.Field - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleGetResponseMatcher) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleGetResponseMatcherJSON) RawJSON() string { - return r.raw -} - -// Field for type matcher. -type EmailRoutingRoutingRuleGetResponseMatchersField string - -const ( - EmailRoutingRoutingRuleGetResponseMatchersFieldTo EmailRoutingRoutingRuleGetResponseMatchersField = "to" -) - -// Type of matcher. -type EmailRoutingRoutingRuleGetResponseMatchersType string - -const ( - EmailRoutingRoutingRuleGetResponseMatchersTypeLiteral EmailRoutingRoutingRuleGetResponseMatchersType = "literal" -) - -type EmailRoutingRoutingRuleNewParams struct { - // List actions patterns. - Actions param.Field[[]EmailRoutingRoutingRuleNewParamsAction] `json:"actions,required"` - // Matching patterns to forward to your actions. - Matchers param.Field[[]EmailRoutingRoutingRuleNewParamsMatcher] `json:"matchers,required"` - // Routing rule status. - Enabled param.Field[EmailRoutingRoutingRuleNewParamsEnabled] `json:"enabled"` - // Routing rule name. - Name param.Field[string] `json:"name"` - // Priority of the routing rule. - Priority param.Field[float64] `json:"priority"` -} - -func (r EmailRoutingRoutingRuleNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Actions pattern. -type EmailRoutingRoutingRuleNewParamsAction struct { - // Type of supported action. - Type param.Field[EmailRoutingRoutingRuleNewParamsActionsType] `json:"type,required"` - Value param.Field[[]string] `json:"value,required"` -} - -func (r EmailRoutingRoutingRuleNewParamsAction) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Type of supported action. -type EmailRoutingRoutingRuleNewParamsActionsType string - -const ( - EmailRoutingRoutingRuleNewParamsActionsTypeDrop EmailRoutingRoutingRuleNewParamsActionsType = "drop" - EmailRoutingRoutingRuleNewParamsActionsTypeForward EmailRoutingRoutingRuleNewParamsActionsType = "forward" - EmailRoutingRoutingRuleNewParamsActionsTypeWorker EmailRoutingRoutingRuleNewParamsActionsType = "worker" -) - -// Matching pattern to forward your actions. -type EmailRoutingRoutingRuleNewParamsMatcher struct { - // Field for type matcher. - Field param.Field[EmailRoutingRoutingRuleNewParamsMatchersField] `json:"field,required"` - // Type of matcher. - Type param.Field[EmailRoutingRoutingRuleNewParamsMatchersType] `json:"type,required"` - // Value for matcher. - Value param.Field[string] `json:"value,required"` -} - -func (r EmailRoutingRoutingRuleNewParamsMatcher) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Field for type matcher. -type EmailRoutingRoutingRuleNewParamsMatchersField string - -const ( - EmailRoutingRoutingRuleNewParamsMatchersFieldTo EmailRoutingRoutingRuleNewParamsMatchersField = "to" -) - -// Type of matcher. -type EmailRoutingRoutingRuleNewParamsMatchersType string - -const ( - EmailRoutingRoutingRuleNewParamsMatchersTypeLiteral EmailRoutingRoutingRuleNewParamsMatchersType = "literal" -) - -// Routing rule status. -type EmailRoutingRoutingRuleNewParamsEnabled bool - -const ( - EmailRoutingRoutingRuleNewParamsEnabledTrue EmailRoutingRoutingRuleNewParamsEnabled = true - EmailRoutingRoutingRuleNewParamsEnabledFalse EmailRoutingRoutingRuleNewParamsEnabled = false -) - -type EmailRoutingRoutingRuleNewResponseEnvelope struct { - Errors []EmailRoutingRoutingRuleNewResponseEnvelopeErrors `json:"errors,required"` - Messages []EmailRoutingRoutingRuleNewResponseEnvelopeMessages `json:"messages,required"` - Result EmailRoutingRoutingRuleNewResponse `json:"result,required"` - // Whether the API call was successful - Success EmailRoutingRoutingRuleNewResponseEnvelopeSuccess `json:"success,required"` - JSON emailRoutingRoutingRuleNewResponseEnvelopeJSON `json:"-"` -} - -// emailRoutingRoutingRuleNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [EmailRoutingRoutingRuleNewResponseEnvelope] -type emailRoutingRoutingRuleNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingRuleNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingRuleNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// emailRoutingRoutingRuleNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [EmailRoutingRoutingRuleNewResponseEnvelopeErrors] -type emailRoutingRoutingRuleNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingRuleNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingRuleNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// emailRoutingRoutingRuleNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingRuleNewResponseEnvelopeMessages] -type emailRoutingRoutingRuleNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type EmailRoutingRoutingRuleNewResponseEnvelopeSuccess bool - -const ( - EmailRoutingRoutingRuleNewResponseEnvelopeSuccessTrue EmailRoutingRoutingRuleNewResponseEnvelopeSuccess = true -) - -type EmailRoutingRoutingRuleUpdateParams struct { - // List actions patterns. - Actions param.Field[[]EmailRoutingRoutingRuleUpdateParamsAction] `json:"actions,required"` - // Matching patterns to forward to your actions. - Matchers param.Field[[]EmailRoutingRoutingRuleUpdateParamsMatcher] `json:"matchers,required"` - // Routing rule status. - Enabled param.Field[EmailRoutingRoutingRuleUpdateParamsEnabled] `json:"enabled"` - // Routing rule name. - Name param.Field[string] `json:"name"` - // Priority of the routing rule. - Priority param.Field[float64] `json:"priority"` -} - -func (r EmailRoutingRoutingRuleUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Actions pattern. -type EmailRoutingRoutingRuleUpdateParamsAction struct { - // Type of supported action. - Type param.Field[EmailRoutingRoutingRuleUpdateParamsActionsType] `json:"type,required"` - Value param.Field[[]string] `json:"value,required"` -} - -func (r EmailRoutingRoutingRuleUpdateParamsAction) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Type of supported action. -type EmailRoutingRoutingRuleUpdateParamsActionsType string - -const ( - EmailRoutingRoutingRuleUpdateParamsActionsTypeDrop EmailRoutingRoutingRuleUpdateParamsActionsType = "drop" - EmailRoutingRoutingRuleUpdateParamsActionsTypeForward EmailRoutingRoutingRuleUpdateParamsActionsType = "forward" - EmailRoutingRoutingRuleUpdateParamsActionsTypeWorker EmailRoutingRoutingRuleUpdateParamsActionsType = "worker" -) - -// Matching pattern to forward your actions. -type EmailRoutingRoutingRuleUpdateParamsMatcher struct { - // Field for type matcher. - Field param.Field[EmailRoutingRoutingRuleUpdateParamsMatchersField] `json:"field,required"` - // Type of matcher. - Type param.Field[EmailRoutingRoutingRuleUpdateParamsMatchersType] `json:"type,required"` - // Value for matcher. - Value param.Field[string] `json:"value,required"` -} - -func (r EmailRoutingRoutingRuleUpdateParamsMatcher) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Field for type matcher. -type EmailRoutingRoutingRuleUpdateParamsMatchersField string - -const ( - EmailRoutingRoutingRuleUpdateParamsMatchersFieldTo EmailRoutingRoutingRuleUpdateParamsMatchersField = "to" -) - -// Type of matcher. -type EmailRoutingRoutingRuleUpdateParamsMatchersType string - -const ( - EmailRoutingRoutingRuleUpdateParamsMatchersTypeLiteral EmailRoutingRoutingRuleUpdateParamsMatchersType = "literal" -) - -// Routing rule status. -type EmailRoutingRoutingRuleUpdateParamsEnabled bool - -const ( - EmailRoutingRoutingRuleUpdateParamsEnabledTrue EmailRoutingRoutingRuleUpdateParamsEnabled = true - EmailRoutingRoutingRuleUpdateParamsEnabledFalse EmailRoutingRoutingRuleUpdateParamsEnabled = false -) - -type EmailRoutingRoutingRuleUpdateResponseEnvelope struct { - Errors []EmailRoutingRoutingRuleUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []EmailRoutingRoutingRuleUpdateResponseEnvelopeMessages `json:"messages,required"` - Result EmailRoutingRoutingRuleUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success EmailRoutingRoutingRuleUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON emailRoutingRoutingRuleUpdateResponseEnvelopeJSON `json:"-"` -} - -// emailRoutingRoutingRuleUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [EmailRoutingRoutingRuleUpdateResponseEnvelope] -type emailRoutingRoutingRuleUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingRuleUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingRuleUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// emailRoutingRoutingRuleUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingRuleUpdateResponseEnvelopeErrors] -type emailRoutingRoutingRuleUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingRuleUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingRuleUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// emailRoutingRoutingRuleUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingRuleUpdateResponseEnvelopeMessages] -type emailRoutingRoutingRuleUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type EmailRoutingRoutingRuleUpdateResponseEnvelopeSuccess bool - -const ( - EmailRoutingRoutingRuleUpdateResponseEnvelopeSuccessTrue EmailRoutingRoutingRuleUpdateResponseEnvelopeSuccess = true -) - -type EmailRoutingRoutingRuleListParams struct { - // Filter by enabled routing rules. - Enabled param.Field[EmailRoutingRoutingRuleListParamsEnabled] `query:"enabled"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // Maximum number of results per page. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [EmailRoutingRoutingRuleListParams]'s query parameters as -// `url.Values`. -func (r EmailRoutingRoutingRuleListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Filter by enabled routing rules. -type EmailRoutingRoutingRuleListParamsEnabled bool - -const ( - EmailRoutingRoutingRuleListParamsEnabledTrue EmailRoutingRoutingRuleListParamsEnabled = true - EmailRoutingRoutingRuleListParamsEnabledFalse EmailRoutingRoutingRuleListParamsEnabled = false -) - -type EmailRoutingRoutingRuleDeleteResponseEnvelope struct { - Errors []EmailRoutingRoutingRuleDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []EmailRoutingRoutingRuleDeleteResponseEnvelopeMessages `json:"messages,required"` - Result EmailRoutingRoutingRuleDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success EmailRoutingRoutingRuleDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON emailRoutingRoutingRuleDeleteResponseEnvelopeJSON `json:"-"` -} - -// emailRoutingRoutingRuleDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [EmailRoutingRoutingRuleDeleteResponseEnvelope] -type emailRoutingRoutingRuleDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingRuleDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingRuleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// emailRoutingRoutingRuleDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingRuleDeleteResponseEnvelopeErrors] -type emailRoutingRoutingRuleDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingRuleDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingRuleDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// emailRoutingRoutingRuleDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingRuleDeleteResponseEnvelopeMessages] -type emailRoutingRoutingRuleDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type EmailRoutingRoutingRuleDeleteResponseEnvelopeSuccess bool - -const ( - EmailRoutingRoutingRuleDeleteResponseEnvelopeSuccessTrue EmailRoutingRoutingRuleDeleteResponseEnvelopeSuccess = true -) - -type EmailRoutingRoutingRuleGetResponseEnvelope struct { - Errors []EmailRoutingRoutingRuleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []EmailRoutingRoutingRuleGetResponseEnvelopeMessages `json:"messages,required"` - Result EmailRoutingRoutingRuleGetResponse `json:"result,required"` - // Whether the API call was successful - Success EmailRoutingRoutingRuleGetResponseEnvelopeSuccess `json:"success,required"` - JSON emailRoutingRoutingRuleGetResponseEnvelopeJSON `json:"-"` -} - -// emailRoutingRoutingRuleGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [EmailRoutingRoutingRuleGetResponseEnvelope] -type emailRoutingRoutingRuleGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingRuleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingRuleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// emailRoutingRoutingRuleGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [EmailRoutingRoutingRuleGetResponseEnvelopeErrors] -type emailRoutingRoutingRuleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingRuleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingRuleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// emailRoutingRoutingRuleGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingRuleGetResponseEnvelopeMessages] -type emailRoutingRoutingRuleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type EmailRoutingRoutingRuleGetResponseEnvelopeSuccess bool - -const ( - EmailRoutingRoutingRuleGetResponseEnvelopeSuccessTrue EmailRoutingRoutingRuleGetResponseEnvelopeSuccess = true -) diff --git a/emailroutingroutingrule_test.go b/emailroutingroutingrule_test.go deleted file mode 100644 index b091530ba9c..00000000000 --- a/emailroutingroutingrule_test.go +++ /dev/null @@ -1,213 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestEmailRoutingRoutingRuleNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.EmailRouting.Routing.Rules.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.EmailRoutingRoutingRuleNewParams{ - Actions: cloudflare.F([]cloudflare.EmailRoutingRoutingRuleNewParamsAction{{ - Type: cloudflare.F(cloudflare.EmailRoutingRoutingRuleNewParamsActionsTypeForward), - Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), - }, { - Type: cloudflare.F(cloudflare.EmailRoutingRoutingRuleNewParamsActionsTypeForward), - Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), - }, { - Type: cloudflare.F(cloudflare.EmailRoutingRoutingRuleNewParamsActionsTypeForward), - Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), - }}), - Matchers: cloudflare.F([]cloudflare.EmailRoutingRoutingRuleNewParamsMatcher{{ - Field: cloudflare.F(cloudflare.EmailRoutingRoutingRuleNewParamsMatchersFieldTo), - Type: cloudflare.F(cloudflare.EmailRoutingRoutingRuleNewParamsMatchersTypeLiteral), - Value: cloudflare.F("test@example.com"), - }, { - Field: cloudflare.F(cloudflare.EmailRoutingRoutingRuleNewParamsMatchersFieldTo), - Type: cloudflare.F(cloudflare.EmailRoutingRoutingRuleNewParamsMatchersTypeLiteral), - Value: cloudflare.F("test@example.com"), - }, { - Field: cloudflare.F(cloudflare.EmailRoutingRoutingRuleNewParamsMatchersFieldTo), - Type: cloudflare.F(cloudflare.EmailRoutingRoutingRuleNewParamsMatchersTypeLiteral), - Value: cloudflare.F("test@example.com"), - }}), - Enabled: cloudflare.F(cloudflare.EmailRoutingRoutingRuleNewParamsEnabledTrue), - Name: cloudflare.F("Send to user@example.net rule."), - Priority: cloudflare.F(0.000000), - }, - ) - 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 TestEmailRoutingRoutingRuleUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.EmailRouting.Routing.Rules.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "a7e6fb77503c41d8a7f3113c6918f10c", - cloudflare.EmailRoutingRoutingRuleUpdateParams{ - Actions: cloudflare.F([]cloudflare.EmailRoutingRoutingRuleUpdateParamsAction{{ - Type: cloudflare.F(cloudflare.EmailRoutingRoutingRuleUpdateParamsActionsTypeForward), - Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), - }, { - Type: cloudflare.F(cloudflare.EmailRoutingRoutingRuleUpdateParamsActionsTypeForward), - Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), - }, { - Type: cloudflare.F(cloudflare.EmailRoutingRoutingRuleUpdateParamsActionsTypeForward), - Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), - }}), - Matchers: cloudflare.F([]cloudflare.EmailRoutingRoutingRuleUpdateParamsMatcher{{ - Field: cloudflare.F(cloudflare.EmailRoutingRoutingRuleUpdateParamsMatchersFieldTo), - Type: cloudflare.F(cloudflare.EmailRoutingRoutingRuleUpdateParamsMatchersTypeLiteral), - Value: cloudflare.F("test@example.com"), - }, { - Field: cloudflare.F(cloudflare.EmailRoutingRoutingRuleUpdateParamsMatchersFieldTo), - Type: cloudflare.F(cloudflare.EmailRoutingRoutingRuleUpdateParamsMatchersTypeLiteral), - Value: cloudflare.F("test@example.com"), - }, { - Field: cloudflare.F(cloudflare.EmailRoutingRoutingRuleUpdateParamsMatchersFieldTo), - Type: cloudflare.F(cloudflare.EmailRoutingRoutingRuleUpdateParamsMatchersTypeLiteral), - Value: cloudflare.F("test@example.com"), - }}), - Enabled: cloudflare.F(cloudflare.EmailRoutingRoutingRuleUpdateParamsEnabledTrue), - Name: cloudflare.F("Send to user@example.net rule."), - Priority: cloudflare.F(0.000000), - }, - ) - 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 TestEmailRoutingRoutingRuleListWithOptionalParams(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("user@example.com"), - ) - _, err := client.EmailRouting.Routing.Rules.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.EmailRoutingRoutingRuleListParams{ - Enabled: cloudflare.F(cloudflare.EmailRoutingRoutingRuleListParamsEnabledTrue), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(5.000000), - }, - ) - 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 TestEmailRoutingRoutingRuleDelete(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("user@example.com"), - ) - _, err := client.EmailRouting.Routing.Rules.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "a7e6fb77503c41d8a7f3113c6918f10c", - ) - 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 TestEmailRoutingRoutingRuleGet(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("user@example.com"), - ) - _, err := client.EmailRouting.Routing.Rules.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "a7e6fb77503c41d8a7f3113c6918f10c", - ) - 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/emailroutingroutingrulecatchall.go b/emailroutingroutingrulecatchall.go deleted file mode 100644 index 39315f4e584..00000000000 --- a/emailroutingroutingrulecatchall.go +++ /dev/null @@ -1,503 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// EmailRoutingRoutingRuleCatchAllService 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 -// [NewEmailRoutingRoutingRuleCatchAllService] method instead. -type EmailRoutingRoutingRuleCatchAllService struct { - Options []option.RequestOption -} - -// NewEmailRoutingRoutingRuleCatchAllService 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 NewEmailRoutingRoutingRuleCatchAllService(opts ...option.RequestOption) (r *EmailRoutingRoutingRuleCatchAllService) { - r = &EmailRoutingRoutingRuleCatchAllService{} - r.Options = opts - return -} - -// Enable or disable catch-all routing rule, or change action to forward to -// specific destination address. -func (r *EmailRoutingRoutingRuleCatchAllService) Update(ctx context.Context, zoneIdentifier string, body EmailRoutingRoutingRuleCatchAllUpdateParams, opts ...option.RequestOption) (res *EmailRoutingRoutingRuleCatchAllUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env EmailRoutingRoutingRuleCatchAllUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/email/routing/rules/catch_all", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get information on the default catch-all routing rule. -func (r *EmailRoutingRoutingRuleCatchAllService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *EmailRoutingRoutingRuleCatchAllGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env EmailRoutingRoutingRuleCatchAllGetResponseEnvelope - path := fmt.Sprintf("zones/%s/email/routing/rules/catch_all", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type EmailRoutingRoutingRuleCatchAllUpdateResponse struct { - // Routing rule identifier. - ID string `json:"id"` - // List actions for the catch-all routing rule. - Actions []EmailRoutingRoutingRuleCatchAllUpdateResponseAction `json:"actions"` - // Routing rule status. - Enabled EmailRoutingRoutingRuleCatchAllUpdateResponseEnabled `json:"enabled"` - // List of matchers for the catch-all routing rule. - Matchers []EmailRoutingRoutingRuleCatchAllUpdateResponseMatcher `json:"matchers"` - // Routing rule name. - Name string `json:"name"` - // Routing rule tag. (Deprecated, replaced by routing rule identifier) - Tag string `json:"tag"` - JSON emailRoutingRoutingRuleCatchAllUpdateResponseJSON `json:"-"` -} - -// emailRoutingRoutingRuleCatchAllUpdateResponseJSON contains the JSON metadata for -// the struct [EmailRoutingRoutingRuleCatchAllUpdateResponse] -type emailRoutingRoutingRuleCatchAllUpdateResponseJSON struct { - ID apijson.Field - Actions apijson.Field - Enabled apijson.Field - Matchers apijson.Field - Name apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleCatchAllUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleCatchAllUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// Action for the catch-all routing rule. -type EmailRoutingRoutingRuleCatchAllUpdateResponseAction struct { - // Type of action for catch-all rule. - Type EmailRoutingRoutingRuleCatchAllUpdateResponseActionsType `json:"type,required"` - Value []string `json:"value"` - JSON emailRoutingRoutingRuleCatchAllUpdateResponseActionJSON `json:"-"` -} - -// emailRoutingRoutingRuleCatchAllUpdateResponseActionJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingRuleCatchAllUpdateResponseAction] -type emailRoutingRoutingRuleCatchAllUpdateResponseActionJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleCatchAllUpdateResponseAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleCatchAllUpdateResponseActionJSON) RawJSON() string { - return r.raw -} - -// Type of action for catch-all rule. -type EmailRoutingRoutingRuleCatchAllUpdateResponseActionsType string - -const ( - EmailRoutingRoutingRuleCatchAllUpdateResponseActionsTypeDrop EmailRoutingRoutingRuleCatchAllUpdateResponseActionsType = "drop" - EmailRoutingRoutingRuleCatchAllUpdateResponseActionsTypeForward EmailRoutingRoutingRuleCatchAllUpdateResponseActionsType = "forward" - EmailRoutingRoutingRuleCatchAllUpdateResponseActionsTypeWorker EmailRoutingRoutingRuleCatchAllUpdateResponseActionsType = "worker" -) - -// Routing rule status. -type EmailRoutingRoutingRuleCatchAllUpdateResponseEnabled bool - -const ( - EmailRoutingRoutingRuleCatchAllUpdateResponseEnabledTrue EmailRoutingRoutingRuleCatchAllUpdateResponseEnabled = true - EmailRoutingRoutingRuleCatchAllUpdateResponseEnabledFalse EmailRoutingRoutingRuleCatchAllUpdateResponseEnabled = false -) - -// Matcher for catch-all routing rule. -type EmailRoutingRoutingRuleCatchAllUpdateResponseMatcher struct { - // Type of matcher. Default is 'all'. - Type EmailRoutingRoutingRuleCatchAllUpdateResponseMatchersType `json:"type,required"` - JSON emailRoutingRoutingRuleCatchAllUpdateResponseMatcherJSON `json:"-"` -} - -// emailRoutingRoutingRuleCatchAllUpdateResponseMatcherJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingRuleCatchAllUpdateResponseMatcher] -type emailRoutingRoutingRuleCatchAllUpdateResponseMatcherJSON struct { - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleCatchAllUpdateResponseMatcher) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleCatchAllUpdateResponseMatcherJSON) RawJSON() string { - return r.raw -} - -// Type of matcher. Default is 'all'. -type EmailRoutingRoutingRuleCatchAllUpdateResponseMatchersType string - -const ( - EmailRoutingRoutingRuleCatchAllUpdateResponseMatchersTypeAll EmailRoutingRoutingRuleCatchAllUpdateResponseMatchersType = "all" -) - -type EmailRoutingRoutingRuleCatchAllGetResponse struct { - // Routing rule identifier. - ID string `json:"id"` - // List actions for the catch-all routing rule. - Actions []EmailRoutingRoutingRuleCatchAllGetResponseAction `json:"actions"` - // Routing rule status. - Enabled EmailRoutingRoutingRuleCatchAllGetResponseEnabled `json:"enabled"` - // List of matchers for the catch-all routing rule. - Matchers []EmailRoutingRoutingRuleCatchAllGetResponseMatcher `json:"matchers"` - // Routing rule name. - Name string `json:"name"` - // Routing rule tag. (Deprecated, replaced by routing rule identifier) - Tag string `json:"tag"` - JSON emailRoutingRoutingRuleCatchAllGetResponseJSON `json:"-"` -} - -// emailRoutingRoutingRuleCatchAllGetResponseJSON contains the JSON metadata for -// the struct [EmailRoutingRoutingRuleCatchAllGetResponse] -type emailRoutingRoutingRuleCatchAllGetResponseJSON struct { - ID apijson.Field - Actions apijson.Field - Enabled apijson.Field - Matchers apijson.Field - Name apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleCatchAllGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleCatchAllGetResponseJSON) RawJSON() string { - return r.raw -} - -// Action for the catch-all routing rule. -type EmailRoutingRoutingRuleCatchAllGetResponseAction struct { - // Type of action for catch-all rule. - Type EmailRoutingRoutingRuleCatchAllGetResponseActionsType `json:"type,required"` - Value []string `json:"value"` - JSON emailRoutingRoutingRuleCatchAllGetResponseActionJSON `json:"-"` -} - -// emailRoutingRoutingRuleCatchAllGetResponseActionJSON contains the JSON metadata -// for the struct [EmailRoutingRoutingRuleCatchAllGetResponseAction] -type emailRoutingRoutingRuleCatchAllGetResponseActionJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleCatchAllGetResponseAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleCatchAllGetResponseActionJSON) RawJSON() string { - return r.raw -} - -// Type of action for catch-all rule. -type EmailRoutingRoutingRuleCatchAllGetResponseActionsType string - -const ( - EmailRoutingRoutingRuleCatchAllGetResponseActionsTypeDrop EmailRoutingRoutingRuleCatchAllGetResponseActionsType = "drop" - EmailRoutingRoutingRuleCatchAllGetResponseActionsTypeForward EmailRoutingRoutingRuleCatchAllGetResponseActionsType = "forward" - EmailRoutingRoutingRuleCatchAllGetResponseActionsTypeWorker EmailRoutingRoutingRuleCatchAllGetResponseActionsType = "worker" -) - -// Routing rule status. -type EmailRoutingRoutingRuleCatchAllGetResponseEnabled bool - -const ( - EmailRoutingRoutingRuleCatchAllGetResponseEnabledTrue EmailRoutingRoutingRuleCatchAllGetResponseEnabled = true - EmailRoutingRoutingRuleCatchAllGetResponseEnabledFalse EmailRoutingRoutingRuleCatchAllGetResponseEnabled = false -) - -// Matcher for catch-all routing rule. -type EmailRoutingRoutingRuleCatchAllGetResponseMatcher struct { - // Type of matcher. Default is 'all'. - Type EmailRoutingRoutingRuleCatchAllGetResponseMatchersType `json:"type,required"` - JSON emailRoutingRoutingRuleCatchAllGetResponseMatcherJSON `json:"-"` -} - -// emailRoutingRoutingRuleCatchAllGetResponseMatcherJSON contains the JSON metadata -// for the struct [EmailRoutingRoutingRuleCatchAllGetResponseMatcher] -type emailRoutingRoutingRuleCatchAllGetResponseMatcherJSON struct { - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleCatchAllGetResponseMatcher) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleCatchAllGetResponseMatcherJSON) RawJSON() string { - return r.raw -} - -// Type of matcher. Default is 'all'. -type EmailRoutingRoutingRuleCatchAllGetResponseMatchersType string - -const ( - EmailRoutingRoutingRuleCatchAllGetResponseMatchersTypeAll EmailRoutingRoutingRuleCatchAllGetResponseMatchersType = "all" -) - -type EmailRoutingRoutingRuleCatchAllUpdateParams struct { - // List actions for the catch-all routing rule. - Actions param.Field[[]EmailRoutingRoutingRuleCatchAllUpdateParamsAction] `json:"actions,required"` - // List of matchers for the catch-all routing rule. - Matchers param.Field[[]EmailRoutingRoutingRuleCatchAllUpdateParamsMatcher] `json:"matchers,required"` - // Routing rule status. - Enabled param.Field[EmailRoutingRoutingRuleCatchAllUpdateParamsEnabled] `json:"enabled"` - // Routing rule name. - Name param.Field[string] `json:"name"` -} - -func (r EmailRoutingRoutingRuleCatchAllUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Action for the catch-all routing rule. -type EmailRoutingRoutingRuleCatchAllUpdateParamsAction struct { - // Type of action for catch-all rule. - Type param.Field[EmailRoutingRoutingRuleCatchAllUpdateParamsActionsType] `json:"type,required"` - Value param.Field[[]string] `json:"value"` -} - -func (r EmailRoutingRoutingRuleCatchAllUpdateParamsAction) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Type of action for catch-all rule. -type EmailRoutingRoutingRuleCatchAllUpdateParamsActionsType string - -const ( - EmailRoutingRoutingRuleCatchAllUpdateParamsActionsTypeDrop EmailRoutingRoutingRuleCatchAllUpdateParamsActionsType = "drop" - EmailRoutingRoutingRuleCatchAllUpdateParamsActionsTypeForward EmailRoutingRoutingRuleCatchAllUpdateParamsActionsType = "forward" - EmailRoutingRoutingRuleCatchAllUpdateParamsActionsTypeWorker EmailRoutingRoutingRuleCatchAllUpdateParamsActionsType = "worker" -) - -// Matcher for catch-all routing rule. -type EmailRoutingRoutingRuleCatchAllUpdateParamsMatcher struct { - // Type of matcher. Default is 'all'. - Type param.Field[EmailRoutingRoutingRuleCatchAllUpdateParamsMatchersType] `json:"type,required"` -} - -func (r EmailRoutingRoutingRuleCatchAllUpdateParamsMatcher) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Type of matcher. Default is 'all'. -type EmailRoutingRoutingRuleCatchAllUpdateParamsMatchersType string - -const ( - EmailRoutingRoutingRuleCatchAllUpdateParamsMatchersTypeAll EmailRoutingRoutingRuleCatchAllUpdateParamsMatchersType = "all" -) - -// Routing rule status. -type EmailRoutingRoutingRuleCatchAllUpdateParamsEnabled bool - -const ( - EmailRoutingRoutingRuleCatchAllUpdateParamsEnabledTrue EmailRoutingRoutingRuleCatchAllUpdateParamsEnabled = true - EmailRoutingRoutingRuleCatchAllUpdateParamsEnabledFalse EmailRoutingRoutingRuleCatchAllUpdateParamsEnabled = false -) - -type EmailRoutingRoutingRuleCatchAllUpdateResponseEnvelope struct { - Errors []EmailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []EmailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeMessages `json:"messages,required"` - Result EmailRoutingRoutingRuleCatchAllUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success EmailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON emailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeJSON `json:"-"` -} - -// emailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingRuleCatchAllUpdateResponseEnvelope] -type emailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleCatchAllUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// emailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [EmailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeErrors] -type emailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// emailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [EmailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeMessages] -type emailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type EmailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeSuccess bool - -const ( - EmailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeSuccessTrue EmailRoutingRoutingRuleCatchAllUpdateResponseEnvelopeSuccess = true -) - -type EmailRoutingRoutingRuleCatchAllGetResponseEnvelope struct { - Errors []EmailRoutingRoutingRuleCatchAllGetResponseEnvelopeErrors `json:"errors,required"` - Messages []EmailRoutingRoutingRuleCatchAllGetResponseEnvelopeMessages `json:"messages,required"` - Result EmailRoutingRoutingRuleCatchAllGetResponse `json:"result,required"` - // Whether the API call was successful - Success EmailRoutingRoutingRuleCatchAllGetResponseEnvelopeSuccess `json:"success,required"` - JSON emailRoutingRoutingRuleCatchAllGetResponseEnvelopeJSON `json:"-"` -} - -// emailRoutingRoutingRuleCatchAllGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [EmailRoutingRoutingRuleCatchAllGetResponseEnvelope] -type emailRoutingRoutingRuleCatchAllGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleCatchAllGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleCatchAllGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingRuleCatchAllGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingRuleCatchAllGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// emailRoutingRoutingRuleCatchAllGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [EmailRoutingRoutingRuleCatchAllGetResponseEnvelopeErrors] -type emailRoutingRoutingRuleCatchAllGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleCatchAllGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleCatchAllGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type EmailRoutingRoutingRuleCatchAllGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON emailRoutingRoutingRuleCatchAllGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// emailRoutingRoutingRuleCatchAllGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [EmailRoutingRoutingRuleCatchAllGetResponseEnvelopeMessages] -type emailRoutingRoutingRuleCatchAllGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingRoutingRuleCatchAllGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingRoutingRuleCatchAllGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type EmailRoutingRoutingRuleCatchAllGetResponseEnvelopeSuccess bool - -const ( - EmailRoutingRoutingRuleCatchAllGetResponseEnvelopeSuccessTrue EmailRoutingRoutingRuleCatchAllGetResponseEnvelopeSuccess = true -) diff --git a/emailroutingroutingrulecatchall_test.go b/emailroutingroutingrulecatchall_test.go deleted file mode 100644 index b644b9fe3cd..00000000000 --- a/emailroutingroutingrulecatchall_test.go +++ /dev/null @@ -1,86 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestEmailRoutingRoutingRuleCatchAllUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.EmailRouting.Routing.Rules.CatchAlls.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.EmailRoutingRoutingRuleCatchAllUpdateParams{ - Actions: cloudflare.F([]cloudflare.EmailRoutingRoutingRuleCatchAllUpdateParamsAction{{ - Type: cloudflare.F(cloudflare.EmailRoutingRoutingRuleCatchAllUpdateParamsActionsTypeForward), - Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), - }, { - Type: cloudflare.F(cloudflare.EmailRoutingRoutingRuleCatchAllUpdateParamsActionsTypeForward), - Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), - }, { - Type: cloudflare.F(cloudflare.EmailRoutingRoutingRuleCatchAllUpdateParamsActionsTypeForward), - Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), - }}), - Matchers: cloudflare.F([]cloudflare.EmailRoutingRoutingRuleCatchAllUpdateParamsMatcher{{ - Type: cloudflare.F(cloudflare.EmailRoutingRoutingRuleCatchAllUpdateParamsMatchersTypeAll), - }, { - Type: cloudflare.F(cloudflare.EmailRoutingRoutingRuleCatchAllUpdateParamsMatchersTypeAll), - }, { - Type: cloudflare.F(cloudflare.EmailRoutingRoutingRuleCatchAllUpdateParamsMatchersTypeAll), - }}), - Enabled: cloudflare.F(cloudflare.EmailRoutingRoutingRuleCatchAllUpdateParamsEnabledTrue), - Name: cloudflare.F("Send to user@example.net rule."), - }, - ) - 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 TestEmailRoutingRoutingRuleCatchAllGet(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("user@example.com"), - ) - _, err := client.EmailRouting.Routing.Rules.CatchAlls.Get(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/filter.go b/filter.go deleted file mode 100644 index 44f45fd4858..00000000000 --- a/filter.go +++ /dev/null @@ -1,682 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" -) - -// FilterService 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 [NewFilterService] method instead. -type FilterService struct { - Options []option.RequestOption -} - -// NewFilterService 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 NewFilterService(opts ...option.RequestOption) (r *FilterService) { - r = &FilterService{} - r.Options = opts - return -} - -// Creates one or more filters. -func (r *FilterService) New(ctx context.Context, zoneIdentifier string, body FilterNewParams, opts ...option.RequestOption) (res *[]FilterNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env FilterNewResponseEnvelope - path := fmt.Sprintf("zones/%s/filters", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates an existing filter. -func (r *FilterService) Update(ctx context.Context, zoneIdentifier string, id string, body FilterUpdateParams, opts ...option.RequestOption) (res *FilterUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env FilterUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/filters/%s", zoneIdentifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches filters in a zone. You can filter the results using several optional -// parameters. -func (r *FilterService) List(ctx context.Context, zoneIdentifier string, query FilterListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[FilterListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("zones/%s/filters", zoneIdentifier) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Fetches filters in a zone. You can filter the results using several optional -// parameters. -func (r *FilterService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query FilterListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[FilterListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) -} - -// Deletes an existing filter. -func (r *FilterService) Delete(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *FilterDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env FilterDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/filters/%s", zoneIdentifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the details of a filter. -func (r *FilterService) Get(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *FilterGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env FilterGetResponseEnvelope - path := fmt.Sprintf("zones/%s/filters/%s", zoneIdentifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type FilterNewResponse struct { - // The unique identifier of the filter. - ID string `json:"id,required"` - // The filter expression. For more information, refer to - // [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - Expression string `json:"expression,required"` - // When true, indicates that the filter is currently paused. - Paused bool `json:"paused,required"` - // An informative summary of the filter. - Description string `json:"description"` - // A short reference tag. Allows you to select related filters. - Ref string `json:"ref"` - JSON filterNewResponseJSON `json:"-"` -} - -// filterNewResponseJSON contains the JSON metadata for the struct -// [FilterNewResponse] -type filterNewResponseJSON struct { - ID apijson.Field - Expression apijson.Field - Paused apijson.Field - Description apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterNewResponseJSON) RawJSON() string { - return r.raw -} - -type FilterUpdateResponse struct { - // The unique identifier of the filter. - ID string `json:"id,required"` - // The filter expression. For more information, refer to - // [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - Expression string `json:"expression,required"` - // When true, indicates that the filter is currently paused. - Paused bool `json:"paused,required"` - // An informative summary of the filter. - Description string `json:"description"` - // A short reference tag. Allows you to select related filters. - Ref string `json:"ref"` - JSON filterUpdateResponseJSON `json:"-"` -} - -// filterUpdateResponseJSON contains the JSON metadata for the struct -// [FilterUpdateResponse] -type filterUpdateResponseJSON struct { - ID apijson.Field - Expression apijson.Field - Paused apijson.Field - Description apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type FilterListResponse struct { - // The unique identifier of the filter. - ID string `json:"id,required"` - // The filter expression. For more information, refer to - // [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - Expression string `json:"expression,required"` - // When true, indicates that the filter is currently paused. - Paused bool `json:"paused,required"` - // An informative summary of the filter. - Description string `json:"description"` - // A short reference tag. Allows you to select related filters. - Ref string `json:"ref"` - JSON filterListResponseJSON `json:"-"` -} - -// filterListResponseJSON contains the JSON metadata for the struct -// [FilterListResponse] -type filterListResponseJSON struct { - ID apijson.Field - Expression apijson.Field - Paused apijson.Field - Description apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterListResponseJSON) RawJSON() string { - return r.raw -} - -type FilterDeleteResponse struct { - // The unique identifier of the filter. - ID string `json:"id,required"` - // An informative summary of the filter. - Description string `json:"description"` - // The filter expression. For more information, refer to - // [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - Expression string `json:"expression"` - // When true, indicates that the filter is currently paused. - Paused bool `json:"paused"` - // A short reference tag. Allows you to select related filters. - Ref string `json:"ref"` - JSON filterDeleteResponseJSON `json:"-"` -} - -// filterDeleteResponseJSON contains the JSON metadata for the struct -// [FilterDeleteResponse] -type filterDeleteResponseJSON struct { - ID apijson.Field - Description apijson.Field - Expression apijson.Field - Paused apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type FilterGetResponse struct { - // The unique identifier of the filter. - ID string `json:"id,required"` - // The filter expression. For more information, refer to - // [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - Expression string `json:"expression,required"` - // When true, indicates that the filter is currently paused. - Paused bool `json:"paused,required"` - // An informative summary of the filter. - Description string `json:"description"` - // A short reference tag. Allows you to select related filters. - Ref string `json:"ref"` - JSON filterGetResponseJSON `json:"-"` -} - -// filterGetResponseJSON contains the JSON metadata for the struct -// [FilterGetResponse] -type filterGetResponseJSON struct { - ID apijson.Field - Expression apijson.Field - Paused apijson.Field - Description apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterGetResponseJSON) RawJSON() string { - return r.raw -} - -type FilterNewParams struct { - Body param.Field[interface{}] `json:"body,required"` -} - -func (r FilterNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type FilterNewResponseEnvelope struct { - Errors []FilterNewResponseEnvelopeErrors `json:"errors,required"` - Messages []FilterNewResponseEnvelopeMessages `json:"messages,required"` - Result []FilterNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FilterNewResponseEnvelopeSuccess `json:"success,required"` - ResultInfo FilterNewResponseEnvelopeResultInfo `json:"result_info"` - JSON filterNewResponseEnvelopeJSON `json:"-"` -} - -// filterNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [FilterNewResponseEnvelope] -type filterNewResponseEnvelopeJSON 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 *FilterNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FilterNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// filterNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [FilterNewResponseEnvelopeErrors] -type filterNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FilterNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// filterNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [FilterNewResponseEnvelopeMessages] -type filterNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FilterNewResponseEnvelopeSuccess bool - -const ( - FilterNewResponseEnvelopeSuccessTrue FilterNewResponseEnvelopeSuccess = true -) - -type FilterNewResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON filterNewResponseEnvelopeResultInfoJSON `json:"-"` -} - -// filterNewResponseEnvelopeResultInfoJSON contains the JSON metadata for the -// struct [FilterNewResponseEnvelopeResultInfo] -type filterNewResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterNewResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type FilterUpdateParams struct { - Body param.Field[interface{}] `json:"body,required"` -} - -func (r FilterUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type FilterUpdateResponseEnvelope struct { - Errors []FilterUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []FilterUpdateResponseEnvelopeMessages `json:"messages,required"` - Result FilterUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FilterUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON filterUpdateResponseEnvelopeJSON `json:"-"` -} - -// filterUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [FilterUpdateResponseEnvelope] -type filterUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FilterUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// filterUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [FilterUpdateResponseEnvelopeErrors] -type filterUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FilterUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// filterUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [FilterUpdateResponseEnvelopeMessages] -type filterUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FilterUpdateResponseEnvelopeSuccess bool - -const ( - FilterUpdateResponseEnvelopeSuccessTrue FilterUpdateResponseEnvelopeSuccess = true -) - -type FilterListParams struct { - // A case-insensitive string to find in the description. - Description param.Field[string] `query:"description"` - // A case-insensitive string to find in the expression. - Expression param.Field[string] `query:"expression"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // When true, indicates that the filter is currently paused. - Paused param.Field[bool] `query:"paused"` - // Number of filters per page. - PerPage param.Field[float64] `query:"per_page"` - // The filter ref (a short reference tag) to search for. Must be an exact match. - Ref param.Field[string] `query:"ref"` -} - -// URLQuery serializes [FilterListParams]'s query parameters as `url.Values`. -func (r FilterListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type FilterDeleteResponseEnvelope struct { - Errors []FilterDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []FilterDeleteResponseEnvelopeMessages `json:"messages,required"` - Result FilterDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FilterDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON filterDeleteResponseEnvelopeJSON `json:"-"` -} - -// filterDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [FilterDeleteResponseEnvelope] -type filterDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FilterDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// filterDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [FilterDeleteResponseEnvelopeErrors] -type filterDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FilterDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// filterDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [FilterDeleteResponseEnvelopeMessages] -type filterDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FilterDeleteResponseEnvelopeSuccess bool - -const ( - FilterDeleteResponseEnvelopeSuccessTrue FilterDeleteResponseEnvelopeSuccess = true -) - -type FilterGetResponseEnvelope struct { - Errors []FilterGetResponseEnvelopeErrors `json:"errors,required"` - Messages []FilterGetResponseEnvelopeMessages `json:"messages,required"` - Result FilterGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FilterGetResponseEnvelopeSuccess `json:"success,required"` - JSON filterGetResponseEnvelopeJSON `json:"-"` -} - -// filterGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [FilterGetResponseEnvelope] -type filterGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FilterGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// filterGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [FilterGetResponseEnvelopeErrors] -type filterGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FilterGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON filterGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// filterGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [FilterGetResponseEnvelopeMessages] -type filterGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FilterGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r filterGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FilterGetResponseEnvelopeSuccess bool - -const ( - FilterGetResponseEnvelopeSuccessTrue FilterGetResponseEnvelopeSuccess = true -) diff --git a/filter_test.go b/filter_test.go deleted file mode 100644 index f38dc018bc4..00000000000 --- a/filter_test.go +++ /dev/null @@ -1,166 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestFilterNew(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("user@example.com"), - ) - _, err := client.Filters.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.FilterNewParams{ - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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 TestFilterUpdate(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("user@example.com"), - ) - _, err := client.Filters.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "372e67954025e0ba6aaa6d586b9e0b61", - cloudflare.FilterUpdateParams{ - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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 TestFilterListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Filters.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.FilterListParams{ - Description: cloudflare.F("browsers"), - Expression: cloudflare.F("php"), - Page: cloudflare.F(1.000000), - Paused: cloudflare.F(false), - PerPage: cloudflare.F(5.000000), - Ref: cloudflare.F("FIL-100"), - }, - ) - 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 TestFilterDelete(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("user@example.com"), - ) - _, err := client.Filters.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "372e67954025e0ba6aaa6d586b9e0b61", - ) - 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 TestFilterGet(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("user@example.com"), - ) - _, err := client.Filters.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "372e67954025e0ba6aaa6d586b9e0b61", - ) - 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/filters/aliases.go b/filters/aliases.go new file mode 100644 index 00000000000..a02fc7e23c0 --- /dev/null +++ b/filters/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package filters + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/filters/filter.go b/filters/filter.go new file mode 100644 index 00000000000..e15aafde717 --- /dev/null +++ b/filters/filter.go @@ -0,0 +1,543 @@ +// File generated from our OpenAPI spec by Stainless. + +package filters + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" +) + +// FilterService 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 [NewFilterService] method instead. +type FilterService struct { + Options []option.RequestOption +} + +// NewFilterService 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 NewFilterService(opts ...option.RequestOption) (r *FilterService) { + r = &FilterService{} + r.Options = opts + return +} + +// Creates one or more filters. +func (r *FilterService) New(ctx context.Context, zoneIdentifier string, body FilterNewParams, opts ...option.RequestOption) (res *[]LegacyJhsFilter, err error) { + opts = append(r.Options[:], opts...) + var env FilterNewResponseEnvelope + path := fmt.Sprintf("zones/%s/filters", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates an existing filter. +func (r *FilterService) Update(ctx context.Context, zoneIdentifier string, id string, body FilterUpdateParams, opts ...option.RequestOption) (res *LegacyJhsFilter, err error) { + opts = append(r.Options[:], opts...) + var env FilterUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/filters/%s", zoneIdentifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches filters in a zone. You can filter the results using several optional +// parameters. +func (r *FilterService) List(ctx context.Context, zoneIdentifier string, query FilterListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[LegacyJhsFilter], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("zones/%s/filters", zoneIdentifier) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Fetches filters in a zone. You can filter the results using several optional +// parameters. +func (r *FilterService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query FilterListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[LegacyJhsFilter] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) +} + +// Deletes an existing filter. +func (r *FilterService) Delete(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *LegacyJhsFilter, err error) { + opts = append(r.Options[:], opts...) + var env FilterDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/filters/%s", zoneIdentifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the details of a filter. +func (r *FilterService) Get(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *LegacyJhsFilter, err error) { + opts = append(r.Options[:], opts...) + var env FilterGetResponseEnvelope + path := fmt.Sprintf("zones/%s/filters/%s", zoneIdentifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type LegacyJhsFilter struct { + // The unique identifier of the filter. + ID string `json:"id"` + // An informative summary of the filter. + Description string `json:"description"` + // The filter expression. For more information, refer to + // [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). + Expression string `json:"expression"` + // When true, indicates that the filter is currently paused. + Paused bool `json:"paused"` + // A short reference tag. Allows you to select related filters. + Ref string `json:"ref"` + JSON legacyJhsFilterJSON `json:"-"` +} + +// legacyJhsFilterJSON contains the JSON metadata for the struct [LegacyJhsFilter] +type legacyJhsFilterJSON struct { + ID apijson.Field + Description apijson.Field + Expression apijson.Field + Paused apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LegacyJhsFilter) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r legacyJhsFilterJSON) RawJSON() string { + return r.raw +} + +func (r LegacyJhsFilter) implementsFirewallLegacyJhsFilterRuleFilter() {} + +type FilterNewParams struct { + Body param.Field[interface{}] `json:"body,required"` +} + +func (r FilterNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type FilterNewResponseEnvelope struct { + Errors []FilterNewResponseEnvelopeErrors `json:"errors,required"` + Messages []FilterNewResponseEnvelopeMessages `json:"messages,required"` + Result []LegacyJhsFilter `json:"result,required,nullable"` + // Whether the API call was successful + Success FilterNewResponseEnvelopeSuccess `json:"success,required"` + ResultInfo FilterNewResponseEnvelopeResultInfo `json:"result_info"` + JSON filterNewResponseEnvelopeJSON `json:"-"` +} + +// filterNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [FilterNewResponseEnvelope] +type filterNewResponseEnvelopeJSON 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 *FilterNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FilterNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON filterNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// filterNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [FilterNewResponseEnvelopeErrors] +type filterNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FilterNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON filterNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// filterNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [FilterNewResponseEnvelopeMessages] +type filterNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FilterNewResponseEnvelopeSuccess bool + +const ( + FilterNewResponseEnvelopeSuccessTrue FilterNewResponseEnvelopeSuccess = true +) + +type FilterNewResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON filterNewResponseEnvelopeResultInfoJSON `json:"-"` +} + +// filterNewResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [FilterNewResponseEnvelopeResultInfo] +type filterNewResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterNewResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type FilterUpdateParams struct { + Body param.Field[interface{}] `json:"body,required"` +} + +func (r FilterUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type FilterUpdateResponseEnvelope struct { + Errors []FilterUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []FilterUpdateResponseEnvelopeMessages `json:"messages,required"` + Result LegacyJhsFilter `json:"result,required,nullable"` + // Whether the API call was successful + Success FilterUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON filterUpdateResponseEnvelopeJSON `json:"-"` +} + +// filterUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [FilterUpdateResponseEnvelope] +type filterUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FilterUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON filterUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// filterUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [FilterUpdateResponseEnvelopeErrors] +type filterUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FilterUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON filterUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// filterUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [FilterUpdateResponseEnvelopeMessages] +type filterUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FilterUpdateResponseEnvelopeSuccess bool + +const ( + FilterUpdateResponseEnvelopeSuccessTrue FilterUpdateResponseEnvelopeSuccess = true +) + +type FilterListParams struct { + // A case-insensitive string to find in the description. + Description param.Field[string] `query:"description"` + // A case-insensitive string to find in the expression. + Expression param.Field[string] `query:"expression"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // When true, indicates that the filter is currently paused. + Paused param.Field[bool] `query:"paused"` + // Number of filters per page. + PerPage param.Field[float64] `query:"per_page"` + // The filter ref (a short reference tag) to search for. Must be an exact match. + Ref param.Field[string] `query:"ref"` +} + +// URLQuery serializes [FilterListParams]'s query parameters as `url.Values`. +func (r FilterListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type FilterDeleteResponseEnvelope struct { + Errors []FilterDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []FilterDeleteResponseEnvelopeMessages `json:"messages,required"` + Result LegacyJhsFilter `json:"result,required,nullable"` + // Whether the API call was successful + Success FilterDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON filterDeleteResponseEnvelopeJSON `json:"-"` +} + +// filterDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [FilterDeleteResponseEnvelope] +type filterDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FilterDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON filterDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// filterDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [FilterDeleteResponseEnvelopeErrors] +type filterDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FilterDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON filterDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// filterDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [FilterDeleteResponseEnvelopeMessages] +type filterDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FilterDeleteResponseEnvelopeSuccess bool + +const ( + FilterDeleteResponseEnvelopeSuccessTrue FilterDeleteResponseEnvelopeSuccess = true +) + +type FilterGetResponseEnvelope struct { + Errors []FilterGetResponseEnvelopeErrors `json:"errors,required"` + Messages []FilterGetResponseEnvelopeMessages `json:"messages,required"` + Result LegacyJhsFilter `json:"result,required,nullable"` + // Whether the API call was successful + Success FilterGetResponseEnvelopeSuccess `json:"success,required"` + JSON filterGetResponseEnvelopeJSON `json:"-"` +} + +// filterGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [FilterGetResponseEnvelope] +type filterGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FilterGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON filterGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// filterGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [FilterGetResponseEnvelopeErrors] +type filterGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FilterGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON filterGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// filterGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [FilterGetResponseEnvelopeMessages] +type filterGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FilterGetResponseEnvelopeSuccess bool + +const ( + FilterGetResponseEnvelopeSuccessTrue FilterGetResponseEnvelopeSuccess = true +) diff --git a/filters/filter_test.go b/filters/filter_test.go new file mode 100644 index 00000000000..4386b8b7951 --- /dev/null +++ b/filters/filter_test.go @@ -0,0 +1,167 @@ +// File generated from our OpenAPI spec by Stainless. + +package filters_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/filters" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestFilterNew(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("user@example.com"), + ) + _, err := client.Filters.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + filters.FilterNewParams{ + Body: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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 TestFilterUpdate(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("user@example.com"), + ) + _, err := client.Filters.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "372e67954025e0ba6aaa6d586b9e0b61", + filters.FilterUpdateParams{ + Body: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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 TestFilterListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Filters.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + filters.FilterListParams{ + Description: cloudflare.F("browsers"), + Expression: cloudflare.F("php"), + Page: cloudflare.F(1.000000), + Paused: cloudflare.F(false), + PerPage: cloudflare.F(5.000000), + Ref: cloudflare.F("FIL-100"), + }, + ) + 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 TestFilterDelete(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("user@example.com"), + ) + _, err := client.Filters.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "372e67954025e0ba6aaa6d586b9e0b61", + ) + 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 TestFilterGet(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("user@example.com"), + ) + _, err := client.Filters.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "372e67954025e0ba6aaa6d586b9e0b61", + ) + 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/firewall.go b/firewall.go deleted file mode 100644 index 30c9d7f2928..00000000000 --- a/firewall.go +++ /dev/null @@ -1,34 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// FirewallService 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 [NewFirewallService] method instead. -type FirewallService struct { - Options []option.RequestOption - Lockdowns *FirewallLockdownService - Rules *FirewallRuleService - AccessRules *FirewallAccessRuleService - UARules *FirewallUARuleService - WAF *FirewallWAFService -} - -// NewFirewallService 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 NewFirewallService(opts ...option.RequestOption) (r *FirewallService) { - r = &FirewallService{} - r.Options = opts - r.Lockdowns = NewFirewallLockdownService(opts...) - r.Rules = NewFirewallRuleService(opts...) - r.AccessRules = NewFirewallAccessRuleService(opts...) - r.UARules = NewFirewallUARuleService(opts...) - r.WAF = NewFirewallWAFService(opts...) - return -} diff --git a/firewall/accessrule.go b/firewall/accessrule.go new file mode 100644 index 00000000000..cefb9e0cfd8 --- /dev/null +++ b/firewall/accessrule.go @@ -0,0 +1,1027 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// AccessRuleService 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 [NewAccessRuleService] method instead. +type AccessRuleService struct { + Options []option.RequestOption +} + +// NewAccessRuleService 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 NewAccessRuleService(opts ...option.RequestOption) (r *AccessRuleService) { + r = &AccessRuleService{} + r.Options = opts + return +} + +// Creates a new IP Access rule for an account or zone. The rule will apply to all +// zones in the account or zone. +// +// Note: To create an IP Access rule that applies to a single zone, refer to the +// [IP Access rules for a zone](#ip-access-rules-for-a-zone) endpoints. +func (r *AccessRuleService) New(ctx context.Context, params AccessRuleNewParams, opts ...option.RequestOption) (res *AccessRuleNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessRuleNewResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/firewall/access_rules/rules", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches IP Access rules of an account or zone. These rules apply to all the +// zones in the account or zone. You can filter the results using several optional +// parameters. +func (r *AccessRuleService) List(ctx context.Context, params AccessRuleListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[AccessRuleListResponse], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/firewall/access_rules/rules", accountOrZone, accountOrZoneID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Fetches IP Access rules of an account or zone. These rules apply to all the +// zones in the account or zone. You can filter the results using several optional +// parameters. +func (r *AccessRuleService) ListAutoPaging(ctx context.Context, params AccessRuleListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[AccessRuleListResponse] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) +} + +// Deletes an existing IP Access rule defined. +// +// Note: This operation will affect all zones in the account or zone. +func (r *AccessRuleService) Delete(ctx context.Context, identifier interface{}, body AccessRuleDeleteParams, opts ...option.RequestOption) (res *AccessRuleDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessRuleDeleteResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if body.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = body.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = body.ZoneID + } + path := fmt.Sprintf("%s/%s/firewall/access_rules/rules/%v", accountOrZone, accountOrZoneID, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates an IP Access rule defined at the account level. +// +// Note: This operation will affect all zones in the account. +func (r *AccessRuleService) Edit(ctx context.Context, identifier interface{}, params AccessRuleEditParams, opts ...option.RequestOption) (res *AccessRuleEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessRuleEditResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/firewall/access_rules/rules/%v", accountOrZone, accountOrZoneID, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the details of an IP Access rule defined. +func (r *AccessRuleService) Get(ctx context.Context, identifier interface{}, query AccessRuleGetParams, opts ...option.RequestOption) (res *AccessRuleGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessRuleGetResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/firewall/access_rules/rules/%v", accountOrZone, accountOrZoneID, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [firewall.AccessRuleNewResponseUnknown] or +// [shared.UnionString]. +type AccessRuleNewResponse interface { + ImplementsFirewallAccessRuleNewResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessRuleNewResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type AccessRuleListResponse = interface{} + +type AccessRuleDeleteResponse struct { + // Identifier + ID string `json:"id,required"` + JSON accessRuleDeleteResponseJSON `json:"-"` +} + +// accessRuleDeleteResponseJSON contains the JSON metadata for the struct +// [AccessRuleDeleteResponse] +type accessRuleDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessRuleDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessRuleDeleteResponseJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [firewall.AccessRuleEditResponseUnknown] or +// [shared.UnionString]. +type AccessRuleEditResponse interface { + ImplementsFirewallAccessRuleEditResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessRuleEditResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [firewall.AccessRuleGetResponseUnknown] or +// [shared.UnionString]. +type AccessRuleGetResponse interface { + ImplementsFirewallAccessRuleGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessRuleGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type AccessRuleNewParams struct { + // The rule configuration. + Configuration param.Field[AccessRuleNewParamsConfiguration] `json:"configuration,required"` + // The action to apply to a matched request. + Mode param.Field[AccessRuleNewParamsMode] `json:"mode,required"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // An informative summary of the rule, typically used as a reminder or explanation. + Notes param.Field[string] `json:"notes"` +} + +func (r AccessRuleNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The rule configuration. +// +// Satisfied by +// [firewall.AccessRuleNewParamsConfigurationLegacyJhsIPConfiguration], +// [firewall.AccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration], +// [firewall.AccessRuleNewParamsConfigurationLegacyJhsCidrConfiguration], +// [firewall.AccessRuleNewParamsConfigurationLegacyJhsASNConfiguration], +// [firewall.AccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration]. +type AccessRuleNewParamsConfiguration interface { + implementsFirewallAccessRuleNewParamsConfiguration() +} + +type AccessRuleNewParamsConfigurationLegacyJhsIPConfiguration struct { + // The configuration target. You must set the target to `ip` when specifying an IP + // address in the rule. + Target param.Field[AccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget] `json:"target"` + // The IP address to match. This address will be compared to the IP address of + // incoming requests. + Value param.Field[string] `json:"value"` +} + +func (r AccessRuleNewParamsConfigurationLegacyJhsIPConfiguration) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessRuleNewParamsConfigurationLegacyJhsIPConfiguration) implementsFirewallAccessRuleNewParamsConfiguration() { +} + +// The configuration target. You must set the target to `ip` when specifying an IP +// address in the rule. +type AccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget string + +const ( + AccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTargetIP AccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget = "ip" +) + +type AccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration struct { + // The configuration target. You must set the target to `ip6` when specifying an + // IPv6 address in the rule. + Target param.Field[AccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget] `json:"target"` + // The IPv6 address to match. + Value param.Field[string] `json:"value"` +} + +func (r AccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration) implementsFirewallAccessRuleNewParamsConfiguration() { +} + +// The configuration target. You must set the target to `ip6` when specifying an +// IPv6 address in the rule. +type AccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget string + +const ( + AccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTargetIp6 AccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget = "ip6" +) + +type AccessRuleNewParamsConfigurationLegacyJhsCidrConfiguration struct { + // The configuration target. You must set the target to `ip_range` when specifying + // an IP address range in the rule. + Target param.Field[AccessRuleNewParamsConfigurationLegacyJhsCidrConfigurationTarget] `json:"target"` + // The IP address range to match. You can only use prefix lengths `/16` and `/24` + // for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. + Value param.Field[string] `json:"value"` +} + +func (r AccessRuleNewParamsConfigurationLegacyJhsCidrConfiguration) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessRuleNewParamsConfigurationLegacyJhsCidrConfiguration) implementsFirewallAccessRuleNewParamsConfiguration() { +} + +// The configuration target. You must set the target to `ip_range` when specifying +// an IP address range in the rule. +type AccessRuleNewParamsConfigurationLegacyJhsCidrConfigurationTarget string + +const ( + AccessRuleNewParamsConfigurationLegacyJhsCidrConfigurationTargetIPRange AccessRuleNewParamsConfigurationLegacyJhsCidrConfigurationTarget = "ip_range" +) + +type AccessRuleNewParamsConfigurationLegacyJhsASNConfiguration struct { + // The configuration target. You must set the target to `asn` when specifying an + // Autonomous System Number (ASN) in the rule. + Target param.Field[AccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget] `json:"target"` + // The AS number to match. + Value param.Field[string] `json:"value"` +} + +func (r AccessRuleNewParamsConfigurationLegacyJhsASNConfiguration) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessRuleNewParamsConfigurationLegacyJhsASNConfiguration) implementsFirewallAccessRuleNewParamsConfiguration() { +} + +// The configuration target. You must set the target to `asn` when specifying an +// Autonomous System Number (ASN) in the rule. +type AccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget string + +const ( + AccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTargetASN AccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget = "asn" +) + +type AccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration struct { + // The configuration target. You must set the target to `country` when specifying a + // country code in the rule. + Target param.Field[AccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget] `json:"target"` + // The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to + // [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). + Value param.Field[string] `json:"value"` +} + +func (r AccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration) implementsFirewallAccessRuleNewParamsConfiguration() { +} + +// The configuration target. You must set the target to `country` when specifying a +// country code in the rule. +type AccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget string + +const ( + AccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTargetCountry AccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget = "country" +) + +// The action to apply to a matched request. +type AccessRuleNewParamsMode string + +const ( + AccessRuleNewParamsModeBlock AccessRuleNewParamsMode = "block" + AccessRuleNewParamsModeChallenge AccessRuleNewParamsMode = "challenge" + AccessRuleNewParamsModeWhitelist AccessRuleNewParamsMode = "whitelist" + AccessRuleNewParamsModeJsChallenge AccessRuleNewParamsMode = "js_challenge" + AccessRuleNewParamsModeManagedChallenge AccessRuleNewParamsMode = "managed_challenge" +) + +type AccessRuleNewResponseEnvelope struct { + Errors []AccessRuleNewResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessRuleNewResponseEnvelopeMessages `json:"messages,required"` + Result AccessRuleNewResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessRuleNewResponseEnvelopeSuccess `json:"success,required"` + JSON accessRuleNewResponseEnvelopeJSON `json:"-"` +} + +// accessRuleNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessRuleNewResponseEnvelope] +type accessRuleNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessRuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessRuleNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessRuleNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessRuleNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessRuleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessRuleNewResponseEnvelopeErrors] +type accessRuleNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessRuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessRuleNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessRuleNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessRuleNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessRuleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessRuleNewResponseEnvelopeMessages] +type accessRuleNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessRuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessRuleNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessRuleNewResponseEnvelopeSuccess bool + +const ( + AccessRuleNewResponseEnvelopeSuccessTrue AccessRuleNewResponseEnvelopeSuccess = true +) + +type AccessRuleListParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // The direction used to sort returned rules. + Direction param.Field[AccessRuleListParamsDirection] `query:"direction"` + EgsPagination param.Field[AccessRuleListParamsEgsPagination] `query:"egs-pagination"` + Filters param.Field[AccessRuleListParamsFilters] `query:"filters"` + // The field used to sort returned rules. + Order param.Field[AccessRuleListParamsOrder] `query:"order"` + // Requested page within paginated list of results. + Page param.Field[float64] `query:"page"` + // Maximum number of results requested. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [AccessRuleListParams]'s query parameters as `url.Values`. +func (r AccessRuleListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// The direction used to sort returned rules. +type AccessRuleListParamsDirection string + +const ( + AccessRuleListParamsDirectionAsc AccessRuleListParamsDirection = "asc" + AccessRuleListParamsDirectionDesc AccessRuleListParamsDirection = "desc" +) + +type AccessRuleListParamsEgsPagination struct { + Json param.Field[AccessRuleListParamsEgsPaginationJson] `query:"json"` +} + +// URLQuery serializes [AccessRuleListParamsEgsPagination]'s query parameters as +// `url.Values`. +func (r AccessRuleListParamsEgsPagination) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AccessRuleListParamsEgsPaginationJson struct { + // The page number of paginated results. + Page param.Field[float64] `query:"page"` + // The maximum number of results per page. You can only set the value to `1` or to + // a multiple of 5 such as `5`, `10`, `15`, or `20`. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [AccessRuleListParamsEgsPaginationJson]'s query parameters +// as `url.Values`. +func (r AccessRuleListParamsEgsPaginationJson) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AccessRuleListParamsFilters struct { + // The target to search in existing rules. + ConfigurationTarget param.Field[AccessRuleListParamsFiltersConfigurationTarget] `query:"configuration.target"` + // The target value to search for in existing rules: an IP address, an IP address + // range, or a country code, depending on the provided `configuration.target`. + // Notes: You can search for a single IPv4 address, an IP address range with a + // subnet of '/16' or '/24', or a two-letter ISO-3166-1 alpha-2 country code. + ConfigurationValue param.Field[string] `query:"configuration.value"` + // When set to `all`, all the search requirements must match. When set to `any`, + // only one of the search requirements has to match. + Match param.Field[AccessRuleListParamsFiltersMatch] `query:"match"` + // The action to apply to a matched request. + Mode param.Field[AccessRuleListParamsFiltersMode] `query:"mode"` + // The string to search for in the notes of existing IP Access rules. Notes: For + // example, the string 'attack' would match IP Access rules with notes 'Attack + // 26/02' and 'Attack 27/02'. The search is case insensitive. + Notes param.Field[string] `query:"notes"` +} + +// URLQuery serializes [AccessRuleListParamsFilters]'s query parameters as +// `url.Values`. +func (r AccessRuleListParamsFilters) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// The target to search in existing rules. +type AccessRuleListParamsFiltersConfigurationTarget string + +const ( + AccessRuleListParamsFiltersConfigurationTargetIP AccessRuleListParamsFiltersConfigurationTarget = "ip" + AccessRuleListParamsFiltersConfigurationTargetIPRange AccessRuleListParamsFiltersConfigurationTarget = "ip_range" + AccessRuleListParamsFiltersConfigurationTargetASN AccessRuleListParamsFiltersConfigurationTarget = "asn" + AccessRuleListParamsFiltersConfigurationTargetCountry AccessRuleListParamsFiltersConfigurationTarget = "country" +) + +// When set to `all`, all the search requirements must match. When set to `any`, +// only one of the search requirements has to match. +type AccessRuleListParamsFiltersMatch string + +const ( + AccessRuleListParamsFiltersMatchAny AccessRuleListParamsFiltersMatch = "any" + AccessRuleListParamsFiltersMatchAll AccessRuleListParamsFiltersMatch = "all" +) + +// The action to apply to a matched request. +type AccessRuleListParamsFiltersMode string + +const ( + AccessRuleListParamsFiltersModeBlock AccessRuleListParamsFiltersMode = "block" + AccessRuleListParamsFiltersModeChallenge AccessRuleListParamsFiltersMode = "challenge" + AccessRuleListParamsFiltersModeWhitelist AccessRuleListParamsFiltersMode = "whitelist" + AccessRuleListParamsFiltersModeJsChallenge AccessRuleListParamsFiltersMode = "js_challenge" + AccessRuleListParamsFiltersModeManagedChallenge AccessRuleListParamsFiltersMode = "managed_challenge" +) + +// The field used to sort returned rules. +type AccessRuleListParamsOrder string + +const ( + AccessRuleListParamsOrderConfigurationTarget AccessRuleListParamsOrder = "configuration.target" + AccessRuleListParamsOrderConfigurationValue AccessRuleListParamsOrder = "configuration.value" + AccessRuleListParamsOrderMode AccessRuleListParamsOrder = "mode" +) + +type AccessRuleDeleteParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessRuleDeleteResponseEnvelope struct { + Errors []AccessRuleDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessRuleDeleteResponseEnvelopeMessages `json:"messages,required"` + Result AccessRuleDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessRuleDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON accessRuleDeleteResponseEnvelopeJSON `json:"-"` +} + +// accessRuleDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessRuleDeleteResponseEnvelope] +type accessRuleDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessRuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessRuleDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessRuleDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessRuleDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessRuleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessRuleDeleteResponseEnvelopeErrors] +type accessRuleDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessRuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessRuleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessRuleDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessRuleDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessRuleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessRuleDeleteResponseEnvelopeMessages] +type accessRuleDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessRuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessRuleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessRuleDeleteResponseEnvelopeSuccess bool + +const ( + AccessRuleDeleteResponseEnvelopeSuccessTrue AccessRuleDeleteResponseEnvelopeSuccess = true +) + +type AccessRuleEditParams struct { + // The rule configuration. + Configuration param.Field[AccessRuleEditParamsConfiguration] `json:"configuration,required"` + // The action to apply to a matched request. + Mode param.Field[AccessRuleEditParamsMode] `json:"mode,required"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // An informative summary of the rule, typically used as a reminder or explanation. + Notes param.Field[string] `json:"notes"` +} + +func (r AccessRuleEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The rule configuration. +// +// Satisfied by +// [firewall.AccessRuleEditParamsConfigurationLegacyJhsIPConfiguration], +// [firewall.AccessRuleEditParamsConfigurationLegacyJhsIPV6Configuration], +// [firewall.AccessRuleEditParamsConfigurationLegacyJhsCidrConfiguration], +// [firewall.AccessRuleEditParamsConfigurationLegacyJhsASNConfiguration], +// [firewall.AccessRuleEditParamsConfigurationLegacyJhsCountryConfiguration]. +type AccessRuleEditParamsConfiguration interface { + implementsFirewallAccessRuleEditParamsConfiguration() +} + +type AccessRuleEditParamsConfigurationLegacyJhsIPConfiguration struct { + // The configuration target. You must set the target to `ip` when specifying an IP + // address in the rule. + Target param.Field[AccessRuleEditParamsConfigurationLegacyJhsIPConfigurationTarget] `json:"target"` + // The IP address to match. This address will be compared to the IP address of + // incoming requests. + Value param.Field[string] `json:"value"` +} + +func (r AccessRuleEditParamsConfigurationLegacyJhsIPConfiguration) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessRuleEditParamsConfigurationLegacyJhsIPConfiguration) implementsFirewallAccessRuleEditParamsConfiguration() { +} + +// The configuration target. You must set the target to `ip` when specifying an IP +// address in the rule. +type AccessRuleEditParamsConfigurationLegacyJhsIPConfigurationTarget string + +const ( + AccessRuleEditParamsConfigurationLegacyJhsIPConfigurationTargetIP AccessRuleEditParamsConfigurationLegacyJhsIPConfigurationTarget = "ip" +) + +type AccessRuleEditParamsConfigurationLegacyJhsIPV6Configuration struct { + // The configuration target. You must set the target to `ip6` when specifying an + // IPv6 address in the rule. + Target param.Field[AccessRuleEditParamsConfigurationLegacyJhsIPV6ConfigurationTarget] `json:"target"` + // The IPv6 address to match. + Value param.Field[string] `json:"value"` +} + +func (r AccessRuleEditParamsConfigurationLegacyJhsIPV6Configuration) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessRuleEditParamsConfigurationLegacyJhsIPV6Configuration) implementsFirewallAccessRuleEditParamsConfiguration() { +} + +// The configuration target. You must set the target to `ip6` when specifying an +// IPv6 address in the rule. +type AccessRuleEditParamsConfigurationLegacyJhsIPV6ConfigurationTarget string + +const ( + AccessRuleEditParamsConfigurationLegacyJhsIPV6ConfigurationTargetIp6 AccessRuleEditParamsConfigurationLegacyJhsIPV6ConfigurationTarget = "ip6" +) + +type AccessRuleEditParamsConfigurationLegacyJhsCidrConfiguration struct { + // The configuration target. You must set the target to `ip_range` when specifying + // an IP address range in the rule. + Target param.Field[AccessRuleEditParamsConfigurationLegacyJhsCidrConfigurationTarget] `json:"target"` + // The IP address range to match. You can only use prefix lengths `/16` and `/24` + // for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. + Value param.Field[string] `json:"value"` +} + +func (r AccessRuleEditParamsConfigurationLegacyJhsCidrConfiguration) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessRuleEditParamsConfigurationLegacyJhsCidrConfiguration) implementsFirewallAccessRuleEditParamsConfiguration() { +} + +// The configuration target. You must set the target to `ip_range` when specifying +// an IP address range in the rule. +type AccessRuleEditParamsConfigurationLegacyJhsCidrConfigurationTarget string + +const ( + AccessRuleEditParamsConfigurationLegacyJhsCidrConfigurationTargetIPRange AccessRuleEditParamsConfigurationLegacyJhsCidrConfigurationTarget = "ip_range" +) + +type AccessRuleEditParamsConfigurationLegacyJhsASNConfiguration struct { + // The configuration target. You must set the target to `asn` when specifying an + // Autonomous System Number (ASN) in the rule. + Target param.Field[AccessRuleEditParamsConfigurationLegacyJhsASNConfigurationTarget] `json:"target"` + // The AS number to match. + Value param.Field[string] `json:"value"` +} + +func (r AccessRuleEditParamsConfigurationLegacyJhsASNConfiguration) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessRuleEditParamsConfigurationLegacyJhsASNConfiguration) implementsFirewallAccessRuleEditParamsConfiguration() { +} + +// The configuration target. You must set the target to `asn` when specifying an +// Autonomous System Number (ASN) in the rule. +type AccessRuleEditParamsConfigurationLegacyJhsASNConfigurationTarget string + +const ( + AccessRuleEditParamsConfigurationLegacyJhsASNConfigurationTargetASN AccessRuleEditParamsConfigurationLegacyJhsASNConfigurationTarget = "asn" +) + +type AccessRuleEditParamsConfigurationLegacyJhsCountryConfiguration struct { + // The configuration target. You must set the target to `country` when specifying a + // country code in the rule. + Target param.Field[AccessRuleEditParamsConfigurationLegacyJhsCountryConfigurationTarget] `json:"target"` + // The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to + // [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). + Value param.Field[string] `json:"value"` +} + +func (r AccessRuleEditParamsConfigurationLegacyJhsCountryConfiguration) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessRuleEditParamsConfigurationLegacyJhsCountryConfiguration) implementsFirewallAccessRuleEditParamsConfiguration() { +} + +// The configuration target. You must set the target to `country` when specifying a +// country code in the rule. +type AccessRuleEditParamsConfigurationLegacyJhsCountryConfigurationTarget string + +const ( + AccessRuleEditParamsConfigurationLegacyJhsCountryConfigurationTargetCountry AccessRuleEditParamsConfigurationLegacyJhsCountryConfigurationTarget = "country" +) + +// The action to apply to a matched request. +type AccessRuleEditParamsMode string + +const ( + AccessRuleEditParamsModeBlock AccessRuleEditParamsMode = "block" + AccessRuleEditParamsModeChallenge AccessRuleEditParamsMode = "challenge" + AccessRuleEditParamsModeWhitelist AccessRuleEditParamsMode = "whitelist" + AccessRuleEditParamsModeJsChallenge AccessRuleEditParamsMode = "js_challenge" + AccessRuleEditParamsModeManagedChallenge AccessRuleEditParamsMode = "managed_challenge" +) + +type AccessRuleEditResponseEnvelope struct { + Errors []AccessRuleEditResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessRuleEditResponseEnvelopeMessages `json:"messages,required"` + Result AccessRuleEditResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessRuleEditResponseEnvelopeSuccess `json:"success,required"` + JSON accessRuleEditResponseEnvelopeJSON `json:"-"` +} + +// accessRuleEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessRuleEditResponseEnvelope] +type accessRuleEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessRuleEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessRuleEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessRuleEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessRuleEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessRuleEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessRuleEditResponseEnvelopeErrors] +type accessRuleEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessRuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessRuleEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessRuleEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessRuleEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessRuleEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessRuleEditResponseEnvelopeMessages] +type accessRuleEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessRuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessRuleEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessRuleEditResponseEnvelopeSuccess bool + +const ( + AccessRuleEditResponseEnvelopeSuccessTrue AccessRuleEditResponseEnvelopeSuccess = true +) + +type AccessRuleGetParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessRuleGetResponseEnvelope struct { + Errors []AccessRuleGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessRuleGetResponseEnvelopeMessages `json:"messages,required"` + Result AccessRuleGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessRuleGetResponseEnvelopeSuccess `json:"success,required"` + JSON accessRuleGetResponseEnvelopeJSON `json:"-"` +} + +// accessRuleGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessRuleGetResponseEnvelope] +type accessRuleGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessRuleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessRuleGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessRuleGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessRuleGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessRuleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessRuleGetResponseEnvelopeErrors] +type accessRuleGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessRuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessRuleGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessRuleGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessRuleGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessRuleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessRuleGetResponseEnvelopeMessages] +type accessRuleGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessRuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessRuleGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessRuleGetResponseEnvelopeSuccess bool + +const ( + AccessRuleGetResponseEnvelopeSuccessTrue AccessRuleGetResponseEnvelopeSuccess = true +) diff --git a/firewall/accessrule_test.go b/firewall/accessrule_test.go new file mode 100644 index 00000000000..65e1f8c063b --- /dev/null +++ b/firewall/accessrule_test.go @@ -0,0 +1,191 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/firewall" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestAccessRuleNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Firewall.AccessRules.New(context.TODO(), firewall.AccessRuleNewParams{ + Configuration: cloudflare.F[firewall.AccessRuleNewParamsConfiguration](firewall.AccessRuleNewParamsConfigurationLegacyJhsIPConfiguration(firewall.AccessRuleNewParamsConfigurationLegacyJhsIPConfiguration{ + Target: cloudflare.F(firewall.AccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTargetIP), + Value: cloudflare.F("198.51.100.4"), + })), + Mode: cloudflare.F(firewall.AccessRuleNewParamsModeChallenge), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + Notes: cloudflare.F("This rule is enabled because of an event that occurred on date X."), + }) + 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 TestAccessRuleListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Firewall.AccessRules.List(context.TODO(), firewall.AccessRuleListParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + Direction: cloudflare.F(firewall.AccessRuleListParamsDirectionDesc), + EgsPagination: cloudflare.F(firewall.AccessRuleListParamsEgsPagination{ + Json: cloudflare.F(firewall.AccessRuleListParamsEgsPaginationJson{ + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(1.000000), + }), + }), + Filters: cloudflare.F(firewall.AccessRuleListParamsFilters{ + ConfigurationTarget: cloudflare.F(firewall.AccessRuleListParamsFiltersConfigurationTargetIP), + ConfigurationValue: cloudflare.F("198.51.100.4"), + Match: cloudflare.F(firewall.AccessRuleListParamsFiltersMatchAny), + Mode: cloudflare.F(firewall.AccessRuleListParamsFiltersModeChallenge), + Notes: cloudflare.F("my note"), + }), + Order: cloudflare.F(firewall.AccessRuleListParamsOrderMode), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(20.000000), + }) + 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 TestAccessRuleDeleteWithOptionalParams(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("user@example.com"), + ) + _, err := client.Firewall.AccessRules.Delete( + context.TODO(), + map[string]interface{}{}, + firewall.AccessRuleDeleteParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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 TestAccessRuleEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Firewall.AccessRules.Edit( + context.TODO(), + map[string]interface{}{}, + firewall.AccessRuleEditParams{ + Configuration: cloudflare.F[firewall.AccessRuleEditParamsConfiguration](firewall.AccessRuleEditParamsConfigurationLegacyJhsIPConfiguration(firewall.AccessRuleEditParamsConfigurationLegacyJhsIPConfiguration{ + Target: cloudflare.F(firewall.AccessRuleEditParamsConfigurationLegacyJhsIPConfigurationTargetIP), + Value: cloudflare.F("198.51.100.4"), + })), + Mode: cloudflare.F(firewall.AccessRuleEditParamsModeChallenge), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + Notes: cloudflare.F("This rule is enabled because of an event that occurred on date X."), + }, + ) + 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 TestAccessRuleGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Firewall.AccessRules.Get( + context.TODO(), + map[string]interface{}{}, + firewall.AccessRuleGetParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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/firewall/aliases.go b/firewall/aliases.go new file mode 100644 index 00000000000..7773a76afe9 --- /dev/null +++ b/firewall/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/firewall/firewall.go b/firewall/firewall.go new file mode 100644 index 00000000000..e38ff71749a --- /dev/null +++ b/firewall/firewall.go @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// FirewallService 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 [NewFirewallService] method instead. +type FirewallService struct { + Options []option.RequestOption + Lockdowns *LockdownService + Rules *RuleService + AccessRules *AccessRuleService + UARules *UARuleService + WAF *WAFService +} + +// NewFirewallService 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 NewFirewallService(opts ...option.RequestOption) (r *FirewallService) { + r = &FirewallService{} + r.Options = opts + r.Lockdowns = NewLockdownService(opts...) + r.Rules = NewRuleService(opts...) + r.AccessRules = NewAccessRuleService(opts...) + r.UARules = NewUARuleService(opts...) + r.WAF = NewWAFService(opts...) + return +} diff --git a/firewall/lockdown.go b/firewall/lockdown.go new file mode 100644 index 00000000000..39dc0d186dc --- /dev/null +++ b/firewall/lockdown.go @@ -0,0 +1,595 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// LockdownService 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 [NewLockdownService] method instead. +type LockdownService struct { + Options []option.RequestOption +} + +// NewLockdownService 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 NewLockdownService(opts ...option.RequestOption) (r *LockdownService) { + r = &LockdownService{} + r.Options = opts + return +} + +// Creates a new Zone Lockdown rule. +func (r *LockdownService) New(ctx context.Context, zoneIdentifier string, body LockdownNewParams, opts ...option.RequestOption) (res *LegacyJhsZonelockdown, err error) { + opts = append(r.Options[:], opts...) + var env LockdownNewResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/lockdowns", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates an existing Zone Lockdown rule. +func (r *LockdownService) Update(ctx context.Context, zoneIdentifier string, id string, body LockdownUpdateParams, opts ...option.RequestOption) (res *LegacyJhsZonelockdown, err error) { + opts = append(r.Options[:], opts...) + var env LockdownUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/lockdowns/%s", zoneIdentifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches Zone Lockdown rules. You can filter the results using several optional +// parameters. +func (r *LockdownService) List(ctx context.Context, zoneIdentifier string, query LockdownListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[LegacyJhsZonelockdown], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("zones/%s/firewall/lockdowns", zoneIdentifier) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Fetches Zone Lockdown rules. You can filter the results using several optional +// parameters. +func (r *LockdownService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query LockdownListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[LegacyJhsZonelockdown] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) +} + +// Deletes an existing Zone Lockdown rule. +func (r *LockdownService) Delete(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *LockdownDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env LockdownDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/lockdowns/%s", zoneIdentifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the details of a Zone Lockdown rule. +func (r *LockdownService) Get(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *LegacyJhsZonelockdown, err error) { + opts = append(r.Options[:], opts...) + var env LockdownGetResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/lockdowns/%s", zoneIdentifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type LegacyJhsZonelockdown struct { + // The unique identifier of the Zone Lockdown rule. + ID string `json:"id,required"` + // A list of IP addresses or CIDR ranges that will be allowed to access the URLs + // specified in the Zone Lockdown rule. You can include any number of `ip` or + // `ip_range` configurations. + Configurations LegacyJhsZonelockdownConfigurations `json:"configurations,required"` + // The timestamp of when the rule was created. + CreatedOn time.Time `json:"created_on,required" format:"date-time"` + // An informative summary of the rule. + Description string `json:"description,required"` + // The timestamp of when the rule was last modified. + ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` + // When true, indicates that the rule is currently paused. + Paused bool `json:"paused,required"` + // The URLs to include in the rule definition. You can use wildcards. Each entered + // URL will be escaped before use, which means you can only use simple wildcard + // patterns. + URLs []string `json:"urls,required"` + JSON legacyJhsZonelockdownJSON `json:"-"` +} + +// legacyJhsZonelockdownJSON contains the JSON metadata for the struct +// [LegacyJhsZonelockdown] +type legacyJhsZonelockdownJSON struct { + ID apijson.Field + Configurations apijson.Field + CreatedOn apijson.Field + Description apijson.Field + ModifiedOn apijson.Field + Paused apijson.Field + URLs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LegacyJhsZonelockdown) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r legacyJhsZonelockdownJSON) RawJSON() string { + return r.raw +} + +// A list of IP addresses or CIDR ranges that will be allowed to access the URLs +// specified in the Zone Lockdown rule. You can include any number of `ip` or +// `ip_range` configurations. +// +// Union satisfied by +// [firewall.LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasIPConfiguration] or +// [firewall.LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasCidrConfiguration]. +type LegacyJhsZonelockdownConfigurations interface { + implementsFirewallLegacyJhsZonelockdownConfigurations() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*LegacyJhsZonelockdownConfigurations)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasIPConfiguration{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasCidrConfiguration{}), + }, + ) +} + +type LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasIPConfiguration struct { + // The configuration target. You must set the target to `ip` when specifying an IP + // address in the Zone Lockdown rule. + Target LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasIPConfigurationTarget `json:"target"` + // The IP address to match. This address will be compared to the IP address of + // incoming requests. + Value string `json:"value"` + JSON legacyJhsZonelockdownConfigurationsLegacyJhsSchemasIPConfigurationJSON `json:"-"` +} + +// legacyJhsZonelockdownConfigurationsLegacyJhsSchemasIPConfigurationJSON contains +// the JSON metadata for the struct +// [LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasIPConfiguration] +type legacyJhsZonelockdownConfigurationsLegacyJhsSchemasIPConfigurationJSON struct { + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasIPConfiguration) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r legacyJhsZonelockdownConfigurationsLegacyJhsSchemasIPConfigurationJSON) RawJSON() string { + return r.raw +} + +func (r LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasIPConfiguration) implementsFirewallLegacyJhsZonelockdownConfigurations() { +} + +// The configuration target. You must set the target to `ip` when specifying an IP +// address in the Zone Lockdown rule. +type LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasIPConfigurationTarget string + +const ( + LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasIPConfigurationTargetIP LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasIPConfigurationTarget = "ip" +) + +type LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasCidrConfiguration struct { + // The configuration target. You must set the target to `ip_range` when specifying + // an IP address range in the Zone Lockdown rule. + Target LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasCidrConfigurationTarget `json:"target"` + // The IP address range to match. You can only use prefix lengths `/16` and `/24`. + Value string `json:"value"` + JSON legacyJhsZonelockdownConfigurationsLegacyJhsSchemasCidrConfigurationJSON `json:"-"` +} + +// legacyJhsZonelockdownConfigurationsLegacyJhsSchemasCidrConfigurationJSON +// contains the JSON metadata for the struct +// [LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasCidrConfiguration] +type legacyJhsZonelockdownConfigurationsLegacyJhsSchemasCidrConfigurationJSON struct { + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasCidrConfiguration) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r legacyJhsZonelockdownConfigurationsLegacyJhsSchemasCidrConfigurationJSON) RawJSON() string { + return r.raw +} + +func (r LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasCidrConfiguration) implementsFirewallLegacyJhsZonelockdownConfigurations() { +} + +// The configuration target. You must set the target to `ip_range` when specifying +// an IP address range in the Zone Lockdown rule. +type LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasCidrConfigurationTarget string + +const ( + LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasCidrConfigurationTargetIPRange LegacyJhsZonelockdownConfigurationsLegacyJhsSchemasCidrConfigurationTarget = "ip_range" +) + +type LockdownDeleteResponse struct { + // The unique identifier of the Zone Lockdown rule. + ID string `json:"id"` + JSON lockdownDeleteResponseJSON `json:"-"` +} + +// lockdownDeleteResponseJSON contains the JSON metadata for the struct +// [LockdownDeleteResponse] +type lockdownDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LockdownDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r lockdownDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type LockdownNewParams struct { + Body param.Field[interface{}] `json:"body,required"` +} + +func (r LockdownNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type LockdownNewResponseEnvelope struct { + Errors []LockdownNewResponseEnvelopeErrors `json:"errors,required"` + Messages []LockdownNewResponseEnvelopeMessages `json:"messages,required"` + Result LegacyJhsZonelockdown `json:"result,required,nullable"` + // Whether the API call was successful + Success LockdownNewResponseEnvelopeSuccess `json:"success,required"` + JSON lockdownNewResponseEnvelopeJSON `json:"-"` +} + +// lockdownNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [LockdownNewResponseEnvelope] +type lockdownNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LockdownNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r lockdownNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LockdownNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON lockdownNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// lockdownNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [LockdownNewResponseEnvelopeErrors] +type lockdownNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LockdownNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r lockdownNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LockdownNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON lockdownNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// lockdownNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [LockdownNewResponseEnvelopeMessages] +type lockdownNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LockdownNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r lockdownNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LockdownNewResponseEnvelopeSuccess bool + +const ( + LockdownNewResponseEnvelopeSuccessTrue LockdownNewResponseEnvelopeSuccess = true +) + +type LockdownUpdateParams struct { + Body param.Field[interface{}] `json:"body,required"` +} + +func (r LockdownUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type LockdownUpdateResponseEnvelope struct { + Errors []LockdownUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []LockdownUpdateResponseEnvelopeMessages `json:"messages,required"` + Result LegacyJhsZonelockdown `json:"result,required,nullable"` + // Whether the API call was successful + Success LockdownUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON lockdownUpdateResponseEnvelopeJSON `json:"-"` +} + +// lockdownUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [LockdownUpdateResponseEnvelope] +type lockdownUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LockdownUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r lockdownUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LockdownUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON lockdownUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// lockdownUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [LockdownUpdateResponseEnvelopeErrors] +type lockdownUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LockdownUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r lockdownUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LockdownUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON lockdownUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// lockdownUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [LockdownUpdateResponseEnvelopeMessages] +type lockdownUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LockdownUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r lockdownUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LockdownUpdateResponseEnvelopeSuccess bool + +const ( + LockdownUpdateResponseEnvelopeSuccessTrue LockdownUpdateResponseEnvelopeSuccess = true +) + +type LockdownListParams struct { + // A string to search for in the description of existing rules. + Description param.Field[string] `query:"description"` + // A string to search for in the description of existing rules. + DescriptionSearch param.Field[string] `query:"description_search"` + // A single IP address to search for in existing rules. + IP param.Field[string] `query:"ip"` + // A single IP address range to search for in existing rules. + IPRangeSearch param.Field[string] `query:"ip_range_search"` + // A single IP address to search for in existing rules. + IPSearch param.Field[string] `query:"ip_search"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // The maximum number of results per page. You can only set the value to `1` or to + // a multiple of 5 such as `5`, `10`, `15`, or `20`. + PerPage param.Field[float64] `query:"per_page"` + // The priority of the rule to control the processing order. A lower number + // indicates higher priority. If not provided, any rules with a configured priority + // will be processed before rules without a priority. + Priority param.Field[float64] `query:"priority"` + // A single URI to search for in the list of URLs of existing rules. + URISearch param.Field[string] `query:"uri_search"` +} + +// URLQuery serializes [LockdownListParams]'s query parameters as `url.Values`. +func (r LockdownListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type LockdownDeleteResponseEnvelope struct { + Result LockdownDeleteResponse `json:"result"` + JSON lockdownDeleteResponseEnvelopeJSON `json:"-"` +} + +// lockdownDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [LockdownDeleteResponseEnvelope] +type lockdownDeleteResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LockdownDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r lockdownDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LockdownGetResponseEnvelope struct { + Errors []LockdownGetResponseEnvelopeErrors `json:"errors,required"` + Messages []LockdownGetResponseEnvelopeMessages `json:"messages,required"` + Result LegacyJhsZonelockdown `json:"result,required,nullable"` + // Whether the API call was successful + Success LockdownGetResponseEnvelopeSuccess `json:"success,required"` + JSON lockdownGetResponseEnvelopeJSON `json:"-"` +} + +// lockdownGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [LockdownGetResponseEnvelope] +type lockdownGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LockdownGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r lockdownGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LockdownGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON lockdownGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// lockdownGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [LockdownGetResponseEnvelopeErrors] +type lockdownGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LockdownGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r lockdownGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LockdownGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON lockdownGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// lockdownGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [LockdownGetResponseEnvelopeMessages] +type lockdownGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LockdownGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r lockdownGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LockdownGetResponseEnvelopeSuccess bool + +const ( + LockdownGetResponseEnvelopeSuccessTrue LockdownGetResponseEnvelopeSuccess = true +) diff --git a/firewall/lockdown_test.go b/firewall/lockdown_test.go new file mode 100644 index 00000000000..8a6d5a3c972 --- /dev/null +++ b/firewall/lockdown_test.go @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/firewall" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestLockdownNew(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("user@example.com"), + ) + _, err := client.Firewall.Lockdowns.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + firewall.LockdownNewParams{ + Body: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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 TestLockdownUpdate(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("user@example.com"), + ) + _, err := client.Firewall.Lockdowns.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "372e67954025e0ba6aaa6d586b9e0b59", + firewall.LockdownUpdateParams{ + Body: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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 TestLockdownListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Firewall.Lockdowns.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + firewall.LockdownListParams{ + Description: cloudflare.F("endpoints"), + DescriptionSearch: cloudflare.F("endpoints"), + IP: cloudflare.F("1.2.3.4"), + IPRangeSearch: cloudflare.F("1.2.3.0/16"), + IPSearch: cloudflare.F("1.2.3.4"), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(1.000000), + Priority: cloudflare.F(5.000000), + URISearch: cloudflare.F("/some/path"), + }, + ) + 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 TestLockdownDelete(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("user@example.com"), + ) + _, err := client.Firewall.Lockdowns.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "372e67954025e0ba6aaa6d586b9e0b59", + ) + 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 TestLockdownGet(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("user@example.com"), + ) + _, err := client.Firewall.Lockdowns.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "372e67954025e0ba6aaa6d586b9e0b59", + ) + 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/firewall/rule.go b/firewall/rule.go new file mode 100644 index 00000000000..8d125253a7c --- /dev/null +++ b/firewall/rule.go @@ -0,0 +1,776 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + + "github.com/cloudflare/cloudflare-go/filters" + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// 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 +} + +// 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 + return +} + +// Create one or more firewall rules. +func (r *RuleService) New(ctx context.Context, zoneIdentifier string, body RuleNewParams, opts ...option.RequestOption) (res *[]LegacyJhsFilterRule, err error) { + opts = append(r.Options[:], opts...) + var env RuleNewResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/rules", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates an existing firewall rule. +func (r *RuleService) Update(ctx context.Context, zoneIdentifier string, id string, body RuleUpdateParams, opts ...option.RequestOption) (res *LegacyJhsFilterRule, err error) { + opts = append(r.Options[:], opts...) + var env RuleUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/rules/%s", zoneIdentifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches firewall rules in a zone. You can filter the results using several +// optional parameters. +func (r *RuleService) List(ctx context.Context, zoneIdentifier string, query RuleListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[LegacyJhsFilterRule], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("zones/%s/firewall/rules", zoneIdentifier) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Fetches firewall rules in a zone. You can filter the results using several +// optional parameters. +func (r *RuleService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query RuleListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[LegacyJhsFilterRule] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) +} + +// Deletes an existing firewall rule. +func (r *RuleService) Delete(ctx context.Context, zoneIdentifier string, id string, body RuleDeleteParams, opts ...option.RequestOption) (res *LegacyJhsFilterRule, err error) { + opts = append(r.Options[:], opts...) + var env RuleDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/rules/%s", zoneIdentifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates the priority of an existing firewall rule. +func (r *RuleService) Edit(ctx context.Context, zoneIdentifier string, id string, body RuleEditParams, opts ...option.RequestOption) (res *[]LegacyJhsFilterRule, err error) { + opts = append(r.Options[:], opts...) + var env RuleEditResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/rules/%s", zoneIdentifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the details of a firewall rule. +func (r *RuleService) Get(ctx context.Context, zoneIdentifier string, id string, query RuleGetParams, opts ...option.RequestOption) (res *LegacyJhsFilterRule, err error) { + opts = append(r.Options[:], opts...) + var env RuleGetResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/rules/%s", zoneIdentifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type LegacyJhsFilterRule struct { + // The unique identifier of the firewall rule. + ID string `json:"id"` + // The action to apply to a matched request. The `log` action is only available on + // an Enterprise plan. + Action LegacyJhsFilterRuleAction `json:"action"` + // An informative summary of the firewall rule. + Description string `json:"description"` + Filter LegacyJhsFilterRuleFilter `json:"filter"` + // When true, indicates that the firewall rule is currently paused. + Paused bool `json:"paused"` + // The priority of the rule. Optional value used to define the processing order. A + // lower number indicates a higher priority. If not provided, rules with a defined + // priority will be processed before rules without a priority. + Priority float64 `json:"priority"` + Products []LegacyJhsFilterRuleProduct `json:"products"` + // A short reference tag. Allows you to select related firewall rules. + Ref string `json:"ref"` + JSON legacyJhsFilterRuleJSON `json:"-"` +} + +// legacyJhsFilterRuleJSON contains the JSON metadata for the struct +// [LegacyJhsFilterRule] +type legacyJhsFilterRuleJSON struct { + ID apijson.Field + Action apijson.Field + Description apijson.Field + Filter apijson.Field + Paused apijson.Field + Priority apijson.Field + Products apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LegacyJhsFilterRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r legacyJhsFilterRuleJSON) RawJSON() string { + return r.raw +} + +// The action to apply to a matched request. The `log` action is only available on +// an Enterprise plan. +type LegacyJhsFilterRuleAction string + +const ( + LegacyJhsFilterRuleActionBlock LegacyJhsFilterRuleAction = "block" + LegacyJhsFilterRuleActionChallenge LegacyJhsFilterRuleAction = "challenge" + LegacyJhsFilterRuleActionJsChallenge LegacyJhsFilterRuleAction = "js_challenge" + LegacyJhsFilterRuleActionManagedChallenge LegacyJhsFilterRuleAction = "managed_challenge" + LegacyJhsFilterRuleActionAllow LegacyJhsFilterRuleAction = "allow" + LegacyJhsFilterRuleActionLog LegacyJhsFilterRuleAction = "log" + LegacyJhsFilterRuleActionBypass LegacyJhsFilterRuleAction = "bypass" +) + +// Union satisfied by [filters.LegacyJhsFilter] or +// [firewall.LegacyJhsFilterRuleFilterLegacyJhsDeletedFilter]. +type LegacyJhsFilterRuleFilter interface { + implementsFirewallLegacyJhsFilterRuleFilter() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*LegacyJhsFilterRuleFilter)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(filters.LegacyJhsFilter{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LegacyJhsFilterRuleFilterLegacyJhsDeletedFilter{}), + }, + ) +} + +type LegacyJhsFilterRuleFilterLegacyJhsDeletedFilter struct { + // The unique identifier of the filter. + ID string `json:"id,required"` + // When true, indicates that the firewall rule was deleted. + Deleted bool `json:"deleted,required"` + JSON legacyJhsFilterRuleFilterLegacyJhsDeletedFilterJSON `json:"-"` +} + +// legacyJhsFilterRuleFilterLegacyJhsDeletedFilterJSON contains the JSON metadata +// for the struct [LegacyJhsFilterRuleFilterLegacyJhsDeletedFilter] +type legacyJhsFilterRuleFilterLegacyJhsDeletedFilterJSON struct { + ID apijson.Field + Deleted apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LegacyJhsFilterRuleFilterLegacyJhsDeletedFilter) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r legacyJhsFilterRuleFilterLegacyJhsDeletedFilterJSON) RawJSON() string { + return r.raw +} + +func (r LegacyJhsFilterRuleFilterLegacyJhsDeletedFilter) implementsFirewallLegacyJhsFilterRuleFilter() { +} + +// A list of products to bypass for a request when using the `bypass` action. +type LegacyJhsFilterRuleProduct string + +const ( + LegacyJhsFilterRuleProductZoneLockdown LegacyJhsFilterRuleProduct = "zoneLockdown" + LegacyJhsFilterRuleProductUABlock LegacyJhsFilterRuleProduct = "uaBlock" + LegacyJhsFilterRuleProductBic LegacyJhsFilterRuleProduct = "bic" + LegacyJhsFilterRuleProductHot LegacyJhsFilterRuleProduct = "hot" + LegacyJhsFilterRuleProductSecurityLevel LegacyJhsFilterRuleProduct = "securityLevel" + LegacyJhsFilterRuleProductRateLimit LegacyJhsFilterRuleProduct = "rateLimit" + LegacyJhsFilterRuleProductWAF LegacyJhsFilterRuleProduct = "waf" +) + +type RuleNewParams struct { + Body param.Field[interface{}] `json:"body,required"` +} + +func (r RuleNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type RuleNewResponseEnvelope struct { + Errors []RuleNewResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleNewResponseEnvelopeMessages `json:"messages,required"` + Result []LegacyJhsFilterRule `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleNewResponseEnvelopeSuccess `json:"success,required"` + ResultInfo RuleNewResponseEnvelopeResultInfo `json:"result_info"` + JSON ruleNewResponseEnvelopeJSON `json:"-"` +} + +// ruleNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleNewResponseEnvelope] +type ruleNewResponseEnvelopeJSON 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 *RuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleNewResponseEnvelopeErrors] +type ruleNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleNewResponseEnvelopeMessages] +type ruleNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleNewResponseEnvelopeSuccess bool + +const ( + RuleNewResponseEnvelopeSuccessTrue RuleNewResponseEnvelopeSuccess = true +) + +type RuleNewResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON ruleNewResponseEnvelopeResultInfoJSON `json:"-"` +} + +// ruleNewResponseEnvelopeResultInfoJSON contains the JSON metadata for the struct +// [RuleNewResponseEnvelopeResultInfo] +type ruleNewResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleNewResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type RuleUpdateParams struct { + Body param.Field[interface{}] `json:"body,required"` +} + +func (r RuleUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type RuleUpdateResponseEnvelope struct { + Errors []RuleUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleUpdateResponseEnvelopeMessages `json:"messages,required"` + Result LegacyJhsFilterRule `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON ruleUpdateResponseEnvelopeJSON `json:"-"` +} + +// ruleUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleUpdateResponseEnvelope] +type ruleUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleUpdateResponseEnvelopeErrors] +type ruleUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleUpdateResponseEnvelopeMessages] +type ruleUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleUpdateResponseEnvelopeSuccess bool + +const ( + RuleUpdateResponseEnvelopeSuccessTrue RuleUpdateResponseEnvelopeSuccess = true +) + +type RuleListParams struct { + // The action to search for. Must be an exact match. + Action param.Field[string] `query:"action"` + // A case-insensitive string to find in the description. + Description param.Field[string] `query:"description"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // When true, indicates that the firewall rule is currently paused. + Paused param.Field[bool] `query:"paused"` + // Number of firewall rules per page. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [RuleListParams]'s query parameters as `url.Values`. +func (r RuleListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type RuleDeleteParams struct { + // When true, indicates that Cloudflare should also delete the associated filter if + // there are no other firewall rules referencing the filter. + DeleteFilterIfUnused param.Field[bool] `json:"delete_filter_if_unused"` +} + +func (r RuleDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RuleDeleteResponseEnvelope struct { + Errors []RuleDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleDeleteResponseEnvelopeMessages `json:"messages,required"` + Result LegacyJhsFilterRule `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON ruleDeleteResponseEnvelopeJSON `json:"-"` +} + +// ruleDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleDeleteResponseEnvelope] +type ruleDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleDeleteResponseEnvelopeErrors] +type ruleDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleDeleteResponseEnvelopeMessages] +type ruleDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleDeleteResponseEnvelopeSuccess bool + +const ( + RuleDeleteResponseEnvelopeSuccessTrue RuleDeleteResponseEnvelopeSuccess = true +) + +type RuleEditParams struct { + Body param.Field[interface{}] `json:"body,required"` +} + +func (r RuleEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type RuleEditResponseEnvelope struct { + Errors []RuleEditResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleEditResponseEnvelopeMessages `json:"messages,required"` + Result []LegacyJhsFilterRule `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleEditResponseEnvelopeSuccess `json:"success,required"` + ResultInfo RuleEditResponseEnvelopeResultInfo `json:"result_info"` + JSON ruleEditResponseEnvelopeJSON `json:"-"` +} + +// ruleEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleEditResponseEnvelope] +type ruleEditResponseEnvelopeJSON 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 *RuleEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleEditResponseEnvelopeErrors] +type ruleEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleEditResponseEnvelopeMessages] +type ruleEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleEditResponseEnvelopeSuccess bool + +const ( + RuleEditResponseEnvelopeSuccessTrue RuleEditResponseEnvelopeSuccess = true +) + +type RuleEditResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON ruleEditResponseEnvelopeResultInfoJSON `json:"-"` +} + +// ruleEditResponseEnvelopeResultInfoJSON contains the JSON metadata for the struct +// [RuleEditResponseEnvelopeResultInfo] +type ruleEditResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleEditResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleEditResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type RuleGetParams struct { +} + +type RuleGetResponseEnvelope struct { + Errors []RuleGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleGetResponseEnvelopeMessages `json:"messages,required"` + Result LegacyJhsFilterRule `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleGetResponseEnvelopeSuccess `json:"success,required"` + JSON ruleGetResponseEnvelopeJSON `json:"-"` +} + +// ruleGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleGetResponseEnvelope] +type ruleGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleGetResponseEnvelopeErrors] +type ruleGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleGetResponseEnvelopeMessages] +type ruleGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleGetResponseEnvelopeSuccess bool + +const ( + RuleGetResponseEnvelopeSuccessTrue RuleGetResponseEnvelopeSuccess = true +) diff --git a/firewall/rule_test.go b/firewall/rule_test.go new file mode 100644 index 00000000000..e1af30c4b1f --- /dev/null +++ b/firewall/rule_test.go @@ -0,0 +1,201 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/firewall" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRuleNew(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("user@example.com"), + ) + _, err := client.Firewall.Rules.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + firewall.RuleNewParams{ + Body: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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 TestRuleUpdate(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("user@example.com"), + ) + _, err := client.Firewall.Rules.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "372e67954025e0ba6aaa6d586b9e0b60", + firewall.RuleUpdateParams{ + Body: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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 TestRuleListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Firewall.Rules.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + firewall.RuleListParams{ + Action: cloudflare.F("block"), + Description: cloudflare.F("mir"), + Page: cloudflare.F(1.000000), + Paused: cloudflare.F(false), + PerPage: cloudflare.F(5.000000), + }, + ) + 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 TestRuleDeleteWithOptionalParams(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("user@example.com"), + ) + _, err := client.Firewall.Rules.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "372e67954025e0ba6aaa6d586b9e0b60", + firewall.RuleDeleteParams{ + DeleteFilterIfUnused: cloudflare.F(true), + }, + ) + 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 TestRuleEdit(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("user@example.com"), + ) + _, err := client.Firewall.Rules.Edit( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "372e67954025e0ba6aaa6d586b9e0b60", + firewall.RuleEditParams{ + Body: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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 TestRuleGet(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("user@example.com"), + ) + _, err := client.Firewall.Rules.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "372e67954025e0ba6aaa6d586b9e0b60", + firewall.RuleGetParams{}, + ) + 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/firewall/uarule.go b/firewall/uarule.go new file mode 100644 index 00000000000..fb03ee0a6c3 --- /dev/null +++ b/firewall/uarule.go @@ -0,0 +1,618 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// UARuleService 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 [NewUARuleService] method instead. +type UARuleService struct { + Options []option.RequestOption +} + +// NewUARuleService 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 NewUARuleService(opts ...option.RequestOption) (r *UARuleService) { + r = &UARuleService{} + r.Options = opts + return +} + +// Creates a new User Agent Blocking rule in a zone. +func (r *UARuleService) New(ctx context.Context, zoneIdentifier string, body UARuleNewParams, opts ...option.RequestOption) (res *UARuleNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env UARuleNewResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/ua_rules", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates an existing User Agent Blocking rule. +func (r *UARuleService) Update(ctx context.Context, zoneIdentifier string, id string, body UARuleUpdateParams, opts ...option.RequestOption) (res *UARuleUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env UARuleUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/ua_rules/%s", zoneIdentifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches User Agent Blocking rules in a zone. You can filter the results using +// several optional parameters. +func (r *UARuleService) List(ctx context.Context, zoneIdentifier string, query UARuleListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[UARuleListResponse], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("zones/%s/firewall/ua_rules", zoneIdentifier) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Fetches User Agent Blocking rules in a zone. You can filter the results using +// several optional parameters. +func (r *UARuleService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query UARuleListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[UARuleListResponse] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) +} + +// Deletes an existing User Agent Blocking rule. +func (r *UARuleService) Delete(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *UARuleDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env UARuleDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/ua_rules/%s", zoneIdentifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the details of a User Agent Blocking rule. +func (r *UARuleService) Get(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *UARuleGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env UARuleGetResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/ua_rules/%s", zoneIdentifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [firewall.UARuleNewResponseUnknown] or [shared.UnionString]. +type UARuleNewResponse interface { + ImplementsFirewallUARuleNewResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*UARuleNewResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [firewall.UARuleUpdateResponseUnknown] or +// [shared.UnionString]. +type UARuleUpdateResponse interface { + ImplementsFirewallUARuleUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*UARuleUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type UARuleListResponse struct { + // The unique identifier of the User Agent Blocking rule. + ID string `json:"id"` + // The configuration object for the current rule. + Configuration UARuleListResponseConfiguration `json:"configuration"` + // An informative summary of the rule. + Description string `json:"description"` + // The action to apply to a matched request. + Mode UARuleListResponseMode `json:"mode"` + // When true, indicates that the rule is currently paused. + Paused bool `json:"paused"` + JSON uaRuleListResponseJSON `json:"-"` +} + +// uaRuleListResponseJSON contains the JSON metadata for the struct +// [UARuleListResponse] +type uaRuleListResponseJSON struct { + ID apijson.Field + Configuration apijson.Field + Description apijson.Field + Mode apijson.Field + Paused apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UARuleListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uaRuleListResponseJSON) RawJSON() string { + return r.raw +} + +// The configuration object for the current rule. +type UARuleListResponseConfiguration struct { + // The configuration target for this rule. You must set the target to `ua` for User + // Agent Blocking rules. + Target string `json:"target"` + // The exact user agent string to match. This value will be compared to the + // received `User-Agent` HTTP header value. + Value string `json:"value"` + JSON uaRuleListResponseConfigurationJSON `json:"-"` +} + +// uaRuleListResponseConfigurationJSON contains the JSON metadata for the struct +// [UARuleListResponseConfiguration] +type uaRuleListResponseConfigurationJSON struct { + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UARuleListResponseConfiguration) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uaRuleListResponseConfigurationJSON) RawJSON() string { + return r.raw +} + +// The action to apply to a matched request. +type UARuleListResponseMode string + +const ( + UARuleListResponseModeBlock UARuleListResponseMode = "block" + UARuleListResponseModeChallenge UARuleListResponseMode = "challenge" + UARuleListResponseModeJsChallenge UARuleListResponseMode = "js_challenge" + UARuleListResponseModeManagedChallenge UARuleListResponseMode = "managed_challenge" +) + +type UARuleDeleteResponse struct { + // The unique identifier of the User Agent Blocking rule. + ID string `json:"id"` + JSON uaRuleDeleteResponseJSON `json:"-"` +} + +// uaRuleDeleteResponseJSON contains the JSON metadata for the struct +// [UARuleDeleteResponse] +type uaRuleDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UARuleDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uaRuleDeleteResponseJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [firewall.UARuleGetResponseUnknown] or [shared.UnionString]. +type UARuleGetResponse interface { + ImplementsFirewallUARuleGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*UARuleGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type UARuleNewParams struct { + Body param.Field[interface{}] `json:"body,required"` +} + +func (r UARuleNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type UARuleNewResponseEnvelope struct { + Errors []UARuleNewResponseEnvelopeErrors `json:"errors,required"` + Messages []UARuleNewResponseEnvelopeMessages `json:"messages,required"` + Result UARuleNewResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success UARuleNewResponseEnvelopeSuccess `json:"success,required"` + JSON uaRuleNewResponseEnvelopeJSON `json:"-"` +} + +// uaRuleNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [UARuleNewResponseEnvelope] +type uaRuleNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UARuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uaRuleNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type UARuleNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON uaRuleNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// uaRuleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [UARuleNewResponseEnvelopeErrors] +type uaRuleNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UARuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uaRuleNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type UARuleNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON uaRuleNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// uaRuleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [UARuleNewResponseEnvelopeMessages] +type uaRuleNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UARuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uaRuleNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type UARuleNewResponseEnvelopeSuccess bool + +const ( + UARuleNewResponseEnvelopeSuccessTrue UARuleNewResponseEnvelopeSuccess = true +) + +type UARuleUpdateParams struct { + Body param.Field[interface{}] `json:"body,required"` +} + +func (r UARuleUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type UARuleUpdateResponseEnvelope struct { + Errors []UARuleUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []UARuleUpdateResponseEnvelopeMessages `json:"messages,required"` + Result UARuleUpdateResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success UARuleUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON uaRuleUpdateResponseEnvelopeJSON `json:"-"` +} + +// uaRuleUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [UARuleUpdateResponseEnvelope] +type uaRuleUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UARuleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uaRuleUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type UARuleUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON uaRuleUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// uaRuleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [UARuleUpdateResponseEnvelopeErrors] +type uaRuleUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UARuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uaRuleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type UARuleUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON uaRuleUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// uaRuleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [UARuleUpdateResponseEnvelopeMessages] +type uaRuleUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UARuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uaRuleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type UARuleUpdateResponseEnvelopeSuccess bool + +const ( + UARuleUpdateResponseEnvelopeSuccessTrue UARuleUpdateResponseEnvelopeSuccess = true +) + +type UARuleListParams struct { + // A string to search for in the description of existing rules. + Description param.Field[string] `query:"description"` + // A string to search for in the description of existing rules. + DescriptionSearch param.Field[string] `query:"description_search"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // The maximum number of results per page. You can only set the value to `1` or to + // a multiple of 5 such as `5`, `10`, `15`, or `20`. + PerPage param.Field[float64] `query:"per_page"` + // A string to search for in the user agent values of existing rules. + UASearch param.Field[string] `query:"ua_search"` +} + +// URLQuery serializes [UARuleListParams]'s query parameters as `url.Values`. +func (r UARuleListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type UARuleDeleteResponseEnvelope struct { + Errors []UARuleDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []UARuleDeleteResponseEnvelopeMessages `json:"messages,required"` + Result UARuleDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success UARuleDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON uaRuleDeleteResponseEnvelopeJSON `json:"-"` +} + +// uaRuleDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [UARuleDeleteResponseEnvelope] +type uaRuleDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UARuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uaRuleDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type UARuleDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON uaRuleDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// uaRuleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [UARuleDeleteResponseEnvelopeErrors] +type uaRuleDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UARuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uaRuleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type UARuleDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON uaRuleDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// uaRuleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [UARuleDeleteResponseEnvelopeMessages] +type uaRuleDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UARuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uaRuleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type UARuleDeleteResponseEnvelopeSuccess bool + +const ( + UARuleDeleteResponseEnvelopeSuccessTrue UARuleDeleteResponseEnvelopeSuccess = true +) + +type UARuleGetResponseEnvelope struct { + Errors []UARuleGetResponseEnvelopeErrors `json:"errors,required"` + Messages []UARuleGetResponseEnvelopeMessages `json:"messages,required"` + Result UARuleGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success UARuleGetResponseEnvelopeSuccess `json:"success,required"` + JSON uaRuleGetResponseEnvelopeJSON `json:"-"` +} + +// uaRuleGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [UARuleGetResponseEnvelope] +type uaRuleGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UARuleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uaRuleGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type UARuleGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON uaRuleGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// uaRuleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [UARuleGetResponseEnvelopeErrors] +type uaRuleGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UARuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uaRuleGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type UARuleGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON uaRuleGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// uaRuleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [UARuleGetResponseEnvelopeMessages] +type uaRuleGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UARuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r uaRuleGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type UARuleGetResponseEnvelopeSuccess bool + +const ( + UARuleGetResponseEnvelopeSuccessTrue UARuleGetResponseEnvelopeSuccess = true +) diff --git a/firewall/uarule_test.go b/firewall/uarule_test.go new file mode 100644 index 00000000000..658740f50a3 --- /dev/null +++ b/firewall/uarule_test.go @@ -0,0 +1,166 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/firewall" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestUARuleNew(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("user@example.com"), + ) + _, err := client.Firewall.UARules.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + firewall.UARuleNewParams{ + Body: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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 TestUARuleUpdate(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("user@example.com"), + ) + _, err := client.Firewall.UARules.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "372e67954025e0ba6aaa6d586b9e0b59", + firewall.UARuleUpdateParams{ + Body: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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 TestUARuleListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Firewall.UARules.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + firewall.UARuleListParams{ + Description: cloudflare.F("abusive"), + DescriptionSearch: cloudflare.F("abusive"), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(1.000000), + UASearch: cloudflare.F("Safari"), + }, + ) + 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 TestUARuleDelete(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("user@example.com"), + ) + _, err := client.Firewall.UARules.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "372e67954025e0ba6aaa6d586b9e0b59", + ) + 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 TestUARuleGet(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("user@example.com"), + ) + _, err := client.Firewall.UARules.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "372e67954025e0ba6aaa6d586b9e0b59", + ) + 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/firewall/waf.go b/firewall/waf.go new file mode 100644 index 00000000000..6abdceada96 --- /dev/null +++ b/firewall/waf.go @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// WAFService 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 [NewWAFService] method instead. +type WAFService struct { + Options []option.RequestOption + Overrides *WAFOverrideService + Packages *WAFPackageService +} + +// NewWAFService 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 NewWAFService(opts ...option.RequestOption) (r *WAFService) { + r = &WAFService{} + r.Options = opts + r.Overrides = NewWAFOverrideService(opts...) + r.Packages = NewWAFPackageService(opts...) + return +} diff --git a/firewall/wafoverride.go b/firewall/wafoverride.go new file mode 100644 index 00000000000..b9779f22c7e --- /dev/null +++ b/firewall/wafoverride.go @@ -0,0 +1,567 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" +) + +// WAFOverrideService 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 [NewWAFOverrideService] method +// instead. +type WAFOverrideService struct { + Options []option.RequestOption +} + +// NewWAFOverrideService 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 NewWAFOverrideService(opts ...option.RequestOption) (r *WAFOverrideService) { + r = &WAFOverrideService{} + r.Options = opts + return +} + +// Creates a URI-based WAF override for a zone. +// +// **Note:** Applies only to the +// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). +func (r *WAFOverrideService) New(ctx context.Context, zoneIdentifier string, body WAFOverrideNewParams, opts ...option.RequestOption) (res *LegacyJhsOverride, err error) { + opts = append(r.Options[:], opts...) + var env WAFOverrideNewResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/waf/overrides", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates an existing URI-based WAF override. +// +// **Note:** Applies only to the +// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). +func (r *WAFOverrideService) Update(ctx context.Context, zoneIdentifier string, id string, body WAFOverrideUpdateParams, opts ...option.RequestOption) (res *LegacyJhsOverride, err error) { + opts = append(r.Options[:], opts...) + var env WAFOverrideUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/waf/overrides/%s", zoneIdentifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the URI-based WAF overrides in a zone. +// +// **Note:** Applies only to the +// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). +func (r *WAFOverrideService) List(ctx context.Context, zoneIdentifier string, query WAFOverrideListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[LegacyJhsOverride], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("zones/%s/firewall/waf/overrides", zoneIdentifier) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Fetches the URI-based WAF overrides in a zone. +// +// **Note:** Applies only to the +// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). +func (r *WAFOverrideService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query WAFOverrideListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[LegacyJhsOverride] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) +} + +// Deletes an existing URI-based WAF override. +// +// **Note:** Applies only to the +// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). +func (r *WAFOverrideService) Delete(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *WAFOverrideDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env WAFOverrideDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/waf/overrides/%s", zoneIdentifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the details of a URI-based WAF override. +// +// **Note:** Applies only to the +// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). +func (r *WAFOverrideService) Get(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *LegacyJhsOverride, err error) { + opts = append(r.Options[:], opts...) + var env WAFOverrideGetResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/waf/overrides/%s", zoneIdentifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type LegacyJhsOverride struct { + // The unique identifier of the WAF override. + ID string `json:"id"` + // An informative summary of the current URI-based WAF override. + Description string `json:"description,nullable"` + // An object that allows you to enable or disable WAF rule groups for the current + // WAF override. Each key of this object must be the ID of a WAF rule group, and + // each value must be a valid WAF action (usually `default` or `disable`). When + // creating a new URI-based WAF override, you must provide a `groups` object or a + // `rules` object. + Groups map[string]interface{} `json:"groups"` + // When true, indicates that the WAF package is currently paused. + Paused bool `json:"paused"` + // The relative priority of the current URI-based WAF override when multiple + // overrides match a single URL. A lower number indicates higher priority. Higher + // priority overrides may overwrite values set by lower priority overrides. + Priority float64 `json:"priority"` + // Specifies that, when a WAF rule matches, its configured action will be replaced + // by the action configured in this object. + RewriteAction LegacyJhsOverrideRewriteAction `json:"rewrite_action"` + // An object that allows you to override the action of specific WAF rules. Each key + // of this object must be the ID of a WAF rule, and each value must be a valid WAF + // action. Unless you are disabling a rule, ensure that you also enable the rule + // group that this WAF rule belongs to. When creating a new URI-based WAF override, + // you must provide a `groups` object or a `rules` object. + Rules map[string]LegacyJhsOverrideRule `json:"rules"` + // The URLs to include in the current WAF override. You can use wildcards. Each + // entered URL will be escaped before use, which means you can only use simple + // wildcard patterns. + URLs []string `json:"urls"` + JSON legacyJhsOverrideJSON `json:"-"` +} + +// legacyJhsOverrideJSON contains the JSON metadata for the struct +// [LegacyJhsOverride] +type legacyJhsOverrideJSON struct { + ID apijson.Field + Description apijson.Field + Groups apijson.Field + Paused apijson.Field + Priority apijson.Field + RewriteAction apijson.Field + Rules apijson.Field + URLs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LegacyJhsOverride) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r legacyJhsOverrideJSON) RawJSON() string { + return r.raw +} + +// Specifies that, when a WAF rule matches, its configured action will be replaced +// by the action configured in this object. +type LegacyJhsOverrideRewriteAction struct { + // The WAF rule action to apply. + Block LegacyJhsOverrideRewriteActionBlock `json:"block"` + Challenge interface{} `json:"challenge"` + Default interface{} `json:"default"` + // The WAF rule action to apply. + Disable LegacyJhsOverrideRewriteActionDisable `json:"disable"` + Simulate interface{} `json:"simulate"` + JSON legacyJhsOverrideRewriteActionJSON `json:"-"` +} + +// legacyJhsOverrideRewriteActionJSON contains the JSON metadata for the struct +// [LegacyJhsOverrideRewriteAction] +type legacyJhsOverrideRewriteActionJSON struct { + Block apijson.Field + Challenge apijson.Field + Default apijson.Field + Disable apijson.Field + Simulate apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LegacyJhsOverrideRewriteAction) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r legacyJhsOverrideRewriteActionJSON) RawJSON() string { + return r.raw +} + +// The WAF rule action to apply. +type LegacyJhsOverrideRewriteActionBlock string + +const ( + LegacyJhsOverrideRewriteActionBlockChallenge LegacyJhsOverrideRewriteActionBlock = "challenge" + LegacyJhsOverrideRewriteActionBlockBlock LegacyJhsOverrideRewriteActionBlock = "block" + LegacyJhsOverrideRewriteActionBlockSimulate LegacyJhsOverrideRewriteActionBlock = "simulate" + LegacyJhsOverrideRewriteActionBlockDisable LegacyJhsOverrideRewriteActionBlock = "disable" + LegacyJhsOverrideRewriteActionBlockDefault LegacyJhsOverrideRewriteActionBlock = "default" +) + +// The WAF rule action to apply. +type LegacyJhsOverrideRewriteActionDisable string + +const ( + LegacyJhsOverrideRewriteActionDisableChallenge LegacyJhsOverrideRewriteActionDisable = "challenge" + LegacyJhsOverrideRewriteActionDisableBlock LegacyJhsOverrideRewriteActionDisable = "block" + LegacyJhsOverrideRewriteActionDisableSimulate LegacyJhsOverrideRewriteActionDisable = "simulate" + LegacyJhsOverrideRewriteActionDisableDisable LegacyJhsOverrideRewriteActionDisable = "disable" + LegacyJhsOverrideRewriteActionDisableDefault LegacyJhsOverrideRewriteActionDisable = "default" +) + +// The WAF rule action to apply. +type LegacyJhsOverrideRule string + +const ( + LegacyJhsOverrideRuleChallenge LegacyJhsOverrideRule = "challenge" + LegacyJhsOverrideRuleBlock LegacyJhsOverrideRule = "block" + LegacyJhsOverrideRuleSimulate LegacyJhsOverrideRule = "simulate" + LegacyJhsOverrideRuleDisable LegacyJhsOverrideRule = "disable" + LegacyJhsOverrideRuleDefault LegacyJhsOverrideRule = "default" +) + +type WAFOverrideDeleteResponse struct { + // The unique identifier of the WAF override. + ID string `json:"id"` + JSON wafOverrideDeleteResponseJSON `json:"-"` +} + +// wafOverrideDeleteResponseJSON contains the JSON metadata for the struct +// [WAFOverrideDeleteResponse] +type wafOverrideDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFOverrideDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafOverrideDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type WAFOverrideNewParams struct { + Body param.Field[interface{}] `json:"body,required"` +} + +func (r WAFOverrideNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type WAFOverrideNewResponseEnvelope struct { + Errors []WAFOverrideNewResponseEnvelopeErrors `json:"errors,required"` + Messages []WAFOverrideNewResponseEnvelopeMessages `json:"messages,required"` + Result LegacyJhsOverride `json:"result,required,nullable"` + // Whether the API call was successful + Success WAFOverrideNewResponseEnvelopeSuccess `json:"success,required"` + JSON wafOverrideNewResponseEnvelopeJSON `json:"-"` +} + +// wafOverrideNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [WAFOverrideNewResponseEnvelope] +type wafOverrideNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFOverrideNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafOverrideNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WAFOverrideNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON wafOverrideNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// wafOverrideNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [WAFOverrideNewResponseEnvelopeErrors] +type wafOverrideNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFOverrideNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafOverrideNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WAFOverrideNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON wafOverrideNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// wafOverrideNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [WAFOverrideNewResponseEnvelopeMessages] +type wafOverrideNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFOverrideNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafOverrideNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type WAFOverrideNewResponseEnvelopeSuccess bool + +const ( + WAFOverrideNewResponseEnvelopeSuccessTrue WAFOverrideNewResponseEnvelopeSuccess = true +) + +type WAFOverrideUpdateParams struct { + Body param.Field[interface{}] `json:"body,required"` +} + +func (r WAFOverrideUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type WAFOverrideUpdateResponseEnvelope struct { + Errors []WAFOverrideUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []WAFOverrideUpdateResponseEnvelopeMessages `json:"messages,required"` + Result LegacyJhsOverride `json:"result,required,nullable"` + // Whether the API call was successful + Success WAFOverrideUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON wafOverrideUpdateResponseEnvelopeJSON `json:"-"` +} + +// wafOverrideUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [WAFOverrideUpdateResponseEnvelope] +type wafOverrideUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFOverrideUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafOverrideUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WAFOverrideUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON wafOverrideUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// wafOverrideUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [WAFOverrideUpdateResponseEnvelopeErrors] +type wafOverrideUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFOverrideUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafOverrideUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WAFOverrideUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON wafOverrideUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// wafOverrideUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [WAFOverrideUpdateResponseEnvelopeMessages] +type wafOverrideUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFOverrideUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafOverrideUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type WAFOverrideUpdateResponseEnvelopeSuccess bool + +const ( + WAFOverrideUpdateResponseEnvelopeSuccessTrue WAFOverrideUpdateResponseEnvelopeSuccess = true +) + +type WAFOverrideListParams struct { + // The page number of paginated results. + Page param.Field[float64] `query:"page"` + // The number of WAF overrides per page. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [WAFOverrideListParams]'s query parameters as `url.Values`. +func (r WAFOverrideListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type WAFOverrideDeleteResponseEnvelope struct { + Result WAFOverrideDeleteResponse `json:"result"` + JSON wafOverrideDeleteResponseEnvelopeJSON `json:"-"` +} + +// wafOverrideDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [WAFOverrideDeleteResponseEnvelope] +type wafOverrideDeleteResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFOverrideDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafOverrideDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WAFOverrideGetResponseEnvelope struct { + Errors []WAFOverrideGetResponseEnvelopeErrors `json:"errors,required"` + Messages []WAFOverrideGetResponseEnvelopeMessages `json:"messages,required"` + Result LegacyJhsOverride `json:"result,required,nullable"` + // Whether the API call was successful + Success WAFOverrideGetResponseEnvelopeSuccess `json:"success,required"` + JSON wafOverrideGetResponseEnvelopeJSON `json:"-"` +} + +// wafOverrideGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [WAFOverrideGetResponseEnvelope] +type wafOverrideGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFOverrideGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafOverrideGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WAFOverrideGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON wafOverrideGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// wafOverrideGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [WAFOverrideGetResponseEnvelopeErrors] +type wafOverrideGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFOverrideGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafOverrideGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WAFOverrideGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON wafOverrideGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// wafOverrideGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [WAFOverrideGetResponseEnvelopeMessages] +type wafOverrideGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFOverrideGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafOverrideGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type WAFOverrideGetResponseEnvelopeSuccess bool + +const ( + WAFOverrideGetResponseEnvelopeSuccessTrue WAFOverrideGetResponseEnvelopeSuccess = true +) diff --git a/firewall/wafoverride_test.go b/firewall/wafoverride_test.go new file mode 100644 index 00000000000..06749e99f8f --- /dev/null +++ b/firewall/wafoverride_test.go @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/firewall" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestWAFOverrideNew(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("user@example.com"), + ) + _, err := client.Firewall.WAF.Overrides.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + firewall.WAFOverrideNewParams{ + Body: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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 TestWAFOverrideUpdate(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("user@example.com"), + ) + _, err := client.Firewall.WAF.Overrides.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "de677e5818985db1285d0e80225f06e5", + firewall.WAFOverrideUpdateParams{ + Body: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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 TestWAFOverrideListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Firewall.WAF.Overrides.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + firewall.WAFOverrideListParams{ + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(5.000000), + }, + ) + 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 TestWAFOverrideDelete(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("user@example.com"), + ) + _, err := client.Firewall.WAF.Overrides.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "de677e5818985db1285d0e80225f06e5", + ) + 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 TestWAFOverrideGet(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("user@example.com"), + ) + _, err := client.Firewall.WAF.Overrides.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "de677e5818985db1285d0e80225f06e5", + ) + 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/firewall/wafpackage.go b/firewall/wafpackage.go new file mode 100644 index 00000000000..68f83c89ec0 --- /dev/null +++ b/firewall/wafpackage.go @@ -0,0 +1,647 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// WAFPackageService 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 [NewWAFPackageService] method instead. +type WAFPackageService struct { + Options []option.RequestOption + Groups *WAFPackageGroupService + Rules *WAFPackageRuleService +} + +// NewWAFPackageService 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 NewWAFPackageService(opts ...option.RequestOption) (r *WAFPackageService) { + r = &WAFPackageService{} + r.Options = opts + r.Groups = NewWAFPackageGroupService(opts...) + r.Rules = NewWAFPackageRuleService(opts...) + return +} + +// Fetches WAF packages for a zone. +// +// **Note:** Applies only to the +// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). +func (r *WAFPackageService) List(ctx context.Context, zoneIdentifier string, query WAFPackageListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[WAFPackageListResponse], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("zones/%s/firewall/waf/packages", zoneIdentifier) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Fetches WAF packages for a zone. +// +// **Note:** Applies only to the +// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). +func (r *WAFPackageService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query WAFPackageListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[WAFPackageListResponse] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) +} + +// Fetches the details of a WAF package. +// +// **Note:** Applies only to the +// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). +func (r *WAFPackageService) Get(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *WAFPackageGetResponse, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("zones/%s/firewall/waf/packages/%s", zoneIdentifier, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return +} + +// Union satisfied by +// [firewall.WAFPackageListResponseLegacyJhsAPIResponseCollection] or +// [firewall.WAFPackageListResponseObject]. +type WAFPackageListResponse interface { + implementsFirewallWAFPackageListResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WAFPackageListResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WAFPackageListResponseLegacyJhsAPIResponseCollection{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WAFPackageListResponseObject{}), + }, + ) +} + +type WAFPackageListResponseLegacyJhsAPIResponseCollection struct { + Errors []WAFPackageListResponseLegacyJhsAPIResponseCollectionError `json:"errors,required"` + Messages []WAFPackageListResponseLegacyJhsAPIResponseCollectionMessage `json:"messages,required"` + Result WAFPackageListResponseLegacyJhsAPIResponseCollectionResult `json:"result,required,nullable"` + // Whether the API call was successful + Success WAFPackageListResponseLegacyJhsAPIResponseCollectionSuccess `json:"success,required"` + ResultInfo WAFPackageListResponseLegacyJhsAPIResponseCollectionResultInfo `json:"result_info"` + JSON wafPackageListResponseLegacyJhsAPIResponseCollectionJSON `json:"-"` +} + +// wafPackageListResponseLegacyJhsAPIResponseCollectionJSON contains the JSON +// metadata for the struct [WAFPackageListResponseLegacyJhsAPIResponseCollection] +type wafPackageListResponseLegacyJhsAPIResponseCollectionJSON 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 *WAFPackageListResponseLegacyJhsAPIResponseCollection) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageListResponseLegacyJhsAPIResponseCollectionJSON) RawJSON() string { + return r.raw +} + +func (r WAFPackageListResponseLegacyJhsAPIResponseCollection) implementsFirewallWAFPackageListResponse() { +} + +type WAFPackageListResponseLegacyJhsAPIResponseCollectionError struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON wafPackageListResponseLegacyJhsAPIResponseCollectionErrorJSON `json:"-"` +} + +// wafPackageListResponseLegacyJhsAPIResponseCollectionErrorJSON contains the JSON +// metadata for the struct +// [WAFPackageListResponseLegacyJhsAPIResponseCollectionError] +type wafPackageListResponseLegacyJhsAPIResponseCollectionErrorJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageListResponseLegacyJhsAPIResponseCollectionError) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageListResponseLegacyJhsAPIResponseCollectionErrorJSON) RawJSON() string { + return r.raw +} + +type WAFPackageListResponseLegacyJhsAPIResponseCollectionMessage struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON wafPackageListResponseLegacyJhsAPIResponseCollectionMessageJSON `json:"-"` +} + +// wafPackageListResponseLegacyJhsAPIResponseCollectionMessageJSON contains the +// JSON metadata for the struct +// [WAFPackageListResponseLegacyJhsAPIResponseCollectionMessage] +type wafPackageListResponseLegacyJhsAPIResponseCollectionMessageJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageListResponseLegacyJhsAPIResponseCollectionMessage) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageListResponseLegacyJhsAPIResponseCollectionMessageJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by +// [firewall.WAFPackageListResponseLegacyJhsAPIResponseCollectionResultUnknown], +// [firewall.WAFPackageListResponseLegacyJhsAPIResponseCollectionResultArray] or +// [shared.UnionString]. +type WAFPackageListResponseLegacyJhsAPIResponseCollectionResult interface { + ImplementsFirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResult() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WAFPackageListResponseLegacyJhsAPIResponseCollectionResult)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WAFPackageListResponseLegacyJhsAPIResponseCollectionResultArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type WAFPackageListResponseLegacyJhsAPIResponseCollectionResultArray []interface{} + +func (r WAFPackageListResponseLegacyJhsAPIResponseCollectionResultArray) ImplementsFirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResult() { +} + +// Whether the API call was successful +type WAFPackageListResponseLegacyJhsAPIResponseCollectionSuccess bool + +const ( + WAFPackageListResponseLegacyJhsAPIResponseCollectionSuccessTrue WAFPackageListResponseLegacyJhsAPIResponseCollectionSuccess = true +) + +type WAFPackageListResponseLegacyJhsAPIResponseCollectionResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON wafPackageListResponseLegacyJhsAPIResponseCollectionResultInfoJSON `json:"-"` +} + +// wafPackageListResponseLegacyJhsAPIResponseCollectionResultInfoJSON contains the +// JSON metadata for the struct +// [WAFPackageListResponseLegacyJhsAPIResponseCollectionResultInfo] +type wafPackageListResponseLegacyJhsAPIResponseCollectionResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageListResponseLegacyJhsAPIResponseCollectionResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageListResponseLegacyJhsAPIResponseCollectionResultInfoJSON) RawJSON() string { + return r.raw +} + +type WAFPackageListResponseObject struct { + Result []WAFPackageListResponseObjectResult `json:"result"` + JSON wafPackageListResponseObjectJSON `json:"-"` +} + +// wafPackageListResponseObjectJSON contains the JSON metadata for the struct +// [WAFPackageListResponseObject] +type wafPackageListResponseObjectJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageListResponseObject) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageListResponseObjectJSON) RawJSON() string { + return r.raw +} + +func (r WAFPackageListResponseObject) implementsFirewallWAFPackageListResponse() {} + +// Union satisfied by +// [firewall.WAFPackageListResponseObjectResultLegacyJhsPackageDefinition] or +// [firewall.WAFPackageListResponseObjectResultLegacyJhsAnomalyPackage]. +type WAFPackageListResponseObjectResult interface { + implementsFirewallWAFPackageListResponseObjectResult() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WAFPackageListResponseObjectResult)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WAFPackageListResponseObjectResultLegacyJhsPackageDefinition{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WAFPackageListResponseObjectResultLegacyJhsAnomalyPackage{}), + }, + ) +} + +type WAFPackageListResponseObjectResultLegacyJhsPackageDefinition struct { + // The unique identifier of a WAF package. + ID string `json:"id,required"` + // A summary of the purpose/function of the WAF package. + Description string `json:"description,required"` + // The mode that defines how rules within the package are evaluated during the + // course of a request. When a package uses anomaly detection mode (`anomaly` + // value), each rule is given a score when triggered. If the total score of all + // triggered rules exceeds the sensitivity defined in the WAF package, the action + // configured in the package will be performed. Traditional detection mode + // (`traditional` value) will decide the action to take when it is triggered by the + // request. If multiple rules are triggered, the action providing the highest + // protection will be applied (for example, a 'block' action will win over a + // 'challenge' action). + DetectionMode WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionMode `json:"detection_mode,required"` + // The name of the WAF package. + Name string `json:"name,required"` + // Identifier + ZoneID string `json:"zone_id,required"` + // When set to `active`, indicates that the WAF package will be applied to the + // zone. + Status WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionStatus `json:"status"` + JSON wafPackageListResponseObjectResultLegacyJhsPackageDefinitionJSON `json:"-"` +} + +// wafPackageListResponseObjectResultLegacyJhsPackageDefinitionJSON contains the +// JSON metadata for the struct +// [WAFPackageListResponseObjectResultLegacyJhsPackageDefinition] +type wafPackageListResponseObjectResultLegacyJhsPackageDefinitionJSON struct { + ID apijson.Field + Description apijson.Field + DetectionMode apijson.Field + Name apijson.Field + ZoneID apijson.Field + Status apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageListResponseObjectResultLegacyJhsPackageDefinition) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageListResponseObjectResultLegacyJhsPackageDefinitionJSON) RawJSON() string { + return r.raw +} + +func (r WAFPackageListResponseObjectResultLegacyJhsPackageDefinition) implementsFirewallWAFPackageListResponseObjectResult() { +} + +// The mode that defines how rules within the package are evaluated during the +// course of a request. When a package uses anomaly detection mode (`anomaly` +// value), each rule is given a score when triggered. If the total score of all +// triggered rules exceeds the sensitivity defined in the WAF package, the action +// configured in the package will be performed. Traditional detection mode +// (`traditional` value) will decide the action to take when it is triggered by the +// request. If multiple rules are triggered, the action providing the highest +// protection will be applied (for example, a 'block' action will win over a +// 'challenge' action). +type WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionMode string + +const ( + WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionModeAnomaly WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionMode = "anomaly" + WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionModeTraditional WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionMode = "traditional" +) + +// When set to `active`, indicates that the WAF package will be applied to the +// zone. +type WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionStatus string + +const ( + WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionStatusActive WAFPackageListResponseObjectResultLegacyJhsPackageDefinitionStatus = "active" +) + +type WAFPackageListResponseObjectResultLegacyJhsAnomalyPackage struct { + // The unique identifier of a WAF package. + ID string `json:"id,required"` + // A summary of the purpose/function of the WAF package. + Description string `json:"description,required"` + // When a WAF package uses anomaly detection, each rule is given a score when + // triggered. If the total score of all triggered rules exceeds the sensitivity + // defined on the WAF package, the action defined on the package will be taken. + DetectionMode WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionMode `json:"detection_mode,required"` + // The name of the WAF package. + Name string `json:"name,required"` + // Identifier + ZoneID string `json:"zone_id,required"` + // The default action performed by the rules in the WAF package. + ActionMode WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionMode `json:"action_mode"` + // The sensitivity of the WAF package. + Sensitivity WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity `json:"sensitivity"` + // When set to `active`, indicates that the WAF package will be applied to the + // zone. + Status WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageStatus `json:"status"` + JSON wafPackageListResponseObjectResultLegacyJhsAnomalyPackageJSON `json:"-"` +} + +// wafPackageListResponseObjectResultLegacyJhsAnomalyPackageJSON contains the JSON +// metadata for the struct +// [WAFPackageListResponseObjectResultLegacyJhsAnomalyPackage] +type wafPackageListResponseObjectResultLegacyJhsAnomalyPackageJSON struct { + ID apijson.Field + Description apijson.Field + DetectionMode apijson.Field + Name apijson.Field + ZoneID apijson.Field + ActionMode apijson.Field + Sensitivity apijson.Field + Status apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageListResponseObjectResultLegacyJhsAnomalyPackage) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageListResponseObjectResultLegacyJhsAnomalyPackageJSON) RawJSON() string { + return r.raw +} + +func (r WAFPackageListResponseObjectResultLegacyJhsAnomalyPackage) implementsFirewallWAFPackageListResponseObjectResult() { +} + +// When a WAF package uses anomaly detection, each rule is given a score when +// triggered. If the total score of all triggered rules exceeds the sensitivity +// defined on the WAF package, the action defined on the package will be taken. +type WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionMode string + +const ( + WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionModeAnomaly WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionMode = "anomaly" + WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionModeTraditional WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionMode = "traditional" +) + +// The default action performed by the rules in the WAF package. +type WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionMode string + +const ( + WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionModeSimulate WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionMode = "simulate" + WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionModeBlock WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionMode = "block" + WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionModeChallenge WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionMode = "challenge" +) + +// The sensitivity of the WAF package. +type WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity string + +const ( + WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivityHigh WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity = "high" + WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivityMedium WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity = "medium" + WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivityLow WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity = "low" + WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivityOff WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity = "off" +) + +// When set to `active`, indicates that the WAF package will be applied to the +// zone. +type WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageStatus string + +const ( + WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageStatusActive WAFPackageListResponseObjectResultLegacyJhsAnomalyPackageStatus = "active" +) + +// Union satisfied by [firewall.WAFPackageGetResponseLegacyJhsAPIResponseSingle] or +// [firewall.WAFPackageGetResponseObject]. +type WAFPackageGetResponse interface { + implementsFirewallWAFPackageGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WAFPackageGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WAFPackageGetResponseLegacyJhsAPIResponseSingle{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WAFPackageGetResponseObject{}), + }, + ) +} + +type WAFPackageGetResponseLegacyJhsAPIResponseSingle struct { + Errors []WAFPackageGetResponseLegacyJhsAPIResponseSingleError `json:"errors,required"` + Messages []WAFPackageGetResponseLegacyJhsAPIResponseSingleMessage `json:"messages,required"` + Result WAFPackageGetResponseLegacyJhsAPIResponseSingleResult `json:"result,required,nullable"` + // Whether the API call was successful + Success WAFPackageGetResponseLegacyJhsAPIResponseSingleSuccess `json:"success,required"` + JSON wafPackageGetResponseLegacyJhsAPIResponseSingleJSON `json:"-"` +} + +// wafPackageGetResponseLegacyJhsAPIResponseSingleJSON contains the JSON metadata +// for the struct [WAFPackageGetResponseLegacyJhsAPIResponseSingle] +type wafPackageGetResponseLegacyJhsAPIResponseSingleJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageGetResponseLegacyJhsAPIResponseSingle) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageGetResponseLegacyJhsAPIResponseSingleJSON) RawJSON() string { + return r.raw +} + +func (r WAFPackageGetResponseLegacyJhsAPIResponseSingle) implementsFirewallWAFPackageGetResponse() {} + +type WAFPackageGetResponseLegacyJhsAPIResponseSingleError struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON wafPackageGetResponseLegacyJhsAPIResponseSingleErrorJSON `json:"-"` +} + +// wafPackageGetResponseLegacyJhsAPIResponseSingleErrorJSON contains the JSON +// metadata for the struct [WAFPackageGetResponseLegacyJhsAPIResponseSingleError] +type wafPackageGetResponseLegacyJhsAPIResponseSingleErrorJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageGetResponseLegacyJhsAPIResponseSingleError) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageGetResponseLegacyJhsAPIResponseSingleErrorJSON) RawJSON() string { + return r.raw +} + +type WAFPackageGetResponseLegacyJhsAPIResponseSingleMessage struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON wafPackageGetResponseLegacyJhsAPIResponseSingleMessageJSON `json:"-"` +} + +// wafPackageGetResponseLegacyJhsAPIResponseSingleMessageJSON contains the JSON +// metadata for the struct [WAFPackageGetResponseLegacyJhsAPIResponseSingleMessage] +type wafPackageGetResponseLegacyJhsAPIResponseSingleMessageJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageGetResponseLegacyJhsAPIResponseSingleMessage) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageGetResponseLegacyJhsAPIResponseSingleMessageJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by +// [firewall.WAFPackageGetResponseLegacyJhsAPIResponseSingleResultUnknown] or +// [shared.UnionString]. +type WAFPackageGetResponseLegacyJhsAPIResponseSingleResult interface { + ImplementsFirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleResult() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WAFPackageGetResponseLegacyJhsAPIResponseSingleResult)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Whether the API call was successful +type WAFPackageGetResponseLegacyJhsAPIResponseSingleSuccess bool + +const ( + WAFPackageGetResponseLegacyJhsAPIResponseSingleSuccessTrue WAFPackageGetResponseLegacyJhsAPIResponseSingleSuccess = true +) + +type WAFPackageGetResponseObject struct { + Result interface{} `json:"result"` + JSON wafPackageGetResponseObjectJSON `json:"-"` +} + +// wafPackageGetResponseObjectJSON contains the JSON metadata for the struct +// [WAFPackageGetResponseObject] +type wafPackageGetResponseObjectJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageGetResponseObject) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageGetResponseObjectJSON) RawJSON() string { + return r.raw +} + +func (r WAFPackageGetResponseObject) implementsFirewallWAFPackageGetResponse() {} + +type WAFPackageListParams struct { + // The direction used to sort returned packages. + Direction param.Field[WAFPackageListParamsDirection] `query:"direction"` + // When set to `all`, all the search requirements must match. When set to `any`, + // only one of the search requirements has to match. + Match param.Field[WAFPackageListParamsMatch] `query:"match"` + // The field used to sort returned packages. + Order param.Field[WAFPackageListParamsOrder] `query:"order"` + // The page number of paginated results. + Page param.Field[float64] `query:"page"` + // The number of packages per page. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [WAFPackageListParams]'s query parameters as `url.Values`. +func (r WAFPackageListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// The direction used to sort returned packages. +type WAFPackageListParamsDirection string + +const ( + WAFPackageListParamsDirectionAsc WAFPackageListParamsDirection = "asc" + WAFPackageListParamsDirectionDesc WAFPackageListParamsDirection = "desc" +) + +// When set to `all`, all the search requirements must match. When set to `any`, +// only one of the search requirements has to match. +type WAFPackageListParamsMatch string + +const ( + WAFPackageListParamsMatchAny WAFPackageListParamsMatch = "any" + WAFPackageListParamsMatchAll WAFPackageListParamsMatch = "all" +) + +// The field used to sort returned packages. +type WAFPackageListParamsOrder string + +const ( + WAFPackageListParamsOrderName WAFPackageListParamsOrder = "name" +) diff --git a/firewall/wafpackage_test.go b/firewall/wafpackage_test.go new file mode 100644 index 00000000000..ef7308b0455 --- /dev/null +++ b/firewall/wafpackage_test.go @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/firewall" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestWAFPackageListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Firewall.WAF.Packages.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + firewall.WAFPackageListParams{ + Direction: cloudflare.F(firewall.WAFPackageListParamsDirectionDesc), + Match: cloudflare.F(firewall.WAFPackageListParamsMatchAny), + Order: cloudflare.F(firewall.WAFPackageListParamsOrderName), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(5.000000), + }, + ) + 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 TestWAFPackageGet(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("user@example.com"), + ) + _, err := client.Firewall.WAF.Packages.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "a25a9a7e9c00afc1fb2e0245519d725b", + ) + 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/firewall/wafpackagegroup.go b/firewall/wafpackagegroup.go new file mode 100644 index 00000000000..16ba17c9c98 --- /dev/null +++ b/firewall/wafpackagegroup.go @@ -0,0 +1,462 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// WAFPackageGroupService 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 [NewWAFPackageGroupService] method +// instead. +type WAFPackageGroupService struct { + Options []option.RequestOption +} + +// NewWAFPackageGroupService 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 NewWAFPackageGroupService(opts ...option.RequestOption) (r *WAFPackageGroupService) { + r = &WAFPackageGroupService{} + r.Options = opts + return +} + +// Fetches the WAF rule groups in a WAF package. +// +// **Note:** Applies only to the +// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). +func (r *WAFPackageGroupService) List(ctx context.Context, packageID string, params WAFPackageGroupListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[WAFManagedRulesSchemasGroup], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("zones/%s/firewall/waf/packages/%s/groups", params.ZoneID, packageID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Fetches the WAF rule groups in a WAF package. +// +// **Note:** Applies only to the +// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). +func (r *WAFPackageGroupService) ListAutoPaging(ctx context.Context, packageID string, params WAFPackageGroupListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[WAFManagedRulesSchemasGroup] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, packageID, params, opts...)) +} + +// Updates a WAF rule group. You can update the state (`mode` parameter) of a rule +// group. +// +// **Note:** Applies only to the +// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). +func (r *WAFPackageGroupService) Edit(ctx context.Context, packageID string, groupID string, params WAFPackageGroupEditParams, opts ...option.RequestOption) (res *WAFPackageGroupEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env WAFPackageGroupEditResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/waf/packages/%s/groups/%s", params.ZoneID, packageID, groupID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the details of a WAF rule group. +// +// **Note:** Applies only to the +// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). +func (r *WAFPackageGroupService) Get(ctx context.Context, packageID string, groupID string, query WAFPackageGroupGetParams, opts ...option.RequestOption) (res *WAFPackageGroupGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env WAFPackageGroupGetResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/waf/packages/%s/groups/%s", query.ZoneID, packageID, groupID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type WAFManagedRulesSchemasGroup struct { + // The unique identifier of the rule group. + ID string `json:"id,required"` + // An informative summary of what the rule group does. + Description string `json:"description,required,nullable"` + // The state of the rules contained in the rule group. When `on`, the rules in the + // group are configurable/usable. + Mode WAFManagedRulesSchemasGroupMode `json:"mode,required"` + // The name of the rule group. + Name string `json:"name,required"` + // The number of rules in the current rule group. + RulesCount float64 `json:"rules_count,required"` + // The available states for the rule group. + AllowedModes []WAFManagedRulesSchemasGroupAllowedMode `json:"allowed_modes"` + // The number of rules within the group that have been modified from their default + // configuration. + ModifiedRulesCount float64 `json:"modified_rules_count"` + // The unique identifier of a WAF package. + PackageID string `json:"package_id"` + JSON wafManagedRulesSchemasGroupJSON `json:"-"` +} + +// wafManagedRulesSchemasGroupJSON contains the JSON metadata for the struct +// [WAFManagedRulesSchemasGroup] +type wafManagedRulesSchemasGroupJSON struct { + ID apijson.Field + Description apijson.Field + Mode apijson.Field + Name apijson.Field + RulesCount apijson.Field + AllowedModes apijson.Field + ModifiedRulesCount apijson.Field + PackageID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFManagedRulesSchemasGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafManagedRulesSchemasGroupJSON) RawJSON() string { + return r.raw +} + +// The state of the rules contained in the rule group. When `on`, the rules in the +// group are configurable/usable. +type WAFManagedRulesSchemasGroupMode string + +const ( + WAFManagedRulesSchemasGroupModeOn WAFManagedRulesSchemasGroupMode = "on" + WAFManagedRulesSchemasGroupModeOff WAFManagedRulesSchemasGroupMode = "off" +) + +// The state of the rules contained in the rule group. When `on`, the rules in the +// group are configurable/usable. +type WAFManagedRulesSchemasGroupAllowedMode string + +const ( + WAFManagedRulesSchemasGroupAllowedModeOn WAFManagedRulesSchemasGroupAllowedMode = "on" + WAFManagedRulesSchemasGroupAllowedModeOff WAFManagedRulesSchemasGroupAllowedMode = "off" +) + +// Union satisfied by [firewall.WAFPackageGroupEditResponseUnknown], +// [firewall.WAFPackageGroupEditResponseArray] or [shared.UnionString]. +type WAFPackageGroupEditResponse interface { + ImplementsFirewallWAFPackageGroupEditResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WAFPackageGroupEditResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WAFPackageGroupEditResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type WAFPackageGroupEditResponseArray []interface{} + +func (r WAFPackageGroupEditResponseArray) ImplementsFirewallWAFPackageGroupEditResponse() {} + +// Union satisfied by [firewall.WAFPackageGroupGetResponseUnknown], +// [firewall.WAFPackageGroupGetResponseArray] or [shared.UnionString]. +type WAFPackageGroupGetResponse interface { + ImplementsFirewallWAFPackageGroupGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WAFPackageGroupGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WAFPackageGroupGetResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type WAFPackageGroupGetResponseArray []interface{} + +func (r WAFPackageGroupGetResponseArray) ImplementsFirewallWAFPackageGroupGetResponse() {} + +type WAFPackageGroupListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // The direction used to sort returned rule groups. + Direction param.Field[WAFPackageGroupListParamsDirection] `query:"direction"` + // When set to `all`, all the search requirements must match. When set to `any`, + // only one of the search requirements has to match. + Match param.Field[WAFPackageGroupListParamsMatch] `query:"match"` + // The state of the rules contained in the rule group. When `on`, the rules in the + // group are configurable/usable. + Mode param.Field[WAFPackageGroupListParamsMode] `query:"mode"` + // The field used to sort returned rule groups. + Order param.Field[WAFPackageGroupListParamsOrder] `query:"order"` + // The page number of paginated results. + Page param.Field[float64] `query:"page"` + // The number of rule groups per page. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [WAFPackageGroupListParams]'s query parameters as +// `url.Values`. +func (r WAFPackageGroupListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// The direction used to sort returned rule groups. +type WAFPackageGroupListParamsDirection string + +const ( + WAFPackageGroupListParamsDirectionAsc WAFPackageGroupListParamsDirection = "asc" + WAFPackageGroupListParamsDirectionDesc WAFPackageGroupListParamsDirection = "desc" +) + +// When set to `all`, all the search requirements must match. When set to `any`, +// only one of the search requirements has to match. +type WAFPackageGroupListParamsMatch string + +const ( + WAFPackageGroupListParamsMatchAny WAFPackageGroupListParamsMatch = "any" + WAFPackageGroupListParamsMatchAll WAFPackageGroupListParamsMatch = "all" +) + +// The state of the rules contained in the rule group. When `on`, the rules in the +// group are configurable/usable. +type WAFPackageGroupListParamsMode string + +const ( + WAFPackageGroupListParamsModeOn WAFPackageGroupListParamsMode = "on" + WAFPackageGroupListParamsModeOff WAFPackageGroupListParamsMode = "off" +) + +// The field used to sort returned rule groups. +type WAFPackageGroupListParamsOrder string + +const ( + WAFPackageGroupListParamsOrderMode WAFPackageGroupListParamsOrder = "mode" + WAFPackageGroupListParamsOrderRulesCount WAFPackageGroupListParamsOrder = "rules_count" +) + +type WAFPackageGroupEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // The state of the rules contained in the rule group. When `on`, the rules in the + // group are configurable/usable. + Mode param.Field[WAFPackageGroupEditParamsMode] `json:"mode"` +} + +func (r WAFPackageGroupEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The state of the rules contained in the rule group. When `on`, the rules in the +// group are configurable/usable. +type WAFPackageGroupEditParamsMode string + +const ( + WAFPackageGroupEditParamsModeOn WAFPackageGroupEditParamsMode = "on" + WAFPackageGroupEditParamsModeOff WAFPackageGroupEditParamsMode = "off" +) + +type WAFPackageGroupEditResponseEnvelope struct { + Errors []WAFPackageGroupEditResponseEnvelopeErrors `json:"errors,required"` + Messages []WAFPackageGroupEditResponseEnvelopeMessages `json:"messages,required"` + Result WAFPackageGroupEditResponse `json:"result,required"` + // Whether the API call was successful + Success WAFPackageGroupEditResponseEnvelopeSuccess `json:"success,required"` + JSON wafPackageGroupEditResponseEnvelopeJSON `json:"-"` +} + +// wafPackageGroupEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [WAFPackageGroupEditResponseEnvelope] +type wafPackageGroupEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageGroupEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageGroupEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WAFPackageGroupEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON wafPackageGroupEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// wafPackageGroupEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [WAFPackageGroupEditResponseEnvelopeErrors] +type wafPackageGroupEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageGroupEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageGroupEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WAFPackageGroupEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON wafPackageGroupEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// wafPackageGroupEditResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [WAFPackageGroupEditResponseEnvelopeMessages] +type wafPackageGroupEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageGroupEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageGroupEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type WAFPackageGroupEditResponseEnvelopeSuccess bool + +const ( + WAFPackageGroupEditResponseEnvelopeSuccessTrue WAFPackageGroupEditResponseEnvelopeSuccess = true +) + +type WAFPackageGroupGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type WAFPackageGroupGetResponseEnvelope struct { + Errors []WAFPackageGroupGetResponseEnvelopeErrors `json:"errors,required"` + Messages []WAFPackageGroupGetResponseEnvelopeMessages `json:"messages,required"` + Result WAFPackageGroupGetResponse `json:"result,required"` + // Whether the API call was successful + Success WAFPackageGroupGetResponseEnvelopeSuccess `json:"success,required"` + JSON wafPackageGroupGetResponseEnvelopeJSON `json:"-"` +} + +// wafPackageGroupGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [WAFPackageGroupGetResponseEnvelope] +type wafPackageGroupGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageGroupGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageGroupGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WAFPackageGroupGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON wafPackageGroupGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// wafPackageGroupGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [WAFPackageGroupGetResponseEnvelopeErrors] +type wafPackageGroupGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageGroupGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageGroupGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WAFPackageGroupGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON wafPackageGroupGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// wafPackageGroupGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [WAFPackageGroupGetResponseEnvelopeMessages] +type wafPackageGroupGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageGroupGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageGroupGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type WAFPackageGroupGetResponseEnvelopeSuccess bool + +const ( + WAFPackageGroupGetResponseEnvelopeSuccessTrue WAFPackageGroupGetResponseEnvelopeSuccess = true +) diff --git a/firewall/wafpackagegroup_test.go b/firewall/wafpackagegroup_test.go new file mode 100644 index 00000000000..6f4ae25c1dd --- /dev/null +++ b/firewall/wafpackagegroup_test.go @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/firewall" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestWAFPackageGroupListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Firewall.WAF.Packages.Groups.List( + context.TODO(), + "a25a9a7e9c00afc1fb2e0245519d725b", + firewall.WAFPackageGroupListParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Direction: cloudflare.F(firewall.WAFPackageGroupListParamsDirectionDesc), + Match: cloudflare.F(firewall.WAFPackageGroupListParamsMatchAny), + Mode: cloudflare.F(firewall.WAFPackageGroupListParamsModeOn), + Order: cloudflare.F(firewall.WAFPackageGroupListParamsOrderMode), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(5.000000), + }, + ) + 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 TestWAFPackageGroupEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Firewall.WAF.Packages.Groups.Edit( + context.TODO(), + "a25a9a7e9c00afc1fb2e0245519d725b", + "a25a9a7e9c00afc1fb2e0245519d725b", + firewall.WAFPackageGroupEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Mode: cloudflare.F(firewall.WAFPackageGroupEditParamsModeOn), + }, + ) + 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 TestWAFPackageGroupGet(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("user@example.com"), + ) + _, err := client.Firewall.WAF.Packages.Groups.Get( + context.TODO(), + "a25a9a7e9c00afc1fb2e0245519d725b", + "a25a9a7e9c00afc1fb2e0245519d725b", + firewall.WAFPackageGroupGetParams{ + ZoneID: cloudflare.F("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/firewall/wafpackagerule.go b/firewall/wafpackagerule.go new file mode 100644 index 00000000000..f122f305584 --- /dev/null +++ b/firewall/wafpackagerule.go @@ -0,0 +1,1042 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// WAFPackageRuleService 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 [NewWAFPackageRuleService] method +// instead. +type WAFPackageRuleService struct { + Options []option.RequestOption +} + +// NewWAFPackageRuleService 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 NewWAFPackageRuleService(opts ...option.RequestOption) (r *WAFPackageRuleService) { + r = &WAFPackageRuleService{} + r.Options = opts + return +} + +// Fetches WAF rules in a WAF package. +// +// **Note:** Applies only to the +// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). +func (r *WAFPackageRuleService) List(ctx context.Context, packageID string, params WAFPackageRuleListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[WAFManagedRulesRule], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("zones/%s/firewall/waf/packages/%s/rules", params.ZoneID, packageID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Fetches WAF rules in a WAF package. +// +// **Note:** Applies only to the +// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). +func (r *WAFPackageRuleService) ListAutoPaging(ctx context.Context, packageID string, params WAFPackageRuleListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[WAFManagedRulesRule] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, packageID, params, opts...)) +} + +// Updates a WAF rule. You can only update the mode/action of the rule. +// +// **Note:** Applies only to the +// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). +func (r *WAFPackageRuleService) Edit(ctx context.Context, packageID string, ruleID string, params WAFPackageRuleEditParams, opts ...option.RequestOption) (res *WAFPackageRuleEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env WAFPackageRuleEditResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/waf/packages/%s/rules/%s", params.ZoneID, packageID, ruleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the details of a WAF rule in a WAF package. +// +// **Note:** Applies only to the +// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). +func (r *WAFPackageRuleService) Get(ctx context.Context, packageID string, ruleID string, query WAFPackageRuleGetParams, opts ...option.RequestOption) (res *WAFPackageRuleGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env WAFPackageRuleGetResponseEnvelope + path := fmt.Sprintf("zones/%s/firewall/waf/packages/%s/rules/%s", query.ZoneID, packageID, ruleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// When triggered, anomaly detection WAF rules contribute to an overall threat +// score that will determine if a request is considered malicious. You can +// configure the total scoring threshold through the 'sensitivity' property of the +// WAF package. +// +// Union satisfied by [firewall.WAFManagedRulesRuleWAFManagedRulesAnomalyRule], +// [firewall.WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRule] or +// [firewall.WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRule]. +type WAFManagedRulesRule interface { + implementsFirewallWAFManagedRulesRule() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WAFManagedRulesRule)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WAFManagedRulesRuleWAFManagedRulesAnomalyRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRule{}), + }, + ) +} + +// When triggered, anomaly detection WAF rules contribute to an overall threat +// score that will determine if a request is considered malicious. You can +// configure the total scoring threshold through the 'sensitivity' property of the +// WAF package. +type WAFManagedRulesRuleWAFManagedRulesAnomalyRule struct { + // The unique identifier of the WAF rule. + ID string `json:"id,required"` + // Defines the available modes for the current WAF rule. Applies to anomaly + // detection WAF rules. + AllowedModes []WAFManagedRulesRuleWAFManagedRulesAnomalyRuleAllowedMode `json:"allowed_modes,required"` + // The public description of the WAF rule. + Description string `json:"description,required"` + // The rule group to which the current WAF rule belongs. + Group WAFManagedRulesRuleWAFManagedRulesAnomalyRuleGroup `json:"group,required"` + // When set to `on`, the current WAF rule will be used when evaluating the request. + // Applies to anomaly detection WAF rules. + Mode WAFManagedRulesRuleWAFManagedRulesAnomalyRuleMode `json:"mode,required"` + // The unique identifier of a WAF package. + PackageID string `json:"package_id,required"` + // The order in which the individual WAF rule is executed within its rule group. + Priority string `json:"priority,required"` + JSON wafManagedRulesRuleWAFManagedRulesAnomalyRuleJSON `json:"-"` +} + +// wafManagedRulesRuleWAFManagedRulesAnomalyRuleJSON contains the JSON metadata for +// the struct [WAFManagedRulesRuleWAFManagedRulesAnomalyRule] +type wafManagedRulesRuleWAFManagedRulesAnomalyRuleJSON struct { + ID apijson.Field + AllowedModes apijson.Field + Description apijson.Field + Group apijson.Field + Mode apijson.Field + PackageID apijson.Field + Priority apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFManagedRulesRuleWAFManagedRulesAnomalyRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafManagedRulesRuleWAFManagedRulesAnomalyRuleJSON) RawJSON() string { + return r.raw +} + +func (r WAFManagedRulesRuleWAFManagedRulesAnomalyRule) implementsFirewallWAFManagedRulesRule() {} + +// When set to `on`, the current WAF rule will be used when evaluating the request. +// Applies to anomaly detection WAF rules. +type WAFManagedRulesRuleWAFManagedRulesAnomalyRuleAllowedMode string + +const ( + WAFManagedRulesRuleWAFManagedRulesAnomalyRuleAllowedModeOn WAFManagedRulesRuleWAFManagedRulesAnomalyRuleAllowedMode = "on" + WAFManagedRulesRuleWAFManagedRulesAnomalyRuleAllowedModeOff WAFManagedRulesRuleWAFManagedRulesAnomalyRuleAllowedMode = "off" +) + +// The rule group to which the current WAF rule belongs. +type WAFManagedRulesRuleWAFManagedRulesAnomalyRuleGroup struct { + // The unique identifier of the rule group. + ID string `json:"id"` + // The name of the rule group. + Name string `json:"name"` + JSON wafManagedRulesRuleWAFManagedRulesAnomalyRuleGroupJSON `json:"-"` +} + +// wafManagedRulesRuleWAFManagedRulesAnomalyRuleGroupJSON contains the JSON +// metadata for the struct [WAFManagedRulesRuleWAFManagedRulesAnomalyRuleGroup] +type wafManagedRulesRuleWAFManagedRulesAnomalyRuleGroupJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFManagedRulesRuleWAFManagedRulesAnomalyRuleGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafManagedRulesRuleWAFManagedRulesAnomalyRuleGroupJSON) RawJSON() string { + return r.raw +} + +// When set to `on`, the current WAF rule will be used when evaluating the request. +// Applies to anomaly detection WAF rules. +type WAFManagedRulesRuleWAFManagedRulesAnomalyRuleMode string + +const ( + WAFManagedRulesRuleWAFManagedRulesAnomalyRuleModeOn WAFManagedRulesRuleWAFManagedRulesAnomalyRuleMode = "on" + WAFManagedRulesRuleWAFManagedRulesAnomalyRuleModeOff WAFManagedRulesRuleWAFManagedRulesAnomalyRuleMode = "off" +) + +// When triggered, traditional WAF rules cause the firewall to immediately act upon +// the request based on the configuration of the rule. A 'deny' rule will +// immediately respond to the request based on the configured rule action/mode (for +// example, 'block') and no other rules will be processed. +type WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRule struct { + // The unique identifier of the WAF rule. + ID string `json:"id,required"` + // The list of possible actions of the WAF rule when it is triggered. + AllowedModes []WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedMode `json:"allowed_modes,required"` + // The default action/mode of a rule. + DefaultMode WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultMode `json:"default_mode,required"` + // The public description of the WAF rule. + Description string `json:"description,required"` + // The rule group to which the current WAF rule belongs. + Group WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleGroup `json:"group,required"` + // The action that the current WAF rule will perform when triggered. Applies to + // traditional (deny) WAF rules. + Mode WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleMode `json:"mode,required"` + // The unique identifier of a WAF package. + PackageID string `json:"package_id,required"` + // The order in which the individual WAF rule is executed within its rule group. + Priority string `json:"priority,required"` + JSON wafManagedRulesRuleWAFManagedRulesTraditionalDenyRuleJSON `json:"-"` +} + +// wafManagedRulesRuleWAFManagedRulesTraditionalDenyRuleJSON contains the JSON +// metadata for the struct [WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRule] +type wafManagedRulesRuleWAFManagedRulesTraditionalDenyRuleJSON struct { + ID apijson.Field + AllowedModes apijson.Field + DefaultMode apijson.Field + Description apijson.Field + Group apijson.Field + Mode apijson.Field + PackageID apijson.Field + Priority apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafManagedRulesRuleWAFManagedRulesTraditionalDenyRuleJSON) RawJSON() string { + return r.raw +} + +func (r WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRule) implementsFirewallWAFManagedRulesRule() { +} + +// The action that the current WAF rule will perform when triggered. Applies to +// traditional (deny) WAF rules. +type WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedMode string + +const ( + WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedModeDefault WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedMode = "default" + WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedModeDisable WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedMode = "disable" + WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedModeSimulate WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedMode = "simulate" + WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedModeBlock WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedMode = "block" + WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedModeChallenge WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleAllowedMode = "challenge" +) + +// The default action/mode of a rule. +type WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultMode string + +const ( + WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultModeDisable WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultMode = "disable" + WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultModeSimulate WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultMode = "simulate" + WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultModeBlock WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultMode = "block" + WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultModeChallenge WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleDefaultMode = "challenge" +) + +// The rule group to which the current WAF rule belongs. +type WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleGroup struct { + // The unique identifier of the rule group. + ID string `json:"id"` + // The name of the rule group. + Name string `json:"name"` + JSON wafManagedRulesRuleWAFManagedRulesTraditionalDenyRuleGroupJSON `json:"-"` +} + +// wafManagedRulesRuleWAFManagedRulesTraditionalDenyRuleGroupJSON contains the JSON +// metadata for the struct +// [WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleGroup] +type wafManagedRulesRuleWAFManagedRulesTraditionalDenyRuleGroupJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafManagedRulesRuleWAFManagedRulesTraditionalDenyRuleGroupJSON) RawJSON() string { + return r.raw +} + +// The action that the current WAF rule will perform when triggered. Applies to +// traditional (deny) WAF rules. +type WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleMode string + +const ( + WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleModeDefault WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleMode = "default" + WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleModeDisable WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleMode = "disable" + WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleModeSimulate WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleMode = "simulate" + WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleModeBlock WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleMode = "block" + WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleModeChallenge WAFManagedRulesRuleWAFManagedRulesTraditionalDenyRuleMode = "challenge" +) + +// When triggered, traditional WAF rules cause the firewall to immediately act on +// the request based on the rule configuration. An 'allow' rule will immediately +// allow the request and no other rules will be processed. +type WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRule struct { + // The unique identifier of the WAF rule. + ID string `json:"id,required"` + // Defines the available modes for the current WAF rule. + AllowedModes []WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleAllowedMode `json:"allowed_modes,required"` + // The public description of the WAF rule. + Description string `json:"description,required"` + // The rule group to which the current WAF rule belongs. + Group WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleGroup `json:"group,required"` + // When set to `on`, the current rule will be used when evaluating the request. + // Applies to traditional (allow) WAF rules. + Mode WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleMode `json:"mode,required"` + // The unique identifier of a WAF package. + PackageID string `json:"package_id,required"` + // The order in which the individual WAF rule is executed within its rule group. + Priority string `json:"priority,required"` + JSON wafManagedRulesRuleWAFManagedRulesTraditionalAllowRuleJSON `json:"-"` +} + +// wafManagedRulesRuleWAFManagedRulesTraditionalAllowRuleJSON contains the JSON +// metadata for the struct [WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRule] +type wafManagedRulesRuleWAFManagedRulesTraditionalAllowRuleJSON struct { + ID apijson.Field + AllowedModes apijson.Field + Description apijson.Field + Group apijson.Field + Mode apijson.Field + PackageID apijson.Field + Priority apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafManagedRulesRuleWAFManagedRulesTraditionalAllowRuleJSON) RawJSON() string { + return r.raw +} + +func (r WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRule) implementsFirewallWAFManagedRulesRule() { +} + +// When set to `on`, the current rule will be used when evaluating the request. +// Applies to traditional (allow) WAF rules. +type WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleAllowedMode string + +const ( + WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleAllowedModeOn WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleAllowedMode = "on" + WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleAllowedModeOff WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleAllowedMode = "off" +) + +// The rule group to which the current WAF rule belongs. +type WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleGroup struct { + // The unique identifier of the rule group. + ID string `json:"id"` + // The name of the rule group. + Name string `json:"name"` + JSON wafManagedRulesRuleWAFManagedRulesTraditionalAllowRuleGroupJSON `json:"-"` +} + +// wafManagedRulesRuleWAFManagedRulesTraditionalAllowRuleGroupJSON contains the +// JSON metadata for the struct +// [WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleGroup] +type wafManagedRulesRuleWAFManagedRulesTraditionalAllowRuleGroupJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafManagedRulesRuleWAFManagedRulesTraditionalAllowRuleGroupJSON) RawJSON() string { + return r.raw +} + +// When set to `on`, the current rule will be used when evaluating the request. +// Applies to traditional (allow) WAF rules. +type WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleMode string + +const ( + WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleModeOn WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleMode = "on" + WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleModeOff WAFManagedRulesRuleWAFManagedRulesTraditionalAllowRuleMode = "off" +) + +// When triggered, anomaly detection WAF rules contribute to an overall threat +// score that will determine if a request is considered malicious. You can +// configure the total scoring threshold through the 'sensitivity' property of the +// WAF package. +// +// Union satisfied by +// [firewall.WAFPackageRuleEditResponseWAFManagedRulesAnomalyRule], +// [firewall.WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRule] or +// [firewall.WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRule]. +type WAFPackageRuleEditResponse interface { + implementsFirewallWAFPackageRuleEditResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WAFPackageRuleEditResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WAFPackageRuleEditResponseWAFManagedRulesAnomalyRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRule{}), + }, + ) +} + +// When triggered, anomaly detection WAF rules contribute to an overall threat +// score that will determine if a request is considered malicious. You can +// configure the total scoring threshold through the 'sensitivity' property of the +// WAF package. +type WAFPackageRuleEditResponseWAFManagedRulesAnomalyRule struct { + // The unique identifier of the WAF rule. + ID string `json:"id,required"` + // Defines the available modes for the current WAF rule. Applies to anomaly + // detection WAF rules. + AllowedModes []WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedMode `json:"allowed_modes,required"` + // The public description of the WAF rule. + Description string `json:"description,required"` + // The rule group to which the current WAF rule belongs. + Group WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroup `json:"group,required"` + // When set to `on`, the current WAF rule will be used when evaluating the request. + // Applies to anomaly detection WAF rules. + Mode WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleMode `json:"mode,required"` + // The unique identifier of a WAF package. + PackageID string `json:"package_id,required"` + // The order in which the individual WAF rule is executed within its rule group. + Priority string `json:"priority,required"` + JSON wafPackageRuleEditResponseWAFManagedRulesAnomalyRuleJSON `json:"-"` +} + +// wafPackageRuleEditResponseWAFManagedRulesAnomalyRuleJSON contains the JSON +// metadata for the struct [WAFPackageRuleEditResponseWAFManagedRulesAnomalyRule] +type wafPackageRuleEditResponseWAFManagedRulesAnomalyRuleJSON struct { + ID apijson.Field + AllowedModes apijson.Field + Description apijson.Field + Group apijson.Field + Mode apijson.Field + PackageID apijson.Field + Priority apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageRuleEditResponseWAFManagedRulesAnomalyRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageRuleEditResponseWAFManagedRulesAnomalyRuleJSON) RawJSON() string { + return r.raw +} + +func (r WAFPackageRuleEditResponseWAFManagedRulesAnomalyRule) implementsFirewallWAFPackageRuleEditResponse() { +} + +// When set to `on`, the current WAF rule will be used when evaluating the request. +// Applies to anomaly detection WAF rules. +type WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedMode string + +const ( + WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedModeOn WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedMode = "on" + WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedModeOff WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedMode = "off" +) + +// The rule group to which the current WAF rule belongs. +type WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroup struct { + // The unique identifier of the rule group. + ID string `json:"id"` + // The name of the rule group. + Name string `json:"name"` + JSON wafPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroupJSON `json:"-"` +} + +// wafPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroupJSON contains the JSON +// metadata for the struct +// [WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroup] +type wafPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroupJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroupJSON) RawJSON() string { + return r.raw +} + +// When set to `on`, the current WAF rule will be used when evaluating the request. +// Applies to anomaly detection WAF rules. +type WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleMode string + +const ( + WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleModeOn WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleMode = "on" + WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleModeOff WAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleMode = "off" +) + +// When triggered, traditional WAF rules cause the firewall to immediately act upon +// the request based on the configuration of the rule. A 'deny' rule will +// immediately respond to the request based on the configured rule action/mode (for +// example, 'block') and no other rules will be processed. +type WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRule struct { + // The unique identifier of the WAF rule. + ID string `json:"id,required"` + // The list of possible actions of the WAF rule when it is triggered. + AllowedModes []WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedMode `json:"allowed_modes,required"` + // The default action/mode of a rule. + DefaultMode WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultMode `json:"default_mode,required"` + // The public description of the WAF rule. + Description string `json:"description,required"` + // The rule group to which the current WAF rule belongs. + Group WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroup `json:"group,required"` + // The action that the current WAF rule will perform when triggered. Applies to + // traditional (deny) WAF rules. + Mode WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleMode `json:"mode,required"` + // The unique identifier of a WAF package. + PackageID string `json:"package_id,required"` + // The order in which the individual WAF rule is executed within its rule group. + Priority string `json:"priority,required"` + JSON wafPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleJSON `json:"-"` +} + +// wafPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleJSON contains the +// JSON metadata for the struct +// [WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRule] +type wafPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleJSON struct { + ID apijson.Field + AllowedModes apijson.Field + DefaultMode apijson.Field + Description apijson.Field + Group apijson.Field + Mode apijson.Field + PackageID apijson.Field + Priority apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleJSON) RawJSON() string { + return r.raw +} + +func (r WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRule) implementsFirewallWAFPackageRuleEditResponse() { +} + +// The action that the current WAF rule will perform when triggered. Applies to +// traditional (deny) WAF rules. +type WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedMode string + +const ( + WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedModeDefault WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "default" + WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedModeDisable WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "disable" + WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedModeSimulate WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "simulate" + WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedModeBlock WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "block" + WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedModeChallenge WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "challenge" +) + +// The default action/mode of a rule. +type WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultMode string + +const ( + WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultModeDisable WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultMode = "disable" + WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultModeSimulate WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultMode = "simulate" + WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultModeBlock WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultMode = "block" + WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultModeChallenge WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultMode = "challenge" +) + +// The rule group to which the current WAF rule belongs. +type WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroup struct { + // The unique identifier of the rule group. + ID string `json:"id"` + // The name of the rule group. + Name string `json:"name"` + JSON wafPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroupJSON `json:"-"` +} + +// wafPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroupJSON contains +// the JSON metadata for the struct +// [WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroup] +type wafPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroupJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroupJSON) RawJSON() string { + return r.raw +} + +// The action that the current WAF rule will perform when triggered. Applies to +// traditional (deny) WAF rules. +type WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleMode string + +const ( + WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleModeDefault WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleMode = "default" + WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleModeDisable WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleMode = "disable" + WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleModeSimulate WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleMode = "simulate" + WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleModeBlock WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleMode = "block" + WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleModeChallenge WAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleMode = "challenge" +) + +// When triggered, traditional WAF rules cause the firewall to immediately act on +// the request based on the rule configuration. An 'allow' rule will immediately +// allow the request and no other rules will be processed. +type WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRule struct { + // The unique identifier of the WAF rule. + ID string `json:"id,required"` + // Defines the available modes for the current WAF rule. + AllowedModes []WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleAllowedMode `json:"allowed_modes,required"` + // The public description of the WAF rule. + Description string `json:"description,required"` + // The rule group to which the current WAF rule belongs. + Group WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroup `json:"group,required"` + // When set to `on`, the current rule will be used when evaluating the request. + // Applies to traditional (allow) WAF rules. + Mode WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleMode `json:"mode,required"` + // The unique identifier of a WAF package. + PackageID string `json:"package_id,required"` + // The order in which the individual WAF rule is executed within its rule group. + Priority string `json:"priority,required"` + JSON wafPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleJSON `json:"-"` +} + +// wafPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleJSON contains the +// JSON metadata for the struct +// [WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRule] +type wafPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleJSON struct { + ID apijson.Field + AllowedModes apijson.Field + Description apijson.Field + Group apijson.Field + Mode apijson.Field + PackageID apijson.Field + Priority apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleJSON) RawJSON() string { + return r.raw +} + +func (r WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRule) implementsFirewallWAFPackageRuleEditResponse() { +} + +// When set to `on`, the current rule will be used when evaluating the request. +// Applies to traditional (allow) WAF rules. +type WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleAllowedMode string + +const ( + WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleAllowedModeOn WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleAllowedMode = "on" + WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleAllowedModeOff WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleAllowedMode = "off" +) + +// The rule group to which the current WAF rule belongs. +type WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroup struct { + // The unique identifier of the rule group. + ID string `json:"id"` + // The name of the rule group. + Name string `json:"name"` + JSON wafPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroupJSON `json:"-"` +} + +// wafPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroupJSON contains +// the JSON metadata for the struct +// [WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroup] +type wafPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroupJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroupJSON) RawJSON() string { + return r.raw +} + +// When set to `on`, the current rule will be used when evaluating the request. +// Applies to traditional (allow) WAF rules. +type WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleMode string + +const ( + WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleModeOn WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleMode = "on" + WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleModeOff WAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleMode = "off" +) + +// Union satisfied by [firewall.WAFPackageRuleGetResponseUnknown], +// [firewall.WAFPackageRuleGetResponseArray] or [shared.UnionString]. +type WAFPackageRuleGetResponse interface { + ImplementsFirewallWAFPackageRuleGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WAFPackageRuleGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WAFPackageRuleGetResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type WAFPackageRuleGetResponseArray []interface{} + +func (r WAFPackageRuleGetResponseArray) ImplementsFirewallWAFPackageRuleGetResponse() {} + +type WAFPackageRuleListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // The direction used to sort returned rules. + Direction param.Field[WAFPackageRuleListParamsDirection] `query:"direction"` + // When set to `all`, all the search requirements must match. When set to `any`, + // only one of the search requirements has to match. + Match param.Field[WAFPackageRuleListParamsMatch] `query:"match"` + // The action/mode a rule has been overridden to perform. + Mode param.Field[WAFPackageRuleListParamsMode] `query:"mode"` + // The field used to sort returned rules. + Order param.Field[WAFPackageRuleListParamsOrder] `query:"order"` + // The page number of paginated results. + Page param.Field[float64] `query:"page"` + // The number of rules per page. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [WAFPackageRuleListParams]'s query parameters as +// `url.Values`. +func (r WAFPackageRuleListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// The direction used to sort returned rules. +type WAFPackageRuleListParamsDirection string + +const ( + WAFPackageRuleListParamsDirectionAsc WAFPackageRuleListParamsDirection = "asc" + WAFPackageRuleListParamsDirectionDesc WAFPackageRuleListParamsDirection = "desc" +) + +// When set to `all`, all the search requirements must match. When set to `any`, +// only one of the search requirements has to match. +type WAFPackageRuleListParamsMatch string + +const ( + WAFPackageRuleListParamsMatchAny WAFPackageRuleListParamsMatch = "any" + WAFPackageRuleListParamsMatchAll WAFPackageRuleListParamsMatch = "all" +) + +// The action/mode a rule has been overridden to perform. +type WAFPackageRuleListParamsMode string + +const ( + WAFPackageRuleListParamsModeDis WAFPackageRuleListParamsMode = "DIS" + WAFPackageRuleListParamsModeChl WAFPackageRuleListParamsMode = "CHL" + WAFPackageRuleListParamsModeBlk WAFPackageRuleListParamsMode = "BLK" + WAFPackageRuleListParamsModeSim WAFPackageRuleListParamsMode = "SIM" +) + +// The field used to sort returned rules. +type WAFPackageRuleListParamsOrder string + +const ( + WAFPackageRuleListParamsOrderPriority WAFPackageRuleListParamsOrder = "priority" + WAFPackageRuleListParamsOrderGroupID WAFPackageRuleListParamsOrder = "group_id" + WAFPackageRuleListParamsOrderDescription WAFPackageRuleListParamsOrder = "description" +) + +type WAFPackageRuleEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // The mode/action of the rule when triggered. You must use a value from the + // `allowed_modes` array of the current rule. + Mode param.Field[WAFPackageRuleEditParamsMode] `json:"mode"` +} + +func (r WAFPackageRuleEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The mode/action of the rule when triggered. You must use a value from the +// `allowed_modes` array of the current rule. +type WAFPackageRuleEditParamsMode string + +const ( + WAFPackageRuleEditParamsModeDefault WAFPackageRuleEditParamsMode = "default" + WAFPackageRuleEditParamsModeDisable WAFPackageRuleEditParamsMode = "disable" + WAFPackageRuleEditParamsModeSimulate WAFPackageRuleEditParamsMode = "simulate" + WAFPackageRuleEditParamsModeBlock WAFPackageRuleEditParamsMode = "block" + WAFPackageRuleEditParamsModeChallenge WAFPackageRuleEditParamsMode = "challenge" + WAFPackageRuleEditParamsModeOn WAFPackageRuleEditParamsMode = "on" + WAFPackageRuleEditParamsModeOff WAFPackageRuleEditParamsMode = "off" +) + +type WAFPackageRuleEditResponseEnvelope struct { + Errors []WAFPackageRuleEditResponseEnvelopeErrors `json:"errors,required"` + Messages []WAFPackageRuleEditResponseEnvelopeMessages `json:"messages,required"` + // When triggered, anomaly detection WAF rules contribute to an overall threat + // score that will determine if a request is considered malicious. You can + // configure the total scoring threshold through the 'sensitivity' property of the + // WAF package. + Result WAFPackageRuleEditResponse `json:"result,required"` + // Whether the API call was successful + Success WAFPackageRuleEditResponseEnvelopeSuccess `json:"success,required"` + JSON wafPackageRuleEditResponseEnvelopeJSON `json:"-"` +} + +// wafPackageRuleEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [WAFPackageRuleEditResponseEnvelope] +type wafPackageRuleEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageRuleEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageRuleEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WAFPackageRuleEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON wafPackageRuleEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// wafPackageRuleEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [WAFPackageRuleEditResponseEnvelopeErrors] +type wafPackageRuleEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageRuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageRuleEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WAFPackageRuleEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON wafPackageRuleEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// wafPackageRuleEditResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [WAFPackageRuleEditResponseEnvelopeMessages] +type wafPackageRuleEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageRuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageRuleEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type WAFPackageRuleEditResponseEnvelopeSuccess bool + +const ( + WAFPackageRuleEditResponseEnvelopeSuccessTrue WAFPackageRuleEditResponseEnvelopeSuccess = true +) + +type WAFPackageRuleGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type WAFPackageRuleGetResponseEnvelope struct { + Errors []WAFPackageRuleGetResponseEnvelopeErrors `json:"errors,required"` + Messages []WAFPackageRuleGetResponseEnvelopeMessages `json:"messages,required"` + Result WAFPackageRuleGetResponse `json:"result,required"` + // Whether the API call was successful + Success WAFPackageRuleGetResponseEnvelopeSuccess `json:"success,required"` + JSON wafPackageRuleGetResponseEnvelopeJSON `json:"-"` +} + +// wafPackageRuleGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [WAFPackageRuleGetResponseEnvelope] +type wafPackageRuleGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageRuleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageRuleGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WAFPackageRuleGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON wafPackageRuleGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// wafPackageRuleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [WAFPackageRuleGetResponseEnvelopeErrors] +type wafPackageRuleGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageRuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageRuleGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WAFPackageRuleGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON wafPackageRuleGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// wafPackageRuleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [WAFPackageRuleGetResponseEnvelopeMessages] +type wafPackageRuleGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WAFPackageRuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r wafPackageRuleGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type WAFPackageRuleGetResponseEnvelopeSuccess bool + +const ( + WAFPackageRuleGetResponseEnvelopeSuccessTrue WAFPackageRuleGetResponseEnvelopeSuccess = true +) diff --git a/firewall/wafpackagerule_test.go b/firewall/wafpackagerule_test.go new file mode 100644 index 00000000000..64577e3b446 --- /dev/null +++ b/firewall/wafpackagerule_test.go @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package firewall_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/firewall" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestWAFPackageRuleListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Firewall.WAF.Packages.Rules.List( + context.TODO(), + "a25a9a7e9c00afc1fb2e0245519d725b", + firewall.WAFPackageRuleListParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Direction: cloudflare.F(firewall.WAFPackageRuleListParamsDirectionDesc), + Match: cloudflare.F(firewall.WAFPackageRuleListParamsMatchAny), + Mode: cloudflare.F(firewall.WAFPackageRuleListParamsModeChl), + Order: cloudflare.F(firewall.WAFPackageRuleListParamsOrderPriority), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(5.000000), + }, + ) + 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 TestWAFPackageRuleEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Firewall.WAF.Packages.Rules.Edit( + context.TODO(), + "a25a9a7e9c00afc1fb2e0245519d725b", + "a25a9a7e9c00afc1fb2e0245519d725b", + firewall.WAFPackageRuleEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Mode: cloudflare.F(firewall.WAFPackageRuleEditParamsModeOn), + }, + ) + 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 TestWAFPackageRuleGet(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("user@example.com"), + ) + _, err := client.Firewall.WAF.Packages.Rules.Get( + context.TODO(), + "a25a9a7e9c00afc1fb2e0245519d725b", + "a25a9a7e9c00afc1fb2e0245519d725b", + firewall.WAFPackageRuleGetParams{ + ZoneID: cloudflare.F("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/firewallaccessrule.go b/firewallaccessrule.go deleted file mode 100644 index bee1241d101..00000000000 --- a/firewallaccessrule.go +++ /dev/null @@ -1,1028 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// FirewallAccessRuleService 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 [NewFirewallAccessRuleService] method -// instead. -type FirewallAccessRuleService struct { - Options []option.RequestOption -} - -// NewFirewallAccessRuleService 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 NewFirewallAccessRuleService(opts ...option.RequestOption) (r *FirewallAccessRuleService) { - r = &FirewallAccessRuleService{} - r.Options = opts - return -} - -// Creates a new IP Access rule for an account or zone. The rule will apply to all -// zones in the account or zone. -// -// Note: To create an IP Access rule that applies to a single zone, refer to the -// [IP Access rules for a zone](#ip-access-rules-for-a-zone) endpoints. -func (r *FirewallAccessRuleService) New(ctx context.Context, params FirewallAccessRuleNewParams, opts ...option.RequestOption) (res *FirewallAccessRuleNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallAccessRuleNewResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/firewall/access_rules/rules", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches IP Access rules of an account or zone. These rules apply to all the -// zones in the account or zone. You can filter the results using several optional -// parameters. -func (r *FirewallAccessRuleService) List(ctx context.Context, params FirewallAccessRuleListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[FirewallAccessRuleListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/firewall/access_rules/rules", accountOrZone, accountOrZoneID) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Fetches IP Access rules of an account or zone. These rules apply to all the -// zones in the account or zone. You can filter the results using several optional -// parameters. -func (r *FirewallAccessRuleService) ListAutoPaging(ctx context.Context, params FirewallAccessRuleListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[FirewallAccessRuleListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) -} - -// Deletes an existing IP Access rule defined. -// -// Note: This operation will affect all zones in the account or zone. -func (r *FirewallAccessRuleService) Delete(ctx context.Context, identifier interface{}, body FirewallAccessRuleDeleteParams, opts ...option.RequestOption) (res *FirewallAccessRuleDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallAccessRuleDeleteResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if body.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = body.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = body.ZoneID - } - path := fmt.Sprintf("%s/%s/firewall/access_rules/rules/%v", accountOrZone, accountOrZoneID, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates an IP Access rule defined at the account level. -// -// Note: This operation will affect all zones in the account. -func (r *FirewallAccessRuleService) Edit(ctx context.Context, identifier interface{}, params FirewallAccessRuleEditParams, opts ...option.RequestOption) (res *FirewallAccessRuleEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallAccessRuleEditResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/firewall/access_rules/rules/%v", accountOrZone, accountOrZoneID, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the details of an IP Access rule defined. -func (r *FirewallAccessRuleService) Get(ctx context.Context, identifier interface{}, query FirewallAccessRuleGetParams, opts ...option.RequestOption) (res *FirewallAccessRuleGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallAccessRuleGetResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/firewall/access_rules/rules/%v", accountOrZone, accountOrZoneID, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [FirewallAccessRuleNewResponseUnknown] or -// [shared.UnionString]. -type FirewallAccessRuleNewResponse interface { - ImplementsFirewallAccessRuleNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallAccessRuleNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type FirewallAccessRuleListResponse = interface{} - -type FirewallAccessRuleDeleteResponse struct { - // Identifier - ID string `json:"id,required"` - JSON firewallAccessRuleDeleteResponseJSON `json:"-"` -} - -// firewallAccessRuleDeleteResponseJSON contains the JSON metadata for the struct -// [FirewallAccessRuleDeleteResponse] -type firewallAccessRuleDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [FirewallAccessRuleEditResponseUnknown] or -// [shared.UnionString]. -type FirewallAccessRuleEditResponse interface { - ImplementsFirewallAccessRuleEditResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallAccessRuleEditResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [FirewallAccessRuleGetResponseUnknown] or -// [shared.UnionString]. -type FirewallAccessRuleGetResponse interface { - ImplementsFirewallAccessRuleGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallAccessRuleGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type FirewallAccessRuleNewParams struct { - // The rule configuration. - Configuration param.Field[FirewallAccessRuleNewParamsConfiguration] `json:"configuration,required"` - // The action to apply to a matched request. - Mode param.Field[FirewallAccessRuleNewParamsMode] `json:"mode,required"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // An informative summary of the rule, typically used as a reminder or explanation. - Notes param.Field[string] `json:"notes"` -} - -func (r FirewallAccessRuleNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The rule configuration. -// -// Satisfied by [FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration], -// [FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration], -// [FirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfiguration], -// [FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfiguration], -// [FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration]. -type FirewallAccessRuleNewParamsConfiguration interface { - implementsFirewallAccessRuleNewParamsConfiguration() -} - -type FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration struct { - // The configuration target. You must set the target to `ip` when specifying an IP - // address in the rule. - Target param.Field[FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget] `json:"target"` - // The IP address to match. This address will be compared to the IP address of - // incoming requests. - Value param.Field[string] `json:"value"` -} - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration) implementsFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `ip` when specifying an IP -// address in the rule. -type FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget string - -const ( - FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTargetIP FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget = "ip" -) - -type FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration struct { - // The configuration target. You must set the target to `ip6` when specifying an - // IPv6 address in the rule. - Target param.Field[FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget] `json:"target"` - // The IPv6 address to match. - Value param.Field[string] `json:"value"` -} - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration) implementsFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `ip6` when specifying an -// IPv6 address in the rule. -type FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget string - -const ( - FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTargetIp6 FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget = "ip6" -) - -type FirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfiguration struct { - // The configuration target. You must set the target to `ip_range` when specifying - // an IP address range in the rule. - Target param.Field[FirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfigurationTarget] `json:"target"` - // The IP address range to match. You can only use prefix lengths `/16` and `/24` - // for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. - Value param.Field[string] `json:"value"` -} - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfiguration) implementsFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `ip_range` when specifying -// an IP address range in the rule. -type FirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfigurationTarget string - -const ( - FirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfigurationTargetIPRange FirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfigurationTarget = "ip_range" -) - -type FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfiguration struct { - // The configuration target. You must set the target to `asn` when specifying an - // Autonomous System Number (ASN) in the rule. - Target param.Field[FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget] `json:"target"` - // The AS number to match. - Value param.Field[string] `json:"value"` -} - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfiguration) implementsFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `asn` when specifying an -// Autonomous System Number (ASN) in the rule. -type FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget string - -const ( - FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTargetASN FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget = "asn" -) - -type FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration struct { - // The configuration target. You must set the target to `country` when specifying a - // country code in the rule. - Target param.Field[FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget] `json:"target"` - // The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to - // [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). - Value param.Field[string] `json:"value"` -} - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration) implementsFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `country` when specifying a -// country code in the rule. -type FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget string - -const ( - FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTargetCountry FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget = "country" -) - -// The action to apply to a matched request. -type FirewallAccessRuleNewParamsMode string - -const ( - FirewallAccessRuleNewParamsModeBlock FirewallAccessRuleNewParamsMode = "block" - FirewallAccessRuleNewParamsModeChallenge FirewallAccessRuleNewParamsMode = "challenge" - FirewallAccessRuleNewParamsModeWhitelist FirewallAccessRuleNewParamsMode = "whitelist" - FirewallAccessRuleNewParamsModeJsChallenge FirewallAccessRuleNewParamsMode = "js_challenge" - FirewallAccessRuleNewParamsModeManagedChallenge FirewallAccessRuleNewParamsMode = "managed_challenge" -) - -type FirewallAccessRuleNewResponseEnvelope struct { - Errors []FirewallAccessRuleNewResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallAccessRuleNewResponseEnvelopeMessages `json:"messages,required"` - Result FirewallAccessRuleNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallAccessRuleNewResponseEnvelopeSuccess `json:"success,required"` - JSON firewallAccessRuleNewResponseEnvelopeJSON `json:"-"` -} - -// firewallAccessRuleNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [FirewallAccessRuleNewResponseEnvelope] -type firewallAccessRuleNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallAccessRuleNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallAccessRuleNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallAccessRuleNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [FirewallAccessRuleNewResponseEnvelopeErrors] -type firewallAccessRuleNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallAccessRuleNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallAccessRuleNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallAccessRuleNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [FirewallAccessRuleNewResponseEnvelopeMessages] -type firewallAccessRuleNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallAccessRuleNewResponseEnvelopeSuccess bool - -const ( - FirewallAccessRuleNewResponseEnvelopeSuccessTrue FirewallAccessRuleNewResponseEnvelopeSuccess = true -) - -type FirewallAccessRuleListParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // The direction used to sort returned rules. - Direction param.Field[FirewallAccessRuleListParamsDirection] `query:"direction"` - EgsPagination param.Field[FirewallAccessRuleListParamsEgsPagination] `query:"egs-pagination"` - Filters param.Field[FirewallAccessRuleListParamsFilters] `query:"filters"` - // The field used to sort returned rules. - Order param.Field[FirewallAccessRuleListParamsOrder] `query:"order"` - // Requested page within paginated list of results. - Page param.Field[float64] `query:"page"` - // Maximum number of results requested. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [FirewallAccessRuleListParams]'s query parameters as -// `url.Values`. -func (r FirewallAccessRuleListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// The direction used to sort returned rules. -type FirewallAccessRuleListParamsDirection string - -const ( - FirewallAccessRuleListParamsDirectionAsc FirewallAccessRuleListParamsDirection = "asc" - FirewallAccessRuleListParamsDirectionDesc FirewallAccessRuleListParamsDirection = "desc" -) - -type FirewallAccessRuleListParamsEgsPagination struct { - Json param.Field[FirewallAccessRuleListParamsEgsPaginationJson] `query:"json"` -} - -// URLQuery serializes [FirewallAccessRuleListParamsEgsPagination]'s query -// parameters as `url.Values`. -func (r FirewallAccessRuleListParamsEgsPagination) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type FirewallAccessRuleListParamsEgsPaginationJson struct { - // The page number of paginated results. - Page param.Field[float64] `query:"page"` - // The maximum number of results per page. You can only set the value to `1` or to - // a multiple of 5 such as `5`, `10`, `15`, or `20`. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [FirewallAccessRuleListParamsEgsPaginationJson]'s query -// parameters as `url.Values`. -func (r FirewallAccessRuleListParamsEgsPaginationJson) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type FirewallAccessRuleListParamsFilters struct { - // The target to search in existing rules. - ConfigurationTarget param.Field[FirewallAccessRuleListParamsFiltersConfigurationTarget] `query:"configuration.target"` - // The target value to search for in existing rules: an IP address, an IP address - // range, or a country code, depending on the provided `configuration.target`. - // Notes: You can search for a single IPv4 address, an IP address range with a - // subnet of '/16' or '/24', or a two-letter ISO-3166-1 alpha-2 country code. - ConfigurationValue param.Field[string] `query:"configuration.value"` - // When set to `all`, all the search requirements must match. When set to `any`, - // only one of the search requirements has to match. - Match param.Field[FirewallAccessRuleListParamsFiltersMatch] `query:"match"` - // The action to apply to a matched request. - Mode param.Field[FirewallAccessRuleListParamsFiltersMode] `query:"mode"` - // The string to search for in the notes of existing IP Access rules. Notes: For - // example, the string 'attack' would match IP Access rules with notes 'Attack - // 26/02' and 'Attack 27/02'. The search is case insensitive. - Notes param.Field[string] `query:"notes"` -} - -// URLQuery serializes [FirewallAccessRuleListParamsFilters]'s query parameters as -// `url.Values`. -func (r FirewallAccessRuleListParamsFilters) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// The target to search in existing rules. -type FirewallAccessRuleListParamsFiltersConfigurationTarget string - -const ( - FirewallAccessRuleListParamsFiltersConfigurationTargetIP FirewallAccessRuleListParamsFiltersConfigurationTarget = "ip" - FirewallAccessRuleListParamsFiltersConfigurationTargetIPRange FirewallAccessRuleListParamsFiltersConfigurationTarget = "ip_range" - FirewallAccessRuleListParamsFiltersConfigurationTargetASN FirewallAccessRuleListParamsFiltersConfigurationTarget = "asn" - FirewallAccessRuleListParamsFiltersConfigurationTargetCountry FirewallAccessRuleListParamsFiltersConfigurationTarget = "country" -) - -// When set to `all`, all the search requirements must match. When set to `any`, -// only one of the search requirements has to match. -type FirewallAccessRuleListParamsFiltersMatch string - -const ( - FirewallAccessRuleListParamsFiltersMatchAny FirewallAccessRuleListParamsFiltersMatch = "any" - FirewallAccessRuleListParamsFiltersMatchAll FirewallAccessRuleListParamsFiltersMatch = "all" -) - -// The action to apply to a matched request. -type FirewallAccessRuleListParamsFiltersMode string - -const ( - FirewallAccessRuleListParamsFiltersModeBlock FirewallAccessRuleListParamsFiltersMode = "block" - FirewallAccessRuleListParamsFiltersModeChallenge FirewallAccessRuleListParamsFiltersMode = "challenge" - FirewallAccessRuleListParamsFiltersModeWhitelist FirewallAccessRuleListParamsFiltersMode = "whitelist" - FirewallAccessRuleListParamsFiltersModeJsChallenge FirewallAccessRuleListParamsFiltersMode = "js_challenge" - FirewallAccessRuleListParamsFiltersModeManagedChallenge FirewallAccessRuleListParamsFiltersMode = "managed_challenge" -) - -// The field used to sort returned rules. -type FirewallAccessRuleListParamsOrder string - -const ( - FirewallAccessRuleListParamsOrderConfigurationTarget FirewallAccessRuleListParamsOrder = "configuration.target" - FirewallAccessRuleListParamsOrderConfigurationValue FirewallAccessRuleListParamsOrder = "configuration.value" - FirewallAccessRuleListParamsOrderMode FirewallAccessRuleListParamsOrder = "mode" -) - -type FirewallAccessRuleDeleteParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type FirewallAccessRuleDeleteResponseEnvelope struct { - Errors []FirewallAccessRuleDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallAccessRuleDeleteResponseEnvelopeMessages `json:"messages,required"` - Result FirewallAccessRuleDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallAccessRuleDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON firewallAccessRuleDeleteResponseEnvelopeJSON `json:"-"` -} - -// firewallAccessRuleDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [FirewallAccessRuleDeleteResponseEnvelope] -type firewallAccessRuleDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallAccessRuleDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallAccessRuleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallAccessRuleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [FirewallAccessRuleDeleteResponseEnvelopeErrors] -type firewallAccessRuleDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallAccessRuleDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallAccessRuleDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallAccessRuleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [FirewallAccessRuleDeleteResponseEnvelopeMessages] -type firewallAccessRuleDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallAccessRuleDeleteResponseEnvelopeSuccess bool - -const ( - FirewallAccessRuleDeleteResponseEnvelopeSuccessTrue FirewallAccessRuleDeleteResponseEnvelopeSuccess = true -) - -type FirewallAccessRuleEditParams struct { - // The rule configuration. - Configuration param.Field[FirewallAccessRuleEditParamsConfiguration] `json:"configuration,required"` - // The action to apply to a matched request. - Mode param.Field[FirewallAccessRuleEditParamsMode] `json:"mode,required"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // An informative summary of the rule, typically used as a reminder or explanation. - Notes param.Field[string] `json:"notes"` -} - -func (r FirewallAccessRuleEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The rule configuration. -// -// Satisfied by -// [FirewallAccessRuleEditParamsConfigurationLegacyJhsIPConfiguration], -// [FirewallAccessRuleEditParamsConfigurationLegacyJhsIPV6Configuration], -// [FirewallAccessRuleEditParamsConfigurationLegacyJhsCidrConfiguration], -// [FirewallAccessRuleEditParamsConfigurationLegacyJhsASNConfiguration], -// [FirewallAccessRuleEditParamsConfigurationLegacyJhsCountryConfiguration]. -type FirewallAccessRuleEditParamsConfiguration interface { - implementsFirewallAccessRuleEditParamsConfiguration() -} - -type FirewallAccessRuleEditParamsConfigurationLegacyJhsIPConfiguration struct { - // The configuration target. You must set the target to `ip` when specifying an IP - // address in the rule. - Target param.Field[FirewallAccessRuleEditParamsConfigurationLegacyJhsIPConfigurationTarget] `json:"target"` - // The IP address to match. This address will be compared to the IP address of - // incoming requests. - Value param.Field[string] `json:"value"` -} - -func (r FirewallAccessRuleEditParamsConfigurationLegacyJhsIPConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r FirewallAccessRuleEditParamsConfigurationLegacyJhsIPConfiguration) implementsFirewallAccessRuleEditParamsConfiguration() { -} - -// The configuration target. You must set the target to `ip` when specifying an IP -// address in the rule. -type FirewallAccessRuleEditParamsConfigurationLegacyJhsIPConfigurationTarget string - -const ( - FirewallAccessRuleEditParamsConfigurationLegacyJhsIPConfigurationTargetIP FirewallAccessRuleEditParamsConfigurationLegacyJhsIPConfigurationTarget = "ip" -) - -type FirewallAccessRuleEditParamsConfigurationLegacyJhsIPV6Configuration struct { - // The configuration target. You must set the target to `ip6` when specifying an - // IPv6 address in the rule. - Target param.Field[FirewallAccessRuleEditParamsConfigurationLegacyJhsIPV6ConfigurationTarget] `json:"target"` - // The IPv6 address to match. - Value param.Field[string] `json:"value"` -} - -func (r FirewallAccessRuleEditParamsConfigurationLegacyJhsIPV6Configuration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r FirewallAccessRuleEditParamsConfigurationLegacyJhsIPV6Configuration) implementsFirewallAccessRuleEditParamsConfiguration() { -} - -// The configuration target. You must set the target to `ip6` when specifying an -// IPv6 address in the rule. -type FirewallAccessRuleEditParamsConfigurationLegacyJhsIPV6ConfigurationTarget string - -const ( - FirewallAccessRuleEditParamsConfigurationLegacyJhsIPV6ConfigurationTargetIp6 FirewallAccessRuleEditParamsConfigurationLegacyJhsIPV6ConfigurationTarget = "ip6" -) - -type FirewallAccessRuleEditParamsConfigurationLegacyJhsCidrConfiguration struct { - // The configuration target. You must set the target to `ip_range` when specifying - // an IP address range in the rule. - Target param.Field[FirewallAccessRuleEditParamsConfigurationLegacyJhsCidrConfigurationTarget] `json:"target"` - // The IP address range to match. You can only use prefix lengths `/16` and `/24` - // for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. - Value param.Field[string] `json:"value"` -} - -func (r FirewallAccessRuleEditParamsConfigurationLegacyJhsCidrConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r FirewallAccessRuleEditParamsConfigurationLegacyJhsCidrConfiguration) implementsFirewallAccessRuleEditParamsConfiguration() { -} - -// The configuration target. You must set the target to `ip_range` when specifying -// an IP address range in the rule. -type FirewallAccessRuleEditParamsConfigurationLegacyJhsCidrConfigurationTarget string - -const ( - FirewallAccessRuleEditParamsConfigurationLegacyJhsCidrConfigurationTargetIPRange FirewallAccessRuleEditParamsConfigurationLegacyJhsCidrConfigurationTarget = "ip_range" -) - -type FirewallAccessRuleEditParamsConfigurationLegacyJhsASNConfiguration struct { - // The configuration target. You must set the target to `asn` when specifying an - // Autonomous System Number (ASN) in the rule. - Target param.Field[FirewallAccessRuleEditParamsConfigurationLegacyJhsASNConfigurationTarget] `json:"target"` - // The AS number to match. - Value param.Field[string] `json:"value"` -} - -func (r FirewallAccessRuleEditParamsConfigurationLegacyJhsASNConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r FirewallAccessRuleEditParamsConfigurationLegacyJhsASNConfiguration) implementsFirewallAccessRuleEditParamsConfiguration() { -} - -// The configuration target. You must set the target to `asn` when specifying an -// Autonomous System Number (ASN) in the rule. -type FirewallAccessRuleEditParamsConfigurationLegacyJhsASNConfigurationTarget string - -const ( - FirewallAccessRuleEditParamsConfigurationLegacyJhsASNConfigurationTargetASN FirewallAccessRuleEditParamsConfigurationLegacyJhsASNConfigurationTarget = "asn" -) - -type FirewallAccessRuleEditParamsConfigurationLegacyJhsCountryConfiguration struct { - // The configuration target. You must set the target to `country` when specifying a - // country code in the rule. - Target param.Field[FirewallAccessRuleEditParamsConfigurationLegacyJhsCountryConfigurationTarget] `json:"target"` - // The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to - // [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). - Value param.Field[string] `json:"value"` -} - -func (r FirewallAccessRuleEditParamsConfigurationLegacyJhsCountryConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r FirewallAccessRuleEditParamsConfigurationLegacyJhsCountryConfiguration) implementsFirewallAccessRuleEditParamsConfiguration() { -} - -// The configuration target. You must set the target to `country` when specifying a -// country code in the rule. -type FirewallAccessRuleEditParamsConfigurationLegacyJhsCountryConfigurationTarget string - -const ( - FirewallAccessRuleEditParamsConfigurationLegacyJhsCountryConfigurationTargetCountry FirewallAccessRuleEditParamsConfigurationLegacyJhsCountryConfigurationTarget = "country" -) - -// The action to apply to a matched request. -type FirewallAccessRuleEditParamsMode string - -const ( - FirewallAccessRuleEditParamsModeBlock FirewallAccessRuleEditParamsMode = "block" - FirewallAccessRuleEditParamsModeChallenge FirewallAccessRuleEditParamsMode = "challenge" - FirewallAccessRuleEditParamsModeWhitelist FirewallAccessRuleEditParamsMode = "whitelist" - FirewallAccessRuleEditParamsModeJsChallenge FirewallAccessRuleEditParamsMode = "js_challenge" - FirewallAccessRuleEditParamsModeManagedChallenge FirewallAccessRuleEditParamsMode = "managed_challenge" -) - -type FirewallAccessRuleEditResponseEnvelope struct { - Errors []FirewallAccessRuleEditResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallAccessRuleEditResponseEnvelopeMessages `json:"messages,required"` - Result FirewallAccessRuleEditResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallAccessRuleEditResponseEnvelopeSuccess `json:"success,required"` - JSON firewallAccessRuleEditResponseEnvelopeJSON `json:"-"` -} - -// firewallAccessRuleEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [FirewallAccessRuleEditResponseEnvelope] -type firewallAccessRuleEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallAccessRuleEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallAccessRuleEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallAccessRuleEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [FirewallAccessRuleEditResponseEnvelopeErrors] -type firewallAccessRuleEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallAccessRuleEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallAccessRuleEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallAccessRuleEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [FirewallAccessRuleEditResponseEnvelopeMessages] -type firewallAccessRuleEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallAccessRuleEditResponseEnvelopeSuccess bool - -const ( - FirewallAccessRuleEditResponseEnvelopeSuccessTrue FirewallAccessRuleEditResponseEnvelopeSuccess = true -) - -type FirewallAccessRuleGetParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type FirewallAccessRuleGetResponseEnvelope struct { - Errors []FirewallAccessRuleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallAccessRuleGetResponseEnvelopeMessages `json:"messages,required"` - Result FirewallAccessRuleGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallAccessRuleGetResponseEnvelopeSuccess `json:"success,required"` - JSON firewallAccessRuleGetResponseEnvelopeJSON `json:"-"` -} - -// firewallAccessRuleGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [FirewallAccessRuleGetResponseEnvelope] -type firewallAccessRuleGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallAccessRuleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallAccessRuleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallAccessRuleGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [FirewallAccessRuleGetResponseEnvelopeErrors] -type firewallAccessRuleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallAccessRuleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallAccessRuleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallAccessRuleGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [FirewallAccessRuleGetResponseEnvelopeMessages] -type firewallAccessRuleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallAccessRuleGetResponseEnvelopeSuccess bool - -const ( - FirewallAccessRuleGetResponseEnvelopeSuccessTrue FirewallAccessRuleGetResponseEnvelopeSuccess = true -) diff --git a/firewallaccessrule_test.go b/firewallaccessrule_test.go deleted file mode 100644 index ec73a395820..00000000000 --- a/firewallaccessrule_test.go +++ /dev/null @@ -1,190 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestFirewallAccessRuleNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Firewall.AccessRules.New(context.TODO(), cloudflare.FirewallAccessRuleNewParams{ - Configuration: cloudflare.F[cloudflare.FirewallAccessRuleNewParamsConfiguration](cloudflare.FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration(cloudflare.FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration{ - Target: cloudflare.F(cloudflare.FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTargetIP), - Value: cloudflare.F("198.51.100.4"), - })), - Mode: cloudflare.F(cloudflare.FirewallAccessRuleNewParamsModeChallenge), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - Notes: cloudflare.F("This rule is enabled because of an event that occurred on date X."), - }) - 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 TestFirewallAccessRuleListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Firewall.AccessRules.List(context.TODO(), cloudflare.FirewallAccessRuleListParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - Direction: cloudflare.F(cloudflare.FirewallAccessRuleListParamsDirectionDesc), - EgsPagination: cloudflare.F(cloudflare.FirewallAccessRuleListParamsEgsPagination{ - Json: cloudflare.F(cloudflare.FirewallAccessRuleListParamsEgsPaginationJson{ - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(1.000000), - }), - }), - Filters: cloudflare.F(cloudflare.FirewallAccessRuleListParamsFilters{ - ConfigurationTarget: cloudflare.F(cloudflare.FirewallAccessRuleListParamsFiltersConfigurationTargetIP), - ConfigurationValue: cloudflare.F("198.51.100.4"), - Match: cloudflare.F(cloudflare.FirewallAccessRuleListParamsFiltersMatchAny), - Mode: cloudflare.F(cloudflare.FirewallAccessRuleListParamsFiltersModeChallenge), - Notes: cloudflare.F("my note"), - }), - Order: cloudflare.F(cloudflare.FirewallAccessRuleListParamsOrderMode), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(20.000000), - }) - 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 TestFirewallAccessRuleDeleteWithOptionalParams(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("user@example.com"), - ) - _, err := client.Firewall.AccessRules.Delete( - context.TODO(), - map[string]interface{}{}, - cloudflare.FirewallAccessRuleDeleteParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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 TestFirewallAccessRuleEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Firewall.AccessRules.Edit( - context.TODO(), - map[string]interface{}{}, - cloudflare.FirewallAccessRuleEditParams{ - Configuration: cloudflare.F[cloudflare.FirewallAccessRuleEditParamsConfiguration](cloudflare.FirewallAccessRuleEditParamsConfigurationLegacyJhsIPConfiguration(cloudflare.FirewallAccessRuleEditParamsConfigurationLegacyJhsIPConfiguration{ - Target: cloudflare.F(cloudflare.FirewallAccessRuleEditParamsConfigurationLegacyJhsIPConfigurationTargetIP), - Value: cloudflare.F("198.51.100.4"), - })), - Mode: cloudflare.F(cloudflare.FirewallAccessRuleEditParamsModeChallenge), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - Notes: cloudflare.F("This rule is enabled because of an event that occurred on date X."), - }, - ) - 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 TestFirewallAccessRuleGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Firewall.AccessRules.Get( - context.TODO(), - map[string]interface{}{}, - cloudflare.FirewallAccessRuleGetParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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/firewalllockdown.go b/firewalllockdown.go deleted file mode 100644 index 7a68416e406..00000000000 --- a/firewalllockdown.go +++ /dev/null @@ -1,1038 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// FirewallLockdownService 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 [NewFirewallLockdownService] method -// instead. -type FirewallLockdownService struct { - Options []option.RequestOption -} - -// NewFirewallLockdownService 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 NewFirewallLockdownService(opts ...option.RequestOption) (r *FirewallLockdownService) { - r = &FirewallLockdownService{} - r.Options = opts - return -} - -// Creates a new Zone Lockdown rule. -func (r *FirewallLockdownService) New(ctx context.Context, zoneIdentifier string, body FirewallLockdownNewParams, opts ...option.RequestOption) (res *FirewallLockdownNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallLockdownNewResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/lockdowns", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates an existing Zone Lockdown rule. -func (r *FirewallLockdownService) Update(ctx context.Context, zoneIdentifier string, id string, body FirewallLockdownUpdateParams, opts ...option.RequestOption) (res *FirewallLockdownUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallLockdownUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/lockdowns/%s", zoneIdentifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches Zone Lockdown rules. You can filter the results using several optional -// parameters. -func (r *FirewallLockdownService) List(ctx context.Context, zoneIdentifier string, query FirewallLockdownListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[FirewallLockdownListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("zones/%s/firewall/lockdowns", zoneIdentifier) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Fetches Zone Lockdown rules. You can filter the results using several optional -// parameters. -func (r *FirewallLockdownService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query FirewallLockdownListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[FirewallLockdownListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) -} - -// Deletes an existing Zone Lockdown rule. -func (r *FirewallLockdownService) Delete(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *FirewallLockdownDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallLockdownDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/lockdowns/%s", zoneIdentifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the details of a Zone Lockdown rule. -func (r *FirewallLockdownService) Get(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *FirewallLockdownGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallLockdownGetResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/lockdowns/%s", zoneIdentifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type FirewallLockdownNewResponse struct { - // The unique identifier of the Zone Lockdown rule. - ID string `json:"id,required"` - // A list of IP addresses or CIDR ranges that will be allowed to access the URLs - // specified in the Zone Lockdown rule. You can include any number of `ip` or - // `ip_range` configurations. - Configurations FirewallLockdownNewResponseConfigurations `json:"configurations,required"` - // The timestamp of when the rule was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - // An informative summary of the rule. - Description string `json:"description,required"` - // The timestamp of when the rule was last modified. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // When true, indicates that the rule is currently paused. - Paused bool `json:"paused,required"` - // The URLs to include in the rule definition. You can use wildcards. Each entered - // URL will be escaped before use, which means you can only use simple wildcard - // patterns. - URLs []string `json:"urls,required"` - JSON firewallLockdownNewResponseJSON `json:"-"` -} - -// firewallLockdownNewResponseJSON contains the JSON metadata for the struct -// [FirewallLockdownNewResponse] -type firewallLockdownNewResponseJSON struct { - ID apijson.Field - Configurations apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ModifiedOn apijson.Field - Paused apijson.Field - URLs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownNewResponseJSON) RawJSON() string { - return r.raw -} - -// A list of IP addresses or CIDR ranges that will be allowed to access the URLs -// specified in the Zone Lockdown rule. You can include any number of `ip` or -// `ip_range` configurations. -// -// Union satisfied by -// [FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasIPConfiguration] or -// [FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasCidrConfiguration]. -type FirewallLockdownNewResponseConfigurations interface { - implementsFirewallLockdownNewResponseConfigurations() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallLockdownNewResponseConfigurations)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasIPConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasCidrConfiguration{}), - }, - ) -} - -type FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasIPConfiguration struct { - // The configuration target. You must set the target to `ip` when specifying an IP - // address in the Zone Lockdown rule. - Target FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasIPConfigurationTarget `json:"target"` - // The IP address to match. This address will be compared to the IP address of - // incoming requests. - Value string `json:"value"` - JSON firewallLockdownNewResponseConfigurationsLegacyJhsSchemasIPConfigurationJSON `json:"-"` -} - -// firewallLockdownNewResponseConfigurationsLegacyJhsSchemasIPConfigurationJSON -// contains the JSON metadata for the struct -// [FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasIPConfiguration] -type firewallLockdownNewResponseConfigurationsLegacyJhsSchemasIPConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasIPConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownNewResponseConfigurationsLegacyJhsSchemasIPConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasIPConfiguration) implementsFirewallLockdownNewResponseConfigurations() { -} - -// The configuration target. You must set the target to `ip` when specifying an IP -// address in the Zone Lockdown rule. -type FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasIPConfigurationTarget string - -const ( - FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasIPConfigurationTargetIP FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasIPConfigurationTarget = "ip" -) - -type FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasCidrConfiguration struct { - // The configuration target. You must set the target to `ip_range` when specifying - // an IP address range in the Zone Lockdown rule. - Target FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasCidrConfigurationTarget `json:"target"` - // The IP address range to match. You can only use prefix lengths `/16` and `/24`. - Value string `json:"value"` - JSON firewallLockdownNewResponseConfigurationsLegacyJhsSchemasCidrConfigurationJSON `json:"-"` -} - -// firewallLockdownNewResponseConfigurationsLegacyJhsSchemasCidrConfigurationJSON -// contains the JSON metadata for the struct -// [FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasCidrConfiguration] -type firewallLockdownNewResponseConfigurationsLegacyJhsSchemasCidrConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasCidrConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownNewResponseConfigurationsLegacyJhsSchemasCidrConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasCidrConfiguration) implementsFirewallLockdownNewResponseConfigurations() { -} - -// The configuration target. You must set the target to `ip_range` when specifying -// an IP address range in the Zone Lockdown rule. -type FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasCidrConfigurationTarget string - -const ( - FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasCidrConfigurationTargetIPRange FirewallLockdownNewResponseConfigurationsLegacyJhsSchemasCidrConfigurationTarget = "ip_range" -) - -type FirewallLockdownUpdateResponse struct { - // The unique identifier of the Zone Lockdown rule. - ID string `json:"id,required"` - // A list of IP addresses or CIDR ranges that will be allowed to access the URLs - // specified in the Zone Lockdown rule. You can include any number of `ip` or - // `ip_range` configurations. - Configurations FirewallLockdownUpdateResponseConfigurations `json:"configurations,required"` - // The timestamp of when the rule was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - // An informative summary of the rule. - Description string `json:"description,required"` - // The timestamp of when the rule was last modified. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // When true, indicates that the rule is currently paused. - Paused bool `json:"paused,required"` - // The URLs to include in the rule definition. You can use wildcards. Each entered - // URL will be escaped before use, which means you can only use simple wildcard - // patterns. - URLs []string `json:"urls,required"` - JSON firewallLockdownUpdateResponseJSON `json:"-"` -} - -// firewallLockdownUpdateResponseJSON contains the JSON metadata for the struct -// [FirewallLockdownUpdateResponse] -type firewallLockdownUpdateResponseJSON struct { - ID apijson.Field - Configurations apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ModifiedOn apijson.Field - Paused apijson.Field - URLs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// A list of IP addresses or CIDR ranges that will be allowed to access the URLs -// specified in the Zone Lockdown rule. You can include any number of `ip` or -// `ip_range` configurations. -// -// Union satisfied by -// [FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasIPConfiguration] or -// [FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasCidrConfiguration]. -type FirewallLockdownUpdateResponseConfigurations interface { - implementsFirewallLockdownUpdateResponseConfigurations() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallLockdownUpdateResponseConfigurations)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasIPConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasCidrConfiguration{}), - }, - ) -} - -type FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasIPConfiguration struct { - // The configuration target. You must set the target to `ip` when specifying an IP - // address in the Zone Lockdown rule. - Target FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasIPConfigurationTarget `json:"target"` - // The IP address to match. This address will be compared to the IP address of - // incoming requests. - Value string `json:"value"` - JSON firewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasIPConfigurationJSON `json:"-"` -} - -// firewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasIPConfigurationJSON -// contains the JSON metadata for the struct -// [FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasIPConfiguration] -type firewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasIPConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasIPConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasIPConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasIPConfiguration) implementsFirewallLockdownUpdateResponseConfigurations() { -} - -// The configuration target. You must set the target to `ip` when specifying an IP -// address in the Zone Lockdown rule. -type FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasIPConfigurationTarget string - -const ( - FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasIPConfigurationTargetIP FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasIPConfigurationTarget = "ip" -) - -type FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasCidrConfiguration struct { - // The configuration target. You must set the target to `ip_range` when specifying - // an IP address range in the Zone Lockdown rule. - Target FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasCidrConfigurationTarget `json:"target"` - // The IP address range to match. You can only use prefix lengths `/16` and `/24`. - Value string `json:"value"` - JSON firewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasCidrConfigurationJSON `json:"-"` -} - -// firewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasCidrConfigurationJSON -// contains the JSON metadata for the struct -// [FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasCidrConfiguration] -type firewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasCidrConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasCidrConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasCidrConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasCidrConfiguration) implementsFirewallLockdownUpdateResponseConfigurations() { -} - -// The configuration target. You must set the target to `ip_range` when specifying -// an IP address range in the Zone Lockdown rule. -type FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasCidrConfigurationTarget string - -const ( - FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasCidrConfigurationTargetIPRange FirewallLockdownUpdateResponseConfigurationsLegacyJhsSchemasCidrConfigurationTarget = "ip_range" -) - -type FirewallLockdownListResponse struct { - // The unique identifier of the Zone Lockdown rule. - ID string `json:"id,required"` - // A list of IP addresses or CIDR ranges that will be allowed to access the URLs - // specified in the Zone Lockdown rule. You can include any number of `ip` or - // `ip_range` configurations. - Configurations FirewallLockdownListResponseConfigurations `json:"configurations,required"` - // The timestamp of when the rule was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - // An informative summary of the rule. - Description string `json:"description,required"` - // The timestamp of when the rule was last modified. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // When true, indicates that the rule is currently paused. - Paused bool `json:"paused,required"` - // The URLs to include in the rule definition. You can use wildcards. Each entered - // URL will be escaped before use, which means you can only use simple wildcard - // patterns. - URLs []string `json:"urls,required"` - JSON firewallLockdownListResponseJSON `json:"-"` -} - -// firewallLockdownListResponseJSON contains the JSON metadata for the struct -// [FirewallLockdownListResponse] -type firewallLockdownListResponseJSON struct { - ID apijson.Field - Configurations apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ModifiedOn apijson.Field - Paused apijson.Field - URLs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownListResponseJSON) RawJSON() string { - return r.raw -} - -// A list of IP addresses or CIDR ranges that will be allowed to access the URLs -// specified in the Zone Lockdown rule. You can include any number of `ip` or -// `ip_range` configurations. -// -// Union satisfied by -// [FirewallLockdownListResponseConfigurationsLegacyJhsSchemasIPConfiguration] or -// [FirewallLockdownListResponseConfigurationsLegacyJhsSchemasCidrConfiguration]. -type FirewallLockdownListResponseConfigurations interface { - implementsFirewallLockdownListResponseConfigurations() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallLockdownListResponseConfigurations)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallLockdownListResponseConfigurationsLegacyJhsSchemasIPConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallLockdownListResponseConfigurationsLegacyJhsSchemasCidrConfiguration{}), - }, - ) -} - -type FirewallLockdownListResponseConfigurationsLegacyJhsSchemasIPConfiguration struct { - // The configuration target. You must set the target to `ip` when specifying an IP - // address in the Zone Lockdown rule. - Target FirewallLockdownListResponseConfigurationsLegacyJhsSchemasIPConfigurationTarget `json:"target"` - // The IP address to match. This address will be compared to the IP address of - // incoming requests. - Value string `json:"value"` - JSON firewallLockdownListResponseConfigurationsLegacyJhsSchemasIPConfigurationJSON `json:"-"` -} - -// firewallLockdownListResponseConfigurationsLegacyJhsSchemasIPConfigurationJSON -// contains the JSON metadata for the struct -// [FirewallLockdownListResponseConfigurationsLegacyJhsSchemasIPConfiguration] -type firewallLockdownListResponseConfigurationsLegacyJhsSchemasIPConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownListResponseConfigurationsLegacyJhsSchemasIPConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownListResponseConfigurationsLegacyJhsSchemasIPConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r FirewallLockdownListResponseConfigurationsLegacyJhsSchemasIPConfiguration) implementsFirewallLockdownListResponseConfigurations() { -} - -// The configuration target. You must set the target to `ip` when specifying an IP -// address in the Zone Lockdown rule. -type FirewallLockdownListResponseConfigurationsLegacyJhsSchemasIPConfigurationTarget string - -const ( - FirewallLockdownListResponseConfigurationsLegacyJhsSchemasIPConfigurationTargetIP FirewallLockdownListResponseConfigurationsLegacyJhsSchemasIPConfigurationTarget = "ip" -) - -type FirewallLockdownListResponseConfigurationsLegacyJhsSchemasCidrConfiguration struct { - // The configuration target. You must set the target to `ip_range` when specifying - // an IP address range in the Zone Lockdown rule. - Target FirewallLockdownListResponseConfigurationsLegacyJhsSchemasCidrConfigurationTarget `json:"target"` - // The IP address range to match. You can only use prefix lengths `/16` and `/24`. - Value string `json:"value"` - JSON firewallLockdownListResponseConfigurationsLegacyJhsSchemasCidrConfigurationJSON `json:"-"` -} - -// firewallLockdownListResponseConfigurationsLegacyJhsSchemasCidrConfigurationJSON -// contains the JSON metadata for the struct -// [FirewallLockdownListResponseConfigurationsLegacyJhsSchemasCidrConfiguration] -type firewallLockdownListResponseConfigurationsLegacyJhsSchemasCidrConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownListResponseConfigurationsLegacyJhsSchemasCidrConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownListResponseConfigurationsLegacyJhsSchemasCidrConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r FirewallLockdownListResponseConfigurationsLegacyJhsSchemasCidrConfiguration) implementsFirewallLockdownListResponseConfigurations() { -} - -// The configuration target. You must set the target to `ip_range` when specifying -// an IP address range in the Zone Lockdown rule. -type FirewallLockdownListResponseConfigurationsLegacyJhsSchemasCidrConfigurationTarget string - -const ( - FirewallLockdownListResponseConfigurationsLegacyJhsSchemasCidrConfigurationTargetIPRange FirewallLockdownListResponseConfigurationsLegacyJhsSchemasCidrConfigurationTarget = "ip_range" -) - -type FirewallLockdownDeleteResponse struct { - // The unique identifier of the Zone Lockdown rule. - ID string `json:"id"` - JSON firewallLockdownDeleteResponseJSON `json:"-"` -} - -// firewallLockdownDeleteResponseJSON contains the JSON metadata for the struct -// [FirewallLockdownDeleteResponse] -type firewallLockdownDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type FirewallLockdownGetResponse struct { - // The unique identifier of the Zone Lockdown rule. - ID string `json:"id,required"` - // A list of IP addresses or CIDR ranges that will be allowed to access the URLs - // specified in the Zone Lockdown rule. You can include any number of `ip` or - // `ip_range` configurations. - Configurations FirewallLockdownGetResponseConfigurations `json:"configurations,required"` - // The timestamp of when the rule was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - // An informative summary of the rule. - Description string `json:"description,required"` - // The timestamp of when the rule was last modified. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // When true, indicates that the rule is currently paused. - Paused bool `json:"paused,required"` - // The URLs to include in the rule definition. You can use wildcards. Each entered - // URL will be escaped before use, which means you can only use simple wildcard - // patterns. - URLs []string `json:"urls,required"` - JSON firewallLockdownGetResponseJSON `json:"-"` -} - -// firewallLockdownGetResponseJSON contains the JSON metadata for the struct -// [FirewallLockdownGetResponse] -type firewallLockdownGetResponseJSON struct { - ID apijson.Field - Configurations apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ModifiedOn apijson.Field - Paused apijson.Field - URLs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownGetResponseJSON) RawJSON() string { - return r.raw -} - -// A list of IP addresses or CIDR ranges that will be allowed to access the URLs -// specified in the Zone Lockdown rule. You can include any number of `ip` or -// `ip_range` configurations. -// -// Union satisfied by -// [FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasIPConfiguration] or -// [FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasCidrConfiguration]. -type FirewallLockdownGetResponseConfigurations interface { - implementsFirewallLockdownGetResponseConfigurations() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallLockdownGetResponseConfigurations)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasIPConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasCidrConfiguration{}), - }, - ) -} - -type FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasIPConfiguration struct { - // The configuration target. You must set the target to `ip` when specifying an IP - // address in the Zone Lockdown rule. - Target FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasIPConfigurationTarget `json:"target"` - // The IP address to match. This address will be compared to the IP address of - // incoming requests. - Value string `json:"value"` - JSON firewallLockdownGetResponseConfigurationsLegacyJhsSchemasIPConfigurationJSON `json:"-"` -} - -// firewallLockdownGetResponseConfigurationsLegacyJhsSchemasIPConfigurationJSON -// contains the JSON metadata for the struct -// [FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasIPConfiguration] -type firewallLockdownGetResponseConfigurationsLegacyJhsSchemasIPConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasIPConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownGetResponseConfigurationsLegacyJhsSchemasIPConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasIPConfiguration) implementsFirewallLockdownGetResponseConfigurations() { -} - -// The configuration target. You must set the target to `ip` when specifying an IP -// address in the Zone Lockdown rule. -type FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasIPConfigurationTarget string - -const ( - FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasIPConfigurationTargetIP FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasIPConfigurationTarget = "ip" -) - -type FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasCidrConfiguration struct { - // The configuration target. You must set the target to `ip_range` when specifying - // an IP address range in the Zone Lockdown rule. - Target FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasCidrConfigurationTarget `json:"target"` - // The IP address range to match. You can only use prefix lengths `/16` and `/24`. - Value string `json:"value"` - JSON firewallLockdownGetResponseConfigurationsLegacyJhsSchemasCidrConfigurationJSON `json:"-"` -} - -// firewallLockdownGetResponseConfigurationsLegacyJhsSchemasCidrConfigurationJSON -// contains the JSON metadata for the struct -// [FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasCidrConfiguration] -type firewallLockdownGetResponseConfigurationsLegacyJhsSchemasCidrConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasCidrConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownGetResponseConfigurationsLegacyJhsSchemasCidrConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasCidrConfiguration) implementsFirewallLockdownGetResponseConfigurations() { -} - -// The configuration target. You must set the target to `ip_range` when specifying -// an IP address range in the Zone Lockdown rule. -type FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasCidrConfigurationTarget string - -const ( - FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasCidrConfigurationTargetIPRange FirewallLockdownGetResponseConfigurationsLegacyJhsSchemasCidrConfigurationTarget = "ip_range" -) - -type FirewallLockdownNewParams struct { - Body param.Field[interface{}] `json:"body,required"` -} - -func (r FirewallLockdownNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type FirewallLockdownNewResponseEnvelope struct { - Errors []FirewallLockdownNewResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallLockdownNewResponseEnvelopeMessages `json:"messages,required"` - Result FirewallLockdownNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallLockdownNewResponseEnvelopeSuccess `json:"success,required"` - JSON firewallLockdownNewResponseEnvelopeJSON `json:"-"` -} - -// firewallLockdownNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [FirewallLockdownNewResponseEnvelope] -type firewallLockdownNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallLockdownNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallLockdownNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallLockdownNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [FirewallLockdownNewResponseEnvelopeErrors] -type firewallLockdownNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallLockdownNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallLockdownNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallLockdownNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [FirewallLockdownNewResponseEnvelopeMessages] -type firewallLockdownNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallLockdownNewResponseEnvelopeSuccess bool - -const ( - FirewallLockdownNewResponseEnvelopeSuccessTrue FirewallLockdownNewResponseEnvelopeSuccess = true -) - -type FirewallLockdownUpdateParams struct { - Body param.Field[interface{}] `json:"body,required"` -} - -func (r FirewallLockdownUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type FirewallLockdownUpdateResponseEnvelope struct { - Errors []FirewallLockdownUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallLockdownUpdateResponseEnvelopeMessages `json:"messages,required"` - Result FirewallLockdownUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallLockdownUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON firewallLockdownUpdateResponseEnvelopeJSON `json:"-"` -} - -// firewallLockdownUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [FirewallLockdownUpdateResponseEnvelope] -type firewallLockdownUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallLockdownUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallLockdownUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallLockdownUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [FirewallLockdownUpdateResponseEnvelopeErrors] -type firewallLockdownUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallLockdownUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallLockdownUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallLockdownUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [FirewallLockdownUpdateResponseEnvelopeMessages] -type firewallLockdownUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallLockdownUpdateResponseEnvelopeSuccess bool - -const ( - FirewallLockdownUpdateResponseEnvelopeSuccessTrue FirewallLockdownUpdateResponseEnvelopeSuccess = true -) - -type FirewallLockdownListParams struct { - // A string to search for in the description of existing rules. - Description param.Field[string] `query:"description"` - // A string to search for in the description of existing rules. - DescriptionSearch param.Field[string] `query:"description_search"` - // A single IP address to search for in existing rules. - IP param.Field[string] `query:"ip"` - // A single IP address range to search for in existing rules. - IPRangeSearch param.Field[string] `query:"ip_range_search"` - // A single IP address to search for in existing rules. - IPSearch param.Field[string] `query:"ip_search"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // The maximum number of results per page. You can only set the value to `1` or to - // a multiple of 5 such as `5`, `10`, `15`, or `20`. - PerPage param.Field[float64] `query:"per_page"` - // The priority of the rule to control the processing order. A lower number - // indicates higher priority. If not provided, any rules with a configured priority - // will be processed before rules without a priority. - Priority param.Field[float64] `query:"priority"` - // A single URI to search for in the list of URLs of existing rules. - URISearch param.Field[string] `query:"uri_search"` -} - -// URLQuery serializes [FirewallLockdownListParams]'s query parameters as -// `url.Values`. -func (r FirewallLockdownListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type FirewallLockdownDeleteResponseEnvelope struct { - Result FirewallLockdownDeleteResponse `json:"result"` - JSON firewallLockdownDeleteResponseEnvelopeJSON `json:"-"` -} - -// firewallLockdownDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [FirewallLockdownDeleteResponseEnvelope] -type firewallLockdownDeleteResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallLockdownGetResponseEnvelope struct { - Errors []FirewallLockdownGetResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallLockdownGetResponseEnvelopeMessages `json:"messages,required"` - Result FirewallLockdownGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallLockdownGetResponseEnvelopeSuccess `json:"success,required"` - JSON firewallLockdownGetResponseEnvelopeJSON `json:"-"` -} - -// firewallLockdownGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [FirewallLockdownGetResponseEnvelope] -type firewallLockdownGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallLockdownGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallLockdownGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallLockdownGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [FirewallLockdownGetResponseEnvelopeErrors] -type firewallLockdownGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallLockdownGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallLockdownGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallLockdownGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [FirewallLockdownGetResponseEnvelopeMessages] -type firewallLockdownGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallLockdownGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallLockdownGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallLockdownGetResponseEnvelopeSuccess bool - -const ( - FirewallLockdownGetResponseEnvelopeSuccessTrue FirewallLockdownGetResponseEnvelopeSuccess = true -) diff --git a/firewalllockdown_test.go b/firewalllockdown_test.go deleted file mode 100644 index aa3311681cf..00000000000 --- a/firewalllockdown_test.go +++ /dev/null @@ -1,169 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestFirewallLockdownNew(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("user@example.com"), - ) - _, err := client.Firewall.Lockdowns.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.FirewallLockdownNewParams{ - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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 TestFirewallLockdownUpdate(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("user@example.com"), - ) - _, err := client.Firewall.Lockdowns.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "372e67954025e0ba6aaa6d586b9e0b59", - cloudflare.FirewallLockdownUpdateParams{ - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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 TestFirewallLockdownListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Firewall.Lockdowns.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.FirewallLockdownListParams{ - Description: cloudflare.F("endpoints"), - DescriptionSearch: cloudflare.F("endpoints"), - IP: cloudflare.F("1.2.3.4"), - IPRangeSearch: cloudflare.F("1.2.3.0/16"), - IPSearch: cloudflare.F("1.2.3.4"), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(1.000000), - Priority: cloudflare.F(5.000000), - URISearch: cloudflare.F("/some/path"), - }, - ) - 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 TestFirewallLockdownDelete(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("user@example.com"), - ) - _, err := client.Firewall.Lockdowns.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "372e67954025e0ba6aaa6d586b9e0b59", - ) - 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 TestFirewallLockdownGet(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("user@example.com"), - ) - _, err := client.Firewall.Lockdowns.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "372e67954025e0ba6aaa6d586b9e0b59", - ) - 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/firewallrule.go b/firewallrule.go deleted file mode 100644 index ea5d92b8428..00000000000 --- a/firewallrule.go +++ /dev/null @@ -1,1600 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// FirewallRuleService 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 [NewFirewallRuleService] method -// instead. -type FirewallRuleService struct { - Options []option.RequestOption -} - -// NewFirewallRuleService 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 NewFirewallRuleService(opts ...option.RequestOption) (r *FirewallRuleService) { - r = &FirewallRuleService{} - r.Options = opts - return -} - -// Create one or more firewall rules. -func (r *FirewallRuleService) New(ctx context.Context, zoneIdentifier string, body FirewallRuleNewParams, opts ...option.RequestOption) (res *[]FirewallRuleNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallRuleNewResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/rules", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates an existing firewall rule. -func (r *FirewallRuleService) Update(ctx context.Context, zoneIdentifier string, id string, body FirewallRuleUpdateParams, opts ...option.RequestOption) (res *FirewallRuleUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallRuleUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/rules/%s", zoneIdentifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches firewall rules in a zone. You can filter the results using several -// optional parameters. -func (r *FirewallRuleService) List(ctx context.Context, zoneIdentifier string, query FirewallRuleListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[FirewallRuleListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("zones/%s/firewall/rules", zoneIdentifier) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Fetches firewall rules in a zone. You can filter the results using several -// optional parameters. -func (r *FirewallRuleService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query FirewallRuleListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[FirewallRuleListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) -} - -// Deletes an existing firewall rule. -func (r *FirewallRuleService) Delete(ctx context.Context, zoneIdentifier string, id string, body FirewallRuleDeleteParams, opts ...option.RequestOption) (res *FirewallRuleDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallRuleDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/rules/%s", zoneIdentifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates the priority of an existing firewall rule. -func (r *FirewallRuleService) Edit(ctx context.Context, zoneIdentifier string, id string, body FirewallRuleEditParams, opts ...option.RequestOption) (res *[]FirewallRuleEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallRuleEditResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/rules/%s", zoneIdentifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the details of a firewall rule. -func (r *FirewallRuleService) Get(ctx context.Context, zoneIdentifier string, id string, query FirewallRuleGetParams, opts ...option.RequestOption) (res *FirewallRuleGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallRuleGetResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/rules/%s", zoneIdentifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type FirewallRuleNewResponse struct { - // The unique identifier of the firewall rule. - ID string `json:"id,required"` - // The action to apply to a matched request. The `log` action is only available on - // an Enterprise plan. - Action FirewallRuleNewResponseAction `json:"action,required"` - Filter FirewallRuleNewResponseFilter `json:"filter,required"` - // When true, indicates that the firewall rule is currently paused. - Paused bool `json:"paused,required"` - // An informative summary of the firewall rule. - Description string `json:"description"` - // The priority of the rule. Optional value used to define the processing order. A - // lower number indicates a higher priority. If not provided, rules with a defined - // priority will be processed before rules without a priority. - Priority float64 `json:"priority"` - Products []FirewallRuleNewResponseProduct `json:"products"` - // A short reference tag. Allows you to select related firewall rules. - Ref string `json:"ref"` - JSON firewallRuleNewResponseJSON `json:"-"` -} - -// firewallRuleNewResponseJSON contains the JSON metadata for the struct -// [FirewallRuleNewResponse] -type firewallRuleNewResponseJSON struct { - ID apijson.Field - Action apijson.Field - Filter apijson.Field - Paused apijson.Field - Description apijson.Field - Priority apijson.Field - Products apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleNewResponseJSON) RawJSON() string { - return r.raw -} - -// The action to apply to a matched request. The `log` action is only available on -// an Enterprise plan. -type FirewallRuleNewResponseAction string - -const ( - FirewallRuleNewResponseActionBlock FirewallRuleNewResponseAction = "block" - FirewallRuleNewResponseActionChallenge FirewallRuleNewResponseAction = "challenge" - FirewallRuleNewResponseActionJsChallenge FirewallRuleNewResponseAction = "js_challenge" - FirewallRuleNewResponseActionManagedChallenge FirewallRuleNewResponseAction = "managed_challenge" - FirewallRuleNewResponseActionAllow FirewallRuleNewResponseAction = "allow" - FirewallRuleNewResponseActionLog FirewallRuleNewResponseAction = "log" - FirewallRuleNewResponseActionBypass FirewallRuleNewResponseAction = "bypass" -) - -// Union satisfied by [FirewallRuleNewResponseFilterLegacyJhsFilter] or -// [FirewallRuleNewResponseFilterLegacyJhsDeletedFilter]. -type FirewallRuleNewResponseFilter interface { - implementsFirewallRuleNewResponseFilter() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallRuleNewResponseFilter)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallRuleNewResponseFilterLegacyJhsFilter{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallRuleNewResponseFilterLegacyJhsDeletedFilter{}), - }, - ) -} - -type FirewallRuleNewResponseFilterLegacyJhsFilter struct { - // The unique identifier of the filter. - ID string `json:"id"` - // An informative summary of the filter. - Description string `json:"description"` - // The filter expression. For more information, refer to - // [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - Expression string `json:"expression"` - // When true, indicates that the filter is currently paused. - Paused bool `json:"paused"` - // A short reference tag. Allows you to select related filters. - Ref string `json:"ref"` - JSON firewallRuleNewResponseFilterLegacyJhsFilterJSON `json:"-"` -} - -// firewallRuleNewResponseFilterLegacyJhsFilterJSON contains the JSON metadata for -// the struct [FirewallRuleNewResponseFilterLegacyJhsFilter] -type firewallRuleNewResponseFilterLegacyJhsFilterJSON struct { - ID apijson.Field - Description apijson.Field - Expression apijson.Field - Paused apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleNewResponseFilterLegacyJhsFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleNewResponseFilterLegacyJhsFilterJSON) RawJSON() string { - return r.raw -} - -func (r FirewallRuleNewResponseFilterLegacyJhsFilter) implementsFirewallRuleNewResponseFilter() {} - -type FirewallRuleNewResponseFilterLegacyJhsDeletedFilter struct { - // The unique identifier of the filter. - ID string `json:"id,required"` - // When true, indicates that the firewall rule was deleted. - Deleted bool `json:"deleted,required"` - JSON firewallRuleNewResponseFilterLegacyJhsDeletedFilterJSON `json:"-"` -} - -// firewallRuleNewResponseFilterLegacyJhsDeletedFilterJSON contains the JSON -// metadata for the struct [FirewallRuleNewResponseFilterLegacyJhsDeletedFilter] -type firewallRuleNewResponseFilterLegacyJhsDeletedFilterJSON struct { - ID apijson.Field - Deleted apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleNewResponseFilterLegacyJhsDeletedFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleNewResponseFilterLegacyJhsDeletedFilterJSON) RawJSON() string { - return r.raw -} - -func (r FirewallRuleNewResponseFilterLegacyJhsDeletedFilter) implementsFirewallRuleNewResponseFilter() { -} - -// A list of products to bypass for a request when using the `bypass` action. -type FirewallRuleNewResponseProduct string - -const ( - FirewallRuleNewResponseProductZoneLockdown FirewallRuleNewResponseProduct = "zoneLockdown" - FirewallRuleNewResponseProductUABlock FirewallRuleNewResponseProduct = "uaBlock" - FirewallRuleNewResponseProductBic FirewallRuleNewResponseProduct = "bic" - FirewallRuleNewResponseProductHot FirewallRuleNewResponseProduct = "hot" - FirewallRuleNewResponseProductSecurityLevel FirewallRuleNewResponseProduct = "securityLevel" - FirewallRuleNewResponseProductRateLimit FirewallRuleNewResponseProduct = "rateLimit" - FirewallRuleNewResponseProductWAF FirewallRuleNewResponseProduct = "waf" -) - -type FirewallRuleUpdateResponse struct { - // The unique identifier of the firewall rule. - ID string `json:"id,required"` - // The action to apply to a matched request. The `log` action is only available on - // an Enterprise plan. - Action FirewallRuleUpdateResponseAction `json:"action,required"` - Filter FirewallRuleUpdateResponseFilter `json:"filter,required"` - // When true, indicates that the firewall rule is currently paused. - Paused bool `json:"paused,required"` - // An informative summary of the firewall rule. - Description string `json:"description"` - // The priority of the rule. Optional value used to define the processing order. A - // lower number indicates a higher priority. If not provided, rules with a defined - // priority will be processed before rules without a priority. - Priority float64 `json:"priority"` - Products []FirewallRuleUpdateResponseProduct `json:"products"` - // A short reference tag. Allows you to select related firewall rules. - Ref string `json:"ref"` - JSON firewallRuleUpdateResponseJSON `json:"-"` -} - -// firewallRuleUpdateResponseJSON contains the JSON metadata for the struct -// [FirewallRuleUpdateResponse] -type firewallRuleUpdateResponseJSON struct { - ID apijson.Field - Action apijson.Field - Filter apijson.Field - Paused apijson.Field - Description apijson.Field - Priority apijson.Field - Products apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// The action to apply to a matched request. The `log` action is only available on -// an Enterprise plan. -type FirewallRuleUpdateResponseAction string - -const ( - FirewallRuleUpdateResponseActionBlock FirewallRuleUpdateResponseAction = "block" - FirewallRuleUpdateResponseActionChallenge FirewallRuleUpdateResponseAction = "challenge" - FirewallRuleUpdateResponseActionJsChallenge FirewallRuleUpdateResponseAction = "js_challenge" - FirewallRuleUpdateResponseActionManagedChallenge FirewallRuleUpdateResponseAction = "managed_challenge" - FirewallRuleUpdateResponseActionAllow FirewallRuleUpdateResponseAction = "allow" - FirewallRuleUpdateResponseActionLog FirewallRuleUpdateResponseAction = "log" - FirewallRuleUpdateResponseActionBypass FirewallRuleUpdateResponseAction = "bypass" -) - -// Union satisfied by [FirewallRuleUpdateResponseFilterLegacyJhsFilter] or -// [FirewallRuleUpdateResponseFilterLegacyJhsDeletedFilter]. -type FirewallRuleUpdateResponseFilter interface { - implementsFirewallRuleUpdateResponseFilter() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallRuleUpdateResponseFilter)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallRuleUpdateResponseFilterLegacyJhsFilter{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallRuleUpdateResponseFilterLegacyJhsDeletedFilter{}), - }, - ) -} - -type FirewallRuleUpdateResponseFilterLegacyJhsFilter struct { - // The unique identifier of the filter. - ID string `json:"id"` - // An informative summary of the filter. - Description string `json:"description"` - // The filter expression. For more information, refer to - // [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - Expression string `json:"expression"` - // When true, indicates that the filter is currently paused. - Paused bool `json:"paused"` - // A short reference tag. Allows you to select related filters. - Ref string `json:"ref"` - JSON firewallRuleUpdateResponseFilterLegacyJhsFilterJSON `json:"-"` -} - -// firewallRuleUpdateResponseFilterLegacyJhsFilterJSON contains the JSON metadata -// for the struct [FirewallRuleUpdateResponseFilterLegacyJhsFilter] -type firewallRuleUpdateResponseFilterLegacyJhsFilterJSON struct { - ID apijson.Field - Description apijson.Field - Expression apijson.Field - Paused apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleUpdateResponseFilterLegacyJhsFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleUpdateResponseFilterLegacyJhsFilterJSON) RawJSON() string { - return r.raw -} - -func (r FirewallRuleUpdateResponseFilterLegacyJhsFilter) implementsFirewallRuleUpdateResponseFilter() { -} - -type FirewallRuleUpdateResponseFilterLegacyJhsDeletedFilter struct { - // The unique identifier of the filter. - ID string `json:"id,required"` - // When true, indicates that the firewall rule was deleted. - Deleted bool `json:"deleted,required"` - JSON firewallRuleUpdateResponseFilterLegacyJhsDeletedFilterJSON `json:"-"` -} - -// firewallRuleUpdateResponseFilterLegacyJhsDeletedFilterJSON contains the JSON -// metadata for the struct [FirewallRuleUpdateResponseFilterLegacyJhsDeletedFilter] -type firewallRuleUpdateResponseFilterLegacyJhsDeletedFilterJSON struct { - ID apijson.Field - Deleted apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleUpdateResponseFilterLegacyJhsDeletedFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleUpdateResponseFilterLegacyJhsDeletedFilterJSON) RawJSON() string { - return r.raw -} - -func (r FirewallRuleUpdateResponseFilterLegacyJhsDeletedFilter) implementsFirewallRuleUpdateResponseFilter() { -} - -// A list of products to bypass for a request when using the `bypass` action. -type FirewallRuleUpdateResponseProduct string - -const ( - FirewallRuleUpdateResponseProductZoneLockdown FirewallRuleUpdateResponseProduct = "zoneLockdown" - FirewallRuleUpdateResponseProductUABlock FirewallRuleUpdateResponseProduct = "uaBlock" - FirewallRuleUpdateResponseProductBic FirewallRuleUpdateResponseProduct = "bic" - FirewallRuleUpdateResponseProductHot FirewallRuleUpdateResponseProduct = "hot" - FirewallRuleUpdateResponseProductSecurityLevel FirewallRuleUpdateResponseProduct = "securityLevel" - FirewallRuleUpdateResponseProductRateLimit FirewallRuleUpdateResponseProduct = "rateLimit" - FirewallRuleUpdateResponseProductWAF FirewallRuleUpdateResponseProduct = "waf" -) - -type FirewallRuleListResponse struct { - // The unique identifier of the firewall rule. - ID string `json:"id,required"` - // The action to apply to a matched request. The `log` action is only available on - // an Enterprise plan. - Action FirewallRuleListResponseAction `json:"action,required"` - Filter FirewallRuleListResponseFilter `json:"filter,required"` - // When true, indicates that the firewall rule is currently paused. - Paused bool `json:"paused,required"` - // An informative summary of the firewall rule. - Description string `json:"description"` - // The priority of the rule. Optional value used to define the processing order. A - // lower number indicates a higher priority. If not provided, rules with a defined - // priority will be processed before rules without a priority. - Priority float64 `json:"priority"` - Products []FirewallRuleListResponseProduct `json:"products"` - // A short reference tag. Allows you to select related firewall rules. - Ref string `json:"ref"` - JSON firewallRuleListResponseJSON `json:"-"` -} - -// firewallRuleListResponseJSON contains the JSON metadata for the struct -// [FirewallRuleListResponse] -type firewallRuleListResponseJSON struct { - ID apijson.Field - Action apijson.Field - Filter apijson.Field - Paused apijson.Field - Description apijson.Field - Priority apijson.Field - Products apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleListResponseJSON) RawJSON() string { - return r.raw -} - -// The action to apply to a matched request. The `log` action is only available on -// an Enterprise plan. -type FirewallRuleListResponseAction string - -const ( - FirewallRuleListResponseActionBlock FirewallRuleListResponseAction = "block" - FirewallRuleListResponseActionChallenge FirewallRuleListResponseAction = "challenge" - FirewallRuleListResponseActionJsChallenge FirewallRuleListResponseAction = "js_challenge" - FirewallRuleListResponseActionManagedChallenge FirewallRuleListResponseAction = "managed_challenge" - FirewallRuleListResponseActionAllow FirewallRuleListResponseAction = "allow" - FirewallRuleListResponseActionLog FirewallRuleListResponseAction = "log" - FirewallRuleListResponseActionBypass FirewallRuleListResponseAction = "bypass" -) - -// Union satisfied by [FirewallRuleListResponseFilterLegacyJhsFilter] or -// [FirewallRuleListResponseFilterLegacyJhsDeletedFilter]. -type FirewallRuleListResponseFilter interface { - implementsFirewallRuleListResponseFilter() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallRuleListResponseFilter)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallRuleListResponseFilterLegacyJhsFilter{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallRuleListResponseFilterLegacyJhsDeletedFilter{}), - }, - ) -} - -type FirewallRuleListResponseFilterLegacyJhsFilter struct { - // The unique identifier of the filter. - ID string `json:"id"` - // An informative summary of the filter. - Description string `json:"description"` - // The filter expression. For more information, refer to - // [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - Expression string `json:"expression"` - // When true, indicates that the filter is currently paused. - Paused bool `json:"paused"` - // A short reference tag. Allows you to select related filters. - Ref string `json:"ref"` - JSON firewallRuleListResponseFilterLegacyJhsFilterJSON `json:"-"` -} - -// firewallRuleListResponseFilterLegacyJhsFilterJSON contains the JSON metadata for -// the struct [FirewallRuleListResponseFilterLegacyJhsFilter] -type firewallRuleListResponseFilterLegacyJhsFilterJSON struct { - ID apijson.Field - Description apijson.Field - Expression apijson.Field - Paused apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleListResponseFilterLegacyJhsFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleListResponseFilterLegacyJhsFilterJSON) RawJSON() string { - return r.raw -} - -func (r FirewallRuleListResponseFilterLegacyJhsFilter) implementsFirewallRuleListResponseFilter() {} - -type FirewallRuleListResponseFilterLegacyJhsDeletedFilter struct { - // The unique identifier of the filter. - ID string `json:"id,required"` - // When true, indicates that the firewall rule was deleted. - Deleted bool `json:"deleted,required"` - JSON firewallRuleListResponseFilterLegacyJhsDeletedFilterJSON `json:"-"` -} - -// firewallRuleListResponseFilterLegacyJhsDeletedFilterJSON contains the JSON -// metadata for the struct [FirewallRuleListResponseFilterLegacyJhsDeletedFilter] -type firewallRuleListResponseFilterLegacyJhsDeletedFilterJSON struct { - ID apijson.Field - Deleted apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleListResponseFilterLegacyJhsDeletedFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleListResponseFilterLegacyJhsDeletedFilterJSON) RawJSON() string { - return r.raw -} - -func (r FirewallRuleListResponseFilterLegacyJhsDeletedFilter) implementsFirewallRuleListResponseFilter() { -} - -// A list of products to bypass for a request when using the `bypass` action. -type FirewallRuleListResponseProduct string - -const ( - FirewallRuleListResponseProductZoneLockdown FirewallRuleListResponseProduct = "zoneLockdown" - FirewallRuleListResponseProductUABlock FirewallRuleListResponseProduct = "uaBlock" - FirewallRuleListResponseProductBic FirewallRuleListResponseProduct = "bic" - FirewallRuleListResponseProductHot FirewallRuleListResponseProduct = "hot" - FirewallRuleListResponseProductSecurityLevel FirewallRuleListResponseProduct = "securityLevel" - FirewallRuleListResponseProductRateLimit FirewallRuleListResponseProduct = "rateLimit" - FirewallRuleListResponseProductWAF FirewallRuleListResponseProduct = "waf" -) - -type FirewallRuleDeleteResponse struct { - // The unique identifier of the firewall rule. - ID string `json:"id,required"` - // The action to apply to a matched request. The `log` action is only available on - // an Enterprise plan. - Action FirewallRuleDeleteResponseAction `json:"action"` - // An informative summary of the firewall rule. - Description string `json:"description"` - Filter FirewallRuleDeleteResponseFilter `json:"filter"` - // When true, indicates that the firewall rule is currently paused. - Paused bool `json:"paused"` - // The priority of the rule. Optional value used to define the processing order. A - // lower number indicates a higher priority. If not provided, rules with a defined - // priority will be processed before rules without a priority. - Priority float64 `json:"priority"` - Products []FirewallRuleDeleteResponseProduct `json:"products"` - // A short reference tag. Allows you to select related firewall rules. - Ref string `json:"ref"` - JSON firewallRuleDeleteResponseJSON `json:"-"` -} - -// firewallRuleDeleteResponseJSON contains the JSON metadata for the struct -// [FirewallRuleDeleteResponse] -type firewallRuleDeleteResponseJSON struct { - ID apijson.Field - Action apijson.Field - Description apijson.Field - Filter apijson.Field - Paused apijson.Field - Priority apijson.Field - Products apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// The action to apply to a matched request. The `log` action is only available on -// an Enterprise plan. -type FirewallRuleDeleteResponseAction string - -const ( - FirewallRuleDeleteResponseActionBlock FirewallRuleDeleteResponseAction = "block" - FirewallRuleDeleteResponseActionChallenge FirewallRuleDeleteResponseAction = "challenge" - FirewallRuleDeleteResponseActionJsChallenge FirewallRuleDeleteResponseAction = "js_challenge" - FirewallRuleDeleteResponseActionManagedChallenge FirewallRuleDeleteResponseAction = "managed_challenge" - FirewallRuleDeleteResponseActionAllow FirewallRuleDeleteResponseAction = "allow" - FirewallRuleDeleteResponseActionLog FirewallRuleDeleteResponseAction = "log" - FirewallRuleDeleteResponseActionBypass FirewallRuleDeleteResponseAction = "bypass" -) - -// Union satisfied by [FirewallRuleDeleteResponseFilterLegacyJhsFilter] or -// [FirewallRuleDeleteResponseFilterLegacyJhsDeletedFilter]. -type FirewallRuleDeleteResponseFilter interface { - implementsFirewallRuleDeleteResponseFilter() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallRuleDeleteResponseFilter)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallRuleDeleteResponseFilterLegacyJhsFilter{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallRuleDeleteResponseFilterLegacyJhsDeletedFilter{}), - }, - ) -} - -type FirewallRuleDeleteResponseFilterLegacyJhsFilter struct { - // The unique identifier of the filter. - ID string `json:"id"` - // An informative summary of the filter. - Description string `json:"description"` - // The filter expression. For more information, refer to - // [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - Expression string `json:"expression"` - // When true, indicates that the filter is currently paused. - Paused bool `json:"paused"` - // A short reference tag. Allows you to select related filters. - Ref string `json:"ref"` - JSON firewallRuleDeleteResponseFilterLegacyJhsFilterJSON `json:"-"` -} - -// firewallRuleDeleteResponseFilterLegacyJhsFilterJSON contains the JSON metadata -// for the struct [FirewallRuleDeleteResponseFilterLegacyJhsFilter] -type firewallRuleDeleteResponseFilterLegacyJhsFilterJSON struct { - ID apijson.Field - Description apijson.Field - Expression apijson.Field - Paused apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleDeleteResponseFilterLegacyJhsFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleDeleteResponseFilterLegacyJhsFilterJSON) RawJSON() string { - return r.raw -} - -func (r FirewallRuleDeleteResponseFilterLegacyJhsFilter) implementsFirewallRuleDeleteResponseFilter() { -} - -type FirewallRuleDeleteResponseFilterLegacyJhsDeletedFilter struct { - // The unique identifier of the filter. - ID string `json:"id,required"` - // When true, indicates that the firewall rule was deleted. - Deleted bool `json:"deleted,required"` - JSON firewallRuleDeleteResponseFilterLegacyJhsDeletedFilterJSON `json:"-"` -} - -// firewallRuleDeleteResponseFilterLegacyJhsDeletedFilterJSON contains the JSON -// metadata for the struct [FirewallRuleDeleteResponseFilterLegacyJhsDeletedFilter] -type firewallRuleDeleteResponseFilterLegacyJhsDeletedFilterJSON struct { - ID apijson.Field - Deleted apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleDeleteResponseFilterLegacyJhsDeletedFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleDeleteResponseFilterLegacyJhsDeletedFilterJSON) RawJSON() string { - return r.raw -} - -func (r FirewallRuleDeleteResponseFilterLegacyJhsDeletedFilter) implementsFirewallRuleDeleteResponseFilter() { -} - -// A list of products to bypass for a request when using the `bypass` action. -type FirewallRuleDeleteResponseProduct string - -const ( - FirewallRuleDeleteResponseProductZoneLockdown FirewallRuleDeleteResponseProduct = "zoneLockdown" - FirewallRuleDeleteResponseProductUABlock FirewallRuleDeleteResponseProduct = "uaBlock" - FirewallRuleDeleteResponseProductBic FirewallRuleDeleteResponseProduct = "bic" - FirewallRuleDeleteResponseProductHot FirewallRuleDeleteResponseProduct = "hot" - FirewallRuleDeleteResponseProductSecurityLevel FirewallRuleDeleteResponseProduct = "securityLevel" - FirewallRuleDeleteResponseProductRateLimit FirewallRuleDeleteResponseProduct = "rateLimit" - FirewallRuleDeleteResponseProductWAF FirewallRuleDeleteResponseProduct = "waf" -) - -type FirewallRuleEditResponse struct { - // The unique identifier of the firewall rule. - ID string `json:"id,required"` - // The action to apply to a matched request. The `log` action is only available on - // an Enterprise plan. - Action FirewallRuleEditResponseAction `json:"action,required"` - Filter FirewallRuleEditResponseFilter `json:"filter,required"` - // When true, indicates that the firewall rule is currently paused. - Paused bool `json:"paused,required"` - // An informative summary of the firewall rule. - Description string `json:"description"` - // The priority of the rule. Optional value used to define the processing order. A - // lower number indicates a higher priority. If not provided, rules with a defined - // priority will be processed before rules without a priority. - Priority float64 `json:"priority"` - Products []FirewallRuleEditResponseProduct `json:"products"` - // A short reference tag. Allows you to select related firewall rules. - Ref string `json:"ref"` - JSON firewallRuleEditResponseJSON `json:"-"` -} - -// firewallRuleEditResponseJSON contains the JSON metadata for the struct -// [FirewallRuleEditResponse] -type firewallRuleEditResponseJSON struct { - ID apijson.Field - Action apijson.Field - Filter apijson.Field - Paused apijson.Field - Description apijson.Field - Priority apijson.Field - Products apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleEditResponseJSON) RawJSON() string { - return r.raw -} - -// The action to apply to a matched request. The `log` action is only available on -// an Enterprise plan. -type FirewallRuleEditResponseAction string - -const ( - FirewallRuleEditResponseActionBlock FirewallRuleEditResponseAction = "block" - FirewallRuleEditResponseActionChallenge FirewallRuleEditResponseAction = "challenge" - FirewallRuleEditResponseActionJsChallenge FirewallRuleEditResponseAction = "js_challenge" - FirewallRuleEditResponseActionManagedChallenge FirewallRuleEditResponseAction = "managed_challenge" - FirewallRuleEditResponseActionAllow FirewallRuleEditResponseAction = "allow" - FirewallRuleEditResponseActionLog FirewallRuleEditResponseAction = "log" - FirewallRuleEditResponseActionBypass FirewallRuleEditResponseAction = "bypass" -) - -// Union satisfied by [FirewallRuleEditResponseFilterLegacyJhsFilter] or -// [FirewallRuleEditResponseFilterLegacyJhsDeletedFilter]. -type FirewallRuleEditResponseFilter interface { - implementsFirewallRuleEditResponseFilter() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallRuleEditResponseFilter)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallRuleEditResponseFilterLegacyJhsFilter{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallRuleEditResponseFilterLegacyJhsDeletedFilter{}), - }, - ) -} - -type FirewallRuleEditResponseFilterLegacyJhsFilter struct { - // The unique identifier of the filter. - ID string `json:"id"` - // An informative summary of the filter. - Description string `json:"description"` - // The filter expression. For more information, refer to - // [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - Expression string `json:"expression"` - // When true, indicates that the filter is currently paused. - Paused bool `json:"paused"` - // A short reference tag. Allows you to select related filters. - Ref string `json:"ref"` - JSON firewallRuleEditResponseFilterLegacyJhsFilterJSON `json:"-"` -} - -// firewallRuleEditResponseFilterLegacyJhsFilterJSON contains the JSON metadata for -// the struct [FirewallRuleEditResponseFilterLegacyJhsFilter] -type firewallRuleEditResponseFilterLegacyJhsFilterJSON struct { - ID apijson.Field - Description apijson.Field - Expression apijson.Field - Paused apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleEditResponseFilterLegacyJhsFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleEditResponseFilterLegacyJhsFilterJSON) RawJSON() string { - return r.raw -} - -func (r FirewallRuleEditResponseFilterLegacyJhsFilter) implementsFirewallRuleEditResponseFilter() {} - -type FirewallRuleEditResponseFilterLegacyJhsDeletedFilter struct { - // The unique identifier of the filter. - ID string `json:"id,required"` - // When true, indicates that the firewall rule was deleted. - Deleted bool `json:"deleted,required"` - JSON firewallRuleEditResponseFilterLegacyJhsDeletedFilterJSON `json:"-"` -} - -// firewallRuleEditResponseFilterLegacyJhsDeletedFilterJSON contains the JSON -// metadata for the struct [FirewallRuleEditResponseFilterLegacyJhsDeletedFilter] -type firewallRuleEditResponseFilterLegacyJhsDeletedFilterJSON struct { - ID apijson.Field - Deleted apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleEditResponseFilterLegacyJhsDeletedFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleEditResponseFilterLegacyJhsDeletedFilterJSON) RawJSON() string { - return r.raw -} - -func (r FirewallRuleEditResponseFilterLegacyJhsDeletedFilter) implementsFirewallRuleEditResponseFilter() { -} - -// A list of products to bypass for a request when using the `bypass` action. -type FirewallRuleEditResponseProduct string - -const ( - FirewallRuleEditResponseProductZoneLockdown FirewallRuleEditResponseProduct = "zoneLockdown" - FirewallRuleEditResponseProductUABlock FirewallRuleEditResponseProduct = "uaBlock" - FirewallRuleEditResponseProductBic FirewallRuleEditResponseProduct = "bic" - FirewallRuleEditResponseProductHot FirewallRuleEditResponseProduct = "hot" - FirewallRuleEditResponseProductSecurityLevel FirewallRuleEditResponseProduct = "securityLevel" - FirewallRuleEditResponseProductRateLimit FirewallRuleEditResponseProduct = "rateLimit" - FirewallRuleEditResponseProductWAF FirewallRuleEditResponseProduct = "waf" -) - -type FirewallRuleGetResponse struct { - // The unique identifier of the firewall rule. - ID string `json:"id,required"` - // The action to apply to a matched request. The `log` action is only available on - // an Enterprise plan. - Action FirewallRuleGetResponseAction `json:"action,required"` - Filter FirewallRuleGetResponseFilter `json:"filter,required"` - // When true, indicates that the firewall rule is currently paused. - Paused bool `json:"paused,required"` - // An informative summary of the firewall rule. - Description string `json:"description"` - // The priority of the rule. Optional value used to define the processing order. A - // lower number indicates a higher priority. If not provided, rules with a defined - // priority will be processed before rules without a priority. - Priority float64 `json:"priority"` - Products []FirewallRuleGetResponseProduct `json:"products"` - // A short reference tag. Allows you to select related firewall rules. - Ref string `json:"ref"` - JSON firewallRuleGetResponseJSON `json:"-"` -} - -// firewallRuleGetResponseJSON contains the JSON metadata for the struct -// [FirewallRuleGetResponse] -type firewallRuleGetResponseJSON struct { - ID apijson.Field - Action apijson.Field - Filter apijson.Field - Paused apijson.Field - Description apijson.Field - Priority apijson.Field - Products apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleGetResponseJSON) RawJSON() string { - return r.raw -} - -// The action to apply to a matched request. The `log` action is only available on -// an Enterprise plan. -type FirewallRuleGetResponseAction string - -const ( - FirewallRuleGetResponseActionBlock FirewallRuleGetResponseAction = "block" - FirewallRuleGetResponseActionChallenge FirewallRuleGetResponseAction = "challenge" - FirewallRuleGetResponseActionJsChallenge FirewallRuleGetResponseAction = "js_challenge" - FirewallRuleGetResponseActionManagedChallenge FirewallRuleGetResponseAction = "managed_challenge" - FirewallRuleGetResponseActionAllow FirewallRuleGetResponseAction = "allow" - FirewallRuleGetResponseActionLog FirewallRuleGetResponseAction = "log" - FirewallRuleGetResponseActionBypass FirewallRuleGetResponseAction = "bypass" -) - -// Union satisfied by [FirewallRuleGetResponseFilterLegacyJhsFilter] or -// [FirewallRuleGetResponseFilterLegacyJhsDeletedFilter]. -type FirewallRuleGetResponseFilter interface { - implementsFirewallRuleGetResponseFilter() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallRuleGetResponseFilter)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallRuleGetResponseFilterLegacyJhsFilter{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallRuleGetResponseFilterLegacyJhsDeletedFilter{}), - }, - ) -} - -type FirewallRuleGetResponseFilterLegacyJhsFilter struct { - // The unique identifier of the filter. - ID string `json:"id"` - // An informative summary of the filter. - Description string `json:"description"` - // The filter expression. For more information, refer to - // [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - Expression string `json:"expression"` - // When true, indicates that the filter is currently paused. - Paused bool `json:"paused"` - // A short reference tag. Allows you to select related filters. - Ref string `json:"ref"` - JSON firewallRuleGetResponseFilterLegacyJhsFilterJSON `json:"-"` -} - -// firewallRuleGetResponseFilterLegacyJhsFilterJSON contains the JSON metadata for -// the struct [FirewallRuleGetResponseFilterLegacyJhsFilter] -type firewallRuleGetResponseFilterLegacyJhsFilterJSON struct { - ID apijson.Field - Description apijson.Field - Expression apijson.Field - Paused apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleGetResponseFilterLegacyJhsFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleGetResponseFilterLegacyJhsFilterJSON) RawJSON() string { - return r.raw -} - -func (r FirewallRuleGetResponseFilterLegacyJhsFilter) implementsFirewallRuleGetResponseFilter() {} - -type FirewallRuleGetResponseFilterLegacyJhsDeletedFilter struct { - // The unique identifier of the filter. - ID string `json:"id,required"` - // When true, indicates that the firewall rule was deleted. - Deleted bool `json:"deleted,required"` - JSON firewallRuleGetResponseFilterLegacyJhsDeletedFilterJSON `json:"-"` -} - -// firewallRuleGetResponseFilterLegacyJhsDeletedFilterJSON contains the JSON -// metadata for the struct [FirewallRuleGetResponseFilterLegacyJhsDeletedFilter] -type firewallRuleGetResponseFilterLegacyJhsDeletedFilterJSON struct { - ID apijson.Field - Deleted apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleGetResponseFilterLegacyJhsDeletedFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleGetResponseFilterLegacyJhsDeletedFilterJSON) RawJSON() string { - return r.raw -} - -func (r FirewallRuleGetResponseFilterLegacyJhsDeletedFilter) implementsFirewallRuleGetResponseFilter() { -} - -// A list of products to bypass for a request when using the `bypass` action. -type FirewallRuleGetResponseProduct string - -const ( - FirewallRuleGetResponseProductZoneLockdown FirewallRuleGetResponseProduct = "zoneLockdown" - FirewallRuleGetResponseProductUABlock FirewallRuleGetResponseProduct = "uaBlock" - FirewallRuleGetResponseProductBic FirewallRuleGetResponseProduct = "bic" - FirewallRuleGetResponseProductHot FirewallRuleGetResponseProduct = "hot" - FirewallRuleGetResponseProductSecurityLevel FirewallRuleGetResponseProduct = "securityLevel" - FirewallRuleGetResponseProductRateLimit FirewallRuleGetResponseProduct = "rateLimit" - FirewallRuleGetResponseProductWAF FirewallRuleGetResponseProduct = "waf" -) - -type FirewallRuleNewParams struct { - Body param.Field[interface{}] `json:"body,required"` -} - -func (r FirewallRuleNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type FirewallRuleNewResponseEnvelope struct { - Errors []FirewallRuleNewResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallRuleNewResponseEnvelopeMessages `json:"messages,required"` - Result []FirewallRuleNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallRuleNewResponseEnvelopeSuccess `json:"success,required"` - ResultInfo FirewallRuleNewResponseEnvelopeResultInfo `json:"result_info"` - JSON firewallRuleNewResponseEnvelopeJSON `json:"-"` -} - -// firewallRuleNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [FirewallRuleNewResponseEnvelope] -type firewallRuleNewResponseEnvelopeJSON 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 *FirewallRuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallRuleNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallRuleNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallRuleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [FirewallRuleNewResponseEnvelopeErrors] -type firewallRuleNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallRuleNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallRuleNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallRuleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [FirewallRuleNewResponseEnvelopeMessages] -type firewallRuleNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallRuleNewResponseEnvelopeSuccess bool - -const ( - FirewallRuleNewResponseEnvelopeSuccessTrue FirewallRuleNewResponseEnvelopeSuccess = true -) - -type FirewallRuleNewResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON firewallRuleNewResponseEnvelopeResultInfoJSON `json:"-"` -} - -// firewallRuleNewResponseEnvelopeResultInfoJSON contains the JSON metadata for the -// struct [FirewallRuleNewResponseEnvelopeResultInfo] -type firewallRuleNewResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleNewResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type FirewallRuleUpdateParams struct { - Body param.Field[interface{}] `json:"body,required"` -} - -func (r FirewallRuleUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type FirewallRuleUpdateResponseEnvelope struct { - Errors []FirewallRuleUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallRuleUpdateResponseEnvelopeMessages `json:"messages,required"` - Result FirewallRuleUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallRuleUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON firewallRuleUpdateResponseEnvelopeJSON `json:"-"` -} - -// firewallRuleUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [FirewallRuleUpdateResponseEnvelope] -type firewallRuleUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallRuleUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallRuleUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallRuleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [FirewallRuleUpdateResponseEnvelopeErrors] -type firewallRuleUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallRuleUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallRuleUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallRuleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [FirewallRuleUpdateResponseEnvelopeMessages] -type firewallRuleUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallRuleUpdateResponseEnvelopeSuccess bool - -const ( - FirewallRuleUpdateResponseEnvelopeSuccessTrue FirewallRuleUpdateResponseEnvelopeSuccess = true -) - -type FirewallRuleListParams struct { - // The action to search for. Must be an exact match. - Action param.Field[string] `query:"action"` - // A case-insensitive string to find in the description. - Description param.Field[string] `query:"description"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // When true, indicates that the firewall rule is currently paused. - Paused param.Field[bool] `query:"paused"` - // Number of firewall rules per page. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [FirewallRuleListParams]'s query parameters as `url.Values`. -func (r FirewallRuleListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type FirewallRuleDeleteParams struct { - // When true, indicates that Cloudflare should also delete the associated filter if - // there are no other firewall rules referencing the filter. - DeleteFilterIfUnused param.Field[bool] `json:"delete_filter_if_unused"` -} - -func (r FirewallRuleDeleteParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type FirewallRuleDeleteResponseEnvelope struct { - Errors []FirewallRuleDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallRuleDeleteResponseEnvelopeMessages `json:"messages,required"` - Result FirewallRuleDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallRuleDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON firewallRuleDeleteResponseEnvelopeJSON `json:"-"` -} - -// firewallRuleDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [FirewallRuleDeleteResponseEnvelope] -type firewallRuleDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallRuleDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallRuleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallRuleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [FirewallRuleDeleteResponseEnvelopeErrors] -type firewallRuleDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallRuleDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallRuleDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallRuleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [FirewallRuleDeleteResponseEnvelopeMessages] -type firewallRuleDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallRuleDeleteResponseEnvelopeSuccess bool - -const ( - FirewallRuleDeleteResponseEnvelopeSuccessTrue FirewallRuleDeleteResponseEnvelopeSuccess = true -) - -type FirewallRuleEditParams struct { - Body param.Field[interface{}] `json:"body,required"` -} - -func (r FirewallRuleEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type FirewallRuleEditResponseEnvelope struct { - Errors []FirewallRuleEditResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallRuleEditResponseEnvelopeMessages `json:"messages,required"` - Result []FirewallRuleEditResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallRuleEditResponseEnvelopeSuccess `json:"success,required"` - ResultInfo FirewallRuleEditResponseEnvelopeResultInfo `json:"result_info"` - JSON firewallRuleEditResponseEnvelopeJSON `json:"-"` -} - -// firewallRuleEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [FirewallRuleEditResponseEnvelope] -type firewallRuleEditResponseEnvelopeJSON 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 *FirewallRuleEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallRuleEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallRuleEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallRuleEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [FirewallRuleEditResponseEnvelopeErrors] -type firewallRuleEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallRuleEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallRuleEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallRuleEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [FirewallRuleEditResponseEnvelopeMessages] -type firewallRuleEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallRuleEditResponseEnvelopeSuccess bool - -const ( - FirewallRuleEditResponseEnvelopeSuccessTrue FirewallRuleEditResponseEnvelopeSuccess = true -) - -type FirewallRuleEditResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON firewallRuleEditResponseEnvelopeResultInfoJSON `json:"-"` -} - -// firewallRuleEditResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [FirewallRuleEditResponseEnvelopeResultInfo] -type firewallRuleEditResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleEditResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleEditResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type FirewallRuleGetParams struct { -} - -type FirewallRuleGetResponseEnvelope struct { - Errors []FirewallRuleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallRuleGetResponseEnvelopeMessages `json:"messages,required"` - Result FirewallRuleGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallRuleGetResponseEnvelopeSuccess `json:"success,required"` - JSON firewallRuleGetResponseEnvelopeJSON `json:"-"` -} - -// firewallRuleGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [FirewallRuleGetResponseEnvelope] -type firewallRuleGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallRuleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallRuleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallRuleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [FirewallRuleGetResponseEnvelopeErrors] -type firewallRuleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallRuleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallRuleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallRuleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [FirewallRuleGetResponseEnvelopeMessages] -type firewallRuleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallRuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallRuleGetResponseEnvelopeSuccess bool - -const ( - FirewallRuleGetResponseEnvelopeSuccessTrue FirewallRuleGetResponseEnvelopeSuccess = true -) diff --git a/firewallrule_test.go b/firewallrule_test.go deleted file mode 100644 index 73d6c40e44f..00000000000 --- a/firewallrule_test.go +++ /dev/null @@ -1,200 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestFirewallRuleNew(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("user@example.com"), - ) - _, err := client.Firewall.Rules.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.FirewallRuleNewParams{ - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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 TestFirewallRuleUpdate(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("user@example.com"), - ) - _, err := client.Firewall.Rules.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "372e67954025e0ba6aaa6d586b9e0b60", - cloudflare.FirewallRuleUpdateParams{ - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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 TestFirewallRuleListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Firewall.Rules.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.FirewallRuleListParams{ - Action: cloudflare.F("block"), - Description: cloudflare.F("mir"), - Page: cloudflare.F(1.000000), - Paused: cloudflare.F(false), - PerPage: cloudflare.F(5.000000), - }, - ) - 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 TestFirewallRuleDeleteWithOptionalParams(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("user@example.com"), - ) - _, err := client.Firewall.Rules.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "372e67954025e0ba6aaa6d586b9e0b60", - cloudflare.FirewallRuleDeleteParams{ - DeleteFilterIfUnused: cloudflare.F(true), - }, - ) - 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 TestFirewallRuleEdit(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("user@example.com"), - ) - _, err := client.Firewall.Rules.Edit( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "372e67954025e0ba6aaa6d586b9e0b60", - cloudflare.FirewallRuleEditParams{ - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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 TestFirewallRuleGet(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("user@example.com"), - ) - _, err := client.Firewall.Rules.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "372e67954025e0ba6aaa6d586b9e0b60", - cloudflare.FirewallRuleGetParams{}, - ) - 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/firewalluarule.go b/firewalluarule.go deleted file mode 100644 index 567f0fea098..00000000000 --- a/firewalluarule.go +++ /dev/null @@ -1,620 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// FirewallUARuleService 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 [NewFirewallUARuleService] method -// instead. -type FirewallUARuleService struct { - Options []option.RequestOption -} - -// NewFirewallUARuleService 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 NewFirewallUARuleService(opts ...option.RequestOption) (r *FirewallUARuleService) { - r = &FirewallUARuleService{} - r.Options = opts - return -} - -// Creates a new User Agent Blocking rule in a zone. -func (r *FirewallUARuleService) New(ctx context.Context, zoneIdentifier string, body FirewallUARuleNewParams, opts ...option.RequestOption) (res *FirewallUARuleNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallUARuleNewResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/ua_rules", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates an existing User Agent Blocking rule. -func (r *FirewallUARuleService) Update(ctx context.Context, zoneIdentifier string, id string, body FirewallUARuleUpdateParams, opts ...option.RequestOption) (res *FirewallUARuleUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallUARuleUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/ua_rules/%s", zoneIdentifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches User Agent Blocking rules in a zone. You can filter the results using -// several optional parameters. -func (r *FirewallUARuleService) List(ctx context.Context, zoneIdentifier string, query FirewallUARuleListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[FirewallUARuleListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("zones/%s/firewall/ua_rules", zoneIdentifier) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Fetches User Agent Blocking rules in a zone. You can filter the results using -// several optional parameters. -func (r *FirewallUARuleService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query FirewallUARuleListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[FirewallUARuleListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) -} - -// Deletes an existing User Agent Blocking rule. -func (r *FirewallUARuleService) Delete(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *FirewallUARuleDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallUARuleDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/ua_rules/%s", zoneIdentifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the details of a User Agent Blocking rule. -func (r *FirewallUARuleService) Get(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *FirewallUARuleGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallUARuleGetResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/ua_rules/%s", zoneIdentifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [FirewallUARuleNewResponseUnknown] or [shared.UnionString]. -type FirewallUARuleNewResponse interface { - ImplementsFirewallUARuleNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallUARuleNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [FirewallUARuleUpdateResponseUnknown] or -// [shared.UnionString]. -type FirewallUARuleUpdateResponse interface { - ImplementsFirewallUARuleUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallUARuleUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type FirewallUARuleListResponse struct { - // The unique identifier of the User Agent Blocking rule. - ID string `json:"id"` - // The configuration object for the current rule. - Configuration FirewallUARuleListResponseConfiguration `json:"configuration"` - // An informative summary of the rule. - Description string `json:"description"` - // The action to apply to a matched request. - Mode FirewallUARuleListResponseMode `json:"mode"` - // When true, indicates that the rule is currently paused. - Paused bool `json:"paused"` - JSON firewallUARuleListResponseJSON `json:"-"` -} - -// firewallUARuleListResponseJSON contains the JSON metadata for the struct -// [FirewallUARuleListResponse] -type firewallUARuleListResponseJSON struct { - ID apijson.Field - Configuration apijson.Field - Description apijson.Field - Mode apijson.Field - Paused apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallUARuleListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallUARuleListResponseJSON) RawJSON() string { - return r.raw -} - -// The configuration object for the current rule. -type FirewallUARuleListResponseConfiguration struct { - // The configuration target for this rule. You must set the target to `ua` for User - // Agent Blocking rules. - Target string `json:"target"` - // The exact user agent string to match. This value will be compared to the - // received `User-Agent` HTTP header value. - Value string `json:"value"` - JSON firewallUARuleListResponseConfigurationJSON `json:"-"` -} - -// firewallUARuleListResponseConfigurationJSON contains the JSON metadata for the -// struct [FirewallUARuleListResponseConfiguration] -type firewallUARuleListResponseConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallUARuleListResponseConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallUARuleListResponseConfigurationJSON) RawJSON() string { - return r.raw -} - -// The action to apply to a matched request. -type FirewallUARuleListResponseMode string - -const ( - FirewallUARuleListResponseModeBlock FirewallUARuleListResponseMode = "block" - FirewallUARuleListResponseModeChallenge FirewallUARuleListResponseMode = "challenge" - FirewallUARuleListResponseModeJsChallenge FirewallUARuleListResponseMode = "js_challenge" - FirewallUARuleListResponseModeManagedChallenge FirewallUARuleListResponseMode = "managed_challenge" -) - -type FirewallUARuleDeleteResponse struct { - // The unique identifier of the User Agent Blocking rule. - ID string `json:"id"` - JSON firewallUARuleDeleteResponseJSON `json:"-"` -} - -// firewallUARuleDeleteResponseJSON contains the JSON metadata for the struct -// [FirewallUARuleDeleteResponse] -type firewallUARuleDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallUARuleDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallUARuleDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [FirewallUARuleGetResponseUnknown] or [shared.UnionString]. -type FirewallUARuleGetResponse interface { - ImplementsFirewallUARuleGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallUARuleGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type FirewallUARuleNewParams struct { - Body param.Field[interface{}] `json:"body,required"` -} - -func (r FirewallUARuleNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type FirewallUARuleNewResponseEnvelope struct { - Errors []FirewallUARuleNewResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallUARuleNewResponseEnvelopeMessages `json:"messages,required"` - Result FirewallUARuleNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallUARuleNewResponseEnvelopeSuccess `json:"success,required"` - JSON firewallUARuleNewResponseEnvelopeJSON `json:"-"` -} - -// firewallUARuleNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [FirewallUARuleNewResponseEnvelope] -type firewallUARuleNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallUARuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallUARuleNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallUARuleNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallUARuleNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallUARuleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [FirewallUARuleNewResponseEnvelopeErrors] -type firewallUARuleNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallUARuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallUARuleNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallUARuleNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallUARuleNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallUARuleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [FirewallUARuleNewResponseEnvelopeMessages] -type firewallUARuleNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallUARuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallUARuleNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallUARuleNewResponseEnvelopeSuccess bool - -const ( - FirewallUARuleNewResponseEnvelopeSuccessTrue FirewallUARuleNewResponseEnvelopeSuccess = true -) - -type FirewallUARuleUpdateParams struct { - Body param.Field[interface{}] `json:"body,required"` -} - -func (r FirewallUARuleUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type FirewallUARuleUpdateResponseEnvelope struct { - Errors []FirewallUARuleUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallUARuleUpdateResponseEnvelopeMessages `json:"messages,required"` - Result FirewallUARuleUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallUARuleUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON firewallUARuleUpdateResponseEnvelopeJSON `json:"-"` -} - -// firewallUARuleUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [FirewallUARuleUpdateResponseEnvelope] -type firewallUARuleUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallUARuleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallUARuleUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallUARuleUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallUARuleUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallUARuleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [FirewallUARuleUpdateResponseEnvelopeErrors] -type firewallUARuleUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallUARuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallUARuleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallUARuleUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallUARuleUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallUARuleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [FirewallUARuleUpdateResponseEnvelopeMessages] -type firewallUARuleUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallUARuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallUARuleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallUARuleUpdateResponseEnvelopeSuccess bool - -const ( - FirewallUARuleUpdateResponseEnvelopeSuccessTrue FirewallUARuleUpdateResponseEnvelopeSuccess = true -) - -type FirewallUARuleListParams struct { - // A string to search for in the description of existing rules. - Description param.Field[string] `query:"description"` - // A string to search for in the description of existing rules. - DescriptionSearch param.Field[string] `query:"description_search"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // The maximum number of results per page. You can only set the value to `1` or to - // a multiple of 5 such as `5`, `10`, `15`, or `20`. - PerPage param.Field[float64] `query:"per_page"` - // A string to search for in the user agent values of existing rules. - UASearch param.Field[string] `query:"ua_search"` -} - -// URLQuery serializes [FirewallUARuleListParams]'s query parameters as -// `url.Values`. -func (r FirewallUARuleListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type FirewallUARuleDeleteResponseEnvelope struct { - Errors []FirewallUARuleDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallUARuleDeleteResponseEnvelopeMessages `json:"messages,required"` - Result FirewallUARuleDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallUARuleDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON firewallUARuleDeleteResponseEnvelopeJSON `json:"-"` -} - -// firewallUARuleDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [FirewallUARuleDeleteResponseEnvelope] -type firewallUARuleDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallUARuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallUARuleDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallUARuleDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallUARuleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallUARuleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [FirewallUARuleDeleteResponseEnvelopeErrors] -type firewallUARuleDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallUARuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallUARuleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallUARuleDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallUARuleDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallUARuleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [FirewallUARuleDeleteResponseEnvelopeMessages] -type firewallUARuleDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallUARuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallUARuleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallUARuleDeleteResponseEnvelopeSuccess bool - -const ( - FirewallUARuleDeleteResponseEnvelopeSuccessTrue FirewallUARuleDeleteResponseEnvelopeSuccess = true -) - -type FirewallUARuleGetResponseEnvelope struct { - Errors []FirewallUARuleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallUARuleGetResponseEnvelopeMessages `json:"messages,required"` - Result FirewallUARuleGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallUARuleGetResponseEnvelopeSuccess `json:"success,required"` - JSON firewallUARuleGetResponseEnvelopeJSON `json:"-"` -} - -// firewallUARuleGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [FirewallUARuleGetResponseEnvelope] -type firewallUARuleGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallUARuleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallUARuleGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallUARuleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallUARuleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallUARuleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [FirewallUARuleGetResponseEnvelopeErrors] -type firewallUARuleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallUARuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallUARuleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallUARuleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallUARuleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallUARuleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [FirewallUARuleGetResponseEnvelopeMessages] -type firewallUARuleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallUARuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallUARuleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallUARuleGetResponseEnvelopeSuccess bool - -const ( - FirewallUARuleGetResponseEnvelopeSuccessTrue FirewallUARuleGetResponseEnvelopeSuccess = true -) diff --git a/firewalluarule_test.go b/firewalluarule_test.go deleted file mode 100644 index 75a42c56f85..00000000000 --- a/firewalluarule_test.go +++ /dev/null @@ -1,165 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestFirewallUARuleNew(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("user@example.com"), - ) - _, err := client.Firewall.UARules.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.FirewallUARuleNewParams{ - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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 TestFirewallUARuleUpdate(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("user@example.com"), - ) - _, err := client.Firewall.UARules.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "372e67954025e0ba6aaa6d586b9e0b59", - cloudflare.FirewallUARuleUpdateParams{ - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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 TestFirewallUARuleListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Firewall.UARules.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.FirewallUARuleListParams{ - Description: cloudflare.F("abusive"), - DescriptionSearch: cloudflare.F("abusive"), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(1.000000), - UASearch: cloudflare.F("Safari"), - }, - ) - 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 TestFirewallUARuleDelete(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("user@example.com"), - ) - _, err := client.Firewall.UARules.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "372e67954025e0ba6aaa6d586b9e0b59", - ) - 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 TestFirewallUARuleGet(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("user@example.com"), - ) - _, err := client.Firewall.UARules.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "372e67954025e0ba6aaa6d586b9e0b59", - ) - 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/firewallwaf.go b/firewallwaf.go deleted file mode 100644 index f01b4f881e1..00000000000 --- a/firewallwaf.go +++ /dev/null @@ -1,29 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// FirewallWAFService 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 [NewFirewallWAFService] method -// instead. -type FirewallWAFService struct { - Options []option.RequestOption - Overrides *FirewallWAFOverrideService - Packages *FirewallWAFPackageService -} - -// NewFirewallWAFService 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 NewFirewallWAFService(opts ...option.RequestOption) (r *FirewallWAFService) { - r = &FirewallWAFService{} - r.Options = opts - r.Overrides = NewFirewallWAFOverrideService(opts...) - r.Packages = NewFirewallWAFPackageService(opts...) - return -} diff --git a/firewallwafoverride.go b/firewallwafoverride.go deleted file mode 100644 index d6a7ac00599..00000000000 --- a/firewallwafoverride.go +++ /dev/null @@ -1,934 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" -) - -// FirewallWAFOverrideService 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 [NewFirewallWAFOverrideService] -// method instead. -type FirewallWAFOverrideService struct { - Options []option.RequestOption -} - -// NewFirewallWAFOverrideService 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 NewFirewallWAFOverrideService(opts ...option.RequestOption) (r *FirewallWAFOverrideService) { - r = &FirewallWAFOverrideService{} - r.Options = opts - return -} - -// Creates a URI-based WAF override for a zone. -// -// **Note:** Applies only to the -// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *FirewallWAFOverrideService) New(ctx context.Context, zoneIdentifier string, body FirewallWAFOverrideNewParams, opts ...option.RequestOption) (res *FirewallWAFOverrideNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallWAFOverrideNewResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/waf/overrides", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates an existing URI-based WAF override. -// -// **Note:** Applies only to the -// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *FirewallWAFOverrideService) Update(ctx context.Context, zoneIdentifier string, id string, body FirewallWAFOverrideUpdateParams, opts ...option.RequestOption) (res *FirewallWAFOverrideUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallWAFOverrideUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/waf/overrides/%s", zoneIdentifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the URI-based WAF overrides in a zone. -// -// **Note:** Applies only to the -// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *FirewallWAFOverrideService) List(ctx context.Context, zoneIdentifier string, query FirewallWAFOverrideListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[FirewallWAFOverrideListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("zones/%s/firewall/waf/overrides", zoneIdentifier) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Fetches the URI-based WAF overrides in a zone. -// -// **Note:** Applies only to the -// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *FirewallWAFOverrideService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query FirewallWAFOverrideListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[FirewallWAFOverrideListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) -} - -// Deletes an existing URI-based WAF override. -// -// **Note:** Applies only to the -// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *FirewallWAFOverrideService) Delete(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *FirewallWAFOverrideDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallWAFOverrideDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/waf/overrides/%s", zoneIdentifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the details of a URI-based WAF override. -// -// **Note:** Applies only to the -// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *FirewallWAFOverrideService) Get(ctx context.Context, zoneIdentifier string, id string, opts ...option.RequestOption) (res *FirewallWAFOverrideGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallWAFOverrideGetResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/waf/overrides/%s", zoneIdentifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type FirewallWAFOverrideNewResponse struct { - // The unique identifier of the WAF override. - ID string `json:"id"` - // An informative summary of the current URI-based WAF override. - Description string `json:"description,nullable"` - // An object that allows you to enable or disable WAF rule groups for the current - // WAF override. Each key of this object must be the ID of a WAF rule group, and - // each value must be a valid WAF action (usually `default` or `disable`). When - // creating a new URI-based WAF override, you must provide a `groups` object or a - // `rules` object. - Groups map[string]interface{} `json:"groups"` - // When true, indicates that the WAF package is currently paused. - Paused bool `json:"paused"` - // The relative priority of the current URI-based WAF override when multiple - // overrides match a single URL. A lower number indicates higher priority. Higher - // priority overrides may overwrite values set by lower priority overrides. - Priority float64 `json:"priority"` - // Specifies that, when a WAF rule matches, its configured action will be replaced - // by the action configured in this object. - RewriteAction FirewallWAFOverrideNewResponseRewriteAction `json:"rewrite_action"` - // An object that allows you to override the action of specific WAF rules. Each key - // of this object must be the ID of a WAF rule, and each value must be a valid WAF - // action. Unless you are disabling a rule, ensure that you also enable the rule - // group that this WAF rule belongs to. When creating a new URI-based WAF override, - // you must provide a `groups` object or a `rules` object. - Rules map[string]FirewallWAFOverrideNewResponseRule `json:"rules"` - // The URLs to include in the current WAF override. You can use wildcards. Each - // entered URL will be escaped before use, which means you can only use simple - // wildcard patterns. - URLs []string `json:"urls"` - JSON firewallWAFOverrideNewResponseJSON `json:"-"` -} - -// firewallWAFOverrideNewResponseJSON contains the JSON metadata for the struct -// [FirewallWAFOverrideNewResponse] -type firewallWAFOverrideNewResponseJSON struct { - ID apijson.Field - Description apijson.Field - Groups apijson.Field - Paused apijson.Field - Priority apijson.Field - RewriteAction apijson.Field - Rules apijson.Field - URLs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideNewResponseJSON) RawJSON() string { - return r.raw -} - -// Specifies that, when a WAF rule matches, its configured action will be replaced -// by the action configured in this object. -type FirewallWAFOverrideNewResponseRewriteAction struct { - // The WAF rule action to apply. - Block FirewallWAFOverrideNewResponseRewriteActionBlock `json:"block"` - Challenge interface{} `json:"challenge"` - Default interface{} `json:"default"` - // The WAF rule action to apply. - Disable FirewallWAFOverrideNewResponseRewriteActionDisable `json:"disable"` - Simulate interface{} `json:"simulate"` - JSON firewallWAFOverrideNewResponseRewriteActionJSON `json:"-"` -} - -// firewallWAFOverrideNewResponseRewriteActionJSON contains the JSON metadata for -// the struct [FirewallWAFOverrideNewResponseRewriteAction] -type firewallWAFOverrideNewResponseRewriteActionJSON struct { - Block apijson.Field - Challenge apijson.Field - Default apijson.Field - Disable apijson.Field - Simulate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideNewResponseRewriteAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideNewResponseRewriteActionJSON) RawJSON() string { - return r.raw -} - -// The WAF rule action to apply. -type FirewallWAFOverrideNewResponseRewriteActionBlock string - -const ( - FirewallWAFOverrideNewResponseRewriteActionBlockChallenge FirewallWAFOverrideNewResponseRewriteActionBlock = "challenge" - FirewallWAFOverrideNewResponseRewriteActionBlockBlock FirewallWAFOverrideNewResponseRewriteActionBlock = "block" - FirewallWAFOverrideNewResponseRewriteActionBlockSimulate FirewallWAFOverrideNewResponseRewriteActionBlock = "simulate" - FirewallWAFOverrideNewResponseRewriteActionBlockDisable FirewallWAFOverrideNewResponseRewriteActionBlock = "disable" - FirewallWAFOverrideNewResponseRewriteActionBlockDefault FirewallWAFOverrideNewResponseRewriteActionBlock = "default" -) - -// The WAF rule action to apply. -type FirewallWAFOverrideNewResponseRewriteActionDisable string - -const ( - FirewallWAFOverrideNewResponseRewriteActionDisableChallenge FirewallWAFOverrideNewResponseRewriteActionDisable = "challenge" - FirewallWAFOverrideNewResponseRewriteActionDisableBlock FirewallWAFOverrideNewResponseRewriteActionDisable = "block" - FirewallWAFOverrideNewResponseRewriteActionDisableSimulate FirewallWAFOverrideNewResponseRewriteActionDisable = "simulate" - FirewallWAFOverrideNewResponseRewriteActionDisableDisable FirewallWAFOverrideNewResponseRewriteActionDisable = "disable" - FirewallWAFOverrideNewResponseRewriteActionDisableDefault FirewallWAFOverrideNewResponseRewriteActionDisable = "default" -) - -// The WAF rule action to apply. -type FirewallWAFOverrideNewResponseRule string - -const ( - FirewallWAFOverrideNewResponseRuleChallenge FirewallWAFOverrideNewResponseRule = "challenge" - FirewallWAFOverrideNewResponseRuleBlock FirewallWAFOverrideNewResponseRule = "block" - FirewallWAFOverrideNewResponseRuleSimulate FirewallWAFOverrideNewResponseRule = "simulate" - FirewallWAFOverrideNewResponseRuleDisable FirewallWAFOverrideNewResponseRule = "disable" - FirewallWAFOverrideNewResponseRuleDefault FirewallWAFOverrideNewResponseRule = "default" -) - -type FirewallWAFOverrideUpdateResponse struct { - // The unique identifier of the WAF override. - ID string `json:"id"` - // An informative summary of the current URI-based WAF override. - Description string `json:"description,nullable"` - // An object that allows you to enable or disable WAF rule groups for the current - // WAF override. Each key of this object must be the ID of a WAF rule group, and - // each value must be a valid WAF action (usually `default` or `disable`). When - // creating a new URI-based WAF override, you must provide a `groups` object or a - // `rules` object. - Groups map[string]interface{} `json:"groups"` - // When true, indicates that the WAF package is currently paused. - Paused bool `json:"paused"` - // The relative priority of the current URI-based WAF override when multiple - // overrides match a single URL. A lower number indicates higher priority. Higher - // priority overrides may overwrite values set by lower priority overrides. - Priority float64 `json:"priority"` - // Specifies that, when a WAF rule matches, its configured action will be replaced - // by the action configured in this object. - RewriteAction FirewallWAFOverrideUpdateResponseRewriteAction `json:"rewrite_action"` - // An object that allows you to override the action of specific WAF rules. Each key - // of this object must be the ID of a WAF rule, and each value must be a valid WAF - // action. Unless you are disabling a rule, ensure that you also enable the rule - // group that this WAF rule belongs to. When creating a new URI-based WAF override, - // you must provide a `groups` object or a `rules` object. - Rules map[string]FirewallWAFOverrideUpdateResponseRule `json:"rules"` - // The URLs to include in the current WAF override. You can use wildcards. Each - // entered URL will be escaped before use, which means you can only use simple - // wildcard patterns. - URLs []string `json:"urls"` - JSON firewallWAFOverrideUpdateResponseJSON `json:"-"` -} - -// firewallWAFOverrideUpdateResponseJSON contains the JSON metadata for the struct -// [FirewallWAFOverrideUpdateResponse] -type firewallWAFOverrideUpdateResponseJSON struct { - ID apijson.Field - Description apijson.Field - Groups apijson.Field - Paused apijson.Field - Priority apijson.Field - RewriteAction apijson.Field - Rules apijson.Field - URLs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// Specifies that, when a WAF rule matches, its configured action will be replaced -// by the action configured in this object. -type FirewallWAFOverrideUpdateResponseRewriteAction struct { - // The WAF rule action to apply. - Block FirewallWAFOverrideUpdateResponseRewriteActionBlock `json:"block"` - Challenge interface{} `json:"challenge"` - Default interface{} `json:"default"` - // The WAF rule action to apply. - Disable FirewallWAFOverrideUpdateResponseRewriteActionDisable `json:"disable"` - Simulate interface{} `json:"simulate"` - JSON firewallWAFOverrideUpdateResponseRewriteActionJSON `json:"-"` -} - -// firewallWAFOverrideUpdateResponseRewriteActionJSON contains the JSON metadata -// for the struct [FirewallWAFOverrideUpdateResponseRewriteAction] -type firewallWAFOverrideUpdateResponseRewriteActionJSON struct { - Block apijson.Field - Challenge apijson.Field - Default apijson.Field - Disable apijson.Field - Simulate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideUpdateResponseRewriteAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideUpdateResponseRewriteActionJSON) RawJSON() string { - return r.raw -} - -// The WAF rule action to apply. -type FirewallWAFOverrideUpdateResponseRewriteActionBlock string - -const ( - FirewallWAFOverrideUpdateResponseRewriteActionBlockChallenge FirewallWAFOverrideUpdateResponseRewriteActionBlock = "challenge" - FirewallWAFOverrideUpdateResponseRewriteActionBlockBlock FirewallWAFOverrideUpdateResponseRewriteActionBlock = "block" - FirewallWAFOverrideUpdateResponseRewriteActionBlockSimulate FirewallWAFOverrideUpdateResponseRewriteActionBlock = "simulate" - FirewallWAFOverrideUpdateResponseRewriteActionBlockDisable FirewallWAFOverrideUpdateResponseRewriteActionBlock = "disable" - FirewallWAFOverrideUpdateResponseRewriteActionBlockDefault FirewallWAFOverrideUpdateResponseRewriteActionBlock = "default" -) - -// The WAF rule action to apply. -type FirewallWAFOverrideUpdateResponseRewriteActionDisable string - -const ( - FirewallWAFOverrideUpdateResponseRewriteActionDisableChallenge FirewallWAFOverrideUpdateResponseRewriteActionDisable = "challenge" - FirewallWAFOverrideUpdateResponseRewriteActionDisableBlock FirewallWAFOverrideUpdateResponseRewriteActionDisable = "block" - FirewallWAFOverrideUpdateResponseRewriteActionDisableSimulate FirewallWAFOverrideUpdateResponseRewriteActionDisable = "simulate" - FirewallWAFOverrideUpdateResponseRewriteActionDisableDisable FirewallWAFOverrideUpdateResponseRewriteActionDisable = "disable" - FirewallWAFOverrideUpdateResponseRewriteActionDisableDefault FirewallWAFOverrideUpdateResponseRewriteActionDisable = "default" -) - -// The WAF rule action to apply. -type FirewallWAFOverrideUpdateResponseRule string - -const ( - FirewallWAFOverrideUpdateResponseRuleChallenge FirewallWAFOverrideUpdateResponseRule = "challenge" - FirewallWAFOverrideUpdateResponseRuleBlock FirewallWAFOverrideUpdateResponseRule = "block" - FirewallWAFOverrideUpdateResponseRuleSimulate FirewallWAFOverrideUpdateResponseRule = "simulate" - FirewallWAFOverrideUpdateResponseRuleDisable FirewallWAFOverrideUpdateResponseRule = "disable" - FirewallWAFOverrideUpdateResponseRuleDefault FirewallWAFOverrideUpdateResponseRule = "default" -) - -type FirewallWAFOverrideListResponse struct { - // The unique identifier of the WAF override. - ID string `json:"id,required"` - // When true, indicates that the WAF package is currently paused. - Paused bool `json:"paused,required"` - // The relative priority of the current URI-based WAF override when multiple - // overrides match a single URL. A lower number indicates higher priority. Higher - // priority overrides may overwrite values set by lower priority overrides. - Priority float64 `json:"priority,required"` - // The URLs to include in the current WAF override. You can use wildcards. Each - // entered URL will be escaped before use, which means you can only use simple - // wildcard patterns. - URLs []string `json:"urls,required"` - // An informative summary of the current URI-based WAF override. - Description string `json:"description,nullable"` - // An object that allows you to enable or disable WAF rule groups for the current - // WAF override. Each key of this object must be the ID of a WAF rule group, and - // each value must be a valid WAF action (usually `default` or `disable`). When - // creating a new URI-based WAF override, you must provide a `groups` object or a - // `rules` object. - Groups map[string]interface{} `json:"groups"` - // Specifies that, when a WAF rule matches, its configured action will be replaced - // by the action configured in this object. - RewriteAction FirewallWAFOverrideListResponseRewriteAction `json:"rewrite_action"` - // An object that allows you to override the action of specific WAF rules. Each key - // of this object must be the ID of a WAF rule, and each value must be a valid WAF - // action. Unless you are disabling a rule, ensure that you also enable the rule - // group that this WAF rule belongs to. When creating a new URI-based WAF override, - // you must provide a `groups` object or a `rules` object. - Rules map[string]FirewallWAFOverrideListResponseRule `json:"rules"` - JSON firewallWAFOverrideListResponseJSON `json:"-"` -} - -// firewallWAFOverrideListResponseJSON contains the JSON metadata for the struct -// [FirewallWAFOverrideListResponse] -type firewallWAFOverrideListResponseJSON struct { - ID apijson.Field - Paused apijson.Field - Priority apijson.Field - URLs apijson.Field - Description apijson.Field - Groups apijson.Field - RewriteAction apijson.Field - Rules apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideListResponseJSON) RawJSON() string { - return r.raw -} - -// Specifies that, when a WAF rule matches, its configured action will be replaced -// by the action configured in this object. -type FirewallWAFOverrideListResponseRewriteAction struct { - // The WAF rule action to apply. - Block FirewallWAFOverrideListResponseRewriteActionBlock `json:"block"` - Challenge interface{} `json:"challenge"` - Default interface{} `json:"default"` - // The WAF rule action to apply. - Disable FirewallWAFOverrideListResponseRewriteActionDisable `json:"disable"` - Simulate interface{} `json:"simulate"` - JSON firewallWAFOverrideListResponseRewriteActionJSON `json:"-"` -} - -// firewallWAFOverrideListResponseRewriteActionJSON contains the JSON metadata for -// the struct [FirewallWAFOverrideListResponseRewriteAction] -type firewallWAFOverrideListResponseRewriteActionJSON struct { - Block apijson.Field - Challenge apijson.Field - Default apijson.Field - Disable apijson.Field - Simulate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideListResponseRewriteAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideListResponseRewriteActionJSON) RawJSON() string { - return r.raw -} - -// The WAF rule action to apply. -type FirewallWAFOverrideListResponseRewriteActionBlock string - -const ( - FirewallWAFOverrideListResponseRewriteActionBlockChallenge FirewallWAFOverrideListResponseRewriteActionBlock = "challenge" - FirewallWAFOverrideListResponseRewriteActionBlockBlock FirewallWAFOverrideListResponseRewriteActionBlock = "block" - FirewallWAFOverrideListResponseRewriteActionBlockSimulate FirewallWAFOverrideListResponseRewriteActionBlock = "simulate" - FirewallWAFOverrideListResponseRewriteActionBlockDisable FirewallWAFOverrideListResponseRewriteActionBlock = "disable" - FirewallWAFOverrideListResponseRewriteActionBlockDefault FirewallWAFOverrideListResponseRewriteActionBlock = "default" -) - -// The WAF rule action to apply. -type FirewallWAFOverrideListResponseRewriteActionDisable string - -const ( - FirewallWAFOverrideListResponseRewriteActionDisableChallenge FirewallWAFOverrideListResponseRewriteActionDisable = "challenge" - FirewallWAFOverrideListResponseRewriteActionDisableBlock FirewallWAFOverrideListResponseRewriteActionDisable = "block" - FirewallWAFOverrideListResponseRewriteActionDisableSimulate FirewallWAFOverrideListResponseRewriteActionDisable = "simulate" - FirewallWAFOverrideListResponseRewriteActionDisableDisable FirewallWAFOverrideListResponseRewriteActionDisable = "disable" - FirewallWAFOverrideListResponseRewriteActionDisableDefault FirewallWAFOverrideListResponseRewriteActionDisable = "default" -) - -// The WAF rule action to apply. -type FirewallWAFOverrideListResponseRule string - -const ( - FirewallWAFOverrideListResponseRuleChallenge FirewallWAFOverrideListResponseRule = "challenge" - FirewallWAFOverrideListResponseRuleBlock FirewallWAFOverrideListResponseRule = "block" - FirewallWAFOverrideListResponseRuleSimulate FirewallWAFOverrideListResponseRule = "simulate" - FirewallWAFOverrideListResponseRuleDisable FirewallWAFOverrideListResponseRule = "disable" - FirewallWAFOverrideListResponseRuleDefault FirewallWAFOverrideListResponseRule = "default" -) - -type FirewallWAFOverrideDeleteResponse struct { - // The unique identifier of the WAF override. - ID string `json:"id"` - JSON firewallWAFOverrideDeleteResponseJSON `json:"-"` -} - -// firewallWAFOverrideDeleteResponseJSON contains the JSON metadata for the struct -// [FirewallWAFOverrideDeleteResponse] -type firewallWAFOverrideDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFOverrideGetResponse struct { - // The unique identifier of the WAF override. - ID string `json:"id"` - // An informative summary of the current URI-based WAF override. - Description string `json:"description,nullable"` - // An object that allows you to enable or disable WAF rule groups for the current - // WAF override. Each key of this object must be the ID of a WAF rule group, and - // each value must be a valid WAF action (usually `default` or `disable`). When - // creating a new URI-based WAF override, you must provide a `groups` object or a - // `rules` object. - Groups map[string]interface{} `json:"groups"` - // When true, indicates that the WAF package is currently paused. - Paused bool `json:"paused"` - // The relative priority of the current URI-based WAF override when multiple - // overrides match a single URL. A lower number indicates higher priority. Higher - // priority overrides may overwrite values set by lower priority overrides. - Priority float64 `json:"priority"` - // Specifies that, when a WAF rule matches, its configured action will be replaced - // by the action configured in this object. - RewriteAction FirewallWAFOverrideGetResponseRewriteAction `json:"rewrite_action"` - // An object that allows you to override the action of specific WAF rules. Each key - // of this object must be the ID of a WAF rule, and each value must be a valid WAF - // action. Unless you are disabling a rule, ensure that you also enable the rule - // group that this WAF rule belongs to. When creating a new URI-based WAF override, - // you must provide a `groups` object or a `rules` object. - Rules map[string]FirewallWAFOverrideGetResponseRule `json:"rules"` - // The URLs to include in the current WAF override. You can use wildcards. Each - // entered URL will be escaped before use, which means you can only use simple - // wildcard patterns. - URLs []string `json:"urls"` - JSON firewallWAFOverrideGetResponseJSON `json:"-"` -} - -// firewallWAFOverrideGetResponseJSON contains the JSON metadata for the struct -// [FirewallWAFOverrideGetResponse] -type firewallWAFOverrideGetResponseJSON struct { - ID apijson.Field - Description apijson.Field - Groups apijson.Field - Paused apijson.Field - Priority apijson.Field - RewriteAction apijson.Field - Rules apijson.Field - URLs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideGetResponseJSON) RawJSON() string { - return r.raw -} - -// Specifies that, when a WAF rule matches, its configured action will be replaced -// by the action configured in this object. -type FirewallWAFOverrideGetResponseRewriteAction struct { - // The WAF rule action to apply. - Block FirewallWAFOverrideGetResponseRewriteActionBlock `json:"block"` - Challenge interface{} `json:"challenge"` - Default interface{} `json:"default"` - // The WAF rule action to apply. - Disable FirewallWAFOverrideGetResponseRewriteActionDisable `json:"disable"` - Simulate interface{} `json:"simulate"` - JSON firewallWAFOverrideGetResponseRewriteActionJSON `json:"-"` -} - -// firewallWAFOverrideGetResponseRewriteActionJSON contains the JSON metadata for -// the struct [FirewallWAFOverrideGetResponseRewriteAction] -type firewallWAFOverrideGetResponseRewriteActionJSON struct { - Block apijson.Field - Challenge apijson.Field - Default apijson.Field - Disable apijson.Field - Simulate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideGetResponseRewriteAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideGetResponseRewriteActionJSON) RawJSON() string { - return r.raw -} - -// The WAF rule action to apply. -type FirewallWAFOverrideGetResponseRewriteActionBlock string - -const ( - FirewallWAFOverrideGetResponseRewriteActionBlockChallenge FirewallWAFOverrideGetResponseRewriteActionBlock = "challenge" - FirewallWAFOverrideGetResponseRewriteActionBlockBlock FirewallWAFOverrideGetResponseRewriteActionBlock = "block" - FirewallWAFOverrideGetResponseRewriteActionBlockSimulate FirewallWAFOverrideGetResponseRewriteActionBlock = "simulate" - FirewallWAFOverrideGetResponseRewriteActionBlockDisable FirewallWAFOverrideGetResponseRewriteActionBlock = "disable" - FirewallWAFOverrideGetResponseRewriteActionBlockDefault FirewallWAFOverrideGetResponseRewriteActionBlock = "default" -) - -// The WAF rule action to apply. -type FirewallWAFOverrideGetResponseRewriteActionDisable string - -const ( - FirewallWAFOverrideGetResponseRewriteActionDisableChallenge FirewallWAFOverrideGetResponseRewriteActionDisable = "challenge" - FirewallWAFOverrideGetResponseRewriteActionDisableBlock FirewallWAFOverrideGetResponseRewriteActionDisable = "block" - FirewallWAFOverrideGetResponseRewriteActionDisableSimulate FirewallWAFOverrideGetResponseRewriteActionDisable = "simulate" - FirewallWAFOverrideGetResponseRewriteActionDisableDisable FirewallWAFOverrideGetResponseRewriteActionDisable = "disable" - FirewallWAFOverrideGetResponseRewriteActionDisableDefault FirewallWAFOverrideGetResponseRewriteActionDisable = "default" -) - -// The WAF rule action to apply. -type FirewallWAFOverrideGetResponseRule string - -const ( - FirewallWAFOverrideGetResponseRuleChallenge FirewallWAFOverrideGetResponseRule = "challenge" - FirewallWAFOverrideGetResponseRuleBlock FirewallWAFOverrideGetResponseRule = "block" - FirewallWAFOverrideGetResponseRuleSimulate FirewallWAFOverrideGetResponseRule = "simulate" - FirewallWAFOverrideGetResponseRuleDisable FirewallWAFOverrideGetResponseRule = "disable" - FirewallWAFOverrideGetResponseRuleDefault FirewallWAFOverrideGetResponseRule = "default" -) - -type FirewallWAFOverrideNewParams struct { - Body param.Field[interface{}] `json:"body,required"` -} - -func (r FirewallWAFOverrideNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type FirewallWAFOverrideNewResponseEnvelope struct { - Errors []FirewallWAFOverrideNewResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallWAFOverrideNewResponseEnvelopeMessages `json:"messages,required"` - Result FirewallWAFOverrideNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallWAFOverrideNewResponseEnvelopeSuccess `json:"success,required"` - JSON firewallWAFOverrideNewResponseEnvelopeJSON `json:"-"` -} - -// firewallWAFOverrideNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [FirewallWAFOverrideNewResponseEnvelope] -type firewallWAFOverrideNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFOverrideNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallWAFOverrideNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallWAFOverrideNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [FirewallWAFOverrideNewResponseEnvelopeErrors] -type firewallWAFOverrideNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFOverrideNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallWAFOverrideNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallWAFOverrideNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [FirewallWAFOverrideNewResponseEnvelopeMessages] -type firewallWAFOverrideNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallWAFOverrideNewResponseEnvelopeSuccess bool - -const ( - FirewallWAFOverrideNewResponseEnvelopeSuccessTrue FirewallWAFOverrideNewResponseEnvelopeSuccess = true -) - -type FirewallWAFOverrideUpdateParams struct { - Body param.Field[interface{}] `json:"body,required"` -} - -func (r FirewallWAFOverrideUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type FirewallWAFOverrideUpdateResponseEnvelope struct { - Errors []FirewallWAFOverrideUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallWAFOverrideUpdateResponseEnvelopeMessages `json:"messages,required"` - Result FirewallWAFOverrideUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallWAFOverrideUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON firewallWAFOverrideUpdateResponseEnvelopeJSON `json:"-"` -} - -// firewallWAFOverrideUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [FirewallWAFOverrideUpdateResponseEnvelope] -type firewallWAFOverrideUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFOverrideUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallWAFOverrideUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallWAFOverrideUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [FirewallWAFOverrideUpdateResponseEnvelopeErrors] -type firewallWAFOverrideUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFOverrideUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallWAFOverrideUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallWAFOverrideUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [FirewallWAFOverrideUpdateResponseEnvelopeMessages] -type firewallWAFOverrideUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallWAFOverrideUpdateResponseEnvelopeSuccess bool - -const ( - FirewallWAFOverrideUpdateResponseEnvelopeSuccessTrue FirewallWAFOverrideUpdateResponseEnvelopeSuccess = true -) - -type FirewallWAFOverrideListParams struct { - // The page number of paginated results. - Page param.Field[float64] `query:"page"` - // The number of WAF overrides per page. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [FirewallWAFOverrideListParams]'s query parameters as -// `url.Values`. -func (r FirewallWAFOverrideListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type FirewallWAFOverrideDeleteResponseEnvelope struct { - Result FirewallWAFOverrideDeleteResponse `json:"result"` - JSON firewallWAFOverrideDeleteResponseEnvelopeJSON `json:"-"` -} - -// firewallWAFOverrideDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [FirewallWAFOverrideDeleteResponseEnvelope] -type firewallWAFOverrideDeleteResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFOverrideGetResponseEnvelope struct { - Errors []FirewallWAFOverrideGetResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallWAFOverrideGetResponseEnvelopeMessages `json:"messages,required"` - Result FirewallWAFOverrideGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallWAFOverrideGetResponseEnvelopeSuccess `json:"success,required"` - JSON firewallWAFOverrideGetResponseEnvelopeJSON `json:"-"` -} - -// firewallWAFOverrideGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [FirewallWAFOverrideGetResponseEnvelope] -type firewallWAFOverrideGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFOverrideGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallWAFOverrideGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallWAFOverrideGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [FirewallWAFOverrideGetResponseEnvelopeErrors] -type firewallWAFOverrideGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFOverrideGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallWAFOverrideGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallWAFOverrideGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [FirewallWAFOverrideGetResponseEnvelopeMessages] -type firewallWAFOverrideGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFOverrideGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFOverrideGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallWAFOverrideGetResponseEnvelopeSuccess bool - -const ( - FirewallWAFOverrideGetResponseEnvelopeSuccessTrue FirewallWAFOverrideGetResponseEnvelopeSuccess = true -) diff --git a/firewallwafoverride_test.go b/firewallwafoverride_test.go deleted file mode 100644 index 7cb808c63e6..00000000000 --- a/firewallwafoverride_test.go +++ /dev/null @@ -1,162 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestFirewallWAFOverrideNew(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("user@example.com"), - ) - _, err := client.Firewall.WAF.Overrides.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.FirewallWAFOverrideNewParams{ - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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 TestFirewallWAFOverrideUpdate(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("user@example.com"), - ) - _, err := client.Firewall.WAF.Overrides.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "de677e5818985db1285d0e80225f06e5", - cloudflare.FirewallWAFOverrideUpdateParams{ - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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 TestFirewallWAFOverrideListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Firewall.WAF.Overrides.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.FirewallWAFOverrideListParams{ - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(5.000000), - }, - ) - 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 TestFirewallWAFOverrideDelete(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("user@example.com"), - ) - _, err := client.Firewall.WAF.Overrides.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "de677e5818985db1285d0e80225f06e5", - ) - 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 TestFirewallWAFOverrideGet(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("user@example.com"), - ) - _, err := client.Firewall.WAF.Overrides.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "de677e5818985db1285d0e80225f06e5", - ) - 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/firewallwafpackage.go b/firewallwafpackage.go deleted file mode 100644 index 07ee56d166a..00000000000 --- a/firewallwafpackage.go +++ /dev/null @@ -1,654 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// FirewallWAFPackageService 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 [NewFirewallWAFPackageService] method -// instead. -type FirewallWAFPackageService struct { - Options []option.RequestOption - Groups *FirewallWAFPackageGroupService - Rules *FirewallWAFPackageRuleService -} - -// NewFirewallWAFPackageService 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 NewFirewallWAFPackageService(opts ...option.RequestOption) (r *FirewallWAFPackageService) { - r = &FirewallWAFPackageService{} - r.Options = opts - r.Groups = NewFirewallWAFPackageGroupService(opts...) - r.Rules = NewFirewallWAFPackageRuleService(opts...) - return -} - -// Fetches WAF packages for a zone. -// -// **Note:** Applies only to the -// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *FirewallWAFPackageService) List(ctx context.Context, zoneIdentifier string, query FirewallWAFPackageListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[FirewallWAFPackageListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("zones/%s/firewall/waf/packages", zoneIdentifier) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Fetches WAF packages for a zone. -// -// **Note:** Applies only to the -// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *FirewallWAFPackageService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query FirewallWAFPackageListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[FirewallWAFPackageListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) -} - -// Fetches the details of a WAF package. -// -// **Note:** Applies only to the -// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *FirewallWAFPackageService) Get(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *FirewallWAFPackageGetResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("zones/%s/firewall/waf/packages/%s", zoneIdentifier, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) - return -} - -// Union satisfied by -// [FirewallWAFPackageListResponseLegacyJhsAPIResponseCollection] or -// [FirewallWAFPackageListResponseObject]. -type FirewallWAFPackageListResponse interface { - implementsFirewallWAFPackageListResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallWAFPackageListResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallWAFPackageListResponseLegacyJhsAPIResponseCollection{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallWAFPackageListResponseObject{}), - }, - ) -} - -type FirewallWAFPackageListResponseLegacyJhsAPIResponseCollection struct { - Errors []FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionError `json:"errors,required"` - Messages []FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionMessage `json:"messages,required"` - Result FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResult `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionSuccess `json:"success,required"` - ResultInfo FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResultInfo `json:"result_info"` - JSON firewallWAFPackageListResponseLegacyJhsAPIResponseCollectionJSON `json:"-"` -} - -// firewallWAFPackageListResponseLegacyJhsAPIResponseCollectionJSON contains the -// JSON metadata for the struct -// [FirewallWAFPackageListResponseLegacyJhsAPIResponseCollection] -type firewallWAFPackageListResponseLegacyJhsAPIResponseCollectionJSON 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 *FirewallWAFPackageListResponseLegacyJhsAPIResponseCollection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageListResponseLegacyJhsAPIResponseCollectionJSON) RawJSON() string { - return r.raw -} - -func (r FirewallWAFPackageListResponseLegacyJhsAPIResponseCollection) implementsFirewallWAFPackageListResponse() { -} - -type FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionError struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallWAFPackageListResponseLegacyJhsAPIResponseCollectionErrorJSON `json:"-"` -} - -// firewallWAFPackageListResponseLegacyJhsAPIResponseCollectionErrorJSON contains -// the JSON metadata for the struct -// [FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionError] -type firewallWAFPackageListResponseLegacyJhsAPIResponseCollectionErrorJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageListResponseLegacyJhsAPIResponseCollectionErrorJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionMessage struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallWAFPackageListResponseLegacyJhsAPIResponseCollectionMessageJSON `json:"-"` -} - -// firewallWAFPackageListResponseLegacyJhsAPIResponseCollectionMessageJSON contains -// the JSON metadata for the struct -// [FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionMessage] -type firewallWAFPackageListResponseLegacyJhsAPIResponseCollectionMessageJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionMessage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageListResponseLegacyJhsAPIResponseCollectionMessageJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by -// [FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResultUnknown], -// [FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResultArray] or -// [shared.UnionString]. -type FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResult interface { - ImplementsFirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResult() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResult)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResultArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResultArray []interface{} - -func (r FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResultArray) ImplementsFirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResult() { -} - -// Whether the API call was successful -type FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionSuccess bool - -const ( - FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionSuccessTrue FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionSuccess = true -) - -type FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON firewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResultInfoJSON `json:"-"` -} - -// firewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResultInfoJSON -// contains the JSON metadata for the struct -// [FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResultInfo] -type firewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResultInfoJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFPackageListResponseObject struct { - Result []FirewallWAFPackageListResponseObjectResult `json:"result"` - JSON firewallWAFPackageListResponseObjectJSON `json:"-"` -} - -// firewallWAFPackageListResponseObjectJSON contains the JSON metadata for the -// struct [FirewallWAFPackageListResponseObject] -type firewallWAFPackageListResponseObjectJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageListResponseObject) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageListResponseObjectJSON) RawJSON() string { - return r.raw -} - -func (r FirewallWAFPackageListResponseObject) implementsFirewallWAFPackageListResponse() {} - -// Union satisfied by -// [FirewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinition] or -// [FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackage]. -type FirewallWAFPackageListResponseObjectResult interface { - implementsFirewallWAFPackageListResponseObjectResult() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallWAFPackageListResponseObjectResult)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinition{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackage{}), - }, - ) -} - -type FirewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinition struct { - // The unique identifier of a WAF package. - ID string `json:"id,required"` - // A summary of the purpose/function of the WAF package. - Description string `json:"description,required"` - // The mode that defines how rules within the package are evaluated during the - // course of a request. When a package uses anomaly detection mode (`anomaly` - // value), each rule is given a score when triggered. If the total score of all - // triggered rules exceeds the sensitivity defined in the WAF package, the action - // configured in the package will be performed. Traditional detection mode - // (`traditional` value) will decide the action to take when it is triggered by the - // request. If multiple rules are triggered, the action providing the highest - // protection will be applied (for example, a 'block' action will win over a - // 'challenge' action). - DetectionMode FirewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionMode `json:"detection_mode,required"` - // The name of the WAF package. - Name string `json:"name,required"` - // Identifier - ZoneID string `json:"zone_id,required"` - // When set to `active`, indicates that the WAF package will be applied to the - // zone. - Status FirewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinitionStatus `json:"status"` - JSON firewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinitionJSON `json:"-"` -} - -// firewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinitionJSON -// contains the JSON metadata for the struct -// [FirewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinition] -type firewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinitionJSON struct { - ID apijson.Field - Description apijson.Field - DetectionMode apijson.Field - Name apijson.Field - ZoneID apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinition) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinitionJSON) RawJSON() string { - return r.raw -} - -func (r FirewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinition) implementsFirewallWAFPackageListResponseObjectResult() { -} - -// The mode that defines how rules within the package are evaluated during the -// course of a request. When a package uses anomaly detection mode (`anomaly` -// value), each rule is given a score when triggered. If the total score of all -// triggered rules exceeds the sensitivity defined in the WAF package, the action -// configured in the package will be performed. Traditional detection mode -// (`traditional` value) will decide the action to take when it is triggered by the -// request. If multiple rules are triggered, the action providing the highest -// protection will be applied (for example, a 'block' action will win over a -// 'challenge' action). -type FirewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionMode string - -const ( - FirewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionModeAnomaly FirewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionMode = "anomaly" - FirewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionModeTraditional FirewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinitionDetectionMode = "traditional" -) - -// When set to `active`, indicates that the WAF package will be applied to the -// zone. -type FirewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinitionStatus string - -const ( - FirewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinitionStatusActive FirewallWAFPackageListResponseObjectResultLegacyJhsPackageDefinitionStatus = "active" -) - -type FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackage struct { - // The unique identifier of a WAF package. - ID string `json:"id,required"` - // A summary of the purpose/function of the WAF package. - Description string `json:"description,required"` - // When a WAF package uses anomaly detection, each rule is given a score when - // triggered. If the total score of all triggered rules exceeds the sensitivity - // defined on the WAF package, the action defined on the package will be taken. - DetectionMode FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionMode `json:"detection_mode,required"` - // The name of the WAF package. - Name string `json:"name,required"` - // Identifier - ZoneID string `json:"zone_id,required"` - // The default action performed by the rules in the WAF package. - ActionMode FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionMode `json:"action_mode"` - // The sensitivity of the WAF package. - Sensitivity FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity `json:"sensitivity"` - // When set to `active`, indicates that the WAF package will be applied to the - // zone. - Status FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageStatus `json:"status"` - JSON firewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageJSON `json:"-"` -} - -// firewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageJSON contains -// the JSON metadata for the struct -// [FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackage] -type firewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageJSON struct { - ID apijson.Field - Description apijson.Field - DetectionMode apijson.Field - Name apijson.Field - ZoneID apijson.Field - ActionMode apijson.Field - Sensitivity apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageJSON) RawJSON() string { - return r.raw -} - -func (r FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackage) implementsFirewallWAFPackageListResponseObjectResult() { -} - -// When a WAF package uses anomaly detection, each rule is given a score when -// triggered. If the total score of all triggered rules exceeds the sensitivity -// defined on the WAF package, the action defined on the package will be taken. -type FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionMode string - -const ( - FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionModeAnomaly FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionMode = "anomaly" - FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionModeTraditional FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageDetectionMode = "traditional" -) - -// The default action performed by the rules in the WAF package. -type FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionMode string - -const ( - FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionModeSimulate FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionMode = "simulate" - FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionModeBlock FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionMode = "block" - FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionModeChallenge FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageActionMode = "challenge" -) - -// The sensitivity of the WAF package. -type FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity string - -const ( - FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivityHigh FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity = "high" - FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivityMedium FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity = "medium" - FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivityLow FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity = "low" - FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivityOff FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageSensitivity = "off" -) - -// When set to `active`, indicates that the WAF package will be applied to the -// zone. -type FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageStatus string - -const ( - FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageStatusActive FirewallWAFPackageListResponseObjectResultLegacyJhsAnomalyPackageStatus = "active" -) - -// Union satisfied by [FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingle] or -// [FirewallWAFPackageGetResponseObject]. -type FirewallWAFPackageGetResponse interface { - implementsFirewallWAFPackageGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallWAFPackageGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingle{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallWAFPackageGetResponseObject{}), - }, - ) -} - -type FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingle struct { - Errors []FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleError `json:"errors,required"` - Messages []FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleMessage `json:"messages,required"` - Result FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleResult `json:"result,required,nullable"` - // Whether the API call was successful - Success FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleSuccess `json:"success,required"` - JSON firewallWAFPackageGetResponseLegacyJhsAPIResponseSingleJSON `json:"-"` -} - -// firewallWAFPackageGetResponseLegacyJhsAPIResponseSingleJSON contains the JSON -// metadata for the struct -// [FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingle] -type firewallWAFPackageGetResponseLegacyJhsAPIResponseSingleJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingle) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageGetResponseLegacyJhsAPIResponseSingleJSON) RawJSON() string { - return r.raw -} - -func (r FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingle) implementsFirewallWAFPackageGetResponse() { -} - -type FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleError struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallWAFPackageGetResponseLegacyJhsAPIResponseSingleErrorJSON `json:"-"` -} - -// firewallWAFPackageGetResponseLegacyJhsAPIResponseSingleErrorJSON contains the -// JSON metadata for the struct -// [FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleError] -type firewallWAFPackageGetResponseLegacyJhsAPIResponseSingleErrorJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageGetResponseLegacyJhsAPIResponseSingleErrorJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleMessage struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallWAFPackageGetResponseLegacyJhsAPIResponseSingleMessageJSON `json:"-"` -} - -// firewallWAFPackageGetResponseLegacyJhsAPIResponseSingleMessageJSON contains the -// JSON metadata for the struct -// [FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleMessage] -type firewallWAFPackageGetResponseLegacyJhsAPIResponseSingleMessageJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleMessage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageGetResponseLegacyJhsAPIResponseSingleMessageJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by -// [FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleResultUnknown] or -// [shared.UnionString]. -type FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleResult interface { - ImplementsFirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleResult() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleResult)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Whether the API call was successful -type FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleSuccess bool - -const ( - FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleSuccessTrue FirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleSuccess = true -) - -type FirewallWAFPackageGetResponseObject struct { - Result interface{} `json:"result"` - JSON firewallWAFPackageGetResponseObjectJSON `json:"-"` -} - -// firewallWAFPackageGetResponseObjectJSON contains the JSON metadata for the -// struct [FirewallWAFPackageGetResponseObject] -type firewallWAFPackageGetResponseObjectJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageGetResponseObject) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageGetResponseObjectJSON) RawJSON() string { - return r.raw -} - -func (r FirewallWAFPackageGetResponseObject) implementsFirewallWAFPackageGetResponse() {} - -type FirewallWAFPackageListParams struct { - // The direction used to sort returned packages. - Direction param.Field[FirewallWAFPackageListParamsDirection] `query:"direction"` - // When set to `all`, all the search requirements must match. When set to `any`, - // only one of the search requirements has to match. - Match param.Field[FirewallWAFPackageListParamsMatch] `query:"match"` - // The field used to sort returned packages. - Order param.Field[FirewallWAFPackageListParamsOrder] `query:"order"` - // The page number of paginated results. - Page param.Field[float64] `query:"page"` - // The number of packages per page. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [FirewallWAFPackageListParams]'s query parameters as -// `url.Values`. -func (r FirewallWAFPackageListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// The direction used to sort returned packages. -type FirewallWAFPackageListParamsDirection string - -const ( - FirewallWAFPackageListParamsDirectionAsc FirewallWAFPackageListParamsDirection = "asc" - FirewallWAFPackageListParamsDirectionDesc FirewallWAFPackageListParamsDirection = "desc" -) - -// When set to `all`, all the search requirements must match. When set to `any`, -// only one of the search requirements has to match. -type FirewallWAFPackageListParamsMatch string - -const ( - FirewallWAFPackageListParamsMatchAny FirewallWAFPackageListParamsMatch = "any" - FirewallWAFPackageListParamsMatchAll FirewallWAFPackageListParamsMatch = "all" -) - -// The field used to sort returned packages. -type FirewallWAFPackageListParamsOrder string - -const ( - FirewallWAFPackageListParamsOrderName FirewallWAFPackageListParamsOrder = "name" -) diff --git a/firewallwafpackage_test.go b/firewallwafpackage_test.go deleted file mode 100644 index 49923c49245..00000000000 --- a/firewallwafpackage_test.go +++ /dev/null @@ -1,76 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestFirewallWAFPackageListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Firewall.WAF.Packages.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.FirewallWAFPackageListParams{ - Direction: cloudflare.F(cloudflare.FirewallWAFPackageListParamsDirectionDesc), - Match: cloudflare.F(cloudflare.FirewallWAFPackageListParamsMatchAny), - Order: cloudflare.F(cloudflare.FirewallWAFPackageListParamsOrderName), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(5.000000), - }, - ) - 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 TestFirewallWAFPackageGet(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("user@example.com"), - ) - _, err := client.Firewall.WAF.Packages.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "a25a9a7e9c00afc1fb2e0245519d725b", - ) - 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/firewallwafpackagegroup.go b/firewallwafpackagegroup.go deleted file mode 100644 index bec77cd10db..00000000000 --- a/firewallwafpackagegroup.go +++ /dev/null @@ -1,462 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// FirewallWAFPackageGroupService 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 -// [NewFirewallWAFPackageGroupService] method instead. -type FirewallWAFPackageGroupService struct { - Options []option.RequestOption -} - -// NewFirewallWAFPackageGroupService 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 NewFirewallWAFPackageGroupService(opts ...option.RequestOption) (r *FirewallWAFPackageGroupService) { - r = &FirewallWAFPackageGroupService{} - r.Options = opts - return -} - -// Fetches the WAF rule groups in a WAF package. -// -// **Note:** Applies only to the -// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *FirewallWAFPackageGroupService) List(ctx context.Context, packageID string, params FirewallWAFPackageGroupListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[FirewallWAFPackageGroupListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("zones/%s/firewall/waf/packages/%s/groups", params.ZoneID, packageID) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Fetches the WAF rule groups in a WAF package. -// -// **Note:** Applies only to the -// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *FirewallWAFPackageGroupService) ListAutoPaging(ctx context.Context, packageID string, params FirewallWAFPackageGroupListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[FirewallWAFPackageGroupListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, packageID, params, opts...)) -} - -// Updates a WAF rule group. You can update the state (`mode` parameter) of a rule -// group. -// -// **Note:** Applies only to the -// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *FirewallWAFPackageGroupService) Edit(ctx context.Context, packageID string, groupID string, params FirewallWAFPackageGroupEditParams, opts ...option.RequestOption) (res *FirewallWAFPackageGroupEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallWAFPackageGroupEditResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/waf/packages/%s/groups/%s", params.ZoneID, packageID, groupID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the details of a WAF rule group. -// -// **Note:** Applies only to the -// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *FirewallWAFPackageGroupService) Get(ctx context.Context, packageID string, groupID string, query FirewallWAFPackageGroupGetParams, opts ...option.RequestOption) (res *FirewallWAFPackageGroupGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallWAFPackageGroupGetResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/waf/packages/%s/groups/%s", query.ZoneID, packageID, groupID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type FirewallWAFPackageGroupListResponse struct { - // The unique identifier of the rule group. - ID string `json:"id,required"` - // An informative summary of what the rule group does. - Description string `json:"description,required,nullable"` - // The state of the rules contained in the rule group. When `on`, the rules in the - // group are configurable/usable. - Mode FirewallWAFPackageGroupListResponseMode `json:"mode,required"` - // The name of the rule group. - Name string `json:"name,required"` - // The number of rules in the current rule group. - RulesCount float64 `json:"rules_count,required"` - // The available states for the rule group. - AllowedModes []FirewallWAFPackageGroupListResponseAllowedMode `json:"allowed_modes"` - // The number of rules within the group that have been modified from their default - // configuration. - ModifiedRulesCount float64 `json:"modified_rules_count"` - // The unique identifier of a WAF package. - PackageID string `json:"package_id"` - JSON firewallWAFPackageGroupListResponseJSON `json:"-"` -} - -// firewallWAFPackageGroupListResponseJSON contains the JSON metadata for the -// struct [FirewallWAFPackageGroupListResponse] -type firewallWAFPackageGroupListResponseJSON struct { - ID apijson.Field - Description apijson.Field - Mode apijson.Field - Name apijson.Field - RulesCount apijson.Field - AllowedModes apijson.Field - ModifiedRulesCount apijson.Field - PackageID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageGroupListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageGroupListResponseJSON) RawJSON() string { - return r.raw -} - -// The state of the rules contained in the rule group. When `on`, the rules in the -// group are configurable/usable. -type FirewallWAFPackageGroupListResponseMode string - -const ( - FirewallWAFPackageGroupListResponseModeOn FirewallWAFPackageGroupListResponseMode = "on" - FirewallWAFPackageGroupListResponseModeOff FirewallWAFPackageGroupListResponseMode = "off" -) - -// The state of the rules contained in the rule group. When `on`, the rules in the -// group are configurable/usable. -type FirewallWAFPackageGroupListResponseAllowedMode string - -const ( - FirewallWAFPackageGroupListResponseAllowedModeOn FirewallWAFPackageGroupListResponseAllowedMode = "on" - FirewallWAFPackageGroupListResponseAllowedModeOff FirewallWAFPackageGroupListResponseAllowedMode = "off" -) - -// Union satisfied by [FirewallWAFPackageGroupEditResponseUnknown], -// [FirewallWAFPackageGroupEditResponseArray] or [shared.UnionString]. -type FirewallWAFPackageGroupEditResponse interface { - ImplementsFirewallWAFPackageGroupEditResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallWAFPackageGroupEditResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallWAFPackageGroupEditResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type FirewallWAFPackageGroupEditResponseArray []interface{} - -func (r FirewallWAFPackageGroupEditResponseArray) ImplementsFirewallWAFPackageGroupEditResponse() {} - -// Union satisfied by [FirewallWAFPackageGroupGetResponseUnknown], -// [FirewallWAFPackageGroupGetResponseArray] or [shared.UnionString]. -type FirewallWAFPackageGroupGetResponse interface { - ImplementsFirewallWAFPackageGroupGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallWAFPackageGroupGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallWAFPackageGroupGetResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type FirewallWAFPackageGroupGetResponseArray []interface{} - -func (r FirewallWAFPackageGroupGetResponseArray) ImplementsFirewallWAFPackageGroupGetResponse() {} - -type FirewallWAFPackageGroupListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // The direction used to sort returned rule groups. - Direction param.Field[FirewallWAFPackageGroupListParamsDirection] `query:"direction"` - // When set to `all`, all the search requirements must match. When set to `any`, - // only one of the search requirements has to match. - Match param.Field[FirewallWAFPackageGroupListParamsMatch] `query:"match"` - // The state of the rules contained in the rule group. When `on`, the rules in the - // group are configurable/usable. - Mode param.Field[FirewallWAFPackageGroupListParamsMode] `query:"mode"` - // The field used to sort returned rule groups. - Order param.Field[FirewallWAFPackageGroupListParamsOrder] `query:"order"` - // The page number of paginated results. - Page param.Field[float64] `query:"page"` - // The number of rule groups per page. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [FirewallWAFPackageGroupListParams]'s query parameters as -// `url.Values`. -func (r FirewallWAFPackageGroupListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// The direction used to sort returned rule groups. -type FirewallWAFPackageGroupListParamsDirection string - -const ( - FirewallWAFPackageGroupListParamsDirectionAsc FirewallWAFPackageGroupListParamsDirection = "asc" - FirewallWAFPackageGroupListParamsDirectionDesc FirewallWAFPackageGroupListParamsDirection = "desc" -) - -// When set to `all`, all the search requirements must match. When set to `any`, -// only one of the search requirements has to match. -type FirewallWAFPackageGroupListParamsMatch string - -const ( - FirewallWAFPackageGroupListParamsMatchAny FirewallWAFPackageGroupListParamsMatch = "any" - FirewallWAFPackageGroupListParamsMatchAll FirewallWAFPackageGroupListParamsMatch = "all" -) - -// The state of the rules contained in the rule group. When `on`, the rules in the -// group are configurable/usable. -type FirewallWAFPackageGroupListParamsMode string - -const ( - FirewallWAFPackageGroupListParamsModeOn FirewallWAFPackageGroupListParamsMode = "on" - FirewallWAFPackageGroupListParamsModeOff FirewallWAFPackageGroupListParamsMode = "off" -) - -// The field used to sort returned rule groups. -type FirewallWAFPackageGroupListParamsOrder string - -const ( - FirewallWAFPackageGroupListParamsOrderMode FirewallWAFPackageGroupListParamsOrder = "mode" - FirewallWAFPackageGroupListParamsOrderRulesCount FirewallWAFPackageGroupListParamsOrder = "rules_count" -) - -type FirewallWAFPackageGroupEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // The state of the rules contained in the rule group. When `on`, the rules in the - // group are configurable/usable. - Mode param.Field[FirewallWAFPackageGroupEditParamsMode] `json:"mode"` -} - -func (r FirewallWAFPackageGroupEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The state of the rules contained in the rule group. When `on`, the rules in the -// group are configurable/usable. -type FirewallWAFPackageGroupEditParamsMode string - -const ( - FirewallWAFPackageGroupEditParamsModeOn FirewallWAFPackageGroupEditParamsMode = "on" - FirewallWAFPackageGroupEditParamsModeOff FirewallWAFPackageGroupEditParamsMode = "off" -) - -type FirewallWAFPackageGroupEditResponseEnvelope struct { - Errors []FirewallWAFPackageGroupEditResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallWAFPackageGroupEditResponseEnvelopeMessages `json:"messages,required"` - Result FirewallWAFPackageGroupEditResponse `json:"result,required"` - // Whether the API call was successful - Success FirewallWAFPackageGroupEditResponseEnvelopeSuccess `json:"success,required"` - JSON firewallWAFPackageGroupEditResponseEnvelopeJSON `json:"-"` -} - -// firewallWAFPackageGroupEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [FirewallWAFPackageGroupEditResponseEnvelope] -type firewallWAFPackageGroupEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageGroupEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageGroupEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFPackageGroupEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallWAFPackageGroupEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallWAFPackageGroupEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [FirewallWAFPackageGroupEditResponseEnvelopeErrors] -type firewallWAFPackageGroupEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageGroupEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageGroupEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFPackageGroupEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallWAFPackageGroupEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallWAFPackageGroupEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [FirewallWAFPackageGroupEditResponseEnvelopeMessages] -type firewallWAFPackageGroupEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageGroupEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageGroupEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallWAFPackageGroupEditResponseEnvelopeSuccess bool - -const ( - FirewallWAFPackageGroupEditResponseEnvelopeSuccessTrue FirewallWAFPackageGroupEditResponseEnvelopeSuccess = true -) - -type FirewallWAFPackageGroupGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type FirewallWAFPackageGroupGetResponseEnvelope struct { - Errors []FirewallWAFPackageGroupGetResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallWAFPackageGroupGetResponseEnvelopeMessages `json:"messages,required"` - Result FirewallWAFPackageGroupGetResponse `json:"result,required"` - // Whether the API call was successful - Success FirewallWAFPackageGroupGetResponseEnvelopeSuccess `json:"success,required"` - JSON firewallWAFPackageGroupGetResponseEnvelopeJSON `json:"-"` -} - -// firewallWAFPackageGroupGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [FirewallWAFPackageGroupGetResponseEnvelope] -type firewallWAFPackageGroupGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageGroupGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageGroupGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFPackageGroupGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallWAFPackageGroupGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallWAFPackageGroupGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [FirewallWAFPackageGroupGetResponseEnvelopeErrors] -type firewallWAFPackageGroupGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageGroupGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageGroupGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFPackageGroupGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallWAFPackageGroupGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallWAFPackageGroupGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [FirewallWAFPackageGroupGetResponseEnvelopeMessages] -type firewallWAFPackageGroupGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageGroupGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageGroupGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallWAFPackageGroupGetResponseEnvelopeSuccess bool - -const ( - FirewallWAFPackageGroupGetResponseEnvelopeSuccessTrue FirewallWAFPackageGroupGetResponseEnvelopeSuccess = true -) diff --git a/firewallwafpackagegroup_test.go b/firewallwafpackagegroup_test.go deleted file mode 100644 index 4a130103c98..00000000000 --- a/firewallwafpackagegroup_test.go +++ /dev/null @@ -1,113 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestFirewallWAFPackageGroupListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Firewall.WAF.Packages.Groups.List( - context.TODO(), - "a25a9a7e9c00afc1fb2e0245519d725b", - cloudflare.FirewallWAFPackageGroupListParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Direction: cloudflare.F(cloudflare.FirewallWAFPackageGroupListParamsDirectionDesc), - Match: cloudflare.F(cloudflare.FirewallWAFPackageGroupListParamsMatchAny), - Mode: cloudflare.F(cloudflare.FirewallWAFPackageGroupListParamsModeOn), - Order: cloudflare.F(cloudflare.FirewallWAFPackageGroupListParamsOrderMode), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(5.000000), - }, - ) - 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 TestFirewallWAFPackageGroupEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Firewall.WAF.Packages.Groups.Edit( - context.TODO(), - "a25a9a7e9c00afc1fb2e0245519d725b", - "a25a9a7e9c00afc1fb2e0245519d725b", - cloudflare.FirewallWAFPackageGroupEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Mode: cloudflare.F(cloudflare.FirewallWAFPackageGroupEditParamsModeOn), - }, - ) - 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 TestFirewallWAFPackageGroupGet(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("user@example.com"), - ) - _, err := client.Firewall.WAF.Packages.Groups.Get( - context.TODO(), - "a25a9a7e9c00afc1fb2e0245519d725b", - "a25a9a7e9c00afc1fb2e0245519d725b", - cloudflare.FirewallWAFPackageGroupGetParams{ - ZoneID: cloudflare.F("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/firewallwafpackagerule.go b/firewallwafpackagerule.go deleted file mode 100644 index 3115ba7c3d4..00000000000 --- a/firewallwafpackagerule.go +++ /dev/null @@ -1,1049 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// FirewallWAFPackageRuleService 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 [NewFirewallWAFPackageRuleService] -// method instead. -type FirewallWAFPackageRuleService struct { - Options []option.RequestOption -} - -// NewFirewallWAFPackageRuleService 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 NewFirewallWAFPackageRuleService(opts ...option.RequestOption) (r *FirewallWAFPackageRuleService) { - r = &FirewallWAFPackageRuleService{} - r.Options = opts - return -} - -// Fetches WAF rules in a WAF package. -// -// **Note:** Applies only to the -// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *FirewallWAFPackageRuleService) List(ctx context.Context, packageID string, params FirewallWAFPackageRuleListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[FirewallWAFPackageRuleListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("zones/%s/firewall/waf/packages/%s/rules", params.ZoneID, packageID) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Fetches WAF rules in a WAF package. -// -// **Note:** Applies only to the -// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *FirewallWAFPackageRuleService) ListAutoPaging(ctx context.Context, packageID string, params FirewallWAFPackageRuleListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[FirewallWAFPackageRuleListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, packageID, params, opts...)) -} - -// Updates a WAF rule. You can only update the mode/action of the rule. -// -// **Note:** Applies only to the -// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *FirewallWAFPackageRuleService) Edit(ctx context.Context, packageID string, ruleID string, params FirewallWAFPackageRuleEditParams, opts ...option.RequestOption) (res *FirewallWAFPackageRuleEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallWAFPackageRuleEditResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/waf/packages/%s/rules/%s", params.ZoneID, packageID, ruleID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the details of a WAF rule in a WAF package. -// -// **Note:** Applies only to the -// [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). -func (r *FirewallWAFPackageRuleService) Get(ctx context.Context, packageID string, ruleID string, query FirewallWAFPackageRuleGetParams, opts ...option.RequestOption) (res *FirewallWAFPackageRuleGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallWAFPackageRuleGetResponseEnvelope - path := fmt.Sprintf("zones/%s/firewall/waf/packages/%s/rules/%s", query.ZoneID, packageID, ruleID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// When triggered, anomaly detection WAF rules contribute to an overall threat -// score that will determine if a request is considered malicious. You can -// configure the total scoring threshold through the 'sensitivity' property of the -// WAF package. -// -// Union satisfied by -// [FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRule], -// [FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRule] or -// [FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRule]. -type FirewallWAFPackageRuleListResponse interface { - implementsFirewallWAFPackageRuleListResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallWAFPackageRuleListResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRule{}), - }, - ) -} - -// When triggered, anomaly detection WAF rules contribute to an overall threat -// score that will determine if a request is considered malicious. You can -// configure the total scoring threshold through the 'sensitivity' property of the -// WAF package. -type FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRule struct { - // The unique identifier of the WAF rule. - ID string `json:"id,required"` - // Defines the available modes for the current WAF rule. Applies to anomaly - // detection WAF rules. - AllowedModes []FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleAllowedMode `json:"allowed_modes,required"` - // The public description of the WAF rule. - Description string `json:"description,required"` - // The rule group to which the current WAF rule belongs. - Group FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleGroup `json:"group,required"` - // When set to `on`, the current WAF rule will be used when evaluating the request. - // Applies to anomaly detection WAF rules. - Mode FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleMode `json:"mode,required"` - // The unique identifier of a WAF package. - PackageID string `json:"package_id,required"` - // The order in which the individual WAF rule is executed within its rule group. - Priority string `json:"priority,required"` - JSON firewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleJSON `json:"-"` -} - -// firewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleJSON contains the -// JSON metadata for the struct -// [FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRule] -type firewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleJSON struct { - ID apijson.Field - AllowedModes apijson.Field - Description apijson.Field - Group apijson.Field - Mode apijson.Field - PackageID apijson.Field - Priority apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleJSON) RawJSON() string { - return r.raw -} - -func (r FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRule) implementsFirewallWAFPackageRuleListResponse() { -} - -// When set to `on`, the current WAF rule will be used when evaluating the request. -// Applies to anomaly detection WAF rules. -type FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleAllowedMode string - -const ( - FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleAllowedModeOn FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleAllowedMode = "on" - FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleAllowedModeOff FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleAllowedMode = "off" -) - -// The rule group to which the current WAF rule belongs. -type FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleGroup struct { - // The unique identifier of the rule group. - ID string `json:"id"` - // The name of the rule group. - Name string `json:"name"` - JSON firewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleGroupJSON `json:"-"` -} - -// firewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleGroupJSON contains -// the JSON metadata for the struct -// [FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleGroup] -type firewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleGroupJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleGroupJSON) RawJSON() string { - return r.raw -} - -// When set to `on`, the current WAF rule will be used when evaluating the request. -// Applies to anomaly detection WAF rules. -type FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleMode string - -const ( - FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleModeOn FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleMode = "on" - FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleModeOff FirewallWAFPackageRuleListResponseWAFManagedRulesAnomalyRuleMode = "off" -) - -// When triggered, traditional WAF rules cause the firewall to immediately act upon -// the request based on the configuration of the rule. A 'deny' rule will -// immediately respond to the request based on the configured rule action/mode (for -// example, 'block') and no other rules will be processed. -type FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRule struct { - // The unique identifier of the WAF rule. - ID string `json:"id,required"` - // The list of possible actions of the WAF rule when it is triggered. - AllowedModes []FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedMode `json:"allowed_modes,required"` - // The default action/mode of a rule. - DefaultMode FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultMode `json:"default_mode,required"` - // The public description of the WAF rule. - Description string `json:"description,required"` - // The rule group to which the current WAF rule belongs. - Group FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleGroup `json:"group,required"` - // The action that the current WAF rule will perform when triggered. Applies to - // traditional (deny) WAF rules. - Mode FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleMode `json:"mode,required"` - // The unique identifier of a WAF package. - PackageID string `json:"package_id,required"` - // The order in which the individual WAF rule is executed within its rule group. - Priority string `json:"priority,required"` - JSON firewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleJSON `json:"-"` -} - -// firewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleJSON -// contains the JSON metadata for the struct -// [FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRule] -type firewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleJSON struct { - ID apijson.Field - AllowedModes apijson.Field - DefaultMode apijson.Field - Description apijson.Field - Group apijson.Field - Mode apijson.Field - PackageID apijson.Field - Priority apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleJSON) RawJSON() string { - return r.raw -} - -func (r FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRule) implementsFirewallWAFPackageRuleListResponse() { -} - -// The action that the current WAF rule will perform when triggered. Applies to -// traditional (deny) WAF rules. -type FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedMode string - -const ( - FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedModeDefault FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "default" - FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedModeDisable FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "disable" - FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedModeSimulate FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "simulate" - FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedModeBlock FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "block" - FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedModeChallenge FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "challenge" -) - -// The default action/mode of a rule. -type FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultMode string - -const ( - FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultModeDisable FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultMode = "disable" - FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultModeSimulate FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultMode = "simulate" - FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultModeBlock FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultMode = "block" - FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultModeChallenge FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleDefaultMode = "challenge" -) - -// The rule group to which the current WAF rule belongs. -type FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleGroup struct { - // The unique identifier of the rule group. - ID string `json:"id"` - // The name of the rule group. - Name string `json:"name"` - JSON firewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleGroupJSON `json:"-"` -} - -// firewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleGroupJSON -// contains the JSON metadata for the struct -// [FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleGroup] -type firewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleGroupJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleGroupJSON) RawJSON() string { - return r.raw -} - -// The action that the current WAF rule will perform when triggered. Applies to -// traditional (deny) WAF rules. -type FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleMode string - -const ( - FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleModeDefault FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleMode = "default" - FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleModeDisable FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleMode = "disable" - FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleModeSimulate FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleMode = "simulate" - FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleModeBlock FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleMode = "block" - FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleModeChallenge FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalDenyRuleMode = "challenge" -) - -// When triggered, traditional WAF rules cause the firewall to immediately act on -// the request based on the rule configuration. An 'allow' rule will immediately -// allow the request and no other rules will be processed. -type FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRule struct { - // The unique identifier of the WAF rule. - ID string `json:"id,required"` - // Defines the available modes for the current WAF rule. - AllowedModes []FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleAllowedMode `json:"allowed_modes,required"` - // The public description of the WAF rule. - Description string `json:"description,required"` - // The rule group to which the current WAF rule belongs. - Group FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleGroup `json:"group,required"` - // When set to `on`, the current rule will be used when evaluating the request. - // Applies to traditional (allow) WAF rules. - Mode FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleMode `json:"mode,required"` - // The unique identifier of a WAF package. - PackageID string `json:"package_id,required"` - // The order in which the individual WAF rule is executed within its rule group. - Priority string `json:"priority,required"` - JSON firewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleJSON `json:"-"` -} - -// firewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleJSON -// contains the JSON metadata for the struct -// [FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRule] -type firewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleJSON struct { - ID apijson.Field - AllowedModes apijson.Field - Description apijson.Field - Group apijson.Field - Mode apijson.Field - PackageID apijson.Field - Priority apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleJSON) RawJSON() string { - return r.raw -} - -func (r FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRule) implementsFirewallWAFPackageRuleListResponse() { -} - -// When set to `on`, the current rule will be used when evaluating the request. -// Applies to traditional (allow) WAF rules. -type FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleAllowedMode string - -const ( - FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleAllowedModeOn FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleAllowedMode = "on" - FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleAllowedModeOff FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleAllowedMode = "off" -) - -// The rule group to which the current WAF rule belongs. -type FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleGroup struct { - // The unique identifier of the rule group. - ID string `json:"id"` - // The name of the rule group. - Name string `json:"name"` - JSON firewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleGroupJSON `json:"-"` -} - -// firewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleGroupJSON -// contains the JSON metadata for the struct -// [FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleGroup] -type firewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleGroupJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleGroupJSON) RawJSON() string { - return r.raw -} - -// When set to `on`, the current rule will be used when evaluating the request. -// Applies to traditional (allow) WAF rules. -type FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleMode string - -const ( - FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleModeOn FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleMode = "on" - FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleModeOff FirewallWAFPackageRuleListResponseWAFManagedRulesTraditionalAllowRuleMode = "off" -) - -// When triggered, anomaly detection WAF rules contribute to an overall threat -// score that will determine if a request is considered malicious. You can -// configure the total scoring threshold through the 'sensitivity' property of the -// WAF package. -// -// Union satisfied by -// [FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRule], -// [FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRule] or -// [FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRule]. -type FirewallWAFPackageRuleEditResponse interface { - implementsFirewallWAFPackageRuleEditResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallWAFPackageRuleEditResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRule{}), - }, - ) -} - -// When triggered, anomaly detection WAF rules contribute to an overall threat -// score that will determine if a request is considered malicious. You can -// configure the total scoring threshold through the 'sensitivity' property of the -// WAF package. -type FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRule struct { - // The unique identifier of the WAF rule. - ID string `json:"id,required"` - // Defines the available modes for the current WAF rule. Applies to anomaly - // detection WAF rules. - AllowedModes []FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedMode `json:"allowed_modes,required"` - // The public description of the WAF rule. - Description string `json:"description,required"` - // The rule group to which the current WAF rule belongs. - Group FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroup `json:"group,required"` - // When set to `on`, the current WAF rule will be used when evaluating the request. - // Applies to anomaly detection WAF rules. - Mode FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleMode `json:"mode,required"` - // The unique identifier of a WAF package. - PackageID string `json:"package_id,required"` - // The order in which the individual WAF rule is executed within its rule group. - Priority string `json:"priority,required"` - JSON firewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleJSON `json:"-"` -} - -// firewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleJSON contains the -// JSON metadata for the struct -// [FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRule] -type firewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleJSON struct { - ID apijson.Field - AllowedModes apijson.Field - Description apijson.Field - Group apijson.Field - Mode apijson.Field - PackageID apijson.Field - Priority apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleJSON) RawJSON() string { - return r.raw -} - -func (r FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRule) implementsFirewallWAFPackageRuleEditResponse() { -} - -// When set to `on`, the current WAF rule will be used when evaluating the request. -// Applies to anomaly detection WAF rules. -type FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedMode string - -const ( - FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedModeOn FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedMode = "on" - FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedModeOff FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleAllowedMode = "off" -) - -// The rule group to which the current WAF rule belongs. -type FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroup struct { - // The unique identifier of the rule group. - ID string `json:"id"` - // The name of the rule group. - Name string `json:"name"` - JSON firewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroupJSON `json:"-"` -} - -// firewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroupJSON contains -// the JSON metadata for the struct -// [FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroup] -type firewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroupJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleGroupJSON) RawJSON() string { - return r.raw -} - -// When set to `on`, the current WAF rule will be used when evaluating the request. -// Applies to anomaly detection WAF rules. -type FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleMode string - -const ( - FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleModeOn FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleMode = "on" - FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleModeOff FirewallWAFPackageRuleEditResponseWAFManagedRulesAnomalyRuleMode = "off" -) - -// When triggered, traditional WAF rules cause the firewall to immediately act upon -// the request based on the configuration of the rule. A 'deny' rule will -// immediately respond to the request based on the configured rule action/mode (for -// example, 'block') and no other rules will be processed. -type FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRule struct { - // The unique identifier of the WAF rule. - ID string `json:"id,required"` - // The list of possible actions of the WAF rule when it is triggered. - AllowedModes []FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedMode `json:"allowed_modes,required"` - // The default action/mode of a rule. - DefaultMode FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultMode `json:"default_mode,required"` - // The public description of the WAF rule. - Description string `json:"description,required"` - // The rule group to which the current WAF rule belongs. - Group FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroup `json:"group,required"` - // The action that the current WAF rule will perform when triggered. Applies to - // traditional (deny) WAF rules. - Mode FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleMode `json:"mode,required"` - // The unique identifier of a WAF package. - PackageID string `json:"package_id,required"` - // The order in which the individual WAF rule is executed within its rule group. - Priority string `json:"priority,required"` - JSON firewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleJSON `json:"-"` -} - -// firewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleJSON -// contains the JSON metadata for the struct -// [FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRule] -type firewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleJSON struct { - ID apijson.Field - AllowedModes apijson.Field - DefaultMode apijson.Field - Description apijson.Field - Group apijson.Field - Mode apijson.Field - PackageID apijson.Field - Priority apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleJSON) RawJSON() string { - return r.raw -} - -func (r FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRule) implementsFirewallWAFPackageRuleEditResponse() { -} - -// The action that the current WAF rule will perform when triggered. Applies to -// traditional (deny) WAF rules. -type FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedMode string - -const ( - FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedModeDefault FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "default" - FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedModeDisable FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "disable" - FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedModeSimulate FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "simulate" - FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedModeBlock FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "block" - FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedModeChallenge FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleAllowedMode = "challenge" -) - -// The default action/mode of a rule. -type FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultMode string - -const ( - FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultModeDisable FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultMode = "disable" - FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultModeSimulate FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultMode = "simulate" - FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultModeBlock FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultMode = "block" - FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultModeChallenge FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleDefaultMode = "challenge" -) - -// The rule group to which the current WAF rule belongs. -type FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroup struct { - // The unique identifier of the rule group. - ID string `json:"id"` - // The name of the rule group. - Name string `json:"name"` - JSON firewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroupJSON `json:"-"` -} - -// firewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroupJSON -// contains the JSON metadata for the struct -// [FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroup] -type firewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroupJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleGroupJSON) RawJSON() string { - return r.raw -} - -// The action that the current WAF rule will perform when triggered. Applies to -// traditional (deny) WAF rules. -type FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleMode string - -const ( - FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleModeDefault FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleMode = "default" - FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleModeDisable FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleMode = "disable" - FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleModeSimulate FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleMode = "simulate" - FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleModeBlock FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleMode = "block" - FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleModeChallenge FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalDenyRuleMode = "challenge" -) - -// When triggered, traditional WAF rules cause the firewall to immediately act on -// the request based on the rule configuration. An 'allow' rule will immediately -// allow the request and no other rules will be processed. -type FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRule struct { - // The unique identifier of the WAF rule. - ID string `json:"id,required"` - // Defines the available modes for the current WAF rule. - AllowedModes []FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleAllowedMode `json:"allowed_modes,required"` - // The public description of the WAF rule. - Description string `json:"description,required"` - // The rule group to which the current WAF rule belongs. - Group FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroup `json:"group,required"` - // When set to `on`, the current rule will be used when evaluating the request. - // Applies to traditional (allow) WAF rules. - Mode FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleMode `json:"mode,required"` - // The unique identifier of a WAF package. - PackageID string `json:"package_id,required"` - // The order in which the individual WAF rule is executed within its rule group. - Priority string `json:"priority,required"` - JSON firewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleJSON `json:"-"` -} - -// firewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleJSON -// contains the JSON metadata for the struct -// [FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRule] -type firewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleJSON struct { - ID apijson.Field - AllowedModes apijson.Field - Description apijson.Field - Group apijson.Field - Mode apijson.Field - PackageID apijson.Field - Priority apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleJSON) RawJSON() string { - return r.raw -} - -func (r FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRule) implementsFirewallWAFPackageRuleEditResponse() { -} - -// When set to `on`, the current rule will be used when evaluating the request. -// Applies to traditional (allow) WAF rules. -type FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleAllowedMode string - -const ( - FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleAllowedModeOn FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleAllowedMode = "on" - FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleAllowedModeOff FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleAllowedMode = "off" -) - -// The rule group to which the current WAF rule belongs. -type FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroup struct { - // The unique identifier of the rule group. - ID string `json:"id"` - // The name of the rule group. - Name string `json:"name"` - JSON firewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroupJSON `json:"-"` -} - -// firewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroupJSON -// contains the JSON metadata for the struct -// [FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroup] -type firewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroupJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleGroupJSON) RawJSON() string { - return r.raw -} - -// When set to `on`, the current rule will be used when evaluating the request. -// Applies to traditional (allow) WAF rules. -type FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleMode string - -const ( - FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleModeOn FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleMode = "on" - FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleModeOff FirewallWAFPackageRuleEditResponseWAFManagedRulesTraditionalAllowRuleMode = "off" -) - -// Union satisfied by [FirewallWAFPackageRuleGetResponseUnknown], -// [FirewallWAFPackageRuleGetResponseArray] or [shared.UnionString]. -type FirewallWAFPackageRuleGetResponse interface { - ImplementsFirewallWAFPackageRuleGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallWAFPackageRuleGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(FirewallWAFPackageRuleGetResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type FirewallWAFPackageRuleGetResponseArray []interface{} - -func (r FirewallWAFPackageRuleGetResponseArray) ImplementsFirewallWAFPackageRuleGetResponse() {} - -type FirewallWAFPackageRuleListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // The direction used to sort returned rules. - Direction param.Field[FirewallWAFPackageRuleListParamsDirection] `query:"direction"` - // When set to `all`, all the search requirements must match. When set to `any`, - // only one of the search requirements has to match. - Match param.Field[FirewallWAFPackageRuleListParamsMatch] `query:"match"` - // The action/mode a rule has been overridden to perform. - Mode param.Field[FirewallWAFPackageRuleListParamsMode] `query:"mode"` - // The field used to sort returned rules. - Order param.Field[FirewallWAFPackageRuleListParamsOrder] `query:"order"` - // The page number of paginated results. - Page param.Field[float64] `query:"page"` - // The number of rules per page. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [FirewallWAFPackageRuleListParams]'s query parameters as -// `url.Values`. -func (r FirewallWAFPackageRuleListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// The direction used to sort returned rules. -type FirewallWAFPackageRuleListParamsDirection string - -const ( - FirewallWAFPackageRuleListParamsDirectionAsc FirewallWAFPackageRuleListParamsDirection = "asc" - FirewallWAFPackageRuleListParamsDirectionDesc FirewallWAFPackageRuleListParamsDirection = "desc" -) - -// When set to `all`, all the search requirements must match. When set to `any`, -// only one of the search requirements has to match. -type FirewallWAFPackageRuleListParamsMatch string - -const ( - FirewallWAFPackageRuleListParamsMatchAny FirewallWAFPackageRuleListParamsMatch = "any" - FirewallWAFPackageRuleListParamsMatchAll FirewallWAFPackageRuleListParamsMatch = "all" -) - -// The action/mode a rule has been overridden to perform. -type FirewallWAFPackageRuleListParamsMode string - -const ( - FirewallWAFPackageRuleListParamsModeDis FirewallWAFPackageRuleListParamsMode = "DIS" - FirewallWAFPackageRuleListParamsModeChl FirewallWAFPackageRuleListParamsMode = "CHL" - FirewallWAFPackageRuleListParamsModeBlk FirewallWAFPackageRuleListParamsMode = "BLK" - FirewallWAFPackageRuleListParamsModeSim FirewallWAFPackageRuleListParamsMode = "SIM" -) - -// The field used to sort returned rules. -type FirewallWAFPackageRuleListParamsOrder string - -const ( - FirewallWAFPackageRuleListParamsOrderPriority FirewallWAFPackageRuleListParamsOrder = "priority" - FirewallWAFPackageRuleListParamsOrderGroupID FirewallWAFPackageRuleListParamsOrder = "group_id" - FirewallWAFPackageRuleListParamsOrderDescription FirewallWAFPackageRuleListParamsOrder = "description" -) - -type FirewallWAFPackageRuleEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // The mode/action of the rule when triggered. You must use a value from the - // `allowed_modes` array of the current rule. - Mode param.Field[FirewallWAFPackageRuleEditParamsMode] `json:"mode"` -} - -func (r FirewallWAFPackageRuleEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The mode/action of the rule when triggered. You must use a value from the -// `allowed_modes` array of the current rule. -type FirewallWAFPackageRuleEditParamsMode string - -const ( - FirewallWAFPackageRuleEditParamsModeDefault FirewallWAFPackageRuleEditParamsMode = "default" - FirewallWAFPackageRuleEditParamsModeDisable FirewallWAFPackageRuleEditParamsMode = "disable" - FirewallWAFPackageRuleEditParamsModeSimulate FirewallWAFPackageRuleEditParamsMode = "simulate" - FirewallWAFPackageRuleEditParamsModeBlock FirewallWAFPackageRuleEditParamsMode = "block" - FirewallWAFPackageRuleEditParamsModeChallenge FirewallWAFPackageRuleEditParamsMode = "challenge" - FirewallWAFPackageRuleEditParamsModeOn FirewallWAFPackageRuleEditParamsMode = "on" - FirewallWAFPackageRuleEditParamsModeOff FirewallWAFPackageRuleEditParamsMode = "off" -) - -type FirewallWAFPackageRuleEditResponseEnvelope struct { - Errors []FirewallWAFPackageRuleEditResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallWAFPackageRuleEditResponseEnvelopeMessages `json:"messages,required"` - // When triggered, anomaly detection WAF rules contribute to an overall threat - // score that will determine if a request is considered malicious. You can - // configure the total scoring threshold through the 'sensitivity' property of the - // WAF package. - Result FirewallWAFPackageRuleEditResponse `json:"result,required"` - // Whether the API call was successful - Success FirewallWAFPackageRuleEditResponseEnvelopeSuccess `json:"success,required"` - JSON firewallWAFPackageRuleEditResponseEnvelopeJSON `json:"-"` -} - -// firewallWAFPackageRuleEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [FirewallWAFPackageRuleEditResponseEnvelope] -type firewallWAFPackageRuleEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageRuleEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageRuleEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFPackageRuleEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallWAFPackageRuleEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallWAFPackageRuleEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [FirewallWAFPackageRuleEditResponseEnvelopeErrors] -type firewallWAFPackageRuleEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageRuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageRuleEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFPackageRuleEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallWAFPackageRuleEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallWAFPackageRuleEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [FirewallWAFPackageRuleEditResponseEnvelopeMessages] -type firewallWAFPackageRuleEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageRuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageRuleEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallWAFPackageRuleEditResponseEnvelopeSuccess bool - -const ( - FirewallWAFPackageRuleEditResponseEnvelopeSuccessTrue FirewallWAFPackageRuleEditResponseEnvelopeSuccess = true -) - -type FirewallWAFPackageRuleGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type FirewallWAFPackageRuleGetResponseEnvelope struct { - Errors []FirewallWAFPackageRuleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []FirewallWAFPackageRuleGetResponseEnvelopeMessages `json:"messages,required"` - Result FirewallWAFPackageRuleGetResponse `json:"result,required"` - // Whether the API call was successful - Success FirewallWAFPackageRuleGetResponseEnvelopeSuccess `json:"success,required"` - JSON firewallWAFPackageRuleGetResponseEnvelopeJSON `json:"-"` -} - -// firewallWAFPackageRuleGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [FirewallWAFPackageRuleGetResponseEnvelope] -type firewallWAFPackageRuleGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageRuleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageRuleGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFPackageRuleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallWAFPackageRuleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// firewallWAFPackageRuleGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [FirewallWAFPackageRuleGetResponseEnvelopeErrors] -type firewallWAFPackageRuleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageRuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageRuleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type FirewallWAFPackageRuleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON firewallWAFPackageRuleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// firewallWAFPackageRuleGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [FirewallWAFPackageRuleGetResponseEnvelopeMessages] -type firewallWAFPackageRuleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *FirewallWAFPackageRuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallWAFPackageRuleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type FirewallWAFPackageRuleGetResponseEnvelopeSuccess bool - -const ( - FirewallWAFPackageRuleGetResponseEnvelopeSuccessTrue FirewallWAFPackageRuleGetResponseEnvelopeSuccess = true -) diff --git a/firewallwafpackagerule_test.go b/firewallwafpackagerule_test.go deleted file mode 100644 index ea8d45f111c..00000000000 --- a/firewallwafpackagerule_test.go +++ /dev/null @@ -1,113 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestFirewallWAFPackageRuleListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Firewall.WAF.Packages.Rules.List( - context.TODO(), - "a25a9a7e9c00afc1fb2e0245519d725b", - cloudflare.FirewallWAFPackageRuleListParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Direction: cloudflare.F(cloudflare.FirewallWAFPackageRuleListParamsDirectionDesc), - Match: cloudflare.F(cloudflare.FirewallWAFPackageRuleListParamsMatchAny), - Mode: cloudflare.F(cloudflare.FirewallWAFPackageRuleListParamsModeChl), - Order: cloudflare.F(cloudflare.FirewallWAFPackageRuleListParamsOrderPriority), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(5.000000), - }, - ) - 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 TestFirewallWAFPackageRuleEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Firewall.WAF.Packages.Rules.Edit( - context.TODO(), - "a25a9a7e9c00afc1fb2e0245519d725b", - "a25a9a7e9c00afc1fb2e0245519d725b", - cloudflare.FirewallWAFPackageRuleEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Mode: cloudflare.F(cloudflare.FirewallWAFPackageRuleEditParamsModeOn), - }, - ) - 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 TestFirewallWAFPackageRuleGet(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("user@example.com"), - ) - _, err := client.Firewall.WAF.Packages.Rules.Get( - context.TODO(), - "a25a9a7e9c00afc1fb2e0245519d725b", - "a25a9a7e9c00afc1fb2e0245519d725b", - cloudflare.FirewallWAFPackageRuleGetParams{ - ZoneID: cloudflare.F("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/healthcheck.go b/healthcheck.go deleted file mode 100644 index da6bdf5f4fc..00000000000 --- a/healthcheck.go +++ /dev/null @@ -1,2024 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// HealthcheckService 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 [NewHealthcheckService] method -// instead. -type HealthcheckService struct { - Options []option.RequestOption - Previews *HealthcheckPreviewService -} - -// NewHealthcheckService 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 NewHealthcheckService(opts ...option.RequestOption) (r *HealthcheckService) { - r = &HealthcheckService{} - r.Options = opts - r.Previews = NewHealthcheckPreviewService(opts...) - return -} - -// Create a new health check. -func (r *HealthcheckService) New(ctx context.Context, zoneIdentifier string, body HealthcheckNewParams, opts ...option.RequestOption) (res *HealthcheckNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env HealthcheckNewResponseEnvelope - path := fmt.Sprintf("zones/%s/healthchecks", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update a configured health check. -func (r *HealthcheckService) Update(ctx context.Context, zoneIdentifier string, identifier string, body HealthcheckUpdateParams, opts ...option.RequestOption) (res *HealthcheckUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env HealthcheckUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/healthchecks/%s", zoneIdentifier, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List configured health checks. -func (r *HealthcheckService) List(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *[]HealthcheckListResponse, err error) { - opts = append(r.Options[:], opts...) - var env HealthcheckListResponseEnvelope - path := fmt.Sprintf("zones/%s/healthchecks", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a health check. -func (r *HealthcheckService) Delete(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *HealthcheckDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env HealthcheckDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/healthchecks/%s", zoneIdentifier, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Patch a configured health check. -func (r *HealthcheckService) Edit(ctx context.Context, zoneIdentifier string, identifier string, body HealthcheckEditParams, opts ...option.RequestOption) (res *HealthcheckEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env HealthcheckEditResponseEnvelope - path := fmt.Sprintf("zones/%s/healthchecks/%s", zoneIdentifier, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch a single configured health check. -func (r *HealthcheckService) Get(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *HealthcheckGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env HealthcheckGetResponseEnvelope - path := fmt.Sprintf("zones/%s/healthchecks/%s", zoneIdentifier, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type HealthcheckNewResponse struct { - // Identifier - ID string `json:"id"` - // The hostname or IP address of the origin server to run health checks on. - Address string `json:"address"` - // A list of regions from which to run health checks. Null means Cloudflare will - // pick a default region. - CheckRegions []HealthcheckNewResponseCheckRegion `json:"check_regions,nullable"` - // The number of consecutive fails required from a health check before changing the - // health to unhealthy. - ConsecutiveFails int64 `json:"consecutive_fails"` - // The number of consecutive successes required from a health check before changing - // the health to healthy. - ConsecutiveSuccesses int64 `json:"consecutive_successes"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A human-readable description of the health check. - Description string `json:"description"` - // The current failure reason if status is unhealthy. - FailureReason string `json:"failure_reason"` - // Parameters specific to an HTTP or HTTPS health check. - HTTPConfig HealthcheckNewResponseHTTPConfig `json:"http_config,nullable"` - // The interval between each health check. Shorter intervals may give quicker - // notifications if the origin status changes, but will increase load on the origin - // as we check from multiple locations. - Interval int64 `json:"interval"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A short name to identify the health check. Only alphanumeric characters, hyphens - // and underscores are allowed. - Name string `json:"name"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The current status of the origin server according to the health check. - Status HealthcheckNewResponseStatus `json:"status"` - // If suspended, no health checks are sent to the origin. - Suspended bool `json:"suspended"` - // Parameters specific to TCP health check. - TcpConfig HealthcheckNewResponseTcpConfig `json:"tcp_config,nullable"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP', 'HTTPS' and 'TCP'. - Type string `json:"type"` - JSON healthcheckNewResponseJSON `json:"-"` -} - -// healthcheckNewResponseJSON contains the JSON metadata for the struct -// [HealthcheckNewResponse] -type healthcheckNewResponseJSON struct { - ID apijson.Field - Address apijson.Field - CheckRegions apijson.Field - ConsecutiveFails apijson.Field - ConsecutiveSuccesses apijson.Field - CreatedOn apijson.Field - Description apijson.Field - FailureReason apijson.Field - HTTPConfig apijson.Field - Interval apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Retries apijson.Field - Status apijson.Field - Suspended apijson.Field - TcpConfig apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckNewResponseJSON) RawJSON() string { - return r.raw -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, -// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS -// and ENTERPRISE customers only). -type HealthcheckNewResponseCheckRegion string - -const ( - HealthcheckNewResponseCheckRegionWnam HealthcheckNewResponseCheckRegion = "WNAM" - HealthcheckNewResponseCheckRegionEnam HealthcheckNewResponseCheckRegion = "ENAM" - HealthcheckNewResponseCheckRegionWeu HealthcheckNewResponseCheckRegion = "WEU" - HealthcheckNewResponseCheckRegionEeu HealthcheckNewResponseCheckRegion = "EEU" - HealthcheckNewResponseCheckRegionNsam HealthcheckNewResponseCheckRegion = "NSAM" - HealthcheckNewResponseCheckRegionSsam HealthcheckNewResponseCheckRegion = "SSAM" - HealthcheckNewResponseCheckRegionOc HealthcheckNewResponseCheckRegion = "OC" - HealthcheckNewResponseCheckRegionMe HealthcheckNewResponseCheckRegion = "ME" - HealthcheckNewResponseCheckRegionNaf HealthcheckNewResponseCheckRegion = "NAF" - HealthcheckNewResponseCheckRegionSaf HealthcheckNewResponseCheckRegion = "SAF" - HealthcheckNewResponseCheckRegionIn HealthcheckNewResponseCheckRegion = "IN" - HealthcheckNewResponseCheckRegionSeas HealthcheckNewResponseCheckRegion = "SEAS" - HealthcheckNewResponseCheckRegionNeas HealthcheckNewResponseCheckRegion = "NEAS" - HealthcheckNewResponseCheckRegionAllRegions HealthcheckNewResponseCheckRegion = "ALL_REGIONS" -) - -// Parameters specific to an HTTP or HTTPS health check. -type HealthcheckNewResponseHTTPConfig struct { - // Do not validate the certificate when the health check uses HTTPS. - AllowInsecure bool `json:"allow_insecure"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all - // codes starting with 2) of the health check. - ExpectedCodes []string `json:"expected_codes,nullable"` - // Follow redirects if the origin returns a 3xx status code. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. - Header interface{} `json:"header,nullable"` - // The HTTP method to use for the health check. - Method HealthcheckNewResponseHTTPConfigMethod `json:"method"` - // The endpoint path to health check against. - Path string `json:"path"` - // Port number to connect to for the health check. Defaults to 80 if type is HTTP - // or 443 if type is HTTPS. - Port int64 `json:"port"` - JSON healthcheckNewResponseHTTPConfigJSON `json:"-"` -} - -// healthcheckNewResponseHTTPConfigJSON contains the JSON metadata for the struct -// [HealthcheckNewResponseHTTPConfig] -type healthcheckNewResponseHTTPConfigJSON struct { - AllowInsecure apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Method apijson.Field - Path apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckNewResponseHTTPConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckNewResponseHTTPConfigJSON) RawJSON() string { - return r.raw -} - -// The HTTP method to use for the health check. -type HealthcheckNewResponseHTTPConfigMethod string - -const ( - HealthcheckNewResponseHTTPConfigMethodGet HealthcheckNewResponseHTTPConfigMethod = "GET" - HealthcheckNewResponseHTTPConfigMethodHead HealthcheckNewResponseHTTPConfigMethod = "HEAD" -) - -// The current status of the origin server according to the health check. -type HealthcheckNewResponseStatus string - -const ( - HealthcheckNewResponseStatusUnknown HealthcheckNewResponseStatus = "unknown" - HealthcheckNewResponseStatusHealthy HealthcheckNewResponseStatus = "healthy" - HealthcheckNewResponseStatusUnhealthy HealthcheckNewResponseStatus = "unhealthy" - HealthcheckNewResponseStatusSuspended HealthcheckNewResponseStatus = "suspended" -) - -// Parameters specific to TCP health check. -type HealthcheckNewResponseTcpConfig struct { - // The TCP connection method to use for the health check. - Method HealthcheckNewResponseTcpConfigMethod `json:"method"` - // Port number to connect to for the health check. Defaults to 80. - Port int64 `json:"port"` - JSON healthcheckNewResponseTcpConfigJSON `json:"-"` -} - -// healthcheckNewResponseTcpConfigJSON contains the JSON metadata for the struct -// [HealthcheckNewResponseTcpConfig] -type healthcheckNewResponseTcpConfigJSON struct { - Method apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckNewResponseTcpConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckNewResponseTcpConfigJSON) RawJSON() string { - return r.raw -} - -// The TCP connection method to use for the health check. -type HealthcheckNewResponseTcpConfigMethod string - -const ( - HealthcheckNewResponseTcpConfigMethodConnectionEstablished HealthcheckNewResponseTcpConfigMethod = "connection_established" -) - -type HealthcheckUpdateResponse struct { - // Identifier - ID string `json:"id"` - // The hostname or IP address of the origin server to run health checks on. - Address string `json:"address"` - // A list of regions from which to run health checks. Null means Cloudflare will - // pick a default region. - CheckRegions []HealthcheckUpdateResponseCheckRegion `json:"check_regions,nullable"` - // The number of consecutive fails required from a health check before changing the - // health to unhealthy. - ConsecutiveFails int64 `json:"consecutive_fails"` - // The number of consecutive successes required from a health check before changing - // the health to healthy. - ConsecutiveSuccesses int64 `json:"consecutive_successes"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A human-readable description of the health check. - Description string `json:"description"` - // The current failure reason if status is unhealthy. - FailureReason string `json:"failure_reason"` - // Parameters specific to an HTTP or HTTPS health check. - HTTPConfig HealthcheckUpdateResponseHTTPConfig `json:"http_config,nullable"` - // The interval between each health check. Shorter intervals may give quicker - // notifications if the origin status changes, but will increase load on the origin - // as we check from multiple locations. - Interval int64 `json:"interval"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A short name to identify the health check. Only alphanumeric characters, hyphens - // and underscores are allowed. - Name string `json:"name"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The current status of the origin server according to the health check. - Status HealthcheckUpdateResponseStatus `json:"status"` - // If suspended, no health checks are sent to the origin. - Suspended bool `json:"suspended"` - // Parameters specific to TCP health check. - TcpConfig HealthcheckUpdateResponseTcpConfig `json:"tcp_config,nullable"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP', 'HTTPS' and 'TCP'. - Type string `json:"type"` - JSON healthcheckUpdateResponseJSON `json:"-"` -} - -// healthcheckUpdateResponseJSON contains the JSON metadata for the struct -// [HealthcheckUpdateResponse] -type healthcheckUpdateResponseJSON struct { - ID apijson.Field - Address apijson.Field - CheckRegions apijson.Field - ConsecutiveFails apijson.Field - ConsecutiveSuccesses apijson.Field - CreatedOn apijson.Field - Description apijson.Field - FailureReason apijson.Field - HTTPConfig apijson.Field - Interval apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Retries apijson.Field - Status apijson.Field - Suspended apijson.Field - TcpConfig apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, -// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS -// and ENTERPRISE customers only). -type HealthcheckUpdateResponseCheckRegion string - -const ( - HealthcheckUpdateResponseCheckRegionWnam HealthcheckUpdateResponseCheckRegion = "WNAM" - HealthcheckUpdateResponseCheckRegionEnam HealthcheckUpdateResponseCheckRegion = "ENAM" - HealthcheckUpdateResponseCheckRegionWeu HealthcheckUpdateResponseCheckRegion = "WEU" - HealthcheckUpdateResponseCheckRegionEeu HealthcheckUpdateResponseCheckRegion = "EEU" - HealthcheckUpdateResponseCheckRegionNsam HealthcheckUpdateResponseCheckRegion = "NSAM" - HealthcheckUpdateResponseCheckRegionSsam HealthcheckUpdateResponseCheckRegion = "SSAM" - HealthcheckUpdateResponseCheckRegionOc HealthcheckUpdateResponseCheckRegion = "OC" - HealthcheckUpdateResponseCheckRegionMe HealthcheckUpdateResponseCheckRegion = "ME" - HealthcheckUpdateResponseCheckRegionNaf HealthcheckUpdateResponseCheckRegion = "NAF" - HealthcheckUpdateResponseCheckRegionSaf HealthcheckUpdateResponseCheckRegion = "SAF" - HealthcheckUpdateResponseCheckRegionIn HealthcheckUpdateResponseCheckRegion = "IN" - HealthcheckUpdateResponseCheckRegionSeas HealthcheckUpdateResponseCheckRegion = "SEAS" - HealthcheckUpdateResponseCheckRegionNeas HealthcheckUpdateResponseCheckRegion = "NEAS" - HealthcheckUpdateResponseCheckRegionAllRegions HealthcheckUpdateResponseCheckRegion = "ALL_REGIONS" -) - -// Parameters specific to an HTTP or HTTPS health check. -type HealthcheckUpdateResponseHTTPConfig struct { - // Do not validate the certificate when the health check uses HTTPS. - AllowInsecure bool `json:"allow_insecure"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all - // codes starting with 2) of the health check. - ExpectedCodes []string `json:"expected_codes,nullable"` - // Follow redirects if the origin returns a 3xx status code. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. - Header interface{} `json:"header,nullable"` - // The HTTP method to use for the health check. - Method HealthcheckUpdateResponseHTTPConfigMethod `json:"method"` - // The endpoint path to health check against. - Path string `json:"path"` - // Port number to connect to for the health check. Defaults to 80 if type is HTTP - // or 443 if type is HTTPS. - Port int64 `json:"port"` - JSON healthcheckUpdateResponseHTTPConfigJSON `json:"-"` -} - -// healthcheckUpdateResponseHTTPConfigJSON contains the JSON metadata for the -// struct [HealthcheckUpdateResponseHTTPConfig] -type healthcheckUpdateResponseHTTPConfigJSON struct { - AllowInsecure apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Method apijson.Field - Path apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckUpdateResponseHTTPConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckUpdateResponseHTTPConfigJSON) RawJSON() string { - return r.raw -} - -// The HTTP method to use for the health check. -type HealthcheckUpdateResponseHTTPConfigMethod string - -const ( - HealthcheckUpdateResponseHTTPConfigMethodGet HealthcheckUpdateResponseHTTPConfigMethod = "GET" - HealthcheckUpdateResponseHTTPConfigMethodHead HealthcheckUpdateResponseHTTPConfigMethod = "HEAD" -) - -// The current status of the origin server according to the health check. -type HealthcheckUpdateResponseStatus string - -const ( - HealthcheckUpdateResponseStatusUnknown HealthcheckUpdateResponseStatus = "unknown" - HealthcheckUpdateResponseStatusHealthy HealthcheckUpdateResponseStatus = "healthy" - HealthcheckUpdateResponseStatusUnhealthy HealthcheckUpdateResponseStatus = "unhealthy" - HealthcheckUpdateResponseStatusSuspended HealthcheckUpdateResponseStatus = "suspended" -) - -// Parameters specific to TCP health check. -type HealthcheckUpdateResponseTcpConfig struct { - // The TCP connection method to use for the health check. - Method HealthcheckUpdateResponseTcpConfigMethod `json:"method"` - // Port number to connect to for the health check. Defaults to 80. - Port int64 `json:"port"` - JSON healthcheckUpdateResponseTcpConfigJSON `json:"-"` -} - -// healthcheckUpdateResponseTcpConfigJSON contains the JSON metadata for the struct -// [HealthcheckUpdateResponseTcpConfig] -type healthcheckUpdateResponseTcpConfigJSON struct { - Method apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckUpdateResponseTcpConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckUpdateResponseTcpConfigJSON) RawJSON() string { - return r.raw -} - -// The TCP connection method to use for the health check. -type HealthcheckUpdateResponseTcpConfigMethod string - -const ( - HealthcheckUpdateResponseTcpConfigMethodConnectionEstablished HealthcheckUpdateResponseTcpConfigMethod = "connection_established" -) - -type HealthcheckListResponse struct { - // Identifier - ID string `json:"id"` - // The hostname or IP address of the origin server to run health checks on. - Address string `json:"address"` - // A list of regions from which to run health checks. Null means Cloudflare will - // pick a default region. - CheckRegions []HealthcheckListResponseCheckRegion `json:"check_regions,nullable"` - // The number of consecutive fails required from a health check before changing the - // health to unhealthy. - ConsecutiveFails int64 `json:"consecutive_fails"` - // The number of consecutive successes required from a health check before changing - // the health to healthy. - ConsecutiveSuccesses int64 `json:"consecutive_successes"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A human-readable description of the health check. - Description string `json:"description"` - // The current failure reason if status is unhealthy. - FailureReason string `json:"failure_reason"` - // Parameters specific to an HTTP or HTTPS health check. - HTTPConfig HealthcheckListResponseHTTPConfig `json:"http_config,nullable"` - // The interval between each health check. Shorter intervals may give quicker - // notifications if the origin status changes, but will increase load on the origin - // as we check from multiple locations. - Interval int64 `json:"interval"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A short name to identify the health check. Only alphanumeric characters, hyphens - // and underscores are allowed. - Name string `json:"name"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The current status of the origin server according to the health check. - Status HealthcheckListResponseStatus `json:"status"` - // If suspended, no health checks are sent to the origin. - Suspended bool `json:"suspended"` - // Parameters specific to TCP health check. - TcpConfig HealthcheckListResponseTcpConfig `json:"tcp_config,nullable"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP', 'HTTPS' and 'TCP'. - Type string `json:"type"` - JSON healthcheckListResponseJSON `json:"-"` -} - -// healthcheckListResponseJSON contains the JSON metadata for the struct -// [HealthcheckListResponse] -type healthcheckListResponseJSON struct { - ID apijson.Field - Address apijson.Field - CheckRegions apijson.Field - ConsecutiveFails apijson.Field - ConsecutiveSuccesses apijson.Field - CreatedOn apijson.Field - Description apijson.Field - FailureReason apijson.Field - HTTPConfig apijson.Field - Interval apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Retries apijson.Field - Status apijson.Field - Suspended apijson.Field - TcpConfig apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckListResponseJSON) RawJSON() string { - return r.raw -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, -// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS -// and ENTERPRISE customers only). -type HealthcheckListResponseCheckRegion string - -const ( - HealthcheckListResponseCheckRegionWnam HealthcheckListResponseCheckRegion = "WNAM" - HealthcheckListResponseCheckRegionEnam HealthcheckListResponseCheckRegion = "ENAM" - HealthcheckListResponseCheckRegionWeu HealthcheckListResponseCheckRegion = "WEU" - HealthcheckListResponseCheckRegionEeu HealthcheckListResponseCheckRegion = "EEU" - HealthcheckListResponseCheckRegionNsam HealthcheckListResponseCheckRegion = "NSAM" - HealthcheckListResponseCheckRegionSsam HealthcheckListResponseCheckRegion = "SSAM" - HealthcheckListResponseCheckRegionOc HealthcheckListResponseCheckRegion = "OC" - HealthcheckListResponseCheckRegionMe HealthcheckListResponseCheckRegion = "ME" - HealthcheckListResponseCheckRegionNaf HealthcheckListResponseCheckRegion = "NAF" - HealthcheckListResponseCheckRegionSaf HealthcheckListResponseCheckRegion = "SAF" - HealthcheckListResponseCheckRegionIn HealthcheckListResponseCheckRegion = "IN" - HealthcheckListResponseCheckRegionSeas HealthcheckListResponseCheckRegion = "SEAS" - HealthcheckListResponseCheckRegionNeas HealthcheckListResponseCheckRegion = "NEAS" - HealthcheckListResponseCheckRegionAllRegions HealthcheckListResponseCheckRegion = "ALL_REGIONS" -) - -// Parameters specific to an HTTP or HTTPS health check. -type HealthcheckListResponseHTTPConfig struct { - // Do not validate the certificate when the health check uses HTTPS. - AllowInsecure bool `json:"allow_insecure"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all - // codes starting with 2) of the health check. - ExpectedCodes []string `json:"expected_codes,nullable"` - // Follow redirects if the origin returns a 3xx status code. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. - Header interface{} `json:"header,nullable"` - // The HTTP method to use for the health check. - Method HealthcheckListResponseHTTPConfigMethod `json:"method"` - // The endpoint path to health check against. - Path string `json:"path"` - // Port number to connect to for the health check. Defaults to 80 if type is HTTP - // or 443 if type is HTTPS. - Port int64 `json:"port"` - JSON healthcheckListResponseHTTPConfigJSON `json:"-"` -} - -// healthcheckListResponseHTTPConfigJSON contains the JSON metadata for the struct -// [HealthcheckListResponseHTTPConfig] -type healthcheckListResponseHTTPConfigJSON struct { - AllowInsecure apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Method apijson.Field - Path apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckListResponseHTTPConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckListResponseHTTPConfigJSON) RawJSON() string { - return r.raw -} - -// The HTTP method to use for the health check. -type HealthcheckListResponseHTTPConfigMethod string - -const ( - HealthcheckListResponseHTTPConfigMethodGet HealthcheckListResponseHTTPConfigMethod = "GET" - HealthcheckListResponseHTTPConfigMethodHead HealthcheckListResponseHTTPConfigMethod = "HEAD" -) - -// The current status of the origin server according to the health check. -type HealthcheckListResponseStatus string - -const ( - HealthcheckListResponseStatusUnknown HealthcheckListResponseStatus = "unknown" - HealthcheckListResponseStatusHealthy HealthcheckListResponseStatus = "healthy" - HealthcheckListResponseStatusUnhealthy HealthcheckListResponseStatus = "unhealthy" - HealthcheckListResponseStatusSuspended HealthcheckListResponseStatus = "suspended" -) - -// Parameters specific to TCP health check. -type HealthcheckListResponseTcpConfig struct { - // The TCP connection method to use for the health check. - Method HealthcheckListResponseTcpConfigMethod `json:"method"` - // Port number to connect to for the health check. Defaults to 80. - Port int64 `json:"port"` - JSON healthcheckListResponseTcpConfigJSON `json:"-"` -} - -// healthcheckListResponseTcpConfigJSON contains the JSON metadata for the struct -// [HealthcheckListResponseTcpConfig] -type healthcheckListResponseTcpConfigJSON struct { - Method apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckListResponseTcpConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckListResponseTcpConfigJSON) RawJSON() string { - return r.raw -} - -// The TCP connection method to use for the health check. -type HealthcheckListResponseTcpConfigMethod string - -const ( - HealthcheckListResponseTcpConfigMethodConnectionEstablished HealthcheckListResponseTcpConfigMethod = "connection_established" -) - -type HealthcheckDeleteResponse struct { - // Identifier - ID string `json:"id"` - JSON healthcheckDeleteResponseJSON `json:"-"` -} - -// healthcheckDeleteResponseJSON contains the JSON metadata for the struct -// [HealthcheckDeleteResponse] -type healthcheckDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type HealthcheckEditResponse struct { - // Identifier - ID string `json:"id"` - // The hostname or IP address of the origin server to run health checks on. - Address string `json:"address"` - // A list of regions from which to run health checks. Null means Cloudflare will - // pick a default region. - CheckRegions []HealthcheckEditResponseCheckRegion `json:"check_regions,nullable"` - // The number of consecutive fails required from a health check before changing the - // health to unhealthy. - ConsecutiveFails int64 `json:"consecutive_fails"` - // The number of consecutive successes required from a health check before changing - // the health to healthy. - ConsecutiveSuccesses int64 `json:"consecutive_successes"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A human-readable description of the health check. - Description string `json:"description"` - // The current failure reason if status is unhealthy. - FailureReason string `json:"failure_reason"` - // Parameters specific to an HTTP or HTTPS health check. - HTTPConfig HealthcheckEditResponseHTTPConfig `json:"http_config,nullable"` - // The interval between each health check. Shorter intervals may give quicker - // notifications if the origin status changes, but will increase load on the origin - // as we check from multiple locations. - Interval int64 `json:"interval"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A short name to identify the health check. Only alphanumeric characters, hyphens - // and underscores are allowed. - Name string `json:"name"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The current status of the origin server according to the health check. - Status HealthcheckEditResponseStatus `json:"status"` - // If suspended, no health checks are sent to the origin. - Suspended bool `json:"suspended"` - // Parameters specific to TCP health check. - TcpConfig HealthcheckEditResponseTcpConfig `json:"tcp_config,nullable"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP', 'HTTPS' and 'TCP'. - Type string `json:"type"` - JSON healthcheckEditResponseJSON `json:"-"` -} - -// healthcheckEditResponseJSON contains the JSON metadata for the struct -// [HealthcheckEditResponse] -type healthcheckEditResponseJSON struct { - ID apijson.Field - Address apijson.Field - CheckRegions apijson.Field - ConsecutiveFails apijson.Field - ConsecutiveSuccesses apijson.Field - CreatedOn apijson.Field - Description apijson.Field - FailureReason apijson.Field - HTTPConfig apijson.Field - Interval apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Retries apijson.Field - Status apijson.Field - Suspended apijson.Field - TcpConfig apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckEditResponseJSON) RawJSON() string { - return r.raw -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, -// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS -// and ENTERPRISE customers only). -type HealthcheckEditResponseCheckRegion string - -const ( - HealthcheckEditResponseCheckRegionWnam HealthcheckEditResponseCheckRegion = "WNAM" - HealthcheckEditResponseCheckRegionEnam HealthcheckEditResponseCheckRegion = "ENAM" - HealthcheckEditResponseCheckRegionWeu HealthcheckEditResponseCheckRegion = "WEU" - HealthcheckEditResponseCheckRegionEeu HealthcheckEditResponseCheckRegion = "EEU" - HealthcheckEditResponseCheckRegionNsam HealthcheckEditResponseCheckRegion = "NSAM" - HealthcheckEditResponseCheckRegionSsam HealthcheckEditResponseCheckRegion = "SSAM" - HealthcheckEditResponseCheckRegionOc HealthcheckEditResponseCheckRegion = "OC" - HealthcheckEditResponseCheckRegionMe HealthcheckEditResponseCheckRegion = "ME" - HealthcheckEditResponseCheckRegionNaf HealthcheckEditResponseCheckRegion = "NAF" - HealthcheckEditResponseCheckRegionSaf HealthcheckEditResponseCheckRegion = "SAF" - HealthcheckEditResponseCheckRegionIn HealthcheckEditResponseCheckRegion = "IN" - HealthcheckEditResponseCheckRegionSeas HealthcheckEditResponseCheckRegion = "SEAS" - HealthcheckEditResponseCheckRegionNeas HealthcheckEditResponseCheckRegion = "NEAS" - HealthcheckEditResponseCheckRegionAllRegions HealthcheckEditResponseCheckRegion = "ALL_REGIONS" -) - -// Parameters specific to an HTTP or HTTPS health check. -type HealthcheckEditResponseHTTPConfig struct { - // Do not validate the certificate when the health check uses HTTPS. - AllowInsecure bool `json:"allow_insecure"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all - // codes starting with 2) of the health check. - ExpectedCodes []string `json:"expected_codes,nullable"` - // Follow redirects if the origin returns a 3xx status code. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. - Header interface{} `json:"header,nullable"` - // The HTTP method to use for the health check. - Method HealthcheckEditResponseHTTPConfigMethod `json:"method"` - // The endpoint path to health check against. - Path string `json:"path"` - // Port number to connect to for the health check. Defaults to 80 if type is HTTP - // or 443 if type is HTTPS. - Port int64 `json:"port"` - JSON healthcheckEditResponseHTTPConfigJSON `json:"-"` -} - -// healthcheckEditResponseHTTPConfigJSON contains the JSON metadata for the struct -// [HealthcheckEditResponseHTTPConfig] -type healthcheckEditResponseHTTPConfigJSON struct { - AllowInsecure apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Method apijson.Field - Path apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckEditResponseHTTPConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckEditResponseHTTPConfigJSON) RawJSON() string { - return r.raw -} - -// The HTTP method to use for the health check. -type HealthcheckEditResponseHTTPConfigMethod string - -const ( - HealthcheckEditResponseHTTPConfigMethodGet HealthcheckEditResponseHTTPConfigMethod = "GET" - HealthcheckEditResponseHTTPConfigMethodHead HealthcheckEditResponseHTTPConfigMethod = "HEAD" -) - -// The current status of the origin server according to the health check. -type HealthcheckEditResponseStatus string - -const ( - HealthcheckEditResponseStatusUnknown HealthcheckEditResponseStatus = "unknown" - HealthcheckEditResponseStatusHealthy HealthcheckEditResponseStatus = "healthy" - HealthcheckEditResponseStatusUnhealthy HealthcheckEditResponseStatus = "unhealthy" - HealthcheckEditResponseStatusSuspended HealthcheckEditResponseStatus = "suspended" -) - -// Parameters specific to TCP health check. -type HealthcheckEditResponseTcpConfig struct { - // The TCP connection method to use for the health check. - Method HealthcheckEditResponseTcpConfigMethod `json:"method"` - // Port number to connect to for the health check. Defaults to 80. - Port int64 `json:"port"` - JSON healthcheckEditResponseTcpConfigJSON `json:"-"` -} - -// healthcheckEditResponseTcpConfigJSON contains the JSON metadata for the struct -// [HealthcheckEditResponseTcpConfig] -type healthcheckEditResponseTcpConfigJSON struct { - Method apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckEditResponseTcpConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckEditResponseTcpConfigJSON) RawJSON() string { - return r.raw -} - -// The TCP connection method to use for the health check. -type HealthcheckEditResponseTcpConfigMethod string - -const ( - HealthcheckEditResponseTcpConfigMethodConnectionEstablished HealthcheckEditResponseTcpConfigMethod = "connection_established" -) - -type HealthcheckGetResponse struct { - // Identifier - ID string `json:"id"` - // The hostname or IP address of the origin server to run health checks on. - Address string `json:"address"` - // A list of regions from which to run health checks. Null means Cloudflare will - // pick a default region. - CheckRegions []HealthcheckGetResponseCheckRegion `json:"check_regions,nullable"` - // The number of consecutive fails required from a health check before changing the - // health to unhealthy. - ConsecutiveFails int64 `json:"consecutive_fails"` - // The number of consecutive successes required from a health check before changing - // the health to healthy. - ConsecutiveSuccesses int64 `json:"consecutive_successes"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A human-readable description of the health check. - Description string `json:"description"` - // The current failure reason if status is unhealthy. - FailureReason string `json:"failure_reason"` - // Parameters specific to an HTTP or HTTPS health check. - HTTPConfig HealthcheckGetResponseHTTPConfig `json:"http_config,nullable"` - // The interval between each health check. Shorter intervals may give quicker - // notifications if the origin status changes, but will increase load on the origin - // as we check from multiple locations. - Interval int64 `json:"interval"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A short name to identify the health check. Only alphanumeric characters, hyphens - // and underscores are allowed. - Name string `json:"name"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The current status of the origin server according to the health check. - Status HealthcheckGetResponseStatus `json:"status"` - // If suspended, no health checks are sent to the origin. - Suspended bool `json:"suspended"` - // Parameters specific to TCP health check. - TcpConfig HealthcheckGetResponseTcpConfig `json:"tcp_config,nullable"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP', 'HTTPS' and 'TCP'. - Type string `json:"type"` - JSON healthcheckGetResponseJSON `json:"-"` -} - -// healthcheckGetResponseJSON contains the JSON metadata for the struct -// [HealthcheckGetResponse] -type healthcheckGetResponseJSON struct { - ID apijson.Field - Address apijson.Field - CheckRegions apijson.Field - ConsecutiveFails apijson.Field - ConsecutiveSuccesses apijson.Field - CreatedOn apijson.Field - Description apijson.Field - FailureReason apijson.Field - HTTPConfig apijson.Field - Interval apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Retries apijson.Field - Status apijson.Field - Suspended apijson.Field - TcpConfig apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckGetResponseJSON) RawJSON() string { - return r.raw -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, -// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS -// and ENTERPRISE customers only). -type HealthcheckGetResponseCheckRegion string - -const ( - HealthcheckGetResponseCheckRegionWnam HealthcheckGetResponseCheckRegion = "WNAM" - HealthcheckGetResponseCheckRegionEnam HealthcheckGetResponseCheckRegion = "ENAM" - HealthcheckGetResponseCheckRegionWeu HealthcheckGetResponseCheckRegion = "WEU" - HealthcheckGetResponseCheckRegionEeu HealthcheckGetResponseCheckRegion = "EEU" - HealthcheckGetResponseCheckRegionNsam HealthcheckGetResponseCheckRegion = "NSAM" - HealthcheckGetResponseCheckRegionSsam HealthcheckGetResponseCheckRegion = "SSAM" - HealthcheckGetResponseCheckRegionOc HealthcheckGetResponseCheckRegion = "OC" - HealthcheckGetResponseCheckRegionMe HealthcheckGetResponseCheckRegion = "ME" - HealthcheckGetResponseCheckRegionNaf HealthcheckGetResponseCheckRegion = "NAF" - HealthcheckGetResponseCheckRegionSaf HealthcheckGetResponseCheckRegion = "SAF" - HealthcheckGetResponseCheckRegionIn HealthcheckGetResponseCheckRegion = "IN" - HealthcheckGetResponseCheckRegionSeas HealthcheckGetResponseCheckRegion = "SEAS" - HealthcheckGetResponseCheckRegionNeas HealthcheckGetResponseCheckRegion = "NEAS" - HealthcheckGetResponseCheckRegionAllRegions HealthcheckGetResponseCheckRegion = "ALL_REGIONS" -) - -// Parameters specific to an HTTP or HTTPS health check. -type HealthcheckGetResponseHTTPConfig struct { - // Do not validate the certificate when the health check uses HTTPS. - AllowInsecure bool `json:"allow_insecure"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all - // codes starting with 2) of the health check. - ExpectedCodes []string `json:"expected_codes,nullable"` - // Follow redirects if the origin returns a 3xx status code. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. - Header interface{} `json:"header,nullable"` - // The HTTP method to use for the health check. - Method HealthcheckGetResponseHTTPConfigMethod `json:"method"` - // The endpoint path to health check against. - Path string `json:"path"` - // Port number to connect to for the health check. Defaults to 80 if type is HTTP - // or 443 if type is HTTPS. - Port int64 `json:"port"` - JSON healthcheckGetResponseHTTPConfigJSON `json:"-"` -} - -// healthcheckGetResponseHTTPConfigJSON contains the JSON metadata for the struct -// [HealthcheckGetResponseHTTPConfig] -type healthcheckGetResponseHTTPConfigJSON struct { - AllowInsecure apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Method apijson.Field - Path apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckGetResponseHTTPConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckGetResponseHTTPConfigJSON) RawJSON() string { - return r.raw -} - -// The HTTP method to use for the health check. -type HealthcheckGetResponseHTTPConfigMethod string - -const ( - HealthcheckGetResponseHTTPConfigMethodGet HealthcheckGetResponseHTTPConfigMethod = "GET" - HealthcheckGetResponseHTTPConfigMethodHead HealthcheckGetResponseHTTPConfigMethod = "HEAD" -) - -// The current status of the origin server according to the health check. -type HealthcheckGetResponseStatus string - -const ( - HealthcheckGetResponseStatusUnknown HealthcheckGetResponseStatus = "unknown" - HealthcheckGetResponseStatusHealthy HealthcheckGetResponseStatus = "healthy" - HealthcheckGetResponseStatusUnhealthy HealthcheckGetResponseStatus = "unhealthy" - HealthcheckGetResponseStatusSuspended HealthcheckGetResponseStatus = "suspended" -) - -// Parameters specific to TCP health check. -type HealthcheckGetResponseTcpConfig struct { - // The TCP connection method to use for the health check. - Method HealthcheckGetResponseTcpConfigMethod `json:"method"` - // Port number to connect to for the health check. Defaults to 80. - Port int64 `json:"port"` - JSON healthcheckGetResponseTcpConfigJSON `json:"-"` -} - -// healthcheckGetResponseTcpConfigJSON contains the JSON metadata for the struct -// [HealthcheckGetResponseTcpConfig] -type healthcheckGetResponseTcpConfigJSON struct { - Method apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckGetResponseTcpConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckGetResponseTcpConfigJSON) RawJSON() string { - return r.raw -} - -// The TCP connection method to use for the health check. -type HealthcheckGetResponseTcpConfigMethod string - -const ( - HealthcheckGetResponseTcpConfigMethodConnectionEstablished HealthcheckGetResponseTcpConfigMethod = "connection_established" -) - -type HealthcheckNewParams struct { - // The hostname or IP address of the origin server to run health checks on. - Address param.Field[string] `json:"address,required"` - // A short name to identify the health check. Only alphanumeric characters, hyphens - // and underscores are allowed. - Name param.Field[string] `json:"name,required"` - // A list of regions from which to run health checks. Null means Cloudflare will - // pick a default region. - CheckRegions param.Field[[]HealthcheckNewParamsCheckRegion] `json:"check_regions"` - // The number of consecutive fails required from a health check before changing the - // health to unhealthy. - ConsecutiveFails param.Field[int64] `json:"consecutive_fails"` - // The number of consecutive successes required from a health check before changing - // the health to healthy. - ConsecutiveSuccesses param.Field[int64] `json:"consecutive_successes"` - // A human-readable description of the health check. - Description param.Field[string] `json:"description"` - // Parameters specific to an HTTP or HTTPS health check. - HTTPConfig param.Field[HealthcheckNewParamsHTTPConfig] `json:"http_config"` - // The interval between each health check. Shorter intervals may give quicker - // notifications if the origin status changes, but will increase load on the origin - // as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // If suspended, no health checks are sent to the origin. - Suspended param.Field[bool] `json:"suspended"` - // Parameters specific to TCP health check. - TcpConfig param.Field[HealthcheckNewParamsTcpConfig] `json:"tcp_config"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP', 'HTTPS' and 'TCP'. - Type param.Field[string] `json:"type"` -} - -func (r HealthcheckNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, -// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS -// and ENTERPRISE customers only). -type HealthcheckNewParamsCheckRegion string - -const ( - HealthcheckNewParamsCheckRegionWnam HealthcheckNewParamsCheckRegion = "WNAM" - HealthcheckNewParamsCheckRegionEnam HealthcheckNewParamsCheckRegion = "ENAM" - HealthcheckNewParamsCheckRegionWeu HealthcheckNewParamsCheckRegion = "WEU" - HealthcheckNewParamsCheckRegionEeu HealthcheckNewParamsCheckRegion = "EEU" - HealthcheckNewParamsCheckRegionNsam HealthcheckNewParamsCheckRegion = "NSAM" - HealthcheckNewParamsCheckRegionSsam HealthcheckNewParamsCheckRegion = "SSAM" - HealthcheckNewParamsCheckRegionOc HealthcheckNewParamsCheckRegion = "OC" - HealthcheckNewParamsCheckRegionMe HealthcheckNewParamsCheckRegion = "ME" - HealthcheckNewParamsCheckRegionNaf HealthcheckNewParamsCheckRegion = "NAF" - HealthcheckNewParamsCheckRegionSaf HealthcheckNewParamsCheckRegion = "SAF" - HealthcheckNewParamsCheckRegionIn HealthcheckNewParamsCheckRegion = "IN" - HealthcheckNewParamsCheckRegionSeas HealthcheckNewParamsCheckRegion = "SEAS" - HealthcheckNewParamsCheckRegionNeas HealthcheckNewParamsCheckRegion = "NEAS" - HealthcheckNewParamsCheckRegionAllRegions HealthcheckNewParamsCheckRegion = "ALL_REGIONS" -) - -// Parameters specific to an HTTP or HTTPS health check. -type HealthcheckNewParamsHTTPConfig struct { - // Do not validate the certificate when the health check uses HTTPS. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. - ExpectedBody param.Field[string] `json:"expected_body"` - // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all - // codes starting with 2) of the health check. - ExpectedCodes param.Field[[]string] `json:"expected_codes"` - // Follow redirects if the origin returns a 3xx status code. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. - Header param.Field[interface{}] `json:"header"` - // The HTTP method to use for the health check. - Method param.Field[HealthcheckNewParamsHTTPConfigMethod] `json:"method"` - // The endpoint path to health check against. - Path param.Field[string] `json:"path"` - // Port number to connect to for the health check. Defaults to 80 if type is HTTP - // or 443 if type is HTTPS. - Port param.Field[int64] `json:"port"` -} - -func (r HealthcheckNewParamsHTTPConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The HTTP method to use for the health check. -type HealthcheckNewParamsHTTPConfigMethod string - -const ( - HealthcheckNewParamsHTTPConfigMethodGet HealthcheckNewParamsHTTPConfigMethod = "GET" - HealthcheckNewParamsHTTPConfigMethodHead HealthcheckNewParamsHTTPConfigMethod = "HEAD" -) - -// Parameters specific to TCP health check. -type HealthcheckNewParamsTcpConfig struct { - // The TCP connection method to use for the health check. - Method param.Field[HealthcheckNewParamsTcpConfigMethod] `json:"method"` - // Port number to connect to for the health check. Defaults to 80. - Port param.Field[int64] `json:"port"` -} - -func (r HealthcheckNewParamsTcpConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The TCP connection method to use for the health check. -type HealthcheckNewParamsTcpConfigMethod string - -const ( - HealthcheckNewParamsTcpConfigMethodConnectionEstablished HealthcheckNewParamsTcpConfigMethod = "connection_established" -) - -type HealthcheckNewResponseEnvelope struct { - Errors []HealthcheckNewResponseEnvelopeErrors `json:"errors,required"` - Messages []HealthcheckNewResponseEnvelopeMessages `json:"messages,required"` - Result HealthcheckNewResponse `json:"result,required"` - // Whether the API call was successful - Success HealthcheckNewResponseEnvelopeSuccess `json:"success,required"` - JSON healthcheckNewResponseEnvelopeJSON `json:"-"` -} - -// healthcheckNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [HealthcheckNewResponseEnvelope] -type healthcheckNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HealthcheckNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// healthcheckNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [HealthcheckNewResponseEnvelopeErrors] -type healthcheckNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HealthcheckNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// healthcheckNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [HealthcheckNewResponseEnvelopeMessages] -type healthcheckNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HealthcheckNewResponseEnvelopeSuccess bool - -const ( - HealthcheckNewResponseEnvelopeSuccessTrue HealthcheckNewResponseEnvelopeSuccess = true -) - -type HealthcheckUpdateParams struct { - // The hostname or IP address of the origin server to run health checks on. - Address param.Field[string] `json:"address,required"` - // A short name to identify the health check. Only alphanumeric characters, hyphens - // and underscores are allowed. - Name param.Field[string] `json:"name,required"` - // A list of regions from which to run health checks. Null means Cloudflare will - // pick a default region. - CheckRegions param.Field[[]HealthcheckUpdateParamsCheckRegion] `json:"check_regions"` - // The number of consecutive fails required from a health check before changing the - // health to unhealthy. - ConsecutiveFails param.Field[int64] `json:"consecutive_fails"` - // The number of consecutive successes required from a health check before changing - // the health to healthy. - ConsecutiveSuccesses param.Field[int64] `json:"consecutive_successes"` - // A human-readable description of the health check. - Description param.Field[string] `json:"description"` - // Parameters specific to an HTTP or HTTPS health check. - HTTPConfig param.Field[HealthcheckUpdateParamsHTTPConfig] `json:"http_config"` - // The interval between each health check. Shorter intervals may give quicker - // notifications if the origin status changes, but will increase load on the origin - // as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // If suspended, no health checks are sent to the origin. - Suspended param.Field[bool] `json:"suspended"` - // Parameters specific to TCP health check. - TcpConfig param.Field[HealthcheckUpdateParamsTcpConfig] `json:"tcp_config"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP', 'HTTPS' and 'TCP'. - Type param.Field[string] `json:"type"` -} - -func (r HealthcheckUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, -// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS -// and ENTERPRISE customers only). -type HealthcheckUpdateParamsCheckRegion string - -const ( - HealthcheckUpdateParamsCheckRegionWnam HealthcheckUpdateParamsCheckRegion = "WNAM" - HealthcheckUpdateParamsCheckRegionEnam HealthcheckUpdateParamsCheckRegion = "ENAM" - HealthcheckUpdateParamsCheckRegionWeu HealthcheckUpdateParamsCheckRegion = "WEU" - HealthcheckUpdateParamsCheckRegionEeu HealthcheckUpdateParamsCheckRegion = "EEU" - HealthcheckUpdateParamsCheckRegionNsam HealthcheckUpdateParamsCheckRegion = "NSAM" - HealthcheckUpdateParamsCheckRegionSsam HealthcheckUpdateParamsCheckRegion = "SSAM" - HealthcheckUpdateParamsCheckRegionOc HealthcheckUpdateParamsCheckRegion = "OC" - HealthcheckUpdateParamsCheckRegionMe HealthcheckUpdateParamsCheckRegion = "ME" - HealthcheckUpdateParamsCheckRegionNaf HealthcheckUpdateParamsCheckRegion = "NAF" - HealthcheckUpdateParamsCheckRegionSaf HealthcheckUpdateParamsCheckRegion = "SAF" - HealthcheckUpdateParamsCheckRegionIn HealthcheckUpdateParamsCheckRegion = "IN" - HealthcheckUpdateParamsCheckRegionSeas HealthcheckUpdateParamsCheckRegion = "SEAS" - HealthcheckUpdateParamsCheckRegionNeas HealthcheckUpdateParamsCheckRegion = "NEAS" - HealthcheckUpdateParamsCheckRegionAllRegions HealthcheckUpdateParamsCheckRegion = "ALL_REGIONS" -) - -// Parameters specific to an HTTP or HTTPS health check. -type HealthcheckUpdateParamsHTTPConfig struct { - // Do not validate the certificate when the health check uses HTTPS. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. - ExpectedBody param.Field[string] `json:"expected_body"` - // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all - // codes starting with 2) of the health check. - ExpectedCodes param.Field[[]string] `json:"expected_codes"` - // Follow redirects if the origin returns a 3xx status code. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. - Header param.Field[interface{}] `json:"header"` - // The HTTP method to use for the health check. - Method param.Field[HealthcheckUpdateParamsHTTPConfigMethod] `json:"method"` - // The endpoint path to health check against. - Path param.Field[string] `json:"path"` - // Port number to connect to for the health check. Defaults to 80 if type is HTTP - // or 443 if type is HTTPS. - Port param.Field[int64] `json:"port"` -} - -func (r HealthcheckUpdateParamsHTTPConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The HTTP method to use for the health check. -type HealthcheckUpdateParamsHTTPConfigMethod string - -const ( - HealthcheckUpdateParamsHTTPConfigMethodGet HealthcheckUpdateParamsHTTPConfigMethod = "GET" - HealthcheckUpdateParamsHTTPConfigMethodHead HealthcheckUpdateParamsHTTPConfigMethod = "HEAD" -) - -// Parameters specific to TCP health check. -type HealthcheckUpdateParamsTcpConfig struct { - // The TCP connection method to use for the health check. - Method param.Field[HealthcheckUpdateParamsTcpConfigMethod] `json:"method"` - // Port number to connect to for the health check. Defaults to 80. - Port param.Field[int64] `json:"port"` -} - -func (r HealthcheckUpdateParamsTcpConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The TCP connection method to use for the health check. -type HealthcheckUpdateParamsTcpConfigMethod string - -const ( - HealthcheckUpdateParamsTcpConfigMethodConnectionEstablished HealthcheckUpdateParamsTcpConfigMethod = "connection_established" -) - -type HealthcheckUpdateResponseEnvelope struct { - Errors []HealthcheckUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []HealthcheckUpdateResponseEnvelopeMessages `json:"messages,required"` - Result HealthcheckUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success HealthcheckUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON healthcheckUpdateResponseEnvelopeJSON `json:"-"` -} - -// healthcheckUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [HealthcheckUpdateResponseEnvelope] -type healthcheckUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HealthcheckUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// healthcheckUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [HealthcheckUpdateResponseEnvelopeErrors] -type healthcheckUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HealthcheckUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// healthcheckUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [HealthcheckUpdateResponseEnvelopeMessages] -type healthcheckUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HealthcheckUpdateResponseEnvelopeSuccess bool - -const ( - HealthcheckUpdateResponseEnvelopeSuccessTrue HealthcheckUpdateResponseEnvelopeSuccess = true -) - -type HealthcheckListResponseEnvelope struct { - Errors []HealthcheckListResponseEnvelopeErrors `json:"errors,required"` - Messages []HealthcheckListResponseEnvelopeMessages `json:"messages,required"` - Result []HealthcheckListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success HealthcheckListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo HealthcheckListResponseEnvelopeResultInfo `json:"result_info"` - JSON healthcheckListResponseEnvelopeJSON `json:"-"` -} - -// healthcheckListResponseEnvelopeJSON contains the JSON metadata for the struct -// [HealthcheckListResponseEnvelope] -type healthcheckListResponseEnvelopeJSON 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 *HealthcheckListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HealthcheckListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckListResponseEnvelopeErrorsJSON `json:"-"` -} - -// healthcheckListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [HealthcheckListResponseEnvelopeErrors] -type healthcheckListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HealthcheckListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckListResponseEnvelopeMessagesJSON `json:"-"` -} - -// healthcheckListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [HealthcheckListResponseEnvelopeMessages] -type healthcheckListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HealthcheckListResponseEnvelopeSuccess bool - -const ( - HealthcheckListResponseEnvelopeSuccessTrue HealthcheckListResponseEnvelopeSuccess = true -) - -type HealthcheckListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON healthcheckListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// healthcheckListResponseEnvelopeResultInfoJSON contains the JSON metadata for the -// struct [HealthcheckListResponseEnvelopeResultInfo] -type healthcheckListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type HealthcheckDeleteResponseEnvelope struct { - Errors []HealthcheckDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []HealthcheckDeleteResponseEnvelopeMessages `json:"messages,required"` - Result HealthcheckDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success HealthcheckDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON healthcheckDeleteResponseEnvelopeJSON `json:"-"` -} - -// healthcheckDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [HealthcheckDeleteResponseEnvelope] -type healthcheckDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HealthcheckDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// healthcheckDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [HealthcheckDeleteResponseEnvelopeErrors] -type healthcheckDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HealthcheckDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// healthcheckDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [HealthcheckDeleteResponseEnvelopeMessages] -type healthcheckDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HealthcheckDeleteResponseEnvelopeSuccess bool - -const ( - HealthcheckDeleteResponseEnvelopeSuccessTrue HealthcheckDeleteResponseEnvelopeSuccess = true -) - -type HealthcheckEditParams struct { - // The hostname or IP address of the origin server to run health checks on. - Address param.Field[string] `json:"address,required"` - // A short name to identify the health check. Only alphanumeric characters, hyphens - // and underscores are allowed. - Name param.Field[string] `json:"name,required"` - // A list of regions from which to run health checks. Null means Cloudflare will - // pick a default region. - CheckRegions param.Field[[]HealthcheckEditParamsCheckRegion] `json:"check_regions"` - // The number of consecutive fails required from a health check before changing the - // health to unhealthy. - ConsecutiveFails param.Field[int64] `json:"consecutive_fails"` - // The number of consecutive successes required from a health check before changing - // the health to healthy. - ConsecutiveSuccesses param.Field[int64] `json:"consecutive_successes"` - // A human-readable description of the health check. - Description param.Field[string] `json:"description"` - // Parameters specific to an HTTP or HTTPS health check. - HTTPConfig param.Field[HealthcheckEditParamsHTTPConfig] `json:"http_config"` - // The interval between each health check. Shorter intervals may give quicker - // notifications if the origin status changes, but will increase load on the origin - // as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // If suspended, no health checks are sent to the origin. - Suspended param.Field[bool] `json:"suspended"` - // Parameters specific to TCP health check. - TcpConfig param.Field[HealthcheckEditParamsTcpConfig] `json:"tcp_config"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP', 'HTTPS' and 'TCP'. - Type param.Field[string] `json:"type"` -} - -func (r HealthcheckEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, -// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS -// and ENTERPRISE customers only). -type HealthcheckEditParamsCheckRegion string - -const ( - HealthcheckEditParamsCheckRegionWnam HealthcheckEditParamsCheckRegion = "WNAM" - HealthcheckEditParamsCheckRegionEnam HealthcheckEditParamsCheckRegion = "ENAM" - HealthcheckEditParamsCheckRegionWeu HealthcheckEditParamsCheckRegion = "WEU" - HealthcheckEditParamsCheckRegionEeu HealthcheckEditParamsCheckRegion = "EEU" - HealthcheckEditParamsCheckRegionNsam HealthcheckEditParamsCheckRegion = "NSAM" - HealthcheckEditParamsCheckRegionSsam HealthcheckEditParamsCheckRegion = "SSAM" - HealthcheckEditParamsCheckRegionOc HealthcheckEditParamsCheckRegion = "OC" - HealthcheckEditParamsCheckRegionMe HealthcheckEditParamsCheckRegion = "ME" - HealthcheckEditParamsCheckRegionNaf HealthcheckEditParamsCheckRegion = "NAF" - HealthcheckEditParamsCheckRegionSaf HealthcheckEditParamsCheckRegion = "SAF" - HealthcheckEditParamsCheckRegionIn HealthcheckEditParamsCheckRegion = "IN" - HealthcheckEditParamsCheckRegionSeas HealthcheckEditParamsCheckRegion = "SEAS" - HealthcheckEditParamsCheckRegionNeas HealthcheckEditParamsCheckRegion = "NEAS" - HealthcheckEditParamsCheckRegionAllRegions HealthcheckEditParamsCheckRegion = "ALL_REGIONS" -) - -// Parameters specific to an HTTP or HTTPS health check. -type HealthcheckEditParamsHTTPConfig struct { - // Do not validate the certificate when the health check uses HTTPS. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. - ExpectedBody param.Field[string] `json:"expected_body"` - // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all - // codes starting with 2) of the health check. - ExpectedCodes param.Field[[]string] `json:"expected_codes"` - // Follow redirects if the origin returns a 3xx status code. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. - Header param.Field[interface{}] `json:"header"` - // The HTTP method to use for the health check. - Method param.Field[HealthcheckEditParamsHTTPConfigMethod] `json:"method"` - // The endpoint path to health check against. - Path param.Field[string] `json:"path"` - // Port number to connect to for the health check. Defaults to 80 if type is HTTP - // or 443 if type is HTTPS. - Port param.Field[int64] `json:"port"` -} - -func (r HealthcheckEditParamsHTTPConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The HTTP method to use for the health check. -type HealthcheckEditParamsHTTPConfigMethod string - -const ( - HealthcheckEditParamsHTTPConfigMethodGet HealthcheckEditParamsHTTPConfigMethod = "GET" - HealthcheckEditParamsHTTPConfigMethodHead HealthcheckEditParamsHTTPConfigMethod = "HEAD" -) - -// Parameters specific to TCP health check. -type HealthcheckEditParamsTcpConfig struct { - // The TCP connection method to use for the health check. - Method param.Field[HealthcheckEditParamsTcpConfigMethod] `json:"method"` - // Port number to connect to for the health check. Defaults to 80. - Port param.Field[int64] `json:"port"` -} - -func (r HealthcheckEditParamsTcpConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The TCP connection method to use for the health check. -type HealthcheckEditParamsTcpConfigMethod string - -const ( - HealthcheckEditParamsTcpConfigMethodConnectionEstablished HealthcheckEditParamsTcpConfigMethod = "connection_established" -) - -type HealthcheckEditResponseEnvelope struct { - Errors []HealthcheckEditResponseEnvelopeErrors `json:"errors,required"` - Messages []HealthcheckEditResponseEnvelopeMessages `json:"messages,required"` - Result HealthcheckEditResponse `json:"result,required"` - // Whether the API call was successful - Success HealthcheckEditResponseEnvelopeSuccess `json:"success,required"` - JSON healthcheckEditResponseEnvelopeJSON `json:"-"` -} - -// healthcheckEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [HealthcheckEditResponseEnvelope] -type healthcheckEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HealthcheckEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// healthcheckEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [HealthcheckEditResponseEnvelopeErrors] -type healthcheckEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HealthcheckEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// healthcheckEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [HealthcheckEditResponseEnvelopeMessages] -type healthcheckEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HealthcheckEditResponseEnvelopeSuccess bool - -const ( - HealthcheckEditResponseEnvelopeSuccessTrue HealthcheckEditResponseEnvelopeSuccess = true -) - -type HealthcheckGetResponseEnvelope struct { - Errors []HealthcheckGetResponseEnvelopeErrors `json:"errors,required"` - Messages []HealthcheckGetResponseEnvelopeMessages `json:"messages,required"` - Result HealthcheckGetResponse `json:"result,required"` - // Whether the API call was successful - Success HealthcheckGetResponseEnvelopeSuccess `json:"success,required"` - JSON healthcheckGetResponseEnvelopeJSON `json:"-"` -} - -// healthcheckGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [HealthcheckGetResponseEnvelope] -type healthcheckGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HealthcheckGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// healthcheckGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [HealthcheckGetResponseEnvelopeErrors] -type healthcheckGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HealthcheckGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// healthcheckGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [HealthcheckGetResponseEnvelopeMessages] -type healthcheckGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HealthcheckGetResponseEnvelopeSuccess bool - -const ( - HealthcheckGetResponseEnvelopeSuccessTrue HealthcheckGetResponseEnvelopeSuccess = true -) diff --git a/healthcheckpreview.go b/healthcheckpreview.go deleted file mode 100644 index fcdbaf4766b..00000000000 --- a/healthcheckpreview.go +++ /dev/null @@ -1,861 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// HealthcheckPreviewService 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 [NewHealthcheckPreviewService] method -// instead. -type HealthcheckPreviewService struct { - Options []option.RequestOption -} - -// NewHealthcheckPreviewService 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 NewHealthcheckPreviewService(opts ...option.RequestOption) (r *HealthcheckPreviewService) { - r = &HealthcheckPreviewService{} - r.Options = opts - return -} - -// Create a new preview health check. -func (r *HealthcheckPreviewService) New(ctx context.Context, zoneIdentifier string, body HealthcheckPreviewNewParams, opts ...option.RequestOption) (res *HealthcheckPreviewNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env HealthcheckPreviewNewResponseEnvelope - path := fmt.Sprintf("zones/%s/healthchecks/preview", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a health check. -func (r *HealthcheckPreviewService) Delete(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *HealthcheckPreviewDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env HealthcheckPreviewDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/healthchecks/preview/%s", zoneIdentifier, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch a single configured health check preview. -func (r *HealthcheckPreviewService) Get(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *HealthcheckPreviewGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env HealthcheckPreviewGetResponseEnvelope - path := fmt.Sprintf("zones/%s/healthchecks/preview/%s", zoneIdentifier, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type HealthcheckPreviewNewResponse struct { - // Identifier - ID string `json:"id"` - // The hostname or IP address of the origin server to run health checks on. - Address string `json:"address"` - // A list of regions from which to run health checks. Null means Cloudflare will - // pick a default region. - CheckRegions []HealthcheckPreviewNewResponseCheckRegion `json:"check_regions,nullable"` - // The number of consecutive fails required from a health check before changing the - // health to unhealthy. - ConsecutiveFails int64 `json:"consecutive_fails"` - // The number of consecutive successes required from a health check before changing - // the health to healthy. - ConsecutiveSuccesses int64 `json:"consecutive_successes"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A human-readable description of the health check. - Description string `json:"description"` - // The current failure reason if status is unhealthy. - FailureReason string `json:"failure_reason"` - // Parameters specific to an HTTP or HTTPS health check. - HTTPConfig HealthcheckPreviewNewResponseHTTPConfig `json:"http_config,nullable"` - // The interval between each health check. Shorter intervals may give quicker - // notifications if the origin status changes, but will increase load on the origin - // as we check from multiple locations. - Interval int64 `json:"interval"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A short name to identify the health check. Only alphanumeric characters, hyphens - // and underscores are allowed. - Name string `json:"name"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The current status of the origin server according to the health check. - Status HealthcheckPreviewNewResponseStatus `json:"status"` - // If suspended, no health checks are sent to the origin. - Suspended bool `json:"suspended"` - // Parameters specific to TCP health check. - TcpConfig HealthcheckPreviewNewResponseTcpConfig `json:"tcp_config,nullable"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP', 'HTTPS' and 'TCP'. - Type string `json:"type"` - JSON healthcheckPreviewNewResponseJSON `json:"-"` -} - -// healthcheckPreviewNewResponseJSON contains the JSON metadata for the struct -// [HealthcheckPreviewNewResponse] -type healthcheckPreviewNewResponseJSON struct { - ID apijson.Field - Address apijson.Field - CheckRegions apijson.Field - ConsecutiveFails apijson.Field - ConsecutiveSuccesses apijson.Field - CreatedOn apijson.Field - Description apijson.Field - FailureReason apijson.Field - HTTPConfig apijson.Field - Interval apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Retries apijson.Field - Status apijson.Field - Suspended apijson.Field - TcpConfig apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckPreviewNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckPreviewNewResponseJSON) RawJSON() string { - return r.raw -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, -// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS -// and ENTERPRISE customers only). -type HealthcheckPreviewNewResponseCheckRegion string - -const ( - HealthcheckPreviewNewResponseCheckRegionWnam HealthcheckPreviewNewResponseCheckRegion = "WNAM" - HealthcheckPreviewNewResponseCheckRegionEnam HealthcheckPreviewNewResponseCheckRegion = "ENAM" - HealthcheckPreviewNewResponseCheckRegionWeu HealthcheckPreviewNewResponseCheckRegion = "WEU" - HealthcheckPreviewNewResponseCheckRegionEeu HealthcheckPreviewNewResponseCheckRegion = "EEU" - HealthcheckPreviewNewResponseCheckRegionNsam HealthcheckPreviewNewResponseCheckRegion = "NSAM" - HealthcheckPreviewNewResponseCheckRegionSsam HealthcheckPreviewNewResponseCheckRegion = "SSAM" - HealthcheckPreviewNewResponseCheckRegionOc HealthcheckPreviewNewResponseCheckRegion = "OC" - HealthcheckPreviewNewResponseCheckRegionMe HealthcheckPreviewNewResponseCheckRegion = "ME" - HealthcheckPreviewNewResponseCheckRegionNaf HealthcheckPreviewNewResponseCheckRegion = "NAF" - HealthcheckPreviewNewResponseCheckRegionSaf HealthcheckPreviewNewResponseCheckRegion = "SAF" - HealthcheckPreviewNewResponseCheckRegionIn HealthcheckPreviewNewResponseCheckRegion = "IN" - HealthcheckPreviewNewResponseCheckRegionSeas HealthcheckPreviewNewResponseCheckRegion = "SEAS" - HealthcheckPreviewNewResponseCheckRegionNeas HealthcheckPreviewNewResponseCheckRegion = "NEAS" - HealthcheckPreviewNewResponseCheckRegionAllRegions HealthcheckPreviewNewResponseCheckRegion = "ALL_REGIONS" -) - -// Parameters specific to an HTTP or HTTPS health check. -type HealthcheckPreviewNewResponseHTTPConfig struct { - // Do not validate the certificate when the health check uses HTTPS. - AllowInsecure bool `json:"allow_insecure"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all - // codes starting with 2) of the health check. - ExpectedCodes []string `json:"expected_codes,nullable"` - // Follow redirects if the origin returns a 3xx status code. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. - Header interface{} `json:"header,nullable"` - // The HTTP method to use for the health check. - Method HealthcheckPreviewNewResponseHTTPConfigMethod `json:"method"` - // The endpoint path to health check against. - Path string `json:"path"` - // Port number to connect to for the health check. Defaults to 80 if type is HTTP - // or 443 if type is HTTPS. - Port int64 `json:"port"` - JSON healthcheckPreviewNewResponseHTTPConfigJSON `json:"-"` -} - -// healthcheckPreviewNewResponseHTTPConfigJSON contains the JSON metadata for the -// struct [HealthcheckPreviewNewResponseHTTPConfig] -type healthcheckPreviewNewResponseHTTPConfigJSON struct { - AllowInsecure apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Method apijson.Field - Path apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckPreviewNewResponseHTTPConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckPreviewNewResponseHTTPConfigJSON) RawJSON() string { - return r.raw -} - -// The HTTP method to use for the health check. -type HealthcheckPreviewNewResponseHTTPConfigMethod string - -const ( - HealthcheckPreviewNewResponseHTTPConfigMethodGet HealthcheckPreviewNewResponseHTTPConfigMethod = "GET" - HealthcheckPreviewNewResponseHTTPConfigMethodHead HealthcheckPreviewNewResponseHTTPConfigMethod = "HEAD" -) - -// The current status of the origin server according to the health check. -type HealthcheckPreviewNewResponseStatus string - -const ( - HealthcheckPreviewNewResponseStatusUnknown HealthcheckPreviewNewResponseStatus = "unknown" - HealthcheckPreviewNewResponseStatusHealthy HealthcheckPreviewNewResponseStatus = "healthy" - HealthcheckPreviewNewResponseStatusUnhealthy HealthcheckPreviewNewResponseStatus = "unhealthy" - HealthcheckPreviewNewResponseStatusSuspended HealthcheckPreviewNewResponseStatus = "suspended" -) - -// Parameters specific to TCP health check. -type HealthcheckPreviewNewResponseTcpConfig struct { - // The TCP connection method to use for the health check. - Method HealthcheckPreviewNewResponseTcpConfigMethod `json:"method"` - // Port number to connect to for the health check. Defaults to 80. - Port int64 `json:"port"` - JSON healthcheckPreviewNewResponseTcpConfigJSON `json:"-"` -} - -// healthcheckPreviewNewResponseTcpConfigJSON contains the JSON metadata for the -// struct [HealthcheckPreviewNewResponseTcpConfig] -type healthcheckPreviewNewResponseTcpConfigJSON struct { - Method apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckPreviewNewResponseTcpConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckPreviewNewResponseTcpConfigJSON) RawJSON() string { - return r.raw -} - -// The TCP connection method to use for the health check. -type HealthcheckPreviewNewResponseTcpConfigMethod string - -const ( - HealthcheckPreviewNewResponseTcpConfigMethodConnectionEstablished HealthcheckPreviewNewResponseTcpConfigMethod = "connection_established" -) - -type HealthcheckPreviewDeleteResponse struct { - // Identifier - ID string `json:"id"` - JSON healthcheckPreviewDeleteResponseJSON `json:"-"` -} - -// healthcheckPreviewDeleteResponseJSON contains the JSON metadata for the struct -// [HealthcheckPreviewDeleteResponse] -type healthcheckPreviewDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckPreviewDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckPreviewDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type HealthcheckPreviewGetResponse struct { - // Identifier - ID string `json:"id"` - // The hostname or IP address of the origin server to run health checks on. - Address string `json:"address"` - // A list of regions from which to run health checks. Null means Cloudflare will - // pick a default region. - CheckRegions []HealthcheckPreviewGetResponseCheckRegion `json:"check_regions,nullable"` - // The number of consecutive fails required from a health check before changing the - // health to unhealthy. - ConsecutiveFails int64 `json:"consecutive_fails"` - // The number of consecutive successes required from a health check before changing - // the health to healthy. - ConsecutiveSuccesses int64 `json:"consecutive_successes"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A human-readable description of the health check. - Description string `json:"description"` - // The current failure reason if status is unhealthy. - FailureReason string `json:"failure_reason"` - // Parameters specific to an HTTP or HTTPS health check. - HTTPConfig HealthcheckPreviewGetResponseHTTPConfig `json:"http_config,nullable"` - // The interval between each health check. Shorter intervals may give quicker - // notifications if the origin status changes, but will increase load on the origin - // as we check from multiple locations. - Interval int64 `json:"interval"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A short name to identify the health check. Only alphanumeric characters, hyphens - // and underscores are allowed. - Name string `json:"name"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The current status of the origin server according to the health check. - Status HealthcheckPreviewGetResponseStatus `json:"status"` - // If suspended, no health checks are sent to the origin. - Suspended bool `json:"suspended"` - // Parameters specific to TCP health check. - TcpConfig HealthcheckPreviewGetResponseTcpConfig `json:"tcp_config,nullable"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP', 'HTTPS' and 'TCP'. - Type string `json:"type"` - JSON healthcheckPreviewGetResponseJSON `json:"-"` -} - -// healthcheckPreviewGetResponseJSON contains the JSON metadata for the struct -// [HealthcheckPreviewGetResponse] -type healthcheckPreviewGetResponseJSON struct { - ID apijson.Field - Address apijson.Field - CheckRegions apijson.Field - ConsecutiveFails apijson.Field - ConsecutiveSuccesses apijson.Field - CreatedOn apijson.Field - Description apijson.Field - FailureReason apijson.Field - HTTPConfig apijson.Field - Interval apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Retries apijson.Field - Status apijson.Field - Suspended apijson.Field - TcpConfig apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckPreviewGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckPreviewGetResponseJSON) RawJSON() string { - return r.raw -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, -// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS -// and ENTERPRISE customers only). -type HealthcheckPreviewGetResponseCheckRegion string - -const ( - HealthcheckPreviewGetResponseCheckRegionWnam HealthcheckPreviewGetResponseCheckRegion = "WNAM" - HealthcheckPreviewGetResponseCheckRegionEnam HealthcheckPreviewGetResponseCheckRegion = "ENAM" - HealthcheckPreviewGetResponseCheckRegionWeu HealthcheckPreviewGetResponseCheckRegion = "WEU" - HealthcheckPreviewGetResponseCheckRegionEeu HealthcheckPreviewGetResponseCheckRegion = "EEU" - HealthcheckPreviewGetResponseCheckRegionNsam HealthcheckPreviewGetResponseCheckRegion = "NSAM" - HealthcheckPreviewGetResponseCheckRegionSsam HealthcheckPreviewGetResponseCheckRegion = "SSAM" - HealthcheckPreviewGetResponseCheckRegionOc HealthcheckPreviewGetResponseCheckRegion = "OC" - HealthcheckPreviewGetResponseCheckRegionMe HealthcheckPreviewGetResponseCheckRegion = "ME" - HealthcheckPreviewGetResponseCheckRegionNaf HealthcheckPreviewGetResponseCheckRegion = "NAF" - HealthcheckPreviewGetResponseCheckRegionSaf HealthcheckPreviewGetResponseCheckRegion = "SAF" - HealthcheckPreviewGetResponseCheckRegionIn HealthcheckPreviewGetResponseCheckRegion = "IN" - HealthcheckPreviewGetResponseCheckRegionSeas HealthcheckPreviewGetResponseCheckRegion = "SEAS" - HealthcheckPreviewGetResponseCheckRegionNeas HealthcheckPreviewGetResponseCheckRegion = "NEAS" - HealthcheckPreviewGetResponseCheckRegionAllRegions HealthcheckPreviewGetResponseCheckRegion = "ALL_REGIONS" -) - -// Parameters specific to an HTTP or HTTPS health check. -type HealthcheckPreviewGetResponseHTTPConfig struct { - // Do not validate the certificate when the health check uses HTTPS. - AllowInsecure bool `json:"allow_insecure"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all - // codes starting with 2) of the health check. - ExpectedCodes []string `json:"expected_codes,nullable"` - // Follow redirects if the origin returns a 3xx status code. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. - Header interface{} `json:"header,nullable"` - // The HTTP method to use for the health check. - Method HealthcheckPreviewGetResponseHTTPConfigMethod `json:"method"` - // The endpoint path to health check against. - Path string `json:"path"` - // Port number to connect to for the health check. Defaults to 80 if type is HTTP - // or 443 if type is HTTPS. - Port int64 `json:"port"` - JSON healthcheckPreviewGetResponseHTTPConfigJSON `json:"-"` -} - -// healthcheckPreviewGetResponseHTTPConfigJSON contains the JSON metadata for the -// struct [HealthcheckPreviewGetResponseHTTPConfig] -type healthcheckPreviewGetResponseHTTPConfigJSON struct { - AllowInsecure apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Method apijson.Field - Path apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckPreviewGetResponseHTTPConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckPreviewGetResponseHTTPConfigJSON) RawJSON() string { - return r.raw -} - -// The HTTP method to use for the health check. -type HealthcheckPreviewGetResponseHTTPConfigMethod string - -const ( - HealthcheckPreviewGetResponseHTTPConfigMethodGet HealthcheckPreviewGetResponseHTTPConfigMethod = "GET" - HealthcheckPreviewGetResponseHTTPConfigMethodHead HealthcheckPreviewGetResponseHTTPConfigMethod = "HEAD" -) - -// The current status of the origin server according to the health check. -type HealthcheckPreviewGetResponseStatus string - -const ( - HealthcheckPreviewGetResponseStatusUnknown HealthcheckPreviewGetResponseStatus = "unknown" - HealthcheckPreviewGetResponseStatusHealthy HealthcheckPreviewGetResponseStatus = "healthy" - HealthcheckPreviewGetResponseStatusUnhealthy HealthcheckPreviewGetResponseStatus = "unhealthy" - HealthcheckPreviewGetResponseStatusSuspended HealthcheckPreviewGetResponseStatus = "suspended" -) - -// Parameters specific to TCP health check. -type HealthcheckPreviewGetResponseTcpConfig struct { - // The TCP connection method to use for the health check. - Method HealthcheckPreviewGetResponseTcpConfigMethod `json:"method"` - // Port number to connect to for the health check. Defaults to 80. - Port int64 `json:"port"` - JSON healthcheckPreviewGetResponseTcpConfigJSON `json:"-"` -} - -// healthcheckPreviewGetResponseTcpConfigJSON contains the JSON metadata for the -// struct [HealthcheckPreviewGetResponseTcpConfig] -type healthcheckPreviewGetResponseTcpConfigJSON struct { - Method apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckPreviewGetResponseTcpConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckPreviewGetResponseTcpConfigJSON) RawJSON() string { - return r.raw -} - -// The TCP connection method to use for the health check. -type HealthcheckPreviewGetResponseTcpConfigMethod string - -const ( - HealthcheckPreviewGetResponseTcpConfigMethodConnectionEstablished HealthcheckPreviewGetResponseTcpConfigMethod = "connection_established" -) - -type HealthcheckPreviewNewParams struct { - // The hostname or IP address of the origin server to run health checks on. - Address param.Field[string] `json:"address,required"` - // A short name to identify the health check. Only alphanumeric characters, hyphens - // and underscores are allowed. - Name param.Field[string] `json:"name,required"` - // A list of regions from which to run health checks. Null means Cloudflare will - // pick a default region. - CheckRegions param.Field[[]HealthcheckPreviewNewParamsCheckRegion] `json:"check_regions"` - // The number of consecutive fails required from a health check before changing the - // health to unhealthy. - ConsecutiveFails param.Field[int64] `json:"consecutive_fails"` - // The number of consecutive successes required from a health check before changing - // the health to healthy. - ConsecutiveSuccesses param.Field[int64] `json:"consecutive_successes"` - // A human-readable description of the health check. - Description param.Field[string] `json:"description"` - // Parameters specific to an HTTP or HTTPS health check. - HTTPConfig param.Field[HealthcheckPreviewNewParamsHTTPConfig] `json:"http_config"` - // The interval between each health check. Shorter intervals may give quicker - // notifications if the origin status changes, but will increase load on the origin - // as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // If suspended, no health checks are sent to the origin. - Suspended param.Field[bool] `json:"suspended"` - // Parameters specific to TCP health check. - TcpConfig param.Field[HealthcheckPreviewNewParamsTcpConfig] `json:"tcp_config"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP', 'HTTPS' and 'TCP'. - Type param.Field[string] `json:"type"` -} - -func (r HealthcheckPreviewNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, -// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS -// and ENTERPRISE customers only). -type HealthcheckPreviewNewParamsCheckRegion string - -const ( - HealthcheckPreviewNewParamsCheckRegionWnam HealthcheckPreviewNewParamsCheckRegion = "WNAM" - HealthcheckPreviewNewParamsCheckRegionEnam HealthcheckPreviewNewParamsCheckRegion = "ENAM" - HealthcheckPreviewNewParamsCheckRegionWeu HealthcheckPreviewNewParamsCheckRegion = "WEU" - HealthcheckPreviewNewParamsCheckRegionEeu HealthcheckPreviewNewParamsCheckRegion = "EEU" - HealthcheckPreviewNewParamsCheckRegionNsam HealthcheckPreviewNewParamsCheckRegion = "NSAM" - HealthcheckPreviewNewParamsCheckRegionSsam HealthcheckPreviewNewParamsCheckRegion = "SSAM" - HealthcheckPreviewNewParamsCheckRegionOc HealthcheckPreviewNewParamsCheckRegion = "OC" - HealthcheckPreviewNewParamsCheckRegionMe HealthcheckPreviewNewParamsCheckRegion = "ME" - HealthcheckPreviewNewParamsCheckRegionNaf HealthcheckPreviewNewParamsCheckRegion = "NAF" - HealthcheckPreviewNewParamsCheckRegionSaf HealthcheckPreviewNewParamsCheckRegion = "SAF" - HealthcheckPreviewNewParamsCheckRegionIn HealthcheckPreviewNewParamsCheckRegion = "IN" - HealthcheckPreviewNewParamsCheckRegionSeas HealthcheckPreviewNewParamsCheckRegion = "SEAS" - HealthcheckPreviewNewParamsCheckRegionNeas HealthcheckPreviewNewParamsCheckRegion = "NEAS" - HealthcheckPreviewNewParamsCheckRegionAllRegions HealthcheckPreviewNewParamsCheckRegion = "ALL_REGIONS" -) - -// Parameters specific to an HTTP or HTTPS health check. -type HealthcheckPreviewNewParamsHTTPConfig struct { - // Do not validate the certificate when the health check uses HTTPS. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. - ExpectedBody param.Field[string] `json:"expected_body"` - // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all - // codes starting with 2) of the health check. - ExpectedCodes param.Field[[]string] `json:"expected_codes"` - // Follow redirects if the origin returns a 3xx status code. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. - Header param.Field[interface{}] `json:"header"` - // The HTTP method to use for the health check. - Method param.Field[HealthcheckPreviewNewParamsHTTPConfigMethod] `json:"method"` - // The endpoint path to health check against. - Path param.Field[string] `json:"path"` - // Port number to connect to for the health check. Defaults to 80 if type is HTTP - // or 443 if type is HTTPS. - Port param.Field[int64] `json:"port"` -} - -func (r HealthcheckPreviewNewParamsHTTPConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The HTTP method to use for the health check. -type HealthcheckPreviewNewParamsHTTPConfigMethod string - -const ( - HealthcheckPreviewNewParamsHTTPConfigMethodGet HealthcheckPreviewNewParamsHTTPConfigMethod = "GET" - HealthcheckPreviewNewParamsHTTPConfigMethodHead HealthcheckPreviewNewParamsHTTPConfigMethod = "HEAD" -) - -// Parameters specific to TCP health check. -type HealthcheckPreviewNewParamsTcpConfig struct { - // The TCP connection method to use for the health check. - Method param.Field[HealthcheckPreviewNewParamsTcpConfigMethod] `json:"method"` - // Port number to connect to for the health check. Defaults to 80. - Port param.Field[int64] `json:"port"` -} - -func (r HealthcheckPreviewNewParamsTcpConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The TCP connection method to use for the health check. -type HealthcheckPreviewNewParamsTcpConfigMethod string - -const ( - HealthcheckPreviewNewParamsTcpConfigMethodConnectionEstablished HealthcheckPreviewNewParamsTcpConfigMethod = "connection_established" -) - -type HealthcheckPreviewNewResponseEnvelope struct { - Errors []HealthcheckPreviewNewResponseEnvelopeErrors `json:"errors,required"` - Messages []HealthcheckPreviewNewResponseEnvelopeMessages `json:"messages,required"` - Result HealthcheckPreviewNewResponse `json:"result,required"` - // Whether the API call was successful - Success HealthcheckPreviewNewResponseEnvelopeSuccess `json:"success,required"` - JSON healthcheckPreviewNewResponseEnvelopeJSON `json:"-"` -} - -// healthcheckPreviewNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [HealthcheckPreviewNewResponseEnvelope] -type healthcheckPreviewNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckPreviewNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckPreviewNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HealthcheckPreviewNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckPreviewNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// healthcheckPreviewNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [HealthcheckPreviewNewResponseEnvelopeErrors] -type healthcheckPreviewNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckPreviewNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckPreviewNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HealthcheckPreviewNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckPreviewNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// healthcheckPreviewNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [HealthcheckPreviewNewResponseEnvelopeMessages] -type healthcheckPreviewNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckPreviewNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckPreviewNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HealthcheckPreviewNewResponseEnvelopeSuccess bool - -const ( - HealthcheckPreviewNewResponseEnvelopeSuccessTrue HealthcheckPreviewNewResponseEnvelopeSuccess = true -) - -type HealthcheckPreviewDeleteResponseEnvelope struct { - Errors []HealthcheckPreviewDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []HealthcheckPreviewDeleteResponseEnvelopeMessages `json:"messages,required"` - Result HealthcheckPreviewDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success HealthcheckPreviewDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON healthcheckPreviewDeleteResponseEnvelopeJSON `json:"-"` -} - -// healthcheckPreviewDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [HealthcheckPreviewDeleteResponseEnvelope] -type healthcheckPreviewDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckPreviewDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckPreviewDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HealthcheckPreviewDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckPreviewDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// healthcheckPreviewDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [HealthcheckPreviewDeleteResponseEnvelopeErrors] -type healthcheckPreviewDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckPreviewDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckPreviewDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HealthcheckPreviewDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckPreviewDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// healthcheckPreviewDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [HealthcheckPreviewDeleteResponseEnvelopeMessages] -type healthcheckPreviewDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckPreviewDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckPreviewDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HealthcheckPreviewDeleteResponseEnvelopeSuccess bool - -const ( - HealthcheckPreviewDeleteResponseEnvelopeSuccessTrue HealthcheckPreviewDeleteResponseEnvelopeSuccess = true -) - -type HealthcheckPreviewGetResponseEnvelope struct { - Errors []HealthcheckPreviewGetResponseEnvelopeErrors `json:"errors,required"` - Messages []HealthcheckPreviewGetResponseEnvelopeMessages `json:"messages,required"` - Result HealthcheckPreviewGetResponse `json:"result,required"` - // Whether the API call was successful - Success HealthcheckPreviewGetResponseEnvelopeSuccess `json:"success,required"` - JSON healthcheckPreviewGetResponseEnvelopeJSON `json:"-"` -} - -// healthcheckPreviewGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [HealthcheckPreviewGetResponseEnvelope] -type healthcheckPreviewGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckPreviewGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckPreviewGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HealthcheckPreviewGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckPreviewGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// healthcheckPreviewGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [HealthcheckPreviewGetResponseEnvelopeErrors] -type healthcheckPreviewGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckPreviewGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckPreviewGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HealthcheckPreviewGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON healthcheckPreviewGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// healthcheckPreviewGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [HealthcheckPreviewGetResponseEnvelopeMessages] -type healthcheckPreviewGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HealthcheckPreviewGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r healthcheckPreviewGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HealthcheckPreviewGetResponseEnvelopeSuccess bool - -const ( - HealthcheckPreviewGetResponseEnvelopeSuccessTrue HealthcheckPreviewGetResponseEnvelopeSuccess = true -) diff --git a/healthcheckpreview_test.go b/healthcheckpreview_test.go deleted file mode 100644 index da41147a787..00000000000 --- a/healthcheckpreview_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestHealthcheckPreviewNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Healthchecks.Previews.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.HealthcheckPreviewNewParams{ - Address: cloudflare.F("www.example.com"), - Name: cloudflare.F("server-1"), - CheckRegions: cloudflare.F([]cloudflare.HealthcheckPreviewNewParamsCheckRegion{cloudflare.HealthcheckPreviewNewParamsCheckRegionWeu, cloudflare.HealthcheckPreviewNewParamsCheckRegionEnam}), - ConsecutiveFails: cloudflare.F(int64(0)), - ConsecutiveSuccesses: cloudflare.F(int64(0)), - Description: cloudflare.F("Health check for www.example.com"), - HTTPConfig: cloudflare.F(cloudflare.HealthcheckPreviewNewParamsHTTPConfig{ - AllowInsecure: cloudflare.F(true), - ExpectedBody: cloudflare.F("success"), - ExpectedCodes: cloudflare.F([]string{"2xx", "302"}), - FollowRedirects: cloudflare.F(true), - Header: cloudflare.F[any](map[string]interface{}{ - "Host": map[string]interface{}{ - "0": "example.com", - }, - "X-App-ID": map[string]interface{}{ - "0": "abc123", - }, - }), - Method: cloudflare.F(cloudflare.HealthcheckPreviewNewParamsHTTPConfigMethodGet), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - }), - Interval: cloudflare.F(int64(0)), - Retries: cloudflare.F(int64(0)), - Suspended: cloudflare.F(true), - TcpConfig: cloudflare.F(cloudflare.HealthcheckPreviewNewParamsTcpConfig{ - Method: cloudflare.F(cloudflare.HealthcheckPreviewNewParamsTcpConfigMethodConnectionEstablished), - Port: cloudflare.F(int64(0)), - }), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F("HTTPS"), - }, - ) - 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 TestHealthcheckPreviewDelete(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("user@example.com"), - ) - _, err := client.Healthchecks.Previews.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "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()) - } -} - -func TestHealthcheckPreviewGet(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("user@example.com"), - ) - _, err := client.Healthchecks.Previews.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "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/healthchecks/aliases.go b/healthchecks/aliases.go new file mode 100644 index 00000000000..dc8ae3e590b --- /dev/null +++ b/healthchecks/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package healthchecks + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/healthchecks/healthcheck.go b/healthchecks/healthcheck.go new file mode 100644 index 00000000000..ff8c6ccf3fa --- /dev/null +++ b/healthchecks/healthcheck.go @@ -0,0 +1,1216 @@ +// File generated from our OpenAPI spec by Stainless. + +package healthchecks + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HealthcheckService 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 [NewHealthcheckService] method +// instead. +type HealthcheckService struct { + Options []option.RequestOption + Previews *PreviewService +} + +// NewHealthcheckService 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 NewHealthcheckService(opts ...option.RequestOption) (r *HealthcheckService) { + r = &HealthcheckService{} + r.Options = opts + r.Previews = NewPreviewService(opts...) + return +} + +// Create a new health check. +func (r *HealthcheckService) New(ctx context.Context, zoneIdentifier string, body HealthcheckNewParams, opts ...option.RequestOption) (res *HealthchecksHealthchecks, err error) { + opts = append(r.Options[:], opts...) + var env HealthcheckNewResponseEnvelope + path := fmt.Sprintf("zones/%s/healthchecks", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update a configured health check. +func (r *HealthcheckService) Update(ctx context.Context, zoneIdentifier string, identifier string, body HealthcheckUpdateParams, opts ...option.RequestOption) (res *HealthchecksHealthchecks, err error) { + opts = append(r.Options[:], opts...) + var env HealthcheckUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/healthchecks/%s", zoneIdentifier, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List configured health checks. +func (r *HealthcheckService) List(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *[]HealthchecksHealthchecks, err error) { + opts = append(r.Options[:], opts...) + var env HealthcheckListResponseEnvelope + path := fmt.Sprintf("zones/%s/healthchecks", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a health check. +func (r *HealthcheckService) Delete(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *HealthcheckDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env HealthcheckDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/healthchecks/%s", zoneIdentifier, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Patch a configured health check. +func (r *HealthcheckService) Edit(ctx context.Context, zoneIdentifier string, identifier string, body HealthcheckEditParams, opts ...option.RequestOption) (res *HealthchecksHealthchecks, err error) { + opts = append(r.Options[:], opts...) + var env HealthcheckEditResponseEnvelope + path := fmt.Sprintf("zones/%s/healthchecks/%s", zoneIdentifier, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch a single configured health check. +func (r *HealthcheckService) Get(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *HealthchecksHealthchecks, err error) { + opts = append(r.Options[:], opts...) + var env HealthcheckGetResponseEnvelope + path := fmt.Sprintf("zones/%s/healthchecks/%s", zoneIdentifier, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HealthchecksHealthchecks struct { + // Identifier + ID string `json:"id"` + // The hostname or IP address of the origin server to run health checks on. + Address string `json:"address"` + // A list of regions from which to run health checks. Null means Cloudflare will + // pick a default region. + CheckRegions []HealthchecksHealthchecksCheckRegion `json:"check_regions,nullable"` + // The number of consecutive fails required from a health check before changing the + // health to unhealthy. + ConsecutiveFails int64 `json:"consecutive_fails"` + // The number of consecutive successes required from a health check before changing + // the health to healthy. + ConsecutiveSuccesses int64 `json:"consecutive_successes"` + CreatedOn time.Time `json:"created_on" format:"date-time"` + // A human-readable description of the health check. + Description string `json:"description"` + // The current failure reason if status is unhealthy. + FailureReason string `json:"failure_reason"` + // Parameters specific to an HTTP or HTTPS health check. + HTTPConfig HealthchecksHealthchecksHTTPConfig `json:"http_config,nullable"` + // The interval between each health check. Shorter intervals may give quicker + // notifications if the origin status changes, but will increase load on the origin + // as we check from multiple locations. + Interval int64 `json:"interval"` + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // A short name to identify the health check. Only alphanumeric characters, hyphens + // and underscores are allowed. + Name string `json:"name"` + // The number of retries to attempt in case of a timeout before marking the origin + // as unhealthy. Retries are attempted immediately. + Retries int64 `json:"retries"` + // The current status of the origin server according to the health check. + Status HealthchecksHealthchecksStatus `json:"status"` + // If suspended, no health checks are sent to the origin. + Suspended bool `json:"suspended"` + // Parameters specific to TCP health check. + TcpConfig HealthchecksHealthchecksTcpConfig `json:"tcp_config,nullable"` + // The timeout (in seconds) before marking the health check as failed. + Timeout int64 `json:"timeout"` + // The protocol to use for the health check. Currently supported protocols are + // 'HTTP', 'HTTPS' and 'TCP'. + Type string `json:"type"` + JSON healthchecksHealthchecksJSON `json:"-"` +} + +// healthchecksHealthchecksJSON contains the JSON metadata for the struct +// [HealthchecksHealthchecks] +type healthchecksHealthchecksJSON struct { + ID apijson.Field + Address apijson.Field + CheckRegions apijson.Field + ConsecutiveFails apijson.Field + ConsecutiveSuccesses apijson.Field + CreatedOn apijson.Field + Description apijson.Field + FailureReason apijson.Field + HTTPConfig apijson.Field + Interval apijson.Field + ModifiedOn apijson.Field + Name apijson.Field + Retries apijson.Field + Status apijson.Field + Suspended apijson.Field + TcpConfig apijson.Field + Timeout apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthchecksHealthchecks) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthchecksHealthchecksJSON) RawJSON() string { + return r.raw +} + +// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, +// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, +// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, +// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS +// and ENTERPRISE customers only). +type HealthchecksHealthchecksCheckRegion string + +const ( + HealthchecksHealthchecksCheckRegionWnam HealthchecksHealthchecksCheckRegion = "WNAM" + HealthchecksHealthchecksCheckRegionEnam HealthchecksHealthchecksCheckRegion = "ENAM" + HealthchecksHealthchecksCheckRegionWeu HealthchecksHealthchecksCheckRegion = "WEU" + HealthchecksHealthchecksCheckRegionEeu HealthchecksHealthchecksCheckRegion = "EEU" + HealthchecksHealthchecksCheckRegionNsam HealthchecksHealthchecksCheckRegion = "NSAM" + HealthchecksHealthchecksCheckRegionSsam HealthchecksHealthchecksCheckRegion = "SSAM" + HealthchecksHealthchecksCheckRegionOc HealthchecksHealthchecksCheckRegion = "OC" + HealthchecksHealthchecksCheckRegionMe HealthchecksHealthchecksCheckRegion = "ME" + HealthchecksHealthchecksCheckRegionNaf HealthchecksHealthchecksCheckRegion = "NAF" + HealthchecksHealthchecksCheckRegionSaf HealthchecksHealthchecksCheckRegion = "SAF" + HealthchecksHealthchecksCheckRegionIn HealthchecksHealthchecksCheckRegion = "IN" + HealthchecksHealthchecksCheckRegionSeas HealthchecksHealthchecksCheckRegion = "SEAS" + HealthchecksHealthchecksCheckRegionNeas HealthchecksHealthchecksCheckRegion = "NEAS" + HealthchecksHealthchecksCheckRegionAllRegions HealthchecksHealthchecksCheckRegion = "ALL_REGIONS" +) + +// Parameters specific to an HTTP or HTTPS health check. +type HealthchecksHealthchecksHTTPConfig struct { + // Do not validate the certificate when the health check uses HTTPS. + AllowInsecure bool `json:"allow_insecure"` + // A case-insensitive sub-string to look for in the response body. If this string + // is not found, the origin will be marked as unhealthy. + ExpectedBody string `json:"expected_body"` + // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all + // codes starting with 2) of the health check. + ExpectedCodes []string `json:"expected_codes,nullable"` + // Follow redirects if the origin returns a 3xx status code. + FollowRedirects bool `json:"follow_redirects"` + // The HTTP request headers to send in the health check. It is recommended you set + // a Host header by default. The User-Agent header cannot be overridden. + Header interface{} `json:"header,nullable"` + // The HTTP method to use for the health check. + Method HealthchecksHealthchecksHTTPConfigMethod `json:"method"` + // The endpoint path to health check against. + Path string `json:"path"` + // Port number to connect to for the health check. Defaults to 80 if type is HTTP + // or 443 if type is HTTPS. + Port int64 `json:"port"` + JSON healthchecksHealthchecksHTTPConfigJSON `json:"-"` +} + +// healthchecksHealthchecksHTTPConfigJSON contains the JSON metadata for the struct +// [HealthchecksHealthchecksHTTPConfig] +type healthchecksHealthchecksHTTPConfigJSON struct { + AllowInsecure apijson.Field + ExpectedBody apijson.Field + ExpectedCodes apijson.Field + FollowRedirects apijson.Field + Header apijson.Field + Method apijson.Field + Path apijson.Field + Port apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthchecksHealthchecksHTTPConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthchecksHealthchecksHTTPConfigJSON) RawJSON() string { + return r.raw +} + +// The HTTP method to use for the health check. +type HealthchecksHealthchecksHTTPConfigMethod string + +const ( + HealthchecksHealthchecksHTTPConfigMethodGet HealthchecksHealthchecksHTTPConfigMethod = "GET" + HealthchecksHealthchecksHTTPConfigMethodHead HealthchecksHealthchecksHTTPConfigMethod = "HEAD" +) + +// The current status of the origin server according to the health check. +type HealthchecksHealthchecksStatus string + +const ( + HealthchecksHealthchecksStatusUnknown HealthchecksHealthchecksStatus = "unknown" + HealthchecksHealthchecksStatusHealthy HealthchecksHealthchecksStatus = "healthy" + HealthchecksHealthchecksStatusUnhealthy HealthchecksHealthchecksStatus = "unhealthy" + HealthchecksHealthchecksStatusSuspended HealthchecksHealthchecksStatus = "suspended" +) + +// Parameters specific to TCP health check. +type HealthchecksHealthchecksTcpConfig struct { + // The TCP connection method to use for the health check. + Method HealthchecksHealthchecksTcpConfigMethod `json:"method"` + // Port number to connect to for the health check. Defaults to 80. + Port int64 `json:"port"` + JSON healthchecksHealthchecksTcpConfigJSON `json:"-"` +} + +// healthchecksHealthchecksTcpConfigJSON contains the JSON metadata for the struct +// [HealthchecksHealthchecksTcpConfig] +type healthchecksHealthchecksTcpConfigJSON struct { + Method apijson.Field + Port apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthchecksHealthchecksTcpConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthchecksHealthchecksTcpConfigJSON) RawJSON() string { + return r.raw +} + +// The TCP connection method to use for the health check. +type HealthchecksHealthchecksTcpConfigMethod string + +const ( + HealthchecksHealthchecksTcpConfigMethodConnectionEstablished HealthchecksHealthchecksTcpConfigMethod = "connection_established" +) + +type HealthcheckDeleteResponse struct { + // Identifier + ID string `json:"id"` + JSON healthcheckDeleteResponseJSON `json:"-"` +} + +// healthcheckDeleteResponseJSON contains the JSON metadata for the struct +// [HealthcheckDeleteResponse] +type healthcheckDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type HealthcheckNewParams struct { + // The hostname or IP address of the origin server to run health checks on. + Address param.Field[string] `json:"address,required"` + // A short name to identify the health check. Only alphanumeric characters, hyphens + // and underscores are allowed. + Name param.Field[string] `json:"name,required"` + // A list of regions from which to run health checks. Null means Cloudflare will + // pick a default region. + CheckRegions param.Field[[]HealthcheckNewParamsCheckRegion] `json:"check_regions"` + // The number of consecutive fails required from a health check before changing the + // health to unhealthy. + ConsecutiveFails param.Field[int64] `json:"consecutive_fails"` + // The number of consecutive successes required from a health check before changing + // the health to healthy. + ConsecutiveSuccesses param.Field[int64] `json:"consecutive_successes"` + // A human-readable description of the health check. + Description param.Field[string] `json:"description"` + // Parameters specific to an HTTP or HTTPS health check. + HTTPConfig param.Field[HealthcheckNewParamsHTTPConfig] `json:"http_config"` + // The interval between each health check. Shorter intervals may give quicker + // notifications if the origin status changes, but will increase load on the origin + // as we check from multiple locations. + Interval param.Field[int64] `json:"interval"` + // The number of retries to attempt in case of a timeout before marking the origin + // as unhealthy. Retries are attempted immediately. + Retries param.Field[int64] `json:"retries"` + // If suspended, no health checks are sent to the origin. + Suspended param.Field[bool] `json:"suspended"` + // Parameters specific to TCP health check. + TcpConfig param.Field[HealthcheckNewParamsTcpConfig] `json:"tcp_config"` + // The timeout (in seconds) before marking the health check as failed. + Timeout param.Field[int64] `json:"timeout"` + // The protocol to use for the health check. Currently supported protocols are + // 'HTTP', 'HTTPS' and 'TCP'. + Type param.Field[string] `json:"type"` +} + +func (r HealthcheckNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, +// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, +// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, +// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS +// and ENTERPRISE customers only). +type HealthcheckNewParamsCheckRegion string + +const ( + HealthcheckNewParamsCheckRegionWnam HealthcheckNewParamsCheckRegion = "WNAM" + HealthcheckNewParamsCheckRegionEnam HealthcheckNewParamsCheckRegion = "ENAM" + HealthcheckNewParamsCheckRegionWeu HealthcheckNewParamsCheckRegion = "WEU" + HealthcheckNewParamsCheckRegionEeu HealthcheckNewParamsCheckRegion = "EEU" + HealthcheckNewParamsCheckRegionNsam HealthcheckNewParamsCheckRegion = "NSAM" + HealthcheckNewParamsCheckRegionSsam HealthcheckNewParamsCheckRegion = "SSAM" + HealthcheckNewParamsCheckRegionOc HealthcheckNewParamsCheckRegion = "OC" + HealthcheckNewParamsCheckRegionMe HealthcheckNewParamsCheckRegion = "ME" + HealthcheckNewParamsCheckRegionNaf HealthcheckNewParamsCheckRegion = "NAF" + HealthcheckNewParamsCheckRegionSaf HealthcheckNewParamsCheckRegion = "SAF" + HealthcheckNewParamsCheckRegionIn HealthcheckNewParamsCheckRegion = "IN" + HealthcheckNewParamsCheckRegionSeas HealthcheckNewParamsCheckRegion = "SEAS" + HealthcheckNewParamsCheckRegionNeas HealthcheckNewParamsCheckRegion = "NEAS" + HealthcheckNewParamsCheckRegionAllRegions HealthcheckNewParamsCheckRegion = "ALL_REGIONS" +) + +// Parameters specific to an HTTP or HTTPS health check. +type HealthcheckNewParamsHTTPConfig struct { + // Do not validate the certificate when the health check uses HTTPS. + AllowInsecure param.Field[bool] `json:"allow_insecure"` + // A case-insensitive sub-string to look for in the response body. If this string + // is not found, the origin will be marked as unhealthy. + ExpectedBody param.Field[string] `json:"expected_body"` + // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all + // codes starting with 2) of the health check. + ExpectedCodes param.Field[[]string] `json:"expected_codes"` + // Follow redirects if the origin returns a 3xx status code. + FollowRedirects param.Field[bool] `json:"follow_redirects"` + // The HTTP request headers to send in the health check. It is recommended you set + // a Host header by default. The User-Agent header cannot be overridden. + Header param.Field[interface{}] `json:"header"` + // The HTTP method to use for the health check. + Method param.Field[HealthcheckNewParamsHTTPConfigMethod] `json:"method"` + // The endpoint path to health check against. + Path param.Field[string] `json:"path"` + // Port number to connect to for the health check. Defaults to 80 if type is HTTP + // or 443 if type is HTTPS. + Port param.Field[int64] `json:"port"` +} + +func (r HealthcheckNewParamsHTTPConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The HTTP method to use for the health check. +type HealthcheckNewParamsHTTPConfigMethod string + +const ( + HealthcheckNewParamsHTTPConfigMethodGet HealthcheckNewParamsHTTPConfigMethod = "GET" + HealthcheckNewParamsHTTPConfigMethodHead HealthcheckNewParamsHTTPConfigMethod = "HEAD" +) + +// Parameters specific to TCP health check. +type HealthcheckNewParamsTcpConfig struct { + // The TCP connection method to use for the health check. + Method param.Field[HealthcheckNewParamsTcpConfigMethod] `json:"method"` + // Port number to connect to for the health check. Defaults to 80. + Port param.Field[int64] `json:"port"` +} + +func (r HealthcheckNewParamsTcpConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The TCP connection method to use for the health check. +type HealthcheckNewParamsTcpConfigMethod string + +const ( + HealthcheckNewParamsTcpConfigMethodConnectionEstablished HealthcheckNewParamsTcpConfigMethod = "connection_established" +) + +type HealthcheckNewResponseEnvelope struct { + Errors []HealthcheckNewResponseEnvelopeErrors `json:"errors,required"` + Messages []HealthcheckNewResponseEnvelopeMessages `json:"messages,required"` + Result HealthchecksHealthchecks `json:"result,required"` + // Whether the API call was successful + Success HealthcheckNewResponseEnvelopeSuccess `json:"success,required"` + JSON healthcheckNewResponseEnvelopeJSON `json:"-"` +} + +// healthcheckNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [HealthcheckNewResponseEnvelope] +type healthcheckNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HealthcheckNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON healthcheckNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// healthcheckNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [HealthcheckNewResponseEnvelopeErrors] +type healthcheckNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HealthcheckNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON healthcheckNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// healthcheckNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [HealthcheckNewResponseEnvelopeMessages] +type healthcheckNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HealthcheckNewResponseEnvelopeSuccess bool + +const ( + HealthcheckNewResponseEnvelopeSuccessTrue HealthcheckNewResponseEnvelopeSuccess = true +) + +type HealthcheckUpdateParams struct { + // The hostname or IP address of the origin server to run health checks on. + Address param.Field[string] `json:"address,required"` + // A short name to identify the health check. Only alphanumeric characters, hyphens + // and underscores are allowed. + Name param.Field[string] `json:"name,required"` + // A list of regions from which to run health checks. Null means Cloudflare will + // pick a default region. + CheckRegions param.Field[[]HealthcheckUpdateParamsCheckRegion] `json:"check_regions"` + // The number of consecutive fails required from a health check before changing the + // health to unhealthy. + ConsecutiveFails param.Field[int64] `json:"consecutive_fails"` + // The number of consecutive successes required from a health check before changing + // the health to healthy. + ConsecutiveSuccesses param.Field[int64] `json:"consecutive_successes"` + // A human-readable description of the health check. + Description param.Field[string] `json:"description"` + // Parameters specific to an HTTP or HTTPS health check. + HTTPConfig param.Field[HealthcheckUpdateParamsHTTPConfig] `json:"http_config"` + // The interval between each health check. Shorter intervals may give quicker + // notifications if the origin status changes, but will increase load on the origin + // as we check from multiple locations. + Interval param.Field[int64] `json:"interval"` + // The number of retries to attempt in case of a timeout before marking the origin + // as unhealthy. Retries are attempted immediately. + Retries param.Field[int64] `json:"retries"` + // If suspended, no health checks are sent to the origin. + Suspended param.Field[bool] `json:"suspended"` + // Parameters specific to TCP health check. + TcpConfig param.Field[HealthcheckUpdateParamsTcpConfig] `json:"tcp_config"` + // The timeout (in seconds) before marking the health check as failed. + Timeout param.Field[int64] `json:"timeout"` + // The protocol to use for the health check. Currently supported protocols are + // 'HTTP', 'HTTPS' and 'TCP'. + Type param.Field[string] `json:"type"` +} + +func (r HealthcheckUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, +// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, +// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, +// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS +// and ENTERPRISE customers only). +type HealthcheckUpdateParamsCheckRegion string + +const ( + HealthcheckUpdateParamsCheckRegionWnam HealthcheckUpdateParamsCheckRegion = "WNAM" + HealthcheckUpdateParamsCheckRegionEnam HealthcheckUpdateParamsCheckRegion = "ENAM" + HealthcheckUpdateParamsCheckRegionWeu HealthcheckUpdateParamsCheckRegion = "WEU" + HealthcheckUpdateParamsCheckRegionEeu HealthcheckUpdateParamsCheckRegion = "EEU" + HealthcheckUpdateParamsCheckRegionNsam HealthcheckUpdateParamsCheckRegion = "NSAM" + HealthcheckUpdateParamsCheckRegionSsam HealthcheckUpdateParamsCheckRegion = "SSAM" + HealthcheckUpdateParamsCheckRegionOc HealthcheckUpdateParamsCheckRegion = "OC" + HealthcheckUpdateParamsCheckRegionMe HealthcheckUpdateParamsCheckRegion = "ME" + HealthcheckUpdateParamsCheckRegionNaf HealthcheckUpdateParamsCheckRegion = "NAF" + HealthcheckUpdateParamsCheckRegionSaf HealthcheckUpdateParamsCheckRegion = "SAF" + HealthcheckUpdateParamsCheckRegionIn HealthcheckUpdateParamsCheckRegion = "IN" + HealthcheckUpdateParamsCheckRegionSeas HealthcheckUpdateParamsCheckRegion = "SEAS" + HealthcheckUpdateParamsCheckRegionNeas HealthcheckUpdateParamsCheckRegion = "NEAS" + HealthcheckUpdateParamsCheckRegionAllRegions HealthcheckUpdateParamsCheckRegion = "ALL_REGIONS" +) + +// Parameters specific to an HTTP or HTTPS health check. +type HealthcheckUpdateParamsHTTPConfig struct { + // Do not validate the certificate when the health check uses HTTPS. + AllowInsecure param.Field[bool] `json:"allow_insecure"` + // A case-insensitive sub-string to look for in the response body. If this string + // is not found, the origin will be marked as unhealthy. + ExpectedBody param.Field[string] `json:"expected_body"` + // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all + // codes starting with 2) of the health check. + ExpectedCodes param.Field[[]string] `json:"expected_codes"` + // Follow redirects if the origin returns a 3xx status code. + FollowRedirects param.Field[bool] `json:"follow_redirects"` + // The HTTP request headers to send in the health check. It is recommended you set + // a Host header by default. The User-Agent header cannot be overridden. + Header param.Field[interface{}] `json:"header"` + // The HTTP method to use for the health check. + Method param.Field[HealthcheckUpdateParamsHTTPConfigMethod] `json:"method"` + // The endpoint path to health check against. + Path param.Field[string] `json:"path"` + // Port number to connect to for the health check. Defaults to 80 if type is HTTP + // or 443 if type is HTTPS. + Port param.Field[int64] `json:"port"` +} + +func (r HealthcheckUpdateParamsHTTPConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The HTTP method to use for the health check. +type HealthcheckUpdateParamsHTTPConfigMethod string + +const ( + HealthcheckUpdateParamsHTTPConfigMethodGet HealthcheckUpdateParamsHTTPConfigMethod = "GET" + HealthcheckUpdateParamsHTTPConfigMethodHead HealthcheckUpdateParamsHTTPConfigMethod = "HEAD" +) + +// Parameters specific to TCP health check. +type HealthcheckUpdateParamsTcpConfig struct { + // The TCP connection method to use for the health check. + Method param.Field[HealthcheckUpdateParamsTcpConfigMethod] `json:"method"` + // Port number to connect to for the health check. Defaults to 80. + Port param.Field[int64] `json:"port"` +} + +func (r HealthcheckUpdateParamsTcpConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The TCP connection method to use for the health check. +type HealthcheckUpdateParamsTcpConfigMethod string + +const ( + HealthcheckUpdateParamsTcpConfigMethodConnectionEstablished HealthcheckUpdateParamsTcpConfigMethod = "connection_established" +) + +type HealthcheckUpdateResponseEnvelope struct { + Errors []HealthcheckUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []HealthcheckUpdateResponseEnvelopeMessages `json:"messages,required"` + Result HealthchecksHealthchecks `json:"result,required"` + // Whether the API call was successful + Success HealthcheckUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON healthcheckUpdateResponseEnvelopeJSON `json:"-"` +} + +// healthcheckUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [HealthcheckUpdateResponseEnvelope] +type healthcheckUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HealthcheckUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON healthcheckUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// healthcheckUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [HealthcheckUpdateResponseEnvelopeErrors] +type healthcheckUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HealthcheckUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON healthcheckUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// healthcheckUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [HealthcheckUpdateResponseEnvelopeMessages] +type healthcheckUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HealthcheckUpdateResponseEnvelopeSuccess bool + +const ( + HealthcheckUpdateResponseEnvelopeSuccessTrue HealthcheckUpdateResponseEnvelopeSuccess = true +) + +type HealthcheckListResponseEnvelope struct { + Errors []HealthcheckListResponseEnvelopeErrors `json:"errors,required"` + Messages []HealthcheckListResponseEnvelopeMessages `json:"messages,required"` + Result []HealthchecksHealthchecks `json:"result,required,nullable"` + // Whether the API call was successful + Success HealthcheckListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo HealthcheckListResponseEnvelopeResultInfo `json:"result_info"` + JSON healthcheckListResponseEnvelopeJSON `json:"-"` +} + +// healthcheckListResponseEnvelopeJSON contains the JSON metadata for the struct +// [HealthcheckListResponseEnvelope] +type healthcheckListResponseEnvelopeJSON 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 *HealthcheckListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HealthcheckListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON healthcheckListResponseEnvelopeErrorsJSON `json:"-"` +} + +// healthcheckListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [HealthcheckListResponseEnvelopeErrors] +type healthcheckListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HealthcheckListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON healthcheckListResponseEnvelopeMessagesJSON `json:"-"` +} + +// healthcheckListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [HealthcheckListResponseEnvelopeMessages] +type healthcheckListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HealthcheckListResponseEnvelopeSuccess bool + +const ( + HealthcheckListResponseEnvelopeSuccessTrue HealthcheckListResponseEnvelopeSuccess = true +) + +type HealthcheckListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON healthcheckListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// healthcheckListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [HealthcheckListResponseEnvelopeResultInfo] +type healthcheckListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type HealthcheckDeleteResponseEnvelope struct { + Errors []HealthcheckDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []HealthcheckDeleteResponseEnvelopeMessages `json:"messages,required"` + Result HealthcheckDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success HealthcheckDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON healthcheckDeleteResponseEnvelopeJSON `json:"-"` +} + +// healthcheckDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [HealthcheckDeleteResponseEnvelope] +type healthcheckDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HealthcheckDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON healthcheckDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// healthcheckDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [HealthcheckDeleteResponseEnvelopeErrors] +type healthcheckDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HealthcheckDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON healthcheckDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// healthcheckDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [HealthcheckDeleteResponseEnvelopeMessages] +type healthcheckDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HealthcheckDeleteResponseEnvelopeSuccess bool + +const ( + HealthcheckDeleteResponseEnvelopeSuccessTrue HealthcheckDeleteResponseEnvelopeSuccess = true +) + +type HealthcheckEditParams struct { + // The hostname or IP address of the origin server to run health checks on. + Address param.Field[string] `json:"address,required"` + // A short name to identify the health check. Only alphanumeric characters, hyphens + // and underscores are allowed. + Name param.Field[string] `json:"name,required"` + // A list of regions from which to run health checks. Null means Cloudflare will + // pick a default region. + CheckRegions param.Field[[]HealthcheckEditParamsCheckRegion] `json:"check_regions"` + // The number of consecutive fails required from a health check before changing the + // health to unhealthy. + ConsecutiveFails param.Field[int64] `json:"consecutive_fails"` + // The number of consecutive successes required from a health check before changing + // the health to healthy. + ConsecutiveSuccesses param.Field[int64] `json:"consecutive_successes"` + // A human-readable description of the health check. + Description param.Field[string] `json:"description"` + // Parameters specific to an HTTP or HTTPS health check. + HTTPConfig param.Field[HealthcheckEditParamsHTTPConfig] `json:"http_config"` + // The interval between each health check. Shorter intervals may give quicker + // notifications if the origin status changes, but will increase load on the origin + // as we check from multiple locations. + Interval param.Field[int64] `json:"interval"` + // The number of retries to attempt in case of a timeout before marking the origin + // as unhealthy. Retries are attempted immediately. + Retries param.Field[int64] `json:"retries"` + // If suspended, no health checks are sent to the origin. + Suspended param.Field[bool] `json:"suspended"` + // Parameters specific to TCP health check. + TcpConfig param.Field[HealthcheckEditParamsTcpConfig] `json:"tcp_config"` + // The timeout (in seconds) before marking the health check as failed. + Timeout param.Field[int64] `json:"timeout"` + // The protocol to use for the health check. Currently supported protocols are + // 'HTTP', 'HTTPS' and 'TCP'. + Type param.Field[string] `json:"type"` +} + +func (r HealthcheckEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, +// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, +// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, +// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS +// and ENTERPRISE customers only). +type HealthcheckEditParamsCheckRegion string + +const ( + HealthcheckEditParamsCheckRegionWnam HealthcheckEditParamsCheckRegion = "WNAM" + HealthcheckEditParamsCheckRegionEnam HealthcheckEditParamsCheckRegion = "ENAM" + HealthcheckEditParamsCheckRegionWeu HealthcheckEditParamsCheckRegion = "WEU" + HealthcheckEditParamsCheckRegionEeu HealthcheckEditParamsCheckRegion = "EEU" + HealthcheckEditParamsCheckRegionNsam HealthcheckEditParamsCheckRegion = "NSAM" + HealthcheckEditParamsCheckRegionSsam HealthcheckEditParamsCheckRegion = "SSAM" + HealthcheckEditParamsCheckRegionOc HealthcheckEditParamsCheckRegion = "OC" + HealthcheckEditParamsCheckRegionMe HealthcheckEditParamsCheckRegion = "ME" + HealthcheckEditParamsCheckRegionNaf HealthcheckEditParamsCheckRegion = "NAF" + HealthcheckEditParamsCheckRegionSaf HealthcheckEditParamsCheckRegion = "SAF" + HealthcheckEditParamsCheckRegionIn HealthcheckEditParamsCheckRegion = "IN" + HealthcheckEditParamsCheckRegionSeas HealthcheckEditParamsCheckRegion = "SEAS" + HealthcheckEditParamsCheckRegionNeas HealthcheckEditParamsCheckRegion = "NEAS" + HealthcheckEditParamsCheckRegionAllRegions HealthcheckEditParamsCheckRegion = "ALL_REGIONS" +) + +// Parameters specific to an HTTP or HTTPS health check. +type HealthcheckEditParamsHTTPConfig struct { + // Do not validate the certificate when the health check uses HTTPS. + AllowInsecure param.Field[bool] `json:"allow_insecure"` + // A case-insensitive sub-string to look for in the response body. If this string + // is not found, the origin will be marked as unhealthy. + ExpectedBody param.Field[string] `json:"expected_body"` + // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all + // codes starting with 2) of the health check. + ExpectedCodes param.Field[[]string] `json:"expected_codes"` + // Follow redirects if the origin returns a 3xx status code. + FollowRedirects param.Field[bool] `json:"follow_redirects"` + // The HTTP request headers to send in the health check. It is recommended you set + // a Host header by default. The User-Agent header cannot be overridden. + Header param.Field[interface{}] `json:"header"` + // The HTTP method to use for the health check. + Method param.Field[HealthcheckEditParamsHTTPConfigMethod] `json:"method"` + // The endpoint path to health check against. + Path param.Field[string] `json:"path"` + // Port number to connect to for the health check. Defaults to 80 if type is HTTP + // or 443 if type is HTTPS. + Port param.Field[int64] `json:"port"` +} + +func (r HealthcheckEditParamsHTTPConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The HTTP method to use for the health check. +type HealthcheckEditParamsHTTPConfigMethod string + +const ( + HealthcheckEditParamsHTTPConfigMethodGet HealthcheckEditParamsHTTPConfigMethod = "GET" + HealthcheckEditParamsHTTPConfigMethodHead HealthcheckEditParamsHTTPConfigMethod = "HEAD" +) + +// Parameters specific to TCP health check. +type HealthcheckEditParamsTcpConfig struct { + // The TCP connection method to use for the health check. + Method param.Field[HealthcheckEditParamsTcpConfigMethod] `json:"method"` + // Port number to connect to for the health check. Defaults to 80. + Port param.Field[int64] `json:"port"` +} + +func (r HealthcheckEditParamsTcpConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The TCP connection method to use for the health check. +type HealthcheckEditParamsTcpConfigMethod string + +const ( + HealthcheckEditParamsTcpConfigMethodConnectionEstablished HealthcheckEditParamsTcpConfigMethod = "connection_established" +) + +type HealthcheckEditResponseEnvelope struct { + Errors []HealthcheckEditResponseEnvelopeErrors `json:"errors,required"` + Messages []HealthcheckEditResponseEnvelopeMessages `json:"messages,required"` + Result HealthchecksHealthchecks `json:"result,required"` + // Whether the API call was successful + Success HealthcheckEditResponseEnvelopeSuccess `json:"success,required"` + JSON healthcheckEditResponseEnvelopeJSON `json:"-"` +} + +// healthcheckEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [HealthcheckEditResponseEnvelope] +type healthcheckEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HealthcheckEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON healthcheckEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// healthcheckEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [HealthcheckEditResponseEnvelopeErrors] +type healthcheckEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HealthcheckEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON healthcheckEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// healthcheckEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [HealthcheckEditResponseEnvelopeMessages] +type healthcheckEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HealthcheckEditResponseEnvelopeSuccess bool + +const ( + HealthcheckEditResponseEnvelopeSuccessTrue HealthcheckEditResponseEnvelopeSuccess = true +) + +type HealthcheckGetResponseEnvelope struct { + Errors []HealthcheckGetResponseEnvelopeErrors `json:"errors,required"` + Messages []HealthcheckGetResponseEnvelopeMessages `json:"messages,required"` + Result HealthchecksHealthchecks `json:"result,required"` + // Whether the API call was successful + Success HealthcheckGetResponseEnvelopeSuccess `json:"success,required"` + JSON healthcheckGetResponseEnvelopeJSON `json:"-"` +} + +// healthcheckGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [HealthcheckGetResponseEnvelope] +type healthcheckGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HealthcheckGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON healthcheckGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// healthcheckGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [HealthcheckGetResponseEnvelopeErrors] +type healthcheckGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HealthcheckGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON healthcheckGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// healthcheckGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [HealthcheckGetResponseEnvelopeMessages] +type healthcheckGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HealthcheckGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r healthcheckGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HealthcheckGetResponseEnvelopeSuccess bool + +const ( + HealthcheckGetResponseEnvelopeSuccessTrue HealthcheckGetResponseEnvelopeSuccess = true +) diff --git a/healthcheck_test.go b/healthchecks/healthcheck_test.go similarity index 82% rename from healthcheck_test.go rename to healthchecks/healthcheck_test.go index d111599aad5..6e52ad68d98 100644 --- a/healthcheck_test.go +++ b/healthchecks/healthcheck_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package healthchecks_test import ( "context" @@ -9,6 +9,7 @@ import ( "testing" "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/healthchecks" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" ) @@ -30,14 +31,14 @@ func TestHealthcheckNewWithOptionalParams(t *testing.T) { _, err := client.Healthchecks.New( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.HealthcheckNewParams{ + healthchecks.HealthcheckNewParams{ Address: cloudflare.F("www.example.com"), Name: cloudflare.F("server-1"), - CheckRegions: cloudflare.F([]cloudflare.HealthcheckNewParamsCheckRegion{cloudflare.HealthcheckNewParamsCheckRegionWeu, cloudflare.HealthcheckNewParamsCheckRegionEnam}), + CheckRegions: cloudflare.F([]healthchecks.HealthcheckNewParamsCheckRegion{healthchecks.HealthcheckNewParamsCheckRegionWeu, healthchecks.HealthcheckNewParamsCheckRegionEnam}), ConsecutiveFails: cloudflare.F(int64(0)), ConsecutiveSuccesses: cloudflare.F(int64(0)), Description: cloudflare.F("Health check for www.example.com"), - HTTPConfig: cloudflare.F(cloudflare.HealthcheckNewParamsHTTPConfig{ + HTTPConfig: cloudflare.F(healthchecks.HealthcheckNewParamsHTTPConfig{ AllowInsecure: cloudflare.F(true), ExpectedBody: cloudflare.F("success"), ExpectedCodes: cloudflare.F([]string{"2xx", "302"}), @@ -50,15 +51,15 @@ func TestHealthcheckNewWithOptionalParams(t *testing.T) { "0": "abc123", }, }), - Method: cloudflare.F(cloudflare.HealthcheckNewParamsHTTPConfigMethodGet), + Method: cloudflare.F(healthchecks.HealthcheckNewParamsHTTPConfigMethodGet), Path: cloudflare.F("/health"), Port: cloudflare.F(int64(0)), }), Interval: cloudflare.F(int64(0)), Retries: cloudflare.F(int64(0)), Suspended: cloudflare.F(true), - TcpConfig: cloudflare.F(cloudflare.HealthcheckNewParamsTcpConfig{ - Method: cloudflare.F(cloudflare.HealthcheckNewParamsTcpConfigMethodConnectionEstablished), + TcpConfig: cloudflare.F(healthchecks.HealthcheckNewParamsTcpConfig{ + Method: cloudflare.F(healthchecks.HealthcheckNewParamsTcpConfigMethodConnectionEstablished), Port: cloudflare.F(int64(0)), }), Timeout: cloudflare.F(int64(0)), @@ -92,14 +93,14 @@ func TestHealthcheckUpdateWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.HealthcheckUpdateParams{ + healthchecks.HealthcheckUpdateParams{ Address: cloudflare.F("www.example.com"), Name: cloudflare.F("server-1"), - CheckRegions: cloudflare.F([]cloudflare.HealthcheckUpdateParamsCheckRegion{cloudflare.HealthcheckUpdateParamsCheckRegionWeu, cloudflare.HealthcheckUpdateParamsCheckRegionEnam}), + CheckRegions: cloudflare.F([]healthchecks.HealthcheckUpdateParamsCheckRegion{healthchecks.HealthcheckUpdateParamsCheckRegionWeu, healthchecks.HealthcheckUpdateParamsCheckRegionEnam}), ConsecutiveFails: cloudflare.F(int64(0)), ConsecutiveSuccesses: cloudflare.F(int64(0)), Description: cloudflare.F("Health check for www.example.com"), - HTTPConfig: cloudflare.F(cloudflare.HealthcheckUpdateParamsHTTPConfig{ + HTTPConfig: cloudflare.F(healthchecks.HealthcheckUpdateParamsHTTPConfig{ AllowInsecure: cloudflare.F(true), ExpectedBody: cloudflare.F("success"), ExpectedCodes: cloudflare.F([]string{"2xx", "302"}), @@ -112,15 +113,15 @@ func TestHealthcheckUpdateWithOptionalParams(t *testing.T) { "0": "abc123", }, }), - Method: cloudflare.F(cloudflare.HealthcheckUpdateParamsHTTPConfigMethodGet), + Method: cloudflare.F(healthchecks.HealthcheckUpdateParamsHTTPConfigMethodGet), Path: cloudflare.F("/health"), Port: cloudflare.F(int64(0)), }), Interval: cloudflare.F(int64(0)), Retries: cloudflare.F(int64(0)), Suspended: cloudflare.F(true), - TcpConfig: cloudflare.F(cloudflare.HealthcheckUpdateParamsTcpConfig{ - Method: cloudflare.F(cloudflare.HealthcheckUpdateParamsTcpConfigMethodConnectionEstablished), + TcpConfig: cloudflare.F(healthchecks.HealthcheckUpdateParamsTcpConfig{ + Method: cloudflare.F(healthchecks.HealthcheckUpdateParamsTcpConfigMethodConnectionEstablished), Port: cloudflare.F(int64(0)), }), Timeout: cloudflare.F(int64(0)), @@ -206,14 +207,14 @@ func TestHealthcheckEditWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.HealthcheckEditParams{ + healthchecks.HealthcheckEditParams{ Address: cloudflare.F("www.example.com"), Name: cloudflare.F("server-1"), - CheckRegions: cloudflare.F([]cloudflare.HealthcheckEditParamsCheckRegion{cloudflare.HealthcheckEditParamsCheckRegionWeu, cloudflare.HealthcheckEditParamsCheckRegionEnam}), + CheckRegions: cloudflare.F([]healthchecks.HealthcheckEditParamsCheckRegion{healthchecks.HealthcheckEditParamsCheckRegionWeu, healthchecks.HealthcheckEditParamsCheckRegionEnam}), ConsecutiveFails: cloudflare.F(int64(0)), ConsecutiveSuccesses: cloudflare.F(int64(0)), Description: cloudflare.F("Health check for www.example.com"), - HTTPConfig: cloudflare.F(cloudflare.HealthcheckEditParamsHTTPConfig{ + HTTPConfig: cloudflare.F(healthchecks.HealthcheckEditParamsHTTPConfig{ AllowInsecure: cloudflare.F(true), ExpectedBody: cloudflare.F("success"), ExpectedCodes: cloudflare.F([]string{"2xx", "302"}), @@ -226,15 +227,15 @@ func TestHealthcheckEditWithOptionalParams(t *testing.T) { "0": "abc123", }, }), - Method: cloudflare.F(cloudflare.HealthcheckEditParamsHTTPConfigMethodGet), + Method: cloudflare.F(healthchecks.HealthcheckEditParamsHTTPConfigMethodGet), Path: cloudflare.F("/health"), Port: cloudflare.F(int64(0)), }), Interval: cloudflare.F(int64(0)), Retries: cloudflare.F(int64(0)), Suspended: cloudflare.F(true), - TcpConfig: cloudflare.F(cloudflare.HealthcheckEditParamsTcpConfig{ - Method: cloudflare.F(cloudflare.HealthcheckEditParamsTcpConfigMethodConnectionEstablished), + TcpConfig: cloudflare.F(healthchecks.HealthcheckEditParamsTcpConfig{ + Method: cloudflare.F(healthchecks.HealthcheckEditParamsTcpConfigMethodConnectionEstablished), Port: cloudflare.F(int64(0)), }), Timeout: cloudflare.F(int64(0)), diff --git a/healthchecks/preview.go b/healthchecks/preview.go new file mode 100644 index 00000000000..3545965486c --- /dev/null +++ b/healthchecks/preview.go @@ -0,0 +1,455 @@ +// File generated from our OpenAPI spec by Stainless. + +package healthchecks + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// PreviewService 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 [NewPreviewService] method instead. +type PreviewService struct { + Options []option.RequestOption +} + +// NewPreviewService 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 NewPreviewService(opts ...option.RequestOption) (r *PreviewService) { + r = &PreviewService{} + r.Options = opts + return +} + +// Create a new preview health check. +func (r *PreviewService) New(ctx context.Context, zoneIdentifier string, body PreviewNewParams, opts ...option.RequestOption) (res *HealthchecksHealthchecks, err error) { + opts = append(r.Options[:], opts...) + var env PreviewNewResponseEnvelope + path := fmt.Sprintf("zones/%s/healthchecks/preview", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a health check. +func (r *PreviewService) Delete(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *PreviewDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env PreviewDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/healthchecks/preview/%s", zoneIdentifier, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch a single configured health check preview. +func (r *PreviewService) Get(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *HealthchecksHealthchecks, err error) { + opts = append(r.Options[:], opts...) + var env PreviewGetResponseEnvelope + path := fmt.Sprintf("zones/%s/healthchecks/preview/%s", zoneIdentifier, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type PreviewDeleteResponse struct { + // Identifier + ID string `json:"id"` + JSON previewDeleteResponseJSON `json:"-"` +} + +// previewDeleteResponseJSON contains the JSON metadata for the struct +// [PreviewDeleteResponse] +type previewDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PreviewDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r previewDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type PreviewNewParams struct { + // The hostname or IP address of the origin server to run health checks on. + Address param.Field[string] `json:"address,required"` + // A short name to identify the health check. Only alphanumeric characters, hyphens + // and underscores are allowed. + Name param.Field[string] `json:"name,required"` + // A list of regions from which to run health checks. Null means Cloudflare will + // pick a default region. + CheckRegions param.Field[[]PreviewNewParamsCheckRegion] `json:"check_regions"` + // The number of consecutive fails required from a health check before changing the + // health to unhealthy. + ConsecutiveFails param.Field[int64] `json:"consecutive_fails"` + // The number of consecutive successes required from a health check before changing + // the health to healthy. + ConsecutiveSuccesses param.Field[int64] `json:"consecutive_successes"` + // A human-readable description of the health check. + Description param.Field[string] `json:"description"` + // Parameters specific to an HTTP or HTTPS health check. + HTTPConfig param.Field[PreviewNewParamsHTTPConfig] `json:"http_config"` + // The interval between each health check. Shorter intervals may give quicker + // notifications if the origin status changes, but will increase load on the origin + // as we check from multiple locations. + Interval param.Field[int64] `json:"interval"` + // The number of retries to attempt in case of a timeout before marking the origin + // as unhealthy. Retries are attempted immediately. + Retries param.Field[int64] `json:"retries"` + // If suspended, no health checks are sent to the origin. + Suspended param.Field[bool] `json:"suspended"` + // Parameters specific to TCP health check. + TcpConfig param.Field[PreviewNewParamsTcpConfig] `json:"tcp_config"` + // The timeout (in seconds) before marking the health check as failed. + Timeout param.Field[int64] `json:"timeout"` + // The protocol to use for the health check. Currently supported protocols are + // 'HTTP', 'HTTPS' and 'TCP'. + Type param.Field[string] `json:"type"` +} + +func (r PreviewNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, +// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, +// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, IN: India, +// SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all regions (BUSINESS +// and ENTERPRISE customers only). +type PreviewNewParamsCheckRegion string + +const ( + PreviewNewParamsCheckRegionWnam PreviewNewParamsCheckRegion = "WNAM" + PreviewNewParamsCheckRegionEnam PreviewNewParamsCheckRegion = "ENAM" + PreviewNewParamsCheckRegionWeu PreviewNewParamsCheckRegion = "WEU" + PreviewNewParamsCheckRegionEeu PreviewNewParamsCheckRegion = "EEU" + PreviewNewParamsCheckRegionNsam PreviewNewParamsCheckRegion = "NSAM" + PreviewNewParamsCheckRegionSsam PreviewNewParamsCheckRegion = "SSAM" + PreviewNewParamsCheckRegionOc PreviewNewParamsCheckRegion = "OC" + PreviewNewParamsCheckRegionMe PreviewNewParamsCheckRegion = "ME" + PreviewNewParamsCheckRegionNaf PreviewNewParamsCheckRegion = "NAF" + PreviewNewParamsCheckRegionSaf PreviewNewParamsCheckRegion = "SAF" + PreviewNewParamsCheckRegionIn PreviewNewParamsCheckRegion = "IN" + PreviewNewParamsCheckRegionSeas PreviewNewParamsCheckRegion = "SEAS" + PreviewNewParamsCheckRegionNeas PreviewNewParamsCheckRegion = "NEAS" + PreviewNewParamsCheckRegionAllRegions PreviewNewParamsCheckRegion = "ALL_REGIONS" +) + +// Parameters specific to an HTTP or HTTPS health check. +type PreviewNewParamsHTTPConfig struct { + // Do not validate the certificate when the health check uses HTTPS. + AllowInsecure param.Field[bool] `json:"allow_insecure"` + // A case-insensitive sub-string to look for in the response body. If this string + // is not found, the origin will be marked as unhealthy. + ExpectedBody param.Field[string] `json:"expected_body"` + // The expected HTTP response codes (e.g. "200") or code ranges (e.g. "2xx" for all + // codes starting with 2) of the health check. + ExpectedCodes param.Field[[]string] `json:"expected_codes"` + // Follow redirects if the origin returns a 3xx status code. + FollowRedirects param.Field[bool] `json:"follow_redirects"` + // The HTTP request headers to send in the health check. It is recommended you set + // a Host header by default. The User-Agent header cannot be overridden. + Header param.Field[interface{}] `json:"header"` + // The HTTP method to use for the health check. + Method param.Field[PreviewNewParamsHTTPConfigMethod] `json:"method"` + // The endpoint path to health check against. + Path param.Field[string] `json:"path"` + // Port number to connect to for the health check. Defaults to 80 if type is HTTP + // or 443 if type is HTTPS. + Port param.Field[int64] `json:"port"` +} + +func (r PreviewNewParamsHTTPConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The HTTP method to use for the health check. +type PreviewNewParamsHTTPConfigMethod string + +const ( + PreviewNewParamsHTTPConfigMethodGet PreviewNewParamsHTTPConfigMethod = "GET" + PreviewNewParamsHTTPConfigMethodHead PreviewNewParamsHTTPConfigMethod = "HEAD" +) + +// Parameters specific to TCP health check. +type PreviewNewParamsTcpConfig struct { + // The TCP connection method to use for the health check. + Method param.Field[PreviewNewParamsTcpConfigMethod] `json:"method"` + // Port number to connect to for the health check. Defaults to 80. + Port param.Field[int64] `json:"port"` +} + +func (r PreviewNewParamsTcpConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The TCP connection method to use for the health check. +type PreviewNewParamsTcpConfigMethod string + +const ( + PreviewNewParamsTcpConfigMethodConnectionEstablished PreviewNewParamsTcpConfigMethod = "connection_established" +) + +type PreviewNewResponseEnvelope struct { + Errors []PreviewNewResponseEnvelopeErrors `json:"errors,required"` + Messages []PreviewNewResponseEnvelopeMessages `json:"messages,required"` + Result HealthchecksHealthchecks `json:"result,required"` + // Whether the API call was successful + Success PreviewNewResponseEnvelopeSuccess `json:"success,required"` + JSON previewNewResponseEnvelopeJSON `json:"-"` +} + +// previewNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [PreviewNewResponseEnvelope] +type previewNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PreviewNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r previewNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PreviewNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON previewNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// previewNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PreviewNewResponseEnvelopeErrors] +type previewNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PreviewNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r previewNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PreviewNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON previewNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// previewNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PreviewNewResponseEnvelopeMessages] +type previewNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PreviewNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r previewNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PreviewNewResponseEnvelopeSuccess bool + +const ( + PreviewNewResponseEnvelopeSuccessTrue PreviewNewResponseEnvelopeSuccess = true +) + +type PreviewDeleteResponseEnvelope struct { + Errors []PreviewDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []PreviewDeleteResponseEnvelopeMessages `json:"messages,required"` + Result PreviewDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success PreviewDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON previewDeleteResponseEnvelopeJSON `json:"-"` +} + +// previewDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [PreviewDeleteResponseEnvelope] +type previewDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PreviewDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r previewDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PreviewDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON previewDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// previewDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [PreviewDeleteResponseEnvelopeErrors] +type previewDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PreviewDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r previewDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PreviewDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON previewDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// previewDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [PreviewDeleteResponseEnvelopeMessages] +type previewDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PreviewDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r previewDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PreviewDeleteResponseEnvelopeSuccess bool + +const ( + PreviewDeleteResponseEnvelopeSuccessTrue PreviewDeleteResponseEnvelopeSuccess = true +) + +type PreviewGetResponseEnvelope struct { + Errors []PreviewGetResponseEnvelopeErrors `json:"errors,required"` + Messages []PreviewGetResponseEnvelopeMessages `json:"messages,required"` + Result HealthchecksHealthchecks `json:"result,required"` + // Whether the API call was successful + Success PreviewGetResponseEnvelopeSuccess `json:"success,required"` + JSON previewGetResponseEnvelopeJSON `json:"-"` +} + +// previewGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [PreviewGetResponseEnvelope] +type previewGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PreviewGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r previewGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PreviewGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON previewGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// previewGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PreviewGetResponseEnvelopeErrors] +type previewGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PreviewGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r previewGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PreviewGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON previewGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// previewGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PreviewGetResponseEnvelopeMessages] +type previewGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PreviewGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r previewGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PreviewGetResponseEnvelopeSuccess bool + +const ( + PreviewGetResponseEnvelopeSuccessTrue PreviewGetResponseEnvelopeSuccess = true +) diff --git a/healthchecks/preview_test.go b/healthchecks/preview_test.go new file mode 100644 index 00000000000..1e701ac27ea --- /dev/null +++ b/healthchecks/preview_test.go @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. + +package healthchecks_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/healthchecks" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestPreviewNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Healthchecks.Previews.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + healthchecks.PreviewNewParams{ + Address: cloudflare.F("www.example.com"), + Name: cloudflare.F("server-1"), + CheckRegions: cloudflare.F([]healthchecks.PreviewNewParamsCheckRegion{healthchecks.PreviewNewParamsCheckRegionWeu, healthchecks.PreviewNewParamsCheckRegionEnam}), + ConsecutiveFails: cloudflare.F(int64(0)), + ConsecutiveSuccesses: cloudflare.F(int64(0)), + Description: cloudflare.F("Health check for www.example.com"), + HTTPConfig: cloudflare.F(healthchecks.PreviewNewParamsHTTPConfig{ + AllowInsecure: cloudflare.F(true), + ExpectedBody: cloudflare.F("success"), + ExpectedCodes: cloudflare.F([]string{"2xx", "302"}), + FollowRedirects: cloudflare.F(true), + Header: cloudflare.F[any](map[string]interface{}{ + "Host": map[string]interface{}{ + "0": "example.com", + }, + "X-App-ID": map[string]interface{}{ + "0": "abc123", + }, + }), + Method: cloudflare.F(healthchecks.PreviewNewParamsHTTPConfigMethodGet), + Path: cloudflare.F("/health"), + Port: cloudflare.F(int64(0)), + }), + Interval: cloudflare.F(int64(0)), + Retries: cloudflare.F(int64(0)), + Suspended: cloudflare.F(true), + TcpConfig: cloudflare.F(healthchecks.PreviewNewParamsTcpConfig{ + Method: cloudflare.F(healthchecks.PreviewNewParamsTcpConfigMethodConnectionEstablished), + Port: cloudflare.F(int64(0)), + }), + Timeout: cloudflare.F(int64(0)), + Type: cloudflare.F("HTTPS"), + }, + ) + 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 TestPreviewDelete(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("user@example.com"), + ) + _, err := client.Healthchecks.Previews.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "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()) + } +} + +func TestPreviewGet(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("user@example.com"), + ) + _, err := client.Healthchecks.Previews.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "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/hostname.go b/hostname.go deleted file mode 100644 index 7cad7428163..00000000000 --- a/hostname.go +++ /dev/null @@ -1,26 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// HostnameService 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 [NewHostnameService] method instead. -type HostnameService struct { - Options []option.RequestOption - Settings *HostnameSettingService -} - -// NewHostnameService 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 NewHostnameService(opts ...option.RequestOption) (r *HostnameService) { - r = &HostnameService{} - r.Options = opts - r.Settings = NewHostnameSettingService(opts...) - return -} diff --git a/hostnames/aliases.go b/hostnames/aliases.go new file mode 100644 index 00000000000..2cb001a3093 --- /dev/null +++ b/hostnames/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package hostnames + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/hostnames/hostname.go b/hostnames/hostname.go new file mode 100644 index 00000000000..c60c58541c9 --- /dev/null +++ b/hostnames/hostname.go @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package hostnames + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// HostnameService 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 [NewHostnameService] method instead. +type HostnameService struct { + Options []option.RequestOption + Settings *SettingService +} + +// NewHostnameService 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 NewHostnameService(opts ...option.RequestOption) (r *HostnameService) { + r = &HostnameService{} + r.Options = opts + r.Settings = NewSettingService(opts...) + return +} diff --git a/hostnames/setting.go b/hostnames/setting.go new file mode 100644 index 00000000000..cdfc677614c --- /dev/null +++ b/hostnames/setting.go @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package hostnames + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingService 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 [NewSettingService] method instead. +type SettingService struct { + Options []option.RequestOption + TLS *SettingTLSService +} + +// NewSettingService 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 NewSettingService(opts ...option.RequestOption) (r *SettingService) { + r = &SettingService{} + r.Options = opts + r.TLS = NewSettingTLSService(opts...) + return +} diff --git a/hostnames/settingtls.go b/hostnames/settingtls.go new file mode 100644 index 00000000000..9bb7fdeb1a2 --- /dev/null +++ b/hostnames/settingtls.go @@ -0,0 +1,576 @@ +// File generated from our OpenAPI spec by Stainless. + +package hostnames + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// SettingTLSService 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 [NewSettingTLSService] method instead. +type SettingTLSService struct { + Options []option.RequestOption +} + +// NewSettingTLSService 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 NewSettingTLSService(opts ...option.RequestOption) (r *SettingTLSService) { + r = &SettingTLSService{} + r.Options = opts + return +} + +// Update the tls setting value for the hostname. +func (r *SettingTLSService) Update(ctx context.Context, settingID SettingTLSUpdateParamsSettingID, hostname string, params SettingTLSUpdateParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesSettingObject, err error) { + opts = append(r.Options[:], opts...) + var env SettingTLSUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/hostnames/settings/%v/%s", params.ZoneID, settingID, hostname) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete the tls setting value for the hostname. +func (r *SettingTLSService) Delete(ctx context.Context, settingID SettingTLSDeleteParamsSettingID, hostname string, body SettingTLSDeleteParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesSettingObjectDelete, err error) { + opts = append(r.Options[:], opts...) + var env SettingTLSDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/hostnames/settings/%v/%s", body.ZoneID, settingID, hostname) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List the requested TLS setting for the hostnames under this zone. +func (r *SettingTLSService) Get(ctx context.Context, settingID SettingTLSGetParamsSettingID, query SettingTLSGetParams, opts ...option.RequestOption) (res *[]SettingTLSGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env SettingTLSGetResponseEnvelope + path := fmt.Sprintf("zones/%s/hostnames/settings/%v", query.ZoneID, settingID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TLSCertificatesAndHostnamesSettingObject struct { + // This is the time the tls setting was originally created for this hostname. + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The hostname for which the tls settings are set. + Hostname string `json:"hostname"` + // Deployment status for the given tls setting. + Status string `json:"status"` + // This is the time the tls setting was updated. + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + // The tls setting value. + Value TLSCertificatesAndHostnamesSettingObjectValue `json:"value"` + JSON tlsCertificatesAndHostnamesSettingObjectJSON `json:"-"` +} + +// tlsCertificatesAndHostnamesSettingObjectJSON contains the JSON metadata for the +// struct [TLSCertificatesAndHostnamesSettingObject] +type tlsCertificatesAndHostnamesSettingObjectJSON struct { + CreatedAt apijson.Field + Hostname apijson.Field + Status apijson.Field + UpdatedAt apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TLSCertificatesAndHostnamesSettingObject) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tlsCertificatesAndHostnamesSettingObjectJSON) RawJSON() string { + return r.raw +} + +// The tls setting value. +// +// Union satisfied by [shared.UnionFloat], [shared.UnionString] or +// [hostnames.TLSCertificatesAndHostnamesSettingObjectValueArray]. +type TLSCertificatesAndHostnamesSettingObjectValue interface { + ImplementsHostnamesTLSCertificatesAndHostnamesSettingObjectValue() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*TLSCertificatesAndHostnamesSettingObjectValue)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TLSCertificatesAndHostnamesSettingObjectValueArray{}), + }, + ) +} + +type TLSCertificatesAndHostnamesSettingObjectValueArray []string + +func (r TLSCertificatesAndHostnamesSettingObjectValueArray) ImplementsHostnamesTLSCertificatesAndHostnamesSettingObjectValue() { +} + +type TLSCertificatesAndHostnamesSettingObjectDelete struct { + // This is the time the tls setting was originally created for this hostname. + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The hostname for which the tls settings are set. + Hostname string `json:"hostname"` + Status interface{} `json:"status"` + // This is the time the tls setting was updated. + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + Value interface{} `json:"value"` + JSON tlsCertificatesAndHostnamesSettingObjectDeleteJSON `json:"-"` +} + +// tlsCertificatesAndHostnamesSettingObjectDeleteJSON contains the JSON metadata +// for the struct [TLSCertificatesAndHostnamesSettingObjectDelete] +type tlsCertificatesAndHostnamesSettingObjectDeleteJSON struct { + CreatedAt apijson.Field + Hostname apijson.Field + Status apijson.Field + UpdatedAt apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TLSCertificatesAndHostnamesSettingObjectDelete) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tlsCertificatesAndHostnamesSettingObjectDeleteJSON) RawJSON() string { + return r.raw +} + +type SettingTLSGetResponse struct { + // This is the time the tls setting was originally created for this hostname. + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The hostname for which the tls settings are set. + Hostname string `json:"hostname"` + // Deployment status for the given tls setting. + Status string `json:"status"` + // This is the time the tls setting was updated. + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + // The tls setting value. + Value SettingTLSGetResponseValue `json:"value"` + JSON settingTLSGetResponseJSON `json:"-"` +} + +// settingTLSGetResponseJSON contains the JSON metadata for the struct +// [SettingTLSGetResponse] +type settingTLSGetResponseJSON struct { + CreatedAt apijson.Field + Hostname apijson.Field + Status apijson.Field + UpdatedAt apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTLSGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTLSGetResponseJSON) RawJSON() string { + return r.raw +} + +// The tls setting value. +// +// Union satisfied by [shared.UnionFloat], [shared.UnionString] or +// [hostnames.SettingTLSGetResponseValueArray]. +type SettingTLSGetResponseValue interface { + ImplementsHostnamesSettingTLSGetResponseValue() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*SettingTLSGetResponseValue)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SettingTLSGetResponseValueArray{}), + }, + ) +} + +type SettingTLSGetResponseValueArray []string + +func (r SettingTLSGetResponseValueArray) ImplementsHostnamesSettingTLSGetResponseValue() {} + +type SettingTLSUpdateParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // The tls setting value. + Value param.Field[SettingTLSUpdateParamsValue] `json:"value,required"` +} + +func (r SettingTLSUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The TLS Setting name. +type SettingTLSUpdateParamsSettingID string + +const ( + SettingTLSUpdateParamsSettingIDCiphers SettingTLSUpdateParamsSettingID = "ciphers" + SettingTLSUpdateParamsSettingIDMinTLSVersion SettingTLSUpdateParamsSettingID = "min_tls_version" + SettingTLSUpdateParamsSettingIDHTTP2 SettingTLSUpdateParamsSettingID = "http2" +) + +// The tls setting value. +// +// Satisfied by [shared.UnionFloat], [shared.UnionString], +// [hostnames.SettingTLSUpdateParamsValueArray]. +type SettingTLSUpdateParamsValue interface { + ImplementsHostnamesSettingTLSUpdateParamsValue() +} + +type SettingTLSUpdateParamsValueArray []string + +func (r SettingTLSUpdateParamsValueArray) ImplementsHostnamesSettingTLSUpdateParamsValue() {} + +type SettingTLSUpdateResponseEnvelope struct { + Errors []SettingTLSUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingTLSUpdateResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesSettingObject `json:"result,required"` + // Whether the API call was successful + Success SettingTLSUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON settingTLSUpdateResponseEnvelopeJSON `json:"-"` +} + +// settingTLSUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingTLSUpdateResponseEnvelope] +type settingTLSUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTLSUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTLSUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingTLSUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingTLSUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingTLSUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingTLSUpdateResponseEnvelopeErrors] +type settingTLSUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTLSUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTLSUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingTLSUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingTLSUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingTLSUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingTLSUpdateResponseEnvelopeMessages] +type settingTLSUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTLSUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTLSUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SettingTLSUpdateResponseEnvelopeSuccess bool + +const ( + SettingTLSUpdateResponseEnvelopeSuccessTrue SettingTLSUpdateResponseEnvelopeSuccess = true +) + +type SettingTLSDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +// The TLS Setting name. +type SettingTLSDeleteParamsSettingID string + +const ( + SettingTLSDeleteParamsSettingIDCiphers SettingTLSDeleteParamsSettingID = "ciphers" + SettingTLSDeleteParamsSettingIDMinTLSVersion SettingTLSDeleteParamsSettingID = "min_tls_version" + SettingTLSDeleteParamsSettingIDHTTP2 SettingTLSDeleteParamsSettingID = "http2" +) + +type SettingTLSDeleteResponseEnvelope struct { + Errors []SettingTLSDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingTLSDeleteResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesSettingObjectDelete `json:"result,required"` + // Whether the API call was successful + Success SettingTLSDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON settingTLSDeleteResponseEnvelopeJSON `json:"-"` +} + +// settingTLSDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingTLSDeleteResponseEnvelope] +type settingTLSDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTLSDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTLSDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingTLSDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingTLSDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingTLSDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingTLSDeleteResponseEnvelopeErrors] +type settingTLSDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTLSDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTLSDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingTLSDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingTLSDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingTLSDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingTLSDeleteResponseEnvelopeMessages] +type settingTLSDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTLSDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTLSDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SettingTLSDeleteResponseEnvelopeSuccess bool + +const ( + SettingTLSDeleteResponseEnvelopeSuccessTrue SettingTLSDeleteResponseEnvelopeSuccess = true +) + +type SettingTLSGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +// The TLS Setting name. +type SettingTLSGetParamsSettingID string + +const ( + SettingTLSGetParamsSettingIDCiphers SettingTLSGetParamsSettingID = "ciphers" + SettingTLSGetParamsSettingIDMinTLSVersion SettingTLSGetParamsSettingID = "min_tls_version" + SettingTLSGetParamsSettingIDHTTP2 SettingTLSGetParamsSettingID = "http2" +) + +type SettingTLSGetResponseEnvelope struct { + Errors []SettingTLSGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingTLSGetResponseEnvelopeMessages `json:"messages,required"` + Result []SettingTLSGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success SettingTLSGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo SettingTLSGetResponseEnvelopeResultInfo `json:"result_info"` + JSON settingTLSGetResponseEnvelopeJSON `json:"-"` +} + +// settingTLSGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingTLSGetResponseEnvelope] +type settingTLSGetResponseEnvelopeJSON 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 *SettingTLSGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTLSGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingTLSGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingTLSGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingTLSGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingTLSGetResponseEnvelopeErrors] +type settingTLSGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTLSGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTLSGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingTLSGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingTLSGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingTLSGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingTLSGetResponseEnvelopeMessages] +type settingTLSGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTLSGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTLSGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SettingTLSGetResponseEnvelopeSuccess bool + +const ( + SettingTLSGetResponseEnvelopeSuccessTrue SettingTLSGetResponseEnvelopeSuccess = true +) + +type SettingTLSGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + // Total pages available of results + TotalPages float64 `json:"total_pages"` + JSON settingTLSGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// settingTLSGetResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [SettingTLSGetResponseEnvelopeResultInfo] +type settingTLSGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + TotalPages apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTLSGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTLSGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/hostnames/settingtls_test.go b/hostnames/settingtls_test.go new file mode 100644 index 00000000000..3870d2179c6 --- /dev/null +++ b/hostnames/settingtls_test.go @@ -0,0 +1,108 @@ +// File generated from our OpenAPI spec by Stainless. + +package hostnames_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/hostnames" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestSettingTLSUpdate(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("user@example.com"), + ) + _, err := client.Hostnames.Settings.TLS.Update( + context.TODO(), + hostnames.SettingTLSUpdateParamsSettingIDCiphers, + "app.example.com", + hostnames.SettingTLSUpdateParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F[hostnames.SettingTLSUpdateParamsValue](hostnames.SettingTLSUpdateParamsValueArray([]string{"ECDHE-RSA-AES128-GCM-SHA256", "AES128-GCM-SHA256"})), + }, + ) + 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 TestSettingTLSDelete(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("user@example.com"), + ) + _, err := client.Hostnames.Settings.TLS.Delete( + context.TODO(), + hostnames.SettingTLSDeleteParamsSettingIDCiphers, + "app.example.com", + hostnames.SettingTLSDeleteParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestSettingTLSGet(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("user@example.com"), + ) + _, err := client.Hostnames.Settings.TLS.Get( + context.TODO(), + hostnames.SettingTLSGetParamsSettingIDCiphers, + hostnames.SettingTLSGetParams{ + ZoneID: cloudflare.F("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/hostnamesetting.go b/hostnamesetting.go deleted file mode 100644 index cd05f6a2700..00000000000 --- a/hostnamesetting.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// HostnameSettingService 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 [NewHostnameSettingService] method -// instead. -type HostnameSettingService struct { - Options []option.RequestOption - TLS *HostnameSettingTLSService -} - -// NewHostnameSettingService 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 NewHostnameSettingService(opts ...option.RequestOption) (r *HostnameSettingService) { - r = &HostnameSettingService{} - r.Options = opts - r.TLS = NewHostnameSettingTLSService(opts...) - return -} diff --git a/hostnamesettingtls.go b/hostnamesettingtls.go deleted file mode 100644 index 8457e6b6cba..00000000000 --- a/hostnamesettingtls.go +++ /dev/null @@ -1,577 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// HostnameSettingTLSService 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 [NewHostnameSettingTLSService] method -// instead. -type HostnameSettingTLSService struct { - Options []option.RequestOption -} - -// NewHostnameSettingTLSService 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 NewHostnameSettingTLSService(opts ...option.RequestOption) (r *HostnameSettingTLSService) { - r = &HostnameSettingTLSService{} - r.Options = opts - return -} - -// Update the tls setting value for the hostname. -func (r *HostnameSettingTLSService) Update(ctx context.Context, settingID HostnameSettingTLSUpdateParamsSettingID, hostname string, params HostnameSettingTLSUpdateParams, opts ...option.RequestOption) (res *HostnameSettingTLSUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env HostnameSettingTLSUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/hostnames/settings/%v/%s", params.ZoneID, settingID, hostname) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete the tls setting value for the hostname. -func (r *HostnameSettingTLSService) Delete(ctx context.Context, settingID HostnameSettingTLSDeleteParamsSettingID, hostname string, body HostnameSettingTLSDeleteParams, opts ...option.RequestOption) (res *HostnameSettingTLSDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env HostnameSettingTLSDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/hostnames/settings/%v/%s", body.ZoneID, settingID, hostname) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List the requested TLS setting for the hostnames under this zone. -func (r *HostnameSettingTLSService) Get(ctx context.Context, settingID HostnameSettingTLSGetParamsSettingID, query HostnameSettingTLSGetParams, opts ...option.RequestOption) (res *[]HostnameSettingTLSGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env HostnameSettingTLSGetResponseEnvelope - path := fmt.Sprintf("zones/%s/hostnames/settings/%v", query.ZoneID, settingID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type HostnameSettingTLSUpdateResponse struct { - // This is the time the tls setting was originally created for this hostname. - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The hostname for which the tls settings are set. - Hostname string `json:"hostname"` - // Deployment status for the given tls setting. - Status string `json:"status"` - // This is the time the tls setting was updated. - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - // The tls setting value. - Value HostnameSettingTLSUpdateResponseValue `json:"value"` - JSON hostnameSettingTLSUpdateResponseJSON `json:"-"` -} - -// hostnameSettingTLSUpdateResponseJSON contains the JSON metadata for the struct -// [HostnameSettingTLSUpdateResponse] -type hostnameSettingTLSUpdateResponseJSON struct { - CreatedAt apijson.Field - Hostname apijson.Field - Status apijson.Field - UpdatedAt apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameSettingTLSUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameSettingTLSUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// The tls setting value. -// -// Union satisfied by [shared.UnionFloat], [shared.UnionString] or -// [HostnameSettingTLSUpdateResponseValueArray]. -type HostnameSettingTLSUpdateResponseValue interface { - ImplementsHostnameSettingTLSUpdateResponseValue() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*HostnameSettingTLSUpdateResponseValue)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(HostnameSettingTLSUpdateResponseValueArray{}), - }, - ) -} - -type HostnameSettingTLSUpdateResponseValueArray []string - -func (r HostnameSettingTLSUpdateResponseValueArray) ImplementsHostnameSettingTLSUpdateResponseValue() { -} - -type HostnameSettingTLSDeleteResponse struct { - // This is the time the tls setting was originally created for this hostname. - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The hostname for which the tls settings are set. - Hostname string `json:"hostname"` - Status interface{} `json:"status"` - // This is the time the tls setting was updated. - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - Value interface{} `json:"value"` - JSON hostnameSettingTLSDeleteResponseJSON `json:"-"` -} - -// hostnameSettingTLSDeleteResponseJSON contains the JSON metadata for the struct -// [HostnameSettingTLSDeleteResponse] -type hostnameSettingTLSDeleteResponseJSON struct { - CreatedAt apijson.Field - Hostname apijson.Field - Status apijson.Field - UpdatedAt apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameSettingTLSDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameSettingTLSDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type HostnameSettingTLSGetResponse struct { - // This is the time the tls setting was originally created for this hostname. - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The hostname for which the tls settings are set. - Hostname string `json:"hostname"` - // Deployment status for the given tls setting. - Status string `json:"status"` - // This is the time the tls setting was updated. - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - // The tls setting value. - Value HostnameSettingTLSGetResponseValue `json:"value"` - JSON hostnameSettingTLSGetResponseJSON `json:"-"` -} - -// hostnameSettingTLSGetResponseJSON contains the JSON metadata for the struct -// [HostnameSettingTLSGetResponse] -type hostnameSettingTLSGetResponseJSON struct { - CreatedAt apijson.Field - Hostname apijson.Field - Status apijson.Field - UpdatedAt apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameSettingTLSGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameSettingTLSGetResponseJSON) RawJSON() string { - return r.raw -} - -// The tls setting value. -// -// Union satisfied by [shared.UnionFloat], [shared.UnionString] or -// [HostnameSettingTLSGetResponseValueArray]. -type HostnameSettingTLSGetResponseValue interface { - ImplementsHostnameSettingTLSGetResponseValue() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*HostnameSettingTLSGetResponseValue)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionFloat(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(HostnameSettingTLSGetResponseValueArray{}), - }, - ) -} - -type HostnameSettingTLSGetResponseValueArray []string - -func (r HostnameSettingTLSGetResponseValueArray) ImplementsHostnameSettingTLSGetResponseValue() {} - -type HostnameSettingTLSUpdateParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // The tls setting value. - Value param.Field[HostnameSettingTLSUpdateParamsValue] `json:"value,required"` -} - -func (r HostnameSettingTLSUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The TLS Setting name. -type HostnameSettingTLSUpdateParamsSettingID string - -const ( - HostnameSettingTLSUpdateParamsSettingIDCiphers HostnameSettingTLSUpdateParamsSettingID = "ciphers" - HostnameSettingTLSUpdateParamsSettingIDMinTLSVersion HostnameSettingTLSUpdateParamsSettingID = "min_tls_version" - HostnameSettingTLSUpdateParamsSettingIDHTTP2 HostnameSettingTLSUpdateParamsSettingID = "http2" -) - -// The tls setting value. -// -// Satisfied by [shared.UnionFloat], [shared.UnionString], -// [HostnameSettingTLSUpdateParamsValueArray]. -type HostnameSettingTLSUpdateParamsValue interface { - ImplementsHostnameSettingTLSUpdateParamsValue() -} - -type HostnameSettingTLSUpdateParamsValueArray []string - -func (r HostnameSettingTLSUpdateParamsValueArray) ImplementsHostnameSettingTLSUpdateParamsValue() {} - -type HostnameSettingTLSUpdateResponseEnvelope struct { - Errors []HostnameSettingTLSUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameSettingTLSUpdateResponseEnvelopeMessages `json:"messages,required"` - Result HostnameSettingTLSUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success HostnameSettingTLSUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON hostnameSettingTLSUpdateResponseEnvelopeJSON `json:"-"` -} - -// hostnameSettingTLSUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [HostnameSettingTLSUpdateResponseEnvelope] -type hostnameSettingTLSUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameSettingTLSUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameSettingTLSUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HostnameSettingTLSUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameSettingTLSUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameSettingTLSUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [HostnameSettingTLSUpdateResponseEnvelopeErrors] -type hostnameSettingTLSUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameSettingTLSUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameSettingTLSUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameSettingTLSUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameSettingTLSUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameSettingTLSUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [HostnameSettingTLSUpdateResponseEnvelopeMessages] -type hostnameSettingTLSUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameSettingTLSUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameSettingTLSUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HostnameSettingTLSUpdateResponseEnvelopeSuccess bool - -const ( - HostnameSettingTLSUpdateResponseEnvelopeSuccessTrue HostnameSettingTLSUpdateResponseEnvelopeSuccess = true -) - -type HostnameSettingTLSDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -// The TLS Setting name. -type HostnameSettingTLSDeleteParamsSettingID string - -const ( - HostnameSettingTLSDeleteParamsSettingIDCiphers HostnameSettingTLSDeleteParamsSettingID = "ciphers" - HostnameSettingTLSDeleteParamsSettingIDMinTLSVersion HostnameSettingTLSDeleteParamsSettingID = "min_tls_version" - HostnameSettingTLSDeleteParamsSettingIDHTTP2 HostnameSettingTLSDeleteParamsSettingID = "http2" -) - -type HostnameSettingTLSDeleteResponseEnvelope struct { - Errors []HostnameSettingTLSDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameSettingTLSDeleteResponseEnvelopeMessages `json:"messages,required"` - Result HostnameSettingTLSDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success HostnameSettingTLSDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON hostnameSettingTLSDeleteResponseEnvelopeJSON `json:"-"` -} - -// hostnameSettingTLSDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [HostnameSettingTLSDeleteResponseEnvelope] -type hostnameSettingTLSDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameSettingTLSDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameSettingTLSDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HostnameSettingTLSDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameSettingTLSDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameSettingTLSDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [HostnameSettingTLSDeleteResponseEnvelopeErrors] -type hostnameSettingTLSDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameSettingTLSDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameSettingTLSDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameSettingTLSDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameSettingTLSDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameSettingTLSDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [HostnameSettingTLSDeleteResponseEnvelopeMessages] -type hostnameSettingTLSDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameSettingTLSDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameSettingTLSDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HostnameSettingTLSDeleteResponseEnvelopeSuccess bool - -const ( - HostnameSettingTLSDeleteResponseEnvelopeSuccessTrue HostnameSettingTLSDeleteResponseEnvelopeSuccess = true -) - -type HostnameSettingTLSGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -// The TLS Setting name. -type HostnameSettingTLSGetParamsSettingID string - -const ( - HostnameSettingTLSGetParamsSettingIDCiphers HostnameSettingTLSGetParamsSettingID = "ciphers" - HostnameSettingTLSGetParamsSettingIDMinTLSVersion HostnameSettingTLSGetParamsSettingID = "min_tls_version" - HostnameSettingTLSGetParamsSettingIDHTTP2 HostnameSettingTLSGetParamsSettingID = "http2" -) - -type HostnameSettingTLSGetResponseEnvelope struct { - Errors []HostnameSettingTLSGetResponseEnvelopeErrors `json:"errors,required"` - Messages []HostnameSettingTLSGetResponseEnvelopeMessages `json:"messages,required"` - Result []HostnameSettingTLSGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success HostnameSettingTLSGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo HostnameSettingTLSGetResponseEnvelopeResultInfo `json:"result_info"` - JSON hostnameSettingTLSGetResponseEnvelopeJSON `json:"-"` -} - -// hostnameSettingTLSGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [HostnameSettingTLSGetResponseEnvelope] -type hostnameSettingTLSGetResponseEnvelopeJSON 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 *HostnameSettingTLSGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameSettingTLSGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HostnameSettingTLSGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameSettingTLSGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// hostnameSettingTLSGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [HostnameSettingTLSGetResponseEnvelopeErrors] -type hostnameSettingTLSGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameSettingTLSGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameSettingTLSGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HostnameSettingTLSGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hostnameSettingTLSGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// hostnameSettingTLSGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [HostnameSettingTLSGetResponseEnvelopeMessages] -type hostnameSettingTLSGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameSettingTLSGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameSettingTLSGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HostnameSettingTLSGetResponseEnvelopeSuccess bool - -const ( - HostnameSettingTLSGetResponseEnvelopeSuccessTrue HostnameSettingTLSGetResponseEnvelopeSuccess = true -) - -type HostnameSettingTLSGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - // Total pages available of results - TotalPages float64 `json:"total_pages"` - JSON hostnameSettingTLSGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// hostnameSettingTLSGetResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [HostnameSettingTLSGetResponseEnvelopeResultInfo] -type hostnameSettingTLSGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - TotalPages apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HostnameSettingTLSGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hostnameSettingTLSGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/hostnamesettingtls_test.go b/hostnamesettingtls_test.go deleted file mode 100644 index 470ef16779a..00000000000 --- a/hostnamesettingtls_test.go +++ /dev/null @@ -1,107 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestHostnameSettingTLSUpdate(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("user@example.com"), - ) - _, err := client.Hostnames.Settings.TLS.Update( - context.TODO(), - cloudflare.HostnameSettingTLSUpdateParamsSettingIDCiphers, - "app.example.com", - cloudflare.HostnameSettingTLSUpdateParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F[cloudflare.HostnameSettingTLSUpdateParamsValue](cloudflare.HostnameSettingTLSUpdateParamsValueArray([]string{"ECDHE-RSA-AES128-GCM-SHA256", "AES128-GCM-SHA256"})), - }, - ) - 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 TestHostnameSettingTLSDelete(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("user@example.com"), - ) - _, err := client.Hostnames.Settings.TLS.Delete( - context.TODO(), - cloudflare.HostnameSettingTLSDeleteParamsSettingIDCiphers, - "app.example.com", - cloudflare.HostnameSettingTLSDeleteParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestHostnameSettingTLSGet(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("user@example.com"), - ) - _, err := client.Hostnames.Settings.TLS.Get( - context.TODO(), - cloudflare.HostnameSettingTLSGetParamsSettingIDCiphers, - cloudflare.HostnameSettingTLSGetParams{ - ZoneID: cloudflare.F("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/hyperdrive/aliases.go b/hyperdrive/aliases.go new file mode 100644 index 00000000000..d50d2cd6fae --- /dev/null +++ b/hyperdrive/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package hyperdrive + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/hyperdrive/config.go b/hyperdrive/config.go new file mode 100644 index 00000000000..d0ccc85a67e --- /dev/null +++ b/hyperdrive/config.go @@ -0,0 +1,801 @@ +// File generated from our OpenAPI spec by Stainless. + +package hyperdrive + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// ConfigService 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 [NewConfigService] method instead. +type ConfigService struct { + Options []option.RequestOption +} + +// NewConfigService 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 NewConfigService(opts ...option.RequestOption) (r *ConfigService) { + r = &ConfigService{} + r.Options = opts + return +} + +// Creates and returns a new Hyperdrive configuration. +func (r *ConfigService) New(ctx context.Context, params ConfigNewParams, opts ...option.RequestOption) (res *ConfigNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env ConfigNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/hyperdrive/configs", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates and returns the specified Hyperdrive configuration. +func (r *ConfigService) Update(ctx context.Context, hyperdriveID string, params ConfigUpdateParams, opts ...option.RequestOption) (res *ConfigUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env ConfigUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/hyperdrive/configs/%s", params.AccountID, hyperdriveID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Returns a list of Hyperdrives +func (r *ConfigService) List(ctx context.Context, query ConfigListParams, opts ...option.RequestOption) (res *[]ConfigListResponse, err error) { + opts = append(r.Options[:], opts...) + var env ConfigListResponseEnvelope + path := fmt.Sprintf("accounts/%s/hyperdrive/configs", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes the specified Hyperdrive. +func (r *ConfigService) Delete(ctx context.Context, hyperdriveID string, body ConfigDeleteParams, opts ...option.RequestOption) (res *ConfigDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env ConfigDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/hyperdrive/configs/%s", body.AccountID, hyperdriveID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Patches and returns the specified Hyperdrive configuration. Updates to the +// origin and caching settings are applied with an all-or-nothing approach. +func (r *ConfigService) Edit(ctx context.Context, hyperdriveID string, params ConfigEditParams, opts ...option.RequestOption) (res *ConfigEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env ConfigEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/hyperdrive/configs/%s", params.AccountID, hyperdriveID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Returns the specified Hyperdrive configuration. +func (r *ConfigService) Get(ctx context.Context, hyperdriveID string, query ConfigGetParams, opts ...option.RequestOption) (res *ConfigGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env ConfigGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/hyperdrive/configs/%s", query.AccountID, hyperdriveID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ConfigNewResponse struct { + // Identifier + ID string `json:"id"` + JSON configNewResponseJSON `json:"-"` +} + +// configNewResponseJSON contains the JSON metadata for the struct +// [ConfigNewResponse] +type configNewResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configNewResponseJSON) RawJSON() string { + return r.raw +} + +type ConfigUpdateResponse struct { + // Identifier + ID string `json:"id"` + JSON configUpdateResponseJSON `json:"-"` +} + +// configUpdateResponseJSON contains the JSON metadata for the struct +// [ConfigUpdateResponse] +type configUpdateResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configUpdateResponseJSON) RawJSON() string { + return r.raw +} + +type ConfigListResponse struct { + // Identifier + ID string `json:"id"` + JSON configListResponseJSON `json:"-"` +} + +// configListResponseJSON contains the JSON metadata for the struct +// [ConfigListResponse] +type configListResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configListResponseJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [hyperdrive.ConfigDeleteResponseUnknown] or +// [shared.UnionString]. +type ConfigDeleteResponse interface { + ImplementsHyperdriveConfigDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ConfigDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type ConfigEditResponse struct { + // Identifier + ID string `json:"id"` + JSON configEditResponseJSON `json:"-"` +} + +// configEditResponseJSON contains the JSON metadata for the struct +// [ConfigEditResponse] +type configEditResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigEditResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configEditResponseJSON) RawJSON() string { + return r.raw +} + +type ConfigGetResponse struct { + // Identifier + ID string `json:"id"` + JSON configGetResponseJSON `json:"-"` +} + +// configGetResponseJSON contains the JSON metadata for the struct +// [ConfigGetResponse] +type configGetResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configGetResponseJSON) RawJSON() string { + return r.raw +} + +type ConfigNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Origin param.Field[ConfigNewParamsOrigin] `json:"origin,required"` +} + +func (r ConfigNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ConfigNewParamsOrigin struct { + // The password required to access your origin database. This value is write-only + // and never returned by the API. + Password param.Field[string] `json:"password,required"` +} + +func (r ConfigNewParamsOrigin) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ConfigNewResponseEnvelope struct { + Errors []ConfigNewResponseEnvelopeErrors `json:"errors,required"` + Messages []ConfigNewResponseEnvelopeMessages `json:"messages,required"` + Result ConfigNewResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ConfigNewResponseEnvelopeSuccess `json:"success,required"` + JSON configNewResponseEnvelopeJSON `json:"-"` +} + +// configNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [ConfigNewResponseEnvelope] +type configNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConfigNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// configNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ConfigNewResponseEnvelopeErrors] +type configNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ConfigNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// configNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ConfigNewResponseEnvelopeMessages] +type configNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConfigNewResponseEnvelopeSuccess bool + +const ( + ConfigNewResponseEnvelopeSuccessTrue ConfigNewResponseEnvelopeSuccess = true +) + +type ConfigUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Origin param.Field[ConfigUpdateParamsOrigin] `json:"origin,required"` +} + +func (r ConfigUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ConfigUpdateParamsOrigin struct { + // The password required to access your origin database. This value is write-only + // and never returned by the API. + Password param.Field[string] `json:"password,required"` +} + +func (r ConfigUpdateParamsOrigin) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ConfigUpdateResponseEnvelope struct { + Errors []ConfigUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []ConfigUpdateResponseEnvelopeMessages `json:"messages,required"` + Result ConfigUpdateResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ConfigUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON configUpdateResponseEnvelopeJSON `json:"-"` +} + +// configUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [ConfigUpdateResponseEnvelope] +type configUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConfigUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// configUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ConfigUpdateResponseEnvelopeErrors] +type configUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ConfigUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// configUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ConfigUpdateResponseEnvelopeMessages] +type configUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConfigUpdateResponseEnvelopeSuccess bool + +const ( + ConfigUpdateResponseEnvelopeSuccessTrue ConfigUpdateResponseEnvelopeSuccess = true +) + +type ConfigListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ConfigListResponseEnvelope struct { + Errors []ConfigListResponseEnvelopeErrors `json:"errors,required"` + Messages []ConfigListResponseEnvelopeMessages `json:"messages,required"` + Result []ConfigListResponse `json:"result,required"` + // Whether the API call was successful + Success ConfigListResponseEnvelopeSuccess `json:"success,required"` + JSON configListResponseEnvelopeJSON `json:"-"` +} + +// configListResponseEnvelopeJSON contains the JSON metadata for the struct +// [ConfigListResponseEnvelope] +type configListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConfigListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configListResponseEnvelopeErrorsJSON `json:"-"` +} + +// configListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ConfigListResponseEnvelopeErrors] +type configListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ConfigListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configListResponseEnvelopeMessagesJSON `json:"-"` +} + +// configListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ConfigListResponseEnvelopeMessages] +type configListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConfigListResponseEnvelopeSuccess bool + +const ( + ConfigListResponseEnvelopeSuccessTrue ConfigListResponseEnvelopeSuccess = true +) + +type ConfigDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ConfigDeleteResponseEnvelope struct { + Errors []ConfigDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []ConfigDeleteResponseEnvelopeMessages `json:"messages,required"` + Result ConfigDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ConfigDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON configDeleteResponseEnvelopeJSON `json:"-"` +} + +// configDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [ConfigDeleteResponseEnvelope] +type configDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConfigDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// configDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ConfigDeleteResponseEnvelopeErrors] +type configDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ConfigDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// configDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ConfigDeleteResponseEnvelopeMessages] +type configDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConfigDeleteResponseEnvelopeSuccess bool + +const ( + ConfigDeleteResponseEnvelopeSuccessTrue ConfigDeleteResponseEnvelopeSuccess = true +) + +type ConfigEditParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Origin param.Field[ConfigEditParamsOrigin] `json:"origin"` +} + +func (r ConfigEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ConfigEditParamsOrigin struct { + // The password required to access your origin database. This value is write-only + // and never returned by the API. + Password param.Field[string] `json:"password,required"` +} + +func (r ConfigEditParamsOrigin) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ConfigEditResponseEnvelope struct { + Errors []ConfigEditResponseEnvelopeErrors `json:"errors,required"` + Messages []ConfigEditResponseEnvelopeMessages `json:"messages,required"` + Result ConfigEditResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ConfigEditResponseEnvelopeSuccess `json:"success,required"` + JSON configEditResponseEnvelopeJSON `json:"-"` +} + +// configEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [ConfigEditResponseEnvelope] +type configEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConfigEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// configEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ConfigEditResponseEnvelopeErrors] +type configEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ConfigEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// configEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ConfigEditResponseEnvelopeMessages] +type configEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConfigEditResponseEnvelopeSuccess bool + +const ( + ConfigEditResponseEnvelopeSuccessTrue ConfigEditResponseEnvelopeSuccess = true +) + +type ConfigGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ConfigGetResponseEnvelope struct { + Errors []ConfigGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ConfigGetResponseEnvelopeMessages `json:"messages,required"` + Result ConfigGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ConfigGetResponseEnvelopeSuccess `json:"success,required"` + JSON configGetResponseEnvelopeJSON `json:"-"` +} + +// configGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [ConfigGetResponseEnvelope] +type configGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConfigGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// configGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ConfigGetResponseEnvelopeErrors] +type configGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ConfigGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// configGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ConfigGetResponseEnvelopeMessages] +type configGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConfigGetResponseEnvelopeSuccess bool + +const ( + ConfigGetResponseEnvelopeSuccessTrue ConfigGetResponseEnvelopeSuccess = true +) diff --git a/hyperdrive/config_test.go b/hyperdrive/config_test.go new file mode 100644 index 00000000000..ec90e359c15 --- /dev/null +++ b/hyperdrive/config_test.go @@ -0,0 +1,196 @@ +// File generated from our OpenAPI spec by Stainless. + +package hyperdrive_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/hyperdrive" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestConfigNew(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("user@example.com"), + ) + _, err := client.Hyperdrive.Configs.New(context.TODO(), hyperdrive.ConfigNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Origin: cloudflare.F(hyperdrive.ConfigNewParamsOrigin{ + Password: cloudflare.F("password1234!"), + }), + }) + 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 TestConfigUpdate(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("user@example.com"), + ) + _, err := client.Hyperdrive.Configs.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + hyperdrive.ConfigUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Origin: cloudflare.F(hyperdrive.ConfigUpdateParamsOrigin{ + Password: cloudflare.F("password1234!"), + }), + }, + ) + 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 TestConfigList(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("user@example.com"), + ) + _, err := client.Hyperdrive.Configs.List(context.TODO(), hyperdrive.ConfigListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestConfigDelete(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("user@example.com"), + ) + _, err := client.Hyperdrive.Configs.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + hyperdrive.ConfigDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestConfigEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Hyperdrive.Configs.Edit( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + hyperdrive.ConfigEditParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Origin: cloudflare.F(hyperdrive.ConfigEditParamsOrigin{ + Password: cloudflare.F("password1234!"), + }), + }, + ) + 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 TestConfigGet(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("user@example.com"), + ) + _, err := client.Hyperdrive.Configs.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + hyperdrive.ConfigGetParams{ + AccountID: cloudflare.F("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/hyperdrive.go b/hyperdrive/hyperdrive.go similarity index 89% rename from hyperdrive.go rename to hyperdrive/hyperdrive.go index 79eeb68ab8b..eedca3cbf4e 100644 --- a/hyperdrive.go +++ b/hyperdrive/hyperdrive.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package hyperdrive import ( "github.com/cloudflare/cloudflare-go/option" @@ -12,7 +12,7 @@ import ( // service directly, and instead use the [NewHyperdriveService] method instead. type HyperdriveService struct { Options []option.RequestOption - Configs *HyperdriveConfigService + Configs *ConfigService } // NewHyperdriveService generates a new service that applies the given options to @@ -21,6 +21,6 @@ type HyperdriveService struct { func NewHyperdriveService(opts ...option.RequestOption) (r *HyperdriveService) { r = &HyperdriveService{} r.Options = opts - r.Configs = NewHyperdriveConfigService(opts...) + r.Configs = NewConfigService(opts...) return } diff --git a/hyperdriveconfig.go b/hyperdriveconfig.go deleted file mode 100644 index 4ef7d408b80..00000000000 --- a/hyperdriveconfig.go +++ /dev/null @@ -1,802 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// HyperdriveConfigService 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 [NewHyperdriveConfigService] method -// instead. -type HyperdriveConfigService struct { - Options []option.RequestOption -} - -// NewHyperdriveConfigService 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 NewHyperdriveConfigService(opts ...option.RequestOption) (r *HyperdriveConfigService) { - r = &HyperdriveConfigService{} - r.Options = opts - return -} - -// Creates and returns a new Hyperdrive configuration. -func (r *HyperdriveConfigService) New(ctx context.Context, params HyperdriveConfigNewParams, opts ...option.RequestOption) (res *HyperdriveConfigNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env HyperdriveConfigNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/hyperdrive/configs", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates and returns the specified Hyperdrive configuration. -func (r *HyperdriveConfigService) Update(ctx context.Context, hyperdriveID string, params HyperdriveConfigUpdateParams, opts ...option.RequestOption) (res *HyperdriveConfigUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env HyperdriveConfigUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/hyperdrive/configs/%s", params.AccountID, hyperdriveID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Returns a list of Hyperdrives -func (r *HyperdriveConfigService) List(ctx context.Context, query HyperdriveConfigListParams, opts ...option.RequestOption) (res *[]HyperdriveConfigListResponse, err error) { - opts = append(r.Options[:], opts...) - var env HyperdriveConfigListResponseEnvelope - path := fmt.Sprintf("accounts/%s/hyperdrive/configs", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes the specified Hyperdrive. -func (r *HyperdriveConfigService) Delete(ctx context.Context, hyperdriveID string, body HyperdriveConfigDeleteParams, opts ...option.RequestOption) (res *HyperdriveConfigDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env HyperdriveConfigDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/hyperdrive/configs/%s", body.AccountID, hyperdriveID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Patches and returns the specified Hyperdrive configuration. Updates to the -// origin and caching settings are applied with an all-or-nothing approach. -func (r *HyperdriveConfigService) Edit(ctx context.Context, hyperdriveID string, params HyperdriveConfigEditParams, opts ...option.RequestOption) (res *HyperdriveConfigEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env HyperdriveConfigEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/hyperdrive/configs/%s", params.AccountID, hyperdriveID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Returns the specified Hyperdrive configuration. -func (r *HyperdriveConfigService) Get(ctx context.Context, hyperdriveID string, query HyperdriveConfigGetParams, opts ...option.RequestOption) (res *HyperdriveConfigGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env HyperdriveConfigGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/hyperdrive/configs/%s", query.AccountID, hyperdriveID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type HyperdriveConfigNewResponse struct { - // Identifier - ID string `json:"id"` - JSON hyperdriveConfigNewResponseJSON `json:"-"` -} - -// hyperdriveConfigNewResponseJSON contains the JSON metadata for the struct -// [HyperdriveConfigNewResponse] -type hyperdriveConfigNewResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigNewResponseJSON) RawJSON() string { - return r.raw -} - -type HyperdriveConfigUpdateResponse struct { - // Identifier - ID string `json:"id"` - JSON hyperdriveConfigUpdateResponseJSON `json:"-"` -} - -// hyperdriveConfigUpdateResponseJSON contains the JSON metadata for the struct -// [HyperdriveConfigUpdateResponse] -type hyperdriveConfigUpdateResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type HyperdriveConfigListResponse struct { - // Identifier - ID string `json:"id"` - JSON hyperdriveConfigListResponseJSON `json:"-"` -} - -// hyperdriveConfigListResponseJSON contains the JSON metadata for the struct -// [HyperdriveConfigListResponse] -type hyperdriveConfigListResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigListResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [HyperdriveConfigDeleteResponseUnknown] or -// [shared.UnionString]. -type HyperdriveConfigDeleteResponse interface { - ImplementsHyperdriveConfigDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*HyperdriveConfigDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type HyperdriveConfigEditResponse struct { - // Identifier - ID string `json:"id"` - JSON hyperdriveConfigEditResponseJSON `json:"-"` -} - -// hyperdriveConfigEditResponseJSON contains the JSON metadata for the struct -// [HyperdriveConfigEditResponse] -type hyperdriveConfigEditResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigEditResponseJSON) RawJSON() string { - return r.raw -} - -type HyperdriveConfigGetResponse struct { - // Identifier - ID string `json:"id"` - JSON hyperdriveConfigGetResponseJSON `json:"-"` -} - -// hyperdriveConfigGetResponseJSON contains the JSON metadata for the struct -// [HyperdriveConfigGetResponse] -type hyperdriveConfigGetResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigGetResponseJSON) RawJSON() string { - return r.raw -} - -type HyperdriveConfigNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Origin param.Field[HyperdriveConfigNewParamsOrigin] `json:"origin,required"` -} - -func (r HyperdriveConfigNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type HyperdriveConfigNewParamsOrigin struct { - // The password required to access your origin database. This value is write-only - // and never returned by the API. - Password param.Field[string] `json:"password,required"` -} - -func (r HyperdriveConfigNewParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type HyperdriveConfigNewResponseEnvelope struct { - Errors []HyperdriveConfigNewResponseEnvelopeErrors `json:"errors,required"` - Messages []HyperdriveConfigNewResponseEnvelopeMessages `json:"messages,required"` - Result HyperdriveConfigNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success HyperdriveConfigNewResponseEnvelopeSuccess `json:"success,required"` - JSON hyperdriveConfigNewResponseEnvelopeJSON `json:"-"` -} - -// hyperdriveConfigNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [HyperdriveConfigNewResponseEnvelope] -type hyperdriveConfigNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HyperdriveConfigNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hyperdriveConfigNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// hyperdriveConfigNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [HyperdriveConfigNewResponseEnvelopeErrors] -type hyperdriveConfigNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HyperdriveConfigNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hyperdriveConfigNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// hyperdriveConfigNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [HyperdriveConfigNewResponseEnvelopeMessages] -type hyperdriveConfigNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HyperdriveConfigNewResponseEnvelopeSuccess bool - -const ( - HyperdriveConfigNewResponseEnvelopeSuccessTrue HyperdriveConfigNewResponseEnvelopeSuccess = true -) - -type HyperdriveConfigUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Origin param.Field[HyperdriveConfigUpdateParamsOrigin] `json:"origin,required"` -} - -func (r HyperdriveConfigUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type HyperdriveConfigUpdateParamsOrigin struct { - // The password required to access your origin database. This value is write-only - // and never returned by the API. - Password param.Field[string] `json:"password,required"` -} - -func (r HyperdriveConfigUpdateParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type HyperdriveConfigUpdateResponseEnvelope struct { - Errors []HyperdriveConfigUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []HyperdriveConfigUpdateResponseEnvelopeMessages `json:"messages,required"` - Result HyperdriveConfigUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success HyperdriveConfigUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON hyperdriveConfigUpdateResponseEnvelopeJSON `json:"-"` -} - -// hyperdriveConfigUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [HyperdriveConfigUpdateResponseEnvelope] -type hyperdriveConfigUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HyperdriveConfigUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hyperdriveConfigUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// hyperdriveConfigUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [HyperdriveConfigUpdateResponseEnvelopeErrors] -type hyperdriveConfigUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HyperdriveConfigUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hyperdriveConfigUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// hyperdriveConfigUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [HyperdriveConfigUpdateResponseEnvelopeMessages] -type hyperdriveConfigUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HyperdriveConfigUpdateResponseEnvelopeSuccess bool - -const ( - HyperdriveConfigUpdateResponseEnvelopeSuccessTrue HyperdriveConfigUpdateResponseEnvelopeSuccess = true -) - -type HyperdriveConfigListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type HyperdriveConfigListResponseEnvelope struct { - Errors []HyperdriveConfigListResponseEnvelopeErrors `json:"errors,required"` - Messages []HyperdriveConfigListResponseEnvelopeMessages `json:"messages,required"` - Result []HyperdriveConfigListResponse `json:"result,required"` - // Whether the API call was successful - Success HyperdriveConfigListResponseEnvelopeSuccess `json:"success,required"` - JSON hyperdriveConfigListResponseEnvelopeJSON `json:"-"` -} - -// hyperdriveConfigListResponseEnvelopeJSON contains the JSON metadata for the -// struct [HyperdriveConfigListResponseEnvelope] -type hyperdriveConfigListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HyperdriveConfigListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hyperdriveConfigListResponseEnvelopeErrorsJSON `json:"-"` -} - -// hyperdriveConfigListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [HyperdriveConfigListResponseEnvelopeErrors] -type hyperdriveConfigListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HyperdriveConfigListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hyperdriveConfigListResponseEnvelopeMessagesJSON `json:"-"` -} - -// hyperdriveConfigListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [HyperdriveConfigListResponseEnvelopeMessages] -type hyperdriveConfigListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HyperdriveConfigListResponseEnvelopeSuccess bool - -const ( - HyperdriveConfigListResponseEnvelopeSuccessTrue HyperdriveConfigListResponseEnvelopeSuccess = true -) - -type HyperdriveConfigDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type HyperdriveConfigDeleteResponseEnvelope struct { - Errors []HyperdriveConfigDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []HyperdriveConfigDeleteResponseEnvelopeMessages `json:"messages,required"` - Result HyperdriveConfigDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success HyperdriveConfigDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON hyperdriveConfigDeleteResponseEnvelopeJSON `json:"-"` -} - -// hyperdriveConfigDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [HyperdriveConfigDeleteResponseEnvelope] -type hyperdriveConfigDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HyperdriveConfigDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hyperdriveConfigDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// hyperdriveConfigDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [HyperdriveConfigDeleteResponseEnvelopeErrors] -type hyperdriveConfigDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HyperdriveConfigDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hyperdriveConfigDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// hyperdriveConfigDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [HyperdriveConfigDeleteResponseEnvelopeMessages] -type hyperdriveConfigDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HyperdriveConfigDeleteResponseEnvelopeSuccess bool - -const ( - HyperdriveConfigDeleteResponseEnvelopeSuccessTrue HyperdriveConfigDeleteResponseEnvelopeSuccess = true -) - -type HyperdriveConfigEditParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Origin param.Field[HyperdriveConfigEditParamsOrigin] `json:"origin"` -} - -func (r HyperdriveConfigEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type HyperdriveConfigEditParamsOrigin struct { - // The password required to access your origin database. This value is write-only - // and never returned by the API. - Password param.Field[string] `json:"password,required"` -} - -func (r HyperdriveConfigEditParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type HyperdriveConfigEditResponseEnvelope struct { - Errors []HyperdriveConfigEditResponseEnvelopeErrors `json:"errors,required"` - Messages []HyperdriveConfigEditResponseEnvelopeMessages `json:"messages,required"` - Result HyperdriveConfigEditResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success HyperdriveConfigEditResponseEnvelopeSuccess `json:"success,required"` - JSON hyperdriveConfigEditResponseEnvelopeJSON `json:"-"` -} - -// hyperdriveConfigEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [HyperdriveConfigEditResponseEnvelope] -type hyperdriveConfigEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HyperdriveConfigEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hyperdriveConfigEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// hyperdriveConfigEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [HyperdriveConfigEditResponseEnvelopeErrors] -type hyperdriveConfigEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HyperdriveConfigEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hyperdriveConfigEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// hyperdriveConfigEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [HyperdriveConfigEditResponseEnvelopeMessages] -type hyperdriveConfigEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HyperdriveConfigEditResponseEnvelopeSuccess bool - -const ( - HyperdriveConfigEditResponseEnvelopeSuccessTrue HyperdriveConfigEditResponseEnvelopeSuccess = true -) - -type HyperdriveConfigGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type HyperdriveConfigGetResponseEnvelope struct { - Errors []HyperdriveConfigGetResponseEnvelopeErrors `json:"errors,required"` - Messages []HyperdriveConfigGetResponseEnvelopeMessages `json:"messages,required"` - Result HyperdriveConfigGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success HyperdriveConfigGetResponseEnvelopeSuccess `json:"success,required"` - JSON hyperdriveConfigGetResponseEnvelopeJSON `json:"-"` -} - -// hyperdriveConfigGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [HyperdriveConfigGetResponseEnvelope] -type hyperdriveConfigGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type HyperdriveConfigGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hyperdriveConfigGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// hyperdriveConfigGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [HyperdriveConfigGetResponseEnvelopeErrors] -type hyperdriveConfigGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type HyperdriveConfigGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON hyperdriveConfigGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// hyperdriveConfigGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [HyperdriveConfigGetResponseEnvelopeMessages] -type hyperdriveConfigGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *HyperdriveConfigGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r hyperdriveConfigGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type HyperdriveConfigGetResponseEnvelopeSuccess bool - -const ( - HyperdriveConfigGetResponseEnvelopeSuccessTrue HyperdriveConfigGetResponseEnvelopeSuccess = true -) diff --git a/hyperdriveconfig_test.go b/hyperdriveconfig_test.go deleted file mode 100644 index 1914973dfc4..00000000000 --- a/hyperdriveconfig_test.go +++ /dev/null @@ -1,195 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestHyperdriveConfigNew(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("user@example.com"), - ) - _, err := client.Hyperdrive.Configs.New(context.TODO(), cloudflare.HyperdriveConfigNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Origin: cloudflare.F(cloudflare.HyperdriveConfigNewParamsOrigin{ - Password: cloudflare.F("password1234!"), - }), - }) - 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 TestHyperdriveConfigUpdate(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("user@example.com"), - ) - _, err := client.Hyperdrive.Configs.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.HyperdriveConfigUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Origin: cloudflare.F(cloudflare.HyperdriveConfigUpdateParamsOrigin{ - Password: cloudflare.F("password1234!"), - }), - }, - ) - 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 TestHyperdriveConfigList(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("user@example.com"), - ) - _, err := client.Hyperdrive.Configs.List(context.TODO(), cloudflare.HyperdriveConfigListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestHyperdriveConfigDelete(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("user@example.com"), - ) - _, err := client.Hyperdrive.Configs.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.HyperdriveConfigDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestHyperdriveConfigEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Hyperdrive.Configs.Edit( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.HyperdriveConfigEditParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Origin: cloudflare.F(cloudflare.HyperdriveConfigEditParamsOrigin{ - Password: cloudflare.F("password1234!"), - }), - }, - ) - 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 TestHyperdriveConfigGet(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("user@example.com"), - ) - _, err := client.Hyperdrive.Configs.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.HyperdriveConfigGetParams{ - AccountID: cloudflare.F("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/images/aliases.go b/images/aliases.go new file mode 100644 index 00000000000..f8d1d209fc8 --- /dev/null +++ b/images/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package images + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/image.go b/images/image.go similarity index 85% rename from image.go rename to images/image.go index ec386bc9ae4..090fd2ebdf9 100644 --- a/image.go +++ b/images/image.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package images import ( "github.com/cloudflare/cloudflare-go/option" @@ -12,8 +12,8 @@ import ( // directly, and instead use the [NewImageService] method instead. type ImageService struct { Options []option.RequestOption - V1 *ImageV1Service - V2 *ImageV2Service + V1 *V1Service + V2 *V2Service } // NewImageService generates a new service that applies the given options to each @@ -22,7 +22,7 @@ type ImageService struct { func NewImageService(opts ...option.RequestOption) (r *ImageService) { r = &ImageService{} r.Options = opts - r.V1 = NewImageV1Service(opts...) - r.V2 = NewImageV2Service(opts...) + r.V1 = NewV1Service(opts...) + r.V2 = NewV2Service(opts...) return } diff --git a/images/v1.go b/images/v1.go new file mode 100644 index 00000000000..97b8d98f264 --- /dev/null +++ b/images/v1.go @@ -0,0 +1,687 @@ +// File generated from our OpenAPI spec by Stainless. + +package images + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// V1Service 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 [NewV1Service] method instead. +type V1Service struct { + Options []option.RequestOption + Keys *V1KeyService + Stats *V1StatService + Variants *V1VariantService + Blobs *V1BlobService +} + +// NewV1Service 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 NewV1Service(opts ...option.RequestOption) (r *V1Service) { + r = &V1Service{} + r.Options = opts + r.Keys = NewV1KeyService(opts...) + r.Stats = NewV1StatService(opts...) + r.Variants = NewV1VariantService(opts...) + r.Blobs = NewV1BlobService(opts...) + return +} + +// Upload an image with up to 10 Megabytes using a single HTTP POST +// (multipart/form-data) request. An image can be uploaded by sending an image file +// or passing an accessible to an API url. +func (r *V1Service) New(ctx context.Context, params V1NewParams, opts ...option.RequestOption) (res *ImagesImage, err error) { + opts = append(r.Options[:], opts...) + var env V1NewResponseEnvelope + path := fmt.Sprintf("accounts/%s/images/v1", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List up to 100 images with one request. Use the optional parameters below to get +// a specific range of images. +func (r *V1Service) List(ctx context.Context, params V1ListParams, opts ...option.RequestOption) (res *shared.V4PagePagination[V1ListResponse], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("accounts/%s/images/v1", params.AccountID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// List up to 100 images with one request. Use the optional parameters below to get +// a specific range of images. +func (r *V1Service) ListAutoPaging(ctx context.Context, params V1ListParams, opts ...option.RequestOption) *shared.V4PagePaginationAutoPager[V1ListResponse] { + return shared.NewV4PagePaginationAutoPager(r.List(ctx, params, opts...)) +} + +// Delete an image on Cloudflare Images. On success, all copies of the image are +// deleted and purged from cache. +func (r *V1Service) Delete(ctx context.Context, imageID string, body V1DeleteParams, opts ...option.RequestOption) (res *V1DeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env V1DeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/images/v1/%s", body.AccountID, imageID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update image access control. On access control change, all copies of the image +// are purged from cache. +func (r *V1Service) Edit(ctx context.Context, imageID string, params V1EditParams, opts ...option.RequestOption) (res *ImagesImage, err error) { + opts = append(r.Options[:], opts...) + var env V1EditResponseEnvelope + path := fmt.Sprintf("accounts/%s/images/v1/%s", params.AccountID, imageID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch details for a single image. +func (r *V1Service) Get(ctx context.Context, imageID string, query V1GetParams, opts ...option.RequestOption) (res *ImagesImage, err error) { + opts = append(r.Options[:], opts...) + var env V1GetResponseEnvelope + path := fmt.Sprintf("accounts/%s/images/v1/%s", query.AccountID, imageID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ImagesImage struct { + // Image unique identifier. + ID string `json:"id"` + // Image file name. + Filename string `json:"filename"` + // User modifiable key-value store. Can be used for keeping references to another + // system of record for managing images. Metadata must not exceed 1024 bytes. + Meta interface{} `json:"meta"` + // Indicates whether the image can be a accessed only using it's UID. If set to + // true, a signed token needs to be generated with a signing key to view the image. + RequireSignedURLs bool `json:"requireSignedURLs"` + // When the media item was uploaded. + Uploaded time.Time `json:"uploaded" format:"date-time"` + // Object specifying available variants for an image. + Variants []ImagesImageVariant `json:"variants" format:"uri"` + JSON imagesImageJSON `json:"-"` +} + +// imagesImageJSON contains the JSON metadata for the struct [ImagesImage] +type imagesImageJSON struct { + ID apijson.Field + Filename apijson.Field + Meta apijson.Field + RequireSignedURLs apijson.Field + Uploaded apijson.Field + Variants apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ImagesImage) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r imagesImageJSON) RawJSON() string { + return r.raw +} + +// URI to thumbnail variant for an image. +// +// Union satisfied by [shared.UnionString], [shared.UnionString] or +// [shared.UnionString]. +type ImagesImageVariant interface { + ImplementsImagesImagesImageVariant() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ImagesImageVariant)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type V1ListResponse struct { + Errors []V1ListResponseError `json:"errors,required"` + Messages []V1ListResponseMessage `json:"messages,required"` + Result V1ListResponseResult `json:"result,required"` + // Whether the API call was successful + Success V1ListResponseSuccess `json:"success,required"` + JSON v1ListResponseJSON `json:"-"` +} + +// v1ListResponseJSON contains the JSON metadata for the struct [V1ListResponse] +type v1ListResponseJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1ListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1ListResponseJSON) RawJSON() string { + return r.raw +} + +type V1ListResponseError struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1ListResponseErrorJSON `json:"-"` +} + +// v1ListResponseErrorJSON contains the JSON metadata for the struct +// [V1ListResponseError] +type v1ListResponseErrorJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1ListResponseError) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1ListResponseErrorJSON) RawJSON() string { + return r.raw +} + +type V1ListResponseMessage struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1ListResponseMessageJSON `json:"-"` +} + +// v1ListResponseMessageJSON contains the JSON metadata for the struct +// [V1ListResponseMessage] +type v1ListResponseMessageJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1ListResponseMessage) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1ListResponseMessageJSON) RawJSON() string { + return r.raw +} + +type V1ListResponseResult struct { + Images []ImagesImage `json:"images"` + JSON v1ListResponseResultJSON `json:"-"` +} + +// v1ListResponseResultJSON contains the JSON metadata for the struct +// [V1ListResponseResult] +type v1ListResponseResultJSON struct { + Images apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1ListResponseResult) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1ListResponseResultJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V1ListResponseSuccess bool + +const ( + V1ListResponseSuccessTrue V1ListResponseSuccess = true +) + +// Union satisfied by [images.V1DeleteResponseUnknown] or [shared.UnionString]. +type V1DeleteResponse interface { + ImplementsImagesV1DeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*V1DeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type V1NewParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + Metadata param.Field[interface{}] `json:"metadata"` + // Indicates whether the image requires a signature token for the access. + RequireSignedURLs param.Field[bool] `json:"requireSignedURLs"` +} + +func (r V1NewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type V1NewResponseEnvelope struct { + Errors []V1NewResponseEnvelopeErrors `json:"errors,required"` + Messages []V1NewResponseEnvelopeMessages `json:"messages,required"` + Result ImagesImage `json:"result,required"` + // Whether the API call was successful + Success V1NewResponseEnvelopeSuccess `json:"success,required"` + JSON v1NewResponseEnvelopeJSON `json:"-"` +} + +// v1NewResponseEnvelopeJSON contains the JSON metadata for the struct +// [V1NewResponseEnvelope] +type v1NewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1NewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1NewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V1NewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1NewResponseEnvelopeErrorsJSON `json:"-"` +} + +// v1NewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [V1NewResponseEnvelopeErrors] +type v1NewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1NewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1NewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V1NewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1NewResponseEnvelopeMessagesJSON `json:"-"` +} + +// v1NewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [V1NewResponseEnvelopeMessages] +type v1NewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1NewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1NewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V1NewResponseEnvelopeSuccess bool + +const ( + V1NewResponseEnvelopeSuccessTrue V1NewResponseEnvelopeSuccess = true +) + +type V1ListParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // Number of items per page. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [V1ListParams]'s query parameters as `url.Values`. +func (r V1ListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type V1DeleteParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type V1DeleteResponseEnvelope struct { + Errors []V1DeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []V1DeleteResponseEnvelopeMessages `json:"messages,required"` + Result V1DeleteResponse `json:"result,required"` + // Whether the API call was successful + Success V1DeleteResponseEnvelopeSuccess `json:"success,required"` + JSON v1DeleteResponseEnvelopeJSON `json:"-"` +} + +// v1DeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [V1DeleteResponseEnvelope] +type v1DeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1DeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1DeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V1DeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1DeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// v1DeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [V1DeleteResponseEnvelopeErrors] +type v1DeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1DeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1DeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V1DeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1DeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// v1DeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [V1DeleteResponseEnvelopeMessages] +type v1DeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1DeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1DeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V1DeleteResponseEnvelopeSuccess bool + +const ( + V1DeleteResponseEnvelopeSuccessTrue V1DeleteResponseEnvelopeSuccess = true +) + +type V1EditParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + // User modifiable key-value store. Can be used for keeping references to another + // system of record for managing images. No change if not specified. + Metadata param.Field[interface{}] `json:"metadata"` + // Indicates whether the image can be accessed using only its UID. If set to + // `true`, a signed token needs to be generated with a signing key to view the + // image. Returns a new UID on a change. No change if not specified. + RequireSignedURLs param.Field[bool] `json:"requireSignedURLs"` +} + +func (r V1EditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type V1EditResponseEnvelope struct { + Errors []V1EditResponseEnvelopeErrors `json:"errors,required"` + Messages []V1EditResponseEnvelopeMessages `json:"messages,required"` + Result ImagesImage `json:"result,required"` + // Whether the API call was successful + Success V1EditResponseEnvelopeSuccess `json:"success,required"` + JSON v1EditResponseEnvelopeJSON `json:"-"` +} + +// v1EditResponseEnvelopeJSON contains the JSON metadata for the struct +// [V1EditResponseEnvelope] +type v1EditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1EditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1EditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V1EditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1EditResponseEnvelopeErrorsJSON `json:"-"` +} + +// v1EditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [V1EditResponseEnvelopeErrors] +type v1EditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1EditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1EditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V1EditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1EditResponseEnvelopeMessagesJSON `json:"-"` +} + +// v1EditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [V1EditResponseEnvelopeMessages] +type v1EditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1EditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1EditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V1EditResponseEnvelopeSuccess bool + +const ( + V1EditResponseEnvelopeSuccessTrue V1EditResponseEnvelopeSuccess = true +) + +type V1GetParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type V1GetResponseEnvelope struct { + Errors []V1GetResponseEnvelopeErrors `json:"errors,required"` + Messages []V1GetResponseEnvelopeMessages `json:"messages,required"` + Result ImagesImage `json:"result,required"` + // Whether the API call was successful + Success V1GetResponseEnvelopeSuccess `json:"success,required"` + JSON v1GetResponseEnvelopeJSON `json:"-"` +} + +// v1GetResponseEnvelopeJSON contains the JSON metadata for the struct +// [V1GetResponseEnvelope] +type v1GetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1GetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1GetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V1GetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1GetResponseEnvelopeErrorsJSON `json:"-"` +} + +// v1GetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [V1GetResponseEnvelopeErrors] +type v1GetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1GetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1GetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V1GetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1GetResponseEnvelopeMessagesJSON `json:"-"` +} + +// v1GetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [V1GetResponseEnvelopeMessages] +type v1GetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1GetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1GetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V1GetResponseEnvelopeSuccess bool + +const ( + V1GetResponseEnvelopeSuccessTrue V1GetResponseEnvelopeSuccess = true +) diff --git a/images/v1_test.go b/images/v1_test.go new file mode 100644 index 00000000000..5d474132b1e --- /dev/null +++ b/images/v1_test.go @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package images_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/images" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestV1NewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Images.V1.New(context.TODO(), images.V1NewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Metadata: cloudflare.F[any](map[string]interface{}{}), + RequireSignedURLs: cloudflare.F(true), + }) + 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 TestV1ListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Images.V1.List(context.TODO(), images.V1ListParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(10.000000), + }) + 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 TestV1Delete(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("user@example.com"), + ) + _, err := client.Images.V1.Delete( + context.TODO(), + "string", + images.V1DeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestV1EditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Images.V1.Edit( + context.TODO(), + "string", + images.V1EditParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Metadata: cloudflare.F[any](map[string]interface{}{}), + RequireSignedURLs: cloudflare.F(true), + }, + ) + 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 TestV1Get(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("user@example.com"), + ) + _, err := client.Images.V1.Get( + context.TODO(), + "string", + images.V1GetParams{ + AccountID: cloudflare.F("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/images/v1blob.go b/images/v1blob.go new file mode 100644 index 00000000000..536a6b20c95 --- /dev/null +++ b/images/v1blob.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package images + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// V1BlobService 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 [NewV1BlobService] method instead. +type V1BlobService struct { + Options []option.RequestOption +} + +// NewV1BlobService 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 NewV1BlobService(opts ...option.RequestOption) (r *V1BlobService) { + r = &V1BlobService{} + r.Options = opts + return +} + +// Fetch base image. For most images this will be the originally uploaded file. For +// larger images it can be a near-lossless version of the original. +func (r *V1BlobService) Get(ctx context.Context, imageID string, query V1BlobGetParams, opts ...option.RequestOption) (res *http.Response, err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "image/*")}, opts...) + path := fmt.Sprintf("accounts/%s/images/v1/%s/blob", query.AccountID, imageID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +type V1BlobGetParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} diff --git a/images/v1blob_test.go b/images/v1blob_test.go new file mode 100644 index 00000000000..8a1ce93e8fd --- /dev/null +++ b/images/v1blob_test.go @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package images_test + +import ( + "bytes" + "context" + "errors" + "io" + "net/http" + "net/http/httptest" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/images" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestV1BlobGet(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + w.Write([]byte("abc")) + })) + defer server.Close() + baseURL := server.URL + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("user@example.com"), + ) + resp, err := client.Images.V1.Blobs.Get( + context.TODO(), + "string", + images.V1BlobGetParams{ + AccountID: cloudflare.F("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()) + } + defer resp.Body.Close() + + b, err := io.ReadAll(resp.Body) + 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()) + } + if !bytes.Equal(b, []byte("abc")) { + t.Fatalf("return value not %s: %s", "abc", b) + } +} diff --git a/images/v1key.go b/images/v1key.go new file mode 100644 index 00000000000..afa19abf08f --- /dev/null +++ b/images/v1key.go @@ -0,0 +1,175 @@ +// File generated from our OpenAPI spec by Stainless. + +package images + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// V1KeyService 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 [NewV1KeyService] method instead. +type V1KeyService struct { + Options []option.RequestOption +} + +// NewV1KeyService 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 NewV1KeyService(opts ...option.RequestOption) (r *V1KeyService) { + r = &V1KeyService{} + r.Options = opts + return +} + +// Lists your signing keys. These can be found on your Cloudflare Images dashboard. +func (r *V1KeyService) List(ctx context.Context, query V1KeyListParams, opts ...option.RequestOption) (res *ImagesImageKeys, err error) { + opts = append(r.Options[:], opts...) + var env V1KeyListResponseEnvelope + path := fmt.Sprintf("accounts/%s/images/v1/keys", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ImagesImageKeys struct { + Keys []ImagesImageKeysKey `json:"keys"` + JSON imagesImageKeysJSON `json:"-"` +} + +// imagesImageKeysJSON contains the JSON metadata for the struct [ImagesImageKeys] +type imagesImageKeysJSON struct { + Keys apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ImagesImageKeys) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r imagesImageKeysJSON) RawJSON() string { + return r.raw +} + +type ImagesImageKeysKey struct { + // Key name. + Name string `json:"name"` + // Key value. + Value string `json:"value"` + JSON imagesImageKeysKeyJSON `json:"-"` +} + +// imagesImageKeysKeyJSON contains the JSON metadata for the struct +// [ImagesImageKeysKey] +type imagesImageKeysKeyJSON struct { + Name apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ImagesImageKeysKey) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r imagesImageKeysKeyJSON) RawJSON() string { + return r.raw +} + +type V1KeyListParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type V1KeyListResponseEnvelope struct { + Errors []V1KeyListResponseEnvelopeErrors `json:"errors,required"` + Messages []V1KeyListResponseEnvelopeMessages `json:"messages,required"` + Result ImagesImageKeys `json:"result,required"` + // Whether the API call was successful + Success V1KeyListResponseEnvelopeSuccess `json:"success,required"` + JSON v1KeyListResponseEnvelopeJSON `json:"-"` +} + +// v1KeyListResponseEnvelopeJSON contains the JSON metadata for the struct +// [V1KeyListResponseEnvelope] +type v1KeyListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1KeyListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1KeyListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V1KeyListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1KeyListResponseEnvelopeErrorsJSON `json:"-"` +} + +// v1KeyListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [V1KeyListResponseEnvelopeErrors] +type v1KeyListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1KeyListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1KeyListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V1KeyListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1KeyListResponseEnvelopeMessagesJSON `json:"-"` +} + +// v1KeyListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [V1KeyListResponseEnvelopeMessages] +type v1KeyListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1KeyListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1KeyListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V1KeyListResponseEnvelopeSuccess bool + +const ( + V1KeyListResponseEnvelopeSuccessTrue V1KeyListResponseEnvelopeSuccess = true +) diff --git a/images/v1key_test.go b/images/v1key_test.go new file mode 100644 index 00000000000..87a1dc55b6a --- /dev/null +++ b/images/v1key_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package images_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/images" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestV1KeyList(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("user@example.com"), + ) + _, err := client.Images.V1.Keys.List(context.TODO(), images.V1KeyListParams{ + AccountID: cloudflare.F("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/images/v1stat.go b/images/v1stat.go new file mode 100644 index 00000000000..08d468af7d2 --- /dev/null +++ b/images/v1stat.go @@ -0,0 +1,176 @@ +// File generated from our OpenAPI spec by Stainless. + +package images + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// V1StatService 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 [NewV1StatService] method instead. +type V1StatService struct { + Options []option.RequestOption +} + +// NewV1StatService 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 NewV1StatService(opts ...option.RequestOption) (r *V1StatService) { + r = &V1StatService{} + r.Options = opts + return +} + +// Fetch usage statistics details for Cloudflare Images. +func (r *V1StatService) Get(ctx context.Context, query V1StatGetParams, opts ...option.RequestOption) (res *ImagesImagesStats, err error) { + opts = append(r.Options[:], opts...) + var env V1StatGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/images/v1/stats", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ImagesImagesStats struct { + Count ImagesImagesStatsCount `json:"count"` + JSON imagesImagesStatsJSON `json:"-"` +} + +// imagesImagesStatsJSON contains the JSON metadata for the struct +// [ImagesImagesStats] +type imagesImagesStatsJSON struct { + Count apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ImagesImagesStats) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r imagesImagesStatsJSON) RawJSON() string { + return r.raw +} + +type ImagesImagesStatsCount struct { + // Cloudflare Images allowed usage. + Allowed float64 `json:"allowed"` + // Cloudflare Images current usage. + Current float64 `json:"current"` + JSON imagesImagesStatsCountJSON `json:"-"` +} + +// imagesImagesStatsCountJSON contains the JSON metadata for the struct +// [ImagesImagesStatsCount] +type imagesImagesStatsCountJSON struct { + Allowed apijson.Field + Current apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ImagesImagesStatsCount) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r imagesImagesStatsCountJSON) RawJSON() string { + return r.raw +} + +type V1StatGetParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type V1StatGetResponseEnvelope struct { + Errors []V1StatGetResponseEnvelopeErrors `json:"errors,required"` + Messages []V1StatGetResponseEnvelopeMessages `json:"messages,required"` + Result ImagesImagesStats `json:"result,required"` + // Whether the API call was successful + Success V1StatGetResponseEnvelopeSuccess `json:"success,required"` + JSON v1StatGetResponseEnvelopeJSON `json:"-"` +} + +// v1StatGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [V1StatGetResponseEnvelope] +type v1StatGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1StatGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1StatGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V1StatGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1StatGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// v1StatGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [V1StatGetResponseEnvelopeErrors] +type v1StatGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1StatGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1StatGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V1StatGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1StatGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// v1StatGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [V1StatGetResponseEnvelopeMessages] +type v1StatGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1StatGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1StatGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V1StatGetResponseEnvelopeSuccess bool + +const ( + V1StatGetResponseEnvelopeSuccessTrue V1StatGetResponseEnvelopeSuccess = true +) diff --git a/images/v1stat_test.go b/images/v1stat_test.go new file mode 100644 index 00000000000..f2d9d24d372 --- /dev/null +++ b/images/v1stat_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package images_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/images" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestV1StatGet(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("user@example.com"), + ) + _, err := client.Images.V1.Stats.Get(context.TODO(), images.V1StatGetParams{ + AccountID: cloudflare.F("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/images/v1variant.go b/images/v1variant.go new file mode 100644 index 00000000000..3bed6bf84ba --- /dev/null +++ b/images/v1variant.go @@ -0,0 +1,866 @@ +// File generated from our OpenAPI spec by Stainless. + +package images + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// V1VariantService 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 [NewV1VariantService] method instead. +type V1VariantService struct { + Options []option.RequestOption +} + +// NewV1VariantService 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 NewV1VariantService(opts ...option.RequestOption) (r *V1VariantService) { + r = &V1VariantService{} + r.Options = opts + return +} + +// Specify variants that allow you to resize images for different use cases. +func (r *V1VariantService) New(ctx context.Context, params V1VariantNewParams, opts ...option.RequestOption) (res *ImageVariant, err error) { + opts = append(r.Options[:], opts...) + var env V1VariantNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/images/v1/variants", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists existing variants. +func (r *V1VariantService) List(ctx context.Context, query V1VariantListParams, opts ...option.RequestOption) (res *ImageVariants, err error) { + opts = append(r.Options[:], opts...) + var env V1VariantListResponseEnvelope + path := fmt.Sprintf("accounts/%s/images/v1/variants", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deleting a variant purges the cache for all images associated with the variant. +func (r *V1VariantService) Delete(ctx context.Context, variantID interface{}, body V1VariantDeleteParams, opts ...option.RequestOption) (res *V1VariantDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env V1VariantDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/images/v1/variants/%v", body.AccountID, variantID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updating a variant purges the cache for all images associated with the variant. +func (r *V1VariantService) Edit(ctx context.Context, variantID interface{}, params V1VariantEditParams, opts ...option.RequestOption) (res *ImageVariant, err error) { + opts = append(r.Options[:], opts...) + var env V1VariantEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/images/v1/variants/%v", params.AccountID, variantID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch details for a single variant. +func (r *V1VariantService) Get(ctx context.Context, variantID interface{}, query V1VariantGetParams, opts ...option.RequestOption) (res *ImageVariant, err error) { + opts = append(r.Options[:], opts...) + var env V1VariantGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/images/v1/variants/%v", query.AccountID, variantID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ImageVariant struct { + Variant ImageVariantVariant `json:"variant"` + JSON imageVariantJSON `json:"-"` +} + +// imageVariantJSON contains the JSON metadata for the struct [ImageVariant] +type imageVariantJSON struct { + Variant apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ImageVariant) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r imageVariantJSON) RawJSON() string { + return r.raw +} + +type ImageVariantVariant struct { + ID interface{} `json:"id,required"` + // Allows you to define image resizing sizes for different use cases. + Options ImageVariantVariantOptions `json:"options,required"` + // Indicates whether the variant can access an image without a signature, + // regardless of image access control. + NeverRequireSignedURLs bool `json:"neverRequireSignedURLs"` + JSON imageVariantVariantJSON `json:"-"` +} + +// imageVariantVariantJSON contains the JSON metadata for the struct +// [ImageVariantVariant] +type imageVariantVariantJSON struct { + ID apijson.Field + Options apijson.Field + NeverRequireSignedURLs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ImageVariantVariant) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r imageVariantVariantJSON) RawJSON() string { + return r.raw +} + +// Allows you to define image resizing sizes for different use cases. +type ImageVariantVariantOptions struct { + // The fit property describes how the width and height dimensions should be + // interpreted. + Fit ImageVariantVariantOptionsFit `json:"fit,required"` + // Maximum height in image pixels. + Height float64 `json:"height,required"` + // What EXIF data should be preserved in the output image. + Metadata ImageVariantVariantOptionsMetadata `json:"metadata,required"` + // Maximum width in image pixels. + Width float64 `json:"width,required"` + JSON imageVariantVariantOptionsJSON `json:"-"` +} + +// imageVariantVariantOptionsJSON contains the JSON metadata for the struct +// [ImageVariantVariantOptions] +type imageVariantVariantOptionsJSON struct { + Fit apijson.Field + Height apijson.Field + Metadata apijson.Field + Width apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ImageVariantVariantOptions) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r imageVariantVariantOptionsJSON) RawJSON() string { + return r.raw +} + +// The fit property describes how the width and height dimensions should be +// interpreted. +type ImageVariantVariantOptionsFit string + +const ( + ImageVariantVariantOptionsFitScaleDown ImageVariantVariantOptionsFit = "scale-down" + ImageVariantVariantOptionsFitContain ImageVariantVariantOptionsFit = "contain" + ImageVariantVariantOptionsFitCover ImageVariantVariantOptionsFit = "cover" + ImageVariantVariantOptionsFitCrop ImageVariantVariantOptionsFit = "crop" + ImageVariantVariantOptionsFitPad ImageVariantVariantOptionsFit = "pad" +) + +// What EXIF data should be preserved in the output image. +type ImageVariantVariantOptionsMetadata string + +const ( + ImageVariantVariantOptionsMetadataKeep ImageVariantVariantOptionsMetadata = "keep" + ImageVariantVariantOptionsMetadataCopyright ImageVariantVariantOptionsMetadata = "copyright" + ImageVariantVariantOptionsMetadataNone ImageVariantVariantOptionsMetadata = "none" +) + +type ImageVariants struct { + Variants ImageVariantsVariants `json:"variants"` + JSON imageVariantsJSON `json:"-"` +} + +// imageVariantsJSON contains the JSON metadata for the struct [ImageVariants] +type imageVariantsJSON struct { + Variants apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ImageVariants) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r imageVariantsJSON) RawJSON() string { + return r.raw +} + +type ImageVariantsVariants struct { + Hero ImageVariantsVariantsHero `json:"hero"` + JSON imageVariantsVariantsJSON `json:"-"` +} + +// imageVariantsVariantsJSON contains the JSON metadata for the struct +// [ImageVariantsVariants] +type imageVariantsVariantsJSON struct { + Hero apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ImageVariantsVariants) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r imageVariantsVariantsJSON) RawJSON() string { + return r.raw +} + +type ImageVariantsVariantsHero struct { + ID interface{} `json:"id,required"` + // Allows you to define image resizing sizes for different use cases. + Options ImageVariantsVariantsHeroOptions `json:"options,required"` + // Indicates whether the variant can access an image without a signature, + // regardless of image access control. + NeverRequireSignedURLs bool `json:"neverRequireSignedURLs"` + JSON imageVariantsVariantsHeroJSON `json:"-"` +} + +// imageVariantsVariantsHeroJSON contains the JSON metadata for the struct +// [ImageVariantsVariantsHero] +type imageVariantsVariantsHeroJSON struct { + ID apijson.Field + Options apijson.Field + NeverRequireSignedURLs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ImageVariantsVariantsHero) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r imageVariantsVariantsHeroJSON) RawJSON() string { + return r.raw +} + +// Allows you to define image resizing sizes for different use cases. +type ImageVariantsVariantsHeroOptions struct { + // The fit property describes how the width and height dimensions should be + // interpreted. + Fit ImageVariantsVariantsHeroOptionsFit `json:"fit,required"` + // Maximum height in image pixels. + Height float64 `json:"height,required"` + // What EXIF data should be preserved in the output image. + Metadata ImageVariantsVariantsHeroOptionsMetadata `json:"metadata,required"` + // Maximum width in image pixels. + Width float64 `json:"width,required"` + JSON imageVariantsVariantsHeroOptionsJSON `json:"-"` +} + +// imageVariantsVariantsHeroOptionsJSON contains the JSON metadata for the struct +// [ImageVariantsVariantsHeroOptions] +type imageVariantsVariantsHeroOptionsJSON struct { + Fit apijson.Field + Height apijson.Field + Metadata apijson.Field + Width apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ImageVariantsVariantsHeroOptions) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r imageVariantsVariantsHeroOptionsJSON) RawJSON() string { + return r.raw +} + +// The fit property describes how the width and height dimensions should be +// interpreted. +type ImageVariantsVariantsHeroOptionsFit string + +const ( + ImageVariantsVariantsHeroOptionsFitScaleDown ImageVariantsVariantsHeroOptionsFit = "scale-down" + ImageVariantsVariantsHeroOptionsFitContain ImageVariantsVariantsHeroOptionsFit = "contain" + ImageVariantsVariantsHeroOptionsFitCover ImageVariantsVariantsHeroOptionsFit = "cover" + ImageVariantsVariantsHeroOptionsFitCrop ImageVariantsVariantsHeroOptionsFit = "crop" + ImageVariantsVariantsHeroOptionsFitPad ImageVariantsVariantsHeroOptionsFit = "pad" +) + +// What EXIF data should be preserved in the output image. +type ImageVariantsVariantsHeroOptionsMetadata string + +const ( + ImageVariantsVariantsHeroOptionsMetadataKeep ImageVariantsVariantsHeroOptionsMetadata = "keep" + ImageVariantsVariantsHeroOptionsMetadataCopyright ImageVariantsVariantsHeroOptionsMetadata = "copyright" + ImageVariantsVariantsHeroOptionsMetadataNone ImageVariantsVariantsHeroOptionsMetadata = "none" +) + +// Union satisfied by [images.V1VariantDeleteResponseUnknown] or +// [shared.UnionString]. +type V1VariantDeleteResponse interface { + ImplementsImagesV1VariantDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*V1VariantDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type V1VariantNewParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + ID param.Field[interface{}] `json:"id,required"` + // Allows you to define image resizing sizes for different use cases. + Options param.Field[V1VariantNewParamsOptions] `json:"options,required"` + // Indicates whether the variant can access an image without a signature, + // regardless of image access control. + NeverRequireSignedURLs param.Field[bool] `json:"neverRequireSignedURLs"` +} + +func (r V1VariantNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Allows you to define image resizing sizes for different use cases. +type V1VariantNewParamsOptions struct { + // The fit property describes how the width and height dimensions should be + // interpreted. + Fit param.Field[V1VariantNewParamsOptionsFit] `json:"fit,required"` + // Maximum height in image pixels. + Height param.Field[float64] `json:"height,required"` + // What EXIF data should be preserved in the output image. + Metadata param.Field[V1VariantNewParamsOptionsMetadata] `json:"metadata,required"` + // Maximum width in image pixels. + Width param.Field[float64] `json:"width,required"` +} + +func (r V1VariantNewParamsOptions) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The fit property describes how the width and height dimensions should be +// interpreted. +type V1VariantNewParamsOptionsFit string + +const ( + V1VariantNewParamsOptionsFitScaleDown V1VariantNewParamsOptionsFit = "scale-down" + V1VariantNewParamsOptionsFitContain V1VariantNewParamsOptionsFit = "contain" + V1VariantNewParamsOptionsFitCover V1VariantNewParamsOptionsFit = "cover" + V1VariantNewParamsOptionsFitCrop V1VariantNewParamsOptionsFit = "crop" + V1VariantNewParamsOptionsFitPad V1VariantNewParamsOptionsFit = "pad" +) + +// What EXIF data should be preserved in the output image. +type V1VariantNewParamsOptionsMetadata string + +const ( + V1VariantNewParamsOptionsMetadataKeep V1VariantNewParamsOptionsMetadata = "keep" + V1VariantNewParamsOptionsMetadataCopyright V1VariantNewParamsOptionsMetadata = "copyright" + V1VariantNewParamsOptionsMetadataNone V1VariantNewParamsOptionsMetadata = "none" +) + +type V1VariantNewResponseEnvelope struct { + Errors []V1VariantNewResponseEnvelopeErrors `json:"errors,required"` + Messages []V1VariantNewResponseEnvelopeMessages `json:"messages,required"` + Result ImageVariant `json:"result,required"` + // Whether the API call was successful + Success V1VariantNewResponseEnvelopeSuccess `json:"success,required"` + JSON v1VariantNewResponseEnvelopeJSON `json:"-"` +} + +// v1VariantNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [V1VariantNewResponseEnvelope] +type v1VariantNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V1VariantNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1VariantNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// v1VariantNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [V1VariantNewResponseEnvelopeErrors] +type v1VariantNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V1VariantNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1VariantNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// v1VariantNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [V1VariantNewResponseEnvelopeMessages] +type v1VariantNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V1VariantNewResponseEnvelopeSuccess bool + +const ( + V1VariantNewResponseEnvelopeSuccessTrue V1VariantNewResponseEnvelopeSuccess = true +) + +type V1VariantListParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type V1VariantListResponseEnvelope struct { + Errors []V1VariantListResponseEnvelopeErrors `json:"errors,required"` + Messages []V1VariantListResponseEnvelopeMessages `json:"messages,required"` + Result ImageVariants `json:"result,required"` + // Whether the API call was successful + Success V1VariantListResponseEnvelopeSuccess `json:"success,required"` + JSON v1VariantListResponseEnvelopeJSON `json:"-"` +} + +// v1VariantListResponseEnvelopeJSON contains the JSON metadata for the struct +// [V1VariantListResponseEnvelope] +type v1VariantListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V1VariantListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1VariantListResponseEnvelopeErrorsJSON `json:"-"` +} + +// v1VariantListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [V1VariantListResponseEnvelopeErrors] +type v1VariantListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V1VariantListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1VariantListResponseEnvelopeMessagesJSON `json:"-"` +} + +// v1VariantListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [V1VariantListResponseEnvelopeMessages] +type v1VariantListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V1VariantListResponseEnvelopeSuccess bool + +const ( + V1VariantListResponseEnvelopeSuccessTrue V1VariantListResponseEnvelopeSuccess = true +) + +type V1VariantDeleteParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type V1VariantDeleteResponseEnvelope struct { + Errors []V1VariantDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []V1VariantDeleteResponseEnvelopeMessages `json:"messages,required"` + Result V1VariantDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success V1VariantDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON v1VariantDeleteResponseEnvelopeJSON `json:"-"` +} + +// v1VariantDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [V1VariantDeleteResponseEnvelope] +type v1VariantDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V1VariantDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1VariantDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// v1VariantDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [V1VariantDeleteResponseEnvelopeErrors] +type v1VariantDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V1VariantDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1VariantDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// v1VariantDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [V1VariantDeleteResponseEnvelopeMessages] +type v1VariantDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V1VariantDeleteResponseEnvelopeSuccess bool + +const ( + V1VariantDeleteResponseEnvelopeSuccessTrue V1VariantDeleteResponseEnvelopeSuccess = true +) + +type V1VariantEditParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + // Allows you to define image resizing sizes for different use cases. + Options param.Field[V1VariantEditParamsOptions] `json:"options,required"` + // Indicates whether the variant can access an image without a signature, + // regardless of image access control. + NeverRequireSignedURLs param.Field[bool] `json:"neverRequireSignedURLs"` +} + +func (r V1VariantEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Allows you to define image resizing sizes for different use cases. +type V1VariantEditParamsOptions struct { + // The fit property describes how the width and height dimensions should be + // interpreted. + Fit param.Field[V1VariantEditParamsOptionsFit] `json:"fit,required"` + // Maximum height in image pixels. + Height param.Field[float64] `json:"height,required"` + // What EXIF data should be preserved in the output image. + Metadata param.Field[V1VariantEditParamsOptionsMetadata] `json:"metadata,required"` + // Maximum width in image pixels. + Width param.Field[float64] `json:"width,required"` +} + +func (r V1VariantEditParamsOptions) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The fit property describes how the width and height dimensions should be +// interpreted. +type V1VariantEditParamsOptionsFit string + +const ( + V1VariantEditParamsOptionsFitScaleDown V1VariantEditParamsOptionsFit = "scale-down" + V1VariantEditParamsOptionsFitContain V1VariantEditParamsOptionsFit = "contain" + V1VariantEditParamsOptionsFitCover V1VariantEditParamsOptionsFit = "cover" + V1VariantEditParamsOptionsFitCrop V1VariantEditParamsOptionsFit = "crop" + V1VariantEditParamsOptionsFitPad V1VariantEditParamsOptionsFit = "pad" +) + +// What EXIF data should be preserved in the output image. +type V1VariantEditParamsOptionsMetadata string + +const ( + V1VariantEditParamsOptionsMetadataKeep V1VariantEditParamsOptionsMetadata = "keep" + V1VariantEditParamsOptionsMetadataCopyright V1VariantEditParamsOptionsMetadata = "copyright" + V1VariantEditParamsOptionsMetadataNone V1VariantEditParamsOptionsMetadata = "none" +) + +type V1VariantEditResponseEnvelope struct { + Errors []V1VariantEditResponseEnvelopeErrors `json:"errors,required"` + Messages []V1VariantEditResponseEnvelopeMessages `json:"messages,required"` + Result ImageVariant `json:"result,required"` + // Whether the API call was successful + Success V1VariantEditResponseEnvelopeSuccess `json:"success,required"` + JSON v1VariantEditResponseEnvelopeJSON `json:"-"` +} + +// v1VariantEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [V1VariantEditResponseEnvelope] +type v1VariantEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V1VariantEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1VariantEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// v1VariantEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [V1VariantEditResponseEnvelopeErrors] +type v1VariantEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V1VariantEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1VariantEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// v1VariantEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [V1VariantEditResponseEnvelopeMessages] +type v1VariantEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V1VariantEditResponseEnvelopeSuccess bool + +const ( + V1VariantEditResponseEnvelopeSuccessTrue V1VariantEditResponseEnvelopeSuccess = true +) + +type V1VariantGetParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type V1VariantGetResponseEnvelope struct { + Errors []V1VariantGetResponseEnvelopeErrors `json:"errors,required"` + Messages []V1VariantGetResponseEnvelopeMessages `json:"messages,required"` + Result ImageVariant `json:"result,required"` + // Whether the API call was successful + Success V1VariantGetResponseEnvelopeSuccess `json:"success,required"` + JSON v1VariantGetResponseEnvelopeJSON `json:"-"` +} + +// v1VariantGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [V1VariantGetResponseEnvelope] +type v1VariantGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V1VariantGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1VariantGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// v1VariantGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [V1VariantGetResponseEnvelopeErrors] +type v1VariantGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V1VariantGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v1VariantGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// v1VariantGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [V1VariantGetResponseEnvelopeMessages] +type v1VariantGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V1VariantGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v1VariantGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V1VariantGetResponseEnvelopeSuccess bool + +const ( + V1VariantGetResponseEnvelopeSuccessTrue V1VariantGetResponseEnvelopeSuccess = true +) diff --git a/images/v1variant_test.go b/images/v1variant_test.go new file mode 100644 index 00000000000..b9fe0bebf28 --- /dev/null +++ b/images/v1variant_test.go @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package images_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/images" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestV1VariantNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Images.V1.Variants.New(context.TODO(), images.V1VariantNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + ID: cloudflare.F[any]("hero"), + Options: cloudflare.F(images.V1VariantNewParamsOptions{ + Fit: cloudflare.F(images.V1VariantNewParamsOptionsFitScaleDown), + Height: cloudflare.F(768.000000), + Metadata: cloudflare.F(images.V1VariantNewParamsOptionsMetadataNone), + Width: cloudflare.F(1366.000000), + }), + NeverRequireSignedURLs: cloudflare.F(true), + }) + 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 TestV1VariantList(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("user@example.com"), + ) + _, err := client.Images.V1.Variants.List(context.TODO(), images.V1VariantListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestV1VariantDelete(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("user@example.com"), + ) + _, err := client.Images.V1.Variants.Delete( + context.TODO(), + "hero", + images.V1VariantDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestV1VariantEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Images.V1.Variants.Edit( + context.TODO(), + "hero", + images.V1VariantEditParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Options: cloudflare.F(images.V1VariantEditParamsOptions{ + Fit: cloudflare.F(images.V1VariantEditParamsOptionsFitScaleDown), + Height: cloudflare.F(768.000000), + Metadata: cloudflare.F(images.V1VariantEditParamsOptionsMetadataNone), + Width: cloudflare.F(1366.000000), + }), + NeverRequireSignedURLs: cloudflare.F(true), + }, + ) + 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 TestV1VariantGet(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("user@example.com"), + ) + _, err := client.Images.V1.Variants.Get( + context.TODO(), + "hero", + images.V1VariantGetParams{ + AccountID: cloudflare.F("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/images/v2.go b/images/v2.go new file mode 100644 index 00000000000..a773830f6f6 --- /dev/null +++ b/images/v2.go @@ -0,0 +1,182 @@ +// File generated from our OpenAPI spec by Stainless. + +package images + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// V2Service 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 [NewV2Service] method instead. +type V2Service struct { + Options []option.RequestOption + DirectUploads *V2DirectUploadService +} + +// NewV2Service 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 NewV2Service(opts ...option.RequestOption) (r *V2Service) { + r = &V2Service{} + r.Options = opts + r.DirectUploads = NewV2DirectUploadService(opts...) + return +} + +// List up to 10000 images with one request. Use the optional parameters below to +// get a specific range of images. Endpoint returns continuation_token if more +// images are present. +func (r *V2Service) List(ctx context.Context, params V2ListParams, opts ...option.RequestOption) (res *V2ListResponse, err error) { + opts = append(r.Options[:], opts...) + var env V2ListResponseEnvelope + path := fmt.Sprintf("accounts/%s/images/v2", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type V2ListResponse struct { + // Continuation token to fetch next page. Passed as a query param when requesting + // List V2 api endpoint. + ContinuationToken string `json:"continuation_token,nullable"` + Images []ImagesImage `json:"images"` + JSON v2ListResponseJSON `json:"-"` +} + +// v2ListResponseJSON contains the JSON metadata for the struct [V2ListResponse] +type v2ListResponseJSON struct { + ContinuationToken apijson.Field + Images apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V2ListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v2ListResponseJSON) RawJSON() string { + return r.raw +} + +type V2ListParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + // Continuation token for a next page. List images V2 returns continuation_token + ContinuationToken param.Field[string] `query:"continuation_token"` + // Number of items per page. + PerPage param.Field[float64] `query:"per_page"` + // Sorting order by upload time. + SortOrder param.Field[V2ListParamsSortOrder] `query:"sort_order"` +} + +// URLQuery serializes [V2ListParams]'s query parameters as `url.Values`. +func (r V2ListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Sorting order by upload time. +type V2ListParamsSortOrder string + +const ( + V2ListParamsSortOrderAsc V2ListParamsSortOrder = "asc" + V2ListParamsSortOrderDesc V2ListParamsSortOrder = "desc" +) + +type V2ListResponseEnvelope struct { + Errors []V2ListResponseEnvelopeErrors `json:"errors,required"` + Messages []V2ListResponseEnvelopeMessages `json:"messages,required"` + Result V2ListResponse `json:"result,required"` + // Whether the API call was successful + Success V2ListResponseEnvelopeSuccess `json:"success,required"` + JSON v2ListResponseEnvelopeJSON `json:"-"` +} + +// v2ListResponseEnvelopeJSON contains the JSON metadata for the struct +// [V2ListResponseEnvelope] +type v2ListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V2ListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v2ListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V2ListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v2ListResponseEnvelopeErrorsJSON `json:"-"` +} + +// v2ListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [V2ListResponseEnvelopeErrors] +type v2ListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V2ListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v2ListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V2ListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v2ListResponseEnvelopeMessagesJSON `json:"-"` +} + +// v2ListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [V2ListResponseEnvelopeMessages] +type v2ListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V2ListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v2ListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V2ListResponseEnvelopeSuccess bool + +const ( + V2ListResponseEnvelopeSuccessTrue V2ListResponseEnvelopeSuccess = true +) diff --git a/images/v2_test.go b/images/v2_test.go new file mode 100644 index 00000000000..9f239da6334 --- /dev/null +++ b/images/v2_test.go @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package images_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/images" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestV2ListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Images.V2.List(context.TODO(), images.V2ListParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + ContinuationToken: cloudflare.F("string"), + PerPage: cloudflare.F(10.000000), + SortOrder: cloudflare.F(images.V2ListParamsSortOrderAsc), + }) + 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/images/v2directupload.go b/images/v2directupload.go new file mode 100644 index 00000000000..25dc4514cb2 --- /dev/null +++ b/images/v2directupload.go @@ -0,0 +1,176 @@ +// File generated from our OpenAPI spec by Stainless. + +package images + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// V2DirectUploadService 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 [NewV2DirectUploadService] method +// instead. +type V2DirectUploadService struct { + Options []option.RequestOption +} + +// NewV2DirectUploadService 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 NewV2DirectUploadService(opts ...option.RequestOption) (r *V2DirectUploadService) { + r = &V2DirectUploadService{} + r.Options = opts + return +} + +// Direct uploads allow users to upload images without API keys. A common use case +// are web apps, client-side applications, or mobile devices where users upload +// content directly to Cloudflare Images. This method creates a draft record for a +// future image. It returns an upload URL and an image identifier. To verify if the +// image itself has been uploaded, send an image details request +// (accounts/:account_identifier/images/v1/:identifier), and check that the +// `draft: true` property is not present. +func (r *V2DirectUploadService) New(ctx context.Context, params V2DirectUploadNewParams, opts ...option.RequestOption) (res *V2DirectUploadNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env V2DirectUploadNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/images/v2/direct_upload", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type V2DirectUploadNewResponse struct { + // Image unique identifier. + ID string `json:"id"` + // The URL the unauthenticated upload can be performed to using a single HTTP POST + // (multipart/form-data) request. + UploadURL string `json:"uploadURL"` + JSON v2DirectUploadNewResponseJSON `json:"-"` +} + +// v2DirectUploadNewResponseJSON contains the JSON metadata for the struct +// [V2DirectUploadNewResponse] +type v2DirectUploadNewResponseJSON struct { + ID apijson.Field + UploadURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V2DirectUploadNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v2DirectUploadNewResponseJSON) RawJSON() string { + return r.raw +} + +type V2DirectUploadNewParams struct { + // Account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + // The date after which the upload will not be accepted. Minimum: Now + 2 minutes. + // Maximum: Now + 6 hours. + Expiry param.Field[time.Time] `json:"expiry" format:"date-time"` + // User modifiable key-value store. Can be used for keeping references to another + // system of record, for managing images. + Metadata param.Field[interface{}] `json:"metadata"` + // Indicates whether the image requires a signature token to be accessed. + RequireSignedURLs param.Field[bool] `json:"requireSignedURLs"` +} + +func (r V2DirectUploadNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type V2DirectUploadNewResponseEnvelope struct { + Errors []V2DirectUploadNewResponseEnvelopeErrors `json:"errors,required"` + Messages []V2DirectUploadNewResponseEnvelopeMessages `json:"messages,required"` + Result V2DirectUploadNewResponse `json:"result,required"` + // Whether the API call was successful + Success V2DirectUploadNewResponseEnvelopeSuccess `json:"success,required"` + JSON v2DirectUploadNewResponseEnvelopeJSON `json:"-"` +} + +// v2DirectUploadNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [V2DirectUploadNewResponseEnvelope] +type v2DirectUploadNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V2DirectUploadNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v2DirectUploadNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type V2DirectUploadNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v2DirectUploadNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// v2DirectUploadNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [V2DirectUploadNewResponseEnvelopeErrors] +type v2DirectUploadNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V2DirectUploadNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v2DirectUploadNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type V2DirectUploadNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON v2DirectUploadNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// v2DirectUploadNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [V2DirectUploadNewResponseEnvelopeMessages] +type v2DirectUploadNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *V2DirectUploadNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r v2DirectUploadNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type V2DirectUploadNewResponseEnvelopeSuccess bool + +const ( + V2DirectUploadNewResponseEnvelopeSuccessTrue V2DirectUploadNewResponseEnvelopeSuccess = true +) diff --git a/images/v2directupload_test.go b/images/v2directupload_test.go new file mode 100644 index 00000000000..db32a3d8408 --- /dev/null +++ b/images/v2directupload_test.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package images_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/images" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestV2DirectUploadNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Images.V2.DirectUploads.New(context.TODO(), images.V2DirectUploadNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Expiry: cloudflare.F(time.Now()), + Metadata: cloudflare.F[any](map[string]interface{}{}), + RequireSignedURLs: cloudflare.F(true), + }) + 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/imagev1.go b/imagev1.go deleted file mode 100644 index a942f102762..00000000000 --- a/imagev1.go +++ /dev/null @@ -1,887 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ImageV1Service 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 [NewImageV1Service] method instead. -type ImageV1Service struct { - Options []option.RequestOption - Keys *ImageV1KeyService - Stats *ImageV1StatService - Variants *ImageV1VariantService - Blobs *ImageV1BlobService -} - -// NewImageV1Service 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 NewImageV1Service(opts ...option.RequestOption) (r *ImageV1Service) { - r = &ImageV1Service{} - r.Options = opts - r.Keys = NewImageV1KeyService(opts...) - r.Stats = NewImageV1StatService(opts...) - r.Variants = NewImageV1VariantService(opts...) - r.Blobs = NewImageV1BlobService(opts...) - return -} - -// Upload an image with up to 10 Megabytes using a single HTTP POST -// (multipart/form-data) request. An image can be uploaded by sending an image file -// or passing an accessible to an API url. -func (r *ImageV1Service) New(ctx context.Context, params ImageV1NewParams, opts ...option.RequestOption) (res *ImageV1NewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ImageV1NewResponseEnvelope - path := fmt.Sprintf("accounts/%s/images/v1", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List up to 100 images with one request. Use the optional parameters below to get -// a specific range of images. -func (r *ImageV1Service) List(ctx context.Context, params ImageV1ListParams, opts ...option.RequestOption) (res *shared.V4PagePagination[ImageV1ListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("accounts/%s/images/v1", params.AccountID) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// List up to 100 images with one request. Use the optional parameters below to get -// a specific range of images. -func (r *ImageV1Service) ListAutoPaging(ctx context.Context, params ImageV1ListParams, opts ...option.RequestOption) *shared.V4PagePaginationAutoPager[ImageV1ListResponse] { - return shared.NewV4PagePaginationAutoPager(r.List(ctx, params, opts...)) -} - -// Delete an image on Cloudflare Images. On success, all copies of the image are -// deleted and purged from cache. -func (r *ImageV1Service) Delete(ctx context.Context, imageID string, body ImageV1DeleteParams, opts ...option.RequestOption) (res *ImageV1DeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ImageV1DeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/images/v1/%s", body.AccountID, imageID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update image access control. On access control change, all copies of the image -// are purged from cache. -func (r *ImageV1Service) Edit(ctx context.Context, imageID string, params ImageV1EditParams, opts ...option.RequestOption) (res *ImageV1EditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ImageV1EditResponseEnvelope - path := fmt.Sprintf("accounts/%s/images/v1/%s", params.AccountID, imageID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch details for a single image. -func (r *ImageV1Service) Get(ctx context.Context, imageID string, query ImageV1GetParams, opts ...option.RequestOption) (res *ImageV1GetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ImageV1GetResponseEnvelope - path := fmt.Sprintf("accounts/%s/images/v1/%s", query.AccountID, imageID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ImageV1NewResponse struct { - // Image unique identifier. - ID string `json:"id"` - // Image file name. - Filename string `json:"filename"` - // User modifiable key-value store. Can be used for keeping references to another - // system of record for managing images. Metadata must not exceed 1024 bytes. - Meta interface{} `json:"meta"` - // Indicates whether the image can be a accessed only using it's UID. If set to - // true, a signed token needs to be generated with a signing key to view the image. - RequireSignedURLs bool `json:"requireSignedURLs"` - // When the media item was uploaded. - Uploaded time.Time `json:"uploaded" format:"date-time"` - // Object specifying available variants for an image. - Variants []ImageV1NewResponseVariant `json:"variants" format:"uri"` - JSON imageV1NewResponseJSON `json:"-"` -} - -// imageV1NewResponseJSON contains the JSON metadata for the struct -// [ImageV1NewResponse] -type imageV1NewResponseJSON struct { - ID apijson.Field - Filename apijson.Field - Meta apijson.Field - RequireSignedURLs apijson.Field - Uploaded apijson.Field - Variants apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1NewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1NewResponseJSON) RawJSON() string { - return r.raw -} - -// URI to thumbnail variant for an image. -// -// Union satisfied by [shared.UnionString], [shared.UnionString] or -// [shared.UnionString]. -type ImageV1NewResponseVariant interface { - ImplementsImageV1NewResponseVariant() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ImageV1NewResponseVariant)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ImageV1ListResponse struct { - Errors []ImageV1ListResponseError `json:"errors,required"` - Messages []ImageV1ListResponseMessage `json:"messages,required"` - Result ImageV1ListResponseResult `json:"result,required"` - // Whether the API call was successful - Success ImageV1ListResponseSuccess `json:"success,required"` - JSON imageV1ListResponseJSON `json:"-"` -} - -// imageV1ListResponseJSON contains the JSON metadata for the struct -// [ImageV1ListResponse] -type imageV1ListResponseJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1ListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1ListResponseJSON) RawJSON() string { - return r.raw -} - -type ImageV1ListResponseError struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1ListResponseErrorJSON `json:"-"` -} - -// imageV1ListResponseErrorJSON contains the JSON metadata for the struct -// [ImageV1ListResponseError] -type imageV1ListResponseErrorJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1ListResponseError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1ListResponseErrorJSON) RawJSON() string { - return r.raw -} - -type ImageV1ListResponseMessage struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1ListResponseMessageJSON `json:"-"` -} - -// imageV1ListResponseMessageJSON contains the JSON metadata for the struct -// [ImageV1ListResponseMessage] -type imageV1ListResponseMessageJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1ListResponseMessage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1ListResponseMessageJSON) RawJSON() string { - return r.raw -} - -type ImageV1ListResponseResult struct { - Images []ImageV1ListResponseResultImage `json:"images"` - JSON imageV1ListResponseResultJSON `json:"-"` -} - -// imageV1ListResponseResultJSON contains the JSON metadata for the struct -// [ImageV1ListResponseResult] -type imageV1ListResponseResultJSON struct { - Images apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1ListResponseResult) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1ListResponseResultJSON) RawJSON() string { - return r.raw -} - -type ImageV1ListResponseResultImage struct { - // Image unique identifier. - ID string `json:"id"` - // Image file name. - Filename string `json:"filename"` - // User modifiable key-value store. Can be used for keeping references to another - // system of record for managing images. Metadata must not exceed 1024 bytes. - Meta interface{} `json:"meta"` - // Indicates whether the image can be a accessed only using it's UID. If set to - // true, a signed token needs to be generated with a signing key to view the image. - RequireSignedURLs bool `json:"requireSignedURLs"` - // When the media item was uploaded. - Uploaded time.Time `json:"uploaded" format:"date-time"` - // Object specifying available variants for an image. - Variants []ImageV1ListResponseResultImagesVariant `json:"variants" format:"uri"` - JSON imageV1ListResponseResultImageJSON `json:"-"` -} - -// imageV1ListResponseResultImageJSON contains the JSON metadata for the struct -// [ImageV1ListResponseResultImage] -type imageV1ListResponseResultImageJSON struct { - ID apijson.Field - Filename apijson.Field - Meta apijson.Field - RequireSignedURLs apijson.Field - Uploaded apijson.Field - Variants apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1ListResponseResultImage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1ListResponseResultImageJSON) RawJSON() string { - return r.raw -} - -// URI to thumbnail variant for an image. -// -// Union satisfied by [shared.UnionString], [shared.UnionString] or -// [shared.UnionString]. -type ImageV1ListResponseResultImagesVariant interface { - ImplementsImageV1ListResponseResultImagesVariant() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ImageV1ListResponseResultImagesVariant)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Whether the API call was successful -type ImageV1ListResponseSuccess bool - -const ( - ImageV1ListResponseSuccessTrue ImageV1ListResponseSuccess = true -) - -// Union satisfied by [ImageV1DeleteResponseUnknown] or [shared.UnionString]. -type ImageV1DeleteResponse interface { - ImplementsImageV1DeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ImageV1DeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ImageV1EditResponse struct { - // Image unique identifier. - ID string `json:"id"` - // Image file name. - Filename string `json:"filename"` - // User modifiable key-value store. Can be used for keeping references to another - // system of record for managing images. Metadata must not exceed 1024 bytes. - Meta interface{} `json:"meta"` - // Indicates whether the image can be a accessed only using it's UID. If set to - // true, a signed token needs to be generated with a signing key to view the image. - RequireSignedURLs bool `json:"requireSignedURLs"` - // When the media item was uploaded. - Uploaded time.Time `json:"uploaded" format:"date-time"` - // Object specifying available variants for an image. - Variants []ImageV1EditResponseVariant `json:"variants" format:"uri"` - JSON imageV1EditResponseJSON `json:"-"` -} - -// imageV1EditResponseJSON contains the JSON metadata for the struct -// [ImageV1EditResponse] -type imageV1EditResponseJSON struct { - ID apijson.Field - Filename apijson.Field - Meta apijson.Field - RequireSignedURLs apijson.Field - Uploaded apijson.Field - Variants apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1EditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1EditResponseJSON) RawJSON() string { - return r.raw -} - -// URI to thumbnail variant for an image. -// -// Union satisfied by [shared.UnionString], [shared.UnionString] or -// [shared.UnionString]. -type ImageV1EditResponseVariant interface { - ImplementsImageV1EditResponseVariant() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ImageV1EditResponseVariant)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ImageV1GetResponse struct { - // Image unique identifier. - ID string `json:"id"` - // Image file name. - Filename string `json:"filename"` - // User modifiable key-value store. Can be used for keeping references to another - // system of record for managing images. Metadata must not exceed 1024 bytes. - Meta interface{} `json:"meta"` - // Indicates whether the image can be a accessed only using it's UID. If set to - // true, a signed token needs to be generated with a signing key to view the image. - RequireSignedURLs bool `json:"requireSignedURLs"` - // When the media item was uploaded. - Uploaded time.Time `json:"uploaded" format:"date-time"` - // Object specifying available variants for an image. - Variants []ImageV1GetResponseVariant `json:"variants" format:"uri"` - JSON imageV1GetResponseJSON `json:"-"` -} - -// imageV1GetResponseJSON contains the JSON metadata for the struct -// [ImageV1GetResponse] -type imageV1GetResponseJSON struct { - ID apijson.Field - Filename apijson.Field - Meta apijson.Field - RequireSignedURLs apijson.Field - Uploaded apijson.Field - Variants apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1GetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1GetResponseJSON) RawJSON() string { - return r.raw -} - -// URI to thumbnail variant for an image. -// -// Union satisfied by [shared.UnionString], [shared.UnionString] or -// [shared.UnionString]. -type ImageV1GetResponseVariant interface { - ImplementsImageV1GetResponseVariant() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ImageV1GetResponseVariant)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ImageV1NewParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - Metadata param.Field[interface{}] `json:"metadata"` - // Indicates whether the image requires a signature token for the access. - RequireSignedURLs param.Field[bool] `json:"requireSignedURLs"` -} - -func (r ImageV1NewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ImageV1NewResponseEnvelope struct { - Errors []ImageV1NewResponseEnvelopeErrors `json:"errors,required"` - Messages []ImageV1NewResponseEnvelopeMessages `json:"messages,required"` - Result ImageV1NewResponse `json:"result,required"` - // Whether the API call was successful - Success ImageV1NewResponseEnvelopeSuccess `json:"success,required"` - JSON imageV1NewResponseEnvelopeJSON `json:"-"` -} - -// imageV1NewResponseEnvelopeJSON contains the JSON metadata for the struct -// [ImageV1NewResponseEnvelope] -type imageV1NewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1NewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1NewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ImageV1NewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1NewResponseEnvelopeErrorsJSON `json:"-"` -} - -// imageV1NewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ImageV1NewResponseEnvelopeErrors] -type imageV1NewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1NewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1NewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ImageV1NewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1NewResponseEnvelopeMessagesJSON `json:"-"` -} - -// imageV1NewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ImageV1NewResponseEnvelopeMessages] -type imageV1NewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1NewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1NewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ImageV1NewResponseEnvelopeSuccess bool - -const ( - ImageV1NewResponseEnvelopeSuccessTrue ImageV1NewResponseEnvelopeSuccess = true -) - -type ImageV1ListParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // Number of items per page. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [ImageV1ListParams]'s query parameters as `url.Values`. -func (r ImageV1ListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type ImageV1DeleteParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type ImageV1DeleteResponseEnvelope struct { - Errors []ImageV1DeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ImageV1DeleteResponseEnvelopeMessages `json:"messages,required"` - Result ImageV1DeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ImageV1DeleteResponseEnvelopeSuccess `json:"success,required"` - JSON imageV1DeleteResponseEnvelopeJSON `json:"-"` -} - -// imageV1DeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [ImageV1DeleteResponseEnvelope] -type imageV1DeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1DeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1DeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ImageV1DeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1DeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// imageV1DeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ImageV1DeleteResponseEnvelopeErrors] -type imageV1DeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1DeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1DeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ImageV1DeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1DeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// imageV1DeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ImageV1DeleteResponseEnvelopeMessages] -type imageV1DeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1DeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1DeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ImageV1DeleteResponseEnvelopeSuccess bool - -const ( - ImageV1DeleteResponseEnvelopeSuccessTrue ImageV1DeleteResponseEnvelopeSuccess = true -) - -type ImageV1EditParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // User modifiable key-value store. Can be used for keeping references to another - // system of record for managing images. No change if not specified. - Metadata param.Field[interface{}] `json:"metadata"` - // Indicates whether the image can be accessed using only its UID. If set to - // `true`, a signed token needs to be generated with a signing key to view the - // image. Returns a new UID on a change. No change if not specified. - RequireSignedURLs param.Field[bool] `json:"requireSignedURLs"` -} - -func (r ImageV1EditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ImageV1EditResponseEnvelope struct { - Errors []ImageV1EditResponseEnvelopeErrors `json:"errors,required"` - Messages []ImageV1EditResponseEnvelopeMessages `json:"messages,required"` - Result ImageV1EditResponse `json:"result,required"` - // Whether the API call was successful - Success ImageV1EditResponseEnvelopeSuccess `json:"success,required"` - JSON imageV1EditResponseEnvelopeJSON `json:"-"` -} - -// imageV1EditResponseEnvelopeJSON contains the JSON metadata for the struct -// [ImageV1EditResponseEnvelope] -type imageV1EditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1EditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1EditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ImageV1EditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1EditResponseEnvelopeErrorsJSON `json:"-"` -} - -// imageV1EditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ImageV1EditResponseEnvelopeErrors] -type imageV1EditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1EditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1EditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ImageV1EditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1EditResponseEnvelopeMessagesJSON `json:"-"` -} - -// imageV1EditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ImageV1EditResponseEnvelopeMessages] -type imageV1EditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1EditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1EditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ImageV1EditResponseEnvelopeSuccess bool - -const ( - ImageV1EditResponseEnvelopeSuccessTrue ImageV1EditResponseEnvelopeSuccess = true -) - -type ImageV1GetParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type ImageV1GetResponseEnvelope struct { - Errors []ImageV1GetResponseEnvelopeErrors `json:"errors,required"` - Messages []ImageV1GetResponseEnvelopeMessages `json:"messages,required"` - Result ImageV1GetResponse `json:"result,required"` - // Whether the API call was successful - Success ImageV1GetResponseEnvelopeSuccess `json:"success,required"` - JSON imageV1GetResponseEnvelopeJSON `json:"-"` -} - -// imageV1GetResponseEnvelopeJSON contains the JSON metadata for the struct -// [ImageV1GetResponseEnvelope] -type imageV1GetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1GetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1GetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ImageV1GetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1GetResponseEnvelopeErrorsJSON `json:"-"` -} - -// imageV1GetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ImageV1GetResponseEnvelopeErrors] -type imageV1GetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1GetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1GetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ImageV1GetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1GetResponseEnvelopeMessagesJSON `json:"-"` -} - -// imageV1GetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [ImageV1GetResponseEnvelopeMessages] -type imageV1GetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1GetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1GetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ImageV1GetResponseEnvelopeSuccess bool - -const ( - ImageV1GetResponseEnvelopeSuccessTrue ImageV1GetResponseEnvelopeSuccess = true -) diff --git a/imagev1_test.go b/imagev1_test.go deleted file mode 100644 index c206daf719b..00000000000 --- a/imagev1_test.go +++ /dev/null @@ -1,162 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestImageV1NewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Images.V1.New(context.TODO(), cloudflare.ImageV1NewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Metadata: cloudflare.F[any](map[string]interface{}{}), - RequireSignedURLs: cloudflare.F(true), - }) - 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 TestImageV1ListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Images.V1.List(context.TODO(), cloudflare.ImageV1ListParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(10.000000), - }) - 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 TestImageV1Delete(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("user@example.com"), - ) - _, err := client.Images.V1.Delete( - context.TODO(), - "string", - cloudflare.ImageV1DeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestImageV1EditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Images.V1.Edit( - context.TODO(), - "string", - cloudflare.ImageV1EditParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Metadata: cloudflare.F[any](map[string]interface{}{}), - RequireSignedURLs: cloudflare.F(true), - }, - ) - 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 TestImageV1Get(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("user@example.com"), - ) - _, err := client.Images.V1.Get( - context.TODO(), - "string", - cloudflare.ImageV1GetParams{ - AccountID: cloudflare.F("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/imagev1blob.go b/imagev1blob.go deleted file mode 100644 index 7cf964b5162..00000000000 --- a/imagev1blob.go +++ /dev/null @@ -1,46 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ImageV1BlobService 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 [NewImageV1BlobService] method -// instead. -type ImageV1BlobService struct { - Options []option.RequestOption -} - -// NewImageV1BlobService 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 NewImageV1BlobService(opts ...option.RequestOption) (r *ImageV1BlobService) { - r = &ImageV1BlobService{} - r.Options = opts - return -} - -// Fetch base image. For most images this will be the originally uploaded file. For -// larger images it can be a near-lossless version of the original. -func (r *ImageV1BlobService) Get(ctx context.Context, imageID string, query ImageV1BlobGetParams, opts ...option.RequestOption) (res *http.Response, err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "image/*")}, opts...) - path := fmt.Sprintf("accounts/%s/images/v1/%s/blob", query.AccountID, imageID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -type ImageV1BlobGetParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} diff --git a/imagev1blob_test.go b/imagev1blob_test.go deleted file mode 100644 index 3ae7dabbcfe..00000000000 --- a/imagev1blob_test.go +++ /dev/null @@ -1,58 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "bytes" - "context" - "errors" - "io" - "net/http" - "net/http/httptest" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestImageV1BlobGet(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - w.Write([]byte("abc")) - })) - defer server.Close() - baseURL := server.URL - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - resp, err := client.Images.V1.Blobs.Get( - context.TODO(), - "string", - cloudflare.ImageV1BlobGetParams{ - AccountID: cloudflare.F("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()) - } - defer resp.Body.Close() - - b, err := io.ReadAll(resp.Body) - 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()) - } - if !bytes.Equal(b, []byte("abc")) { - t.Fatalf("return value not %s: %s", "abc", b) - } -} diff --git a/imagev1key.go b/imagev1key.go deleted file mode 100644 index 8c73486211f..00000000000 --- a/imagev1key.go +++ /dev/null @@ -1,176 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ImageV1KeyService 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 [NewImageV1KeyService] method instead. -type ImageV1KeyService struct { - Options []option.RequestOption -} - -// NewImageV1KeyService 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 NewImageV1KeyService(opts ...option.RequestOption) (r *ImageV1KeyService) { - r = &ImageV1KeyService{} - r.Options = opts - return -} - -// Lists your signing keys. These can be found on your Cloudflare Images dashboard. -func (r *ImageV1KeyService) List(ctx context.Context, query ImageV1KeyListParams, opts ...option.RequestOption) (res *ImageV1KeyListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ImageV1KeyListResponseEnvelope - path := fmt.Sprintf("accounts/%s/images/v1/keys", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ImageV1KeyListResponse struct { - Keys []ImageV1KeyListResponseKey `json:"keys"` - JSON imageV1KeyListResponseJSON `json:"-"` -} - -// imageV1KeyListResponseJSON contains the JSON metadata for the struct -// [ImageV1KeyListResponse] -type imageV1KeyListResponseJSON struct { - Keys apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1KeyListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1KeyListResponseJSON) RawJSON() string { - return r.raw -} - -type ImageV1KeyListResponseKey struct { - // Key name. - Name string `json:"name"` - // Key value. - Value string `json:"value"` - JSON imageV1KeyListResponseKeyJSON `json:"-"` -} - -// imageV1KeyListResponseKeyJSON contains the JSON metadata for the struct -// [ImageV1KeyListResponseKey] -type imageV1KeyListResponseKeyJSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1KeyListResponseKey) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1KeyListResponseKeyJSON) RawJSON() string { - return r.raw -} - -type ImageV1KeyListParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type ImageV1KeyListResponseEnvelope struct { - Errors []ImageV1KeyListResponseEnvelopeErrors `json:"errors,required"` - Messages []ImageV1KeyListResponseEnvelopeMessages `json:"messages,required"` - Result ImageV1KeyListResponse `json:"result,required"` - // Whether the API call was successful - Success ImageV1KeyListResponseEnvelopeSuccess `json:"success,required"` - JSON imageV1KeyListResponseEnvelopeJSON `json:"-"` -} - -// imageV1KeyListResponseEnvelopeJSON contains the JSON metadata for the struct -// [ImageV1KeyListResponseEnvelope] -type imageV1KeyListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1KeyListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1KeyListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ImageV1KeyListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1KeyListResponseEnvelopeErrorsJSON `json:"-"` -} - -// imageV1KeyListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ImageV1KeyListResponseEnvelopeErrors] -type imageV1KeyListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1KeyListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1KeyListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ImageV1KeyListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1KeyListResponseEnvelopeMessagesJSON `json:"-"` -} - -// imageV1KeyListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ImageV1KeyListResponseEnvelopeMessages] -type imageV1KeyListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1KeyListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1KeyListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ImageV1KeyListResponseEnvelopeSuccess bool - -const ( - ImageV1KeyListResponseEnvelopeSuccessTrue ImageV1KeyListResponseEnvelopeSuccess = true -) diff --git a/imagev1key_test.go b/imagev1key_test.go deleted file mode 100644 index f9bbe1819d4..00000000000 --- a/imagev1key_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestImageV1KeyList(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("user@example.com"), - ) - _, err := client.Images.V1.Keys.List(context.TODO(), cloudflare.ImageV1KeyListParams{ - AccountID: cloudflare.F("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/imagev1stat.go b/imagev1stat.go deleted file mode 100644 index fb9c3a1cee5..00000000000 --- a/imagev1stat.go +++ /dev/null @@ -1,177 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ImageV1StatService 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 [NewImageV1StatService] method -// instead. -type ImageV1StatService struct { - Options []option.RequestOption -} - -// NewImageV1StatService 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 NewImageV1StatService(opts ...option.RequestOption) (r *ImageV1StatService) { - r = &ImageV1StatService{} - r.Options = opts - return -} - -// Fetch usage statistics details for Cloudflare Images. -func (r *ImageV1StatService) Get(ctx context.Context, query ImageV1StatGetParams, opts ...option.RequestOption) (res *ImageV1StatGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ImageV1StatGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/images/v1/stats", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ImageV1StatGetResponse struct { - Count ImageV1StatGetResponseCount `json:"count"` - JSON imageV1StatGetResponseJSON `json:"-"` -} - -// imageV1StatGetResponseJSON contains the JSON metadata for the struct -// [ImageV1StatGetResponse] -type imageV1StatGetResponseJSON struct { - Count apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1StatGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1StatGetResponseJSON) RawJSON() string { - return r.raw -} - -type ImageV1StatGetResponseCount struct { - // Cloudflare Images allowed usage. - Allowed float64 `json:"allowed"` - // Cloudflare Images current usage. - Current float64 `json:"current"` - JSON imageV1StatGetResponseCountJSON `json:"-"` -} - -// imageV1StatGetResponseCountJSON contains the JSON metadata for the struct -// [ImageV1StatGetResponseCount] -type imageV1StatGetResponseCountJSON struct { - Allowed apijson.Field - Current apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1StatGetResponseCount) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1StatGetResponseCountJSON) RawJSON() string { - return r.raw -} - -type ImageV1StatGetParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type ImageV1StatGetResponseEnvelope struct { - Errors []ImageV1StatGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ImageV1StatGetResponseEnvelopeMessages `json:"messages,required"` - Result ImageV1StatGetResponse `json:"result,required"` - // Whether the API call was successful - Success ImageV1StatGetResponseEnvelopeSuccess `json:"success,required"` - JSON imageV1StatGetResponseEnvelopeJSON `json:"-"` -} - -// imageV1StatGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [ImageV1StatGetResponseEnvelope] -type imageV1StatGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1StatGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1StatGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ImageV1StatGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1StatGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// imageV1StatGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ImageV1StatGetResponseEnvelopeErrors] -type imageV1StatGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1StatGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1StatGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ImageV1StatGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1StatGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// imageV1StatGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ImageV1StatGetResponseEnvelopeMessages] -type imageV1StatGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1StatGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1StatGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ImageV1StatGetResponseEnvelopeSuccess bool - -const ( - ImageV1StatGetResponseEnvelopeSuccessTrue ImageV1StatGetResponseEnvelopeSuccess = true -) diff --git a/imagev1stat_test.go b/imagev1stat_test.go deleted file mode 100644 index 100e138a255..00000000000 --- a/imagev1stat_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestImageV1StatGet(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("user@example.com"), - ) - _, err := client.Images.V1.Stats.Get(context.TODO(), cloudflare.ImageV1StatGetParams{ - AccountID: cloudflare.F("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/imagev1variant.go b/imagev1variant.go deleted file mode 100644 index 1e998bccf9a..00000000000 --- a/imagev1variant.go +++ /dev/null @@ -1,1075 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ImageV1VariantService 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 [NewImageV1VariantService] method -// instead. -type ImageV1VariantService struct { - Options []option.RequestOption -} - -// NewImageV1VariantService 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 NewImageV1VariantService(opts ...option.RequestOption) (r *ImageV1VariantService) { - r = &ImageV1VariantService{} - r.Options = opts - return -} - -// Specify variants that allow you to resize images for different use cases. -func (r *ImageV1VariantService) New(ctx context.Context, params ImageV1VariantNewParams, opts ...option.RequestOption) (res *ImageV1VariantNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ImageV1VariantNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/images/v1/variants", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists existing variants. -func (r *ImageV1VariantService) List(ctx context.Context, query ImageV1VariantListParams, opts ...option.RequestOption) (res *ImageV1VariantListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ImageV1VariantListResponseEnvelope - path := fmt.Sprintf("accounts/%s/images/v1/variants", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deleting a variant purges the cache for all images associated with the variant. -func (r *ImageV1VariantService) Delete(ctx context.Context, variantID interface{}, body ImageV1VariantDeleteParams, opts ...option.RequestOption) (res *ImageV1VariantDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ImageV1VariantDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/images/v1/variants/%v", body.AccountID, variantID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updating a variant purges the cache for all images associated with the variant. -func (r *ImageV1VariantService) Edit(ctx context.Context, variantID interface{}, params ImageV1VariantEditParams, opts ...option.RequestOption) (res *ImageV1VariantEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ImageV1VariantEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/images/v1/variants/%v", params.AccountID, variantID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch details for a single variant. -func (r *ImageV1VariantService) Get(ctx context.Context, variantID interface{}, query ImageV1VariantGetParams, opts ...option.RequestOption) (res *ImageV1VariantGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ImageV1VariantGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/images/v1/variants/%v", query.AccountID, variantID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ImageV1VariantNewResponse struct { - Variant ImageV1VariantNewResponseVariant `json:"variant"` - JSON imageV1VariantNewResponseJSON `json:"-"` -} - -// imageV1VariantNewResponseJSON contains the JSON metadata for the struct -// [ImageV1VariantNewResponse] -type imageV1VariantNewResponseJSON struct { - Variant apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantNewResponseJSON) RawJSON() string { - return r.raw -} - -type ImageV1VariantNewResponseVariant struct { - ID interface{} `json:"id,required"` - // Allows you to define image resizing sizes for different use cases. - Options ImageV1VariantNewResponseVariantOptions `json:"options,required"` - // Indicates whether the variant can access an image without a signature, - // regardless of image access control. - NeverRequireSignedURLs bool `json:"neverRequireSignedURLs"` - JSON imageV1VariantNewResponseVariantJSON `json:"-"` -} - -// imageV1VariantNewResponseVariantJSON contains the JSON metadata for the struct -// [ImageV1VariantNewResponseVariant] -type imageV1VariantNewResponseVariantJSON struct { - ID apijson.Field - Options apijson.Field - NeverRequireSignedURLs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantNewResponseVariant) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantNewResponseVariantJSON) RawJSON() string { - return r.raw -} - -// Allows you to define image resizing sizes for different use cases. -type ImageV1VariantNewResponseVariantOptions struct { - // The fit property describes how the width and height dimensions should be - // interpreted. - Fit ImageV1VariantNewResponseVariantOptionsFit `json:"fit,required"` - // Maximum height in image pixels. - Height float64 `json:"height,required"` - // What EXIF data should be preserved in the output image. - Metadata ImageV1VariantNewResponseVariantOptionsMetadata `json:"metadata,required"` - // Maximum width in image pixels. - Width float64 `json:"width,required"` - JSON imageV1VariantNewResponseVariantOptionsJSON `json:"-"` -} - -// imageV1VariantNewResponseVariantOptionsJSON contains the JSON metadata for the -// struct [ImageV1VariantNewResponseVariantOptions] -type imageV1VariantNewResponseVariantOptionsJSON struct { - Fit apijson.Field - Height apijson.Field - Metadata apijson.Field - Width apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantNewResponseVariantOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantNewResponseVariantOptionsJSON) RawJSON() string { - return r.raw -} - -// The fit property describes how the width and height dimensions should be -// interpreted. -type ImageV1VariantNewResponseVariantOptionsFit string - -const ( - ImageV1VariantNewResponseVariantOptionsFitScaleDown ImageV1VariantNewResponseVariantOptionsFit = "scale-down" - ImageV1VariantNewResponseVariantOptionsFitContain ImageV1VariantNewResponseVariantOptionsFit = "contain" - ImageV1VariantNewResponseVariantOptionsFitCover ImageV1VariantNewResponseVariantOptionsFit = "cover" - ImageV1VariantNewResponseVariantOptionsFitCrop ImageV1VariantNewResponseVariantOptionsFit = "crop" - ImageV1VariantNewResponseVariantOptionsFitPad ImageV1VariantNewResponseVariantOptionsFit = "pad" -) - -// What EXIF data should be preserved in the output image. -type ImageV1VariantNewResponseVariantOptionsMetadata string - -const ( - ImageV1VariantNewResponseVariantOptionsMetadataKeep ImageV1VariantNewResponseVariantOptionsMetadata = "keep" - ImageV1VariantNewResponseVariantOptionsMetadataCopyright ImageV1VariantNewResponseVariantOptionsMetadata = "copyright" - ImageV1VariantNewResponseVariantOptionsMetadataNone ImageV1VariantNewResponseVariantOptionsMetadata = "none" -) - -type ImageV1VariantListResponse struct { - Variants ImageV1VariantListResponseVariants `json:"variants"` - JSON imageV1VariantListResponseJSON `json:"-"` -} - -// imageV1VariantListResponseJSON contains the JSON metadata for the struct -// [ImageV1VariantListResponse] -type imageV1VariantListResponseJSON struct { - Variants apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantListResponseJSON) RawJSON() string { - return r.raw -} - -type ImageV1VariantListResponseVariants struct { - Hero ImageV1VariantListResponseVariantsHero `json:"hero"` - JSON imageV1VariantListResponseVariantsJSON `json:"-"` -} - -// imageV1VariantListResponseVariantsJSON contains the JSON metadata for the struct -// [ImageV1VariantListResponseVariants] -type imageV1VariantListResponseVariantsJSON struct { - Hero apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantListResponseVariants) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantListResponseVariantsJSON) RawJSON() string { - return r.raw -} - -type ImageV1VariantListResponseVariantsHero struct { - ID interface{} `json:"id,required"` - // Allows you to define image resizing sizes for different use cases. - Options ImageV1VariantListResponseVariantsHeroOptions `json:"options,required"` - // Indicates whether the variant can access an image without a signature, - // regardless of image access control. - NeverRequireSignedURLs bool `json:"neverRequireSignedURLs"` - JSON imageV1VariantListResponseVariantsHeroJSON `json:"-"` -} - -// imageV1VariantListResponseVariantsHeroJSON contains the JSON metadata for the -// struct [ImageV1VariantListResponseVariantsHero] -type imageV1VariantListResponseVariantsHeroJSON struct { - ID apijson.Field - Options apijson.Field - NeverRequireSignedURLs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantListResponseVariantsHero) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantListResponseVariantsHeroJSON) RawJSON() string { - return r.raw -} - -// Allows you to define image resizing sizes for different use cases. -type ImageV1VariantListResponseVariantsHeroOptions struct { - // The fit property describes how the width and height dimensions should be - // interpreted. - Fit ImageV1VariantListResponseVariantsHeroOptionsFit `json:"fit,required"` - // Maximum height in image pixels. - Height float64 `json:"height,required"` - // What EXIF data should be preserved in the output image. - Metadata ImageV1VariantListResponseVariantsHeroOptionsMetadata `json:"metadata,required"` - // Maximum width in image pixels. - Width float64 `json:"width,required"` - JSON imageV1VariantListResponseVariantsHeroOptionsJSON `json:"-"` -} - -// imageV1VariantListResponseVariantsHeroOptionsJSON contains the JSON metadata for -// the struct [ImageV1VariantListResponseVariantsHeroOptions] -type imageV1VariantListResponseVariantsHeroOptionsJSON struct { - Fit apijson.Field - Height apijson.Field - Metadata apijson.Field - Width apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantListResponseVariantsHeroOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantListResponseVariantsHeroOptionsJSON) RawJSON() string { - return r.raw -} - -// The fit property describes how the width and height dimensions should be -// interpreted. -type ImageV1VariantListResponseVariantsHeroOptionsFit string - -const ( - ImageV1VariantListResponseVariantsHeroOptionsFitScaleDown ImageV1VariantListResponseVariantsHeroOptionsFit = "scale-down" - ImageV1VariantListResponseVariantsHeroOptionsFitContain ImageV1VariantListResponseVariantsHeroOptionsFit = "contain" - ImageV1VariantListResponseVariantsHeroOptionsFitCover ImageV1VariantListResponseVariantsHeroOptionsFit = "cover" - ImageV1VariantListResponseVariantsHeroOptionsFitCrop ImageV1VariantListResponseVariantsHeroOptionsFit = "crop" - ImageV1VariantListResponseVariantsHeroOptionsFitPad ImageV1VariantListResponseVariantsHeroOptionsFit = "pad" -) - -// What EXIF data should be preserved in the output image. -type ImageV1VariantListResponseVariantsHeroOptionsMetadata string - -const ( - ImageV1VariantListResponseVariantsHeroOptionsMetadataKeep ImageV1VariantListResponseVariantsHeroOptionsMetadata = "keep" - ImageV1VariantListResponseVariantsHeroOptionsMetadataCopyright ImageV1VariantListResponseVariantsHeroOptionsMetadata = "copyright" - ImageV1VariantListResponseVariantsHeroOptionsMetadataNone ImageV1VariantListResponseVariantsHeroOptionsMetadata = "none" -) - -// Union satisfied by [ImageV1VariantDeleteResponseUnknown] or -// [shared.UnionString]. -type ImageV1VariantDeleteResponse interface { - ImplementsImageV1VariantDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ImageV1VariantDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ImageV1VariantEditResponse struct { - Variant ImageV1VariantEditResponseVariant `json:"variant"` - JSON imageV1VariantEditResponseJSON `json:"-"` -} - -// imageV1VariantEditResponseJSON contains the JSON metadata for the struct -// [ImageV1VariantEditResponse] -type imageV1VariantEditResponseJSON struct { - Variant apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantEditResponseJSON) RawJSON() string { - return r.raw -} - -type ImageV1VariantEditResponseVariant struct { - ID interface{} `json:"id,required"` - // Allows you to define image resizing sizes for different use cases. - Options ImageV1VariantEditResponseVariantOptions `json:"options,required"` - // Indicates whether the variant can access an image without a signature, - // regardless of image access control. - NeverRequireSignedURLs bool `json:"neverRequireSignedURLs"` - JSON imageV1VariantEditResponseVariantJSON `json:"-"` -} - -// imageV1VariantEditResponseVariantJSON contains the JSON metadata for the struct -// [ImageV1VariantEditResponseVariant] -type imageV1VariantEditResponseVariantJSON struct { - ID apijson.Field - Options apijson.Field - NeverRequireSignedURLs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantEditResponseVariant) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantEditResponseVariantJSON) RawJSON() string { - return r.raw -} - -// Allows you to define image resizing sizes for different use cases. -type ImageV1VariantEditResponseVariantOptions struct { - // The fit property describes how the width and height dimensions should be - // interpreted. - Fit ImageV1VariantEditResponseVariantOptionsFit `json:"fit,required"` - // Maximum height in image pixels. - Height float64 `json:"height,required"` - // What EXIF data should be preserved in the output image. - Metadata ImageV1VariantEditResponseVariantOptionsMetadata `json:"metadata,required"` - // Maximum width in image pixels. - Width float64 `json:"width,required"` - JSON imageV1VariantEditResponseVariantOptionsJSON `json:"-"` -} - -// imageV1VariantEditResponseVariantOptionsJSON contains the JSON metadata for the -// struct [ImageV1VariantEditResponseVariantOptions] -type imageV1VariantEditResponseVariantOptionsJSON struct { - Fit apijson.Field - Height apijson.Field - Metadata apijson.Field - Width apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantEditResponseVariantOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantEditResponseVariantOptionsJSON) RawJSON() string { - return r.raw -} - -// The fit property describes how the width and height dimensions should be -// interpreted. -type ImageV1VariantEditResponseVariantOptionsFit string - -const ( - ImageV1VariantEditResponseVariantOptionsFitScaleDown ImageV1VariantEditResponseVariantOptionsFit = "scale-down" - ImageV1VariantEditResponseVariantOptionsFitContain ImageV1VariantEditResponseVariantOptionsFit = "contain" - ImageV1VariantEditResponseVariantOptionsFitCover ImageV1VariantEditResponseVariantOptionsFit = "cover" - ImageV1VariantEditResponseVariantOptionsFitCrop ImageV1VariantEditResponseVariantOptionsFit = "crop" - ImageV1VariantEditResponseVariantOptionsFitPad ImageV1VariantEditResponseVariantOptionsFit = "pad" -) - -// What EXIF data should be preserved in the output image. -type ImageV1VariantEditResponseVariantOptionsMetadata string - -const ( - ImageV1VariantEditResponseVariantOptionsMetadataKeep ImageV1VariantEditResponseVariantOptionsMetadata = "keep" - ImageV1VariantEditResponseVariantOptionsMetadataCopyright ImageV1VariantEditResponseVariantOptionsMetadata = "copyright" - ImageV1VariantEditResponseVariantOptionsMetadataNone ImageV1VariantEditResponseVariantOptionsMetadata = "none" -) - -type ImageV1VariantGetResponse struct { - Variant ImageV1VariantGetResponseVariant `json:"variant"` - JSON imageV1VariantGetResponseJSON `json:"-"` -} - -// imageV1VariantGetResponseJSON contains the JSON metadata for the struct -// [ImageV1VariantGetResponse] -type imageV1VariantGetResponseJSON struct { - Variant apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantGetResponseJSON) RawJSON() string { - return r.raw -} - -type ImageV1VariantGetResponseVariant struct { - ID interface{} `json:"id,required"` - // Allows you to define image resizing sizes for different use cases. - Options ImageV1VariantGetResponseVariantOptions `json:"options,required"` - // Indicates whether the variant can access an image without a signature, - // regardless of image access control. - NeverRequireSignedURLs bool `json:"neverRequireSignedURLs"` - JSON imageV1VariantGetResponseVariantJSON `json:"-"` -} - -// imageV1VariantGetResponseVariantJSON contains the JSON metadata for the struct -// [ImageV1VariantGetResponseVariant] -type imageV1VariantGetResponseVariantJSON struct { - ID apijson.Field - Options apijson.Field - NeverRequireSignedURLs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantGetResponseVariant) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantGetResponseVariantJSON) RawJSON() string { - return r.raw -} - -// Allows you to define image resizing sizes for different use cases. -type ImageV1VariantGetResponseVariantOptions struct { - // The fit property describes how the width and height dimensions should be - // interpreted. - Fit ImageV1VariantGetResponseVariantOptionsFit `json:"fit,required"` - // Maximum height in image pixels. - Height float64 `json:"height,required"` - // What EXIF data should be preserved in the output image. - Metadata ImageV1VariantGetResponseVariantOptionsMetadata `json:"metadata,required"` - // Maximum width in image pixels. - Width float64 `json:"width,required"` - JSON imageV1VariantGetResponseVariantOptionsJSON `json:"-"` -} - -// imageV1VariantGetResponseVariantOptionsJSON contains the JSON metadata for the -// struct [ImageV1VariantGetResponseVariantOptions] -type imageV1VariantGetResponseVariantOptionsJSON struct { - Fit apijson.Field - Height apijson.Field - Metadata apijson.Field - Width apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantGetResponseVariantOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantGetResponseVariantOptionsJSON) RawJSON() string { - return r.raw -} - -// The fit property describes how the width and height dimensions should be -// interpreted. -type ImageV1VariantGetResponseVariantOptionsFit string - -const ( - ImageV1VariantGetResponseVariantOptionsFitScaleDown ImageV1VariantGetResponseVariantOptionsFit = "scale-down" - ImageV1VariantGetResponseVariantOptionsFitContain ImageV1VariantGetResponseVariantOptionsFit = "contain" - ImageV1VariantGetResponseVariantOptionsFitCover ImageV1VariantGetResponseVariantOptionsFit = "cover" - ImageV1VariantGetResponseVariantOptionsFitCrop ImageV1VariantGetResponseVariantOptionsFit = "crop" - ImageV1VariantGetResponseVariantOptionsFitPad ImageV1VariantGetResponseVariantOptionsFit = "pad" -) - -// What EXIF data should be preserved in the output image. -type ImageV1VariantGetResponseVariantOptionsMetadata string - -const ( - ImageV1VariantGetResponseVariantOptionsMetadataKeep ImageV1VariantGetResponseVariantOptionsMetadata = "keep" - ImageV1VariantGetResponseVariantOptionsMetadataCopyright ImageV1VariantGetResponseVariantOptionsMetadata = "copyright" - ImageV1VariantGetResponseVariantOptionsMetadataNone ImageV1VariantGetResponseVariantOptionsMetadata = "none" -) - -type ImageV1VariantNewParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - ID param.Field[interface{}] `json:"id,required"` - // Allows you to define image resizing sizes for different use cases. - Options param.Field[ImageV1VariantNewParamsOptions] `json:"options,required"` - // Indicates whether the variant can access an image without a signature, - // regardless of image access control. - NeverRequireSignedURLs param.Field[bool] `json:"neverRequireSignedURLs"` -} - -func (r ImageV1VariantNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Allows you to define image resizing sizes for different use cases. -type ImageV1VariantNewParamsOptions struct { - // The fit property describes how the width and height dimensions should be - // interpreted. - Fit param.Field[ImageV1VariantNewParamsOptionsFit] `json:"fit,required"` - // Maximum height in image pixels. - Height param.Field[float64] `json:"height,required"` - // What EXIF data should be preserved in the output image. - Metadata param.Field[ImageV1VariantNewParamsOptionsMetadata] `json:"metadata,required"` - // Maximum width in image pixels. - Width param.Field[float64] `json:"width,required"` -} - -func (r ImageV1VariantNewParamsOptions) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The fit property describes how the width and height dimensions should be -// interpreted. -type ImageV1VariantNewParamsOptionsFit string - -const ( - ImageV1VariantNewParamsOptionsFitScaleDown ImageV1VariantNewParamsOptionsFit = "scale-down" - ImageV1VariantNewParamsOptionsFitContain ImageV1VariantNewParamsOptionsFit = "contain" - ImageV1VariantNewParamsOptionsFitCover ImageV1VariantNewParamsOptionsFit = "cover" - ImageV1VariantNewParamsOptionsFitCrop ImageV1VariantNewParamsOptionsFit = "crop" - ImageV1VariantNewParamsOptionsFitPad ImageV1VariantNewParamsOptionsFit = "pad" -) - -// What EXIF data should be preserved in the output image. -type ImageV1VariantNewParamsOptionsMetadata string - -const ( - ImageV1VariantNewParamsOptionsMetadataKeep ImageV1VariantNewParamsOptionsMetadata = "keep" - ImageV1VariantNewParamsOptionsMetadataCopyright ImageV1VariantNewParamsOptionsMetadata = "copyright" - ImageV1VariantNewParamsOptionsMetadataNone ImageV1VariantNewParamsOptionsMetadata = "none" -) - -type ImageV1VariantNewResponseEnvelope struct { - Errors []ImageV1VariantNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ImageV1VariantNewResponseEnvelopeMessages `json:"messages,required"` - Result ImageV1VariantNewResponse `json:"result,required"` - // Whether the API call was successful - Success ImageV1VariantNewResponseEnvelopeSuccess `json:"success,required"` - JSON imageV1VariantNewResponseEnvelopeJSON `json:"-"` -} - -// imageV1VariantNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [ImageV1VariantNewResponseEnvelope] -type imageV1VariantNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ImageV1VariantNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1VariantNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// imageV1VariantNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ImageV1VariantNewResponseEnvelopeErrors] -type imageV1VariantNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ImageV1VariantNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1VariantNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// imageV1VariantNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ImageV1VariantNewResponseEnvelopeMessages] -type imageV1VariantNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ImageV1VariantNewResponseEnvelopeSuccess bool - -const ( - ImageV1VariantNewResponseEnvelopeSuccessTrue ImageV1VariantNewResponseEnvelopeSuccess = true -) - -type ImageV1VariantListParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type ImageV1VariantListResponseEnvelope struct { - Errors []ImageV1VariantListResponseEnvelopeErrors `json:"errors,required"` - Messages []ImageV1VariantListResponseEnvelopeMessages `json:"messages,required"` - Result ImageV1VariantListResponse `json:"result,required"` - // Whether the API call was successful - Success ImageV1VariantListResponseEnvelopeSuccess `json:"success,required"` - JSON imageV1VariantListResponseEnvelopeJSON `json:"-"` -} - -// imageV1VariantListResponseEnvelopeJSON contains the JSON metadata for the struct -// [ImageV1VariantListResponseEnvelope] -type imageV1VariantListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ImageV1VariantListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1VariantListResponseEnvelopeErrorsJSON `json:"-"` -} - -// imageV1VariantListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ImageV1VariantListResponseEnvelopeErrors] -type imageV1VariantListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ImageV1VariantListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1VariantListResponseEnvelopeMessagesJSON `json:"-"` -} - -// imageV1VariantListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ImageV1VariantListResponseEnvelopeMessages] -type imageV1VariantListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ImageV1VariantListResponseEnvelopeSuccess bool - -const ( - ImageV1VariantListResponseEnvelopeSuccessTrue ImageV1VariantListResponseEnvelopeSuccess = true -) - -type ImageV1VariantDeleteParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type ImageV1VariantDeleteResponseEnvelope struct { - Errors []ImageV1VariantDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ImageV1VariantDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ImageV1VariantDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ImageV1VariantDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON imageV1VariantDeleteResponseEnvelopeJSON `json:"-"` -} - -// imageV1VariantDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [ImageV1VariantDeleteResponseEnvelope] -type imageV1VariantDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ImageV1VariantDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1VariantDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// imageV1VariantDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ImageV1VariantDeleteResponseEnvelopeErrors] -type imageV1VariantDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ImageV1VariantDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1VariantDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// imageV1VariantDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ImageV1VariantDeleteResponseEnvelopeMessages] -type imageV1VariantDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ImageV1VariantDeleteResponseEnvelopeSuccess bool - -const ( - ImageV1VariantDeleteResponseEnvelopeSuccessTrue ImageV1VariantDeleteResponseEnvelopeSuccess = true -) - -type ImageV1VariantEditParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // Allows you to define image resizing sizes for different use cases. - Options param.Field[ImageV1VariantEditParamsOptions] `json:"options,required"` - // Indicates whether the variant can access an image without a signature, - // regardless of image access control. - NeverRequireSignedURLs param.Field[bool] `json:"neverRequireSignedURLs"` -} - -func (r ImageV1VariantEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Allows you to define image resizing sizes for different use cases. -type ImageV1VariantEditParamsOptions struct { - // The fit property describes how the width and height dimensions should be - // interpreted. - Fit param.Field[ImageV1VariantEditParamsOptionsFit] `json:"fit,required"` - // Maximum height in image pixels. - Height param.Field[float64] `json:"height,required"` - // What EXIF data should be preserved in the output image. - Metadata param.Field[ImageV1VariantEditParamsOptionsMetadata] `json:"metadata,required"` - // Maximum width in image pixels. - Width param.Field[float64] `json:"width,required"` -} - -func (r ImageV1VariantEditParamsOptions) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The fit property describes how the width and height dimensions should be -// interpreted. -type ImageV1VariantEditParamsOptionsFit string - -const ( - ImageV1VariantEditParamsOptionsFitScaleDown ImageV1VariantEditParamsOptionsFit = "scale-down" - ImageV1VariantEditParamsOptionsFitContain ImageV1VariantEditParamsOptionsFit = "contain" - ImageV1VariantEditParamsOptionsFitCover ImageV1VariantEditParamsOptionsFit = "cover" - ImageV1VariantEditParamsOptionsFitCrop ImageV1VariantEditParamsOptionsFit = "crop" - ImageV1VariantEditParamsOptionsFitPad ImageV1VariantEditParamsOptionsFit = "pad" -) - -// What EXIF data should be preserved in the output image. -type ImageV1VariantEditParamsOptionsMetadata string - -const ( - ImageV1VariantEditParamsOptionsMetadataKeep ImageV1VariantEditParamsOptionsMetadata = "keep" - ImageV1VariantEditParamsOptionsMetadataCopyright ImageV1VariantEditParamsOptionsMetadata = "copyright" - ImageV1VariantEditParamsOptionsMetadataNone ImageV1VariantEditParamsOptionsMetadata = "none" -) - -type ImageV1VariantEditResponseEnvelope struct { - Errors []ImageV1VariantEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ImageV1VariantEditResponseEnvelopeMessages `json:"messages,required"` - Result ImageV1VariantEditResponse `json:"result,required"` - // Whether the API call was successful - Success ImageV1VariantEditResponseEnvelopeSuccess `json:"success,required"` - JSON imageV1VariantEditResponseEnvelopeJSON `json:"-"` -} - -// imageV1VariantEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [ImageV1VariantEditResponseEnvelope] -type imageV1VariantEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ImageV1VariantEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1VariantEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// imageV1VariantEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ImageV1VariantEditResponseEnvelopeErrors] -type imageV1VariantEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ImageV1VariantEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1VariantEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// imageV1VariantEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ImageV1VariantEditResponseEnvelopeMessages] -type imageV1VariantEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ImageV1VariantEditResponseEnvelopeSuccess bool - -const ( - ImageV1VariantEditResponseEnvelopeSuccessTrue ImageV1VariantEditResponseEnvelopeSuccess = true -) - -type ImageV1VariantGetParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type ImageV1VariantGetResponseEnvelope struct { - Errors []ImageV1VariantGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ImageV1VariantGetResponseEnvelopeMessages `json:"messages,required"` - Result ImageV1VariantGetResponse `json:"result,required"` - // Whether the API call was successful - Success ImageV1VariantGetResponseEnvelopeSuccess `json:"success,required"` - JSON imageV1VariantGetResponseEnvelopeJSON `json:"-"` -} - -// imageV1VariantGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [ImageV1VariantGetResponseEnvelope] -type imageV1VariantGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ImageV1VariantGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1VariantGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// imageV1VariantGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ImageV1VariantGetResponseEnvelopeErrors] -type imageV1VariantGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ImageV1VariantGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV1VariantGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// imageV1VariantGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ImageV1VariantGetResponseEnvelopeMessages] -type imageV1VariantGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV1VariantGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV1VariantGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ImageV1VariantGetResponseEnvelopeSuccess bool - -const ( - ImageV1VariantGetResponseEnvelopeSuccessTrue ImageV1VariantGetResponseEnvelopeSuccess = true -) diff --git a/imagev1variant_test.go b/imagev1variant_test.go deleted file mode 100644 index 14ad686e1ab..00000000000 --- a/imagev1variant_test.go +++ /dev/null @@ -1,171 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestImageV1VariantNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Images.V1.Variants.New(context.TODO(), cloudflare.ImageV1VariantNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - ID: cloudflare.F[any]("hero"), - Options: cloudflare.F(cloudflare.ImageV1VariantNewParamsOptions{ - Fit: cloudflare.F(cloudflare.ImageV1VariantNewParamsOptionsFitScaleDown), - Height: cloudflare.F(768.000000), - Metadata: cloudflare.F(cloudflare.ImageV1VariantNewParamsOptionsMetadataNone), - Width: cloudflare.F(1366.000000), - }), - NeverRequireSignedURLs: cloudflare.F(true), - }) - 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 TestImageV1VariantList(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("user@example.com"), - ) - _, err := client.Images.V1.Variants.List(context.TODO(), cloudflare.ImageV1VariantListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestImageV1VariantDelete(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("user@example.com"), - ) - _, err := client.Images.V1.Variants.Delete( - context.TODO(), - "hero", - cloudflare.ImageV1VariantDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestImageV1VariantEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Images.V1.Variants.Edit( - context.TODO(), - "hero", - cloudflare.ImageV1VariantEditParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Options: cloudflare.F(cloudflare.ImageV1VariantEditParamsOptions{ - Fit: cloudflare.F(cloudflare.ImageV1VariantEditParamsOptionsFitScaleDown), - Height: cloudflare.F(768.000000), - Metadata: cloudflare.F(cloudflare.ImageV1VariantEditParamsOptionsMetadataNone), - Width: cloudflare.F(1366.000000), - }), - NeverRequireSignedURLs: cloudflare.F(true), - }, - ) - 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 TestImageV1VariantGet(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("user@example.com"), - ) - _, err := client.Images.V1.Variants.Get( - context.TODO(), - "hero", - cloudflare.ImageV1VariantGetParams{ - AccountID: cloudflare.F("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/imagev2.go b/imagev2.go deleted file mode 100644 index 784b9d4960a..00000000000 --- a/imagev2.go +++ /dev/null @@ -1,253 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ImageV2Service 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 [NewImageV2Service] method instead. -type ImageV2Service struct { - Options []option.RequestOption - DirectUploads *ImageV2DirectUploadService -} - -// NewImageV2Service 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 NewImageV2Service(opts ...option.RequestOption) (r *ImageV2Service) { - r = &ImageV2Service{} - r.Options = opts - r.DirectUploads = NewImageV2DirectUploadService(opts...) - return -} - -// List up to 10000 images with one request. Use the optional parameters below to -// get a specific range of images. Endpoint returns continuation_token if more -// images are present. -func (r *ImageV2Service) List(ctx context.Context, params ImageV2ListParams, opts ...option.RequestOption) (res *ImageV2ListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ImageV2ListResponseEnvelope - path := fmt.Sprintf("accounts/%s/images/v2", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ImageV2ListResponse struct { - // Continuation token to fetch next page. Passed as a query param when requesting - // List V2 api endpoint. - ContinuationToken string `json:"continuation_token,nullable"` - Images []ImageV2ListResponseImage `json:"images"` - JSON imageV2ListResponseJSON `json:"-"` -} - -// imageV2ListResponseJSON contains the JSON metadata for the struct -// [ImageV2ListResponse] -type imageV2ListResponseJSON struct { - ContinuationToken apijson.Field - Images apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV2ListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV2ListResponseJSON) RawJSON() string { - return r.raw -} - -type ImageV2ListResponseImage struct { - // Image unique identifier. - ID string `json:"id"` - // Image file name. - Filename string `json:"filename"` - // User modifiable key-value store. Can be used for keeping references to another - // system of record for managing images. Metadata must not exceed 1024 bytes. - Meta interface{} `json:"meta"` - // Indicates whether the image can be a accessed only using it's UID. If set to - // true, a signed token needs to be generated with a signing key to view the image. - RequireSignedURLs bool `json:"requireSignedURLs"` - // When the media item was uploaded. - Uploaded time.Time `json:"uploaded" format:"date-time"` - // Object specifying available variants for an image. - Variants []ImageV2ListResponseImagesVariant `json:"variants" format:"uri"` - JSON imageV2ListResponseImageJSON `json:"-"` -} - -// imageV2ListResponseImageJSON contains the JSON metadata for the struct -// [ImageV2ListResponseImage] -type imageV2ListResponseImageJSON struct { - ID apijson.Field - Filename apijson.Field - Meta apijson.Field - RequireSignedURLs apijson.Field - Uploaded apijson.Field - Variants apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV2ListResponseImage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV2ListResponseImageJSON) RawJSON() string { - return r.raw -} - -// URI to thumbnail variant for an image. -// -// Union satisfied by [shared.UnionString], [shared.UnionString] or -// [shared.UnionString]. -type ImageV2ListResponseImagesVariant interface { - ImplementsImageV2ListResponseImagesVariant() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ImageV2ListResponseImagesVariant)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ImageV2ListParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // Continuation token for a next page. List images V2 returns continuation_token - ContinuationToken param.Field[string] `query:"continuation_token"` - // Number of items per page. - PerPage param.Field[float64] `query:"per_page"` - // Sorting order by upload time. - SortOrder param.Field[ImageV2ListParamsSortOrder] `query:"sort_order"` -} - -// URLQuery serializes [ImageV2ListParams]'s query parameters as `url.Values`. -func (r ImageV2ListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Sorting order by upload time. -type ImageV2ListParamsSortOrder string - -const ( - ImageV2ListParamsSortOrderAsc ImageV2ListParamsSortOrder = "asc" - ImageV2ListParamsSortOrderDesc ImageV2ListParamsSortOrder = "desc" -) - -type ImageV2ListResponseEnvelope struct { - Errors []ImageV2ListResponseEnvelopeErrors `json:"errors,required"` - Messages []ImageV2ListResponseEnvelopeMessages `json:"messages,required"` - Result ImageV2ListResponse `json:"result,required"` - // Whether the API call was successful - Success ImageV2ListResponseEnvelopeSuccess `json:"success,required"` - JSON imageV2ListResponseEnvelopeJSON `json:"-"` -} - -// imageV2ListResponseEnvelopeJSON contains the JSON metadata for the struct -// [ImageV2ListResponseEnvelope] -type imageV2ListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV2ListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV2ListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ImageV2ListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV2ListResponseEnvelopeErrorsJSON `json:"-"` -} - -// imageV2ListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ImageV2ListResponseEnvelopeErrors] -type imageV2ListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV2ListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV2ListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ImageV2ListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV2ListResponseEnvelopeMessagesJSON `json:"-"` -} - -// imageV2ListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ImageV2ListResponseEnvelopeMessages] -type imageV2ListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV2ListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV2ListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ImageV2ListResponseEnvelopeSuccess bool - -const ( - ImageV2ListResponseEnvelopeSuccessTrue ImageV2ListResponseEnvelopeSuccess = true -) diff --git a/imagev2_test.go b/imagev2_test.go deleted file mode 100644 index 2882b56d907..00000000000 --- a/imagev2_test.go +++ /dev/null @@ -1,43 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestImageV2ListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Images.V2.List(context.TODO(), cloudflare.ImageV2ListParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - ContinuationToken: cloudflare.F("string"), - PerPage: cloudflare.F(10.000000), - SortOrder: cloudflare.F(cloudflare.ImageV2ListParamsSortOrderAsc), - }) - 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/imagev2directupload.go b/imagev2directupload.go deleted file mode 100644 index a9811d897e6..00000000000 --- a/imagev2directupload.go +++ /dev/null @@ -1,176 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ImageV2DirectUploadService 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 [NewImageV2DirectUploadService] -// method instead. -type ImageV2DirectUploadService struct { - Options []option.RequestOption -} - -// NewImageV2DirectUploadService 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 NewImageV2DirectUploadService(opts ...option.RequestOption) (r *ImageV2DirectUploadService) { - r = &ImageV2DirectUploadService{} - r.Options = opts - return -} - -// Direct uploads allow users to upload images without API keys. A common use case -// are web apps, client-side applications, or mobile devices where users upload -// content directly to Cloudflare Images. This method creates a draft record for a -// future image. It returns an upload URL and an image identifier. To verify if the -// image itself has been uploaded, send an image details request -// (accounts/:account_identifier/images/v1/:identifier), and check that the -// `draft: true` property is not present. -func (r *ImageV2DirectUploadService) New(ctx context.Context, params ImageV2DirectUploadNewParams, opts ...option.RequestOption) (res *ImageV2DirectUploadNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ImageV2DirectUploadNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/images/v2/direct_upload", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ImageV2DirectUploadNewResponse struct { - // Image unique identifier. - ID string `json:"id"` - // The URL the unauthenticated upload can be performed to using a single HTTP POST - // (multipart/form-data) request. - UploadURL string `json:"uploadURL"` - JSON imageV2DirectUploadNewResponseJSON `json:"-"` -} - -// imageV2DirectUploadNewResponseJSON contains the JSON metadata for the struct -// [ImageV2DirectUploadNewResponse] -type imageV2DirectUploadNewResponseJSON struct { - ID apijson.Field - UploadURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV2DirectUploadNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV2DirectUploadNewResponseJSON) RawJSON() string { - return r.raw -} - -type ImageV2DirectUploadNewParams struct { - // Account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // The date after which the upload will not be accepted. Minimum: Now + 2 minutes. - // Maximum: Now + 6 hours. - Expiry param.Field[time.Time] `json:"expiry" format:"date-time"` - // User modifiable key-value store. Can be used for keeping references to another - // system of record, for managing images. - Metadata param.Field[interface{}] `json:"metadata"` - // Indicates whether the image requires a signature token to be accessed. - RequireSignedURLs param.Field[bool] `json:"requireSignedURLs"` -} - -func (r ImageV2DirectUploadNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ImageV2DirectUploadNewResponseEnvelope struct { - Errors []ImageV2DirectUploadNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ImageV2DirectUploadNewResponseEnvelopeMessages `json:"messages,required"` - Result ImageV2DirectUploadNewResponse `json:"result,required"` - // Whether the API call was successful - Success ImageV2DirectUploadNewResponseEnvelopeSuccess `json:"success,required"` - JSON imageV2DirectUploadNewResponseEnvelopeJSON `json:"-"` -} - -// imageV2DirectUploadNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [ImageV2DirectUploadNewResponseEnvelope] -type imageV2DirectUploadNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV2DirectUploadNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV2DirectUploadNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ImageV2DirectUploadNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV2DirectUploadNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// imageV2DirectUploadNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ImageV2DirectUploadNewResponseEnvelopeErrors] -type imageV2DirectUploadNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV2DirectUploadNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV2DirectUploadNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ImageV2DirectUploadNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON imageV2DirectUploadNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// imageV2DirectUploadNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ImageV2DirectUploadNewResponseEnvelopeMessages] -type imageV2DirectUploadNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ImageV2DirectUploadNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r imageV2DirectUploadNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ImageV2DirectUploadNewResponseEnvelopeSuccess bool - -const ( - ImageV2DirectUploadNewResponseEnvelopeSuccessTrue ImageV2DirectUploadNewResponseEnvelopeSuccess = true -) diff --git a/imagev2directupload_test.go b/imagev2directupload_test.go deleted file mode 100644 index d6f436aaf0e..00000000000 --- a/imagev2directupload_test.go +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestImageV2DirectUploadNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Images.V2.DirectUploads.New(context.TODO(), cloudflare.ImageV2DirectUploadNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Expiry: cloudflare.F(time.Now()), - Metadata: cloudflare.F[any](map[string]interface{}{}), - RequireSignedURLs: cloudflare.F(true), - }) - 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/intel.go b/intel.go deleted file mode 100644 index 3de1f057bf3..00000000000 --- a/intel.go +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// IntelService 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 [NewIntelService] method instead. -type IntelService struct { - Options []option.RequestOption - ASN *IntelASNService - DNS *IntelDNSService - Domains *IntelDomainService - DomainHistory *IntelDomainHistoryService - IPs *IntelIPService - IPLists *IntelIPListService - Miscategorizations *IntelMiscategorizationService - Whois *IntelWhoisService - IndicatorFeeds *IntelIndicatorFeedService - Sinkholes *IntelSinkholeService -} - -// NewIntelService 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 NewIntelService(opts ...option.RequestOption) (r *IntelService) { - r = &IntelService{} - r.Options = opts - r.ASN = NewIntelASNService(opts...) - r.DNS = NewIntelDNSService(opts...) - r.Domains = NewIntelDomainService(opts...) - r.DomainHistory = NewIntelDomainHistoryService(opts...) - r.IPs = NewIntelIPService(opts...) - r.IPLists = NewIntelIPListService(opts...) - r.Miscategorizations = NewIntelMiscategorizationService(opts...) - r.Whois = NewIntelWhoisService(opts...) - r.IndicatorFeeds = NewIntelIndicatorFeedService(opts...) - r.Sinkholes = NewIntelSinkholeService(opts...) - return -} diff --git a/intel/aliases.go b/intel/aliases.go new file mode 100644 index 00000000000..0b28feeab32 --- /dev/null +++ b/intel/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/intel/asn.go b/intel/asn.go new file mode 100644 index 00000000000..a4016dba8da --- /dev/null +++ b/intel/asn.go @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ASNService 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 [NewASNService] method instead. +type ASNService struct { + Options []option.RequestOption + Subnets *ASNSubnetService +} + +// NewASNService 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 NewASNService(opts ...option.RequestOption) (r *ASNService) { + r = &ASNService{} + r.Options = opts + r.Subnets = NewASNSubnetService(opts...) + return +} + +// Get ASN Overview +func (r *ASNService) Get(ctx context.Context, asn IntelASNParam, query ASNGetParams, opts ...option.RequestOption) (res *IntelASN, err error) { + opts = append(r.Options[:], opts...) + var env ASNGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/intel/asn/%v", query.AccountID, asn) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type IntelASN = int64 + +type IntelASNParam = int64 + +type ASNGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ASNGetResponseEnvelope struct { + Errors []ASNGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ASNGetResponseEnvelopeMessages `json:"messages,required"` + Result IntelASN `json:"result,required"` + // Whether the API call was successful + Success ASNGetResponseEnvelopeSuccess `json:"success,required"` + JSON asnGetResponseEnvelopeJSON `json:"-"` +} + +// asnGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [ASNGetResponseEnvelope] +type asnGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ASNGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r asnGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ASNGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON asnGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// asnGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ASNGetResponseEnvelopeErrors] +type asnGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ASNGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r asnGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ASNGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON asnGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// asnGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ASNGetResponseEnvelopeMessages] +type asnGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ASNGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r asnGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ASNGetResponseEnvelopeSuccess bool + +const ( + ASNGetResponseEnvelopeSuccessTrue ASNGetResponseEnvelopeSuccess = true +) diff --git a/intel/asn_test.go b/intel/asn_test.go new file mode 100644 index 00000000000..a622f35a442 --- /dev/null +++ b/intel/asn_test.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/intel" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestASNGet(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("user@example.com"), + ) + _, err := client.Intel.ASN.Get( + context.TODO(), + int64(0), + intel.ASNGetParams{ + AccountID: cloudflare.F("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/intel/asnsubnet.go b/intel/asnsubnet.go new file mode 100644 index 00000000000..de8ebb43066 --- /dev/null +++ b/intel/asnsubnet.go @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ASNSubnetService 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 [NewASNSubnetService] method instead. +type ASNSubnetService struct { + Options []option.RequestOption +} + +// NewASNSubnetService 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 NewASNSubnetService(opts ...option.RequestOption) (r *ASNSubnetService) { + r = &ASNSubnetService{} + r.Options = opts + return +} + +// Get ASN Subnets +func (r *ASNSubnetService) Get(ctx context.Context, asn IntelASNParam, query ASNSubnetGetParams, opts ...option.RequestOption) (res *ASNSubnetGetResponse, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("accounts/%s/intel/asn/%v/subnets", query.AccountID, asn) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +type ASNSubnetGetResponse struct { + ASN IntelASN `json:"asn"` + // Total results returned based on your search parameters. + Count float64 `json:"count"` + IPCountTotal int64 `json:"ip_count_total"` + // Current page within paginated list of results. + Page float64 `json:"page"` + // Number of results per page of results. + PerPage float64 `json:"per_page"` + Subnets []string `json:"subnets"` + JSON asnSubnetGetResponseJSON `json:"-"` +} + +// asnSubnetGetResponseJSON contains the JSON metadata for the struct +// [ASNSubnetGetResponse] +type asnSubnetGetResponseJSON struct { + ASN apijson.Field + Count apijson.Field + IPCountTotal apijson.Field + Page apijson.Field + PerPage apijson.Field + Subnets apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ASNSubnetGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r asnSubnetGetResponseJSON) RawJSON() string { + return r.raw +} + +type ASNSubnetGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} diff --git a/intel/asnsubnet_test.go b/intel/asnsubnet_test.go new file mode 100644 index 00000000000..89a6bd7b079 --- /dev/null +++ b/intel/asnsubnet_test.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/intel" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestASNSubnetGet(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("user@example.com"), + ) + _, err := client.Intel.ASN.Subnets.Get( + context.TODO(), + int64(0), + intel.ASNSubnetGetParams{ + AccountID: cloudflare.F("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/intel/dns.go b/intel/dns.go new file mode 100644 index 00000000000..610d084ac61 --- /dev/null +++ b/intel/dns.go @@ -0,0 +1,222 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DNSService 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 [NewDNSService] method instead. +type DNSService struct { + Options []option.RequestOption +} + +// NewDNSService 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 NewDNSService(opts ...option.RequestOption) (r *DNSService) { + r = &DNSService{} + r.Options = opts + return +} + +// Get Passive DNS by IP +func (r *DNSService) Get(ctx context.Context, params DNSGetParams, opts ...option.RequestOption) (res *IntelPassiveDNSByIP, err error) { + opts = append(r.Options[:], opts...) + var env DNSGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/intel/dns", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type IntelPassiveDNSByIP struct { + // Total results returned based on your search parameters. + Count float64 `json:"count"` + // Current page within paginated list of results. + Page float64 `json:"page"` + // Number of results per page of results. + PerPage float64 `json:"per_page"` + // Reverse DNS look-ups observed during the time period. + ReverseRecords []IntelPassiveDNSByIPReverseRecord `json:"reverse_records"` + JSON intelPassiveDNSByIPJSON `json:"-"` +} + +// intelPassiveDNSByIPJSON contains the JSON metadata for the struct +// [IntelPassiveDNSByIP] +type intelPassiveDNSByIPJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + ReverseRecords apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelPassiveDNSByIP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelPassiveDNSByIPJSON) RawJSON() string { + return r.raw +} + +type IntelPassiveDNSByIPReverseRecord struct { + // First seen date of the DNS record during the time period. + FirstSeen time.Time `json:"first_seen" format:"date"` + // Hostname that the IP was observed resolving to. + Hostname interface{} `json:"hostname"` + // Last seen date of the DNS record during the time period. + LastSeen time.Time `json:"last_seen" format:"date"` + JSON intelPassiveDNSByIPReverseRecordJSON `json:"-"` +} + +// intelPassiveDNSByIPReverseRecordJSON contains the JSON metadata for the struct +// [IntelPassiveDNSByIPReverseRecord] +type intelPassiveDNSByIPReverseRecordJSON struct { + FirstSeen apijson.Field + Hostname apijson.Field + LastSeen apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelPassiveDNSByIPReverseRecord) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelPassiveDNSByIPReverseRecordJSON) RawJSON() string { + return r.raw +} + +type DNSGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + IPV4 param.Field[string] `query:"ipv4"` + // Requested page within paginated list of results. + Page param.Field[float64] `query:"page"` + // Maximum number of results requested. + PerPage param.Field[float64] `query:"per_page"` + StartEndParams param.Field[DNSGetParamsStartEndParams] `query:"start_end_params"` +} + +// URLQuery serializes [DNSGetParams]'s query parameters as `url.Values`. +func (r DNSGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type DNSGetParamsStartEndParams struct { + // Defaults to the current date. + End param.Field[time.Time] `query:"end" format:"date"` + // Defaults to 30 days before the end parameter value. + Start param.Field[time.Time] `query:"start" format:"date"` +} + +// URLQuery serializes [DNSGetParamsStartEndParams]'s query parameters as +// `url.Values`. +func (r DNSGetParamsStartEndParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type DNSGetResponseEnvelope struct { + Errors []DNSGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DNSGetResponseEnvelopeMessages `json:"messages,required"` + Result IntelPassiveDNSByIP `json:"result,required"` + // Whether the API call was successful + Success DNSGetResponseEnvelopeSuccess `json:"success,required"` + JSON dnsGetResponseEnvelopeJSON `json:"-"` +} + +// dnsGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DNSGetResponseEnvelope] +type dnsGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DNSGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dnsGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// dnsGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [DNSGetResponseEnvelopeErrors] +type dnsGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DNSGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dnsGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// dnsGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [DNSGetResponseEnvelopeMessages] +type dnsGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DNSGetResponseEnvelopeSuccess bool + +const ( + DNSGetResponseEnvelopeSuccessTrue DNSGetResponseEnvelopeSuccess = true +) diff --git a/intel/dns_test.go b/intel/dns_test.go new file mode 100644 index 00000000000..3be346388ee --- /dev/null +++ b/intel/dns_test.go @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/intel" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestDNSGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Intel.DNS.Get(context.TODO(), intel.DNSGetParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + IPV4: cloudflare.F("string"), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(20.000000), + StartEndParams: cloudflare.F(intel.DNSGetParamsStartEndParams{ + End: cloudflare.F(time.Now()), + Start: cloudflare.F(time.Now()), + }), + }) + 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/intel/domain.go b/intel/domain.go new file mode 100644 index 00000000000..b19cd74338b --- /dev/null +++ b/intel/domain.go @@ -0,0 +1,317 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DomainService 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 [NewDomainService] method instead. +type DomainService struct { + Options []option.RequestOption + Bulks *DomainBulkService +} + +// NewDomainService 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 NewDomainService(opts ...option.RequestOption) (r *DomainService) { + r = &DomainService{} + r.Options = opts + r.Bulks = NewDomainBulkService(opts...) + return +} + +// Get Domain Details +func (r *DomainService) Get(ctx context.Context, params DomainGetParams, opts ...option.RequestOption) (res *IntelDomain, err error) { + opts = append(r.Options[:], opts...) + var env DomainGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/intel/domain", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type IntelDomain struct { + // Additional information related to the host name. + AdditionalInformation IntelDomainAdditionalInformation `json:"additional_information"` + // Application that the hostname belongs to. + Application IntelDomainApplication `json:"application"` + // Current content categories. + ContentCategories interface{} `json:"content_categories"` + Domain string `json:"domain"` + InheritedContentCategories []IntelDomainInheritedContentCategory `json:"inherited_content_categories"` + // Domain from which `inherited_content_categories` and `inherited_risk_types` are + // inherited, if applicable. + InheritedFrom string `json:"inherited_from"` + InheritedRiskTypes []IntelDomainInheritedRiskType `json:"inherited_risk_types"` + // Global Cloudflare 100k ranking for the last 30 days, if available for the + // hostname. The top ranked domain is 1, the lowest ranked domain is 100,000. + PopularityRank int64 `json:"popularity_rank"` + // Specifies a list of references to one or more IP addresses or domain names that + // the domain name currently resolves to. + ResolvesToRefs []IntelDomainResolvesToRef `json:"resolves_to_refs"` + // Hostname risk score, which is a value between 0 (lowest risk) to 1 (highest + // risk). + RiskScore float64 `json:"risk_score"` + RiskTypes interface{} `json:"risk_types"` + JSON intelDomainJSON `json:"-"` +} + +// intelDomainJSON contains the JSON metadata for the struct [IntelDomain] +type intelDomainJSON struct { + AdditionalInformation apijson.Field + Application apijson.Field + ContentCategories apijson.Field + Domain apijson.Field + InheritedContentCategories apijson.Field + InheritedFrom apijson.Field + InheritedRiskTypes apijson.Field + PopularityRank apijson.Field + ResolvesToRefs apijson.Field + RiskScore apijson.Field + RiskTypes apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelDomain) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelDomainJSON) RawJSON() string { + return r.raw +} + +// Additional information related to the host name. +type IntelDomainAdditionalInformation struct { + // Suspected DGA malware family. + SuspectedMalwareFamily string `json:"suspected_malware_family"` + JSON intelDomainAdditionalInformationJSON `json:"-"` +} + +// intelDomainAdditionalInformationJSON contains the JSON metadata for the struct +// [IntelDomainAdditionalInformation] +type intelDomainAdditionalInformationJSON struct { + SuspectedMalwareFamily apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelDomainAdditionalInformation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelDomainAdditionalInformationJSON) RawJSON() string { + return r.raw +} + +// Application that the hostname belongs to. +type IntelDomainApplication struct { + ID int64 `json:"id"` + Name string `json:"name"` + JSON intelDomainApplicationJSON `json:"-"` +} + +// intelDomainApplicationJSON contains the JSON metadata for the struct +// [IntelDomainApplication] +type intelDomainApplicationJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelDomainApplication) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelDomainApplicationJSON) RawJSON() string { + return r.raw +} + +type IntelDomainInheritedContentCategory struct { + ID int64 `json:"id"` + Name string `json:"name"` + SuperCategoryID int64 `json:"super_category_id"` + JSON intelDomainInheritedContentCategoryJSON `json:"-"` +} + +// intelDomainInheritedContentCategoryJSON contains the JSON metadata for the +// struct [IntelDomainInheritedContentCategory] +type intelDomainInheritedContentCategoryJSON struct { + ID apijson.Field + Name apijson.Field + SuperCategoryID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelDomainInheritedContentCategory) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelDomainInheritedContentCategoryJSON) RawJSON() string { + return r.raw +} + +type IntelDomainInheritedRiskType struct { + ID int64 `json:"id"` + Name string `json:"name"` + SuperCategoryID int64 `json:"super_category_id"` + JSON intelDomainInheritedRiskTypeJSON `json:"-"` +} + +// intelDomainInheritedRiskTypeJSON contains the JSON metadata for the struct +// [IntelDomainInheritedRiskType] +type intelDomainInheritedRiskTypeJSON struct { + ID apijson.Field + Name apijson.Field + SuperCategoryID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelDomainInheritedRiskType) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelDomainInheritedRiskTypeJSON) RawJSON() string { + return r.raw +} + +type IntelDomainResolvesToRef struct { + // STIX 2.1 identifier: + // https://docs.oasis-open.org/cti/stix/v2.1/cs02/stix-v2.1-cs02.html#_64yvzeku5a5c + ID string `json:"id"` + // IP address or domain name. + Value string `json:"value"` + JSON intelDomainResolvesToRefJSON `json:"-"` +} + +// intelDomainResolvesToRefJSON contains the JSON metadata for the struct +// [IntelDomainResolvesToRef] +type intelDomainResolvesToRefJSON struct { + ID apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelDomainResolvesToRef) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelDomainResolvesToRefJSON) RawJSON() string { + return r.raw +} + +type DomainGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Domain param.Field[string] `query:"domain"` +} + +// URLQuery serializes [DomainGetParams]'s query parameters as `url.Values`. +func (r DomainGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type DomainGetResponseEnvelope struct { + Errors []DomainGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DomainGetResponseEnvelopeMessages `json:"messages,required"` + Result IntelDomain `json:"result,required"` + // Whether the API call was successful + Success DomainGetResponseEnvelopeSuccess `json:"success,required"` + JSON domainGetResponseEnvelopeJSON `json:"-"` +} + +// domainGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DomainGetResponseEnvelope] +type domainGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DomainGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON domainGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// domainGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [DomainGetResponseEnvelopeErrors] +type domainGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DomainGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON domainGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// domainGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [DomainGetResponseEnvelopeMessages] +type domainGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DomainGetResponseEnvelopeSuccess bool + +const ( + DomainGetResponseEnvelopeSuccessTrue DomainGetResponseEnvelopeSuccess = true +) diff --git a/intel/domain_test.go b/intel/domain_test.go new file mode 100644 index 00000000000..aa27b2d74b4 --- /dev/null +++ b/intel/domain_test.go @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/intel" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestDomainGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Intel.Domains.Get(context.TODO(), intel.DomainGetParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Domain: cloudflare.F("string"), + }) + 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/intel/domainbulk.go b/intel/domainbulk.go new file mode 100644 index 00000000000..91fd05ebd7d --- /dev/null +++ b/intel/domainbulk.go @@ -0,0 +1,320 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DomainBulkService 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 [NewDomainBulkService] method instead. +type DomainBulkService struct { + Options []option.RequestOption +} + +// NewDomainBulkService 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 NewDomainBulkService(opts ...option.RequestOption) (r *DomainBulkService) { + r = &DomainBulkService{} + r.Options = opts + return +} + +// Get Multiple Domain Details +func (r *DomainBulkService) Get(ctx context.Context, params DomainBulkGetParams, opts ...option.RequestOption) (res *[]DomainBulkGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env DomainBulkGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/intel/domain/bulk", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DomainBulkGetResponse struct { + // Additional information related to the host name. + AdditionalInformation DomainBulkGetResponseAdditionalInformation `json:"additional_information"` + // Application that the hostname belongs to. + Application DomainBulkGetResponseApplication `json:"application"` + // Current content categories. + ContentCategories interface{} `json:"content_categories"` + Domain string `json:"domain"` + InheritedContentCategories []DomainBulkGetResponseInheritedContentCategory `json:"inherited_content_categories"` + // Domain from which `inherited_content_categories` and `inherited_risk_types` are + // inherited, if applicable. + InheritedFrom string `json:"inherited_from"` + InheritedRiskTypes []DomainBulkGetResponseInheritedRiskType `json:"inherited_risk_types"` + // Global Cloudflare 100k ranking for the last 30 days, if available for the + // hostname. The top ranked domain is 1, the lowest ranked domain is 100,000. + PopularityRank int64 `json:"popularity_rank"` + // Hostname risk score, which is a value between 0 (lowest risk) to 1 (highest + // risk). + RiskScore float64 `json:"risk_score"` + RiskTypes interface{} `json:"risk_types"` + JSON domainBulkGetResponseJSON `json:"-"` +} + +// domainBulkGetResponseJSON contains the JSON metadata for the struct +// [DomainBulkGetResponse] +type domainBulkGetResponseJSON struct { + AdditionalInformation apijson.Field + Application apijson.Field + ContentCategories apijson.Field + Domain apijson.Field + InheritedContentCategories apijson.Field + InheritedFrom apijson.Field + InheritedRiskTypes apijson.Field + PopularityRank apijson.Field + RiskScore apijson.Field + RiskTypes apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainBulkGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainBulkGetResponseJSON) RawJSON() string { + return r.raw +} + +// Additional information related to the host name. +type DomainBulkGetResponseAdditionalInformation struct { + // Suspected DGA malware family. + SuspectedMalwareFamily string `json:"suspected_malware_family"` + JSON domainBulkGetResponseAdditionalInformationJSON `json:"-"` +} + +// domainBulkGetResponseAdditionalInformationJSON contains the JSON metadata for +// the struct [DomainBulkGetResponseAdditionalInformation] +type domainBulkGetResponseAdditionalInformationJSON struct { + SuspectedMalwareFamily apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainBulkGetResponseAdditionalInformation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainBulkGetResponseAdditionalInformationJSON) RawJSON() string { + return r.raw +} + +// Application that the hostname belongs to. +type DomainBulkGetResponseApplication struct { + ID int64 `json:"id"` + Name string `json:"name"` + JSON domainBulkGetResponseApplicationJSON `json:"-"` +} + +// domainBulkGetResponseApplicationJSON contains the JSON metadata for the struct +// [DomainBulkGetResponseApplication] +type domainBulkGetResponseApplicationJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainBulkGetResponseApplication) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainBulkGetResponseApplicationJSON) RawJSON() string { + return r.raw +} + +type DomainBulkGetResponseInheritedContentCategory struct { + ID int64 `json:"id"` + Name string `json:"name"` + SuperCategoryID int64 `json:"super_category_id"` + JSON domainBulkGetResponseInheritedContentCategoryJSON `json:"-"` +} + +// domainBulkGetResponseInheritedContentCategoryJSON contains the JSON metadata for +// the struct [DomainBulkGetResponseInheritedContentCategory] +type domainBulkGetResponseInheritedContentCategoryJSON struct { + ID apijson.Field + Name apijson.Field + SuperCategoryID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainBulkGetResponseInheritedContentCategory) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainBulkGetResponseInheritedContentCategoryJSON) RawJSON() string { + return r.raw +} + +type DomainBulkGetResponseInheritedRiskType struct { + ID int64 `json:"id"` + Name string `json:"name"` + SuperCategoryID int64 `json:"super_category_id"` + JSON domainBulkGetResponseInheritedRiskTypeJSON `json:"-"` +} + +// domainBulkGetResponseInheritedRiskTypeJSON contains the JSON metadata for the +// struct [DomainBulkGetResponseInheritedRiskType] +type domainBulkGetResponseInheritedRiskTypeJSON struct { + ID apijson.Field + Name apijson.Field + SuperCategoryID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainBulkGetResponseInheritedRiskType) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainBulkGetResponseInheritedRiskTypeJSON) RawJSON() string { + return r.raw +} + +type DomainBulkGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Accepts multiple values, i.e. `?domain=cloudflare.com&domain=example.com`. + Domain param.Field[interface{}] `query:"domain"` +} + +// URLQuery serializes [DomainBulkGetParams]'s query parameters as `url.Values`. +func (r DomainBulkGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type DomainBulkGetResponseEnvelope struct { + Errors []DomainBulkGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DomainBulkGetResponseEnvelopeMessages `json:"messages,required"` + Result []DomainBulkGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success DomainBulkGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DomainBulkGetResponseEnvelopeResultInfo `json:"result_info"` + JSON domainBulkGetResponseEnvelopeJSON `json:"-"` +} + +// domainBulkGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DomainBulkGetResponseEnvelope] +type domainBulkGetResponseEnvelopeJSON 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 *DomainBulkGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainBulkGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DomainBulkGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON domainBulkGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// domainBulkGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DomainBulkGetResponseEnvelopeErrors] +type domainBulkGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainBulkGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainBulkGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DomainBulkGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON domainBulkGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// domainBulkGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DomainBulkGetResponseEnvelopeMessages] +type domainBulkGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainBulkGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainBulkGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DomainBulkGetResponseEnvelopeSuccess bool + +const ( + DomainBulkGetResponseEnvelopeSuccessTrue DomainBulkGetResponseEnvelopeSuccess = true +) + +type DomainBulkGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON domainBulkGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// domainBulkGetResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [DomainBulkGetResponseEnvelopeResultInfo] +type domainBulkGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainBulkGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainBulkGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/intel/domainbulk_test.go b/intel/domainbulk_test.go new file mode 100644 index 00000000000..693e93ff3dd --- /dev/null +++ b/intel/domainbulk_test.go @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/intel" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestDomainBulkGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Intel.Domains.Bulks.Get(context.TODO(), intel.DomainBulkGetParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Domain: cloudflare.F[any](map[string]interface{}{}), + }) + 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/intel/domainhistory.go b/intel/domainhistory.go new file mode 100644 index 00000000000..28fbf046299 --- /dev/null +++ b/intel/domainhistory.go @@ -0,0 +1,224 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DomainHistoryService 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 [NewDomainHistoryService] method +// instead. +type DomainHistoryService struct { + Options []option.RequestOption +} + +// NewDomainHistoryService 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 NewDomainHistoryService(opts ...option.RequestOption) (r *DomainHistoryService) { + r = &DomainHistoryService{} + r.Options = opts + return +} + +// Get Domain History +func (r *DomainHistoryService) Get(ctx context.Context, params DomainHistoryGetParams, opts ...option.RequestOption) (res *[]IntelDomainHistory, err error) { + opts = append(r.Options[:], opts...) + var env DomainHistoryGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/intel/domain-history", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type IntelDomainHistory struct { + Categorizations []IntelDomainHistoryCategorization `json:"categorizations"` + Domain string `json:"domain"` + JSON intelDomainHistoryJSON `json:"-"` +} + +// intelDomainHistoryJSON contains the JSON metadata for the struct +// [IntelDomainHistory] +type intelDomainHistoryJSON struct { + Categorizations apijson.Field + Domain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelDomainHistory) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelDomainHistoryJSON) RawJSON() string { + return r.raw +} + +type IntelDomainHistoryCategorization struct { + Categories interface{} `json:"categories"` + End time.Time `json:"end" format:"date"` + Start time.Time `json:"start" format:"date"` + JSON intelDomainHistoryCategorizationJSON `json:"-"` +} + +// intelDomainHistoryCategorizationJSON contains the JSON metadata for the struct +// [IntelDomainHistoryCategorization] +type intelDomainHistoryCategorizationJSON struct { + Categories apijson.Field + End apijson.Field + Start apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelDomainHistoryCategorization) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelDomainHistoryCategorizationJSON) RawJSON() string { + return r.raw +} + +type DomainHistoryGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Domain param.Field[interface{}] `query:"domain"` +} + +// URLQuery serializes [DomainHistoryGetParams]'s query parameters as `url.Values`. +func (r DomainHistoryGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type DomainHistoryGetResponseEnvelope struct { + Errors []DomainHistoryGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DomainHistoryGetResponseEnvelopeMessages `json:"messages,required"` + Result []IntelDomainHistory `json:"result,required,nullable"` + // Whether the API call was successful + Success DomainHistoryGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DomainHistoryGetResponseEnvelopeResultInfo `json:"result_info"` + JSON domainHistoryGetResponseEnvelopeJSON `json:"-"` +} + +// domainHistoryGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DomainHistoryGetResponseEnvelope] +type domainHistoryGetResponseEnvelopeJSON 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 *DomainHistoryGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainHistoryGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DomainHistoryGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON domainHistoryGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// domainHistoryGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DomainHistoryGetResponseEnvelopeErrors] +type domainHistoryGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainHistoryGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainHistoryGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DomainHistoryGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON domainHistoryGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// domainHistoryGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DomainHistoryGetResponseEnvelopeMessages] +type domainHistoryGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainHistoryGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainHistoryGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DomainHistoryGetResponseEnvelopeSuccess bool + +const ( + DomainHistoryGetResponseEnvelopeSuccessTrue DomainHistoryGetResponseEnvelopeSuccess = true +) + +type DomainHistoryGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON domainHistoryGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// domainHistoryGetResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [DomainHistoryGetResponseEnvelopeResultInfo] +type domainHistoryGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainHistoryGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainHistoryGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/intel/domainhistory_test.go b/intel/domainhistory_test.go new file mode 100644 index 00000000000..c1bc01caf6e --- /dev/null +++ b/intel/domainhistory_test.go @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/intel" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestDomainHistoryGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Intel.DomainHistory.Get(context.TODO(), intel.DomainHistoryGetParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Domain: cloudflare.F[any]("example.com"), + }) + 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/intel/indicatorfeed.go b/intel/indicatorfeed.go new file mode 100644 index 00000000000..6ded7a5ee83 --- /dev/null +++ b/intel/indicatorfeed.go @@ -0,0 +1,569 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// IndicatorFeedService 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 [NewIndicatorFeedService] method +// instead. +type IndicatorFeedService struct { + Options []option.RequestOption + Permissions *IndicatorFeedPermissionService +} + +// NewIndicatorFeedService 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 NewIndicatorFeedService(opts ...option.RequestOption) (r *IndicatorFeedService) { + r = &IndicatorFeedService{} + r.Options = opts + r.Permissions = NewIndicatorFeedPermissionService(opts...) + return +} + +// Create new indicator feed +func (r *IndicatorFeedService) New(ctx context.Context, params IndicatorFeedNewParams, opts ...option.RequestOption) (res *IntelIndicatorFeedItem, err error) { + opts = append(r.Options[:], opts...) + var env IndicatorFeedNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/intel/indicator-feeds", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update indicator feed data +func (r *IndicatorFeedService) Update(ctx context.Context, feedID int64, params IndicatorFeedUpdateParams, opts ...option.RequestOption) (res *IntelUpdateFeed, err error) { + opts = append(r.Options[:], opts...) + var env IndicatorFeedUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/intel/indicator-feeds/%v/snapshot", params.AccountID, feedID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get indicator feeds owned by this account +func (r *IndicatorFeedService) List(ctx context.Context, query IndicatorFeedListParams, opts ...option.RequestOption) (res *[]IntelIndicatorFeedItem, err error) { + opts = append(r.Options[:], opts...) + var env IndicatorFeedListResponseEnvelope + path := fmt.Sprintf("accounts/%s/intel/indicator-feeds", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get indicator feed data +func (r *IndicatorFeedService) Data(ctx context.Context, feedID int64, query IndicatorFeedDataParams, opts ...option.RequestOption) (res *string, err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "text/csv")}, opts...) + path := fmt.Sprintf("accounts/%s/intel/indicator-feeds/%v/data", query.AccountID, feedID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +// Get indicator feed metadata +func (r *IndicatorFeedService) Get(ctx context.Context, feedID int64, query IndicatorFeedGetParams, opts ...option.RequestOption) (res *IntelIndicatorFeedMetadata, err error) { + opts = append(r.Options[:], opts...) + var env IndicatorFeedGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/intel/indicator-feeds/%v", query.AccountID, feedID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type IntelIndicatorFeedItem struct { + // The unique identifier for the indicator feed + ID int64 `json:"id"` + // The date and time when the data entry was created + CreatedOn time.Time `json:"created_on" format:"date-time"` + // The description of the example test + Description string `json:"description"` + // The date and time when the data entry was last modified + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // The name of the indicator feed + Name string `json:"name"` + JSON intelIndicatorFeedItemJSON `json:"-"` +} + +// intelIndicatorFeedItemJSON contains the JSON metadata for the struct +// [IntelIndicatorFeedItem] +type intelIndicatorFeedItemJSON struct { + ID apijson.Field + CreatedOn apijson.Field + Description apijson.Field + ModifiedOn apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelIndicatorFeedItem) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelIndicatorFeedItemJSON) RawJSON() string { + return r.raw +} + +type IntelIndicatorFeedMetadata struct { + // The unique identifier for the indicator feed + ID int64 `json:"id"` + // The date and time when the data entry was created + CreatedOn time.Time `json:"created_on" format:"date-time"` + // The description of the example test + Description string `json:"description"` + // Status of the latest snapshot uploaded + LatestUploadStatus IntelIndicatorFeedMetadataLatestUploadStatus `json:"latest_upload_status"` + // The date and time when the data entry was last modified + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // The name of the indicator feed + Name string `json:"name"` + JSON intelIndicatorFeedMetadataJSON `json:"-"` +} + +// intelIndicatorFeedMetadataJSON contains the JSON metadata for the struct +// [IntelIndicatorFeedMetadata] +type intelIndicatorFeedMetadataJSON struct { + ID apijson.Field + CreatedOn apijson.Field + Description apijson.Field + LatestUploadStatus apijson.Field + ModifiedOn apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelIndicatorFeedMetadata) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelIndicatorFeedMetadataJSON) RawJSON() string { + return r.raw +} + +// Status of the latest snapshot uploaded +type IntelIndicatorFeedMetadataLatestUploadStatus string + +const ( + IntelIndicatorFeedMetadataLatestUploadStatusMirroring IntelIndicatorFeedMetadataLatestUploadStatus = "Mirroring" + IntelIndicatorFeedMetadataLatestUploadStatusUnifying IntelIndicatorFeedMetadataLatestUploadStatus = "Unifying" + IntelIndicatorFeedMetadataLatestUploadStatusLoading IntelIndicatorFeedMetadataLatestUploadStatus = "Loading" + IntelIndicatorFeedMetadataLatestUploadStatusProvisioning IntelIndicatorFeedMetadataLatestUploadStatus = "Provisioning" + IntelIndicatorFeedMetadataLatestUploadStatusComplete IntelIndicatorFeedMetadataLatestUploadStatus = "Complete" + IntelIndicatorFeedMetadataLatestUploadStatusError IntelIndicatorFeedMetadataLatestUploadStatus = "Error" +) + +type IntelUpdateFeed struct { + // Feed id + FileID int64 `json:"file_id"` + // Name of the file unified in our system + Filename string `json:"filename"` + // Current status of upload, should be unified + Status string `json:"status"` + JSON intelUpdateFeedJSON `json:"-"` +} + +// intelUpdateFeedJSON contains the JSON metadata for the struct [IntelUpdateFeed] +type intelUpdateFeedJSON struct { + FileID apijson.Field + Filename apijson.Field + Status apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelUpdateFeed) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelUpdateFeedJSON) RawJSON() string { + return r.raw +} + +type IndicatorFeedNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The description of the example test + Description param.Field[string] `json:"description"` + // The name of the indicator feed + Name param.Field[string] `json:"name"` +} + +func (r IndicatorFeedNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IndicatorFeedNewResponseEnvelope struct { + Errors []IndicatorFeedNewResponseEnvelopeErrors `json:"errors,required"` + Messages []IndicatorFeedNewResponseEnvelopeMessages `json:"messages,required"` + Result IntelIndicatorFeedItem `json:"result,required"` + // Whether the API call was successful + Success IndicatorFeedNewResponseEnvelopeSuccess `json:"success,required"` + JSON indicatorFeedNewResponseEnvelopeJSON `json:"-"` +} + +// indicatorFeedNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [IndicatorFeedNewResponseEnvelope] +type indicatorFeedNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IndicatorFeedNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indicatorFeedNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// indicatorFeedNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [IndicatorFeedNewResponseEnvelopeErrors] +type indicatorFeedNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IndicatorFeedNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indicatorFeedNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// indicatorFeedNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [IndicatorFeedNewResponseEnvelopeMessages] +type indicatorFeedNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IndicatorFeedNewResponseEnvelopeSuccess bool + +const ( + IndicatorFeedNewResponseEnvelopeSuccessTrue IndicatorFeedNewResponseEnvelopeSuccess = true +) + +type IndicatorFeedUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The file to upload + Source param.Field[string] `json:"source"` +} + +func (r IndicatorFeedUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IndicatorFeedUpdateResponseEnvelope struct { + Errors []IndicatorFeedUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []IndicatorFeedUpdateResponseEnvelopeMessages `json:"messages,required"` + Result IntelUpdateFeed `json:"result,required"` + // Whether the API call was successful + Success IndicatorFeedUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON indicatorFeedUpdateResponseEnvelopeJSON `json:"-"` +} + +// indicatorFeedUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [IndicatorFeedUpdateResponseEnvelope] +type indicatorFeedUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IndicatorFeedUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indicatorFeedUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// indicatorFeedUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [IndicatorFeedUpdateResponseEnvelopeErrors] +type indicatorFeedUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IndicatorFeedUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indicatorFeedUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// indicatorFeedUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [IndicatorFeedUpdateResponseEnvelopeMessages] +type indicatorFeedUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IndicatorFeedUpdateResponseEnvelopeSuccess bool + +const ( + IndicatorFeedUpdateResponseEnvelopeSuccessTrue IndicatorFeedUpdateResponseEnvelopeSuccess = true +) + +type IndicatorFeedListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type IndicatorFeedListResponseEnvelope struct { + Errors []IndicatorFeedListResponseEnvelopeErrors `json:"errors,required"` + Messages []IndicatorFeedListResponseEnvelopeMessages `json:"messages,required"` + Result []IntelIndicatorFeedItem `json:"result,required"` + // Whether the API call was successful + Success IndicatorFeedListResponseEnvelopeSuccess `json:"success,required"` + JSON indicatorFeedListResponseEnvelopeJSON `json:"-"` +} + +// indicatorFeedListResponseEnvelopeJSON contains the JSON metadata for the struct +// [IndicatorFeedListResponseEnvelope] +type indicatorFeedListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IndicatorFeedListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indicatorFeedListResponseEnvelopeErrorsJSON `json:"-"` +} + +// indicatorFeedListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [IndicatorFeedListResponseEnvelopeErrors] +type indicatorFeedListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IndicatorFeedListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indicatorFeedListResponseEnvelopeMessagesJSON `json:"-"` +} + +// indicatorFeedListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [IndicatorFeedListResponseEnvelopeMessages] +type indicatorFeedListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IndicatorFeedListResponseEnvelopeSuccess bool + +const ( + IndicatorFeedListResponseEnvelopeSuccessTrue IndicatorFeedListResponseEnvelopeSuccess = true +) + +type IndicatorFeedDataParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type IndicatorFeedGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type IndicatorFeedGetResponseEnvelope struct { + Errors []IndicatorFeedGetResponseEnvelopeErrors `json:"errors,required"` + Messages []IndicatorFeedGetResponseEnvelopeMessages `json:"messages,required"` + Result IntelIndicatorFeedMetadata `json:"result,required"` + // Whether the API call was successful + Success IndicatorFeedGetResponseEnvelopeSuccess `json:"success,required"` + JSON indicatorFeedGetResponseEnvelopeJSON `json:"-"` +} + +// indicatorFeedGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [IndicatorFeedGetResponseEnvelope] +type indicatorFeedGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IndicatorFeedGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indicatorFeedGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// indicatorFeedGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [IndicatorFeedGetResponseEnvelopeErrors] +type indicatorFeedGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IndicatorFeedGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indicatorFeedGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// indicatorFeedGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [IndicatorFeedGetResponseEnvelopeMessages] +type indicatorFeedGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IndicatorFeedGetResponseEnvelopeSuccess bool + +const ( + IndicatorFeedGetResponseEnvelopeSuccessTrue IndicatorFeedGetResponseEnvelopeSuccess = true +) diff --git a/intel/indicatorfeed_test.go b/intel/indicatorfeed_test.go new file mode 100644 index 00000000000..83fe7e523ad --- /dev/null +++ b/intel/indicatorfeed_test.go @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/intel" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestIndicatorFeedNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Intel.IndicatorFeeds.New(context.TODO(), intel.IndicatorFeedNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Description: cloudflare.F("example feed description"), + Name: cloudflare.F("example_feed_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 TestIndicatorFeedUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Intel.IndicatorFeeds.Update( + context.TODO(), + int64(12), + intel.IndicatorFeedUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Source: cloudflare.F("@/Users/me/test.stix2"), + }, + ) + 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 TestIndicatorFeedList(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("user@example.com"), + ) + _, err := client.Intel.IndicatorFeeds.List(context.TODO(), intel.IndicatorFeedListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestIndicatorFeedData(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("user@example.com"), + ) + _, err := client.Intel.IndicatorFeeds.Data( + context.TODO(), + int64(12), + intel.IndicatorFeedDataParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestIndicatorFeedGet(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("user@example.com"), + ) + _, err := client.Intel.IndicatorFeeds.Get( + context.TODO(), + int64(12), + intel.IndicatorFeedGetParams{ + AccountID: cloudflare.F("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/intel/indicatorfeedpermission.go b/intel/indicatorfeedpermission.go new file mode 100644 index 00000000000..bb3e04be674 --- /dev/null +++ b/intel/indicatorfeedpermission.go @@ -0,0 +1,395 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// IndicatorFeedPermissionService 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 +// [NewIndicatorFeedPermissionService] method instead. +type IndicatorFeedPermissionService struct { + Options []option.RequestOption +} + +// NewIndicatorFeedPermissionService 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 NewIndicatorFeedPermissionService(opts ...option.RequestOption) (r *IndicatorFeedPermissionService) { + r = &IndicatorFeedPermissionService{} + r.Options = opts + return +} + +// Grant permission to indicator feed +func (r *IndicatorFeedPermissionService) New(ctx context.Context, params IndicatorFeedPermissionNewParams, opts ...option.RequestOption) (res *IntelPermissionsUpdate, err error) { + opts = append(r.Options[:], opts...) + var env IndicatorFeedPermissionNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/intel/indicator-feeds/permissions/add", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List indicator feed permissions +func (r *IndicatorFeedPermissionService) List(ctx context.Context, query IndicatorFeedPermissionListParams, opts ...option.RequestOption) (res *[]IntelPermissionListItem, err error) { + opts = append(r.Options[:], opts...) + var env IndicatorFeedPermissionListResponseEnvelope + path := fmt.Sprintf("accounts/%s/intel/indicator-feeds/permissions/view", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Revoke permission to indicator feed +func (r *IndicatorFeedPermissionService) Delete(ctx context.Context, params IndicatorFeedPermissionDeleteParams, opts ...option.RequestOption) (res *IntelPermissionsUpdate, err error) { + opts = append(r.Options[:], opts...) + var env IndicatorFeedPermissionDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/intel/indicator-feeds/permissions/remove", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type IntelPermissionListItem struct { + // The unique identifier for the indicator feed + ID int64 `json:"id"` + // The description of the example test + Description string `json:"description"` + // The name of the indicator feed + Name string `json:"name"` + JSON intelPermissionListItemJSON `json:"-"` +} + +// intelPermissionListItemJSON contains the JSON metadata for the struct +// [IntelPermissionListItem] +type intelPermissionListItemJSON struct { + ID apijson.Field + Description apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelPermissionListItem) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelPermissionListItemJSON) RawJSON() string { + return r.raw +} + +type IntelPermissionsUpdate struct { + // Whether the update succeeded or not + Success bool `json:"success"` + JSON intelPermissionsUpdateJSON `json:"-"` +} + +// intelPermissionsUpdateJSON contains the JSON metadata for the struct +// [IntelPermissionsUpdate] +type intelPermissionsUpdateJSON struct { + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelPermissionsUpdate) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelPermissionsUpdateJSON) RawJSON() string { + return r.raw +} + +type IndicatorFeedPermissionNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The Cloudflare account tag of the account to change permissions on + AccountTag param.Field[string] `json:"account_tag"` + // The ID of the feed to add/remove permissions on + FeedID param.Field[int64] `json:"feed_id"` +} + +func (r IndicatorFeedPermissionNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IndicatorFeedPermissionNewResponseEnvelope struct { + Errors []IndicatorFeedPermissionNewResponseEnvelopeErrors `json:"errors,required"` + Messages []IndicatorFeedPermissionNewResponseEnvelopeMessages `json:"messages,required"` + Result IntelPermissionsUpdate `json:"result,required"` + // Whether the API call was successful + Success IndicatorFeedPermissionNewResponseEnvelopeSuccess `json:"success,required"` + JSON indicatorFeedPermissionNewResponseEnvelopeJSON `json:"-"` +} + +// indicatorFeedPermissionNewResponseEnvelopeJSON contains the JSON metadata for +// the struct [IndicatorFeedPermissionNewResponseEnvelope] +type indicatorFeedPermissionNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedPermissionNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedPermissionNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IndicatorFeedPermissionNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indicatorFeedPermissionNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// indicatorFeedPermissionNewResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [IndicatorFeedPermissionNewResponseEnvelopeErrors] +type indicatorFeedPermissionNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedPermissionNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedPermissionNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IndicatorFeedPermissionNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indicatorFeedPermissionNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// indicatorFeedPermissionNewResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [IndicatorFeedPermissionNewResponseEnvelopeMessages] +type indicatorFeedPermissionNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedPermissionNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedPermissionNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IndicatorFeedPermissionNewResponseEnvelopeSuccess bool + +const ( + IndicatorFeedPermissionNewResponseEnvelopeSuccessTrue IndicatorFeedPermissionNewResponseEnvelopeSuccess = true +) + +type IndicatorFeedPermissionListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type IndicatorFeedPermissionListResponseEnvelope struct { + Errors []IndicatorFeedPermissionListResponseEnvelopeErrors `json:"errors,required"` + Messages []IndicatorFeedPermissionListResponseEnvelopeMessages `json:"messages,required"` + Result []IntelPermissionListItem `json:"result,required"` + // Whether the API call was successful + Success IndicatorFeedPermissionListResponseEnvelopeSuccess `json:"success,required"` + JSON indicatorFeedPermissionListResponseEnvelopeJSON `json:"-"` +} + +// indicatorFeedPermissionListResponseEnvelopeJSON contains the JSON metadata for +// the struct [IndicatorFeedPermissionListResponseEnvelope] +type indicatorFeedPermissionListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedPermissionListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedPermissionListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IndicatorFeedPermissionListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indicatorFeedPermissionListResponseEnvelopeErrorsJSON `json:"-"` +} + +// indicatorFeedPermissionListResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [IndicatorFeedPermissionListResponseEnvelopeErrors] +type indicatorFeedPermissionListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedPermissionListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedPermissionListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IndicatorFeedPermissionListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indicatorFeedPermissionListResponseEnvelopeMessagesJSON `json:"-"` +} + +// indicatorFeedPermissionListResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [IndicatorFeedPermissionListResponseEnvelopeMessages] +type indicatorFeedPermissionListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedPermissionListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedPermissionListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IndicatorFeedPermissionListResponseEnvelopeSuccess bool + +const ( + IndicatorFeedPermissionListResponseEnvelopeSuccessTrue IndicatorFeedPermissionListResponseEnvelopeSuccess = true +) + +type IndicatorFeedPermissionDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The Cloudflare account tag of the account to change permissions on + AccountTag param.Field[string] `json:"account_tag"` + // The ID of the feed to add/remove permissions on + FeedID param.Field[int64] `json:"feed_id"` +} + +func (r IndicatorFeedPermissionDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IndicatorFeedPermissionDeleteResponseEnvelope struct { + Errors []IndicatorFeedPermissionDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []IndicatorFeedPermissionDeleteResponseEnvelopeMessages `json:"messages,required"` + Result IntelPermissionsUpdate `json:"result,required"` + // Whether the API call was successful + Success IndicatorFeedPermissionDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON indicatorFeedPermissionDeleteResponseEnvelopeJSON `json:"-"` +} + +// indicatorFeedPermissionDeleteResponseEnvelopeJSON contains the JSON metadata for +// the struct [IndicatorFeedPermissionDeleteResponseEnvelope] +type indicatorFeedPermissionDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedPermissionDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedPermissionDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IndicatorFeedPermissionDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indicatorFeedPermissionDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// indicatorFeedPermissionDeleteResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [IndicatorFeedPermissionDeleteResponseEnvelopeErrors] +type indicatorFeedPermissionDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedPermissionDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedPermissionDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IndicatorFeedPermissionDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indicatorFeedPermissionDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// indicatorFeedPermissionDeleteResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [IndicatorFeedPermissionDeleteResponseEnvelopeMessages] +type indicatorFeedPermissionDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndicatorFeedPermissionDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indicatorFeedPermissionDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IndicatorFeedPermissionDeleteResponseEnvelopeSuccess bool + +const ( + IndicatorFeedPermissionDeleteResponseEnvelopeSuccessTrue IndicatorFeedPermissionDeleteResponseEnvelopeSuccess = true +) diff --git a/intel/indicatorfeedpermission_test.go b/intel/indicatorfeedpermission_test.go new file mode 100644 index 00000000000..8df7a146b1c --- /dev/null +++ b/intel/indicatorfeedpermission_test.go @@ -0,0 +1,97 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/intel" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestIndicatorFeedPermissionNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Intel.IndicatorFeeds.Permissions.New(context.TODO(), intel.IndicatorFeedPermissionNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + AccountTag: cloudflare.F("823f45f16fd2f7e21e1e054aga4d2859"), + FeedID: cloudflare.F(int64(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 TestIndicatorFeedPermissionList(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("user@example.com"), + ) + _, err := client.Intel.IndicatorFeeds.Permissions.List(context.TODO(), intel.IndicatorFeedPermissionListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestIndicatorFeedPermissionDeleteWithOptionalParams(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("user@example.com"), + ) + _, err := client.Intel.IndicatorFeeds.Permissions.Delete(context.TODO(), intel.IndicatorFeedPermissionDeleteParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + AccountTag: cloudflare.F("823f45f16fd2f7e21e1e054aga4d2859"), + FeedID: cloudflare.F(int64(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()) + } +} diff --git a/intel/intel.go b/intel/intel.go new file mode 100644 index 00000000000..ca970a3ebff --- /dev/null +++ b/intel/intel.go @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// IntelService 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 [NewIntelService] method instead. +type IntelService struct { + Options []option.RequestOption + ASN *ASNService + DNS *DNSService + Domains *DomainService + DomainHistory *DomainHistoryService + IPs *IPService + IPLists *IPListService + Miscategorizations *MiscategorizationService + Whois *WhoisService + IndicatorFeeds *IndicatorFeedService + Sinkholes *SinkholeService +} + +// NewIntelService 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 NewIntelService(opts ...option.RequestOption) (r *IntelService) { + r = &IntelService{} + r.Options = opts + r.ASN = NewASNService(opts...) + r.DNS = NewDNSService(opts...) + r.Domains = NewDomainService(opts...) + r.DomainHistory = NewDomainHistoryService(opts...) + r.IPs = NewIPService(opts...) + r.IPLists = NewIPListService(opts...) + r.Miscategorizations = NewMiscategorizationService(opts...) + r.Whois = NewWhoisService(opts...) + r.IndicatorFeeds = NewIndicatorFeedService(opts...) + r.Sinkholes = NewSinkholeService(opts...) + return +} diff --git a/intel/ip.go b/intel/ip.go new file mode 100644 index 00000000000..255c0b75dfb --- /dev/null +++ b/intel/ip.go @@ -0,0 +1,265 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// IPService 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 [NewIPService] method instead. +type IPService struct { + Options []option.RequestOption +} + +// NewIPService 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 NewIPService(opts ...option.RequestOption) (r *IPService) { + r = &IPService{} + r.Options = opts + return +} + +// Get IP Overview +func (r *IPService) Get(ctx context.Context, params IPGetParams, opts ...option.RequestOption) (res *[]IntelSchemasIP, err error) { + opts = append(r.Options[:], opts...) + var env IPGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/intel/ip", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type IntelSchemasIP struct { + // Specifies a reference to the autonomous systems (AS) that the IP address belongs + // to. + BelongsToRef IntelSchemasIPBelongsToRef `json:"belongs_to_ref"` + IP IntelSchemasIPIP `json:"ip" format:"ipv4"` + RiskTypes interface{} `json:"risk_types"` + JSON intelSchemasIPJSON `json:"-"` +} + +// intelSchemasIPJSON contains the JSON metadata for the struct [IntelSchemasIP] +type intelSchemasIPJSON struct { + BelongsToRef apijson.Field + IP apijson.Field + RiskTypes apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelSchemasIP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelSchemasIPJSON) RawJSON() string { + return r.raw +} + +// Specifies a reference to the autonomous systems (AS) that the IP address belongs +// to. +type IntelSchemasIPBelongsToRef struct { + ID interface{} `json:"id"` + Country string `json:"country"` + Description string `json:"description"` + // Infrastructure type of this ASN. + Type IntelSchemasIPBelongsToRefType `json:"type"` + Value string `json:"value"` + JSON intelSchemasIPBelongsToRefJSON `json:"-"` +} + +// intelSchemasIPBelongsToRefJSON contains the JSON metadata for the struct +// [IntelSchemasIPBelongsToRef] +type intelSchemasIPBelongsToRefJSON struct { + ID apijson.Field + Country apijson.Field + Description apijson.Field + Type apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelSchemasIPBelongsToRef) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelSchemasIPBelongsToRefJSON) RawJSON() string { + return r.raw +} + +// Infrastructure type of this ASN. +type IntelSchemasIPBelongsToRefType string + +const ( + IntelSchemasIPBelongsToRefTypeHostingProvider IntelSchemasIPBelongsToRefType = "hosting_provider" + IntelSchemasIPBelongsToRefTypeIsp IntelSchemasIPBelongsToRefType = "isp" + IntelSchemasIPBelongsToRefTypeOrganization IntelSchemasIPBelongsToRefType = "organization" +) + +// Union satisfied by [shared.UnionString] or [shared.UnionString]. +type IntelSchemasIPIP interface { + ImplementsIntelIntelSchemasIpip() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*IntelSchemasIPIP)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type IPGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + IPV4 param.Field[string] `query:"ipv4"` + IPV6 param.Field[string] `query:"ipv6"` +} + +// URLQuery serializes [IPGetParams]'s query parameters as `url.Values`. +func (r IPGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type IPGetResponseEnvelope struct { + Errors []IPGetResponseEnvelopeErrors `json:"errors,required"` + Messages []IPGetResponseEnvelopeMessages `json:"messages,required"` + Result []IntelSchemasIP `json:"result,required,nullable"` + // Whether the API call was successful + Success IPGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo IPGetResponseEnvelopeResultInfo `json:"result_info"` + JSON ipGetResponseEnvelopeJSON `json:"-"` +} + +// ipGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [IPGetResponseEnvelope] +type ipGetResponseEnvelopeJSON 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 *IPGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IPGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ipGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// ipGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [IPGetResponseEnvelopeErrors] +type ipGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IPGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ipGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// ipGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [IPGetResponseEnvelopeMessages] +type ipGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IPGetResponseEnvelopeSuccess bool + +const ( + IPGetResponseEnvelopeSuccessTrue IPGetResponseEnvelopeSuccess = true +) + +type IPGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON ipGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// ipGetResponseEnvelopeResultInfoJSON contains the JSON metadata for the struct +// [IPGetResponseEnvelopeResultInfo] +type ipGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/intel/ip_test.go b/intel/ip_test.go new file mode 100644 index 00000000000..681857a0ea2 --- /dev/null +++ b/intel/ip_test.go @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/intel" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestIPGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Intel.IPs.Get(context.TODO(), intel.IPGetParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + IPV4: cloudflare.F("string"), + IPV6: cloudflare.F("string"), + }) + 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/intel/iplist.go b/intel/iplist.go new file mode 100644 index 00000000000..cb669ac9090 --- /dev/null +++ b/intel/iplist.go @@ -0,0 +1,187 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// IPListService 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 [NewIPListService] method instead. +type IPListService struct { + Options []option.RequestOption +} + +// NewIPListService 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 NewIPListService(opts ...option.RequestOption) (r *IPListService) { + r = &IPListService{} + r.Options = opts + return +} + +// Get IP Lists +func (r *IPListService) Get(ctx context.Context, query IPListGetParams, opts ...option.RequestOption) (res *[]IntelIPList, err error) { + opts = append(r.Options[:], opts...) + var env IPListGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/intel/ip-list", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type IntelIPList struct { + ID int64 `json:"id"` + Description string `json:"description"` + Name string `json:"name"` + JSON intelIPListJSON `json:"-"` +} + +// intelIPListJSON contains the JSON metadata for the struct [IntelIPList] +type intelIPListJSON struct { + ID apijson.Field + Description apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelIPList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelIPListJSON) RawJSON() string { + return r.raw +} + +type IPListGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type IPListGetResponseEnvelope struct { + Errors []IPListGetResponseEnvelopeErrors `json:"errors,required"` + Messages []IPListGetResponseEnvelopeMessages `json:"messages,required"` + Result []IntelIPList `json:"result,required,nullable"` + // Whether the API call was successful + Success IPListGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo IPListGetResponseEnvelopeResultInfo `json:"result_info"` + JSON ipListGetResponseEnvelopeJSON `json:"-"` +} + +// ipListGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [IPListGetResponseEnvelope] +type ipListGetResponseEnvelopeJSON 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 *IPListGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipListGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IPListGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ipListGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// ipListGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [IPListGetResponseEnvelopeErrors] +type ipListGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPListGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipListGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IPListGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ipListGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// ipListGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [IPListGetResponseEnvelopeMessages] +type ipListGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPListGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipListGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IPListGetResponseEnvelopeSuccess bool + +const ( + IPListGetResponseEnvelopeSuccessTrue IPListGetResponseEnvelopeSuccess = true +) + +type IPListGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON ipListGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// ipListGetResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [IPListGetResponseEnvelopeResultInfo] +type ipListGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPListGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipListGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/intel/iplist_test.go b/intel/iplist_test.go new file mode 100644 index 00000000000..90bdc8e1476 --- /dev/null +++ b/intel/iplist_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/intel" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestIPListGet(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("user@example.com"), + ) + _, err := client.Intel.IPLists.Get(context.TODO(), intel.IPListGetParams{ + AccountID: cloudflare.F("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/intel/miscategorization.go b/intel/miscategorization.go new file mode 100644 index 00000000000..0666eeef030 --- /dev/null +++ b/intel/miscategorization.go @@ -0,0 +1,179 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// MiscategorizationService 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 [NewMiscategorizationService] method +// instead. +type MiscategorizationService struct { + Options []option.RequestOption +} + +// NewMiscategorizationService 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 NewMiscategorizationService(opts ...option.RequestOption) (r *MiscategorizationService) { + r = &MiscategorizationService{} + r.Options = opts + return +} + +// Create Miscategorization +func (r *MiscategorizationService) New(ctx context.Context, params MiscategorizationNewParams, opts ...option.RequestOption) (res *MiscategorizationNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env MiscategorizationNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/intel/miscategorization", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [intel.MiscategorizationNewResponseUnknown] or +// [shared.UnionString]. +type MiscategorizationNewResponse interface { + ImplementsIntelMiscategorizationNewResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*MiscategorizationNewResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type MiscategorizationNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Content category IDs to add. + ContentAdds param.Field[interface{}] `json:"content_adds"` + // Content category IDs to remove. + ContentRemoves param.Field[interface{}] `json:"content_removes"` + IndicatorType param.Field[MiscategorizationNewParamsIndicatorType] `json:"indicator_type"` + // Provide only if indicator_type is `ipv4` or `ipv6`. + IP param.Field[interface{}] `json:"ip"` + // Security category IDs to add. + SecurityAdds param.Field[interface{}] `json:"security_adds"` + // Security category IDs to remove. + SecurityRemoves param.Field[interface{}] `json:"security_removes"` + // Provide only if indicator_type is `domain` or `url`. Example if indicator_type + // is `domain`: `example.com`. Example if indicator_type is `url`: + // `https://example.com/news/`. + URL param.Field[string] `json:"url"` +} + +func (r MiscategorizationNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type MiscategorizationNewParamsIndicatorType string + +const ( + MiscategorizationNewParamsIndicatorTypeDomain MiscategorizationNewParamsIndicatorType = "domain" + MiscategorizationNewParamsIndicatorTypeIPV4 MiscategorizationNewParamsIndicatorType = "ipv4" + MiscategorizationNewParamsIndicatorTypeIPV6 MiscategorizationNewParamsIndicatorType = "ipv6" + MiscategorizationNewParamsIndicatorTypeURL MiscategorizationNewParamsIndicatorType = "url" +) + +type MiscategorizationNewResponseEnvelope struct { + Errors []MiscategorizationNewResponseEnvelopeErrors `json:"errors,required"` + Messages []MiscategorizationNewResponseEnvelopeMessages `json:"messages,required"` + Result MiscategorizationNewResponse `json:"result,required"` + // Whether the API call was successful + Success MiscategorizationNewResponseEnvelopeSuccess `json:"success,required"` + JSON miscategorizationNewResponseEnvelopeJSON `json:"-"` +} + +// miscategorizationNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [MiscategorizationNewResponseEnvelope] +type miscategorizationNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MiscategorizationNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r miscategorizationNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type MiscategorizationNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON miscategorizationNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// miscategorizationNewResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [MiscategorizationNewResponseEnvelopeErrors] +type miscategorizationNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MiscategorizationNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r miscategorizationNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type MiscategorizationNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON miscategorizationNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// miscategorizationNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [MiscategorizationNewResponseEnvelopeMessages] +type miscategorizationNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MiscategorizationNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r miscategorizationNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type MiscategorizationNewResponseEnvelopeSuccess bool + +const ( + MiscategorizationNewResponseEnvelopeSuccessTrue MiscategorizationNewResponseEnvelopeSuccess = true +) diff --git a/intel/miscategorization_test.go b/intel/miscategorization_test.go new file mode 100644 index 00000000000..72c9669e103 --- /dev/null +++ b/intel/miscategorization_test.go @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/intel" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestMiscategorizationNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Intel.Miscategorizations.New(context.TODO(), intel.MiscategorizationNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + ContentAdds: cloudflare.F[any](map[string]interface{}{ + "0": int64(82), + }), + ContentRemoves: cloudflare.F[any](map[string]interface{}{ + "0": int64(155), + }), + IndicatorType: cloudflare.F(intel.MiscategorizationNewParamsIndicatorTypeDomain), + IP: cloudflare.F[any](map[string]interface{}{}), + SecurityAdds: cloudflare.F[any](map[string]interface{}{ + "0": int64(117), + "1": int64(131), + }), + SecurityRemoves: cloudflare.F[any](map[string]interface{}{ + "0": int64(83), + }), + URL: cloudflare.F("string"), + }) + 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/intel/sinkhole.go b/intel/sinkhole.go new file mode 100644 index 00000000000..66e53cb9c4a --- /dev/null +++ b/intel/sinkhole.go @@ -0,0 +1,171 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SinkholeService 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 [NewSinkholeService] method instead. +type SinkholeService struct { + Options []option.RequestOption +} + +// NewSinkholeService 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 NewSinkholeService(opts ...option.RequestOption) (r *SinkholeService) { + r = &SinkholeService{} + r.Options = opts + return +} + +// List sinkholes owned by this account +func (r *SinkholeService) List(ctx context.Context, query SinkholeListParams, opts ...option.RequestOption) (res *[]IntelSinkholesSinkholeItem, err error) { + opts = append(r.Options[:], opts...) + var env SinkholeListResponseEnvelope + path := fmt.Sprintf("accounts/%s/intel/sinkholes", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type IntelSinkholesSinkholeItem struct { + // The unique identifier for the sinkhole + ID int64 `json:"id"` + // The account tag that owns this sinkhole + AccountTag string `json:"account_tag"` + // The date and time when the sinkhole was created + CreatedOn time.Time `json:"created_on" format:"date-time"` + // The date and time when the sinkhole was last modified + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // The name of the sinkhole + Name string `json:"name"` + // The name of the R2 bucket to store results + R2Bucket string `json:"r2_bucket"` + // The id of the R2 instance + R2ID string `json:"r2_id"` + JSON intelSinkholesSinkholeItemJSON `json:"-"` +} + +// intelSinkholesSinkholeItemJSON contains the JSON metadata for the struct +// [IntelSinkholesSinkholeItem] +type intelSinkholesSinkholeItemJSON struct { + ID apijson.Field + AccountTag apijson.Field + CreatedOn apijson.Field + ModifiedOn apijson.Field + Name apijson.Field + R2Bucket apijson.Field + R2ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelSinkholesSinkholeItem) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelSinkholesSinkholeItemJSON) RawJSON() string { + return r.raw +} + +type SinkholeListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type SinkholeListResponseEnvelope struct { + Errors []SinkholeListResponseEnvelopeErrors `json:"errors,required"` + Messages []SinkholeListResponseEnvelopeMessages `json:"messages,required"` + Result []IntelSinkholesSinkholeItem `json:"result,required"` + // Whether the API call was successful + Success SinkholeListResponseEnvelopeSuccess `json:"success,required"` + JSON sinkholeListResponseEnvelopeJSON `json:"-"` +} + +// sinkholeListResponseEnvelopeJSON contains the JSON metadata for the struct +// [SinkholeListResponseEnvelope] +type sinkholeListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SinkholeListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r sinkholeListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SinkholeListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON sinkholeListResponseEnvelopeErrorsJSON `json:"-"` +} + +// sinkholeListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [SinkholeListResponseEnvelopeErrors] +type sinkholeListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SinkholeListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r sinkholeListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SinkholeListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON sinkholeListResponseEnvelopeMessagesJSON `json:"-"` +} + +// sinkholeListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SinkholeListResponseEnvelopeMessages] +type sinkholeListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SinkholeListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r sinkholeListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SinkholeListResponseEnvelopeSuccess bool + +const ( + SinkholeListResponseEnvelopeSuccessTrue SinkholeListResponseEnvelopeSuccess = true +) diff --git a/intel/sinkhole_test.go b/intel/sinkhole_test.go new file mode 100644 index 00000000000..7d4ae56cbec --- /dev/null +++ b/intel/sinkhole_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/intel" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestSinkholeList(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("user@example.com"), + ) + _, err := client.Intel.Sinkholes.List(context.TODO(), intel.SinkholeListParams{ + AccountID: cloudflare.F("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/intel/whois.go b/intel/whois.go new file mode 100644 index 00000000000..c7f9b5b0e62 --- /dev/null +++ b/intel/whois.go @@ -0,0 +1,178 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// WhoisService 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 [NewWhoisService] method instead. +type WhoisService struct { + Options []option.RequestOption +} + +// NewWhoisService 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 NewWhoisService(opts ...option.RequestOption) (r *WhoisService) { + r = &WhoisService{} + r.Options = opts + return +} + +// Get WHOIS Record +func (r *WhoisService) Get(ctx context.Context, params WhoisGetParams, opts ...option.RequestOption) (res *IntelWhois, err error) { + opts = append(r.Options[:], opts...) + var env WhoisGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/intel/whois", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type IntelWhois struct { + CreatedDate time.Time `json:"created_date" format:"date"` + Domain string `json:"domain"` + Nameservers []string `json:"nameservers"` + Registrant string `json:"registrant"` + RegistrantCountry string `json:"registrant_country"` + RegistrantEmail string `json:"registrant_email"` + RegistrantOrg string `json:"registrant_org"` + Registrar string `json:"registrar"` + UpdatedDate time.Time `json:"updated_date" format:"date"` + JSON intelWhoisJSON `json:"-"` +} + +// intelWhoisJSON contains the JSON metadata for the struct [IntelWhois] +type intelWhoisJSON struct { + CreatedDate apijson.Field + Domain apijson.Field + Nameservers apijson.Field + Registrant apijson.Field + RegistrantCountry apijson.Field + RegistrantEmail apijson.Field + RegistrantOrg apijson.Field + Registrar apijson.Field + UpdatedDate apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IntelWhois) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r intelWhoisJSON) RawJSON() string { + return r.raw +} + +type WhoisGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Domain param.Field[string] `query:"domain"` +} + +// URLQuery serializes [WhoisGetParams]'s query parameters as `url.Values`. +func (r WhoisGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type WhoisGetResponseEnvelope struct { + Errors []WhoisGetResponseEnvelopeErrors `json:"errors,required"` + Messages []WhoisGetResponseEnvelopeMessages `json:"messages,required"` + Result IntelWhois `json:"result,required"` + // Whether the API call was successful + Success WhoisGetResponseEnvelopeSuccess `json:"success,required"` + JSON whoisGetResponseEnvelopeJSON `json:"-"` +} + +// whoisGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [WhoisGetResponseEnvelope] +type whoisGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WhoisGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r whoisGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WhoisGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON whoisGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// whoisGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [WhoisGetResponseEnvelopeErrors] +type whoisGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WhoisGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r whoisGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WhoisGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON whoisGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// whoisGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [WhoisGetResponseEnvelopeMessages] +type whoisGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WhoisGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r whoisGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type WhoisGetResponseEnvelopeSuccess bool + +const ( + WhoisGetResponseEnvelopeSuccessTrue WhoisGetResponseEnvelopeSuccess = true +) diff --git a/intel/whois_test.go b/intel/whois_test.go new file mode 100644 index 00000000000..f5fb90f6d5d --- /dev/null +++ b/intel/whois_test.go @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package intel_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/intel" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestWhoisGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Intel.Whois.Get(context.TODO(), intel.WhoisGetParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Domain: cloudflare.F("string"), + }) + 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/intelasn.go b/intelasn.go deleted file mode 100644 index 49c661aca10..00000000000 --- a/intelasn.go +++ /dev/null @@ -1,132 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// IntelASNService 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 [NewIntelASNService] method instead. -type IntelASNService struct { - Options []option.RequestOption - Subnets *IntelASNSubnetService -} - -// NewIntelASNService 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 NewIntelASNService(opts ...option.RequestOption) (r *IntelASNService) { - r = &IntelASNService{} - r.Options = opts - r.Subnets = NewIntelASNSubnetService(opts...) - return -} - -// Get ASN Overview -func (r *IntelASNService) Get(ctx context.Context, asn int64, query IntelASNGetParams, opts ...option.RequestOption) (res *int64, err error) { - opts = append(r.Options[:], opts...) - var env IntelASNGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/intel/asn/%v", query.AccountID, asn) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type IntelASNGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type IntelASNGetResponseEnvelope struct { - Errors []IntelASNGetResponseEnvelopeErrors `json:"errors,required"` - Messages []IntelASNGetResponseEnvelopeMessages `json:"messages,required"` - Result int64 `json:"result,required"` - // Whether the API call was successful - Success IntelASNGetResponseEnvelopeSuccess `json:"success,required"` - JSON intelASNGetResponseEnvelopeJSON `json:"-"` -} - -// intelASNGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [IntelASNGetResponseEnvelope] -type intelASNGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelASNGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelASNGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IntelASNGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelASNGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// intelASNGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [IntelASNGetResponseEnvelopeErrors] -type intelASNGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelASNGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelASNGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IntelASNGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelASNGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// intelASNGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IntelASNGetResponseEnvelopeMessages] -type intelASNGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelASNGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelASNGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type IntelASNGetResponseEnvelopeSuccess bool - -const ( - IntelASNGetResponseEnvelopeSuccessTrue IntelASNGetResponseEnvelopeSuccess = true -) diff --git a/intelasn_test.go b/intelasn_test.go deleted file mode 100644 index 93503791e46..00000000000 --- a/intelasn_test.go +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestIntelASNGet(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("user@example.com"), - ) - _, err := client.Intel.ASN.Get( - context.TODO(), - int64(0), - cloudflare.IntelASNGetParams{ - AccountID: cloudflare.F("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/intelasnsubnet.go b/intelasnsubnet.go deleted file mode 100644 index e30f373d4a6..00000000000 --- a/intelasnsubnet.go +++ /dev/null @@ -1,79 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// IntelASNSubnetService 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 [NewIntelASNSubnetService] method -// instead. -type IntelASNSubnetService struct { - Options []option.RequestOption -} - -// NewIntelASNSubnetService 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 NewIntelASNSubnetService(opts ...option.RequestOption) (r *IntelASNSubnetService) { - r = &IntelASNSubnetService{} - r.Options = opts - return -} - -// Get ASN Subnets -func (r *IntelASNSubnetService) Get(ctx context.Context, asn int64, query IntelASNSubnetGetParams, opts ...option.RequestOption) (res *IntelASNSubnetGetResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("accounts/%s/intel/asn/%v/subnets", query.AccountID, asn) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -type IntelASNSubnetGetResponse struct { - ASN int64 `json:"asn"` - // Total results returned based on your search parameters. - Count float64 `json:"count"` - IPCountTotal int64 `json:"ip_count_total"` - // Current page within paginated list of results. - Page float64 `json:"page"` - // Number of results per page of results. - PerPage float64 `json:"per_page"` - Subnets []string `json:"subnets"` - JSON intelASNSubnetGetResponseJSON `json:"-"` -} - -// intelASNSubnetGetResponseJSON contains the JSON metadata for the struct -// [IntelASNSubnetGetResponse] -type intelASNSubnetGetResponseJSON struct { - ASN apijson.Field - Count apijson.Field - IPCountTotal apijson.Field - Page apijson.Field - PerPage apijson.Field - Subnets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelASNSubnetGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelASNSubnetGetResponseJSON) RawJSON() string { - return r.raw -} - -type IntelASNSubnetGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} diff --git a/intelasnsubnet_test.go b/intelasnsubnet_test.go deleted file mode 100644 index bc88ead9c4f..00000000000 --- a/intelasnsubnet_test.go +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestIntelASNSubnetGet(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("user@example.com"), - ) - _, err := client.Intel.ASN.Subnets.Get( - context.TODO(), - int64(0), - cloudflare.IntelASNSubnetGetParams{ - AccountID: cloudflare.F("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/inteldns.go b/inteldns.go deleted file mode 100644 index 42fb6f5f49e..00000000000 --- a/inteldns.go +++ /dev/null @@ -1,222 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// IntelDNSService 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 [NewIntelDNSService] method instead. -type IntelDNSService struct { - Options []option.RequestOption -} - -// NewIntelDNSService 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 NewIntelDNSService(opts ...option.RequestOption) (r *IntelDNSService) { - r = &IntelDNSService{} - r.Options = opts - return -} - -// Get Passive DNS by IP -func (r *IntelDNSService) Get(ctx context.Context, params IntelDNSGetParams, opts ...option.RequestOption) (res *IntelDNSGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env IntelDNSGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/intel/dns", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type IntelDNSGetResponse struct { - // Total results returned based on your search parameters. - Count float64 `json:"count"` - // Current page within paginated list of results. - Page float64 `json:"page"` - // Number of results per page of results. - PerPage float64 `json:"per_page"` - // Reverse DNS look-ups observed during the time period. - ReverseRecords []IntelDNSGetResponseReverseRecord `json:"reverse_records"` - JSON intelDNSGetResponseJSON `json:"-"` -} - -// intelDNSGetResponseJSON contains the JSON metadata for the struct -// [IntelDNSGetResponse] -type intelDNSGetResponseJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - ReverseRecords apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDNSGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDNSGetResponseJSON) RawJSON() string { - return r.raw -} - -type IntelDNSGetResponseReverseRecord struct { - // First seen date of the DNS record during the time period. - FirstSeen time.Time `json:"first_seen" format:"date"` - // Hostname that the IP was observed resolving to. - Hostname interface{} `json:"hostname"` - // Last seen date of the DNS record during the time period. - LastSeen time.Time `json:"last_seen" format:"date"` - JSON intelDNSGetResponseReverseRecordJSON `json:"-"` -} - -// intelDNSGetResponseReverseRecordJSON contains the JSON metadata for the struct -// [IntelDNSGetResponseReverseRecord] -type intelDNSGetResponseReverseRecordJSON struct { - FirstSeen apijson.Field - Hostname apijson.Field - LastSeen apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDNSGetResponseReverseRecord) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDNSGetResponseReverseRecordJSON) RawJSON() string { - return r.raw -} - -type IntelDNSGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - IPV4 param.Field[string] `query:"ipv4"` - // Requested page within paginated list of results. - Page param.Field[float64] `query:"page"` - // Maximum number of results requested. - PerPage param.Field[float64] `query:"per_page"` - StartEndParams param.Field[IntelDNSGetParamsStartEndParams] `query:"start_end_params"` -} - -// URLQuery serializes [IntelDNSGetParams]'s query parameters as `url.Values`. -func (r IntelDNSGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type IntelDNSGetParamsStartEndParams struct { - // Defaults to the current date. - End param.Field[time.Time] `query:"end" format:"date"` - // Defaults to 30 days before the end parameter value. - Start param.Field[time.Time] `query:"start" format:"date"` -} - -// URLQuery serializes [IntelDNSGetParamsStartEndParams]'s query parameters as -// `url.Values`. -func (r IntelDNSGetParamsStartEndParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type IntelDNSGetResponseEnvelope struct { - Errors []IntelDNSGetResponseEnvelopeErrors `json:"errors,required"` - Messages []IntelDNSGetResponseEnvelopeMessages `json:"messages,required"` - Result IntelDNSGetResponse `json:"result,required"` - // Whether the API call was successful - Success IntelDNSGetResponseEnvelopeSuccess `json:"success,required"` - JSON intelDNSGetResponseEnvelopeJSON `json:"-"` -} - -// intelDNSGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [IntelDNSGetResponseEnvelope] -type intelDNSGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDNSGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDNSGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IntelDNSGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelDNSGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// intelDNSGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [IntelDNSGetResponseEnvelopeErrors] -type intelDNSGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDNSGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDNSGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IntelDNSGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelDNSGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// intelDNSGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IntelDNSGetResponseEnvelopeMessages] -type intelDNSGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDNSGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDNSGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type IntelDNSGetResponseEnvelopeSuccess bool - -const ( - IntelDNSGetResponseEnvelopeSuccessTrue IntelDNSGetResponseEnvelopeSuccess = true -) diff --git a/inteldns_test.go b/inteldns_test.go deleted file mode 100644 index 761b686343e..00000000000 --- a/inteldns_test.go +++ /dev/null @@ -1,48 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestIntelDNSGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Intel.DNS.Get(context.TODO(), cloudflare.IntelDNSGetParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - IPV4: cloudflare.F("string"), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(20.000000), - StartEndParams: cloudflare.F(cloudflare.IntelDNSGetParamsStartEndParams{ - End: cloudflare.F(time.Now()), - Start: cloudflare.F(time.Now()), - }), - }) - 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/inteldomain.go b/inteldomain.go deleted file mode 100644 index 86d86cba76c..00000000000 --- a/inteldomain.go +++ /dev/null @@ -1,319 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// IntelDomainService 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 [NewIntelDomainService] method -// instead. -type IntelDomainService struct { - Options []option.RequestOption - Bulks *IntelDomainBulkService -} - -// NewIntelDomainService 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 NewIntelDomainService(opts ...option.RequestOption) (r *IntelDomainService) { - r = &IntelDomainService{} - r.Options = opts - r.Bulks = NewIntelDomainBulkService(opts...) - return -} - -// Get Domain Details -func (r *IntelDomainService) Get(ctx context.Context, params IntelDomainGetParams, opts ...option.RequestOption) (res *IntelDomainGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env IntelDomainGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/intel/domain", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type IntelDomainGetResponse struct { - // Additional information related to the host name. - AdditionalInformation IntelDomainGetResponseAdditionalInformation `json:"additional_information"` - // Application that the hostname belongs to. - Application IntelDomainGetResponseApplication `json:"application"` - // Current content categories. - ContentCategories interface{} `json:"content_categories"` - Domain string `json:"domain"` - InheritedContentCategories []IntelDomainGetResponseInheritedContentCategory `json:"inherited_content_categories"` - // Domain from which `inherited_content_categories` and `inherited_risk_types` are - // inherited, if applicable. - InheritedFrom string `json:"inherited_from"` - InheritedRiskTypes []IntelDomainGetResponseInheritedRiskType `json:"inherited_risk_types"` - // Global Cloudflare 100k ranking for the last 30 days, if available for the - // hostname. The top ranked domain is 1, the lowest ranked domain is 100,000. - PopularityRank int64 `json:"popularity_rank"` - // Specifies a list of references to one or more IP addresses or domain names that - // the domain name currently resolves to. - ResolvesToRefs []IntelDomainGetResponseResolvesToRef `json:"resolves_to_refs"` - // Hostname risk score, which is a value between 0 (lowest risk) to 1 (highest - // risk). - RiskScore float64 `json:"risk_score"` - RiskTypes interface{} `json:"risk_types"` - JSON intelDomainGetResponseJSON `json:"-"` -} - -// intelDomainGetResponseJSON contains the JSON metadata for the struct -// [IntelDomainGetResponse] -type intelDomainGetResponseJSON struct { - AdditionalInformation apijson.Field - Application apijson.Field - ContentCategories apijson.Field - Domain apijson.Field - InheritedContentCategories apijson.Field - InheritedFrom apijson.Field - InheritedRiskTypes apijson.Field - PopularityRank apijson.Field - ResolvesToRefs apijson.Field - RiskScore apijson.Field - RiskTypes apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainGetResponseJSON) RawJSON() string { - return r.raw -} - -// Additional information related to the host name. -type IntelDomainGetResponseAdditionalInformation struct { - // Suspected DGA malware family. - SuspectedMalwareFamily string `json:"suspected_malware_family"` - JSON intelDomainGetResponseAdditionalInformationJSON `json:"-"` -} - -// intelDomainGetResponseAdditionalInformationJSON contains the JSON metadata for -// the struct [IntelDomainGetResponseAdditionalInformation] -type intelDomainGetResponseAdditionalInformationJSON struct { - SuspectedMalwareFamily apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainGetResponseAdditionalInformation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainGetResponseAdditionalInformationJSON) RawJSON() string { - return r.raw -} - -// Application that the hostname belongs to. -type IntelDomainGetResponseApplication struct { - ID int64 `json:"id"` - Name string `json:"name"` - JSON intelDomainGetResponseApplicationJSON `json:"-"` -} - -// intelDomainGetResponseApplicationJSON contains the JSON metadata for the struct -// [IntelDomainGetResponseApplication] -type intelDomainGetResponseApplicationJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainGetResponseApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainGetResponseApplicationJSON) RawJSON() string { - return r.raw -} - -type IntelDomainGetResponseInheritedContentCategory struct { - ID int64 `json:"id"` - Name string `json:"name"` - SuperCategoryID int64 `json:"super_category_id"` - JSON intelDomainGetResponseInheritedContentCategoryJSON `json:"-"` -} - -// intelDomainGetResponseInheritedContentCategoryJSON contains the JSON metadata -// for the struct [IntelDomainGetResponseInheritedContentCategory] -type intelDomainGetResponseInheritedContentCategoryJSON struct { - ID apijson.Field - Name apijson.Field - SuperCategoryID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainGetResponseInheritedContentCategory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainGetResponseInheritedContentCategoryJSON) RawJSON() string { - return r.raw -} - -type IntelDomainGetResponseInheritedRiskType struct { - ID int64 `json:"id"` - Name string `json:"name"` - SuperCategoryID int64 `json:"super_category_id"` - JSON intelDomainGetResponseInheritedRiskTypeJSON `json:"-"` -} - -// intelDomainGetResponseInheritedRiskTypeJSON contains the JSON metadata for the -// struct [IntelDomainGetResponseInheritedRiskType] -type intelDomainGetResponseInheritedRiskTypeJSON struct { - ID apijson.Field - Name apijson.Field - SuperCategoryID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainGetResponseInheritedRiskType) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainGetResponseInheritedRiskTypeJSON) RawJSON() string { - return r.raw -} - -type IntelDomainGetResponseResolvesToRef struct { - // STIX 2.1 identifier: - // https://docs.oasis-open.org/cti/stix/v2.1/cs02/stix-v2.1-cs02.html#_64yvzeku5a5c - ID string `json:"id"` - // IP address or domain name. - Value string `json:"value"` - JSON intelDomainGetResponseResolvesToRefJSON `json:"-"` -} - -// intelDomainGetResponseResolvesToRefJSON contains the JSON metadata for the -// struct [IntelDomainGetResponseResolvesToRef] -type intelDomainGetResponseResolvesToRefJSON struct { - ID apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainGetResponseResolvesToRef) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainGetResponseResolvesToRefJSON) RawJSON() string { - return r.raw -} - -type IntelDomainGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Domain param.Field[string] `query:"domain"` -} - -// URLQuery serializes [IntelDomainGetParams]'s query parameters as `url.Values`. -func (r IntelDomainGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type IntelDomainGetResponseEnvelope struct { - Errors []IntelDomainGetResponseEnvelopeErrors `json:"errors,required"` - Messages []IntelDomainGetResponseEnvelopeMessages `json:"messages,required"` - Result IntelDomainGetResponse `json:"result,required"` - // Whether the API call was successful - Success IntelDomainGetResponseEnvelopeSuccess `json:"success,required"` - JSON intelDomainGetResponseEnvelopeJSON `json:"-"` -} - -// intelDomainGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [IntelDomainGetResponseEnvelope] -type intelDomainGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IntelDomainGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelDomainGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// intelDomainGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IntelDomainGetResponseEnvelopeErrors] -type intelDomainGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IntelDomainGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelDomainGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// intelDomainGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IntelDomainGetResponseEnvelopeMessages] -type intelDomainGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type IntelDomainGetResponseEnvelopeSuccess bool - -const ( - IntelDomainGetResponseEnvelopeSuccessTrue IntelDomainGetResponseEnvelopeSuccess = true -) diff --git a/inteldomain_test.go b/inteldomain_test.go deleted file mode 100644 index db6b5e668b8..00000000000 --- a/inteldomain_test.go +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestIntelDomainGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Intel.Domains.Get(context.TODO(), cloudflare.IntelDomainGetParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Domain: cloudflare.F("string"), - }) - 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/inteldomainbulk.go b/inteldomainbulk.go deleted file mode 100644 index 8d277ff20f0..00000000000 --- a/inteldomainbulk.go +++ /dev/null @@ -1,322 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// IntelDomainBulkService 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 [NewIntelDomainBulkService] method -// instead. -type IntelDomainBulkService struct { - Options []option.RequestOption -} - -// NewIntelDomainBulkService 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 NewIntelDomainBulkService(opts ...option.RequestOption) (r *IntelDomainBulkService) { - r = &IntelDomainBulkService{} - r.Options = opts - return -} - -// Get Multiple Domain Details -func (r *IntelDomainBulkService) Get(ctx context.Context, params IntelDomainBulkGetParams, opts ...option.RequestOption) (res *[]IntelDomainBulkGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env IntelDomainBulkGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/intel/domain/bulk", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type IntelDomainBulkGetResponse struct { - // Additional information related to the host name. - AdditionalInformation IntelDomainBulkGetResponseAdditionalInformation `json:"additional_information"` - // Application that the hostname belongs to. - Application IntelDomainBulkGetResponseApplication `json:"application"` - // Current content categories. - ContentCategories interface{} `json:"content_categories"` - Domain string `json:"domain"` - InheritedContentCategories []IntelDomainBulkGetResponseInheritedContentCategory `json:"inherited_content_categories"` - // Domain from which `inherited_content_categories` and `inherited_risk_types` are - // inherited, if applicable. - InheritedFrom string `json:"inherited_from"` - InheritedRiskTypes []IntelDomainBulkGetResponseInheritedRiskType `json:"inherited_risk_types"` - // Global Cloudflare 100k ranking for the last 30 days, if available for the - // hostname. The top ranked domain is 1, the lowest ranked domain is 100,000. - PopularityRank int64 `json:"popularity_rank"` - // Hostname risk score, which is a value between 0 (lowest risk) to 1 (highest - // risk). - RiskScore float64 `json:"risk_score"` - RiskTypes interface{} `json:"risk_types"` - JSON intelDomainBulkGetResponseJSON `json:"-"` -} - -// intelDomainBulkGetResponseJSON contains the JSON metadata for the struct -// [IntelDomainBulkGetResponse] -type intelDomainBulkGetResponseJSON struct { - AdditionalInformation apijson.Field - Application apijson.Field - ContentCategories apijson.Field - Domain apijson.Field - InheritedContentCategories apijson.Field - InheritedFrom apijson.Field - InheritedRiskTypes apijson.Field - PopularityRank apijson.Field - RiskScore apijson.Field - RiskTypes apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainBulkGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainBulkGetResponseJSON) RawJSON() string { - return r.raw -} - -// Additional information related to the host name. -type IntelDomainBulkGetResponseAdditionalInformation struct { - // Suspected DGA malware family. - SuspectedMalwareFamily string `json:"suspected_malware_family"` - JSON intelDomainBulkGetResponseAdditionalInformationJSON `json:"-"` -} - -// intelDomainBulkGetResponseAdditionalInformationJSON contains the JSON metadata -// for the struct [IntelDomainBulkGetResponseAdditionalInformation] -type intelDomainBulkGetResponseAdditionalInformationJSON struct { - SuspectedMalwareFamily apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainBulkGetResponseAdditionalInformation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainBulkGetResponseAdditionalInformationJSON) RawJSON() string { - return r.raw -} - -// Application that the hostname belongs to. -type IntelDomainBulkGetResponseApplication struct { - ID int64 `json:"id"` - Name string `json:"name"` - JSON intelDomainBulkGetResponseApplicationJSON `json:"-"` -} - -// intelDomainBulkGetResponseApplicationJSON contains the JSON metadata for the -// struct [IntelDomainBulkGetResponseApplication] -type intelDomainBulkGetResponseApplicationJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainBulkGetResponseApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainBulkGetResponseApplicationJSON) RawJSON() string { - return r.raw -} - -type IntelDomainBulkGetResponseInheritedContentCategory struct { - ID int64 `json:"id"` - Name string `json:"name"` - SuperCategoryID int64 `json:"super_category_id"` - JSON intelDomainBulkGetResponseInheritedContentCategoryJSON `json:"-"` -} - -// intelDomainBulkGetResponseInheritedContentCategoryJSON contains the JSON -// metadata for the struct [IntelDomainBulkGetResponseInheritedContentCategory] -type intelDomainBulkGetResponseInheritedContentCategoryJSON struct { - ID apijson.Field - Name apijson.Field - SuperCategoryID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainBulkGetResponseInheritedContentCategory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainBulkGetResponseInheritedContentCategoryJSON) RawJSON() string { - return r.raw -} - -type IntelDomainBulkGetResponseInheritedRiskType struct { - ID int64 `json:"id"` - Name string `json:"name"` - SuperCategoryID int64 `json:"super_category_id"` - JSON intelDomainBulkGetResponseInheritedRiskTypeJSON `json:"-"` -} - -// intelDomainBulkGetResponseInheritedRiskTypeJSON contains the JSON metadata for -// the struct [IntelDomainBulkGetResponseInheritedRiskType] -type intelDomainBulkGetResponseInheritedRiskTypeJSON struct { - ID apijson.Field - Name apijson.Field - SuperCategoryID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainBulkGetResponseInheritedRiskType) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainBulkGetResponseInheritedRiskTypeJSON) RawJSON() string { - return r.raw -} - -type IntelDomainBulkGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Accepts multiple values, i.e. `?domain=cloudflare.com&domain=example.com`. - Domain param.Field[interface{}] `query:"domain"` -} - -// URLQuery serializes [IntelDomainBulkGetParams]'s query parameters as -// `url.Values`. -func (r IntelDomainBulkGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type IntelDomainBulkGetResponseEnvelope struct { - Errors []IntelDomainBulkGetResponseEnvelopeErrors `json:"errors,required"` - Messages []IntelDomainBulkGetResponseEnvelopeMessages `json:"messages,required"` - Result []IntelDomainBulkGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success IntelDomainBulkGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo IntelDomainBulkGetResponseEnvelopeResultInfo `json:"result_info"` - JSON intelDomainBulkGetResponseEnvelopeJSON `json:"-"` -} - -// intelDomainBulkGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [IntelDomainBulkGetResponseEnvelope] -type intelDomainBulkGetResponseEnvelopeJSON 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 *IntelDomainBulkGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainBulkGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IntelDomainBulkGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelDomainBulkGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// intelDomainBulkGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IntelDomainBulkGetResponseEnvelopeErrors] -type intelDomainBulkGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainBulkGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainBulkGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IntelDomainBulkGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelDomainBulkGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// intelDomainBulkGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [IntelDomainBulkGetResponseEnvelopeMessages] -type intelDomainBulkGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainBulkGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainBulkGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type IntelDomainBulkGetResponseEnvelopeSuccess bool - -const ( - IntelDomainBulkGetResponseEnvelopeSuccessTrue IntelDomainBulkGetResponseEnvelopeSuccess = true -) - -type IntelDomainBulkGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON intelDomainBulkGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// intelDomainBulkGetResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [IntelDomainBulkGetResponseEnvelopeResultInfo] -type intelDomainBulkGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainBulkGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainBulkGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/inteldomainbulk_test.go b/inteldomainbulk_test.go deleted file mode 100644 index 9451c18612d..00000000000 --- a/inteldomainbulk_test.go +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestIntelDomainBulkGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Intel.Domains.Bulks.Get(context.TODO(), cloudflare.IntelDomainBulkGetParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Domain: cloudflare.F[any](map[string]interface{}{}), - }) - 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/inteldomainhistory.go b/inteldomainhistory.go deleted file mode 100644 index 2a2d649cd1c..00000000000 --- a/inteldomainhistory.go +++ /dev/null @@ -1,225 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// IntelDomainHistoryService 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 [NewIntelDomainHistoryService] method -// instead. -type IntelDomainHistoryService struct { - Options []option.RequestOption -} - -// NewIntelDomainHistoryService 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 NewIntelDomainHistoryService(opts ...option.RequestOption) (r *IntelDomainHistoryService) { - r = &IntelDomainHistoryService{} - r.Options = opts - return -} - -// Get Domain History -func (r *IntelDomainHistoryService) Get(ctx context.Context, params IntelDomainHistoryGetParams, opts ...option.RequestOption) (res *[]IntelDomainHistoryGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env IntelDomainHistoryGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/intel/domain-history", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type IntelDomainHistoryGetResponse struct { - Categorizations []IntelDomainHistoryGetResponseCategorization `json:"categorizations"` - Domain string `json:"domain"` - JSON intelDomainHistoryGetResponseJSON `json:"-"` -} - -// intelDomainHistoryGetResponseJSON contains the JSON metadata for the struct -// [IntelDomainHistoryGetResponse] -type intelDomainHistoryGetResponseJSON struct { - Categorizations apijson.Field - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainHistoryGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainHistoryGetResponseJSON) RawJSON() string { - return r.raw -} - -type IntelDomainHistoryGetResponseCategorization struct { - Categories interface{} `json:"categories"` - End time.Time `json:"end" format:"date"` - Start time.Time `json:"start" format:"date"` - JSON intelDomainHistoryGetResponseCategorizationJSON `json:"-"` -} - -// intelDomainHistoryGetResponseCategorizationJSON contains the JSON metadata for -// the struct [IntelDomainHistoryGetResponseCategorization] -type intelDomainHistoryGetResponseCategorizationJSON struct { - Categories apijson.Field - End apijson.Field - Start apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainHistoryGetResponseCategorization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainHistoryGetResponseCategorizationJSON) RawJSON() string { - return r.raw -} - -type IntelDomainHistoryGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Domain param.Field[interface{}] `query:"domain"` -} - -// URLQuery serializes [IntelDomainHistoryGetParams]'s query parameters as -// `url.Values`. -func (r IntelDomainHistoryGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type IntelDomainHistoryGetResponseEnvelope struct { - Errors []IntelDomainHistoryGetResponseEnvelopeErrors `json:"errors,required"` - Messages []IntelDomainHistoryGetResponseEnvelopeMessages `json:"messages,required"` - Result []IntelDomainHistoryGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success IntelDomainHistoryGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo IntelDomainHistoryGetResponseEnvelopeResultInfo `json:"result_info"` - JSON intelDomainHistoryGetResponseEnvelopeJSON `json:"-"` -} - -// intelDomainHistoryGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [IntelDomainHistoryGetResponseEnvelope] -type intelDomainHistoryGetResponseEnvelopeJSON 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 *IntelDomainHistoryGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainHistoryGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IntelDomainHistoryGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelDomainHistoryGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// intelDomainHistoryGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [IntelDomainHistoryGetResponseEnvelopeErrors] -type intelDomainHistoryGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainHistoryGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainHistoryGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IntelDomainHistoryGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelDomainHistoryGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// intelDomainHistoryGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [IntelDomainHistoryGetResponseEnvelopeMessages] -type intelDomainHistoryGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainHistoryGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainHistoryGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type IntelDomainHistoryGetResponseEnvelopeSuccess bool - -const ( - IntelDomainHistoryGetResponseEnvelopeSuccessTrue IntelDomainHistoryGetResponseEnvelopeSuccess = true -) - -type IntelDomainHistoryGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON intelDomainHistoryGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// intelDomainHistoryGetResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [IntelDomainHistoryGetResponseEnvelopeResultInfo] -type intelDomainHistoryGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelDomainHistoryGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelDomainHistoryGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/inteldomainhistory_test.go b/inteldomainhistory_test.go deleted file mode 100644 index f791dbb1c35..00000000000 --- a/inteldomainhistory_test.go +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestIntelDomainHistoryGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Intel.DomainHistory.Get(context.TODO(), cloudflare.IntelDomainHistoryGetParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Domain: cloudflare.F[any]("example.com"), - }) - 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/intelindicatorfeed.go b/intelindicatorfeed.go deleted file mode 100644 index 5a314cca308..00000000000 --- a/intelindicatorfeed.go +++ /dev/null @@ -1,604 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// IntelIndicatorFeedService 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 [NewIntelIndicatorFeedService] method -// instead. -type IntelIndicatorFeedService struct { - Options []option.RequestOption - Permissions *IntelIndicatorFeedPermissionService -} - -// NewIntelIndicatorFeedService 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 NewIntelIndicatorFeedService(opts ...option.RequestOption) (r *IntelIndicatorFeedService) { - r = &IntelIndicatorFeedService{} - r.Options = opts - r.Permissions = NewIntelIndicatorFeedPermissionService(opts...) - return -} - -// Create new indicator feed -func (r *IntelIndicatorFeedService) New(ctx context.Context, params IntelIndicatorFeedNewParams, opts ...option.RequestOption) (res *IntelIndicatorFeedNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env IntelIndicatorFeedNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/intel/indicator-feeds", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update indicator feed data -func (r *IntelIndicatorFeedService) Update(ctx context.Context, feedID int64, params IntelIndicatorFeedUpdateParams, opts ...option.RequestOption) (res *IntelIndicatorFeedUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env IntelIndicatorFeedUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/intel/indicator-feeds/%v/snapshot", params.AccountID, feedID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get indicator feeds owned by this account -func (r *IntelIndicatorFeedService) List(ctx context.Context, query IntelIndicatorFeedListParams, opts ...option.RequestOption) (res *[]IntelIndicatorFeedListResponse, err error) { - opts = append(r.Options[:], opts...) - var env IntelIndicatorFeedListResponseEnvelope - path := fmt.Sprintf("accounts/%s/intel/indicator-feeds", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get indicator feed data -func (r *IntelIndicatorFeedService) Data(ctx context.Context, feedID int64, query IntelIndicatorFeedDataParams, opts ...option.RequestOption) (res *string, err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "text/csv")}, opts...) - path := fmt.Sprintf("accounts/%s/intel/indicator-feeds/%v/data", query.AccountID, feedID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -// Get indicator feed metadata -func (r *IntelIndicatorFeedService) Get(ctx context.Context, feedID int64, query IntelIndicatorFeedGetParams, opts ...option.RequestOption) (res *IntelIndicatorFeedGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env IntelIndicatorFeedGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/intel/indicator-feeds/%v", query.AccountID, feedID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type IntelIndicatorFeedNewResponse struct { - // The unique identifier for the indicator feed - ID int64 `json:"id"` - // The date and time when the data entry was created - CreatedOn time.Time `json:"created_on" format:"date-time"` - // The description of the example test - Description string `json:"description"` - // The date and time when the data entry was last modified - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The name of the indicator feed - Name string `json:"name"` - JSON intelIndicatorFeedNewResponseJSON `json:"-"` -} - -// intelIndicatorFeedNewResponseJSON contains the JSON metadata for the struct -// [IntelIndicatorFeedNewResponse] -type intelIndicatorFeedNewResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedNewResponseJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedUpdateResponse struct { - // Feed id - FileID int64 `json:"file_id"` - // Name of the file unified in our system - Filename string `json:"filename"` - // Current status of upload, should be unified - Status string `json:"status"` - JSON intelIndicatorFeedUpdateResponseJSON `json:"-"` -} - -// intelIndicatorFeedUpdateResponseJSON contains the JSON metadata for the struct -// [IntelIndicatorFeedUpdateResponse] -type intelIndicatorFeedUpdateResponseJSON struct { - FileID apijson.Field - Filename apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedListResponse struct { - // The unique identifier for the indicator feed - ID int64 `json:"id"` - // The date and time when the data entry was created - CreatedOn time.Time `json:"created_on" format:"date-time"` - // The description of the example test - Description string `json:"description"` - // The date and time when the data entry was last modified - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The name of the indicator feed - Name string `json:"name"` - JSON intelIndicatorFeedListResponseJSON `json:"-"` -} - -// intelIndicatorFeedListResponseJSON contains the JSON metadata for the struct -// [IntelIndicatorFeedListResponse] -type intelIndicatorFeedListResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedListResponseJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedGetResponse struct { - // The unique identifier for the indicator feed - ID int64 `json:"id"` - // The date and time when the data entry was created - CreatedOn time.Time `json:"created_on" format:"date-time"` - // The description of the example test - Description string `json:"description"` - // Status of the latest snapshot uploaded - LatestUploadStatus IntelIndicatorFeedGetResponseLatestUploadStatus `json:"latest_upload_status"` - // The date and time when the data entry was last modified - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The name of the indicator feed - Name string `json:"name"` - JSON intelIndicatorFeedGetResponseJSON `json:"-"` -} - -// intelIndicatorFeedGetResponseJSON contains the JSON metadata for the struct -// [IntelIndicatorFeedGetResponse] -type intelIndicatorFeedGetResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Description apijson.Field - LatestUploadStatus apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedGetResponseJSON) RawJSON() string { - return r.raw -} - -// Status of the latest snapshot uploaded -type IntelIndicatorFeedGetResponseLatestUploadStatus string - -const ( - IntelIndicatorFeedGetResponseLatestUploadStatusMirroring IntelIndicatorFeedGetResponseLatestUploadStatus = "Mirroring" - IntelIndicatorFeedGetResponseLatestUploadStatusUnifying IntelIndicatorFeedGetResponseLatestUploadStatus = "Unifying" - IntelIndicatorFeedGetResponseLatestUploadStatusLoading IntelIndicatorFeedGetResponseLatestUploadStatus = "Loading" - IntelIndicatorFeedGetResponseLatestUploadStatusProvisioning IntelIndicatorFeedGetResponseLatestUploadStatus = "Provisioning" - IntelIndicatorFeedGetResponseLatestUploadStatusComplete IntelIndicatorFeedGetResponseLatestUploadStatus = "Complete" - IntelIndicatorFeedGetResponseLatestUploadStatusError IntelIndicatorFeedGetResponseLatestUploadStatus = "Error" -) - -type IntelIndicatorFeedNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The description of the example test - Description param.Field[string] `json:"description"` - // The name of the indicator feed - Name param.Field[string] `json:"name"` -} - -func (r IntelIndicatorFeedNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type IntelIndicatorFeedNewResponseEnvelope struct { - Errors []IntelIndicatorFeedNewResponseEnvelopeErrors `json:"errors,required"` - Messages []IntelIndicatorFeedNewResponseEnvelopeMessages `json:"messages,required"` - Result IntelIndicatorFeedNewResponse `json:"result,required"` - // Whether the API call was successful - Success IntelIndicatorFeedNewResponseEnvelopeSuccess `json:"success,required"` - JSON intelIndicatorFeedNewResponseEnvelopeJSON `json:"-"` -} - -// intelIndicatorFeedNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [IntelIndicatorFeedNewResponseEnvelope] -type intelIndicatorFeedNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelIndicatorFeedNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// intelIndicatorFeedNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [IntelIndicatorFeedNewResponseEnvelopeErrors] -type intelIndicatorFeedNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelIndicatorFeedNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// intelIndicatorFeedNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [IntelIndicatorFeedNewResponseEnvelopeMessages] -type intelIndicatorFeedNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type IntelIndicatorFeedNewResponseEnvelopeSuccess bool - -const ( - IntelIndicatorFeedNewResponseEnvelopeSuccessTrue IntelIndicatorFeedNewResponseEnvelopeSuccess = true -) - -type IntelIndicatorFeedUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The file to upload - Source param.Field[string] `json:"source"` -} - -func (r IntelIndicatorFeedUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type IntelIndicatorFeedUpdateResponseEnvelope struct { - Errors []IntelIndicatorFeedUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []IntelIndicatorFeedUpdateResponseEnvelopeMessages `json:"messages,required"` - Result IntelIndicatorFeedUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success IntelIndicatorFeedUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON intelIndicatorFeedUpdateResponseEnvelopeJSON `json:"-"` -} - -// intelIndicatorFeedUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [IntelIndicatorFeedUpdateResponseEnvelope] -type intelIndicatorFeedUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelIndicatorFeedUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// intelIndicatorFeedUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [IntelIndicatorFeedUpdateResponseEnvelopeErrors] -type intelIndicatorFeedUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelIndicatorFeedUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// intelIndicatorFeedUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [IntelIndicatorFeedUpdateResponseEnvelopeMessages] -type intelIndicatorFeedUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type IntelIndicatorFeedUpdateResponseEnvelopeSuccess bool - -const ( - IntelIndicatorFeedUpdateResponseEnvelopeSuccessTrue IntelIndicatorFeedUpdateResponseEnvelopeSuccess = true -) - -type IntelIndicatorFeedListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type IntelIndicatorFeedListResponseEnvelope struct { - Errors []IntelIndicatorFeedListResponseEnvelopeErrors `json:"errors,required"` - Messages []IntelIndicatorFeedListResponseEnvelopeMessages `json:"messages,required"` - Result []IntelIndicatorFeedListResponse `json:"result,required"` - // Whether the API call was successful - Success IntelIndicatorFeedListResponseEnvelopeSuccess `json:"success,required"` - JSON intelIndicatorFeedListResponseEnvelopeJSON `json:"-"` -} - -// intelIndicatorFeedListResponseEnvelopeJSON contains the JSON metadata for the -// struct [IntelIndicatorFeedListResponseEnvelope] -type intelIndicatorFeedListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelIndicatorFeedListResponseEnvelopeErrorsJSON `json:"-"` -} - -// intelIndicatorFeedListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [IntelIndicatorFeedListResponseEnvelopeErrors] -type intelIndicatorFeedListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelIndicatorFeedListResponseEnvelopeMessagesJSON `json:"-"` -} - -// intelIndicatorFeedListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [IntelIndicatorFeedListResponseEnvelopeMessages] -type intelIndicatorFeedListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type IntelIndicatorFeedListResponseEnvelopeSuccess bool - -const ( - IntelIndicatorFeedListResponseEnvelopeSuccessTrue IntelIndicatorFeedListResponseEnvelopeSuccess = true -) - -type IntelIndicatorFeedDataParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type IntelIndicatorFeedGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type IntelIndicatorFeedGetResponseEnvelope struct { - Errors []IntelIndicatorFeedGetResponseEnvelopeErrors `json:"errors,required"` - Messages []IntelIndicatorFeedGetResponseEnvelopeMessages `json:"messages,required"` - Result IntelIndicatorFeedGetResponse `json:"result,required"` - // Whether the API call was successful - Success IntelIndicatorFeedGetResponseEnvelopeSuccess `json:"success,required"` - JSON intelIndicatorFeedGetResponseEnvelopeJSON `json:"-"` -} - -// intelIndicatorFeedGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [IntelIndicatorFeedGetResponseEnvelope] -type intelIndicatorFeedGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelIndicatorFeedGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// intelIndicatorFeedGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [IntelIndicatorFeedGetResponseEnvelopeErrors] -type intelIndicatorFeedGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelIndicatorFeedGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// intelIndicatorFeedGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [IntelIndicatorFeedGetResponseEnvelopeMessages] -type intelIndicatorFeedGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type IntelIndicatorFeedGetResponseEnvelopeSuccess bool - -const ( - IntelIndicatorFeedGetResponseEnvelopeSuccessTrue IntelIndicatorFeedGetResponseEnvelopeSuccess = true -) diff --git a/intelindicatorfeed_test.go b/intelindicatorfeed_test.go deleted file mode 100644 index 7684fe5fdea..00000000000 --- a/intelindicatorfeed_test.go +++ /dev/null @@ -1,159 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestIntelIndicatorFeedNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Intel.IndicatorFeeds.New(context.TODO(), cloudflare.IntelIndicatorFeedNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Description: cloudflare.F("example feed description"), - Name: cloudflare.F("example_feed_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 TestIntelIndicatorFeedUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Intel.IndicatorFeeds.Update( - context.TODO(), - int64(12), - cloudflare.IntelIndicatorFeedUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Source: cloudflare.F("@/Users/me/test.stix2"), - }, - ) - 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 TestIntelIndicatorFeedList(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("user@example.com"), - ) - _, err := client.Intel.IndicatorFeeds.List(context.TODO(), cloudflare.IntelIndicatorFeedListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestIntelIndicatorFeedData(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("user@example.com"), - ) - _, err := client.Intel.IndicatorFeeds.Data( - context.TODO(), - int64(12), - cloudflare.IntelIndicatorFeedDataParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestIntelIndicatorFeedGet(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("user@example.com"), - ) - _, err := client.Intel.IndicatorFeeds.Get( - context.TODO(), - int64(12), - cloudflare.IntelIndicatorFeedGetParams{ - AccountID: cloudflare.F("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/intelindicatorfeedpermission.go b/intelindicatorfeedpermission.go deleted file mode 100644 index 31eec85e259..00000000000 --- a/intelindicatorfeedpermission.go +++ /dev/null @@ -1,421 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// IntelIndicatorFeedPermissionService 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 -// [NewIntelIndicatorFeedPermissionService] method instead. -type IntelIndicatorFeedPermissionService struct { - Options []option.RequestOption -} - -// NewIntelIndicatorFeedPermissionService 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 NewIntelIndicatorFeedPermissionService(opts ...option.RequestOption) (r *IntelIndicatorFeedPermissionService) { - r = &IntelIndicatorFeedPermissionService{} - r.Options = opts - return -} - -// Grant permission to indicator feed -func (r *IntelIndicatorFeedPermissionService) New(ctx context.Context, params IntelIndicatorFeedPermissionNewParams, opts ...option.RequestOption) (res *IntelIndicatorFeedPermissionNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env IntelIndicatorFeedPermissionNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/intel/indicator-feeds/permissions/add", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List indicator feed permissions -func (r *IntelIndicatorFeedPermissionService) List(ctx context.Context, query IntelIndicatorFeedPermissionListParams, opts ...option.RequestOption) (res *[]IntelIndicatorFeedPermissionListResponse, err error) { - opts = append(r.Options[:], opts...) - var env IntelIndicatorFeedPermissionListResponseEnvelope - path := fmt.Sprintf("accounts/%s/intel/indicator-feeds/permissions/view", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Revoke permission to indicator feed -func (r *IntelIndicatorFeedPermissionService) Delete(ctx context.Context, params IntelIndicatorFeedPermissionDeleteParams, opts ...option.RequestOption) (res *IntelIndicatorFeedPermissionDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env IntelIndicatorFeedPermissionDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/intel/indicator-feeds/permissions/remove", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type IntelIndicatorFeedPermissionNewResponse struct { - // Whether the update succeeded or not - Success bool `json:"success"` - JSON intelIndicatorFeedPermissionNewResponseJSON `json:"-"` -} - -// intelIndicatorFeedPermissionNewResponseJSON contains the JSON metadata for the -// struct [IntelIndicatorFeedPermissionNewResponse] -type intelIndicatorFeedPermissionNewResponseJSON struct { - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedPermissionNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedPermissionNewResponseJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedPermissionListResponse struct { - // The unique identifier for the indicator feed - ID int64 `json:"id"` - // The description of the example test - Description string `json:"description"` - // The name of the indicator feed - Name string `json:"name"` - JSON intelIndicatorFeedPermissionListResponseJSON `json:"-"` -} - -// intelIndicatorFeedPermissionListResponseJSON contains the JSON metadata for the -// struct [IntelIndicatorFeedPermissionListResponse] -type intelIndicatorFeedPermissionListResponseJSON struct { - ID apijson.Field - Description apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedPermissionListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedPermissionListResponseJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedPermissionDeleteResponse struct { - // Whether the update succeeded or not - Success bool `json:"success"` - JSON intelIndicatorFeedPermissionDeleteResponseJSON `json:"-"` -} - -// intelIndicatorFeedPermissionDeleteResponseJSON contains the JSON metadata for -// the struct [IntelIndicatorFeedPermissionDeleteResponse] -type intelIndicatorFeedPermissionDeleteResponseJSON struct { - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedPermissionDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedPermissionDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedPermissionNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The Cloudflare account tag of the account to change permissions on - AccountTag param.Field[string] `json:"account_tag"` - // The ID of the feed to add/remove permissions on - FeedID param.Field[int64] `json:"feed_id"` -} - -func (r IntelIndicatorFeedPermissionNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type IntelIndicatorFeedPermissionNewResponseEnvelope struct { - Errors []IntelIndicatorFeedPermissionNewResponseEnvelopeErrors `json:"errors,required"` - Messages []IntelIndicatorFeedPermissionNewResponseEnvelopeMessages `json:"messages,required"` - Result IntelIndicatorFeedPermissionNewResponse `json:"result,required"` - // Whether the API call was successful - Success IntelIndicatorFeedPermissionNewResponseEnvelopeSuccess `json:"success,required"` - JSON intelIndicatorFeedPermissionNewResponseEnvelopeJSON `json:"-"` -} - -// intelIndicatorFeedPermissionNewResponseEnvelopeJSON contains the JSON metadata -// for the struct [IntelIndicatorFeedPermissionNewResponseEnvelope] -type intelIndicatorFeedPermissionNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedPermissionNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedPermissionNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedPermissionNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelIndicatorFeedPermissionNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// intelIndicatorFeedPermissionNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [IntelIndicatorFeedPermissionNewResponseEnvelopeErrors] -type intelIndicatorFeedPermissionNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedPermissionNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedPermissionNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedPermissionNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelIndicatorFeedPermissionNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// intelIndicatorFeedPermissionNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [IntelIndicatorFeedPermissionNewResponseEnvelopeMessages] -type intelIndicatorFeedPermissionNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedPermissionNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedPermissionNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type IntelIndicatorFeedPermissionNewResponseEnvelopeSuccess bool - -const ( - IntelIndicatorFeedPermissionNewResponseEnvelopeSuccessTrue IntelIndicatorFeedPermissionNewResponseEnvelopeSuccess = true -) - -type IntelIndicatorFeedPermissionListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type IntelIndicatorFeedPermissionListResponseEnvelope struct { - Errors []IntelIndicatorFeedPermissionListResponseEnvelopeErrors `json:"errors,required"` - Messages []IntelIndicatorFeedPermissionListResponseEnvelopeMessages `json:"messages,required"` - Result []IntelIndicatorFeedPermissionListResponse `json:"result,required"` - // Whether the API call was successful - Success IntelIndicatorFeedPermissionListResponseEnvelopeSuccess `json:"success,required"` - JSON intelIndicatorFeedPermissionListResponseEnvelopeJSON `json:"-"` -} - -// intelIndicatorFeedPermissionListResponseEnvelopeJSON contains the JSON metadata -// for the struct [IntelIndicatorFeedPermissionListResponseEnvelope] -type intelIndicatorFeedPermissionListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedPermissionListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedPermissionListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedPermissionListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelIndicatorFeedPermissionListResponseEnvelopeErrorsJSON `json:"-"` -} - -// intelIndicatorFeedPermissionListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [IntelIndicatorFeedPermissionListResponseEnvelopeErrors] -type intelIndicatorFeedPermissionListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedPermissionListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedPermissionListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedPermissionListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelIndicatorFeedPermissionListResponseEnvelopeMessagesJSON `json:"-"` -} - -// intelIndicatorFeedPermissionListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [IntelIndicatorFeedPermissionListResponseEnvelopeMessages] -type intelIndicatorFeedPermissionListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedPermissionListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedPermissionListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type IntelIndicatorFeedPermissionListResponseEnvelopeSuccess bool - -const ( - IntelIndicatorFeedPermissionListResponseEnvelopeSuccessTrue IntelIndicatorFeedPermissionListResponseEnvelopeSuccess = true -) - -type IntelIndicatorFeedPermissionDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The Cloudflare account tag of the account to change permissions on - AccountTag param.Field[string] `json:"account_tag"` - // The ID of the feed to add/remove permissions on - FeedID param.Field[int64] `json:"feed_id"` -} - -func (r IntelIndicatorFeedPermissionDeleteParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type IntelIndicatorFeedPermissionDeleteResponseEnvelope struct { - Errors []IntelIndicatorFeedPermissionDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []IntelIndicatorFeedPermissionDeleteResponseEnvelopeMessages `json:"messages,required"` - Result IntelIndicatorFeedPermissionDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success IntelIndicatorFeedPermissionDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON intelIndicatorFeedPermissionDeleteResponseEnvelopeJSON `json:"-"` -} - -// intelIndicatorFeedPermissionDeleteResponseEnvelopeJSON contains the JSON -// metadata for the struct [IntelIndicatorFeedPermissionDeleteResponseEnvelope] -type intelIndicatorFeedPermissionDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedPermissionDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedPermissionDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedPermissionDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelIndicatorFeedPermissionDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// intelIndicatorFeedPermissionDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [IntelIndicatorFeedPermissionDeleteResponseEnvelopeErrors] -type intelIndicatorFeedPermissionDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedPermissionDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedPermissionDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IntelIndicatorFeedPermissionDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelIndicatorFeedPermissionDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// intelIndicatorFeedPermissionDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [IntelIndicatorFeedPermissionDeleteResponseEnvelopeMessages] -type intelIndicatorFeedPermissionDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIndicatorFeedPermissionDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIndicatorFeedPermissionDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type IntelIndicatorFeedPermissionDeleteResponseEnvelopeSuccess bool - -const ( - IntelIndicatorFeedPermissionDeleteResponseEnvelopeSuccessTrue IntelIndicatorFeedPermissionDeleteResponseEnvelopeSuccess = true -) diff --git a/intelindicatorfeedpermission_test.go b/intelindicatorfeedpermission_test.go deleted file mode 100644 index aa1f8c04207..00000000000 --- a/intelindicatorfeedpermission_test.go +++ /dev/null @@ -1,96 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestIntelIndicatorFeedPermissionNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Intel.IndicatorFeeds.Permissions.New(context.TODO(), cloudflare.IntelIndicatorFeedPermissionNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - AccountTag: cloudflare.F("823f45f16fd2f7e21e1e054aga4d2859"), - FeedID: cloudflare.F(int64(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 TestIntelIndicatorFeedPermissionList(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("user@example.com"), - ) - _, err := client.Intel.IndicatorFeeds.Permissions.List(context.TODO(), cloudflare.IntelIndicatorFeedPermissionListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestIntelIndicatorFeedPermissionDeleteWithOptionalParams(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("user@example.com"), - ) - _, err := client.Intel.IndicatorFeeds.Permissions.Delete(context.TODO(), cloudflare.IntelIndicatorFeedPermissionDeleteParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - AccountTag: cloudflare.F("823f45f16fd2f7e21e1e054aga4d2859"), - FeedID: cloudflare.F(int64(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()) - } -} diff --git a/intelip.go b/intelip.go deleted file mode 100644 index 8d48ec5a40f..00000000000 --- a/intelip.go +++ /dev/null @@ -1,266 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// IntelIPService 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 [NewIntelIPService] method instead. -type IntelIPService struct { - Options []option.RequestOption -} - -// NewIntelIPService 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 NewIntelIPService(opts ...option.RequestOption) (r *IntelIPService) { - r = &IntelIPService{} - r.Options = opts - return -} - -// Get IP Overview -func (r *IntelIPService) Get(ctx context.Context, params IntelIPGetParams, opts ...option.RequestOption) (res *[]IntelIPGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env IntelIPGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/intel/ip", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type IntelIPGetResponse struct { - // Specifies a reference to the autonomous systems (AS) that the IP address belongs - // to. - BelongsToRef IntelIPGetResponseBelongsToRef `json:"belongs_to_ref"` - IP IntelIPGetResponseIP `json:"ip" format:"ipv4"` - RiskTypes interface{} `json:"risk_types"` - JSON intelIPGetResponseJSON `json:"-"` -} - -// intelIPGetResponseJSON contains the JSON metadata for the struct -// [IntelIPGetResponse] -type intelIPGetResponseJSON struct { - BelongsToRef apijson.Field - IP apijson.Field - RiskTypes apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIPGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIPGetResponseJSON) RawJSON() string { - return r.raw -} - -// Specifies a reference to the autonomous systems (AS) that the IP address belongs -// to. -type IntelIPGetResponseBelongsToRef struct { - ID interface{} `json:"id"` - Country string `json:"country"` - Description string `json:"description"` - // Infrastructure type of this ASN. - Type IntelIPGetResponseBelongsToRefType `json:"type"` - Value string `json:"value"` - JSON intelIPGetResponseBelongsToRefJSON `json:"-"` -} - -// intelIPGetResponseBelongsToRefJSON contains the JSON metadata for the struct -// [IntelIPGetResponseBelongsToRef] -type intelIPGetResponseBelongsToRefJSON struct { - ID apijson.Field - Country apijson.Field - Description apijson.Field - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIPGetResponseBelongsToRef) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIPGetResponseBelongsToRefJSON) RawJSON() string { - return r.raw -} - -// Infrastructure type of this ASN. -type IntelIPGetResponseBelongsToRefType string - -const ( - IntelIPGetResponseBelongsToRefTypeHostingProvider IntelIPGetResponseBelongsToRefType = "hosting_provider" - IntelIPGetResponseBelongsToRefTypeIsp IntelIPGetResponseBelongsToRefType = "isp" - IntelIPGetResponseBelongsToRefTypeOrganization IntelIPGetResponseBelongsToRefType = "organization" -) - -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type IntelIPGetResponseIP interface { - ImplementsIntelIPGetResponseIP() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*IntelIPGetResponseIP)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type IntelIPGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - IPV4 param.Field[string] `query:"ipv4"` - IPV6 param.Field[string] `query:"ipv6"` -} - -// URLQuery serializes [IntelIPGetParams]'s query parameters as `url.Values`. -func (r IntelIPGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type IntelIPGetResponseEnvelope struct { - Errors []IntelIPGetResponseEnvelopeErrors `json:"errors,required"` - Messages []IntelIPGetResponseEnvelopeMessages `json:"messages,required"` - Result []IntelIPGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success IntelIPGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo IntelIPGetResponseEnvelopeResultInfo `json:"result_info"` - JSON intelIPGetResponseEnvelopeJSON `json:"-"` -} - -// intelIPGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [IntelIPGetResponseEnvelope] -type intelIPGetResponseEnvelopeJSON 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 *IntelIPGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIPGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IntelIPGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelIPGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// intelIPGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [IntelIPGetResponseEnvelopeErrors] -type intelIPGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIPGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIPGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IntelIPGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelIPGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// intelIPGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [IntelIPGetResponseEnvelopeMessages] -type intelIPGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIPGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIPGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type IntelIPGetResponseEnvelopeSuccess bool - -const ( - IntelIPGetResponseEnvelopeSuccessTrue IntelIPGetResponseEnvelopeSuccess = true -) - -type IntelIPGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON intelIPGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// intelIPGetResponseEnvelopeResultInfoJSON contains the JSON metadata for the -// struct [IntelIPGetResponseEnvelopeResultInfo] -type intelIPGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIPGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIPGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/intelip_test.go b/intelip_test.go deleted file mode 100644 index 91cd42622c1..00000000000 --- a/intelip_test.go +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestIntelIPGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Intel.IPs.Get(context.TODO(), cloudflare.IntelIPGetParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - IPV4: cloudflare.F("string"), - IPV6: cloudflare.F("string"), - }) - 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/inteliplist.go b/inteliplist.go deleted file mode 100644 index 1d688c05a79..00000000000 --- a/inteliplist.go +++ /dev/null @@ -1,189 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// IntelIPListService 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 [NewIntelIPListService] method -// instead. -type IntelIPListService struct { - Options []option.RequestOption -} - -// NewIntelIPListService 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 NewIntelIPListService(opts ...option.RequestOption) (r *IntelIPListService) { - r = &IntelIPListService{} - r.Options = opts - return -} - -// Get IP Lists -func (r *IntelIPListService) Get(ctx context.Context, query IntelIPListGetParams, opts ...option.RequestOption) (res *[]IntelIPListGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env IntelIPListGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/intel/ip-list", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type IntelIPListGetResponse struct { - ID int64 `json:"id"` - Description string `json:"description"` - Name string `json:"name"` - JSON intelIPListGetResponseJSON `json:"-"` -} - -// intelIPListGetResponseJSON contains the JSON metadata for the struct -// [IntelIPListGetResponse] -type intelIPListGetResponseJSON struct { - ID apijson.Field - Description apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIPListGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIPListGetResponseJSON) RawJSON() string { - return r.raw -} - -type IntelIPListGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type IntelIPListGetResponseEnvelope struct { - Errors []IntelIPListGetResponseEnvelopeErrors `json:"errors,required"` - Messages []IntelIPListGetResponseEnvelopeMessages `json:"messages,required"` - Result []IntelIPListGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success IntelIPListGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo IntelIPListGetResponseEnvelopeResultInfo `json:"result_info"` - JSON intelIPListGetResponseEnvelopeJSON `json:"-"` -} - -// intelIPListGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [IntelIPListGetResponseEnvelope] -type intelIPListGetResponseEnvelopeJSON 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 *IntelIPListGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIPListGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IntelIPListGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelIPListGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// intelIPListGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IntelIPListGetResponseEnvelopeErrors] -type intelIPListGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIPListGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIPListGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IntelIPListGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelIPListGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// intelIPListGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IntelIPListGetResponseEnvelopeMessages] -type intelIPListGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIPListGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIPListGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type IntelIPListGetResponseEnvelopeSuccess bool - -const ( - IntelIPListGetResponseEnvelopeSuccessTrue IntelIPListGetResponseEnvelopeSuccess = true -) - -type IntelIPListGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON intelIPListGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// intelIPListGetResponseEnvelopeResultInfoJSON contains the JSON metadata for the -// struct [IntelIPListGetResponseEnvelopeResultInfo] -type intelIPListGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelIPListGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelIPListGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/inteliplist_test.go b/inteliplist_test.go deleted file mode 100644 index 2a12f64dc48..00000000000 --- a/inteliplist_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestIntelIPListGet(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("user@example.com"), - ) - _, err := client.Intel.IPLists.Get(context.TODO(), cloudflare.IntelIPListGetParams{ - AccountID: cloudflare.F("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/intelmiscategorization.go b/intelmiscategorization.go deleted file mode 100644 index aa2b942ab2f..00000000000 --- a/intelmiscategorization.go +++ /dev/null @@ -1,179 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// IntelMiscategorizationService 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 [NewIntelMiscategorizationService] -// method instead. -type IntelMiscategorizationService struct { - Options []option.RequestOption -} - -// NewIntelMiscategorizationService 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 NewIntelMiscategorizationService(opts ...option.RequestOption) (r *IntelMiscategorizationService) { - r = &IntelMiscategorizationService{} - r.Options = opts - return -} - -// Create Miscategorization -func (r *IntelMiscategorizationService) New(ctx context.Context, params IntelMiscategorizationNewParams, opts ...option.RequestOption) (res *IntelMiscategorizationNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env IntelMiscategorizationNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/intel/miscategorization", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [IntelMiscategorizationNewResponseUnknown] or -// [shared.UnionString]. -type IntelMiscategorizationNewResponse interface { - ImplementsIntelMiscategorizationNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*IntelMiscategorizationNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type IntelMiscategorizationNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Content category IDs to add. - ContentAdds param.Field[interface{}] `json:"content_adds"` - // Content category IDs to remove. - ContentRemoves param.Field[interface{}] `json:"content_removes"` - IndicatorType param.Field[IntelMiscategorizationNewParamsIndicatorType] `json:"indicator_type"` - // Provide only if indicator_type is `ipv4` or `ipv6`. - IP param.Field[interface{}] `json:"ip"` - // Security category IDs to add. - SecurityAdds param.Field[interface{}] `json:"security_adds"` - // Security category IDs to remove. - SecurityRemoves param.Field[interface{}] `json:"security_removes"` - // Provide only if indicator_type is `domain` or `url`. Example if indicator_type - // is `domain`: `example.com`. Example if indicator_type is `url`: - // `https://example.com/news/`. - URL param.Field[string] `json:"url"` -} - -func (r IntelMiscategorizationNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type IntelMiscategorizationNewParamsIndicatorType string - -const ( - IntelMiscategorizationNewParamsIndicatorTypeDomain IntelMiscategorizationNewParamsIndicatorType = "domain" - IntelMiscategorizationNewParamsIndicatorTypeIPV4 IntelMiscategorizationNewParamsIndicatorType = "ipv4" - IntelMiscategorizationNewParamsIndicatorTypeIPV6 IntelMiscategorizationNewParamsIndicatorType = "ipv6" - IntelMiscategorizationNewParamsIndicatorTypeURL IntelMiscategorizationNewParamsIndicatorType = "url" -) - -type IntelMiscategorizationNewResponseEnvelope struct { - Errors []IntelMiscategorizationNewResponseEnvelopeErrors `json:"errors,required"` - Messages []IntelMiscategorizationNewResponseEnvelopeMessages `json:"messages,required"` - Result IntelMiscategorizationNewResponse `json:"result,required"` - // Whether the API call was successful - Success IntelMiscategorizationNewResponseEnvelopeSuccess `json:"success,required"` - JSON intelMiscategorizationNewResponseEnvelopeJSON `json:"-"` -} - -// intelMiscategorizationNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [IntelMiscategorizationNewResponseEnvelope] -type intelMiscategorizationNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelMiscategorizationNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelMiscategorizationNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IntelMiscategorizationNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelMiscategorizationNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// intelMiscategorizationNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [IntelMiscategorizationNewResponseEnvelopeErrors] -type intelMiscategorizationNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelMiscategorizationNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelMiscategorizationNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IntelMiscategorizationNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelMiscategorizationNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// intelMiscategorizationNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [IntelMiscategorizationNewResponseEnvelopeMessages] -type intelMiscategorizationNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelMiscategorizationNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelMiscategorizationNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type IntelMiscategorizationNewResponseEnvelopeSuccess bool - -const ( - IntelMiscategorizationNewResponseEnvelopeSuccessTrue IntelMiscategorizationNewResponseEnvelopeSuccess = true -) diff --git a/intelmiscategorization_test.go b/intelmiscategorization_test.go deleted file mode 100644 index a2452f803b4..00000000000 --- a/intelmiscategorization_test.go +++ /dev/null @@ -1,56 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestIntelMiscategorizationNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Intel.Miscategorizations.New(context.TODO(), cloudflare.IntelMiscategorizationNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - ContentAdds: cloudflare.F[any](map[string]interface{}{ - "0": int64(82), - }), - ContentRemoves: cloudflare.F[any](map[string]interface{}{ - "0": int64(155), - }), - IndicatorType: cloudflare.F(cloudflare.IntelMiscategorizationNewParamsIndicatorTypeDomain), - IP: cloudflare.F[any](map[string]interface{}{}), - SecurityAdds: cloudflare.F[any](map[string]interface{}{ - "0": int64(117), - "1": int64(131), - }), - SecurityRemoves: cloudflare.F[any](map[string]interface{}{ - "0": int64(83), - }), - URL: cloudflare.F("string"), - }) - 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/intelsinkhole.go b/intelsinkhole.go deleted file mode 100644 index 6e92afa5b51..00000000000 --- a/intelsinkhole.go +++ /dev/null @@ -1,172 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// IntelSinkholeService 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 [NewIntelSinkholeService] method -// instead. -type IntelSinkholeService struct { - Options []option.RequestOption -} - -// NewIntelSinkholeService 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 NewIntelSinkholeService(opts ...option.RequestOption) (r *IntelSinkholeService) { - r = &IntelSinkholeService{} - r.Options = opts - return -} - -// List sinkholes owned by this account -func (r *IntelSinkholeService) List(ctx context.Context, query IntelSinkholeListParams, opts ...option.RequestOption) (res *[]IntelSinkholeListResponse, err error) { - opts = append(r.Options[:], opts...) - var env IntelSinkholeListResponseEnvelope - path := fmt.Sprintf("accounts/%s/intel/sinkholes", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type IntelSinkholeListResponse struct { - // The unique identifier for the sinkhole - ID int64 `json:"id"` - // The account tag that owns this sinkhole - AccountTag string `json:"account_tag"` - // The date and time when the sinkhole was created - CreatedOn time.Time `json:"created_on" format:"date-time"` - // The date and time when the sinkhole was last modified - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The name of the sinkhole - Name string `json:"name"` - // The name of the R2 bucket to store results - R2Bucket string `json:"r2_bucket"` - // The id of the R2 instance - R2ID string `json:"r2_id"` - JSON intelSinkholeListResponseJSON `json:"-"` -} - -// intelSinkholeListResponseJSON contains the JSON metadata for the struct -// [IntelSinkholeListResponse] -type intelSinkholeListResponseJSON struct { - ID apijson.Field - AccountTag apijson.Field - CreatedOn apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - R2Bucket apijson.Field - R2ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelSinkholeListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelSinkholeListResponseJSON) RawJSON() string { - return r.raw -} - -type IntelSinkholeListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type IntelSinkholeListResponseEnvelope struct { - Errors []IntelSinkholeListResponseEnvelopeErrors `json:"errors,required"` - Messages []IntelSinkholeListResponseEnvelopeMessages `json:"messages,required"` - Result []IntelSinkholeListResponse `json:"result,required"` - // Whether the API call was successful - Success IntelSinkholeListResponseEnvelopeSuccess `json:"success,required"` - JSON intelSinkholeListResponseEnvelopeJSON `json:"-"` -} - -// intelSinkholeListResponseEnvelopeJSON contains the JSON metadata for the struct -// [IntelSinkholeListResponseEnvelope] -type intelSinkholeListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelSinkholeListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelSinkholeListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IntelSinkholeListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelSinkholeListResponseEnvelopeErrorsJSON `json:"-"` -} - -// intelSinkholeListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IntelSinkholeListResponseEnvelopeErrors] -type intelSinkholeListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelSinkholeListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelSinkholeListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IntelSinkholeListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelSinkholeListResponseEnvelopeMessagesJSON `json:"-"` -} - -// intelSinkholeListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IntelSinkholeListResponseEnvelopeMessages] -type intelSinkholeListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelSinkholeListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelSinkholeListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type IntelSinkholeListResponseEnvelopeSuccess bool - -const ( - IntelSinkholeListResponseEnvelopeSuccessTrue IntelSinkholeListResponseEnvelopeSuccess = true -) diff --git a/intelsinkhole_test.go b/intelsinkhole_test.go deleted file mode 100644 index ed074c5f1a5..00000000000 --- a/intelsinkhole_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestIntelSinkholeList(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("user@example.com"), - ) - _, err := client.Intel.Sinkholes.List(context.TODO(), cloudflare.IntelSinkholeListParams{ - AccountID: cloudflare.F("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/intelwhois.go b/intelwhois.go deleted file mode 100644 index b73dc233f68..00000000000 --- a/intelwhois.go +++ /dev/null @@ -1,179 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// IntelWhoisService 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 [NewIntelWhoisService] method instead. -type IntelWhoisService struct { - Options []option.RequestOption -} - -// NewIntelWhoisService 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 NewIntelWhoisService(opts ...option.RequestOption) (r *IntelWhoisService) { - r = &IntelWhoisService{} - r.Options = opts - return -} - -// Get WHOIS Record -func (r *IntelWhoisService) Get(ctx context.Context, params IntelWhoisGetParams, opts ...option.RequestOption) (res *IntelWhoisGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env IntelWhoisGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/intel/whois", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type IntelWhoisGetResponse struct { - CreatedDate time.Time `json:"created_date" format:"date"` - Domain string `json:"domain"` - Nameservers []string `json:"nameservers"` - Registrant string `json:"registrant"` - RegistrantCountry string `json:"registrant_country"` - RegistrantEmail string `json:"registrant_email"` - RegistrantOrg string `json:"registrant_org"` - Registrar string `json:"registrar"` - UpdatedDate time.Time `json:"updated_date" format:"date"` - JSON intelWhoisGetResponseJSON `json:"-"` -} - -// intelWhoisGetResponseJSON contains the JSON metadata for the struct -// [IntelWhoisGetResponse] -type intelWhoisGetResponseJSON struct { - CreatedDate apijson.Field - Domain apijson.Field - Nameservers apijson.Field - Registrant apijson.Field - RegistrantCountry apijson.Field - RegistrantEmail apijson.Field - RegistrantOrg apijson.Field - Registrar apijson.Field - UpdatedDate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelWhoisGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelWhoisGetResponseJSON) RawJSON() string { - return r.raw -} - -type IntelWhoisGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Domain param.Field[string] `query:"domain"` -} - -// URLQuery serializes [IntelWhoisGetParams]'s query parameters as `url.Values`. -func (r IntelWhoisGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type IntelWhoisGetResponseEnvelope struct { - Errors []IntelWhoisGetResponseEnvelopeErrors `json:"errors,required"` - Messages []IntelWhoisGetResponseEnvelopeMessages `json:"messages,required"` - Result IntelWhoisGetResponse `json:"result,required"` - // Whether the API call was successful - Success IntelWhoisGetResponseEnvelopeSuccess `json:"success,required"` - JSON intelWhoisGetResponseEnvelopeJSON `json:"-"` -} - -// intelWhoisGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [IntelWhoisGetResponseEnvelope] -type intelWhoisGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelWhoisGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelWhoisGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IntelWhoisGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelWhoisGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// intelWhoisGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [IntelWhoisGetResponseEnvelopeErrors] -type intelWhoisGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelWhoisGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelWhoisGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IntelWhoisGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON intelWhoisGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// intelWhoisGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [IntelWhoisGetResponseEnvelopeMessages] -type intelWhoisGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IntelWhoisGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r intelWhoisGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type IntelWhoisGetResponseEnvelopeSuccess bool - -const ( - IntelWhoisGetResponseEnvelopeSuccessTrue IntelWhoisGetResponseEnvelopeSuccess = true -) diff --git a/intelwhois_test.go b/intelwhois_test.go deleted file mode 100644 index 27a9efe97b4..00000000000 --- a/intelwhois_test.go +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestIntelWhoisGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Intel.Whois.Get(context.TODO(), cloudflare.IntelWhoisGetParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Domain: cloudflare.F("string"), - }) - 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/internal/shared/union.go b/internal/shared/union.go index 05058cf3277..90eee425f62 100644 --- a/internal/shared/union.go +++ b/internal/shared/union.go @@ -4,320 +4,309 @@ package shared type UnionString string -func (UnionString) ImplementsAccountUpdateResponse() {} -func (UnionString) ImplementsAccountGetResponse() {} -func (UnionString) ImplementsAccountRoleGetResponse() {} -func (UnionString) ImplementsCertificateNewResponse() {} -func (UnionString) ImplementsCertificateGetResponse() {} -func (UnionString) ImplementsMembershipUpdateResponse() {} -func (UnionString) ImplementsMembershipGetResponse() {} -func (UnionString) ImplementsUserEditResponse() {} -func (UnionString) ImplementsUserGetResponse() {} -func (UnionString) ImplementsUserAuditLogListResponse() {} -func (UnionString) ImplementsUserBillingProfileGetResponse() {} -func (UnionString) ImplementsUserInviteEditResponse() {} -func (UnionString) ImplementsUserInviteGetResponse() {} -func (UnionString) ImplementsUserLoadBalancerPoolHealthResponse() {} -func (UnionString) ImplementsUserOrganizationGetResponse() {} -func (UnionString) ImplementsUserSubscriptionUpdateResponse() {} -func (UnionString) ImplementsUserSubscriptionEditResponse() {} -func (UnionString) ImplementsUserTokenUpdateResponse() {} -func (UnionString) ImplementsUserTokenGetResponse() {} -func (UnionString) ImplementsZoneCustomNameserverUpdateResponse() {} -func (UnionString) ImplementsZoneCustomNameserverGetResponse() {} -func (UnionString) ImplementsZoneWorkerScriptUpdateResponse() {} -func (UnionString) ImplementsZoneSubscriptionNewResponse() {} -func (UnionString) ImplementsZoneSubscriptionGetResponse() {} -func (UnionString) ImplementsLoadBalancerPoolHealthGetResponse() {} -func (UnionString) ImplementsLoadBalancerRegionListResponse() {} -func (UnionString) ImplementsLoadBalancerRegionGetResponse() {} -func (UnionString) ImplementsCachePurgeParamsFile() {} -func (UnionString) ImplementsCacheSmartTieredCachedDeleteResponse() {} -func (UnionString) ImplementsCacheSmartTieredCachedEditResponse() {} -func (UnionString) ImplementsCacheSmartTieredCachedGetResponse() {} -func (UnionString) ImplementsSSLAnalyzeNewResponse() {} -func (UnionString) ImplementsSSLCertificatePackGetResponse() {} -func (UnionString) ImplementsSubscriptionNewResponse() {} -func (UnionString) ImplementsSubscriptionUpdateResponse() {} -func (UnionString) ImplementsSubscriptionGetResponse() {} -func (UnionString) ImplementsArgoSmartRoutingEditResponse() {} -func (UnionString) ImplementsArgoSmartRoutingGetResponse() {} -func (UnionString) ImplementsArgoTieredCachingEditResponse() {} -func (UnionString) ImplementsArgoTieredCachingGetResponse() {} -func (UnionString) ImplementsCustomCertificateNewResponse() {} -func (UnionString) ImplementsCustomCertificateEditResponse() {} -func (UnionString) ImplementsCustomCertificateGetResponse() {} -func (UnionString) ImplementsCustomHostnameFallbackOriginUpdateResponse() {} -func (UnionString) ImplementsCustomHostnameFallbackOriginDeleteResponse() {} -func (UnionString) ImplementsCustomHostnameFallbackOriginGetResponse() {} -func (UnionString) ImplementsCustomNameserverDeleteResponse() {} -func (UnionString) ImplementsDNSFirewallNewResponseDNSFirewallIP() {} -func (UnionString) ImplementsDNSFirewallNewResponseUpstreamIP() {} -func (UnionString) ImplementsDNSFirewallListResponseDNSFirewallIP() {} -func (UnionString) ImplementsDNSFirewallListResponseUpstreamIP() {} -func (UnionString) ImplementsDNSFirewallEditResponseDNSFirewallIP() {} -func (UnionString) ImplementsDNSFirewallEditResponseUpstreamIP() {} -func (UnionString) ImplementsDNSFirewallGetResponseDNSFirewallIP() {} -func (UnionString) ImplementsDNSFirewallGetResponseUpstreamIP() {} -func (UnionString) ImplementsDNSFirewallNewParamsUpstreamIP() {} -func (UnionString) ImplementsDNSFirewallEditParamsDNSFirewallIP() {} -func (UnionString) ImplementsDNSFirewallEditParamsUpstreamIP() {} -func (UnionString) ImplementsDNSSECDeleteResponse() {} -func (UnionString) ImplementsFirewallAccessRuleNewResponse() {} -func (UnionString) ImplementsFirewallAccessRuleEditResponse() {} -func (UnionString) ImplementsFirewallAccessRuleGetResponse() {} -func (UnionString) ImplementsFirewallUARuleNewResponse() {} -func (UnionString) ImplementsFirewallUARuleUpdateResponse() {} -func (UnionString) ImplementsFirewallUARuleGetResponse() {} -func (UnionString) ImplementsFirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResult() {} -func (UnionString) ImplementsFirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleResult() {} -func (UnionString) ImplementsFirewallWAFPackageGroupEditResponse() {} -func (UnionString) ImplementsFirewallWAFPackageGroupGetResponse() {} -func (UnionString) ImplementsFirewallWAFPackageRuleGetResponse() {} -func (UnionString) ImplementsLogpushJobDeleteResponse() {} -func (UnionString) ImplementsLogControlCmbConfigDeleteResponse() {} -func (UnionString) ImplementsLogRayidGetResponse() {} -func (UnionString) ImplementsLogReceivedGetResponse() {} -func (UnionString) ImplementsLogReceivedGetParamsEnd() {} -func (UnionString) ImplementsLogReceivedGetParamsStart() {} -func (UnionString) ImplementsOriginTLSClientAuthNewResponse() {} -func (UnionString) ImplementsOriginTLSClientAuthDeleteResponse() {} -func (UnionString) ImplementsOriginTLSClientAuthGetResponse() {} -func (UnionString) ImplementsPageruleNewResponse() {} -func (UnionString) ImplementsPageruleUpdateResponse() {} -func (UnionString) ImplementsPageruleEditResponse() {} -func (UnionString) ImplementsPageruleGetResponse() {} -func (UnionString) ImplementsRateLimitNewResponse() {} -func (UnionString) ImplementsRateLimitEditResponse() {} -func (UnionString) ImplementsRateLimitGetResponse() {} -func (UnionString) ImplementsWorkerScriptTailDeleteResponse() {} -func (UnionString) ImplementsWorkerRouteNewResponse() {} -func (UnionString) ImplementsWorkerRouteDeleteResponse() {} -func (UnionString) ImplementsKVNamespaceUpdateResponse() {} -func (UnionString) ImplementsKVNamespaceDeleteResponse() {} -func (UnionString) ImplementsKVNamespaceBulkUpdateResponse() {} -func (UnionString) ImplementsKVNamespaceBulkDeleteResponse() {} -func (UnionString) ImplementsKVNamespaceValueUpdateResponse() {} -func (UnionString) ImplementsKVNamespaceValueDeleteResponse() {} -func (UnionString) ImplementsQueueDeleteResponse() {} -func (UnionString) ImplementsQueueConsumerDeleteResponse() {} -func (UnionString) ImplementsSpectrumAnalyticsEventBytimeGetResponse() {} -func (UnionString) ImplementsSpectrumAnalyticsEventSummaryGetResponse() {} -func (UnionString) ImplementsSpectrumAppNewResponseOriginPort() {} -func (UnionString) ImplementsSpectrumAppUpdateResponseOriginPort() {} -func (UnionString) ImplementsSpectrumAppGetResponse() {} -func (UnionString) ImplementsSpectrumAppNewParamsOriginPort() {} -func (UnionString) ImplementsSpectrumAppUpdateParamsOriginPort() {} -func (UnionString) ImplementsAddressingAddressMapDeleteResponse() {} -func (UnionString) ImplementsAddressingAddressMapAccountUpdateResponse() {} -func (UnionString) ImplementsAddressingAddressMapAccountDeleteResponse() {} -func (UnionString) ImplementsAddressingAddressMapIPUpdateResponse() {} -func (UnionString) ImplementsAddressingAddressMapIPDeleteResponse() {} -func (UnionString) ImplementsAddressingAddressMapZoneUpdateResponse() {} -func (UnionString) ImplementsAddressingAddressMapZoneDeleteResponse() {} -func (UnionString) ImplementsAddressingPrefixDeleteResponse() {} -func (UnionString) ImplementsAddressingPrefixBGPBindingDeleteResponse() {} -func (UnionString) ImplementsAuditLogListResponse() {} -func (UnionString) ImplementsBillingProfileGetResponse() {} -func (UnionString) ImplementsImageV1NewResponseVariant() {} -func (UnionString) ImplementsImageV1ListResponseResultImagesVariant() {} -func (UnionString) ImplementsImageV1DeleteResponse() {} -func (UnionString) ImplementsImageV1EditResponseVariant() {} -func (UnionString) ImplementsImageV1GetResponseVariant() {} -func (UnionString) ImplementsImageV1VariantDeleteResponse() {} -func (UnionString) ImplementsImageV2ListResponseImagesVariant() {} -func (UnionString) ImplementsIntelIPGetResponseIP() {} -func (UnionString) ImplementsIntelMiscategorizationNewResponse() {} -func (UnionString) ImplementsPageProjectNewResponse() {} -func (UnionString) ImplementsPageProjectEditResponse() {} -func (UnionString) ImplementsPageProjectDeploymentHistoryLogGetResponse() {} -func (UnionString) ImplementsPageProjectDomainNewResponse() {} -func (UnionString) ImplementsPageProjectDomainEditResponse() {} -func (UnionString) ImplementsPageProjectDomainGetResponse() {} -func (UnionString) ImplementsRegistrarDomainUpdateResponse() {} -func (UnionString) ImplementsRegistrarDomainGetResponse() {} -func (UnionString) ImplementsRuleListItemGetResponse() {} -func (UnionString) ImplementsStreamAudioTrackDeleteResponse() {} -func (UnionString) ImplementsStreamKeyDeleteResponse() {} -func (UnionString) ImplementsStreamWatermarkNewResponse() {} -func (UnionString) ImplementsStreamWatermarkDeleteResponse() {} -func (UnionString) ImplementsStreamWatermarkGetResponse() {} -func (UnionString) ImplementsStreamWebhookUpdateResponse() {} -func (UnionString) ImplementsStreamWebhookDeleteResponse() {} -func (UnionString) ImplementsStreamWebhookGetResponse() {} -func (UnionString) ImplementsStreamCaptionUpdateResponse() {} -func (UnionString) ImplementsStreamCaptionDeleteResponse() {} -func (UnionString) ImplementsStreamDownloadNewResponse() {} -func (UnionString) ImplementsStreamDownloadDeleteResponse() {} -func (UnionString) ImplementsStreamDownloadGetResponse() {} -func (UnionString) ImplementsAlertingV3ListResponse() {} -func (UnionString) ImplementsAlertingV3DestinationEligibleGetResponse() {} -func (UnionString) ImplementsAlertingV3DestinationPagerdutyDeleteResponse() {} -func (UnionString) ImplementsAlertingV3DestinationWebhookDeleteResponse() {} -func (UnionString) ImplementsAlertingV3PolicyListResponseMechanismsID() {} -func (UnionString) ImplementsAlertingV3PolicyDeleteResponse() {} -func (UnionString) ImplementsAlertingV3PolicyGetResponseMechanismsID() {} -func (UnionString) ImplementsAlertingV3PolicyNewParamsMechanismsID() {} -func (UnionString) ImplementsAlertingV3PolicyUpdateParamsMechanismsID() {} -func (UnionString) ImplementsD1DatabaseDeleteResponse() {} -func (UnionString) ImplementsWARPConnectorTokenResponse() {} -func (UnionString) ImplementsZeroTrustDeviceGetResponse() {} -func (UnionString) ImplementsZeroTrustDevicePostureIntegrationDeleteResponse() {} -func (UnionString) ImplementsZeroTrustDeviceRevokeNewResponse() {} -func (UnionString) ImplementsZeroTrustDeviceUnrevokeNewResponse() {} -func (UnionString) ImplementsZeroTrustAccessApplicationUpdateParamsAppID() {} -func (UnionString) ImplementsZeroTrustAccessApplicationDeleteParamsAppID() {} -func (UnionString) ImplementsZeroTrustAccessApplicationGetParamsAppID() {} -func (UnionString) ImplementsZeroTrustAccessApplicationRevokeTokensParamsAppID() {} -func (UnionString) ImplementsZeroTrustAccessApplicationCANewResponse() {} -func (UnionString) ImplementsZeroTrustAccessApplicationCAGetResponse() {} -func (UnionString) ImplementsZeroTrustAccessApplicationUserPolicyCheckListParamsAppID() {} -func (UnionString) ImplementsZeroTrustAccessKeyUpdateResponse() {} -func (UnionString) ImplementsZeroTrustAccessKeyListResponse() {} -func (UnionString) ImplementsZeroTrustAccessKeyRotateResponse() {} -func (UnionString) ImplementsZeroTrustTunnelConfigurationUpdateResponse() {} -func (UnionString) ImplementsZeroTrustTunnelConfigurationGetResponse() {} -func (UnionString) ImplementsZeroTrustTunnelConnectionDeleteResponse() {} -func (UnionString) ImplementsZeroTrustTunnelTokenGetResponse() {} -func (UnionString) ImplementsZeroTrustTunnelManagementNewResponse() {} -func (UnionString) ImplementsZeroTrustDLPProfileCustomDeleteResponse() {} -func (UnionString) ImplementsZeroTrustGatewayListDeleteResponse() {} -func (UnionString) ImplementsZeroTrustGatewayLocationDeleteResponse() {} -func (UnionString) ImplementsZeroTrustGatewayProxyEndpointDeleteResponse() {} -func (UnionString) ImplementsZeroTrustGatewayRuleDeleteResponse() {} -func (UnionString) ImplementsZeroTrustNetworkVirtualNetworkNewResponse() {} -func (UnionString) ImplementsZeroTrustNetworkVirtualNetworkDeleteResponse() {} -func (UnionString) ImplementsZeroTrustNetworkVirtualNetworkEditResponse() {} -func (UnionString) ImplementsHyperdriveConfigDeleteResponse() {} -func (UnionString) ImplementsVectorizeIndexDeleteResponse() {} -func (UnionString) ImplementsRadarRankingTimeseriesGroupsResponseSerie0() {} -func (UnionString) ImplementsOriginPostQuantumEncryptionUpdateResponse() {} -func (UnionString) ImplementsOriginPostQuantumEncryptionGetResponse() {} -func (UnionString) ImplementsHostnameSettingTLSUpdateResponseValue() {} -func (UnionString) ImplementsHostnameSettingTLSGetResponseValue() {} -func (UnionString) ImplementsHostnameSettingTLSUpdateParamsValue() {} -func (UnionString) ImplementsSnippetDeleteResponse() {} -func (UnionString) ImplementsCloudforceOneRequestDeleteResponse() {} -func (UnionString) ImplementsCloudforceOneRequestMessageDeleteResponse() {} -func (UnionString) ImplementsCloudforceOneRequestPriorityDeleteResponse() {} +func (UnionString) ImplementsAccountsAccountUpdateResponse() {} +func (UnionString) ImplementsAccountsAccountGetResponse() {} +func (UnionString) ImplementsAccountsRoleGetResponse() {} +func (UnionString) ImplementsCertificatesCertificateNewResponse() {} +func (UnionString) ImplementsCertificatesCertificateGetResponse() {} +func (UnionString) ImplementsMembershipsMembershipUpdateResponse() {} +func (UnionString) ImplementsMembershipsMembershipGetResponse() {} +func (UnionString) ImplementsUserUserEditResponse() {} +func (UnionString) ImplementsUserUserGetResponse() {} +func (UnionString) ImplementsUserAuditLogListResponse() {} +func (UnionString) ImplementsUserBillingProfileGetResponse() {} +func (UnionString) ImplementsUserInviteEditResponse() {} +func (UnionString) ImplementsUserInviteGetResponse() {} +func (UnionString) ImplementsUserLoadBalancerPoolHealthResponse() {} +func (UnionString) ImplementsUserOrganizationGetResponse() {} +func (UnionString) ImplementsUserSubscriptionUpdateResponse() {} +func (UnionString) ImplementsUserSubscriptionEditResponse() {} +func (UnionString) ImplementsUserTokenUpdateResponse() {} +func (UnionString) ImplementsUserTokenGetResponse() {} +func (UnionString) ImplementsZonesCustomNameserverUpdateResponse() {} +func (UnionString) ImplementsZonesCustomNameserverGetResponse() {} +func (UnionString) ImplementsZonesWorkerScriptUpdateResponse() {} +func (UnionString) ImplementsZonesSubscriptionNewResponse() {} +func (UnionString) ImplementsZonesSubscriptionGetResponse() {} +func (UnionString) ImplementsLoadBalancersPoolHealthGetResponse() {} +func (UnionString) ImplementsLoadBalancersRegionListResponse() {} +func (UnionString) ImplementsLoadBalancersRegionGetResponse() {} +func (UnionString) ImplementsCacheCachePurgeParamsFile() {} +func (UnionString) ImplementsCacheSmartTieredCachedDeleteResponse() {} +func (UnionString) ImplementsCacheSmartTieredCachedEditResponse() {} +func (UnionString) ImplementsCacheSmartTieredCachedGetResponse() {} +func (UnionString) ImplementsSSLAnalyzeNewResponse() {} +func (UnionString) ImplementsSSLCertificatePackGetResponse() {} +func (UnionString) ImplementsSubscriptionsSubscriptionNewResponse() {} +func (UnionString) ImplementsSubscriptionsSubscriptionUpdateResponse() {} +func (UnionString) ImplementsSubscriptionsSubscriptionGetResponse() {} +func (UnionString) ImplementsArgoSmartRoutingEditResponse() {} +func (UnionString) ImplementsArgoSmartRoutingGetResponse() {} +func (UnionString) ImplementsArgoTieredCachingEditResponse() {} +func (UnionString) ImplementsArgoTieredCachingGetResponse() {} +func (UnionString) ImplementsCustomCertificatesCustomCertificateNewResponse() {} +func (UnionString) ImplementsCustomCertificatesCustomCertificateEditResponse() {} +func (UnionString) ImplementsCustomCertificatesCustomCertificateGetResponse() {} +func (UnionString) ImplementsCustomHostnamesFallbackOriginUpdateResponse() {} +func (UnionString) ImplementsCustomHostnamesFallbackOriginDeleteResponse() {} +func (UnionString) ImplementsCustomHostnamesFallbackOriginGetResponse() {} +func (UnionString) ImplementsCustomNameserversCustomNameserverDeleteResponse() {} +func (UnionString) ImplementsDNSDNSFirewallDNSFirewallDNSFirewallIP() {} +func (UnionString) ImplementsDNSDNSFirewallDNSFirewallUpstreamIP() {} +func (UnionString) ImplementsDNSFirewallNewParamsUpstreamIP() {} +func (UnionString) ImplementsDNSFirewallEditParamsDNSFirewallIP() {} +func (UnionString) ImplementsDNSFirewallEditParamsUpstreamIP() {} +func (UnionString) ImplementsDNSSECDNSSECDeleteResponse() {} +func (UnionString) ImplementsFirewallAccessRuleNewResponse() {} +func (UnionString) ImplementsFirewallAccessRuleEditResponse() {} +func (UnionString) ImplementsFirewallAccessRuleGetResponse() {} +func (UnionString) ImplementsFirewallUARuleNewResponse() {} +func (UnionString) ImplementsFirewallUARuleUpdateResponse() {} +func (UnionString) ImplementsFirewallUARuleGetResponse() {} +func (UnionString) ImplementsFirewallWAFPackageListResponseLegacyJhsAPIResponseCollectionResult() {} +func (UnionString) ImplementsFirewallWAFPackageGetResponseLegacyJhsAPIResponseSingleResult() {} +func (UnionString) ImplementsFirewallWAFPackageGroupEditResponse() {} +func (UnionString) ImplementsFirewallWAFPackageGroupGetResponse() {} +func (UnionString) ImplementsFirewallWAFPackageRuleGetResponse() {} +func (UnionString) ImplementsLogpushJobDeleteResponse() {} +func (UnionString) ImplementsLogsControlCmbConfigDeleteResponse() {} +func (UnionString) ImplementsLogsRayidGetResponse() {} +func (UnionString) ImplementsLogsReceivedGetResponse() {} +func (UnionString) ImplementsLogsReceivedGetParamsEnd() {} +func (UnionString) ImplementsLogsReceivedGetParamsStart() {} +func (UnionString) ImplementsOriginTLSClientAuthOriginTLSClientAuthNewResponse() {} +func (UnionString) ImplementsOriginTLSClientAuthOriginTLSClientAuthDeleteResponse() {} +func (UnionString) ImplementsOriginTLSClientAuthOriginTLSClientAuthGetResponse() {} +func (UnionString) ImplementsPagerulesPageruleNewResponse() {} +func (UnionString) ImplementsPagerulesPageruleUpdateResponse() {} +func (UnionString) ImplementsPagerulesPageruleEditResponse() {} +func (UnionString) ImplementsPagerulesPageruleGetResponse() {} +func (UnionString) ImplementsRateLimitsRateLimitNewResponse() {} +func (UnionString) ImplementsRateLimitsRateLimitEditResponse() {} +func (UnionString) ImplementsRateLimitsRateLimitGetResponse() {} +func (UnionString) ImplementsWorkersScriptTailDeleteResponse() {} +func (UnionString) ImplementsWorkersRouteNewResponse() {} +func (UnionString) ImplementsWorkersRouteDeleteResponse() {} +func (UnionString) ImplementsKVNamespaceUpdateResponse() {} +func (UnionString) ImplementsKVNamespaceDeleteResponse() {} +func (UnionString) ImplementsKVNamespaceBulkUpdateResponse() {} +func (UnionString) ImplementsKVNamespaceBulkDeleteResponse() {} +func (UnionString) ImplementsKVNamespaceValueUpdateResponse() {} +func (UnionString) ImplementsKVNamespaceValueDeleteResponse() {} +func (UnionString) ImplementsQueuesQueueDeleteResponse() {} +func (UnionString) ImplementsQueuesConsumerDeleteResponse() {} +func (UnionString) ImplementsSpectrumAnalyticsEventBytimeGetResponse() {} +func (UnionString) ImplementsSpectrumAnalyticsEventSummaryGetResponse() {} +func (UnionString) ImplementsSpectrumAppNewResponseOriginPort() {} +func (UnionString) ImplementsSpectrumAppUpdateResponseOriginPort() {} +func (UnionString) ImplementsSpectrumAppGetResponse() {} +func (UnionString) ImplementsSpectrumAppNewParamsOriginPort() {} +func (UnionString) ImplementsSpectrumAppUpdateParamsOriginPort() {} +func (UnionString) ImplementsAddressingAddressMapDeleteResponse() {} +func (UnionString) ImplementsAddressingAddressMapAccountUpdateResponse() {} +func (UnionString) ImplementsAddressingAddressMapAccountDeleteResponse() {} +func (UnionString) ImplementsAddressingAddressMapIPUpdateResponse() {} +func (UnionString) ImplementsAddressingAddressMapIPDeleteResponse() {} +func (UnionString) ImplementsAddressingAddressMapZoneUpdateResponse() {} +func (UnionString) ImplementsAddressingAddressMapZoneDeleteResponse() {} +func (UnionString) ImplementsAddressingPrefixDeleteResponse() {} +func (UnionString) ImplementsAddressingPrefixBGPBindingDeleteResponse() {} +func (UnionString) ImplementsAuditLogsAuditLogListResponse() {} +func (UnionString) ImplementsBillingProfileGetResponse() {} +func (UnionString) ImplementsImagesImagesImageVariant() {} +func (UnionString) ImplementsImagesV1DeleteResponse() {} +func (UnionString) ImplementsImagesV1VariantDeleteResponse() {} +func (UnionString) ImplementsIntelIntelSchemasIpip() {} +func (UnionString) ImplementsIntelMiscategorizationNewResponse() {} +func (UnionString) ImplementsPagesProjectNewResponse() {} +func (UnionString) ImplementsPagesProjectEditResponse() {} +func (UnionString) ImplementsPagesProjectDeploymentHistoryLogGetResponse() {} +func (UnionString) ImplementsPagesProjectDomainNewResponse() {} +func (UnionString) ImplementsPagesProjectDomainEditResponse() {} +func (UnionString) ImplementsPagesProjectDomainGetResponse() {} +func (UnionString) ImplementsRegistrarDomainUpdateResponse() {} +func (UnionString) ImplementsRegistrarDomainGetResponse() {} +func (UnionString) ImplementsRulesListItemGetResponse() {} +func (UnionString) ImplementsStreamAudioTrackDeleteResponse() {} +func (UnionString) ImplementsStreamKeyDeleteResponse() {} +func (UnionString) ImplementsStreamWatermarkNewResponse() {} +func (UnionString) ImplementsStreamWatermarkDeleteResponse() {} +func (UnionString) ImplementsStreamWatermarkGetResponse() {} +func (UnionString) ImplementsStreamWebhookUpdateResponse() {} +func (UnionString) ImplementsStreamWebhookDeleteResponse() {} +func (UnionString) ImplementsStreamWebhookGetResponse() {} +func (UnionString) ImplementsStreamCaptionUpdateResponse() {} +func (UnionString) ImplementsStreamCaptionDeleteResponse() {} +func (UnionString) ImplementsStreamDownloadNewResponse() {} +func (UnionString) ImplementsStreamDownloadDeleteResponse() {} +func (UnionString) ImplementsStreamDownloadGetResponse() {} +func (UnionString) ImplementsAlertingV3ListResponse() {} +func (UnionString) ImplementsAlertingV3DestinationEligibleGetResponse() {} +func (UnionString) ImplementsAlertingV3DestinationPagerdutyDeleteResponse() {} +func (UnionString) ImplementsAlertingV3DestinationWebhookDeleteResponse() {} +func (UnionString) ImplementsAlertingAaaPoliciesMechanismsID() {} +func (UnionString) ImplementsAlertingV3PolicyDeleteResponse() {} +func (UnionString) ImplementsAlertingV3PolicyNewParamsMechanismsID() {} +func (UnionString) ImplementsAlertingV3PolicyUpdateParamsMechanismsID() {} +func (UnionString) ImplementsD1DatabaseDeleteResponse() {} +func (UnionString) ImplementsWARPConnectorWARPConnectorTokenResponse() {} +func (UnionString) ImplementsZeroTrustDeviceGetResponse() {} +func (UnionString) ImplementsZeroTrustDevicePostureIntegrationDeleteResponse() {} +func (UnionString) ImplementsZeroTrustDeviceRevokeNewResponse() {} +func (UnionString) ImplementsZeroTrustDeviceUnrevokeNewResponse() {} +func (UnionString) ImplementsZeroTrustAccessApplicationUpdateParamsAppID() {} +func (UnionString) ImplementsZeroTrustAccessApplicationDeleteParamsAppID() {} +func (UnionString) ImplementsZeroTrustAccessApplicationGetParamsAppID() {} +func (UnionString) ImplementsZeroTrustAccessApplicationRevokeTokensParamsAppID() {} +func (UnionString) ImplementsZeroTrustAccessApplicationCANewResponse() {} +func (UnionString) ImplementsZeroTrustAccessApplicationCAGetResponse() {} +func (UnionString) ImplementsZeroTrustAccessApplicationUserPolicyCheckListParamsAppID() {} +func (UnionString) ImplementsZeroTrustAccessKeyUpdateResponse() {} +func (UnionString) ImplementsZeroTrustAccessKeyListResponse() {} +func (UnionString) ImplementsZeroTrustAccessKeyRotateResponse() {} +func (UnionString) ImplementsZeroTrustTunnelConfigurationUpdateResponse() {} +func (UnionString) ImplementsZeroTrustTunnelConfigurationGetResponse() {} +func (UnionString) ImplementsZeroTrustTunnelConnectionDeleteResponse() {} +func (UnionString) ImplementsZeroTrustTunnelTokenGetResponse() {} +func (UnionString) ImplementsZeroTrustTunnelManagementNewResponse() {} +func (UnionString) ImplementsZeroTrustDLPProfileCustomDeleteResponse() {} +func (UnionString) ImplementsZeroTrustGatewayListDeleteResponse() {} +func (UnionString) ImplementsZeroTrustGatewayLocationDeleteResponse() {} +func (UnionString) ImplementsZeroTrustGatewayProxyEndpointDeleteResponse() {} +func (UnionString) ImplementsZeroTrustGatewayRuleDeleteResponse() {} +func (UnionString) ImplementsZeroTrustNetworkVirtualNetworkNewResponse() {} +func (UnionString) ImplementsZeroTrustNetworkVirtualNetworkDeleteResponse() {} +func (UnionString) ImplementsZeroTrustNetworkVirtualNetworkEditResponse() {} +func (UnionString) ImplementsHyperdriveConfigDeleteResponse() {} +func (UnionString) ImplementsVectorizeIndexDeleteResponse() {} +func (UnionString) ImplementsRadarRankingTimeseriesGroupsResponseSerie0() {} +func (UnionString) ImplementsOriginPostQuantumEncryptionOriginPostQuantumEncryptionUpdateResponse() {} +func (UnionString) ImplementsOriginPostQuantumEncryptionOriginPostQuantumEncryptionGetResponse() {} +func (UnionString) ImplementsHostnamesTLSCertificatesAndHostnamesSettingObjectValue() {} +func (UnionString) ImplementsHostnamesSettingTLSGetResponseValue() {} +func (UnionString) ImplementsHostnamesSettingTLSUpdateParamsValue() {} +func (UnionString) ImplementsSnippetsSnippetDeleteResponse() {} +func (UnionString) ImplementsCloudforceOneRequestDeleteResponse() {} +func (UnionString) ImplementsCloudforceOneRequestMessageDeleteResponse() {} +func (UnionString) ImplementsCloudforceOneRequestPriorityDeleteResponse() {} type UnionInt int64 -func (UnionInt) ImplementsLogReceivedGetParamsEnd() {} -func (UnionInt) ImplementsLogReceivedGetParamsStart() {} +func (UnionInt) ImplementsLogsReceivedGetParamsEnd() {} +func (UnionInt) ImplementsLogsReceivedGetParamsStart() {} func (UnionInt) ImplementsSpectrumAppNewResponseOriginPort() {} func (UnionInt) ImplementsSpectrumAppUpdateResponseOriginPort() {} func (UnionInt) ImplementsSpectrumAppNewParamsOriginPort() {} func (UnionInt) ImplementsSpectrumAppUpdateParamsOriginPort() {} -func (UnionInt) ImplementsRuleListItemGetResponse() {} +func (UnionInt) ImplementsRulesListItemGetResponse() {} type UnionFloat float64 -func (UnionFloat) ImplementsDNSRecordNewResponseAttl() {} -func (UnionFloat) ImplementsDNSRecordNewResponseAaaattl() {} -func (UnionFloat) ImplementsDNSRecordNewResponseCaattl() {} -func (UnionFloat) ImplementsDNSRecordNewResponseCertTTL() {} -func (UnionFloat) ImplementsDNSRecordNewResponseCnamettl() {} -func (UnionFloat) ImplementsDNSRecordNewResponseDnskeyttl() {} -func (UnionFloat) ImplementsDNSRecordNewResponseDsttl() {} -func (UnionFloat) ImplementsDNSRecordNewResponseHttpsttl() {} -func (UnionFloat) ImplementsDNSRecordNewResponseLocttl() {} -func (UnionFloat) ImplementsDNSRecordNewResponseMxttl() {} -func (UnionFloat) ImplementsDNSRecordNewResponseNaptrttl() {} -func (UnionFloat) ImplementsDNSRecordNewResponseNsttl() {} -func (UnionFloat) ImplementsDNSRecordNewResponsePtrttl() {} -func (UnionFloat) ImplementsDNSRecordNewResponseSmimeaTTL() {} -func (UnionFloat) ImplementsDNSRecordNewResponseSrvttl() {} -func (UnionFloat) ImplementsDNSRecordNewResponseSshfpttl() {} -func (UnionFloat) ImplementsDNSRecordNewResponseSvcbttl() {} -func (UnionFloat) ImplementsDNSRecordNewResponseTlsattl() {} -func (UnionFloat) ImplementsDNSRecordNewResponseTxtttl() {} -func (UnionFloat) ImplementsDNSRecordNewResponseUrittl() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseAttl() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseAaaattl() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseCaattl() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseCertTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseCnamettl() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseDnskeyttl() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseDsttl() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseHttpsttl() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseLocttl() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseMxttl() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseNaptrttl() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseNsttl() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponsePtrttl() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseSmimeaTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseSrvttl() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseSshfpttl() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseSvcbttl() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseTlsattl() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseTxtttl() {} -func (UnionFloat) ImplementsDNSRecordUpdateResponseUrittl() {} -func (UnionFloat) ImplementsDNSRecordListResponseAttl() {} -func (UnionFloat) ImplementsDNSRecordListResponseAaaattl() {} -func (UnionFloat) ImplementsDNSRecordListResponseCaattl() {} -func (UnionFloat) ImplementsDNSRecordListResponseCertTTL() {} -func (UnionFloat) ImplementsDNSRecordListResponseCnamettl() {} -func (UnionFloat) ImplementsDNSRecordListResponseDnskeyttl() {} -func (UnionFloat) ImplementsDNSRecordListResponseDsttl() {} -func (UnionFloat) ImplementsDNSRecordListResponseHttpsttl() {} -func (UnionFloat) ImplementsDNSRecordListResponseLocttl() {} -func (UnionFloat) ImplementsDNSRecordListResponseMxttl() {} -func (UnionFloat) ImplementsDNSRecordListResponseNaptrttl() {} -func (UnionFloat) ImplementsDNSRecordListResponseNsttl() {} -func (UnionFloat) ImplementsDNSRecordListResponsePtrttl() {} -func (UnionFloat) ImplementsDNSRecordListResponseSmimeaTTL() {} -func (UnionFloat) ImplementsDNSRecordListResponseSrvttl() {} -func (UnionFloat) ImplementsDNSRecordListResponseSshfpttl() {} -func (UnionFloat) ImplementsDNSRecordListResponseSvcbttl() {} -func (UnionFloat) ImplementsDNSRecordListResponseTlsattl() {} -func (UnionFloat) ImplementsDNSRecordListResponseTxtttl() {} -func (UnionFloat) ImplementsDNSRecordListResponseUrittl() {} -func (UnionFloat) ImplementsDNSRecordEditResponseAttl() {} -func (UnionFloat) ImplementsDNSRecordEditResponseAaaattl() {} -func (UnionFloat) ImplementsDNSRecordEditResponseCaattl() {} -func (UnionFloat) ImplementsDNSRecordEditResponseCertTTL() {} -func (UnionFloat) ImplementsDNSRecordEditResponseCnamettl() {} -func (UnionFloat) ImplementsDNSRecordEditResponseDnskeyttl() {} -func (UnionFloat) ImplementsDNSRecordEditResponseDsttl() {} -func (UnionFloat) ImplementsDNSRecordEditResponseHttpsttl() {} -func (UnionFloat) ImplementsDNSRecordEditResponseLocttl() {} -func (UnionFloat) ImplementsDNSRecordEditResponseMxttl() {} -func (UnionFloat) ImplementsDNSRecordEditResponseNaptrttl() {} -func (UnionFloat) ImplementsDNSRecordEditResponseNsttl() {} -func (UnionFloat) ImplementsDNSRecordEditResponsePtrttl() {} -func (UnionFloat) ImplementsDNSRecordEditResponseSmimeaTTL() {} -func (UnionFloat) ImplementsDNSRecordEditResponseSrvttl() {} -func (UnionFloat) ImplementsDNSRecordEditResponseSshfpttl() {} -func (UnionFloat) ImplementsDNSRecordEditResponseSvcbttl() {} -func (UnionFloat) ImplementsDNSRecordEditResponseTlsattl() {} -func (UnionFloat) ImplementsDNSRecordEditResponseTxtttl() {} -func (UnionFloat) ImplementsDNSRecordEditResponseUrittl() {} -func (UnionFloat) ImplementsDNSRecordGetResponseAttl() {} -func (UnionFloat) ImplementsDNSRecordGetResponseAaaattl() {} -func (UnionFloat) ImplementsDNSRecordGetResponseCaattl() {} -func (UnionFloat) ImplementsDNSRecordGetResponseCertTTL() {} -func (UnionFloat) ImplementsDNSRecordGetResponseCnamettl() {} -func (UnionFloat) ImplementsDNSRecordGetResponseDnskeyttl() {} -func (UnionFloat) ImplementsDNSRecordGetResponseDsttl() {} -func (UnionFloat) ImplementsDNSRecordGetResponseHttpsttl() {} -func (UnionFloat) ImplementsDNSRecordGetResponseLocttl() {} -func (UnionFloat) ImplementsDNSRecordGetResponseMxttl() {} -func (UnionFloat) ImplementsDNSRecordGetResponseNaptrttl() {} -func (UnionFloat) ImplementsDNSRecordGetResponseNsttl() {} -func (UnionFloat) ImplementsDNSRecordGetResponsePtrttl() {} -func (UnionFloat) ImplementsDNSRecordGetResponseSmimeaTTL() {} -func (UnionFloat) ImplementsDNSRecordGetResponseSrvttl() {} -func (UnionFloat) ImplementsDNSRecordGetResponseSshfpttl() {} -func (UnionFloat) ImplementsDNSRecordGetResponseSvcbttl() {} -func (UnionFloat) ImplementsDNSRecordGetResponseTlsattl() {} -func (UnionFloat) ImplementsDNSRecordGetResponseTxtttl() {} -func (UnionFloat) ImplementsDNSRecordGetResponseUrittl() {} -func (UnionFloat) ImplementsDNSRecordNewParamsTTL() {} -func (UnionFloat) ImplementsDNSRecordUpdateParamsTTL() {} -func (UnionFloat) ImplementsDNSRecordEditParamsTTL() {} -func (UnionFloat) ImplementsEmailRoutingRoutingDNSGetResponseTTL() {} -func (UnionFloat) ImplementsRadarRankingTimeseriesGroupsResponseSerie0() {} -func (UnionFloat) ImplementsHostnameSettingTLSUpdateResponseValue() {} -func (UnionFloat) ImplementsHostnameSettingTLSGetResponseValue() {} -func (UnionFloat) ImplementsHostnameSettingTLSUpdateParamsValue() {} +func (UnionFloat) ImplementsDNSRecordNewResponseAttl() {} +func (UnionFloat) ImplementsDNSRecordNewResponseAaaattl() {} +func (UnionFloat) ImplementsDNSRecordNewResponseCaattl() {} +func (UnionFloat) ImplementsDNSRecordNewResponseCertTTL() {} +func (UnionFloat) ImplementsDNSRecordNewResponseCnamettl() {} +func (UnionFloat) ImplementsDNSRecordNewResponseDnskeyttl() {} +func (UnionFloat) ImplementsDNSRecordNewResponseDsttl() {} +func (UnionFloat) ImplementsDNSRecordNewResponseHttpsttl() {} +func (UnionFloat) ImplementsDNSRecordNewResponseLocttl() {} +func (UnionFloat) ImplementsDNSRecordNewResponseMxttl() {} +func (UnionFloat) ImplementsDNSRecordNewResponseNaptrttl() {} +func (UnionFloat) ImplementsDNSRecordNewResponseNsttl() {} +func (UnionFloat) ImplementsDNSRecordNewResponsePtrttl() {} +func (UnionFloat) ImplementsDNSRecordNewResponseSmimeaTTL() {} +func (UnionFloat) ImplementsDNSRecordNewResponseSrvttl() {} +func (UnionFloat) ImplementsDNSRecordNewResponseSshfpttl() {} +func (UnionFloat) ImplementsDNSRecordNewResponseSvcbttl() {} +func (UnionFloat) ImplementsDNSRecordNewResponseTlsattl() {} +func (UnionFloat) ImplementsDNSRecordNewResponseTxtttl() {} +func (UnionFloat) ImplementsDNSRecordNewResponseUrittl() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseAttl() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseAaaattl() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseCaattl() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseCertTTL() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseCnamettl() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseDnskeyttl() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseDsttl() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseHttpsttl() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseLocttl() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseMxttl() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseNaptrttl() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseNsttl() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponsePtrttl() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseSmimeaTTL() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseSrvttl() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseSshfpttl() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseSvcbttl() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseTlsattl() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseTxtttl() {} +func (UnionFloat) ImplementsDNSRecordUpdateResponseUrittl() {} +func (UnionFloat) ImplementsDNSRecordListResponseAttl() {} +func (UnionFloat) ImplementsDNSRecordListResponseAaaattl() {} +func (UnionFloat) ImplementsDNSRecordListResponseCaattl() {} +func (UnionFloat) ImplementsDNSRecordListResponseCertTTL() {} +func (UnionFloat) ImplementsDNSRecordListResponseCnamettl() {} +func (UnionFloat) ImplementsDNSRecordListResponseDnskeyttl() {} +func (UnionFloat) ImplementsDNSRecordListResponseDsttl() {} +func (UnionFloat) ImplementsDNSRecordListResponseHttpsttl() {} +func (UnionFloat) ImplementsDNSRecordListResponseLocttl() {} +func (UnionFloat) ImplementsDNSRecordListResponseMxttl() {} +func (UnionFloat) ImplementsDNSRecordListResponseNaptrttl() {} +func (UnionFloat) ImplementsDNSRecordListResponseNsttl() {} +func (UnionFloat) ImplementsDNSRecordListResponsePtrttl() {} +func (UnionFloat) ImplementsDNSRecordListResponseSmimeaTTL() {} +func (UnionFloat) ImplementsDNSRecordListResponseSrvttl() {} +func (UnionFloat) ImplementsDNSRecordListResponseSshfpttl() {} +func (UnionFloat) ImplementsDNSRecordListResponseSvcbttl() {} +func (UnionFloat) ImplementsDNSRecordListResponseTlsattl() {} +func (UnionFloat) ImplementsDNSRecordListResponseTxtttl() {} +func (UnionFloat) ImplementsDNSRecordListResponseUrittl() {} +func (UnionFloat) ImplementsDNSRecordEditResponseAttl() {} +func (UnionFloat) ImplementsDNSRecordEditResponseAaaattl() {} +func (UnionFloat) ImplementsDNSRecordEditResponseCaattl() {} +func (UnionFloat) ImplementsDNSRecordEditResponseCertTTL() {} +func (UnionFloat) ImplementsDNSRecordEditResponseCnamettl() {} +func (UnionFloat) ImplementsDNSRecordEditResponseDnskeyttl() {} +func (UnionFloat) ImplementsDNSRecordEditResponseDsttl() {} +func (UnionFloat) ImplementsDNSRecordEditResponseHttpsttl() {} +func (UnionFloat) ImplementsDNSRecordEditResponseLocttl() {} +func (UnionFloat) ImplementsDNSRecordEditResponseMxttl() {} +func (UnionFloat) ImplementsDNSRecordEditResponseNaptrttl() {} +func (UnionFloat) ImplementsDNSRecordEditResponseNsttl() {} +func (UnionFloat) ImplementsDNSRecordEditResponsePtrttl() {} +func (UnionFloat) ImplementsDNSRecordEditResponseSmimeaTTL() {} +func (UnionFloat) ImplementsDNSRecordEditResponseSrvttl() {} +func (UnionFloat) ImplementsDNSRecordEditResponseSshfpttl() {} +func (UnionFloat) ImplementsDNSRecordEditResponseSvcbttl() {} +func (UnionFloat) ImplementsDNSRecordEditResponseTlsattl() {} +func (UnionFloat) ImplementsDNSRecordEditResponseTxtttl() {} +func (UnionFloat) ImplementsDNSRecordEditResponseUrittl() {} +func (UnionFloat) ImplementsDNSRecordGetResponseAttl() {} +func (UnionFloat) ImplementsDNSRecordGetResponseAaaattl() {} +func (UnionFloat) ImplementsDNSRecordGetResponseCaattl() {} +func (UnionFloat) ImplementsDNSRecordGetResponseCertTTL() {} +func (UnionFloat) ImplementsDNSRecordGetResponseCnamettl() {} +func (UnionFloat) ImplementsDNSRecordGetResponseDnskeyttl() {} +func (UnionFloat) ImplementsDNSRecordGetResponseDsttl() {} +func (UnionFloat) ImplementsDNSRecordGetResponseHttpsttl() {} +func (UnionFloat) ImplementsDNSRecordGetResponseLocttl() {} +func (UnionFloat) ImplementsDNSRecordGetResponseMxttl() {} +func (UnionFloat) ImplementsDNSRecordGetResponseNaptrttl() {} +func (UnionFloat) ImplementsDNSRecordGetResponseNsttl() {} +func (UnionFloat) ImplementsDNSRecordGetResponsePtrttl() {} +func (UnionFloat) ImplementsDNSRecordGetResponseSmimeaTTL() {} +func (UnionFloat) ImplementsDNSRecordGetResponseSrvttl() {} +func (UnionFloat) ImplementsDNSRecordGetResponseSshfpttl() {} +func (UnionFloat) ImplementsDNSRecordGetResponseSvcbttl() {} +func (UnionFloat) ImplementsDNSRecordGetResponseTlsattl() {} +func (UnionFloat) ImplementsDNSRecordGetResponseTxtttl() {} +func (UnionFloat) ImplementsDNSRecordGetResponseUrittl() {} +func (UnionFloat) ImplementsDNSRecordNewParamsTTL() {} +func (UnionFloat) ImplementsDNSRecordUpdateParamsTTL() {} +func (UnionFloat) ImplementsDNSRecordEditParamsTTL() {} +func (UnionFloat) ImplementsEmailRoutingEmailDNSRecordTTL() {} +func (UnionFloat) ImplementsRadarRankingTimeseriesGroupsResponseSerie0() {} +func (UnionFloat) ImplementsHostnamesTLSCertificatesAndHostnamesSettingObjectValue() {} +func (UnionFloat) ImplementsHostnamesSettingTLSGetResponseValue() {} +func (UnionFloat) ImplementsHostnamesSettingTLSUpdateParamsValue() {} diff --git a/internal/version.go b/internal/version.go index cd1452de975..13dfb6cd613 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "0.1.0" // x-release-please-version +const PackageVersion = "2.0.0-beta.1" // x-release-please-version diff --git a/ip.go b/ip.go deleted file mode 100644 index 20114cad120..00000000000 --- a/ip.go +++ /dev/null @@ -1,225 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// IPService 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 [NewIPService] method instead. -type IPService struct { - Options []option.RequestOption -} - -// NewIPService 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 NewIPService(opts ...option.RequestOption) (r *IPService) { - r = &IPService{} - r.Options = opts - return -} - -// Get IPs used on the Cloudflare/JD Cloud network, see -// https://www.cloudflare.com/ips for Cloudflare IPs or -// https://developers.cloudflare.com/china-network/reference/infrastructure/ for JD -// Cloud IPs. -func (r *IPService) List(ctx context.Context, query IPListParams, opts ...option.RequestOption) (res *IPListResponse, err error) { - opts = append(r.Options[:], opts...) - var env IPListResponseEnvelope - path := "ips" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type IPs struct { - // A digest of the IP data. Useful for determining if the data has changed. - Etag string `json:"etag"` - // List of Cloudflare IPv4 CIDR addresses. - IPV4Cidrs []string `json:"ipv4_cidrs"` - // List of Cloudflare IPv6 CIDR addresses. - IPV6Cidrs []string `json:"ipv6_cidrs"` - JSON ipsJSON `json:"-"` -} - -// ipsJSON contains the JSON metadata for the struct [IPs] -type ipsJSON struct { - Etag apijson.Field - IPV4Cidrs apijson.Field - IPV6Cidrs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipsJSON) RawJSON() string { - return r.raw -} - -func (r IPs) implementsIPListResponse() {} - -type JdcloudIPs struct { - // A digest of the IP data. Useful for determining if the data has changed. - Etag string `json:"etag"` - // List of Cloudflare IPv4 CIDR addresses. - IPV4Cidrs []string `json:"ipv4_cidrs"` - // List of Cloudflare IPv6 CIDR addresses. - IPV6Cidrs []string `json:"ipv6_cidrs"` - // List IPv4 and IPv6 CIDRs, only populated if `?networks=jdcloud` is used. - JdcloudCidrs []string `json:"jdcloud_cidrs"` - JSON jdcloudIPsJSON `json:"-"` -} - -// jdcloudIPsJSON contains the JSON metadata for the struct [JdcloudIPs] -type jdcloudIPsJSON struct { - Etag apijson.Field - IPV4Cidrs apijson.Field - IPV6Cidrs apijson.Field - JdcloudCidrs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *JdcloudIPs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r jdcloudIPsJSON) RawJSON() string { - return r.raw -} - -func (r JdcloudIPs) implementsIPListResponse() {} - -// Union satisfied by [IPs] or [JdcloudIPs]. -type IPListResponse interface { - implementsIPListResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*IPListResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(IPs{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(JdcloudIPs{}), - }, - ) -} - -type IPListParams struct { - // Specified as `jdcloud` to list IPs used by JD Cloud data centers. - Networks param.Field[string] `query:"networks"` -} - -// URLQuery serializes [IPListParams]'s query parameters as `url.Values`. -func (r IPListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type IPListResponseEnvelope struct { - Errors []IPListResponseEnvelopeErrors `json:"errors,required"` - Messages []IPListResponseEnvelopeMessages `json:"messages,required"` - Result IPListResponse `json:"result,required"` - // Whether the API call was successful - Success IPListResponseEnvelopeSuccess `json:"success,required"` - JSON ipListResponseEnvelopeJSON `json:"-"` -} - -// ipListResponseEnvelopeJSON contains the JSON metadata for the struct -// [IPListResponseEnvelope] -type ipListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type IPListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipListResponseEnvelopeErrorsJSON `json:"-"` -} - -// ipListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [IPListResponseEnvelopeErrors] -type ipListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type IPListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ipListResponseEnvelopeMessagesJSON `json:"-"` -} - -// ipListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [IPListResponseEnvelopeMessages] -type ipListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *IPListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ipListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type IPListResponseEnvelopeSuccess bool - -const ( - IPListResponseEnvelopeSuccessTrue IPListResponseEnvelopeSuccess = true -) diff --git a/ip_test.go b/ip_test.go deleted file mode 100644 index d200c7fbb47..00000000000 --- a/ip_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestIPListWithOptionalParams(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("user@example.com"), - ) - _, err := client.IPs.List(context.TODO(), cloudflare.IPListParams{ - Networks: cloudflare.F("string"), - }) - 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/ips/aliases.go b/ips/aliases.go new file mode 100644 index 00000000000..668d73037fc --- /dev/null +++ b/ips/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package ips + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/ips/ip.go b/ips/ip.go new file mode 100644 index 00000000000..9eb454f2458 --- /dev/null +++ b/ips/ip.go @@ -0,0 +1,225 @@ +// File generated from our OpenAPI spec by Stainless. + +package ips + +import ( + "context" + "net/http" + "net/url" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// IPService 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 [NewIPService] method instead. +type IPService struct { + Options []option.RequestOption +} + +// NewIPService 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 NewIPService(opts ...option.RequestOption) (r *IPService) { + r = &IPService{} + r.Options = opts + return +} + +// Get IPs used on the Cloudflare/JD Cloud network, see +// https://www.cloudflare.com/ips for Cloudflare IPs or +// https://developers.cloudflare.com/china-network/reference/infrastructure/ for JD +// Cloud IPs. +func (r *IPService) List(ctx context.Context, query IPListParams, opts ...option.RequestOption) (res *IPListResponse, err error) { + opts = append(r.Options[:], opts...) + var env IPListResponseEnvelope + path := "ips" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type IPs struct { + // A digest of the IP data. Useful for determining if the data has changed. + Etag string `json:"etag"` + // List of Cloudflare IPv4 CIDR addresses. + IPV4Cidrs []string `json:"ipv4_cidrs"` + // List of Cloudflare IPv6 CIDR addresses. + IPV6Cidrs []string `json:"ipv6_cidrs"` + JSON ipsJSON `json:"-"` +} + +// ipsJSON contains the JSON metadata for the struct [IPs] +type ipsJSON struct { + Etag apijson.Field + IPV4Cidrs apijson.Field + IPV6Cidrs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsJSON) RawJSON() string { + return r.raw +} + +func (r IPs) implementsIPsIPListResponse() {} + +type JdcloudIPs struct { + // A digest of the IP data. Useful for determining if the data has changed. + Etag string `json:"etag"` + // List of Cloudflare IPv4 CIDR addresses. + IPV4Cidrs []string `json:"ipv4_cidrs"` + // List of Cloudflare IPv6 CIDR addresses. + IPV6Cidrs []string `json:"ipv6_cidrs"` + // List IPv4 and IPv6 CIDRs, only populated if `?networks=jdcloud` is used. + JdcloudCidrs []string `json:"jdcloud_cidrs"` + JSON jdcloudIPsJSON `json:"-"` +} + +// jdcloudIPsJSON contains the JSON metadata for the struct [JdcloudIPs] +type jdcloudIPsJSON struct { + Etag apijson.Field + IPV4Cidrs apijson.Field + IPV6Cidrs apijson.Field + JdcloudCidrs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *JdcloudIPs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r jdcloudIPsJSON) RawJSON() string { + return r.raw +} + +func (r JdcloudIPs) implementsIPsIPListResponse() {} + +// Union satisfied by [ips.IPs] or [ips.JdcloudIPs]. +type IPListResponse interface { + implementsIPsIPListResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*IPListResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IPs{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(JdcloudIPs{}), + }, + ) +} + +type IPListParams struct { + // Specified as `jdcloud` to list IPs used by JD Cloud data centers. + Networks param.Field[string] `query:"networks"` +} + +// URLQuery serializes [IPListParams]'s query parameters as `url.Values`. +func (r IPListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type IPListResponseEnvelope struct { + Errors []IPListResponseEnvelopeErrors `json:"errors,required"` + Messages []IPListResponseEnvelopeMessages `json:"messages,required"` + Result IPListResponse `json:"result,required"` + // Whether the API call was successful + Success IPListResponseEnvelopeSuccess `json:"success,required"` + JSON ipListResponseEnvelopeJSON `json:"-"` +} + +// ipListResponseEnvelopeJSON contains the JSON metadata for the struct +// [IPListResponseEnvelope] +type ipListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IPListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ipListResponseEnvelopeErrorsJSON `json:"-"` +} + +// ipListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [IPListResponseEnvelopeErrors] +type ipListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IPListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ipListResponseEnvelopeMessagesJSON `json:"-"` +} + +// ipListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [IPListResponseEnvelopeMessages] +type ipListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IPListResponseEnvelopeSuccess bool + +const ( + IPListResponseEnvelopeSuccessTrue IPListResponseEnvelopeSuccess = true +) diff --git a/ips/ip_test.go b/ips/ip_test.go new file mode 100644 index 00000000000..8d96f7bfd36 --- /dev/null +++ b/ips/ip_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package ips_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/ips" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestIPListWithOptionalParams(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("user@example.com"), + ) + _, err := client.IPs.List(context.TODO(), ips.IPListParams{ + Networks: cloudflare.F("string"), + }) + 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/keyless_certificates/aliases.go b/keyless_certificates/aliases.go new file mode 100644 index 00000000000..417a7eea0ee --- /dev/null +++ b/keyless_certificates/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package keyless_certificates + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/keyless_certificates/keylesscertificate.go b/keyless_certificates/keylesscertificate.go new file mode 100644 index 00000000000..aaa39f6ed22 --- /dev/null +++ b/keyless_certificates/keylesscertificate.go @@ -0,0 +1,740 @@ +// File generated from our OpenAPI spec by Stainless. + +package keyless_certificates + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// KeylessCertificateService 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 [NewKeylessCertificateService] method +// instead. +type KeylessCertificateService struct { + Options []option.RequestOption +} + +// NewKeylessCertificateService 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 NewKeylessCertificateService(opts ...option.RequestOption) (r *KeylessCertificateService) { + r = &KeylessCertificateService{} + r.Options = opts + return +} + +// Create Keyless SSL Configuration +func (r *KeylessCertificateService) New(ctx context.Context, params KeylessCertificateNewParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesBase, err error) { + opts = append(r.Options[:], opts...) + var env KeylessCertificateNewResponseEnvelope + path := fmt.Sprintf("zones/%s/keyless_certificates", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List all Keyless SSL configurations for a given zone. +func (r *KeylessCertificateService) List(ctx context.Context, query KeylessCertificateListParams, opts ...option.RequestOption) (res *[]TLSCertificatesAndHostnamesBase, err error) { + opts = append(r.Options[:], opts...) + var env KeylessCertificateListResponseEnvelope + path := fmt.Sprintf("zones/%s/keyless_certificates", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete Keyless SSL Configuration +func (r *KeylessCertificateService) Delete(ctx context.Context, keylessCertificateID string, body KeylessCertificateDeleteParams, opts ...option.RequestOption) (res *KeylessCertificateDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env KeylessCertificateDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/keyless_certificates/%s", body.ZoneID, keylessCertificateID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// This will update attributes of a Keyless SSL. Consists of one or more of the +// following: host,name,port. +func (r *KeylessCertificateService) Edit(ctx context.Context, keylessCertificateID string, params KeylessCertificateEditParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesBase, err error) { + opts = append(r.Options[:], opts...) + var env KeylessCertificateEditResponseEnvelope + path := fmt.Sprintf("zones/%s/keyless_certificates/%s", params.ZoneID, keylessCertificateID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get details for one Keyless SSL configuration. +func (r *KeylessCertificateService) Get(ctx context.Context, keylessCertificateID string, query KeylessCertificateGetParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesBase, err error) { + opts = append(r.Options[:], opts...) + var env KeylessCertificateGetResponseEnvelope + path := fmt.Sprintf("zones/%s/keyless_certificates/%s", query.ZoneID, keylessCertificateID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TLSCertificatesAndHostnamesBase struct { + // Keyless certificate identifier tag. + ID string `json:"id,required"` + // When the Keyless SSL was created. + CreatedOn time.Time `json:"created_on,required" format:"date-time"` + // Whether or not the Keyless SSL is on or off. + Enabled bool `json:"enabled,required"` + // The keyless SSL name. + Host string `json:"host,required" format:"hostname"` + // When the Keyless SSL was last modified. + ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` + // The keyless SSL name. + Name string `json:"name,required"` + // Available permissions for the Keyless SSL for the current user requesting the + // item. + Permissions []interface{} `json:"permissions,required"` + // The keyless SSL port used to communicate between Cloudflare and the client's + // Keyless SSL server. + Port float64 `json:"port,required"` + // Status of the Keyless SSL. + Status TLSCertificatesAndHostnamesBaseStatus `json:"status,required"` + // Configuration for using Keyless SSL through a Cloudflare Tunnel + Tunnel TLSCertificatesAndHostnamesBaseTunnel `json:"tunnel"` + JSON tlsCertificatesAndHostnamesBaseJSON `json:"-"` +} + +// tlsCertificatesAndHostnamesBaseJSON contains the JSON metadata for the struct +// [TLSCertificatesAndHostnamesBase] +type tlsCertificatesAndHostnamesBaseJSON struct { + ID apijson.Field + CreatedOn apijson.Field + Enabled apijson.Field + Host apijson.Field + ModifiedOn apijson.Field + Name apijson.Field + Permissions apijson.Field + Port apijson.Field + Status apijson.Field + Tunnel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TLSCertificatesAndHostnamesBase) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tlsCertificatesAndHostnamesBaseJSON) RawJSON() string { + return r.raw +} + +// Status of the Keyless SSL. +type TLSCertificatesAndHostnamesBaseStatus string + +const ( + TLSCertificatesAndHostnamesBaseStatusActive TLSCertificatesAndHostnamesBaseStatus = "active" + TLSCertificatesAndHostnamesBaseStatusDeleted TLSCertificatesAndHostnamesBaseStatus = "deleted" +) + +// Configuration for using Keyless SSL through a Cloudflare Tunnel +type TLSCertificatesAndHostnamesBaseTunnel struct { + // Private IP of the Key Server Host + PrivateIP string `json:"private_ip,required"` + // Cloudflare Tunnel Virtual Network ID + VnetID string `json:"vnet_id,required"` + JSON tlsCertificatesAndHostnamesBaseTunnelJSON `json:"-"` +} + +// tlsCertificatesAndHostnamesBaseTunnelJSON contains the JSON metadata for the +// struct [TLSCertificatesAndHostnamesBaseTunnel] +type tlsCertificatesAndHostnamesBaseTunnelJSON struct { + PrivateIP apijson.Field + VnetID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TLSCertificatesAndHostnamesBaseTunnel) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tlsCertificatesAndHostnamesBaseTunnelJSON) RawJSON() string { + return r.raw +} + +type KeylessCertificateDeleteResponse struct { + // Identifier + ID string `json:"id"` + JSON keylessCertificateDeleteResponseJSON `json:"-"` +} + +// keylessCertificateDeleteResponseJSON contains the JSON metadata for the struct +// [KeylessCertificateDeleteResponse] +type keylessCertificateDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeylessCertificateDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keylessCertificateDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type KeylessCertificateNewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // The zone's SSL certificate or SSL certificate and intermediate(s). + Certificate param.Field[string] `json:"certificate,required"` + // The keyless SSL name. + Host param.Field[string] `json:"host,required" format:"hostname"` + // The keyless SSL port used to communicate between Cloudflare and the client's + // Keyless SSL server. + Port param.Field[float64] `json:"port,required"` + // A ubiquitous bundle has the highest probability of being verified everywhere, + // even by clients using outdated or unusual trust stores. An optimal bundle uses + // the shortest chain and newest intermediates. And the force bundle verifies the + // chain, but does not otherwise modify it. + BundleMethod param.Field[KeylessCertificateNewParamsBundleMethod] `json:"bundle_method"` + // The keyless SSL name. + Name param.Field[string] `json:"name"` + // Configuration for using Keyless SSL through a Cloudflare Tunnel + Tunnel param.Field[KeylessCertificateNewParamsTunnel] `json:"tunnel"` +} + +func (r KeylessCertificateNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A ubiquitous bundle has the highest probability of being verified everywhere, +// even by clients using outdated or unusual trust stores. An optimal bundle uses +// the shortest chain and newest intermediates. And the force bundle verifies the +// chain, but does not otherwise modify it. +type KeylessCertificateNewParamsBundleMethod string + +const ( + KeylessCertificateNewParamsBundleMethodUbiquitous KeylessCertificateNewParamsBundleMethod = "ubiquitous" + KeylessCertificateNewParamsBundleMethodOptimal KeylessCertificateNewParamsBundleMethod = "optimal" + KeylessCertificateNewParamsBundleMethodForce KeylessCertificateNewParamsBundleMethod = "force" +) + +// Configuration for using Keyless SSL through a Cloudflare Tunnel +type KeylessCertificateNewParamsTunnel struct { + // Private IP of the Key Server Host + PrivateIP param.Field[string] `json:"private_ip,required"` + // Cloudflare Tunnel Virtual Network ID + VnetID param.Field[string] `json:"vnet_id,required"` +} + +func (r KeylessCertificateNewParamsTunnel) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type KeylessCertificateNewResponseEnvelope struct { + Errors []KeylessCertificateNewResponseEnvelopeErrors `json:"errors,required"` + Messages []KeylessCertificateNewResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesBase `json:"result,required"` + // Whether the API call was successful + Success KeylessCertificateNewResponseEnvelopeSuccess `json:"success,required"` + JSON keylessCertificateNewResponseEnvelopeJSON `json:"-"` +} + +// keylessCertificateNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [KeylessCertificateNewResponseEnvelope] +type keylessCertificateNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeylessCertificateNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keylessCertificateNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type KeylessCertificateNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON keylessCertificateNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// keylessCertificateNewResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [KeylessCertificateNewResponseEnvelopeErrors] +type keylessCertificateNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeylessCertificateNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keylessCertificateNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type KeylessCertificateNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON keylessCertificateNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// keylessCertificateNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [KeylessCertificateNewResponseEnvelopeMessages] +type keylessCertificateNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeylessCertificateNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keylessCertificateNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type KeylessCertificateNewResponseEnvelopeSuccess bool + +const ( + KeylessCertificateNewResponseEnvelopeSuccessTrue KeylessCertificateNewResponseEnvelopeSuccess = true +) + +type KeylessCertificateListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type KeylessCertificateListResponseEnvelope struct { + Errors []KeylessCertificateListResponseEnvelopeErrors `json:"errors,required"` + Messages []KeylessCertificateListResponseEnvelopeMessages `json:"messages,required"` + Result []TLSCertificatesAndHostnamesBase `json:"result,required,nullable"` + // Whether the API call was successful + Success KeylessCertificateListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo KeylessCertificateListResponseEnvelopeResultInfo `json:"result_info"` + JSON keylessCertificateListResponseEnvelopeJSON `json:"-"` +} + +// keylessCertificateListResponseEnvelopeJSON contains the JSON metadata for the +// struct [KeylessCertificateListResponseEnvelope] +type keylessCertificateListResponseEnvelopeJSON 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 *KeylessCertificateListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keylessCertificateListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type KeylessCertificateListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON keylessCertificateListResponseEnvelopeErrorsJSON `json:"-"` +} + +// keylessCertificateListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [KeylessCertificateListResponseEnvelopeErrors] +type keylessCertificateListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeylessCertificateListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keylessCertificateListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type KeylessCertificateListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON keylessCertificateListResponseEnvelopeMessagesJSON `json:"-"` +} + +// keylessCertificateListResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [KeylessCertificateListResponseEnvelopeMessages] +type keylessCertificateListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeylessCertificateListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keylessCertificateListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type KeylessCertificateListResponseEnvelopeSuccess bool + +const ( + KeylessCertificateListResponseEnvelopeSuccessTrue KeylessCertificateListResponseEnvelopeSuccess = true +) + +type KeylessCertificateListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON keylessCertificateListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// keylessCertificateListResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [KeylessCertificateListResponseEnvelopeResultInfo] +type keylessCertificateListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeylessCertificateListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keylessCertificateListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type KeylessCertificateDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type KeylessCertificateDeleteResponseEnvelope struct { + Errors []KeylessCertificateDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []KeylessCertificateDeleteResponseEnvelopeMessages `json:"messages,required"` + Result KeylessCertificateDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success KeylessCertificateDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON keylessCertificateDeleteResponseEnvelopeJSON `json:"-"` +} + +// keylessCertificateDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [KeylessCertificateDeleteResponseEnvelope] +type keylessCertificateDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeylessCertificateDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keylessCertificateDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type KeylessCertificateDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON keylessCertificateDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// keylessCertificateDeleteResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [KeylessCertificateDeleteResponseEnvelopeErrors] +type keylessCertificateDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeylessCertificateDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keylessCertificateDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type KeylessCertificateDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON keylessCertificateDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// keylessCertificateDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [KeylessCertificateDeleteResponseEnvelopeMessages] +type keylessCertificateDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeylessCertificateDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keylessCertificateDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type KeylessCertificateDeleteResponseEnvelopeSuccess bool + +const ( + KeylessCertificateDeleteResponseEnvelopeSuccessTrue KeylessCertificateDeleteResponseEnvelopeSuccess = true +) + +type KeylessCertificateEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Whether or not the Keyless SSL is on or off. + Enabled param.Field[bool] `json:"enabled"` + // The keyless SSL name. + Host param.Field[string] `json:"host" format:"hostname"` + // The keyless SSL name. + Name param.Field[string] `json:"name"` + // The keyless SSL port used to communicate between Cloudflare and the client's + // Keyless SSL server. + Port param.Field[float64] `json:"port"` + // Configuration for using Keyless SSL through a Cloudflare Tunnel + Tunnel param.Field[KeylessCertificateEditParamsTunnel] `json:"tunnel"` +} + +func (r KeylessCertificateEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configuration for using Keyless SSL through a Cloudflare Tunnel +type KeylessCertificateEditParamsTunnel struct { + // Private IP of the Key Server Host + PrivateIP param.Field[string] `json:"private_ip,required"` + // Cloudflare Tunnel Virtual Network ID + VnetID param.Field[string] `json:"vnet_id,required"` +} + +func (r KeylessCertificateEditParamsTunnel) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type KeylessCertificateEditResponseEnvelope struct { + Errors []KeylessCertificateEditResponseEnvelopeErrors `json:"errors,required"` + Messages []KeylessCertificateEditResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesBase `json:"result,required"` + // Whether the API call was successful + Success KeylessCertificateEditResponseEnvelopeSuccess `json:"success,required"` + JSON keylessCertificateEditResponseEnvelopeJSON `json:"-"` +} + +// keylessCertificateEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [KeylessCertificateEditResponseEnvelope] +type keylessCertificateEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeylessCertificateEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keylessCertificateEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type KeylessCertificateEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON keylessCertificateEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// keylessCertificateEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [KeylessCertificateEditResponseEnvelopeErrors] +type keylessCertificateEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeylessCertificateEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keylessCertificateEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type KeylessCertificateEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON keylessCertificateEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// keylessCertificateEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [KeylessCertificateEditResponseEnvelopeMessages] +type keylessCertificateEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeylessCertificateEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keylessCertificateEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type KeylessCertificateEditResponseEnvelopeSuccess bool + +const ( + KeylessCertificateEditResponseEnvelopeSuccessTrue KeylessCertificateEditResponseEnvelopeSuccess = true +) + +type KeylessCertificateGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type KeylessCertificateGetResponseEnvelope struct { + Errors []KeylessCertificateGetResponseEnvelopeErrors `json:"errors,required"` + Messages []KeylessCertificateGetResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesBase `json:"result,required"` + // Whether the API call was successful + Success KeylessCertificateGetResponseEnvelopeSuccess `json:"success,required"` + JSON keylessCertificateGetResponseEnvelopeJSON `json:"-"` +} + +// keylessCertificateGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [KeylessCertificateGetResponseEnvelope] +type keylessCertificateGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeylessCertificateGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keylessCertificateGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type KeylessCertificateGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON keylessCertificateGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// keylessCertificateGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [KeylessCertificateGetResponseEnvelopeErrors] +type keylessCertificateGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeylessCertificateGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keylessCertificateGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type KeylessCertificateGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON keylessCertificateGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// keylessCertificateGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [KeylessCertificateGetResponseEnvelopeMessages] +type keylessCertificateGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeylessCertificateGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keylessCertificateGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type KeylessCertificateGetResponseEnvelopeSuccess bool + +const ( + KeylessCertificateGetResponseEnvelopeSuccessTrue KeylessCertificateGetResponseEnvelopeSuccess = true +) diff --git a/keylesscertificate_test.go b/keyless_certificates/keylesscertificate_test.go similarity index 89% rename from keylesscertificate_test.go rename to keyless_certificates/keylesscertificate_test.go index a1e9c891da2..f1627872031 100644 --- a/keylesscertificate_test.go +++ b/keyless_certificates/keylesscertificate_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package keyless_certificates_test import ( "context" @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/keyless_certificates" "github.com/cloudflare/cloudflare-go/option" ) @@ -27,14 +28,14 @@ func TestKeylessCertificateNewWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.KeylessCertificates.New(context.TODO(), cloudflare.KeylessCertificateNewParams{ + _, err := client.KeylessCertificates.New(context.TODO(), keyless_certificates.KeylessCertificateNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Certificate: cloudflare.F("-----BEGIN CERTIFICATE----- MIIDtTCCAp2gAwIBAgIJAM15n7fdxhRtMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV BAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX aWRnaXRzIFB0eSBMdGQwHhcNMTQwMzExMTkyMTU5WhcNMTQwNDEwMTkyMTU5WjBF MQswCQYDVQQGEwJVUzETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50 ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB CgKCAQEAvq3sKsHpeduJHimOK+fvQdKsI8z8A05MZyyLp2/R/GE8FjNv+hkVY1WQ LIyTNNQH7CJecE1nbTfo8Y56S7x/rhxC6/DJ8MIulapFPnorq46KU6yRxiM0MQ3N nTJHlHA2ozZta6YBBfVfhHWl1F0IfNbXCLKvGwWWMbCx43OfW6KTkbRnE6gFWKuO fSO5h2u5TaWVuSIzBvYs7Vza6m+gtYAvKAJV2nSZ+eSEFPDo29corOy8+huEOUL8 5FAw4BFPsr1TlrlGPFitduQUHGrSL7skk1ESGza0to3bOtrodKei2s9bk5MXm7lZ qI+WZJX4Zu9+mzZhc9pCVi8r/qlXuQIDAQABo4GnMIGkMB0GA1UdDgQWBBRvavf+ sWM4IwKiH9X9w1vl6nUVRDB1BgNVHSMEbjBsgBRvavf+sWM4IwKiH9X9w1vl6nUV RKFJpEcwRTELMAkGA1UEBhMCVVMxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNV BAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAM15n7fdxhRtMAwGA1UdEwQF MAMBAf8wDQYJKoZIhvcNAQEFBQADggEBABY2ZzBaW0dMsAAT7tPJzrVWVzQx6KU4 UEBLudIlWPlkAwTnINCWR/8eNjCCmGA4heUdHmazdpPa8RzwOmc0NT1NQqzSyktt vTqb4iHD7+8f9MqJ9/FssCfTtqr/Qst/hGH4Wmdf1EJ/6FqYAAb5iRlPgshFZxU8 uXtA8hWn6fK6eISD9HBdcAFToUvKNZ1BIDPvh9f95Ine8ar6yGd56TUNrHR8eHBs ESxz5ddVR/oWRysNJ+aGAyYqHS8S/ttmC7r4XCAHqXptkHPCGRqkAhsterYhd4I8 /cBzejUobNCjjHFbtkAL/SjxZOLW+pNkZwfeYdM8iPkD54Uua1v2tdw= -----END CERTIFICATE-----"), Host: cloudflare.F("example.com"), Port: cloudflare.F(24008.000000), - BundleMethod: cloudflare.F(cloudflare.KeylessCertificateNewParamsBundleMethodUbiquitous), + BundleMethod: cloudflare.F(keyless_certificates.KeylessCertificateNewParamsBundleMethodUbiquitous), Name: cloudflare.F("example.com Keyless SSL"), - Tunnel: cloudflare.F(cloudflare.KeylessCertificateNewParamsTunnel{ + Tunnel: cloudflare.F(keyless_certificates.KeylessCertificateNewParamsTunnel{ PrivateIP: cloudflare.F("10.0.0.1"), VnetID: cloudflare.F("7365377a-85a4-4390-9480-531ef7dc7a3c"), }), @@ -62,7 +63,7 @@ func TestKeylessCertificateList(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.KeylessCertificates.List(context.TODO(), cloudflare.KeylessCertificateListParams{ + _, err := client.KeylessCertificates.List(context.TODO(), keyless_certificates.KeylessCertificateListParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { @@ -91,7 +92,7 @@ func TestKeylessCertificateDelete(t *testing.T) { _, err := client.KeylessCertificates.Delete( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.KeylessCertificateDeleteParams{ + keyless_certificates.KeylessCertificateDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) @@ -121,13 +122,13 @@ func TestKeylessCertificateEditWithOptionalParams(t *testing.T) { _, err := client.KeylessCertificates.Edit( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.KeylessCertificateEditParams{ + keyless_certificates.KeylessCertificateEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Enabled: cloudflare.F(false), Host: cloudflare.F("example.com"), Name: cloudflare.F("example.com Keyless SSL"), Port: cloudflare.F(24008.000000), - Tunnel: cloudflare.F(cloudflare.KeylessCertificateEditParamsTunnel{ + Tunnel: cloudflare.F(keyless_certificates.KeylessCertificateEditParamsTunnel{ PrivateIP: cloudflare.F("10.0.0.1"), VnetID: cloudflare.F("7365377a-85a4-4390-9480-531ef7dc7a3c"), }), @@ -159,7 +160,7 @@ func TestKeylessCertificateGet(t *testing.T) { _, err := client.KeylessCertificates.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.KeylessCertificateGetParams{ + keyless_certificates.KeylessCertificateGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) diff --git a/keylesscertificate.go b/keylesscertificate.go deleted file mode 100644 index 1d1b8480db9..00000000000 --- a/keylesscertificate.go +++ /dev/null @@ -1,995 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// KeylessCertificateService 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 [NewKeylessCertificateService] method -// instead. -type KeylessCertificateService struct { - Options []option.RequestOption -} - -// NewKeylessCertificateService 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 NewKeylessCertificateService(opts ...option.RequestOption) (r *KeylessCertificateService) { - r = &KeylessCertificateService{} - r.Options = opts - return -} - -// Create Keyless SSL Configuration -func (r *KeylessCertificateService) New(ctx context.Context, params KeylessCertificateNewParams, opts ...option.RequestOption) (res *KeylessCertificateNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env KeylessCertificateNewResponseEnvelope - path := fmt.Sprintf("zones/%s/keyless_certificates", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List all Keyless SSL configurations for a given zone. -func (r *KeylessCertificateService) List(ctx context.Context, query KeylessCertificateListParams, opts ...option.RequestOption) (res *[]KeylessCertificateListResponse, err error) { - opts = append(r.Options[:], opts...) - var env KeylessCertificateListResponseEnvelope - path := fmt.Sprintf("zones/%s/keyless_certificates", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete Keyless SSL Configuration -func (r *KeylessCertificateService) Delete(ctx context.Context, keylessCertificateID string, body KeylessCertificateDeleteParams, opts ...option.RequestOption) (res *KeylessCertificateDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env KeylessCertificateDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/keyless_certificates/%s", body.ZoneID, keylessCertificateID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// This will update attributes of a Keyless SSL. Consists of one or more of the -// following: host,name,port. -func (r *KeylessCertificateService) Edit(ctx context.Context, keylessCertificateID string, params KeylessCertificateEditParams, opts ...option.RequestOption) (res *KeylessCertificateEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env KeylessCertificateEditResponseEnvelope - path := fmt.Sprintf("zones/%s/keyless_certificates/%s", params.ZoneID, keylessCertificateID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get details for one Keyless SSL configuration. -func (r *KeylessCertificateService) Get(ctx context.Context, keylessCertificateID string, query KeylessCertificateGetParams, opts ...option.RequestOption) (res *KeylessCertificateGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env KeylessCertificateGetResponseEnvelope - path := fmt.Sprintf("zones/%s/keyless_certificates/%s", query.ZoneID, keylessCertificateID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type KeylessCertificateNewResponse struct { - // Keyless certificate identifier tag. - ID string `json:"id,required"` - // When the Keyless SSL was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - // Whether or not the Keyless SSL is on or off. - Enabled bool `json:"enabled,required"` - // The keyless SSL name. - Host string `json:"host,required" format:"hostname"` - // When the Keyless SSL was last modified. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // The keyless SSL name. - Name string `json:"name,required"` - // Available permissions for the Keyless SSL for the current user requesting the - // item. - Permissions []interface{} `json:"permissions,required"` - // The keyless SSL port used to communicate between Cloudflare and the client's - // Keyless SSL server. - Port float64 `json:"port,required"` - // Status of the Keyless SSL. - Status KeylessCertificateNewResponseStatus `json:"status,required"` - // Configuration for using Keyless SSL through a Cloudflare Tunnel - Tunnel KeylessCertificateNewResponseTunnel `json:"tunnel"` - JSON keylessCertificateNewResponseJSON `json:"-"` -} - -// keylessCertificateNewResponseJSON contains the JSON metadata for the struct -// [KeylessCertificateNewResponse] -type keylessCertificateNewResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Enabled apijson.Field - Host apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Permissions apijson.Field - Port apijson.Field - Status apijson.Field - Tunnel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateNewResponseJSON) RawJSON() string { - return r.raw -} - -// Status of the Keyless SSL. -type KeylessCertificateNewResponseStatus string - -const ( - KeylessCertificateNewResponseStatusActive KeylessCertificateNewResponseStatus = "active" - KeylessCertificateNewResponseStatusDeleted KeylessCertificateNewResponseStatus = "deleted" -) - -// Configuration for using Keyless SSL through a Cloudflare Tunnel -type KeylessCertificateNewResponseTunnel struct { - // Private IP of the Key Server Host - PrivateIP string `json:"private_ip,required"` - // Cloudflare Tunnel Virtual Network ID - VnetID string `json:"vnet_id,required"` - JSON keylessCertificateNewResponseTunnelJSON `json:"-"` -} - -// keylessCertificateNewResponseTunnelJSON contains the JSON metadata for the -// struct [KeylessCertificateNewResponseTunnel] -type keylessCertificateNewResponseTunnelJSON struct { - PrivateIP apijson.Field - VnetID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateNewResponseTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateNewResponseTunnelJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateListResponse struct { - // Keyless certificate identifier tag. - ID string `json:"id,required"` - // When the Keyless SSL was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - // Whether or not the Keyless SSL is on or off. - Enabled bool `json:"enabled,required"` - // The keyless SSL name. - Host string `json:"host,required" format:"hostname"` - // When the Keyless SSL was last modified. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // The keyless SSL name. - Name string `json:"name,required"` - // Available permissions for the Keyless SSL for the current user requesting the - // item. - Permissions []interface{} `json:"permissions,required"` - // The keyless SSL port used to communicate between Cloudflare and the client's - // Keyless SSL server. - Port float64 `json:"port,required"` - // Status of the Keyless SSL. - Status KeylessCertificateListResponseStatus `json:"status,required"` - // Configuration for using Keyless SSL through a Cloudflare Tunnel - Tunnel KeylessCertificateListResponseTunnel `json:"tunnel"` - JSON keylessCertificateListResponseJSON `json:"-"` -} - -// keylessCertificateListResponseJSON contains the JSON metadata for the struct -// [KeylessCertificateListResponse] -type keylessCertificateListResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Enabled apijson.Field - Host apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Permissions apijson.Field - Port apijson.Field - Status apijson.Field - Tunnel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateListResponseJSON) RawJSON() string { - return r.raw -} - -// Status of the Keyless SSL. -type KeylessCertificateListResponseStatus string - -const ( - KeylessCertificateListResponseStatusActive KeylessCertificateListResponseStatus = "active" - KeylessCertificateListResponseStatusDeleted KeylessCertificateListResponseStatus = "deleted" -) - -// Configuration for using Keyless SSL through a Cloudflare Tunnel -type KeylessCertificateListResponseTunnel struct { - // Private IP of the Key Server Host - PrivateIP string `json:"private_ip,required"` - // Cloudflare Tunnel Virtual Network ID - VnetID string `json:"vnet_id,required"` - JSON keylessCertificateListResponseTunnelJSON `json:"-"` -} - -// keylessCertificateListResponseTunnelJSON contains the JSON metadata for the -// struct [KeylessCertificateListResponseTunnel] -type keylessCertificateListResponseTunnelJSON struct { - PrivateIP apijson.Field - VnetID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateListResponseTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateListResponseTunnelJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateDeleteResponse struct { - // Identifier - ID string `json:"id"` - JSON keylessCertificateDeleteResponseJSON `json:"-"` -} - -// keylessCertificateDeleteResponseJSON contains the JSON metadata for the struct -// [KeylessCertificateDeleteResponse] -type keylessCertificateDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateEditResponse struct { - // Keyless certificate identifier tag. - ID string `json:"id,required"` - // When the Keyless SSL was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - // Whether or not the Keyless SSL is on or off. - Enabled bool `json:"enabled,required"` - // The keyless SSL name. - Host string `json:"host,required" format:"hostname"` - // When the Keyless SSL was last modified. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // The keyless SSL name. - Name string `json:"name,required"` - // Available permissions for the Keyless SSL for the current user requesting the - // item. - Permissions []interface{} `json:"permissions,required"` - // The keyless SSL port used to communicate between Cloudflare and the client's - // Keyless SSL server. - Port float64 `json:"port,required"` - // Status of the Keyless SSL. - Status KeylessCertificateEditResponseStatus `json:"status,required"` - // Configuration for using Keyless SSL through a Cloudflare Tunnel - Tunnel KeylessCertificateEditResponseTunnel `json:"tunnel"` - JSON keylessCertificateEditResponseJSON `json:"-"` -} - -// keylessCertificateEditResponseJSON contains the JSON metadata for the struct -// [KeylessCertificateEditResponse] -type keylessCertificateEditResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Enabled apijson.Field - Host apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Permissions apijson.Field - Port apijson.Field - Status apijson.Field - Tunnel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateEditResponseJSON) RawJSON() string { - return r.raw -} - -// Status of the Keyless SSL. -type KeylessCertificateEditResponseStatus string - -const ( - KeylessCertificateEditResponseStatusActive KeylessCertificateEditResponseStatus = "active" - KeylessCertificateEditResponseStatusDeleted KeylessCertificateEditResponseStatus = "deleted" -) - -// Configuration for using Keyless SSL through a Cloudflare Tunnel -type KeylessCertificateEditResponseTunnel struct { - // Private IP of the Key Server Host - PrivateIP string `json:"private_ip,required"` - // Cloudflare Tunnel Virtual Network ID - VnetID string `json:"vnet_id,required"` - JSON keylessCertificateEditResponseTunnelJSON `json:"-"` -} - -// keylessCertificateEditResponseTunnelJSON contains the JSON metadata for the -// struct [KeylessCertificateEditResponseTunnel] -type keylessCertificateEditResponseTunnelJSON struct { - PrivateIP apijson.Field - VnetID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateEditResponseTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateEditResponseTunnelJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateGetResponse struct { - // Keyless certificate identifier tag. - ID string `json:"id,required"` - // When the Keyless SSL was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - // Whether or not the Keyless SSL is on or off. - Enabled bool `json:"enabled,required"` - // The keyless SSL name. - Host string `json:"host,required" format:"hostname"` - // When the Keyless SSL was last modified. - ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` - // The keyless SSL name. - Name string `json:"name,required"` - // Available permissions for the Keyless SSL for the current user requesting the - // item. - Permissions []interface{} `json:"permissions,required"` - // The keyless SSL port used to communicate between Cloudflare and the client's - // Keyless SSL server. - Port float64 `json:"port,required"` - // Status of the Keyless SSL. - Status KeylessCertificateGetResponseStatus `json:"status,required"` - // Configuration for using Keyless SSL through a Cloudflare Tunnel - Tunnel KeylessCertificateGetResponseTunnel `json:"tunnel"` - JSON keylessCertificateGetResponseJSON `json:"-"` -} - -// keylessCertificateGetResponseJSON contains the JSON metadata for the struct -// [KeylessCertificateGetResponse] -type keylessCertificateGetResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Enabled apijson.Field - Host apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Permissions apijson.Field - Port apijson.Field - Status apijson.Field - Tunnel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateGetResponseJSON) RawJSON() string { - return r.raw -} - -// Status of the Keyless SSL. -type KeylessCertificateGetResponseStatus string - -const ( - KeylessCertificateGetResponseStatusActive KeylessCertificateGetResponseStatus = "active" - KeylessCertificateGetResponseStatusDeleted KeylessCertificateGetResponseStatus = "deleted" -) - -// Configuration for using Keyless SSL through a Cloudflare Tunnel -type KeylessCertificateGetResponseTunnel struct { - // Private IP of the Key Server Host - PrivateIP string `json:"private_ip,required"` - // Cloudflare Tunnel Virtual Network ID - VnetID string `json:"vnet_id,required"` - JSON keylessCertificateGetResponseTunnelJSON `json:"-"` -} - -// keylessCertificateGetResponseTunnelJSON contains the JSON metadata for the -// struct [KeylessCertificateGetResponseTunnel] -type keylessCertificateGetResponseTunnelJSON struct { - PrivateIP apijson.Field - VnetID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateGetResponseTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateGetResponseTunnelJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateNewParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // The zone's SSL certificate or SSL certificate and intermediate(s). - Certificate param.Field[string] `json:"certificate,required"` - // The keyless SSL name. - Host param.Field[string] `json:"host,required" format:"hostname"` - // The keyless SSL port used to communicate between Cloudflare and the client's - // Keyless SSL server. - Port param.Field[float64] `json:"port,required"` - // A ubiquitous bundle has the highest probability of being verified everywhere, - // even by clients using outdated or unusual trust stores. An optimal bundle uses - // the shortest chain and newest intermediates. And the force bundle verifies the - // chain, but does not otherwise modify it. - BundleMethod param.Field[KeylessCertificateNewParamsBundleMethod] `json:"bundle_method"` - // The keyless SSL name. - Name param.Field[string] `json:"name"` - // Configuration for using Keyless SSL through a Cloudflare Tunnel - Tunnel param.Field[KeylessCertificateNewParamsTunnel] `json:"tunnel"` -} - -func (r KeylessCertificateNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A ubiquitous bundle has the highest probability of being verified everywhere, -// even by clients using outdated or unusual trust stores. An optimal bundle uses -// the shortest chain and newest intermediates. And the force bundle verifies the -// chain, but does not otherwise modify it. -type KeylessCertificateNewParamsBundleMethod string - -const ( - KeylessCertificateNewParamsBundleMethodUbiquitous KeylessCertificateNewParamsBundleMethod = "ubiquitous" - KeylessCertificateNewParamsBundleMethodOptimal KeylessCertificateNewParamsBundleMethod = "optimal" - KeylessCertificateNewParamsBundleMethodForce KeylessCertificateNewParamsBundleMethod = "force" -) - -// Configuration for using Keyless SSL through a Cloudflare Tunnel -type KeylessCertificateNewParamsTunnel struct { - // Private IP of the Key Server Host - PrivateIP param.Field[string] `json:"private_ip,required"` - // Cloudflare Tunnel Virtual Network ID - VnetID param.Field[string] `json:"vnet_id,required"` -} - -func (r KeylessCertificateNewParamsTunnel) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type KeylessCertificateNewResponseEnvelope struct { - Errors []KeylessCertificateNewResponseEnvelopeErrors `json:"errors,required"` - Messages []KeylessCertificateNewResponseEnvelopeMessages `json:"messages,required"` - Result KeylessCertificateNewResponse `json:"result,required"` - // Whether the API call was successful - Success KeylessCertificateNewResponseEnvelopeSuccess `json:"success,required"` - JSON keylessCertificateNewResponseEnvelopeJSON `json:"-"` -} - -// keylessCertificateNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [KeylessCertificateNewResponseEnvelope] -type keylessCertificateNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keylessCertificateNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// keylessCertificateNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [KeylessCertificateNewResponseEnvelopeErrors] -type keylessCertificateNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keylessCertificateNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// keylessCertificateNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [KeylessCertificateNewResponseEnvelopeMessages] -type keylessCertificateNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type KeylessCertificateNewResponseEnvelopeSuccess bool - -const ( - KeylessCertificateNewResponseEnvelopeSuccessTrue KeylessCertificateNewResponseEnvelopeSuccess = true -) - -type KeylessCertificateListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type KeylessCertificateListResponseEnvelope struct { - Errors []KeylessCertificateListResponseEnvelopeErrors `json:"errors,required"` - Messages []KeylessCertificateListResponseEnvelopeMessages `json:"messages,required"` - Result []KeylessCertificateListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success KeylessCertificateListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo KeylessCertificateListResponseEnvelopeResultInfo `json:"result_info"` - JSON keylessCertificateListResponseEnvelopeJSON `json:"-"` -} - -// keylessCertificateListResponseEnvelopeJSON contains the JSON metadata for the -// struct [KeylessCertificateListResponseEnvelope] -type keylessCertificateListResponseEnvelopeJSON 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 *KeylessCertificateListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keylessCertificateListResponseEnvelopeErrorsJSON `json:"-"` -} - -// keylessCertificateListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [KeylessCertificateListResponseEnvelopeErrors] -type keylessCertificateListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keylessCertificateListResponseEnvelopeMessagesJSON `json:"-"` -} - -// keylessCertificateListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [KeylessCertificateListResponseEnvelopeMessages] -type keylessCertificateListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type KeylessCertificateListResponseEnvelopeSuccess bool - -const ( - KeylessCertificateListResponseEnvelopeSuccessTrue KeylessCertificateListResponseEnvelopeSuccess = true -) - -type KeylessCertificateListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON keylessCertificateListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// keylessCertificateListResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [KeylessCertificateListResponseEnvelopeResultInfo] -type keylessCertificateListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type KeylessCertificateDeleteResponseEnvelope struct { - Errors []KeylessCertificateDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []KeylessCertificateDeleteResponseEnvelopeMessages `json:"messages,required"` - Result KeylessCertificateDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success KeylessCertificateDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON keylessCertificateDeleteResponseEnvelopeJSON `json:"-"` -} - -// keylessCertificateDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [KeylessCertificateDeleteResponseEnvelope] -type keylessCertificateDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keylessCertificateDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// keylessCertificateDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [KeylessCertificateDeleteResponseEnvelopeErrors] -type keylessCertificateDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keylessCertificateDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// keylessCertificateDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [KeylessCertificateDeleteResponseEnvelopeMessages] -type keylessCertificateDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type KeylessCertificateDeleteResponseEnvelopeSuccess bool - -const ( - KeylessCertificateDeleteResponseEnvelopeSuccessTrue KeylessCertificateDeleteResponseEnvelopeSuccess = true -) - -type KeylessCertificateEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Whether or not the Keyless SSL is on or off. - Enabled param.Field[bool] `json:"enabled"` - // The keyless SSL name. - Host param.Field[string] `json:"host" format:"hostname"` - // The keyless SSL name. - Name param.Field[string] `json:"name"` - // The keyless SSL port used to communicate between Cloudflare and the client's - // Keyless SSL server. - Port param.Field[float64] `json:"port"` - // Configuration for using Keyless SSL through a Cloudflare Tunnel - Tunnel param.Field[KeylessCertificateEditParamsTunnel] `json:"tunnel"` -} - -func (r KeylessCertificateEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configuration for using Keyless SSL through a Cloudflare Tunnel -type KeylessCertificateEditParamsTunnel struct { - // Private IP of the Key Server Host - PrivateIP param.Field[string] `json:"private_ip,required"` - // Cloudflare Tunnel Virtual Network ID - VnetID param.Field[string] `json:"vnet_id,required"` -} - -func (r KeylessCertificateEditParamsTunnel) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type KeylessCertificateEditResponseEnvelope struct { - Errors []KeylessCertificateEditResponseEnvelopeErrors `json:"errors,required"` - Messages []KeylessCertificateEditResponseEnvelopeMessages `json:"messages,required"` - Result KeylessCertificateEditResponse `json:"result,required"` - // Whether the API call was successful - Success KeylessCertificateEditResponseEnvelopeSuccess `json:"success,required"` - JSON keylessCertificateEditResponseEnvelopeJSON `json:"-"` -} - -// keylessCertificateEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [KeylessCertificateEditResponseEnvelope] -type keylessCertificateEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keylessCertificateEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// keylessCertificateEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [KeylessCertificateEditResponseEnvelopeErrors] -type keylessCertificateEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keylessCertificateEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// keylessCertificateEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [KeylessCertificateEditResponseEnvelopeMessages] -type keylessCertificateEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type KeylessCertificateEditResponseEnvelopeSuccess bool - -const ( - KeylessCertificateEditResponseEnvelopeSuccessTrue KeylessCertificateEditResponseEnvelopeSuccess = true -) - -type KeylessCertificateGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type KeylessCertificateGetResponseEnvelope struct { - Errors []KeylessCertificateGetResponseEnvelopeErrors `json:"errors,required"` - Messages []KeylessCertificateGetResponseEnvelopeMessages `json:"messages,required"` - Result KeylessCertificateGetResponse `json:"result,required"` - // Whether the API call was successful - Success KeylessCertificateGetResponseEnvelopeSuccess `json:"success,required"` - JSON keylessCertificateGetResponseEnvelopeJSON `json:"-"` -} - -// keylessCertificateGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [KeylessCertificateGetResponseEnvelope] -type keylessCertificateGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keylessCertificateGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// keylessCertificateGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [KeylessCertificateGetResponseEnvelopeErrors] -type keylessCertificateGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KeylessCertificateGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON keylessCertificateGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// keylessCertificateGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [KeylessCertificateGetResponseEnvelopeMessages] -type keylessCertificateGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KeylessCertificateGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r keylessCertificateGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type KeylessCertificateGetResponseEnvelopeSuccess bool - -const ( - KeylessCertificateGetResponseEnvelopeSuccessTrue KeylessCertificateGetResponseEnvelopeSuccess = true -) diff --git a/kv/aliases.go b/kv/aliases.go new file mode 100644 index 00000000000..185fdcf5b12 --- /dev/null +++ b/kv/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package kv + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/kv.go b/kv/kv.go similarity index 89% rename from kv.go rename to kv/kv.go index 3daff08ab1a..78be8e7282e 100644 --- a/kv.go +++ b/kv/kv.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package kv import ( "github.com/cloudflare/cloudflare-go/option" @@ -12,7 +12,7 @@ import ( // directly, and instead use the [NewKVService] method instead. type KVService struct { Options []option.RequestOption - Namespaces *KVNamespaceService + Namespaces *NamespaceService } // NewKVService generates a new service that applies the given options to each @@ -21,6 +21,6 @@ type KVService struct { func NewKVService(opts ...option.RequestOption) (r *KVService) { r = &KVService{} r.Options = opts - r.Namespaces = NewKVNamespaceService(opts...) + r.Namespaces = NewNamespaceService(opts...) return } diff --git a/kv/namespace.go b/kv/namespace.go new file mode 100644 index 00000000000..51b96c0d936 --- /dev/null +++ b/kv/namespace.go @@ -0,0 +1,476 @@ +// File generated from our OpenAPI spec by Stainless. + +package kv + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// NamespaceService 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 [NewNamespaceService] method instead. +type NamespaceService struct { + Options []option.RequestOption + Bulk *NamespaceBulkService + Keys *NamespaceKeyService + Metadata *NamespaceMetadataService + Values *NamespaceValueService +} + +// NewNamespaceService 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 NewNamespaceService(opts ...option.RequestOption) (r *NamespaceService) { + r = &NamespaceService{} + r.Options = opts + r.Bulk = NewNamespaceBulkService(opts...) + r.Keys = NewNamespaceKeyService(opts...) + r.Metadata = NewNamespaceMetadataService(opts...) + r.Values = NewNamespaceValueService(opts...) + return +} + +// Creates a namespace under the given title. A `400` is returned if the account +// already owns a namespace with this title. A namespace must be explicitly deleted +// to be replaced. +func (r *NamespaceService) New(ctx context.Context, params NamespaceNewParams, opts ...option.RequestOption) (res *WorkersKVNamespace, err error) { + opts = append(r.Options[:], opts...) + var env NamespaceNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/storage/kv/namespaces", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Modifies a namespace's title. +func (r *NamespaceService) Update(ctx context.Context, namespaceID string, params NamespaceUpdateParams, opts ...option.RequestOption) (res *NamespaceUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env NamespaceUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s", params.AccountID, namespaceID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Returns the namespaces owned by an account. +func (r *NamespaceService) List(ctx context.Context, params NamespaceListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[WorkersKVNamespace], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("accounts/%s/storage/kv/namespaces", params.AccountID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Returns the namespaces owned by an account. +func (r *NamespaceService) ListAutoPaging(ctx context.Context, params NamespaceListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[WorkersKVNamespace] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) +} + +// Deletes the namespace corresponding to the given ID. +func (r *NamespaceService) Delete(ctx context.Context, namespaceID string, body NamespaceDeleteParams, opts ...option.RequestOption) (res *NamespaceDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env NamespaceDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s", body.AccountID, namespaceID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type WorkersKVNamespace struct { + // Namespace identifier tag. + ID string `json:"id,required"` + // A human-readable string name for a Namespace. + Title string `json:"title,required"` + // True if keys written on the URL will be URL-decoded before storing. For example, + // if set to "true", a key written on the URL as "%3F" will be stored as "?". + SupportsURLEncoding bool `json:"supports_url_encoding"` + JSON workersKVNamespaceJSON `json:"-"` +} + +// workersKVNamespaceJSON contains the JSON metadata for the struct +// [WorkersKVNamespace] +type workersKVNamespaceJSON struct { + ID apijson.Field + Title apijson.Field + SupportsURLEncoding apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersKVNamespace) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersKVNamespaceJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [kv.NamespaceUpdateResponseUnknown] or [shared.UnionString]. +type NamespaceUpdateResponse interface { + ImplementsKVNamespaceUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*NamespaceUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [kv.NamespaceDeleteResponseUnknown] or [shared.UnionString]. +type NamespaceDeleteResponse interface { + ImplementsKVNamespaceDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*NamespaceDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type NamespaceNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // A human-readable string name for a Namespace. + Title param.Field[string] `json:"title,required"` +} + +func (r NamespaceNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type NamespaceNewResponseEnvelope struct { + Errors []NamespaceNewResponseEnvelopeErrors `json:"errors,required"` + Messages []NamespaceNewResponseEnvelopeMessages `json:"messages,required"` + Result WorkersKVNamespace `json:"result,required"` + // Whether the API call was successful + Success NamespaceNewResponseEnvelopeSuccess `json:"success,required"` + JSON namespaceNewResponseEnvelopeJSON `json:"-"` +} + +// namespaceNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [NamespaceNewResponseEnvelope] +type namespaceNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NamespaceNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// namespaceNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [NamespaceNewResponseEnvelopeErrors] +type namespaceNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NamespaceNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// namespaceNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [NamespaceNewResponseEnvelopeMessages] +type namespaceNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NamespaceNewResponseEnvelopeSuccess bool + +const ( + NamespaceNewResponseEnvelopeSuccessTrue NamespaceNewResponseEnvelopeSuccess = true +) + +type NamespaceUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // A human-readable string name for a Namespace. + Title param.Field[string] `json:"title,required"` +} + +func (r NamespaceUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type NamespaceUpdateResponseEnvelope struct { + Errors []NamespaceUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []NamespaceUpdateResponseEnvelopeMessages `json:"messages,required"` + Result NamespaceUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success NamespaceUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON namespaceUpdateResponseEnvelopeJSON `json:"-"` +} + +// namespaceUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [NamespaceUpdateResponseEnvelope] +type namespaceUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NamespaceUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// namespaceUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [NamespaceUpdateResponseEnvelopeErrors] +type namespaceUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NamespaceUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// namespaceUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [NamespaceUpdateResponseEnvelopeMessages] +type namespaceUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NamespaceUpdateResponseEnvelopeSuccess bool + +const ( + NamespaceUpdateResponseEnvelopeSuccessTrue NamespaceUpdateResponseEnvelopeSuccess = true +) + +type NamespaceListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Direction to order namespaces. + Direction param.Field[NamespaceListParamsDirection] `query:"direction"` + // Field to order results by. + Order param.Field[NamespaceListParamsOrder] `query:"order"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // Maximum number of results per page. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [NamespaceListParams]'s query parameters as `url.Values`. +func (r NamespaceListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Direction to order namespaces. +type NamespaceListParamsDirection string + +const ( + NamespaceListParamsDirectionAsc NamespaceListParamsDirection = "asc" + NamespaceListParamsDirectionDesc NamespaceListParamsDirection = "desc" +) + +// Field to order results by. +type NamespaceListParamsOrder string + +const ( + NamespaceListParamsOrderID NamespaceListParamsOrder = "id" + NamespaceListParamsOrderTitle NamespaceListParamsOrder = "title" +) + +type NamespaceDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type NamespaceDeleteResponseEnvelope struct { + Errors []NamespaceDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []NamespaceDeleteResponseEnvelopeMessages `json:"messages,required"` + Result NamespaceDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success NamespaceDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON namespaceDeleteResponseEnvelopeJSON `json:"-"` +} + +// namespaceDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [NamespaceDeleteResponseEnvelope] +type namespaceDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NamespaceDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// namespaceDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [NamespaceDeleteResponseEnvelopeErrors] +type namespaceDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NamespaceDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// namespaceDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [NamespaceDeleteResponseEnvelopeMessages] +type namespaceDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NamespaceDeleteResponseEnvelopeSuccess bool + +const ( + NamespaceDeleteResponseEnvelopeSuccessTrue NamespaceDeleteResponseEnvelopeSuccess = true +) diff --git a/kv/namespace_test.go b/kv/namespace_test.go new file mode 100644 index 00000000000..a9069e9f75f --- /dev/null +++ b/kv/namespace_test.go @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package kv_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/kv" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestNamespaceNew(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("user@example.com"), + ) + _, err := client.KV.Namespaces.New(context.TODO(), kv.NamespaceNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Title: cloudflare.F("My Own Namespace"), + }) + 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 TestNamespaceUpdate(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("user@example.com"), + ) + _, err := client.KV.Namespaces.Update( + context.TODO(), + "0f2ac74b498b48028cb68387c421e279", + kv.NamespaceUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Title: cloudflare.F("My Own Namespace"), + }, + ) + 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 TestNamespaceListWithOptionalParams(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("user@example.com"), + ) + _, err := client.KV.Namespaces.List(context.TODO(), kv.NamespaceListParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Direction: cloudflare.F(kv.NamespaceListParamsDirectionAsc), + Order: cloudflare.F(kv.NamespaceListParamsOrderID), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(5.000000), + }) + 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 TestNamespaceDelete(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("user@example.com"), + ) + _, err := client.KV.Namespaces.Delete( + context.TODO(), + "0f2ac74b498b48028cb68387c421e279", + kv.NamespaceDeleteParams{ + AccountID: cloudflare.F("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/kv/namespacebulk.go b/kv/namespacebulk.go new file mode 100644 index 00000000000..566b05e7bcd --- /dev/null +++ b/kv/namespacebulk.go @@ -0,0 +1,307 @@ +// File generated from our OpenAPI spec by Stainless. + +package kv + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// NamespaceBulkService 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 [NewNamespaceBulkService] method +// instead. +type NamespaceBulkService struct { + Options []option.RequestOption +} + +// NewNamespaceBulkService 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 NewNamespaceBulkService(opts ...option.RequestOption) (r *NamespaceBulkService) { + r = &NamespaceBulkService{} + r.Options = opts + return +} + +// Write multiple keys and values at once. Body should be an array of up to 10,000 +// key-value pairs to be stored, along with optional expiration information. +// Existing values and expirations will be overwritten. If neither `expiration` nor +// `expiration_ttl` is specified, the key-value pair will never expire. If both are +// set, `expiration_ttl` is used and `expiration` is ignored. The entire request +// size must be 100 megabytes or less. +func (r *NamespaceBulkService) Update(ctx context.Context, namespaceID string, params NamespaceBulkUpdateParams, opts ...option.RequestOption) (res *NamespaceBulkUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env NamespaceBulkUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/bulk", params.AccountID, namespaceID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Remove multiple KV pairs from the namespace. Body should be an array of up to +// 10,000 keys to be removed. +func (r *NamespaceBulkService) Delete(ctx context.Context, namespaceID string, params NamespaceBulkDeleteParams, opts ...option.RequestOption) (res *NamespaceBulkDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env NamespaceBulkDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/bulk", params.AccountID, namespaceID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [kv.NamespaceBulkUpdateResponseUnknown] or +// [shared.UnionString]. +type NamespaceBulkUpdateResponse interface { + ImplementsKVNamespaceBulkUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*NamespaceBulkUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [kv.NamespaceBulkDeleteResponseUnknown] or +// [shared.UnionString]. +type NamespaceBulkDeleteResponse interface { + ImplementsKVNamespaceBulkDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*NamespaceBulkDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type NamespaceBulkUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Body param.Field[[]NamespaceBulkUpdateParamsBody] `json:"body,required"` +} + +func (r NamespaceBulkUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type NamespaceBulkUpdateParamsBody struct { + // Whether or not the server should base64 decode the value before storing it. + // Useful for writing values that wouldn't otherwise be valid JSON strings, such as + // images. + Base64 param.Field[bool] `json:"base64"` + // The time, measured in number of seconds since the UNIX epoch, at which the key + // should expire. + Expiration param.Field[float64] `json:"expiration"` + // The number of seconds for which the key should be visible before it expires. At + // least 60. + ExpirationTTL param.Field[float64] `json:"expiration_ttl"` + // A key's name. The name may be at most 512 bytes. All printable, non-whitespace + // characters are valid. + Key param.Field[string] `json:"key"` + // Arbitrary JSON that is associated with a key. + Metadata param.Field[interface{}] `json:"metadata"` + // A UTF-8 encoded string to be stored, up to 25 MiB in length. + Value param.Field[string] `json:"value"` +} + +func (r NamespaceBulkUpdateParamsBody) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type NamespaceBulkUpdateResponseEnvelope struct { + Errors []NamespaceBulkUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []NamespaceBulkUpdateResponseEnvelopeMessages `json:"messages,required"` + Result NamespaceBulkUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success NamespaceBulkUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON namespaceBulkUpdateResponseEnvelopeJSON `json:"-"` +} + +// namespaceBulkUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [NamespaceBulkUpdateResponseEnvelope] +type namespaceBulkUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceBulkUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceBulkUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NamespaceBulkUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceBulkUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// namespaceBulkUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [NamespaceBulkUpdateResponseEnvelopeErrors] +type namespaceBulkUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceBulkUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceBulkUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NamespaceBulkUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceBulkUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// namespaceBulkUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [NamespaceBulkUpdateResponseEnvelopeMessages] +type namespaceBulkUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceBulkUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceBulkUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NamespaceBulkUpdateResponseEnvelopeSuccess bool + +const ( + NamespaceBulkUpdateResponseEnvelopeSuccessTrue NamespaceBulkUpdateResponseEnvelopeSuccess = true +) + +type NamespaceBulkDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Body param.Field[[]string] `json:"body,required"` +} + +func (r NamespaceBulkDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type NamespaceBulkDeleteResponseEnvelope struct { + Errors []NamespaceBulkDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []NamespaceBulkDeleteResponseEnvelopeMessages `json:"messages,required"` + Result NamespaceBulkDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success NamespaceBulkDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON namespaceBulkDeleteResponseEnvelopeJSON `json:"-"` +} + +// namespaceBulkDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [NamespaceBulkDeleteResponseEnvelope] +type namespaceBulkDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceBulkDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceBulkDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NamespaceBulkDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceBulkDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// namespaceBulkDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [NamespaceBulkDeleteResponseEnvelopeErrors] +type namespaceBulkDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceBulkDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceBulkDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NamespaceBulkDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceBulkDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// namespaceBulkDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [NamespaceBulkDeleteResponseEnvelopeMessages] +type namespaceBulkDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceBulkDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceBulkDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NamespaceBulkDeleteResponseEnvelopeSuccess bool + +const ( + NamespaceBulkDeleteResponseEnvelopeSuccessTrue NamespaceBulkDeleteResponseEnvelopeSuccess = true +) diff --git a/kv/namespacebulk_test.go b/kv/namespacebulk_test.go new file mode 100644 index 00000000000..897245404dc --- /dev/null +++ b/kv/namespacebulk_test.go @@ -0,0 +1,104 @@ +// File generated from our OpenAPI spec by Stainless. + +package kv_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/kv" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestNamespaceBulkUpdate(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("user@example.com"), + ) + _, err := client.KV.Namespaces.Bulk.Update( + context.TODO(), + "0f2ac74b498b48028cb68387c421e279", + kv.NamespaceBulkUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: cloudflare.F([]kv.NamespaceBulkUpdateParamsBody{{ + Base64: cloudflare.F(true), + Expiration: cloudflare.F(1578435000.000000), + ExpirationTTL: cloudflare.F(300.000000), + Key: cloudflare.F("My-Key"), + Metadata: cloudflare.F[any](map[string]interface{}{ + "someMetadataKey": "someMetadataValue", + }), + Value: cloudflare.F("Some string"), + }, { + Base64: cloudflare.F(true), + Expiration: cloudflare.F(1578435000.000000), + ExpirationTTL: cloudflare.F(300.000000), + Key: cloudflare.F("My-Key"), + Metadata: cloudflare.F[any](map[string]interface{}{ + "someMetadataKey": "someMetadataValue", + }), + Value: cloudflare.F("Some string"), + }, { + Base64: cloudflare.F(true), + Expiration: cloudflare.F(1578435000.000000), + ExpirationTTL: cloudflare.F(300.000000), + Key: cloudflare.F("My-Key"), + Metadata: cloudflare.F[any](map[string]interface{}{ + "someMetadataKey": "someMetadataValue", + }), + Value: cloudflare.F("Some string"), + }}), + }, + ) + 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 TestNamespaceBulkDelete(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("user@example.com"), + ) + _, err := client.KV.Namespaces.Bulk.Delete( + context.TODO(), + "0f2ac74b498b48028cb68387c421e279", + kv.NamespaceBulkDeleteParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: cloudflare.F([]string{"My-Key", "My-Key", "My-Key"}), + }, + ) + 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/kv/namespacekey.go b/kv/namespacekey.go new file mode 100644 index 00000000000..4927d304ded --- /dev/null +++ b/kv/namespacekey.go @@ -0,0 +1,213 @@ +// File generated from our OpenAPI spec by Stainless. + +package kv + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// NamespaceKeyService 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 [NewNamespaceKeyService] method +// instead. +type NamespaceKeyService struct { + Options []option.RequestOption +} + +// NewNamespaceKeyService 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 NewNamespaceKeyService(opts ...option.RequestOption) (r *NamespaceKeyService) { + r = &NamespaceKeyService{} + r.Options = opts + return +} + +// Lists a namespace's keys. +func (r *NamespaceKeyService) List(ctx context.Context, namespaceID string, params NamespaceKeyListParams, opts ...option.RequestOption) (res *[]WorkersKVKey, err error) { + opts = append(r.Options[:], opts...) + var env NamespaceKeyListResponseEnvelope + path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/keys", params.AccountID, namespaceID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// A name for a value. A value stored under a given key may be retrieved via the +// same key. +type WorkersKVKey struct { + // A key's name. The name may be at most 512 bytes. All printable, non-whitespace + // characters are valid. Use percent-encoding to define key names as part of a URL. + Name string `json:"name,required"` + // The time, measured in number of seconds since the UNIX epoch, at which the key + // will expire. This property is omitted for keys that will not expire. + Expiration float64 `json:"expiration"` + // Arbitrary JSON that is associated with a key. + Metadata interface{} `json:"metadata"` + JSON workersKVKeyJSON `json:"-"` +} + +// workersKVKeyJSON contains the JSON metadata for the struct [WorkersKVKey] +type workersKVKeyJSON struct { + Name apijson.Field + Expiration apijson.Field + Metadata apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersKVKey) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersKVKeyJSON) RawJSON() string { + return r.raw +} + +type NamespaceKeyListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Opaque token indicating the position from which to continue when requesting the + // next set of records if the amount of list results was limited by the limit + // parameter. A valid value for the cursor can be obtained from the `cursors` + // object in the `result_info` structure. + Cursor param.Field[string] `query:"cursor"` + // The number of keys to return. The cursor attribute may be used to iterate over + // the next batch of keys if there are more than the limit. + Limit param.Field[float64] `query:"limit"` + // A string prefix used to filter down which keys will be returned. Exact matches + // and any key names that begin with the prefix will be returned. + Prefix param.Field[string] `query:"prefix"` +} + +// URLQuery serializes [NamespaceKeyListParams]'s query parameters as `url.Values`. +func (r NamespaceKeyListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type NamespaceKeyListResponseEnvelope struct { + Errors []NamespaceKeyListResponseEnvelopeErrors `json:"errors,required"` + Messages []NamespaceKeyListResponseEnvelopeMessages `json:"messages,required"` + Result []WorkersKVKey `json:"result,required"` + // Whether the API call was successful + Success NamespaceKeyListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo NamespaceKeyListResponseEnvelopeResultInfo `json:"result_info"` + JSON namespaceKeyListResponseEnvelopeJSON `json:"-"` +} + +// namespaceKeyListResponseEnvelopeJSON contains the JSON metadata for the struct +// [NamespaceKeyListResponseEnvelope] +type namespaceKeyListResponseEnvelopeJSON 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 *NamespaceKeyListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceKeyListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NamespaceKeyListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceKeyListResponseEnvelopeErrorsJSON `json:"-"` +} + +// namespaceKeyListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [NamespaceKeyListResponseEnvelopeErrors] +type namespaceKeyListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceKeyListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceKeyListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NamespaceKeyListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceKeyListResponseEnvelopeMessagesJSON `json:"-"` +} + +// namespaceKeyListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [NamespaceKeyListResponseEnvelopeMessages] +type namespaceKeyListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceKeyListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceKeyListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NamespaceKeyListResponseEnvelopeSuccess bool + +const ( + NamespaceKeyListResponseEnvelopeSuccessTrue NamespaceKeyListResponseEnvelopeSuccess = true +) + +type NamespaceKeyListResponseEnvelopeResultInfo struct { + // Total results returned based on your list parameters. + Count float64 `json:"count"` + // Opaque token indicating the position from which to continue when requesting the + // next set of records if the amount of list results was limited by the limit + // parameter. A valid value for the cursor can be obtained from the cursors object + // in the result_info structure. + Cursor string `json:"cursor"` + JSON namespaceKeyListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// namespaceKeyListResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [NamespaceKeyListResponseEnvelopeResultInfo] +type namespaceKeyListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Cursor apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceKeyListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceKeyListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/kv/namespacekey_test.go b/kv/namespacekey_test.go new file mode 100644 index 00000000000..ceb73c479ef --- /dev/null +++ b/kv/namespacekey_test.go @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package kv_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/kv" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestNamespaceKeyListWithOptionalParams(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("user@example.com"), + ) + _, err := client.KV.Namespaces.Keys.List( + context.TODO(), + "0f2ac74b498b48028cb68387c421e279", + kv.NamespaceKeyListParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Cursor: cloudflare.F("6Ck1la0VxJ0djhidm1MdX2FyDGxLKVeeHZZmORS_8XeSuhz9SjIJRaSa2lnsF01tQOHrfTGAP3R5X1Kv5iVUuMbNKhWNAXHOl6ePB0TUL8nw"), + Limit: cloudflare.F(10.000000), + Prefix: cloudflare.F("My-Prefix"), + }, + ) + 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/kv/namespacemetadata.go b/kv/namespacemetadata.go new file mode 100644 index 00000000000..8ecb072fe46 --- /dev/null +++ b/kv/namespacemetadata.go @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package kv + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// NamespaceMetadataService 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 [NewNamespaceMetadataService] method +// instead. +type NamespaceMetadataService struct { + Options []option.RequestOption +} + +// NewNamespaceMetadataService 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 NewNamespaceMetadataService(opts ...option.RequestOption) (r *NamespaceMetadataService) { + r = &NamespaceMetadataService{} + r.Options = opts + return +} + +// Returns the metadata associated with the given key in the given namespace. Use +// URL-encoding to use special characters (for example, `:`, `!`, `%`) in the key +// name. +func (r *NamespaceMetadataService) Get(ctx context.Context, namespaceID string, keyName string, query NamespaceMetadataGetParams, opts ...option.RequestOption) (res *NamespaceMetadataGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env NamespaceMetadataGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/metadata/%s", query.AccountID, namespaceID, keyName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type NamespaceMetadataGetResponse = interface{} + +type NamespaceMetadataGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type NamespaceMetadataGetResponseEnvelope struct { + Errors []NamespaceMetadataGetResponseEnvelopeErrors `json:"errors,required"` + Messages []NamespaceMetadataGetResponseEnvelopeMessages `json:"messages,required"` + // Arbitrary JSON that is associated with a key. + Result NamespaceMetadataGetResponse `json:"result,required"` + // Whether the API call was successful + Success NamespaceMetadataGetResponseEnvelopeSuccess `json:"success,required"` + JSON namespaceMetadataGetResponseEnvelopeJSON `json:"-"` +} + +// namespaceMetadataGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [NamespaceMetadataGetResponseEnvelope] +type namespaceMetadataGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceMetadataGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceMetadataGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NamespaceMetadataGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceMetadataGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// namespaceMetadataGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [NamespaceMetadataGetResponseEnvelopeErrors] +type namespaceMetadataGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceMetadataGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceMetadataGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NamespaceMetadataGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceMetadataGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// namespaceMetadataGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [NamespaceMetadataGetResponseEnvelopeMessages] +type namespaceMetadataGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceMetadataGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceMetadataGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NamespaceMetadataGetResponseEnvelopeSuccess bool + +const ( + NamespaceMetadataGetResponseEnvelopeSuccessTrue NamespaceMetadataGetResponseEnvelopeSuccess = true +) diff --git a/kv/namespacemetadata_test.go b/kv/namespacemetadata_test.go new file mode 100644 index 00000000000..d324f706aa5 --- /dev/null +++ b/kv/namespacemetadata_test.go @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package kv_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/kv" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestNamespaceMetadataGet(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("user@example.com"), + ) + _, err := client.KV.Namespaces.Metadata.Get( + context.TODO(), + "0f2ac74b498b48028cb68387c421e279", + "My-Key", + kv.NamespaceMetadataGetParams{ + AccountID: cloudflare.F("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/kv/namespacevalue.go b/kv/namespacevalue.go new file mode 100644 index 00000000000..148f9117e0d --- /dev/null +++ b/kv/namespacevalue.go @@ -0,0 +1,298 @@ +// File generated from our OpenAPI spec by Stainless. + +package kv + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// NamespaceValueService 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 [NewNamespaceValueService] method +// instead. +type NamespaceValueService struct { + Options []option.RequestOption +} + +// NewNamespaceValueService 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 NewNamespaceValueService(opts ...option.RequestOption) (r *NamespaceValueService) { + r = &NamespaceValueService{} + r.Options = opts + return +} + +// Write a value identified by a key. Use URL-encoding to use special characters +// (for example, `:`, `!`, `%`) in the key name. Body should be the value to be +// stored along with JSON metadata to be associated with the key/value pair. +// Existing values, expirations, and metadata will be overwritten. If neither +// `expiration` nor `expiration_ttl` is specified, the key-value pair will never +// expire. If both are set, `expiration_ttl` is used and `expiration` is ignored. +func (r *NamespaceValueService) Update(ctx context.Context, namespaceID string, keyName string, params NamespaceValueUpdateParams, opts ...option.RequestOption) (res *NamespaceValueUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env NamespaceValueUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/values/%s", params.AccountID, namespaceID, keyName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Remove a KV pair from the namespace. Use URL-encoding to use special characters +// (for example, `:`, `!`, `%`) in the key name. +func (r *NamespaceValueService) Delete(ctx context.Context, namespaceID string, keyName string, body NamespaceValueDeleteParams, opts ...option.RequestOption) (res *NamespaceValueDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env NamespaceValueDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/values/%s", body.AccountID, namespaceID, keyName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Returns the value associated with the given key in the given namespace. Use +// URL-encoding to use special characters (for example, `:`, `!`, `%`) in the key +// name. If the KV-pair is set to expire at some point, the expiration time as +// measured in seconds since the UNIX epoch will be returned in the `expiration` +// response header. +func (r *NamespaceValueService) Get(ctx context.Context, namespaceID string, keyName string, query NamespaceValueGetParams, opts ...option.RequestOption) (res *string, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/values/%s", query.AccountID, namespaceID, keyName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +// Union satisfied by [kv.NamespaceValueUpdateResponseUnknown] or +// [shared.UnionString]. +type NamespaceValueUpdateResponse interface { + ImplementsKVNamespaceValueUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*NamespaceValueUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [kv.NamespaceValueDeleteResponseUnknown] or +// [shared.UnionString]. +type NamespaceValueDeleteResponse interface { + ImplementsKVNamespaceValueDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*NamespaceValueDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type NamespaceValueUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Arbitrary JSON to be associated with a key/value pair. + Metadata param.Field[string] `json:"metadata,required"` + // A byte sequence to be stored, up to 25 MiB in length. + Value param.Field[string] `json:"value,required"` +} + +func (r NamespaceValueUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type NamespaceValueUpdateResponseEnvelope struct { + Errors []NamespaceValueUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []NamespaceValueUpdateResponseEnvelopeMessages `json:"messages,required"` + Result NamespaceValueUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success NamespaceValueUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON namespaceValueUpdateResponseEnvelopeJSON `json:"-"` +} + +// namespaceValueUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [NamespaceValueUpdateResponseEnvelope] +type namespaceValueUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceValueUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceValueUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NamespaceValueUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceValueUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// namespaceValueUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [NamespaceValueUpdateResponseEnvelopeErrors] +type namespaceValueUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceValueUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceValueUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NamespaceValueUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceValueUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// namespaceValueUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [NamespaceValueUpdateResponseEnvelopeMessages] +type namespaceValueUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceValueUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceValueUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NamespaceValueUpdateResponseEnvelopeSuccess bool + +const ( + NamespaceValueUpdateResponseEnvelopeSuccessTrue NamespaceValueUpdateResponseEnvelopeSuccess = true +) + +type NamespaceValueDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type NamespaceValueDeleteResponseEnvelope struct { + Errors []NamespaceValueDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []NamespaceValueDeleteResponseEnvelopeMessages `json:"messages,required"` + Result NamespaceValueDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success NamespaceValueDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON namespaceValueDeleteResponseEnvelopeJSON `json:"-"` +} + +// namespaceValueDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [NamespaceValueDeleteResponseEnvelope] +type namespaceValueDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceValueDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceValueDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NamespaceValueDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceValueDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// namespaceValueDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [NamespaceValueDeleteResponseEnvelopeErrors] +type namespaceValueDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceValueDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceValueDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NamespaceValueDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON namespaceValueDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// namespaceValueDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [NamespaceValueDeleteResponseEnvelopeMessages] +type namespaceValueDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceValueDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceValueDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NamespaceValueDeleteResponseEnvelopeSuccess bool + +const ( + NamespaceValueDeleteResponseEnvelopeSuccessTrue NamespaceValueDeleteResponseEnvelopeSuccess = true +) + +type NamespaceValueGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} diff --git a/kv/namespacevalue_test.go b/kv/namespacevalue_test.go new file mode 100644 index 00000000000..1779a8fcf22 --- /dev/null +++ b/kv/namespacevalue_test.go @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package kv_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/kv" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestNamespaceValueUpdate(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("user@example.com"), + ) + _, err := client.KV.Namespaces.Values.Update( + context.TODO(), + "0f2ac74b498b48028cb68387c421e279", + "My-Key", + kv.NamespaceValueUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Metadata: cloudflare.F("{\"someMetadataKey\": \"someMetadataValue\"}"), + Value: cloudflare.F("Some Value"), + }, + ) + 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 TestNamespaceValueDelete(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("user@example.com"), + ) + _, err := client.KV.Namespaces.Values.Delete( + context.TODO(), + "0f2ac74b498b48028cb68387c421e279", + "My-Key", + kv.NamespaceValueDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestNamespaceValueGet(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("user@example.com"), + ) + _, err := client.KV.Namespaces.Values.Get( + context.TODO(), + "0f2ac74b498b48028cb68387c421e279", + "My-Key", + kv.NamespaceValueGetParams{ + AccountID: cloudflare.F("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/kvnamespace.go b/kvnamespace.go deleted file mode 100644 index 4a0a2fb112e..00000000000 --- a/kvnamespace.go +++ /dev/null @@ -1,506 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// KVNamespaceService 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 [NewKVNamespaceService] method -// instead. -type KVNamespaceService struct { - Options []option.RequestOption - Bulk *KVNamespaceBulkService - Keys *KVNamespaceKeyService - Metadata *KVNamespaceMetadataService - Values *KVNamespaceValueService -} - -// NewKVNamespaceService 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 NewKVNamespaceService(opts ...option.RequestOption) (r *KVNamespaceService) { - r = &KVNamespaceService{} - r.Options = opts - r.Bulk = NewKVNamespaceBulkService(opts...) - r.Keys = NewKVNamespaceKeyService(opts...) - r.Metadata = NewKVNamespaceMetadataService(opts...) - r.Values = NewKVNamespaceValueService(opts...) - return -} - -// Creates a namespace under the given title. A `400` is returned if the account -// already owns a namespace with this title. A namespace must be explicitly deleted -// to be replaced. -func (r *KVNamespaceService) New(ctx context.Context, params KVNamespaceNewParams, opts ...option.RequestOption) (res *KVNamespaceNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env KVNamespaceNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/storage/kv/namespaces", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Modifies a namespace's title. -func (r *KVNamespaceService) Update(ctx context.Context, namespaceID string, params KVNamespaceUpdateParams, opts ...option.RequestOption) (res *KVNamespaceUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env KVNamespaceUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s", params.AccountID, namespaceID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Returns the namespaces owned by an account. -func (r *KVNamespaceService) List(ctx context.Context, params KVNamespaceListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[KVNamespaceListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("accounts/%s/storage/kv/namespaces", params.AccountID) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Returns the namespaces owned by an account. -func (r *KVNamespaceService) ListAutoPaging(ctx context.Context, params KVNamespaceListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[KVNamespaceListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) -} - -// Deletes the namespace corresponding to the given ID. -func (r *KVNamespaceService) Delete(ctx context.Context, namespaceID string, body KVNamespaceDeleteParams, opts ...option.RequestOption) (res *KVNamespaceDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env KVNamespaceDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s", body.AccountID, namespaceID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type KVNamespaceNewResponse struct { - // Namespace identifier tag. - ID string `json:"id,required"` - // A human-readable string name for a Namespace. - Title string `json:"title,required"` - // True if keys written on the URL will be URL-decoded before storing. For example, - // if set to "true", a key written on the URL as "%3F" will be stored as "?". - SupportsURLEncoding bool `json:"supports_url_encoding"` - JSON kvNamespaceNewResponseJSON `json:"-"` -} - -// kvNamespaceNewResponseJSON contains the JSON metadata for the struct -// [KVNamespaceNewResponse] -type kvNamespaceNewResponseJSON struct { - ID apijson.Field - Title apijson.Field - SupportsURLEncoding apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceNewResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [KVNamespaceUpdateResponseUnknown] or [shared.UnionString]. -type KVNamespaceUpdateResponse interface { - ImplementsKVNamespaceUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*KVNamespaceUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type KVNamespaceListResponse struct { - // Namespace identifier tag. - ID string `json:"id,required"` - // A human-readable string name for a Namespace. - Title string `json:"title,required"` - // True if keys written on the URL will be URL-decoded before storing. For example, - // if set to "true", a key written on the URL as "%3F" will be stored as "?". - SupportsURLEncoding bool `json:"supports_url_encoding"` - JSON kvNamespaceListResponseJSON `json:"-"` -} - -// kvNamespaceListResponseJSON contains the JSON metadata for the struct -// [KVNamespaceListResponse] -type kvNamespaceListResponseJSON struct { - ID apijson.Field - Title apijson.Field - SupportsURLEncoding apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceListResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [KVNamespaceDeleteResponseUnknown] or [shared.UnionString]. -type KVNamespaceDeleteResponse interface { - ImplementsKVNamespaceDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*KVNamespaceDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type KVNamespaceNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // A human-readable string name for a Namespace. - Title param.Field[string] `json:"title,required"` -} - -func (r KVNamespaceNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type KVNamespaceNewResponseEnvelope struct { - Errors []KVNamespaceNewResponseEnvelopeErrors `json:"errors,required"` - Messages []KVNamespaceNewResponseEnvelopeMessages `json:"messages,required"` - Result KVNamespaceNewResponse `json:"result,required"` - // Whether the API call was successful - Success KVNamespaceNewResponseEnvelopeSuccess `json:"success,required"` - JSON kvNamespaceNewResponseEnvelopeJSON `json:"-"` -} - -// kvNamespaceNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [KVNamespaceNewResponseEnvelope] -type kvNamespaceNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON kvNamespaceNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// kvNamespaceNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [KVNamespaceNewResponseEnvelopeErrors] -type kvNamespaceNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON kvNamespaceNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// kvNamespaceNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [KVNamespaceNewResponseEnvelopeMessages] -type kvNamespaceNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type KVNamespaceNewResponseEnvelopeSuccess bool - -const ( - KVNamespaceNewResponseEnvelopeSuccessTrue KVNamespaceNewResponseEnvelopeSuccess = true -) - -type KVNamespaceUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // A human-readable string name for a Namespace. - Title param.Field[string] `json:"title,required"` -} - -func (r KVNamespaceUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type KVNamespaceUpdateResponseEnvelope struct { - Errors []KVNamespaceUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []KVNamespaceUpdateResponseEnvelopeMessages `json:"messages,required"` - Result KVNamespaceUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success KVNamespaceUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON kvNamespaceUpdateResponseEnvelopeJSON `json:"-"` -} - -// kvNamespaceUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [KVNamespaceUpdateResponseEnvelope] -type kvNamespaceUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON kvNamespaceUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// kvNamespaceUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [KVNamespaceUpdateResponseEnvelopeErrors] -type kvNamespaceUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON kvNamespaceUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// kvNamespaceUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [KVNamespaceUpdateResponseEnvelopeMessages] -type kvNamespaceUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type KVNamespaceUpdateResponseEnvelopeSuccess bool - -const ( - KVNamespaceUpdateResponseEnvelopeSuccessTrue KVNamespaceUpdateResponseEnvelopeSuccess = true -) - -type KVNamespaceListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Direction to order namespaces. - Direction param.Field[KVNamespaceListParamsDirection] `query:"direction"` - // Field to order results by. - Order param.Field[KVNamespaceListParamsOrder] `query:"order"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // Maximum number of results per page. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [KVNamespaceListParams]'s query parameters as `url.Values`. -func (r KVNamespaceListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Direction to order namespaces. -type KVNamespaceListParamsDirection string - -const ( - KVNamespaceListParamsDirectionAsc KVNamespaceListParamsDirection = "asc" - KVNamespaceListParamsDirectionDesc KVNamespaceListParamsDirection = "desc" -) - -// Field to order results by. -type KVNamespaceListParamsOrder string - -const ( - KVNamespaceListParamsOrderID KVNamespaceListParamsOrder = "id" - KVNamespaceListParamsOrderTitle KVNamespaceListParamsOrder = "title" -) - -type KVNamespaceDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type KVNamespaceDeleteResponseEnvelope struct { - Errors []KVNamespaceDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []KVNamespaceDeleteResponseEnvelopeMessages `json:"messages,required"` - Result KVNamespaceDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success KVNamespaceDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON kvNamespaceDeleteResponseEnvelopeJSON `json:"-"` -} - -// kvNamespaceDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [KVNamespaceDeleteResponseEnvelope] -type kvNamespaceDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON kvNamespaceDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// kvNamespaceDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [KVNamespaceDeleteResponseEnvelopeErrors] -type kvNamespaceDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON kvNamespaceDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// kvNamespaceDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [KVNamespaceDeleteResponseEnvelopeMessages] -type kvNamespaceDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type KVNamespaceDeleteResponseEnvelopeSuccess bool - -const ( - KVNamespaceDeleteResponseEnvelopeSuccessTrue KVNamespaceDeleteResponseEnvelopeSuccess = true -) diff --git a/kvnamespace_test.go b/kvnamespace_test.go deleted file mode 100644 index 7aad2d51a83..00000000000 --- a/kvnamespace_test.go +++ /dev/null @@ -1,132 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestKVNamespaceNew(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("user@example.com"), - ) - _, err := client.KV.Namespaces.New(context.TODO(), cloudflare.KVNamespaceNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Title: cloudflare.F("My Own Namespace"), - }) - 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 TestKVNamespaceUpdate(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("user@example.com"), - ) - _, err := client.KV.Namespaces.Update( - context.TODO(), - "0f2ac74b498b48028cb68387c421e279", - cloudflare.KVNamespaceUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Title: cloudflare.F("My Own Namespace"), - }, - ) - 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 TestKVNamespaceListWithOptionalParams(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("user@example.com"), - ) - _, err := client.KV.Namespaces.List(context.TODO(), cloudflare.KVNamespaceListParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Direction: cloudflare.F(cloudflare.KVNamespaceListParamsDirectionAsc), - Order: cloudflare.F(cloudflare.KVNamespaceListParamsOrderID), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(5.000000), - }) - 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 TestKVNamespaceDelete(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("user@example.com"), - ) - _, err := client.KV.Namespaces.Delete( - context.TODO(), - "0f2ac74b498b48028cb68387c421e279", - cloudflare.KVNamespaceDeleteParams{ - AccountID: cloudflare.F("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/kvnamespacebulk.go b/kvnamespacebulk.go deleted file mode 100644 index e5796dbfa22..00000000000 --- a/kvnamespacebulk.go +++ /dev/null @@ -1,307 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// KVNamespaceBulkService 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 [NewKVNamespaceBulkService] method -// instead. -type KVNamespaceBulkService struct { - Options []option.RequestOption -} - -// NewKVNamespaceBulkService 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 NewKVNamespaceBulkService(opts ...option.RequestOption) (r *KVNamespaceBulkService) { - r = &KVNamespaceBulkService{} - r.Options = opts - return -} - -// Write multiple keys and values at once. Body should be an array of up to 10,000 -// key-value pairs to be stored, along with optional expiration information. -// Existing values and expirations will be overwritten. If neither `expiration` nor -// `expiration_ttl` is specified, the key-value pair will never expire. If both are -// set, `expiration_ttl` is used and `expiration` is ignored. The entire request -// size must be 100 megabytes or less. -func (r *KVNamespaceBulkService) Update(ctx context.Context, namespaceID string, params KVNamespaceBulkUpdateParams, opts ...option.RequestOption) (res *KVNamespaceBulkUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env KVNamespaceBulkUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/bulk", params.AccountID, namespaceID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Remove multiple KV pairs from the namespace. Body should be an array of up to -// 10,000 keys to be removed. -func (r *KVNamespaceBulkService) Delete(ctx context.Context, namespaceID string, params KVNamespaceBulkDeleteParams, opts ...option.RequestOption) (res *KVNamespaceBulkDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env KVNamespaceBulkDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/bulk", params.AccountID, namespaceID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [KVNamespaceBulkUpdateResponseUnknown] or -// [shared.UnionString]. -type KVNamespaceBulkUpdateResponse interface { - ImplementsKVNamespaceBulkUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*KVNamespaceBulkUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [KVNamespaceBulkDeleteResponseUnknown] or -// [shared.UnionString]. -type KVNamespaceBulkDeleteResponse interface { - ImplementsKVNamespaceBulkDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*KVNamespaceBulkDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type KVNamespaceBulkUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[[]KVNamespaceBulkUpdateParamsBody] `json:"body,required"` -} - -func (r KVNamespaceBulkUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type KVNamespaceBulkUpdateParamsBody struct { - // Whether or not the server should base64 decode the value before storing it. - // Useful for writing values that wouldn't otherwise be valid JSON strings, such as - // images. - Base64 param.Field[bool] `json:"base64"` - // The time, measured in number of seconds since the UNIX epoch, at which the key - // should expire. - Expiration param.Field[float64] `json:"expiration"` - // The number of seconds for which the key should be visible before it expires. At - // least 60. - ExpirationTTL param.Field[float64] `json:"expiration_ttl"` - // A key's name. The name may be at most 512 bytes. All printable, non-whitespace - // characters are valid. - Key param.Field[string] `json:"key"` - // Arbitrary JSON that is associated with a key. - Metadata param.Field[interface{}] `json:"metadata"` - // A UTF-8 encoded string to be stored, up to 25 MiB in length. - Value param.Field[string] `json:"value"` -} - -func (r KVNamespaceBulkUpdateParamsBody) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type KVNamespaceBulkUpdateResponseEnvelope struct { - Errors []KVNamespaceBulkUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []KVNamespaceBulkUpdateResponseEnvelopeMessages `json:"messages,required"` - Result KVNamespaceBulkUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success KVNamespaceBulkUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON kvNamespaceBulkUpdateResponseEnvelopeJSON `json:"-"` -} - -// kvNamespaceBulkUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [KVNamespaceBulkUpdateResponseEnvelope] -type kvNamespaceBulkUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceBulkUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceBulkUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceBulkUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON kvNamespaceBulkUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// kvNamespaceBulkUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [KVNamespaceBulkUpdateResponseEnvelopeErrors] -type kvNamespaceBulkUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceBulkUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceBulkUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceBulkUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON kvNamespaceBulkUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// kvNamespaceBulkUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [KVNamespaceBulkUpdateResponseEnvelopeMessages] -type kvNamespaceBulkUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceBulkUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceBulkUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type KVNamespaceBulkUpdateResponseEnvelopeSuccess bool - -const ( - KVNamespaceBulkUpdateResponseEnvelopeSuccessTrue KVNamespaceBulkUpdateResponseEnvelopeSuccess = true -) - -type KVNamespaceBulkDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[[]string] `json:"body,required"` -} - -func (r KVNamespaceBulkDeleteParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type KVNamespaceBulkDeleteResponseEnvelope struct { - Errors []KVNamespaceBulkDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []KVNamespaceBulkDeleteResponseEnvelopeMessages `json:"messages,required"` - Result KVNamespaceBulkDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success KVNamespaceBulkDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON kvNamespaceBulkDeleteResponseEnvelopeJSON `json:"-"` -} - -// kvNamespaceBulkDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [KVNamespaceBulkDeleteResponseEnvelope] -type kvNamespaceBulkDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceBulkDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceBulkDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceBulkDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON kvNamespaceBulkDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// kvNamespaceBulkDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [KVNamespaceBulkDeleteResponseEnvelopeErrors] -type kvNamespaceBulkDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceBulkDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceBulkDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceBulkDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON kvNamespaceBulkDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// kvNamespaceBulkDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [KVNamespaceBulkDeleteResponseEnvelopeMessages] -type kvNamespaceBulkDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceBulkDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceBulkDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type KVNamespaceBulkDeleteResponseEnvelopeSuccess bool - -const ( - KVNamespaceBulkDeleteResponseEnvelopeSuccessTrue KVNamespaceBulkDeleteResponseEnvelopeSuccess = true -) diff --git a/kvnamespacebulk_test.go b/kvnamespacebulk_test.go deleted file mode 100644 index e6ef144e882..00000000000 --- a/kvnamespacebulk_test.go +++ /dev/null @@ -1,103 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestKVNamespaceBulkUpdate(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("user@example.com"), - ) - _, err := client.KV.Namespaces.Bulk.Update( - context.TODO(), - "0f2ac74b498b48028cb68387c421e279", - cloudflare.KVNamespaceBulkUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F([]cloudflare.KVNamespaceBulkUpdateParamsBody{{ - Base64: cloudflare.F(true), - Expiration: cloudflare.F(1578435000.000000), - ExpirationTTL: cloudflare.F(300.000000), - Key: cloudflare.F("My-Key"), - Metadata: cloudflare.F[any](map[string]interface{}{ - "someMetadataKey": "someMetadataValue", - }), - Value: cloudflare.F("Some string"), - }, { - Base64: cloudflare.F(true), - Expiration: cloudflare.F(1578435000.000000), - ExpirationTTL: cloudflare.F(300.000000), - Key: cloudflare.F("My-Key"), - Metadata: cloudflare.F[any](map[string]interface{}{ - "someMetadataKey": "someMetadataValue", - }), - Value: cloudflare.F("Some string"), - }, { - Base64: cloudflare.F(true), - Expiration: cloudflare.F(1578435000.000000), - ExpirationTTL: cloudflare.F(300.000000), - Key: cloudflare.F("My-Key"), - Metadata: cloudflare.F[any](map[string]interface{}{ - "someMetadataKey": "someMetadataValue", - }), - Value: cloudflare.F("Some string"), - }}), - }, - ) - 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 TestKVNamespaceBulkDelete(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("user@example.com"), - ) - _, err := client.KV.Namespaces.Bulk.Delete( - context.TODO(), - "0f2ac74b498b48028cb68387c421e279", - cloudflare.KVNamespaceBulkDeleteParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F([]string{"My-Key", "My-Key", "My-Key"}), - }, - ) - 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/kvnamespacekey.go b/kvnamespacekey.go deleted file mode 100644 index b28de6e34fe..00000000000 --- a/kvnamespacekey.go +++ /dev/null @@ -1,215 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// KVNamespaceKeyService 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 [NewKVNamespaceKeyService] method -// instead. -type KVNamespaceKeyService struct { - Options []option.RequestOption -} - -// NewKVNamespaceKeyService 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 NewKVNamespaceKeyService(opts ...option.RequestOption) (r *KVNamespaceKeyService) { - r = &KVNamespaceKeyService{} - r.Options = opts - return -} - -// Lists a namespace's keys. -func (r *KVNamespaceKeyService) List(ctx context.Context, namespaceID string, params KVNamespaceKeyListParams, opts ...option.RequestOption) (res *[]KVNamespaceKeyListResponse, err error) { - opts = append(r.Options[:], opts...) - var env KVNamespaceKeyListResponseEnvelope - path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/keys", params.AccountID, namespaceID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// A name for a value. A value stored under a given key may be retrieved via the -// same key. -type KVNamespaceKeyListResponse struct { - // A key's name. The name may be at most 512 bytes. All printable, non-whitespace - // characters are valid. Use percent-encoding to define key names as part of a URL. - Name string `json:"name,required"` - // The time, measured in number of seconds since the UNIX epoch, at which the key - // will expire. This property is omitted for keys that will not expire. - Expiration float64 `json:"expiration"` - // Arbitrary JSON that is associated with a key. - Metadata interface{} `json:"metadata"` - JSON kvNamespaceKeyListResponseJSON `json:"-"` -} - -// kvNamespaceKeyListResponseJSON contains the JSON metadata for the struct -// [KVNamespaceKeyListResponse] -type kvNamespaceKeyListResponseJSON struct { - Name apijson.Field - Expiration apijson.Field - Metadata apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceKeyListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceKeyListResponseJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceKeyListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Opaque token indicating the position from which to continue when requesting the - // next set of records if the amount of list results was limited by the limit - // parameter. A valid value for the cursor can be obtained from the `cursors` - // object in the `result_info` structure. - Cursor param.Field[string] `query:"cursor"` - // The number of keys to return. The cursor attribute may be used to iterate over - // the next batch of keys if there are more than the limit. - Limit param.Field[float64] `query:"limit"` - // A string prefix used to filter down which keys will be returned. Exact matches - // and any key names that begin with the prefix will be returned. - Prefix param.Field[string] `query:"prefix"` -} - -// URLQuery serializes [KVNamespaceKeyListParams]'s query parameters as -// `url.Values`. -func (r KVNamespaceKeyListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type KVNamespaceKeyListResponseEnvelope struct { - Errors []KVNamespaceKeyListResponseEnvelopeErrors `json:"errors,required"` - Messages []KVNamespaceKeyListResponseEnvelopeMessages `json:"messages,required"` - Result []KVNamespaceKeyListResponse `json:"result,required"` - // Whether the API call was successful - Success KVNamespaceKeyListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo KVNamespaceKeyListResponseEnvelopeResultInfo `json:"result_info"` - JSON kvNamespaceKeyListResponseEnvelopeJSON `json:"-"` -} - -// kvNamespaceKeyListResponseEnvelopeJSON contains the JSON metadata for the struct -// [KVNamespaceKeyListResponseEnvelope] -type kvNamespaceKeyListResponseEnvelopeJSON 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 *KVNamespaceKeyListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceKeyListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceKeyListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON kvNamespaceKeyListResponseEnvelopeErrorsJSON `json:"-"` -} - -// kvNamespaceKeyListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [KVNamespaceKeyListResponseEnvelopeErrors] -type kvNamespaceKeyListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceKeyListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceKeyListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceKeyListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON kvNamespaceKeyListResponseEnvelopeMessagesJSON `json:"-"` -} - -// kvNamespaceKeyListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [KVNamespaceKeyListResponseEnvelopeMessages] -type kvNamespaceKeyListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceKeyListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceKeyListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type KVNamespaceKeyListResponseEnvelopeSuccess bool - -const ( - KVNamespaceKeyListResponseEnvelopeSuccessTrue KVNamespaceKeyListResponseEnvelopeSuccess = true -) - -type KVNamespaceKeyListResponseEnvelopeResultInfo struct { - // Total results returned based on your list parameters. - Count float64 `json:"count"` - // Opaque token indicating the position from which to continue when requesting the - // next set of records if the amount of list results was limited by the limit - // parameter. A valid value for the cursor can be obtained from the cursors object - // in the result_info structure. - Cursor string `json:"cursor"` - JSON kvNamespaceKeyListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// kvNamespaceKeyListResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [KVNamespaceKeyListResponseEnvelopeResultInfo] -type kvNamespaceKeyListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Cursor apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceKeyListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceKeyListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/kvnamespacekey_test.go b/kvnamespacekey_test.go deleted file mode 100644 index 222c97439fb..00000000000 --- a/kvnamespacekey_test.go +++ /dev/null @@ -1,47 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestKVNamespaceKeyListWithOptionalParams(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("user@example.com"), - ) - _, err := client.KV.Namespaces.Keys.List( - context.TODO(), - "0f2ac74b498b48028cb68387c421e279", - cloudflare.KVNamespaceKeyListParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Cursor: cloudflare.F("6Ck1la0VxJ0djhidm1MdX2FyDGxLKVeeHZZmORS_8XeSuhz9SjIJRaSa2lnsF01tQOHrfTGAP3R5X1Kv5iVUuMbNKhWNAXHOl6ePB0TUL8nw"), - Limit: cloudflare.F(10.000000), - Prefix: cloudflare.F("My-Prefix"), - }, - ) - 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/kvnamespacemetadata.go b/kvnamespacemetadata.go deleted file mode 100644 index b1b0fbe4871..00000000000 --- a/kvnamespacemetadata.go +++ /dev/null @@ -1,136 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// KVNamespaceMetadataService 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 [NewKVNamespaceMetadataService] -// method instead. -type KVNamespaceMetadataService struct { - Options []option.RequestOption -} - -// NewKVNamespaceMetadataService 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 NewKVNamespaceMetadataService(opts ...option.RequestOption) (r *KVNamespaceMetadataService) { - r = &KVNamespaceMetadataService{} - r.Options = opts - return -} - -// Returns the metadata associated with the given key in the given namespace. Use -// URL-encoding to use special characters (for example, `:`, `!`, `%`) in the key -// name. -func (r *KVNamespaceMetadataService) Get(ctx context.Context, namespaceID string, keyName string, query KVNamespaceMetadataGetParams, opts ...option.RequestOption) (res *KVNamespaceMetadataGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env KVNamespaceMetadataGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/metadata/%s", query.AccountID, namespaceID, keyName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type KVNamespaceMetadataGetResponse = interface{} - -type KVNamespaceMetadataGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type KVNamespaceMetadataGetResponseEnvelope struct { - Errors []KVNamespaceMetadataGetResponseEnvelopeErrors `json:"errors,required"` - Messages []KVNamespaceMetadataGetResponseEnvelopeMessages `json:"messages,required"` - // Arbitrary JSON that is associated with a key. - Result KVNamespaceMetadataGetResponse `json:"result,required"` - // Whether the API call was successful - Success KVNamespaceMetadataGetResponseEnvelopeSuccess `json:"success,required"` - JSON kvNamespaceMetadataGetResponseEnvelopeJSON `json:"-"` -} - -// kvNamespaceMetadataGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [KVNamespaceMetadataGetResponseEnvelope] -type kvNamespaceMetadataGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceMetadataGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceMetadataGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceMetadataGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON kvNamespaceMetadataGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// kvNamespaceMetadataGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [KVNamespaceMetadataGetResponseEnvelopeErrors] -type kvNamespaceMetadataGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceMetadataGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceMetadataGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceMetadataGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON kvNamespaceMetadataGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// kvNamespaceMetadataGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [KVNamespaceMetadataGetResponseEnvelopeMessages] -type kvNamespaceMetadataGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceMetadataGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceMetadataGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type KVNamespaceMetadataGetResponseEnvelopeSuccess bool - -const ( - KVNamespaceMetadataGetResponseEnvelopeSuccessTrue KVNamespaceMetadataGetResponseEnvelopeSuccess = true -) diff --git a/kvnamespacemetadata_test.go b/kvnamespacemetadata_test.go deleted file mode 100644 index 720e74ac93d..00000000000 --- a/kvnamespacemetadata_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestKVNamespaceMetadataGet(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("user@example.com"), - ) - _, err := client.KV.Namespaces.Metadata.Get( - context.TODO(), - "0f2ac74b498b48028cb68387c421e279", - "My-Key", - cloudflare.KVNamespaceMetadataGetParams{ - AccountID: cloudflare.F("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/kvnamespacevalue.go b/kvnamespacevalue.go deleted file mode 100644 index 747460641d3..00000000000 --- a/kvnamespacevalue.go +++ /dev/null @@ -1,298 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// KVNamespaceValueService 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 [NewKVNamespaceValueService] method -// instead. -type KVNamespaceValueService struct { - Options []option.RequestOption -} - -// NewKVNamespaceValueService 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 NewKVNamespaceValueService(opts ...option.RequestOption) (r *KVNamespaceValueService) { - r = &KVNamespaceValueService{} - r.Options = opts - return -} - -// Write a value identified by a key. Use URL-encoding to use special characters -// (for example, `:`, `!`, `%`) in the key name. Body should be the value to be -// stored along with JSON metadata to be associated with the key/value pair. -// Existing values, expirations, and metadata will be overwritten. If neither -// `expiration` nor `expiration_ttl` is specified, the key-value pair will never -// expire. If both are set, `expiration_ttl` is used and `expiration` is ignored. -func (r *KVNamespaceValueService) Update(ctx context.Context, namespaceID string, keyName string, params KVNamespaceValueUpdateParams, opts ...option.RequestOption) (res *KVNamespaceValueUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env KVNamespaceValueUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/values/%s", params.AccountID, namespaceID, keyName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Remove a KV pair from the namespace. Use URL-encoding to use special characters -// (for example, `:`, `!`, `%`) in the key name. -func (r *KVNamespaceValueService) Delete(ctx context.Context, namespaceID string, keyName string, body KVNamespaceValueDeleteParams, opts ...option.RequestOption) (res *KVNamespaceValueDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env KVNamespaceValueDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/values/%s", body.AccountID, namespaceID, keyName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Returns the value associated with the given key in the given namespace. Use -// URL-encoding to use special characters (for example, `:`, `!`, `%`) in the key -// name. If the KV-pair is set to expire at some point, the expiration time as -// measured in seconds since the UNIX epoch will be returned in the `expiration` -// response header. -func (r *KVNamespaceValueService) Get(ctx context.Context, namespaceID string, keyName string, query KVNamespaceValueGetParams, opts ...option.RequestOption) (res *string, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("accounts/%s/storage/kv/namespaces/%s/values/%s", query.AccountID, namespaceID, keyName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -// Union satisfied by [KVNamespaceValueUpdateResponseUnknown] or -// [shared.UnionString]. -type KVNamespaceValueUpdateResponse interface { - ImplementsKVNamespaceValueUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*KVNamespaceValueUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [KVNamespaceValueDeleteResponseUnknown] or -// [shared.UnionString]. -type KVNamespaceValueDeleteResponse interface { - ImplementsKVNamespaceValueDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*KVNamespaceValueDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type KVNamespaceValueUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Arbitrary JSON to be associated with a key/value pair. - Metadata param.Field[string] `json:"metadata,required"` - // A byte sequence to be stored, up to 25 MiB in length. - Value param.Field[string] `json:"value,required"` -} - -func (r KVNamespaceValueUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type KVNamespaceValueUpdateResponseEnvelope struct { - Errors []KVNamespaceValueUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []KVNamespaceValueUpdateResponseEnvelopeMessages `json:"messages,required"` - Result KVNamespaceValueUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success KVNamespaceValueUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON kvNamespaceValueUpdateResponseEnvelopeJSON `json:"-"` -} - -// kvNamespaceValueUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [KVNamespaceValueUpdateResponseEnvelope] -type kvNamespaceValueUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceValueUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceValueUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceValueUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON kvNamespaceValueUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// kvNamespaceValueUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [KVNamespaceValueUpdateResponseEnvelopeErrors] -type kvNamespaceValueUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceValueUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceValueUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceValueUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON kvNamespaceValueUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// kvNamespaceValueUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [KVNamespaceValueUpdateResponseEnvelopeMessages] -type kvNamespaceValueUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceValueUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceValueUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type KVNamespaceValueUpdateResponseEnvelopeSuccess bool - -const ( - KVNamespaceValueUpdateResponseEnvelopeSuccessTrue KVNamespaceValueUpdateResponseEnvelopeSuccess = true -) - -type KVNamespaceValueDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type KVNamespaceValueDeleteResponseEnvelope struct { - Errors []KVNamespaceValueDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []KVNamespaceValueDeleteResponseEnvelopeMessages `json:"messages,required"` - Result KVNamespaceValueDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success KVNamespaceValueDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON kvNamespaceValueDeleteResponseEnvelopeJSON `json:"-"` -} - -// kvNamespaceValueDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [KVNamespaceValueDeleteResponseEnvelope] -type kvNamespaceValueDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceValueDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceValueDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceValueDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON kvNamespaceValueDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// kvNamespaceValueDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [KVNamespaceValueDeleteResponseEnvelopeErrors] -type kvNamespaceValueDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceValueDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceValueDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type KVNamespaceValueDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON kvNamespaceValueDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// kvNamespaceValueDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [KVNamespaceValueDeleteResponseEnvelopeMessages] -type kvNamespaceValueDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *KVNamespaceValueDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r kvNamespaceValueDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type KVNamespaceValueDeleteResponseEnvelopeSuccess bool - -const ( - KVNamespaceValueDeleteResponseEnvelopeSuccessTrue KVNamespaceValueDeleteResponseEnvelopeSuccess = true -) - -type KVNamespaceValueGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} diff --git a/kvnamespacevalue_test.go b/kvnamespacevalue_test.go deleted file mode 100644 index 722dc1b565a..00000000000 --- a/kvnamespacevalue_test.go +++ /dev/null @@ -1,109 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestKVNamespaceValueUpdate(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("user@example.com"), - ) - _, err := client.KV.Namespaces.Values.Update( - context.TODO(), - "0f2ac74b498b48028cb68387c421e279", - "My-Key", - cloudflare.KVNamespaceValueUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Metadata: cloudflare.F("{\"someMetadataKey\": \"someMetadataValue\"}"), - Value: cloudflare.F("Some Value"), - }, - ) - 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 TestKVNamespaceValueDelete(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("user@example.com"), - ) - _, err := client.KV.Namespaces.Values.Delete( - context.TODO(), - "0f2ac74b498b48028cb68387c421e279", - "My-Key", - cloudflare.KVNamespaceValueDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestKVNamespaceValueGet(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("user@example.com"), - ) - _, err := client.KV.Namespaces.Values.Get( - context.TODO(), - "0f2ac74b498b48028cb68387c421e279", - "My-Key", - cloudflare.KVNamespaceValueGetParams{ - AccountID: cloudflare.F("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/load_balancers/aliases.go b/load_balancers/aliases.go new file mode 100644 index 00000000000..90a73d005b9 --- /dev/null +++ b/load_balancers/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/load_balancers/loadbalancer.go b/load_balancers/loadbalancer.go new file mode 100644 index 00000000000..be8ab70e1df --- /dev/null +++ b/load_balancers/loadbalancer.go @@ -0,0 +1,4075 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// LoadBalancerService 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 [NewLoadBalancerService] method +// instead. +type LoadBalancerService struct { + Options []option.RequestOption + Monitors *MonitorService + Pools *PoolService + Previews *PreviewService + Regions *RegionService + Searches *SearchService +} + +// NewLoadBalancerService 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 NewLoadBalancerService(opts ...option.RequestOption) (r *LoadBalancerService) { + r = &LoadBalancerService{} + r.Options = opts + r.Monitors = NewMonitorService(opts...) + r.Pools = NewPoolService(opts...) + r.Previews = NewPreviewService(opts...) + r.Regions = NewRegionService(opts...) + r.Searches = NewSearchService(opts...) + return +} + +// Create a new load balancer. +func (r *LoadBalancerService) New(ctx context.Context, params LoadBalancerNewParams, opts ...option.RequestOption) (res *LoadBalancer, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerNewResponseEnvelope + path := fmt.Sprintf("zones/%s/load_balancers", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update a configured load balancer. +func (r *LoadBalancerService) Update(ctx context.Context, loadBalancerID string, params LoadBalancerUpdateParams, opts ...option.RequestOption) (res *LoadBalancer, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/load_balancers/%s", params.ZoneID, loadBalancerID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List configured load balancers. +func (r *LoadBalancerService) List(ctx context.Context, query LoadBalancerListParams, opts ...option.RequestOption) (res *[]LoadBalancer, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerListResponseEnvelope + path := fmt.Sprintf("zones/%s/load_balancers", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a configured load balancer. +func (r *LoadBalancerService) Delete(ctx context.Context, loadBalancerID string, body LoadBalancerDeleteParams, opts ...option.RequestOption) (res *LoadBalancerDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/load_balancers/%s", body.ZoneID, loadBalancerID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Apply changes to an existing load balancer, overwriting the supplied properties. +func (r *LoadBalancerService) Edit(ctx context.Context, loadBalancerID string, params LoadBalancerEditParams, opts ...option.RequestOption) (res *LoadBalancer, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerEditResponseEnvelope + path := fmt.Sprintf("zones/%s/load_balancers/%s", params.ZoneID, loadBalancerID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch a single configured load balancer. +func (r *LoadBalancerService) Get(ctx context.Context, loadBalancerID string, query LoadBalancerGetParams, opts ...option.RequestOption) (res *LoadBalancer, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerGetResponseEnvelope + path := fmt.Sprintf("zones/%s/load_balancers/%s", query.ZoneID, loadBalancerID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type LoadBalancer struct { + ID string `json:"id"` + // Controls features that modify the routing of requests to pools and origins in + // response to dynamic conditions, such as during the interval between active + // health monitoring requests. For example, zero-downtime failover occurs + // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 + // response codes. If there is another healthy origin in the same pool, the request + // is retried once against this alternate origin. + AdaptiveRouting LoadBalancerAdaptiveRouting `json:"adaptive_routing"` + // A mapping of country codes to a list of pool IDs (ordered by their failover + // priority) for the given country. Any country not explicitly defined will fall + // back to using the corresponding region_pool mapping if it exists else to + // default_pools. + CountryPools interface{} `json:"country_pools"` + CreatedOn time.Time `json:"created_on" format:"date-time"` + // A list of pool IDs ordered by their failover priority. Pools defined here are + // used by default, or when region_pools are not configured for a given region. + DefaultPools []string `json:"default_pools"` + // Object description. + Description string `json:"description"` + // Whether to enable (the default) this load balancer. + Enabled bool `json:"enabled"` + // The pool ID to use when all other pools are detected as unhealthy. + FallbackPool interface{} `json:"fallback_pool"` + // Controls location-based steering for non-proxied requests. See `steering_policy` + // to learn how steering is affected. + LocationStrategy LoadBalancerLocationStrategy `json:"location_strategy"` + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // The DNS hostname to associate with your Load Balancer. If this hostname already + // exists as a DNS record in Cloudflare's DNS, the Load Balancer will take + // precedence and the DNS record will not be used. + Name string `json:"name"` + // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs + // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not + // explicitly defined will fall back to using the corresponding country_pool, then + // region_pool mapping if it exists else to default_pools. + PopPools interface{} `json:"pop_pools"` + // Whether the hostname should be gray clouded (false) or orange clouded (true). + Proxied bool `json:"proxied"` + // Configures pool weights. + // + // - `steering_policy="random"`: A random pool is selected with probability + // proportional to pool weights. + // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each + // pool's outstanding requests. + // - `steering_policy="least_connections"`: Use pool weights to scale each pool's + // open connections. + RandomSteering LoadBalancerRandomSteering `json:"random_steering"` + // A mapping of region codes to a list of pool IDs (ordered by their failover + // priority) for the given region. Any regions not explicitly defined will fall + // back to using default_pools. + RegionPools interface{} `json:"region_pools"` + // BETA Field Not General Access: A list of rules for this load balancer to + // execute. + Rules []LoadBalancerRule `json:"rules"` + // Specifies the type of session affinity the load balancer should use unless + // specified as `"none"` or "" (default). The supported types are: + // + // - `"cookie"`: On the first request to a proxied load balancer, a cookie is + // generated, encoding information of which origin the request will be forwarded + // to. Subsequent requests, by the same client to the same load balancer, will be + // sent to the origin server the cookie encodes, for the duration of the cookie + // and as long as the origin server remains healthy. If the cookie has expired or + // the origin server is unhealthy, then a new origin server is calculated and + // used. + // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin + // selection is stable and based on the client's ip address. + // - `"header"`: On the first request to a proxied load balancer, a session key + // based on the configured HTTP headers (see + // `session_affinity_attributes.headers`) is generated, encoding the request + // headers used for storing in the load balancer session state which origin the + // request will be forwarded to. Subsequent requests to the load balancer with + // the same headers will be sent to the same origin server, for the duration of + // the session and as long as the origin server remains healthy. If the session + // has been idle for the duration of `session_affinity_ttl` seconds or the origin + // server is unhealthy, then a new origin server is calculated and used. See + // `headers` in `session_affinity_attributes` for additional required + // configuration. + SessionAffinity LoadBalancerSessionAffinity `json:"session_affinity"` + // Configures attributes for session affinity. + SessionAffinityAttributes LoadBalancerSessionAffinityAttributes `json:"session_affinity_attributes"` + // Time, in seconds, until a client's session expires after being created. Once the + // expiry time has been reached, subsequent requests may get sent to a different + // origin server. The accepted ranges per `session_affinity` policy are: + // + // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used + // unless explicitly set. The accepted range of values is between [1800, 604800]. + // - `"header"`: The current default of 1800 seconds will be used unless explicitly + // set. The accepted range of values is between [30, 3600]. Note: With session + // affinity by header, sessions only expire after they haven't been used for the + // number of seconds specified. + SessionAffinityTTL float64 `json:"session_affinity_ttl"` + // Steering Policy for this load balancer. + // + // - `"off"`: Use `default_pools`. + // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied + // requests, the country for `country_pools` is determined by + // `location_strategy`. + // - `"random"`: Select a pool randomly. + // - `"dynamic_latency"`: Use round trip time to select the closest pool in + // default_pools (requires pool health checks). + // - `"proximity"`: Use the pools' latitude and longitude to select the closest + // pool using the Cloudflare PoP location for proxied requests or the location + // determined by `location_strategy` for non-proxied requests. + // - `"least_outstanding_requests"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of outstanding + // requests. Pools with more pending requests are weighted proportionately less + // relative to others. + // - `"least_connections"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of open connections. + // Pools with more open connections are weighted proportionately less relative to + // others. Supported for HTTP/1 and HTTP/2 connections. + // - `""`: Will map to `"geo"` if you use + // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. + SteeringPolicy LoadBalancerSteeringPolicy `json:"steering_policy"` + // Time to live (TTL) of the DNS entry for the IP address returned by this load + // balancer. This only applies to gray-clouded (unproxied) load balancers. + TTL float64 `json:"ttl"` + JSON loadBalancerJSON `json:"-"` +} + +// loadBalancerJSON contains the JSON metadata for the struct [LoadBalancer] +type loadBalancerJSON struct { + ID apijson.Field + AdaptiveRouting apijson.Field + CountryPools apijson.Field + CreatedOn apijson.Field + DefaultPools apijson.Field + Description apijson.Field + Enabled apijson.Field + FallbackPool apijson.Field + LocationStrategy apijson.Field + ModifiedOn apijson.Field + Name apijson.Field + PopPools apijson.Field + Proxied apijson.Field + RandomSteering apijson.Field + RegionPools apijson.Field + Rules apijson.Field + SessionAffinity apijson.Field + SessionAffinityAttributes apijson.Field + SessionAffinityTTL apijson.Field + SteeringPolicy apijson.Field + TTL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancer) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerJSON) RawJSON() string { + return r.raw +} + +// Controls features that modify the routing of requests to pools and origins in +// response to dynamic conditions, such as during the interval between active +// health monitoring requests. For example, zero-downtime failover occurs +// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 +// response codes. If there is another healthy origin in the same pool, the request +// is retried once against this alternate origin. +type LoadBalancerAdaptiveRouting struct { + // Extends zero-downtime failover of requests to healthy origins from alternate + // pools, when no healthy alternate exists in the same pool, according to the + // failover order defined by traffic and origin steering. When set false (the + // default) zero-downtime failover will only occur between origins within the same + // pool. See `session_affinity_attributes` for control over when sessions are + // broken or reassigned. + FailoverAcrossPools bool `json:"failover_across_pools"` + JSON loadBalancerAdaptiveRoutingJSON `json:"-"` +} + +// loadBalancerAdaptiveRoutingJSON contains the JSON metadata for the struct +// [LoadBalancerAdaptiveRouting] +type loadBalancerAdaptiveRoutingJSON struct { + FailoverAcrossPools apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerAdaptiveRouting) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerAdaptiveRoutingJSON) RawJSON() string { + return r.raw +} + +// Controls location-based steering for non-proxied requests. See `steering_policy` +// to learn how steering is affected. +type LoadBalancerLocationStrategy struct { + // Determines the authoritative location when ECS is not preferred, does not exist + // in the request, or its GeoIP lookup is unsuccessful. + // + // - `"pop"`: Use the Cloudflare PoP location. + // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is + // unsuccessful, use the Cloudflare PoP location. + Mode LoadBalancerLocationStrategyMode `json:"mode"` + // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the + // authoritative location. + // + // - `"always"`: Always prefer ECS. + // - `"never"`: Never prefer ECS. + // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. + // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. + PreferEcs LoadBalancerLocationStrategyPreferEcs `json:"prefer_ecs"` + JSON loadBalancerLocationStrategyJSON `json:"-"` +} + +// loadBalancerLocationStrategyJSON contains the JSON metadata for the struct +// [LoadBalancerLocationStrategy] +type loadBalancerLocationStrategyJSON struct { + Mode apijson.Field + PreferEcs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerLocationStrategy) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerLocationStrategyJSON) RawJSON() string { + return r.raw +} + +// Determines the authoritative location when ECS is not preferred, does not exist +// in the request, or its GeoIP lookup is unsuccessful. +// +// - `"pop"`: Use the Cloudflare PoP location. +// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is +// unsuccessful, use the Cloudflare PoP location. +type LoadBalancerLocationStrategyMode string + +const ( + LoadBalancerLocationStrategyModePop LoadBalancerLocationStrategyMode = "pop" + LoadBalancerLocationStrategyModeResolverIP LoadBalancerLocationStrategyMode = "resolver_ip" +) + +// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the +// authoritative location. +// +// - `"always"`: Always prefer ECS. +// - `"never"`: Never prefer ECS. +// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. +// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. +type LoadBalancerLocationStrategyPreferEcs string + +const ( + LoadBalancerLocationStrategyPreferEcsAlways LoadBalancerLocationStrategyPreferEcs = "always" + LoadBalancerLocationStrategyPreferEcsNever LoadBalancerLocationStrategyPreferEcs = "never" + LoadBalancerLocationStrategyPreferEcsProximity LoadBalancerLocationStrategyPreferEcs = "proximity" + LoadBalancerLocationStrategyPreferEcsGeo LoadBalancerLocationStrategyPreferEcs = "geo" +) + +// Configures pool weights. +// +// - `steering_policy="random"`: A random pool is selected with probability +// proportional to pool weights. +// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each +// pool's outstanding requests. +// - `steering_policy="least_connections"`: Use pool weights to scale each pool's +// open connections. +type LoadBalancerRandomSteering struct { + // The default weight for pools in the load balancer that are not specified in the + // pool_weights map. + DefaultWeight float64 `json:"default_weight"` + // A mapping of pool IDs to custom weights. The weight is relative to other pools + // in the load balancer. + PoolWeights interface{} `json:"pool_weights"` + JSON loadBalancerRandomSteeringJSON `json:"-"` +} + +// loadBalancerRandomSteeringJSON contains the JSON metadata for the struct +// [LoadBalancerRandomSteering] +type loadBalancerRandomSteeringJSON struct { + DefaultWeight apijson.Field + PoolWeights apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerRandomSteering) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerRandomSteeringJSON) RawJSON() string { + return r.raw +} + +// A rule object containing conditions and overrides for this load balancer to +// evaluate. +type LoadBalancerRule struct { + // The condition expressions to evaluate. If the condition evaluates to true, the + // overrides or fixed_response in this rule will be applied. An empty condition is + // always true. For more details on condition expressions, please see + // https://developers.cloudflare.com/load-balancing/understand-basics/load-balancing-rules/expressions. + Condition string `json:"condition"` + // Disable this specific rule. It will no longer be evaluated by this load + // balancer. + Disabled bool `json:"disabled"` + // A collection of fields used to directly respond to the eyeball instead of + // routing to a pool. If a fixed_response is supplied the rule will be marked as + // terminates. + FixedResponse LoadBalancerRulesFixedResponse `json:"fixed_response"` + // Name of this rule. Only used for human readability. + Name string `json:"name"` + // A collection of overrides to apply to the load balancer when this rule's + // condition is true. All fields are optional. + Overrides LoadBalancerRulesOverrides `json:"overrides"` + // The order in which rules should be executed in relation to each other. Lower + // values are executed first. Values do not need to be sequential. If no value is + // provided for any rule the array order of the rules field will be used to assign + // a priority. + Priority int64 `json:"priority"` + // If this rule's condition is true, this causes rule evaluation to stop after + // processing this rule. + Terminates bool `json:"terminates"` + JSON loadBalancerRuleJSON `json:"-"` +} + +// loadBalancerRuleJSON contains the JSON metadata for the struct +// [LoadBalancerRule] +type loadBalancerRuleJSON struct { + Condition apijson.Field + Disabled apijson.Field + FixedResponse apijson.Field + Name apijson.Field + Overrides apijson.Field + Priority apijson.Field + Terminates apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerRuleJSON) RawJSON() string { + return r.raw +} + +// A collection of fields used to directly respond to the eyeball instead of +// routing to a pool. If a fixed_response is supplied the rule will be marked as +// terminates. +type LoadBalancerRulesFixedResponse struct { + // The http 'Content-Type' header to include in the response. + ContentType string `json:"content_type"` + // The http 'Location' header to include in the response. + Location string `json:"location"` + // Text to include as the http body. + MessageBody string `json:"message_body"` + // The http status code to respond with. + StatusCode int64 `json:"status_code"` + JSON loadBalancerRulesFixedResponseJSON `json:"-"` +} + +// loadBalancerRulesFixedResponseJSON contains the JSON metadata for the struct +// [LoadBalancerRulesFixedResponse] +type loadBalancerRulesFixedResponseJSON struct { + ContentType apijson.Field + Location apijson.Field + MessageBody apijson.Field + StatusCode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerRulesFixedResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerRulesFixedResponseJSON) RawJSON() string { + return r.raw +} + +// A collection of overrides to apply to the load balancer when this rule's +// condition is true. All fields are optional. +type LoadBalancerRulesOverrides struct { + // Controls features that modify the routing of requests to pools and origins in + // response to dynamic conditions, such as during the interval between active + // health monitoring requests. For example, zero-downtime failover occurs + // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 + // response codes. If there is another healthy origin in the same pool, the request + // is retried once against this alternate origin. + AdaptiveRouting LoadBalancerRulesOverridesAdaptiveRouting `json:"adaptive_routing"` + // A mapping of country codes to a list of pool IDs (ordered by their failover + // priority) for the given country. Any country not explicitly defined will fall + // back to using the corresponding region_pool mapping if it exists else to + // default_pools. + CountryPools interface{} `json:"country_pools"` + // A list of pool IDs ordered by their failover priority. Pools defined here are + // used by default, or when region_pools are not configured for a given region. + DefaultPools []string `json:"default_pools"` + // The pool ID to use when all other pools are detected as unhealthy. + FallbackPool interface{} `json:"fallback_pool"` + // Controls location-based steering for non-proxied requests. See `steering_policy` + // to learn how steering is affected. + LocationStrategy LoadBalancerRulesOverridesLocationStrategy `json:"location_strategy"` + // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs + // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not + // explicitly defined will fall back to using the corresponding country_pool, then + // region_pool mapping if it exists else to default_pools. + PopPools interface{} `json:"pop_pools"` + // Configures pool weights. + // + // - `steering_policy="random"`: A random pool is selected with probability + // proportional to pool weights. + // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each + // pool's outstanding requests. + // - `steering_policy="least_connections"`: Use pool weights to scale each pool's + // open connections. + RandomSteering LoadBalancerRulesOverridesRandomSteering `json:"random_steering"` + // A mapping of region codes to a list of pool IDs (ordered by their failover + // priority) for the given region. Any regions not explicitly defined will fall + // back to using default_pools. + RegionPools interface{} `json:"region_pools"` + // Specifies the type of session affinity the load balancer should use unless + // specified as `"none"` or "" (default). The supported types are: + // + // - `"cookie"`: On the first request to a proxied load balancer, a cookie is + // generated, encoding information of which origin the request will be forwarded + // to. Subsequent requests, by the same client to the same load balancer, will be + // sent to the origin server the cookie encodes, for the duration of the cookie + // and as long as the origin server remains healthy. If the cookie has expired or + // the origin server is unhealthy, then a new origin server is calculated and + // used. + // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin + // selection is stable and based on the client's ip address. + // - `"header"`: On the first request to a proxied load balancer, a session key + // based on the configured HTTP headers (see + // `session_affinity_attributes.headers`) is generated, encoding the request + // headers used for storing in the load balancer session state which origin the + // request will be forwarded to. Subsequent requests to the load balancer with + // the same headers will be sent to the same origin server, for the duration of + // the session and as long as the origin server remains healthy. If the session + // has been idle for the duration of `session_affinity_ttl` seconds or the origin + // server is unhealthy, then a new origin server is calculated and used. See + // `headers` in `session_affinity_attributes` for additional required + // configuration. + SessionAffinity LoadBalancerRulesOverridesSessionAffinity `json:"session_affinity"` + // Configures attributes for session affinity. + SessionAffinityAttributes LoadBalancerRulesOverridesSessionAffinityAttributes `json:"session_affinity_attributes"` + // Time, in seconds, until a client's session expires after being created. Once the + // expiry time has been reached, subsequent requests may get sent to a different + // origin server. The accepted ranges per `session_affinity` policy are: + // + // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used + // unless explicitly set. The accepted range of values is between [1800, 604800]. + // - `"header"`: The current default of 1800 seconds will be used unless explicitly + // set. The accepted range of values is between [30, 3600]. Note: With session + // affinity by header, sessions only expire after they haven't been used for the + // number of seconds specified. + SessionAffinityTTL float64 `json:"session_affinity_ttl"` + // Steering Policy for this load balancer. + // + // - `"off"`: Use `default_pools`. + // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied + // requests, the country for `country_pools` is determined by + // `location_strategy`. + // - `"random"`: Select a pool randomly. + // - `"dynamic_latency"`: Use round trip time to select the closest pool in + // default_pools (requires pool health checks). + // - `"proximity"`: Use the pools' latitude and longitude to select the closest + // pool using the Cloudflare PoP location for proxied requests or the location + // determined by `location_strategy` for non-proxied requests. + // - `"least_outstanding_requests"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of outstanding + // requests. Pools with more pending requests are weighted proportionately less + // relative to others. + // - `"least_connections"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of open connections. + // Pools with more open connections are weighted proportionately less relative to + // others. Supported for HTTP/1 and HTTP/2 connections. + // - `""`: Will map to `"geo"` if you use + // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. + SteeringPolicy LoadBalancerRulesOverridesSteeringPolicy `json:"steering_policy"` + // Time to live (TTL) of the DNS entry for the IP address returned by this load + // balancer. This only applies to gray-clouded (unproxied) load balancers. + TTL float64 `json:"ttl"` + JSON loadBalancerRulesOverridesJSON `json:"-"` +} + +// loadBalancerRulesOverridesJSON contains the JSON metadata for the struct +// [LoadBalancerRulesOverrides] +type loadBalancerRulesOverridesJSON struct { + AdaptiveRouting apijson.Field + CountryPools apijson.Field + DefaultPools apijson.Field + FallbackPool apijson.Field + LocationStrategy apijson.Field + PopPools apijson.Field + RandomSteering apijson.Field + RegionPools apijson.Field + SessionAffinity apijson.Field + SessionAffinityAttributes apijson.Field + SessionAffinityTTL apijson.Field + SteeringPolicy apijson.Field + TTL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerRulesOverrides) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerRulesOverridesJSON) RawJSON() string { + return r.raw +} + +// Controls features that modify the routing of requests to pools and origins in +// response to dynamic conditions, such as during the interval between active +// health monitoring requests. For example, zero-downtime failover occurs +// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 +// response codes. If there is another healthy origin in the same pool, the request +// is retried once against this alternate origin. +type LoadBalancerRulesOverridesAdaptiveRouting struct { + // Extends zero-downtime failover of requests to healthy origins from alternate + // pools, when no healthy alternate exists in the same pool, according to the + // failover order defined by traffic and origin steering. When set false (the + // default) zero-downtime failover will only occur between origins within the same + // pool. See `session_affinity_attributes` for control over when sessions are + // broken or reassigned. + FailoverAcrossPools bool `json:"failover_across_pools"` + JSON loadBalancerRulesOverridesAdaptiveRoutingJSON `json:"-"` +} + +// loadBalancerRulesOverridesAdaptiveRoutingJSON contains the JSON metadata for the +// struct [LoadBalancerRulesOverridesAdaptiveRouting] +type loadBalancerRulesOverridesAdaptiveRoutingJSON struct { + FailoverAcrossPools apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerRulesOverridesAdaptiveRouting) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerRulesOverridesAdaptiveRoutingJSON) RawJSON() string { + return r.raw +} + +// Controls location-based steering for non-proxied requests. See `steering_policy` +// to learn how steering is affected. +type LoadBalancerRulesOverridesLocationStrategy struct { + // Determines the authoritative location when ECS is not preferred, does not exist + // in the request, or its GeoIP lookup is unsuccessful. + // + // - `"pop"`: Use the Cloudflare PoP location. + // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is + // unsuccessful, use the Cloudflare PoP location. + Mode LoadBalancerRulesOverridesLocationStrategyMode `json:"mode"` + // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the + // authoritative location. + // + // - `"always"`: Always prefer ECS. + // - `"never"`: Never prefer ECS. + // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. + // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. + PreferEcs LoadBalancerRulesOverridesLocationStrategyPreferEcs `json:"prefer_ecs"` + JSON loadBalancerRulesOverridesLocationStrategyJSON `json:"-"` +} + +// loadBalancerRulesOverridesLocationStrategyJSON contains the JSON metadata for +// the struct [LoadBalancerRulesOverridesLocationStrategy] +type loadBalancerRulesOverridesLocationStrategyJSON struct { + Mode apijson.Field + PreferEcs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerRulesOverridesLocationStrategy) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerRulesOverridesLocationStrategyJSON) RawJSON() string { + return r.raw +} + +// Determines the authoritative location when ECS is not preferred, does not exist +// in the request, or its GeoIP lookup is unsuccessful. +// +// - `"pop"`: Use the Cloudflare PoP location. +// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is +// unsuccessful, use the Cloudflare PoP location. +type LoadBalancerRulesOverridesLocationStrategyMode string + +const ( + LoadBalancerRulesOverridesLocationStrategyModePop LoadBalancerRulesOverridesLocationStrategyMode = "pop" + LoadBalancerRulesOverridesLocationStrategyModeResolverIP LoadBalancerRulesOverridesLocationStrategyMode = "resolver_ip" +) + +// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the +// authoritative location. +// +// - `"always"`: Always prefer ECS. +// - `"never"`: Never prefer ECS. +// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. +// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. +type LoadBalancerRulesOverridesLocationStrategyPreferEcs string + +const ( + LoadBalancerRulesOverridesLocationStrategyPreferEcsAlways LoadBalancerRulesOverridesLocationStrategyPreferEcs = "always" + LoadBalancerRulesOverridesLocationStrategyPreferEcsNever LoadBalancerRulesOverridesLocationStrategyPreferEcs = "never" + LoadBalancerRulesOverridesLocationStrategyPreferEcsProximity LoadBalancerRulesOverridesLocationStrategyPreferEcs = "proximity" + LoadBalancerRulesOverridesLocationStrategyPreferEcsGeo LoadBalancerRulesOverridesLocationStrategyPreferEcs = "geo" +) + +// Configures pool weights. +// +// - `steering_policy="random"`: A random pool is selected with probability +// proportional to pool weights. +// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each +// pool's outstanding requests. +// - `steering_policy="least_connections"`: Use pool weights to scale each pool's +// open connections. +type LoadBalancerRulesOverridesRandomSteering struct { + // The default weight for pools in the load balancer that are not specified in the + // pool_weights map. + DefaultWeight float64 `json:"default_weight"` + // A mapping of pool IDs to custom weights. The weight is relative to other pools + // in the load balancer. + PoolWeights interface{} `json:"pool_weights"` + JSON loadBalancerRulesOverridesRandomSteeringJSON `json:"-"` +} + +// loadBalancerRulesOverridesRandomSteeringJSON contains the JSON metadata for the +// struct [LoadBalancerRulesOverridesRandomSteering] +type loadBalancerRulesOverridesRandomSteeringJSON struct { + DefaultWeight apijson.Field + PoolWeights apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerRulesOverridesRandomSteering) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerRulesOverridesRandomSteeringJSON) RawJSON() string { + return r.raw +} + +// Specifies the type of session affinity the load balancer should use unless +// specified as `"none"` or "" (default). The supported types are: +// +// - `"cookie"`: On the first request to a proxied load balancer, a cookie is +// generated, encoding information of which origin the request will be forwarded +// to. Subsequent requests, by the same client to the same load balancer, will be +// sent to the origin server the cookie encodes, for the duration of the cookie +// and as long as the origin server remains healthy. If the cookie has expired or +// the origin server is unhealthy, then a new origin server is calculated and +// used. +// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin +// selection is stable and based on the client's ip address. +// - `"header"`: On the first request to a proxied load balancer, a session key +// based on the configured HTTP headers (see +// `session_affinity_attributes.headers`) is generated, encoding the request +// headers used for storing in the load balancer session state which origin the +// request will be forwarded to. Subsequent requests to the load balancer with +// the same headers will be sent to the same origin server, for the duration of +// the session and as long as the origin server remains healthy. If the session +// has been idle for the duration of `session_affinity_ttl` seconds or the origin +// server is unhealthy, then a new origin server is calculated and used. See +// `headers` in `session_affinity_attributes` for additional required +// configuration. +type LoadBalancerRulesOverridesSessionAffinity string + +const ( + LoadBalancerRulesOverridesSessionAffinityNone LoadBalancerRulesOverridesSessionAffinity = "none" + LoadBalancerRulesOverridesSessionAffinityCookie LoadBalancerRulesOverridesSessionAffinity = "cookie" + LoadBalancerRulesOverridesSessionAffinityIPCookie LoadBalancerRulesOverridesSessionAffinity = "ip_cookie" + LoadBalancerRulesOverridesSessionAffinityHeader LoadBalancerRulesOverridesSessionAffinity = "header" + LoadBalancerRulesOverridesSessionAffinityEmpty LoadBalancerRulesOverridesSessionAffinity = "\"\"" +) + +// Configures attributes for session affinity. +type LoadBalancerRulesOverridesSessionAffinityAttributes struct { + // Configures the drain duration in seconds. This field is only used when session + // affinity is enabled on the load balancer. + DrainDuration float64 `json:"drain_duration"` + // Configures the names of HTTP headers to base session affinity on when header + // `session_affinity` is enabled. At least one HTTP header name must be provided. + // To specify the exact cookies to be used, include an item in the following + // format: `"cookie:,"` (example) where everything + // after the colon is a comma-separated list of cookie names. Providing only + // `"cookie"` will result in all cookies being used. The default max number of HTTP + // header names that can be provided depends on your plan: 5 for Enterprise, 1 for + // all other plans. + Headers []string `json:"headers"` + // When header `session_affinity` is enabled, this option can be used to specify + // how HTTP headers on load balancing requests will be used. The supported values + // are: + // + // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers + // specified by the `headers` session affinity attribute, otherwise sessions + // aren't created. + // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP + // headers specified by the `headers` session affinity attribute, otherwise + // sessions aren't created. + RequireAllHeaders bool `json:"require_all_headers"` + // Configures the SameSite attribute on session affinity cookie. Value "Auto" will + // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: + // when using value "None", the secure attribute can not be set to "Never". + Samesite LoadBalancerRulesOverridesSessionAffinityAttributesSamesite `json:"samesite"` + // Configures the Secure attribute on session affinity cookie. Value "Always" + // indicates the Secure attribute will be set in the Set-Cookie header, "Never" + // indicates the Secure attribute will not be set, and "Auto" will set the Secure + // attribute depending if Always Use HTTPS is enabled. + Secure LoadBalancerRulesOverridesSessionAffinityAttributesSecure `json:"secure"` + // Configures the zero-downtime failover between origins within a pool when session + // affinity is enabled. This feature is currently incompatible with Argo, Tiered + // Cache, and Bandwidth Alliance. The supported values are: + // + // - `"none"`: No failover takes place for sessions pinned to the origin (default). + // - `"temporary"`: Traffic will be sent to another other healthy origin until the + // originally pinned origin is available; note that this can potentially result + // in heavy origin flapping. + // - `"sticky"`: The session affinity cookie is updated and subsequent requests are + // sent to the new origin. Note: Zero-downtime failover with sticky sessions is + // currently not supported for session affinity by header. + ZeroDowntimeFailover LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailover `json:"zero_downtime_failover"` + JSON loadBalancerRulesOverridesSessionAffinityAttributesJSON `json:"-"` +} + +// loadBalancerRulesOverridesSessionAffinityAttributesJSON contains the JSON +// metadata for the struct [LoadBalancerRulesOverridesSessionAffinityAttributes] +type loadBalancerRulesOverridesSessionAffinityAttributesJSON struct { + DrainDuration apijson.Field + Headers apijson.Field + RequireAllHeaders apijson.Field + Samesite apijson.Field + Secure apijson.Field + ZeroDowntimeFailover apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerRulesOverridesSessionAffinityAttributes) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerRulesOverridesSessionAffinityAttributesJSON) RawJSON() string { + return r.raw +} + +// Configures the SameSite attribute on session affinity cookie. Value "Auto" will +// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: +// when using value "None", the secure attribute can not be set to "Never". +type LoadBalancerRulesOverridesSessionAffinityAttributesSamesite string + +const ( + LoadBalancerRulesOverridesSessionAffinityAttributesSamesiteAuto LoadBalancerRulesOverridesSessionAffinityAttributesSamesite = "Auto" + LoadBalancerRulesOverridesSessionAffinityAttributesSamesiteLax LoadBalancerRulesOverridesSessionAffinityAttributesSamesite = "Lax" + LoadBalancerRulesOverridesSessionAffinityAttributesSamesiteNone LoadBalancerRulesOverridesSessionAffinityAttributesSamesite = "None" + LoadBalancerRulesOverridesSessionAffinityAttributesSamesiteStrict LoadBalancerRulesOverridesSessionAffinityAttributesSamesite = "Strict" +) + +// Configures the Secure attribute on session affinity cookie. Value "Always" +// indicates the Secure attribute will be set in the Set-Cookie header, "Never" +// indicates the Secure attribute will not be set, and "Auto" will set the Secure +// attribute depending if Always Use HTTPS is enabled. +type LoadBalancerRulesOverridesSessionAffinityAttributesSecure string + +const ( + LoadBalancerRulesOverridesSessionAffinityAttributesSecureAuto LoadBalancerRulesOverridesSessionAffinityAttributesSecure = "Auto" + LoadBalancerRulesOverridesSessionAffinityAttributesSecureAlways LoadBalancerRulesOverridesSessionAffinityAttributesSecure = "Always" + LoadBalancerRulesOverridesSessionAffinityAttributesSecureNever LoadBalancerRulesOverridesSessionAffinityAttributesSecure = "Never" +) + +// Configures the zero-downtime failover between origins within a pool when session +// affinity is enabled. This feature is currently incompatible with Argo, Tiered +// Cache, and Bandwidth Alliance. The supported values are: +// +// - `"none"`: No failover takes place for sessions pinned to the origin (default). +// - `"temporary"`: Traffic will be sent to another other healthy origin until the +// originally pinned origin is available; note that this can potentially result +// in heavy origin flapping. +// - `"sticky"`: The session affinity cookie is updated and subsequent requests are +// sent to the new origin. Note: Zero-downtime failover with sticky sessions is +// currently not supported for session affinity by header. +type LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailover string + +const ( + LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "none" + LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "temporary" + LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "sticky" +) + +// Steering Policy for this load balancer. +// +// - `"off"`: Use `default_pools`. +// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied +// requests, the country for `country_pools` is determined by +// `location_strategy`. +// - `"random"`: Select a pool randomly. +// - `"dynamic_latency"`: Use round trip time to select the closest pool in +// default_pools (requires pool health checks). +// - `"proximity"`: Use the pools' latitude and longitude to select the closest +// pool using the Cloudflare PoP location for proxied requests or the location +// determined by `location_strategy` for non-proxied requests. +// - `"least_outstanding_requests"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of outstanding +// requests. Pools with more pending requests are weighted proportionately less +// relative to others. +// - `"least_connections"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of open connections. +// Pools with more open connections are weighted proportionately less relative to +// others. Supported for HTTP/1 and HTTP/2 connections. +// - `""`: Will map to `"geo"` if you use +// `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. +type LoadBalancerRulesOverridesSteeringPolicy string + +const ( + LoadBalancerRulesOverridesSteeringPolicyOff LoadBalancerRulesOverridesSteeringPolicy = "off" + LoadBalancerRulesOverridesSteeringPolicyGeo LoadBalancerRulesOverridesSteeringPolicy = "geo" + LoadBalancerRulesOverridesSteeringPolicyRandom LoadBalancerRulesOverridesSteeringPolicy = "random" + LoadBalancerRulesOverridesSteeringPolicyDynamicLatency LoadBalancerRulesOverridesSteeringPolicy = "dynamic_latency" + LoadBalancerRulesOverridesSteeringPolicyProximity LoadBalancerRulesOverridesSteeringPolicy = "proximity" + LoadBalancerRulesOverridesSteeringPolicyLeastOutstandingRequests LoadBalancerRulesOverridesSteeringPolicy = "least_outstanding_requests" + LoadBalancerRulesOverridesSteeringPolicyLeastConnections LoadBalancerRulesOverridesSteeringPolicy = "least_connections" + LoadBalancerRulesOverridesSteeringPolicyEmpty LoadBalancerRulesOverridesSteeringPolicy = "\"\"" +) + +// Specifies the type of session affinity the load balancer should use unless +// specified as `"none"` or "" (default). The supported types are: +// +// - `"cookie"`: On the first request to a proxied load balancer, a cookie is +// generated, encoding information of which origin the request will be forwarded +// to. Subsequent requests, by the same client to the same load balancer, will be +// sent to the origin server the cookie encodes, for the duration of the cookie +// and as long as the origin server remains healthy. If the cookie has expired or +// the origin server is unhealthy, then a new origin server is calculated and +// used. +// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin +// selection is stable and based on the client's ip address. +// - `"header"`: On the first request to a proxied load balancer, a session key +// based on the configured HTTP headers (see +// `session_affinity_attributes.headers`) is generated, encoding the request +// headers used for storing in the load balancer session state which origin the +// request will be forwarded to. Subsequent requests to the load balancer with +// the same headers will be sent to the same origin server, for the duration of +// the session and as long as the origin server remains healthy. If the session +// has been idle for the duration of `session_affinity_ttl` seconds or the origin +// server is unhealthy, then a new origin server is calculated and used. See +// `headers` in `session_affinity_attributes` for additional required +// configuration. +type LoadBalancerSessionAffinity string + +const ( + LoadBalancerSessionAffinityNone LoadBalancerSessionAffinity = "none" + LoadBalancerSessionAffinityCookie LoadBalancerSessionAffinity = "cookie" + LoadBalancerSessionAffinityIPCookie LoadBalancerSessionAffinity = "ip_cookie" + LoadBalancerSessionAffinityHeader LoadBalancerSessionAffinity = "header" + LoadBalancerSessionAffinityEmpty LoadBalancerSessionAffinity = "\"\"" +) + +// Configures attributes for session affinity. +type LoadBalancerSessionAffinityAttributes struct { + // Configures the drain duration in seconds. This field is only used when session + // affinity is enabled on the load balancer. + DrainDuration float64 `json:"drain_duration"` + // Configures the names of HTTP headers to base session affinity on when header + // `session_affinity` is enabled. At least one HTTP header name must be provided. + // To specify the exact cookies to be used, include an item in the following + // format: `"cookie:,"` (example) where everything + // after the colon is a comma-separated list of cookie names. Providing only + // `"cookie"` will result in all cookies being used. The default max number of HTTP + // header names that can be provided depends on your plan: 5 for Enterprise, 1 for + // all other plans. + Headers []string `json:"headers"` + // When header `session_affinity` is enabled, this option can be used to specify + // how HTTP headers on load balancing requests will be used. The supported values + // are: + // + // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers + // specified by the `headers` session affinity attribute, otherwise sessions + // aren't created. + // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP + // headers specified by the `headers` session affinity attribute, otherwise + // sessions aren't created. + RequireAllHeaders bool `json:"require_all_headers"` + // Configures the SameSite attribute on session affinity cookie. Value "Auto" will + // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: + // when using value "None", the secure attribute can not be set to "Never". + Samesite LoadBalancerSessionAffinityAttributesSamesite `json:"samesite"` + // Configures the Secure attribute on session affinity cookie. Value "Always" + // indicates the Secure attribute will be set in the Set-Cookie header, "Never" + // indicates the Secure attribute will not be set, and "Auto" will set the Secure + // attribute depending if Always Use HTTPS is enabled. + Secure LoadBalancerSessionAffinityAttributesSecure `json:"secure"` + // Configures the zero-downtime failover between origins within a pool when session + // affinity is enabled. This feature is currently incompatible with Argo, Tiered + // Cache, and Bandwidth Alliance. The supported values are: + // + // - `"none"`: No failover takes place for sessions pinned to the origin (default). + // - `"temporary"`: Traffic will be sent to another other healthy origin until the + // originally pinned origin is available; note that this can potentially result + // in heavy origin flapping. + // - `"sticky"`: The session affinity cookie is updated and subsequent requests are + // sent to the new origin. Note: Zero-downtime failover with sticky sessions is + // currently not supported for session affinity by header. + ZeroDowntimeFailover LoadBalancerSessionAffinityAttributesZeroDowntimeFailover `json:"zero_downtime_failover"` + JSON loadBalancerSessionAffinityAttributesJSON `json:"-"` +} + +// loadBalancerSessionAffinityAttributesJSON contains the JSON metadata for the +// struct [LoadBalancerSessionAffinityAttributes] +type loadBalancerSessionAffinityAttributesJSON struct { + DrainDuration apijson.Field + Headers apijson.Field + RequireAllHeaders apijson.Field + Samesite apijson.Field + Secure apijson.Field + ZeroDowntimeFailover apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerSessionAffinityAttributes) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerSessionAffinityAttributesJSON) RawJSON() string { + return r.raw +} + +// Configures the SameSite attribute on session affinity cookie. Value "Auto" will +// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: +// when using value "None", the secure attribute can not be set to "Never". +type LoadBalancerSessionAffinityAttributesSamesite string + +const ( + LoadBalancerSessionAffinityAttributesSamesiteAuto LoadBalancerSessionAffinityAttributesSamesite = "Auto" + LoadBalancerSessionAffinityAttributesSamesiteLax LoadBalancerSessionAffinityAttributesSamesite = "Lax" + LoadBalancerSessionAffinityAttributesSamesiteNone LoadBalancerSessionAffinityAttributesSamesite = "None" + LoadBalancerSessionAffinityAttributesSamesiteStrict LoadBalancerSessionAffinityAttributesSamesite = "Strict" +) + +// Configures the Secure attribute on session affinity cookie. Value "Always" +// indicates the Secure attribute will be set in the Set-Cookie header, "Never" +// indicates the Secure attribute will not be set, and "Auto" will set the Secure +// attribute depending if Always Use HTTPS is enabled. +type LoadBalancerSessionAffinityAttributesSecure string + +const ( + LoadBalancerSessionAffinityAttributesSecureAuto LoadBalancerSessionAffinityAttributesSecure = "Auto" + LoadBalancerSessionAffinityAttributesSecureAlways LoadBalancerSessionAffinityAttributesSecure = "Always" + LoadBalancerSessionAffinityAttributesSecureNever LoadBalancerSessionAffinityAttributesSecure = "Never" +) + +// Configures the zero-downtime failover between origins within a pool when session +// affinity is enabled. This feature is currently incompatible with Argo, Tiered +// Cache, and Bandwidth Alliance. The supported values are: +// +// - `"none"`: No failover takes place for sessions pinned to the origin (default). +// - `"temporary"`: Traffic will be sent to another other healthy origin until the +// originally pinned origin is available; note that this can potentially result +// in heavy origin flapping. +// - `"sticky"`: The session affinity cookie is updated and subsequent requests are +// sent to the new origin. Note: Zero-downtime failover with sticky sessions is +// currently not supported for session affinity by header. +type LoadBalancerSessionAffinityAttributesZeroDowntimeFailover string + +const ( + LoadBalancerSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerSessionAffinityAttributesZeroDowntimeFailover = "none" + LoadBalancerSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerSessionAffinityAttributesZeroDowntimeFailover = "temporary" + LoadBalancerSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerSessionAffinityAttributesZeroDowntimeFailover = "sticky" +) + +// Steering Policy for this load balancer. +// +// - `"off"`: Use `default_pools`. +// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied +// requests, the country for `country_pools` is determined by +// `location_strategy`. +// - `"random"`: Select a pool randomly. +// - `"dynamic_latency"`: Use round trip time to select the closest pool in +// default_pools (requires pool health checks). +// - `"proximity"`: Use the pools' latitude and longitude to select the closest +// pool using the Cloudflare PoP location for proxied requests or the location +// determined by `location_strategy` for non-proxied requests. +// - `"least_outstanding_requests"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of outstanding +// requests. Pools with more pending requests are weighted proportionately less +// relative to others. +// - `"least_connections"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of open connections. +// Pools with more open connections are weighted proportionately less relative to +// others. Supported for HTTP/1 and HTTP/2 connections. +// - `""`: Will map to `"geo"` if you use +// `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. +type LoadBalancerSteeringPolicy string + +const ( + LoadBalancerSteeringPolicyOff LoadBalancerSteeringPolicy = "off" + LoadBalancerSteeringPolicyGeo LoadBalancerSteeringPolicy = "geo" + LoadBalancerSteeringPolicyRandom LoadBalancerSteeringPolicy = "random" + LoadBalancerSteeringPolicyDynamicLatency LoadBalancerSteeringPolicy = "dynamic_latency" + LoadBalancerSteeringPolicyProximity LoadBalancerSteeringPolicy = "proximity" + LoadBalancerSteeringPolicyLeastOutstandingRequests LoadBalancerSteeringPolicy = "least_outstanding_requests" + LoadBalancerSteeringPolicyLeastConnections LoadBalancerSteeringPolicy = "least_connections" + LoadBalancerSteeringPolicyEmpty LoadBalancerSteeringPolicy = "\"\"" +) + +type LoadBalancerDeleteResponse struct { + ID string `json:"id"` + JSON loadBalancerDeleteResponseJSON `json:"-"` +} + +// loadBalancerDeleteResponseJSON contains the JSON metadata for the struct +// [LoadBalancerDeleteResponse] +type loadBalancerDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerNewParams struct { + ZoneID param.Field[string] `path:"zone_id,required"` + // A list of pool IDs ordered by their failover priority. Pools defined here are + // used by default, or when region_pools are not configured for a given region. + DefaultPools param.Field[[]string] `json:"default_pools,required"` + // The pool ID to use when all other pools are detected as unhealthy. + FallbackPool param.Field[interface{}] `json:"fallback_pool,required"` + // The DNS hostname to associate with your Load Balancer. If this hostname already + // exists as a DNS record in Cloudflare's DNS, the Load Balancer will take + // precedence and the DNS record will not be used. + Name param.Field[string] `json:"name,required"` + // Controls features that modify the routing of requests to pools and origins in + // response to dynamic conditions, such as during the interval between active + // health monitoring requests. For example, zero-downtime failover occurs + // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 + // response codes. If there is another healthy origin in the same pool, the request + // is retried once against this alternate origin. + AdaptiveRouting param.Field[LoadBalancerNewParamsAdaptiveRouting] `json:"adaptive_routing"` + // A mapping of country codes to a list of pool IDs (ordered by their failover + // priority) for the given country. Any country not explicitly defined will fall + // back to using the corresponding region_pool mapping if it exists else to + // default_pools. + CountryPools param.Field[interface{}] `json:"country_pools"` + // Object description. + Description param.Field[string] `json:"description"` + // Controls location-based steering for non-proxied requests. See `steering_policy` + // to learn how steering is affected. + LocationStrategy param.Field[LoadBalancerNewParamsLocationStrategy] `json:"location_strategy"` + // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs + // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not + // explicitly defined will fall back to using the corresponding country_pool, then + // region_pool mapping if it exists else to default_pools. + PopPools param.Field[interface{}] `json:"pop_pools"` + // Whether the hostname should be gray clouded (false) or orange clouded (true). + Proxied param.Field[bool] `json:"proxied"` + // Configures pool weights. + // + // - `steering_policy="random"`: A random pool is selected with probability + // proportional to pool weights. + // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each + // pool's outstanding requests. + // - `steering_policy="least_connections"`: Use pool weights to scale each pool's + // open connections. + RandomSteering param.Field[LoadBalancerNewParamsRandomSteering] `json:"random_steering"` + // A mapping of region codes to a list of pool IDs (ordered by their failover + // priority) for the given region. Any regions not explicitly defined will fall + // back to using default_pools. + RegionPools param.Field[interface{}] `json:"region_pools"` + // BETA Field Not General Access: A list of rules for this load balancer to + // execute. + Rules param.Field[[]LoadBalancerNewParamsRule] `json:"rules"` + // Specifies the type of session affinity the load balancer should use unless + // specified as `"none"` or "" (default). The supported types are: + // + // - `"cookie"`: On the first request to a proxied load balancer, a cookie is + // generated, encoding information of which origin the request will be forwarded + // to. Subsequent requests, by the same client to the same load balancer, will be + // sent to the origin server the cookie encodes, for the duration of the cookie + // and as long as the origin server remains healthy. If the cookie has expired or + // the origin server is unhealthy, then a new origin server is calculated and + // used. + // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin + // selection is stable and based on the client's ip address. + // - `"header"`: On the first request to a proxied load balancer, a session key + // based on the configured HTTP headers (see + // `session_affinity_attributes.headers`) is generated, encoding the request + // headers used for storing in the load balancer session state which origin the + // request will be forwarded to. Subsequent requests to the load balancer with + // the same headers will be sent to the same origin server, for the duration of + // the session and as long as the origin server remains healthy. If the session + // has been idle for the duration of `session_affinity_ttl` seconds or the origin + // server is unhealthy, then a new origin server is calculated and used. See + // `headers` in `session_affinity_attributes` for additional required + // configuration. + SessionAffinity param.Field[LoadBalancerNewParamsSessionAffinity] `json:"session_affinity"` + // Configures attributes for session affinity. + SessionAffinityAttributes param.Field[LoadBalancerNewParamsSessionAffinityAttributes] `json:"session_affinity_attributes"` + // Time, in seconds, until a client's session expires after being created. Once the + // expiry time has been reached, subsequent requests may get sent to a different + // origin server. The accepted ranges per `session_affinity` policy are: + // + // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used + // unless explicitly set. The accepted range of values is between [1800, 604800]. + // - `"header"`: The current default of 1800 seconds will be used unless explicitly + // set. The accepted range of values is between [30, 3600]. Note: With session + // affinity by header, sessions only expire after they haven't been used for the + // number of seconds specified. + SessionAffinityTTL param.Field[float64] `json:"session_affinity_ttl"` + // Steering Policy for this load balancer. + // + // - `"off"`: Use `default_pools`. + // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied + // requests, the country for `country_pools` is determined by + // `location_strategy`. + // - `"random"`: Select a pool randomly. + // - `"dynamic_latency"`: Use round trip time to select the closest pool in + // default_pools (requires pool health checks). + // - `"proximity"`: Use the pools' latitude and longitude to select the closest + // pool using the Cloudflare PoP location for proxied requests or the location + // determined by `location_strategy` for non-proxied requests. + // - `"least_outstanding_requests"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of outstanding + // requests. Pools with more pending requests are weighted proportionately less + // relative to others. + // - `"least_connections"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of open connections. + // Pools with more open connections are weighted proportionately less relative to + // others. Supported for HTTP/1 and HTTP/2 connections. + // - `""`: Will map to `"geo"` if you use + // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. + SteeringPolicy param.Field[LoadBalancerNewParamsSteeringPolicy] `json:"steering_policy"` + // Time to live (TTL) of the DNS entry for the IP address returned by this load + // balancer. This only applies to gray-clouded (unproxied) load balancers. + TTL param.Field[float64] `json:"ttl"` +} + +func (r LoadBalancerNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Controls features that modify the routing of requests to pools and origins in +// response to dynamic conditions, such as during the interval between active +// health monitoring requests. For example, zero-downtime failover occurs +// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 +// response codes. If there is another healthy origin in the same pool, the request +// is retried once against this alternate origin. +type LoadBalancerNewParamsAdaptiveRouting struct { + // Extends zero-downtime failover of requests to healthy origins from alternate + // pools, when no healthy alternate exists in the same pool, according to the + // failover order defined by traffic and origin steering. When set false (the + // default) zero-downtime failover will only occur between origins within the same + // pool. See `session_affinity_attributes` for control over when sessions are + // broken or reassigned. + FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` +} + +func (r LoadBalancerNewParamsAdaptiveRouting) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Controls location-based steering for non-proxied requests. See `steering_policy` +// to learn how steering is affected. +type LoadBalancerNewParamsLocationStrategy struct { + // Determines the authoritative location when ECS is not preferred, does not exist + // in the request, or its GeoIP lookup is unsuccessful. + // + // - `"pop"`: Use the Cloudflare PoP location. + // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is + // unsuccessful, use the Cloudflare PoP location. + Mode param.Field[LoadBalancerNewParamsLocationStrategyMode] `json:"mode"` + // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the + // authoritative location. + // + // - `"always"`: Always prefer ECS. + // - `"never"`: Never prefer ECS. + // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. + // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. + PreferEcs param.Field[LoadBalancerNewParamsLocationStrategyPreferEcs] `json:"prefer_ecs"` +} + +func (r LoadBalancerNewParamsLocationStrategy) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Determines the authoritative location when ECS is not preferred, does not exist +// in the request, or its GeoIP lookup is unsuccessful. +// +// - `"pop"`: Use the Cloudflare PoP location. +// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is +// unsuccessful, use the Cloudflare PoP location. +type LoadBalancerNewParamsLocationStrategyMode string + +const ( + LoadBalancerNewParamsLocationStrategyModePop LoadBalancerNewParamsLocationStrategyMode = "pop" + LoadBalancerNewParamsLocationStrategyModeResolverIP LoadBalancerNewParamsLocationStrategyMode = "resolver_ip" +) + +// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the +// authoritative location. +// +// - `"always"`: Always prefer ECS. +// - `"never"`: Never prefer ECS. +// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. +// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. +type LoadBalancerNewParamsLocationStrategyPreferEcs string + +const ( + LoadBalancerNewParamsLocationStrategyPreferEcsAlways LoadBalancerNewParamsLocationStrategyPreferEcs = "always" + LoadBalancerNewParamsLocationStrategyPreferEcsNever LoadBalancerNewParamsLocationStrategyPreferEcs = "never" + LoadBalancerNewParamsLocationStrategyPreferEcsProximity LoadBalancerNewParamsLocationStrategyPreferEcs = "proximity" + LoadBalancerNewParamsLocationStrategyPreferEcsGeo LoadBalancerNewParamsLocationStrategyPreferEcs = "geo" +) + +// Configures pool weights. +// +// - `steering_policy="random"`: A random pool is selected with probability +// proportional to pool weights. +// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each +// pool's outstanding requests. +// - `steering_policy="least_connections"`: Use pool weights to scale each pool's +// open connections. +type LoadBalancerNewParamsRandomSteering struct { + // The default weight for pools in the load balancer that are not specified in the + // pool_weights map. + DefaultWeight param.Field[float64] `json:"default_weight"` + // A mapping of pool IDs to custom weights. The weight is relative to other pools + // in the load balancer. + PoolWeights param.Field[interface{}] `json:"pool_weights"` +} + +func (r LoadBalancerNewParamsRandomSteering) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A rule object containing conditions and overrides for this load balancer to +// evaluate. +type LoadBalancerNewParamsRule struct { + // The condition expressions to evaluate. If the condition evaluates to true, the + // overrides or fixed_response in this rule will be applied. An empty condition is + // always true. For more details on condition expressions, please see + // https://developers.cloudflare.com/load-balancing/understand-basics/load-balancing-rules/expressions. + Condition param.Field[string] `json:"condition"` + // Disable this specific rule. It will no longer be evaluated by this load + // balancer. + Disabled param.Field[bool] `json:"disabled"` + // A collection of fields used to directly respond to the eyeball instead of + // routing to a pool. If a fixed_response is supplied the rule will be marked as + // terminates. + FixedResponse param.Field[LoadBalancerNewParamsRulesFixedResponse] `json:"fixed_response"` + // Name of this rule. Only used for human readability. + Name param.Field[string] `json:"name"` + // A collection of overrides to apply to the load balancer when this rule's + // condition is true. All fields are optional. + Overrides param.Field[LoadBalancerNewParamsRulesOverrides] `json:"overrides"` + // The order in which rules should be executed in relation to each other. Lower + // values are executed first. Values do not need to be sequential. If no value is + // provided for any rule the array order of the rules field will be used to assign + // a priority. + Priority param.Field[int64] `json:"priority"` + // If this rule's condition is true, this causes rule evaluation to stop after + // processing this rule. + Terminates param.Field[bool] `json:"terminates"` +} + +func (r LoadBalancerNewParamsRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A collection of fields used to directly respond to the eyeball instead of +// routing to a pool. If a fixed_response is supplied the rule will be marked as +// terminates. +type LoadBalancerNewParamsRulesFixedResponse struct { + // The http 'Content-Type' header to include in the response. + ContentType param.Field[string] `json:"content_type"` + // The http 'Location' header to include in the response. + Location param.Field[string] `json:"location"` + // Text to include as the http body. + MessageBody param.Field[string] `json:"message_body"` + // The http status code to respond with. + StatusCode param.Field[int64] `json:"status_code"` +} + +func (r LoadBalancerNewParamsRulesFixedResponse) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A collection of overrides to apply to the load balancer when this rule's +// condition is true. All fields are optional. +type LoadBalancerNewParamsRulesOverrides struct { + // Controls features that modify the routing of requests to pools and origins in + // response to dynamic conditions, such as during the interval between active + // health monitoring requests. For example, zero-downtime failover occurs + // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 + // response codes. If there is another healthy origin in the same pool, the request + // is retried once against this alternate origin. + AdaptiveRouting param.Field[LoadBalancerNewParamsRulesOverridesAdaptiveRouting] `json:"adaptive_routing"` + // A mapping of country codes to a list of pool IDs (ordered by their failover + // priority) for the given country. Any country not explicitly defined will fall + // back to using the corresponding region_pool mapping if it exists else to + // default_pools. + CountryPools param.Field[interface{}] `json:"country_pools"` + // A list of pool IDs ordered by their failover priority. Pools defined here are + // used by default, or when region_pools are not configured for a given region. + DefaultPools param.Field[[]string] `json:"default_pools"` + // The pool ID to use when all other pools are detected as unhealthy. + FallbackPool param.Field[interface{}] `json:"fallback_pool"` + // Controls location-based steering for non-proxied requests. See `steering_policy` + // to learn how steering is affected. + LocationStrategy param.Field[LoadBalancerNewParamsRulesOverridesLocationStrategy] `json:"location_strategy"` + // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs + // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not + // explicitly defined will fall back to using the corresponding country_pool, then + // region_pool mapping if it exists else to default_pools. + PopPools param.Field[interface{}] `json:"pop_pools"` + // Configures pool weights. + // + // - `steering_policy="random"`: A random pool is selected with probability + // proportional to pool weights. + // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each + // pool's outstanding requests. + // - `steering_policy="least_connections"`: Use pool weights to scale each pool's + // open connections. + RandomSteering param.Field[LoadBalancerNewParamsRulesOverridesRandomSteering] `json:"random_steering"` + // A mapping of region codes to a list of pool IDs (ordered by their failover + // priority) for the given region. Any regions not explicitly defined will fall + // back to using default_pools. + RegionPools param.Field[interface{}] `json:"region_pools"` + // Specifies the type of session affinity the load balancer should use unless + // specified as `"none"` or "" (default). The supported types are: + // + // - `"cookie"`: On the first request to a proxied load balancer, a cookie is + // generated, encoding information of which origin the request will be forwarded + // to. Subsequent requests, by the same client to the same load balancer, will be + // sent to the origin server the cookie encodes, for the duration of the cookie + // and as long as the origin server remains healthy. If the cookie has expired or + // the origin server is unhealthy, then a new origin server is calculated and + // used. + // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin + // selection is stable and based on the client's ip address. + // - `"header"`: On the first request to a proxied load balancer, a session key + // based on the configured HTTP headers (see + // `session_affinity_attributes.headers`) is generated, encoding the request + // headers used for storing in the load balancer session state which origin the + // request will be forwarded to. Subsequent requests to the load balancer with + // the same headers will be sent to the same origin server, for the duration of + // the session and as long as the origin server remains healthy. If the session + // has been idle for the duration of `session_affinity_ttl` seconds or the origin + // server is unhealthy, then a new origin server is calculated and used. See + // `headers` in `session_affinity_attributes` for additional required + // configuration. + SessionAffinity param.Field[LoadBalancerNewParamsRulesOverridesSessionAffinity] `json:"session_affinity"` + // Configures attributes for session affinity. + SessionAffinityAttributes param.Field[LoadBalancerNewParamsRulesOverridesSessionAffinityAttributes] `json:"session_affinity_attributes"` + // Time, in seconds, until a client's session expires after being created. Once the + // expiry time has been reached, subsequent requests may get sent to a different + // origin server. The accepted ranges per `session_affinity` policy are: + // + // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used + // unless explicitly set. The accepted range of values is between [1800, 604800]. + // - `"header"`: The current default of 1800 seconds will be used unless explicitly + // set. The accepted range of values is between [30, 3600]. Note: With session + // affinity by header, sessions only expire after they haven't been used for the + // number of seconds specified. + SessionAffinityTTL param.Field[float64] `json:"session_affinity_ttl"` + // Steering Policy for this load balancer. + // + // - `"off"`: Use `default_pools`. + // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied + // requests, the country for `country_pools` is determined by + // `location_strategy`. + // - `"random"`: Select a pool randomly. + // - `"dynamic_latency"`: Use round trip time to select the closest pool in + // default_pools (requires pool health checks). + // - `"proximity"`: Use the pools' latitude and longitude to select the closest + // pool using the Cloudflare PoP location for proxied requests or the location + // determined by `location_strategy` for non-proxied requests. + // - `"least_outstanding_requests"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of outstanding + // requests. Pools with more pending requests are weighted proportionately less + // relative to others. + // - `"least_connections"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of open connections. + // Pools with more open connections are weighted proportionately less relative to + // others. Supported for HTTP/1 and HTTP/2 connections. + // - `""`: Will map to `"geo"` if you use + // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. + SteeringPolicy param.Field[LoadBalancerNewParamsRulesOverridesSteeringPolicy] `json:"steering_policy"` + // Time to live (TTL) of the DNS entry for the IP address returned by this load + // balancer. This only applies to gray-clouded (unproxied) load balancers. + TTL param.Field[float64] `json:"ttl"` +} + +func (r LoadBalancerNewParamsRulesOverrides) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Controls features that modify the routing of requests to pools and origins in +// response to dynamic conditions, such as during the interval between active +// health monitoring requests. For example, zero-downtime failover occurs +// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 +// response codes. If there is another healthy origin in the same pool, the request +// is retried once against this alternate origin. +type LoadBalancerNewParamsRulesOverridesAdaptiveRouting struct { + // Extends zero-downtime failover of requests to healthy origins from alternate + // pools, when no healthy alternate exists in the same pool, according to the + // failover order defined by traffic and origin steering. When set false (the + // default) zero-downtime failover will only occur between origins within the same + // pool. See `session_affinity_attributes` for control over when sessions are + // broken or reassigned. + FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` +} + +func (r LoadBalancerNewParamsRulesOverridesAdaptiveRouting) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Controls location-based steering for non-proxied requests. See `steering_policy` +// to learn how steering is affected. +type LoadBalancerNewParamsRulesOverridesLocationStrategy struct { + // Determines the authoritative location when ECS is not preferred, does not exist + // in the request, or its GeoIP lookup is unsuccessful. + // + // - `"pop"`: Use the Cloudflare PoP location. + // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is + // unsuccessful, use the Cloudflare PoP location. + Mode param.Field[LoadBalancerNewParamsRulesOverridesLocationStrategyMode] `json:"mode"` + // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the + // authoritative location. + // + // - `"always"`: Always prefer ECS. + // - `"never"`: Never prefer ECS. + // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. + // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. + PreferEcs param.Field[LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs] `json:"prefer_ecs"` +} + +func (r LoadBalancerNewParamsRulesOverridesLocationStrategy) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Determines the authoritative location when ECS is not preferred, does not exist +// in the request, or its GeoIP lookup is unsuccessful. +// +// - `"pop"`: Use the Cloudflare PoP location. +// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is +// unsuccessful, use the Cloudflare PoP location. +type LoadBalancerNewParamsRulesOverridesLocationStrategyMode string + +const ( + LoadBalancerNewParamsRulesOverridesLocationStrategyModePop LoadBalancerNewParamsRulesOverridesLocationStrategyMode = "pop" + LoadBalancerNewParamsRulesOverridesLocationStrategyModeResolverIP LoadBalancerNewParamsRulesOverridesLocationStrategyMode = "resolver_ip" +) + +// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the +// authoritative location. +// +// - `"always"`: Always prefer ECS. +// - `"never"`: Never prefer ECS. +// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. +// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. +type LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs string + +const ( + LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsAlways LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs = "always" + LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsNever LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs = "never" + LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsProximity LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs = "proximity" + LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsGeo LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs = "geo" +) + +// Configures pool weights. +// +// - `steering_policy="random"`: A random pool is selected with probability +// proportional to pool weights. +// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each +// pool's outstanding requests. +// - `steering_policy="least_connections"`: Use pool weights to scale each pool's +// open connections. +type LoadBalancerNewParamsRulesOverridesRandomSteering struct { + // The default weight for pools in the load balancer that are not specified in the + // pool_weights map. + DefaultWeight param.Field[float64] `json:"default_weight"` + // A mapping of pool IDs to custom weights. The weight is relative to other pools + // in the load balancer. + PoolWeights param.Field[interface{}] `json:"pool_weights"` +} + +func (r LoadBalancerNewParamsRulesOverridesRandomSteering) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Specifies the type of session affinity the load balancer should use unless +// specified as `"none"` or "" (default). The supported types are: +// +// - `"cookie"`: On the first request to a proxied load balancer, a cookie is +// generated, encoding information of which origin the request will be forwarded +// to. Subsequent requests, by the same client to the same load balancer, will be +// sent to the origin server the cookie encodes, for the duration of the cookie +// and as long as the origin server remains healthy. If the cookie has expired or +// the origin server is unhealthy, then a new origin server is calculated and +// used. +// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin +// selection is stable and based on the client's ip address. +// - `"header"`: On the first request to a proxied load balancer, a session key +// based on the configured HTTP headers (see +// `session_affinity_attributes.headers`) is generated, encoding the request +// headers used for storing in the load balancer session state which origin the +// request will be forwarded to. Subsequent requests to the load balancer with +// the same headers will be sent to the same origin server, for the duration of +// the session and as long as the origin server remains healthy. If the session +// has been idle for the duration of `session_affinity_ttl` seconds or the origin +// server is unhealthy, then a new origin server is calculated and used. See +// `headers` in `session_affinity_attributes` for additional required +// configuration. +type LoadBalancerNewParamsRulesOverridesSessionAffinity string + +const ( + LoadBalancerNewParamsRulesOverridesSessionAffinityNone LoadBalancerNewParamsRulesOverridesSessionAffinity = "none" + LoadBalancerNewParamsRulesOverridesSessionAffinityCookie LoadBalancerNewParamsRulesOverridesSessionAffinity = "cookie" + LoadBalancerNewParamsRulesOverridesSessionAffinityIPCookie LoadBalancerNewParamsRulesOverridesSessionAffinity = "ip_cookie" + LoadBalancerNewParamsRulesOverridesSessionAffinityHeader LoadBalancerNewParamsRulesOverridesSessionAffinity = "header" + LoadBalancerNewParamsRulesOverridesSessionAffinityEmpty LoadBalancerNewParamsRulesOverridesSessionAffinity = "\"\"" +) + +// Configures attributes for session affinity. +type LoadBalancerNewParamsRulesOverridesSessionAffinityAttributes struct { + // Configures the drain duration in seconds. This field is only used when session + // affinity is enabled on the load balancer. + DrainDuration param.Field[float64] `json:"drain_duration"` + // Configures the names of HTTP headers to base session affinity on when header + // `session_affinity` is enabled. At least one HTTP header name must be provided. + // To specify the exact cookies to be used, include an item in the following + // format: `"cookie:,"` (example) where everything + // after the colon is a comma-separated list of cookie names. Providing only + // `"cookie"` will result in all cookies being used. The default max number of HTTP + // header names that can be provided depends on your plan: 5 for Enterprise, 1 for + // all other plans. + Headers param.Field[[]string] `json:"headers"` + // When header `session_affinity` is enabled, this option can be used to specify + // how HTTP headers on load balancing requests will be used. The supported values + // are: + // + // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers + // specified by the `headers` session affinity attribute, otherwise sessions + // aren't created. + // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP + // headers specified by the `headers` session affinity attribute, otherwise + // sessions aren't created. + RequireAllHeaders param.Field[bool] `json:"require_all_headers"` + // Configures the SameSite attribute on session affinity cookie. Value "Auto" will + // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: + // when using value "None", the secure attribute can not be set to "Never". + Samesite param.Field[LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite] `json:"samesite"` + // Configures the Secure attribute on session affinity cookie. Value "Always" + // indicates the Secure attribute will be set in the Set-Cookie header, "Never" + // indicates the Secure attribute will not be set, and "Auto" will set the Secure + // attribute depending if Always Use HTTPS is enabled. + Secure param.Field[LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecure] `json:"secure"` + // Configures the zero-downtime failover between origins within a pool when session + // affinity is enabled. This feature is currently incompatible with Argo, Tiered + // Cache, and Bandwidth Alliance. The supported values are: + // + // - `"none"`: No failover takes place for sessions pinned to the origin (default). + // - `"temporary"`: Traffic will be sent to another other healthy origin until the + // originally pinned origin is available; note that this can potentially result + // in heavy origin flapping. + // - `"sticky"`: The session affinity cookie is updated and subsequent requests are + // sent to the new origin. Note: Zero-downtime failover with sticky sessions is + // currently not supported for session affinity by header. + ZeroDowntimeFailover param.Field[LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` +} + +func (r LoadBalancerNewParamsRulesOverridesSessionAffinityAttributes) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures the SameSite attribute on session affinity cookie. Value "Auto" will +// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: +// when using value "None", the secure attribute can not be set to "Never". +type LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite string + +const ( + LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteAuto LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite = "Auto" + LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteLax LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite = "Lax" + LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteNone LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite = "None" + LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteStrict LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite = "Strict" +) + +// Configures the Secure attribute on session affinity cookie. Value "Always" +// indicates the Secure attribute will be set in the Set-Cookie header, "Never" +// indicates the Secure attribute will not be set, and "Auto" will set the Secure +// attribute depending if Always Use HTTPS is enabled. +type LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecure string + +const ( + LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureAuto LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecure = "Auto" + LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureAlways LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecure = "Always" + LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureNever LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecure = "Never" +) + +// Configures the zero-downtime failover between origins within a pool when session +// affinity is enabled. This feature is currently incompatible with Argo, Tiered +// Cache, and Bandwidth Alliance. The supported values are: +// +// - `"none"`: No failover takes place for sessions pinned to the origin (default). +// - `"temporary"`: Traffic will be sent to another other healthy origin until the +// originally pinned origin is available; note that this can potentially result +// in heavy origin flapping. +// - `"sticky"`: The session affinity cookie is updated and subsequent requests are +// sent to the new origin. Note: Zero-downtime failover with sticky sessions is +// currently not supported for session affinity by header. +type LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover string + +const ( + LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "none" + LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "temporary" + LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "sticky" +) + +// Steering Policy for this load balancer. +// +// - `"off"`: Use `default_pools`. +// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied +// requests, the country for `country_pools` is determined by +// `location_strategy`. +// - `"random"`: Select a pool randomly. +// - `"dynamic_latency"`: Use round trip time to select the closest pool in +// default_pools (requires pool health checks). +// - `"proximity"`: Use the pools' latitude and longitude to select the closest +// pool using the Cloudflare PoP location for proxied requests or the location +// determined by `location_strategy` for non-proxied requests. +// - `"least_outstanding_requests"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of outstanding +// requests. Pools with more pending requests are weighted proportionately less +// relative to others. +// - `"least_connections"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of open connections. +// Pools with more open connections are weighted proportionately less relative to +// others. Supported for HTTP/1 and HTTP/2 connections. +// - `""`: Will map to `"geo"` if you use +// `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. +type LoadBalancerNewParamsRulesOverridesSteeringPolicy string + +const ( + LoadBalancerNewParamsRulesOverridesSteeringPolicyOff LoadBalancerNewParamsRulesOverridesSteeringPolicy = "off" + LoadBalancerNewParamsRulesOverridesSteeringPolicyGeo LoadBalancerNewParamsRulesOverridesSteeringPolicy = "geo" + LoadBalancerNewParamsRulesOverridesSteeringPolicyRandom LoadBalancerNewParamsRulesOverridesSteeringPolicy = "random" + LoadBalancerNewParamsRulesOverridesSteeringPolicyDynamicLatency LoadBalancerNewParamsRulesOverridesSteeringPolicy = "dynamic_latency" + LoadBalancerNewParamsRulesOverridesSteeringPolicyProximity LoadBalancerNewParamsRulesOverridesSteeringPolicy = "proximity" + LoadBalancerNewParamsRulesOverridesSteeringPolicyLeastOutstandingRequests LoadBalancerNewParamsRulesOverridesSteeringPolicy = "least_outstanding_requests" + LoadBalancerNewParamsRulesOverridesSteeringPolicyLeastConnections LoadBalancerNewParamsRulesOverridesSteeringPolicy = "least_connections" + LoadBalancerNewParamsRulesOverridesSteeringPolicyEmpty LoadBalancerNewParamsRulesOverridesSteeringPolicy = "\"\"" +) + +// Specifies the type of session affinity the load balancer should use unless +// specified as `"none"` or "" (default). The supported types are: +// +// - `"cookie"`: On the first request to a proxied load balancer, a cookie is +// generated, encoding information of which origin the request will be forwarded +// to. Subsequent requests, by the same client to the same load balancer, will be +// sent to the origin server the cookie encodes, for the duration of the cookie +// and as long as the origin server remains healthy. If the cookie has expired or +// the origin server is unhealthy, then a new origin server is calculated and +// used. +// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin +// selection is stable and based on the client's ip address. +// - `"header"`: On the first request to a proxied load balancer, a session key +// based on the configured HTTP headers (see +// `session_affinity_attributes.headers`) is generated, encoding the request +// headers used for storing in the load balancer session state which origin the +// request will be forwarded to. Subsequent requests to the load balancer with +// the same headers will be sent to the same origin server, for the duration of +// the session and as long as the origin server remains healthy. If the session +// has been idle for the duration of `session_affinity_ttl` seconds or the origin +// server is unhealthy, then a new origin server is calculated and used. See +// `headers` in `session_affinity_attributes` for additional required +// configuration. +type LoadBalancerNewParamsSessionAffinity string + +const ( + LoadBalancerNewParamsSessionAffinityNone LoadBalancerNewParamsSessionAffinity = "none" + LoadBalancerNewParamsSessionAffinityCookie LoadBalancerNewParamsSessionAffinity = "cookie" + LoadBalancerNewParamsSessionAffinityIPCookie LoadBalancerNewParamsSessionAffinity = "ip_cookie" + LoadBalancerNewParamsSessionAffinityHeader LoadBalancerNewParamsSessionAffinity = "header" + LoadBalancerNewParamsSessionAffinityEmpty LoadBalancerNewParamsSessionAffinity = "\"\"" +) + +// Configures attributes for session affinity. +type LoadBalancerNewParamsSessionAffinityAttributes struct { + // Configures the drain duration in seconds. This field is only used when session + // affinity is enabled on the load balancer. + DrainDuration param.Field[float64] `json:"drain_duration"` + // Configures the names of HTTP headers to base session affinity on when header + // `session_affinity` is enabled. At least one HTTP header name must be provided. + // To specify the exact cookies to be used, include an item in the following + // format: `"cookie:,"` (example) where everything + // after the colon is a comma-separated list of cookie names. Providing only + // `"cookie"` will result in all cookies being used. The default max number of HTTP + // header names that can be provided depends on your plan: 5 for Enterprise, 1 for + // all other plans. + Headers param.Field[[]string] `json:"headers"` + // When header `session_affinity` is enabled, this option can be used to specify + // how HTTP headers on load balancing requests will be used. The supported values + // are: + // + // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers + // specified by the `headers` session affinity attribute, otherwise sessions + // aren't created. + // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP + // headers specified by the `headers` session affinity attribute, otherwise + // sessions aren't created. + RequireAllHeaders param.Field[bool] `json:"require_all_headers"` + // Configures the SameSite attribute on session affinity cookie. Value "Auto" will + // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: + // when using value "None", the secure attribute can not be set to "Never". + Samesite param.Field[LoadBalancerNewParamsSessionAffinityAttributesSamesite] `json:"samesite"` + // Configures the Secure attribute on session affinity cookie. Value "Always" + // indicates the Secure attribute will be set in the Set-Cookie header, "Never" + // indicates the Secure attribute will not be set, and "Auto" will set the Secure + // attribute depending if Always Use HTTPS is enabled. + Secure param.Field[LoadBalancerNewParamsSessionAffinityAttributesSecure] `json:"secure"` + // Configures the zero-downtime failover between origins within a pool when session + // affinity is enabled. This feature is currently incompatible with Argo, Tiered + // Cache, and Bandwidth Alliance. The supported values are: + // + // - `"none"`: No failover takes place for sessions pinned to the origin (default). + // - `"temporary"`: Traffic will be sent to another other healthy origin until the + // originally pinned origin is available; note that this can potentially result + // in heavy origin flapping. + // - `"sticky"`: The session affinity cookie is updated and subsequent requests are + // sent to the new origin. Note: Zero-downtime failover with sticky sessions is + // currently not supported for session affinity by header. + ZeroDowntimeFailover param.Field[LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` +} + +func (r LoadBalancerNewParamsSessionAffinityAttributes) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures the SameSite attribute on session affinity cookie. Value "Auto" will +// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: +// when using value "None", the secure attribute can not be set to "Never". +type LoadBalancerNewParamsSessionAffinityAttributesSamesite string + +const ( + LoadBalancerNewParamsSessionAffinityAttributesSamesiteAuto LoadBalancerNewParamsSessionAffinityAttributesSamesite = "Auto" + LoadBalancerNewParamsSessionAffinityAttributesSamesiteLax LoadBalancerNewParamsSessionAffinityAttributesSamesite = "Lax" + LoadBalancerNewParamsSessionAffinityAttributesSamesiteNone LoadBalancerNewParamsSessionAffinityAttributesSamesite = "None" + LoadBalancerNewParamsSessionAffinityAttributesSamesiteStrict LoadBalancerNewParamsSessionAffinityAttributesSamesite = "Strict" +) + +// Configures the Secure attribute on session affinity cookie. Value "Always" +// indicates the Secure attribute will be set in the Set-Cookie header, "Never" +// indicates the Secure attribute will not be set, and "Auto" will set the Secure +// attribute depending if Always Use HTTPS is enabled. +type LoadBalancerNewParamsSessionAffinityAttributesSecure string + +const ( + LoadBalancerNewParamsSessionAffinityAttributesSecureAuto LoadBalancerNewParamsSessionAffinityAttributesSecure = "Auto" + LoadBalancerNewParamsSessionAffinityAttributesSecureAlways LoadBalancerNewParamsSessionAffinityAttributesSecure = "Always" + LoadBalancerNewParamsSessionAffinityAttributesSecureNever LoadBalancerNewParamsSessionAffinityAttributesSecure = "Never" +) + +// Configures the zero-downtime failover between origins within a pool when session +// affinity is enabled. This feature is currently incompatible with Argo, Tiered +// Cache, and Bandwidth Alliance. The supported values are: +// +// - `"none"`: No failover takes place for sessions pinned to the origin (default). +// - `"temporary"`: Traffic will be sent to another other healthy origin until the +// originally pinned origin is available; note that this can potentially result +// in heavy origin flapping. +// - `"sticky"`: The session affinity cookie is updated and subsequent requests are +// sent to the new origin. Note: Zero-downtime failover with sticky sessions is +// currently not supported for session affinity by header. +type LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailover string + +const ( + LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailover = "none" + LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailover = "temporary" + LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailover = "sticky" +) + +// Steering Policy for this load balancer. +// +// - `"off"`: Use `default_pools`. +// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied +// requests, the country for `country_pools` is determined by +// `location_strategy`. +// - `"random"`: Select a pool randomly. +// - `"dynamic_latency"`: Use round trip time to select the closest pool in +// default_pools (requires pool health checks). +// - `"proximity"`: Use the pools' latitude and longitude to select the closest +// pool using the Cloudflare PoP location for proxied requests or the location +// determined by `location_strategy` for non-proxied requests. +// - `"least_outstanding_requests"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of outstanding +// requests. Pools with more pending requests are weighted proportionately less +// relative to others. +// - `"least_connections"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of open connections. +// Pools with more open connections are weighted proportionately less relative to +// others. Supported for HTTP/1 and HTTP/2 connections. +// - `""`: Will map to `"geo"` if you use +// `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. +type LoadBalancerNewParamsSteeringPolicy string + +const ( + LoadBalancerNewParamsSteeringPolicyOff LoadBalancerNewParamsSteeringPolicy = "off" + LoadBalancerNewParamsSteeringPolicyGeo LoadBalancerNewParamsSteeringPolicy = "geo" + LoadBalancerNewParamsSteeringPolicyRandom LoadBalancerNewParamsSteeringPolicy = "random" + LoadBalancerNewParamsSteeringPolicyDynamicLatency LoadBalancerNewParamsSteeringPolicy = "dynamic_latency" + LoadBalancerNewParamsSteeringPolicyProximity LoadBalancerNewParamsSteeringPolicy = "proximity" + LoadBalancerNewParamsSteeringPolicyLeastOutstandingRequests LoadBalancerNewParamsSteeringPolicy = "least_outstanding_requests" + LoadBalancerNewParamsSteeringPolicyLeastConnections LoadBalancerNewParamsSteeringPolicy = "least_connections" + LoadBalancerNewParamsSteeringPolicyEmpty LoadBalancerNewParamsSteeringPolicy = "\"\"" +) + +type LoadBalancerNewResponseEnvelope struct { + Errors []LoadBalancerNewResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerNewResponseEnvelopeMessages `json:"messages,required"` + Result LoadBalancer `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerNewResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerNewResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [LoadBalancerNewResponseEnvelope] +type loadBalancerNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [LoadBalancerNewResponseEnvelopeErrors] +type loadBalancerNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [LoadBalancerNewResponseEnvelopeMessages] +type loadBalancerNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerNewResponseEnvelopeSuccess bool + +const ( + LoadBalancerNewResponseEnvelopeSuccessTrue LoadBalancerNewResponseEnvelopeSuccess = true +) + +type LoadBalancerUpdateParams struct { + ZoneID param.Field[string] `path:"zone_id,required"` + // A list of pool IDs ordered by their failover priority. Pools defined here are + // used by default, or when region_pools are not configured for a given region. + DefaultPools param.Field[[]string] `json:"default_pools,required"` + // The pool ID to use when all other pools are detected as unhealthy. + FallbackPool param.Field[interface{}] `json:"fallback_pool,required"` + // The DNS hostname to associate with your Load Balancer. If this hostname already + // exists as a DNS record in Cloudflare's DNS, the Load Balancer will take + // precedence and the DNS record will not be used. + Name param.Field[string] `json:"name,required"` + // Controls features that modify the routing of requests to pools and origins in + // response to dynamic conditions, such as during the interval between active + // health monitoring requests. For example, zero-downtime failover occurs + // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 + // response codes. If there is another healthy origin in the same pool, the request + // is retried once against this alternate origin. + AdaptiveRouting param.Field[LoadBalancerUpdateParamsAdaptiveRouting] `json:"adaptive_routing"` + // A mapping of country codes to a list of pool IDs (ordered by their failover + // priority) for the given country. Any country not explicitly defined will fall + // back to using the corresponding region_pool mapping if it exists else to + // default_pools. + CountryPools param.Field[interface{}] `json:"country_pools"` + // Object description. + Description param.Field[string] `json:"description"` + // Whether to enable (the default) this load balancer. + Enabled param.Field[bool] `json:"enabled"` + // Controls location-based steering for non-proxied requests. See `steering_policy` + // to learn how steering is affected. + LocationStrategy param.Field[LoadBalancerUpdateParamsLocationStrategy] `json:"location_strategy"` + // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs + // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not + // explicitly defined will fall back to using the corresponding country_pool, then + // region_pool mapping if it exists else to default_pools. + PopPools param.Field[interface{}] `json:"pop_pools"` + // Whether the hostname should be gray clouded (false) or orange clouded (true). + Proxied param.Field[bool] `json:"proxied"` + // Configures pool weights. + // + // - `steering_policy="random"`: A random pool is selected with probability + // proportional to pool weights. + // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each + // pool's outstanding requests. + // - `steering_policy="least_connections"`: Use pool weights to scale each pool's + // open connections. + RandomSteering param.Field[LoadBalancerUpdateParamsRandomSteering] `json:"random_steering"` + // A mapping of region codes to a list of pool IDs (ordered by their failover + // priority) for the given region. Any regions not explicitly defined will fall + // back to using default_pools. + RegionPools param.Field[interface{}] `json:"region_pools"` + // BETA Field Not General Access: A list of rules for this load balancer to + // execute. + Rules param.Field[[]LoadBalancerUpdateParamsRule] `json:"rules"` + // Specifies the type of session affinity the load balancer should use unless + // specified as `"none"` or "" (default). The supported types are: + // + // - `"cookie"`: On the first request to a proxied load balancer, a cookie is + // generated, encoding information of which origin the request will be forwarded + // to. Subsequent requests, by the same client to the same load balancer, will be + // sent to the origin server the cookie encodes, for the duration of the cookie + // and as long as the origin server remains healthy. If the cookie has expired or + // the origin server is unhealthy, then a new origin server is calculated and + // used. + // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin + // selection is stable and based on the client's ip address. + // - `"header"`: On the first request to a proxied load balancer, a session key + // based on the configured HTTP headers (see + // `session_affinity_attributes.headers`) is generated, encoding the request + // headers used for storing in the load balancer session state which origin the + // request will be forwarded to. Subsequent requests to the load balancer with + // the same headers will be sent to the same origin server, for the duration of + // the session and as long as the origin server remains healthy. If the session + // has been idle for the duration of `session_affinity_ttl` seconds or the origin + // server is unhealthy, then a new origin server is calculated and used. See + // `headers` in `session_affinity_attributes` for additional required + // configuration. + SessionAffinity param.Field[LoadBalancerUpdateParamsSessionAffinity] `json:"session_affinity"` + // Configures attributes for session affinity. + SessionAffinityAttributes param.Field[LoadBalancerUpdateParamsSessionAffinityAttributes] `json:"session_affinity_attributes"` + // Time, in seconds, until a client's session expires after being created. Once the + // expiry time has been reached, subsequent requests may get sent to a different + // origin server. The accepted ranges per `session_affinity` policy are: + // + // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used + // unless explicitly set. The accepted range of values is between [1800, 604800]. + // - `"header"`: The current default of 1800 seconds will be used unless explicitly + // set. The accepted range of values is between [30, 3600]. Note: With session + // affinity by header, sessions only expire after they haven't been used for the + // number of seconds specified. + SessionAffinityTTL param.Field[float64] `json:"session_affinity_ttl"` + // Steering Policy for this load balancer. + // + // - `"off"`: Use `default_pools`. + // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied + // requests, the country for `country_pools` is determined by + // `location_strategy`. + // - `"random"`: Select a pool randomly. + // - `"dynamic_latency"`: Use round trip time to select the closest pool in + // default_pools (requires pool health checks). + // - `"proximity"`: Use the pools' latitude and longitude to select the closest + // pool using the Cloudflare PoP location for proxied requests or the location + // determined by `location_strategy` for non-proxied requests. + // - `"least_outstanding_requests"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of outstanding + // requests. Pools with more pending requests are weighted proportionately less + // relative to others. + // - `"least_connections"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of open connections. + // Pools with more open connections are weighted proportionately less relative to + // others. Supported for HTTP/1 and HTTP/2 connections. + // - `""`: Will map to `"geo"` if you use + // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. + SteeringPolicy param.Field[LoadBalancerUpdateParamsSteeringPolicy] `json:"steering_policy"` + // Time to live (TTL) of the DNS entry for the IP address returned by this load + // balancer. This only applies to gray-clouded (unproxied) load balancers. + TTL param.Field[float64] `json:"ttl"` +} + +func (r LoadBalancerUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Controls features that modify the routing of requests to pools and origins in +// response to dynamic conditions, such as during the interval between active +// health monitoring requests. For example, zero-downtime failover occurs +// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 +// response codes. If there is another healthy origin in the same pool, the request +// is retried once against this alternate origin. +type LoadBalancerUpdateParamsAdaptiveRouting struct { + // Extends zero-downtime failover of requests to healthy origins from alternate + // pools, when no healthy alternate exists in the same pool, according to the + // failover order defined by traffic and origin steering. When set false (the + // default) zero-downtime failover will only occur between origins within the same + // pool. See `session_affinity_attributes` for control over when sessions are + // broken or reassigned. + FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` +} + +func (r LoadBalancerUpdateParamsAdaptiveRouting) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Controls location-based steering for non-proxied requests. See `steering_policy` +// to learn how steering is affected. +type LoadBalancerUpdateParamsLocationStrategy struct { + // Determines the authoritative location when ECS is not preferred, does not exist + // in the request, or its GeoIP lookup is unsuccessful. + // + // - `"pop"`: Use the Cloudflare PoP location. + // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is + // unsuccessful, use the Cloudflare PoP location. + Mode param.Field[LoadBalancerUpdateParamsLocationStrategyMode] `json:"mode"` + // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the + // authoritative location. + // + // - `"always"`: Always prefer ECS. + // - `"never"`: Never prefer ECS. + // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. + // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. + PreferEcs param.Field[LoadBalancerUpdateParamsLocationStrategyPreferEcs] `json:"prefer_ecs"` +} + +func (r LoadBalancerUpdateParamsLocationStrategy) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Determines the authoritative location when ECS is not preferred, does not exist +// in the request, or its GeoIP lookup is unsuccessful. +// +// - `"pop"`: Use the Cloudflare PoP location. +// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is +// unsuccessful, use the Cloudflare PoP location. +type LoadBalancerUpdateParamsLocationStrategyMode string + +const ( + LoadBalancerUpdateParamsLocationStrategyModePop LoadBalancerUpdateParamsLocationStrategyMode = "pop" + LoadBalancerUpdateParamsLocationStrategyModeResolverIP LoadBalancerUpdateParamsLocationStrategyMode = "resolver_ip" +) + +// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the +// authoritative location. +// +// - `"always"`: Always prefer ECS. +// - `"never"`: Never prefer ECS. +// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. +// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. +type LoadBalancerUpdateParamsLocationStrategyPreferEcs string + +const ( + LoadBalancerUpdateParamsLocationStrategyPreferEcsAlways LoadBalancerUpdateParamsLocationStrategyPreferEcs = "always" + LoadBalancerUpdateParamsLocationStrategyPreferEcsNever LoadBalancerUpdateParamsLocationStrategyPreferEcs = "never" + LoadBalancerUpdateParamsLocationStrategyPreferEcsProximity LoadBalancerUpdateParamsLocationStrategyPreferEcs = "proximity" + LoadBalancerUpdateParamsLocationStrategyPreferEcsGeo LoadBalancerUpdateParamsLocationStrategyPreferEcs = "geo" +) + +// Configures pool weights. +// +// - `steering_policy="random"`: A random pool is selected with probability +// proportional to pool weights. +// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each +// pool's outstanding requests. +// - `steering_policy="least_connections"`: Use pool weights to scale each pool's +// open connections. +type LoadBalancerUpdateParamsRandomSteering struct { + // The default weight for pools in the load balancer that are not specified in the + // pool_weights map. + DefaultWeight param.Field[float64] `json:"default_weight"` + // A mapping of pool IDs to custom weights. The weight is relative to other pools + // in the load balancer. + PoolWeights param.Field[interface{}] `json:"pool_weights"` +} + +func (r LoadBalancerUpdateParamsRandomSteering) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A rule object containing conditions and overrides for this load balancer to +// evaluate. +type LoadBalancerUpdateParamsRule struct { + // The condition expressions to evaluate. If the condition evaluates to true, the + // overrides or fixed_response in this rule will be applied. An empty condition is + // always true. For more details on condition expressions, please see + // https://developers.cloudflare.com/load-balancing/understand-basics/load-balancing-rules/expressions. + Condition param.Field[string] `json:"condition"` + // Disable this specific rule. It will no longer be evaluated by this load + // balancer. + Disabled param.Field[bool] `json:"disabled"` + // A collection of fields used to directly respond to the eyeball instead of + // routing to a pool. If a fixed_response is supplied the rule will be marked as + // terminates. + FixedResponse param.Field[LoadBalancerUpdateParamsRulesFixedResponse] `json:"fixed_response"` + // Name of this rule. Only used for human readability. + Name param.Field[string] `json:"name"` + // A collection of overrides to apply to the load balancer when this rule's + // condition is true. All fields are optional. + Overrides param.Field[LoadBalancerUpdateParamsRulesOverrides] `json:"overrides"` + // The order in which rules should be executed in relation to each other. Lower + // values are executed first. Values do not need to be sequential. If no value is + // provided for any rule the array order of the rules field will be used to assign + // a priority. + Priority param.Field[int64] `json:"priority"` + // If this rule's condition is true, this causes rule evaluation to stop after + // processing this rule. + Terminates param.Field[bool] `json:"terminates"` +} + +func (r LoadBalancerUpdateParamsRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A collection of fields used to directly respond to the eyeball instead of +// routing to a pool. If a fixed_response is supplied the rule will be marked as +// terminates. +type LoadBalancerUpdateParamsRulesFixedResponse struct { + // The http 'Content-Type' header to include in the response. + ContentType param.Field[string] `json:"content_type"` + // The http 'Location' header to include in the response. + Location param.Field[string] `json:"location"` + // Text to include as the http body. + MessageBody param.Field[string] `json:"message_body"` + // The http status code to respond with. + StatusCode param.Field[int64] `json:"status_code"` +} + +func (r LoadBalancerUpdateParamsRulesFixedResponse) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A collection of overrides to apply to the load balancer when this rule's +// condition is true. All fields are optional. +type LoadBalancerUpdateParamsRulesOverrides struct { + // Controls features that modify the routing of requests to pools and origins in + // response to dynamic conditions, such as during the interval between active + // health monitoring requests. For example, zero-downtime failover occurs + // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 + // response codes. If there is another healthy origin in the same pool, the request + // is retried once against this alternate origin. + AdaptiveRouting param.Field[LoadBalancerUpdateParamsRulesOverridesAdaptiveRouting] `json:"adaptive_routing"` + // A mapping of country codes to a list of pool IDs (ordered by their failover + // priority) for the given country. Any country not explicitly defined will fall + // back to using the corresponding region_pool mapping if it exists else to + // default_pools. + CountryPools param.Field[interface{}] `json:"country_pools"` + // A list of pool IDs ordered by their failover priority. Pools defined here are + // used by default, or when region_pools are not configured for a given region. + DefaultPools param.Field[[]string] `json:"default_pools"` + // The pool ID to use when all other pools are detected as unhealthy. + FallbackPool param.Field[interface{}] `json:"fallback_pool"` + // Controls location-based steering for non-proxied requests. See `steering_policy` + // to learn how steering is affected. + LocationStrategy param.Field[LoadBalancerUpdateParamsRulesOverridesLocationStrategy] `json:"location_strategy"` + // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs + // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not + // explicitly defined will fall back to using the corresponding country_pool, then + // region_pool mapping if it exists else to default_pools. + PopPools param.Field[interface{}] `json:"pop_pools"` + // Configures pool weights. + // + // - `steering_policy="random"`: A random pool is selected with probability + // proportional to pool weights. + // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each + // pool's outstanding requests. + // - `steering_policy="least_connections"`: Use pool weights to scale each pool's + // open connections. + RandomSteering param.Field[LoadBalancerUpdateParamsRulesOverridesRandomSteering] `json:"random_steering"` + // A mapping of region codes to a list of pool IDs (ordered by their failover + // priority) for the given region. Any regions not explicitly defined will fall + // back to using default_pools. + RegionPools param.Field[interface{}] `json:"region_pools"` + // Specifies the type of session affinity the load balancer should use unless + // specified as `"none"` or "" (default). The supported types are: + // + // - `"cookie"`: On the first request to a proxied load balancer, a cookie is + // generated, encoding information of which origin the request will be forwarded + // to. Subsequent requests, by the same client to the same load balancer, will be + // sent to the origin server the cookie encodes, for the duration of the cookie + // and as long as the origin server remains healthy. If the cookie has expired or + // the origin server is unhealthy, then a new origin server is calculated and + // used. + // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin + // selection is stable and based on the client's ip address. + // - `"header"`: On the first request to a proxied load balancer, a session key + // based on the configured HTTP headers (see + // `session_affinity_attributes.headers`) is generated, encoding the request + // headers used for storing in the load balancer session state which origin the + // request will be forwarded to. Subsequent requests to the load balancer with + // the same headers will be sent to the same origin server, for the duration of + // the session and as long as the origin server remains healthy. If the session + // has been idle for the duration of `session_affinity_ttl` seconds or the origin + // server is unhealthy, then a new origin server is calculated and used. See + // `headers` in `session_affinity_attributes` for additional required + // configuration. + SessionAffinity param.Field[LoadBalancerUpdateParamsRulesOverridesSessionAffinity] `json:"session_affinity"` + // Configures attributes for session affinity. + SessionAffinityAttributes param.Field[LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributes] `json:"session_affinity_attributes"` + // Time, in seconds, until a client's session expires after being created. Once the + // expiry time has been reached, subsequent requests may get sent to a different + // origin server. The accepted ranges per `session_affinity` policy are: + // + // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used + // unless explicitly set. The accepted range of values is between [1800, 604800]. + // - `"header"`: The current default of 1800 seconds will be used unless explicitly + // set. The accepted range of values is between [30, 3600]. Note: With session + // affinity by header, sessions only expire after they haven't been used for the + // number of seconds specified. + SessionAffinityTTL param.Field[float64] `json:"session_affinity_ttl"` + // Steering Policy for this load balancer. + // + // - `"off"`: Use `default_pools`. + // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied + // requests, the country for `country_pools` is determined by + // `location_strategy`. + // - `"random"`: Select a pool randomly. + // - `"dynamic_latency"`: Use round trip time to select the closest pool in + // default_pools (requires pool health checks). + // - `"proximity"`: Use the pools' latitude and longitude to select the closest + // pool using the Cloudflare PoP location for proxied requests or the location + // determined by `location_strategy` for non-proxied requests. + // - `"least_outstanding_requests"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of outstanding + // requests. Pools with more pending requests are weighted proportionately less + // relative to others. + // - `"least_connections"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of open connections. + // Pools with more open connections are weighted proportionately less relative to + // others. Supported for HTTP/1 and HTTP/2 connections. + // - `""`: Will map to `"geo"` if you use + // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. + SteeringPolicy param.Field[LoadBalancerUpdateParamsRulesOverridesSteeringPolicy] `json:"steering_policy"` + // Time to live (TTL) of the DNS entry for the IP address returned by this load + // balancer. This only applies to gray-clouded (unproxied) load balancers. + TTL param.Field[float64] `json:"ttl"` +} + +func (r LoadBalancerUpdateParamsRulesOverrides) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Controls features that modify the routing of requests to pools and origins in +// response to dynamic conditions, such as during the interval between active +// health monitoring requests. For example, zero-downtime failover occurs +// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 +// response codes. If there is another healthy origin in the same pool, the request +// is retried once against this alternate origin. +type LoadBalancerUpdateParamsRulesOverridesAdaptiveRouting struct { + // Extends zero-downtime failover of requests to healthy origins from alternate + // pools, when no healthy alternate exists in the same pool, according to the + // failover order defined by traffic and origin steering. When set false (the + // default) zero-downtime failover will only occur between origins within the same + // pool. See `session_affinity_attributes` for control over when sessions are + // broken or reassigned. + FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` +} + +func (r LoadBalancerUpdateParamsRulesOverridesAdaptiveRouting) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Controls location-based steering for non-proxied requests. See `steering_policy` +// to learn how steering is affected. +type LoadBalancerUpdateParamsRulesOverridesLocationStrategy struct { + // Determines the authoritative location when ECS is not preferred, does not exist + // in the request, or its GeoIP lookup is unsuccessful. + // + // - `"pop"`: Use the Cloudflare PoP location. + // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is + // unsuccessful, use the Cloudflare PoP location. + Mode param.Field[LoadBalancerUpdateParamsRulesOverridesLocationStrategyMode] `json:"mode"` + // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the + // authoritative location. + // + // - `"always"`: Always prefer ECS. + // - `"never"`: Never prefer ECS. + // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. + // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. + PreferEcs param.Field[LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs] `json:"prefer_ecs"` +} + +func (r LoadBalancerUpdateParamsRulesOverridesLocationStrategy) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Determines the authoritative location when ECS is not preferred, does not exist +// in the request, or its GeoIP lookup is unsuccessful. +// +// - `"pop"`: Use the Cloudflare PoP location. +// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is +// unsuccessful, use the Cloudflare PoP location. +type LoadBalancerUpdateParamsRulesOverridesLocationStrategyMode string + +const ( + LoadBalancerUpdateParamsRulesOverridesLocationStrategyModePop LoadBalancerUpdateParamsRulesOverridesLocationStrategyMode = "pop" + LoadBalancerUpdateParamsRulesOverridesLocationStrategyModeResolverIP LoadBalancerUpdateParamsRulesOverridesLocationStrategyMode = "resolver_ip" +) + +// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the +// authoritative location. +// +// - `"always"`: Always prefer ECS. +// - `"never"`: Never prefer ECS. +// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. +// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. +type LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs string + +const ( + LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsAlways LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs = "always" + LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsNever LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs = "never" + LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsProximity LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs = "proximity" + LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsGeo LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs = "geo" +) + +// Configures pool weights. +// +// - `steering_policy="random"`: A random pool is selected with probability +// proportional to pool weights. +// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each +// pool's outstanding requests. +// - `steering_policy="least_connections"`: Use pool weights to scale each pool's +// open connections. +type LoadBalancerUpdateParamsRulesOverridesRandomSteering struct { + // The default weight for pools in the load balancer that are not specified in the + // pool_weights map. + DefaultWeight param.Field[float64] `json:"default_weight"` + // A mapping of pool IDs to custom weights. The weight is relative to other pools + // in the load balancer. + PoolWeights param.Field[interface{}] `json:"pool_weights"` +} + +func (r LoadBalancerUpdateParamsRulesOverridesRandomSteering) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Specifies the type of session affinity the load balancer should use unless +// specified as `"none"` or "" (default). The supported types are: +// +// - `"cookie"`: On the first request to a proxied load balancer, a cookie is +// generated, encoding information of which origin the request will be forwarded +// to. Subsequent requests, by the same client to the same load balancer, will be +// sent to the origin server the cookie encodes, for the duration of the cookie +// and as long as the origin server remains healthy. If the cookie has expired or +// the origin server is unhealthy, then a new origin server is calculated and +// used. +// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin +// selection is stable and based on the client's ip address. +// - `"header"`: On the first request to a proxied load balancer, a session key +// based on the configured HTTP headers (see +// `session_affinity_attributes.headers`) is generated, encoding the request +// headers used for storing in the load balancer session state which origin the +// request will be forwarded to. Subsequent requests to the load balancer with +// the same headers will be sent to the same origin server, for the duration of +// the session and as long as the origin server remains healthy. If the session +// has been idle for the duration of `session_affinity_ttl` seconds or the origin +// server is unhealthy, then a new origin server is calculated and used. See +// `headers` in `session_affinity_attributes` for additional required +// configuration. +type LoadBalancerUpdateParamsRulesOverridesSessionAffinity string + +const ( + LoadBalancerUpdateParamsRulesOverridesSessionAffinityNone LoadBalancerUpdateParamsRulesOverridesSessionAffinity = "none" + LoadBalancerUpdateParamsRulesOverridesSessionAffinityCookie LoadBalancerUpdateParamsRulesOverridesSessionAffinity = "cookie" + LoadBalancerUpdateParamsRulesOverridesSessionAffinityIPCookie LoadBalancerUpdateParamsRulesOverridesSessionAffinity = "ip_cookie" + LoadBalancerUpdateParamsRulesOverridesSessionAffinityHeader LoadBalancerUpdateParamsRulesOverridesSessionAffinity = "header" + LoadBalancerUpdateParamsRulesOverridesSessionAffinityEmpty LoadBalancerUpdateParamsRulesOverridesSessionAffinity = "\"\"" +) + +// Configures attributes for session affinity. +type LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributes struct { + // Configures the drain duration in seconds. This field is only used when session + // affinity is enabled on the load balancer. + DrainDuration param.Field[float64] `json:"drain_duration"` + // Configures the names of HTTP headers to base session affinity on when header + // `session_affinity` is enabled. At least one HTTP header name must be provided. + // To specify the exact cookies to be used, include an item in the following + // format: `"cookie:,"` (example) where everything + // after the colon is a comma-separated list of cookie names. Providing only + // `"cookie"` will result in all cookies being used. The default max number of HTTP + // header names that can be provided depends on your plan: 5 for Enterprise, 1 for + // all other plans. + Headers param.Field[[]string] `json:"headers"` + // When header `session_affinity` is enabled, this option can be used to specify + // how HTTP headers on load balancing requests will be used. The supported values + // are: + // + // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers + // specified by the `headers` session affinity attribute, otherwise sessions + // aren't created. + // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP + // headers specified by the `headers` session affinity attribute, otherwise + // sessions aren't created. + RequireAllHeaders param.Field[bool] `json:"require_all_headers"` + // Configures the SameSite attribute on session affinity cookie. Value "Auto" will + // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: + // when using value "None", the secure attribute can not be set to "Never". + Samesite param.Field[LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite] `json:"samesite"` + // Configures the Secure attribute on session affinity cookie. Value "Always" + // indicates the Secure attribute will be set in the Set-Cookie header, "Never" + // indicates the Secure attribute will not be set, and "Auto" will set the Secure + // attribute depending if Always Use HTTPS is enabled. + Secure param.Field[LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecure] `json:"secure"` + // Configures the zero-downtime failover between origins within a pool when session + // affinity is enabled. This feature is currently incompatible with Argo, Tiered + // Cache, and Bandwidth Alliance. The supported values are: + // + // - `"none"`: No failover takes place for sessions pinned to the origin (default). + // - `"temporary"`: Traffic will be sent to another other healthy origin until the + // originally pinned origin is available; note that this can potentially result + // in heavy origin flapping. + // - `"sticky"`: The session affinity cookie is updated and subsequent requests are + // sent to the new origin. Note: Zero-downtime failover with sticky sessions is + // currently not supported for session affinity by header. + ZeroDowntimeFailover param.Field[LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` +} + +func (r LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributes) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures the SameSite attribute on session affinity cookie. Value "Auto" will +// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: +// when using value "None", the secure attribute can not be set to "Never". +type LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite string + +const ( + LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteAuto LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite = "Auto" + LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteLax LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite = "Lax" + LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteNone LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite = "None" + LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteStrict LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite = "Strict" +) + +// Configures the Secure attribute on session affinity cookie. Value "Always" +// indicates the Secure attribute will be set in the Set-Cookie header, "Never" +// indicates the Secure attribute will not be set, and "Auto" will set the Secure +// attribute depending if Always Use HTTPS is enabled. +type LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecure string + +const ( + LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureAuto LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecure = "Auto" + LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureAlways LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecure = "Always" + LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureNever LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecure = "Never" +) + +// Configures the zero-downtime failover between origins within a pool when session +// affinity is enabled. This feature is currently incompatible with Argo, Tiered +// Cache, and Bandwidth Alliance. The supported values are: +// +// - `"none"`: No failover takes place for sessions pinned to the origin (default). +// - `"temporary"`: Traffic will be sent to another other healthy origin until the +// originally pinned origin is available; note that this can potentially result +// in heavy origin flapping. +// - `"sticky"`: The session affinity cookie is updated and subsequent requests are +// sent to the new origin. Note: Zero-downtime failover with sticky sessions is +// currently not supported for session affinity by header. +type LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover string + +const ( + LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "none" + LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "temporary" + LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "sticky" +) + +// Steering Policy for this load balancer. +// +// - `"off"`: Use `default_pools`. +// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied +// requests, the country for `country_pools` is determined by +// `location_strategy`. +// - `"random"`: Select a pool randomly. +// - `"dynamic_latency"`: Use round trip time to select the closest pool in +// default_pools (requires pool health checks). +// - `"proximity"`: Use the pools' latitude and longitude to select the closest +// pool using the Cloudflare PoP location for proxied requests or the location +// determined by `location_strategy` for non-proxied requests. +// - `"least_outstanding_requests"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of outstanding +// requests. Pools with more pending requests are weighted proportionately less +// relative to others. +// - `"least_connections"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of open connections. +// Pools with more open connections are weighted proportionately less relative to +// others. Supported for HTTP/1 and HTTP/2 connections. +// - `""`: Will map to `"geo"` if you use +// `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. +type LoadBalancerUpdateParamsRulesOverridesSteeringPolicy string + +const ( + LoadBalancerUpdateParamsRulesOverridesSteeringPolicyOff LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "off" + LoadBalancerUpdateParamsRulesOverridesSteeringPolicyGeo LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "geo" + LoadBalancerUpdateParamsRulesOverridesSteeringPolicyRandom LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "random" + LoadBalancerUpdateParamsRulesOverridesSteeringPolicyDynamicLatency LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "dynamic_latency" + LoadBalancerUpdateParamsRulesOverridesSteeringPolicyProximity LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "proximity" + LoadBalancerUpdateParamsRulesOverridesSteeringPolicyLeastOutstandingRequests LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "least_outstanding_requests" + LoadBalancerUpdateParamsRulesOverridesSteeringPolicyLeastConnections LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "least_connections" + LoadBalancerUpdateParamsRulesOverridesSteeringPolicyEmpty LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "\"\"" +) + +// Specifies the type of session affinity the load balancer should use unless +// specified as `"none"` or "" (default). The supported types are: +// +// - `"cookie"`: On the first request to a proxied load balancer, a cookie is +// generated, encoding information of which origin the request will be forwarded +// to. Subsequent requests, by the same client to the same load balancer, will be +// sent to the origin server the cookie encodes, for the duration of the cookie +// and as long as the origin server remains healthy. If the cookie has expired or +// the origin server is unhealthy, then a new origin server is calculated and +// used. +// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin +// selection is stable and based on the client's ip address. +// - `"header"`: On the first request to a proxied load balancer, a session key +// based on the configured HTTP headers (see +// `session_affinity_attributes.headers`) is generated, encoding the request +// headers used for storing in the load balancer session state which origin the +// request will be forwarded to. Subsequent requests to the load balancer with +// the same headers will be sent to the same origin server, for the duration of +// the session and as long as the origin server remains healthy. If the session +// has been idle for the duration of `session_affinity_ttl` seconds or the origin +// server is unhealthy, then a new origin server is calculated and used. See +// `headers` in `session_affinity_attributes` for additional required +// configuration. +type LoadBalancerUpdateParamsSessionAffinity string + +const ( + LoadBalancerUpdateParamsSessionAffinityNone LoadBalancerUpdateParamsSessionAffinity = "none" + LoadBalancerUpdateParamsSessionAffinityCookie LoadBalancerUpdateParamsSessionAffinity = "cookie" + LoadBalancerUpdateParamsSessionAffinityIPCookie LoadBalancerUpdateParamsSessionAffinity = "ip_cookie" + LoadBalancerUpdateParamsSessionAffinityHeader LoadBalancerUpdateParamsSessionAffinity = "header" + LoadBalancerUpdateParamsSessionAffinityEmpty LoadBalancerUpdateParamsSessionAffinity = "\"\"" +) + +// Configures attributes for session affinity. +type LoadBalancerUpdateParamsSessionAffinityAttributes struct { + // Configures the drain duration in seconds. This field is only used when session + // affinity is enabled on the load balancer. + DrainDuration param.Field[float64] `json:"drain_duration"` + // Configures the names of HTTP headers to base session affinity on when header + // `session_affinity` is enabled. At least one HTTP header name must be provided. + // To specify the exact cookies to be used, include an item in the following + // format: `"cookie:,"` (example) where everything + // after the colon is a comma-separated list of cookie names. Providing only + // `"cookie"` will result in all cookies being used. The default max number of HTTP + // header names that can be provided depends on your plan: 5 for Enterprise, 1 for + // all other plans. + Headers param.Field[[]string] `json:"headers"` + // When header `session_affinity` is enabled, this option can be used to specify + // how HTTP headers on load balancing requests will be used. The supported values + // are: + // + // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers + // specified by the `headers` session affinity attribute, otherwise sessions + // aren't created. + // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP + // headers specified by the `headers` session affinity attribute, otherwise + // sessions aren't created. + RequireAllHeaders param.Field[bool] `json:"require_all_headers"` + // Configures the SameSite attribute on session affinity cookie. Value "Auto" will + // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: + // when using value "None", the secure attribute can not be set to "Never". + Samesite param.Field[LoadBalancerUpdateParamsSessionAffinityAttributesSamesite] `json:"samesite"` + // Configures the Secure attribute on session affinity cookie. Value "Always" + // indicates the Secure attribute will be set in the Set-Cookie header, "Never" + // indicates the Secure attribute will not be set, and "Auto" will set the Secure + // attribute depending if Always Use HTTPS is enabled. + Secure param.Field[LoadBalancerUpdateParamsSessionAffinityAttributesSecure] `json:"secure"` + // Configures the zero-downtime failover between origins within a pool when session + // affinity is enabled. This feature is currently incompatible with Argo, Tiered + // Cache, and Bandwidth Alliance. The supported values are: + // + // - `"none"`: No failover takes place for sessions pinned to the origin (default). + // - `"temporary"`: Traffic will be sent to another other healthy origin until the + // originally pinned origin is available; note that this can potentially result + // in heavy origin flapping. + // - `"sticky"`: The session affinity cookie is updated and subsequent requests are + // sent to the new origin. Note: Zero-downtime failover with sticky sessions is + // currently not supported for session affinity by header. + ZeroDowntimeFailover param.Field[LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` +} + +func (r LoadBalancerUpdateParamsSessionAffinityAttributes) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures the SameSite attribute on session affinity cookie. Value "Auto" will +// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: +// when using value "None", the secure attribute can not be set to "Never". +type LoadBalancerUpdateParamsSessionAffinityAttributesSamesite string + +const ( + LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteAuto LoadBalancerUpdateParamsSessionAffinityAttributesSamesite = "Auto" + LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteLax LoadBalancerUpdateParamsSessionAffinityAttributesSamesite = "Lax" + LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteNone LoadBalancerUpdateParamsSessionAffinityAttributesSamesite = "None" + LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteStrict LoadBalancerUpdateParamsSessionAffinityAttributesSamesite = "Strict" +) + +// Configures the Secure attribute on session affinity cookie. Value "Always" +// indicates the Secure attribute will be set in the Set-Cookie header, "Never" +// indicates the Secure attribute will not be set, and "Auto" will set the Secure +// attribute depending if Always Use HTTPS is enabled. +type LoadBalancerUpdateParamsSessionAffinityAttributesSecure string + +const ( + LoadBalancerUpdateParamsSessionAffinityAttributesSecureAuto LoadBalancerUpdateParamsSessionAffinityAttributesSecure = "Auto" + LoadBalancerUpdateParamsSessionAffinityAttributesSecureAlways LoadBalancerUpdateParamsSessionAffinityAttributesSecure = "Always" + LoadBalancerUpdateParamsSessionAffinityAttributesSecureNever LoadBalancerUpdateParamsSessionAffinityAttributesSecure = "Never" +) + +// Configures the zero-downtime failover between origins within a pool when session +// affinity is enabled. This feature is currently incompatible with Argo, Tiered +// Cache, and Bandwidth Alliance. The supported values are: +// +// - `"none"`: No failover takes place for sessions pinned to the origin (default). +// - `"temporary"`: Traffic will be sent to another other healthy origin until the +// originally pinned origin is available; note that this can potentially result +// in heavy origin flapping. +// - `"sticky"`: The session affinity cookie is updated and subsequent requests are +// sent to the new origin. Note: Zero-downtime failover with sticky sessions is +// currently not supported for session affinity by header. +type LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailover string + +const ( + LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailover = "none" + LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailover = "temporary" + LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailover = "sticky" +) + +// Steering Policy for this load balancer. +// +// - `"off"`: Use `default_pools`. +// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied +// requests, the country for `country_pools` is determined by +// `location_strategy`. +// - `"random"`: Select a pool randomly. +// - `"dynamic_latency"`: Use round trip time to select the closest pool in +// default_pools (requires pool health checks). +// - `"proximity"`: Use the pools' latitude and longitude to select the closest +// pool using the Cloudflare PoP location for proxied requests or the location +// determined by `location_strategy` for non-proxied requests. +// - `"least_outstanding_requests"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of outstanding +// requests. Pools with more pending requests are weighted proportionately less +// relative to others. +// - `"least_connections"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of open connections. +// Pools with more open connections are weighted proportionately less relative to +// others. Supported for HTTP/1 and HTTP/2 connections. +// - `""`: Will map to `"geo"` if you use +// `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. +type LoadBalancerUpdateParamsSteeringPolicy string + +const ( + LoadBalancerUpdateParamsSteeringPolicyOff LoadBalancerUpdateParamsSteeringPolicy = "off" + LoadBalancerUpdateParamsSteeringPolicyGeo LoadBalancerUpdateParamsSteeringPolicy = "geo" + LoadBalancerUpdateParamsSteeringPolicyRandom LoadBalancerUpdateParamsSteeringPolicy = "random" + LoadBalancerUpdateParamsSteeringPolicyDynamicLatency LoadBalancerUpdateParamsSteeringPolicy = "dynamic_latency" + LoadBalancerUpdateParamsSteeringPolicyProximity LoadBalancerUpdateParamsSteeringPolicy = "proximity" + LoadBalancerUpdateParamsSteeringPolicyLeastOutstandingRequests LoadBalancerUpdateParamsSteeringPolicy = "least_outstanding_requests" + LoadBalancerUpdateParamsSteeringPolicyLeastConnections LoadBalancerUpdateParamsSteeringPolicy = "least_connections" + LoadBalancerUpdateParamsSteeringPolicyEmpty LoadBalancerUpdateParamsSteeringPolicy = "\"\"" +) + +type LoadBalancerUpdateResponseEnvelope struct { + Errors []LoadBalancerUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerUpdateResponseEnvelopeMessages `json:"messages,required"` + Result LoadBalancer `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerUpdateResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [LoadBalancerUpdateResponseEnvelope] +type loadBalancerUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [LoadBalancerUpdateResponseEnvelopeErrors] +type loadBalancerUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [LoadBalancerUpdateResponseEnvelopeMessages] +type loadBalancerUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerUpdateResponseEnvelopeSuccess bool + +const ( + LoadBalancerUpdateResponseEnvelopeSuccessTrue LoadBalancerUpdateResponseEnvelopeSuccess = true +) + +type LoadBalancerListParams struct { + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type LoadBalancerListResponseEnvelope struct { + Errors []LoadBalancerListResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerListResponseEnvelopeMessages `json:"messages,required"` + Result []LoadBalancer `json:"result,required,nullable"` + // Whether the API call was successful + Success LoadBalancerListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo LoadBalancerListResponseEnvelopeResultInfo `json:"result_info"` + JSON loadBalancerListResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerListResponseEnvelopeJSON contains the JSON metadata for the struct +// [LoadBalancerListResponseEnvelope] +type loadBalancerListResponseEnvelopeJSON 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 *LoadBalancerListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerListResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [LoadBalancerListResponseEnvelopeErrors] +type loadBalancerListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerListResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [LoadBalancerListResponseEnvelopeMessages] +type loadBalancerListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerListResponseEnvelopeSuccess bool + +const ( + LoadBalancerListResponseEnvelopeSuccessTrue LoadBalancerListResponseEnvelopeSuccess = true +) + +type LoadBalancerListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON loadBalancerListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// loadBalancerListResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [LoadBalancerListResponseEnvelopeResultInfo] +type loadBalancerListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerDeleteParams struct { + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type LoadBalancerDeleteResponseEnvelope struct { + Errors []LoadBalancerDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerDeleteResponseEnvelopeMessages `json:"messages,required"` + Result LoadBalancerDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerDeleteResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [LoadBalancerDeleteResponseEnvelope] +type loadBalancerDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [LoadBalancerDeleteResponseEnvelopeErrors] +type loadBalancerDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [LoadBalancerDeleteResponseEnvelopeMessages] +type loadBalancerDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerDeleteResponseEnvelopeSuccess bool + +const ( + LoadBalancerDeleteResponseEnvelopeSuccessTrue LoadBalancerDeleteResponseEnvelopeSuccess = true +) + +type LoadBalancerEditParams struct { + ZoneID param.Field[string] `path:"zone_id,required"` + // Controls features that modify the routing of requests to pools and origins in + // response to dynamic conditions, such as during the interval between active + // health monitoring requests. For example, zero-downtime failover occurs + // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 + // response codes. If there is another healthy origin in the same pool, the request + // is retried once against this alternate origin. + AdaptiveRouting param.Field[LoadBalancerEditParamsAdaptiveRouting] `json:"adaptive_routing"` + // A mapping of country codes to a list of pool IDs (ordered by their failover + // priority) for the given country. Any country not explicitly defined will fall + // back to using the corresponding region_pool mapping if it exists else to + // default_pools. + CountryPools param.Field[interface{}] `json:"country_pools"` + // A list of pool IDs ordered by their failover priority. Pools defined here are + // used by default, or when region_pools are not configured for a given region. + DefaultPools param.Field[[]string] `json:"default_pools"` + // Object description. + Description param.Field[string] `json:"description"` + // Whether to enable (the default) this load balancer. + Enabled param.Field[bool] `json:"enabled"` + // The pool ID to use when all other pools are detected as unhealthy. + FallbackPool param.Field[interface{}] `json:"fallback_pool"` + // Controls location-based steering for non-proxied requests. See `steering_policy` + // to learn how steering is affected. + LocationStrategy param.Field[LoadBalancerEditParamsLocationStrategy] `json:"location_strategy"` + // The DNS hostname to associate with your Load Balancer. If this hostname already + // exists as a DNS record in Cloudflare's DNS, the Load Balancer will take + // precedence and the DNS record will not be used. + Name param.Field[string] `json:"name"` + // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs + // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not + // explicitly defined will fall back to using the corresponding country_pool, then + // region_pool mapping if it exists else to default_pools. + PopPools param.Field[interface{}] `json:"pop_pools"` + // Whether the hostname should be gray clouded (false) or orange clouded (true). + Proxied param.Field[bool] `json:"proxied"` + // Configures pool weights. + // + // - `steering_policy="random"`: A random pool is selected with probability + // proportional to pool weights. + // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each + // pool's outstanding requests. + // - `steering_policy="least_connections"`: Use pool weights to scale each pool's + // open connections. + RandomSteering param.Field[LoadBalancerEditParamsRandomSteering] `json:"random_steering"` + // A mapping of region codes to a list of pool IDs (ordered by their failover + // priority) for the given region. Any regions not explicitly defined will fall + // back to using default_pools. + RegionPools param.Field[interface{}] `json:"region_pools"` + // BETA Field Not General Access: A list of rules for this load balancer to + // execute. + Rules param.Field[[]LoadBalancerEditParamsRule] `json:"rules"` + // Specifies the type of session affinity the load balancer should use unless + // specified as `"none"` or "" (default). The supported types are: + // + // - `"cookie"`: On the first request to a proxied load balancer, a cookie is + // generated, encoding information of which origin the request will be forwarded + // to. Subsequent requests, by the same client to the same load balancer, will be + // sent to the origin server the cookie encodes, for the duration of the cookie + // and as long as the origin server remains healthy. If the cookie has expired or + // the origin server is unhealthy, then a new origin server is calculated and + // used. + // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin + // selection is stable and based on the client's ip address. + // - `"header"`: On the first request to a proxied load balancer, a session key + // based on the configured HTTP headers (see + // `session_affinity_attributes.headers`) is generated, encoding the request + // headers used for storing in the load balancer session state which origin the + // request will be forwarded to. Subsequent requests to the load balancer with + // the same headers will be sent to the same origin server, for the duration of + // the session and as long as the origin server remains healthy. If the session + // has been idle for the duration of `session_affinity_ttl` seconds or the origin + // server is unhealthy, then a new origin server is calculated and used. See + // `headers` in `session_affinity_attributes` for additional required + // configuration. + SessionAffinity param.Field[LoadBalancerEditParamsSessionAffinity] `json:"session_affinity"` + // Configures attributes for session affinity. + SessionAffinityAttributes param.Field[LoadBalancerEditParamsSessionAffinityAttributes] `json:"session_affinity_attributes"` + // Time, in seconds, until a client's session expires after being created. Once the + // expiry time has been reached, subsequent requests may get sent to a different + // origin server. The accepted ranges per `session_affinity` policy are: + // + // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used + // unless explicitly set. The accepted range of values is between [1800, 604800]. + // - `"header"`: The current default of 1800 seconds will be used unless explicitly + // set. The accepted range of values is between [30, 3600]. Note: With session + // affinity by header, sessions only expire after they haven't been used for the + // number of seconds specified. + SessionAffinityTTL param.Field[float64] `json:"session_affinity_ttl"` + // Steering Policy for this load balancer. + // + // - `"off"`: Use `default_pools`. + // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied + // requests, the country for `country_pools` is determined by + // `location_strategy`. + // - `"random"`: Select a pool randomly. + // - `"dynamic_latency"`: Use round trip time to select the closest pool in + // default_pools (requires pool health checks). + // - `"proximity"`: Use the pools' latitude and longitude to select the closest + // pool using the Cloudflare PoP location for proxied requests or the location + // determined by `location_strategy` for non-proxied requests. + // - `"least_outstanding_requests"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of outstanding + // requests. Pools with more pending requests are weighted proportionately less + // relative to others. + // - `"least_connections"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of open connections. + // Pools with more open connections are weighted proportionately less relative to + // others. Supported for HTTP/1 and HTTP/2 connections. + // - `""`: Will map to `"geo"` if you use + // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. + SteeringPolicy param.Field[LoadBalancerEditParamsSteeringPolicy] `json:"steering_policy"` + // Time to live (TTL) of the DNS entry for the IP address returned by this load + // balancer. This only applies to gray-clouded (unproxied) load balancers. + TTL param.Field[float64] `json:"ttl"` +} + +func (r LoadBalancerEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Controls features that modify the routing of requests to pools and origins in +// response to dynamic conditions, such as during the interval between active +// health monitoring requests. For example, zero-downtime failover occurs +// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 +// response codes. If there is another healthy origin in the same pool, the request +// is retried once against this alternate origin. +type LoadBalancerEditParamsAdaptiveRouting struct { + // Extends zero-downtime failover of requests to healthy origins from alternate + // pools, when no healthy alternate exists in the same pool, according to the + // failover order defined by traffic and origin steering. When set false (the + // default) zero-downtime failover will only occur between origins within the same + // pool. See `session_affinity_attributes` for control over when sessions are + // broken or reassigned. + FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` +} + +func (r LoadBalancerEditParamsAdaptiveRouting) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Controls location-based steering for non-proxied requests. See `steering_policy` +// to learn how steering is affected. +type LoadBalancerEditParamsLocationStrategy struct { + // Determines the authoritative location when ECS is not preferred, does not exist + // in the request, or its GeoIP lookup is unsuccessful. + // + // - `"pop"`: Use the Cloudflare PoP location. + // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is + // unsuccessful, use the Cloudflare PoP location. + Mode param.Field[LoadBalancerEditParamsLocationStrategyMode] `json:"mode"` + // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the + // authoritative location. + // + // - `"always"`: Always prefer ECS. + // - `"never"`: Never prefer ECS. + // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. + // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. + PreferEcs param.Field[LoadBalancerEditParamsLocationStrategyPreferEcs] `json:"prefer_ecs"` +} + +func (r LoadBalancerEditParamsLocationStrategy) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Determines the authoritative location when ECS is not preferred, does not exist +// in the request, or its GeoIP lookup is unsuccessful. +// +// - `"pop"`: Use the Cloudflare PoP location. +// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is +// unsuccessful, use the Cloudflare PoP location. +type LoadBalancerEditParamsLocationStrategyMode string + +const ( + LoadBalancerEditParamsLocationStrategyModePop LoadBalancerEditParamsLocationStrategyMode = "pop" + LoadBalancerEditParamsLocationStrategyModeResolverIP LoadBalancerEditParamsLocationStrategyMode = "resolver_ip" +) + +// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the +// authoritative location. +// +// - `"always"`: Always prefer ECS. +// - `"never"`: Never prefer ECS. +// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. +// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. +type LoadBalancerEditParamsLocationStrategyPreferEcs string + +const ( + LoadBalancerEditParamsLocationStrategyPreferEcsAlways LoadBalancerEditParamsLocationStrategyPreferEcs = "always" + LoadBalancerEditParamsLocationStrategyPreferEcsNever LoadBalancerEditParamsLocationStrategyPreferEcs = "never" + LoadBalancerEditParamsLocationStrategyPreferEcsProximity LoadBalancerEditParamsLocationStrategyPreferEcs = "proximity" + LoadBalancerEditParamsLocationStrategyPreferEcsGeo LoadBalancerEditParamsLocationStrategyPreferEcs = "geo" +) + +// Configures pool weights. +// +// - `steering_policy="random"`: A random pool is selected with probability +// proportional to pool weights. +// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each +// pool's outstanding requests. +// - `steering_policy="least_connections"`: Use pool weights to scale each pool's +// open connections. +type LoadBalancerEditParamsRandomSteering struct { + // The default weight for pools in the load balancer that are not specified in the + // pool_weights map. + DefaultWeight param.Field[float64] `json:"default_weight"` + // A mapping of pool IDs to custom weights. The weight is relative to other pools + // in the load balancer. + PoolWeights param.Field[interface{}] `json:"pool_weights"` +} + +func (r LoadBalancerEditParamsRandomSteering) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A rule object containing conditions and overrides for this load balancer to +// evaluate. +type LoadBalancerEditParamsRule struct { + // The condition expressions to evaluate. If the condition evaluates to true, the + // overrides or fixed_response in this rule will be applied. An empty condition is + // always true. For more details on condition expressions, please see + // https://developers.cloudflare.com/load-balancing/understand-basics/load-balancing-rules/expressions. + Condition param.Field[string] `json:"condition"` + // Disable this specific rule. It will no longer be evaluated by this load + // balancer. + Disabled param.Field[bool] `json:"disabled"` + // A collection of fields used to directly respond to the eyeball instead of + // routing to a pool. If a fixed_response is supplied the rule will be marked as + // terminates. + FixedResponse param.Field[LoadBalancerEditParamsRulesFixedResponse] `json:"fixed_response"` + // Name of this rule. Only used for human readability. + Name param.Field[string] `json:"name"` + // A collection of overrides to apply to the load balancer when this rule's + // condition is true. All fields are optional. + Overrides param.Field[LoadBalancerEditParamsRulesOverrides] `json:"overrides"` + // The order in which rules should be executed in relation to each other. Lower + // values are executed first. Values do not need to be sequential. If no value is + // provided for any rule the array order of the rules field will be used to assign + // a priority. + Priority param.Field[int64] `json:"priority"` + // If this rule's condition is true, this causes rule evaluation to stop after + // processing this rule. + Terminates param.Field[bool] `json:"terminates"` +} + +func (r LoadBalancerEditParamsRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A collection of fields used to directly respond to the eyeball instead of +// routing to a pool. If a fixed_response is supplied the rule will be marked as +// terminates. +type LoadBalancerEditParamsRulesFixedResponse struct { + // The http 'Content-Type' header to include in the response. + ContentType param.Field[string] `json:"content_type"` + // The http 'Location' header to include in the response. + Location param.Field[string] `json:"location"` + // Text to include as the http body. + MessageBody param.Field[string] `json:"message_body"` + // The http status code to respond with. + StatusCode param.Field[int64] `json:"status_code"` +} + +func (r LoadBalancerEditParamsRulesFixedResponse) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A collection of overrides to apply to the load balancer when this rule's +// condition is true. All fields are optional. +type LoadBalancerEditParamsRulesOverrides struct { + // Controls features that modify the routing of requests to pools and origins in + // response to dynamic conditions, such as during the interval between active + // health monitoring requests. For example, zero-downtime failover occurs + // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 + // response codes. If there is another healthy origin in the same pool, the request + // is retried once against this alternate origin. + AdaptiveRouting param.Field[LoadBalancerEditParamsRulesOverridesAdaptiveRouting] `json:"adaptive_routing"` + // A mapping of country codes to a list of pool IDs (ordered by their failover + // priority) for the given country. Any country not explicitly defined will fall + // back to using the corresponding region_pool mapping if it exists else to + // default_pools. + CountryPools param.Field[interface{}] `json:"country_pools"` + // A list of pool IDs ordered by their failover priority. Pools defined here are + // used by default, or when region_pools are not configured for a given region. + DefaultPools param.Field[[]string] `json:"default_pools"` + // The pool ID to use when all other pools are detected as unhealthy. + FallbackPool param.Field[interface{}] `json:"fallback_pool"` + // Controls location-based steering for non-proxied requests. See `steering_policy` + // to learn how steering is affected. + LocationStrategy param.Field[LoadBalancerEditParamsRulesOverridesLocationStrategy] `json:"location_strategy"` + // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs + // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not + // explicitly defined will fall back to using the corresponding country_pool, then + // region_pool mapping if it exists else to default_pools. + PopPools param.Field[interface{}] `json:"pop_pools"` + // Configures pool weights. + // + // - `steering_policy="random"`: A random pool is selected with probability + // proportional to pool weights. + // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each + // pool's outstanding requests. + // - `steering_policy="least_connections"`: Use pool weights to scale each pool's + // open connections. + RandomSteering param.Field[LoadBalancerEditParamsRulesOverridesRandomSteering] `json:"random_steering"` + // A mapping of region codes to a list of pool IDs (ordered by their failover + // priority) for the given region. Any regions not explicitly defined will fall + // back to using default_pools. + RegionPools param.Field[interface{}] `json:"region_pools"` + // Specifies the type of session affinity the load balancer should use unless + // specified as `"none"` or "" (default). The supported types are: + // + // - `"cookie"`: On the first request to a proxied load balancer, a cookie is + // generated, encoding information of which origin the request will be forwarded + // to. Subsequent requests, by the same client to the same load balancer, will be + // sent to the origin server the cookie encodes, for the duration of the cookie + // and as long as the origin server remains healthy. If the cookie has expired or + // the origin server is unhealthy, then a new origin server is calculated and + // used. + // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin + // selection is stable and based on the client's ip address. + // - `"header"`: On the first request to a proxied load balancer, a session key + // based on the configured HTTP headers (see + // `session_affinity_attributes.headers`) is generated, encoding the request + // headers used for storing in the load balancer session state which origin the + // request will be forwarded to. Subsequent requests to the load balancer with + // the same headers will be sent to the same origin server, for the duration of + // the session and as long as the origin server remains healthy. If the session + // has been idle for the duration of `session_affinity_ttl` seconds or the origin + // server is unhealthy, then a new origin server is calculated and used. See + // `headers` in `session_affinity_attributes` for additional required + // configuration. + SessionAffinity param.Field[LoadBalancerEditParamsRulesOverridesSessionAffinity] `json:"session_affinity"` + // Configures attributes for session affinity. + SessionAffinityAttributes param.Field[LoadBalancerEditParamsRulesOverridesSessionAffinityAttributes] `json:"session_affinity_attributes"` + // Time, in seconds, until a client's session expires after being created. Once the + // expiry time has been reached, subsequent requests may get sent to a different + // origin server. The accepted ranges per `session_affinity` policy are: + // + // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used + // unless explicitly set. The accepted range of values is between [1800, 604800]. + // - `"header"`: The current default of 1800 seconds will be used unless explicitly + // set. The accepted range of values is between [30, 3600]. Note: With session + // affinity by header, sessions only expire after they haven't been used for the + // number of seconds specified. + SessionAffinityTTL param.Field[float64] `json:"session_affinity_ttl"` + // Steering Policy for this load balancer. + // + // - `"off"`: Use `default_pools`. + // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied + // requests, the country for `country_pools` is determined by + // `location_strategy`. + // - `"random"`: Select a pool randomly. + // - `"dynamic_latency"`: Use round trip time to select the closest pool in + // default_pools (requires pool health checks). + // - `"proximity"`: Use the pools' latitude and longitude to select the closest + // pool using the Cloudflare PoP location for proxied requests or the location + // determined by `location_strategy` for non-proxied requests. + // - `"least_outstanding_requests"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of outstanding + // requests. Pools with more pending requests are weighted proportionately less + // relative to others. + // - `"least_connections"`: Select a pool by taking into consideration + // `random_steering` weights, as well as each pool's number of open connections. + // Pools with more open connections are weighted proportionately less relative to + // others. Supported for HTTP/1 and HTTP/2 connections. + // - `""`: Will map to `"geo"` if you use + // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. + SteeringPolicy param.Field[LoadBalancerEditParamsRulesOverridesSteeringPolicy] `json:"steering_policy"` + // Time to live (TTL) of the DNS entry for the IP address returned by this load + // balancer. This only applies to gray-clouded (unproxied) load balancers. + TTL param.Field[float64] `json:"ttl"` +} + +func (r LoadBalancerEditParamsRulesOverrides) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Controls features that modify the routing of requests to pools and origins in +// response to dynamic conditions, such as during the interval between active +// health monitoring requests. For example, zero-downtime failover occurs +// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 +// response codes. If there is another healthy origin in the same pool, the request +// is retried once against this alternate origin. +type LoadBalancerEditParamsRulesOverridesAdaptiveRouting struct { + // Extends zero-downtime failover of requests to healthy origins from alternate + // pools, when no healthy alternate exists in the same pool, according to the + // failover order defined by traffic and origin steering. When set false (the + // default) zero-downtime failover will only occur between origins within the same + // pool. See `session_affinity_attributes` for control over when sessions are + // broken or reassigned. + FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` +} + +func (r LoadBalancerEditParamsRulesOverridesAdaptiveRouting) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Controls location-based steering for non-proxied requests. See `steering_policy` +// to learn how steering is affected. +type LoadBalancerEditParamsRulesOverridesLocationStrategy struct { + // Determines the authoritative location when ECS is not preferred, does not exist + // in the request, or its GeoIP lookup is unsuccessful. + // + // - `"pop"`: Use the Cloudflare PoP location. + // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is + // unsuccessful, use the Cloudflare PoP location. + Mode param.Field[LoadBalancerEditParamsRulesOverridesLocationStrategyMode] `json:"mode"` + // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the + // authoritative location. + // + // - `"always"`: Always prefer ECS. + // - `"never"`: Never prefer ECS. + // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. + // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. + PreferEcs param.Field[LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs] `json:"prefer_ecs"` +} + +func (r LoadBalancerEditParamsRulesOverridesLocationStrategy) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Determines the authoritative location when ECS is not preferred, does not exist +// in the request, or its GeoIP lookup is unsuccessful. +// +// - `"pop"`: Use the Cloudflare PoP location. +// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is +// unsuccessful, use the Cloudflare PoP location. +type LoadBalancerEditParamsRulesOverridesLocationStrategyMode string + +const ( + LoadBalancerEditParamsRulesOverridesLocationStrategyModePop LoadBalancerEditParamsRulesOverridesLocationStrategyMode = "pop" + LoadBalancerEditParamsRulesOverridesLocationStrategyModeResolverIP LoadBalancerEditParamsRulesOverridesLocationStrategyMode = "resolver_ip" +) + +// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the +// authoritative location. +// +// - `"always"`: Always prefer ECS. +// - `"never"`: Never prefer ECS. +// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. +// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. +type LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs string + +const ( + LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsAlways LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs = "always" + LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsNever LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs = "never" + LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsProximity LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs = "proximity" + LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsGeo LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs = "geo" +) + +// Configures pool weights. +// +// - `steering_policy="random"`: A random pool is selected with probability +// proportional to pool weights. +// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each +// pool's outstanding requests. +// - `steering_policy="least_connections"`: Use pool weights to scale each pool's +// open connections. +type LoadBalancerEditParamsRulesOverridesRandomSteering struct { + // The default weight for pools in the load balancer that are not specified in the + // pool_weights map. + DefaultWeight param.Field[float64] `json:"default_weight"` + // A mapping of pool IDs to custom weights. The weight is relative to other pools + // in the load balancer. + PoolWeights param.Field[interface{}] `json:"pool_weights"` +} + +func (r LoadBalancerEditParamsRulesOverridesRandomSteering) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Specifies the type of session affinity the load balancer should use unless +// specified as `"none"` or "" (default). The supported types are: +// +// - `"cookie"`: On the first request to a proxied load balancer, a cookie is +// generated, encoding information of which origin the request will be forwarded +// to. Subsequent requests, by the same client to the same load balancer, will be +// sent to the origin server the cookie encodes, for the duration of the cookie +// and as long as the origin server remains healthy. If the cookie has expired or +// the origin server is unhealthy, then a new origin server is calculated and +// used. +// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin +// selection is stable and based on the client's ip address. +// - `"header"`: On the first request to a proxied load balancer, a session key +// based on the configured HTTP headers (see +// `session_affinity_attributes.headers`) is generated, encoding the request +// headers used for storing in the load balancer session state which origin the +// request will be forwarded to. Subsequent requests to the load balancer with +// the same headers will be sent to the same origin server, for the duration of +// the session and as long as the origin server remains healthy. If the session +// has been idle for the duration of `session_affinity_ttl` seconds or the origin +// server is unhealthy, then a new origin server is calculated and used. See +// `headers` in `session_affinity_attributes` for additional required +// configuration. +type LoadBalancerEditParamsRulesOverridesSessionAffinity string + +const ( + LoadBalancerEditParamsRulesOverridesSessionAffinityNone LoadBalancerEditParamsRulesOverridesSessionAffinity = "none" + LoadBalancerEditParamsRulesOverridesSessionAffinityCookie LoadBalancerEditParamsRulesOverridesSessionAffinity = "cookie" + LoadBalancerEditParamsRulesOverridesSessionAffinityIPCookie LoadBalancerEditParamsRulesOverridesSessionAffinity = "ip_cookie" + LoadBalancerEditParamsRulesOverridesSessionAffinityHeader LoadBalancerEditParamsRulesOverridesSessionAffinity = "header" + LoadBalancerEditParamsRulesOverridesSessionAffinityEmpty LoadBalancerEditParamsRulesOverridesSessionAffinity = "\"\"" +) + +// Configures attributes for session affinity. +type LoadBalancerEditParamsRulesOverridesSessionAffinityAttributes struct { + // Configures the drain duration in seconds. This field is only used when session + // affinity is enabled on the load balancer. + DrainDuration param.Field[float64] `json:"drain_duration"` + // Configures the names of HTTP headers to base session affinity on when header + // `session_affinity` is enabled. At least one HTTP header name must be provided. + // To specify the exact cookies to be used, include an item in the following + // format: `"cookie:,"` (example) where everything + // after the colon is a comma-separated list of cookie names. Providing only + // `"cookie"` will result in all cookies being used. The default max number of HTTP + // header names that can be provided depends on your plan: 5 for Enterprise, 1 for + // all other plans. + Headers param.Field[[]string] `json:"headers"` + // When header `session_affinity` is enabled, this option can be used to specify + // how HTTP headers on load balancing requests will be used. The supported values + // are: + // + // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers + // specified by the `headers` session affinity attribute, otherwise sessions + // aren't created. + // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP + // headers specified by the `headers` session affinity attribute, otherwise + // sessions aren't created. + RequireAllHeaders param.Field[bool] `json:"require_all_headers"` + // Configures the SameSite attribute on session affinity cookie. Value "Auto" will + // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: + // when using value "None", the secure attribute can not be set to "Never". + Samesite param.Field[LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite] `json:"samesite"` + // Configures the Secure attribute on session affinity cookie. Value "Always" + // indicates the Secure attribute will be set in the Set-Cookie header, "Never" + // indicates the Secure attribute will not be set, and "Auto" will set the Secure + // attribute depending if Always Use HTTPS is enabled. + Secure param.Field[LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecure] `json:"secure"` + // Configures the zero-downtime failover between origins within a pool when session + // affinity is enabled. This feature is currently incompatible with Argo, Tiered + // Cache, and Bandwidth Alliance. The supported values are: + // + // - `"none"`: No failover takes place for sessions pinned to the origin (default). + // - `"temporary"`: Traffic will be sent to another other healthy origin until the + // originally pinned origin is available; note that this can potentially result + // in heavy origin flapping. + // - `"sticky"`: The session affinity cookie is updated and subsequent requests are + // sent to the new origin. Note: Zero-downtime failover with sticky sessions is + // currently not supported for session affinity by header. + ZeroDowntimeFailover param.Field[LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` +} + +func (r LoadBalancerEditParamsRulesOverridesSessionAffinityAttributes) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures the SameSite attribute on session affinity cookie. Value "Auto" will +// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: +// when using value "None", the secure attribute can not be set to "Never". +type LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite string + +const ( + LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteAuto LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite = "Auto" + LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteLax LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite = "Lax" + LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteNone LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite = "None" + LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteStrict LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite = "Strict" +) + +// Configures the Secure attribute on session affinity cookie. Value "Always" +// indicates the Secure attribute will be set in the Set-Cookie header, "Never" +// indicates the Secure attribute will not be set, and "Auto" will set the Secure +// attribute depending if Always Use HTTPS is enabled. +type LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecure string + +const ( + LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureAuto LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecure = "Auto" + LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureAlways LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecure = "Always" + LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureNever LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecure = "Never" +) + +// Configures the zero-downtime failover between origins within a pool when session +// affinity is enabled. This feature is currently incompatible with Argo, Tiered +// Cache, and Bandwidth Alliance. The supported values are: +// +// - `"none"`: No failover takes place for sessions pinned to the origin (default). +// - `"temporary"`: Traffic will be sent to another other healthy origin until the +// originally pinned origin is available; note that this can potentially result +// in heavy origin flapping. +// - `"sticky"`: The session affinity cookie is updated and subsequent requests are +// sent to the new origin. Note: Zero-downtime failover with sticky sessions is +// currently not supported for session affinity by header. +type LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover string + +const ( + LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "none" + LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "temporary" + LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "sticky" +) + +// Steering Policy for this load balancer. +// +// - `"off"`: Use `default_pools`. +// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied +// requests, the country for `country_pools` is determined by +// `location_strategy`. +// - `"random"`: Select a pool randomly. +// - `"dynamic_latency"`: Use round trip time to select the closest pool in +// default_pools (requires pool health checks). +// - `"proximity"`: Use the pools' latitude and longitude to select the closest +// pool using the Cloudflare PoP location for proxied requests or the location +// determined by `location_strategy` for non-proxied requests. +// - `"least_outstanding_requests"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of outstanding +// requests. Pools with more pending requests are weighted proportionately less +// relative to others. +// - `"least_connections"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of open connections. +// Pools with more open connections are weighted proportionately less relative to +// others. Supported for HTTP/1 and HTTP/2 connections. +// - `""`: Will map to `"geo"` if you use +// `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. +type LoadBalancerEditParamsRulesOverridesSteeringPolicy string + +const ( + LoadBalancerEditParamsRulesOverridesSteeringPolicyOff LoadBalancerEditParamsRulesOverridesSteeringPolicy = "off" + LoadBalancerEditParamsRulesOverridesSteeringPolicyGeo LoadBalancerEditParamsRulesOverridesSteeringPolicy = "geo" + LoadBalancerEditParamsRulesOverridesSteeringPolicyRandom LoadBalancerEditParamsRulesOverridesSteeringPolicy = "random" + LoadBalancerEditParamsRulesOverridesSteeringPolicyDynamicLatency LoadBalancerEditParamsRulesOverridesSteeringPolicy = "dynamic_latency" + LoadBalancerEditParamsRulesOverridesSteeringPolicyProximity LoadBalancerEditParamsRulesOverridesSteeringPolicy = "proximity" + LoadBalancerEditParamsRulesOverridesSteeringPolicyLeastOutstandingRequests LoadBalancerEditParamsRulesOverridesSteeringPolicy = "least_outstanding_requests" + LoadBalancerEditParamsRulesOverridesSteeringPolicyLeastConnections LoadBalancerEditParamsRulesOverridesSteeringPolicy = "least_connections" + LoadBalancerEditParamsRulesOverridesSteeringPolicyEmpty LoadBalancerEditParamsRulesOverridesSteeringPolicy = "\"\"" +) + +// Specifies the type of session affinity the load balancer should use unless +// specified as `"none"` or "" (default). The supported types are: +// +// - `"cookie"`: On the first request to a proxied load balancer, a cookie is +// generated, encoding information of which origin the request will be forwarded +// to. Subsequent requests, by the same client to the same load balancer, will be +// sent to the origin server the cookie encodes, for the duration of the cookie +// and as long as the origin server remains healthy. If the cookie has expired or +// the origin server is unhealthy, then a new origin server is calculated and +// used. +// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin +// selection is stable and based on the client's ip address. +// - `"header"`: On the first request to a proxied load balancer, a session key +// based on the configured HTTP headers (see +// `session_affinity_attributes.headers`) is generated, encoding the request +// headers used for storing in the load balancer session state which origin the +// request will be forwarded to. Subsequent requests to the load balancer with +// the same headers will be sent to the same origin server, for the duration of +// the session and as long as the origin server remains healthy. If the session +// has been idle for the duration of `session_affinity_ttl` seconds or the origin +// server is unhealthy, then a new origin server is calculated and used. See +// `headers` in `session_affinity_attributes` for additional required +// configuration. +type LoadBalancerEditParamsSessionAffinity string + +const ( + LoadBalancerEditParamsSessionAffinityNone LoadBalancerEditParamsSessionAffinity = "none" + LoadBalancerEditParamsSessionAffinityCookie LoadBalancerEditParamsSessionAffinity = "cookie" + LoadBalancerEditParamsSessionAffinityIPCookie LoadBalancerEditParamsSessionAffinity = "ip_cookie" + LoadBalancerEditParamsSessionAffinityHeader LoadBalancerEditParamsSessionAffinity = "header" + LoadBalancerEditParamsSessionAffinityEmpty LoadBalancerEditParamsSessionAffinity = "\"\"" +) + +// Configures attributes for session affinity. +type LoadBalancerEditParamsSessionAffinityAttributes struct { + // Configures the drain duration in seconds. This field is only used when session + // affinity is enabled on the load balancer. + DrainDuration param.Field[float64] `json:"drain_duration"` + // Configures the names of HTTP headers to base session affinity on when header + // `session_affinity` is enabled. At least one HTTP header name must be provided. + // To specify the exact cookies to be used, include an item in the following + // format: `"cookie:,"` (example) where everything + // after the colon is a comma-separated list of cookie names. Providing only + // `"cookie"` will result in all cookies being used. The default max number of HTTP + // header names that can be provided depends on your plan: 5 for Enterprise, 1 for + // all other plans. + Headers param.Field[[]string] `json:"headers"` + // When header `session_affinity` is enabled, this option can be used to specify + // how HTTP headers on load balancing requests will be used. The supported values + // are: + // + // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers + // specified by the `headers` session affinity attribute, otherwise sessions + // aren't created. + // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP + // headers specified by the `headers` session affinity attribute, otherwise + // sessions aren't created. + RequireAllHeaders param.Field[bool] `json:"require_all_headers"` + // Configures the SameSite attribute on session affinity cookie. Value "Auto" will + // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: + // when using value "None", the secure attribute can not be set to "Never". + Samesite param.Field[LoadBalancerEditParamsSessionAffinityAttributesSamesite] `json:"samesite"` + // Configures the Secure attribute on session affinity cookie. Value "Always" + // indicates the Secure attribute will be set in the Set-Cookie header, "Never" + // indicates the Secure attribute will not be set, and "Auto" will set the Secure + // attribute depending if Always Use HTTPS is enabled. + Secure param.Field[LoadBalancerEditParamsSessionAffinityAttributesSecure] `json:"secure"` + // Configures the zero-downtime failover between origins within a pool when session + // affinity is enabled. This feature is currently incompatible with Argo, Tiered + // Cache, and Bandwidth Alliance. The supported values are: + // + // - `"none"`: No failover takes place for sessions pinned to the origin (default). + // - `"temporary"`: Traffic will be sent to another other healthy origin until the + // originally pinned origin is available; note that this can potentially result + // in heavy origin flapping. + // - `"sticky"`: The session affinity cookie is updated and subsequent requests are + // sent to the new origin. Note: Zero-downtime failover with sticky sessions is + // currently not supported for session affinity by header. + ZeroDowntimeFailover param.Field[LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` +} + +func (r LoadBalancerEditParamsSessionAffinityAttributes) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures the SameSite attribute on session affinity cookie. Value "Auto" will +// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: +// when using value "None", the secure attribute can not be set to "Never". +type LoadBalancerEditParamsSessionAffinityAttributesSamesite string + +const ( + LoadBalancerEditParamsSessionAffinityAttributesSamesiteAuto LoadBalancerEditParamsSessionAffinityAttributesSamesite = "Auto" + LoadBalancerEditParamsSessionAffinityAttributesSamesiteLax LoadBalancerEditParamsSessionAffinityAttributesSamesite = "Lax" + LoadBalancerEditParamsSessionAffinityAttributesSamesiteNone LoadBalancerEditParamsSessionAffinityAttributesSamesite = "None" + LoadBalancerEditParamsSessionAffinityAttributesSamesiteStrict LoadBalancerEditParamsSessionAffinityAttributesSamesite = "Strict" +) + +// Configures the Secure attribute on session affinity cookie. Value "Always" +// indicates the Secure attribute will be set in the Set-Cookie header, "Never" +// indicates the Secure attribute will not be set, and "Auto" will set the Secure +// attribute depending if Always Use HTTPS is enabled. +type LoadBalancerEditParamsSessionAffinityAttributesSecure string + +const ( + LoadBalancerEditParamsSessionAffinityAttributesSecureAuto LoadBalancerEditParamsSessionAffinityAttributesSecure = "Auto" + LoadBalancerEditParamsSessionAffinityAttributesSecureAlways LoadBalancerEditParamsSessionAffinityAttributesSecure = "Always" + LoadBalancerEditParamsSessionAffinityAttributesSecureNever LoadBalancerEditParamsSessionAffinityAttributesSecure = "Never" +) + +// Configures the zero-downtime failover between origins within a pool when session +// affinity is enabled. This feature is currently incompatible with Argo, Tiered +// Cache, and Bandwidth Alliance. The supported values are: +// +// - `"none"`: No failover takes place for sessions pinned to the origin (default). +// - `"temporary"`: Traffic will be sent to another other healthy origin until the +// originally pinned origin is available; note that this can potentially result +// in heavy origin flapping. +// - `"sticky"`: The session affinity cookie is updated and subsequent requests are +// sent to the new origin. Note: Zero-downtime failover with sticky sessions is +// currently not supported for session affinity by header. +type LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailover string + +const ( + LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailover = "none" + LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailover = "temporary" + LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailover = "sticky" +) + +// Steering Policy for this load balancer. +// +// - `"off"`: Use `default_pools`. +// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied +// requests, the country for `country_pools` is determined by +// `location_strategy`. +// - `"random"`: Select a pool randomly. +// - `"dynamic_latency"`: Use round trip time to select the closest pool in +// default_pools (requires pool health checks). +// - `"proximity"`: Use the pools' latitude and longitude to select the closest +// pool using the Cloudflare PoP location for proxied requests or the location +// determined by `location_strategy` for non-proxied requests. +// - `"least_outstanding_requests"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of outstanding +// requests. Pools with more pending requests are weighted proportionately less +// relative to others. +// - `"least_connections"`: Select a pool by taking into consideration +// `random_steering` weights, as well as each pool's number of open connections. +// Pools with more open connections are weighted proportionately less relative to +// others. Supported for HTTP/1 and HTTP/2 connections. +// - `""`: Will map to `"geo"` if you use +// `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. +type LoadBalancerEditParamsSteeringPolicy string + +const ( + LoadBalancerEditParamsSteeringPolicyOff LoadBalancerEditParamsSteeringPolicy = "off" + LoadBalancerEditParamsSteeringPolicyGeo LoadBalancerEditParamsSteeringPolicy = "geo" + LoadBalancerEditParamsSteeringPolicyRandom LoadBalancerEditParamsSteeringPolicy = "random" + LoadBalancerEditParamsSteeringPolicyDynamicLatency LoadBalancerEditParamsSteeringPolicy = "dynamic_latency" + LoadBalancerEditParamsSteeringPolicyProximity LoadBalancerEditParamsSteeringPolicy = "proximity" + LoadBalancerEditParamsSteeringPolicyLeastOutstandingRequests LoadBalancerEditParamsSteeringPolicy = "least_outstanding_requests" + LoadBalancerEditParamsSteeringPolicyLeastConnections LoadBalancerEditParamsSteeringPolicy = "least_connections" + LoadBalancerEditParamsSteeringPolicyEmpty LoadBalancerEditParamsSteeringPolicy = "\"\"" +) + +type LoadBalancerEditResponseEnvelope struct { + Errors []LoadBalancerEditResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerEditResponseEnvelopeMessages `json:"messages,required"` + Result LoadBalancer `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerEditResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerEditResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [LoadBalancerEditResponseEnvelope] +type loadBalancerEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [LoadBalancerEditResponseEnvelopeErrors] +type loadBalancerEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [LoadBalancerEditResponseEnvelopeMessages] +type loadBalancerEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerEditResponseEnvelopeSuccess bool + +const ( + LoadBalancerEditResponseEnvelopeSuccessTrue LoadBalancerEditResponseEnvelopeSuccess = true +) + +type LoadBalancerGetParams struct { + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type LoadBalancerGetResponseEnvelope struct { + Errors []LoadBalancerGetResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerGetResponseEnvelopeMessages `json:"messages,required"` + Result LoadBalancer `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerGetResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerGetResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [LoadBalancerGetResponseEnvelope] +type loadBalancerGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [LoadBalancerGetResponseEnvelopeErrors] +type loadBalancerGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [LoadBalancerGetResponseEnvelopeMessages] +type loadBalancerGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerGetResponseEnvelopeSuccess bool + +const ( + LoadBalancerGetResponseEnvelopeSuccessTrue LoadBalancerGetResponseEnvelopeSuccess = true +) diff --git a/load_balancers/loadbalancer_test.go b/load_balancers/loadbalancer_test.go new file mode 100644 index 00000000000..32765d3d614 --- /dev/null +++ b/load_balancers/loadbalancer_test.go @@ -0,0 +1,1035 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/load_balancers" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestLoadBalancerNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.LoadBalancers.New(context.TODO(), load_balancers.LoadBalancerNewParams{ + ZoneID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + FallbackPool: cloudflare.F[any](map[string]interface{}{}), + Name: cloudflare.F("www.example.com"), + AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerNewParamsAdaptiveRouting{ + FailoverAcrossPools: cloudflare.F(true), + }), + CountryPools: cloudflare.F[any](map[string]interface{}{ + "GB": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + }, + "US": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + Description: cloudflare.F("Load Balancer for www.example.com"), + LocationStrategy: cloudflare.F(load_balancers.LoadBalancerNewParamsLocationStrategy{ + Mode: cloudflare.F(load_balancers.LoadBalancerNewParamsLocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LoadBalancerNewParamsLocationStrategyPreferEcsAlways), + }), + PopPools: cloudflare.F[any](map[string]interface{}{ + "LAX": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + "LHR": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + "1": "f9138c5d07c2e2f4df57b1f61d4196", + }, + "SJC": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + Proxied: cloudflare.F(true), + RandomSteering: cloudflare.F(load_balancers.LoadBalancerNewParamsRandomSteering{ + DefaultWeight: cloudflare.F(0.200000), + PoolWeights: cloudflare.F[any](map[string]interface{}{ + "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, + "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, + }), + }), + RegionPools: cloudflare.F[any](map[string]interface{}{ + "ENAM": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + "WNAM": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + }), + Rules: cloudflare.F([]load_balancers.LoadBalancerNewParamsRule{{ + Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), + Disabled: cloudflare.F(true), + FixedResponse: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesFixedResponse{ + ContentType: cloudflare.F("application/json"), + Location: cloudflare.F("www.example.com"), + MessageBody: cloudflare.F("Testing Hello"), + StatusCode: cloudflare.F(int64(0)), + }), + Name: cloudflare.F("route the path /testing to testing datacenter."), + Overrides: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverrides{ + AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesAdaptiveRouting{ + FailoverAcrossPools: cloudflare.F(true), + }), + CountryPools: cloudflare.F[any](map[string]interface{}{ + "GB": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + }, + "US": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + FallbackPool: cloudflare.F[any](map[string]interface{}{}), + LocationStrategy: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesLocationStrategy{ + Mode: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesLocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsAlways), + }), + PopPools: cloudflare.F[any](map[string]interface{}{ + "LAX": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + "LHR": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + "1": "f9138c5d07c2e2f4df57b1f61d4196", + }, + "SJC": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + RandomSteering: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesRandomSteering{ + DefaultWeight: cloudflare.F(0.200000), + PoolWeights: cloudflare.F[any](map[string]interface{}{ + "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, + "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, + }), + }), + RegionPools: cloudflare.F[any](map[string]interface{}{ + "ENAM": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + "WNAM": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + }), + SessionAffinity: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributes{ + DrainDuration: cloudflare.F(100.000000), + Headers: cloudflare.F([]string{"x"}), + RequireAllHeaders: cloudflare.F(true), + Samesite: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), + }), + SessionAffinityTTL: cloudflare.F(1800.000000), + SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSteeringPolicyDynamicLatency), + TTL: cloudflare.F(30.000000), + }), + Priority: cloudflare.F(int64(0)), + Terminates: cloudflare.F(true), + }, { + Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), + Disabled: cloudflare.F(true), + FixedResponse: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesFixedResponse{ + ContentType: cloudflare.F("application/json"), + Location: cloudflare.F("www.example.com"), + MessageBody: cloudflare.F("Testing Hello"), + StatusCode: cloudflare.F(int64(0)), + }), + Name: cloudflare.F("route the path /testing to testing datacenter."), + Overrides: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverrides{ + AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesAdaptiveRouting{ + FailoverAcrossPools: cloudflare.F(true), + }), + CountryPools: cloudflare.F[any](map[string]interface{}{ + "GB": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + }, + "US": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + FallbackPool: cloudflare.F[any](map[string]interface{}{}), + LocationStrategy: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesLocationStrategy{ + Mode: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesLocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsAlways), + }), + PopPools: cloudflare.F[any](map[string]interface{}{ + "LAX": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + "LHR": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + "1": "f9138c5d07c2e2f4df57b1f61d4196", + }, + "SJC": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + RandomSteering: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesRandomSteering{ + DefaultWeight: cloudflare.F(0.200000), + PoolWeights: cloudflare.F[any](map[string]interface{}{ + "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, + "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, + }), + }), + RegionPools: cloudflare.F[any](map[string]interface{}{ + "ENAM": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + "WNAM": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + }), + SessionAffinity: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributes{ + DrainDuration: cloudflare.F(100.000000), + Headers: cloudflare.F([]string{"x"}), + RequireAllHeaders: cloudflare.F(true), + Samesite: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), + }), + SessionAffinityTTL: cloudflare.F(1800.000000), + SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSteeringPolicyDynamicLatency), + TTL: cloudflare.F(30.000000), + }), + Priority: cloudflare.F(int64(0)), + Terminates: cloudflare.F(true), + }, { + Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), + Disabled: cloudflare.F(true), + FixedResponse: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesFixedResponse{ + ContentType: cloudflare.F("application/json"), + Location: cloudflare.F("www.example.com"), + MessageBody: cloudflare.F("Testing Hello"), + StatusCode: cloudflare.F(int64(0)), + }), + Name: cloudflare.F("route the path /testing to testing datacenter."), + Overrides: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverrides{ + AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesAdaptiveRouting{ + FailoverAcrossPools: cloudflare.F(true), + }), + CountryPools: cloudflare.F[any](map[string]interface{}{ + "GB": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + }, + "US": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + FallbackPool: cloudflare.F[any](map[string]interface{}{}), + LocationStrategy: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesLocationStrategy{ + Mode: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesLocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsAlways), + }), + PopPools: cloudflare.F[any](map[string]interface{}{ + "LAX": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + "LHR": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + "1": "f9138c5d07c2e2f4df57b1f61d4196", + }, + "SJC": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + RandomSteering: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesRandomSteering{ + DefaultWeight: cloudflare.F(0.200000), + PoolWeights: cloudflare.F[any](map[string]interface{}{ + "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, + "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, + }), + }), + RegionPools: cloudflare.F[any](map[string]interface{}{ + "ENAM": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + "WNAM": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + }), + SessionAffinity: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributes{ + DrainDuration: cloudflare.F(100.000000), + Headers: cloudflare.F([]string{"x"}), + RequireAllHeaders: cloudflare.F(true), + Samesite: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), + }), + SessionAffinityTTL: cloudflare.F(1800.000000), + SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerNewParamsRulesOverridesSteeringPolicyDynamicLatency), + TTL: cloudflare.F(30.000000), + }), + Priority: cloudflare.F(int64(0)), + Terminates: cloudflare.F(true), + }}), + SessionAffinity: cloudflare.F(load_balancers.LoadBalancerNewParamsSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerNewParamsSessionAffinityAttributes{ + DrainDuration: cloudflare.F(100.000000), + Headers: cloudflare.F([]string{"x"}), + RequireAllHeaders: cloudflare.F(true), + Samesite: cloudflare.F(load_balancers.LoadBalancerNewParamsSessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.LoadBalancerNewParamsSessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailoverSticky), + }), + SessionAffinityTTL: cloudflare.F(1800.000000), + SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerNewParamsSteeringPolicyDynamicLatency), + TTL: cloudflare.F(30.000000), + }) + 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 TestLoadBalancerUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.LoadBalancers.Update( + context.TODO(), + "699d98642c564d2e855e9661899b7252", + load_balancers.LoadBalancerUpdateParams{ + ZoneID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + FallbackPool: cloudflare.F[any](map[string]interface{}{}), + Name: cloudflare.F("www.example.com"), + AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerUpdateParamsAdaptiveRouting{ + FailoverAcrossPools: cloudflare.F(true), + }), + CountryPools: cloudflare.F[any](map[string]interface{}{ + "GB": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + }, + "US": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + Description: cloudflare.F("Load Balancer for www.example.com"), + Enabled: cloudflare.F(true), + LocationStrategy: cloudflare.F(load_balancers.LoadBalancerUpdateParamsLocationStrategy{ + Mode: cloudflare.F(load_balancers.LoadBalancerUpdateParamsLocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LoadBalancerUpdateParamsLocationStrategyPreferEcsAlways), + }), + PopPools: cloudflare.F[any](map[string]interface{}{ + "LAX": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + "LHR": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + "1": "f9138c5d07c2e2f4df57b1f61d4196", + }, + "SJC": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + Proxied: cloudflare.F(true), + RandomSteering: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRandomSteering{ + DefaultWeight: cloudflare.F(0.200000), + PoolWeights: cloudflare.F[any](map[string]interface{}{ + "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, + "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, + }), + }), + RegionPools: cloudflare.F[any](map[string]interface{}{ + "ENAM": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + "WNAM": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + }), + Rules: cloudflare.F([]load_balancers.LoadBalancerUpdateParamsRule{{ + Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), + Disabled: cloudflare.F(true), + FixedResponse: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesFixedResponse{ + ContentType: cloudflare.F("application/json"), + Location: cloudflare.F("www.example.com"), + MessageBody: cloudflare.F("Testing Hello"), + StatusCode: cloudflare.F(int64(0)), + }), + Name: cloudflare.F("route the path /testing to testing datacenter."), + Overrides: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverrides{ + AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesAdaptiveRouting{ + FailoverAcrossPools: cloudflare.F(true), + }), + CountryPools: cloudflare.F[any](map[string]interface{}{ + "GB": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + }, + "US": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + FallbackPool: cloudflare.F[any](map[string]interface{}{}), + LocationStrategy: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesLocationStrategy{ + Mode: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesLocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsAlways), + }), + PopPools: cloudflare.F[any](map[string]interface{}{ + "LAX": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + "LHR": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + "1": "f9138c5d07c2e2f4df57b1f61d4196", + }, + "SJC": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + RandomSteering: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesRandomSteering{ + DefaultWeight: cloudflare.F(0.200000), + PoolWeights: cloudflare.F[any](map[string]interface{}{ + "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, + "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, + }), + }), + RegionPools: cloudflare.F[any](map[string]interface{}{ + "ENAM": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + "WNAM": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + }), + SessionAffinity: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributes{ + DrainDuration: cloudflare.F(100.000000), + Headers: cloudflare.F([]string{"x"}), + RequireAllHeaders: cloudflare.F(true), + Samesite: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), + }), + SessionAffinityTTL: cloudflare.F(1800.000000), + SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSteeringPolicyDynamicLatency), + TTL: cloudflare.F(30.000000), + }), + Priority: cloudflare.F(int64(0)), + Terminates: cloudflare.F(true), + }, { + Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), + Disabled: cloudflare.F(true), + FixedResponse: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesFixedResponse{ + ContentType: cloudflare.F("application/json"), + Location: cloudflare.F("www.example.com"), + MessageBody: cloudflare.F("Testing Hello"), + StatusCode: cloudflare.F(int64(0)), + }), + Name: cloudflare.F("route the path /testing to testing datacenter."), + Overrides: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverrides{ + AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesAdaptiveRouting{ + FailoverAcrossPools: cloudflare.F(true), + }), + CountryPools: cloudflare.F[any](map[string]interface{}{ + "GB": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + }, + "US": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + FallbackPool: cloudflare.F[any](map[string]interface{}{}), + LocationStrategy: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesLocationStrategy{ + Mode: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesLocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsAlways), + }), + PopPools: cloudflare.F[any](map[string]interface{}{ + "LAX": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + "LHR": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + "1": "f9138c5d07c2e2f4df57b1f61d4196", + }, + "SJC": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + RandomSteering: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesRandomSteering{ + DefaultWeight: cloudflare.F(0.200000), + PoolWeights: cloudflare.F[any](map[string]interface{}{ + "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, + "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, + }), + }), + RegionPools: cloudflare.F[any](map[string]interface{}{ + "ENAM": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + "WNAM": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + }), + SessionAffinity: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributes{ + DrainDuration: cloudflare.F(100.000000), + Headers: cloudflare.F([]string{"x"}), + RequireAllHeaders: cloudflare.F(true), + Samesite: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), + }), + SessionAffinityTTL: cloudflare.F(1800.000000), + SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSteeringPolicyDynamicLatency), + TTL: cloudflare.F(30.000000), + }), + Priority: cloudflare.F(int64(0)), + Terminates: cloudflare.F(true), + }, { + Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), + Disabled: cloudflare.F(true), + FixedResponse: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesFixedResponse{ + ContentType: cloudflare.F("application/json"), + Location: cloudflare.F("www.example.com"), + MessageBody: cloudflare.F("Testing Hello"), + StatusCode: cloudflare.F(int64(0)), + }), + Name: cloudflare.F("route the path /testing to testing datacenter."), + Overrides: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverrides{ + AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesAdaptiveRouting{ + FailoverAcrossPools: cloudflare.F(true), + }), + CountryPools: cloudflare.F[any](map[string]interface{}{ + "GB": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + }, + "US": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + FallbackPool: cloudflare.F[any](map[string]interface{}{}), + LocationStrategy: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesLocationStrategy{ + Mode: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesLocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsAlways), + }), + PopPools: cloudflare.F[any](map[string]interface{}{ + "LAX": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + "LHR": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + "1": "f9138c5d07c2e2f4df57b1f61d4196", + }, + "SJC": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + RandomSteering: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesRandomSteering{ + DefaultWeight: cloudflare.F(0.200000), + PoolWeights: cloudflare.F[any](map[string]interface{}{ + "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, + "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, + }), + }), + RegionPools: cloudflare.F[any](map[string]interface{}{ + "ENAM": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + "WNAM": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + }), + SessionAffinity: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributes{ + DrainDuration: cloudflare.F(100.000000), + Headers: cloudflare.F([]string{"x"}), + RequireAllHeaders: cloudflare.F(true), + Samesite: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), + }), + SessionAffinityTTL: cloudflare.F(1800.000000), + SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerUpdateParamsRulesOverridesSteeringPolicyDynamicLatency), + TTL: cloudflare.F(30.000000), + }), + Priority: cloudflare.F(int64(0)), + Terminates: cloudflare.F(true), + }}), + SessionAffinity: cloudflare.F(load_balancers.LoadBalancerUpdateParamsSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerUpdateParamsSessionAffinityAttributes{ + DrainDuration: cloudflare.F(100.000000), + Headers: cloudflare.F([]string{"x"}), + RequireAllHeaders: cloudflare.F(true), + Samesite: cloudflare.F(load_balancers.LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.LoadBalancerUpdateParamsSessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailoverSticky), + }), + SessionAffinityTTL: cloudflare.F(1800.000000), + SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerUpdateParamsSteeringPolicyDynamicLatency), + TTL: cloudflare.F(30.000000), + }, + ) + 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 TestLoadBalancerList(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("user@example.com"), + ) + _, err := client.LoadBalancers.List(context.TODO(), load_balancers.LoadBalancerListParams{ + ZoneID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + }) + 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 TestLoadBalancerDelete(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("user@example.com"), + ) + _, err := client.LoadBalancers.Delete( + context.TODO(), + "699d98642c564d2e855e9661899b7252", + load_balancers.LoadBalancerDeleteParams{ + ZoneID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + }, + ) + 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 TestLoadBalancerEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.LoadBalancers.Edit( + context.TODO(), + "699d98642c564d2e855e9661899b7252", + load_balancers.LoadBalancerEditParams{ + ZoneID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerEditParamsAdaptiveRouting{ + FailoverAcrossPools: cloudflare.F(true), + }), + CountryPools: cloudflare.F[any](map[string]interface{}{ + "GB": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + }, + "US": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + Description: cloudflare.F("Load Balancer for www.example.com"), + Enabled: cloudflare.F(true), + FallbackPool: cloudflare.F[any](map[string]interface{}{}), + LocationStrategy: cloudflare.F(load_balancers.LoadBalancerEditParamsLocationStrategy{ + Mode: cloudflare.F(load_balancers.LoadBalancerEditParamsLocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LoadBalancerEditParamsLocationStrategyPreferEcsAlways), + }), + Name: cloudflare.F("www.example.com"), + PopPools: cloudflare.F[any](map[string]interface{}{ + "LAX": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + "LHR": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + "1": "f9138c5d07c2e2f4df57b1f61d4196", + }, + "SJC": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + Proxied: cloudflare.F(true), + RandomSteering: cloudflare.F(load_balancers.LoadBalancerEditParamsRandomSteering{ + DefaultWeight: cloudflare.F(0.200000), + PoolWeights: cloudflare.F[any](map[string]interface{}{ + "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, + "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, + }), + }), + RegionPools: cloudflare.F[any](map[string]interface{}{ + "ENAM": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + "WNAM": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + }), + Rules: cloudflare.F([]load_balancers.LoadBalancerEditParamsRule{{ + Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), + Disabled: cloudflare.F(true), + FixedResponse: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesFixedResponse{ + ContentType: cloudflare.F("application/json"), + Location: cloudflare.F("www.example.com"), + MessageBody: cloudflare.F("Testing Hello"), + StatusCode: cloudflare.F(int64(0)), + }), + Name: cloudflare.F("route the path /testing to testing datacenter."), + Overrides: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverrides{ + AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesAdaptiveRouting{ + FailoverAcrossPools: cloudflare.F(true), + }), + CountryPools: cloudflare.F[any](map[string]interface{}{ + "GB": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + }, + "US": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + FallbackPool: cloudflare.F[any](map[string]interface{}{}), + LocationStrategy: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesLocationStrategy{ + Mode: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesLocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsAlways), + }), + PopPools: cloudflare.F[any](map[string]interface{}{ + "LAX": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + "LHR": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + "1": "f9138c5d07c2e2f4df57b1f61d4196", + }, + "SJC": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + RandomSteering: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesRandomSteering{ + DefaultWeight: cloudflare.F(0.200000), + PoolWeights: cloudflare.F[any](map[string]interface{}{ + "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, + "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, + }), + }), + RegionPools: cloudflare.F[any](map[string]interface{}{ + "ENAM": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + "WNAM": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + }), + SessionAffinity: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributes{ + DrainDuration: cloudflare.F(100.000000), + Headers: cloudflare.F([]string{"x"}), + RequireAllHeaders: cloudflare.F(true), + Samesite: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), + }), + SessionAffinityTTL: cloudflare.F(1800.000000), + SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSteeringPolicyDynamicLatency), + TTL: cloudflare.F(30.000000), + }), + Priority: cloudflare.F(int64(0)), + Terminates: cloudflare.F(true), + }, { + Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), + Disabled: cloudflare.F(true), + FixedResponse: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesFixedResponse{ + ContentType: cloudflare.F("application/json"), + Location: cloudflare.F("www.example.com"), + MessageBody: cloudflare.F("Testing Hello"), + StatusCode: cloudflare.F(int64(0)), + }), + Name: cloudflare.F("route the path /testing to testing datacenter."), + Overrides: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverrides{ + AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesAdaptiveRouting{ + FailoverAcrossPools: cloudflare.F(true), + }), + CountryPools: cloudflare.F[any](map[string]interface{}{ + "GB": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + }, + "US": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + FallbackPool: cloudflare.F[any](map[string]interface{}{}), + LocationStrategy: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesLocationStrategy{ + Mode: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesLocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsAlways), + }), + PopPools: cloudflare.F[any](map[string]interface{}{ + "LAX": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + "LHR": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + "1": "f9138c5d07c2e2f4df57b1f61d4196", + }, + "SJC": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + RandomSteering: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesRandomSteering{ + DefaultWeight: cloudflare.F(0.200000), + PoolWeights: cloudflare.F[any](map[string]interface{}{ + "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, + "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, + }), + }), + RegionPools: cloudflare.F[any](map[string]interface{}{ + "ENAM": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + "WNAM": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + }), + SessionAffinity: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributes{ + DrainDuration: cloudflare.F(100.000000), + Headers: cloudflare.F([]string{"x"}), + RequireAllHeaders: cloudflare.F(true), + Samesite: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), + }), + SessionAffinityTTL: cloudflare.F(1800.000000), + SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSteeringPolicyDynamicLatency), + TTL: cloudflare.F(30.000000), + }), + Priority: cloudflare.F(int64(0)), + Terminates: cloudflare.F(true), + }, { + Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), + Disabled: cloudflare.F(true), + FixedResponse: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesFixedResponse{ + ContentType: cloudflare.F("application/json"), + Location: cloudflare.F("www.example.com"), + MessageBody: cloudflare.F("Testing Hello"), + StatusCode: cloudflare.F(int64(0)), + }), + Name: cloudflare.F("route the path /testing to testing datacenter."), + Overrides: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverrides{ + AdaptiveRouting: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesAdaptiveRouting{ + FailoverAcrossPools: cloudflare.F(true), + }), + CountryPools: cloudflare.F[any](map[string]interface{}{ + "GB": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + }, + "US": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + FallbackPool: cloudflare.F[any](map[string]interface{}{}), + LocationStrategy: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesLocationStrategy{ + Mode: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesLocationStrategyModeResolverIP), + PreferEcs: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsAlways), + }), + PopPools: cloudflare.F[any](map[string]interface{}{ + "LAX": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + "LHR": map[string]interface{}{ + "0": "abd90f38ced07c2e2f4df50b1f61d4194", + "1": "f9138c5d07c2e2f4df57b1f61d4196", + }, + "SJC": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + }), + RandomSteering: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesRandomSteering{ + DefaultWeight: cloudflare.F(0.200000), + PoolWeights: cloudflare.F[any](map[string]interface{}{ + "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, + "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, + }), + }), + RegionPools: cloudflare.F[any](map[string]interface{}{ + "ENAM": map[string]interface{}{ + "0": "00920f38ce07c2e2f4df50b1f61d4194", + }, + "WNAM": map[string]interface{}{ + "0": "de90f38ced07c2e2f4df50b1f61d4194", + "1": "9290f38c5d07c2e2f4df57b1f61d4196", + }, + }), + SessionAffinity: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributes{ + DrainDuration: cloudflare.F(100.000000), + Headers: cloudflare.F([]string{"x"}), + RequireAllHeaders: cloudflare.F(true), + Samesite: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), + }), + SessionAffinityTTL: cloudflare.F(1800.000000), + SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerEditParamsRulesOverridesSteeringPolicyDynamicLatency), + TTL: cloudflare.F(30.000000), + }), + Priority: cloudflare.F(int64(0)), + Terminates: cloudflare.F(true), + }}), + SessionAffinity: cloudflare.F(load_balancers.LoadBalancerEditParamsSessionAffinityCookie), + SessionAffinityAttributes: cloudflare.F(load_balancers.LoadBalancerEditParamsSessionAffinityAttributes{ + DrainDuration: cloudflare.F(100.000000), + Headers: cloudflare.F([]string{"x"}), + RequireAllHeaders: cloudflare.F(true), + Samesite: cloudflare.F(load_balancers.LoadBalancerEditParamsSessionAffinityAttributesSamesiteAuto), + Secure: cloudflare.F(load_balancers.LoadBalancerEditParamsSessionAffinityAttributesSecureAuto), + ZeroDowntimeFailover: cloudflare.F(load_balancers.LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailoverSticky), + }), + SessionAffinityTTL: cloudflare.F(1800.000000), + SteeringPolicy: cloudflare.F(load_balancers.LoadBalancerEditParamsSteeringPolicyDynamicLatency), + TTL: cloudflare.F(30.000000), + }, + ) + 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 TestLoadBalancerGet(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("user@example.com"), + ) + _, err := client.LoadBalancers.Get( + context.TODO(), + "699d98642c564d2e855e9661899b7252", + load_balancers.LoadBalancerGetParams{ + ZoneID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/load_balancers/monitor.go b/load_balancers/monitor.go new file mode 100644 index 00000000000..94e30272727 --- /dev/null +++ b/load_balancers/monitor.go @@ -0,0 +1,882 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/user" +) + +// MonitorService 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 [NewMonitorService] method instead. +type MonitorService struct { + Options []option.RequestOption + Previews *MonitorPreviewService + References *MonitorReferenceService +} + +// NewMonitorService 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 NewMonitorService(opts ...option.RequestOption) (r *MonitorService) { + r = &MonitorService{} + r.Options = opts + r.Previews = NewMonitorPreviewService(opts...) + r.References = NewMonitorReferenceService(opts...) + return +} + +// Create a configured monitor. +func (r *MonitorService) New(ctx context.Context, params MonitorNewParams, opts ...option.RequestOption) (res *user.LoadBalancingMonitor, err error) { + opts = append(r.Options[:], opts...) + var env MonitorNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/monitors", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Modify a configured monitor. +func (r *MonitorService) Update(ctx context.Context, monitorID string, params MonitorUpdateParams, opts ...option.RequestOption) (res *user.LoadBalancingMonitor, err error) { + opts = append(r.Options[:], opts...) + var env MonitorUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s", params.AccountID, monitorID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List configured monitors for an account. +func (r *MonitorService) List(ctx context.Context, query MonitorListParams, opts ...option.RequestOption) (res *[]user.LoadBalancingMonitor, err error) { + opts = append(r.Options[:], opts...) + var env MonitorListResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/monitors", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a configured monitor. +func (r *MonitorService) Delete(ctx context.Context, monitorID string, body MonitorDeleteParams, opts ...option.RequestOption) (res *MonitorDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env MonitorDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s", body.AccountID, monitorID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Apply changes to an existing monitor, overwriting the supplied properties. +func (r *MonitorService) Edit(ctx context.Context, monitorID string, params MonitorEditParams, opts ...option.RequestOption) (res *user.LoadBalancingMonitor, err error) { + opts = append(r.Options[:], opts...) + var env MonitorEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s", params.AccountID, monitorID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List a single configured monitor for an account. +func (r *MonitorService) Get(ctx context.Context, monitorID string, query MonitorGetParams, opts ...option.RequestOption) (res *user.LoadBalancingMonitor, err error) { + opts = append(r.Options[:], opts...) + var env MonitorGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s", query.AccountID, monitorID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type MonitorDeleteResponse struct { + ID string `json:"id"` + JSON monitorDeleteResponseJSON `json:"-"` +} + +// monitorDeleteResponseJSON contains the JSON metadata for the struct +// [MonitorDeleteResponse] +type monitorDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type MonitorNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The expected HTTP response code or code range of the health check. This + // parameter is only valid for HTTP and HTTPS monitors. + ExpectedCodes param.Field[string] `json:"expected_codes,required"` + // Do not validate the certificate when monitor use HTTPS. This parameter is + // currently only valid for HTTP and HTTPS monitors. + AllowInsecure param.Field[bool] `json:"allow_insecure"` + // To be marked unhealthy the monitored origin must fail this healthcheck N + // consecutive times. + ConsecutiveDown param.Field[int64] `json:"consecutive_down"` + // To be marked healthy the monitored origin must pass this healthcheck N + // consecutive times. + ConsecutiveUp param.Field[int64] `json:"consecutive_up"` + // Object description. + Description param.Field[string] `json:"description"` + // A case-insensitive sub-string to look for in the response body. If this string + // is not found, the origin will be marked as unhealthy. This parameter is only + // valid for HTTP and HTTPS monitors. + ExpectedBody param.Field[string] `json:"expected_body"` + // Follow redirects if returned by the origin. This parameter is only valid for + // HTTP and HTTPS monitors. + FollowRedirects param.Field[bool] `json:"follow_redirects"` + // The HTTP request headers to send in the health check. It is recommended you set + // a Host header by default. The User-Agent header cannot be overridden. This + // parameter is only valid for HTTP and HTTPS monitors. + Header param.Field[interface{}] `json:"header"` + // The interval between each health check. Shorter intervals may improve failover + // time, but will increase load on the origins as we check from multiple locations. + Interval param.Field[int64] `json:"interval"` + // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS + // based checks and 'connection_established' for TCP based health checks. + Method param.Field[string] `json:"method"` + // The endpoint path you want to conduct a health check against. This parameter is + // only valid for HTTP and HTTPS monitors. + Path param.Field[string] `json:"path"` + // The port number to connect to for the health check. Required for TCP, UDP, and + // SMTP checks. HTTP and HTTPS checks should only define the port when using a + // non-standard port (HTTP: default 80, HTTPS: default 443). + Port param.Field[int64] `json:"port"` + // Assign this monitor to emulate the specified zone while probing. This parameter + // is only valid for HTTP and HTTPS monitors. + ProbeZone param.Field[string] `json:"probe_zone"` + // The number of retries to attempt in case of a timeout before marking the origin + // as unhealthy. Retries are attempted immediately. + Retries param.Field[int64] `json:"retries"` + // The timeout (in seconds) before marking the health check as failed. + Timeout param.Field[int64] `json:"timeout"` + // The protocol to use for the health check. Currently supported protocols are + // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. + Type param.Field[MonitorNewParamsType] `json:"type"` +} + +func (r MonitorNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The protocol to use for the health check. Currently supported protocols are +// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. +type MonitorNewParamsType string + +const ( + MonitorNewParamsTypeHTTP MonitorNewParamsType = "http" + MonitorNewParamsTypeHTTPS MonitorNewParamsType = "https" + MonitorNewParamsTypeTcp MonitorNewParamsType = "tcp" + MonitorNewParamsTypeUdpIcmp MonitorNewParamsType = "udp_icmp" + MonitorNewParamsTypeIcmpPing MonitorNewParamsType = "icmp_ping" + MonitorNewParamsTypeSmtp MonitorNewParamsType = "smtp" +) + +type MonitorNewResponseEnvelope struct { + Errors []MonitorNewResponseEnvelopeErrors `json:"errors,required"` + Messages []MonitorNewResponseEnvelopeMessages `json:"messages,required"` + Result user.LoadBalancingMonitor `json:"result,required"` + // Whether the API call was successful + Success MonitorNewResponseEnvelopeSuccess `json:"success,required"` + JSON monitorNewResponseEnvelopeJSON `json:"-"` +} + +// monitorNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [MonitorNewResponseEnvelope] +type monitorNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type MonitorNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON monitorNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// monitorNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [MonitorNewResponseEnvelopeErrors] +type monitorNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type MonitorNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON monitorNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// monitorNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [MonitorNewResponseEnvelopeMessages] +type monitorNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type MonitorNewResponseEnvelopeSuccess bool + +const ( + MonitorNewResponseEnvelopeSuccessTrue MonitorNewResponseEnvelopeSuccess = true +) + +type MonitorUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The expected HTTP response code or code range of the health check. This + // parameter is only valid for HTTP and HTTPS monitors. + ExpectedCodes param.Field[string] `json:"expected_codes,required"` + // Do not validate the certificate when monitor use HTTPS. This parameter is + // currently only valid for HTTP and HTTPS monitors. + AllowInsecure param.Field[bool] `json:"allow_insecure"` + // To be marked unhealthy the monitored origin must fail this healthcheck N + // consecutive times. + ConsecutiveDown param.Field[int64] `json:"consecutive_down"` + // To be marked healthy the monitored origin must pass this healthcheck N + // consecutive times. + ConsecutiveUp param.Field[int64] `json:"consecutive_up"` + // Object description. + Description param.Field[string] `json:"description"` + // A case-insensitive sub-string to look for in the response body. If this string + // is not found, the origin will be marked as unhealthy. This parameter is only + // valid for HTTP and HTTPS monitors. + ExpectedBody param.Field[string] `json:"expected_body"` + // Follow redirects if returned by the origin. This parameter is only valid for + // HTTP and HTTPS monitors. + FollowRedirects param.Field[bool] `json:"follow_redirects"` + // The HTTP request headers to send in the health check. It is recommended you set + // a Host header by default. The User-Agent header cannot be overridden. This + // parameter is only valid for HTTP and HTTPS monitors. + Header param.Field[interface{}] `json:"header"` + // The interval between each health check. Shorter intervals may improve failover + // time, but will increase load on the origins as we check from multiple locations. + Interval param.Field[int64] `json:"interval"` + // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS + // based checks and 'connection_established' for TCP based health checks. + Method param.Field[string] `json:"method"` + // The endpoint path you want to conduct a health check against. This parameter is + // only valid for HTTP and HTTPS monitors. + Path param.Field[string] `json:"path"` + // The port number to connect to for the health check. Required for TCP, UDP, and + // SMTP checks. HTTP and HTTPS checks should only define the port when using a + // non-standard port (HTTP: default 80, HTTPS: default 443). + Port param.Field[int64] `json:"port"` + // Assign this monitor to emulate the specified zone while probing. This parameter + // is only valid for HTTP and HTTPS monitors. + ProbeZone param.Field[string] `json:"probe_zone"` + // The number of retries to attempt in case of a timeout before marking the origin + // as unhealthy. Retries are attempted immediately. + Retries param.Field[int64] `json:"retries"` + // The timeout (in seconds) before marking the health check as failed. + Timeout param.Field[int64] `json:"timeout"` + // The protocol to use for the health check. Currently supported protocols are + // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. + Type param.Field[MonitorUpdateParamsType] `json:"type"` +} + +func (r MonitorUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The protocol to use for the health check. Currently supported protocols are +// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. +type MonitorUpdateParamsType string + +const ( + MonitorUpdateParamsTypeHTTP MonitorUpdateParamsType = "http" + MonitorUpdateParamsTypeHTTPS MonitorUpdateParamsType = "https" + MonitorUpdateParamsTypeTcp MonitorUpdateParamsType = "tcp" + MonitorUpdateParamsTypeUdpIcmp MonitorUpdateParamsType = "udp_icmp" + MonitorUpdateParamsTypeIcmpPing MonitorUpdateParamsType = "icmp_ping" + MonitorUpdateParamsTypeSmtp MonitorUpdateParamsType = "smtp" +) + +type MonitorUpdateResponseEnvelope struct { + Errors []MonitorUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []MonitorUpdateResponseEnvelopeMessages `json:"messages,required"` + Result user.LoadBalancingMonitor `json:"result,required"` + // Whether the API call was successful + Success MonitorUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON monitorUpdateResponseEnvelopeJSON `json:"-"` +} + +// monitorUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [MonitorUpdateResponseEnvelope] +type monitorUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type MonitorUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON monitorUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// monitorUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [MonitorUpdateResponseEnvelopeErrors] +type monitorUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type MonitorUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON monitorUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// monitorUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [MonitorUpdateResponseEnvelopeMessages] +type monitorUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type MonitorUpdateResponseEnvelopeSuccess bool + +const ( + MonitorUpdateResponseEnvelopeSuccessTrue MonitorUpdateResponseEnvelopeSuccess = true +) + +type MonitorListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type MonitorListResponseEnvelope struct { + Errors []MonitorListResponseEnvelopeErrors `json:"errors,required"` + Messages []MonitorListResponseEnvelopeMessages `json:"messages,required"` + Result []user.LoadBalancingMonitor `json:"result,required,nullable"` + // Whether the API call was successful + Success MonitorListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo MonitorListResponseEnvelopeResultInfo `json:"result_info"` + JSON monitorListResponseEnvelopeJSON `json:"-"` +} + +// monitorListResponseEnvelopeJSON contains the JSON metadata for the struct +// [MonitorListResponseEnvelope] +type monitorListResponseEnvelopeJSON 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 *MonitorListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type MonitorListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON monitorListResponseEnvelopeErrorsJSON `json:"-"` +} + +// monitorListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [MonitorListResponseEnvelopeErrors] +type monitorListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type MonitorListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON monitorListResponseEnvelopeMessagesJSON `json:"-"` +} + +// monitorListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [MonitorListResponseEnvelopeMessages] +type monitorListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type MonitorListResponseEnvelopeSuccess bool + +const ( + MonitorListResponseEnvelopeSuccessTrue MonitorListResponseEnvelopeSuccess = true +) + +type MonitorListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON monitorListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// monitorListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [MonitorListResponseEnvelopeResultInfo] +type monitorListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type MonitorDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type MonitorDeleteResponseEnvelope struct { + Errors []MonitorDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []MonitorDeleteResponseEnvelopeMessages `json:"messages,required"` + Result MonitorDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success MonitorDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON monitorDeleteResponseEnvelopeJSON `json:"-"` +} + +// monitorDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [MonitorDeleteResponseEnvelope] +type monitorDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type MonitorDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON monitorDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// monitorDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [MonitorDeleteResponseEnvelopeErrors] +type monitorDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type MonitorDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON monitorDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// monitorDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [MonitorDeleteResponseEnvelopeMessages] +type monitorDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type MonitorDeleteResponseEnvelopeSuccess bool + +const ( + MonitorDeleteResponseEnvelopeSuccessTrue MonitorDeleteResponseEnvelopeSuccess = true +) + +type MonitorEditParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The expected HTTP response code or code range of the health check. This + // parameter is only valid for HTTP and HTTPS monitors. + ExpectedCodes param.Field[string] `json:"expected_codes,required"` + // Do not validate the certificate when monitor use HTTPS. This parameter is + // currently only valid for HTTP and HTTPS monitors. + AllowInsecure param.Field[bool] `json:"allow_insecure"` + // To be marked unhealthy the monitored origin must fail this healthcheck N + // consecutive times. + ConsecutiveDown param.Field[int64] `json:"consecutive_down"` + // To be marked healthy the monitored origin must pass this healthcheck N + // consecutive times. + ConsecutiveUp param.Field[int64] `json:"consecutive_up"` + // Object description. + Description param.Field[string] `json:"description"` + // A case-insensitive sub-string to look for in the response body. If this string + // is not found, the origin will be marked as unhealthy. This parameter is only + // valid for HTTP and HTTPS monitors. + ExpectedBody param.Field[string] `json:"expected_body"` + // Follow redirects if returned by the origin. This parameter is only valid for + // HTTP and HTTPS monitors. + FollowRedirects param.Field[bool] `json:"follow_redirects"` + // The HTTP request headers to send in the health check. It is recommended you set + // a Host header by default. The User-Agent header cannot be overridden. This + // parameter is only valid for HTTP and HTTPS monitors. + Header param.Field[interface{}] `json:"header"` + // The interval between each health check. Shorter intervals may improve failover + // time, but will increase load on the origins as we check from multiple locations. + Interval param.Field[int64] `json:"interval"` + // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS + // based checks and 'connection_established' for TCP based health checks. + Method param.Field[string] `json:"method"` + // The endpoint path you want to conduct a health check against. This parameter is + // only valid for HTTP and HTTPS monitors. + Path param.Field[string] `json:"path"` + // The port number to connect to for the health check. Required for TCP, UDP, and + // SMTP checks. HTTP and HTTPS checks should only define the port when using a + // non-standard port (HTTP: default 80, HTTPS: default 443). + Port param.Field[int64] `json:"port"` + // Assign this monitor to emulate the specified zone while probing. This parameter + // is only valid for HTTP and HTTPS monitors. + ProbeZone param.Field[string] `json:"probe_zone"` + // The number of retries to attempt in case of a timeout before marking the origin + // as unhealthy. Retries are attempted immediately. + Retries param.Field[int64] `json:"retries"` + // The timeout (in seconds) before marking the health check as failed. + Timeout param.Field[int64] `json:"timeout"` + // The protocol to use for the health check. Currently supported protocols are + // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. + Type param.Field[MonitorEditParamsType] `json:"type"` +} + +func (r MonitorEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The protocol to use for the health check. Currently supported protocols are +// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. +type MonitorEditParamsType string + +const ( + MonitorEditParamsTypeHTTP MonitorEditParamsType = "http" + MonitorEditParamsTypeHTTPS MonitorEditParamsType = "https" + MonitorEditParamsTypeTcp MonitorEditParamsType = "tcp" + MonitorEditParamsTypeUdpIcmp MonitorEditParamsType = "udp_icmp" + MonitorEditParamsTypeIcmpPing MonitorEditParamsType = "icmp_ping" + MonitorEditParamsTypeSmtp MonitorEditParamsType = "smtp" +) + +type MonitorEditResponseEnvelope struct { + Errors []MonitorEditResponseEnvelopeErrors `json:"errors,required"` + Messages []MonitorEditResponseEnvelopeMessages `json:"messages,required"` + Result user.LoadBalancingMonitor `json:"result,required"` + // Whether the API call was successful + Success MonitorEditResponseEnvelopeSuccess `json:"success,required"` + JSON monitorEditResponseEnvelopeJSON `json:"-"` +} + +// monitorEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [MonitorEditResponseEnvelope] +type monitorEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type MonitorEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON monitorEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// monitorEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [MonitorEditResponseEnvelopeErrors] +type monitorEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type MonitorEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON monitorEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// monitorEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [MonitorEditResponseEnvelopeMessages] +type monitorEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type MonitorEditResponseEnvelopeSuccess bool + +const ( + MonitorEditResponseEnvelopeSuccessTrue MonitorEditResponseEnvelopeSuccess = true +) + +type MonitorGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type MonitorGetResponseEnvelope struct { + Errors []MonitorGetResponseEnvelopeErrors `json:"errors,required"` + Messages []MonitorGetResponseEnvelopeMessages `json:"messages,required"` + Result user.LoadBalancingMonitor `json:"result,required"` + // Whether the API call was successful + Success MonitorGetResponseEnvelopeSuccess `json:"success,required"` + JSON monitorGetResponseEnvelopeJSON `json:"-"` +} + +// monitorGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [MonitorGetResponseEnvelope] +type monitorGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type MonitorGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON monitorGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// monitorGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [MonitorGetResponseEnvelopeErrors] +type monitorGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type MonitorGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON monitorGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// monitorGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [MonitorGetResponseEnvelopeMessages] +type monitorGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type MonitorGetResponseEnvelopeSuccess bool + +const ( + MonitorGetResponseEnvelopeSuccessTrue MonitorGetResponseEnvelopeSuccess = true +) diff --git a/load_balancers/monitor_test.go b/load_balancers/monitor_test.go new file mode 100644 index 00000000000..47619a6dc60 --- /dev/null +++ b/load_balancers/monitor_test.go @@ -0,0 +1,256 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/load_balancers" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestMonitorNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.LoadBalancers.Monitors.New(context.TODO(), load_balancers.MonitorNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + ExpectedCodes: cloudflare.F("2xx"), + AllowInsecure: cloudflare.F(true), + ConsecutiveDown: cloudflare.F(int64(0)), + ConsecutiveUp: cloudflare.F(int64(0)), + Description: cloudflare.F("Login page monitor"), + ExpectedBody: cloudflare.F("alive"), + FollowRedirects: cloudflare.F(true), + Header: cloudflare.F[any](map[string]interface{}{ + "Host": map[string]interface{}{ + "0": "example.com", + }, + "X-App-ID": map[string]interface{}{ + "0": "abc123", + }, + }), + Interval: cloudflare.F(int64(0)), + Method: cloudflare.F("GET"), + Path: cloudflare.F("/health"), + Port: cloudflare.F(int64(0)), + ProbeZone: cloudflare.F("example.com"), + Retries: cloudflare.F(int64(0)), + Timeout: cloudflare.F(int64(0)), + Type: cloudflare.F(load_balancers.MonitorNewParamsTypeHTTPS), + }) + 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 TestMonitorUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.LoadBalancers.Monitors.Update( + context.TODO(), + "f1aba936b94213e5b8dca0c0dbf1f9cc", + load_balancers.MonitorUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + ExpectedCodes: cloudflare.F("2xx"), + AllowInsecure: cloudflare.F(true), + ConsecutiveDown: cloudflare.F(int64(0)), + ConsecutiveUp: cloudflare.F(int64(0)), + Description: cloudflare.F("Login page monitor"), + ExpectedBody: cloudflare.F("alive"), + FollowRedirects: cloudflare.F(true), + Header: cloudflare.F[any](map[string]interface{}{ + "Host": map[string]interface{}{ + "0": "example.com", + }, + "X-App-ID": map[string]interface{}{ + "0": "abc123", + }, + }), + Interval: cloudflare.F(int64(0)), + Method: cloudflare.F("GET"), + Path: cloudflare.F("/health"), + Port: cloudflare.F(int64(0)), + ProbeZone: cloudflare.F("example.com"), + Retries: cloudflare.F(int64(0)), + Timeout: cloudflare.F(int64(0)), + Type: cloudflare.F(load_balancers.MonitorUpdateParamsTypeHTTPS), + }, + ) + 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 TestMonitorList(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("user@example.com"), + ) + _, err := client.LoadBalancers.Monitors.List(context.TODO(), load_balancers.MonitorListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestMonitorDelete(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("user@example.com"), + ) + _, err := client.LoadBalancers.Monitors.Delete( + context.TODO(), + "f1aba936b94213e5b8dca0c0dbf1f9cc", + load_balancers.MonitorDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestMonitorEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.LoadBalancers.Monitors.Edit( + context.TODO(), + "f1aba936b94213e5b8dca0c0dbf1f9cc", + load_balancers.MonitorEditParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + ExpectedCodes: cloudflare.F("2xx"), + AllowInsecure: cloudflare.F(true), + ConsecutiveDown: cloudflare.F(int64(0)), + ConsecutiveUp: cloudflare.F(int64(0)), + Description: cloudflare.F("Login page monitor"), + ExpectedBody: cloudflare.F("alive"), + FollowRedirects: cloudflare.F(true), + Header: cloudflare.F[any](map[string]interface{}{ + "Host": map[string]interface{}{ + "0": "example.com", + }, + "X-App-ID": map[string]interface{}{ + "0": "abc123", + }, + }), + Interval: cloudflare.F(int64(0)), + Method: cloudflare.F("GET"), + Path: cloudflare.F("/health"), + Port: cloudflare.F(int64(0)), + ProbeZone: cloudflare.F("example.com"), + Retries: cloudflare.F(int64(0)), + Timeout: cloudflare.F(int64(0)), + Type: cloudflare.F(load_balancers.MonitorEditParamsTypeHTTPS), + }, + ) + 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 TestMonitorGet(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("user@example.com"), + ) + _, err := client.LoadBalancers.Monitors.Get( + context.TODO(), + "f1aba936b94213e5b8dca0c0dbf1f9cc", + load_balancers.MonitorGetParams{ + AccountID: cloudflare.F("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/load_balancers/monitorpreview.go b/load_balancers/monitorpreview.go new file mode 100644 index 00000000000..253867d061b --- /dev/null +++ b/load_balancers/monitorpreview.go @@ -0,0 +1,222 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// MonitorPreviewService 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 [NewMonitorPreviewService] method +// instead. +type MonitorPreviewService struct { + Options []option.RequestOption +} + +// NewMonitorPreviewService 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 NewMonitorPreviewService(opts ...option.RequestOption) (r *MonitorPreviewService) { + r = &MonitorPreviewService{} + r.Options = opts + return +} + +// Preview pools using the specified monitor with provided monitor details. The +// returned preview_id can be used in the preview endpoint to retrieve the results. +func (r *MonitorPreviewService) New(ctx context.Context, monitorID string, params MonitorPreviewNewParams, opts ...option.RequestOption) (res *MonitorPreviewNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env MonitorPreviewNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s/preview", params.AccountID, monitorID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type MonitorPreviewNewResponse struct { + // Monitored pool IDs mapped to their respective names. + Pools map[string]string `json:"pools"` + PreviewID string `json:"preview_id"` + JSON monitorPreviewNewResponseJSON `json:"-"` +} + +// monitorPreviewNewResponseJSON contains the JSON metadata for the struct +// [MonitorPreviewNewResponse] +type monitorPreviewNewResponseJSON struct { + Pools apijson.Field + PreviewID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorPreviewNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorPreviewNewResponseJSON) RawJSON() string { + return r.raw +} + +type MonitorPreviewNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The expected HTTP response code or code range of the health check. This + // parameter is only valid for HTTP and HTTPS monitors. + ExpectedCodes param.Field[string] `json:"expected_codes,required"` + // Do not validate the certificate when monitor use HTTPS. This parameter is + // currently only valid for HTTP and HTTPS monitors. + AllowInsecure param.Field[bool] `json:"allow_insecure"` + // To be marked unhealthy the monitored origin must fail this healthcheck N + // consecutive times. + ConsecutiveDown param.Field[int64] `json:"consecutive_down"` + // To be marked healthy the monitored origin must pass this healthcheck N + // consecutive times. + ConsecutiveUp param.Field[int64] `json:"consecutive_up"` + // Object description. + Description param.Field[string] `json:"description"` + // A case-insensitive sub-string to look for in the response body. If this string + // is not found, the origin will be marked as unhealthy. This parameter is only + // valid for HTTP and HTTPS monitors. + ExpectedBody param.Field[string] `json:"expected_body"` + // Follow redirects if returned by the origin. This parameter is only valid for + // HTTP and HTTPS monitors. + FollowRedirects param.Field[bool] `json:"follow_redirects"` + // The HTTP request headers to send in the health check. It is recommended you set + // a Host header by default. The User-Agent header cannot be overridden. This + // parameter is only valid for HTTP and HTTPS monitors. + Header param.Field[interface{}] `json:"header"` + // The interval between each health check. Shorter intervals may improve failover + // time, but will increase load on the origins as we check from multiple locations. + Interval param.Field[int64] `json:"interval"` + // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS + // based checks and 'connection_established' for TCP based health checks. + Method param.Field[string] `json:"method"` + // The endpoint path you want to conduct a health check against. This parameter is + // only valid for HTTP and HTTPS monitors. + Path param.Field[string] `json:"path"` + // The port number to connect to for the health check. Required for TCP, UDP, and + // SMTP checks. HTTP and HTTPS checks should only define the port when using a + // non-standard port (HTTP: default 80, HTTPS: default 443). + Port param.Field[int64] `json:"port"` + // Assign this monitor to emulate the specified zone while probing. This parameter + // is only valid for HTTP and HTTPS monitors. + ProbeZone param.Field[string] `json:"probe_zone"` + // The number of retries to attempt in case of a timeout before marking the origin + // as unhealthy. Retries are attempted immediately. + Retries param.Field[int64] `json:"retries"` + // The timeout (in seconds) before marking the health check as failed. + Timeout param.Field[int64] `json:"timeout"` + // The protocol to use for the health check. Currently supported protocols are + // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. + Type param.Field[MonitorPreviewNewParamsType] `json:"type"` +} + +func (r MonitorPreviewNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The protocol to use for the health check. Currently supported protocols are +// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. +type MonitorPreviewNewParamsType string + +const ( + MonitorPreviewNewParamsTypeHTTP MonitorPreviewNewParamsType = "http" + MonitorPreviewNewParamsTypeHTTPS MonitorPreviewNewParamsType = "https" + MonitorPreviewNewParamsTypeTcp MonitorPreviewNewParamsType = "tcp" + MonitorPreviewNewParamsTypeUdpIcmp MonitorPreviewNewParamsType = "udp_icmp" + MonitorPreviewNewParamsTypeIcmpPing MonitorPreviewNewParamsType = "icmp_ping" + MonitorPreviewNewParamsTypeSmtp MonitorPreviewNewParamsType = "smtp" +) + +type MonitorPreviewNewResponseEnvelope struct { + Errors []MonitorPreviewNewResponseEnvelopeErrors `json:"errors,required"` + Messages []MonitorPreviewNewResponseEnvelopeMessages `json:"messages,required"` + Result MonitorPreviewNewResponse `json:"result,required"` + // Whether the API call was successful + Success MonitorPreviewNewResponseEnvelopeSuccess `json:"success,required"` + JSON monitorPreviewNewResponseEnvelopeJSON `json:"-"` +} + +// monitorPreviewNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [MonitorPreviewNewResponseEnvelope] +type monitorPreviewNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorPreviewNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorPreviewNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type MonitorPreviewNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON monitorPreviewNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// monitorPreviewNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [MonitorPreviewNewResponseEnvelopeErrors] +type monitorPreviewNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorPreviewNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorPreviewNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type MonitorPreviewNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON monitorPreviewNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// monitorPreviewNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [MonitorPreviewNewResponseEnvelopeMessages] +type monitorPreviewNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorPreviewNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorPreviewNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type MonitorPreviewNewResponseEnvelopeSuccess bool + +const ( + MonitorPreviewNewResponseEnvelopeSuccessTrue MonitorPreviewNewResponseEnvelopeSuccess = true +) diff --git a/load_balancers/monitorpreview_test.go b/load_balancers/monitorpreview_test.go new file mode 100644 index 00000000000..87b41a1202b --- /dev/null +++ b/load_balancers/monitorpreview_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/load_balancers" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestMonitorPreviewNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.LoadBalancers.Monitors.Previews.New( + context.TODO(), + "f1aba936b94213e5b8dca0c0dbf1f9cc", + load_balancers.MonitorPreviewNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + ExpectedCodes: cloudflare.F("2xx"), + AllowInsecure: cloudflare.F(true), + ConsecutiveDown: cloudflare.F(int64(0)), + ConsecutiveUp: cloudflare.F(int64(0)), + Description: cloudflare.F("Login page monitor"), + ExpectedBody: cloudflare.F("alive"), + FollowRedirects: cloudflare.F(true), + Header: cloudflare.F[any](map[string]interface{}{ + "Host": map[string]interface{}{ + "0": "example.com", + }, + "X-App-ID": map[string]interface{}{ + "0": "abc123", + }, + }), + Interval: cloudflare.F(int64(0)), + Method: cloudflare.F("GET"), + Path: cloudflare.F("/health"), + Port: cloudflare.F(int64(0)), + ProbeZone: cloudflare.F("example.com"), + Retries: cloudflare.F(int64(0)), + Timeout: cloudflare.F(int64(0)), + Type: cloudflare.F(load_balancers.MonitorPreviewNewParamsTypeHTTPS), + }, + ) + 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/load_balancers/monitorreference.go b/load_balancers/monitorreference.go new file mode 100644 index 00000000000..ad16af7fd39 --- /dev/null +++ b/load_balancers/monitorreference.go @@ -0,0 +1,200 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// MonitorReferenceService 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 [NewMonitorReferenceService] method +// instead. +type MonitorReferenceService struct { + Options []option.RequestOption +} + +// NewMonitorReferenceService 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 NewMonitorReferenceService(opts ...option.RequestOption) (r *MonitorReferenceService) { + r = &MonitorReferenceService{} + r.Options = opts + return +} + +// Get the list of resources that reference the provided monitor. +func (r *MonitorReferenceService) Get(ctx context.Context, monitorID string, query MonitorReferenceGetParams, opts ...option.RequestOption) (res *[]MonitorReferenceGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env MonitorReferenceGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s/references", query.AccountID, monitorID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type MonitorReferenceGetResponse struct { + ReferenceType MonitorReferenceGetResponseReferenceType `json:"reference_type"` + ResourceID string `json:"resource_id"` + ResourceName string `json:"resource_name"` + ResourceType string `json:"resource_type"` + JSON monitorReferenceGetResponseJSON `json:"-"` +} + +// monitorReferenceGetResponseJSON contains the JSON metadata for the struct +// [MonitorReferenceGetResponse] +type monitorReferenceGetResponseJSON struct { + ReferenceType apijson.Field + ResourceID apijson.Field + ResourceName apijson.Field + ResourceType apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorReferenceGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorReferenceGetResponseJSON) RawJSON() string { + return r.raw +} + +type MonitorReferenceGetResponseReferenceType string + +const ( + MonitorReferenceGetResponseReferenceTypeStar MonitorReferenceGetResponseReferenceType = "*" + MonitorReferenceGetResponseReferenceTypeReferral MonitorReferenceGetResponseReferenceType = "referral" + MonitorReferenceGetResponseReferenceTypeReferrer MonitorReferenceGetResponseReferenceType = "referrer" +) + +type MonitorReferenceGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type MonitorReferenceGetResponseEnvelope struct { + Errors []MonitorReferenceGetResponseEnvelopeErrors `json:"errors,required"` + Messages []MonitorReferenceGetResponseEnvelopeMessages `json:"messages,required"` + // List of resources that reference a given monitor. + Result []MonitorReferenceGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success MonitorReferenceGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo MonitorReferenceGetResponseEnvelopeResultInfo `json:"result_info"` + JSON monitorReferenceGetResponseEnvelopeJSON `json:"-"` +} + +// monitorReferenceGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [MonitorReferenceGetResponseEnvelope] +type monitorReferenceGetResponseEnvelopeJSON 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 *MonitorReferenceGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorReferenceGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type MonitorReferenceGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON monitorReferenceGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// monitorReferenceGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [MonitorReferenceGetResponseEnvelopeErrors] +type monitorReferenceGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorReferenceGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorReferenceGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type MonitorReferenceGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON monitorReferenceGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// monitorReferenceGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [MonitorReferenceGetResponseEnvelopeMessages] +type monitorReferenceGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorReferenceGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorReferenceGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type MonitorReferenceGetResponseEnvelopeSuccess bool + +const ( + MonitorReferenceGetResponseEnvelopeSuccessTrue MonitorReferenceGetResponseEnvelopeSuccess = true +) + +type MonitorReferenceGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON monitorReferenceGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// monitorReferenceGetResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [MonitorReferenceGetResponseEnvelopeResultInfo] +type monitorReferenceGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MonitorReferenceGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r monitorReferenceGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/load_balancers/monitorreference_test.go b/load_balancers/monitorreference_test.go new file mode 100644 index 00000000000..7d322e783f5 --- /dev/null +++ b/load_balancers/monitorreference_test.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/load_balancers" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestMonitorReferenceGet(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("user@example.com"), + ) + _, err := client.LoadBalancers.Monitors.References.Get( + context.TODO(), + "f1aba936b94213e5b8dca0c0dbf1f9cc", + load_balancers.MonitorReferenceGetParams{ + AccountID: cloudflare.F("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/load_balancers/pool.go b/load_balancers/pool.go new file mode 100644 index 00000000000..db2090534a5 --- /dev/null +++ b/load_balancers/pool.go @@ -0,0 +1,1402 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/user" +) + +// PoolService 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 [NewPoolService] method instead. +type PoolService struct { + Options []option.RequestOption + Health *PoolHealthService + References *PoolReferenceService +} + +// NewPoolService 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 NewPoolService(opts ...option.RequestOption) (r *PoolService) { + r = &PoolService{} + r.Options = opts + r.Health = NewPoolHealthService(opts...) + r.References = NewPoolReferenceService(opts...) + return +} + +// Create a new pool. +func (r *PoolService) New(ctx context.Context, params PoolNewParams, opts ...option.RequestOption) (res *user.LoadBalancingPool, err error) { + opts = append(r.Options[:], opts...) + var env PoolNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/pools", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Modify a configured pool. +func (r *PoolService) Update(ctx context.Context, poolID string, params PoolUpdateParams, opts ...option.RequestOption) (res *user.LoadBalancingPool, err error) { + opts = append(r.Options[:], opts...) + var env PoolUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s", params.AccountID, poolID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List configured pools. +func (r *PoolService) List(ctx context.Context, params PoolListParams, opts ...option.RequestOption) (res *[]user.LoadBalancingPool, err error) { + opts = append(r.Options[:], opts...) + var env PoolListResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/pools", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a configured pool. +func (r *PoolService) Delete(ctx context.Context, poolID string, body PoolDeleteParams, opts ...option.RequestOption) (res *PoolDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env PoolDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s", body.AccountID, poolID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Apply changes to an existing pool, overwriting the supplied properties. +func (r *PoolService) Edit(ctx context.Context, poolID string, params PoolEditParams, opts ...option.RequestOption) (res *user.LoadBalancingPool, err error) { + opts = append(r.Options[:], opts...) + var env PoolEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s", params.AccountID, poolID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch a single configured pool. +func (r *PoolService) Get(ctx context.Context, poolID string, query PoolGetParams, opts ...option.RequestOption) (res *user.LoadBalancingPool, err error) { + opts = append(r.Options[:], opts...) + var env PoolGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s", query.AccountID, poolID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type PoolDeleteResponse struct { + ID string `json:"id"` + JSON poolDeleteResponseJSON `json:"-"` +} + +// poolDeleteResponseJSON contains the JSON metadata for the struct +// [PoolDeleteResponse] +type poolDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type PoolNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and + // underscores are allowed. + Name param.Field[string] `json:"name,required"` + // The list of origins within this pool. Traffic directed at this pool is balanced + // across all currently healthy origins, provided the pool itself is healthy. + Origins param.Field[[]PoolNewParamsOrigin] `json:"origins,required"` + // A human-readable description of the pool. + Description param.Field[string] `json:"description"` + // Whether to enable (the default) or disable this pool. Disabled pools will not + // receive traffic and are excluded from health checks. Disabling a pool will cause + // any load balancers using it to failover to the next pool (if any). + Enabled param.Field[bool] `json:"enabled"` + // The latitude of the data center containing the origins used in this pool in + // decimal degrees. If this is set, longitude must also be set. + Latitude param.Field[float64] `json:"latitude"` + // Configures load shedding policies and percentages for the pool. + LoadShedding param.Field[PoolNewParamsLoadShedding] `json:"load_shedding"` + // The longitude of the data center containing the origins used in this pool in + // decimal degrees. If this is set, latitude must also be set. + Longitude param.Field[float64] `json:"longitude"` + // The minimum number of origins that must be healthy for this pool to serve + // traffic. If the number of healthy origins falls below this number, the pool will + // be marked unhealthy and will failover to the next available pool. + MinimumOrigins param.Field[int64] `json:"minimum_origins"` + // The ID of the Monitor to use for checking the health of origins within this + // pool. + Monitor param.Field[interface{}] `json:"monitor"` + // This field is now deprecated. It has been moved to Cloudflare's Centralized + // Notification service + // https://developers.cloudflare.com/fundamentals/notifications/. The email address + // to send health status notifications to. This can be an individual mailbox or a + // mailing list. Multiple emails can be supplied as a comma delimited list. + NotificationEmail param.Field[string] `json:"notification_email"` + // Filter pool and origin health notifications by resource type or health status. + // Use null to reset. + NotificationFilter param.Field[PoolNewParamsNotificationFilter] `json:"notification_filter"` + // Configures origin steering for the pool. Controls how origins are selected for + // new sessions and traffic without session affinity. + OriginSteering param.Field[PoolNewParamsOriginSteering] `json:"origin_steering"` +} + +func (r PoolNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type PoolNewParamsOrigin struct { + // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable + // hostname. Hostnames entered here should resolve directly to the origin, and not + // be a hostname proxied by Cloudflare. To set an internal/reserved address, + // virtual_network_id must also be set. + Address param.Field[string] `json:"address"` + // Whether to enable (the default) this origin within the pool. Disabled origins + // will not receive traffic and are excluded from health checks. The origin will + // only be disabled for the current pool. + Enabled param.Field[bool] `json:"enabled"` + // The request header is used to pass additional information with an HTTP request. + // Currently supported header is 'Host'. + Header param.Field[PoolNewParamsOriginsHeader] `json:"header"` + // A human-identifiable name for the origin. + Name param.Field[string] `json:"name"` + // The virtual network subnet ID the origin belongs in. Virtual network must also + // belong to the account. + VirtualNetworkID param.Field[string] `json:"virtual_network_id"` + // The weight of this origin relative to other origins in the pool. Based on the + // configured weight the total traffic is distributed among origins within the + // pool. + // + // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the + // origin's outstanding requests. + // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's + // open connections. + Weight param.Field[float64] `json:"weight"` +} + +func (r PoolNewParamsOrigin) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The request header is used to pass additional information with an HTTP request. +// Currently supported header is 'Host'. +type PoolNewParamsOriginsHeader struct { + // The 'Host' header allows to override the hostname set in the HTTP request. + // Current support is 1 'Host' header override per origin. + Host param.Field[[]string] `json:"Host"` +} + +func (r PoolNewParamsOriginsHeader) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures load shedding policies and percentages for the pool. +type PoolNewParamsLoadShedding struct { + // The percent of traffic to shed from the pool, according to the default policy. + // Applies to new sessions and traffic without session affinity. + DefaultPercent param.Field[float64] `json:"default_percent"` + // The default policy to use when load shedding. A random policy randomly sheds a + // given percent of requests. A hash policy computes a hash over the + // CF-Connecting-IP address and sheds all requests originating from a percent of + // IPs. + DefaultPolicy param.Field[PoolNewParamsLoadSheddingDefaultPolicy] `json:"default_policy"` + // The percent of existing sessions to shed from the pool, according to the session + // policy. + SessionPercent param.Field[float64] `json:"session_percent"` + // Only the hash policy is supported for existing sessions (to avoid exponential + // decay). + SessionPolicy param.Field[PoolNewParamsLoadSheddingSessionPolicy] `json:"session_policy"` +} + +func (r PoolNewParamsLoadShedding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The default policy to use when load shedding. A random policy randomly sheds a +// given percent of requests. A hash policy computes a hash over the +// CF-Connecting-IP address and sheds all requests originating from a percent of +// IPs. +type PoolNewParamsLoadSheddingDefaultPolicy string + +const ( + PoolNewParamsLoadSheddingDefaultPolicyRandom PoolNewParamsLoadSheddingDefaultPolicy = "random" + PoolNewParamsLoadSheddingDefaultPolicyHash PoolNewParamsLoadSheddingDefaultPolicy = "hash" +) + +// Only the hash policy is supported for existing sessions (to avoid exponential +// decay). +type PoolNewParamsLoadSheddingSessionPolicy string + +const ( + PoolNewParamsLoadSheddingSessionPolicyHash PoolNewParamsLoadSheddingSessionPolicy = "hash" +) + +// Filter pool and origin health notifications by resource type or health status. +// Use null to reset. +type PoolNewParamsNotificationFilter struct { + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Origin param.Field[PoolNewParamsNotificationFilterOrigin] `json:"origin"` + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Pool param.Field[PoolNewParamsNotificationFilterPool] `json:"pool"` +} + +func (r PoolNewParamsNotificationFilter) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Filter options for a particular resource type (pool or origin). Use null to +// reset. +type PoolNewParamsNotificationFilterOrigin struct { + // If set true, disable notifications for this type of resource (pool or origin). + Disable param.Field[bool] `json:"disable"` + // If present, send notifications only for this health status (e.g. false for only + // DOWN events). Use null to reset (all events). + Healthy param.Field[bool] `json:"healthy"` +} + +func (r PoolNewParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Filter options for a particular resource type (pool or origin). Use null to +// reset. +type PoolNewParamsNotificationFilterPool struct { + // If set true, disable notifications for this type of resource (pool or origin). + Disable param.Field[bool] `json:"disable"` + // If present, send notifications only for this health status (e.g. false for only + // DOWN events). Use null to reset (all events). + Healthy param.Field[bool] `json:"healthy"` +} + +func (r PoolNewParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures origin steering for the pool. Controls how origins are selected for +// new sessions and traffic without session affinity. +type PoolNewParamsOriginSteering struct { + // The type of origin steering policy to use. + // + // - `"random"`: Select an origin randomly. + // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP + // address. + // - `"least_outstanding_requests"`: Select an origin by taking into consideration + // origin weights, as well as each origin's number of outstanding requests. + // Origins with more pending requests are weighted proportionately less relative + // to others. + // - `"least_connections"`: Select an origin by taking into consideration origin + // weights, as well as each origin's number of open connections. Origins with + // more open connections are weighted proportionately less relative to others. + // Supported for HTTP/1 and HTTP/2 connections. + Policy param.Field[PoolNewParamsOriginSteeringPolicy] `json:"policy"` +} + +func (r PoolNewParamsOriginSteering) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of origin steering policy to use. +// +// - `"random"`: Select an origin randomly. +// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP +// address. +// - `"least_outstanding_requests"`: Select an origin by taking into consideration +// origin weights, as well as each origin's number of outstanding requests. +// Origins with more pending requests are weighted proportionately less relative +// to others. +// - `"least_connections"`: Select an origin by taking into consideration origin +// weights, as well as each origin's number of open connections. Origins with +// more open connections are weighted proportionately less relative to others. +// Supported for HTTP/1 and HTTP/2 connections. +type PoolNewParamsOriginSteeringPolicy string + +const ( + PoolNewParamsOriginSteeringPolicyRandom PoolNewParamsOriginSteeringPolicy = "random" + PoolNewParamsOriginSteeringPolicyHash PoolNewParamsOriginSteeringPolicy = "hash" + PoolNewParamsOriginSteeringPolicyLeastOutstandingRequests PoolNewParamsOriginSteeringPolicy = "least_outstanding_requests" + PoolNewParamsOriginSteeringPolicyLeastConnections PoolNewParamsOriginSteeringPolicy = "least_connections" +) + +type PoolNewResponseEnvelope struct { + Errors []PoolNewResponseEnvelopeErrors `json:"errors,required"` + Messages []PoolNewResponseEnvelopeMessages `json:"messages,required"` + Result user.LoadBalancingPool `json:"result,required"` + // Whether the API call was successful + Success PoolNewResponseEnvelopeSuccess `json:"success,required"` + JSON poolNewResponseEnvelopeJSON `json:"-"` +} + +// poolNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [PoolNewResponseEnvelope] +type poolNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PoolNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON poolNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// poolNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PoolNewResponseEnvelopeErrors] +type poolNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PoolNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON poolNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// poolNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PoolNewResponseEnvelopeMessages] +type poolNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PoolNewResponseEnvelopeSuccess bool + +const ( + PoolNewResponseEnvelopeSuccessTrue PoolNewResponseEnvelopeSuccess = true +) + +type PoolUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and + // underscores are allowed. + Name param.Field[string] `json:"name,required"` + // The list of origins within this pool. Traffic directed at this pool is balanced + // across all currently healthy origins, provided the pool itself is healthy. + Origins param.Field[[]PoolUpdateParamsOrigin] `json:"origins,required"` + // A list of regions from which to run health checks. Null means every Cloudflare + // data center. + CheckRegions param.Field[[]PoolUpdateParamsCheckRegion] `json:"check_regions"` + // A human-readable description of the pool. + Description param.Field[string] `json:"description"` + // Whether to enable (the default) or disable this pool. Disabled pools will not + // receive traffic and are excluded from health checks. Disabling a pool will cause + // any load balancers using it to failover to the next pool (if any). + Enabled param.Field[bool] `json:"enabled"` + // The latitude of the data center containing the origins used in this pool in + // decimal degrees. If this is set, longitude must also be set. + Latitude param.Field[float64] `json:"latitude"` + // Configures load shedding policies and percentages for the pool. + LoadShedding param.Field[PoolUpdateParamsLoadShedding] `json:"load_shedding"` + // The longitude of the data center containing the origins used in this pool in + // decimal degrees. If this is set, latitude must also be set. + Longitude param.Field[float64] `json:"longitude"` + // The minimum number of origins that must be healthy for this pool to serve + // traffic. If the number of healthy origins falls below this number, the pool will + // be marked unhealthy and will failover to the next available pool. + MinimumOrigins param.Field[int64] `json:"minimum_origins"` + // The ID of the Monitor to use for checking the health of origins within this + // pool. + Monitor param.Field[interface{}] `json:"monitor"` + // This field is now deprecated. It has been moved to Cloudflare's Centralized + // Notification service + // https://developers.cloudflare.com/fundamentals/notifications/. The email address + // to send health status notifications to. This can be an individual mailbox or a + // mailing list. Multiple emails can be supplied as a comma delimited list. + NotificationEmail param.Field[string] `json:"notification_email"` + // Filter pool and origin health notifications by resource type or health status. + // Use null to reset. + NotificationFilter param.Field[PoolUpdateParamsNotificationFilter] `json:"notification_filter"` + // Configures origin steering for the pool. Controls how origins are selected for + // new sessions and traffic without session affinity. + OriginSteering param.Field[PoolUpdateParamsOriginSteering] `json:"origin_steering"` +} + +func (r PoolUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type PoolUpdateParamsOrigin struct { + // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable + // hostname. Hostnames entered here should resolve directly to the origin, and not + // be a hostname proxied by Cloudflare. To set an internal/reserved address, + // virtual_network_id must also be set. + Address param.Field[string] `json:"address"` + // Whether to enable (the default) this origin within the pool. Disabled origins + // will not receive traffic and are excluded from health checks. The origin will + // only be disabled for the current pool. + Enabled param.Field[bool] `json:"enabled"` + // The request header is used to pass additional information with an HTTP request. + // Currently supported header is 'Host'. + Header param.Field[PoolUpdateParamsOriginsHeader] `json:"header"` + // A human-identifiable name for the origin. + Name param.Field[string] `json:"name"` + // The virtual network subnet ID the origin belongs in. Virtual network must also + // belong to the account. + VirtualNetworkID param.Field[string] `json:"virtual_network_id"` + // The weight of this origin relative to other origins in the pool. Based on the + // configured weight the total traffic is distributed among origins within the + // pool. + // + // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the + // origin's outstanding requests. + // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's + // open connections. + Weight param.Field[float64] `json:"weight"` +} + +func (r PoolUpdateParamsOrigin) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The request header is used to pass additional information with an HTTP request. +// Currently supported header is 'Host'. +type PoolUpdateParamsOriginsHeader struct { + // The 'Host' header allows to override the hostname set in the HTTP request. + // Current support is 1 'Host' header override per origin. + Host param.Field[[]string] `json:"Host"` +} + +func (r PoolUpdateParamsOriginsHeader) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, +// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, +// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: +// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all +// regions (ENTERPRISE customers only). +type PoolUpdateParamsCheckRegion string + +const ( + PoolUpdateParamsCheckRegionWnam PoolUpdateParamsCheckRegion = "WNAM" + PoolUpdateParamsCheckRegionEnam PoolUpdateParamsCheckRegion = "ENAM" + PoolUpdateParamsCheckRegionWeu PoolUpdateParamsCheckRegion = "WEU" + PoolUpdateParamsCheckRegionEeu PoolUpdateParamsCheckRegion = "EEU" + PoolUpdateParamsCheckRegionNsam PoolUpdateParamsCheckRegion = "NSAM" + PoolUpdateParamsCheckRegionSsam PoolUpdateParamsCheckRegion = "SSAM" + PoolUpdateParamsCheckRegionOc PoolUpdateParamsCheckRegion = "OC" + PoolUpdateParamsCheckRegionMe PoolUpdateParamsCheckRegion = "ME" + PoolUpdateParamsCheckRegionNaf PoolUpdateParamsCheckRegion = "NAF" + PoolUpdateParamsCheckRegionSaf PoolUpdateParamsCheckRegion = "SAF" + PoolUpdateParamsCheckRegionSas PoolUpdateParamsCheckRegion = "SAS" + PoolUpdateParamsCheckRegionSeas PoolUpdateParamsCheckRegion = "SEAS" + PoolUpdateParamsCheckRegionNeas PoolUpdateParamsCheckRegion = "NEAS" + PoolUpdateParamsCheckRegionAllRegions PoolUpdateParamsCheckRegion = "ALL_REGIONS" +) + +// Configures load shedding policies and percentages for the pool. +type PoolUpdateParamsLoadShedding struct { + // The percent of traffic to shed from the pool, according to the default policy. + // Applies to new sessions and traffic without session affinity. + DefaultPercent param.Field[float64] `json:"default_percent"` + // The default policy to use when load shedding. A random policy randomly sheds a + // given percent of requests. A hash policy computes a hash over the + // CF-Connecting-IP address and sheds all requests originating from a percent of + // IPs. + DefaultPolicy param.Field[PoolUpdateParamsLoadSheddingDefaultPolicy] `json:"default_policy"` + // The percent of existing sessions to shed from the pool, according to the session + // policy. + SessionPercent param.Field[float64] `json:"session_percent"` + // Only the hash policy is supported for existing sessions (to avoid exponential + // decay). + SessionPolicy param.Field[PoolUpdateParamsLoadSheddingSessionPolicy] `json:"session_policy"` +} + +func (r PoolUpdateParamsLoadShedding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The default policy to use when load shedding. A random policy randomly sheds a +// given percent of requests. A hash policy computes a hash over the +// CF-Connecting-IP address and sheds all requests originating from a percent of +// IPs. +type PoolUpdateParamsLoadSheddingDefaultPolicy string + +const ( + PoolUpdateParamsLoadSheddingDefaultPolicyRandom PoolUpdateParamsLoadSheddingDefaultPolicy = "random" + PoolUpdateParamsLoadSheddingDefaultPolicyHash PoolUpdateParamsLoadSheddingDefaultPolicy = "hash" +) + +// Only the hash policy is supported for existing sessions (to avoid exponential +// decay). +type PoolUpdateParamsLoadSheddingSessionPolicy string + +const ( + PoolUpdateParamsLoadSheddingSessionPolicyHash PoolUpdateParamsLoadSheddingSessionPolicy = "hash" +) + +// Filter pool and origin health notifications by resource type or health status. +// Use null to reset. +type PoolUpdateParamsNotificationFilter struct { + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Origin param.Field[PoolUpdateParamsNotificationFilterOrigin] `json:"origin"` + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Pool param.Field[PoolUpdateParamsNotificationFilterPool] `json:"pool"` +} + +func (r PoolUpdateParamsNotificationFilter) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Filter options for a particular resource type (pool or origin). Use null to +// reset. +type PoolUpdateParamsNotificationFilterOrigin struct { + // If set true, disable notifications for this type of resource (pool or origin). + Disable param.Field[bool] `json:"disable"` + // If present, send notifications only for this health status (e.g. false for only + // DOWN events). Use null to reset (all events). + Healthy param.Field[bool] `json:"healthy"` +} + +func (r PoolUpdateParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Filter options for a particular resource type (pool or origin). Use null to +// reset. +type PoolUpdateParamsNotificationFilterPool struct { + // If set true, disable notifications for this type of resource (pool or origin). + Disable param.Field[bool] `json:"disable"` + // If present, send notifications only for this health status (e.g. false for only + // DOWN events). Use null to reset (all events). + Healthy param.Field[bool] `json:"healthy"` +} + +func (r PoolUpdateParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures origin steering for the pool. Controls how origins are selected for +// new sessions and traffic without session affinity. +type PoolUpdateParamsOriginSteering struct { + // The type of origin steering policy to use. + // + // - `"random"`: Select an origin randomly. + // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP + // address. + // - `"least_outstanding_requests"`: Select an origin by taking into consideration + // origin weights, as well as each origin's number of outstanding requests. + // Origins with more pending requests are weighted proportionately less relative + // to others. + // - `"least_connections"`: Select an origin by taking into consideration origin + // weights, as well as each origin's number of open connections. Origins with + // more open connections are weighted proportionately less relative to others. + // Supported for HTTP/1 and HTTP/2 connections. + Policy param.Field[PoolUpdateParamsOriginSteeringPolicy] `json:"policy"` +} + +func (r PoolUpdateParamsOriginSteering) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of origin steering policy to use. +// +// - `"random"`: Select an origin randomly. +// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP +// address. +// - `"least_outstanding_requests"`: Select an origin by taking into consideration +// origin weights, as well as each origin's number of outstanding requests. +// Origins with more pending requests are weighted proportionately less relative +// to others. +// - `"least_connections"`: Select an origin by taking into consideration origin +// weights, as well as each origin's number of open connections. Origins with +// more open connections are weighted proportionately less relative to others. +// Supported for HTTP/1 and HTTP/2 connections. +type PoolUpdateParamsOriginSteeringPolicy string + +const ( + PoolUpdateParamsOriginSteeringPolicyRandom PoolUpdateParamsOriginSteeringPolicy = "random" + PoolUpdateParamsOriginSteeringPolicyHash PoolUpdateParamsOriginSteeringPolicy = "hash" + PoolUpdateParamsOriginSteeringPolicyLeastOutstandingRequests PoolUpdateParamsOriginSteeringPolicy = "least_outstanding_requests" + PoolUpdateParamsOriginSteeringPolicyLeastConnections PoolUpdateParamsOriginSteeringPolicy = "least_connections" +) + +type PoolUpdateResponseEnvelope struct { + Errors []PoolUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []PoolUpdateResponseEnvelopeMessages `json:"messages,required"` + Result user.LoadBalancingPool `json:"result,required"` + // Whether the API call was successful + Success PoolUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON poolUpdateResponseEnvelopeJSON `json:"-"` +} + +// poolUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [PoolUpdateResponseEnvelope] +type poolUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PoolUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON poolUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// poolUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PoolUpdateResponseEnvelopeErrors] +type poolUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PoolUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON poolUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// poolUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PoolUpdateResponseEnvelopeMessages] +type poolUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PoolUpdateResponseEnvelopeSuccess bool + +const ( + PoolUpdateResponseEnvelopeSuccessTrue PoolUpdateResponseEnvelopeSuccess = true +) + +type PoolListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The ID of the Monitor to use for checking the health of origins within this + // pool. + Monitor param.Field[interface{}] `query:"monitor"` +} + +// URLQuery serializes [PoolListParams]'s query parameters as `url.Values`. +func (r PoolListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type PoolListResponseEnvelope struct { + Errors []PoolListResponseEnvelopeErrors `json:"errors,required"` + Messages []PoolListResponseEnvelopeMessages `json:"messages,required"` + Result []user.LoadBalancingPool `json:"result,required,nullable"` + // Whether the API call was successful + Success PoolListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo PoolListResponseEnvelopeResultInfo `json:"result_info"` + JSON poolListResponseEnvelopeJSON `json:"-"` +} + +// poolListResponseEnvelopeJSON contains the JSON metadata for the struct +// [PoolListResponseEnvelope] +type poolListResponseEnvelopeJSON 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 *PoolListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PoolListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON poolListResponseEnvelopeErrorsJSON `json:"-"` +} + +// poolListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PoolListResponseEnvelopeErrors] +type poolListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PoolListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON poolListResponseEnvelopeMessagesJSON `json:"-"` +} + +// poolListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PoolListResponseEnvelopeMessages] +type poolListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PoolListResponseEnvelopeSuccess bool + +const ( + PoolListResponseEnvelopeSuccessTrue PoolListResponseEnvelopeSuccess = true +) + +type PoolListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON poolListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// poolListResponseEnvelopeResultInfoJSON contains the JSON metadata for the struct +// [PoolListResponseEnvelopeResultInfo] +type poolListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type PoolDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type PoolDeleteResponseEnvelope struct { + Errors []PoolDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []PoolDeleteResponseEnvelopeMessages `json:"messages,required"` + Result PoolDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success PoolDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON poolDeleteResponseEnvelopeJSON `json:"-"` +} + +// poolDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [PoolDeleteResponseEnvelope] +type poolDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PoolDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON poolDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// poolDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PoolDeleteResponseEnvelopeErrors] +type poolDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PoolDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON poolDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// poolDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PoolDeleteResponseEnvelopeMessages] +type poolDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PoolDeleteResponseEnvelopeSuccess bool + +const ( + PoolDeleteResponseEnvelopeSuccessTrue PoolDeleteResponseEnvelopeSuccess = true +) + +type PoolEditParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // A list of regions from which to run health checks. Null means every Cloudflare + // data center. + CheckRegions param.Field[[]PoolEditParamsCheckRegion] `json:"check_regions"` + // A human-readable description of the pool. + Description param.Field[string] `json:"description"` + // Whether to enable (the default) or disable this pool. Disabled pools will not + // receive traffic and are excluded from health checks. Disabling a pool will cause + // any load balancers using it to failover to the next pool (if any). + Enabled param.Field[bool] `json:"enabled"` + // The latitude of the data center containing the origins used in this pool in + // decimal degrees. If this is set, longitude must also be set. + Latitude param.Field[float64] `json:"latitude"` + // Configures load shedding policies and percentages for the pool. + LoadShedding param.Field[PoolEditParamsLoadShedding] `json:"load_shedding"` + // The longitude of the data center containing the origins used in this pool in + // decimal degrees. If this is set, latitude must also be set. + Longitude param.Field[float64] `json:"longitude"` + // The minimum number of origins that must be healthy for this pool to serve + // traffic. If the number of healthy origins falls below this number, the pool will + // be marked unhealthy and will failover to the next available pool. + MinimumOrigins param.Field[int64] `json:"minimum_origins"` + // The ID of the Monitor to use for checking the health of origins within this + // pool. + Monitor param.Field[interface{}] `json:"monitor"` + // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and + // underscores are allowed. + Name param.Field[string] `json:"name"` + // This field is now deprecated. It has been moved to Cloudflare's Centralized + // Notification service + // https://developers.cloudflare.com/fundamentals/notifications/. The email address + // to send health status notifications to. This can be an individual mailbox or a + // mailing list. Multiple emails can be supplied as a comma delimited list. + NotificationEmail param.Field[string] `json:"notification_email"` + // Filter pool and origin health notifications by resource type or health status. + // Use null to reset. + NotificationFilter param.Field[PoolEditParamsNotificationFilter] `json:"notification_filter"` + // Configures origin steering for the pool. Controls how origins are selected for + // new sessions and traffic without session affinity. + OriginSteering param.Field[PoolEditParamsOriginSteering] `json:"origin_steering"` + // The list of origins within this pool. Traffic directed at this pool is balanced + // across all currently healthy origins, provided the pool itself is healthy. + Origins param.Field[[]PoolEditParamsOrigin] `json:"origins"` +} + +func (r PoolEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, +// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, +// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: +// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all +// regions (ENTERPRISE customers only). +type PoolEditParamsCheckRegion string + +const ( + PoolEditParamsCheckRegionWnam PoolEditParamsCheckRegion = "WNAM" + PoolEditParamsCheckRegionEnam PoolEditParamsCheckRegion = "ENAM" + PoolEditParamsCheckRegionWeu PoolEditParamsCheckRegion = "WEU" + PoolEditParamsCheckRegionEeu PoolEditParamsCheckRegion = "EEU" + PoolEditParamsCheckRegionNsam PoolEditParamsCheckRegion = "NSAM" + PoolEditParamsCheckRegionSsam PoolEditParamsCheckRegion = "SSAM" + PoolEditParamsCheckRegionOc PoolEditParamsCheckRegion = "OC" + PoolEditParamsCheckRegionMe PoolEditParamsCheckRegion = "ME" + PoolEditParamsCheckRegionNaf PoolEditParamsCheckRegion = "NAF" + PoolEditParamsCheckRegionSaf PoolEditParamsCheckRegion = "SAF" + PoolEditParamsCheckRegionSas PoolEditParamsCheckRegion = "SAS" + PoolEditParamsCheckRegionSeas PoolEditParamsCheckRegion = "SEAS" + PoolEditParamsCheckRegionNeas PoolEditParamsCheckRegion = "NEAS" + PoolEditParamsCheckRegionAllRegions PoolEditParamsCheckRegion = "ALL_REGIONS" +) + +// Configures load shedding policies and percentages for the pool. +type PoolEditParamsLoadShedding struct { + // The percent of traffic to shed from the pool, according to the default policy. + // Applies to new sessions and traffic without session affinity. + DefaultPercent param.Field[float64] `json:"default_percent"` + // The default policy to use when load shedding. A random policy randomly sheds a + // given percent of requests. A hash policy computes a hash over the + // CF-Connecting-IP address and sheds all requests originating from a percent of + // IPs. + DefaultPolicy param.Field[PoolEditParamsLoadSheddingDefaultPolicy] `json:"default_policy"` + // The percent of existing sessions to shed from the pool, according to the session + // policy. + SessionPercent param.Field[float64] `json:"session_percent"` + // Only the hash policy is supported for existing sessions (to avoid exponential + // decay). + SessionPolicy param.Field[PoolEditParamsLoadSheddingSessionPolicy] `json:"session_policy"` +} + +func (r PoolEditParamsLoadShedding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The default policy to use when load shedding. A random policy randomly sheds a +// given percent of requests. A hash policy computes a hash over the +// CF-Connecting-IP address and sheds all requests originating from a percent of +// IPs. +type PoolEditParamsLoadSheddingDefaultPolicy string + +const ( + PoolEditParamsLoadSheddingDefaultPolicyRandom PoolEditParamsLoadSheddingDefaultPolicy = "random" + PoolEditParamsLoadSheddingDefaultPolicyHash PoolEditParamsLoadSheddingDefaultPolicy = "hash" +) + +// Only the hash policy is supported for existing sessions (to avoid exponential +// decay). +type PoolEditParamsLoadSheddingSessionPolicy string + +const ( + PoolEditParamsLoadSheddingSessionPolicyHash PoolEditParamsLoadSheddingSessionPolicy = "hash" +) + +// Filter pool and origin health notifications by resource type or health status. +// Use null to reset. +type PoolEditParamsNotificationFilter struct { + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Origin param.Field[PoolEditParamsNotificationFilterOrigin] `json:"origin"` + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Pool param.Field[PoolEditParamsNotificationFilterPool] `json:"pool"` +} + +func (r PoolEditParamsNotificationFilter) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Filter options for a particular resource type (pool or origin). Use null to +// reset. +type PoolEditParamsNotificationFilterOrigin struct { + // If set true, disable notifications for this type of resource (pool or origin). + Disable param.Field[bool] `json:"disable"` + // If present, send notifications only for this health status (e.g. false for only + // DOWN events). Use null to reset (all events). + Healthy param.Field[bool] `json:"healthy"` +} + +func (r PoolEditParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Filter options for a particular resource type (pool or origin). Use null to +// reset. +type PoolEditParamsNotificationFilterPool struct { + // If set true, disable notifications for this type of resource (pool or origin). + Disable param.Field[bool] `json:"disable"` + // If present, send notifications only for this health status (e.g. false for only + // DOWN events). Use null to reset (all events). + Healthy param.Field[bool] `json:"healthy"` +} + +func (r PoolEditParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures origin steering for the pool. Controls how origins are selected for +// new sessions and traffic without session affinity. +type PoolEditParamsOriginSteering struct { + // The type of origin steering policy to use. + // + // - `"random"`: Select an origin randomly. + // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP + // address. + // - `"least_outstanding_requests"`: Select an origin by taking into consideration + // origin weights, as well as each origin's number of outstanding requests. + // Origins with more pending requests are weighted proportionately less relative + // to others. + // - `"least_connections"`: Select an origin by taking into consideration origin + // weights, as well as each origin's number of open connections. Origins with + // more open connections are weighted proportionately less relative to others. + // Supported for HTTP/1 and HTTP/2 connections. + Policy param.Field[PoolEditParamsOriginSteeringPolicy] `json:"policy"` +} + +func (r PoolEditParamsOriginSteering) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of origin steering policy to use. +// +// - `"random"`: Select an origin randomly. +// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP +// address. +// - `"least_outstanding_requests"`: Select an origin by taking into consideration +// origin weights, as well as each origin's number of outstanding requests. +// Origins with more pending requests are weighted proportionately less relative +// to others. +// - `"least_connections"`: Select an origin by taking into consideration origin +// weights, as well as each origin's number of open connections. Origins with +// more open connections are weighted proportionately less relative to others. +// Supported for HTTP/1 and HTTP/2 connections. +type PoolEditParamsOriginSteeringPolicy string + +const ( + PoolEditParamsOriginSteeringPolicyRandom PoolEditParamsOriginSteeringPolicy = "random" + PoolEditParamsOriginSteeringPolicyHash PoolEditParamsOriginSteeringPolicy = "hash" + PoolEditParamsOriginSteeringPolicyLeastOutstandingRequests PoolEditParamsOriginSteeringPolicy = "least_outstanding_requests" + PoolEditParamsOriginSteeringPolicyLeastConnections PoolEditParamsOriginSteeringPolicy = "least_connections" +) + +type PoolEditParamsOrigin struct { + // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable + // hostname. Hostnames entered here should resolve directly to the origin, and not + // be a hostname proxied by Cloudflare. To set an internal/reserved address, + // virtual_network_id must also be set. + Address param.Field[string] `json:"address"` + // Whether to enable (the default) this origin within the pool. Disabled origins + // will not receive traffic and are excluded from health checks. The origin will + // only be disabled for the current pool. + Enabled param.Field[bool] `json:"enabled"` + // The request header is used to pass additional information with an HTTP request. + // Currently supported header is 'Host'. + Header param.Field[PoolEditParamsOriginsHeader] `json:"header"` + // A human-identifiable name for the origin. + Name param.Field[string] `json:"name"` + // The virtual network subnet ID the origin belongs in. Virtual network must also + // belong to the account. + VirtualNetworkID param.Field[string] `json:"virtual_network_id"` + // The weight of this origin relative to other origins in the pool. Based on the + // configured weight the total traffic is distributed among origins within the + // pool. + // + // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the + // origin's outstanding requests. + // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's + // open connections. + Weight param.Field[float64] `json:"weight"` +} + +func (r PoolEditParamsOrigin) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The request header is used to pass additional information with an HTTP request. +// Currently supported header is 'Host'. +type PoolEditParamsOriginsHeader struct { + // The 'Host' header allows to override the hostname set in the HTTP request. + // Current support is 1 'Host' header override per origin. + Host param.Field[[]string] `json:"Host"` +} + +func (r PoolEditParamsOriginsHeader) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type PoolEditResponseEnvelope struct { + Errors []PoolEditResponseEnvelopeErrors `json:"errors,required"` + Messages []PoolEditResponseEnvelopeMessages `json:"messages,required"` + Result user.LoadBalancingPool `json:"result,required"` + // Whether the API call was successful + Success PoolEditResponseEnvelopeSuccess `json:"success,required"` + JSON poolEditResponseEnvelopeJSON `json:"-"` +} + +// poolEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [PoolEditResponseEnvelope] +type poolEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PoolEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON poolEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// poolEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PoolEditResponseEnvelopeErrors] +type poolEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PoolEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON poolEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// poolEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PoolEditResponseEnvelopeMessages] +type poolEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PoolEditResponseEnvelopeSuccess bool + +const ( + PoolEditResponseEnvelopeSuccessTrue PoolEditResponseEnvelopeSuccess = true +) + +type PoolGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type PoolGetResponseEnvelope struct { + Errors []PoolGetResponseEnvelopeErrors `json:"errors,required"` + Messages []PoolGetResponseEnvelopeMessages `json:"messages,required"` + Result user.LoadBalancingPool `json:"result,required"` + // Whether the API call was successful + Success PoolGetResponseEnvelopeSuccess `json:"success,required"` + JSON poolGetResponseEnvelopeJSON `json:"-"` +} + +// poolGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [PoolGetResponseEnvelope] +type poolGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PoolGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON poolGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// poolGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PoolGetResponseEnvelopeErrors] +type poolGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PoolGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON poolGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// poolGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PoolGetResponseEnvelopeMessages] +type poolGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PoolGetResponseEnvelopeSuccess bool + +const ( + PoolGetResponseEnvelopeSuccessTrue PoolGetResponseEnvelopeSuccess = true +) diff --git a/load_balancers/pool_test.go b/load_balancers/pool_test.go new file mode 100644 index 00000000000..32da1569d1e --- /dev/null +++ b/load_balancers/pool_test.go @@ -0,0 +1,355 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/load_balancers" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestPoolNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.LoadBalancers.Pools.New(context.TODO(), load_balancers.PoolNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Name: cloudflare.F("primary-dc-1"), + Origins: cloudflare.F([]load_balancers.PoolNewParamsOrigin{{ + Address: cloudflare.F("0.0.0.0"), + Enabled: cloudflare.F(true), + Header: cloudflare.F(load_balancers.PoolNewParamsOriginsHeader{ + Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + }), + Name: cloudflare.F("app-server-1"), + VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), + Weight: cloudflare.F(0.600000), + }, { + Address: cloudflare.F("0.0.0.0"), + Enabled: cloudflare.F(true), + Header: cloudflare.F(load_balancers.PoolNewParamsOriginsHeader{ + Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + }), + Name: cloudflare.F("app-server-1"), + VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), + Weight: cloudflare.F(0.600000), + }, { + Address: cloudflare.F("0.0.0.0"), + Enabled: cloudflare.F(true), + Header: cloudflare.F(load_balancers.PoolNewParamsOriginsHeader{ + Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + }), + Name: cloudflare.F("app-server-1"), + VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), + Weight: cloudflare.F(0.600000), + }}), + Description: cloudflare.F("Primary data center - Provider XYZ"), + Enabled: cloudflare.F(false), + Latitude: cloudflare.F(0.000000), + LoadShedding: cloudflare.F(load_balancers.PoolNewParamsLoadShedding{ + DefaultPercent: cloudflare.F(0.000000), + DefaultPolicy: cloudflare.F(load_balancers.PoolNewParamsLoadSheddingDefaultPolicyRandom), + SessionPercent: cloudflare.F(0.000000), + SessionPolicy: cloudflare.F(load_balancers.PoolNewParamsLoadSheddingSessionPolicyHash), + }), + Longitude: cloudflare.F(0.000000), + MinimumOrigins: cloudflare.F(int64(0)), + Monitor: cloudflare.F[any](map[string]interface{}{}), + NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), + NotificationFilter: cloudflare.F(load_balancers.PoolNewParamsNotificationFilter{ + Origin: cloudflare.F(load_balancers.PoolNewParamsNotificationFilterOrigin{ + Disable: cloudflare.F(true), + Healthy: cloudflare.F(true), + }), + Pool: cloudflare.F(load_balancers.PoolNewParamsNotificationFilterPool{ + Disable: cloudflare.F(true), + Healthy: cloudflare.F(false), + }), + }), + OriginSteering: cloudflare.F(load_balancers.PoolNewParamsOriginSteering{ + Policy: cloudflare.F(load_balancers.PoolNewParamsOriginSteeringPolicyRandom), + }), + }) + 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 TestPoolUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.LoadBalancers.Pools.Update( + context.TODO(), + "17b5962d775c646f3f9725cbc7a53df4", + load_balancers.PoolUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Name: cloudflare.F("primary-dc-1"), + Origins: cloudflare.F([]load_balancers.PoolUpdateParamsOrigin{{ + Address: cloudflare.F("0.0.0.0"), + Enabled: cloudflare.F(true), + Header: cloudflare.F(load_balancers.PoolUpdateParamsOriginsHeader{ + Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + }), + Name: cloudflare.F("app-server-1"), + VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), + Weight: cloudflare.F(0.600000), + }, { + Address: cloudflare.F("0.0.0.0"), + Enabled: cloudflare.F(true), + Header: cloudflare.F(load_balancers.PoolUpdateParamsOriginsHeader{ + Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + }), + Name: cloudflare.F("app-server-1"), + VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), + Weight: cloudflare.F(0.600000), + }, { + Address: cloudflare.F("0.0.0.0"), + Enabled: cloudflare.F(true), + Header: cloudflare.F(load_balancers.PoolUpdateParamsOriginsHeader{ + Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + }), + Name: cloudflare.F("app-server-1"), + VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), + Weight: cloudflare.F(0.600000), + }}), + CheckRegions: cloudflare.F([]load_balancers.PoolUpdateParamsCheckRegion{load_balancers.PoolUpdateParamsCheckRegionWeu, load_balancers.PoolUpdateParamsCheckRegionEnam}), + Description: cloudflare.F("Primary data center - Provider XYZ"), + Enabled: cloudflare.F(false), + Latitude: cloudflare.F(0.000000), + LoadShedding: cloudflare.F(load_balancers.PoolUpdateParamsLoadShedding{ + DefaultPercent: cloudflare.F(0.000000), + DefaultPolicy: cloudflare.F(load_balancers.PoolUpdateParamsLoadSheddingDefaultPolicyRandom), + SessionPercent: cloudflare.F(0.000000), + SessionPolicy: cloudflare.F(load_balancers.PoolUpdateParamsLoadSheddingSessionPolicyHash), + }), + Longitude: cloudflare.F(0.000000), + MinimumOrigins: cloudflare.F(int64(0)), + Monitor: cloudflare.F[any](map[string]interface{}{}), + NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), + NotificationFilter: cloudflare.F(load_balancers.PoolUpdateParamsNotificationFilter{ + Origin: cloudflare.F(load_balancers.PoolUpdateParamsNotificationFilterOrigin{ + Disable: cloudflare.F(true), + Healthy: cloudflare.F(true), + }), + Pool: cloudflare.F(load_balancers.PoolUpdateParamsNotificationFilterPool{ + Disable: cloudflare.F(true), + Healthy: cloudflare.F(false), + }), + }), + OriginSteering: cloudflare.F(load_balancers.PoolUpdateParamsOriginSteering{ + Policy: cloudflare.F(load_balancers.PoolUpdateParamsOriginSteeringPolicyRandom), + }), + }, + ) + 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 TestPoolListWithOptionalParams(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("user@example.com"), + ) + _, err := client.LoadBalancers.Pools.List(context.TODO(), load_balancers.PoolListParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Monitor: cloudflare.F[any](map[string]interface{}{}), + }) + 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 TestPoolDelete(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("user@example.com"), + ) + _, err := client.LoadBalancers.Pools.Delete( + context.TODO(), + "17b5962d775c646f3f9725cbc7a53df4", + load_balancers.PoolDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestPoolEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.LoadBalancers.Pools.Edit( + context.TODO(), + "17b5962d775c646f3f9725cbc7a53df4", + load_balancers.PoolEditParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + CheckRegions: cloudflare.F([]load_balancers.PoolEditParamsCheckRegion{load_balancers.PoolEditParamsCheckRegionWeu, load_balancers.PoolEditParamsCheckRegionEnam}), + Description: cloudflare.F("Primary data center - Provider XYZ"), + Enabled: cloudflare.F(false), + Latitude: cloudflare.F(0.000000), + LoadShedding: cloudflare.F(load_balancers.PoolEditParamsLoadShedding{ + DefaultPercent: cloudflare.F(0.000000), + DefaultPolicy: cloudflare.F(load_balancers.PoolEditParamsLoadSheddingDefaultPolicyRandom), + SessionPercent: cloudflare.F(0.000000), + SessionPolicy: cloudflare.F(load_balancers.PoolEditParamsLoadSheddingSessionPolicyHash), + }), + Longitude: cloudflare.F(0.000000), + MinimumOrigins: cloudflare.F(int64(0)), + Monitor: cloudflare.F[any](map[string]interface{}{}), + Name: cloudflare.F("primary-dc-1"), + NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), + NotificationFilter: cloudflare.F(load_balancers.PoolEditParamsNotificationFilter{ + Origin: cloudflare.F(load_balancers.PoolEditParamsNotificationFilterOrigin{ + Disable: cloudflare.F(true), + Healthy: cloudflare.F(true), + }), + Pool: cloudflare.F(load_balancers.PoolEditParamsNotificationFilterPool{ + Disable: cloudflare.F(true), + Healthy: cloudflare.F(false), + }), + }), + OriginSteering: cloudflare.F(load_balancers.PoolEditParamsOriginSteering{ + Policy: cloudflare.F(load_balancers.PoolEditParamsOriginSteeringPolicyRandom), + }), + Origins: cloudflare.F([]load_balancers.PoolEditParamsOrigin{{ + Address: cloudflare.F("0.0.0.0"), + Enabled: cloudflare.F(true), + Header: cloudflare.F(load_balancers.PoolEditParamsOriginsHeader{ + Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + }), + Name: cloudflare.F("app-server-1"), + VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), + Weight: cloudflare.F(0.600000), + }, { + Address: cloudflare.F("0.0.0.0"), + Enabled: cloudflare.F(true), + Header: cloudflare.F(load_balancers.PoolEditParamsOriginsHeader{ + Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + }), + Name: cloudflare.F("app-server-1"), + VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), + Weight: cloudflare.F(0.600000), + }, { + Address: cloudflare.F("0.0.0.0"), + Enabled: cloudflare.F(true), + Header: cloudflare.F(load_balancers.PoolEditParamsOriginsHeader{ + Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + }), + Name: cloudflare.F("app-server-1"), + VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), + Weight: cloudflare.F(0.600000), + }}), + }, + ) + 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 TestPoolGet(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("user@example.com"), + ) + _, err := client.LoadBalancers.Pools.Get( + context.TODO(), + "17b5962d775c646f3f9725cbc7a53df4", + load_balancers.PoolGetParams{ + AccountID: cloudflare.F("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/load_balancers/poolhealth.go b/load_balancers/poolhealth.go new file mode 100644 index 00000000000..8d94ae95890 --- /dev/null +++ b/load_balancers/poolhealth.go @@ -0,0 +1,345 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// PoolHealthService 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 [NewPoolHealthService] method instead. +type PoolHealthService struct { + Options []option.RequestOption +} + +// NewPoolHealthService 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 NewPoolHealthService(opts ...option.RequestOption) (r *PoolHealthService) { + r = &PoolHealthService{} + r.Options = opts + return +} + +// Preview pool health using provided monitor details. The returned preview_id can +// be used in the preview endpoint to retrieve the results. +func (r *PoolHealthService) New(ctx context.Context, poolID string, params PoolHealthNewParams, opts ...option.RequestOption) (res *PoolHealthNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env PoolHealthNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s/preview", params.AccountID, poolID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch the latest pool health status for a single pool. +func (r *PoolHealthService) Get(ctx context.Context, poolID string, query PoolHealthGetParams, opts ...option.RequestOption) (res *PoolHealthGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env PoolHealthGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s/health", query.AccountID, poolID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type PoolHealthNewResponse struct { + // Monitored pool IDs mapped to their respective names. + Pools map[string]string `json:"pools"` + PreviewID string `json:"preview_id"` + JSON poolHealthNewResponseJSON `json:"-"` +} + +// poolHealthNewResponseJSON contains the JSON metadata for the struct +// [PoolHealthNewResponse] +type poolHealthNewResponseJSON struct { + Pools apijson.Field + PreviewID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolHealthNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolHealthNewResponseJSON) RawJSON() string { + return r.raw +} + +// A list of regions from which to run health checks. Null means every Cloudflare +// data center. +// +// Union satisfied by [load_balancers.PoolHealthGetResponseUnknown] or +// [shared.UnionString]. +type PoolHealthGetResponse interface { + ImplementsLoadBalancersPoolHealthGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*PoolHealthGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type PoolHealthNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The expected HTTP response code or code range of the health check. This + // parameter is only valid for HTTP and HTTPS monitors. + ExpectedCodes param.Field[string] `json:"expected_codes,required"` + // Do not validate the certificate when monitor use HTTPS. This parameter is + // currently only valid for HTTP and HTTPS monitors. + AllowInsecure param.Field[bool] `json:"allow_insecure"` + // To be marked unhealthy the monitored origin must fail this healthcheck N + // consecutive times. + ConsecutiveDown param.Field[int64] `json:"consecutive_down"` + // To be marked healthy the monitored origin must pass this healthcheck N + // consecutive times. + ConsecutiveUp param.Field[int64] `json:"consecutive_up"` + // Object description. + Description param.Field[string] `json:"description"` + // A case-insensitive sub-string to look for in the response body. If this string + // is not found, the origin will be marked as unhealthy. This parameter is only + // valid for HTTP and HTTPS monitors. + ExpectedBody param.Field[string] `json:"expected_body"` + // Follow redirects if returned by the origin. This parameter is only valid for + // HTTP and HTTPS monitors. + FollowRedirects param.Field[bool] `json:"follow_redirects"` + // The HTTP request headers to send in the health check. It is recommended you set + // a Host header by default. The User-Agent header cannot be overridden. This + // parameter is only valid for HTTP and HTTPS monitors. + Header param.Field[interface{}] `json:"header"` + // The interval between each health check. Shorter intervals may improve failover + // time, but will increase load on the origins as we check from multiple locations. + Interval param.Field[int64] `json:"interval"` + // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS + // based checks and 'connection_established' for TCP based health checks. + Method param.Field[string] `json:"method"` + // The endpoint path you want to conduct a health check against. This parameter is + // only valid for HTTP and HTTPS monitors. + Path param.Field[string] `json:"path"` + // The port number to connect to for the health check. Required for TCP, UDP, and + // SMTP checks. HTTP and HTTPS checks should only define the port when using a + // non-standard port (HTTP: default 80, HTTPS: default 443). + Port param.Field[int64] `json:"port"` + // Assign this monitor to emulate the specified zone while probing. This parameter + // is only valid for HTTP and HTTPS monitors. + ProbeZone param.Field[string] `json:"probe_zone"` + // The number of retries to attempt in case of a timeout before marking the origin + // as unhealthy. Retries are attempted immediately. + Retries param.Field[int64] `json:"retries"` + // The timeout (in seconds) before marking the health check as failed. + Timeout param.Field[int64] `json:"timeout"` + // The protocol to use for the health check. Currently supported protocols are + // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. + Type param.Field[PoolHealthNewParamsType] `json:"type"` +} + +func (r PoolHealthNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The protocol to use for the health check. Currently supported protocols are +// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. +type PoolHealthNewParamsType string + +const ( + PoolHealthNewParamsTypeHTTP PoolHealthNewParamsType = "http" + PoolHealthNewParamsTypeHTTPS PoolHealthNewParamsType = "https" + PoolHealthNewParamsTypeTcp PoolHealthNewParamsType = "tcp" + PoolHealthNewParamsTypeUdpIcmp PoolHealthNewParamsType = "udp_icmp" + PoolHealthNewParamsTypeIcmpPing PoolHealthNewParamsType = "icmp_ping" + PoolHealthNewParamsTypeSmtp PoolHealthNewParamsType = "smtp" +) + +type PoolHealthNewResponseEnvelope struct { + Errors []PoolHealthNewResponseEnvelopeErrors `json:"errors,required"` + Messages []PoolHealthNewResponseEnvelopeMessages `json:"messages,required"` + Result PoolHealthNewResponse `json:"result,required"` + // Whether the API call was successful + Success PoolHealthNewResponseEnvelopeSuccess `json:"success,required"` + JSON poolHealthNewResponseEnvelopeJSON `json:"-"` +} + +// poolHealthNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [PoolHealthNewResponseEnvelope] +type poolHealthNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolHealthNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolHealthNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PoolHealthNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON poolHealthNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// poolHealthNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [PoolHealthNewResponseEnvelopeErrors] +type poolHealthNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolHealthNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolHealthNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PoolHealthNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON poolHealthNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// poolHealthNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [PoolHealthNewResponseEnvelopeMessages] +type poolHealthNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolHealthNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolHealthNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PoolHealthNewResponseEnvelopeSuccess bool + +const ( + PoolHealthNewResponseEnvelopeSuccessTrue PoolHealthNewResponseEnvelopeSuccess = true +) + +type PoolHealthGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type PoolHealthGetResponseEnvelope struct { + Errors []PoolHealthGetResponseEnvelopeErrors `json:"errors,required"` + Messages []PoolHealthGetResponseEnvelopeMessages `json:"messages,required"` + // A list of regions from which to run health checks. Null means every Cloudflare + // data center. + Result PoolHealthGetResponse `json:"result,required"` + // Whether the API call was successful + Success PoolHealthGetResponseEnvelopeSuccess `json:"success,required"` + JSON poolHealthGetResponseEnvelopeJSON `json:"-"` +} + +// poolHealthGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [PoolHealthGetResponseEnvelope] +type poolHealthGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolHealthGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolHealthGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PoolHealthGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON poolHealthGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// poolHealthGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [PoolHealthGetResponseEnvelopeErrors] +type poolHealthGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolHealthGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolHealthGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PoolHealthGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON poolHealthGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// poolHealthGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [PoolHealthGetResponseEnvelopeMessages] +type poolHealthGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolHealthGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolHealthGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PoolHealthGetResponseEnvelopeSuccess bool + +const ( + PoolHealthGetResponseEnvelopeSuccessTrue PoolHealthGetResponseEnvelopeSuccess = true +) diff --git a/load_balancers/poolhealth_test.go b/load_balancers/poolhealth_test.go new file mode 100644 index 00000000000..430b18c2a80 --- /dev/null +++ b/load_balancers/poolhealth_test.go @@ -0,0 +1,98 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/load_balancers" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestPoolHealthNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.LoadBalancers.Pools.Health.New( + context.TODO(), + "17b5962d775c646f3f9725cbc7a53df4", + load_balancers.PoolHealthNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + ExpectedCodes: cloudflare.F("2xx"), + AllowInsecure: cloudflare.F(true), + ConsecutiveDown: cloudflare.F(int64(0)), + ConsecutiveUp: cloudflare.F(int64(0)), + Description: cloudflare.F("Login page monitor"), + ExpectedBody: cloudflare.F("alive"), + FollowRedirects: cloudflare.F(true), + Header: cloudflare.F[any](map[string]interface{}{ + "Host": map[string]interface{}{ + "0": "example.com", + }, + "X-App-ID": map[string]interface{}{ + "0": "abc123", + }, + }), + Interval: cloudflare.F(int64(0)), + Method: cloudflare.F("GET"), + Path: cloudflare.F("/health"), + Port: cloudflare.F(int64(0)), + ProbeZone: cloudflare.F("example.com"), + Retries: cloudflare.F(int64(0)), + Timeout: cloudflare.F(int64(0)), + Type: cloudflare.F(load_balancers.PoolHealthNewParamsTypeHTTPS), + }, + ) + 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 TestPoolHealthGet(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("user@example.com"), + ) + _, err := client.LoadBalancers.Pools.Health.Get( + context.TODO(), + "17b5962d775c646f3f9725cbc7a53df4", + load_balancers.PoolHealthGetParams{ + AccountID: cloudflare.F("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/load_balancers/poolreference.go b/load_balancers/poolreference.go new file mode 100644 index 00000000000..8b84ec78254 --- /dev/null +++ b/load_balancers/poolreference.go @@ -0,0 +1,200 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// PoolReferenceService 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 [NewPoolReferenceService] method +// instead. +type PoolReferenceService struct { + Options []option.RequestOption +} + +// NewPoolReferenceService 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 NewPoolReferenceService(opts ...option.RequestOption) (r *PoolReferenceService) { + r = &PoolReferenceService{} + r.Options = opts + return +} + +// Get the list of resources that reference the provided pool. +func (r *PoolReferenceService) Get(ctx context.Context, poolID string, query PoolReferenceGetParams, opts ...option.RequestOption) (res *[]PoolReferenceGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env PoolReferenceGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s/references", query.AccountID, poolID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type PoolReferenceGetResponse struct { + ReferenceType PoolReferenceGetResponseReferenceType `json:"reference_type"` + ResourceID string `json:"resource_id"` + ResourceName string `json:"resource_name"` + ResourceType string `json:"resource_type"` + JSON poolReferenceGetResponseJSON `json:"-"` +} + +// poolReferenceGetResponseJSON contains the JSON metadata for the struct +// [PoolReferenceGetResponse] +type poolReferenceGetResponseJSON struct { + ReferenceType apijson.Field + ResourceID apijson.Field + ResourceName apijson.Field + ResourceType apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolReferenceGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolReferenceGetResponseJSON) RawJSON() string { + return r.raw +} + +type PoolReferenceGetResponseReferenceType string + +const ( + PoolReferenceGetResponseReferenceTypeStar PoolReferenceGetResponseReferenceType = "*" + PoolReferenceGetResponseReferenceTypeReferral PoolReferenceGetResponseReferenceType = "referral" + PoolReferenceGetResponseReferenceTypeReferrer PoolReferenceGetResponseReferenceType = "referrer" +) + +type PoolReferenceGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type PoolReferenceGetResponseEnvelope struct { + Errors []PoolReferenceGetResponseEnvelopeErrors `json:"errors,required"` + Messages []PoolReferenceGetResponseEnvelopeMessages `json:"messages,required"` + // List of resources that reference a given pool. + Result []PoolReferenceGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success PoolReferenceGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo PoolReferenceGetResponseEnvelopeResultInfo `json:"result_info"` + JSON poolReferenceGetResponseEnvelopeJSON `json:"-"` +} + +// poolReferenceGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [PoolReferenceGetResponseEnvelope] +type poolReferenceGetResponseEnvelopeJSON 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 *PoolReferenceGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolReferenceGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PoolReferenceGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON poolReferenceGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// poolReferenceGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [PoolReferenceGetResponseEnvelopeErrors] +type poolReferenceGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolReferenceGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolReferenceGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PoolReferenceGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON poolReferenceGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// poolReferenceGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [PoolReferenceGetResponseEnvelopeMessages] +type poolReferenceGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolReferenceGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolReferenceGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PoolReferenceGetResponseEnvelopeSuccess bool + +const ( + PoolReferenceGetResponseEnvelopeSuccessTrue PoolReferenceGetResponseEnvelopeSuccess = true +) + +type PoolReferenceGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON poolReferenceGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// poolReferenceGetResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [PoolReferenceGetResponseEnvelopeResultInfo] +type poolReferenceGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PoolReferenceGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r poolReferenceGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/load_balancers/poolreference_test.go b/load_balancers/poolreference_test.go new file mode 100644 index 00000000000..c24ed0096eb --- /dev/null +++ b/load_balancers/poolreference_test.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/load_balancers" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestPoolReferenceGet(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("user@example.com"), + ) + _, err := client.LoadBalancers.Pools.References.Get( + context.TODO(), + "17b5962d775c646f3f9725cbc7a53df4", + load_balancers.PoolReferenceGetParams{ + AccountID: cloudflare.F("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/load_balancers/preview.go b/load_balancers/preview.go new file mode 100644 index 00000000000..a86f5c57785 --- /dev/null +++ b/load_balancers/preview.go @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/user" +) + +// PreviewService 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 [NewPreviewService] method instead. +type PreviewService struct { + Options []option.RequestOption +} + +// NewPreviewService 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 NewPreviewService(opts ...option.RequestOption) (r *PreviewService) { + r = &PreviewService{} + r.Options = opts + return +} + +// Get the result of a previous preview operation using the provided preview_id. +func (r *PreviewService) Get(ctx context.Context, previewID interface{}, query PreviewGetParams, opts ...option.RequestOption) (res *user.LoadBalancingPreviewResult, err error) { + opts = append(r.Options[:], opts...) + var env PreviewGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/preview/%v", query.AccountID, previewID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type PreviewGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type PreviewGetResponseEnvelope struct { + Errors []PreviewGetResponseEnvelopeErrors `json:"errors,required"` + Messages []PreviewGetResponseEnvelopeMessages `json:"messages,required"` + // Resulting health data from a preview operation. + Result user.LoadBalancingPreviewResult `json:"result,required"` + // Whether the API call was successful + Success PreviewGetResponseEnvelopeSuccess `json:"success,required"` + JSON previewGetResponseEnvelopeJSON `json:"-"` +} + +// previewGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [PreviewGetResponseEnvelope] +type previewGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PreviewGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r previewGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PreviewGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON previewGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// previewGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PreviewGetResponseEnvelopeErrors] +type previewGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PreviewGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r previewGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PreviewGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON previewGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// previewGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PreviewGetResponseEnvelopeMessages] +type previewGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PreviewGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r previewGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PreviewGetResponseEnvelopeSuccess bool + +const ( + PreviewGetResponseEnvelopeSuccessTrue PreviewGetResponseEnvelopeSuccess = true +) diff --git a/load_balancers/preview_test.go b/load_balancers/preview_test.go new file mode 100644 index 00000000000..37e10158728 --- /dev/null +++ b/load_balancers/preview_test.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/load_balancers" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestPreviewGet(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("user@example.com"), + ) + _, err := client.LoadBalancers.Previews.Get( + context.TODO(), + "p1aba936b94213e5b8dca0c0dbf1f9cc", + load_balancers.PreviewGetParams{ + AccountID: cloudflare.F("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/load_balancers/region.go b/load_balancers/region.go new file mode 100644 index 00000000000..9b99a3cc738 --- /dev/null +++ b/load_balancers/region.go @@ -0,0 +1,308 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// RegionService 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 [NewRegionService] method instead. +type RegionService struct { + Options []option.RequestOption +} + +// NewRegionService 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 NewRegionService(opts ...option.RequestOption) (r *RegionService) { + r = &RegionService{} + r.Options = opts + return +} + +// List all region mappings. +func (r *RegionService) List(ctx context.Context, params RegionListParams, opts ...option.RequestOption) (res *RegionListResponse, err error) { + opts = append(r.Options[:], opts...) + var env RegionListResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/regions", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a single region mapping. +func (r *RegionService) Get(ctx context.Context, regionID RegionGetParamsRegionID, query RegionGetParams, opts ...option.RequestOption) (res *RegionGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RegionGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/regions/%v", query.AccountID, regionID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [load_balancers.RegionListResponseUnknown] or +// [shared.UnionString]. +type RegionListResponse interface { + ImplementsLoadBalancersRegionListResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RegionListResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// A list of countries and subdivisions mapped to a region. +// +// Union satisfied by [load_balancers.RegionGetResponseUnknown] or +// [shared.UnionString]. +type RegionGetResponse interface { + ImplementsLoadBalancersRegionGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RegionGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type RegionListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Two-letter alpha-2 country code followed in ISO 3166-1. + CountryCodeA2 param.Field[string] `query:"country_code_a2"` + // Two-letter subdivision code followed in ISO 3166-2. + SubdivisionCode param.Field[string] `query:"subdivision_code"` + // Two-letter subdivision code followed in ISO 3166-2. + SubdivisionCodeA2 param.Field[string] `query:"subdivision_code_a2"` +} + +// URLQuery serializes [RegionListParams]'s query parameters as `url.Values`. +func (r RegionListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type RegionListResponseEnvelope struct { + Errors []RegionListResponseEnvelopeErrors `json:"errors,required"` + Messages []RegionListResponseEnvelopeMessages `json:"messages,required"` + Result RegionListResponse `json:"result,required"` + // Whether the API call was successful + Success RegionListResponseEnvelopeSuccess `json:"success,required"` + JSON regionListResponseEnvelopeJSON `json:"-"` +} + +// regionListResponseEnvelopeJSON contains the JSON metadata for the struct +// [RegionListResponseEnvelope] +type regionListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RegionListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r regionListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RegionListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON regionListResponseEnvelopeErrorsJSON `json:"-"` +} + +// regionListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RegionListResponseEnvelopeErrors] +type regionListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RegionListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r regionListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RegionListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON regionListResponseEnvelopeMessagesJSON `json:"-"` +} + +// regionListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RegionListResponseEnvelopeMessages] +type regionListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RegionListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r regionListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RegionListResponseEnvelopeSuccess bool + +const ( + RegionListResponseEnvelopeSuccessTrue RegionListResponseEnvelopeSuccess = true +) + +type RegionGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +// A list of Cloudflare regions. WNAM: Western North America, ENAM: Eastern North +// America, WEU: Western Europe, EEU: Eastern Europe, NSAM: Northern South America, +// SSAM: Southern South America, OC: Oceania, ME: Middle East, NAF: North Africa, +// SAF: South Africa, SAS: Southern Asia, SEAS: South East Asia, NEAS: North East +// Asia). +type RegionGetParamsRegionID string + +const ( + RegionGetParamsRegionIDWnam RegionGetParamsRegionID = "WNAM" + RegionGetParamsRegionIDEnam RegionGetParamsRegionID = "ENAM" + RegionGetParamsRegionIDWeu RegionGetParamsRegionID = "WEU" + RegionGetParamsRegionIDEeu RegionGetParamsRegionID = "EEU" + RegionGetParamsRegionIDNsam RegionGetParamsRegionID = "NSAM" + RegionGetParamsRegionIDSsam RegionGetParamsRegionID = "SSAM" + RegionGetParamsRegionIDOc RegionGetParamsRegionID = "OC" + RegionGetParamsRegionIDMe RegionGetParamsRegionID = "ME" + RegionGetParamsRegionIDNaf RegionGetParamsRegionID = "NAF" + RegionGetParamsRegionIDSaf RegionGetParamsRegionID = "SAF" + RegionGetParamsRegionIDSas RegionGetParamsRegionID = "SAS" + RegionGetParamsRegionIDSeas RegionGetParamsRegionID = "SEAS" + RegionGetParamsRegionIDNeas RegionGetParamsRegionID = "NEAS" +) + +type RegionGetResponseEnvelope struct { + Errors []RegionGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RegionGetResponseEnvelopeMessages `json:"messages,required"` + // A list of countries and subdivisions mapped to a region. + Result RegionGetResponse `json:"result,required"` + // Whether the API call was successful + Success RegionGetResponseEnvelopeSuccess `json:"success,required"` + JSON regionGetResponseEnvelopeJSON `json:"-"` +} + +// regionGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RegionGetResponseEnvelope] +type regionGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RegionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r regionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RegionGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON regionGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// regionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RegionGetResponseEnvelopeErrors] +type regionGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RegionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r regionGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RegionGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON regionGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// regionGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RegionGetResponseEnvelopeMessages] +type regionGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RegionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r regionGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RegionGetResponseEnvelopeSuccess bool + +const ( + RegionGetResponseEnvelopeSuccessTrue RegionGetResponseEnvelopeSuccess = true +) diff --git a/load_balancers/region_test.go b/load_balancers/region_test.go new file mode 100644 index 00000000000..c1ad0cc7f2c --- /dev/null +++ b/load_balancers/region_test.go @@ -0,0 +1,74 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/load_balancers" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRegionListWithOptionalParams(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("user@example.com"), + ) + _, err := client.LoadBalancers.Regions.List(context.TODO(), load_balancers.RegionListParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + CountryCodeA2: cloudflare.F("US"), + SubdivisionCode: cloudflare.F("CA"), + SubdivisionCodeA2: cloudflare.F("CA"), + }) + 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 TestRegionGet(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("user@example.com"), + ) + _, err := client.LoadBalancers.Regions.Get( + context.TODO(), + load_balancers.RegionGetParamsRegionIDWnam, + load_balancers.RegionGetParams{ + AccountID: cloudflare.F("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/load_balancers/search.go b/load_balancers/search.go new file mode 100644 index 00000000000..452aa1d0126 --- /dev/null +++ b/load_balancers/search.go @@ -0,0 +1,204 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SearchService 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 [NewSearchService] method instead. +type SearchService struct { + Options []option.RequestOption +} + +// NewSearchService 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 NewSearchService(opts ...option.RequestOption) (r *SearchService) { + r = &SearchService{} + r.Options = opts + return +} + +// Search for Load Balancing resources. +func (r *SearchService) Get(ctx context.Context, params SearchGetParams, opts ...option.RequestOption) (res *[]SearchGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env SearchGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/load_balancers/search", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type SearchGetResponse = interface{} + +type SearchGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Page param.Field[interface{}] `query:"page"` + PerPage param.Field[interface{}] `query:"per_page"` + SearchParams param.Field[SearchGetParamsSearchParams] `query:"search_params"` +} + +// URLQuery serializes [SearchGetParams]'s query parameters as `url.Values`. +func (r SearchGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type SearchGetParamsSearchParams struct { + // Search query term. + Query param.Field[string] `query:"query"` + // The type of references to include ("\*" for all). + References param.Field[SearchGetParamsSearchParamsReferences] `query:"references"` +} + +// URLQuery serializes [SearchGetParamsSearchParams]'s query parameters as +// `url.Values`. +func (r SearchGetParamsSearchParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// The type of references to include ("\*" for all). +type SearchGetParamsSearchParamsReferences string + +const ( + SearchGetParamsSearchParamsReferencesEmpty SearchGetParamsSearchParamsReferences = "" + SearchGetParamsSearchParamsReferencesStar SearchGetParamsSearchParamsReferences = "*" + SearchGetParamsSearchParamsReferencesReferral SearchGetParamsSearchParamsReferences = "referral" + SearchGetParamsSearchParamsReferencesReferrer SearchGetParamsSearchParamsReferences = "referrer" +) + +type SearchGetResponseEnvelope struct { + Errors []SearchGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SearchGetResponseEnvelopeMessages `json:"messages,required"` + Result []SearchGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success SearchGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo SearchGetResponseEnvelopeResultInfo `json:"result_info"` + JSON searchGetResponseEnvelopeJSON `json:"-"` +} + +// searchGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SearchGetResponseEnvelope] +type searchGetResponseEnvelopeJSON 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 *SearchGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r searchGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SearchGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON searchGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// searchGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [SearchGetResponseEnvelopeErrors] +type searchGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SearchGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r searchGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SearchGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON searchGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// searchGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [SearchGetResponseEnvelopeMessages] +type searchGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SearchGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r searchGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SearchGetResponseEnvelopeSuccess bool + +const ( + SearchGetResponseEnvelopeSuccessTrue SearchGetResponseEnvelopeSuccess = true +) + +type SearchGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON searchGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// searchGetResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [SearchGetResponseEnvelopeResultInfo] +type searchGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SearchGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r searchGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/load_balancers/search_test.go b/load_balancers/search_test.go new file mode 100644 index 00000000000..3e139c9dbe6 --- /dev/null +++ b/load_balancers/search_test.go @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package load_balancers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/load_balancers" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestSearchGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.LoadBalancers.Searches.Get(context.TODO(), load_balancers.SearchGetParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Page: cloudflare.F[any](map[string]interface{}{}), + PerPage: cloudflare.F[any](map[string]interface{}{}), + SearchParams: cloudflare.F(load_balancers.SearchGetParamsSearchParams{ + Query: cloudflare.F("primary"), + References: cloudflare.F(load_balancers.SearchGetParamsSearchParamsReferencesStar), + }), + }) + 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/loadbalancer.go b/loadbalancer.go deleted file mode 100644 index 36f99ccedb3..00000000000 --- a/loadbalancer.go +++ /dev/null @@ -1,4075 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// LoadBalancerService 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 [NewLoadBalancerService] method -// instead. -type LoadBalancerService struct { - Options []option.RequestOption - Monitors *LoadBalancerMonitorService - Pools *LoadBalancerPoolService - Previews *LoadBalancerPreviewService - Regions *LoadBalancerRegionService - Searches *LoadBalancerSearchService -} - -// NewLoadBalancerService 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 NewLoadBalancerService(opts ...option.RequestOption) (r *LoadBalancerService) { - r = &LoadBalancerService{} - r.Options = opts - r.Monitors = NewLoadBalancerMonitorService(opts...) - r.Pools = NewLoadBalancerPoolService(opts...) - r.Previews = NewLoadBalancerPreviewService(opts...) - r.Regions = NewLoadBalancerRegionService(opts...) - r.Searches = NewLoadBalancerSearchService(opts...) - return -} - -// Create a new load balancer. -func (r *LoadBalancerService) New(ctx context.Context, params LoadBalancerNewParams, opts ...option.RequestOption) (res *LoadBalancer, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerNewResponseEnvelope - path := fmt.Sprintf("zones/%s/load_balancers", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update a configured load balancer. -func (r *LoadBalancerService) Update(ctx context.Context, loadBalancerID string, params LoadBalancerUpdateParams, opts ...option.RequestOption) (res *LoadBalancer, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/load_balancers/%s", params.ZoneID, loadBalancerID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List configured load balancers. -func (r *LoadBalancerService) List(ctx context.Context, query LoadBalancerListParams, opts ...option.RequestOption) (res *[]LoadBalancer, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerListResponseEnvelope - path := fmt.Sprintf("zones/%s/load_balancers", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a configured load balancer. -func (r *LoadBalancerService) Delete(ctx context.Context, loadBalancerID string, body LoadBalancerDeleteParams, opts ...option.RequestOption) (res *LoadBalancerDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/load_balancers/%s", body.ZoneID, loadBalancerID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Apply changes to an existing load balancer, overwriting the supplied properties. -func (r *LoadBalancerService) Edit(ctx context.Context, loadBalancerID string, params LoadBalancerEditParams, opts ...option.RequestOption) (res *LoadBalancer, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerEditResponseEnvelope - path := fmt.Sprintf("zones/%s/load_balancers/%s", params.ZoneID, loadBalancerID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch a single configured load balancer. -func (r *LoadBalancerService) Get(ctx context.Context, loadBalancerID string, query LoadBalancerGetParams, opts ...option.RequestOption) (res *LoadBalancer, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerGetResponseEnvelope - path := fmt.Sprintf("zones/%s/load_balancers/%s", query.ZoneID, loadBalancerID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LoadBalancer struct { - ID string `json:"id"` - // Controls features that modify the routing of requests to pools and origins in - // response to dynamic conditions, such as during the interval between active - // health monitoring requests. For example, zero-downtime failover occurs - // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 - // response codes. If there is another healthy origin in the same pool, the request - // is retried once against this alternate origin. - AdaptiveRouting LoadBalancerAdaptiveRouting `json:"adaptive_routing"` - // A mapping of country codes to a list of pool IDs (ordered by their failover - // priority) for the given country. Any country not explicitly defined will fall - // back to using the corresponding region_pool mapping if it exists else to - // default_pools. - CountryPools interface{} `json:"country_pools"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A list of pool IDs ordered by their failover priority. Pools defined here are - // used by default, or when region_pools are not configured for a given region. - DefaultPools []string `json:"default_pools"` - // Object description. - Description string `json:"description"` - // Whether to enable (the default) this load balancer. - Enabled bool `json:"enabled"` - // The pool ID to use when all other pools are detected as unhealthy. - FallbackPool interface{} `json:"fallback_pool"` - // Controls location-based steering for non-proxied requests. See `steering_policy` - // to learn how steering is affected. - LocationStrategy LoadBalancerLocationStrategy `json:"location_strategy"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The DNS hostname to associate with your Load Balancer. If this hostname already - // exists as a DNS record in Cloudflare's DNS, the Load Balancer will take - // precedence and the DNS record will not be used. - Name string `json:"name"` - // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs - // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not - // explicitly defined will fall back to using the corresponding country_pool, then - // region_pool mapping if it exists else to default_pools. - PopPools interface{} `json:"pop_pools"` - // Whether the hostname should be gray clouded (false) or orange clouded (true). - Proxied bool `json:"proxied"` - // Configures pool weights. - // - // - `steering_policy="random"`: A random pool is selected with probability - // proportional to pool weights. - // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each - // pool's outstanding requests. - // - `steering_policy="least_connections"`: Use pool weights to scale each pool's - // open connections. - RandomSteering LoadBalancerRandomSteering `json:"random_steering"` - // A mapping of region codes to a list of pool IDs (ordered by their failover - // priority) for the given region. Any regions not explicitly defined will fall - // back to using default_pools. - RegionPools interface{} `json:"region_pools"` - // BETA Field Not General Access: A list of rules for this load balancer to - // execute. - Rules []LoadBalancerRule `json:"rules"` - // Specifies the type of session affinity the load balancer should use unless - // specified as `"none"` or "" (default). The supported types are: - // - // - `"cookie"`: On the first request to a proxied load balancer, a cookie is - // generated, encoding information of which origin the request will be forwarded - // to. Subsequent requests, by the same client to the same load balancer, will be - // sent to the origin server the cookie encodes, for the duration of the cookie - // and as long as the origin server remains healthy. If the cookie has expired or - // the origin server is unhealthy, then a new origin server is calculated and - // used. - // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin - // selection is stable and based on the client's ip address. - // - `"header"`: On the first request to a proxied load balancer, a session key - // based on the configured HTTP headers (see - // `session_affinity_attributes.headers`) is generated, encoding the request - // headers used for storing in the load balancer session state which origin the - // request will be forwarded to. Subsequent requests to the load balancer with - // the same headers will be sent to the same origin server, for the duration of - // the session and as long as the origin server remains healthy. If the session - // has been idle for the duration of `session_affinity_ttl` seconds or the origin - // server is unhealthy, then a new origin server is calculated and used. See - // `headers` in `session_affinity_attributes` for additional required - // configuration. - SessionAffinity LoadBalancerSessionAffinity `json:"session_affinity"` - // Configures attributes for session affinity. - SessionAffinityAttributes LoadBalancerSessionAffinityAttributes `json:"session_affinity_attributes"` - // Time, in seconds, until a client's session expires after being created. Once the - // expiry time has been reached, subsequent requests may get sent to a different - // origin server. The accepted ranges per `session_affinity` policy are: - // - // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used - // unless explicitly set. The accepted range of values is between [1800, 604800]. - // - `"header"`: The current default of 1800 seconds will be used unless explicitly - // set. The accepted range of values is between [30, 3600]. Note: With session - // affinity by header, sessions only expire after they haven't been used for the - // number of seconds specified. - SessionAffinityTTL float64 `json:"session_affinity_ttl"` - // Steering Policy for this load balancer. - // - // - `"off"`: Use `default_pools`. - // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied - // requests, the country for `country_pools` is determined by - // `location_strategy`. - // - `"random"`: Select a pool randomly. - // - `"dynamic_latency"`: Use round trip time to select the closest pool in - // default_pools (requires pool health checks). - // - `"proximity"`: Use the pools' latitude and longitude to select the closest - // pool using the Cloudflare PoP location for proxied requests or the location - // determined by `location_strategy` for non-proxied requests. - // - `"least_outstanding_requests"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of outstanding - // requests. Pools with more pending requests are weighted proportionately less - // relative to others. - // - `"least_connections"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of open connections. - // Pools with more open connections are weighted proportionately less relative to - // others. Supported for HTTP/1 and HTTP/2 connections. - // - `""`: Will map to `"geo"` if you use - // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. - SteeringPolicy LoadBalancerSteeringPolicy `json:"steering_policy"` - // Time to live (TTL) of the DNS entry for the IP address returned by this load - // balancer. This only applies to gray-clouded (unproxied) load balancers. - TTL float64 `json:"ttl"` - JSON loadBalancerJSON `json:"-"` -} - -// loadBalancerJSON contains the JSON metadata for the struct [LoadBalancer] -type loadBalancerJSON struct { - ID apijson.Field - AdaptiveRouting apijson.Field - CountryPools apijson.Field - CreatedOn apijson.Field - DefaultPools apijson.Field - Description apijson.Field - Enabled apijson.Field - FallbackPool apijson.Field - LocationStrategy apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - PopPools apijson.Field - Proxied apijson.Field - RandomSteering apijson.Field - RegionPools apijson.Field - Rules apijson.Field - SessionAffinity apijson.Field - SessionAffinityAttributes apijson.Field - SessionAffinityTTL apijson.Field - SteeringPolicy apijson.Field - TTL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerJSON) RawJSON() string { - return r.raw -} - -// Controls features that modify the routing of requests to pools and origins in -// response to dynamic conditions, such as during the interval between active -// health monitoring requests. For example, zero-downtime failover occurs -// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 -// response codes. If there is another healthy origin in the same pool, the request -// is retried once against this alternate origin. -type LoadBalancerAdaptiveRouting struct { - // Extends zero-downtime failover of requests to healthy origins from alternate - // pools, when no healthy alternate exists in the same pool, according to the - // failover order defined by traffic and origin steering. When set false (the - // default) zero-downtime failover will only occur between origins within the same - // pool. See `session_affinity_attributes` for control over when sessions are - // broken or reassigned. - FailoverAcrossPools bool `json:"failover_across_pools"` - JSON loadBalancerAdaptiveRoutingJSON `json:"-"` -} - -// loadBalancerAdaptiveRoutingJSON contains the JSON metadata for the struct -// [LoadBalancerAdaptiveRouting] -type loadBalancerAdaptiveRoutingJSON struct { - FailoverAcrossPools apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerAdaptiveRouting) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerAdaptiveRoutingJSON) RawJSON() string { - return r.raw -} - -// Controls location-based steering for non-proxied requests. See `steering_policy` -// to learn how steering is affected. -type LoadBalancerLocationStrategy struct { - // Determines the authoritative location when ECS is not preferred, does not exist - // in the request, or its GeoIP lookup is unsuccessful. - // - // - `"pop"`: Use the Cloudflare PoP location. - // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is - // unsuccessful, use the Cloudflare PoP location. - Mode LoadBalancerLocationStrategyMode `json:"mode"` - // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the - // authoritative location. - // - // - `"always"`: Always prefer ECS. - // - `"never"`: Never prefer ECS. - // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. - // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. - PreferEcs LoadBalancerLocationStrategyPreferEcs `json:"prefer_ecs"` - JSON loadBalancerLocationStrategyJSON `json:"-"` -} - -// loadBalancerLocationStrategyJSON contains the JSON metadata for the struct -// [LoadBalancerLocationStrategy] -type loadBalancerLocationStrategyJSON struct { - Mode apijson.Field - PreferEcs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerLocationStrategy) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerLocationStrategyJSON) RawJSON() string { - return r.raw -} - -// Determines the authoritative location when ECS is not preferred, does not exist -// in the request, or its GeoIP lookup is unsuccessful. -// -// - `"pop"`: Use the Cloudflare PoP location. -// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is -// unsuccessful, use the Cloudflare PoP location. -type LoadBalancerLocationStrategyMode string - -const ( - LoadBalancerLocationStrategyModePop LoadBalancerLocationStrategyMode = "pop" - LoadBalancerLocationStrategyModeResolverIP LoadBalancerLocationStrategyMode = "resolver_ip" -) - -// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the -// authoritative location. -// -// - `"always"`: Always prefer ECS. -// - `"never"`: Never prefer ECS. -// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. -// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. -type LoadBalancerLocationStrategyPreferEcs string - -const ( - LoadBalancerLocationStrategyPreferEcsAlways LoadBalancerLocationStrategyPreferEcs = "always" - LoadBalancerLocationStrategyPreferEcsNever LoadBalancerLocationStrategyPreferEcs = "never" - LoadBalancerLocationStrategyPreferEcsProximity LoadBalancerLocationStrategyPreferEcs = "proximity" - LoadBalancerLocationStrategyPreferEcsGeo LoadBalancerLocationStrategyPreferEcs = "geo" -) - -// Configures pool weights. -// -// - `steering_policy="random"`: A random pool is selected with probability -// proportional to pool weights. -// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each -// pool's outstanding requests. -// - `steering_policy="least_connections"`: Use pool weights to scale each pool's -// open connections. -type LoadBalancerRandomSteering struct { - // The default weight for pools in the load balancer that are not specified in the - // pool_weights map. - DefaultWeight float64 `json:"default_weight"` - // A mapping of pool IDs to custom weights. The weight is relative to other pools - // in the load balancer. - PoolWeights interface{} `json:"pool_weights"` - JSON loadBalancerRandomSteeringJSON `json:"-"` -} - -// loadBalancerRandomSteeringJSON contains the JSON metadata for the struct -// [LoadBalancerRandomSteering] -type loadBalancerRandomSteeringJSON struct { - DefaultWeight apijson.Field - PoolWeights apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerRandomSteering) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerRandomSteeringJSON) RawJSON() string { - return r.raw -} - -// A rule object containing conditions and overrides for this load balancer to -// evaluate. -type LoadBalancerRule struct { - // The condition expressions to evaluate. If the condition evaluates to true, the - // overrides or fixed_response in this rule will be applied. An empty condition is - // always true. For more details on condition expressions, please see - // https://developers.cloudflare.com/load-balancing/understand-basics/load-balancing-rules/expressions. - Condition string `json:"condition"` - // Disable this specific rule. It will no longer be evaluated by this load - // balancer. - Disabled bool `json:"disabled"` - // A collection of fields used to directly respond to the eyeball instead of - // routing to a pool. If a fixed_response is supplied the rule will be marked as - // terminates. - FixedResponse LoadBalancerRulesFixedResponse `json:"fixed_response"` - // Name of this rule. Only used for human readability. - Name string `json:"name"` - // A collection of overrides to apply to the load balancer when this rule's - // condition is true. All fields are optional. - Overrides LoadBalancerRulesOverrides `json:"overrides"` - // The order in which rules should be executed in relation to each other. Lower - // values are executed first. Values do not need to be sequential. If no value is - // provided for any rule the array order of the rules field will be used to assign - // a priority. - Priority int64 `json:"priority"` - // If this rule's condition is true, this causes rule evaluation to stop after - // processing this rule. - Terminates bool `json:"terminates"` - JSON loadBalancerRuleJSON `json:"-"` -} - -// loadBalancerRuleJSON contains the JSON metadata for the struct -// [LoadBalancerRule] -type loadBalancerRuleJSON struct { - Condition apijson.Field - Disabled apijson.Field - FixedResponse apijson.Field - Name apijson.Field - Overrides apijson.Field - Priority apijson.Field - Terminates apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerRuleJSON) RawJSON() string { - return r.raw -} - -// A collection of fields used to directly respond to the eyeball instead of -// routing to a pool. If a fixed_response is supplied the rule will be marked as -// terminates. -type LoadBalancerRulesFixedResponse struct { - // The http 'Content-Type' header to include in the response. - ContentType string `json:"content_type"` - // The http 'Location' header to include in the response. - Location string `json:"location"` - // Text to include as the http body. - MessageBody string `json:"message_body"` - // The http status code to respond with. - StatusCode int64 `json:"status_code"` - JSON loadBalancerRulesFixedResponseJSON `json:"-"` -} - -// loadBalancerRulesFixedResponseJSON contains the JSON metadata for the struct -// [LoadBalancerRulesFixedResponse] -type loadBalancerRulesFixedResponseJSON struct { - ContentType apijson.Field - Location apijson.Field - MessageBody apijson.Field - StatusCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerRulesFixedResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerRulesFixedResponseJSON) RawJSON() string { - return r.raw -} - -// A collection of overrides to apply to the load balancer when this rule's -// condition is true. All fields are optional. -type LoadBalancerRulesOverrides struct { - // Controls features that modify the routing of requests to pools and origins in - // response to dynamic conditions, such as during the interval between active - // health monitoring requests. For example, zero-downtime failover occurs - // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 - // response codes. If there is another healthy origin in the same pool, the request - // is retried once against this alternate origin. - AdaptiveRouting LoadBalancerRulesOverridesAdaptiveRouting `json:"adaptive_routing"` - // A mapping of country codes to a list of pool IDs (ordered by their failover - // priority) for the given country. Any country not explicitly defined will fall - // back to using the corresponding region_pool mapping if it exists else to - // default_pools. - CountryPools interface{} `json:"country_pools"` - // A list of pool IDs ordered by their failover priority. Pools defined here are - // used by default, or when region_pools are not configured for a given region. - DefaultPools []string `json:"default_pools"` - // The pool ID to use when all other pools are detected as unhealthy. - FallbackPool interface{} `json:"fallback_pool"` - // Controls location-based steering for non-proxied requests. See `steering_policy` - // to learn how steering is affected. - LocationStrategy LoadBalancerRulesOverridesLocationStrategy `json:"location_strategy"` - // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs - // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not - // explicitly defined will fall back to using the corresponding country_pool, then - // region_pool mapping if it exists else to default_pools. - PopPools interface{} `json:"pop_pools"` - // Configures pool weights. - // - // - `steering_policy="random"`: A random pool is selected with probability - // proportional to pool weights. - // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each - // pool's outstanding requests. - // - `steering_policy="least_connections"`: Use pool weights to scale each pool's - // open connections. - RandomSteering LoadBalancerRulesOverridesRandomSteering `json:"random_steering"` - // A mapping of region codes to a list of pool IDs (ordered by their failover - // priority) for the given region. Any regions not explicitly defined will fall - // back to using default_pools. - RegionPools interface{} `json:"region_pools"` - // Specifies the type of session affinity the load balancer should use unless - // specified as `"none"` or "" (default). The supported types are: - // - // - `"cookie"`: On the first request to a proxied load balancer, a cookie is - // generated, encoding information of which origin the request will be forwarded - // to. Subsequent requests, by the same client to the same load balancer, will be - // sent to the origin server the cookie encodes, for the duration of the cookie - // and as long as the origin server remains healthy. If the cookie has expired or - // the origin server is unhealthy, then a new origin server is calculated and - // used. - // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin - // selection is stable and based on the client's ip address. - // - `"header"`: On the first request to a proxied load balancer, a session key - // based on the configured HTTP headers (see - // `session_affinity_attributes.headers`) is generated, encoding the request - // headers used for storing in the load balancer session state which origin the - // request will be forwarded to. Subsequent requests to the load balancer with - // the same headers will be sent to the same origin server, for the duration of - // the session and as long as the origin server remains healthy. If the session - // has been idle for the duration of `session_affinity_ttl` seconds or the origin - // server is unhealthy, then a new origin server is calculated and used. See - // `headers` in `session_affinity_attributes` for additional required - // configuration. - SessionAffinity LoadBalancerRulesOverridesSessionAffinity `json:"session_affinity"` - // Configures attributes for session affinity. - SessionAffinityAttributes LoadBalancerRulesOverridesSessionAffinityAttributes `json:"session_affinity_attributes"` - // Time, in seconds, until a client's session expires after being created. Once the - // expiry time has been reached, subsequent requests may get sent to a different - // origin server. The accepted ranges per `session_affinity` policy are: - // - // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used - // unless explicitly set. The accepted range of values is between [1800, 604800]. - // - `"header"`: The current default of 1800 seconds will be used unless explicitly - // set. The accepted range of values is between [30, 3600]. Note: With session - // affinity by header, sessions only expire after they haven't been used for the - // number of seconds specified. - SessionAffinityTTL float64 `json:"session_affinity_ttl"` - // Steering Policy for this load balancer. - // - // - `"off"`: Use `default_pools`. - // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied - // requests, the country for `country_pools` is determined by - // `location_strategy`. - // - `"random"`: Select a pool randomly. - // - `"dynamic_latency"`: Use round trip time to select the closest pool in - // default_pools (requires pool health checks). - // - `"proximity"`: Use the pools' latitude and longitude to select the closest - // pool using the Cloudflare PoP location for proxied requests or the location - // determined by `location_strategy` for non-proxied requests. - // - `"least_outstanding_requests"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of outstanding - // requests. Pools with more pending requests are weighted proportionately less - // relative to others. - // - `"least_connections"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of open connections. - // Pools with more open connections are weighted proportionately less relative to - // others. Supported for HTTP/1 and HTTP/2 connections. - // - `""`: Will map to `"geo"` if you use - // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. - SteeringPolicy LoadBalancerRulesOverridesSteeringPolicy `json:"steering_policy"` - // Time to live (TTL) of the DNS entry for the IP address returned by this load - // balancer. This only applies to gray-clouded (unproxied) load balancers. - TTL float64 `json:"ttl"` - JSON loadBalancerRulesOverridesJSON `json:"-"` -} - -// loadBalancerRulesOverridesJSON contains the JSON metadata for the struct -// [LoadBalancerRulesOverrides] -type loadBalancerRulesOverridesJSON struct { - AdaptiveRouting apijson.Field - CountryPools apijson.Field - DefaultPools apijson.Field - FallbackPool apijson.Field - LocationStrategy apijson.Field - PopPools apijson.Field - RandomSteering apijson.Field - RegionPools apijson.Field - SessionAffinity apijson.Field - SessionAffinityAttributes apijson.Field - SessionAffinityTTL apijson.Field - SteeringPolicy apijson.Field - TTL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerRulesOverrides) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerRulesOverridesJSON) RawJSON() string { - return r.raw -} - -// Controls features that modify the routing of requests to pools and origins in -// response to dynamic conditions, such as during the interval between active -// health monitoring requests. For example, zero-downtime failover occurs -// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 -// response codes. If there is another healthy origin in the same pool, the request -// is retried once against this alternate origin. -type LoadBalancerRulesOverridesAdaptiveRouting struct { - // Extends zero-downtime failover of requests to healthy origins from alternate - // pools, when no healthy alternate exists in the same pool, according to the - // failover order defined by traffic and origin steering. When set false (the - // default) zero-downtime failover will only occur between origins within the same - // pool. See `session_affinity_attributes` for control over when sessions are - // broken or reassigned. - FailoverAcrossPools bool `json:"failover_across_pools"` - JSON loadBalancerRulesOverridesAdaptiveRoutingJSON `json:"-"` -} - -// loadBalancerRulesOverridesAdaptiveRoutingJSON contains the JSON metadata for the -// struct [LoadBalancerRulesOverridesAdaptiveRouting] -type loadBalancerRulesOverridesAdaptiveRoutingJSON struct { - FailoverAcrossPools apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerRulesOverridesAdaptiveRouting) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerRulesOverridesAdaptiveRoutingJSON) RawJSON() string { - return r.raw -} - -// Controls location-based steering for non-proxied requests. See `steering_policy` -// to learn how steering is affected. -type LoadBalancerRulesOverridesLocationStrategy struct { - // Determines the authoritative location when ECS is not preferred, does not exist - // in the request, or its GeoIP lookup is unsuccessful. - // - // - `"pop"`: Use the Cloudflare PoP location. - // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is - // unsuccessful, use the Cloudflare PoP location. - Mode LoadBalancerRulesOverridesLocationStrategyMode `json:"mode"` - // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the - // authoritative location. - // - // - `"always"`: Always prefer ECS. - // - `"never"`: Never prefer ECS. - // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. - // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. - PreferEcs LoadBalancerRulesOverridesLocationStrategyPreferEcs `json:"prefer_ecs"` - JSON loadBalancerRulesOverridesLocationStrategyJSON `json:"-"` -} - -// loadBalancerRulesOverridesLocationStrategyJSON contains the JSON metadata for -// the struct [LoadBalancerRulesOverridesLocationStrategy] -type loadBalancerRulesOverridesLocationStrategyJSON struct { - Mode apijson.Field - PreferEcs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerRulesOverridesLocationStrategy) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerRulesOverridesLocationStrategyJSON) RawJSON() string { - return r.raw -} - -// Determines the authoritative location when ECS is not preferred, does not exist -// in the request, or its GeoIP lookup is unsuccessful. -// -// - `"pop"`: Use the Cloudflare PoP location. -// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is -// unsuccessful, use the Cloudflare PoP location. -type LoadBalancerRulesOverridesLocationStrategyMode string - -const ( - LoadBalancerRulesOverridesLocationStrategyModePop LoadBalancerRulesOverridesLocationStrategyMode = "pop" - LoadBalancerRulesOverridesLocationStrategyModeResolverIP LoadBalancerRulesOverridesLocationStrategyMode = "resolver_ip" -) - -// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the -// authoritative location. -// -// - `"always"`: Always prefer ECS. -// - `"never"`: Never prefer ECS. -// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. -// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. -type LoadBalancerRulesOverridesLocationStrategyPreferEcs string - -const ( - LoadBalancerRulesOverridesLocationStrategyPreferEcsAlways LoadBalancerRulesOverridesLocationStrategyPreferEcs = "always" - LoadBalancerRulesOverridesLocationStrategyPreferEcsNever LoadBalancerRulesOverridesLocationStrategyPreferEcs = "never" - LoadBalancerRulesOverridesLocationStrategyPreferEcsProximity LoadBalancerRulesOverridesLocationStrategyPreferEcs = "proximity" - LoadBalancerRulesOverridesLocationStrategyPreferEcsGeo LoadBalancerRulesOverridesLocationStrategyPreferEcs = "geo" -) - -// Configures pool weights. -// -// - `steering_policy="random"`: A random pool is selected with probability -// proportional to pool weights. -// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each -// pool's outstanding requests. -// - `steering_policy="least_connections"`: Use pool weights to scale each pool's -// open connections. -type LoadBalancerRulesOverridesRandomSteering struct { - // The default weight for pools in the load balancer that are not specified in the - // pool_weights map. - DefaultWeight float64 `json:"default_weight"` - // A mapping of pool IDs to custom weights. The weight is relative to other pools - // in the load balancer. - PoolWeights interface{} `json:"pool_weights"` - JSON loadBalancerRulesOverridesRandomSteeringJSON `json:"-"` -} - -// loadBalancerRulesOverridesRandomSteeringJSON contains the JSON metadata for the -// struct [LoadBalancerRulesOverridesRandomSteering] -type loadBalancerRulesOverridesRandomSteeringJSON struct { - DefaultWeight apijson.Field - PoolWeights apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerRulesOverridesRandomSteering) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerRulesOverridesRandomSteeringJSON) RawJSON() string { - return r.raw -} - -// Specifies the type of session affinity the load balancer should use unless -// specified as `"none"` or "" (default). The supported types are: -// -// - `"cookie"`: On the first request to a proxied load balancer, a cookie is -// generated, encoding information of which origin the request will be forwarded -// to. Subsequent requests, by the same client to the same load balancer, will be -// sent to the origin server the cookie encodes, for the duration of the cookie -// and as long as the origin server remains healthy. If the cookie has expired or -// the origin server is unhealthy, then a new origin server is calculated and -// used. -// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin -// selection is stable and based on the client's ip address. -// - `"header"`: On the first request to a proxied load balancer, a session key -// based on the configured HTTP headers (see -// `session_affinity_attributes.headers`) is generated, encoding the request -// headers used for storing in the load balancer session state which origin the -// request will be forwarded to. Subsequent requests to the load balancer with -// the same headers will be sent to the same origin server, for the duration of -// the session and as long as the origin server remains healthy. If the session -// has been idle for the duration of `session_affinity_ttl` seconds or the origin -// server is unhealthy, then a new origin server is calculated and used. See -// `headers` in `session_affinity_attributes` for additional required -// configuration. -type LoadBalancerRulesOverridesSessionAffinity string - -const ( - LoadBalancerRulesOverridesSessionAffinityNone LoadBalancerRulesOverridesSessionAffinity = "none" - LoadBalancerRulesOverridesSessionAffinityCookie LoadBalancerRulesOverridesSessionAffinity = "cookie" - LoadBalancerRulesOverridesSessionAffinityIPCookie LoadBalancerRulesOverridesSessionAffinity = "ip_cookie" - LoadBalancerRulesOverridesSessionAffinityHeader LoadBalancerRulesOverridesSessionAffinity = "header" - LoadBalancerRulesOverridesSessionAffinityEmpty LoadBalancerRulesOverridesSessionAffinity = "\"\"" -) - -// Configures attributes for session affinity. -type LoadBalancerRulesOverridesSessionAffinityAttributes struct { - // Configures the drain duration in seconds. This field is only used when session - // affinity is enabled on the load balancer. - DrainDuration float64 `json:"drain_duration"` - // Configures the names of HTTP headers to base session affinity on when header - // `session_affinity` is enabled. At least one HTTP header name must be provided. - // To specify the exact cookies to be used, include an item in the following - // format: `"cookie:,"` (example) where everything - // after the colon is a comma-separated list of cookie names. Providing only - // `"cookie"` will result in all cookies being used. The default max number of HTTP - // header names that can be provided depends on your plan: 5 for Enterprise, 1 for - // all other plans. - Headers []string `json:"headers"` - // When header `session_affinity` is enabled, this option can be used to specify - // how HTTP headers on load balancing requests will be used. The supported values - // are: - // - // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers - // specified by the `headers` session affinity attribute, otherwise sessions - // aren't created. - // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP - // headers specified by the `headers` session affinity attribute, otherwise - // sessions aren't created. - RequireAllHeaders bool `json:"require_all_headers"` - // Configures the SameSite attribute on session affinity cookie. Value "Auto" will - // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: - // when using value "None", the secure attribute can not be set to "Never". - Samesite LoadBalancerRulesOverridesSessionAffinityAttributesSamesite `json:"samesite"` - // Configures the Secure attribute on session affinity cookie. Value "Always" - // indicates the Secure attribute will be set in the Set-Cookie header, "Never" - // indicates the Secure attribute will not be set, and "Auto" will set the Secure - // attribute depending if Always Use HTTPS is enabled. - Secure LoadBalancerRulesOverridesSessionAffinityAttributesSecure `json:"secure"` - // Configures the zero-downtime failover between origins within a pool when session - // affinity is enabled. This feature is currently incompatible with Argo, Tiered - // Cache, and Bandwidth Alliance. The supported values are: - // - // - `"none"`: No failover takes place for sessions pinned to the origin (default). - // - `"temporary"`: Traffic will be sent to another other healthy origin until the - // originally pinned origin is available; note that this can potentially result - // in heavy origin flapping. - // - `"sticky"`: The session affinity cookie is updated and subsequent requests are - // sent to the new origin. Note: Zero-downtime failover with sticky sessions is - // currently not supported for session affinity by header. - ZeroDowntimeFailover LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailover `json:"zero_downtime_failover"` - JSON loadBalancerRulesOverridesSessionAffinityAttributesJSON `json:"-"` -} - -// loadBalancerRulesOverridesSessionAffinityAttributesJSON contains the JSON -// metadata for the struct [LoadBalancerRulesOverridesSessionAffinityAttributes] -type loadBalancerRulesOverridesSessionAffinityAttributesJSON struct { - DrainDuration apijson.Field - Headers apijson.Field - RequireAllHeaders apijson.Field - Samesite apijson.Field - Secure apijson.Field - ZeroDowntimeFailover apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerRulesOverridesSessionAffinityAttributes) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerRulesOverridesSessionAffinityAttributesJSON) RawJSON() string { - return r.raw -} - -// Configures the SameSite attribute on session affinity cookie. Value "Auto" will -// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: -// when using value "None", the secure attribute can not be set to "Never". -type LoadBalancerRulesOverridesSessionAffinityAttributesSamesite string - -const ( - LoadBalancerRulesOverridesSessionAffinityAttributesSamesiteAuto LoadBalancerRulesOverridesSessionAffinityAttributesSamesite = "Auto" - LoadBalancerRulesOverridesSessionAffinityAttributesSamesiteLax LoadBalancerRulesOverridesSessionAffinityAttributesSamesite = "Lax" - LoadBalancerRulesOverridesSessionAffinityAttributesSamesiteNone LoadBalancerRulesOverridesSessionAffinityAttributesSamesite = "None" - LoadBalancerRulesOverridesSessionAffinityAttributesSamesiteStrict LoadBalancerRulesOverridesSessionAffinityAttributesSamesite = "Strict" -) - -// Configures the Secure attribute on session affinity cookie. Value "Always" -// indicates the Secure attribute will be set in the Set-Cookie header, "Never" -// indicates the Secure attribute will not be set, and "Auto" will set the Secure -// attribute depending if Always Use HTTPS is enabled. -type LoadBalancerRulesOverridesSessionAffinityAttributesSecure string - -const ( - LoadBalancerRulesOverridesSessionAffinityAttributesSecureAuto LoadBalancerRulesOverridesSessionAffinityAttributesSecure = "Auto" - LoadBalancerRulesOverridesSessionAffinityAttributesSecureAlways LoadBalancerRulesOverridesSessionAffinityAttributesSecure = "Always" - LoadBalancerRulesOverridesSessionAffinityAttributesSecureNever LoadBalancerRulesOverridesSessionAffinityAttributesSecure = "Never" -) - -// Configures the zero-downtime failover between origins within a pool when session -// affinity is enabled. This feature is currently incompatible with Argo, Tiered -// Cache, and Bandwidth Alliance. The supported values are: -// -// - `"none"`: No failover takes place for sessions pinned to the origin (default). -// - `"temporary"`: Traffic will be sent to another other healthy origin until the -// originally pinned origin is available; note that this can potentially result -// in heavy origin flapping. -// - `"sticky"`: The session affinity cookie is updated and subsequent requests are -// sent to the new origin. Note: Zero-downtime failover with sticky sessions is -// currently not supported for session affinity by header. -type LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailover string - -const ( - LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "none" - LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "temporary" - LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "sticky" -) - -// Steering Policy for this load balancer. -// -// - `"off"`: Use `default_pools`. -// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied -// requests, the country for `country_pools` is determined by -// `location_strategy`. -// - `"random"`: Select a pool randomly. -// - `"dynamic_latency"`: Use round trip time to select the closest pool in -// default_pools (requires pool health checks). -// - `"proximity"`: Use the pools' latitude and longitude to select the closest -// pool using the Cloudflare PoP location for proxied requests or the location -// determined by `location_strategy` for non-proxied requests. -// - `"least_outstanding_requests"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of outstanding -// requests. Pools with more pending requests are weighted proportionately less -// relative to others. -// - `"least_connections"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of open connections. -// Pools with more open connections are weighted proportionately less relative to -// others. Supported for HTTP/1 and HTTP/2 connections. -// - `""`: Will map to `"geo"` if you use -// `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. -type LoadBalancerRulesOverridesSteeringPolicy string - -const ( - LoadBalancerRulesOverridesSteeringPolicyOff LoadBalancerRulesOverridesSteeringPolicy = "off" - LoadBalancerRulesOverridesSteeringPolicyGeo LoadBalancerRulesOverridesSteeringPolicy = "geo" - LoadBalancerRulesOverridesSteeringPolicyRandom LoadBalancerRulesOverridesSteeringPolicy = "random" - LoadBalancerRulesOverridesSteeringPolicyDynamicLatency LoadBalancerRulesOverridesSteeringPolicy = "dynamic_latency" - LoadBalancerRulesOverridesSteeringPolicyProximity LoadBalancerRulesOverridesSteeringPolicy = "proximity" - LoadBalancerRulesOverridesSteeringPolicyLeastOutstandingRequests LoadBalancerRulesOverridesSteeringPolicy = "least_outstanding_requests" - LoadBalancerRulesOverridesSteeringPolicyLeastConnections LoadBalancerRulesOverridesSteeringPolicy = "least_connections" - LoadBalancerRulesOverridesSteeringPolicyEmpty LoadBalancerRulesOverridesSteeringPolicy = "\"\"" -) - -// Specifies the type of session affinity the load balancer should use unless -// specified as `"none"` or "" (default). The supported types are: -// -// - `"cookie"`: On the first request to a proxied load balancer, a cookie is -// generated, encoding information of which origin the request will be forwarded -// to. Subsequent requests, by the same client to the same load balancer, will be -// sent to the origin server the cookie encodes, for the duration of the cookie -// and as long as the origin server remains healthy. If the cookie has expired or -// the origin server is unhealthy, then a new origin server is calculated and -// used. -// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin -// selection is stable and based on the client's ip address. -// - `"header"`: On the first request to a proxied load balancer, a session key -// based on the configured HTTP headers (see -// `session_affinity_attributes.headers`) is generated, encoding the request -// headers used for storing in the load balancer session state which origin the -// request will be forwarded to. Subsequent requests to the load balancer with -// the same headers will be sent to the same origin server, for the duration of -// the session and as long as the origin server remains healthy. If the session -// has been idle for the duration of `session_affinity_ttl` seconds or the origin -// server is unhealthy, then a new origin server is calculated and used. See -// `headers` in `session_affinity_attributes` for additional required -// configuration. -type LoadBalancerSessionAffinity string - -const ( - LoadBalancerSessionAffinityNone LoadBalancerSessionAffinity = "none" - LoadBalancerSessionAffinityCookie LoadBalancerSessionAffinity = "cookie" - LoadBalancerSessionAffinityIPCookie LoadBalancerSessionAffinity = "ip_cookie" - LoadBalancerSessionAffinityHeader LoadBalancerSessionAffinity = "header" - LoadBalancerSessionAffinityEmpty LoadBalancerSessionAffinity = "\"\"" -) - -// Configures attributes for session affinity. -type LoadBalancerSessionAffinityAttributes struct { - // Configures the drain duration in seconds. This field is only used when session - // affinity is enabled on the load balancer. - DrainDuration float64 `json:"drain_duration"` - // Configures the names of HTTP headers to base session affinity on when header - // `session_affinity` is enabled. At least one HTTP header name must be provided. - // To specify the exact cookies to be used, include an item in the following - // format: `"cookie:,"` (example) where everything - // after the colon is a comma-separated list of cookie names. Providing only - // `"cookie"` will result in all cookies being used. The default max number of HTTP - // header names that can be provided depends on your plan: 5 for Enterprise, 1 for - // all other plans. - Headers []string `json:"headers"` - // When header `session_affinity` is enabled, this option can be used to specify - // how HTTP headers on load balancing requests will be used. The supported values - // are: - // - // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers - // specified by the `headers` session affinity attribute, otherwise sessions - // aren't created. - // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP - // headers specified by the `headers` session affinity attribute, otherwise - // sessions aren't created. - RequireAllHeaders bool `json:"require_all_headers"` - // Configures the SameSite attribute on session affinity cookie. Value "Auto" will - // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: - // when using value "None", the secure attribute can not be set to "Never". - Samesite LoadBalancerSessionAffinityAttributesSamesite `json:"samesite"` - // Configures the Secure attribute on session affinity cookie. Value "Always" - // indicates the Secure attribute will be set in the Set-Cookie header, "Never" - // indicates the Secure attribute will not be set, and "Auto" will set the Secure - // attribute depending if Always Use HTTPS is enabled. - Secure LoadBalancerSessionAffinityAttributesSecure `json:"secure"` - // Configures the zero-downtime failover between origins within a pool when session - // affinity is enabled. This feature is currently incompatible with Argo, Tiered - // Cache, and Bandwidth Alliance. The supported values are: - // - // - `"none"`: No failover takes place for sessions pinned to the origin (default). - // - `"temporary"`: Traffic will be sent to another other healthy origin until the - // originally pinned origin is available; note that this can potentially result - // in heavy origin flapping. - // - `"sticky"`: The session affinity cookie is updated and subsequent requests are - // sent to the new origin. Note: Zero-downtime failover with sticky sessions is - // currently not supported for session affinity by header. - ZeroDowntimeFailover LoadBalancerSessionAffinityAttributesZeroDowntimeFailover `json:"zero_downtime_failover"` - JSON loadBalancerSessionAffinityAttributesJSON `json:"-"` -} - -// loadBalancerSessionAffinityAttributesJSON contains the JSON metadata for the -// struct [LoadBalancerSessionAffinityAttributes] -type loadBalancerSessionAffinityAttributesJSON struct { - DrainDuration apijson.Field - Headers apijson.Field - RequireAllHeaders apijson.Field - Samesite apijson.Field - Secure apijson.Field - ZeroDowntimeFailover apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerSessionAffinityAttributes) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerSessionAffinityAttributesJSON) RawJSON() string { - return r.raw -} - -// Configures the SameSite attribute on session affinity cookie. Value "Auto" will -// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: -// when using value "None", the secure attribute can not be set to "Never". -type LoadBalancerSessionAffinityAttributesSamesite string - -const ( - LoadBalancerSessionAffinityAttributesSamesiteAuto LoadBalancerSessionAffinityAttributesSamesite = "Auto" - LoadBalancerSessionAffinityAttributesSamesiteLax LoadBalancerSessionAffinityAttributesSamesite = "Lax" - LoadBalancerSessionAffinityAttributesSamesiteNone LoadBalancerSessionAffinityAttributesSamesite = "None" - LoadBalancerSessionAffinityAttributesSamesiteStrict LoadBalancerSessionAffinityAttributesSamesite = "Strict" -) - -// Configures the Secure attribute on session affinity cookie. Value "Always" -// indicates the Secure attribute will be set in the Set-Cookie header, "Never" -// indicates the Secure attribute will not be set, and "Auto" will set the Secure -// attribute depending if Always Use HTTPS is enabled. -type LoadBalancerSessionAffinityAttributesSecure string - -const ( - LoadBalancerSessionAffinityAttributesSecureAuto LoadBalancerSessionAffinityAttributesSecure = "Auto" - LoadBalancerSessionAffinityAttributesSecureAlways LoadBalancerSessionAffinityAttributesSecure = "Always" - LoadBalancerSessionAffinityAttributesSecureNever LoadBalancerSessionAffinityAttributesSecure = "Never" -) - -// Configures the zero-downtime failover between origins within a pool when session -// affinity is enabled. This feature is currently incompatible with Argo, Tiered -// Cache, and Bandwidth Alliance. The supported values are: -// -// - `"none"`: No failover takes place for sessions pinned to the origin (default). -// - `"temporary"`: Traffic will be sent to another other healthy origin until the -// originally pinned origin is available; note that this can potentially result -// in heavy origin flapping. -// - `"sticky"`: The session affinity cookie is updated and subsequent requests are -// sent to the new origin. Note: Zero-downtime failover with sticky sessions is -// currently not supported for session affinity by header. -type LoadBalancerSessionAffinityAttributesZeroDowntimeFailover string - -const ( - LoadBalancerSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerSessionAffinityAttributesZeroDowntimeFailover = "none" - LoadBalancerSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerSessionAffinityAttributesZeroDowntimeFailover = "temporary" - LoadBalancerSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerSessionAffinityAttributesZeroDowntimeFailover = "sticky" -) - -// Steering Policy for this load balancer. -// -// - `"off"`: Use `default_pools`. -// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied -// requests, the country for `country_pools` is determined by -// `location_strategy`. -// - `"random"`: Select a pool randomly. -// - `"dynamic_latency"`: Use round trip time to select the closest pool in -// default_pools (requires pool health checks). -// - `"proximity"`: Use the pools' latitude and longitude to select the closest -// pool using the Cloudflare PoP location for proxied requests or the location -// determined by `location_strategy` for non-proxied requests. -// - `"least_outstanding_requests"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of outstanding -// requests. Pools with more pending requests are weighted proportionately less -// relative to others. -// - `"least_connections"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of open connections. -// Pools with more open connections are weighted proportionately less relative to -// others. Supported for HTTP/1 and HTTP/2 connections. -// - `""`: Will map to `"geo"` if you use -// `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. -type LoadBalancerSteeringPolicy string - -const ( - LoadBalancerSteeringPolicyOff LoadBalancerSteeringPolicy = "off" - LoadBalancerSteeringPolicyGeo LoadBalancerSteeringPolicy = "geo" - LoadBalancerSteeringPolicyRandom LoadBalancerSteeringPolicy = "random" - LoadBalancerSteeringPolicyDynamicLatency LoadBalancerSteeringPolicy = "dynamic_latency" - LoadBalancerSteeringPolicyProximity LoadBalancerSteeringPolicy = "proximity" - LoadBalancerSteeringPolicyLeastOutstandingRequests LoadBalancerSteeringPolicy = "least_outstanding_requests" - LoadBalancerSteeringPolicyLeastConnections LoadBalancerSteeringPolicy = "least_connections" - LoadBalancerSteeringPolicyEmpty LoadBalancerSteeringPolicy = "\"\"" -) - -type LoadBalancerDeleteResponse struct { - ID string `json:"id"` - JSON loadBalancerDeleteResponseJSON `json:"-"` -} - -// loadBalancerDeleteResponseJSON contains the JSON metadata for the struct -// [LoadBalancerDeleteResponse] -type loadBalancerDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerNewParams struct { - ZoneID param.Field[string] `path:"zone_id,required"` - // A list of pool IDs ordered by their failover priority. Pools defined here are - // used by default, or when region_pools are not configured for a given region. - DefaultPools param.Field[[]string] `json:"default_pools,required"` - // The pool ID to use when all other pools are detected as unhealthy. - FallbackPool param.Field[interface{}] `json:"fallback_pool,required"` - // The DNS hostname to associate with your Load Balancer. If this hostname already - // exists as a DNS record in Cloudflare's DNS, the Load Balancer will take - // precedence and the DNS record will not be used. - Name param.Field[string] `json:"name,required"` - // Controls features that modify the routing of requests to pools and origins in - // response to dynamic conditions, such as during the interval between active - // health monitoring requests. For example, zero-downtime failover occurs - // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 - // response codes. If there is another healthy origin in the same pool, the request - // is retried once against this alternate origin. - AdaptiveRouting param.Field[LoadBalancerNewParamsAdaptiveRouting] `json:"adaptive_routing"` - // A mapping of country codes to a list of pool IDs (ordered by their failover - // priority) for the given country. Any country not explicitly defined will fall - // back to using the corresponding region_pool mapping if it exists else to - // default_pools. - CountryPools param.Field[interface{}] `json:"country_pools"` - // Object description. - Description param.Field[string] `json:"description"` - // Controls location-based steering for non-proxied requests. See `steering_policy` - // to learn how steering is affected. - LocationStrategy param.Field[LoadBalancerNewParamsLocationStrategy] `json:"location_strategy"` - // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs - // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not - // explicitly defined will fall back to using the corresponding country_pool, then - // region_pool mapping if it exists else to default_pools. - PopPools param.Field[interface{}] `json:"pop_pools"` - // Whether the hostname should be gray clouded (false) or orange clouded (true). - Proxied param.Field[bool] `json:"proxied"` - // Configures pool weights. - // - // - `steering_policy="random"`: A random pool is selected with probability - // proportional to pool weights. - // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each - // pool's outstanding requests. - // - `steering_policy="least_connections"`: Use pool weights to scale each pool's - // open connections. - RandomSteering param.Field[LoadBalancerNewParamsRandomSteering] `json:"random_steering"` - // A mapping of region codes to a list of pool IDs (ordered by their failover - // priority) for the given region. Any regions not explicitly defined will fall - // back to using default_pools. - RegionPools param.Field[interface{}] `json:"region_pools"` - // BETA Field Not General Access: A list of rules for this load balancer to - // execute. - Rules param.Field[[]LoadBalancerNewParamsRule] `json:"rules"` - // Specifies the type of session affinity the load balancer should use unless - // specified as `"none"` or "" (default). The supported types are: - // - // - `"cookie"`: On the first request to a proxied load balancer, a cookie is - // generated, encoding information of which origin the request will be forwarded - // to. Subsequent requests, by the same client to the same load balancer, will be - // sent to the origin server the cookie encodes, for the duration of the cookie - // and as long as the origin server remains healthy. If the cookie has expired or - // the origin server is unhealthy, then a new origin server is calculated and - // used. - // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin - // selection is stable and based on the client's ip address. - // - `"header"`: On the first request to a proxied load balancer, a session key - // based on the configured HTTP headers (see - // `session_affinity_attributes.headers`) is generated, encoding the request - // headers used for storing in the load balancer session state which origin the - // request will be forwarded to. Subsequent requests to the load balancer with - // the same headers will be sent to the same origin server, for the duration of - // the session and as long as the origin server remains healthy. If the session - // has been idle for the duration of `session_affinity_ttl` seconds or the origin - // server is unhealthy, then a new origin server is calculated and used. See - // `headers` in `session_affinity_attributes` for additional required - // configuration. - SessionAffinity param.Field[LoadBalancerNewParamsSessionAffinity] `json:"session_affinity"` - // Configures attributes for session affinity. - SessionAffinityAttributes param.Field[LoadBalancerNewParamsSessionAffinityAttributes] `json:"session_affinity_attributes"` - // Time, in seconds, until a client's session expires after being created. Once the - // expiry time has been reached, subsequent requests may get sent to a different - // origin server. The accepted ranges per `session_affinity` policy are: - // - // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used - // unless explicitly set. The accepted range of values is between [1800, 604800]. - // - `"header"`: The current default of 1800 seconds will be used unless explicitly - // set. The accepted range of values is between [30, 3600]. Note: With session - // affinity by header, sessions only expire after they haven't been used for the - // number of seconds specified. - SessionAffinityTTL param.Field[float64] `json:"session_affinity_ttl"` - // Steering Policy for this load balancer. - // - // - `"off"`: Use `default_pools`. - // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied - // requests, the country for `country_pools` is determined by - // `location_strategy`. - // - `"random"`: Select a pool randomly. - // - `"dynamic_latency"`: Use round trip time to select the closest pool in - // default_pools (requires pool health checks). - // - `"proximity"`: Use the pools' latitude and longitude to select the closest - // pool using the Cloudflare PoP location for proxied requests or the location - // determined by `location_strategy` for non-proxied requests. - // - `"least_outstanding_requests"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of outstanding - // requests. Pools with more pending requests are weighted proportionately less - // relative to others. - // - `"least_connections"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of open connections. - // Pools with more open connections are weighted proportionately less relative to - // others. Supported for HTTP/1 and HTTP/2 connections. - // - `""`: Will map to `"geo"` if you use - // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. - SteeringPolicy param.Field[LoadBalancerNewParamsSteeringPolicy] `json:"steering_policy"` - // Time to live (TTL) of the DNS entry for the IP address returned by this load - // balancer. This only applies to gray-clouded (unproxied) load balancers. - TTL param.Field[float64] `json:"ttl"` -} - -func (r LoadBalancerNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Controls features that modify the routing of requests to pools and origins in -// response to dynamic conditions, such as during the interval between active -// health monitoring requests. For example, zero-downtime failover occurs -// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 -// response codes. If there is another healthy origin in the same pool, the request -// is retried once against this alternate origin. -type LoadBalancerNewParamsAdaptiveRouting struct { - // Extends zero-downtime failover of requests to healthy origins from alternate - // pools, when no healthy alternate exists in the same pool, according to the - // failover order defined by traffic and origin steering. When set false (the - // default) zero-downtime failover will only occur between origins within the same - // pool. See `session_affinity_attributes` for control over when sessions are - // broken or reassigned. - FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` -} - -func (r LoadBalancerNewParamsAdaptiveRouting) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Controls location-based steering for non-proxied requests. See `steering_policy` -// to learn how steering is affected. -type LoadBalancerNewParamsLocationStrategy struct { - // Determines the authoritative location when ECS is not preferred, does not exist - // in the request, or its GeoIP lookup is unsuccessful. - // - // - `"pop"`: Use the Cloudflare PoP location. - // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is - // unsuccessful, use the Cloudflare PoP location. - Mode param.Field[LoadBalancerNewParamsLocationStrategyMode] `json:"mode"` - // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the - // authoritative location. - // - // - `"always"`: Always prefer ECS. - // - `"never"`: Never prefer ECS. - // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. - // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. - PreferEcs param.Field[LoadBalancerNewParamsLocationStrategyPreferEcs] `json:"prefer_ecs"` -} - -func (r LoadBalancerNewParamsLocationStrategy) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Determines the authoritative location when ECS is not preferred, does not exist -// in the request, or its GeoIP lookup is unsuccessful. -// -// - `"pop"`: Use the Cloudflare PoP location. -// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is -// unsuccessful, use the Cloudflare PoP location. -type LoadBalancerNewParamsLocationStrategyMode string - -const ( - LoadBalancerNewParamsLocationStrategyModePop LoadBalancerNewParamsLocationStrategyMode = "pop" - LoadBalancerNewParamsLocationStrategyModeResolverIP LoadBalancerNewParamsLocationStrategyMode = "resolver_ip" -) - -// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the -// authoritative location. -// -// - `"always"`: Always prefer ECS. -// - `"never"`: Never prefer ECS. -// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. -// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. -type LoadBalancerNewParamsLocationStrategyPreferEcs string - -const ( - LoadBalancerNewParamsLocationStrategyPreferEcsAlways LoadBalancerNewParamsLocationStrategyPreferEcs = "always" - LoadBalancerNewParamsLocationStrategyPreferEcsNever LoadBalancerNewParamsLocationStrategyPreferEcs = "never" - LoadBalancerNewParamsLocationStrategyPreferEcsProximity LoadBalancerNewParamsLocationStrategyPreferEcs = "proximity" - LoadBalancerNewParamsLocationStrategyPreferEcsGeo LoadBalancerNewParamsLocationStrategyPreferEcs = "geo" -) - -// Configures pool weights. -// -// - `steering_policy="random"`: A random pool is selected with probability -// proportional to pool weights. -// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each -// pool's outstanding requests. -// - `steering_policy="least_connections"`: Use pool weights to scale each pool's -// open connections. -type LoadBalancerNewParamsRandomSteering struct { - // The default weight for pools in the load balancer that are not specified in the - // pool_weights map. - DefaultWeight param.Field[float64] `json:"default_weight"` - // A mapping of pool IDs to custom weights. The weight is relative to other pools - // in the load balancer. - PoolWeights param.Field[interface{}] `json:"pool_weights"` -} - -func (r LoadBalancerNewParamsRandomSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A rule object containing conditions and overrides for this load balancer to -// evaluate. -type LoadBalancerNewParamsRule struct { - // The condition expressions to evaluate. If the condition evaluates to true, the - // overrides or fixed_response in this rule will be applied. An empty condition is - // always true. For more details on condition expressions, please see - // https://developers.cloudflare.com/load-balancing/understand-basics/load-balancing-rules/expressions. - Condition param.Field[string] `json:"condition"` - // Disable this specific rule. It will no longer be evaluated by this load - // balancer. - Disabled param.Field[bool] `json:"disabled"` - // A collection of fields used to directly respond to the eyeball instead of - // routing to a pool. If a fixed_response is supplied the rule will be marked as - // terminates. - FixedResponse param.Field[LoadBalancerNewParamsRulesFixedResponse] `json:"fixed_response"` - // Name of this rule. Only used for human readability. - Name param.Field[string] `json:"name"` - // A collection of overrides to apply to the load balancer when this rule's - // condition is true. All fields are optional. - Overrides param.Field[LoadBalancerNewParamsRulesOverrides] `json:"overrides"` - // The order in which rules should be executed in relation to each other. Lower - // values are executed first. Values do not need to be sequential. If no value is - // provided for any rule the array order of the rules field will be used to assign - // a priority. - Priority param.Field[int64] `json:"priority"` - // If this rule's condition is true, this causes rule evaluation to stop after - // processing this rule. - Terminates param.Field[bool] `json:"terminates"` -} - -func (r LoadBalancerNewParamsRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A collection of fields used to directly respond to the eyeball instead of -// routing to a pool. If a fixed_response is supplied the rule will be marked as -// terminates. -type LoadBalancerNewParamsRulesFixedResponse struct { - // The http 'Content-Type' header to include in the response. - ContentType param.Field[string] `json:"content_type"` - // The http 'Location' header to include in the response. - Location param.Field[string] `json:"location"` - // Text to include as the http body. - MessageBody param.Field[string] `json:"message_body"` - // The http status code to respond with. - StatusCode param.Field[int64] `json:"status_code"` -} - -func (r LoadBalancerNewParamsRulesFixedResponse) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A collection of overrides to apply to the load balancer when this rule's -// condition is true. All fields are optional. -type LoadBalancerNewParamsRulesOverrides struct { - // Controls features that modify the routing of requests to pools and origins in - // response to dynamic conditions, such as during the interval between active - // health monitoring requests. For example, zero-downtime failover occurs - // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 - // response codes. If there is another healthy origin in the same pool, the request - // is retried once against this alternate origin. - AdaptiveRouting param.Field[LoadBalancerNewParamsRulesOverridesAdaptiveRouting] `json:"adaptive_routing"` - // A mapping of country codes to a list of pool IDs (ordered by their failover - // priority) for the given country. Any country not explicitly defined will fall - // back to using the corresponding region_pool mapping if it exists else to - // default_pools. - CountryPools param.Field[interface{}] `json:"country_pools"` - // A list of pool IDs ordered by their failover priority. Pools defined here are - // used by default, or when region_pools are not configured for a given region. - DefaultPools param.Field[[]string] `json:"default_pools"` - // The pool ID to use when all other pools are detected as unhealthy. - FallbackPool param.Field[interface{}] `json:"fallback_pool"` - // Controls location-based steering for non-proxied requests. See `steering_policy` - // to learn how steering is affected. - LocationStrategy param.Field[LoadBalancerNewParamsRulesOverridesLocationStrategy] `json:"location_strategy"` - // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs - // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not - // explicitly defined will fall back to using the corresponding country_pool, then - // region_pool mapping if it exists else to default_pools. - PopPools param.Field[interface{}] `json:"pop_pools"` - // Configures pool weights. - // - // - `steering_policy="random"`: A random pool is selected with probability - // proportional to pool weights. - // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each - // pool's outstanding requests. - // - `steering_policy="least_connections"`: Use pool weights to scale each pool's - // open connections. - RandomSteering param.Field[LoadBalancerNewParamsRulesOverridesRandomSteering] `json:"random_steering"` - // A mapping of region codes to a list of pool IDs (ordered by their failover - // priority) for the given region. Any regions not explicitly defined will fall - // back to using default_pools. - RegionPools param.Field[interface{}] `json:"region_pools"` - // Specifies the type of session affinity the load balancer should use unless - // specified as `"none"` or "" (default). The supported types are: - // - // - `"cookie"`: On the first request to a proxied load balancer, a cookie is - // generated, encoding information of which origin the request will be forwarded - // to. Subsequent requests, by the same client to the same load balancer, will be - // sent to the origin server the cookie encodes, for the duration of the cookie - // and as long as the origin server remains healthy. If the cookie has expired or - // the origin server is unhealthy, then a new origin server is calculated and - // used. - // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin - // selection is stable and based on the client's ip address. - // - `"header"`: On the first request to a proxied load balancer, a session key - // based on the configured HTTP headers (see - // `session_affinity_attributes.headers`) is generated, encoding the request - // headers used for storing in the load balancer session state which origin the - // request will be forwarded to. Subsequent requests to the load balancer with - // the same headers will be sent to the same origin server, for the duration of - // the session and as long as the origin server remains healthy. If the session - // has been idle for the duration of `session_affinity_ttl` seconds or the origin - // server is unhealthy, then a new origin server is calculated and used. See - // `headers` in `session_affinity_attributes` for additional required - // configuration. - SessionAffinity param.Field[LoadBalancerNewParamsRulesOverridesSessionAffinity] `json:"session_affinity"` - // Configures attributes for session affinity. - SessionAffinityAttributes param.Field[LoadBalancerNewParamsRulesOverridesSessionAffinityAttributes] `json:"session_affinity_attributes"` - // Time, in seconds, until a client's session expires after being created. Once the - // expiry time has been reached, subsequent requests may get sent to a different - // origin server. The accepted ranges per `session_affinity` policy are: - // - // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used - // unless explicitly set. The accepted range of values is between [1800, 604800]. - // - `"header"`: The current default of 1800 seconds will be used unless explicitly - // set. The accepted range of values is between [30, 3600]. Note: With session - // affinity by header, sessions only expire after they haven't been used for the - // number of seconds specified. - SessionAffinityTTL param.Field[float64] `json:"session_affinity_ttl"` - // Steering Policy for this load balancer. - // - // - `"off"`: Use `default_pools`. - // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied - // requests, the country for `country_pools` is determined by - // `location_strategy`. - // - `"random"`: Select a pool randomly. - // - `"dynamic_latency"`: Use round trip time to select the closest pool in - // default_pools (requires pool health checks). - // - `"proximity"`: Use the pools' latitude and longitude to select the closest - // pool using the Cloudflare PoP location for proxied requests or the location - // determined by `location_strategy` for non-proxied requests. - // - `"least_outstanding_requests"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of outstanding - // requests. Pools with more pending requests are weighted proportionately less - // relative to others. - // - `"least_connections"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of open connections. - // Pools with more open connections are weighted proportionately less relative to - // others. Supported for HTTP/1 and HTTP/2 connections. - // - `""`: Will map to `"geo"` if you use - // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. - SteeringPolicy param.Field[LoadBalancerNewParamsRulesOverridesSteeringPolicy] `json:"steering_policy"` - // Time to live (TTL) of the DNS entry for the IP address returned by this load - // balancer. This only applies to gray-clouded (unproxied) load balancers. - TTL param.Field[float64] `json:"ttl"` -} - -func (r LoadBalancerNewParamsRulesOverrides) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Controls features that modify the routing of requests to pools and origins in -// response to dynamic conditions, such as during the interval between active -// health monitoring requests. For example, zero-downtime failover occurs -// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 -// response codes. If there is another healthy origin in the same pool, the request -// is retried once against this alternate origin. -type LoadBalancerNewParamsRulesOverridesAdaptiveRouting struct { - // Extends zero-downtime failover of requests to healthy origins from alternate - // pools, when no healthy alternate exists in the same pool, according to the - // failover order defined by traffic and origin steering. When set false (the - // default) zero-downtime failover will only occur between origins within the same - // pool. See `session_affinity_attributes` for control over when sessions are - // broken or reassigned. - FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` -} - -func (r LoadBalancerNewParamsRulesOverridesAdaptiveRouting) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Controls location-based steering for non-proxied requests. See `steering_policy` -// to learn how steering is affected. -type LoadBalancerNewParamsRulesOverridesLocationStrategy struct { - // Determines the authoritative location when ECS is not preferred, does not exist - // in the request, or its GeoIP lookup is unsuccessful. - // - // - `"pop"`: Use the Cloudflare PoP location. - // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is - // unsuccessful, use the Cloudflare PoP location. - Mode param.Field[LoadBalancerNewParamsRulesOverridesLocationStrategyMode] `json:"mode"` - // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the - // authoritative location. - // - // - `"always"`: Always prefer ECS. - // - `"never"`: Never prefer ECS. - // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. - // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. - PreferEcs param.Field[LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs] `json:"prefer_ecs"` -} - -func (r LoadBalancerNewParamsRulesOverridesLocationStrategy) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Determines the authoritative location when ECS is not preferred, does not exist -// in the request, or its GeoIP lookup is unsuccessful. -// -// - `"pop"`: Use the Cloudflare PoP location. -// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is -// unsuccessful, use the Cloudflare PoP location. -type LoadBalancerNewParamsRulesOverridesLocationStrategyMode string - -const ( - LoadBalancerNewParamsRulesOverridesLocationStrategyModePop LoadBalancerNewParamsRulesOverridesLocationStrategyMode = "pop" - LoadBalancerNewParamsRulesOverridesLocationStrategyModeResolverIP LoadBalancerNewParamsRulesOverridesLocationStrategyMode = "resolver_ip" -) - -// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the -// authoritative location. -// -// - `"always"`: Always prefer ECS. -// - `"never"`: Never prefer ECS. -// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. -// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. -type LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs string - -const ( - LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsAlways LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs = "always" - LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsNever LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs = "never" - LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsProximity LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs = "proximity" - LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsGeo LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcs = "geo" -) - -// Configures pool weights. -// -// - `steering_policy="random"`: A random pool is selected with probability -// proportional to pool weights. -// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each -// pool's outstanding requests. -// - `steering_policy="least_connections"`: Use pool weights to scale each pool's -// open connections. -type LoadBalancerNewParamsRulesOverridesRandomSteering struct { - // The default weight for pools in the load balancer that are not specified in the - // pool_weights map. - DefaultWeight param.Field[float64] `json:"default_weight"` - // A mapping of pool IDs to custom weights. The weight is relative to other pools - // in the load balancer. - PoolWeights param.Field[interface{}] `json:"pool_weights"` -} - -func (r LoadBalancerNewParamsRulesOverridesRandomSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Specifies the type of session affinity the load balancer should use unless -// specified as `"none"` or "" (default). The supported types are: -// -// - `"cookie"`: On the first request to a proxied load balancer, a cookie is -// generated, encoding information of which origin the request will be forwarded -// to. Subsequent requests, by the same client to the same load balancer, will be -// sent to the origin server the cookie encodes, for the duration of the cookie -// and as long as the origin server remains healthy. If the cookie has expired or -// the origin server is unhealthy, then a new origin server is calculated and -// used. -// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin -// selection is stable and based on the client's ip address. -// - `"header"`: On the first request to a proxied load balancer, a session key -// based on the configured HTTP headers (see -// `session_affinity_attributes.headers`) is generated, encoding the request -// headers used for storing in the load balancer session state which origin the -// request will be forwarded to. Subsequent requests to the load balancer with -// the same headers will be sent to the same origin server, for the duration of -// the session and as long as the origin server remains healthy. If the session -// has been idle for the duration of `session_affinity_ttl` seconds or the origin -// server is unhealthy, then a new origin server is calculated and used. See -// `headers` in `session_affinity_attributes` for additional required -// configuration. -type LoadBalancerNewParamsRulesOverridesSessionAffinity string - -const ( - LoadBalancerNewParamsRulesOverridesSessionAffinityNone LoadBalancerNewParamsRulesOverridesSessionAffinity = "none" - LoadBalancerNewParamsRulesOverridesSessionAffinityCookie LoadBalancerNewParamsRulesOverridesSessionAffinity = "cookie" - LoadBalancerNewParamsRulesOverridesSessionAffinityIPCookie LoadBalancerNewParamsRulesOverridesSessionAffinity = "ip_cookie" - LoadBalancerNewParamsRulesOverridesSessionAffinityHeader LoadBalancerNewParamsRulesOverridesSessionAffinity = "header" - LoadBalancerNewParamsRulesOverridesSessionAffinityEmpty LoadBalancerNewParamsRulesOverridesSessionAffinity = "\"\"" -) - -// Configures attributes for session affinity. -type LoadBalancerNewParamsRulesOverridesSessionAffinityAttributes struct { - // Configures the drain duration in seconds. This field is only used when session - // affinity is enabled on the load balancer. - DrainDuration param.Field[float64] `json:"drain_duration"` - // Configures the names of HTTP headers to base session affinity on when header - // `session_affinity` is enabled. At least one HTTP header name must be provided. - // To specify the exact cookies to be used, include an item in the following - // format: `"cookie:,"` (example) where everything - // after the colon is a comma-separated list of cookie names. Providing only - // `"cookie"` will result in all cookies being used. The default max number of HTTP - // header names that can be provided depends on your plan: 5 for Enterprise, 1 for - // all other plans. - Headers param.Field[[]string] `json:"headers"` - // When header `session_affinity` is enabled, this option can be used to specify - // how HTTP headers on load balancing requests will be used. The supported values - // are: - // - // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers - // specified by the `headers` session affinity attribute, otherwise sessions - // aren't created. - // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP - // headers specified by the `headers` session affinity attribute, otherwise - // sessions aren't created. - RequireAllHeaders param.Field[bool] `json:"require_all_headers"` - // Configures the SameSite attribute on session affinity cookie. Value "Auto" will - // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: - // when using value "None", the secure attribute can not be set to "Never". - Samesite param.Field[LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite] `json:"samesite"` - // Configures the Secure attribute on session affinity cookie. Value "Always" - // indicates the Secure attribute will be set in the Set-Cookie header, "Never" - // indicates the Secure attribute will not be set, and "Auto" will set the Secure - // attribute depending if Always Use HTTPS is enabled. - Secure param.Field[LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecure] `json:"secure"` - // Configures the zero-downtime failover between origins within a pool when session - // affinity is enabled. This feature is currently incompatible with Argo, Tiered - // Cache, and Bandwidth Alliance. The supported values are: - // - // - `"none"`: No failover takes place for sessions pinned to the origin (default). - // - `"temporary"`: Traffic will be sent to another other healthy origin until the - // originally pinned origin is available; note that this can potentially result - // in heavy origin flapping. - // - `"sticky"`: The session affinity cookie is updated and subsequent requests are - // sent to the new origin. Note: Zero-downtime failover with sticky sessions is - // currently not supported for session affinity by header. - ZeroDowntimeFailover param.Field[LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` -} - -func (r LoadBalancerNewParamsRulesOverridesSessionAffinityAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures the SameSite attribute on session affinity cookie. Value "Auto" will -// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: -// when using value "None", the secure attribute can not be set to "Never". -type LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite string - -const ( - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteAuto LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite = "Auto" - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteLax LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite = "Lax" - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteNone LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite = "None" - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteStrict LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesite = "Strict" -) - -// Configures the Secure attribute on session affinity cookie. Value "Always" -// indicates the Secure attribute will be set in the Set-Cookie header, "Never" -// indicates the Secure attribute will not be set, and "Auto" will set the Secure -// attribute depending if Always Use HTTPS is enabled. -type LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecure string - -const ( - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureAuto LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecure = "Auto" - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureAlways LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecure = "Always" - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureNever LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecure = "Never" -) - -// Configures the zero-downtime failover between origins within a pool when session -// affinity is enabled. This feature is currently incompatible with Argo, Tiered -// Cache, and Bandwidth Alliance. The supported values are: -// -// - `"none"`: No failover takes place for sessions pinned to the origin (default). -// - `"temporary"`: Traffic will be sent to another other healthy origin until the -// originally pinned origin is available; note that this can potentially result -// in heavy origin flapping. -// - `"sticky"`: The session affinity cookie is updated and subsequent requests are -// sent to the new origin. Note: Zero-downtime failover with sticky sessions is -// currently not supported for session affinity by header. -type LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover string - -const ( - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "none" - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "temporary" - LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "sticky" -) - -// Steering Policy for this load balancer. -// -// - `"off"`: Use `default_pools`. -// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied -// requests, the country for `country_pools` is determined by -// `location_strategy`. -// - `"random"`: Select a pool randomly. -// - `"dynamic_latency"`: Use round trip time to select the closest pool in -// default_pools (requires pool health checks). -// - `"proximity"`: Use the pools' latitude and longitude to select the closest -// pool using the Cloudflare PoP location for proxied requests or the location -// determined by `location_strategy` for non-proxied requests. -// - `"least_outstanding_requests"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of outstanding -// requests. Pools with more pending requests are weighted proportionately less -// relative to others. -// - `"least_connections"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of open connections. -// Pools with more open connections are weighted proportionately less relative to -// others. Supported for HTTP/1 and HTTP/2 connections. -// - `""`: Will map to `"geo"` if you use -// `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. -type LoadBalancerNewParamsRulesOverridesSteeringPolicy string - -const ( - LoadBalancerNewParamsRulesOverridesSteeringPolicyOff LoadBalancerNewParamsRulesOverridesSteeringPolicy = "off" - LoadBalancerNewParamsRulesOverridesSteeringPolicyGeo LoadBalancerNewParamsRulesOverridesSteeringPolicy = "geo" - LoadBalancerNewParamsRulesOverridesSteeringPolicyRandom LoadBalancerNewParamsRulesOverridesSteeringPolicy = "random" - LoadBalancerNewParamsRulesOverridesSteeringPolicyDynamicLatency LoadBalancerNewParamsRulesOverridesSteeringPolicy = "dynamic_latency" - LoadBalancerNewParamsRulesOverridesSteeringPolicyProximity LoadBalancerNewParamsRulesOverridesSteeringPolicy = "proximity" - LoadBalancerNewParamsRulesOverridesSteeringPolicyLeastOutstandingRequests LoadBalancerNewParamsRulesOverridesSteeringPolicy = "least_outstanding_requests" - LoadBalancerNewParamsRulesOverridesSteeringPolicyLeastConnections LoadBalancerNewParamsRulesOverridesSteeringPolicy = "least_connections" - LoadBalancerNewParamsRulesOverridesSteeringPolicyEmpty LoadBalancerNewParamsRulesOverridesSteeringPolicy = "\"\"" -) - -// Specifies the type of session affinity the load balancer should use unless -// specified as `"none"` or "" (default). The supported types are: -// -// - `"cookie"`: On the first request to a proxied load balancer, a cookie is -// generated, encoding information of which origin the request will be forwarded -// to. Subsequent requests, by the same client to the same load balancer, will be -// sent to the origin server the cookie encodes, for the duration of the cookie -// and as long as the origin server remains healthy. If the cookie has expired or -// the origin server is unhealthy, then a new origin server is calculated and -// used. -// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin -// selection is stable and based on the client's ip address. -// - `"header"`: On the first request to a proxied load balancer, a session key -// based on the configured HTTP headers (see -// `session_affinity_attributes.headers`) is generated, encoding the request -// headers used for storing in the load balancer session state which origin the -// request will be forwarded to. Subsequent requests to the load balancer with -// the same headers will be sent to the same origin server, for the duration of -// the session and as long as the origin server remains healthy. If the session -// has been idle for the duration of `session_affinity_ttl` seconds or the origin -// server is unhealthy, then a new origin server is calculated and used. See -// `headers` in `session_affinity_attributes` for additional required -// configuration. -type LoadBalancerNewParamsSessionAffinity string - -const ( - LoadBalancerNewParamsSessionAffinityNone LoadBalancerNewParamsSessionAffinity = "none" - LoadBalancerNewParamsSessionAffinityCookie LoadBalancerNewParamsSessionAffinity = "cookie" - LoadBalancerNewParamsSessionAffinityIPCookie LoadBalancerNewParamsSessionAffinity = "ip_cookie" - LoadBalancerNewParamsSessionAffinityHeader LoadBalancerNewParamsSessionAffinity = "header" - LoadBalancerNewParamsSessionAffinityEmpty LoadBalancerNewParamsSessionAffinity = "\"\"" -) - -// Configures attributes for session affinity. -type LoadBalancerNewParamsSessionAffinityAttributes struct { - // Configures the drain duration in seconds. This field is only used when session - // affinity is enabled on the load balancer. - DrainDuration param.Field[float64] `json:"drain_duration"` - // Configures the names of HTTP headers to base session affinity on when header - // `session_affinity` is enabled. At least one HTTP header name must be provided. - // To specify the exact cookies to be used, include an item in the following - // format: `"cookie:,"` (example) where everything - // after the colon is a comma-separated list of cookie names. Providing only - // `"cookie"` will result in all cookies being used. The default max number of HTTP - // header names that can be provided depends on your plan: 5 for Enterprise, 1 for - // all other plans. - Headers param.Field[[]string] `json:"headers"` - // When header `session_affinity` is enabled, this option can be used to specify - // how HTTP headers on load balancing requests will be used. The supported values - // are: - // - // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers - // specified by the `headers` session affinity attribute, otherwise sessions - // aren't created. - // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP - // headers specified by the `headers` session affinity attribute, otherwise - // sessions aren't created. - RequireAllHeaders param.Field[bool] `json:"require_all_headers"` - // Configures the SameSite attribute on session affinity cookie. Value "Auto" will - // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: - // when using value "None", the secure attribute can not be set to "Never". - Samesite param.Field[LoadBalancerNewParamsSessionAffinityAttributesSamesite] `json:"samesite"` - // Configures the Secure attribute on session affinity cookie. Value "Always" - // indicates the Secure attribute will be set in the Set-Cookie header, "Never" - // indicates the Secure attribute will not be set, and "Auto" will set the Secure - // attribute depending if Always Use HTTPS is enabled. - Secure param.Field[LoadBalancerNewParamsSessionAffinityAttributesSecure] `json:"secure"` - // Configures the zero-downtime failover between origins within a pool when session - // affinity is enabled. This feature is currently incompatible with Argo, Tiered - // Cache, and Bandwidth Alliance. The supported values are: - // - // - `"none"`: No failover takes place for sessions pinned to the origin (default). - // - `"temporary"`: Traffic will be sent to another other healthy origin until the - // originally pinned origin is available; note that this can potentially result - // in heavy origin flapping. - // - `"sticky"`: The session affinity cookie is updated and subsequent requests are - // sent to the new origin. Note: Zero-downtime failover with sticky sessions is - // currently not supported for session affinity by header. - ZeroDowntimeFailover param.Field[LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` -} - -func (r LoadBalancerNewParamsSessionAffinityAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures the SameSite attribute on session affinity cookie. Value "Auto" will -// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: -// when using value "None", the secure attribute can not be set to "Never". -type LoadBalancerNewParamsSessionAffinityAttributesSamesite string - -const ( - LoadBalancerNewParamsSessionAffinityAttributesSamesiteAuto LoadBalancerNewParamsSessionAffinityAttributesSamesite = "Auto" - LoadBalancerNewParamsSessionAffinityAttributesSamesiteLax LoadBalancerNewParamsSessionAffinityAttributesSamesite = "Lax" - LoadBalancerNewParamsSessionAffinityAttributesSamesiteNone LoadBalancerNewParamsSessionAffinityAttributesSamesite = "None" - LoadBalancerNewParamsSessionAffinityAttributesSamesiteStrict LoadBalancerNewParamsSessionAffinityAttributesSamesite = "Strict" -) - -// Configures the Secure attribute on session affinity cookie. Value "Always" -// indicates the Secure attribute will be set in the Set-Cookie header, "Never" -// indicates the Secure attribute will not be set, and "Auto" will set the Secure -// attribute depending if Always Use HTTPS is enabled. -type LoadBalancerNewParamsSessionAffinityAttributesSecure string - -const ( - LoadBalancerNewParamsSessionAffinityAttributesSecureAuto LoadBalancerNewParamsSessionAffinityAttributesSecure = "Auto" - LoadBalancerNewParamsSessionAffinityAttributesSecureAlways LoadBalancerNewParamsSessionAffinityAttributesSecure = "Always" - LoadBalancerNewParamsSessionAffinityAttributesSecureNever LoadBalancerNewParamsSessionAffinityAttributesSecure = "Never" -) - -// Configures the zero-downtime failover between origins within a pool when session -// affinity is enabled. This feature is currently incompatible with Argo, Tiered -// Cache, and Bandwidth Alliance. The supported values are: -// -// - `"none"`: No failover takes place for sessions pinned to the origin (default). -// - `"temporary"`: Traffic will be sent to another other healthy origin until the -// originally pinned origin is available; note that this can potentially result -// in heavy origin flapping. -// - `"sticky"`: The session affinity cookie is updated and subsequent requests are -// sent to the new origin. Note: Zero-downtime failover with sticky sessions is -// currently not supported for session affinity by header. -type LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailover string - -const ( - LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailover = "none" - LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailover = "temporary" - LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailover = "sticky" -) - -// Steering Policy for this load balancer. -// -// - `"off"`: Use `default_pools`. -// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied -// requests, the country for `country_pools` is determined by -// `location_strategy`. -// - `"random"`: Select a pool randomly. -// - `"dynamic_latency"`: Use round trip time to select the closest pool in -// default_pools (requires pool health checks). -// - `"proximity"`: Use the pools' latitude and longitude to select the closest -// pool using the Cloudflare PoP location for proxied requests or the location -// determined by `location_strategy` for non-proxied requests. -// - `"least_outstanding_requests"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of outstanding -// requests. Pools with more pending requests are weighted proportionately less -// relative to others. -// - `"least_connections"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of open connections. -// Pools with more open connections are weighted proportionately less relative to -// others. Supported for HTTP/1 and HTTP/2 connections. -// - `""`: Will map to `"geo"` if you use -// `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. -type LoadBalancerNewParamsSteeringPolicy string - -const ( - LoadBalancerNewParamsSteeringPolicyOff LoadBalancerNewParamsSteeringPolicy = "off" - LoadBalancerNewParamsSteeringPolicyGeo LoadBalancerNewParamsSteeringPolicy = "geo" - LoadBalancerNewParamsSteeringPolicyRandom LoadBalancerNewParamsSteeringPolicy = "random" - LoadBalancerNewParamsSteeringPolicyDynamicLatency LoadBalancerNewParamsSteeringPolicy = "dynamic_latency" - LoadBalancerNewParamsSteeringPolicyProximity LoadBalancerNewParamsSteeringPolicy = "proximity" - LoadBalancerNewParamsSteeringPolicyLeastOutstandingRequests LoadBalancerNewParamsSteeringPolicy = "least_outstanding_requests" - LoadBalancerNewParamsSteeringPolicyLeastConnections LoadBalancerNewParamsSteeringPolicy = "least_connections" - LoadBalancerNewParamsSteeringPolicyEmpty LoadBalancerNewParamsSteeringPolicy = "\"\"" -) - -type LoadBalancerNewResponseEnvelope struct { - Errors []LoadBalancerNewResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerNewResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancer `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerNewResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerNewResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [LoadBalancerNewResponseEnvelope] -type loadBalancerNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LoadBalancerNewResponseEnvelopeErrors] -type loadBalancerNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LoadBalancerNewResponseEnvelopeMessages] -type loadBalancerNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerNewResponseEnvelopeSuccess bool - -const ( - LoadBalancerNewResponseEnvelopeSuccessTrue LoadBalancerNewResponseEnvelopeSuccess = true -) - -type LoadBalancerUpdateParams struct { - ZoneID param.Field[string] `path:"zone_id,required"` - // A list of pool IDs ordered by their failover priority. Pools defined here are - // used by default, or when region_pools are not configured for a given region. - DefaultPools param.Field[[]string] `json:"default_pools,required"` - // The pool ID to use when all other pools are detected as unhealthy. - FallbackPool param.Field[interface{}] `json:"fallback_pool,required"` - // The DNS hostname to associate with your Load Balancer. If this hostname already - // exists as a DNS record in Cloudflare's DNS, the Load Balancer will take - // precedence and the DNS record will not be used. - Name param.Field[string] `json:"name,required"` - // Controls features that modify the routing of requests to pools and origins in - // response to dynamic conditions, such as during the interval between active - // health monitoring requests. For example, zero-downtime failover occurs - // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 - // response codes. If there is another healthy origin in the same pool, the request - // is retried once against this alternate origin. - AdaptiveRouting param.Field[LoadBalancerUpdateParamsAdaptiveRouting] `json:"adaptive_routing"` - // A mapping of country codes to a list of pool IDs (ordered by their failover - // priority) for the given country. Any country not explicitly defined will fall - // back to using the corresponding region_pool mapping if it exists else to - // default_pools. - CountryPools param.Field[interface{}] `json:"country_pools"` - // Object description. - Description param.Field[string] `json:"description"` - // Whether to enable (the default) this load balancer. - Enabled param.Field[bool] `json:"enabled"` - // Controls location-based steering for non-proxied requests. See `steering_policy` - // to learn how steering is affected. - LocationStrategy param.Field[LoadBalancerUpdateParamsLocationStrategy] `json:"location_strategy"` - // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs - // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not - // explicitly defined will fall back to using the corresponding country_pool, then - // region_pool mapping if it exists else to default_pools. - PopPools param.Field[interface{}] `json:"pop_pools"` - // Whether the hostname should be gray clouded (false) or orange clouded (true). - Proxied param.Field[bool] `json:"proxied"` - // Configures pool weights. - // - // - `steering_policy="random"`: A random pool is selected with probability - // proportional to pool weights. - // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each - // pool's outstanding requests. - // - `steering_policy="least_connections"`: Use pool weights to scale each pool's - // open connections. - RandomSteering param.Field[LoadBalancerUpdateParamsRandomSteering] `json:"random_steering"` - // A mapping of region codes to a list of pool IDs (ordered by their failover - // priority) for the given region. Any regions not explicitly defined will fall - // back to using default_pools. - RegionPools param.Field[interface{}] `json:"region_pools"` - // BETA Field Not General Access: A list of rules for this load balancer to - // execute. - Rules param.Field[[]LoadBalancerUpdateParamsRule] `json:"rules"` - // Specifies the type of session affinity the load balancer should use unless - // specified as `"none"` or "" (default). The supported types are: - // - // - `"cookie"`: On the first request to a proxied load balancer, a cookie is - // generated, encoding information of which origin the request will be forwarded - // to. Subsequent requests, by the same client to the same load balancer, will be - // sent to the origin server the cookie encodes, for the duration of the cookie - // and as long as the origin server remains healthy. If the cookie has expired or - // the origin server is unhealthy, then a new origin server is calculated and - // used. - // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin - // selection is stable and based on the client's ip address. - // - `"header"`: On the first request to a proxied load balancer, a session key - // based on the configured HTTP headers (see - // `session_affinity_attributes.headers`) is generated, encoding the request - // headers used for storing in the load balancer session state which origin the - // request will be forwarded to. Subsequent requests to the load balancer with - // the same headers will be sent to the same origin server, for the duration of - // the session and as long as the origin server remains healthy. If the session - // has been idle for the duration of `session_affinity_ttl` seconds or the origin - // server is unhealthy, then a new origin server is calculated and used. See - // `headers` in `session_affinity_attributes` for additional required - // configuration. - SessionAffinity param.Field[LoadBalancerUpdateParamsSessionAffinity] `json:"session_affinity"` - // Configures attributes for session affinity. - SessionAffinityAttributes param.Field[LoadBalancerUpdateParamsSessionAffinityAttributes] `json:"session_affinity_attributes"` - // Time, in seconds, until a client's session expires after being created. Once the - // expiry time has been reached, subsequent requests may get sent to a different - // origin server. The accepted ranges per `session_affinity` policy are: - // - // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used - // unless explicitly set. The accepted range of values is between [1800, 604800]. - // - `"header"`: The current default of 1800 seconds will be used unless explicitly - // set. The accepted range of values is between [30, 3600]. Note: With session - // affinity by header, sessions only expire after they haven't been used for the - // number of seconds specified. - SessionAffinityTTL param.Field[float64] `json:"session_affinity_ttl"` - // Steering Policy for this load balancer. - // - // - `"off"`: Use `default_pools`. - // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied - // requests, the country for `country_pools` is determined by - // `location_strategy`. - // - `"random"`: Select a pool randomly. - // - `"dynamic_latency"`: Use round trip time to select the closest pool in - // default_pools (requires pool health checks). - // - `"proximity"`: Use the pools' latitude and longitude to select the closest - // pool using the Cloudflare PoP location for proxied requests or the location - // determined by `location_strategy` for non-proxied requests. - // - `"least_outstanding_requests"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of outstanding - // requests. Pools with more pending requests are weighted proportionately less - // relative to others. - // - `"least_connections"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of open connections. - // Pools with more open connections are weighted proportionately less relative to - // others. Supported for HTTP/1 and HTTP/2 connections. - // - `""`: Will map to `"geo"` if you use - // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. - SteeringPolicy param.Field[LoadBalancerUpdateParamsSteeringPolicy] `json:"steering_policy"` - // Time to live (TTL) of the DNS entry for the IP address returned by this load - // balancer. This only applies to gray-clouded (unproxied) load balancers. - TTL param.Field[float64] `json:"ttl"` -} - -func (r LoadBalancerUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Controls features that modify the routing of requests to pools and origins in -// response to dynamic conditions, such as during the interval between active -// health monitoring requests. For example, zero-downtime failover occurs -// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 -// response codes. If there is another healthy origin in the same pool, the request -// is retried once against this alternate origin. -type LoadBalancerUpdateParamsAdaptiveRouting struct { - // Extends zero-downtime failover of requests to healthy origins from alternate - // pools, when no healthy alternate exists in the same pool, according to the - // failover order defined by traffic and origin steering. When set false (the - // default) zero-downtime failover will only occur between origins within the same - // pool. See `session_affinity_attributes` for control over when sessions are - // broken or reassigned. - FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` -} - -func (r LoadBalancerUpdateParamsAdaptiveRouting) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Controls location-based steering for non-proxied requests. See `steering_policy` -// to learn how steering is affected. -type LoadBalancerUpdateParamsLocationStrategy struct { - // Determines the authoritative location when ECS is not preferred, does not exist - // in the request, or its GeoIP lookup is unsuccessful. - // - // - `"pop"`: Use the Cloudflare PoP location. - // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is - // unsuccessful, use the Cloudflare PoP location. - Mode param.Field[LoadBalancerUpdateParamsLocationStrategyMode] `json:"mode"` - // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the - // authoritative location. - // - // - `"always"`: Always prefer ECS. - // - `"never"`: Never prefer ECS. - // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. - // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. - PreferEcs param.Field[LoadBalancerUpdateParamsLocationStrategyPreferEcs] `json:"prefer_ecs"` -} - -func (r LoadBalancerUpdateParamsLocationStrategy) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Determines the authoritative location when ECS is not preferred, does not exist -// in the request, or its GeoIP lookup is unsuccessful. -// -// - `"pop"`: Use the Cloudflare PoP location. -// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is -// unsuccessful, use the Cloudflare PoP location. -type LoadBalancerUpdateParamsLocationStrategyMode string - -const ( - LoadBalancerUpdateParamsLocationStrategyModePop LoadBalancerUpdateParamsLocationStrategyMode = "pop" - LoadBalancerUpdateParamsLocationStrategyModeResolverIP LoadBalancerUpdateParamsLocationStrategyMode = "resolver_ip" -) - -// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the -// authoritative location. -// -// - `"always"`: Always prefer ECS. -// - `"never"`: Never prefer ECS. -// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. -// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. -type LoadBalancerUpdateParamsLocationStrategyPreferEcs string - -const ( - LoadBalancerUpdateParamsLocationStrategyPreferEcsAlways LoadBalancerUpdateParamsLocationStrategyPreferEcs = "always" - LoadBalancerUpdateParamsLocationStrategyPreferEcsNever LoadBalancerUpdateParamsLocationStrategyPreferEcs = "never" - LoadBalancerUpdateParamsLocationStrategyPreferEcsProximity LoadBalancerUpdateParamsLocationStrategyPreferEcs = "proximity" - LoadBalancerUpdateParamsLocationStrategyPreferEcsGeo LoadBalancerUpdateParamsLocationStrategyPreferEcs = "geo" -) - -// Configures pool weights. -// -// - `steering_policy="random"`: A random pool is selected with probability -// proportional to pool weights. -// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each -// pool's outstanding requests. -// - `steering_policy="least_connections"`: Use pool weights to scale each pool's -// open connections. -type LoadBalancerUpdateParamsRandomSteering struct { - // The default weight for pools in the load balancer that are not specified in the - // pool_weights map. - DefaultWeight param.Field[float64] `json:"default_weight"` - // A mapping of pool IDs to custom weights. The weight is relative to other pools - // in the load balancer. - PoolWeights param.Field[interface{}] `json:"pool_weights"` -} - -func (r LoadBalancerUpdateParamsRandomSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A rule object containing conditions and overrides for this load balancer to -// evaluate. -type LoadBalancerUpdateParamsRule struct { - // The condition expressions to evaluate. If the condition evaluates to true, the - // overrides or fixed_response in this rule will be applied. An empty condition is - // always true. For more details on condition expressions, please see - // https://developers.cloudflare.com/load-balancing/understand-basics/load-balancing-rules/expressions. - Condition param.Field[string] `json:"condition"` - // Disable this specific rule. It will no longer be evaluated by this load - // balancer. - Disabled param.Field[bool] `json:"disabled"` - // A collection of fields used to directly respond to the eyeball instead of - // routing to a pool. If a fixed_response is supplied the rule will be marked as - // terminates. - FixedResponse param.Field[LoadBalancerUpdateParamsRulesFixedResponse] `json:"fixed_response"` - // Name of this rule. Only used for human readability. - Name param.Field[string] `json:"name"` - // A collection of overrides to apply to the load balancer when this rule's - // condition is true. All fields are optional. - Overrides param.Field[LoadBalancerUpdateParamsRulesOverrides] `json:"overrides"` - // The order in which rules should be executed in relation to each other. Lower - // values are executed first. Values do not need to be sequential. If no value is - // provided for any rule the array order of the rules field will be used to assign - // a priority. - Priority param.Field[int64] `json:"priority"` - // If this rule's condition is true, this causes rule evaluation to stop after - // processing this rule. - Terminates param.Field[bool] `json:"terminates"` -} - -func (r LoadBalancerUpdateParamsRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A collection of fields used to directly respond to the eyeball instead of -// routing to a pool. If a fixed_response is supplied the rule will be marked as -// terminates. -type LoadBalancerUpdateParamsRulesFixedResponse struct { - // The http 'Content-Type' header to include in the response. - ContentType param.Field[string] `json:"content_type"` - // The http 'Location' header to include in the response. - Location param.Field[string] `json:"location"` - // Text to include as the http body. - MessageBody param.Field[string] `json:"message_body"` - // The http status code to respond with. - StatusCode param.Field[int64] `json:"status_code"` -} - -func (r LoadBalancerUpdateParamsRulesFixedResponse) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A collection of overrides to apply to the load balancer when this rule's -// condition is true. All fields are optional. -type LoadBalancerUpdateParamsRulesOverrides struct { - // Controls features that modify the routing of requests to pools and origins in - // response to dynamic conditions, such as during the interval between active - // health monitoring requests. For example, zero-downtime failover occurs - // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 - // response codes. If there is another healthy origin in the same pool, the request - // is retried once against this alternate origin. - AdaptiveRouting param.Field[LoadBalancerUpdateParamsRulesOverridesAdaptiveRouting] `json:"adaptive_routing"` - // A mapping of country codes to a list of pool IDs (ordered by their failover - // priority) for the given country. Any country not explicitly defined will fall - // back to using the corresponding region_pool mapping if it exists else to - // default_pools. - CountryPools param.Field[interface{}] `json:"country_pools"` - // A list of pool IDs ordered by their failover priority. Pools defined here are - // used by default, or when region_pools are not configured for a given region. - DefaultPools param.Field[[]string] `json:"default_pools"` - // The pool ID to use when all other pools are detected as unhealthy. - FallbackPool param.Field[interface{}] `json:"fallback_pool"` - // Controls location-based steering for non-proxied requests. See `steering_policy` - // to learn how steering is affected. - LocationStrategy param.Field[LoadBalancerUpdateParamsRulesOverridesLocationStrategy] `json:"location_strategy"` - // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs - // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not - // explicitly defined will fall back to using the corresponding country_pool, then - // region_pool mapping if it exists else to default_pools. - PopPools param.Field[interface{}] `json:"pop_pools"` - // Configures pool weights. - // - // - `steering_policy="random"`: A random pool is selected with probability - // proportional to pool weights. - // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each - // pool's outstanding requests. - // - `steering_policy="least_connections"`: Use pool weights to scale each pool's - // open connections. - RandomSteering param.Field[LoadBalancerUpdateParamsRulesOverridesRandomSteering] `json:"random_steering"` - // A mapping of region codes to a list of pool IDs (ordered by their failover - // priority) for the given region. Any regions not explicitly defined will fall - // back to using default_pools. - RegionPools param.Field[interface{}] `json:"region_pools"` - // Specifies the type of session affinity the load balancer should use unless - // specified as `"none"` or "" (default). The supported types are: - // - // - `"cookie"`: On the first request to a proxied load balancer, a cookie is - // generated, encoding information of which origin the request will be forwarded - // to. Subsequent requests, by the same client to the same load balancer, will be - // sent to the origin server the cookie encodes, for the duration of the cookie - // and as long as the origin server remains healthy. If the cookie has expired or - // the origin server is unhealthy, then a new origin server is calculated and - // used. - // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin - // selection is stable and based on the client's ip address. - // - `"header"`: On the first request to a proxied load balancer, a session key - // based on the configured HTTP headers (see - // `session_affinity_attributes.headers`) is generated, encoding the request - // headers used for storing in the load balancer session state which origin the - // request will be forwarded to. Subsequent requests to the load balancer with - // the same headers will be sent to the same origin server, for the duration of - // the session and as long as the origin server remains healthy. If the session - // has been idle for the duration of `session_affinity_ttl` seconds or the origin - // server is unhealthy, then a new origin server is calculated and used. See - // `headers` in `session_affinity_attributes` for additional required - // configuration. - SessionAffinity param.Field[LoadBalancerUpdateParamsRulesOverridesSessionAffinity] `json:"session_affinity"` - // Configures attributes for session affinity. - SessionAffinityAttributes param.Field[LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributes] `json:"session_affinity_attributes"` - // Time, in seconds, until a client's session expires after being created. Once the - // expiry time has been reached, subsequent requests may get sent to a different - // origin server. The accepted ranges per `session_affinity` policy are: - // - // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used - // unless explicitly set. The accepted range of values is between [1800, 604800]. - // - `"header"`: The current default of 1800 seconds will be used unless explicitly - // set. The accepted range of values is between [30, 3600]. Note: With session - // affinity by header, sessions only expire after they haven't been used for the - // number of seconds specified. - SessionAffinityTTL param.Field[float64] `json:"session_affinity_ttl"` - // Steering Policy for this load balancer. - // - // - `"off"`: Use `default_pools`. - // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied - // requests, the country for `country_pools` is determined by - // `location_strategy`. - // - `"random"`: Select a pool randomly. - // - `"dynamic_latency"`: Use round trip time to select the closest pool in - // default_pools (requires pool health checks). - // - `"proximity"`: Use the pools' latitude and longitude to select the closest - // pool using the Cloudflare PoP location for proxied requests or the location - // determined by `location_strategy` for non-proxied requests. - // - `"least_outstanding_requests"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of outstanding - // requests. Pools with more pending requests are weighted proportionately less - // relative to others. - // - `"least_connections"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of open connections. - // Pools with more open connections are weighted proportionately less relative to - // others. Supported for HTTP/1 and HTTP/2 connections. - // - `""`: Will map to `"geo"` if you use - // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. - SteeringPolicy param.Field[LoadBalancerUpdateParamsRulesOverridesSteeringPolicy] `json:"steering_policy"` - // Time to live (TTL) of the DNS entry for the IP address returned by this load - // balancer. This only applies to gray-clouded (unproxied) load balancers. - TTL param.Field[float64] `json:"ttl"` -} - -func (r LoadBalancerUpdateParamsRulesOverrides) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Controls features that modify the routing of requests to pools and origins in -// response to dynamic conditions, such as during the interval between active -// health monitoring requests. For example, zero-downtime failover occurs -// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 -// response codes. If there is another healthy origin in the same pool, the request -// is retried once against this alternate origin. -type LoadBalancerUpdateParamsRulesOverridesAdaptiveRouting struct { - // Extends zero-downtime failover of requests to healthy origins from alternate - // pools, when no healthy alternate exists in the same pool, according to the - // failover order defined by traffic and origin steering. When set false (the - // default) zero-downtime failover will only occur between origins within the same - // pool. See `session_affinity_attributes` for control over when sessions are - // broken or reassigned. - FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` -} - -func (r LoadBalancerUpdateParamsRulesOverridesAdaptiveRouting) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Controls location-based steering for non-proxied requests. See `steering_policy` -// to learn how steering is affected. -type LoadBalancerUpdateParamsRulesOverridesLocationStrategy struct { - // Determines the authoritative location when ECS is not preferred, does not exist - // in the request, or its GeoIP lookup is unsuccessful. - // - // - `"pop"`: Use the Cloudflare PoP location. - // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is - // unsuccessful, use the Cloudflare PoP location. - Mode param.Field[LoadBalancerUpdateParamsRulesOverridesLocationStrategyMode] `json:"mode"` - // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the - // authoritative location. - // - // - `"always"`: Always prefer ECS. - // - `"never"`: Never prefer ECS. - // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. - // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. - PreferEcs param.Field[LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs] `json:"prefer_ecs"` -} - -func (r LoadBalancerUpdateParamsRulesOverridesLocationStrategy) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Determines the authoritative location when ECS is not preferred, does not exist -// in the request, or its GeoIP lookup is unsuccessful. -// -// - `"pop"`: Use the Cloudflare PoP location. -// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is -// unsuccessful, use the Cloudflare PoP location. -type LoadBalancerUpdateParamsRulesOverridesLocationStrategyMode string - -const ( - LoadBalancerUpdateParamsRulesOverridesLocationStrategyModePop LoadBalancerUpdateParamsRulesOverridesLocationStrategyMode = "pop" - LoadBalancerUpdateParamsRulesOverridesLocationStrategyModeResolverIP LoadBalancerUpdateParamsRulesOverridesLocationStrategyMode = "resolver_ip" -) - -// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the -// authoritative location. -// -// - `"always"`: Always prefer ECS. -// - `"never"`: Never prefer ECS. -// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. -// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. -type LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs string - -const ( - LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsAlways LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs = "always" - LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsNever LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs = "never" - LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsProximity LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs = "proximity" - LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsGeo LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcs = "geo" -) - -// Configures pool weights. -// -// - `steering_policy="random"`: A random pool is selected with probability -// proportional to pool weights. -// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each -// pool's outstanding requests. -// - `steering_policy="least_connections"`: Use pool weights to scale each pool's -// open connections. -type LoadBalancerUpdateParamsRulesOverridesRandomSteering struct { - // The default weight for pools in the load balancer that are not specified in the - // pool_weights map. - DefaultWeight param.Field[float64] `json:"default_weight"` - // A mapping of pool IDs to custom weights. The weight is relative to other pools - // in the load balancer. - PoolWeights param.Field[interface{}] `json:"pool_weights"` -} - -func (r LoadBalancerUpdateParamsRulesOverridesRandomSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Specifies the type of session affinity the load balancer should use unless -// specified as `"none"` or "" (default). The supported types are: -// -// - `"cookie"`: On the first request to a proxied load balancer, a cookie is -// generated, encoding information of which origin the request will be forwarded -// to. Subsequent requests, by the same client to the same load balancer, will be -// sent to the origin server the cookie encodes, for the duration of the cookie -// and as long as the origin server remains healthy. If the cookie has expired or -// the origin server is unhealthy, then a new origin server is calculated and -// used. -// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin -// selection is stable and based on the client's ip address. -// - `"header"`: On the first request to a proxied load balancer, a session key -// based on the configured HTTP headers (see -// `session_affinity_attributes.headers`) is generated, encoding the request -// headers used for storing in the load balancer session state which origin the -// request will be forwarded to. Subsequent requests to the load balancer with -// the same headers will be sent to the same origin server, for the duration of -// the session and as long as the origin server remains healthy. If the session -// has been idle for the duration of `session_affinity_ttl` seconds or the origin -// server is unhealthy, then a new origin server is calculated and used. See -// `headers` in `session_affinity_attributes` for additional required -// configuration. -type LoadBalancerUpdateParamsRulesOverridesSessionAffinity string - -const ( - LoadBalancerUpdateParamsRulesOverridesSessionAffinityNone LoadBalancerUpdateParamsRulesOverridesSessionAffinity = "none" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityCookie LoadBalancerUpdateParamsRulesOverridesSessionAffinity = "cookie" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityIPCookie LoadBalancerUpdateParamsRulesOverridesSessionAffinity = "ip_cookie" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityHeader LoadBalancerUpdateParamsRulesOverridesSessionAffinity = "header" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityEmpty LoadBalancerUpdateParamsRulesOverridesSessionAffinity = "\"\"" -) - -// Configures attributes for session affinity. -type LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributes struct { - // Configures the drain duration in seconds. This field is only used when session - // affinity is enabled on the load balancer. - DrainDuration param.Field[float64] `json:"drain_duration"` - // Configures the names of HTTP headers to base session affinity on when header - // `session_affinity` is enabled. At least one HTTP header name must be provided. - // To specify the exact cookies to be used, include an item in the following - // format: `"cookie:,"` (example) where everything - // after the colon is a comma-separated list of cookie names. Providing only - // `"cookie"` will result in all cookies being used. The default max number of HTTP - // header names that can be provided depends on your plan: 5 for Enterprise, 1 for - // all other plans. - Headers param.Field[[]string] `json:"headers"` - // When header `session_affinity` is enabled, this option can be used to specify - // how HTTP headers on load balancing requests will be used. The supported values - // are: - // - // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers - // specified by the `headers` session affinity attribute, otherwise sessions - // aren't created. - // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP - // headers specified by the `headers` session affinity attribute, otherwise - // sessions aren't created. - RequireAllHeaders param.Field[bool] `json:"require_all_headers"` - // Configures the SameSite attribute on session affinity cookie. Value "Auto" will - // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: - // when using value "None", the secure attribute can not be set to "Never". - Samesite param.Field[LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite] `json:"samesite"` - // Configures the Secure attribute on session affinity cookie. Value "Always" - // indicates the Secure attribute will be set in the Set-Cookie header, "Never" - // indicates the Secure attribute will not be set, and "Auto" will set the Secure - // attribute depending if Always Use HTTPS is enabled. - Secure param.Field[LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecure] `json:"secure"` - // Configures the zero-downtime failover between origins within a pool when session - // affinity is enabled. This feature is currently incompatible with Argo, Tiered - // Cache, and Bandwidth Alliance. The supported values are: - // - // - `"none"`: No failover takes place for sessions pinned to the origin (default). - // - `"temporary"`: Traffic will be sent to another other healthy origin until the - // originally pinned origin is available; note that this can potentially result - // in heavy origin flapping. - // - `"sticky"`: The session affinity cookie is updated and subsequent requests are - // sent to the new origin. Note: Zero-downtime failover with sticky sessions is - // currently not supported for session affinity by header. - ZeroDowntimeFailover param.Field[LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` -} - -func (r LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures the SameSite attribute on session affinity cookie. Value "Auto" will -// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: -// when using value "None", the secure attribute can not be set to "Never". -type LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite string - -const ( - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteAuto LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite = "Auto" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteLax LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite = "Lax" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteNone LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite = "None" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteStrict LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesite = "Strict" -) - -// Configures the Secure attribute on session affinity cookie. Value "Always" -// indicates the Secure attribute will be set in the Set-Cookie header, "Never" -// indicates the Secure attribute will not be set, and "Auto" will set the Secure -// attribute depending if Always Use HTTPS is enabled. -type LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecure string - -const ( - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureAuto LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecure = "Auto" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureAlways LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecure = "Always" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureNever LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecure = "Never" -) - -// Configures the zero-downtime failover between origins within a pool when session -// affinity is enabled. This feature is currently incompatible with Argo, Tiered -// Cache, and Bandwidth Alliance. The supported values are: -// -// - `"none"`: No failover takes place for sessions pinned to the origin (default). -// - `"temporary"`: Traffic will be sent to another other healthy origin until the -// originally pinned origin is available; note that this can potentially result -// in heavy origin flapping. -// - `"sticky"`: The session affinity cookie is updated and subsequent requests are -// sent to the new origin. Note: Zero-downtime failover with sticky sessions is -// currently not supported for session affinity by header. -type LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover string - -const ( - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "none" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "temporary" - LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "sticky" -) - -// Steering Policy for this load balancer. -// -// - `"off"`: Use `default_pools`. -// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied -// requests, the country for `country_pools` is determined by -// `location_strategy`. -// - `"random"`: Select a pool randomly. -// - `"dynamic_latency"`: Use round trip time to select the closest pool in -// default_pools (requires pool health checks). -// - `"proximity"`: Use the pools' latitude and longitude to select the closest -// pool using the Cloudflare PoP location for proxied requests or the location -// determined by `location_strategy` for non-proxied requests. -// - `"least_outstanding_requests"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of outstanding -// requests. Pools with more pending requests are weighted proportionately less -// relative to others. -// - `"least_connections"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of open connections. -// Pools with more open connections are weighted proportionately less relative to -// others. Supported for HTTP/1 and HTTP/2 connections. -// - `""`: Will map to `"geo"` if you use -// `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. -type LoadBalancerUpdateParamsRulesOverridesSteeringPolicy string - -const ( - LoadBalancerUpdateParamsRulesOverridesSteeringPolicyOff LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "off" - LoadBalancerUpdateParamsRulesOverridesSteeringPolicyGeo LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "geo" - LoadBalancerUpdateParamsRulesOverridesSteeringPolicyRandom LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "random" - LoadBalancerUpdateParamsRulesOverridesSteeringPolicyDynamicLatency LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "dynamic_latency" - LoadBalancerUpdateParamsRulesOverridesSteeringPolicyProximity LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "proximity" - LoadBalancerUpdateParamsRulesOverridesSteeringPolicyLeastOutstandingRequests LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "least_outstanding_requests" - LoadBalancerUpdateParamsRulesOverridesSteeringPolicyLeastConnections LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "least_connections" - LoadBalancerUpdateParamsRulesOverridesSteeringPolicyEmpty LoadBalancerUpdateParamsRulesOverridesSteeringPolicy = "\"\"" -) - -// Specifies the type of session affinity the load balancer should use unless -// specified as `"none"` or "" (default). The supported types are: -// -// - `"cookie"`: On the first request to a proxied load balancer, a cookie is -// generated, encoding information of which origin the request will be forwarded -// to. Subsequent requests, by the same client to the same load balancer, will be -// sent to the origin server the cookie encodes, for the duration of the cookie -// and as long as the origin server remains healthy. If the cookie has expired or -// the origin server is unhealthy, then a new origin server is calculated and -// used. -// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin -// selection is stable and based on the client's ip address. -// - `"header"`: On the first request to a proxied load balancer, a session key -// based on the configured HTTP headers (see -// `session_affinity_attributes.headers`) is generated, encoding the request -// headers used for storing in the load balancer session state which origin the -// request will be forwarded to. Subsequent requests to the load balancer with -// the same headers will be sent to the same origin server, for the duration of -// the session and as long as the origin server remains healthy. If the session -// has been idle for the duration of `session_affinity_ttl` seconds or the origin -// server is unhealthy, then a new origin server is calculated and used. See -// `headers` in `session_affinity_attributes` for additional required -// configuration. -type LoadBalancerUpdateParamsSessionAffinity string - -const ( - LoadBalancerUpdateParamsSessionAffinityNone LoadBalancerUpdateParamsSessionAffinity = "none" - LoadBalancerUpdateParamsSessionAffinityCookie LoadBalancerUpdateParamsSessionAffinity = "cookie" - LoadBalancerUpdateParamsSessionAffinityIPCookie LoadBalancerUpdateParamsSessionAffinity = "ip_cookie" - LoadBalancerUpdateParamsSessionAffinityHeader LoadBalancerUpdateParamsSessionAffinity = "header" - LoadBalancerUpdateParamsSessionAffinityEmpty LoadBalancerUpdateParamsSessionAffinity = "\"\"" -) - -// Configures attributes for session affinity. -type LoadBalancerUpdateParamsSessionAffinityAttributes struct { - // Configures the drain duration in seconds. This field is only used when session - // affinity is enabled on the load balancer. - DrainDuration param.Field[float64] `json:"drain_duration"` - // Configures the names of HTTP headers to base session affinity on when header - // `session_affinity` is enabled. At least one HTTP header name must be provided. - // To specify the exact cookies to be used, include an item in the following - // format: `"cookie:,"` (example) where everything - // after the colon is a comma-separated list of cookie names. Providing only - // `"cookie"` will result in all cookies being used. The default max number of HTTP - // header names that can be provided depends on your plan: 5 for Enterprise, 1 for - // all other plans. - Headers param.Field[[]string] `json:"headers"` - // When header `session_affinity` is enabled, this option can be used to specify - // how HTTP headers on load balancing requests will be used. The supported values - // are: - // - // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers - // specified by the `headers` session affinity attribute, otherwise sessions - // aren't created. - // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP - // headers specified by the `headers` session affinity attribute, otherwise - // sessions aren't created. - RequireAllHeaders param.Field[bool] `json:"require_all_headers"` - // Configures the SameSite attribute on session affinity cookie. Value "Auto" will - // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: - // when using value "None", the secure attribute can not be set to "Never". - Samesite param.Field[LoadBalancerUpdateParamsSessionAffinityAttributesSamesite] `json:"samesite"` - // Configures the Secure attribute on session affinity cookie. Value "Always" - // indicates the Secure attribute will be set in the Set-Cookie header, "Never" - // indicates the Secure attribute will not be set, and "Auto" will set the Secure - // attribute depending if Always Use HTTPS is enabled. - Secure param.Field[LoadBalancerUpdateParamsSessionAffinityAttributesSecure] `json:"secure"` - // Configures the zero-downtime failover between origins within a pool when session - // affinity is enabled. This feature is currently incompatible with Argo, Tiered - // Cache, and Bandwidth Alliance. The supported values are: - // - // - `"none"`: No failover takes place for sessions pinned to the origin (default). - // - `"temporary"`: Traffic will be sent to another other healthy origin until the - // originally pinned origin is available; note that this can potentially result - // in heavy origin flapping. - // - `"sticky"`: The session affinity cookie is updated and subsequent requests are - // sent to the new origin. Note: Zero-downtime failover with sticky sessions is - // currently not supported for session affinity by header. - ZeroDowntimeFailover param.Field[LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` -} - -func (r LoadBalancerUpdateParamsSessionAffinityAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures the SameSite attribute on session affinity cookie. Value "Auto" will -// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: -// when using value "None", the secure attribute can not be set to "Never". -type LoadBalancerUpdateParamsSessionAffinityAttributesSamesite string - -const ( - LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteAuto LoadBalancerUpdateParamsSessionAffinityAttributesSamesite = "Auto" - LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteLax LoadBalancerUpdateParamsSessionAffinityAttributesSamesite = "Lax" - LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteNone LoadBalancerUpdateParamsSessionAffinityAttributesSamesite = "None" - LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteStrict LoadBalancerUpdateParamsSessionAffinityAttributesSamesite = "Strict" -) - -// Configures the Secure attribute on session affinity cookie. Value "Always" -// indicates the Secure attribute will be set in the Set-Cookie header, "Never" -// indicates the Secure attribute will not be set, and "Auto" will set the Secure -// attribute depending if Always Use HTTPS is enabled. -type LoadBalancerUpdateParamsSessionAffinityAttributesSecure string - -const ( - LoadBalancerUpdateParamsSessionAffinityAttributesSecureAuto LoadBalancerUpdateParamsSessionAffinityAttributesSecure = "Auto" - LoadBalancerUpdateParamsSessionAffinityAttributesSecureAlways LoadBalancerUpdateParamsSessionAffinityAttributesSecure = "Always" - LoadBalancerUpdateParamsSessionAffinityAttributesSecureNever LoadBalancerUpdateParamsSessionAffinityAttributesSecure = "Never" -) - -// Configures the zero-downtime failover between origins within a pool when session -// affinity is enabled. This feature is currently incompatible with Argo, Tiered -// Cache, and Bandwidth Alliance. The supported values are: -// -// - `"none"`: No failover takes place for sessions pinned to the origin (default). -// - `"temporary"`: Traffic will be sent to another other healthy origin until the -// originally pinned origin is available; note that this can potentially result -// in heavy origin flapping. -// - `"sticky"`: The session affinity cookie is updated and subsequent requests are -// sent to the new origin. Note: Zero-downtime failover with sticky sessions is -// currently not supported for session affinity by header. -type LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailover string - -const ( - LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailover = "none" - LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailover = "temporary" - LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailover = "sticky" -) - -// Steering Policy for this load balancer. -// -// - `"off"`: Use `default_pools`. -// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied -// requests, the country for `country_pools` is determined by -// `location_strategy`. -// - `"random"`: Select a pool randomly. -// - `"dynamic_latency"`: Use round trip time to select the closest pool in -// default_pools (requires pool health checks). -// - `"proximity"`: Use the pools' latitude and longitude to select the closest -// pool using the Cloudflare PoP location for proxied requests or the location -// determined by `location_strategy` for non-proxied requests. -// - `"least_outstanding_requests"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of outstanding -// requests. Pools with more pending requests are weighted proportionately less -// relative to others. -// - `"least_connections"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of open connections. -// Pools with more open connections are weighted proportionately less relative to -// others. Supported for HTTP/1 and HTTP/2 connections. -// - `""`: Will map to `"geo"` if you use -// `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. -type LoadBalancerUpdateParamsSteeringPolicy string - -const ( - LoadBalancerUpdateParamsSteeringPolicyOff LoadBalancerUpdateParamsSteeringPolicy = "off" - LoadBalancerUpdateParamsSteeringPolicyGeo LoadBalancerUpdateParamsSteeringPolicy = "geo" - LoadBalancerUpdateParamsSteeringPolicyRandom LoadBalancerUpdateParamsSteeringPolicy = "random" - LoadBalancerUpdateParamsSteeringPolicyDynamicLatency LoadBalancerUpdateParamsSteeringPolicy = "dynamic_latency" - LoadBalancerUpdateParamsSteeringPolicyProximity LoadBalancerUpdateParamsSteeringPolicy = "proximity" - LoadBalancerUpdateParamsSteeringPolicyLeastOutstandingRequests LoadBalancerUpdateParamsSteeringPolicy = "least_outstanding_requests" - LoadBalancerUpdateParamsSteeringPolicyLeastConnections LoadBalancerUpdateParamsSteeringPolicy = "least_connections" - LoadBalancerUpdateParamsSteeringPolicyEmpty LoadBalancerUpdateParamsSteeringPolicy = "\"\"" -) - -type LoadBalancerUpdateResponseEnvelope struct { - Errors []LoadBalancerUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerUpdateResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancer `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerUpdateResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [LoadBalancerUpdateResponseEnvelope] -type loadBalancerUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LoadBalancerUpdateResponseEnvelopeErrors] -type loadBalancerUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [LoadBalancerUpdateResponseEnvelopeMessages] -type loadBalancerUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerUpdateResponseEnvelopeSuccess bool - -const ( - LoadBalancerUpdateResponseEnvelopeSuccessTrue LoadBalancerUpdateResponseEnvelopeSuccess = true -) - -type LoadBalancerListParams struct { - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type LoadBalancerListResponseEnvelope struct { - Errors []LoadBalancerListResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerListResponseEnvelopeMessages `json:"messages,required"` - Result []LoadBalancer `json:"result,required,nullable"` - // Whether the API call was successful - Success LoadBalancerListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo LoadBalancerListResponseEnvelopeResultInfo `json:"result_info"` - JSON loadBalancerListResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerListResponseEnvelopeJSON contains the JSON metadata for the struct -// [LoadBalancerListResponseEnvelope] -type loadBalancerListResponseEnvelopeJSON 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 *LoadBalancerListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerListResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LoadBalancerListResponseEnvelopeErrors] -type loadBalancerListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerListResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LoadBalancerListResponseEnvelopeMessages] -type loadBalancerListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerListResponseEnvelopeSuccess bool - -const ( - LoadBalancerListResponseEnvelopeSuccessTrue LoadBalancerListResponseEnvelopeSuccess = true -) - -type LoadBalancerListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON loadBalancerListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// loadBalancerListResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [LoadBalancerListResponseEnvelopeResultInfo] -type loadBalancerListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerDeleteParams struct { - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type LoadBalancerDeleteResponseEnvelope struct { - Errors []LoadBalancerDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerDeleteResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerDeleteResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [LoadBalancerDeleteResponseEnvelope] -type loadBalancerDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LoadBalancerDeleteResponseEnvelopeErrors] -type loadBalancerDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [LoadBalancerDeleteResponseEnvelopeMessages] -type loadBalancerDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerDeleteResponseEnvelopeSuccess bool - -const ( - LoadBalancerDeleteResponseEnvelopeSuccessTrue LoadBalancerDeleteResponseEnvelopeSuccess = true -) - -type LoadBalancerEditParams struct { - ZoneID param.Field[string] `path:"zone_id,required"` - // Controls features that modify the routing of requests to pools and origins in - // response to dynamic conditions, such as during the interval between active - // health monitoring requests. For example, zero-downtime failover occurs - // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 - // response codes. If there is another healthy origin in the same pool, the request - // is retried once against this alternate origin. - AdaptiveRouting param.Field[LoadBalancerEditParamsAdaptiveRouting] `json:"adaptive_routing"` - // A mapping of country codes to a list of pool IDs (ordered by their failover - // priority) for the given country. Any country not explicitly defined will fall - // back to using the corresponding region_pool mapping if it exists else to - // default_pools. - CountryPools param.Field[interface{}] `json:"country_pools"` - // A list of pool IDs ordered by their failover priority. Pools defined here are - // used by default, or when region_pools are not configured for a given region. - DefaultPools param.Field[[]string] `json:"default_pools"` - // Object description. - Description param.Field[string] `json:"description"` - // Whether to enable (the default) this load balancer. - Enabled param.Field[bool] `json:"enabled"` - // The pool ID to use when all other pools are detected as unhealthy. - FallbackPool param.Field[interface{}] `json:"fallback_pool"` - // Controls location-based steering for non-proxied requests. See `steering_policy` - // to learn how steering is affected. - LocationStrategy param.Field[LoadBalancerEditParamsLocationStrategy] `json:"location_strategy"` - // The DNS hostname to associate with your Load Balancer. If this hostname already - // exists as a DNS record in Cloudflare's DNS, the Load Balancer will take - // precedence and the DNS record will not be used. - Name param.Field[string] `json:"name"` - // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs - // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not - // explicitly defined will fall back to using the corresponding country_pool, then - // region_pool mapping if it exists else to default_pools. - PopPools param.Field[interface{}] `json:"pop_pools"` - // Whether the hostname should be gray clouded (false) or orange clouded (true). - Proxied param.Field[bool] `json:"proxied"` - // Configures pool weights. - // - // - `steering_policy="random"`: A random pool is selected with probability - // proportional to pool weights. - // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each - // pool's outstanding requests. - // - `steering_policy="least_connections"`: Use pool weights to scale each pool's - // open connections. - RandomSteering param.Field[LoadBalancerEditParamsRandomSteering] `json:"random_steering"` - // A mapping of region codes to a list of pool IDs (ordered by their failover - // priority) for the given region. Any regions not explicitly defined will fall - // back to using default_pools. - RegionPools param.Field[interface{}] `json:"region_pools"` - // BETA Field Not General Access: A list of rules for this load balancer to - // execute. - Rules param.Field[[]LoadBalancerEditParamsRule] `json:"rules"` - // Specifies the type of session affinity the load balancer should use unless - // specified as `"none"` or "" (default). The supported types are: - // - // - `"cookie"`: On the first request to a proxied load balancer, a cookie is - // generated, encoding information of which origin the request will be forwarded - // to. Subsequent requests, by the same client to the same load balancer, will be - // sent to the origin server the cookie encodes, for the duration of the cookie - // and as long as the origin server remains healthy. If the cookie has expired or - // the origin server is unhealthy, then a new origin server is calculated and - // used. - // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin - // selection is stable and based on the client's ip address. - // - `"header"`: On the first request to a proxied load balancer, a session key - // based on the configured HTTP headers (see - // `session_affinity_attributes.headers`) is generated, encoding the request - // headers used for storing in the load balancer session state which origin the - // request will be forwarded to. Subsequent requests to the load balancer with - // the same headers will be sent to the same origin server, for the duration of - // the session and as long as the origin server remains healthy. If the session - // has been idle for the duration of `session_affinity_ttl` seconds or the origin - // server is unhealthy, then a new origin server is calculated and used. See - // `headers` in `session_affinity_attributes` for additional required - // configuration. - SessionAffinity param.Field[LoadBalancerEditParamsSessionAffinity] `json:"session_affinity"` - // Configures attributes for session affinity. - SessionAffinityAttributes param.Field[LoadBalancerEditParamsSessionAffinityAttributes] `json:"session_affinity_attributes"` - // Time, in seconds, until a client's session expires after being created. Once the - // expiry time has been reached, subsequent requests may get sent to a different - // origin server. The accepted ranges per `session_affinity` policy are: - // - // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used - // unless explicitly set. The accepted range of values is between [1800, 604800]. - // - `"header"`: The current default of 1800 seconds will be used unless explicitly - // set. The accepted range of values is between [30, 3600]. Note: With session - // affinity by header, sessions only expire after they haven't been used for the - // number of seconds specified. - SessionAffinityTTL param.Field[float64] `json:"session_affinity_ttl"` - // Steering Policy for this load balancer. - // - // - `"off"`: Use `default_pools`. - // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied - // requests, the country for `country_pools` is determined by - // `location_strategy`. - // - `"random"`: Select a pool randomly. - // - `"dynamic_latency"`: Use round trip time to select the closest pool in - // default_pools (requires pool health checks). - // - `"proximity"`: Use the pools' latitude and longitude to select the closest - // pool using the Cloudflare PoP location for proxied requests or the location - // determined by `location_strategy` for non-proxied requests. - // - `"least_outstanding_requests"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of outstanding - // requests. Pools with more pending requests are weighted proportionately less - // relative to others. - // - `"least_connections"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of open connections. - // Pools with more open connections are weighted proportionately less relative to - // others. Supported for HTTP/1 and HTTP/2 connections. - // - `""`: Will map to `"geo"` if you use - // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. - SteeringPolicy param.Field[LoadBalancerEditParamsSteeringPolicy] `json:"steering_policy"` - // Time to live (TTL) of the DNS entry for the IP address returned by this load - // balancer. This only applies to gray-clouded (unproxied) load balancers. - TTL param.Field[float64] `json:"ttl"` -} - -func (r LoadBalancerEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Controls features that modify the routing of requests to pools and origins in -// response to dynamic conditions, such as during the interval between active -// health monitoring requests. For example, zero-downtime failover occurs -// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 -// response codes. If there is another healthy origin in the same pool, the request -// is retried once against this alternate origin. -type LoadBalancerEditParamsAdaptiveRouting struct { - // Extends zero-downtime failover of requests to healthy origins from alternate - // pools, when no healthy alternate exists in the same pool, according to the - // failover order defined by traffic and origin steering. When set false (the - // default) zero-downtime failover will only occur between origins within the same - // pool. See `session_affinity_attributes` for control over when sessions are - // broken or reassigned. - FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` -} - -func (r LoadBalancerEditParamsAdaptiveRouting) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Controls location-based steering for non-proxied requests. See `steering_policy` -// to learn how steering is affected. -type LoadBalancerEditParamsLocationStrategy struct { - // Determines the authoritative location when ECS is not preferred, does not exist - // in the request, or its GeoIP lookup is unsuccessful. - // - // - `"pop"`: Use the Cloudflare PoP location. - // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is - // unsuccessful, use the Cloudflare PoP location. - Mode param.Field[LoadBalancerEditParamsLocationStrategyMode] `json:"mode"` - // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the - // authoritative location. - // - // - `"always"`: Always prefer ECS. - // - `"never"`: Never prefer ECS. - // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. - // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. - PreferEcs param.Field[LoadBalancerEditParamsLocationStrategyPreferEcs] `json:"prefer_ecs"` -} - -func (r LoadBalancerEditParamsLocationStrategy) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Determines the authoritative location when ECS is not preferred, does not exist -// in the request, or its GeoIP lookup is unsuccessful. -// -// - `"pop"`: Use the Cloudflare PoP location. -// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is -// unsuccessful, use the Cloudflare PoP location. -type LoadBalancerEditParamsLocationStrategyMode string - -const ( - LoadBalancerEditParamsLocationStrategyModePop LoadBalancerEditParamsLocationStrategyMode = "pop" - LoadBalancerEditParamsLocationStrategyModeResolverIP LoadBalancerEditParamsLocationStrategyMode = "resolver_ip" -) - -// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the -// authoritative location. -// -// - `"always"`: Always prefer ECS. -// - `"never"`: Never prefer ECS. -// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. -// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. -type LoadBalancerEditParamsLocationStrategyPreferEcs string - -const ( - LoadBalancerEditParamsLocationStrategyPreferEcsAlways LoadBalancerEditParamsLocationStrategyPreferEcs = "always" - LoadBalancerEditParamsLocationStrategyPreferEcsNever LoadBalancerEditParamsLocationStrategyPreferEcs = "never" - LoadBalancerEditParamsLocationStrategyPreferEcsProximity LoadBalancerEditParamsLocationStrategyPreferEcs = "proximity" - LoadBalancerEditParamsLocationStrategyPreferEcsGeo LoadBalancerEditParamsLocationStrategyPreferEcs = "geo" -) - -// Configures pool weights. -// -// - `steering_policy="random"`: A random pool is selected with probability -// proportional to pool weights. -// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each -// pool's outstanding requests. -// - `steering_policy="least_connections"`: Use pool weights to scale each pool's -// open connections. -type LoadBalancerEditParamsRandomSteering struct { - // The default weight for pools in the load balancer that are not specified in the - // pool_weights map. - DefaultWeight param.Field[float64] `json:"default_weight"` - // A mapping of pool IDs to custom weights. The weight is relative to other pools - // in the load balancer. - PoolWeights param.Field[interface{}] `json:"pool_weights"` -} - -func (r LoadBalancerEditParamsRandomSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A rule object containing conditions and overrides for this load balancer to -// evaluate. -type LoadBalancerEditParamsRule struct { - // The condition expressions to evaluate. If the condition evaluates to true, the - // overrides or fixed_response in this rule will be applied. An empty condition is - // always true. For more details on condition expressions, please see - // https://developers.cloudflare.com/load-balancing/understand-basics/load-balancing-rules/expressions. - Condition param.Field[string] `json:"condition"` - // Disable this specific rule. It will no longer be evaluated by this load - // balancer. - Disabled param.Field[bool] `json:"disabled"` - // A collection of fields used to directly respond to the eyeball instead of - // routing to a pool. If a fixed_response is supplied the rule will be marked as - // terminates. - FixedResponse param.Field[LoadBalancerEditParamsRulesFixedResponse] `json:"fixed_response"` - // Name of this rule. Only used for human readability. - Name param.Field[string] `json:"name"` - // A collection of overrides to apply to the load balancer when this rule's - // condition is true. All fields are optional. - Overrides param.Field[LoadBalancerEditParamsRulesOverrides] `json:"overrides"` - // The order in which rules should be executed in relation to each other. Lower - // values are executed first. Values do not need to be sequential. If no value is - // provided for any rule the array order of the rules field will be used to assign - // a priority. - Priority param.Field[int64] `json:"priority"` - // If this rule's condition is true, this causes rule evaluation to stop after - // processing this rule. - Terminates param.Field[bool] `json:"terminates"` -} - -func (r LoadBalancerEditParamsRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A collection of fields used to directly respond to the eyeball instead of -// routing to a pool. If a fixed_response is supplied the rule will be marked as -// terminates. -type LoadBalancerEditParamsRulesFixedResponse struct { - // The http 'Content-Type' header to include in the response. - ContentType param.Field[string] `json:"content_type"` - // The http 'Location' header to include in the response. - Location param.Field[string] `json:"location"` - // Text to include as the http body. - MessageBody param.Field[string] `json:"message_body"` - // The http status code to respond with. - StatusCode param.Field[int64] `json:"status_code"` -} - -func (r LoadBalancerEditParamsRulesFixedResponse) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A collection of overrides to apply to the load balancer when this rule's -// condition is true. All fields are optional. -type LoadBalancerEditParamsRulesOverrides struct { - // Controls features that modify the routing of requests to pools and origins in - // response to dynamic conditions, such as during the interval between active - // health monitoring requests. For example, zero-downtime failover occurs - // immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 - // response codes. If there is another healthy origin in the same pool, the request - // is retried once against this alternate origin. - AdaptiveRouting param.Field[LoadBalancerEditParamsRulesOverridesAdaptiveRouting] `json:"adaptive_routing"` - // A mapping of country codes to a list of pool IDs (ordered by their failover - // priority) for the given country. Any country not explicitly defined will fall - // back to using the corresponding region_pool mapping if it exists else to - // default_pools. - CountryPools param.Field[interface{}] `json:"country_pools"` - // A list of pool IDs ordered by their failover priority. Pools defined here are - // used by default, or when region_pools are not configured for a given region. - DefaultPools param.Field[[]string] `json:"default_pools"` - // The pool ID to use when all other pools are detected as unhealthy. - FallbackPool param.Field[interface{}] `json:"fallback_pool"` - // Controls location-based steering for non-proxied requests. See `steering_policy` - // to learn how steering is affected. - LocationStrategy param.Field[LoadBalancerEditParamsRulesOverridesLocationStrategy] `json:"location_strategy"` - // (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs - // (ordered by their failover priority) for the PoP (datacenter). Any PoPs not - // explicitly defined will fall back to using the corresponding country_pool, then - // region_pool mapping if it exists else to default_pools. - PopPools param.Field[interface{}] `json:"pop_pools"` - // Configures pool weights. - // - // - `steering_policy="random"`: A random pool is selected with probability - // proportional to pool weights. - // - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each - // pool's outstanding requests. - // - `steering_policy="least_connections"`: Use pool weights to scale each pool's - // open connections. - RandomSteering param.Field[LoadBalancerEditParamsRulesOverridesRandomSteering] `json:"random_steering"` - // A mapping of region codes to a list of pool IDs (ordered by their failover - // priority) for the given region. Any regions not explicitly defined will fall - // back to using default_pools. - RegionPools param.Field[interface{}] `json:"region_pools"` - // Specifies the type of session affinity the load balancer should use unless - // specified as `"none"` or "" (default). The supported types are: - // - // - `"cookie"`: On the first request to a proxied load balancer, a cookie is - // generated, encoding information of which origin the request will be forwarded - // to. Subsequent requests, by the same client to the same load balancer, will be - // sent to the origin server the cookie encodes, for the duration of the cookie - // and as long as the origin server remains healthy. If the cookie has expired or - // the origin server is unhealthy, then a new origin server is calculated and - // used. - // - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin - // selection is stable and based on the client's ip address. - // - `"header"`: On the first request to a proxied load balancer, a session key - // based on the configured HTTP headers (see - // `session_affinity_attributes.headers`) is generated, encoding the request - // headers used for storing in the load balancer session state which origin the - // request will be forwarded to. Subsequent requests to the load balancer with - // the same headers will be sent to the same origin server, for the duration of - // the session and as long as the origin server remains healthy. If the session - // has been idle for the duration of `session_affinity_ttl` seconds or the origin - // server is unhealthy, then a new origin server is calculated and used. See - // `headers` in `session_affinity_attributes` for additional required - // configuration. - SessionAffinity param.Field[LoadBalancerEditParamsRulesOverridesSessionAffinity] `json:"session_affinity"` - // Configures attributes for session affinity. - SessionAffinityAttributes param.Field[LoadBalancerEditParamsRulesOverridesSessionAffinityAttributes] `json:"session_affinity_attributes"` - // Time, in seconds, until a client's session expires after being created. Once the - // expiry time has been reached, subsequent requests may get sent to a different - // origin server. The accepted ranges per `session_affinity` policy are: - // - // - `"cookie"` / `"ip_cookie"`: The current default of 23 hours will be used - // unless explicitly set. The accepted range of values is between [1800, 604800]. - // - `"header"`: The current default of 1800 seconds will be used unless explicitly - // set. The accepted range of values is between [30, 3600]. Note: With session - // affinity by header, sessions only expire after they haven't been used for the - // number of seconds specified. - SessionAffinityTTL param.Field[float64] `json:"session_affinity_ttl"` - // Steering Policy for this load balancer. - // - // - `"off"`: Use `default_pools`. - // - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied - // requests, the country for `country_pools` is determined by - // `location_strategy`. - // - `"random"`: Select a pool randomly. - // - `"dynamic_latency"`: Use round trip time to select the closest pool in - // default_pools (requires pool health checks). - // - `"proximity"`: Use the pools' latitude and longitude to select the closest - // pool using the Cloudflare PoP location for proxied requests or the location - // determined by `location_strategy` for non-proxied requests. - // - `"least_outstanding_requests"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of outstanding - // requests. Pools with more pending requests are weighted proportionately less - // relative to others. - // - `"least_connections"`: Select a pool by taking into consideration - // `random_steering` weights, as well as each pool's number of open connections. - // Pools with more open connections are weighted proportionately less relative to - // others. Supported for HTTP/1 and HTTP/2 connections. - // - `""`: Will map to `"geo"` if you use - // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. - SteeringPolicy param.Field[LoadBalancerEditParamsRulesOverridesSteeringPolicy] `json:"steering_policy"` - // Time to live (TTL) of the DNS entry for the IP address returned by this load - // balancer. This only applies to gray-clouded (unproxied) load balancers. - TTL param.Field[float64] `json:"ttl"` -} - -func (r LoadBalancerEditParamsRulesOverrides) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Controls features that modify the routing of requests to pools and origins in -// response to dynamic conditions, such as during the interval between active -// health monitoring requests. For example, zero-downtime failover occurs -// immediately when an origin becomes unavailable due to HTTP 521, 522, or 523 -// response codes. If there is another healthy origin in the same pool, the request -// is retried once against this alternate origin. -type LoadBalancerEditParamsRulesOverridesAdaptiveRouting struct { - // Extends zero-downtime failover of requests to healthy origins from alternate - // pools, when no healthy alternate exists in the same pool, according to the - // failover order defined by traffic and origin steering. When set false (the - // default) zero-downtime failover will only occur between origins within the same - // pool. See `session_affinity_attributes` for control over when sessions are - // broken or reassigned. - FailoverAcrossPools param.Field[bool] `json:"failover_across_pools"` -} - -func (r LoadBalancerEditParamsRulesOverridesAdaptiveRouting) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Controls location-based steering for non-proxied requests. See `steering_policy` -// to learn how steering is affected. -type LoadBalancerEditParamsRulesOverridesLocationStrategy struct { - // Determines the authoritative location when ECS is not preferred, does not exist - // in the request, or its GeoIP lookup is unsuccessful. - // - // - `"pop"`: Use the Cloudflare PoP location. - // - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is - // unsuccessful, use the Cloudflare PoP location. - Mode param.Field[LoadBalancerEditParamsRulesOverridesLocationStrategyMode] `json:"mode"` - // Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the - // authoritative location. - // - // - `"always"`: Always prefer ECS. - // - `"never"`: Never prefer ECS. - // - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. - // - `"geo"`: Prefer ECS only when `steering_policy="geo"`. - PreferEcs param.Field[LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs] `json:"prefer_ecs"` -} - -func (r LoadBalancerEditParamsRulesOverridesLocationStrategy) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Determines the authoritative location when ECS is not preferred, does not exist -// in the request, or its GeoIP lookup is unsuccessful. -// -// - `"pop"`: Use the Cloudflare PoP location. -// - `"resolver_ip"`: Use the DNS resolver GeoIP location. If the GeoIP lookup is -// unsuccessful, use the Cloudflare PoP location. -type LoadBalancerEditParamsRulesOverridesLocationStrategyMode string - -const ( - LoadBalancerEditParamsRulesOverridesLocationStrategyModePop LoadBalancerEditParamsRulesOverridesLocationStrategyMode = "pop" - LoadBalancerEditParamsRulesOverridesLocationStrategyModeResolverIP LoadBalancerEditParamsRulesOverridesLocationStrategyMode = "resolver_ip" -) - -// Whether the EDNS Client Subnet (ECS) GeoIP should be preferred as the -// authoritative location. -// -// - `"always"`: Always prefer ECS. -// - `"never"`: Never prefer ECS. -// - `"proximity"`: Prefer ECS only when `steering_policy="proximity"`. -// - `"geo"`: Prefer ECS only when `steering_policy="geo"`. -type LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs string - -const ( - LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsAlways LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs = "always" - LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsNever LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs = "never" - LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsProximity LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs = "proximity" - LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsGeo LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcs = "geo" -) - -// Configures pool weights. -// -// - `steering_policy="random"`: A random pool is selected with probability -// proportional to pool weights. -// - `steering_policy="least_outstanding_requests"`: Use pool weights to scale each -// pool's outstanding requests. -// - `steering_policy="least_connections"`: Use pool weights to scale each pool's -// open connections. -type LoadBalancerEditParamsRulesOverridesRandomSteering struct { - // The default weight for pools in the load balancer that are not specified in the - // pool_weights map. - DefaultWeight param.Field[float64] `json:"default_weight"` - // A mapping of pool IDs to custom weights. The weight is relative to other pools - // in the load balancer. - PoolWeights param.Field[interface{}] `json:"pool_weights"` -} - -func (r LoadBalancerEditParamsRulesOverridesRandomSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Specifies the type of session affinity the load balancer should use unless -// specified as `"none"` or "" (default). The supported types are: -// -// - `"cookie"`: On the first request to a proxied load balancer, a cookie is -// generated, encoding information of which origin the request will be forwarded -// to. Subsequent requests, by the same client to the same load balancer, will be -// sent to the origin server the cookie encodes, for the duration of the cookie -// and as long as the origin server remains healthy. If the cookie has expired or -// the origin server is unhealthy, then a new origin server is calculated and -// used. -// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin -// selection is stable and based on the client's ip address. -// - `"header"`: On the first request to a proxied load balancer, a session key -// based on the configured HTTP headers (see -// `session_affinity_attributes.headers`) is generated, encoding the request -// headers used for storing in the load balancer session state which origin the -// request will be forwarded to. Subsequent requests to the load balancer with -// the same headers will be sent to the same origin server, for the duration of -// the session and as long as the origin server remains healthy. If the session -// has been idle for the duration of `session_affinity_ttl` seconds or the origin -// server is unhealthy, then a new origin server is calculated and used. See -// `headers` in `session_affinity_attributes` for additional required -// configuration. -type LoadBalancerEditParamsRulesOverridesSessionAffinity string - -const ( - LoadBalancerEditParamsRulesOverridesSessionAffinityNone LoadBalancerEditParamsRulesOverridesSessionAffinity = "none" - LoadBalancerEditParamsRulesOverridesSessionAffinityCookie LoadBalancerEditParamsRulesOverridesSessionAffinity = "cookie" - LoadBalancerEditParamsRulesOverridesSessionAffinityIPCookie LoadBalancerEditParamsRulesOverridesSessionAffinity = "ip_cookie" - LoadBalancerEditParamsRulesOverridesSessionAffinityHeader LoadBalancerEditParamsRulesOverridesSessionAffinity = "header" - LoadBalancerEditParamsRulesOverridesSessionAffinityEmpty LoadBalancerEditParamsRulesOverridesSessionAffinity = "\"\"" -) - -// Configures attributes for session affinity. -type LoadBalancerEditParamsRulesOverridesSessionAffinityAttributes struct { - // Configures the drain duration in seconds. This field is only used when session - // affinity is enabled on the load balancer. - DrainDuration param.Field[float64] `json:"drain_duration"` - // Configures the names of HTTP headers to base session affinity on when header - // `session_affinity` is enabled. At least one HTTP header name must be provided. - // To specify the exact cookies to be used, include an item in the following - // format: `"cookie:,"` (example) where everything - // after the colon is a comma-separated list of cookie names. Providing only - // `"cookie"` will result in all cookies being used. The default max number of HTTP - // header names that can be provided depends on your plan: 5 for Enterprise, 1 for - // all other plans. - Headers param.Field[[]string] `json:"headers"` - // When header `session_affinity` is enabled, this option can be used to specify - // how HTTP headers on load balancing requests will be used. The supported values - // are: - // - // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers - // specified by the `headers` session affinity attribute, otherwise sessions - // aren't created. - // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP - // headers specified by the `headers` session affinity attribute, otherwise - // sessions aren't created. - RequireAllHeaders param.Field[bool] `json:"require_all_headers"` - // Configures the SameSite attribute on session affinity cookie. Value "Auto" will - // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: - // when using value "None", the secure attribute can not be set to "Never". - Samesite param.Field[LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite] `json:"samesite"` - // Configures the Secure attribute on session affinity cookie. Value "Always" - // indicates the Secure attribute will be set in the Set-Cookie header, "Never" - // indicates the Secure attribute will not be set, and "Auto" will set the Secure - // attribute depending if Always Use HTTPS is enabled. - Secure param.Field[LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecure] `json:"secure"` - // Configures the zero-downtime failover between origins within a pool when session - // affinity is enabled. This feature is currently incompatible with Argo, Tiered - // Cache, and Bandwidth Alliance. The supported values are: - // - // - `"none"`: No failover takes place for sessions pinned to the origin (default). - // - `"temporary"`: Traffic will be sent to another other healthy origin until the - // originally pinned origin is available; note that this can potentially result - // in heavy origin flapping. - // - `"sticky"`: The session affinity cookie is updated and subsequent requests are - // sent to the new origin. Note: Zero-downtime failover with sticky sessions is - // currently not supported for session affinity by header. - ZeroDowntimeFailover param.Field[LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` -} - -func (r LoadBalancerEditParamsRulesOverridesSessionAffinityAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures the SameSite attribute on session affinity cookie. Value "Auto" will -// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: -// when using value "None", the secure attribute can not be set to "Never". -type LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite string - -const ( - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteAuto LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite = "Auto" - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteLax LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite = "Lax" - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteNone LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite = "None" - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteStrict LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesite = "Strict" -) - -// Configures the Secure attribute on session affinity cookie. Value "Always" -// indicates the Secure attribute will be set in the Set-Cookie header, "Never" -// indicates the Secure attribute will not be set, and "Auto" will set the Secure -// attribute depending if Always Use HTTPS is enabled. -type LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecure string - -const ( - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureAuto LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecure = "Auto" - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureAlways LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecure = "Always" - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureNever LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecure = "Never" -) - -// Configures the zero-downtime failover between origins within a pool when session -// affinity is enabled. This feature is currently incompatible with Argo, Tiered -// Cache, and Bandwidth Alliance. The supported values are: -// -// - `"none"`: No failover takes place for sessions pinned to the origin (default). -// - `"temporary"`: Traffic will be sent to another other healthy origin until the -// originally pinned origin is available; note that this can potentially result -// in heavy origin flapping. -// - `"sticky"`: The session affinity cookie is updated and subsequent requests are -// sent to the new origin. Note: Zero-downtime failover with sticky sessions is -// currently not supported for session affinity by header. -type LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover string - -const ( - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "none" - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "temporary" - LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailover = "sticky" -) - -// Steering Policy for this load balancer. -// -// - `"off"`: Use `default_pools`. -// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied -// requests, the country for `country_pools` is determined by -// `location_strategy`. -// - `"random"`: Select a pool randomly. -// - `"dynamic_latency"`: Use round trip time to select the closest pool in -// default_pools (requires pool health checks). -// - `"proximity"`: Use the pools' latitude and longitude to select the closest -// pool using the Cloudflare PoP location for proxied requests or the location -// determined by `location_strategy` for non-proxied requests. -// - `"least_outstanding_requests"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of outstanding -// requests. Pools with more pending requests are weighted proportionately less -// relative to others. -// - `"least_connections"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of open connections. -// Pools with more open connections are weighted proportionately less relative to -// others. Supported for HTTP/1 and HTTP/2 connections. -// - `""`: Will map to `"geo"` if you use -// `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. -type LoadBalancerEditParamsRulesOverridesSteeringPolicy string - -const ( - LoadBalancerEditParamsRulesOverridesSteeringPolicyOff LoadBalancerEditParamsRulesOverridesSteeringPolicy = "off" - LoadBalancerEditParamsRulesOverridesSteeringPolicyGeo LoadBalancerEditParamsRulesOverridesSteeringPolicy = "geo" - LoadBalancerEditParamsRulesOverridesSteeringPolicyRandom LoadBalancerEditParamsRulesOverridesSteeringPolicy = "random" - LoadBalancerEditParamsRulesOverridesSteeringPolicyDynamicLatency LoadBalancerEditParamsRulesOverridesSteeringPolicy = "dynamic_latency" - LoadBalancerEditParamsRulesOverridesSteeringPolicyProximity LoadBalancerEditParamsRulesOverridesSteeringPolicy = "proximity" - LoadBalancerEditParamsRulesOverridesSteeringPolicyLeastOutstandingRequests LoadBalancerEditParamsRulesOverridesSteeringPolicy = "least_outstanding_requests" - LoadBalancerEditParamsRulesOverridesSteeringPolicyLeastConnections LoadBalancerEditParamsRulesOverridesSteeringPolicy = "least_connections" - LoadBalancerEditParamsRulesOverridesSteeringPolicyEmpty LoadBalancerEditParamsRulesOverridesSteeringPolicy = "\"\"" -) - -// Specifies the type of session affinity the load balancer should use unless -// specified as `"none"` or "" (default). The supported types are: -// -// - `"cookie"`: On the first request to a proxied load balancer, a cookie is -// generated, encoding information of which origin the request will be forwarded -// to. Subsequent requests, by the same client to the same load balancer, will be -// sent to the origin server the cookie encodes, for the duration of the cookie -// and as long as the origin server remains healthy. If the cookie has expired or -// the origin server is unhealthy, then a new origin server is calculated and -// used. -// - `"ip_cookie"`: Behaves the same as `"cookie"` except the initial origin -// selection is stable and based on the client's ip address. -// - `"header"`: On the first request to a proxied load balancer, a session key -// based on the configured HTTP headers (see -// `session_affinity_attributes.headers`) is generated, encoding the request -// headers used for storing in the load balancer session state which origin the -// request will be forwarded to. Subsequent requests to the load balancer with -// the same headers will be sent to the same origin server, for the duration of -// the session and as long as the origin server remains healthy. If the session -// has been idle for the duration of `session_affinity_ttl` seconds or the origin -// server is unhealthy, then a new origin server is calculated and used. See -// `headers` in `session_affinity_attributes` for additional required -// configuration. -type LoadBalancerEditParamsSessionAffinity string - -const ( - LoadBalancerEditParamsSessionAffinityNone LoadBalancerEditParamsSessionAffinity = "none" - LoadBalancerEditParamsSessionAffinityCookie LoadBalancerEditParamsSessionAffinity = "cookie" - LoadBalancerEditParamsSessionAffinityIPCookie LoadBalancerEditParamsSessionAffinity = "ip_cookie" - LoadBalancerEditParamsSessionAffinityHeader LoadBalancerEditParamsSessionAffinity = "header" - LoadBalancerEditParamsSessionAffinityEmpty LoadBalancerEditParamsSessionAffinity = "\"\"" -) - -// Configures attributes for session affinity. -type LoadBalancerEditParamsSessionAffinityAttributes struct { - // Configures the drain duration in seconds. This field is only used when session - // affinity is enabled on the load balancer. - DrainDuration param.Field[float64] `json:"drain_duration"` - // Configures the names of HTTP headers to base session affinity on when header - // `session_affinity` is enabled. At least one HTTP header name must be provided. - // To specify the exact cookies to be used, include an item in the following - // format: `"cookie:,"` (example) where everything - // after the colon is a comma-separated list of cookie names. Providing only - // `"cookie"` will result in all cookies being used. The default max number of HTTP - // header names that can be provided depends on your plan: 5 for Enterprise, 1 for - // all other plans. - Headers param.Field[[]string] `json:"headers"` - // When header `session_affinity` is enabled, this option can be used to specify - // how HTTP headers on load balancing requests will be used. The supported values - // are: - // - // - `"true"`: Load balancing requests must contain _all_ of the HTTP headers - // specified by the `headers` session affinity attribute, otherwise sessions - // aren't created. - // - `"false"`: Load balancing requests must contain _at least one_ of the HTTP - // headers specified by the `headers` session affinity attribute, otherwise - // sessions aren't created. - RequireAllHeaders param.Field[bool] `json:"require_all_headers"` - // Configures the SameSite attribute on session affinity cookie. Value "Auto" will - // be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: - // when using value "None", the secure attribute can not be set to "Never". - Samesite param.Field[LoadBalancerEditParamsSessionAffinityAttributesSamesite] `json:"samesite"` - // Configures the Secure attribute on session affinity cookie. Value "Always" - // indicates the Secure attribute will be set in the Set-Cookie header, "Never" - // indicates the Secure attribute will not be set, and "Auto" will set the Secure - // attribute depending if Always Use HTTPS is enabled. - Secure param.Field[LoadBalancerEditParamsSessionAffinityAttributesSecure] `json:"secure"` - // Configures the zero-downtime failover between origins within a pool when session - // affinity is enabled. This feature is currently incompatible with Argo, Tiered - // Cache, and Bandwidth Alliance. The supported values are: - // - // - `"none"`: No failover takes place for sessions pinned to the origin (default). - // - `"temporary"`: Traffic will be sent to another other healthy origin until the - // originally pinned origin is available; note that this can potentially result - // in heavy origin flapping. - // - `"sticky"`: The session affinity cookie is updated and subsequent requests are - // sent to the new origin. Note: Zero-downtime failover with sticky sessions is - // currently not supported for session affinity by header. - ZeroDowntimeFailover param.Field[LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailover] `json:"zero_downtime_failover"` -} - -func (r LoadBalancerEditParamsSessionAffinityAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures the SameSite attribute on session affinity cookie. Value "Auto" will -// be translated to "Lax" or "None" depending if Always Use HTTPS is enabled. Note: -// when using value "None", the secure attribute can not be set to "Never". -type LoadBalancerEditParamsSessionAffinityAttributesSamesite string - -const ( - LoadBalancerEditParamsSessionAffinityAttributesSamesiteAuto LoadBalancerEditParamsSessionAffinityAttributesSamesite = "Auto" - LoadBalancerEditParamsSessionAffinityAttributesSamesiteLax LoadBalancerEditParamsSessionAffinityAttributesSamesite = "Lax" - LoadBalancerEditParamsSessionAffinityAttributesSamesiteNone LoadBalancerEditParamsSessionAffinityAttributesSamesite = "None" - LoadBalancerEditParamsSessionAffinityAttributesSamesiteStrict LoadBalancerEditParamsSessionAffinityAttributesSamesite = "Strict" -) - -// Configures the Secure attribute on session affinity cookie. Value "Always" -// indicates the Secure attribute will be set in the Set-Cookie header, "Never" -// indicates the Secure attribute will not be set, and "Auto" will set the Secure -// attribute depending if Always Use HTTPS is enabled. -type LoadBalancerEditParamsSessionAffinityAttributesSecure string - -const ( - LoadBalancerEditParamsSessionAffinityAttributesSecureAuto LoadBalancerEditParamsSessionAffinityAttributesSecure = "Auto" - LoadBalancerEditParamsSessionAffinityAttributesSecureAlways LoadBalancerEditParamsSessionAffinityAttributesSecure = "Always" - LoadBalancerEditParamsSessionAffinityAttributesSecureNever LoadBalancerEditParamsSessionAffinityAttributesSecure = "Never" -) - -// Configures the zero-downtime failover between origins within a pool when session -// affinity is enabled. This feature is currently incompatible with Argo, Tiered -// Cache, and Bandwidth Alliance. The supported values are: -// -// - `"none"`: No failover takes place for sessions pinned to the origin (default). -// - `"temporary"`: Traffic will be sent to another other healthy origin until the -// originally pinned origin is available; note that this can potentially result -// in heavy origin flapping. -// - `"sticky"`: The session affinity cookie is updated and subsequent requests are -// sent to the new origin. Note: Zero-downtime failover with sticky sessions is -// currently not supported for session affinity by header. -type LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailover string - -const ( - LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailoverNone LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailover = "none" - LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailoverTemporary LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailover = "temporary" - LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailoverSticky LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailover = "sticky" -) - -// Steering Policy for this load balancer. -// -// - `"off"`: Use `default_pools`. -// - `"geo"`: Use `region_pools`/`country_pools`/`pop_pools`. For non-proxied -// requests, the country for `country_pools` is determined by -// `location_strategy`. -// - `"random"`: Select a pool randomly. -// - `"dynamic_latency"`: Use round trip time to select the closest pool in -// default_pools (requires pool health checks). -// - `"proximity"`: Use the pools' latitude and longitude to select the closest -// pool using the Cloudflare PoP location for proxied requests or the location -// determined by `location_strategy` for non-proxied requests. -// - `"least_outstanding_requests"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of outstanding -// requests. Pools with more pending requests are weighted proportionately less -// relative to others. -// - `"least_connections"`: Select a pool by taking into consideration -// `random_steering` weights, as well as each pool's number of open connections. -// Pools with more open connections are weighted proportionately less relative to -// others. Supported for HTTP/1 and HTTP/2 connections. -// - `""`: Will map to `"geo"` if you use -// `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. -type LoadBalancerEditParamsSteeringPolicy string - -const ( - LoadBalancerEditParamsSteeringPolicyOff LoadBalancerEditParamsSteeringPolicy = "off" - LoadBalancerEditParamsSteeringPolicyGeo LoadBalancerEditParamsSteeringPolicy = "geo" - LoadBalancerEditParamsSteeringPolicyRandom LoadBalancerEditParamsSteeringPolicy = "random" - LoadBalancerEditParamsSteeringPolicyDynamicLatency LoadBalancerEditParamsSteeringPolicy = "dynamic_latency" - LoadBalancerEditParamsSteeringPolicyProximity LoadBalancerEditParamsSteeringPolicy = "proximity" - LoadBalancerEditParamsSteeringPolicyLeastOutstandingRequests LoadBalancerEditParamsSteeringPolicy = "least_outstanding_requests" - LoadBalancerEditParamsSteeringPolicyLeastConnections LoadBalancerEditParamsSteeringPolicy = "least_connections" - LoadBalancerEditParamsSteeringPolicyEmpty LoadBalancerEditParamsSteeringPolicy = "\"\"" -) - -type LoadBalancerEditResponseEnvelope struct { - Errors []LoadBalancerEditResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerEditResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancer `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerEditResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerEditResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [LoadBalancerEditResponseEnvelope] -type loadBalancerEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LoadBalancerEditResponseEnvelopeErrors] -type loadBalancerEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LoadBalancerEditResponseEnvelopeMessages] -type loadBalancerEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerEditResponseEnvelopeSuccess bool - -const ( - LoadBalancerEditResponseEnvelopeSuccessTrue LoadBalancerEditResponseEnvelopeSuccess = true -) - -type LoadBalancerGetParams struct { - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type LoadBalancerGetResponseEnvelope struct { - Errors []LoadBalancerGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerGetResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancer `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerGetResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerGetResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [LoadBalancerGetResponseEnvelope] -type loadBalancerGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LoadBalancerGetResponseEnvelopeErrors] -type loadBalancerGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LoadBalancerGetResponseEnvelopeMessages] -type loadBalancerGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerGetResponseEnvelopeSuccess bool - -const ( - LoadBalancerGetResponseEnvelopeSuccessTrue LoadBalancerGetResponseEnvelopeSuccess = true -) diff --git a/loadbalancer_test.go b/loadbalancer_test.go deleted file mode 100644 index 7e90320656a..00000000000 --- a/loadbalancer_test.go +++ /dev/null @@ -1,1034 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLoadBalancerNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.LoadBalancers.New(context.TODO(), cloudflare.LoadBalancerNewParams{ - ZoneID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), - FallbackPool: cloudflare.F[any](map[string]interface{}{}), - Name: cloudflare.F("www.example.com"), - AdaptiveRouting: cloudflare.F(cloudflare.LoadBalancerNewParamsAdaptiveRouting{ - FailoverAcrossPools: cloudflare.F(true), - }), - CountryPools: cloudflare.F[any](map[string]interface{}{ - "GB": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - }, - "US": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - Description: cloudflare.F("Load Balancer for www.example.com"), - LocationStrategy: cloudflare.F(cloudflare.LoadBalancerNewParamsLocationStrategy{ - Mode: cloudflare.F(cloudflare.LoadBalancerNewParamsLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(cloudflare.LoadBalancerNewParamsLocationStrategyPreferEcsAlways), - }), - PopPools: cloudflare.F[any](map[string]interface{}{ - "LAX": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - "LHR": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - "1": "f9138c5d07c2e2f4df57b1f61d4196", - }, - "SJC": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - Proxied: cloudflare.F(true), - RandomSteering: cloudflare.F(cloudflare.LoadBalancerNewParamsRandomSteering{ - DefaultWeight: cloudflare.F(0.200000), - PoolWeights: cloudflare.F[any](map[string]interface{}{ - "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, - "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, - }), - }), - RegionPools: cloudflare.F[any](map[string]interface{}{ - "ENAM": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - "WNAM": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - }), - Rules: cloudflare.F([]cloudflare.LoadBalancerNewParamsRule{{ - Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), - Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesFixedResponse{ - ContentType: cloudflare.F("application/json"), - Location: cloudflare.F("www.example.com"), - MessageBody: cloudflare.F("Testing Hello"), - StatusCode: cloudflare.F(int64(0)), - }), - Name: cloudflare.F("route the path /testing to testing datacenter."), - Overrides: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverrides{ - AdaptiveRouting: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesAdaptiveRouting{ - FailoverAcrossPools: cloudflare.F(true), - }), - CountryPools: cloudflare.F[any](map[string]interface{}{ - "GB": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - }, - "US": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), - FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesLocationStrategy{ - Mode: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsAlways), - }), - PopPools: cloudflare.F[any](map[string]interface{}{ - "LAX": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - "LHR": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - "1": "f9138c5d07c2e2f4df57b1f61d4196", - }, - "SJC": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - RandomSteering: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesRandomSteering{ - DefaultWeight: cloudflare.F(0.200000), - PoolWeights: cloudflare.F[any](map[string]interface{}{ - "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, - "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, - }), - }), - RegionPools: cloudflare.F[any](map[string]interface{}{ - "ENAM": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - "WNAM": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - }), - SessionAffinity: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributes{ - DrainDuration: cloudflare.F(100.000000), - Headers: cloudflare.F([]string{"x"}), - RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), - }), - SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesSteeringPolicyDynamicLatency), - TTL: cloudflare.F(30.000000), - }), - Priority: cloudflare.F(int64(0)), - Terminates: cloudflare.F(true), - }, { - Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), - Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesFixedResponse{ - ContentType: cloudflare.F("application/json"), - Location: cloudflare.F("www.example.com"), - MessageBody: cloudflare.F("Testing Hello"), - StatusCode: cloudflare.F(int64(0)), - }), - Name: cloudflare.F("route the path /testing to testing datacenter."), - Overrides: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverrides{ - AdaptiveRouting: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesAdaptiveRouting{ - FailoverAcrossPools: cloudflare.F(true), - }), - CountryPools: cloudflare.F[any](map[string]interface{}{ - "GB": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - }, - "US": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), - FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesLocationStrategy{ - Mode: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsAlways), - }), - PopPools: cloudflare.F[any](map[string]interface{}{ - "LAX": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - "LHR": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - "1": "f9138c5d07c2e2f4df57b1f61d4196", - }, - "SJC": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - RandomSteering: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesRandomSteering{ - DefaultWeight: cloudflare.F(0.200000), - PoolWeights: cloudflare.F[any](map[string]interface{}{ - "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, - "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, - }), - }), - RegionPools: cloudflare.F[any](map[string]interface{}{ - "ENAM": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - "WNAM": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - }), - SessionAffinity: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributes{ - DrainDuration: cloudflare.F(100.000000), - Headers: cloudflare.F([]string{"x"}), - RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), - }), - SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesSteeringPolicyDynamicLatency), - TTL: cloudflare.F(30.000000), - }), - Priority: cloudflare.F(int64(0)), - Terminates: cloudflare.F(true), - }, { - Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), - Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesFixedResponse{ - ContentType: cloudflare.F("application/json"), - Location: cloudflare.F("www.example.com"), - MessageBody: cloudflare.F("Testing Hello"), - StatusCode: cloudflare.F(int64(0)), - }), - Name: cloudflare.F("route the path /testing to testing datacenter."), - Overrides: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverrides{ - AdaptiveRouting: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesAdaptiveRouting{ - FailoverAcrossPools: cloudflare.F(true), - }), - CountryPools: cloudflare.F[any](map[string]interface{}{ - "GB": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - }, - "US": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), - FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesLocationStrategy{ - Mode: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesLocationStrategyPreferEcsAlways), - }), - PopPools: cloudflare.F[any](map[string]interface{}{ - "LAX": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - "LHR": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - "1": "f9138c5d07c2e2f4df57b1f61d4196", - }, - "SJC": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - RandomSteering: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesRandomSteering{ - DefaultWeight: cloudflare.F(0.200000), - PoolWeights: cloudflare.F[any](map[string]interface{}{ - "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, - "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, - }), - }), - RegionPools: cloudflare.F[any](map[string]interface{}{ - "ENAM": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - "WNAM": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - }), - SessionAffinity: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributes{ - DrainDuration: cloudflare.F(100.000000), - Headers: cloudflare.F([]string{"x"}), - RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), - }), - SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(cloudflare.LoadBalancerNewParamsRulesOverridesSteeringPolicyDynamicLatency), - TTL: cloudflare.F(30.000000), - }), - Priority: cloudflare.F(int64(0)), - Terminates: cloudflare.F(true), - }}), - SessionAffinity: cloudflare.F(cloudflare.LoadBalancerNewParamsSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(cloudflare.LoadBalancerNewParamsSessionAffinityAttributes{ - DrainDuration: cloudflare.F(100.000000), - Headers: cloudflare.F([]string{"x"}), - RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(cloudflare.LoadBalancerNewParamsSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(cloudflare.LoadBalancerNewParamsSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(cloudflare.LoadBalancerNewParamsSessionAffinityAttributesZeroDowntimeFailoverSticky), - }), - SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(cloudflare.LoadBalancerNewParamsSteeringPolicyDynamicLatency), - TTL: cloudflare.F(30.000000), - }) - 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 TestLoadBalancerUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.LoadBalancers.Update( - context.TODO(), - "699d98642c564d2e855e9661899b7252", - cloudflare.LoadBalancerUpdateParams{ - ZoneID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), - FallbackPool: cloudflare.F[any](map[string]interface{}{}), - Name: cloudflare.F("www.example.com"), - AdaptiveRouting: cloudflare.F(cloudflare.LoadBalancerUpdateParamsAdaptiveRouting{ - FailoverAcrossPools: cloudflare.F(true), - }), - CountryPools: cloudflare.F[any](map[string]interface{}{ - "GB": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - }, - "US": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - Description: cloudflare.F("Load Balancer for www.example.com"), - Enabled: cloudflare.F(true), - LocationStrategy: cloudflare.F(cloudflare.LoadBalancerUpdateParamsLocationStrategy{ - Mode: cloudflare.F(cloudflare.LoadBalancerUpdateParamsLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(cloudflare.LoadBalancerUpdateParamsLocationStrategyPreferEcsAlways), - }), - PopPools: cloudflare.F[any](map[string]interface{}{ - "LAX": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - "LHR": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - "1": "f9138c5d07c2e2f4df57b1f61d4196", - }, - "SJC": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - Proxied: cloudflare.F(true), - RandomSteering: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRandomSteering{ - DefaultWeight: cloudflare.F(0.200000), - PoolWeights: cloudflare.F[any](map[string]interface{}{ - "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, - "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, - }), - }), - RegionPools: cloudflare.F[any](map[string]interface{}{ - "ENAM": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - "WNAM": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - }), - Rules: cloudflare.F([]cloudflare.LoadBalancerUpdateParamsRule{{ - Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), - Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesFixedResponse{ - ContentType: cloudflare.F("application/json"), - Location: cloudflare.F("www.example.com"), - MessageBody: cloudflare.F("Testing Hello"), - StatusCode: cloudflare.F(int64(0)), - }), - Name: cloudflare.F("route the path /testing to testing datacenter."), - Overrides: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverrides{ - AdaptiveRouting: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesAdaptiveRouting{ - FailoverAcrossPools: cloudflare.F(true), - }), - CountryPools: cloudflare.F[any](map[string]interface{}{ - "GB": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - }, - "US": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), - FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesLocationStrategy{ - Mode: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsAlways), - }), - PopPools: cloudflare.F[any](map[string]interface{}{ - "LAX": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - "LHR": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - "1": "f9138c5d07c2e2f4df57b1f61d4196", - }, - "SJC": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - RandomSteering: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesRandomSteering{ - DefaultWeight: cloudflare.F(0.200000), - PoolWeights: cloudflare.F[any](map[string]interface{}{ - "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, - "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, - }), - }), - RegionPools: cloudflare.F[any](map[string]interface{}{ - "ENAM": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - "WNAM": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - }), - SessionAffinity: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributes{ - DrainDuration: cloudflare.F(100.000000), - Headers: cloudflare.F([]string{"x"}), - RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), - }), - SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesSteeringPolicyDynamicLatency), - TTL: cloudflare.F(30.000000), - }), - Priority: cloudflare.F(int64(0)), - Terminates: cloudflare.F(true), - }, { - Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), - Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesFixedResponse{ - ContentType: cloudflare.F("application/json"), - Location: cloudflare.F("www.example.com"), - MessageBody: cloudflare.F("Testing Hello"), - StatusCode: cloudflare.F(int64(0)), - }), - Name: cloudflare.F("route the path /testing to testing datacenter."), - Overrides: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverrides{ - AdaptiveRouting: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesAdaptiveRouting{ - FailoverAcrossPools: cloudflare.F(true), - }), - CountryPools: cloudflare.F[any](map[string]interface{}{ - "GB": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - }, - "US": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), - FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesLocationStrategy{ - Mode: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsAlways), - }), - PopPools: cloudflare.F[any](map[string]interface{}{ - "LAX": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - "LHR": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - "1": "f9138c5d07c2e2f4df57b1f61d4196", - }, - "SJC": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - RandomSteering: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesRandomSteering{ - DefaultWeight: cloudflare.F(0.200000), - PoolWeights: cloudflare.F[any](map[string]interface{}{ - "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, - "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, - }), - }), - RegionPools: cloudflare.F[any](map[string]interface{}{ - "ENAM": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - "WNAM": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - }), - SessionAffinity: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributes{ - DrainDuration: cloudflare.F(100.000000), - Headers: cloudflare.F([]string{"x"}), - RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), - }), - SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesSteeringPolicyDynamicLatency), - TTL: cloudflare.F(30.000000), - }), - Priority: cloudflare.F(int64(0)), - Terminates: cloudflare.F(true), - }, { - Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), - Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesFixedResponse{ - ContentType: cloudflare.F("application/json"), - Location: cloudflare.F("www.example.com"), - MessageBody: cloudflare.F("Testing Hello"), - StatusCode: cloudflare.F(int64(0)), - }), - Name: cloudflare.F("route the path /testing to testing datacenter."), - Overrides: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverrides{ - AdaptiveRouting: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesAdaptiveRouting{ - FailoverAcrossPools: cloudflare.F(true), - }), - CountryPools: cloudflare.F[any](map[string]interface{}{ - "GB": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - }, - "US": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), - FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesLocationStrategy{ - Mode: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesLocationStrategyPreferEcsAlways), - }), - PopPools: cloudflare.F[any](map[string]interface{}{ - "LAX": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - "LHR": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - "1": "f9138c5d07c2e2f4df57b1f61d4196", - }, - "SJC": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - RandomSteering: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesRandomSteering{ - DefaultWeight: cloudflare.F(0.200000), - PoolWeights: cloudflare.F[any](map[string]interface{}{ - "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, - "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, - }), - }), - RegionPools: cloudflare.F[any](map[string]interface{}{ - "ENAM": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - "WNAM": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - }), - SessionAffinity: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributes{ - DrainDuration: cloudflare.F(100.000000), - Headers: cloudflare.F([]string{"x"}), - RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), - }), - SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(cloudflare.LoadBalancerUpdateParamsRulesOverridesSteeringPolicyDynamicLatency), - TTL: cloudflare.F(30.000000), - }), - Priority: cloudflare.F(int64(0)), - Terminates: cloudflare.F(true), - }}), - SessionAffinity: cloudflare.F(cloudflare.LoadBalancerUpdateParamsSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(cloudflare.LoadBalancerUpdateParamsSessionAffinityAttributes{ - DrainDuration: cloudflare.F(100.000000), - Headers: cloudflare.F([]string{"x"}), - RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(cloudflare.LoadBalancerUpdateParamsSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(cloudflare.LoadBalancerUpdateParamsSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(cloudflare.LoadBalancerUpdateParamsSessionAffinityAttributesZeroDowntimeFailoverSticky), - }), - SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(cloudflare.LoadBalancerUpdateParamsSteeringPolicyDynamicLatency), - TTL: cloudflare.F(30.000000), - }, - ) - 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 TestLoadBalancerList(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("user@example.com"), - ) - _, err := client.LoadBalancers.List(context.TODO(), cloudflare.LoadBalancerListParams{ - ZoneID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - }) - 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 TestLoadBalancerDelete(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("user@example.com"), - ) - _, err := client.LoadBalancers.Delete( - context.TODO(), - "699d98642c564d2e855e9661899b7252", - cloudflare.LoadBalancerDeleteParams{ - ZoneID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - }, - ) - 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 TestLoadBalancerEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.LoadBalancers.Edit( - context.TODO(), - "699d98642c564d2e855e9661899b7252", - cloudflare.LoadBalancerEditParams{ - ZoneID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - AdaptiveRouting: cloudflare.F(cloudflare.LoadBalancerEditParamsAdaptiveRouting{ - FailoverAcrossPools: cloudflare.F(true), - }), - CountryPools: cloudflare.F[any](map[string]interface{}{ - "GB": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - }, - "US": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), - Description: cloudflare.F("Load Balancer for www.example.com"), - Enabled: cloudflare.F(true), - FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(cloudflare.LoadBalancerEditParamsLocationStrategy{ - Mode: cloudflare.F(cloudflare.LoadBalancerEditParamsLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(cloudflare.LoadBalancerEditParamsLocationStrategyPreferEcsAlways), - }), - Name: cloudflare.F("www.example.com"), - PopPools: cloudflare.F[any](map[string]interface{}{ - "LAX": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - "LHR": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - "1": "f9138c5d07c2e2f4df57b1f61d4196", - }, - "SJC": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - Proxied: cloudflare.F(true), - RandomSteering: cloudflare.F(cloudflare.LoadBalancerEditParamsRandomSteering{ - DefaultWeight: cloudflare.F(0.200000), - PoolWeights: cloudflare.F[any](map[string]interface{}{ - "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, - "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, - }), - }), - RegionPools: cloudflare.F[any](map[string]interface{}{ - "ENAM": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - "WNAM": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - }), - Rules: cloudflare.F([]cloudflare.LoadBalancerEditParamsRule{{ - Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), - Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesFixedResponse{ - ContentType: cloudflare.F("application/json"), - Location: cloudflare.F("www.example.com"), - MessageBody: cloudflare.F("Testing Hello"), - StatusCode: cloudflare.F(int64(0)), - }), - Name: cloudflare.F("route the path /testing to testing datacenter."), - Overrides: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverrides{ - AdaptiveRouting: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesAdaptiveRouting{ - FailoverAcrossPools: cloudflare.F(true), - }), - CountryPools: cloudflare.F[any](map[string]interface{}{ - "GB": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - }, - "US": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), - FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesLocationStrategy{ - Mode: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsAlways), - }), - PopPools: cloudflare.F[any](map[string]interface{}{ - "LAX": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - "LHR": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - "1": "f9138c5d07c2e2f4df57b1f61d4196", - }, - "SJC": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - RandomSteering: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesRandomSteering{ - DefaultWeight: cloudflare.F(0.200000), - PoolWeights: cloudflare.F[any](map[string]interface{}{ - "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, - "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, - }), - }), - RegionPools: cloudflare.F[any](map[string]interface{}{ - "ENAM": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - "WNAM": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - }), - SessionAffinity: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributes{ - DrainDuration: cloudflare.F(100.000000), - Headers: cloudflare.F([]string{"x"}), - RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), - }), - SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesSteeringPolicyDynamicLatency), - TTL: cloudflare.F(30.000000), - }), - Priority: cloudflare.F(int64(0)), - Terminates: cloudflare.F(true), - }, { - Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), - Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesFixedResponse{ - ContentType: cloudflare.F("application/json"), - Location: cloudflare.F("www.example.com"), - MessageBody: cloudflare.F("Testing Hello"), - StatusCode: cloudflare.F(int64(0)), - }), - Name: cloudflare.F("route the path /testing to testing datacenter."), - Overrides: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverrides{ - AdaptiveRouting: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesAdaptiveRouting{ - FailoverAcrossPools: cloudflare.F(true), - }), - CountryPools: cloudflare.F[any](map[string]interface{}{ - "GB": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - }, - "US": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), - FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesLocationStrategy{ - Mode: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsAlways), - }), - PopPools: cloudflare.F[any](map[string]interface{}{ - "LAX": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - "LHR": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - "1": "f9138c5d07c2e2f4df57b1f61d4196", - }, - "SJC": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - RandomSteering: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesRandomSteering{ - DefaultWeight: cloudflare.F(0.200000), - PoolWeights: cloudflare.F[any](map[string]interface{}{ - "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, - "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, - }), - }), - RegionPools: cloudflare.F[any](map[string]interface{}{ - "ENAM": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - "WNAM": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - }), - SessionAffinity: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributes{ - DrainDuration: cloudflare.F(100.000000), - Headers: cloudflare.F([]string{"x"}), - RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), - }), - SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesSteeringPolicyDynamicLatency), - TTL: cloudflare.F(30.000000), - }), - Priority: cloudflare.F(int64(0)), - Terminates: cloudflare.F(true), - }, { - Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), - Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesFixedResponse{ - ContentType: cloudflare.F("application/json"), - Location: cloudflare.F("www.example.com"), - MessageBody: cloudflare.F("Testing Hello"), - StatusCode: cloudflare.F(int64(0)), - }), - Name: cloudflare.F("route the path /testing to testing datacenter."), - Overrides: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverrides{ - AdaptiveRouting: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesAdaptiveRouting{ - FailoverAcrossPools: cloudflare.F(true), - }), - CountryPools: cloudflare.F[any](map[string]interface{}{ - "GB": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - }, - "US": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - DefaultPools: cloudflare.F([]string{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), - FallbackPool: cloudflare.F[any](map[string]interface{}{}), - LocationStrategy: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesLocationStrategy{ - Mode: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesLocationStrategyModeResolverIP), - PreferEcs: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesLocationStrategyPreferEcsAlways), - }), - PopPools: cloudflare.F[any](map[string]interface{}{ - "LAX": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - "LHR": map[string]interface{}{ - "0": "abd90f38ced07c2e2f4df50b1f61d4194", - "1": "f9138c5d07c2e2f4df57b1f61d4196", - }, - "SJC": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - }), - RandomSteering: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesRandomSteering{ - DefaultWeight: cloudflare.F(0.200000), - PoolWeights: cloudflare.F[any](map[string]interface{}{ - "9290f38c5d07c2e2f4df57b1f61d4196": 0.500000, - "de90f38ced07c2e2f4df50b1f61d4194": 0.300000, - }), - }), - RegionPools: cloudflare.F[any](map[string]interface{}{ - "ENAM": map[string]interface{}{ - "0": "00920f38ce07c2e2f4df50b1f61d4194", - }, - "WNAM": map[string]interface{}{ - "0": "de90f38ced07c2e2f4df50b1f61d4194", - "1": "9290f38c5d07c2e2f4df57b1f61d4196", - }, - }), - SessionAffinity: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributes{ - DrainDuration: cloudflare.F(100.000000), - Headers: cloudflare.F([]string{"x"}), - RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesSessionAffinityAttributesZeroDowntimeFailoverSticky), - }), - SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(cloudflare.LoadBalancerEditParamsRulesOverridesSteeringPolicyDynamicLatency), - TTL: cloudflare.F(30.000000), - }), - Priority: cloudflare.F(int64(0)), - Terminates: cloudflare.F(true), - }}), - SessionAffinity: cloudflare.F(cloudflare.LoadBalancerEditParamsSessionAffinityCookie), - SessionAffinityAttributes: cloudflare.F(cloudflare.LoadBalancerEditParamsSessionAffinityAttributes{ - DrainDuration: cloudflare.F(100.000000), - Headers: cloudflare.F([]string{"x"}), - RequireAllHeaders: cloudflare.F(true), - Samesite: cloudflare.F(cloudflare.LoadBalancerEditParamsSessionAffinityAttributesSamesiteAuto), - Secure: cloudflare.F(cloudflare.LoadBalancerEditParamsSessionAffinityAttributesSecureAuto), - ZeroDowntimeFailover: cloudflare.F(cloudflare.LoadBalancerEditParamsSessionAffinityAttributesZeroDowntimeFailoverSticky), - }), - SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(cloudflare.LoadBalancerEditParamsSteeringPolicyDynamicLatency), - TTL: cloudflare.F(30.000000), - }, - ) - 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 TestLoadBalancerGet(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("user@example.com"), - ) - _, err := client.LoadBalancers.Get( - context.TODO(), - "699d98642c564d2e855e9661899b7252", - cloudflare.LoadBalancerGetParams{ - ZoneID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/loadbalancermonitor.go b/loadbalancermonitor.go deleted file mode 100644 index 938529223a8..00000000000 --- a/loadbalancermonitor.go +++ /dev/null @@ -1,1398 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// LoadBalancerMonitorService 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 [NewLoadBalancerMonitorService] -// method instead. -type LoadBalancerMonitorService struct { - Options []option.RequestOption - Previews *LoadBalancerMonitorPreviewService - References *LoadBalancerMonitorReferenceService -} - -// NewLoadBalancerMonitorService 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 NewLoadBalancerMonitorService(opts ...option.RequestOption) (r *LoadBalancerMonitorService) { - r = &LoadBalancerMonitorService{} - r.Options = opts - r.Previews = NewLoadBalancerMonitorPreviewService(opts...) - r.References = NewLoadBalancerMonitorReferenceService(opts...) - return -} - -// Create a configured monitor. -func (r *LoadBalancerMonitorService) New(ctx context.Context, params LoadBalancerMonitorNewParams, opts ...option.RequestOption) (res *LoadBalancerMonitorNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerMonitorNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/monitors", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Modify a configured monitor. -func (r *LoadBalancerMonitorService) Update(ctx context.Context, monitorID string, params LoadBalancerMonitorUpdateParams, opts ...option.RequestOption) (res *LoadBalancerMonitorUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerMonitorUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s", params.AccountID, monitorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List configured monitors for an account. -func (r *LoadBalancerMonitorService) List(ctx context.Context, query LoadBalancerMonitorListParams, opts ...option.RequestOption) (res *[]LoadBalancerMonitorListResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerMonitorListResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/monitors", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a configured monitor. -func (r *LoadBalancerMonitorService) Delete(ctx context.Context, monitorID string, body LoadBalancerMonitorDeleteParams, opts ...option.RequestOption) (res *LoadBalancerMonitorDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerMonitorDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s", body.AccountID, monitorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Apply changes to an existing monitor, overwriting the supplied properties. -func (r *LoadBalancerMonitorService) Edit(ctx context.Context, monitorID string, params LoadBalancerMonitorEditParams, opts ...option.RequestOption) (res *LoadBalancerMonitorEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerMonitorEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s", params.AccountID, monitorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List a single configured monitor for an account. -func (r *LoadBalancerMonitorService) Get(ctx context.Context, monitorID string, query LoadBalancerMonitorGetParams, opts ...option.RequestOption) (res *LoadBalancerMonitorGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerMonitorGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s", query.AccountID, monitorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LoadBalancerMonitorNewResponse struct { - ID string `json:"id"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure bool `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown int64 `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp int64 `json:"consecutive_up"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Object description. - Description string `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes string `json:"expected_codes"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header interface{} `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval int64 `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method string `json:"method"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path string `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port int64 `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone string `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type LoadBalancerMonitorNewResponseType `json:"type"` - JSON loadBalancerMonitorNewResponseJSON `json:"-"` -} - -// loadBalancerMonitorNewResponseJSON contains the JSON metadata for the struct -// [LoadBalancerMonitorNewResponse] -type loadBalancerMonitorNewResponseJSON struct { - ID apijson.Field - AllowInsecure apijson.Field - ConsecutiveDown apijson.Field - ConsecutiveUp apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Interval apijson.Field - Method apijson.Field - ModifiedOn apijson.Field - Path apijson.Field - Port apijson.Field - ProbeZone apijson.Field - Retries apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorNewResponseJSON) RawJSON() string { - return r.raw -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancerMonitorNewResponseType string - -const ( - LoadBalancerMonitorNewResponseTypeHTTP LoadBalancerMonitorNewResponseType = "http" - LoadBalancerMonitorNewResponseTypeHTTPS LoadBalancerMonitorNewResponseType = "https" - LoadBalancerMonitorNewResponseTypeTcp LoadBalancerMonitorNewResponseType = "tcp" - LoadBalancerMonitorNewResponseTypeUdpIcmp LoadBalancerMonitorNewResponseType = "udp_icmp" - LoadBalancerMonitorNewResponseTypeIcmpPing LoadBalancerMonitorNewResponseType = "icmp_ping" - LoadBalancerMonitorNewResponseTypeSmtp LoadBalancerMonitorNewResponseType = "smtp" -) - -type LoadBalancerMonitorUpdateResponse struct { - ID string `json:"id"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure bool `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown int64 `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp int64 `json:"consecutive_up"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Object description. - Description string `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes string `json:"expected_codes"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header interface{} `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval int64 `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method string `json:"method"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path string `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port int64 `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone string `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type LoadBalancerMonitorUpdateResponseType `json:"type"` - JSON loadBalancerMonitorUpdateResponseJSON `json:"-"` -} - -// loadBalancerMonitorUpdateResponseJSON contains the JSON metadata for the struct -// [LoadBalancerMonitorUpdateResponse] -type loadBalancerMonitorUpdateResponseJSON struct { - ID apijson.Field - AllowInsecure apijson.Field - ConsecutiveDown apijson.Field - ConsecutiveUp apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Interval apijson.Field - Method apijson.Field - ModifiedOn apijson.Field - Path apijson.Field - Port apijson.Field - ProbeZone apijson.Field - Retries apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancerMonitorUpdateResponseType string - -const ( - LoadBalancerMonitorUpdateResponseTypeHTTP LoadBalancerMonitorUpdateResponseType = "http" - LoadBalancerMonitorUpdateResponseTypeHTTPS LoadBalancerMonitorUpdateResponseType = "https" - LoadBalancerMonitorUpdateResponseTypeTcp LoadBalancerMonitorUpdateResponseType = "tcp" - LoadBalancerMonitorUpdateResponseTypeUdpIcmp LoadBalancerMonitorUpdateResponseType = "udp_icmp" - LoadBalancerMonitorUpdateResponseTypeIcmpPing LoadBalancerMonitorUpdateResponseType = "icmp_ping" - LoadBalancerMonitorUpdateResponseTypeSmtp LoadBalancerMonitorUpdateResponseType = "smtp" -) - -type LoadBalancerMonitorListResponse struct { - ID string `json:"id"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure bool `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown int64 `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp int64 `json:"consecutive_up"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Object description. - Description string `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes string `json:"expected_codes"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header interface{} `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval int64 `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method string `json:"method"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path string `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port int64 `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone string `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type LoadBalancerMonitorListResponseType `json:"type"` - JSON loadBalancerMonitorListResponseJSON `json:"-"` -} - -// loadBalancerMonitorListResponseJSON contains the JSON metadata for the struct -// [LoadBalancerMonitorListResponse] -type loadBalancerMonitorListResponseJSON struct { - ID apijson.Field - AllowInsecure apijson.Field - ConsecutiveDown apijson.Field - ConsecutiveUp apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Interval apijson.Field - Method apijson.Field - ModifiedOn apijson.Field - Path apijson.Field - Port apijson.Field - ProbeZone apijson.Field - Retries apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorListResponseJSON) RawJSON() string { - return r.raw -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancerMonitorListResponseType string - -const ( - LoadBalancerMonitorListResponseTypeHTTP LoadBalancerMonitorListResponseType = "http" - LoadBalancerMonitorListResponseTypeHTTPS LoadBalancerMonitorListResponseType = "https" - LoadBalancerMonitorListResponseTypeTcp LoadBalancerMonitorListResponseType = "tcp" - LoadBalancerMonitorListResponseTypeUdpIcmp LoadBalancerMonitorListResponseType = "udp_icmp" - LoadBalancerMonitorListResponseTypeIcmpPing LoadBalancerMonitorListResponseType = "icmp_ping" - LoadBalancerMonitorListResponseTypeSmtp LoadBalancerMonitorListResponseType = "smtp" -) - -type LoadBalancerMonitorDeleteResponse struct { - ID string `json:"id"` - JSON loadBalancerMonitorDeleteResponseJSON `json:"-"` -} - -// loadBalancerMonitorDeleteResponseJSON contains the JSON metadata for the struct -// [LoadBalancerMonitorDeleteResponse] -type loadBalancerMonitorDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorEditResponse struct { - ID string `json:"id"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure bool `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown int64 `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp int64 `json:"consecutive_up"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Object description. - Description string `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes string `json:"expected_codes"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header interface{} `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval int64 `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method string `json:"method"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path string `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port int64 `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone string `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type LoadBalancerMonitorEditResponseType `json:"type"` - JSON loadBalancerMonitorEditResponseJSON `json:"-"` -} - -// loadBalancerMonitorEditResponseJSON contains the JSON metadata for the struct -// [LoadBalancerMonitorEditResponse] -type loadBalancerMonitorEditResponseJSON struct { - ID apijson.Field - AllowInsecure apijson.Field - ConsecutiveDown apijson.Field - ConsecutiveUp apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Interval apijson.Field - Method apijson.Field - ModifiedOn apijson.Field - Path apijson.Field - Port apijson.Field - ProbeZone apijson.Field - Retries apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorEditResponseJSON) RawJSON() string { - return r.raw -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancerMonitorEditResponseType string - -const ( - LoadBalancerMonitorEditResponseTypeHTTP LoadBalancerMonitorEditResponseType = "http" - LoadBalancerMonitorEditResponseTypeHTTPS LoadBalancerMonitorEditResponseType = "https" - LoadBalancerMonitorEditResponseTypeTcp LoadBalancerMonitorEditResponseType = "tcp" - LoadBalancerMonitorEditResponseTypeUdpIcmp LoadBalancerMonitorEditResponseType = "udp_icmp" - LoadBalancerMonitorEditResponseTypeIcmpPing LoadBalancerMonitorEditResponseType = "icmp_ping" - LoadBalancerMonitorEditResponseTypeSmtp LoadBalancerMonitorEditResponseType = "smtp" -) - -type LoadBalancerMonitorGetResponse struct { - ID string `json:"id"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure bool `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown int64 `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp int64 `json:"consecutive_up"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Object description. - Description string `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes string `json:"expected_codes"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header interface{} `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval int64 `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method string `json:"method"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path string `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port int64 `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone string `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type LoadBalancerMonitorGetResponseType `json:"type"` - JSON loadBalancerMonitorGetResponseJSON `json:"-"` -} - -// loadBalancerMonitorGetResponseJSON contains the JSON metadata for the struct -// [LoadBalancerMonitorGetResponse] -type loadBalancerMonitorGetResponseJSON struct { - ID apijson.Field - AllowInsecure apijson.Field - ConsecutiveDown apijson.Field - ConsecutiveUp apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Interval apijson.Field - Method apijson.Field - ModifiedOn apijson.Field - Path apijson.Field - Port apijson.Field - ProbeZone apijson.Field - Retries apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorGetResponseJSON) RawJSON() string { - return r.raw -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancerMonitorGetResponseType string - -const ( - LoadBalancerMonitorGetResponseTypeHTTP LoadBalancerMonitorGetResponseType = "http" - LoadBalancerMonitorGetResponseTypeHTTPS LoadBalancerMonitorGetResponseType = "https" - LoadBalancerMonitorGetResponseTypeTcp LoadBalancerMonitorGetResponseType = "tcp" - LoadBalancerMonitorGetResponseTypeUdpIcmp LoadBalancerMonitorGetResponseType = "udp_icmp" - LoadBalancerMonitorGetResponseTypeIcmpPing LoadBalancerMonitorGetResponseType = "icmp_ping" - LoadBalancerMonitorGetResponseTypeSmtp LoadBalancerMonitorGetResponseType = "smtp" -) - -type LoadBalancerMonitorNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes param.Field[string] `json:"expected_codes,required"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown param.Field[int64] `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp param.Field[int64] `json:"consecutive_up"` - // Object description. - Description param.Field[string] `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody param.Field[string] `json:"expected_body"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header param.Field[interface{}] `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method param.Field[string] `json:"method"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path param.Field[string] `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port param.Field[int64] `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone param.Field[string] `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type param.Field[LoadBalancerMonitorNewParamsType] `json:"type"` -} - -func (r LoadBalancerMonitorNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancerMonitorNewParamsType string - -const ( - LoadBalancerMonitorNewParamsTypeHTTP LoadBalancerMonitorNewParamsType = "http" - LoadBalancerMonitorNewParamsTypeHTTPS LoadBalancerMonitorNewParamsType = "https" - LoadBalancerMonitorNewParamsTypeTcp LoadBalancerMonitorNewParamsType = "tcp" - LoadBalancerMonitorNewParamsTypeUdpIcmp LoadBalancerMonitorNewParamsType = "udp_icmp" - LoadBalancerMonitorNewParamsTypeIcmpPing LoadBalancerMonitorNewParamsType = "icmp_ping" - LoadBalancerMonitorNewParamsTypeSmtp LoadBalancerMonitorNewParamsType = "smtp" -) - -type LoadBalancerMonitorNewResponseEnvelope struct { - Errors []LoadBalancerMonitorNewResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerMonitorNewResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerMonitorNewResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerMonitorNewResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerMonitorNewResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerMonitorNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerMonitorNewResponseEnvelope] -type loadBalancerMonitorNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerMonitorNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerMonitorNewResponseEnvelopeErrors] -type loadBalancerMonitorNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerMonitorNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerMonitorNewResponseEnvelopeMessages] -type loadBalancerMonitorNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerMonitorNewResponseEnvelopeSuccess bool - -const ( - LoadBalancerMonitorNewResponseEnvelopeSuccessTrue LoadBalancerMonitorNewResponseEnvelopeSuccess = true -) - -type LoadBalancerMonitorUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes param.Field[string] `json:"expected_codes,required"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown param.Field[int64] `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp param.Field[int64] `json:"consecutive_up"` - // Object description. - Description param.Field[string] `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody param.Field[string] `json:"expected_body"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header param.Field[interface{}] `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method param.Field[string] `json:"method"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path param.Field[string] `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port param.Field[int64] `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone param.Field[string] `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type param.Field[LoadBalancerMonitorUpdateParamsType] `json:"type"` -} - -func (r LoadBalancerMonitorUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancerMonitorUpdateParamsType string - -const ( - LoadBalancerMonitorUpdateParamsTypeHTTP LoadBalancerMonitorUpdateParamsType = "http" - LoadBalancerMonitorUpdateParamsTypeHTTPS LoadBalancerMonitorUpdateParamsType = "https" - LoadBalancerMonitorUpdateParamsTypeTcp LoadBalancerMonitorUpdateParamsType = "tcp" - LoadBalancerMonitorUpdateParamsTypeUdpIcmp LoadBalancerMonitorUpdateParamsType = "udp_icmp" - LoadBalancerMonitorUpdateParamsTypeIcmpPing LoadBalancerMonitorUpdateParamsType = "icmp_ping" - LoadBalancerMonitorUpdateParamsTypeSmtp LoadBalancerMonitorUpdateParamsType = "smtp" -) - -type LoadBalancerMonitorUpdateResponseEnvelope struct { - Errors []LoadBalancerMonitorUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerMonitorUpdateResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerMonitorUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerMonitorUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerMonitorUpdateResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerMonitorUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerMonitorUpdateResponseEnvelope] -type loadBalancerMonitorUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerMonitorUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [LoadBalancerMonitorUpdateResponseEnvelopeErrors] -type loadBalancerMonitorUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerMonitorUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerMonitorUpdateResponseEnvelopeMessages] -type loadBalancerMonitorUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerMonitorUpdateResponseEnvelopeSuccess bool - -const ( - LoadBalancerMonitorUpdateResponseEnvelopeSuccessTrue LoadBalancerMonitorUpdateResponseEnvelopeSuccess = true -) - -type LoadBalancerMonitorListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type LoadBalancerMonitorListResponseEnvelope struct { - Errors []LoadBalancerMonitorListResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerMonitorListResponseEnvelopeMessages `json:"messages,required"` - Result []LoadBalancerMonitorListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LoadBalancerMonitorListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo LoadBalancerMonitorListResponseEnvelopeResultInfo `json:"result_info"` - JSON loadBalancerMonitorListResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerMonitorListResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerMonitorListResponseEnvelope] -type loadBalancerMonitorListResponseEnvelopeJSON 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 *LoadBalancerMonitorListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorListResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerMonitorListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerMonitorListResponseEnvelopeErrors] -type loadBalancerMonitorListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorListResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerMonitorListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerMonitorListResponseEnvelopeMessages] -type loadBalancerMonitorListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerMonitorListResponseEnvelopeSuccess bool - -const ( - LoadBalancerMonitorListResponseEnvelopeSuccessTrue LoadBalancerMonitorListResponseEnvelopeSuccess = true -) - -type LoadBalancerMonitorListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON loadBalancerMonitorListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// loadBalancerMonitorListResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [LoadBalancerMonitorListResponseEnvelopeResultInfo] -type loadBalancerMonitorListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type LoadBalancerMonitorDeleteResponseEnvelope struct { - Errors []LoadBalancerMonitorDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerMonitorDeleteResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerMonitorDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerMonitorDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerMonitorDeleteResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerMonitorDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerMonitorDeleteResponseEnvelope] -type loadBalancerMonitorDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerMonitorDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [LoadBalancerMonitorDeleteResponseEnvelopeErrors] -type loadBalancerMonitorDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerMonitorDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerMonitorDeleteResponseEnvelopeMessages] -type loadBalancerMonitorDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerMonitorDeleteResponseEnvelopeSuccess bool - -const ( - LoadBalancerMonitorDeleteResponseEnvelopeSuccessTrue LoadBalancerMonitorDeleteResponseEnvelopeSuccess = true -) - -type LoadBalancerMonitorEditParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes param.Field[string] `json:"expected_codes,required"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown param.Field[int64] `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp param.Field[int64] `json:"consecutive_up"` - // Object description. - Description param.Field[string] `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody param.Field[string] `json:"expected_body"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header param.Field[interface{}] `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method param.Field[string] `json:"method"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path param.Field[string] `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port param.Field[int64] `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone param.Field[string] `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type param.Field[LoadBalancerMonitorEditParamsType] `json:"type"` -} - -func (r LoadBalancerMonitorEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancerMonitorEditParamsType string - -const ( - LoadBalancerMonitorEditParamsTypeHTTP LoadBalancerMonitorEditParamsType = "http" - LoadBalancerMonitorEditParamsTypeHTTPS LoadBalancerMonitorEditParamsType = "https" - LoadBalancerMonitorEditParamsTypeTcp LoadBalancerMonitorEditParamsType = "tcp" - LoadBalancerMonitorEditParamsTypeUdpIcmp LoadBalancerMonitorEditParamsType = "udp_icmp" - LoadBalancerMonitorEditParamsTypeIcmpPing LoadBalancerMonitorEditParamsType = "icmp_ping" - LoadBalancerMonitorEditParamsTypeSmtp LoadBalancerMonitorEditParamsType = "smtp" -) - -type LoadBalancerMonitorEditResponseEnvelope struct { - Errors []LoadBalancerMonitorEditResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerMonitorEditResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerMonitorEditResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerMonitorEditResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerMonitorEditResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerMonitorEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerMonitorEditResponseEnvelope] -type loadBalancerMonitorEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerMonitorEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerMonitorEditResponseEnvelopeErrors] -type loadBalancerMonitorEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerMonitorEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerMonitorEditResponseEnvelopeMessages] -type loadBalancerMonitorEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerMonitorEditResponseEnvelopeSuccess bool - -const ( - LoadBalancerMonitorEditResponseEnvelopeSuccessTrue LoadBalancerMonitorEditResponseEnvelopeSuccess = true -) - -type LoadBalancerMonitorGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type LoadBalancerMonitorGetResponseEnvelope struct { - Errors []LoadBalancerMonitorGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerMonitorGetResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerMonitorGetResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerMonitorGetResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerMonitorGetResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerMonitorGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerMonitorGetResponseEnvelope] -type loadBalancerMonitorGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerMonitorGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerMonitorGetResponseEnvelopeErrors] -type loadBalancerMonitorGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerMonitorGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerMonitorGetResponseEnvelopeMessages] -type loadBalancerMonitorGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerMonitorGetResponseEnvelopeSuccess bool - -const ( - LoadBalancerMonitorGetResponseEnvelopeSuccessTrue LoadBalancerMonitorGetResponseEnvelopeSuccess = true -) diff --git a/loadbalancermonitor_test.go b/loadbalancermonitor_test.go deleted file mode 100644 index 11a11d31d7c..00000000000 --- a/loadbalancermonitor_test.go +++ /dev/null @@ -1,255 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLoadBalancerMonitorNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.LoadBalancers.Monitors.New(context.TODO(), cloudflare.LoadBalancerMonitorNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - ExpectedCodes: cloudflare.F("2xx"), - AllowInsecure: cloudflare.F(true), - ConsecutiveDown: cloudflare.F(int64(0)), - ConsecutiveUp: cloudflare.F(int64(0)), - Description: cloudflare.F("Login page monitor"), - ExpectedBody: cloudflare.F("alive"), - FollowRedirects: cloudflare.F(true), - Header: cloudflare.F[any](map[string]interface{}{ - "Host": map[string]interface{}{ - "0": "example.com", - }, - "X-App-ID": map[string]interface{}{ - "0": "abc123", - }, - }), - Interval: cloudflare.F(int64(0)), - Method: cloudflare.F("GET"), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - ProbeZone: cloudflare.F("example.com"), - Retries: cloudflare.F(int64(0)), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F(cloudflare.LoadBalancerMonitorNewParamsTypeHTTPS), - }) - 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 TestLoadBalancerMonitorUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.LoadBalancers.Monitors.Update( - context.TODO(), - "f1aba936b94213e5b8dca0c0dbf1f9cc", - cloudflare.LoadBalancerMonitorUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - ExpectedCodes: cloudflare.F("2xx"), - AllowInsecure: cloudflare.F(true), - ConsecutiveDown: cloudflare.F(int64(0)), - ConsecutiveUp: cloudflare.F(int64(0)), - Description: cloudflare.F("Login page monitor"), - ExpectedBody: cloudflare.F("alive"), - FollowRedirects: cloudflare.F(true), - Header: cloudflare.F[any](map[string]interface{}{ - "Host": map[string]interface{}{ - "0": "example.com", - }, - "X-App-ID": map[string]interface{}{ - "0": "abc123", - }, - }), - Interval: cloudflare.F(int64(0)), - Method: cloudflare.F("GET"), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - ProbeZone: cloudflare.F("example.com"), - Retries: cloudflare.F(int64(0)), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F(cloudflare.LoadBalancerMonitorUpdateParamsTypeHTTPS), - }, - ) - 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 TestLoadBalancerMonitorList(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("user@example.com"), - ) - _, err := client.LoadBalancers.Monitors.List(context.TODO(), cloudflare.LoadBalancerMonitorListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestLoadBalancerMonitorDelete(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("user@example.com"), - ) - _, err := client.LoadBalancers.Monitors.Delete( - context.TODO(), - "f1aba936b94213e5b8dca0c0dbf1f9cc", - cloudflare.LoadBalancerMonitorDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestLoadBalancerMonitorEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.LoadBalancers.Monitors.Edit( - context.TODO(), - "f1aba936b94213e5b8dca0c0dbf1f9cc", - cloudflare.LoadBalancerMonitorEditParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - ExpectedCodes: cloudflare.F("2xx"), - AllowInsecure: cloudflare.F(true), - ConsecutiveDown: cloudflare.F(int64(0)), - ConsecutiveUp: cloudflare.F(int64(0)), - Description: cloudflare.F("Login page monitor"), - ExpectedBody: cloudflare.F("alive"), - FollowRedirects: cloudflare.F(true), - Header: cloudflare.F[any](map[string]interface{}{ - "Host": map[string]interface{}{ - "0": "example.com", - }, - "X-App-ID": map[string]interface{}{ - "0": "abc123", - }, - }), - Interval: cloudflare.F(int64(0)), - Method: cloudflare.F("GET"), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - ProbeZone: cloudflare.F("example.com"), - Retries: cloudflare.F(int64(0)), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F(cloudflare.LoadBalancerMonitorEditParamsTypeHTTPS), - }, - ) - 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 TestLoadBalancerMonitorGet(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("user@example.com"), - ) - _, err := client.LoadBalancers.Monitors.Get( - context.TODO(), - "f1aba936b94213e5b8dca0c0dbf1f9cc", - cloudflare.LoadBalancerMonitorGetParams{ - AccountID: cloudflare.F("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/loadbalancermonitorpreview.go b/loadbalancermonitorpreview.go deleted file mode 100644 index 39d5be9e36c..00000000000 --- a/loadbalancermonitorpreview.go +++ /dev/null @@ -1,222 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// LoadBalancerMonitorPreviewService 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 -// [NewLoadBalancerMonitorPreviewService] method instead. -type LoadBalancerMonitorPreviewService struct { - Options []option.RequestOption -} - -// NewLoadBalancerMonitorPreviewService 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 NewLoadBalancerMonitorPreviewService(opts ...option.RequestOption) (r *LoadBalancerMonitorPreviewService) { - r = &LoadBalancerMonitorPreviewService{} - r.Options = opts - return -} - -// Preview pools using the specified monitor with provided monitor details. The -// returned preview_id can be used in the preview endpoint to retrieve the results. -func (r *LoadBalancerMonitorPreviewService) New(ctx context.Context, monitorID string, params LoadBalancerMonitorPreviewNewParams, opts ...option.RequestOption) (res *LoadBalancerMonitorPreviewNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerMonitorPreviewNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s/preview", params.AccountID, monitorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LoadBalancerMonitorPreviewNewResponse struct { - // Monitored pool IDs mapped to their respective names. - Pools map[string]string `json:"pools"` - PreviewID string `json:"preview_id"` - JSON loadBalancerMonitorPreviewNewResponseJSON `json:"-"` -} - -// loadBalancerMonitorPreviewNewResponseJSON contains the JSON metadata for the -// struct [LoadBalancerMonitorPreviewNewResponse] -type loadBalancerMonitorPreviewNewResponseJSON struct { - Pools apijson.Field - PreviewID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorPreviewNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorPreviewNewResponseJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorPreviewNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes param.Field[string] `json:"expected_codes,required"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown param.Field[int64] `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp param.Field[int64] `json:"consecutive_up"` - // Object description. - Description param.Field[string] `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody param.Field[string] `json:"expected_body"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header param.Field[interface{}] `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method param.Field[string] `json:"method"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path param.Field[string] `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port param.Field[int64] `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone param.Field[string] `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type param.Field[LoadBalancerMonitorPreviewNewParamsType] `json:"type"` -} - -func (r LoadBalancerMonitorPreviewNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancerMonitorPreviewNewParamsType string - -const ( - LoadBalancerMonitorPreviewNewParamsTypeHTTP LoadBalancerMonitorPreviewNewParamsType = "http" - LoadBalancerMonitorPreviewNewParamsTypeHTTPS LoadBalancerMonitorPreviewNewParamsType = "https" - LoadBalancerMonitorPreviewNewParamsTypeTcp LoadBalancerMonitorPreviewNewParamsType = "tcp" - LoadBalancerMonitorPreviewNewParamsTypeUdpIcmp LoadBalancerMonitorPreviewNewParamsType = "udp_icmp" - LoadBalancerMonitorPreviewNewParamsTypeIcmpPing LoadBalancerMonitorPreviewNewParamsType = "icmp_ping" - LoadBalancerMonitorPreviewNewParamsTypeSmtp LoadBalancerMonitorPreviewNewParamsType = "smtp" -) - -type LoadBalancerMonitorPreviewNewResponseEnvelope struct { - Errors []LoadBalancerMonitorPreviewNewResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerMonitorPreviewNewResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerMonitorPreviewNewResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerMonitorPreviewNewResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerMonitorPreviewNewResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerMonitorPreviewNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [LoadBalancerMonitorPreviewNewResponseEnvelope] -type loadBalancerMonitorPreviewNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorPreviewNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorPreviewNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorPreviewNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorPreviewNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerMonitorPreviewNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [LoadBalancerMonitorPreviewNewResponseEnvelopeErrors] -type loadBalancerMonitorPreviewNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorPreviewNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorPreviewNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorPreviewNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorPreviewNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerMonitorPreviewNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [LoadBalancerMonitorPreviewNewResponseEnvelopeMessages] -type loadBalancerMonitorPreviewNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorPreviewNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorPreviewNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerMonitorPreviewNewResponseEnvelopeSuccess bool - -const ( - LoadBalancerMonitorPreviewNewResponseEnvelopeSuccessTrue LoadBalancerMonitorPreviewNewResponseEnvelopeSuccess = true -) diff --git a/loadbalancermonitorpreview_test.go b/loadbalancermonitorpreview_test.go deleted file mode 100644 index 93536406f40..00000000000 --- a/loadbalancermonitorpreview_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLoadBalancerMonitorPreviewNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.LoadBalancers.Monitors.Previews.New( - context.TODO(), - "f1aba936b94213e5b8dca0c0dbf1f9cc", - cloudflare.LoadBalancerMonitorPreviewNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - ExpectedCodes: cloudflare.F("2xx"), - AllowInsecure: cloudflare.F(true), - ConsecutiveDown: cloudflare.F(int64(0)), - ConsecutiveUp: cloudflare.F(int64(0)), - Description: cloudflare.F("Login page monitor"), - ExpectedBody: cloudflare.F("alive"), - FollowRedirects: cloudflare.F(true), - Header: cloudflare.F[any](map[string]interface{}{ - "Host": map[string]interface{}{ - "0": "example.com", - }, - "X-App-ID": map[string]interface{}{ - "0": "abc123", - }, - }), - Interval: cloudflare.F(int64(0)), - Method: cloudflare.F("GET"), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - ProbeZone: cloudflare.F("example.com"), - Retries: cloudflare.F(int64(0)), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F(cloudflare.LoadBalancerMonitorPreviewNewParamsTypeHTTPS), - }, - ) - 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/loadbalancermonitorreference.go b/loadbalancermonitorreference.go deleted file mode 100644 index a43cb73e718..00000000000 --- a/loadbalancermonitorreference.go +++ /dev/null @@ -1,202 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// LoadBalancerMonitorReferenceService 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 -// [NewLoadBalancerMonitorReferenceService] method instead. -type LoadBalancerMonitorReferenceService struct { - Options []option.RequestOption -} - -// NewLoadBalancerMonitorReferenceService 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 NewLoadBalancerMonitorReferenceService(opts ...option.RequestOption) (r *LoadBalancerMonitorReferenceService) { - r = &LoadBalancerMonitorReferenceService{} - r.Options = opts - return -} - -// Get the list of resources that reference the provided monitor. -func (r *LoadBalancerMonitorReferenceService) Get(ctx context.Context, monitorID string, query LoadBalancerMonitorReferenceGetParams, opts ...option.RequestOption) (res *[]LoadBalancerMonitorReferenceGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerMonitorReferenceGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/monitors/%s/references", query.AccountID, monitorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LoadBalancerMonitorReferenceGetResponse struct { - ReferenceType LoadBalancerMonitorReferenceGetResponseReferenceType `json:"reference_type"` - ResourceID string `json:"resource_id"` - ResourceName string `json:"resource_name"` - ResourceType string `json:"resource_type"` - JSON loadBalancerMonitorReferenceGetResponseJSON `json:"-"` -} - -// loadBalancerMonitorReferenceGetResponseJSON contains the JSON metadata for the -// struct [LoadBalancerMonitorReferenceGetResponse] -type loadBalancerMonitorReferenceGetResponseJSON struct { - ReferenceType apijson.Field - ResourceID apijson.Field - ResourceName apijson.Field - ResourceType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorReferenceGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorReferenceGetResponseJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorReferenceGetResponseReferenceType string - -const ( - LoadBalancerMonitorReferenceGetResponseReferenceTypeStar LoadBalancerMonitorReferenceGetResponseReferenceType = "*" - LoadBalancerMonitorReferenceGetResponseReferenceTypeReferral LoadBalancerMonitorReferenceGetResponseReferenceType = "referral" - LoadBalancerMonitorReferenceGetResponseReferenceTypeReferrer LoadBalancerMonitorReferenceGetResponseReferenceType = "referrer" -) - -type LoadBalancerMonitorReferenceGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type LoadBalancerMonitorReferenceGetResponseEnvelope struct { - Errors []LoadBalancerMonitorReferenceGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerMonitorReferenceGetResponseEnvelopeMessages `json:"messages,required"` - // List of resources that reference a given monitor. - Result []LoadBalancerMonitorReferenceGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LoadBalancerMonitorReferenceGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo LoadBalancerMonitorReferenceGetResponseEnvelopeResultInfo `json:"result_info"` - JSON loadBalancerMonitorReferenceGetResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerMonitorReferenceGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [LoadBalancerMonitorReferenceGetResponseEnvelope] -type loadBalancerMonitorReferenceGetResponseEnvelopeJSON 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 *LoadBalancerMonitorReferenceGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorReferenceGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorReferenceGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorReferenceGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerMonitorReferenceGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [LoadBalancerMonitorReferenceGetResponseEnvelopeErrors] -type loadBalancerMonitorReferenceGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorReferenceGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorReferenceGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerMonitorReferenceGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerMonitorReferenceGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerMonitorReferenceGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [LoadBalancerMonitorReferenceGetResponseEnvelopeMessages] -type loadBalancerMonitorReferenceGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorReferenceGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorReferenceGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerMonitorReferenceGetResponseEnvelopeSuccess bool - -const ( - LoadBalancerMonitorReferenceGetResponseEnvelopeSuccessTrue LoadBalancerMonitorReferenceGetResponseEnvelopeSuccess = true -) - -type LoadBalancerMonitorReferenceGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON loadBalancerMonitorReferenceGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// loadBalancerMonitorReferenceGetResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [LoadBalancerMonitorReferenceGetResponseEnvelopeResultInfo] -type loadBalancerMonitorReferenceGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerMonitorReferenceGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerMonitorReferenceGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/loadbalancermonitorreference_test.go b/loadbalancermonitorreference_test.go deleted file mode 100644 index 98db9de939c..00000000000 --- a/loadbalancermonitorreference_test.go +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLoadBalancerMonitorReferenceGet(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("user@example.com"), - ) - _, err := client.LoadBalancers.Monitors.References.Get( - context.TODO(), - "f1aba936b94213e5b8dca0c0dbf1f9cc", - cloudflare.LoadBalancerMonitorReferenceGetParams{ - AccountID: cloudflare.F("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/loadbalancerpool.go b/loadbalancerpool.go deleted file mode 100644 index 3e30341e087..00000000000 --- a/loadbalancerpool.go +++ /dev/null @@ -1,3344 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// LoadBalancerPoolService 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 [NewLoadBalancerPoolService] method -// instead. -type LoadBalancerPoolService struct { - Options []option.RequestOption - Health *LoadBalancerPoolHealthService - References *LoadBalancerPoolReferenceService -} - -// NewLoadBalancerPoolService 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 NewLoadBalancerPoolService(opts ...option.RequestOption) (r *LoadBalancerPoolService) { - r = &LoadBalancerPoolService{} - r.Options = opts - r.Health = NewLoadBalancerPoolHealthService(opts...) - r.References = NewLoadBalancerPoolReferenceService(opts...) - return -} - -// Create a new pool. -func (r *LoadBalancerPoolService) New(ctx context.Context, params LoadBalancerPoolNewParams, opts ...option.RequestOption) (res *LoadBalancerPoolNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPoolNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/pools", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Modify a configured pool. -func (r *LoadBalancerPoolService) Update(ctx context.Context, poolID string, params LoadBalancerPoolUpdateParams, opts ...option.RequestOption) (res *LoadBalancerPoolUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPoolUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s", params.AccountID, poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List configured pools. -func (r *LoadBalancerPoolService) List(ctx context.Context, params LoadBalancerPoolListParams, opts ...option.RequestOption) (res *[]LoadBalancerPoolListResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPoolListResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/pools", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a configured pool. -func (r *LoadBalancerPoolService) Delete(ctx context.Context, poolID string, body LoadBalancerPoolDeleteParams, opts ...option.RequestOption) (res *LoadBalancerPoolDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPoolDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s", body.AccountID, poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Apply changes to an existing pool, overwriting the supplied properties. -func (r *LoadBalancerPoolService) Edit(ctx context.Context, poolID string, params LoadBalancerPoolEditParams, opts ...option.RequestOption) (res *LoadBalancerPoolEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPoolEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s", params.AccountID, poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch a single configured pool. -func (r *LoadBalancerPoolService) Get(ctx context.Context, poolID string, query LoadBalancerPoolGetParams, opts ...option.RequestOption) (res *LoadBalancerPoolGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPoolGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s", query.AccountID, poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LoadBalancerPoolNewResponse struct { - ID string `json:"id"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions []LoadBalancerPoolNewResponseCheckRegion `json:"check_regions,nullable"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A human-readable description of the pool. - Description string `json:"description"` - // This field shows up only if the pool is disabled. This field is set with the - // time the pool was disabled at. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) or disable this pool. Disabled pools will not - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled bool `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, longitude must also be set. - Latitude float64 `json:"latitude"` - // Configures load shedding policies and percentages for the pool. - LoadShedding LoadBalancerPoolNewResponseLoadShedding `json:"load_shedding"` - // The longitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, latitude must also be set. - Longitude float64 `json:"longitude"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins int64 `json:"minimum_origins"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor interface{} `json:"monitor"` - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - Name string `json:"name"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - NotificationEmail string `json:"notification_email"` - // Filter pool and origin health notifications by resource type or health status. - // Use null to reset. - NotificationFilter LoadBalancerPoolNewResponseNotificationFilter `json:"notification_filter,nullable"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering LoadBalancerPoolNewResponseOriginSteering `json:"origin_steering"` - // The list of origins within this pool. Traffic directed at this pool is balanced - // across all currently healthy origins, provided the pool itself is healthy. - Origins []LoadBalancerPoolNewResponseOrigin `json:"origins"` - JSON loadBalancerPoolNewResponseJSON `json:"-"` -} - -// loadBalancerPoolNewResponseJSON contains the JSON metadata for the struct -// [LoadBalancerPoolNewResponse] -type loadBalancerPoolNewResponseJSON struct { - ID apijson.Field - CheckRegions apijson.Field - CreatedOn apijson.Field - Description apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Latitude apijson.Field - LoadShedding apijson.Field - Longitude apijson.Field - MinimumOrigins apijson.Field - ModifiedOn apijson.Field - Monitor apijson.Field - Name apijson.Field - NotificationEmail apijson.Field - NotificationFilter apijson.Field - OriginSteering apijson.Field - Origins apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolNewResponseJSON) RawJSON() string { - return r.raw -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type LoadBalancerPoolNewResponseCheckRegion string - -const ( - LoadBalancerPoolNewResponseCheckRegionWnam LoadBalancerPoolNewResponseCheckRegion = "WNAM" - LoadBalancerPoolNewResponseCheckRegionEnam LoadBalancerPoolNewResponseCheckRegion = "ENAM" - LoadBalancerPoolNewResponseCheckRegionWeu LoadBalancerPoolNewResponseCheckRegion = "WEU" - LoadBalancerPoolNewResponseCheckRegionEeu LoadBalancerPoolNewResponseCheckRegion = "EEU" - LoadBalancerPoolNewResponseCheckRegionNsam LoadBalancerPoolNewResponseCheckRegion = "NSAM" - LoadBalancerPoolNewResponseCheckRegionSsam LoadBalancerPoolNewResponseCheckRegion = "SSAM" - LoadBalancerPoolNewResponseCheckRegionOc LoadBalancerPoolNewResponseCheckRegion = "OC" - LoadBalancerPoolNewResponseCheckRegionMe LoadBalancerPoolNewResponseCheckRegion = "ME" - LoadBalancerPoolNewResponseCheckRegionNaf LoadBalancerPoolNewResponseCheckRegion = "NAF" - LoadBalancerPoolNewResponseCheckRegionSaf LoadBalancerPoolNewResponseCheckRegion = "SAF" - LoadBalancerPoolNewResponseCheckRegionSas LoadBalancerPoolNewResponseCheckRegion = "SAS" - LoadBalancerPoolNewResponseCheckRegionSeas LoadBalancerPoolNewResponseCheckRegion = "SEAS" - LoadBalancerPoolNewResponseCheckRegionNeas LoadBalancerPoolNewResponseCheckRegion = "NEAS" - LoadBalancerPoolNewResponseCheckRegionAllRegions LoadBalancerPoolNewResponseCheckRegion = "ALL_REGIONS" -) - -// Configures load shedding policies and percentages for the pool. -type LoadBalancerPoolNewResponseLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent float64 `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy LoadBalancerPoolNewResponseLoadSheddingDefaultPolicy `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent float64 `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy LoadBalancerPoolNewResponseLoadSheddingSessionPolicy `json:"session_policy"` - JSON loadBalancerPoolNewResponseLoadSheddingJSON `json:"-"` -} - -// loadBalancerPoolNewResponseLoadSheddingJSON contains the JSON metadata for the -// struct [LoadBalancerPoolNewResponseLoadShedding] -type loadBalancerPoolNewResponseLoadSheddingJSON struct { - DefaultPercent apijson.Field - DefaultPolicy apijson.Field - SessionPercent apijson.Field - SessionPolicy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolNewResponseLoadShedding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolNewResponseLoadSheddingJSON) RawJSON() string { - return r.raw -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type LoadBalancerPoolNewResponseLoadSheddingDefaultPolicy string - -const ( - LoadBalancerPoolNewResponseLoadSheddingDefaultPolicyRandom LoadBalancerPoolNewResponseLoadSheddingDefaultPolicy = "random" - LoadBalancerPoolNewResponseLoadSheddingDefaultPolicyHash LoadBalancerPoolNewResponseLoadSheddingDefaultPolicy = "hash" -) - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type LoadBalancerPoolNewResponseLoadSheddingSessionPolicy string - -const ( - LoadBalancerPoolNewResponseLoadSheddingSessionPolicyHash LoadBalancerPoolNewResponseLoadSheddingSessionPolicy = "hash" -) - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type LoadBalancerPoolNewResponseNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin LoadBalancerPoolNewResponseNotificationFilterOrigin `json:"origin,nullable"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool LoadBalancerPoolNewResponseNotificationFilterPool `json:"pool,nullable"` - JSON loadBalancerPoolNewResponseNotificationFilterJSON `json:"-"` -} - -// loadBalancerPoolNewResponseNotificationFilterJSON contains the JSON metadata for -// the struct [LoadBalancerPoolNewResponseNotificationFilter] -type loadBalancerPoolNewResponseNotificationFilterJSON struct { - Origin apijson.Field - Pool apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolNewResponseNotificationFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolNewResponseNotificationFilterJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolNewResponseNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON loadBalancerPoolNewResponseNotificationFilterOriginJSON `json:"-"` -} - -// loadBalancerPoolNewResponseNotificationFilterOriginJSON contains the JSON -// metadata for the struct [LoadBalancerPoolNewResponseNotificationFilterOrigin] -type loadBalancerPoolNewResponseNotificationFilterOriginJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolNewResponseNotificationFilterOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolNewResponseNotificationFilterOriginJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolNewResponseNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON loadBalancerPoolNewResponseNotificationFilterPoolJSON `json:"-"` -} - -// loadBalancerPoolNewResponseNotificationFilterPoolJSON contains the JSON metadata -// for the struct [LoadBalancerPoolNewResponseNotificationFilterPool] -type loadBalancerPoolNewResponseNotificationFilterPoolJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolNewResponseNotificationFilterPool) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolNewResponseNotificationFilterPoolJSON) RawJSON() string { - return r.raw -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type LoadBalancerPoolNewResponseOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy LoadBalancerPoolNewResponseOriginSteeringPolicy `json:"policy"` - JSON loadBalancerPoolNewResponseOriginSteeringJSON `json:"-"` -} - -// loadBalancerPoolNewResponseOriginSteeringJSON contains the JSON metadata for the -// struct [LoadBalancerPoolNewResponseOriginSteering] -type loadBalancerPoolNewResponseOriginSteeringJSON struct { - Policy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolNewResponseOriginSteering) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolNewResponseOriginSteeringJSON) RawJSON() string { - return r.raw -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type LoadBalancerPoolNewResponseOriginSteeringPolicy string - -const ( - LoadBalancerPoolNewResponseOriginSteeringPolicyRandom LoadBalancerPoolNewResponseOriginSteeringPolicy = "random" - LoadBalancerPoolNewResponseOriginSteeringPolicyHash LoadBalancerPoolNewResponseOriginSteeringPolicy = "hash" - LoadBalancerPoolNewResponseOriginSteeringPolicyLeastOutstandingRequests LoadBalancerPoolNewResponseOriginSteeringPolicy = "least_outstanding_requests" - LoadBalancerPoolNewResponseOriginSteeringPolicyLeastConnections LoadBalancerPoolNewResponseOriginSteeringPolicy = "least_connections" -) - -type LoadBalancerPoolNewResponseOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address string `json:"address"` - // This field shows up only if the origin is disabled. This field is set with the - // time the origin was disabled. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled bool `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header LoadBalancerPoolNewResponseOriginsHeader `json:"header"` - // A human-identifiable name for the origin. - Name string `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID string `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight float64 `json:"weight"` - JSON loadBalancerPoolNewResponseOriginJSON `json:"-"` -} - -// loadBalancerPoolNewResponseOriginJSON contains the JSON metadata for the struct -// [LoadBalancerPoolNewResponseOrigin] -type loadBalancerPoolNewResponseOriginJSON struct { - Address apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Header apijson.Field - Name apijson.Field - VirtualNetworkID apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolNewResponseOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolNewResponseOriginJSON) RawJSON() string { - return r.raw -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type LoadBalancerPoolNewResponseOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host []string `json:"Host"` - JSON loadBalancerPoolNewResponseOriginsHeaderJSON `json:"-"` -} - -// loadBalancerPoolNewResponseOriginsHeaderJSON contains the JSON metadata for the -// struct [LoadBalancerPoolNewResponseOriginsHeader] -type loadBalancerPoolNewResponseOriginsHeaderJSON struct { - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolNewResponseOriginsHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolNewResponseOriginsHeaderJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolUpdateResponse struct { - ID string `json:"id"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions []LoadBalancerPoolUpdateResponseCheckRegion `json:"check_regions,nullable"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A human-readable description of the pool. - Description string `json:"description"` - // This field shows up only if the pool is disabled. This field is set with the - // time the pool was disabled at. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) or disable this pool. Disabled pools will not - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled bool `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, longitude must also be set. - Latitude float64 `json:"latitude"` - // Configures load shedding policies and percentages for the pool. - LoadShedding LoadBalancerPoolUpdateResponseLoadShedding `json:"load_shedding"` - // The longitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, latitude must also be set. - Longitude float64 `json:"longitude"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins int64 `json:"minimum_origins"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor interface{} `json:"monitor"` - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - Name string `json:"name"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - NotificationEmail string `json:"notification_email"` - // Filter pool and origin health notifications by resource type or health status. - // Use null to reset. - NotificationFilter LoadBalancerPoolUpdateResponseNotificationFilter `json:"notification_filter,nullable"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering LoadBalancerPoolUpdateResponseOriginSteering `json:"origin_steering"` - // The list of origins within this pool. Traffic directed at this pool is balanced - // across all currently healthy origins, provided the pool itself is healthy. - Origins []LoadBalancerPoolUpdateResponseOrigin `json:"origins"` - JSON loadBalancerPoolUpdateResponseJSON `json:"-"` -} - -// loadBalancerPoolUpdateResponseJSON contains the JSON metadata for the struct -// [LoadBalancerPoolUpdateResponse] -type loadBalancerPoolUpdateResponseJSON struct { - ID apijson.Field - CheckRegions apijson.Field - CreatedOn apijson.Field - Description apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Latitude apijson.Field - LoadShedding apijson.Field - Longitude apijson.Field - MinimumOrigins apijson.Field - ModifiedOn apijson.Field - Monitor apijson.Field - Name apijson.Field - NotificationEmail apijson.Field - NotificationFilter apijson.Field - OriginSteering apijson.Field - Origins apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type LoadBalancerPoolUpdateResponseCheckRegion string - -const ( - LoadBalancerPoolUpdateResponseCheckRegionWnam LoadBalancerPoolUpdateResponseCheckRegion = "WNAM" - LoadBalancerPoolUpdateResponseCheckRegionEnam LoadBalancerPoolUpdateResponseCheckRegion = "ENAM" - LoadBalancerPoolUpdateResponseCheckRegionWeu LoadBalancerPoolUpdateResponseCheckRegion = "WEU" - LoadBalancerPoolUpdateResponseCheckRegionEeu LoadBalancerPoolUpdateResponseCheckRegion = "EEU" - LoadBalancerPoolUpdateResponseCheckRegionNsam LoadBalancerPoolUpdateResponseCheckRegion = "NSAM" - LoadBalancerPoolUpdateResponseCheckRegionSsam LoadBalancerPoolUpdateResponseCheckRegion = "SSAM" - LoadBalancerPoolUpdateResponseCheckRegionOc LoadBalancerPoolUpdateResponseCheckRegion = "OC" - LoadBalancerPoolUpdateResponseCheckRegionMe LoadBalancerPoolUpdateResponseCheckRegion = "ME" - LoadBalancerPoolUpdateResponseCheckRegionNaf LoadBalancerPoolUpdateResponseCheckRegion = "NAF" - LoadBalancerPoolUpdateResponseCheckRegionSaf LoadBalancerPoolUpdateResponseCheckRegion = "SAF" - LoadBalancerPoolUpdateResponseCheckRegionSas LoadBalancerPoolUpdateResponseCheckRegion = "SAS" - LoadBalancerPoolUpdateResponseCheckRegionSeas LoadBalancerPoolUpdateResponseCheckRegion = "SEAS" - LoadBalancerPoolUpdateResponseCheckRegionNeas LoadBalancerPoolUpdateResponseCheckRegion = "NEAS" - LoadBalancerPoolUpdateResponseCheckRegionAllRegions LoadBalancerPoolUpdateResponseCheckRegion = "ALL_REGIONS" -) - -// Configures load shedding policies and percentages for the pool. -type LoadBalancerPoolUpdateResponseLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent float64 `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy LoadBalancerPoolUpdateResponseLoadSheddingDefaultPolicy `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent float64 `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy LoadBalancerPoolUpdateResponseLoadSheddingSessionPolicy `json:"session_policy"` - JSON loadBalancerPoolUpdateResponseLoadSheddingJSON `json:"-"` -} - -// loadBalancerPoolUpdateResponseLoadSheddingJSON contains the JSON metadata for -// the struct [LoadBalancerPoolUpdateResponseLoadShedding] -type loadBalancerPoolUpdateResponseLoadSheddingJSON struct { - DefaultPercent apijson.Field - DefaultPolicy apijson.Field - SessionPercent apijson.Field - SessionPolicy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolUpdateResponseLoadShedding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolUpdateResponseLoadSheddingJSON) RawJSON() string { - return r.raw -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type LoadBalancerPoolUpdateResponseLoadSheddingDefaultPolicy string - -const ( - LoadBalancerPoolUpdateResponseLoadSheddingDefaultPolicyRandom LoadBalancerPoolUpdateResponseLoadSheddingDefaultPolicy = "random" - LoadBalancerPoolUpdateResponseLoadSheddingDefaultPolicyHash LoadBalancerPoolUpdateResponseLoadSheddingDefaultPolicy = "hash" -) - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type LoadBalancerPoolUpdateResponseLoadSheddingSessionPolicy string - -const ( - LoadBalancerPoolUpdateResponseLoadSheddingSessionPolicyHash LoadBalancerPoolUpdateResponseLoadSheddingSessionPolicy = "hash" -) - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type LoadBalancerPoolUpdateResponseNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin LoadBalancerPoolUpdateResponseNotificationFilterOrigin `json:"origin,nullable"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool LoadBalancerPoolUpdateResponseNotificationFilterPool `json:"pool,nullable"` - JSON loadBalancerPoolUpdateResponseNotificationFilterJSON `json:"-"` -} - -// loadBalancerPoolUpdateResponseNotificationFilterJSON contains the JSON metadata -// for the struct [LoadBalancerPoolUpdateResponseNotificationFilter] -type loadBalancerPoolUpdateResponseNotificationFilterJSON struct { - Origin apijson.Field - Pool apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolUpdateResponseNotificationFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolUpdateResponseNotificationFilterJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolUpdateResponseNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON loadBalancerPoolUpdateResponseNotificationFilterOriginJSON `json:"-"` -} - -// loadBalancerPoolUpdateResponseNotificationFilterOriginJSON contains the JSON -// metadata for the struct [LoadBalancerPoolUpdateResponseNotificationFilterOrigin] -type loadBalancerPoolUpdateResponseNotificationFilterOriginJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolUpdateResponseNotificationFilterOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolUpdateResponseNotificationFilterOriginJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolUpdateResponseNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON loadBalancerPoolUpdateResponseNotificationFilterPoolJSON `json:"-"` -} - -// loadBalancerPoolUpdateResponseNotificationFilterPoolJSON contains the JSON -// metadata for the struct [LoadBalancerPoolUpdateResponseNotificationFilterPool] -type loadBalancerPoolUpdateResponseNotificationFilterPoolJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolUpdateResponseNotificationFilterPool) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolUpdateResponseNotificationFilterPoolJSON) RawJSON() string { - return r.raw -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type LoadBalancerPoolUpdateResponseOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy LoadBalancerPoolUpdateResponseOriginSteeringPolicy `json:"policy"` - JSON loadBalancerPoolUpdateResponseOriginSteeringJSON `json:"-"` -} - -// loadBalancerPoolUpdateResponseOriginSteeringJSON contains the JSON metadata for -// the struct [LoadBalancerPoolUpdateResponseOriginSteering] -type loadBalancerPoolUpdateResponseOriginSteeringJSON struct { - Policy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolUpdateResponseOriginSteering) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolUpdateResponseOriginSteeringJSON) RawJSON() string { - return r.raw -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type LoadBalancerPoolUpdateResponseOriginSteeringPolicy string - -const ( - LoadBalancerPoolUpdateResponseOriginSteeringPolicyRandom LoadBalancerPoolUpdateResponseOriginSteeringPolicy = "random" - LoadBalancerPoolUpdateResponseOriginSteeringPolicyHash LoadBalancerPoolUpdateResponseOriginSteeringPolicy = "hash" - LoadBalancerPoolUpdateResponseOriginSteeringPolicyLeastOutstandingRequests LoadBalancerPoolUpdateResponseOriginSteeringPolicy = "least_outstanding_requests" - LoadBalancerPoolUpdateResponseOriginSteeringPolicyLeastConnections LoadBalancerPoolUpdateResponseOriginSteeringPolicy = "least_connections" -) - -type LoadBalancerPoolUpdateResponseOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address string `json:"address"` - // This field shows up only if the origin is disabled. This field is set with the - // time the origin was disabled. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled bool `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header LoadBalancerPoolUpdateResponseOriginsHeader `json:"header"` - // A human-identifiable name for the origin. - Name string `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID string `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight float64 `json:"weight"` - JSON loadBalancerPoolUpdateResponseOriginJSON `json:"-"` -} - -// loadBalancerPoolUpdateResponseOriginJSON contains the JSON metadata for the -// struct [LoadBalancerPoolUpdateResponseOrigin] -type loadBalancerPoolUpdateResponseOriginJSON struct { - Address apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Header apijson.Field - Name apijson.Field - VirtualNetworkID apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolUpdateResponseOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolUpdateResponseOriginJSON) RawJSON() string { - return r.raw -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type LoadBalancerPoolUpdateResponseOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host []string `json:"Host"` - JSON loadBalancerPoolUpdateResponseOriginsHeaderJSON `json:"-"` -} - -// loadBalancerPoolUpdateResponseOriginsHeaderJSON contains the JSON metadata for -// the struct [LoadBalancerPoolUpdateResponseOriginsHeader] -type loadBalancerPoolUpdateResponseOriginsHeaderJSON struct { - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolUpdateResponseOriginsHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolUpdateResponseOriginsHeaderJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolListResponse struct { - ID string `json:"id"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions []LoadBalancerPoolListResponseCheckRegion `json:"check_regions,nullable"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A human-readable description of the pool. - Description string `json:"description"` - // This field shows up only if the pool is disabled. This field is set with the - // time the pool was disabled at. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) or disable this pool. Disabled pools will not - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled bool `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, longitude must also be set. - Latitude float64 `json:"latitude"` - // Configures load shedding policies and percentages for the pool. - LoadShedding LoadBalancerPoolListResponseLoadShedding `json:"load_shedding"` - // The longitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, latitude must also be set. - Longitude float64 `json:"longitude"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins int64 `json:"minimum_origins"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor interface{} `json:"monitor"` - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - Name string `json:"name"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - NotificationEmail string `json:"notification_email"` - // Filter pool and origin health notifications by resource type or health status. - // Use null to reset. - NotificationFilter LoadBalancerPoolListResponseNotificationFilter `json:"notification_filter,nullable"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering LoadBalancerPoolListResponseOriginSteering `json:"origin_steering"` - // The list of origins within this pool. Traffic directed at this pool is balanced - // across all currently healthy origins, provided the pool itself is healthy. - Origins []LoadBalancerPoolListResponseOrigin `json:"origins"` - JSON loadBalancerPoolListResponseJSON `json:"-"` -} - -// loadBalancerPoolListResponseJSON contains the JSON metadata for the struct -// [LoadBalancerPoolListResponse] -type loadBalancerPoolListResponseJSON struct { - ID apijson.Field - CheckRegions apijson.Field - CreatedOn apijson.Field - Description apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Latitude apijson.Field - LoadShedding apijson.Field - Longitude apijson.Field - MinimumOrigins apijson.Field - ModifiedOn apijson.Field - Monitor apijson.Field - Name apijson.Field - NotificationEmail apijson.Field - NotificationFilter apijson.Field - OriginSteering apijson.Field - Origins apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolListResponseJSON) RawJSON() string { - return r.raw -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type LoadBalancerPoolListResponseCheckRegion string - -const ( - LoadBalancerPoolListResponseCheckRegionWnam LoadBalancerPoolListResponseCheckRegion = "WNAM" - LoadBalancerPoolListResponseCheckRegionEnam LoadBalancerPoolListResponseCheckRegion = "ENAM" - LoadBalancerPoolListResponseCheckRegionWeu LoadBalancerPoolListResponseCheckRegion = "WEU" - LoadBalancerPoolListResponseCheckRegionEeu LoadBalancerPoolListResponseCheckRegion = "EEU" - LoadBalancerPoolListResponseCheckRegionNsam LoadBalancerPoolListResponseCheckRegion = "NSAM" - LoadBalancerPoolListResponseCheckRegionSsam LoadBalancerPoolListResponseCheckRegion = "SSAM" - LoadBalancerPoolListResponseCheckRegionOc LoadBalancerPoolListResponseCheckRegion = "OC" - LoadBalancerPoolListResponseCheckRegionMe LoadBalancerPoolListResponseCheckRegion = "ME" - LoadBalancerPoolListResponseCheckRegionNaf LoadBalancerPoolListResponseCheckRegion = "NAF" - LoadBalancerPoolListResponseCheckRegionSaf LoadBalancerPoolListResponseCheckRegion = "SAF" - LoadBalancerPoolListResponseCheckRegionSas LoadBalancerPoolListResponseCheckRegion = "SAS" - LoadBalancerPoolListResponseCheckRegionSeas LoadBalancerPoolListResponseCheckRegion = "SEAS" - LoadBalancerPoolListResponseCheckRegionNeas LoadBalancerPoolListResponseCheckRegion = "NEAS" - LoadBalancerPoolListResponseCheckRegionAllRegions LoadBalancerPoolListResponseCheckRegion = "ALL_REGIONS" -) - -// Configures load shedding policies and percentages for the pool. -type LoadBalancerPoolListResponseLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent float64 `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy LoadBalancerPoolListResponseLoadSheddingDefaultPolicy `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent float64 `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy LoadBalancerPoolListResponseLoadSheddingSessionPolicy `json:"session_policy"` - JSON loadBalancerPoolListResponseLoadSheddingJSON `json:"-"` -} - -// loadBalancerPoolListResponseLoadSheddingJSON contains the JSON metadata for the -// struct [LoadBalancerPoolListResponseLoadShedding] -type loadBalancerPoolListResponseLoadSheddingJSON struct { - DefaultPercent apijson.Field - DefaultPolicy apijson.Field - SessionPercent apijson.Field - SessionPolicy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolListResponseLoadShedding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolListResponseLoadSheddingJSON) RawJSON() string { - return r.raw -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type LoadBalancerPoolListResponseLoadSheddingDefaultPolicy string - -const ( - LoadBalancerPoolListResponseLoadSheddingDefaultPolicyRandom LoadBalancerPoolListResponseLoadSheddingDefaultPolicy = "random" - LoadBalancerPoolListResponseLoadSheddingDefaultPolicyHash LoadBalancerPoolListResponseLoadSheddingDefaultPolicy = "hash" -) - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type LoadBalancerPoolListResponseLoadSheddingSessionPolicy string - -const ( - LoadBalancerPoolListResponseLoadSheddingSessionPolicyHash LoadBalancerPoolListResponseLoadSheddingSessionPolicy = "hash" -) - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type LoadBalancerPoolListResponseNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin LoadBalancerPoolListResponseNotificationFilterOrigin `json:"origin,nullable"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool LoadBalancerPoolListResponseNotificationFilterPool `json:"pool,nullable"` - JSON loadBalancerPoolListResponseNotificationFilterJSON `json:"-"` -} - -// loadBalancerPoolListResponseNotificationFilterJSON contains the JSON metadata -// for the struct [LoadBalancerPoolListResponseNotificationFilter] -type loadBalancerPoolListResponseNotificationFilterJSON struct { - Origin apijson.Field - Pool apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolListResponseNotificationFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolListResponseNotificationFilterJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolListResponseNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON loadBalancerPoolListResponseNotificationFilterOriginJSON `json:"-"` -} - -// loadBalancerPoolListResponseNotificationFilterOriginJSON contains the JSON -// metadata for the struct [LoadBalancerPoolListResponseNotificationFilterOrigin] -type loadBalancerPoolListResponseNotificationFilterOriginJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolListResponseNotificationFilterOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolListResponseNotificationFilterOriginJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolListResponseNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON loadBalancerPoolListResponseNotificationFilterPoolJSON `json:"-"` -} - -// loadBalancerPoolListResponseNotificationFilterPoolJSON contains the JSON -// metadata for the struct [LoadBalancerPoolListResponseNotificationFilterPool] -type loadBalancerPoolListResponseNotificationFilterPoolJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolListResponseNotificationFilterPool) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolListResponseNotificationFilterPoolJSON) RawJSON() string { - return r.raw -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type LoadBalancerPoolListResponseOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy LoadBalancerPoolListResponseOriginSteeringPolicy `json:"policy"` - JSON loadBalancerPoolListResponseOriginSteeringJSON `json:"-"` -} - -// loadBalancerPoolListResponseOriginSteeringJSON contains the JSON metadata for -// the struct [LoadBalancerPoolListResponseOriginSteering] -type loadBalancerPoolListResponseOriginSteeringJSON struct { - Policy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolListResponseOriginSteering) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolListResponseOriginSteeringJSON) RawJSON() string { - return r.raw -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type LoadBalancerPoolListResponseOriginSteeringPolicy string - -const ( - LoadBalancerPoolListResponseOriginSteeringPolicyRandom LoadBalancerPoolListResponseOriginSteeringPolicy = "random" - LoadBalancerPoolListResponseOriginSteeringPolicyHash LoadBalancerPoolListResponseOriginSteeringPolicy = "hash" - LoadBalancerPoolListResponseOriginSteeringPolicyLeastOutstandingRequests LoadBalancerPoolListResponseOriginSteeringPolicy = "least_outstanding_requests" - LoadBalancerPoolListResponseOriginSteeringPolicyLeastConnections LoadBalancerPoolListResponseOriginSteeringPolicy = "least_connections" -) - -type LoadBalancerPoolListResponseOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address string `json:"address"` - // This field shows up only if the origin is disabled. This field is set with the - // time the origin was disabled. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled bool `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header LoadBalancerPoolListResponseOriginsHeader `json:"header"` - // A human-identifiable name for the origin. - Name string `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID string `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight float64 `json:"weight"` - JSON loadBalancerPoolListResponseOriginJSON `json:"-"` -} - -// loadBalancerPoolListResponseOriginJSON contains the JSON metadata for the struct -// [LoadBalancerPoolListResponseOrigin] -type loadBalancerPoolListResponseOriginJSON struct { - Address apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Header apijson.Field - Name apijson.Field - VirtualNetworkID apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolListResponseOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolListResponseOriginJSON) RawJSON() string { - return r.raw -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type LoadBalancerPoolListResponseOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host []string `json:"Host"` - JSON loadBalancerPoolListResponseOriginsHeaderJSON `json:"-"` -} - -// loadBalancerPoolListResponseOriginsHeaderJSON contains the JSON metadata for the -// struct [LoadBalancerPoolListResponseOriginsHeader] -type loadBalancerPoolListResponseOriginsHeaderJSON struct { - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolListResponseOriginsHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolListResponseOriginsHeaderJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolDeleteResponse struct { - ID string `json:"id"` - JSON loadBalancerPoolDeleteResponseJSON `json:"-"` -} - -// loadBalancerPoolDeleteResponseJSON contains the JSON metadata for the struct -// [LoadBalancerPoolDeleteResponse] -type loadBalancerPoolDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolEditResponse struct { - ID string `json:"id"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions []LoadBalancerPoolEditResponseCheckRegion `json:"check_regions,nullable"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A human-readable description of the pool. - Description string `json:"description"` - // This field shows up only if the pool is disabled. This field is set with the - // time the pool was disabled at. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) or disable this pool. Disabled pools will not - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled bool `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, longitude must also be set. - Latitude float64 `json:"latitude"` - // Configures load shedding policies and percentages for the pool. - LoadShedding LoadBalancerPoolEditResponseLoadShedding `json:"load_shedding"` - // The longitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, latitude must also be set. - Longitude float64 `json:"longitude"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins int64 `json:"minimum_origins"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor interface{} `json:"monitor"` - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - Name string `json:"name"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - NotificationEmail string `json:"notification_email"` - // Filter pool and origin health notifications by resource type or health status. - // Use null to reset. - NotificationFilter LoadBalancerPoolEditResponseNotificationFilter `json:"notification_filter,nullable"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering LoadBalancerPoolEditResponseOriginSteering `json:"origin_steering"` - // The list of origins within this pool. Traffic directed at this pool is balanced - // across all currently healthy origins, provided the pool itself is healthy. - Origins []LoadBalancerPoolEditResponseOrigin `json:"origins"` - JSON loadBalancerPoolEditResponseJSON `json:"-"` -} - -// loadBalancerPoolEditResponseJSON contains the JSON metadata for the struct -// [LoadBalancerPoolEditResponse] -type loadBalancerPoolEditResponseJSON struct { - ID apijson.Field - CheckRegions apijson.Field - CreatedOn apijson.Field - Description apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Latitude apijson.Field - LoadShedding apijson.Field - Longitude apijson.Field - MinimumOrigins apijson.Field - ModifiedOn apijson.Field - Monitor apijson.Field - Name apijson.Field - NotificationEmail apijson.Field - NotificationFilter apijson.Field - OriginSteering apijson.Field - Origins apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolEditResponseJSON) RawJSON() string { - return r.raw -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type LoadBalancerPoolEditResponseCheckRegion string - -const ( - LoadBalancerPoolEditResponseCheckRegionWnam LoadBalancerPoolEditResponseCheckRegion = "WNAM" - LoadBalancerPoolEditResponseCheckRegionEnam LoadBalancerPoolEditResponseCheckRegion = "ENAM" - LoadBalancerPoolEditResponseCheckRegionWeu LoadBalancerPoolEditResponseCheckRegion = "WEU" - LoadBalancerPoolEditResponseCheckRegionEeu LoadBalancerPoolEditResponseCheckRegion = "EEU" - LoadBalancerPoolEditResponseCheckRegionNsam LoadBalancerPoolEditResponseCheckRegion = "NSAM" - LoadBalancerPoolEditResponseCheckRegionSsam LoadBalancerPoolEditResponseCheckRegion = "SSAM" - LoadBalancerPoolEditResponseCheckRegionOc LoadBalancerPoolEditResponseCheckRegion = "OC" - LoadBalancerPoolEditResponseCheckRegionMe LoadBalancerPoolEditResponseCheckRegion = "ME" - LoadBalancerPoolEditResponseCheckRegionNaf LoadBalancerPoolEditResponseCheckRegion = "NAF" - LoadBalancerPoolEditResponseCheckRegionSaf LoadBalancerPoolEditResponseCheckRegion = "SAF" - LoadBalancerPoolEditResponseCheckRegionSas LoadBalancerPoolEditResponseCheckRegion = "SAS" - LoadBalancerPoolEditResponseCheckRegionSeas LoadBalancerPoolEditResponseCheckRegion = "SEAS" - LoadBalancerPoolEditResponseCheckRegionNeas LoadBalancerPoolEditResponseCheckRegion = "NEAS" - LoadBalancerPoolEditResponseCheckRegionAllRegions LoadBalancerPoolEditResponseCheckRegion = "ALL_REGIONS" -) - -// Configures load shedding policies and percentages for the pool. -type LoadBalancerPoolEditResponseLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent float64 `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy LoadBalancerPoolEditResponseLoadSheddingDefaultPolicy `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent float64 `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy LoadBalancerPoolEditResponseLoadSheddingSessionPolicy `json:"session_policy"` - JSON loadBalancerPoolEditResponseLoadSheddingJSON `json:"-"` -} - -// loadBalancerPoolEditResponseLoadSheddingJSON contains the JSON metadata for the -// struct [LoadBalancerPoolEditResponseLoadShedding] -type loadBalancerPoolEditResponseLoadSheddingJSON struct { - DefaultPercent apijson.Field - DefaultPolicy apijson.Field - SessionPercent apijson.Field - SessionPolicy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolEditResponseLoadShedding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolEditResponseLoadSheddingJSON) RawJSON() string { - return r.raw -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type LoadBalancerPoolEditResponseLoadSheddingDefaultPolicy string - -const ( - LoadBalancerPoolEditResponseLoadSheddingDefaultPolicyRandom LoadBalancerPoolEditResponseLoadSheddingDefaultPolicy = "random" - LoadBalancerPoolEditResponseLoadSheddingDefaultPolicyHash LoadBalancerPoolEditResponseLoadSheddingDefaultPolicy = "hash" -) - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type LoadBalancerPoolEditResponseLoadSheddingSessionPolicy string - -const ( - LoadBalancerPoolEditResponseLoadSheddingSessionPolicyHash LoadBalancerPoolEditResponseLoadSheddingSessionPolicy = "hash" -) - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type LoadBalancerPoolEditResponseNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin LoadBalancerPoolEditResponseNotificationFilterOrigin `json:"origin,nullable"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool LoadBalancerPoolEditResponseNotificationFilterPool `json:"pool,nullable"` - JSON loadBalancerPoolEditResponseNotificationFilterJSON `json:"-"` -} - -// loadBalancerPoolEditResponseNotificationFilterJSON contains the JSON metadata -// for the struct [LoadBalancerPoolEditResponseNotificationFilter] -type loadBalancerPoolEditResponseNotificationFilterJSON struct { - Origin apijson.Field - Pool apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolEditResponseNotificationFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolEditResponseNotificationFilterJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolEditResponseNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON loadBalancerPoolEditResponseNotificationFilterOriginJSON `json:"-"` -} - -// loadBalancerPoolEditResponseNotificationFilterOriginJSON contains the JSON -// metadata for the struct [LoadBalancerPoolEditResponseNotificationFilterOrigin] -type loadBalancerPoolEditResponseNotificationFilterOriginJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolEditResponseNotificationFilterOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolEditResponseNotificationFilterOriginJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolEditResponseNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON loadBalancerPoolEditResponseNotificationFilterPoolJSON `json:"-"` -} - -// loadBalancerPoolEditResponseNotificationFilterPoolJSON contains the JSON -// metadata for the struct [LoadBalancerPoolEditResponseNotificationFilterPool] -type loadBalancerPoolEditResponseNotificationFilterPoolJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolEditResponseNotificationFilterPool) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolEditResponseNotificationFilterPoolJSON) RawJSON() string { - return r.raw -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type LoadBalancerPoolEditResponseOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy LoadBalancerPoolEditResponseOriginSteeringPolicy `json:"policy"` - JSON loadBalancerPoolEditResponseOriginSteeringJSON `json:"-"` -} - -// loadBalancerPoolEditResponseOriginSteeringJSON contains the JSON metadata for -// the struct [LoadBalancerPoolEditResponseOriginSteering] -type loadBalancerPoolEditResponseOriginSteeringJSON struct { - Policy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolEditResponseOriginSteering) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolEditResponseOriginSteeringJSON) RawJSON() string { - return r.raw -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type LoadBalancerPoolEditResponseOriginSteeringPolicy string - -const ( - LoadBalancerPoolEditResponseOriginSteeringPolicyRandom LoadBalancerPoolEditResponseOriginSteeringPolicy = "random" - LoadBalancerPoolEditResponseOriginSteeringPolicyHash LoadBalancerPoolEditResponseOriginSteeringPolicy = "hash" - LoadBalancerPoolEditResponseOriginSteeringPolicyLeastOutstandingRequests LoadBalancerPoolEditResponseOriginSteeringPolicy = "least_outstanding_requests" - LoadBalancerPoolEditResponseOriginSteeringPolicyLeastConnections LoadBalancerPoolEditResponseOriginSteeringPolicy = "least_connections" -) - -type LoadBalancerPoolEditResponseOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address string `json:"address"` - // This field shows up only if the origin is disabled. This field is set with the - // time the origin was disabled. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled bool `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header LoadBalancerPoolEditResponseOriginsHeader `json:"header"` - // A human-identifiable name for the origin. - Name string `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID string `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight float64 `json:"weight"` - JSON loadBalancerPoolEditResponseOriginJSON `json:"-"` -} - -// loadBalancerPoolEditResponseOriginJSON contains the JSON metadata for the struct -// [LoadBalancerPoolEditResponseOrigin] -type loadBalancerPoolEditResponseOriginJSON struct { - Address apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Header apijson.Field - Name apijson.Field - VirtualNetworkID apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolEditResponseOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolEditResponseOriginJSON) RawJSON() string { - return r.raw -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type LoadBalancerPoolEditResponseOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host []string `json:"Host"` - JSON loadBalancerPoolEditResponseOriginsHeaderJSON `json:"-"` -} - -// loadBalancerPoolEditResponseOriginsHeaderJSON contains the JSON metadata for the -// struct [LoadBalancerPoolEditResponseOriginsHeader] -type loadBalancerPoolEditResponseOriginsHeaderJSON struct { - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolEditResponseOriginsHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolEditResponseOriginsHeaderJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolGetResponse struct { - ID string `json:"id"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions []LoadBalancerPoolGetResponseCheckRegion `json:"check_regions,nullable"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A human-readable description of the pool. - Description string `json:"description"` - // This field shows up only if the pool is disabled. This field is set with the - // time the pool was disabled at. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) or disable this pool. Disabled pools will not - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled bool `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, longitude must also be set. - Latitude float64 `json:"latitude"` - // Configures load shedding policies and percentages for the pool. - LoadShedding LoadBalancerPoolGetResponseLoadShedding `json:"load_shedding"` - // The longitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, latitude must also be set. - Longitude float64 `json:"longitude"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins int64 `json:"minimum_origins"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor interface{} `json:"monitor"` - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - Name string `json:"name"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - NotificationEmail string `json:"notification_email"` - // Filter pool and origin health notifications by resource type or health status. - // Use null to reset. - NotificationFilter LoadBalancerPoolGetResponseNotificationFilter `json:"notification_filter,nullable"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering LoadBalancerPoolGetResponseOriginSteering `json:"origin_steering"` - // The list of origins within this pool. Traffic directed at this pool is balanced - // across all currently healthy origins, provided the pool itself is healthy. - Origins []LoadBalancerPoolGetResponseOrigin `json:"origins"` - JSON loadBalancerPoolGetResponseJSON `json:"-"` -} - -// loadBalancerPoolGetResponseJSON contains the JSON metadata for the struct -// [LoadBalancerPoolGetResponse] -type loadBalancerPoolGetResponseJSON struct { - ID apijson.Field - CheckRegions apijson.Field - CreatedOn apijson.Field - Description apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Latitude apijson.Field - LoadShedding apijson.Field - Longitude apijson.Field - MinimumOrigins apijson.Field - ModifiedOn apijson.Field - Monitor apijson.Field - Name apijson.Field - NotificationEmail apijson.Field - NotificationFilter apijson.Field - OriginSteering apijson.Field - Origins apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolGetResponseJSON) RawJSON() string { - return r.raw -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type LoadBalancerPoolGetResponseCheckRegion string - -const ( - LoadBalancerPoolGetResponseCheckRegionWnam LoadBalancerPoolGetResponseCheckRegion = "WNAM" - LoadBalancerPoolGetResponseCheckRegionEnam LoadBalancerPoolGetResponseCheckRegion = "ENAM" - LoadBalancerPoolGetResponseCheckRegionWeu LoadBalancerPoolGetResponseCheckRegion = "WEU" - LoadBalancerPoolGetResponseCheckRegionEeu LoadBalancerPoolGetResponseCheckRegion = "EEU" - LoadBalancerPoolGetResponseCheckRegionNsam LoadBalancerPoolGetResponseCheckRegion = "NSAM" - LoadBalancerPoolGetResponseCheckRegionSsam LoadBalancerPoolGetResponseCheckRegion = "SSAM" - LoadBalancerPoolGetResponseCheckRegionOc LoadBalancerPoolGetResponseCheckRegion = "OC" - LoadBalancerPoolGetResponseCheckRegionMe LoadBalancerPoolGetResponseCheckRegion = "ME" - LoadBalancerPoolGetResponseCheckRegionNaf LoadBalancerPoolGetResponseCheckRegion = "NAF" - LoadBalancerPoolGetResponseCheckRegionSaf LoadBalancerPoolGetResponseCheckRegion = "SAF" - LoadBalancerPoolGetResponseCheckRegionSas LoadBalancerPoolGetResponseCheckRegion = "SAS" - LoadBalancerPoolGetResponseCheckRegionSeas LoadBalancerPoolGetResponseCheckRegion = "SEAS" - LoadBalancerPoolGetResponseCheckRegionNeas LoadBalancerPoolGetResponseCheckRegion = "NEAS" - LoadBalancerPoolGetResponseCheckRegionAllRegions LoadBalancerPoolGetResponseCheckRegion = "ALL_REGIONS" -) - -// Configures load shedding policies and percentages for the pool. -type LoadBalancerPoolGetResponseLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent float64 `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy LoadBalancerPoolGetResponseLoadSheddingDefaultPolicy `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent float64 `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy LoadBalancerPoolGetResponseLoadSheddingSessionPolicy `json:"session_policy"` - JSON loadBalancerPoolGetResponseLoadSheddingJSON `json:"-"` -} - -// loadBalancerPoolGetResponseLoadSheddingJSON contains the JSON metadata for the -// struct [LoadBalancerPoolGetResponseLoadShedding] -type loadBalancerPoolGetResponseLoadSheddingJSON struct { - DefaultPercent apijson.Field - DefaultPolicy apijson.Field - SessionPercent apijson.Field - SessionPolicy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolGetResponseLoadShedding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolGetResponseLoadSheddingJSON) RawJSON() string { - return r.raw -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type LoadBalancerPoolGetResponseLoadSheddingDefaultPolicy string - -const ( - LoadBalancerPoolGetResponseLoadSheddingDefaultPolicyRandom LoadBalancerPoolGetResponseLoadSheddingDefaultPolicy = "random" - LoadBalancerPoolGetResponseLoadSheddingDefaultPolicyHash LoadBalancerPoolGetResponseLoadSheddingDefaultPolicy = "hash" -) - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type LoadBalancerPoolGetResponseLoadSheddingSessionPolicy string - -const ( - LoadBalancerPoolGetResponseLoadSheddingSessionPolicyHash LoadBalancerPoolGetResponseLoadSheddingSessionPolicy = "hash" -) - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type LoadBalancerPoolGetResponseNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin LoadBalancerPoolGetResponseNotificationFilterOrigin `json:"origin,nullable"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool LoadBalancerPoolGetResponseNotificationFilterPool `json:"pool,nullable"` - JSON loadBalancerPoolGetResponseNotificationFilterJSON `json:"-"` -} - -// loadBalancerPoolGetResponseNotificationFilterJSON contains the JSON metadata for -// the struct [LoadBalancerPoolGetResponseNotificationFilter] -type loadBalancerPoolGetResponseNotificationFilterJSON struct { - Origin apijson.Field - Pool apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolGetResponseNotificationFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolGetResponseNotificationFilterJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolGetResponseNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON loadBalancerPoolGetResponseNotificationFilterOriginJSON `json:"-"` -} - -// loadBalancerPoolGetResponseNotificationFilterOriginJSON contains the JSON -// metadata for the struct [LoadBalancerPoolGetResponseNotificationFilterOrigin] -type loadBalancerPoolGetResponseNotificationFilterOriginJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolGetResponseNotificationFilterOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolGetResponseNotificationFilterOriginJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolGetResponseNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON loadBalancerPoolGetResponseNotificationFilterPoolJSON `json:"-"` -} - -// loadBalancerPoolGetResponseNotificationFilterPoolJSON contains the JSON metadata -// for the struct [LoadBalancerPoolGetResponseNotificationFilterPool] -type loadBalancerPoolGetResponseNotificationFilterPoolJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolGetResponseNotificationFilterPool) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolGetResponseNotificationFilterPoolJSON) RawJSON() string { - return r.raw -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type LoadBalancerPoolGetResponseOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy LoadBalancerPoolGetResponseOriginSteeringPolicy `json:"policy"` - JSON loadBalancerPoolGetResponseOriginSteeringJSON `json:"-"` -} - -// loadBalancerPoolGetResponseOriginSteeringJSON contains the JSON metadata for the -// struct [LoadBalancerPoolGetResponseOriginSteering] -type loadBalancerPoolGetResponseOriginSteeringJSON struct { - Policy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolGetResponseOriginSteering) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolGetResponseOriginSteeringJSON) RawJSON() string { - return r.raw -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type LoadBalancerPoolGetResponseOriginSteeringPolicy string - -const ( - LoadBalancerPoolGetResponseOriginSteeringPolicyRandom LoadBalancerPoolGetResponseOriginSteeringPolicy = "random" - LoadBalancerPoolGetResponseOriginSteeringPolicyHash LoadBalancerPoolGetResponseOriginSteeringPolicy = "hash" - LoadBalancerPoolGetResponseOriginSteeringPolicyLeastOutstandingRequests LoadBalancerPoolGetResponseOriginSteeringPolicy = "least_outstanding_requests" - LoadBalancerPoolGetResponseOriginSteeringPolicyLeastConnections LoadBalancerPoolGetResponseOriginSteeringPolicy = "least_connections" -) - -type LoadBalancerPoolGetResponseOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address string `json:"address"` - // This field shows up only if the origin is disabled. This field is set with the - // time the origin was disabled. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled bool `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header LoadBalancerPoolGetResponseOriginsHeader `json:"header"` - // A human-identifiable name for the origin. - Name string `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID string `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight float64 `json:"weight"` - JSON loadBalancerPoolGetResponseOriginJSON `json:"-"` -} - -// loadBalancerPoolGetResponseOriginJSON contains the JSON metadata for the struct -// [LoadBalancerPoolGetResponseOrigin] -type loadBalancerPoolGetResponseOriginJSON struct { - Address apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Header apijson.Field - Name apijson.Field - VirtualNetworkID apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolGetResponseOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolGetResponseOriginJSON) RawJSON() string { - return r.raw -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type LoadBalancerPoolGetResponseOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host []string `json:"Host"` - JSON loadBalancerPoolGetResponseOriginsHeaderJSON `json:"-"` -} - -// loadBalancerPoolGetResponseOriginsHeaderJSON contains the JSON metadata for the -// struct [LoadBalancerPoolGetResponseOriginsHeader] -type loadBalancerPoolGetResponseOriginsHeaderJSON struct { - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolGetResponseOriginsHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolGetResponseOriginsHeaderJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - Name param.Field[string] `json:"name,required"` - // The list of origins within this pool. Traffic directed at this pool is balanced - // across all currently healthy origins, provided the pool itself is healthy. - Origins param.Field[[]LoadBalancerPoolNewParamsOrigin] `json:"origins,required"` - // A human-readable description of the pool. - Description param.Field[string] `json:"description"` - // Whether to enable (the default) or disable this pool. Disabled pools will not - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled param.Field[bool] `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, longitude must also be set. - Latitude param.Field[float64] `json:"latitude"` - // Configures load shedding policies and percentages for the pool. - LoadShedding param.Field[LoadBalancerPoolNewParamsLoadShedding] `json:"load_shedding"` - // The longitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, latitude must also be set. - Longitude param.Field[float64] `json:"longitude"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins param.Field[int64] `json:"minimum_origins"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor param.Field[interface{}] `json:"monitor"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - NotificationEmail param.Field[string] `json:"notification_email"` - // Filter pool and origin health notifications by resource type or health status. - // Use null to reset. - NotificationFilter param.Field[LoadBalancerPoolNewParamsNotificationFilter] `json:"notification_filter"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering param.Field[LoadBalancerPoolNewParamsOriginSteering] `json:"origin_steering"` -} - -func (r LoadBalancerPoolNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type LoadBalancerPoolNewParamsOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address param.Field[string] `json:"address"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled param.Field[bool] `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header param.Field[LoadBalancerPoolNewParamsOriginsHeader] `json:"header"` - // A human-identifiable name for the origin. - Name param.Field[string] `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID param.Field[string] `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight param.Field[float64] `json:"weight"` -} - -func (r LoadBalancerPoolNewParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type LoadBalancerPoolNewParamsOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host param.Field[[]string] `json:"Host"` -} - -func (r LoadBalancerPoolNewParamsOriginsHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures load shedding policies and percentages for the pool. -type LoadBalancerPoolNewParamsLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent param.Field[float64] `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy param.Field[LoadBalancerPoolNewParamsLoadSheddingDefaultPolicy] `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent param.Field[float64] `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy param.Field[LoadBalancerPoolNewParamsLoadSheddingSessionPolicy] `json:"session_policy"` -} - -func (r LoadBalancerPoolNewParamsLoadShedding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type LoadBalancerPoolNewParamsLoadSheddingDefaultPolicy string - -const ( - LoadBalancerPoolNewParamsLoadSheddingDefaultPolicyRandom LoadBalancerPoolNewParamsLoadSheddingDefaultPolicy = "random" - LoadBalancerPoolNewParamsLoadSheddingDefaultPolicyHash LoadBalancerPoolNewParamsLoadSheddingDefaultPolicy = "hash" -) - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type LoadBalancerPoolNewParamsLoadSheddingSessionPolicy string - -const ( - LoadBalancerPoolNewParamsLoadSheddingSessionPolicyHash LoadBalancerPoolNewParamsLoadSheddingSessionPolicy = "hash" -) - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type LoadBalancerPoolNewParamsNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin param.Field[LoadBalancerPoolNewParamsNotificationFilterOrigin] `json:"origin"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool param.Field[LoadBalancerPoolNewParamsNotificationFilterPool] `json:"pool"` -} - -func (r LoadBalancerPoolNewParamsNotificationFilter) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolNewParamsNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r LoadBalancerPoolNewParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolNewParamsNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r LoadBalancerPoolNewParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type LoadBalancerPoolNewParamsOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy param.Field[LoadBalancerPoolNewParamsOriginSteeringPolicy] `json:"policy"` -} - -func (r LoadBalancerPoolNewParamsOriginSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type LoadBalancerPoolNewParamsOriginSteeringPolicy string - -const ( - LoadBalancerPoolNewParamsOriginSteeringPolicyRandom LoadBalancerPoolNewParamsOriginSteeringPolicy = "random" - LoadBalancerPoolNewParamsOriginSteeringPolicyHash LoadBalancerPoolNewParamsOriginSteeringPolicy = "hash" - LoadBalancerPoolNewParamsOriginSteeringPolicyLeastOutstandingRequests LoadBalancerPoolNewParamsOriginSteeringPolicy = "least_outstanding_requests" - LoadBalancerPoolNewParamsOriginSteeringPolicyLeastConnections LoadBalancerPoolNewParamsOriginSteeringPolicy = "least_connections" -) - -type LoadBalancerPoolNewResponseEnvelope struct { - Errors []LoadBalancerPoolNewResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPoolNewResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerPoolNewResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerPoolNewResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerPoolNewResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPoolNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerPoolNewResponseEnvelope] -type loadBalancerPoolNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPoolNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LoadBalancerPoolNewResponseEnvelopeErrors] -type loadBalancerPoolNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPoolNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [LoadBalancerPoolNewResponseEnvelopeMessages] -type loadBalancerPoolNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPoolNewResponseEnvelopeSuccess bool - -const ( - LoadBalancerPoolNewResponseEnvelopeSuccessTrue LoadBalancerPoolNewResponseEnvelopeSuccess = true -) - -type LoadBalancerPoolUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - Name param.Field[string] `json:"name,required"` - // The list of origins within this pool. Traffic directed at this pool is balanced - // across all currently healthy origins, provided the pool itself is healthy. - Origins param.Field[[]LoadBalancerPoolUpdateParamsOrigin] `json:"origins,required"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions param.Field[[]LoadBalancerPoolUpdateParamsCheckRegion] `json:"check_regions"` - // A human-readable description of the pool. - Description param.Field[string] `json:"description"` - // Whether to enable (the default) or disable this pool. Disabled pools will not - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled param.Field[bool] `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, longitude must also be set. - Latitude param.Field[float64] `json:"latitude"` - // Configures load shedding policies and percentages for the pool. - LoadShedding param.Field[LoadBalancerPoolUpdateParamsLoadShedding] `json:"load_shedding"` - // The longitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, latitude must also be set. - Longitude param.Field[float64] `json:"longitude"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins param.Field[int64] `json:"minimum_origins"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor param.Field[interface{}] `json:"monitor"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - NotificationEmail param.Field[string] `json:"notification_email"` - // Filter pool and origin health notifications by resource type or health status. - // Use null to reset. - NotificationFilter param.Field[LoadBalancerPoolUpdateParamsNotificationFilter] `json:"notification_filter"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering param.Field[LoadBalancerPoolUpdateParamsOriginSteering] `json:"origin_steering"` -} - -func (r LoadBalancerPoolUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type LoadBalancerPoolUpdateParamsOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address param.Field[string] `json:"address"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled param.Field[bool] `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header param.Field[LoadBalancerPoolUpdateParamsOriginsHeader] `json:"header"` - // A human-identifiable name for the origin. - Name param.Field[string] `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID param.Field[string] `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight param.Field[float64] `json:"weight"` -} - -func (r LoadBalancerPoolUpdateParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type LoadBalancerPoolUpdateParamsOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host param.Field[[]string] `json:"Host"` -} - -func (r LoadBalancerPoolUpdateParamsOriginsHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type LoadBalancerPoolUpdateParamsCheckRegion string - -const ( - LoadBalancerPoolUpdateParamsCheckRegionWnam LoadBalancerPoolUpdateParamsCheckRegion = "WNAM" - LoadBalancerPoolUpdateParamsCheckRegionEnam LoadBalancerPoolUpdateParamsCheckRegion = "ENAM" - LoadBalancerPoolUpdateParamsCheckRegionWeu LoadBalancerPoolUpdateParamsCheckRegion = "WEU" - LoadBalancerPoolUpdateParamsCheckRegionEeu LoadBalancerPoolUpdateParamsCheckRegion = "EEU" - LoadBalancerPoolUpdateParamsCheckRegionNsam LoadBalancerPoolUpdateParamsCheckRegion = "NSAM" - LoadBalancerPoolUpdateParamsCheckRegionSsam LoadBalancerPoolUpdateParamsCheckRegion = "SSAM" - LoadBalancerPoolUpdateParamsCheckRegionOc LoadBalancerPoolUpdateParamsCheckRegion = "OC" - LoadBalancerPoolUpdateParamsCheckRegionMe LoadBalancerPoolUpdateParamsCheckRegion = "ME" - LoadBalancerPoolUpdateParamsCheckRegionNaf LoadBalancerPoolUpdateParamsCheckRegion = "NAF" - LoadBalancerPoolUpdateParamsCheckRegionSaf LoadBalancerPoolUpdateParamsCheckRegion = "SAF" - LoadBalancerPoolUpdateParamsCheckRegionSas LoadBalancerPoolUpdateParamsCheckRegion = "SAS" - LoadBalancerPoolUpdateParamsCheckRegionSeas LoadBalancerPoolUpdateParamsCheckRegion = "SEAS" - LoadBalancerPoolUpdateParamsCheckRegionNeas LoadBalancerPoolUpdateParamsCheckRegion = "NEAS" - LoadBalancerPoolUpdateParamsCheckRegionAllRegions LoadBalancerPoolUpdateParamsCheckRegion = "ALL_REGIONS" -) - -// Configures load shedding policies and percentages for the pool. -type LoadBalancerPoolUpdateParamsLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent param.Field[float64] `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy param.Field[LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy] `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent param.Field[float64] `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy param.Field[LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicy] `json:"session_policy"` -} - -func (r LoadBalancerPoolUpdateParamsLoadShedding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy string - -const ( - LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyRandom LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy = "random" - LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyHash LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy = "hash" -) - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicy string - -const ( - LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicyHash LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicy = "hash" -) - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type LoadBalancerPoolUpdateParamsNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin param.Field[LoadBalancerPoolUpdateParamsNotificationFilterOrigin] `json:"origin"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool param.Field[LoadBalancerPoolUpdateParamsNotificationFilterPool] `json:"pool"` -} - -func (r LoadBalancerPoolUpdateParamsNotificationFilter) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolUpdateParamsNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r LoadBalancerPoolUpdateParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolUpdateParamsNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r LoadBalancerPoolUpdateParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type LoadBalancerPoolUpdateParamsOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy param.Field[LoadBalancerPoolUpdateParamsOriginSteeringPolicy] `json:"policy"` -} - -func (r LoadBalancerPoolUpdateParamsOriginSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type LoadBalancerPoolUpdateParamsOriginSteeringPolicy string - -const ( - LoadBalancerPoolUpdateParamsOriginSteeringPolicyRandom LoadBalancerPoolUpdateParamsOriginSteeringPolicy = "random" - LoadBalancerPoolUpdateParamsOriginSteeringPolicyHash LoadBalancerPoolUpdateParamsOriginSteeringPolicy = "hash" - LoadBalancerPoolUpdateParamsOriginSteeringPolicyLeastOutstandingRequests LoadBalancerPoolUpdateParamsOriginSteeringPolicy = "least_outstanding_requests" - LoadBalancerPoolUpdateParamsOriginSteeringPolicyLeastConnections LoadBalancerPoolUpdateParamsOriginSteeringPolicy = "least_connections" -) - -type LoadBalancerPoolUpdateResponseEnvelope struct { - Errors []LoadBalancerPoolUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPoolUpdateResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerPoolUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerPoolUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerPoolUpdateResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPoolUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerPoolUpdateResponseEnvelope] -type loadBalancerPoolUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPoolUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerPoolUpdateResponseEnvelopeErrors] -type loadBalancerPoolUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPoolUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerPoolUpdateResponseEnvelopeMessages] -type loadBalancerPoolUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPoolUpdateResponseEnvelopeSuccess bool - -const ( - LoadBalancerPoolUpdateResponseEnvelopeSuccessTrue LoadBalancerPoolUpdateResponseEnvelopeSuccess = true -) - -type LoadBalancerPoolListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor param.Field[interface{}] `query:"monitor"` -} - -// URLQuery serializes [LoadBalancerPoolListParams]'s query parameters as -// `url.Values`. -func (r LoadBalancerPoolListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type LoadBalancerPoolListResponseEnvelope struct { - Errors []LoadBalancerPoolListResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPoolListResponseEnvelopeMessages `json:"messages,required"` - Result []LoadBalancerPoolListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LoadBalancerPoolListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo LoadBalancerPoolListResponseEnvelopeResultInfo `json:"result_info"` - JSON loadBalancerPoolListResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPoolListResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerPoolListResponseEnvelope] -type loadBalancerPoolListResponseEnvelopeJSON 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 *LoadBalancerPoolListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolListResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPoolListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerPoolListResponseEnvelopeErrors] -type loadBalancerPoolListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolListResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPoolListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [LoadBalancerPoolListResponseEnvelopeMessages] -type loadBalancerPoolListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPoolListResponseEnvelopeSuccess bool - -const ( - LoadBalancerPoolListResponseEnvelopeSuccessTrue LoadBalancerPoolListResponseEnvelopeSuccess = true -) - -type LoadBalancerPoolListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON loadBalancerPoolListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// loadBalancerPoolListResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [LoadBalancerPoolListResponseEnvelopeResultInfo] -type loadBalancerPoolListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type LoadBalancerPoolDeleteResponseEnvelope struct { - Errors []LoadBalancerPoolDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPoolDeleteResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerPoolDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerPoolDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerPoolDeleteResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPoolDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerPoolDeleteResponseEnvelope] -type loadBalancerPoolDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPoolDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerPoolDeleteResponseEnvelopeErrors] -type loadBalancerPoolDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPoolDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerPoolDeleteResponseEnvelopeMessages] -type loadBalancerPoolDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPoolDeleteResponseEnvelopeSuccess bool - -const ( - LoadBalancerPoolDeleteResponseEnvelopeSuccessTrue LoadBalancerPoolDeleteResponseEnvelopeSuccess = true -) - -type LoadBalancerPoolEditParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions param.Field[[]LoadBalancerPoolEditParamsCheckRegion] `json:"check_regions"` - // A human-readable description of the pool. - Description param.Field[string] `json:"description"` - // Whether to enable (the default) or disable this pool. Disabled pools will not - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled param.Field[bool] `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, longitude must also be set. - Latitude param.Field[float64] `json:"latitude"` - // Configures load shedding policies and percentages for the pool. - LoadShedding param.Field[LoadBalancerPoolEditParamsLoadShedding] `json:"load_shedding"` - // The longitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, latitude must also be set. - Longitude param.Field[float64] `json:"longitude"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins param.Field[int64] `json:"minimum_origins"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor param.Field[interface{}] `json:"monitor"` - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - Name param.Field[string] `json:"name"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - NotificationEmail param.Field[string] `json:"notification_email"` - // Filter pool and origin health notifications by resource type or health status. - // Use null to reset. - NotificationFilter param.Field[LoadBalancerPoolEditParamsNotificationFilter] `json:"notification_filter"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering param.Field[LoadBalancerPoolEditParamsOriginSteering] `json:"origin_steering"` - // The list of origins within this pool. Traffic directed at this pool is balanced - // across all currently healthy origins, provided the pool itself is healthy. - Origins param.Field[[]LoadBalancerPoolEditParamsOrigin] `json:"origins"` -} - -func (r LoadBalancerPoolEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type LoadBalancerPoolEditParamsCheckRegion string - -const ( - LoadBalancerPoolEditParamsCheckRegionWnam LoadBalancerPoolEditParamsCheckRegion = "WNAM" - LoadBalancerPoolEditParamsCheckRegionEnam LoadBalancerPoolEditParamsCheckRegion = "ENAM" - LoadBalancerPoolEditParamsCheckRegionWeu LoadBalancerPoolEditParamsCheckRegion = "WEU" - LoadBalancerPoolEditParamsCheckRegionEeu LoadBalancerPoolEditParamsCheckRegion = "EEU" - LoadBalancerPoolEditParamsCheckRegionNsam LoadBalancerPoolEditParamsCheckRegion = "NSAM" - LoadBalancerPoolEditParamsCheckRegionSsam LoadBalancerPoolEditParamsCheckRegion = "SSAM" - LoadBalancerPoolEditParamsCheckRegionOc LoadBalancerPoolEditParamsCheckRegion = "OC" - LoadBalancerPoolEditParamsCheckRegionMe LoadBalancerPoolEditParamsCheckRegion = "ME" - LoadBalancerPoolEditParamsCheckRegionNaf LoadBalancerPoolEditParamsCheckRegion = "NAF" - LoadBalancerPoolEditParamsCheckRegionSaf LoadBalancerPoolEditParamsCheckRegion = "SAF" - LoadBalancerPoolEditParamsCheckRegionSas LoadBalancerPoolEditParamsCheckRegion = "SAS" - LoadBalancerPoolEditParamsCheckRegionSeas LoadBalancerPoolEditParamsCheckRegion = "SEAS" - LoadBalancerPoolEditParamsCheckRegionNeas LoadBalancerPoolEditParamsCheckRegion = "NEAS" - LoadBalancerPoolEditParamsCheckRegionAllRegions LoadBalancerPoolEditParamsCheckRegion = "ALL_REGIONS" -) - -// Configures load shedding policies and percentages for the pool. -type LoadBalancerPoolEditParamsLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent param.Field[float64] `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy param.Field[LoadBalancerPoolEditParamsLoadSheddingDefaultPolicy] `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent param.Field[float64] `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy param.Field[LoadBalancerPoolEditParamsLoadSheddingSessionPolicy] `json:"session_policy"` -} - -func (r LoadBalancerPoolEditParamsLoadShedding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type LoadBalancerPoolEditParamsLoadSheddingDefaultPolicy string - -const ( - LoadBalancerPoolEditParamsLoadSheddingDefaultPolicyRandom LoadBalancerPoolEditParamsLoadSheddingDefaultPolicy = "random" - LoadBalancerPoolEditParamsLoadSheddingDefaultPolicyHash LoadBalancerPoolEditParamsLoadSheddingDefaultPolicy = "hash" -) - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type LoadBalancerPoolEditParamsLoadSheddingSessionPolicy string - -const ( - LoadBalancerPoolEditParamsLoadSheddingSessionPolicyHash LoadBalancerPoolEditParamsLoadSheddingSessionPolicy = "hash" -) - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type LoadBalancerPoolEditParamsNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin param.Field[LoadBalancerPoolEditParamsNotificationFilterOrigin] `json:"origin"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool param.Field[LoadBalancerPoolEditParamsNotificationFilterPool] `json:"pool"` -} - -func (r LoadBalancerPoolEditParamsNotificationFilter) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolEditParamsNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r LoadBalancerPoolEditParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolEditParamsNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r LoadBalancerPoolEditParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type LoadBalancerPoolEditParamsOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy param.Field[LoadBalancerPoolEditParamsOriginSteeringPolicy] `json:"policy"` -} - -func (r LoadBalancerPoolEditParamsOriginSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type LoadBalancerPoolEditParamsOriginSteeringPolicy string - -const ( - LoadBalancerPoolEditParamsOriginSteeringPolicyRandom LoadBalancerPoolEditParamsOriginSteeringPolicy = "random" - LoadBalancerPoolEditParamsOriginSteeringPolicyHash LoadBalancerPoolEditParamsOriginSteeringPolicy = "hash" - LoadBalancerPoolEditParamsOriginSteeringPolicyLeastOutstandingRequests LoadBalancerPoolEditParamsOriginSteeringPolicy = "least_outstanding_requests" - LoadBalancerPoolEditParamsOriginSteeringPolicyLeastConnections LoadBalancerPoolEditParamsOriginSteeringPolicy = "least_connections" -) - -type LoadBalancerPoolEditParamsOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address param.Field[string] `json:"address"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled param.Field[bool] `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header param.Field[LoadBalancerPoolEditParamsOriginsHeader] `json:"header"` - // A human-identifiable name for the origin. - Name param.Field[string] `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID param.Field[string] `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight param.Field[float64] `json:"weight"` -} - -func (r LoadBalancerPoolEditParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type LoadBalancerPoolEditParamsOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host param.Field[[]string] `json:"Host"` -} - -func (r LoadBalancerPoolEditParamsOriginsHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type LoadBalancerPoolEditResponseEnvelope struct { - Errors []LoadBalancerPoolEditResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPoolEditResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerPoolEditResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerPoolEditResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerPoolEditResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPoolEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerPoolEditResponseEnvelope] -type loadBalancerPoolEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPoolEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerPoolEditResponseEnvelopeErrors] -type loadBalancerPoolEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPoolEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [LoadBalancerPoolEditResponseEnvelopeMessages] -type loadBalancerPoolEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPoolEditResponseEnvelopeSuccess bool - -const ( - LoadBalancerPoolEditResponseEnvelopeSuccessTrue LoadBalancerPoolEditResponseEnvelopeSuccess = true -) - -type LoadBalancerPoolGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type LoadBalancerPoolGetResponseEnvelope struct { - Errors []LoadBalancerPoolGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPoolGetResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerPoolGetResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerPoolGetResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerPoolGetResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPoolGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerPoolGetResponseEnvelope] -type loadBalancerPoolGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPoolGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LoadBalancerPoolGetResponseEnvelopeErrors] -type loadBalancerPoolGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPoolGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [LoadBalancerPoolGetResponseEnvelopeMessages] -type loadBalancerPoolGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPoolGetResponseEnvelopeSuccess bool - -const ( - LoadBalancerPoolGetResponseEnvelopeSuccessTrue LoadBalancerPoolGetResponseEnvelopeSuccess = true -) diff --git a/loadbalancerpool_test.go b/loadbalancerpool_test.go deleted file mode 100644 index 8545df99f6f..00000000000 --- a/loadbalancerpool_test.go +++ /dev/null @@ -1,354 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLoadBalancerPoolNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.LoadBalancers.Pools.New(context.TODO(), cloudflare.LoadBalancerPoolNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Name: cloudflare.F("primary-dc-1"), - Origins: cloudflare.F([]cloudflare.LoadBalancerPoolNewParamsOrigin{{ - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(cloudflare.LoadBalancerPoolNewParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), - }), - Name: cloudflare.F("app-server-1"), - VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), - Weight: cloudflare.F(0.600000), - }, { - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(cloudflare.LoadBalancerPoolNewParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), - }), - Name: cloudflare.F("app-server-1"), - VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), - Weight: cloudflare.F(0.600000), - }, { - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(cloudflare.LoadBalancerPoolNewParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), - }), - Name: cloudflare.F("app-server-1"), - VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), - Weight: cloudflare.F(0.600000), - }}), - Description: cloudflare.F("Primary data center - Provider XYZ"), - Enabled: cloudflare.F(false), - Latitude: cloudflare.F(0.000000), - LoadShedding: cloudflare.F(cloudflare.LoadBalancerPoolNewParamsLoadShedding{ - DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(cloudflare.LoadBalancerPoolNewParamsLoadSheddingDefaultPolicyRandom), - SessionPercent: cloudflare.F(0.000000), - SessionPolicy: cloudflare.F(cloudflare.LoadBalancerPoolNewParamsLoadSheddingSessionPolicyHash), - }), - Longitude: cloudflare.F(0.000000), - MinimumOrigins: cloudflare.F(int64(0)), - Monitor: cloudflare.F[any](map[string]interface{}{}), - NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), - NotificationFilter: cloudflare.F(cloudflare.LoadBalancerPoolNewParamsNotificationFilter{ - Origin: cloudflare.F(cloudflare.LoadBalancerPoolNewParamsNotificationFilterOrigin{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(true), - }), - Pool: cloudflare.F(cloudflare.LoadBalancerPoolNewParamsNotificationFilterPool{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(false), - }), - }), - OriginSteering: cloudflare.F(cloudflare.LoadBalancerPoolNewParamsOriginSteering{ - Policy: cloudflare.F(cloudflare.LoadBalancerPoolNewParamsOriginSteeringPolicyRandom), - }), - }) - 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 TestLoadBalancerPoolUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.LoadBalancers.Pools.Update( - context.TODO(), - "17b5962d775c646f3f9725cbc7a53df4", - cloudflare.LoadBalancerPoolUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Name: cloudflare.F("primary-dc-1"), - Origins: cloudflare.F([]cloudflare.LoadBalancerPoolUpdateParamsOrigin{{ - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(cloudflare.LoadBalancerPoolUpdateParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), - }), - Name: cloudflare.F("app-server-1"), - VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), - Weight: cloudflare.F(0.600000), - }, { - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(cloudflare.LoadBalancerPoolUpdateParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), - }), - Name: cloudflare.F("app-server-1"), - VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), - Weight: cloudflare.F(0.600000), - }, { - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(cloudflare.LoadBalancerPoolUpdateParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), - }), - Name: cloudflare.F("app-server-1"), - VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), - Weight: cloudflare.F(0.600000), - }}), - CheckRegions: cloudflare.F([]cloudflare.LoadBalancerPoolUpdateParamsCheckRegion{cloudflare.LoadBalancerPoolUpdateParamsCheckRegionWeu, cloudflare.LoadBalancerPoolUpdateParamsCheckRegionEnam}), - Description: cloudflare.F("Primary data center - Provider XYZ"), - Enabled: cloudflare.F(false), - Latitude: cloudflare.F(0.000000), - LoadShedding: cloudflare.F(cloudflare.LoadBalancerPoolUpdateParamsLoadShedding{ - DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(cloudflare.LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyRandom), - SessionPercent: cloudflare.F(0.000000), - SessionPolicy: cloudflare.F(cloudflare.LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicyHash), - }), - Longitude: cloudflare.F(0.000000), - MinimumOrigins: cloudflare.F(int64(0)), - Monitor: cloudflare.F[any](map[string]interface{}{}), - NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), - NotificationFilter: cloudflare.F(cloudflare.LoadBalancerPoolUpdateParamsNotificationFilter{ - Origin: cloudflare.F(cloudflare.LoadBalancerPoolUpdateParamsNotificationFilterOrigin{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(true), - }), - Pool: cloudflare.F(cloudflare.LoadBalancerPoolUpdateParamsNotificationFilterPool{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(false), - }), - }), - OriginSteering: cloudflare.F(cloudflare.LoadBalancerPoolUpdateParamsOriginSteering{ - Policy: cloudflare.F(cloudflare.LoadBalancerPoolUpdateParamsOriginSteeringPolicyRandom), - }), - }, - ) - 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 TestLoadBalancerPoolListWithOptionalParams(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("user@example.com"), - ) - _, err := client.LoadBalancers.Pools.List(context.TODO(), cloudflare.LoadBalancerPoolListParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Monitor: cloudflare.F[any](map[string]interface{}{}), - }) - 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 TestLoadBalancerPoolDelete(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("user@example.com"), - ) - _, err := client.LoadBalancers.Pools.Delete( - context.TODO(), - "17b5962d775c646f3f9725cbc7a53df4", - cloudflare.LoadBalancerPoolDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestLoadBalancerPoolEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.LoadBalancers.Pools.Edit( - context.TODO(), - "17b5962d775c646f3f9725cbc7a53df4", - cloudflare.LoadBalancerPoolEditParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - CheckRegions: cloudflare.F([]cloudflare.LoadBalancerPoolEditParamsCheckRegion{cloudflare.LoadBalancerPoolEditParamsCheckRegionWeu, cloudflare.LoadBalancerPoolEditParamsCheckRegionEnam}), - Description: cloudflare.F("Primary data center - Provider XYZ"), - Enabled: cloudflare.F(false), - Latitude: cloudflare.F(0.000000), - LoadShedding: cloudflare.F(cloudflare.LoadBalancerPoolEditParamsLoadShedding{ - DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(cloudflare.LoadBalancerPoolEditParamsLoadSheddingDefaultPolicyRandom), - SessionPercent: cloudflare.F(0.000000), - SessionPolicy: cloudflare.F(cloudflare.LoadBalancerPoolEditParamsLoadSheddingSessionPolicyHash), - }), - Longitude: cloudflare.F(0.000000), - MinimumOrigins: cloudflare.F(int64(0)), - Monitor: cloudflare.F[any](map[string]interface{}{}), - Name: cloudflare.F("primary-dc-1"), - NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), - NotificationFilter: cloudflare.F(cloudflare.LoadBalancerPoolEditParamsNotificationFilter{ - Origin: cloudflare.F(cloudflare.LoadBalancerPoolEditParamsNotificationFilterOrigin{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(true), - }), - Pool: cloudflare.F(cloudflare.LoadBalancerPoolEditParamsNotificationFilterPool{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(false), - }), - }), - OriginSteering: cloudflare.F(cloudflare.LoadBalancerPoolEditParamsOriginSteering{ - Policy: cloudflare.F(cloudflare.LoadBalancerPoolEditParamsOriginSteeringPolicyRandom), - }), - Origins: cloudflare.F([]cloudflare.LoadBalancerPoolEditParamsOrigin{{ - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(cloudflare.LoadBalancerPoolEditParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), - }), - Name: cloudflare.F("app-server-1"), - VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), - Weight: cloudflare.F(0.600000), - }, { - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(cloudflare.LoadBalancerPoolEditParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), - }), - Name: cloudflare.F("app-server-1"), - VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), - Weight: cloudflare.F(0.600000), - }, { - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(cloudflare.LoadBalancerPoolEditParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), - }), - Name: cloudflare.F("app-server-1"), - VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), - Weight: cloudflare.F(0.600000), - }}), - }, - ) - 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 TestLoadBalancerPoolGet(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("user@example.com"), - ) - _, err := client.LoadBalancers.Pools.Get( - context.TODO(), - "17b5962d775c646f3f9725cbc7a53df4", - cloudflare.LoadBalancerPoolGetParams{ - AccountID: cloudflare.F("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/loadbalancerpoolhealth.go b/loadbalancerpoolhealth.go deleted file mode 100644 index 40aa2a79a23..00000000000 --- a/loadbalancerpoolhealth.go +++ /dev/null @@ -1,346 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// LoadBalancerPoolHealthService 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 [NewLoadBalancerPoolHealthService] -// method instead. -type LoadBalancerPoolHealthService struct { - Options []option.RequestOption -} - -// NewLoadBalancerPoolHealthService 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 NewLoadBalancerPoolHealthService(opts ...option.RequestOption) (r *LoadBalancerPoolHealthService) { - r = &LoadBalancerPoolHealthService{} - r.Options = opts - return -} - -// Preview pool health using provided monitor details. The returned preview_id can -// be used in the preview endpoint to retrieve the results. -func (r *LoadBalancerPoolHealthService) New(ctx context.Context, poolID string, params LoadBalancerPoolHealthNewParams, opts ...option.RequestOption) (res *LoadBalancerPoolHealthNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPoolHealthNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s/preview", params.AccountID, poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch the latest pool health status for a single pool. -func (r *LoadBalancerPoolHealthService) Get(ctx context.Context, poolID string, query LoadBalancerPoolHealthGetParams, opts ...option.RequestOption) (res *LoadBalancerPoolHealthGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPoolHealthGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s/health", query.AccountID, poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LoadBalancerPoolHealthNewResponse struct { - // Monitored pool IDs mapped to their respective names. - Pools map[string]string `json:"pools"` - PreviewID string `json:"preview_id"` - JSON loadBalancerPoolHealthNewResponseJSON `json:"-"` -} - -// loadBalancerPoolHealthNewResponseJSON contains the JSON metadata for the struct -// [LoadBalancerPoolHealthNewResponse] -type loadBalancerPoolHealthNewResponseJSON struct { - Pools apijson.Field - PreviewID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolHealthNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolHealthNewResponseJSON) RawJSON() string { - return r.raw -} - -// A list of regions from which to run health checks. Null means every Cloudflare -// data center. -// -// Union satisfied by [LoadBalancerPoolHealthGetResponseUnknown] or -// [shared.UnionString]. -type LoadBalancerPoolHealthGetResponse interface { - ImplementsLoadBalancerPoolHealthGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*LoadBalancerPoolHealthGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type LoadBalancerPoolHealthNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes param.Field[string] `json:"expected_codes,required"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown param.Field[int64] `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp param.Field[int64] `json:"consecutive_up"` - // Object description. - Description param.Field[string] `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody param.Field[string] `json:"expected_body"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header param.Field[interface{}] `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method param.Field[string] `json:"method"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path param.Field[string] `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port param.Field[int64] `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone param.Field[string] `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type param.Field[LoadBalancerPoolHealthNewParamsType] `json:"type"` -} - -func (r LoadBalancerPoolHealthNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancerPoolHealthNewParamsType string - -const ( - LoadBalancerPoolHealthNewParamsTypeHTTP LoadBalancerPoolHealthNewParamsType = "http" - LoadBalancerPoolHealthNewParamsTypeHTTPS LoadBalancerPoolHealthNewParamsType = "https" - LoadBalancerPoolHealthNewParamsTypeTcp LoadBalancerPoolHealthNewParamsType = "tcp" - LoadBalancerPoolHealthNewParamsTypeUdpIcmp LoadBalancerPoolHealthNewParamsType = "udp_icmp" - LoadBalancerPoolHealthNewParamsTypeIcmpPing LoadBalancerPoolHealthNewParamsType = "icmp_ping" - LoadBalancerPoolHealthNewParamsTypeSmtp LoadBalancerPoolHealthNewParamsType = "smtp" -) - -type LoadBalancerPoolHealthNewResponseEnvelope struct { - Errors []LoadBalancerPoolHealthNewResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPoolHealthNewResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerPoolHealthNewResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerPoolHealthNewResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerPoolHealthNewResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPoolHealthNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerPoolHealthNewResponseEnvelope] -type loadBalancerPoolHealthNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolHealthNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolHealthNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolHealthNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolHealthNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPoolHealthNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [LoadBalancerPoolHealthNewResponseEnvelopeErrors] -type loadBalancerPoolHealthNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolHealthNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolHealthNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolHealthNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolHealthNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPoolHealthNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerPoolHealthNewResponseEnvelopeMessages] -type loadBalancerPoolHealthNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolHealthNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolHealthNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPoolHealthNewResponseEnvelopeSuccess bool - -const ( - LoadBalancerPoolHealthNewResponseEnvelopeSuccessTrue LoadBalancerPoolHealthNewResponseEnvelopeSuccess = true -) - -type LoadBalancerPoolHealthGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type LoadBalancerPoolHealthGetResponseEnvelope struct { - Errors []LoadBalancerPoolHealthGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPoolHealthGetResponseEnvelopeMessages `json:"messages,required"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - Result LoadBalancerPoolHealthGetResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerPoolHealthGetResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerPoolHealthGetResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPoolHealthGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerPoolHealthGetResponseEnvelope] -type loadBalancerPoolHealthGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolHealthGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolHealthGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolHealthGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolHealthGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPoolHealthGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [LoadBalancerPoolHealthGetResponseEnvelopeErrors] -type loadBalancerPoolHealthGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolHealthGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolHealthGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolHealthGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolHealthGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPoolHealthGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerPoolHealthGetResponseEnvelopeMessages] -type loadBalancerPoolHealthGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolHealthGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolHealthGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPoolHealthGetResponseEnvelopeSuccess bool - -const ( - LoadBalancerPoolHealthGetResponseEnvelopeSuccessTrue LoadBalancerPoolHealthGetResponseEnvelopeSuccess = true -) diff --git a/loadbalancerpoolhealth_test.go b/loadbalancerpoolhealth_test.go deleted file mode 100644 index 1f144657e5d..00000000000 --- a/loadbalancerpoolhealth_test.go +++ /dev/null @@ -1,97 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLoadBalancerPoolHealthNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.LoadBalancers.Pools.Health.New( - context.TODO(), - "17b5962d775c646f3f9725cbc7a53df4", - cloudflare.LoadBalancerPoolHealthNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - ExpectedCodes: cloudflare.F("2xx"), - AllowInsecure: cloudflare.F(true), - ConsecutiveDown: cloudflare.F(int64(0)), - ConsecutiveUp: cloudflare.F(int64(0)), - Description: cloudflare.F("Login page monitor"), - ExpectedBody: cloudflare.F("alive"), - FollowRedirects: cloudflare.F(true), - Header: cloudflare.F[any](map[string]interface{}{ - "Host": map[string]interface{}{ - "0": "example.com", - }, - "X-App-ID": map[string]interface{}{ - "0": "abc123", - }, - }), - Interval: cloudflare.F(int64(0)), - Method: cloudflare.F("GET"), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - ProbeZone: cloudflare.F("example.com"), - Retries: cloudflare.F(int64(0)), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F(cloudflare.LoadBalancerPoolHealthNewParamsTypeHTTPS), - }, - ) - 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 TestLoadBalancerPoolHealthGet(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("user@example.com"), - ) - _, err := client.LoadBalancers.Pools.Health.Get( - context.TODO(), - "17b5962d775c646f3f9725cbc7a53df4", - cloudflare.LoadBalancerPoolHealthGetParams{ - AccountID: cloudflare.F("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/loadbalancerpoolreference.go b/loadbalancerpoolreference.go deleted file mode 100644 index f00c638a70f..00000000000 --- a/loadbalancerpoolreference.go +++ /dev/null @@ -1,200 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// LoadBalancerPoolReferenceService 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 -// [NewLoadBalancerPoolReferenceService] method instead. -type LoadBalancerPoolReferenceService struct { - Options []option.RequestOption -} - -// NewLoadBalancerPoolReferenceService 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 NewLoadBalancerPoolReferenceService(opts ...option.RequestOption) (r *LoadBalancerPoolReferenceService) { - r = &LoadBalancerPoolReferenceService{} - r.Options = opts - return -} - -// Get the list of resources that reference the provided pool. -func (r *LoadBalancerPoolReferenceService) Get(ctx context.Context, poolID string, query LoadBalancerPoolReferenceGetParams, opts ...option.RequestOption) (res *[]LoadBalancerPoolReferenceGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPoolReferenceGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/pools/%s/references", query.AccountID, poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LoadBalancerPoolReferenceGetResponse struct { - ReferenceType LoadBalancerPoolReferenceGetResponseReferenceType `json:"reference_type"` - ResourceID string `json:"resource_id"` - ResourceName string `json:"resource_name"` - ResourceType string `json:"resource_type"` - JSON loadBalancerPoolReferenceGetResponseJSON `json:"-"` -} - -// loadBalancerPoolReferenceGetResponseJSON contains the JSON metadata for the -// struct [LoadBalancerPoolReferenceGetResponse] -type loadBalancerPoolReferenceGetResponseJSON struct { - ReferenceType apijson.Field - ResourceID apijson.Field - ResourceName apijson.Field - ResourceType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolReferenceGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolReferenceGetResponseJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolReferenceGetResponseReferenceType string - -const ( - LoadBalancerPoolReferenceGetResponseReferenceTypeStar LoadBalancerPoolReferenceGetResponseReferenceType = "*" - LoadBalancerPoolReferenceGetResponseReferenceTypeReferral LoadBalancerPoolReferenceGetResponseReferenceType = "referral" - LoadBalancerPoolReferenceGetResponseReferenceTypeReferrer LoadBalancerPoolReferenceGetResponseReferenceType = "referrer" -) - -type LoadBalancerPoolReferenceGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type LoadBalancerPoolReferenceGetResponseEnvelope struct { - Errors []LoadBalancerPoolReferenceGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPoolReferenceGetResponseEnvelopeMessages `json:"messages,required"` - // List of resources that reference a given pool. - Result []LoadBalancerPoolReferenceGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LoadBalancerPoolReferenceGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo LoadBalancerPoolReferenceGetResponseEnvelopeResultInfo `json:"result_info"` - JSON loadBalancerPoolReferenceGetResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPoolReferenceGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [LoadBalancerPoolReferenceGetResponseEnvelope] -type loadBalancerPoolReferenceGetResponseEnvelopeJSON 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 *LoadBalancerPoolReferenceGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolReferenceGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolReferenceGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolReferenceGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPoolReferenceGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [LoadBalancerPoolReferenceGetResponseEnvelopeErrors] -type loadBalancerPoolReferenceGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolReferenceGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolReferenceGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPoolReferenceGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPoolReferenceGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPoolReferenceGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [LoadBalancerPoolReferenceGetResponseEnvelopeMessages] -type loadBalancerPoolReferenceGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolReferenceGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolReferenceGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPoolReferenceGetResponseEnvelopeSuccess bool - -const ( - LoadBalancerPoolReferenceGetResponseEnvelopeSuccessTrue LoadBalancerPoolReferenceGetResponseEnvelopeSuccess = true -) - -type LoadBalancerPoolReferenceGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON loadBalancerPoolReferenceGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// loadBalancerPoolReferenceGetResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [LoadBalancerPoolReferenceGetResponseEnvelopeResultInfo] -type loadBalancerPoolReferenceGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPoolReferenceGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPoolReferenceGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/loadbalancerpoolreference_test.go b/loadbalancerpoolreference_test.go deleted file mode 100644 index 2f90b2befe9..00000000000 --- a/loadbalancerpoolreference_test.go +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLoadBalancerPoolReferenceGet(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("user@example.com"), - ) - _, err := client.LoadBalancers.Pools.References.Get( - context.TODO(), - "17b5962d775c646f3f9725cbc7a53df4", - cloudflare.LoadBalancerPoolReferenceGetParams{ - AccountID: cloudflare.F("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/loadbalancerpreview.go b/loadbalancerpreview.go deleted file mode 100644 index 173fede7767..00000000000 --- a/loadbalancerpreview.go +++ /dev/null @@ -1,134 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// LoadBalancerPreviewService 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 [NewLoadBalancerPreviewService] -// method instead. -type LoadBalancerPreviewService struct { - Options []option.RequestOption -} - -// NewLoadBalancerPreviewService 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 NewLoadBalancerPreviewService(opts ...option.RequestOption) (r *LoadBalancerPreviewService) { - r = &LoadBalancerPreviewService{} - r.Options = opts - return -} - -// Get the result of a previous preview operation using the provided preview_id. -func (r *LoadBalancerPreviewService) Get(ctx context.Context, previewID interface{}, query LoadBalancerPreviewGetParams, opts ...option.RequestOption) (res *LoadBalancerPreviewGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerPreviewGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/preview/%v", query.AccountID, previewID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LoadBalancerPreviewGetResponse map[string]LoadBalancerPreviewGetResponse - -type LoadBalancerPreviewGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type LoadBalancerPreviewGetResponseEnvelope struct { - Errors []LoadBalancerPreviewGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerPreviewGetResponseEnvelopeMessages `json:"messages,required"` - // Resulting health data from a preview operation. - Result LoadBalancerPreviewGetResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerPreviewGetResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerPreviewGetResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerPreviewGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerPreviewGetResponseEnvelope] -type loadBalancerPreviewGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPreviewGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPreviewGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPreviewGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPreviewGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerPreviewGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerPreviewGetResponseEnvelopeErrors] -type loadBalancerPreviewGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPreviewGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPreviewGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerPreviewGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerPreviewGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerPreviewGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerPreviewGetResponseEnvelopeMessages] -type loadBalancerPreviewGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerPreviewGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerPreviewGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerPreviewGetResponseEnvelopeSuccess bool - -const ( - LoadBalancerPreviewGetResponseEnvelopeSuccessTrue LoadBalancerPreviewGetResponseEnvelopeSuccess = true -) diff --git a/loadbalancerregion.go b/loadbalancerregion.go deleted file mode 100644 index 57c6d932303..00000000000 --- a/loadbalancerregion.go +++ /dev/null @@ -1,310 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// LoadBalancerRegionService 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 [NewLoadBalancerRegionService] method -// instead. -type LoadBalancerRegionService struct { - Options []option.RequestOption -} - -// NewLoadBalancerRegionService 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 NewLoadBalancerRegionService(opts ...option.RequestOption) (r *LoadBalancerRegionService) { - r = &LoadBalancerRegionService{} - r.Options = opts - return -} - -// List all region mappings. -func (r *LoadBalancerRegionService) List(ctx context.Context, params LoadBalancerRegionListParams, opts ...option.RequestOption) (res *LoadBalancerRegionListResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerRegionListResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/regions", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a single region mapping. -func (r *LoadBalancerRegionService) Get(ctx context.Context, regionID LoadBalancerRegionGetParamsRegionID, query LoadBalancerRegionGetParams, opts ...option.RequestOption) (res *LoadBalancerRegionGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerRegionGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/regions/%v", query.AccountID, regionID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [LoadBalancerRegionListResponseUnknown] or -// [shared.UnionString]. -type LoadBalancerRegionListResponse interface { - ImplementsLoadBalancerRegionListResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*LoadBalancerRegionListResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// A list of countries and subdivisions mapped to a region. -// -// Union satisfied by [LoadBalancerRegionGetResponseUnknown] or -// [shared.UnionString]. -type LoadBalancerRegionGetResponse interface { - ImplementsLoadBalancerRegionGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*LoadBalancerRegionGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type LoadBalancerRegionListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Two-letter alpha-2 country code followed in ISO 3166-1. - CountryCodeA2 param.Field[string] `query:"country_code_a2"` - // Two-letter subdivision code followed in ISO 3166-2. - SubdivisionCode param.Field[string] `query:"subdivision_code"` - // Two-letter subdivision code followed in ISO 3166-2. - SubdivisionCodeA2 param.Field[string] `query:"subdivision_code_a2"` -} - -// URLQuery serializes [LoadBalancerRegionListParams]'s query parameters as -// `url.Values`. -func (r LoadBalancerRegionListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type LoadBalancerRegionListResponseEnvelope struct { - Errors []LoadBalancerRegionListResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerRegionListResponseEnvelopeMessages `json:"messages,required"` - Result LoadBalancerRegionListResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerRegionListResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerRegionListResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerRegionListResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerRegionListResponseEnvelope] -type loadBalancerRegionListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerRegionListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerRegionListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerRegionListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerRegionListResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerRegionListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerRegionListResponseEnvelopeErrors] -type loadBalancerRegionListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerRegionListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerRegionListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerRegionListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerRegionListResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerRegionListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LoadBalancerRegionListResponseEnvelopeMessages] -type loadBalancerRegionListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerRegionListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerRegionListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerRegionListResponseEnvelopeSuccess bool - -const ( - LoadBalancerRegionListResponseEnvelopeSuccessTrue LoadBalancerRegionListResponseEnvelopeSuccess = true -) - -type LoadBalancerRegionGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -// A list of Cloudflare regions. WNAM: Western North America, ENAM: Eastern North -// America, WEU: Western Europe, EEU: Eastern Europe, NSAM: Northern South America, -// SSAM: Southern South America, OC: Oceania, ME: Middle East, NAF: North Africa, -// SAF: South Africa, SAS: Southern Asia, SEAS: South East Asia, NEAS: North East -// Asia). -type LoadBalancerRegionGetParamsRegionID string - -const ( - LoadBalancerRegionGetParamsRegionIDWnam LoadBalancerRegionGetParamsRegionID = "WNAM" - LoadBalancerRegionGetParamsRegionIDEnam LoadBalancerRegionGetParamsRegionID = "ENAM" - LoadBalancerRegionGetParamsRegionIDWeu LoadBalancerRegionGetParamsRegionID = "WEU" - LoadBalancerRegionGetParamsRegionIDEeu LoadBalancerRegionGetParamsRegionID = "EEU" - LoadBalancerRegionGetParamsRegionIDNsam LoadBalancerRegionGetParamsRegionID = "NSAM" - LoadBalancerRegionGetParamsRegionIDSsam LoadBalancerRegionGetParamsRegionID = "SSAM" - LoadBalancerRegionGetParamsRegionIDOc LoadBalancerRegionGetParamsRegionID = "OC" - LoadBalancerRegionGetParamsRegionIDMe LoadBalancerRegionGetParamsRegionID = "ME" - LoadBalancerRegionGetParamsRegionIDNaf LoadBalancerRegionGetParamsRegionID = "NAF" - LoadBalancerRegionGetParamsRegionIDSaf LoadBalancerRegionGetParamsRegionID = "SAF" - LoadBalancerRegionGetParamsRegionIDSas LoadBalancerRegionGetParamsRegionID = "SAS" - LoadBalancerRegionGetParamsRegionIDSeas LoadBalancerRegionGetParamsRegionID = "SEAS" - LoadBalancerRegionGetParamsRegionIDNeas LoadBalancerRegionGetParamsRegionID = "NEAS" -) - -type LoadBalancerRegionGetResponseEnvelope struct { - Errors []LoadBalancerRegionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerRegionGetResponseEnvelopeMessages `json:"messages,required"` - // A list of countries and subdivisions mapped to a region. - Result LoadBalancerRegionGetResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancerRegionGetResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancerRegionGetResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerRegionGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerRegionGetResponseEnvelope] -type loadBalancerRegionGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerRegionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerRegionGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerRegionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerRegionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerRegionGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerRegionGetResponseEnvelopeErrors] -type loadBalancerRegionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerRegionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerRegionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerRegionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerRegionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerRegionGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [LoadBalancerRegionGetResponseEnvelopeMessages] -type loadBalancerRegionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerRegionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerRegionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerRegionGetResponseEnvelopeSuccess bool - -const ( - LoadBalancerRegionGetResponseEnvelopeSuccessTrue LoadBalancerRegionGetResponseEnvelopeSuccess = true -) diff --git a/loadbalancerregion_test.go b/loadbalancerregion_test.go deleted file mode 100644 index cba93fe1e9b..00000000000 --- a/loadbalancerregion_test.go +++ /dev/null @@ -1,73 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLoadBalancerRegionListWithOptionalParams(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("user@example.com"), - ) - _, err := client.LoadBalancers.Regions.List(context.TODO(), cloudflare.LoadBalancerRegionListParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - CountryCodeA2: cloudflare.F("US"), - SubdivisionCode: cloudflare.F("CA"), - SubdivisionCodeA2: cloudflare.F("CA"), - }) - 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 TestLoadBalancerRegionGet(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("user@example.com"), - ) - _, err := client.LoadBalancers.Regions.Get( - context.TODO(), - cloudflare.LoadBalancerRegionGetParamsRegionIDWnam, - cloudflare.LoadBalancerRegionGetParams{ - AccountID: cloudflare.F("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/loadbalancersearch.go b/loadbalancersearch.go deleted file mode 100644 index 178bba8cc51..00000000000 --- a/loadbalancersearch.go +++ /dev/null @@ -1,206 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// LoadBalancerSearchService 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 [NewLoadBalancerSearchService] method -// instead. -type LoadBalancerSearchService struct { - Options []option.RequestOption -} - -// NewLoadBalancerSearchService 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 NewLoadBalancerSearchService(opts ...option.RequestOption) (r *LoadBalancerSearchService) { - r = &LoadBalancerSearchService{} - r.Options = opts - return -} - -// Search for Load Balancing resources. -func (r *LoadBalancerSearchService) Get(ctx context.Context, params LoadBalancerSearchGetParams, opts ...option.RequestOption) (res *[]LoadBalancerSearchGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancerSearchGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/load_balancers/search", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LoadBalancerSearchGetResponse = interface{} - -type LoadBalancerSearchGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Page param.Field[interface{}] `query:"page"` - PerPage param.Field[interface{}] `query:"per_page"` - SearchParams param.Field[LoadBalancerSearchGetParamsSearchParams] `query:"search_params"` -} - -// URLQuery serializes [LoadBalancerSearchGetParams]'s query parameters as -// `url.Values`. -func (r LoadBalancerSearchGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type LoadBalancerSearchGetParamsSearchParams struct { - // Search query term. - Query param.Field[string] `query:"query"` - // The type of references to include ("\*" for all). - References param.Field[LoadBalancerSearchGetParamsSearchParamsReferences] `query:"references"` -} - -// URLQuery serializes [LoadBalancerSearchGetParamsSearchParams]'s query parameters -// as `url.Values`. -func (r LoadBalancerSearchGetParamsSearchParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// The type of references to include ("\*" for all). -type LoadBalancerSearchGetParamsSearchParamsReferences string - -const ( - LoadBalancerSearchGetParamsSearchParamsReferencesEmpty LoadBalancerSearchGetParamsSearchParamsReferences = "" - LoadBalancerSearchGetParamsSearchParamsReferencesStar LoadBalancerSearchGetParamsSearchParamsReferences = "*" - LoadBalancerSearchGetParamsSearchParamsReferencesReferral LoadBalancerSearchGetParamsSearchParamsReferences = "referral" - LoadBalancerSearchGetParamsSearchParamsReferencesReferrer LoadBalancerSearchGetParamsSearchParamsReferences = "referrer" -) - -type LoadBalancerSearchGetResponseEnvelope struct { - Errors []LoadBalancerSearchGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LoadBalancerSearchGetResponseEnvelopeMessages `json:"messages,required"` - Result []LoadBalancerSearchGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LoadBalancerSearchGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo LoadBalancerSearchGetResponseEnvelopeResultInfo `json:"result_info"` - JSON loadBalancerSearchGetResponseEnvelopeJSON `json:"-"` -} - -// loadBalancerSearchGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancerSearchGetResponseEnvelope] -type loadBalancerSearchGetResponseEnvelopeJSON 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 *LoadBalancerSearchGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerSearchGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerSearchGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerSearchGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// loadBalancerSearchGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LoadBalancerSearchGetResponseEnvelopeErrors] -type loadBalancerSearchGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerSearchGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerSearchGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LoadBalancerSearchGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON loadBalancerSearchGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// loadBalancerSearchGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [LoadBalancerSearchGetResponseEnvelopeMessages] -type loadBalancerSearchGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerSearchGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerSearchGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancerSearchGetResponseEnvelopeSuccess bool - -const ( - LoadBalancerSearchGetResponseEnvelopeSuccessTrue LoadBalancerSearchGetResponseEnvelopeSuccess = true -) - -type LoadBalancerSearchGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON loadBalancerSearchGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// loadBalancerSearchGetResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [LoadBalancerSearchGetResponseEnvelopeResultInfo] -type loadBalancerSearchGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancerSearchGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancerSearchGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/loadbalancersearch_test.go b/loadbalancersearch_test.go deleted file mode 100644 index 6a46c039b0e..00000000000 --- a/loadbalancersearch_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLoadBalancerSearchGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.LoadBalancers.Searches.Get(context.TODO(), cloudflare.LoadBalancerSearchGetParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Page: cloudflare.F[any](map[string]interface{}{}), - PerPage: cloudflare.F[any](map[string]interface{}{}), - SearchParams: cloudflare.F(cloudflare.LoadBalancerSearchGetParamsSearchParams{ - Query: cloudflare.F("primary"), - References: cloudflare.F(cloudflare.LoadBalancerSearchGetParamsSearchParamsReferencesStar), - }), - }) - 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/logcontrol.go b/logcontrol.go deleted file mode 100644 index 09819461f21..00000000000 --- a/logcontrol.go +++ /dev/null @@ -1,28 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// LogControlService 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 [NewLogControlService] method instead. -type LogControlService struct { - Options []option.RequestOption - Retention *LogControlRetentionService - Cmb *LogControlCmbService -} - -// NewLogControlService 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 NewLogControlService(opts ...option.RequestOption) (r *LogControlService) { - r = &LogControlService{} - r.Options = opts - r.Retention = NewLogControlRetentionService(opts...) - r.Cmb = NewLogControlCmbService(opts...) - return -} diff --git a/logcontrolcmb.go b/logcontrolcmb.go deleted file mode 100644 index 8f823100eb8..00000000000 --- a/logcontrolcmb.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// LogControlCmbService 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 [NewLogControlCmbService] method -// instead. -type LogControlCmbService struct { - Options []option.RequestOption - Config *LogControlCmbConfigService -} - -// NewLogControlCmbService 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 NewLogControlCmbService(opts ...option.RequestOption) (r *LogControlCmbService) { - r = &LogControlCmbService{} - r.Options = opts - r.Config = NewLogControlCmbConfigService(opts...) - return -} diff --git a/logcontrolcmbconfig.go b/logcontrolcmbconfig.go deleted file mode 100644 index c184d6096de..00000000000 --- a/logcontrolcmbconfig.go +++ /dev/null @@ -1,407 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// LogControlCmbConfigService 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 [NewLogControlCmbConfigService] -// method instead. -type LogControlCmbConfigService struct { - Options []option.RequestOption -} - -// NewLogControlCmbConfigService 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 NewLogControlCmbConfigService(opts ...option.RequestOption) (r *LogControlCmbConfigService) { - r = &LogControlCmbConfigService{} - r.Options = opts - return -} - -// Updates CMB config. -func (r *LogControlCmbConfigService) New(ctx context.Context, params LogControlCmbConfigNewParams, opts ...option.RequestOption) (res *LogControlCmbConfigNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env LogControlCmbConfigNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/logs/control/cmb/config", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes CMB config. -func (r *LogControlCmbConfigService) Delete(ctx context.Context, body LogControlCmbConfigDeleteParams, opts ...option.RequestOption) (res *LogControlCmbConfigDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env LogControlCmbConfigDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/logs/control/cmb/config", body.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets CMB config. -func (r *LogControlCmbConfigService) Get(ctx context.Context, query LogControlCmbConfigGetParams, opts ...option.RequestOption) (res *LogControlCmbConfigGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env LogControlCmbConfigGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/logs/control/cmb/config", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LogControlCmbConfigNewResponse struct { - // Comma-separated list of regions. - Regions string `json:"regions"` - JSON logControlCmbConfigNewResponseJSON `json:"-"` -} - -// logControlCmbConfigNewResponseJSON contains the JSON metadata for the struct -// [LogControlCmbConfigNewResponse] -type logControlCmbConfigNewResponseJSON struct { - Regions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlCmbConfigNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlCmbConfigNewResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [LogControlCmbConfigDeleteResponseUnknown], -// [LogControlCmbConfigDeleteResponseArray] or [shared.UnionString]. -type LogControlCmbConfigDeleteResponse interface { - ImplementsLogControlCmbConfigDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*LogControlCmbConfigDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(LogControlCmbConfigDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type LogControlCmbConfigDeleteResponseArray []interface{} - -func (r LogControlCmbConfigDeleteResponseArray) ImplementsLogControlCmbConfigDeleteResponse() {} - -type LogControlCmbConfigGetResponse struct { - // Comma-separated list of regions. - Regions string `json:"regions"` - JSON logControlCmbConfigGetResponseJSON `json:"-"` -} - -// logControlCmbConfigGetResponseJSON contains the JSON metadata for the struct -// [LogControlCmbConfigGetResponse] -type logControlCmbConfigGetResponseJSON struct { - Regions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlCmbConfigGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlCmbConfigGetResponseJSON) RawJSON() string { - return r.raw -} - -type LogControlCmbConfigNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Comma-separated list of regions. - Regions param.Field[string] `json:"regions"` -} - -func (r LogControlCmbConfigNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type LogControlCmbConfigNewResponseEnvelope struct { - Errors []LogControlCmbConfigNewResponseEnvelopeErrors `json:"errors,required"` - Messages []LogControlCmbConfigNewResponseEnvelopeMessages `json:"messages,required"` - Result LogControlCmbConfigNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LogControlCmbConfigNewResponseEnvelopeSuccess `json:"success,required"` - JSON logControlCmbConfigNewResponseEnvelopeJSON `json:"-"` -} - -// logControlCmbConfigNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [LogControlCmbConfigNewResponseEnvelope] -type logControlCmbConfigNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlCmbConfigNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlCmbConfigNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LogControlCmbConfigNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logControlCmbConfigNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// logControlCmbConfigNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LogControlCmbConfigNewResponseEnvelopeErrors] -type logControlCmbConfigNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlCmbConfigNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlCmbConfigNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LogControlCmbConfigNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logControlCmbConfigNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// logControlCmbConfigNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LogControlCmbConfigNewResponseEnvelopeMessages] -type logControlCmbConfigNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlCmbConfigNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlCmbConfigNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LogControlCmbConfigNewResponseEnvelopeSuccess bool - -const ( - LogControlCmbConfigNewResponseEnvelopeSuccessTrue LogControlCmbConfigNewResponseEnvelopeSuccess = true -) - -type LogControlCmbConfigDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type LogControlCmbConfigDeleteResponseEnvelope struct { - Errors []LogControlCmbConfigDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []LogControlCmbConfigDeleteResponseEnvelopeMessages `json:"messages,required"` - Result LogControlCmbConfigDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LogControlCmbConfigDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON logControlCmbConfigDeleteResponseEnvelopeJSON `json:"-"` -} - -// logControlCmbConfigDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [LogControlCmbConfigDeleteResponseEnvelope] -type logControlCmbConfigDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlCmbConfigDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlCmbConfigDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LogControlCmbConfigDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logControlCmbConfigDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// logControlCmbConfigDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [LogControlCmbConfigDeleteResponseEnvelopeErrors] -type logControlCmbConfigDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlCmbConfigDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlCmbConfigDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LogControlCmbConfigDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logControlCmbConfigDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// logControlCmbConfigDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LogControlCmbConfigDeleteResponseEnvelopeMessages] -type logControlCmbConfigDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlCmbConfigDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlCmbConfigDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LogControlCmbConfigDeleteResponseEnvelopeSuccess bool - -const ( - LogControlCmbConfigDeleteResponseEnvelopeSuccessTrue LogControlCmbConfigDeleteResponseEnvelopeSuccess = true -) - -type LogControlCmbConfigGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type LogControlCmbConfigGetResponseEnvelope struct { - Errors []LogControlCmbConfigGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LogControlCmbConfigGetResponseEnvelopeMessages `json:"messages,required"` - Result LogControlCmbConfigGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LogControlCmbConfigGetResponseEnvelopeSuccess `json:"success,required"` - JSON logControlCmbConfigGetResponseEnvelopeJSON `json:"-"` -} - -// logControlCmbConfigGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [LogControlCmbConfigGetResponseEnvelope] -type logControlCmbConfigGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlCmbConfigGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlCmbConfigGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LogControlCmbConfigGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logControlCmbConfigGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// logControlCmbConfigGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LogControlCmbConfigGetResponseEnvelopeErrors] -type logControlCmbConfigGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlCmbConfigGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlCmbConfigGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LogControlCmbConfigGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logControlCmbConfigGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// logControlCmbConfigGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LogControlCmbConfigGetResponseEnvelopeMessages] -type logControlCmbConfigGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlCmbConfigGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlCmbConfigGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LogControlCmbConfigGetResponseEnvelopeSuccess bool - -const ( - LogControlCmbConfigGetResponseEnvelopeSuccessTrue LogControlCmbConfigGetResponseEnvelopeSuccess = true -) diff --git a/logcontrolcmbconfig_test.go b/logcontrolcmbconfig_test.go deleted file mode 100644 index 61b21519a01..00000000000 --- a/logcontrolcmbconfig_test.go +++ /dev/null @@ -1,93 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLogControlCmbConfigNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Logs.Control.Cmb.Config.New(context.TODO(), cloudflare.LogControlCmbConfigNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Regions: cloudflare.F("eu"), - }) - 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 TestLogControlCmbConfigDelete(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("user@example.com"), - ) - _, err := client.Logs.Control.Cmb.Config.Delete(context.TODO(), cloudflare.LogControlCmbConfigDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestLogControlCmbConfigGet(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("user@example.com"), - ) - _, err := client.Logs.Control.Cmb.Config.Get(context.TODO(), cloudflare.LogControlCmbConfigGetParams{ - AccountID: cloudflare.F("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/logcontrolretention.go b/logcontrolretention.go deleted file mode 100644 index 823ab21136a..00000000000 --- a/logcontrolretention.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// LogControlRetentionService 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 [NewLogControlRetentionService] -// method instead. -type LogControlRetentionService struct { - Options []option.RequestOption - Flag *LogControlRetentionFlagService -} - -// NewLogControlRetentionService 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 NewLogControlRetentionService(opts ...option.RequestOption) (r *LogControlRetentionService) { - r = &LogControlRetentionService{} - r.Options = opts - r.Flag = NewLogControlRetentionFlagService(opts...) - return -} diff --git a/logcontrolretentionflag.go b/logcontrolretentionflag.go deleted file mode 100644 index d091c6d0d9f..00000000000 --- a/logcontrolretentionflag.go +++ /dev/null @@ -1,271 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// LogControlRetentionFlagService 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 -// [NewLogControlRetentionFlagService] method instead. -type LogControlRetentionFlagService struct { - Options []option.RequestOption -} - -// NewLogControlRetentionFlagService 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 NewLogControlRetentionFlagService(opts ...option.RequestOption) (r *LogControlRetentionFlagService) { - r = &LogControlRetentionFlagService{} - r.Options = opts - return -} - -// Updates log retention flag for Logpull API. -func (r *LogControlRetentionFlagService) New(ctx context.Context, zoneIdentifier string, body LogControlRetentionFlagNewParams, opts ...option.RequestOption) (res *LogControlRetentionFlagNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env LogControlRetentionFlagNewResponseEnvelope - path := fmt.Sprintf("zones/%s/logs/control/retention/flag", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets log retention flag for Logpull API. -func (r *LogControlRetentionFlagService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *LogControlRetentionFlagGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env LogControlRetentionFlagGetResponseEnvelope - path := fmt.Sprintf("zones/%s/logs/control/retention/flag", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LogControlRetentionFlagNewResponse struct { - Flag bool `json:"flag"` - JSON logControlRetentionFlagNewResponseJSON `json:"-"` -} - -// logControlRetentionFlagNewResponseJSON contains the JSON metadata for the struct -// [LogControlRetentionFlagNewResponse] -type logControlRetentionFlagNewResponseJSON struct { - Flag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlRetentionFlagNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlRetentionFlagNewResponseJSON) RawJSON() string { - return r.raw -} - -type LogControlRetentionFlagGetResponse struct { - Flag bool `json:"flag"` - JSON logControlRetentionFlagGetResponseJSON `json:"-"` -} - -// logControlRetentionFlagGetResponseJSON contains the JSON metadata for the struct -// [LogControlRetentionFlagGetResponse] -type logControlRetentionFlagGetResponseJSON struct { - Flag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlRetentionFlagGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlRetentionFlagGetResponseJSON) RawJSON() string { - return r.raw -} - -type LogControlRetentionFlagNewParams struct { - // The log retention flag for Logpull API. - Flag param.Field[bool] `json:"flag,required"` -} - -func (r LogControlRetentionFlagNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type LogControlRetentionFlagNewResponseEnvelope struct { - Errors []LogControlRetentionFlagNewResponseEnvelopeErrors `json:"errors,required"` - Messages []LogControlRetentionFlagNewResponseEnvelopeMessages `json:"messages,required"` - Result LogControlRetentionFlagNewResponse `json:"result,required"` - // Whether the API call was successful - Success LogControlRetentionFlagNewResponseEnvelopeSuccess `json:"success,required"` - JSON logControlRetentionFlagNewResponseEnvelopeJSON `json:"-"` -} - -// logControlRetentionFlagNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [LogControlRetentionFlagNewResponseEnvelope] -type logControlRetentionFlagNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlRetentionFlagNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlRetentionFlagNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LogControlRetentionFlagNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logControlRetentionFlagNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// logControlRetentionFlagNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [LogControlRetentionFlagNewResponseEnvelopeErrors] -type logControlRetentionFlagNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlRetentionFlagNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlRetentionFlagNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LogControlRetentionFlagNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logControlRetentionFlagNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// logControlRetentionFlagNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [LogControlRetentionFlagNewResponseEnvelopeMessages] -type logControlRetentionFlagNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlRetentionFlagNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlRetentionFlagNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LogControlRetentionFlagNewResponseEnvelopeSuccess bool - -const ( - LogControlRetentionFlagNewResponseEnvelopeSuccessTrue LogControlRetentionFlagNewResponseEnvelopeSuccess = true -) - -type LogControlRetentionFlagGetResponseEnvelope struct { - Errors []LogControlRetentionFlagGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LogControlRetentionFlagGetResponseEnvelopeMessages `json:"messages,required"` - Result LogControlRetentionFlagGetResponse `json:"result,required"` - // Whether the API call was successful - Success LogControlRetentionFlagGetResponseEnvelopeSuccess `json:"success,required"` - JSON logControlRetentionFlagGetResponseEnvelopeJSON `json:"-"` -} - -// logControlRetentionFlagGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [LogControlRetentionFlagGetResponseEnvelope] -type logControlRetentionFlagGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlRetentionFlagGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlRetentionFlagGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LogControlRetentionFlagGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logControlRetentionFlagGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// logControlRetentionFlagGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [LogControlRetentionFlagGetResponseEnvelopeErrors] -type logControlRetentionFlagGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlRetentionFlagGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlRetentionFlagGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LogControlRetentionFlagGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logControlRetentionFlagGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// logControlRetentionFlagGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [LogControlRetentionFlagGetResponseEnvelopeMessages] -type logControlRetentionFlagGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogControlRetentionFlagGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logControlRetentionFlagGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LogControlRetentionFlagGetResponseEnvelopeSuccess bool - -const ( - LogControlRetentionFlagGetResponseEnvelopeSuccessTrue LogControlRetentionFlagGetResponseEnvelopeSuccess = true -) diff --git a/logcontrolretentionflag_test.go b/logcontrolretentionflag_test.go deleted file mode 100644 index 1d64c2cefd2..00000000000 --- a/logcontrolretentionflag_test.go +++ /dev/null @@ -1,68 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLogControlRetentionFlagNew(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("user@example.com"), - ) - _, err := client.Logs.Control.Retention.Flag.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.LogControlRetentionFlagNewParams{ - Flag: cloudflare.F(true), - }, - ) - 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 TestLogControlRetentionFlagGet(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("user@example.com"), - ) - _, err := client.Logs.Control.Retention.Flag.Get(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/logpush.go b/logpush.go deleted file mode 100644 index abd62e5304c..00000000000 --- a/logpush.go +++ /dev/null @@ -1,34 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// LogpushService 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 [NewLogpushService] method instead. -type LogpushService struct { - Options []option.RequestOption - Datasets *LogpushDatasetService - Edge *LogpushEdgeService - Jobs *LogpushJobService - Ownership *LogpushOwnershipService - Validate *LogpushValidateService -} - -// NewLogpushService 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 NewLogpushService(opts ...option.RequestOption) (r *LogpushService) { - r = &LogpushService{} - r.Options = opts - r.Datasets = NewLogpushDatasetService(opts...) - r.Edge = NewLogpushEdgeService(opts...) - r.Jobs = NewLogpushJobService(opts...) - r.Ownership = NewLogpushOwnershipService(opts...) - r.Validate = NewLogpushValidateService(opts...) - return -} diff --git a/logpush/aliases.go b/logpush/aliases.go new file mode 100644 index 00000000000..a0a164e290b --- /dev/null +++ b/logpush/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package logpush + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/logpush/dataset.go b/logpush/dataset.go new file mode 100644 index 00000000000..4eb8afd2015 --- /dev/null +++ b/logpush/dataset.go @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package logpush + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// DatasetService 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 [NewDatasetService] method instead. +type DatasetService struct { + Options []option.RequestOption + Fields *DatasetFieldService + Jobs *DatasetJobService +} + +// NewDatasetService 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 NewDatasetService(opts ...option.RequestOption) (r *DatasetService) { + r = &DatasetService{} + r.Options = opts + r.Fields = NewDatasetFieldService(opts...) + r.Jobs = NewDatasetJobService(opts...) + return +} diff --git a/logpush/datasetfield.go b/logpush/datasetfield.go new file mode 100644 index 00000000000..4c2a36a4cd6 --- /dev/null +++ b/logpush/datasetfield.go @@ -0,0 +1,145 @@ +// File generated from our OpenAPI spec by Stainless. + +package logpush + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DatasetFieldService 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 [NewDatasetFieldService] method +// instead. +type DatasetFieldService struct { + Options []option.RequestOption +} + +// NewDatasetFieldService 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 NewDatasetFieldService(opts ...option.RequestOption) (r *DatasetFieldService) { + r = &DatasetFieldService{} + r.Options = opts + return +} + +// Lists all fields available for a dataset. The response result is an object with +// key-value pairs, where keys are field names, and values are descriptions. +func (r *DatasetFieldService) Get(ctx context.Context, datasetID string, query DatasetFieldGetParams, opts ...option.RequestOption) (res *DatasetFieldGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env DatasetFieldGetResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/logpush/datasets/%s/fields", accountOrZone, accountOrZoneID, datasetID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DatasetFieldGetResponse = interface{} + +type DatasetFieldGetParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type DatasetFieldGetResponseEnvelope struct { + Errors []DatasetFieldGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DatasetFieldGetResponseEnvelopeMessages `json:"messages,required"` + Result DatasetFieldGetResponse `json:"result,required"` + // Whether the API call was successful + Success DatasetFieldGetResponseEnvelopeSuccess `json:"success,required"` + JSON datasetFieldGetResponseEnvelopeJSON `json:"-"` +} + +// datasetFieldGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DatasetFieldGetResponseEnvelope] +type datasetFieldGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatasetFieldGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r datasetFieldGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DatasetFieldGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON datasetFieldGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// datasetFieldGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DatasetFieldGetResponseEnvelopeErrors] +type datasetFieldGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatasetFieldGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r datasetFieldGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DatasetFieldGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON datasetFieldGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// datasetFieldGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DatasetFieldGetResponseEnvelopeMessages] +type datasetFieldGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatasetFieldGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r datasetFieldGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DatasetFieldGetResponseEnvelopeSuccess bool + +const ( + DatasetFieldGetResponseEnvelopeSuccessTrue DatasetFieldGetResponseEnvelopeSuccess = true +) diff --git a/logpush/datasetfield_test.go b/logpush/datasetfield_test.go new file mode 100644 index 00000000000..58fdf8b14f3 --- /dev/null +++ b/logpush/datasetfield_test.go @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package logpush_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/logpush" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestDatasetFieldGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Logpush.Datasets.Fields.Get( + context.TODO(), + "http_requests", + logpush.DatasetFieldGetParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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/logpush/datasetjob.go b/logpush/datasetjob.go new file mode 100644 index 00000000000..0ac4dba985b --- /dev/null +++ b/logpush/datasetjob.go @@ -0,0 +1,310 @@ +// File generated from our OpenAPI spec by Stainless. + +package logpush + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DatasetJobService 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 [NewDatasetJobService] method instead. +type DatasetJobService struct { + Options []option.RequestOption +} + +// NewDatasetJobService 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 NewDatasetJobService(opts ...option.RequestOption) (r *DatasetJobService) { + r = &DatasetJobService{} + r.Options = opts + return +} + +// Lists Logpush jobs for an account or zone for a dataset. +func (r *DatasetJobService) Get(ctx context.Context, datasetID string, query DatasetJobGetParams, opts ...option.RequestOption) (res *[]LogpushLogpushJob, err error) { + opts = append(r.Options[:], opts...) + var env DatasetJobGetResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/logpush/datasets/%s/jobs", accountOrZone, accountOrZoneID, datasetID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type LogpushLogpushJob struct { + // Unique id of the job. + ID int64 `json:"id"` + // Name of the dataset. + Dataset string `json:"dataset,nullable"` + // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. + // Additional configuration parameters supported by the destination may be + // included. + DestinationConf string `json:"destination_conf" format:"uri"` + // Flag that indicates if the job is enabled. + Enabled bool `json:"enabled"` + // If not null, the job is currently failing. Failures are usually repetitive + // (example: no permissions to write to destination bucket). Only the last failure + // is recorded. On successful execution of a job the error_message and last_error + // are set to null. + ErrorMessage time.Time `json:"error_message,nullable" format:"date-time"` + // The frequency at which Cloudflare sends batches of logs to your destination. + // Setting frequency to high sends your logs in larger quantities of smaller files. + // Setting frequency to low sends logs in smaller quantities of larger files. + Frequency LogpushLogpushJobFrequency `json:"frequency,nullable"` + // Records the last time for which logs have been successfully pushed. If the last + // successful push was for logs range 2018-07-23T10:00:00Z to 2018-07-23T10:01:00Z + // then the value of this field will be 2018-07-23T10:01:00Z. If the job has never + // run or has just been enabled and hasn't run yet then the field will be empty. + LastComplete time.Time `json:"last_complete,nullable" format:"date-time"` + // Records the last time the job failed. If not null, the job is currently failing. + // If null, the job has either never failed or has run successfully at least once + // since last failure. See also the error_message field. + LastError time.Time `json:"last_error,nullable" format:"date-time"` + // This field is deprecated. Use `output_options` instead. Configuration string. It + // specifies things like requested fields and timestamp formats. If migrating from + // the logpull api, copy the url (full url or just the query string) of your call + // here, and logpush will keep on making this call for you, setting start and end + // times appropriately. + LogpullOptions string `json:"logpull_options,nullable" format:"uri-reference"` + // Optional human readable job name. Not unique. Cloudflare suggests that you set + // this to a meaningful string, like the domain name, to make it easier to identify + // your job. + Name string `json:"name,nullable"` + // The structured replacement for `logpull_options`. When including this field, the + // `logpull_option` field will be ignored. + OutputOptions LogpushLogpushJobOutputOptions `json:"output_options,nullable"` + JSON logpushLogpushJobJSON `json:"-"` +} + +// logpushLogpushJobJSON contains the JSON metadata for the struct +// [LogpushLogpushJob] +type logpushLogpushJobJSON struct { + ID apijson.Field + Dataset apijson.Field + DestinationConf apijson.Field + Enabled apijson.Field + ErrorMessage apijson.Field + Frequency apijson.Field + LastComplete apijson.Field + LastError apijson.Field + LogpullOptions apijson.Field + Name apijson.Field + OutputOptions apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LogpushLogpushJob) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r logpushLogpushJobJSON) RawJSON() string { + return r.raw +} + +// The frequency at which Cloudflare sends batches of logs to your destination. +// Setting frequency to high sends your logs in larger quantities of smaller files. +// Setting frequency to low sends logs in smaller quantities of larger files. +type LogpushLogpushJobFrequency string + +const ( + LogpushLogpushJobFrequencyHigh LogpushLogpushJobFrequency = "high" + LogpushLogpushJobFrequencyLow LogpushLogpushJobFrequency = "low" +) + +// The structured replacement for `logpull_options`. When including this field, the +// `logpull_option` field will be ignored. +type LogpushLogpushJobOutputOptions struct { + // String to be prepended before each batch. + BatchPrefix string `json:"batch_prefix,nullable"` + // String to be appended after each batch. + BatchSuffix string `json:"batch_suffix,nullable"` + // If set to true, will cause all occurrences of `${` in the generated files to be + // replaced with `x{`. + Cve2021_4428 bool `json:"CVE-2021-4428,nullable"` + // String to join fields. This field be ignored when `record_template` is set. + FieldDelimiter string `json:"field_delimiter,nullable"` + // List of field names to be included in the Logpush output. For the moment, there + // is no option to add all fields at once, so you must specify all the fields names + // you are interested in. + FieldNames []string `json:"field_names"` + // Specifies the output type, such as `ndjson` or `csv`. This sets default values + // for the rest of the settings, depending on the chosen output type. Some + // formatting rules, like string quoting, are different between output types. + OutputType LogpushLogpushJobOutputOptionsOutputType `json:"output_type"` + // String to be inserted in-between the records as separator. + RecordDelimiter string `json:"record_delimiter,nullable"` + // String to be prepended before each record. + RecordPrefix string `json:"record_prefix,nullable"` + // String to be appended after each record. + RecordSuffix string `json:"record_suffix,nullable"` + // String to use as template for each record instead of the default comma-separated + // list. All fields used in the template must be present in `field_names` as well, + // otherwise they will end up as null. Format as a Go `text/template` without any + // standard functions, like conditionals, loops, sub-templates, etc. + RecordTemplate string `json:"record_template,nullable"` + // Floating number to specify sampling rate. Sampling is applied on top of + // filtering, and regardless of the current `sample_interval` of the data. + SampleRate float64 `json:"sample_rate,nullable"` + // String to specify the format for timestamps, such as `unixnano`, `unix`, or + // `rfc3339`. + TimestampFormat LogpushLogpushJobOutputOptionsTimestampFormat `json:"timestamp_format"` + JSON logpushLogpushJobOutputOptionsJSON `json:"-"` +} + +// logpushLogpushJobOutputOptionsJSON contains the JSON metadata for the struct +// [LogpushLogpushJobOutputOptions] +type logpushLogpushJobOutputOptionsJSON struct { + BatchPrefix apijson.Field + BatchSuffix apijson.Field + Cve2021_4428 apijson.Field + FieldDelimiter apijson.Field + FieldNames apijson.Field + OutputType apijson.Field + RecordDelimiter apijson.Field + RecordPrefix apijson.Field + RecordSuffix apijson.Field + RecordTemplate apijson.Field + SampleRate apijson.Field + TimestampFormat apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LogpushLogpushJobOutputOptions) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r logpushLogpushJobOutputOptionsJSON) RawJSON() string { + return r.raw +} + +// Specifies the output type, such as `ndjson` or `csv`. This sets default values +// for the rest of the settings, depending on the chosen output type. Some +// formatting rules, like string quoting, are different between output types. +type LogpushLogpushJobOutputOptionsOutputType string + +const ( + LogpushLogpushJobOutputOptionsOutputTypeNdjson LogpushLogpushJobOutputOptionsOutputType = "ndjson" + LogpushLogpushJobOutputOptionsOutputTypeCsv LogpushLogpushJobOutputOptionsOutputType = "csv" +) + +// String to specify the format for timestamps, such as `unixnano`, `unix`, or +// `rfc3339`. +type LogpushLogpushJobOutputOptionsTimestampFormat string + +const ( + LogpushLogpushJobOutputOptionsTimestampFormatUnixnano LogpushLogpushJobOutputOptionsTimestampFormat = "unixnano" + LogpushLogpushJobOutputOptionsTimestampFormatUnix LogpushLogpushJobOutputOptionsTimestampFormat = "unix" + LogpushLogpushJobOutputOptionsTimestampFormatRfc3339 LogpushLogpushJobOutputOptionsTimestampFormat = "rfc3339" +) + +type DatasetJobGetParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type DatasetJobGetResponseEnvelope struct { + Errors []DatasetJobGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DatasetJobGetResponseEnvelopeMessages `json:"messages,required"` + Result []LogpushLogpushJob `json:"result,required"` + // Whether the API call was successful + Success DatasetJobGetResponseEnvelopeSuccess `json:"success,required"` + JSON datasetJobGetResponseEnvelopeJSON `json:"-"` +} + +// datasetJobGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DatasetJobGetResponseEnvelope] +type datasetJobGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatasetJobGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r datasetJobGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DatasetJobGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON datasetJobGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// datasetJobGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DatasetJobGetResponseEnvelopeErrors] +type datasetJobGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatasetJobGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r datasetJobGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DatasetJobGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON datasetJobGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// datasetJobGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DatasetJobGetResponseEnvelopeMessages] +type datasetJobGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatasetJobGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r datasetJobGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DatasetJobGetResponseEnvelopeSuccess bool + +const ( + DatasetJobGetResponseEnvelopeSuccessTrue DatasetJobGetResponseEnvelopeSuccess = true +) diff --git a/logpush/datasetjob_test.go b/logpush/datasetjob_test.go new file mode 100644 index 00000000000..0895c298eb6 --- /dev/null +++ b/logpush/datasetjob_test.go @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package logpush_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/logpush" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestDatasetJobGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Logpush.Datasets.Jobs.Get( + context.TODO(), + "http_requests", + logpush.DatasetJobGetParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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/logpush/edge.go b/logpush/edge.go new file mode 100644 index 00000000000..4d9accb45e4 --- /dev/null +++ b/logpush/edge.go @@ -0,0 +1,275 @@ +// File generated from our OpenAPI spec by Stainless. + +package logpush + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// EdgeService 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 [NewEdgeService] method instead. +type EdgeService struct { + Options []option.RequestOption +} + +// NewEdgeService 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 NewEdgeService(opts ...option.RequestOption) (r *EdgeService) { + r = &EdgeService{} + r.Options = opts + return +} + +// Creates a new Instant Logs job for a zone. +func (r *EdgeService) New(ctx context.Context, params EdgeNewParams, opts ...option.RequestOption) (res *LogpushInstantLogsJob, err error) { + opts = append(r.Options[:], opts...) + var env EdgeNewResponseEnvelope + path := fmt.Sprintf("zones/%s/logpush/edge", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists Instant Logs jobs for a zone. +func (r *EdgeService) Get(ctx context.Context, query EdgeGetParams, opts ...option.RequestOption) (res *[]LogpushInstantLogsJob, err error) { + opts = append(r.Options[:], opts...) + var env EdgeGetResponseEnvelope + path := fmt.Sprintf("zones/%s/logpush/edge", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type LogpushInstantLogsJob struct { + // Unique WebSocket address that will receive messages from Cloudflare’s edge. + DestinationConf string `json:"destination_conf" format:"uri"` + // Comma-separated list of fields. + Fields string `json:"fields"` + // Filters to drill down into specific events. + Filter string `json:"filter"` + // The sample parameter is the sample rate of the records set by the client: + // "sample": 1 is 100% of records "sample": 10 is 10% and so on. + Sample int64 `json:"sample"` + // Unique session id of the job. + SessionID string `json:"session_id"` + JSON logpushInstantLogsJobJSON `json:"-"` +} + +// logpushInstantLogsJobJSON contains the JSON metadata for the struct +// [LogpushInstantLogsJob] +type logpushInstantLogsJobJSON struct { + DestinationConf apijson.Field + Fields apijson.Field + Filter apijson.Field + Sample apijson.Field + SessionID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LogpushInstantLogsJob) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r logpushInstantLogsJobJSON) RawJSON() string { + return r.raw +} + +type EdgeNewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Comma-separated list of fields. + Fields param.Field[string] `json:"fields"` + // Filters to drill down into specific events. + Filter param.Field[string] `json:"filter"` + // The sample parameter is the sample rate of the records set by the client: + // "sample": 1 is 100% of records "sample": 10 is 10% and so on. + Sample param.Field[int64] `json:"sample"` +} + +func (r EdgeNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type EdgeNewResponseEnvelope struct { + Errors []EdgeNewResponseEnvelopeErrors `json:"errors,required"` + Messages []EdgeNewResponseEnvelopeMessages `json:"messages,required"` + Result LogpushInstantLogsJob `json:"result,required,nullable"` + // Whether the API call was successful + Success EdgeNewResponseEnvelopeSuccess `json:"success,required"` + JSON edgeNewResponseEnvelopeJSON `json:"-"` +} + +// edgeNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [EdgeNewResponseEnvelope] +type edgeNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EdgeNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r edgeNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EdgeNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON edgeNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// edgeNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [EdgeNewResponseEnvelopeErrors] +type edgeNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EdgeNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r edgeNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type EdgeNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON edgeNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// edgeNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [EdgeNewResponseEnvelopeMessages] +type edgeNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EdgeNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r edgeNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type EdgeNewResponseEnvelopeSuccess bool + +const ( + EdgeNewResponseEnvelopeSuccessTrue EdgeNewResponseEnvelopeSuccess = true +) + +type EdgeGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type EdgeGetResponseEnvelope struct { + Errors []EdgeGetResponseEnvelopeErrors `json:"errors,required"` + Messages []EdgeGetResponseEnvelopeMessages `json:"messages,required"` + Result []LogpushInstantLogsJob `json:"result,required"` + // Whether the API call was successful + Success EdgeGetResponseEnvelopeSuccess `json:"success,required"` + JSON edgeGetResponseEnvelopeJSON `json:"-"` +} + +// edgeGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [EdgeGetResponseEnvelope] +type edgeGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EdgeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r edgeGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EdgeGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON edgeGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// edgeGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [EdgeGetResponseEnvelopeErrors] +type edgeGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EdgeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r edgeGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type EdgeGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON edgeGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// edgeGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [EdgeGetResponseEnvelopeMessages] +type edgeGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EdgeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r edgeGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type EdgeGetResponseEnvelopeSuccess bool + +const ( + EdgeGetResponseEnvelopeSuccessTrue EdgeGetResponseEnvelopeSuccess = true +) diff --git a/logpush/edge_test.go b/logpush/edge_test.go new file mode 100644 index 00000000000..e471ffc0947 --- /dev/null +++ b/logpush/edge_test.go @@ -0,0 +1,70 @@ +// File generated from our OpenAPI spec by Stainless. + +package logpush_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/logpush" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestEdgeNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Logpush.Edge.New(context.TODO(), logpush.EdgeNewParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Fields: cloudflare.F("ClientIP,ClientRequestHost,ClientRequestMethod,ClientRequestURI,EdgeEndTimestamp,EdgeResponseBytes,EdgeResponseStatus,EdgeStartTimestamp,RayID"), + Filter: cloudflare.F("{\"where\":{\"and\":[{\"key\":\"ClientCountry\",\"operator\":\"neq\",\"value\":\"ca\"}]}}"), + Sample: cloudflare.F(int64(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 TestEdgeGet(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("user@example.com"), + ) + _, err := client.Logpush.Edge.Get(context.TODO(), logpush.EdgeGetParams{ + ZoneID: cloudflare.F("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/logpush/job.go b/logpush/job.go new file mode 100644 index 00000000000..ccb5ac61294 --- /dev/null +++ b/logpush/job.go @@ -0,0 +1,811 @@ +// File generated from our OpenAPI spec by Stainless. + +package logpush + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// JobService 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 [NewJobService] method instead. +type JobService struct { + Options []option.RequestOption +} + +// NewJobService 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 NewJobService(opts ...option.RequestOption) (r *JobService) { + r = &JobService{} + r.Options = opts + return +} + +// Creates a new Logpush job for an account or zone. +func (r *JobService) New(ctx context.Context, params JobNewParams, opts ...option.RequestOption) (res *LogpushLogpushJob, err error) { + opts = append(r.Options[:], opts...) + var env JobNewResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/logpush/jobs", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a Logpush job. +func (r *JobService) Update(ctx context.Context, jobID int64, params JobUpdateParams, opts ...option.RequestOption) (res *LogpushLogpushJob, err error) { + opts = append(r.Options[:], opts...) + var env JobUpdateResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/logpush/jobs/%v", accountOrZone, accountOrZoneID, jobID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists Logpush jobs for an account or zone. +func (r *JobService) List(ctx context.Context, query JobListParams, opts ...option.RequestOption) (res *[]LogpushLogpushJob, err error) { + opts = append(r.Options[:], opts...) + var env JobListResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/logpush/jobs", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a Logpush job. +func (r *JobService) Delete(ctx context.Context, jobID int64, body JobDeleteParams, opts ...option.RequestOption) (res *JobDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env JobDeleteResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if body.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = body.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = body.ZoneID + } + path := fmt.Sprintf("%s/%s/logpush/jobs/%v", accountOrZone, accountOrZoneID, jobID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets the details of a Logpush job. +func (r *JobService) Get(ctx context.Context, jobID int64, query JobGetParams, opts ...option.RequestOption) (res *LogpushLogpushJob, err error) { + opts = append(r.Options[:], opts...) + var env JobGetResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/logpush/jobs/%v", accountOrZone, accountOrZoneID, jobID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [logpush.JobDeleteResponseUnknown], +// [logpush.JobDeleteResponseArray] or [shared.UnionString]. +type JobDeleteResponse interface { + ImplementsLogpushJobDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*JobDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(JobDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type JobDeleteResponseArray []interface{} + +func (r JobDeleteResponseArray) ImplementsLogpushJobDeleteResponse() {} + +type JobNewParams struct { + // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. + // Additional configuration parameters supported by the destination may be + // included. + DestinationConf param.Field[string] `json:"destination_conf,required" format:"uri"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // Name of the dataset. + Dataset param.Field[string] `json:"dataset"` + // Flag that indicates if the job is enabled. + Enabled param.Field[bool] `json:"enabled"` + // The frequency at which Cloudflare sends batches of logs to your destination. + // Setting frequency to high sends your logs in larger quantities of smaller files. + // Setting frequency to low sends logs in smaller quantities of larger files. + Frequency param.Field[JobNewParamsFrequency] `json:"frequency"` + // This field is deprecated. Use `output_options` instead. Configuration string. It + // specifies things like requested fields and timestamp formats. If migrating from + // the logpull api, copy the url (full url or just the query string) of your call + // here, and logpush will keep on making this call for you, setting start and end + // times appropriately. + LogpullOptions param.Field[string] `json:"logpull_options" format:"uri-reference"` + // Optional human readable job name. Not unique. Cloudflare suggests that you set + // this to a meaningful string, like the domain name, to make it easier to identify + // your job. + Name param.Field[string] `json:"name"` + // The structured replacement for `logpull_options`. When including this field, the + // `logpull_option` field will be ignored. + OutputOptions param.Field[JobNewParamsOutputOptions] `json:"output_options"` + // Ownership challenge token to prove destination ownership. + OwnershipChallenge param.Field[string] `json:"ownership_challenge"` +} + +func (r JobNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The frequency at which Cloudflare sends batches of logs to your destination. +// Setting frequency to high sends your logs in larger quantities of smaller files. +// Setting frequency to low sends logs in smaller quantities of larger files. +type JobNewParamsFrequency string + +const ( + JobNewParamsFrequencyHigh JobNewParamsFrequency = "high" + JobNewParamsFrequencyLow JobNewParamsFrequency = "low" +) + +// The structured replacement for `logpull_options`. When including this field, the +// `logpull_option` field will be ignored. +type JobNewParamsOutputOptions struct { + // String to be prepended before each batch. + BatchPrefix param.Field[string] `json:"batch_prefix"` + // String to be appended after each batch. + BatchSuffix param.Field[string] `json:"batch_suffix"` + // If set to true, will cause all occurrences of `${` in the generated files to be + // replaced with `x{`. + Cve2021_4428 param.Field[bool] `json:"CVE-2021-4428"` + // String to join fields. This field be ignored when `record_template` is set. + FieldDelimiter param.Field[string] `json:"field_delimiter"` + // List of field names to be included in the Logpush output. For the moment, there + // is no option to add all fields at once, so you must specify all the fields names + // you are interested in. + FieldNames param.Field[[]string] `json:"field_names"` + // Specifies the output type, such as `ndjson` or `csv`. This sets default values + // for the rest of the settings, depending on the chosen output type. Some + // formatting rules, like string quoting, are different between output types. + OutputType param.Field[JobNewParamsOutputOptionsOutputType] `json:"output_type"` + // String to be inserted in-between the records as separator. + RecordDelimiter param.Field[string] `json:"record_delimiter"` + // String to be prepended before each record. + RecordPrefix param.Field[string] `json:"record_prefix"` + // String to be appended after each record. + RecordSuffix param.Field[string] `json:"record_suffix"` + // String to use as template for each record instead of the default comma-separated + // list. All fields used in the template must be present in `field_names` as well, + // otherwise they will end up as null. Format as a Go `text/template` without any + // standard functions, like conditionals, loops, sub-templates, etc. + RecordTemplate param.Field[string] `json:"record_template"` + // Floating number to specify sampling rate. Sampling is applied on top of + // filtering, and regardless of the current `sample_interval` of the data. + SampleRate param.Field[float64] `json:"sample_rate"` + // String to specify the format for timestamps, such as `unixnano`, `unix`, or + // `rfc3339`. + TimestampFormat param.Field[JobNewParamsOutputOptionsTimestampFormat] `json:"timestamp_format"` +} + +func (r JobNewParamsOutputOptions) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Specifies the output type, such as `ndjson` or `csv`. This sets default values +// for the rest of the settings, depending on the chosen output type. Some +// formatting rules, like string quoting, are different between output types. +type JobNewParamsOutputOptionsOutputType string + +const ( + JobNewParamsOutputOptionsOutputTypeNdjson JobNewParamsOutputOptionsOutputType = "ndjson" + JobNewParamsOutputOptionsOutputTypeCsv JobNewParamsOutputOptionsOutputType = "csv" +) + +// String to specify the format for timestamps, such as `unixnano`, `unix`, or +// `rfc3339`. +type JobNewParamsOutputOptionsTimestampFormat string + +const ( + JobNewParamsOutputOptionsTimestampFormatUnixnano JobNewParamsOutputOptionsTimestampFormat = "unixnano" + JobNewParamsOutputOptionsTimestampFormatUnix JobNewParamsOutputOptionsTimestampFormat = "unix" + JobNewParamsOutputOptionsTimestampFormatRfc3339 JobNewParamsOutputOptionsTimestampFormat = "rfc3339" +) + +type JobNewResponseEnvelope struct { + Errors []JobNewResponseEnvelopeErrors `json:"errors,required"` + Messages []JobNewResponseEnvelopeMessages `json:"messages,required"` + Result LogpushLogpushJob `json:"result,required,nullable"` + // Whether the API call was successful + Success JobNewResponseEnvelopeSuccess `json:"success,required"` + JSON jobNewResponseEnvelopeJSON `json:"-"` +} + +// jobNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [JobNewResponseEnvelope] +type jobNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *JobNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r jobNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type JobNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON jobNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// jobNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [JobNewResponseEnvelopeErrors] +type jobNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *JobNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r jobNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type JobNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON jobNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// jobNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [JobNewResponseEnvelopeMessages] +type jobNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *JobNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r jobNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type JobNewResponseEnvelopeSuccess bool + +const ( + JobNewResponseEnvelopeSuccessTrue JobNewResponseEnvelopeSuccess = true +) + +type JobUpdateParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. + // Additional configuration parameters supported by the destination may be + // included. + DestinationConf param.Field[string] `json:"destination_conf" format:"uri"` + // Flag that indicates if the job is enabled. + Enabled param.Field[bool] `json:"enabled"` + // The frequency at which Cloudflare sends batches of logs to your destination. + // Setting frequency to high sends your logs in larger quantities of smaller files. + // Setting frequency to low sends logs in smaller quantities of larger files. + Frequency param.Field[JobUpdateParamsFrequency] `json:"frequency"` + // This field is deprecated. Use `output_options` instead. Configuration string. It + // specifies things like requested fields and timestamp formats. If migrating from + // the logpull api, copy the url (full url or just the query string) of your call + // here, and logpush will keep on making this call for you, setting start and end + // times appropriately. + LogpullOptions param.Field[string] `json:"logpull_options" format:"uri-reference"` + // The structured replacement for `logpull_options`. When including this field, the + // `logpull_option` field will be ignored. + OutputOptions param.Field[JobUpdateParamsOutputOptions] `json:"output_options"` + // Ownership challenge token to prove destination ownership. + OwnershipChallenge param.Field[string] `json:"ownership_challenge"` +} + +func (r JobUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The frequency at which Cloudflare sends batches of logs to your destination. +// Setting frequency to high sends your logs in larger quantities of smaller files. +// Setting frequency to low sends logs in smaller quantities of larger files. +type JobUpdateParamsFrequency string + +const ( + JobUpdateParamsFrequencyHigh JobUpdateParamsFrequency = "high" + JobUpdateParamsFrequencyLow JobUpdateParamsFrequency = "low" +) + +// The structured replacement for `logpull_options`. When including this field, the +// `logpull_option` field will be ignored. +type JobUpdateParamsOutputOptions struct { + // String to be prepended before each batch. + BatchPrefix param.Field[string] `json:"batch_prefix"` + // String to be appended after each batch. + BatchSuffix param.Field[string] `json:"batch_suffix"` + // If set to true, will cause all occurrences of `${` in the generated files to be + // replaced with `x{`. + Cve2021_4428 param.Field[bool] `json:"CVE-2021-4428"` + // String to join fields. This field be ignored when `record_template` is set. + FieldDelimiter param.Field[string] `json:"field_delimiter"` + // List of field names to be included in the Logpush output. For the moment, there + // is no option to add all fields at once, so you must specify all the fields names + // you are interested in. + FieldNames param.Field[[]string] `json:"field_names"` + // Specifies the output type, such as `ndjson` or `csv`. This sets default values + // for the rest of the settings, depending on the chosen output type. Some + // formatting rules, like string quoting, are different between output types. + OutputType param.Field[JobUpdateParamsOutputOptionsOutputType] `json:"output_type"` + // String to be inserted in-between the records as separator. + RecordDelimiter param.Field[string] `json:"record_delimiter"` + // String to be prepended before each record. + RecordPrefix param.Field[string] `json:"record_prefix"` + // String to be appended after each record. + RecordSuffix param.Field[string] `json:"record_suffix"` + // String to use as template for each record instead of the default comma-separated + // list. All fields used in the template must be present in `field_names` as well, + // otherwise they will end up as null. Format as a Go `text/template` without any + // standard functions, like conditionals, loops, sub-templates, etc. + RecordTemplate param.Field[string] `json:"record_template"` + // Floating number to specify sampling rate. Sampling is applied on top of + // filtering, and regardless of the current `sample_interval` of the data. + SampleRate param.Field[float64] `json:"sample_rate"` + // String to specify the format for timestamps, such as `unixnano`, `unix`, or + // `rfc3339`. + TimestampFormat param.Field[JobUpdateParamsOutputOptionsTimestampFormat] `json:"timestamp_format"` +} + +func (r JobUpdateParamsOutputOptions) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Specifies the output type, such as `ndjson` or `csv`. This sets default values +// for the rest of the settings, depending on the chosen output type. Some +// formatting rules, like string quoting, are different between output types. +type JobUpdateParamsOutputOptionsOutputType string + +const ( + JobUpdateParamsOutputOptionsOutputTypeNdjson JobUpdateParamsOutputOptionsOutputType = "ndjson" + JobUpdateParamsOutputOptionsOutputTypeCsv JobUpdateParamsOutputOptionsOutputType = "csv" +) + +// String to specify the format for timestamps, such as `unixnano`, `unix`, or +// `rfc3339`. +type JobUpdateParamsOutputOptionsTimestampFormat string + +const ( + JobUpdateParamsOutputOptionsTimestampFormatUnixnano JobUpdateParamsOutputOptionsTimestampFormat = "unixnano" + JobUpdateParamsOutputOptionsTimestampFormatUnix JobUpdateParamsOutputOptionsTimestampFormat = "unix" + JobUpdateParamsOutputOptionsTimestampFormatRfc3339 JobUpdateParamsOutputOptionsTimestampFormat = "rfc3339" +) + +type JobUpdateResponseEnvelope struct { + Errors []JobUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []JobUpdateResponseEnvelopeMessages `json:"messages,required"` + Result LogpushLogpushJob `json:"result,required,nullable"` + // Whether the API call was successful + Success JobUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON jobUpdateResponseEnvelopeJSON `json:"-"` +} + +// jobUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [JobUpdateResponseEnvelope] +type jobUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *JobUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r jobUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type JobUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON jobUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// jobUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [JobUpdateResponseEnvelopeErrors] +type jobUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *JobUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r jobUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type JobUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON jobUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// jobUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [JobUpdateResponseEnvelopeMessages] +type jobUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *JobUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r jobUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type JobUpdateResponseEnvelopeSuccess bool + +const ( + JobUpdateResponseEnvelopeSuccessTrue JobUpdateResponseEnvelopeSuccess = true +) + +type JobListParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type JobListResponseEnvelope struct { + Errors []JobListResponseEnvelopeErrors `json:"errors,required"` + Messages []JobListResponseEnvelopeMessages `json:"messages,required"` + Result []LogpushLogpushJob `json:"result,required"` + // Whether the API call was successful + Success JobListResponseEnvelopeSuccess `json:"success,required"` + JSON jobListResponseEnvelopeJSON `json:"-"` +} + +// jobListResponseEnvelopeJSON contains the JSON metadata for the struct +// [JobListResponseEnvelope] +type jobListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *JobListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r jobListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type JobListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON jobListResponseEnvelopeErrorsJSON `json:"-"` +} + +// jobListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [JobListResponseEnvelopeErrors] +type jobListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *JobListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r jobListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type JobListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON jobListResponseEnvelopeMessagesJSON `json:"-"` +} + +// jobListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [JobListResponseEnvelopeMessages] +type jobListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *JobListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r jobListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type JobListResponseEnvelopeSuccess bool + +const ( + JobListResponseEnvelopeSuccessTrue JobListResponseEnvelopeSuccess = true +) + +type JobDeleteParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type JobDeleteResponseEnvelope struct { + Errors []JobDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []JobDeleteResponseEnvelopeMessages `json:"messages,required"` + Result JobDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success JobDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON jobDeleteResponseEnvelopeJSON `json:"-"` +} + +// jobDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [JobDeleteResponseEnvelope] +type jobDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *JobDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r jobDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type JobDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON jobDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// jobDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [JobDeleteResponseEnvelopeErrors] +type jobDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *JobDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r jobDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type JobDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON jobDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// jobDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [JobDeleteResponseEnvelopeMessages] +type jobDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *JobDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r jobDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type JobDeleteResponseEnvelopeSuccess bool + +const ( + JobDeleteResponseEnvelopeSuccessTrue JobDeleteResponseEnvelopeSuccess = true +) + +type JobGetParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type JobGetResponseEnvelope struct { + Errors []JobGetResponseEnvelopeErrors `json:"errors,required"` + Messages []JobGetResponseEnvelopeMessages `json:"messages,required"` + Result LogpushLogpushJob `json:"result,required,nullable"` + // Whether the API call was successful + Success JobGetResponseEnvelopeSuccess `json:"success,required"` + JSON jobGetResponseEnvelopeJSON `json:"-"` +} + +// jobGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [JobGetResponseEnvelope] +type jobGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *JobGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r jobGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type JobGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON jobGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// jobGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [JobGetResponseEnvelopeErrors] +type jobGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *JobGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r jobGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type JobGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON jobGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// jobGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [JobGetResponseEnvelopeMessages] +type jobGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *JobGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r jobGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type JobGetResponseEnvelopeSuccess bool + +const ( + JobGetResponseEnvelopeSuccessTrue JobGetResponseEnvelopeSuccess = true +) diff --git a/logpush/job_test.go b/logpush/job_test.go new file mode 100644 index 00000000000..fb55d8972ee --- /dev/null +++ b/logpush/job_test.go @@ -0,0 +1,202 @@ +// File generated from our OpenAPI spec by Stainless. + +package logpush_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/logpush" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestJobNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Logpush.Jobs.New(context.TODO(), logpush.JobNewParams{ + DestinationConf: cloudflare.F("s3://mybucket/logs?region=us-west-2"), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + Dataset: cloudflare.F("http_requests"), + Enabled: cloudflare.F(false), + Frequency: cloudflare.F(logpush.JobNewParamsFrequencyHigh), + LogpullOptions: cloudflare.F("fields=RayID,ClientIP,EdgeStartTimestamp×tamps=rfc3339"), + Name: cloudflare.F("example.com"), + OutputOptions: cloudflare.F(logpush.JobNewParamsOutputOptions{ + Cve2021_4428: cloudflare.F(true), + BatchPrefix: cloudflare.F("string"), + BatchSuffix: cloudflare.F("string"), + FieldDelimiter: cloudflare.F("string"), + FieldNames: cloudflare.F([]string{"ClientIP", "EdgeStartTimestamp", "RayID"}), + OutputType: cloudflare.F(logpush.JobNewParamsOutputOptionsOutputTypeNdjson), + RecordDelimiter: cloudflare.F("string"), + RecordPrefix: cloudflare.F("string"), + RecordSuffix: cloudflare.F("string"), + RecordTemplate: cloudflare.F("string"), + SampleRate: cloudflare.F(0.000000), + TimestampFormat: cloudflare.F(logpush.JobNewParamsOutputOptionsTimestampFormatUnixnano), + }), + OwnershipChallenge: cloudflare.F("00000000000000000000"), + }) + 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 TestJobUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Logpush.Jobs.Update( + context.TODO(), + int64(1), + logpush.JobUpdateParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + DestinationConf: cloudflare.F("s3://mybucket/logs?region=us-west-2"), + Enabled: cloudflare.F(false), + Frequency: cloudflare.F(logpush.JobUpdateParamsFrequencyHigh), + LogpullOptions: cloudflare.F("fields=RayID,ClientIP,EdgeStartTimestamp×tamps=rfc3339"), + OutputOptions: cloudflare.F(logpush.JobUpdateParamsOutputOptions{ + Cve2021_4428: cloudflare.F(true), + BatchPrefix: cloudflare.F("string"), + BatchSuffix: cloudflare.F("string"), + FieldDelimiter: cloudflare.F("string"), + FieldNames: cloudflare.F([]string{"ClientIP", "EdgeStartTimestamp", "RayID"}), + OutputType: cloudflare.F(logpush.JobUpdateParamsOutputOptionsOutputTypeNdjson), + RecordDelimiter: cloudflare.F("string"), + RecordPrefix: cloudflare.F("string"), + RecordSuffix: cloudflare.F("string"), + RecordTemplate: cloudflare.F("string"), + SampleRate: cloudflare.F(0.000000), + TimestampFormat: cloudflare.F(logpush.JobUpdateParamsOutputOptionsTimestampFormatUnixnano), + }), + OwnershipChallenge: cloudflare.F("00000000000000000000"), + }, + ) + 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 TestJobListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Logpush.Jobs.List(context.TODO(), logpush.JobListParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }) + 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 TestJobDeleteWithOptionalParams(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("user@example.com"), + ) + _, err := client.Logpush.Jobs.Delete( + context.TODO(), + int64(1), + logpush.JobDeleteParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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 TestJobGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Logpush.Jobs.Get( + context.TODO(), + int64(1), + logpush.JobGetParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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/logpush/logpush.go b/logpush/logpush.go new file mode 100644 index 00000000000..b1d55a9957d --- /dev/null +++ b/logpush/logpush.go @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package logpush + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// LogpushService 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 [NewLogpushService] method instead. +type LogpushService struct { + Options []option.RequestOption + Datasets *DatasetService + Edge *EdgeService + Jobs *JobService + Ownership *OwnershipService + Validate *ValidateService +} + +// NewLogpushService 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 NewLogpushService(opts ...option.RequestOption) (r *LogpushService) { + r = &LogpushService{} + r.Options = opts + r.Datasets = NewDatasetService(opts...) + r.Edge = NewEdgeService(opts...) + r.Jobs = NewJobService(opts...) + r.Ownership = NewOwnershipService(opts...) + r.Validate = NewValidateService(opts...) + return +} diff --git a/logpush/ownership.go b/logpush/ownership.go new file mode 100644 index 00000000000..4754133aab7 --- /dev/null +++ b/logpush/ownership.go @@ -0,0 +1,315 @@ +// File generated from our OpenAPI spec by Stainless. + +package logpush + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// OwnershipService 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 [NewOwnershipService] method instead. +type OwnershipService struct { + Options []option.RequestOption +} + +// NewOwnershipService 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 NewOwnershipService(opts ...option.RequestOption) (r *OwnershipService) { + r = &OwnershipService{} + r.Options = opts + return +} + +// Gets a new ownership challenge sent to your destination. +func (r *OwnershipService) New(ctx context.Context, params OwnershipNewParams, opts ...option.RequestOption) (res *OwnershipNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env OwnershipNewResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/logpush/ownership", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Validates ownership challenge of the destination. +func (r *OwnershipService) Validate(ctx context.Context, params OwnershipValidateParams, opts ...option.RequestOption) (res *OwnershipValidateResponse, err error) { + opts = append(r.Options[:], opts...) + var env OwnershipValidateResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/logpush/ownership/validate", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type OwnershipNewResponse struct { + Filename string `json:"filename"` + Message string `json:"message"` + Valid bool `json:"valid"` + JSON ownershipNewResponseJSON `json:"-"` +} + +// ownershipNewResponseJSON contains the JSON metadata for the struct +// [OwnershipNewResponse] +type ownershipNewResponseJSON struct { + Filename apijson.Field + Message apijson.Field + Valid apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OwnershipNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ownershipNewResponseJSON) RawJSON() string { + return r.raw +} + +type OwnershipValidateResponse struct { + Valid bool `json:"valid"` + JSON ownershipValidateResponseJSON `json:"-"` +} + +// ownershipValidateResponseJSON contains the JSON metadata for the struct +// [OwnershipValidateResponse] +type ownershipValidateResponseJSON struct { + Valid apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OwnershipValidateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ownershipValidateResponseJSON) RawJSON() string { + return r.raw +} + +type OwnershipNewParams struct { + // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. + // Additional configuration parameters supported by the destination may be + // included. + DestinationConf param.Field[string] `json:"destination_conf,required" format:"uri"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +func (r OwnershipNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type OwnershipNewResponseEnvelope struct { + Errors []OwnershipNewResponseEnvelopeErrors `json:"errors,required"` + Messages []OwnershipNewResponseEnvelopeMessages `json:"messages,required"` + Result OwnershipNewResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success OwnershipNewResponseEnvelopeSuccess `json:"success,required"` + JSON ownershipNewResponseEnvelopeJSON `json:"-"` +} + +// ownershipNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [OwnershipNewResponseEnvelope] +type ownershipNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OwnershipNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ownershipNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type OwnershipNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ownershipNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// ownershipNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [OwnershipNewResponseEnvelopeErrors] +type ownershipNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OwnershipNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ownershipNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type OwnershipNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ownershipNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// ownershipNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [OwnershipNewResponseEnvelopeMessages] +type ownershipNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OwnershipNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ownershipNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type OwnershipNewResponseEnvelopeSuccess bool + +const ( + OwnershipNewResponseEnvelopeSuccessTrue OwnershipNewResponseEnvelopeSuccess = true +) + +type OwnershipValidateParams struct { + // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. + // Additional configuration parameters supported by the destination may be + // included. + DestinationConf param.Field[string] `json:"destination_conf,required" format:"uri"` + // Ownership challenge token to prove destination ownership. + OwnershipChallenge param.Field[string] `json:"ownership_challenge,required"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +func (r OwnershipValidateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type OwnershipValidateResponseEnvelope struct { + Errors []OwnershipValidateResponseEnvelopeErrors `json:"errors,required"` + Messages []OwnershipValidateResponseEnvelopeMessages `json:"messages,required"` + Result OwnershipValidateResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success OwnershipValidateResponseEnvelopeSuccess `json:"success,required"` + JSON ownershipValidateResponseEnvelopeJSON `json:"-"` +} + +// ownershipValidateResponseEnvelopeJSON contains the JSON metadata for the struct +// [OwnershipValidateResponseEnvelope] +type ownershipValidateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OwnershipValidateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ownershipValidateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type OwnershipValidateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ownershipValidateResponseEnvelopeErrorsJSON `json:"-"` +} + +// ownershipValidateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [OwnershipValidateResponseEnvelopeErrors] +type ownershipValidateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OwnershipValidateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ownershipValidateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type OwnershipValidateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ownershipValidateResponseEnvelopeMessagesJSON `json:"-"` +} + +// ownershipValidateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [OwnershipValidateResponseEnvelopeMessages] +type ownershipValidateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OwnershipValidateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ownershipValidateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type OwnershipValidateResponseEnvelopeSuccess bool + +const ( + OwnershipValidateResponseEnvelopeSuccessTrue OwnershipValidateResponseEnvelopeSuccess = true +) diff --git a/logpush/ownership_test.go b/logpush/ownership_test.go new file mode 100644 index 00000000000..36bcf0be51a --- /dev/null +++ b/logpush/ownership_test.go @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package logpush_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/logpush" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestOwnershipNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Logpush.Ownership.New(context.TODO(), logpush.OwnershipNewParams{ + DestinationConf: cloudflare.F("s3://mybucket/logs?region=us-west-2"), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }) + 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 TestOwnershipValidateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Logpush.Ownership.Validate(context.TODO(), logpush.OwnershipValidateParams{ + DestinationConf: cloudflare.F("s3://mybucket/logs?region=us-west-2"), + OwnershipChallenge: cloudflare.F("00000000000000000000"), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }) + 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/logpush/validate.go b/logpush/validate.go new file mode 100644 index 00000000000..1af55f1234a --- /dev/null +++ b/logpush/validate.go @@ -0,0 +1,313 @@ +// File generated from our OpenAPI spec by Stainless. + +package logpush + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ValidateService 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 [NewValidateService] method instead. +type ValidateService struct { + Options []option.RequestOption +} + +// NewValidateService 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 NewValidateService(opts ...option.RequestOption) (r *ValidateService) { + r = &ValidateService{} + r.Options = opts + return +} + +// Checks if there is an existing job with a destination. +func (r *ValidateService) Destination(ctx context.Context, params ValidateDestinationParams, opts ...option.RequestOption) (res *ValidateDestinationResponse, err error) { + opts = append(r.Options[:], opts...) + var env ValidateDestinationResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/logpush/validate/destination/exists", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Validates logpull origin with logpull_options. +func (r *ValidateService) Origin(ctx context.Context, params ValidateOriginParams, opts ...option.RequestOption) (res *ValidateOriginResponse, err error) { + opts = append(r.Options[:], opts...) + var env ValidateOriginResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/logpush/validate/origin", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ValidateDestinationResponse struct { + Exists bool `json:"exists"` + JSON validateDestinationResponseJSON `json:"-"` +} + +// validateDestinationResponseJSON contains the JSON metadata for the struct +// [ValidateDestinationResponse] +type validateDestinationResponseJSON struct { + Exists apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ValidateDestinationResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r validateDestinationResponseJSON) RawJSON() string { + return r.raw +} + +type ValidateOriginResponse struct { + Message string `json:"message"` + Valid bool `json:"valid"` + JSON validateOriginResponseJSON `json:"-"` +} + +// validateOriginResponseJSON contains the JSON metadata for the struct +// [ValidateOriginResponse] +type validateOriginResponseJSON struct { + Message apijson.Field + Valid apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ValidateOriginResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r validateOriginResponseJSON) RawJSON() string { + return r.raw +} + +type ValidateDestinationParams struct { + // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. + // Additional configuration parameters supported by the destination may be + // included. + DestinationConf param.Field[string] `json:"destination_conf,required" format:"uri"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +func (r ValidateDestinationParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ValidateDestinationResponseEnvelope struct { + Errors []ValidateDestinationResponseEnvelopeErrors `json:"errors,required"` + Messages []ValidateDestinationResponseEnvelopeMessages `json:"messages,required"` + Result ValidateDestinationResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ValidateDestinationResponseEnvelopeSuccess `json:"success,required"` + JSON validateDestinationResponseEnvelopeJSON `json:"-"` +} + +// validateDestinationResponseEnvelopeJSON contains the JSON metadata for the +// struct [ValidateDestinationResponseEnvelope] +type validateDestinationResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ValidateDestinationResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r validateDestinationResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ValidateDestinationResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON validateDestinationResponseEnvelopeErrorsJSON `json:"-"` +} + +// validateDestinationResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ValidateDestinationResponseEnvelopeErrors] +type validateDestinationResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ValidateDestinationResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r validateDestinationResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ValidateDestinationResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON validateDestinationResponseEnvelopeMessagesJSON `json:"-"` +} + +// validateDestinationResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [ValidateDestinationResponseEnvelopeMessages] +type validateDestinationResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ValidateDestinationResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r validateDestinationResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ValidateDestinationResponseEnvelopeSuccess bool + +const ( + ValidateDestinationResponseEnvelopeSuccessTrue ValidateDestinationResponseEnvelopeSuccess = true +) + +type ValidateOriginParams struct { + // This field is deprecated. Use `output_options` instead. Configuration string. It + // specifies things like requested fields and timestamp formats. If migrating from + // the logpull api, copy the url (full url or just the query string) of your call + // here, and logpush will keep on making this call for you, setting start and end + // times appropriately. + LogpullOptions param.Field[string] `json:"logpull_options,required" format:"uri-reference"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +func (r ValidateOriginParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ValidateOriginResponseEnvelope struct { + Errors []ValidateOriginResponseEnvelopeErrors `json:"errors,required"` + Messages []ValidateOriginResponseEnvelopeMessages `json:"messages,required"` + Result ValidateOriginResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ValidateOriginResponseEnvelopeSuccess `json:"success,required"` + JSON validateOriginResponseEnvelopeJSON `json:"-"` +} + +// validateOriginResponseEnvelopeJSON contains the JSON metadata for the struct +// [ValidateOriginResponseEnvelope] +type validateOriginResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ValidateOriginResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r validateOriginResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ValidateOriginResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON validateOriginResponseEnvelopeErrorsJSON `json:"-"` +} + +// validateOriginResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ValidateOriginResponseEnvelopeErrors] +type validateOriginResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ValidateOriginResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r validateOriginResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ValidateOriginResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON validateOriginResponseEnvelopeMessagesJSON `json:"-"` +} + +// validateOriginResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ValidateOriginResponseEnvelopeMessages] +type validateOriginResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ValidateOriginResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r validateOriginResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ValidateOriginResponseEnvelopeSuccess bool + +const ( + ValidateOriginResponseEnvelopeSuccessTrue ValidateOriginResponseEnvelopeSuccess = true +) diff --git a/logpush/validate_test.go b/logpush/validate_test.go new file mode 100644 index 00000000000..f915d3731c3 --- /dev/null +++ b/logpush/validate_test.go @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package logpush_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/logpush" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestValidateDestinationWithOptionalParams(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("user@example.com"), + ) + _, err := client.Logpush.Validate.Destination(context.TODO(), logpush.ValidateDestinationParams{ + DestinationConf: cloudflare.F("s3://mybucket/logs?region=us-west-2"), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }) + 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 TestValidateOriginWithOptionalParams(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("user@example.com"), + ) + _, err := client.Logpush.Validate.Origin(context.TODO(), logpush.ValidateOriginParams{ + LogpullOptions: cloudflare.F("fields=RayID,ClientIP,EdgeStartTimestamp×tamps=rfc3339"), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }) + 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/logpushdataset.go b/logpushdataset.go deleted file mode 100644 index ae7e3df0d20..00000000000 --- a/logpushdataset.go +++ /dev/null @@ -1,29 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// LogpushDatasetService 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 [NewLogpushDatasetService] method -// instead. -type LogpushDatasetService struct { - Options []option.RequestOption - Fields *LogpushDatasetFieldService - Jobs *LogpushDatasetJobService -} - -// NewLogpushDatasetService 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 NewLogpushDatasetService(opts ...option.RequestOption) (r *LogpushDatasetService) { - r = &LogpushDatasetService{} - r.Options = opts - r.Fields = NewLogpushDatasetFieldService(opts...) - r.Jobs = NewLogpushDatasetJobService(opts...) - return -} diff --git a/logpushdatasetfield.go b/logpushdatasetfield.go deleted file mode 100644 index cffe6d0f6a6..00000000000 --- a/logpushdatasetfield.go +++ /dev/null @@ -1,145 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// LogpushDatasetFieldService 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 [NewLogpushDatasetFieldService] -// method instead. -type LogpushDatasetFieldService struct { - Options []option.RequestOption -} - -// NewLogpushDatasetFieldService 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 NewLogpushDatasetFieldService(opts ...option.RequestOption) (r *LogpushDatasetFieldService) { - r = &LogpushDatasetFieldService{} - r.Options = opts - return -} - -// Lists all fields available for a dataset. The response result is an object with -// key-value pairs, where keys are field names, and values are descriptions. -func (r *LogpushDatasetFieldService) Get(ctx context.Context, datasetID string, query LogpushDatasetFieldGetParams, opts ...option.RequestOption) (res *LogpushDatasetFieldGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env LogpushDatasetFieldGetResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/logpush/datasets/%s/fields", accountOrZone, accountOrZoneID, datasetID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LogpushDatasetFieldGetResponse = interface{} - -type LogpushDatasetFieldGetParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type LogpushDatasetFieldGetResponseEnvelope struct { - Errors []LogpushDatasetFieldGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LogpushDatasetFieldGetResponseEnvelopeMessages `json:"messages,required"` - Result LogpushDatasetFieldGetResponse `json:"result,required"` - // Whether the API call was successful - Success LogpushDatasetFieldGetResponseEnvelopeSuccess `json:"success,required"` - JSON logpushDatasetFieldGetResponseEnvelopeJSON `json:"-"` -} - -// logpushDatasetFieldGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [LogpushDatasetFieldGetResponseEnvelope] -type logpushDatasetFieldGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushDatasetFieldGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushDatasetFieldGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LogpushDatasetFieldGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushDatasetFieldGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// logpushDatasetFieldGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LogpushDatasetFieldGetResponseEnvelopeErrors] -type logpushDatasetFieldGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushDatasetFieldGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushDatasetFieldGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LogpushDatasetFieldGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushDatasetFieldGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// logpushDatasetFieldGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LogpushDatasetFieldGetResponseEnvelopeMessages] -type logpushDatasetFieldGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushDatasetFieldGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushDatasetFieldGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LogpushDatasetFieldGetResponseEnvelopeSuccess bool - -const ( - LogpushDatasetFieldGetResponseEnvelopeSuccessTrue LogpushDatasetFieldGetResponseEnvelopeSuccess = true -) diff --git a/logpushdatasetfield_test.go b/logpushdatasetfield_test.go deleted file mode 100644 index 7b2c42af024..00000000000 --- a/logpushdatasetfield_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLogpushDatasetFieldGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Logpush.Datasets.Fields.Get( - context.TODO(), - "http_requests", - cloudflare.LogpushDatasetFieldGetParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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/logpushdatasetjob.go b/logpushdatasetjob.go deleted file mode 100644 index f1fb1ecc5ef..00000000000 --- a/logpushdatasetjob.go +++ /dev/null @@ -1,311 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// LogpushDatasetJobService 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 [NewLogpushDatasetJobService] method -// instead. -type LogpushDatasetJobService struct { - Options []option.RequestOption -} - -// NewLogpushDatasetJobService 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 NewLogpushDatasetJobService(opts ...option.RequestOption) (r *LogpushDatasetJobService) { - r = &LogpushDatasetJobService{} - r.Options = opts - return -} - -// Lists Logpush jobs for an account or zone for a dataset. -func (r *LogpushDatasetJobService) Get(ctx context.Context, datasetID string, query LogpushDatasetJobGetParams, opts ...option.RequestOption) (res *[]LogpushDatasetJobGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env LogpushDatasetJobGetResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/logpush/datasets/%s/jobs", accountOrZone, accountOrZoneID, datasetID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LogpushDatasetJobGetResponse struct { - // Unique id of the job. - ID int64 `json:"id"` - // Name of the dataset. - Dataset string `json:"dataset,nullable"` - // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. - // Additional configuration parameters supported by the destination may be - // included. - DestinationConf string `json:"destination_conf" format:"uri"` - // Flag that indicates if the job is enabled. - Enabled bool `json:"enabled"` - // If not null, the job is currently failing. Failures are usually repetitive - // (example: no permissions to write to destination bucket). Only the last failure - // is recorded. On successful execution of a job the error_message and last_error - // are set to null. - ErrorMessage time.Time `json:"error_message,nullable" format:"date-time"` - // The frequency at which Cloudflare sends batches of logs to your destination. - // Setting frequency to high sends your logs in larger quantities of smaller files. - // Setting frequency to low sends logs in smaller quantities of larger files. - Frequency LogpushDatasetJobGetResponseFrequency `json:"frequency,nullable"` - // Records the last time for which logs have been successfully pushed. If the last - // successful push was for logs range 2018-07-23T10:00:00Z to 2018-07-23T10:01:00Z - // then the value of this field will be 2018-07-23T10:01:00Z. If the job has never - // run or has just been enabled and hasn't run yet then the field will be empty. - LastComplete time.Time `json:"last_complete,nullable" format:"date-time"` - // Records the last time the job failed. If not null, the job is currently failing. - // If null, the job has either never failed or has run successfully at least once - // since last failure. See also the error_message field. - LastError time.Time `json:"last_error,nullable" format:"date-time"` - // This field is deprecated. Use `output_options` instead. Configuration string. It - // specifies things like requested fields and timestamp formats. If migrating from - // the logpull api, copy the url (full url or just the query string) of your call - // here, and logpush will keep on making this call for you, setting start and end - // times appropriately. - LogpullOptions string `json:"logpull_options,nullable" format:"uri-reference"` - // Optional human readable job name. Not unique. Cloudflare suggests that you set - // this to a meaningful string, like the domain name, to make it easier to identify - // your job. - Name string `json:"name,nullable"` - // The structured replacement for `logpull_options`. When including this field, the - // `logpull_option` field will be ignored. - OutputOptions LogpushDatasetJobGetResponseOutputOptions `json:"output_options,nullable"` - JSON logpushDatasetJobGetResponseJSON `json:"-"` -} - -// logpushDatasetJobGetResponseJSON contains the JSON metadata for the struct -// [LogpushDatasetJobGetResponse] -type logpushDatasetJobGetResponseJSON struct { - ID apijson.Field - Dataset apijson.Field - DestinationConf apijson.Field - Enabled apijson.Field - ErrorMessage apijson.Field - Frequency apijson.Field - LastComplete apijson.Field - LastError apijson.Field - LogpullOptions apijson.Field - Name apijson.Field - OutputOptions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushDatasetJobGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushDatasetJobGetResponseJSON) RawJSON() string { - return r.raw -} - -// The frequency at which Cloudflare sends batches of logs to your destination. -// Setting frequency to high sends your logs in larger quantities of smaller files. -// Setting frequency to low sends logs in smaller quantities of larger files. -type LogpushDatasetJobGetResponseFrequency string - -const ( - LogpushDatasetJobGetResponseFrequencyHigh LogpushDatasetJobGetResponseFrequency = "high" - LogpushDatasetJobGetResponseFrequencyLow LogpushDatasetJobGetResponseFrequency = "low" -) - -// The structured replacement for `logpull_options`. When including this field, the -// `logpull_option` field will be ignored. -type LogpushDatasetJobGetResponseOutputOptions struct { - // String to be prepended before each batch. - BatchPrefix string `json:"batch_prefix,nullable"` - // String to be appended after each batch. - BatchSuffix string `json:"batch_suffix,nullable"` - // If set to true, will cause all occurrences of `${` in the generated files to be - // replaced with `x{`. - Cve2021_4428 bool `json:"CVE-2021-4428,nullable"` - // String to join fields. This field be ignored when `record_template` is set. - FieldDelimiter string `json:"field_delimiter,nullable"` - // List of field names to be included in the Logpush output. For the moment, there - // is no option to add all fields at once, so you must specify all the fields names - // you are interested in. - FieldNames []string `json:"field_names"` - // Specifies the output type, such as `ndjson` or `csv`. This sets default values - // for the rest of the settings, depending on the chosen output type. Some - // formatting rules, like string quoting, are different between output types. - OutputType LogpushDatasetJobGetResponseOutputOptionsOutputType `json:"output_type"` - // String to be inserted in-between the records as separator. - RecordDelimiter string `json:"record_delimiter,nullable"` - // String to be prepended before each record. - RecordPrefix string `json:"record_prefix,nullable"` - // String to be appended after each record. - RecordSuffix string `json:"record_suffix,nullable"` - // String to use as template for each record instead of the default comma-separated - // list. All fields used in the template must be present in `field_names` as well, - // otherwise they will end up as null. Format as a Go `text/template` without any - // standard functions, like conditionals, loops, sub-templates, etc. - RecordTemplate string `json:"record_template,nullable"` - // Floating number to specify sampling rate. Sampling is applied on top of - // filtering, and regardless of the current `sample_interval` of the data. - SampleRate float64 `json:"sample_rate,nullable"` - // String to specify the format for timestamps, such as `unixnano`, `unix`, or - // `rfc3339`. - TimestampFormat LogpushDatasetJobGetResponseOutputOptionsTimestampFormat `json:"timestamp_format"` - JSON logpushDatasetJobGetResponseOutputOptionsJSON `json:"-"` -} - -// logpushDatasetJobGetResponseOutputOptionsJSON contains the JSON metadata for the -// struct [LogpushDatasetJobGetResponseOutputOptions] -type logpushDatasetJobGetResponseOutputOptionsJSON struct { - BatchPrefix apijson.Field - BatchSuffix apijson.Field - Cve2021_4428 apijson.Field - FieldDelimiter apijson.Field - FieldNames apijson.Field - OutputType apijson.Field - RecordDelimiter apijson.Field - RecordPrefix apijson.Field - RecordSuffix apijson.Field - RecordTemplate apijson.Field - SampleRate apijson.Field - TimestampFormat apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushDatasetJobGetResponseOutputOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushDatasetJobGetResponseOutputOptionsJSON) RawJSON() string { - return r.raw -} - -// Specifies the output type, such as `ndjson` or `csv`. This sets default values -// for the rest of the settings, depending on the chosen output type. Some -// formatting rules, like string quoting, are different between output types. -type LogpushDatasetJobGetResponseOutputOptionsOutputType string - -const ( - LogpushDatasetJobGetResponseOutputOptionsOutputTypeNdjson LogpushDatasetJobGetResponseOutputOptionsOutputType = "ndjson" - LogpushDatasetJobGetResponseOutputOptionsOutputTypeCsv LogpushDatasetJobGetResponseOutputOptionsOutputType = "csv" -) - -// String to specify the format for timestamps, such as `unixnano`, `unix`, or -// `rfc3339`. -type LogpushDatasetJobGetResponseOutputOptionsTimestampFormat string - -const ( - LogpushDatasetJobGetResponseOutputOptionsTimestampFormatUnixnano LogpushDatasetJobGetResponseOutputOptionsTimestampFormat = "unixnano" - LogpushDatasetJobGetResponseOutputOptionsTimestampFormatUnix LogpushDatasetJobGetResponseOutputOptionsTimestampFormat = "unix" - LogpushDatasetJobGetResponseOutputOptionsTimestampFormatRfc3339 LogpushDatasetJobGetResponseOutputOptionsTimestampFormat = "rfc3339" -) - -type LogpushDatasetJobGetParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type LogpushDatasetJobGetResponseEnvelope struct { - Errors []LogpushDatasetJobGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LogpushDatasetJobGetResponseEnvelopeMessages `json:"messages,required"` - Result []LogpushDatasetJobGetResponse `json:"result,required"` - // Whether the API call was successful - Success LogpushDatasetJobGetResponseEnvelopeSuccess `json:"success,required"` - JSON logpushDatasetJobGetResponseEnvelopeJSON `json:"-"` -} - -// logpushDatasetJobGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [LogpushDatasetJobGetResponseEnvelope] -type logpushDatasetJobGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushDatasetJobGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushDatasetJobGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LogpushDatasetJobGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushDatasetJobGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// logpushDatasetJobGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LogpushDatasetJobGetResponseEnvelopeErrors] -type logpushDatasetJobGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushDatasetJobGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushDatasetJobGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LogpushDatasetJobGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushDatasetJobGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// logpushDatasetJobGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [LogpushDatasetJobGetResponseEnvelopeMessages] -type logpushDatasetJobGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushDatasetJobGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushDatasetJobGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LogpushDatasetJobGetResponseEnvelopeSuccess bool - -const ( - LogpushDatasetJobGetResponseEnvelopeSuccessTrue LogpushDatasetJobGetResponseEnvelopeSuccess = true -) diff --git a/logpushdatasetjob_test.go b/logpushdatasetjob_test.go deleted file mode 100644 index 8440ef98bfc..00000000000 --- a/logpushdatasetjob_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLogpushDatasetJobGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Logpush.Datasets.Jobs.Get( - context.TODO(), - "http_requests", - cloudflare.LogpushDatasetJobGetParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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/logpushedge.go b/logpushedge.go deleted file mode 100644 index 637194eeae7..00000000000 --- a/logpushedge.go +++ /dev/null @@ -1,311 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// LogpushEdgeService 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 [NewLogpushEdgeService] method -// instead. -type LogpushEdgeService struct { - Options []option.RequestOption -} - -// NewLogpushEdgeService 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 NewLogpushEdgeService(opts ...option.RequestOption) (r *LogpushEdgeService) { - r = &LogpushEdgeService{} - r.Options = opts - return -} - -// Creates a new Instant Logs job for a zone. -func (r *LogpushEdgeService) New(ctx context.Context, params LogpushEdgeNewParams, opts ...option.RequestOption) (res *LogpushEdgeNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env LogpushEdgeNewResponseEnvelope - path := fmt.Sprintf("zones/%s/logpush/edge", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists Instant Logs jobs for a zone. -func (r *LogpushEdgeService) Get(ctx context.Context, query LogpushEdgeGetParams, opts ...option.RequestOption) (res *[]LogpushEdgeGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env LogpushEdgeGetResponseEnvelope - path := fmt.Sprintf("zones/%s/logpush/edge", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LogpushEdgeNewResponse struct { - // Unique WebSocket address that will receive messages from Cloudflare’s edge. - DestinationConf string `json:"destination_conf" format:"uri"` - // Comma-separated list of fields. - Fields string `json:"fields"` - // Filters to drill down into specific events. - Filter string `json:"filter"` - // The sample parameter is the sample rate of the records set by the client: - // "sample": 1 is 100% of records "sample": 10 is 10% and so on. - Sample int64 `json:"sample"` - // Unique session id of the job. - SessionID string `json:"session_id"` - JSON logpushEdgeNewResponseJSON `json:"-"` -} - -// logpushEdgeNewResponseJSON contains the JSON metadata for the struct -// [LogpushEdgeNewResponse] -type logpushEdgeNewResponseJSON struct { - DestinationConf apijson.Field - Fields apijson.Field - Filter apijson.Field - Sample apijson.Field - SessionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushEdgeNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushEdgeNewResponseJSON) RawJSON() string { - return r.raw -} - -type LogpushEdgeGetResponse struct { - // Unique WebSocket address that will receive messages from Cloudflare’s edge. - DestinationConf string `json:"destination_conf" format:"uri"` - // Comma-separated list of fields. - Fields string `json:"fields"` - // Filters to drill down into specific events. - Filter string `json:"filter"` - // The sample parameter is the sample rate of the records set by the client: - // "sample": 1 is 100% of records "sample": 10 is 10% and so on. - Sample int64 `json:"sample"` - // Unique session id of the job. - SessionID string `json:"session_id"` - JSON logpushEdgeGetResponseJSON `json:"-"` -} - -// logpushEdgeGetResponseJSON contains the JSON metadata for the struct -// [LogpushEdgeGetResponse] -type logpushEdgeGetResponseJSON struct { - DestinationConf apijson.Field - Fields apijson.Field - Filter apijson.Field - Sample apijson.Field - SessionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushEdgeGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushEdgeGetResponseJSON) RawJSON() string { - return r.raw -} - -type LogpushEdgeNewParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Comma-separated list of fields. - Fields param.Field[string] `json:"fields"` - // Filters to drill down into specific events. - Filter param.Field[string] `json:"filter"` - // The sample parameter is the sample rate of the records set by the client: - // "sample": 1 is 100% of records "sample": 10 is 10% and so on. - Sample param.Field[int64] `json:"sample"` -} - -func (r LogpushEdgeNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type LogpushEdgeNewResponseEnvelope struct { - Errors []LogpushEdgeNewResponseEnvelopeErrors `json:"errors,required"` - Messages []LogpushEdgeNewResponseEnvelopeMessages `json:"messages,required"` - Result LogpushEdgeNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LogpushEdgeNewResponseEnvelopeSuccess `json:"success,required"` - JSON logpushEdgeNewResponseEnvelopeJSON `json:"-"` -} - -// logpushEdgeNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [LogpushEdgeNewResponseEnvelope] -type logpushEdgeNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushEdgeNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushEdgeNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LogpushEdgeNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushEdgeNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// logpushEdgeNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LogpushEdgeNewResponseEnvelopeErrors] -type logpushEdgeNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushEdgeNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushEdgeNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LogpushEdgeNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushEdgeNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// logpushEdgeNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LogpushEdgeNewResponseEnvelopeMessages] -type logpushEdgeNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushEdgeNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushEdgeNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LogpushEdgeNewResponseEnvelopeSuccess bool - -const ( - LogpushEdgeNewResponseEnvelopeSuccessTrue LogpushEdgeNewResponseEnvelopeSuccess = true -) - -type LogpushEdgeGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type LogpushEdgeGetResponseEnvelope struct { - Errors []LogpushEdgeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LogpushEdgeGetResponseEnvelopeMessages `json:"messages,required"` - Result []LogpushEdgeGetResponse `json:"result,required"` - // Whether the API call was successful - Success LogpushEdgeGetResponseEnvelopeSuccess `json:"success,required"` - JSON logpushEdgeGetResponseEnvelopeJSON `json:"-"` -} - -// logpushEdgeGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [LogpushEdgeGetResponseEnvelope] -type logpushEdgeGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushEdgeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushEdgeGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LogpushEdgeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushEdgeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// logpushEdgeGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LogpushEdgeGetResponseEnvelopeErrors] -type logpushEdgeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushEdgeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushEdgeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LogpushEdgeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushEdgeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// logpushEdgeGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LogpushEdgeGetResponseEnvelopeMessages] -type logpushEdgeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushEdgeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushEdgeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LogpushEdgeGetResponseEnvelopeSuccess bool - -const ( - LogpushEdgeGetResponseEnvelopeSuccessTrue LogpushEdgeGetResponseEnvelopeSuccess = true -) diff --git a/logpushedge_test.go b/logpushedge_test.go deleted file mode 100644 index 7b2e83ee907..00000000000 --- a/logpushedge_test.go +++ /dev/null @@ -1,69 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLogpushEdgeNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Logpush.Edge.New(context.TODO(), cloudflare.LogpushEdgeNewParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Fields: cloudflare.F("ClientIP,ClientRequestHost,ClientRequestMethod,ClientRequestURI,EdgeEndTimestamp,EdgeResponseBytes,EdgeResponseStatus,EdgeStartTimestamp,RayID"), - Filter: cloudflare.F("{\"where\":{\"and\":[{\"key\":\"ClientCountry\",\"operator\":\"neq\",\"value\":\"ca\"}]}}"), - Sample: cloudflare.F(int64(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 TestLogpushEdgeGet(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("user@example.com"), - ) - _, err := client.Logpush.Edge.Get(context.TODO(), cloudflare.LogpushEdgeGetParams{ - ZoneID: cloudflare.F("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/logpushjob.go b/logpushjob.go deleted file mode 100644 index 5bf3588dbf5..00000000000 --- a/logpushjob.go +++ /dev/null @@ -1,1484 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// LogpushJobService 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 [NewLogpushJobService] method instead. -type LogpushJobService struct { - Options []option.RequestOption -} - -// NewLogpushJobService 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 NewLogpushJobService(opts ...option.RequestOption) (r *LogpushJobService) { - r = &LogpushJobService{} - r.Options = opts - return -} - -// Creates a new Logpush job for an account or zone. -func (r *LogpushJobService) New(ctx context.Context, params LogpushJobNewParams, opts ...option.RequestOption) (res *LogpushJobNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env LogpushJobNewResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/logpush/jobs", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a Logpush job. -func (r *LogpushJobService) Update(ctx context.Context, jobID int64, params LogpushJobUpdateParams, opts ...option.RequestOption) (res *LogpushJobUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env LogpushJobUpdateResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/logpush/jobs/%v", accountOrZone, accountOrZoneID, jobID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists Logpush jobs for an account or zone. -func (r *LogpushJobService) List(ctx context.Context, query LogpushJobListParams, opts ...option.RequestOption) (res *[]LogpushJobListResponse, err error) { - opts = append(r.Options[:], opts...) - var env LogpushJobListResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/logpush/jobs", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a Logpush job. -func (r *LogpushJobService) Delete(ctx context.Context, jobID int64, body LogpushJobDeleteParams, opts ...option.RequestOption) (res *LogpushJobDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env LogpushJobDeleteResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if body.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = body.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = body.ZoneID - } - path := fmt.Sprintf("%s/%s/logpush/jobs/%v", accountOrZone, accountOrZoneID, jobID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets the details of a Logpush job. -func (r *LogpushJobService) Get(ctx context.Context, jobID int64, query LogpushJobGetParams, opts ...option.RequestOption) (res *LogpushJobGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env LogpushJobGetResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/logpush/jobs/%v", accountOrZone, accountOrZoneID, jobID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LogpushJobNewResponse struct { - // Unique id of the job. - ID int64 `json:"id"` - // Name of the dataset. - Dataset string `json:"dataset,nullable"` - // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. - // Additional configuration parameters supported by the destination may be - // included. - DestinationConf string `json:"destination_conf" format:"uri"` - // Flag that indicates if the job is enabled. - Enabled bool `json:"enabled"` - // If not null, the job is currently failing. Failures are usually repetitive - // (example: no permissions to write to destination bucket). Only the last failure - // is recorded. On successful execution of a job the error_message and last_error - // are set to null. - ErrorMessage time.Time `json:"error_message,nullable" format:"date-time"` - // The frequency at which Cloudflare sends batches of logs to your destination. - // Setting frequency to high sends your logs in larger quantities of smaller files. - // Setting frequency to low sends logs in smaller quantities of larger files. - Frequency LogpushJobNewResponseFrequency `json:"frequency,nullable"` - // Records the last time for which logs have been successfully pushed. If the last - // successful push was for logs range 2018-07-23T10:00:00Z to 2018-07-23T10:01:00Z - // then the value of this field will be 2018-07-23T10:01:00Z. If the job has never - // run or has just been enabled and hasn't run yet then the field will be empty. - LastComplete time.Time `json:"last_complete,nullable" format:"date-time"` - // Records the last time the job failed. If not null, the job is currently failing. - // If null, the job has either never failed or has run successfully at least once - // since last failure. See also the error_message field. - LastError time.Time `json:"last_error,nullable" format:"date-time"` - // This field is deprecated. Use `output_options` instead. Configuration string. It - // specifies things like requested fields and timestamp formats. If migrating from - // the logpull api, copy the url (full url or just the query string) of your call - // here, and logpush will keep on making this call for you, setting start and end - // times appropriately. - LogpullOptions string `json:"logpull_options,nullable" format:"uri-reference"` - // Optional human readable job name. Not unique. Cloudflare suggests that you set - // this to a meaningful string, like the domain name, to make it easier to identify - // your job. - Name string `json:"name,nullable"` - // The structured replacement for `logpull_options`. When including this field, the - // `logpull_option` field will be ignored. - OutputOptions LogpushJobNewResponseOutputOptions `json:"output_options,nullable"` - JSON logpushJobNewResponseJSON `json:"-"` -} - -// logpushJobNewResponseJSON contains the JSON metadata for the struct -// [LogpushJobNewResponse] -type logpushJobNewResponseJSON struct { - ID apijson.Field - Dataset apijson.Field - DestinationConf apijson.Field - Enabled apijson.Field - ErrorMessage apijson.Field - Frequency apijson.Field - LastComplete apijson.Field - LastError apijson.Field - LogpullOptions apijson.Field - Name apijson.Field - OutputOptions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobNewResponseJSON) RawJSON() string { - return r.raw -} - -// The frequency at which Cloudflare sends batches of logs to your destination. -// Setting frequency to high sends your logs in larger quantities of smaller files. -// Setting frequency to low sends logs in smaller quantities of larger files. -type LogpushJobNewResponseFrequency string - -const ( - LogpushJobNewResponseFrequencyHigh LogpushJobNewResponseFrequency = "high" - LogpushJobNewResponseFrequencyLow LogpushJobNewResponseFrequency = "low" -) - -// The structured replacement for `logpull_options`. When including this field, the -// `logpull_option` field will be ignored. -type LogpushJobNewResponseOutputOptions struct { - // String to be prepended before each batch. - BatchPrefix string `json:"batch_prefix,nullable"` - // String to be appended after each batch. - BatchSuffix string `json:"batch_suffix,nullable"` - // If set to true, will cause all occurrences of `${` in the generated files to be - // replaced with `x{`. - Cve2021_4428 bool `json:"CVE-2021-4428,nullable"` - // String to join fields. This field be ignored when `record_template` is set. - FieldDelimiter string `json:"field_delimiter,nullable"` - // List of field names to be included in the Logpush output. For the moment, there - // is no option to add all fields at once, so you must specify all the fields names - // you are interested in. - FieldNames []string `json:"field_names"` - // Specifies the output type, such as `ndjson` or `csv`. This sets default values - // for the rest of the settings, depending on the chosen output type. Some - // formatting rules, like string quoting, are different between output types. - OutputType LogpushJobNewResponseOutputOptionsOutputType `json:"output_type"` - // String to be inserted in-between the records as separator. - RecordDelimiter string `json:"record_delimiter,nullable"` - // String to be prepended before each record. - RecordPrefix string `json:"record_prefix,nullable"` - // String to be appended after each record. - RecordSuffix string `json:"record_suffix,nullable"` - // String to use as template for each record instead of the default comma-separated - // list. All fields used in the template must be present in `field_names` as well, - // otherwise they will end up as null. Format as a Go `text/template` without any - // standard functions, like conditionals, loops, sub-templates, etc. - RecordTemplate string `json:"record_template,nullable"` - // Floating number to specify sampling rate. Sampling is applied on top of - // filtering, and regardless of the current `sample_interval` of the data. - SampleRate float64 `json:"sample_rate,nullable"` - // String to specify the format for timestamps, such as `unixnano`, `unix`, or - // `rfc3339`. - TimestampFormat LogpushJobNewResponseOutputOptionsTimestampFormat `json:"timestamp_format"` - JSON logpushJobNewResponseOutputOptionsJSON `json:"-"` -} - -// logpushJobNewResponseOutputOptionsJSON contains the JSON metadata for the struct -// [LogpushJobNewResponseOutputOptions] -type logpushJobNewResponseOutputOptionsJSON struct { - BatchPrefix apijson.Field - BatchSuffix apijson.Field - Cve2021_4428 apijson.Field - FieldDelimiter apijson.Field - FieldNames apijson.Field - OutputType apijson.Field - RecordDelimiter apijson.Field - RecordPrefix apijson.Field - RecordSuffix apijson.Field - RecordTemplate apijson.Field - SampleRate apijson.Field - TimestampFormat apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobNewResponseOutputOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobNewResponseOutputOptionsJSON) RawJSON() string { - return r.raw -} - -// Specifies the output type, such as `ndjson` or `csv`. This sets default values -// for the rest of the settings, depending on the chosen output type. Some -// formatting rules, like string quoting, are different between output types. -type LogpushJobNewResponseOutputOptionsOutputType string - -const ( - LogpushJobNewResponseOutputOptionsOutputTypeNdjson LogpushJobNewResponseOutputOptionsOutputType = "ndjson" - LogpushJobNewResponseOutputOptionsOutputTypeCsv LogpushJobNewResponseOutputOptionsOutputType = "csv" -) - -// String to specify the format for timestamps, such as `unixnano`, `unix`, or -// `rfc3339`. -type LogpushJobNewResponseOutputOptionsTimestampFormat string - -const ( - LogpushJobNewResponseOutputOptionsTimestampFormatUnixnano LogpushJobNewResponseOutputOptionsTimestampFormat = "unixnano" - LogpushJobNewResponseOutputOptionsTimestampFormatUnix LogpushJobNewResponseOutputOptionsTimestampFormat = "unix" - LogpushJobNewResponseOutputOptionsTimestampFormatRfc3339 LogpushJobNewResponseOutputOptionsTimestampFormat = "rfc3339" -) - -type LogpushJobUpdateResponse struct { - // Unique id of the job. - ID int64 `json:"id"` - // Name of the dataset. - Dataset string `json:"dataset,nullable"` - // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. - // Additional configuration parameters supported by the destination may be - // included. - DestinationConf string `json:"destination_conf" format:"uri"` - // Flag that indicates if the job is enabled. - Enabled bool `json:"enabled"` - // If not null, the job is currently failing. Failures are usually repetitive - // (example: no permissions to write to destination bucket). Only the last failure - // is recorded. On successful execution of a job the error_message and last_error - // are set to null. - ErrorMessage time.Time `json:"error_message,nullable" format:"date-time"` - // The frequency at which Cloudflare sends batches of logs to your destination. - // Setting frequency to high sends your logs in larger quantities of smaller files. - // Setting frequency to low sends logs in smaller quantities of larger files. - Frequency LogpushJobUpdateResponseFrequency `json:"frequency,nullable"` - // Records the last time for which logs have been successfully pushed. If the last - // successful push was for logs range 2018-07-23T10:00:00Z to 2018-07-23T10:01:00Z - // then the value of this field will be 2018-07-23T10:01:00Z. If the job has never - // run or has just been enabled and hasn't run yet then the field will be empty. - LastComplete time.Time `json:"last_complete,nullable" format:"date-time"` - // Records the last time the job failed. If not null, the job is currently failing. - // If null, the job has either never failed or has run successfully at least once - // since last failure. See also the error_message field. - LastError time.Time `json:"last_error,nullable" format:"date-time"` - // This field is deprecated. Use `output_options` instead. Configuration string. It - // specifies things like requested fields and timestamp formats. If migrating from - // the logpull api, copy the url (full url or just the query string) of your call - // here, and logpush will keep on making this call for you, setting start and end - // times appropriately. - LogpullOptions string `json:"logpull_options,nullable" format:"uri-reference"` - // Optional human readable job name. Not unique. Cloudflare suggests that you set - // this to a meaningful string, like the domain name, to make it easier to identify - // your job. - Name string `json:"name,nullable"` - // The structured replacement for `logpull_options`. When including this field, the - // `logpull_option` field will be ignored. - OutputOptions LogpushJobUpdateResponseOutputOptions `json:"output_options,nullable"` - JSON logpushJobUpdateResponseJSON `json:"-"` -} - -// logpushJobUpdateResponseJSON contains the JSON metadata for the struct -// [LogpushJobUpdateResponse] -type logpushJobUpdateResponseJSON struct { - ID apijson.Field - Dataset apijson.Field - DestinationConf apijson.Field - Enabled apijson.Field - ErrorMessage apijson.Field - Frequency apijson.Field - LastComplete apijson.Field - LastError apijson.Field - LogpullOptions apijson.Field - Name apijson.Field - OutputOptions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// The frequency at which Cloudflare sends batches of logs to your destination. -// Setting frequency to high sends your logs in larger quantities of smaller files. -// Setting frequency to low sends logs in smaller quantities of larger files. -type LogpushJobUpdateResponseFrequency string - -const ( - LogpushJobUpdateResponseFrequencyHigh LogpushJobUpdateResponseFrequency = "high" - LogpushJobUpdateResponseFrequencyLow LogpushJobUpdateResponseFrequency = "low" -) - -// The structured replacement for `logpull_options`. When including this field, the -// `logpull_option` field will be ignored. -type LogpushJobUpdateResponseOutputOptions struct { - // String to be prepended before each batch. - BatchPrefix string `json:"batch_prefix,nullable"` - // String to be appended after each batch. - BatchSuffix string `json:"batch_suffix,nullable"` - // If set to true, will cause all occurrences of `${` in the generated files to be - // replaced with `x{`. - Cve2021_4428 bool `json:"CVE-2021-4428,nullable"` - // String to join fields. This field be ignored when `record_template` is set. - FieldDelimiter string `json:"field_delimiter,nullable"` - // List of field names to be included in the Logpush output. For the moment, there - // is no option to add all fields at once, so you must specify all the fields names - // you are interested in. - FieldNames []string `json:"field_names"` - // Specifies the output type, such as `ndjson` or `csv`. This sets default values - // for the rest of the settings, depending on the chosen output type. Some - // formatting rules, like string quoting, are different between output types. - OutputType LogpushJobUpdateResponseOutputOptionsOutputType `json:"output_type"` - // String to be inserted in-between the records as separator. - RecordDelimiter string `json:"record_delimiter,nullable"` - // String to be prepended before each record. - RecordPrefix string `json:"record_prefix,nullable"` - // String to be appended after each record. - RecordSuffix string `json:"record_suffix,nullable"` - // String to use as template for each record instead of the default comma-separated - // list. All fields used in the template must be present in `field_names` as well, - // otherwise they will end up as null. Format as a Go `text/template` without any - // standard functions, like conditionals, loops, sub-templates, etc. - RecordTemplate string `json:"record_template,nullable"` - // Floating number to specify sampling rate. Sampling is applied on top of - // filtering, and regardless of the current `sample_interval` of the data. - SampleRate float64 `json:"sample_rate,nullable"` - // String to specify the format for timestamps, such as `unixnano`, `unix`, or - // `rfc3339`. - TimestampFormat LogpushJobUpdateResponseOutputOptionsTimestampFormat `json:"timestamp_format"` - JSON logpushJobUpdateResponseOutputOptionsJSON `json:"-"` -} - -// logpushJobUpdateResponseOutputOptionsJSON contains the JSON metadata for the -// struct [LogpushJobUpdateResponseOutputOptions] -type logpushJobUpdateResponseOutputOptionsJSON struct { - BatchPrefix apijson.Field - BatchSuffix apijson.Field - Cve2021_4428 apijson.Field - FieldDelimiter apijson.Field - FieldNames apijson.Field - OutputType apijson.Field - RecordDelimiter apijson.Field - RecordPrefix apijson.Field - RecordSuffix apijson.Field - RecordTemplate apijson.Field - SampleRate apijson.Field - TimestampFormat apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobUpdateResponseOutputOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobUpdateResponseOutputOptionsJSON) RawJSON() string { - return r.raw -} - -// Specifies the output type, such as `ndjson` or `csv`. This sets default values -// for the rest of the settings, depending on the chosen output type. Some -// formatting rules, like string quoting, are different between output types. -type LogpushJobUpdateResponseOutputOptionsOutputType string - -const ( - LogpushJobUpdateResponseOutputOptionsOutputTypeNdjson LogpushJobUpdateResponseOutputOptionsOutputType = "ndjson" - LogpushJobUpdateResponseOutputOptionsOutputTypeCsv LogpushJobUpdateResponseOutputOptionsOutputType = "csv" -) - -// String to specify the format for timestamps, such as `unixnano`, `unix`, or -// `rfc3339`. -type LogpushJobUpdateResponseOutputOptionsTimestampFormat string - -const ( - LogpushJobUpdateResponseOutputOptionsTimestampFormatUnixnano LogpushJobUpdateResponseOutputOptionsTimestampFormat = "unixnano" - LogpushJobUpdateResponseOutputOptionsTimestampFormatUnix LogpushJobUpdateResponseOutputOptionsTimestampFormat = "unix" - LogpushJobUpdateResponseOutputOptionsTimestampFormatRfc3339 LogpushJobUpdateResponseOutputOptionsTimestampFormat = "rfc3339" -) - -type LogpushJobListResponse struct { - // Unique id of the job. - ID int64 `json:"id"` - // Name of the dataset. - Dataset string `json:"dataset,nullable"` - // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. - // Additional configuration parameters supported by the destination may be - // included. - DestinationConf string `json:"destination_conf" format:"uri"` - // Flag that indicates if the job is enabled. - Enabled bool `json:"enabled"` - // If not null, the job is currently failing. Failures are usually repetitive - // (example: no permissions to write to destination bucket). Only the last failure - // is recorded. On successful execution of a job the error_message and last_error - // are set to null. - ErrorMessage time.Time `json:"error_message,nullable" format:"date-time"` - // The frequency at which Cloudflare sends batches of logs to your destination. - // Setting frequency to high sends your logs in larger quantities of smaller files. - // Setting frequency to low sends logs in smaller quantities of larger files. - Frequency LogpushJobListResponseFrequency `json:"frequency,nullable"` - // Records the last time for which logs have been successfully pushed. If the last - // successful push was for logs range 2018-07-23T10:00:00Z to 2018-07-23T10:01:00Z - // then the value of this field will be 2018-07-23T10:01:00Z. If the job has never - // run or has just been enabled and hasn't run yet then the field will be empty. - LastComplete time.Time `json:"last_complete,nullable" format:"date-time"` - // Records the last time the job failed. If not null, the job is currently failing. - // If null, the job has either never failed or has run successfully at least once - // since last failure. See also the error_message field. - LastError time.Time `json:"last_error,nullable" format:"date-time"` - // This field is deprecated. Use `output_options` instead. Configuration string. It - // specifies things like requested fields and timestamp formats. If migrating from - // the logpull api, copy the url (full url or just the query string) of your call - // here, and logpush will keep on making this call for you, setting start and end - // times appropriately. - LogpullOptions string `json:"logpull_options,nullable" format:"uri-reference"` - // Optional human readable job name. Not unique. Cloudflare suggests that you set - // this to a meaningful string, like the domain name, to make it easier to identify - // your job. - Name string `json:"name,nullable"` - // The structured replacement for `logpull_options`. When including this field, the - // `logpull_option` field will be ignored. - OutputOptions LogpushJobListResponseOutputOptions `json:"output_options,nullable"` - JSON logpushJobListResponseJSON `json:"-"` -} - -// logpushJobListResponseJSON contains the JSON metadata for the struct -// [LogpushJobListResponse] -type logpushJobListResponseJSON struct { - ID apijson.Field - Dataset apijson.Field - DestinationConf apijson.Field - Enabled apijson.Field - ErrorMessage apijson.Field - Frequency apijson.Field - LastComplete apijson.Field - LastError apijson.Field - LogpullOptions apijson.Field - Name apijson.Field - OutputOptions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobListResponseJSON) RawJSON() string { - return r.raw -} - -// The frequency at which Cloudflare sends batches of logs to your destination. -// Setting frequency to high sends your logs in larger quantities of smaller files. -// Setting frequency to low sends logs in smaller quantities of larger files. -type LogpushJobListResponseFrequency string - -const ( - LogpushJobListResponseFrequencyHigh LogpushJobListResponseFrequency = "high" - LogpushJobListResponseFrequencyLow LogpushJobListResponseFrequency = "low" -) - -// The structured replacement for `logpull_options`. When including this field, the -// `logpull_option` field will be ignored. -type LogpushJobListResponseOutputOptions struct { - // String to be prepended before each batch. - BatchPrefix string `json:"batch_prefix,nullable"` - // String to be appended after each batch. - BatchSuffix string `json:"batch_suffix,nullable"` - // If set to true, will cause all occurrences of `${` in the generated files to be - // replaced with `x{`. - Cve2021_4428 bool `json:"CVE-2021-4428,nullable"` - // String to join fields. This field be ignored when `record_template` is set. - FieldDelimiter string `json:"field_delimiter,nullable"` - // List of field names to be included in the Logpush output. For the moment, there - // is no option to add all fields at once, so you must specify all the fields names - // you are interested in. - FieldNames []string `json:"field_names"` - // Specifies the output type, such as `ndjson` or `csv`. This sets default values - // for the rest of the settings, depending on the chosen output type. Some - // formatting rules, like string quoting, are different between output types. - OutputType LogpushJobListResponseOutputOptionsOutputType `json:"output_type"` - // String to be inserted in-between the records as separator. - RecordDelimiter string `json:"record_delimiter,nullable"` - // String to be prepended before each record. - RecordPrefix string `json:"record_prefix,nullable"` - // String to be appended after each record. - RecordSuffix string `json:"record_suffix,nullable"` - // String to use as template for each record instead of the default comma-separated - // list. All fields used in the template must be present in `field_names` as well, - // otherwise they will end up as null. Format as a Go `text/template` without any - // standard functions, like conditionals, loops, sub-templates, etc. - RecordTemplate string `json:"record_template,nullable"` - // Floating number to specify sampling rate. Sampling is applied on top of - // filtering, and regardless of the current `sample_interval` of the data. - SampleRate float64 `json:"sample_rate,nullable"` - // String to specify the format for timestamps, such as `unixnano`, `unix`, or - // `rfc3339`. - TimestampFormat LogpushJobListResponseOutputOptionsTimestampFormat `json:"timestamp_format"` - JSON logpushJobListResponseOutputOptionsJSON `json:"-"` -} - -// logpushJobListResponseOutputOptionsJSON contains the JSON metadata for the -// struct [LogpushJobListResponseOutputOptions] -type logpushJobListResponseOutputOptionsJSON struct { - BatchPrefix apijson.Field - BatchSuffix apijson.Field - Cve2021_4428 apijson.Field - FieldDelimiter apijson.Field - FieldNames apijson.Field - OutputType apijson.Field - RecordDelimiter apijson.Field - RecordPrefix apijson.Field - RecordSuffix apijson.Field - RecordTemplate apijson.Field - SampleRate apijson.Field - TimestampFormat apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobListResponseOutputOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobListResponseOutputOptionsJSON) RawJSON() string { - return r.raw -} - -// Specifies the output type, such as `ndjson` or `csv`. This sets default values -// for the rest of the settings, depending on the chosen output type. Some -// formatting rules, like string quoting, are different between output types. -type LogpushJobListResponseOutputOptionsOutputType string - -const ( - LogpushJobListResponseOutputOptionsOutputTypeNdjson LogpushJobListResponseOutputOptionsOutputType = "ndjson" - LogpushJobListResponseOutputOptionsOutputTypeCsv LogpushJobListResponseOutputOptionsOutputType = "csv" -) - -// String to specify the format for timestamps, such as `unixnano`, `unix`, or -// `rfc3339`. -type LogpushJobListResponseOutputOptionsTimestampFormat string - -const ( - LogpushJobListResponseOutputOptionsTimestampFormatUnixnano LogpushJobListResponseOutputOptionsTimestampFormat = "unixnano" - LogpushJobListResponseOutputOptionsTimestampFormatUnix LogpushJobListResponseOutputOptionsTimestampFormat = "unix" - LogpushJobListResponseOutputOptionsTimestampFormatRfc3339 LogpushJobListResponseOutputOptionsTimestampFormat = "rfc3339" -) - -// Union satisfied by [LogpushJobDeleteResponseUnknown], -// [LogpushJobDeleteResponseArray] or [shared.UnionString]. -type LogpushJobDeleteResponse interface { - ImplementsLogpushJobDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*LogpushJobDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(LogpushJobDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type LogpushJobDeleteResponseArray []interface{} - -func (r LogpushJobDeleteResponseArray) ImplementsLogpushJobDeleteResponse() {} - -type LogpushJobGetResponse struct { - // Unique id of the job. - ID int64 `json:"id"` - // Name of the dataset. - Dataset string `json:"dataset,nullable"` - // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. - // Additional configuration parameters supported by the destination may be - // included. - DestinationConf string `json:"destination_conf" format:"uri"` - // Flag that indicates if the job is enabled. - Enabled bool `json:"enabled"` - // If not null, the job is currently failing. Failures are usually repetitive - // (example: no permissions to write to destination bucket). Only the last failure - // is recorded. On successful execution of a job the error_message and last_error - // are set to null. - ErrorMessage time.Time `json:"error_message,nullable" format:"date-time"` - // The frequency at which Cloudflare sends batches of logs to your destination. - // Setting frequency to high sends your logs in larger quantities of smaller files. - // Setting frequency to low sends logs in smaller quantities of larger files. - Frequency LogpushJobGetResponseFrequency `json:"frequency,nullable"` - // Records the last time for which logs have been successfully pushed. If the last - // successful push was for logs range 2018-07-23T10:00:00Z to 2018-07-23T10:01:00Z - // then the value of this field will be 2018-07-23T10:01:00Z. If the job has never - // run or has just been enabled and hasn't run yet then the field will be empty. - LastComplete time.Time `json:"last_complete,nullable" format:"date-time"` - // Records the last time the job failed. If not null, the job is currently failing. - // If null, the job has either never failed or has run successfully at least once - // since last failure. See also the error_message field. - LastError time.Time `json:"last_error,nullable" format:"date-time"` - // This field is deprecated. Use `output_options` instead. Configuration string. It - // specifies things like requested fields and timestamp formats. If migrating from - // the logpull api, copy the url (full url or just the query string) of your call - // here, and logpush will keep on making this call for you, setting start and end - // times appropriately. - LogpullOptions string `json:"logpull_options,nullable" format:"uri-reference"` - // Optional human readable job name. Not unique. Cloudflare suggests that you set - // this to a meaningful string, like the domain name, to make it easier to identify - // your job. - Name string `json:"name,nullable"` - // The structured replacement for `logpull_options`. When including this field, the - // `logpull_option` field will be ignored. - OutputOptions LogpushJobGetResponseOutputOptions `json:"output_options,nullable"` - JSON logpushJobGetResponseJSON `json:"-"` -} - -// logpushJobGetResponseJSON contains the JSON metadata for the struct -// [LogpushJobGetResponse] -type logpushJobGetResponseJSON struct { - ID apijson.Field - Dataset apijson.Field - DestinationConf apijson.Field - Enabled apijson.Field - ErrorMessage apijson.Field - Frequency apijson.Field - LastComplete apijson.Field - LastError apijson.Field - LogpullOptions apijson.Field - Name apijson.Field - OutputOptions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobGetResponseJSON) RawJSON() string { - return r.raw -} - -// The frequency at which Cloudflare sends batches of logs to your destination. -// Setting frequency to high sends your logs in larger quantities of smaller files. -// Setting frequency to low sends logs in smaller quantities of larger files. -type LogpushJobGetResponseFrequency string - -const ( - LogpushJobGetResponseFrequencyHigh LogpushJobGetResponseFrequency = "high" - LogpushJobGetResponseFrequencyLow LogpushJobGetResponseFrequency = "low" -) - -// The structured replacement for `logpull_options`. When including this field, the -// `logpull_option` field will be ignored. -type LogpushJobGetResponseOutputOptions struct { - // String to be prepended before each batch. - BatchPrefix string `json:"batch_prefix,nullable"` - // String to be appended after each batch. - BatchSuffix string `json:"batch_suffix,nullable"` - // If set to true, will cause all occurrences of `${` in the generated files to be - // replaced with `x{`. - Cve2021_4428 bool `json:"CVE-2021-4428,nullable"` - // String to join fields. This field be ignored when `record_template` is set. - FieldDelimiter string `json:"field_delimiter,nullable"` - // List of field names to be included in the Logpush output. For the moment, there - // is no option to add all fields at once, so you must specify all the fields names - // you are interested in. - FieldNames []string `json:"field_names"` - // Specifies the output type, such as `ndjson` or `csv`. This sets default values - // for the rest of the settings, depending on the chosen output type. Some - // formatting rules, like string quoting, are different between output types. - OutputType LogpushJobGetResponseOutputOptionsOutputType `json:"output_type"` - // String to be inserted in-between the records as separator. - RecordDelimiter string `json:"record_delimiter,nullable"` - // String to be prepended before each record. - RecordPrefix string `json:"record_prefix,nullable"` - // String to be appended after each record. - RecordSuffix string `json:"record_suffix,nullable"` - // String to use as template for each record instead of the default comma-separated - // list. All fields used in the template must be present in `field_names` as well, - // otherwise they will end up as null. Format as a Go `text/template` without any - // standard functions, like conditionals, loops, sub-templates, etc. - RecordTemplate string `json:"record_template,nullable"` - // Floating number to specify sampling rate. Sampling is applied on top of - // filtering, and regardless of the current `sample_interval` of the data. - SampleRate float64 `json:"sample_rate,nullable"` - // String to specify the format for timestamps, such as `unixnano`, `unix`, or - // `rfc3339`. - TimestampFormat LogpushJobGetResponseOutputOptionsTimestampFormat `json:"timestamp_format"` - JSON logpushJobGetResponseOutputOptionsJSON `json:"-"` -} - -// logpushJobGetResponseOutputOptionsJSON contains the JSON metadata for the struct -// [LogpushJobGetResponseOutputOptions] -type logpushJobGetResponseOutputOptionsJSON struct { - BatchPrefix apijson.Field - BatchSuffix apijson.Field - Cve2021_4428 apijson.Field - FieldDelimiter apijson.Field - FieldNames apijson.Field - OutputType apijson.Field - RecordDelimiter apijson.Field - RecordPrefix apijson.Field - RecordSuffix apijson.Field - RecordTemplate apijson.Field - SampleRate apijson.Field - TimestampFormat apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobGetResponseOutputOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobGetResponseOutputOptionsJSON) RawJSON() string { - return r.raw -} - -// Specifies the output type, such as `ndjson` or `csv`. This sets default values -// for the rest of the settings, depending on the chosen output type. Some -// formatting rules, like string quoting, are different between output types. -type LogpushJobGetResponseOutputOptionsOutputType string - -const ( - LogpushJobGetResponseOutputOptionsOutputTypeNdjson LogpushJobGetResponseOutputOptionsOutputType = "ndjson" - LogpushJobGetResponseOutputOptionsOutputTypeCsv LogpushJobGetResponseOutputOptionsOutputType = "csv" -) - -// String to specify the format for timestamps, such as `unixnano`, `unix`, or -// `rfc3339`. -type LogpushJobGetResponseOutputOptionsTimestampFormat string - -const ( - LogpushJobGetResponseOutputOptionsTimestampFormatUnixnano LogpushJobGetResponseOutputOptionsTimestampFormat = "unixnano" - LogpushJobGetResponseOutputOptionsTimestampFormatUnix LogpushJobGetResponseOutputOptionsTimestampFormat = "unix" - LogpushJobGetResponseOutputOptionsTimestampFormatRfc3339 LogpushJobGetResponseOutputOptionsTimestampFormat = "rfc3339" -) - -type LogpushJobNewParams struct { - // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. - // Additional configuration parameters supported by the destination may be - // included. - DestinationConf param.Field[string] `json:"destination_conf,required" format:"uri"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // Name of the dataset. - Dataset param.Field[string] `json:"dataset"` - // Flag that indicates if the job is enabled. - Enabled param.Field[bool] `json:"enabled"` - // The frequency at which Cloudflare sends batches of logs to your destination. - // Setting frequency to high sends your logs in larger quantities of smaller files. - // Setting frequency to low sends logs in smaller quantities of larger files. - Frequency param.Field[LogpushJobNewParamsFrequency] `json:"frequency"` - // This field is deprecated. Use `output_options` instead. Configuration string. It - // specifies things like requested fields and timestamp formats. If migrating from - // the logpull api, copy the url (full url or just the query string) of your call - // here, and logpush will keep on making this call for you, setting start and end - // times appropriately. - LogpullOptions param.Field[string] `json:"logpull_options" format:"uri-reference"` - // Optional human readable job name. Not unique. Cloudflare suggests that you set - // this to a meaningful string, like the domain name, to make it easier to identify - // your job. - Name param.Field[string] `json:"name"` - // The structured replacement for `logpull_options`. When including this field, the - // `logpull_option` field will be ignored. - OutputOptions param.Field[LogpushJobNewParamsOutputOptions] `json:"output_options"` - // Ownership challenge token to prove destination ownership. - OwnershipChallenge param.Field[string] `json:"ownership_challenge"` -} - -func (r LogpushJobNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The frequency at which Cloudflare sends batches of logs to your destination. -// Setting frequency to high sends your logs in larger quantities of smaller files. -// Setting frequency to low sends logs in smaller quantities of larger files. -type LogpushJobNewParamsFrequency string - -const ( - LogpushJobNewParamsFrequencyHigh LogpushJobNewParamsFrequency = "high" - LogpushJobNewParamsFrequencyLow LogpushJobNewParamsFrequency = "low" -) - -// The structured replacement for `logpull_options`. When including this field, the -// `logpull_option` field will be ignored. -type LogpushJobNewParamsOutputOptions struct { - // String to be prepended before each batch. - BatchPrefix param.Field[string] `json:"batch_prefix"` - // String to be appended after each batch. - BatchSuffix param.Field[string] `json:"batch_suffix"` - // If set to true, will cause all occurrences of `${` in the generated files to be - // replaced with `x{`. - Cve2021_4428 param.Field[bool] `json:"CVE-2021-4428"` - // String to join fields. This field be ignored when `record_template` is set. - FieldDelimiter param.Field[string] `json:"field_delimiter"` - // List of field names to be included in the Logpush output. For the moment, there - // is no option to add all fields at once, so you must specify all the fields names - // you are interested in. - FieldNames param.Field[[]string] `json:"field_names"` - // Specifies the output type, such as `ndjson` or `csv`. This sets default values - // for the rest of the settings, depending on the chosen output type. Some - // formatting rules, like string quoting, are different between output types. - OutputType param.Field[LogpushJobNewParamsOutputOptionsOutputType] `json:"output_type"` - // String to be inserted in-between the records as separator. - RecordDelimiter param.Field[string] `json:"record_delimiter"` - // String to be prepended before each record. - RecordPrefix param.Field[string] `json:"record_prefix"` - // String to be appended after each record. - RecordSuffix param.Field[string] `json:"record_suffix"` - // String to use as template for each record instead of the default comma-separated - // list. All fields used in the template must be present in `field_names` as well, - // otherwise they will end up as null. Format as a Go `text/template` without any - // standard functions, like conditionals, loops, sub-templates, etc. - RecordTemplate param.Field[string] `json:"record_template"` - // Floating number to specify sampling rate. Sampling is applied on top of - // filtering, and regardless of the current `sample_interval` of the data. - SampleRate param.Field[float64] `json:"sample_rate"` - // String to specify the format for timestamps, such as `unixnano`, `unix`, or - // `rfc3339`. - TimestampFormat param.Field[LogpushJobNewParamsOutputOptionsTimestampFormat] `json:"timestamp_format"` -} - -func (r LogpushJobNewParamsOutputOptions) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Specifies the output type, such as `ndjson` or `csv`. This sets default values -// for the rest of the settings, depending on the chosen output type. Some -// formatting rules, like string quoting, are different between output types. -type LogpushJobNewParamsOutputOptionsOutputType string - -const ( - LogpushJobNewParamsOutputOptionsOutputTypeNdjson LogpushJobNewParamsOutputOptionsOutputType = "ndjson" - LogpushJobNewParamsOutputOptionsOutputTypeCsv LogpushJobNewParamsOutputOptionsOutputType = "csv" -) - -// String to specify the format for timestamps, such as `unixnano`, `unix`, or -// `rfc3339`. -type LogpushJobNewParamsOutputOptionsTimestampFormat string - -const ( - LogpushJobNewParamsOutputOptionsTimestampFormatUnixnano LogpushJobNewParamsOutputOptionsTimestampFormat = "unixnano" - LogpushJobNewParamsOutputOptionsTimestampFormatUnix LogpushJobNewParamsOutputOptionsTimestampFormat = "unix" - LogpushJobNewParamsOutputOptionsTimestampFormatRfc3339 LogpushJobNewParamsOutputOptionsTimestampFormat = "rfc3339" -) - -type LogpushJobNewResponseEnvelope struct { - Errors []LogpushJobNewResponseEnvelopeErrors `json:"errors,required"` - Messages []LogpushJobNewResponseEnvelopeMessages `json:"messages,required"` - Result LogpushJobNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LogpushJobNewResponseEnvelopeSuccess `json:"success,required"` - JSON logpushJobNewResponseEnvelopeJSON `json:"-"` -} - -// logpushJobNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [LogpushJobNewResponseEnvelope] -type logpushJobNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LogpushJobNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushJobNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// logpushJobNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LogpushJobNewResponseEnvelopeErrors] -type logpushJobNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LogpushJobNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushJobNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// logpushJobNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LogpushJobNewResponseEnvelopeMessages] -type logpushJobNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LogpushJobNewResponseEnvelopeSuccess bool - -const ( - LogpushJobNewResponseEnvelopeSuccessTrue LogpushJobNewResponseEnvelopeSuccess = true -) - -type LogpushJobUpdateParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. - // Additional configuration parameters supported by the destination may be - // included. - DestinationConf param.Field[string] `json:"destination_conf" format:"uri"` - // Flag that indicates if the job is enabled. - Enabled param.Field[bool] `json:"enabled"` - // The frequency at which Cloudflare sends batches of logs to your destination. - // Setting frequency to high sends your logs in larger quantities of smaller files. - // Setting frequency to low sends logs in smaller quantities of larger files. - Frequency param.Field[LogpushJobUpdateParamsFrequency] `json:"frequency"` - // This field is deprecated. Use `output_options` instead. Configuration string. It - // specifies things like requested fields and timestamp formats. If migrating from - // the logpull api, copy the url (full url or just the query string) of your call - // here, and logpush will keep on making this call for you, setting start and end - // times appropriately. - LogpullOptions param.Field[string] `json:"logpull_options" format:"uri-reference"` - // The structured replacement for `logpull_options`. When including this field, the - // `logpull_option` field will be ignored. - OutputOptions param.Field[LogpushJobUpdateParamsOutputOptions] `json:"output_options"` - // Ownership challenge token to prove destination ownership. - OwnershipChallenge param.Field[string] `json:"ownership_challenge"` -} - -func (r LogpushJobUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The frequency at which Cloudflare sends batches of logs to your destination. -// Setting frequency to high sends your logs in larger quantities of smaller files. -// Setting frequency to low sends logs in smaller quantities of larger files. -type LogpushJobUpdateParamsFrequency string - -const ( - LogpushJobUpdateParamsFrequencyHigh LogpushJobUpdateParamsFrequency = "high" - LogpushJobUpdateParamsFrequencyLow LogpushJobUpdateParamsFrequency = "low" -) - -// The structured replacement for `logpull_options`. When including this field, the -// `logpull_option` field will be ignored. -type LogpushJobUpdateParamsOutputOptions struct { - // String to be prepended before each batch. - BatchPrefix param.Field[string] `json:"batch_prefix"` - // String to be appended after each batch. - BatchSuffix param.Field[string] `json:"batch_suffix"` - // If set to true, will cause all occurrences of `${` in the generated files to be - // replaced with `x{`. - Cve2021_4428 param.Field[bool] `json:"CVE-2021-4428"` - // String to join fields. This field be ignored when `record_template` is set. - FieldDelimiter param.Field[string] `json:"field_delimiter"` - // List of field names to be included in the Logpush output. For the moment, there - // is no option to add all fields at once, so you must specify all the fields names - // you are interested in. - FieldNames param.Field[[]string] `json:"field_names"` - // Specifies the output type, such as `ndjson` or `csv`. This sets default values - // for the rest of the settings, depending on the chosen output type. Some - // formatting rules, like string quoting, are different between output types. - OutputType param.Field[LogpushJobUpdateParamsOutputOptionsOutputType] `json:"output_type"` - // String to be inserted in-between the records as separator. - RecordDelimiter param.Field[string] `json:"record_delimiter"` - // String to be prepended before each record. - RecordPrefix param.Field[string] `json:"record_prefix"` - // String to be appended after each record. - RecordSuffix param.Field[string] `json:"record_suffix"` - // String to use as template for each record instead of the default comma-separated - // list. All fields used in the template must be present in `field_names` as well, - // otherwise they will end up as null. Format as a Go `text/template` without any - // standard functions, like conditionals, loops, sub-templates, etc. - RecordTemplate param.Field[string] `json:"record_template"` - // Floating number to specify sampling rate. Sampling is applied on top of - // filtering, and regardless of the current `sample_interval` of the data. - SampleRate param.Field[float64] `json:"sample_rate"` - // String to specify the format for timestamps, such as `unixnano`, `unix`, or - // `rfc3339`. - TimestampFormat param.Field[LogpushJobUpdateParamsOutputOptionsTimestampFormat] `json:"timestamp_format"` -} - -func (r LogpushJobUpdateParamsOutputOptions) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Specifies the output type, such as `ndjson` or `csv`. This sets default values -// for the rest of the settings, depending on the chosen output type. Some -// formatting rules, like string quoting, are different between output types. -type LogpushJobUpdateParamsOutputOptionsOutputType string - -const ( - LogpushJobUpdateParamsOutputOptionsOutputTypeNdjson LogpushJobUpdateParamsOutputOptionsOutputType = "ndjson" - LogpushJobUpdateParamsOutputOptionsOutputTypeCsv LogpushJobUpdateParamsOutputOptionsOutputType = "csv" -) - -// String to specify the format for timestamps, such as `unixnano`, `unix`, or -// `rfc3339`. -type LogpushJobUpdateParamsOutputOptionsTimestampFormat string - -const ( - LogpushJobUpdateParamsOutputOptionsTimestampFormatUnixnano LogpushJobUpdateParamsOutputOptionsTimestampFormat = "unixnano" - LogpushJobUpdateParamsOutputOptionsTimestampFormatUnix LogpushJobUpdateParamsOutputOptionsTimestampFormat = "unix" - LogpushJobUpdateParamsOutputOptionsTimestampFormatRfc3339 LogpushJobUpdateParamsOutputOptionsTimestampFormat = "rfc3339" -) - -type LogpushJobUpdateResponseEnvelope struct { - Errors []LogpushJobUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []LogpushJobUpdateResponseEnvelopeMessages `json:"messages,required"` - Result LogpushJobUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LogpushJobUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON logpushJobUpdateResponseEnvelopeJSON `json:"-"` -} - -// logpushJobUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [LogpushJobUpdateResponseEnvelope] -type logpushJobUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LogpushJobUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushJobUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// logpushJobUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LogpushJobUpdateResponseEnvelopeErrors] -type logpushJobUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LogpushJobUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushJobUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// logpushJobUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LogpushJobUpdateResponseEnvelopeMessages] -type logpushJobUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LogpushJobUpdateResponseEnvelopeSuccess bool - -const ( - LogpushJobUpdateResponseEnvelopeSuccessTrue LogpushJobUpdateResponseEnvelopeSuccess = true -) - -type LogpushJobListParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type LogpushJobListResponseEnvelope struct { - Errors []LogpushJobListResponseEnvelopeErrors `json:"errors,required"` - Messages []LogpushJobListResponseEnvelopeMessages `json:"messages,required"` - Result []LogpushJobListResponse `json:"result,required"` - // Whether the API call was successful - Success LogpushJobListResponseEnvelopeSuccess `json:"success,required"` - JSON logpushJobListResponseEnvelopeJSON `json:"-"` -} - -// logpushJobListResponseEnvelopeJSON contains the JSON metadata for the struct -// [LogpushJobListResponseEnvelope] -type logpushJobListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LogpushJobListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushJobListResponseEnvelopeErrorsJSON `json:"-"` -} - -// logpushJobListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LogpushJobListResponseEnvelopeErrors] -type logpushJobListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LogpushJobListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushJobListResponseEnvelopeMessagesJSON `json:"-"` -} - -// logpushJobListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LogpushJobListResponseEnvelopeMessages] -type logpushJobListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LogpushJobListResponseEnvelopeSuccess bool - -const ( - LogpushJobListResponseEnvelopeSuccessTrue LogpushJobListResponseEnvelopeSuccess = true -) - -type LogpushJobDeleteParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type LogpushJobDeleteResponseEnvelope struct { - Errors []LogpushJobDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []LogpushJobDeleteResponseEnvelopeMessages `json:"messages,required"` - Result LogpushJobDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LogpushJobDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON logpushJobDeleteResponseEnvelopeJSON `json:"-"` -} - -// logpushJobDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [LogpushJobDeleteResponseEnvelope] -type logpushJobDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LogpushJobDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushJobDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// logpushJobDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LogpushJobDeleteResponseEnvelopeErrors] -type logpushJobDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LogpushJobDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushJobDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// logpushJobDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LogpushJobDeleteResponseEnvelopeMessages] -type logpushJobDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LogpushJobDeleteResponseEnvelopeSuccess bool - -const ( - LogpushJobDeleteResponseEnvelopeSuccessTrue LogpushJobDeleteResponseEnvelopeSuccess = true -) - -type LogpushJobGetParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type LogpushJobGetResponseEnvelope struct { - Errors []LogpushJobGetResponseEnvelopeErrors `json:"errors,required"` - Messages []LogpushJobGetResponseEnvelopeMessages `json:"messages,required"` - Result LogpushJobGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LogpushJobGetResponseEnvelopeSuccess `json:"success,required"` - JSON logpushJobGetResponseEnvelopeJSON `json:"-"` -} - -// logpushJobGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [LogpushJobGetResponseEnvelope] -type logpushJobGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LogpushJobGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushJobGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// logpushJobGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LogpushJobGetResponseEnvelopeErrors] -type logpushJobGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LogpushJobGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushJobGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// logpushJobGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [LogpushJobGetResponseEnvelopeMessages] -type logpushJobGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushJobGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushJobGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LogpushJobGetResponseEnvelopeSuccess bool - -const ( - LogpushJobGetResponseEnvelopeSuccessTrue LogpushJobGetResponseEnvelopeSuccess = true -) diff --git a/logpushjob_test.go b/logpushjob_test.go deleted file mode 100644 index ce060849299..00000000000 --- a/logpushjob_test.go +++ /dev/null @@ -1,201 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLogpushJobNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Logpush.Jobs.New(context.TODO(), cloudflare.LogpushJobNewParams{ - DestinationConf: cloudflare.F("s3://mybucket/logs?region=us-west-2"), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - Dataset: cloudflare.F("http_requests"), - Enabled: cloudflare.F(false), - Frequency: cloudflare.F(cloudflare.LogpushJobNewParamsFrequencyHigh), - LogpullOptions: cloudflare.F("fields=RayID,ClientIP,EdgeStartTimestamp×tamps=rfc3339"), - Name: cloudflare.F("example.com"), - OutputOptions: cloudflare.F(cloudflare.LogpushJobNewParamsOutputOptions{ - Cve2021_4428: cloudflare.F(true), - BatchPrefix: cloudflare.F("string"), - BatchSuffix: cloudflare.F("string"), - FieldDelimiter: cloudflare.F("string"), - FieldNames: cloudflare.F([]string{"ClientIP", "EdgeStartTimestamp", "RayID"}), - OutputType: cloudflare.F(cloudflare.LogpushJobNewParamsOutputOptionsOutputTypeNdjson), - RecordDelimiter: cloudflare.F("string"), - RecordPrefix: cloudflare.F("string"), - RecordSuffix: cloudflare.F("string"), - RecordTemplate: cloudflare.F("string"), - SampleRate: cloudflare.F(0.000000), - TimestampFormat: cloudflare.F(cloudflare.LogpushJobNewParamsOutputOptionsTimestampFormatUnixnano), - }), - OwnershipChallenge: cloudflare.F("00000000000000000000"), - }) - 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 TestLogpushJobUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Logpush.Jobs.Update( - context.TODO(), - int64(1), - cloudflare.LogpushJobUpdateParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - DestinationConf: cloudflare.F("s3://mybucket/logs?region=us-west-2"), - Enabled: cloudflare.F(false), - Frequency: cloudflare.F(cloudflare.LogpushJobUpdateParamsFrequencyHigh), - LogpullOptions: cloudflare.F("fields=RayID,ClientIP,EdgeStartTimestamp×tamps=rfc3339"), - OutputOptions: cloudflare.F(cloudflare.LogpushJobUpdateParamsOutputOptions{ - Cve2021_4428: cloudflare.F(true), - BatchPrefix: cloudflare.F("string"), - BatchSuffix: cloudflare.F("string"), - FieldDelimiter: cloudflare.F("string"), - FieldNames: cloudflare.F([]string{"ClientIP", "EdgeStartTimestamp", "RayID"}), - OutputType: cloudflare.F(cloudflare.LogpushJobUpdateParamsOutputOptionsOutputTypeNdjson), - RecordDelimiter: cloudflare.F("string"), - RecordPrefix: cloudflare.F("string"), - RecordSuffix: cloudflare.F("string"), - RecordTemplate: cloudflare.F("string"), - SampleRate: cloudflare.F(0.000000), - TimestampFormat: cloudflare.F(cloudflare.LogpushJobUpdateParamsOutputOptionsTimestampFormatUnixnano), - }), - OwnershipChallenge: cloudflare.F("00000000000000000000"), - }, - ) - 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 TestLogpushJobListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Logpush.Jobs.List(context.TODO(), cloudflare.LogpushJobListParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }) - 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 TestLogpushJobDeleteWithOptionalParams(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("user@example.com"), - ) - _, err := client.Logpush.Jobs.Delete( - context.TODO(), - int64(1), - cloudflare.LogpushJobDeleteParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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 TestLogpushJobGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Logpush.Jobs.Get( - context.TODO(), - int64(1), - cloudflare.LogpushJobGetParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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/logpushownership.go b/logpushownership.go deleted file mode 100644 index d8ce46d7483..00000000000 --- a/logpushownership.go +++ /dev/null @@ -1,316 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// LogpushOwnershipService 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 [NewLogpushOwnershipService] method -// instead. -type LogpushOwnershipService struct { - Options []option.RequestOption -} - -// NewLogpushOwnershipService 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 NewLogpushOwnershipService(opts ...option.RequestOption) (r *LogpushOwnershipService) { - r = &LogpushOwnershipService{} - r.Options = opts - return -} - -// Gets a new ownership challenge sent to your destination. -func (r *LogpushOwnershipService) New(ctx context.Context, params LogpushOwnershipNewParams, opts ...option.RequestOption) (res *LogpushOwnershipNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env LogpushOwnershipNewResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/logpush/ownership", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Validates ownership challenge of the destination. -func (r *LogpushOwnershipService) Validate(ctx context.Context, params LogpushOwnershipValidateParams, opts ...option.RequestOption) (res *LogpushOwnershipValidateResponse, err error) { - opts = append(r.Options[:], opts...) - var env LogpushOwnershipValidateResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/logpush/ownership/validate", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LogpushOwnershipNewResponse struct { - Filename string `json:"filename"` - Message string `json:"message"` - Valid bool `json:"valid"` - JSON logpushOwnershipNewResponseJSON `json:"-"` -} - -// logpushOwnershipNewResponseJSON contains the JSON metadata for the struct -// [LogpushOwnershipNewResponse] -type logpushOwnershipNewResponseJSON struct { - Filename apijson.Field - Message apijson.Field - Valid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushOwnershipNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushOwnershipNewResponseJSON) RawJSON() string { - return r.raw -} - -type LogpushOwnershipValidateResponse struct { - Valid bool `json:"valid"` - JSON logpushOwnershipValidateResponseJSON `json:"-"` -} - -// logpushOwnershipValidateResponseJSON contains the JSON metadata for the struct -// [LogpushOwnershipValidateResponse] -type logpushOwnershipValidateResponseJSON struct { - Valid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushOwnershipValidateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushOwnershipValidateResponseJSON) RawJSON() string { - return r.raw -} - -type LogpushOwnershipNewParams struct { - // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. - // Additional configuration parameters supported by the destination may be - // included. - DestinationConf param.Field[string] `json:"destination_conf,required" format:"uri"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -func (r LogpushOwnershipNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type LogpushOwnershipNewResponseEnvelope struct { - Errors []LogpushOwnershipNewResponseEnvelopeErrors `json:"errors,required"` - Messages []LogpushOwnershipNewResponseEnvelopeMessages `json:"messages,required"` - Result LogpushOwnershipNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LogpushOwnershipNewResponseEnvelopeSuccess `json:"success,required"` - JSON logpushOwnershipNewResponseEnvelopeJSON `json:"-"` -} - -// logpushOwnershipNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [LogpushOwnershipNewResponseEnvelope] -type logpushOwnershipNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushOwnershipNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushOwnershipNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LogpushOwnershipNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushOwnershipNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// logpushOwnershipNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [LogpushOwnershipNewResponseEnvelopeErrors] -type logpushOwnershipNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushOwnershipNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushOwnershipNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LogpushOwnershipNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushOwnershipNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// logpushOwnershipNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [LogpushOwnershipNewResponseEnvelopeMessages] -type logpushOwnershipNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushOwnershipNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushOwnershipNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LogpushOwnershipNewResponseEnvelopeSuccess bool - -const ( - LogpushOwnershipNewResponseEnvelopeSuccessTrue LogpushOwnershipNewResponseEnvelopeSuccess = true -) - -type LogpushOwnershipValidateParams struct { - // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. - // Additional configuration parameters supported by the destination may be - // included. - DestinationConf param.Field[string] `json:"destination_conf,required" format:"uri"` - // Ownership challenge token to prove destination ownership. - OwnershipChallenge param.Field[string] `json:"ownership_challenge,required"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -func (r LogpushOwnershipValidateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type LogpushOwnershipValidateResponseEnvelope struct { - Errors []LogpushOwnershipValidateResponseEnvelopeErrors `json:"errors,required"` - Messages []LogpushOwnershipValidateResponseEnvelopeMessages `json:"messages,required"` - Result LogpushOwnershipValidateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LogpushOwnershipValidateResponseEnvelopeSuccess `json:"success,required"` - JSON logpushOwnershipValidateResponseEnvelopeJSON `json:"-"` -} - -// logpushOwnershipValidateResponseEnvelopeJSON contains the JSON metadata for the -// struct [LogpushOwnershipValidateResponseEnvelope] -type logpushOwnershipValidateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushOwnershipValidateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushOwnershipValidateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LogpushOwnershipValidateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushOwnershipValidateResponseEnvelopeErrorsJSON `json:"-"` -} - -// logpushOwnershipValidateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [LogpushOwnershipValidateResponseEnvelopeErrors] -type logpushOwnershipValidateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushOwnershipValidateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushOwnershipValidateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LogpushOwnershipValidateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushOwnershipValidateResponseEnvelopeMessagesJSON `json:"-"` -} - -// logpushOwnershipValidateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [LogpushOwnershipValidateResponseEnvelopeMessages] -type logpushOwnershipValidateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushOwnershipValidateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushOwnershipValidateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LogpushOwnershipValidateResponseEnvelopeSuccess bool - -const ( - LogpushOwnershipValidateResponseEnvelopeSuccessTrue LogpushOwnershipValidateResponseEnvelopeSuccess = true -) diff --git a/logpushownership_test.go b/logpushownership_test.go deleted file mode 100644 index 05ca2f9ff12..00000000000 --- a/logpushownership_test.go +++ /dev/null @@ -1,71 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLogpushOwnershipNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Logpush.Ownership.New(context.TODO(), cloudflare.LogpushOwnershipNewParams{ - DestinationConf: cloudflare.F("s3://mybucket/logs?region=us-west-2"), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }) - 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 TestLogpushOwnershipValidateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Logpush.Ownership.Validate(context.TODO(), cloudflare.LogpushOwnershipValidateParams{ - DestinationConf: cloudflare.F("s3://mybucket/logs?region=us-west-2"), - OwnershipChallenge: cloudflare.F("00000000000000000000"), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }) - 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/logpushvalidate.go b/logpushvalidate.go deleted file mode 100644 index 2031d3f7201..00000000000 --- a/logpushvalidate.go +++ /dev/null @@ -1,314 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// LogpushValidateService 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 [NewLogpushValidateService] method -// instead. -type LogpushValidateService struct { - Options []option.RequestOption -} - -// NewLogpushValidateService 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 NewLogpushValidateService(opts ...option.RequestOption) (r *LogpushValidateService) { - r = &LogpushValidateService{} - r.Options = opts - return -} - -// Checks if there is an existing job with a destination. -func (r *LogpushValidateService) Destination(ctx context.Context, params LogpushValidateDestinationParams, opts ...option.RequestOption) (res *LogpushValidateDestinationResponse, err error) { - opts = append(r.Options[:], opts...) - var env LogpushValidateDestinationResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/logpush/validate/destination/exists", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Validates logpull origin with logpull_options. -func (r *LogpushValidateService) Origin(ctx context.Context, params LogpushValidateOriginParams, opts ...option.RequestOption) (res *LogpushValidateOriginResponse, err error) { - opts = append(r.Options[:], opts...) - var env LogpushValidateOriginResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/logpush/validate/origin", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LogpushValidateDestinationResponse struct { - Exists bool `json:"exists"` - JSON logpushValidateDestinationResponseJSON `json:"-"` -} - -// logpushValidateDestinationResponseJSON contains the JSON metadata for the struct -// [LogpushValidateDestinationResponse] -type logpushValidateDestinationResponseJSON struct { - Exists apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushValidateDestinationResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushValidateDestinationResponseJSON) RawJSON() string { - return r.raw -} - -type LogpushValidateOriginResponse struct { - Message string `json:"message"` - Valid bool `json:"valid"` - JSON logpushValidateOriginResponseJSON `json:"-"` -} - -// logpushValidateOriginResponseJSON contains the JSON metadata for the struct -// [LogpushValidateOriginResponse] -type logpushValidateOriginResponseJSON struct { - Message apijson.Field - Valid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushValidateOriginResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushValidateOriginResponseJSON) RawJSON() string { - return r.raw -} - -type LogpushValidateDestinationParams struct { - // Uniquely identifies a resource (such as an s3 bucket) where data will be pushed. - // Additional configuration parameters supported by the destination may be - // included. - DestinationConf param.Field[string] `json:"destination_conf,required" format:"uri"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -func (r LogpushValidateDestinationParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type LogpushValidateDestinationResponseEnvelope struct { - Errors []LogpushValidateDestinationResponseEnvelopeErrors `json:"errors,required"` - Messages []LogpushValidateDestinationResponseEnvelopeMessages `json:"messages,required"` - Result LogpushValidateDestinationResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LogpushValidateDestinationResponseEnvelopeSuccess `json:"success,required"` - JSON logpushValidateDestinationResponseEnvelopeJSON `json:"-"` -} - -// logpushValidateDestinationResponseEnvelopeJSON contains the JSON metadata for -// the struct [LogpushValidateDestinationResponseEnvelope] -type logpushValidateDestinationResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushValidateDestinationResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushValidateDestinationResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LogpushValidateDestinationResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushValidateDestinationResponseEnvelopeErrorsJSON `json:"-"` -} - -// logpushValidateDestinationResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [LogpushValidateDestinationResponseEnvelopeErrors] -type logpushValidateDestinationResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushValidateDestinationResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushValidateDestinationResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LogpushValidateDestinationResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushValidateDestinationResponseEnvelopeMessagesJSON `json:"-"` -} - -// logpushValidateDestinationResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [LogpushValidateDestinationResponseEnvelopeMessages] -type logpushValidateDestinationResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushValidateDestinationResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushValidateDestinationResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LogpushValidateDestinationResponseEnvelopeSuccess bool - -const ( - LogpushValidateDestinationResponseEnvelopeSuccessTrue LogpushValidateDestinationResponseEnvelopeSuccess = true -) - -type LogpushValidateOriginParams struct { - // This field is deprecated. Use `output_options` instead. Configuration string. It - // specifies things like requested fields and timestamp formats. If migrating from - // the logpull api, copy the url (full url or just the query string) of your call - // here, and logpush will keep on making this call for you, setting start and end - // times appropriately. - LogpullOptions param.Field[string] `json:"logpull_options,required" format:"uri-reference"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -func (r LogpushValidateOriginParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type LogpushValidateOriginResponseEnvelope struct { - Errors []LogpushValidateOriginResponseEnvelopeErrors `json:"errors,required"` - Messages []LogpushValidateOriginResponseEnvelopeMessages `json:"messages,required"` - Result LogpushValidateOriginResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LogpushValidateOriginResponseEnvelopeSuccess `json:"success,required"` - JSON logpushValidateOriginResponseEnvelopeJSON `json:"-"` -} - -// logpushValidateOriginResponseEnvelopeJSON contains the JSON metadata for the -// struct [LogpushValidateOriginResponseEnvelope] -type logpushValidateOriginResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushValidateOriginResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushValidateOriginResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type LogpushValidateOriginResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushValidateOriginResponseEnvelopeErrorsJSON `json:"-"` -} - -// logpushValidateOriginResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [LogpushValidateOriginResponseEnvelopeErrors] -type logpushValidateOriginResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushValidateOriginResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushValidateOriginResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type LogpushValidateOriginResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON logpushValidateOriginResponseEnvelopeMessagesJSON `json:"-"` -} - -// logpushValidateOriginResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [LogpushValidateOriginResponseEnvelopeMessages] -type logpushValidateOriginResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogpushValidateOriginResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logpushValidateOriginResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LogpushValidateOriginResponseEnvelopeSuccess bool - -const ( - LogpushValidateOriginResponseEnvelopeSuccessTrue LogpushValidateOriginResponseEnvelopeSuccess = true -) diff --git a/logpushvalidate_test.go b/logpushvalidate_test.go deleted file mode 100644 index f236b99b201..00000000000 --- a/logpushvalidate_test.go +++ /dev/null @@ -1,70 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLogpushValidateDestinationWithOptionalParams(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("user@example.com"), - ) - _, err := client.Logpush.Validate.Destination(context.TODO(), cloudflare.LogpushValidateDestinationParams{ - DestinationConf: cloudflare.F("s3://mybucket/logs?region=us-west-2"), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }) - 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 TestLogpushValidateOriginWithOptionalParams(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("user@example.com"), - ) - _, err := client.Logpush.Validate.Origin(context.TODO(), cloudflare.LogpushValidateOriginParams{ - LogpullOptions: cloudflare.F("fields=RayID,ClientIP,EdgeStartTimestamp×tamps=rfc3339"), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }) - 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/lograyid.go b/lograyid.go deleted file mode 100644 index 06d1bdfaf0c..00000000000 --- a/lograyid.go +++ /dev/null @@ -1,103 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// LogRayidService 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 [NewLogRayidService] method instead. -type LogRayidService struct { - Options []option.RequestOption -} - -// NewLogRayidService 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 NewLogRayidService(opts ...option.RequestOption) (r *LogRayidService) { - r = &LogRayidService{} - r.Options = opts - return -} - -// The `/rayids` api route allows lookups by specific rayid. The rayids route will -// return zero, one, or more records (ray ids are not unique). -func (r *LogRayidService) Get(ctx context.Context, zoneIdentifier string, rayIdentifier string, query LogRayidGetParams, opts ...option.RequestOption) (res *LogRayidGetResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("zones/%s/logs/rayids/%s", zoneIdentifier, rayIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -// Union satisfied by [shared.UnionString] or [LogRayidGetResponseUnknown]. -type LogRayidGetResponse interface { - ImplementsLogRayidGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*LogRayidGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type LogRayidGetParams struct { - // The `/received` route by default returns a limited set of fields, and allows - // customers to override the default field set by specifying individual fields. The - // reasons for this are: 1. Most customers require only a small subset of fields, - // but that subset varies from customer to customer; 2. Flat schema is much easier - // to work with downstream (importing into BigTable etc); 3. Performance (time to - // process, file size). If `?fields=` is not specified, default field set is - // returned. This default field set may change at any time. When `?fields=` is - // provided, each record is returned with the specified fields. `fields` must be - // specified as a comma separated list without any whitespaces, and all fields must - // exist. The order in which fields are specified does not matter, and the order of - // fields in the response is not specified. - Fields param.Field[string] `query:"fields"` - // By default, timestamps in responses are returned as Unix nanosecond integers. - // The `?timestamps=` argument can be set to change the format in which response - // timestamps are returned. Possible values are: `unix`, `unixnano`, `rfc3339`. - // Note that `unix` and `unixnano` return timestamps as integers; `rfc3339` returns - // timestamps as strings. - Timestamps param.Field[LogRayidGetParamsTimestamps] `query:"timestamps"` -} - -// URLQuery serializes [LogRayidGetParams]'s query parameters as `url.Values`. -func (r LogRayidGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// By default, timestamps in responses are returned as Unix nanosecond integers. -// The `?timestamps=` argument can be set to change the format in which response -// timestamps are returned. Possible values are: `unix`, `unixnano`, `rfc3339`. -// Note that `unix` and `unixnano` return timestamps as integers; `rfc3339` returns -// timestamps as strings. -type LogRayidGetParamsTimestamps string - -const ( - LogRayidGetParamsTimestampsUnix LogRayidGetParamsTimestamps = "unix" - LogRayidGetParamsTimestampsUnixnano LogRayidGetParamsTimestamps = "unixnano" - LogRayidGetParamsTimestampsRfc3339 LogRayidGetParamsTimestamps = "rfc3339" -) diff --git a/lograyid_test.go b/lograyid_test.go deleted file mode 100644 index bf58bfda280..00000000000 --- a/lograyid_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLogRayidGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Logs.Rayid.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "41ddf1740f67442d", - cloudflare.LogRayidGetParams{ - Fields: cloudflare.F("ClientIP,RayID,EdgeStartTimestamp"), - Timestamps: cloudflare.F(cloudflare.LogRayidGetParamsTimestampsUnixnano), - }, - ) - 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/logreceived.go b/logreceived.go deleted file mode 100644 index b7189a669d1..00000000000 --- a/logreceived.go +++ /dev/null @@ -1,157 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// LogReceivedService 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 [NewLogReceivedService] method -// instead. -type LogReceivedService struct { - Options []option.RequestOption - Fields *LogReceivedFieldService -} - -// NewLogReceivedService 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 NewLogReceivedService(opts ...option.RequestOption) (r *LogReceivedService) { - r = &LogReceivedService{} - r.Options = opts - r.Fields = NewLogReceivedFieldService(opts...) - return -} - -// The `/received` api route allows customers to retrieve their edge HTTP logs. The -// basic access pattern is "give me all the logs for zone Z for minute M", where -// the minute M refers to the time records were received at Cloudflare's central -// data center. `start` is inclusive, and `end` is exclusive. Because of that, to -// get all data, at minutely cadence, starting at 10AM, the proper values are: -// `start=2018-05-20T10:00:00Z&end=2018-05-20T10:01:00Z`, then -// `start=2018-05-20T10:01:00Z&end=2018-05-20T10:02:00Z` and so on; the overlap -// will be handled properly. -func (r *LogReceivedService) Get(ctx context.Context, zoneIdentifier string, query LogReceivedGetParams, opts ...option.RequestOption) (res *LogReceivedGetResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("zones/%s/logs/received", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -// Union satisfied by [shared.UnionString] or [LogReceivedGetResponseUnknown]. -type LogReceivedGetResponse interface { - ImplementsLogReceivedGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*LogReceivedGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type LogReceivedGetParams struct { - // Sets the (exclusive) end of the requested time frame. This can be a unix - // timestamp (in seconds or nanoseconds), or an absolute timestamp that conforms to - // RFC 3339. `end` must be at least five minutes earlier than now and must be later - // than `start`. Difference between `start` and `end` must be not greater than one - // hour. - End param.Field[LogReceivedGetParamsEnd] `query:"end,required"` - // When `?count=` is provided, the response will contain up to `count` results. - // Since results are not sorted, you are likely to get different data for repeated - // requests. `count` must be an integer > 0. - Count param.Field[int64] `query:"count"` - // The `/received` route by default returns a limited set of fields, and allows - // customers to override the default field set by specifying individual fields. The - // reasons for this are: 1. Most customers require only a small subset of fields, - // but that subset varies from customer to customer; 2. Flat schema is much easier - // to work with downstream (importing into BigTable etc); 3. Performance (time to - // process, file size). If `?fields=` is not specified, default field set is - // returned. This default field set may change at any time. When `?fields=` is - // provided, each record is returned with the specified fields. `fields` must be - // specified as a comma separated list without any whitespaces, and all fields must - // exist. The order in which fields are specified does not matter, and the order of - // fields in the response is not specified. - Fields param.Field[string] `query:"fields"` - // When `?sample=` is provided, a sample of matching records is returned. If - // `sample=0.1` then 10% of records will be returned. Sampling is random: repeated - // calls will not only return different records, but likely will also vary slightly - // in number of returned records. When `?count=` is also specified, `count` is - // applied to the number of returned records, not the sampled records. So, with - // `sample=0.05` and `count=7`, when there is a total of 100 records available, - // approximately five will be returned. When there are 1000 records, seven will be - // returned. When there are 10,000 records, seven will be returned. - Sample param.Field[float64] `query:"sample"` - // Sets the (inclusive) beginning of the requested time frame. This can be a unix - // timestamp (in seconds or nanoseconds), or an absolute timestamp that conforms to - // RFC 3339. At this point in time, it cannot exceed a time in the past greater - // than seven days. - Start param.Field[LogReceivedGetParamsStart] `query:"start"` - // By default, timestamps in responses are returned as Unix nanosecond integers. - // The `?timestamps=` argument can be set to change the format in which response - // timestamps are returned. Possible values are: `unix`, `unixnano`, `rfc3339`. - // Note that `unix` and `unixnano` return timestamps as integers; `rfc3339` returns - // timestamps as strings. - Timestamps param.Field[LogReceivedGetParamsTimestamps] `query:"timestamps"` -} - -// URLQuery serializes [LogReceivedGetParams]'s query parameters as `url.Values`. -func (r LogReceivedGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Sets the (exclusive) end of the requested time frame. This can be a unix -// timestamp (in seconds or nanoseconds), or an absolute timestamp that conforms to -// RFC 3339. `end` must be at least five minutes earlier than now and must be later -// than `start`. Difference between `start` and `end` must be not greater than one -// hour. -// -// Satisfied by [shared.UnionString], [shared.UnionInt]. -type LogReceivedGetParamsEnd interface { - ImplementsLogReceivedGetParamsEnd() -} - -// Sets the (inclusive) beginning of the requested time frame. This can be a unix -// timestamp (in seconds or nanoseconds), or an absolute timestamp that conforms to -// RFC 3339. At this point in time, it cannot exceed a time in the past greater -// than seven days. -// -// Satisfied by [shared.UnionString], [shared.UnionInt]. -type LogReceivedGetParamsStart interface { - ImplementsLogReceivedGetParamsStart() -} - -// By default, timestamps in responses are returned as Unix nanosecond integers. -// The `?timestamps=` argument can be set to change the format in which response -// timestamps are returned. Possible values are: `unix`, `unixnano`, `rfc3339`. -// Note that `unix` and `unixnano` return timestamps as integers; `rfc3339` returns -// timestamps as strings. -type LogReceivedGetParamsTimestamps string - -const ( - LogReceivedGetParamsTimestampsUnix LogReceivedGetParamsTimestamps = "unix" - LogReceivedGetParamsTimestampsUnixnano LogReceivedGetParamsTimestamps = "unixnano" - LogReceivedGetParamsTimestampsRfc3339 LogReceivedGetParamsTimestamps = "rfc3339" -) diff --git a/logreceived_test.go b/logreceived_test.go deleted file mode 100644 index 468a420f89f..00000000000 --- a/logreceived_test.go +++ /dev/null @@ -1,50 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLogReceivedGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Logs.Received.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.LogReceivedGetParams{ - End: cloudflare.F[cloudflare.LogReceivedGetParamsEnd](shared.UnionString("2018-05-20T10:01:00Z")), - Count: cloudflare.F(int64(1)), - Fields: cloudflare.F("ClientIP,RayID,EdgeStartTimestamp"), - Sample: cloudflare.F(0.100000), - Start: cloudflare.F[cloudflare.LogReceivedGetParamsStart](shared.UnionString("2018-05-20T10:00:00Z")), - Timestamps: cloudflare.F(cloudflare.LogReceivedGetParamsTimestampsUnixnano), - }, - ) - 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/logreceivedfield.go b/logreceivedfield.go deleted file mode 100644 index 139e1c85955..00000000000 --- a/logreceivedfield.go +++ /dev/null @@ -1,61 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// LogReceivedFieldService 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 [NewLogReceivedFieldService] method -// instead. -type LogReceivedFieldService struct { - Options []option.RequestOption -} - -// NewLogReceivedFieldService 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 NewLogReceivedFieldService(opts ...option.RequestOption) (r *LogReceivedFieldService) { - r = &LogReceivedFieldService{} - r.Options = opts - return -} - -// Lists all fields available. The response is json object with key-value pairs, -// where keys are field names, and values are descriptions. -func (r *LogReceivedFieldService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *LogReceivedFieldGetResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("zones/%s/logs/received/fields", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) - return -} - -type LogReceivedFieldGetResponse struct { - Key string `json:"key"` - JSON logReceivedFieldGetResponseJSON `json:"-"` -} - -// logReceivedFieldGetResponseJSON contains the JSON metadata for the struct -// [LogReceivedFieldGetResponse] -type logReceivedFieldGetResponseJSON struct { - Key apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LogReceivedFieldGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r logReceivedFieldGetResponseJSON) RawJSON() string { - return r.raw -} diff --git a/logreceivedfield_test.go b/logreceivedfield_test.go deleted file mode 100644 index af048dcef1a..00000000000 --- a/logreceivedfield_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestLogReceivedFieldGet(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("user@example.com"), - ) - _, err := client.Logs.Received.Fields.Get(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/logs/aliases.go b/logs/aliases.go new file mode 100644 index 00000000000..e89e5369627 --- /dev/null +++ b/logs/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package logs + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/logs/control.go b/logs/control.go new file mode 100644 index 00000000000..b619a402658 --- /dev/null +++ b/logs/control.go @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package logs + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// ControlService 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 [NewControlService] method instead. +type ControlService struct { + Options []option.RequestOption + Retention *ControlRetentionService + Cmb *ControlCmbService +} + +// NewControlService 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 NewControlService(opts ...option.RequestOption) (r *ControlService) { + r = &ControlService{} + r.Options = opts + r.Retention = NewControlRetentionService(opts...) + r.Cmb = NewControlCmbService(opts...) + return +} diff --git a/logs/controlcmb.go b/logs/controlcmb.go new file mode 100644 index 00000000000..1e979de675c --- /dev/null +++ b/logs/controlcmb.go @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package logs + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// ControlCmbService 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 [NewControlCmbService] method instead. +type ControlCmbService struct { + Options []option.RequestOption + Config *ControlCmbConfigService +} + +// NewControlCmbService 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 NewControlCmbService(opts ...option.RequestOption) (r *ControlCmbService) { + r = &ControlCmbService{} + r.Options = opts + r.Config = NewControlCmbConfigService(opts...) + return +} diff --git a/logs/controlcmbconfig.go b/logs/controlcmbconfig.go new file mode 100644 index 00000000000..1899e8b959f --- /dev/null +++ b/logs/controlcmbconfig.go @@ -0,0 +1,385 @@ +// File generated from our OpenAPI spec by Stainless. + +package logs + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// ControlCmbConfigService 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 [NewControlCmbConfigService] method +// instead. +type ControlCmbConfigService struct { + Options []option.RequestOption +} + +// NewControlCmbConfigService 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 NewControlCmbConfigService(opts ...option.RequestOption) (r *ControlCmbConfigService) { + r = &ControlCmbConfigService{} + r.Options = opts + return +} + +// Updates CMB config. +func (r *ControlCmbConfigService) New(ctx context.Context, params ControlCmbConfigNewParams, opts ...option.RequestOption) (res *LogcontrolCmbConfig, err error) { + opts = append(r.Options[:], opts...) + var env ControlCmbConfigNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/logs/control/cmb/config", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes CMB config. +func (r *ControlCmbConfigService) Delete(ctx context.Context, body ControlCmbConfigDeleteParams, opts ...option.RequestOption) (res *ControlCmbConfigDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env ControlCmbConfigDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/logs/control/cmb/config", body.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets CMB config. +func (r *ControlCmbConfigService) Get(ctx context.Context, query ControlCmbConfigGetParams, opts ...option.RequestOption) (res *LogcontrolCmbConfig, err error) { + opts = append(r.Options[:], opts...) + var env ControlCmbConfigGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/logs/control/cmb/config", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type LogcontrolCmbConfig struct { + // Comma-separated list of regions. + Regions string `json:"regions"` + JSON logcontrolCmbConfigJSON `json:"-"` +} + +// logcontrolCmbConfigJSON contains the JSON metadata for the struct +// [LogcontrolCmbConfig] +type logcontrolCmbConfigJSON struct { + Regions apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LogcontrolCmbConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r logcontrolCmbConfigJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [logs.ControlCmbConfigDeleteResponseUnknown], +// [logs.ControlCmbConfigDeleteResponseArray] or [shared.UnionString]. +type ControlCmbConfigDeleteResponse interface { + ImplementsLogsControlCmbConfigDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ControlCmbConfigDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ControlCmbConfigDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type ControlCmbConfigDeleteResponseArray []interface{} + +func (r ControlCmbConfigDeleteResponseArray) ImplementsLogsControlCmbConfigDeleteResponse() {} + +type ControlCmbConfigNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Comma-separated list of regions. + Regions param.Field[string] `json:"regions"` +} + +func (r ControlCmbConfigNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ControlCmbConfigNewResponseEnvelope struct { + Errors []ControlCmbConfigNewResponseEnvelopeErrors `json:"errors,required"` + Messages []ControlCmbConfigNewResponseEnvelopeMessages `json:"messages,required"` + Result LogcontrolCmbConfig `json:"result,required,nullable"` + // Whether the API call was successful + Success ControlCmbConfigNewResponseEnvelopeSuccess `json:"success,required"` + JSON controlCmbConfigNewResponseEnvelopeJSON `json:"-"` +} + +// controlCmbConfigNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [ControlCmbConfigNewResponseEnvelope] +type controlCmbConfigNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ControlCmbConfigNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r controlCmbConfigNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ControlCmbConfigNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON controlCmbConfigNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// controlCmbConfigNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ControlCmbConfigNewResponseEnvelopeErrors] +type controlCmbConfigNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ControlCmbConfigNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r controlCmbConfigNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ControlCmbConfigNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON controlCmbConfigNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// controlCmbConfigNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [ControlCmbConfigNewResponseEnvelopeMessages] +type controlCmbConfigNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ControlCmbConfigNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r controlCmbConfigNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ControlCmbConfigNewResponseEnvelopeSuccess bool + +const ( + ControlCmbConfigNewResponseEnvelopeSuccessTrue ControlCmbConfigNewResponseEnvelopeSuccess = true +) + +type ControlCmbConfigDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ControlCmbConfigDeleteResponseEnvelope struct { + Errors []ControlCmbConfigDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []ControlCmbConfigDeleteResponseEnvelopeMessages `json:"messages,required"` + Result ControlCmbConfigDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ControlCmbConfigDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON controlCmbConfigDeleteResponseEnvelopeJSON `json:"-"` +} + +// controlCmbConfigDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [ControlCmbConfigDeleteResponseEnvelope] +type controlCmbConfigDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ControlCmbConfigDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r controlCmbConfigDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ControlCmbConfigDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON controlCmbConfigDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// controlCmbConfigDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [ControlCmbConfigDeleteResponseEnvelopeErrors] +type controlCmbConfigDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ControlCmbConfigDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r controlCmbConfigDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ControlCmbConfigDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON controlCmbConfigDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// controlCmbConfigDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [ControlCmbConfigDeleteResponseEnvelopeMessages] +type controlCmbConfigDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ControlCmbConfigDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r controlCmbConfigDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ControlCmbConfigDeleteResponseEnvelopeSuccess bool + +const ( + ControlCmbConfigDeleteResponseEnvelopeSuccessTrue ControlCmbConfigDeleteResponseEnvelopeSuccess = true +) + +type ControlCmbConfigGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ControlCmbConfigGetResponseEnvelope struct { + Errors []ControlCmbConfigGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ControlCmbConfigGetResponseEnvelopeMessages `json:"messages,required"` + Result LogcontrolCmbConfig `json:"result,required,nullable"` + // Whether the API call was successful + Success ControlCmbConfigGetResponseEnvelopeSuccess `json:"success,required"` + JSON controlCmbConfigGetResponseEnvelopeJSON `json:"-"` +} + +// controlCmbConfigGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [ControlCmbConfigGetResponseEnvelope] +type controlCmbConfigGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ControlCmbConfigGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r controlCmbConfigGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ControlCmbConfigGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON controlCmbConfigGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// controlCmbConfigGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ControlCmbConfigGetResponseEnvelopeErrors] +type controlCmbConfigGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ControlCmbConfigGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r controlCmbConfigGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ControlCmbConfigGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON controlCmbConfigGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// controlCmbConfigGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [ControlCmbConfigGetResponseEnvelopeMessages] +type controlCmbConfigGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ControlCmbConfigGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r controlCmbConfigGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ControlCmbConfigGetResponseEnvelopeSuccess bool + +const ( + ControlCmbConfigGetResponseEnvelopeSuccessTrue ControlCmbConfigGetResponseEnvelopeSuccess = true +) diff --git a/logs/controlcmbconfig_test.go b/logs/controlcmbconfig_test.go new file mode 100644 index 00000000000..5174fbcf9b9 --- /dev/null +++ b/logs/controlcmbconfig_test.go @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package logs_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/logs" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestControlCmbConfigNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Logs.Control.Cmb.Config.New(context.TODO(), logs.ControlCmbConfigNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Regions: cloudflare.F("eu"), + }) + 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 TestControlCmbConfigDelete(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("user@example.com"), + ) + _, err := client.Logs.Control.Cmb.Config.Delete(context.TODO(), logs.ControlCmbConfigDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestControlCmbConfigGet(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("user@example.com"), + ) + _, err := client.Logs.Control.Cmb.Config.Get(context.TODO(), logs.ControlCmbConfigGetParams{ + AccountID: cloudflare.F("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/logs/controlretention.go b/logs/controlretention.go new file mode 100644 index 00000000000..47cdeaa107d --- /dev/null +++ b/logs/controlretention.go @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package logs + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// ControlRetentionService 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 [NewControlRetentionService] method +// instead. +type ControlRetentionService struct { + Options []option.RequestOption + Flag *ControlRetentionFlagService +} + +// NewControlRetentionService 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 NewControlRetentionService(opts ...option.RequestOption) (r *ControlRetentionService) { + r = &ControlRetentionService{} + r.Options = opts + r.Flag = NewControlRetentionFlagService(opts...) + return +} diff --git a/logs/controlretentionflag.go b/logs/controlretentionflag.go new file mode 100644 index 00000000000..6b805b5f640 --- /dev/null +++ b/logs/controlretentionflag.go @@ -0,0 +1,271 @@ +// File generated from our OpenAPI spec by Stainless. + +package logs + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ControlRetentionFlagService 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 [NewControlRetentionFlagService] +// method instead. +type ControlRetentionFlagService struct { + Options []option.RequestOption +} + +// NewControlRetentionFlagService 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 NewControlRetentionFlagService(opts ...option.RequestOption) (r *ControlRetentionFlagService) { + r = &ControlRetentionFlagService{} + r.Options = opts + return +} + +// Updates log retention flag for Logpull API. +func (r *ControlRetentionFlagService) New(ctx context.Context, zoneIdentifier string, body ControlRetentionFlagNewParams, opts ...option.RequestOption) (res *ControlRetentionFlagNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env ControlRetentionFlagNewResponseEnvelope + path := fmt.Sprintf("zones/%s/logs/control/retention/flag", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets log retention flag for Logpull API. +func (r *ControlRetentionFlagService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *ControlRetentionFlagGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env ControlRetentionFlagGetResponseEnvelope + path := fmt.Sprintf("zones/%s/logs/control/retention/flag", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ControlRetentionFlagNewResponse struct { + Flag bool `json:"flag"` + JSON controlRetentionFlagNewResponseJSON `json:"-"` +} + +// controlRetentionFlagNewResponseJSON contains the JSON metadata for the struct +// [ControlRetentionFlagNewResponse] +type controlRetentionFlagNewResponseJSON struct { + Flag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ControlRetentionFlagNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r controlRetentionFlagNewResponseJSON) RawJSON() string { + return r.raw +} + +type ControlRetentionFlagGetResponse struct { + Flag bool `json:"flag"` + JSON controlRetentionFlagGetResponseJSON `json:"-"` +} + +// controlRetentionFlagGetResponseJSON contains the JSON metadata for the struct +// [ControlRetentionFlagGetResponse] +type controlRetentionFlagGetResponseJSON struct { + Flag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ControlRetentionFlagGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r controlRetentionFlagGetResponseJSON) RawJSON() string { + return r.raw +} + +type ControlRetentionFlagNewParams struct { + // The log retention flag for Logpull API. + Flag param.Field[bool] `json:"flag,required"` +} + +func (r ControlRetentionFlagNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ControlRetentionFlagNewResponseEnvelope struct { + Errors []ControlRetentionFlagNewResponseEnvelopeErrors `json:"errors,required"` + Messages []ControlRetentionFlagNewResponseEnvelopeMessages `json:"messages,required"` + Result ControlRetentionFlagNewResponse `json:"result,required"` + // Whether the API call was successful + Success ControlRetentionFlagNewResponseEnvelopeSuccess `json:"success,required"` + JSON controlRetentionFlagNewResponseEnvelopeJSON `json:"-"` +} + +// controlRetentionFlagNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [ControlRetentionFlagNewResponseEnvelope] +type controlRetentionFlagNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ControlRetentionFlagNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r controlRetentionFlagNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ControlRetentionFlagNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON controlRetentionFlagNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// controlRetentionFlagNewResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [ControlRetentionFlagNewResponseEnvelopeErrors] +type controlRetentionFlagNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ControlRetentionFlagNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r controlRetentionFlagNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ControlRetentionFlagNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON controlRetentionFlagNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// controlRetentionFlagNewResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [ControlRetentionFlagNewResponseEnvelopeMessages] +type controlRetentionFlagNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ControlRetentionFlagNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r controlRetentionFlagNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ControlRetentionFlagNewResponseEnvelopeSuccess bool + +const ( + ControlRetentionFlagNewResponseEnvelopeSuccessTrue ControlRetentionFlagNewResponseEnvelopeSuccess = true +) + +type ControlRetentionFlagGetResponseEnvelope struct { + Errors []ControlRetentionFlagGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ControlRetentionFlagGetResponseEnvelopeMessages `json:"messages,required"` + Result ControlRetentionFlagGetResponse `json:"result,required"` + // Whether the API call was successful + Success ControlRetentionFlagGetResponseEnvelopeSuccess `json:"success,required"` + JSON controlRetentionFlagGetResponseEnvelopeJSON `json:"-"` +} + +// controlRetentionFlagGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [ControlRetentionFlagGetResponseEnvelope] +type controlRetentionFlagGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ControlRetentionFlagGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r controlRetentionFlagGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ControlRetentionFlagGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON controlRetentionFlagGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// controlRetentionFlagGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [ControlRetentionFlagGetResponseEnvelopeErrors] +type controlRetentionFlagGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ControlRetentionFlagGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r controlRetentionFlagGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ControlRetentionFlagGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON controlRetentionFlagGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// controlRetentionFlagGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [ControlRetentionFlagGetResponseEnvelopeMessages] +type controlRetentionFlagGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ControlRetentionFlagGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r controlRetentionFlagGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ControlRetentionFlagGetResponseEnvelopeSuccess bool + +const ( + ControlRetentionFlagGetResponseEnvelopeSuccessTrue ControlRetentionFlagGetResponseEnvelopeSuccess = true +) diff --git a/logs/controlretentionflag_test.go b/logs/controlretentionflag_test.go new file mode 100644 index 00000000000..fa26ad3583f --- /dev/null +++ b/logs/controlretentionflag_test.go @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package logs_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/logs" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestControlRetentionFlagNew(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("user@example.com"), + ) + _, err := client.Logs.Control.Retention.Flag.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + logs.ControlRetentionFlagNewParams{ + Flag: cloudflare.F(true), + }, + ) + 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 TestControlRetentionFlagGet(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("user@example.com"), + ) + _, err := client.Logs.Control.Retention.Flag.Get(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/log.go b/logs/log.go similarity index 77% rename from log.go rename to logs/log.go index 21a6c9732a6..d45cc915bfd 100644 --- a/log.go +++ b/logs/log.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package logs import ( "github.com/cloudflare/cloudflare-go/option" @@ -12,9 +12,9 @@ import ( // directly, and instead use the [NewLogService] method instead. type LogService struct { Options []option.RequestOption - Control *LogControlService - Rayid *LogRayidService - Received *LogReceivedService + Control *ControlService + Rayid *RayidService + Received *ReceivedService } // NewLogService generates a new service that applies the given options to each @@ -23,8 +23,8 @@ type LogService struct { func NewLogService(opts ...option.RequestOption) (r *LogService) { r = &LogService{} r.Options = opts - r.Control = NewLogControlService(opts...) - r.Rayid = NewLogRayidService(opts...) - r.Received = NewLogReceivedService(opts...) + r.Control = NewControlService(opts...) + r.Rayid = NewRayidService(opts...) + r.Received = NewReceivedService(opts...) return } diff --git a/logs/rayid.go b/logs/rayid.go new file mode 100644 index 00000000000..25de94e3cb7 --- /dev/null +++ b/logs/rayid.go @@ -0,0 +1,103 @@ +// File generated from our OpenAPI spec by Stainless. + +package logs + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// RayidService 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 [NewRayidService] method instead. +type RayidService struct { + Options []option.RequestOption +} + +// NewRayidService 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 NewRayidService(opts ...option.RequestOption) (r *RayidService) { + r = &RayidService{} + r.Options = opts + return +} + +// The `/rayids` api route allows lookups by specific rayid. The rayids route will +// return zero, one, or more records (ray ids are not unique). +func (r *RayidService) Get(ctx context.Context, zoneIdentifier string, rayIdentifier string, query RayidGetParams, opts ...option.RequestOption) (res *RayidGetResponse, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("zones/%s/logs/rayids/%s", zoneIdentifier, rayIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +// Union satisfied by [shared.UnionString] or [logs.RayidGetResponseUnknown]. +type RayidGetResponse interface { + ImplementsLogsRayidGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RayidGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type RayidGetParams struct { + // The `/received` route by default returns a limited set of fields, and allows + // customers to override the default field set by specifying individual fields. The + // reasons for this are: 1. Most customers require only a small subset of fields, + // but that subset varies from customer to customer; 2. Flat schema is much easier + // to work with downstream (importing into BigTable etc); 3. Performance (time to + // process, file size). If `?fields=` is not specified, default field set is + // returned. This default field set may change at any time. When `?fields=` is + // provided, each record is returned with the specified fields. `fields` must be + // specified as a comma separated list without any whitespaces, and all fields must + // exist. The order in which fields are specified does not matter, and the order of + // fields in the response is not specified. + Fields param.Field[string] `query:"fields"` + // By default, timestamps in responses are returned as Unix nanosecond integers. + // The `?timestamps=` argument can be set to change the format in which response + // timestamps are returned. Possible values are: `unix`, `unixnano`, `rfc3339`. + // Note that `unix` and `unixnano` return timestamps as integers; `rfc3339` returns + // timestamps as strings. + Timestamps param.Field[RayidGetParamsTimestamps] `query:"timestamps"` +} + +// URLQuery serializes [RayidGetParams]'s query parameters as `url.Values`. +func (r RayidGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// By default, timestamps in responses are returned as Unix nanosecond integers. +// The `?timestamps=` argument can be set to change the format in which response +// timestamps are returned. Possible values are: `unix`, `unixnano`, `rfc3339`. +// Note that `unix` and `unixnano` return timestamps as integers; `rfc3339` returns +// timestamps as strings. +type RayidGetParamsTimestamps string + +const ( + RayidGetParamsTimestampsUnix RayidGetParamsTimestamps = "unix" + RayidGetParamsTimestampsUnixnano RayidGetParamsTimestamps = "unixnano" + RayidGetParamsTimestampsRfc3339 RayidGetParamsTimestamps = "rfc3339" +) diff --git a/logs/rayid_test.go b/logs/rayid_test.go new file mode 100644 index 00000000000..4a1c0d531a0 --- /dev/null +++ b/logs/rayid_test.go @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package logs_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/logs" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRayidGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Logs.Rayid.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "41ddf1740f67442d", + logs.RayidGetParams{ + Fields: cloudflare.F("ClientIP,RayID,EdgeStartTimestamp"), + Timestamps: cloudflare.F(logs.RayidGetParamsTimestampsUnixnano), + }, + ) + 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/logs/received.go b/logs/received.go new file mode 100644 index 00000000000..daaa434826d --- /dev/null +++ b/logs/received.go @@ -0,0 +1,156 @@ +// File generated from our OpenAPI spec by Stainless. + +package logs + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// ReceivedService 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 [NewReceivedService] method instead. +type ReceivedService struct { + Options []option.RequestOption + Fields *ReceivedFieldService +} + +// NewReceivedService 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 NewReceivedService(opts ...option.RequestOption) (r *ReceivedService) { + r = &ReceivedService{} + r.Options = opts + r.Fields = NewReceivedFieldService(opts...) + return +} + +// The `/received` api route allows customers to retrieve their edge HTTP logs. The +// basic access pattern is "give me all the logs for zone Z for minute M", where +// the minute M refers to the time records were received at Cloudflare's central +// data center. `start` is inclusive, and `end` is exclusive. Because of that, to +// get all data, at minutely cadence, starting at 10AM, the proper values are: +// `start=2018-05-20T10:00:00Z&end=2018-05-20T10:01:00Z`, then +// `start=2018-05-20T10:01:00Z&end=2018-05-20T10:02:00Z` and so on; the overlap +// will be handled properly. +func (r *ReceivedService) Get(ctx context.Context, zoneIdentifier string, query ReceivedGetParams, opts ...option.RequestOption) (res *ReceivedGetResponse, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("zones/%s/logs/received", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +// Union satisfied by [shared.UnionString] or [logs.ReceivedGetResponseUnknown]. +type ReceivedGetResponse interface { + ImplementsLogsReceivedGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ReceivedGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type ReceivedGetParams struct { + // Sets the (exclusive) end of the requested time frame. This can be a unix + // timestamp (in seconds or nanoseconds), or an absolute timestamp that conforms to + // RFC 3339. `end` must be at least five minutes earlier than now and must be later + // than `start`. Difference between `start` and `end` must be not greater than one + // hour. + End param.Field[ReceivedGetParamsEnd] `query:"end,required"` + // When `?count=` is provided, the response will contain up to `count` results. + // Since results are not sorted, you are likely to get different data for repeated + // requests. `count` must be an integer > 0. + Count param.Field[int64] `query:"count"` + // The `/received` route by default returns a limited set of fields, and allows + // customers to override the default field set by specifying individual fields. The + // reasons for this are: 1. Most customers require only a small subset of fields, + // but that subset varies from customer to customer; 2. Flat schema is much easier + // to work with downstream (importing into BigTable etc); 3. Performance (time to + // process, file size). If `?fields=` is not specified, default field set is + // returned. This default field set may change at any time. When `?fields=` is + // provided, each record is returned with the specified fields. `fields` must be + // specified as a comma separated list without any whitespaces, and all fields must + // exist. The order in which fields are specified does not matter, and the order of + // fields in the response is not specified. + Fields param.Field[string] `query:"fields"` + // When `?sample=` is provided, a sample of matching records is returned. If + // `sample=0.1` then 10% of records will be returned. Sampling is random: repeated + // calls will not only return different records, but likely will also vary slightly + // in number of returned records. When `?count=` is also specified, `count` is + // applied to the number of returned records, not the sampled records. So, with + // `sample=0.05` and `count=7`, when there is a total of 100 records available, + // approximately five will be returned. When there are 1000 records, seven will be + // returned. When there are 10,000 records, seven will be returned. + Sample param.Field[float64] `query:"sample"` + // Sets the (inclusive) beginning of the requested time frame. This can be a unix + // timestamp (in seconds or nanoseconds), or an absolute timestamp that conforms to + // RFC 3339. At this point in time, it cannot exceed a time in the past greater + // than seven days. + Start param.Field[ReceivedGetParamsStart] `query:"start"` + // By default, timestamps in responses are returned as Unix nanosecond integers. + // The `?timestamps=` argument can be set to change the format in which response + // timestamps are returned. Possible values are: `unix`, `unixnano`, `rfc3339`. + // Note that `unix` and `unixnano` return timestamps as integers; `rfc3339` returns + // timestamps as strings. + Timestamps param.Field[ReceivedGetParamsTimestamps] `query:"timestamps"` +} + +// URLQuery serializes [ReceivedGetParams]'s query parameters as `url.Values`. +func (r ReceivedGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Sets the (exclusive) end of the requested time frame. This can be a unix +// timestamp (in seconds or nanoseconds), or an absolute timestamp that conforms to +// RFC 3339. `end` must be at least five minutes earlier than now and must be later +// than `start`. Difference between `start` and `end` must be not greater than one +// hour. +// +// Satisfied by [shared.UnionString], [shared.UnionInt]. +type ReceivedGetParamsEnd interface { + ImplementsLogsReceivedGetParamsEnd() +} + +// Sets the (inclusive) beginning of the requested time frame. This can be a unix +// timestamp (in seconds or nanoseconds), or an absolute timestamp that conforms to +// RFC 3339. At this point in time, it cannot exceed a time in the past greater +// than seven days. +// +// Satisfied by [shared.UnionString], [shared.UnionInt]. +type ReceivedGetParamsStart interface { + ImplementsLogsReceivedGetParamsStart() +} + +// By default, timestamps in responses are returned as Unix nanosecond integers. +// The `?timestamps=` argument can be set to change the format in which response +// timestamps are returned. Possible values are: `unix`, `unixnano`, `rfc3339`. +// Note that `unix` and `unixnano` return timestamps as integers; `rfc3339` returns +// timestamps as strings. +type ReceivedGetParamsTimestamps string + +const ( + ReceivedGetParamsTimestampsUnix ReceivedGetParamsTimestamps = "unix" + ReceivedGetParamsTimestampsUnixnano ReceivedGetParamsTimestamps = "unixnano" + ReceivedGetParamsTimestampsRfc3339 ReceivedGetParamsTimestamps = "rfc3339" +) diff --git a/logs/received_test.go b/logs/received_test.go new file mode 100644 index 00000000000..17099206c62 --- /dev/null +++ b/logs/received_test.go @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package logs_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/logs" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestReceivedGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Logs.Received.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + logs.ReceivedGetParams{ + End: cloudflare.F[logs.ReceivedGetParamsEnd](shared.UnionString("2018-05-20T10:01:00Z")), + Count: cloudflare.F(int64(1)), + Fields: cloudflare.F("ClientIP,RayID,EdgeStartTimestamp"), + Sample: cloudflare.F(0.100000), + Start: cloudflare.F[logs.ReceivedGetParamsStart](shared.UnionString("2018-05-20T10:00:00Z")), + Timestamps: cloudflare.F(logs.ReceivedGetParamsTimestampsUnixnano), + }, + ) + 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/logs/receivedfield.go b/logs/receivedfield.go new file mode 100644 index 00000000000..e2932de1fc4 --- /dev/null +++ b/logs/receivedfield.go @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package logs + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ReceivedFieldService 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 [NewReceivedFieldService] method +// instead. +type ReceivedFieldService struct { + Options []option.RequestOption +} + +// NewReceivedFieldService 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 NewReceivedFieldService(opts ...option.RequestOption) (r *ReceivedFieldService) { + r = &ReceivedFieldService{} + r.Options = opts + return +} + +// Lists all fields available. The response is json object with key-value pairs, +// where keys are field names, and values are descriptions. +func (r *ReceivedFieldService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *ReceivedFieldGetResponse, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("zones/%s/logs/received/fields", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return +} + +type ReceivedFieldGetResponse struct { + Key string `json:"key"` + JSON receivedFieldGetResponseJSON `json:"-"` +} + +// receivedFieldGetResponseJSON contains the JSON metadata for the struct +// [ReceivedFieldGetResponse] +type receivedFieldGetResponseJSON struct { + Key apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ReceivedFieldGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r receivedFieldGetResponseJSON) RawJSON() string { + return r.raw +} diff --git a/logs/receivedfield_test.go b/logs/receivedfield_test.go new file mode 100644 index 00000000000..67099c56940 --- /dev/null +++ b/logs/receivedfield_test.go @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package logs_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestReceivedFieldGet(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("user@example.com"), + ) + _, err := client.Logs.Received.Fields.Get(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/magic_network_monitoring/aliases.go b/magic_network_monitoring/aliases.go new file mode 100644 index 00000000000..96acec95921 --- /dev/null +++ b/magic_network_monitoring/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_network_monitoring + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/magic_network_monitoring/config.go b/magic_network_monitoring/config.go new file mode 100644 index 00000000000..c2ee1f15bb3 --- /dev/null +++ b/magic_network_monitoring/config.go @@ -0,0 +1,531 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_network_monitoring + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ConfigService 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 [NewConfigService] method instead. +type ConfigService struct { + Options []option.RequestOption + Full *ConfigFullService +} + +// NewConfigService 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 NewConfigService(opts ...option.RequestOption) (r *ConfigService) { + r = &ConfigService{} + r.Options = opts + r.Full = NewConfigFullService(opts...) + return +} + +// Create a new network monitoring configuration. +func (r *ConfigService) New(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *MagicVisibilityMNMConfig, err error) { + opts = append(r.Options[:], opts...) + var env ConfigNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/mnm/config", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update an existing network monitoring configuration, requires the entire +// configuration to be updated at once. +func (r *ConfigService) Update(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *MagicVisibilityMNMConfig, err error) { + opts = append(r.Options[:], opts...) + var env ConfigUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/mnm/config", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete an existing network monitoring configuration. +func (r *ConfigService) Delete(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *MagicVisibilityMNMConfig, err error) { + opts = append(r.Options[:], opts...) + var env ConfigDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%v/mnm/config", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update fields in an existing network monitoring configuration. +func (r *ConfigService) Edit(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *MagicVisibilityMNMConfig, err error) { + opts = append(r.Options[:], opts...) + var env ConfigEditResponseEnvelope + path := fmt.Sprintf("accounts/%v/mnm/config", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists default sampling and router IPs for account. +func (r *ConfigService) Get(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *MagicVisibilityMNMConfig, err error) { + opts = append(r.Options[:], opts...) + var env ConfigGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/mnm/config", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type MagicVisibilityMNMConfig struct { + // Fallback sampling rate of flow messages being sent in packets per second. This + // should match the packet sampling rate configured on the router. + DefaultSampling float64 `json:"default_sampling,required"` + // The account name. + Name string `json:"name,required"` + RouterIPs []string `json:"router_ips,required"` + JSON magicVisibilityMNMConfigJSON `json:"-"` +} + +// magicVisibilityMNMConfigJSON contains the JSON metadata for the struct +// [MagicVisibilityMNMConfig] +type magicVisibilityMNMConfigJSON struct { + DefaultSampling apijson.Field + Name apijson.Field + RouterIPs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MagicVisibilityMNMConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r magicVisibilityMNMConfigJSON) RawJSON() string { + return r.raw +} + +type ConfigNewResponseEnvelope struct { + Errors []ConfigNewResponseEnvelopeErrors `json:"errors,required"` + Messages []ConfigNewResponseEnvelopeMessages `json:"messages,required"` + Result MagicVisibilityMNMConfig `json:"result,required"` + // Whether the API call was successful + Success ConfigNewResponseEnvelopeSuccess `json:"success,required"` + JSON configNewResponseEnvelopeJSON `json:"-"` +} + +// configNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [ConfigNewResponseEnvelope] +type configNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConfigNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// configNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ConfigNewResponseEnvelopeErrors] +type configNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ConfigNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// configNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ConfigNewResponseEnvelopeMessages] +type configNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConfigNewResponseEnvelopeSuccess bool + +const ( + ConfigNewResponseEnvelopeSuccessTrue ConfigNewResponseEnvelopeSuccess = true +) + +type ConfigUpdateResponseEnvelope struct { + Errors []ConfigUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []ConfigUpdateResponseEnvelopeMessages `json:"messages,required"` + Result MagicVisibilityMNMConfig `json:"result,required"` + // Whether the API call was successful + Success ConfigUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON configUpdateResponseEnvelopeJSON `json:"-"` +} + +// configUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [ConfigUpdateResponseEnvelope] +type configUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConfigUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// configUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ConfigUpdateResponseEnvelopeErrors] +type configUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ConfigUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// configUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ConfigUpdateResponseEnvelopeMessages] +type configUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConfigUpdateResponseEnvelopeSuccess bool + +const ( + ConfigUpdateResponseEnvelopeSuccessTrue ConfigUpdateResponseEnvelopeSuccess = true +) + +type ConfigDeleteResponseEnvelope struct { + Errors []ConfigDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []ConfigDeleteResponseEnvelopeMessages `json:"messages,required"` + Result MagicVisibilityMNMConfig `json:"result,required"` + // Whether the API call was successful + Success ConfigDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON configDeleteResponseEnvelopeJSON `json:"-"` +} + +// configDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [ConfigDeleteResponseEnvelope] +type configDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConfigDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// configDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ConfigDeleteResponseEnvelopeErrors] +type configDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ConfigDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// configDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ConfigDeleteResponseEnvelopeMessages] +type configDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConfigDeleteResponseEnvelopeSuccess bool + +const ( + ConfigDeleteResponseEnvelopeSuccessTrue ConfigDeleteResponseEnvelopeSuccess = true +) + +type ConfigEditResponseEnvelope struct { + Errors []ConfigEditResponseEnvelopeErrors `json:"errors,required"` + Messages []ConfigEditResponseEnvelopeMessages `json:"messages,required"` + Result MagicVisibilityMNMConfig `json:"result,required"` + // Whether the API call was successful + Success ConfigEditResponseEnvelopeSuccess `json:"success,required"` + JSON configEditResponseEnvelopeJSON `json:"-"` +} + +// configEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [ConfigEditResponseEnvelope] +type configEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConfigEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// configEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ConfigEditResponseEnvelopeErrors] +type configEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ConfigEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// configEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ConfigEditResponseEnvelopeMessages] +type configEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConfigEditResponseEnvelopeSuccess bool + +const ( + ConfigEditResponseEnvelopeSuccessTrue ConfigEditResponseEnvelopeSuccess = true +) + +type ConfigGetResponseEnvelope struct { + Errors []ConfigGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ConfigGetResponseEnvelopeMessages `json:"messages,required"` + Result MagicVisibilityMNMConfig `json:"result,required"` + // Whether the API call was successful + Success ConfigGetResponseEnvelopeSuccess `json:"success,required"` + JSON configGetResponseEnvelopeJSON `json:"-"` +} + +// configGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [ConfigGetResponseEnvelope] +type configGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConfigGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// configGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ConfigGetResponseEnvelopeErrors] +type configGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ConfigGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// configGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ConfigGetResponseEnvelopeMessages] +type configGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConfigGetResponseEnvelopeSuccess bool + +const ( + ConfigGetResponseEnvelopeSuccessTrue ConfigGetResponseEnvelopeSuccess = true +) diff --git a/magic_network_monitoring/config_test.go b/magic_network_monitoring/config_test.go new file mode 100644 index 00000000000..4fbed6223a2 --- /dev/null +++ b/magic_network_monitoring/config_test.go @@ -0,0 +1,134 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_network_monitoring_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestConfigNew(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("user@example.com"), + ) + _, err := client.MagicNetworkMonitoring.Configs.New(context.TODO(), "6f91088a406011ed95aed352566e8d4c") + 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 TestConfigUpdate(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("user@example.com"), + ) + _, err := client.MagicNetworkMonitoring.Configs.Update(context.TODO(), "6f91088a406011ed95aed352566e8d4c") + 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 TestConfigDelete(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("user@example.com"), + ) + _, err := client.MagicNetworkMonitoring.Configs.Delete(context.TODO(), "6f91088a406011ed95aed352566e8d4c") + 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 TestConfigEdit(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("user@example.com"), + ) + _, err := client.MagicNetworkMonitoring.Configs.Edit(context.TODO(), "6f91088a406011ed95aed352566e8d4c") + 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 TestConfigGet(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("user@example.com"), + ) + _, err := client.MagicNetworkMonitoring.Configs.Get(context.TODO(), "6f91088a406011ed95aed352566e8d4c") + 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/magic_network_monitoring/configfull.go b/magic_network_monitoring/configfull.go new file mode 100644 index 00000000000..b3cd1a42884 --- /dev/null +++ b/magic_network_monitoring/configfull.go @@ -0,0 +1,124 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_network_monitoring + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ConfigFullService 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 [NewConfigFullService] method instead. +type ConfigFullService struct { + Options []option.RequestOption +} + +// NewConfigFullService 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 NewConfigFullService(opts ...option.RequestOption) (r *ConfigFullService) { + r = &ConfigFullService{} + r.Options = opts + return +} + +// Lists default sampling, router IPs, and rules for account. +func (r *ConfigFullService) Get(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *MagicVisibilityMNMConfig, err error) { + opts = append(r.Options[:], opts...) + var env ConfigFullGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/mnm/config/full", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ConfigFullGetResponseEnvelope struct { + Errors []ConfigFullGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ConfigFullGetResponseEnvelopeMessages `json:"messages,required"` + Result MagicVisibilityMNMConfig `json:"result,required"` + // Whether the API call was successful + Success ConfigFullGetResponseEnvelopeSuccess `json:"success,required"` + JSON configFullGetResponseEnvelopeJSON `json:"-"` +} + +// configFullGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [ConfigFullGetResponseEnvelope] +type configFullGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigFullGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configFullGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConfigFullGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configFullGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// configFullGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ConfigFullGetResponseEnvelopeErrors] +type configFullGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigFullGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configFullGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ConfigFullGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON configFullGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// configFullGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ConfigFullGetResponseEnvelopeMessages] +type configFullGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConfigFullGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r configFullGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConfigFullGetResponseEnvelopeSuccess bool + +const ( + ConfigFullGetResponseEnvelopeSuccessTrue ConfigFullGetResponseEnvelopeSuccess = true +) diff --git a/magic_network_monitoring/configfull_test.go b/magic_network_monitoring/configfull_test.go new file mode 100644 index 00000000000..9b5dad569cb --- /dev/null +++ b/magic_network_monitoring/configfull_test.go @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_network_monitoring_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestConfigFullGet(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("user@example.com"), + ) + _, err := client.MagicNetworkMonitoring.Configs.Full.Get(context.TODO(), "6f91088a406011ed95aed352566e8d4c") + 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/magicnetworkmonitoring.go b/magic_network_monitoring/magicnetworkmonitoring.go similarity index 80% rename from magicnetworkmonitoring.go rename to magic_network_monitoring/magicnetworkmonitoring.go index 8e2747fe250..39e67bfa191 100644 --- a/magicnetworkmonitoring.go +++ b/magic_network_monitoring/magicnetworkmonitoring.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package magic_network_monitoring import ( "github.com/cloudflare/cloudflare-go/option" @@ -13,8 +13,8 @@ import ( // method instead. type MagicNetworkMonitoringService struct { Options []option.RequestOption - Configs *MagicNetworkMonitoringConfigService - Rules *MagicNetworkMonitoringRuleService + Configs *ConfigService + Rules *RuleService } // NewMagicNetworkMonitoringService generates a new service that applies the given @@ -23,7 +23,7 @@ type MagicNetworkMonitoringService struct { func NewMagicNetworkMonitoringService(opts ...option.RequestOption) (r *MagicNetworkMonitoringService) { r = &MagicNetworkMonitoringService{} r.Options = opts - r.Configs = NewMagicNetworkMonitoringConfigService(opts...) - r.Rules = NewMagicNetworkMonitoringRuleService(opts...) + r.Configs = NewConfigService(opts...) + r.Rules = NewRuleService(opts...) return } diff --git a/magic_network_monitoring/rule.go b/magic_network_monitoring/rule.go new file mode 100644 index 00000000000..9904058c022 --- /dev/null +++ b/magic_network_monitoring/rule.go @@ -0,0 +1,678 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_network_monitoring + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-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 + Advertisements *RuleAdvertisementService +} + +// 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.Advertisements = NewRuleAdvertisementService(opts...) + return +} + +// Create network monitoring rules for account. Currently only supports creating a +// single rule per API request. +func (r *RuleService) New(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *MagicVisibilityMNMRule, err error) { + opts = append(r.Options[:], opts...) + var env RuleNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/mnm/rules", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update network monitoring rules for account. +func (r *RuleService) Update(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *MagicVisibilityMNMRule, err error) { + opts = append(r.Options[:], opts...) + var env RuleUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/mnm/rules", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists network monitoring rules for account. +func (r *RuleService) List(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *[]MagicVisibilityMNMRule, err error) { + opts = append(r.Options[:], opts...) + var env RuleListResponseEnvelope + path := fmt.Sprintf("accounts/%v/mnm/rules", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a network monitoring rule for account. +func (r *RuleService) Delete(ctx context.Context, accountIdentifier interface{}, ruleIdentifier interface{}, opts ...option.RequestOption) (res *MagicVisibilityMNMRule, err error) { + opts = append(r.Options[:], opts...) + var env RuleDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%v/mnm/rules/%v", accountIdentifier, ruleIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update a network monitoring rule for account. +func (r *RuleService) Edit(ctx context.Context, accountIdentifier interface{}, ruleIdentifier interface{}, opts ...option.RequestOption) (res *MagicVisibilityMNMRule, err error) { + opts = append(r.Options[:], opts...) + var env RuleEditResponseEnvelope + path := fmt.Sprintf("accounts/%v/mnm/rules/%v", accountIdentifier, ruleIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List a single network monitoring rule for account. +func (r *RuleService) Get(ctx context.Context, accountIdentifier interface{}, ruleIdentifier interface{}, opts ...option.RequestOption) (res *MagicVisibilityMNMRule, err error) { + opts = append(r.Options[:], opts...) + var env RuleGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/mnm/rules/%v", accountIdentifier, ruleIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type MagicVisibilityMNMRule struct { + // Toggle on if you would like Cloudflare to automatically advertise the IP + // Prefixes within the rule via Magic Transit when the rule is triggered. Only + // available for users of Magic Transit. + AutomaticAdvertisement bool `json:"automatic_advertisement,required,nullable"` + // The amount of time that the rule threshold must be exceeded to send an alert + // notification. The final value must be equivalent to one of the following 8 + // values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is + // AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at + // least one unit must be provided. + Duration string `json:"duration,required"` + // The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, + // underscore (\_), dash (-), period (.), and tilde (~). You can’t have a space in + // the rule name. Max 256 characters. + Name string `json:"name,required"` + Prefixes []string `json:"prefixes,required"` + ID interface{} `json:"id"` + // The number of bits per second for the rule. When this value is exceeded for the + // set duration, an alert notification is sent. Minimum of 1 and no maximum. + BandwidthThreshold float64 `json:"bandwidth_threshold"` + // The number of packets per second for the rule. When this value is exceeded for + // the set duration, an alert notification is sent. Minimum of 1 and no maximum. + PacketThreshold float64 `json:"packet_threshold"` + JSON magicVisibilityMNMRuleJSON `json:"-"` +} + +// magicVisibilityMNMRuleJSON contains the JSON metadata for the struct +// [MagicVisibilityMNMRule] +type magicVisibilityMNMRuleJSON struct { + AutomaticAdvertisement apijson.Field + Duration apijson.Field + Name apijson.Field + Prefixes apijson.Field + ID apijson.Field + BandwidthThreshold apijson.Field + PacketThreshold apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MagicVisibilityMNMRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r magicVisibilityMNMRuleJSON) RawJSON() string { + return r.raw +} + +type RuleNewResponseEnvelope struct { + Errors []RuleNewResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleNewResponseEnvelopeMessages `json:"messages,required"` + Result MagicVisibilityMNMRule `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleNewResponseEnvelopeSuccess `json:"success,required"` + JSON ruleNewResponseEnvelopeJSON `json:"-"` +} + +// ruleNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleNewResponseEnvelope] +type ruleNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleNewResponseEnvelopeErrors] +type ruleNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleNewResponseEnvelopeMessages] +type ruleNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleNewResponseEnvelopeSuccess bool + +const ( + RuleNewResponseEnvelopeSuccessTrue RuleNewResponseEnvelopeSuccess = true +) + +type RuleUpdateResponseEnvelope struct { + Errors []RuleUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleUpdateResponseEnvelopeMessages `json:"messages,required"` + Result MagicVisibilityMNMRule `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON ruleUpdateResponseEnvelopeJSON `json:"-"` +} + +// ruleUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleUpdateResponseEnvelope] +type ruleUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleUpdateResponseEnvelopeErrors] +type ruleUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleUpdateResponseEnvelopeMessages] +type ruleUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleUpdateResponseEnvelopeSuccess bool + +const ( + RuleUpdateResponseEnvelopeSuccessTrue RuleUpdateResponseEnvelopeSuccess = true +) + +type RuleListResponseEnvelope struct { + Errors []RuleListResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleListResponseEnvelopeMessages `json:"messages,required"` + Result []MagicVisibilityMNMRule `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo RuleListResponseEnvelopeResultInfo `json:"result_info"` + JSON ruleListResponseEnvelopeJSON `json:"-"` +} + +// ruleListResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleListResponseEnvelope] +type ruleListResponseEnvelopeJSON 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 *RuleListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleListResponseEnvelopeErrors] +type ruleListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleListResponseEnvelopeMessages] +type ruleListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleListResponseEnvelopeSuccess bool + +const ( + RuleListResponseEnvelopeSuccessTrue RuleListResponseEnvelopeSuccess = true +) + +type RuleListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON ruleListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// ruleListResponseEnvelopeResultInfoJSON contains the JSON metadata for the struct +// [RuleListResponseEnvelopeResultInfo] +type ruleListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type RuleDeleteResponseEnvelope struct { + Errors []RuleDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleDeleteResponseEnvelopeMessages `json:"messages,required"` + Result MagicVisibilityMNMRule `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON ruleDeleteResponseEnvelopeJSON `json:"-"` +} + +// ruleDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleDeleteResponseEnvelope] +type ruleDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleDeleteResponseEnvelopeErrors] +type ruleDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleDeleteResponseEnvelopeMessages] +type ruleDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleDeleteResponseEnvelopeSuccess bool + +const ( + RuleDeleteResponseEnvelopeSuccessTrue RuleDeleteResponseEnvelopeSuccess = true +) + +type RuleEditResponseEnvelope struct { + Errors []RuleEditResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleEditResponseEnvelopeMessages `json:"messages,required"` + Result MagicVisibilityMNMRule `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleEditResponseEnvelopeSuccess `json:"success,required"` + JSON ruleEditResponseEnvelopeJSON `json:"-"` +} + +// ruleEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleEditResponseEnvelope] +type ruleEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleEditResponseEnvelopeErrors] +type ruleEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleEditResponseEnvelopeMessages] +type ruleEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleEditResponseEnvelopeSuccess bool + +const ( + RuleEditResponseEnvelopeSuccessTrue RuleEditResponseEnvelopeSuccess = true +) + +type RuleGetResponseEnvelope struct { + Errors []RuleGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleGetResponseEnvelopeMessages `json:"messages,required"` + Result MagicVisibilityMNMRule `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleGetResponseEnvelopeSuccess `json:"success,required"` + JSON ruleGetResponseEnvelopeJSON `json:"-"` +} + +// ruleGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleGetResponseEnvelope] +type ruleGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleGetResponseEnvelopeErrors] +type ruleGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleGetResponseEnvelopeMessages] +type ruleGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleGetResponseEnvelopeSuccess bool + +const ( + RuleGetResponseEnvelopeSuccessTrue RuleGetResponseEnvelopeSuccess = true +) diff --git a/magic_network_monitoring/rule_test.go b/magic_network_monitoring/rule_test.go new file mode 100644 index 00000000000..36fc5c5fc20 --- /dev/null +++ b/magic_network_monitoring/rule_test.go @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_network_monitoring_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRuleNew(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("user@example.com"), + ) + _, err := client.MagicNetworkMonitoring.Rules.New(context.TODO(), "6f91088a406011ed95aed352566e8d4c") + 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 TestRuleUpdate(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("user@example.com"), + ) + _, err := client.MagicNetworkMonitoring.Rules.Update(context.TODO(), "6f91088a406011ed95aed352566e8d4c") + 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 TestRuleList(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("user@example.com"), + ) + _, err := client.MagicNetworkMonitoring.Rules.List(context.TODO(), "6f91088a406011ed95aed352566e8d4c") + 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 TestRuleDelete(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("user@example.com"), + ) + _, err := client.MagicNetworkMonitoring.Rules.Delete( + context.TODO(), + "6f91088a406011ed95aed352566e8d4c", + "2890e6fa406311ed9b5a23f70f6fb8cf", + ) + 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 TestRuleEdit(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("user@example.com"), + ) + _, err := client.MagicNetworkMonitoring.Rules.Edit( + context.TODO(), + "6f91088a406011ed95aed352566e8d4c", + "2890e6fa406311ed9b5a23f70f6fb8cf", + ) + 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 TestRuleGet(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("user@example.com"), + ) + _, err := client.MagicNetworkMonitoring.Rules.Get( + context.TODO(), + "6f91088a406011ed95aed352566e8d4c", + "2890e6fa406311ed9b5a23f70f6fb8cf", + ) + 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/magic_network_monitoring/ruleadvertisement.go b/magic_network_monitoring/ruleadvertisement.go new file mode 100644 index 00000000000..db517cd9ba7 --- /dev/null +++ b/magic_network_monitoring/ruleadvertisement.go @@ -0,0 +1,149 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_network_monitoring + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// RuleAdvertisementService 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 [NewRuleAdvertisementService] method +// instead. +type RuleAdvertisementService struct { + Options []option.RequestOption +} + +// NewRuleAdvertisementService 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 NewRuleAdvertisementService(opts ...option.RequestOption) (r *RuleAdvertisementService) { + r = &RuleAdvertisementService{} + r.Options = opts + return +} + +// Update advertisement for rule. +func (r *RuleAdvertisementService) Edit(ctx context.Context, accountIdentifier interface{}, ruleIdentifier interface{}, opts ...option.RequestOption) (res *MagicVisibilityMNMRuleAdvertisable, err error) { + opts = append(r.Options[:], opts...) + var env RuleAdvertisementEditResponseEnvelope + path := fmt.Sprintf("accounts/%v/mnm/rules/%v/advertisement", accountIdentifier, ruleIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type MagicVisibilityMNMRuleAdvertisable struct { + // Toggle on if you would like Cloudflare to automatically advertise the IP + // Prefixes within the rule via Magic Transit when the rule is triggered. Only + // available for users of Magic Transit. + AutomaticAdvertisement bool `json:"automatic_advertisement,required,nullable"` + JSON magicVisibilityMNMRuleAdvertisableJSON `json:"-"` +} + +// magicVisibilityMNMRuleAdvertisableJSON contains the JSON metadata for the struct +// [MagicVisibilityMNMRuleAdvertisable] +type magicVisibilityMNMRuleAdvertisableJSON struct { + AutomaticAdvertisement apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MagicVisibilityMNMRuleAdvertisable) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r magicVisibilityMNMRuleAdvertisableJSON) RawJSON() string { + return r.raw +} + +type RuleAdvertisementEditResponseEnvelope struct { + Errors []RuleAdvertisementEditResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleAdvertisementEditResponseEnvelopeMessages `json:"messages,required"` + Result MagicVisibilityMNMRuleAdvertisable `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleAdvertisementEditResponseEnvelopeSuccess `json:"success,required"` + JSON ruleAdvertisementEditResponseEnvelopeJSON `json:"-"` +} + +// ruleAdvertisementEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [RuleAdvertisementEditResponseEnvelope] +type ruleAdvertisementEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleAdvertisementEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleAdvertisementEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleAdvertisementEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleAdvertisementEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleAdvertisementEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [RuleAdvertisementEditResponseEnvelopeErrors] +type ruleAdvertisementEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleAdvertisementEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleAdvertisementEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleAdvertisementEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleAdvertisementEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleAdvertisementEditResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [RuleAdvertisementEditResponseEnvelopeMessages] +type ruleAdvertisementEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleAdvertisementEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleAdvertisementEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleAdvertisementEditResponseEnvelopeSuccess bool + +const ( + RuleAdvertisementEditResponseEnvelopeSuccessTrue RuleAdvertisementEditResponseEnvelopeSuccess = true +) diff --git a/magic_network_monitoring/ruleadvertisement_test.go b/magic_network_monitoring/ruleadvertisement_test.go new file mode 100644 index 00000000000..da4cefe21aa --- /dev/null +++ b/magic_network_monitoring/ruleadvertisement_test.go @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_network_monitoring_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRuleAdvertisementEdit(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("user@example.com"), + ) + _, err := client.MagicNetworkMonitoring.Rules.Advertisements.Edit( + context.TODO(), + "6f91088a406011ed95aed352566e8d4c", + "2890e6fa406311ed9b5a23f70f6fb8cf", + ) + 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/magic_transit/aliases.go b/magic_transit/aliases.go new file mode 100644 index 00000000000..877af154fd4 --- /dev/null +++ b/magic_transit/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_transit + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/magic_transit/cfinterconnect.go b/magic_transit/cfinterconnect.go new file mode 100644 index 00000000000..6a6a31f8a90 --- /dev/null +++ b/magic_transit/cfinterconnect.go @@ -0,0 +1,571 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_transit + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// CfInterconnectService 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 [NewCfInterconnectService] method +// instead. +type CfInterconnectService struct { + Options []option.RequestOption +} + +// NewCfInterconnectService 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 NewCfInterconnectService(opts ...option.RequestOption) (r *CfInterconnectService) { + r = &CfInterconnectService{} + r.Options = opts + return +} + +// Updates a specific interconnect associated with an account. Use +// `?validate_only=true` as an optional query parameter to only run validation +// without persisting changes. +func (r *CfInterconnectService) Update(ctx context.Context, accountIdentifier string, tunnelIdentifier string, body CfInterconnectUpdateParams, opts ...option.RequestOption) (res *CfInterconnectUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env CfInterconnectUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/cf_interconnects/%s", accountIdentifier, tunnelIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists interconnects associated with an account. +func (r *CfInterconnectService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *CfInterconnectListResponse, err error) { + opts = append(r.Options[:], opts...) + var env CfInterconnectListResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/cf_interconnects", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists details for a specific interconnect. +func (r *CfInterconnectService) Get(ctx context.Context, accountIdentifier string, tunnelIdentifier string, opts ...option.RequestOption) (res *CfInterconnectGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env CfInterconnectGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/cf_interconnects/%s", accountIdentifier, tunnelIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type CfInterconnectUpdateResponse struct { + Modified bool `json:"modified"` + ModifiedInterconnect interface{} `json:"modified_interconnect"` + JSON cfInterconnectUpdateResponseJSON `json:"-"` +} + +// cfInterconnectUpdateResponseJSON contains the JSON metadata for the struct +// [CfInterconnectUpdateResponse] +type cfInterconnectUpdateResponseJSON struct { + Modified apijson.Field + ModifiedInterconnect apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CfInterconnectUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cfInterconnectUpdateResponseJSON) RawJSON() string { + return r.raw +} + +type CfInterconnectListResponse struct { + Interconnects []CfInterconnectListResponseInterconnect `json:"interconnects"` + JSON cfInterconnectListResponseJSON `json:"-"` +} + +// cfInterconnectListResponseJSON contains the JSON metadata for the struct +// [CfInterconnectListResponse] +type cfInterconnectListResponseJSON struct { + Interconnects apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CfInterconnectListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cfInterconnectListResponseJSON) RawJSON() string { + return r.raw +} + +type CfInterconnectListResponseInterconnect struct { + // Tunnel identifier tag. + ID string `json:"id"` + // The name of the interconnect. The name cannot share a name with other tunnels. + ColoName string `json:"colo_name"` + // The date and time the tunnel was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // An optional description of the interconnect. + Description string `json:"description"` + // The configuration specific to GRE interconnects. + GRE CfInterconnectListResponseInterconnectsGRE `json:"gre"` + HealthCheck CfInterconnectListResponseInterconnectsHealthCheck `json:"health_check"` + // A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + // of the tunnel. Select the subnet from the following private IP space: + // 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + InterfaceAddress string `json:"interface_address"` + // The date and time the tunnel was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // The Maximum Transmission Unit (MTU) in bytes for the interconnect. The minimum + // value is 576. + Mtu int64 `json:"mtu"` + // The name of the interconnect. The name cannot share a name with other tunnels. + Name string `json:"name"` + JSON cfInterconnectListResponseInterconnectJSON `json:"-"` +} + +// cfInterconnectListResponseInterconnectJSON contains the JSON metadata for the +// struct [CfInterconnectListResponseInterconnect] +type cfInterconnectListResponseInterconnectJSON struct { + ID apijson.Field + ColoName apijson.Field + CreatedOn apijson.Field + Description apijson.Field + GRE apijson.Field + HealthCheck apijson.Field + InterfaceAddress apijson.Field + ModifiedOn apijson.Field + Mtu apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CfInterconnectListResponseInterconnect) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cfInterconnectListResponseInterconnectJSON) RawJSON() string { + return r.raw +} + +// The configuration specific to GRE interconnects. +type CfInterconnectListResponseInterconnectsGRE struct { + // The IP address assigned to the Cloudflare side of the GRE tunnel created as part + // of the Interconnect. + CloudflareEndpoint string `json:"cloudflare_endpoint"` + JSON cfInterconnectListResponseInterconnectsGREJSON `json:"-"` +} + +// cfInterconnectListResponseInterconnectsGREJSON contains the JSON metadata for +// the struct [CfInterconnectListResponseInterconnectsGRE] +type cfInterconnectListResponseInterconnectsGREJSON struct { + CloudflareEndpoint apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CfInterconnectListResponseInterconnectsGRE) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cfInterconnectListResponseInterconnectsGREJSON) RawJSON() string { + return r.raw +} + +type CfInterconnectListResponseInterconnectsHealthCheck struct { + // Determines whether to run healthchecks for a tunnel. + Enabled bool `json:"enabled"` + // How frequent the health check is run. The default value is `mid`. + Rate CfInterconnectListResponseInterconnectsHealthCheckRate `json:"rate"` + // The destination address in a request type health check. After the healthcheck is + // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded + // to this address. This field defaults to `customer_gre_endpoint address`. + Target string `json:"target"` + // The type of healthcheck to run, reply or request. The default value is `reply`. + Type CfInterconnectListResponseInterconnectsHealthCheckType `json:"type"` + JSON cfInterconnectListResponseInterconnectsHealthCheckJSON `json:"-"` +} + +// cfInterconnectListResponseInterconnectsHealthCheckJSON contains the JSON +// metadata for the struct [CfInterconnectListResponseInterconnectsHealthCheck] +type cfInterconnectListResponseInterconnectsHealthCheckJSON struct { + Enabled apijson.Field + Rate apijson.Field + Target apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CfInterconnectListResponseInterconnectsHealthCheck) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cfInterconnectListResponseInterconnectsHealthCheckJSON) RawJSON() string { + return r.raw +} + +// How frequent the health check is run. The default value is `mid`. +type CfInterconnectListResponseInterconnectsHealthCheckRate string + +const ( + CfInterconnectListResponseInterconnectsHealthCheckRateLow CfInterconnectListResponseInterconnectsHealthCheckRate = "low" + CfInterconnectListResponseInterconnectsHealthCheckRateMid CfInterconnectListResponseInterconnectsHealthCheckRate = "mid" + CfInterconnectListResponseInterconnectsHealthCheckRateHigh CfInterconnectListResponseInterconnectsHealthCheckRate = "high" +) + +// The type of healthcheck to run, reply or request. The default value is `reply`. +type CfInterconnectListResponseInterconnectsHealthCheckType string + +const ( + CfInterconnectListResponseInterconnectsHealthCheckTypeReply CfInterconnectListResponseInterconnectsHealthCheckType = "reply" + CfInterconnectListResponseInterconnectsHealthCheckTypeRequest CfInterconnectListResponseInterconnectsHealthCheckType = "request" +) + +type CfInterconnectGetResponse struct { + Interconnect interface{} `json:"interconnect"` + JSON cfInterconnectGetResponseJSON `json:"-"` +} + +// cfInterconnectGetResponseJSON contains the JSON metadata for the struct +// [CfInterconnectGetResponse] +type cfInterconnectGetResponseJSON struct { + Interconnect apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CfInterconnectGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cfInterconnectGetResponseJSON) RawJSON() string { + return r.raw +} + +type CfInterconnectUpdateParams struct { + // An optional description of the interconnect. + Description param.Field[string] `json:"description"` + // The configuration specific to GRE interconnects. + GRE param.Field[CfInterconnectUpdateParamsGRE] `json:"gre"` + HealthCheck param.Field[CfInterconnectUpdateParamsHealthCheck] `json:"health_check"` + // A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + // of the tunnel. Select the subnet from the following private IP space: + // 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + InterfaceAddress param.Field[string] `json:"interface_address"` + // The Maximum Transmission Unit (MTU) in bytes for the interconnect. The minimum + // value is 576. + Mtu param.Field[int64] `json:"mtu"` +} + +func (r CfInterconnectUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The configuration specific to GRE interconnects. +type CfInterconnectUpdateParamsGRE struct { + // The IP address assigned to the Cloudflare side of the GRE tunnel created as part + // of the Interconnect. + CloudflareEndpoint param.Field[string] `json:"cloudflare_endpoint"` +} + +func (r CfInterconnectUpdateParamsGRE) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type CfInterconnectUpdateParamsHealthCheck struct { + // Determines whether to run healthchecks for a tunnel. + Enabled param.Field[bool] `json:"enabled"` + // How frequent the health check is run. The default value is `mid`. + Rate param.Field[CfInterconnectUpdateParamsHealthCheckRate] `json:"rate"` + // The destination address in a request type health check. After the healthcheck is + // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded + // to this address. This field defaults to `customer_gre_endpoint address`. + Target param.Field[string] `json:"target"` + // The type of healthcheck to run, reply or request. The default value is `reply`. + Type param.Field[CfInterconnectUpdateParamsHealthCheckType] `json:"type"` +} + +func (r CfInterconnectUpdateParamsHealthCheck) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// How frequent the health check is run. The default value is `mid`. +type CfInterconnectUpdateParamsHealthCheckRate string + +const ( + CfInterconnectUpdateParamsHealthCheckRateLow CfInterconnectUpdateParamsHealthCheckRate = "low" + CfInterconnectUpdateParamsHealthCheckRateMid CfInterconnectUpdateParamsHealthCheckRate = "mid" + CfInterconnectUpdateParamsHealthCheckRateHigh CfInterconnectUpdateParamsHealthCheckRate = "high" +) + +// The type of healthcheck to run, reply or request. The default value is `reply`. +type CfInterconnectUpdateParamsHealthCheckType string + +const ( + CfInterconnectUpdateParamsHealthCheckTypeReply CfInterconnectUpdateParamsHealthCheckType = "reply" + CfInterconnectUpdateParamsHealthCheckTypeRequest CfInterconnectUpdateParamsHealthCheckType = "request" +) + +type CfInterconnectUpdateResponseEnvelope struct { + Errors []CfInterconnectUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []CfInterconnectUpdateResponseEnvelopeMessages `json:"messages,required"` + Result CfInterconnectUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success CfInterconnectUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON cfInterconnectUpdateResponseEnvelopeJSON `json:"-"` +} + +// cfInterconnectUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [CfInterconnectUpdateResponseEnvelope] +type cfInterconnectUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CfInterconnectUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cfInterconnectUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CfInterconnectUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON cfInterconnectUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// cfInterconnectUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [CfInterconnectUpdateResponseEnvelopeErrors] +type cfInterconnectUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CfInterconnectUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cfInterconnectUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CfInterconnectUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON cfInterconnectUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// cfInterconnectUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [CfInterconnectUpdateResponseEnvelopeMessages] +type cfInterconnectUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CfInterconnectUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cfInterconnectUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CfInterconnectUpdateResponseEnvelopeSuccess bool + +const ( + CfInterconnectUpdateResponseEnvelopeSuccessTrue CfInterconnectUpdateResponseEnvelopeSuccess = true +) + +type CfInterconnectListResponseEnvelope struct { + Errors []CfInterconnectListResponseEnvelopeErrors `json:"errors,required"` + Messages []CfInterconnectListResponseEnvelopeMessages `json:"messages,required"` + Result CfInterconnectListResponse `json:"result,required"` + // Whether the API call was successful + Success CfInterconnectListResponseEnvelopeSuccess `json:"success,required"` + JSON cfInterconnectListResponseEnvelopeJSON `json:"-"` +} + +// cfInterconnectListResponseEnvelopeJSON contains the JSON metadata for the struct +// [CfInterconnectListResponseEnvelope] +type cfInterconnectListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CfInterconnectListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cfInterconnectListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CfInterconnectListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON cfInterconnectListResponseEnvelopeErrorsJSON `json:"-"` +} + +// cfInterconnectListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [CfInterconnectListResponseEnvelopeErrors] +type cfInterconnectListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CfInterconnectListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cfInterconnectListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CfInterconnectListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON cfInterconnectListResponseEnvelopeMessagesJSON `json:"-"` +} + +// cfInterconnectListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [CfInterconnectListResponseEnvelopeMessages] +type cfInterconnectListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CfInterconnectListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cfInterconnectListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CfInterconnectListResponseEnvelopeSuccess bool + +const ( + CfInterconnectListResponseEnvelopeSuccessTrue CfInterconnectListResponseEnvelopeSuccess = true +) + +type CfInterconnectGetResponseEnvelope struct { + Errors []CfInterconnectGetResponseEnvelopeErrors `json:"errors,required"` + Messages []CfInterconnectGetResponseEnvelopeMessages `json:"messages,required"` + Result CfInterconnectGetResponse `json:"result,required"` + // Whether the API call was successful + Success CfInterconnectGetResponseEnvelopeSuccess `json:"success,required"` + JSON cfInterconnectGetResponseEnvelopeJSON `json:"-"` +} + +// cfInterconnectGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [CfInterconnectGetResponseEnvelope] +type cfInterconnectGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CfInterconnectGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cfInterconnectGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CfInterconnectGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON cfInterconnectGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// cfInterconnectGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [CfInterconnectGetResponseEnvelopeErrors] +type cfInterconnectGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CfInterconnectGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cfInterconnectGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CfInterconnectGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON cfInterconnectGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// cfInterconnectGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [CfInterconnectGetResponseEnvelopeMessages] +type cfInterconnectGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CfInterconnectGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r cfInterconnectGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CfInterconnectGetResponseEnvelopeSuccess bool + +const ( + CfInterconnectGetResponseEnvelopeSuccessTrue CfInterconnectGetResponseEnvelopeSuccess = true +) diff --git a/magic_transit/cfinterconnect_test.go b/magic_transit/cfinterconnect_test.go new file mode 100644 index 00000000000..7e2895f7d93 --- /dev/null +++ b/magic_transit/cfinterconnect_test.go @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_transit_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/magic_transit" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestCfInterconnectUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.MagicTransit.CfInterconnects.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + magic_transit.CfInterconnectUpdateParams{ + Description: cloudflare.F("Tunnel for Interconnect to ORD"), + GRE: cloudflare.F(magic_transit.CfInterconnectUpdateParamsGRE{ + CloudflareEndpoint: cloudflare.F("203.0.113.1"), + }), + HealthCheck: cloudflare.F(magic_transit.CfInterconnectUpdateParamsHealthCheck{ + Enabled: cloudflare.F(true), + Rate: cloudflare.F(magic_transit.CfInterconnectUpdateParamsHealthCheckRateLow), + Target: cloudflare.F("203.0.113.1"), + Type: cloudflare.F(magic_transit.CfInterconnectUpdateParamsHealthCheckTypeRequest), + }), + InterfaceAddress: cloudflare.F("192.0.2.0/31"), + Mtu: cloudflare.F(int64(0)), + }, + ) + 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 TestCfInterconnectList(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("user@example.com"), + ) + _, err := client.MagicTransit.CfInterconnects.List(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()) + } +} + +func TestCfInterconnectGet(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("user@example.com"), + ) + _, err := client.MagicTransit.CfInterconnects.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "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/magic_transit/gretunnel.go b/magic_transit/gretunnel.go new file mode 100644 index 00000000000..9e6a5a60f29 --- /dev/null +++ b/magic_transit/gretunnel.go @@ -0,0 +1,960 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_transit + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// GRETunnelService 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 [NewGRETunnelService] method instead. +type GRETunnelService struct { + Options []option.RequestOption +} + +// NewGRETunnelService 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 NewGRETunnelService(opts ...option.RequestOption) (r *GRETunnelService) { + r = &GRETunnelService{} + r.Options = opts + return +} + +// Creates new GRE tunnels. Use `?validate_only=true` as an optional query +// parameter to only run validation without persisting changes. +func (r *GRETunnelService) New(ctx context.Context, accountIdentifier string, body GRETunnelNewParams, opts ...option.RequestOption) (res *GRETunnelNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env GRETunnelNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/gre_tunnels", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a specific GRE tunnel. Use `?validate_only=true` as an optional query +// parameter to only run validation without persisting changes. +func (r *GRETunnelService) Update(ctx context.Context, accountIdentifier string, tunnelIdentifier string, body GRETunnelUpdateParams, opts ...option.RequestOption) (res *GRETunnelUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env GRETunnelUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/gre_tunnels/%s", accountIdentifier, tunnelIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists GRE tunnels associated with an account. +func (r *GRETunnelService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *GRETunnelListResponse, err error) { + opts = append(r.Options[:], opts...) + var env GRETunnelListResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/gre_tunnels", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Disables and removes a specific static GRE tunnel. Use `?validate_only=true` as +// an optional query parameter to only run validation without persisting changes. +func (r *GRETunnelService) Delete(ctx context.Context, accountIdentifier string, tunnelIdentifier string, opts ...option.RequestOption) (res *GRETunnelDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env GRETunnelDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/gre_tunnels/%s", accountIdentifier, tunnelIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists informtion for a specific GRE tunnel. +func (r *GRETunnelService) Get(ctx context.Context, accountIdentifier string, tunnelIdentifier string, opts ...option.RequestOption) (res *GRETunnelGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env GRETunnelGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/gre_tunnels/%s", accountIdentifier, tunnelIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type GRETunnelNewResponse struct { + GRETunnels []GRETunnelNewResponseGRETunnel `json:"gre_tunnels"` + JSON greTunnelNewResponseJSON `json:"-"` +} + +// greTunnelNewResponseJSON contains the JSON metadata for the struct +// [GRETunnelNewResponse] +type greTunnelNewResponseJSON struct { + GRETunnels apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelNewResponseJSON) RawJSON() string { + return r.raw +} + +type GRETunnelNewResponseGRETunnel struct { + // The IP address assigned to the Cloudflare side of the GRE tunnel. + CloudflareGREEndpoint string `json:"cloudflare_gre_endpoint,required"` + // The IP address assigned to the customer side of the GRE tunnel. + CustomerGREEndpoint string `json:"customer_gre_endpoint,required"` + // A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + // of the tunnel. Select the subnet from the following private IP space: + // 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + InterfaceAddress string `json:"interface_address,required"` + // The name of the tunnel. The name cannot contain spaces or special characters, + // must be 15 characters or less, and cannot share a name with another GRE tunnel. + Name string `json:"name,required"` + // Tunnel identifier tag. + ID string `json:"id"` + // The date and time the tunnel was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // An optional description of the GRE tunnel. + Description string `json:"description"` + HealthCheck GRETunnelNewResponseGRETunnelsHealthCheck `json:"health_check"` + // The date and time the tunnel was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value + // is 576. + Mtu int64 `json:"mtu"` + // Time To Live (TTL) in number of hops of the GRE tunnel. + TTL int64 `json:"ttl"` + JSON greTunnelNewResponseGRETunnelJSON `json:"-"` +} + +// greTunnelNewResponseGRETunnelJSON contains the JSON metadata for the struct +// [GRETunnelNewResponseGRETunnel] +type greTunnelNewResponseGRETunnelJSON struct { + CloudflareGREEndpoint apijson.Field + CustomerGREEndpoint apijson.Field + InterfaceAddress apijson.Field + Name apijson.Field + ID apijson.Field + CreatedOn apijson.Field + Description apijson.Field + HealthCheck apijson.Field + ModifiedOn apijson.Field + Mtu apijson.Field + TTL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelNewResponseGRETunnel) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelNewResponseGRETunnelJSON) RawJSON() string { + return r.raw +} + +type GRETunnelNewResponseGRETunnelsHealthCheck struct { + // The direction of the flow of the healthcheck. Either unidirectional, where the + // probe comes to you via the tunnel and the result comes back to Cloudflare via + // the open Internet, or bidirectional where both the probe and result come and go + // via the tunnel. Note in the case of bidirecitonal healthchecks, the target field + // in health_check is ignored as the interface_address is used to send traffic into + // the tunnel. + Direction GRETunnelNewResponseGRETunnelsHealthCheckDirection `json:"direction"` + // Determines whether to run healthchecks for a tunnel. + Enabled bool `json:"enabled"` + // How frequent the health check is run. The default value is `mid`. + Rate GRETunnelNewResponseGRETunnelsHealthCheckRate `json:"rate"` + // The destination address in a request type health check. After the healthcheck is + // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded + // to this address. This field defaults to `customer_gre_endpoint address`. This + // field is ignored for bidirectional healthchecks as the interface_address (not + // assigned to the Cloudflare side of the tunnel) is used as the target. + Target string `json:"target"` + // The type of healthcheck to run, reply or request. The default value is `reply`. + Type GRETunnelNewResponseGRETunnelsHealthCheckType `json:"type"` + JSON greTunnelNewResponseGRETunnelsHealthCheckJSON `json:"-"` +} + +// greTunnelNewResponseGRETunnelsHealthCheckJSON contains the JSON metadata for the +// struct [GRETunnelNewResponseGRETunnelsHealthCheck] +type greTunnelNewResponseGRETunnelsHealthCheckJSON struct { + Direction apijson.Field + Enabled apijson.Field + Rate apijson.Field + Target apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelNewResponseGRETunnelsHealthCheck) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelNewResponseGRETunnelsHealthCheckJSON) RawJSON() string { + return r.raw +} + +// The direction of the flow of the healthcheck. Either unidirectional, where the +// probe comes to you via the tunnel and the result comes back to Cloudflare via +// the open Internet, or bidirectional where both the probe and result come and go +// via the tunnel. Note in the case of bidirecitonal healthchecks, the target field +// in health_check is ignored as the interface_address is used to send traffic into +// the tunnel. +type GRETunnelNewResponseGRETunnelsHealthCheckDirection string + +const ( + GRETunnelNewResponseGRETunnelsHealthCheckDirectionUnidirectional GRETunnelNewResponseGRETunnelsHealthCheckDirection = "unidirectional" + GRETunnelNewResponseGRETunnelsHealthCheckDirectionBidirectional GRETunnelNewResponseGRETunnelsHealthCheckDirection = "bidirectional" +) + +// How frequent the health check is run. The default value is `mid`. +type GRETunnelNewResponseGRETunnelsHealthCheckRate string + +const ( + GRETunnelNewResponseGRETunnelsHealthCheckRateLow GRETunnelNewResponseGRETunnelsHealthCheckRate = "low" + GRETunnelNewResponseGRETunnelsHealthCheckRateMid GRETunnelNewResponseGRETunnelsHealthCheckRate = "mid" + GRETunnelNewResponseGRETunnelsHealthCheckRateHigh GRETunnelNewResponseGRETunnelsHealthCheckRate = "high" +) + +// The type of healthcheck to run, reply or request. The default value is `reply`. +type GRETunnelNewResponseGRETunnelsHealthCheckType string + +const ( + GRETunnelNewResponseGRETunnelsHealthCheckTypeReply GRETunnelNewResponseGRETunnelsHealthCheckType = "reply" + GRETunnelNewResponseGRETunnelsHealthCheckTypeRequest GRETunnelNewResponseGRETunnelsHealthCheckType = "request" +) + +type GRETunnelUpdateResponse struct { + Modified bool `json:"modified"` + ModifiedGRETunnel interface{} `json:"modified_gre_tunnel"` + JSON greTunnelUpdateResponseJSON `json:"-"` +} + +// greTunnelUpdateResponseJSON contains the JSON metadata for the struct +// [GRETunnelUpdateResponse] +type greTunnelUpdateResponseJSON struct { + Modified apijson.Field + ModifiedGRETunnel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelUpdateResponseJSON) RawJSON() string { + return r.raw +} + +type GRETunnelListResponse struct { + GRETunnels []GRETunnelListResponseGRETunnel `json:"gre_tunnels"` + JSON greTunnelListResponseJSON `json:"-"` +} + +// greTunnelListResponseJSON contains the JSON metadata for the struct +// [GRETunnelListResponse] +type greTunnelListResponseJSON struct { + GRETunnels apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelListResponseJSON) RawJSON() string { + return r.raw +} + +type GRETunnelListResponseGRETunnel struct { + // The IP address assigned to the Cloudflare side of the GRE tunnel. + CloudflareGREEndpoint string `json:"cloudflare_gre_endpoint,required"` + // The IP address assigned to the customer side of the GRE tunnel. + CustomerGREEndpoint string `json:"customer_gre_endpoint,required"` + // A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + // of the tunnel. Select the subnet from the following private IP space: + // 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + InterfaceAddress string `json:"interface_address,required"` + // The name of the tunnel. The name cannot contain spaces or special characters, + // must be 15 characters or less, and cannot share a name with another GRE tunnel. + Name string `json:"name,required"` + // Tunnel identifier tag. + ID string `json:"id"` + // The date and time the tunnel was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // An optional description of the GRE tunnel. + Description string `json:"description"` + HealthCheck GRETunnelListResponseGRETunnelsHealthCheck `json:"health_check"` + // The date and time the tunnel was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value + // is 576. + Mtu int64 `json:"mtu"` + // Time To Live (TTL) in number of hops of the GRE tunnel. + TTL int64 `json:"ttl"` + JSON greTunnelListResponseGRETunnelJSON `json:"-"` +} + +// greTunnelListResponseGRETunnelJSON contains the JSON metadata for the struct +// [GRETunnelListResponseGRETunnel] +type greTunnelListResponseGRETunnelJSON struct { + CloudflareGREEndpoint apijson.Field + CustomerGREEndpoint apijson.Field + InterfaceAddress apijson.Field + Name apijson.Field + ID apijson.Field + CreatedOn apijson.Field + Description apijson.Field + HealthCheck apijson.Field + ModifiedOn apijson.Field + Mtu apijson.Field + TTL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelListResponseGRETunnel) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelListResponseGRETunnelJSON) RawJSON() string { + return r.raw +} + +type GRETunnelListResponseGRETunnelsHealthCheck struct { + // The direction of the flow of the healthcheck. Either unidirectional, where the + // probe comes to you via the tunnel and the result comes back to Cloudflare via + // the open Internet, or bidirectional where both the probe and result come and go + // via the tunnel. Note in the case of bidirecitonal healthchecks, the target field + // in health_check is ignored as the interface_address is used to send traffic into + // the tunnel. + Direction GRETunnelListResponseGRETunnelsHealthCheckDirection `json:"direction"` + // Determines whether to run healthchecks for a tunnel. + Enabled bool `json:"enabled"` + // How frequent the health check is run. The default value is `mid`. + Rate GRETunnelListResponseGRETunnelsHealthCheckRate `json:"rate"` + // The destination address in a request type health check. After the healthcheck is + // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded + // to this address. This field defaults to `customer_gre_endpoint address`. This + // field is ignored for bidirectional healthchecks as the interface_address (not + // assigned to the Cloudflare side of the tunnel) is used as the target. + Target string `json:"target"` + // The type of healthcheck to run, reply or request. The default value is `reply`. + Type GRETunnelListResponseGRETunnelsHealthCheckType `json:"type"` + JSON greTunnelListResponseGRETunnelsHealthCheckJSON `json:"-"` +} + +// greTunnelListResponseGRETunnelsHealthCheckJSON contains the JSON metadata for +// the struct [GRETunnelListResponseGRETunnelsHealthCheck] +type greTunnelListResponseGRETunnelsHealthCheckJSON struct { + Direction apijson.Field + Enabled apijson.Field + Rate apijson.Field + Target apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelListResponseGRETunnelsHealthCheck) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelListResponseGRETunnelsHealthCheckJSON) RawJSON() string { + return r.raw +} + +// The direction of the flow of the healthcheck. Either unidirectional, where the +// probe comes to you via the tunnel and the result comes back to Cloudflare via +// the open Internet, or bidirectional where both the probe and result come and go +// via the tunnel. Note in the case of bidirecitonal healthchecks, the target field +// in health_check is ignored as the interface_address is used to send traffic into +// the tunnel. +type GRETunnelListResponseGRETunnelsHealthCheckDirection string + +const ( + GRETunnelListResponseGRETunnelsHealthCheckDirectionUnidirectional GRETunnelListResponseGRETunnelsHealthCheckDirection = "unidirectional" + GRETunnelListResponseGRETunnelsHealthCheckDirectionBidirectional GRETunnelListResponseGRETunnelsHealthCheckDirection = "bidirectional" +) + +// How frequent the health check is run. The default value is `mid`. +type GRETunnelListResponseGRETunnelsHealthCheckRate string + +const ( + GRETunnelListResponseGRETunnelsHealthCheckRateLow GRETunnelListResponseGRETunnelsHealthCheckRate = "low" + GRETunnelListResponseGRETunnelsHealthCheckRateMid GRETunnelListResponseGRETunnelsHealthCheckRate = "mid" + GRETunnelListResponseGRETunnelsHealthCheckRateHigh GRETunnelListResponseGRETunnelsHealthCheckRate = "high" +) + +// The type of healthcheck to run, reply or request. The default value is `reply`. +type GRETunnelListResponseGRETunnelsHealthCheckType string + +const ( + GRETunnelListResponseGRETunnelsHealthCheckTypeReply GRETunnelListResponseGRETunnelsHealthCheckType = "reply" + GRETunnelListResponseGRETunnelsHealthCheckTypeRequest GRETunnelListResponseGRETunnelsHealthCheckType = "request" +) + +type GRETunnelDeleteResponse struct { + Deleted bool `json:"deleted"` + DeletedGRETunnel interface{} `json:"deleted_gre_tunnel"` + JSON greTunnelDeleteResponseJSON `json:"-"` +} + +// greTunnelDeleteResponseJSON contains the JSON metadata for the struct +// [GRETunnelDeleteResponse] +type greTunnelDeleteResponseJSON struct { + Deleted apijson.Field + DeletedGRETunnel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type GRETunnelGetResponse struct { + GRETunnel interface{} `json:"gre_tunnel"` + JSON greTunnelGetResponseJSON `json:"-"` +} + +// greTunnelGetResponseJSON contains the JSON metadata for the struct +// [GRETunnelGetResponse] +type greTunnelGetResponseJSON struct { + GRETunnel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelGetResponseJSON) RawJSON() string { + return r.raw +} + +type GRETunnelNewParams struct { + Body param.Field[interface{}] `json:"body,required"` +} + +func (r GRETunnelNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type GRETunnelNewResponseEnvelope struct { + Errors []GRETunnelNewResponseEnvelopeErrors `json:"errors,required"` + Messages []GRETunnelNewResponseEnvelopeMessages `json:"messages,required"` + Result GRETunnelNewResponse `json:"result,required"` + // Whether the API call was successful + Success GRETunnelNewResponseEnvelopeSuccess `json:"success,required"` + JSON greTunnelNewResponseEnvelopeJSON `json:"-"` +} + +// greTunnelNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [GRETunnelNewResponseEnvelope] +type greTunnelNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GRETunnelNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON greTunnelNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// greTunnelNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [GRETunnelNewResponseEnvelopeErrors] +type greTunnelNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GRETunnelNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON greTunnelNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// greTunnelNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [GRETunnelNewResponseEnvelopeMessages] +type greTunnelNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GRETunnelNewResponseEnvelopeSuccess bool + +const ( + GRETunnelNewResponseEnvelopeSuccessTrue GRETunnelNewResponseEnvelopeSuccess = true +) + +type GRETunnelUpdateParams struct { + // The IP address assigned to the Cloudflare side of the GRE tunnel. + CloudflareGREEndpoint param.Field[string] `json:"cloudflare_gre_endpoint,required"` + // The IP address assigned to the customer side of the GRE tunnel. + CustomerGREEndpoint param.Field[string] `json:"customer_gre_endpoint,required"` + // A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + // of the tunnel. Select the subnet from the following private IP space: + // 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + InterfaceAddress param.Field[string] `json:"interface_address,required"` + // The name of the tunnel. The name cannot contain spaces or special characters, + // must be 15 characters or less, and cannot share a name with another GRE tunnel. + Name param.Field[string] `json:"name,required"` + // An optional description of the GRE tunnel. + Description param.Field[string] `json:"description"` + HealthCheck param.Field[GRETunnelUpdateParamsHealthCheck] `json:"health_check"` + // Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value + // is 576. + Mtu param.Field[int64] `json:"mtu"` + // Time To Live (TTL) in number of hops of the GRE tunnel. + TTL param.Field[int64] `json:"ttl"` +} + +func (r GRETunnelUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GRETunnelUpdateParamsHealthCheck struct { + // The direction of the flow of the healthcheck. Either unidirectional, where the + // probe comes to you via the tunnel and the result comes back to Cloudflare via + // the open Internet, or bidirectional where both the probe and result come and go + // via the tunnel. Note in the case of bidirecitonal healthchecks, the target field + // in health_check is ignored as the interface_address is used to send traffic into + // the tunnel. + Direction param.Field[GRETunnelUpdateParamsHealthCheckDirection] `json:"direction"` + // Determines whether to run healthchecks for a tunnel. + Enabled param.Field[bool] `json:"enabled"` + // How frequent the health check is run. The default value is `mid`. + Rate param.Field[GRETunnelUpdateParamsHealthCheckRate] `json:"rate"` + // The destination address in a request type health check. After the healthcheck is + // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded + // to this address. This field defaults to `customer_gre_endpoint address`. This + // field is ignored for bidirectional healthchecks as the interface_address (not + // assigned to the Cloudflare side of the tunnel) is used as the target. + Target param.Field[string] `json:"target"` + // The type of healthcheck to run, reply or request. The default value is `reply`. + Type param.Field[GRETunnelUpdateParamsHealthCheckType] `json:"type"` +} + +func (r GRETunnelUpdateParamsHealthCheck) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The direction of the flow of the healthcheck. Either unidirectional, where the +// probe comes to you via the tunnel and the result comes back to Cloudflare via +// the open Internet, or bidirectional where both the probe and result come and go +// via the tunnel. Note in the case of bidirecitonal healthchecks, the target field +// in health_check is ignored as the interface_address is used to send traffic into +// the tunnel. +type GRETunnelUpdateParamsHealthCheckDirection string + +const ( + GRETunnelUpdateParamsHealthCheckDirectionUnidirectional GRETunnelUpdateParamsHealthCheckDirection = "unidirectional" + GRETunnelUpdateParamsHealthCheckDirectionBidirectional GRETunnelUpdateParamsHealthCheckDirection = "bidirectional" +) + +// How frequent the health check is run. The default value is `mid`. +type GRETunnelUpdateParamsHealthCheckRate string + +const ( + GRETunnelUpdateParamsHealthCheckRateLow GRETunnelUpdateParamsHealthCheckRate = "low" + GRETunnelUpdateParamsHealthCheckRateMid GRETunnelUpdateParamsHealthCheckRate = "mid" + GRETunnelUpdateParamsHealthCheckRateHigh GRETunnelUpdateParamsHealthCheckRate = "high" +) + +// The type of healthcheck to run, reply or request. The default value is `reply`. +type GRETunnelUpdateParamsHealthCheckType string + +const ( + GRETunnelUpdateParamsHealthCheckTypeReply GRETunnelUpdateParamsHealthCheckType = "reply" + GRETunnelUpdateParamsHealthCheckTypeRequest GRETunnelUpdateParamsHealthCheckType = "request" +) + +type GRETunnelUpdateResponseEnvelope struct { + Errors []GRETunnelUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []GRETunnelUpdateResponseEnvelopeMessages `json:"messages,required"` + Result GRETunnelUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success GRETunnelUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON greTunnelUpdateResponseEnvelopeJSON `json:"-"` +} + +// greTunnelUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [GRETunnelUpdateResponseEnvelope] +type greTunnelUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GRETunnelUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON greTunnelUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// greTunnelUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GRETunnelUpdateResponseEnvelopeErrors] +type greTunnelUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GRETunnelUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON greTunnelUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// greTunnelUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [GRETunnelUpdateResponseEnvelopeMessages] +type greTunnelUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GRETunnelUpdateResponseEnvelopeSuccess bool + +const ( + GRETunnelUpdateResponseEnvelopeSuccessTrue GRETunnelUpdateResponseEnvelopeSuccess = true +) + +type GRETunnelListResponseEnvelope struct { + Errors []GRETunnelListResponseEnvelopeErrors `json:"errors,required"` + Messages []GRETunnelListResponseEnvelopeMessages `json:"messages,required"` + Result GRETunnelListResponse `json:"result,required"` + // Whether the API call was successful + Success GRETunnelListResponseEnvelopeSuccess `json:"success,required"` + JSON greTunnelListResponseEnvelopeJSON `json:"-"` +} + +// greTunnelListResponseEnvelopeJSON contains the JSON metadata for the struct +// [GRETunnelListResponseEnvelope] +type greTunnelListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GRETunnelListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON greTunnelListResponseEnvelopeErrorsJSON `json:"-"` +} + +// greTunnelListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GRETunnelListResponseEnvelopeErrors] +type greTunnelListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GRETunnelListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON greTunnelListResponseEnvelopeMessagesJSON `json:"-"` +} + +// greTunnelListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [GRETunnelListResponseEnvelopeMessages] +type greTunnelListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GRETunnelListResponseEnvelopeSuccess bool + +const ( + GRETunnelListResponseEnvelopeSuccessTrue GRETunnelListResponseEnvelopeSuccess = true +) + +type GRETunnelDeleteResponseEnvelope struct { + Errors []GRETunnelDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []GRETunnelDeleteResponseEnvelopeMessages `json:"messages,required"` + Result GRETunnelDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success GRETunnelDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON greTunnelDeleteResponseEnvelopeJSON `json:"-"` +} + +// greTunnelDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [GRETunnelDeleteResponseEnvelope] +type greTunnelDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GRETunnelDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON greTunnelDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// greTunnelDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GRETunnelDeleteResponseEnvelopeErrors] +type greTunnelDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GRETunnelDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON greTunnelDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// greTunnelDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [GRETunnelDeleteResponseEnvelopeMessages] +type greTunnelDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GRETunnelDeleteResponseEnvelopeSuccess bool + +const ( + GRETunnelDeleteResponseEnvelopeSuccessTrue GRETunnelDeleteResponseEnvelopeSuccess = true +) + +type GRETunnelGetResponseEnvelope struct { + Errors []GRETunnelGetResponseEnvelopeErrors `json:"errors,required"` + Messages []GRETunnelGetResponseEnvelopeMessages `json:"messages,required"` + Result GRETunnelGetResponse `json:"result,required"` + // Whether the API call was successful + Success GRETunnelGetResponseEnvelopeSuccess `json:"success,required"` + JSON greTunnelGetResponseEnvelopeJSON `json:"-"` +} + +// greTunnelGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [GRETunnelGetResponseEnvelope] +type greTunnelGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GRETunnelGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON greTunnelGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// greTunnelGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [GRETunnelGetResponseEnvelopeErrors] +type greTunnelGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GRETunnelGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON greTunnelGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// greTunnelGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [GRETunnelGetResponseEnvelopeMessages] +type greTunnelGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GRETunnelGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r greTunnelGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GRETunnelGetResponseEnvelopeSuccess bool + +const ( + GRETunnelGetResponseEnvelopeSuccessTrue GRETunnelGetResponseEnvelopeSuccess = true +) diff --git a/magic_transit/gretunnel_test.go b/magic_transit/gretunnel_test.go new file mode 100644 index 00000000000..5b2c89f3438 --- /dev/null +++ b/magic_transit/gretunnel_test.go @@ -0,0 +1,169 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_transit_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/magic_transit" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestGRETunnelNew(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("user@example.com"), + ) + _, err := client.MagicTransit.GRETunnels.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + magic_transit.GRETunnelNewParams{ + Body: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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 TestGRETunnelUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.MagicTransit.GRETunnels.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + magic_transit.GRETunnelUpdateParams{ + CloudflareGREEndpoint: cloudflare.F("203.0.113.1"), + CustomerGREEndpoint: cloudflare.F("203.0.113.1"), + InterfaceAddress: cloudflare.F("192.0.2.0/31"), + Name: cloudflare.F("GRE_1"), + Description: cloudflare.F("Tunnel for ISP X"), + HealthCheck: cloudflare.F(magic_transit.GRETunnelUpdateParamsHealthCheck{ + Direction: cloudflare.F(magic_transit.GRETunnelUpdateParamsHealthCheckDirectionBidirectional), + Enabled: cloudflare.F(true), + Rate: cloudflare.F(magic_transit.GRETunnelUpdateParamsHealthCheckRateLow), + Target: cloudflare.F("203.0.113.1"), + Type: cloudflare.F(magic_transit.GRETunnelUpdateParamsHealthCheckTypeRequest), + }), + Mtu: cloudflare.F(int64(0)), + TTL: cloudflare.F(int64(0)), + }, + ) + 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 TestGRETunnelList(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("user@example.com"), + ) + _, err := client.MagicTransit.GRETunnels.List(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()) + } +} + +func TestGRETunnelDelete(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("user@example.com"), + ) + _, err := client.MagicTransit.GRETunnels.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "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()) + } +} + +func TestGRETunnelGet(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("user@example.com"), + ) + _, err := client.MagicTransit.GRETunnels.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "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/magic_transit/ipsectunnel.go b/magic_transit/ipsectunnel.go new file mode 100644 index 00000000000..88da5d376a3 --- /dev/null +++ b/magic_transit/ipsectunnel.go @@ -0,0 +1,1191 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_transit + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// IPSECTunnelService 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 [NewIPSECTunnelService] method +// instead. +type IPSECTunnelService struct { + Options []option.RequestOption +} + +// NewIPSECTunnelService 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 NewIPSECTunnelService(opts ...option.RequestOption) (r *IPSECTunnelService) { + r = &IPSECTunnelService{} + r.Options = opts + return +} + +// Creates new IPsec tunnels associated with an account. Use `?validate_only=true` +// as an optional query parameter to only run validation without persisting +// changes. +func (r *IPSECTunnelService) New(ctx context.Context, accountIdentifier string, body IPSECTunnelNewParams, opts ...option.RequestOption) (res *IPSECTunnelNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env IPSECTunnelNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/ipsec_tunnels", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a specific IPsec tunnel associated with an account. Use +// `?validate_only=true` as an optional query parameter to only run validation +// without persisting changes. +func (r *IPSECTunnelService) Update(ctx context.Context, accountIdentifier string, tunnelIdentifier string, body IPSECTunnelUpdateParams, opts ...option.RequestOption) (res *IPSECTunnelUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env IPSECTunnelUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/ipsec_tunnels/%s", accountIdentifier, tunnelIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists IPsec tunnels associated with an account. +func (r *IPSECTunnelService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *IPSECTunnelListResponse, err error) { + opts = append(r.Options[:], opts...) + var env IPSECTunnelListResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/ipsec_tunnels", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Disables and removes a specific static IPsec Tunnel associated with an account. +// Use `?validate_only=true` as an optional query parameter to only run validation +// without persisting changes. +func (r *IPSECTunnelService) Delete(ctx context.Context, accountIdentifier string, tunnelIdentifier string, opts ...option.RequestOption) (res *IPSECTunnelDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env IPSECTunnelDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/ipsec_tunnels/%s", accountIdentifier, tunnelIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists details for a specific IPsec tunnel. +func (r *IPSECTunnelService) Get(ctx context.Context, accountIdentifier string, tunnelIdentifier string, opts ...option.RequestOption) (res *IPSECTunnelGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env IPSECTunnelGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/ipsec_tunnels/%s", accountIdentifier, tunnelIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Generates a Pre Shared Key for a specific IPsec tunnel used in the IKE session. +// Use `?validate_only=true` as an optional query parameter to only run validation +// without persisting changes. After a PSK is generated, the PSK is immediately +// persisted to Cloudflare's edge and cannot be retrieved later. Note the PSK in a +// safe place. +func (r *IPSECTunnelService) PSKGenerate(ctx context.Context, accountIdentifier string, tunnelIdentifier string, opts ...option.RequestOption) (res *IPSECTunnelPSKGenerateResponse, err error) { + opts = append(r.Options[:], opts...) + var env IPSECTunnelPSKGenerateResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/ipsec_tunnels/%s/psk_generate", accountIdentifier, tunnelIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type IPSECTunnelNewResponse struct { + IPSECTunnels []IPSECTunnelNewResponseIPSECTunnel `json:"ipsec_tunnels"` + JSON ipsecTunnelNewResponseJSON `json:"-"` +} + +// ipsecTunnelNewResponseJSON contains the JSON metadata for the struct +// [IPSECTunnelNewResponse] +type ipsecTunnelNewResponseJSON struct { + IPSECTunnels apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelNewResponseJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelNewResponseIPSECTunnel struct { + // The IP address assigned to the Cloudflare side of the IPsec tunnel. + CloudflareEndpoint string `json:"cloudflare_endpoint,required"` + // A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + // of the tunnel. Select the subnet from the following private IP space: + // 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + InterfaceAddress string `json:"interface_address,required"` + // The name of the IPsec tunnel. The name cannot share a name with other tunnels. + Name string `json:"name,required"` + // Tunnel identifier tag. + ID string `json:"id"` + // When `true`, the tunnel can use a null-cipher (`ENCR_NULL`) in the ESP tunnel + // (Phase 2). + AllowNullCipher bool `json:"allow_null_cipher"` + // The date and time the tunnel was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // The IP address assigned to the customer side of the IPsec tunnel. + CustomerEndpoint string `json:"customer_endpoint"` + // An optional description forthe IPsec tunnel. + Description string `json:"description"` + // The date and time the tunnel was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // The PSK metadata that includes when the PSK was generated. + PSKMetadata IPSECTunnelNewResponseIPSECTunnelsPSKMetadata `json:"psk_metadata"` + // If `true`, then IPsec replay protection will be supported in the + // Cloudflare-to-customer direction. + ReplayProtection bool `json:"replay_protection"` + TunnelHealthCheck IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheck `json:"tunnel_health_check"` + JSON ipsecTunnelNewResponseIPSECTunnelJSON `json:"-"` +} + +// ipsecTunnelNewResponseIPSECTunnelJSON contains the JSON metadata for the struct +// [IPSECTunnelNewResponseIPSECTunnel] +type ipsecTunnelNewResponseIPSECTunnelJSON struct { + CloudflareEndpoint apijson.Field + InterfaceAddress apijson.Field + Name apijson.Field + ID apijson.Field + AllowNullCipher apijson.Field + CreatedOn apijson.Field + CustomerEndpoint apijson.Field + Description apijson.Field + ModifiedOn apijson.Field + PSKMetadata apijson.Field + ReplayProtection apijson.Field + TunnelHealthCheck apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelNewResponseIPSECTunnel) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelNewResponseIPSECTunnelJSON) RawJSON() string { + return r.raw +} + +// The PSK metadata that includes when the PSK was generated. +type IPSECTunnelNewResponseIPSECTunnelsPSKMetadata struct { + // The date and time the tunnel was last modified. + LastGeneratedOn time.Time `json:"last_generated_on" format:"date-time"` + JSON ipsecTunnelNewResponseIPSECTunnelsPSKMetadataJSON `json:"-"` +} + +// ipsecTunnelNewResponseIPSECTunnelsPSKMetadataJSON contains the JSON metadata for +// the struct [IPSECTunnelNewResponseIPSECTunnelsPSKMetadata] +type ipsecTunnelNewResponseIPSECTunnelsPSKMetadataJSON struct { + LastGeneratedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelNewResponseIPSECTunnelsPSKMetadata) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelNewResponseIPSECTunnelsPSKMetadataJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheck struct { + // Determines whether to run healthchecks for a tunnel. + Enabled bool `json:"enabled"` + // How frequent the health check is run. The default value is `mid`. + Rate IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRate `json:"rate"` + // The destination address in a request type health check. After the healthcheck is + // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded + // to this address. This field defaults to `customer_gre_endpoint address`. + Target string `json:"target"` + // The type of healthcheck to run, reply or request. The default value is `reply`. + Type IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckType `json:"type"` + JSON ipsecTunnelNewResponseIPSECTunnelsTunnelHealthCheckJSON `json:"-"` +} + +// ipsecTunnelNewResponseIPSECTunnelsTunnelHealthCheckJSON contains the JSON +// metadata for the struct [IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheck] +type ipsecTunnelNewResponseIPSECTunnelsTunnelHealthCheckJSON struct { + Enabled apijson.Field + Rate apijson.Field + Target apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheck) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelNewResponseIPSECTunnelsTunnelHealthCheckJSON) RawJSON() string { + return r.raw +} + +// How frequent the health check is run. The default value is `mid`. +type IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRate string + +const ( + IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRateLow IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRate = "low" + IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRateMid IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRate = "mid" + IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRateHigh IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRate = "high" +) + +// The type of healthcheck to run, reply or request. The default value is `reply`. +type IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckType string + +const ( + IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckTypeReply IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckType = "reply" + IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckTypeRequest IPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckType = "request" +) + +type IPSECTunnelUpdateResponse struct { + Modified bool `json:"modified"` + ModifiedIPSECTunnel interface{} `json:"modified_ipsec_tunnel"` + JSON ipsecTunnelUpdateResponseJSON `json:"-"` +} + +// ipsecTunnelUpdateResponseJSON contains the JSON metadata for the struct +// [IPSECTunnelUpdateResponse] +type ipsecTunnelUpdateResponseJSON struct { + Modified apijson.Field + ModifiedIPSECTunnel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelUpdateResponseJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelListResponse struct { + IPSECTunnels []IPSECTunnelListResponseIPSECTunnel `json:"ipsec_tunnels"` + JSON ipsecTunnelListResponseJSON `json:"-"` +} + +// ipsecTunnelListResponseJSON contains the JSON metadata for the struct +// [IPSECTunnelListResponse] +type ipsecTunnelListResponseJSON struct { + IPSECTunnels apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelListResponseJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelListResponseIPSECTunnel struct { + // The IP address assigned to the Cloudflare side of the IPsec tunnel. + CloudflareEndpoint string `json:"cloudflare_endpoint,required"` + // A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + // of the tunnel. Select the subnet from the following private IP space: + // 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + InterfaceAddress string `json:"interface_address,required"` + // The name of the IPsec tunnel. The name cannot share a name with other tunnels. + Name string `json:"name,required"` + // Tunnel identifier tag. + ID string `json:"id"` + // When `true`, the tunnel can use a null-cipher (`ENCR_NULL`) in the ESP tunnel + // (Phase 2). + AllowNullCipher bool `json:"allow_null_cipher"` + // The date and time the tunnel was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // The IP address assigned to the customer side of the IPsec tunnel. + CustomerEndpoint string `json:"customer_endpoint"` + // An optional description forthe IPsec tunnel. + Description string `json:"description"` + // The date and time the tunnel was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // The PSK metadata that includes when the PSK was generated. + PSKMetadata IPSECTunnelListResponseIPSECTunnelsPSKMetadata `json:"psk_metadata"` + // If `true`, then IPsec replay protection will be supported in the + // Cloudflare-to-customer direction. + ReplayProtection bool `json:"replay_protection"` + TunnelHealthCheck IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheck `json:"tunnel_health_check"` + JSON ipsecTunnelListResponseIPSECTunnelJSON `json:"-"` +} + +// ipsecTunnelListResponseIPSECTunnelJSON contains the JSON metadata for the struct +// [IPSECTunnelListResponseIPSECTunnel] +type ipsecTunnelListResponseIPSECTunnelJSON struct { + CloudflareEndpoint apijson.Field + InterfaceAddress apijson.Field + Name apijson.Field + ID apijson.Field + AllowNullCipher apijson.Field + CreatedOn apijson.Field + CustomerEndpoint apijson.Field + Description apijson.Field + ModifiedOn apijson.Field + PSKMetadata apijson.Field + ReplayProtection apijson.Field + TunnelHealthCheck apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelListResponseIPSECTunnel) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelListResponseIPSECTunnelJSON) RawJSON() string { + return r.raw +} + +// The PSK metadata that includes when the PSK was generated. +type IPSECTunnelListResponseIPSECTunnelsPSKMetadata struct { + // The date and time the tunnel was last modified. + LastGeneratedOn time.Time `json:"last_generated_on" format:"date-time"` + JSON ipsecTunnelListResponseIPSECTunnelsPSKMetadataJSON `json:"-"` +} + +// ipsecTunnelListResponseIPSECTunnelsPSKMetadataJSON contains the JSON metadata +// for the struct [IPSECTunnelListResponseIPSECTunnelsPSKMetadata] +type ipsecTunnelListResponseIPSECTunnelsPSKMetadataJSON struct { + LastGeneratedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelListResponseIPSECTunnelsPSKMetadata) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelListResponseIPSECTunnelsPSKMetadataJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheck struct { + // Determines whether to run healthchecks for a tunnel. + Enabled bool `json:"enabled"` + // How frequent the health check is run. The default value is `mid`. + Rate IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRate `json:"rate"` + // The destination address in a request type health check. After the healthcheck is + // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded + // to this address. This field defaults to `customer_gre_endpoint address`. + Target string `json:"target"` + // The type of healthcheck to run, reply or request. The default value is `reply`. + Type IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckType `json:"type"` + JSON ipsecTunnelListResponseIPSECTunnelsTunnelHealthCheckJSON `json:"-"` +} + +// ipsecTunnelListResponseIPSECTunnelsTunnelHealthCheckJSON contains the JSON +// metadata for the struct [IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheck] +type ipsecTunnelListResponseIPSECTunnelsTunnelHealthCheckJSON struct { + Enabled apijson.Field + Rate apijson.Field + Target apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheck) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelListResponseIPSECTunnelsTunnelHealthCheckJSON) RawJSON() string { + return r.raw +} + +// How frequent the health check is run. The default value is `mid`. +type IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRate string + +const ( + IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRateLow IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRate = "low" + IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRateMid IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRate = "mid" + IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRateHigh IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRate = "high" +) + +// The type of healthcheck to run, reply or request. The default value is `reply`. +type IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckType string + +const ( + IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckTypeReply IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckType = "reply" + IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckTypeRequest IPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckType = "request" +) + +type IPSECTunnelDeleteResponse struct { + Deleted bool `json:"deleted"` + DeletedIPSECTunnel interface{} `json:"deleted_ipsec_tunnel"` + JSON ipsecTunnelDeleteResponseJSON `json:"-"` +} + +// ipsecTunnelDeleteResponseJSON contains the JSON metadata for the struct +// [IPSECTunnelDeleteResponse] +type ipsecTunnelDeleteResponseJSON struct { + Deleted apijson.Field + DeletedIPSECTunnel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelGetResponse struct { + IPSECTunnel interface{} `json:"ipsec_tunnel"` + JSON ipsecTunnelGetResponseJSON `json:"-"` +} + +// ipsecTunnelGetResponseJSON contains the JSON metadata for the struct +// [IPSECTunnelGetResponse] +type ipsecTunnelGetResponseJSON struct { + IPSECTunnel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelGetResponseJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelPSKGenerateResponse struct { + // Identifier + IPSECTunnelID string `json:"ipsec_tunnel_id"` + // A randomly generated or provided string for use in the IPsec tunnel. + PSK string `json:"psk"` + // The PSK metadata that includes when the PSK was generated. + PSKMetadata IPSECTunnelPSKGenerateResponsePSKMetadata `json:"psk_metadata"` + JSON ipsecTunnelPSKGenerateResponseJSON `json:"-"` +} + +// ipsecTunnelPSKGenerateResponseJSON contains the JSON metadata for the struct +// [IPSECTunnelPSKGenerateResponse] +type ipsecTunnelPSKGenerateResponseJSON struct { + IPSECTunnelID apijson.Field + PSK apijson.Field + PSKMetadata apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelPSKGenerateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelPSKGenerateResponseJSON) RawJSON() string { + return r.raw +} + +// The PSK metadata that includes when the PSK was generated. +type IPSECTunnelPSKGenerateResponsePSKMetadata struct { + // The date and time the tunnel was last modified. + LastGeneratedOn time.Time `json:"last_generated_on" format:"date-time"` + JSON ipsecTunnelPSKGenerateResponsePSKMetadataJSON `json:"-"` +} + +// ipsecTunnelPSKGenerateResponsePSKMetadataJSON contains the JSON metadata for the +// struct [IPSECTunnelPSKGenerateResponsePSKMetadata] +type ipsecTunnelPSKGenerateResponsePSKMetadataJSON struct { + LastGeneratedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelPSKGenerateResponsePSKMetadata) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelPSKGenerateResponsePSKMetadataJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelNewParams struct { + // The IP address assigned to the Cloudflare side of the IPsec tunnel. + CloudflareEndpoint param.Field[string] `json:"cloudflare_endpoint,required"` + // A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + // of the tunnel. Select the subnet from the following private IP space: + // 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + InterfaceAddress param.Field[string] `json:"interface_address,required"` + // The name of the IPsec tunnel. The name cannot share a name with other tunnels. + Name param.Field[string] `json:"name,required"` + // The IP address assigned to the customer side of the IPsec tunnel. + CustomerEndpoint param.Field[string] `json:"customer_endpoint"` + // An optional description forthe IPsec tunnel. + Description param.Field[string] `json:"description"` + HealthCheck param.Field[IPSECTunnelNewParamsHealthCheck] `json:"health_check"` + // A randomly generated or provided string for use in the IPsec tunnel. + PSK param.Field[string] `json:"psk"` + // If `true`, then IPsec replay protection will be supported in the + // Cloudflare-to-customer direction. + ReplayProtection param.Field[bool] `json:"replay_protection"` +} + +func (r IPSECTunnelNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IPSECTunnelNewParamsHealthCheck struct { + // The direction of the flow of the healthcheck. Either unidirectional, where the + // probe comes to you via the tunnel and the result comes back to Cloudflare via + // the open Internet, or bidirectional where both the probe and result come and go + // via the tunnel. Note in the case of bidirecitonal healthchecks, the target field + // in health_check is ignored as the interface_address is used to send traffic into + // the tunnel. + Direction param.Field[IPSECTunnelNewParamsHealthCheckDirection] `json:"direction"` + // Determines whether to run healthchecks for a tunnel. + Enabled param.Field[bool] `json:"enabled"` + // How frequent the health check is run. The default value is `mid`. + Rate param.Field[IPSECTunnelNewParamsHealthCheckRate] `json:"rate"` + // The destination address in a request type health check. After the healthcheck is + // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded + // to this address. This field defaults to `customer_gre_endpoint address`. This + // field is ignored for bidirectional healthchecks as the interface_address (not + // assigned to the Cloudflare side of the tunnel) is used as the target. + Target param.Field[string] `json:"target"` + // The type of healthcheck to run, reply or request. The default value is `reply`. + Type param.Field[IPSECTunnelNewParamsHealthCheckType] `json:"type"` +} + +func (r IPSECTunnelNewParamsHealthCheck) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The direction of the flow of the healthcheck. Either unidirectional, where the +// probe comes to you via the tunnel and the result comes back to Cloudflare via +// the open Internet, or bidirectional where both the probe and result come and go +// via the tunnel. Note in the case of bidirecitonal healthchecks, the target field +// in health_check is ignored as the interface_address is used to send traffic into +// the tunnel. +type IPSECTunnelNewParamsHealthCheckDirection string + +const ( + IPSECTunnelNewParamsHealthCheckDirectionUnidirectional IPSECTunnelNewParamsHealthCheckDirection = "unidirectional" + IPSECTunnelNewParamsHealthCheckDirectionBidirectional IPSECTunnelNewParamsHealthCheckDirection = "bidirectional" +) + +// How frequent the health check is run. The default value is `mid`. +type IPSECTunnelNewParamsHealthCheckRate string + +const ( + IPSECTunnelNewParamsHealthCheckRateLow IPSECTunnelNewParamsHealthCheckRate = "low" + IPSECTunnelNewParamsHealthCheckRateMid IPSECTunnelNewParamsHealthCheckRate = "mid" + IPSECTunnelNewParamsHealthCheckRateHigh IPSECTunnelNewParamsHealthCheckRate = "high" +) + +// The type of healthcheck to run, reply or request. The default value is `reply`. +type IPSECTunnelNewParamsHealthCheckType string + +const ( + IPSECTunnelNewParamsHealthCheckTypeReply IPSECTunnelNewParamsHealthCheckType = "reply" + IPSECTunnelNewParamsHealthCheckTypeRequest IPSECTunnelNewParamsHealthCheckType = "request" +) + +type IPSECTunnelNewResponseEnvelope struct { + Errors []IPSECTunnelNewResponseEnvelopeErrors `json:"errors,required"` + Messages []IPSECTunnelNewResponseEnvelopeMessages `json:"messages,required"` + Result IPSECTunnelNewResponse `json:"result,required"` + // Whether the API call was successful + Success IPSECTunnelNewResponseEnvelopeSuccess `json:"success,required"` + JSON ipsecTunnelNewResponseEnvelopeJSON `json:"-"` +} + +// ipsecTunnelNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [IPSECTunnelNewResponseEnvelope] +type ipsecTunnelNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ipsecTunnelNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// ipsecTunnelNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [IPSECTunnelNewResponseEnvelopeErrors] +type ipsecTunnelNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ipsecTunnelNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// ipsecTunnelNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [IPSECTunnelNewResponseEnvelopeMessages] +type ipsecTunnelNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IPSECTunnelNewResponseEnvelopeSuccess bool + +const ( + IPSECTunnelNewResponseEnvelopeSuccessTrue IPSECTunnelNewResponseEnvelopeSuccess = true +) + +type IPSECTunnelUpdateParams struct { + // The IP address assigned to the Cloudflare side of the IPsec tunnel. + CloudflareEndpoint param.Field[string] `json:"cloudflare_endpoint,required"` + // A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side + // of the tunnel. Select the subnet from the following private IP space: + // 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. + InterfaceAddress param.Field[string] `json:"interface_address,required"` + // The name of the IPsec tunnel. The name cannot share a name with other tunnels. + Name param.Field[string] `json:"name,required"` + // The IP address assigned to the customer side of the IPsec tunnel. + CustomerEndpoint param.Field[string] `json:"customer_endpoint"` + // An optional description forthe IPsec tunnel. + Description param.Field[string] `json:"description"` + HealthCheck param.Field[IPSECTunnelUpdateParamsHealthCheck] `json:"health_check"` + // A randomly generated or provided string for use in the IPsec tunnel. + PSK param.Field[string] `json:"psk"` + // If `true`, then IPsec replay protection will be supported in the + // Cloudflare-to-customer direction. + ReplayProtection param.Field[bool] `json:"replay_protection"` +} + +func (r IPSECTunnelUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IPSECTunnelUpdateParamsHealthCheck struct { + // The direction of the flow of the healthcheck. Either unidirectional, where the + // probe comes to you via the tunnel and the result comes back to Cloudflare via + // the open Internet, or bidirectional where both the probe and result come and go + // via the tunnel. Note in the case of bidirecitonal healthchecks, the target field + // in health_check is ignored as the interface_address is used to send traffic into + // the tunnel. + Direction param.Field[IPSECTunnelUpdateParamsHealthCheckDirection] `json:"direction"` + // Determines whether to run healthchecks for a tunnel. + Enabled param.Field[bool] `json:"enabled"` + // How frequent the health check is run. The default value is `mid`. + Rate param.Field[IPSECTunnelUpdateParamsHealthCheckRate] `json:"rate"` + // The destination address in a request type health check. After the healthcheck is + // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded + // to this address. This field defaults to `customer_gre_endpoint address`. This + // field is ignored for bidirectional healthchecks as the interface_address (not + // assigned to the Cloudflare side of the tunnel) is used as the target. + Target param.Field[string] `json:"target"` + // The type of healthcheck to run, reply or request. The default value is `reply`. + Type param.Field[IPSECTunnelUpdateParamsHealthCheckType] `json:"type"` +} + +func (r IPSECTunnelUpdateParamsHealthCheck) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The direction of the flow of the healthcheck. Either unidirectional, where the +// probe comes to you via the tunnel and the result comes back to Cloudflare via +// the open Internet, or bidirectional where both the probe and result come and go +// via the tunnel. Note in the case of bidirecitonal healthchecks, the target field +// in health_check is ignored as the interface_address is used to send traffic into +// the tunnel. +type IPSECTunnelUpdateParamsHealthCheckDirection string + +const ( + IPSECTunnelUpdateParamsHealthCheckDirectionUnidirectional IPSECTunnelUpdateParamsHealthCheckDirection = "unidirectional" + IPSECTunnelUpdateParamsHealthCheckDirectionBidirectional IPSECTunnelUpdateParamsHealthCheckDirection = "bidirectional" +) + +// How frequent the health check is run. The default value is `mid`. +type IPSECTunnelUpdateParamsHealthCheckRate string + +const ( + IPSECTunnelUpdateParamsHealthCheckRateLow IPSECTunnelUpdateParamsHealthCheckRate = "low" + IPSECTunnelUpdateParamsHealthCheckRateMid IPSECTunnelUpdateParamsHealthCheckRate = "mid" + IPSECTunnelUpdateParamsHealthCheckRateHigh IPSECTunnelUpdateParamsHealthCheckRate = "high" +) + +// The type of healthcheck to run, reply or request. The default value is `reply`. +type IPSECTunnelUpdateParamsHealthCheckType string + +const ( + IPSECTunnelUpdateParamsHealthCheckTypeReply IPSECTunnelUpdateParamsHealthCheckType = "reply" + IPSECTunnelUpdateParamsHealthCheckTypeRequest IPSECTunnelUpdateParamsHealthCheckType = "request" +) + +type IPSECTunnelUpdateResponseEnvelope struct { + Errors []IPSECTunnelUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []IPSECTunnelUpdateResponseEnvelopeMessages `json:"messages,required"` + Result IPSECTunnelUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success IPSECTunnelUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON ipsecTunnelUpdateResponseEnvelopeJSON `json:"-"` +} + +// ipsecTunnelUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [IPSECTunnelUpdateResponseEnvelope] +type ipsecTunnelUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ipsecTunnelUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// ipsecTunnelUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [IPSECTunnelUpdateResponseEnvelopeErrors] +type ipsecTunnelUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ipsecTunnelUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// ipsecTunnelUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [IPSECTunnelUpdateResponseEnvelopeMessages] +type ipsecTunnelUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IPSECTunnelUpdateResponseEnvelopeSuccess bool + +const ( + IPSECTunnelUpdateResponseEnvelopeSuccessTrue IPSECTunnelUpdateResponseEnvelopeSuccess = true +) + +type IPSECTunnelListResponseEnvelope struct { + Errors []IPSECTunnelListResponseEnvelopeErrors `json:"errors,required"` + Messages []IPSECTunnelListResponseEnvelopeMessages `json:"messages,required"` + Result IPSECTunnelListResponse `json:"result,required"` + // Whether the API call was successful + Success IPSECTunnelListResponseEnvelopeSuccess `json:"success,required"` + JSON ipsecTunnelListResponseEnvelopeJSON `json:"-"` +} + +// ipsecTunnelListResponseEnvelopeJSON contains the JSON metadata for the struct +// [IPSECTunnelListResponseEnvelope] +type ipsecTunnelListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ipsecTunnelListResponseEnvelopeErrorsJSON `json:"-"` +} + +// ipsecTunnelListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [IPSECTunnelListResponseEnvelopeErrors] +type ipsecTunnelListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ipsecTunnelListResponseEnvelopeMessagesJSON `json:"-"` +} + +// ipsecTunnelListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [IPSECTunnelListResponseEnvelopeMessages] +type ipsecTunnelListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IPSECTunnelListResponseEnvelopeSuccess bool + +const ( + IPSECTunnelListResponseEnvelopeSuccessTrue IPSECTunnelListResponseEnvelopeSuccess = true +) + +type IPSECTunnelDeleteResponseEnvelope struct { + Errors []IPSECTunnelDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []IPSECTunnelDeleteResponseEnvelopeMessages `json:"messages,required"` + Result IPSECTunnelDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success IPSECTunnelDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON ipsecTunnelDeleteResponseEnvelopeJSON `json:"-"` +} + +// ipsecTunnelDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [IPSECTunnelDeleteResponseEnvelope] +type ipsecTunnelDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ipsecTunnelDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// ipsecTunnelDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [IPSECTunnelDeleteResponseEnvelopeErrors] +type ipsecTunnelDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ipsecTunnelDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// ipsecTunnelDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [IPSECTunnelDeleteResponseEnvelopeMessages] +type ipsecTunnelDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IPSECTunnelDeleteResponseEnvelopeSuccess bool + +const ( + IPSECTunnelDeleteResponseEnvelopeSuccessTrue IPSECTunnelDeleteResponseEnvelopeSuccess = true +) + +type IPSECTunnelGetResponseEnvelope struct { + Errors []IPSECTunnelGetResponseEnvelopeErrors `json:"errors,required"` + Messages []IPSECTunnelGetResponseEnvelopeMessages `json:"messages,required"` + Result IPSECTunnelGetResponse `json:"result,required"` + // Whether the API call was successful + Success IPSECTunnelGetResponseEnvelopeSuccess `json:"success,required"` + JSON ipsecTunnelGetResponseEnvelopeJSON `json:"-"` +} + +// ipsecTunnelGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [IPSECTunnelGetResponseEnvelope] +type ipsecTunnelGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ipsecTunnelGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// ipsecTunnelGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [IPSECTunnelGetResponseEnvelopeErrors] +type ipsecTunnelGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ipsecTunnelGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// ipsecTunnelGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [IPSECTunnelGetResponseEnvelopeMessages] +type ipsecTunnelGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IPSECTunnelGetResponseEnvelopeSuccess bool + +const ( + IPSECTunnelGetResponseEnvelopeSuccessTrue IPSECTunnelGetResponseEnvelopeSuccess = true +) + +type IPSECTunnelPSKGenerateResponseEnvelope struct { + Errors []IPSECTunnelPSKGenerateResponseEnvelopeErrors `json:"errors,required"` + Messages []IPSECTunnelPSKGenerateResponseEnvelopeMessages `json:"messages,required"` + Result IPSECTunnelPSKGenerateResponse `json:"result,required"` + // Whether the API call was successful + Success IPSECTunnelPSKGenerateResponseEnvelopeSuccess `json:"success,required"` + JSON ipsecTunnelPSKGenerateResponseEnvelopeJSON `json:"-"` +} + +// ipsecTunnelPSKGenerateResponseEnvelopeJSON contains the JSON metadata for the +// struct [IPSECTunnelPSKGenerateResponseEnvelope] +type ipsecTunnelPSKGenerateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelPSKGenerateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelPSKGenerateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelPSKGenerateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ipsecTunnelPSKGenerateResponseEnvelopeErrorsJSON `json:"-"` +} + +// ipsecTunnelPSKGenerateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [IPSECTunnelPSKGenerateResponseEnvelopeErrors] +type ipsecTunnelPSKGenerateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelPSKGenerateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelPSKGenerateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IPSECTunnelPSKGenerateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ipsecTunnelPSKGenerateResponseEnvelopeMessagesJSON `json:"-"` +} + +// ipsecTunnelPSKGenerateResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [IPSECTunnelPSKGenerateResponseEnvelopeMessages] +type ipsecTunnelPSKGenerateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IPSECTunnelPSKGenerateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ipsecTunnelPSKGenerateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IPSECTunnelPSKGenerateResponseEnvelopeSuccess bool + +const ( + IPSECTunnelPSKGenerateResponseEnvelopeSuccessTrue IPSECTunnelPSKGenerateResponseEnvelopeSuccess = true +) diff --git a/magic_transit/ipsectunnel_test.go b/magic_transit/ipsectunnel_test.go new file mode 100644 index 00000000000..766eb54713d --- /dev/null +++ b/magic_transit/ipsectunnel_test.go @@ -0,0 +1,210 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_transit_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/magic_transit" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestIPSECTunnelNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.MagicTransit.IPSECTunnels.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + magic_transit.IPSECTunnelNewParams{ + CloudflareEndpoint: cloudflare.F("203.0.113.1"), + InterfaceAddress: cloudflare.F("192.0.2.0/31"), + Name: cloudflare.F("IPsec_1"), + CustomerEndpoint: cloudflare.F("203.0.113.1"), + Description: cloudflare.F("Tunnel for ISP X"), + HealthCheck: cloudflare.F(magic_transit.IPSECTunnelNewParamsHealthCheck{ + Direction: cloudflare.F(magic_transit.IPSECTunnelNewParamsHealthCheckDirectionBidirectional), + Enabled: cloudflare.F(true), + Rate: cloudflare.F(magic_transit.IPSECTunnelNewParamsHealthCheckRateLow), + Target: cloudflare.F("203.0.113.1"), + Type: cloudflare.F(magic_transit.IPSECTunnelNewParamsHealthCheckTypeRequest), + }), + PSK: cloudflare.F("O3bwKSjnaoCxDoUxjcq4Rk8ZKkezQUiy"), + ReplayProtection: cloudflare.F(false), + }, + ) + 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 TestIPSECTunnelUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.MagicTransit.IPSECTunnels.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + magic_transit.IPSECTunnelUpdateParams{ + CloudflareEndpoint: cloudflare.F("203.0.113.1"), + InterfaceAddress: cloudflare.F("192.0.2.0/31"), + Name: cloudflare.F("IPsec_1"), + CustomerEndpoint: cloudflare.F("203.0.113.1"), + Description: cloudflare.F("Tunnel for ISP X"), + HealthCheck: cloudflare.F(magic_transit.IPSECTunnelUpdateParamsHealthCheck{ + Direction: cloudflare.F(magic_transit.IPSECTunnelUpdateParamsHealthCheckDirectionBidirectional), + Enabled: cloudflare.F(true), + Rate: cloudflare.F(magic_transit.IPSECTunnelUpdateParamsHealthCheckRateLow), + Target: cloudflare.F("203.0.113.1"), + Type: cloudflare.F(magic_transit.IPSECTunnelUpdateParamsHealthCheckTypeRequest), + }), + PSK: cloudflare.F("O3bwKSjnaoCxDoUxjcq4Rk8ZKkezQUiy"), + ReplayProtection: cloudflare.F(false), + }, + ) + 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 TestIPSECTunnelList(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("user@example.com"), + ) + _, err := client.MagicTransit.IPSECTunnels.List(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()) + } +} + +func TestIPSECTunnelDelete(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("user@example.com"), + ) + _, err := client.MagicTransit.IPSECTunnels.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "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()) + } +} + +func TestIPSECTunnelGet(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("user@example.com"), + ) + _, err := client.MagicTransit.IPSECTunnels.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "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()) + } +} + +func TestIPSECTunnelPSKGenerate(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("user@example.com"), + ) + _, err := client.MagicTransit.IPSECTunnels.PSKGenerate( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "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/magic_transit/magictransit.go b/magic_transit/magictransit.go new file mode 100644 index 00000000000..0f71406e6d7 --- /dev/null +++ b/magic_transit/magictransit.go @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_transit + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// MagicTransitService 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 [NewMagicTransitService] method +// instead. +type MagicTransitService struct { + Options []option.RequestOption + CfInterconnects *CfInterconnectService + GRETunnels *GRETunnelService + IPSECTunnels *IPSECTunnelService + Routes *RouteService +} + +// NewMagicTransitService 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 NewMagicTransitService(opts ...option.RequestOption) (r *MagicTransitService) { + r = &MagicTransitService{} + r.Options = opts + r.CfInterconnects = NewCfInterconnectService(opts...) + r.GRETunnels = NewGRETunnelService(opts...) + r.IPSECTunnels = NewIPSECTunnelService(opts...) + r.Routes = NewRouteService(opts...) + return +} diff --git a/magic_transit/route.go b/magic_transit/route.go new file mode 100644 index 00000000000..55f8ab49ad6 --- /dev/null +++ b/magic_transit/route.go @@ -0,0 +1,928 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_transit + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// RouteService 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 [NewRouteService] method instead. +type RouteService struct { + Options []option.RequestOption +} + +// NewRouteService 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 NewRouteService(opts ...option.RequestOption) (r *RouteService) { + r = &RouteService{} + r.Options = opts + return +} + +// Creates a new Magic static route. Use `?validate_only=true` as an optional query +// parameter to run validation only without persisting changes. +func (r *RouteService) New(ctx context.Context, accountIdentifier string, body RouteNewParams, opts ...option.RequestOption) (res *RouteNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env RouteNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/routes", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update a specific Magic static route. Use `?validate_only=true` as an optional +// query parameter to run validation only without persisting changes. +func (r *RouteService) Update(ctx context.Context, accountIdentifier string, routeIdentifier string, body RouteUpdateParams, opts ...option.RequestOption) (res *RouteUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env RouteUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/routes/%s", accountIdentifier, routeIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List all Magic static routes. +func (r *RouteService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *RouteListResponse, err error) { + opts = append(r.Options[:], opts...) + var env RouteListResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/routes", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Disable and remove a specific Magic static route. +func (r *RouteService) Delete(ctx context.Context, accountIdentifier string, routeIdentifier string, opts ...option.RequestOption) (res *RouteDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env RouteDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/routes/%s", accountIdentifier, routeIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete multiple Magic static routes. +func (r *RouteService) Empty(ctx context.Context, accountIdentifier string, body RouteEmptyParams, opts ...option.RequestOption) (res *RouteEmptyResponse, err error) { + opts = append(r.Options[:], opts...) + var env RouteEmptyResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/routes", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a specific Magic static route. +func (r *RouteService) Get(ctx context.Context, accountIdentifier string, routeIdentifier string, opts ...option.RequestOption) (res *RouteGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RouteGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/magic/routes/%s", accountIdentifier, routeIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type RouteNewResponse struct { + Routes []RouteNewResponseRoute `json:"routes"` + JSON routeNewResponseJSON `json:"-"` +} + +// routeNewResponseJSON contains the JSON metadata for the struct +// [RouteNewResponse] +type routeNewResponseJSON struct { + Routes apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeNewResponseJSON) RawJSON() string { + return r.raw +} + +type RouteNewResponseRoute struct { + // The next-hop IP Address for the static route. + Nexthop string `json:"nexthop,required"` + // IP Prefix in Classless Inter-Domain Routing format. + Prefix string `json:"prefix,required"` + // Priority of the static route. + Priority int64 `json:"priority,required"` + // Identifier + ID string `json:"id"` + // When the route was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // An optional human provided description of the static route. + Description string `json:"description"` + // When the route was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Used only for ECMP routes. + Scope RouteNewResponseRoutesScope `json:"scope"` + // Optional weight of the ECMP scope - if provided. + Weight int64 `json:"weight"` + JSON routeNewResponseRouteJSON `json:"-"` +} + +// routeNewResponseRouteJSON contains the JSON metadata for the struct +// [RouteNewResponseRoute] +type routeNewResponseRouteJSON struct { + Nexthop apijson.Field + Prefix apijson.Field + Priority apijson.Field + ID apijson.Field + CreatedOn apijson.Field + Description apijson.Field + ModifiedOn apijson.Field + Scope apijson.Field + Weight apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteNewResponseRoute) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeNewResponseRouteJSON) RawJSON() string { + return r.raw +} + +// Used only for ECMP routes. +type RouteNewResponseRoutesScope struct { + // List of colo names for the ECMP scope. + ColoNames []string `json:"colo_names"` + // List of colo regions for the ECMP scope. + ColoRegions []string `json:"colo_regions"` + JSON routeNewResponseRoutesScopeJSON `json:"-"` +} + +// routeNewResponseRoutesScopeJSON contains the JSON metadata for the struct +// [RouteNewResponseRoutesScope] +type routeNewResponseRoutesScopeJSON struct { + ColoNames apijson.Field + ColoRegions apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteNewResponseRoutesScope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeNewResponseRoutesScopeJSON) RawJSON() string { + return r.raw +} + +type RouteUpdateResponse struct { + Modified bool `json:"modified"` + ModifiedRoute interface{} `json:"modified_route"` + JSON routeUpdateResponseJSON `json:"-"` +} + +// routeUpdateResponseJSON contains the JSON metadata for the struct +// [RouteUpdateResponse] +type routeUpdateResponseJSON struct { + Modified apijson.Field + ModifiedRoute apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeUpdateResponseJSON) RawJSON() string { + return r.raw +} + +type RouteListResponse struct { + Routes []RouteListResponseRoute `json:"routes"` + JSON routeListResponseJSON `json:"-"` +} + +// routeListResponseJSON contains the JSON metadata for the struct +// [RouteListResponse] +type routeListResponseJSON struct { + Routes apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeListResponseJSON) RawJSON() string { + return r.raw +} + +type RouteListResponseRoute struct { + // The next-hop IP Address for the static route. + Nexthop string `json:"nexthop,required"` + // IP Prefix in Classless Inter-Domain Routing format. + Prefix string `json:"prefix,required"` + // Priority of the static route. + Priority int64 `json:"priority,required"` + // Identifier + ID string `json:"id"` + // When the route was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // An optional human provided description of the static route. + Description string `json:"description"` + // When the route was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Used only for ECMP routes. + Scope RouteListResponseRoutesScope `json:"scope"` + // Optional weight of the ECMP scope - if provided. + Weight int64 `json:"weight"` + JSON routeListResponseRouteJSON `json:"-"` +} + +// routeListResponseRouteJSON contains the JSON metadata for the struct +// [RouteListResponseRoute] +type routeListResponseRouteJSON struct { + Nexthop apijson.Field + Prefix apijson.Field + Priority apijson.Field + ID apijson.Field + CreatedOn apijson.Field + Description apijson.Field + ModifiedOn apijson.Field + Scope apijson.Field + Weight apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteListResponseRoute) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeListResponseRouteJSON) RawJSON() string { + return r.raw +} + +// Used only for ECMP routes. +type RouteListResponseRoutesScope struct { + // List of colo names for the ECMP scope. + ColoNames []string `json:"colo_names"` + // List of colo regions for the ECMP scope. + ColoRegions []string `json:"colo_regions"` + JSON routeListResponseRoutesScopeJSON `json:"-"` +} + +// routeListResponseRoutesScopeJSON contains the JSON metadata for the struct +// [RouteListResponseRoutesScope] +type routeListResponseRoutesScopeJSON struct { + ColoNames apijson.Field + ColoRegions apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteListResponseRoutesScope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeListResponseRoutesScopeJSON) RawJSON() string { + return r.raw +} + +type RouteDeleteResponse struct { + Deleted bool `json:"deleted"` + DeletedRoute interface{} `json:"deleted_route"` + JSON routeDeleteResponseJSON `json:"-"` +} + +// routeDeleteResponseJSON contains the JSON metadata for the struct +// [RouteDeleteResponse] +type routeDeleteResponseJSON struct { + Deleted apijson.Field + DeletedRoute apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type RouteEmptyResponse struct { + Deleted bool `json:"deleted"` + DeletedRoutes interface{} `json:"deleted_routes"` + JSON routeEmptyResponseJSON `json:"-"` +} + +// routeEmptyResponseJSON contains the JSON metadata for the struct +// [RouteEmptyResponse] +type routeEmptyResponseJSON struct { + Deleted apijson.Field + DeletedRoutes apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteEmptyResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeEmptyResponseJSON) RawJSON() string { + return r.raw +} + +type RouteGetResponse struct { + Route interface{} `json:"route"` + JSON routeGetResponseJSON `json:"-"` +} + +// routeGetResponseJSON contains the JSON metadata for the struct +// [RouteGetResponse] +type routeGetResponseJSON struct { + Route apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeGetResponseJSON) RawJSON() string { + return r.raw +} + +type RouteNewParams struct { + Body param.Field[interface{}] `json:"body,required"` +} + +func (r RouteNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type RouteNewResponseEnvelope struct { + Errors []RouteNewResponseEnvelopeErrors `json:"errors,required"` + Messages []RouteNewResponseEnvelopeMessages `json:"messages,required"` + Result RouteNewResponse `json:"result,required"` + // Whether the API call was successful + Success RouteNewResponseEnvelopeSuccess `json:"success,required"` + JSON routeNewResponseEnvelopeJSON `json:"-"` +} + +// routeNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [RouteNewResponseEnvelope] +type routeNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RouteNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// routeNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RouteNewResponseEnvelopeErrors] +type routeNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RouteNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// routeNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RouteNewResponseEnvelopeMessages] +type routeNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RouteNewResponseEnvelopeSuccess bool + +const ( + RouteNewResponseEnvelopeSuccessTrue RouteNewResponseEnvelopeSuccess = true +) + +type RouteUpdateParams struct { + // The next-hop IP Address for the static route. + Nexthop param.Field[string] `json:"nexthop,required"` + // IP Prefix in Classless Inter-Domain Routing format. + Prefix param.Field[string] `json:"prefix,required"` + // Priority of the static route. + Priority param.Field[int64] `json:"priority,required"` + // An optional human provided description of the static route. + Description param.Field[string] `json:"description"` + // Used only for ECMP routes. + Scope param.Field[RouteUpdateParamsScope] `json:"scope"` + // Optional weight of the ECMP scope - if provided. + Weight param.Field[int64] `json:"weight"` +} + +func (r RouteUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Used only for ECMP routes. +type RouteUpdateParamsScope struct { + // List of colo names for the ECMP scope. + ColoNames param.Field[[]string] `json:"colo_names"` + // List of colo regions for the ECMP scope. + ColoRegions param.Field[[]string] `json:"colo_regions"` +} + +func (r RouteUpdateParamsScope) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RouteUpdateResponseEnvelope struct { + Errors []RouteUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []RouteUpdateResponseEnvelopeMessages `json:"messages,required"` + Result RouteUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success RouteUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON routeUpdateResponseEnvelopeJSON `json:"-"` +} + +// routeUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [RouteUpdateResponseEnvelope] +type routeUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RouteUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// routeUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RouteUpdateResponseEnvelopeErrors] +type routeUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RouteUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// routeUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RouteUpdateResponseEnvelopeMessages] +type routeUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RouteUpdateResponseEnvelopeSuccess bool + +const ( + RouteUpdateResponseEnvelopeSuccessTrue RouteUpdateResponseEnvelopeSuccess = true +) + +type RouteListResponseEnvelope struct { + Errors []RouteListResponseEnvelopeErrors `json:"errors,required"` + Messages []RouteListResponseEnvelopeMessages `json:"messages,required"` + Result RouteListResponse `json:"result,required"` + // Whether the API call was successful + Success RouteListResponseEnvelopeSuccess `json:"success,required"` + JSON routeListResponseEnvelopeJSON `json:"-"` +} + +// routeListResponseEnvelopeJSON contains the JSON metadata for the struct +// [RouteListResponseEnvelope] +type routeListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RouteListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeListResponseEnvelopeErrorsJSON `json:"-"` +} + +// routeListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RouteListResponseEnvelopeErrors] +type routeListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RouteListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeListResponseEnvelopeMessagesJSON `json:"-"` +} + +// routeListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RouteListResponseEnvelopeMessages] +type routeListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RouteListResponseEnvelopeSuccess bool + +const ( + RouteListResponseEnvelopeSuccessTrue RouteListResponseEnvelopeSuccess = true +) + +type RouteDeleteResponseEnvelope struct { + Errors []RouteDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []RouteDeleteResponseEnvelopeMessages `json:"messages,required"` + Result RouteDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success RouteDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON routeDeleteResponseEnvelopeJSON `json:"-"` +} + +// routeDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [RouteDeleteResponseEnvelope] +type routeDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RouteDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// routeDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RouteDeleteResponseEnvelopeErrors] +type routeDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RouteDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// routeDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RouteDeleteResponseEnvelopeMessages] +type routeDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RouteDeleteResponseEnvelopeSuccess bool + +const ( + RouteDeleteResponseEnvelopeSuccessTrue RouteDeleteResponseEnvelopeSuccess = true +) + +type RouteEmptyParams struct { + Routes param.Field[[]RouteEmptyParamsRoute] `json:"routes,required"` +} + +func (r RouteEmptyParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RouteEmptyParamsRoute struct { +} + +func (r RouteEmptyParamsRoute) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RouteEmptyResponseEnvelope struct { + Errors []RouteEmptyResponseEnvelopeErrors `json:"errors,required"` + Messages []RouteEmptyResponseEnvelopeMessages `json:"messages,required"` + Result RouteEmptyResponse `json:"result,required"` + // Whether the API call was successful + Success RouteEmptyResponseEnvelopeSuccess `json:"success,required"` + JSON routeEmptyResponseEnvelopeJSON `json:"-"` +} + +// routeEmptyResponseEnvelopeJSON contains the JSON metadata for the struct +// [RouteEmptyResponseEnvelope] +type routeEmptyResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteEmptyResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeEmptyResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RouteEmptyResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeEmptyResponseEnvelopeErrorsJSON `json:"-"` +} + +// routeEmptyResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RouteEmptyResponseEnvelopeErrors] +type routeEmptyResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteEmptyResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeEmptyResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RouteEmptyResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeEmptyResponseEnvelopeMessagesJSON `json:"-"` +} + +// routeEmptyResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RouteEmptyResponseEnvelopeMessages] +type routeEmptyResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteEmptyResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeEmptyResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RouteEmptyResponseEnvelopeSuccess bool + +const ( + RouteEmptyResponseEnvelopeSuccessTrue RouteEmptyResponseEnvelopeSuccess = true +) + +type RouteGetResponseEnvelope struct { + Errors []RouteGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RouteGetResponseEnvelopeMessages `json:"messages,required"` + Result RouteGetResponse `json:"result,required"` + // Whether the API call was successful + Success RouteGetResponseEnvelopeSuccess `json:"success,required"` + JSON routeGetResponseEnvelopeJSON `json:"-"` +} + +// routeGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RouteGetResponseEnvelope] +type routeGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RouteGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// routeGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RouteGetResponseEnvelopeErrors] +type routeGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RouteGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// routeGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RouteGetResponseEnvelopeMessages] +type routeGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RouteGetResponseEnvelopeSuccess bool + +const ( + RouteGetResponseEnvelopeSuccessTrue RouteGetResponseEnvelopeSuccess = true +) diff --git a/magic_transit/route_test.go b/magic_transit/route_test.go new file mode 100644 index 00000000000..178a0ff9d4d --- /dev/null +++ b/magic_transit/route_test.go @@ -0,0 +1,194 @@ +// File generated from our OpenAPI spec by Stainless. + +package magic_transit_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/magic_transit" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRouteNew(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("user@example.com"), + ) + _, err := client.MagicTransit.Routes.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + magic_transit.RouteNewParams{ + Body: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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 TestRouteUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.MagicTransit.Routes.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + magic_transit.RouteUpdateParams{ + Nexthop: cloudflare.F("203.0.113.1"), + Prefix: cloudflare.F("192.0.2.0/24"), + Priority: cloudflare.F(int64(0)), + Description: cloudflare.F("New route for new prefix 203.0.113.1"), + Scope: cloudflare.F(magic_transit.RouteUpdateParamsScope{ + ColoNames: cloudflare.F([]string{"den01", "den01", "den01"}), + ColoRegions: cloudflare.F([]string{"APAC", "APAC", "APAC"}), + }), + Weight: cloudflare.F(int64(0)), + }, + ) + 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 TestRouteList(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("user@example.com"), + ) + _, err := client.MagicTransit.Routes.List(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()) + } +} + +func TestRouteDelete(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("user@example.com"), + ) + _, err := client.MagicTransit.Routes.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "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()) + } +} + +func TestRouteEmpty(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("user@example.com"), + ) + _, err := client.MagicTransit.Routes.Empty( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + magic_transit.RouteEmptyParams{ + Routes: cloudflare.F([]magic_transit.RouteEmptyParamsRoute{{}, {}, {}}), + }, + ) + 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 TestRouteGet(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("user@example.com"), + ) + _, err := client.MagicTransit.Routes.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "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/magicnetworkmonitoringconfig.go b/magicnetworkmonitoringconfig.go deleted file mode 100644 index e9625f14619..00000000000 --- a/magicnetworkmonitoringconfig.go +++ /dev/null @@ -1,651 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// MagicNetworkMonitoringConfigService 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 -// [NewMagicNetworkMonitoringConfigService] method instead. -type MagicNetworkMonitoringConfigService struct { - Options []option.RequestOption - Full *MagicNetworkMonitoringConfigFullService -} - -// NewMagicNetworkMonitoringConfigService 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 NewMagicNetworkMonitoringConfigService(opts ...option.RequestOption) (r *MagicNetworkMonitoringConfigService) { - r = &MagicNetworkMonitoringConfigService{} - r.Options = opts - r.Full = NewMagicNetworkMonitoringConfigFullService(opts...) - return -} - -// Create a new network monitoring configuration. -func (r *MagicNetworkMonitoringConfigService) New(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *MagicNetworkMonitoringConfigNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicNetworkMonitoringConfigNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/mnm/config", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update an existing network monitoring configuration, requires the entire -// configuration to be updated at once. -func (r *MagicNetworkMonitoringConfigService) Update(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *MagicNetworkMonitoringConfigUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicNetworkMonitoringConfigUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/mnm/config", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete an existing network monitoring configuration. -func (r *MagicNetworkMonitoringConfigService) Delete(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *MagicNetworkMonitoringConfigDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicNetworkMonitoringConfigDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%v/mnm/config", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update fields in an existing network monitoring configuration. -func (r *MagicNetworkMonitoringConfigService) Edit(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *MagicNetworkMonitoringConfigEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicNetworkMonitoringConfigEditResponseEnvelope - path := fmt.Sprintf("accounts/%v/mnm/config", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists default sampling and router IPs for account. -func (r *MagicNetworkMonitoringConfigService) Get(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *MagicNetworkMonitoringConfigGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicNetworkMonitoringConfigGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/mnm/config", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type MagicNetworkMonitoringConfigNewResponse struct { - // Fallback sampling rate of flow messages being sent in packets per second. This - // should match the packet sampling rate configured on the router. - DefaultSampling float64 `json:"default_sampling,required"` - // The account name. - Name string `json:"name,required"` - RouterIPs []string `json:"router_ips,required"` - JSON magicNetworkMonitoringConfigNewResponseJSON `json:"-"` -} - -// magicNetworkMonitoringConfigNewResponseJSON contains the JSON metadata for the -// struct [MagicNetworkMonitoringConfigNewResponse] -type magicNetworkMonitoringConfigNewResponseJSON struct { - DefaultSampling apijson.Field - Name apijson.Field - RouterIPs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigNewResponseJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringConfigUpdateResponse struct { - // Fallback sampling rate of flow messages being sent in packets per second. This - // should match the packet sampling rate configured on the router. - DefaultSampling float64 `json:"default_sampling,required"` - // The account name. - Name string `json:"name,required"` - RouterIPs []string `json:"router_ips,required"` - JSON magicNetworkMonitoringConfigUpdateResponseJSON `json:"-"` -} - -// magicNetworkMonitoringConfigUpdateResponseJSON contains the JSON metadata for -// the struct [MagicNetworkMonitoringConfigUpdateResponse] -type magicNetworkMonitoringConfigUpdateResponseJSON struct { - DefaultSampling apijson.Field - Name apijson.Field - RouterIPs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringConfigDeleteResponse struct { - // Fallback sampling rate of flow messages being sent in packets per second. This - // should match the packet sampling rate configured on the router. - DefaultSampling float64 `json:"default_sampling,required"` - // The account name. - Name string `json:"name,required"` - RouterIPs []string `json:"router_ips,required"` - JSON magicNetworkMonitoringConfigDeleteResponseJSON `json:"-"` -} - -// magicNetworkMonitoringConfigDeleteResponseJSON contains the JSON metadata for -// the struct [MagicNetworkMonitoringConfigDeleteResponse] -type magicNetworkMonitoringConfigDeleteResponseJSON struct { - DefaultSampling apijson.Field - Name apijson.Field - RouterIPs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringConfigEditResponse struct { - // Fallback sampling rate of flow messages being sent in packets per second. This - // should match the packet sampling rate configured on the router. - DefaultSampling float64 `json:"default_sampling,required"` - // The account name. - Name string `json:"name,required"` - RouterIPs []string `json:"router_ips,required"` - JSON magicNetworkMonitoringConfigEditResponseJSON `json:"-"` -} - -// magicNetworkMonitoringConfigEditResponseJSON contains the JSON metadata for the -// struct [MagicNetworkMonitoringConfigEditResponse] -type magicNetworkMonitoringConfigEditResponseJSON struct { - DefaultSampling apijson.Field - Name apijson.Field - RouterIPs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigEditResponseJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringConfigGetResponse struct { - // Fallback sampling rate of flow messages being sent in packets per second. This - // should match the packet sampling rate configured on the router. - DefaultSampling float64 `json:"default_sampling,required"` - // The account name. - Name string `json:"name,required"` - RouterIPs []string `json:"router_ips,required"` - JSON magicNetworkMonitoringConfigGetResponseJSON `json:"-"` -} - -// magicNetworkMonitoringConfigGetResponseJSON contains the JSON metadata for the -// struct [MagicNetworkMonitoringConfigGetResponse] -type magicNetworkMonitoringConfigGetResponseJSON struct { - DefaultSampling apijson.Field - Name apijson.Field - RouterIPs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigGetResponseJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringConfigNewResponseEnvelope struct { - Errors []MagicNetworkMonitoringConfigNewResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicNetworkMonitoringConfigNewResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringConfigNewResponse `json:"result,required"` - // Whether the API call was successful - Success MagicNetworkMonitoringConfigNewResponseEnvelopeSuccess `json:"success,required"` - JSON magicNetworkMonitoringConfigNewResponseEnvelopeJSON `json:"-"` -} - -// magicNetworkMonitoringConfigNewResponseEnvelopeJSON contains the JSON metadata -// for the struct [MagicNetworkMonitoringConfigNewResponseEnvelope] -type magicNetworkMonitoringConfigNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringConfigNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringConfigNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicNetworkMonitoringConfigNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [MagicNetworkMonitoringConfigNewResponseEnvelopeErrors] -type magicNetworkMonitoringConfigNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringConfigNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringConfigNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicNetworkMonitoringConfigNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [MagicNetworkMonitoringConfigNewResponseEnvelopeMessages] -type magicNetworkMonitoringConfigNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicNetworkMonitoringConfigNewResponseEnvelopeSuccess bool - -const ( - MagicNetworkMonitoringConfigNewResponseEnvelopeSuccessTrue MagicNetworkMonitoringConfigNewResponseEnvelopeSuccess = true -) - -type MagicNetworkMonitoringConfigUpdateResponseEnvelope struct { - Errors []MagicNetworkMonitoringConfigUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicNetworkMonitoringConfigUpdateResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringConfigUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success MagicNetworkMonitoringConfigUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON magicNetworkMonitoringConfigUpdateResponseEnvelopeJSON `json:"-"` -} - -// magicNetworkMonitoringConfigUpdateResponseEnvelopeJSON contains the JSON -// metadata for the struct [MagicNetworkMonitoringConfigUpdateResponseEnvelope] -type magicNetworkMonitoringConfigUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringConfigUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringConfigUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicNetworkMonitoringConfigUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [MagicNetworkMonitoringConfigUpdateResponseEnvelopeErrors] -type magicNetworkMonitoringConfigUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringConfigUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringConfigUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicNetworkMonitoringConfigUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [MagicNetworkMonitoringConfigUpdateResponseEnvelopeMessages] -type magicNetworkMonitoringConfigUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicNetworkMonitoringConfigUpdateResponseEnvelopeSuccess bool - -const ( - MagicNetworkMonitoringConfigUpdateResponseEnvelopeSuccessTrue MagicNetworkMonitoringConfigUpdateResponseEnvelopeSuccess = true -) - -type MagicNetworkMonitoringConfigDeleteResponseEnvelope struct { - Errors []MagicNetworkMonitoringConfigDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicNetworkMonitoringConfigDeleteResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringConfigDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success MagicNetworkMonitoringConfigDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON magicNetworkMonitoringConfigDeleteResponseEnvelopeJSON `json:"-"` -} - -// magicNetworkMonitoringConfigDeleteResponseEnvelopeJSON contains the JSON -// metadata for the struct [MagicNetworkMonitoringConfigDeleteResponseEnvelope] -type magicNetworkMonitoringConfigDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringConfigDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringConfigDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicNetworkMonitoringConfigDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [MagicNetworkMonitoringConfigDeleteResponseEnvelopeErrors] -type magicNetworkMonitoringConfigDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringConfigDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringConfigDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicNetworkMonitoringConfigDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [MagicNetworkMonitoringConfigDeleteResponseEnvelopeMessages] -type magicNetworkMonitoringConfigDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicNetworkMonitoringConfigDeleteResponseEnvelopeSuccess bool - -const ( - MagicNetworkMonitoringConfigDeleteResponseEnvelopeSuccessTrue MagicNetworkMonitoringConfigDeleteResponseEnvelopeSuccess = true -) - -type MagicNetworkMonitoringConfigEditResponseEnvelope struct { - Errors []MagicNetworkMonitoringConfigEditResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicNetworkMonitoringConfigEditResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringConfigEditResponse `json:"result,required"` - // Whether the API call was successful - Success MagicNetworkMonitoringConfigEditResponseEnvelopeSuccess `json:"success,required"` - JSON magicNetworkMonitoringConfigEditResponseEnvelopeJSON `json:"-"` -} - -// magicNetworkMonitoringConfigEditResponseEnvelopeJSON contains the JSON metadata -// for the struct [MagicNetworkMonitoringConfigEditResponseEnvelope] -type magicNetworkMonitoringConfigEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringConfigEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringConfigEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicNetworkMonitoringConfigEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [MagicNetworkMonitoringConfigEditResponseEnvelopeErrors] -type magicNetworkMonitoringConfigEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringConfigEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringConfigEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicNetworkMonitoringConfigEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [MagicNetworkMonitoringConfigEditResponseEnvelopeMessages] -type magicNetworkMonitoringConfigEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicNetworkMonitoringConfigEditResponseEnvelopeSuccess bool - -const ( - MagicNetworkMonitoringConfigEditResponseEnvelopeSuccessTrue MagicNetworkMonitoringConfigEditResponseEnvelopeSuccess = true -) - -type MagicNetworkMonitoringConfigGetResponseEnvelope struct { - Errors []MagicNetworkMonitoringConfigGetResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicNetworkMonitoringConfigGetResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringConfigGetResponse `json:"result,required"` - // Whether the API call was successful - Success MagicNetworkMonitoringConfigGetResponseEnvelopeSuccess `json:"success,required"` - JSON magicNetworkMonitoringConfigGetResponseEnvelopeJSON `json:"-"` -} - -// magicNetworkMonitoringConfigGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [MagicNetworkMonitoringConfigGetResponseEnvelope] -type magicNetworkMonitoringConfigGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringConfigGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringConfigGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicNetworkMonitoringConfigGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [MagicNetworkMonitoringConfigGetResponseEnvelopeErrors] -type magicNetworkMonitoringConfigGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringConfigGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringConfigGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicNetworkMonitoringConfigGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [MagicNetworkMonitoringConfigGetResponseEnvelopeMessages] -type magicNetworkMonitoringConfigGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicNetworkMonitoringConfigGetResponseEnvelopeSuccess bool - -const ( - MagicNetworkMonitoringConfigGetResponseEnvelopeSuccessTrue MagicNetworkMonitoringConfigGetResponseEnvelopeSuccess = true -) diff --git a/magicnetworkmonitoringconfig_test.go b/magicnetworkmonitoringconfig_test.go deleted file mode 100644 index 32ba5a47b68..00000000000 --- a/magicnetworkmonitoringconfig_test.go +++ /dev/null @@ -1,134 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestMagicNetworkMonitoringConfigNew(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("user@example.com"), - ) - _, err := client.MagicNetworkMonitoring.Configs.New(context.TODO(), "6f91088a406011ed95aed352566e8d4c") - 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 TestMagicNetworkMonitoringConfigUpdate(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("user@example.com"), - ) - _, err := client.MagicNetworkMonitoring.Configs.Update(context.TODO(), "6f91088a406011ed95aed352566e8d4c") - 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 TestMagicNetworkMonitoringConfigDelete(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("user@example.com"), - ) - _, err := client.MagicNetworkMonitoring.Configs.Delete(context.TODO(), "6f91088a406011ed95aed352566e8d4c") - 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 TestMagicNetworkMonitoringConfigEdit(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("user@example.com"), - ) - _, err := client.MagicNetworkMonitoring.Configs.Edit(context.TODO(), "6f91088a406011ed95aed352566e8d4c") - 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 TestMagicNetworkMonitoringConfigGet(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("user@example.com"), - ) - _, err := client.MagicNetworkMonitoring.Configs.Get(context.TODO(), "6f91088a406011ed95aed352566e8d4c") - 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/magicnetworkmonitoringconfigfull.go b/magicnetworkmonitoringconfigfull.go deleted file mode 100644 index 79cab14f53a..00000000000 --- a/magicnetworkmonitoringconfigfull.go +++ /dev/null @@ -1,155 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// MagicNetworkMonitoringConfigFullService 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 -// [NewMagicNetworkMonitoringConfigFullService] method instead. -type MagicNetworkMonitoringConfigFullService struct { - Options []option.RequestOption -} - -// NewMagicNetworkMonitoringConfigFullService 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 NewMagicNetworkMonitoringConfigFullService(opts ...option.RequestOption) (r *MagicNetworkMonitoringConfigFullService) { - r = &MagicNetworkMonitoringConfigFullService{} - r.Options = opts - return -} - -// Lists default sampling, router IPs, and rules for account. -func (r *MagicNetworkMonitoringConfigFullService) Get(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *MagicNetworkMonitoringConfigFullGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicNetworkMonitoringConfigFullGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/mnm/config/full", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type MagicNetworkMonitoringConfigFullGetResponse struct { - // Fallback sampling rate of flow messages being sent in packets per second. This - // should match the packet sampling rate configured on the router. - DefaultSampling float64 `json:"default_sampling,required"` - // The account name. - Name string `json:"name,required"` - RouterIPs []string `json:"router_ips,required"` - JSON magicNetworkMonitoringConfigFullGetResponseJSON `json:"-"` -} - -// magicNetworkMonitoringConfigFullGetResponseJSON contains the JSON metadata for -// the struct [MagicNetworkMonitoringConfigFullGetResponse] -type magicNetworkMonitoringConfigFullGetResponseJSON struct { - DefaultSampling apijson.Field - Name apijson.Field - RouterIPs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigFullGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigFullGetResponseJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringConfigFullGetResponseEnvelope struct { - Errors []MagicNetworkMonitoringConfigFullGetResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicNetworkMonitoringConfigFullGetResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringConfigFullGetResponse `json:"result,required"` - // Whether the API call was successful - Success MagicNetworkMonitoringConfigFullGetResponseEnvelopeSuccess `json:"success,required"` - JSON magicNetworkMonitoringConfigFullGetResponseEnvelopeJSON `json:"-"` -} - -// magicNetworkMonitoringConfigFullGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [MagicNetworkMonitoringConfigFullGetResponseEnvelope] -type magicNetworkMonitoringConfigFullGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigFullGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigFullGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringConfigFullGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringConfigFullGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicNetworkMonitoringConfigFullGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [MagicNetworkMonitoringConfigFullGetResponseEnvelopeErrors] -type magicNetworkMonitoringConfigFullGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigFullGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigFullGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringConfigFullGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringConfigFullGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicNetworkMonitoringConfigFullGetResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [MagicNetworkMonitoringConfigFullGetResponseEnvelopeMessages] -type magicNetworkMonitoringConfigFullGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringConfigFullGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringConfigFullGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicNetworkMonitoringConfigFullGetResponseEnvelopeSuccess bool - -const ( - MagicNetworkMonitoringConfigFullGetResponseEnvelopeSuccessTrue MagicNetworkMonitoringConfigFullGetResponseEnvelopeSuccess = true -) diff --git a/magicnetworkmonitoringconfigfull_test.go b/magicnetworkmonitoringconfigfull_test.go deleted file mode 100644 index 1498385821a..00000000000 --- a/magicnetworkmonitoringconfigfull_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestMagicNetworkMonitoringConfigFullGet(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("user@example.com"), - ) - _, err := client.MagicNetworkMonitoring.Configs.Full.Get(context.TODO(), "6f91088a406011ed95aed352566e8d4c") - 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/magicnetworkmonitoringrule.go b/magicnetworkmonitoringrule.go deleted file mode 100644 index 04a75e9b554..00000000000 --- a/magicnetworkmonitoringrule.go +++ /dev/null @@ -1,922 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// MagicNetworkMonitoringRuleService 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 -// [NewMagicNetworkMonitoringRuleService] method instead. -type MagicNetworkMonitoringRuleService struct { - Options []option.RequestOption - Advertisements *MagicNetworkMonitoringRuleAdvertisementService -} - -// NewMagicNetworkMonitoringRuleService 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 NewMagicNetworkMonitoringRuleService(opts ...option.RequestOption) (r *MagicNetworkMonitoringRuleService) { - r = &MagicNetworkMonitoringRuleService{} - r.Options = opts - r.Advertisements = NewMagicNetworkMonitoringRuleAdvertisementService(opts...) - return -} - -// Create network monitoring rules for account. Currently only supports creating a -// single rule per API request. -func (r *MagicNetworkMonitoringRuleService) New(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *MagicNetworkMonitoringRuleNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicNetworkMonitoringRuleNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/mnm/rules", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update network monitoring rules for account. -func (r *MagicNetworkMonitoringRuleService) Update(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *MagicNetworkMonitoringRuleUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicNetworkMonitoringRuleUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/mnm/rules", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists network monitoring rules for account. -func (r *MagicNetworkMonitoringRuleService) List(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *[]MagicNetworkMonitoringRuleListResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicNetworkMonitoringRuleListResponseEnvelope - path := fmt.Sprintf("accounts/%v/mnm/rules", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a network monitoring rule for account. -func (r *MagicNetworkMonitoringRuleService) Delete(ctx context.Context, accountIdentifier interface{}, ruleIdentifier interface{}, opts ...option.RequestOption) (res *MagicNetworkMonitoringRuleDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicNetworkMonitoringRuleDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%v/mnm/rules/%v", accountIdentifier, ruleIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update a network monitoring rule for account. -func (r *MagicNetworkMonitoringRuleService) Edit(ctx context.Context, accountIdentifier interface{}, ruleIdentifier interface{}, opts ...option.RequestOption) (res *MagicNetworkMonitoringRuleEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicNetworkMonitoringRuleEditResponseEnvelope - path := fmt.Sprintf("accounts/%v/mnm/rules/%v", accountIdentifier, ruleIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List a single network monitoring rule for account. -func (r *MagicNetworkMonitoringRuleService) Get(ctx context.Context, accountIdentifier interface{}, ruleIdentifier interface{}, opts ...option.RequestOption) (res *MagicNetworkMonitoringRuleGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicNetworkMonitoringRuleGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/mnm/rules/%v", accountIdentifier, ruleIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type MagicNetworkMonitoringRuleNewResponse struct { - // Toggle on if you would like Cloudflare to automatically advertise the IP - // Prefixes within the rule via Magic Transit when the rule is triggered. Only - // available for users of Magic Transit. - AutomaticAdvertisement bool `json:"automatic_advertisement,required,nullable"` - // The amount of time that the rule threshold must be exceeded to send an alert - // notification. The final value must be equivalent to one of the following 8 - // values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is - // AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at - // least one unit must be provided. - Duration string `json:"duration,required"` - // The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, - // underscore (\_), dash (-), period (.), and tilde (~). You can’t have a space in - // the rule name. Max 256 characters. - Name string `json:"name,required"` - Prefixes []string `json:"prefixes,required"` - ID interface{} `json:"id"` - // The number of bits per second for the rule. When this value is exceeded for the - // set duration, an alert notification is sent. Minimum of 1 and no maximum. - BandwidthThreshold float64 `json:"bandwidth_threshold"` - // The number of packets per second for the rule. When this value is exceeded for - // the set duration, an alert notification is sent. Minimum of 1 and no maximum. - PacketThreshold float64 `json:"packet_threshold"` - JSON magicNetworkMonitoringRuleNewResponseJSON `json:"-"` -} - -// magicNetworkMonitoringRuleNewResponseJSON contains the JSON metadata for the -// struct [MagicNetworkMonitoringRuleNewResponse] -type magicNetworkMonitoringRuleNewResponseJSON struct { - AutomaticAdvertisement apijson.Field - Duration apijson.Field - Name apijson.Field - Prefixes apijson.Field - ID apijson.Field - BandwidthThreshold apijson.Field - PacketThreshold apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleNewResponseJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleUpdateResponse struct { - // Toggle on if you would like Cloudflare to automatically advertise the IP - // Prefixes within the rule via Magic Transit when the rule is triggered. Only - // available for users of Magic Transit. - AutomaticAdvertisement bool `json:"automatic_advertisement,required,nullable"` - // The amount of time that the rule threshold must be exceeded to send an alert - // notification. The final value must be equivalent to one of the following 8 - // values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is - // AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at - // least one unit must be provided. - Duration string `json:"duration,required"` - // The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, - // underscore (\_), dash (-), period (.), and tilde (~). You can’t have a space in - // the rule name. Max 256 characters. - Name string `json:"name,required"` - Prefixes []string `json:"prefixes,required"` - ID interface{} `json:"id"` - // The number of bits per second for the rule. When this value is exceeded for the - // set duration, an alert notification is sent. Minimum of 1 and no maximum. - BandwidthThreshold float64 `json:"bandwidth_threshold"` - // The number of packets per second for the rule. When this value is exceeded for - // the set duration, an alert notification is sent. Minimum of 1 and no maximum. - PacketThreshold float64 `json:"packet_threshold"` - JSON magicNetworkMonitoringRuleUpdateResponseJSON `json:"-"` -} - -// magicNetworkMonitoringRuleUpdateResponseJSON contains the JSON metadata for the -// struct [MagicNetworkMonitoringRuleUpdateResponse] -type magicNetworkMonitoringRuleUpdateResponseJSON struct { - AutomaticAdvertisement apijson.Field - Duration apijson.Field - Name apijson.Field - Prefixes apijson.Field - ID apijson.Field - BandwidthThreshold apijson.Field - PacketThreshold apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleListResponse struct { - // Toggle on if you would like Cloudflare to automatically advertise the IP - // Prefixes within the rule via Magic Transit when the rule is triggered. Only - // available for users of Magic Transit. - AutomaticAdvertisement bool `json:"automatic_advertisement,required,nullable"` - // The amount of time that the rule threshold must be exceeded to send an alert - // notification. The final value must be equivalent to one of the following 8 - // values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is - // AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at - // least one unit must be provided. - Duration string `json:"duration,required"` - // The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, - // underscore (\_), dash (-), period (.), and tilde (~). You can’t have a space in - // the rule name. Max 256 characters. - Name string `json:"name,required"` - Prefixes []string `json:"prefixes,required"` - ID interface{} `json:"id"` - // The number of bits per second for the rule. When this value is exceeded for the - // set duration, an alert notification is sent. Minimum of 1 and no maximum. - BandwidthThreshold float64 `json:"bandwidth_threshold"` - // The number of packets per second for the rule. When this value is exceeded for - // the set duration, an alert notification is sent. Minimum of 1 and no maximum. - PacketThreshold float64 `json:"packet_threshold"` - JSON magicNetworkMonitoringRuleListResponseJSON `json:"-"` -} - -// magicNetworkMonitoringRuleListResponseJSON contains the JSON metadata for the -// struct [MagicNetworkMonitoringRuleListResponse] -type magicNetworkMonitoringRuleListResponseJSON struct { - AutomaticAdvertisement apijson.Field - Duration apijson.Field - Name apijson.Field - Prefixes apijson.Field - ID apijson.Field - BandwidthThreshold apijson.Field - PacketThreshold apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleListResponseJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleDeleteResponse struct { - // Toggle on if you would like Cloudflare to automatically advertise the IP - // Prefixes within the rule via Magic Transit when the rule is triggered. Only - // available for users of Magic Transit. - AutomaticAdvertisement bool `json:"automatic_advertisement,required,nullable"` - // The amount of time that the rule threshold must be exceeded to send an alert - // notification. The final value must be equivalent to one of the following 8 - // values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is - // AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at - // least one unit must be provided. - Duration string `json:"duration,required"` - // The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, - // underscore (\_), dash (-), period (.), and tilde (~). You can’t have a space in - // the rule name. Max 256 characters. - Name string `json:"name,required"` - Prefixes []string `json:"prefixes,required"` - ID interface{} `json:"id"` - // The number of bits per second for the rule. When this value is exceeded for the - // set duration, an alert notification is sent. Minimum of 1 and no maximum. - BandwidthThreshold float64 `json:"bandwidth_threshold"` - // The number of packets per second for the rule. When this value is exceeded for - // the set duration, an alert notification is sent. Minimum of 1 and no maximum. - PacketThreshold float64 `json:"packet_threshold"` - JSON magicNetworkMonitoringRuleDeleteResponseJSON `json:"-"` -} - -// magicNetworkMonitoringRuleDeleteResponseJSON contains the JSON metadata for the -// struct [MagicNetworkMonitoringRuleDeleteResponse] -type magicNetworkMonitoringRuleDeleteResponseJSON struct { - AutomaticAdvertisement apijson.Field - Duration apijson.Field - Name apijson.Field - Prefixes apijson.Field - ID apijson.Field - BandwidthThreshold apijson.Field - PacketThreshold apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleEditResponse struct { - // Toggle on if you would like Cloudflare to automatically advertise the IP - // Prefixes within the rule via Magic Transit when the rule is triggered. Only - // available for users of Magic Transit. - AutomaticAdvertisement bool `json:"automatic_advertisement,required,nullable"` - // The amount of time that the rule threshold must be exceeded to send an alert - // notification. The final value must be equivalent to one of the following 8 - // values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is - // AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at - // least one unit must be provided. - Duration string `json:"duration,required"` - // The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, - // underscore (\_), dash (-), period (.), and tilde (~). You can’t have a space in - // the rule name. Max 256 characters. - Name string `json:"name,required"` - Prefixes []string `json:"prefixes,required"` - ID interface{} `json:"id"` - // The number of bits per second for the rule. When this value is exceeded for the - // set duration, an alert notification is sent. Minimum of 1 and no maximum. - BandwidthThreshold float64 `json:"bandwidth_threshold"` - // The number of packets per second for the rule. When this value is exceeded for - // the set duration, an alert notification is sent. Minimum of 1 and no maximum. - PacketThreshold float64 `json:"packet_threshold"` - JSON magicNetworkMonitoringRuleEditResponseJSON `json:"-"` -} - -// magicNetworkMonitoringRuleEditResponseJSON contains the JSON metadata for the -// struct [MagicNetworkMonitoringRuleEditResponse] -type magicNetworkMonitoringRuleEditResponseJSON struct { - AutomaticAdvertisement apijson.Field - Duration apijson.Field - Name apijson.Field - Prefixes apijson.Field - ID apijson.Field - BandwidthThreshold apijson.Field - PacketThreshold apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleEditResponseJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleGetResponse struct { - // Toggle on if you would like Cloudflare to automatically advertise the IP - // Prefixes within the rule via Magic Transit when the rule is triggered. Only - // available for users of Magic Transit. - AutomaticAdvertisement bool `json:"automatic_advertisement,required,nullable"` - // The amount of time that the rule threshold must be exceeded to send an alert - // notification. The final value must be equivalent to one of the following 8 - // values ["1m","5m","10m","15m","20m","30m","45m","60m"]. The format is - // AhBmCsDmsEusFns where A, B, C, D, E and F durations are optional; however at - // least one unit must be provided. - Duration string `json:"duration,required"` - // The name of the rule. Must be unique. Supports characters A-Z, a-z, 0-9, - // underscore (\_), dash (-), period (.), and tilde (~). You can’t have a space in - // the rule name. Max 256 characters. - Name string `json:"name,required"` - Prefixes []string `json:"prefixes,required"` - ID interface{} `json:"id"` - // The number of bits per second for the rule. When this value is exceeded for the - // set duration, an alert notification is sent. Minimum of 1 and no maximum. - BandwidthThreshold float64 `json:"bandwidth_threshold"` - // The number of packets per second for the rule. When this value is exceeded for - // the set duration, an alert notification is sent. Minimum of 1 and no maximum. - PacketThreshold float64 `json:"packet_threshold"` - JSON magicNetworkMonitoringRuleGetResponseJSON `json:"-"` -} - -// magicNetworkMonitoringRuleGetResponseJSON contains the JSON metadata for the -// struct [MagicNetworkMonitoringRuleGetResponse] -type magicNetworkMonitoringRuleGetResponseJSON struct { - AutomaticAdvertisement apijson.Field - Duration apijson.Field - Name apijson.Field - Prefixes apijson.Field - ID apijson.Field - BandwidthThreshold apijson.Field - PacketThreshold apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleGetResponseJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleNewResponseEnvelope struct { - Errors []MagicNetworkMonitoringRuleNewResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicNetworkMonitoringRuleNewResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringRuleNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success MagicNetworkMonitoringRuleNewResponseEnvelopeSuccess `json:"success,required"` - JSON magicNetworkMonitoringRuleNewResponseEnvelopeJSON `json:"-"` -} - -// magicNetworkMonitoringRuleNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [MagicNetworkMonitoringRuleNewResponseEnvelope] -type magicNetworkMonitoringRuleNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringRuleNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicNetworkMonitoringRuleNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [MagicNetworkMonitoringRuleNewResponseEnvelopeErrors] -type magicNetworkMonitoringRuleNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringRuleNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicNetworkMonitoringRuleNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [MagicNetworkMonitoringRuleNewResponseEnvelopeMessages] -type magicNetworkMonitoringRuleNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicNetworkMonitoringRuleNewResponseEnvelopeSuccess bool - -const ( - MagicNetworkMonitoringRuleNewResponseEnvelopeSuccessTrue MagicNetworkMonitoringRuleNewResponseEnvelopeSuccess = true -) - -type MagicNetworkMonitoringRuleUpdateResponseEnvelope struct { - Errors []MagicNetworkMonitoringRuleUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicNetworkMonitoringRuleUpdateResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringRuleUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success MagicNetworkMonitoringRuleUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON magicNetworkMonitoringRuleUpdateResponseEnvelopeJSON `json:"-"` -} - -// magicNetworkMonitoringRuleUpdateResponseEnvelopeJSON contains the JSON metadata -// for the struct [MagicNetworkMonitoringRuleUpdateResponseEnvelope] -type magicNetworkMonitoringRuleUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringRuleUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicNetworkMonitoringRuleUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [MagicNetworkMonitoringRuleUpdateResponseEnvelopeErrors] -type magicNetworkMonitoringRuleUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringRuleUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicNetworkMonitoringRuleUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [MagicNetworkMonitoringRuleUpdateResponseEnvelopeMessages] -type magicNetworkMonitoringRuleUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicNetworkMonitoringRuleUpdateResponseEnvelopeSuccess bool - -const ( - MagicNetworkMonitoringRuleUpdateResponseEnvelopeSuccessTrue MagicNetworkMonitoringRuleUpdateResponseEnvelopeSuccess = true -) - -type MagicNetworkMonitoringRuleListResponseEnvelope struct { - Errors []MagicNetworkMonitoringRuleListResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicNetworkMonitoringRuleListResponseEnvelopeMessages `json:"messages,required"` - Result []MagicNetworkMonitoringRuleListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success MagicNetworkMonitoringRuleListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo MagicNetworkMonitoringRuleListResponseEnvelopeResultInfo `json:"result_info"` - JSON magicNetworkMonitoringRuleListResponseEnvelopeJSON `json:"-"` -} - -// magicNetworkMonitoringRuleListResponseEnvelopeJSON contains the JSON metadata -// for the struct [MagicNetworkMonitoringRuleListResponseEnvelope] -type magicNetworkMonitoringRuleListResponseEnvelopeJSON 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 *MagicNetworkMonitoringRuleListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringRuleListResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicNetworkMonitoringRuleListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [MagicNetworkMonitoringRuleListResponseEnvelopeErrors] -type magicNetworkMonitoringRuleListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringRuleListResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicNetworkMonitoringRuleListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [MagicNetworkMonitoringRuleListResponseEnvelopeMessages] -type magicNetworkMonitoringRuleListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicNetworkMonitoringRuleListResponseEnvelopeSuccess bool - -const ( - MagicNetworkMonitoringRuleListResponseEnvelopeSuccessTrue MagicNetworkMonitoringRuleListResponseEnvelopeSuccess = true -) - -type MagicNetworkMonitoringRuleListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON magicNetworkMonitoringRuleListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// magicNetworkMonitoringRuleListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [MagicNetworkMonitoringRuleListResponseEnvelopeResultInfo] -type magicNetworkMonitoringRuleListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleDeleteResponseEnvelope struct { - Errors []MagicNetworkMonitoringRuleDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicNetworkMonitoringRuleDeleteResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringRuleDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success MagicNetworkMonitoringRuleDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON magicNetworkMonitoringRuleDeleteResponseEnvelopeJSON `json:"-"` -} - -// magicNetworkMonitoringRuleDeleteResponseEnvelopeJSON contains the JSON metadata -// for the struct [MagicNetworkMonitoringRuleDeleteResponseEnvelope] -type magicNetworkMonitoringRuleDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringRuleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicNetworkMonitoringRuleDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [MagicNetworkMonitoringRuleDeleteResponseEnvelopeErrors] -type magicNetworkMonitoringRuleDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringRuleDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicNetworkMonitoringRuleDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [MagicNetworkMonitoringRuleDeleteResponseEnvelopeMessages] -type magicNetworkMonitoringRuleDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicNetworkMonitoringRuleDeleteResponseEnvelopeSuccess bool - -const ( - MagicNetworkMonitoringRuleDeleteResponseEnvelopeSuccessTrue MagicNetworkMonitoringRuleDeleteResponseEnvelopeSuccess = true -) - -type MagicNetworkMonitoringRuleEditResponseEnvelope struct { - Errors []MagicNetworkMonitoringRuleEditResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicNetworkMonitoringRuleEditResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringRuleEditResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success MagicNetworkMonitoringRuleEditResponseEnvelopeSuccess `json:"success,required"` - JSON magicNetworkMonitoringRuleEditResponseEnvelopeJSON `json:"-"` -} - -// magicNetworkMonitoringRuleEditResponseEnvelopeJSON contains the JSON metadata -// for the struct [MagicNetworkMonitoringRuleEditResponseEnvelope] -type magicNetworkMonitoringRuleEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringRuleEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicNetworkMonitoringRuleEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [MagicNetworkMonitoringRuleEditResponseEnvelopeErrors] -type magicNetworkMonitoringRuleEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringRuleEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicNetworkMonitoringRuleEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [MagicNetworkMonitoringRuleEditResponseEnvelopeMessages] -type magicNetworkMonitoringRuleEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicNetworkMonitoringRuleEditResponseEnvelopeSuccess bool - -const ( - MagicNetworkMonitoringRuleEditResponseEnvelopeSuccessTrue MagicNetworkMonitoringRuleEditResponseEnvelopeSuccess = true -) - -type MagicNetworkMonitoringRuleGetResponseEnvelope struct { - Errors []MagicNetworkMonitoringRuleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicNetworkMonitoringRuleGetResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringRuleGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success MagicNetworkMonitoringRuleGetResponseEnvelopeSuccess `json:"success,required"` - JSON magicNetworkMonitoringRuleGetResponseEnvelopeJSON `json:"-"` -} - -// magicNetworkMonitoringRuleGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [MagicNetworkMonitoringRuleGetResponseEnvelope] -type magicNetworkMonitoringRuleGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringRuleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicNetworkMonitoringRuleGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [MagicNetworkMonitoringRuleGetResponseEnvelopeErrors] -type magicNetworkMonitoringRuleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringRuleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicNetworkMonitoringRuleGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [MagicNetworkMonitoringRuleGetResponseEnvelopeMessages] -type magicNetworkMonitoringRuleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicNetworkMonitoringRuleGetResponseEnvelopeSuccess bool - -const ( - MagicNetworkMonitoringRuleGetResponseEnvelopeSuccessTrue MagicNetworkMonitoringRuleGetResponseEnvelopeSuccess = true -) diff --git a/magicnetworkmonitoringrule_test.go b/magicnetworkmonitoringrule_test.go deleted file mode 100644 index 8722e3eb187..00000000000 --- a/magicnetworkmonitoringrule_test.go +++ /dev/null @@ -1,170 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestMagicNetworkMonitoringRuleNew(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("user@example.com"), - ) - _, err := client.MagicNetworkMonitoring.Rules.New(context.TODO(), "6f91088a406011ed95aed352566e8d4c") - 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 TestMagicNetworkMonitoringRuleUpdate(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("user@example.com"), - ) - _, err := client.MagicNetworkMonitoring.Rules.Update(context.TODO(), "6f91088a406011ed95aed352566e8d4c") - 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 TestMagicNetworkMonitoringRuleList(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("user@example.com"), - ) - _, err := client.MagicNetworkMonitoring.Rules.List(context.TODO(), "6f91088a406011ed95aed352566e8d4c") - 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 TestMagicNetworkMonitoringRuleDelete(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("user@example.com"), - ) - _, err := client.MagicNetworkMonitoring.Rules.Delete( - context.TODO(), - "6f91088a406011ed95aed352566e8d4c", - "2890e6fa406311ed9b5a23f70f6fb8cf", - ) - 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 TestMagicNetworkMonitoringRuleEdit(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("user@example.com"), - ) - _, err := client.MagicNetworkMonitoring.Rules.Edit( - context.TODO(), - "6f91088a406011ed95aed352566e8d4c", - "2890e6fa406311ed9b5a23f70f6fb8cf", - ) - 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 TestMagicNetworkMonitoringRuleGet(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("user@example.com"), - ) - _, err := client.MagicNetworkMonitoring.Rules.Get( - context.TODO(), - "6f91088a406011ed95aed352566e8d4c", - "2890e6fa406311ed9b5a23f70f6fb8cf", - ) - 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/magicnetworkmonitoringruleadvertisement.go b/magicnetworkmonitoringruleadvertisement.go deleted file mode 100644 index 5365c0f173e..00000000000 --- a/magicnetworkmonitoringruleadvertisement.go +++ /dev/null @@ -1,153 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// MagicNetworkMonitoringRuleAdvertisementService 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 [NewMagicNetworkMonitoringRuleAdvertisementService] method instead. -type MagicNetworkMonitoringRuleAdvertisementService struct { - Options []option.RequestOption -} - -// NewMagicNetworkMonitoringRuleAdvertisementService 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 NewMagicNetworkMonitoringRuleAdvertisementService(opts ...option.RequestOption) (r *MagicNetworkMonitoringRuleAdvertisementService) { - r = &MagicNetworkMonitoringRuleAdvertisementService{} - r.Options = opts - return -} - -// Update advertisement for rule. -func (r *MagicNetworkMonitoringRuleAdvertisementService) Edit(ctx context.Context, accountIdentifier interface{}, ruleIdentifier interface{}, opts ...option.RequestOption) (res *MagicNetworkMonitoringRuleAdvertisementEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicNetworkMonitoringRuleAdvertisementEditResponseEnvelope - path := fmt.Sprintf("accounts/%v/mnm/rules/%v/advertisement", accountIdentifier, ruleIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type MagicNetworkMonitoringRuleAdvertisementEditResponse struct { - // Toggle on if you would like Cloudflare to automatically advertise the IP - // Prefixes within the rule via Magic Transit when the rule is triggered. Only - // available for users of Magic Transit. - AutomaticAdvertisement bool `json:"automatic_advertisement,required,nullable"` - JSON magicNetworkMonitoringRuleAdvertisementEditResponseJSON `json:"-"` -} - -// magicNetworkMonitoringRuleAdvertisementEditResponseJSON contains the JSON -// metadata for the struct [MagicNetworkMonitoringRuleAdvertisementEditResponse] -type magicNetworkMonitoringRuleAdvertisementEditResponseJSON struct { - AutomaticAdvertisement apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleAdvertisementEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleAdvertisementEditResponseJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleAdvertisementEditResponseEnvelope struct { - Errors []MagicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeMessages `json:"messages,required"` - Result MagicNetworkMonitoringRuleAdvertisementEditResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success MagicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeSuccess `json:"success,required"` - JSON magicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeJSON `json:"-"` -} - -// magicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeJSON contains the -// JSON metadata for the struct -// [MagicNetworkMonitoringRuleAdvertisementEditResponseEnvelope] -type magicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleAdvertisementEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeErrorsJSON contains -// the JSON metadata for the struct -// [MagicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeErrors] -type magicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeMessagesJSON contains -// the JSON metadata for the struct -// [MagicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeMessages] -type magicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeSuccess bool - -const ( - MagicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeSuccessTrue MagicNetworkMonitoringRuleAdvertisementEditResponseEnvelopeSuccess = true -) diff --git a/magicnetworkmonitoringruleadvertisement_test.go b/magicnetworkmonitoringruleadvertisement_test.go deleted file mode 100644 index ff901c1374d..00000000000 --- a/magicnetworkmonitoringruleadvertisement_test.go +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestMagicNetworkMonitoringRuleAdvertisementEdit(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("user@example.com"), - ) - _, err := client.MagicNetworkMonitoring.Rules.Advertisements.Edit( - context.TODO(), - "6f91088a406011ed95aed352566e8d4c", - "2890e6fa406311ed9b5a23f70f6fb8cf", - ) - 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/magictransit.go b/magictransit.go deleted file mode 100644 index 56d27cd3ac4..00000000000 --- a/magictransit.go +++ /dev/null @@ -1,33 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// MagicTransitService 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 [NewMagicTransitService] method -// instead. -type MagicTransitService struct { - Options []option.RequestOption - CfInterconnects *MagicTransitCfInterconnectService - GRETunnels *MagicTransitGRETunnelService - IPSECTunnels *MagicTransitIPSECTunnelService - Routes *MagicTransitRouteService -} - -// NewMagicTransitService 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 NewMagicTransitService(opts ...option.RequestOption) (r *MagicTransitService) { - r = &MagicTransitService{} - r.Options = opts - r.CfInterconnects = NewMagicTransitCfInterconnectService(opts...) - r.GRETunnels = NewMagicTransitGRETunnelService(opts...) - r.IPSECTunnels = NewMagicTransitIPSECTunnelService(opts...) - r.Routes = NewMagicTransitRouteService(opts...) - return -} diff --git a/magictransitcfinterconnect.go b/magictransitcfinterconnect.go deleted file mode 100644 index cc92ee14f98..00000000000 --- a/magictransitcfinterconnect.go +++ /dev/null @@ -1,573 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// MagicTransitCfInterconnectService 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 -// [NewMagicTransitCfInterconnectService] method instead. -type MagicTransitCfInterconnectService struct { - Options []option.RequestOption -} - -// NewMagicTransitCfInterconnectService 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 NewMagicTransitCfInterconnectService(opts ...option.RequestOption) (r *MagicTransitCfInterconnectService) { - r = &MagicTransitCfInterconnectService{} - r.Options = opts - return -} - -// Updates a specific interconnect associated with an account. Use -// `?validate_only=true` as an optional query parameter to only run validation -// without persisting changes. -func (r *MagicTransitCfInterconnectService) Update(ctx context.Context, accountIdentifier string, tunnelIdentifier string, body MagicTransitCfInterconnectUpdateParams, opts ...option.RequestOption) (res *MagicTransitCfInterconnectUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitCfInterconnectUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/cf_interconnects/%s", accountIdentifier, tunnelIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists interconnects associated with an account. -func (r *MagicTransitCfInterconnectService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *MagicTransitCfInterconnectListResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitCfInterconnectListResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/cf_interconnects", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists details for a specific interconnect. -func (r *MagicTransitCfInterconnectService) Get(ctx context.Context, accountIdentifier string, tunnelIdentifier string, opts ...option.RequestOption) (res *MagicTransitCfInterconnectGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitCfInterconnectGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/cf_interconnects/%s", accountIdentifier, tunnelIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type MagicTransitCfInterconnectUpdateResponse struct { - Modified bool `json:"modified"` - ModifiedInterconnect interface{} `json:"modified_interconnect"` - JSON magicTransitCfInterconnectUpdateResponseJSON `json:"-"` -} - -// magicTransitCfInterconnectUpdateResponseJSON contains the JSON metadata for the -// struct [MagicTransitCfInterconnectUpdateResponse] -type magicTransitCfInterconnectUpdateResponseJSON struct { - Modified apijson.Field - ModifiedInterconnect apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitCfInterconnectUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitCfInterconnectUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitCfInterconnectListResponse struct { - Interconnects []MagicTransitCfInterconnectListResponseInterconnect `json:"interconnects"` - JSON magicTransitCfInterconnectListResponseJSON `json:"-"` -} - -// magicTransitCfInterconnectListResponseJSON contains the JSON metadata for the -// struct [MagicTransitCfInterconnectListResponse] -type magicTransitCfInterconnectListResponseJSON struct { - Interconnects apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitCfInterconnectListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitCfInterconnectListResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitCfInterconnectListResponseInterconnect struct { - // Tunnel identifier tag. - ID string `json:"id"` - // The name of the interconnect. The name cannot share a name with other tunnels. - ColoName string `json:"colo_name"` - // The date and time the tunnel was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // An optional description of the interconnect. - Description string `json:"description"` - // The configuration specific to GRE interconnects. - GRE MagicTransitCfInterconnectListResponseInterconnectsGRE `json:"gre"` - HealthCheck MagicTransitCfInterconnectListResponseInterconnectsHealthCheck `json:"health_check"` - // A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side - // of the tunnel. Select the subnet from the following private IP space: - // 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. - InterfaceAddress string `json:"interface_address"` - // The date and time the tunnel was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The Maximum Transmission Unit (MTU) in bytes for the interconnect. The minimum - // value is 576. - Mtu int64 `json:"mtu"` - // The name of the interconnect. The name cannot share a name with other tunnels. - Name string `json:"name"` - JSON magicTransitCfInterconnectListResponseInterconnectJSON `json:"-"` -} - -// magicTransitCfInterconnectListResponseInterconnectJSON contains the JSON -// metadata for the struct [MagicTransitCfInterconnectListResponseInterconnect] -type magicTransitCfInterconnectListResponseInterconnectJSON struct { - ID apijson.Field - ColoName apijson.Field - CreatedOn apijson.Field - Description apijson.Field - GRE apijson.Field - HealthCheck apijson.Field - InterfaceAddress apijson.Field - ModifiedOn apijson.Field - Mtu apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitCfInterconnectListResponseInterconnect) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitCfInterconnectListResponseInterconnectJSON) RawJSON() string { - return r.raw -} - -// The configuration specific to GRE interconnects. -type MagicTransitCfInterconnectListResponseInterconnectsGRE struct { - // The IP address assigned to the Cloudflare side of the GRE tunnel created as part - // of the Interconnect. - CloudflareEndpoint string `json:"cloudflare_endpoint"` - JSON magicTransitCfInterconnectListResponseInterconnectsGREJSON `json:"-"` -} - -// magicTransitCfInterconnectListResponseInterconnectsGREJSON contains the JSON -// metadata for the struct [MagicTransitCfInterconnectListResponseInterconnectsGRE] -type magicTransitCfInterconnectListResponseInterconnectsGREJSON struct { - CloudflareEndpoint apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitCfInterconnectListResponseInterconnectsGRE) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitCfInterconnectListResponseInterconnectsGREJSON) RawJSON() string { - return r.raw -} - -type MagicTransitCfInterconnectListResponseInterconnectsHealthCheck struct { - // Determines whether to run healthchecks for a tunnel. - Enabled bool `json:"enabled"` - // How frequent the health check is run. The default value is `mid`. - Rate MagicTransitCfInterconnectListResponseInterconnectsHealthCheckRate `json:"rate"` - // The destination address in a request type health check. After the healthcheck is - // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded - // to this address. This field defaults to `customer_gre_endpoint address`. - Target string `json:"target"` - // The type of healthcheck to run, reply or request. The default value is `reply`. - Type MagicTransitCfInterconnectListResponseInterconnectsHealthCheckType `json:"type"` - JSON magicTransitCfInterconnectListResponseInterconnectsHealthCheckJSON `json:"-"` -} - -// magicTransitCfInterconnectListResponseInterconnectsHealthCheckJSON contains the -// JSON metadata for the struct -// [MagicTransitCfInterconnectListResponseInterconnectsHealthCheck] -type magicTransitCfInterconnectListResponseInterconnectsHealthCheckJSON struct { - Enabled apijson.Field - Rate apijson.Field - Target apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitCfInterconnectListResponseInterconnectsHealthCheck) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitCfInterconnectListResponseInterconnectsHealthCheckJSON) RawJSON() string { - return r.raw -} - -// How frequent the health check is run. The default value is `mid`. -type MagicTransitCfInterconnectListResponseInterconnectsHealthCheckRate string - -const ( - MagicTransitCfInterconnectListResponseInterconnectsHealthCheckRateLow MagicTransitCfInterconnectListResponseInterconnectsHealthCheckRate = "low" - MagicTransitCfInterconnectListResponseInterconnectsHealthCheckRateMid MagicTransitCfInterconnectListResponseInterconnectsHealthCheckRate = "mid" - MagicTransitCfInterconnectListResponseInterconnectsHealthCheckRateHigh MagicTransitCfInterconnectListResponseInterconnectsHealthCheckRate = "high" -) - -// The type of healthcheck to run, reply or request. The default value is `reply`. -type MagicTransitCfInterconnectListResponseInterconnectsHealthCheckType string - -const ( - MagicTransitCfInterconnectListResponseInterconnectsHealthCheckTypeReply MagicTransitCfInterconnectListResponseInterconnectsHealthCheckType = "reply" - MagicTransitCfInterconnectListResponseInterconnectsHealthCheckTypeRequest MagicTransitCfInterconnectListResponseInterconnectsHealthCheckType = "request" -) - -type MagicTransitCfInterconnectGetResponse struct { - Interconnect interface{} `json:"interconnect"` - JSON magicTransitCfInterconnectGetResponseJSON `json:"-"` -} - -// magicTransitCfInterconnectGetResponseJSON contains the JSON metadata for the -// struct [MagicTransitCfInterconnectGetResponse] -type magicTransitCfInterconnectGetResponseJSON struct { - Interconnect apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitCfInterconnectGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitCfInterconnectGetResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitCfInterconnectUpdateParams struct { - // An optional description of the interconnect. - Description param.Field[string] `json:"description"` - // The configuration specific to GRE interconnects. - GRE param.Field[MagicTransitCfInterconnectUpdateParamsGRE] `json:"gre"` - HealthCheck param.Field[MagicTransitCfInterconnectUpdateParamsHealthCheck] `json:"health_check"` - // A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side - // of the tunnel. Select the subnet from the following private IP space: - // 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. - InterfaceAddress param.Field[string] `json:"interface_address"` - // The Maximum Transmission Unit (MTU) in bytes for the interconnect. The minimum - // value is 576. - Mtu param.Field[int64] `json:"mtu"` -} - -func (r MagicTransitCfInterconnectUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The configuration specific to GRE interconnects. -type MagicTransitCfInterconnectUpdateParamsGRE struct { - // The IP address assigned to the Cloudflare side of the GRE tunnel created as part - // of the Interconnect. - CloudflareEndpoint param.Field[string] `json:"cloudflare_endpoint"` -} - -func (r MagicTransitCfInterconnectUpdateParamsGRE) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MagicTransitCfInterconnectUpdateParamsHealthCheck struct { - // Determines whether to run healthchecks for a tunnel. - Enabled param.Field[bool] `json:"enabled"` - // How frequent the health check is run. The default value is `mid`. - Rate param.Field[MagicTransitCfInterconnectUpdateParamsHealthCheckRate] `json:"rate"` - // The destination address in a request type health check. After the healthcheck is - // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded - // to this address. This field defaults to `customer_gre_endpoint address`. - Target param.Field[string] `json:"target"` - // The type of healthcheck to run, reply or request. The default value is `reply`. - Type param.Field[MagicTransitCfInterconnectUpdateParamsHealthCheckType] `json:"type"` -} - -func (r MagicTransitCfInterconnectUpdateParamsHealthCheck) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// How frequent the health check is run. The default value is `mid`. -type MagicTransitCfInterconnectUpdateParamsHealthCheckRate string - -const ( - MagicTransitCfInterconnectUpdateParamsHealthCheckRateLow MagicTransitCfInterconnectUpdateParamsHealthCheckRate = "low" - MagicTransitCfInterconnectUpdateParamsHealthCheckRateMid MagicTransitCfInterconnectUpdateParamsHealthCheckRate = "mid" - MagicTransitCfInterconnectUpdateParamsHealthCheckRateHigh MagicTransitCfInterconnectUpdateParamsHealthCheckRate = "high" -) - -// The type of healthcheck to run, reply or request. The default value is `reply`. -type MagicTransitCfInterconnectUpdateParamsHealthCheckType string - -const ( - MagicTransitCfInterconnectUpdateParamsHealthCheckTypeReply MagicTransitCfInterconnectUpdateParamsHealthCheckType = "reply" - MagicTransitCfInterconnectUpdateParamsHealthCheckTypeRequest MagicTransitCfInterconnectUpdateParamsHealthCheckType = "request" -) - -type MagicTransitCfInterconnectUpdateResponseEnvelope struct { - Errors []MagicTransitCfInterconnectUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitCfInterconnectUpdateResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitCfInterconnectUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitCfInterconnectUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitCfInterconnectUpdateResponseEnvelopeJSON `json:"-"` -} - -// magicTransitCfInterconnectUpdateResponseEnvelopeJSON contains the JSON metadata -// for the struct [MagicTransitCfInterconnectUpdateResponseEnvelope] -type magicTransitCfInterconnectUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitCfInterconnectUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitCfInterconnectUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitCfInterconnectUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitCfInterconnectUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitCfInterconnectUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [MagicTransitCfInterconnectUpdateResponseEnvelopeErrors] -type magicTransitCfInterconnectUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitCfInterconnectUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitCfInterconnectUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitCfInterconnectUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitCfInterconnectUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitCfInterconnectUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [MagicTransitCfInterconnectUpdateResponseEnvelopeMessages] -type magicTransitCfInterconnectUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitCfInterconnectUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitCfInterconnectUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitCfInterconnectUpdateResponseEnvelopeSuccess bool - -const ( - MagicTransitCfInterconnectUpdateResponseEnvelopeSuccessTrue MagicTransitCfInterconnectUpdateResponseEnvelopeSuccess = true -) - -type MagicTransitCfInterconnectListResponseEnvelope struct { - Errors []MagicTransitCfInterconnectListResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitCfInterconnectListResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitCfInterconnectListResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitCfInterconnectListResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitCfInterconnectListResponseEnvelopeJSON `json:"-"` -} - -// magicTransitCfInterconnectListResponseEnvelopeJSON contains the JSON metadata -// for the struct [MagicTransitCfInterconnectListResponseEnvelope] -type magicTransitCfInterconnectListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitCfInterconnectListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitCfInterconnectListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitCfInterconnectListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitCfInterconnectListResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitCfInterconnectListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [MagicTransitCfInterconnectListResponseEnvelopeErrors] -type magicTransitCfInterconnectListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitCfInterconnectListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitCfInterconnectListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitCfInterconnectListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitCfInterconnectListResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitCfInterconnectListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [MagicTransitCfInterconnectListResponseEnvelopeMessages] -type magicTransitCfInterconnectListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitCfInterconnectListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitCfInterconnectListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitCfInterconnectListResponseEnvelopeSuccess bool - -const ( - MagicTransitCfInterconnectListResponseEnvelopeSuccessTrue MagicTransitCfInterconnectListResponseEnvelopeSuccess = true -) - -type MagicTransitCfInterconnectGetResponseEnvelope struct { - Errors []MagicTransitCfInterconnectGetResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitCfInterconnectGetResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitCfInterconnectGetResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitCfInterconnectGetResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitCfInterconnectGetResponseEnvelopeJSON `json:"-"` -} - -// magicTransitCfInterconnectGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [MagicTransitCfInterconnectGetResponseEnvelope] -type magicTransitCfInterconnectGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitCfInterconnectGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitCfInterconnectGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitCfInterconnectGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitCfInterconnectGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitCfInterconnectGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [MagicTransitCfInterconnectGetResponseEnvelopeErrors] -type magicTransitCfInterconnectGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitCfInterconnectGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitCfInterconnectGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitCfInterconnectGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitCfInterconnectGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitCfInterconnectGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [MagicTransitCfInterconnectGetResponseEnvelopeMessages] -type magicTransitCfInterconnectGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitCfInterconnectGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitCfInterconnectGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitCfInterconnectGetResponseEnvelopeSuccess bool - -const ( - MagicTransitCfInterconnectGetResponseEnvelopeSuccessTrue MagicTransitCfInterconnectGetResponseEnvelopeSuccess = true -) diff --git a/magictransitcfinterconnect_test.go b/magictransitcfinterconnect_test.go deleted file mode 100644 index 50b2be4be74..00000000000 --- a/magictransitcfinterconnect_test.go +++ /dev/null @@ -1,108 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestMagicTransitCfInterconnectUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.MagicTransit.CfInterconnects.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.MagicTransitCfInterconnectUpdateParams{ - Description: cloudflare.F("Tunnel for Interconnect to ORD"), - GRE: cloudflare.F(cloudflare.MagicTransitCfInterconnectUpdateParamsGRE{ - CloudflareEndpoint: cloudflare.F("203.0.113.1"), - }), - HealthCheck: cloudflare.F(cloudflare.MagicTransitCfInterconnectUpdateParamsHealthCheck{ - Enabled: cloudflare.F(true), - Rate: cloudflare.F(cloudflare.MagicTransitCfInterconnectUpdateParamsHealthCheckRateLow), - Target: cloudflare.F("203.0.113.1"), - Type: cloudflare.F(cloudflare.MagicTransitCfInterconnectUpdateParamsHealthCheckTypeRequest), - }), - InterfaceAddress: cloudflare.F("192.0.2.0/31"), - Mtu: cloudflare.F(int64(0)), - }, - ) - 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 TestMagicTransitCfInterconnectList(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("user@example.com"), - ) - _, err := client.MagicTransit.CfInterconnects.List(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()) - } -} - -func TestMagicTransitCfInterconnectGet(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("user@example.com"), - ) - _, err := client.MagicTransit.CfInterconnects.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "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/magictransitgretunnel.go b/magictransitgretunnel.go deleted file mode 100644 index b6a23489840..00000000000 --- a/magictransitgretunnel.go +++ /dev/null @@ -1,961 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// MagicTransitGRETunnelService 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 [NewMagicTransitGRETunnelService] -// method instead. -type MagicTransitGRETunnelService struct { - Options []option.RequestOption -} - -// NewMagicTransitGRETunnelService 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 NewMagicTransitGRETunnelService(opts ...option.RequestOption) (r *MagicTransitGRETunnelService) { - r = &MagicTransitGRETunnelService{} - r.Options = opts - return -} - -// Creates new GRE tunnels. Use `?validate_only=true` as an optional query -// parameter to only run validation without persisting changes. -func (r *MagicTransitGRETunnelService) New(ctx context.Context, accountIdentifier string, body MagicTransitGRETunnelNewParams, opts ...option.RequestOption) (res *MagicTransitGRETunnelNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitGRETunnelNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/gre_tunnels", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a specific GRE tunnel. Use `?validate_only=true` as an optional query -// parameter to only run validation without persisting changes. -func (r *MagicTransitGRETunnelService) Update(ctx context.Context, accountIdentifier string, tunnelIdentifier string, body MagicTransitGRETunnelUpdateParams, opts ...option.RequestOption) (res *MagicTransitGRETunnelUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitGRETunnelUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/gre_tunnels/%s", accountIdentifier, tunnelIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists GRE tunnels associated with an account. -func (r *MagicTransitGRETunnelService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *MagicTransitGRETunnelListResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitGRETunnelListResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/gre_tunnels", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Disables and removes a specific static GRE tunnel. Use `?validate_only=true` as -// an optional query parameter to only run validation without persisting changes. -func (r *MagicTransitGRETunnelService) Delete(ctx context.Context, accountIdentifier string, tunnelIdentifier string, opts ...option.RequestOption) (res *MagicTransitGRETunnelDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitGRETunnelDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/gre_tunnels/%s", accountIdentifier, tunnelIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists informtion for a specific GRE tunnel. -func (r *MagicTransitGRETunnelService) Get(ctx context.Context, accountIdentifier string, tunnelIdentifier string, opts ...option.RequestOption) (res *MagicTransitGRETunnelGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitGRETunnelGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/gre_tunnels/%s", accountIdentifier, tunnelIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type MagicTransitGRETunnelNewResponse struct { - GRETunnels []MagicTransitGRETunnelNewResponseGRETunnel `json:"gre_tunnels"` - JSON magicTransitGRETunnelNewResponseJSON `json:"-"` -} - -// magicTransitGRETunnelNewResponseJSON contains the JSON metadata for the struct -// [MagicTransitGRETunnelNewResponse] -type magicTransitGRETunnelNewResponseJSON struct { - GRETunnels apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelNewResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitGRETunnelNewResponseGRETunnel struct { - // The IP address assigned to the Cloudflare side of the GRE tunnel. - CloudflareGREEndpoint string `json:"cloudflare_gre_endpoint,required"` - // The IP address assigned to the customer side of the GRE tunnel. - CustomerGREEndpoint string `json:"customer_gre_endpoint,required"` - // A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side - // of the tunnel. Select the subnet from the following private IP space: - // 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. - InterfaceAddress string `json:"interface_address,required"` - // The name of the tunnel. The name cannot contain spaces or special characters, - // must be 15 characters or less, and cannot share a name with another GRE tunnel. - Name string `json:"name,required"` - // Tunnel identifier tag. - ID string `json:"id"` - // The date and time the tunnel was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // An optional description of the GRE tunnel. - Description string `json:"description"` - HealthCheck MagicTransitGRETunnelNewResponseGRETunnelsHealthCheck `json:"health_check"` - // The date and time the tunnel was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value - // is 576. - Mtu int64 `json:"mtu"` - // Time To Live (TTL) in number of hops of the GRE tunnel. - TTL int64 `json:"ttl"` - JSON magicTransitGRETunnelNewResponseGRETunnelJSON `json:"-"` -} - -// magicTransitGRETunnelNewResponseGRETunnelJSON contains the JSON metadata for the -// struct [MagicTransitGRETunnelNewResponseGRETunnel] -type magicTransitGRETunnelNewResponseGRETunnelJSON struct { - CloudflareGREEndpoint apijson.Field - CustomerGREEndpoint apijson.Field - InterfaceAddress apijson.Field - Name apijson.Field - ID apijson.Field - CreatedOn apijson.Field - Description apijson.Field - HealthCheck apijson.Field - ModifiedOn apijson.Field - Mtu apijson.Field - TTL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelNewResponseGRETunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelNewResponseGRETunnelJSON) RawJSON() string { - return r.raw -} - -type MagicTransitGRETunnelNewResponseGRETunnelsHealthCheck struct { - // The direction of the flow of the healthcheck. Either unidirectional, where the - // probe comes to you via the tunnel and the result comes back to Cloudflare via - // the open Internet, or bidirectional where both the probe and result come and go - // via the tunnel. Note in the case of bidirecitonal healthchecks, the target field - // in health_check is ignored as the interface_address is used to send traffic into - // the tunnel. - Direction MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckDirection `json:"direction"` - // Determines whether to run healthchecks for a tunnel. - Enabled bool `json:"enabled"` - // How frequent the health check is run. The default value is `mid`. - Rate MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckRate `json:"rate"` - // The destination address in a request type health check. After the healthcheck is - // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded - // to this address. This field defaults to `customer_gre_endpoint address`. This - // field is ignored for bidirectional healthchecks as the interface_address (not - // assigned to the Cloudflare side of the tunnel) is used as the target. - Target string `json:"target"` - // The type of healthcheck to run, reply or request. The default value is `reply`. - Type MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckType `json:"type"` - JSON magicTransitGRETunnelNewResponseGRETunnelsHealthCheckJSON `json:"-"` -} - -// magicTransitGRETunnelNewResponseGRETunnelsHealthCheckJSON contains the JSON -// metadata for the struct [MagicTransitGRETunnelNewResponseGRETunnelsHealthCheck] -type magicTransitGRETunnelNewResponseGRETunnelsHealthCheckJSON struct { - Direction apijson.Field - Enabled apijson.Field - Rate apijson.Field - Target apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelNewResponseGRETunnelsHealthCheck) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelNewResponseGRETunnelsHealthCheckJSON) RawJSON() string { - return r.raw -} - -// The direction of the flow of the healthcheck. Either unidirectional, where the -// probe comes to you via the tunnel and the result comes back to Cloudflare via -// the open Internet, or bidirectional where both the probe and result come and go -// via the tunnel. Note in the case of bidirecitonal healthchecks, the target field -// in health_check is ignored as the interface_address is used to send traffic into -// the tunnel. -type MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckDirection string - -const ( - MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckDirectionUnidirectional MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckDirection = "unidirectional" - MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckDirectionBidirectional MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckDirection = "bidirectional" -) - -// How frequent the health check is run. The default value is `mid`. -type MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckRate string - -const ( - MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckRateLow MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckRate = "low" - MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckRateMid MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckRate = "mid" - MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckRateHigh MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckRate = "high" -) - -// The type of healthcheck to run, reply or request. The default value is `reply`. -type MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckType string - -const ( - MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckTypeReply MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckType = "reply" - MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckTypeRequest MagicTransitGRETunnelNewResponseGRETunnelsHealthCheckType = "request" -) - -type MagicTransitGRETunnelUpdateResponse struct { - Modified bool `json:"modified"` - ModifiedGRETunnel interface{} `json:"modified_gre_tunnel"` - JSON magicTransitGRETunnelUpdateResponseJSON `json:"-"` -} - -// magicTransitGRETunnelUpdateResponseJSON contains the JSON metadata for the -// struct [MagicTransitGRETunnelUpdateResponse] -type magicTransitGRETunnelUpdateResponseJSON struct { - Modified apijson.Field - ModifiedGRETunnel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitGRETunnelListResponse struct { - GRETunnels []MagicTransitGRETunnelListResponseGRETunnel `json:"gre_tunnels"` - JSON magicTransitGRETunnelListResponseJSON `json:"-"` -} - -// magicTransitGRETunnelListResponseJSON contains the JSON metadata for the struct -// [MagicTransitGRETunnelListResponse] -type magicTransitGRETunnelListResponseJSON struct { - GRETunnels apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelListResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitGRETunnelListResponseGRETunnel struct { - // The IP address assigned to the Cloudflare side of the GRE tunnel. - CloudflareGREEndpoint string `json:"cloudflare_gre_endpoint,required"` - // The IP address assigned to the customer side of the GRE tunnel. - CustomerGREEndpoint string `json:"customer_gre_endpoint,required"` - // A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side - // of the tunnel. Select the subnet from the following private IP space: - // 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. - InterfaceAddress string `json:"interface_address,required"` - // The name of the tunnel. The name cannot contain spaces or special characters, - // must be 15 characters or less, and cannot share a name with another GRE tunnel. - Name string `json:"name,required"` - // Tunnel identifier tag. - ID string `json:"id"` - // The date and time the tunnel was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // An optional description of the GRE tunnel. - Description string `json:"description"` - HealthCheck MagicTransitGRETunnelListResponseGRETunnelsHealthCheck `json:"health_check"` - // The date and time the tunnel was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value - // is 576. - Mtu int64 `json:"mtu"` - // Time To Live (TTL) in number of hops of the GRE tunnel. - TTL int64 `json:"ttl"` - JSON magicTransitGRETunnelListResponseGRETunnelJSON `json:"-"` -} - -// magicTransitGRETunnelListResponseGRETunnelJSON contains the JSON metadata for -// the struct [MagicTransitGRETunnelListResponseGRETunnel] -type magicTransitGRETunnelListResponseGRETunnelJSON struct { - CloudflareGREEndpoint apijson.Field - CustomerGREEndpoint apijson.Field - InterfaceAddress apijson.Field - Name apijson.Field - ID apijson.Field - CreatedOn apijson.Field - Description apijson.Field - HealthCheck apijson.Field - ModifiedOn apijson.Field - Mtu apijson.Field - TTL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelListResponseGRETunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelListResponseGRETunnelJSON) RawJSON() string { - return r.raw -} - -type MagicTransitGRETunnelListResponseGRETunnelsHealthCheck struct { - // The direction of the flow of the healthcheck. Either unidirectional, where the - // probe comes to you via the tunnel and the result comes back to Cloudflare via - // the open Internet, or bidirectional where both the probe and result come and go - // via the tunnel. Note in the case of bidirecitonal healthchecks, the target field - // in health_check is ignored as the interface_address is used to send traffic into - // the tunnel. - Direction MagicTransitGRETunnelListResponseGRETunnelsHealthCheckDirection `json:"direction"` - // Determines whether to run healthchecks for a tunnel. - Enabled bool `json:"enabled"` - // How frequent the health check is run. The default value is `mid`. - Rate MagicTransitGRETunnelListResponseGRETunnelsHealthCheckRate `json:"rate"` - // The destination address in a request type health check. After the healthcheck is - // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded - // to this address. This field defaults to `customer_gre_endpoint address`. This - // field is ignored for bidirectional healthchecks as the interface_address (not - // assigned to the Cloudflare side of the tunnel) is used as the target. - Target string `json:"target"` - // The type of healthcheck to run, reply or request. The default value is `reply`. - Type MagicTransitGRETunnelListResponseGRETunnelsHealthCheckType `json:"type"` - JSON magicTransitGRETunnelListResponseGRETunnelsHealthCheckJSON `json:"-"` -} - -// magicTransitGRETunnelListResponseGRETunnelsHealthCheckJSON contains the JSON -// metadata for the struct [MagicTransitGRETunnelListResponseGRETunnelsHealthCheck] -type magicTransitGRETunnelListResponseGRETunnelsHealthCheckJSON struct { - Direction apijson.Field - Enabled apijson.Field - Rate apijson.Field - Target apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelListResponseGRETunnelsHealthCheck) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelListResponseGRETunnelsHealthCheckJSON) RawJSON() string { - return r.raw -} - -// The direction of the flow of the healthcheck. Either unidirectional, where the -// probe comes to you via the tunnel and the result comes back to Cloudflare via -// the open Internet, or bidirectional where both the probe and result come and go -// via the tunnel. Note in the case of bidirecitonal healthchecks, the target field -// in health_check is ignored as the interface_address is used to send traffic into -// the tunnel. -type MagicTransitGRETunnelListResponseGRETunnelsHealthCheckDirection string - -const ( - MagicTransitGRETunnelListResponseGRETunnelsHealthCheckDirectionUnidirectional MagicTransitGRETunnelListResponseGRETunnelsHealthCheckDirection = "unidirectional" - MagicTransitGRETunnelListResponseGRETunnelsHealthCheckDirectionBidirectional MagicTransitGRETunnelListResponseGRETunnelsHealthCheckDirection = "bidirectional" -) - -// How frequent the health check is run. The default value is `mid`. -type MagicTransitGRETunnelListResponseGRETunnelsHealthCheckRate string - -const ( - MagicTransitGRETunnelListResponseGRETunnelsHealthCheckRateLow MagicTransitGRETunnelListResponseGRETunnelsHealthCheckRate = "low" - MagicTransitGRETunnelListResponseGRETunnelsHealthCheckRateMid MagicTransitGRETunnelListResponseGRETunnelsHealthCheckRate = "mid" - MagicTransitGRETunnelListResponseGRETunnelsHealthCheckRateHigh MagicTransitGRETunnelListResponseGRETunnelsHealthCheckRate = "high" -) - -// The type of healthcheck to run, reply or request. The default value is `reply`. -type MagicTransitGRETunnelListResponseGRETunnelsHealthCheckType string - -const ( - MagicTransitGRETunnelListResponseGRETunnelsHealthCheckTypeReply MagicTransitGRETunnelListResponseGRETunnelsHealthCheckType = "reply" - MagicTransitGRETunnelListResponseGRETunnelsHealthCheckTypeRequest MagicTransitGRETunnelListResponseGRETunnelsHealthCheckType = "request" -) - -type MagicTransitGRETunnelDeleteResponse struct { - Deleted bool `json:"deleted"` - DeletedGRETunnel interface{} `json:"deleted_gre_tunnel"` - JSON magicTransitGRETunnelDeleteResponseJSON `json:"-"` -} - -// magicTransitGRETunnelDeleteResponseJSON contains the JSON metadata for the -// struct [MagicTransitGRETunnelDeleteResponse] -type magicTransitGRETunnelDeleteResponseJSON struct { - Deleted apijson.Field - DeletedGRETunnel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitGRETunnelGetResponse struct { - GRETunnel interface{} `json:"gre_tunnel"` - JSON magicTransitGRETunnelGetResponseJSON `json:"-"` -} - -// magicTransitGRETunnelGetResponseJSON contains the JSON metadata for the struct -// [MagicTransitGRETunnelGetResponse] -type magicTransitGRETunnelGetResponseJSON struct { - GRETunnel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelGetResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitGRETunnelNewParams struct { - Body param.Field[interface{}] `json:"body,required"` -} - -func (r MagicTransitGRETunnelNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type MagicTransitGRETunnelNewResponseEnvelope struct { - Errors []MagicTransitGRETunnelNewResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitGRETunnelNewResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitGRETunnelNewResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitGRETunnelNewResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitGRETunnelNewResponseEnvelopeJSON `json:"-"` -} - -// magicTransitGRETunnelNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [MagicTransitGRETunnelNewResponseEnvelope] -type magicTransitGRETunnelNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitGRETunnelNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitGRETunnelNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitGRETunnelNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [MagicTransitGRETunnelNewResponseEnvelopeErrors] -type magicTransitGRETunnelNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitGRETunnelNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitGRETunnelNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitGRETunnelNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [MagicTransitGRETunnelNewResponseEnvelopeMessages] -type magicTransitGRETunnelNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitGRETunnelNewResponseEnvelopeSuccess bool - -const ( - MagicTransitGRETunnelNewResponseEnvelopeSuccessTrue MagicTransitGRETunnelNewResponseEnvelopeSuccess = true -) - -type MagicTransitGRETunnelUpdateParams struct { - // The IP address assigned to the Cloudflare side of the GRE tunnel. - CloudflareGREEndpoint param.Field[string] `json:"cloudflare_gre_endpoint,required"` - // The IP address assigned to the customer side of the GRE tunnel. - CustomerGREEndpoint param.Field[string] `json:"customer_gre_endpoint,required"` - // A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side - // of the tunnel. Select the subnet from the following private IP space: - // 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. - InterfaceAddress param.Field[string] `json:"interface_address,required"` - // The name of the tunnel. The name cannot contain spaces or special characters, - // must be 15 characters or less, and cannot share a name with another GRE tunnel. - Name param.Field[string] `json:"name,required"` - // An optional description of the GRE tunnel. - Description param.Field[string] `json:"description"` - HealthCheck param.Field[MagicTransitGRETunnelUpdateParamsHealthCheck] `json:"health_check"` - // Maximum Transmission Unit (MTU) in bytes for the GRE tunnel. The minimum value - // is 576. - Mtu param.Field[int64] `json:"mtu"` - // Time To Live (TTL) in number of hops of the GRE tunnel. - TTL param.Field[int64] `json:"ttl"` -} - -func (r MagicTransitGRETunnelUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MagicTransitGRETunnelUpdateParamsHealthCheck struct { - // The direction of the flow of the healthcheck. Either unidirectional, where the - // probe comes to you via the tunnel and the result comes back to Cloudflare via - // the open Internet, or bidirectional where both the probe and result come and go - // via the tunnel. Note in the case of bidirecitonal healthchecks, the target field - // in health_check is ignored as the interface_address is used to send traffic into - // the tunnel. - Direction param.Field[MagicTransitGRETunnelUpdateParamsHealthCheckDirection] `json:"direction"` - // Determines whether to run healthchecks for a tunnel. - Enabled param.Field[bool] `json:"enabled"` - // How frequent the health check is run. The default value is `mid`. - Rate param.Field[MagicTransitGRETunnelUpdateParamsHealthCheckRate] `json:"rate"` - // The destination address in a request type health check. After the healthcheck is - // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded - // to this address. This field defaults to `customer_gre_endpoint address`. This - // field is ignored for bidirectional healthchecks as the interface_address (not - // assigned to the Cloudflare side of the tunnel) is used as the target. - Target param.Field[string] `json:"target"` - // The type of healthcheck to run, reply or request. The default value is `reply`. - Type param.Field[MagicTransitGRETunnelUpdateParamsHealthCheckType] `json:"type"` -} - -func (r MagicTransitGRETunnelUpdateParamsHealthCheck) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The direction of the flow of the healthcheck. Either unidirectional, where the -// probe comes to you via the tunnel and the result comes back to Cloudflare via -// the open Internet, or bidirectional where both the probe and result come and go -// via the tunnel. Note in the case of bidirecitonal healthchecks, the target field -// in health_check is ignored as the interface_address is used to send traffic into -// the tunnel. -type MagicTransitGRETunnelUpdateParamsHealthCheckDirection string - -const ( - MagicTransitGRETunnelUpdateParamsHealthCheckDirectionUnidirectional MagicTransitGRETunnelUpdateParamsHealthCheckDirection = "unidirectional" - MagicTransitGRETunnelUpdateParamsHealthCheckDirectionBidirectional MagicTransitGRETunnelUpdateParamsHealthCheckDirection = "bidirectional" -) - -// How frequent the health check is run. The default value is `mid`. -type MagicTransitGRETunnelUpdateParamsHealthCheckRate string - -const ( - MagicTransitGRETunnelUpdateParamsHealthCheckRateLow MagicTransitGRETunnelUpdateParamsHealthCheckRate = "low" - MagicTransitGRETunnelUpdateParamsHealthCheckRateMid MagicTransitGRETunnelUpdateParamsHealthCheckRate = "mid" - MagicTransitGRETunnelUpdateParamsHealthCheckRateHigh MagicTransitGRETunnelUpdateParamsHealthCheckRate = "high" -) - -// The type of healthcheck to run, reply or request. The default value is `reply`. -type MagicTransitGRETunnelUpdateParamsHealthCheckType string - -const ( - MagicTransitGRETunnelUpdateParamsHealthCheckTypeReply MagicTransitGRETunnelUpdateParamsHealthCheckType = "reply" - MagicTransitGRETunnelUpdateParamsHealthCheckTypeRequest MagicTransitGRETunnelUpdateParamsHealthCheckType = "request" -) - -type MagicTransitGRETunnelUpdateResponseEnvelope struct { - Errors []MagicTransitGRETunnelUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitGRETunnelUpdateResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitGRETunnelUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitGRETunnelUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitGRETunnelUpdateResponseEnvelopeJSON `json:"-"` -} - -// magicTransitGRETunnelUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [MagicTransitGRETunnelUpdateResponseEnvelope] -type magicTransitGRETunnelUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitGRETunnelUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitGRETunnelUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitGRETunnelUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [MagicTransitGRETunnelUpdateResponseEnvelopeErrors] -type magicTransitGRETunnelUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitGRETunnelUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitGRETunnelUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitGRETunnelUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [MagicTransitGRETunnelUpdateResponseEnvelopeMessages] -type magicTransitGRETunnelUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitGRETunnelUpdateResponseEnvelopeSuccess bool - -const ( - MagicTransitGRETunnelUpdateResponseEnvelopeSuccessTrue MagicTransitGRETunnelUpdateResponseEnvelopeSuccess = true -) - -type MagicTransitGRETunnelListResponseEnvelope struct { - Errors []MagicTransitGRETunnelListResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitGRETunnelListResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitGRETunnelListResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitGRETunnelListResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitGRETunnelListResponseEnvelopeJSON `json:"-"` -} - -// magicTransitGRETunnelListResponseEnvelopeJSON contains the JSON metadata for the -// struct [MagicTransitGRETunnelListResponseEnvelope] -type magicTransitGRETunnelListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitGRETunnelListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitGRETunnelListResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitGRETunnelListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [MagicTransitGRETunnelListResponseEnvelopeErrors] -type magicTransitGRETunnelListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitGRETunnelListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitGRETunnelListResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitGRETunnelListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [MagicTransitGRETunnelListResponseEnvelopeMessages] -type magicTransitGRETunnelListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitGRETunnelListResponseEnvelopeSuccess bool - -const ( - MagicTransitGRETunnelListResponseEnvelopeSuccessTrue MagicTransitGRETunnelListResponseEnvelopeSuccess = true -) - -type MagicTransitGRETunnelDeleteResponseEnvelope struct { - Errors []MagicTransitGRETunnelDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitGRETunnelDeleteResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitGRETunnelDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitGRETunnelDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitGRETunnelDeleteResponseEnvelopeJSON `json:"-"` -} - -// magicTransitGRETunnelDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [MagicTransitGRETunnelDeleteResponseEnvelope] -type magicTransitGRETunnelDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitGRETunnelDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitGRETunnelDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitGRETunnelDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [MagicTransitGRETunnelDeleteResponseEnvelopeErrors] -type magicTransitGRETunnelDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitGRETunnelDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitGRETunnelDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitGRETunnelDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [MagicTransitGRETunnelDeleteResponseEnvelopeMessages] -type magicTransitGRETunnelDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitGRETunnelDeleteResponseEnvelopeSuccess bool - -const ( - MagicTransitGRETunnelDeleteResponseEnvelopeSuccessTrue MagicTransitGRETunnelDeleteResponseEnvelopeSuccess = true -) - -type MagicTransitGRETunnelGetResponseEnvelope struct { - Errors []MagicTransitGRETunnelGetResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitGRETunnelGetResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitGRETunnelGetResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitGRETunnelGetResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitGRETunnelGetResponseEnvelopeJSON `json:"-"` -} - -// magicTransitGRETunnelGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [MagicTransitGRETunnelGetResponseEnvelope] -type magicTransitGRETunnelGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitGRETunnelGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitGRETunnelGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitGRETunnelGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [MagicTransitGRETunnelGetResponseEnvelopeErrors] -type magicTransitGRETunnelGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitGRETunnelGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitGRETunnelGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitGRETunnelGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [MagicTransitGRETunnelGetResponseEnvelopeMessages] -type magicTransitGRETunnelGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitGRETunnelGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitGRETunnelGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitGRETunnelGetResponseEnvelopeSuccess bool - -const ( - MagicTransitGRETunnelGetResponseEnvelopeSuccessTrue MagicTransitGRETunnelGetResponseEnvelopeSuccess = true -) diff --git a/magictransitgretunnel_test.go b/magictransitgretunnel_test.go deleted file mode 100644 index 7d891f5af33..00000000000 --- a/magictransitgretunnel_test.go +++ /dev/null @@ -1,168 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestMagicTransitGRETunnelNew(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("user@example.com"), - ) - _, err := client.MagicTransit.GRETunnels.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.MagicTransitGRETunnelNewParams{ - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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 TestMagicTransitGRETunnelUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.MagicTransit.GRETunnels.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.MagicTransitGRETunnelUpdateParams{ - CloudflareGREEndpoint: cloudflare.F("203.0.113.1"), - CustomerGREEndpoint: cloudflare.F("203.0.113.1"), - InterfaceAddress: cloudflare.F("192.0.2.0/31"), - Name: cloudflare.F("GRE_1"), - Description: cloudflare.F("Tunnel for ISP X"), - HealthCheck: cloudflare.F(cloudflare.MagicTransitGRETunnelUpdateParamsHealthCheck{ - Direction: cloudflare.F(cloudflare.MagicTransitGRETunnelUpdateParamsHealthCheckDirectionBidirectional), - Enabled: cloudflare.F(true), - Rate: cloudflare.F(cloudflare.MagicTransitGRETunnelUpdateParamsHealthCheckRateLow), - Target: cloudflare.F("203.0.113.1"), - Type: cloudflare.F(cloudflare.MagicTransitGRETunnelUpdateParamsHealthCheckTypeRequest), - }), - Mtu: cloudflare.F(int64(0)), - TTL: cloudflare.F(int64(0)), - }, - ) - 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 TestMagicTransitGRETunnelList(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("user@example.com"), - ) - _, err := client.MagicTransit.GRETunnels.List(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()) - } -} - -func TestMagicTransitGRETunnelDelete(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("user@example.com"), - ) - _, err := client.MagicTransit.GRETunnels.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "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()) - } -} - -func TestMagicTransitGRETunnelGet(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("user@example.com"), - ) - _, err := client.MagicTransit.GRETunnels.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "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/magictransitipsectunnel.go b/magictransitipsectunnel.go deleted file mode 100644 index e7631df504c..00000000000 --- a/magictransitipsectunnel.go +++ /dev/null @@ -1,1197 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// MagicTransitIPSECTunnelService 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 -// [NewMagicTransitIPSECTunnelService] method instead. -type MagicTransitIPSECTunnelService struct { - Options []option.RequestOption -} - -// NewMagicTransitIPSECTunnelService 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 NewMagicTransitIPSECTunnelService(opts ...option.RequestOption) (r *MagicTransitIPSECTunnelService) { - r = &MagicTransitIPSECTunnelService{} - r.Options = opts - return -} - -// Creates new IPsec tunnels associated with an account. Use `?validate_only=true` -// as an optional query parameter to only run validation without persisting -// changes. -func (r *MagicTransitIPSECTunnelService) New(ctx context.Context, accountIdentifier string, body MagicTransitIPSECTunnelNewParams, opts ...option.RequestOption) (res *MagicTransitIPSECTunnelNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitIPSECTunnelNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/ipsec_tunnels", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a specific IPsec tunnel associated with an account. Use -// `?validate_only=true` as an optional query parameter to only run validation -// without persisting changes. -func (r *MagicTransitIPSECTunnelService) Update(ctx context.Context, accountIdentifier string, tunnelIdentifier string, body MagicTransitIPSECTunnelUpdateParams, opts ...option.RequestOption) (res *MagicTransitIPSECTunnelUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitIPSECTunnelUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/ipsec_tunnels/%s", accountIdentifier, tunnelIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists IPsec tunnels associated with an account. -func (r *MagicTransitIPSECTunnelService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *MagicTransitIPSECTunnelListResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitIPSECTunnelListResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/ipsec_tunnels", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Disables and removes a specific static IPsec Tunnel associated with an account. -// Use `?validate_only=true` as an optional query parameter to only run validation -// without persisting changes. -func (r *MagicTransitIPSECTunnelService) Delete(ctx context.Context, accountIdentifier string, tunnelIdentifier string, opts ...option.RequestOption) (res *MagicTransitIPSECTunnelDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitIPSECTunnelDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/ipsec_tunnels/%s", accountIdentifier, tunnelIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists details for a specific IPsec tunnel. -func (r *MagicTransitIPSECTunnelService) Get(ctx context.Context, accountIdentifier string, tunnelIdentifier string, opts ...option.RequestOption) (res *MagicTransitIPSECTunnelGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitIPSECTunnelGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/ipsec_tunnels/%s", accountIdentifier, tunnelIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Generates a Pre Shared Key for a specific IPsec tunnel used in the IKE session. -// Use `?validate_only=true` as an optional query parameter to only run validation -// without persisting changes. After a PSK is generated, the PSK is immediately -// persisted to Cloudflare's edge and cannot be retrieved later. Note the PSK in a -// safe place. -func (r *MagicTransitIPSECTunnelService) PSKGenerate(ctx context.Context, accountIdentifier string, tunnelIdentifier string, opts ...option.RequestOption) (res *MagicTransitIPSECTunnelPSKGenerateResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitIPSECTunnelPSKGenerateResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/ipsec_tunnels/%s/psk_generate", accountIdentifier, tunnelIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type MagicTransitIPSECTunnelNewResponse struct { - IPSECTunnels []MagicTransitIPSECTunnelNewResponseIPSECTunnel `json:"ipsec_tunnels"` - JSON magicTransitIPSECTunnelNewResponseJSON `json:"-"` -} - -// magicTransitIPSECTunnelNewResponseJSON contains the JSON metadata for the struct -// [MagicTransitIPSECTunnelNewResponse] -type magicTransitIPSECTunnelNewResponseJSON struct { - IPSECTunnels apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelNewResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelNewResponseIPSECTunnel struct { - // The IP address assigned to the Cloudflare side of the IPsec tunnel. - CloudflareEndpoint string `json:"cloudflare_endpoint,required"` - // A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side - // of the tunnel. Select the subnet from the following private IP space: - // 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. - InterfaceAddress string `json:"interface_address,required"` - // The name of the IPsec tunnel. The name cannot share a name with other tunnels. - Name string `json:"name,required"` - // Tunnel identifier tag. - ID string `json:"id"` - // When `true`, the tunnel can use a null-cipher (`ENCR_NULL`) in the ESP tunnel - // (Phase 2). - AllowNullCipher bool `json:"allow_null_cipher"` - // The date and time the tunnel was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // The IP address assigned to the customer side of the IPsec tunnel. - CustomerEndpoint string `json:"customer_endpoint"` - // An optional description forthe IPsec tunnel. - Description string `json:"description"` - // The date and time the tunnel was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The PSK metadata that includes when the PSK was generated. - PSKMetadata MagicTransitIPSECTunnelNewResponseIPSECTunnelsPSKMetadata `json:"psk_metadata"` - // If `true`, then IPsec replay protection will be supported in the - // Cloudflare-to-customer direction. - ReplayProtection bool `json:"replay_protection"` - TunnelHealthCheck MagicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheck `json:"tunnel_health_check"` - JSON magicTransitIPSECTunnelNewResponseIPSECTunnelJSON `json:"-"` -} - -// magicTransitIPSECTunnelNewResponseIPSECTunnelJSON contains the JSON metadata for -// the struct [MagicTransitIPSECTunnelNewResponseIPSECTunnel] -type magicTransitIPSECTunnelNewResponseIPSECTunnelJSON struct { - CloudflareEndpoint apijson.Field - InterfaceAddress apijson.Field - Name apijson.Field - ID apijson.Field - AllowNullCipher apijson.Field - CreatedOn apijson.Field - CustomerEndpoint apijson.Field - Description apijson.Field - ModifiedOn apijson.Field - PSKMetadata apijson.Field - ReplayProtection apijson.Field - TunnelHealthCheck apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelNewResponseIPSECTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelNewResponseIPSECTunnelJSON) RawJSON() string { - return r.raw -} - -// The PSK metadata that includes when the PSK was generated. -type MagicTransitIPSECTunnelNewResponseIPSECTunnelsPSKMetadata struct { - // The date and time the tunnel was last modified. - LastGeneratedOn time.Time `json:"last_generated_on" format:"date-time"` - JSON magicTransitIPSECTunnelNewResponseIPSECTunnelsPSKMetadataJSON `json:"-"` -} - -// magicTransitIPSECTunnelNewResponseIPSECTunnelsPSKMetadataJSON contains the JSON -// metadata for the struct -// [MagicTransitIPSECTunnelNewResponseIPSECTunnelsPSKMetadata] -type magicTransitIPSECTunnelNewResponseIPSECTunnelsPSKMetadataJSON struct { - LastGeneratedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelNewResponseIPSECTunnelsPSKMetadata) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelNewResponseIPSECTunnelsPSKMetadataJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheck struct { - // Determines whether to run healthchecks for a tunnel. - Enabled bool `json:"enabled"` - // How frequent the health check is run. The default value is `mid`. - Rate MagicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRate `json:"rate"` - // The destination address in a request type health check. After the healthcheck is - // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded - // to this address. This field defaults to `customer_gre_endpoint address`. - Target string `json:"target"` - // The type of healthcheck to run, reply or request. The default value is `reply`. - Type MagicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckType `json:"type"` - JSON magicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckJSON `json:"-"` -} - -// magicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckJSON contains the -// JSON metadata for the struct -// [MagicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheck] -type magicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckJSON struct { - Enabled apijson.Field - Rate apijson.Field - Target apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheck) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckJSON) RawJSON() string { - return r.raw -} - -// How frequent the health check is run. The default value is `mid`. -type MagicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRate string - -const ( - MagicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRateLow MagicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRate = "low" - MagicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRateMid MagicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRate = "mid" - MagicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRateHigh MagicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckRate = "high" -) - -// The type of healthcheck to run, reply or request. The default value is `reply`. -type MagicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckType string - -const ( - MagicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckTypeReply MagicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckType = "reply" - MagicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckTypeRequest MagicTransitIPSECTunnelNewResponseIPSECTunnelsTunnelHealthCheckType = "request" -) - -type MagicTransitIPSECTunnelUpdateResponse struct { - Modified bool `json:"modified"` - ModifiedIPSECTunnel interface{} `json:"modified_ipsec_tunnel"` - JSON magicTransitIPSECTunnelUpdateResponseJSON `json:"-"` -} - -// magicTransitIPSECTunnelUpdateResponseJSON contains the JSON metadata for the -// struct [MagicTransitIPSECTunnelUpdateResponse] -type magicTransitIPSECTunnelUpdateResponseJSON struct { - Modified apijson.Field - ModifiedIPSECTunnel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelListResponse struct { - IPSECTunnels []MagicTransitIPSECTunnelListResponseIPSECTunnel `json:"ipsec_tunnels"` - JSON magicTransitIPSECTunnelListResponseJSON `json:"-"` -} - -// magicTransitIPSECTunnelListResponseJSON contains the JSON metadata for the -// struct [MagicTransitIPSECTunnelListResponse] -type magicTransitIPSECTunnelListResponseJSON struct { - IPSECTunnels apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelListResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelListResponseIPSECTunnel struct { - // The IP address assigned to the Cloudflare side of the IPsec tunnel. - CloudflareEndpoint string `json:"cloudflare_endpoint,required"` - // A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side - // of the tunnel. Select the subnet from the following private IP space: - // 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. - InterfaceAddress string `json:"interface_address,required"` - // The name of the IPsec tunnel. The name cannot share a name with other tunnels. - Name string `json:"name,required"` - // Tunnel identifier tag. - ID string `json:"id"` - // When `true`, the tunnel can use a null-cipher (`ENCR_NULL`) in the ESP tunnel - // (Phase 2). - AllowNullCipher bool `json:"allow_null_cipher"` - // The date and time the tunnel was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // The IP address assigned to the customer side of the IPsec tunnel. - CustomerEndpoint string `json:"customer_endpoint"` - // An optional description forthe IPsec tunnel. - Description string `json:"description"` - // The date and time the tunnel was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The PSK metadata that includes when the PSK was generated. - PSKMetadata MagicTransitIPSECTunnelListResponseIPSECTunnelsPSKMetadata `json:"psk_metadata"` - // If `true`, then IPsec replay protection will be supported in the - // Cloudflare-to-customer direction. - ReplayProtection bool `json:"replay_protection"` - TunnelHealthCheck MagicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheck `json:"tunnel_health_check"` - JSON magicTransitIPSECTunnelListResponseIPSECTunnelJSON `json:"-"` -} - -// magicTransitIPSECTunnelListResponseIPSECTunnelJSON contains the JSON metadata -// for the struct [MagicTransitIPSECTunnelListResponseIPSECTunnel] -type magicTransitIPSECTunnelListResponseIPSECTunnelJSON struct { - CloudflareEndpoint apijson.Field - InterfaceAddress apijson.Field - Name apijson.Field - ID apijson.Field - AllowNullCipher apijson.Field - CreatedOn apijson.Field - CustomerEndpoint apijson.Field - Description apijson.Field - ModifiedOn apijson.Field - PSKMetadata apijson.Field - ReplayProtection apijson.Field - TunnelHealthCheck apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelListResponseIPSECTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelListResponseIPSECTunnelJSON) RawJSON() string { - return r.raw -} - -// The PSK metadata that includes when the PSK was generated. -type MagicTransitIPSECTunnelListResponseIPSECTunnelsPSKMetadata struct { - // The date and time the tunnel was last modified. - LastGeneratedOn time.Time `json:"last_generated_on" format:"date-time"` - JSON magicTransitIPSECTunnelListResponseIPSECTunnelsPSKMetadataJSON `json:"-"` -} - -// magicTransitIPSECTunnelListResponseIPSECTunnelsPSKMetadataJSON contains the JSON -// metadata for the struct -// [MagicTransitIPSECTunnelListResponseIPSECTunnelsPSKMetadata] -type magicTransitIPSECTunnelListResponseIPSECTunnelsPSKMetadataJSON struct { - LastGeneratedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelListResponseIPSECTunnelsPSKMetadata) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelListResponseIPSECTunnelsPSKMetadataJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheck struct { - // Determines whether to run healthchecks for a tunnel. - Enabled bool `json:"enabled"` - // How frequent the health check is run. The default value is `mid`. - Rate MagicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRate `json:"rate"` - // The destination address in a request type health check. After the healthcheck is - // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded - // to this address. This field defaults to `customer_gre_endpoint address`. - Target string `json:"target"` - // The type of healthcheck to run, reply or request. The default value is `reply`. - Type MagicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckType `json:"type"` - JSON magicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckJSON `json:"-"` -} - -// magicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckJSON contains -// the JSON metadata for the struct -// [MagicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheck] -type magicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckJSON struct { - Enabled apijson.Field - Rate apijson.Field - Target apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheck) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckJSON) RawJSON() string { - return r.raw -} - -// How frequent the health check is run. The default value is `mid`. -type MagicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRate string - -const ( - MagicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRateLow MagicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRate = "low" - MagicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRateMid MagicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRate = "mid" - MagicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRateHigh MagicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckRate = "high" -) - -// The type of healthcheck to run, reply or request. The default value is `reply`. -type MagicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckType string - -const ( - MagicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckTypeReply MagicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckType = "reply" - MagicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckTypeRequest MagicTransitIPSECTunnelListResponseIPSECTunnelsTunnelHealthCheckType = "request" -) - -type MagicTransitIPSECTunnelDeleteResponse struct { - Deleted bool `json:"deleted"` - DeletedIPSECTunnel interface{} `json:"deleted_ipsec_tunnel"` - JSON magicTransitIPSECTunnelDeleteResponseJSON `json:"-"` -} - -// magicTransitIPSECTunnelDeleteResponseJSON contains the JSON metadata for the -// struct [MagicTransitIPSECTunnelDeleteResponse] -type magicTransitIPSECTunnelDeleteResponseJSON struct { - Deleted apijson.Field - DeletedIPSECTunnel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelGetResponse struct { - IPSECTunnel interface{} `json:"ipsec_tunnel"` - JSON magicTransitIPSECTunnelGetResponseJSON `json:"-"` -} - -// magicTransitIPSECTunnelGetResponseJSON contains the JSON metadata for the struct -// [MagicTransitIPSECTunnelGetResponse] -type magicTransitIPSECTunnelGetResponseJSON struct { - IPSECTunnel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelGetResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelPSKGenerateResponse struct { - // Identifier - IPSECTunnelID string `json:"ipsec_tunnel_id"` - // A randomly generated or provided string for use in the IPsec tunnel. - PSK string `json:"psk"` - // The PSK metadata that includes when the PSK was generated. - PSKMetadata MagicTransitIPSECTunnelPSKGenerateResponsePSKMetadata `json:"psk_metadata"` - JSON magicTransitIPSECTunnelPSKGenerateResponseJSON `json:"-"` -} - -// magicTransitIPSECTunnelPSKGenerateResponseJSON contains the JSON metadata for -// the struct [MagicTransitIPSECTunnelPSKGenerateResponse] -type magicTransitIPSECTunnelPSKGenerateResponseJSON struct { - IPSECTunnelID apijson.Field - PSK apijson.Field - PSKMetadata apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelPSKGenerateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelPSKGenerateResponseJSON) RawJSON() string { - return r.raw -} - -// The PSK metadata that includes when the PSK was generated. -type MagicTransitIPSECTunnelPSKGenerateResponsePSKMetadata struct { - // The date and time the tunnel was last modified. - LastGeneratedOn time.Time `json:"last_generated_on" format:"date-time"` - JSON magicTransitIPSECTunnelPSKGenerateResponsePSKMetadataJSON `json:"-"` -} - -// magicTransitIPSECTunnelPSKGenerateResponsePSKMetadataJSON contains the JSON -// metadata for the struct [MagicTransitIPSECTunnelPSKGenerateResponsePSKMetadata] -type magicTransitIPSECTunnelPSKGenerateResponsePSKMetadataJSON struct { - LastGeneratedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelPSKGenerateResponsePSKMetadata) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelPSKGenerateResponsePSKMetadataJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelNewParams struct { - // The IP address assigned to the Cloudflare side of the IPsec tunnel. - CloudflareEndpoint param.Field[string] `json:"cloudflare_endpoint,required"` - // A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side - // of the tunnel. Select the subnet from the following private IP space: - // 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. - InterfaceAddress param.Field[string] `json:"interface_address,required"` - // The name of the IPsec tunnel. The name cannot share a name with other tunnels. - Name param.Field[string] `json:"name,required"` - // The IP address assigned to the customer side of the IPsec tunnel. - CustomerEndpoint param.Field[string] `json:"customer_endpoint"` - // An optional description forthe IPsec tunnel. - Description param.Field[string] `json:"description"` - HealthCheck param.Field[MagicTransitIPSECTunnelNewParamsHealthCheck] `json:"health_check"` - // A randomly generated or provided string for use in the IPsec tunnel. - PSK param.Field[string] `json:"psk"` - // If `true`, then IPsec replay protection will be supported in the - // Cloudflare-to-customer direction. - ReplayProtection param.Field[bool] `json:"replay_protection"` -} - -func (r MagicTransitIPSECTunnelNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MagicTransitIPSECTunnelNewParamsHealthCheck struct { - // The direction of the flow of the healthcheck. Either unidirectional, where the - // probe comes to you via the tunnel and the result comes back to Cloudflare via - // the open Internet, or bidirectional where both the probe and result come and go - // via the tunnel. Note in the case of bidirecitonal healthchecks, the target field - // in health_check is ignored as the interface_address is used to send traffic into - // the tunnel. - Direction param.Field[MagicTransitIPSECTunnelNewParamsHealthCheckDirection] `json:"direction"` - // Determines whether to run healthchecks for a tunnel. - Enabled param.Field[bool] `json:"enabled"` - // How frequent the health check is run. The default value is `mid`. - Rate param.Field[MagicTransitIPSECTunnelNewParamsHealthCheckRate] `json:"rate"` - // The destination address in a request type health check. After the healthcheck is - // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded - // to this address. This field defaults to `customer_gre_endpoint address`. This - // field is ignored for bidirectional healthchecks as the interface_address (not - // assigned to the Cloudflare side of the tunnel) is used as the target. - Target param.Field[string] `json:"target"` - // The type of healthcheck to run, reply or request. The default value is `reply`. - Type param.Field[MagicTransitIPSECTunnelNewParamsHealthCheckType] `json:"type"` -} - -func (r MagicTransitIPSECTunnelNewParamsHealthCheck) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The direction of the flow of the healthcheck. Either unidirectional, where the -// probe comes to you via the tunnel and the result comes back to Cloudflare via -// the open Internet, or bidirectional where both the probe and result come and go -// via the tunnel. Note in the case of bidirecitonal healthchecks, the target field -// in health_check is ignored as the interface_address is used to send traffic into -// the tunnel. -type MagicTransitIPSECTunnelNewParamsHealthCheckDirection string - -const ( - MagicTransitIPSECTunnelNewParamsHealthCheckDirectionUnidirectional MagicTransitIPSECTunnelNewParamsHealthCheckDirection = "unidirectional" - MagicTransitIPSECTunnelNewParamsHealthCheckDirectionBidirectional MagicTransitIPSECTunnelNewParamsHealthCheckDirection = "bidirectional" -) - -// How frequent the health check is run. The default value is `mid`. -type MagicTransitIPSECTunnelNewParamsHealthCheckRate string - -const ( - MagicTransitIPSECTunnelNewParamsHealthCheckRateLow MagicTransitIPSECTunnelNewParamsHealthCheckRate = "low" - MagicTransitIPSECTunnelNewParamsHealthCheckRateMid MagicTransitIPSECTunnelNewParamsHealthCheckRate = "mid" - MagicTransitIPSECTunnelNewParamsHealthCheckRateHigh MagicTransitIPSECTunnelNewParamsHealthCheckRate = "high" -) - -// The type of healthcheck to run, reply or request. The default value is `reply`. -type MagicTransitIPSECTunnelNewParamsHealthCheckType string - -const ( - MagicTransitIPSECTunnelNewParamsHealthCheckTypeReply MagicTransitIPSECTunnelNewParamsHealthCheckType = "reply" - MagicTransitIPSECTunnelNewParamsHealthCheckTypeRequest MagicTransitIPSECTunnelNewParamsHealthCheckType = "request" -) - -type MagicTransitIPSECTunnelNewResponseEnvelope struct { - Errors []MagicTransitIPSECTunnelNewResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitIPSECTunnelNewResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitIPSECTunnelNewResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitIPSECTunnelNewResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitIPSECTunnelNewResponseEnvelopeJSON `json:"-"` -} - -// magicTransitIPSECTunnelNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [MagicTransitIPSECTunnelNewResponseEnvelope] -type magicTransitIPSECTunnelNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitIPSECTunnelNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitIPSECTunnelNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [MagicTransitIPSECTunnelNewResponseEnvelopeErrors] -type magicTransitIPSECTunnelNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitIPSECTunnelNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitIPSECTunnelNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [MagicTransitIPSECTunnelNewResponseEnvelopeMessages] -type magicTransitIPSECTunnelNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitIPSECTunnelNewResponseEnvelopeSuccess bool - -const ( - MagicTransitIPSECTunnelNewResponseEnvelopeSuccessTrue MagicTransitIPSECTunnelNewResponseEnvelopeSuccess = true -) - -type MagicTransitIPSECTunnelUpdateParams struct { - // The IP address assigned to the Cloudflare side of the IPsec tunnel. - CloudflareEndpoint param.Field[string] `json:"cloudflare_endpoint,required"` - // A 31-bit prefix (/31 in CIDR notation) supporting two hosts, one for each side - // of the tunnel. Select the subnet from the following private IP space: - // 10.0.0.0–10.255.255.255, 172.16.0.0–172.31.255.255, 192.168.0.0–192.168.255.255. - InterfaceAddress param.Field[string] `json:"interface_address,required"` - // The name of the IPsec tunnel. The name cannot share a name with other tunnels. - Name param.Field[string] `json:"name,required"` - // The IP address assigned to the customer side of the IPsec tunnel. - CustomerEndpoint param.Field[string] `json:"customer_endpoint"` - // An optional description forthe IPsec tunnel. - Description param.Field[string] `json:"description"` - HealthCheck param.Field[MagicTransitIPSECTunnelUpdateParamsHealthCheck] `json:"health_check"` - // A randomly generated or provided string for use in the IPsec tunnel. - PSK param.Field[string] `json:"psk"` - // If `true`, then IPsec replay protection will be supported in the - // Cloudflare-to-customer direction. - ReplayProtection param.Field[bool] `json:"replay_protection"` -} - -func (r MagicTransitIPSECTunnelUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MagicTransitIPSECTunnelUpdateParamsHealthCheck struct { - // The direction of the flow of the healthcheck. Either unidirectional, where the - // probe comes to you via the tunnel and the result comes back to Cloudflare via - // the open Internet, or bidirectional where both the probe and result come and go - // via the tunnel. Note in the case of bidirecitonal healthchecks, the target field - // in health_check is ignored as the interface_address is used to send traffic into - // the tunnel. - Direction param.Field[MagicTransitIPSECTunnelUpdateParamsHealthCheckDirection] `json:"direction"` - // Determines whether to run healthchecks for a tunnel. - Enabled param.Field[bool] `json:"enabled"` - // How frequent the health check is run. The default value is `mid`. - Rate param.Field[MagicTransitIPSECTunnelUpdateParamsHealthCheckRate] `json:"rate"` - // The destination address in a request type health check. After the healthcheck is - // decapsulated at the customer end of the tunnel, the ICMP echo will be forwarded - // to this address. This field defaults to `customer_gre_endpoint address`. This - // field is ignored for bidirectional healthchecks as the interface_address (not - // assigned to the Cloudflare side of the tunnel) is used as the target. - Target param.Field[string] `json:"target"` - // The type of healthcheck to run, reply or request. The default value is `reply`. - Type param.Field[MagicTransitIPSECTunnelUpdateParamsHealthCheckType] `json:"type"` -} - -func (r MagicTransitIPSECTunnelUpdateParamsHealthCheck) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The direction of the flow of the healthcheck. Either unidirectional, where the -// probe comes to you via the tunnel and the result comes back to Cloudflare via -// the open Internet, or bidirectional where both the probe and result come and go -// via the tunnel. Note in the case of bidirecitonal healthchecks, the target field -// in health_check is ignored as the interface_address is used to send traffic into -// the tunnel. -type MagicTransitIPSECTunnelUpdateParamsHealthCheckDirection string - -const ( - MagicTransitIPSECTunnelUpdateParamsHealthCheckDirectionUnidirectional MagicTransitIPSECTunnelUpdateParamsHealthCheckDirection = "unidirectional" - MagicTransitIPSECTunnelUpdateParamsHealthCheckDirectionBidirectional MagicTransitIPSECTunnelUpdateParamsHealthCheckDirection = "bidirectional" -) - -// How frequent the health check is run. The default value is `mid`. -type MagicTransitIPSECTunnelUpdateParamsHealthCheckRate string - -const ( - MagicTransitIPSECTunnelUpdateParamsHealthCheckRateLow MagicTransitIPSECTunnelUpdateParamsHealthCheckRate = "low" - MagicTransitIPSECTunnelUpdateParamsHealthCheckRateMid MagicTransitIPSECTunnelUpdateParamsHealthCheckRate = "mid" - MagicTransitIPSECTunnelUpdateParamsHealthCheckRateHigh MagicTransitIPSECTunnelUpdateParamsHealthCheckRate = "high" -) - -// The type of healthcheck to run, reply or request. The default value is `reply`. -type MagicTransitIPSECTunnelUpdateParamsHealthCheckType string - -const ( - MagicTransitIPSECTunnelUpdateParamsHealthCheckTypeReply MagicTransitIPSECTunnelUpdateParamsHealthCheckType = "reply" - MagicTransitIPSECTunnelUpdateParamsHealthCheckTypeRequest MagicTransitIPSECTunnelUpdateParamsHealthCheckType = "request" -) - -type MagicTransitIPSECTunnelUpdateResponseEnvelope struct { - Errors []MagicTransitIPSECTunnelUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitIPSECTunnelUpdateResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitIPSECTunnelUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitIPSECTunnelUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitIPSECTunnelUpdateResponseEnvelopeJSON `json:"-"` -} - -// magicTransitIPSECTunnelUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [MagicTransitIPSECTunnelUpdateResponseEnvelope] -type magicTransitIPSECTunnelUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitIPSECTunnelUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitIPSECTunnelUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [MagicTransitIPSECTunnelUpdateResponseEnvelopeErrors] -type magicTransitIPSECTunnelUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitIPSECTunnelUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitIPSECTunnelUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [MagicTransitIPSECTunnelUpdateResponseEnvelopeMessages] -type magicTransitIPSECTunnelUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitIPSECTunnelUpdateResponseEnvelopeSuccess bool - -const ( - MagicTransitIPSECTunnelUpdateResponseEnvelopeSuccessTrue MagicTransitIPSECTunnelUpdateResponseEnvelopeSuccess = true -) - -type MagicTransitIPSECTunnelListResponseEnvelope struct { - Errors []MagicTransitIPSECTunnelListResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitIPSECTunnelListResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitIPSECTunnelListResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitIPSECTunnelListResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitIPSECTunnelListResponseEnvelopeJSON `json:"-"` -} - -// magicTransitIPSECTunnelListResponseEnvelopeJSON contains the JSON metadata for -// the struct [MagicTransitIPSECTunnelListResponseEnvelope] -type magicTransitIPSECTunnelListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitIPSECTunnelListResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitIPSECTunnelListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [MagicTransitIPSECTunnelListResponseEnvelopeErrors] -type magicTransitIPSECTunnelListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitIPSECTunnelListResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitIPSECTunnelListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [MagicTransitIPSECTunnelListResponseEnvelopeMessages] -type magicTransitIPSECTunnelListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitIPSECTunnelListResponseEnvelopeSuccess bool - -const ( - MagicTransitIPSECTunnelListResponseEnvelopeSuccessTrue MagicTransitIPSECTunnelListResponseEnvelopeSuccess = true -) - -type MagicTransitIPSECTunnelDeleteResponseEnvelope struct { - Errors []MagicTransitIPSECTunnelDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitIPSECTunnelDeleteResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitIPSECTunnelDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitIPSECTunnelDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitIPSECTunnelDeleteResponseEnvelopeJSON `json:"-"` -} - -// magicTransitIPSECTunnelDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [MagicTransitIPSECTunnelDeleteResponseEnvelope] -type magicTransitIPSECTunnelDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitIPSECTunnelDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitIPSECTunnelDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [MagicTransitIPSECTunnelDeleteResponseEnvelopeErrors] -type magicTransitIPSECTunnelDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitIPSECTunnelDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitIPSECTunnelDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [MagicTransitIPSECTunnelDeleteResponseEnvelopeMessages] -type magicTransitIPSECTunnelDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitIPSECTunnelDeleteResponseEnvelopeSuccess bool - -const ( - MagicTransitIPSECTunnelDeleteResponseEnvelopeSuccessTrue MagicTransitIPSECTunnelDeleteResponseEnvelopeSuccess = true -) - -type MagicTransitIPSECTunnelGetResponseEnvelope struct { - Errors []MagicTransitIPSECTunnelGetResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitIPSECTunnelGetResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitIPSECTunnelGetResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitIPSECTunnelGetResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitIPSECTunnelGetResponseEnvelopeJSON `json:"-"` -} - -// magicTransitIPSECTunnelGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [MagicTransitIPSECTunnelGetResponseEnvelope] -type magicTransitIPSECTunnelGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitIPSECTunnelGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitIPSECTunnelGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [MagicTransitIPSECTunnelGetResponseEnvelopeErrors] -type magicTransitIPSECTunnelGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitIPSECTunnelGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitIPSECTunnelGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [MagicTransitIPSECTunnelGetResponseEnvelopeMessages] -type magicTransitIPSECTunnelGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitIPSECTunnelGetResponseEnvelopeSuccess bool - -const ( - MagicTransitIPSECTunnelGetResponseEnvelopeSuccessTrue MagicTransitIPSECTunnelGetResponseEnvelopeSuccess = true -) - -type MagicTransitIPSECTunnelPSKGenerateResponseEnvelope struct { - Errors []MagicTransitIPSECTunnelPSKGenerateResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitIPSECTunnelPSKGenerateResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitIPSECTunnelPSKGenerateResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitIPSECTunnelPSKGenerateResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitIPSECTunnelPSKGenerateResponseEnvelopeJSON `json:"-"` -} - -// magicTransitIPSECTunnelPSKGenerateResponseEnvelopeJSON contains the JSON -// metadata for the struct [MagicTransitIPSECTunnelPSKGenerateResponseEnvelope] -type magicTransitIPSECTunnelPSKGenerateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelPSKGenerateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelPSKGenerateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelPSKGenerateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitIPSECTunnelPSKGenerateResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitIPSECTunnelPSKGenerateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [MagicTransitIPSECTunnelPSKGenerateResponseEnvelopeErrors] -type magicTransitIPSECTunnelPSKGenerateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelPSKGenerateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelPSKGenerateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitIPSECTunnelPSKGenerateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitIPSECTunnelPSKGenerateResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitIPSECTunnelPSKGenerateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [MagicTransitIPSECTunnelPSKGenerateResponseEnvelopeMessages] -type magicTransitIPSECTunnelPSKGenerateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitIPSECTunnelPSKGenerateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitIPSECTunnelPSKGenerateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitIPSECTunnelPSKGenerateResponseEnvelopeSuccess bool - -const ( - MagicTransitIPSECTunnelPSKGenerateResponseEnvelopeSuccessTrue MagicTransitIPSECTunnelPSKGenerateResponseEnvelopeSuccess = true -) diff --git a/magictransitipsectunnel_test.go b/magictransitipsectunnel_test.go deleted file mode 100644 index 82a2da20c5d..00000000000 --- a/magictransitipsectunnel_test.go +++ /dev/null @@ -1,209 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestMagicTransitIPSECTunnelNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.MagicTransit.IPSECTunnels.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.MagicTransitIPSECTunnelNewParams{ - CloudflareEndpoint: cloudflare.F("203.0.113.1"), - InterfaceAddress: cloudflare.F("192.0.2.0/31"), - Name: cloudflare.F("IPsec_1"), - CustomerEndpoint: cloudflare.F("203.0.113.1"), - Description: cloudflare.F("Tunnel for ISP X"), - HealthCheck: cloudflare.F(cloudflare.MagicTransitIPSECTunnelNewParamsHealthCheck{ - Direction: cloudflare.F(cloudflare.MagicTransitIPSECTunnelNewParamsHealthCheckDirectionBidirectional), - Enabled: cloudflare.F(true), - Rate: cloudflare.F(cloudflare.MagicTransitIPSECTunnelNewParamsHealthCheckRateLow), - Target: cloudflare.F("203.0.113.1"), - Type: cloudflare.F(cloudflare.MagicTransitIPSECTunnelNewParamsHealthCheckTypeRequest), - }), - PSK: cloudflare.F("O3bwKSjnaoCxDoUxjcq4Rk8ZKkezQUiy"), - ReplayProtection: cloudflare.F(false), - }, - ) - 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 TestMagicTransitIPSECTunnelUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.MagicTransit.IPSECTunnels.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.MagicTransitIPSECTunnelUpdateParams{ - CloudflareEndpoint: cloudflare.F("203.0.113.1"), - InterfaceAddress: cloudflare.F("192.0.2.0/31"), - Name: cloudflare.F("IPsec_1"), - CustomerEndpoint: cloudflare.F("203.0.113.1"), - Description: cloudflare.F("Tunnel for ISP X"), - HealthCheck: cloudflare.F(cloudflare.MagicTransitIPSECTunnelUpdateParamsHealthCheck{ - Direction: cloudflare.F(cloudflare.MagicTransitIPSECTunnelUpdateParamsHealthCheckDirectionBidirectional), - Enabled: cloudflare.F(true), - Rate: cloudflare.F(cloudflare.MagicTransitIPSECTunnelUpdateParamsHealthCheckRateLow), - Target: cloudflare.F("203.0.113.1"), - Type: cloudflare.F(cloudflare.MagicTransitIPSECTunnelUpdateParamsHealthCheckTypeRequest), - }), - PSK: cloudflare.F("O3bwKSjnaoCxDoUxjcq4Rk8ZKkezQUiy"), - ReplayProtection: cloudflare.F(false), - }, - ) - 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 TestMagicTransitIPSECTunnelList(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("user@example.com"), - ) - _, err := client.MagicTransit.IPSECTunnels.List(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()) - } -} - -func TestMagicTransitIPSECTunnelDelete(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("user@example.com"), - ) - _, err := client.MagicTransit.IPSECTunnels.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "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()) - } -} - -func TestMagicTransitIPSECTunnelGet(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("user@example.com"), - ) - _, err := client.MagicTransit.IPSECTunnels.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "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()) - } -} - -func TestMagicTransitIPSECTunnelPSKGenerate(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("user@example.com"), - ) - _, err := client.MagicTransit.IPSECTunnels.PSKGenerate( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "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/magictransitroute.go b/magictransitroute.go deleted file mode 100644 index 87a45b026ab..00000000000 --- a/magictransitroute.go +++ /dev/null @@ -1,929 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// MagicTransitRouteService 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 [NewMagicTransitRouteService] method -// instead. -type MagicTransitRouteService struct { - Options []option.RequestOption -} - -// NewMagicTransitRouteService 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 NewMagicTransitRouteService(opts ...option.RequestOption) (r *MagicTransitRouteService) { - r = &MagicTransitRouteService{} - r.Options = opts - return -} - -// Creates a new Magic static route. Use `?validate_only=true` as an optional query -// parameter to run validation only without persisting changes. -func (r *MagicTransitRouteService) New(ctx context.Context, accountIdentifier string, body MagicTransitRouteNewParams, opts ...option.RequestOption) (res *MagicTransitRouteNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitRouteNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/routes", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update a specific Magic static route. Use `?validate_only=true` as an optional -// query parameter to run validation only without persisting changes. -func (r *MagicTransitRouteService) Update(ctx context.Context, accountIdentifier string, routeIdentifier string, body MagicTransitRouteUpdateParams, opts ...option.RequestOption) (res *MagicTransitRouteUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitRouteUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/routes/%s", accountIdentifier, routeIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List all Magic static routes. -func (r *MagicTransitRouteService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *MagicTransitRouteListResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitRouteListResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/routes", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Disable and remove a specific Magic static route. -func (r *MagicTransitRouteService) Delete(ctx context.Context, accountIdentifier string, routeIdentifier string, opts ...option.RequestOption) (res *MagicTransitRouteDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitRouteDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/routes/%s", accountIdentifier, routeIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete multiple Magic static routes. -func (r *MagicTransitRouteService) Empty(ctx context.Context, accountIdentifier string, body MagicTransitRouteEmptyParams, opts ...option.RequestOption) (res *MagicTransitRouteEmptyResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitRouteEmptyResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/routes", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a specific Magic static route. -func (r *MagicTransitRouteService) Get(ctx context.Context, accountIdentifier string, routeIdentifier string, opts ...option.RequestOption) (res *MagicTransitRouteGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env MagicTransitRouteGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/magic/routes/%s", accountIdentifier, routeIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type MagicTransitRouteNewResponse struct { - Routes []MagicTransitRouteNewResponseRoute `json:"routes"` - JSON magicTransitRouteNewResponseJSON `json:"-"` -} - -// magicTransitRouteNewResponseJSON contains the JSON metadata for the struct -// [MagicTransitRouteNewResponse] -type magicTransitRouteNewResponseJSON struct { - Routes apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteNewResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteNewResponseRoute struct { - // The next-hop IP Address for the static route. - Nexthop string `json:"nexthop,required"` - // IP Prefix in Classless Inter-Domain Routing format. - Prefix string `json:"prefix,required"` - // Priority of the static route. - Priority int64 `json:"priority,required"` - // Identifier - ID string `json:"id"` - // When the route was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // An optional human provided description of the static route. - Description string `json:"description"` - // When the route was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Used only for ECMP routes. - Scope MagicTransitRouteNewResponseRoutesScope `json:"scope"` - // Optional weight of the ECMP scope - if provided. - Weight int64 `json:"weight"` - JSON magicTransitRouteNewResponseRouteJSON `json:"-"` -} - -// magicTransitRouteNewResponseRouteJSON contains the JSON metadata for the struct -// [MagicTransitRouteNewResponseRoute] -type magicTransitRouteNewResponseRouteJSON struct { - Nexthop apijson.Field - Prefix apijson.Field - Priority apijson.Field - ID apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ModifiedOn apijson.Field - Scope apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteNewResponseRoute) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteNewResponseRouteJSON) RawJSON() string { - return r.raw -} - -// Used only for ECMP routes. -type MagicTransitRouteNewResponseRoutesScope struct { - // List of colo names for the ECMP scope. - ColoNames []string `json:"colo_names"` - // List of colo regions for the ECMP scope. - ColoRegions []string `json:"colo_regions"` - JSON magicTransitRouteNewResponseRoutesScopeJSON `json:"-"` -} - -// magicTransitRouteNewResponseRoutesScopeJSON contains the JSON metadata for the -// struct [MagicTransitRouteNewResponseRoutesScope] -type magicTransitRouteNewResponseRoutesScopeJSON struct { - ColoNames apijson.Field - ColoRegions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteNewResponseRoutesScope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteNewResponseRoutesScopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteUpdateResponse struct { - Modified bool `json:"modified"` - ModifiedRoute interface{} `json:"modified_route"` - JSON magicTransitRouteUpdateResponseJSON `json:"-"` -} - -// magicTransitRouteUpdateResponseJSON contains the JSON metadata for the struct -// [MagicTransitRouteUpdateResponse] -type magicTransitRouteUpdateResponseJSON struct { - Modified apijson.Field - ModifiedRoute apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteListResponse struct { - Routes []MagicTransitRouteListResponseRoute `json:"routes"` - JSON magicTransitRouteListResponseJSON `json:"-"` -} - -// magicTransitRouteListResponseJSON contains the JSON metadata for the struct -// [MagicTransitRouteListResponse] -type magicTransitRouteListResponseJSON struct { - Routes apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteListResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteListResponseRoute struct { - // The next-hop IP Address for the static route. - Nexthop string `json:"nexthop,required"` - // IP Prefix in Classless Inter-Domain Routing format. - Prefix string `json:"prefix,required"` - // Priority of the static route. - Priority int64 `json:"priority,required"` - // Identifier - ID string `json:"id"` - // When the route was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // An optional human provided description of the static route. - Description string `json:"description"` - // When the route was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Used only for ECMP routes. - Scope MagicTransitRouteListResponseRoutesScope `json:"scope"` - // Optional weight of the ECMP scope - if provided. - Weight int64 `json:"weight"` - JSON magicTransitRouteListResponseRouteJSON `json:"-"` -} - -// magicTransitRouteListResponseRouteJSON contains the JSON metadata for the struct -// [MagicTransitRouteListResponseRoute] -type magicTransitRouteListResponseRouteJSON struct { - Nexthop apijson.Field - Prefix apijson.Field - Priority apijson.Field - ID apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ModifiedOn apijson.Field - Scope apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteListResponseRoute) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteListResponseRouteJSON) RawJSON() string { - return r.raw -} - -// Used only for ECMP routes. -type MagicTransitRouteListResponseRoutesScope struct { - // List of colo names for the ECMP scope. - ColoNames []string `json:"colo_names"` - // List of colo regions for the ECMP scope. - ColoRegions []string `json:"colo_regions"` - JSON magicTransitRouteListResponseRoutesScopeJSON `json:"-"` -} - -// magicTransitRouteListResponseRoutesScopeJSON contains the JSON metadata for the -// struct [MagicTransitRouteListResponseRoutesScope] -type magicTransitRouteListResponseRoutesScopeJSON struct { - ColoNames apijson.Field - ColoRegions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteListResponseRoutesScope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteListResponseRoutesScopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteDeleteResponse struct { - Deleted bool `json:"deleted"` - DeletedRoute interface{} `json:"deleted_route"` - JSON magicTransitRouteDeleteResponseJSON `json:"-"` -} - -// magicTransitRouteDeleteResponseJSON contains the JSON metadata for the struct -// [MagicTransitRouteDeleteResponse] -type magicTransitRouteDeleteResponseJSON struct { - Deleted apijson.Field - DeletedRoute apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteEmptyResponse struct { - Deleted bool `json:"deleted"` - DeletedRoutes interface{} `json:"deleted_routes"` - JSON magicTransitRouteEmptyResponseJSON `json:"-"` -} - -// magicTransitRouteEmptyResponseJSON contains the JSON metadata for the struct -// [MagicTransitRouteEmptyResponse] -type magicTransitRouteEmptyResponseJSON struct { - Deleted apijson.Field - DeletedRoutes apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteEmptyResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteEmptyResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteGetResponse struct { - Route interface{} `json:"route"` - JSON magicTransitRouteGetResponseJSON `json:"-"` -} - -// magicTransitRouteGetResponseJSON contains the JSON metadata for the struct -// [MagicTransitRouteGetResponse] -type magicTransitRouteGetResponseJSON struct { - Route apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteGetResponseJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteNewParams struct { - Body param.Field[interface{}] `json:"body,required"` -} - -func (r MagicTransitRouteNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type MagicTransitRouteNewResponseEnvelope struct { - Errors []MagicTransitRouteNewResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitRouteNewResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitRouteNewResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitRouteNewResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitRouteNewResponseEnvelopeJSON `json:"-"` -} - -// magicTransitRouteNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [MagicTransitRouteNewResponseEnvelope] -type magicTransitRouteNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitRouteNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitRouteNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [MagicTransitRouteNewResponseEnvelopeErrors] -type magicTransitRouteNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitRouteNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitRouteNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [MagicTransitRouteNewResponseEnvelopeMessages] -type magicTransitRouteNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitRouteNewResponseEnvelopeSuccess bool - -const ( - MagicTransitRouteNewResponseEnvelopeSuccessTrue MagicTransitRouteNewResponseEnvelopeSuccess = true -) - -type MagicTransitRouteUpdateParams struct { - // The next-hop IP Address for the static route. - Nexthop param.Field[string] `json:"nexthop,required"` - // IP Prefix in Classless Inter-Domain Routing format. - Prefix param.Field[string] `json:"prefix,required"` - // Priority of the static route. - Priority param.Field[int64] `json:"priority,required"` - // An optional human provided description of the static route. - Description param.Field[string] `json:"description"` - // Used only for ECMP routes. - Scope param.Field[MagicTransitRouteUpdateParamsScope] `json:"scope"` - // Optional weight of the ECMP scope - if provided. - Weight param.Field[int64] `json:"weight"` -} - -func (r MagicTransitRouteUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Used only for ECMP routes. -type MagicTransitRouteUpdateParamsScope struct { - // List of colo names for the ECMP scope. - ColoNames param.Field[[]string] `json:"colo_names"` - // List of colo regions for the ECMP scope. - ColoRegions param.Field[[]string] `json:"colo_regions"` -} - -func (r MagicTransitRouteUpdateParamsScope) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MagicTransitRouteUpdateResponseEnvelope struct { - Errors []MagicTransitRouteUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitRouteUpdateResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitRouteUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitRouteUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitRouteUpdateResponseEnvelopeJSON `json:"-"` -} - -// magicTransitRouteUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [MagicTransitRouteUpdateResponseEnvelope] -type magicTransitRouteUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitRouteUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitRouteUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [MagicTransitRouteUpdateResponseEnvelopeErrors] -type magicTransitRouteUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitRouteUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitRouteUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [MagicTransitRouteUpdateResponseEnvelopeMessages] -type magicTransitRouteUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitRouteUpdateResponseEnvelopeSuccess bool - -const ( - MagicTransitRouteUpdateResponseEnvelopeSuccessTrue MagicTransitRouteUpdateResponseEnvelopeSuccess = true -) - -type MagicTransitRouteListResponseEnvelope struct { - Errors []MagicTransitRouteListResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitRouteListResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitRouteListResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitRouteListResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitRouteListResponseEnvelopeJSON `json:"-"` -} - -// magicTransitRouteListResponseEnvelopeJSON contains the JSON metadata for the -// struct [MagicTransitRouteListResponseEnvelope] -type magicTransitRouteListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitRouteListResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitRouteListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [MagicTransitRouteListResponseEnvelopeErrors] -type magicTransitRouteListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitRouteListResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitRouteListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [MagicTransitRouteListResponseEnvelopeMessages] -type magicTransitRouteListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitRouteListResponseEnvelopeSuccess bool - -const ( - MagicTransitRouteListResponseEnvelopeSuccessTrue MagicTransitRouteListResponseEnvelopeSuccess = true -) - -type MagicTransitRouteDeleteResponseEnvelope struct { - Errors []MagicTransitRouteDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitRouteDeleteResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitRouteDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitRouteDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitRouteDeleteResponseEnvelopeJSON `json:"-"` -} - -// magicTransitRouteDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [MagicTransitRouteDeleteResponseEnvelope] -type magicTransitRouteDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitRouteDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitRouteDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [MagicTransitRouteDeleteResponseEnvelopeErrors] -type magicTransitRouteDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitRouteDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitRouteDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [MagicTransitRouteDeleteResponseEnvelopeMessages] -type magicTransitRouteDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitRouteDeleteResponseEnvelopeSuccess bool - -const ( - MagicTransitRouteDeleteResponseEnvelopeSuccessTrue MagicTransitRouteDeleteResponseEnvelopeSuccess = true -) - -type MagicTransitRouteEmptyParams struct { - Routes param.Field[[]MagicTransitRouteEmptyParamsRoute] `json:"routes,required"` -} - -func (r MagicTransitRouteEmptyParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MagicTransitRouteEmptyParamsRoute struct { -} - -func (r MagicTransitRouteEmptyParamsRoute) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type MagicTransitRouteEmptyResponseEnvelope struct { - Errors []MagicTransitRouteEmptyResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitRouteEmptyResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitRouteEmptyResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitRouteEmptyResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitRouteEmptyResponseEnvelopeJSON `json:"-"` -} - -// magicTransitRouteEmptyResponseEnvelopeJSON contains the JSON metadata for the -// struct [MagicTransitRouteEmptyResponseEnvelope] -type magicTransitRouteEmptyResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteEmptyResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteEmptyResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteEmptyResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitRouteEmptyResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitRouteEmptyResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [MagicTransitRouteEmptyResponseEnvelopeErrors] -type magicTransitRouteEmptyResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteEmptyResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteEmptyResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteEmptyResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitRouteEmptyResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitRouteEmptyResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [MagicTransitRouteEmptyResponseEnvelopeMessages] -type magicTransitRouteEmptyResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteEmptyResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteEmptyResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitRouteEmptyResponseEnvelopeSuccess bool - -const ( - MagicTransitRouteEmptyResponseEnvelopeSuccessTrue MagicTransitRouteEmptyResponseEnvelopeSuccess = true -) - -type MagicTransitRouteGetResponseEnvelope struct { - Errors []MagicTransitRouteGetResponseEnvelopeErrors `json:"errors,required"` - Messages []MagicTransitRouteGetResponseEnvelopeMessages `json:"messages,required"` - Result MagicTransitRouteGetResponse `json:"result,required"` - // Whether the API call was successful - Success MagicTransitRouteGetResponseEnvelopeSuccess `json:"success,required"` - JSON magicTransitRouteGetResponseEnvelopeJSON `json:"-"` -} - -// magicTransitRouteGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [MagicTransitRouteGetResponseEnvelope] -type magicTransitRouteGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitRouteGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// magicTransitRouteGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [MagicTransitRouteGetResponseEnvelopeErrors] -type magicTransitRouteGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MagicTransitRouteGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON magicTransitRouteGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// magicTransitRouteGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [MagicTransitRouteGetResponseEnvelopeMessages] -type magicTransitRouteGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MagicTransitRouteGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r magicTransitRouteGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MagicTransitRouteGetResponseEnvelopeSuccess bool - -const ( - MagicTransitRouteGetResponseEnvelopeSuccessTrue MagicTransitRouteGetResponseEnvelopeSuccess = true -) diff --git a/magictransitroute_test.go b/magictransitroute_test.go deleted file mode 100644 index 1f824122c9f..00000000000 --- a/magictransitroute_test.go +++ /dev/null @@ -1,193 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestMagicTransitRouteNew(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("user@example.com"), - ) - _, err := client.MagicTransit.Routes.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.MagicTransitRouteNewParams{ - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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 TestMagicTransitRouteUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.MagicTransit.Routes.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.MagicTransitRouteUpdateParams{ - Nexthop: cloudflare.F("203.0.113.1"), - Prefix: cloudflare.F("192.0.2.0/24"), - Priority: cloudflare.F(int64(0)), - Description: cloudflare.F("New route for new prefix 203.0.113.1"), - Scope: cloudflare.F(cloudflare.MagicTransitRouteUpdateParamsScope{ - ColoNames: cloudflare.F([]string{"den01", "den01", "den01"}), - ColoRegions: cloudflare.F([]string{"APAC", "APAC", "APAC"}), - }), - Weight: cloudflare.F(int64(0)), - }, - ) - 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 TestMagicTransitRouteList(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("user@example.com"), - ) - _, err := client.MagicTransit.Routes.List(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()) - } -} - -func TestMagicTransitRouteDelete(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("user@example.com"), - ) - _, err := client.MagicTransit.Routes.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "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()) - } -} - -func TestMagicTransitRouteEmpty(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("user@example.com"), - ) - _, err := client.MagicTransit.Routes.Empty( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.MagicTransitRouteEmptyParams{ - Routes: cloudflare.F([]cloudflare.MagicTransitRouteEmptyParamsRoute{{}, {}, {}}), - }, - ) - 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 TestMagicTransitRouteGet(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("user@example.com"), - ) - _, err := client.MagicTransit.Routes.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "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/managed_headers/aliases.go b/managed_headers/aliases.go new file mode 100644 index 00000000000..a45308dcea2 --- /dev/null +++ b/managed_headers/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package managed_headers + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/managedheader.go b/managed_headers/managedheader.go similarity index 99% rename from managedheader.go rename to managed_headers/managedheader.go index 896ad9da996..a84590f0a64 100644 --- a/managedheader.go +++ b/managed_headers/managedheader.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package managed_headers import ( "context" diff --git a/managedheader_test.go b/managed_headers/managedheader_test.go similarity index 81% rename from managedheader_test.go rename to managed_headers/managedheader_test.go index 5cad0e04eac..a03e59a00bf 100644 --- a/managedheader_test.go +++ b/managed_headers/managedheader_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package managed_headers_test import ( "context" @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/managed_headers" "github.com/cloudflare/cloudflare-go/option" ) @@ -27,7 +28,7 @@ func TestManagedHeaderList(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.ManagedHeaders.List(context.TODO(), cloudflare.ManagedHeaderListParams{ + _, err := client.ManagedHeaders.List(context.TODO(), managed_headers.ManagedHeaderListParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { @@ -53,9 +54,9 @@ func TestManagedHeaderEdit(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.ManagedHeaders.Edit(context.TODO(), cloudflare.ManagedHeaderEditParams{ + _, err := client.ManagedHeaders.Edit(context.TODO(), managed_headers.ManagedHeaderEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - ManagedRequestHeaders: cloudflare.F([]cloudflare.ManagedHeaderEditParamsManagedRequestHeader{{ + ManagedRequestHeaders: cloudflare.F([]managed_headers.ManagedHeaderEditParamsManagedRequestHeader{{ Enabled: cloudflare.F(true), ID: cloudflare.F("add_cf-bot-score_header"), }, { @@ -65,7 +66,7 @@ func TestManagedHeaderEdit(t *testing.T) { Enabled: cloudflare.F(true), ID: cloudflare.F("add_cf-bot-score_header"), }}), - ManagedResponseHeaders: cloudflare.F([]cloudflare.ManagedHeaderEditParamsManagedResponseHeader{{ + ManagedResponseHeaders: cloudflare.F([]managed_headers.ManagedHeaderEditParamsManagedResponseHeader{{ Enabled: cloudflare.F(true), ID: cloudflare.F("add_cf-bot-score_header"), }, { diff --git a/memberships/aliases.go b/memberships/aliases.go new file mode 100644 index 00000000000..ece7754be85 --- /dev/null +++ b/memberships/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package memberships + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/membership.go b/memberships/membership.go similarity index 98% rename from membership.go rename to memberships/membership.go index 4b0ec3339e3..af4663c3023 100644 --- a/membership.go +++ b/memberships/membership.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package memberships import ( "context" @@ -9,6 +9,7 @@ import ( "net/url" "reflect" + "github.com/cloudflare/cloudflare-go/accounts" "github.com/cloudflare/cloudflare-go/internal/apijson" "github.com/cloudflare/cloudflare-go/internal/apiquery" "github.com/cloudflare/cloudflare-go/internal/param" @@ -99,8 +100,8 @@ func (r *MembershipService) Get(ctx context.Context, membershipID string, opts . type Membership struct { // Membership identifier tag. - ID string `json:"id"` - Account Account `json:"account"` + ID string `json:"id"` + Account accounts.Account `json:"account"` // Enterprise only. Indicates whether or not API access is enabled specifically for // this user on a given account. APIAccessEnabled bool `json:"api_access_enabled,nullable"` @@ -465,9 +466,10 @@ const ( MembershipStatusRejected MembershipStatus = "rejected" ) -// Union satisfied by [MembershipUpdateResponseUnknown] or [shared.UnionString]. +// Union satisfied by [memberships.MembershipUpdateResponseUnknown] or +// [shared.UnionString]. type MembershipUpdateResponse interface { - ImplementsMembershipUpdateResponse() + ImplementsMembershipsMembershipUpdateResponse() } func init() { @@ -503,9 +505,10 @@ func (r membershipDeleteResponseJSON) RawJSON() string { return r.raw } -// Union satisfied by [MembershipGetResponseUnknown] or [shared.UnionString]. +// Union satisfied by [memberships.MembershipGetResponseUnknown] or +// [shared.UnionString]. type MembershipGetResponse interface { - ImplementsMembershipGetResponse() + ImplementsMembershipsMembershipGetResponse() } func init() { diff --git a/membership_test.go b/memberships/membership_test.go similarity index 85% rename from membership_test.go rename to memberships/membership_test.go index f95e2704a13..92dc38aae38 100644 --- a/membership_test.go +++ b/memberships/membership_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package memberships_test import ( "context" @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/memberships" "github.com/cloudflare/cloudflare-go/option" ) @@ -30,8 +31,8 @@ func TestMembershipUpdate(t *testing.T) { _, err := client.Memberships.Update( context.TODO(), "4536bcfad5faccb111b47003c79917fa", - cloudflare.MembershipUpdateParams{ - Status: cloudflare.F(cloudflare.MembershipUpdateParamsStatusAccepted), + memberships.MembershipUpdateParams{ + Status: cloudflare.F(memberships.MembershipUpdateParamsStatusAccepted), }, ) if err != nil { @@ -57,16 +58,16 @@ func TestMembershipListWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Memberships.List(context.TODO(), cloudflare.MembershipListParams{ - Account: cloudflare.F(cloudflare.MembershipListParamsAccount{ + _, err := client.Memberships.List(context.TODO(), memberships.MembershipListParams{ + Account: cloudflare.F(memberships.MembershipListParamsAccount{ Name: cloudflare.F("Demo Account"), }), - Direction: cloudflare.F(cloudflare.MembershipListParamsDirectionDesc), + Direction: cloudflare.F(memberships.MembershipListParamsDirectionDesc), Name: cloudflare.F("Demo Account"), - Order: cloudflare.F(cloudflare.MembershipListParamsOrderStatus), + Order: cloudflare.F(memberships.MembershipListParamsOrderStatus), Page: cloudflare.F(1.000000), PerPage: cloudflare.F(5.000000), - Status: cloudflare.F(cloudflare.MembershipListParamsStatusAccepted), + Status: cloudflare.F(memberships.MembershipListParamsStatusAccepted), }) if err != nil { var apierr *cloudflare.Error diff --git a/mtls_certificates/aliases.go b/mtls_certificates/aliases.go new file mode 100644 index 00000000000..625b8dda3bd --- /dev/null +++ b/mtls_certificates/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package mtls_certificates + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/mtls_certificates/association.go b/mtls_certificates/association.go new file mode 100644 index 00000000000..005edaefe71 --- /dev/null +++ b/mtls_certificates/association.go @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package mtls_certificates + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AssociationService 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 [NewAssociationService] method +// instead. +type AssociationService struct { + Options []option.RequestOption +} + +// NewAssociationService 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 NewAssociationService(opts ...option.RequestOption) (r *AssociationService) { + r = &AssociationService{} + r.Options = opts + return +} + +// Lists all active associations between the certificate and Cloudflare services. +func (r *AssociationService) Get(ctx context.Context, mtlsCertificateID string, query AssociationGetParams, opts ...option.RequestOption) (res *[]TLSCertificatesAndHostnamesAssociationObject, err error) { + opts = append(r.Options[:], opts...) + var env AssociationGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/mtls_certificates/%s/associations", query.AccountID, mtlsCertificateID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TLSCertificatesAndHostnamesAssociationObject struct { + // The service using the certificate. + Service string `json:"service"` + // Certificate deployment status for the given service. + Status string `json:"status"` + JSON tlsCertificatesAndHostnamesAssociationObjectJSON `json:"-"` +} + +// tlsCertificatesAndHostnamesAssociationObjectJSON contains the JSON metadata for +// the struct [TLSCertificatesAndHostnamesAssociationObject] +type tlsCertificatesAndHostnamesAssociationObjectJSON struct { + Service apijson.Field + Status apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TLSCertificatesAndHostnamesAssociationObject) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tlsCertificatesAndHostnamesAssociationObjectJSON) RawJSON() string { + return r.raw +} + +type AssociationGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type AssociationGetResponseEnvelope struct { + Errors []AssociationGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AssociationGetResponseEnvelopeMessages `json:"messages,required"` + Result []TLSCertificatesAndHostnamesAssociationObject `json:"result,required,nullable"` + // Whether the API call was successful + Success AssociationGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AssociationGetResponseEnvelopeResultInfo `json:"result_info"` + JSON associationGetResponseEnvelopeJSON `json:"-"` +} + +// associationGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [AssociationGetResponseEnvelope] +type associationGetResponseEnvelopeJSON 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 *AssociationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r associationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AssociationGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON associationGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// associationGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AssociationGetResponseEnvelopeErrors] +type associationGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AssociationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r associationGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AssociationGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON associationGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// associationGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AssociationGetResponseEnvelopeMessages] +type associationGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AssociationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r associationGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AssociationGetResponseEnvelopeSuccess bool + +const ( + AssociationGetResponseEnvelopeSuccessTrue AssociationGetResponseEnvelopeSuccess = true +) + +type AssociationGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON associationGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// associationGetResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [AssociationGetResponseEnvelopeResultInfo] +type associationGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AssociationGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r associationGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/mtls_certificates/association_test.go b/mtls_certificates/association_test.go new file mode 100644 index 00000000000..05c4b7d74cb --- /dev/null +++ b/mtls_certificates/association_test.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package mtls_certificates_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/mtls_certificates" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestAssociationGet(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("user@example.com"), + ) + _, err := client.MTLSCertificates.Associations.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + mtls_certificates.AssociationGetParams{ + AccountID: cloudflare.F("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/mtlscertificate.go b/mtls_certificates/mtlscertificate.go similarity index 77% rename from mtlscertificate.go rename to mtls_certificates/mtlscertificate.go index 12a30561891..2b6e4123355 100644 --- a/mtlscertificate.go +++ b/mtls_certificates/mtlscertificate.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package mtls_certificates import ( "context" @@ -21,7 +21,7 @@ import ( // instead. type MTLSCertificateService struct { Options []option.RequestOption - Associations *MTLSCertificateAssociationService + Associations *AssociationService } // NewMTLSCertificateService generates a new service that applies the given options @@ -30,12 +30,12 @@ type MTLSCertificateService struct { func NewMTLSCertificateService(opts ...option.RequestOption) (r *MTLSCertificateService) { r = &MTLSCertificateService{} r.Options = opts - r.Associations = NewMTLSCertificateAssociationService(opts...) + r.Associations = NewAssociationService(opts...) return } // Upload a certificate that you want to use with mTLS-enabled Cloudflare services. -func (r *MTLSCertificateService) New(ctx context.Context, params MTLSCertificateNewParams, opts ...option.RequestOption) (res *MTLSCertificateNewResponse, err error) { +func (r *MTLSCertificateService) New(ctx context.Context, params MTLSCertificateNewParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesCertificateObjectPost, err error) { opts = append(r.Options[:], opts...) var env MTLSCertificateNewResponseEnvelope path := fmt.Sprintf("accounts/%s/mtls_certificates", params.AccountID) @@ -48,7 +48,7 @@ func (r *MTLSCertificateService) New(ctx context.Context, params MTLSCertificate } // Lists all mTLS certificates. -func (r *MTLSCertificateService) List(ctx context.Context, query MTLSCertificateListParams, opts ...option.RequestOption) (res *[]MTLSCertificateListResponse, err error) { +func (r *MTLSCertificateService) List(ctx context.Context, query MTLSCertificateListParams, opts ...option.RequestOption) (res *[]TLSCertificatesAndHostnamesComponentsSchemasCertificateObject, err error) { opts = append(r.Options[:], opts...) var env MTLSCertificateListResponseEnvelope path := fmt.Sprintf("accounts/%s/mtls_certificates", query.AccountID) @@ -62,7 +62,7 @@ func (r *MTLSCertificateService) List(ctx context.Context, query MTLSCertificate // Deletes the mTLS certificate unless the certificate is in use by one or more // Cloudflare services. -func (r *MTLSCertificateService) Delete(ctx context.Context, mtlsCertificateID string, body MTLSCertificateDeleteParams, opts ...option.RequestOption) (res *MTLSCertificateDeleteResponse, err error) { +func (r *MTLSCertificateService) Delete(ctx context.Context, mtlsCertificateID string, body MTLSCertificateDeleteParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesComponentsSchemasCertificateObject, err error) { opts = append(r.Options[:], opts...) var env MTLSCertificateDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/mtls_certificates/%s", body.AccountID, mtlsCertificateID) @@ -75,7 +75,7 @@ func (r *MTLSCertificateService) Delete(ctx context.Context, mtlsCertificateID s } // Fetches a single mTLS certificate. -func (r *MTLSCertificateService) Get(ctx context.Context, mtlsCertificateID string, query MTLSCertificateGetParams, opts ...option.RequestOption) (res *MTLSCertificateGetResponse, err error) { +func (r *MTLSCertificateService) Get(ctx context.Context, mtlsCertificateID string, query MTLSCertificateGetParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesComponentsSchemasCertificateObject, err error) { opts = append(r.Options[:], opts...) var env MTLSCertificateGetResponseEnvelope path := fmt.Sprintf("accounts/%s/mtls_certificates/%s", query.AccountID, mtlsCertificateID) @@ -87,7 +87,7 @@ func (r *MTLSCertificateService) Get(ctx context.Context, mtlsCertificateID stri return } -type MTLSCertificateNewResponse struct { +type TLSCertificatesAndHostnamesCertificateObjectPost struct { // Identifier ID string `json:"id"` // Indicates whether the certificate is a CA or leaf certificate. @@ -107,13 +107,13 @@ type MTLSCertificateNewResponse struct { // This is the time the certificate was updated. UpdatedAt time.Time `json:"updated_at" format:"date-time"` // This is the time the certificate was uploaded. - UploadedOn time.Time `json:"uploaded_on" format:"date-time"` - JSON mtlsCertificateNewResponseJSON `json:"-"` + UploadedOn time.Time `json:"uploaded_on" format:"date-time"` + JSON tlsCertificatesAndHostnamesCertificateObjectPostJSON `json:"-"` } -// mtlsCertificateNewResponseJSON contains the JSON metadata for the struct -// [MTLSCertificateNewResponse] -type mtlsCertificateNewResponseJSON struct { +// tlsCertificatesAndHostnamesCertificateObjectPostJSON contains the JSON metadata +// for the struct [TLSCertificatesAndHostnamesCertificateObjectPost] +type tlsCertificatesAndHostnamesCertificateObjectPostJSON struct { ID apijson.Field CA apijson.Field Certificates apijson.Field @@ -128,15 +128,15 @@ type mtlsCertificateNewResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *MTLSCertificateNewResponse) UnmarshalJSON(data []byte) (err error) { +func (r *TLSCertificatesAndHostnamesCertificateObjectPost) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r mtlsCertificateNewResponseJSON) RawJSON() string { +func (r tlsCertificatesAndHostnamesCertificateObjectPostJSON) RawJSON() string { return r.raw } -type MTLSCertificateListResponse struct { +type TLSCertificatesAndHostnamesComponentsSchemasCertificateObject struct { // Identifier ID string `json:"id"` // Indicates whether the certificate is a CA or leaf certificate. @@ -154,13 +154,14 @@ type MTLSCertificateListResponse struct { // The type of hash used for the certificate. Signature string `json:"signature"` // This is the time the certificate was uploaded. - UploadedOn time.Time `json:"uploaded_on" format:"date-time"` - JSON mtlsCertificateListResponseJSON `json:"-"` + UploadedOn time.Time `json:"uploaded_on" format:"date-time"` + JSON tlsCertificatesAndHostnamesComponentsSchemasCertificateObjectJSON `json:"-"` } -// mtlsCertificateListResponseJSON contains the JSON metadata for the struct -// [MTLSCertificateListResponse] -type mtlsCertificateListResponseJSON struct { +// tlsCertificatesAndHostnamesComponentsSchemasCertificateObjectJSON contains the +// JSON metadata for the struct +// [TLSCertificatesAndHostnamesComponentsSchemasCertificateObject] +type tlsCertificatesAndHostnamesComponentsSchemasCertificateObjectJSON struct { ID apijson.Field CA apijson.Field Certificates apijson.Field @@ -174,103 +175,11 @@ type mtlsCertificateListResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *MTLSCertificateListResponse) UnmarshalJSON(data []byte) (err error) { +func (r *TLSCertificatesAndHostnamesComponentsSchemasCertificateObject) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r mtlsCertificateListResponseJSON) RawJSON() string { - return r.raw -} - -type MTLSCertificateDeleteResponse struct { - // Identifier - ID string `json:"id"` - // Indicates whether the certificate is a CA or leaf certificate. - CA bool `json:"ca"` - // The uploaded root CA certificate. - Certificates string `json:"certificates"` - // When the certificate expires. - ExpiresOn time.Time `json:"expires_on" format:"date-time"` - // The certificate authority that issued the certificate. - Issuer string `json:"issuer"` - // Optional unique name for the certificate. Only used for human readability. - Name string `json:"name"` - // The certificate serial number. - SerialNumber string `json:"serial_number"` - // The type of hash used for the certificate. - Signature string `json:"signature"` - // This is the time the certificate was uploaded. - UploadedOn time.Time `json:"uploaded_on" format:"date-time"` - JSON mtlsCertificateDeleteResponseJSON `json:"-"` -} - -// mtlsCertificateDeleteResponseJSON contains the JSON metadata for the struct -// [MTLSCertificateDeleteResponse] -type mtlsCertificateDeleteResponseJSON struct { - ID apijson.Field - CA apijson.Field - Certificates apijson.Field - ExpiresOn apijson.Field - Issuer apijson.Field - Name apijson.Field - SerialNumber apijson.Field - Signature apijson.Field - UploadedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MTLSCertificateDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r mtlsCertificateDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type MTLSCertificateGetResponse struct { - // Identifier - ID string `json:"id"` - // Indicates whether the certificate is a CA or leaf certificate. - CA bool `json:"ca"` - // The uploaded root CA certificate. - Certificates string `json:"certificates"` - // When the certificate expires. - ExpiresOn time.Time `json:"expires_on" format:"date-time"` - // The certificate authority that issued the certificate. - Issuer string `json:"issuer"` - // Optional unique name for the certificate. Only used for human readability. - Name string `json:"name"` - // The certificate serial number. - SerialNumber string `json:"serial_number"` - // The type of hash used for the certificate. - Signature string `json:"signature"` - // This is the time the certificate was uploaded. - UploadedOn time.Time `json:"uploaded_on" format:"date-time"` - JSON mtlsCertificateGetResponseJSON `json:"-"` -} - -// mtlsCertificateGetResponseJSON contains the JSON metadata for the struct -// [MTLSCertificateGetResponse] -type mtlsCertificateGetResponseJSON struct { - ID apijson.Field - CA apijson.Field - Certificates apijson.Field - ExpiresOn apijson.Field - Issuer apijson.Field - Name apijson.Field - SerialNumber apijson.Field - Signature apijson.Field - UploadedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MTLSCertificateGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r mtlsCertificateGetResponseJSON) RawJSON() string { +func (r tlsCertificatesAndHostnamesComponentsSchemasCertificateObjectJSON) RawJSON() string { return r.raw } @@ -292,9 +201,9 @@ func (r MTLSCertificateNewParams) MarshalJSON() (data []byte, err error) { } type MTLSCertificateNewResponseEnvelope struct { - Errors []MTLSCertificateNewResponseEnvelopeErrors `json:"errors,required"` - Messages []MTLSCertificateNewResponseEnvelopeMessages `json:"messages,required"` - Result MTLSCertificateNewResponse `json:"result,required"` + Errors []MTLSCertificateNewResponseEnvelopeErrors `json:"errors,required"` + Messages []MTLSCertificateNewResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesCertificateObjectPost `json:"result,required"` // Whether the API call was successful Success MTLSCertificateNewResponseEnvelopeSuccess `json:"success,required"` JSON mtlsCertificateNewResponseEnvelopeJSON `json:"-"` @@ -378,9 +287,9 @@ type MTLSCertificateListParams struct { } type MTLSCertificateListResponseEnvelope struct { - Errors []MTLSCertificateListResponseEnvelopeErrors `json:"errors,required"` - Messages []MTLSCertificateListResponseEnvelopeMessages `json:"messages,required"` - Result []MTLSCertificateListResponse `json:"result,required,nullable"` + Errors []MTLSCertificateListResponseEnvelopeErrors `json:"errors,required"` + Messages []MTLSCertificateListResponseEnvelopeMessages `json:"messages,required"` + Result []TLSCertificatesAndHostnamesComponentsSchemasCertificateObject `json:"result,required,nullable"` // Whether the API call was successful Success MTLSCertificateListResponseEnvelopeSuccess `json:"success,required"` ResultInfo MTLSCertificateListResponseEnvelopeResultInfo `json:"result_info"` @@ -499,9 +408,9 @@ type MTLSCertificateDeleteParams struct { } type MTLSCertificateDeleteResponseEnvelope struct { - Errors []MTLSCertificateDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []MTLSCertificateDeleteResponseEnvelopeMessages `json:"messages,required"` - Result MTLSCertificateDeleteResponse `json:"result,required"` + Errors []MTLSCertificateDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []MTLSCertificateDeleteResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesComponentsSchemasCertificateObject `json:"result,required"` // Whether the API call was successful Success MTLSCertificateDeleteResponseEnvelopeSuccess `json:"success,required"` JSON mtlsCertificateDeleteResponseEnvelopeJSON `json:"-"` @@ -585,9 +494,9 @@ type MTLSCertificateGetParams struct { } type MTLSCertificateGetResponseEnvelope struct { - Errors []MTLSCertificateGetResponseEnvelopeErrors `json:"errors,required"` - Messages []MTLSCertificateGetResponseEnvelopeMessages `json:"messages,required"` - Result MTLSCertificateGetResponse `json:"result,required"` + Errors []MTLSCertificateGetResponseEnvelopeErrors `json:"errors,required"` + Messages []MTLSCertificateGetResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesComponentsSchemasCertificateObject `json:"result,required"` // Whether the API call was successful Success MTLSCertificateGetResponseEnvelopeSuccess `json:"success,required"` JSON mtlsCertificateGetResponseEnvelopeJSON `json:"-"` diff --git a/mtlscertificate_test.go b/mtls_certificates/mtlscertificate_test.go similarity index 94% rename from mtlscertificate_test.go rename to mtls_certificates/mtlscertificate_test.go index 44479e3e4f7..4859ecd76fc 100644 --- a/mtlscertificate_test.go +++ b/mtls_certificates/mtlscertificate_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package mtls_certificates_test import ( "context" @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/mtls_certificates" "github.com/cloudflare/cloudflare-go/option" ) @@ -27,7 +28,7 @@ func TestMTLSCertificateNewWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.MTLSCertificates.New(context.TODO(), cloudflare.MTLSCertificateNewParams{ + _, err := client.MTLSCertificates.New(context.TODO(), mtls_certificates.MTLSCertificateNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), CA: cloudflare.F(true), Certificates: cloudflare.F("-----BEGIN CERTIFICATE-----\nMIIDmDCCAoCgAwIBAgIUKTOAZNjcXVZRj4oQt0SHsl1c1vMwDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCVVMxFjAUBgNVBAgMDVNhbiBGcmFuY2lzY28xEzARBgNVBAcMCkNhbGlmb3JuaWExFTATBgNVBAoMDEV4YW1wbGUgSW5jLjAgFw0yMjExMjIxNjU5NDdaGA8yMTIyMTAyOTE2NTk0N1owUTELMAkGA1UEBhMCVVMxFjAUBgNVBAgMDVNhbiBGcmFuY2lzY28xEzARBgNVBAcMCkNhbGlmb3JuaWExFTATBgNVBAoMDEV4YW1wbGUgSW5jLjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMRcORwgJFTdcG/2GKI+cFYiOBNDKjCZUXEOvXWY42BkH9wxiMT869CO+enA1w5pIrXow6kCM1sQspHHaVmJUlotEMJxyoLFfA/8Kt1EKFyobOjuZs2SwyVyJ2sStvQuUQEosULZCNGZEqoH5g6zhMPxaxm7ZLrrsDZ9maNGVqo7EWLWHrZ57Q/5MtTrbxQL+eXjUmJ9K3kS+3uEwMdqR6Z3BluU1ivanpPc1CN2GNhdO0/hSY4YkGEnuLsqJyDd3cIiB1MxuCBJ4ZaqOd2viV1WcP3oU3dxVPm4MWyfYIldMWB14FahScxLhWdRnM9YZ/i9IFcLypXsuz7DjrJPtPUCAwEAAaNmMGQwHQYDVR0OBBYEFP5JzLUawNF+c3AXsYTEWHh7z2czMB8GA1UdIwQYMBaAFP5JzLUawNF+c3AXsYTEWHh7z2czMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/AgEBMA0GCSqGSIb3DQEBCwUAA4IBAQBc+Be7NDhpE09y7hLPZGRPl1cSKBw4RI0XIv6rlbSTFs5EebpTGjhx/whNxwEZhB9HZ7111Oa1YlT8xkI9DshB78mjAHCKBAJ76moK8tkG0aqdYpJ4ZcJTVBB7l98Rvgc7zfTii7WemTy72deBbSeiEtXavm4EF0mWjHhQ5Nxpnp00Bqn5g1x8CyTDypgmugnep+xG+iFzNmTdsz7WI9T/7kDMXqB7M/FPWBORyS98OJqNDswCLF8bIZYwUBEe+bRHFomoShMzaC3tvim7WCb16noDkSTMlfKO4pnvKhpcVdSgwcruATV7y+W+Lvmz2OT/Gui4JhqeoTewsxndhDDE\n-----END CERTIFICATE-----"), @@ -57,7 +58,7 @@ func TestMTLSCertificateList(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.MTLSCertificates.List(context.TODO(), cloudflare.MTLSCertificateListParams{ + _, err := client.MTLSCertificates.List(context.TODO(), mtls_certificates.MTLSCertificateListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { @@ -86,7 +87,7 @@ func TestMTLSCertificateDelete(t *testing.T) { _, err := client.MTLSCertificates.Delete( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.MTLSCertificateDeleteParams{ + mtls_certificates.MTLSCertificateDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) @@ -116,7 +117,7 @@ func TestMTLSCertificateGet(t *testing.T) { _, err := client.MTLSCertificates.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.MTLSCertificateGetParams{ + mtls_certificates.MTLSCertificateGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) diff --git a/mtlscertificateassociation.go b/mtlscertificateassociation.go deleted file mode 100644 index 1ea013980ae..00000000000 --- a/mtlscertificateassociation.go +++ /dev/null @@ -1,190 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// MTLSCertificateAssociationService 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 -// [NewMTLSCertificateAssociationService] method instead. -type MTLSCertificateAssociationService struct { - Options []option.RequestOption -} - -// NewMTLSCertificateAssociationService 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 NewMTLSCertificateAssociationService(opts ...option.RequestOption) (r *MTLSCertificateAssociationService) { - r = &MTLSCertificateAssociationService{} - r.Options = opts - return -} - -// Lists all active associations between the certificate and Cloudflare services. -func (r *MTLSCertificateAssociationService) Get(ctx context.Context, mtlsCertificateID string, query MTLSCertificateAssociationGetParams, opts ...option.RequestOption) (res *[]MTLSCertificateAssociationGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env MTLSCertificateAssociationGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/mtls_certificates/%s/associations", query.AccountID, mtlsCertificateID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type MTLSCertificateAssociationGetResponse struct { - // The service using the certificate. - Service string `json:"service"` - // Certificate deployment status for the given service. - Status string `json:"status"` - JSON mtlsCertificateAssociationGetResponseJSON `json:"-"` -} - -// mtlsCertificateAssociationGetResponseJSON contains the JSON metadata for the -// struct [MTLSCertificateAssociationGetResponse] -type mtlsCertificateAssociationGetResponseJSON struct { - Service apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MTLSCertificateAssociationGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r mtlsCertificateAssociationGetResponseJSON) RawJSON() string { - return r.raw -} - -type MTLSCertificateAssociationGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type MTLSCertificateAssociationGetResponseEnvelope struct { - Errors []MTLSCertificateAssociationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []MTLSCertificateAssociationGetResponseEnvelopeMessages `json:"messages,required"` - Result []MTLSCertificateAssociationGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success MTLSCertificateAssociationGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo MTLSCertificateAssociationGetResponseEnvelopeResultInfo `json:"result_info"` - JSON mtlsCertificateAssociationGetResponseEnvelopeJSON `json:"-"` -} - -// mtlsCertificateAssociationGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [MTLSCertificateAssociationGetResponseEnvelope] -type mtlsCertificateAssociationGetResponseEnvelopeJSON 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 *MTLSCertificateAssociationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r mtlsCertificateAssociationGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type MTLSCertificateAssociationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON mtlsCertificateAssociationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// mtlsCertificateAssociationGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [MTLSCertificateAssociationGetResponseEnvelopeErrors] -type mtlsCertificateAssociationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MTLSCertificateAssociationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r mtlsCertificateAssociationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type MTLSCertificateAssociationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON mtlsCertificateAssociationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// mtlsCertificateAssociationGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [MTLSCertificateAssociationGetResponseEnvelopeMessages] -type mtlsCertificateAssociationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MTLSCertificateAssociationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r mtlsCertificateAssociationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type MTLSCertificateAssociationGetResponseEnvelopeSuccess bool - -const ( - MTLSCertificateAssociationGetResponseEnvelopeSuccessTrue MTLSCertificateAssociationGetResponseEnvelopeSuccess = true -) - -type MTLSCertificateAssociationGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON mtlsCertificateAssociationGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// mtlsCertificateAssociationGetResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [MTLSCertificateAssociationGetResponseEnvelopeResultInfo] -type mtlsCertificateAssociationGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MTLSCertificateAssociationGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r mtlsCertificateAssociationGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/mtlscertificateassociation_test.go b/mtlscertificateassociation_test.go deleted file mode 100644 index 2c4a02397ec..00000000000 --- a/mtlscertificateassociation_test.go +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestMTLSCertificateAssociationGet(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("user@example.com"), - ) - _, err := client.MTLSCertificates.Associations.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.MTLSCertificateAssociationGetParams{ - AccountID: cloudflare.F("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/origin_post_quantum_encryption/aliases.go b/origin_post_quantum_encryption/aliases.go new file mode 100644 index 00000000000..9ac9424f166 --- /dev/null +++ b/origin_post_quantum_encryption/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package origin_post_quantum_encryption + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/originpostquantumencryption.go b/origin_post_quantum_encryption/originpostquantumencryption.go similarity index 96% rename from originpostquantumencryption.go rename to origin_post_quantum_encryption/originpostquantumencryption.go index fb93ce9a442..17114c8615d 100644 --- a/originpostquantumencryption.go +++ b/origin_post_quantum_encryption/originpostquantumencryption.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package origin_post_quantum_encryption import ( "context" @@ -70,10 +70,11 @@ func (r *OriginPostQuantumEncryptionService) Get(ctx context.Context, query Orig return } -// Union satisfied by [OriginPostQuantumEncryptionUpdateResponseUnknown] or -// [shared.UnionString]. +// Union satisfied by +// [origin_post_quantum_encryption.OriginPostQuantumEncryptionUpdateResponseUnknown] +// or [shared.UnionString]. type OriginPostQuantumEncryptionUpdateResponse interface { - ImplementsOriginPostQuantumEncryptionUpdateResponse() + ImplementsOriginPostQuantumEncryptionOriginPostQuantumEncryptionUpdateResponse() } func init() { @@ -87,10 +88,11 @@ func init() { ) } -// Union satisfied by [OriginPostQuantumEncryptionGetResponseUnknown] or -// [shared.UnionString]. +// Union satisfied by +// [origin_post_quantum_encryption.OriginPostQuantumEncryptionGetResponseUnknown] +// or [shared.UnionString]. type OriginPostQuantumEncryptionGetResponse interface { - ImplementsOriginPostQuantumEncryptionGetResponse() + ImplementsOriginPostQuantumEncryptionOriginPostQuantumEncryptionGetResponse() } func init() { diff --git a/originpostquantumencryption_test.go b/origin_post_quantum_encryption/originpostquantumencryption_test.go similarity index 82% rename from originpostquantumencryption_test.go rename to origin_post_quantum_encryption/originpostquantumencryption_test.go index ba419d923c1..aca43188bf5 100644 --- a/originpostquantumencryption_test.go +++ b/origin_post_quantum_encryption/originpostquantumencryption_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package origin_post_quantum_encryption_test import ( "context" @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/origin_post_quantum_encryption" ) func TestOriginPostQuantumEncryptionUpdate(t *testing.T) { @@ -27,9 +28,9 @@ func TestOriginPostQuantumEncryptionUpdate(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.OriginPostQuantumEncryption.Update(context.TODO(), cloudflare.OriginPostQuantumEncryptionUpdateParams{ + _, err := client.OriginPostQuantumEncryption.Update(context.TODO(), origin_post_quantum_encryption.OriginPostQuantumEncryptionUpdateParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.OriginPostQuantumEncryptionUpdateParamsValuePreferred), + Value: cloudflare.F(origin_post_quantum_encryption.OriginPostQuantumEncryptionUpdateParamsValuePreferred), }) if err != nil { var apierr *cloudflare.Error @@ -54,7 +55,7 @@ func TestOriginPostQuantumEncryptionGet(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.OriginPostQuantumEncryption.Get(context.TODO(), cloudflare.OriginPostQuantumEncryptionGetParams{ + _, err := client.OriginPostQuantumEncryption.Get(context.TODO(), origin_post_quantum_encryption.OriginPostQuantumEncryptionGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { diff --git a/origin_tls_client_auth/aliases.go b/origin_tls_client_auth/aliases.go new file mode 100644 index 00000000000..f0c651bb018 --- /dev/null +++ b/origin_tls_client_auth/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package origin_tls_client_auth + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/origin_tls_client_auth/hostname.go b/origin_tls_client_auth/hostname.go new file mode 100644 index 00000000000..43bec803d00 --- /dev/null +++ b/origin_tls_client_auth/hostname.go @@ -0,0 +1,378 @@ +// File generated from our OpenAPI spec by Stainless. + +package origin_tls_client_auth + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HostnameService 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 [NewHostnameService] method instead. +type HostnameService struct { + Options []option.RequestOption + Certificates *HostnameCertificateService +} + +// NewHostnameService 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 NewHostnameService(opts ...option.RequestOption) (r *HostnameService) { + r = &HostnameService{} + r.Options = opts + r.Certificates = NewHostnameCertificateService(opts...) + return +} + +// Associate a hostname to a certificate and enable, disable or invalidate the +// association. If disabled, client certificate will not be sent to the hostname +// even if activated at the zone level. 100 maximum associations on a single +// certificate are allowed. Note: Use a null value for parameter _enabled_ to +// invalidate the association. +func (r *HostnameService) Update(ctx context.Context, params HostnameUpdateParams, opts ...option.RequestOption) (res *[]TLSCertificatesAndHostnamesHostnameCertidObject, err error) { + opts = append(r.Options[:], opts...) + var env HostnameUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/origin_tls_client_auth/hostnames", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the Hostname Status for Client Authentication +func (r *HostnameService) Get(ctx context.Context, hostname string, query HostnameGetParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesHostnameCertidObject, err error) { + opts = append(r.Options[:], opts...) + var env HostnameGetResponseEnvelope + path := fmt.Sprintf("zones/%s/origin_tls_client_auth/hostnames/%s", query.ZoneID, hostname) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TLSCertificatesAndHostnamesHostnameCertidObject struct { + // Identifier + CertID string `json:"cert_id"` + // Status of the certificate or the association. + CertStatus TLSCertificatesAndHostnamesHostnameCertidObjectCertStatus `json:"cert_status"` + // The time when the certificate was updated. + CertUpdatedAt time.Time `json:"cert_updated_at" format:"date-time"` + // The time when the certificate was uploaded. + CertUploadedOn time.Time `json:"cert_uploaded_on" format:"date-time"` + // The hostname certificate. + Certificate string `json:"certificate"` + // The time when the certificate was created. + CreatedAt time.Time `json:"created_at" format:"date-time"` + // Indicates whether hostname-level authenticated origin pulls is enabled. A null + // value voids the association. + Enabled bool `json:"enabled,nullable"` + // The date when the certificate expires. + ExpiresOn time.Time `json:"expires_on" format:"date-time"` + // The hostname on the origin for which the client certificate uploaded will be + // used. + Hostname string `json:"hostname"` + // The certificate authority that issued the certificate. + Issuer string `json:"issuer"` + // The serial number on the uploaded certificate. + SerialNumber string `json:"serial_number"` + // The type of hash used for the certificate. + Signature string `json:"signature"` + // Status of the certificate or the association. + Status TLSCertificatesAndHostnamesHostnameCertidObjectStatus `json:"status"` + // The time when the certificate was updated. + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON tlsCertificatesAndHostnamesHostnameCertidObjectJSON `json:"-"` +} + +// tlsCertificatesAndHostnamesHostnameCertidObjectJSON contains the JSON metadata +// for the struct [TLSCertificatesAndHostnamesHostnameCertidObject] +type tlsCertificatesAndHostnamesHostnameCertidObjectJSON struct { + CertID apijson.Field + CertStatus apijson.Field + CertUpdatedAt apijson.Field + CertUploadedOn apijson.Field + Certificate apijson.Field + CreatedAt apijson.Field + Enabled apijson.Field + ExpiresOn apijson.Field + Hostname apijson.Field + Issuer apijson.Field + SerialNumber apijson.Field + Signature apijson.Field + Status apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TLSCertificatesAndHostnamesHostnameCertidObject) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tlsCertificatesAndHostnamesHostnameCertidObjectJSON) RawJSON() string { + return r.raw +} + +// Status of the certificate or the association. +type TLSCertificatesAndHostnamesHostnameCertidObjectCertStatus string + +const ( + TLSCertificatesAndHostnamesHostnameCertidObjectCertStatusInitializing TLSCertificatesAndHostnamesHostnameCertidObjectCertStatus = "initializing" + TLSCertificatesAndHostnamesHostnameCertidObjectCertStatusPendingDeployment TLSCertificatesAndHostnamesHostnameCertidObjectCertStatus = "pending_deployment" + TLSCertificatesAndHostnamesHostnameCertidObjectCertStatusPendingDeletion TLSCertificatesAndHostnamesHostnameCertidObjectCertStatus = "pending_deletion" + TLSCertificatesAndHostnamesHostnameCertidObjectCertStatusActive TLSCertificatesAndHostnamesHostnameCertidObjectCertStatus = "active" + TLSCertificatesAndHostnamesHostnameCertidObjectCertStatusDeleted TLSCertificatesAndHostnamesHostnameCertidObjectCertStatus = "deleted" + TLSCertificatesAndHostnamesHostnameCertidObjectCertStatusDeploymentTimedOut TLSCertificatesAndHostnamesHostnameCertidObjectCertStatus = "deployment_timed_out" + TLSCertificatesAndHostnamesHostnameCertidObjectCertStatusDeletionTimedOut TLSCertificatesAndHostnamesHostnameCertidObjectCertStatus = "deletion_timed_out" +) + +// Status of the certificate or the association. +type TLSCertificatesAndHostnamesHostnameCertidObjectStatus string + +const ( + TLSCertificatesAndHostnamesHostnameCertidObjectStatusInitializing TLSCertificatesAndHostnamesHostnameCertidObjectStatus = "initializing" + TLSCertificatesAndHostnamesHostnameCertidObjectStatusPendingDeployment TLSCertificatesAndHostnamesHostnameCertidObjectStatus = "pending_deployment" + TLSCertificatesAndHostnamesHostnameCertidObjectStatusPendingDeletion TLSCertificatesAndHostnamesHostnameCertidObjectStatus = "pending_deletion" + TLSCertificatesAndHostnamesHostnameCertidObjectStatusActive TLSCertificatesAndHostnamesHostnameCertidObjectStatus = "active" + TLSCertificatesAndHostnamesHostnameCertidObjectStatusDeleted TLSCertificatesAndHostnamesHostnameCertidObjectStatus = "deleted" + TLSCertificatesAndHostnamesHostnameCertidObjectStatusDeploymentTimedOut TLSCertificatesAndHostnamesHostnameCertidObjectStatus = "deployment_timed_out" + TLSCertificatesAndHostnamesHostnameCertidObjectStatusDeletionTimedOut TLSCertificatesAndHostnamesHostnameCertidObjectStatus = "deletion_timed_out" +) + +type HostnameUpdateParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Config param.Field[[]HostnameUpdateParamsConfig] `json:"config,required"` +} + +func (r HostnameUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type HostnameUpdateParamsConfig struct { + // Certificate identifier tag. + CertID param.Field[string] `json:"cert_id"` + // Indicates whether hostname-level authenticated origin pulls is enabled. A null + // value voids the association. + Enabled param.Field[bool] `json:"enabled"` + // The hostname on the origin for which the client certificate uploaded will be + // used. + Hostname param.Field[string] `json:"hostname"` +} + +func (r HostnameUpdateParamsConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type HostnameUpdateResponseEnvelope struct { + Errors []HostnameUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameUpdateResponseEnvelopeMessages `json:"messages,required"` + Result []TLSCertificatesAndHostnamesHostnameCertidObject `json:"result,required,nullable"` + // Whether the API call was successful + Success HostnameUpdateResponseEnvelopeSuccess `json:"success,required"` + ResultInfo HostnameUpdateResponseEnvelopeResultInfo `json:"result_info"` + JSON hostnameUpdateResponseEnvelopeJSON `json:"-"` +} + +// hostnameUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [HostnameUpdateResponseEnvelope] +type hostnameUpdateResponseEnvelopeJSON 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 *HostnameUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [HostnameUpdateResponseEnvelopeErrors] +type hostnameUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [HostnameUpdateResponseEnvelopeMessages] +type hostnameUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameUpdateResponseEnvelopeSuccess bool + +const ( + HostnameUpdateResponseEnvelopeSuccessTrue HostnameUpdateResponseEnvelopeSuccess = true +) + +type HostnameUpdateResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON hostnameUpdateResponseEnvelopeResultInfoJSON `json:"-"` +} + +// hostnameUpdateResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [HostnameUpdateResponseEnvelopeResultInfo] +type hostnameUpdateResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type HostnameGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type HostnameGetResponseEnvelope struct { + Errors []HostnameGetResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameGetResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesHostnameCertidObject `json:"result,required"` + // Whether the API call was successful + Success HostnameGetResponseEnvelopeSuccess `json:"success,required"` + JSON hostnameGetResponseEnvelopeJSON `json:"-"` +} + +// hostnameGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [HostnameGetResponseEnvelope] +type hostnameGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [HostnameGetResponseEnvelopeErrors] +type hostnameGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [HostnameGetResponseEnvelopeMessages] +type hostnameGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameGetResponseEnvelopeSuccess bool + +const ( + HostnameGetResponseEnvelopeSuccessTrue HostnameGetResponseEnvelopeSuccess = true +) diff --git a/origin_tls_client_auth/hostname_test.go b/origin_tls_client_auth/hostname_test.go new file mode 100644 index 00000000000..3d7c3db5258 --- /dev/null +++ b/origin_tls_client_auth/hostname_test.go @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package origin_tls_client_auth_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/origin_tls_client_auth" +) + +func TestHostnameUpdate(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("user@example.com"), + ) + _, err := client.OriginTLSClientAuth.Hostnames.Update(context.TODO(), origin_tls_client_auth.HostnameUpdateParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Config: cloudflare.F([]origin_tls_client_auth.HostnameUpdateParamsConfig{{ + CertID: cloudflare.F("2458ce5a-0c35-4c7f-82c7-8e9487d3ff60"), + Enabled: cloudflare.F(true), + Hostname: cloudflare.F("app.example.com"), + }, { + CertID: cloudflare.F("2458ce5a-0c35-4c7f-82c7-8e9487d3ff60"), + Enabled: cloudflare.F(true), + Hostname: cloudflare.F("app.example.com"), + }, { + CertID: cloudflare.F("2458ce5a-0c35-4c7f-82c7-8e9487d3ff60"), + Enabled: cloudflare.F(true), + Hostname: cloudflare.F("app.example.com"), + }}), + }) + 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 TestHostnameGet(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("user@example.com"), + ) + _, err := client.OriginTLSClientAuth.Hostnames.Get( + context.TODO(), + "app.example.com", + origin_tls_client_auth.HostnameGetParams{ + ZoneID: cloudflare.F("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/origin_tls_client_auth/hostnamecertificate.go b/origin_tls_client_auth/hostnamecertificate.go new file mode 100644 index 00000000000..1d86b3787be --- /dev/null +++ b/origin_tls_client_auth/hostnamecertificate.go @@ -0,0 +1,527 @@ +// File generated from our OpenAPI spec by Stainless. + +package origin_tls_client_auth + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HostnameCertificateService 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 [NewHostnameCertificateService] +// method instead. +type HostnameCertificateService struct { + Options []option.RequestOption +} + +// NewHostnameCertificateService 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 NewHostnameCertificateService(opts ...option.RequestOption) (r *HostnameCertificateService) { + r = &HostnameCertificateService{} + r.Options = opts + return +} + +// Upload a certificate to be used for client authentication on a hostname. 10 +// hostname certificates per zone are allowed. +func (r *HostnameCertificateService) New(ctx context.Context, params HostnameCertificateNewParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesSchemasCertificateObject, err error) { + opts = append(r.Options[:], opts...) + var env HostnameCertificateNewResponseEnvelope + path := fmt.Sprintf("zones/%s/origin_tls_client_auth/hostnames/certificates", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List Certificates +func (r *HostnameCertificateService) List(ctx context.Context, query HostnameCertificateListParams, opts ...option.RequestOption) (res *[]TLSCertificatesAndHostnamesHostnameCertidObject, err error) { + opts = append(r.Options[:], opts...) + var env HostnameCertificateListResponseEnvelope + path := fmt.Sprintf("zones/%s/origin_tls_client_auth/hostnames/certificates", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete Hostname Client Certificate +func (r *HostnameCertificateService) Delete(ctx context.Context, certificateID string, body HostnameCertificateDeleteParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesSchemasCertificateObject, err error) { + opts = append(r.Options[:], opts...) + var env HostnameCertificateDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/origin_tls_client_auth/hostnames/certificates/%s", body.ZoneID, certificateID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the certificate by ID to be used for client authentication on a hostname. +func (r *HostnameCertificateService) Get(ctx context.Context, certificateID string, query HostnameCertificateGetParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesSchemasCertificateObject, err error) { + opts = append(r.Options[:], opts...) + var env HostnameCertificateGetResponseEnvelope + path := fmt.Sprintf("zones/%s/origin_tls_client_auth/hostnames/certificates/%s", query.ZoneID, certificateID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TLSCertificatesAndHostnamesSchemasCertificateObject struct { + // Identifier + ID string `json:"id"` + // The hostname certificate. + Certificate string `json:"certificate"` + // The date when the certificate expires. + ExpiresOn time.Time `json:"expires_on" format:"date-time"` + // The certificate authority that issued the certificate. + Issuer string `json:"issuer"` + // The serial number on the uploaded certificate. + SerialNumber string `json:"serial_number"` + // The type of hash used for the certificate. + Signature string `json:"signature"` + // Status of the certificate or the association. + Status TLSCertificatesAndHostnamesSchemasCertificateObjectStatus `json:"status"` + // The time when the certificate was uploaded. + UploadedOn time.Time `json:"uploaded_on" format:"date-time"` + JSON tlsCertificatesAndHostnamesSchemasCertificateObjectJSON `json:"-"` +} + +// tlsCertificatesAndHostnamesSchemasCertificateObjectJSON contains the JSON +// metadata for the struct [TLSCertificatesAndHostnamesSchemasCertificateObject] +type tlsCertificatesAndHostnamesSchemasCertificateObjectJSON struct { + ID apijson.Field + Certificate apijson.Field + ExpiresOn apijson.Field + Issuer apijson.Field + SerialNumber apijson.Field + Signature apijson.Field + Status apijson.Field + UploadedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TLSCertificatesAndHostnamesSchemasCertificateObject) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tlsCertificatesAndHostnamesSchemasCertificateObjectJSON) RawJSON() string { + return r.raw +} + +// Status of the certificate or the association. +type TLSCertificatesAndHostnamesSchemasCertificateObjectStatus string + +const ( + TLSCertificatesAndHostnamesSchemasCertificateObjectStatusInitializing TLSCertificatesAndHostnamesSchemasCertificateObjectStatus = "initializing" + TLSCertificatesAndHostnamesSchemasCertificateObjectStatusPendingDeployment TLSCertificatesAndHostnamesSchemasCertificateObjectStatus = "pending_deployment" + TLSCertificatesAndHostnamesSchemasCertificateObjectStatusPendingDeletion TLSCertificatesAndHostnamesSchemasCertificateObjectStatus = "pending_deletion" + TLSCertificatesAndHostnamesSchemasCertificateObjectStatusActive TLSCertificatesAndHostnamesSchemasCertificateObjectStatus = "active" + TLSCertificatesAndHostnamesSchemasCertificateObjectStatusDeleted TLSCertificatesAndHostnamesSchemasCertificateObjectStatus = "deleted" + TLSCertificatesAndHostnamesSchemasCertificateObjectStatusDeploymentTimedOut TLSCertificatesAndHostnamesSchemasCertificateObjectStatus = "deployment_timed_out" + TLSCertificatesAndHostnamesSchemasCertificateObjectStatusDeletionTimedOut TLSCertificatesAndHostnamesSchemasCertificateObjectStatus = "deletion_timed_out" +) + +type HostnameCertificateNewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // The hostname certificate. + Certificate param.Field[string] `json:"certificate,required"` + // The hostname certificate's private key. + PrivateKey param.Field[string] `json:"private_key,required"` +} + +func (r HostnameCertificateNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type HostnameCertificateNewResponseEnvelope struct { + Errors []HostnameCertificateNewResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameCertificateNewResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesSchemasCertificateObject `json:"result,required"` + // Whether the API call was successful + Success HostnameCertificateNewResponseEnvelopeSuccess `json:"success,required"` + JSON hostnameCertificateNewResponseEnvelopeJSON `json:"-"` +} + +// hostnameCertificateNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [HostnameCertificateNewResponseEnvelope] +type hostnameCertificateNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameCertificateNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameCertificateNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameCertificateNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameCertificateNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameCertificateNewResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [HostnameCertificateNewResponseEnvelopeErrors] +type hostnameCertificateNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameCertificateNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameCertificateNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameCertificateNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameCertificateNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameCertificateNewResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [HostnameCertificateNewResponseEnvelopeMessages] +type hostnameCertificateNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameCertificateNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameCertificateNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameCertificateNewResponseEnvelopeSuccess bool + +const ( + HostnameCertificateNewResponseEnvelopeSuccessTrue HostnameCertificateNewResponseEnvelopeSuccess = true +) + +type HostnameCertificateListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type HostnameCertificateListResponseEnvelope struct { + Errors []HostnameCertificateListResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameCertificateListResponseEnvelopeMessages `json:"messages,required"` + Result []TLSCertificatesAndHostnamesHostnameCertidObject `json:"result,required,nullable"` + // Whether the API call was successful + Success HostnameCertificateListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo HostnameCertificateListResponseEnvelopeResultInfo `json:"result_info"` + JSON hostnameCertificateListResponseEnvelopeJSON `json:"-"` +} + +// hostnameCertificateListResponseEnvelopeJSON contains the JSON metadata for the +// struct [HostnameCertificateListResponseEnvelope] +type hostnameCertificateListResponseEnvelopeJSON 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 *HostnameCertificateListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameCertificateListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameCertificateListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameCertificateListResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameCertificateListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [HostnameCertificateListResponseEnvelopeErrors] +type hostnameCertificateListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameCertificateListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameCertificateListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameCertificateListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameCertificateListResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameCertificateListResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [HostnameCertificateListResponseEnvelopeMessages] +type hostnameCertificateListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameCertificateListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameCertificateListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameCertificateListResponseEnvelopeSuccess bool + +const ( + HostnameCertificateListResponseEnvelopeSuccessTrue HostnameCertificateListResponseEnvelopeSuccess = true +) + +type HostnameCertificateListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON hostnameCertificateListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// hostnameCertificateListResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [HostnameCertificateListResponseEnvelopeResultInfo] +type hostnameCertificateListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameCertificateListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameCertificateListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type HostnameCertificateDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type HostnameCertificateDeleteResponseEnvelope struct { + Errors []HostnameCertificateDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameCertificateDeleteResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesSchemasCertificateObject `json:"result,required"` + // Whether the API call was successful + Success HostnameCertificateDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON hostnameCertificateDeleteResponseEnvelopeJSON `json:"-"` +} + +// hostnameCertificateDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [HostnameCertificateDeleteResponseEnvelope] +type hostnameCertificateDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameCertificateDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameCertificateDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameCertificateDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameCertificateDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameCertificateDeleteResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [HostnameCertificateDeleteResponseEnvelopeErrors] +type hostnameCertificateDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameCertificateDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameCertificateDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameCertificateDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameCertificateDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameCertificateDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [HostnameCertificateDeleteResponseEnvelopeMessages] +type hostnameCertificateDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameCertificateDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameCertificateDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameCertificateDeleteResponseEnvelopeSuccess bool + +const ( + HostnameCertificateDeleteResponseEnvelopeSuccessTrue HostnameCertificateDeleteResponseEnvelopeSuccess = true +) + +type HostnameCertificateGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type HostnameCertificateGetResponseEnvelope struct { + Errors []HostnameCertificateGetResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameCertificateGetResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesSchemasCertificateObject `json:"result,required"` + // Whether the API call was successful + Success HostnameCertificateGetResponseEnvelopeSuccess `json:"success,required"` + JSON hostnameCertificateGetResponseEnvelopeJSON `json:"-"` +} + +// hostnameCertificateGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [HostnameCertificateGetResponseEnvelope] +type hostnameCertificateGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameCertificateGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameCertificateGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameCertificateGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameCertificateGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameCertificateGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [HostnameCertificateGetResponseEnvelopeErrors] +type hostnameCertificateGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameCertificateGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameCertificateGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameCertificateGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameCertificateGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameCertificateGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [HostnameCertificateGetResponseEnvelopeMessages] +type hostnameCertificateGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameCertificateGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameCertificateGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameCertificateGetResponseEnvelopeSuccess bool + +const ( + HostnameCertificateGetResponseEnvelopeSuccessTrue HostnameCertificateGetResponseEnvelopeSuccess = true +) diff --git a/origin_tls_client_auth/hostnamecertificate_test.go b/origin_tls_client_auth/hostnamecertificate_test.go new file mode 100644 index 00000000000..bf541ffbb62 --- /dev/null +++ b/origin_tls_client_auth/hostnamecertificate_test.go @@ -0,0 +1,129 @@ +// File generated from our OpenAPI spec by Stainless. + +package origin_tls_client_auth_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/origin_tls_client_auth" +) + +func TestHostnameCertificateNew(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("user@example.com"), + ) + _, err := client.OriginTLSClientAuth.Hostnames.Certificates.New(context.TODO(), origin_tls_client_auth.HostnameCertificateNewParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Certificate: cloudflare.F("-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIJAMHAwfXZ5/PWMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\nBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX\naWRnaXRzIFB0eSBMdGQwHhcNMTYwODI0MTY0MzAxWhcNMTYxMTIyMTY0MzAxWjBF\nMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50\nZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\nCgKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmGdtcGbg/1\nCGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKnabIRuGvB\nKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpidtnKX/a+5\n0GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+pyFxIXjbEI\ndZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pEewooaeO2\nizNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABo4GnMIGkMB0GA1UdDgQWBBT/LbE4\n9rWf288N6sJA5BRb6FJIGDB1BgNVHSMEbjBsgBT/LbE49rWf288N6sJA5BRb6FJI\nGKFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNV\nBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAMHAwfXZ5/PWMAwGA1UdEwQF\nMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAHHFwl0tH0quUYZYO0dZYt4R7SJ0pCm2\n2satiyzHl4OnXcHDpekAo7/a09c6Lz6AU83cKy/+x3/djYHXWba7HpEu0dR3ugQP\nMlr4zrhd9xKZ0KZKiYmtJH+ak4OM4L3FbT0owUZPyjLSlhMtJVcoRp5CJsjAMBUG\nSvD8RX+T01wzox/Qb+lnnNnOlaWpqu8eoOenybxKp1a9ULzIVvN/LAcc+14vioFq\n2swRWtmocBAs8QR9n4uvbpiYvS8eYueDCWMM4fvFfBhaDZ3N9IbtySh3SpFdQDhw\nYbjM2rxXiyLGxB4Bol7QTv4zHif7Zt89FReT/NBy4rzaskDJY5L6xmY=\n-----END CERTIFICATE-----\n"), + PrivateKey: cloudflare.F("-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmG\ndtcGbg/1CGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKn\nabIRuGvBKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpid\ntnKX/a+50GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+py\nFxIXjbEIdZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pE\newooaeO2izNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABAoIBACbhTYXBZYKmYPCb\nHBR1IBlCQA2nLGf0qRuJNJZg5iEzXows/6tc8YymZkQE7nolapWsQ+upk2y5Xdp/\naxiuprIs9JzkYK8Ox0r+dlwCG1kSW+UAbX0bQ/qUqlsTvU6muVuMP8vZYHxJ3wmb\n+ufRBKztPTQ/rYWaYQcgC0RWI20HTFBMxlTAyNxYNWzX7RKFkGVVyB9RsAtmcc8g\n+j4OdosbfNoJPS0HeIfNpAznDfHKdxDk2Yc1tV6RHBrC1ynyLE9+TaflIAdo2MVv\nKLMLq51GqYKtgJFIlBRPQqKoyXdz3fGvXrTkf/WY9QNq0J1Vk5ERePZ54mN8iZB7\n9lwy/AkCgYEA6FXzosxswaJ2wQLeoYc7ceaweX/SwTvxHgXzRyJIIT0eJWgx13Wo\n/WA3Iziimsjf6qE+SI/8laxPp2A86VMaIt3Z3mJN/CqSVGw8LK2AQst+OwdPyDMu\niacE8lj/IFGC8mwNUAb9CzGU3JpU4PxxGFjS/eMtGeRXCWkK4NE+G08CgYEA1Kp9\nN2JrVlqUz+gAX+LPmE9OEMAS9WQSQsfCHGogIFDGGcNf7+uwBM7GAaSJIP01zcoe\nVAgWdzXCv3FLhsaZoJ6RyLOLay5phbu1iaTr4UNYm5WtYTzMzqh8l1+MFFDl9xDB\nvULuCIIrglM5MeS/qnSg1uMoH2oVPj9TVst/ir8CgYEAxrI7Ws9Zc4Bt70N1As+U\nlySjaEVZCMkqvHJ6TCuVZFfQoE0r0whdLdRLU2PsLFP+q7qaeZQqgBaNSKeVcDYR\n9B+nY/jOmQoPewPVsp/vQTCnE/R81spu0mp0YI6cIheT1Z9zAy322svcc43JaWB7\nmEbeqyLOP4Z4qSOcmghZBSECgYACvR9Xs0DGn+wCsW4vze/2ei77MD4OQvepPIFX\ndFZtlBy5ADcgE9z0cuVB6CiL8DbdK5kwY9pGNr8HUCI03iHkW6Zs+0L0YmihfEVe\nPG19PSzK9CaDdhD9KFZSbLyVFmWfxOt50H7YRTTiPMgjyFpfi5j2q348yVT0tEQS\nfhRqaQKBgAcWPokmJ7EbYQGeMbS7HC8eWO/RyamlnSffdCdSc7ue3zdVJxpAkQ8W\nqu80pEIF6raIQfAf8MXiiZ7auFOSnHQTXUbhCpvDLKi0Mwq3G8Pl07l+2s6dQG6T\nlv6XTQaMyf6n1yjzL+fzDrH3qXMxHMO/b13EePXpDMpY7HQpoLDi\n-----END RSA PRIVATE KEY-----\n"), + }) + 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 TestHostnameCertificateList(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("user@example.com"), + ) + _, err := client.OriginTLSClientAuth.Hostnames.Certificates.List(context.TODO(), origin_tls_client_auth.HostnameCertificateListParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestHostnameCertificateDelete(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("user@example.com"), + ) + _, err := client.OriginTLSClientAuth.Hostnames.Certificates.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + origin_tls_client_auth.HostnameCertificateDeleteParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestHostnameCertificateGet(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("user@example.com"), + ) + _, err := client.OriginTLSClientAuth.Hostnames.Certificates.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + origin_tls_client_auth.HostnameCertificateGetParams{ + ZoneID: cloudflare.F("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/origintlsclientauth.go b/origin_tls_client_auth/origintlsclientauth.go similarity index 96% rename from origintlsclientauth.go rename to origin_tls_client_auth/origintlsclientauth.go index 13ffd200ac2..593e9f18697 100644 --- a/origintlsclientauth.go +++ b/origin_tls_client_auth/origintlsclientauth.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package origin_tls_client_auth import ( "context" @@ -23,8 +23,8 @@ import ( // method instead. type OriginTLSClientAuthService struct { Options []option.RequestOption - Hostnames *OriginTLSClientAuthHostnameService - Settings *OriginTLSClientAuthSettingService + Hostnames *HostnameService + Settings *SettingService } // NewOriginTLSClientAuthService generates a new service that applies the given @@ -33,8 +33,8 @@ type OriginTLSClientAuthService struct { func NewOriginTLSClientAuthService(opts ...option.RequestOption) (r *OriginTLSClientAuthService) { r = &OriginTLSClientAuthService{} r.Options = opts - r.Hostnames = NewOriginTLSClientAuthHostnameService(opts...) - r.Settings = NewOriginTLSClientAuthSettingService(opts...) + r.Hostnames = NewHostnameService(opts...) + r.Settings = NewSettingService(opts...) return } @@ -94,10 +94,11 @@ func (r *OriginTLSClientAuthService) Get(ctx context.Context, certificateID stri return } -// Union satisfied by [OriginTLSClientAuthNewResponseUnknown] or +// Union satisfied by +// [origin_tls_client_auth.OriginTLSClientAuthNewResponseUnknown] or // [shared.UnionString]. type OriginTLSClientAuthNewResponse interface { - ImplementsOriginTLSClientAuthNewResponse() + ImplementsOriginTLSClientAuthOriginTLSClientAuthNewResponse() } func init() { @@ -142,10 +143,11 @@ func (r originTLSClientAuthListResponseJSON) RawJSON() string { return r.raw } -// Union satisfied by [OriginTLSClientAuthDeleteResponseUnknown] or +// Union satisfied by +// [origin_tls_client_auth.OriginTLSClientAuthDeleteResponseUnknown] or // [shared.UnionString]. type OriginTLSClientAuthDeleteResponse interface { - ImplementsOriginTLSClientAuthDeleteResponse() + ImplementsOriginTLSClientAuthOriginTLSClientAuthDeleteResponse() } func init() { @@ -159,10 +161,11 @@ func init() { ) } -// Union satisfied by [OriginTLSClientAuthGetResponseUnknown] or +// Union satisfied by +// [origin_tls_client_auth.OriginTLSClientAuthGetResponseUnknown] or // [shared.UnionString]. type OriginTLSClientAuthGetResponse interface { - ImplementsOriginTLSClientAuthGetResponse() + ImplementsOriginTLSClientAuthOriginTLSClientAuthGetResponse() } func init() { diff --git a/origintlsclientauth_test.go b/origin_tls_client_auth/origintlsclientauth_test.go similarity index 93% rename from origintlsclientauth_test.go rename to origin_tls_client_auth/origintlsclientauth_test.go index 64b3a948a31..7f866e219ed 100644 --- a/origintlsclientauth_test.go +++ b/origin_tls_client_auth/origintlsclientauth_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package origin_tls_client_auth_test import ( "context" @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/origin_tls_client_auth" ) func TestOriginTLSClientAuthNew(t *testing.T) { @@ -27,7 +28,7 @@ func TestOriginTLSClientAuthNew(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.OriginTLSClientAuth.New(context.TODO(), cloudflare.OriginTLSClientAuthNewParams{ + _, err := client.OriginTLSClientAuth.New(context.TODO(), origin_tls_client_auth.OriginTLSClientAuthNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Certificate: cloudflare.F("-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIJAMHAwfXZ5/PWMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\nBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX\naWRnaXRzIFB0eSBMdGQwHhcNMTYwODI0MTY0MzAxWhcNMTYxMTIyMTY0MzAxWjBF\nMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50\nZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\nCgKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmGdtcGbg/1\nCGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKnabIRuGvB\nKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpidtnKX/a+5\n0GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+pyFxIXjbEI\ndZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pEewooaeO2\nizNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABo4GnMIGkMB0GA1UdDgQWBBT/LbE4\n9rWf288N6sJA5BRb6FJIGDB1BgNVHSMEbjBsgBT/LbE49rWf288N6sJA5BRb6FJI\nGKFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNV\nBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAMHAwfXZ5/PWMAwGA1UdEwQF\nMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAHHFwl0tH0quUYZYO0dZYt4R7SJ0pCm2\n2satiyzHl4OnXcHDpekAo7/a09c6Lz6AU83cKy/+x3/djYHXWba7HpEu0dR3ugQP\nMlr4zrhd9xKZ0KZKiYmtJH+ak4OM4L3FbT0owUZPyjLSlhMtJVcoRp5CJsjAMBUG\nSvD8RX+T01wzox/Qb+lnnNnOlaWpqu8eoOenybxKp1a9ULzIVvN/LAcc+14vioFq\n2swRWtmocBAs8QR9n4uvbpiYvS8eYueDCWMM4fvFfBhaDZ3N9IbtySh3SpFdQDhw\nYbjM2rxXiyLGxB4Bol7QTv4zHif7Zt89FReT/NBy4rzaskDJY5L6xmY=\n-----END CERTIFICATE-----\n"), PrivateKey: cloudflare.F("-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmG\ndtcGbg/1CGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKn\nabIRuGvBKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpid\ntnKX/a+50GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+py\nFxIXjbEIdZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pE\newooaeO2izNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABAoIBACbhTYXBZYKmYPCb\nHBR1IBlCQA2nLGf0qRuJNJZg5iEzXows/6tc8YymZkQE7nolapWsQ+upk2y5Xdp/\naxiuprIs9JzkYK8Ox0r+dlwCG1kSW+UAbX0bQ/qUqlsTvU6muVuMP8vZYHxJ3wmb\n+ufRBKztPTQ/rYWaYQcgC0RWI20HTFBMxlTAyNxYNWzX7RKFkGVVyB9RsAtmcc8g\n+j4OdosbfNoJPS0HeIfNpAznDfHKdxDk2Yc1tV6RHBrC1ynyLE9+TaflIAdo2MVv\nKLMLq51GqYKtgJFIlBRPQqKoyXdz3fGvXrTkf/WY9QNq0J1Vk5ERePZ54mN8iZB7\n9lwy/AkCgYEA6FXzosxswaJ2wQLeoYc7ceaweX/SwTvxHgXzRyJIIT0eJWgx13Wo\n/WA3Iziimsjf6qE+SI/8laxPp2A86VMaIt3Z3mJN/CqSVGw8LK2AQst+OwdPyDMu\niacE8lj/IFGC8mwNUAb9CzGU3JpU4PxxGFjS/eMtGeRXCWkK4NE+G08CgYEA1Kp9\nN2JrVlqUz+gAX+LPmE9OEMAS9WQSQsfCHGogIFDGGcNf7+uwBM7GAaSJIP01zcoe\nVAgWdzXCv3FLhsaZoJ6RyLOLay5phbu1iaTr4UNYm5WtYTzMzqh8l1+MFFDl9xDB\nvULuCIIrglM5MeS/qnSg1uMoH2oVPj9TVst/ir8CgYEAxrI7Ws9Zc4Bt70N1As+U\nlySjaEVZCMkqvHJ6TCuVZFfQoE0r0whdLdRLU2PsLFP+q7qaeZQqgBaNSKeVcDYR\n9B+nY/jOmQoPewPVsp/vQTCnE/R81spu0mp0YI6cIheT1Z9zAy322svcc43JaWB7\nmEbeqyLOP4Z4qSOcmghZBSECgYACvR9Xs0DGn+wCsW4vze/2ei77MD4OQvepPIFX\ndFZtlBy5ADcgE9z0cuVB6CiL8DbdK5kwY9pGNr8HUCI03iHkW6Zs+0L0YmihfEVe\nPG19PSzK9CaDdhD9KFZSbLyVFmWfxOt50H7YRTTiPMgjyFpfi5j2q348yVT0tEQS\nfhRqaQKBgAcWPokmJ7EbYQGeMbS7HC8eWO/RyamlnSffdCdSc7ue3zdVJxpAkQ8W\nqu80pEIF6raIQfAf8MXiiZ7auFOSnHQTXUbhCpvDLKi0Mwq3G8Pl07l+2s6dQG6T\nlv6XTQaMyf6n1yjzL+fzDrH3qXMxHMO/b13EePXpDMpY7HQpoLDi\n-----END RSA PRIVATE KEY-----\n"), @@ -55,7 +56,7 @@ func TestOriginTLSClientAuthList(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.OriginTLSClientAuth.List(context.TODO(), cloudflare.OriginTLSClientAuthListParams{ + _, err := client.OriginTLSClientAuth.List(context.TODO(), origin_tls_client_auth.OriginTLSClientAuthListParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { @@ -84,7 +85,7 @@ func TestOriginTLSClientAuthDelete(t *testing.T) { _, err := client.OriginTLSClientAuth.Delete( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.OriginTLSClientAuthDeleteParams{ + origin_tls_client_auth.OriginTLSClientAuthDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) @@ -114,7 +115,7 @@ func TestOriginTLSClientAuthGet(t *testing.T) { _, err := client.OriginTLSClientAuth.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.OriginTLSClientAuthGetParams{ + origin_tls_client_auth.OriginTLSClientAuthGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) diff --git a/origin_tls_client_auth/setting.go b/origin_tls_client_auth/setting.go new file mode 100644 index 00000000000..cc04ac7ce48 --- /dev/null +++ b/origin_tls_client_auth/setting.go @@ -0,0 +1,282 @@ +// File generated from our OpenAPI spec by Stainless. + +package origin_tls_client_auth + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingService 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 [NewSettingService] method instead. +type SettingService struct { + Options []option.RequestOption +} + +// NewSettingService 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 NewSettingService(opts ...option.RequestOption) (r *SettingService) { + r = &SettingService{} + r.Options = opts + return +} + +// Enable or disable zone-level authenticated origin pulls. 'enabled' should be set +// true either before/after the certificate is uploaded to see the certificate in +// use. +func (r *SettingService) Update(ctx context.Context, params SettingUpdateParams, opts ...option.RequestOption) (res *SettingUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env SettingUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/origin_tls_client_auth/settings", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get whether zone-level authenticated origin pulls is enabled or not. It is false +// by default. +func (r *SettingService) Get(ctx context.Context, query SettingGetParams, opts ...option.RequestOption) (res *SettingGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env SettingGetResponseEnvelope + path := fmt.Sprintf("zones/%s/origin_tls_client_auth/settings", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type SettingUpdateResponse struct { + // Indicates whether zone-level authenticated origin pulls is enabled. + Enabled bool `json:"enabled"` + JSON settingUpdateResponseJSON `json:"-"` +} + +// settingUpdateResponseJSON contains the JSON metadata for the struct +// [SettingUpdateResponse] +type settingUpdateResponseJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingUpdateResponseJSON) RawJSON() string { + return r.raw +} + +type SettingGetResponse struct { + // Indicates whether zone-level authenticated origin pulls is enabled. + Enabled bool `json:"enabled"` + JSON settingGetResponseJSON `json:"-"` +} + +// settingGetResponseJSON contains the JSON metadata for the struct +// [SettingGetResponse] +type settingGetResponseJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingGetResponseJSON) RawJSON() string { + return r.raw +} + +type SettingUpdateParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Indicates whether zone-level authenticated origin pulls is enabled. + Enabled param.Field[bool] `json:"enabled,required"` +} + +func (r SettingUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingUpdateResponseEnvelope struct { + Errors []SettingUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingUpdateResponseEnvelopeMessages `json:"messages,required"` + Result SettingUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success SettingUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON settingUpdateResponseEnvelopeJSON `json:"-"` +} + +// settingUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingUpdateResponseEnvelope] +type settingUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingUpdateResponseEnvelopeErrors] +type settingUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingUpdateResponseEnvelopeMessages] +type settingUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SettingUpdateResponseEnvelopeSuccess bool + +const ( + SettingUpdateResponseEnvelopeSuccessTrue SettingUpdateResponseEnvelopeSuccess = true +) + +type SettingGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingGetResponseEnvelope struct { + Errors []SettingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingGetResponseEnvelopeMessages `json:"messages,required"` + Result SettingGetResponse `json:"result,required"` + // Whether the API call was successful + Success SettingGetResponseEnvelopeSuccess `json:"success,required"` + JSON settingGetResponseEnvelopeJSON `json:"-"` +} + +// settingGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingGetResponseEnvelope] +type settingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [SettingGetResponseEnvelopeErrors] +type settingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [SettingGetResponseEnvelopeMessages] +type settingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SettingGetResponseEnvelopeSuccess bool + +const ( + SettingGetResponseEnvelopeSuccessTrue SettingGetResponseEnvelopeSuccess = true +) diff --git a/origin_tls_client_auth/setting_test.go b/origin_tls_client_auth/setting_test.go new file mode 100644 index 00000000000..2ab7b0ba56a --- /dev/null +++ b/origin_tls_client_auth/setting_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package origin_tls_client_auth_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/origin_tls_client_auth" +) + +func TestSettingUpdate(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("user@example.com"), + ) + _, err := client.OriginTLSClientAuth.Settings.Update(context.TODO(), origin_tls_client_auth.SettingUpdateParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Enabled: cloudflare.F(true), + }) + 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 TestSettingGet(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("user@example.com"), + ) + _, err := client.OriginTLSClientAuth.Settings.Get(context.TODO(), origin_tls_client_auth.SettingGetParams{ + ZoneID: cloudflare.F("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/origintlsclientauthhostname.go b/origintlsclientauthhostname.go deleted file mode 100644 index c66c53d78b4..00000000000 --- a/origintlsclientauthhostname.go +++ /dev/null @@ -1,421 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// OriginTLSClientAuthHostnameService 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 -// [NewOriginTLSClientAuthHostnameService] method instead. -type OriginTLSClientAuthHostnameService struct { - Options []option.RequestOption - Certificates *OriginTLSClientAuthHostnameCertificateService -} - -// NewOriginTLSClientAuthHostnameService 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 NewOriginTLSClientAuthHostnameService(opts ...option.RequestOption) (r *OriginTLSClientAuthHostnameService) { - r = &OriginTLSClientAuthHostnameService{} - r.Options = opts - r.Certificates = NewOriginTLSClientAuthHostnameCertificateService(opts...) - return -} - -// Associate a hostname to a certificate and enable, disable or invalidate the -// association. If disabled, client certificate will not be sent to the hostname -// even if activated at the zone level. 100 maximum associations on a single -// certificate are allowed. Note: Use a null value for parameter _enabled_ to -// invalidate the association. -func (r *OriginTLSClientAuthHostnameService) Update(ctx context.Context, params OriginTLSClientAuthHostnameUpdateParams, opts ...option.RequestOption) (res *[]OriginTLSClientAuthHostnameUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env OriginTLSClientAuthHostnameUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/origin_tls_client_auth/hostnames", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the Hostname Status for Client Authentication -func (r *OriginTLSClientAuthHostnameService) Get(ctx context.Context, hostname string, query OriginTLSClientAuthHostnameGetParams, opts ...option.RequestOption) (res *OriginTLSClientAuthHostnameGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env OriginTLSClientAuthHostnameGetResponseEnvelope - path := fmt.Sprintf("zones/%s/origin_tls_client_auth/hostnames/%s", query.ZoneID, hostname) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type OriginTLSClientAuthHostnameUpdateResponse struct { - // Identifier - ID string `json:"id"` - // Identifier - CertID string `json:"cert_id"` - // The hostname certificate. - Certificate string `json:"certificate"` - // Indicates whether hostname-level authenticated origin pulls is enabled. A null - // value voids the association. - Enabled bool `json:"enabled,nullable"` - // The hostname on the origin for which the client certificate uploaded will be - // used. - Hostname string `json:"hostname"` - // The hostname certificate's private key. - PrivateKey string `json:"private_key"` - JSON originTLSClientAuthHostnameUpdateResponseJSON `json:"-"` -} - -// originTLSClientAuthHostnameUpdateResponseJSON contains the JSON metadata for the -// struct [OriginTLSClientAuthHostnameUpdateResponse] -type originTLSClientAuthHostnameUpdateResponseJSON struct { - ID apijson.Field - CertID apijson.Field - Certificate apijson.Field - Enabled apijson.Field - Hostname apijson.Field - PrivateKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthHostnameGetResponse struct { - // Identifier - CertID string `json:"cert_id"` - // Status of the certificate or the association. - CertStatus OriginTLSClientAuthHostnameGetResponseCertStatus `json:"cert_status"` - // The time when the certificate was updated. - CertUpdatedAt time.Time `json:"cert_updated_at" format:"date-time"` - // The time when the certificate was uploaded. - CertUploadedOn time.Time `json:"cert_uploaded_on" format:"date-time"` - // The hostname certificate. - Certificate string `json:"certificate"` - // The time when the certificate was created. - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Indicates whether hostname-level authenticated origin pulls is enabled. A null - // value voids the association. - Enabled bool `json:"enabled,nullable"` - // The date when the certificate expires. - ExpiresOn time.Time `json:"expires_on" format:"date-time"` - // The hostname on the origin for which the client certificate uploaded will be - // used. - Hostname string `json:"hostname"` - // The certificate authority that issued the certificate. - Issuer string `json:"issuer"` - // The serial number on the uploaded certificate. - SerialNumber string `json:"serial_number"` - // The type of hash used for the certificate. - Signature string `json:"signature"` - // Status of the certificate or the association. - Status OriginTLSClientAuthHostnameGetResponseStatus `json:"status"` - // The time when the certificate was updated. - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON originTLSClientAuthHostnameGetResponseJSON `json:"-"` -} - -// originTLSClientAuthHostnameGetResponseJSON contains the JSON metadata for the -// struct [OriginTLSClientAuthHostnameGetResponse] -type originTLSClientAuthHostnameGetResponseJSON struct { - CertID apijson.Field - CertStatus apijson.Field - CertUpdatedAt apijson.Field - CertUploadedOn apijson.Field - Certificate apijson.Field - CreatedAt apijson.Field - Enabled apijson.Field - ExpiresOn apijson.Field - Hostname apijson.Field - Issuer apijson.Field - SerialNumber apijson.Field - Signature apijson.Field - Status apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameGetResponseJSON) RawJSON() string { - return r.raw -} - -// Status of the certificate or the association. -type OriginTLSClientAuthHostnameGetResponseCertStatus string - -const ( - OriginTLSClientAuthHostnameGetResponseCertStatusInitializing OriginTLSClientAuthHostnameGetResponseCertStatus = "initializing" - OriginTLSClientAuthHostnameGetResponseCertStatusPendingDeployment OriginTLSClientAuthHostnameGetResponseCertStatus = "pending_deployment" - OriginTLSClientAuthHostnameGetResponseCertStatusPendingDeletion OriginTLSClientAuthHostnameGetResponseCertStatus = "pending_deletion" - OriginTLSClientAuthHostnameGetResponseCertStatusActive OriginTLSClientAuthHostnameGetResponseCertStatus = "active" - OriginTLSClientAuthHostnameGetResponseCertStatusDeleted OriginTLSClientAuthHostnameGetResponseCertStatus = "deleted" - OriginTLSClientAuthHostnameGetResponseCertStatusDeploymentTimedOut OriginTLSClientAuthHostnameGetResponseCertStatus = "deployment_timed_out" - OriginTLSClientAuthHostnameGetResponseCertStatusDeletionTimedOut OriginTLSClientAuthHostnameGetResponseCertStatus = "deletion_timed_out" -) - -// Status of the certificate or the association. -type OriginTLSClientAuthHostnameGetResponseStatus string - -const ( - OriginTLSClientAuthHostnameGetResponseStatusInitializing OriginTLSClientAuthHostnameGetResponseStatus = "initializing" - OriginTLSClientAuthHostnameGetResponseStatusPendingDeployment OriginTLSClientAuthHostnameGetResponseStatus = "pending_deployment" - OriginTLSClientAuthHostnameGetResponseStatusPendingDeletion OriginTLSClientAuthHostnameGetResponseStatus = "pending_deletion" - OriginTLSClientAuthHostnameGetResponseStatusActive OriginTLSClientAuthHostnameGetResponseStatus = "active" - OriginTLSClientAuthHostnameGetResponseStatusDeleted OriginTLSClientAuthHostnameGetResponseStatus = "deleted" - OriginTLSClientAuthHostnameGetResponseStatusDeploymentTimedOut OriginTLSClientAuthHostnameGetResponseStatus = "deployment_timed_out" - OriginTLSClientAuthHostnameGetResponseStatusDeletionTimedOut OriginTLSClientAuthHostnameGetResponseStatus = "deletion_timed_out" -) - -type OriginTLSClientAuthHostnameUpdateParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Config param.Field[[]OriginTLSClientAuthHostnameUpdateParamsConfig] `json:"config,required"` -} - -func (r OriginTLSClientAuthHostnameUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type OriginTLSClientAuthHostnameUpdateParamsConfig struct { - // Certificate identifier tag. - CertID param.Field[string] `json:"cert_id"` - // Indicates whether hostname-level authenticated origin pulls is enabled. A null - // value voids the association. - Enabled param.Field[bool] `json:"enabled"` - // The hostname on the origin for which the client certificate uploaded will be - // used. - Hostname param.Field[string] `json:"hostname"` -} - -func (r OriginTLSClientAuthHostnameUpdateParamsConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type OriginTLSClientAuthHostnameUpdateResponseEnvelope struct { - Errors []OriginTLSClientAuthHostnameUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []OriginTLSClientAuthHostnameUpdateResponseEnvelopeMessages `json:"messages,required"` - Result []OriginTLSClientAuthHostnameUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success OriginTLSClientAuthHostnameUpdateResponseEnvelopeSuccess `json:"success,required"` - ResultInfo OriginTLSClientAuthHostnameUpdateResponseEnvelopeResultInfo `json:"result_info"` - JSON originTLSClientAuthHostnameUpdateResponseEnvelopeJSON `json:"-"` -} - -// originTLSClientAuthHostnameUpdateResponseEnvelopeJSON contains the JSON metadata -// for the struct [OriginTLSClientAuthHostnameUpdateResponseEnvelope] -type originTLSClientAuthHostnameUpdateResponseEnvelopeJSON 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 *OriginTLSClientAuthHostnameUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthHostnameUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthHostnameUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// originTLSClientAuthHostnameUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [OriginTLSClientAuthHostnameUpdateResponseEnvelopeErrors] -type originTLSClientAuthHostnameUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthHostnameUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthHostnameUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// originTLSClientAuthHostnameUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [OriginTLSClientAuthHostnameUpdateResponseEnvelopeMessages] -type originTLSClientAuthHostnameUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type OriginTLSClientAuthHostnameUpdateResponseEnvelopeSuccess bool - -const ( - OriginTLSClientAuthHostnameUpdateResponseEnvelopeSuccessTrue OriginTLSClientAuthHostnameUpdateResponseEnvelopeSuccess = true -) - -type OriginTLSClientAuthHostnameUpdateResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON originTLSClientAuthHostnameUpdateResponseEnvelopeResultInfoJSON `json:"-"` -} - -// originTLSClientAuthHostnameUpdateResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [OriginTLSClientAuthHostnameUpdateResponseEnvelopeResultInfo] -type originTLSClientAuthHostnameUpdateResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthHostnameGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type OriginTLSClientAuthHostnameGetResponseEnvelope struct { - Errors []OriginTLSClientAuthHostnameGetResponseEnvelopeErrors `json:"errors,required"` - Messages []OriginTLSClientAuthHostnameGetResponseEnvelopeMessages `json:"messages,required"` - Result OriginTLSClientAuthHostnameGetResponse `json:"result,required"` - // Whether the API call was successful - Success OriginTLSClientAuthHostnameGetResponseEnvelopeSuccess `json:"success,required"` - JSON originTLSClientAuthHostnameGetResponseEnvelopeJSON `json:"-"` -} - -// originTLSClientAuthHostnameGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [OriginTLSClientAuthHostnameGetResponseEnvelope] -type originTLSClientAuthHostnameGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthHostnameGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthHostnameGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// originTLSClientAuthHostnameGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [OriginTLSClientAuthHostnameGetResponseEnvelopeErrors] -type originTLSClientAuthHostnameGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthHostnameGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthHostnameGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// originTLSClientAuthHostnameGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [OriginTLSClientAuthHostnameGetResponseEnvelopeMessages] -type originTLSClientAuthHostnameGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type OriginTLSClientAuthHostnameGetResponseEnvelopeSuccess bool - -const ( - OriginTLSClientAuthHostnameGetResponseEnvelopeSuccessTrue OriginTLSClientAuthHostnameGetResponseEnvelopeSuccess = true -) diff --git a/origintlsclientauthhostname_test.go b/origintlsclientauthhostname_test.go deleted file mode 100644 index cf9001ae8b7..00000000000 --- a/origintlsclientauthhostname_test.go +++ /dev/null @@ -1,83 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestOriginTLSClientAuthHostnameUpdate(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("user@example.com"), - ) - _, err := client.OriginTLSClientAuth.Hostnames.Update(context.TODO(), cloudflare.OriginTLSClientAuthHostnameUpdateParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Config: cloudflare.F([]cloudflare.OriginTLSClientAuthHostnameUpdateParamsConfig{{ - CertID: cloudflare.F("2458ce5a-0c35-4c7f-82c7-8e9487d3ff60"), - Enabled: cloudflare.F(true), - Hostname: cloudflare.F("app.example.com"), - }, { - CertID: cloudflare.F("2458ce5a-0c35-4c7f-82c7-8e9487d3ff60"), - Enabled: cloudflare.F(true), - Hostname: cloudflare.F("app.example.com"), - }, { - CertID: cloudflare.F("2458ce5a-0c35-4c7f-82c7-8e9487d3ff60"), - Enabled: cloudflare.F(true), - Hostname: cloudflare.F("app.example.com"), - }}), - }) - 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 TestOriginTLSClientAuthHostnameGet(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("user@example.com"), - ) - _, err := client.OriginTLSClientAuth.Hostnames.Get( - context.TODO(), - "app.example.com", - cloudflare.OriginTLSClientAuthHostnameGetParams{ - ZoneID: cloudflare.F("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/origintlsclientauthhostnamecertificate.go b/origintlsclientauthhostnamecertificate.go deleted file mode 100644 index d5c3f434c5c..00000000000 --- a/origintlsclientauthhostnamecertificate.go +++ /dev/null @@ -1,692 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// OriginTLSClientAuthHostnameCertificateService 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 [NewOriginTLSClientAuthHostnameCertificateService] method instead. -type OriginTLSClientAuthHostnameCertificateService struct { - Options []option.RequestOption -} - -// NewOriginTLSClientAuthHostnameCertificateService 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 NewOriginTLSClientAuthHostnameCertificateService(opts ...option.RequestOption) (r *OriginTLSClientAuthHostnameCertificateService) { - r = &OriginTLSClientAuthHostnameCertificateService{} - r.Options = opts - return -} - -// Upload a certificate to be used for client authentication on a hostname. 10 -// hostname certificates per zone are allowed. -func (r *OriginTLSClientAuthHostnameCertificateService) New(ctx context.Context, params OriginTLSClientAuthHostnameCertificateNewParams, opts ...option.RequestOption) (res *OriginTLSClientAuthHostnameCertificateNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env OriginTLSClientAuthHostnameCertificateNewResponseEnvelope - path := fmt.Sprintf("zones/%s/origin_tls_client_auth/hostnames/certificates", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List Certificates -func (r *OriginTLSClientAuthHostnameCertificateService) List(ctx context.Context, query OriginTLSClientAuthHostnameCertificateListParams, opts ...option.RequestOption) (res *[]OriginTLSClientAuthHostnameCertificateListResponse, err error) { - opts = append(r.Options[:], opts...) - var env OriginTLSClientAuthHostnameCertificateListResponseEnvelope - path := fmt.Sprintf("zones/%s/origin_tls_client_auth/hostnames/certificates", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete Hostname Client Certificate -func (r *OriginTLSClientAuthHostnameCertificateService) Delete(ctx context.Context, certificateID string, body OriginTLSClientAuthHostnameCertificateDeleteParams, opts ...option.RequestOption) (res *OriginTLSClientAuthHostnameCertificateDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env OriginTLSClientAuthHostnameCertificateDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/origin_tls_client_auth/hostnames/certificates/%s", body.ZoneID, certificateID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the certificate by ID to be used for client authentication on a hostname. -func (r *OriginTLSClientAuthHostnameCertificateService) Get(ctx context.Context, certificateID string, query OriginTLSClientAuthHostnameCertificateGetParams, opts ...option.RequestOption) (res *OriginTLSClientAuthHostnameCertificateGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env OriginTLSClientAuthHostnameCertificateGetResponseEnvelope - path := fmt.Sprintf("zones/%s/origin_tls_client_auth/hostnames/certificates/%s", query.ZoneID, certificateID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type OriginTLSClientAuthHostnameCertificateNewResponse struct { - // Identifier - ID string `json:"id"` - // The hostname certificate. - Certificate string `json:"certificate"` - // The date when the certificate expires. - ExpiresOn time.Time `json:"expires_on" format:"date-time"` - // The certificate authority that issued the certificate. - Issuer string `json:"issuer"` - // The serial number on the uploaded certificate. - SerialNumber string `json:"serial_number"` - // The type of hash used for the certificate. - Signature string `json:"signature"` - // Status of the certificate or the association. - Status OriginTLSClientAuthHostnameCertificateNewResponseStatus `json:"status"` - // The time when the certificate was uploaded. - UploadedOn time.Time `json:"uploaded_on" format:"date-time"` - JSON originTLSClientAuthHostnameCertificateNewResponseJSON `json:"-"` -} - -// originTLSClientAuthHostnameCertificateNewResponseJSON contains the JSON metadata -// for the struct [OriginTLSClientAuthHostnameCertificateNewResponse] -type originTLSClientAuthHostnameCertificateNewResponseJSON struct { - ID apijson.Field - Certificate apijson.Field - ExpiresOn apijson.Field - Issuer apijson.Field - SerialNumber apijson.Field - Signature apijson.Field - Status apijson.Field - UploadedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameCertificateNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameCertificateNewResponseJSON) RawJSON() string { - return r.raw -} - -// Status of the certificate or the association. -type OriginTLSClientAuthHostnameCertificateNewResponseStatus string - -const ( - OriginTLSClientAuthHostnameCertificateNewResponseStatusInitializing OriginTLSClientAuthHostnameCertificateNewResponseStatus = "initializing" - OriginTLSClientAuthHostnameCertificateNewResponseStatusPendingDeployment OriginTLSClientAuthHostnameCertificateNewResponseStatus = "pending_deployment" - OriginTLSClientAuthHostnameCertificateNewResponseStatusPendingDeletion OriginTLSClientAuthHostnameCertificateNewResponseStatus = "pending_deletion" - OriginTLSClientAuthHostnameCertificateNewResponseStatusActive OriginTLSClientAuthHostnameCertificateNewResponseStatus = "active" - OriginTLSClientAuthHostnameCertificateNewResponseStatusDeleted OriginTLSClientAuthHostnameCertificateNewResponseStatus = "deleted" - OriginTLSClientAuthHostnameCertificateNewResponseStatusDeploymentTimedOut OriginTLSClientAuthHostnameCertificateNewResponseStatus = "deployment_timed_out" - OriginTLSClientAuthHostnameCertificateNewResponseStatusDeletionTimedOut OriginTLSClientAuthHostnameCertificateNewResponseStatus = "deletion_timed_out" -) - -type OriginTLSClientAuthHostnameCertificateListResponse struct { - // Identifier - ID string `json:"id"` - // Identifier - CertID string `json:"cert_id"` - // The hostname certificate. - Certificate string `json:"certificate"` - // Indicates whether hostname-level authenticated origin pulls is enabled. A null - // value voids the association. - Enabled bool `json:"enabled,nullable"` - // The hostname on the origin for which the client certificate uploaded will be - // used. - Hostname string `json:"hostname"` - // The hostname certificate's private key. - PrivateKey string `json:"private_key"` - JSON originTLSClientAuthHostnameCertificateListResponseJSON `json:"-"` -} - -// originTLSClientAuthHostnameCertificateListResponseJSON contains the JSON -// metadata for the struct [OriginTLSClientAuthHostnameCertificateListResponse] -type originTLSClientAuthHostnameCertificateListResponseJSON struct { - ID apijson.Field - CertID apijson.Field - Certificate apijson.Field - Enabled apijson.Field - Hostname apijson.Field - PrivateKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameCertificateListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameCertificateListResponseJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthHostnameCertificateDeleteResponse struct { - // Identifier - ID string `json:"id"` - // The hostname certificate. - Certificate string `json:"certificate"` - // The date when the certificate expires. - ExpiresOn time.Time `json:"expires_on" format:"date-time"` - // The certificate authority that issued the certificate. - Issuer string `json:"issuer"` - // The serial number on the uploaded certificate. - SerialNumber string `json:"serial_number"` - // The type of hash used for the certificate. - Signature string `json:"signature"` - // Status of the certificate or the association. - Status OriginTLSClientAuthHostnameCertificateDeleteResponseStatus `json:"status"` - // The time when the certificate was uploaded. - UploadedOn time.Time `json:"uploaded_on" format:"date-time"` - JSON originTLSClientAuthHostnameCertificateDeleteResponseJSON `json:"-"` -} - -// originTLSClientAuthHostnameCertificateDeleteResponseJSON contains the JSON -// metadata for the struct [OriginTLSClientAuthHostnameCertificateDeleteResponse] -type originTLSClientAuthHostnameCertificateDeleteResponseJSON struct { - ID apijson.Field - Certificate apijson.Field - ExpiresOn apijson.Field - Issuer apijson.Field - SerialNumber apijson.Field - Signature apijson.Field - Status apijson.Field - UploadedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameCertificateDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameCertificateDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// Status of the certificate or the association. -type OriginTLSClientAuthHostnameCertificateDeleteResponseStatus string - -const ( - OriginTLSClientAuthHostnameCertificateDeleteResponseStatusInitializing OriginTLSClientAuthHostnameCertificateDeleteResponseStatus = "initializing" - OriginTLSClientAuthHostnameCertificateDeleteResponseStatusPendingDeployment OriginTLSClientAuthHostnameCertificateDeleteResponseStatus = "pending_deployment" - OriginTLSClientAuthHostnameCertificateDeleteResponseStatusPendingDeletion OriginTLSClientAuthHostnameCertificateDeleteResponseStatus = "pending_deletion" - OriginTLSClientAuthHostnameCertificateDeleteResponseStatusActive OriginTLSClientAuthHostnameCertificateDeleteResponseStatus = "active" - OriginTLSClientAuthHostnameCertificateDeleteResponseStatusDeleted OriginTLSClientAuthHostnameCertificateDeleteResponseStatus = "deleted" - OriginTLSClientAuthHostnameCertificateDeleteResponseStatusDeploymentTimedOut OriginTLSClientAuthHostnameCertificateDeleteResponseStatus = "deployment_timed_out" - OriginTLSClientAuthHostnameCertificateDeleteResponseStatusDeletionTimedOut OriginTLSClientAuthHostnameCertificateDeleteResponseStatus = "deletion_timed_out" -) - -type OriginTLSClientAuthHostnameCertificateGetResponse struct { - // Identifier - ID string `json:"id"` - // The hostname certificate. - Certificate string `json:"certificate"` - // The date when the certificate expires. - ExpiresOn time.Time `json:"expires_on" format:"date-time"` - // The certificate authority that issued the certificate. - Issuer string `json:"issuer"` - // The serial number on the uploaded certificate. - SerialNumber string `json:"serial_number"` - // The type of hash used for the certificate. - Signature string `json:"signature"` - // Status of the certificate or the association. - Status OriginTLSClientAuthHostnameCertificateGetResponseStatus `json:"status"` - // The time when the certificate was uploaded. - UploadedOn time.Time `json:"uploaded_on" format:"date-time"` - JSON originTLSClientAuthHostnameCertificateGetResponseJSON `json:"-"` -} - -// originTLSClientAuthHostnameCertificateGetResponseJSON contains the JSON metadata -// for the struct [OriginTLSClientAuthHostnameCertificateGetResponse] -type originTLSClientAuthHostnameCertificateGetResponseJSON struct { - ID apijson.Field - Certificate apijson.Field - ExpiresOn apijson.Field - Issuer apijson.Field - SerialNumber apijson.Field - Signature apijson.Field - Status apijson.Field - UploadedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameCertificateGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameCertificateGetResponseJSON) RawJSON() string { - return r.raw -} - -// Status of the certificate or the association. -type OriginTLSClientAuthHostnameCertificateGetResponseStatus string - -const ( - OriginTLSClientAuthHostnameCertificateGetResponseStatusInitializing OriginTLSClientAuthHostnameCertificateGetResponseStatus = "initializing" - OriginTLSClientAuthHostnameCertificateGetResponseStatusPendingDeployment OriginTLSClientAuthHostnameCertificateGetResponseStatus = "pending_deployment" - OriginTLSClientAuthHostnameCertificateGetResponseStatusPendingDeletion OriginTLSClientAuthHostnameCertificateGetResponseStatus = "pending_deletion" - OriginTLSClientAuthHostnameCertificateGetResponseStatusActive OriginTLSClientAuthHostnameCertificateGetResponseStatus = "active" - OriginTLSClientAuthHostnameCertificateGetResponseStatusDeleted OriginTLSClientAuthHostnameCertificateGetResponseStatus = "deleted" - OriginTLSClientAuthHostnameCertificateGetResponseStatusDeploymentTimedOut OriginTLSClientAuthHostnameCertificateGetResponseStatus = "deployment_timed_out" - OriginTLSClientAuthHostnameCertificateGetResponseStatusDeletionTimedOut OriginTLSClientAuthHostnameCertificateGetResponseStatus = "deletion_timed_out" -) - -type OriginTLSClientAuthHostnameCertificateNewParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // The hostname certificate. - Certificate param.Field[string] `json:"certificate,required"` - // The hostname certificate's private key. - PrivateKey param.Field[string] `json:"private_key,required"` -} - -func (r OriginTLSClientAuthHostnameCertificateNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type OriginTLSClientAuthHostnameCertificateNewResponseEnvelope struct { - Errors []OriginTLSClientAuthHostnameCertificateNewResponseEnvelopeErrors `json:"errors,required"` - Messages []OriginTLSClientAuthHostnameCertificateNewResponseEnvelopeMessages `json:"messages,required"` - Result OriginTLSClientAuthHostnameCertificateNewResponse `json:"result,required"` - // Whether the API call was successful - Success OriginTLSClientAuthHostnameCertificateNewResponseEnvelopeSuccess `json:"success,required"` - JSON originTLSClientAuthHostnameCertificateNewResponseEnvelopeJSON `json:"-"` -} - -// originTLSClientAuthHostnameCertificateNewResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [OriginTLSClientAuthHostnameCertificateNewResponseEnvelope] -type originTLSClientAuthHostnameCertificateNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameCertificateNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameCertificateNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthHostnameCertificateNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthHostnameCertificateNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// originTLSClientAuthHostnameCertificateNewResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [OriginTLSClientAuthHostnameCertificateNewResponseEnvelopeErrors] -type originTLSClientAuthHostnameCertificateNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameCertificateNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameCertificateNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthHostnameCertificateNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthHostnameCertificateNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// originTLSClientAuthHostnameCertificateNewResponseEnvelopeMessagesJSON contains -// the JSON metadata for the struct -// [OriginTLSClientAuthHostnameCertificateNewResponseEnvelopeMessages] -type originTLSClientAuthHostnameCertificateNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameCertificateNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameCertificateNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type OriginTLSClientAuthHostnameCertificateNewResponseEnvelopeSuccess bool - -const ( - OriginTLSClientAuthHostnameCertificateNewResponseEnvelopeSuccessTrue OriginTLSClientAuthHostnameCertificateNewResponseEnvelopeSuccess = true -) - -type OriginTLSClientAuthHostnameCertificateListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type OriginTLSClientAuthHostnameCertificateListResponseEnvelope struct { - Errors []OriginTLSClientAuthHostnameCertificateListResponseEnvelopeErrors `json:"errors,required"` - Messages []OriginTLSClientAuthHostnameCertificateListResponseEnvelopeMessages `json:"messages,required"` - Result []OriginTLSClientAuthHostnameCertificateListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success OriginTLSClientAuthHostnameCertificateListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo OriginTLSClientAuthHostnameCertificateListResponseEnvelopeResultInfo `json:"result_info"` - JSON originTLSClientAuthHostnameCertificateListResponseEnvelopeJSON `json:"-"` -} - -// originTLSClientAuthHostnameCertificateListResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [OriginTLSClientAuthHostnameCertificateListResponseEnvelope] -type originTLSClientAuthHostnameCertificateListResponseEnvelopeJSON 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 *OriginTLSClientAuthHostnameCertificateListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameCertificateListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthHostnameCertificateListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthHostnameCertificateListResponseEnvelopeErrorsJSON `json:"-"` -} - -// originTLSClientAuthHostnameCertificateListResponseEnvelopeErrorsJSON contains -// the JSON metadata for the struct -// [OriginTLSClientAuthHostnameCertificateListResponseEnvelopeErrors] -type originTLSClientAuthHostnameCertificateListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameCertificateListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameCertificateListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthHostnameCertificateListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthHostnameCertificateListResponseEnvelopeMessagesJSON `json:"-"` -} - -// originTLSClientAuthHostnameCertificateListResponseEnvelopeMessagesJSON contains -// the JSON metadata for the struct -// [OriginTLSClientAuthHostnameCertificateListResponseEnvelopeMessages] -type originTLSClientAuthHostnameCertificateListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameCertificateListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameCertificateListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type OriginTLSClientAuthHostnameCertificateListResponseEnvelopeSuccess bool - -const ( - OriginTLSClientAuthHostnameCertificateListResponseEnvelopeSuccessTrue OriginTLSClientAuthHostnameCertificateListResponseEnvelopeSuccess = true -) - -type OriginTLSClientAuthHostnameCertificateListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON originTLSClientAuthHostnameCertificateListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// originTLSClientAuthHostnameCertificateListResponseEnvelopeResultInfoJSON -// contains the JSON metadata for the struct -// [OriginTLSClientAuthHostnameCertificateListResponseEnvelopeResultInfo] -type originTLSClientAuthHostnameCertificateListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameCertificateListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameCertificateListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthHostnameCertificateDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type OriginTLSClientAuthHostnameCertificateDeleteResponseEnvelope struct { - Errors []OriginTLSClientAuthHostnameCertificateDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []OriginTLSClientAuthHostnameCertificateDeleteResponseEnvelopeMessages `json:"messages,required"` - Result OriginTLSClientAuthHostnameCertificateDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success OriginTLSClientAuthHostnameCertificateDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON originTLSClientAuthHostnameCertificateDeleteResponseEnvelopeJSON `json:"-"` -} - -// originTLSClientAuthHostnameCertificateDeleteResponseEnvelopeJSON contains the -// JSON metadata for the struct -// [OriginTLSClientAuthHostnameCertificateDeleteResponseEnvelope] -type originTLSClientAuthHostnameCertificateDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameCertificateDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameCertificateDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthHostnameCertificateDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthHostnameCertificateDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// originTLSClientAuthHostnameCertificateDeleteResponseEnvelopeErrorsJSON contains -// the JSON metadata for the struct -// [OriginTLSClientAuthHostnameCertificateDeleteResponseEnvelopeErrors] -type originTLSClientAuthHostnameCertificateDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameCertificateDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameCertificateDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthHostnameCertificateDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthHostnameCertificateDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// originTLSClientAuthHostnameCertificateDeleteResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [OriginTLSClientAuthHostnameCertificateDeleteResponseEnvelopeMessages] -type originTLSClientAuthHostnameCertificateDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameCertificateDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameCertificateDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type OriginTLSClientAuthHostnameCertificateDeleteResponseEnvelopeSuccess bool - -const ( - OriginTLSClientAuthHostnameCertificateDeleteResponseEnvelopeSuccessTrue OriginTLSClientAuthHostnameCertificateDeleteResponseEnvelopeSuccess = true -) - -type OriginTLSClientAuthHostnameCertificateGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type OriginTLSClientAuthHostnameCertificateGetResponseEnvelope struct { - Errors []OriginTLSClientAuthHostnameCertificateGetResponseEnvelopeErrors `json:"errors,required"` - Messages []OriginTLSClientAuthHostnameCertificateGetResponseEnvelopeMessages `json:"messages,required"` - Result OriginTLSClientAuthHostnameCertificateGetResponse `json:"result,required"` - // Whether the API call was successful - Success OriginTLSClientAuthHostnameCertificateGetResponseEnvelopeSuccess `json:"success,required"` - JSON originTLSClientAuthHostnameCertificateGetResponseEnvelopeJSON `json:"-"` -} - -// originTLSClientAuthHostnameCertificateGetResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [OriginTLSClientAuthHostnameCertificateGetResponseEnvelope] -type originTLSClientAuthHostnameCertificateGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameCertificateGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameCertificateGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthHostnameCertificateGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthHostnameCertificateGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// originTLSClientAuthHostnameCertificateGetResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [OriginTLSClientAuthHostnameCertificateGetResponseEnvelopeErrors] -type originTLSClientAuthHostnameCertificateGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameCertificateGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameCertificateGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthHostnameCertificateGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthHostnameCertificateGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// originTLSClientAuthHostnameCertificateGetResponseEnvelopeMessagesJSON contains -// the JSON metadata for the struct -// [OriginTLSClientAuthHostnameCertificateGetResponseEnvelopeMessages] -type originTLSClientAuthHostnameCertificateGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthHostnameCertificateGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthHostnameCertificateGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type OriginTLSClientAuthHostnameCertificateGetResponseEnvelopeSuccess bool - -const ( - OriginTLSClientAuthHostnameCertificateGetResponseEnvelopeSuccessTrue OriginTLSClientAuthHostnameCertificateGetResponseEnvelopeSuccess = true -) diff --git a/origintlsclientauthhostnamecertificate_test.go b/origintlsclientauthhostnamecertificate_test.go deleted file mode 100644 index 26c600c7a13..00000000000 --- a/origintlsclientauthhostnamecertificate_test.go +++ /dev/null @@ -1,128 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestOriginTLSClientAuthHostnameCertificateNew(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("user@example.com"), - ) - _, err := client.OriginTLSClientAuth.Hostnames.Certificates.New(context.TODO(), cloudflare.OriginTLSClientAuthHostnameCertificateNewParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Certificate: cloudflare.F("-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIJAMHAwfXZ5/PWMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\nBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX\naWRnaXRzIFB0eSBMdGQwHhcNMTYwODI0MTY0MzAxWhcNMTYxMTIyMTY0MzAxWjBF\nMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50\nZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\nCgKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmGdtcGbg/1\nCGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKnabIRuGvB\nKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpidtnKX/a+5\n0GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+pyFxIXjbEI\ndZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pEewooaeO2\nizNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABo4GnMIGkMB0GA1UdDgQWBBT/LbE4\n9rWf288N6sJA5BRb6FJIGDB1BgNVHSMEbjBsgBT/LbE49rWf288N6sJA5BRb6FJI\nGKFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNV\nBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAMHAwfXZ5/PWMAwGA1UdEwQF\nMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAHHFwl0tH0quUYZYO0dZYt4R7SJ0pCm2\n2satiyzHl4OnXcHDpekAo7/a09c6Lz6AU83cKy/+x3/djYHXWba7HpEu0dR3ugQP\nMlr4zrhd9xKZ0KZKiYmtJH+ak4OM4L3FbT0owUZPyjLSlhMtJVcoRp5CJsjAMBUG\nSvD8RX+T01wzox/Qb+lnnNnOlaWpqu8eoOenybxKp1a9ULzIVvN/LAcc+14vioFq\n2swRWtmocBAs8QR9n4uvbpiYvS8eYueDCWMM4fvFfBhaDZ3N9IbtySh3SpFdQDhw\nYbjM2rxXiyLGxB4Bol7QTv4zHif7Zt89FReT/NBy4rzaskDJY5L6xmY=\n-----END CERTIFICATE-----\n"), - PrivateKey: cloudflare.F("-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmG\ndtcGbg/1CGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKn\nabIRuGvBKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpid\ntnKX/a+50GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+py\nFxIXjbEIdZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pE\newooaeO2izNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABAoIBACbhTYXBZYKmYPCb\nHBR1IBlCQA2nLGf0qRuJNJZg5iEzXows/6tc8YymZkQE7nolapWsQ+upk2y5Xdp/\naxiuprIs9JzkYK8Ox0r+dlwCG1kSW+UAbX0bQ/qUqlsTvU6muVuMP8vZYHxJ3wmb\n+ufRBKztPTQ/rYWaYQcgC0RWI20HTFBMxlTAyNxYNWzX7RKFkGVVyB9RsAtmcc8g\n+j4OdosbfNoJPS0HeIfNpAznDfHKdxDk2Yc1tV6RHBrC1ynyLE9+TaflIAdo2MVv\nKLMLq51GqYKtgJFIlBRPQqKoyXdz3fGvXrTkf/WY9QNq0J1Vk5ERePZ54mN8iZB7\n9lwy/AkCgYEA6FXzosxswaJ2wQLeoYc7ceaweX/SwTvxHgXzRyJIIT0eJWgx13Wo\n/WA3Iziimsjf6qE+SI/8laxPp2A86VMaIt3Z3mJN/CqSVGw8LK2AQst+OwdPyDMu\niacE8lj/IFGC8mwNUAb9CzGU3JpU4PxxGFjS/eMtGeRXCWkK4NE+G08CgYEA1Kp9\nN2JrVlqUz+gAX+LPmE9OEMAS9WQSQsfCHGogIFDGGcNf7+uwBM7GAaSJIP01zcoe\nVAgWdzXCv3FLhsaZoJ6RyLOLay5phbu1iaTr4UNYm5WtYTzMzqh8l1+MFFDl9xDB\nvULuCIIrglM5MeS/qnSg1uMoH2oVPj9TVst/ir8CgYEAxrI7Ws9Zc4Bt70N1As+U\nlySjaEVZCMkqvHJ6TCuVZFfQoE0r0whdLdRLU2PsLFP+q7qaeZQqgBaNSKeVcDYR\n9B+nY/jOmQoPewPVsp/vQTCnE/R81spu0mp0YI6cIheT1Z9zAy322svcc43JaWB7\nmEbeqyLOP4Z4qSOcmghZBSECgYACvR9Xs0DGn+wCsW4vze/2ei77MD4OQvepPIFX\ndFZtlBy5ADcgE9z0cuVB6CiL8DbdK5kwY9pGNr8HUCI03iHkW6Zs+0L0YmihfEVe\nPG19PSzK9CaDdhD9KFZSbLyVFmWfxOt50H7YRTTiPMgjyFpfi5j2q348yVT0tEQS\nfhRqaQKBgAcWPokmJ7EbYQGeMbS7HC8eWO/RyamlnSffdCdSc7ue3zdVJxpAkQ8W\nqu80pEIF6raIQfAf8MXiiZ7auFOSnHQTXUbhCpvDLKi0Mwq3G8Pl07l+2s6dQG6T\nlv6XTQaMyf6n1yjzL+fzDrH3qXMxHMO/b13EePXpDMpY7HQpoLDi\n-----END RSA PRIVATE KEY-----\n"), - }) - 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 TestOriginTLSClientAuthHostnameCertificateList(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("user@example.com"), - ) - _, err := client.OriginTLSClientAuth.Hostnames.Certificates.List(context.TODO(), cloudflare.OriginTLSClientAuthHostnameCertificateListParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestOriginTLSClientAuthHostnameCertificateDelete(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("user@example.com"), - ) - _, err := client.OriginTLSClientAuth.Hostnames.Certificates.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.OriginTLSClientAuthHostnameCertificateDeleteParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestOriginTLSClientAuthHostnameCertificateGet(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("user@example.com"), - ) - _, err := client.OriginTLSClientAuth.Hostnames.Certificates.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.OriginTLSClientAuthHostnameCertificateGetParams{ - ZoneID: cloudflare.F("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/origintlsclientauthsetting.go b/origintlsclientauthsetting.go deleted file mode 100644 index 2d8df850acb..00000000000 --- a/origintlsclientauthsetting.go +++ /dev/null @@ -1,284 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// OriginTLSClientAuthSettingService 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 -// [NewOriginTLSClientAuthSettingService] method instead. -type OriginTLSClientAuthSettingService struct { - Options []option.RequestOption -} - -// NewOriginTLSClientAuthSettingService 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 NewOriginTLSClientAuthSettingService(opts ...option.RequestOption) (r *OriginTLSClientAuthSettingService) { - r = &OriginTLSClientAuthSettingService{} - r.Options = opts - return -} - -// Enable or disable zone-level authenticated origin pulls. 'enabled' should be set -// true either before/after the certificate is uploaded to see the certificate in -// use. -func (r *OriginTLSClientAuthSettingService) Update(ctx context.Context, params OriginTLSClientAuthSettingUpdateParams, opts ...option.RequestOption) (res *OriginTLSClientAuthSettingUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env OriginTLSClientAuthSettingUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/origin_tls_client_auth/settings", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get whether zone-level authenticated origin pulls is enabled or not. It is false -// by default. -func (r *OriginTLSClientAuthSettingService) Get(ctx context.Context, query OriginTLSClientAuthSettingGetParams, opts ...option.RequestOption) (res *OriginTLSClientAuthSettingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env OriginTLSClientAuthSettingGetResponseEnvelope - path := fmt.Sprintf("zones/%s/origin_tls_client_auth/settings", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type OriginTLSClientAuthSettingUpdateResponse struct { - // Indicates whether zone-level authenticated origin pulls is enabled. - Enabled bool `json:"enabled"` - JSON originTLSClientAuthSettingUpdateResponseJSON `json:"-"` -} - -// originTLSClientAuthSettingUpdateResponseJSON contains the JSON metadata for the -// struct [OriginTLSClientAuthSettingUpdateResponse] -type originTLSClientAuthSettingUpdateResponseJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthSettingUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthSettingUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthSettingGetResponse struct { - // Indicates whether zone-level authenticated origin pulls is enabled. - Enabled bool `json:"enabled"` - JSON originTLSClientAuthSettingGetResponseJSON `json:"-"` -} - -// originTLSClientAuthSettingGetResponseJSON contains the JSON metadata for the -// struct [OriginTLSClientAuthSettingGetResponse] -type originTLSClientAuthSettingGetResponseJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthSettingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthSettingGetResponseJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthSettingUpdateParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Indicates whether zone-level authenticated origin pulls is enabled. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r OriginTLSClientAuthSettingUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type OriginTLSClientAuthSettingUpdateResponseEnvelope struct { - Errors []OriginTLSClientAuthSettingUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []OriginTLSClientAuthSettingUpdateResponseEnvelopeMessages `json:"messages,required"` - Result OriginTLSClientAuthSettingUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success OriginTLSClientAuthSettingUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON originTLSClientAuthSettingUpdateResponseEnvelopeJSON `json:"-"` -} - -// originTLSClientAuthSettingUpdateResponseEnvelopeJSON contains the JSON metadata -// for the struct [OriginTLSClientAuthSettingUpdateResponseEnvelope] -type originTLSClientAuthSettingUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthSettingUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthSettingUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthSettingUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthSettingUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// originTLSClientAuthSettingUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [OriginTLSClientAuthSettingUpdateResponseEnvelopeErrors] -type originTLSClientAuthSettingUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthSettingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthSettingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthSettingUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthSettingUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// originTLSClientAuthSettingUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [OriginTLSClientAuthSettingUpdateResponseEnvelopeMessages] -type originTLSClientAuthSettingUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthSettingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthSettingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type OriginTLSClientAuthSettingUpdateResponseEnvelopeSuccess bool - -const ( - OriginTLSClientAuthSettingUpdateResponseEnvelopeSuccessTrue OriginTLSClientAuthSettingUpdateResponseEnvelopeSuccess = true -) - -type OriginTLSClientAuthSettingGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type OriginTLSClientAuthSettingGetResponseEnvelope struct { - Errors []OriginTLSClientAuthSettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []OriginTLSClientAuthSettingGetResponseEnvelopeMessages `json:"messages,required"` - Result OriginTLSClientAuthSettingGetResponse `json:"result,required"` - // Whether the API call was successful - Success OriginTLSClientAuthSettingGetResponseEnvelopeSuccess `json:"success,required"` - JSON originTLSClientAuthSettingGetResponseEnvelopeJSON `json:"-"` -} - -// originTLSClientAuthSettingGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [OriginTLSClientAuthSettingGetResponseEnvelope] -type originTLSClientAuthSettingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthSettingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthSettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthSettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// originTLSClientAuthSettingGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [OriginTLSClientAuthSettingGetResponseEnvelopeErrors] -type originTLSClientAuthSettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type OriginTLSClientAuthSettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON originTLSClientAuthSettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// originTLSClientAuthSettingGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [OriginTLSClientAuthSettingGetResponseEnvelopeMessages] -type originTLSClientAuthSettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *OriginTLSClientAuthSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r originTLSClientAuthSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type OriginTLSClientAuthSettingGetResponseEnvelopeSuccess bool - -const ( - OriginTLSClientAuthSettingGetResponseEnvelopeSuccessTrue OriginTLSClientAuthSettingGetResponseEnvelopeSuccess = true -) diff --git a/origintlsclientauthsetting_test.go b/origintlsclientauthsetting_test.go deleted file mode 100644 index be1d0dc4adf..00000000000 --- a/origintlsclientauthsetting_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestOriginTLSClientAuthSettingUpdate(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("user@example.com"), - ) - _, err := client.OriginTLSClientAuth.Settings.Update(context.TODO(), cloudflare.OriginTLSClientAuthSettingUpdateParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Enabled: cloudflare.F(true), - }) - 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 TestOriginTLSClientAuthSettingGet(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("user@example.com"), - ) - _, err := client.OriginTLSClientAuth.Settings.Get(context.TODO(), cloudflare.OriginTLSClientAuthSettingGetParams{ - ZoneID: cloudflare.F("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/page.go b/page.go deleted file mode 100644 index d3197aa79b2..00000000000 --- a/page.go +++ /dev/null @@ -1,26 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// PageService 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 [NewPageService] method instead. -type PageService struct { - Options []option.RequestOption - Projects *PageProjectService -} - -// NewPageService 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 NewPageService(opts ...option.RequestOption) (r *PageService) { - r = &PageService{} - r.Options = opts - r.Projects = NewPageProjectService(opts...) - return -} diff --git a/page_shield/aliases.go b/page_shield/aliases.go new file mode 100644 index 00000000000..53d99d7a368 --- /dev/null +++ b/page_shield/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package page_shield + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/page_shield/connection.go b/page_shield/connection.go new file mode 100644 index 00000000000..f48a9377901 --- /dev/null +++ b/page_shield/connection.go @@ -0,0 +1,295 @@ +// File generated from our OpenAPI spec by Stainless. + +package page_shield + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ConnectionService 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 [NewConnectionService] method instead. +type ConnectionService struct { + Options []option.RequestOption +} + +// NewConnectionService 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 NewConnectionService(opts ...option.RequestOption) (r *ConnectionService) { + r = &ConnectionService{} + r.Options = opts + return +} + +// Lists all connections detected by Page Shield. +func (r *ConnectionService) List(ctx context.Context, params ConnectionListParams, opts ...option.RequestOption) (res *[]PageShieldConnection, err error) { + opts = append(r.Options[:], opts...) + var env ConnectionListResponseEnvelope + path := fmt.Sprintf("zones/%s/page_shield/connections", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a connection detected by Page Shield by connection ID. +func (r *ConnectionService) Get(ctx context.Context, connectionID string, query ConnectionGetParams, opts ...option.RequestOption) (res *PageShieldConnection, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("zones/%s/page_shield/connections/%s", query.ZoneID, connectionID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +type PageShieldConnection struct { + ID interface{} `json:"id"` + AddedAt interface{} `json:"added_at"` + DomainReportedMalicious interface{} `json:"domain_reported_malicious"` + FirstPageURL interface{} `json:"first_page_url"` + FirstSeenAt interface{} `json:"first_seen_at"` + Host interface{} `json:"host"` + LastSeenAt interface{} `json:"last_seen_at"` + PageURLs interface{} `json:"page_urls"` + URL interface{} `json:"url"` + URLContainsCdnCgiPath interface{} `json:"url_contains_cdn_cgi_path"` + JSON pageShieldConnectionJSON `json:"-"` +} + +// pageShieldConnectionJSON contains the JSON metadata for the struct +// [PageShieldConnection] +type pageShieldConnectionJSON struct { + ID apijson.Field + AddedAt apijson.Field + DomainReportedMalicious apijson.Field + FirstPageURL apijson.Field + FirstSeenAt apijson.Field + Host apijson.Field + LastSeenAt apijson.Field + PageURLs apijson.Field + URL apijson.Field + URLContainsCdnCgiPath apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PageShieldConnection) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pageShieldConnectionJSON) RawJSON() string { + return r.raw +} + +type ConnectionListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // The direction used to sort returned connections. + Direction param.Field[ConnectionListParamsDirection] `query:"direction"` + // When true, excludes connections seen in a `/cdn-cgi` path from the returned + // connections. The default value is true. + ExcludeCdnCgi param.Field[bool] `query:"exclude_cdn_cgi"` + // Excludes connections whose URL contains one of the URL-encoded URLs separated by + // commas. + ExcludeURLs param.Field[string] `query:"exclude_urls"` + // Export the list of connections as a file. Cannot be used with per_page or page + // options. + Export param.Field[ConnectionListParamsExport] `query:"export"` + // Includes connections that match one or more URL-encoded hostnames separated by + // commas. + // + // Wildcards are supported at the start and end of each hostname to support starts + // with, ends with and contains. If no wildcards are used, results will be filtered + // by exact match + Hosts param.Field[string] `query:"hosts"` + // The field used to sort returned connections. + OrderBy param.Field[ConnectionListParamsOrderBy] `query:"order_by"` + // The current page number of the paginated results. + // + // We additionally support a special value "all". When "all" is used, the API will + // return all the connections with the applied filters in a single page. + // Additionally, when using this value, the API will not return the categorisation + // data for the URL and domain of the connections. This feature is best-effort and + // it may only work for zones with a low number of connections + Page param.Field[string] `query:"page"` + // Includes connections that match one or more page URLs (separated by commas) + // where they were last seen + // + // Wildcards are supported at the start and end of each page URL to support starts + // with, ends with and contains. If no wildcards are used, results will be filtered + // by exact match + PageURL param.Field[string] `query:"page_url"` + // The number of results per page. + PerPage param.Field[float64] `query:"per_page"` + // When true, malicious connections appear first in the returned connections. + PrioritizeMalicious param.Field[bool] `query:"prioritize_malicious"` + // Filters the returned connections using a comma-separated list of connection + // statuses. Accepted values: `active`, `infrequent`, and `inactive`. The default + // value is `active`. + Status param.Field[string] `query:"status"` + // Includes connections whose URL contain one or more URL-encoded URLs separated by + // commas. + URLs param.Field[string] `query:"urls"` +} + +// URLQuery serializes [ConnectionListParams]'s query parameters as `url.Values`. +func (r ConnectionListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// The direction used to sort returned connections. +type ConnectionListParamsDirection string + +const ( + ConnectionListParamsDirectionAsc ConnectionListParamsDirection = "asc" + ConnectionListParamsDirectionDesc ConnectionListParamsDirection = "desc" +) + +// Export the list of connections as a file. Cannot be used with per_page or page +// options. +type ConnectionListParamsExport string + +const ( + ConnectionListParamsExportCsv ConnectionListParamsExport = "csv" +) + +// The field used to sort returned connections. +type ConnectionListParamsOrderBy string + +const ( + ConnectionListParamsOrderByFirstSeenAt ConnectionListParamsOrderBy = "first_seen_at" + ConnectionListParamsOrderByLastSeenAt ConnectionListParamsOrderBy = "last_seen_at" +) + +type ConnectionListResponseEnvelope struct { + Errors []ConnectionListResponseEnvelopeErrors `json:"errors,required"` + Messages []ConnectionListResponseEnvelopeMessages `json:"messages,required"` + Result []PageShieldConnection `json:"result,required,nullable"` + // Whether the API call was successful + Success ConnectionListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo ConnectionListResponseEnvelopeResultInfo `json:"result_info"` + JSON connectionListResponseEnvelopeJSON `json:"-"` +} + +// connectionListResponseEnvelopeJSON contains the JSON metadata for the struct +// [ConnectionListResponseEnvelope] +type connectionListResponseEnvelopeJSON 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 *ConnectionListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectionListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConnectionListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON connectionListResponseEnvelopeErrorsJSON `json:"-"` +} + +// connectionListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ConnectionListResponseEnvelopeErrors] +type connectionListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectionListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectionListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ConnectionListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON connectionListResponseEnvelopeMessagesJSON `json:"-"` +} + +// connectionListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ConnectionListResponseEnvelopeMessages] +type connectionListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectionListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectionListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConnectionListResponseEnvelopeSuccess bool + +const ( + ConnectionListResponseEnvelopeSuccessTrue ConnectionListResponseEnvelopeSuccess = true +) + +type ConnectionListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON connectionListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// connectionListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [ConnectionListResponseEnvelopeResultInfo] +type connectionListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectionListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectionListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type ConnectionGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} diff --git a/page_shield/connection_test.go b/page_shield/connection_test.go new file mode 100644 index 00000000000..12898b9e741 --- /dev/null +++ b/page_shield/connection_test.go @@ -0,0 +1,83 @@ +// File generated from our OpenAPI spec by Stainless. + +package page_shield_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/page_shield" +) + +func TestConnectionListWithOptionalParams(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("user@example.com"), + ) + _, err := client.PageShield.Connections.List(context.TODO(), page_shield.ConnectionListParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Direction: cloudflare.F(page_shield.ConnectionListParamsDirectionAsc), + ExcludeCdnCgi: cloudflare.F(true), + ExcludeURLs: cloudflare.F("blog.cloudflare.com,www.example"), + Export: cloudflare.F(page_shield.ConnectionListParamsExportCsv), + Hosts: cloudflare.F("blog.cloudflare.com,www.example*,*cloudflare.com"), + OrderBy: cloudflare.F(page_shield.ConnectionListParamsOrderByFirstSeenAt), + Page: cloudflare.F("string"), + PageURL: cloudflare.F("example.com/page,*/checkout,example.com/*,*checkout*"), + PerPage: cloudflare.F(100.000000), + PrioritizeMalicious: cloudflare.F(true), + Status: cloudflare.F("active,inactive"), + URLs: cloudflare.F("blog.cloudflare.com,www.example"), + }) + 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 TestConnectionGet(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("user@example.com"), + ) + _, err := client.PageShield.Connections.Get( + context.TODO(), + "c9ef84a6bf5e47138c75d95e2f933e8f", + page_shield.ConnectionGetParams{ + ZoneID: cloudflare.F("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/pageshield.go b/page_shield/pageshield.go similarity index 87% rename from pageshield.go rename to page_shield/pageshield.go index d828e8a2a5e..6c8781750ff 100644 --- a/pageshield.go +++ b/page_shield/pageshield.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package page_shield import ( "context" @@ -19,9 +19,9 @@ import ( // service directly, and instead use the [NewPageShieldService] method instead. type PageShieldService struct { Options []option.RequestOption - Policies *PageShieldPolicyService - Connections *PageShieldConnectionService - Scripts *PageShieldScriptService + Policies *PolicyService + Connections *ConnectionService + Scripts *ScriptService } // NewPageShieldService generates a new service that applies the given options to @@ -30,14 +30,14 @@ type PageShieldService struct { func NewPageShieldService(opts ...option.RequestOption) (r *PageShieldService) { r = &PageShieldService{} r.Options = opts - r.Policies = NewPageShieldPolicyService(opts...) - r.Connections = NewPageShieldConnectionService(opts...) - r.Scripts = NewPageShieldScriptService(opts...) + r.Policies = NewPolicyService(opts...) + r.Connections = NewConnectionService(opts...) + r.Scripts = NewScriptService(opts...) return } // Updates Page Shield settings. -func (r *PageShieldService) Update(ctx context.Context, params PageShieldUpdateParams, opts ...option.RequestOption) (res *PageShieldUpdateResponse, err error) { +func (r *PageShieldService) Update(ctx context.Context, params PageShieldUpdateParams, opts ...option.RequestOption) (res *PageShieldUpdateZoneSettings, err error) { opts = append(r.Options[:], opts...) var env PageShieldUpdateResponseEnvelope path := fmt.Sprintf("zones/%s/page_shield", params.ZoneID) @@ -50,7 +50,7 @@ func (r *PageShieldService) Update(ctx context.Context, params PageShieldUpdateP } // Fetches the Page Shield settings. -func (r *PageShieldService) List(ctx context.Context, query PageShieldListParams, opts ...option.RequestOption) (res *PageShieldListResponse, err error) { +func (r *PageShieldService) List(ctx context.Context, query PageShieldListParams, opts ...option.RequestOption) (res *PageShieldGetZoneSettings, err error) { opts = append(r.Options[:], opts...) var env PageShieldListResponseEnvelope path := fmt.Sprintf("zones/%s/page_shield", query.ZoneID) @@ -62,7 +62,7 @@ func (r *PageShieldService) List(ctx context.Context, query PageShieldListParams return } -type PageShieldUpdateResponse struct { +type PageShieldGetZoneSettings struct { // When true, indicates that Page Shield is enabled. Enabled bool `json:"enabled"` // The timestamp of when Page Shield was last updated. @@ -71,13 +71,13 @@ type PageShieldUpdateResponse struct { // https://csp-reporting.cloudflare.com/cdn-cgi/script_monitor/report UseCloudflareReportingEndpoint bool `json:"use_cloudflare_reporting_endpoint"` // When true, the paths associated with connections URLs will also be analyzed. - UseConnectionURLPath bool `json:"use_connection_url_path"` - JSON pageShieldUpdateResponseJSON `json:"-"` + UseConnectionURLPath bool `json:"use_connection_url_path"` + JSON pageShieldGetZoneSettingsJSON `json:"-"` } -// pageShieldUpdateResponseJSON contains the JSON metadata for the struct -// [PageShieldUpdateResponse] -type pageShieldUpdateResponseJSON struct { +// pageShieldGetZoneSettingsJSON contains the JSON metadata for the struct +// [PageShieldGetZoneSettings] +type pageShieldGetZoneSettingsJSON struct { Enabled apijson.Field UpdatedAt apijson.Field UseCloudflareReportingEndpoint apijson.Field @@ -86,15 +86,15 @@ type pageShieldUpdateResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *PageShieldUpdateResponse) UnmarshalJSON(data []byte) (err error) { +func (r *PageShieldGetZoneSettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pageShieldUpdateResponseJSON) RawJSON() string { +func (r pageShieldGetZoneSettingsJSON) RawJSON() string { return r.raw } -type PageShieldListResponse struct { +type PageShieldUpdateZoneSettings struct { // When true, indicates that Page Shield is enabled. Enabled bool `json:"enabled"` // The timestamp of when Page Shield was last updated. @@ -103,13 +103,13 @@ type PageShieldListResponse struct { // https://csp-reporting.cloudflare.com/cdn-cgi/script_monitor/report UseCloudflareReportingEndpoint bool `json:"use_cloudflare_reporting_endpoint"` // When true, the paths associated with connections URLs will also be analyzed. - UseConnectionURLPath bool `json:"use_connection_url_path"` - JSON pageShieldListResponseJSON `json:"-"` + UseConnectionURLPath bool `json:"use_connection_url_path"` + JSON pageShieldUpdateZoneSettingsJSON `json:"-"` } -// pageShieldListResponseJSON contains the JSON metadata for the struct -// [PageShieldListResponse] -type pageShieldListResponseJSON struct { +// pageShieldUpdateZoneSettingsJSON contains the JSON metadata for the struct +// [PageShieldUpdateZoneSettings] +type pageShieldUpdateZoneSettingsJSON struct { Enabled apijson.Field UpdatedAt apijson.Field UseCloudflareReportingEndpoint apijson.Field @@ -118,11 +118,11 @@ type pageShieldListResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *PageShieldListResponse) UnmarshalJSON(data []byte) (err error) { +func (r *PageShieldUpdateZoneSettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pageShieldListResponseJSON) RawJSON() string { +func (r pageShieldUpdateZoneSettingsJSON) RawJSON() string { return r.raw } @@ -145,7 +145,7 @@ func (r PageShieldUpdateParams) MarshalJSON() (data []byte, err error) { type PageShieldUpdateResponseEnvelope struct { Errors []PageShieldUpdateResponseEnvelopeErrors `json:"errors,required"` Messages []PageShieldUpdateResponseEnvelopeMessages `json:"messages,required"` - Result PageShieldUpdateResponse `json:"result,required"` + Result PageShieldUpdateZoneSettings `json:"result,required"` // Whether the API call was successful Success PageShieldUpdateResponseEnvelopeSuccess `json:"success,required"` JSON pageShieldUpdateResponseEnvelopeJSON `json:"-"` @@ -231,7 +231,7 @@ type PageShieldListParams struct { type PageShieldListResponseEnvelope struct { Errors []PageShieldListResponseEnvelopeErrors `json:"errors,required"` Messages []PageShieldListResponseEnvelopeMessages `json:"messages,required"` - Result PageShieldListResponse `json:"result,required"` + Result PageShieldGetZoneSettings `json:"result,required"` // Whether the API call was successful Success PageShieldListResponseEnvelopeSuccess `json:"success,required"` JSON pageShieldListResponseEnvelopeJSON `json:"-"` diff --git a/pageshield_test.go b/page_shield/pageshield_test.go similarity index 87% rename from pageshield_test.go rename to page_shield/pageshield_test.go index ebc3cf38ae3..3cb37f2bfd2 100644 --- a/pageshield_test.go +++ b/page_shield/pageshield_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package page_shield_test import ( "context" @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/page_shield" ) func TestPageShieldUpdateWithOptionalParams(t *testing.T) { @@ -27,7 +28,7 @@ func TestPageShieldUpdateWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.PageShield.Update(context.TODO(), cloudflare.PageShieldUpdateParams{ + _, err := client.PageShield.Update(context.TODO(), page_shield.PageShieldUpdateParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Enabled: cloudflare.F(true), UseCloudflareReportingEndpoint: cloudflare.F(true), @@ -56,7 +57,7 @@ func TestPageShieldList(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.PageShield.List(context.TODO(), cloudflare.PageShieldListParams{ + _, err := client.PageShield.List(context.TODO(), page_shield.PageShieldListParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { diff --git a/page_shield/policy.go b/page_shield/policy.go new file mode 100644 index 00000000000..b944188f88e --- /dev/null +++ b/page_shield/policy.go @@ -0,0 +1,308 @@ +// File generated from our OpenAPI spec by Stainless. + +package page_shield + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// PolicyService 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 [NewPolicyService] method instead. +type PolicyService struct { + Options []option.RequestOption +} + +// NewPolicyService 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 NewPolicyService(opts ...option.RequestOption) (r *PolicyService) { + r = &PolicyService{} + r.Options = opts + return +} + +// Create a Page Shield policy. +func (r *PolicyService) New(ctx context.Context, params PolicyNewParams, opts ...option.RequestOption) (res *PageShieldPageshieldPolicy, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("zones/%s/page_shield/policies", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...) + return +} + +// Update a Page Shield policy by ID. +func (r *PolicyService) Update(ctx context.Context, policyID string, params PolicyUpdateParams, opts ...option.RequestOption) (res *PageShieldPageshieldPolicy, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("zones/%s/page_shield/policies/%s", params.ZoneID, policyID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &res, opts...) + return +} + +// Lists all Page Shield policies. +func (r *PolicyService) List(ctx context.Context, query PolicyListParams, opts ...option.RequestOption) (res *[]PageShieldPageshieldPolicy, err error) { + opts = append(r.Options[:], opts...) + var env PolicyListResponseEnvelope + path := fmt.Sprintf("zones/%s/page_shield/policies", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a Page Shield policy by ID. +func (r *PolicyService) Delete(ctx context.Context, policyID string, body PolicyDeleteParams, opts ...option.RequestOption) (err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + path := fmt.Sprintf("zones/%s/page_shield/policies/%s", body.ZoneID, policyID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) + return +} + +// Fetches a Page Shield policy by ID. +func (r *PolicyService) Get(ctx context.Context, policyID string, query PolicyGetParams, opts ...option.RequestOption) (res *PageShieldPageshieldPolicy, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("zones/%s/page_shield/policies/%s", query.ZoneID, policyID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +type PageShieldPageshieldPolicy struct { + // The ID of the policy + ID string `json:"id"` + // The action to take if the expression matches + Action PageShieldPageshieldPolicyAction `json:"action"` + // A description for the policy + Description string `json:"description"` + // Whether the policy is enabled + Enabled bool `json:"enabled"` + // The expression which must match for the policy to be applied, using the + // Cloudflare Firewall rule expression syntax + Expression string `json:"expression"` + // The policy which will be applied + Value string `json:"value"` + JSON pageShieldPageshieldPolicyJSON `json:"-"` +} + +// pageShieldPageshieldPolicyJSON contains the JSON metadata for the struct +// [PageShieldPageshieldPolicy] +type pageShieldPageshieldPolicyJSON struct { + ID apijson.Field + Action apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PageShieldPageshieldPolicy) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pageShieldPageshieldPolicyJSON) RawJSON() string { + return r.raw +} + +// The action to take if the expression matches +type PageShieldPageshieldPolicyAction string + +const ( + PageShieldPageshieldPolicyActionAllow PageShieldPageshieldPolicyAction = "allow" + PageShieldPageshieldPolicyActionLog PageShieldPageshieldPolicyAction = "log" +) + +type PolicyNewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // The action to take if the expression matches + Action param.Field[PolicyNewParamsAction] `json:"action"` + // A description for the policy + Description param.Field[string] `json:"description"` + // Whether the policy is enabled + Enabled param.Field[bool] `json:"enabled"` + // The expression which must match for the policy to be applied, using the + // Cloudflare Firewall rule expression syntax + Expression param.Field[string] `json:"expression"` + // The policy which will be applied + Value param.Field[string] `json:"value"` +} + +func (r PolicyNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The action to take if the expression matches +type PolicyNewParamsAction string + +const ( + PolicyNewParamsActionAllow PolicyNewParamsAction = "allow" + PolicyNewParamsActionLog PolicyNewParamsAction = "log" +) + +type PolicyUpdateParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // The action to take if the expression matches + Action param.Field[PolicyUpdateParamsAction] `json:"action"` + // A description for the policy + Description param.Field[string] `json:"description"` + // Whether the policy is enabled + Enabled param.Field[bool] `json:"enabled"` + // The expression which must match for the policy to be applied, using the + // Cloudflare Firewall rule expression syntax + Expression param.Field[string] `json:"expression"` + // The policy which will be applied + Value param.Field[string] `json:"value"` +} + +func (r PolicyUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The action to take if the expression matches +type PolicyUpdateParamsAction string + +const ( + PolicyUpdateParamsActionAllow PolicyUpdateParamsAction = "allow" + PolicyUpdateParamsActionLog PolicyUpdateParamsAction = "log" +) + +type PolicyListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type PolicyListResponseEnvelope struct { + Errors []PolicyListResponseEnvelopeErrors `json:"errors,required"` + Messages []PolicyListResponseEnvelopeMessages `json:"messages,required"` + Result []PageShieldPageshieldPolicy `json:"result,required,nullable"` + // Whether the API call was successful + Success PolicyListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo PolicyListResponseEnvelopeResultInfo `json:"result_info"` + JSON policyListResponseEnvelopeJSON `json:"-"` +} + +// policyListResponseEnvelopeJSON contains the JSON metadata for the struct +// [PolicyListResponseEnvelope] +type policyListResponseEnvelopeJSON 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 *PolicyListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r policyListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PolicyListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON policyListResponseEnvelopeErrorsJSON `json:"-"` +} + +// policyListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PolicyListResponseEnvelopeErrors] +type policyListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PolicyListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r policyListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PolicyListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON policyListResponseEnvelopeMessagesJSON `json:"-"` +} + +// policyListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PolicyListResponseEnvelopeMessages] +type policyListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PolicyListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r policyListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PolicyListResponseEnvelopeSuccess bool + +const ( + PolicyListResponseEnvelopeSuccessTrue PolicyListResponseEnvelopeSuccess = true +) + +type PolicyListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON policyListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// policyListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [PolicyListResponseEnvelopeResultInfo] +type policyListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PolicyListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r policyListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type PolicyDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type PolicyGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} diff --git a/page_shield/policy_test.go b/page_shield/policy_test.go new file mode 100644 index 00000000000..0a57a9004f3 --- /dev/null +++ b/page_shield/policy_test.go @@ -0,0 +1,167 @@ +// File generated from our OpenAPI spec by Stainless. + +package page_shield_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/page_shield" +) + +func TestPolicyNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.PageShield.Policies.New(context.TODO(), page_shield.PolicyNewParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Action: cloudflare.F(page_shield.PolicyNewParamsActionAllow), + Description: cloudflare.F("Checkout page CSP policy"), + Enabled: cloudflare.F(true), + Expression: cloudflare.F("ends_with(http.request.uri.path, \"/checkout\")"), + Value: cloudflare.F("script-src 'none';"), + }) + 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 TestPolicyUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.PageShield.Policies.Update( + context.TODO(), + "c9ef84a6bf5e47138c75d95e2f933e8f", + page_shield.PolicyUpdateParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Action: cloudflare.F(page_shield.PolicyUpdateParamsActionAllow), + Description: cloudflare.F("Checkout page CSP policy"), + Enabled: cloudflare.F(true), + Expression: cloudflare.F("ends_with(http.request.uri.path, \"/checkout\")"), + Value: cloudflare.F("script-src 'none';"), + }, + ) + 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 TestPolicyList(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("user@example.com"), + ) + _, err := client.PageShield.Policies.List(context.TODO(), page_shield.PolicyListParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestPolicyDelete(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("user@example.com"), + ) + err := client.PageShield.Policies.Delete( + context.TODO(), + "c9ef84a6bf5e47138c75d95e2f933e8f", + page_shield.PolicyDeleteParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestPolicyGet(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("user@example.com"), + ) + _, err := client.PageShield.Policies.Get( + context.TODO(), + "c9ef84a6bf5e47138c75d95e2f933e8f", + page_shield.PolicyGetParams{ + ZoneID: cloudflare.F("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/page_shield/script.go b/page_shield/script.go new file mode 100644 index 00000000000..296854670e7 --- /dev/null +++ b/page_shield/script.go @@ -0,0 +1,382 @@ +// File generated from our OpenAPI spec by Stainless. + +package page_shield + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ScriptService 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 [NewScriptService] method instead. +type ScriptService struct { + Options []option.RequestOption +} + +// NewScriptService 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 NewScriptService(opts ...option.RequestOption) (r *ScriptService) { + r = &ScriptService{} + r.Options = opts + return +} + +// Lists all scripts detected by Page Shield. +func (r *ScriptService) List(ctx context.Context, params ScriptListParams, opts ...option.RequestOption) (res *[]PageShieldScript, err error) { + opts = append(r.Options[:], opts...) + var env ScriptListResponseEnvelope + path := fmt.Sprintf("zones/%s/page_shield/scripts", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a script detected by Page Shield by script ID. +func (r *ScriptService) Get(ctx context.Context, scriptID string, query ScriptGetParams, opts ...option.RequestOption) (res *ScriptGetResponse, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("zones/%s/page_shield/scripts/%s", query.ZoneID, scriptID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +type PageShieldScript struct { + ID interface{} `json:"id"` + AddedAt interface{} `json:"added_at"` + DomainReportedMalicious interface{} `json:"domain_reported_malicious"` + FetchedAt interface{} `json:"fetched_at"` + FirstPageURL interface{} `json:"first_page_url"` + FirstSeenAt interface{} `json:"first_seen_at"` + Hash interface{} `json:"hash"` + Host interface{} `json:"host"` + JsIntegrityScore interface{} `json:"js_integrity_score"` + LastSeenAt interface{} `json:"last_seen_at"` + PageURLs interface{} `json:"page_urls"` + URL interface{} `json:"url"` + URLContainsCdnCgiPath interface{} `json:"url_contains_cdn_cgi_path"` + JSON pageShieldScriptJSON `json:"-"` +} + +// pageShieldScriptJSON contains the JSON metadata for the struct +// [PageShieldScript] +type pageShieldScriptJSON struct { + ID apijson.Field + AddedAt apijson.Field + DomainReportedMalicious apijson.Field + FetchedAt apijson.Field + FirstPageURL apijson.Field + FirstSeenAt apijson.Field + Hash apijson.Field + Host apijson.Field + JsIntegrityScore apijson.Field + LastSeenAt apijson.Field + PageURLs apijson.Field + URL apijson.Field + URLContainsCdnCgiPath apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PageShieldScript) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pageShieldScriptJSON) RawJSON() string { + return r.raw +} + +type ScriptGetResponse struct { + ID interface{} `json:"id"` + AddedAt interface{} `json:"added_at"` + DomainReportedMalicious interface{} `json:"domain_reported_malicious"` + FetchedAt interface{} `json:"fetched_at"` + FirstPageURL interface{} `json:"first_page_url"` + FirstSeenAt interface{} `json:"first_seen_at"` + Hash interface{} `json:"hash"` + Host interface{} `json:"host"` + JsIntegrityScore interface{} `json:"js_integrity_score"` + LastSeenAt interface{} `json:"last_seen_at"` + PageURLs interface{} `json:"page_urls"` + URL interface{} `json:"url"` + URLContainsCdnCgiPath interface{} `json:"url_contains_cdn_cgi_path"` + Versions []ScriptGetResponseVersion `json:"versions,nullable"` + JSON scriptGetResponseJSON `json:"-"` +} + +// scriptGetResponseJSON contains the JSON metadata for the struct +// [ScriptGetResponse] +type scriptGetResponseJSON struct { + ID apijson.Field + AddedAt apijson.Field + DomainReportedMalicious apijson.Field + FetchedAt apijson.Field + FirstPageURL apijson.Field + FirstSeenAt apijson.Field + Hash apijson.Field + Host apijson.Field + JsIntegrityScore apijson.Field + LastSeenAt apijson.Field + PageURLs apijson.Field + URL apijson.Field + URLContainsCdnCgiPath apijson.Field + Versions apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptGetResponseJSON) RawJSON() string { + return r.raw +} + +// The version of the analyzed script. +type ScriptGetResponseVersion struct { + // The timestamp of when the script was last fetched. + FetchedAt string `json:"fetched_at,nullable"` + // The computed hash of the analyzed script. + Hash string `json:"hash,nullable"` + // The integrity score of the JavaScript content. + JsIntegrityScore int64 `json:"js_integrity_score,nullable"` + JSON scriptGetResponseVersionJSON `json:"-"` +} + +// scriptGetResponseVersionJSON contains the JSON metadata for the struct +// [ScriptGetResponseVersion] +type scriptGetResponseVersionJSON struct { + FetchedAt apijson.Field + Hash apijson.Field + JsIntegrityScore apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptGetResponseVersion) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptGetResponseVersionJSON) RawJSON() string { + return r.raw +} + +type ScriptListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // The direction used to sort returned scripts. + Direction param.Field[ScriptListParamsDirection] `query:"direction"` + // When true, excludes scripts seen in a `/cdn-cgi` path from the returned scripts. + // The default value is true. + ExcludeCdnCgi param.Field[bool] `query:"exclude_cdn_cgi"` + // When true, excludes duplicate scripts. We consider a script duplicate of another + // if their javascript content matches and they share the same url host and zone + // hostname. In such case, we return the most recent script for the URL host and + // zone hostname combination. + ExcludeDuplicates param.Field[bool] `query:"exclude_duplicates"` + // Excludes scripts whose URL contains one of the URL-encoded URLs separated by + // commas. + ExcludeURLs param.Field[string] `query:"exclude_urls"` + // Export the list of scripts as a file. Cannot be used with per_page or page + // options. + Export param.Field[ScriptListParamsExport] `query:"export"` + // Includes scripts that match one or more URL-encoded hostnames separated by + // commas. + // + // Wildcards are supported at the start and end of each hostname to support starts + // with, ends with and contains. If no wildcards are used, results will be filtered + // by exact match + Hosts param.Field[string] `query:"hosts"` + // The field used to sort returned scripts. + OrderBy param.Field[ScriptListParamsOrderBy] `query:"order_by"` + // The current page number of the paginated results. + // + // We additionally support a special value "all". When "all" is used, the API will + // return all the scripts with the applied filters in a single page. Additionally, + // when using this value, the API will not return the script versions or + // categorisation data for the URL and domain of the scripts. This feature is + // best-effort and it may only work for zones with a low number of scripts + Page param.Field[string] `query:"page"` + // Includes scripts that match one or more page URLs (separated by commas) where + // they were last seen + // + // Wildcards are supported at the start and end of each page URL to support starts + // with, ends with and contains. If no wildcards are used, results will be filtered + // by exact match + PageURL param.Field[string] `query:"page_url"` + // The number of results per page. + PerPage param.Field[float64] `query:"per_page"` + // When true, malicious scripts appear first in the returned scripts. + PrioritizeMalicious param.Field[bool] `query:"prioritize_malicious"` + // Filters the returned scripts using a comma-separated list of scripts statuses. + // Accepted values: `active`, `infrequent`, and `inactive`. The default value is + // `active`. + Status param.Field[string] `query:"status"` + // Includes scripts whose URL contain one or more URL-encoded URLs separated by + // commas. + URLs param.Field[string] `query:"urls"` +} + +// URLQuery serializes [ScriptListParams]'s query parameters as `url.Values`. +func (r ScriptListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// The direction used to sort returned scripts. +type ScriptListParamsDirection string + +const ( + ScriptListParamsDirectionAsc ScriptListParamsDirection = "asc" + ScriptListParamsDirectionDesc ScriptListParamsDirection = "desc" +) + +// Export the list of scripts as a file. Cannot be used with per_page or page +// options. +type ScriptListParamsExport string + +const ( + ScriptListParamsExportCsv ScriptListParamsExport = "csv" +) + +// The field used to sort returned scripts. +type ScriptListParamsOrderBy string + +const ( + ScriptListParamsOrderByFirstSeenAt ScriptListParamsOrderBy = "first_seen_at" + ScriptListParamsOrderByLastSeenAt ScriptListParamsOrderBy = "last_seen_at" +) + +type ScriptListResponseEnvelope struct { + Errors []ScriptListResponseEnvelopeErrors `json:"errors,required"` + Messages []ScriptListResponseEnvelopeMessages `json:"messages,required"` + Result []PageShieldScript `json:"result,required,nullable"` + // Whether the API call was successful + Success ScriptListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo ScriptListResponseEnvelopeResultInfo `json:"result_info"` + JSON scriptListResponseEnvelopeJSON `json:"-"` +} + +// scriptListResponseEnvelopeJSON contains the JSON metadata for the struct +// [ScriptListResponseEnvelope] +type scriptListResponseEnvelopeJSON 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 *ScriptListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ScriptListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptListResponseEnvelopeErrorsJSON `json:"-"` +} + +// scriptListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ScriptListResponseEnvelopeErrors] +type scriptListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ScriptListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptListResponseEnvelopeMessagesJSON `json:"-"` +} + +// scriptListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ScriptListResponseEnvelopeMessages] +type scriptListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptListResponseEnvelopeSuccess bool + +const ( + ScriptListResponseEnvelopeSuccessTrue ScriptListResponseEnvelopeSuccess = true +) + +type ScriptListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON scriptListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// scriptListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [ScriptListResponseEnvelopeResultInfo] +type scriptListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type ScriptGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} diff --git a/page_shield/script_test.go b/page_shield/script_test.go new file mode 100644 index 00000000000..cf5ad852349 --- /dev/null +++ b/page_shield/script_test.go @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package page_shield_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/page_shield" +) + +func TestScriptListWithOptionalParams(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("user@example.com"), + ) + _, err := client.PageShield.Scripts.List(context.TODO(), page_shield.ScriptListParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Direction: cloudflare.F(page_shield.ScriptListParamsDirectionAsc), + ExcludeCdnCgi: cloudflare.F(true), + ExcludeDuplicates: cloudflare.F(true), + ExcludeURLs: cloudflare.F("blog.cloudflare.com,www.example"), + Export: cloudflare.F(page_shield.ScriptListParamsExportCsv), + Hosts: cloudflare.F("blog.cloudflare.com,www.example*,*cloudflare.com"), + OrderBy: cloudflare.F(page_shield.ScriptListParamsOrderByFirstSeenAt), + Page: cloudflare.F("string"), + PageURL: cloudflare.F("example.com/page,*/checkout,example.com/*,*checkout*"), + PerPage: cloudflare.F(100.000000), + PrioritizeMalicious: cloudflare.F(true), + Status: cloudflare.F("active,inactive"), + URLs: cloudflare.F("blog.cloudflare.com,www.example"), + }) + 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 TestScriptGet(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("user@example.com"), + ) + _, err := client.PageShield.Scripts.Get( + context.TODO(), + "c9ef84a6bf5e47138c75d95e2f933e8f", + page_shield.ScriptGetParams{ + ZoneID: cloudflare.F("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/pageproject.go b/pageproject.go deleted file mode 100644 index a8896de9e28..00000000000 --- a/pageproject.go +++ /dev/null @@ -1,2752 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// PageProjectService 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 [NewPageProjectService] method -// instead. -type PageProjectService struct { - Options []option.RequestOption - Deployments *PageProjectDeploymentService - Domains *PageProjectDomainService -} - -// NewPageProjectService 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 NewPageProjectService(opts ...option.RequestOption) (r *PageProjectService) { - r = &PageProjectService{} - r.Options = opts - r.Deployments = NewPageProjectDeploymentService(opts...) - r.Domains = NewPageProjectDomainService(opts...) - return -} - -// Create a new project. -func (r *PageProjectService) New(ctx context.Context, params PageProjectNewParams, opts ...option.RequestOption) (res *PageProjectNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env PageProjectNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/pages/projects", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch a list of all user projects. -func (r *PageProjectService) List(ctx context.Context, query PageProjectListParams, opts ...option.RequestOption) (res *[]PageProjectListResponse, err error) { - opts = append(r.Options[:], opts...) - var env PageProjectListResponseEnvelope - path := fmt.Sprintf("accounts/%s/pages/projects", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a project by name. -func (r *PageProjectService) Delete(ctx context.Context, projectName string, body PageProjectDeleteParams, opts ...option.RequestOption) (res *PageProjectDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("accounts/%s/pages/projects/%s", body.AccountID, projectName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &res, opts...) - return -} - -// Set new attributes for an existing project. Modify environment variables. To -// delete an environment variable, set the key to null. -func (r *PageProjectService) Edit(ctx context.Context, projectName string, params PageProjectEditParams, opts ...option.RequestOption) (res *PageProjectEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env PageProjectEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/pages/projects/%s", params.AccountID, projectName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch a project by name. -func (r *PageProjectService) Get(ctx context.Context, projectName string, query PageProjectGetParams, opts ...option.RequestOption) (res *PageProjectGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env PageProjectGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/pages/projects/%s", query.AccountID, projectName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Purge all cached build artifacts for a Pages project -func (r *PageProjectService) PurgeBuildCache(ctx context.Context, projectName string, body PageProjectPurgeBuildCacheParams, opts ...option.RequestOption) (res *PageProjectPurgeBuildCacheResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("accounts/%s/pages/projects/%s/purge_build_cache", body.AccountID, projectName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) - return -} - -// Union satisfied by [PageProjectNewResponseUnknown], -// [PageProjectNewResponseArray] or [shared.UnionString]. -type PageProjectNewResponse interface { - ImplementsPageProjectNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*PageProjectNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(PageProjectNewResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type PageProjectNewResponseArray []interface{} - -func (r PageProjectNewResponseArray) ImplementsPageProjectNewResponse() {} - -type PageProjectListResponse struct { - // Id of the deployment. - ID string `json:"id"` - // A list of alias URLs pointing to this deployment. - Aliases []interface{} `json:"aliases,nullable"` - BuildConfig interface{} `json:"build_config"` - // When the deployment was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Info about what caused the deployment. - DeploymentTrigger PageProjectListResponseDeploymentTrigger `json:"deployment_trigger"` - // A dict of env variables to build this deploy. - EnvVars interface{} `json:"env_vars"` - // Type of deploy. - Environment string `json:"environment"` - // If the deployment has been skipped. - IsSkipped bool `json:"is_skipped"` - LatestStage interface{} `json:"latest_stage"` - // When the deployment was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Id of the project. - ProjectID string `json:"project_id"` - // Name of the project. - ProjectName string `json:"project_name"` - // Short Id (8 character) of the deployment. - ShortID string `json:"short_id"` - Source interface{} `json:"source"` - // List of past stages. - Stages []PageProjectListResponseStage `json:"stages"` - // The live URL to view this deployment. - URL string `json:"url"` - JSON pageProjectListResponseJSON `json:"-"` -} - -// pageProjectListResponseJSON contains the JSON metadata for the struct -// [PageProjectListResponse] -type pageProjectListResponseJSON struct { - ID apijson.Field - Aliases apijson.Field - BuildConfig apijson.Field - CreatedOn apijson.Field - DeploymentTrigger apijson.Field - EnvVars apijson.Field - Environment apijson.Field - IsSkipped apijson.Field - LatestStage apijson.Field - ModifiedOn apijson.Field - ProjectID apijson.Field - ProjectName apijson.Field - ShortID apijson.Field - Source apijson.Field - Stages apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectListResponseJSON) RawJSON() string { - return r.raw -} - -// Info about what caused the deployment. -type PageProjectListResponseDeploymentTrigger struct { - // Additional info about the trigger. - Metadata PageProjectListResponseDeploymentTriggerMetadata `json:"metadata"` - // What caused the deployment. - Type string `json:"type"` - JSON pageProjectListResponseDeploymentTriggerJSON `json:"-"` -} - -// pageProjectListResponseDeploymentTriggerJSON contains the JSON metadata for the -// struct [PageProjectListResponseDeploymentTrigger] -type pageProjectListResponseDeploymentTriggerJSON struct { - Metadata apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectListResponseDeploymentTrigger) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectListResponseDeploymentTriggerJSON) RawJSON() string { - return r.raw -} - -// Additional info about the trigger. -type PageProjectListResponseDeploymentTriggerMetadata struct { - // Where the trigger happened. - Branch string `json:"branch"` - // Hash of the deployment trigger commit. - CommitHash string `json:"commit_hash"` - // Message of the deployment trigger commit. - CommitMessage string `json:"commit_message"` - JSON pageProjectListResponseDeploymentTriggerMetadataJSON `json:"-"` -} - -// pageProjectListResponseDeploymentTriggerMetadataJSON contains the JSON metadata -// for the struct [PageProjectListResponseDeploymentTriggerMetadata] -type pageProjectListResponseDeploymentTriggerMetadataJSON struct { - Branch apijson.Field - CommitHash apijson.Field - CommitMessage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectListResponseDeploymentTriggerMetadata) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectListResponseDeploymentTriggerMetadataJSON) RawJSON() string { - return r.raw -} - -// The status of the deployment. -type PageProjectListResponseStage struct { - // When the stage ended. - EndedOn time.Time `json:"ended_on,nullable" format:"date-time"` - // The current build stage. - Name string `json:"name"` - // When the stage started. - StartedOn time.Time `json:"started_on,nullable" format:"date-time"` - // State of the current stage. - Status string `json:"status"` - JSON pageProjectListResponseStageJSON `json:"-"` -} - -// pageProjectListResponseStageJSON contains the JSON metadata for the struct -// [PageProjectListResponseStage] -type pageProjectListResponseStageJSON struct { - EndedOn apijson.Field - Name apijson.Field - StartedOn apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectListResponseStage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectListResponseStageJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeleteResponse = interface{} - -// Union satisfied by [PageProjectEditResponseUnknown], -// [PageProjectEditResponseArray] or [shared.UnionString]. -type PageProjectEditResponse interface { - ImplementsPageProjectEditResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*PageProjectEditResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(PageProjectEditResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type PageProjectEditResponseArray []interface{} - -func (r PageProjectEditResponseArray) ImplementsPageProjectEditResponse() {} - -type PageProjectGetResponse struct { - // Id of the project. - ID string `json:"id"` - // Configs for the project build process. - BuildConfig PageProjectGetResponseBuildConfig `json:"build_config"` - CanonicalDeployment PageProjectGetResponseCanonicalDeployment `json:"canonical_deployment"` - // When the project was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Configs for deployments in a project. - DeploymentConfigs PageProjectGetResponseDeploymentConfigs `json:"deployment_configs"` - // A list of associated custom domains for the project. - Domains []interface{} `json:"domains"` - LatestDeployment PageProjectGetResponseLatestDeployment `json:"latest_deployment"` - // Name of the project. - Name string `json:"name"` - // Production branch of the project. Used to identify production deployments. - ProductionBranch string `json:"production_branch"` - Source interface{} `json:"source"` - // The Cloudflare subdomain associated with the project. - Subdomain string `json:"subdomain"` - JSON pageProjectGetResponseJSON `json:"-"` -} - -// pageProjectGetResponseJSON contains the JSON metadata for the struct -// [PageProjectGetResponse] -type pageProjectGetResponseJSON struct { - ID apijson.Field - BuildConfig apijson.Field - CanonicalDeployment apijson.Field - CreatedOn apijson.Field - DeploymentConfigs apijson.Field - Domains apijson.Field - LatestDeployment apijson.Field - Name apijson.Field - ProductionBranch apijson.Field - Source apijson.Field - Subdomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseJSON) RawJSON() string { - return r.raw -} - -// Configs for the project build process. -type PageProjectGetResponseBuildConfig struct { - // Enable build caching for the project. - BuildCaching bool `json:"build_caching,nullable"` - // Command used to build project. - BuildCommand string `json:"build_command,nullable"` - // Output directory of the build. - DestinationDir string `json:"destination_dir,nullable"` - // Directory to run the command. - RootDir string `json:"root_dir,nullable"` - // The classifying tag for analytics. - WebAnalyticsTag string `json:"web_analytics_tag,nullable"` - // The auth token for analytics. - WebAnalyticsToken string `json:"web_analytics_token,nullable"` - JSON pageProjectGetResponseBuildConfigJSON `json:"-"` -} - -// pageProjectGetResponseBuildConfigJSON contains the JSON metadata for the struct -// [PageProjectGetResponseBuildConfig] -type pageProjectGetResponseBuildConfigJSON struct { - BuildCaching apijson.Field - BuildCommand apijson.Field - DestinationDir apijson.Field - RootDir apijson.Field - WebAnalyticsTag apijson.Field - WebAnalyticsToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseBuildConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseBuildConfigJSON) RawJSON() string { - return r.raw -} - -type PageProjectGetResponseCanonicalDeployment struct { - // Id of the deployment. - ID string `json:"id"` - // A list of alias URLs pointing to this deployment. - Aliases []interface{} `json:"aliases,nullable"` - BuildConfig interface{} `json:"build_config"` - // When the deployment was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Info about what caused the deployment. - DeploymentTrigger PageProjectGetResponseCanonicalDeploymentDeploymentTrigger `json:"deployment_trigger"` - // A dict of env variables to build this deploy. - EnvVars interface{} `json:"env_vars"` - // Type of deploy. - Environment string `json:"environment"` - // If the deployment has been skipped. - IsSkipped bool `json:"is_skipped"` - LatestStage interface{} `json:"latest_stage"` - // When the deployment was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Id of the project. - ProjectID string `json:"project_id"` - // Name of the project. - ProjectName string `json:"project_name"` - // Short Id (8 character) of the deployment. - ShortID string `json:"short_id"` - Source interface{} `json:"source"` - // List of past stages. - Stages []PageProjectGetResponseCanonicalDeploymentStage `json:"stages"` - // The live URL to view this deployment. - URL string `json:"url"` - JSON pageProjectGetResponseCanonicalDeploymentJSON `json:"-"` -} - -// pageProjectGetResponseCanonicalDeploymentJSON contains the JSON metadata for the -// struct [PageProjectGetResponseCanonicalDeployment] -type pageProjectGetResponseCanonicalDeploymentJSON struct { - ID apijson.Field - Aliases apijson.Field - BuildConfig apijson.Field - CreatedOn apijson.Field - DeploymentTrigger apijson.Field - EnvVars apijson.Field - Environment apijson.Field - IsSkipped apijson.Field - LatestStage apijson.Field - ModifiedOn apijson.Field - ProjectID apijson.Field - ProjectName apijson.Field - ShortID apijson.Field - Source apijson.Field - Stages apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseCanonicalDeployment) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseCanonicalDeploymentJSON) RawJSON() string { - return r.raw -} - -// Info about what caused the deployment. -type PageProjectGetResponseCanonicalDeploymentDeploymentTrigger struct { - // Additional info about the trigger. - Metadata PageProjectGetResponseCanonicalDeploymentDeploymentTriggerMetadata `json:"metadata"` - // What caused the deployment. - Type string `json:"type"` - JSON pageProjectGetResponseCanonicalDeploymentDeploymentTriggerJSON `json:"-"` -} - -// pageProjectGetResponseCanonicalDeploymentDeploymentTriggerJSON contains the JSON -// metadata for the struct -// [PageProjectGetResponseCanonicalDeploymentDeploymentTrigger] -type pageProjectGetResponseCanonicalDeploymentDeploymentTriggerJSON struct { - Metadata apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseCanonicalDeploymentDeploymentTrigger) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseCanonicalDeploymentDeploymentTriggerJSON) RawJSON() string { - return r.raw -} - -// Additional info about the trigger. -type PageProjectGetResponseCanonicalDeploymentDeploymentTriggerMetadata struct { - // Where the trigger happened. - Branch string `json:"branch"` - // Hash of the deployment trigger commit. - CommitHash string `json:"commit_hash"` - // Message of the deployment trigger commit. - CommitMessage string `json:"commit_message"` - JSON pageProjectGetResponseCanonicalDeploymentDeploymentTriggerMetadataJSON `json:"-"` -} - -// pageProjectGetResponseCanonicalDeploymentDeploymentTriggerMetadataJSON contains -// the JSON metadata for the struct -// [PageProjectGetResponseCanonicalDeploymentDeploymentTriggerMetadata] -type pageProjectGetResponseCanonicalDeploymentDeploymentTriggerMetadataJSON struct { - Branch apijson.Field - CommitHash apijson.Field - CommitMessage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseCanonicalDeploymentDeploymentTriggerMetadata) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseCanonicalDeploymentDeploymentTriggerMetadataJSON) RawJSON() string { - return r.raw -} - -// The status of the deployment. -type PageProjectGetResponseCanonicalDeploymentStage struct { - // When the stage ended. - EndedOn time.Time `json:"ended_on,nullable" format:"date-time"` - // The current build stage. - Name string `json:"name"` - // When the stage started. - StartedOn time.Time `json:"started_on,nullable" format:"date-time"` - // State of the current stage. - Status string `json:"status"` - JSON pageProjectGetResponseCanonicalDeploymentStageJSON `json:"-"` -} - -// pageProjectGetResponseCanonicalDeploymentStageJSON contains the JSON metadata -// for the struct [PageProjectGetResponseCanonicalDeploymentStage] -type pageProjectGetResponseCanonicalDeploymentStageJSON struct { - EndedOn apijson.Field - Name apijson.Field - StartedOn apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseCanonicalDeploymentStage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseCanonicalDeploymentStageJSON) RawJSON() string { - return r.raw -} - -// Configs for deployments in a project. -type PageProjectGetResponseDeploymentConfigs struct { - // Configs for preview deploys. - Preview PageProjectGetResponseDeploymentConfigsPreview `json:"preview"` - // Configs for production deploys. - Production PageProjectGetResponseDeploymentConfigsProduction `json:"production"` - JSON pageProjectGetResponseDeploymentConfigsJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsJSON contains the JSON metadata for the -// struct [PageProjectGetResponseDeploymentConfigs] -type pageProjectGetResponseDeploymentConfigsJSON struct { - Preview apijson.Field - Production apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsJSON) RawJSON() string { - return r.raw -} - -// Configs for preview deploys. -type PageProjectGetResponseDeploymentConfigsPreview struct { - // Constellation bindings used for Pages Functions. - AIBindings PageProjectGetResponseDeploymentConfigsPreviewAIBindings `json:"ai_bindings,nullable"` - // Analytics Engine bindings used for Pages Functions. - AnalyticsEngineDatasets PageProjectGetResponseDeploymentConfigsPreviewAnalyticsEngineDatasets `json:"analytics_engine_datasets,nullable"` - // Compatibility date used for Pages Functions. - CompatibilityDate string `json:"compatibility_date"` - // Compatibility flags used for Pages Functions. - CompatibilityFlags []interface{} `json:"compatibility_flags"` - // D1 databases used for Pages Functions. - D1Databases PageProjectGetResponseDeploymentConfigsPreviewD1Databases `json:"d1_databases,nullable"` - // Durabble Object namespaces used for Pages Functions. - DurableObjectNamespaces PageProjectGetResponseDeploymentConfigsPreviewDurableObjectNamespaces `json:"durable_object_namespaces,nullable"` - // Environment variables for build configs. - EnvVars PageProjectGetResponseDeploymentConfigsPreviewEnvVars `json:"env_vars,nullable"` - // KV namespaces used for Pages Functions. - KVNamespaces PageProjectGetResponseDeploymentConfigsPreviewKVNamespaces `json:"kv_namespaces"` - // Placement setting used for Pages Functions. - Placement PageProjectGetResponseDeploymentConfigsPreviewPlacement `json:"placement,nullable"` - // Queue Producer bindings used for Pages Functions. - QueueProducers PageProjectGetResponseDeploymentConfigsPreviewQueueProducers `json:"queue_producers,nullable"` - // R2 buckets used for Pages Functions. - R2Buckets PageProjectGetResponseDeploymentConfigsPreviewR2Buckets `json:"r2_buckets,nullable"` - // Services used for Pages Functions. - ServiceBindings PageProjectGetResponseDeploymentConfigsPreviewServiceBindings `json:"service_bindings,nullable"` - JSON pageProjectGetResponseDeploymentConfigsPreviewJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewJSON contains the JSON metadata -// for the struct [PageProjectGetResponseDeploymentConfigsPreview] -type pageProjectGetResponseDeploymentConfigsPreviewJSON struct { - AIBindings apijson.Field - AnalyticsEngineDatasets apijson.Field - CompatibilityDate apijson.Field - CompatibilityFlags apijson.Field - D1Databases apijson.Field - DurableObjectNamespaces apijson.Field - EnvVars apijson.Field - KVNamespaces apijson.Field - Placement apijson.Field - QueueProducers apijson.Field - R2Buckets apijson.Field - ServiceBindings apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreview) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewJSON) RawJSON() string { - return r.raw -} - -// Constellation bindings used for Pages Functions. -type PageProjectGetResponseDeploymentConfigsPreviewAIBindings struct { - // AI binding. - AIBinding PageProjectGetResponseDeploymentConfigsPreviewAIBindingsAIBinding `json:"AI_BINDING"` - JSON pageProjectGetResponseDeploymentConfigsPreviewAIBindingsJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewAIBindingsJSON contains the JSON -// metadata for the struct -// [PageProjectGetResponseDeploymentConfigsPreviewAIBindings] -type pageProjectGetResponseDeploymentConfigsPreviewAIBindingsJSON struct { - AIBinding apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewAIBindings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewAIBindingsJSON) RawJSON() string { - return r.raw -} - -// AI binding. -type PageProjectGetResponseDeploymentConfigsPreviewAIBindingsAIBinding struct { - ProjectID interface{} `json:"project_id"` - JSON pageProjectGetResponseDeploymentConfigsPreviewAIBindingsAIBindingJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewAIBindingsAIBindingJSON contains -// the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsPreviewAIBindingsAIBinding] -type pageProjectGetResponseDeploymentConfigsPreviewAIBindingsAIBindingJSON struct { - ProjectID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewAIBindingsAIBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewAIBindingsAIBindingJSON) RawJSON() string { - return r.raw -} - -// Analytics Engine bindings used for Pages Functions. -type PageProjectGetResponseDeploymentConfigsPreviewAnalyticsEngineDatasets struct { - // Analytics Engine binding. - AnalyticsEngineBinding PageProjectGetResponseDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding `json:"ANALYTICS_ENGINE_BINDING"` - JSON pageProjectGetResponseDeploymentConfigsPreviewAnalyticsEngineDatasetsJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewAnalyticsEngineDatasetsJSON -// contains the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsPreviewAnalyticsEngineDatasets] -type pageProjectGetResponseDeploymentConfigsPreviewAnalyticsEngineDatasetsJSON struct { - AnalyticsEngineBinding apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewAnalyticsEngineDatasets) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewAnalyticsEngineDatasetsJSON) RawJSON() string { - return r.raw -} - -// Analytics Engine binding. -type PageProjectGetResponseDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding struct { - // Name of the dataset. - Dataset string `json:"dataset"` - JSON pageProjectGetResponseDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingJSON -// contains the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding] -type pageProjectGetResponseDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingJSON struct { - Dataset apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingJSON) RawJSON() string { - return r.raw -} - -// D1 databases used for Pages Functions. -type PageProjectGetResponseDeploymentConfigsPreviewD1Databases struct { - // D1 binding. - D1Binding PageProjectGetResponseDeploymentConfigsPreviewD1DatabasesD1Binding `json:"D1_BINDING"` - JSON pageProjectGetResponseDeploymentConfigsPreviewD1DatabasesJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewD1DatabasesJSON contains the JSON -// metadata for the struct -// [PageProjectGetResponseDeploymentConfigsPreviewD1Databases] -type pageProjectGetResponseDeploymentConfigsPreviewD1DatabasesJSON struct { - D1Binding apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewD1Databases) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewD1DatabasesJSON) RawJSON() string { - return r.raw -} - -// D1 binding. -type PageProjectGetResponseDeploymentConfigsPreviewD1DatabasesD1Binding struct { - // UUID of the D1 database. - ID string `json:"id"` - JSON pageProjectGetResponseDeploymentConfigsPreviewD1DatabasesD1BindingJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewD1DatabasesD1BindingJSON contains -// the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsPreviewD1DatabasesD1Binding] -type pageProjectGetResponseDeploymentConfigsPreviewD1DatabasesD1BindingJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewD1DatabasesD1Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewD1DatabasesD1BindingJSON) RawJSON() string { - return r.raw -} - -// Durabble Object namespaces used for Pages Functions. -type PageProjectGetResponseDeploymentConfigsPreviewDurableObjectNamespaces struct { - // Durabble Object binding. - DoBinding PageProjectGetResponseDeploymentConfigsPreviewDurableObjectNamespacesDoBinding `json:"DO_BINDING"` - JSON pageProjectGetResponseDeploymentConfigsPreviewDurableObjectNamespacesJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewDurableObjectNamespacesJSON -// contains the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsPreviewDurableObjectNamespaces] -type pageProjectGetResponseDeploymentConfigsPreviewDurableObjectNamespacesJSON struct { - DoBinding apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewDurableObjectNamespaces) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewDurableObjectNamespacesJSON) RawJSON() string { - return r.raw -} - -// Durabble Object binding. -type PageProjectGetResponseDeploymentConfigsPreviewDurableObjectNamespacesDoBinding struct { - // ID of the Durabble Object namespace. - NamespaceID string `json:"namespace_id"` - JSON pageProjectGetResponseDeploymentConfigsPreviewDurableObjectNamespacesDoBindingJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewDurableObjectNamespacesDoBindingJSON -// contains the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsPreviewDurableObjectNamespacesDoBinding] -type pageProjectGetResponseDeploymentConfigsPreviewDurableObjectNamespacesDoBindingJSON struct { - NamespaceID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewDurableObjectNamespacesDoBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewDurableObjectNamespacesDoBindingJSON) RawJSON() string { - return r.raw -} - -// Environment variables for build configs. -type PageProjectGetResponseDeploymentConfigsPreviewEnvVars struct { - // Environment variable. - EnvironmentVariable PageProjectGetResponseDeploymentConfigsPreviewEnvVarsEnvironmentVariable `json:"ENVIRONMENT_VARIABLE"` - JSON pageProjectGetResponseDeploymentConfigsPreviewEnvVarsJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewEnvVarsJSON contains the JSON -// metadata for the struct [PageProjectGetResponseDeploymentConfigsPreviewEnvVars] -type pageProjectGetResponseDeploymentConfigsPreviewEnvVarsJSON struct { - EnvironmentVariable apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewEnvVars) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewEnvVarsJSON) RawJSON() string { - return r.raw -} - -// Environment variable. -type PageProjectGetResponseDeploymentConfigsPreviewEnvVarsEnvironmentVariable struct { - // The type of environment variable (plain text or secret) - Type PageProjectGetResponseDeploymentConfigsPreviewEnvVarsEnvironmentVariableType `json:"type"` - // Environment variable value. - Value string `json:"value"` - JSON pageProjectGetResponseDeploymentConfigsPreviewEnvVarsEnvironmentVariableJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewEnvVarsEnvironmentVariableJSON -// contains the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsPreviewEnvVarsEnvironmentVariable] -type pageProjectGetResponseDeploymentConfigsPreviewEnvVarsEnvironmentVariableJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewEnvVarsEnvironmentVariable) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewEnvVarsEnvironmentVariableJSON) RawJSON() string { - return r.raw -} - -// The type of environment variable (plain text or secret) -type PageProjectGetResponseDeploymentConfigsPreviewEnvVarsEnvironmentVariableType string - -const ( - PageProjectGetResponseDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypePlainText PageProjectGetResponseDeploymentConfigsPreviewEnvVarsEnvironmentVariableType = "plain_text" - PageProjectGetResponseDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypeSecretText PageProjectGetResponseDeploymentConfigsPreviewEnvVarsEnvironmentVariableType = "secret_text" -) - -// KV namespaces used for Pages Functions. -type PageProjectGetResponseDeploymentConfigsPreviewKVNamespaces struct { - // KV binding. - KVBinding PageProjectGetResponseDeploymentConfigsPreviewKVNamespacesKVBinding `json:"KV_BINDING"` - JSON pageProjectGetResponseDeploymentConfigsPreviewKVNamespacesJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewKVNamespacesJSON contains the JSON -// metadata for the struct -// [PageProjectGetResponseDeploymentConfigsPreviewKVNamespaces] -type pageProjectGetResponseDeploymentConfigsPreviewKVNamespacesJSON struct { - KVBinding apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewKVNamespaces) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewKVNamespacesJSON) RawJSON() string { - return r.raw -} - -// KV binding. -type PageProjectGetResponseDeploymentConfigsPreviewKVNamespacesKVBinding struct { - // ID of the KV namespace. - NamespaceID string `json:"namespace_id"` - JSON pageProjectGetResponseDeploymentConfigsPreviewKVNamespacesKVBindingJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewKVNamespacesKVBindingJSON contains -// the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsPreviewKVNamespacesKVBinding] -type pageProjectGetResponseDeploymentConfigsPreviewKVNamespacesKVBindingJSON struct { - NamespaceID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewKVNamespacesKVBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewKVNamespacesKVBindingJSON) RawJSON() string { - return r.raw -} - -// Placement setting used for Pages Functions. -type PageProjectGetResponseDeploymentConfigsPreviewPlacement struct { - // Placement mode. - Mode string `json:"mode"` - JSON pageProjectGetResponseDeploymentConfigsPreviewPlacementJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewPlacementJSON contains the JSON -// metadata for the struct -// [PageProjectGetResponseDeploymentConfigsPreviewPlacement] -type pageProjectGetResponseDeploymentConfigsPreviewPlacementJSON struct { - Mode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewPlacement) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewPlacementJSON) RawJSON() string { - return r.raw -} - -// Queue Producer bindings used for Pages Functions. -type PageProjectGetResponseDeploymentConfigsPreviewQueueProducers struct { - // Queue Producer binding. - QueueProducerBinding PageProjectGetResponseDeploymentConfigsPreviewQueueProducersQueueProducerBinding `json:"QUEUE_PRODUCER_BINDING"` - JSON pageProjectGetResponseDeploymentConfigsPreviewQueueProducersJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewQueueProducersJSON contains the -// JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsPreviewQueueProducers] -type pageProjectGetResponseDeploymentConfigsPreviewQueueProducersJSON struct { - QueueProducerBinding apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewQueueProducers) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewQueueProducersJSON) RawJSON() string { - return r.raw -} - -// Queue Producer binding. -type PageProjectGetResponseDeploymentConfigsPreviewQueueProducersQueueProducerBinding struct { - // Name of the Queue. - Name string `json:"name"` - JSON pageProjectGetResponseDeploymentConfigsPreviewQueueProducersQueueProducerBindingJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewQueueProducersQueueProducerBindingJSON -// contains the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsPreviewQueueProducersQueueProducerBinding] -type pageProjectGetResponseDeploymentConfigsPreviewQueueProducersQueueProducerBindingJSON struct { - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewQueueProducersQueueProducerBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewQueueProducersQueueProducerBindingJSON) RawJSON() string { - return r.raw -} - -// R2 buckets used for Pages Functions. -type PageProjectGetResponseDeploymentConfigsPreviewR2Buckets struct { - // R2 binding. - R2Binding PageProjectGetResponseDeploymentConfigsPreviewR2BucketsR2Binding `json:"R2_BINDING"` - JSON pageProjectGetResponseDeploymentConfigsPreviewR2BucketsJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewR2BucketsJSON contains the JSON -// metadata for the struct -// [PageProjectGetResponseDeploymentConfigsPreviewR2Buckets] -type pageProjectGetResponseDeploymentConfigsPreviewR2BucketsJSON struct { - R2Binding apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewR2Buckets) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewR2BucketsJSON) RawJSON() string { - return r.raw -} - -// R2 binding. -type PageProjectGetResponseDeploymentConfigsPreviewR2BucketsR2Binding struct { - // Name of the R2 bucket. - Name string `json:"name"` - JSON pageProjectGetResponseDeploymentConfigsPreviewR2BucketsR2BindingJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewR2BucketsR2BindingJSON contains -// the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsPreviewR2BucketsR2Binding] -type pageProjectGetResponseDeploymentConfigsPreviewR2BucketsR2BindingJSON struct { - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewR2BucketsR2Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewR2BucketsR2BindingJSON) RawJSON() string { - return r.raw -} - -// Services used for Pages Functions. -type PageProjectGetResponseDeploymentConfigsPreviewServiceBindings struct { - // Service binding. - ServiceBinding PageProjectGetResponseDeploymentConfigsPreviewServiceBindingsServiceBinding `json:"SERVICE_BINDING"` - JSON pageProjectGetResponseDeploymentConfigsPreviewServiceBindingsJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewServiceBindingsJSON contains the -// JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsPreviewServiceBindings] -type pageProjectGetResponseDeploymentConfigsPreviewServiceBindingsJSON struct { - ServiceBinding apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewServiceBindings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewServiceBindingsJSON) RawJSON() string { - return r.raw -} - -// Service binding. -type PageProjectGetResponseDeploymentConfigsPreviewServiceBindingsServiceBinding struct { - // The Service environment. - Environment string `json:"environment"` - // The Service name. - Service string `json:"service"` - JSON pageProjectGetResponseDeploymentConfigsPreviewServiceBindingsServiceBindingJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsPreviewServiceBindingsServiceBindingJSON -// contains the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsPreviewServiceBindingsServiceBinding] -type pageProjectGetResponseDeploymentConfigsPreviewServiceBindingsServiceBindingJSON struct { - Environment apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsPreviewServiceBindingsServiceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsPreviewServiceBindingsServiceBindingJSON) RawJSON() string { - return r.raw -} - -// Configs for production deploys. -type PageProjectGetResponseDeploymentConfigsProduction struct { - // Constellation bindings used for Pages Functions. - AIBindings PageProjectGetResponseDeploymentConfigsProductionAIBindings `json:"ai_bindings,nullable"` - // Analytics Engine bindings used for Pages Functions. - AnalyticsEngineDatasets PageProjectGetResponseDeploymentConfigsProductionAnalyticsEngineDatasets `json:"analytics_engine_datasets,nullable"` - // Compatibility date used for Pages Functions. - CompatibilityDate string `json:"compatibility_date"` - // Compatibility flags used for Pages Functions. - CompatibilityFlags []interface{} `json:"compatibility_flags"` - // D1 databases used for Pages Functions. - D1Databases PageProjectGetResponseDeploymentConfigsProductionD1Databases `json:"d1_databases,nullable"` - // Durabble Object namespaces used for Pages Functions. - DurableObjectNamespaces PageProjectGetResponseDeploymentConfigsProductionDurableObjectNamespaces `json:"durable_object_namespaces,nullable"` - // Environment variables for build configs. - EnvVars PageProjectGetResponseDeploymentConfigsProductionEnvVars `json:"env_vars,nullable"` - // KV namespaces used for Pages Functions. - KVNamespaces PageProjectGetResponseDeploymentConfigsProductionKVNamespaces `json:"kv_namespaces"` - // Placement setting used for Pages Functions. - Placement PageProjectGetResponseDeploymentConfigsProductionPlacement `json:"placement,nullable"` - // Queue Producer bindings used for Pages Functions. - QueueProducers PageProjectGetResponseDeploymentConfigsProductionQueueProducers `json:"queue_producers,nullable"` - // R2 buckets used for Pages Functions. - R2Buckets PageProjectGetResponseDeploymentConfigsProductionR2Buckets `json:"r2_buckets,nullable"` - // Services used for Pages Functions. - ServiceBindings PageProjectGetResponseDeploymentConfigsProductionServiceBindings `json:"service_bindings,nullable"` - JSON pageProjectGetResponseDeploymentConfigsProductionJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionJSON contains the JSON metadata -// for the struct [PageProjectGetResponseDeploymentConfigsProduction] -type pageProjectGetResponseDeploymentConfigsProductionJSON struct { - AIBindings apijson.Field - AnalyticsEngineDatasets apijson.Field - CompatibilityDate apijson.Field - CompatibilityFlags apijson.Field - D1Databases apijson.Field - DurableObjectNamespaces apijson.Field - EnvVars apijson.Field - KVNamespaces apijson.Field - Placement apijson.Field - QueueProducers apijson.Field - R2Buckets apijson.Field - ServiceBindings apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProduction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionJSON) RawJSON() string { - return r.raw -} - -// Constellation bindings used for Pages Functions. -type PageProjectGetResponseDeploymentConfigsProductionAIBindings struct { - // AI binding. - AIBinding PageProjectGetResponseDeploymentConfigsProductionAIBindingsAIBinding `json:"AI_BINDING"` - JSON pageProjectGetResponseDeploymentConfigsProductionAIBindingsJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionAIBindingsJSON contains the -// JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionAIBindings] -type pageProjectGetResponseDeploymentConfigsProductionAIBindingsJSON struct { - AIBinding apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionAIBindings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionAIBindingsJSON) RawJSON() string { - return r.raw -} - -// AI binding. -type PageProjectGetResponseDeploymentConfigsProductionAIBindingsAIBinding struct { - ProjectID interface{} `json:"project_id"` - JSON pageProjectGetResponseDeploymentConfigsProductionAIBindingsAIBindingJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionAIBindingsAIBindingJSON -// contains the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionAIBindingsAIBinding] -type pageProjectGetResponseDeploymentConfigsProductionAIBindingsAIBindingJSON struct { - ProjectID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionAIBindingsAIBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionAIBindingsAIBindingJSON) RawJSON() string { - return r.raw -} - -// Analytics Engine bindings used for Pages Functions. -type PageProjectGetResponseDeploymentConfigsProductionAnalyticsEngineDatasets struct { - // Analytics Engine binding. - AnalyticsEngineBinding PageProjectGetResponseDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding `json:"ANALYTICS_ENGINE_BINDING"` - JSON pageProjectGetResponseDeploymentConfigsProductionAnalyticsEngineDatasetsJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionAnalyticsEngineDatasetsJSON -// contains the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionAnalyticsEngineDatasets] -type pageProjectGetResponseDeploymentConfigsProductionAnalyticsEngineDatasetsJSON struct { - AnalyticsEngineBinding apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionAnalyticsEngineDatasets) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionAnalyticsEngineDatasetsJSON) RawJSON() string { - return r.raw -} - -// Analytics Engine binding. -type PageProjectGetResponseDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding struct { - // Name of the dataset. - Dataset string `json:"dataset"` - JSON pageProjectGetResponseDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingJSON -// contains the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding] -type pageProjectGetResponseDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingJSON struct { - Dataset apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingJSON) RawJSON() string { - return r.raw -} - -// D1 databases used for Pages Functions. -type PageProjectGetResponseDeploymentConfigsProductionD1Databases struct { - // D1 binding. - D1Binding PageProjectGetResponseDeploymentConfigsProductionD1DatabasesD1Binding `json:"D1_BINDING"` - JSON pageProjectGetResponseDeploymentConfigsProductionD1DatabasesJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionD1DatabasesJSON contains the -// JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionD1Databases] -type pageProjectGetResponseDeploymentConfigsProductionD1DatabasesJSON struct { - D1Binding apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionD1Databases) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionD1DatabasesJSON) RawJSON() string { - return r.raw -} - -// D1 binding. -type PageProjectGetResponseDeploymentConfigsProductionD1DatabasesD1Binding struct { - // UUID of the D1 database. - ID string `json:"id"` - JSON pageProjectGetResponseDeploymentConfigsProductionD1DatabasesD1BindingJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionD1DatabasesD1BindingJSON -// contains the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionD1DatabasesD1Binding] -type pageProjectGetResponseDeploymentConfigsProductionD1DatabasesD1BindingJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionD1DatabasesD1Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionD1DatabasesD1BindingJSON) RawJSON() string { - return r.raw -} - -// Durabble Object namespaces used for Pages Functions. -type PageProjectGetResponseDeploymentConfigsProductionDurableObjectNamespaces struct { - // Durabble Object binding. - DoBinding PageProjectGetResponseDeploymentConfigsProductionDurableObjectNamespacesDoBinding `json:"DO_BINDING"` - JSON pageProjectGetResponseDeploymentConfigsProductionDurableObjectNamespacesJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionDurableObjectNamespacesJSON -// contains the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionDurableObjectNamespaces] -type pageProjectGetResponseDeploymentConfigsProductionDurableObjectNamespacesJSON struct { - DoBinding apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionDurableObjectNamespaces) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionDurableObjectNamespacesJSON) RawJSON() string { - return r.raw -} - -// Durabble Object binding. -type PageProjectGetResponseDeploymentConfigsProductionDurableObjectNamespacesDoBinding struct { - // ID of the Durabble Object namespace. - NamespaceID string `json:"namespace_id"` - JSON pageProjectGetResponseDeploymentConfigsProductionDurableObjectNamespacesDoBindingJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionDurableObjectNamespacesDoBindingJSON -// contains the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionDurableObjectNamespacesDoBinding] -type pageProjectGetResponseDeploymentConfigsProductionDurableObjectNamespacesDoBindingJSON struct { - NamespaceID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionDurableObjectNamespacesDoBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionDurableObjectNamespacesDoBindingJSON) RawJSON() string { - return r.raw -} - -// Environment variables for build configs. -type PageProjectGetResponseDeploymentConfigsProductionEnvVars struct { - // Environment variable. - EnvironmentVariable PageProjectGetResponseDeploymentConfigsProductionEnvVarsEnvironmentVariable `json:"ENVIRONMENT_VARIABLE"` - JSON pageProjectGetResponseDeploymentConfigsProductionEnvVarsJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionEnvVarsJSON contains the JSON -// metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionEnvVars] -type pageProjectGetResponseDeploymentConfigsProductionEnvVarsJSON struct { - EnvironmentVariable apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionEnvVars) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionEnvVarsJSON) RawJSON() string { - return r.raw -} - -// Environment variable. -type PageProjectGetResponseDeploymentConfigsProductionEnvVarsEnvironmentVariable struct { - // The type of environment variable (plain text or secret) - Type PageProjectGetResponseDeploymentConfigsProductionEnvVarsEnvironmentVariableType `json:"type"` - // Environment variable value. - Value string `json:"value"` - JSON pageProjectGetResponseDeploymentConfigsProductionEnvVarsEnvironmentVariableJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionEnvVarsEnvironmentVariableJSON -// contains the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionEnvVarsEnvironmentVariable] -type pageProjectGetResponseDeploymentConfigsProductionEnvVarsEnvironmentVariableJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionEnvVarsEnvironmentVariable) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionEnvVarsEnvironmentVariableJSON) RawJSON() string { - return r.raw -} - -// The type of environment variable (plain text or secret) -type PageProjectGetResponseDeploymentConfigsProductionEnvVarsEnvironmentVariableType string - -const ( - PageProjectGetResponseDeploymentConfigsProductionEnvVarsEnvironmentVariableTypePlainText PageProjectGetResponseDeploymentConfigsProductionEnvVarsEnvironmentVariableType = "plain_text" - PageProjectGetResponseDeploymentConfigsProductionEnvVarsEnvironmentVariableTypeSecretText PageProjectGetResponseDeploymentConfigsProductionEnvVarsEnvironmentVariableType = "secret_text" -) - -// KV namespaces used for Pages Functions. -type PageProjectGetResponseDeploymentConfigsProductionKVNamespaces struct { - // KV binding. - KVBinding PageProjectGetResponseDeploymentConfigsProductionKVNamespacesKVBinding `json:"KV_BINDING"` - JSON pageProjectGetResponseDeploymentConfigsProductionKVNamespacesJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionKVNamespacesJSON contains the -// JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionKVNamespaces] -type pageProjectGetResponseDeploymentConfigsProductionKVNamespacesJSON struct { - KVBinding apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionKVNamespaces) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionKVNamespacesJSON) RawJSON() string { - return r.raw -} - -// KV binding. -type PageProjectGetResponseDeploymentConfigsProductionKVNamespacesKVBinding struct { - // ID of the KV namespace. - NamespaceID string `json:"namespace_id"` - JSON pageProjectGetResponseDeploymentConfigsProductionKVNamespacesKVBindingJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionKVNamespacesKVBindingJSON -// contains the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionKVNamespacesKVBinding] -type pageProjectGetResponseDeploymentConfigsProductionKVNamespacesKVBindingJSON struct { - NamespaceID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionKVNamespacesKVBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionKVNamespacesKVBindingJSON) RawJSON() string { - return r.raw -} - -// Placement setting used for Pages Functions. -type PageProjectGetResponseDeploymentConfigsProductionPlacement struct { - // Placement mode. - Mode string `json:"mode"` - JSON pageProjectGetResponseDeploymentConfigsProductionPlacementJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionPlacementJSON contains the JSON -// metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionPlacement] -type pageProjectGetResponseDeploymentConfigsProductionPlacementJSON struct { - Mode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionPlacement) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionPlacementJSON) RawJSON() string { - return r.raw -} - -// Queue Producer bindings used for Pages Functions. -type PageProjectGetResponseDeploymentConfigsProductionQueueProducers struct { - // Queue Producer binding. - QueueProducerBinding PageProjectGetResponseDeploymentConfigsProductionQueueProducersQueueProducerBinding `json:"QUEUE_PRODUCER_BINDING"` - JSON pageProjectGetResponseDeploymentConfigsProductionQueueProducersJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionQueueProducersJSON contains the -// JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionQueueProducers] -type pageProjectGetResponseDeploymentConfigsProductionQueueProducersJSON struct { - QueueProducerBinding apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionQueueProducers) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionQueueProducersJSON) RawJSON() string { - return r.raw -} - -// Queue Producer binding. -type PageProjectGetResponseDeploymentConfigsProductionQueueProducersQueueProducerBinding struct { - // Name of the Queue. - Name string `json:"name"` - JSON pageProjectGetResponseDeploymentConfigsProductionQueueProducersQueueProducerBindingJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionQueueProducersQueueProducerBindingJSON -// contains the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionQueueProducersQueueProducerBinding] -type pageProjectGetResponseDeploymentConfigsProductionQueueProducersQueueProducerBindingJSON struct { - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionQueueProducersQueueProducerBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionQueueProducersQueueProducerBindingJSON) RawJSON() string { - return r.raw -} - -// R2 buckets used for Pages Functions. -type PageProjectGetResponseDeploymentConfigsProductionR2Buckets struct { - // R2 binding. - R2Binding PageProjectGetResponseDeploymentConfigsProductionR2BucketsR2Binding `json:"R2_BINDING"` - JSON pageProjectGetResponseDeploymentConfigsProductionR2BucketsJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionR2BucketsJSON contains the JSON -// metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionR2Buckets] -type pageProjectGetResponseDeploymentConfigsProductionR2BucketsJSON struct { - R2Binding apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionR2Buckets) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionR2BucketsJSON) RawJSON() string { - return r.raw -} - -// R2 binding. -type PageProjectGetResponseDeploymentConfigsProductionR2BucketsR2Binding struct { - // Name of the R2 bucket. - Name string `json:"name"` - JSON pageProjectGetResponseDeploymentConfigsProductionR2BucketsR2BindingJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionR2BucketsR2BindingJSON contains -// the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionR2BucketsR2Binding] -type pageProjectGetResponseDeploymentConfigsProductionR2BucketsR2BindingJSON struct { - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionR2BucketsR2Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionR2BucketsR2BindingJSON) RawJSON() string { - return r.raw -} - -// Services used for Pages Functions. -type PageProjectGetResponseDeploymentConfigsProductionServiceBindings struct { - // Service binding. - ServiceBinding PageProjectGetResponseDeploymentConfigsProductionServiceBindingsServiceBinding `json:"SERVICE_BINDING"` - JSON pageProjectGetResponseDeploymentConfigsProductionServiceBindingsJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionServiceBindingsJSON contains -// the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionServiceBindings] -type pageProjectGetResponseDeploymentConfigsProductionServiceBindingsJSON struct { - ServiceBinding apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionServiceBindings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionServiceBindingsJSON) RawJSON() string { - return r.raw -} - -// Service binding. -type PageProjectGetResponseDeploymentConfigsProductionServiceBindingsServiceBinding struct { - // The Service environment. - Environment string `json:"environment"` - // The Service name. - Service string `json:"service"` - JSON pageProjectGetResponseDeploymentConfigsProductionServiceBindingsServiceBindingJSON `json:"-"` -} - -// pageProjectGetResponseDeploymentConfigsProductionServiceBindingsServiceBindingJSON -// contains the JSON metadata for the struct -// [PageProjectGetResponseDeploymentConfigsProductionServiceBindingsServiceBinding] -type pageProjectGetResponseDeploymentConfigsProductionServiceBindingsServiceBindingJSON struct { - Environment apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseDeploymentConfigsProductionServiceBindingsServiceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseDeploymentConfigsProductionServiceBindingsServiceBindingJSON) RawJSON() string { - return r.raw -} - -type PageProjectGetResponseLatestDeployment struct { - // Id of the deployment. - ID string `json:"id"` - // A list of alias URLs pointing to this deployment. - Aliases []interface{} `json:"aliases,nullable"` - BuildConfig interface{} `json:"build_config"` - // When the deployment was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Info about what caused the deployment. - DeploymentTrigger PageProjectGetResponseLatestDeploymentDeploymentTrigger `json:"deployment_trigger"` - // A dict of env variables to build this deploy. - EnvVars interface{} `json:"env_vars"` - // Type of deploy. - Environment string `json:"environment"` - // If the deployment has been skipped. - IsSkipped bool `json:"is_skipped"` - LatestStage interface{} `json:"latest_stage"` - // When the deployment was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Id of the project. - ProjectID string `json:"project_id"` - // Name of the project. - ProjectName string `json:"project_name"` - // Short Id (8 character) of the deployment. - ShortID string `json:"short_id"` - Source interface{} `json:"source"` - // List of past stages. - Stages []PageProjectGetResponseLatestDeploymentStage `json:"stages"` - // The live URL to view this deployment. - URL string `json:"url"` - JSON pageProjectGetResponseLatestDeploymentJSON `json:"-"` -} - -// pageProjectGetResponseLatestDeploymentJSON contains the JSON metadata for the -// struct [PageProjectGetResponseLatestDeployment] -type pageProjectGetResponseLatestDeploymentJSON struct { - ID apijson.Field - Aliases apijson.Field - BuildConfig apijson.Field - CreatedOn apijson.Field - DeploymentTrigger apijson.Field - EnvVars apijson.Field - Environment apijson.Field - IsSkipped apijson.Field - LatestStage apijson.Field - ModifiedOn apijson.Field - ProjectID apijson.Field - ProjectName apijson.Field - ShortID apijson.Field - Source apijson.Field - Stages apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseLatestDeployment) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseLatestDeploymentJSON) RawJSON() string { - return r.raw -} - -// Info about what caused the deployment. -type PageProjectGetResponseLatestDeploymentDeploymentTrigger struct { - // Additional info about the trigger. - Metadata PageProjectGetResponseLatestDeploymentDeploymentTriggerMetadata `json:"metadata"` - // What caused the deployment. - Type string `json:"type"` - JSON pageProjectGetResponseLatestDeploymentDeploymentTriggerJSON `json:"-"` -} - -// pageProjectGetResponseLatestDeploymentDeploymentTriggerJSON contains the JSON -// metadata for the struct -// [PageProjectGetResponseLatestDeploymentDeploymentTrigger] -type pageProjectGetResponseLatestDeploymentDeploymentTriggerJSON struct { - Metadata apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseLatestDeploymentDeploymentTrigger) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseLatestDeploymentDeploymentTriggerJSON) RawJSON() string { - return r.raw -} - -// Additional info about the trigger. -type PageProjectGetResponseLatestDeploymentDeploymentTriggerMetadata struct { - // Where the trigger happened. - Branch string `json:"branch"` - // Hash of the deployment trigger commit. - CommitHash string `json:"commit_hash"` - // Message of the deployment trigger commit. - CommitMessage string `json:"commit_message"` - JSON pageProjectGetResponseLatestDeploymentDeploymentTriggerMetadataJSON `json:"-"` -} - -// pageProjectGetResponseLatestDeploymentDeploymentTriggerMetadataJSON contains the -// JSON metadata for the struct -// [PageProjectGetResponseLatestDeploymentDeploymentTriggerMetadata] -type pageProjectGetResponseLatestDeploymentDeploymentTriggerMetadataJSON struct { - Branch apijson.Field - CommitHash apijson.Field - CommitMessage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseLatestDeploymentDeploymentTriggerMetadata) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseLatestDeploymentDeploymentTriggerMetadataJSON) RawJSON() string { - return r.raw -} - -// The status of the deployment. -type PageProjectGetResponseLatestDeploymentStage struct { - // When the stage ended. - EndedOn time.Time `json:"ended_on,nullable" format:"date-time"` - // The current build stage. - Name string `json:"name"` - // When the stage started. - StartedOn time.Time `json:"started_on,nullable" format:"date-time"` - // State of the current stage. - Status string `json:"status"` - JSON pageProjectGetResponseLatestDeploymentStageJSON `json:"-"` -} - -// pageProjectGetResponseLatestDeploymentStageJSON contains the JSON metadata for -// the struct [PageProjectGetResponseLatestDeploymentStage] -type pageProjectGetResponseLatestDeploymentStageJSON struct { - EndedOn apijson.Field - Name apijson.Field - StartedOn apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseLatestDeploymentStage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseLatestDeploymentStageJSON) RawJSON() string { - return r.raw -} - -type PageProjectPurgeBuildCacheResponse = interface{} - -type PageProjectNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Configs for the project build process. - BuildConfig param.Field[PageProjectNewParamsBuildConfig] `json:"build_config"` - CanonicalDeployment param.Field[PageProjectNewParamsCanonicalDeployment] `json:"canonical_deployment"` - // Configs for deployments in a project. - DeploymentConfigs param.Field[PageProjectNewParamsDeploymentConfigs] `json:"deployment_configs"` - LatestDeployment param.Field[PageProjectNewParamsLatestDeployment] `json:"latest_deployment"` - // Name of the project. - Name param.Field[string] `json:"name"` - // Production branch of the project. Used to identify production deployments. - ProductionBranch param.Field[string] `json:"production_branch"` -} - -func (r PageProjectNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configs for the project build process. -type PageProjectNewParamsBuildConfig struct { - // Enable build caching for the project. - BuildCaching param.Field[bool] `json:"build_caching"` - // Command used to build project. - BuildCommand param.Field[string] `json:"build_command"` - // Output directory of the build. - DestinationDir param.Field[string] `json:"destination_dir"` - // Directory to run the command. - RootDir param.Field[string] `json:"root_dir"` - // The classifying tag for analytics. - WebAnalyticsTag param.Field[string] `json:"web_analytics_tag"` - // The auth token for analytics. - WebAnalyticsToken param.Field[string] `json:"web_analytics_token"` -} - -func (r PageProjectNewParamsBuildConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type PageProjectNewParamsCanonicalDeployment struct { -} - -func (r PageProjectNewParamsCanonicalDeployment) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Info about what caused the deployment. -type PageProjectNewParamsCanonicalDeploymentDeploymentTrigger struct { - // Additional info about the trigger. - Metadata param.Field[PageProjectNewParamsCanonicalDeploymentDeploymentTriggerMetadata] `json:"metadata"` -} - -func (r PageProjectNewParamsCanonicalDeploymentDeploymentTrigger) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Additional info about the trigger. -type PageProjectNewParamsCanonicalDeploymentDeploymentTriggerMetadata struct { -} - -func (r PageProjectNewParamsCanonicalDeploymentDeploymentTriggerMetadata) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The status of the deployment. -type PageProjectNewParamsCanonicalDeploymentStage struct { - // The current build stage. - Name param.Field[string] `json:"name"` -} - -func (r PageProjectNewParamsCanonicalDeploymentStage) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configs for deployments in a project. -type PageProjectNewParamsDeploymentConfigs struct { - // Configs for preview deploys. - Preview param.Field[PageProjectNewParamsDeploymentConfigsPreview] `json:"preview"` - // Configs for production deploys. - Production param.Field[PageProjectNewParamsDeploymentConfigsProduction] `json:"production"` -} - -func (r PageProjectNewParamsDeploymentConfigs) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configs for preview deploys. -type PageProjectNewParamsDeploymentConfigsPreview struct { - // Constellation bindings used for Pages Functions. - AIBindings param.Field[PageProjectNewParamsDeploymentConfigsPreviewAIBindings] `json:"ai_bindings"` - // Analytics Engine bindings used for Pages Functions. - AnalyticsEngineDatasets param.Field[PageProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasets] `json:"analytics_engine_datasets"` - // Compatibility date used for Pages Functions. - CompatibilityDate param.Field[string] `json:"compatibility_date"` - // Compatibility flags used for Pages Functions. - CompatibilityFlags param.Field[[]interface{}] `json:"compatibility_flags"` - // D1 databases used for Pages Functions. - D1Databases param.Field[PageProjectNewParamsDeploymentConfigsPreviewD1Databases] `json:"d1_databases"` - // Durabble Object namespaces used for Pages Functions. - DurableObjectNamespaces param.Field[PageProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespaces] `json:"durable_object_namespaces"` - // Environment variables for build configs. - EnvVars param.Field[PageProjectNewParamsDeploymentConfigsPreviewEnvVars] `json:"env_vars"` - // KV namespaces used for Pages Functions. - KVNamespaces param.Field[PageProjectNewParamsDeploymentConfigsPreviewKVNamespaces] `json:"kv_namespaces"` - // Placement setting used for Pages Functions. - Placement param.Field[PageProjectNewParamsDeploymentConfigsPreviewPlacement] `json:"placement"` - // Queue Producer bindings used for Pages Functions. - QueueProducers param.Field[PageProjectNewParamsDeploymentConfigsPreviewQueueProducers] `json:"queue_producers"` - // R2 buckets used for Pages Functions. - R2Buckets param.Field[PageProjectNewParamsDeploymentConfigsPreviewR2Buckets] `json:"r2_buckets"` - // Services used for Pages Functions. - ServiceBindings param.Field[PageProjectNewParamsDeploymentConfigsPreviewServiceBindings] `json:"service_bindings"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreview) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Constellation bindings used for Pages Functions. -type PageProjectNewParamsDeploymentConfigsPreviewAIBindings struct { - // AI binding. - AIBinding param.Field[PageProjectNewParamsDeploymentConfigsPreviewAIBindingsAIBinding] `json:"AI_BINDING"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewAIBindings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// AI binding. -type PageProjectNewParamsDeploymentConfigsPreviewAIBindingsAIBinding struct { - ProjectID param.Field[interface{}] `json:"project_id"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewAIBindingsAIBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Analytics Engine bindings used for Pages Functions. -type PageProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasets struct { - // Analytics Engine binding. - AnalyticsEngineBinding param.Field[PageProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding] `json:"ANALYTICS_ENGINE_BINDING"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasets) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Analytics Engine binding. -type PageProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding struct { - // Name of the dataset. - Dataset param.Field[string] `json:"dataset"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// D1 databases used for Pages Functions. -type PageProjectNewParamsDeploymentConfigsPreviewD1Databases struct { - // D1 binding. - D1Binding param.Field[PageProjectNewParamsDeploymentConfigsPreviewD1DatabasesD1Binding] `json:"D1_BINDING"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewD1Databases) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// D1 binding. -type PageProjectNewParamsDeploymentConfigsPreviewD1DatabasesD1Binding struct { - // UUID of the D1 database. - ID param.Field[string] `json:"id"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewD1DatabasesD1Binding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Durabble Object namespaces used for Pages Functions. -type PageProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespaces struct { - // Durabble Object binding. - DoBinding param.Field[PageProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding] `json:"DO_BINDING"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespaces) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Durabble Object binding. -type PageProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding struct { - // ID of the Durabble Object namespace. - NamespaceID param.Field[string] `json:"namespace_id"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Environment variables for build configs. -type PageProjectNewParamsDeploymentConfigsPreviewEnvVars struct { - // Environment variable. - EnvironmentVariable param.Field[PageProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariable] `json:"ENVIRONMENT_VARIABLE"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewEnvVars) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Environment variable. -type PageProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariable struct { - // The type of environment variable (plain text or secret) - Type param.Field[PageProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType] `json:"type"` - // Environment variable value. - Value param.Field[string] `json:"value"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariable) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of environment variable (plain text or secret) -type PageProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType string - -const ( - PageProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypePlainText PageProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType = "plain_text" - PageProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypeSecretText PageProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType = "secret_text" -) - -// KV namespaces used for Pages Functions. -type PageProjectNewParamsDeploymentConfigsPreviewKVNamespaces struct { - // KV binding. - KVBinding param.Field[PageProjectNewParamsDeploymentConfigsPreviewKVNamespacesKVBinding] `json:"KV_BINDING"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewKVNamespaces) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// KV binding. -type PageProjectNewParamsDeploymentConfigsPreviewKVNamespacesKVBinding struct { - // ID of the KV namespace. - NamespaceID param.Field[string] `json:"namespace_id"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewKVNamespacesKVBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Placement setting used for Pages Functions. -type PageProjectNewParamsDeploymentConfigsPreviewPlacement struct { - // Placement mode. - Mode param.Field[string] `json:"mode"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewPlacement) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Queue Producer bindings used for Pages Functions. -type PageProjectNewParamsDeploymentConfigsPreviewQueueProducers struct { - // Queue Producer binding. - QueueProducerBinding param.Field[PageProjectNewParamsDeploymentConfigsPreviewQueueProducersQueueProducerBinding] `json:"QUEUE_PRODUCER_BINDING"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewQueueProducers) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Queue Producer binding. -type PageProjectNewParamsDeploymentConfigsPreviewQueueProducersQueueProducerBinding struct { - // Name of the Queue. - Name param.Field[string] `json:"name"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewQueueProducersQueueProducerBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// R2 buckets used for Pages Functions. -type PageProjectNewParamsDeploymentConfigsPreviewR2Buckets struct { - // R2 binding. - R2Binding param.Field[PageProjectNewParamsDeploymentConfigsPreviewR2BucketsR2Binding] `json:"R2_BINDING"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewR2Buckets) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// R2 binding. -type PageProjectNewParamsDeploymentConfigsPreviewR2BucketsR2Binding struct { - // Name of the R2 bucket. - Name param.Field[string] `json:"name"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewR2BucketsR2Binding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Services used for Pages Functions. -type PageProjectNewParamsDeploymentConfigsPreviewServiceBindings struct { - // Service binding. - ServiceBinding param.Field[PageProjectNewParamsDeploymentConfigsPreviewServiceBindingsServiceBinding] `json:"SERVICE_BINDING"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewServiceBindings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Service binding. -type PageProjectNewParamsDeploymentConfigsPreviewServiceBindingsServiceBinding struct { - // The Service environment. - Environment param.Field[string] `json:"environment"` - // The Service name. - Service param.Field[string] `json:"service"` -} - -func (r PageProjectNewParamsDeploymentConfigsPreviewServiceBindingsServiceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configs for production deploys. -type PageProjectNewParamsDeploymentConfigsProduction struct { - // Constellation bindings used for Pages Functions. - AIBindings param.Field[PageProjectNewParamsDeploymentConfigsProductionAIBindings] `json:"ai_bindings"` - // Analytics Engine bindings used for Pages Functions. - AnalyticsEngineDatasets param.Field[PageProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasets] `json:"analytics_engine_datasets"` - // Compatibility date used for Pages Functions. - CompatibilityDate param.Field[string] `json:"compatibility_date"` - // Compatibility flags used for Pages Functions. - CompatibilityFlags param.Field[[]interface{}] `json:"compatibility_flags"` - // D1 databases used for Pages Functions. - D1Databases param.Field[PageProjectNewParamsDeploymentConfigsProductionD1Databases] `json:"d1_databases"` - // Durabble Object namespaces used for Pages Functions. - DurableObjectNamespaces param.Field[PageProjectNewParamsDeploymentConfigsProductionDurableObjectNamespaces] `json:"durable_object_namespaces"` - // Environment variables for build configs. - EnvVars param.Field[PageProjectNewParamsDeploymentConfigsProductionEnvVars] `json:"env_vars"` - // KV namespaces used for Pages Functions. - KVNamespaces param.Field[PageProjectNewParamsDeploymentConfigsProductionKVNamespaces] `json:"kv_namespaces"` - // Placement setting used for Pages Functions. - Placement param.Field[PageProjectNewParamsDeploymentConfigsProductionPlacement] `json:"placement"` - // Queue Producer bindings used for Pages Functions. - QueueProducers param.Field[PageProjectNewParamsDeploymentConfigsProductionQueueProducers] `json:"queue_producers"` - // R2 buckets used for Pages Functions. - R2Buckets param.Field[PageProjectNewParamsDeploymentConfigsProductionR2Buckets] `json:"r2_buckets"` - // Services used for Pages Functions. - ServiceBindings param.Field[PageProjectNewParamsDeploymentConfigsProductionServiceBindings] `json:"service_bindings"` -} - -func (r PageProjectNewParamsDeploymentConfigsProduction) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Constellation bindings used for Pages Functions. -type PageProjectNewParamsDeploymentConfigsProductionAIBindings struct { - // AI binding. - AIBinding param.Field[PageProjectNewParamsDeploymentConfigsProductionAIBindingsAIBinding] `json:"AI_BINDING"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionAIBindings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// AI binding. -type PageProjectNewParamsDeploymentConfigsProductionAIBindingsAIBinding struct { - ProjectID param.Field[interface{}] `json:"project_id"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionAIBindingsAIBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Analytics Engine bindings used for Pages Functions. -type PageProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasets struct { - // Analytics Engine binding. - AnalyticsEngineBinding param.Field[PageProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding] `json:"ANALYTICS_ENGINE_BINDING"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasets) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Analytics Engine binding. -type PageProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding struct { - // Name of the dataset. - Dataset param.Field[string] `json:"dataset"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// D1 databases used for Pages Functions. -type PageProjectNewParamsDeploymentConfigsProductionD1Databases struct { - // D1 binding. - D1Binding param.Field[PageProjectNewParamsDeploymentConfigsProductionD1DatabasesD1Binding] `json:"D1_BINDING"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionD1Databases) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// D1 binding. -type PageProjectNewParamsDeploymentConfigsProductionD1DatabasesD1Binding struct { - // UUID of the D1 database. - ID param.Field[string] `json:"id"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionD1DatabasesD1Binding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Durabble Object namespaces used for Pages Functions. -type PageProjectNewParamsDeploymentConfigsProductionDurableObjectNamespaces struct { - // Durabble Object binding. - DoBinding param.Field[PageProjectNewParamsDeploymentConfigsProductionDurableObjectNamespacesDoBinding] `json:"DO_BINDING"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionDurableObjectNamespaces) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Durabble Object binding. -type PageProjectNewParamsDeploymentConfigsProductionDurableObjectNamespacesDoBinding struct { - // ID of the Durabble Object namespace. - NamespaceID param.Field[string] `json:"namespace_id"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionDurableObjectNamespacesDoBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Environment variables for build configs. -type PageProjectNewParamsDeploymentConfigsProductionEnvVars struct { - // Environment variable. - EnvironmentVariable param.Field[PageProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariable] `json:"ENVIRONMENT_VARIABLE"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionEnvVars) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Environment variable. -type PageProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariable struct { - // The type of environment variable (plain text or secret) - Type param.Field[PageProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableType] `json:"type"` - // Environment variable value. - Value param.Field[string] `json:"value"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariable) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of environment variable (plain text or secret) -type PageProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableType string - -const ( - PageProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableTypePlainText PageProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableType = "plain_text" - PageProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableTypeSecretText PageProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableType = "secret_text" -) - -// KV namespaces used for Pages Functions. -type PageProjectNewParamsDeploymentConfigsProductionKVNamespaces struct { - // KV binding. - KVBinding param.Field[PageProjectNewParamsDeploymentConfigsProductionKVNamespacesKVBinding] `json:"KV_BINDING"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionKVNamespaces) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// KV binding. -type PageProjectNewParamsDeploymentConfigsProductionKVNamespacesKVBinding struct { - // ID of the KV namespace. - NamespaceID param.Field[string] `json:"namespace_id"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionKVNamespacesKVBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Placement setting used for Pages Functions. -type PageProjectNewParamsDeploymentConfigsProductionPlacement struct { - // Placement mode. - Mode param.Field[string] `json:"mode"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionPlacement) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Queue Producer bindings used for Pages Functions. -type PageProjectNewParamsDeploymentConfigsProductionQueueProducers struct { - // Queue Producer binding. - QueueProducerBinding param.Field[PageProjectNewParamsDeploymentConfigsProductionQueueProducersQueueProducerBinding] `json:"QUEUE_PRODUCER_BINDING"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionQueueProducers) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Queue Producer binding. -type PageProjectNewParamsDeploymentConfigsProductionQueueProducersQueueProducerBinding struct { - // Name of the Queue. - Name param.Field[string] `json:"name"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionQueueProducersQueueProducerBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// R2 buckets used for Pages Functions. -type PageProjectNewParamsDeploymentConfigsProductionR2Buckets struct { - // R2 binding. - R2Binding param.Field[PageProjectNewParamsDeploymentConfigsProductionR2BucketsR2Binding] `json:"R2_BINDING"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionR2Buckets) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// R2 binding. -type PageProjectNewParamsDeploymentConfigsProductionR2BucketsR2Binding struct { - // Name of the R2 bucket. - Name param.Field[string] `json:"name"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionR2BucketsR2Binding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Services used for Pages Functions. -type PageProjectNewParamsDeploymentConfigsProductionServiceBindings struct { - // Service binding. - ServiceBinding param.Field[PageProjectNewParamsDeploymentConfigsProductionServiceBindingsServiceBinding] `json:"SERVICE_BINDING"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionServiceBindings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Service binding. -type PageProjectNewParamsDeploymentConfigsProductionServiceBindingsServiceBinding struct { - // The Service environment. - Environment param.Field[string] `json:"environment"` - // The Service name. - Service param.Field[string] `json:"service"` -} - -func (r PageProjectNewParamsDeploymentConfigsProductionServiceBindingsServiceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type PageProjectNewParamsLatestDeployment struct { -} - -func (r PageProjectNewParamsLatestDeployment) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Info about what caused the deployment. -type PageProjectNewParamsLatestDeploymentDeploymentTrigger struct { - // Additional info about the trigger. - Metadata param.Field[PageProjectNewParamsLatestDeploymentDeploymentTriggerMetadata] `json:"metadata"` -} - -func (r PageProjectNewParamsLatestDeploymentDeploymentTrigger) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Additional info about the trigger. -type PageProjectNewParamsLatestDeploymentDeploymentTriggerMetadata struct { -} - -func (r PageProjectNewParamsLatestDeploymentDeploymentTriggerMetadata) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The status of the deployment. -type PageProjectNewParamsLatestDeploymentStage struct { - // The current build stage. - Name param.Field[string] `json:"name"` -} - -func (r PageProjectNewParamsLatestDeploymentStage) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type PageProjectNewResponseEnvelope struct { - Errors []PageProjectNewResponseEnvelopeErrors `json:"errors,required"` - Messages []PageProjectNewResponseEnvelopeMessages `json:"messages,required"` - Result PageProjectNewResponse `json:"result,required"` - // Whether the API call was successful - Success PageProjectNewResponseEnvelopeSuccess `json:"success,required"` - JSON pageProjectNewResponseEnvelopeJSON `json:"-"` -} - -// pageProjectNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [PageProjectNewResponseEnvelope] -type pageProjectNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PageProjectNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageProjectNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PageProjectNewResponseEnvelopeErrors] -type pageProjectNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageProjectNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageProjectNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PageProjectNewResponseEnvelopeMessages] -type pageProjectNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PageProjectNewResponseEnvelopeSuccess bool - -const ( - PageProjectNewResponseEnvelopeSuccessTrue PageProjectNewResponseEnvelopeSuccess = true -) - -type PageProjectListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type PageProjectListResponseEnvelope struct { - Errors []PageProjectListResponseEnvelopeErrors `json:"errors,required"` - Messages []PageProjectListResponseEnvelopeMessages `json:"messages,required"` - Result []PageProjectListResponse `json:"result,required"` - // Whether the API call was successful - Success PageProjectListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo PageProjectListResponseEnvelopeResultInfo `json:"result_info"` - JSON pageProjectListResponseEnvelopeJSON `json:"-"` -} - -// pageProjectListResponseEnvelopeJSON contains the JSON metadata for the struct -// [PageProjectListResponseEnvelope] -type pageProjectListResponseEnvelopeJSON 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 *PageProjectListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PageProjectListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectListResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageProjectListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PageProjectListResponseEnvelopeErrors] -type pageProjectListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageProjectListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectListResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageProjectListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PageProjectListResponseEnvelopeMessages] -type pageProjectListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PageProjectListResponseEnvelopeSuccess bool - -const ( - PageProjectListResponseEnvelopeSuccessTrue PageProjectListResponseEnvelopeSuccess = true -) - -type PageProjectListResponseEnvelopeResultInfo struct { - Count interface{} `json:"count"` - Page interface{} `json:"page"` - PerPage interface{} `json:"per_page"` - TotalCount interface{} `json:"total_count"` - JSON pageProjectListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// pageProjectListResponseEnvelopeResultInfoJSON contains the JSON metadata for the -// struct [PageProjectListResponseEnvelopeResultInfo] -type pageProjectListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type PageProjectEditParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` -} - -func (r PageProjectEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type PageProjectEditResponseEnvelope struct { - Errors []PageProjectEditResponseEnvelopeErrors `json:"errors,required"` - Messages []PageProjectEditResponseEnvelopeMessages `json:"messages,required"` - Result PageProjectEditResponse `json:"result,required"` - // Whether the API call was successful - Success PageProjectEditResponseEnvelopeSuccess `json:"success,required"` - JSON pageProjectEditResponseEnvelopeJSON `json:"-"` -} - -// pageProjectEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [PageProjectEditResponseEnvelope] -type pageProjectEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PageProjectEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageProjectEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PageProjectEditResponseEnvelopeErrors] -type pageProjectEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageProjectEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageProjectEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PageProjectEditResponseEnvelopeMessages] -type pageProjectEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PageProjectEditResponseEnvelopeSuccess bool - -const ( - PageProjectEditResponseEnvelopeSuccessTrue PageProjectEditResponseEnvelopeSuccess = true -) - -type PageProjectGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type PageProjectGetResponseEnvelope struct { - Errors []PageProjectGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PageProjectGetResponseEnvelopeMessages `json:"messages,required"` - Result PageProjectGetResponse `json:"result,required"` - // Whether the API call was successful - Success PageProjectGetResponseEnvelopeSuccess `json:"success,required"` - JSON pageProjectGetResponseEnvelopeJSON `json:"-"` -} - -// pageProjectGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [PageProjectGetResponseEnvelope] -type pageProjectGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PageProjectGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageProjectGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PageProjectGetResponseEnvelopeErrors] -type pageProjectGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageProjectGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageProjectGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PageProjectGetResponseEnvelopeMessages] -type pageProjectGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PageProjectGetResponseEnvelopeSuccess bool - -const ( - PageProjectGetResponseEnvelopeSuccessTrue PageProjectGetResponseEnvelopeSuccess = true -) - -type PageProjectPurgeBuildCacheParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} diff --git a/pageproject_test.go b/pageproject_test.go deleted file mode 100644 index 2e06c4bd767..00000000000 --- a/pageproject_test.go +++ /dev/null @@ -1,328 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestPageProjectNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Pages.Projects.New(context.TODO(), cloudflare.PageProjectNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - BuildConfig: cloudflare.F(cloudflare.PageProjectNewParamsBuildConfig{ - BuildCaching: cloudflare.F(true), - BuildCommand: cloudflare.F("npm run build"), - DestinationDir: cloudflare.F("build"), - RootDir: cloudflare.F("/"), - WebAnalyticsTag: cloudflare.F("cee1c73f6e4743d0b5e6bb1a0bcaabcc"), - WebAnalyticsToken: cloudflare.F("021e1057c18547eca7b79f2516f06o7x"), - }), - CanonicalDeployment: cloudflare.F(cloudflare.PageProjectNewParamsCanonicalDeployment{}), - DeploymentConfigs: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigs{ - Preview: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreview{ - AIBindings: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewAIBindings{ - AIBinding: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewAIBindingsAIBinding{ - ProjectID: cloudflare.F[any](map[string]interface{}{}), - }), - }), - AnalyticsEngineDatasets: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasets{ - AnalyticsEngineBinding: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding{ - Dataset: cloudflare.F("api_analytics"), - }), - }), - CompatibilityDate: cloudflare.F("2022-01-01"), - CompatibilityFlags: cloudflare.F([]interface{}{"url_standard"}), - D1Databases: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewD1Databases{ - D1Binding: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewD1DatabasesD1Binding{ - ID: cloudflare.F("445e2955-951a-43f8-a35b-a4d0c8138f63"), - }), - }), - DurableObjectNamespaces: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespaces{ - DoBinding: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding{ - NamespaceID: cloudflare.F("5eb63bbbe01eeed093cb22bb8f5acdc3"), - }), - }), - EnvVars: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewEnvVars{ - EnvironmentVariable: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariable{ - Type: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypePlainText), - Value: cloudflare.F("hello world"), - }), - }), - KVNamespaces: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewKVNamespaces{ - KVBinding: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewKVNamespacesKVBinding{ - NamespaceID: cloudflare.F("5eb63bbbe01eeed093cb22bb8f5acdc3"), - }), - }), - Placement: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewPlacement{ - Mode: cloudflare.F("smart"), - }), - QueueProducers: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewQueueProducers{ - QueueProducerBinding: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewQueueProducersQueueProducerBinding{ - Name: cloudflare.F("some-queue"), - }), - }), - R2Buckets: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewR2Buckets{ - R2Binding: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewR2BucketsR2Binding{ - Name: cloudflare.F("some-bucket"), - }), - }), - ServiceBindings: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewServiceBindings{ - ServiceBinding: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsPreviewServiceBindingsServiceBinding{ - Environment: cloudflare.F("production"), - Service: cloudflare.F("example-worker"), - }), - }), - }), - Production: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProduction{ - AIBindings: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionAIBindings{ - AIBinding: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionAIBindingsAIBinding{ - ProjectID: cloudflare.F[any](map[string]interface{}{}), - }), - }), - AnalyticsEngineDatasets: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasets{ - AnalyticsEngineBinding: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding{ - Dataset: cloudflare.F("api_analytics"), - }), - }), - CompatibilityDate: cloudflare.F("2022-01-01"), - CompatibilityFlags: cloudflare.F([]interface{}{"url_standard"}), - D1Databases: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionD1Databases{ - D1Binding: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionD1DatabasesD1Binding{ - ID: cloudflare.F("445e2955-951a-43f8-a35b-a4d0c8138f63"), - }), - }), - DurableObjectNamespaces: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionDurableObjectNamespaces{ - DoBinding: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionDurableObjectNamespacesDoBinding{ - NamespaceID: cloudflare.F("5eb63bbbe01eeed093cb22bb8f5acdc3"), - }), - }), - EnvVars: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionEnvVars{ - EnvironmentVariable: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariable{ - Type: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableTypePlainText), - Value: cloudflare.F("hello world"), - }), - }), - KVNamespaces: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionKVNamespaces{ - KVBinding: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionKVNamespacesKVBinding{ - NamespaceID: cloudflare.F("5eb63bbbe01eeed093cb22bb8f5acdc3"), - }), - }), - Placement: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionPlacement{ - Mode: cloudflare.F("smart"), - }), - QueueProducers: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionQueueProducers{ - QueueProducerBinding: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionQueueProducersQueueProducerBinding{ - Name: cloudflare.F("some-queue"), - }), - }), - R2Buckets: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionR2Buckets{ - R2Binding: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionR2BucketsR2Binding{ - Name: cloudflare.F("some-bucket"), - }), - }), - ServiceBindings: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionServiceBindings{ - ServiceBinding: cloudflare.F(cloudflare.PageProjectNewParamsDeploymentConfigsProductionServiceBindingsServiceBinding{ - Environment: cloudflare.F("production"), - Service: cloudflare.F("example-worker"), - }), - }), - }), - }), - LatestDeployment: cloudflare.F(cloudflare.PageProjectNewParamsLatestDeployment{}), - Name: cloudflare.F("NextJS Blog"), - ProductionBranch: cloudflare.F("main"), - }) - 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 TestPageProjectList(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("user@example.com"), - ) - _, err := client.Pages.Projects.List(context.TODO(), cloudflare.PageProjectListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestPageProjectDelete(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("user@example.com"), - ) - _, err := client.Pages.Projects.Delete( - context.TODO(), - "this-is-my-project-01", - cloudflare.PageProjectDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestPageProjectEdit(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("user@example.com"), - ) - _, err := client.Pages.Projects.Edit( - context.TODO(), - "this-is-my-project-01", - cloudflare.PageProjectEditParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F[any](map[string]interface{}{ - "deployment_configs": map[string]interface{}{ - "production": map[string]interface{}{ - "compatibility_date": "2022-01-01", - "compatibility_flags": map[string]interface{}{ - "0": "url_standard", - }, - "env_vars": map[string]interface{}{ - "BUILD_VERSION": map[string]interface{}{ - "value": "3.3", - }, - "delete_this_env_var": nil, - "secret_var": map[string]interface{}{ - "type": "secret_text", - "value": "A_CMS_API_TOKEN", - }, - }, - }, - }, - }), - }, - ) - 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 TestPageProjectGet(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("user@example.com"), - ) - _, err := client.Pages.Projects.Get( - context.TODO(), - "this-is-my-project-01", - cloudflare.PageProjectGetParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestPageProjectPurgeBuildCache(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("user@example.com"), - ) - _, err := client.Pages.Projects.PurgeBuildCache( - context.TODO(), - "this-is-my-project-01", - cloudflare.PageProjectPurgeBuildCacheParams{ - AccountID: cloudflare.F("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/pageprojectdeployment.go b/pageprojectdeployment.go deleted file mode 100644 index 76d17dc8176..00000000000 --- a/pageprojectdeployment.go +++ /dev/null @@ -1,1343 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// PageProjectDeploymentService 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 [NewPageProjectDeploymentService] -// method instead. -type PageProjectDeploymentService struct { - Options []option.RequestOption - History *PageProjectDeploymentHistoryService -} - -// NewPageProjectDeploymentService 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 NewPageProjectDeploymentService(opts ...option.RequestOption) (r *PageProjectDeploymentService) { - r = &PageProjectDeploymentService{} - r.Options = opts - r.History = NewPageProjectDeploymentHistoryService(opts...) - return -} - -// Start a new deployment from production. The repository and account must have -// already been authorized on the Cloudflare Pages dashboard. -func (r *PageProjectDeploymentService) New(ctx context.Context, projectName string, params PageProjectDeploymentNewParams, opts ...option.RequestOption) (res *PageProjectDeploymentNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env PageProjectDeploymentNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments", params.AccountID, projectName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch a list of project deployments. -func (r *PageProjectDeploymentService) List(ctx context.Context, projectName string, query PageProjectDeploymentListParams, opts ...option.RequestOption) (res *[]PageProjectDeploymentListResponse, err error) { - opts = append(r.Options[:], opts...) - var env PageProjectDeploymentListResponseEnvelope - path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments", query.AccountID, projectName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a deployment. -func (r *PageProjectDeploymentService) Delete(ctx context.Context, projectName string, deploymentID string, body PageProjectDeploymentDeleteParams, opts ...option.RequestOption) (res *PageProjectDeploymentDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments/%s", body.AccountID, projectName, deploymentID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &res, opts...) - return -} - -// Fetch information about a deployment. -func (r *PageProjectDeploymentService) Get(ctx context.Context, projectName string, deploymentID string, query PageProjectDeploymentGetParams, opts ...option.RequestOption) (res *PageProjectDeploymentGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env PageProjectDeploymentGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments/%s", query.AccountID, projectName, deploymentID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Retry a previous deployment. -func (r *PageProjectDeploymentService) Retry(ctx context.Context, projectName string, deploymentID string, body PageProjectDeploymentRetryParams, opts ...option.RequestOption) (res *PageProjectDeploymentRetryResponse, err error) { - opts = append(r.Options[:], opts...) - var env PageProjectDeploymentRetryResponseEnvelope - path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments/%s/retry", body.AccountID, projectName, deploymentID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Rollback the production deployment to a previous deployment. You can only -// rollback to succesful builds on production. -func (r *PageProjectDeploymentService) Rollback(ctx context.Context, projectName string, deploymentID string, body PageProjectDeploymentRollbackParams, opts ...option.RequestOption) (res *PageProjectDeploymentRollbackResponse, err error) { - opts = append(r.Options[:], opts...) - var env PageProjectDeploymentRollbackResponseEnvelope - path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments/%s/rollback", body.AccountID, projectName, deploymentID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type PageProjectDeploymentNewResponse struct { - // Id of the deployment. - ID string `json:"id"` - // A list of alias URLs pointing to this deployment. - Aliases []interface{} `json:"aliases,nullable"` - BuildConfig interface{} `json:"build_config"` - // When the deployment was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Info about what caused the deployment. - DeploymentTrigger PageProjectDeploymentNewResponseDeploymentTrigger `json:"deployment_trigger"` - // A dict of env variables to build this deploy. - EnvVars interface{} `json:"env_vars"` - // Type of deploy. - Environment string `json:"environment"` - // If the deployment has been skipped. - IsSkipped bool `json:"is_skipped"` - LatestStage interface{} `json:"latest_stage"` - // When the deployment was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Id of the project. - ProjectID string `json:"project_id"` - // Name of the project. - ProjectName string `json:"project_name"` - // Short Id (8 character) of the deployment. - ShortID string `json:"short_id"` - Source interface{} `json:"source"` - // List of past stages. - Stages []PageProjectDeploymentNewResponseStage `json:"stages"` - // The live URL to view this deployment. - URL string `json:"url"` - JSON pageProjectDeploymentNewResponseJSON `json:"-"` -} - -// pageProjectDeploymentNewResponseJSON contains the JSON metadata for the struct -// [PageProjectDeploymentNewResponse] -type pageProjectDeploymentNewResponseJSON struct { - ID apijson.Field - Aliases apijson.Field - BuildConfig apijson.Field - CreatedOn apijson.Field - DeploymentTrigger apijson.Field - EnvVars apijson.Field - Environment apijson.Field - IsSkipped apijson.Field - LatestStage apijson.Field - ModifiedOn apijson.Field - ProjectID apijson.Field - ProjectName apijson.Field - ShortID apijson.Field - Source apijson.Field - Stages apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentNewResponseJSON) RawJSON() string { - return r.raw -} - -// Info about what caused the deployment. -type PageProjectDeploymentNewResponseDeploymentTrigger struct { - // Additional info about the trigger. - Metadata PageProjectDeploymentNewResponseDeploymentTriggerMetadata `json:"metadata"` - // What caused the deployment. - Type string `json:"type"` - JSON pageProjectDeploymentNewResponseDeploymentTriggerJSON `json:"-"` -} - -// pageProjectDeploymentNewResponseDeploymentTriggerJSON contains the JSON metadata -// for the struct [PageProjectDeploymentNewResponseDeploymentTrigger] -type pageProjectDeploymentNewResponseDeploymentTriggerJSON struct { - Metadata apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentNewResponseDeploymentTrigger) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentNewResponseDeploymentTriggerJSON) RawJSON() string { - return r.raw -} - -// Additional info about the trigger. -type PageProjectDeploymentNewResponseDeploymentTriggerMetadata struct { - // Where the trigger happened. - Branch string `json:"branch"` - // Hash of the deployment trigger commit. - CommitHash string `json:"commit_hash"` - // Message of the deployment trigger commit. - CommitMessage string `json:"commit_message"` - JSON pageProjectDeploymentNewResponseDeploymentTriggerMetadataJSON `json:"-"` -} - -// pageProjectDeploymentNewResponseDeploymentTriggerMetadataJSON contains the JSON -// metadata for the struct -// [PageProjectDeploymentNewResponseDeploymentTriggerMetadata] -type pageProjectDeploymentNewResponseDeploymentTriggerMetadataJSON struct { - Branch apijson.Field - CommitHash apijson.Field - CommitMessage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentNewResponseDeploymentTriggerMetadata) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentNewResponseDeploymentTriggerMetadataJSON) RawJSON() string { - return r.raw -} - -// The status of the deployment. -type PageProjectDeploymentNewResponseStage struct { - // When the stage ended. - EndedOn time.Time `json:"ended_on,nullable" format:"date-time"` - // The current build stage. - Name string `json:"name"` - // When the stage started. - StartedOn time.Time `json:"started_on,nullable" format:"date-time"` - // State of the current stage. - Status string `json:"status"` - JSON pageProjectDeploymentNewResponseStageJSON `json:"-"` -} - -// pageProjectDeploymentNewResponseStageJSON contains the JSON metadata for the -// struct [PageProjectDeploymentNewResponseStage] -type pageProjectDeploymentNewResponseStageJSON struct { - EndedOn apijson.Field - Name apijson.Field - StartedOn apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentNewResponseStage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentNewResponseStageJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeploymentListResponse struct { - // Id of the deployment. - ID string `json:"id"` - // A list of alias URLs pointing to this deployment. - Aliases []interface{} `json:"aliases,nullable"` - BuildConfig interface{} `json:"build_config"` - // When the deployment was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Info about what caused the deployment. - DeploymentTrigger PageProjectDeploymentListResponseDeploymentTrigger `json:"deployment_trigger"` - // A dict of env variables to build this deploy. - EnvVars interface{} `json:"env_vars"` - // Type of deploy. - Environment string `json:"environment"` - // If the deployment has been skipped. - IsSkipped bool `json:"is_skipped"` - LatestStage interface{} `json:"latest_stage"` - // When the deployment was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Id of the project. - ProjectID string `json:"project_id"` - // Name of the project. - ProjectName string `json:"project_name"` - // Short Id (8 character) of the deployment. - ShortID string `json:"short_id"` - Source interface{} `json:"source"` - // List of past stages. - Stages []PageProjectDeploymentListResponseStage `json:"stages"` - // The live URL to view this deployment. - URL string `json:"url"` - JSON pageProjectDeploymentListResponseJSON `json:"-"` -} - -// pageProjectDeploymentListResponseJSON contains the JSON metadata for the struct -// [PageProjectDeploymentListResponse] -type pageProjectDeploymentListResponseJSON struct { - ID apijson.Field - Aliases apijson.Field - BuildConfig apijson.Field - CreatedOn apijson.Field - DeploymentTrigger apijson.Field - EnvVars apijson.Field - Environment apijson.Field - IsSkipped apijson.Field - LatestStage apijson.Field - ModifiedOn apijson.Field - ProjectID apijson.Field - ProjectName apijson.Field - ShortID apijson.Field - Source apijson.Field - Stages apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentListResponseJSON) RawJSON() string { - return r.raw -} - -// Info about what caused the deployment. -type PageProjectDeploymentListResponseDeploymentTrigger struct { - // Additional info about the trigger. - Metadata PageProjectDeploymentListResponseDeploymentTriggerMetadata `json:"metadata"` - // What caused the deployment. - Type string `json:"type"` - JSON pageProjectDeploymentListResponseDeploymentTriggerJSON `json:"-"` -} - -// pageProjectDeploymentListResponseDeploymentTriggerJSON contains the JSON -// metadata for the struct [PageProjectDeploymentListResponseDeploymentTrigger] -type pageProjectDeploymentListResponseDeploymentTriggerJSON struct { - Metadata apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentListResponseDeploymentTrigger) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentListResponseDeploymentTriggerJSON) RawJSON() string { - return r.raw -} - -// Additional info about the trigger. -type PageProjectDeploymentListResponseDeploymentTriggerMetadata struct { - // Where the trigger happened. - Branch string `json:"branch"` - // Hash of the deployment trigger commit. - CommitHash string `json:"commit_hash"` - // Message of the deployment trigger commit. - CommitMessage string `json:"commit_message"` - JSON pageProjectDeploymentListResponseDeploymentTriggerMetadataJSON `json:"-"` -} - -// pageProjectDeploymentListResponseDeploymentTriggerMetadataJSON contains the JSON -// metadata for the struct -// [PageProjectDeploymentListResponseDeploymentTriggerMetadata] -type pageProjectDeploymentListResponseDeploymentTriggerMetadataJSON struct { - Branch apijson.Field - CommitHash apijson.Field - CommitMessage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentListResponseDeploymentTriggerMetadata) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentListResponseDeploymentTriggerMetadataJSON) RawJSON() string { - return r.raw -} - -// The status of the deployment. -type PageProjectDeploymentListResponseStage struct { - // When the stage ended. - EndedOn time.Time `json:"ended_on,nullable" format:"date-time"` - // The current build stage. - Name string `json:"name"` - // When the stage started. - StartedOn time.Time `json:"started_on,nullable" format:"date-time"` - // State of the current stage. - Status string `json:"status"` - JSON pageProjectDeploymentListResponseStageJSON `json:"-"` -} - -// pageProjectDeploymentListResponseStageJSON contains the JSON metadata for the -// struct [PageProjectDeploymentListResponseStage] -type pageProjectDeploymentListResponseStageJSON struct { - EndedOn apijson.Field - Name apijson.Field - StartedOn apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentListResponseStage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentListResponseStageJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeploymentDeleteResponse = interface{} - -type PageProjectDeploymentGetResponse struct { - // Id of the deployment. - ID string `json:"id"` - // A list of alias URLs pointing to this deployment. - Aliases []interface{} `json:"aliases,nullable"` - BuildConfig interface{} `json:"build_config"` - // When the deployment was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Info about what caused the deployment. - DeploymentTrigger PageProjectDeploymentGetResponseDeploymentTrigger `json:"deployment_trigger"` - // A dict of env variables to build this deploy. - EnvVars interface{} `json:"env_vars"` - // Type of deploy. - Environment string `json:"environment"` - // If the deployment has been skipped. - IsSkipped bool `json:"is_skipped"` - LatestStage interface{} `json:"latest_stage"` - // When the deployment was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Id of the project. - ProjectID string `json:"project_id"` - // Name of the project. - ProjectName string `json:"project_name"` - // Short Id (8 character) of the deployment. - ShortID string `json:"short_id"` - Source interface{} `json:"source"` - // List of past stages. - Stages []PageProjectDeploymentGetResponseStage `json:"stages"` - // The live URL to view this deployment. - URL string `json:"url"` - JSON pageProjectDeploymentGetResponseJSON `json:"-"` -} - -// pageProjectDeploymentGetResponseJSON contains the JSON metadata for the struct -// [PageProjectDeploymentGetResponse] -type pageProjectDeploymentGetResponseJSON struct { - ID apijson.Field - Aliases apijson.Field - BuildConfig apijson.Field - CreatedOn apijson.Field - DeploymentTrigger apijson.Field - EnvVars apijson.Field - Environment apijson.Field - IsSkipped apijson.Field - LatestStage apijson.Field - ModifiedOn apijson.Field - ProjectID apijson.Field - ProjectName apijson.Field - ShortID apijson.Field - Source apijson.Field - Stages apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentGetResponseJSON) RawJSON() string { - return r.raw -} - -// Info about what caused the deployment. -type PageProjectDeploymentGetResponseDeploymentTrigger struct { - // Additional info about the trigger. - Metadata PageProjectDeploymentGetResponseDeploymentTriggerMetadata `json:"metadata"` - // What caused the deployment. - Type string `json:"type"` - JSON pageProjectDeploymentGetResponseDeploymentTriggerJSON `json:"-"` -} - -// pageProjectDeploymentGetResponseDeploymentTriggerJSON contains the JSON metadata -// for the struct [PageProjectDeploymentGetResponseDeploymentTrigger] -type pageProjectDeploymentGetResponseDeploymentTriggerJSON struct { - Metadata apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentGetResponseDeploymentTrigger) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentGetResponseDeploymentTriggerJSON) RawJSON() string { - return r.raw -} - -// Additional info about the trigger. -type PageProjectDeploymentGetResponseDeploymentTriggerMetadata struct { - // Where the trigger happened. - Branch string `json:"branch"` - // Hash of the deployment trigger commit. - CommitHash string `json:"commit_hash"` - // Message of the deployment trigger commit. - CommitMessage string `json:"commit_message"` - JSON pageProjectDeploymentGetResponseDeploymentTriggerMetadataJSON `json:"-"` -} - -// pageProjectDeploymentGetResponseDeploymentTriggerMetadataJSON contains the JSON -// metadata for the struct -// [PageProjectDeploymentGetResponseDeploymentTriggerMetadata] -type pageProjectDeploymentGetResponseDeploymentTriggerMetadataJSON struct { - Branch apijson.Field - CommitHash apijson.Field - CommitMessage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentGetResponseDeploymentTriggerMetadata) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentGetResponseDeploymentTriggerMetadataJSON) RawJSON() string { - return r.raw -} - -// The status of the deployment. -type PageProjectDeploymentGetResponseStage struct { - // When the stage ended. - EndedOn time.Time `json:"ended_on,nullable" format:"date-time"` - // The current build stage. - Name string `json:"name"` - // When the stage started. - StartedOn time.Time `json:"started_on,nullable" format:"date-time"` - // State of the current stage. - Status string `json:"status"` - JSON pageProjectDeploymentGetResponseStageJSON `json:"-"` -} - -// pageProjectDeploymentGetResponseStageJSON contains the JSON metadata for the -// struct [PageProjectDeploymentGetResponseStage] -type pageProjectDeploymentGetResponseStageJSON struct { - EndedOn apijson.Field - Name apijson.Field - StartedOn apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentGetResponseStage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentGetResponseStageJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeploymentRetryResponse struct { - // Id of the deployment. - ID string `json:"id"` - // A list of alias URLs pointing to this deployment. - Aliases []interface{} `json:"aliases,nullable"` - BuildConfig interface{} `json:"build_config"` - // When the deployment was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Info about what caused the deployment. - DeploymentTrigger PageProjectDeploymentRetryResponseDeploymentTrigger `json:"deployment_trigger"` - // A dict of env variables to build this deploy. - EnvVars interface{} `json:"env_vars"` - // Type of deploy. - Environment string `json:"environment"` - // If the deployment has been skipped. - IsSkipped bool `json:"is_skipped"` - LatestStage interface{} `json:"latest_stage"` - // When the deployment was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Id of the project. - ProjectID string `json:"project_id"` - // Name of the project. - ProjectName string `json:"project_name"` - // Short Id (8 character) of the deployment. - ShortID string `json:"short_id"` - Source interface{} `json:"source"` - // List of past stages. - Stages []PageProjectDeploymentRetryResponseStage `json:"stages"` - // The live URL to view this deployment. - URL string `json:"url"` - JSON pageProjectDeploymentRetryResponseJSON `json:"-"` -} - -// pageProjectDeploymentRetryResponseJSON contains the JSON metadata for the struct -// [PageProjectDeploymentRetryResponse] -type pageProjectDeploymentRetryResponseJSON struct { - ID apijson.Field - Aliases apijson.Field - BuildConfig apijson.Field - CreatedOn apijson.Field - DeploymentTrigger apijson.Field - EnvVars apijson.Field - Environment apijson.Field - IsSkipped apijson.Field - LatestStage apijson.Field - ModifiedOn apijson.Field - ProjectID apijson.Field - ProjectName apijson.Field - ShortID apijson.Field - Source apijson.Field - Stages apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentRetryResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentRetryResponseJSON) RawJSON() string { - return r.raw -} - -// Info about what caused the deployment. -type PageProjectDeploymentRetryResponseDeploymentTrigger struct { - // Additional info about the trigger. - Metadata PageProjectDeploymentRetryResponseDeploymentTriggerMetadata `json:"metadata"` - // What caused the deployment. - Type string `json:"type"` - JSON pageProjectDeploymentRetryResponseDeploymentTriggerJSON `json:"-"` -} - -// pageProjectDeploymentRetryResponseDeploymentTriggerJSON contains the JSON -// metadata for the struct [PageProjectDeploymentRetryResponseDeploymentTrigger] -type pageProjectDeploymentRetryResponseDeploymentTriggerJSON struct { - Metadata apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentRetryResponseDeploymentTrigger) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentRetryResponseDeploymentTriggerJSON) RawJSON() string { - return r.raw -} - -// Additional info about the trigger. -type PageProjectDeploymentRetryResponseDeploymentTriggerMetadata struct { - // Where the trigger happened. - Branch string `json:"branch"` - // Hash of the deployment trigger commit. - CommitHash string `json:"commit_hash"` - // Message of the deployment trigger commit. - CommitMessage string `json:"commit_message"` - JSON pageProjectDeploymentRetryResponseDeploymentTriggerMetadataJSON `json:"-"` -} - -// pageProjectDeploymentRetryResponseDeploymentTriggerMetadataJSON contains the -// JSON metadata for the struct -// [PageProjectDeploymentRetryResponseDeploymentTriggerMetadata] -type pageProjectDeploymentRetryResponseDeploymentTriggerMetadataJSON struct { - Branch apijson.Field - CommitHash apijson.Field - CommitMessage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentRetryResponseDeploymentTriggerMetadata) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentRetryResponseDeploymentTriggerMetadataJSON) RawJSON() string { - return r.raw -} - -// The status of the deployment. -type PageProjectDeploymentRetryResponseStage struct { - // When the stage ended. - EndedOn time.Time `json:"ended_on,nullable" format:"date-time"` - // The current build stage. - Name string `json:"name"` - // When the stage started. - StartedOn time.Time `json:"started_on,nullable" format:"date-time"` - // State of the current stage. - Status string `json:"status"` - JSON pageProjectDeploymentRetryResponseStageJSON `json:"-"` -} - -// pageProjectDeploymentRetryResponseStageJSON contains the JSON metadata for the -// struct [PageProjectDeploymentRetryResponseStage] -type pageProjectDeploymentRetryResponseStageJSON struct { - EndedOn apijson.Field - Name apijson.Field - StartedOn apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentRetryResponseStage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentRetryResponseStageJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeploymentRollbackResponse struct { - // Id of the deployment. - ID string `json:"id"` - // A list of alias URLs pointing to this deployment. - Aliases []interface{} `json:"aliases,nullable"` - BuildConfig interface{} `json:"build_config"` - // When the deployment was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Info about what caused the deployment. - DeploymentTrigger PageProjectDeploymentRollbackResponseDeploymentTrigger `json:"deployment_trigger"` - // A dict of env variables to build this deploy. - EnvVars interface{} `json:"env_vars"` - // Type of deploy. - Environment string `json:"environment"` - // If the deployment has been skipped. - IsSkipped bool `json:"is_skipped"` - LatestStage interface{} `json:"latest_stage"` - // When the deployment was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Id of the project. - ProjectID string `json:"project_id"` - // Name of the project. - ProjectName string `json:"project_name"` - // Short Id (8 character) of the deployment. - ShortID string `json:"short_id"` - Source interface{} `json:"source"` - // List of past stages. - Stages []PageProjectDeploymentRollbackResponseStage `json:"stages"` - // The live URL to view this deployment. - URL string `json:"url"` - JSON pageProjectDeploymentRollbackResponseJSON `json:"-"` -} - -// pageProjectDeploymentRollbackResponseJSON contains the JSON metadata for the -// struct [PageProjectDeploymentRollbackResponse] -type pageProjectDeploymentRollbackResponseJSON struct { - ID apijson.Field - Aliases apijson.Field - BuildConfig apijson.Field - CreatedOn apijson.Field - DeploymentTrigger apijson.Field - EnvVars apijson.Field - Environment apijson.Field - IsSkipped apijson.Field - LatestStage apijson.Field - ModifiedOn apijson.Field - ProjectID apijson.Field - ProjectName apijson.Field - ShortID apijson.Field - Source apijson.Field - Stages apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentRollbackResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentRollbackResponseJSON) RawJSON() string { - return r.raw -} - -// Info about what caused the deployment. -type PageProjectDeploymentRollbackResponseDeploymentTrigger struct { - // Additional info about the trigger. - Metadata PageProjectDeploymentRollbackResponseDeploymentTriggerMetadata `json:"metadata"` - // What caused the deployment. - Type string `json:"type"` - JSON pageProjectDeploymentRollbackResponseDeploymentTriggerJSON `json:"-"` -} - -// pageProjectDeploymentRollbackResponseDeploymentTriggerJSON contains the JSON -// metadata for the struct [PageProjectDeploymentRollbackResponseDeploymentTrigger] -type pageProjectDeploymentRollbackResponseDeploymentTriggerJSON struct { - Metadata apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentRollbackResponseDeploymentTrigger) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentRollbackResponseDeploymentTriggerJSON) RawJSON() string { - return r.raw -} - -// Additional info about the trigger. -type PageProjectDeploymentRollbackResponseDeploymentTriggerMetadata struct { - // Where the trigger happened. - Branch string `json:"branch"` - // Hash of the deployment trigger commit. - CommitHash string `json:"commit_hash"` - // Message of the deployment trigger commit. - CommitMessage string `json:"commit_message"` - JSON pageProjectDeploymentRollbackResponseDeploymentTriggerMetadataJSON `json:"-"` -} - -// pageProjectDeploymentRollbackResponseDeploymentTriggerMetadataJSON contains the -// JSON metadata for the struct -// [PageProjectDeploymentRollbackResponseDeploymentTriggerMetadata] -type pageProjectDeploymentRollbackResponseDeploymentTriggerMetadataJSON struct { - Branch apijson.Field - CommitHash apijson.Field - CommitMessage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentRollbackResponseDeploymentTriggerMetadata) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentRollbackResponseDeploymentTriggerMetadataJSON) RawJSON() string { - return r.raw -} - -// The status of the deployment. -type PageProjectDeploymentRollbackResponseStage struct { - // When the stage ended. - EndedOn time.Time `json:"ended_on,nullable" format:"date-time"` - // The current build stage. - Name string `json:"name"` - // When the stage started. - StartedOn time.Time `json:"started_on,nullable" format:"date-time"` - // State of the current stage. - Status string `json:"status"` - JSON pageProjectDeploymentRollbackResponseStageJSON `json:"-"` -} - -// pageProjectDeploymentRollbackResponseStageJSON contains the JSON metadata for -// the struct [PageProjectDeploymentRollbackResponseStage] -type pageProjectDeploymentRollbackResponseStageJSON struct { - EndedOn apijson.Field - Name apijson.Field - StartedOn apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentRollbackResponseStage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentRollbackResponseStageJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeploymentNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The branch to build the new deployment from. The `HEAD` of the branch will be - // used. If omitted, the production branch will be used by default. - Branch param.Field[string] `json:"branch"` -} - -func (r PageProjectDeploymentNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type PageProjectDeploymentNewResponseEnvelope struct { - Errors []PageProjectDeploymentNewResponseEnvelopeErrors `json:"errors,required"` - Messages []PageProjectDeploymentNewResponseEnvelopeMessages `json:"messages,required"` - Result PageProjectDeploymentNewResponse `json:"result,required"` - // Whether the API call was successful - Success PageProjectDeploymentNewResponseEnvelopeSuccess `json:"success,required"` - JSON pageProjectDeploymentNewResponseEnvelopeJSON `json:"-"` -} - -// pageProjectDeploymentNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [PageProjectDeploymentNewResponseEnvelope] -type pageProjectDeploymentNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeploymentNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDeploymentNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageProjectDeploymentNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [PageProjectDeploymentNewResponseEnvelopeErrors] -type pageProjectDeploymentNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeploymentNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDeploymentNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageProjectDeploymentNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [PageProjectDeploymentNewResponseEnvelopeMessages] -type pageProjectDeploymentNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PageProjectDeploymentNewResponseEnvelopeSuccess bool - -const ( - PageProjectDeploymentNewResponseEnvelopeSuccessTrue PageProjectDeploymentNewResponseEnvelopeSuccess = true -) - -type PageProjectDeploymentListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type PageProjectDeploymentListResponseEnvelope struct { - Errors []PageProjectDeploymentListResponseEnvelopeErrors `json:"errors,required"` - Messages []PageProjectDeploymentListResponseEnvelopeMessages `json:"messages,required"` - Result []PageProjectDeploymentListResponse `json:"result,required"` - // Whether the API call was successful - Success PageProjectDeploymentListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo PageProjectDeploymentListResponseEnvelopeResultInfo `json:"result_info"` - JSON pageProjectDeploymentListResponseEnvelopeJSON `json:"-"` -} - -// pageProjectDeploymentListResponseEnvelopeJSON contains the JSON metadata for the -// struct [PageProjectDeploymentListResponseEnvelope] -type pageProjectDeploymentListResponseEnvelopeJSON 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 *PageProjectDeploymentListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeploymentListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDeploymentListResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageProjectDeploymentListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [PageProjectDeploymentListResponseEnvelopeErrors] -type pageProjectDeploymentListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeploymentListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDeploymentListResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageProjectDeploymentListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [PageProjectDeploymentListResponseEnvelopeMessages] -type pageProjectDeploymentListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PageProjectDeploymentListResponseEnvelopeSuccess bool - -const ( - PageProjectDeploymentListResponseEnvelopeSuccessTrue PageProjectDeploymentListResponseEnvelopeSuccess = true -) - -type PageProjectDeploymentListResponseEnvelopeResultInfo struct { - Count interface{} `json:"count"` - Page interface{} `json:"page"` - PerPage interface{} `json:"per_page"` - TotalCount interface{} `json:"total_count"` - JSON pageProjectDeploymentListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// pageProjectDeploymentListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [PageProjectDeploymentListResponseEnvelopeResultInfo] -type pageProjectDeploymentListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeploymentDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type PageProjectDeploymentGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type PageProjectDeploymentGetResponseEnvelope struct { - Errors []PageProjectDeploymentGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PageProjectDeploymentGetResponseEnvelopeMessages `json:"messages,required"` - Result PageProjectDeploymentGetResponse `json:"result,required"` - // Whether the API call was successful - Success PageProjectDeploymentGetResponseEnvelopeSuccess `json:"success,required"` - JSON pageProjectDeploymentGetResponseEnvelopeJSON `json:"-"` -} - -// pageProjectDeploymentGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [PageProjectDeploymentGetResponseEnvelope] -type pageProjectDeploymentGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeploymentGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDeploymentGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageProjectDeploymentGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [PageProjectDeploymentGetResponseEnvelopeErrors] -type pageProjectDeploymentGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeploymentGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDeploymentGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageProjectDeploymentGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [PageProjectDeploymentGetResponseEnvelopeMessages] -type pageProjectDeploymentGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PageProjectDeploymentGetResponseEnvelopeSuccess bool - -const ( - PageProjectDeploymentGetResponseEnvelopeSuccessTrue PageProjectDeploymentGetResponseEnvelopeSuccess = true -) - -type PageProjectDeploymentRetryParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type PageProjectDeploymentRetryResponseEnvelope struct { - Errors []PageProjectDeploymentRetryResponseEnvelopeErrors `json:"errors,required"` - Messages []PageProjectDeploymentRetryResponseEnvelopeMessages `json:"messages,required"` - Result PageProjectDeploymentRetryResponse `json:"result,required"` - // Whether the API call was successful - Success PageProjectDeploymentRetryResponseEnvelopeSuccess `json:"success,required"` - JSON pageProjectDeploymentRetryResponseEnvelopeJSON `json:"-"` -} - -// pageProjectDeploymentRetryResponseEnvelopeJSON contains the JSON metadata for -// the struct [PageProjectDeploymentRetryResponseEnvelope] -type pageProjectDeploymentRetryResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentRetryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentRetryResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeploymentRetryResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDeploymentRetryResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageProjectDeploymentRetryResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [PageProjectDeploymentRetryResponseEnvelopeErrors] -type pageProjectDeploymentRetryResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentRetryResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentRetryResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeploymentRetryResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDeploymentRetryResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageProjectDeploymentRetryResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [PageProjectDeploymentRetryResponseEnvelopeMessages] -type pageProjectDeploymentRetryResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentRetryResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentRetryResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PageProjectDeploymentRetryResponseEnvelopeSuccess bool - -const ( - PageProjectDeploymentRetryResponseEnvelopeSuccessTrue PageProjectDeploymentRetryResponseEnvelopeSuccess = true -) - -type PageProjectDeploymentRollbackParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type PageProjectDeploymentRollbackResponseEnvelope struct { - Errors []PageProjectDeploymentRollbackResponseEnvelopeErrors `json:"errors,required"` - Messages []PageProjectDeploymentRollbackResponseEnvelopeMessages `json:"messages,required"` - Result PageProjectDeploymentRollbackResponse `json:"result,required"` - // Whether the API call was successful - Success PageProjectDeploymentRollbackResponseEnvelopeSuccess `json:"success,required"` - JSON pageProjectDeploymentRollbackResponseEnvelopeJSON `json:"-"` -} - -// pageProjectDeploymentRollbackResponseEnvelopeJSON contains the JSON metadata for -// the struct [PageProjectDeploymentRollbackResponseEnvelope] -type pageProjectDeploymentRollbackResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentRollbackResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentRollbackResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeploymentRollbackResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDeploymentRollbackResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageProjectDeploymentRollbackResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [PageProjectDeploymentRollbackResponseEnvelopeErrors] -type pageProjectDeploymentRollbackResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentRollbackResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentRollbackResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeploymentRollbackResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDeploymentRollbackResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageProjectDeploymentRollbackResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [PageProjectDeploymentRollbackResponseEnvelopeMessages] -type pageProjectDeploymentRollbackResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentRollbackResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentRollbackResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PageProjectDeploymentRollbackResponseEnvelopeSuccess bool - -const ( - PageProjectDeploymentRollbackResponseEnvelopeSuccessTrue PageProjectDeploymentRollbackResponseEnvelopeSuccess = true -) diff --git a/pageprojectdeployment_test.go b/pageprojectdeployment_test.go deleted file mode 100644 index ede9165dd1b..00000000000 --- a/pageprojectdeployment_test.go +++ /dev/null @@ -1,199 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestPageProjectDeploymentNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Pages.Projects.Deployments.New( - context.TODO(), - "this-is-my-project-01", - cloudflare.PageProjectDeploymentNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Branch: cloudflare.F("staging"), - }, - ) - 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 TestPageProjectDeploymentList(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("user@example.com"), - ) - _, err := client.Pages.Projects.Deployments.List( - context.TODO(), - "this-is-my-project-01", - cloudflare.PageProjectDeploymentListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestPageProjectDeploymentDelete(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("user@example.com"), - ) - _, err := client.Pages.Projects.Deployments.Delete( - context.TODO(), - "this-is-my-project-01", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.PageProjectDeploymentDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestPageProjectDeploymentGet(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("user@example.com"), - ) - _, err := client.Pages.Projects.Deployments.Get( - context.TODO(), - "this-is-my-project-01", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.PageProjectDeploymentGetParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestPageProjectDeploymentRetry(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("user@example.com"), - ) - _, err := client.Pages.Projects.Deployments.Retry( - context.TODO(), - "this-is-my-project-01", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.PageProjectDeploymentRetryParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestPageProjectDeploymentRollback(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("user@example.com"), - ) - _, err := client.Pages.Projects.Deployments.Rollback( - context.TODO(), - "this-is-my-project-01", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.PageProjectDeploymentRollbackParams{ - AccountID: cloudflare.F("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/pageprojectdeploymenthistory.go b/pageprojectdeploymenthistory.go deleted file mode 100644 index 8dfd3569f52..00000000000 --- a/pageprojectdeploymenthistory.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// PageProjectDeploymentHistoryService 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 -// [NewPageProjectDeploymentHistoryService] method instead. -type PageProjectDeploymentHistoryService struct { - Options []option.RequestOption - Logs *PageProjectDeploymentHistoryLogService -} - -// NewPageProjectDeploymentHistoryService 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 NewPageProjectDeploymentHistoryService(opts ...option.RequestOption) (r *PageProjectDeploymentHistoryService) { - r = &PageProjectDeploymentHistoryService{} - r.Options = opts - r.Logs = NewPageProjectDeploymentHistoryLogService(opts...) - return -} diff --git a/pageprojectdeploymenthistorylog.go b/pageprojectdeploymenthistorylog.go deleted file mode 100644 index 25cc6d71fe0..00000000000 --- a/pageprojectdeploymenthistorylog.go +++ /dev/null @@ -1,162 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// PageProjectDeploymentHistoryLogService 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 -// [NewPageProjectDeploymentHistoryLogService] method instead. -type PageProjectDeploymentHistoryLogService struct { - Options []option.RequestOption -} - -// NewPageProjectDeploymentHistoryLogService 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 NewPageProjectDeploymentHistoryLogService(opts ...option.RequestOption) (r *PageProjectDeploymentHistoryLogService) { - r = &PageProjectDeploymentHistoryLogService{} - r.Options = opts - return -} - -// Fetch deployment logs for a project. -func (r *PageProjectDeploymentHistoryLogService) Get(ctx context.Context, projectName string, deploymentID string, query PageProjectDeploymentHistoryLogGetParams, opts ...option.RequestOption) (res *PageProjectDeploymentHistoryLogGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env PageProjectDeploymentHistoryLogGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments/%s/history/logs", query.AccountID, projectName, deploymentID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [PageProjectDeploymentHistoryLogGetResponseUnknown], -// [PageProjectDeploymentHistoryLogGetResponseArray] or [shared.UnionString]. -type PageProjectDeploymentHistoryLogGetResponse interface { - ImplementsPageProjectDeploymentHistoryLogGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*PageProjectDeploymentHistoryLogGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(PageProjectDeploymentHistoryLogGetResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type PageProjectDeploymentHistoryLogGetResponseArray []interface{} - -func (r PageProjectDeploymentHistoryLogGetResponseArray) ImplementsPageProjectDeploymentHistoryLogGetResponse() { -} - -type PageProjectDeploymentHistoryLogGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type PageProjectDeploymentHistoryLogGetResponseEnvelope struct { - Errors []PageProjectDeploymentHistoryLogGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PageProjectDeploymentHistoryLogGetResponseEnvelopeMessages `json:"messages,required"` - Result PageProjectDeploymentHistoryLogGetResponse `json:"result,required"` - // Whether the API call was successful - Success PageProjectDeploymentHistoryLogGetResponseEnvelopeSuccess `json:"success,required"` - JSON pageProjectDeploymentHistoryLogGetResponseEnvelopeJSON `json:"-"` -} - -// pageProjectDeploymentHistoryLogGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [PageProjectDeploymentHistoryLogGetResponseEnvelope] -type pageProjectDeploymentHistoryLogGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentHistoryLogGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentHistoryLogGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeploymentHistoryLogGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDeploymentHistoryLogGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageProjectDeploymentHistoryLogGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [PageProjectDeploymentHistoryLogGetResponseEnvelopeErrors] -type pageProjectDeploymentHistoryLogGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentHistoryLogGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentHistoryLogGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageProjectDeploymentHistoryLogGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDeploymentHistoryLogGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageProjectDeploymentHistoryLogGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [PageProjectDeploymentHistoryLogGetResponseEnvelopeMessages] -type pageProjectDeploymentHistoryLogGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDeploymentHistoryLogGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDeploymentHistoryLogGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PageProjectDeploymentHistoryLogGetResponseEnvelopeSuccess bool - -const ( - PageProjectDeploymentHistoryLogGetResponseEnvelopeSuccessTrue PageProjectDeploymentHistoryLogGetResponseEnvelopeSuccess = true -) diff --git a/pageprojectdeploymenthistorylog_test.go b/pageprojectdeploymenthistorylog_test.go deleted file mode 100644 index a8158921b62..00000000000 --- a/pageprojectdeploymenthistorylog_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestPageProjectDeploymentHistoryLogGet(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("user@example.com"), - ) - _, err := client.Pages.Projects.Deployments.History.Logs.Get( - context.TODO(), - "this-is-my-project-01", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.PageProjectDeploymentHistoryLogGetParams{ - AccountID: cloudflare.F("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/pageprojectdomain.go b/pageprojectdomain.go deleted file mode 100644 index d3696d32efd..00000000000 --- a/pageprojectdomain.go +++ /dev/null @@ -1,557 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// PageProjectDomainService 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 [NewPageProjectDomainService] method -// instead. -type PageProjectDomainService struct { - Options []option.RequestOption -} - -// NewPageProjectDomainService 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 NewPageProjectDomainService(opts ...option.RequestOption) (r *PageProjectDomainService) { - r = &PageProjectDomainService{} - r.Options = opts - return -} - -// Add a new domain for the Pages project. -func (r *PageProjectDomainService) New(ctx context.Context, projectName string, params PageProjectDomainNewParams, opts ...option.RequestOption) (res *PageProjectDomainNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env PageProjectDomainNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/pages/projects/%s/domains", params.AccountID, projectName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch a list of all domains associated with a Pages project. -func (r *PageProjectDomainService) List(ctx context.Context, projectName string, query PageProjectDomainListParams, opts ...option.RequestOption) (res *[]PageProjectDomainListResponse, err error) { - opts = append(r.Options[:], opts...) - var env PageProjectDomainListResponseEnvelope - path := fmt.Sprintf("accounts/%s/pages/projects/%s/domains", query.AccountID, projectName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a Pages project's domain. -func (r *PageProjectDomainService) Delete(ctx context.Context, projectName string, domainName string, body PageProjectDomainDeleteParams, opts ...option.RequestOption) (res *PageProjectDomainDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("accounts/%s/pages/projects/%s/domains/%s", body.AccountID, projectName, domainName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &res, opts...) - return -} - -// Retry the validation status of a single domain. -func (r *PageProjectDomainService) Edit(ctx context.Context, projectName string, domainName string, body PageProjectDomainEditParams, opts ...option.RequestOption) (res *PageProjectDomainEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env PageProjectDomainEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/pages/projects/%s/domains/%s", body.AccountID, projectName, domainName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch a single domain. -func (r *PageProjectDomainService) Get(ctx context.Context, projectName string, domainName string, query PageProjectDomainGetParams, opts ...option.RequestOption) (res *PageProjectDomainGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env PageProjectDomainGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/pages/projects/%s/domains/%s", query.AccountID, projectName, domainName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [PageProjectDomainNewResponseUnknown], -// [PageProjectDomainNewResponseArray] or [shared.UnionString]. -type PageProjectDomainNewResponse interface { - ImplementsPageProjectDomainNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*PageProjectDomainNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(PageProjectDomainNewResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type PageProjectDomainNewResponseArray []interface{} - -func (r PageProjectDomainNewResponseArray) ImplementsPageProjectDomainNewResponse() {} - -type PageProjectDomainListResponse = interface{} - -type PageProjectDomainDeleteResponse = interface{} - -// Union satisfied by [PageProjectDomainEditResponseUnknown], -// [PageProjectDomainEditResponseArray] or [shared.UnionString]. -type PageProjectDomainEditResponse interface { - ImplementsPageProjectDomainEditResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*PageProjectDomainEditResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(PageProjectDomainEditResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type PageProjectDomainEditResponseArray []interface{} - -func (r PageProjectDomainEditResponseArray) ImplementsPageProjectDomainEditResponse() {} - -// Union satisfied by [PageProjectDomainGetResponseUnknown], -// [PageProjectDomainGetResponseArray] or [shared.UnionString]. -type PageProjectDomainGetResponse interface { - ImplementsPageProjectDomainGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*PageProjectDomainGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(PageProjectDomainGetResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type PageProjectDomainGetResponseArray []interface{} - -func (r PageProjectDomainGetResponseArray) ImplementsPageProjectDomainGetResponse() {} - -type PageProjectDomainNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` -} - -func (r PageProjectDomainNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type PageProjectDomainNewResponseEnvelope struct { - Errors []PageProjectDomainNewResponseEnvelopeErrors `json:"errors,required"` - Messages []PageProjectDomainNewResponseEnvelopeMessages `json:"messages,required"` - Result PageProjectDomainNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success PageProjectDomainNewResponseEnvelopeSuccess `json:"success,required"` - JSON pageProjectDomainNewResponseEnvelopeJSON `json:"-"` -} - -// pageProjectDomainNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [PageProjectDomainNewResponseEnvelope] -type pageProjectDomainNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDomainNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDomainNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PageProjectDomainNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDomainNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageProjectDomainNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [PageProjectDomainNewResponseEnvelopeErrors] -type pageProjectDomainNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDomainNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDomainNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageProjectDomainNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDomainNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageProjectDomainNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [PageProjectDomainNewResponseEnvelopeMessages] -type pageProjectDomainNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDomainNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDomainNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PageProjectDomainNewResponseEnvelopeSuccess bool - -const ( - PageProjectDomainNewResponseEnvelopeSuccessTrue PageProjectDomainNewResponseEnvelopeSuccess = true -) - -type PageProjectDomainListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type PageProjectDomainListResponseEnvelope struct { - Errors []PageProjectDomainListResponseEnvelopeErrors `json:"errors,required"` - Messages []PageProjectDomainListResponseEnvelopeMessages `json:"messages,required"` - Result []PageProjectDomainListResponse `json:"result,required"` - // Whether the API call was successful - Success PageProjectDomainListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo PageProjectDomainListResponseEnvelopeResultInfo `json:"result_info"` - JSON pageProjectDomainListResponseEnvelopeJSON `json:"-"` -} - -// pageProjectDomainListResponseEnvelopeJSON contains the JSON metadata for the -// struct [PageProjectDomainListResponseEnvelope] -type pageProjectDomainListResponseEnvelopeJSON 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 *PageProjectDomainListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDomainListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PageProjectDomainListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDomainListResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageProjectDomainListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [PageProjectDomainListResponseEnvelopeErrors] -type pageProjectDomainListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDomainListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDomainListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageProjectDomainListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDomainListResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageProjectDomainListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [PageProjectDomainListResponseEnvelopeMessages] -type pageProjectDomainListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDomainListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDomainListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PageProjectDomainListResponseEnvelopeSuccess bool - -const ( - PageProjectDomainListResponseEnvelopeSuccessTrue PageProjectDomainListResponseEnvelopeSuccess = true -) - -type PageProjectDomainListResponseEnvelopeResultInfo struct { - Count interface{} `json:"count"` - Page interface{} `json:"page"` - PerPage interface{} `json:"per_page"` - TotalCount interface{} `json:"total_count"` - JSON pageProjectDomainListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// pageProjectDomainListResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [PageProjectDomainListResponseEnvelopeResultInfo] -type pageProjectDomainListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDomainListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDomainListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type PageProjectDomainDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type PageProjectDomainEditParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type PageProjectDomainEditResponseEnvelope struct { - Errors []PageProjectDomainEditResponseEnvelopeErrors `json:"errors,required"` - Messages []PageProjectDomainEditResponseEnvelopeMessages `json:"messages,required"` - Result PageProjectDomainEditResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success PageProjectDomainEditResponseEnvelopeSuccess `json:"success,required"` - JSON pageProjectDomainEditResponseEnvelopeJSON `json:"-"` -} - -// pageProjectDomainEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [PageProjectDomainEditResponseEnvelope] -type pageProjectDomainEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDomainEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDomainEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PageProjectDomainEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDomainEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageProjectDomainEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [PageProjectDomainEditResponseEnvelopeErrors] -type pageProjectDomainEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDomainEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDomainEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageProjectDomainEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDomainEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageProjectDomainEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [PageProjectDomainEditResponseEnvelopeMessages] -type pageProjectDomainEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDomainEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDomainEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PageProjectDomainEditResponseEnvelopeSuccess bool - -const ( - PageProjectDomainEditResponseEnvelopeSuccessTrue PageProjectDomainEditResponseEnvelopeSuccess = true -) - -type PageProjectDomainGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type PageProjectDomainGetResponseEnvelope struct { - Errors []PageProjectDomainGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PageProjectDomainGetResponseEnvelopeMessages `json:"messages,required"` - Result PageProjectDomainGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success PageProjectDomainGetResponseEnvelopeSuccess `json:"success,required"` - JSON pageProjectDomainGetResponseEnvelopeJSON `json:"-"` -} - -// pageProjectDomainGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [PageProjectDomainGetResponseEnvelope] -type pageProjectDomainGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDomainGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDomainGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PageProjectDomainGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDomainGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageProjectDomainGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [PageProjectDomainGetResponseEnvelopeErrors] -type pageProjectDomainGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDomainGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDomainGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageProjectDomainGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageProjectDomainGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageProjectDomainGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [PageProjectDomainGetResponseEnvelopeMessages] -type pageProjectDomainGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageProjectDomainGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageProjectDomainGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PageProjectDomainGetResponseEnvelopeSuccess bool - -const ( - PageProjectDomainGetResponseEnvelopeSuccessTrue PageProjectDomainGetResponseEnvelopeSuccess = true -) diff --git a/pageprojectdomain_test.go b/pageprojectdomain_test.go deleted file mode 100644 index c6961764f12..00000000000 --- a/pageprojectdomain_test.go +++ /dev/null @@ -1,170 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestPageProjectDomainNew(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("user@example.com"), - ) - _, err := client.Pages.Projects.Domains.New( - context.TODO(), - "this-is-my-project-01", - cloudflare.PageProjectDomainNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F[any](map[string]interface{}{ - "name": "example.com", - }), - }, - ) - 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 TestPageProjectDomainList(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("user@example.com"), - ) - _, err := client.Pages.Projects.Domains.List( - context.TODO(), - "this-is-my-project-01", - cloudflare.PageProjectDomainListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestPageProjectDomainDelete(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("user@example.com"), - ) - _, err := client.Pages.Projects.Domains.Delete( - context.TODO(), - "this-is-my-project-01", - "string", - cloudflare.PageProjectDomainDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestPageProjectDomainEdit(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("user@example.com"), - ) - _, err := client.Pages.Projects.Domains.Edit( - context.TODO(), - "this-is-my-project-01", - "string", - cloudflare.PageProjectDomainEditParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestPageProjectDomainGet(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("user@example.com"), - ) - _, err := client.Pages.Projects.Domains.Get( - context.TODO(), - "this-is-my-project-01", - "string", - cloudflare.PageProjectDomainGetParams{ - AccountID: cloudflare.F("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/pagerule_test.go b/pagerule_test.go deleted file mode 100644 index ca19d9392bc..00000000000 --- a/pagerule_test.go +++ /dev/null @@ -1,238 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestPageruleNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Pagerules.New(context.TODO(), cloudflare.PageruleNewParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Actions: cloudflare.F([]cloudflare.PageruleNewParamsAction{{ - Name: cloudflare.F(cloudflare.PageruleNewParamsActionsNameForwardURL), - Value: cloudflare.F(cloudflare.PageruleNewParamsActionsValue{ - Type: cloudflare.F(cloudflare.PageruleNewParamsActionsValueTypeTemporary), - URL: cloudflare.F("http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3"), - }), - }}), - Targets: cloudflare.F([]cloudflare.PageruleNewParamsTarget{{ - Constraint: cloudflare.F(cloudflare.PageruleNewParamsTargetsConstraint{ - Operator: cloudflare.F(cloudflare.PageruleNewParamsTargetsConstraintOperatorMatches), - Value: cloudflare.F("*example.com/images/*"), - }), - Target: cloudflare.F(cloudflare.PageruleNewParamsTargetsTargetURL), - }}), - Priority: cloudflare.F(int64(0)), - Status: cloudflare.F(cloudflare.PageruleNewParamsStatusActive), - }) - 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 TestPageruleUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Pagerules.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.PageruleUpdateParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Actions: cloudflare.F([]cloudflare.PageruleUpdateParamsAction{{ - Name: cloudflare.F(cloudflare.PageruleUpdateParamsActionsNameForwardURL), - Value: cloudflare.F(cloudflare.PageruleUpdateParamsActionsValue{ - Type: cloudflare.F(cloudflare.PageruleUpdateParamsActionsValueTypeTemporary), - URL: cloudflare.F("http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3"), - }), - }}), - Targets: cloudflare.F([]cloudflare.PageruleUpdateParamsTarget{{ - Constraint: cloudflare.F(cloudflare.PageruleUpdateParamsTargetsConstraint{ - Operator: cloudflare.F(cloudflare.PageruleUpdateParamsTargetsConstraintOperatorMatches), - Value: cloudflare.F("*example.com/images/*"), - }), - Target: cloudflare.F(cloudflare.PageruleUpdateParamsTargetsTargetURL), - }}), - Priority: cloudflare.F(int64(0)), - Status: cloudflare.F(cloudflare.PageruleUpdateParamsStatusActive), - }, - ) - 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 TestPageruleListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Pagerules.List(context.TODO(), cloudflare.PageruleListParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Direction: cloudflare.F(cloudflare.PageruleListParamsDirectionDesc), - Match: cloudflare.F(cloudflare.PageruleListParamsMatchAny), - Order: cloudflare.F(cloudflare.PageruleListParamsOrderStatus), - Status: cloudflare.F(cloudflare.PageruleListParamsStatusActive), - }) - 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 TestPageruleDelete(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("user@example.com"), - ) - _, err := client.Pagerules.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.PageruleDeleteParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestPageruleEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Pagerules.Edit( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.PageruleEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Actions: cloudflare.F([]cloudflare.PageruleEditParamsAction{{ - Name: cloudflare.F(cloudflare.PageruleEditParamsActionsNameForwardURL), - Value: cloudflare.F(cloudflare.PageruleEditParamsActionsValue{ - Type: cloudflare.F(cloudflare.PageruleEditParamsActionsValueTypeTemporary), - URL: cloudflare.F("http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3"), - }), - }}), - Priority: cloudflare.F(int64(0)), - Status: cloudflare.F(cloudflare.PageruleEditParamsStatusActive), - Targets: cloudflare.F([]cloudflare.PageruleEditParamsTarget{{ - Constraint: cloudflare.F(cloudflare.PageruleEditParamsTargetsConstraint{ - Operator: cloudflare.F(cloudflare.PageruleEditParamsTargetsConstraintOperatorMatches), - Value: cloudflare.F("*example.com/images/*"), - }), - Target: cloudflare.F(cloudflare.PageruleEditParamsTargetsTargetURL), - }}), - }, - ) - 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 TestPageruleGet(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("user@example.com"), - ) - _, err := client.Pagerules.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.PageruleGetParams{ - ZoneID: cloudflare.F("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/pagerules/aliases.go b/pagerules/aliases.go new file mode 100644 index 00000000000..031338e7b65 --- /dev/null +++ b/pagerules/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package pagerules + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/pagerule.go b/pagerules/pagerule.go similarity index 89% rename from pagerule.go rename to pagerules/pagerule.go index a1def4a2cdf..c168bcbe41c 100644 --- a/pagerule.go +++ b/pagerules/pagerule.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package pagerules import ( "context" @@ -25,7 +25,7 @@ import ( // service directly, and instead use the [NewPageruleService] method instead. type PageruleService struct { Options []option.RequestOption - Settings *PageruleSettingService + Settings *SettingService } // NewPageruleService generates a new service that applies the given options to @@ -34,7 +34,7 @@ type PageruleService struct { func NewPageruleService(opts ...option.RequestOption) (r *PageruleService) { r = &PageruleService{} r.Options = opts - r.Settings = NewPageruleSettingService(opts...) + r.Settings = NewSettingService(opts...) return } @@ -66,7 +66,7 @@ func (r *PageruleService) Update(ctx context.Context, pageruleID string, params } // Fetches Page Rules in a zone. -func (r *PageruleService) List(ctx context.Context, params PageruleListParams, opts ...option.RequestOption) (res *[]PageruleListResponse, err error) { +func (r *PageruleService) List(ctx context.Context, params PageruleListParams, opts ...option.RequestOption) (res *[]ZonesPageRule, err error) { opts = append(r.Options[:], opts...) var env PageruleListResponseEnvelope path := fmt.Sprintf("zones/%s/pagerules", params.ZoneID) @@ -117,44 +117,12 @@ func (r *PageruleService) Get(ctx context.Context, pageruleID string, query Page return } -// Union satisfied by [PageruleNewResponseUnknown] or [shared.UnionString]. -type PageruleNewResponse interface { - ImplementsPageruleNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*PageruleNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [PageruleUpdateResponseUnknown] or [shared.UnionString]. -type PageruleUpdateResponse interface { - ImplementsPageruleUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*PageruleUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type PageruleListResponse struct { +type ZonesPageRule struct { // Identifier ID string `json:"id,required"` // The set of actions to perform if the targets of this rule match the request. // Actions can redirect to another URL or override settings, but not both. - Actions []PageruleListResponseAction `json:"actions,required"` + Actions []ZonesPageRuleAction `json:"actions,required"` // The timestamp of when the Page Rule was created. CreatedOn time.Time `json:"created_on,required" format:"date-time"` // The timestamp of when the Page Rule was last modified. @@ -166,15 +134,14 @@ type PageruleListResponse struct { // rule B so it overrides rule A. Priority int64 `json:"priority,required"` // The status of the Page Rule. - Status PageruleListResponseStatus `json:"status,required"` + Status ZonesPageRuleStatus `json:"status,required"` // The rule targets to evaluate on each request. - Targets []PageruleListResponseTarget `json:"targets,required"` - JSON pageruleListResponseJSON `json:"-"` + Targets []ZonesPageRuleTarget `json:"targets,required"` + JSON zonesPageRuleJSON `json:"-"` } -// pageruleListResponseJSON contains the JSON metadata for the struct -// [PageruleListResponse] -type pageruleListResponseJSON struct { +// zonesPageRuleJSON contains the JSON metadata for the struct [ZonesPageRule] +type zonesPageRuleJSON struct { ID apijson.Field Actions apijson.Field CreatedOn apijson.Field @@ -186,26 +153,26 @@ type pageruleListResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *PageruleListResponse) UnmarshalJSON(data []byte) (err error) { +func (r *ZonesPageRule) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pageruleListResponseJSON) RawJSON() string { +func (r zonesPageRuleJSON) RawJSON() string { return r.raw } -type PageruleListResponseAction struct { +type ZonesPageRuleAction struct { // The timestamp of when the override was last modified. ModifiedOn time.Time `json:"modified_on" format:"date-time"` // The type of route. - Name PageruleListResponseActionsName `json:"name"` - Value PageruleListResponseActionsValue `json:"value"` - JSON pageruleListResponseActionJSON `json:"-"` + Name ZonesPageRuleActionsName `json:"name"` + Value ZonesPageRuleActionsValue `json:"value"` + JSON zonesPageRuleActionJSON `json:"-"` } -// pageruleListResponseActionJSON contains the JSON metadata for the struct -// [PageruleListResponseAction] -type pageruleListResponseActionJSON struct { +// zonesPageRuleActionJSON contains the JSON metadata for the struct +// [ZonesPageRuleAction] +type zonesPageRuleActionJSON struct { ModifiedOn apijson.Field Name apijson.Field Value apijson.Field @@ -213,134 +180,168 @@ type pageruleListResponseActionJSON struct { ExtraFields map[string]apijson.Field } -func (r *PageruleListResponseAction) UnmarshalJSON(data []byte) (err error) { +func (r *ZonesPageRuleAction) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pageruleListResponseActionJSON) RawJSON() string { +func (r zonesPageRuleActionJSON) RawJSON() string { return r.raw } // The type of route. -type PageruleListResponseActionsName string +type ZonesPageRuleActionsName string const ( - PageruleListResponseActionsNameForwardURL PageruleListResponseActionsName = "forward_url" + ZonesPageRuleActionsNameForwardURL ZonesPageRuleActionsName = "forward_url" ) -type PageruleListResponseActionsValue struct { +type ZonesPageRuleActionsValue struct { // The response type for the URL redirect. - Type PageruleListResponseActionsValueType `json:"type"` + Type ZonesPageRuleActionsValueType `json:"type"` // The URL to redirect the request to. Notes: ${num} refers to the position of '\*' // in the constraint value. - URL string `json:"url"` - JSON pageruleListResponseActionsValueJSON `json:"-"` + URL string `json:"url"` + JSON zonesPageRuleActionsValueJSON `json:"-"` } -// pageruleListResponseActionsValueJSON contains the JSON metadata for the struct -// [PageruleListResponseActionsValue] -type pageruleListResponseActionsValueJSON struct { +// zonesPageRuleActionsValueJSON contains the JSON metadata for the struct +// [ZonesPageRuleActionsValue] +type zonesPageRuleActionsValueJSON struct { Type apijson.Field URL apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PageruleListResponseActionsValue) UnmarshalJSON(data []byte) (err error) { +func (r *ZonesPageRuleActionsValue) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pageruleListResponseActionsValueJSON) RawJSON() string { +func (r zonesPageRuleActionsValueJSON) RawJSON() string { return r.raw } // The response type for the URL redirect. -type PageruleListResponseActionsValueType string +type ZonesPageRuleActionsValueType string const ( - PageruleListResponseActionsValueTypeTemporary PageruleListResponseActionsValueType = "temporary" - PageruleListResponseActionsValueTypePermanent PageruleListResponseActionsValueType = "permanent" + ZonesPageRuleActionsValueTypeTemporary ZonesPageRuleActionsValueType = "temporary" + ZonesPageRuleActionsValueTypePermanent ZonesPageRuleActionsValueType = "permanent" ) // The status of the Page Rule. -type PageruleListResponseStatus string +type ZonesPageRuleStatus string const ( - PageruleListResponseStatusActive PageruleListResponseStatus = "active" - PageruleListResponseStatusDisabled PageruleListResponseStatus = "disabled" + ZonesPageRuleStatusActive ZonesPageRuleStatus = "active" + ZonesPageRuleStatusDisabled ZonesPageRuleStatus = "disabled" ) // A request condition target. -type PageruleListResponseTarget struct { +type ZonesPageRuleTarget struct { // String constraint. - Constraint PageruleListResponseTargetsConstraint `json:"constraint,required"` + Constraint ZonesPageRuleTargetsConstraint `json:"constraint,required"` // A target based on the URL of the request. - Target PageruleListResponseTargetsTarget `json:"target,required"` - JSON pageruleListResponseTargetJSON `json:"-"` + Target ZonesPageRuleTargetsTarget `json:"target,required"` + JSON zonesPageRuleTargetJSON `json:"-"` } -// pageruleListResponseTargetJSON contains the JSON metadata for the struct -// [PageruleListResponseTarget] -type pageruleListResponseTargetJSON struct { +// zonesPageRuleTargetJSON contains the JSON metadata for the struct +// [ZonesPageRuleTarget] +type zonesPageRuleTargetJSON struct { Constraint apijson.Field Target apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PageruleListResponseTarget) UnmarshalJSON(data []byte) (err error) { +func (r *ZonesPageRuleTarget) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pageruleListResponseTargetJSON) RawJSON() string { +func (r zonesPageRuleTargetJSON) RawJSON() string { return r.raw } // String constraint. -type PageruleListResponseTargetsConstraint struct { +type ZonesPageRuleTargetsConstraint struct { // The matches operator can use asterisks and pipes as wildcard and 'or' operators. - Operator PageruleListResponseTargetsConstraintOperator `json:"operator,required"` + Operator ZonesPageRuleTargetsConstraintOperator `json:"operator,required"` // The URL pattern to match against the current request. The pattern may contain up // to four asterisks ('\*') as placeholders. - Value string `json:"value,required"` - JSON pageruleListResponseTargetsConstraintJSON `json:"-"` + Value string `json:"value,required"` + JSON zonesPageRuleTargetsConstraintJSON `json:"-"` } -// pageruleListResponseTargetsConstraintJSON contains the JSON metadata for the -// struct [PageruleListResponseTargetsConstraint] -type pageruleListResponseTargetsConstraintJSON struct { +// zonesPageRuleTargetsConstraintJSON contains the JSON metadata for the struct +// [ZonesPageRuleTargetsConstraint] +type zonesPageRuleTargetsConstraintJSON struct { Operator apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *PageruleListResponseTargetsConstraint) UnmarshalJSON(data []byte) (err error) { +func (r *ZonesPageRuleTargetsConstraint) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r pageruleListResponseTargetsConstraintJSON) RawJSON() string { +func (r zonesPageRuleTargetsConstraintJSON) RawJSON() string { return r.raw } // The matches operator can use asterisks and pipes as wildcard and 'or' operators. -type PageruleListResponseTargetsConstraintOperator string +type ZonesPageRuleTargetsConstraintOperator string const ( - PageruleListResponseTargetsConstraintOperatorMatches PageruleListResponseTargetsConstraintOperator = "matches" - PageruleListResponseTargetsConstraintOperatorContains PageruleListResponseTargetsConstraintOperator = "contains" - PageruleListResponseTargetsConstraintOperatorEquals PageruleListResponseTargetsConstraintOperator = "equals" - PageruleListResponseTargetsConstraintOperatorNotEqual PageruleListResponseTargetsConstraintOperator = "not_equal" - PageruleListResponseTargetsConstraintOperatorNotContain PageruleListResponseTargetsConstraintOperator = "not_contain" + ZonesPageRuleTargetsConstraintOperatorMatches ZonesPageRuleTargetsConstraintOperator = "matches" + ZonesPageRuleTargetsConstraintOperatorContains ZonesPageRuleTargetsConstraintOperator = "contains" + ZonesPageRuleTargetsConstraintOperatorEquals ZonesPageRuleTargetsConstraintOperator = "equals" + ZonesPageRuleTargetsConstraintOperatorNotEqual ZonesPageRuleTargetsConstraintOperator = "not_equal" + ZonesPageRuleTargetsConstraintOperatorNotContain ZonesPageRuleTargetsConstraintOperator = "not_contain" ) // A target based on the URL of the request. -type PageruleListResponseTargetsTarget string +type ZonesPageRuleTargetsTarget string const ( - PageruleListResponseTargetsTargetURL PageruleListResponseTargetsTarget = "url" + ZonesPageRuleTargetsTargetURL ZonesPageRuleTargetsTarget = "url" ) +// Union satisfied by [pagerules.PageruleNewResponseUnknown] or +// [shared.UnionString]. +type PageruleNewResponse interface { + ImplementsPagerulesPageruleNewResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*PageruleNewResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [pagerules.PageruleUpdateResponseUnknown] or +// [shared.UnionString]. +type PageruleUpdateResponse interface { + ImplementsPagerulesPageruleUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*PageruleUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + type PageruleDeleteResponse struct { // Identifier ID string `json:"id,required"` @@ -363,9 +364,10 @@ func (r pageruleDeleteResponseJSON) RawJSON() string { return r.raw } -// Union satisfied by [PageruleEditResponseUnknown] or [shared.UnionString]. +// Union satisfied by [pagerules.PageruleEditResponseUnknown] or +// [shared.UnionString]. type PageruleEditResponse interface { - ImplementsPageruleEditResponse() + ImplementsPagerulesPageruleEditResponse() } func init() { @@ -379,9 +381,10 @@ func init() { ) } -// Union satisfied by [PageruleGetResponseUnknown] or [shared.UnionString]. +// Union satisfied by [pagerules.PageruleGetResponseUnknown] or +// [shared.UnionString]. type PageruleGetResponse interface { - ImplementsPageruleGetResponse() + ImplementsPagerulesPageruleGetResponse() } func init() { @@ -835,7 +838,7 @@ const ( type PageruleListResponseEnvelope struct { Errors []PageruleListResponseEnvelopeErrors `json:"errors,required"` Messages []PageruleListResponseEnvelopeMessages `json:"messages,required"` - Result []PageruleListResponse `json:"result,required"` + Result []ZonesPageRule `json:"result,required"` // Whether the API call was successful Success PageruleListResponseEnvelopeSuccess `json:"success,required"` JSON pageruleListResponseEnvelopeJSON `json:"-"` diff --git a/pagerules/pagerule_test.go b/pagerules/pagerule_test.go new file mode 100644 index 00000000000..d772bc213d8 --- /dev/null +++ b/pagerules/pagerule_test.go @@ -0,0 +1,239 @@ +// File generated from our OpenAPI spec by Stainless. + +package pagerules_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/pagerules" +) + +func TestPageruleNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Pagerules.New(context.TODO(), pagerules.PageruleNewParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Actions: cloudflare.F([]pagerules.PageruleNewParamsAction{{ + Name: cloudflare.F(pagerules.PageruleNewParamsActionsNameForwardURL), + Value: cloudflare.F(pagerules.PageruleNewParamsActionsValue{ + Type: cloudflare.F(pagerules.PageruleNewParamsActionsValueTypeTemporary), + URL: cloudflare.F("http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3"), + }), + }}), + Targets: cloudflare.F([]pagerules.PageruleNewParamsTarget{{ + Constraint: cloudflare.F(pagerules.PageruleNewParamsTargetsConstraint{ + Operator: cloudflare.F(pagerules.PageruleNewParamsTargetsConstraintOperatorMatches), + Value: cloudflare.F("*example.com/images/*"), + }), + Target: cloudflare.F(pagerules.PageruleNewParamsTargetsTargetURL), + }}), + Priority: cloudflare.F(int64(0)), + Status: cloudflare.F(pagerules.PageruleNewParamsStatusActive), + }) + 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 TestPageruleUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Pagerules.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + pagerules.PageruleUpdateParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Actions: cloudflare.F([]pagerules.PageruleUpdateParamsAction{{ + Name: cloudflare.F(pagerules.PageruleUpdateParamsActionsNameForwardURL), + Value: cloudflare.F(pagerules.PageruleUpdateParamsActionsValue{ + Type: cloudflare.F(pagerules.PageruleUpdateParamsActionsValueTypeTemporary), + URL: cloudflare.F("http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3"), + }), + }}), + Targets: cloudflare.F([]pagerules.PageruleUpdateParamsTarget{{ + Constraint: cloudflare.F(pagerules.PageruleUpdateParamsTargetsConstraint{ + Operator: cloudflare.F(pagerules.PageruleUpdateParamsTargetsConstraintOperatorMatches), + Value: cloudflare.F("*example.com/images/*"), + }), + Target: cloudflare.F(pagerules.PageruleUpdateParamsTargetsTargetURL), + }}), + Priority: cloudflare.F(int64(0)), + Status: cloudflare.F(pagerules.PageruleUpdateParamsStatusActive), + }, + ) + 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 TestPageruleListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Pagerules.List(context.TODO(), pagerules.PageruleListParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Direction: cloudflare.F(pagerules.PageruleListParamsDirectionDesc), + Match: cloudflare.F(pagerules.PageruleListParamsMatchAny), + Order: cloudflare.F(pagerules.PageruleListParamsOrderStatus), + Status: cloudflare.F(pagerules.PageruleListParamsStatusActive), + }) + 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 TestPageruleDelete(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("user@example.com"), + ) + _, err := client.Pagerules.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + pagerules.PageruleDeleteParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestPageruleEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Pagerules.Edit( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + pagerules.PageruleEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Actions: cloudflare.F([]pagerules.PageruleEditParamsAction{{ + Name: cloudflare.F(pagerules.PageruleEditParamsActionsNameForwardURL), + Value: cloudflare.F(pagerules.PageruleEditParamsActionsValue{ + Type: cloudflare.F(pagerules.PageruleEditParamsActionsValueTypeTemporary), + URL: cloudflare.F("http://www.example.com/somewhere/$1/astring/$2/anotherstring/$3"), + }), + }}), + Priority: cloudflare.F(int64(0)), + Status: cloudflare.F(pagerules.PageruleEditParamsStatusActive), + Targets: cloudflare.F([]pagerules.PageruleEditParamsTarget{{ + Constraint: cloudflare.F(pagerules.PageruleEditParamsTargetsConstraint{ + Operator: cloudflare.F(pagerules.PageruleEditParamsTargetsConstraintOperatorMatches), + Value: cloudflare.F("*example.com/images/*"), + }), + Target: cloudflare.F(pagerules.PageruleEditParamsTargetsTargetURL), + }}), + }, + ) + 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 TestPageruleGet(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("user@example.com"), + ) + _, err := client.Pagerules.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + pagerules.PageruleGetParams{ + ZoneID: cloudflare.F("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/pagerules/setting.go b/pagerules/setting.go new file mode 100644 index 00000000000..de61a6e5e89 --- /dev/null +++ b/pagerules/setting.go @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package pagerules + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingService 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 [NewSettingService] method instead. +type SettingService struct { + Options []option.RequestOption +} + +// NewSettingService 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 NewSettingService(opts ...option.RequestOption) (r *SettingService) { + r = &SettingService{} + r.Options = opts + return +} + +// Returns a list of settings (and their details) that Page Rules can apply to +// matching requests. +func (r *SettingService) List(ctx context.Context, query SettingListParams, opts ...option.RequestOption) (res *ZonesSettings, err error) { + opts = append(r.Options[:], opts...) + var env SettingListResponseEnvelope + path := fmt.Sprintf("zones/%s/pagerules/settings", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ZonesSettings []interface{} + +type SettingListResponse = interface{} + +type SettingListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingListResponseEnvelope struct { + Errors []SettingListResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingListResponseEnvelopeMessages `json:"messages,required"` + // Settings available for the zone. + Result ZonesSettings `json:"result,required"` + // Whether the API call was successful + Success SettingListResponseEnvelopeSuccess `json:"success,required"` + JSON settingListResponseEnvelopeJSON `json:"-"` +} + +// settingListResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingListResponseEnvelope] +type settingListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingListResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [SettingListResponseEnvelopeErrors] +type settingListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingListResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingListResponseEnvelopeMessages] +type settingListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SettingListResponseEnvelopeSuccess bool + +const ( + SettingListResponseEnvelopeSuccessTrue SettingListResponseEnvelopeSuccess = true +) diff --git a/pagerules/setting_test.go b/pagerules/setting_test.go new file mode 100644 index 00000000000..031e2733ed8 --- /dev/null +++ b/pagerules/setting_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package pagerules_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/pagerules" +) + +func TestSettingList(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("user@example.com"), + ) + _, err := client.Pagerules.Settings.List(context.TODO(), pagerules.SettingListParams{ + ZoneID: cloudflare.F("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/pagerulesetting.go b/pagerulesetting.go deleted file mode 100644 index d9024f01726..00000000000 --- a/pagerulesetting.go +++ /dev/null @@ -1,135 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// PageruleSettingService 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 [NewPageruleSettingService] method -// instead. -type PageruleSettingService struct { - Options []option.RequestOption -} - -// NewPageruleSettingService 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 NewPageruleSettingService(opts ...option.RequestOption) (r *PageruleSettingService) { - r = &PageruleSettingService{} - r.Options = opts - return -} - -// Returns a list of settings (and their details) that Page Rules can apply to -// matching requests. -func (r *PageruleSettingService) List(ctx context.Context, query PageruleSettingListParams, opts ...option.RequestOption) (res *[]PageruleSettingListResponse, err error) { - opts = append(r.Options[:], opts...) - var env PageruleSettingListResponseEnvelope - path := fmt.Sprintf("zones/%s/pagerules/settings", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type PageruleSettingListResponse = interface{} - -type PageruleSettingListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type PageruleSettingListResponseEnvelope struct { - Errors []PageruleSettingListResponseEnvelopeErrors `json:"errors,required"` - Messages []PageruleSettingListResponseEnvelopeMessages `json:"messages,required"` - // Settings available for the zone. - Result []PageruleSettingListResponse `json:"result,required"` - // Whether the API call was successful - Success PageruleSettingListResponseEnvelopeSuccess `json:"success,required"` - JSON pageruleSettingListResponseEnvelopeJSON `json:"-"` -} - -// pageruleSettingListResponseEnvelopeJSON contains the JSON metadata for the -// struct [PageruleSettingListResponseEnvelope] -type pageruleSettingListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageruleSettingListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageruleSettingListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PageruleSettingListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageruleSettingListResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageruleSettingListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PageruleSettingListResponseEnvelopeErrors] -type pageruleSettingListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageruleSettingListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageruleSettingListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageruleSettingListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageruleSettingListResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageruleSettingListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [PageruleSettingListResponseEnvelopeMessages] -type pageruleSettingListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageruleSettingListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageruleSettingListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PageruleSettingListResponseEnvelopeSuccess bool - -const ( - PageruleSettingListResponseEnvelopeSuccessTrue PageruleSettingListResponseEnvelopeSuccess = true -) diff --git a/pagerulesetting_test.go b/pagerulesetting_test.go deleted file mode 100644 index b2dc8ddd347..00000000000 --- a/pagerulesetting_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestPageruleSettingList(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("user@example.com"), - ) - _, err := client.Pagerules.Settings.List(context.TODO(), cloudflare.PageruleSettingListParams{ - ZoneID: cloudflare.F("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/pages/aliases.go b/pages/aliases.go new file mode 100644 index 00000000000..e6811c0adad --- /dev/null +++ b/pages/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package pages + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/pages/page.go b/pages/page.go new file mode 100644 index 00000000000..adacf85df62 --- /dev/null +++ b/pages/page.go @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package pages + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// PageService 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 [NewPageService] method instead. +type PageService struct { + Options []option.RequestOption + Projects *ProjectService +} + +// NewPageService 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 NewPageService(opts ...option.RequestOption) (r *PageService) { + r = &PageService{} + r.Options = opts + r.Projects = NewProjectService(opts...) + return +} diff --git a/pages/project.go b/pages/project.go new file mode 100644 index 00000000000..1df55c9efa0 --- /dev/null +++ b/pages/project.go @@ -0,0 +1,2395 @@ +// File generated from our OpenAPI spec by Stainless. + +package pages + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// ProjectService 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 [NewProjectService] method instead. +type ProjectService struct { + Options []option.RequestOption + Deployments *ProjectDeploymentService + Domains *ProjectDomainService +} + +// NewProjectService 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 NewProjectService(opts ...option.RequestOption) (r *ProjectService) { + r = &ProjectService{} + r.Options = opts + r.Deployments = NewProjectDeploymentService(opts...) + r.Domains = NewProjectDomainService(opts...) + return +} + +// Create a new project. +func (r *ProjectService) New(ctx context.Context, params ProjectNewParams, opts ...option.RequestOption) (res *ProjectNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env ProjectNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/pages/projects", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch a list of all user projects. +func (r *ProjectService) List(ctx context.Context, query ProjectListParams, opts ...option.RequestOption) (res *[]PagesDeployments, err error) { + opts = append(r.Options[:], opts...) + var env ProjectListResponseEnvelope + path := fmt.Sprintf("accounts/%s/pages/projects", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a project by name. +func (r *ProjectService) Delete(ctx context.Context, projectName string, body ProjectDeleteParams, opts ...option.RequestOption) (res *ProjectDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("accounts/%s/pages/projects/%s", body.AccountID, projectName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &res, opts...) + return +} + +// Set new attributes for an existing project. Modify environment variables. To +// delete an environment variable, set the key to null. +func (r *ProjectService) Edit(ctx context.Context, projectName string, params ProjectEditParams, opts ...option.RequestOption) (res *ProjectEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env ProjectEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/pages/projects/%s", params.AccountID, projectName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch a project by name. +func (r *ProjectService) Get(ctx context.Context, projectName string, query ProjectGetParams, opts ...option.RequestOption) (res *PagesProjects, err error) { + opts = append(r.Options[:], opts...) + var env ProjectGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/pages/projects/%s", query.AccountID, projectName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Purge all cached build artifacts for a Pages project +func (r *ProjectService) PurgeBuildCache(ctx context.Context, projectName string, body ProjectPurgeBuildCacheParams, opts ...option.RequestOption) (res *ProjectPurgeBuildCacheResponse, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("accounts/%s/pages/projects/%s/purge_build_cache", body.AccountID, projectName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) + return +} + +type PagesDeployments struct { + // Id of the deployment. + ID string `json:"id"` + // A list of alias URLs pointing to this deployment. + Aliases []interface{} `json:"aliases,nullable"` + BuildConfig interface{} `json:"build_config"` + // When the deployment was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Info about what caused the deployment. + DeploymentTrigger PagesDeploymentsDeploymentTrigger `json:"deployment_trigger"` + // A dict of env variables to build this deploy. + EnvVars interface{} `json:"env_vars"` + // Type of deploy. + Environment string `json:"environment"` + // If the deployment has been skipped. + IsSkipped bool `json:"is_skipped"` + LatestStage interface{} `json:"latest_stage"` + // When the deployment was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Id of the project. + ProjectID string `json:"project_id"` + // Name of the project. + ProjectName string `json:"project_name"` + // Short Id (8 character) of the deployment. + ShortID string `json:"short_id"` + Source interface{} `json:"source"` + // List of past stages. + Stages []PagesDeploymentsStage `json:"stages"` + // The live URL to view this deployment. + URL string `json:"url"` + JSON pagesDeploymentsJSON `json:"-"` +} + +// pagesDeploymentsJSON contains the JSON metadata for the struct +// [PagesDeployments] +type pagesDeploymentsJSON struct { + ID apijson.Field + Aliases apijson.Field + BuildConfig apijson.Field + CreatedOn apijson.Field + DeploymentTrigger apijson.Field + EnvVars apijson.Field + Environment apijson.Field + IsSkipped apijson.Field + LatestStage apijson.Field + ModifiedOn apijson.Field + ProjectID apijson.Field + ProjectName apijson.Field + ShortID apijson.Field + Source apijson.Field + Stages apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesDeployments) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesDeploymentsJSON) RawJSON() string { + return r.raw +} + +// Info about what caused the deployment. +type PagesDeploymentsDeploymentTrigger struct { + // Additional info about the trigger. + Metadata PagesDeploymentsDeploymentTriggerMetadata `json:"metadata"` + // What caused the deployment. + Type string `json:"type"` + JSON pagesDeploymentsDeploymentTriggerJSON `json:"-"` +} + +// pagesDeploymentsDeploymentTriggerJSON contains the JSON metadata for the struct +// [PagesDeploymentsDeploymentTrigger] +type pagesDeploymentsDeploymentTriggerJSON struct { + Metadata apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesDeploymentsDeploymentTrigger) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesDeploymentsDeploymentTriggerJSON) RawJSON() string { + return r.raw +} + +// Additional info about the trigger. +type PagesDeploymentsDeploymentTriggerMetadata struct { + // Where the trigger happened. + Branch string `json:"branch"` + // Hash of the deployment trigger commit. + CommitHash string `json:"commit_hash"` + // Message of the deployment trigger commit. + CommitMessage string `json:"commit_message"` + JSON pagesDeploymentsDeploymentTriggerMetadataJSON `json:"-"` +} + +// pagesDeploymentsDeploymentTriggerMetadataJSON contains the JSON metadata for the +// struct [PagesDeploymentsDeploymentTriggerMetadata] +type pagesDeploymentsDeploymentTriggerMetadataJSON struct { + Branch apijson.Field + CommitHash apijson.Field + CommitMessage apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesDeploymentsDeploymentTriggerMetadata) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesDeploymentsDeploymentTriggerMetadataJSON) RawJSON() string { + return r.raw +} + +// The status of the deployment. +type PagesDeploymentsStage struct { + // When the stage ended. + EndedOn time.Time `json:"ended_on,nullable" format:"date-time"` + // The current build stage. + Name string `json:"name"` + // When the stage started. + StartedOn time.Time `json:"started_on,nullable" format:"date-time"` + // State of the current stage. + Status string `json:"status"` + JSON pagesDeploymentsStageJSON `json:"-"` +} + +// pagesDeploymentsStageJSON contains the JSON metadata for the struct +// [PagesDeploymentsStage] +type pagesDeploymentsStageJSON struct { + EndedOn apijson.Field + Name apijson.Field + StartedOn apijson.Field + Status apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesDeploymentsStage) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesDeploymentsStageJSON) RawJSON() string { + return r.raw +} + +type PagesDeploymentsParam struct { +} + +func (r PagesDeploymentsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Info about what caused the deployment. +type PagesDeploymentsDeploymentTriggerParam struct { + // Additional info about the trigger. + Metadata param.Field[PagesDeploymentsDeploymentTriggerMetadataParam] `json:"metadata"` +} + +func (r PagesDeploymentsDeploymentTriggerParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Additional info about the trigger. +type PagesDeploymentsDeploymentTriggerMetadataParam struct { +} + +func (r PagesDeploymentsDeploymentTriggerMetadataParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The status of the deployment. +type PagesDeploymentsStageParam struct { + // The current build stage. + Name param.Field[string] `json:"name"` +} + +func (r PagesDeploymentsStageParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type PagesProjects struct { + // Id of the project. + ID string `json:"id"` + // Configs for the project build process. + BuildConfig PagesProjectsBuildConfig `json:"build_config"` + CanonicalDeployment PagesDeployments `json:"canonical_deployment"` + // When the project was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Configs for deployments in a project. + DeploymentConfigs PagesProjectsDeploymentConfigs `json:"deployment_configs"` + // A list of associated custom domains for the project. + Domains []interface{} `json:"domains"` + LatestDeployment PagesDeployments `json:"latest_deployment"` + // Name of the project. + Name string `json:"name"` + // Production branch of the project. Used to identify production deployments. + ProductionBranch string `json:"production_branch"` + Source interface{} `json:"source"` + // The Cloudflare subdomain associated with the project. + Subdomain string `json:"subdomain"` + JSON pagesProjectsJSON `json:"-"` +} + +// pagesProjectsJSON contains the JSON metadata for the struct [PagesProjects] +type pagesProjectsJSON struct { + ID apijson.Field + BuildConfig apijson.Field + CanonicalDeployment apijson.Field + CreatedOn apijson.Field + DeploymentConfigs apijson.Field + Domains apijson.Field + LatestDeployment apijson.Field + Name apijson.Field + ProductionBranch apijson.Field + Source apijson.Field + Subdomain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjects) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsJSON) RawJSON() string { + return r.raw +} + +// Configs for the project build process. +type PagesProjectsBuildConfig struct { + // Enable build caching for the project. + BuildCaching bool `json:"build_caching,nullable"` + // Command used to build project. + BuildCommand string `json:"build_command,nullable"` + // Output directory of the build. + DestinationDir string `json:"destination_dir,nullable"` + // Directory to run the command. + RootDir string `json:"root_dir,nullable"` + // The classifying tag for analytics. + WebAnalyticsTag string `json:"web_analytics_tag,nullable"` + // The auth token for analytics. + WebAnalyticsToken string `json:"web_analytics_token,nullable"` + JSON pagesProjectsBuildConfigJSON `json:"-"` +} + +// pagesProjectsBuildConfigJSON contains the JSON metadata for the struct +// [PagesProjectsBuildConfig] +type pagesProjectsBuildConfigJSON struct { + BuildCaching apijson.Field + BuildCommand apijson.Field + DestinationDir apijson.Field + RootDir apijson.Field + WebAnalyticsTag apijson.Field + WebAnalyticsToken apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsBuildConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsBuildConfigJSON) RawJSON() string { + return r.raw +} + +// Configs for deployments in a project. +type PagesProjectsDeploymentConfigs struct { + // Configs for preview deploys. + Preview PagesProjectsDeploymentConfigsPreview `json:"preview"` + // Configs for production deploys. + Production PagesProjectsDeploymentConfigsProduction `json:"production"` + JSON pagesProjectsDeploymentConfigsJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsJSON contains the JSON metadata for the struct +// [PagesProjectsDeploymentConfigs] +type pagesProjectsDeploymentConfigsJSON struct { + Preview apijson.Field + Production apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsJSON) RawJSON() string { + return r.raw +} + +// Configs for preview deploys. +type PagesProjectsDeploymentConfigsPreview struct { + // Constellation bindings used for Pages Functions. + AIBindings PagesProjectsDeploymentConfigsPreviewAIBindings `json:"ai_bindings,nullable"` + // Analytics Engine bindings used for Pages Functions. + AnalyticsEngineDatasets PagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasets `json:"analytics_engine_datasets,nullable"` + // Compatibility date used for Pages Functions. + CompatibilityDate string `json:"compatibility_date"` + // Compatibility flags used for Pages Functions. + CompatibilityFlags []interface{} `json:"compatibility_flags"` + // D1 databases used for Pages Functions. + D1Databases PagesProjectsDeploymentConfigsPreviewD1Databases `json:"d1_databases,nullable"` + // Durabble Object namespaces used for Pages Functions. + DurableObjectNamespaces PagesProjectsDeploymentConfigsPreviewDurableObjectNamespaces `json:"durable_object_namespaces,nullable"` + // Environment variables for build configs. + EnvVars PagesProjectsDeploymentConfigsPreviewEnvVars `json:"env_vars,nullable"` + // KV namespaces used for Pages Functions. + KVNamespaces PagesProjectsDeploymentConfigsPreviewKVNamespaces `json:"kv_namespaces"` + // Placement setting used for Pages Functions. + Placement PagesProjectsDeploymentConfigsPreviewPlacement `json:"placement,nullable"` + // Queue Producer bindings used for Pages Functions. + QueueProducers PagesProjectsDeploymentConfigsPreviewQueueProducers `json:"queue_producers,nullable"` + // R2 buckets used for Pages Functions. + R2Buckets PagesProjectsDeploymentConfigsPreviewR2Buckets `json:"r2_buckets,nullable"` + // Services used for Pages Functions. + ServiceBindings PagesProjectsDeploymentConfigsPreviewServiceBindings `json:"service_bindings,nullable"` + JSON pagesProjectsDeploymentConfigsPreviewJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewJSON contains the JSON metadata for the +// struct [PagesProjectsDeploymentConfigsPreview] +type pagesProjectsDeploymentConfigsPreviewJSON struct { + AIBindings apijson.Field + AnalyticsEngineDatasets apijson.Field + CompatibilityDate apijson.Field + CompatibilityFlags apijson.Field + D1Databases apijson.Field + DurableObjectNamespaces apijson.Field + EnvVars apijson.Field + KVNamespaces apijson.Field + Placement apijson.Field + QueueProducers apijson.Field + R2Buckets apijson.Field + ServiceBindings apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreview) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewJSON) RawJSON() string { + return r.raw +} + +// Constellation bindings used for Pages Functions. +type PagesProjectsDeploymentConfigsPreviewAIBindings struct { + // AI binding. + AIBinding PagesProjectsDeploymentConfigsPreviewAIBindingsAIBinding `json:"AI_BINDING"` + JSON pagesProjectsDeploymentConfigsPreviewAIBindingsJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewAIBindingsJSON contains the JSON metadata +// for the struct [PagesProjectsDeploymentConfigsPreviewAIBindings] +type pagesProjectsDeploymentConfigsPreviewAIBindingsJSON struct { + AIBinding apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewAIBindings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewAIBindingsJSON) RawJSON() string { + return r.raw +} + +// AI binding. +type PagesProjectsDeploymentConfigsPreviewAIBindingsAIBinding struct { + ProjectID interface{} `json:"project_id"` + JSON pagesProjectsDeploymentConfigsPreviewAIBindingsAIBindingJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewAIBindingsAIBindingJSON contains the JSON +// metadata for the struct +// [PagesProjectsDeploymentConfigsPreviewAIBindingsAIBinding] +type pagesProjectsDeploymentConfigsPreviewAIBindingsAIBindingJSON struct { + ProjectID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewAIBindingsAIBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewAIBindingsAIBindingJSON) RawJSON() string { + return r.raw +} + +// Analytics Engine bindings used for Pages Functions. +type PagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasets struct { + // Analytics Engine binding. + AnalyticsEngineBinding PagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding `json:"ANALYTICS_ENGINE_BINDING"` + JSON pagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsJSON contains the +// JSON metadata for the struct +// [PagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasets] +type pagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsJSON struct { + AnalyticsEngineBinding apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasets) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsJSON) RawJSON() string { + return r.raw +} + +// Analytics Engine binding. +type PagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding struct { + // Name of the dataset. + Dataset string `json:"dataset"` + JSON pagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingJSON +// contains the JSON metadata for the struct +// [PagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding] +type pagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingJSON struct { + Dataset apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBindingJSON) RawJSON() string { + return r.raw +} + +// D1 databases used for Pages Functions. +type PagesProjectsDeploymentConfigsPreviewD1Databases struct { + // D1 binding. + D1Binding PagesProjectsDeploymentConfigsPreviewD1DatabasesD1Binding `json:"D1_BINDING"` + JSON pagesProjectsDeploymentConfigsPreviewD1DatabasesJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewD1DatabasesJSON contains the JSON metadata +// for the struct [PagesProjectsDeploymentConfigsPreviewD1Databases] +type pagesProjectsDeploymentConfigsPreviewD1DatabasesJSON struct { + D1Binding apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewD1Databases) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewD1DatabasesJSON) RawJSON() string { + return r.raw +} + +// D1 binding. +type PagesProjectsDeploymentConfigsPreviewD1DatabasesD1Binding struct { + // UUID of the D1 database. + ID string `json:"id"` + JSON pagesProjectsDeploymentConfigsPreviewD1DatabasesD1BindingJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewD1DatabasesD1BindingJSON contains the JSON +// metadata for the struct +// [PagesProjectsDeploymentConfigsPreviewD1DatabasesD1Binding] +type pagesProjectsDeploymentConfigsPreviewD1DatabasesD1BindingJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewD1DatabasesD1Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewD1DatabasesD1BindingJSON) RawJSON() string { + return r.raw +} + +// Durabble Object namespaces used for Pages Functions. +type PagesProjectsDeploymentConfigsPreviewDurableObjectNamespaces struct { + // Durabble Object binding. + DoBinding PagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding `json:"DO_BINDING"` + JSON pagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesJSON contains the +// JSON metadata for the struct +// [PagesProjectsDeploymentConfigsPreviewDurableObjectNamespaces] +type pagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesJSON struct { + DoBinding apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewDurableObjectNamespaces) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesJSON) RawJSON() string { + return r.raw +} + +// Durabble Object binding. +type PagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding struct { + // ID of the Durabble Object namespace. + NamespaceID string `json:"namespace_id"` + JSON pagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesDoBindingJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesDoBindingJSON +// contains the JSON metadata for the struct +// [PagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding] +type pagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesDoBindingJSON struct { + NamespaceID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewDurableObjectNamespacesDoBindingJSON) RawJSON() string { + return r.raw +} + +// Environment variables for build configs. +type PagesProjectsDeploymentConfigsPreviewEnvVars struct { + // Environment variable. + EnvironmentVariable PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariable `json:"ENVIRONMENT_VARIABLE"` + JSON pagesProjectsDeploymentConfigsPreviewEnvVarsJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewEnvVarsJSON contains the JSON metadata for +// the struct [PagesProjectsDeploymentConfigsPreviewEnvVars] +type pagesProjectsDeploymentConfigsPreviewEnvVarsJSON struct { + EnvironmentVariable apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewEnvVars) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewEnvVarsJSON) RawJSON() string { + return r.raw +} + +// Environment variable. +type PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariable struct { + // The type of environment variable (plain text or secret) + Type PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType `json:"type"` + // Environment variable value. + Value string `json:"value"` + JSON pagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableJSON contains the +// JSON metadata for the struct +// [PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariable] +type pagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableJSON struct { + Type apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariable) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableJSON) RawJSON() string { + return r.raw +} + +// The type of environment variable (plain text or secret) +type PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType string + +const ( + PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypePlainText PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType = "plain_text" + PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypeSecretText PagesProjectsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType = "secret_text" +) + +// KV namespaces used for Pages Functions. +type PagesProjectsDeploymentConfigsPreviewKVNamespaces struct { + // KV binding. + KVBinding PagesProjectsDeploymentConfigsPreviewKVNamespacesKVBinding `json:"KV_BINDING"` + JSON pagesProjectsDeploymentConfigsPreviewKVNamespacesJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewKVNamespacesJSON contains the JSON metadata +// for the struct [PagesProjectsDeploymentConfigsPreviewKVNamespaces] +type pagesProjectsDeploymentConfigsPreviewKVNamespacesJSON struct { + KVBinding apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewKVNamespaces) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewKVNamespacesJSON) RawJSON() string { + return r.raw +} + +// KV binding. +type PagesProjectsDeploymentConfigsPreviewKVNamespacesKVBinding struct { + // ID of the KV namespace. + NamespaceID string `json:"namespace_id"` + JSON pagesProjectsDeploymentConfigsPreviewKVNamespacesKVBindingJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewKVNamespacesKVBindingJSON contains the JSON +// metadata for the struct +// [PagesProjectsDeploymentConfigsPreviewKVNamespacesKVBinding] +type pagesProjectsDeploymentConfigsPreviewKVNamespacesKVBindingJSON struct { + NamespaceID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewKVNamespacesKVBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewKVNamespacesKVBindingJSON) RawJSON() string { + return r.raw +} + +// Placement setting used for Pages Functions. +type PagesProjectsDeploymentConfigsPreviewPlacement struct { + // Placement mode. + Mode string `json:"mode"` + JSON pagesProjectsDeploymentConfigsPreviewPlacementJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewPlacementJSON contains the JSON metadata +// for the struct [PagesProjectsDeploymentConfigsPreviewPlacement] +type pagesProjectsDeploymentConfigsPreviewPlacementJSON struct { + Mode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewPlacement) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewPlacementJSON) RawJSON() string { + return r.raw +} + +// Queue Producer bindings used for Pages Functions. +type PagesProjectsDeploymentConfigsPreviewQueueProducers struct { + // Queue Producer binding. + QueueProducerBinding PagesProjectsDeploymentConfigsPreviewQueueProducersQueueProducerBinding `json:"QUEUE_PRODUCER_BINDING"` + JSON pagesProjectsDeploymentConfigsPreviewQueueProducersJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewQueueProducersJSON contains the JSON +// metadata for the struct [PagesProjectsDeploymentConfigsPreviewQueueProducers] +type pagesProjectsDeploymentConfigsPreviewQueueProducersJSON struct { + QueueProducerBinding apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewQueueProducers) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewQueueProducersJSON) RawJSON() string { + return r.raw +} + +// Queue Producer binding. +type PagesProjectsDeploymentConfigsPreviewQueueProducersQueueProducerBinding struct { + // Name of the Queue. + Name string `json:"name"` + JSON pagesProjectsDeploymentConfigsPreviewQueueProducersQueueProducerBindingJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewQueueProducersQueueProducerBindingJSON +// contains the JSON metadata for the struct +// [PagesProjectsDeploymentConfigsPreviewQueueProducersQueueProducerBinding] +type pagesProjectsDeploymentConfigsPreviewQueueProducersQueueProducerBindingJSON struct { + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewQueueProducersQueueProducerBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewQueueProducersQueueProducerBindingJSON) RawJSON() string { + return r.raw +} + +// R2 buckets used for Pages Functions. +type PagesProjectsDeploymentConfigsPreviewR2Buckets struct { + // R2 binding. + R2Binding PagesProjectsDeploymentConfigsPreviewR2BucketsR2Binding `json:"R2_BINDING"` + JSON pagesProjectsDeploymentConfigsPreviewR2BucketsJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewR2BucketsJSON contains the JSON metadata +// for the struct [PagesProjectsDeploymentConfigsPreviewR2Buckets] +type pagesProjectsDeploymentConfigsPreviewR2BucketsJSON struct { + R2Binding apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewR2Buckets) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewR2BucketsJSON) RawJSON() string { + return r.raw +} + +// R2 binding. +type PagesProjectsDeploymentConfigsPreviewR2BucketsR2Binding struct { + // Name of the R2 bucket. + Name string `json:"name"` + JSON pagesProjectsDeploymentConfigsPreviewR2BucketsR2BindingJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewR2BucketsR2BindingJSON contains the JSON +// metadata for the struct +// [PagesProjectsDeploymentConfigsPreviewR2BucketsR2Binding] +type pagesProjectsDeploymentConfigsPreviewR2BucketsR2BindingJSON struct { + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewR2BucketsR2Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewR2BucketsR2BindingJSON) RawJSON() string { + return r.raw +} + +// Services used for Pages Functions. +type PagesProjectsDeploymentConfigsPreviewServiceBindings struct { + // Service binding. + ServiceBinding PagesProjectsDeploymentConfigsPreviewServiceBindingsServiceBinding `json:"SERVICE_BINDING"` + JSON pagesProjectsDeploymentConfigsPreviewServiceBindingsJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewServiceBindingsJSON contains the JSON +// metadata for the struct [PagesProjectsDeploymentConfigsPreviewServiceBindings] +type pagesProjectsDeploymentConfigsPreviewServiceBindingsJSON struct { + ServiceBinding apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewServiceBindings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewServiceBindingsJSON) RawJSON() string { + return r.raw +} + +// Service binding. +type PagesProjectsDeploymentConfigsPreviewServiceBindingsServiceBinding struct { + // The Service environment. + Environment string `json:"environment"` + // The Service name. + Service string `json:"service"` + JSON pagesProjectsDeploymentConfigsPreviewServiceBindingsServiceBindingJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsPreviewServiceBindingsServiceBindingJSON contains +// the JSON metadata for the struct +// [PagesProjectsDeploymentConfigsPreviewServiceBindingsServiceBinding] +type pagesProjectsDeploymentConfigsPreviewServiceBindingsServiceBindingJSON struct { + Environment apijson.Field + Service apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsPreviewServiceBindingsServiceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsPreviewServiceBindingsServiceBindingJSON) RawJSON() string { + return r.raw +} + +// Configs for production deploys. +type PagesProjectsDeploymentConfigsProduction struct { + // Constellation bindings used for Pages Functions. + AIBindings PagesProjectsDeploymentConfigsProductionAIBindings `json:"ai_bindings,nullable"` + // Analytics Engine bindings used for Pages Functions. + AnalyticsEngineDatasets PagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasets `json:"analytics_engine_datasets,nullable"` + // Compatibility date used for Pages Functions. + CompatibilityDate string `json:"compatibility_date"` + // Compatibility flags used for Pages Functions. + CompatibilityFlags []interface{} `json:"compatibility_flags"` + // D1 databases used for Pages Functions. + D1Databases PagesProjectsDeploymentConfigsProductionD1Databases `json:"d1_databases,nullable"` + // Durabble Object namespaces used for Pages Functions. + DurableObjectNamespaces PagesProjectsDeploymentConfigsProductionDurableObjectNamespaces `json:"durable_object_namespaces,nullable"` + // Environment variables for build configs. + EnvVars PagesProjectsDeploymentConfigsProductionEnvVars `json:"env_vars,nullable"` + // KV namespaces used for Pages Functions. + KVNamespaces PagesProjectsDeploymentConfigsProductionKVNamespaces `json:"kv_namespaces"` + // Placement setting used for Pages Functions. + Placement PagesProjectsDeploymentConfigsProductionPlacement `json:"placement,nullable"` + // Queue Producer bindings used for Pages Functions. + QueueProducers PagesProjectsDeploymentConfigsProductionQueueProducers `json:"queue_producers,nullable"` + // R2 buckets used for Pages Functions. + R2Buckets PagesProjectsDeploymentConfigsProductionR2Buckets `json:"r2_buckets,nullable"` + // Services used for Pages Functions. + ServiceBindings PagesProjectsDeploymentConfigsProductionServiceBindings `json:"service_bindings,nullable"` + JSON pagesProjectsDeploymentConfigsProductionJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionJSON contains the JSON metadata for the +// struct [PagesProjectsDeploymentConfigsProduction] +type pagesProjectsDeploymentConfigsProductionJSON struct { + AIBindings apijson.Field + AnalyticsEngineDatasets apijson.Field + CompatibilityDate apijson.Field + CompatibilityFlags apijson.Field + D1Databases apijson.Field + DurableObjectNamespaces apijson.Field + EnvVars apijson.Field + KVNamespaces apijson.Field + Placement apijson.Field + QueueProducers apijson.Field + R2Buckets apijson.Field + ServiceBindings apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProduction) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionJSON) RawJSON() string { + return r.raw +} + +// Constellation bindings used for Pages Functions. +type PagesProjectsDeploymentConfigsProductionAIBindings struct { + // AI binding. + AIBinding PagesProjectsDeploymentConfigsProductionAIBindingsAIBinding `json:"AI_BINDING"` + JSON pagesProjectsDeploymentConfigsProductionAIBindingsJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionAIBindingsJSON contains the JSON +// metadata for the struct [PagesProjectsDeploymentConfigsProductionAIBindings] +type pagesProjectsDeploymentConfigsProductionAIBindingsJSON struct { + AIBinding apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionAIBindings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionAIBindingsJSON) RawJSON() string { + return r.raw +} + +// AI binding. +type PagesProjectsDeploymentConfigsProductionAIBindingsAIBinding struct { + ProjectID interface{} `json:"project_id"` + JSON pagesProjectsDeploymentConfigsProductionAIBindingsAIBindingJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionAIBindingsAIBindingJSON contains the +// JSON metadata for the struct +// [PagesProjectsDeploymentConfigsProductionAIBindingsAIBinding] +type pagesProjectsDeploymentConfigsProductionAIBindingsAIBindingJSON struct { + ProjectID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionAIBindingsAIBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionAIBindingsAIBindingJSON) RawJSON() string { + return r.raw +} + +// Analytics Engine bindings used for Pages Functions. +type PagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasets struct { + // Analytics Engine binding. + AnalyticsEngineBinding PagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding `json:"ANALYTICS_ENGINE_BINDING"` + JSON pagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsJSON contains the +// JSON metadata for the struct +// [PagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasets] +type pagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsJSON struct { + AnalyticsEngineBinding apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasets) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsJSON) RawJSON() string { + return r.raw +} + +// Analytics Engine binding. +type PagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding struct { + // Name of the dataset. + Dataset string `json:"dataset"` + JSON pagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingJSON +// contains the JSON metadata for the struct +// [PagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding] +type pagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingJSON struct { + Dataset apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBindingJSON) RawJSON() string { + return r.raw +} + +// D1 databases used for Pages Functions. +type PagesProjectsDeploymentConfigsProductionD1Databases struct { + // D1 binding. + D1Binding PagesProjectsDeploymentConfigsProductionD1DatabasesD1Binding `json:"D1_BINDING"` + JSON pagesProjectsDeploymentConfigsProductionD1DatabasesJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionD1DatabasesJSON contains the JSON +// metadata for the struct [PagesProjectsDeploymentConfigsProductionD1Databases] +type pagesProjectsDeploymentConfigsProductionD1DatabasesJSON struct { + D1Binding apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionD1Databases) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionD1DatabasesJSON) RawJSON() string { + return r.raw +} + +// D1 binding. +type PagesProjectsDeploymentConfigsProductionD1DatabasesD1Binding struct { + // UUID of the D1 database. + ID string `json:"id"` + JSON pagesProjectsDeploymentConfigsProductionD1DatabasesD1BindingJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionD1DatabasesD1BindingJSON contains the +// JSON metadata for the struct +// [PagesProjectsDeploymentConfigsProductionD1DatabasesD1Binding] +type pagesProjectsDeploymentConfigsProductionD1DatabasesD1BindingJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionD1DatabasesD1Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionD1DatabasesD1BindingJSON) RawJSON() string { + return r.raw +} + +// Durabble Object namespaces used for Pages Functions. +type PagesProjectsDeploymentConfigsProductionDurableObjectNamespaces struct { + // Durabble Object binding. + DoBinding PagesProjectsDeploymentConfigsProductionDurableObjectNamespacesDoBinding `json:"DO_BINDING"` + JSON pagesProjectsDeploymentConfigsProductionDurableObjectNamespacesJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionDurableObjectNamespacesJSON contains the +// JSON metadata for the struct +// [PagesProjectsDeploymentConfigsProductionDurableObjectNamespaces] +type pagesProjectsDeploymentConfigsProductionDurableObjectNamespacesJSON struct { + DoBinding apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionDurableObjectNamespaces) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionDurableObjectNamespacesJSON) RawJSON() string { + return r.raw +} + +// Durabble Object binding. +type PagesProjectsDeploymentConfigsProductionDurableObjectNamespacesDoBinding struct { + // ID of the Durabble Object namespace. + NamespaceID string `json:"namespace_id"` + JSON pagesProjectsDeploymentConfigsProductionDurableObjectNamespacesDoBindingJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionDurableObjectNamespacesDoBindingJSON +// contains the JSON metadata for the struct +// [PagesProjectsDeploymentConfigsProductionDurableObjectNamespacesDoBinding] +type pagesProjectsDeploymentConfigsProductionDurableObjectNamespacesDoBindingJSON struct { + NamespaceID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionDurableObjectNamespacesDoBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionDurableObjectNamespacesDoBindingJSON) RawJSON() string { + return r.raw +} + +// Environment variables for build configs. +type PagesProjectsDeploymentConfigsProductionEnvVars struct { + // Environment variable. + EnvironmentVariable PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariable `json:"ENVIRONMENT_VARIABLE"` + JSON pagesProjectsDeploymentConfigsProductionEnvVarsJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionEnvVarsJSON contains the JSON metadata +// for the struct [PagesProjectsDeploymentConfigsProductionEnvVars] +type pagesProjectsDeploymentConfigsProductionEnvVarsJSON struct { + EnvironmentVariable apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionEnvVars) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionEnvVarsJSON) RawJSON() string { + return r.raw +} + +// Environment variable. +type PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariable struct { + // The type of environment variable (plain text or secret) + Type PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableType `json:"type"` + // Environment variable value. + Value string `json:"value"` + JSON pagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableJSON contains +// the JSON metadata for the struct +// [PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariable] +type pagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableJSON struct { + Type apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariable) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableJSON) RawJSON() string { + return r.raw +} + +// The type of environment variable (plain text or secret) +type PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableType string + +const ( + PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableTypePlainText PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableType = "plain_text" + PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableTypeSecretText PagesProjectsDeploymentConfigsProductionEnvVarsEnvironmentVariableType = "secret_text" +) + +// KV namespaces used for Pages Functions. +type PagesProjectsDeploymentConfigsProductionKVNamespaces struct { + // KV binding. + KVBinding PagesProjectsDeploymentConfigsProductionKVNamespacesKVBinding `json:"KV_BINDING"` + JSON pagesProjectsDeploymentConfigsProductionKVNamespacesJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionKVNamespacesJSON contains the JSON +// metadata for the struct [PagesProjectsDeploymentConfigsProductionKVNamespaces] +type pagesProjectsDeploymentConfigsProductionKVNamespacesJSON struct { + KVBinding apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionKVNamespaces) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionKVNamespacesJSON) RawJSON() string { + return r.raw +} + +// KV binding. +type PagesProjectsDeploymentConfigsProductionKVNamespacesKVBinding struct { + // ID of the KV namespace. + NamespaceID string `json:"namespace_id"` + JSON pagesProjectsDeploymentConfigsProductionKVNamespacesKVBindingJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionKVNamespacesKVBindingJSON contains the +// JSON metadata for the struct +// [PagesProjectsDeploymentConfigsProductionKVNamespacesKVBinding] +type pagesProjectsDeploymentConfigsProductionKVNamespacesKVBindingJSON struct { + NamespaceID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionKVNamespacesKVBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionKVNamespacesKVBindingJSON) RawJSON() string { + return r.raw +} + +// Placement setting used for Pages Functions. +type PagesProjectsDeploymentConfigsProductionPlacement struct { + // Placement mode. + Mode string `json:"mode"` + JSON pagesProjectsDeploymentConfigsProductionPlacementJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionPlacementJSON contains the JSON metadata +// for the struct [PagesProjectsDeploymentConfigsProductionPlacement] +type pagesProjectsDeploymentConfigsProductionPlacementJSON struct { + Mode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionPlacement) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionPlacementJSON) RawJSON() string { + return r.raw +} + +// Queue Producer bindings used for Pages Functions. +type PagesProjectsDeploymentConfigsProductionQueueProducers struct { + // Queue Producer binding. + QueueProducerBinding PagesProjectsDeploymentConfigsProductionQueueProducersQueueProducerBinding `json:"QUEUE_PRODUCER_BINDING"` + JSON pagesProjectsDeploymentConfigsProductionQueueProducersJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionQueueProducersJSON contains the JSON +// metadata for the struct [PagesProjectsDeploymentConfigsProductionQueueProducers] +type pagesProjectsDeploymentConfigsProductionQueueProducersJSON struct { + QueueProducerBinding apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionQueueProducers) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionQueueProducersJSON) RawJSON() string { + return r.raw +} + +// Queue Producer binding. +type PagesProjectsDeploymentConfigsProductionQueueProducersQueueProducerBinding struct { + // Name of the Queue. + Name string `json:"name"` + JSON pagesProjectsDeploymentConfigsProductionQueueProducersQueueProducerBindingJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionQueueProducersQueueProducerBindingJSON +// contains the JSON metadata for the struct +// [PagesProjectsDeploymentConfigsProductionQueueProducersQueueProducerBinding] +type pagesProjectsDeploymentConfigsProductionQueueProducersQueueProducerBindingJSON struct { + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionQueueProducersQueueProducerBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionQueueProducersQueueProducerBindingJSON) RawJSON() string { + return r.raw +} + +// R2 buckets used for Pages Functions. +type PagesProjectsDeploymentConfigsProductionR2Buckets struct { + // R2 binding. + R2Binding PagesProjectsDeploymentConfigsProductionR2BucketsR2Binding `json:"R2_BINDING"` + JSON pagesProjectsDeploymentConfigsProductionR2BucketsJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionR2BucketsJSON contains the JSON metadata +// for the struct [PagesProjectsDeploymentConfigsProductionR2Buckets] +type pagesProjectsDeploymentConfigsProductionR2BucketsJSON struct { + R2Binding apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionR2Buckets) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionR2BucketsJSON) RawJSON() string { + return r.raw +} + +// R2 binding. +type PagesProjectsDeploymentConfigsProductionR2BucketsR2Binding struct { + // Name of the R2 bucket. + Name string `json:"name"` + JSON pagesProjectsDeploymentConfigsProductionR2BucketsR2BindingJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionR2BucketsR2BindingJSON contains the JSON +// metadata for the struct +// [PagesProjectsDeploymentConfigsProductionR2BucketsR2Binding] +type pagesProjectsDeploymentConfigsProductionR2BucketsR2BindingJSON struct { + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionR2BucketsR2Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionR2BucketsR2BindingJSON) RawJSON() string { + return r.raw +} + +// Services used for Pages Functions. +type PagesProjectsDeploymentConfigsProductionServiceBindings struct { + // Service binding. + ServiceBinding PagesProjectsDeploymentConfigsProductionServiceBindingsServiceBinding `json:"SERVICE_BINDING"` + JSON pagesProjectsDeploymentConfigsProductionServiceBindingsJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionServiceBindingsJSON contains the JSON +// metadata for the struct +// [PagesProjectsDeploymentConfigsProductionServiceBindings] +type pagesProjectsDeploymentConfigsProductionServiceBindingsJSON struct { + ServiceBinding apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionServiceBindings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionServiceBindingsJSON) RawJSON() string { + return r.raw +} + +// Service binding. +type PagesProjectsDeploymentConfigsProductionServiceBindingsServiceBinding struct { + // The Service environment. + Environment string `json:"environment"` + // The Service name. + Service string `json:"service"` + JSON pagesProjectsDeploymentConfigsProductionServiceBindingsServiceBindingJSON `json:"-"` +} + +// pagesProjectsDeploymentConfigsProductionServiceBindingsServiceBindingJSON +// contains the JSON metadata for the struct +// [PagesProjectsDeploymentConfigsProductionServiceBindingsServiceBinding] +type pagesProjectsDeploymentConfigsProductionServiceBindingsServiceBindingJSON struct { + Environment apijson.Field + Service apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PagesProjectsDeploymentConfigsProductionServiceBindingsServiceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pagesProjectsDeploymentConfigsProductionServiceBindingsServiceBindingJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [pages.ProjectNewResponseUnknown], +// [pages.ProjectNewResponseArray] or [shared.UnionString]. +type ProjectNewResponse interface { + ImplementsPagesProjectNewResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ProjectNewResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ProjectNewResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type ProjectNewResponseArray []interface{} + +func (r ProjectNewResponseArray) ImplementsPagesProjectNewResponse() {} + +type ProjectDeleteResponse = interface{} + +// Union satisfied by [pages.ProjectEditResponseUnknown], +// [pages.ProjectEditResponseArray] or [shared.UnionString]. +type ProjectEditResponse interface { + ImplementsPagesProjectEditResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ProjectEditResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ProjectEditResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type ProjectEditResponseArray []interface{} + +func (r ProjectEditResponseArray) ImplementsPagesProjectEditResponse() {} + +type ProjectPurgeBuildCacheResponse = interface{} + +type ProjectNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Configs for the project build process. + BuildConfig param.Field[ProjectNewParamsBuildConfig] `json:"build_config"` + CanonicalDeployment param.Field[PagesDeploymentsParam] `json:"canonical_deployment"` + // Configs for deployments in a project. + DeploymentConfigs param.Field[ProjectNewParamsDeploymentConfigs] `json:"deployment_configs"` + LatestDeployment param.Field[PagesDeploymentsParam] `json:"latest_deployment"` + // Name of the project. + Name param.Field[string] `json:"name"` + // Production branch of the project. Used to identify production deployments. + ProductionBranch param.Field[string] `json:"production_branch"` +} + +func (r ProjectNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configs for the project build process. +type ProjectNewParamsBuildConfig struct { + // Enable build caching for the project. + BuildCaching param.Field[bool] `json:"build_caching"` + // Command used to build project. + BuildCommand param.Field[string] `json:"build_command"` + // Output directory of the build. + DestinationDir param.Field[string] `json:"destination_dir"` + // Directory to run the command. + RootDir param.Field[string] `json:"root_dir"` + // The classifying tag for analytics. + WebAnalyticsTag param.Field[string] `json:"web_analytics_tag"` + // The auth token for analytics. + WebAnalyticsToken param.Field[string] `json:"web_analytics_token"` +} + +func (r ProjectNewParamsBuildConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configs for deployments in a project. +type ProjectNewParamsDeploymentConfigs struct { + // Configs for preview deploys. + Preview param.Field[ProjectNewParamsDeploymentConfigsPreview] `json:"preview"` + // Configs for production deploys. + Production param.Field[ProjectNewParamsDeploymentConfigsProduction] `json:"production"` +} + +func (r ProjectNewParamsDeploymentConfigs) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configs for preview deploys. +type ProjectNewParamsDeploymentConfigsPreview struct { + // Constellation bindings used for Pages Functions. + AIBindings param.Field[ProjectNewParamsDeploymentConfigsPreviewAIBindings] `json:"ai_bindings"` + // Analytics Engine bindings used for Pages Functions. + AnalyticsEngineDatasets param.Field[ProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasets] `json:"analytics_engine_datasets"` + // Compatibility date used for Pages Functions. + CompatibilityDate param.Field[string] `json:"compatibility_date"` + // Compatibility flags used for Pages Functions. + CompatibilityFlags param.Field[[]interface{}] `json:"compatibility_flags"` + // D1 databases used for Pages Functions. + D1Databases param.Field[ProjectNewParamsDeploymentConfigsPreviewD1Databases] `json:"d1_databases"` + // Durabble Object namespaces used for Pages Functions. + DurableObjectNamespaces param.Field[ProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespaces] `json:"durable_object_namespaces"` + // Environment variables for build configs. + EnvVars param.Field[ProjectNewParamsDeploymentConfigsPreviewEnvVars] `json:"env_vars"` + // KV namespaces used for Pages Functions. + KVNamespaces param.Field[ProjectNewParamsDeploymentConfigsPreviewKVNamespaces] `json:"kv_namespaces"` + // Placement setting used for Pages Functions. + Placement param.Field[ProjectNewParamsDeploymentConfigsPreviewPlacement] `json:"placement"` + // Queue Producer bindings used for Pages Functions. + QueueProducers param.Field[ProjectNewParamsDeploymentConfigsPreviewQueueProducers] `json:"queue_producers"` + // R2 buckets used for Pages Functions. + R2Buckets param.Field[ProjectNewParamsDeploymentConfigsPreviewR2Buckets] `json:"r2_buckets"` + // Services used for Pages Functions. + ServiceBindings param.Field[ProjectNewParamsDeploymentConfigsPreviewServiceBindings] `json:"service_bindings"` +} + +func (r ProjectNewParamsDeploymentConfigsPreview) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Constellation bindings used for Pages Functions. +type ProjectNewParamsDeploymentConfigsPreviewAIBindings struct { + // AI binding. + AIBinding param.Field[ProjectNewParamsDeploymentConfigsPreviewAIBindingsAIBinding] `json:"AI_BINDING"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewAIBindings) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// AI binding. +type ProjectNewParamsDeploymentConfigsPreviewAIBindingsAIBinding struct { + ProjectID param.Field[interface{}] `json:"project_id"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewAIBindingsAIBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Analytics Engine bindings used for Pages Functions. +type ProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasets struct { + // Analytics Engine binding. + AnalyticsEngineBinding param.Field[ProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding] `json:"ANALYTICS_ENGINE_BINDING"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasets) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Analytics Engine binding. +type ProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding struct { + // Name of the dataset. + Dataset param.Field[string] `json:"dataset"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// D1 databases used for Pages Functions. +type ProjectNewParamsDeploymentConfigsPreviewD1Databases struct { + // D1 binding. + D1Binding param.Field[ProjectNewParamsDeploymentConfigsPreviewD1DatabasesD1Binding] `json:"D1_BINDING"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewD1Databases) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// D1 binding. +type ProjectNewParamsDeploymentConfigsPreviewD1DatabasesD1Binding struct { + // UUID of the D1 database. + ID param.Field[string] `json:"id"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewD1DatabasesD1Binding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Durabble Object namespaces used for Pages Functions. +type ProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespaces struct { + // Durabble Object binding. + DoBinding param.Field[ProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding] `json:"DO_BINDING"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespaces) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Durabble Object binding. +type ProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding struct { + // ID of the Durabble Object namespace. + NamespaceID param.Field[string] `json:"namespace_id"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Environment variables for build configs. +type ProjectNewParamsDeploymentConfigsPreviewEnvVars struct { + // Environment variable. + EnvironmentVariable param.Field[ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariable] `json:"ENVIRONMENT_VARIABLE"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewEnvVars) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Environment variable. +type ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariable struct { + // The type of environment variable (plain text or secret) + Type param.Field[ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType] `json:"type"` + // Environment variable value. + Value param.Field[string] `json:"value"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariable) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of environment variable (plain text or secret) +type ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType string + +const ( + ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypePlainText ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType = "plain_text" + ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypeSecretText ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableType = "secret_text" +) + +// KV namespaces used for Pages Functions. +type ProjectNewParamsDeploymentConfigsPreviewKVNamespaces struct { + // KV binding. + KVBinding param.Field[ProjectNewParamsDeploymentConfigsPreviewKVNamespacesKVBinding] `json:"KV_BINDING"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewKVNamespaces) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// KV binding. +type ProjectNewParamsDeploymentConfigsPreviewKVNamespacesKVBinding struct { + // ID of the KV namespace. + NamespaceID param.Field[string] `json:"namespace_id"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewKVNamespacesKVBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Placement setting used for Pages Functions. +type ProjectNewParamsDeploymentConfigsPreviewPlacement struct { + // Placement mode. + Mode param.Field[string] `json:"mode"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewPlacement) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Queue Producer bindings used for Pages Functions. +type ProjectNewParamsDeploymentConfigsPreviewQueueProducers struct { + // Queue Producer binding. + QueueProducerBinding param.Field[ProjectNewParamsDeploymentConfigsPreviewQueueProducersQueueProducerBinding] `json:"QUEUE_PRODUCER_BINDING"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewQueueProducers) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Queue Producer binding. +type ProjectNewParamsDeploymentConfigsPreviewQueueProducersQueueProducerBinding struct { + // Name of the Queue. + Name param.Field[string] `json:"name"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewQueueProducersQueueProducerBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// R2 buckets used for Pages Functions. +type ProjectNewParamsDeploymentConfigsPreviewR2Buckets struct { + // R2 binding. + R2Binding param.Field[ProjectNewParamsDeploymentConfigsPreviewR2BucketsR2Binding] `json:"R2_BINDING"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewR2Buckets) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// R2 binding. +type ProjectNewParamsDeploymentConfigsPreviewR2BucketsR2Binding struct { + // Name of the R2 bucket. + Name param.Field[string] `json:"name"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewR2BucketsR2Binding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Services used for Pages Functions. +type ProjectNewParamsDeploymentConfigsPreviewServiceBindings struct { + // Service binding. + ServiceBinding param.Field[ProjectNewParamsDeploymentConfigsPreviewServiceBindingsServiceBinding] `json:"SERVICE_BINDING"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewServiceBindings) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Service binding. +type ProjectNewParamsDeploymentConfigsPreviewServiceBindingsServiceBinding struct { + // The Service environment. + Environment param.Field[string] `json:"environment"` + // The Service name. + Service param.Field[string] `json:"service"` +} + +func (r ProjectNewParamsDeploymentConfigsPreviewServiceBindingsServiceBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configs for production deploys. +type ProjectNewParamsDeploymentConfigsProduction struct { + // Constellation bindings used for Pages Functions. + AIBindings param.Field[ProjectNewParamsDeploymentConfigsProductionAIBindings] `json:"ai_bindings"` + // Analytics Engine bindings used for Pages Functions. + AnalyticsEngineDatasets param.Field[ProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasets] `json:"analytics_engine_datasets"` + // Compatibility date used for Pages Functions. + CompatibilityDate param.Field[string] `json:"compatibility_date"` + // Compatibility flags used for Pages Functions. + CompatibilityFlags param.Field[[]interface{}] `json:"compatibility_flags"` + // D1 databases used for Pages Functions. + D1Databases param.Field[ProjectNewParamsDeploymentConfigsProductionD1Databases] `json:"d1_databases"` + // Durabble Object namespaces used for Pages Functions. + DurableObjectNamespaces param.Field[ProjectNewParamsDeploymentConfigsProductionDurableObjectNamespaces] `json:"durable_object_namespaces"` + // Environment variables for build configs. + EnvVars param.Field[ProjectNewParamsDeploymentConfigsProductionEnvVars] `json:"env_vars"` + // KV namespaces used for Pages Functions. + KVNamespaces param.Field[ProjectNewParamsDeploymentConfigsProductionKVNamespaces] `json:"kv_namespaces"` + // Placement setting used for Pages Functions. + Placement param.Field[ProjectNewParamsDeploymentConfigsProductionPlacement] `json:"placement"` + // Queue Producer bindings used for Pages Functions. + QueueProducers param.Field[ProjectNewParamsDeploymentConfigsProductionQueueProducers] `json:"queue_producers"` + // R2 buckets used for Pages Functions. + R2Buckets param.Field[ProjectNewParamsDeploymentConfigsProductionR2Buckets] `json:"r2_buckets"` + // Services used for Pages Functions. + ServiceBindings param.Field[ProjectNewParamsDeploymentConfigsProductionServiceBindings] `json:"service_bindings"` +} + +func (r ProjectNewParamsDeploymentConfigsProduction) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Constellation bindings used for Pages Functions. +type ProjectNewParamsDeploymentConfigsProductionAIBindings struct { + // AI binding. + AIBinding param.Field[ProjectNewParamsDeploymentConfigsProductionAIBindingsAIBinding] `json:"AI_BINDING"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionAIBindings) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// AI binding. +type ProjectNewParamsDeploymentConfigsProductionAIBindingsAIBinding struct { + ProjectID param.Field[interface{}] `json:"project_id"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionAIBindingsAIBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Analytics Engine bindings used for Pages Functions. +type ProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasets struct { + // Analytics Engine binding. + AnalyticsEngineBinding param.Field[ProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding] `json:"ANALYTICS_ENGINE_BINDING"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasets) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Analytics Engine binding. +type ProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding struct { + // Name of the dataset. + Dataset param.Field[string] `json:"dataset"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// D1 databases used for Pages Functions. +type ProjectNewParamsDeploymentConfigsProductionD1Databases struct { + // D1 binding. + D1Binding param.Field[ProjectNewParamsDeploymentConfigsProductionD1DatabasesD1Binding] `json:"D1_BINDING"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionD1Databases) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// D1 binding. +type ProjectNewParamsDeploymentConfigsProductionD1DatabasesD1Binding struct { + // UUID of the D1 database. + ID param.Field[string] `json:"id"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionD1DatabasesD1Binding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Durabble Object namespaces used for Pages Functions. +type ProjectNewParamsDeploymentConfigsProductionDurableObjectNamespaces struct { + // Durabble Object binding. + DoBinding param.Field[ProjectNewParamsDeploymentConfigsProductionDurableObjectNamespacesDoBinding] `json:"DO_BINDING"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionDurableObjectNamespaces) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Durabble Object binding. +type ProjectNewParamsDeploymentConfigsProductionDurableObjectNamespacesDoBinding struct { + // ID of the Durabble Object namespace. + NamespaceID param.Field[string] `json:"namespace_id"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionDurableObjectNamespacesDoBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Environment variables for build configs. +type ProjectNewParamsDeploymentConfigsProductionEnvVars struct { + // Environment variable. + EnvironmentVariable param.Field[ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariable] `json:"ENVIRONMENT_VARIABLE"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionEnvVars) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Environment variable. +type ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariable struct { + // The type of environment variable (plain text or secret) + Type param.Field[ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableType] `json:"type"` + // Environment variable value. + Value param.Field[string] `json:"value"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariable) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of environment variable (plain text or secret) +type ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableType string + +const ( + ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableTypePlainText ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableType = "plain_text" + ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableTypeSecretText ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableType = "secret_text" +) + +// KV namespaces used for Pages Functions. +type ProjectNewParamsDeploymentConfigsProductionKVNamespaces struct { + // KV binding. + KVBinding param.Field[ProjectNewParamsDeploymentConfigsProductionKVNamespacesKVBinding] `json:"KV_BINDING"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionKVNamespaces) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// KV binding. +type ProjectNewParamsDeploymentConfigsProductionKVNamespacesKVBinding struct { + // ID of the KV namespace. + NamespaceID param.Field[string] `json:"namespace_id"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionKVNamespacesKVBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Placement setting used for Pages Functions. +type ProjectNewParamsDeploymentConfigsProductionPlacement struct { + // Placement mode. + Mode param.Field[string] `json:"mode"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionPlacement) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Queue Producer bindings used for Pages Functions. +type ProjectNewParamsDeploymentConfigsProductionQueueProducers struct { + // Queue Producer binding. + QueueProducerBinding param.Field[ProjectNewParamsDeploymentConfigsProductionQueueProducersQueueProducerBinding] `json:"QUEUE_PRODUCER_BINDING"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionQueueProducers) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Queue Producer binding. +type ProjectNewParamsDeploymentConfigsProductionQueueProducersQueueProducerBinding struct { + // Name of the Queue. + Name param.Field[string] `json:"name"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionQueueProducersQueueProducerBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// R2 buckets used for Pages Functions. +type ProjectNewParamsDeploymentConfigsProductionR2Buckets struct { + // R2 binding. + R2Binding param.Field[ProjectNewParamsDeploymentConfigsProductionR2BucketsR2Binding] `json:"R2_BINDING"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionR2Buckets) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// R2 binding. +type ProjectNewParamsDeploymentConfigsProductionR2BucketsR2Binding struct { + // Name of the R2 bucket. + Name param.Field[string] `json:"name"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionR2BucketsR2Binding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Services used for Pages Functions. +type ProjectNewParamsDeploymentConfigsProductionServiceBindings struct { + // Service binding. + ServiceBinding param.Field[ProjectNewParamsDeploymentConfigsProductionServiceBindingsServiceBinding] `json:"SERVICE_BINDING"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionServiceBindings) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Service binding. +type ProjectNewParamsDeploymentConfigsProductionServiceBindingsServiceBinding struct { + // The Service environment. + Environment param.Field[string] `json:"environment"` + // The Service name. + Service param.Field[string] `json:"service"` +} + +func (r ProjectNewParamsDeploymentConfigsProductionServiceBindingsServiceBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ProjectNewResponseEnvelope struct { + Errors []ProjectNewResponseEnvelopeErrors `json:"errors,required"` + Messages []ProjectNewResponseEnvelopeMessages `json:"messages,required"` + Result ProjectNewResponse `json:"result,required"` + // Whether the API call was successful + Success ProjectNewResponseEnvelopeSuccess `json:"success,required"` + JSON projectNewResponseEnvelopeJSON `json:"-"` +} + +// projectNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [ProjectNewResponseEnvelope] +type projectNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ProjectNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// projectNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ProjectNewResponseEnvelopeErrors] +type projectNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ProjectNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// projectNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ProjectNewResponseEnvelopeMessages] +type projectNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ProjectNewResponseEnvelopeSuccess bool + +const ( + ProjectNewResponseEnvelopeSuccessTrue ProjectNewResponseEnvelopeSuccess = true +) + +type ProjectListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ProjectListResponseEnvelope struct { + Errors []ProjectListResponseEnvelopeErrors `json:"errors,required"` + Messages []ProjectListResponseEnvelopeMessages `json:"messages,required"` + Result []PagesDeployments `json:"result,required"` + // Whether the API call was successful + Success ProjectListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo ProjectListResponseEnvelopeResultInfo `json:"result_info"` + JSON projectListResponseEnvelopeJSON `json:"-"` +} + +// projectListResponseEnvelopeJSON contains the JSON metadata for the struct +// [ProjectListResponseEnvelope] +type projectListResponseEnvelopeJSON 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 *ProjectListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ProjectListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectListResponseEnvelopeErrorsJSON `json:"-"` +} + +// projectListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ProjectListResponseEnvelopeErrors] +type projectListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ProjectListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectListResponseEnvelopeMessagesJSON `json:"-"` +} + +// projectListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ProjectListResponseEnvelopeMessages] +type projectListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ProjectListResponseEnvelopeSuccess bool + +const ( + ProjectListResponseEnvelopeSuccessTrue ProjectListResponseEnvelopeSuccess = true +) + +type ProjectListResponseEnvelopeResultInfo struct { + Count interface{} `json:"count"` + Page interface{} `json:"page"` + PerPage interface{} `json:"per_page"` + TotalCount interface{} `json:"total_count"` + JSON projectListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// projectListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [ProjectListResponseEnvelopeResultInfo] +type projectListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type ProjectDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ProjectEditParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Body param.Field[interface{}] `json:"body,required"` +} + +func (r ProjectEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type ProjectEditResponseEnvelope struct { + Errors []ProjectEditResponseEnvelopeErrors `json:"errors,required"` + Messages []ProjectEditResponseEnvelopeMessages `json:"messages,required"` + Result ProjectEditResponse `json:"result,required"` + // Whether the API call was successful + Success ProjectEditResponseEnvelopeSuccess `json:"success,required"` + JSON projectEditResponseEnvelopeJSON `json:"-"` +} + +// projectEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [ProjectEditResponseEnvelope] +type projectEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ProjectEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// projectEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ProjectEditResponseEnvelopeErrors] +type projectEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ProjectEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// projectEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ProjectEditResponseEnvelopeMessages] +type projectEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ProjectEditResponseEnvelopeSuccess bool + +const ( + ProjectEditResponseEnvelopeSuccessTrue ProjectEditResponseEnvelopeSuccess = true +) + +type ProjectGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ProjectGetResponseEnvelope struct { + Errors []ProjectGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ProjectGetResponseEnvelopeMessages `json:"messages,required"` + Result PagesProjects `json:"result,required"` + // Whether the API call was successful + Success ProjectGetResponseEnvelopeSuccess `json:"success,required"` + JSON projectGetResponseEnvelopeJSON `json:"-"` +} + +// projectGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [ProjectGetResponseEnvelope] +type projectGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ProjectGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// projectGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ProjectGetResponseEnvelopeErrors] +type projectGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ProjectGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// projectGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ProjectGetResponseEnvelopeMessages] +type projectGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ProjectGetResponseEnvelopeSuccess bool + +const ( + ProjectGetResponseEnvelopeSuccessTrue ProjectGetResponseEnvelopeSuccess = true +) + +type ProjectPurgeBuildCacheParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} diff --git a/pages/project_test.go b/pages/project_test.go new file mode 100644 index 00000000000..4e469f3b24c --- /dev/null +++ b/pages/project_test.go @@ -0,0 +1,329 @@ +// File generated from our OpenAPI spec by Stainless. + +package pages_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/pages" +) + +func TestProjectNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Pages.Projects.New(context.TODO(), pages.ProjectNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + BuildConfig: cloudflare.F(pages.ProjectNewParamsBuildConfig{ + BuildCaching: cloudflare.F(true), + BuildCommand: cloudflare.F("npm run build"), + DestinationDir: cloudflare.F("build"), + RootDir: cloudflare.F("/"), + WebAnalyticsTag: cloudflare.F("cee1c73f6e4743d0b5e6bb1a0bcaabcc"), + WebAnalyticsToken: cloudflare.F("021e1057c18547eca7b79f2516f06o7x"), + }), + CanonicalDeployment: cloudflare.F(pages.PagesDeploymentsParam{}), + DeploymentConfigs: cloudflare.F(pages.ProjectNewParamsDeploymentConfigs{ + Preview: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreview{ + AIBindings: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewAIBindings{ + AIBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewAIBindingsAIBinding{ + ProjectID: cloudflare.F[any](map[string]interface{}{}), + }), + }), + AnalyticsEngineDatasets: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasets{ + AnalyticsEngineBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewAnalyticsEngineDatasetsAnalyticsEngineBinding{ + Dataset: cloudflare.F("api_analytics"), + }), + }), + CompatibilityDate: cloudflare.F("2022-01-01"), + CompatibilityFlags: cloudflare.F([]interface{}{"url_standard"}), + D1Databases: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewD1Databases{ + D1Binding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewD1DatabasesD1Binding{ + ID: cloudflare.F("445e2955-951a-43f8-a35b-a4d0c8138f63"), + }), + }), + DurableObjectNamespaces: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespaces{ + DoBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewDurableObjectNamespacesDoBinding{ + NamespaceID: cloudflare.F("5eb63bbbe01eeed093cb22bb8f5acdc3"), + }), + }), + EnvVars: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewEnvVars{ + EnvironmentVariable: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariable{ + Type: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewEnvVarsEnvironmentVariableTypePlainText), + Value: cloudflare.F("hello world"), + }), + }), + KVNamespaces: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewKVNamespaces{ + KVBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewKVNamespacesKVBinding{ + NamespaceID: cloudflare.F("5eb63bbbe01eeed093cb22bb8f5acdc3"), + }), + }), + Placement: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewPlacement{ + Mode: cloudflare.F("smart"), + }), + QueueProducers: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewQueueProducers{ + QueueProducerBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewQueueProducersQueueProducerBinding{ + Name: cloudflare.F("some-queue"), + }), + }), + R2Buckets: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewR2Buckets{ + R2Binding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewR2BucketsR2Binding{ + Name: cloudflare.F("some-bucket"), + }), + }), + ServiceBindings: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewServiceBindings{ + ServiceBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewServiceBindingsServiceBinding{ + Environment: cloudflare.F("production"), + Service: cloudflare.F("example-worker"), + }), + }), + }), + Production: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProduction{ + AIBindings: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionAIBindings{ + AIBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionAIBindingsAIBinding{ + ProjectID: cloudflare.F[any](map[string]interface{}{}), + }), + }), + AnalyticsEngineDatasets: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasets{ + AnalyticsEngineBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionAnalyticsEngineDatasetsAnalyticsEngineBinding{ + Dataset: cloudflare.F("api_analytics"), + }), + }), + CompatibilityDate: cloudflare.F("2022-01-01"), + CompatibilityFlags: cloudflare.F([]interface{}{"url_standard"}), + D1Databases: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionD1Databases{ + D1Binding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionD1DatabasesD1Binding{ + ID: cloudflare.F("445e2955-951a-43f8-a35b-a4d0c8138f63"), + }), + }), + DurableObjectNamespaces: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionDurableObjectNamespaces{ + DoBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionDurableObjectNamespacesDoBinding{ + NamespaceID: cloudflare.F("5eb63bbbe01eeed093cb22bb8f5acdc3"), + }), + }), + EnvVars: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionEnvVars{ + EnvironmentVariable: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariable{ + Type: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionEnvVarsEnvironmentVariableTypePlainText), + Value: cloudflare.F("hello world"), + }), + }), + KVNamespaces: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionKVNamespaces{ + KVBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionKVNamespacesKVBinding{ + NamespaceID: cloudflare.F("5eb63bbbe01eeed093cb22bb8f5acdc3"), + }), + }), + Placement: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionPlacement{ + Mode: cloudflare.F("smart"), + }), + QueueProducers: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionQueueProducers{ + QueueProducerBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionQueueProducersQueueProducerBinding{ + Name: cloudflare.F("some-queue"), + }), + }), + R2Buckets: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionR2Buckets{ + R2Binding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionR2BucketsR2Binding{ + Name: cloudflare.F("some-bucket"), + }), + }), + ServiceBindings: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionServiceBindings{ + ServiceBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionServiceBindingsServiceBinding{ + Environment: cloudflare.F("production"), + Service: cloudflare.F("example-worker"), + }), + }), + }), + }), + LatestDeployment: cloudflare.F(pages.PagesDeploymentsParam{}), + Name: cloudflare.F("NextJS Blog"), + ProductionBranch: cloudflare.F("main"), + }) + 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 TestProjectList(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("user@example.com"), + ) + _, err := client.Pages.Projects.List(context.TODO(), pages.ProjectListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestProjectDelete(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("user@example.com"), + ) + _, err := client.Pages.Projects.Delete( + context.TODO(), + "this-is-my-project-01", + pages.ProjectDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestProjectEdit(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("user@example.com"), + ) + _, err := client.Pages.Projects.Edit( + context.TODO(), + "this-is-my-project-01", + pages.ProjectEditParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: cloudflare.F[any](map[string]interface{}{ + "deployment_configs": map[string]interface{}{ + "production": map[string]interface{}{ + "compatibility_date": "2022-01-01", + "compatibility_flags": map[string]interface{}{ + "0": "url_standard", + }, + "env_vars": map[string]interface{}{ + "BUILD_VERSION": map[string]interface{}{ + "value": "3.3", + }, + "delete_this_env_var": nil, + "secret_var": map[string]interface{}{ + "type": "secret_text", + "value": "A_CMS_API_TOKEN", + }, + }, + }, + }, + }), + }, + ) + 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 TestProjectGet(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("user@example.com"), + ) + _, err := client.Pages.Projects.Get( + context.TODO(), + "this-is-my-project-01", + pages.ProjectGetParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestProjectPurgeBuildCache(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("user@example.com"), + ) + _, err := client.Pages.Projects.PurgeBuildCache( + context.TODO(), + "this-is-my-project-01", + pages.ProjectPurgeBuildCacheParams{ + AccountID: cloudflare.F("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/pages/projectdeployment.go b/pages/projectdeployment.go new file mode 100644 index 00000000000..e25abe9ad6e --- /dev/null +++ b/pages/projectdeployment.go @@ -0,0 +1,582 @@ +// File generated from our OpenAPI spec by Stainless. + +package pages + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ProjectDeploymentService 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 [NewProjectDeploymentService] method +// instead. +type ProjectDeploymentService struct { + Options []option.RequestOption + History *ProjectDeploymentHistoryService +} + +// NewProjectDeploymentService 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 NewProjectDeploymentService(opts ...option.RequestOption) (r *ProjectDeploymentService) { + r = &ProjectDeploymentService{} + r.Options = opts + r.History = NewProjectDeploymentHistoryService(opts...) + return +} + +// Start a new deployment from production. The repository and account must have +// already been authorized on the Cloudflare Pages dashboard. +func (r *ProjectDeploymentService) New(ctx context.Context, projectName string, params ProjectDeploymentNewParams, opts ...option.RequestOption) (res *PagesDeployments, err error) { + opts = append(r.Options[:], opts...) + var env ProjectDeploymentNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments", params.AccountID, projectName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch a list of project deployments. +func (r *ProjectDeploymentService) List(ctx context.Context, projectName string, query ProjectDeploymentListParams, opts ...option.RequestOption) (res *[]PagesDeployments, err error) { + opts = append(r.Options[:], opts...) + var env ProjectDeploymentListResponseEnvelope + path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments", query.AccountID, projectName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a deployment. +func (r *ProjectDeploymentService) Delete(ctx context.Context, projectName string, deploymentID string, body ProjectDeploymentDeleteParams, opts ...option.RequestOption) (res *ProjectDeploymentDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments/%s", body.AccountID, projectName, deploymentID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &res, opts...) + return +} + +// Fetch information about a deployment. +func (r *ProjectDeploymentService) Get(ctx context.Context, projectName string, deploymentID string, query ProjectDeploymentGetParams, opts ...option.RequestOption) (res *PagesDeployments, err error) { + opts = append(r.Options[:], opts...) + var env ProjectDeploymentGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments/%s", query.AccountID, projectName, deploymentID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Retry a previous deployment. +func (r *ProjectDeploymentService) Retry(ctx context.Context, projectName string, deploymentID string, body ProjectDeploymentRetryParams, opts ...option.RequestOption) (res *PagesDeployments, err error) { + opts = append(r.Options[:], opts...) + var env ProjectDeploymentRetryResponseEnvelope + path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments/%s/retry", body.AccountID, projectName, deploymentID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Rollback the production deployment to a previous deployment. You can only +// rollback to succesful builds on production. +func (r *ProjectDeploymentService) Rollback(ctx context.Context, projectName string, deploymentID string, body ProjectDeploymentRollbackParams, opts ...option.RequestOption) (res *PagesDeployments, err error) { + opts = append(r.Options[:], opts...) + var env ProjectDeploymentRollbackResponseEnvelope + path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments/%s/rollback", body.AccountID, projectName, deploymentID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ProjectDeploymentDeleteResponse = interface{} + +type ProjectDeploymentNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The branch to build the new deployment from. The `HEAD` of the branch will be + // used. If omitted, the production branch will be used by default. + Branch param.Field[string] `json:"branch"` +} + +func (r ProjectDeploymentNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ProjectDeploymentNewResponseEnvelope struct { + Errors []ProjectDeploymentNewResponseEnvelopeErrors `json:"errors,required"` + Messages []ProjectDeploymentNewResponseEnvelopeMessages `json:"messages,required"` + Result PagesDeployments `json:"result,required"` + // Whether the API call was successful + Success ProjectDeploymentNewResponseEnvelopeSuccess `json:"success,required"` + JSON projectDeploymentNewResponseEnvelopeJSON `json:"-"` +} + +// projectDeploymentNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [ProjectDeploymentNewResponseEnvelope] +type projectDeploymentNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDeploymentNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ProjectDeploymentNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDeploymentNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// projectDeploymentNewResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [ProjectDeploymentNewResponseEnvelopeErrors] +type projectDeploymentNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDeploymentNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ProjectDeploymentNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDeploymentNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// projectDeploymentNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [ProjectDeploymentNewResponseEnvelopeMessages] +type projectDeploymentNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDeploymentNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ProjectDeploymentNewResponseEnvelopeSuccess bool + +const ( + ProjectDeploymentNewResponseEnvelopeSuccessTrue ProjectDeploymentNewResponseEnvelopeSuccess = true +) + +type ProjectDeploymentListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ProjectDeploymentListResponseEnvelope struct { + Errors []ProjectDeploymentListResponseEnvelopeErrors `json:"errors,required"` + Messages []ProjectDeploymentListResponseEnvelopeMessages `json:"messages,required"` + Result []PagesDeployments `json:"result,required"` + // Whether the API call was successful + Success ProjectDeploymentListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo ProjectDeploymentListResponseEnvelopeResultInfo `json:"result_info"` + JSON projectDeploymentListResponseEnvelopeJSON `json:"-"` +} + +// projectDeploymentListResponseEnvelopeJSON contains the JSON metadata for the +// struct [ProjectDeploymentListResponseEnvelope] +type projectDeploymentListResponseEnvelopeJSON 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 *ProjectDeploymentListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ProjectDeploymentListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDeploymentListResponseEnvelopeErrorsJSON `json:"-"` +} + +// projectDeploymentListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [ProjectDeploymentListResponseEnvelopeErrors] +type projectDeploymentListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDeploymentListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ProjectDeploymentListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDeploymentListResponseEnvelopeMessagesJSON `json:"-"` +} + +// projectDeploymentListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [ProjectDeploymentListResponseEnvelopeMessages] +type projectDeploymentListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDeploymentListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ProjectDeploymentListResponseEnvelopeSuccess bool + +const ( + ProjectDeploymentListResponseEnvelopeSuccessTrue ProjectDeploymentListResponseEnvelopeSuccess = true +) + +type ProjectDeploymentListResponseEnvelopeResultInfo struct { + Count interface{} `json:"count"` + Page interface{} `json:"page"` + PerPage interface{} `json:"per_page"` + TotalCount interface{} `json:"total_count"` + JSON projectDeploymentListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// projectDeploymentListResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [ProjectDeploymentListResponseEnvelopeResultInfo] +type projectDeploymentListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDeploymentListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type ProjectDeploymentDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ProjectDeploymentGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ProjectDeploymentGetResponseEnvelope struct { + Errors []ProjectDeploymentGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ProjectDeploymentGetResponseEnvelopeMessages `json:"messages,required"` + Result PagesDeployments `json:"result,required"` + // Whether the API call was successful + Success ProjectDeploymentGetResponseEnvelopeSuccess `json:"success,required"` + JSON projectDeploymentGetResponseEnvelopeJSON `json:"-"` +} + +// projectDeploymentGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [ProjectDeploymentGetResponseEnvelope] +type projectDeploymentGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDeploymentGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ProjectDeploymentGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDeploymentGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// projectDeploymentGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [ProjectDeploymentGetResponseEnvelopeErrors] +type projectDeploymentGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDeploymentGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ProjectDeploymentGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDeploymentGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// projectDeploymentGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [ProjectDeploymentGetResponseEnvelopeMessages] +type projectDeploymentGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDeploymentGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ProjectDeploymentGetResponseEnvelopeSuccess bool + +const ( + ProjectDeploymentGetResponseEnvelopeSuccessTrue ProjectDeploymentGetResponseEnvelopeSuccess = true +) + +type ProjectDeploymentRetryParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ProjectDeploymentRetryResponseEnvelope struct { + Errors []ProjectDeploymentRetryResponseEnvelopeErrors `json:"errors,required"` + Messages []ProjectDeploymentRetryResponseEnvelopeMessages `json:"messages,required"` + Result PagesDeployments `json:"result,required"` + // Whether the API call was successful + Success ProjectDeploymentRetryResponseEnvelopeSuccess `json:"success,required"` + JSON projectDeploymentRetryResponseEnvelopeJSON `json:"-"` +} + +// projectDeploymentRetryResponseEnvelopeJSON contains the JSON metadata for the +// struct [ProjectDeploymentRetryResponseEnvelope] +type projectDeploymentRetryResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDeploymentRetryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentRetryResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ProjectDeploymentRetryResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDeploymentRetryResponseEnvelopeErrorsJSON `json:"-"` +} + +// projectDeploymentRetryResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [ProjectDeploymentRetryResponseEnvelopeErrors] +type projectDeploymentRetryResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDeploymentRetryResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentRetryResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ProjectDeploymentRetryResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDeploymentRetryResponseEnvelopeMessagesJSON `json:"-"` +} + +// projectDeploymentRetryResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [ProjectDeploymentRetryResponseEnvelopeMessages] +type projectDeploymentRetryResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDeploymentRetryResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentRetryResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ProjectDeploymentRetryResponseEnvelopeSuccess bool + +const ( + ProjectDeploymentRetryResponseEnvelopeSuccessTrue ProjectDeploymentRetryResponseEnvelopeSuccess = true +) + +type ProjectDeploymentRollbackParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ProjectDeploymentRollbackResponseEnvelope struct { + Errors []ProjectDeploymentRollbackResponseEnvelopeErrors `json:"errors,required"` + Messages []ProjectDeploymentRollbackResponseEnvelopeMessages `json:"messages,required"` + Result PagesDeployments `json:"result,required"` + // Whether the API call was successful + Success ProjectDeploymentRollbackResponseEnvelopeSuccess `json:"success,required"` + JSON projectDeploymentRollbackResponseEnvelopeJSON `json:"-"` +} + +// projectDeploymentRollbackResponseEnvelopeJSON contains the JSON metadata for the +// struct [ProjectDeploymentRollbackResponseEnvelope] +type projectDeploymentRollbackResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDeploymentRollbackResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentRollbackResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ProjectDeploymentRollbackResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDeploymentRollbackResponseEnvelopeErrorsJSON `json:"-"` +} + +// projectDeploymentRollbackResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [ProjectDeploymentRollbackResponseEnvelopeErrors] +type projectDeploymentRollbackResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDeploymentRollbackResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentRollbackResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ProjectDeploymentRollbackResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDeploymentRollbackResponseEnvelopeMessagesJSON `json:"-"` +} + +// projectDeploymentRollbackResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [ProjectDeploymentRollbackResponseEnvelopeMessages] +type projectDeploymentRollbackResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDeploymentRollbackResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentRollbackResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ProjectDeploymentRollbackResponseEnvelopeSuccess bool + +const ( + ProjectDeploymentRollbackResponseEnvelopeSuccessTrue ProjectDeploymentRollbackResponseEnvelopeSuccess = true +) diff --git a/pages/projectdeployment_test.go b/pages/projectdeployment_test.go new file mode 100644 index 00000000000..ca808b27fd2 --- /dev/null +++ b/pages/projectdeployment_test.go @@ -0,0 +1,200 @@ +// File generated from our OpenAPI spec by Stainless. + +package pages_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/pages" +) + +func TestProjectDeploymentNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Pages.Projects.Deployments.New( + context.TODO(), + "this-is-my-project-01", + pages.ProjectDeploymentNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Branch: cloudflare.F("staging"), + }, + ) + 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 TestProjectDeploymentList(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("user@example.com"), + ) + _, err := client.Pages.Projects.Deployments.List( + context.TODO(), + "this-is-my-project-01", + pages.ProjectDeploymentListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestProjectDeploymentDelete(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("user@example.com"), + ) + _, err := client.Pages.Projects.Deployments.Delete( + context.TODO(), + "this-is-my-project-01", + "023e105f4ecef8ad9ca31a8372d0c353", + pages.ProjectDeploymentDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestProjectDeploymentGet(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("user@example.com"), + ) + _, err := client.Pages.Projects.Deployments.Get( + context.TODO(), + "this-is-my-project-01", + "023e105f4ecef8ad9ca31a8372d0c353", + pages.ProjectDeploymentGetParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestProjectDeploymentRetry(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("user@example.com"), + ) + _, err := client.Pages.Projects.Deployments.Retry( + context.TODO(), + "this-is-my-project-01", + "023e105f4ecef8ad9ca31a8372d0c353", + pages.ProjectDeploymentRetryParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestProjectDeploymentRollback(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("user@example.com"), + ) + _, err := client.Pages.Projects.Deployments.Rollback( + context.TODO(), + "this-is-my-project-01", + "023e105f4ecef8ad9ca31a8372d0c353", + pages.ProjectDeploymentRollbackParams{ + AccountID: cloudflare.F("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/pages/projectdeploymenthistory.go b/pages/projectdeploymenthistory.go new file mode 100644 index 00000000000..99e5f4dfd4f --- /dev/null +++ b/pages/projectdeploymenthistory.go @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package pages + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// ProjectDeploymentHistoryService 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 +// [NewProjectDeploymentHistoryService] method instead. +type ProjectDeploymentHistoryService struct { + Options []option.RequestOption + Logs *ProjectDeploymentHistoryLogService +} + +// NewProjectDeploymentHistoryService 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 NewProjectDeploymentHistoryService(opts ...option.RequestOption) (r *ProjectDeploymentHistoryService) { + r = &ProjectDeploymentHistoryService{} + r.Options = opts + r.Logs = NewProjectDeploymentHistoryLogService(opts...) + return +} diff --git a/pages/projectdeploymenthistorylog.go b/pages/projectdeploymenthistorylog.go new file mode 100644 index 00000000000..e056cf133a7 --- /dev/null +++ b/pages/projectdeploymenthistorylog.go @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package pages + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// ProjectDeploymentHistoryLogService 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 +// [NewProjectDeploymentHistoryLogService] method instead. +type ProjectDeploymentHistoryLogService struct { + Options []option.RequestOption +} + +// NewProjectDeploymentHistoryLogService 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 NewProjectDeploymentHistoryLogService(opts ...option.RequestOption) (r *ProjectDeploymentHistoryLogService) { + r = &ProjectDeploymentHistoryLogService{} + r.Options = opts + return +} + +// Fetch deployment logs for a project. +func (r *ProjectDeploymentHistoryLogService) Get(ctx context.Context, projectName string, deploymentID string, query ProjectDeploymentHistoryLogGetParams, opts ...option.RequestOption) (res *ProjectDeploymentHistoryLogGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env ProjectDeploymentHistoryLogGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments/%s/history/logs", query.AccountID, projectName, deploymentID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [pages.ProjectDeploymentHistoryLogGetResponseUnknown], +// [pages.ProjectDeploymentHistoryLogGetResponseArray] or [shared.UnionString]. +type ProjectDeploymentHistoryLogGetResponse interface { + ImplementsPagesProjectDeploymentHistoryLogGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ProjectDeploymentHistoryLogGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ProjectDeploymentHistoryLogGetResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type ProjectDeploymentHistoryLogGetResponseArray []interface{} + +func (r ProjectDeploymentHistoryLogGetResponseArray) ImplementsPagesProjectDeploymentHistoryLogGetResponse() { +} + +type ProjectDeploymentHistoryLogGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ProjectDeploymentHistoryLogGetResponseEnvelope struct { + Errors []ProjectDeploymentHistoryLogGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ProjectDeploymentHistoryLogGetResponseEnvelopeMessages `json:"messages,required"` + Result ProjectDeploymentHistoryLogGetResponse `json:"result,required"` + // Whether the API call was successful + Success ProjectDeploymentHistoryLogGetResponseEnvelopeSuccess `json:"success,required"` + JSON projectDeploymentHistoryLogGetResponseEnvelopeJSON `json:"-"` +} + +// projectDeploymentHistoryLogGetResponseEnvelopeJSON contains the JSON metadata +// for the struct [ProjectDeploymentHistoryLogGetResponseEnvelope] +type projectDeploymentHistoryLogGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDeploymentHistoryLogGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentHistoryLogGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ProjectDeploymentHistoryLogGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDeploymentHistoryLogGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// projectDeploymentHistoryLogGetResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [ProjectDeploymentHistoryLogGetResponseEnvelopeErrors] +type projectDeploymentHistoryLogGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDeploymentHistoryLogGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentHistoryLogGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ProjectDeploymentHistoryLogGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDeploymentHistoryLogGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// projectDeploymentHistoryLogGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [ProjectDeploymentHistoryLogGetResponseEnvelopeMessages] +type projectDeploymentHistoryLogGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDeploymentHistoryLogGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDeploymentHistoryLogGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ProjectDeploymentHistoryLogGetResponseEnvelopeSuccess bool + +const ( + ProjectDeploymentHistoryLogGetResponseEnvelopeSuccessTrue ProjectDeploymentHistoryLogGetResponseEnvelopeSuccess = true +) diff --git a/pages/projectdeploymenthistorylog_test.go b/pages/projectdeploymenthistorylog_test.go new file mode 100644 index 00000000000..28968d6b0dc --- /dev/null +++ b/pages/projectdeploymenthistorylog_test.go @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package pages_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/pages" +) + +func TestProjectDeploymentHistoryLogGet(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("user@example.com"), + ) + _, err := client.Pages.Projects.Deployments.History.Logs.Get( + context.TODO(), + "this-is-my-project-01", + "023e105f4ecef8ad9ca31a8372d0c353", + pages.ProjectDeploymentHistoryLogGetParams{ + AccountID: cloudflare.F("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/pages/projectdomain.go b/pages/projectdomain.go new file mode 100644 index 00000000000..216244244c0 --- /dev/null +++ b/pages/projectdomain.go @@ -0,0 +1,557 @@ +// File generated from our OpenAPI spec by Stainless. + +package pages + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// ProjectDomainService 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 [NewProjectDomainService] method +// instead. +type ProjectDomainService struct { + Options []option.RequestOption +} + +// NewProjectDomainService 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 NewProjectDomainService(opts ...option.RequestOption) (r *ProjectDomainService) { + r = &ProjectDomainService{} + r.Options = opts + return +} + +// Add a new domain for the Pages project. +func (r *ProjectDomainService) New(ctx context.Context, projectName string, params ProjectDomainNewParams, opts ...option.RequestOption) (res *ProjectDomainNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env ProjectDomainNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/pages/projects/%s/domains", params.AccountID, projectName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch a list of all domains associated with a Pages project. +func (r *ProjectDomainService) List(ctx context.Context, projectName string, query ProjectDomainListParams, opts ...option.RequestOption) (res *[]ProjectDomainListResponse, err error) { + opts = append(r.Options[:], opts...) + var env ProjectDomainListResponseEnvelope + path := fmt.Sprintf("accounts/%s/pages/projects/%s/domains", query.AccountID, projectName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a Pages project's domain. +func (r *ProjectDomainService) Delete(ctx context.Context, projectName string, domainName string, body ProjectDomainDeleteParams, opts ...option.RequestOption) (res *ProjectDomainDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("accounts/%s/pages/projects/%s/domains/%s", body.AccountID, projectName, domainName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &res, opts...) + return +} + +// Retry the validation status of a single domain. +func (r *ProjectDomainService) Edit(ctx context.Context, projectName string, domainName string, body ProjectDomainEditParams, opts ...option.RequestOption) (res *ProjectDomainEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env ProjectDomainEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/pages/projects/%s/domains/%s", body.AccountID, projectName, domainName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch a single domain. +func (r *ProjectDomainService) Get(ctx context.Context, projectName string, domainName string, query ProjectDomainGetParams, opts ...option.RequestOption) (res *ProjectDomainGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env ProjectDomainGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/pages/projects/%s/domains/%s", query.AccountID, projectName, domainName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [pages.ProjectDomainNewResponseUnknown], +// [pages.ProjectDomainNewResponseArray] or [shared.UnionString]. +type ProjectDomainNewResponse interface { + ImplementsPagesProjectDomainNewResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ProjectDomainNewResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ProjectDomainNewResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type ProjectDomainNewResponseArray []interface{} + +func (r ProjectDomainNewResponseArray) ImplementsPagesProjectDomainNewResponse() {} + +type ProjectDomainListResponse = interface{} + +type ProjectDomainDeleteResponse = interface{} + +// Union satisfied by [pages.ProjectDomainEditResponseUnknown], +// [pages.ProjectDomainEditResponseArray] or [shared.UnionString]. +type ProjectDomainEditResponse interface { + ImplementsPagesProjectDomainEditResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ProjectDomainEditResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ProjectDomainEditResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type ProjectDomainEditResponseArray []interface{} + +func (r ProjectDomainEditResponseArray) ImplementsPagesProjectDomainEditResponse() {} + +// Union satisfied by [pages.ProjectDomainGetResponseUnknown], +// [pages.ProjectDomainGetResponseArray] or [shared.UnionString]. +type ProjectDomainGetResponse interface { + ImplementsPagesProjectDomainGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ProjectDomainGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ProjectDomainGetResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type ProjectDomainGetResponseArray []interface{} + +func (r ProjectDomainGetResponseArray) ImplementsPagesProjectDomainGetResponse() {} + +type ProjectDomainNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Body param.Field[interface{}] `json:"body,required"` +} + +func (r ProjectDomainNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type ProjectDomainNewResponseEnvelope struct { + Errors []ProjectDomainNewResponseEnvelopeErrors `json:"errors,required"` + Messages []ProjectDomainNewResponseEnvelopeMessages `json:"messages,required"` + Result ProjectDomainNewResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ProjectDomainNewResponseEnvelopeSuccess `json:"success,required"` + JSON projectDomainNewResponseEnvelopeJSON `json:"-"` +} + +// projectDomainNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [ProjectDomainNewResponseEnvelope] +type projectDomainNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDomainNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDomainNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ProjectDomainNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDomainNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// projectDomainNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ProjectDomainNewResponseEnvelopeErrors] +type projectDomainNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDomainNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDomainNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ProjectDomainNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDomainNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// projectDomainNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ProjectDomainNewResponseEnvelopeMessages] +type projectDomainNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDomainNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDomainNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ProjectDomainNewResponseEnvelopeSuccess bool + +const ( + ProjectDomainNewResponseEnvelopeSuccessTrue ProjectDomainNewResponseEnvelopeSuccess = true +) + +type ProjectDomainListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ProjectDomainListResponseEnvelope struct { + Errors []ProjectDomainListResponseEnvelopeErrors `json:"errors,required"` + Messages []ProjectDomainListResponseEnvelopeMessages `json:"messages,required"` + Result []ProjectDomainListResponse `json:"result,required"` + // Whether the API call was successful + Success ProjectDomainListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo ProjectDomainListResponseEnvelopeResultInfo `json:"result_info"` + JSON projectDomainListResponseEnvelopeJSON `json:"-"` +} + +// projectDomainListResponseEnvelopeJSON contains the JSON metadata for the struct +// [ProjectDomainListResponseEnvelope] +type projectDomainListResponseEnvelopeJSON 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 *ProjectDomainListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDomainListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ProjectDomainListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDomainListResponseEnvelopeErrorsJSON `json:"-"` +} + +// projectDomainListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ProjectDomainListResponseEnvelopeErrors] +type projectDomainListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDomainListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDomainListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ProjectDomainListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDomainListResponseEnvelopeMessagesJSON `json:"-"` +} + +// projectDomainListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ProjectDomainListResponseEnvelopeMessages] +type projectDomainListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDomainListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDomainListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ProjectDomainListResponseEnvelopeSuccess bool + +const ( + ProjectDomainListResponseEnvelopeSuccessTrue ProjectDomainListResponseEnvelopeSuccess = true +) + +type ProjectDomainListResponseEnvelopeResultInfo struct { + Count interface{} `json:"count"` + Page interface{} `json:"page"` + PerPage interface{} `json:"per_page"` + TotalCount interface{} `json:"total_count"` + JSON projectDomainListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// projectDomainListResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [ProjectDomainListResponseEnvelopeResultInfo] +type projectDomainListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDomainListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDomainListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type ProjectDomainDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ProjectDomainEditParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ProjectDomainEditResponseEnvelope struct { + Errors []ProjectDomainEditResponseEnvelopeErrors `json:"errors,required"` + Messages []ProjectDomainEditResponseEnvelopeMessages `json:"messages,required"` + Result ProjectDomainEditResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ProjectDomainEditResponseEnvelopeSuccess `json:"success,required"` + JSON projectDomainEditResponseEnvelopeJSON `json:"-"` +} + +// projectDomainEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [ProjectDomainEditResponseEnvelope] +type projectDomainEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDomainEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDomainEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ProjectDomainEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDomainEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// projectDomainEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ProjectDomainEditResponseEnvelopeErrors] +type projectDomainEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDomainEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDomainEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ProjectDomainEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDomainEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// projectDomainEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ProjectDomainEditResponseEnvelopeMessages] +type projectDomainEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDomainEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDomainEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ProjectDomainEditResponseEnvelopeSuccess bool + +const ( + ProjectDomainEditResponseEnvelopeSuccessTrue ProjectDomainEditResponseEnvelopeSuccess = true +) + +type ProjectDomainGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ProjectDomainGetResponseEnvelope struct { + Errors []ProjectDomainGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ProjectDomainGetResponseEnvelopeMessages `json:"messages,required"` + Result ProjectDomainGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ProjectDomainGetResponseEnvelopeSuccess `json:"success,required"` + JSON projectDomainGetResponseEnvelopeJSON `json:"-"` +} + +// projectDomainGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [ProjectDomainGetResponseEnvelope] +type projectDomainGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDomainGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDomainGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ProjectDomainGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDomainGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// projectDomainGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ProjectDomainGetResponseEnvelopeErrors] +type projectDomainGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDomainGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDomainGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ProjectDomainGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON projectDomainGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// projectDomainGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ProjectDomainGetResponseEnvelopeMessages] +type projectDomainGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ProjectDomainGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r projectDomainGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ProjectDomainGetResponseEnvelopeSuccess bool + +const ( + ProjectDomainGetResponseEnvelopeSuccessTrue ProjectDomainGetResponseEnvelopeSuccess = true +) diff --git a/pages/projectdomain_test.go b/pages/projectdomain_test.go new file mode 100644 index 00000000000..3061e7c6fe2 --- /dev/null +++ b/pages/projectdomain_test.go @@ -0,0 +1,171 @@ +// File generated from our OpenAPI spec by Stainless. + +package pages_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/pages" +) + +func TestProjectDomainNew(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("user@example.com"), + ) + _, err := client.Pages.Projects.Domains.New( + context.TODO(), + "this-is-my-project-01", + pages.ProjectDomainNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: cloudflare.F[any](map[string]interface{}{ + "name": "example.com", + }), + }, + ) + 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 TestProjectDomainList(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("user@example.com"), + ) + _, err := client.Pages.Projects.Domains.List( + context.TODO(), + "this-is-my-project-01", + pages.ProjectDomainListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestProjectDomainDelete(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("user@example.com"), + ) + _, err := client.Pages.Projects.Domains.Delete( + context.TODO(), + "this-is-my-project-01", + "string", + pages.ProjectDomainDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestProjectDomainEdit(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("user@example.com"), + ) + _, err := client.Pages.Projects.Domains.Edit( + context.TODO(), + "this-is-my-project-01", + "string", + pages.ProjectDomainEditParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestProjectDomainGet(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("user@example.com"), + ) + _, err := client.Pages.Projects.Domains.Get( + context.TODO(), + "this-is-my-project-01", + "string", + pages.ProjectDomainGetParams{ + AccountID: cloudflare.F("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/pageshieldconnection.go b/pageshieldconnection.go deleted file mode 100644 index b3e182839cb..00000000000 --- a/pageshieldconnection.go +++ /dev/null @@ -1,336 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// PageShieldConnectionService 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 [NewPageShieldConnectionService] -// method instead. -type PageShieldConnectionService struct { - Options []option.RequestOption -} - -// NewPageShieldConnectionService 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 NewPageShieldConnectionService(opts ...option.RequestOption) (r *PageShieldConnectionService) { - r = &PageShieldConnectionService{} - r.Options = opts - return -} - -// Lists all connections detected by Page Shield. -func (r *PageShieldConnectionService) List(ctx context.Context, params PageShieldConnectionListParams, opts ...option.RequestOption) (res *[]PageShieldConnectionListResponse, err error) { - opts = append(r.Options[:], opts...) - var env PageShieldConnectionListResponseEnvelope - path := fmt.Sprintf("zones/%s/page_shield/connections", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a connection detected by Page Shield by connection ID. -func (r *PageShieldConnectionService) Get(ctx context.Context, connectionID string, query PageShieldConnectionGetParams, opts ...option.RequestOption) (res *PageShieldConnectionGetResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("zones/%s/page_shield/connections/%s", query.ZoneID, connectionID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -type PageShieldConnectionListResponse struct { - ID interface{} `json:"id"` - AddedAt interface{} `json:"added_at"` - DomainReportedMalicious interface{} `json:"domain_reported_malicious"` - FirstPageURL interface{} `json:"first_page_url"` - FirstSeenAt interface{} `json:"first_seen_at"` - Host interface{} `json:"host"` - LastSeenAt interface{} `json:"last_seen_at"` - PageURLs interface{} `json:"page_urls"` - URL interface{} `json:"url"` - URLContainsCdnCgiPath interface{} `json:"url_contains_cdn_cgi_path"` - JSON pageShieldConnectionListResponseJSON `json:"-"` -} - -// pageShieldConnectionListResponseJSON contains the JSON metadata for the struct -// [PageShieldConnectionListResponse] -type pageShieldConnectionListResponseJSON struct { - ID apijson.Field - AddedAt apijson.Field - DomainReportedMalicious apijson.Field - FirstPageURL apijson.Field - FirstSeenAt apijson.Field - Host apijson.Field - LastSeenAt apijson.Field - PageURLs apijson.Field - URL apijson.Field - URLContainsCdnCgiPath apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldConnectionListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldConnectionListResponseJSON) RawJSON() string { - return r.raw -} - -type PageShieldConnectionGetResponse struct { - ID interface{} `json:"id"` - AddedAt interface{} `json:"added_at"` - DomainReportedMalicious interface{} `json:"domain_reported_malicious"` - FirstPageURL interface{} `json:"first_page_url"` - FirstSeenAt interface{} `json:"first_seen_at"` - Host interface{} `json:"host"` - LastSeenAt interface{} `json:"last_seen_at"` - PageURLs interface{} `json:"page_urls"` - URL interface{} `json:"url"` - URLContainsCdnCgiPath interface{} `json:"url_contains_cdn_cgi_path"` - JSON pageShieldConnectionGetResponseJSON `json:"-"` -} - -// pageShieldConnectionGetResponseJSON contains the JSON metadata for the struct -// [PageShieldConnectionGetResponse] -type pageShieldConnectionGetResponseJSON struct { - ID apijson.Field - AddedAt apijson.Field - DomainReportedMalicious apijson.Field - FirstPageURL apijson.Field - FirstSeenAt apijson.Field - Host apijson.Field - LastSeenAt apijson.Field - PageURLs apijson.Field - URL apijson.Field - URLContainsCdnCgiPath apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldConnectionGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldConnectionGetResponseJSON) RawJSON() string { - return r.raw -} - -type PageShieldConnectionListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // The direction used to sort returned connections. - Direction param.Field[PageShieldConnectionListParamsDirection] `query:"direction"` - // When true, excludes connections seen in a `/cdn-cgi` path from the returned - // connections. The default value is true. - ExcludeCdnCgi param.Field[bool] `query:"exclude_cdn_cgi"` - // Excludes connections whose URL contains one of the URL-encoded URLs separated by - // commas. - ExcludeURLs param.Field[string] `query:"exclude_urls"` - // Export the list of connections as a file. Cannot be used with per_page or page - // options. - Export param.Field[PageShieldConnectionListParamsExport] `query:"export"` - // Includes connections that match one or more URL-encoded hostnames separated by - // commas. - // - // Wildcards are supported at the start and end of each hostname to support starts - // with, ends with and contains. If no wildcards are used, results will be filtered - // by exact match - Hosts param.Field[string] `query:"hosts"` - // The field used to sort returned connections. - OrderBy param.Field[PageShieldConnectionListParamsOrderBy] `query:"order_by"` - // The current page number of the paginated results. - // - // We additionally support a special value "all". When "all" is used, the API will - // return all the connections with the applied filters in a single page. - // Additionally, when using this value, the API will not return the categorisation - // data for the URL and domain of the connections. This feature is best-effort and - // it may only work for zones with a low number of connections - Page param.Field[string] `query:"page"` - // Includes connections that match one or more page URLs (separated by commas) - // where they were last seen - // - // Wildcards are supported at the start and end of each page URL to support starts - // with, ends with and contains. If no wildcards are used, results will be filtered - // by exact match - PageURL param.Field[string] `query:"page_url"` - // The number of results per page. - PerPage param.Field[float64] `query:"per_page"` - // When true, malicious connections appear first in the returned connections. - PrioritizeMalicious param.Field[bool] `query:"prioritize_malicious"` - // Filters the returned connections using a comma-separated list of connection - // statuses. Accepted values: `active`, `infrequent`, and `inactive`. The default - // value is `active`. - Status param.Field[string] `query:"status"` - // Includes connections whose URL contain one or more URL-encoded URLs separated by - // commas. - URLs param.Field[string] `query:"urls"` -} - -// URLQuery serializes [PageShieldConnectionListParams]'s query parameters as -// `url.Values`. -func (r PageShieldConnectionListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// The direction used to sort returned connections. -type PageShieldConnectionListParamsDirection string - -const ( - PageShieldConnectionListParamsDirectionAsc PageShieldConnectionListParamsDirection = "asc" - PageShieldConnectionListParamsDirectionDesc PageShieldConnectionListParamsDirection = "desc" -) - -// Export the list of connections as a file. Cannot be used with per_page or page -// options. -type PageShieldConnectionListParamsExport string - -const ( - PageShieldConnectionListParamsExportCsv PageShieldConnectionListParamsExport = "csv" -) - -// The field used to sort returned connections. -type PageShieldConnectionListParamsOrderBy string - -const ( - PageShieldConnectionListParamsOrderByFirstSeenAt PageShieldConnectionListParamsOrderBy = "first_seen_at" - PageShieldConnectionListParamsOrderByLastSeenAt PageShieldConnectionListParamsOrderBy = "last_seen_at" -) - -type PageShieldConnectionListResponseEnvelope struct { - Errors []PageShieldConnectionListResponseEnvelopeErrors `json:"errors,required"` - Messages []PageShieldConnectionListResponseEnvelopeMessages `json:"messages,required"` - Result []PageShieldConnectionListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success PageShieldConnectionListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo PageShieldConnectionListResponseEnvelopeResultInfo `json:"result_info"` - JSON pageShieldConnectionListResponseEnvelopeJSON `json:"-"` -} - -// pageShieldConnectionListResponseEnvelopeJSON contains the JSON metadata for the -// struct [PageShieldConnectionListResponseEnvelope] -type pageShieldConnectionListResponseEnvelopeJSON 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 *PageShieldConnectionListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldConnectionListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PageShieldConnectionListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageShieldConnectionListResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageShieldConnectionListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [PageShieldConnectionListResponseEnvelopeErrors] -type pageShieldConnectionListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldConnectionListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldConnectionListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageShieldConnectionListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageShieldConnectionListResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageShieldConnectionListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [PageShieldConnectionListResponseEnvelopeMessages] -type pageShieldConnectionListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldConnectionListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldConnectionListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PageShieldConnectionListResponseEnvelopeSuccess bool - -const ( - PageShieldConnectionListResponseEnvelopeSuccessTrue PageShieldConnectionListResponseEnvelopeSuccess = true -) - -type PageShieldConnectionListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON pageShieldConnectionListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// pageShieldConnectionListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [PageShieldConnectionListResponseEnvelopeResultInfo] -type pageShieldConnectionListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldConnectionListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldConnectionListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type PageShieldConnectionGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} diff --git a/pageshieldconnection_test.go b/pageshieldconnection_test.go deleted file mode 100644 index 61b74d8bed4..00000000000 --- a/pageshieldconnection_test.go +++ /dev/null @@ -1,82 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestPageShieldConnectionListWithOptionalParams(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("user@example.com"), - ) - _, err := client.PageShield.Connections.List(context.TODO(), cloudflare.PageShieldConnectionListParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Direction: cloudflare.F(cloudflare.PageShieldConnectionListParamsDirectionAsc), - ExcludeCdnCgi: cloudflare.F(true), - ExcludeURLs: cloudflare.F("blog.cloudflare.com,www.example"), - Export: cloudflare.F(cloudflare.PageShieldConnectionListParamsExportCsv), - Hosts: cloudflare.F("blog.cloudflare.com,www.example*,*cloudflare.com"), - OrderBy: cloudflare.F(cloudflare.PageShieldConnectionListParamsOrderByFirstSeenAt), - Page: cloudflare.F("string"), - PageURL: cloudflare.F("example.com/page,*/checkout,example.com/*,*checkout*"), - PerPage: cloudflare.F(100.000000), - PrioritizeMalicious: cloudflare.F(true), - Status: cloudflare.F("active,inactive"), - URLs: cloudflare.F("blog.cloudflare.com,www.example"), - }) - 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 TestPageShieldConnectionGet(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("user@example.com"), - ) - _, err := client.PageShield.Connections.Get( - context.TODO(), - "c9ef84a6bf5e47138c75d95e2f933e8f", - cloudflare.PageShieldConnectionGetParams{ - ZoneID: cloudflare.F("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/pageshieldpolicy.go b/pageshieldpolicy.go deleted file mode 100644 index 8539a125870..00000000000 --- a/pageshieldpolicy.go +++ /dev/null @@ -1,447 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// PageShieldPolicyService 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 [NewPageShieldPolicyService] method -// instead. -type PageShieldPolicyService struct { - Options []option.RequestOption -} - -// NewPageShieldPolicyService 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 NewPageShieldPolicyService(opts ...option.RequestOption) (r *PageShieldPolicyService) { - r = &PageShieldPolicyService{} - r.Options = opts - return -} - -// Create a Page Shield policy. -func (r *PageShieldPolicyService) New(ctx context.Context, params PageShieldPolicyNewParams, opts ...option.RequestOption) (res *PageShieldPolicyNewResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("zones/%s/page_shield/policies", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &res, opts...) - return -} - -// Update a Page Shield policy by ID. -func (r *PageShieldPolicyService) Update(ctx context.Context, policyID string, params PageShieldPolicyUpdateParams, opts ...option.RequestOption) (res *PageShieldPolicyUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("zones/%s/page_shield/policies/%s", params.ZoneID, policyID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &res, opts...) - return -} - -// Lists all Page Shield policies. -func (r *PageShieldPolicyService) List(ctx context.Context, query PageShieldPolicyListParams, opts ...option.RequestOption) (res *[]PageShieldPolicyListResponse, err error) { - opts = append(r.Options[:], opts...) - var env PageShieldPolicyListResponseEnvelope - path := fmt.Sprintf("zones/%s/page_shield/policies", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a Page Shield policy by ID. -func (r *PageShieldPolicyService) Delete(ctx context.Context, policyID string, body PageShieldPolicyDeleteParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := fmt.Sprintf("zones/%s/page_shield/policies/%s", body.ZoneID, policyID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) - return -} - -// Fetches a Page Shield policy by ID. -func (r *PageShieldPolicyService) Get(ctx context.Context, policyID string, query PageShieldPolicyGetParams, opts ...option.RequestOption) (res *PageShieldPolicyGetResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("zones/%s/page_shield/policies/%s", query.ZoneID, policyID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -type PageShieldPolicyNewResponse struct { - // The ID of the policy - ID string `json:"id"` - // The action to take if the expression matches - Action PageShieldPolicyNewResponseAction `json:"action"` - // A description for the policy - Description string `json:"description"` - // Whether the policy is enabled - Enabled bool `json:"enabled"` - // The expression which must match for the policy to be applied, using the - // Cloudflare Firewall rule expression syntax - Expression string `json:"expression"` - // The policy which will be applied - Value string `json:"value"` - JSON pageShieldPolicyNewResponseJSON `json:"-"` -} - -// pageShieldPolicyNewResponseJSON contains the JSON metadata for the struct -// [PageShieldPolicyNewResponse] -type pageShieldPolicyNewResponseJSON struct { - ID apijson.Field - Action apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldPolicyNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldPolicyNewResponseJSON) RawJSON() string { - return r.raw -} - -// The action to take if the expression matches -type PageShieldPolicyNewResponseAction string - -const ( - PageShieldPolicyNewResponseActionAllow PageShieldPolicyNewResponseAction = "allow" - PageShieldPolicyNewResponseActionLog PageShieldPolicyNewResponseAction = "log" -) - -type PageShieldPolicyUpdateResponse struct { - // The ID of the policy - ID string `json:"id"` - // The action to take if the expression matches - Action PageShieldPolicyUpdateResponseAction `json:"action"` - // A description for the policy - Description string `json:"description"` - // Whether the policy is enabled - Enabled bool `json:"enabled"` - // The expression which must match for the policy to be applied, using the - // Cloudflare Firewall rule expression syntax - Expression string `json:"expression"` - // The policy which will be applied - Value string `json:"value"` - JSON pageShieldPolicyUpdateResponseJSON `json:"-"` -} - -// pageShieldPolicyUpdateResponseJSON contains the JSON metadata for the struct -// [PageShieldPolicyUpdateResponse] -type pageShieldPolicyUpdateResponseJSON struct { - ID apijson.Field - Action apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldPolicyUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldPolicyUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// The action to take if the expression matches -type PageShieldPolicyUpdateResponseAction string - -const ( - PageShieldPolicyUpdateResponseActionAllow PageShieldPolicyUpdateResponseAction = "allow" - PageShieldPolicyUpdateResponseActionLog PageShieldPolicyUpdateResponseAction = "log" -) - -type PageShieldPolicyListResponse struct { - // The ID of the policy - ID string `json:"id"` - // The action to take if the expression matches - Action PageShieldPolicyListResponseAction `json:"action"` - // A description for the policy - Description string `json:"description"` - // Whether the policy is enabled - Enabled bool `json:"enabled"` - // The expression which must match for the policy to be applied, using the - // Cloudflare Firewall rule expression syntax - Expression string `json:"expression"` - // The policy which will be applied - Value string `json:"value"` - JSON pageShieldPolicyListResponseJSON `json:"-"` -} - -// pageShieldPolicyListResponseJSON contains the JSON metadata for the struct -// [PageShieldPolicyListResponse] -type pageShieldPolicyListResponseJSON struct { - ID apijson.Field - Action apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldPolicyListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldPolicyListResponseJSON) RawJSON() string { - return r.raw -} - -// The action to take if the expression matches -type PageShieldPolicyListResponseAction string - -const ( - PageShieldPolicyListResponseActionAllow PageShieldPolicyListResponseAction = "allow" - PageShieldPolicyListResponseActionLog PageShieldPolicyListResponseAction = "log" -) - -type PageShieldPolicyGetResponse struct { - // The ID of the policy - ID string `json:"id"` - // The action to take if the expression matches - Action PageShieldPolicyGetResponseAction `json:"action"` - // A description for the policy - Description string `json:"description"` - // Whether the policy is enabled - Enabled bool `json:"enabled"` - // The expression which must match for the policy to be applied, using the - // Cloudflare Firewall rule expression syntax - Expression string `json:"expression"` - // The policy which will be applied - Value string `json:"value"` - JSON pageShieldPolicyGetResponseJSON `json:"-"` -} - -// pageShieldPolicyGetResponseJSON contains the JSON metadata for the struct -// [PageShieldPolicyGetResponse] -type pageShieldPolicyGetResponseJSON struct { - ID apijson.Field - Action apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldPolicyGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldPolicyGetResponseJSON) RawJSON() string { - return r.raw -} - -// The action to take if the expression matches -type PageShieldPolicyGetResponseAction string - -const ( - PageShieldPolicyGetResponseActionAllow PageShieldPolicyGetResponseAction = "allow" - PageShieldPolicyGetResponseActionLog PageShieldPolicyGetResponseAction = "log" -) - -type PageShieldPolicyNewParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // The action to take if the expression matches - Action param.Field[PageShieldPolicyNewParamsAction] `json:"action"` - // A description for the policy - Description param.Field[string] `json:"description"` - // Whether the policy is enabled - Enabled param.Field[bool] `json:"enabled"` - // The expression which must match for the policy to be applied, using the - // Cloudflare Firewall rule expression syntax - Expression param.Field[string] `json:"expression"` - // The policy which will be applied - Value param.Field[string] `json:"value"` -} - -func (r PageShieldPolicyNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The action to take if the expression matches -type PageShieldPolicyNewParamsAction string - -const ( - PageShieldPolicyNewParamsActionAllow PageShieldPolicyNewParamsAction = "allow" - PageShieldPolicyNewParamsActionLog PageShieldPolicyNewParamsAction = "log" -) - -type PageShieldPolicyUpdateParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // The action to take if the expression matches - Action param.Field[PageShieldPolicyUpdateParamsAction] `json:"action"` - // A description for the policy - Description param.Field[string] `json:"description"` - // Whether the policy is enabled - Enabled param.Field[bool] `json:"enabled"` - // The expression which must match for the policy to be applied, using the - // Cloudflare Firewall rule expression syntax - Expression param.Field[string] `json:"expression"` - // The policy which will be applied - Value param.Field[string] `json:"value"` -} - -func (r PageShieldPolicyUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The action to take if the expression matches -type PageShieldPolicyUpdateParamsAction string - -const ( - PageShieldPolicyUpdateParamsActionAllow PageShieldPolicyUpdateParamsAction = "allow" - PageShieldPolicyUpdateParamsActionLog PageShieldPolicyUpdateParamsAction = "log" -) - -type PageShieldPolicyListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type PageShieldPolicyListResponseEnvelope struct { - Errors []PageShieldPolicyListResponseEnvelopeErrors `json:"errors,required"` - Messages []PageShieldPolicyListResponseEnvelopeMessages `json:"messages,required"` - Result []PageShieldPolicyListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success PageShieldPolicyListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo PageShieldPolicyListResponseEnvelopeResultInfo `json:"result_info"` - JSON pageShieldPolicyListResponseEnvelopeJSON `json:"-"` -} - -// pageShieldPolicyListResponseEnvelopeJSON contains the JSON metadata for the -// struct [PageShieldPolicyListResponseEnvelope] -type pageShieldPolicyListResponseEnvelopeJSON 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 *PageShieldPolicyListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldPolicyListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PageShieldPolicyListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageShieldPolicyListResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageShieldPolicyListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [PageShieldPolicyListResponseEnvelopeErrors] -type pageShieldPolicyListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldPolicyListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldPolicyListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageShieldPolicyListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageShieldPolicyListResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageShieldPolicyListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [PageShieldPolicyListResponseEnvelopeMessages] -type pageShieldPolicyListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldPolicyListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldPolicyListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PageShieldPolicyListResponseEnvelopeSuccess bool - -const ( - PageShieldPolicyListResponseEnvelopeSuccessTrue PageShieldPolicyListResponseEnvelopeSuccess = true -) - -type PageShieldPolicyListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON pageShieldPolicyListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// pageShieldPolicyListResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [PageShieldPolicyListResponseEnvelopeResultInfo] -type pageShieldPolicyListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldPolicyListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldPolicyListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type PageShieldPolicyDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type PageShieldPolicyGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} diff --git a/pageshieldpolicy_test.go b/pageshieldpolicy_test.go deleted file mode 100644 index 6e727c26c55..00000000000 --- a/pageshieldpolicy_test.go +++ /dev/null @@ -1,166 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestPageShieldPolicyNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.PageShield.Policies.New(context.TODO(), cloudflare.PageShieldPolicyNewParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Action: cloudflare.F(cloudflare.PageShieldPolicyNewParamsActionAllow), - Description: cloudflare.F("Checkout page CSP policy"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("ends_with(http.request.uri.path, \"/checkout\")"), - Value: cloudflare.F("script-src 'none';"), - }) - 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 TestPageShieldPolicyUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.PageShield.Policies.Update( - context.TODO(), - "c9ef84a6bf5e47138c75d95e2f933e8f", - cloudflare.PageShieldPolicyUpdateParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Action: cloudflare.F(cloudflare.PageShieldPolicyUpdateParamsActionAllow), - Description: cloudflare.F("Checkout page CSP policy"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("ends_with(http.request.uri.path, \"/checkout\")"), - Value: cloudflare.F("script-src 'none';"), - }, - ) - 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 TestPageShieldPolicyList(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("user@example.com"), - ) - _, err := client.PageShield.Policies.List(context.TODO(), cloudflare.PageShieldPolicyListParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestPageShieldPolicyDelete(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("user@example.com"), - ) - err := client.PageShield.Policies.Delete( - context.TODO(), - "c9ef84a6bf5e47138c75d95e2f933e8f", - cloudflare.PageShieldPolicyDeleteParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestPageShieldPolicyGet(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("user@example.com"), - ) - _, err := client.PageShield.Policies.Get( - context.TODO(), - "c9ef84a6bf5e47138c75d95e2f933e8f", - cloudflare.PageShieldPolicyGetParams{ - ZoneID: cloudflare.F("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/pageshieldscript.go b/pageshieldscript.go deleted file mode 100644 index 71bfc3601f7..00000000000 --- a/pageshieldscript.go +++ /dev/null @@ -1,384 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// PageShieldScriptService 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 [NewPageShieldScriptService] method -// instead. -type PageShieldScriptService struct { - Options []option.RequestOption -} - -// NewPageShieldScriptService 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 NewPageShieldScriptService(opts ...option.RequestOption) (r *PageShieldScriptService) { - r = &PageShieldScriptService{} - r.Options = opts - return -} - -// Lists all scripts detected by Page Shield. -func (r *PageShieldScriptService) List(ctx context.Context, params PageShieldScriptListParams, opts ...option.RequestOption) (res *[]PageShieldScriptListResponse, err error) { - opts = append(r.Options[:], opts...) - var env PageShieldScriptListResponseEnvelope - path := fmt.Sprintf("zones/%s/page_shield/scripts", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a script detected by Page Shield by script ID. -func (r *PageShieldScriptService) Get(ctx context.Context, scriptID string, query PageShieldScriptGetParams, opts ...option.RequestOption) (res *PageShieldScriptGetResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("zones/%s/page_shield/scripts/%s", query.ZoneID, scriptID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -type PageShieldScriptListResponse struct { - ID interface{} `json:"id"` - AddedAt interface{} `json:"added_at"` - DomainReportedMalicious interface{} `json:"domain_reported_malicious"` - FetchedAt interface{} `json:"fetched_at"` - FirstPageURL interface{} `json:"first_page_url"` - FirstSeenAt interface{} `json:"first_seen_at"` - Hash interface{} `json:"hash"` - Host interface{} `json:"host"` - JsIntegrityScore interface{} `json:"js_integrity_score"` - LastSeenAt interface{} `json:"last_seen_at"` - PageURLs interface{} `json:"page_urls"` - URL interface{} `json:"url"` - URLContainsCdnCgiPath interface{} `json:"url_contains_cdn_cgi_path"` - JSON pageShieldScriptListResponseJSON `json:"-"` -} - -// pageShieldScriptListResponseJSON contains the JSON metadata for the struct -// [PageShieldScriptListResponse] -type pageShieldScriptListResponseJSON struct { - ID apijson.Field - AddedAt apijson.Field - DomainReportedMalicious apijson.Field - FetchedAt apijson.Field - FirstPageURL apijson.Field - FirstSeenAt apijson.Field - Hash apijson.Field - Host apijson.Field - JsIntegrityScore apijson.Field - LastSeenAt apijson.Field - PageURLs apijson.Field - URL apijson.Field - URLContainsCdnCgiPath apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldScriptListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldScriptListResponseJSON) RawJSON() string { - return r.raw -} - -type PageShieldScriptGetResponse struct { - ID interface{} `json:"id"` - AddedAt interface{} `json:"added_at"` - DomainReportedMalicious interface{} `json:"domain_reported_malicious"` - FetchedAt interface{} `json:"fetched_at"` - FirstPageURL interface{} `json:"first_page_url"` - FirstSeenAt interface{} `json:"first_seen_at"` - Hash interface{} `json:"hash"` - Host interface{} `json:"host"` - JsIntegrityScore interface{} `json:"js_integrity_score"` - LastSeenAt interface{} `json:"last_seen_at"` - PageURLs interface{} `json:"page_urls"` - URL interface{} `json:"url"` - URLContainsCdnCgiPath interface{} `json:"url_contains_cdn_cgi_path"` - Versions []PageShieldScriptGetResponseVersion `json:"versions,nullable"` - JSON pageShieldScriptGetResponseJSON `json:"-"` -} - -// pageShieldScriptGetResponseJSON contains the JSON metadata for the struct -// [PageShieldScriptGetResponse] -type pageShieldScriptGetResponseJSON struct { - ID apijson.Field - AddedAt apijson.Field - DomainReportedMalicious apijson.Field - FetchedAt apijson.Field - FirstPageURL apijson.Field - FirstSeenAt apijson.Field - Hash apijson.Field - Host apijson.Field - JsIntegrityScore apijson.Field - LastSeenAt apijson.Field - PageURLs apijson.Field - URL apijson.Field - URLContainsCdnCgiPath apijson.Field - Versions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldScriptGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldScriptGetResponseJSON) RawJSON() string { - return r.raw -} - -// The version of the analyzed script. -type PageShieldScriptGetResponseVersion struct { - // The timestamp of when the script was last fetched. - FetchedAt string `json:"fetched_at,nullable"` - // The computed hash of the analyzed script. - Hash string `json:"hash,nullable"` - // The integrity score of the JavaScript content. - JsIntegrityScore int64 `json:"js_integrity_score,nullable"` - JSON pageShieldScriptGetResponseVersionJSON `json:"-"` -} - -// pageShieldScriptGetResponseVersionJSON contains the JSON metadata for the struct -// [PageShieldScriptGetResponseVersion] -type pageShieldScriptGetResponseVersionJSON struct { - FetchedAt apijson.Field - Hash apijson.Field - JsIntegrityScore apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldScriptGetResponseVersion) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldScriptGetResponseVersionJSON) RawJSON() string { - return r.raw -} - -type PageShieldScriptListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // The direction used to sort returned scripts. - Direction param.Field[PageShieldScriptListParamsDirection] `query:"direction"` - // When true, excludes scripts seen in a `/cdn-cgi` path from the returned scripts. - // The default value is true. - ExcludeCdnCgi param.Field[bool] `query:"exclude_cdn_cgi"` - // When true, excludes duplicate scripts. We consider a script duplicate of another - // if their javascript content matches and they share the same url host and zone - // hostname. In such case, we return the most recent script for the URL host and - // zone hostname combination. - ExcludeDuplicates param.Field[bool] `query:"exclude_duplicates"` - // Excludes scripts whose URL contains one of the URL-encoded URLs separated by - // commas. - ExcludeURLs param.Field[string] `query:"exclude_urls"` - // Export the list of scripts as a file. Cannot be used with per_page or page - // options. - Export param.Field[PageShieldScriptListParamsExport] `query:"export"` - // Includes scripts that match one or more URL-encoded hostnames separated by - // commas. - // - // Wildcards are supported at the start and end of each hostname to support starts - // with, ends with and contains. If no wildcards are used, results will be filtered - // by exact match - Hosts param.Field[string] `query:"hosts"` - // The field used to sort returned scripts. - OrderBy param.Field[PageShieldScriptListParamsOrderBy] `query:"order_by"` - // The current page number of the paginated results. - // - // We additionally support a special value "all". When "all" is used, the API will - // return all the scripts with the applied filters in a single page. Additionally, - // when using this value, the API will not return the script versions or - // categorisation data for the URL and domain of the scripts. This feature is - // best-effort and it may only work for zones with a low number of scripts - Page param.Field[string] `query:"page"` - // Includes scripts that match one or more page URLs (separated by commas) where - // they were last seen - // - // Wildcards are supported at the start and end of each page URL to support starts - // with, ends with and contains. If no wildcards are used, results will be filtered - // by exact match - PageURL param.Field[string] `query:"page_url"` - // The number of results per page. - PerPage param.Field[float64] `query:"per_page"` - // When true, malicious scripts appear first in the returned scripts. - PrioritizeMalicious param.Field[bool] `query:"prioritize_malicious"` - // Filters the returned scripts using a comma-separated list of scripts statuses. - // Accepted values: `active`, `infrequent`, and `inactive`. The default value is - // `active`. - Status param.Field[string] `query:"status"` - // Includes scripts whose URL contain one or more URL-encoded URLs separated by - // commas. - URLs param.Field[string] `query:"urls"` -} - -// URLQuery serializes [PageShieldScriptListParams]'s query parameters as -// `url.Values`. -func (r PageShieldScriptListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// The direction used to sort returned scripts. -type PageShieldScriptListParamsDirection string - -const ( - PageShieldScriptListParamsDirectionAsc PageShieldScriptListParamsDirection = "asc" - PageShieldScriptListParamsDirectionDesc PageShieldScriptListParamsDirection = "desc" -) - -// Export the list of scripts as a file. Cannot be used with per_page or page -// options. -type PageShieldScriptListParamsExport string - -const ( - PageShieldScriptListParamsExportCsv PageShieldScriptListParamsExport = "csv" -) - -// The field used to sort returned scripts. -type PageShieldScriptListParamsOrderBy string - -const ( - PageShieldScriptListParamsOrderByFirstSeenAt PageShieldScriptListParamsOrderBy = "first_seen_at" - PageShieldScriptListParamsOrderByLastSeenAt PageShieldScriptListParamsOrderBy = "last_seen_at" -) - -type PageShieldScriptListResponseEnvelope struct { - Errors []PageShieldScriptListResponseEnvelopeErrors `json:"errors,required"` - Messages []PageShieldScriptListResponseEnvelopeMessages `json:"messages,required"` - Result []PageShieldScriptListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success PageShieldScriptListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo PageShieldScriptListResponseEnvelopeResultInfo `json:"result_info"` - JSON pageShieldScriptListResponseEnvelopeJSON `json:"-"` -} - -// pageShieldScriptListResponseEnvelopeJSON contains the JSON metadata for the -// struct [PageShieldScriptListResponseEnvelope] -type pageShieldScriptListResponseEnvelopeJSON 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 *PageShieldScriptListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldScriptListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PageShieldScriptListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageShieldScriptListResponseEnvelopeErrorsJSON `json:"-"` -} - -// pageShieldScriptListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [PageShieldScriptListResponseEnvelopeErrors] -type pageShieldScriptListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldScriptListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldScriptListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PageShieldScriptListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pageShieldScriptListResponseEnvelopeMessagesJSON `json:"-"` -} - -// pageShieldScriptListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [PageShieldScriptListResponseEnvelopeMessages] -type pageShieldScriptListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldScriptListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldScriptListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PageShieldScriptListResponseEnvelopeSuccess bool - -const ( - PageShieldScriptListResponseEnvelopeSuccessTrue PageShieldScriptListResponseEnvelopeSuccess = true -) - -type PageShieldScriptListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON pageShieldScriptListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// pageShieldScriptListResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [PageShieldScriptListResponseEnvelopeResultInfo] -type pageShieldScriptListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PageShieldScriptListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pageShieldScriptListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type PageShieldScriptGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} diff --git a/pageshieldscript_test.go b/pageshieldscript_test.go deleted file mode 100644 index a1fa8eb3570..00000000000 --- a/pageshieldscript_test.go +++ /dev/null @@ -1,83 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestPageShieldScriptListWithOptionalParams(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("user@example.com"), - ) - _, err := client.PageShield.Scripts.List(context.TODO(), cloudflare.PageShieldScriptListParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Direction: cloudflare.F(cloudflare.PageShieldScriptListParamsDirectionAsc), - ExcludeCdnCgi: cloudflare.F(true), - ExcludeDuplicates: cloudflare.F(true), - ExcludeURLs: cloudflare.F("blog.cloudflare.com,www.example"), - Export: cloudflare.F(cloudflare.PageShieldScriptListParamsExportCsv), - Hosts: cloudflare.F("blog.cloudflare.com,www.example*,*cloudflare.com"), - OrderBy: cloudflare.F(cloudflare.PageShieldScriptListParamsOrderByFirstSeenAt), - Page: cloudflare.F("string"), - PageURL: cloudflare.F("example.com/page,*/checkout,example.com/*,*checkout*"), - PerPage: cloudflare.F(100.000000), - PrioritizeMalicious: cloudflare.F(true), - Status: cloudflare.F("active,inactive"), - URLs: cloudflare.F("blog.cloudflare.com,www.example"), - }) - 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 TestPageShieldScriptGet(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("user@example.com"), - ) - _, err := client.PageShield.Scripts.Get( - context.TODO(), - "c9ef84a6bf5e47138c75d95e2f933e8f", - cloudflare.PageShieldScriptGetParams{ - ZoneID: cloudflare.F("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/pcapdownload.go b/pcapdownload.go deleted file mode 100644 index a354cfa21c3..00000000000 --- a/pcapdownload.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// PCAPDownloadService 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 [NewPCAPDownloadService] method -// instead. -type PCAPDownloadService struct { - Options []option.RequestOption -} - -// NewPCAPDownloadService 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 NewPCAPDownloadService(opts ...option.RequestOption) (r *PCAPDownloadService) { - r = &PCAPDownloadService{} - r.Options = opts - return -} - -// Download PCAP information into a file. Response is a binary PCAP file. -func (r *PCAPDownloadService) Get(ctx context.Context, pcapID string, query PCAPDownloadGetParams, opts ...option.RequestOption) (res *http.Response, err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "application/vnd.tcpdump.pcap")}, opts...) - path := fmt.Sprintf("accounts/%s/pcaps/%s/download", query.AccountID, pcapID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -type PCAPDownloadGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} diff --git a/pcapdownload_test.go b/pcapdownload_test.go deleted file mode 100644 index 48550154a69..00000000000 --- a/pcapdownload_test.go +++ /dev/null @@ -1,58 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "bytes" - "context" - "errors" - "io" - "net/http" - "net/http/httptest" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestPCAPDownloadGet(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - w.Write([]byte("abc")) - })) - defer server.Close() - baseURL := server.URL - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - resp, err := client.PCAPs.Downloads.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.PCAPDownloadGetParams{ - AccountID: cloudflare.F("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()) - } - defer resp.Body.Close() - - b, err := io.ReadAll(resp.Body) - 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()) - } - if !bytes.Equal(b, []byte("abc")) { - t.Fatalf("return value not %s: %s", "abc", b) - } -} diff --git a/pcapownership.go b/pcapownership.go deleted file mode 100644 index 6c1bf549096..00000000000 --- a/pcapownership.go +++ /dev/null @@ -1,528 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// PCAPOwnershipService 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 [NewPCAPOwnershipService] method -// instead. -type PCAPOwnershipService struct { - Options []option.RequestOption -} - -// NewPCAPOwnershipService 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 NewPCAPOwnershipService(opts ...option.RequestOption) (r *PCAPOwnershipService) { - r = &PCAPOwnershipService{} - r.Options = opts - return -} - -// Adds an AWS or GCP bucket to use with full packet captures. -func (r *PCAPOwnershipService) New(ctx context.Context, params PCAPOwnershipNewParams, opts ...option.RequestOption) (res *PCAPOwnershipNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env PCAPOwnershipNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/pcaps/ownership", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes buckets added to the packet captures API. -func (r *PCAPOwnershipService) Delete(ctx context.Context, ownershipID string, body PCAPOwnershipDeleteParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := fmt.Sprintf("accounts/%s/pcaps/ownership/%s", body.AccountID, ownershipID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) - return -} - -// List all buckets configured for use with PCAPs API. -func (r *PCAPOwnershipService) Get(ctx context.Context, query PCAPOwnershipGetParams, opts ...option.RequestOption) (res *[]PCAPOwnershipGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env PCAPOwnershipGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/pcaps/ownership", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Validates buckets added to the packet captures API. -func (r *PCAPOwnershipService) Validate(ctx context.Context, params PCAPOwnershipValidateParams, opts ...option.RequestOption) (res *PCAPOwnershipValidateResponse, err error) { - opts = append(r.Options[:], opts...) - var env PCAPOwnershipValidateResponseEnvelope - path := fmt.Sprintf("accounts/%s/pcaps/ownership/validate", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type PCAPOwnershipNewResponse struct { - // The bucket ID associated with the packet captures API. - ID string `json:"id,required"` - // The full URI for the bucket. This field only applies to `full` packet captures. - DestinationConf string `json:"destination_conf,required"` - // The ownership challenge filename stored in the bucket. - Filename string `json:"filename,required"` - // The status of the ownership challenge. Can be pending, success or failed. - Status PCAPOwnershipNewResponseStatus `json:"status,required"` - // The RFC 3339 timestamp when the bucket was added to packet captures API. - Submitted string `json:"submitted,required"` - // The RFC 3339 timestamp when the bucket was validated. - Validated string `json:"validated"` - JSON pcapOwnershipNewResponseJSON `json:"-"` -} - -// pcapOwnershipNewResponseJSON contains the JSON metadata for the struct -// [PCAPOwnershipNewResponse] -type pcapOwnershipNewResponseJSON struct { - ID apijson.Field - DestinationConf apijson.Field - Filename apijson.Field - Status apijson.Field - Submitted apijson.Field - Validated apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPOwnershipNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapOwnershipNewResponseJSON) RawJSON() string { - return r.raw -} - -// The status of the ownership challenge. Can be pending, success or failed. -type PCAPOwnershipNewResponseStatus string - -const ( - PCAPOwnershipNewResponseStatusPending PCAPOwnershipNewResponseStatus = "pending" - PCAPOwnershipNewResponseStatusSuccess PCAPOwnershipNewResponseStatus = "success" - PCAPOwnershipNewResponseStatusFailed PCAPOwnershipNewResponseStatus = "failed" -) - -type PCAPOwnershipGetResponse struct { - // The bucket ID associated with the packet captures API. - ID string `json:"id,required"` - // The full URI for the bucket. This field only applies to `full` packet captures. - DestinationConf string `json:"destination_conf,required"` - // The ownership challenge filename stored in the bucket. - Filename string `json:"filename,required"` - // The status of the ownership challenge. Can be pending, success or failed. - Status PCAPOwnershipGetResponseStatus `json:"status,required"` - // The RFC 3339 timestamp when the bucket was added to packet captures API. - Submitted string `json:"submitted,required"` - // The RFC 3339 timestamp when the bucket was validated. - Validated string `json:"validated"` - JSON pcapOwnershipGetResponseJSON `json:"-"` -} - -// pcapOwnershipGetResponseJSON contains the JSON metadata for the struct -// [PCAPOwnershipGetResponse] -type pcapOwnershipGetResponseJSON struct { - ID apijson.Field - DestinationConf apijson.Field - Filename apijson.Field - Status apijson.Field - Submitted apijson.Field - Validated apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPOwnershipGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapOwnershipGetResponseJSON) RawJSON() string { - return r.raw -} - -// The status of the ownership challenge. Can be pending, success or failed. -type PCAPOwnershipGetResponseStatus string - -const ( - PCAPOwnershipGetResponseStatusPending PCAPOwnershipGetResponseStatus = "pending" - PCAPOwnershipGetResponseStatusSuccess PCAPOwnershipGetResponseStatus = "success" - PCAPOwnershipGetResponseStatusFailed PCAPOwnershipGetResponseStatus = "failed" -) - -type PCAPOwnershipValidateResponse struct { - // The bucket ID associated with the packet captures API. - ID string `json:"id,required"` - // The full URI for the bucket. This field only applies to `full` packet captures. - DestinationConf string `json:"destination_conf,required"` - // The ownership challenge filename stored in the bucket. - Filename string `json:"filename,required"` - // The status of the ownership challenge. Can be pending, success or failed. - Status PCAPOwnershipValidateResponseStatus `json:"status,required"` - // The RFC 3339 timestamp when the bucket was added to packet captures API. - Submitted string `json:"submitted,required"` - // The RFC 3339 timestamp when the bucket was validated. - Validated string `json:"validated"` - JSON pcapOwnershipValidateResponseJSON `json:"-"` -} - -// pcapOwnershipValidateResponseJSON contains the JSON metadata for the struct -// [PCAPOwnershipValidateResponse] -type pcapOwnershipValidateResponseJSON struct { - ID apijson.Field - DestinationConf apijson.Field - Filename apijson.Field - Status apijson.Field - Submitted apijson.Field - Validated apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPOwnershipValidateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapOwnershipValidateResponseJSON) RawJSON() string { - return r.raw -} - -// The status of the ownership challenge. Can be pending, success or failed. -type PCAPOwnershipValidateResponseStatus string - -const ( - PCAPOwnershipValidateResponseStatusPending PCAPOwnershipValidateResponseStatus = "pending" - PCAPOwnershipValidateResponseStatusSuccess PCAPOwnershipValidateResponseStatus = "success" - PCAPOwnershipValidateResponseStatusFailed PCAPOwnershipValidateResponseStatus = "failed" -) - -type PCAPOwnershipNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The full URI for the bucket. This field only applies to `full` packet captures. - DestinationConf param.Field[string] `json:"destination_conf,required"` -} - -func (r PCAPOwnershipNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type PCAPOwnershipNewResponseEnvelope struct { - Errors []PCAPOwnershipNewResponseEnvelopeErrors `json:"errors,required"` - Messages []PCAPOwnershipNewResponseEnvelopeMessages `json:"messages,required"` - Result PCAPOwnershipNewResponse `json:"result,required"` - // Whether the API call was successful - Success PCAPOwnershipNewResponseEnvelopeSuccess `json:"success,required"` - JSON pcapOwnershipNewResponseEnvelopeJSON `json:"-"` -} - -// pcapOwnershipNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [PCAPOwnershipNewResponseEnvelope] -type pcapOwnershipNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPOwnershipNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapOwnershipNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PCAPOwnershipNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pcapOwnershipNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// pcapOwnershipNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PCAPOwnershipNewResponseEnvelopeErrors] -type pcapOwnershipNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPOwnershipNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapOwnershipNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PCAPOwnershipNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pcapOwnershipNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// pcapOwnershipNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PCAPOwnershipNewResponseEnvelopeMessages] -type pcapOwnershipNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPOwnershipNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapOwnershipNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PCAPOwnershipNewResponseEnvelopeSuccess bool - -const ( - PCAPOwnershipNewResponseEnvelopeSuccessTrue PCAPOwnershipNewResponseEnvelopeSuccess = true -) - -type PCAPOwnershipDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type PCAPOwnershipGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type PCAPOwnershipGetResponseEnvelope struct { - Errors []PCAPOwnershipGetResponseEnvelopeErrors `json:"errors,required"` - Messages []PCAPOwnershipGetResponseEnvelopeMessages `json:"messages,required"` - Result []PCAPOwnershipGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success PCAPOwnershipGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo PCAPOwnershipGetResponseEnvelopeResultInfo `json:"result_info"` - JSON pcapOwnershipGetResponseEnvelopeJSON `json:"-"` -} - -// pcapOwnershipGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [PCAPOwnershipGetResponseEnvelope] -type pcapOwnershipGetResponseEnvelopeJSON 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 *PCAPOwnershipGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapOwnershipGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PCAPOwnershipGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pcapOwnershipGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// pcapOwnershipGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [PCAPOwnershipGetResponseEnvelopeErrors] -type pcapOwnershipGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPOwnershipGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapOwnershipGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PCAPOwnershipGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pcapOwnershipGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// pcapOwnershipGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [PCAPOwnershipGetResponseEnvelopeMessages] -type pcapOwnershipGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPOwnershipGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapOwnershipGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PCAPOwnershipGetResponseEnvelopeSuccess bool - -const ( - PCAPOwnershipGetResponseEnvelopeSuccessTrue PCAPOwnershipGetResponseEnvelopeSuccess = true -) - -type PCAPOwnershipGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON pcapOwnershipGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// pcapOwnershipGetResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [PCAPOwnershipGetResponseEnvelopeResultInfo] -type pcapOwnershipGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPOwnershipGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapOwnershipGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type PCAPOwnershipValidateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The full URI for the bucket. This field only applies to `full` packet captures. - DestinationConf param.Field[string] `json:"destination_conf,required"` - // The ownership challenge filename stored in the bucket. - OwnershipChallenge param.Field[string] `json:"ownership_challenge,required"` -} - -func (r PCAPOwnershipValidateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type PCAPOwnershipValidateResponseEnvelope struct { - Errors []PCAPOwnershipValidateResponseEnvelopeErrors `json:"errors,required"` - Messages []PCAPOwnershipValidateResponseEnvelopeMessages `json:"messages,required"` - Result PCAPOwnershipValidateResponse `json:"result,required"` - // Whether the API call was successful - Success PCAPOwnershipValidateResponseEnvelopeSuccess `json:"success,required"` - JSON pcapOwnershipValidateResponseEnvelopeJSON `json:"-"` -} - -// pcapOwnershipValidateResponseEnvelopeJSON contains the JSON metadata for the -// struct [PCAPOwnershipValidateResponseEnvelope] -type pcapOwnershipValidateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPOwnershipValidateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapOwnershipValidateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type PCAPOwnershipValidateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pcapOwnershipValidateResponseEnvelopeErrorsJSON `json:"-"` -} - -// pcapOwnershipValidateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [PCAPOwnershipValidateResponseEnvelopeErrors] -type pcapOwnershipValidateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPOwnershipValidateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapOwnershipValidateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type PCAPOwnershipValidateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON pcapOwnershipValidateResponseEnvelopeMessagesJSON `json:"-"` -} - -// pcapOwnershipValidateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [PCAPOwnershipValidateResponseEnvelopeMessages] -type pcapOwnershipValidateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PCAPOwnershipValidateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r pcapOwnershipValidateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type PCAPOwnershipValidateResponseEnvelopeSuccess bool - -const ( - PCAPOwnershipValidateResponseEnvelopeSuccessTrue PCAPOwnershipValidateResponseEnvelopeSuccess = true -) diff --git a/pcapownership_test.go b/pcapownership_test.go deleted file mode 100644 index d61815d02a7..00000000000 --- a/pcapownership_test.go +++ /dev/null @@ -1,125 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestPCAPOwnershipNew(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("user@example.com"), - ) - _, err := client.PCAPs.Ownerships.New(context.TODO(), cloudflare.PCAPOwnershipNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - DestinationConf: cloudflare.F("s3://pcaps-bucket?region=us-east-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 TestPCAPOwnershipDelete(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("user@example.com"), - ) - err := client.PCAPs.Ownerships.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.PCAPOwnershipDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestPCAPOwnershipGet(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("user@example.com"), - ) - _, err := client.PCAPs.Ownerships.Get(context.TODO(), cloudflare.PCAPOwnershipGetParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestPCAPOwnershipValidate(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("user@example.com"), - ) - _, err := client.PCAPs.Ownerships.Validate(context.TODO(), cloudflare.PCAPOwnershipValidateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - DestinationConf: cloudflare.F("s3://pcaps-bucket?region=us-east-1"), - OwnershipChallenge: cloudflare.F("ownership-challenge-9883874ecac311ec8475433579a6bf5f.txt"), - }) - 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/pcaps/aliases.go b/pcaps/aliases.go new file mode 100644 index 00000000000..961dea82c4e --- /dev/null +++ b/pcaps/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package pcaps + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/pcaps/download.go b/pcaps/download.go new file mode 100644 index 00000000000..ab5985a6363 --- /dev/null +++ b/pcaps/download.go @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package pcaps + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DownloadService 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 [NewDownloadService] method instead. +type DownloadService struct { + Options []option.RequestOption +} + +// NewDownloadService 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 NewDownloadService(opts ...option.RequestOption) (r *DownloadService) { + r = &DownloadService{} + r.Options = opts + return +} + +// Download PCAP information into a file. Response is a binary PCAP file. +func (r *DownloadService) Get(ctx context.Context, pcapID string, query DownloadGetParams, opts ...option.RequestOption) (res *http.Response, err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "application/vnd.tcpdump.pcap")}, opts...) + path := fmt.Sprintf("accounts/%s/pcaps/%s/download", query.AccountID, pcapID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +type DownloadGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} diff --git a/pcaps/download_test.go b/pcaps/download_test.go new file mode 100644 index 00000000000..6d79fc9acd8 --- /dev/null +++ b/pcaps/download_test.go @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package pcaps_test + +import ( + "bytes" + "context" + "errors" + "io" + "net/http" + "net/http/httptest" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/pcaps" +) + +func TestDownloadGet(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + w.Write([]byte("abc")) + })) + defer server.Close() + baseURL := server.URL + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("user@example.com"), + ) + resp, err := client.PCAPs.Downloads.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + pcaps.DownloadGetParams{ + AccountID: cloudflare.F("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()) + } + defer resp.Body.Close() + + b, err := io.ReadAll(resp.Body) + 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()) + } + if !bytes.Equal(b, []byte("abc")) { + t.Fatalf("return value not %s: %s", "abc", b) + } +} diff --git a/pcaps/ownership.go b/pcaps/ownership.go new file mode 100644 index 00000000000..d8b88f7d549 --- /dev/null +++ b/pcaps/ownership.go @@ -0,0 +1,435 @@ +// File generated from our OpenAPI spec by Stainless. + +package pcaps + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// OwnershipService 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 [NewOwnershipService] method instead. +type OwnershipService struct { + Options []option.RequestOption +} + +// NewOwnershipService 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 NewOwnershipService(opts ...option.RequestOption) (r *OwnershipService) { + r = &OwnershipService{} + r.Options = opts + return +} + +// Adds an AWS or GCP bucket to use with full packet captures. +func (r *OwnershipService) New(ctx context.Context, params OwnershipNewParams, opts ...option.RequestOption) (res *MagicVisibilityPCAPsOwnership, err error) { + opts = append(r.Options[:], opts...) + var env OwnershipNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/pcaps/ownership", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes buckets added to the packet captures API. +func (r *OwnershipService) Delete(ctx context.Context, ownershipID string, body OwnershipDeleteParams, opts ...option.RequestOption) (err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + path := fmt.Sprintf("accounts/%s/pcaps/ownership/%s", body.AccountID, ownershipID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) + return +} + +// List all buckets configured for use with PCAPs API. +func (r *OwnershipService) Get(ctx context.Context, query OwnershipGetParams, opts ...option.RequestOption) (res *[]MagicVisibilityPCAPsOwnership, err error) { + opts = append(r.Options[:], opts...) + var env OwnershipGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/pcaps/ownership", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Validates buckets added to the packet captures API. +func (r *OwnershipService) Validate(ctx context.Context, params OwnershipValidateParams, opts ...option.RequestOption) (res *MagicVisibilityPCAPsOwnership, err error) { + opts = append(r.Options[:], opts...) + var env OwnershipValidateResponseEnvelope + path := fmt.Sprintf("accounts/%s/pcaps/ownership/validate", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type MagicVisibilityPCAPsOwnership struct { + // The bucket ID associated with the packet captures API. + ID string `json:"id,required"` + // The full URI for the bucket. This field only applies to `full` packet captures. + DestinationConf string `json:"destination_conf,required"` + // The ownership challenge filename stored in the bucket. + Filename string `json:"filename,required"` + // The status of the ownership challenge. Can be pending, success or failed. + Status MagicVisibilityPCAPsOwnershipStatus `json:"status,required"` + // The RFC 3339 timestamp when the bucket was added to packet captures API. + Submitted string `json:"submitted,required"` + // The RFC 3339 timestamp when the bucket was validated. + Validated string `json:"validated"` + JSON magicVisibilityPCAPsOwnershipJSON `json:"-"` +} + +// magicVisibilityPCAPsOwnershipJSON contains the JSON metadata for the struct +// [MagicVisibilityPCAPsOwnership] +type magicVisibilityPCAPsOwnershipJSON struct { + ID apijson.Field + DestinationConf apijson.Field + Filename apijson.Field + Status apijson.Field + Submitted apijson.Field + Validated apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MagicVisibilityPCAPsOwnership) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r magicVisibilityPCAPsOwnershipJSON) RawJSON() string { + return r.raw +} + +// The status of the ownership challenge. Can be pending, success or failed. +type MagicVisibilityPCAPsOwnershipStatus string + +const ( + MagicVisibilityPCAPsOwnershipStatusPending MagicVisibilityPCAPsOwnershipStatus = "pending" + MagicVisibilityPCAPsOwnershipStatusSuccess MagicVisibilityPCAPsOwnershipStatus = "success" + MagicVisibilityPCAPsOwnershipStatusFailed MagicVisibilityPCAPsOwnershipStatus = "failed" +) + +type OwnershipNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The full URI for the bucket. This field only applies to `full` packet captures. + DestinationConf param.Field[string] `json:"destination_conf,required"` +} + +func (r OwnershipNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type OwnershipNewResponseEnvelope struct { + Errors []OwnershipNewResponseEnvelopeErrors `json:"errors,required"` + Messages []OwnershipNewResponseEnvelopeMessages `json:"messages,required"` + Result MagicVisibilityPCAPsOwnership `json:"result,required"` + // Whether the API call was successful + Success OwnershipNewResponseEnvelopeSuccess `json:"success,required"` + JSON ownershipNewResponseEnvelopeJSON `json:"-"` +} + +// ownershipNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [OwnershipNewResponseEnvelope] +type ownershipNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OwnershipNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ownershipNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type OwnershipNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ownershipNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// ownershipNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [OwnershipNewResponseEnvelopeErrors] +type ownershipNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OwnershipNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ownershipNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type OwnershipNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ownershipNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// ownershipNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [OwnershipNewResponseEnvelopeMessages] +type ownershipNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OwnershipNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ownershipNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type OwnershipNewResponseEnvelopeSuccess bool + +const ( + OwnershipNewResponseEnvelopeSuccessTrue OwnershipNewResponseEnvelopeSuccess = true +) + +type OwnershipDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type OwnershipGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type OwnershipGetResponseEnvelope struct { + Errors []OwnershipGetResponseEnvelopeErrors `json:"errors,required"` + Messages []OwnershipGetResponseEnvelopeMessages `json:"messages,required"` + Result []MagicVisibilityPCAPsOwnership `json:"result,required,nullable"` + // Whether the API call was successful + Success OwnershipGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo OwnershipGetResponseEnvelopeResultInfo `json:"result_info"` + JSON ownershipGetResponseEnvelopeJSON `json:"-"` +} + +// ownershipGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [OwnershipGetResponseEnvelope] +type ownershipGetResponseEnvelopeJSON 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 *OwnershipGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ownershipGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type OwnershipGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ownershipGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// ownershipGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [OwnershipGetResponseEnvelopeErrors] +type ownershipGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OwnershipGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ownershipGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type OwnershipGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ownershipGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// ownershipGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [OwnershipGetResponseEnvelopeMessages] +type ownershipGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OwnershipGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ownershipGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type OwnershipGetResponseEnvelopeSuccess bool + +const ( + OwnershipGetResponseEnvelopeSuccessTrue OwnershipGetResponseEnvelopeSuccess = true +) + +type OwnershipGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON ownershipGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// ownershipGetResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [OwnershipGetResponseEnvelopeResultInfo] +type ownershipGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OwnershipGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ownershipGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type OwnershipValidateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The full URI for the bucket. This field only applies to `full` packet captures. + DestinationConf param.Field[string] `json:"destination_conf,required"` + // The ownership challenge filename stored in the bucket. + OwnershipChallenge param.Field[string] `json:"ownership_challenge,required"` +} + +func (r OwnershipValidateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type OwnershipValidateResponseEnvelope struct { + Errors []OwnershipValidateResponseEnvelopeErrors `json:"errors,required"` + Messages []OwnershipValidateResponseEnvelopeMessages `json:"messages,required"` + Result MagicVisibilityPCAPsOwnership `json:"result,required"` + // Whether the API call was successful + Success OwnershipValidateResponseEnvelopeSuccess `json:"success,required"` + JSON ownershipValidateResponseEnvelopeJSON `json:"-"` +} + +// ownershipValidateResponseEnvelopeJSON contains the JSON metadata for the struct +// [OwnershipValidateResponseEnvelope] +type ownershipValidateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OwnershipValidateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ownershipValidateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type OwnershipValidateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ownershipValidateResponseEnvelopeErrorsJSON `json:"-"` +} + +// ownershipValidateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [OwnershipValidateResponseEnvelopeErrors] +type ownershipValidateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OwnershipValidateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ownershipValidateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type OwnershipValidateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ownershipValidateResponseEnvelopeMessagesJSON `json:"-"` +} + +// ownershipValidateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [OwnershipValidateResponseEnvelopeMessages] +type ownershipValidateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OwnershipValidateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ownershipValidateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type OwnershipValidateResponseEnvelopeSuccess bool + +const ( + OwnershipValidateResponseEnvelopeSuccessTrue OwnershipValidateResponseEnvelopeSuccess = true +) diff --git a/pcaps/ownership_test.go b/pcaps/ownership_test.go new file mode 100644 index 00000000000..686b18ad440 --- /dev/null +++ b/pcaps/ownership_test.go @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Stainless. + +package pcaps_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/pcaps" +) + +func TestOwnershipNew(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("user@example.com"), + ) + _, err := client.PCAPs.Ownerships.New(context.TODO(), pcaps.OwnershipNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + DestinationConf: cloudflare.F("s3://pcaps-bucket?region=us-east-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 TestOwnershipDelete(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("user@example.com"), + ) + err := client.PCAPs.Ownerships.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + pcaps.OwnershipDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestOwnershipGet(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("user@example.com"), + ) + _, err := client.PCAPs.Ownerships.Get(context.TODO(), pcaps.OwnershipGetParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestOwnershipValidate(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("user@example.com"), + ) + _, err := client.PCAPs.Ownerships.Validate(context.TODO(), pcaps.OwnershipValidateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + DestinationConf: cloudflare.F("s3://pcaps-bucket?region=us-east-1"), + OwnershipChallenge: cloudflare.F("ownership-challenge-9883874ecac311ec8475433579a6bf5f.txt"), + }) + 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/pcap.go b/pcaps/pcap.go similarity index 98% rename from pcap.go rename to pcaps/pcap.go index 81d90ecdf83..fe8940eb32b 100644 --- a/pcap.go +++ b/pcaps/pcap.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package pcaps import ( "context" @@ -21,8 +21,8 @@ import ( // directly, and instead use the [NewPCAPService] method instead. type PCAPService struct { Options []option.RequestOption - Ownerships *PCAPOwnershipService - Downloads *PCAPDownloadService + Ownerships *OwnershipService + Downloads *DownloadService } // NewPCAPService generates a new service that applies the given options to each @@ -31,8 +31,8 @@ type PCAPService struct { func NewPCAPService(opts ...option.RequestOption) (r *PCAPService) { r = &PCAPService{} r.Options = opts - r.Ownerships = NewPCAPOwnershipService(opts...) - r.Downloads = NewPCAPDownloadService(opts...) + r.Ownerships = NewOwnershipService(opts...) + r.Downloads = NewDownloadService(opts...) return } @@ -75,10 +75,10 @@ func (r *PCAPService) Get(ctx context.Context, pcapID string, query PCAPGetParam return } -// Union satisfied by [PCAPNewResponseMagicVisibilityPCAPsResponseSimple] or -// [PCAPNewResponseMagicVisibilityPCAPsResponseFull]. +// Union satisfied by [pcaps.PCAPNewResponseMagicVisibilityPCAPsResponseSimple] or +// [pcaps.PCAPNewResponseMagicVisibilityPCAPsResponseFull]. type PCAPNewResponse interface { - implementsPCAPNewResponse() + implementsPCAPsPCAPNewResponse() } func init() { @@ -137,7 +137,7 @@ func (r pcapNewResponseMagicVisibilityPCAPsResponseSimpleJSON) RawJSON() string return r.raw } -func (r PCAPNewResponseMagicVisibilityPCAPsResponseSimple) implementsPCAPNewResponse() {} +func (r PCAPNewResponseMagicVisibilityPCAPsResponseSimple) implementsPCAPsPCAPNewResponse() {} // The packet capture filter. When this field is empty, all packets are captured. type PCAPNewResponseMagicVisibilityPCAPsResponseSimpleFilterV1 struct { @@ -262,7 +262,7 @@ func (r pcapNewResponseMagicVisibilityPCAPsResponseFullJSON) RawJSON() string { return r.raw } -func (r PCAPNewResponseMagicVisibilityPCAPsResponseFull) implementsPCAPNewResponse() {} +func (r PCAPNewResponseMagicVisibilityPCAPsResponseFull) implementsPCAPsPCAPNewResponse() {} // The packet capture filter. When this field is empty, all packets are captured. type PCAPNewResponseMagicVisibilityPCAPsResponseFullFilterV1 struct { @@ -330,10 +330,10 @@ const ( PCAPNewResponseMagicVisibilityPCAPsResponseFullTypeFull PCAPNewResponseMagicVisibilityPCAPsResponseFullType = "full" ) -// Union satisfied by [PCAPListResponseMagicVisibilityPCAPsResponseSimple] or -// [PCAPListResponseMagicVisibilityPCAPsResponseFull]. +// Union satisfied by [pcaps.PCAPListResponseMagicVisibilityPCAPsResponseSimple] or +// [pcaps.PCAPListResponseMagicVisibilityPCAPsResponseFull]. type PCAPListResponse interface { - implementsPCAPListResponse() + implementsPCAPsPCAPListResponse() } func init() { @@ -392,7 +392,7 @@ func (r pcapListResponseMagicVisibilityPCAPsResponseSimpleJSON) RawJSON() string return r.raw } -func (r PCAPListResponseMagicVisibilityPCAPsResponseSimple) implementsPCAPListResponse() {} +func (r PCAPListResponseMagicVisibilityPCAPsResponseSimple) implementsPCAPsPCAPListResponse() {} // The packet capture filter. When this field is empty, all packets are captured. type PCAPListResponseMagicVisibilityPCAPsResponseSimpleFilterV1 struct { @@ -517,7 +517,7 @@ func (r pcapListResponseMagicVisibilityPCAPsResponseFullJSON) RawJSON() string { return r.raw } -func (r PCAPListResponseMagicVisibilityPCAPsResponseFull) implementsPCAPListResponse() {} +func (r PCAPListResponseMagicVisibilityPCAPsResponseFull) implementsPCAPsPCAPListResponse() {} // The packet capture filter. When this field is empty, all packets are captured. type PCAPListResponseMagicVisibilityPCAPsResponseFullFilterV1 struct { @@ -585,10 +585,10 @@ const ( PCAPListResponseMagicVisibilityPCAPsResponseFullTypeFull PCAPListResponseMagicVisibilityPCAPsResponseFullType = "full" ) -// Union satisfied by [PCAPGetResponseMagicVisibilityPCAPsResponseSimple] or -// [PCAPGetResponseMagicVisibilityPCAPsResponseFull]. +// Union satisfied by [pcaps.PCAPGetResponseMagicVisibilityPCAPsResponseSimple] or +// [pcaps.PCAPGetResponseMagicVisibilityPCAPsResponseFull]. type PCAPGetResponse interface { - implementsPCAPGetResponse() + implementsPCAPsPCAPGetResponse() } func init() { @@ -647,7 +647,7 @@ func (r pcapGetResponseMagicVisibilityPCAPsResponseSimpleJSON) RawJSON() string return r.raw } -func (r PCAPGetResponseMagicVisibilityPCAPsResponseSimple) implementsPCAPGetResponse() {} +func (r PCAPGetResponseMagicVisibilityPCAPsResponseSimple) implementsPCAPsPCAPGetResponse() {} // The packet capture filter. When this field is empty, all packets are captured. type PCAPGetResponseMagicVisibilityPCAPsResponseSimpleFilterV1 struct { @@ -772,7 +772,7 @@ func (r pcapGetResponseMagicVisibilityPCAPsResponseFullJSON) RawJSON() string { return r.raw } -func (r PCAPGetResponseMagicVisibilityPCAPsResponseFull) implementsPCAPGetResponse() {} +func (r PCAPGetResponseMagicVisibilityPCAPsResponseFull) implementsPCAPsPCAPGetResponse() {} // The packet capture filter. When this field is empty, all packets are captured. type PCAPGetResponseMagicVisibilityPCAPsResponseFullFilterV1 struct { diff --git a/pcap_test.go b/pcaps/pcap_test.go similarity index 87% rename from pcap_test.go rename to pcaps/pcap_test.go index 48d618d5a58..1b6afd869d6 100644 --- a/pcap_test.go +++ b/pcaps/pcap_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package pcaps_test import ( "context" @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/pcaps" ) func TestPCAPNewWithOptionalParams(t *testing.T) { @@ -27,15 +28,15 @@ func TestPCAPNewWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.PCAPs.New(context.TODO(), cloudflare.PCAPNewParams{ + _, err := client.PCAPs.New(context.TODO(), pcaps.PCAPNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - System: cloudflare.F(cloudflare.PCAPNewParamsSystemMagicTransit), + System: cloudflare.F(pcaps.PCAPNewParamsSystemMagicTransit), TimeLimit: cloudflare.F(300.000000), - Type: cloudflare.F(cloudflare.PCAPNewParamsTypeSimple), + Type: cloudflare.F(pcaps.PCAPNewParamsTypeSimple), ByteLimit: cloudflare.F(500000.000000), ColoName: cloudflare.F("ord02"), DestinationConf: cloudflare.F("s3://pcaps-bucket?region=us-east-1"), - FilterV1: cloudflare.F(cloudflare.PCAPNewParamsFilterV1{ + FilterV1: cloudflare.F(pcaps.PCAPNewParamsFilterV1{ DestinationAddress: cloudflare.F("1.2.3.4"), DestinationPort: cloudflare.F(80.000000), Protocol: cloudflare.F(6.000000), @@ -67,7 +68,7 @@ func TestPCAPList(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.PCAPs.List(context.TODO(), cloudflare.PCAPListParams{ + _, err := client.PCAPs.List(context.TODO(), pcaps.PCAPListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { @@ -96,7 +97,7 @@ func TestPCAPGet(t *testing.T) { _, err := client.PCAPs.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.PCAPGetParams{ + pcaps.PCAPGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) diff --git a/queueconsumer.go b/queueconsumer.go deleted file mode 100644 index d5d4b5fe3e2..00000000000 --- a/queueconsumer.go +++ /dev/null @@ -1,720 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// QueueConsumerService 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 [NewQueueConsumerService] method -// instead. -type QueueConsumerService struct { - Options []option.RequestOption -} - -// NewQueueConsumerService 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 NewQueueConsumerService(opts ...option.RequestOption) (r *QueueConsumerService) { - r = &QueueConsumerService{} - r.Options = opts - return -} - -// Creates a new consumer for a queue. -func (r *QueueConsumerService) New(ctx context.Context, name string, params QueueConsumerNewParams, opts ...option.RequestOption) (res *QueueConsumerNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env QueueConsumerNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/queues/%s/consumers", params.AccountID, name) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates the consumer for a queue, or creates one if it does not exist. -func (r *QueueConsumerService) Update(ctx context.Context, name string, consumerName string, params QueueConsumerUpdateParams, opts ...option.RequestOption) (res *QueueConsumerUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env QueueConsumerUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/queues/%s/consumers/%s", params.AccountID, name, consumerName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes the consumer for a queue. -func (r *QueueConsumerService) Delete(ctx context.Context, name string, consumerName string, body QueueConsumerDeleteParams, opts ...option.RequestOption) (res *QueueConsumerDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env QueueConsumerDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/queues/%s/consumers/%s", body.AccountID, name, consumerName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Returns the consumers for a queue. -func (r *QueueConsumerService) Get(ctx context.Context, name string, query QueueConsumerGetParams, opts ...option.RequestOption) (res *[]QueueConsumerGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env QueueConsumerGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/queues/%s/consumers", query.AccountID, name) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type QueueConsumerNewResponse struct { - CreatedOn interface{} `json:"created_on"` - DeadLetterQueue string `json:"dead_letter_queue"` - Environment interface{} `json:"environment"` - QueueName interface{} `json:"queue_name"` - ScriptName interface{} `json:"script_name"` - Settings QueueConsumerNewResponseSettings `json:"settings"` - JSON queueConsumerNewResponseJSON `json:"-"` -} - -// queueConsumerNewResponseJSON contains the JSON metadata for the struct -// [QueueConsumerNewResponse] -type queueConsumerNewResponseJSON struct { - CreatedOn apijson.Field - DeadLetterQueue apijson.Field - Environment apijson.Field - QueueName apijson.Field - ScriptName apijson.Field - Settings apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueConsumerNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerNewResponseJSON) RawJSON() string { - return r.raw -} - -type QueueConsumerNewResponseSettings struct { - BatchSize float64 `json:"batch_size"` - MaxRetries float64 `json:"max_retries"` - MaxWaitTimeMs float64 `json:"max_wait_time_ms"` - JSON queueConsumerNewResponseSettingsJSON `json:"-"` -} - -// queueConsumerNewResponseSettingsJSON contains the JSON metadata for the struct -// [QueueConsumerNewResponseSettings] -type queueConsumerNewResponseSettingsJSON struct { - BatchSize apijson.Field - MaxRetries apijson.Field - MaxWaitTimeMs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueConsumerNewResponseSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerNewResponseSettingsJSON) RawJSON() string { - return r.raw -} - -type QueueConsumerUpdateResponse struct { - CreatedOn interface{} `json:"created_on"` - DeadLetterQueue interface{} `json:"dead_letter_queue"` - Environment interface{} `json:"environment"` - QueueName interface{} `json:"queue_name"` - ScriptName interface{} `json:"script_name"` - Settings QueueConsumerUpdateResponseSettings `json:"settings"` - JSON queueConsumerUpdateResponseJSON `json:"-"` -} - -// queueConsumerUpdateResponseJSON contains the JSON metadata for the struct -// [QueueConsumerUpdateResponse] -type queueConsumerUpdateResponseJSON struct { - CreatedOn apijson.Field - DeadLetterQueue apijson.Field - Environment apijson.Field - QueueName apijson.Field - ScriptName apijson.Field - Settings apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueConsumerUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type QueueConsumerUpdateResponseSettings struct { - BatchSize float64 `json:"batch_size"` - MaxRetries float64 `json:"max_retries"` - MaxWaitTimeMs float64 `json:"max_wait_time_ms"` - JSON queueConsumerUpdateResponseSettingsJSON `json:"-"` -} - -// queueConsumerUpdateResponseSettingsJSON contains the JSON metadata for the -// struct [QueueConsumerUpdateResponseSettings] -type queueConsumerUpdateResponseSettingsJSON struct { - BatchSize apijson.Field - MaxRetries apijson.Field - MaxWaitTimeMs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueConsumerUpdateResponseSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerUpdateResponseSettingsJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [QueueConsumerDeleteResponseUnknown], -// [QueueConsumerDeleteResponseArray] or [shared.UnionString]. -type QueueConsumerDeleteResponse interface { - ImplementsQueueConsumerDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*QueueConsumerDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(QueueConsumerDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type QueueConsumerDeleteResponseArray []interface{} - -func (r QueueConsumerDeleteResponseArray) ImplementsQueueConsumerDeleteResponse() {} - -type QueueConsumerGetResponse struct { - CreatedOn interface{} `json:"created_on"` - Environment interface{} `json:"environment"` - QueueName interface{} `json:"queue_name"` - Service interface{} `json:"service"` - Settings QueueConsumerGetResponseSettings `json:"settings"` - JSON queueConsumerGetResponseJSON `json:"-"` -} - -// queueConsumerGetResponseJSON contains the JSON metadata for the struct -// [QueueConsumerGetResponse] -type queueConsumerGetResponseJSON struct { - CreatedOn apijson.Field - Environment apijson.Field - QueueName apijson.Field - Service apijson.Field - Settings apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueConsumerGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerGetResponseJSON) RawJSON() string { - return r.raw -} - -type QueueConsumerGetResponseSettings struct { - BatchSize float64 `json:"batch_size"` - MaxRetries float64 `json:"max_retries"` - MaxWaitTimeMs float64 `json:"max_wait_time_ms"` - JSON queueConsumerGetResponseSettingsJSON `json:"-"` -} - -// queueConsumerGetResponseSettingsJSON contains the JSON metadata for the struct -// [QueueConsumerGetResponseSettings] -type queueConsumerGetResponseSettingsJSON struct { - BatchSize apijson.Field - MaxRetries apijson.Field - MaxWaitTimeMs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueConsumerGetResponseSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerGetResponseSettingsJSON) RawJSON() string { - return r.raw -} - -type QueueConsumerNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` -} - -func (r QueueConsumerNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type QueueConsumerNewResponseEnvelope struct { - Errors []QueueConsumerNewResponseEnvelopeErrors `json:"errors,required"` - Messages []QueueConsumerNewResponseEnvelopeMessages `json:"messages,required"` - Result QueueConsumerNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success QueueConsumerNewResponseEnvelopeSuccess `json:"success,required"` - ResultInfo QueueConsumerNewResponseEnvelopeResultInfo `json:"result_info"` - JSON queueConsumerNewResponseEnvelopeJSON `json:"-"` -} - -// queueConsumerNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [QueueConsumerNewResponseEnvelope] -type queueConsumerNewResponseEnvelopeJSON 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 *QueueConsumerNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type QueueConsumerNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON queueConsumerNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// queueConsumerNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [QueueConsumerNewResponseEnvelopeErrors] -type queueConsumerNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueConsumerNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type QueueConsumerNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON queueConsumerNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// queueConsumerNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [QueueConsumerNewResponseEnvelopeMessages] -type queueConsumerNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueConsumerNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type QueueConsumerNewResponseEnvelopeSuccess bool - -const ( - QueueConsumerNewResponseEnvelopeSuccessTrue QueueConsumerNewResponseEnvelopeSuccess = true -) - -type QueueConsumerNewResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON queueConsumerNewResponseEnvelopeResultInfoJSON `json:"-"` -} - -// queueConsumerNewResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [QueueConsumerNewResponseEnvelopeResultInfo] -type queueConsumerNewResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueConsumerNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerNewResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type QueueConsumerUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` -} - -func (r QueueConsumerUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type QueueConsumerUpdateResponseEnvelope struct { - Errors []QueueConsumerUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []QueueConsumerUpdateResponseEnvelopeMessages `json:"messages,required"` - Result QueueConsumerUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success QueueConsumerUpdateResponseEnvelopeSuccess `json:"success,required"` - ResultInfo QueueConsumerUpdateResponseEnvelopeResultInfo `json:"result_info"` - JSON queueConsumerUpdateResponseEnvelopeJSON `json:"-"` -} - -// queueConsumerUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [QueueConsumerUpdateResponseEnvelope] -type queueConsumerUpdateResponseEnvelopeJSON 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 *QueueConsumerUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type QueueConsumerUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON queueConsumerUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// queueConsumerUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [QueueConsumerUpdateResponseEnvelopeErrors] -type queueConsumerUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueConsumerUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type QueueConsumerUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON queueConsumerUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// queueConsumerUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [QueueConsumerUpdateResponseEnvelopeMessages] -type queueConsumerUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueConsumerUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type QueueConsumerUpdateResponseEnvelopeSuccess bool - -const ( - QueueConsumerUpdateResponseEnvelopeSuccessTrue QueueConsumerUpdateResponseEnvelopeSuccess = true -) - -type QueueConsumerUpdateResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON queueConsumerUpdateResponseEnvelopeResultInfoJSON `json:"-"` -} - -// queueConsumerUpdateResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [QueueConsumerUpdateResponseEnvelopeResultInfo] -type queueConsumerUpdateResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueConsumerUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type QueueConsumerDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type QueueConsumerDeleteResponseEnvelope struct { - Errors []QueueConsumerDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []QueueConsumerDeleteResponseEnvelopeMessages `json:"messages,required"` - Result QueueConsumerDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success QueueConsumerDeleteResponseEnvelopeSuccess `json:"success,required"` - ResultInfo QueueConsumerDeleteResponseEnvelopeResultInfo `json:"result_info"` - JSON queueConsumerDeleteResponseEnvelopeJSON `json:"-"` -} - -// queueConsumerDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [QueueConsumerDeleteResponseEnvelope] -type queueConsumerDeleteResponseEnvelopeJSON 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 *QueueConsumerDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type QueueConsumerDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON queueConsumerDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// queueConsumerDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [QueueConsumerDeleteResponseEnvelopeErrors] -type queueConsumerDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueConsumerDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type QueueConsumerDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON queueConsumerDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// queueConsumerDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [QueueConsumerDeleteResponseEnvelopeMessages] -type queueConsumerDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueConsumerDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type QueueConsumerDeleteResponseEnvelopeSuccess bool - -const ( - QueueConsumerDeleteResponseEnvelopeSuccessTrue QueueConsumerDeleteResponseEnvelopeSuccess = true -) - -type QueueConsumerDeleteResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON queueConsumerDeleteResponseEnvelopeResultInfoJSON `json:"-"` -} - -// queueConsumerDeleteResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [QueueConsumerDeleteResponseEnvelopeResultInfo] -type queueConsumerDeleteResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueConsumerDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type QueueConsumerGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type QueueConsumerGetResponseEnvelope struct { - Errors []interface{} `json:"errors,required,nullable"` - Messages []interface{} `json:"messages,required,nullable"` - Result []QueueConsumerGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success QueueConsumerGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo QueueConsumerGetResponseEnvelopeResultInfo `json:"result_info"` - JSON queueConsumerGetResponseEnvelopeJSON `json:"-"` -} - -// queueConsumerGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [QueueConsumerGetResponseEnvelope] -type queueConsumerGetResponseEnvelopeJSON 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 *QueueConsumerGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type QueueConsumerGetResponseEnvelopeSuccess bool - -const ( - QueueConsumerGetResponseEnvelopeSuccessTrue QueueConsumerGetResponseEnvelopeSuccess = true -) - -type QueueConsumerGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - TotalPages interface{} `json:"total_pages"` - JSON queueConsumerGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// queueConsumerGetResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [QueueConsumerGetResponseEnvelopeResultInfo] -type queueConsumerGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - TotalPages apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueConsumerGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueConsumerGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/queueconsumer_test.go b/queueconsumer_test.go deleted file mode 100644 index 7adbaaf489d..00000000000 --- a/queueconsumer_test.go +++ /dev/null @@ -1,154 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestQueueConsumerNew(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("user@example.com"), - ) - _, err := client.Queues.Consumers.New( - context.TODO(), - "example-queue", - cloudflare.QueueConsumerNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F[any](map[string]interface{}{ - "dead_letter_queue": "example-dlq", - "environment": "production", - "script_name": "example-consumer", - "settings": map[string]interface{}{ - "batch_size": int64(10), - "max_retries": int64(3), - "max_wait_time_ms": int64(5000), - }, - }), - }, - ) - 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 TestQueueConsumerUpdate(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("user@example.com"), - ) - _, err := client.Queues.Consumers.Update( - context.TODO(), - "example-queue", - "example-consumer", - cloudflare.QueueConsumerUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F[any](map[string]interface{}{ - "dead_letter_queue": "updated-example-dlq", - "environment": "production", - "script_name": "example-consumer", - "settings": map[string]interface{}{ - "batch_size": int64(100), - }, - }), - }, - ) - 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 TestQueueConsumerDelete(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("user@example.com"), - ) - _, err := client.Queues.Consumers.Delete( - context.TODO(), - "example-queue", - "example-consumer", - cloudflare.QueueConsumerDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestQueueConsumerGet(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("user@example.com"), - ) - _, err := client.Queues.Consumers.Get( - context.TODO(), - "example-queue", - cloudflare.QueueConsumerGetParams{ - AccountID: cloudflare.F("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/queues/aliases.go b/queues/aliases.go new file mode 100644 index 00000000000..c295225f404 --- /dev/null +++ b/queues/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package queues + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/queues/consumer.go b/queues/consumer.go new file mode 100644 index 00000000000..d5e1d274264 --- /dev/null +++ b/queues/consumer.go @@ -0,0 +1,718 @@ +// File generated from our OpenAPI spec by Stainless. + +package queues + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// ConsumerService 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 [NewConsumerService] method instead. +type ConsumerService struct { + Options []option.RequestOption +} + +// NewConsumerService 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 NewConsumerService(opts ...option.RequestOption) (r *ConsumerService) { + r = &ConsumerService{} + r.Options = opts + return +} + +// Creates a new consumer for a queue. +func (r *ConsumerService) New(ctx context.Context, name string, params ConsumerNewParams, opts ...option.RequestOption) (res *WorkersConsumerCreated, err error) { + opts = append(r.Options[:], opts...) + var env ConsumerNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/queues/%s/consumers", params.AccountID, name) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates the consumer for a queue, or creates one if it does not exist. +func (r *ConsumerService) Update(ctx context.Context, name string, consumerName string, params ConsumerUpdateParams, opts ...option.RequestOption) (res *WorkersConsumerUpdated, err error) { + opts = append(r.Options[:], opts...) + var env ConsumerUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/queues/%s/consumers/%s", params.AccountID, name, consumerName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes the consumer for a queue. +func (r *ConsumerService) Delete(ctx context.Context, name string, consumerName string, body ConsumerDeleteParams, opts ...option.RequestOption) (res *ConsumerDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env ConsumerDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/queues/%s/consumers/%s", body.AccountID, name, consumerName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Returns the consumers for a queue. +func (r *ConsumerService) Get(ctx context.Context, name string, query ConsumerGetParams, opts ...option.RequestOption) (res *[]WorkersConsumer, err error) { + opts = append(r.Options[:], opts...) + var env ConsumerGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/queues/%s/consumers", query.AccountID, name) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type WorkersConsumer struct { + CreatedOn interface{} `json:"created_on"` + Environment interface{} `json:"environment"` + QueueName interface{} `json:"queue_name"` + Service interface{} `json:"service"` + Settings WorkersConsumerSettings `json:"settings"` + JSON workersConsumerJSON `json:"-"` +} + +// workersConsumerJSON contains the JSON metadata for the struct [WorkersConsumer] +type workersConsumerJSON struct { + CreatedOn apijson.Field + Environment apijson.Field + QueueName apijson.Field + Service apijson.Field + Settings apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersConsumer) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersConsumerJSON) RawJSON() string { + return r.raw +} + +type WorkersConsumerSettings struct { + BatchSize float64 `json:"batch_size"` + MaxRetries float64 `json:"max_retries"` + MaxWaitTimeMs float64 `json:"max_wait_time_ms"` + JSON workersConsumerSettingsJSON `json:"-"` +} + +// workersConsumerSettingsJSON contains the JSON metadata for the struct +// [WorkersConsumerSettings] +type workersConsumerSettingsJSON struct { + BatchSize apijson.Field + MaxRetries apijson.Field + MaxWaitTimeMs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersConsumerSettings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersConsumerSettingsJSON) RawJSON() string { + return r.raw +} + +type WorkersConsumerCreated struct { + CreatedOn interface{} `json:"created_on"` + DeadLetterQueue string `json:"dead_letter_queue"` + Environment interface{} `json:"environment"` + QueueName interface{} `json:"queue_name"` + ScriptName interface{} `json:"script_name"` + Settings WorkersConsumerCreatedSettings `json:"settings"` + JSON workersConsumerCreatedJSON `json:"-"` +} + +// workersConsumerCreatedJSON contains the JSON metadata for the struct +// [WorkersConsumerCreated] +type workersConsumerCreatedJSON struct { + CreatedOn apijson.Field + DeadLetterQueue apijson.Field + Environment apijson.Field + QueueName apijson.Field + ScriptName apijson.Field + Settings apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersConsumerCreated) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersConsumerCreatedJSON) RawJSON() string { + return r.raw +} + +type WorkersConsumerCreatedSettings struct { + BatchSize float64 `json:"batch_size"` + MaxRetries float64 `json:"max_retries"` + MaxWaitTimeMs float64 `json:"max_wait_time_ms"` + JSON workersConsumerCreatedSettingsJSON `json:"-"` +} + +// workersConsumerCreatedSettingsJSON contains the JSON metadata for the struct +// [WorkersConsumerCreatedSettings] +type workersConsumerCreatedSettingsJSON struct { + BatchSize apijson.Field + MaxRetries apijson.Field + MaxWaitTimeMs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersConsumerCreatedSettings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersConsumerCreatedSettingsJSON) RawJSON() string { + return r.raw +} + +type WorkersConsumerUpdated struct { + CreatedOn interface{} `json:"created_on"` + DeadLetterQueue interface{} `json:"dead_letter_queue"` + Environment interface{} `json:"environment"` + QueueName interface{} `json:"queue_name"` + ScriptName interface{} `json:"script_name"` + Settings WorkersConsumerUpdatedSettings `json:"settings"` + JSON workersConsumerUpdatedJSON `json:"-"` +} + +// workersConsumerUpdatedJSON contains the JSON metadata for the struct +// [WorkersConsumerUpdated] +type workersConsumerUpdatedJSON struct { + CreatedOn apijson.Field + DeadLetterQueue apijson.Field + Environment apijson.Field + QueueName apijson.Field + ScriptName apijson.Field + Settings apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersConsumerUpdated) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersConsumerUpdatedJSON) RawJSON() string { + return r.raw +} + +type WorkersConsumerUpdatedSettings struct { + BatchSize float64 `json:"batch_size"` + MaxRetries float64 `json:"max_retries"` + MaxWaitTimeMs float64 `json:"max_wait_time_ms"` + JSON workersConsumerUpdatedSettingsJSON `json:"-"` +} + +// workersConsumerUpdatedSettingsJSON contains the JSON metadata for the struct +// [WorkersConsumerUpdatedSettings] +type workersConsumerUpdatedSettingsJSON struct { + BatchSize apijson.Field + MaxRetries apijson.Field + MaxWaitTimeMs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersConsumerUpdatedSettings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersConsumerUpdatedSettingsJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [queues.ConsumerDeleteResponseUnknown], +// [queues.ConsumerDeleteResponseArray] or [shared.UnionString]. +type ConsumerDeleteResponse interface { + ImplementsQueuesConsumerDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ConsumerDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ConsumerDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type ConsumerDeleteResponseArray []interface{} + +func (r ConsumerDeleteResponseArray) ImplementsQueuesConsumerDeleteResponse() {} + +type ConsumerNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Body param.Field[interface{}] `json:"body,required"` +} + +func (r ConsumerNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type ConsumerNewResponseEnvelope struct { + Errors []ConsumerNewResponseEnvelopeErrors `json:"errors,required"` + Messages []ConsumerNewResponseEnvelopeMessages `json:"messages,required"` + Result WorkersConsumerCreated `json:"result,required,nullable"` + // Whether the API call was successful + Success ConsumerNewResponseEnvelopeSuccess `json:"success,required"` + ResultInfo ConsumerNewResponseEnvelopeResultInfo `json:"result_info"` + JSON consumerNewResponseEnvelopeJSON `json:"-"` +} + +// consumerNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [ConsumerNewResponseEnvelope] +type consumerNewResponseEnvelopeJSON 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 *ConsumerNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r consumerNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConsumerNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON consumerNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// consumerNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ConsumerNewResponseEnvelopeErrors] +type consumerNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConsumerNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r consumerNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ConsumerNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON consumerNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// consumerNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ConsumerNewResponseEnvelopeMessages] +type consumerNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConsumerNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r consumerNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConsumerNewResponseEnvelopeSuccess bool + +const ( + ConsumerNewResponseEnvelopeSuccessTrue ConsumerNewResponseEnvelopeSuccess = true +) + +type ConsumerNewResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON consumerNewResponseEnvelopeResultInfoJSON `json:"-"` +} + +// consumerNewResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [ConsumerNewResponseEnvelopeResultInfo] +type consumerNewResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConsumerNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r consumerNewResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type ConsumerUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Body param.Field[interface{}] `json:"body,required"` +} + +func (r ConsumerUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type ConsumerUpdateResponseEnvelope struct { + Errors []ConsumerUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []ConsumerUpdateResponseEnvelopeMessages `json:"messages,required"` + Result WorkersConsumerUpdated `json:"result,required,nullable"` + // Whether the API call was successful + Success ConsumerUpdateResponseEnvelopeSuccess `json:"success,required"` + ResultInfo ConsumerUpdateResponseEnvelopeResultInfo `json:"result_info"` + JSON consumerUpdateResponseEnvelopeJSON `json:"-"` +} + +// consumerUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [ConsumerUpdateResponseEnvelope] +type consumerUpdateResponseEnvelopeJSON 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 *ConsumerUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r consumerUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConsumerUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON consumerUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// consumerUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ConsumerUpdateResponseEnvelopeErrors] +type consumerUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConsumerUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r consumerUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ConsumerUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON consumerUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// consumerUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ConsumerUpdateResponseEnvelopeMessages] +type consumerUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConsumerUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r consumerUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConsumerUpdateResponseEnvelopeSuccess bool + +const ( + ConsumerUpdateResponseEnvelopeSuccessTrue ConsumerUpdateResponseEnvelopeSuccess = true +) + +type ConsumerUpdateResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON consumerUpdateResponseEnvelopeResultInfoJSON `json:"-"` +} + +// consumerUpdateResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [ConsumerUpdateResponseEnvelopeResultInfo] +type consumerUpdateResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConsumerUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r consumerUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type ConsumerDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ConsumerDeleteResponseEnvelope struct { + Errors []ConsumerDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []ConsumerDeleteResponseEnvelopeMessages `json:"messages,required"` + Result ConsumerDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ConsumerDeleteResponseEnvelopeSuccess `json:"success,required"` + ResultInfo ConsumerDeleteResponseEnvelopeResultInfo `json:"result_info"` + JSON consumerDeleteResponseEnvelopeJSON `json:"-"` +} + +// consumerDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [ConsumerDeleteResponseEnvelope] +type consumerDeleteResponseEnvelopeJSON 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 *ConsumerDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r consumerDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConsumerDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON consumerDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// consumerDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ConsumerDeleteResponseEnvelopeErrors] +type consumerDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConsumerDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r consumerDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ConsumerDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON consumerDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// consumerDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ConsumerDeleteResponseEnvelopeMessages] +type consumerDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConsumerDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r consumerDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConsumerDeleteResponseEnvelopeSuccess bool + +const ( + ConsumerDeleteResponseEnvelopeSuccessTrue ConsumerDeleteResponseEnvelopeSuccess = true +) + +type ConsumerDeleteResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON consumerDeleteResponseEnvelopeResultInfoJSON `json:"-"` +} + +// consumerDeleteResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [ConsumerDeleteResponseEnvelopeResultInfo] +type consumerDeleteResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConsumerDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r consumerDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type ConsumerGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ConsumerGetResponseEnvelope struct { + Errors []interface{} `json:"errors,required,nullable"` + Messages []interface{} `json:"messages,required,nullable"` + Result []WorkersConsumer `json:"result,required,nullable"` + // Whether the API call was successful + Success ConsumerGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo ConsumerGetResponseEnvelopeResultInfo `json:"result_info"` + JSON consumerGetResponseEnvelopeJSON `json:"-"` +} + +// consumerGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [ConsumerGetResponseEnvelope] +type consumerGetResponseEnvelopeJSON 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 *ConsumerGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r consumerGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConsumerGetResponseEnvelopeSuccess bool + +const ( + ConsumerGetResponseEnvelopeSuccessTrue ConsumerGetResponseEnvelopeSuccess = true +) + +type ConsumerGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + TotalPages interface{} `json:"total_pages"` + JSON consumerGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// consumerGetResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [ConsumerGetResponseEnvelopeResultInfo] +type consumerGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + TotalPages apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConsumerGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r consumerGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/queues/consumer_test.go b/queues/consumer_test.go new file mode 100644 index 00000000000..ca03c0a7221 --- /dev/null +++ b/queues/consumer_test.go @@ -0,0 +1,155 @@ +// File generated from our OpenAPI spec by Stainless. + +package queues_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/queues" +) + +func TestConsumerNew(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("user@example.com"), + ) + _, err := client.Queues.Consumers.New( + context.TODO(), + "example-queue", + queues.ConsumerNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: cloudflare.F[any](map[string]interface{}{ + "dead_letter_queue": "example-dlq", + "environment": "production", + "script_name": "example-consumer", + "settings": map[string]interface{}{ + "batch_size": int64(10), + "max_retries": int64(3), + "max_wait_time_ms": int64(5000), + }, + }), + }, + ) + 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 TestConsumerUpdate(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("user@example.com"), + ) + _, err := client.Queues.Consumers.Update( + context.TODO(), + "example-queue", + "example-consumer", + queues.ConsumerUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: cloudflare.F[any](map[string]interface{}{ + "dead_letter_queue": "updated-example-dlq", + "environment": "production", + "script_name": "example-consumer", + "settings": map[string]interface{}{ + "batch_size": int64(100), + }, + }), + }, + ) + 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 TestConsumerDelete(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("user@example.com"), + ) + _, err := client.Queues.Consumers.Delete( + context.TODO(), + "example-queue", + "example-consumer", + queues.ConsumerDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestConsumerGet(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("user@example.com"), + ) + _, err := client.Queues.Consumers.Get( + context.TODO(), + "example-queue", + queues.ConsumerGetParams{ + AccountID: cloudflare.F("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/queue.go b/queues/queue.go similarity index 85% rename from queue.go rename to queues/queue.go index 91a1e5b4fc6..8d4bca98c23 100644 --- a/queue.go +++ b/queues/queue.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package queues import ( "context" @@ -22,7 +22,7 @@ import ( // directly, and instead use the [NewQueueService] method instead. type QueueService struct { Options []option.RequestOption - Consumers *QueueConsumerService + Consumers *ConsumerService } // NewQueueService generates a new service that applies the given options to each @@ -31,12 +31,12 @@ type QueueService struct { func NewQueueService(opts ...option.RequestOption) (r *QueueService) { r = &QueueService{} r.Options = opts - r.Consumers = NewQueueConsumerService(opts...) + r.Consumers = NewConsumerService(opts...) return } // Creates a new queue. -func (r *QueueService) New(ctx context.Context, params QueueNewParams, opts ...option.RequestOption) (res *QueueNewResponse, err error) { +func (r *QueueService) New(ctx context.Context, params QueueNewParams, opts ...option.RequestOption) (res *WorkersQueueCreated, err error) { opts = append(r.Options[:], opts...) var env QueueNewResponseEnvelope path := fmt.Sprintf("accounts/%s/workers/queues", params.AccountID) @@ -49,7 +49,7 @@ func (r *QueueService) New(ctx context.Context, params QueueNewParams, opts ...o } // Updates a queue. -func (r *QueueService) Update(ctx context.Context, name string, params QueueUpdateParams, opts ...option.RequestOption) (res *QueueUpdateResponse, err error) { +func (r *QueueService) Update(ctx context.Context, name string, params QueueUpdateParams, opts ...option.RequestOption) (res *WorkersQueueUpdated, err error) { opts = append(r.Options[:], opts...) var env QueueUpdateResponseEnvelope path := fmt.Sprintf("accounts/%s/workers/queues/%s", params.AccountID, name) @@ -62,7 +62,7 @@ func (r *QueueService) Update(ctx context.Context, name string, params QueueUpda } // Returns the queues owned by an account. -func (r *QueueService) List(ctx context.Context, query QueueListParams, opts ...option.RequestOption) (res *[]QueueListResponse, err error) { +func (r *QueueService) List(ctx context.Context, query QueueListParams, opts ...option.RequestOption) (res *[]WorkersQueue, err error) { opts = append(r.Options[:], opts...) var env QueueListResponseEnvelope path := fmt.Sprintf("accounts/%s/workers/queues", query.AccountID) @@ -88,7 +88,7 @@ func (r *QueueService) Delete(ctx context.Context, name string, body QueueDelete } // Get information about a specific queue. -func (r *QueueService) Get(ctx context.Context, name string, query QueueGetParams, opts ...option.RequestOption) (res *QueueGetResponse, err error) { +func (r *QueueService) Get(ctx context.Context, name string, query QueueGetParams, opts ...option.RequestOption) (res *WorkersQueue, err error) { opts = append(r.Options[:], opts...) var env QueueGetResponseEnvelope path := fmt.Sprintf("accounts/%s/workers/queues/%s", query.AccountID, name) @@ -100,44 +100,51 @@ func (r *QueueService) Get(ctx context.Context, name string, query QueueGetParam return } -type QueueNewResponse struct { - CreatedOn interface{} `json:"created_on"` - ModifiedOn interface{} `json:"modified_on"` - QueueID interface{} `json:"queue_id"` - QueueName string `json:"queue_name"` - JSON queueNewResponseJSON `json:"-"` +type WorkersQueue struct { + Consumers interface{} `json:"consumers"` + ConsumersTotalCount interface{} `json:"consumers_total_count"` + CreatedOn interface{} `json:"created_on"` + ModifiedOn interface{} `json:"modified_on"` + Producers interface{} `json:"producers"` + ProducersTotalCount interface{} `json:"producers_total_count"` + QueueID interface{} `json:"queue_id"` + QueueName string `json:"queue_name"` + JSON workersQueueJSON `json:"-"` } -// queueNewResponseJSON contains the JSON metadata for the struct -// [QueueNewResponse] -type queueNewResponseJSON struct { - CreatedOn apijson.Field - ModifiedOn apijson.Field - QueueID apijson.Field - QueueName apijson.Field - raw string - ExtraFields map[string]apijson.Field +// workersQueueJSON contains the JSON metadata for the struct [WorkersQueue] +type workersQueueJSON struct { + Consumers apijson.Field + ConsumersTotalCount apijson.Field + CreatedOn apijson.Field + ModifiedOn apijson.Field + Producers apijson.Field + ProducersTotalCount apijson.Field + QueueID apijson.Field + QueueName apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *QueueNewResponse) UnmarshalJSON(data []byte) (err error) { +func (r *WorkersQueue) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r queueNewResponseJSON) RawJSON() string { +func (r workersQueueJSON) RawJSON() string { return r.raw } -type QueueUpdateResponse struct { +type WorkersQueueCreated struct { CreatedOn interface{} `json:"created_on"` ModifiedOn interface{} `json:"modified_on"` QueueID interface{} `json:"queue_id"` QueueName string `json:"queue_name"` - JSON queueUpdateResponseJSON `json:"-"` + JSON workersQueueCreatedJSON `json:"-"` } -// queueUpdateResponseJSON contains the JSON metadata for the struct -// [QueueUpdateResponse] -type queueUpdateResponseJSON struct { +// workersQueueCreatedJSON contains the JSON metadata for the struct +// [WorkersQueueCreated] +type workersQueueCreatedJSON struct { CreatedOn apijson.Field ModifiedOn apijson.Field QueueID apijson.Field @@ -146,53 +153,45 @@ type queueUpdateResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *QueueUpdateResponse) UnmarshalJSON(data []byte) (err error) { +func (r *WorkersQueueCreated) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r queueUpdateResponseJSON) RawJSON() string { +func (r workersQueueCreatedJSON) RawJSON() string { return r.raw } -type QueueListResponse struct { - Consumers interface{} `json:"consumers"` - ConsumersTotalCount interface{} `json:"consumers_total_count"` - CreatedOn interface{} `json:"created_on"` - ModifiedOn interface{} `json:"modified_on"` - Producers interface{} `json:"producers"` - ProducersTotalCount interface{} `json:"producers_total_count"` - QueueID interface{} `json:"queue_id"` - QueueName string `json:"queue_name"` - JSON queueListResponseJSON `json:"-"` +type WorkersQueueUpdated struct { + CreatedOn interface{} `json:"created_on"` + ModifiedOn interface{} `json:"modified_on"` + QueueID interface{} `json:"queue_id"` + QueueName string `json:"queue_name"` + JSON workersQueueUpdatedJSON `json:"-"` } -// queueListResponseJSON contains the JSON metadata for the struct -// [QueueListResponse] -type queueListResponseJSON struct { - Consumers apijson.Field - ConsumersTotalCount apijson.Field - CreatedOn apijson.Field - ModifiedOn apijson.Field - Producers apijson.Field - ProducersTotalCount apijson.Field - QueueID apijson.Field - QueueName apijson.Field - raw string - ExtraFields map[string]apijson.Field +// workersQueueUpdatedJSON contains the JSON metadata for the struct +// [WorkersQueueUpdated] +type workersQueueUpdatedJSON struct { + CreatedOn apijson.Field + ModifiedOn apijson.Field + QueueID apijson.Field + QueueName apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *QueueListResponse) UnmarshalJSON(data []byte) (err error) { +func (r *WorkersQueueUpdated) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r queueListResponseJSON) RawJSON() string { +func (r workersQueueUpdatedJSON) RawJSON() string { return r.raw } -// Union satisfied by [QueueDeleteResponseUnknown], [QueueDeleteResponseArray] or -// [shared.UnionString]. +// Union satisfied by [queues.QueueDeleteResponseUnknown], +// [queues.QueueDeleteResponseArray] or [shared.UnionString]. type QueueDeleteResponse interface { - ImplementsQueueDeleteResponse() + ImplementsQueuesQueueDeleteResponse() } func init() { @@ -212,42 +211,7 @@ func init() { type QueueDeleteResponseArray []interface{} -func (r QueueDeleteResponseArray) ImplementsQueueDeleteResponse() {} - -type QueueGetResponse struct { - Consumers interface{} `json:"consumers"` - ConsumersTotalCount interface{} `json:"consumers_total_count"` - CreatedOn interface{} `json:"created_on"` - ModifiedOn interface{} `json:"modified_on"` - Producers interface{} `json:"producers"` - ProducersTotalCount interface{} `json:"producers_total_count"` - QueueID interface{} `json:"queue_id"` - QueueName string `json:"queue_name"` - JSON queueGetResponseJSON `json:"-"` -} - -// queueGetResponseJSON contains the JSON metadata for the struct -// [QueueGetResponse] -type queueGetResponseJSON struct { - Consumers apijson.Field - ConsumersTotalCount apijson.Field - CreatedOn apijson.Field - ModifiedOn apijson.Field - Producers apijson.Field - ProducersTotalCount apijson.Field - QueueID apijson.Field - QueueName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *QueueGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r queueGetResponseJSON) RawJSON() string { - return r.raw -} +func (r QueueDeleteResponseArray) ImplementsQueuesQueueDeleteResponse() {} type QueueNewParams struct { // Identifier @@ -262,7 +226,7 @@ func (r QueueNewParams) MarshalJSON() (data []byte, err error) { type QueueNewResponseEnvelope struct { Errors []QueueNewResponseEnvelopeErrors `json:"errors,required"` Messages []QueueNewResponseEnvelopeMessages `json:"messages,required"` - Result QueueNewResponse `json:"result,required,nullable"` + Result WorkersQueueCreated `json:"result,required,nullable"` // Whether the API call was successful Success QueueNewResponseEnvelopeSuccess `json:"success,required"` ResultInfo QueueNewResponseEnvelopeResultInfo `json:"result_info"` @@ -386,7 +350,7 @@ func (r QueueUpdateParams) MarshalJSON() (data []byte, err error) { type QueueUpdateResponseEnvelope struct { Errors []QueueUpdateResponseEnvelopeErrors `json:"errors,required"` Messages []QueueUpdateResponseEnvelopeMessages `json:"messages,required"` - Result QueueUpdateResponse `json:"result,required,nullable"` + Result WorkersQueueUpdated `json:"result,required,nullable"` // Whether the API call was successful Success QueueUpdateResponseEnvelopeSuccess `json:"success,required"` ResultInfo QueueUpdateResponseEnvelopeResultInfo `json:"result_info"` @@ -503,9 +467,9 @@ type QueueListParams struct { } type QueueListResponseEnvelope struct { - Errors []interface{} `json:"errors,required,nullable"` - Messages []interface{} `json:"messages,required,nullable"` - Result []QueueListResponse `json:"result,required,nullable"` + Errors []interface{} `json:"errors,required,nullable"` + Messages []interface{} `json:"messages,required,nullable"` + Result []WorkersQueue `json:"result,required,nullable"` // Whether the API call was successful Success QueueListResponseEnvelopeSuccess `json:"success,required"` ResultInfo QueueListResponseEnvelopeResultInfo `json:"result_info"` @@ -699,7 +663,7 @@ type QueueGetParams struct { type QueueGetResponseEnvelope struct { Errors []QueueGetResponseEnvelopeErrors `json:"errors,required"` Messages []QueueGetResponseEnvelopeMessages `json:"messages,required"` - Result QueueGetResponse `json:"result,required,nullable"` + Result WorkersQueue `json:"result,required,nullable"` // Whether the API call was successful Success QueueGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo QueueGetResponseEnvelopeResultInfo `json:"result_info"` diff --git a/queue_test.go b/queues/queue_test.go similarity index 93% rename from queue_test.go rename to queues/queue_test.go index 3f65119f6e7..267b7b8c2fe 100644 --- a/queue_test.go +++ b/queues/queue_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package queues_test import ( "context" @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/queues" ) func TestQueueNew(t *testing.T) { @@ -27,7 +28,7 @@ func TestQueueNew(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Queues.New(context.TODO(), cloudflare.QueueNewParams{ + _, err := client.Queues.New(context.TODO(), queues.QueueNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: cloudflare.F[any](map[string]interface{}{ "queue_name": "example-queue", @@ -59,7 +60,7 @@ func TestQueueUpdate(t *testing.T) { _, err := client.Queues.Update( context.TODO(), "example-queue", - cloudflare.QueueUpdateParams{ + queues.QueueUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Body: cloudflare.F[any](map[string]interface{}{ "queue_name": "renamed-example-queue", @@ -89,7 +90,7 @@ func TestQueueList(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Queues.List(context.TODO(), cloudflare.QueueListParams{ + _, err := client.Queues.List(context.TODO(), queues.QueueListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { @@ -118,7 +119,7 @@ func TestQueueDelete(t *testing.T) { _, err := client.Queues.Delete( context.TODO(), "example-queue", - cloudflare.QueueDeleteParams{ + queues.QueueDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) @@ -148,7 +149,7 @@ func TestQueueGet(t *testing.T) { _, err := client.Queues.Get( context.TODO(), "example-queue", - cloudflare.QueueGetParams{ + queues.QueueGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) diff --git a/r2/aliases.go b/r2/aliases.go new file mode 100644 index 00000000000..8f76200b79c --- /dev/null +++ b/r2/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package r2 + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/r2/bucket.go b/r2/bucket.go new file mode 100644 index 00000000000..367123a1d74 --- /dev/null +++ b/r2/bucket.go @@ -0,0 +1,463 @@ +// File generated from our OpenAPI spec by Stainless. + +package r2 + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// BucketService 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 [NewBucketService] method instead. +type BucketService struct { + Options []option.RequestOption +} + +// NewBucketService 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 NewBucketService(opts ...option.RequestOption) (r *BucketService) { + r = &BucketService{} + r.Options = opts + return +} + +// Creates a new R2 bucket. +func (r *BucketService) New(ctx context.Context, params BucketNewParams, opts ...option.RequestOption) (res *R2Bucket, err error) { + opts = append(r.Options[:], opts...) + var env BucketNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/r2/buckets", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists all R2 buckets on your account +func (r *BucketService) List(ctx context.Context, params BucketListParams, opts ...option.RequestOption) (res *[]R2Bucket, err error) { + opts = append(r.Options[:], opts...) + var env BucketListResponseEnvelope + path := fmt.Sprintf("accounts/%s/r2/buckets", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes an existing R2 bucket. +func (r *BucketService) Delete(ctx context.Context, bucketName string, body BucketDeleteParams, opts ...option.RequestOption) (res *BucketDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env BucketDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/r2/buckets/%s", body.AccountID, bucketName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets metadata for an existing R2 bucket. +func (r *BucketService) Get(ctx context.Context, bucketName string, query BucketGetParams, opts ...option.RequestOption) (res *R2Bucket, err error) { + opts = append(r.Options[:], opts...) + var env BucketGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/r2/buckets/%s", query.AccountID, bucketName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// A single R2 bucket +type R2Bucket struct { + // Creation timestamp + CreationDate string `json:"creation_date"` + // Location of the bucket + Location R2BucketLocation `json:"location"` + // Name of the bucket + Name string `json:"name"` + JSON r2BucketJSON `json:"-"` +} + +// r2BucketJSON contains the JSON metadata for the struct [R2Bucket] +type r2BucketJSON struct { + CreationDate apijson.Field + Location apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *R2Bucket) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r r2BucketJSON) RawJSON() string { + return r.raw +} + +// Location of the bucket +type R2BucketLocation string + +const ( + R2BucketLocationApac R2BucketLocation = "apac" + R2BucketLocationEeur R2BucketLocation = "eeur" + R2BucketLocationEnam R2BucketLocation = "enam" + R2BucketLocationWeur R2BucketLocation = "weur" + R2BucketLocationWnam R2BucketLocation = "wnam" +) + +type BucketDeleteResponse = interface{} + +type BucketNewParams struct { + // Account ID + AccountID param.Field[string] `path:"account_id,required"` + // Name of the bucket + Name param.Field[string] `json:"name,required"` + // Location of the bucket + LocationHint param.Field[BucketNewParamsLocationHint] `json:"locationHint"` +} + +func (r BucketNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Location of the bucket +type BucketNewParamsLocationHint string + +const ( + BucketNewParamsLocationHintApac BucketNewParamsLocationHint = "apac" + BucketNewParamsLocationHintEeur BucketNewParamsLocationHint = "eeur" + BucketNewParamsLocationHintEnam BucketNewParamsLocationHint = "enam" + BucketNewParamsLocationHintWeur BucketNewParamsLocationHint = "weur" + BucketNewParamsLocationHintWnam BucketNewParamsLocationHint = "wnam" +) + +type BucketNewResponseEnvelope struct { + Errors []BucketNewResponseEnvelopeErrors `json:"errors,required"` + Messages []string `json:"messages,required"` + // A single R2 bucket + Result R2Bucket `json:"result,required"` + // Whether the API call was successful + Success BucketNewResponseEnvelopeSuccess `json:"success,required"` + JSON bucketNewResponseEnvelopeJSON `json:"-"` +} + +// bucketNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [BucketNewResponseEnvelope] +type bucketNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BucketNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bucketNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type BucketNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON bucketNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// bucketNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [BucketNewResponseEnvelopeErrors] +type bucketNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BucketNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bucketNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type BucketNewResponseEnvelopeSuccess bool + +const ( + BucketNewResponseEnvelopeSuccessTrue BucketNewResponseEnvelopeSuccess = true +) + +type BucketListParams struct { + // Account ID + AccountID param.Field[string] `path:"account_id,required"` + // Pagination cursor received during the last List Buckets call. R2 buckets are + // paginated using cursors instead of page numbers. + Cursor param.Field[string] `query:"cursor"` + // Direction to order buckets + Direction param.Field[BucketListParamsDirection] `query:"direction"` + // Bucket names to filter by. Only buckets with this phrase in their name will be + // returned. + NameContains param.Field[string] `query:"name_contains"` + // Field to order buckets by + Order param.Field[BucketListParamsOrder] `query:"order"` + // Maximum number of buckets to return in a single call + PerPage param.Field[float64] `query:"per_page"` + // Bucket name to start searching after. Buckets are ordered lexicographically. + StartAfter param.Field[string] `query:"start_after"` +} + +// URLQuery serializes [BucketListParams]'s query parameters as `url.Values`. +func (r BucketListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Direction to order buckets +type BucketListParamsDirection string + +const ( + BucketListParamsDirectionAsc BucketListParamsDirection = "asc" + BucketListParamsDirectionDesc BucketListParamsDirection = "desc" +) + +// Field to order buckets by +type BucketListParamsOrder string + +const ( + BucketListParamsOrderName BucketListParamsOrder = "name" +) + +type BucketListResponseEnvelope struct { + Errors []BucketListResponseEnvelopeErrors `json:"errors,required"` + Messages []string `json:"messages,required"` + Result []R2Bucket `json:"result,required"` + // Whether the API call was successful + Success BucketListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo BucketListResponseEnvelopeResultInfo `json:"result_info"` + JSON bucketListResponseEnvelopeJSON `json:"-"` +} + +// bucketListResponseEnvelopeJSON contains the JSON metadata for the struct +// [BucketListResponseEnvelope] +type bucketListResponseEnvelopeJSON 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 *BucketListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bucketListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type BucketListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON bucketListResponseEnvelopeErrorsJSON `json:"-"` +} + +// bucketListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [BucketListResponseEnvelopeErrors] +type bucketListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BucketListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bucketListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type BucketListResponseEnvelopeSuccess bool + +const ( + BucketListResponseEnvelopeSuccessTrue BucketListResponseEnvelopeSuccess = true +) + +type BucketListResponseEnvelopeResultInfo struct { + // A continuation token that should be used to fetch the next page of results + Cursor string `json:"cursor"` + // Maximum number of results on this page + PerPage float64 `json:"per_page"` + JSON bucketListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// bucketListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [BucketListResponseEnvelopeResultInfo] +type bucketListResponseEnvelopeResultInfoJSON struct { + Cursor apijson.Field + PerPage apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BucketListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bucketListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type BucketDeleteParams struct { + // Account ID + AccountID param.Field[string] `path:"account_id,required"` +} + +type BucketDeleteResponseEnvelope struct { + Errors []BucketDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []string `json:"messages,required"` + Result BucketDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success BucketDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON bucketDeleteResponseEnvelopeJSON `json:"-"` +} + +// bucketDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [BucketDeleteResponseEnvelope] +type bucketDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BucketDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bucketDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type BucketDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON bucketDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// bucketDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [BucketDeleteResponseEnvelopeErrors] +type bucketDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BucketDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bucketDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type BucketDeleteResponseEnvelopeSuccess bool + +const ( + BucketDeleteResponseEnvelopeSuccessTrue BucketDeleteResponseEnvelopeSuccess = true +) + +type BucketGetParams struct { + // Account ID + AccountID param.Field[string] `path:"account_id,required"` +} + +type BucketGetResponseEnvelope struct { + Errors []BucketGetResponseEnvelopeErrors `json:"errors,required"` + Messages []string `json:"messages,required"` + // A single R2 bucket + Result R2Bucket `json:"result,required"` + // Whether the API call was successful + Success BucketGetResponseEnvelopeSuccess `json:"success,required"` + JSON bucketGetResponseEnvelopeJSON `json:"-"` +} + +// bucketGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [BucketGetResponseEnvelope] +type bucketGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BucketGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bucketGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type BucketGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON bucketGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// bucketGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [BucketGetResponseEnvelopeErrors] +type bucketGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BucketGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bucketGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type BucketGetResponseEnvelopeSuccess bool + +const ( + BucketGetResponseEnvelopeSuccessTrue BucketGetResponseEnvelopeSuccess = true +) diff --git a/r2/bucket_test.go b/r2/bucket_test.go new file mode 100644 index 00000000000..c063981cbf5 --- /dev/null +++ b/r2/bucket_test.go @@ -0,0 +1,135 @@ +// File generated from our OpenAPI spec by Stainless. + +package r2_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/r2" +) + +func TestBucketNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.R2.Buckets.New(context.TODO(), r2.BucketNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Name: cloudflare.F("example-bucket"), + LocationHint: cloudflare.F(r2.BucketNewParamsLocationHintApac), + }) + 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 TestBucketListWithOptionalParams(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("user@example.com"), + ) + _, err := client.R2.Buckets.List(context.TODO(), r2.BucketListParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Cursor: cloudflare.F("string"), + Direction: cloudflare.F(r2.BucketListParamsDirectionDesc), + NameContains: cloudflare.F("my-bucket"), + Order: cloudflare.F(r2.BucketListParamsOrderName), + PerPage: cloudflare.F(1.000000), + StartAfter: cloudflare.F("my-bucket"), + }) + 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 TestBucketDelete(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("user@example.com"), + ) + _, err := client.R2.Buckets.Delete( + context.TODO(), + "example-bucket", + r2.BucketDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestBucketGet(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("user@example.com"), + ) + _, err := client.R2.Buckets.Get( + context.TODO(), + "example-bucket", + r2.BucketGetParams{ + AccountID: cloudflare.F("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/r2.go b/r2/r2.go similarity index 84% rename from r2.go rename to r2/r2.go index d446ca6e8de..133fec14f7c 100644 --- a/r2.go +++ b/r2/r2.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package r2 import ( "github.com/cloudflare/cloudflare-go/option" @@ -12,8 +12,8 @@ import ( // directly, and instead use the [NewR2Service] method instead. type R2Service struct { Options []option.RequestOption - Buckets *R2BucketService - Sippy *R2SippyService + Buckets *BucketService + Sippy *SippyService } // NewR2Service generates a new service that applies the given options to each @@ -22,7 +22,7 @@ type R2Service struct { func NewR2Service(opts ...option.RequestOption) (r *R2Service) { r = &R2Service{} r.Options = opts - r.Buckets = NewR2BucketService(opts...) - r.Sippy = NewR2SippyService(opts...) + r.Buckets = NewBucketService(opts...) + r.Sippy = NewSippyService(opts...) return } diff --git a/r2/sippy.go b/r2/sippy.go new file mode 100644 index 00000000000..9f1a0577133 --- /dev/null +++ b/r2/sippy.go @@ -0,0 +1,443 @@ +// File generated from our OpenAPI spec by Stainless. + +package r2 + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SippyService 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 [NewSippyService] method instead. +type SippyService struct { + Options []option.RequestOption +} + +// NewSippyService 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 NewSippyService(opts ...option.RequestOption) (r *SippyService) { + r = &SippyService{} + r.Options = opts + return +} + +// Sets configuration for Sippy for an existing R2 bucket. +func (r *SippyService) Update(ctx context.Context, bucketName string, params SippyUpdateParams, opts ...option.RequestOption) (res *R2Sippy, err error) { + opts = append(r.Options[:], opts...) + var env SippyUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/r2/buckets/%s/sippy", params.AccountID, bucketName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Disables Sippy on this bucket +func (r *SippyService) Delete(ctx context.Context, bucketName string, body SippyDeleteParams, opts ...option.RequestOption) (res *SippyDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env SippyDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/r2/buckets/%s/sippy", body.AccountID, bucketName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets configuration for Sippy for an existing R2 bucket. +func (r *SippyService) Get(ctx context.Context, bucketName string, query SippyGetParams, opts ...option.RequestOption) (res *R2Sippy, err error) { + opts = append(r.Options[:], opts...) + var env SippyGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/r2/buckets/%s/sippy", query.AccountID, bucketName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type R2Sippy struct { + // Details about the configured destination bucket + Destination R2SippyDestination `json:"destination"` + // State of Sippy for this bucket + Enabled bool `json:"enabled"` + // Details about the configured source bucket + Source R2SippySource `json:"source"` + JSON r2SippyJSON `json:"-"` +} + +// r2SippyJSON contains the JSON metadata for the struct [R2Sippy] +type r2SippyJSON struct { + Destination apijson.Field + Enabled apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *R2Sippy) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r r2SippyJSON) RawJSON() string { + return r.raw +} + +// Details about the configured destination bucket +type R2SippyDestination struct { + // ID of the Cloudflare API token used when writing objects to this bucket + AccessKeyID string `json:"accessKeyId"` + Account string `json:"account"` + // Name of the bucket on the provider + Bucket string `json:"bucket"` + Provider R2SippyDestinationProvider `json:"provider"` + JSON r2SippyDestinationJSON `json:"-"` +} + +// r2SippyDestinationJSON contains the JSON metadata for the struct +// [R2SippyDestination] +type r2SippyDestinationJSON struct { + AccessKeyID apijson.Field + Account apijson.Field + Bucket apijson.Field + Provider apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *R2SippyDestination) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r r2SippyDestinationJSON) RawJSON() string { + return r.raw +} + +type R2SippyDestinationProvider string + +const ( + R2SippyDestinationProviderR2 R2SippyDestinationProvider = "r2" +) + +// Details about the configured source bucket +type R2SippySource struct { + // Name of the bucket on the provider + Bucket string `json:"bucket"` + Provider R2SippySourceProvider `json:"provider"` + // Region where the bucket resides (AWS only) + Region string `json:"region,nullable"` + JSON r2SippySourceJSON `json:"-"` +} + +// r2SippySourceJSON contains the JSON metadata for the struct [R2SippySource] +type r2SippySourceJSON struct { + Bucket apijson.Field + Provider apijson.Field + Region apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *R2SippySource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r r2SippySourceJSON) RawJSON() string { + return r.raw +} + +type R2SippySourceProvider string + +const ( + R2SippySourceProviderAws R2SippySourceProvider = "aws" + R2SippySourceProviderGcs R2SippySourceProvider = "gcs" +) + +type SippyDeleteResponse struct { + Enabled SippyDeleteResponseEnabled `json:"enabled"` + JSON sippyDeleteResponseJSON `json:"-"` +} + +// sippyDeleteResponseJSON contains the JSON metadata for the struct +// [SippyDeleteResponse] +type sippyDeleteResponseJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SippyDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r sippyDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type SippyDeleteResponseEnabled bool + +const ( + SippyDeleteResponseEnabledFalse SippyDeleteResponseEnabled = false +) + +type SippyUpdateParams struct { + // Account ID + AccountID param.Field[string] `path:"account_id,required"` + Destination param.Field[SippyUpdateParamsDestination] `json:"destination"` + Source param.Field[SippyUpdateParamsSource] `json:"source"` +} + +func (r SippyUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SippyUpdateParamsDestination struct { + // ID of a Cloudflare API token. This is the value labelled "Access Key ID" when + // creating an API token from the + // [R2 dashboard](https://dash.cloudflare.com/?to=/:account/r2/api-tokens). + // + // Sippy will use this token when writing objects to R2, so it is best to scope + // this token to the bucket you're enabling Sippy for. + AccessKeyID param.Field[string] `json:"accessKeyId"` + Provider param.Field[SippyUpdateParamsDestinationProvider] `json:"provider"` + // Value of a Cloudflare API token. This is the value labelled "Secret Access Key" + // when creating an API token from the + // [R2 dashboard](https://dash.cloudflare.com/?to=/:account/r2/api-tokens). + // + // Sippy will use this token when writing objects to R2, so it is best to scope + // this token to the bucket you're enabling Sippy for. + SecretAccessKey param.Field[string] `json:"secretAccessKey"` +} + +func (r SippyUpdateParamsDestination) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SippyUpdateParamsDestinationProvider string + +const ( + SippyUpdateParamsDestinationProviderR2 SippyUpdateParamsDestinationProvider = "r2" +) + +type SippyUpdateParamsSource struct { + // Access Key ID of an IAM credential (ideally scoped to a single S3 bucket) + AccessKeyID param.Field[string] `json:"accessKeyId"` + // Name of the GCS bucket + Bucket param.Field[string] `json:"bucket"` + // Client email of an IAM credential (ideally scoped to a single GCS bucket) + ClientEmail param.Field[string] `json:"clientEmail"` + // Private Key of an IAM credential (ideally scoped to a single GCS bucket) + PrivateKey param.Field[string] `json:"privateKey"` + Provider param.Field[SippyUpdateParamsSourceProvider] `json:"provider"` + // Name of the AWS availability zone + Region param.Field[string] `json:"region"` + // Secret Access Key of an IAM credential (ideally scoped to a single S3 bucket) + SecretAccessKey param.Field[string] `json:"secretAccessKey"` +} + +func (r SippyUpdateParamsSource) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SippyUpdateParamsSourceProvider string + +const ( + SippyUpdateParamsSourceProviderGcs SippyUpdateParamsSourceProvider = "gcs" +) + +type SippyUpdateResponseEnvelope struct { + Errors []SippyUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []string `json:"messages,required"` + Result R2Sippy `json:"result,required"` + // Whether the API call was successful + Success SippyUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON sippyUpdateResponseEnvelopeJSON `json:"-"` +} + +// sippyUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [SippyUpdateResponseEnvelope] +type sippyUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SippyUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r sippyUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SippyUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON sippyUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// sippyUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [SippyUpdateResponseEnvelopeErrors] +type sippyUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SippyUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r sippyUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SippyUpdateResponseEnvelopeSuccess bool + +const ( + SippyUpdateResponseEnvelopeSuccessTrue SippyUpdateResponseEnvelopeSuccess = true +) + +type SippyDeleteParams struct { + // Account ID + AccountID param.Field[string] `path:"account_id,required"` +} + +type SippyDeleteResponseEnvelope struct { + Errors []SippyDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []string `json:"messages,required"` + Result SippyDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success SippyDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON sippyDeleteResponseEnvelopeJSON `json:"-"` +} + +// sippyDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [SippyDeleteResponseEnvelope] +type sippyDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SippyDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r sippyDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SippyDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON sippyDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// sippyDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [SippyDeleteResponseEnvelopeErrors] +type sippyDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SippyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r sippyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SippyDeleteResponseEnvelopeSuccess bool + +const ( + SippyDeleteResponseEnvelopeSuccessTrue SippyDeleteResponseEnvelopeSuccess = true +) + +type SippyGetParams struct { + // Account ID + AccountID param.Field[string] `path:"account_id,required"` +} + +type SippyGetResponseEnvelope struct { + Errors []SippyGetResponseEnvelopeErrors `json:"errors,required"` + Messages []string `json:"messages,required"` + Result R2Sippy `json:"result,required"` + // Whether the API call was successful + Success SippyGetResponseEnvelopeSuccess `json:"success,required"` + JSON sippyGetResponseEnvelopeJSON `json:"-"` +} + +// sippyGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SippyGetResponseEnvelope] +type sippyGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SippyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r sippyGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SippyGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON sippyGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// sippyGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [SippyGetResponseEnvelopeErrors] +type sippyGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SippyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r sippyGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SippyGetResponseEnvelopeSuccess bool + +const ( + SippyGetResponseEnvelopeSuccessTrue SippyGetResponseEnvelopeSuccess = true +) diff --git a/r2/sippy_test.go b/r2/sippy_test.go new file mode 100644 index 00000000000..2e97b26aa56 --- /dev/null +++ b/r2/sippy_test.go @@ -0,0 +1,119 @@ +// File generated from our OpenAPI spec by Stainless. + +package r2_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/r2" +) + +func TestSippyUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.R2.Sippy.Update( + context.TODO(), + "example-bucket", + r2.SippyUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Destination: cloudflare.F(r2.SippyUpdateParamsDestination{ + AccessKeyID: cloudflare.F("string"), + Provider: cloudflare.F(r2.SippyUpdateParamsDestinationProviderR2), + SecretAccessKey: cloudflare.F("string"), + }), + Source: cloudflare.F(r2.SippyUpdateParamsSource{ + AccessKeyID: cloudflare.F("string"), + Bucket: cloudflare.F("string"), + Provider: cloudflare.F(r2.SippyUpdateParamsSourceProviderGcs), + Region: cloudflare.F("string"), + SecretAccessKey: cloudflare.F("string"), + ClientEmail: cloudflare.F("string"), + PrivateKey: cloudflare.F("string"), + }), + }, + ) + 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 TestSippyDelete(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("user@example.com"), + ) + _, err := client.R2.Sippy.Delete( + context.TODO(), + "example-bucket", + r2.SippyDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestSippyGet(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("user@example.com"), + ) + _, err := client.R2.Sippy.Get( + context.TODO(), + "example-bucket", + r2.SippyGetParams{ + AccountID: cloudflare.F("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/r2bucket.go b/r2bucket.go deleted file mode 100644 index a383ad68281..00000000000 --- a/r2bucket.go +++ /dev/null @@ -1,544 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// R2BucketService 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 [NewR2BucketService] method instead. -type R2BucketService struct { - Options []option.RequestOption -} - -// NewR2BucketService 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 NewR2BucketService(opts ...option.RequestOption) (r *R2BucketService) { - r = &R2BucketService{} - r.Options = opts - return -} - -// Creates a new R2 bucket. -func (r *R2BucketService) New(ctx context.Context, params R2BucketNewParams, opts ...option.RequestOption) (res *R2BucketNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env R2BucketNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/r2/buckets", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists all R2 buckets on your account -func (r *R2BucketService) List(ctx context.Context, params R2BucketListParams, opts ...option.RequestOption) (res *[]R2BucketListResponse, err error) { - opts = append(r.Options[:], opts...) - var env R2BucketListResponseEnvelope - path := fmt.Sprintf("accounts/%s/r2/buckets", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes an existing R2 bucket. -func (r *R2BucketService) Delete(ctx context.Context, bucketName string, body R2BucketDeleteParams, opts ...option.RequestOption) (res *R2BucketDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env R2BucketDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/r2/buckets/%s", body.AccountID, bucketName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets metadata for an existing R2 bucket. -func (r *R2BucketService) Get(ctx context.Context, bucketName string, query R2BucketGetParams, opts ...option.RequestOption) (res *R2BucketGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env R2BucketGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/r2/buckets/%s", query.AccountID, bucketName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// A single R2 bucket -type R2BucketNewResponse struct { - // Creation timestamp - CreationDate string `json:"creation_date"` - // Location of the bucket - Location R2BucketNewResponseLocation `json:"location"` - // Name of the bucket - Name string `json:"name"` - JSON r2BucketNewResponseJSON `json:"-"` -} - -// r2BucketNewResponseJSON contains the JSON metadata for the struct -// [R2BucketNewResponse] -type r2BucketNewResponseJSON struct { - CreationDate apijson.Field - Location apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2BucketNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2BucketNewResponseJSON) RawJSON() string { - return r.raw -} - -// Location of the bucket -type R2BucketNewResponseLocation string - -const ( - R2BucketNewResponseLocationApac R2BucketNewResponseLocation = "apac" - R2BucketNewResponseLocationEeur R2BucketNewResponseLocation = "eeur" - R2BucketNewResponseLocationEnam R2BucketNewResponseLocation = "enam" - R2BucketNewResponseLocationWeur R2BucketNewResponseLocation = "weur" - R2BucketNewResponseLocationWnam R2BucketNewResponseLocation = "wnam" -) - -// A single R2 bucket -type R2BucketListResponse struct { - // Creation timestamp - CreationDate string `json:"creation_date"` - // Location of the bucket - Location R2BucketListResponseLocation `json:"location"` - // Name of the bucket - Name string `json:"name"` - JSON r2BucketListResponseJSON `json:"-"` -} - -// r2BucketListResponseJSON contains the JSON metadata for the struct -// [R2BucketListResponse] -type r2BucketListResponseJSON struct { - CreationDate apijson.Field - Location apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2BucketListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2BucketListResponseJSON) RawJSON() string { - return r.raw -} - -// Location of the bucket -type R2BucketListResponseLocation string - -const ( - R2BucketListResponseLocationApac R2BucketListResponseLocation = "apac" - R2BucketListResponseLocationEeur R2BucketListResponseLocation = "eeur" - R2BucketListResponseLocationEnam R2BucketListResponseLocation = "enam" - R2BucketListResponseLocationWeur R2BucketListResponseLocation = "weur" - R2BucketListResponseLocationWnam R2BucketListResponseLocation = "wnam" -) - -type R2BucketDeleteResponse = interface{} - -// A single R2 bucket -type R2BucketGetResponse struct { - // Creation timestamp - CreationDate string `json:"creation_date"` - // Location of the bucket - Location R2BucketGetResponseLocation `json:"location"` - // Name of the bucket - Name string `json:"name"` - JSON r2BucketGetResponseJSON `json:"-"` -} - -// r2BucketGetResponseJSON contains the JSON metadata for the struct -// [R2BucketGetResponse] -type r2BucketGetResponseJSON struct { - CreationDate apijson.Field - Location apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2BucketGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2BucketGetResponseJSON) RawJSON() string { - return r.raw -} - -// Location of the bucket -type R2BucketGetResponseLocation string - -const ( - R2BucketGetResponseLocationApac R2BucketGetResponseLocation = "apac" - R2BucketGetResponseLocationEeur R2BucketGetResponseLocation = "eeur" - R2BucketGetResponseLocationEnam R2BucketGetResponseLocation = "enam" - R2BucketGetResponseLocationWeur R2BucketGetResponseLocation = "weur" - R2BucketGetResponseLocationWnam R2BucketGetResponseLocation = "wnam" -) - -type R2BucketNewParams struct { - // Account ID - AccountID param.Field[string] `path:"account_id,required"` - // Name of the bucket - Name param.Field[string] `json:"name,required"` - // Location of the bucket - LocationHint param.Field[R2BucketNewParamsLocationHint] `json:"locationHint"` -} - -func (r R2BucketNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Location of the bucket -type R2BucketNewParamsLocationHint string - -const ( - R2BucketNewParamsLocationHintApac R2BucketNewParamsLocationHint = "apac" - R2BucketNewParamsLocationHintEeur R2BucketNewParamsLocationHint = "eeur" - R2BucketNewParamsLocationHintEnam R2BucketNewParamsLocationHint = "enam" - R2BucketNewParamsLocationHintWeur R2BucketNewParamsLocationHint = "weur" - R2BucketNewParamsLocationHintWnam R2BucketNewParamsLocationHint = "wnam" -) - -type R2BucketNewResponseEnvelope struct { - Errors []R2BucketNewResponseEnvelopeErrors `json:"errors,required"` - Messages []string `json:"messages,required"` - // A single R2 bucket - Result R2BucketNewResponse `json:"result,required"` - // Whether the API call was successful - Success R2BucketNewResponseEnvelopeSuccess `json:"success,required"` - JSON r2BucketNewResponseEnvelopeJSON `json:"-"` -} - -// r2BucketNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [R2BucketNewResponseEnvelope] -type r2BucketNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2BucketNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2BucketNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type R2BucketNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON r2BucketNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// r2BucketNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [R2BucketNewResponseEnvelopeErrors] -type r2BucketNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2BucketNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2BucketNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type R2BucketNewResponseEnvelopeSuccess bool - -const ( - R2BucketNewResponseEnvelopeSuccessTrue R2BucketNewResponseEnvelopeSuccess = true -) - -type R2BucketListParams struct { - // Account ID - AccountID param.Field[string] `path:"account_id,required"` - // Pagination cursor received during the last List Buckets call. R2 buckets are - // paginated using cursors instead of page numbers. - Cursor param.Field[string] `query:"cursor"` - // Direction to order buckets - Direction param.Field[R2BucketListParamsDirection] `query:"direction"` - // Bucket names to filter by. Only buckets with this phrase in their name will be - // returned. - NameContains param.Field[string] `query:"name_contains"` - // Field to order buckets by - Order param.Field[R2BucketListParamsOrder] `query:"order"` - // Maximum number of buckets to return in a single call - PerPage param.Field[float64] `query:"per_page"` - // Bucket name to start searching after. Buckets are ordered lexicographically. - StartAfter param.Field[string] `query:"start_after"` -} - -// URLQuery serializes [R2BucketListParams]'s query parameters as `url.Values`. -func (r R2BucketListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Direction to order buckets -type R2BucketListParamsDirection string - -const ( - R2BucketListParamsDirectionAsc R2BucketListParamsDirection = "asc" - R2BucketListParamsDirectionDesc R2BucketListParamsDirection = "desc" -) - -// Field to order buckets by -type R2BucketListParamsOrder string - -const ( - R2BucketListParamsOrderName R2BucketListParamsOrder = "name" -) - -type R2BucketListResponseEnvelope struct { - Errors []R2BucketListResponseEnvelopeErrors `json:"errors,required"` - Messages []string `json:"messages,required"` - Result []R2BucketListResponse `json:"result,required"` - // Whether the API call was successful - Success R2BucketListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo R2BucketListResponseEnvelopeResultInfo `json:"result_info"` - JSON r2BucketListResponseEnvelopeJSON `json:"-"` -} - -// r2BucketListResponseEnvelopeJSON contains the JSON metadata for the struct -// [R2BucketListResponseEnvelope] -type r2BucketListResponseEnvelopeJSON 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 *R2BucketListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2BucketListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type R2BucketListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON r2BucketListResponseEnvelopeErrorsJSON `json:"-"` -} - -// r2BucketListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [R2BucketListResponseEnvelopeErrors] -type r2BucketListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2BucketListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2BucketListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type R2BucketListResponseEnvelopeSuccess bool - -const ( - R2BucketListResponseEnvelopeSuccessTrue R2BucketListResponseEnvelopeSuccess = true -) - -type R2BucketListResponseEnvelopeResultInfo struct { - // A continuation token that should be used to fetch the next page of results - Cursor string `json:"cursor"` - // Maximum number of results on this page - PerPage float64 `json:"per_page"` - JSON r2BucketListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// r2BucketListResponseEnvelopeResultInfoJSON contains the JSON metadata for the -// struct [R2BucketListResponseEnvelopeResultInfo] -type r2BucketListResponseEnvelopeResultInfoJSON struct { - Cursor apijson.Field - PerPage apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2BucketListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2BucketListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type R2BucketDeleteParams struct { - // Account ID - AccountID param.Field[string] `path:"account_id,required"` -} - -type R2BucketDeleteResponseEnvelope struct { - Errors []R2BucketDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []string `json:"messages,required"` - Result R2BucketDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success R2BucketDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON r2BucketDeleteResponseEnvelopeJSON `json:"-"` -} - -// r2BucketDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [R2BucketDeleteResponseEnvelope] -type r2BucketDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2BucketDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2BucketDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type R2BucketDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON r2BucketDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// r2BucketDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [R2BucketDeleteResponseEnvelopeErrors] -type r2BucketDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2BucketDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2BucketDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type R2BucketDeleteResponseEnvelopeSuccess bool - -const ( - R2BucketDeleteResponseEnvelopeSuccessTrue R2BucketDeleteResponseEnvelopeSuccess = true -) - -type R2BucketGetParams struct { - // Account ID - AccountID param.Field[string] `path:"account_id,required"` -} - -type R2BucketGetResponseEnvelope struct { - Errors []R2BucketGetResponseEnvelopeErrors `json:"errors,required"` - Messages []string `json:"messages,required"` - // A single R2 bucket - Result R2BucketGetResponse `json:"result,required"` - // Whether the API call was successful - Success R2BucketGetResponseEnvelopeSuccess `json:"success,required"` - JSON r2BucketGetResponseEnvelopeJSON `json:"-"` -} - -// r2BucketGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [R2BucketGetResponseEnvelope] -type r2BucketGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2BucketGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2BucketGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type R2BucketGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON r2BucketGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// r2BucketGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [R2BucketGetResponseEnvelopeErrors] -type r2BucketGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2BucketGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2BucketGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type R2BucketGetResponseEnvelopeSuccess bool - -const ( - R2BucketGetResponseEnvelopeSuccessTrue R2BucketGetResponseEnvelopeSuccess = true -) diff --git a/r2bucket_test.go b/r2bucket_test.go deleted file mode 100644 index b83fb3391f7..00000000000 --- a/r2bucket_test.go +++ /dev/null @@ -1,134 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestR2BucketNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.R2.Buckets.New(context.TODO(), cloudflare.R2BucketNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Name: cloudflare.F("example-bucket"), - LocationHint: cloudflare.F(cloudflare.R2BucketNewParamsLocationHintApac), - }) - 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 TestR2BucketListWithOptionalParams(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("user@example.com"), - ) - _, err := client.R2.Buckets.List(context.TODO(), cloudflare.R2BucketListParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Cursor: cloudflare.F("string"), - Direction: cloudflare.F(cloudflare.R2BucketListParamsDirectionDesc), - NameContains: cloudflare.F("my-bucket"), - Order: cloudflare.F(cloudflare.R2BucketListParamsOrderName), - PerPage: cloudflare.F(1.000000), - StartAfter: cloudflare.F("my-bucket"), - }) - 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 TestR2BucketDelete(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("user@example.com"), - ) - _, err := client.R2.Buckets.Delete( - context.TODO(), - "example-bucket", - cloudflare.R2BucketDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestR2BucketGet(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("user@example.com"), - ) - _, err := client.R2.Buckets.Get( - context.TODO(), - "example-bucket", - cloudflare.R2BucketGetParams{ - AccountID: cloudflare.F("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/r2sippy.go b/r2sippy.go deleted file mode 100644 index d161ff97488..00000000000 --- a/r2sippy.go +++ /dev/null @@ -1,544 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// R2SippyService 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 [NewR2SippyService] method instead. -type R2SippyService struct { - Options []option.RequestOption -} - -// NewR2SippyService 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 NewR2SippyService(opts ...option.RequestOption) (r *R2SippyService) { - r = &R2SippyService{} - r.Options = opts - return -} - -// Sets configuration for Sippy for an existing R2 bucket. -func (r *R2SippyService) Update(ctx context.Context, bucketName string, params R2SippyUpdateParams, opts ...option.RequestOption) (res *R2SippyUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env R2SippyUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/r2/buckets/%s/sippy", params.AccountID, bucketName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Disables Sippy on this bucket -func (r *R2SippyService) Delete(ctx context.Context, bucketName string, body R2SippyDeleteParams, opts ...option.RequestOption) (res *R2SippyDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env R2SippyDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/r2/buckets/%s/sippy", body.AccountID, bucketName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets configuration for Sippy for an existing R2 bucket. -func (r *R2SippyService) Get(ctx context.Context, bucketName string, query R2SippyGetParams, opts ...option.RequestOption) (res *R2SippyGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env R2SippyGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/r2/buckets/%s/sippy", query.AccountID, bucketName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type R2SippyUpdateResponse struct { - // Details about the configured destination bucket - Destination R2SippyUpdateResponseDestination `json:"destination"` - // State of Sippy for this bucket - Enabled bool `json:"enabled"` - // Details about the configured source bucket - Source R2SippyUpdateResponseSource `json:"source"` - JSON r2SippyUpdateResponseJSON `json:"-"` -} - -// r2SippyUpdateResponseJSON contains the JSON metadata for the struct -// [R2SippyUpdateResponse] -type r2SippyUpdateResponseJSON struct { - Destination apijson.Field - Enabled apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2SippyUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2SippyUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// Details about the configured destination bucket -type R2SippyUpdateResponseDestination struct { - // ID of the Cloudflare API token used when writing objects to this bucket - AccessKeyID string `json:"accessKeyId"` - Account string `json:"account"` - // Name of the bucket on the provider - Bucket string `json:"bucket"` - Provider R2SippyUpdateResponseDestinationProvider `json:"provider"` - JSON r2SippyUpdateResponseDestinationJSON `json:"-"` -} - -// r2SippyUpdateResponseDestinationJSON contains the JSON metadata for the struct -// [R2SippyUpdateResponseDestination] -type r2SippyUpdateResponseDestinationJSON struct { - AccessKeyID apijson.Field - Account apijson.Field - Bucket apijson.Field - Provider apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2SippyUpdateResponseDestination) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2SippyUpdateResponseDestinationJSON) RawJSON() string { - return r.raw -} - -type R2SippyUpdateResponseDestinationProvider string - -const ( - R2SippyUpdateResponseDestinationProviderR2 R2SippyUpdateResponseDestinationProvider = "r2" -) - -// Details about the configured source bucket -type R2SippyUpdateResponseSource struct { - // Name of the bucket on the provider - Bucket string `json:"bucket"` - Provider R2SippyUpdateResponseSourceProvider `json:"provider"` - // Region where the bucket resides (AWS only) - Region string `json:"region,nullable"` - JSON r2SippyUpdateResponseSourceJSON `json:"-"` -} - -// r2SippyUpdateResponseSourceJSON contains the JSON metadata for the struct -// [R2SippyUpdateResponseSource] -type r2SippyUpdateResponseSourceJSON struct { - Bucket apijson.Field - Provider apijson.Field - Region apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2SippyUpdateResponseSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2SippyUpdateResponseSourceJSON) RawJSON() string { - return r.raw -} - -type R2SippyUpdateResponseSourceProvider string - -const ( - R2SippyUpdateResponseSourceProviderAws R2SippyUpdateResponseSourceProvider = "aws" - R2SippyUpdateResponseSourceProviderGcs R2SippyUpdateResponseSourceProvider = "gcs" -) - -type R2SippyDeleteResponse struct { - Enabled R2SippyDeleteResponseEnabled `json:"enabled"` - JSON r2SippyDeleteResponseJSON `json:"-"` -} - -// r2SippyDeleteResponseJSON contains the JSON metadata for the struct -// [R2SippyDeleteResponse] -type r2SippyDeleteResponseJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2SippyDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2SippyDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type R2SippyDeleteResponseEnabled bool - -const ( - R2SippyDeleteResponseEnabledFalse R2SippyDeleteResponseEnabled = false -) - -type R2SippyGetResponse struct { - // Details about the configured destination bucket - Destination R2SippyGetResponseDestination `json:"destination"` - // State of Sippy for this bucket - Enabled bool `json:"enabled"` - // Details about the configured source bucket - Source R2SippyGetResponseSource `json:"source"` - JSON r2SippyGetResponseJSON `json:"-"` -} - -// r2SippyGetResponseJSON contains the JSON metadata for the struct -// [R2SippyGetResponse] -type r2SippyGetResponseJSON struct { - Destination apijson.Field - Enabled apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2SippyGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2SippyGetResponseJSON) RawJSON() string { - return r.raw -} - -// Details about the configured destination bucket -type R2SippyGetResponseDestination struct { - // ID of the Cloudflare API token used when writing objects to this bucket - AccessKeyID string `json:"accessKeyId"` - Account string `json:"account"` - // Name of the bucket on the provider - Bucket string `json:"bucket"` - Provider R2SippyGetResponseDestinationProvider `json:"provider"` - JSON r2SippyGetResponseDestinationJSON `json:"-"` -} - -// r2SippyGetResponseDestinationJSON contains the JSON metadata for the struct -// [R2SippyGetResponseDestination] -type r2SippyGetResponseDestinationJSON struct { - AccessKeyID apijson.Field - Account apijson.Field - Bucket apijson.Field - Provider apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2SippyGetResponseDestination) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2SippyGetResponseDestinationJSON) RawJSON() string { - return r.raw -} - -type R2SippyGetResponseDestinationProvider string - -const ( - R2SippyGetResponseDestinationProviderR2 R2SippyGetResponseDestinationProvider = "r2" -) - -// Details about the configured source bucket -type R2SippyGetResponseSource struct { - // Name of the bucket on the provider - Bucket string `json:"bucket"` - Provider R2SippyGetResponseSourceProvider `json:"provider"` - // Region where the bucket resides (AWS only) - Region string `json:"region,nullable"` - JSON r2SippyGetResponseSourceJSON `json:"-"` -} - -// r2SippyGetResponseSourceJSON contains the JSON metadata for the struct -// [R2SippyGetResponseSource] -type r2SippyGetResponseSourceJSON struct { - Bucket apijson.Field - Provider apijson.Field - Region apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2SippyGetResponseSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2SippyGetResponseSourceJSON) RawJSON() string { - return r.raw -} - -type R2SippyGetResponseSourceProvider string - -const ( - R2SippyGetResponseSourceProviderAws R2SippyGetResponseSourceProvider = "aws" - R2SippyGetResponseSourceProviderGcs R2SippyGetResponseSourceProvider = "gcs" -) - -type R2SippyUpdateParams struct { - // Account ID - AccountID param.Field[string] `path:"account_id,required"` - Destination param.Field[R2SippyUpdateParamsDestination] `json:"destination"` - Source param.Field[R2SippyUpdateParamsSource] `json:"source"` -} - -func (r R2SippyUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type R2SippyUpdateParamsDestination struct { - // ID of a Cloudflare API token. This is the value labelled "Access Key ID" when - // creating an API token from the - // [R2 dashboard](https://dash.cloudflare.com/?to=/:account/r2/api-tokens). - // - // Sippy will use this token when writing objects to R2, so it is best to scope - // this token to the bucket you're enabling Sippy for. - AccessKeyID param.Field[string] `json:"accessKeyId"` - Provider param.Field[R2SippyUpdateParamsDestinationProvider] `json:"provider"` - // Value of a Cloudflare API token. This is the value labelled "Secret Access Key" - // when creating an API token from the - // [R2 dashboard](https://dash.cloudflare.com/?to=/:account/r2/api-tokens). - // - // Sippy will use this token when writing objects to R2, so it is best to scope - // this token to the bucket you're enabling Sippy for. - SecretAccessKey param.Field[string] `json:"secretAccessKey"` -} - -func (r R2SippyUpdateParamsDestination) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type R2SippyUpdateParamsDestinationProvider string - -const ( - R2SippyUpdateParamsDestinationProviderR2 R2SippyUpdateParamsDestinationProvider = "r2" -) - -type R2SippyUpdateParamsSource struct { - // Access Key ID of an IAM credential (ideally scoped to a single S3 bucket) - AccessKeyID param.Field[string] `json:"accessKeyId"` - // Name of the GCS bucket - Bucket param.Field[string] `json:"bucket"` - // Client email of an IAM credential (ideally scoped to a single GCS bucket) - ClientEmail param.Field[string] `json:"clientEmail"` - // Private Key of an IAM credential (ideally scoped to a single GCS bucket) - PrivateKey param.Field[string] `json:"privateKey"` - Provider param.Field[R2SippyUpdateParamsSourceProvider] `json:"provider"` - // Name of the AWS availability zone - Region param.Field[string] `json:"region"` - // Secret Access Key of an IAM credential (ideally scoped to a single S3 bucket) - SecretAccessKey param.Field[string] `json:"secretAccessKey"` -} - -func (r R2SippyUpdateParamsSource) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type R2SippyUpdateParamsSourceProvider string - -const ( - R2SippyUpdateParamsSourceProviderGcs R2SippyUpdateParamsSourceProvider = "gcs" -) - -type R2SippyUpdateResponseEnvelope struct { - Errors []R2SippyUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []string `json:"messages,required"` - Result R2SippyUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success R2SippyUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON r2SippyUpdateResponseEnvelopeJSON `json:"-"` -} - -// r2SippyUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [R2SippyUpdateResponseEnvelope] -type r2SippyUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2SippyUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2SippyUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type R2SippyUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON r2SippyUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// r2SippyUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [R2SippyUpdateResponseEnvelopeErrors] -type r2SippyUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2SippyUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2SippyUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type R2SippyUpdateResponseEnvelopeSuccess bool - -const ( - R2SippyUpdateResponseEnvelopeSuccessTrue R2SippyUpdateResponseEnvelopeSuccess = true -) - -type R2SippyDeleteParams struct { - // Account ID - AccountID param.Field[string] `path:"account_id,required"` -} - -type R2SippyDeleteResponseEnvelope struct { - Errors []R2SippyDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []string `json:"messages,required"` - Result R2SippyDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success R2SippyDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON r2SippyDeleteResponseEnvelopeJSON `json:"-"` -} - -// r2SippyDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [R2SippyDeleteResponseEnvelope] -type r2SippyDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2SippyDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2SippyDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type R2SippyDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON r2SippyDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// r2SippyDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [R2SippyDeleteResponseEnvelopeErrors] -type r2SippyDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2SippyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2SippyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type R2SippyDeleteResponseEnvelopeSuccess bool - -const ( - R2SippyDeleteResponseEnvelopeSuccessTrue R2SippyDeleteResponseEnvelopeSuccess = true -) - -type R2SippyGetParams struct { - // Account ID - AccountID param.Field[string] `path:"account_id,required"` -} - -type R2SippyGetResponseEnvelope struct { - Errors []R2SippyGetResponseEnvelopeErrors `json:"errors,required"` - Messages []string `json:"messages,required"` - Result R2SippyGetResponse `json:"result,required"` - // Whether the API call was successful - Success R2SippyGetResponseEnvelopeSuccess `json:"success,required"` - JSON r2SippyGetResponseEnvelopeJSON `json:"-"` -} - -// r2SippyGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [R2SippyGetResponseEnvelope] -type r2SippyGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2SippyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2SippyGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type R2SippyGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON r2SippyGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// r2SippyGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [R2SippyGetResponseEnvelopeErrors] -type r2SippyGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *R2SippyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r r2SippyGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type R2SippyGetResponseEnvelopeSuccess bool - -const ( - R2SippyGetResponseEnvelopeSuccessTrue R2SippyGetResponseEnvelopeSuccess = true -) diff --git a/r2sippy_test.go b/r2sippy_test.go deleted file mode 100644 index bae58532c90..00000000000 --- a/r2sippy_test.go +++ /dev/null @@ -1,118 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestR2SippyUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.R2.Sippy.Update( - context.TODO(), - "example-bucket", - cloudflare.R2SippyUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Destination: cloudflare.F(cloudflare.R2SippyUpdateParamsDestination{ - AccessKeyID: cloudflare.F("string"), - Provider: cloudflare.F(cloudflare.R2SippyUpdateParamsDestinationProviderR2), - SecretAccessKey: cloudflare.F("string"), - }), - Source: cloudflare.F(cloudflare.R2SippyUpdateParamsSource{ - AccessKeyID: cloudflare.F("string"), - Bucket: cloudflare.F("string"), - Provider: cloudflare.F(cloudflare.R2SippyUpdateParamsSourceProviderGcs), - Region: cloudflare.F("string"), - SecretAccessKey: cloudflare.F("string"), - ClientEmail: cloudflare.F("string"), - PrivateKey: cloudflare.F("string"), - }), - }, - ) - 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 TestR2SippyDelete(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("user@example.com"), - ) - _, err := client.R2.Sippy.Delete( - context.TODO(), - "example-bucket", - cloudflare.R2SippyDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestR2SippyGet(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("user@example.com"), - ) - _, err := client.R2.Sippy.Get( - context.TODO(), - "example-bucket", - cloudflare.R2SippyGetParams{ - AccountID: cloudflare.F("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/radar.go b/radar.go deleted file mode 100644 index 2209f6fe877..00000000000 --- a/radar.go +++ /dev/null @@ -1,56 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarService 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 [NewRadarService] method instead. -type RadarService struct { - Options []option.RequestOption - Annotations *RadarAnnotationService - BGP *RadarBGPService - Datasets *RadarDatasetService - DNS *RadarDNSService - Netflows *RadarNetflowService - Search *RadarSearchService - VerifiedBots *RadarVerifiedBotService - AS112 *RadarAS112Service - ConnectionTampering *RadarConnectionTamperingService - Email *RadarEmailService - Attacks *RadarAttackService - Entities *RadarEntityService - HTTP *RadarHTTPService - Quality *RadarQualityService - Ranking *RadarRankingService - TrafficAnomalies *RadarTrafficAnomalyService -} - -// NewRadarService 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 NewRadarService(opts ...option.RequestOption) (r *RadarService) { - r = &RadarService{} - r.Options = opts - r.Annotations = NewRadarAnnotationService(opts...) - r.BGP = NewRadarBGPService(opts...) - r.Datasets = NewRadarDatasetService(opts...) - r.DNS = NewRadarDNSService(opts...) - r.Netflows = NewRadarNetflowService(opts...) - r.Search = NewRadarSearchService(opts...) - r.VerifiedBots = NewRadarVerifiedBotService(opts...) - r.AS112 = NewRadarAS112Service(opts...) - r.ConnectionTampering = NewRadarConnectionTamperingService(opts...) - r.Email = NewRadarEmailService(opts...) - r.Attacks = NewRadarAttackService(opts...) - r.Entities = NewRadarEntityService(opts...) - r.HTTP = NewRadarHTTPService(opts...) - r.Quality = NewRadarQualityService(opts...) - r.Ranking = NewRadarRankingService(opts...) - r.TrafficAnomalies = NewRadarTrafficAnomalyService(opts...) - return -} diff --git a/radar/aliases.go b/radar/aliases.go new file mode 100644 index 00000000000..3aae5ffe93d --- /dev/null +++ b/radar/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/radar/annotation.go b/radar/annotation.go new file mode 100644 index 00000000000..f54e077143b --- /dev/null +++ b/radar/annotation.go @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// AnnotationService 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 [NewAnnotationService] method instead. +type AnnotationService struct { + Options []option.RequestOption + Outages *AnnotationOutageService +} + +// NewAnnotationService 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 NewAnnotationService(opts ...option.RequestOption) (r *AnnotationService) { + r = &AnnotationService{} + r.Options = opts + r.Outages = NewAnnotationOutageService(opts...) + return +} diff --git a/radar/annotationoutage.go b/radar/annotationoutage.go new file mode 100644 index 00000000000..65e6ba73f09 --- /dev/null +++ b/radar/annotationoutage.go @@ -0,0 +1,425 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AnnotationOutageService 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 [NewAnnotationOutageService] method +// instead. +type AnnotationOutageService struct { + Options []option.RequestOption +} + +// NewAnnotationOutageService 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 NewAnnotationOutageService(opts ...option.RequestOption) (r *AnnotationOutageService) { + r = &AnnotationOutageService{} + r.Options = opts + return +} + +// Get latest Internet outages and anomalies. +func (r *AnnotationOutageService) Get(ctx context.Context, query AnnotationOutageGetParams, opts ...option.RequestOption) (res *AnnotationOutageGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env AnnotationOutageGetResponseEnvelope + path := "radar/annotations/outages" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the number of outages for locations. +func (r *AnnotationOutageService) Locations(ctx context.Context, query AnnotationOutageLocationsParams, opts ...option.RequestOption) (res *AnnotationOutageLocationsResponse, err error) { + opts = append(r.Options[:], opts...) + var env AnnotationOutageLocationsResponseEnvelope + path := "radar/annotations/outages/locations" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AnnotationOutageGetResponse struct { + Annotations []AnnotationOutageGetResponseAnnotation `json:"annotations,required"` + JSON annotationOutageGetResponseJSON `json:"-"` +} + +// annotationOutageGetResponseJSON contains the JSON metadata for the struct +// [AnnotationOutageGetResponse] +type annotationOutageGetResponseJSON struct { + Annotations apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnnotationOutageGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r annotationOutageGetResponseJSON) RawJSON() string { + return r.raw +} + +type AnnotationOutageGetResponseAnnotation struct { + ID string `json:"id,required"` + ASNs []int64 `json:"asns,required"` + ASNsDetails []AnnotationOutageGetResponseAnnotationsASNsDetail `json:"asnsDetails,required"` + DataSource string `json:"dataSource,required"` + EventType string `json:"eventType,required"` + Locations []string `json:"locations,required"` + LocationsDetails []AnnotationOutageGetResponseAnnotationsLocationsDetail `json:"locationsDetails,required"` + Outage AnnotationOutageGetResponseAnnotationsOutage `json:"outage,required"` + StartDate string `json:"startDate,required"` + Description string `json:"description"` + EndDate string `json:"endDate"` + LinkedURL string `json:"linkedUrl"` + Scope string `json:"scope"` + JSON annotationOutageGetResponseAnnotationJSON `json:"-"` +} + +// annotationOutageGetResponseAnnotationJSON contains the JSON metadata for the +// struct [AnnotationOutageGetResponseAnnotation] +type annotationOutageGetResponseAnnotationJSON struct { + ID apijson.Field + ASNs apijson.Field + ASNsDetails apijson.Field + DataSource apijson.Field + EventType apijson.Field + Locations apijson.Field + LocationsDetails apijson.Field + Outage apijson.Field + StartDate apijson.Field + Description apijson.Field + EndDate apijson.Field + LinkedURL apijson.Field + Scope apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnnotationOutageGetResponseAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r annotationOutageGetResponseAnnotationJSON) RawJSON() string { + return r.raw +} + +type AnnotationOutageGetResponseAnnotationsASNsDetail struct { + ASN string `json:"asn,required"` + Name string `json:"name,required"` + Locations AnnotationOutageGetResponseAnnotationsASNsDetailsLocations `json:"locations"` + JSON annotationOutageGetResponseAnnotationsASNsDetailJSON `json:"-"` +} + +// annotationOutageGetResponseAnnotationsASNsDetailJSON contains the JSON metadata +// for the struct [AnnotationOutageGetResponseAnnotationsASNsDetail] +type annotationOutageGetResponseAnnotationsASNsDetailJSON struct { + ASN apijson.Field + Name apijson.Field + Locations apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnnotationOutageGetResponseAnnotationsASNsDetail) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r annotationOutageGetResponseAnnotationsASNsDetailJSON) RawJSON() string { + return r.raw +} + +type AnnotationOutageGetResponseAnnotationsASNsDetailsLocations struct { + Code string `json:"code,required"` + Name string `json:"name,required"` + JSON annotationOutageGetResponseAnnotationsASNsDetailsLocationsJSON `json:"-"` +} + +// annotationOutageGetResponseAnnotationsASNsDetailsLocationsJSON contains the JSON +// metadata for the struct +// [AnnotationOutageGetResponseAnnotationsASNsDetailsLocations] +type annotationOutageGetResponseAnnotationsASNsDetailsLocationsJSON struct { + Code apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnnotationOutageGetResponseAnnotationsASNsDetailsLocations) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r annotationOutageGetResponseAnnotationsASNsDetailsLocationsJSON) RawJSON() string { + return r.raw +} + +type AnnotationOutageGetResponseAnnotationsLocationsDetail struct { + Code string `json:"code,required"` + Name string `json:"name,required"` + JSON annotationOutageGetResponseAnnotationsLocationsDetailJSON `json:"-"` +} + +// annotationOutageGetResponseAnnotationsLocationsDetailJSON contains the JSON +// metadata for the struct [AnnotationOutageGetResponseAnnotationsLocationsDetail] +type annotationOutageGetResponseAnnotationsLocationsDetailJSON struct { + Code apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnnotationOutageGetResponseAnnotationsLocationsDetail) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r annotationOutageGetResponseAnnotationsLocationsDetailJSON) RawJSON() string { + return r.raw +} + +type AnnotationOutageGetResponseAnnotationsOutage struct { + OutageCause string `json:"outageCause,required"` + OutageType string `json:"outageType,required"` + JSON annotationOutageGetResponseAnnotationsOutageJSON `json:"-"` +} + +// annotationOutageGetResponseAnnotationsOutageJSON contains the JSON metadata for +// the struct [AnnotationOutageGetResponseAnnotationsOutage] +type annotationOutageGetResponseAnnotationsOutageJSON struct { + OutageCause apijson.Field + OutageType apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnnotationOutageGetResponseAnnotationsOutage) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r annotationOutageGetResponseAnnotationsOutageJSON) RawJSON() string { + return r.raw +} + +type AnnotationOutageLocationsResponse struct { + Annotations []AnnotationOutageLocationsResponseAnnotation `json:"annotations,required"` + JSON annotationOutageLocationsResponseJSON `json:"-"` +} + +// annotationOutageLocationsResponseJSON contains the JSON metadata for the struct +// [AnnotationOutageLocationsResponse] +type annotationOutageLocationsResponseJSON struct { + Annotations apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnnotationOutageLocationsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r annotationOutageLocationsResponseJSON) RawJSON() string { + return r.raw +} + +type AnnotationOutageLocationsResponseAnnotation struct { + ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` + ClientCountryName string `json:"clientCountryName,required"` + Value string `json:"value,required"` + JSON annotationOutageLocationsResponseAnnotationJSON `json:"-"` +} + +// annotationOutageLocationsResponseAnnotationJSON contains the JSON metadata for +// the struct [AnnotationOutageLocationsResponseAnnotation] +type annotationOutageLocationsResponseAnnotationJSON struct { + ClientCountryAlpha2 apijson.Field + ClientCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnnotationOutageLocationsResponseAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r annotationOutageLocationsResponseAnnotationJSON) RawJSON() string { + return r.raw +} + +type AnnotationOutageGetParams struct { + // Single ASN as integer. + ASN param.Field[int64] `query:"asn"` + // End of the date range (inclusive). + DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"` + // Shorthand date ranges for the last X days - use when you don't need specific + // start and end dates. + DateRange param.Field[AnnotationOutageGetParamsDateRange] `query:"dateRange"` + // Start of the date range (inclusive). + DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AnnotationOutageGetParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Location Alpha2 code. + Location param.Field[string] `query:"location"` + // Number of objects to skip before grabbing results. + Offset param.Field[int64] `query:"offset"` +} + +// URLQuery serializes [AnnotationOutageGetParams]'s query parameters as +// `url.Values`. +func (r AnnotationOutageGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Shorthand date ranges for the last X days - use when you don't need specific +// start and end dates. +type AnnotationOutageGetParamsDateRange string + +const ( + AnnotationOutageGetParamsDateRange1d AnnotationOutageGetParamsDateRange = "1d" + AnnotationOutageGetParamsDateRange2d AnnotationOutageGetParamsDateRange = "2d" + AnnotationOutageGetParamsDateRange7d AnnotationOutageGetParamsDateRange = "7d" + AnnotationOutageGetParamsDateRange14d AnnotationOutageGetParamsDateRange = "14d" + AnnotationOutageGetParamsDateRange28d AnnotationOutageGetParamsDateRange = "28d" + AnnotationOutageGetParamsDateRange12w AnnotationOutageGetParamsDateRange = "12w" + AnnotationOutageGetParamsDateRange24w AnnotationOutageGetParamsDateRange = "24w" + AnnotationOutageGetParamsDateRange52w AnnotationOutageGetParamsDateRange = "52w" + AnnotationOutageGetParamsDateRange1dControl AnnotationOutageGetParamsDateRange = "1dControl" + AnnotationOutageGetParamsDateRange2dControl AnnotationOutageGetParamsDateRange = "2dControl" + AnnotationOutageGetParamsDateRange7dControl AnnotationOutageGetParamsDateRange = "7dControl" + AnnotationOutageGetParamsDateRange14dControl AnnotationOutageGetParamsDateRange = "14dControl" + AnnotationOutageGetParamsDateRange28dControl AnnotationOutageGetParamsDateRange = "28dControl" + AnnotationOutageGetParamsDateRange12wControl AnnotationOutageGetParamsDateRange = "12wControl" + AnnotationOutageGetParamsDateRange24wControl AnnotationOutageGetParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AnnotationOutageGetParamsFormat string + +const ( + AnnotationOutageGetParamsFormatJson AnnotationOutageGetParamsFormat = "JSON" + AnnotationOutageGetParamsFormatCsv AnnotationOutageGetParamsFormat = "CSV" +) + +type AnnotationOutageGetResponseEnvelope struct { + Result AnnotationOutageGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON annotationOutageGetResponseEnvelopeJSON `json:"-"` +} + +// annotationOutageGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [AnnotationOutageGetResponseEnvelope] +type annotationOutageGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnnotationOutageGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r annotationOutageGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AnnotationOutageLocationsParams struct { + // End of the date range (inclusive). + DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"` + // Shorthand date ranges for the last X days - use when you don't need specific + // start and end dates. + DateRange param.Field[AnnotationOutageLocationsParamsDateRange] `query:"dateRange"` + // Start of the date range (inclusive). + DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AnnotationOutageLocationsParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` +} + +// URLQuery serializes [AnnotationOutageLocationsParams]'s query parameters as +// `url.Values`. +func (r AnnotationOutageLocationsParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Shorthand date ranges for the last X days - use when you don't need specific +// start and end dates. +type AnnotationOutageLocationsParamsDateRange string + +const ( + AnnotationOutageLocationsParamsDateRange1d AnnotationOutageLocationsParamsDateRange = "1d" + AnnotationOutageLocationsParamsDateRange2d AnnotationOutageLocationsParamsDateRange = "2d" + AnnotationOutageLocationsParamsDateRange7d AnnotationOutageLocationsParamsDateRange = "7d" + AnnotationOutageLocationsParamsDateRange14d AnnotationOutageLocationsParamsDateRange = "14d" + AnnotationOutageLocationsParamsDateRange28d AnnotationOutageLocationsParamsDateRange = "28d" + AnnotationOutageLocationsParamsDateRange12w AnnotationOutageLocationsParamsDateRange = "12w" + AnnotationOutageLocationsParamsDateRange24w AnnotationOutageLocationsParamsDateRange = "24w" + AnnotationOutageLocationsParamsDateRange52w AnnotationOutageLocationsParamsDateRange = "52w" + AnnotationOutageLocationsParamsDateRange1dControl AnnotationOutageLocationsParamsDateRange = "1dControl" + AnnotationOutageLocationsParamsDateRange2dControl AnnotationOutageLocationsParamsDateRange = "2dControl" + AnnotationOutageLocationsParamsDateRange7dControl AnnotationOutageLocationsParamsDateRange = "7dControl" + AnnotationOutageLocationsParamsDateRange14dControl AnnotationOutageLocationsParamsDateRange = "14dControl" + AnnotationOutageLocationsParamsDateRange28dControl AnnotationOutageLocationsParamsDateRange = "28dControl" + AnnotationOutageLocationsParamsDateRange12wControl AnnotationOutageLocationsParamsDateRange = "12wControl" + AnnotationOutageLocationsParamsDateRange24wControl AnnotationOutageLocationsParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AnnotationOutageLocationsParamsFormat string + +const ( + AnnotationOutageLocationsParamsFormatJson AnnotationOutageLocationsParamsFormat = "JSON" + AnnotationOutageLocationsParamsFormatCsv AnnotationOutageLocationsParamsFormat = "CSV" +) + +type AnnotationOutageLocationsResponseEnvelope struct { + Result AnnotationOutageLocationsResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON annotationOutageLocationsResponseEnvelopeJSON `json:"-"` +} + +// annotationOutageLocationsResponseEnvelopeJSON contains the JSON metadata for the +// struct [AnnotationOutageLocationsResponseEnvelope] +type annotationOutageLocationsResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnnotationOutageLocationsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r annotationOutageLocationsResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/annotationoutage_test.go b/radar/annotationoutage_test.go new file mode 100644 index 00000000000..f46a728a07e --- /dev/null +++ b/radar/annotationoutage_test.go @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestAnnotationOutageGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Annotations.Outages.Get(context.TODO(), radar.AnnotationOutageGetParams{ + ASN: cloudflare.F(int64(0)), + DateEnd: cloudflare.F(time.Now()), + DateRange: cloudflare.F(radar.AnnotationOutageGetParamsDateRange7d), + DateStart: cloudflare.F(time.Now()), + Format: cloudflare.F(radar.AnnotationOutageGetParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F("US"), + Offset: cloudflare.F(int64(0)), + }) + 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 TestAnnotationOutageLocationsWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Annotations.Outages.Locations(context.TODO(), radar.AnnotationOutageLocationsParams{ + DateEnd: cloudflare.F(time.Now()), + DateRange: cloudflare.F(radar.AnnotationOutageLocationsParamsDateRange7d), + DateStart: cloudflare.F(time.Now()), + Format: cloudflare.F(radar.AnnotationOutageLocationsParamsFormatJson), + Limit: cloudflare.F(int64(5)), + }) + 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/radar/as112.go b/radar/as112.go new file mode 100644 index 00000000000..47a35fcd988 --- /dev/null +++ b/radar/as112.go @@ -0,0 +1,308 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AS112Service 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 [NewAS112Service] method instead. +type AS112Service struct { + Options []option.RequestOption + Summary *AS112SummaryService + TimeseriesGroups *AS112TimeseriesGroupService + Top *AS112TopService +} + +// NewAS112Service 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 NewAS112Service(opts ...option.RequestOption) (r *AS112Service) { + r = &AS112Service{} + r.Options = opts + r.Summary = NewAS112SummaryService(opts...) + r.TimeseriesGroups = NewAS112TimeseriesGroupService(opts...) + r.Top = NewAS112TopService(opts...) + return +} + +// Get AS112 queries change over time. +func (r *AS112Service) Timeseries(ctx context.Context, query AS112TimeseriesParams, opts ...option.RequestOption) (res *AS112TimeseriesResponse, err error) { + opts = append(r.Options[:], opts...) + var env AS112TimeseriesResponseEnvelope + path := "radar/as112/timeseries" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AS112TimeseriesResponse struct { + Meta AS112TimeseriesResponseMeta `json:"meta,required"` + Serie0 AS112TimeseriesResponseSerie0 `json:"serie_0,required"` + JSON as112TimeseriesResponseJSON `json:"-"` +} + +// as112TimeseriesResponseJSON contains the JSON metadata for the struct +// [AS112TimeseriesResponse] +type as112TimeseriesResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesResponseJSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesResponseMeta struct { + AggInterval string `json:"aggInterval,required"` + DateRange []AS112TimeseriesResponseMetaDateRange `json:"dateRange,required"` + LastUpdated time.Time `json:"lastUpdated,required" format:"date-time"` + ConfidenceInfo AS112TimeseriesResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON as112TimeseriesResponseMetaJSON `json:"-"` +} + +// as112TimeseriesResponseMetaJSON contains the JSON metadata for the struct +// [AS112TimeseriesResponseMeta] +type as112TimeseriesResponseMetaJSON struct { + AggInterval apijson.Field + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON as112TimeseriesResponseMetaDateRangeJSON `json:"-"` +} + +// as112TimeseriesResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [AS112TimeseriesResponseMetaDateRange] +type as112TimeseriesResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesResponseMetaConfidenceInfo struct { + Annotations []AS112TimeseriesResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON as112TimeseriesResponseMetaConfidenceInfoJSON `json:"-"` +} + +// as112TimeseriesResponseMetaConfidenceInfoJSON contains the JSON metadata for the +// struct [AS112TimeseriesResponseMetaConfidenceInfo] +type as112TimeseriesResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON as112TimeseriesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// as112TimeseriesResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct [AS112TimeseriesResponseMetaConfidenceInfoAnnotation] +type as112TimeseriesResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesResponseSerie0 struct { + Timestamps []time.Time `json:"timestamps,required" format:"date-time"` + Values []string `json:"values,required"` + JSON as112TimeseriesResponseSerie0JSON `json:"-"` +} + +// as112TimeseriesResponseSerie0JSON contains the JSON metadata for the struct +// [AS112TimeseriesResponseSerie0] +type as112TimeseriesResponseSerie0JSON struct { + Timestamps apijson.Field + Values apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AS112TimeseriesParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AS112TimeseriesParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AS112TimeseriesParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AS112TimeseriesParams]'s query parameters as `url.Values`. +func (r AS112TimeseriesParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AS112TimeseriesParamsAggInterval string + +const ( + AS112TimeseriesParamsAggInterval15m AS112TimeseriesParamsAggInterval = "15m" + AS112TimeseriesParamsAggInterval1h AS112TimeseriesParamsAggInterval = "1h" + AS112TimeseriesParamsAggInterval1d AS112TimeseriesParamsAggInterval = "1d" + AS112TimeseriesParamsAggInterval1w AS112TimeseriesParamsAggInterval = "1w" +) + +type AS112TimeseriesParamsDateRange string + +const ( + AS112TimeseriesParamsDateRange1d AS112TimeseriesParamsDateRange = "1d" + AS112TimeseriesParamsDateRange2d AS112TimeseriesParamsDateRange = "2d" + AS112TimeseriesParamsDateRange7d AS112TimeseriesParamsDateRange = "7d" + AS112TimeseriesParamsDateRange14d AS112TimeseriesParamsDateRange = "14d" + AS112TimeseriesParamsDateRange28d AS112TimeseriesParamsDateRange = "28d" + AS112TimeseriesParamsDateRange12w AS112TimeseriesParamsDateRange = "12w" + AS112TimeseriesParamsDateRange24w AS112TimeseriesParamsDateRange = "24w" + AS112TimeseriesParamsDateRange52w AS112TimeseriesParamsDateRange = "52w" + AS112TimeseriesParamsDateRange1dControl AS112TimeseriesParamsDateRange = "1dControl" + AS112TimeseriesParamsDateRange2dControl AS112TimeseriesParamsDateRange = "2dControl" + AS112TimeseriesParamsDateRange7dControl AS112TimeseriesParamsDateRange = "7dControl" + AS112TimeseriesParamsDateRange14dControl AS112TimeseriesParamsDateRange = "14dControl" + AS112TimeseriesParamsDateRange28dControl AS112TimeseriesParamsDateRange = "28dControl" + AS112TimeseriesParamsDateRange12wControl AS112TimeseriesParamsDateRange = "12wControl" + AS112TimeseriesParamsDateRange24wControl AS112TimeseriesParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AS112TimeseriesParamsFormat string + +const ( + AS112TimeseriesParamsFormatJson AS112TimeseriesParamsFormat = "JSON" + AS112TimeseriesParamsFormatCsv AS112TimeseriesParamsFormat = "CSV" +) + +type AS112TimeseriesResponseEnvelope struct { + Result AS112TimeseriesResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON as112TimeseriesResponseEnvelopeJSON `json:"-"` +} + +// as112TimeseriesResponseEnvelopeJSON contains the JSON metadata for the struct +// [AS112TimeseriesResponseEnvelope] +type as112TimeseriesResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/as112_test.go b/radar/as112_test.go new file mode 100644 index 00000000000..b9980ee1df3 --- /dev/null +++ b/radar/as112_test.go @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestAS112TimeseriesWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.AS112.Timeseries(context.TODO(), radar.AS112TimeseriesParams{ + AggInterval: cloudflare.F(radar.AS112TimeseriesParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AS112TimeseriesParamsDateRange{radar.AS112TimeseriesParamsDateRange1d, radar.AS112TimeseriesParamsDateRange2d, radar.AS112TimeseriesParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AS112TimeseriesParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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/radar/as112summary.go b/radar/as112summary.go new file mode 100644 index 00000000000..79f5eaa7797 --- /dev/null +++ b/radar/as112summary.go @@ -0,0 +1,1567 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AS112SummaryService 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 [NewAS112SummaryService] method +// instead. +type AS112SummaryService struct { + Options []option.RequestOption +} + +// NewAS112SummaryService 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 NewAS112SummaryService(opts ...option.RequestOption) (r *AS112SummaryService) { + r = &AS112SummaryService{} + r.Options = opts + return +} + +// Percentage distribution of DNS queries to AS112 by DNSSEC support. +func (r *AS112SummaryService) DNSSEC(ctx context.Context, query AS112SummaryDNSSECParams, opts ...option.RequestOption) (res *AS112SummaryDNSSECResponse, err error) { + opts = append(r.Options[:], opts...) + var env AS112SummaryDNSSECResponseEnvelope + path := "radar/as112/summary/dnssec" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of DNS queries, to AS112, by EDNS support. +func (r *AS112SummaryService) Edns(ctx context.Context, query AS112SummaryEdnsParams, opts ...option.RequestOption) (res *AS112SummaryEdnsResponse, err error) { + opts = append(r.Options[:], opts...) + var env AS112SummaryEdnsResponseEnvelope + path := "radar/as112/summary/edns" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of DNS queries to AS112 per IP Version. +func (r *AS112SummaryService) IPVersion(ctx context.Context, query AS112SummaryIPVersionParams, opts ...option.RequestOption) (res *AS112SummaryIPVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env AS112SummaryIPVersionResponseEnvelope + path := "radar/as112/summary/ip_version" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of DNS queries to AS112 per protocol. +func (r *AS112SummaryService) Protocol(ctx context.Context, query AS112SummaryProtocolParams, opts ...option.RequestOption) (res *AS112SummaryProtocolResponse, err error) { + opts = append(r.Options[:], opts...) + var env AS112SummaryProtocolResponseEnvelope + path := "radar/as112/summary/protocol" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of DNS queries to AS112 by Query Type. +func (r *AS112SummaryService) QueryType(ctx context.Context, query AS112SummaryQueryTypeParams, opts ...option.RequestOption) (res *AS112SummaryQueryTypeResponse, err error) { + opts = append(r.Options[:], opts...) + var env AS112SummaryQueryTypeResponseEnvelope + path := "radar/as112/summary/query_type" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of AS112 dns requests classified per Response Codes. +func (r *AS112SummaryService) ResponseCodes(ctx context.Context, query AS112SummaryResponseCodesParams, opts ...option.RequestOption) (res *AS112SummaryResponseCodesResponse, err error) { + opts = append(r.Options[:], opts...) + var env AS112SummaryResponseCodesResponseEnvelope + path := "radar/as112/summary/response_codes" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AS112SummaryDNSSECResponse struct { + Meta AS112SummaryDNSSECResponseMeta `json:"meta,required"` + Summary0 AS112SummaryDNSSECResponseSummary0 `json:"summary_0,required"` + JSON as112SummaryDNSSECResponseJSON `json:"-"` +} + +// as112SummaryDNSSECResponseJSON contains the JSON metadata for the struct +// [AS112SummaryDNSSECResponse] +type as112SummaryDNSSECResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryDNSSECResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryDNSSECResponseJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryDNSSECResponseMeta struct { + DateRange []AS112SummaryDNSSECResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo AS112SummaryDNSSECResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON as112SummaryDNSSECResponseMetaJSON `json:"-"` +} + +// as112SummaryDNSSECResponseMetaJSON contains the JSON metadata for the struct +// [AS112SummaryDNSSECResponseMeta] +type as112SummaryDNSSECResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryDNSSECResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryDNSSECResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryDNSSECResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON as112SummaryDNSSECResponseMetaDateRangeJSON `json:"-"` +} + +// as112SummaryDNSSECResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [AS112SummaryDNSSECResponseMetaDateRange] +type as112SummaryDNSSECResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryDNSSECResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryDNSSECResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryDNSSECResponseMetaConfidenceInfo struct { + Annotations []AS112SummaryDNSSECResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON as112SummaryDNSSECResponseMetaConfidenceInfoJSON `json:"-"` +} + +// as112SummaryDNSSECResponseMetaConfidenceInfoJSON contains the JSON metadata for +// the struct [AS112SummaryDNSSECResponseMetaConfidenceInfo] +type as112SummaryDNSSECResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryDNSSECResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryDNSSECResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryDNSSECResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON as112SummaryDNSSECResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// as112SummaryDNSSECResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct [AS112SummaryDNSSECResponseMetaConfidenceInfoAnnotation] +type as112SummaryDNSSECResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryDNSSECResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryDNSSECResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryDNSSECResponseSummary0 struct { + NotSupported string `json:"NOT_SUPPORTED,required"` + Supported string `json:"SUPPORTED,required"` + JSON as112SummaryDNSSECResponseSummary0JSON `json:"-"` +} + +// as112SummaryDNSSECResponseSummary0JSON contains the JSON metadata for the struct +// [AS112SummaryDNSSECResponseSummary0] +type as112SummaryDNSSECResponseSummary0JSON struct { + NotSupported apijson.Field + Supported apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryDNSSECResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryDNSSECResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type AS112SummaryEdnsResponse struct { + Meta AS112SummaryEdnsResponseMeta `json:"meta,required"` + Summary0 AS112SummaryEdnsResponseSummary0 `json:"summary_0,required"` + JSON as112SummaryEdnsResponseJSON `json:"-"` +} + +// as112SummaryEdnsResponseJSON contains the JSON metadata for the struct +// [AS112SummaryEdnsResponse] +type as112SummaryEdnsResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryEdnsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryEdnsResponseJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryEdnsResponseMeta struct { + DateRange []AS112SummaryEdnsResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo AS112SummaryEdnsResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON as112SummaryEdnsResponseMetaJSON `json:"-"` +} + +// as112SummaryEdnsResponseMetaJSON contains the JSON metadata for the struct +// [AS112SummaryEdnsResponseMeta] +type as112SummaryEdnsResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryEdnsResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryEdnsResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryEdnsResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON as112SummaryEdnsResponseMetaDateRangeJSON `json:"-"` +} + +// as112SummaryEdnsResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [AS112SummaryEdnsResponseMetaDateRange] +type as112SummaryEdnsResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryEdnsResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryEdnsResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryEdnsResponseMetaConfidenceInfo struct { + Annotations []AS112SummaryEdnsResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON as112SummaryEdnsResponseMetaConfidenceInfoJSON `json:"-"` +} + +// as112SummaryEdnsResponseMetaConfidenceInfoJSON contains the JSON metadata for +// the struct [AS112SummaryEdnsResponseMetaConfidenceInfo] +type as112SummaryEdnsResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryEdnsResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryEdnsResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryEdnsResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON as112SummaryEdnsResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// as112SummaryEdnsResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct [AS112SummaryEdnsResponseMetaConfidenceInfoAnnotation] +type as112SummaryEdnsResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryEdnsResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryEdnsResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryEdnsResponseSummary0 struct { + NotSupported string `json:"NOT_SUPPORTED,required"` + Supported string `json:"SUPPORTED,required"` + JSON as112SummaryEdnsResponseSummary0JSON `json:"-"` +} + +// as112SummaryEdnsResponseSummary0JSON contains the JSON metadata for the struct +// [AS112SummaryEdnsResponseSummary0] +type as112SummaryEdnsResponseSummary0JSON struct { + NotSupported apijson.Field + Supported apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryEdnsResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryEdnsResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type AS112SummaryIPVersionResponse struct { + Meta AS112SummaryIPVersionResponseMeta `json:"meta,required"` + Summary0 AS112SummaryIPVersionResponseSummary0 `json:"summary_0,required"` + JSON as112SummaryIPVersionResponseJSON `json:"-"` +} + +// as112SummaryIPVersionResponseJSON contains the JSON metadata for the struct +// [AS112SummaryIPVersionResponse] +type as112SummaryIPVersionResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryIPVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryIPVersionResponseJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryIPVersionResponseMeta struct { + DateRange []AS112SummaryIPVersionResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo AS112SummaryIPVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON as112SummaryIPVersionResponseMetaJSON `json:"-"` +} + +// as112SummaryIPVersionResponseMetaJSON contains the JSON metadata for the struct +// [AS112SummaryIPVersionResponseMeta] +type as112SummaryIPVersionResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryIPVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryIPVersionResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryIPVersionResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON as112SummaryIPVersionResponseMetaDateRangeJSON `json:"-"` +} + +// as112SummaryIPVersionResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [AS112SummaryIPVersionResponseMetaDateRange] +type as112SummaryIPVersionResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryIPVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryIPVersionResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryIPVersionResponseMetaConfidenceInfo struct { + Annotations []AS112SummaryIPVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON as112SummaryIPVersionResponseMetaConfidenceInfoJSON `json:"-"` +} + +// as112SummaryIPVersionResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [AS112SummaryIPVersionResponseMetaConfidenceInfo] +type as112SummaryIPVersionResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryIPVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryIPVersionResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryIPVersionResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON as112SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// as112SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [AS112SummaryIPVersionResponseMetaConfidenceInfoAnnotation] +type as112SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryIPVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryIPVersionResponseSummary0 struct { + IPv4 string `json:"IPv4,required"` + IPv6 string `json:"IPv6,required"` + JSON as112SummaryIPVersionResponseSummary0JSON `json:"-"` +} + +// as112SummaryIPVersionResponseSummary0JSON contains the JSON metadata for the +// struct [AS112SummaryIPVersionResponseSummary0] +type as112SummaryIPVersionResponseSummary0JSON struct { + IPv4 apijson.Field + IPv6 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryIPVersionResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryIPVersionResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type AS112SummaryProtocolResponse struct { + Meta AS112SummaryProtocolResponseMeta `json:"meta,required"` + Summary0 AS112SummaryProtocolResponseSummary0 `json:"summary_0,required"` + JSON as112SummaryProtocolResponseJSON `json:"-"` +} + +// as112SummaryProtocolResponseJSON contains the JSON metadata for the struct +// [AS112SummaryProtocolResponse] +type as112SummaryProtocolResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryProtocolResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryProtocolResponseJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryProtocolResponseMeta struct { + DateRange []AS112SummaryProtocolResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo AS112SummaryProtocolResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON as112SummaryProtocolResponseMetaJSON `json:"-"` +} + +// as112SummaryProtocolResponseMetaJSON contains the JSON metadata for the struct +// [AS112SummaryProtocolResponseMeta] +type as112SummaryProtocolResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryProtocolResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryProtocolResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryProtocolResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON as112SummaryProtocolResponseMetaDateRangeJSON `json:"-"` +} + +// as112SummaryProtocolResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [AS112SummaryProtocolResponseMetaDateRange] +type as112SummaryProtocolResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryProtocolResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryProtocolResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryProtocolResponseMetaConfidenceInfo struct { + Annotations []AS112SummaryProtocolResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON as112SummaryProtocolResponseMetaConfidenceInfoJSON `json:"-"` +} + +// as112SummaryProtocolResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [AS112SummaryProtocolResponseMetaConfidenceInfo] +type as112SummaryProtocolResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryProtocolResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryProtocolResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryProtocolResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON as112SummaryProtocolResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// as112SummaryProtocolResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [AS112SummaryProtocolResponseMetaConfidenceInfoAnnotation] +type as112SummaryProtocolResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryProtocolResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryProtocolResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryProtocolResponseSummary0 struct { + Tcp string `json:"tcp,required"` + Udp string `json:"udp,required"` + JSON as112SummaryProtocolResponseSummary0JSON `json:"-"` +} + +// as112SummaryProtocolResponseSummary0JSON contains the JSON metadata for the +// struct [AS112SummaryProtocolResponseSummary0] +type as112SummaryProtocolResponseSummary0JSON struct { + Tcp apijson.Field + Udp apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryProtocolResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryProtocolResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type AS112SummaryQueryTypeResponse struct { + Meta AS112SummaryQueryTypeResponseMeta `json:"meta,required"` + Summary0 AS112SummaryQueryTypeResponseSummary0 `json:"summary_0,required"` + JSON as112SummaryQueryTypeResponseJSON `json:"-"` +} + +// as112SummaryQueryTypeResponseJSON contains the JSON metadata for the struct +// [AS112SummaryQueryTypeResponse] +type as112SummaryQueryTypeResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryQueryTypeResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryQueryTypeResponseJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryQueryTypeResponseMeta struct { + DateRange []AS112SummaryQueryTypeResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo AS112SummaryQueryTypeResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON as112SummaryQueryTypeResponseMetaJSON `json:"-"` +} + +// as112SummaryQueryTypeResponseMetaJSON contains the JSON metadata for the struct +// [AS112SummaryQueryTypeResponseMeta] +type as112SummaryQueryTypeResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryQueryTypeResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryQueryTypeResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryQueryTypeResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON as112SummaryQueryTypeResponseMetaDateRangeJSON `json:"-"` +} + +// as112SummaryQueryTypeResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [AS112SummaryQueryTypeResponseMetaDateRange] +type as112SummaryQueryTypeResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryQueryTypeResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryQueryTypeResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryQueryTypeResponseMetaConfidenceInfo struct { + Annotations []AS112SummaryQueryTypeResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON as112SummaryQueryTypeResponseMetaConfidenceInfoJSON `json:"-"` +} + +// as112SummaryQueryTypeResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [AS112SummaryQueryTypeResponseMetaConfidenceInfo] +type as112SummaryQueryTypeResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryQueryTypeResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryQueryTypeResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryQueryTypeResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON as112SummaryQueryTypeResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// as112SummaryQueryTypeResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [AS112SummaryQueryTypeResponseMetaConfidenceInfoAnnotation] +type as112SummaryQueryTypeResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryQueryTypeResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryQueryTypeResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryQueryTypeResponseSummary0 struct { + A string `json:"A,required"` + AAAA string `json:"AAAA,required"` + PTR string `json:"PTR,required"` + Soa string `json:"SOA,required"` + SRV string `json:"SRV,required"` + JSON as112SummaryQueryTypeResponseSummary0JSON `json:"-"` +} + +// as112SummaryQueryTypeResponseSummary0JSON contains the JSON metadata for the +// struct [AS112SummaryQueryTypeResponseSummary0] +type as112SummaryQueryTypeResponseSummary0JSON struct { + A apijson.Field + AAAA apijson.Field + PTR apijson.Field + Soa apijson.Field + SRV apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryQueryTypeResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryQueryTypeResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type AS112SummaryResponseCodesResponse struct { + Meta AS112SummaryResponseCodesResponseMeta `json:"meta,required"` + Summary0 AS112SummaryResponseCodesResponseSummary0 `json:"summary_0,required"` + JSON as112SummaryResponseCodesResponseJSON `json:"-"` +} + +// as112SummaryResponseCodesResponseJSON contains the JSON metadata for the struct +// [AS112SummaryResponseCodesResponse] +type as112SummaryResponseCodesResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryResponseCodesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryResponseCodesResponseJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryResponseCodesResponseMeta struct { + DateRange []AS112SummaryResponseCodesResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo AS112SummaryResponseCodesResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON as112SummaryResponseCodesResponseMetaJSON `json:"-"` +} + +// as112SummaryResponseCodesResponseMetaJSON contains the JSON metadata for the +// struct [AS112SummaryResponseCodesResponseMeta] +type as112SummaryResponseCodesResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryResponseCodesResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryResponseCodesResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryResponseCodesResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON as112SummaryResponseCodesResponseMetaDateRangeJSON `json:"-"` +} + +// as112SummaryResponseCodesResponseMetaDateRangeJSON contains the JSON metadata +// for the struct [AS112SummaryResponseCodesResponseMetaDateRange] +type as112SummaryResponseCodesResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryResponseCodesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryResponseCodesResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryResponseCodesResponseMetaConfidenceInfo struct { + Annotations []AS112SummaryResponseCodesResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON as112SummaryResponseCodesResponseMetaConfidenceInfoJSON `json:"-"` +} + +// as112SummaryResponseCodesResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [AS112SummaryResponseCodesResponseMetaConfidenceInfo] +type as112SummaryResponseCodesResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryResponseCodesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryResponseCodesResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryResponseCodesResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON as112SummaryResponseCodesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// as112SummaryResponseCodesResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [AS112SummaryResponseCodesResponseMetaConfidenceInfoAnnotation] +type as112SummaryResponseCodesResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryResponseCodesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryResponseCodesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryResponseCodesResponseSummary0 struct { + Noerror string `json:"NOERROR,required"` + Nxdomain string `json:"NXDOMAIN,required"` + JSON as112SummaryResponseCodesResponseSummary0JSON `json:"-"` +} + +// as112SummaryResponseCodesResponseSummary0JSON contains the JSON metadata for the +// struct [AS112SummaryResponseCodesResponseSummary0] +type as112SummaryResponseCodesResponseSummary0JSON struct { + Noerror apijson.Field + Nxdomain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryResponseCodesResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryResponseCodesResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type AS112SummaryDNSSECParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AS112SummaryDNSSECParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AS112SummaryDNSSECParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AS112SummaryDNSSECParams]'s query parameters as +// `url.Values`. +func (r AS112SummaryDNSSECParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AS112SummaryDNSSECParamsDateRange string + +const ( + AS112SummaryDNSSECParamsDateRange1d AS112SummaryDNSSECParamsDateRange = "1d" + AS112SummaryDNSSECParamsDateRange2d AS112SummaryDNSSECParamsDateRange = "2d" + AS112SummaryDNSSECParamsDateRange7d AS112SummaryDNSSECParamsDateRange = "7d" + AS112SummaryDNSSECParamsDateRange14d AS112SummaryDNSSECParamsDateRange = "14d" + AS112SummaryDNSSECParamsDateRange28d AS112SummaryDNSSECParamsDateRange = "28d" + AS112SummaryDNSSECParamsDateRange12w AS112SummaryDNSSECParamsDateRange = "12w" + AS112SummaryDNSSECParamsDateRange24w AS112SummaryDNSSECParamsDateRange = "24w" + AS112SummaryDNSSECParamsDateRange52w AS112SummaryDNSSECParamsDateRange = "52w" + AS112SummaryDNSSECParamsDateRange1dControl AS112SummaryDNSSECParamsDateRange = "1dControl" + AS112SummaryDNSSECParamsDateRange2dControl AS112SummaryDNSSECParamsDateRange = "2dControl" + AS112SummaryDNSSECParamsDateRange7dControl AS112SummaryDNSSECParamsDateRange = "7dControl" + AS112SummaryDNSSECParamsDateRange14dControl AS112SummaryDNSSECParamsDateRange = "14dControl" + AS112SummaryDNSSECParamsDateRange28dControl AS112SummaryDNSSECParamsDateRange = "28dControl" + AS112SummaryDNSSECParamsDateRange12wControl AS112SummaryDNSSECParamsDateRange = "12wControl" + AS112SummaryDNSSECParamsDateRange24wControl AS112SummaryDNSSECParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AS112SummaryDNSSECParamsFormat string + +const ( + AS112SummaryDNSSECParamsFormatJson AS112SummaryDNSSECParamsFormat = "JSON" + AS112SummaryDNSSECParamsFormatCsv AS112SummaryDNSSECParamsFormat = "CSV" +) + +type AS112SummaryDNSSECResponseEnvelope struct { + Result AS112SummaryDNSSECResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON as112SummaryDNSSECResponseEnvelopeJSON `json:"-"` +} + +// as112SummaryDNSSECResponseEnvelopeJSON contains the JSON metadata for the struct +// [AS112SummaryDNSSECResponseEnvelope] +type as112SummaryDNSSECResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryDNSSECResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryDNSSECResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryEdnsParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AS112SummaryEdnsParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AS112SummaryEdnsParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AS112SummaryEdnsParams]'s query parameters as `url.Values`. +func (r AS112SummaryEdnsParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AS112SummaryEdnsParamsDateRange string + +const ( + AS112SummaryEdnsParamsDateRange1d AS112SummaryEdnsParamsDateRange = "1d" + AS112SummaryEdnsParamsDateRange2d AS112SummaryEdnsParamsDateRange = "2d" + AS112SummaryEdnsParamsDateRange7d AS112SummaryEdnsParamsDateRange = "7d" + AS112SummaryEdnsParamsDateRange14d AS112SummaryEdnsParamsDateRange = "14d" + AS112SummaryEdnsParamsDateRange28d AS112SummaryEdnsParamsDateRange = "28d" + AS112SummaryEdnsParamsDateRange12w AS112SummaryEdnsParamsDateRange = "12w" + AS112SummaryEdnsParamsDateRange24w AS112SummaryEdnsParamsDateRange = "24w" + AS112SummaryEdnsParamsDateRange52w AS112SummaryEdnsParamsDateRange = "52w" + AS112SummaryEdnsParamsDateRange1dControl AS112SummaryEdnsParamsDateRange = "1dControl" + AS112SummaryEdnsParamsDateRange2dControl AS112SummaryEdnsParamsDateRange = "2dControl" + AS112SummaryEdnsParamsDateRange7dControl AS112SummaryEdnsParamsDateRange = "7dControl" + AS112SummaryEdnsParamsDateRange14dControl AS112SummaryEdnsParamsDateRange = "14dControl" + AS112SummaryEdnsParamsDateRange28dControl AS112SummaryEdnsParamsDateRange = "28dControl" + AS112SummaryEdnsParamsDateRange12wControl AS112SummaryEdnsParamsDateRange = "12wControl" + AS112SummaryEdnsParamsDateRange24wControl AS112SummaryEdnsParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AS112SummaryEdnsParamsFormat string + +const ( + AS112SummaryEdnsParamsFormatJson AS112SummaryEdnsParamsFormat = "JSON" + AS112SummaryEdnsParamsFormatCsv AS112SummaryEdnsParamsFormat = "CSV" +) + +type AS112SummaryEdnsResponseEnvelope struct { + Result AS112SummaryEdnsResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON as112SummaryEdnsResponseEnvelopeJSON `json:"-"` +} + +// as112SummaryEdnsResponseEnvelopeJSON contains the JSON metadata for the struct +// [AS112SummaryEdnsResponseEnvelope] +type as112SummaryEdnsResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryEdnsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryEdnsResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryIPVersionParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AS112SummaryIPVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AS112SummaryIPVersionParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AS112SummaryIPVersionParams]'s query parameters as +// `url.Values`. +func (r AS112SummaryIPVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AS112SummaryIPVersionParamsDateRange string + +const ( + AS112SummaryIPVersionParamsDateRange1d AS112SummaryIPVersionParamsDateRange = "1d" + AS112SummaryIPVersionParamsDateRange2d AS112SummaryIPVersionParamsDateRange = "2d" + AS112SummaryIPVersionParamsDateRange7d AS112SummaryIPVersionParamsDateRange = "7d" + AS112SummaryIPVersionParamsDateRange14d AS112SummaryIPVersionParamsDateRange = "14d" + AS112SummaryIPVersionParamsDateRange28d AS112SummaryIPVersionParamsDateRange = "28d" + AS112SummaryIPVersionParamsDateRange12w AS112SummaryIPVersionParamsDateRange = "12w" + AS112SummaryIPVersionParamsDateRange24w AS112SummaryIPVersionParamsDateRange = "24w" + AS112SummaryIPVersionParamsDateRange52w AS112SummaryIPVersionParamsDateRange = "52w" + AS112SummaryIPVersionParamsDateRange1dControl AS112SummaryIPVersionParamsDateRange = "1dControl" + AS112SummaryIPVersionParamsDateRange2dControl AS112SummaryIPVersionParamsDateRange = "2dControl" + AS112SummaryIPVersionParamsDateRange7dControl AS112SummaryIPVersionParamsDateRange = "7dControl" + AS112SummaryIPVersionParamsDateRange14dControl AS112SummaryIPVersionParamsDateRange = "14dControl" + AS112SummaryIPVersionParamsDateRange28dControl AS112SummaryIPVersionParamsDateRange = "28dControl" + AS112SummaryIPVersionParamsDateRange12wControl AS112SummaryIPVersionParamsDateRange = "12wControl" + AS112SummaryIPVersionParamsDateRange24wControl AS112SummaryIPVersionParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AS112SummaryIPVersionParamsFormat string + +const ( + AS112SummaryIPVersionParamsFormatJson AS112SummaryIPVersionParamsFormat = "JSON" + AS112SummaryIPVersionParamsFormatCsv AS112SummaryIPVersionParamsFormat = "CSV" +) + +type AS112SummaryIPVersionResponseEnvelope struct { + Result AS112SummaryIPVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON as112SummaryIPVersionResponseEnvelopeJSON `json:"-"` +} + +// as112SummaryIPVersionResponseEnvelopeJSON contains the JSON metadata for the +// struct [AS112SummaryIPVersionResponseEnvelope] +type as112SummaryIPVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryIPVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryProtocolParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AS112SummaryProtocolParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AS112SummaryProtocolParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AS112SummaryProtocolParams]'s query parameters as +// `url.Values`. +func (r AS112SummaryProtocolParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AS112SummaryProtocolParamsDateRange string + +const ( + AS112SummaryProtocolParamsDateRange1d AS112SummaryProtocolParamsDateRange = "1d" + AS112SummaryProtocolParamsDateRange2d AS112SummaryProtocolParamsDateRange = "2d" + AS112SummaryProtocolParamsDateRange7d AS112SummaryProtocolParamsDateRange = "7d" + AS112SummaryProtocolParamsDateRange14d AS112SummaryProtocolParamsDateRange = "14d" + AS112SummaryProtocolParamsDateRange28d AS112SummaryProtocolParamsDateRange = "28d" + AS112SummaryProtocolParamsDateRange12w AS112SummaryProtocolParamsDateRange = "12w" + AS112SummaryProtocolParamsDateRange24w AS112SummaryProtocolParamsDateRange = "24w" + AS112SummaryProtocolParamsDateRange52w AS112SummaryProtocolParamsDateRange = "52w" + AS112SummaryProtocolParamsDateRange1dControl AS112SummaryProtocolParamsDateRange = "1dControl" + AS112SummaryProtocolParamsDateRange2dControl AS112SummaryProtocolParamsDateRange = "2dControl" + AS112SummaryProtocolParamsDateRange7dControl AS112SummaryProtocolParamsDateRange = "7dControl" + AS112SummaryProtocolParamsDateRange14dControl AS112SummaryProtocolParamsDateRange = "14dControl" + AS112SummaryProtocolParamsDateRange28dControl AS112SummaryProtocolParamsDateRange = "28dControl" + AS112SummaryProtocolParamsDateRange12wControl AS112SummaryProtocolParamsDateRange = "12wControl" + AS112SummaryProtocolParamsDateRange24wControl AS112SummaryProtocolParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AS112SummaryProtocolParamsFormat string + +const ( + AS112SummaryProtocolParamsFormatJson AS112SummaryProtocolParamsFormat = "JSON" + AS112SummaryProtocolParamsFormatCsv AS112SummaryProtocolParamsFormat = "CSV" +) + +type AS112SummaryProtocolResponseEnvelope struct { + Result AS112SummaryProtocolResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON as112SummaryProtocolResponseEnvelopeJSON `json:"-"` +} + +// as112SummaryProtocolResponseEnvelopeJSON contains the JSON metadata for the +// struct [AS112SummaryProtocolResponseEnvelope] +type as112SummaryProtocolResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryProtocolResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryProtocolResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryQueryTypeParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AS112SummaryQueryTypeParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AS112SummaryQueryTypeParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AS112SummaryQueryTypeParams]'s query parameters as +// `url.Values`. +func (r AS112SummaryQueryTypeParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AS112SummaryQueryTypeParamsDateRange string + +const ( + AS112SummaryQueryTypeParamsDateRange1d AS112SummaryQueryTypeParamsDateRange = "1d" + AS112SummaryQueryTypeParamsDateRange2d AS112SummaryQueryTypeParamsDateRange = "2d" + AS112SummaryQueryTypeParamsDateRange7d AS112SummaryQueryTypeParamsDateRange = "7d" + AS112SummaryQueryTypeParamsDateRange14d AS112SummaryQueryTypeParamsDateRange = "14d" + AS112SummaryQueryTypeParamsDateRange28d AS112SummaryQueryTypeParamsDateRange = "28d" + AS112SummaryQueryTypeParamsDateRange12w AS112SummaryQueryTypeParamsDateRange = "12w" + AS112SummaryQueryTypeParamsDateRange24w AS112SummaryQueryTypeParamsDateRange = "24w" + AS112SummaryQueryTypeParamsDateRange52w AS112SummaryQueryTypeParamsDateRange = "52w" + AS112SummaryQueryTypeParamsDateRange1dControl AS112SummaryQueryTypeParamsDateRange = "1dControl" + AS112SummaryQueryTypeParamsDateRange2dControl AS112SummaryQueryTypeParamsDateRange = "2dControl" + AS112SummaryQueryTypeParamsDateRange7dControl AS112SummaryQueryTypeParamsDateRange = "7dControl" + AS112SummaryQueryTypeParamsDateRange14dControl AS112SummaryQueryTypeParamsDateRange = "14dControl" + AS112SummaryQueryTypeParamsDateRange28dControl AS112SummaryQueryTypeParamsDateRange = "28dControl" + AS112SummaryQueryTypeParamsDateRange12wControl AS112SummaryQueryTypeParamsDateRange = "12wControl" + AS112SummaryQueryTypeParamsDateRange24wControl AS112SummaryQueryTypeParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AS112SummaryQueryTypeParamsFormat string + +const ( + AS112SummaryQueryTypeParamsFormatJson AS112SummaryQueryTypeParamsFormat = "JSON" + AS112SummaryQueryTypeParamsFormatCsv AS112SummaryQueryTypeParamsFormat = "CSV" +) + +type AS112SummaryQueryTypeResponseEnvelope struct { + Result AS112SummaryQueryTypeResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON as112SummaryQueryTypeResponseEnvelopeJSON `json:"-"` +} + +// as112SummaryQueryTypeResponseEnvelopeJSON contains the JSON metadata for the +// struct [AS112SummaryQueryTypeResponseEnvelope] +type as112SummaryQueryTypeResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryQueryTypeResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryQueryTypeResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AS112SummaryResponseCodesParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AS112SummaryResponseCodesParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AS112SummaryResponseCodesParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AS112SummaryResponseCodesParams]'s query parameters as +// `url.Values`. +func (r AS112SummaryResponseCodesParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AS112SummaryResponseCodesParamsDateRange string + +const ( + AS112SummaryResponseCodesParamsDateRange1d AS112SummaryResponseCodesParamsDateRange = "1d" + AS112SummaryResponseCodesParamsDateRange2d AS112SummaryResponseCodesParamsDateRange = "2d" + AS112SummaryResponseCodesParamsDateRange7d AS112SummaryResponseCodesParamsDateRange = "7d" + AS112SummaryResponseCodesParamsDateRange14d AS112SummaryResponseCodesParamsDateRange = "14d" + AS112SummaryResponseCodesParamsDateRange28d AS112SummaryResponseCodesParamsDateRange = "28d" + AS112SummaryResponseCodesParamsDateRange12w AS112SummaryResponseCodesParamsDateRange = "12w" + AS112SummaryResponseCodesParamsDateRange24w AS112SummaryResponseCodesParamsDateRange = "24w" + AS112SummaryResponseCodesParamsDateRange52w AS112SummaryResponseCodesParamsDateRange = "52w" + AS112SummaryResponseCodesParamsDateRange1dControl AS112SummaryResponseCodesParamsDateRange = "1dControl" + AS112SummaryResponseCodesParamsDateRange2dControl AS112SummaryResponseCodesParamsDateRange = "2dControl" + AS112SummaryResponseCodesParamsDateRange7dControl AS112SummaryResponseCodesParamsDateRange = "7dControl" + AS112SummaryResponseCodesParamsDateRange14dControl AS112SummaryResponseCodesParamsDateRange = "14dControl" + AS112SummaryResponseCodesParamsDateRange28dControl AS112SummaryResponseCodesParamsDateRange = "28dControl" + AS112SummaryResponseCodesParamsDateRange12wControl AS112SummaryResponseCodesParamsDateRange = "12wControl" + AS112SummaryResponseCodesParamsDateRange24wControl AS112SummaryResponseCodesParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AS112SummaryResponseCodesParamsFormat string + +const ( + AS112SummaryResponseCodesParamsFormatJson AS112SummaryResponseCodesParamsFormat = "JSON" + AS112SummaryResponseCodesParamsFormatCsv AS112SummaryResponseCodesParamsFormat = "CSV" +) + +type AS112SummaryResponseCodesResponseEnvelope struct { + Result AS112SummaryResponseCodesResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON as112SummaryResponseCodesResponseEnvelopeJSON `json:"-"` +} + +// as112SummaryResponseCodesResponseEnvelopeJSON contains the JSON metadata for the +// struct [AS112SummaryResponseCodesResponseEnvelope] +type as112SummaryResponseCodesResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112SummaryResponseCodesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112SummaryResponseCodesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/as112summary_test.go b/radar/as112summary_test.go new file mode 100644 index 00000000000..d7e1ca2cb00 --- /dev/null +++ b/radar/as112summary_test.go @@ -0,0 +1,214 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestAS112SummaryDNSSECWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.AS112.Summary.DNSSEC(context.TODO(), radar.AS112SummaryDNSSECParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AS112SummaryDNSSECParamsDateRange{radar.AS112SummaryDNSSECParamsDateRange1d, radar.AS112SummaryDNSSECParamsDateRange2d, radar.AS112SummaryDNSSECParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AS112SummaryDNSSECParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAS112SummaryEdnsWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.AS112.Summary.Edns(context.TODO(), radar.AS112SummaryEdnsParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AS112SummaryEdnsParamsDateRange{radar.AS112SummaryEdnsParamsDateRange1d, radar.AS112SummaryEdnsParamsDateRange2d, radar.AS112SummaryEdnsParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AS112SummaryEdnsParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAS112SummaryIPVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.AS112.Summary.IPVersion(context.TODO(), radar.AS112SummaryIPVersionParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AS112SummaryIPVersionParamsDateRange{radar.AS112SummaryIPVersionParamsDateRange1d, radar.AS112SummaryIPVersionParamsDateRange2d, radar.AS112SummaryIPVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AS112SummaryIPVersionParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAS112SummaryProtocolWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.AS112.Summary.Protocol(context.TODO(), radar.AS112SummaryProtocolParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AS112SummaryProtocolParamsDateRange{radar.AS112SummaryProtocolParamsDateRange1d, radar.AS112SummaryProtocolParamsDateRange2d, radar.AS112SummaryProtocolParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AS112SummaryProtocolParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAS112SummaryQueryTypeWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.AS112.Summary.QueryType(context.TODO(), radar.AS112SummaryQueryTypeParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AS112SummaryQueryTypeParamsDateRange{radar.AS112SummaryQueryTypeParamsDateRange1d, radar.AS112SummaryQueryTypeParamsDateRange2d, radar.AS112SummaryQueryTypeParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AS112SummaryQueryTypeParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAS112SummaryResponseCodesWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.AS112.Summary.ResponseCodes(context.TODO(), radar.AS112SummaryResponseCodesParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AS112SummaryResponseCodesParamsDateRange{radar.AS112SummaryResponseCodesParamsDateRange1d, radar.AS112SummaryResponseCodesParamsDateRange2d, radar.AS112SummaryResponseCodesParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AS112SummaryResponseCodesParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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/radar/as112timeseriesgroup.go b/radar/as112timeseriesgroup.go new file mode 100644 index 00000000000..6102f731088 --- /dev/null +++ b/radar/as112timeseriesgroup.go @@ -0,0 +1,1013 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AS112TimeseriesGroupService 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 [NewAS112TimeseriesGroupService] +// method instead. +type AS112TimeseriesGroupService struct { + Options []option.RequestOption +} + +// NewAS112TimeseriesGroupService 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 NewAS112TimeseriesGroupService(opts ...option.RequestOption) (r *AS112TimeseriesGroupService) { + r = &AS112TimeseriesGroupService{} + r.Options = opts + return +} + +// Percentage distribution of DNS AS112 queries by DNSSEC support over time. +func (r *AS112TimeseriesGroupService) DNSSEC(ctx context.Context, query AS112TimeseriesGroupDNSSECParams, opts ...option.RequestOption) (res *AS112TimeseriesGroupDNSSECResponse, err error) { + opts = append(r.Options[:], opts...) + var env AS112TimeseriesGroupDNSSECResponseEnvelope + path := "radar/as112/timeseries_groups/dnssec" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of AS112 DNS queries by EDNS support over time. +func (r *AS112TimeseriesGroupService) Edns(ctx context.Context, query AS112TimeseriesGroupEdnsParams, opts ...option.RequestOption) (res *AS112TimeseriesGroupEdnsResponse, err error) { + opts = append(r.Options[:], opts...) + var env AS112TimeseriesGroupEdnsResponseEnvelope + path := "radar/as112/timeseries_groups/edns" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of AS112 DNS queries by IP Version over time. +func (r *AS112TimeseriesGroupService) IPVersion(ctx context.Context, query AS112TimeseriesGroupIPVersionParams, opts ...option.RequestOption) (res *AS112TimeseriesGroupIPVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env AS112TimeseriesGroupIPVersionResponseEnvelope + path := "radar/as112/timeseries_groups/ip_version" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of AS112 dns requests classified per Protocol over time. +func (r *AS112TimeseriesGroupService) Protocol(ctx context.Context, query AS112TimeseriesGroupProtocolParams, opts ...option.RequestOption) (res *AS112TimeseriesGroupProtocolResponse, err error) { + opts = append(r.Options[:], opts...) + var env AS112TimeseriesGroupProtocolResponseEnvelope + path := "radar/as112/timeseries_groups/protocol" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of AS112 DNS queries by Query Type over time. +func (r *AS112TimeseriesGroupService) QueryType(ctx context.Context, query AS112TimeseriesGroupQueryTypeParams, opts ...option.RequestOption) (res *AS112TimeseriesGroupQueryTypeResponse, err error) { + opts = append(r.Options[:], opts...) + var env AS112TimeseriesGroupQueryTypeResponseEnvelope + path := "radar/as112/timeseries_groups/query_type" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of AS112 dns requests classified per Response Codes over +// time. +func (r *AS112TimeseriesGroupService) ResponseCodes(ctx context.Context, query AS112TimeseriesGroupResponseCodesParams, opts ...option.RequestOption) (res *AS112TimeseriesGroupResponseCodesResponse, err error) { + opts = append(r.Options[:], opts...) + var env AS112TimeseriesGroupResponseCodesResponseEnvelope + path := "radar/as112/timeseries_groups/response_codes" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AS112TimeseriesGroupDNSSECResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AS112TimeseriesGroupDNSSECResponseSerie0 `json:"serie_0,required"` + JSON as112TimeseriesGroupDNSSECResponseJSON `json:"-"` +} + +// as112TimeseriesGroupDNSSECResponseJSON contains the JSON metadata for the struct +// [AS112TimeseriesGroupDNSSECResponse] +type as112TimeseriesGroupDNSSECResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesGroupDNSSECResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesGroupDNSSECResponseJSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesGroupDNSSECResponseSerie0 struct { + NotSupported []string `json:"NOT_SUPPORTED,required"` + Supported []string `json:"SUPPORTED,required"` + JSON as112TimeseriesGroupDNSSECResponseSerie0JSON `json:"-"` +} + +// as112TimeseriesGroupDNSSECResponseSerie0JSON contains the JSON metadata for the +// struct [AS112TimeseriesGroupDNSSECResponseSerie0] +type as112TimeseriesGroupDNSSECResponseSerie0JSON struct { + NotSupported apijson.Field + Supported apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesGroupDNSSECResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesGroupDNSSECResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesGroupEdnsResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AS112TimeseriesGroupEdnsResponseSerie0 `json:"serie_0,required"` + JSON as112TimeseriesGroupEdnsResponseJSON `json:"-"` +} + +// as112TimeseriesGroupEdnsResponseJSON contains the JSON metadata for the struct +// [AS112TimeseriesGroupEdnsResponse] +type as112TimeseriesGroupEdnsResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesGroupEdnsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesGroupEdnsResponseJSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesGroupEdnsResponseSerie0 struct { + NotSupported []string `json:"NOT_SUPPORTED,required"` + Supported []string `json:"SUPPORTED,required"` + JSON as112TimeseriesGroupEdnsResponseSerie0JSON `json:"-"` +} + +// as112TimeseriesGroupEdnsResponseSerie0JSON contains the JSON metadata for the +// struct [AS112TimeseriesGroupEdnsResponseSerie0] +type as112TimeseriesGroupEdnsResponseSerie0JSON struct { + NotSupported apijson.Field + Supported apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesGroupEdnsResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesGroupEdnsResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesGroupIPVersionResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AS112TimeseriesGroupIPVersionResponseSerie0 `json:"serie_0,required"` + JSON as112TimeseriesGroupIPVersionResponseJSON `json:"-"` +} + +// as112TimeseriesGroupIPVersionResponseJSON contains the JSON metadata for the +// struct [AS112TimeseriesGroupIPVersionResponse] +type as112TimeseriesGroupIPVersionResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesGroupIPVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesGroupIPVersionResponseJSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesGroupIPVersionResponseSerie0 struct { + IPv4 []string `json:"IPv4,required"` + IPv6 []string `json:"IPv6,required"` + JSON as112TimeseriesGroupIPVersionResponseSerie0JSON `json:"-"` +} + +// as112TimeseriesGroupIPVersionResponseSerie0JSON contains the JSON metadata for +// the struct [AS112TimeseriesGroupIPVersionResponseSerie0] +type as112TimeseriesGroupIPVersionResponseSerie0JSON struct { + IPv4 apijson.Field + IPv6 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesGroupIPVersionResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesGroupIPVersionResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesGroupProtocolResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AS112TimeseriesGroupProtocolResponseSerie0 `json:"serie_0,required"` + JSON as112TimeseriesGroupProtocolResponseJSON `json:"-"` +} + +// as112TimeseriesGroupProtocolResponseJSON contains the JSON metadata for the +// struct [AS112TimeseriesGroupProtocolResponse] +type as112TimeseriesGroupProtocolResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesGroupProtocolResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesGroupProtocolResponseJSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesGroupProtocolResponseSerie0 struct { + Tcp []string `json:"tcp,required"` + Udp []string `json:"udp,required"` + JSON as112TimeseriesGroupProtocolResponseSerie0JSON `json:"-"` +} + +// as112TimeseriesGroupProtocolResponseSerie0JSON contains the JSON metadata for +// the struct [AS112TimeseriesGroupProtocolResponseSerie0] +type as112TimeseriesGroupProtocolResponseSerie0JSON struct { + Tcp apijson.Field + Udp apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesGroupProtocolResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesGroupProtocolResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesGroupQueryTypeResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AS112TimeseriesGroupQueryTypeResponseSerie0 `json:"serie_0,required"` + JSON as112TimeseriesGroupQueryTypeResponseJSON `json:"-"` +} + +// as112TimeseriesGroupQueryTypeResponseJSON contains the JSON metadata for the +// struct [AS112TimeseriesGroupQueryTypeResponse] +type as112TimeseriesGroupQueryTypeResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesGroupQueryTypeResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesGroupQueryTypeResponseJSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesGroupQueryTypeResponseSerie0 struct { + A []string `json:"A,required"` + AAAA []string `json:"AAAA,required"` + PTR []string `json:"PTR,required"` + Soa []string `json:"SOA,required"` + SRV []string `json:"SRV,required"` + JSON as112TimeseriesGroupQueryTypeResponseSerie0JSON `json:"-"` +} + +// as112TimeseriesGroupQueryTypeResponseSerie0JSON contains the JSON metadata for +// the struct [AS112TimeseriesGroupQueryTypeResponseSerie0] +type as112TimeseriesGroupQueryTypeResponseSerie0JSON struct { + A apijson.Field + AAAA apijson.Field + PTR apijson.Field + Soa apijson.Field + SRV apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesGroupQueryTypeResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesGroupQueryTypeResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesGroupResponseCodesResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AS112TimeseriesGroupResponseCodesResponseSerie0 `json:"serie_0,required"` + JSON as112TimeseriesGroupResponseCodesResponseJSON `json:"-"` +} + +// as112TimeseriesGroupResponseCodesResponseJSON contains the JSON metadata for the +// struct [AS112TimeseriesGroupResponseCodesResponse] +type as112TimeseriesGroupResponseCodesResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesGroupResponseCodesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesGroupResponseCodesResponseJSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesGroupResponseCodesResponseSerie0 struct { + Noerror []string `json:"NOERROR,required"` + Nxdomain []string `json:"NXDOMAIN,required"` + JSON as112TimeseriesGroupResponseCodesResponseSerie0JSON `json:"-"` +} + +// as112TimeseriesGroupResponseCodesResponseSerie0JSON contains the JSON metadata +// for the struct [AS112TimeseriesGroupResponseCodesResponseSerie0] +type as112TimeseriesGroupResponseCodesResponseSerie0JSON struct { + Noerror apijson.Field + Nxdomain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesGroupResponseCodesResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesGroupResponseCodesResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesGroupDNSSECParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AS112TimeseriesGroupDNSSECParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AS112TimeseriesGroupDNSSECParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AS112TimeseriesGroupDNSSECParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AS112TimeseriesGroupDNSSECParams]'s query parameters as +// `url.Values`. +func (r AS112TimeseriesGroupDNSSECParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AS112TimeseriesGroupDNSSECParamsAggInterval string + +const ( + AS112TimeseriesGroupDNSSECParamsAggInterval15m AS112TimeseriesGroupDNSSECParamsAggInterval = "15m" + AS112TimeseriesGroupDNSSECParamsAggInterval1h AS112TimeseriesGroupDNSSECParamsAggInterval = "1h" + AS112TimeseriesGroupDNSSECParamsAggInterval1d AS112TimeseriesGroupDNSSECParamsAggInterval = "1d" + AS112TimeseriesGroupDNSSECParamsAggInterval1w AS112TimeseriesGroupDNSSECParamsAggInterval = "1w" +) + +type AS112TimeseriesGroupDNSSECParamsDateRange string + +const ( + AS112TimeseriesGroupDNSSECParamsDateRange1d AS112TimeseriesGroupDNSSECParamsDateRange = "1d" + AS112TimeseriesGroupDNSSECParamsDateRange2d AS112TimeseriesGroupDNSSECParamsDateRange = "2d" + AS112TimeseriesGroupDNSSECParamsDateRange7d AS112TimeseriesGroupDNSSECParamsDateRange = "7d" + AS112TimeseriesGroupDNSSECParamsDateRange14d AS112TimeseriesGroupDNSSECParamsDateRange = "14d" + AS112TimeseriesGroupDNSSECParamsDateRange28d AS112TimeseriesGroupDNSSECParamsDateRange = "28d" + AS112TimeseriesGroupDNSSECParamsDateRange12w AS112TimeseriesGroupDNSSECParamsDateRange = "12w" + AS112TimeseriesGroupDNSSECParamsDateRange24w AS112TimeseriesGroupDNSSECParamsDateRange = "24w" + AS112TimeseriesGroupDNSSECParamsDateRange52w AS112TimeseriesGroupDNSSECParamsDateRange = "52w" + AS112TimeseriesGroupDNSSECParamsDateRange1dControl AS112TimeseriesGroupDNSSECParamsDateRange = "1dControl" + AS112TimeseriesGroupDNSSECParamsDateRange2dControl AS112TimeseriesGroupDNSSECParamsDateRange = "2dControl" + AS112TimeseriesGroupDNSSECParamsDateRange7dControl AS112TimeseriesGroupDNSSECParamsDateRange = "7dControl" + AS112TimeseriesGroupDNSSECParamsDateRange14dControl AS112TimeseriesGroupDNSSECParamsDateRange = "14dControl" + AS112TimeseriesGroupDNSSECParamsDateRange28dControl AS112TimeseriesGroupDNSSECParamsDateRange = "28dControl" + AS112TimeseriesGroupDNSSECParamsDateRange12wControl AS112TimeseriesGroupDNSSECParamsDateRange = "12wControl" + AS112TimeseriesGroupDNSSECParamsDateRange24wControl AS112TimeseriesGroupDNSSECParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AS112TimeseriesGroupDNSSECParamsFormat string + +const ( + AS112TimeseriesGroupDNSSECParamsFormatJson AS112TimeseriesGroupDNSSECParamsFormat = "JSON" + AS112TimeseriesGroupDNSSECParamsFormatCsv AS112TimeseriesGroupDNSSECParamsFormat = "CSV" +) + +type AS112TimeseriesGroupDNSSECResponseEnvelope struct { + Result AS112TimeseriesGroupDNSSECResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON as112TimeseriesGroupDNSSECResponseEnvelopeJSON `json:"-"` +} + +// as112TimeseriesGroupDNSSECResponseEnvelopeJSON contains the JSON metadata for +// the struct [AS112TimeseriesGroupDNSSECResponseEnvelope] +type as112TimeseriesGroupDNSSECResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesGroupDNSSECResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesGroupDNSSECResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesGroupEdnsParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AS112TimeseriesGroupEdnsParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AS112TimeseriesGroupEdnsParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AS112TimeseriesGroupEdnsParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AS112TimeseriesGroupEdnsParams]'s query parameters as +// `url.Values`. +func (r AS112TimeseriesGroupEdnsParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AS112TimeseriesGroupEdnsParamsAggInterval string + +const ( + AS112TimeseriesGroupEdnsParamsAggInterval15m AS112TimeseriesGroupEdnsParamsAggInterval = "15m" + AS112TimeseriesGroupEdnsParamsAggInterval1h AS112TimeseriesGroupEdnsParamsAggInterval = "1h" + AS112TimeseriesGroupEdnsParamsAggInterval1d AS112TimeseriesGroupEdnsParamsAggInterval = "1d" + AS112TimeseriesGroupEdnsParamsAggInterval1w AS112TimeseriesGroupEdnsParamsAggInterval = "1w" +) + +type AS112TimeseriesGroupEdnsParamsDateRange string + +const ( + AS112TimeseriesGroupEdnsParamsDateRange1d AS112TimeseriesGroupEdnsParamsDateRange = "1d" + AS112TimeseriesGroupEdnsParamsDateRange2d AS112TimeseriesGroupEdnsParamsDateRange = "2d" + AS112TimeseriesGroupEdnsParamsDateRange7d AS112TimeseriesGroupEdnsParamsDateRange = "7d" + AS112TimeseriesGroupEdnsParamsDateRange14d AS112TimeseriesGroupEdnsParamsDateRange = "14d" + AS112TimeseriesGroupEdnsParamsDateRange28d AS112TimeseriesGroupEdnsParamsDateRange = "28d" + AS112TimeseriesGroupEdnsParamsDateRange12w AS112TimeseriesGroupEdnsParamsDateRange = "12w" + AS112TimeseriesGroupEdnsParamsDateRange24w AS112TimeseriesGroupEdnsParamsDateRange = "24w" + AS112TimeseriesGroupEdnsParamsDateRange52w AS112TimeseriesGroupEdnsParamsDateRange = "52w" + AS112TimeseriesGroupEdnsParamsDateRange1dControl AS112TimeseriesGroupEdnsParamsDateRange = "1dControl" + AS112TimeseriesGroupEdnsParamsDateRange2dControl AS112TimeseriesGroupEdnsParamsDateRange = "2dControl" + AS112TimeseriesGroupEdnsParamsDateRange7dControl AS112TimeseriesGroupEdnsParamsDateRange = "7dControl" + AS112TimeseriesGroupEdnsParamsDateRange14dControl AS112TimeseriesGroupEdnsParamsDateRange = "14dControl" + AS112TimeseriesGroupEdnsParamsDateRange28dControl AS112TimeseriesGroupEdnsParamsDateRange = "28dControl" + AS112TimeseriesGroupEdnsParamsDateRange12wControl AS112TimeseriesGroupEdnsParamsDateRange = "12wControl" + AS112TimeseriesGroupEdnsParamsDateRange24wControl AS112TimeseriesGroupEdnsParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AS112TimeseriesGroupEdnsParamsFormat string + +const ( + AS112TimeseriesGroupEdnsParamsFormatJson AS112TimeseriesGroupEdnsParamsFormat = "JSON" + AS112TimeseriesGroupEdnsParamsFormatCsv AS112TimeseriesGroupEdnsParamsFormat = "CSV" +) + +type AS112TimeseriesGroupEdnsResponseEnvelope struct { + Result AS112TimeseriesGroupEdnsResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON as112TimeseriesGroupEdnsResponseEnvelopeJSON `json:"-"` +} + +// as112TimeseriesGroupEdnsResponseEnvelopeJSON contains the JSON metadata for the +// struct [AS112TimeseriesGroupEdnsResponseEnvelope] +type as112TimeseriesGroupEdnsResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesGroupEdnsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesGroupEdnsResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesGroupIPVersionParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AS112TimeseriesGroupIPVersionParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AS112TimeseriesGroupIPVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AS112TimeseriesGroupIPVersionParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AS112TimeseriesGroupIPVersionParams]'s query parameters as +// `url.Values`. +func (r AS112TimeseriesGroupIPVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AS112TimeseriesGroupIPVersionParamsAggInterval string + +const ( + AS112TimeseriesGroupIPVersionParamsAggInterval15m AS112TimeseriesGroupIPVersionParamsAggInterval = "15m" + AS112TimeseriesGroupIPVersionParamsAggInterval1h AS112TimeseriesGroupIPVersionParamsAggInterval = "1h" + AS112TimeseriesGroupIPVersionParamsAggInterval1d AS112TimeseriesGroupIPVersionParamsAggInterval = "1d" + AS112TimeseriesGroupIPVersionParamsAggInterval1w AS112TimeseriesGroupIPVersionParamsAggInterval = "1w" +) + +type AS112TimeseriesGroupIPVersionParamsDateRange string + +const ( + AS112TimeseriesGroupIPVersionParamsDateRange1d AS112TimeseriesGroupIPVersionParamsDateRange = "1d" + AS112TimeseriesGroupIPVersionParamsDateRange2d AS112TimeseriesGroupIPVersionParamsDateRange = "2d" + AS112TimeseriesGroupIPVersionParamsDateRange7d AS112TimeseriesGroupIPVersionParamsDateRange = "7d" + AS112TimeseriesGroupIPVersionParamsDateRange14d AS112TimeseriesGroupIPVersionParamsDateRange = "14d" + AS112TimeseriesGroupIPVersionParamsDateRange28d AS112TimeseriesGroupIPVersionParamsDateRange = "28d" + AS112TimeseriesGroupIPVersionParamsDateRange12w AS112TimeseriesGroupIPVersionParamsDateRange = "12w" + AS112TimeseriesGroupIPVersionParamsDateRange24w AS112TimeseriesGroupIPVersionParamsDateRange = "24w" + AS112TimeseriesGroupIPVersionParamsDateRange52w AS112TimeseriesGroupIPVersionParamsDateRange = "52w" + AS112TimeseriesGroupIPVersionParamsDateRange1dControl AS112TimeseriesGroupIPVersionParamsDateRange = "1dControl" + AS112TimeseriesGroupIPVersionParamsDateRange2dControl AS112TimeseriesGroupIPVersionParamsDateRange = "2dControl" + AS112TimeseriesGroupIPVersionParamsDateRange7dControl AS112TimeseriesGroupIPVersionParamsDateRange = "7dControl" + AS112TimeseriesGroupIPVersionParamsDateRange14dControl AS112TimeseriesGroupIPVersionParamsDateRange = "14dControl" + AS112TimeseriesGroupIPVersionParamsDateRange28dControl AS112TimeseriesGroupIPVersionParamsDateRange = "28dControl" + AS112TimeseriesGroupIPVersionParamsDateRange12wControl AS112TimeseriesGroupIPVersionParamsDateRange = "12wControl" + AS112TimeseriesGroupIPVersionParamsDateRange24wControl AS112TimeseriesGroupIPVersionParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AS112TimeseriesGroupIPVersionParamsFormat string + +const ( + AS112TimeseriesGroupIPVersionParamsFormatJson AS112TimeseriesGroupIPVersionParamsFormat = "JSON" + AS112TimeseriesGroupIPVersionParamsFormatCsv AS112TimeseriesGroupIPVersionParamsFormat = "CSV" +) + +type AS112TimeseriesGroupIPVersionResponseEnvelope struct { + Result AS112TimeseriesGroupIPVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON as112TimeseriesGroupIPVersionResponseEnvelopeJSON `json:"-"` +} + +// as112TimeseriesGroupIPVersionResponseEnvelopeJSON contains the JSON metadata for +// the struct [AS112TimeseriesGroupIPVersionResponseEnvelope] +type as112TimeseriesGroupIPVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesGroupIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesGroupIPVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesGroupProtocolParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AS112TimeseriesGroupProtocolParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AS112TimeseriesGroupProtocolParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AS112TimeseriesGroupProtocolParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AS112TimeseriesGroupProtocolParams]'s query parameters as +// `url.Values`. +func (r AS112TimeseriesGroupProtocolParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AS112TimeseriesGroupProtocolParamsAggInterval string + +const ( + AS112TimeseriesGroupProtocolParamsAggInterval15m AS112TimeseriesGroupProtocolParamsAggInterval = "15m" + AS112TimeseriesGroupProtocolParamsAggInterval1h AS112TimeseriesGroupProtocolParamsAggInterval = "1h" + AS112TimeseriesGroupProtocolParamsAggInterval1d AS112TimeseriesGroupProtocolParamsAggInterval = "1d" + AS112TimeseriesGroupProtocolParamsAggInterval1w AS112TimeseriesGroupProtocolParamsAggInterval = "1w" +) + +type AS112TimeseriesGroupProtocolParamsDateRange string + +const ( + AS112TimeseriesGroupProtocolParamsDateRange1d AS112TimeseriesGroupProtocolParamsDateRange = "1d" + AS112TimeseriesGroupProtocolParamsDateRange2d AS112TimeseriesGroupProtocolParamsDateRange = "2d" + AS112TimeseriesGroupProtocolParamsDateRange7d AS112TimeseriesGroupProtocolParamsDateRange = "7d" + AS112TimeseriesGroupProtocolParamsDateRange14d AS112TimeseriesGroupProtocolParamsDateRange = "14d" + AS112TimeseriesGroupProtocolParamsDateRange28d AS112TimeseriesGroupProtocolParamsDateRange = "28d" + AS112TimeseriesGroupProtocolParamsDateRange12w AS112TimeseriesGroupProtocolParamsDateRange = "12w" + AS112TimeseriesGroupProtocolParamsDateRange24w AS112TimeseriesGroupProtocolParamsDateRange = "24w" + AS112TimeseriesGroupProtocolParamsDateRange52w AS112TimeseriesGroupProtocolParamsDateRange = "52w" + AS112TimeseriesGroupProtocolParamsDateRange1dControl AS112TimeseriesGroupProtocolParamsDateRange = "1dControl" + AS112TimeseriesGroupProtocolParamsDateRange2dControl AS112TimeseriesGroupProtocolParamsDateRange = "2dControl" + AS112TimeseriesGroupProtocolParamsDateRange7dControl AS112TimeseriesGroupProtocolParamsDateRange = "7dControl" + AS112TimeseriesGroupProtocolParamsDateRange14dControl AS112TimeseriesGroupProtocolParamsDateRange = "14dControl" + AS112TimeseriesGroupProtocolParamsDateRange28dControl AS112TimeseriesGroupProtocolParamsDateRange = "28dControl" + AS112TimeseriesGroupProtocolParamsDateRange12wControl AS112TimeseriesGroupProtocolParamsDateRange = "12wControl" + AS112TimeseriesGroupProtocolParamsDateRange24wControl AS112TimeseriesGroupProtocolParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AS112TimeseriesGroupProtocolParamsFormat string + +const ( + AS112TimeseriesGroupProtocolParamsFormatJson AS112TimeseriesGroupProtocolParamsFormat = "JSON" + AS112TimeseriesGroupProtocolParamsFormatCsv AS112TimeseriesGroupProtocolParamsFormat = "CSV" +) + +type AS112TimeseriesGroupProtocolResponseEnvelope struct { + Result AS112TimeseriesGroupProtocolResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON as112TimeseriesGroupProtocolResponseEnvelopeJSON `json:"-"` +} + +// as112TimeseriesGroupProtocolResponseEnvelopeJSON contains the JSON metadata for +// the struct [AS112TimeseriesGroupProtocolResponseEnvelope] +type as112TimeseriesGroupProtocolResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesGroupProtocolResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesGroupProtocolResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesGroupQueryTypeParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AS112TimeseriesGroupQueryTypeParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AS112TimeseriesGroupQueryTypeParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AS112TimeseriesGroupQueryTypeParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AS112TimeseriesGroupQueryTypeParams]'s query parameters as +// `url.Values`. +func (r AS112TimeseriesGroupQueryTypeParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AS112TimeseriesGroupQueryTypeParamsAggInterval string + +const ( + AS112TimeseriesGroupQueryTypeParamsAggInterval15m AS112TimeseriesGroupQueryTypeParamsAggInterval = "15m" + AS112TimeseriesGroupQueryTypeParamsAggInterval1h AS112TimeseriesGroupQueryTypeParamsAggInterval = "1h" + AS112TimeseriesGroupQueryTypeParamsAggInterval1d AS112TimeseriesGroupQueryTypeParamsAggInterval = "1d" + AS112TimeseriesGroupQueryTypeParamsAggInterval1w AS112TimeseriesGroupQueryTypeParamsAggInterval = "1w" +) + +type AS112TimeseriesGroupQueryTypeParamsDateRange string + +const ( + AS112TimeseriesGroupQueryTypeParamsDateRange1d AS112TimeseriesGroupQueryTypeParamsDateRange = "1d" + AS112TimeseriesGroupQueryTypeParamsDateRange2d AS112TimeseriesGroupQueryTypeParamsDateRange = "2d" + AS112TimeseriesGroupQueryTypeParamsDateRange7d AS112TimeseriesGroupQueryTypeParamsDateRange = "7d" + AS112TimeseriesGroupQueryTypeParamsDateRange14d AS112TimeseriesGroupQueryTypeParamsDateRange = "14d" + AS112TimeseriesGroupQueryTypeParamsDateRange28d AS112TimeseriesGroupQueryTypeParamsDateRange = "28d" + AS112TimeseriesGroupQueryTypeParamsDateRange12w AS112TimeseriesGroupQueryTypeParamsDateRange = "12w" + AS112TimeseriesGroupQueryTypeParamsDateRange24w AS112TimeseriesGroupQueryTypeParamsDateRange = "24w" + AS112TimeseriesGroupQueryTypeParamsDateRange52w AS112TimeseriesGroupQueryTypeParamsDateRange = "52w" + AS112TimeseriesGroupQueryTypeParamsDateRange1dControl AS112TimeseriesGroupQueryTypeParamsDateRange = "1dControl" + AS112TimeseriesGroupQueryTypeParamsDateRange2dControl AS112TimeseriesGroupQueryTypeParamsDateRange = "2dControl" + AS112TimeseriesGroupQueryTypeParamsDateRange7dControl AS112TimeseriesGroupQueryTypeParamsDateRange = "7dControl" + AS112TimeseriesGroupQueryTypeParamsDateRange14dControl AS112TimeseriesGroupQueryTypeParamsDateRange = "14dControl" + AS112TimeseriesGroupQueryTypeParamsDateRange28dControl AS112TimeseriesGroupQueryTypeParamsDateRange = "28dControl" + AS112TimeseriesGroupQueryTypeParamsDateRange12wControl AS112TimeseriesGroupQueryTypeParamsDateRange = "12wControl" + AS112TimeseriesGroupQueryTypeParamsDateRange24wControl AS112TimeseriesGroupQueryTypeParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AS112TimeseriesGroupQueryTypeParamsFormat string + +const ( + AS112TimeseriesGroupQueryTypeParamsFormatJson AS112TimeseriesGroupQueryTypeParamsFormat = "JSON" + AS112TimeseriesGroupQueryTypeParamsFormatCsv AS112TimeseriesGroupQueryTypeParamsFormat = "CSV" +) + +type AS112TimeseriesGroupQueryTypeResponseEnvelope struct { + Result AS112TimeseriesGroupQueryTypeResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON as112TimeseriesGroupQueryTypeResponseEnvelopeJSON `json:"-"` +} + +// as112TimeseriesGroupQueryTypeResponseEnvelopeJSON contains the JSON metadata for +// the struct [AS112TimeseriesGroupQueryTypeResponseEnvelope] +type as112TimeseriesGroupQueryTypeResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesGroupQueryTypeResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesGroupQueryTypeResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AS112TimeseriesGroupResponseCodesParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AS112TimeseriesGroupResponseCodesParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AS112TimeseriesGroupResponseCodesParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AS112TimeseriesGroupResponseCodesParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AS112TimeseriesGroupResponseCodesParams]'s query parameters +// as `url.Values`. +func (r AS112TimeseriesGroupResponseCodesParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AS112TimeseriesGroupResponseCodesParamsAggInterval string + +const ( + AS112TimeseriesGroupResponseCodesParamsAggInterval15m AS112TimeseriesGroupResponseCodesParamsAggInterval = "15m" + AS112TimeseriesGroupResponseCodesParamsAggInterval1h AS112TimeseriesGroupResponseCodesParamsAggInterval = "1h" + AS112TimeseriesGroupResponseCodesParamsAggInterval1d AS112TimeseriesGroupResponseCodesParamsAggInterval = "1d" + AS112TimeseriesGroupResponseCodesParamsAggInterval1w AS112TimeseriesGroupResponseCodesParamsAggInterval = "1w" +) + +type AS112TimeseriesGroupResponseCodesParamsDateRange string + +const ( + AS112TimeseriesGroupResponseCodesParamsDateRange1d AS112TimeseriesGroupResponseCodesParamsDateRange = "1d" + AS112TimeseriesGroupResponseCodesParamsDateRange2d AS112TimeseriesGroupResponseCodesParamsDateRange = "2d" + AS112TimeseriesGroupResponseCodesParamsDateRange7d AS112TimeseriesGroupResponseCodesParamsDateRange = "7d" + AS112TimeseriesGroupResponseCodesParamsDateRange14d AS112TimeseriesGroupResponseCodesParamsDateRange = "14d" + AS112TimeseriesGroupResponseCodesParamsDateRange28d AS112TimeseriesGroupResponseCodesParamsDateRange = "28d" + AS112TimeseriesGroupResponseCodesParamsDateRange12w AS112TimeseriesGroupResponseCodesParamsDateRange = "12w" + AS112TimeseriesGroupResponseCodesParamsDateRange24w AS112TimeseriesGroupResponseCodesParamsDateRange = "24w" + AS112TimeseriesGroupResponseCodesParamsDateRange52w AS112TimeseriesGroupResponseCodesParamsDateRange = "52w" + AS112TimeseriesGroupResponseCodesParamsDateRange1dControl AS112TimeseriesGroupResponseCodesParamsDateRange = "1dControl" + AS112TimeseriesGroupResponseCodesParamsDateRange2dControl AS112TimeseriesGroupResponseCodesParamsDateRange = "2dControl" + AS112TimeseriesGroupResponseCodesParamsDateRange7dControl AS112TimeseriesGroupResponseCodesParamsDateRange = "7dControl" + AS112TimeseriesGroupResponseCodesParamsDateRange14dControl AS112TimeseriesGroupResponseCodesParamsDateRange = "14dControl" + AS112TimeseriesGroupResponseCodesParamsDateRange28dControl AS112TimeseriesGroupResponseCodesParamsDateRange = "28dControl" + AS112TimeseriesGroupResponseCodesParamsDateRange12wControl AS112TimeseriesGroupResponseCodesParamsDateRange = "12wControl" + AS112TimeseriesGroupResponseCodesParamsDateRange24wControl AS112TimeseriesGroupResponseCodesParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AS112TimeseriesGroupResponseCodesParamsFormat string + +const ( + AS112TimeseriesGroupResponseCodesParamsFormatJson AS112TimeseriesGroupResponseCodesParamsFormat = "JSON" + AS112TimeseriesGroupResponseCodesParamsFormatCsv AS112TimeseriesGroupResponseCodesParamsFormat = "CSV" +) + +type AS112TimeseriesGroupResponseCodesResponseEnvelope struct { + Result AS112TimeseriesGroupResponseCodesResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON as112TimeseriesGroupResponseCodesResponseEnvelopeJSON `json:"-"` +} + +// as112TimeseriesGroupResponseCodesResponseEnvelopeJSON contains the JSON metadata +// for the struct [AS112TimeseriesGroupResponseCodesResponseEnvelope] +type as112TimeseriesGroupResponseCodesResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TimeseriesGroupResponseCodesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TimeseriesGroupResponseCodesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/as112timeseriesgroup_test.go b/radar/as112timeseriesgroup_test.go new file mode 100644 index 00000000000..c82b910ddcd --- /dev/null +++ b/radar/as112timeseriesgroup_test.go @@ -0,0 +1,220 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestAS112TimeseriesGroupDNSSECWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.AS112.TimeseriesGroups.DNSSEC(context.TODO(), radar.AS112TimeseriesGroupDNSSECParams{ + AggInterval: cloudflare.F(radar.AS112TimeseriesGroupDNSSECParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AS112TimeseriesGroupDNSSECParamsDateRange{radar.AS112TimeseriesGroupDNSSECParamsDateRange1d, radar.AS112TimeseriesGroupDNSSECParamsDateRange2d, radar.AS112TimeseriesGroupDNSSECParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AS112TimeseriesGroupDNSSECParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAS112TimeseriesGroupEdnsWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.AS112.TimeseriesGroups.Edns(context.TODO(), radar.AS112TimeseriesGroupEdnsParams{ + AggInterval: cloudflare.F(radar.AS112TimeseriesGroupEdnsParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AS112TimeseriesGroupEdnsParamsDateRange{radar.AS112TimeseriesGroupEdnsParamsDateRange1d, radar.AS112TimeseriesGroupEdnsParamsDateRange2d, radar.AS112TimeseriesGroupEdnsParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AS112TimeseriesGroupEdnsParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAS112TimeseriesGroupIPVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.AS112.TimeseriesGroups.IPVersion(context.TODO(), radar.AS112TimeseriesGroupIPVersionParams{ + AggInterval: cloudflare.F(radar.AS112TimeseriesGroupIPVersionParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AS112TimeseriesGroupIPVersionParamsDateRange{radar.AS112TimeseriesGroupIPVersionParamsDateRange1d, radar.AS112TimeseriesGroupIPVersionParamsDateRange2d, radar.AS112TimeseriesGroupIPVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AS112TimeseriesGroupIPVersionParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAS112TimeseriesGroupProtocolWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.AS112.TimeseriesGroups.Protocol(context.TODO(), radar.AS112TimeseriesGroupProtocolParams{ + AggInterval: cloudflare.F(radar.AS112TimeseriesGroupProtocolParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AS112TimeseriesGroupProtocolParamsDateRange{radar.AS112TimeseriesGroupProtocolParamsDateRange1d, radar.AS112TimeseriesGroupProtocolParamsDateRange2d, radar.AS112TimeseriesGroupProtocolParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AS112TimeseriesGroupProtocolParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAS112TimeseriesGroupQueryTypeWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.AS112.TimeseriesGroups.QueryType(context.TODO(), radar.AS112TimeseriesGroupQueryTypeParams{ + AggInterval: cloudflare.F(radar.AS112TimeseriesGroupQueryTypeParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AS112TimeseriesGroupQueryTypeParamsDateRange{radar.AS112TimeseriesGroupQueryTypeParamsDateRange1d, radar.AS112TimeseriesGroupQueryTypeParamsDateRange2d, radar.AS112TimeseriesGroupQueryTypeParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AS112TimeseriesGroupQueryTypeParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAS112TimeseriesGroupResponseCodesWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.AS112.TimeseriesGroups.ResponseCodes(context.TODO(), radar.AS112TimeseriesGroupResponseCodesParams{ + AggInterval: cloudflare.F(radar.AS112TimeseriesGroupResponseCodesParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AS112TimeseriesGroupResponseCodesParamsDateRange{radar.AS112TimeseriesGroupResponseCodesParamsDateRange1d, radar.AS112TimeseriesGroupResponseCodesParamsDateRange2d, radar.AS112TimeseriesGroupResponseCodesParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AS112TimeseriesGroupResponseCodesParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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/radar/as112top.go b/radar/as112top.go new file mode 100644 index 00000000000..a525957ae8f --- /dev/null +++ b/radar/as112top.go @@ -0,0 +1,1081 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AS112TopService 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 [NewAS112TopService] method instead. +type AS112TopService struct { + Options []option.RequestOption +} + +// NewAS112TopService 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 NewAS112TopService(opts ...option.RequestOption) (r *AS112TopService) { + r = &AS112TopService{} + r.Options = opts + return +} + +// Get the top locations by DNS queries DNSSEC support to AS112. +func (r *AS112TopService) DNSSEC(ctx context.Context, dnssec AS112TopDNSSECParamsDNSSEC, query AS112TopDNSSECParams, opts ...option.RequestOption) (res *AS112TopDNSSECResponse, err error) { + opts = append(r.Options[:], opts...) + var env AS112TopDNSSECResponseEnvelope + path := fmt.Sprintf("radar/as112/top/locations/dnssec/%v", dnssec) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the top locations, by DNS queries EDNS support to AS112. +func (r *AS112TopService) Edns(ctx context.Context, edns AS112TopEdnsParamsEdns, query AS112TopEdnsParams, opts ...option.RequestOption) (res *AS112TopEdnsResponse, err error) { + opts = append(r.Options[:], opts...) + var env AS112TopEdnsResponseEnvelope + path := fmt.Sprintf("radar/as112/top/locations/edns/%v", edns) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the top locations by DNS queries IP version to AS112. +func (r *AS112TopService) IPVersion(ctx context.Context, ipVersion AS112TopIPVersionParamsIPVersion, query AS112TopIPVersionParams, opts ...option.RequestOption) (res *AS112TopIPVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env AS112TopIPVersionResponseEnvelope + path := fmt.Sprintf("radar/as112/top/locations/ip_version/%v", ipVersion) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the top locations by AS112 DNS queries. Values are a percentage out of the +// total queries. +func (r *AS112TopService) Locations(ctx context.Context, query AS112TopLocationsParams, opts ...option.RequestOption) (res *AS112TopLocationsResponse, err error) { + opts = append(r.Options[:], opts...) + var env AS112TopLocationsResponseEnvelope + path := "radar/as112/top/locations" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AS112TopDNSSECResponse struct { + Meta AS112TopDNSSECResponseMeta `json:"meta,required"` + Top0 []AS112TopDNSSECResponseTop0 `json:"top_0,required"` + JSON as112TopDNSSECResponseJSON `json:"-"` +} + +// as112TopDNSSECResponseJSON contains the JSON metadata for the struct +// [AS112TopDNSSECResponse] +type as112TopDNSSECResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopDNSSECResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopDNSSECResponseJSON) RawJSON() string { + return r.raw +} + +type AS112TopDNSSECResponseMeta struct { + DateRange []AS112TopDNSSECResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo AS112TopDNSSECResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON as112TopDNSSECResponseMetaJSON `json:"-"` +} + +// as112TopDNSSECResponseMetaJSON contains the JSON metadata for the struct +// [AS112TopDNSSECResponseMeta] +type as112TopDNSSECResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopDNSSECResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopDNSSECResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AS112TopDNSSECResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON as112TopDNSSECResponseMetaDateRangeJSON `json:"-"` +} + +// as112TopDNSSECResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [AS112TopDNSSECResponseMetaDateRange] +type as112TopDNSSECResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopDNSSECResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopDNSSECResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AS112TopDNSSECResponseMetaConfidenceInfo struct { + Annotations []AS112TopDNSSECResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON as112TopDNSSECResponseMetaConfidenceInfoJSON `json:"-"` +} + +// as112TopDNSSECResponseMetaConfidenceInfoJSON contains the JSON metadata for the +// struct [AS112TopDNSSECResponseMetaConfidenceInfo] +type as112TopDNSSECResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopDNSSECResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopDNSSECResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AS112TopDNSSECResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON as112TopDNSSECResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// as112TopDNSSECResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct [AS112TopDNSSECResponseMetaConfidenceInfoAnnotation] +type as112TopDNSSECResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopDNSSECResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopDNSSECResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AS112TopDNSSECResponseTop0 struct { + ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` + ClientCountryName string `json:"clientCountryName,required"` + Value string `json:"value,required"` + JSON as112TopDNSSECResponseTop0JSON `json:"-"` +} + +// as112TopDNSSECResponseTop0JSON contains the JSON metadata for the struct +// [AS112TopDNSSECResponseTop0] +type as112TopDNSSECResponseTop0JSON struct { + ClientCountryAlpha2 apijson.Field + ClientCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopDNSSECResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopDNSSECResponseTop0JSON) RawJSON() string { + return r.raw +} + +type AS112TopEdnsResponse struct { + Meta AS112TopEdnsResponseMeta `json:"meta,required"` + Top0 []AS112TopEdnsResponseTop0 `json:"top_0,required"` + JSON as112TopEdnsResponseJSON `json:"-"` +} + +// as112TopEdnsResponseJSON contains the JSON metadata for the struct +// [AS112TopEdnsResponse] +type as112TopEdnsResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopEdnsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopEdnsResponseJSON) RawJSON() string { + return r.raw +} + +type AS112TopEdnsResponseMeta struct { + DateRange []AS112TopEdnsResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo AS112TopEdnsResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON as112TopEdnsResponseMetaJSON `json:"-"` +} + +// as112TopEdnsResponseMetaJSON contains the JSON metadata for the struct +// [AS112TopEdnsResponseMeta] +type as112TopEdnsResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopEdnsResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopEdnsResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AS112TopEdnsResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON as112TopEdnsResponseMetaDateRangeJSON `json:"-"` +} + +// as112TopEdnsResponseMetaDateRangeJSON contains the JSON metadata for the struct +// [AS112TopEdnsResponseMetaDateRange] +type as112TopEdnsResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopEdnsResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopEdnsResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AS112TopEdnsResponseMetaConfidenceInfo struct { + Annotations []AS112TopEdnsResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON as112TopEdnsResponseMetaConfidenceInfoJSON `json:"-"` +} + +// as112TopEdnsResponseMetaConfidenceInfoJSON contains the JSON metadata for the +// struct [AS112TopEdnsResponseMetaConfidenceInfo] +type as112TopEdnsResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopEdnsResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopEdnsResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AS112TopEdnsResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON as112TopEdnsResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// as112TopEdnsResponseMetaConfidenceInfoAnnotationJSON contains the JSON metadata +// for the struct [AS112TopEdnsResponseMetaConfidenceInfoAnnotation] +type as112TopEdnsResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopEdnsResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopEdnsResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AS112TopEdnsResponseTop0 struct { + ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` + ClientCountryName string `json:"clientCountryName,required"` + Value string `json:"value,required"` + JSON as112TopEdnsResponseTop0JSON `json:"-"` +} + +// as112TopEdnsResponseTop0JSON contains the JSON metadata for the struct +// [AS112TopEdnsResponseTop0] +type as112TopEdnsResponseTop0JSON struct { + ClientCountryAlpha2 apijson.Field + ClientCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopEdnsResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopEdnsResponseTop0JSON) RawJSON() string { + return r.raw +} + +type AS112TopIPVersionResponse struct { + Meta AS112TopIPVersionResponseMeta `json:"meta,required"` + Top0 []AS112TopIPVersionResponseTop0 `json:"top_0,required"` + JSON as112TopIPVersionResponseJSON `json:"-"` +} + +// as112TopIPVersionResponseJSON contains the JSON metadata for the struct +// [AS112TopIPVersionResponse] +type as112TopIPVersionResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopIPVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopIPVersionResponseJSON) RawJSON() string { + return r.raw +} + +type AS112TopIPVersionResponseMeta struct { + DateRange []AS112TopIPVersionResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo AS112TopIPVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON as112TopIPVersionResponseMetaJSON `json:"-"` +} + +// as112TopIPVersionResponseMetaJSON contains the JSON metadata for the struct +// [AS112TopIPVersionResponseMeta] +type as112TopIPVersionResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopIPVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopIPVersionResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AS112TopIPVersionResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON as112TopIPVersionResponseMetaDateRangeJSON `json:"-"` +} + +// as112TopIPVersionResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [AS112TopIPVersionResponseMetaDateRange] +type as112TopIPVersionResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopIPVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopIPVersionResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AS112TopIPVersionResponseMetaConfidenceInfo struct { + Annotations []AS112TopIPVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON as112TopIPVersionResponseMetaConfidenceInfoJSON `json:"-"` +} + +// as112TopIPVersionResponseMetaConfidenceInfoJSON contains the JSON metadata for +// the struct [AS112TopIPVersionResponseMetaConfidenceInfo] +type as112TopIPVersionResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopIPVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopIPVersionResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AS112TopIPVersionResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON as112TopIPVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// as112TopIPVersionResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct [AS112TopIPVersionResponseMetaConfidenceInfoAnnotation] +type as112TopIPVersionResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopIPVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopIPVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AS112TopIPVersionResponseTop0 struct { + ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` + ClientCountryName string `json:"clientCountryName,required"` + Value string `json:"value,required"` + JSON as112TopIPVersionResponseTop0JSON `json:"-"` +} + +// as112TopIPVersionResponseTop0JSON contains the JSON metadata for the struct +// [AS112TopIPVersionResponseTop0] +type as112TopIPVersionResponseTop0JSON struct { + ClientCountryAlpha2 apijson.Field + ClientCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopIPVersionResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopIPVersionResponseTop0JSON) RawJSON() string { + return r.raw +} + +type AS112TopLocationsResponse struct { + Meta AS112TopLocationsResponseMeta `json:"meta,required"` + Top0 []AS112TopLocationsResponseTop0 `json:"top_0,required"` + JSON as112TopLocationsResponseJSON `json:"-"` +} + +// as112TopLocationsResponseJSON contains the JSON metadata for the struct +// [AS112TopLocationsResponse] +type as112TopLocationsResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopLocationsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopLocationsResponseJSON) RawJSON() string { + return r.raw +} + +type AS112TopLocationsResponseMeta struct { + DateRange []AS112TopLocationsResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo AS112TopLocationsResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON as112TopLocationsResponseMetaJSON `json:"-"` +} + +// as112TopLocationsResponseMetaJSON contains the JSON metadata for the struct +// [AS112TopLocationsResponseMeta] +type as112TopLocationsResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopLocationsResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopLocationsResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AS112TopLocationsResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON as112TopLocationsResponseMetaDateRangeJSON `json:"-"` +} + +// as112TopLocationsResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [AS112TopLocationsResponseMetaDateRange] +type as112TopLocationsResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopLocationsResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopLocationsResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AS112TopLocationsResponseMetaConfidenceInfo struct { + Annotations []AS112TopLocationsResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON as112TopLocationsResponseMetaConfidenceInfoJSON `json:"-"` +} + +// as112TopLocationsResponseMetaConfidenceInfoJSON contains the JSON metadata for +// the struct [AS112TopLocationsResponseMetaConfidenceInfo] +type as112TopLocationsResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopLocationsResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopLocationsResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AS112TopLocationsResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON as112TopLocationsResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// as112TopLocationsResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct [AS112TopLocationsResponseMetaConfidenceInfoAnnotation] +type as112TopLocationsResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopLocationsResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopLocationsResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AS112TopLocationsResponseTop0 struct { + ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` + ClientCountryName string `json:"clientCountryName,required"` + Value string `json:"value,required"` + JSON as112TopLocationsResponseTop0JSON `json:"-"` +} + +// as112TopLocationsResponseTop0JSON contains the JSON metadata for the struct +// [AS112TopLocationsResponseTop0] +type as112TopLocationsResponseTop0JSON struct { + ClientCountryAlpha2 apijson.Field + ClientCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopLocationsResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopLocationsResponseTop0JSON) RawJSON() string { + return r.raw +} + +type AS112TopDNSSECParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AS112TopDNSSECParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AS112TopDNSSECParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AS112TopDNSSECParams]'s query parameters as `url.Values`. +func (r AS112TopDNSSECParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// DNSSEC. +type AS112TopDNSSECParamsDNSSEC string + +const ( + AS112TopDNSSECParamsDNSSECSupported AS112TopDNSSECParamsDNSSEC = "SUPPORTED" + AS112TopDNSSECParamsDNSSECNotSupported AS112TopDNSSECParamsDNSSEC = "NOT_SUPPORTED" +) + +type AS112TopDNSSECParamsDateRange string + +const ( + AS112TopDNSSECParamsDateRange1d AS112TopDNSSECParamsDateRange = "1d" + AS112TopDNSSECParamsDateRange2d AS112TopDNSSECParamsDateRange = "2d" + AS112TopDNSSECParamsDateRange7d AS112TopDNSSECParamsDateRange = "7d" + AS112TopDNSSECParamsDateRange14d AS112TopDNSSECParamsDateRange = "14d" + AS112TopDNSSECParamsDateRange28d AS112TopDNSSECParamsDateRange = "28d" + AS112TopDNSSECParamsDateRange12w AS112TopDNSSECParamsDateRange = "12w" + AS112TopDNSSECParamsDateRange24w AS112TopDNSSECParamsDateRange = "24w" + AS112TopDNSSECParamsDateRange52w AS112TopDNSSECParamsDateRange = "52w" + AS112TopDNSSECParamsDateRange1dControl AS112TopDNSSECParamsDateRange = "1dControl" + AS112TopDNSSECParamsDateRange2dControl AS112TopDNSSECParamsDateRange = "2dControl" + AS112TopDNSSECParamsDateRange7dControl AS112TopDNSSECParamsDateRange = "7dControl" + AS112TopDNSSECParamsDateRange14dControl AS112TopDNSSECParamsDateRange = "14dControl" + AS112TopDNSSECParamsDateRange28dControl AS112TopDNSSECParamsDateRange = "28dControl" + AS112TopDNSSECParamsDateRange12wControl AS112TopDNSSECParamsDateRange = "12wControl" + AS112TopDNSSECParamsDateRange24wControl AS112TopDNSSECParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AS112TopDNSSECParamsFormat string + +const ( + AS112TopDNSSECParamsFormatJson AS112TopDNSSECParamsFormat = "JSON" + AS112TopDNSSECParamsFormatCsv AS112TopDNSSECParamsFormat = "CSV" +) + +type AS112TopDNSSECResponseEnvelope struct { + Result AS112TopDNSSECResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON as112TopDNSSECResponseEnvelopeJSON `json:"-"` +} + +// as112TopDNSSECResponseEnvelopeJSON contains the JSON metadata for the struct +// [AS112TopDNSSECResponseEnvelope] +type as112TopDNSSECResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopDNSSECResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopDNSSECResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AS112TopEdnsParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AS112TopEdnsParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AS112TopEdnsParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AS112TopEdnsParams]'s query parameters as `url.Values`. +func (r AS112TopEdnsParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// EDNS. +type AS112TopEdnsParamsEdns string + +const ( + AS112TopEdnsParamsEdnsSupported AS112TopEdnsParamsEdns = "SUPPORTED" + AS112TopEdnsParamsEdnsNotSupported AS112TopEdnsParamsEdns = "NOT_SUPPORTED" +) + +type AS112TopEdnsParamsDateRange string + +const ( + AS112TopEdnsParamsDateRange1d AS112TopEdnsParamsDateRange = "1d" + AS112TopEdnsParamsDateRange2d AS112TopEdnsParamsDateRange = "2d" + AS112TopEdnsParamsDateRange7d AS112TopEdnsParamsDateRange = "7d" + AS112TopEdnsParamsDateRange14d AS112TopEdnsParamsDateRange = "14d" + AS112TopEdnsParamsDateRange28d AS112TopEdnsParamsDateRange = "28d" + AS112TopEdnsParamsDateRange12w AS112TopEdnsParamsDateRange = "12w" + AS112TopEdnsParamsDateRange24w AS112TopEdnsParamsDateRange = "24w" + AS112TopEdnsParamsDateRange52w AS112TopEdnsParamsDateRange = "52w" + AS112TopEdnsParamsDateRange1dControl AS112TopEdnsParamsDateRange = "1dControl" + AS112TopEdnsParamsDateRange2dControl AS112TopEdnsParamsDateRange = "2dControl" + AS112TopEdnsParamsDateRange7dControl AS112TopEdnsParamsDateRange = "7dControl" + AS112TopEdnsParamsDateRange14dControl AS112TopEdnsParamsDateRange = "14dControl" + AS112TopEdnsParamsDateRange28dControl AS112TopEdnsParamsDateRange = "28dControl" + AS112TopEdnsParamsDateRange12wControl AS112TopEdnsParamsDateRange = "12wControl" + AS112TopEdnsParamsDateRange24wControl AS112TopEdnsParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AS112TopEdnsParamsFormat string + +const ( + AS112TopEdnsParamsFormatJson AS112TopEdnsParamsFormat = "JSON" + AS112TopEdnsParamsFormatCsv AS112TopEdnsParamsFormat = "CSV" +) + +type AS112TopEdnsResponseEnvelope struct { + Result AS112TopEdnsResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON as112TopEdnsResponseEnvelopeJSON `json:"-"` +} + +// as112TopEdnsResponseEnvelopeJSON contains the JSON metadata for the struct +// [AS112TopEdnsResponseEnvelope] +type as112TopEdnsResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopEdnsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopEdnsResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AS112TopIPVersionParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AS112TopIPVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AS112TopIPVersionParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AS112TopIPVersionParams]'s query parameters as +// `url.Values`. +func (r AS112TopIPVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// IP Version. +type AS112TopIPVersionParamsIPVersion string + +const ( + AS112TopIPVersionParamsIPVersionIPv4 AS112TopIPVersionParamsIPVersion = "IPv4" + AS112TopIPVersionParamsIPVersionIPv6 AS112TopIPVersionParamsIPVersion = "IPv6" +) + +type AS112TopIPVersionParamsDateRange string + +const ( + AS112TopIPVersionParamsDateRange1d AS112TopIPVersionParamsDateRange = "1d" + AS112TopIPVersionParamsDateRange2d AS112TopIPVersionParamsDateRange = "2d" + AS112TopIPVersionParamsDateRange7d AS112TopIPVersionParamsDateRange = "7d" + AS112TopIPVersionParamsDateRange14d AS112TopIPVersionParamsDateRange = "14d" + AS112TopIPVersionParamsDateRange28d AS112TopIPVersionParamsDateRange = "28d" + AS112TopIPVersionParamsDateRange12w AS112TopIPVersionParamsDateRange = "12w" + AS112TopIPVersionParamsDateRange24w AS112TopIPVersionParamsDateRange = "24w" + AS112TopIPVersionParamsDateRange52w AS112TopIPVersionParamsDateRange = "52w" + AS112TopIPVersionParamsDateRange1dControl AS112TopIPVersionParamsDateRange = "1dControl" + AS112TopIPVersionParamsDateRange2dControl AS112TopIPVersionParamsDateRange = "2dControl" + AS112TopIPVersionParamsDateRange7dControl AS112TopIPVersionParamsDateRange = "7dControl" + AS112TopIPVersionParamsDateRange14dControl AS112TopIPVersionParamsDateRange = "14dControl" + AS112TopIPVersionParamsDateRange28dControl AS112TopIPVersionParamsDateRange = "28dControl" + AS112TopIPVersionParamsDateRange12wControl AS112TopIPVersionParamsDateRange = "12wControl" + AS112TopIPVersionParamsDateRange24wControl AS112TopIPVersionParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AS112TopIPVersionParamsFormat string + +const ( + AS112TopIPVersionParamsFormatJson AS112TopIPVersionParamsFormat = "JSON" + AS112TopIPVersionParamsFormatCsv AS112TopIPVersionParamsFormat = "CSV" +) + +type AS112TopIPVersionResponseEnvelope struct { + Result AS112TopIPVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON as112TopIPVersionResponseEnvelopeJSON `json:"-"` +} + +// as112TopIPVersionResponseEnvelopeJSON contains the JSON metadata for the struct +// [AS112TopIPVersionResponseEnvelope] +type as112TopIPVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopIPVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AS112TopLocationsParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AS112TopLocationsParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AS112TopLocationsParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AS112TopLocationsParams]'s query parameters as +// `url.Values`. +func (r AS112TopLocationsParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AS112TopLocationsParamsDateRange string + +const ( + AS112TopLocationsParamsDateRange1d AS112TopLocationsParamsDateRange = "1d" + AS112TopLocationsParamsDateRange2d AS112TopLocationsParamsDateRange = "2d" + AS112TopLocationsParamsDateRange7d AS112TopLocationsParamsDateRange = "7d" + AS112TopLocationsParamsDateRange14d AS112TopLocationsParamsDateRange = "14d" + AS112TopLocationsParamsDateRange28d AS112TopLocationsParamsDateRange = "28d" + AS112TopLocationsParamsDateRange12w AS112TopLocationsParamsDateRange = "12w" + AS112TopLocationsParamsDateRange24w AS112TopLocationsParamsDateRange = "24w" + AS112TopLocationsParamsDateRange52w AS112TopLocationsParamsDateRange = "52w" + AS112TopLocationsParamsDateRange1dControl AS112TopLocationsParamsDateRange = "1dControl" + AS112TopLocationsParamsDateRange2dControl AS112TopLocationsParamsDateRange = "2dControl" + AS112TopLocationsParamsDateRange7dControl AS112TopLocationsParamsDateRange = "7dControl" + AS112TopLocationsParamsDateRange14dControl AS112TopLocationsParamsDateRange = "14dControl" + AS112TopLocationsParamsDateRange28dControl AS112TopLocationsParamsDateRange = "28dControl" + AS112TopLocationsParamsDateRange12wControl AS112TopLocationsParamsDateRange = "12wControl" + AS112TopLocationsParamsDateRange24wControl AS112TopLocationsParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AS112TopLocationsParamsFormat string + +const ( + AS112TopLocationsParamsFormatJson AS112TopLocationsParamsFormat = "JSON" + AS112TopLocationsParamsFormatCsv AS112TopLocationsParamsFormat = "CSV" +) + +type AS112TopLocationsResponseEnvelope struct { + Result AS112TopLocationsResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON as112TopLocationsResponseEnvelopeJSON `json:"-"` +} + +// as112TopLocationsResponseEnvelopeJSON contains the JSON metadata for the struct +// [AS112TopLocationsResponseEnvelope] +type as112TopLocationsResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AS112TopLocationsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r as112TopLocationsResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/as112top_test.go b/radar/as112top_test.go new file mode 100644 index 00000000000..bfd139cb4e4 --- /dev/null +++ b/radar/as112top_test.go @@ -0,0 +1,164 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestAS112TopDNSSECWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.AS112.Top.DNSSEC( + context.TODO(), + radar.AS112TopDNSSECParamsDNSSECSupported, + radar.AS112TopDNSSECParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AS112TopDNSSECParamsDateRange{radar.AS112TopDNSSECParamsDateRange1d, radar.AS112TopDNSSECParamsDateRange2d, radar.AS112TopDNSSECParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AS112TopDNSSECParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }, + ) + 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 TestAS112TopEdnsWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.AS112.Top.Edns( + context.TODO(), + radar.AS112TopEdnsParamsEdnsSupported, + radar.AS112TopEdnsParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AS112TopEdnsParamsDateRange{radar.AS112TopEdnsParamsDateRange1d, radar.AS112TopEdnsParamsDateRange2d, radar.AS112TopEdnsParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AS112TopEdnsParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }, + ) + 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 TestAS112TopIPVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.AS112.Top.IPVersion( + context.TODO(), + radar.AS112TopIPVersionParamsIPVersionIPv4, + radar.AS112TopIPVersionParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AS112TopIPVersionParamsDateRange{radar.AS112TopIPVersionParamsDateRange1d, radar.AS112TopIPVersionParamsDateRange2d, radar.AS112TopIPVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AS112TopIPVersionParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }, + ) + 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 TestAS112TopLocationsWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.AS112.Top.Locations(context.TODO(), radar.AS112TopLocationsParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AS112TopLocationsParamsDateRange{radar.AS112TopLocationsParamsDateRange1d, radar.AS112TopLocationsParamsDateRange2d, radar.AS112TopLocationsParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AS112TopLocationsParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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/radar/attack.go b/radar/attack.go new file mode 100644 index 00000000000..c3a6d34bbe0 --- /dev/null +++ b/radar/attack.go @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// AttackService 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 [NewAttackService] method instead. +type AttackService struct { + Options []option.RequestOption + Layer3 *AttackLayer3Service + Layer7 *AttackLayer7Service +} + +// NewAttackService 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 NewAttackService(opts ...option.RequestOption) (r *AttackService) { + r = &AttackService{} + r.Options = opts + r.Layer3 = NewAttackLayer3Service(opts...) + r.Layer7 = NewAttackLayer7Service(opts...) + return +} diff --git a/radar/attacklayer3.go b/radar/attacklayer3.go new file mode 100644 index 00000000000..914a2af70c5 --- /dev/null +++ b/radar/attacklayer3.go @@ -0,0 +1,256 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AttackLayer3Service 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 [NewAttackLayer3Service] method +// instead. +type AttackLayer3Service struct { + Options []option.RequestOption + Summary *AttackLayer3SummaryService + TimeseriesGroups *AttackLayer3TimeseriesGroupService + Top *AttackLayer3TopService +} + +// NewAttackLayer3Service 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 NewAttackLayer3Service(opts ...option.RequestOption) (r *AttackLayer3Service) { + r = &AttackLayer3Service{} + r.Options = opts + r.Summary = NewAttackLayer3SummaryService(opts...) + r.TimeseriesGroups = NewAttackLayer3TimeseriesGroupService(opts...) + r.Top = NewAttackLayer3TopService(opts...) + return +} + +// Get attacks change over time by bytes. +func (r *AttackLayer3Service) Timeseries(ctx context.Context, query AttackLayer3TimeseriesParams, opts ...option.RequestOption) (res *AttackLayer3TimeseriesResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3TimeseriesResponseEnvelope + path := "radar/attacks/layer3/timeseries" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AttackLayer3TimeseriesResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AttackLayer3TimeseriesResponseSerie0 `json:"serie_0,required"` + JSON attackLayer3TimeseriesResponseJSON `json:"-"` +} + +// attackLayer3TimeseriesResponseJSON contains the JSON metadata for the struct +// [AttackLayer3TimeseriesResponse] +type attackLayer3TimeseriesResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesResponseSerie0 struct { + Timestamps []string `json:"timestamps,required"` + Values []string `json:"values,required"` + JSON attackLayer3TimeseriesResponseSerie0JSON `json:"-"` +} + +// attackLayer3TimeseriesResponseSerie0JSON contains the JSON metadata for the +// struct [AttackLayer3TimeseriesResponseSerie0] +type attackLayer3TimeseriesResponseSerie0JSON struct { + Timestamps apijson.Field + Values apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AttackLayer3TimeseriesParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3TimeseriesParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Together with the `location` parameter, will apply the filter to origin or + // target location. + Direction param.Field[AttackLayer3TimeseriesParamsDirection] `query:"direction"` + // Format results are returned in. + Format param.Field[AttackLayer3TimeseriesParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer3TimeseriesParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Measurement units, eg. bytes. + Metric param.Field[AttackLayer3TimeseriesParamsMetric] `query:"metric"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Normalization method applied. Refer to + // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + Normalization param.Field[AttackLayer3TimeseriesParamsNormalization] `query:"normalization"` + // Array of L3/4 attack types. + Protocol param.Field[[]AttackLayer3TimeseriesParamsProtocol] `query:"protocol"` +} + +// URLQuery serializes [AttackLayer3TimeseriesParams]'s query parameters as +// `url.Values`. +func (r AttackLayer3TimeseriesParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AttackLayer3TimeseriesParamsAggInterval string + +const ( + AttackLayer3TimeseriesParamsAggInterval15m AttackLayer3TimeseriesParamsAggInterval = "15m" + AttackLayer3TimeseriesParamsAggInterval1h AttackLayer3TimeseriesParamsAggInterval = "1h" + AttackLayer3TimeseriesParamsAggInterval1d AttackLayer3TimeseriesParamsAggInterval = "1d" + AttackLayer3TimeseriesParamsAggInterval1w AttackLayer3TimeseriesParamsAggInterval = "1w" +) + +type AttackLayer3TimeseriesParamsDateRange string + +const ( + AttackLayer3TimeseriesParamsDateRange1d AttackLayer3TimeseriesParamsDateRange = "1d" + AttackLayer3TimeseriesParamsDateRange2d AttackLayer3TimeseriesParamsDateRange = "2d" + AttackLayer3TimeseriesParamsDateRange7d AttackLayer3TimeseriesParamsDateRange = "7d" + AttackLayer3TimeseriesParamsDateRange14d AttackLayer3TimeseriesParamsDateRange = "14d" + AttackLayer3TimeseriesParamsDateRange28d AttackLayer3TimeseriesParamsDateRange = "28d" + AttackLayer3TimeseriesParamsDateRange12w AttackLayer3TimeseriesParamsDateRange = "12w" + AttackLayer3TimeseriesParamsDateRange24w AttackLayer3TimeseriesParamsDateRange = "24w" + AttackLayer3TimeseriesParamsDateRange52w AttackLayer3TimeseriesParamsDateRange = "52w" + AttackLayer3TimeseriesParamsDateRange1dControl AttackLayer3TimeseriesParamsDateRange = "1dControl" + AttackLayer3TimeseriesParamsDateRange2dControl AttackLayer3TimeseriesParamsDateRange = "2dControl" + AttackLayer3TimeseriesParamsDateRange7dControl AttackLayer3TimeseriesParamsDateRange = "7dControl" + AttackLayer3TimeseriesParamsDateRange14dControl AttackLayer3TimeseriesParamsDateRange = "14dControl" + AttackLayer3TimeseriesParamsDateRange28dControl AttackLayer3TimeseriesParamsDateRange = "28dControl" + AttackLayer3TimeseriesParamsDateRange12wControl AttackLayer3TimeseriesParamsDateRange = "12wControl" + AttackLayer3TimeseriesParamsDateRange24wControl AttackLayer3TimeseriesParamsDateRange = "24wControl" +) + +// Together with the `location` parameter, will apply the filter to origin or +// target location. +type AttackLayer3TimeseriesParamsDirection string + +const ( + AttackLayer3TimeseriesParamsDirectionOrigin AttackLayer3TimeseriesParamsDirection = "ORIGIN" + AttackLayer3TimeseriesParamsDirectionTarget AttackLayer3TimeseriesParamsDirection = "TARGET" +) + +// Format results are returned in. +type AttackLayer3TimeseriesParamsFormat string + +const ( + AttackLayer3TimeseriesParamsFormatJson AttackLayer3TimeseriesParamsFormat = "JSON" + AttackLayer3TimeseriesParamsFormatCsv AttackLayer3TimeseriesParamsFormat = "CSV" +) + +type AttackLayer3TimeseriesParamsIPVersion string + +const ( + AttackLayer3TimeseriesParamsIPVersionIPv4 AttackLayer3TimeseriesParamsIPVersion = "IPv4" + AttackLayer3TimeseriesParamsIPVersionIPv6 AttackLayer3TimeseriesParamsIPVersion = "IPv6" +) + +// Measurement units, eg. bytes. +type AttackLayer3TimeseriesParamsMetric string + +const ( + AttackLayer3TimeseriesParamsMetricBytes AttackLayer3TimeseriesParamsMetric = "BYTES" + AttackLayer3TimeseriesParamsMetricBytesOld AttackLayer3TimeseriesParamsMetric = "BYTES_OLD" +) + +// Normalization method applied. Refer to +// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). +type AttackLayer3TimeseriesParamsNormalization string + +const ( + AttackLayer3TimeseriesParamsNormalizationPercentageChange AttackLayer3TimeseriesParamsNormalization = "PERCENTAGE_CHANGE" + AttackLayer3TimeseriesParamsNormalizationMin0Max AttackLayer3TimeseriesParamsNormalization = "MIN0_MAX" +) + +type AttackLayer3TimeseriesParamsProtocol string + +const ( + AttackLayer3TimeseriesParamsProtocolUdp AttackLayer3TimeseriesParamsProtocol = "UDP" + AttackLayer3TimeseriesParamsProtocolTcp AttackLayer3TimeseriesParamsProtocol = "TCP" + AttackLayer3TimeseriesParamsProtocolIcmp AttackLayer3TimeseriesParamsProtocol = "ICMP" + AttackLayer3TimeseriesParamsProtocolGRE AttackLayer3TimeseriesParamsProtocol = "GRE" +) + +type AttackLayer3TimeseriesResponseEnvelope struct { + Result AttackLayer3TimeseriesResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3TimeseriesResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3TimeseriesResponseEnvelopeJSON contains the JSON metadata for the +// struct [AttackLayer3TimeseriesResponseEnvelope] +type attackLayer3TimeseriesResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/attacklayer3_test.go b/radar/attacklayer3_test.go new file mode 100644 index 00000000000..723b598e7c7 --- /dev/null +++ b/radar/attacklayer3_test.go @@ -0,0 +1,55 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestAttackLayer3TimeseriesWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.Timeseries(context.TODO(), radar.AttackLayer3TimeseriesParams{ + AggInterval: cloudflare.F(radar.AttackLayer3TimeseriesParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3TimeseriesParamsDateRange{radar.AttackLayer3TimeseriesParamsDateRange1d, radar.AttackLayer3TimeseriesParamsDateRange2d, radar.AttackLayer3TimeseriesParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Direction: cloudflare.F(radar.AttackLayer3TimeseriesParamsDirectionOrigin), + Format: cloudflare.F(radar.AttackLayer3TimeseriesParamsFormatJson), + IPVersion: cloudflare.F([]radar.AttackLayer3TimeseriesParamsIPVersion{radar.AttackLayer3TimeseriesParamsIPVersionIPv4, radar.AttackLayer3TimeseriesParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Metric: cloudflare.F(radar.AttackLayer3TimeseriesParamsMetricBytes), + Name: cloudflare.F([]string{"string", "string", "string"}), + Normalization: cloudflare.F(radar.AttackLayer3TimeseriesParamsNormalizationMin0Max), + Protocol: cloudflare.F([]radar.AttackLayer3TimeseriesParamsProtocol{radar.AttackLayer3TimeseriesParamsProtocolUdp, radar.AttackLayer3TimeseriesParamsProtocolTcp, radar.AttackLayer3TimeseriesParamsProtocolIcmp}), + }) + 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/radar/attacklayer3summary.go b/radar/attacklayer3summary.go new file mode 100644 index 00000000000..01a3b66aabf --- /dev/null +++ b/radar/attacklayer3summary.go @@ -0,0 +1,1680 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AttackLayer3SummaryService 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 [NewAttackLayer3SummaryService] +// method instead. +type AttackLayer3SummaryService struct { + Options []option.RequestOption +} + +// NewAttackLayer3SummaryService 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 NewAttackLayer3SummaryService(opts ...option.RequestOption) (r *AttackLayer3SummaryService) { + r = &AttackLayer3SummaryService{} + r.Options = opts + return +} + +// Percentage distribution of attacks by bitrate. +func (r *AttackLayer3SummaryService) Bitrate(ctx context.Context, query AttackLayer3SummaryBitrateParams, opts ...option.RequestOption) (res *AttackLayer3SummaryBitrateResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3SummaryBitrateResponseEnvelope + path := "radar/attacks/layer3/summary/bitrate" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by duration. +func (r *AttackLayer3SummaryService) Duration(ctx context.Context, query AttackLayer3SummaryDurationParams, opts ...option.RequestOption) (res *AttackLayer3SummaryDurationResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3SummaryDurationResponseEnvelope + path := "radar/attacks/layer3/summary/duration" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of network protocols in layer 3/4 attacks over a given +// time period. +func (r *AttackLayer3SummaryService) Get(ctx context.Context, query AttackLayer3SummaryGetParams, opts ...option.RequestOption) (res *AttackLayer3SummaryGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3SummaryGetResponseEnvelope + path := "radar/attacks/layer3/summary" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by ip version used. +func (r *AttackLayer3SummaryService) IPVersion(ctx context.Context, query AttackLayer3SummaryIPVersionParams, opts ...option.RequestOption) (res *AttackLayer3SummaryIPVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3SummaryIPVersionResponseEnvelope + path := "radar/attacks/layer3/summary/ip_version" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by protocol used. +func (r *AttackLayer3SummaryService) Protocol(ctx context.Context, query AttackLayer3SummaryProtocolParams, opts ...option.RequestOption) (res *AttackLayer3SummaryProtocolResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3SummaryProtocolResponseEnvelope + path := "radar/attacks/layer3/summary/protocol" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by vector. +func (r *AttackLayer3SummaryService) Vector(ctx context.Context, query AttackLayer3SummaryVectorParams, opts ...option.RequestOption) (res *AttackLayer3SummaryVectorResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3SummaryVectorResponseEnvelope + path := "radar/attacks/layer3/summary/vector" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AttackLayer3SummaryBitrateResponse struct { + Meta AttackLayer3SummaryBitrateResponseMeta `json:"meta,required"` + Summary0 AttackLayer3SummaryBitrateResponseSummary0 `json:"summary_0,required"` + JSON attackLayer3SummaryBitrateResponseJSON `json:"-"` +} + +// attackLayer3SummaryBitrateResponseJSON contains the JSON metadata for the struct +// [AttackLayer3SummaryBitrateResponse] +type attackLayer3SummaryBitrateResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryBitrateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryBitrateResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryBitrateResponseMeta struct { + DateRange []AttackLayer3SummaryBitrateResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo AttackLayer3SummaryBitrateResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer3SummaryBitrateResponseMetaJSON `json:"-"` +} + +// attackLayer3SummaryBitrateResponseMetaJSON contains the JSON metadata for the +// struct [AttackLayer3SummaryBitrateResponseMeta] +type attackLayer3SummaryBitrateResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryBitrateResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryBitrateResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryBitrateResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer3SummaryBitrateResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer3SummaryBitrateResponseMetaDateRangeJSON contains the JSON metadata +// for the struct [AttackLayer3SummaryBitrateResponseMetaDateRange] +type attackLayer3SummaryBitrateResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryBitrateResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryBitrateResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryBitrateResponseMetaConfidenceInfo struct { + Annotations []AttackLayer3SummaryBitrateResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer3SummaryBitrateResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer3SummaryBitrateResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [AttackLayer3SummaryBitrateResponseMetaConfidenceInfo] +type attackLayer3SummaryBitrateResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryBitrateResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryBitrateResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryBitrateResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer3SummaryBitrateResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer3SummaryBitrateResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [AttackLayer3SummaryBitrateResponseMetaConfidenceInfoAnnotation] +type attackLayer3SummaryBitrateResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryBitrateResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryBitrateResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryBitrateResponseSummary0 struct { + Number1GbpsTo10Gbps string `json:"_1_GBPS_TO_10_GBPS,required"` + Number10GbpsTo100Gbps string `json:"_10_GBPS_TO_100_GBPS,required"` + Number500MbpsTo1Gbps string `json:"_500_MBPS_TO_1_GBPS,required"` + Over100Gbps string `json:"OVER_100_GBPS,required"` + Under500Mbps string `json:"UNDER_500_MBPS,required"` + JSON attackLayer3SummaryBitrateResponseSummary0JSON `json:"-"` +} + +// attackLayer3SummaryBitrateResponseSummary0JSON contains the JSON metadata for +// the struct [AttackLayer3SummaryBitrateResponseSummary0] +type attackLayer3SummaryBitrateResponseSummary0JSON struct { + Number1GbpsTo10Gbps apijson.Field + Number10GbpsTo100Gbps apijson.Field + Number500MbpsTo1Gbps apijson.Field + Over100Gbps apijson.Field + Under500Mbps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryBitrateResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryBitrateResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryDurationResponse struct { + Meta AttackLayer3SummaryDurationResponseMeta `json:"meta,required"` + Summary0 AttackLayer3SummaryDurationResponseSummary0 `json:"summary_0,required"` + JSON attackLayer3SummaryDurationResponseJSON `json:"-"` +} + +// attackLayer3SummaryDurationResponseJSON contains the JSON metadata for the +// struct [AttackLayer3SummaryDurationResponse] +type attackLayer3SummaryDurationResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryDurationResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryDurationResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryDurationResponseMeta struct { + DateRange []AttackLayer3SummaryDurationResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo AttackLayer3SummaryDurationResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer3SummaryDurationResponseMetaJSON `json:"-"` +} + +// attackLayer3SummaryDurationResponseMetaJSON contains the JSON metadata for the +// struct [AttackLayer3SummaryDurationResponseMeta] +type attackLayer3SummaryDurationResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryDurationResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryDurationResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryDurationResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer3SummaryDurationResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer3SummaryDurationResponseMetaDateRangeJSON contains the JSON metadata +// for the struct [AttackLayer3SummaryDurationResponseMetaDateRange] +type attackLayer3SummaryDurationResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryDurationResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryDurationResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryDurationResponseMetaConfidenceInfo struct { + Annotations []AttackLayer3SummaryDurationResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer3SummaryDurationResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer3SummaryDurationResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [AttackLayer3SummaryDurationResponseMetaConfidenceInfo] +type attackLayer3SummaryDurationResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryDurationResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryDurationResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryDurationResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer3SummaryDurationResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer3SummaryDurationResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [AttackLayer3SummaryDurationResponseMetaConfidenceInfoAnnotation] +type attackLayer3SummaryDurationResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryDurationResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryDurationResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryDurationResponseSummary0 struct { + Number1HourTo3Hours string `json:"_1_HOUR_TO_3_HOURS,required"` + Number10MinsTo20Mins string `json:"_10_MINS_TO_20_MINS,required"` + Number20MinsTo40Mins string `json:"_20_MINS_TO_40_MINS,required"` + Number40MinsTo1Hour string `json:"_40_MINS_TO_1_HOUR,required"` + Over3Hours string `json:"OVER_3_HOURS,required"` + Under10Mins string `json:"UNDER_10_MINS,required"` + JSON attackLayer3SummaryDurationResponseSummary0JSON `json:"-"` +} + +// attackLayer3SummaryDurationResponseSummary0JSON contains the JSON metadata for +// the struct [AttackLayer3SummaryDurationResponseSummary0] +type attackLayer3SummaryDurationResponseSummary0JSON struct { + Number1HourTo3Hours apijson.Field + Number10MinsTo20Mins apijson.Field + Number20MinsTo40Mins apijson.Field + Number40MinsTo1Hour apijson.Field + Over3Hours apijson.Field + Under10Mins apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryDurationResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryDurationResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryGetResponse struct { + Meta AttackLayer3SummaryGetResponseMeta `json:"meta,required"` + Summary0 AttackLayer3SummaryGetResponseSummary0 `json:"summary_0,required"` + JSON attackLayer3SummaryGetResponseJSON `json:"-"` +} + +// attackLayer3SummaryGetResponseJSON contains the JSON metadata for the struct +// [AttackLayer3SummaryGetResponse] +type attackLayer3SummaryGetResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryGetResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryGetResponseMeta struct { + DateRange []AttackLayer3SummaryGetResponseMetaDateRange `json:"dateRange,required"` + ConfidenceInfo AttackLayer3SummaryGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer3SummaryGetResponseMetaJSON `json:"-"` +} + +// attackLayer3SummaryGetResponseMetaJSON contains the JSON metadata for the struct +// [AttackLayer3SummaryGetResponseMeta] +type attackLayer3SummaryGetResponseMetaJSON struct { + DateRange apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer3SummaryGetResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer3SummaryGetResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [AttackLayer3SummaryGetResponseMetaDateRange] +type attackLayer3SummaryGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryGetResponseMetaConfidenceInfo struct { + Annotations []AttackLayer3SummaryGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer3SummaryGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer3SummaryGetResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [AttackLayer3SummaryGetResponseMetaConfidenceInfo] +type attackLayer3SummaryGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer3SummaryGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer3SummaryGetResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [AttackLayer3SummaryGetResponseMetaConfidenceInfoAnnotation] +type attackLayer3SummaryGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryGetResponseSummary0 struct { + GRE string `json:"gre,required"` + Icmp string `json:"icmp,required"` + Tcp string `json:"tcp,required"` + Udp string `json:"udp,required"` + JSON attackLayer3SummaryGetResponseSummary0JSON `json:"-"` +} + +// attackLayer3SummaryGetResponseSummary0JSON contains the JSON metadata for the +// struct [AttackLayer3SummaryGetResponseSummary0] +type attackLayer3SummaryGetResponseSummary0JSON struct { + GRE apijson.Field + Icmp apijson.Field + Tcp apijson.Field + Udp apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryGetResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryGetResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryIPVersionResponse struct { + Meta AttackLayer3SummaryIPVersionResponseMeta `json:"meta,required"` + Summary0 AttackLayer3SummaryIPVersionResponseSummary0 `json:"summary_0,required"` + JSON attackLayer3SummaryIPVersionResponseJSON `json:"-"` +} + +// attackLayer3SummaryIPVersionResponseJSON contains the JSON metadata for the +// struct [AttackLayer3SummaryIPVersionResponse] +type attackLayer3SummaryIPVersionResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryIPVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryIPVersionResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryIPVersionResponseMeta struct { + DateRange []AttackLayer3SummaryIPVersionResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo AttackLayer3SummaryIPVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer3SummaryIPVersionResponseMetaJSON `json:"-"` +} + +// attackLayer3SummaryIPVersionResponseMetaJSON contains the JSON metadata for the +// struct [AttackLayer3SummaryIPVersionResponseMeta] +type attackLayer3SummaryIPVersionResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryIPVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryIPVersionResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryIPVersionResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer3SummaryIPVersionResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer3SummaryIPVersionResponseMetaDateRangeJSON contains the JSON metadata +// for the struct [AttackLayer3SummaryIPVersionResponseMetaDateRange] +type attackLayer3SummaryIPVersionResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryIPVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryIPVersionResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryIPVersionResponseMetaConfidenceInfo struct { + Annotations []AttackLayer3SummaryIPVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer3SummaryIPVersionResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer3SummaryIPVersionResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [AttackLayer3SummaryIPVersionResponseMetaConfidenceInfo] +type attackLayer3SummaryIPVersionResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryIPVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryIPVersionResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryIPVersionResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer3SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer3SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON contains +// the JSON metadata for the struct +// [AttackLayer3SummaryIPVersionResponseMetaConfidenceInfoAnnotation] +type attackLayer3SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryIPVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryIPVersionResponseSummary0 struct { + IPv4 string `json:"IPv4,required"` + IPv6 string `json:"IPv6,required"` + JSON attackLayer3SummaryIPVersionResponseSummary0JSON `json:"-"` +} + +// attackLayer3SummaryIPVersionResponseSummary0JSON contains the JSON metadata for +// the struct [AttackLayer3SummaryIPVersionResponseSummary0] +type attackLayer3SummaryIPVersionResponseSummary0JSON struct { + IPv4 apijson.Field + IPv6 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryIPVersionResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryIPVersionResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryProtocolResponse struct { + Meta AttackLayer3SummaryProtocolResponseMeta `json:"meta,required"` + Summary0 AttackLayer3SummaryProtocolResponseSummary0 `json:"summary_0,required"` + JSON attackLayer3SummaryProtocolResponseJSON `json:"-"` +} + +// attackLayer3SummaryProtocolResponseJSON contains the JSON metadata for the +// struct [AttackLayer3SummaryProtocolResponse] +type attackLayer3SummaryProtocolResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryProtocolResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryProtocolResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryProtocolResponseMeta struct { + DateRange []AttackLayer3SummaryProtocolResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo AttackLayer3SummaryProtocolResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer3SummaryProtocolResponseMetaJSON `json:"-"` +} + +// attackLayer3SummaryProtocolResponseMetaJSON contains the JSON metadata for the +// struct [AttackLayer3SummaryProtocolResponseMeta] +type attackLayer3SummaryProtocolResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryProtocolResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryProtocolResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryProtocolResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer3SummaryProtocolResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer3SummaryProtocolResponseMetaDateRangeJSON contains the JSON metadata +// for the struct [AttackLayer3SummaryProtocolResponseMetaDateRange] +type attackLayer3SummaryProtocolResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryProtocolResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryProtocolResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryProtocolResponseMetaConfidenceInfo struct { + Annotations []AttackLayer3SummaryProtocolResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer3SummaryProtocolResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer3SummaryProtocolResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [AttackLayer3SummaryProtocolResponseMetaConfidenceInfo] +type attackLayer3SummaryProtocolResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryProtocolResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryProtocolResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryProtocolResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer3SummaryProtocolResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer3SummaryProtocolResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [AttackLayer3SummaryProtocolResponseMetaConfidenceInfoAnnotation] +type attackLayer3SummaryProtocolResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryProtocolResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryProtocolResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryProtocolResponseSummary0 struct { + GRE string `json:"GRE,required"` + Icmp string `json:"ICMP,required"` + Tcp string `json:"TCP,required"` + Udp string `json:"UDP,required"` + JSON attackLayer3SummaryProtocolResponseSummary0JSON `json:"-"` +} + +// attackLayer3SummaryProtocolResponseSummary0JSON contains the JSON metadata for +// the struct [AttackLayer3SummaryProtocolResponseSummary0] +type attackLayer3SummaryProtocolResponseSummary0JSON struct { + GRE apijson.Field + Icmp apijson.Field + Tcp apijson.Field + Udp apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryProtocolResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryProtocolResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryVectorResponse struct { + Meta AttackLayer3SummaryVectorResponseMeta `json:"meta,required"` + Summary0 map[string][]string `json:"summary_0,required"` + JSON attackLayer3SummaryVectorResponseJSON `json:"-"` +} + +// attackLayer3SummaryVectorResponseJSON contains the JSON metadata for the struct +// [AttackLayer3SummaryVectorResponse] +type attackLayer3SummaryVectorResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryVectorResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryVectorResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryVectorResponseMeta struct { + DateRange []AttackLayer3SummaryVectorResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo AttackLayer3SummaryVectorResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer3SummaryVectorResponseMetaJSON `json:"-"` +} + +// attackLayer3SummaryVectorResponseMetaJSON contains the JSON metadata for the +// struct [AttackLayer3SummaryVectorResponseMeta] +type attackLayer3SummaryVectorResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryVectorResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryVectorResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryVectorResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer3SummaryVectorResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer3SummaryVectorResponseMetaDateRangeJSON contains the JSON metadata +// for the struct [AttackLayer3SummaryVectorResponseMetaDateRange] +type attackLayer3SummaryVectorResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryVectorResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryVectorResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryVectorResponseMetaConfidenceInfo struct { + Annotations []AttackLayer3SummaryVectorResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer3SummaryVectorResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer3SummaryVectorResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [AttackLayer3SummaryVectorResponseMetaConfidenceInfo] +type attackLayer3SummaryVectorResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryVectorResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryVectorResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryVectorResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer3SummaryVectorResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer3SummaryVectorResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [AttackLayer3SummaryVectorResponseMetaConfidenceInfoAnnotation] +type attackLayer3SummaryVectorResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryVectorResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryVectorResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryBitrateParams struct { + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3SummaryBitrateParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Together with the `location` parameter, will apply the filter to origin or + // target location. + Direction param.Field[AttackLayer3SummaryBitrateParamsDirection] `query:"direction"` + // Format results are returned in. + Format param.Field[AttackLayer3SummaryBitrateParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer3SummaryBitrateParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Array of L3/4 attack types. + Protocol param.Field[[]AttackLayer3SummaryBitrateParamsProtocol] `query:"protocol"` +} + +// URLQuery serializes [AttackLayer3SummaryBitrateParams]'s query parameters as +// `url.Values`. +func (r AttackLayer3SummaryBitrateParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer3SummaryBitrateParamsDateRange string + +const ( + AttackLayer3SummaryBitrateParamsDateRange1d AttackLayer3SummaryBitrateParamsDateRange = "1d" + AttackLayer3SummaryBitrateParamsDateRange2d AttackLayer3SummaryBitrateParamsDateRange = "2d" + AttackLayer3SummaryBitrateParamsDateRange7d AttackLayer3SummaryBitrateParamsDateRange = "7d" + AttackLayer3SummaryBitrateParamsDateRange14d AttackLayer3SummaryBitrateParamsDateRange = "14d" + AttackLayer3SummaryBitrateParamsDateRange28d AttackLayer3SummaryBitrateParamsDateRange = "28d" + AttackLayer3SummaryBitrateParamsDateRange12w AttackLayer3SummaryBitrateParamsDateRange = "12w" + AttackLayer3SummaryBitrateParamsDateRange24w AttackLayer3SummaryBitrateParamsDateRange = "24w" + AttackLayer3SummaryBitrateParamsDateRange52w AttackLayer3SummaryBitrateParamsDateRange = "52w" + AttackLayer3SummaryBitrateParamsDateRange1dControl AttackLayer3SummaryBitrateParamsDateRange = "1dControl" + AttackLayer3SummaryBitrateParamsDateRange2dControl AttackLayer3SummaryBitrateParamsDateRange = "2dControl" + AttackLayer3SummaryBitrateParamsDateRange7dControl AttackLayer3SummaryBitrateParamsDateRange = "7dControl" + AttackLayer3SummaryBitrateParamsDateRange14dControl AttackLayer3SummaryBitrateParamsDateRange = "14dControl" + AttackLayer3SummaryBitrateParamsDateRange28dControl AttackLayer3SummaryBitrateParamsDateRange = "28dControl" + AttackLayer3SummaryBitrateParamsDateRange12wControl AttackLayer3SummaryBitrateParamsDateRange = "12wControl" + AttackLayer3SummaryBitrateParamsDateRange24wControl AttackLayer3SummaryBitrateParamsDateRange = "24wControl" +) + +// Together with the `location` parameter, will apply the filter to origin or +// target location. +type AttackLayer3SummaryBitrateParamsDirection string + +const ( + AttackLayer3SummaryBitrateParamsDirectionOrigin AttackLayer3SummaryBitrateParamsDirection = "ORIGIN" + AttackLayer3SummaryBitrateParamsDirectionTarget AttackLayer3SummaryBitrateParamsDirection = "TARGET" +) + +// Format results are returned in. +type AttackLayer3SummaryBitrateParamsFormat string + +const ( + AttackLayer3SummaryBitrateParamsFormatJson AttackLayer3SummaryBitrateParamsFormat = "JSON" + AttackLayer3SummaryBitrateParamsFormatCsv AttackLayer3SummaryBitrateParamsFormat = "CSV" +) + +type AttackLayer3SummaryBitrateParamsIPVersion string + +const ( + AttackLayer3SummaryBitrateParamsIPVersionIPv4 AttackLayer3SummaryBitrateParamsIPVersion = "IPv4" + AttackLayer3SummaryBitrateParamsIPVersionIPv6 AttackLayer3SummaryBitrateParamsIPVersion = "IPv6" +) + +type AttackLayer3SummaryBitrateParamsProtocol string + +const ( + AttackLayer3SummaryBitrateParamsProtocolUdp AttackLayer3SummaryBitrateParamsProtocol = "UDP" + AttackLayer3SummaryBitrateParamsProtocolTcp AttackLayer3SummaryBitrateParamsProtocol = "TCP" + AttackLayer3SummaryBitrateParamsProtocolIcmp AttackLayer3SummaryBitrateParamsProtocol = "ICMP" + AttackLayer3SummaryBitrateParamsProtocolGRE AttackLayer3SummaryBitrateParamsProtocol = "GRE" +) + +type AttackLayer3SummaryBitrateResponseEnvelope struct { + Result AttackLayer3SummaryBitrateResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3SummaryBitrateResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3SummaryBitrateResponseEnvelopeJSON contains the JSON metadata for +// the struct [AttackLayer3SummaryBitrateResponseEnvelope] +type attackLayer3SummaryBitrateResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryBitrateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryBitrateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryDurationParams struct { + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3SummaryDurationParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Together with the `location` parameter, will apply the filter to origin or + // target location. + Direction param.Field[AttackLayer3SummaryDurationParamsDirection] `query:"direction"` + // Format results are returned in. + Format param.Field[AttackLayer3SummaryDurationParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer3SummaryDurationParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Array of L3/4 attack types. + Protocol param.Field[[]AttackLayer3SummaryDurationParamsProtocol] `query:"protocol"` +} + +// URLQuery serializes [AttackLayer3SummaryDurationParams]'s query parameters as +// `url.Values`. +func (r AttackLayer3SummaryDurationParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer3SummaryDurationParamsDateRange string + +const ( + AttackLayer3SummaryDurationParamsDateRange1d AttackLayer3SummaryDurationParamsDateRange = "1d" + AttackLayer3SummaryDurationParamsDateRange2d AttackLayer3SummaryDurationParamsDateRange = "2d" + AttackLayer3SummaryDurationParamsDateRange7d AttackLayer3SummaryDurationParamsDateRange = "7d" + AttackLayer3SummaryDurationParamsDateRange14d AttackLayer3SummaryDurationParamsDateRange = "14d" + AttackLayer3SummaryDurationParamsDateRange28d AttackLayer3SummaryDurationParamsDateRange = "28d" + AttackLayer3SummaryDurationParamsDateRange12w AttackLayer3SummaryDurationParamsDateRange = "12w" + AttackLayer3SummaryDurationParamsDateRange24w AttackLayer3SummaryDurationParamsDateRange = "24w" + AttackLayer3SummaryDurationParamsDateRange52w AttackLayer3SummaryDurationParamsDateRange = "52w" + AttackLayer3SummaryDurationParamsDateRange1dControl AttackLayer3SummaryDurationParamsDateRange = "1dControl" + AttackLayer3SummaryDurationParamsDateRange2dControl AttackLayer3SummaryDurationParamsDateRange = "2dControl" + AttackLayer3SummaryDurationParamsDateRange7dControl AttackLayer3SummaryDurationParamsDateRange = "7dControl" + AttackLayer3SummaryDurationParamsDateRange14dControl AttackLayer3SummaryDurationParamsDateRange = "14dControl" + AttackLayer3SummaryDurationParamsDateRange28dControl AttackLayer3SummaryDurationParamsDateRange = "28dControl" + AttackLayer3SummaryDurationParamsDateRange12wControl AttackLayer3SummaryDurationParamsDateRange = "12wControl" + AttackLayer3SummaryDurationParamsDateRange24wControl AttackLayer3SummaryDurationParamsDateRange = "24wControl" +) + +// Together with the `location` parameter, will apply the filter to origin or +// target location. +type AttackLayer3SummaryDurationParamsDirection string + +const ( + AttackLayer3SummaryDurationParamsDirectionOrigin AttackLayer3SummaryDurationParamsDirection = "ORIGIN" + AttackLayer3SummaryDurationParamsDirectionTarget AttackLayer3SummaryDurationParamsDirection = "TARGET" +) + +// Format results are returned in. +type AttackLayer3SummaryDurationParamsFormat string + +const ( + AttackLayer3SummaryDurationParamsFormatJson AttackLayer3SummaryDurationParamsFormat = "JSON" + AttackLayer3SummaryDurationParamsFormatCsv AttackLayer3SummaryDurationParamsFormat = "CSV" +) + +type AttackLayer3SummaryDurationParamsIPVersion string + +const ( + AttackLayer3SummaryDurationParamsIPVersionIPv4 AttackLayer3SummaryDurationParamsIPVersion = "IPv4" + AttackLayer3SummaryDurationParamsIPVersionIPv6 AttackLayer3SummaryDurationParamsIPVersion = "IPv6" +) + +type AttackLayer3SummaryDurationParamsProtocol string + +const ( + AttackLayer3SummaryDurationParamsProtocolUdp AttackLayer3SummaryDurationParamsProtocol = "UDP" + AttackLayer3SummaryDurationParamsProtocolTcp AttackLayer3SummaryDurationParamsProtocol = "TCP" + AttackLayer3SummaryDurationParamsProtocolIcmp AttackLayer3SummaryDurationParamsProtocol = "ICMP" + AttackLayer3SummaryDurationParamsProtocolGRE AttackLayer3SummaryDurationParamsProtocol = "GRE" +) + +type AttackLayer3SummaryDurationResponseEnvelope struct { + Result AttackLayer3SummaryDurationResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3SummaryDurationResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3SummaryDurationResponseEnvelopeJSON contains the JSON metadata for +// the struct [AttackLayer3SummaryDurationResponseEnvelope] +type attackLayer3SummaryDurationResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryDurationResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryDurationResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3SummaryGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer3SummaryGetParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AttackLayer3SummaryGetParams]'s query parameters as +// `url.Values`. +func (r AttackLayer3SummaryGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer3SummaryGetParamsDateRange string + +const ( + AttackLayer3SummaryGetParamsDateRange1d AttackLayer3SummaryGetParamsDateRange = "1d" + AttackLayer3SummaryGetParamsDateRange2d AttackLayer3SummaryGetParamsDateRange = "2d" + AttackLayer3SummaryGetParamsDateRange7d AttackLayer3SummaryGetParamsDateRange = "7d" + AttackLayer3SummaryGetParamsDateRange14d AttackLayer3SummaryGetParamsDateRange = "14d" + AttackLayer3SummaryGetParamsDateRange28d AttackLayer3SummaryGetParamsDateRange = "28d" + AttackLayer3SummaryGetParamsDateRange12w AttackLayer3SummaryGetParamsDateRange = "12w" + AttackLayer3SummaryGetParamsDateRange24w AttackLayer3SummaryGetParamsDateRange = "24w" + AttackLayer3SummaryGetParamsDateRange52w AttackLayer3SummaryGetParamsDateRange = "52w" + AttackLayer3SummaryGetParamsDateRange1dControl AttackLayer3SummaryGetParamsDateRange = "1dControl" + AttackLayer3SummaryGetParamsDateRange2dControl AttackLayer3SummaryGetParamsDateRange = "2dControl" + AttackLayer3SummaryGetParamsDateRange7dControl AttackLayer3SummaryGetParamsDateRange = "7dControl" + AttackLayer3SummaryGetParamsDateRange14dControl AttackLayer3SummaryGetParamsDateRange = "14dControl" + AttackLayer3SummaryGetParamsDateRange28dControl AttackLayer3SummaryGetParamsDateRange = "28dControl" + AttackLayer3SummaryGetParamsDateRange12wControl AttackLayer3SummaryGetParamsDateRange = "12wControl" + AttackLayer3SummaryGetParamsDateRange24wControl AttackLayer3SummaryGetParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer3SummaryGetParamsFormat string + +const ( + AttackLayer3SummaryGetParamsFormatJson AttackLayer3SummaryGetParamsFormat = "JSON" + AttackLayer3SummaryGetParamsFormatCsv AttackLayer3SummaryGetParamsFormat = "CSV" +) + +type AttackLayer3SummaryGetResponseEnvelope struct { + Result AttackLayer3SummaryGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3SummaryGetResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3SummaryGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [AttackLayer3SummaryGetResponseEnvelope] +type attackLayer3SummaryGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryIPVersionParams struct { + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3SummaryIPVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Together with the `location` parameter, will apply the filter to origin or + // target location. + Direction param.Field[AttackLayer3SummaryIPVersionParamsDirection] `query:"direction"` + // Format results are returned in. + Format param.Field[AttackLayer3SummaryIPVersionParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Array of L3/4 attack types. + Protocol param.Field[[]AttackLayer3SummaryIPVersionParamsProtocol] `query:"protocol"` +} + +// URLQuery serializes [AttackLayer3SummaryIPVersionParams]'s query parameters as +// `url.Values`. +func (r AttackLayer3SummaryIPVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer3SummaryIPVersionParamsDateRange string + +const ( + AttackLayer3SummaryIPVersionParamsDateRange1d AttackLayer3SummaryIPVersionParamsDateRange = "1d" + AttackLayer3SummaryIPVersionParamsDateRange2d AttackLayer3SummaryIPVersionParamsDateRange = "2d" + AttackLayer3SummaryIPVersionParamsDateRange7d AttackLayer3SummaryIPVersionParamsDateRange = "7d" + AttackLayer3SummaryIPVersionParamsDateRange14d AttackLayer3SummaryIPVersionParamsDateRange = "14d" + AttackLayer3SummaryIPVersionParamsDateRange28d AttackLayer3SummaryIPVersionParamsDateRange = "28d" + AttackLayer3SummaryIPVersionParamsDateRange12w AttackLayer3SummaryIPVersionParamsDateRange = "12w" + AttackLayer3SummaryIPVersionParamsDateRange24w AttackLayer3SummaryIPVersionParamsDateRange = "24w" + AttackLayer3SummaryIPVersionParamsDateRange52w AttackLayer3SummaryIPVersionParamsDateRange = "52w" + AttackLayer3SummaryIPVersionParamsDateRange1dControl AttackLayer3SummaryIPVersionParamsDateRange = "1dControl" + AttackLayer3SummaryIPVersionParamsDateRange2dControl AttackLayer3SummaryIPVersionParamsDateRange = "2dControl" + AttackLayer3SummaryIPVersionParamsDateRange7dControl AttackLayer3SummaryIPVersionParamsDateRange = "7dControl" + AttackLayer3SummaryIPVersionParamsDateRange14dControl AttackLayer3SummaryIPVersionParamsDateRange = "14dControl" + AttackLayer3SummaryIPVersionParamsDateRange28dControl AttackLayer3SummaryIPVersionParamsDateRange = "28dControl" + AttackLayer3SummaryIPVersionParamsDateRange12wControl AttackLayer3SummaryIPVersionParamsDateRange = "12wControl" + AttackLayer3SummaryIPVersionParamsDateRange24wControl AttackLayer3SummaryIPVersionParamsDateRange = "24wControl" +) + +// Together with the `location` parameter, will apply the filter to origin or +// target location. +type AttackLayer3SummaryIPVersionParamsDirection string + +const ( + AttackLayer3SummaryIPVersionParamsDirectionOrigin AttackLayer3SummaryIPVersionParamsDirection = "ORIGIN" + AttackLayer3SummaryIPVersionParamsDirectionTarget AttackLayer3SummaryIPVersionParamsDirection = "TARGET" +) + +// Format results are returned in. +type AttackLayer3SummaryIPVersionParamsFormat string + +const ( + AttackLayer3SummaryIPVersionParamsFormatJson AttackLayer3SummaryIPVersionParamsFormat = "JSON" + AttackLayer3SummaryIPVersionParamsFormatCsv AttackLayer3SummaryIPVersionParamsFormat = "CSV" +) + +type AttackLayer3SummaryIPVersionParamsProtocol string + +const ( + AttackLayer3SummaryIPVersionParamsProtocolUdp AttackLayer3SummaryIPVersionParamsProtocol = "UDP" + AttackLayer3SummaryIPVersionParamsProtocolTcp AttackLayer3SummaryIPVersionParamsProtocol = "TCP" + AttackLayer3SummaryIPVersionParamsProtocolIcmp AttackLayer3SummaryIPVersionParamsProtocol = "ICMP" + AttackLayer3SummaryIPVersionParamsProtocolGRE AttackLayer3SummaryIPVersionParamsProtocol = "GRE" +) + +type AttackLayer3SummaryIPVersionResponseEnvelope struct { + Result AttackLayer3SummaryIPVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3SummaryIPVersionResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3SummaryIPVersionResponseEnvelopeJSON contains the JSON metadata for +// the struct [AttackLayer3SummaryIPVersionResponseEnvelope] +type attackLayer3SummaryIPVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryIPVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryProtocolParams struct { + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3SummaryProtocolParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Together with the `location` parameter, will apply the filter to origin or + // target location. + Direction param.Field[AttackLayer3SummaryProtocolParamsDirection] `query:"direction"` + // Format results are returned in. + Format param.Field[AttackLayer3SummaryProtocolParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer3SummaryProtocolParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AttackLayer3SummaryProtocolParams]'s query parameters as +// `url.Values`. +func (r AttackLayer3SummaryProtocolParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer3SummaryProtocolParamsDateRange string + +const ( + AttackLayer3SummaryProtocolParamsDateRange1d AttackLayer3SummaryProtocolParamsDateRange = "1d" + AttackLayer3SummaryProtocolParamsDateRange2d AttackLayer3SummaryProtocolParamsDateRange = "2d" + AttackLayer3SummaryProtocolParamsDateRange7d AttackLayer3SummaryProtocolParamsDateRange = "7d" + AttackLayer3SummaryProtocolParamsDateRange14d AttackLayer3SummaryProtocolParamsDateRange = "14d" + AttackLayer3SummaryProtocolParamsDateRange28d AttackLayer3SummaryProtocolParamsDateRange = "28d" + AttackLayer3SummaryProtocolParamsDateRange12w AttackLayer3SummaryProtocolParamsDateRange = "12w" + AttackLayer3SummaryProtocolParamsDateRange24w AttackLayer3SummaryProtocolParamsDateRange = "24w" + AttackLayer3SummaryProtocolParamsDateRange52w AttackLayer3SummaryProtocolParamsDateRange = "52w" + AttackLayer3SummaryProtocolParamsDateRange1dControl AttackLayer3SummaryProtocolParamsDateRange = "1dControl" + AttackLayer3SummaryProtocolParamsDateRange2dControl AttackLayer3SummaryProtocolParamsDateRange = "2dControl" + AttackLayer3SummaryProtocolParamsDateRange7dControl AttackLayer3SummaryProtocolParamsDateRange = "7dControl" + AttackLayer3SummaryProtocolParamsDateRange14dControl AttackLayer3SummaryProtocolParamsDateRange = "14dControl" + AttackLayer3SummaryProtocolParamsDateRange28dControl AttackLayer3SummaryProtocolParamsDateRange = "28dControl" + AttackLayer3SummaryProtocolParamsDateRange12wControl AttackLayer3SummaryProtocolParamsDateRange = "12wControl" + AttackLayer3SummaryProtocolParamsDateRange24wControl AttackLayer3SummaryProtocolParamsDateRange = "24wControl" +) + +// Together with the `location` parameter, will apply the filter to origin or +// target location. +type AttackLayer3SummaryProtocolParamsDirection string + +const ( + AttackLayer3SummaryProtocolParamsDirectionOrigin AttackLayer3SummaryProtocolParamsDirection = "ORIGIN" + AttackLayer3SummaryProtocolParamsDirectionTarget AttackLayer3SummaryProtocolParamsDirection = "TARGET" +) + +// Format results are returned in. +type AttackLayer3SummaryProtocolParamsFormat string + +const ( + AttackLayer3SummaryProtocolParamsFormatJson AttackLayer3SummaryProtocolParamsFormat = "JSON" + AttackLayer3SummaryProtocolParamsFormatCsv AttackLayer3SummaryProtocolParamsFormat = "CSV" +) + +type AttackLayer3SummaryProtocolParamsIPVersion string + +const ( + AttackLayer3SummaryProtocolParamsIPVersionIPv4 AttackLayer3SummaryProtocolParamsIPVersion = "IPv4" + AttackLayer3SummaryProtocolParamsIPVersionIPv6 AttackLayer3SummaryProtocolParamsIPVersion = "IPv6" +) + +type AttackLayer3SummaryProtocolResponseEnvelope struct { + Result AttackLayer3SummaryProtocolResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3SummaryProtocolResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3SummaryProtocolResponseEnvelopeJSON contains the JSON metadata for +// the struct [AttackLayer3SummaryProtocolResponseEnvelope] +type attackLayer3SummaryProtocolResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryProtocolResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryProtocolResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3SummaryVectorParams struct { + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3SummaryVectorParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Together with the `location` parameter, will apply the filter to origin or + // target location. + Direction param.Field[AttackLayer3SummaryVectorParamsDirection] `query:"direction"` + // Format results are returned in. + Format param.Field[AttackLayer3SummaryVectorParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer3SummaryVectorParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Array of L3/4 attack types. + Protocol param.Field[[]AttackLayer3SummaryVectorParamsProtocol] `query:"protocol"` +} + +// URLQuery serializes [AttackLayer3SummaryVectorParams]'s query parameters as +// `url.Values`. +func (r AttackLayer3SummaryVectorParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer3SummaryVectorParamsDateRange string + +const ( + AttackLayer3SummaryVectorParamsDateRange1d AttackLayer3SummaryVectorParamsDateRange = "1d" + AttackLayer3SummaryVectorParamsDateRange2d AttackLayer3SummaryVectorParamsDateRange = "2d" + AttackLayer3SummaryVectorParamsDateRange7d AttackLayer3SummaryVectorParamsDateRange = "7d" + AttackLayer3SummaryVectorParamsDateRange14d AttackLayer3SummaryVectorParamsDateRange = "14d" + AttackLayer3SummaryVectorParamsDateRange28d AttackLayer3SummaryVectorParamsDateRange = "28d" + AttackLayer3SummaryVectorParamsDateRange12w AttackLayer3SummaryVectorParamsDateRange = "12w" + AttackLayer3SummaryVectorParamsDateRange24w AttackLayer3SummaryVectorParamsDateRange = "24w" + AttackLayer3SummaryVectorParamsDateRange52w AttackLayer3SummaryVectorParamsDateRange = "52w" + AttackLayer3SummaryVectorParamsDateRange1dControl AttackLayer3SummaryVectorParamsDateRange = "1dControl" + AttackLayer3SummaryVectorParamsDateRange2dControl AttackLayer3SummaryVectorParamsDateRange = "2dControl" + AttackLayer3SummaryVectorParamsDateRange7dControl AttackLayer3SummaryVectorParamsDateRange = "7dControl" + AttackLayer3SummaryVectorParamsDateRange14dControl AttackLayer3SummaryVectorParamsDateRange = "14dControl" + AttackLayer3SummaryVectorParamsDateRange28dControl AttackLayer3SummaryVectorParamsDateRange = "28dControl" + AttackLayer3SummaryVectorParamsDateRange12wControl AttackLayer3SummaryVectorParamsDateRange = "12wControl" + AttackLayer3SummaryVectorParamsDateRange24wControl AttackLayer3SummaryVectorParamsDateRange = "24wControl" +) + +// Together with the `location` parameter, will apply the filter to origin or +// target location. +type AttackLayer3SummaryVectorParamsDirection string + +const ( + AttackLayer3SummaryVectorParamsDirectionOrigin AttackLayer3SummaryVectorParamsDirection = "ORIGIN" + AttackLayer3SummaryVectorParamsDirectionTarget AttackLayer3SummaryVectorParamsDirection = "TARGET" +) + +// Format results are returned in. +type AttackLayer3SummaryVectorParamsFormat string + +const ( + AttackLayer3SummaryVectorParamsFormatJson AttackLayer3SummaryVectorParamsFormat = "JSON" + AttackLayer3SummaryVectorParamsFormatCsv AttackLayer3SummaryVectorParamsFormat = "CSV" +) + +type AttackLayer3SummaryVectorParamsIPVersion string + +const ( + AttackLayer3SummaryVectorParamsIPVersionIPv4 AttackLayer3SummaryVectorParamsIPVersion = "IPv4" + AttackLayer3SummaryVectorParamsIPVersionIPv6 AttackLayer3SummaryVectorParamsIPVersion = "IPv6" +) + +type AttackLayer3SummaryVectorParamsProtocol string + +const ( + AttackLayer3SummaryVectorParamsProtocolUdp AttackLayer3SummaryVectorParamsProtocol = "UDP" + AttackLayer3SummaryVectorParamsProtocolTcp AttackLayer3SummaryVectorParamsProtocol = "TCP" + AttackLayer3SummaryVectorParamsProtocolIcmp AttackLayer3SummaryVectorParamsProtocol = "ICMP" + AttackLayer3SummaryVectorParamsProtocolGRE AttackLayer3SummaryVectorParamsProtocol = "GRE" +) + +type AttackLayer3SummaryVectorResponseEnvelope struct { + Result AttackLayer3SummaryVectorResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3SummaryVectorResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3SummaryVectorResponseEnvelopeJSON contains the JSON metadata for the +// struct [AttackLayer3SummaryVectorResponseEnvelope] +type attackLayer3SummaryVectorResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3SummaryVectorResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3SummaryVectorResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/attacklayer3summary_test.go b/radar/attacklayer3summary_test.go new file mode 100644 index 00000000000..ec150c7e951 --- /dev/null +++ b/radar/attacklayer3summary_test.go @@ -0,0 +1,222 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestAttackLayer3SummaryBitrateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.Summary.Bitrate(context.TODO(), radar.AttackLayer3SummaryBitrateParams{ + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3SummaryBitrateParamsDateRange{radar.AttackLayer3SummaryBitrateParamsDateRange1d, radar.AttackLayer3SummaryBitrateParamsDateRange2d, radar.AttackLayer3SummaryBitrateParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Direction: cloudflare.F(radar.AttackLayer3SummaryBitrateParamsDirectionOrigin), + Format: cloudflare.F(radar.AttackLayer3SummaryBitrateParamsFormatJson), + IPVersion: cloudflare.F([]radar.AttackLayer3SummaryBitrateParamsIPVersion{radar.AttackLayer3SummaryBitrateParamsIPVersionIPv4, radar.AttackLayer3SummaryBitrateParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Protocol: cloudflare.F([]radar.AttackLayer3SummaryBitrateParamsProtocol{radar.AttackLayer3SummaryBitrateParamsProtocolUdp, radar.AttackLayer3SummaryBitrateParamsProtocolTcp, radar.AttackLayer3SummaryBitrateParamsProtocolIcmp}), + }) + 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 TestAttackLayer3SummaryDurationWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.Summary.Duration(context.TODO(), radar.AttackLayer3SummaryDurationParams{ + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3SummaryDurationParamsDateRange{radar.AttackLayer3SummaryDurationParamsDateRange1d, radar.AttackLayer3SummaryDurationParamsDateRange2d, radar.AttackLayer3SummaryDurationParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Direction: cloudflare.F(radar.AttackLayer3SummaryDurationParamsDirectionOrigin), + Format: cloudflare.F(radar.AttackLayer3SummaryDurationParamsFormatJson), + IPVersion: cloudflare.F([]radar.AttackLayer3SummaryDurationParamsIPVersion{radar.AttackLayer3SummaryDurationParamsIPVersionIPv4, radar.AttackLayer3SummaryDurationParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Protocol: cloudflare.F([]radar.AttackLayer3SummaryDurationParamsProtocol{radar.AttackLayer3SummaryDurationParamsProtocolUdp, radar.AttackLayer3SummaryDurationParamsProtocolTcp, radar.AttackLayer3SummaryDurationParamsProtocolIcmp}), + }) + 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 TestAttackLayer3SummaryGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.Summary.Get(context.TODO(), radar.AttackLayer3SummaryGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3SummaryGetParamsDateRange{radar.AttackLayer3SummaryGetParamsDateRange1d, radar.AttackLayer3SummaryGetParamsDateRange2d, radar.AttackLayer3SummaryGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer3SummaryGetParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAttackLayer3SummaryIPVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.Summary.IPVersion(context.TODO(), radar.AttackLayer3SummaryIPVersionParams{ + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3SummaryIPVersionParamsDateRange{radar.AttackLayer3SummaryIPVersionParamsDateRange1d, radar.AttackLayer3SummaryIPVersionParamsDateRange2d, radar.AttackLayer3SummaryIPVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Direction: cloudflare.F(radar.AttackLayer3SummaryIPVersionParamsDirectionOrigin), + Format: cloudflare.F(radar.AttackLayer3SummaryIPVersionParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Protocol: cloudflare.F([]radar.AttackLayer3SummaryIPVersionParamsProtocol{radar.AttackLayer3SummaryIPVersionParamsProtocolUdp, radar.AttackLayer3SummaryIPVersionParamsProtocolTcp, radar.AttackLayer3SummaryIPVersionParamsProtocolIcmp}), + }) + 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 TestAttackLayer3SummaryProtocolWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.Summary.Protocol(context.TODO(), radar.AttackLayer3SummaryProtocolParams{ + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3SummaryProtocolParamsDateRange{radar.AttackLayer3SummaryProtocolParamsDateRange1d, radar.AttackLayer3SummaryProtocolParamsDateRange2d, radar.AttackLayer3SummaryProtocolParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Direction: cloudflare.F(radar.AttackLayer3SummaryProtocolParamsDirectionOrigin), + Format: cloudflare.F(radar.AttackLayer3SummaryProtocolParamsFormatJson), + IPVersion: cloudflare.F([]radar.AttackLayer3SummaryProtocolParamsIPVersion{radar.AttackLayer3SummaryProtocolParamsIPVersionIPv4, radar.AttackLayer3SummaryProtocolParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAttackLayer3SummaryVectorWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.Summary.Vector(context.TODO(), radar.AttackLayer3SummaryVectorParams{ + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3SummaryVectorParamsDateRange{radar.AttackLayer3SummaryVectorParamsDateRange1d, radar.AttackLayer3SummaryVectorParamsDateRange2d, radar.AttackLayer3SummaryVectorParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Direction: cloudflare.F(radar.AttackLayer3SummaryVectorParamsDirectionOrigin), + Format: cloudflare.F(radar.AttackLayer3SummaryVectorParamsFormatJson), + IPVersion: cloudflare.F([]radar.AttackLayer3SummaryVectorParamsIPVersion{radar.AttackLayer3SummaryVectorParamsIPVersionIPv4, radar.AttackLayer3SummaryVectorParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Protocol: cloudflare.F([]radar.AttackLayer3SummaryVectorParamsProtocol{radar.AttackLayer3SummaryVectorParamsProtocolUdp, radar.AttackLayer3SummaryVectorParamsProtocolTcp, radar.AttackLayer3SummaryVectorParamsProtocolIcmp}), + }) + 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/radar/attacklayer3timeseriesgroup.go b/radar/attacklayer3timeseriesgroup.go new file mode 100644 index 00000000000..bb1a2fe330f --- /dev/null +++ b/radar/attacklayer3timeseriesgroup.go @@ -0,0 +1,1717 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AttackLayer3TimeseriesGroupService 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 +// [NewAttackLayer3TimeseriesGroupService] method instead. +type AttackLayer3TimeseriesGroupService struct { + Options []option.RequestOption +} + +// NewAttackLayer3TimeseriesGroupService 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 NewAttackLayer3TimeseriesGroupService(opts ...option.RequestOption) (r *AttackLayer3TimeseriesGroupService) { + r = &AttackLayer3TimeseriesGroupService{} + r.Options = opts + return +} + +// Percentage distribution of attacks by bitrate over time. +func (r *AttackLayer3TimeseriesGroupService) Bitrate(ctx context.Context, query AttackLayer3TimeseriesGroupBitrateParams, opts ...option.RequestOption) (res *AttackLayer3TimeseriesGroupBitrateResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3TimeseriesGroupBitrateResponseEnvelope + path := "radar/attacks/layer3/timeseries_groups/bitrate" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by duration over time. +func (r *AttackLayer3TimeseriesGroupService) Duration(ctx context.Context, query AttackLayer3TimeseriesGroupDurationParams, opts ...option.RequestOption) (res *AttackLayer3TimeseriesGroupDurationResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3TimeseriesGroupDurationResponseEnvelope + path := "radar/attacks/layer3/timeseries_groups/duration" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a timeseries of the percentage distribution of network protocols in Layer +// 3/4 attacks. +func (r *AttackLayer3TimeseriesGroupService) Get(ctx context.Context, query AttackLayer3TimeseriesGroupGetParams, opts ...option.RequestOption) (res *AttackLayer3TimeseriesGroupGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3TimeseriesGroupGetResponseEnvelope + path := "radar/attacks/layer3/timeseries_groups" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by industry used over time. +func (r *AttackLayer3TimeseriesGroupService) Industry(ctx context.Context, query AttackLayer3TimeseriesGroupIndustryParams, opts ...option.RequestOption) (res *AttackLayer3TimeseriesGroupIndustryResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3TimeseriesGroupIndustryResponseEnvelope + path := "radar/attacks/layer3/timeseries_groups/industry" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by ip version used over time. +func (r *AttackLayer3TimeseriesGroupService) IPVersion(ctx context.Context, query AttackLayer3TimeseriesGroupIPVersionParams, opts ...option.RequestOption) (res *AttackLayer3TimeseriesGroupIPVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3TimeseriesGroupIPVersionResponseEnvelope + path := "radar/attacks/layer3/timeseries_groups/ip_version" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by protocol used over time. +func (r *AttackLayer3TimeseriesGroupService) Protocol(ctx context.Context, query AttackLayer3TimeseriesGroupProtocolParams, opts ...option.RequestOption) (res *AttackLayer3TimeseriesGroupProtocolResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3TimeseriesGroupProtocolResponseEnvelope + path := "radar/attacks/layer3/timeseries_groups/protocol" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by vector used over time. +func (r *AttackLayer3TimeseriesGroupService) Vector(ctx context.Context, query AttackLayer3TimeseriesGroupVectorParams, opts ...option.RequestOption) (res *AttackLayer3TimeseriesGroupVectorResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3TimeseriesGroupVectorResponseEnvelope + path := "radar/attacks/layer3/timeseries_groups/vector" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by vertical used over time. +func (r *AttackLayer3TimeseriesGroupService) Vertical(ctx context.Context, query AttackLayer3TimeseriesGroupVerticalParams, opts ...option.RequestOption) (res *AttackLayer3TimeseriesGroupVerticalResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3TimeseriesGroupVerticalResponseEnvelope + path := "radar/attacks/layer3/timeseries_groups/vertical" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AttackLayer3TimeseriesGroupBitrateResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AttackLayer3TimeseriesGroupBitrateResponseSerie0 `json:"serie_0,required"` + JSON attackLayer3TimeseriesGroupBitrateResponseJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupBitrateResponseJSON contains the JSON metadata for +// the struct [AttackLayer3TimeseriesGroupBitrateResponse] +type attackLayer3TimeseriesGroupBitrateResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupBitrateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupBitrateResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupBitrateResponseSerie0 struct { + Number1GbpsTo10Gbps []string `json:"_1_GBPS_TO_10_GBPS,required"` + Number10GbpsTo100Gbps []string `json:"_10_GBPS_TO_100_GBPS,required"` + Number500MbpsTo1Gbps []string `json:"_500_MBPS_TO_1_GBPS,required"` + Over100Gbps []string `json:"OVER_100_GBPS,required"` + Timestamps []string `json:"timestamps,required"` + Under500Mbps []string `json:"UNDER_500_MBPS,required"` + JSON attackLayer3TimeseriesGroupBitrateResponseSerie0JSON `json:"-"` +} + +// attackLayer3TimeseriesGroupBitrateResponseSerie0JSON contains the JSON metadata +// for the struct [AttackLayer3TimeseriesGroupBitrateResponseSerie0] +type attackLayer3TimeseriesGroupBitrateResponseSerie0JSON struct { + Number1GbpsTo10Gbps apijson.Field + Number10GbpsTo100Gbps apijson.Field + Number500MbpsTo1Gbps apijson.Field + Over100Gbps apijson.Field + Timestamps apijson.Field + Under500Mbps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupBitrateResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupBitrateResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupDurationResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AttackLayer3TimeseriesGroupDurationResponseSerie0 `json:"serie_0,required"` + JSON attackLayer3TimeseriesGroupDurationResponseJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupDurationResponseJSON contains the JSON metadata for +// the struct [AttackLayer3TimeseriesGroupDurationResponse] +type attackLayer3TimeseriesGroupDurationResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupDurationResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupDurationResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupDurationResponseSerie0 struct { + Number1HourTo3Hours []string `json:"_1_HOUR_TO_3_HOURS,required"` + Number10MinsTo20Mins []string `json:"_10_MINS_TO_20_MINS,required"` + Number20MinsTo40Mins []string `json:"_20_MINS_TO_40_MINS,required"` + Number40MinsTo1Hour []string `json:"_40_MINS_TO_1_HOUR,required"` + Over3Hours []string `json:"OVER_3_HOURS,required"` + Timestamps []string `json:"timestamps,required"` + Under10Mins []string `json:"UNDER_10_MINS,required"` + JSON attackLayer3TimeseriesGroupDurationResponseSerie0JSON `json:"-"` +} + +// attackLayer3TimeseriesGroupDurationResponseSerie0JSON contains the JSON metadata +// for the struct [AttackLayer3TimeseriesGroupDurationResponseSerie0] +type attackLayer3TimeseriesGroupDurationResponseSerie0JSON struct { + Number1HourTo3Hours apijson.Field + Number10MinsTo20Mins apijson.Field + Number20MinsTo40Mins apijson.Field + Number40MinsTo1Hour apijson.Field + Over3Hours apijson.Field + Timestamps apijson.Field + Under10Mins apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupDurationResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupDurationResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupGetResponse struct { + Meta AttackLayer3TimeseriesGroupGetResponseMeta `json:"meta,required"` + Serie0 AttackLayer3TimeseriesGroupGetResponseSerie0 `json:"serie_0,required"` + JSON attackLayer3TimeseriesGroupGetResponseJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupGetResponseJSON contains the JSON metadata for the +// struct [AttackLayer3TimeseriesGroupGetResponse] +type attackLayer3TimeseriesGroupGetResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupGetResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupGetResponseMeta struct { + AggInterval string `json:"aggInterval,required"` + DateRange []AttackLayer3TimeseriesGroupGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated time.Time `json:"lastUpdated,required" format:"date-time"` + ConfidenceInfo AttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer3TimeseriesGroupGetResponseMetaJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupGetResponseMetaJSON contains the JSON metadata for +// the struct [AttackLayer3TimeseriesGroupGetResponseMeta] +type attackLayer3TimeseriesGroupGetResponseMetaJSON struct { + AggInterval apijson.Field + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer3TimeseriesGroupGetResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupGetResponseMetaDateRangeJSON contains the JSON +// metadata for the struct [AttackLayer3TimeseriesGroupGetResponseMetaDateRange] +type attackLayer3TimeseriesGroupGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfo struct { + Annotations []AttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct +// [AttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfo] +type attackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoAnnotationJSON contains +// the JSON metadata for the struct +// [AttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoAnnotation] +type attackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupGetResponseSerie0 struct { + GRE []string `json:"gre,required"` + Icmp []string `json:"icmp,required"` + Tcp []string `json:"tcp,required"` + Timestamps []string `json:"timestamps,required"` + Udp []string `json:"udp,required"` + JSON attackLayer3TimeseriesGroupGetResponseSerie0JSON `json:"-"` +} + +// attackLayer3TimeseriesGroupGetResponseSerie0JSON contains the JSON metadata for +// the struct [AttackLayer3TimeseriesGroupGetResponseSerie0] +type attackLayer3TimeseriesGroupGetResponseSerie0JSON struct { + GRE apijson.Field + Icmp apijson.Field + Tcp apijson.Field + Timestamps apijson.Field + Udp apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupGetResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupGetResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupIndustryResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AttackLayer3TimeseriesGroupIndustryResponseSerie0 `json:"serie_0,required"` + JSON attackLayer3TimeseriesGroupIndustryResponseJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupIndustryResponseJSON contains the JSON metadata for +// the struct [AttackLayer3TimeseriesGroupIndustryResponse] +type attackLayer3TimeseriesGroupIndustryResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupIndustryResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupIndustryResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupIndustryResponseSerie0 struct { + Timestamps []string `json:"timestamps,required"` + ExtraFields map[string][]string `json:"-,extras"` + JSON attackLayer3TimeseriesGroupIndustryResponseSerie0JSON `json:"-"` +} + +// attackLayer3TimeseriesGroupIndustryResponseSerie0JSON contains the JSON metadata +// for the struct [AttackLayer3TimeseriesGroupIndustryResponseSerie0] +type attackLayer3TimeseriesGroupIndustryResponseSerie0JSON struct { + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupIndustryResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupIndustryResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupIPVersionResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AttackLayer3TimeseriesGroupIPVersionResponseSerie0 `json:"serie_0,required"` + JSON attackLayer3TimeseriesGroupIPVersionResponseJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupIPVersionResponseJSON contains the JSON metadata for +// the struct [AttackLayer3TimeseriesGroupIPVersionResponse] +type attackLayer3TimeseriesGroupIPVersionResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupIPVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupIPVersionResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupIPVersionResponseSerie0 struct { + IPv4 []string `json:"IPv4,required"` + IPv6 []string `json:"IPv6,required"` + Timestamps []string `json:"timestamps,required"` + JSON attackLayer3TimeseriesGroupIPVersionResponseSerie0JSON `json:"-"` +} + +// attackLayer3TimeseriesGroupIPVersionResponseSerie0JSON contains the JSON +// metadata for the struct [AttackLayer3TimeseriesGroupIPVersionResponseSerie0] +type attackLayer3TimeseriesGroupIPVersionResponseSerie0JSON struct { + IPv4 apijson.Field + IPv6 apijson.Field + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupIPVersionResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupIPVersionResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupProtocolResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AttackLayer3TimeseriesGroupProtocolResponseSerie0 `json:"serie_0,required"` + JSON attackLayer3TimeseriesGroupProtocolResponseJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupProtocolResponseJSON contains the JSON metadata for +// the struct [AttackLayer3TimeseriesGroupProtocolResponse] +type attackLayer3TimeseriesGroupProtocolResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupProtocolResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupProtocolResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupProtocolResponseSerie0 struct { + GRE []string `json:"GRE,required"` + Icmp []string `json:"ICMP,required"` + Tcp []string `json:"TCP,required"` + Timestamps []string `json:"timestamps,required"` + Udp []string `json:"UDP,required"` + JSON attackLayer3TimeseriesGroupProtocolResponseSerie0JSON `json:"-"` +} + +// attackLayer3TimeseriesGroupProtocolResponseSerie0JSON contains the JSON metadata +// for the struct [AttackLayer3TimeseriesGroupProtocolResponseSerie0] +type attackLayer3TimeseriesGroupProtocolResponseSerie0JSON struct { + GRE apijson.Field + Icmp apijson.Field + Tcp apijson.Field + Timestamps apijson.Field + Udp apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupProtocolResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupProtocolResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupVectorResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AttackLayer3TimeseriesGroupVectorResponseSerie0 `json:"serie_0,required"` + JSON attackLayer3TimeseriesGroupVectorResponseJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupVectorResponseJSON contains the JSON metadata for the +// struct [AttackLayer3TimeseriesGroupVectorResponse] +type attackLayer3TimeseriesGroupVectorResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupVectorResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupVectorResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupVectorResponseSerie0 struct { + Timestamps []string `json:"timestamps,required"` + ExtraFields map[string][]string `json:"-,extras"` + JSON attackLayer3TimeseriesGroupVectorResponseSerie0JSON `json:"-"` +} + +// attackLayer3TimeseriesGroupVectorResponseSerie0JSON contains the JSON metadata +// for the struct [AttackLayer3TimeseriesGroupVectorResponseSerie0] +type attackLayer3TimeseriesGroupVectorResponseSerie0JSON struct { + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupVectorResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupVectorResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupVerticalResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AttackLayer3TimeseriesGroupVerticalResponseSerie0 `json:"serie_0,required"` + JSON attackLayer3TimeseriesGroupVerticalResponseJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupVerticalResponseJSON contains the JSON metadata for +// the struct [AttackLayer3TimeseriesGroupVerticalResponse] +type attackLayer3TimeseriesGroupVerticalResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupVerticalResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupVerticalResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupVerticalResponseSerie0 struct { + Timestamps []string `json:"timestamps,required"` + ExtraFields map[string][]string `json:"-,extras"` + JSON attackLayer3TimeseriesGroupVerticalResponseSerie0JSON `json:"-"` +} + +// attackLayer3TimeseriesGroupVerticalResponseSerie0JSON contains the JSON metadata +// for the struct [AttackLayer3TimeseriesGroupVerticalResponseSerie0] +type attackLayer3TimeseriesGroupVerticalResponseSerie0JSON struct { + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupVerticalResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupVerticalResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupBitrateParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AttackLayer3TimeseriesGroupBitrateParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3TimeseriesGroupBitrateParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Together with the `location` parameter, will apply the filter to origin or + // target location. + Direction param.Field[AttackLayer3TimeseriesGroupBitrateParamsDirection] `query:"direction"` + // Format results are returned in. + Format param.Field[AttackLayer3TimeseriesGroupBitrateParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer3TimeseriesGroupBitrateParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Normalization method applied. Refer to + // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + Normalization param.Field[AttackLayer3TimeseriesGroupBitrateParamsNormalization] `query:"normalization"` + // Array of L3/4 attack types. + Protocol param.Field[[]AttackLayer3TimeseriesGroupBitrateParamsProtocol] `query:"protocol"` +} + +// URLQuery serializes [AttackLayer3TimeseriesGroupBitrateParams]'s query +// parameters as `url.Values`. +func (r AttackLayer3TimeseriesGroupBitrateParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AttackLayer3TimeseriesGroupBitrateParamsAggInterval string + +const ( + AttackLayer3TimeseriesGroupBitrateParamsAggInterval15m AttackLayer3TimeseriesGroupBitrateParamsAggInterval = "15m" + AttackLayer3TimeseriesGroupBitrateParamsAggInterval1h AttackLayer3TimeseriesGroupBitrateParamsAggInterval = "1h" + AttackLayer3TimeseriesGroupBitrateParamsAggInterval1d AttackLayer3TimeseriesGroupBitrateParamsAggInterval = "1d" + AttackLayer3TimeseriesGroupBitrateParamsAggInterval1w AttackLayer3TimeseriesGroupBitrateParamsAggInterval = "1w" +) + +type AttackLayer3TimeseriesGroupBitrateParamsDateRange string + +const ( + AttackLayer3TimeseriesGroupBitrateParamsDateRange1d AttackLayer3TimeseriesGroupBitrateParamsDateRange = "1d" + AttackLayer3TimeseriesGroupBitrateParamsDateRange2d AttackLayer3TimeseriesGroupBitrateParamsDateRange = "2d" + AttackLayer3TimeseriesGroupBitrateParamsDateRange7d AttackLayer3TimeseriesGroupBitrateParamsDateRange = "7d" + AttackLayer3TimeseriesGroupBitrateParamsDateRange14d AttackLayer3TimeseriesGroupBitrateParamsDateRange = "14d" + AttackLayer3TimeseriesGroupBitrateParamsDateRange28d AttackLayer3TimeseriesGroupBitrateParamsDateRange = "28d" + AttackLayer3TimeseriesGroupBitrateParamsDateRange12w AttackLayer3TimeseriesGroupBitrateParamsDateRange = "12w" + AttackLayer3TimeseriesGroupBitrateParamsDateRange24w AttackLayer3TimeseriesGroupBitrateParamsDateRange = "24w" + AttackLayer3TimeseriesGroupBitrateParamsDateRange52w AttackLayer3TimeseriesGroupBitrateParamsDateRange = "52w" + AttackLayer3TimeseriesGroupBitrateParamsDateRange1dControl AttackLayer3TimeseriesGroupBitrateParamsDateRange = "1dControl" + AttackLayer3TimeseriesGroupBitrateParamsDateRange2dControl AttackLayer3TimeseriesGroupBitrateParamsDateRange = "2dControl" + AttackLayer3TimeseriesGroupBitrateParamsDateRange7dControl AttackLayer3TimeseriesGroupBitrateParamsDateRange = "7dControl" + AttackLayer3TimeseriesGroupBitrateParamsDateRange14dControl AttackLayer3TimeseriesGroupBitrateParamsDateRange = "14dControl" + AttackLayer3TimeseriesGroupBitrateParamsDateRange28dControl AttackLayer3TimeseriesGroupBitrateParamsDateRange = "28dControl" + AttackLayer3TimeseriesGroupBitrateParamsDateRange12wControl AttackLayer3TimeseriesGroupBitrateParamsDateRange = "12wControl" + AttackLayer3TimeseriesGroupBitrateParamsDateRange24wControl AttackLayer3TimeseriesGroupBitrateParamsDateRange = "24wControl" +) + +// Together with the `location` parameter, will apply the filter to origin or +// target location. +type AttackLayer3TimeseriesGroupBitrateParamsDirection string + +const ( + AttackLayer3TimeseriesGroupBitrateParamsDirectionOrigin AttackLayer3TimeseriesGroupBitrateParamsDirection = "ORIGIN" + AttackLayer3TimeseriesGroupBitrateParamsDirectionTarget AttackLayer3TimeseriesGroupBitrateParamsDirection = "TARGET" +) + +// Format results are returned in. +type AttackLayer3TimeseriesGroupBitrateParamsFormat string + +const ( + AttackLayer3TimeseriesGroupBitrateParamsFormatJson AttackLayer3TimeseriesGroupBitrateParamsFormat = "JSON" + AttackLayer3TimeseriesGroupBitrateParamsFormatCsv AttackLayer3TimeseriesGroupBitrateParamsFormat = "CSV" +) + +type AttackLayer3TimeseriesGroupBitrateParamsIPVersion string + +const ( + AttackLayer3TimeseriesGroupBitrateParamsIPVersionIPv4 AttackLayer3TimeseriesGroupBitrateParamsIPVersion = "IPv4" + AttackLayer3TimeseriesGroupBitrateParamsIPVersionIPv6 AttackLayer3TimeseriesGroupBitrateParamsIPVersion = "IPv6" +) + +// Normalization method applied. Refer to +// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). +type AttackLayer3TimeseriesGroupBitrateParamsNormalization string + +const ( + AttackLayer3TimeseriesGroupBitrateParamsNormalizationPercentage AttackLayer3TimeseriesGroupBitrateParamsNormalization = "PERCENTAGE" + AttackLayer3TimeseriesGroupBitrateParamsNormalizationMin0Max AttackLayer3TimeseriesGroupBitrateParamsNormalization = "MIN0_MAX" +) + +type AttackLayer3TimeseriesGroupBitrateParamsProtocol string + +const ( + AttackLayer3TimeseriesGroupBitrateParamsProtocolUdp AttackLayer3TimeseriesGroupBitrateParamsProtocol = "UDP" + AttackLayer3TimeseriesGroupBitrateParamsProtocolTcp AttackLayer3TimeseriesGroupBitrateParamsProtocol = "TCP" + AttackLayer3TimeseriesGroupBitrateParamsProtocolIcmp AttackLayer3TimeseriesGroupBitrateParamsProtocol = "ICMP" + AttackLayer3TimeseriesGroupBitrateParamsProtocolGRE AttackLayer3TimeseriesGroupBitrateParamsProtocol = "GRE" +) + +type AttackLayer3TimeseriesGroupBitrateResponseEnvelope struct { + Result AttackLayer3TimeseriesGroupBitrateResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3TimeseriesGroupBitrateResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupBitrateResponseEnvelopeJSON contains the JSON +// metadata for the struct [AttackLayer3TimeseriesGroupBitrateResponseEnvelope] +type attackLayer3TimeseriesGroupBitrateResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupBitrateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupBitrateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupDurationParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AttackLayer3TimeseriesGroupDurationParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3TimeseriesGroupDurationParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Together with the `location` parameter, will apply the filter to origin or + // target location. + Direction param.Field[AttackLayer3TimeseriesGroupDurationParamsDirection] `query:"direction"` + // Format results are returned in. + Format param.Field[AttackLayer3TimeseriesGroupDurationParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer3TimeseriesGroupDurationParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Normalization method applied. Refer to + // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + Normalization param.Field[AttackLayer3TimeseriesGroupDurationParamsNormalization] `query:"normalization"` + // Array of L3/4 attack types. + Protocol param.Field[[]AttackLayer3TimeseriesGroupDurationParamsProtocol] `query:"protocol"` +} + +// URLQuery serializes [AttackLayer3TimeseriesGroupDurationParams]'s query +// parameters as `url.Values`. +func (r AttackLayer3TimeseriesGroupDurationParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AttackLayer3TimeseriesGroupDurationParamsAggInterval string + +const ( + AttackLayer3TimeseriesGroupDurationParamsAggInterval15m AttackLayer3TimeseriesGroupDurationParamsAggInterval = "15m" + AttackLayer3TimeseriesGroupDurationParamsAggInterval1h AttackLayer3TimeseriesGroupDurationParamsAggInterval = "1h" + AttackLayer3TimeseriesGroupDurationParamsAggInterval1d AttackLayer3TimeseriesGroupDurationParamsAggInterval = "1d" + AttackLayer3TimeseriesGroupDurationParamsAggInterval1w AttackLayer3TimeseriesGroupDurationParamsAggInterval = "1w" +) + +type AttackLayer3TimeseriesGroupDurationParamsDateRange string + +const ( + AttackLayer3TimeseriesGroupDurationParamsDateRange1d AttackLayer3TimeseriesGroupDurationParamsDateRange = "1d" + AttackLayer3TimeseriesGroupDurationParamsDateRange2d AttackLayer3TimeseriesGroupDurationParamsDateRange = "2d" + AttackLayer3TimeseriesGroupDurationParamsDateRange7d AttackLayer3TimeseriesGroupDurationParamsDateRange = "7d" + AttackLayer3TimeseriesGroupDurationParamsDateRange14d AttackLayer3TimeseriesGroupDurationParamsDateRange = "14d" + AttackLayer3TimeseriesGroupDurationParamsDateRange28d AttackLayer3TimeseriesGroupDurationParamsDateRange = "28d" + AttackLayer3TimeseriesGroupDurationParamsDateRange12w AttackLayer3TimeseriesGroupDurationParamsDateRange = "12w" + AttackLayer3TimeseriesGroupDurationParamsDateRange24w AttackLayer3TimeseriesGroupDurationParamsDateRange = "24w" + AttackLayer3TimeseriesGroupDurationParamsDateRange52w AttackLayer3TimeseriesGroupDurationParamsDateRange = "52w" + AttackLayer3TimeseriesGroupDurationParamsDateRange1dControl AttackLayer3TimeseriesGroupDurationParamsDateRange = "1dControl" + AttackLayer3TimeseriesGroupDurationParamsDateRange2dControl AttackLayer3TimeseriesGroupDurationParamsDateRange = "2dControl" + AttackLayer3TimeseriesGroupDurationParamsDateRange7dControl AttackLayer3TimeseriesGroupDurationParamsDateRange = "7dControl" + AttackLayer3TimeseriesGroupDurationParamsDateRange14dControl AttackLayer3TimeseriesGroupDurationParamsDateRange = "14dControl" + AttackLayer3TimeseriesGroupDurationParamsDateRange28dControl AttackLayer3TimeseriesGroupDurationParamsDateRange = "28dControl" + AttackLayer3TimeseriesGroupDurationParamsDateRange12wControl AttackLayer3TimeseriesGroupDurationParamsDateRange = "12wControl" + AttackLayer3TimeseriesGroupDurationParamsDateRange24wControl AttackLayer3TimeseriesGroupDurationParamsDateRange = "24wControl" +) + +// Together with the `location` parameter, will apply the filter to origin or +// target location. +type AttackLayer3TimeseriesGroupDurationParamsDirection string + +const ( + AttackLayer3TimeseriesGroupDurationParamsDirectionOrigin AttackLayer3TimeseriesGroupDurationParamsDirection = "ORIGIN" + AttackLayer3TimeseriesGroupDurationParamsDirectionTarget AttackLayer3TimeseriesGroupDurationParamsDirection = "TARGET" +) + +// Format results are returned in. +type AttackLayer3TimeseriesGroupDurationParamsFormat string + +const ( + AttackLayer3TimeseriesGroupDurationParamsFormatJson AttackLayer3TimeseriesGroupDurationParamsFormat = "JSON" + AttackLayer3TimeseriesGroupDurationParamsFormatCsv AttackLayer3TimeseriesGroupDurationParamsFormat = "CSV" +) + +type AttackLayer3TimeseriesGroupDurationParamsIPVersion string + +const ( + AttackLayer3TimeseriesGroupDurationParamsIPVersionIPv4 AttackLayer3TimeseriesGroupDurationParamsIPVersion = "IPv4" + AttackLayer3TimeseriesGroupDurationParamsIPVersionIPv6 AttackLayer3TimeseriesGroupDurationParamsIPVersion = "IPv6" +) + +// Normalization method applied. Refer to +// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). +type AttackLayer3TimeseriesGroupDurationParamsNormalization string + +const ( + AttackLayer3TimeseriesGroupDurationParamsNormalizationPercentage AttackLayer3TimeseriesGroupDurationParamsNormalization = "PERCENTAGE" + AttackLayer3TimeseriesGroupDurationParamsNormalizationMin0Max AttackLayer3TimeseriesGroupDurationParamsNormalization = "MIN0_MAX" +) + +type AttackLayer3TimeseriesGroupDurationParamsProtocol string + +const ( + AttackLayer3TimeseriesGroupDurationParamsProtocolUdp AttackLayer3TimeseriesGroupDurationParamsProtocol = "UDP" + AttackLayer3TimeseriesGroupDurationParamsProtocolTcp AttackLayer3TimeseriesGroupDurationParamsProtocol = "TCP" + AttackLayer3TimeseriesGroupDurationParamsProtocolIcmp AttackLayer3TimeseriesGroupDurationParamsProtocol = "ICMP" + AttackLayer3TimeseriesGroupDurationParamsProtocolGRE AttackLayer3TimeseriesGroupDurationParamsProtocol = "GRE" +) + +type AttackLayer3TimeseriesGroupDurationResponseEnvelope struct { + Result AttackLayer3TimeseriesGroupDurationResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3TimeseriesGroupDurationResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupDurationResponseEnvelopeJSON contains the JSON +// metadata for the struct [AttackLayer3TimeseriesGroupDurationResponseEnvelope] +type attackLayer3TimeseriesGroupDurationResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupDurationResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupDurationResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupGetParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AttackLayer3TimeseriesGroupGetParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3TimeseriesGroupGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer3TimeseriesGroupGetParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AttackLayer3TimeseriesGroupGetParams]'s query parameters as +// `url.Values`. +func (r AttackLayer3TimeseriesGroupGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AttackLayer3TimeseriesGroupGetParamsAggInterval string + +const ( + AttackLayer3TimeseriesGroupGetParamsAggInterval15m AttackLayer3TimeseriesGroupGetParamsAggInterval = "15m" + AttackLayer3TimeseriesGroupGetParamsAggInterval1h AttackLayer3TimeseriesGroupGetParamsAggInterval = "1h" + AttackLayer3TimeseriesGroupGetParamsAggInterval1d AttackLayer3TimeseriesGroupGetParamsAggInterval = "1d" + AttackLayer3TimeseriesGroupGetParamsAggInterval1w AttackLayer3TimeseriesGroupGetParamsAggInterval = "1w" +) + +type AttackLayer3TimeseriesGroupGetParamsDateRange string + +const ( + AttackLayer3TimeseriesGroupGetParamsDateRange1d AttackLayer3TimeseriesGroupGetParamsDateRange = "1d" + AttackLayer3TimeseriesGroupGetParamsDateRange2d AttackLayer3TimeseriesGroupGetParamsDateRange = "2d" + AttackLayer3TimeseriesGroupGetParamsDateRange7d AttackLayer3TimeseriesGroupGetParamsDateRange = "7d" + AttackLayer3TimeseriesGroupGetParamsDateRange14d AttackLayer3TimeseriesGroupGetParamsDateRange = "14d" + AttackLayer3TimeseriesGroupGetParamsDateRange28d AttackLayer3TimeseriesGroupGetParamsDateRange = "28d" + AttackLayer3TimeseriesGroupGetParamsDateRange12w AttackLayer3TimeseriesGroupGetParamsDateRange = "12w" + AttackLayer3TimeseriesGroupGetParamsDateRange24w AttackLayer3TimeseriesGroupGetParamsDateRange = "24w" + AttackLayer3TimeseriesGroupGetParamsDateRange52w AttackLayer3TimeseriesGroupGetParamsDateRange = "52w" + AttackLayer3TimeseriesGroupGetParamsDateRange1dControl AttackLayer3TimeseriesGroupGetParamsDateRange = "1dControl" + AttackLayer3TimeseriesGroupGetParamsDateRange2dControl AttackLayer3TimeseriesGroupGetParamsDateRange = "2dControl" + AttackLayer3TimeseriesGroupGetParamsDateRange7dControl AttackLayer3TimeseriesGroupGetParamsDateRange = "7dControl" + AttackLayer3TimeseriesGroupGetParamsDateRange14dControl AttackLayer3TimeseriesGroupGetParamsDateRange = "14dControl" + AttackLayer3TimeseriesGroupGetParamsDateRange28dControl AttackLayer3TimeseriesGroupGetParamsDateRange = "28dControl" + AttackLayer3TimeseriesGroupGetParamsDateRange12wControl AttackLayer3TimeseriesGroupGetParamsDateRange = "12wControl" + AttackLayer3TimeseriesGroupGetParamsDateRange24wControl AttackLayer3TimeseriesGroupGetParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer3TimeseriesGroupGetParamsFormat string + +const ( + AttackLayer3TimeseriesGroupGetParamsFormatJson AttackLayer3TimeseriesGroupGetParamsFormat = "JSON" + AttackLayer3TimeseriesGroupGetParamsFormatCsv AttackLayer3TimeseriesGroupGetParamsFormat = "CSV" +) + +type AttackLayer3TimeseriesGroupGetResponseEnvelope struct { + Result AttackLayer3TimeseriesGroupGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3TimeseriesGroupGetResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupGetResponseEnvelopeJSON contains the JSON metadata +// for the struct [AttackLayer3TimeseriesGroupGetResponseEnvelope] +type attackLayer3TimeseriesGroupGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupIndustryParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AttackLayer3TimeseriesGroupIndustryParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3TimeseriesGroupIndustryParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Together with the `location` parameter, will apply the filter to origin or + // target location. + Direction param.Field[AttackLayer3TimeseriesGroupIndustryParamsDirection] `query:"direction"` + // Format results are returned in. + Format param.Field[AttackLayer3TimeseriesGroupIndustryParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer3TimeseriesGroupIndustryParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects (eg browsers, verticals, etc) to the top items over + // the time range. + LimitPerGroup param.Field[int64] `query:"limitPerGroup"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Normalization method applied. Refer to + // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + Normalization param.Field[AttackLayer3TimeseriesGroupIndustryParamsNormalization] `query:"normalization"` +} + +// URLQuery serializes [AttackLayer3TimeseriesGroupIndustryParams]'s query +// parameters as `url.Values`. +func (r AttackLayer3TimeseriesGroupIndustryParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AttackLayer3TimeseriesGroupIndustryParamsAggInterval string + +const ( + AttackLayer3TimeseriesGroupIndustryParamsAggInterval15m AttackLayer3TimeseriesGroupIndustryParamsAggInterval = "15m" + AttackLayer3TimeseriesGroupIndustryParamsAggInterval1h AttackLayer3TimeseriesGroupIndustryParamsAggInterval = "1h" + AttackLayer3TimeseriesGroupIndustryParamsAggInterval1d AttackLayer3TimeseriesGroupIndustryParamsAggInterval = "1d" + AttackLayer3TimeseriesGroupIndustryParamsAggInterval1w AttackLayer3TimeseriesGroupIndustryParamsAggInterval = "1w" +) + +type AttackLayer3TimeseriesGroupIndustryParamsDateRange string + +const ( + AttackLayer3TimeseriesGroupIndustryParamsDateRange1d AttackLayer3TimeseriesGroupIndustryParamsDateRange = "1d" + AttackLayer3TimeseriesGroupIndustryParamsDateRange2d AttackLayer3TimeseriesGroupIndustryParamsDateRange = "2d" + AttackLayer3TimeseriesGroupIndustryParamsDateRange7d AttackLayer3TimeseriesGroupIndustryParamsDateRange = "7d" + AttackLayer3TimeseriesGroupIndustryParamsDateRange14d AttackLayer3TimeseriesGroupIndustryParamsDateRange = "14d" + AttackLayer3TimeseriesGroupIndustryParamsDateRange28d AttackLayer3TimeseriesGroupIndustryParamsDateRange = "28d" + AttackLayer3TimeseriesGroupIndustryParamsDateRange12w AttackLayer3TimeseriesGroupIndustryParamsDateRange = "12w" + AttackLayer3TimeseriesGroupIndustryParamsDateRange24w AttackLayer3TimeseriesGroupIndustryParamsDateRange = "24w" + AttackLayer3TimeseriesGroupIndustryParamsDateRange52w AttackLayer3TimeseriesGroupIndustryParamsDateRange = "52w" + AttackLayer3TimeseriesGroupIndustryParamsDateRange1dControl AttackLayer3TimeseriesGroupIndustryParamsDateRange = "1dControl" + AttackLayer3TimeseriesGroupIndustryParamsDateRange2dControl AttackLayer3TimeseriesGroupIndustryParamsDateRange = "2dControl" + AttackLayer3TimeseriesGroupIndustryParamsDateRange7dControl AttackLayer3TimeseriesGroupIndustryParamsDateRange = "7dControl" + AttackLayer3TimeseriesGroupIndustryParamsDateRange14dControl AttackLayer3TimeseriesGroupIndustryParamsDateRange = "14dControl" + AttackLayer3TimeseriesGroupIndustryParamsDateRange28dControl AttackLayer3TimeseriesGroupIndustryParamsDateRange = "28dControl" + AttackLayer3TimeseriesGroupIndustryParamsDateRange12wControl AttackLayer3TimeseriesGroupIndustryParamsDateRange = "12wControl" + AttackLayer3TimeseriesGroupIndustryParamsDateRange24wControl AttackLayer3TimeseriesGroupIndustryParamsDateRange = "24wControl" +) + +// Together with the `location` parameter, will apply the filter to origin or +// target location. +type AttackLayer3TimeseriesGroupIndustryParamsDirection string + +const ( + AttackLayer3TimeseriesGroupIndustryParamsDirectionOrigin AttackLayer3TimeseriesGroupIndustryParamsDirection = "ORIGIN" + AttackLayer3TimeseriesGroupIndustryParamsDirectionTarget AttackLayer3TimeseriesGroupIndustryParamsDirection = "TARGET" +) + +// Format results are returned in. +type AttackLayer3TimeseriesGroupIndustryParamsFormat string + +const ( + AttackLayer3TimeseriesGroupIndustryParamsFormatJson AttackLayer3TimeseriesGroupIndustryParamsFormat = "JSON" + AttackLayer3TimeseriesGroupIndustryParamsFormatCsv AttackLayer3TimeseriesGroupIndustryParamsFormat = "CSV" +) + +type AttackLayer3TimeseriesGroupIndustryParamsIPVersion string + +const ( + AttackLayer3TimeseriesGroupIndustryParamsIPVersionIPv4 AttackLayer3TimeseriesGroupIndustryParamsIPVersion = "IPv4" + AttackLayer3TimeseriesGroupIndustryParamsIPVersionIPv6 AttackLayer3TimeseriesGroupIndustryParamsIPVersion = "IPv6" +) + +// Normalization method applied. Refer to +// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). +type AttackLayer3TimeseriesGroupIndustryParamsNormalization string + +const ( + AttackLayer3TimeseriesGroupIndustryParamsNormalizationPercentage AttackLayer3TimeseriesGroupIndustryParamsNormalization = "PERCENTAGE" + AttackLayer3TimeseriesGroupIndustryParamsNormalizationMin0Max AttackLayer3TimeseriesGroupIndustryParamsNormalization = "MIN0_MAX" +) + +type AttackLayer3TimeseriesGroupIndustryResponseEnvelope struct { + Result AttackLayer3TimeseriesGroupIndustryResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3TimeseriesGroupIndustryResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupIndustryResponseEnvelopeJSON contains the JSON +// metadata for the struct [AttackLayer3TimeseriesGroupIndustryResponseEnvelope] +type attackLayer3TimeseriesGroupIndustryResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupIndustryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupIndustryResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupIPVersionParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AttackLayer3TimeseriesGroupIPVersionParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3TimeseriesGroupIPVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Together with the `location` parameter, will apply the filter to origin or + // target location. + Direction param.Field[AttackLayer3TimeseriesGroupIPVersionParamsDirection] `query:"direction"` + // Format results are returned in. + Format param.Field[AttackLayer3TimeseriesGroupIPVersionParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Normalization method applied. Refer to + // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + Normalization param.Field[AttackLayer3TimeseriesGroupIPVersionParamsNormalization] `query:"normalization"` + // Array of L3/4 attack types. + Protocol param.Field[[]AttackLayer3TimeseriesGroupIPVersionParamsProtocol] `query:"protocol"` +} + +// URLQuery serializes [AttackLayer3TimeseriesGroupIPVersionParams]'s query +// parameters as `url.Values`. +func (r AttackLayer3TimeseriesGroupIPVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AttackLayer3TimeseriesGroupIPVersionParamsAggInterval string + +const ( + AttackLayer3TimeseriesGroupIPVersionParamsAggInterval15m AttackLayer3TimeseriesGroupIPVersionParamsAggInterval = "15m" + AttackLayer3TimeseriesGroupIPVersionParamsAggInterval1h AttackLayer3TimeseriesGroupIPVersionParamsAggInterval = "1h" + AttackLayer3TimeseriesGroupIPVersionParamsAggInterval1d AttackLayer3TimeseriesGroupIPVersionParamsAggInterval = "1d" + AttackLayer3TimeseriesGroupIPVersionParamsAggInterval1w AttackLayer3TimeseriesGroupIPVersionParamsAggInterval = "1w" +) + +type AttackLayer3TimeseriesGroupIPVersionParamsDateRange string + +const ( + AttackLayer3TimeseriesGroupIPVersionParamsDateRange1d AttackLayer3TimeseriesGroupIPVersionParamsDateRange = "1d" + AttackLayer3TimeseriesGroupIPVersionParamsDateRange2d AttackLayer3TimeseriesGroupIPVersionParamsDateRange = "2d" + AttackLayer3TimeseriesGroupIPVersionParamsDateRange7d AttackLayer3TimeseriesGroupIPVersionParamsDateRange = "7d" + AttackLayer3TimeseriesGroupIPVersionParamsDateRange14d AttackLayer3TimeseriesGroupIPVersionParamsDateRange = "14d" + AttackLayer3TimeseriesGroupIPVersionParamsDateRange28d AttackLayer3TimeseriesGroupIPVersionParamsDateRange = "28d" + AttackLayer3TimeseriesGroupIPVersionParamsDateRange12w AttackLayer3TimeseriesGroupIPVersionParamsDateRange = "12w" + AttackLayer3TimeseriesGroupIPVersionParamsDateRange24w AttackLayer3TimeseriesGroupIPVersionParamsDateRange = "24w" + AttackLayer3TimeseriesGroupIPVersionParamsDateRange52w AttackLayer3TimeseriesGroupIPVersionParamsDateRange = "52w" + AttackLayer3TimeseriesGroupIPVersionParamsDateRange1dControl AttackLayer3TimeseriesGroupIPVersionParamsDateRange = "1dControl" + AttackLayer3TimeseriesGroupIPVersionParamsDateRange2dControl AttackLayer3TimeseriesGroupIPVersionParamsDateRange = "2dControl" + AttackLayer3TimeseriesGroupIPVersionParamsDateRange7dControl AttackLayer3TimeseriesGroupIPVersionParamsDateRange = "7dControl" + AttackLayer3TimeseriesGroupIPVersionParamsDateRange14dControl AttackLayer3TimeseriesGroupIPVersionParamsDateRange = "14dControl" + AttackLayer3TimeseriesGroupIPVersionParamsDateRange28dControl AttackLayer3TimeseriesGroupIPVersionParamsDateRange = "28dControl" + AttackLayer3TimeseriesGroupIPVersionParamsDateRange12wControl AttackLayer3TimeseriesGroupIPVersionParamsDateRange = "12wControl" + AttackLayer3TimeseriesGroupIPVersionParamsDateRange24wControl AttackLayer3TimeseriesGroupIPVersionParamsDateRange = "24wControl" +) + +// Together with the `location` parameter, will apply the filter to origin or +// target location. +type AttackLayer3TimeseriesGroupIPVersionParamsDirection string + +const ( + AttackLayer3TimeseriesGroupIPVersionParamsDirectionOrigin AttackLayer3TimeseriesGroupIPVersionParamsDirection = "ORIGIN" + AttackLayer3TimeseriesGroupIPVersionParamsDirectionTarget AttackLayer3TimeseriesGroupIPVersionParamsDirection = "TARGET" +) + +// Format results are returned in. +type AttackLayer3TimeseriesGroupIPVersionParamsFormat string + +const ( + AttackLayer3TimeseriesGroupIPVersionParamsFormatJson AttackLayer3TimeseriesGroupIPVersionParamsFormat = "JSON" + AttackLayer3TimeseriesGroupIPVersionParamsFormatCsv AttackLayer3TimeseriesGroupIPVersionParamsFormat = "CSV" +) + +// Normalization method applied. Refer to +// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). +type AttackLayer3TimeseriesGroupIPVersionParamsNormalization string + +const ( + AttackLayer3TimeseriesGroupIPVersionParamsNormalizationPercentage AttackLayer3TimeseriesGroupIPVersionParamsNormalization = "PERCENTAGE" + AttackLayer3TimeseriesGroupIPVersionParamsNormalizationMin0Max AttackLayer3TimeseriesGroupIPVersionParamsNormalization = "MIN0_MAX" +) + +type AttackLayer3TimeseriesGroupIPVersionParamsProtocol string + +const ( + AttackLayer3TimeseriesGroupIPVersionParamsProtocolUdp AttackLayer3TimeseriesGroupIPVersionParamsProtocol = "UDP" + AttackLayer3TimeseriesGroupIPVersionParamsProtocolTcp AttackLayer3TimeseriesGroupIPVersionParamsProtocol = "TCP" + AttackLayer3TimeseriesGroupIPVersionParamsProtocolIcmp AttackLayer3TimeseriesGroupIPVersionParamsProtocol = "ICMP" + AttackLayer3TimeseriesGroupIPVersionParamsProtocolGRE AttackLayer3TimeseriesGroupIPVersionParamsProtocol = "GRE" +) + +type AttackLayer3TimeseriesGroupIPVersionResponseEnvelope struct { + Result AttackLayer3TimeseriesGroupIPVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3TimeseriesGroupIPVersionResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupIPVersionResponseEnvelopeJSON contains the JSON +// metadata for the struct [AttackLayer3TimeseriesGroupIPVersionResponseEnvelope] +type attackLayer3TimeseriesGroupIPVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupIPVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupProtocolParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AttackLayer3TimeseriesGroupProtocolParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3TimeseriesGroupProtocolParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Together with the `location` parameter, will apply the filter to origin or + // target location. + Direction param.Field[AttackLayer3TimeseriesGroupProtocolParamsDirection] `query:"direction"` + // Format results are returned in. + Format param.Field[AttackLayer3TimeseriesGroupProtocolParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer3TimeseriesGroupProtocolParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Normalization method applied. Refer to + // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + Normalization param.Field[AttackLayer3TimeseriesGroupProtocolParamsNormalization] `query:"normalization"` +} + +// URLQuery serializes [AttackLayer3TimeseriesGroupProtocolParams]'s query +// parameters as `url.Values`. +func (r AttackLayer3TimeseriesGroupProtocolParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AttackLayer3TimeseriesGroupProtocolParamsAggInterval string + +const ( + AttackLayer3TimeseriesGroupProtocolParamsAggInterval15m AttackLayer3TimeseriesGroupProtocolParamsAggInterval = "15m" + AttackLayer3TimeseriesGroupProtocolParamsAggInterval1h AttackLayer3TimeseriesGroupProtocolParamsAggInterval = "1h" + AttackLayer3TimeseriesGroupProtocolParamsAggInterval1d AttackLayer3TimeseriesGroupProtocolParamsAggInterval = "1d" + AttackLayer3TimeseriesGroupProtocolParamsAggInterval1w AttackLayer3TimeseriesGroupProtocolParamsAggInterval = "1w" +) + +type AttackLayer3TimeseriesGroupProtocolParamsDateRange string + +const ( + AttackLayer3TimeseriesGroupProtocolParamsDateRange1d AttackLayer3TimeseriesGroupProtocolParamsDateRange = "1d" + AttackLayer3TimeseriesGroupProtocolParamsDateRange2d AttackLayer3TimeseriesGroupProtocolParamsDateRange = "2d" + AttackLayer3TimeseriesGroupProtocolParamsDateRange7d AttackLayer3TimeseriesGroupProtocolParamsDateRange = "7d" + AttackLayer3TimeseriesGroupProtocolParamsDateRange14d AttackLayer3TimeseriesGroupProtocolParamsDateRange = "14d" + AttackLayer3TimeseriesGroupProtocolParamsDateRange28d AttackLayer3TimeseriesGroupProtocolParamsDateRange = "28d" + AttackLayer3TimeseriesGroupProtocolParamsDateRange12w AttackLayer3TimeseriesGroupProtocolParamsDateRange = "12w" + AttackLayer3TimeseriesGroupProtocolParamsDateRange24w AttackLayer3TimeseriesGroupProtocolParamsDateRange = "24w" + AttackLayer3TimeseriesGroupProtocolParamsDateRange52w AttackLayer3TimeseriesGroupProtocolParamsDateRange = "52w" + AttackLayer3TimeseriesGroupProtocolParamsDateRange1dControl AttackLayer3TimeseriesGroupProtocolParamsDateRange = "1dControl" + AttackLayer3TimeseriesGroupProtocolParamsDateRange2dControl AttackLayer3TimeseriesGroupProtocolParamsDateRange = "2dControl" + AttackLayer3TimeseriesGroupProtocolParamsDateRange7dControl AttackLayer3TimeseriesGroupProtocolParamsDateRange = "7dControl" + AttackLayer3TimeseriesGroupProtocolParamsDateRange14dControl AttackLayer3TimeseriesGroupProtocolParamsDateRange = "14dControl" + AttackLayer3TimeseriesGroupProtocolParamsDateRange28dControl AttackLayer3TimeseriesGroupProtocolParamsDateRange = "28dControl" + AttackLayer3TimeseriesGroupProtocolParamsDateRange12wControl AttackLayer3TimeseriesGroupProtocolParamsDateRange = "12wControl" + AttackLayer3TimeseriesGroupProtocolParamsDateRange24wControl AttackLayer3TimeseriesGroupProtocolParamsDateRange = "24wControl" +) + +// Together with the `location` parameter, will apply the filter to origin or +// target location. +type AttackLayer3TimeseriesGroupProtocolParamsDirection string + +const ( + AttackLayer3TimeseriesGroupProtocolParamsDirectionOrigin AttackLayer3TimeseriesGroupProtocolParamsDirection = "ORIGIN" + AttackLayer3TimeseriesGroupProtocolParamsDirectionTarget AttackLayer3TimeseriesGroupProtocolParamsDirection = "TARGET" +) + +// Format results are returned in. +type AttackLayer3TimeseriesGroupProtocolParamsFormat string + +const ( + AttackLayer3TimeseriesGroupProtocolParamsFormatJson AttackLayer3TimeseriesGroupProtocolParamsFormat = "JSON" + AttackLayer3TimeseriesGroupProtocolParamsFormatCsv AttackLayer3TimeseriesGroupProtocolParamsFormat = "CSV" +) + +type AttackLayer3TimeseriesGroupProtocolParamsIPVersion string + +const ( + AttackLayer3TimeseriesGroupProtocolParamsIPVersionIPv4 AttackLayer3TimeseriesGroupProtocolParamsIPVersion = "IPv4" + AttackLayer3TimeseriesGroupProtocolParamsIPVersionIPv6 AttackLayer3TimeseriesGroupProtocolParamsIPVersion = "IPv6" +) + +// Normalization method applied. Refer to +// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). +type AttackLayer3TimeseriesGroupProtocolParamsNormalization string + +const ( + AttackLayer3TimeseriesGroupProtocolParamsNormalizationPercentage AttackLayer3TimeseriesGroupProtocolParamsNormalization = "PERCENTAGE" + AttackLayer3TimeseriesGroupProtocolParamsNormalizationMin0Max AttackLayer3TimeseriesGroupProtocolParamsNormalization = "MIN0_MAX" +) + +type AttackLayer3TimeseriesGroupProtocolResponseEnvelope struct { + Result AttackLayer3TimeseriesGroupProtocolResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3TimeseriesGroupProtocolResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupProtocolResponseEnvelopeJSON contains the JSON +// metadata for the struct [AttackLayer3TimeseriesGroupProtocolResponseEnvelope] +type attackLayer3TimeseriesGroupProtocolResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupProtocolResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupProtocolResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupVectorParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AttackLayer3TimeseriesGroupVectorParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3TimeseriesGroupVectorParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Together with the `location` parameter, will apply the filter to origin or + // target location. + Direction param.Field[AttackLayer3TimeseriesGroupVectorParamsDirection] `query:"direction"` + // Format results are returned in. + Format param.Field[AttackLayer3TimeseriesGroupVectorParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer3TimeseriesGroupVectorParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects (eg browsers, verticals, etc) to the top items over + // the time range. + LimitPerGroup param.Field[int64] `query:"limitPerGroup"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Normalization method applied. Refer to + // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + Normalization param.Field[AttackLayer3TimeseriesGroupVectorParamsNormalization] `query:"normalization"` + // Array of L3/4 attack types. + Protocol param.Field[[]AttackLayer3TimeseriesGroupVectorParamsProtocol] `query:"protocol"` +} + +// URLQuery serializes [AttackLayer3TimeseriesGroupVectorParams]'s query parameters +// as `url.Values`. +func (r AttackLayer3TimeseriesGroupVectorParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AttackLayer3TimeseriesGroupVectorParamsAggInterval string + +const ( + AttackLayer3TimeseriesGroupVectorParamsAggInterval15m AttackLayer3TimeseriesGroupVectorParamsAggInterval = "15m" + AttackLayer3TimeseriesGroupVectorParamsAggInterval1h AttackLayer3TimeseriesGroupVectorParamsAggInterval = "1h" + AttackLayer3TimeseriesGroupVectorParamsAggInterval1d AttackLayer3TimeseriesGroupVectorParamsAggInterval = "1d" + AttackLayer3TimeseriesGroupVectorParamsAggInterval1w AttackLayer3TimeseriesGroupVectorParamsAggInterval = "1w" +) + +type AttackLayer3TimeseriesGroupVectorParamsDateRange string + +const ( + AttackLayer3TimeseriesGroupVectorParamsDateRange1d AttackLayer3TimeseriesGroupVectorParamsDateRange = "1d" + AttackLayer3TimeseriesGroupVectorParamsDateRange2d AttackLayer3TimeseriesGroupVectorParamsDateRange = "2d" + AttackLayer3TimeseriesGroupVectorParamsDateRange7d AttackLayer3TimeseriesGroupVectorParamsDateRange = "7d" + AttackLayer3TimeseriesGroupVectorParamsDateRange14d AttackLayer3TimeseriesGroupVectorParamsDateRange = "14d" + AttackLayer3TimeseriesGroupVectorParamsDateRange28d AttackLayer3TimeseriesGroupVectorParamsDateRange = "28d" + AttackLayer3TimeseriesGroupVectorParamsDateRange12w AttackLayer3TimeseriesGroupVectorParamsDateRange = "12w" + AttackLayer3TimeseriesGroupVectorParamsDateRange24w AttackLayer3TimeseriesGroupVectorParamsDateRange = "24w" + AttackLayer3TimeseriesGroupVectorParamsDateRange52w AttackLayer3TimeseriesGroupVectorParamsDateRange = "52w" + AttackLayer3TimeseriesGroupVectorParamsDateRange1dControl AttackLayer3TimeseriesGroupVectorParamsDateRange = "1dControl" + AttackLayer3TimeseriesGroupVectorParamsDateRange2dControl AttackLayer3TimeseriesGroupVectorParamsDateRange = "2dControl" + AttackLayer3TimeseriesGroupVectorParamsDateRange7dControl AttackLayer3TimeseriesGroupVectorParamsDateRange = "7dControl" + AttackLayer3TimeseriesGroupVectorParamsDateRange14dControl AttackLayer3TimeseriesGroupVectorParamsDateRange = "14dControl" + AttackLayer3TimeseriesGroupVectorParamsDateRange28dControl AttackLayer3TimeseriesGroupVectorParamsDateRange = "28dControl" + AttackLayer3TimeseriesGroupVectorParamsDateRange12wControl AttackLayer3TimeseriesGroupVectorParamsDateRange = "12wControl" + AttackLayer3TimeseriesGroupVectorParamsDateRange24wControl AttackLayer3TimeseriesGroupVectorParamsDateRange = "24wControl" +) + +// Together with the `location` parameter, will apply the filter to origin or +// target location. +type AttackLayer3TimeseriesGroupVectorParamsDirection string + +const ( + AttackLayer3TimeseriesGroupVectorParamsDirectionOrigin AttackLayer3TimeseriesGroupVectorParamsDirection = "ORIGIN" + AttackLayer3TimeseriesGroupVectorParamsDirectionTarget AttackLayer3TimeseriesGroupVectorParamsDirection = "TARGET" +) + +// Format results are returned in. +type AttackLayer3TimeseriesGroupVectorParamsFormat string + +const ( + AttackLayer3TimeseriesGroupVectorParamsFormatJson AttackLayer3TimeseriesGroupVectorParamsFormat = "JSON" + AttackLayer3TimeseriesGroupVectorParamsFormatCsv AttackLayer3TimeseriesGroupVectorParamsFormat = "CSV" +) + +type AttackLayer3TimeseriesGroupVectorParamsIPVersion string + +const ( + AttackLayer3TimeseriesGroupVectorParamsIPVersionIPv4 AttackLayer3TimeseriesGroupVectorParamsIPVersion = "IPv4" + AttackLayer3TimeseriesGroupVectorParamsIPVersionIPv6 AttackLayer3TimeseriesGroupVectorParamsIPVersion = "IPv6" +) + +// Normalization method applied. Refer to +// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). +type AttackLayer3TimeseriesGroupVectorParamsNormalization string + +const ( + AttackLayer3TimeseriesGroupVectorParamsNormalizationPercentage AttackLayer3TimeseriesGroupVectorParamsNormalization = "PERCENTAGE" + AttackLayer3TimeseriesGroupVectorParamsNormalizationMin0Max AttackLayer3TimeseriesGroupVectorParamsNormalization = "MIN0_MAX" +) + +type AttackLayer3TimeseriesGroupVectorParamsProtocol string + +const ( + AttackLayer3TimeseriesGroupVectorParamsProtocolUdp AttackLayer3TimeseriesGroupVectorParamsProtocol = "UDP" + AttackLayer3TimeseriesGroupVectorParamsProtocolTcp AttackLayer3TimeseriesGroupVectorParamsProtocol = "TCP" + AttackLayer3TimeseriesGroupVectorParamsProtocolIcmp AttackLayer3TimeseriesGroupVectorParamsProtocol = "ICMP" + AttackLayer3TimeseriesGroupVectorParamsProtocolGRE AttackLayer3TimeseriesGroupVectorParamsProtocol = "GRE" +) + +type AttackLayer3TimeseriesGroupVectorResponseEnvelope struct { + Result AttackLayer3TimeseriesGroupVectorResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3TimeseriesGroupVectorResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupVectorResponseEnvelopeJSON contains the JSON metadata +// for the struct [AttackLayer3TimeseriesGroupVectorResponseEnvelope] +type attackLayer3TimeseriesGroupVectorResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupVectorResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupVectorResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TimeseriesGroupVerticalParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AttackLayer3TimeseriesGroupVerticalParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3TimeseriesGroupVerticalParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Together with the `location` parameter, will apply the filter to origin or + // target location. + Direction param.Field[AttackLayer3TimeseriesGroupVerticalParamsDirection] `query:"direction"` + // Format results are returned in. + Format param.Field[AttackLayer3TimeseriesGroupVerticalParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer3TimeseriesGroupVerticalParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects (eg browsers, verticals, etc) to the top items over + // the time range. + LimitPerGroup param.Field[int64] `query:"limitPerGroup"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Normalization method applied. Refer to + // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + Normalization param.Field[AttackLayer3TimeseriesGroupVerticalParamsNormalization] `query:"normalization"` +} + +// URLQuery serializes [AttackLayer3TimeseriesGroupVerticalParams]'s query +// parameters as `url.Values`. +func (r AttackLayer3TimeseriesGroupVerticalParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AttackLayer3TimeseriesGroupVerticalParamsAggInterval string + +const ( + AttackLayer3TimeseriesGroupVerticalParamsAggInterval15m AttackLayer3TimeseriesGroupVerticalParamsAggInterval = "15m" + AttackLayer3TimeseriesGroupVerticalParamsAggInterval1h AttackLayer3TimeseriesGroupVerticalParamsAggInterval = "1h" + AttackLayer3TimeseriesGroupVerticalParamsAggInterval1d AttackLayer3TimeseriesGroupVerticalParamsAggInterval = "1d" + AttackLayer3TimeseriesGroupVerticalParamsAggInterval1w AttackLayer3TimeseriesGroupVerticalParamsAggInterval = "1w" +) + +type AttackLayer3TimeseriesGroupVerticalParamsDateRange string + +const ( + AttackLayer3TimeseriesGroupVerticalParamsDateRange1d AttackLayer3TimeseriesGroupVerticalParamsDateRange = "1d" + AttackLayer3TimeseriesGroupVerticalParamsDateRange2d AttackLayer3TimeseriesGroupVerticalParamsDateRange = "2d" + AttackLayer3TimeseriesGroupVerticalParamsDateRange7d AttackLayer3TimeseriesGroupVerticalParamsDateRange = "7d" + AttackLayer3TimeseriesGroupVerticalParamsDateRange14d AttackLayer3TimeseriesGroupVerticalParamsDateRange = "14d" + AttackLayer3TimeseriesGroupVerticalParamsDateRange28d AttackLayer3TimeseriesGroupVerticalParamsDateRange = "28d" + AttackLayer3TimeseriesGroupVerticalParamsDateRange12w AttackLayer3TimeseriesGroupVerticalParamsDateRange = "12w" + AttackLayer3TimeseriesGroupVerticalParamsDateRange24w AttackLayer3TimeseriesGroupVerticalParamsDateRange = "24w" + AttackLayer3TimeseriesGroupVerticalParamsDateRange52w AttackLayer3TimeseriesGroupVerticalParamsDateRange = "52w" + AttackLayer3TimeseriesGroupVerticalParamsDateRange1dControl AttackLayer3TimeseriesGroupVerticalParamsDateRange = "1dControl" + AttackLayer3TimeseriesGroupVerticalParamsDateRange2dControl AttackLayer3TimeseriesGroupVerticalParamsDateRange = "2dControl" + AttackLayer3TimeseriesGroupVerticalParamsDateRange7dControl AttackLayer3TimeseriesGroupVerticalParamsDateRange = "7dControl" + AttackLayer3TimeseriesGroupVerticalParamsDateRange14dControl AttackLayer3TimeseriesGroupVerticalParamsDateRange = "14dControl" + AttackLayer3TimeseriesGroupVerticalParamsDateRange28dControl AttackLayer3TimeseriesGroupVerticalParamsDateRange = "28dControl" + AttackLayer3TimeseriesGroupVerticalParamsDateRange12wControl AttackLayer3TimeseriesGroupVerticalParamsDateRange = "12wControl" + AttackLayer3TimeseriesGroupVerticalParamsDateRange24wControl AttackLayer3TimeseriesGroupVerticalParamsDateRange = "24wControl" +) + +// Together with the `location` parameter, will apply the filter to origin or +// target location. +type AttackLayer3TimeseriesGroupVerticalParamsDirection string + +const ( + AttackLayer3TimeseriesGroupVerticalParamsDirectionOrigin AttackLayer3TimeseriesGroupVerticalParamsDirection = "ORIGIN" + AttackLayer3TimeseriesGroupVerticalParamsDirectionTarget AttackLayer3TimeseriesGroupVerticalParamsDirection = "TARGET" +) + +// Format results are returned in. +type AttackLayer3TimeseriesGroupVerticalParamsFormat string + +const ( + AttackLayer3TimeseriesGroupVerticalParamsFormatJson AttackLayer3TimeseriesGroupVerticalParamsFormat = "JSON" + AttackLayer3TimeseriesGroupVerticalParamsFormatCsv AttackLayer3TimeseriesGroupVerticalParamsFormat = "CSV" +) + +type AttackLayer3TimeseriesGroupVerticalParamsIPVersion string + +const ( + AttackLayer3TimeseriesGroupVerticalParamsIPVersionIPv4 AttackLayer3TimeseriesGroupVerticalParamsIPVersion = "IPv4" + AttackLayer3TimeseriesGroupVerticalParamsIPVersionIPv6 AttackLayer3TimeseriesGroupVerticalParamsIPVersion = "IPv6" +) + +// Normalization method applied. Refer to +// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). +type AttackLayer3TimeseriesGroupVerticalParamsNormalization string + +const ( + AttackLayer3TimeseriesGroupVerticalParamsNormalizationPercentage AttackLayer3TimeseriesGroupVerticalParamsNormalization = "PERCENTAGE" + AttackLayer3TimeseriesGroupVerticalParamsNormalizationMin0Max AttackLayer3TimeseriesGroupVerticalParamsNormalization = "MIN0_MAX" +) + +type AttackLayer3TimeseriesGroupVerticalResponseEnvelope struct { + Result AttackLayer3TimeseriesGroupVerticalResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3TimeseriesGroupVerticalResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3TimeseriesGroupVerticalResponseEnvelopeJSON contains the JSON +// metadata for the struct [AttackLayer3TimeseriesGroupVerticalResponseEnvelope] +type attackLayer3TimeseriesGroupVerticalResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TimeseriesGroupVerticalResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TimeseriesGroupVerticalResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/attacklayer3timeseriesgroup_test.go b/radar/attacklayer3timeseriesgroup_test.go new file mode 100644 index 00000000000..e4264ad8fc7 --- /dev/null +++ b/radar/attacklayer3timeseriesgroup_test.go @@ -0,0 +1,308 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestAttackLayer3TimeseriesGroupBitrateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.TimeseriesGroups.Bitrate(context.TODO(), radar.AttackLayer3TimeseriesGroupBitrateParams{ + AggInterval: cloudflare.F(radar.AttackLayer3TimeseriesGroupBitrateParamsAggInterval1h), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3TimeseriesGroupBitrateParamsDateRange{radar.AttackLayer3TimeseriesGroupBitrateParamsDateRange1d, radar.AttackLayer3TimeseriesGroupBitrateParamsDateRange2d, radar.AttackLayer3TimeseriesGroupBitrateParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Direction: cloudflare.F(radar.AttackLayer3TimeseriesGroupBitrateParamsDirectionOrigin), + Format: cloudflare.F(radar.AttackLayer3TimeseriesGroupBitrateParamsFormatJson), + IPVersion: cloudflare.F([]radar.AttackLayer3TimeseriesGroupBitrateParamsIPVersion{radar.AttackLayer3TimeseriesGroupBitrateParamsIPVersionIPv4, radar.AttackLayer3TimeseriesGroupBitrateParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Normalization: cloudflare.F(radar.AttackLayer3TimeseriesGroupBitrateParamsNormalizationPercentage), + Protocol: cloudflare.F([]radar.AttackLayer3TimeseriesGroupBitrateParamsProtocol{radar.AttackLayer3TimeseriesGroupBitrateParamsProtocolUdp, radar.AttackLayer3TimeseriesGroupBitrateParamsProtocolTcp, radar.AttackLayer3TimeseriesGroupBitrateParamsProtocolIcmp}), + }) + 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 TestAttackLayer3TimeseriesGroupDurationWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.TimeseriesGroups.Duration(context.TODO(), radar.AttackLayer3TimeseriesGroupDurationParams{ + AggInterval: cloudflare.F(radar.AttackLayer3TimeseriesGroupDurationParamsAggInterval1h), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3TimeseriesGroupDurationParamsDateRange{radar.AttackLayer3TimeseriesGroupDurationParamsDateRange1d, radar.AttackLayer3TimeseriesGroupDurationParamsDateRange2d, radar.AttackLayer3TimeseriesGroupDurationParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Direction: cloudflare.F(radar.AttackLayer3TimeseriesGroupDurationParamsDirectionOrigin), + Format: cloudflare.F(radar.AttackLayer3TimeseriesGroupDurationParamsFormatJson), + IPVersion: cloudflare.F([]radar.AttackLayer3TimeseriesGroupDurationParamsIPVersion{radar.AttackLayer3TimeseriesGroupDurationParamsIPVersionIPv4, radar.AttackLayer3TimeseriesGroupDurationParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Normalization: cloudflare.F(radar.AttackLayer3TimeseriesGroupDurationParamsNormalizationPercentage), + Protocol: cloudflare.F([]radar.AttackLayer3TimeseriesGroupDurationParamsProtocol{radar.AttackLayer3TimeseriesGroupDurationParamsProtocolUdp, radar.AttackLayer3TimeseriesGroupDurationParamsProtocolTcp, radar.AttackLayer3TimeseriesGroupDurationParamsProtocolIcmp}), + }) + 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 TestAttackLayer3TimeseriesGroupGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.TimeseriesGroups.Get(context.TODO(), radar.AttackLayer3TimeseriesGroupGetParams{ + AggInterval: cloudflare.F(radar.AttackLayer3TimeseriesGroupGetParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3TimeseriesGroupGetParamsDateRange{radar.AttackLayer3TimeseriesGroupGetParamsDateRange1d, radar.AttackLayer3TimeseriesGroupGetParamsDateRange2d, radar.AttackLayer3TimeseriesGroupGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer3TimeseriesGroupGetParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAttackLayer3TimeseriesGroupIndustryWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.TimeseriesGroups.Industry(context.TODO(), radar.AttackLayer3TimeseriesGroupIndustryParams{ + AggInterval: cloudflare.F(radar.AttackLayer3TimeseriesGroupIndustryParamsAggInterval1h), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3TimeseriesGroupIndustryParamsDateRange{radar.AttackLayer3TimeseriesGroupIndustryParamsDateRange1d, radar.AttackLayer3TimeseriesGroupIndustryParamsDateRange2d, radar.AttackLayer3TimeseriesGroupIndustryParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Direction: cloudflare.F(radar.AttackLayer3TimeseriesGroupIndustryParamsDirectionOrigin), + Format: cloudflare.F(radar.AttackLayer3TimeseriesGroupIndustryParamsFormatJson), + IPVersion: cloudflare.F([]radar.AttackLayer3TimeseriesGroupIndustryParamsIPVersion{radar.AttackLayer3TimeseriesGroupIndustryParamsIPVersionIPv4, radar.AttackLayer3TimeseriesGroupIndustryParamsIPVersionIPv6}), + LimitPerGroup: cloudflare.F(int64(4)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Normalization: cloudflare.F(radar.AttackLayer3TimeseriesGroupIndustryParamsNormalizationPercentage), + }) + 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 TestAttackLayer3TimeseriesGroupIPVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.TimeseriesGroups.IPVersion(context.TODO(), radar.AttackLayer3TimeseriesGroupIPVersionParams{ + AggInterval: cloudflare.F(radar.AttackLayer3TimeseriesGroupIPVersionParamsAggInterval1h), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3TimeseriesGroupIPVersionParamsDateRange{radar.AttackLayer3TimeseriesGroupIPVersionParamsDateRange1d, radar.AttackLayer3TimeseriesGroupIPVersionParamsDateRange2d, radar.AttackLayer3TimeseriesGroupIPVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Direction: cloudflare.F(radar.AttackLayer3TimeseriesGroupIPVersionParamsDirectionOrigin), + Format: cloudflare.F(radar.AttackLayer3TimeseriesGroupIPVersionParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Normalization: cloudflare.F(radar.AttackLayer3TimeseriesGroupIPVersionParamsNormalizationPercentage), + Protocol: cloudflare.F([]radar.AttackLayer3TimeseriesGroupIPVersionParamsProtocol{radar.AttackLayer3TimeseriesGroupIPVersionParamsProtocolUdp, radar.AttackLayer3TimeseriesGroupIPVersionParamsProtocolTcp, radar.AttackLayer3TimeseriesGroupIPVersionParamsProtocolIcmp}), + }) + 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 TestAttackLayer3TimeseriesGroupProtocolWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.TimeseriesGroups.Protocol(context.TODO(), radar.AttackLayer3TimeseriesGroupProtocolParams{ + AggInterval: cloudflare.F(radar.AttackLayer3TimeseriesGroupProtocolParamsAggInterval1h), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3TimeseriesGroupProtocolParamsDateRange{radar.AttackLayer3TimeseriesGroupProtocolParamsDateRange1d, radar.AttackLayer3TimeseriesGroupProtocolParamsDateRange2d, radar.AttackLayer3TimeseriesGroupProtocolParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Direction: cloudflare.F(radar.AttackLayer3TimeseriesGroupProtocolParamsDirectionOrigin), + Format: cloudflare.F(radar.AttackLayer3TimeseriesGroupProtocolParamsFormatJson), + IPVersion: cloudflare.F([]radar.AttackLayer3TimeseriesGroupProtocolParamsIPVersion{radar.AttackLayer3TimeseriesGroupProtocolParamsIPVersionIPv4, radar.AttackLayer3TimeseriesGroupProtocolParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Normalization: cloudflare.F(radar.AttackLayer3TimeseriesGroupProtocolParamsNormalizationPercentage), + }) + 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 TestAttackLayer3TimeseriesGroupVectorWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.TimeseriesGroups.Vector(context.TODO(), radar.AttackLayer3TimeseriesGroupVectorParams{ + AggInterval: cloudflare.F(radar.AttackLayer3TimeseriesGroupVectorParamsAggInterval1h), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3TimeseriesGroupVectorParamsDateRange{radar.AttackLayer3TimeseriesGroupVectorParamsDateRange1d, radar.AttackLayer3TimeseriesGroupVectorParamsDateRange2d, radar.AttackLayer3TimeseriesGroupVectorParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Direction: cloudflare.F(radar.AttackLayer3TimeseriesGroupVectorParamsDirectionOrigin), + Format: cloudflare.F(radar.AttackLayer3TimeseriesGroupVectorParamsFormatJson), + IPVersion: cloudflare.F([]radar.AttackLayer3TimeseriesGroupVectorParamsIPVersion{radar.AttackLayer3TimeseriesGroupVectorParamsIPVersionIPv4, radar.AttackLayer3TimeseriesGroupVectorParamsIPVersionIPv6}), + LimitPerGroup: cloudflare.F(int64(4)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Normalization: cloudflare.F(radar.AttackLayer3TimeseriesGroupVectorParamsNormalizationPercentage), + Protocol: cloudflare.F([]radar.AttackLayer3TimeseriesGroupVectorParamsProtocol{radar.AttackLayer3TimeseriesGroupVectorParamsProtocolUdp, radar.AttackLayer3TimeseriesGroupVectorParamsProtocolTcp, radar.AttackLayer3TimeseriesGroupVectorParamsProtocolIcmp}), + }) + 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 TestAttackLayer3TimeseriesGroupVerticalWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.TimeseriesGroups.Vertical(context.TODO(), radar.AttackLayer3TimeseriesGroupVerticalParams{ + AggInterval: cloudflare.F(radar.AttackLayer3TimeseriesGroupVerticalParamsAggInterval1h), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3TimeseriesGroupVerticalParamsDateRange{radar.AttackLayer3TimeseriesGroupVerticalParamsDateRange1d, radar.AttackLayer3TimeseriesGroupVerticalParamsDateRange2d, radar.AttackLayer3TimeseriesGroupVerticalParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Direction: cloudflare.F(radar.AttackLayer3TimeseriesGroupVerticalParamsDirectionOrigin), + Format: cloudflare.F(radar.AttackLayer3TimeseriesGroupVerticalParamsFormatJson), + IPVersion: cloudflare.F([]radar.AttackLayer3TimeseriesGroupVerticalParamsIPVersion{radar.AttackLayer3TimeseriesGroupVerticalParamsIPVersionIPv4, radar.AttackLayer3TimeseriesGroupVerticalParamsIPVersionIPv6}), + LimitPerGroup: cloudflare.F(int64(4)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Normalization: cloudflare.F(radar.AttackLayer3TimeseriesGroupVerticalParamsNormalizationPercentage), + }) + 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/radar/attacklayer3top.go b/radar/attacklayer3top.go new file mode 100644 index 00000000000..c62582630ac --- /dev/null +++ b/radar/attacklayer3top.go @@ -0,0 +1,871 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AttackLayer3TopService 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 [NewAttackLayer3TopService] method +// instead. +type AttackLayer3TopService struct { + Options []option.RequestOption + Locations *AttackLayer3TopLocationService +} + +// NewAttackLayer3TopService 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 NewAttackLayer3TopService(opts ...option.RequestOption) (r *AttackLayer3TopService) { + r = &AttackLayer3TopService{} + r.Options = opts + r.Locations = NewAttackLayer3TopLocationService(opts...) + return +} + +// Get the top attacks from origin to target location. Values are a percentage out +// of the total layer 3 attacks (with billing country). You can optionally limit +// the number of attacks per origin/target location (useful if all the top attacks +// are from or to the same location). +func (r *AttackLayer3TopService) Attacks(ctx context.Context, query AttackLayer3TopAttacksParams, opts ...option.RequestOption) (res *AttackLayer3TopAttacksResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3TopAttacksResponseEnvelope + path := "radar/attacks/layer3/top/attacks" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the Industry of attacks. +func (r *AttackLayer3TopService) Industry(ctx context.Context, query AttackLayer3TopIndustryParams, opts ...option.RequestOption) (res *AttackLayer3TopIndustryResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3TopIndustryResponseEnvelope + path := "radar/attacks/layer3/top/industry" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the Verticals of attacks. +func (r *AttackLayer3TopService) Vertical(ctx context.Context, query AttackLayer3TopVerticalParams, opts ...option.RequestOption) (res *AttackLayer3TopVerticalResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3TopVerticalResponseEnvelope + path := "radar/attacks/layer3/top/vertical" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AttackLayer3TopAttacksResponse struct { + Meta AttackLayer3TopAttacksResponseMeta `json:"meta,required"` + Top0 []AttackLayer3TopAttacksResponseTop0 `json:"top_0,required"` + JSON attackLayer3TopAttacksResponseJSON `json:"-"` +} + +// attackLayer3TopAttacksResponseJSON contains the JSON metadata for the struct +// [AttackLayer3TopAttacksResponse] +type attackLayer3TopAttacksResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopAttacksResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopAttacksResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopAttacksResponseMeta struct { + DateRange []AttackLayer3TopAttacksResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo AttackLayer3TopAttacksResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer3TopAttacksResponseMetaJSON `json:"-"` +} + +// attackLayer3TopAttacksResponseMetaJSON contains the JSON metadata for the struct +// [AttackLayer3TopAttacksResponseMeta] +type attackLayer3TopAttacksResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopAttacksResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopAttacksResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopAttacksResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer3TopAttacksResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer3TopAttacksResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [AttackLayer3TopAttacksResponseMetaDateRange] +type attackLayer3TopAttacksResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopAttacksResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopAttacksResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopAttacksResponseMetaConfidenceInfo struct { + Annotations []AttackLayer3TopAttacksResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer3TopAttacksResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer3TopAttacksResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [AttackLayer3TopAttacksResponseMetaConfidenceInfo] +type attackLayer3TopAttacksResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopAttacksResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopAttacksResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopAttacksResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer3TopAttacksResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer3TopAttacksResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [AttackLayer3TopAttacksResponseMetaConfidenceInfoAnnotation] +type attackLayer3TopAttacksResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopAttacksResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopAttacksResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopAttacksResponseTop0 struct { + OriginCountryAlpha2 string `json:"originCountryAlpha2,required"` + OriginCountryName string `json:"originCountryName,required"` + Value string `json:"value,required"` + JSON attackLayer3TopAttacksResponseTop0JSON `json:"-"` +} + +// attackLayer3TopAttacksResponseTop0JSON contains the JSON metadata for the struct +// [AttackLayer3TopAttacksResponseTop0] +type attackLayer3TopAttacksResponseTop0JSON struct { + OriginCountryAlpha2 apijson.Field + OriginCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopAttacksResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopAttacksResponseTop0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopIndustryResponse struct { + Meta AttackLayer3TopIndustryResponseMeta `json:"meta,required"` + Top0 []AttackLayer3TopIndustryResponseTop0 `json:"top_0,required"` + JSON attackLayer3TopIndustryResponseJSON `json:"-"` +} + +// attackLayer3TopIndustryResponseJSON contains the JSON metadata for the struct +// [AttackLayer3TopIndustryResponse] +type attackLayer3TopIndustryResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopIndustryResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopIndustryResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopIndustryResponseMeta struct { + DateRange []AttackLayer3TopIndustryResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo AttackLayer3TopIndustryResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer3TopIndustryResponseMetaJSON `json:"-"` +} + +// attackLayer3TopIndustryResponseMetaJSON contains the JSON metadata for the +// struct [AttackLayer3TopIndustryResponseMeta] +type attackLayer3TopIndustryResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopIndustryResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopIndustryResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopIndustryResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer3TopIndustryResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer3TopIndustryResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [AttackLayer3TopIndustryResponseMetaDateRange] +type attackLayer3TopIndustryResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopIndustryResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopIndustryResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopIndustryResponseMetaConfidenceInfo struct { + Annotations []AttackLayer3TopIndustryResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer3TopIndustryResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer3TopIndustryResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [AttackLayer3TopIndustryResponseMetaConfidenceInfo] +type attackLayer3TopIndustryResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopIndustryResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopIndustryResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopIndustryResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer3TopIndustryResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer3TopIndustryResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [AttackLayer3TopIndustryResponseMetaConfidenceInfoAnnotation] +type attackLayer3TopIndustryResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopIndustryResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopIndustryResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopIndustryResponseTop0 struct { + Name string `json:"name,required"` + Value string `json:"value,required"` + JSON attackLayer3TopIndustryResponseTop0JSON `json:"-"` +} + +// attackLayer3TopIndustryResponseTop0JSON contains the JSON metadata for the +// struct [AttackLayer3TopIndustryResponseTop0] +type attackLayer3TopIndustryResponseTop0JSON struct { + Name apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopIndustryResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopIndustryResponseTop0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopVerticalResponse struct { + Meta AttackLayer3TopVerticalResponseMeta `json:"meta,required"` + Top0 []AttackLayer3TopVerticalResponseTop0 `json:"top_0,required"` + JSON attackLayer3TopVerticalResponseJSON `json:"-"` +} + +// attackLayer3TopVerticalResponseJSON contains the JSON metadata for the struct +// [AttackLayer3TopVerticalResponse] +type attackLayer3TopVerticalResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopVerticalResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopVerticalResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopVerticalResponseMeta struct { + DateRange []AttackLayer3TopVerticalResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo AttackLayer3TopVerticalResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer3TopVerticalResponseMetaJSON `json:"-"` +} + +// attackLayer3TopVerticalResponseMetaJSON contains the JSON metadata for the +// struct [AttackLayer3TopVerticalResponseMeta] +type attackLayer3TopVerticalResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopVerticalResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopVerticalResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopVerticalResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer3TopVerticalResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer3TopVerticalResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [AttackLayer3TopVerticalResponseMetaDateRange] +type attackLayer3TopVerticalResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopVerticalResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopVerticalResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopVerticalResponseMetaConfidenceInfo struct { + Annotations []AttackLayer3TopVerticalResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer3TopVerticalResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer3TopVerticalResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [AttackLayer3TopVerticalResponseMetaConfidenceInfo] +type attackLayer3TopVerticalResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopVerticalResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopVerticalResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopVerticalResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer3TopVerticalResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer3TopVerticalResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [AttackLayer3TopVerticalResponseMetaConfidenceInfoAnnotation] +type attackLayer3TopVerticalResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopVerticalResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopVerticalResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopVerticalResponseTop0 struct { + Name string `json:"name,required"` + Value string `json:"value,required"` + JSON attackLayer3TopVerticalResponseTop0JSON `json:"-"` +} + +// attackLayer3TopVerticalResponseTop0JSON contains the JSON metadata for the +// struct [AttackLayer3TopVerticalResponseTop0] +type attackLayer3TopVerticalResponseTop0JSON struct { + Name apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopVerticalResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopVerticalResponseTop0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopAttacksParams struct { + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3TopAttacksParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer3TopAttacksParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer3TopAttacksParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of attack origin/target location attack limits. Together with + // `limitPerLocation`, limits how many objects will be fetched per origin/target + // location. + LimitDirection param.Field[AttackLayer3TopAttacksParamsLimitDirection] `query:"limitDirection"` + // Limit the number of attacks per origin/target (refer to `limitDirection` + // parameter) location. + LimitPerLocation param.Field[int64] `query:"limitPerLocation"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Array of L3/4 attack types. + Protocol param.Field[[]AttackLayer3TopAttacksParamsProtocol] `query:"protocol"` +} + +// URLQuery serializes [AttackLayer3TopAttacksParams]'s query parameters as +// `url.Values`. +func (r AttackLayer3TopAttacksParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer3TopAttacksParamsDateRange string + +const ( + AttackLayer3TopAttacksParamsDateRange1d AttackLayer3TopAttacksParamsDateRange = "1d" + AttackLayer3TopAttacksParamsDateRange2d AttackLayer3TopAttacksParamsDateRange = "2d" + AttackLayer3TopAttacksParamsDateRange7d AttackLayer3TopAttacksParamsDateRange = "7d" + AttackLayer3TopAttacksParamsDateRange14d AttackLayer3TopAttacksParamsDateRange = "14d" + AttackLayer3TopAttacksParamsDateRange28d AttackLayer3TopAttacksParamsDateRange = "28d" + AttackLayer3TopAttacksParamsDateRange12w AttackLayer3TopAttacksParamsDateRange = "12w" + AttackLayer3TopAttacksParamsDateRange24w AttackLayer3TopAttacksParamsDateRange = "24w" + AttackLayer3TopAttacksParamsDateRange52w AttackLayer3TopAttacksParamsDateRange = "52w" + AttackLayer3TopAttacksParamsDateRange1dControl AttackLayer3TopAttacksParamsDateRange = "1dControl" + AttackLayer3TopAttacksParamsDateRange2dControl AttackLayer3TopAttacksParamsDateRange = "2dControl" + AttackLayer3TopAttacksParamsDateRange7dControl AttackLayer3TopAttacksParamsDateRange = "7dControl" + AttackLayer3TopAttacksParamsDateRange14dControl AttackLayer3TopAttacksParamsDateRange = "14dControl" + AttackLayer3TopAttacksParamsDateRange28dControl AttackLayer3TopAttacksParamsDateRange = "28dControl" + AttackLayer3TopAttacksParamsDateRange12wControl AttackLayer3TopAttacksParamsDateRange = "12wControl" + AttackLayer3TopAttacksParamsDateRange24wControl AttackLayer3TopAttacksParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer3TopAttacksParamsFormat string + +const ( + AttackLayer3TopAttacksParamsFormatJson AttackLayer3TopAttacksParamsFormat = "JSON" + AttackLayer3TopAttacksParamsFormatCsv AttackLayer3TopAttacksParamsFormat = "CSV" +) + +type AttackLayer3TopAttacksParamsIPVersion string + +const ( + AttackLayer3TopAttacksParamsIPVersionIPv4 AttackLayer3TopAttacksParamsIPVersion = "IPv4" + AttackLayer3TopAttacksParamsIPVersionIPv6 AttackLayer3TopAttacksParamsIPVersion = "IPv6" +) + +// Array of attack origin/target location attack limits. Together with +// `limitPerLocation`, limits how many objects will be fetched per origin/target +// location. +type AttackLayer3TopAttacksParamsLimitDirection string + +const ( + AttackLayer3TopAttacksParamsLimitDirectionOrigin AttackLayer3TopAttacksParamsLimitDirection = "ORIGIN" + AttackLayer3TopAttacksParamsLimitDirectionTarget AttackLayer3TopAttacksParamsLimitDirection = "TARGET" +) + +type AttackLayer3TopAttacksParamsProtocol string + +const ( + AttackLayer3TopAttacksParamsProtocolUdp AttackLayer3TopAttacksParamsProtocol = "UDP" + AttackLayer3TopAttacksParamsProtocolTcp AttackLayer3TopAttacksParamsProtocol = "TCP" + AttackLayer3TopAttacksParamsProtocolIcmp AttackLayer3TopAttacksParamsProtocol = "ICMP" + AttackLayer3TopAttacksParamsProtocolGRE AttackLayer3TopAttacksParamsProtocol = "GRE" +) + +type AttackLayer3TopAttacksResponseEnvelope struct { + Result AttackLayer3TopAttacksResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3TopAttacksResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3TopAttacksResponseEnvelopeJSON contains the JSON metadata for the +// struct [AttackLayer3TopAttacksResponseEnvelope] +type attackLayer3TopAttacksResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopAttacksResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopAttacksResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopIndustryParams struct { + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3TopIndustryParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer3TopIndustryParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer3TopIndustryParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Array of L3/4 attack types. + Protocol param.Field[[]AttackLayer3TopIndustryParamsProtocol] `query:"protocol"` +} + +// URLQuery serializes [AttackLayer3TopIndustryParams]'s query parameters as +// `url.Values`. +func (r AttackLayer3TopIndustryParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer3TopIndustryParamsDateRange string + +const ( + AttackLayer3TopIndustryParamsDateRange1d AttackLayer3TopIndustryParamsDateRange = "1d" + AttackLayer3TopIndustryParamsDateRange2d AttackLayer3TopIndustryParamsDateRange = "2d" + AttackLayer3TopIndustryParamsDateRange7d AttackLayer3TopIndustryParamsDateRange = "7d" + AttackLayer3TopIndustryParamsDateRange14d AttackLayer3TopIndustryParamsDateRange = "14d" + AttackLayer3TopIndustryParamsDateRange28d AttackLayer3TopIndustryParamsDateRange = "28d" + AttackLayer3TopIndustryParamsDateRange12w AttackLayer3TopIndustryParamsDateRange = "12w" + AttackLayer3TopIndustryParamsDateRange24w AttackLayer3TopIndustryParamsDateRange = "24w" + AttackLayer3TopIndustryParamsDateRange52w AttackLayer3TopIndustryParamsDateRange = "52w" + AttackLayer3TopIndustryParamsDateRange1dControl AttackLayer3TopIndustryParamsDateRange = "1dControl" + AttackLayer3TopIndustryParamsDateRange2dControl AttackLayer3TopIndustryParamsDateRange = "2dControl" + AttackLayer3TopIndustryParamsDateRange7dControl AttackLayer3TopIndustryParamsDateRange = "7dControl" + AttackLayer3TopIndustryParamsDateRange14dControl AttackLayer3TopIndustryParamsDateRange = "14dControl" + AttackLayer3TopIndustryParamsDateRange28dControl AttackLayer3TopIndustryParamsDateRange = "28dControl" + AttackLayer3TopIndustryParamsDateRange12wControl AttackLayer3TopIndustryParamsDateRange = "12wControl" + AttackLayer3TopIndustryParamsDateRange24wControl AttackLayer3TopIndustryParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer3TopIndustryParamsFormat string + +const ( + AttackLayer3TopIndustryParamsFormatJson AttackLayer3TopIndustryParamsFormat = "JSON" + AttackLayer3TopIndustryParamsFormatCsv AttackLayer3TopIndustryParamsFormat = "CSV" +) + +type AttackLayer3TopIndustryParamsIPVersion string + +const ( + AttackLayer3TopIndustryParamsIPVersionIPv4 AttackLayer3TopIndustryParamsIPVersion = "IPv4" + AttackLayer3TopIndustryParamsIPVersionIPv6 AttackLayer3TopIndustryParamsIPVersion = "IPv6" +) + +type AttackLayer3TopIndustryParamsProtocol string + +const ( + AttackLayer3TopIndustryParamsProtocolUdp AttackLayer3TopIndustryParamsProtocol = "UDP" + AttackLayer3TopIndustryParamsProtocolTcp AttackLayer3TopIndustryParamsProtocol = "TCP" + AttackLayer3TopIndustryParamsProtocolIcmp AttackLayer3TopIndustryParamsProtocol = "ICMP" + AttackLayer3TopIndustryParamsProtocolGRE AttackLayer3TopIndustryParamsProtocol = "GRE" +) + +type AttackLayer3TopIndustryResponseEnvelope struct { + Result AttackLayer3TopIndustryResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3TopIndustryResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3TopIndustryResponseEnvelopeJSON contains the JSON metadata for the +// struct [AttackLayer3TopIndustryResponseEnvelope] +type attackLayer3TopIndustryResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopIndustryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopIndustryResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopVerticalParams struct { + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3TopVerticalParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer3TopVerticalParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer3TopVerticalParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Array of L3/4 attack types. + Protocol param.Field[[]AttackLayer3TopVerticalParamsProtocol] `query:"protocol"` +} + +// URLQuery serializes [AttackLayer3TopVerticalParams]'s query parameters as +// `url.Values`. +func (r AttackLayer3TopVerticalParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer3TopVerticalParamsDateRange string + +const ( + AttackLayer3TopVerticalParamsDateRange1d AttackLayer3TopVerticalParamsDateRange = "1d" + AttackLayer3TopVerticalParamsDateRange2d AttackLayer3TopVerticalParamsDateRange = "2d" + AttackLayer3TopVerticalParamsDateRange7d AttackLayer3TopVerticalParamsDateRange = "7d" + AttackLayer3TopVerticalParamsDateRange14d AttackLayer3TopVerticalParamsDateRange = "14d" + AttackLayer3TopVerticalParamsDateRange28d AttackLayer3TopVerticalParamsDateRange = "28d" + AttackLayer3TopVerticalParamsDateRange12w AttackLayer3TopVerticalParamsDateRange = "12w" + AttackLayer3TopVerticalParamsDateRange24w AttackLayer3TopVerticalParamsDateRange = "24w" + AttackLayer3TopVerticalParamsDateRange52w AttackLayer3TopVerticalParamsDateRange = "52w" + AttackLayer3TopVerticalParamsDateRange1dControl AttackLayer3TopVerticalParamsDateRange = "1dControl" + AttackLayer3TopVerticalParamsDateRange2dControl AttackLayer3TopVerticalParamsDateRange = "2dControl" + AttackLayer3TopVerticalParamsDateRange7dControl AttackLayer3TopVerticalParamsDateRange = "7dControl" + AttackLayer3TopVerticalParamsDateRange14dControl AttackLayer3TopVerticalParamsDateRange = "14dControl" + AttackLayer3TopVerticalParamsDateRange28dControl AttackLayer3TopVerticalParamsDateRange = "28dControl" + AttackLayer3TopVerticalParamsDateRange12wControl AttackLayer3TopVerticalParamsDateRange = "12wControl" + AttackLayer3TopVerticalParamsDateRange24wControl AttackLayer3TopVerticalParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer3TopVerticalParamsFormat string + +const ( + AttackLayer3TopVerticalParamsFormatJson AttackLayer3TopVerticalParamsFormat = "JSON" + AttackLayer3TopVerticalParamsFormatCsv AttackLayer3TopVerticalParamsFormat = "CSV" +) + +type AttackLayer3TopVerticalParamsIPVersion string + +const ( + AttackLayer3TopVerticalParamsIPVersionIPv4 AttackLayer3TopVerticalParamsIPVersion = "IPv4" + AttackLayer3TopVerticalParamsIPVersionIPv6 AttackLayer3TopVerticalParamsIPVersion = "IPv6" +) + +type AttackLayer3TopVerticalParamsProtocol string + +const ( + AttackLayer3TopVerticalParamsProtocolUdp AttackLayer3TopVerticalParamsProtocol = "UDP" + AttackLayer3TopVerticalParamsProtocolTcp AttackLayer3TopVerticalParamsProtocol = "TCP" + AttackLayer3TopVerticalParamsProtocolIcmp AttackLayer3TopVerticalParamsProtocol = "ICMP" + AttackLayer3TopVerticalParamsProtocolGRE AttackLayer3TopVerticalParamsProtocol = "GRE" +) + +type AttackLayer3TopVerticalResponseEnvelope struct { + Result AttackLayer3TopVerticalResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3TopVerticalResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3TopVerticalResponseEnvelopeJSON contains the JSON metadata for the +// struct [AttackLayer3TopVerticalResponseEnvelope] +type attackLayer3TopVerticalResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopVerticalResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopVerticalResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/attacklayer3top_test.go b/radar/attacklayer3top_test.go new file mode 100644 index 00000000000..ece75af4187 --- /dev/null +++ b/radar/attacklayer3top_test.go @@ -0,0 +1,123 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestAttackLayer3TopAttacksWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.Top.Attacks(context.TODO(), radar.AttackLayer3TopAttacksParams{ + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3TopAttacksParamsDateRange{radar.AttackLayer3TopAttacksParamsDateRange1d, radar.AttackLayer3TopAttacksParamsDateRange2d, radar.AttackLayer3TopAttacksParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer3TopAttacksParamsFormatJson), + IPVersion: cloudflare.F([]radar.AttackLayer3TopAttacksParamsIPVersion{radar.AttackLayer3TopAttacksParamsIPVersionIPv4, radar.AttackLayer3TopAttacksParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + LimitDirection: cloudflare.F(radar.AttackLayer3TopAttacksParamsLimitDirectionOrigin), + LimitPerLocation: cloudflare.F(int64(10)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Protocol: cloudflare.F([]radar.AttackLayer3TopAttacksParamsProtocol{radar.AttackLayer3TopAttacksParamsProtocolUdp, radar.AttackLayer3TopAttacksParamsProtocolTcp, radar.AttackLayer3TopAttacksParamsProtocolIcmp}), + }) + 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 TestAttackLayer3TopIndustryWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.Top.Industry(context.TODO(), radar.AttackLayer3TopIndustryParams{ + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3TopIndustryParamsDateRange{radar.AttackLayer3TopIndustryParamsDateRange1d, radar.AttackLayer3TopIndustryParamsDateRange2d, radar.AttackLayer3TopIndustryParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer3TopIndustryParamsFormatJson), + IPVersion: cloudflare.F([]radar.AttackLayer3TopIndustryParamsIPVersion{radar.AttackLayer3TopIndustryParamsIPVersionIPv4, radar.AttackLayer3TopIndustryParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Protocol: cloudflare.F([]radar.AttackLayer3TopIndustryParamsProtocol{radar.AttackLayer3TopIndustryParamsProtocolUdp, radar.AttackLayer3TopIndustryParamsProtocolTcp, radar.AttackLayer3TopIndustryParamsProtocolIcmp}), + }) + 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 TestAttackLayer3TopVerticalWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.Top.Vertical(context.TODO(), radar.AttackLayer3TopVerticalParams{ + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3TopVerticalParamsDateRange{radar.AttackLayer3TopVerticalParamsDateRange1d, radar.AttackLayer3TopVerticalParamsDateRange2d, radar.AttackLayer3TopVerticalParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer3TopVerticalParamsFormatJson), + IPVersion: cloudflare.F([]radar.AttackLayer3TopVerticalParamsIPVersion{radar.AttackLayer3TopVerticalParamsIPVersionIPv4, radar.AttackLayer3TopVerticalParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Protocol: cloudflare.F([]radar.AttackLayer3TopVerticalParamsProtocol{radar.AttackLayer3TopVerticalParamsProtocolUdp, radar.AttackLayer3TopVerticalParamsProtocolTcp, radar.AttackLayer3TopVerticalParamsProtocolIcmp}), + }) + 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/radar/attacklayer3toplocation.go b/radar/attacklayer3toplocation.go new file mode 100644 index 00000000000..0bc886e53ad --- /dev/null +++ b/radar/attacklayer3toplocation.go @@ -0,0 +1,586 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AttackLayer3TopLocationService 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 +// [NewAttackLayer3TopLocationService] method instead. +type AttackLayer3TopLocationService struct { + Options []option.RequestOption +} + +// NewAttackLayer3TopLocationService 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 NewAttackLayer3TopLocationService(opts ...option.RequestOption) (r *AttackLayer3TopLocationService) { + r = &AttackLayer3TopLocationService{} + r.Options = opts + return +} + +// Get the origin locations of attacks. +func (r *AttackLayer3TopLocationService) Origin(ctx context.Context, query AttackLayer3TopLocationOriginParams, opts ...option.RequestOption) (res *AttackLayer3TopLocationOriginResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3TopLocationOriginResponseEnvelope + path := "radar/attacks/layer3/top/locations/origin" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the target locations of attacks. +func (r *AttackLayer3TopLocationService) Target(ctx context.Context, query AttackLayer3TopLocationTargetParams, opts ...option.RequestOption) (res *AttackLayer3TopLocationTargetResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer3TopLocationTargetResponseEnvelope + path := "radar/attacks/layer3/top/locations/target" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AttackLayer3TopLocationOriginResponse struct { + Meta AttackLayer3TopLocationOriginResponseMeta `json:"meta,required"` + Top0 []AttackLayer3TopLocationOriginResponseTop0 `json:"top_0,required"` + JSON attackLayer3TopLocationOriginResponseJSON `json:"-"` +} + +// attackLayer3TopLocationOriginResponseJSON contains the JSON metadata for the +// struct [AttackLayer3TopLocationOriginResponse] +type attackLayer3TopLocationOriginResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopLocationOriginResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopLocationOriginResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopLocationOriginResponseMeta struct { + DateRange []AttackLayer3TopLocationOriginResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo AttackLayer3TopLocationOriginResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer3TopLocationOriginResponseMetaJSON `json:"-"` +} + +// attackLayer3TopLocationOriginResponseMetaJSON contains the JSON metadata for the +// struct [AttackLayer3TopLocationOriginResponseMeta] +type attackLayer3TopLocationOriginResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopLocationOriginResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopLocationOriginResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopLocationOriginResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer3TopLocationOriginResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer3TopLocationOriginResponseMetaDateRangeJSON contains the JSON +// metadata for the struct [AttackLayer3TopLocationOriginResponseMetaDateRange] +type attackLayer3TopLocationOriginResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopLocationOriginResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopLocationOriginResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopLocationOriginResponseMetaConfidenceInfo struct { + Annotations []AttackLayer3TopLocationOriginResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer3TopLocationOriginResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer3TopLocationOriginResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct +// [AttackLayer3TopLocationOriginResponseMetaConfidenceInfo] +type attackLayer3TopLocationOriginResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopLocationOriginResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopLocationOriginResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopLocationOriginResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer3TopLocationOriginResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer3TopLocationOriginResponseMetaConfidenceInfoAnnotationJSON contains +// the JSON metadata for the struct +// [AttackLayer3TopLocationOriginResponseMetaConfidenceInfoAnnotation] +type attackLayer3TopLocationOriginResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopLocationOriginResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopLocationOriginResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopLocationOriginResponseTop0 struct { + OriginCountryAlpha2 string `json:"originCountryAlpha2,required"` + OriginCountryName string `json:"originCountryName,required"` + Rank float64 `json:"rank,required"` + Value string `json:"value,required"` + JSON attackLayer3TopLocationOriginResponseTop0JSON `json:"-"` +} + +// attackLayer3TopLocationOriginResponseTop0JSON contains the JSON metadata for the +// struct [AttackLayer3TopLocationOriginResponseTop0] +type attackLayer3TopLocationOriginResponseTop0JSON struct { + OriginCountryAlpha2 apijson.Field + OriginCountryName apijson.Field + Rank apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopLocationOriginResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopLocationOriginResponseTop0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopLocationTargetResponse struct { + Meta AttackLayer3TopLocationTargetResponseMeta `json:"meta,required"` + Top0 []AttackLayer3TopLocationTargetResponseTop0 `json:"top_0,required"` + JSON attackLayer3TopLocationTargetResponseJSON `json:"-"` +} + +// attackLayer3TopLocationTargetResponseJSON contains the JSON metadata for the +// struct [AttackLayer3TopLocationTargetResponse] +type attackLayer3TopLocationTargetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopLocationTargetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopLocationTargetResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopLocationTargetResponseMeta struct { + DateRange []AttackLayer3TopLocationTargetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo AttackLayer3TopLocationTargetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer3TopLocationTargetResponseMetaJSON `json:"-"` +} + +// attackLayer3TopLocationTargetResponseMetaJSON contains the JSON metadata for the +// struct [AttackLayer3TopLocationTargetResponseMeta] +type attackLayer3TopLocationTargetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopLocationTargetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopLocationTargetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopLocationTargetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer3TopLocationTargetResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer3TopLocationTargetResponseMetaDateRangeJSON contains the JSON +// metadata for the struct [AttackLayer3TopLocationTargetResponseMetaDateRange] +type attackLayer3TopLocationTargetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopLocationTargetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopLocationTargetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopLocationTargetResponseMetaConfidenceInfo struct { + Annotations []AttackLayer3TopLocationTargetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer3TopLocationTargetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer3TopLocationTargetResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct +// [AttackLayer3TopLocationTargetResponseMetaConfidenceInfo] +type attackLayer3TopLocationTargetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopLocationTargetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopLocationTargetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopLocationTargetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer3TopLocationTargetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer3TopLocationTargetResponseMetaConfidenceInfoAnnotationJSON contains +// the JSON metadata for the struct +// [AttackLayer3TopLocationTargetResponseMetaConfidenceInfoAnnotation] +type attackLayer3TopLocationTargetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopLocationTargetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopLocationTargetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopLocationTargetResponseTop0 struct { + Rank float64 `json:"rank,required"` + TargetCountryAlpha2 string `json:"targetCountryAlpha2,required"` + TargetCountryName string `json:"targetCountryName,required"` + Value string `json:"value,required"` + JSON attackLayer3TopLocationTargetResponseTop0JSON `json:"-"` +} + +// attackLayer3TopLocationTargetResponseTop0JSON contains the JSON metadata for the +// struct [AttackLayer3TopLocationTargetResponseTop0] +type attackLayer3TopLocationTargetResponseTop0JSON struct { + Rank apijson.Field + TargetCountryAlpha2 apijson.Field + TargetCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopLocationTargetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopLocationTargetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopLocationOriginParams struct { + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3TopLocationOriginParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer3TopLocationOriginParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer3TopLocationOriginParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Array of L3/4 attack types. + Protocol param.Field[[]AttackLayer3TopLocationOriginParamsProtocol] `query:"protocol"` +} + +// URLQuery serializes [AttackLayer3TopLocationOriginParams]'s query parameters as +// `url.Values`. +func (r AttackLayer3TopLocationOriginParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer3TopLocationOriginParamsDateRange string + +const ( + AttackLayer3TopLocationOriginParamsDateRange1d AttackLayer3TopLocationOriginParamsDateRange = "1d" + AttackLayer3TopLocationOriginParamsDateRange2d AttackLayer3TopLocationOriginParamsDateRange = "2d" + AttackLayer3TopLocationOriginParamsDateRange7d AttackLayer3TopLocationOriginParamsDateRange = "7d" + AttackLayer3TopLocationOriginParamsDateRange14d AttackLayer3TopLocationOriginParamsDateRange = "14d" + AttackLayer3TopLocationOriginParamsDateRange28d AttackLayer3TopLocationOriginParamsDateRange = "28d" + AttackLayer3TopLocationOriginParamsDateRange12w AttackLayer3TopLocationOriginParamsDateRange = "12w" + AttackLayer3TopLocationOriginParamsDateRange24w AttackLayer3TopLocationOriginParamsDateRange = "24w" + AttackLayer3TopLocationOriginParamsDateRange52w AttackLayer3TopLocationOriginParamsDateRange = "52w" + AttackLayer3TopLocationOriginParamsDateRange1dControl AttackLayer3TopLocationOriginParamsDateRange = "1dControl" + AttackLayer3TopLocationOriginParamsDateRange2dControl AttackLayer3TopLocationOriginParamsDateRange = "2dControl" + AttackLayer3TopLocationOriginParamsDateRange7dControl AttackLayer3TopLocationOriginParamsDateRange = "7dControl" + AttackLayer3TopLocationOriginParamsDateRange14dControl AttackLayer3TopLocationOriginParamsDateRange = "14dControl" + AttackLayer3TopLocationOriginParamsDateRange28dControl AttackLayer3TopLocationOriginParamsDateRange = "28dControl" + AttackLayer3TopLocationOriginParamsDateRange12wControl AttackLayer3TopLocationOriginParamsDateRange = "12wControl" + AttackLayer3TopLocationOriginParamsDateRange24wControl AttackLayer3TopLocationOriginParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer3TopLocationOriginParamsFormat string + +const ( + AttackLayer3TopLocationOriginParamsFormatJson AttackLayer3TopLocationOriginParamsFormat = "JSON" + AttackLayer3TopLocationOriginParamsFormatCsv AttackLayer3TopLocationOriginParamsFormat = "CSV" +) + +type AttackLayer3TopLocationOriginParamsIPVersion string + +const ( + AttackLayer3TopLocationOriginParamsIPVersionIPv4 AttackLayer3TopLocationOriginParamsIPVersion = "IPv4" + AttackLayer3TopLocationOriginParamsIPVersionIPv6 AttackLayer3TopLocationOriginParamsIPVersion = "IPv6" +) + +type AttackLayer3TopLocationOriginParamsProtocol string + +const ( + AttackLayer3TopLocationOriginParamsProtocolUdp AttackLayer3TopLocationOriginParamsProtocol = "UDP" + AttackLayer3TopLocationOriginParamsProtocolTcp AttackLayer3TopLocationOriginParamsProtocol = "TCP" + AttackLayer3TopLocationOriginParamsProtocolIcmp AttackLayer3TopLocationOriginParamsProtocol = "ICMP" + AttackLayer3TopLocationOriginParamsProtocolGRE AttackLayer3TopLocationOriginParamsProtocol = "GRE" +) + +type AttackLayer3TopLocationOriginResponseEnvelope struct { + Result AttackLayer3TopLocationOriginResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3TopLocationOriginResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3TopLocationOriginResponseEnvelopeJSON contains the JSON metadata for +// the struct [AttackLayer3TopLocationOriginResponseEnvelope] +type attackLayer3TopLocationOriginResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopLocationOriginResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopLocationOriginResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer3TopLocationTargetParams struct { + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer3TopLocationTargetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer3TopLocationTargetParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer3TopLocationTargetParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Array of L3/4 attack types. + Protocol param.Field[[]AttackLayer3TopLocationTargetParamsProtocol] `query:"protocol"` +} + +// URLQuery serializes [AttackLayer3TopLocationTargetParams]'s query parameters as +// `url.Values`. +func (r AttackLayer3TopLocationTargetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer3TopLocationTargetParamsDateRange string + +const ( + AttackLayer3TopLocationTargetParamsDateRange1d AttackLayer3TopLocationTargetParamsDateRange = "1d" + AttackLayer3TopLocationTargetParamsDateRange2d AttackLayer3TopLocationTargetParamsDateRange = "2d" + AttackLayer3TopLocationTargetParamsDateRange7d AttackLayer3TopLocationTargetParamsDateRange = "7d" + AttackLayer3TopLocationTargetParamsDateRange14d AttackLayer3TopLocationTargetParamsDateRange = "14d" + AttackLayer3TopLocationTargetParamsDateRange28d AttackLayer3TopLocationTargetParamsDateRange = "28d" + AttackLayer3TopLocationTargetParamsDateRange12w AttackLayer3TopLocationTargetParamsDateRange = "12w" + AttackLayer3TopLocationTargetParamsDateRange24w AttackLayer3TopLocationTargetParamsDateRange = "24w" + AttackLayer3TopLocationTargetParamsDateRange52w AttackLayer3TopLocationTargetParamsDateRange = "52w" + AttackLayer3TopLocationTargetParamsDateRange1dControl AttackLayer3TopLocationTargetParamsDateRange = "1dControl" + AttackLayer3TopLocationTargetParamsDateRange2dControl AttackLayer3TopLocationTargetParamsDateRange = "2dControl" + AttackLayer3TopLocationTargetParamsDateRange7dControl AttackLayer3TopLocationTargetParamsDateRange = "7dControl" + AttackLayer3TopLocationTargetParamsDateRange14dControl AttackLayer3TopLocationTargetParamsDateRange = "14dControl" + AttackLayer3TopLocationTargetParamsDateRange28dControl AttackLayer3TopLocationTargetParamsDateRange = "28dControl" + AttackLayer3TopLocationTargetParamsDateRange12wControl AttackLayer3TopLocationTargetParamsDateRange = "12wControl" + AttackLayer3TopLocationTargetParamsDateRange24wControl AttackLayer3TopLocationTargetParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer3TopLocationTargetParamsFormat string + +const ( + AttackLayer3TopLocationTargetParamsFormatJson AttackLayer3TopLocationTargetParamsFormat = "JSON" + AttackLayer3TopLocationTargetParamsFormatCsv AttackLayer3TopLocationTargetParamsFormat = "CSV" +) + +type AttackLayer3TopLocationTargetParamsIPVersion string + +const ( + AttackLayer3TopLocationTargetParamsIPVersionIPv4 AttackLayer3TopLocationTargetParamsIPVersion = "IPv4" + AttackLayer3TopLocationTargetParamsIPVersionIPv6 AttackLayer3TopLocationTargetParamsIPVersion = "IPv6" +) + +type AttackLayer3TopLocationTargetParamsProtocol string + +const ( + AttackLayer3TopLocationTargetParamsProtocolUdp AttackLayer3TopLocationTargetParamsProtocol = "UDP" + AttackLayer3TopLocationTargetParamsProtocolTcp AttackLayer3TopLocationTargetParamsProtocol = "TCP" + AttackLayer3TopLocationTargetParamsProtocolIcmp AttackLayer3TopLocationTargetParamsProtocol = "ICMP" + AttackLayer3TopLocationTargetParamsProtocolGRE AttackLayer3TopLocationTargetParamsProtocol = "GRE" +) + +type AttackLayer3TopLocationTargetResponseEnvelope struct { + Result AttackLayer3TopLocationTargetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer3TopLocationTargetResponseEnvelopeJSON `json:"-"` +} + +// attackLayer3TopLocationTargetResponseEnvelopeJSON contains the JSON metadata for +// the struct [AttackLayer3TopLocationTargetResponseEnvelope] +type attackLayer3TopLocationTargetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer3TopLocationTargetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer3TopLocationTargetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/attacklayer3toplocation_test.go b/radar/attacklayer3toplocation_test.go new file mode 100644 index 00000000000..c3d95d66974 --- /dev/null +++ b/radar/attacklayer3toplocation_test.go @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestAttackLayer3TopLocationOriginWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.Top.Locations.Origin(context.TODO(), radar.AttackLayer3TopLocationOriginParams{ + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3TopLocationOriginParamsDateRange{radar.AttackLayer3TopLocationOriginParamsDateRange1d, radar.AttackLayer3TopLocationOriginParamsDateRange2d, radar.AttackLayer3TopLocationOriginParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer3TopLocationOriginParamsFormatJson), + IPVersion: cloudflare.F([]radar.AttackLayer3TopLocationOriginParamsIPVersion{radar.AttackLayer3TopLocationOriginParamsIPVersionIPv4, radar.AttackLayer3TopLocationOriginParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Protocol: cloudflare.F([]radar.AttackLayer3TopLocationOriginParamsProtocol{radar.AttackLayer3TopLocationOriginParamsProtocolUdp, radar.AttackLayer3TopLocationOriginParamsProtocolTcp, radar.AttackLayer3TopLocationOriginParamsProtocolIcmp}), + }) + 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 TestAttackLayer3TopLocationTargetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer3.Top.Locations.Target(context.TODO(), radar.AttackLayer3TopLocationTargetParams{ + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer3TopLocationTargetParamsDateRange{radar.AttackLayer3TopLocationTargetParamsDateRange1d, radar.AttackLayer3TopLocationTargetParamsDateRange2d, radar.AttackLayer3TopLocationTargetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer3TopLocationTargetParamsFormatJson), + IPVersion: cloudflare.F([]radar.AttackLayer3TopLocationTargetParamsIPVersion{radar.AttackLayer3TopLocationTargetParamsIPVersionIPv4, radar.AttackLayer3TopLocationTargetParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Protocol: cloudflare.F([]radar.AttackLayer3TopLocationTargetParamsProtocol{radar.AttackLayer3TopLocationTargetParamsProtocolUdp, radar.AttackLayer3TopLocationTargetParamsProtocolTcp, radar.AttackLayer3TopLocationTargetParamsProtocolIcmp}), + }) + 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/radar/attacklayer7.go b/radar/attacklayer7.go new file mode 100644 index 00000000000..d4a6a0abdab --- /dev/null +++ b/radar/attacklayer7.go @@ -0,0 +1,338 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AttackLayer7Service 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 [NewAttackLayer7Service] method +// instead. +type AttackLayer7Service struct { + Options []option.RequestOption + Summary *AttackLayer7SummaryService + TimeseriesGroups *AttackLayer7TimeseriesGroupService + Top *AttackLayer7TopService +} + +// NewAttackLayer7Service 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 NewAttackLayer7Service(opts ...option.RequestOption) (r *AttackLayer7Service) { + r = &AttackLayer7Service{} + r.Options = opts + r.Summary = NewAttackLayer7SummaryService(opts...) + r.TimeseriesGroups = NewAttackLayer7TimeseriesGroupService(opts...) + r.Top = NewAttackLayer7TopService(opts...) + return +} + +// Get a timeseries of Layer 7 attacks. Values represent HTTP requests and are +// normalized using min-max by default. +func (r *AttackLayer7Service) Timeseries(ctx context.Context, query AttackLayer7TimeseriesParams, opts ...option.RequestOption) (res *AttackLayer7TimeseriesResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7TimeseriesResponseEnvelope + path := "radar/attacks/layer7/timeseries" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AttackLayer7TimeseriesResponse struct { + Meta AttackLayer7TimeseriesResponseMeta `json:"meta,required"` + Serie0 AttackLayer7TimeseriesResponseSerie0 `json:"serie_0,required"` + JSON attackLayer7TimeseriesResponseJSON `json:"-"` +} + +// attackLayer7TimeseriesResponseJSON contains the JSON metadata for the struct +// [AttackLayer7TimeseriesResponse] +type attackLayer7TimeseriesResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesResponseMeta struct { + AggInterval string `json:"aggInterval,required"` + DateRange []AttackLayer7TimeseriesResponseMetaDateRange `json:"dateRange,required"` + LastUpdated time.Time `json:"lastUpdated,required" format:"date-time"` + ConfidenceInfo AttackLayer7TimeseriesResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer7TimeseriesResponseMetaJSON `json:"-"` +} + +// attackLayer7TimeseriesResponseMetaJSON contains the JSON metadata for the struct +// [AttackLayer7TimeseriesResponseMeta] +type attackLayer7TimeseriesResponseMetaJSON struct { + AggInterval apijson.Field + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer7TimeseriesResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer7TimeseriesResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [AttackLayer7TimeseriesResponseMetaDateRange] +type attackLayer7TimeseriesResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesResponseMetaConfidenceInfo struct { + Annotations []AttackLayer7TimeseriesResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer7TimeseriesResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer7TimeseriesResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [AttackLayer7TimeseriesResponseMetaConfidenceInfo] +type attackLayer7TimeseriesResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer7TimeseriesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer7TimeseriesResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [AttackLayer7TimeseriesResponseMetaConfidenceInfoAnnotation] +type attackLayer7TimeseriesResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesResponseSerie0 struct { + Timestamps []time.Time `json:"timestamps,required" format:"date-time"` + Values []string `json:"values,required"` + JSON attackLayer7TimeseriesResponseSerie0JSON `json:"-"` +} + +// attackLayer7TimeseriesResponseSerie0JSON contains the JSON metadata for the +// struct [AttackLayer7TimeseriesResponseSerie0] +type attackLayer7TimeseriesResponseSerie0JSON struct { + Timestamps apijson.Field + Values apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AttackLayer7TimeseriesParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of L7 attack types. + Attack param.Field[[]AttackLayer7TimeseriesParamsAttack] `query:"attack"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7TimeseriesParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7TimeseriesParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Normalization method applied. Refer to + // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + Normalization param.Field[AttackLayer7TimeseriesParamsNormalization] `query:"normalization"` +} + +// URLQuery serializes [AttackLayer7TimeseriesParams]'s query parameters as +// `url.Values`. +func (r AttackLayer7TimeseriesParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AttackLayer7TimeseriesParamsAggInterval string + +const ( + AttackLayer7TimeseriesParamsAggInterval15m AttackLayer7TimeseriesParamsAggInterval = "15m" + AttackLayer7TimeseriesParamsAggInterval1h AttackLayer7TimeseriesParamsAggInterval = "1h" + AttackLayer7TimeseriesParamsAggInterval1d AttackLayer7TimeseriesParamsAggInterval = "1d" + AttackLayer7TimeseriesParamsAggInterval1w AttackLayer7TimeseriesParamsAggInterval = "1w" +) + +type AttackLayer7TimeseriesParamsAttack string + +const ( + AttackLayer7TimeseriesParamsAttackDDOS AttackLayer7TimeseriesParamsAttack = "DDOS" + AttackLayer7TimeseriesParamsAttackWAF AttackLayer7TimeseriesParamsAttack = "WAF" + AttackLayer7TimeseriesParamsAttackBotManagement AttackLayer7TimeseriesParamsAttack = "BOT_MANAGEMENT" + AttackLayer7TimeseriesParamsAttackAccessRules AttackLayer7TimeseriesParamsAttack = "ACCESS_RULES" + AttackLayer7TimeseriesParamsAttackIPReputation AttackLayer7TimeseriesParamsAttack = "IP_REPUTATION" + AttackLayer7TimeseriesParamsAttackAPIShield AttackLayer7TimeseriesParamsAttack = "API_SHIELD" + AttackLayer7TimeseriesParamsAttackDataLossPrevention AttackLayer7TimeseriesParamsAttack = "DATA_LOSS_PREVENTION" +) + +type AttackLayer7TimeseriesParamsDateRange string + +const ( + AttackLayer7TimeseriesParamsDateRange1d AttackLayer7TimeseriesParamsDateRange = "1d" + AttackLayer7TimeseriesParamsDateRange2d AttackLayer7TimeseriesParamsDateRange = "2d" + AttackLayer7TimeseriesParamsDateRange7d AttackLayer7TimeseriesParamsDateRange = "7d" + AttackLayer7TimeseriesParamsDateRange14d AttackLayer7TimeseriesParamsDateRange = "14d" + AttackLayer7TimeseriesParamsDateRange28d AttackLayer7TimeseriesParamsDateRange = "28d" + AttackLayer7TimeseriesParamsDateRange12w AttackLayer7TimeseriesParamsDateRange = "12w" + AttackLayer7TimeseriesParamsDateRange24w AttackLayer7TimeseriesParamsDateRange = "24w" + AttackLayer7TimeseriesParamsDateRange52w AttackLayer7TimeseriesParamsDateRange = "52w" + AttackLayer7TimeseriesParamsDateRange1dControl AttackLayer7TimeseriesParamsDateRange = "1dControl" + AttackLayer7TimeseriesParamsDateRange2dControl AttackLayer7TimeseriesParamsDateRange = "2dControl" + AttackLayer7TimeseriesParamsDateRange7dControl AttackLayer7TimeseriesParamsDateRange = "7dControl" + AttackLayer7TimeseriesParamsDateRange14dControl AttackLayer7TimeseriesParamsDateRange = "14dControl" + AttackLayer7TimeseriesParamsDateRange28dControl AttackLayer7TimeseriesParamsDateRange = "28dControl" + AttackLayer7TimeseriesParamsDateRange12wControl AttackLayer7TimeseriesParamsDateRange = "12wControl" + AttackLayer7TimeseriesParamsDateRange24wControl AttackLayer7TimeseriesParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7TimeseriesParamsFormat string + +const ( + AttackLayer7TimeseriesParamsFormatJson AttackLayer7TimeseriesParamsFormat = "JSON" + AttackLayer7TimeseriesParamsFormatCsv AttackLayer7TimeseriesParamsFormat = "CSV" +) + +// Normalization method applied. Refer to +// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). +type AttackLayer7TimeseriesParamsNormalization string + +const ( + AttackLayer7TimeseriesParamsNormalizationPercentageChange AttackLayer7TimeseriesParamsNormalization = "PERCENTAGE_CHANGE" + AttackLayer7TimeseriesParamsNormalizationMin0Max AttackLayer7TimeseriesParamsNormalization = "MIN0_MAX" +) + +type AttackLayer7TimeseriesResponseEnvelope struct { + Result AttackLayer7TimeseriesResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7TimeseriesResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7TimeseriesResponseEnvelopeJSON contains the JSON metadata for the +// struct [AttackLayer7TimeseriesResponseEnvelope] +type attackLayer7TimeseriesResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/attacklayer7_test.go b/radar/attacklayer7_test.go new file mode 100644 index 00000000000..6b850ca49d1 --- /dev/null +++ b/radar/attacklayer7_test.go @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestAttackLayer7TimeseriesWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.Timeseries(context.TODO(), radar.AttackLayer7TimeseriesParams{ + AggInterval: cloudflare.F(radar.AttackLayer7TimeseriesParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Attack: cloudflare.F([]radar.AttackLayer7TimeseriesParamsAttack{radar.AttackLayer7TimeseriesParamsAttackDDOS, radar.AttackLayer7TimeseriesParamsAttackWAF, radar.AttackLayer7TimeseriesParamsAttackBotManagement}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7TimeseriesParamsDateRange{radar.AttackLayer7TimeseriesParamsDateRange1d, radar.AttackLayer7TimeseriesParamsDateRange2d, radar.AttackLayer7TimeseriesParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7TimeseriesParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Normalization: cloudflare.F(radar.AttackLayer7TimeseriesParamsNormalizationMin0Max), + }) + 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/radar/attacklayer7summary.go b/radar/attacklayer7summary.go new file mode 100644 index 00000000000..40ebcd5734d --- /dev/null +++ b/radar/attacklayer7summary.go @@ -0,0 +1,1921 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AttackLayer7SummaryService 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 [NewAttackLayer7SummaryService] +// method instead. +type AttackLayer7SummaryService struct { + Options []option.RequestOption +} + +// NewAttackLayer7SummaryService 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 NewAttackLayer7SummaryService(opts ...option.RequestOption) (r *AttackLayer7SummaryService) { + r = &AttackLayer7SummaryService{} + r.Options = opts + return +} + +// Percentage distribution of mitigation techniques in Layer 7 attacks. +func (r *AttackLayer7SummaryService) Get(ctx context.Context, query AttackLayer7SummaryGetParams, opts ...option.RequestOption) (res *AttackLayer7SummaryGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7SummaryGetResponseEnvelope + path := "radar/attacks/layer7/summary" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by http method used. +func (r *AttackLayer7SummaryService) HTTPMethod(ctx context.Context, query AttackLayer7SummaryHTTPMethodParams, opts ...option.RequestOption) (res *AttackLayer7SummaryHTTPMethodResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7SummaryHTTPMethodResponseEnvelope + path := "radar/attacks/layer7/summary/http_method" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by http version used. +func (r *AttackLayer7SummaryService) HTTPVersion(ctx context.Context, query AttackLayer7SummaryHTTPVersionParams, opts ...option.RequestOption) (res *AttackLayer7SummaryHTTPVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7SummaryHTTPVersionResponseEnvelope + path := "radar/attacks/layer7/summary/http_version" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by ip version used. +func (r *AttackLayer7SummaryService) IPVersion(ctx context.Context, query AttackLayer7SummaryIPVersionParams, opts ...option.RequestOption) (res *AttackLayer7SummaryIPVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7SummaryIPVersionResponseEnvelope + path := "radar/attacks/layer7/summary/ip_version" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by managed rules used. +func (r *AttackLayer7SummaryService) ManagedRules(ctx context.Context, query AttackLayer7SummaryManagedRulesParams, opts ...option.RequestOption) (res *AttackLayer7SummaryManagedRulesResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7SummaryManagedRulesResponseEnvelope + path := "radar/attacks/layer7/summary/managed_rules" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by mitigation product used. +func (r *AttackLayer7SummaryService) MitigationProduct(ctx context.Context, query AttackLayer7SummaryMitigationProductParams, opts ...option.RequestOption) (res *AttackLayer7SummaryMitigationProductResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7SummaryMitigationProductResponseEnvelope + path := "radar/attacks/layer7/summary/mitigation_product" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AttackLayer7SummaryGetResponse struct { + Meta AttackLayer7SummaryGetResponseMeta `json:"meta,required"` + Summary0 AttackLayer7SummaryGetResponseSummary0 `json:"summary_0,required"` + JSON attackLayer7SummaryGetResponseJSON `json:"-"` +} + +// attackLayer7SummaryGetResponseJSON contains the JSON metadata for the struct +// [AttackLayer7SummaryGetResponse] +type attackLayer7SummaryGetResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryGetResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryGetResponseMeta struct { + DateRange []AttackLayer7SummaryGetResponseMetaDateRange `json:"dateRange,required"` + ConfidenceInfo AttackLayer7SummaryGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer7SummaryGetResponseMetaJSON `json:"-"` +} + +// attackLayer7SummaryGetResponseMetaJSON contains the JSON metadata for the struct +// [AttackLayer7SummaryGetResponseMeta] +type attackLayer7SummaryGetResponseMetaJSON struct { + DateRange apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer7SummaryGetResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer7SummaryGetResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [AttackLayer7SummaryGetResponseMetaDateRange] +type attackLayer7SummaryGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryGetResponseMetaConfidenceInfo struct { + Annotations []AttackLayer7SummaryGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer7SummaryGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer7SummaryGetResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [AttackLayer7SummaryGetResponseMetaConfidenceInfo] +type attackLayer7SummaryGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer7SummaryGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer7SummaryGetResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [AttackLayer7SummaryGetResponseMetaConfidenceInfoAnnotation] +type attackLayer7SummaryGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryGetResponseSummary0 struct { + AccessRules string `json:"ACCESS_RULES,required"` + APIShield string `json:"API_SHIELD,required"` + BotManagement string `json:"BOT_MANAGEMENT,required"` + DataLossPrevention string `json:"DATA_LOSS_PREVENTION,required"` + DDOS string `json:"DDOS,required"` + IPReputation string `json:"IP_REPUTATION,required"` + WAF string `json:"WAF,required"` + JSON attackLayer7SummaryGetResponseSummary0JSON `json:"-"` +} + +// attackLayer7SummaryGetResponseSummary0JSON contains the JSON metadata for the +// struct [AttackLayer7SummaryGetResponseSummary0] +type attackLayer7SummaryGetResponseSummary0JSON struct { + AccessRules apijson.Field + APIShield apijson.Field + BotManagement apijson.Field + DataLossPrevention apijson.Field + DDOS apijson.Field + IPReputation apijson.Field + WAF apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryGetResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryGetResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryHTTPMethodResponse struct { + Meta AttackLayer7SummaryHTTPMethodResponseMeta `json:"meta,required"` + Summary0 AttackLayer7SummaryHTTPMethodResponseSummary0 `json:"summary_0,required"` + JSON attackLayer7SummaryHTTPMethodResponseJSON `json:"-"` +} + +// attackLayer7SummaryHTTPMethodResponseJSON contains the JSON metadata for the +// struct [AttackLayer7SummaryHTTPMethodResponse] +type attackLayer7SummaryHTTPMethodResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryHTTPMethodResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryHTTPMethodResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryHTTPMethodResponseMeta struct { + DateRange []AttackLayer7SummaryHTTPMethodResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo AttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer7SummaryHTTPMethodResponseMetaJSON `json:"-"` +} + +// attackLayer7SummaryHTTPMethodResponseMetaJSON contains the JSON metadata for the +// struct [AttackLayer7SummaryHTTPMethodResponseMeta] +type attackLayer7SummaryHTTPMethodResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryHTTPMethodResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryHTTPMethodResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryHTTPMethodResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer7SummaryHTTPMethodResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer7SummaryHTTPMethodResponseMetaDateRangeJSON contains the JSON +// metadata for the struct [AttackLayer7SummaryHTTPMethodResponseMetaDateRange] +type attackLayer7SummaryHTTPMethodResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryHTTPMethodResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryHTTPMethodResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfo struct { + Annotations []AttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct +// [AttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfo] +type attackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoAnnotationJSON contains +// the JSON metadata for the struct +// [AttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoAnnotation] +type attackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryHTTPMethodResponseSummary0 struct { + Get string `json:"GET,required"` + Post string `json:"POST,required"` + JSON attackLayer7SummaryHTTPMethodResponseSummary0JSON `json:"-"` +} + +// attackLayer7SummaryHTTPMethodResponseSummary0JSON contains the JSON metadata for +// the struct [AttackLayer7SummaryHTTPMethodResponseSummary0] +type attackLayer7SummaryHTTPMethodResponseSummary0JSON struct { + Get apijson.Field + Post apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryHTTPMethodResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryHTTPMethodResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryHTTPVersionResponse struct { + Meta AttackLayer7SummaryHTTPVersionResponseMeta `json:"meta,required"` + Summary0 AttackLayer7SummaryHTTPVersionResponseSummary0 `json:"summary_0,required"` + JSON attackLayer7SummaryHTTPVersionResponseJSON `json:"-"` +} + +// attackLayer7SummaryHTTPVersionResponseJSON contains the JSON metadata for the +// struct [AttackLayer7SummaryHTTPVersionResponse] +type attackLayer7SummaryHTTPVersionResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryHTTPVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryHTTPVersionResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryHTTPVersionResponseMeta struct { + DateRange []AttackLayer7SummaryHTTPVersionResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo AttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer7SummaryHTTPVersionResponseMetaJSON `json:"-"` +} + +// attackLayer7SummaryHTTPVersionResponseMetaJSON contains the JSON metadata for +// the struct [AttackLayer7SummaryHTTPVersionResponseMeta] +type attackLayer7SummaryHTTPVersionResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryHTTPVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryHTTPVersionResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryHTTPVersionResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer7SummaryHTTPVersionResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer7SummaryHTTPVersionResponseMetaDateRangeJSON contains the JSON +// metadata for the struct [AttackLayer7SummaryHTTPVersionResponseMetaDateRange] +type attackLayer7SummaryHTTPVersionResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryHTTPVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryHTTPVersionResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfo struct { + Annotations []AttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct +// [AttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfo] +type attackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoAnnotationJSON contains +// the JSON metadata for the struct +// [AttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoAnnotation] +type attackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryHTTPVersionResponseSummary0 struct { + HTTP1X string `json:"HTTP/1.x,required"` + HTTP2 string `json:"HTTP/2,required"` + HTTP3 string `json:"HTTP/3,required"` + JSON attackLayer7SummaryHTTPVersionResponseSummary0JSON `json:"-"` +} + +// attackLayer7SummaryHTTPVersionResponseSummary0JSON contains the JSON metadata +// for the struct [AttackLayer7SummaryHTTPVersionResponseSummary0] +type attackLayer7SummaryHTTPVersionResponseSummary0JSON struct { + HTTP1X apijson.Field + HTTP2 apijson.Field + HTTP3 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryHTTPVersionResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryHTTPVersionResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryIPVersionResponse struct { + Meta AttackLayer7SummaryIPVersionResponseMeta `json:"meta,required"` + Summary0 AttackLayer7SummaryIPVersionResponseSummary0 `json:"summary_0,required"` + JSON attackLayer7SummaryIPVersionResponseJSON `json:"-"` +} + +// attackLayer7SummaryIPVersionResponseJSON contains the JSON metadata for the +// struct [AttackLayer7SummaryIPVersionResponse] +type attackLayer7SummaryIPVersionResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryIPVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryIPVersionResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryIPVersionResponseMeta struct { + DateRange []AttackLayer7SummaryIPVersionResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo AttackLayer7SummaryIPVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer7SummaryIPVersionResponseMetaJSON `json:"-"` +} + +// attackLayer7SummaryIPVersionResponseMetaJSON contains the JSON metadata for the +// struct [AttackLayer7SummaryIPVersionResponseMeta] +type attackLayer7SummaryIPVersionResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryIPVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryIPVersionResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryIPVersionResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer7SummaryIPVersionResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer7SummaryIPVersionResponseMetaDateRangeJSON contains the JSON metadata +// for the struct [AttackLayer7SummaryIPVersionResponseMetaDateRange] +type attackLayer7SummaryIPVersionResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryIPVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryIPVersionResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryIPVersionResponseMetaConfidenceInfo struct { + Annotations []AttackLayer7SummaryIPVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer7SummaryIPVersionResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer7SummaryIPVersionResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [AttackLayer7SummaryIPVersionResponseMetaConfidenceInfo] +type attackLayer7SummaryIPVersionResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryIPVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryIPVersionResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryIPVersionResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer7SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer7SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON contains +// the JSON metadata for the struct +// [AttackLayer7SummaryIPVersionResponseMetaConfidenceInfoAnnotation] +type attackLayer7SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryIPVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryIPVersionResponseSummary0 struct { + IPv4 string `json:"IPv4,required"` + IPv6 string `json:"IPv6,required"` + JSON attackLayer7SummaryIPVersionResponseSummary0JSON `json:"-"` +} + +// attackLayer7SummaryIPVersionResponseSummary0JSON contains the JSON metadata for +// the struct [AttackLayer7SummaryIPVersionResponseSummary0] +type attackLayer7SummaryIPVersionResponseSummary0JSON struct { + IPv4 apijson.Field + IPv6 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryIPVersionResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryIPVersionResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryManagedRulesResponse struct { + Meta AttackLayer7SummaryManagedRulesResponseMeta `json:"meta,required"` + Summary0 AttackLayer7SummaryManagedRulesResponseSummary0 `json:"summary_0,required"` + JSON attackLayer7SummaryManagedRulesResponseJSON `json:"-"` +} + +// attackLayer7SummaryManagedRulesResponseJSON contains the JSON metadata for the +// struct [AttackLayer7SummaryManagedRulesResponse] +type attackLayer7SummaryManagedRulesResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryManagedRulesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryManagedRulesResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryManagedRulesResponseMeta struct { + DateRange []AttackLayer7SummaryManagedRulesResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo AttackLayer7SummaryManagedRulesResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer7SummaryManagedRulesResponseMetaJSON `json:"-"` +} + +// attackLayer7SummaryManagedRulesResponseMetaJSON contains the JSON metadata for +// the struct [AttackLayer7SummaryManagedRulesResponseMeta] +type attackLayer7SummaryManagedRulesResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryManagedRulesResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryManagedRulesResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryManagedRulesResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer7SummaryManagedRulesResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer7SummaryManagedRulesResponseMetaDateRangeJSON contains the JSON +// metadata for the struct [AttackLayer7SummaryManagedRulesResponseMetaDateRange] +type attackLayer7SummaryManagedRulesResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryManagedRulesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryManagedRulesResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryManagedRulesResponseMetaConfidenceInfo struct { + Annotations []AttackLayer7SummaryManagedRulesResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer7SummaryManagedRulesResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer7SummaryManagedRulesResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct +// [AttackLayer7SummaryManagedRulesResponseMetaConfidenceInfo] +type attackLayer7SummaryManagedRulesResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryManagedRulesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryManagedRulesResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryManagedRulesResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer7SummaryManagedRulesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer7SummaryManagedRulesResponseMetaConfidenceInfoAnnotationJSON contains +// the JSON metadata for the struct +// [AttackLayer7SummaryManagedRulesResponseMetaConfidenceInfoAnnotation] +type attackLayer7SummaryManagedRulesResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryManagedRulesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryManagedRulesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryManagedRulesResponseSummary0 struct { + Bot string `json:"Bot,required"` + HTTPAnomaly string `json:"HTTP Anomaly,required"` + JSON attackLayer7SummaryManagedRulesResponseSummary0JSON `json:"-"` +} + +// attackLayer7SummaryManagedRulesResponseSummary0JSON contains the JSON metadata +// for the struct [AttackLayer7SummaryManagedRulesResponseSummary0] +type attackLayer7SummaryManagedRulesResponseSummary0JSON struct { + Bot apijson.Field + HTTPAnomaly apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryManagedRulesResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryManagedRulesResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryMitigationProductResponse struct { + Meta AttackLayer7SummaryMitigationProductResponseMeta `json:"meta,required"` + Summary0 AttackLayer7SummaryMitigationProductResponseSummary0 `json:"summary_0,required"` + JSON attackLayer7SummaryMitigationProductResponseJSON `json:"-"` +} + +// attackLayer7SummaryMitigationProductResponseJSON contains the JSON metadata for +// the struct [AttackLayer7SummaryMitigationProductResponse] +type attackLayer7SummaryMitigationProductResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryMitigationProductResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryMitigationProductResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryMitigationProductResponseMeta struct { + DateRange []AttackLayer7SummaryMitigationProductResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo AttackLayer7SummaryMitigationProductResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer7SummaryMitigationProductResponseMetaJSON `json:"-"` +} + +// attackLayer7SummaryMitigationProductResponseMetaJSON contains the JSON metadata +// for the struct [AttackLayer7SummaryMitigationProductResponseMeta] +type attackLayer7SummaryMitigationProductResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryMitigationProductResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryMitigationProductResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryMitigationProductResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer7SummaryMitigationProductResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer7SummaryMitigationProductResponseMetaDateRangeJSON contains the JSON +// metadata for the struct +// [AttackLayer7SummaryMitigationProductResponseMetaDateRange] +type attackLayer7SummaryMitigationProductResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryMitigationProductResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryMitigationProductResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryMitigationProductResponseMetaConfidenceInfo struct { + Annotations []AttackLayer7SummaryMitigationProductResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer7SummaryMitigationProductResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer7SummaryMitigationProductResponseMetaConfidenceInfoJSON contains the +// JSON metadata for the struct +// [AttackLayer7SummaryMitigationProductResponseMetaConfidenceInfo] +type attackLayer7SummaryMitigationProductResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryMitigationProductResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryMitigationProductResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryMitigationProductResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer7SummaryMitigationProductResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer7SummaryMitigationProductResponseMetaConfidenceInfoAnnotationJSON +// contains the JSON metadata for the struct +// [AttackLayer7SummaryMitigationProductResponseMetaConfidenceInfoAnnotation] +type attackLayer7SummaryMitigationProductResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryMitigationProductResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryMitigationProductResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryMitigationProductResponseSummary0 struct { + DDOS string `json:"DDOS,required"` + WAF string `json:"WAF,required"` + JSON attackLayer7SummaryMitigationProductResponseSummary0JSON `json:"-"` +} + +// attackLayer7SummaryMitigationProductResponseSummary0JSON contains the JSON +// metadata for the struct [AttackLayer7SummaryMitigationProductResponseSummary0] +type attackLayer7SummaryMitigationProductResponseSummary0JSON struct { + DDOS apijson.Field + WAF apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryMitigationProductResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryMitigationProductResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7SummaryGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7SummaryGetParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AttackLayer7SummaryGetParams]'s query parameters as +// `url.Values`. +func (r AttackLayer7SummaryGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer7SummaryGetParamsDateRange string + +const ( + AttackLayer7SummaryGetParamsDateRange1d AttackLayer7SummaryGetParamsDateRange = "1d" + AttackLayer7SummaryGetParamsDateRange2d AttackLayer7SummaryGetParamsDateRange = "2d" + AttackLayer7SummaryGetParamsDateRange7d AttackLayer7SummaryGetParamsDateRange = "7d" + AttackLayer7SummaryGetParamsDateRange14d AttackLayer7SummaryGetParamsDateRange = "14d" + AttackLayer7SummaryGetParamsDateRange28d AttackLayer7SummaryGetParamsDateRange = "28d" + AttackLayer7SummaryGetParamsDateRange12w AttackLayer7SummaryGetParamsDateRange = "12w" + AttackLayer7SummaryGetParamsDateRange24w AttackLayer7SummaryGetParamsDateRange = "24w" + AttackLayer7SummaryGetParamsDateRange52w AttackLayer7SummaryGetParamsDateRange = "52w" + AttackLayer7SummaryGetParamsDateRange1dControl AttackLayer7SummaryGetParamsDateRange = "1dControl" + AttackLayer7SummaryGetParamsDateRange2dControl AttackLayer7SummaryGetParamsDateRange = "2dControl" + AttackLayer7SummaryGetParamsDateRange7dControl AttackLayer7SummaryGetParamsDateRange = "7dControl" + AttackLayer7SummaryGetParamsDateRange14dControl AttackLayer7SummaryGetParamsDateRange = "14dControl" + AttackLayer7SummaryGetParamsDateRange28dControl AttackLayer7SummaryGetParamsDateRange = "28dControl" + AttackLayer7SummaryGetParamsDateRange12wControl AttackLayer7SummaryGetParamsDateRange = "12wControl" + AttackLayer7SummaryGetParamsDateRange24wControl AttackLayer7SummaryGetParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7SummaryGetParamsFormat string + +const ( + AttackLayer7SummaryGetParamsFormatJson AttackLayer7SummaryGetParamsFormat = "JSON" + AttackLayer7SummaryGetParamsFormatCsv AttackLayer7SummaryGetParamsFormat = "CSV" +) + +type AttackLayer7SummaryGetResponseEnvelope struct { + Result AttackLayer7SummaryGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7SummaryGetResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7SummaryGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [AttackLayer7SummaryGetResponseEnvelope] +type attackLayer7SummaryGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryHTTPMethodParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7SummaryHTTPMethodParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7SummaryHTTPMethodParamsFormat] `query:"format"` + // Filter for http version. + HTTPVersion param.Field[[]AttackLayer7SummaryHTTPMethodParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer7SummaryHTTPMethodParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of L7 mitigation products. + MitigationProduct param.Field[[]AttackLayer7SummaryHTTPMethodParamsMitigationProduct] `query:"mitigationProduct"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AttackLayer7SummaryHTTPMethodParams]'s query parameters as +// `url.Values`. +func (r AttackLayer7SummaryHTTPMethodParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer7SummaryHTTPMethodParamsDateRange string + +const ( + AttackLayer7SummaryHTTPMethodParamsDateRange1d AttackLayer7SummaryHTTPMethodParamsDateRange = "1d" + AttackLayer7SummaryHTTPMethodParamsDateRange2d AttackLayer7SummaryHTTPMethodParamsDateRange = "2d" + AttackLayer7SummaryHTTPMethodParamsDateRange7d AttackLayer7SummaryHTTPMethodParamsDateRange = "7d" + AttackLayer7SummaryHTTPMethodParamsDateRange14d AttackLayer7SummaryHTTPMethodParamsDateRange = "14d" + AttackLayer7SummaryHTTPMethodParamsDateRange28d AttackLayer7SummaryHTTPMethodParamsDateRange = "28d" + AttackLayer7SummaryHTTPMethodParamsDateRange12w AttackLayer7SummaryHTTPMethodParamsDateRange = "12w" + AttackLayer7SummaryHTTPMethodParamsDateRange24w AttackLayer7SummaryHTTPMethodParamsDateRange = "24w" + AttackLayer7SummaryHTTPMethodParamsDateRange52w AttackLayer7SummaryHTTPMethodParamsDateRange = "52w" + AttackLayer7SummaryHTTPMethodParamsDateRange1dControl AttackLayer7SummaryHTTPMethodParamsDateRange = "1dControl" + AttackLayer7SummaryHTTPMethodParamsDateRange2dControl AttackLayer7SummaryHTTPMethodParamsDateRange = "2dControl" + AttackLayer7SummaryHTTPMethodParamsDateRange7dControl AttackLayer7SummaryHTTPMethodParamsDateRange = "7dControl" + AttackLayer7SummaryHTTPMethodParamsDateRange14dControl AttackLayer7SummaryHTTPMethodParamsDateRange = "14dControl" + AttackLayer7SummaryHTTPMethodParamsDateRange28dControl AttackLayer7SummaryHTTPMethodParamsDateRange = "28dControl" + AttackLayer7SummaryHTTPMethodParamsDateRange12wControl AttackLayer7SummaryHTTPMethodParamsDateRange = "12wControl" + AttackLayer7SummaryHTTPMethodParamsDateRange24wControl AttackLayer7SummaryHTTPMethodParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7SummaryHTTPMethodParamsFormat string + +const ( + AttackLayer7SummaryHTTPMethodParamsFormatJson AttackLayer7SummaryHTTPMethodParamsFormat = "JSON" + AttackLayer7SummaryHTTPMethodParamsFormatCsv AttackLayer7SummaryHTTPMethodParamsFormat = "CSV" +) + +type AttackLayer7SummaryHTTPMethodParamsHTTPVersion string + +const ( + AttackLayer7SummaryHTTPMethodParamsHTTPVersionHttPv1 AttackLayer7SummaryHTTPMethodParamsHTTPVersion = "HTTPv1" + AttackLayer7SummaryHTTPMethodParamsHTTPVersionHttPv2 AttackLayer7SummaryHTTPMethodParamsHTTPVersion = "HTTPv2" + AttackLayer7SummaryHTTPMethodParamsHTTPVersionHttPv3 AttackLayer7SummaryHTTPMethodParamsHTTPVersion = "HTTPv3" +) + +type AttackLayer7SummaryHTTPMethodParamsIPVersion string + +const ( + AttackLayer7SummaryHTTPMethodParamsIPVersionIPv4 AttackLayer7SummaryHTTPMethodParamsIPVersion = "IPv4" + AttackLayer7SummaryHTTPMethodParamsIPVersionIPv6 AttackLayer7SummaryHTTPMethodParamsIPVersion = "IPv6" +) + +type AttackLayer7SummaryHTTPMethodParamsMitigationProduct string + +const ( + AttackLayer7SummaryHTTPMethodParamsMitigationProductDDOS AttackLayer7SummaryHTTPMethodParamsMitigationProduct = "DDOS" + AttackLayer7SummaryHTTPMethodParamsMitigationProductWAF AttackLayer7SummaryHTTPMethodParamsMitigationProduct = "WAF" + AttackLayer7SummaryHTTPMethodParamsMitigationProductBotManagement AttackLayer7SummaryHTTPMethodParamsMitigationProduct = "BOT_MANAGEMENT" + AttackLayer7SummaryHTTPMethodParamsMitigationProductAccessRules AttackLayer7SummaryHTTPMethodParamsMitigationProduct = "ACCESS_RULES" + AttackLayer7SummaryHTTPMethodParamsMitigationProductIPReputation AttackLayer7SummaryHTTPMethodParamsMitigationProduct = "IP_REPUTATION" + AttackLayer7SummaryHTTPMethodParamsMitigationProductAPIShield AttackLayer7SummaryHTTPMethodParamsMitigationProduct = "API_SHIELD" + AttackLayer7SummaryHTTPMethodParamsMitigationProductDataLossPrevention AttackLayer7SummaryHTTPMethodParamsMitigationProduct = "DATA_LOSS_PREVENTION" +) + +type AttackLayer7SummaryHTTPMethodResponseEnvelope struct { + Result AttackLayer7SummaryHTTPMethodResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7SummaryHTTPMethodResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7SummaryHTTPMethodResponseEnvelopeJSON contains the JSON metadata for +// the struct [AttackLayer7SummaryHTTPMethodResponseEnvelope] +type attackLayer7SummaryHTTPMethodResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryHTTPMethodResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryHTTPMethodResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryHTTPVersionParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7SummaryHTTPVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7SummaryHTTPVersionParamsFormat] `query:"format"` + // Filter for http method. + HTTPMethod param.Field[[]AttackLayer7SummaryHTTPVersionParamsHTTPMethod] `query:"httpMethod"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer7SummaryHTTPVersionParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of L7 mitigation products. + MitigationProduct param.Field[[]AttackLayer7SummaryHTTPVersionParamsMitigationProduct] `query:"mitigationProduct"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AttackLayer7SummaryHTTPVersionParams]'s query parameters as +// `url.Values`. +func (r AttackLayer7SummaryHTTPVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer7SummaryHTTPVersionParamsDateRange string + +const ( + AttackLayer7SummaryHTTPVersionParamsDateRange1d AttackLayer7SummaryHTTPVersionParamsDateRange = "1d" + AttackLayer7SummaryHTTPVersionParamsDateRange2d AttackLayer7SummaryHTTPVersionParamsDateRange = "2d" + AttackLayer7SummaryHTTPVersionParamsDateRange7d AttackLayer7SummaryHTTPVersionParamsDateRange = "7d" + AttackLayer7SummaryHTTPVersionParamsDateRange14d AttackLayer7SummaryHTTPVersionParamsDateRange = "14d" + AttackLayer7SummaryHTTPVersionParamsDateRange28d AttackLayer7SummaryHTTPVersionParamsDateRange = "28d" + AttackLayer7SummaryHTTPVersionParamsDateRange12w AttackLayer7SummaryHTTPVersionParamsDateRange = "12w" + AttackLayer7SummaryHTTPVersionParamsDateRange24w AttackLayer7SummaryHTTPVersionParamsDateRange = "24w" + AttackLayer7SummaryHTTPVersionParamsDateRange52w AttackLayer7SummaryHTTPVersionParamsDateRange = "52w" + AttackLayer7SummaryHTTPVersionParamsDateRange1dControl AttackLayer7SummaryHTTPVersionParamsDateRange = "1dControl" + AttackLayer7SummaryHTTPVersionParamsDateRange2dControl AttackLayer7SummaryHTTPVersionParamsDateRange = "2dControl" + AttackLayer7SummaryHTTPVersionParamsDateRange7dControl AttackLayer7SummaryHTTPVersionParamsDateRange = "7dControl" + AttackLayer7SummaryHTTPVersionParamsDateRange14dControl AttackLayer7SummaryHTTPVersionParamsDateRange = "14dControl" + AttackLayer7SummaryHTTPVersionParamsDateRange28dControl AttackLayer7SummaryHTTPVersionParamsDateRange = "28dControl" + AttackLayer7SummaryHTTPVersionParamsDateRange12wControl AttackLayer7SummaryHTTPVersionParamsDateRange = "12wControl" + AttackLayer7SummaryHTTPVersionParamsDateRange24wControl AttackLayer7SummaryHTTPVersionParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7SummaryHTTPVersionParamsFormat string + +const ( + AttackLayer7SummaryHTTPVersionParamsFormatJson AttackLayer7SummaryHTTPVersionParamsFormat = "JSON" + AttackLayer7SummaryHTTPVersionParamsFormatCsv AttackLayer7SummaryHTTPVersionParamsFormat = "CSV" +) + +type AttackLayer7SummaryHTTPVersionParamsHTTPMethod string + +const ( + AttackLayer7SummaryHTTPVersionParamsHTTPMethodGet AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "GET" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodPost AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "POST" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodDelete AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "DELETE" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodPut AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "PUT" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodHead AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "HEAD" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodPurge AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "PURGE" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodOptions AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "OPTIONS" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodPropfind AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "PROPFIND" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodMkcol AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "MKCOL" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodPatch AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "PATCH" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodACL AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "ACL" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodBcopy AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "BCOPY" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodBdelete AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "BDELETE" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodBmove AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "BMOVE" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodBpropfind AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "BPROPFIND" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodBproppatch AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "BPROPPATCH" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodCheckin AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "CHECKIN" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodCheckout AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "CHECKOUT" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodConnect AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "CONNECT" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodCopy AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "COPY" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodLabel AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "LABEL" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodLock AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "LOCK" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodMerge AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "MERGE" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodMkactivity AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "MKACTIVITY" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodMkworkspace AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "MKWORKSPACE" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodMove AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "MOVE" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodNotify AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "NOTIFY" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodOrderpatch AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "ORDERPATCH" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodPoll AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "POLL" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodProppatch AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "PROPPATCH" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodReport AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "REPORT" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodSearch AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "SEARCH" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodSubscribe AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "SUBSCRIBE" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodTrace AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "TRACE" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodUncheckout AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "UNCHECKOUT" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodUnlock AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "UNLOCK" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodUnsubscribe AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "UNSUBSCRIBE" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodUpdate AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "UPDATE" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodVersioncontrol AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "VERSIONCONTROL" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodBaselinecontrol AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "BASELINECONTROL" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodXmsenumatts AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "XMSENUMATTS" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodRpcOutData AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "RPC_OUT_DATA" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodRpcInData AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "RPC_IN_DATA" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodJson AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "JSON" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodCook AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "COOK" + AttackLayer7SummaryHTTPVersionParamsHTTPMethodTrack AttackLayer7SummaryHTTPVersionParamsHTTPMethod = "TRACK" +) + +type AttackLayer7SummaryHTTPVersionParamsIPVersion string + +const ( + AttackLayer7SummaryHTTPVersionParamsIPVersionIPv4 AttackLayer7SummaryHTTPVersionParamsIPVersion = "IPv4" + AttackLayer7SummaryHTTPVersionParamsIPVersionIPv6 AttackLayer7SummaryHTTPVersionParamsIPVersion = "IPv6" +) + +type AttackLayer7SummaryHTTPVersionParamsMitigationProduct string + +const ( + AttackLayer7SummaryHTTPVersionParamsMitigationProductDDOS AttackLayer7SummaryHTTPVersionParamsMitigationProduct = "DDOS" + AttackLayer7SummaryHTTPVersionParamsMitigationProductWAF AttackLayer7SummaryHTTPVersionParamsMitigationProduct = "WAF" + AttackLayer7SummaryHTTPVersionParamsMitigationProductBotManagement AttackLayer7SummaryHTTPVersionParamsMitigationProduct = "BOT_MANAGEMENT" + AttackLayer7SummaryHTTPVersionParamsMitigationProductAccessRules AttackLayer7SummaryHTTPVersionParamsMitigationProduct = "ACCESS_RULES" + AttackLayer7SummaryHTTPVersionParamsMitigationProductIPReputation AttackLayer7SummaryHTTPVersionParamsMitigationProduct = "IP_REPUTATION" + AttackLayer7SummaryHTTPVersionParamsMitigationProductAPIShield AttackLayer7SummaryHTTPVersionParamsMitigationProduct = "API_SHIELD" + AttackLayer7SummaryHTTPVersionParamsMitigationProductDataLossPrevention AttackLayer7SummaryHTTPVersionParamsMitigationProduct = "DATA_LOSS_PREVENTION" +) + +type AttackLayer7SummaryHTTPVersionResponseEnvelope struct { + Result AttackLayer7SummaryHTTPVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7SummaryHTTPVersionResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7SummaryHTTPVersionResponseEnvelopeJSON contains the JSON metadata +// for the struct [AttackLayer7SummaryHTTPVersionResponseEnvelope] +type attackLayer7SummaryHTTPVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryHTTPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryHTTPVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryIPVersionParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7SummaryIPVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7SummaryIPVersionParamsFormat] `query:"format"` + // Filter for http method. + HTTPMethod param.Field[[]AttackLayer7SummaryIPVersionParamsHTTPMethod] `query:"httpMethod"` + // Filter for http version. + HTTPVersion param.Field[[]AttackLayer7SummaryIPVersionParamsHTTPVersion] `query:"httpVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of L7 mitigation products. + MitigationProduct param.Field[[]AttackLayer7SummaryIPVersionParamsMitigationProduct] `query:"mitigationProduct"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AttackLayer7SummaryIPVersionParams]'s query parameters as +// `url.Values`. +func (r AttackLayer7SummaryIPVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer7SummaryIPVersionParamsDateRange string + +const ( + AttackLayer7SummaryIPVersionParamsDateRange1d AttackLayer7SummaryIPVersionParamsDateRange = "1d" + AttackLayer7SummaryIPVersionParamsDateRange2d AttackLayer7SummaryIPVersionParamsDateRange = "2d" + AttackLayer7SummaryIPVersionParamsDateRange7d AttackLayer7SummaryIPVersionParamsDateRange = "7d" + AttackLayer7SummaryIPVersionParamsDateRange14d AttackLayer7SummaryIPVersionParamsDateRange = "14d" + AttackLayer7SummaryIPVersionParamsDateRange28d AttackLayer7SummaryIPVersionParamsDateRange = "28d" + AttackLayer7SummaryIPVersionParamsDateRange12w AttackLayer7SummaryIPVersionParamsDateRange = "12w" + AttackLayer7SummaryIPVersionParamsDateRange24w AttackLayer7SummaryIPVersionParamsDateRange = "24w" + AttackLayer7SummaryIPVersionParamsDateRange52w AttackLayer7SummaryIPVersionParamsDateRange = "52w" + AttackLayer7SummaryIPVersionParamsDateRange1dControl AttackLayer7SummaryIPVersionParamsDateRange = "1dControl" + AttackLayer7SummaryIPVersionParamsDateRange2dControl AttackLayer7SummaryIPVersionParamsDateRange = "2dControl" + AttackLayer7SummaryIPVersionParamsDateRange7dControl AttackLayer7SummaryIPVersionParamsDateRange = "7dControl" + AttackLayer7SummaryIPVersionParamsDateRange14dControl AttackLayer7SummaryIPVersionParamsDateRange = "14dControl" + AttackLayer7SummaryIPVersionParamsDateRange28dControl AttackLayer7SummaryIPVersionParamsDateRange = "28dControl" + AttackLayer7SummaryIPVersionParamsDateRange12wControl AttackLayer7SummaryIPVersionParamsDateRange = "12wControl" + AttackLayer7SummaryIPVersionParamsDateRange24wControl AttackLayer7SummaryIPVersionParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7SummaryIPVersionParamsFormat string + +const ( + AttackLayer7SummaryIPVersionParamsFormatJson AttackLayer7SummaryIPVersionParamsFormat = "JSON" + AttackLayer7SummaryIPVersionParamsFormatCsv AttackLayer7SummaryIPVersionParamsFormat = "CSV" +) + +type AttackLayer7SummaryIPVersionParamsHTTPMethod string + +const ( + AttackLayer7SummaryIPVersionParamsHTTPMethodGet AttackLayer7SummaryIPVersionParamsHTTPMethod = "GET" + AttackLayer7SummaryIPVersionParamsHTTPMethodPost AttackLayer7SummaryIPVersionParamsHTTPMethod = "POST" + AttackLayer7SummaryIPVersionParamsHTTPMethodDelete AttackLayer7SummaryIPVersionParamsHTTPMethod = "DELETE" + AttackLayer7SummaryIPVersionParamsHTTPMethodPut AttackLayer7SummaryIPVersionParamsHTTPMethod = "PUT" + AttackLayer7SummaryIPVersionParamsHTTPMethodHead AttackLayer7SummaryIPVersionParamsHTTPMethod = "HEAD" + AttackLayer7SummaryIPVersionParamsHTTPMethodPurge AttackLayer7SummaryIPVersionParamsHTTPMethod = "PURGE" + AttackLayer7SummaryIPVersionParamsHTTPMethodOptions AttackLayer7SummaryIPVersionParamsHTTPMethod = "OPTIONS" + AttackLayer7SummaryIPVersionParamsHTTPMethodPropfind AttackLayer7SummaryIPVersionParamsHTTPMethod = "PROPFIND" + AttackLayer7SummaryIPVersionParamsHTTPMethodMkcol AttackLayer7SummaryIPVersionParamsHTTPMethod = "MKCOL" + AttackLayer7SummaryIPVersionParamsHTTPMethodPatch AttackLayer7SummaryIPVersionParamsHTTPMethod = "PATCH" + AttackLayer7SummaryIPVersionParamsHTTPMethodACL AttackLayer7SummaryIPVersionParamsHTTPMethod = "ACL" + AttackLayer7SummaryIPVersionParamsHTTPMethodBcopy AttackLayer7SummaryIPVersionParamsHTTPMethod = "BCOPY" + AttackLayer7SummaryIPVersionParamsHTTPMethodBdelete AttackLayer7SummaryIPVersionParamsHTTPMethod = "BDELETE" + AttackLayer7SummaryIPVersionParamsHTTPMethodBmove AttackLayer7SummaryIPVersionParamsHTTPMethod = "BMOVE" + AttackLayer7SummaryIPVersionParamsHTTPMethodBpropfind AttackLayer7SummaryIPVersionParamsHTTPMethod = "BPROPFIND" + AttackLayer7SummaryIPVersionParamsHTTPMethodBproppatch AttackLayer7SummaryIPVersionParamsHTTPMethod = "BPROPPATCH" + AttackLayer7SummaryIPVersionParamsHTTPMethodCheckin AttackLayer7SummaryIPVersionParamsHTTPMethod = "CHECKIN" + AttackLayer7SummaryIPVersionParamsHTTPMethodCheckout AttackLayer7SummaryIPVersionParamsHTTPMethod = "CHECKOUT" + AttackLayer7SummaryIPVersionParamsHTTPMethodConnect AttackLayer7SummaryIPVersionParamsHTTPMethod = "CONNECT" + AttackLayer7SummaryIPVersionParamsHTTPMethodCopy AttackLayer7SummaryIPVersionParamsHTTPMethod = "COPY" + AttackLayer7SummaryIPVersionParamsHTTPMethodLabel AttackLayer7SummaryIPVersionParamsHTTPMethod = "LABEL" + AttackLayer7SummaryIPVersionParamsHTTPMethodLock AttackLayer7SummaryIPVersionParamsHTTPMethod = "LOCK" + AttackLayer7SummaryIPVersionParamsHTTPMethodMerge AttackLayer7SummaryIPVersionParamsHTTPMethod = "MERGE" + AttackLayer7SummaryIPVersionParamsHTTPMethodMkactivity AttackLayer7SummaryIPVersionParamsHTTPMethod = "MKACTIVITY" + AttackLayer7SummaryIPVersionParamsHTTPMethodMkworkspace AttackLayer7SummaryIPVersionParamsHTTPMethod = "MKWORKSPACE" + AttackLayer7SummaryIPVersionParamsHTTPMethodMove AttackLayer7SummaryIPVersionParamsHTTPMethod = "MOVE" + AttackLayer7SummaryIPVersionParamsHTTPMethodNotify AttackLayer7SummaryIPVersionParamsHTTPMethod = "NOTIFY" + AttackLayer7SummaryIPVersionParamsHTTPMethodOrderpatch AttackLayer7SummaryIPVersionParamsHTTPMethod = "ORDERPATCH" + AttackLayer7SummaryIPVersionParamsHTTPMethodPoll AttackLayer7SummaryIPVersionParamsHTTPMethod = "POLL" + AttackLayer7SummaryIPVersionParamsHTTPMethodProppatch AttackLayer7SummaryIPVersionParamsHTTPMethod = "PROPPATCH" + AttackLayer7SummaryIPVersionParamsHTTPMethodReport AttackLayer7SummaryIPVersionParamsHTTPMethod = "REPORT" + AttackLayer7SummaryIPVersionParamsHTTPMethodSearch AttackLayer7SummaryIPVersionParamsHTTPMethod = "SEARCH" + AttackLayer7SummaryIPVersionParamsHTTPMethodSubscribe AttackLayer7SummaryIPVersionParamsHTTPMethod = "SUBSCRIBE" + AttackLayer7SummaryIPVersionParamsHTTPMethodTrace AttackLayer7SummaryIPVersionParamsHTTPMethod = "TRACE" + AttackLayer7SummaryIPVersionParamsHTTPMethodUncheckout AttackLayer7SummaryIPVersionParamsHTTPMethod = "UNCHECKOUT" + AttackLayer7SummaryIPVersionParamsHTTPMethodUnlock AttackLayer7SummaryIPVersionParamsHTTPMethod = "UNLOCK" + AttackLayer7SummaryIPVersionParamsHTTPMethodUnsubscribe AttackLayer7SummaryIPVersionParamsHTTPMethod = "UNSUBSCRIBE" + AttackLayer7SummaryIPVersionParamsHTTPMethodUpdate AttackLayer7SummaryIPVersionParamsHTTPMethod = "UPDATE" + AttackLayer7SummaryIPVersionParamsHTTPMethodVersioncontrol AttackLayer7SummaryIPVersionParamsHTTPMethod = "VERSIONCONTROL" + AttackLayer7SummaryIPVersionParamsHTTPMethodBaselinecontrol AttackLayer7SummaryIPVersionParamsHTTPMethod = "BASELINECONTROL" + AttackLayer7SummaryIPVersionParamsHTTPMethodXmsenumatts AttackLayer7SummaryIPVersionParamsHTTPMethod = "XMSENUMATTS" + AttackLayer7SummaryIPVersionParamsHTTPMethodRpcOutData AttackLayer7SummaryIPVersionParamsHTTPMethod = "RPC_OUT_DATA" + AttackLayer7SummaryIPVersionParamsHTTPMethodRpcInData AttackLayer7SummaryIPVersionParamsHTTPMethod = "RPC_IN_DATA" + AttackLayer7SummaryIPVersionParamsHTTPMethodJson AttackLayer7SummaryIPVersionParamsHTTPMethod = "JSON" + AttackLayer7SummaryIPVersionParamsHTTPMethodCook AttackLayer7SummaryIPVersionParamsHTTPMethod = "COOK" + AttackLayer7SummaryIPVersionParamsHTTPMethodTrack AttackLayer7SummaryIPVersionParamsHTTPMethod = "TRACK" +) + +type AttackLayer7SummaryIPVersionParamsHTTPVersion string + +const ( + AttackLayer7SummaryIPVersionParamsHTTPVersionHttPv1 AttackLayer7SummaryIPVersionParamsHTTPVersion = "HTTPv1" + AttackLayer7SummaryIPVersionParamsHTTPVersionHttPv2 AttackLayer7SummaryIPVersionParamsHTTPVersion = "HTTPv2" + AttackLayer7SummaryIPVersionParamsHTTPVersionHttPv3 AttackLayer7SummaryIPVersionParamsHTTPVersion = "HTTPv3" +) + +type AttackLayer7SummaryIPVersionParamsMitigationProduct string + +const ( + AttackLayer7SummaryIPVersionParamsMitigationProductDDOS AttackLayer7SummaryIPVersionParamsMitigationProduct = "DDOS" + AttackLayer7SummaryIPVersionParamsMitigationProductWAF AttackLayer7SummaryIPVersionParamsMitigationProduct = "WAF" + AttackLayer7SummaryIPVersionParamsMitigationProductBotManagement AttackLayer7SummaryIPVersionParamsMitigationProduct = "BOT_MANAGEMENT" + AttackLayer7SummaryIPVersionParamsMitigationProductAccessRules AttackLayer7SummaryIPVersionParamsMitigationProduct = "ACCESS_RULES" + AttackLayer7SummaryIPVersionParamsMitigationProductIPReputation AttackLayer7SummaryIPVersionParamsMitigationProduct = "IP_REPUTATION" + AttackLayer7SummaryIPVersionParamsMitigationProductAPIShield AttackLayer7SummaryIPVersionParamsMitigationProduct = "API_SHIELD" + AttackLayer7SummaryIPVersionParamsMitigationProductDataLossPrevention AttackLayer7SummaryIPVersionParamsMitigationProduct = "DATA_LOSS_PREVENTION" +) + +type AttackLayer7SummaryIPVersionResponseEnvelope struct { + Result AttackLayer7SummaryIPVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7SummaryIPVersionResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7SummaryIPVersionResponseEnvelopeJSON contains the JSON metadata for +// the struct [AttackLayer7SummaryIPVersionResponseEnvelope] +type attackLayer7SummaryIPVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryIPVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryManagedRulesParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7SummaryManagedRulesParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7SummaryManagedRulesParamsFormat] `query:"format"` + // Filter for http method. + HTTPMethod param.Field[[]AttackLayer7SummaryManagedRulesParamsHTTPMethod] `query:"httpMethod"` + // Filter for http version. + HTTPVersion param.Field[[]AttackLayer7SummaryManagedRulesParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer7SummaryManagedRulesParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of L7 mitigation products. + MitigationProduct param.Field[[]AttackLayer7SummaryManagedRulesParamsMitigationProduct] `query:"mitigationProduct"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AttackLayer7SummaryManagedRulesParams]'s query parameters +// as `url.Values`. +func (r AttackLayer7SummaryManagedRulesParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer7SummaryManagedRulesParamsDateRange string + +const ( + AttackLayer7SummaryManagedRulesParamsDateRange1d AttackLayer7SummaryManagedRulesParamsDateRange = "1d" + AttackLayer7SummaryManagedRulesParamsDateRange2d AttackLayer7SummaryManagedRulesParamsDateRange = "2d" + AttackLayer7SummaryManagedRulesParamsDateRange7d AttackLayer7SummaryManagedRulesParamsDateRange = "7d" + AttackLayer7SummaryManagedRulesParamsDateRange14d AttackLayer7SummaryManagedRulesParamsDateRange = "14d" + AttackLayer7SummaryManagedRulesParamsDateRange28d AttackLayer7SummaryManagedRulesParamsDateRange = "28d" + AttackLayer7SummaryManagedRulesParamsDateRange12w AttackLayer7SummaryManagedRulesParamsDateRange = "12w" + AttackLayer7SummaryManagedRulesParamsDateRange24w AttackLayer7SummaryManagedRulesParamsDateRange = "24w" + AttackLayer7SummaryManagedRulesParamsDateRange52w AttackLayer7SummaryManagedRulesParamsDateRange = "52w" + AttackLayer7SummaryManagedRulesParamsDateRange1dControl AttackLayer7SummaryManagedRulesParamsDateRange = "1dControl" + AttackLayer7SummaryManagedRulesParamsDateRange2dControl AttackLayer7SummaryManagedRulesParamsDateRange = "2dControl" + AttackLayer7SummaryManagedRulesParamsDateRange7dControl AttackLayer7SummaryManagedRulesParamsDateRange = "7dControl" + AttackLayer7SummaryManagedRulesParamsDateRange14dControl AttackLayer7SummaryManagedRulesParamsDateRange = "14dControl" + AttackLayer7SummaryManagedRulesParamsDateRange28dControl AttackLayer7SummaryManagedRulesParamsDateRange = "28dControl" + AttackLayer7SummaryManagedRulesParamsDateRange12wControl AttackLayer7SummaryManagedRulesParamsDateRange = "12wControl" + AttackLayer7SummaryManagedRulesParamsDateRange24wControl AttackLayer7SummaryManagedRulesParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7SummaryManagedRulesParamsFormat string + +const ( + AttackLayer7SummaryManagedRulesParamsFormatJson AttackLayer7SummaryManagedRulesParamsFormat = "JSON" + AttackLayer7SummaryManagedRulesParamsFormatCsv AttackLayer7SummaryManagedRulesParamsFormat = "CSV" +) + +type AttackLayer7SummaryManagedRulesParamsHTTPMethod string + +const ( + AttackLayer7SummaryManagedRulesParamsHTTPMethodGet AttackLayer7SummaryManagedRulesParamsHTTPMethod = "GET" + AttackLayer7SummaryManagedRulesParamsHTTPMethodPost AttackLayer7SummaryManagedRulesParamsHTTPMethod = "POST" + AttackLayer7SummaryManagedRulesParamsHTTPMethodDelete AttackLayer7SummaryManagedRulesParamsHTTPMethod = "DELETE" + AttackLayer7SummaryManagedRulesParamsHTTPMethodPut AttackLayer7SummaryManagedRulesParamsHTTPMethod = "PUT" + AttackLayer7SummaryManagedRulesParamsHTTPMethodHead AttackLayer7SummaryManagedRulesParamsHTTPMethod = "HEAD" + AttackLayer7SummaryManagedRulesParamsHTTPMethodPurge AttackLayer7SummaryManagedRulesParamsHTTPMethod = "PURGE" + AttackLayer7SummaryManagedRulesParamsHTTPMethodOptions AttackLayer7SummaryManagedRulesParamsHTTPMethod = "OPTIONS" + AttackLayer7SummaryManagedRulesParamsHTTPMethodPropfind AttackLayer7SummaryManagedRulesParamsHTTPMethod = "PROPFIND" + AttackLayer7SummaryManagedRulesParamsHTTPMethodMkcol AttackLayer7SummaryManagedRulesParamsHTTPMethod = "MKCOL" + AttackLayer7SummaryManagedRulesParamsHTTPMethodPatch AttackLayer7SummaryManagedRulesParamsHTTPMethod = "PATCH" + AttackLayer7SummaryManagedRulesParamsHTTPMethodACL AttackLayer7SummaryManagedRulesParamsHTTPMethod = "ACL" + AttackLayer7SummaryManagedRulesParamsHTTPMethodBcopy AttackLayer7SummaryManagedRulesParamsHTTPMethod = "BCOPY" + AttackLayer7SummaryManagedRulesParamsHTTPMethodBdelete AttackLayer7SummaryManagedRulesParamsHTTPMethod = "BDELETE" + AttackLayer7SummaryManagedRulesParamsHTTPMethodBmove AttackLayer7SummaryManagedRulesParamsHTTPMethod = "BMOVE" + AttackLayer7SummaryManagedRulesParamsHTTPMethodBpropfind AttackLayer7SummaryManagedRulesParamsHTTPMethod = "BPROPFIND" + AttackLayer7SummaryManagedRulesParamsHTTPMethodBproppatch AttackLayer7SummaryManagedRulesParamsHTTPMethod = "BPROPPATCH" + AttackLayer7SummaryManagedRulesParamsHTTPMethodCheckin AttackLayer7SummaryManagedRulesParamsHTTPMethod = "CHECKIN" + AttackLayer7SummaryManagedRulesParamsHTTPMethodCheckout AttackLayer7SummaryManagedRulesParamsHTTPMethod = "CHECKOUT" + AttackLayer7SummaryManagedRulesParamsHTTPMethodConnect AttackLayer7SummaryManagedRulesParamsHTTPMethod = "CONNECT" + AttackLayer7SummaryManagedRulesParamsHTTPMethodCopy AttackLayer7SummaryManagedRulesParamsHTTPMethod = "COPY" + AttackLayer7SummaryManagedRulesParamsHTTPMethodLabel AttackLayer7SummaryManagedRulesParamsHTTPMethod = "LABEL" + AttackLayer7SummaryManagedRulesParamsHTTPMethodLock AttackLayer7SummaryManagedRulesParamsHTTPMethod = "LOCK" + AttackLayer7SummaryManagedRulesParamsHTTPMethodMerge AttackLayer7SummaryManagedRulesParamsHTTPMethod = "MERGE" + AttackLayer7SummaryManagedRulesParamsHTTPMethodMkactivity AttackLayer7SummaryManagedRulesParamsHTTPMethod = "MKACTIVITY" + AttackLayer7SummaryManagedRulesParamsHTTPMethodMkworkspace AttackLayer7SummaryManagedRulesParamsHTTPMethod = "MKWORKSPACE" + AttackLayer7SummaryManagedRulesParamsHTTPMethodMove AttackLayer7SummaryManagedRulesParamsHTTPMethod = "MOVE" + AttackLayer7SummaryManagedRulesParamsHTTPMethodNotify AttackLayer7SummaryManagedRulesParamsHTTPMethod = "NOTIFY" + AttackLayer7SummaryManagedRulesParamsHTTPMethodOrderpatch AttackLayer7SummaryManagedRulesParamsHTTPMethod = "ORDERPATCH" + AttackLayer7SummaryManagedRulesParamsHTTPMethodPoll AttackLayer7SummaryManagedRulesParamsHTTPMethod = "POLL" + AttackLayer7SummaryManagedRulesParamsHTTPMethodProppatch AttackLayer7SummaryManagedRulesParamsHTTPMethod = "PROPPATCH" + AttackLayer7SummaryManagedRulesParamsHTTPMethodReport AttackLayer7SummaryManagedRulesParamsHTTPMethod = "REPORT" + AttackLayer7SummaryManagedRulesParamsHTTPMethodSearch AttackLayer7SummaryManagedRulesParamsHTTPMethod = "SEARCH" + AttackLayer7SummaryManagedRulesParamsHTTPMethodSubscribe AttackLayer7SummaryManagedRulesParamsHTTPMethod = "SUBSCRIBE" + AttackLayer7SummaryManagedRulesParamsHTTPMethodTrace AttackLayer7SummaryManagedRulesParamsHTTPMethod = "TRACE" + AttackLayer7SummaryManagedRulesParamsHTTPMethodUncheckout AttackLayer7SummaryManagedRulesParamsHTTPMethod = "UNCHECKOUT" + AttackLayer7SummaryManagedRulesParamsHTTPMethodUnlock AttackLayer7SummaryManagedRulesParamsHTTPMethod = "UNLOCK" + AttackLayer7SummaryManagedRulesParamsHTTPMethodUnsubscribe AttackLayer7SummaryManagedRulesParamsHTTPMethod = "UNSUBSCRIBE" + AttackLayer7SummaryManagedRulesParamsHTTPMethodUpdate AttackLayer7SummaryManagedRulesParamsHTTPMethod = "UPDATE" + AttackLayer7SummaryManagedRulesParamsHTTPMethodVersioncontrol AttackLayer7SummaryManagedRulesParamsHTTPMethod = "VERSIONCONTROL" + AttackLayer7SummaryManagedRulesParamsHTTPMethodBaselinecontrol AttackLayer7SummaryManagedRulesParamsHTTPMethod = "BASELINECONTROL" + AttackLayer7SummaryManagedRulesParamsHTTPMethodXmsenumatts AttackLayer7SummaryManagedRulesParamsHTTPMethod = "XMSENUMATTS" + AttackLayer7SummaryManagedRulesParamsHTTPMethodRpcOutData AttackLayer7SummaryManagedRulesParamsHTTPMethod = "RPC_OUT_DATA" + AttackLayer7SummaryManagedRulesParamsHTTPMethodRpcInData AttackLayer7SummaryManagedRulesParamsHTTPMethod = "RPC_IN_DATA" + AttackLayer7SummaryManagedRulesParamsHTTPMethodJson AttackLayer7SummaryManagedRulesParamsHTTPMethod = "JSON" + AttackLayer7SummaryManagedRulesParamsHTTPMethodCook AttackLayer7SummaryManagedRulesParamsHTTPMethod = "COOK" + AttackLayer7SummaryManagedRulesParamsHTTPMethodTrack AttackLayer7SummaryManagedRulesParamsHTTPMethod = "TRACK" +) + +type AttackLayer7SummaryManagedRulesParamsHTTPVersion string + +const ( + AttackLayer7SummaryManagedRulesParamsHTTPVersionHttPv1 AttackLayer7SummaryManagedRulesParamsHTTPVersion = "HTTPv1" + AttackLayer7SummaryManagedRulesParamsHTTPVersionHttPv2 AttackLayer7SummaryManagedRulesParamsHTTPVersion = "HTTPv2" + AttackLayer7SummaryManagedRulesParamsHTTPVersionHttPv3 AttackLayer7SummaryManagedRulesParamsHTTPVersion = "HTTPv3" +) + +type AttackLayer7SummaryManagedRulesParamsIPVersion string + +const ( + AttackLayer7SummaryManagedRulesParamsIPVersionIPv4 AttackLayer7SummaryManagedRulesParamsIPVersion = "IPv4" + AttackLayer7SummaryManagedRulesParamsIPVersionIPv6 AttackLayer7SummaryManagedRulesParamsIPVersion = "IPv6" +) + +type AttackLayer7SummaryManagedRulesParamsMitigationProduct string + +const ( + AttackLayer7SummaryManagedRulesParamsMitigationProductDDOS AttackLayer7SummaryManagedRulesParamsMitigationProduct = "DDOS" + AttackLayer7SummaryManagedRulesParamsMitigationProductWAF AttackLayer7SummaryManagedRulesParamsMitigationProduct = "WAF" + AttackLayer7SummaryManagedRulesParamsMitigationProductBotManagement AttackLayer7SummaryManagedRulesParamsMitigationProduct = "BOT_MANAGEMENT" + AttackLayer7SummaryManagedRulesParamsMitigationProductAccessRules AttackLayer7SummaryManagedRulesParamsMitigationProduct = "ACCESS_RULES" + AttackLayer7SummaryManagedRulesParamsMitigationProductIPReputation AttackLayer7SummaryManagedRulesParamsMitigationProduct = "IP_REPUTATION" + AttackLayer7SummaryManagedRulesParamsMitigationProductAPIShield AttackLayer7SummaryManagedRulesParamsMitigationProduct = "API_SHIELD" + AttackLayer7SummaryManagedRulesParamsMitigationProductDataLossPrevention AttackLayer7SummaryManagedRulesParamsMitigationProduct = "DATA_LOSS_PREVENTION" +) + +type AttackLayer7SummaryManagedRulesResponseEnvelope struct { + Result AttackLayer7SummaryManagedRulesResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7SummaryManagedRulesResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7SummaryManagedRulesResponseEnvelopeJSON contains the JSON metadata +// for the struct [AttackLayer7SummaryManagedRulesResponseEnvelope] +type attackLayer7SummaryManagedRulesResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryManagedRulesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryManagedRulesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7SummaryMitigationProductParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7SummaryMitigationProductParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7SummaryMitigationProductParamsFormat] `query:"format"` + // Filter for http method. + HTTPMethod param.Field[[]AttackLayer7SummaryMitigationProductParamsHTTPMethod] `query:"httpMethod"` + // Filter for http version. + HTTPVersion param.Field[[]AttackLayer7SummaryMitigationProductParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer7SummaryMitigationProductParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AttackLayer7SummaryMitigationProductParams]'s query +// parameters as `url.Values`. +func (r AttackLayer7SummaryMitigationProductParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer7SummaryMitigationProductParamsDateRange string + +const ( + AttackLayer7SummaryMitigationProductParamsDateRange1d AttackLayer7SummaryMitigationProductParamsDateRange = "1d" + AttackLayer7SummaryMitigationProductParamsDateRange2d AttackLayer7SummaryMitigationProductParamsDateRange = "2d" + AttackLayer7SummaryMitigationProductParamsDateRange7d AttackLayer7SummaryMitigationProductParamsDateRange = "7d" + AttackLayer7SummaryMitigationProductParamsDateRange14d AttackLayer7SummaryMitigationProductParamsDateRange = "14d" + AttackLayer7SummaryMitigationProductParamsDateRange28d AttackLayer7SummaryMitigationProductParamsDateRange = "28d" + AttackLayer7SummaryMitigationProductParamsDateRange12w AttackLayer7SummaryMitigationProductParamsDateRange = "12w" + AttackLayer7SummaryMitigationProductParamsDateRange24w AttackLayer7SummaryMitigationProductParamsDateRange = "24w" + AttackLayer7SummaryMitigationProductParamsDateRange52w AttackLayer7SummaryMitigationProductParamsDateRange = "52w" + AttackLayer7SummaryMitigationProductParamsDateRange1dControl AttackLayer7SummaryMitigationProductParamsDateRange = "1dControl" + AttackLayer7SummaryMitigationProductParamsDateRange2dControl AttackLayer7SummaryMitigationProductParamsDateRange = "2dControl" + AttackLayer7SummaryMitigationProductParamsDateRange7dControl AttackLayer7SummaryMitigationProductParamsDateRange = "7dControl" + AttackLayer7SummaryMitigationProductParamsDateRange14dControl AttackLayer7SummaryMitigationProductParamsDateRange = "14dControl" + AttackLayer7SummaryMitigationProductParamsDateRange28dControl AttackLayer7SummaryMitigationProductParamsDateRange = "28dControl" + AttackLayer7SummaryMitigationProductParamsDateRange12wControl AttackLayer7SummaryMitigationProductParamsDateRange = "12wControl" + AttackLayer7SummaryMitigationProductParamsDateRange24wControl AttackLayer7SummaryMitigationProductParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7SummaryMitigationProductParamsFormat string + +const ( + AttackLayer7SummaryMitigationProductParamsFormatJson AttackLayer7SummaryMitigationProductParamsFormat = "JSON" + AttackLayer7SummaryMitigationProductParamsFormatCsv AttackLayer7SummaryMitigationProductParamsFormat = "CSV" +) + +type AttackLayer7SummaryMitigationProductParamsHTTPMethod string + +const ( + AttackLayer7SummaryMitigationProductParamsHTTPMethodGet AttackLayer7SummaryMitigationProductParamsHTTPMethod = "GET" + AttackLayer7SummaryMitigationProductParamsHTTPMethodPost AttackLayer7SummaryMitigationProductParamsHTTPMethod = "POST" + AttackLayer7SummaryMitigationProductParamsHTTPMethodDelete AttackLayer7SummaryMitigationProductParamsHTTPMethod = "DELETE" + AttackLayer7SummaryMitigationProductParamsHTTPMethodPut AttackLayer7SummaryMitigationProductParamsHTTPMethod = "PUT" + AttackLayer7SummaryMitigationProductParamsHTTPMethodHead AttackLayer7SummaryMitigationProductParamsHTTPMethod = "HEAD" + AttackLayer7SummaryMitigationProductParamsHTTPMethodPurge AttackLayer7SummaryMitigationProductParamsHTTPMethod = "PURGE" + AttackLayer7SummaryMitigationProductParamsHTTPMethodOptions AttackLayer7SummaryMitigationProductParamsHTTPMethod = "OPTIONS" + AttackLayer7SummaryMitigationProductParamsHTTPMethodPropfind AttackLayer7SummaryMitigationProductParamsHTTPMethod = "PROPFIND" + AttackLayer7SummaryMitigationProductParamsHTTPMethodMkcol AttackLayer7SummaryMitigationProductParamsHTTPMethod = "MKCOL" + AttackLayer7SummaryMitigationProductParamsHTTPMethodPatch AttackLayer7SummaryMitigationProductParamsHTTPMethod = "PATCH" + AttackLayer7SummaryMitigationProductParamsHTTPMethodACL AttackLayer7SummaryMitigationProductParamsHTTPMethod = "ACL" + AttackLayer7SummaryMitigationProductParamsHTTPMethodBcopy AttackLayer7SummaryMitigationProductParamsHTTPMethod = "BCOPY" + AttackLayer7SummaryMitigationProductParamsHTTPMethodBdelete AttackLayer7SummaryMitigationProductParamsHTTPMethod = "BDELETE" + AttackLayer7SummaryMitigationProductParamsHTTPMethodBmove AttackLayer7SummaryMitigationProductParamsHTTPMethod = "BMOVE" + AttackLayer7SummaryMitigationProductParamsHTTPMethodBpropfind AttackLayer7SummaryMitigationProductParamsHTTPMethod = "BPROPFIND" + AttackLayer7SummaryMitigationProductParamsHTTPMethodBproppatch AttackLayer7SummaryMitigationProductParamsHTTPMethod = "BPROPPATCH" + AttackLayer7SummaryMitigationProductParamsHTTPMethodCheckin AttackLayer7SummaryMitigationProductParamsHTTPMethod = "CHECKIN" + AttackLayer7SummaryMitigationProductParamsHTTPMethodCheckout AttackLayer7SummaryMitigationProductParamsHTTPMethod = "CHECKOUT" + AttackLayer7SummaryMitigationProductParamsHTTPMethodConnect AttackLayer7SummaryMitigationProductParamsHTTPMethod = "CONNECT" + AttackLayer7SummaryMitigationProductParamsHTTPMethodCopy AttackLayer7SummaryMitigationProductParamsHTTPMethod = "COPY" + AttackLayer7SummaryMitigationProductParamsHTTPMethodLabel AttackLayer7SummaryMitigationProductParamsHTTPMethod = "LABEL" + AttackLayer7SummaryMitigationProductParamsHTTPMethodLock AttackLayer7SummaryMitigationProductParamsHTTPMethod = "LOCK" + AttackLayer7SummaryMitigationProductParamsHTTPMethodMerge AttackLayer7SummaryMitigationProductParamsHTTPMethod = "MERGE" + AttackLayer7SummaryMitigationProductParamsHTTPMethodMkactivity AttackLayer7SummaryMitigationProductParamsHTTPMethod = "MKACTIVITY" + AttackLayer7SummaryMitigationProductParamsHTTPMethodMkworkspace AttackLayer7SummaryMitigationProductParamsHTTPMethod = "MKWORKSPACE" + AttackLayer7SummaryMitigationProductParamsHTTPMethodMove AttackLayer7SummaryMitigationProductParamsHTTPMethod = "MOVE" + AttackLayer7SummaryMitigationProductParamsHTTPMethodNotify AttackLayer7SummaryMitigationProductParamsHTTPMethod = "NOTIFY" + AttackLayer7SummaryMitigationProductParamsHTTPMethodOrderpatch AttackLayer7SummaryMitigationProductParamsHTTPMethod = "ORDERPATCH" + AttackLayer7SummaryMitigationProductParamsHTTPMethodPoll AttackLayer7SummaryMitigationProductParamsHTTPMethod = "POLL" + AttackLayer7SummaryMitigationProductParamsHTTPMethodProppatch AttackLayer7SummaryMitigationProductParamsHTTPMethod = "PROPPATCH" + AttackLayer7SummaryMitigationProductParamsHTTPMethodReport AttackLayer7SummaryMitigationProductParamsHTTPMethod = "REPORT" + AttackLayer7SummaryMitigationProductParamsHTTPMethodSearch AttackLayer7SummaryMitigationProductParamsHTTPMethod = "SEARCH" + AttackLayer7SummaryMitigationProductParamsHTTPMethodSubscribe AttackLayer7SummaryMitigationProductParamsHTTPMethod = "SUBSCRIBE" + AttackLayer7SummaryMitigationProductParamsHTTPMethodTrace AttackLayer7SummaryMitigationProductParamsHTTPMethod = "TRACE" + AttackLayer7SummaryMitigationProductParamsHTTPMethodUncheckout AttackLayer7SummaryMitigationProductParamsHTTPMethod = "UNCHECKOUT" + AttackLayer7SummaryMitigationProductParamsHTTPMethodUnlock AttackLayer7SummaryMitigationProductParamsHTTPMethod = "UNLOCK" + AttackLayer7SummaryMitigationProductParamsHTTPMethodUnsubscribe AttackLayer7SummaryMitigationProductParamsHTTPMethod = "UNSUBSCRIBE" + AttackLayer7SummaryMitigationProductParamsHTTPMethodUpdate AttackLayer7SummaryMitigationProductParamsHTTPMethod = "UPDATE" + AttackLayer7SummaryMitigationProductParamsHTTPMethodVersioncontrol AttackLayer7SummaryMitigationProductParamsHTTPMethod = "VERSIONCONTROL" + AttackLayer7SummaryMitigationProductParamsHTTPMethodBaselinecontrol AttackLayer7SummaryMitigationProductParamsHTTPMethod = "BASELINECONTROL" + AttackLayer7SummaryMitigationProductParamsHTTPMethodXmsenumatts AttackLayer7SummaryMitigationProductParamsHTTPMethod = "XMSENUMATTS" + AttackLayer7SummaryMitigationProductParamsHTTPMethodRpcOutData AttackLayer7SummaryMitigationProductParamsHTTPMethod = "RPC_OUT_DATA" + AttackLayer7SummaryMitigationProductParamsHTTPMethodRpcInData AttackLayer7SummaryMitigationProductParamsHTTPMethod = "RPC_IN_DATA" + AttackLayer7SummaryMitigationProductParamsHTTPMethodJson AttackLayer7SummaryMitigationProductParamsHTTPMethod = "JSON" + AttackLayer7SummaryMitigationProductParamsHTTPMethodCook AttackLayer7SummaryMitigationProductParamsHTTPMethod = "COOK" + AttackLayer7SummaryMitigationProductParamsHTTPMethodTrack AttackLayer7SummaryMitigationProductParamsHTTPMethod = "TRACK" +) + +type AttackLayer7SummaryMitigationProductParamsHTTPVersion string + +const ( + AttackLayer7SummaryMitigationProductParamsHTTPVersionHttPv1 AttackLayer7SummaryMitigationProductParamsHTTPVersion = "HTTPv1" + AttackLayer7SummaryMitigationProductParamsHTTPVersionHttPv2 AttackLayer7SummaryMitigationProductParamsHTTPVersion = "HTTPv2" + AttackLayer7SummaryMitigationProductParamsHTTPVersionHttPv3 AttackLayer7SummaryMitigationProductParamsHTTPVersion = "HTTPv3" +) + +type AttackLayer7SummaryMitigationProductParamsIPVersion string + +const ( + AttackLayer7SummaryMitigationProductParamsIPVersionIPv4 AttackLayer7SummaryMitigationProductParamsIPVersion = "IPv4" + AttackLayer7SummaryMitigationProductParamsIPVersionIPv6 AttackLayer7SummaryMitigationProductParamsIPVersion = "IPv6" +) + +type AttackLayer7SummaryMitigationProductResponseEnvelope struct { + Result AttackLayer7SummaryMitigationProductResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7SummaryMitigationProductResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7SummaryMitigationProductResponseEnvelopeJSON contains the JSON +// metadata for the struct [AttackLayer7SummaryMitigationProductResponseEnvelope] +type attackLayer7SummaryMitigationProductResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7SummaryMitigationProductResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7SummaryMitigationProductResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/attacklayer7summary_test.go b/radar/attacklayer7summary_test.go new file mode 100644 index 00000000000..b15f4c2d571 --- /dev/null +++ b/radar/attacklayer7summary_test.go @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestAttackLayer7SummaryGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.Summary.Get(context.TODO(), radar.AttackLayer7SummaryGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7SummaryGetParamsDateRange{radar.AttackLayer7SummaryGetParamsDateRange1d, radar.AttackLayer7SummaryGetParamsDateRange2d, radar.AttackLayer7SummaryGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7SummaryGetParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAttackLayer7SummaryHTTPMethodWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.Summary.HTTPMethod(context.TODO(), radar.AttackLayer7SummaryHTTPMethodParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7SummaryHTTPMethodParamsDateRange{radar.AttackLayer7SummaryHTTPMethodParamsDateRange1d, radar.AttackLayer7SummaryHTTPMethodParamsDateRange2d, radar.AttackLayer7SummaryHTTPMethodParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7SummaryHTTPMethodParamsFormatJson), + HTTPVersion: cloudflare.F([]radar.AttackLayer7SummaryHTTPMethodParamsHTTPVersion{radar.AttackLayer7SummaryHTTPMethodParamsHTTPVersionHttPv1, radar.AttackLayer7SummaryHTTPMethodParamsHTTPVersionHttPv2, radar.AttackLayer7SummaryHTTPMethodParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.AttackLayer7SummaryHTTPMethodParamsIPVersion{radar.AttackLayer7SummaryHTTPMethodParamsIPVersionIPv4, radar.AttackLayer7SummaryHTTPMethodParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + MitigationProduct: cloudflare.F([]radar.AttackLayer7SummaryHTTPMethodParamsMitigationProduct{radar.AttackLayer7SummaryHTTPMethodParamsMitigationProductDDOS, radar.AttackLayer7SummaryHTTPMethodParamsMitigationProductWAF, radar.AttackLayer7SummaryHTTPMethodParamsMitigationProductBotManagement}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAttackLayer7SummaryHTTPVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.Summary.HTTPVersion(context.TODO(), radar.AttackLayer7SummaryHTTPVersionParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7SummaryHTTPVersionParamsDateRange{radar.AttackLayer7SummaryHTTPVersionParamsDateRange1d, radar.AttackLayer7SummaryHTTPVersionParamsDateRange2d, radar.AttackLayer7SummaryHTTPVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7SummaryHTTPVersionParamsFormatJson), + HTTPMethod: cloudflare.F([]radar.AttackLayer7SummaryHTTPVersionParamsHTTPMethod{radar.AttackLayer7SummaryHTTPVersionParamsHTTPMethodGet, radar.AttackLayer7SummaryHTTPVersionParamsHTTPMethodPost, radar.AttackLayer7SummaryHTTPVersionParamsHTTPMethodDelete}), + IPVersion: cloudflare.F([]radar.AttackLayer7SummaryHTTPVersionParamsIPVersion{radar.AttackLayer7SummaryHTTPVersionParamsIPVersionIPv4, radar.AttackLayer7SummaryHTTPVersionParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + MitigationProduct: cloudflare.F([]radar.AttackLayer7SummaryHTTPVersionParamsMitigationProduct{radar.AttackLayer7SummaryHTTPVersionParamsMitigationProductDDOS, radar.AttackLayer7SummaryHTTPVersionParamsMitigationProductWAF, radar.AttackLayer7SummaryHTTPVersionParamsMitigationProductBotManagement}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAttackLayer7SummaryIPVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.Summary.IPVersion(context.TODO(), radar.AttackLayer7SummaryIPVersionParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7SummaryIPVersionParamsDateRange{radar.AttackLayer7SummaryIPVersionParamsDateRange1d, radar.AttackLayer7SummaryIPVersionParamsDateRange2d, radar.AttackLayer7SummaryIPVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7SummaryIPVersionParamsFormatJson), + HTTPMethod: cloudflare.F([]radar.AttackLayer7SummaryIPVersionParamsHTTPMethod{radar.AttackLayer7SummaryIPVersionParamsHTTPMethodGet, radar.AttackLayer7SummaryIPVersionParamsHTTPMethodPost, radar.AttackLayer7SummaryIPVersionParamsHTTPMethodDelete}), + HTTPVersion: cloudflare.F([]radar.AttackLayer7SummaryIPVersionParamsHTTPVersion{radar.AttackLayer7SummaryIPVersionParamsHTTPVersionHttPv1, radar.AttackLayer7SummaryIPVersionParamsHTTPVersionHttPv2, radar.AttackLayer7SummaryIPVersionParamsHTTPVersionHttPv3}), + Location: cloudflare.F([]string{"string", "string", "string"}), + MitigationProduct: cloudflare.F([]radar.AttackLayer7SummaryIPVersionParamsMitigationProduct{radar.AttackLayer7SummaryIPVersionParamsMitigationProductDDOS, radar.AttackLayer7SummaryIPVersionParamsMitigationProductWAF, radar.AttackLayer7SummaryIPVersionParamsMitigationProductBotManagement}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAttackLayer7SummaryManagedRulesWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.Summary.ManagedRules(context.TODO(), radar.AttackLayer7SummaryManagedRulesParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7SummaryManagedRulesParamsDateRange{radar.AttackLayer7SummaryManagedRulesParamsDateRange1d, radar.AttackLayer7SummaryManagedRulesParamsDateRange2d, radar.AttackLayer7SummaryManagedRulesParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7SummaryManagedRulesParamsFormatJson), + HTTPMethod: cloudflare.F([]radar.AttackLayer7SummaryManagedRulesParamsHTTPMethod{radar.AttackLayer7SummaryManagedRulesParamsHTTPMethodGet, radar.AttackLayer7SummaryManagedRulesParamsHTTPMethodPost, radar.AttackLayer7SummaryManagedRulesParamsHTTPMethodDelete}), + HTTPVersion: cloudflare.F([]radar.AttackLayer7SummaryManagedRulesParamsHTTPVersion{radar.AttackLayer7SummaryManagedRulesParamsHTTPVersionHttPv1, radar.AttackLayer7SummaryManagedRulesParamsHTTPVersionHttPv2, radar.AttackLayer7SummaryManagedRulesParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.AttackLayer7SummaryManagedRulesParamsIPVersion{radar.AttackLayer7SummaryManagedRulesParamsIPVersionIPv4, radar.AttackLayer7SummaryManagedRulesParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + MitigationProduct: cloudflare.F([]radar.AttackLayer7SummaryManagedRulesParamsMitigationProduct{radar.AttackLayer7SummaryManagedRulesParamsMitigationProductDDOS, radar.AttackLayer7SummaryManagedRulesParamsMitigationProductWAF, radar.AttackLayer7SummaryManagedRulesParamsMitigationProductBotManagement}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAttackLayer7SummaryMitigationProductWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.Summary.MitigationProduct(context.TODO(), radar.AttackLayer7SummaryMitigationProductParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7SummaryMitigationProductParamsDateRange{radar.AttackLayer7SummaryMitigationProductParamsDateRange1d, radar.AttackLayer7SummaryMitigationProductParamsDateRange2d, radar.AttackLayer7SummaryMitigationProductParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7SummaryMitigationProductParamsFormatJson), + HTTPMethod: cloudflare.F([]radar.AttackLayer7SummaryMitigationProductParamsHTTPMethod{radar.AttackLayer7SummaryMitigationProductParamsHTTPMethodGet, radar.AttackLayer7SummaryMitigationProductParamsHTTPMethodPost, radar.AttackLayer7SummaryMitigationProductParamsHTTPMethodDelete}), + HTTPVersion: cloudflare.F([]radar.AttackLayer7SummaryMitigationProductParamsHTTPVersion{radar.AttackLayer7SummaryMitigationProductParamsHTTPVersionHttPv1, radar.AttackLayer7SummaryMitigationProductParamsHTTPVersionHttPv2, radar.AttackLayer7SummaryMitigationProductParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.AttackLayer7SummaryMitigationProductParamsIPVersion{radar.AttackLayer7SummaryMitigationProductParamsIPVersionIPv4, radar.AttackLayer7SummaryMitigationProductParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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/radar/attacklayer7timeseriesgroup.go b/radar/attacklayer7timeseriesgroup.go new file mode 100644 index 00000000000..e2ea7f3fbe6 --- /dev/null +++ b/radar/attacklayer7timeseriesgroup.go @@ -0,0 +1,2062 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AttackLayer7TimeseriesGroupService 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 +// [NewAttackLayer7TimeseriesGroupService] method instead. +type AttackLayer7TimeseriesGroupService struct { + Options []option.RequestOption +} + +// NewAttackLayer7TimeseriesGroupService 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 NewAttackLayer7TimeseriesGroupService(opts ...option.RequestOption) (r *AttackLayer7TimeseriesGroupService) { + r = &AttackLayer7TimeseriesGroupService{} + r.Options = opts + return +} + +// Get a time series of the percentual distribution of mitigation techniques, over +// time. +func (r *AttackLayer7TimeseriesGroupService) Get(ctx context.Context, query AttackLayer7TimeseriesGroupGetParams, opts ...option.RequestOption) (res *AttackLayer7TimeseriesGroupGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7TimeseriesGroupGetResponseEnvelope + path := "radar/attacks/layer7/timeseries_groups" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by http method used over time. +func (r *AttackLayer7TimeseriesGroupService) HTTPMethod(ctx context.Context, query AttackLayer7TimeseriesGroupHTTPMethodParams, opts ...option.RequestOption) (res *AttackLayer7TimeseriesGroupHTTPMethodResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7TimeseriesGroupHTTPMethodResponseEnvelope + path := "radar/attacks/layer7/timeseries_groups/http_method" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by http version used over time. +func (r *AttackLayer7TimeseriesGroupService) HTTPVersion(ctx context.Context, query AttackLayer7TimeseriesGroupHTTPVersionParams, opts ...option.RequestOption) (res *AttackLayer7TimeseriesGroupHTTPVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7TimeseriesGroupHTTPVersionResponseEnvelope + path := "radar/attacks/layer7/timeseries_groups/http_version" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by industry used over time. +func (r *AttackLayer7TimeseriesGroupService) Industry(ctx context.Context, query AttackLayer7TimeseriesGroupIndustryParams, opts ...option.RequestOption) (res *AttackLayer7TimeseriesGroupIndustryResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7TimeseriesGroupIndustryResponseEnvelope + path := "radar/attacks/layer7/timeseries_groups/industry" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by ip version used over time. +func (r *AttackLayer7TimeseriesGroupService) IPVersion(ctx context.Context, query AttackLayer7TimeseriesGroupIPVersionParams, opts ...option.RequestOption) (res *AttackLayer7TimeseriesGroupIPVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7TimeseriesGroupIPVersionResponseEnvelope + path := "radar/attacks/layer7/timeseries_groups/ip_version" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by managed rules used over time. +func (r *AttackLayer7TimeseriesGroupService) ManagedRules(ctx context.Context, query AttackLayer7TimeseriesGroupManagedRulesParams, opts ...option.RequestOption) (res *AttackLayer7TimeseriesGroupManagedRulesResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7TimeseriesGroupManagedRulesResponseEnvelope + path := "radar/attacks/layer7/timeseries_groups/managed_rules" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by mitigation product used over time. +func (r *AttackLayer7TimeseriesGroupService) MitigationProduct(ctx context.Context, query AttackLayer7TimeseriesGroupMitigationProductParams, opts ...option.RequestOption) (res *AttackLayer7TimeseriesGroupMitigationProductResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7TimeseriesGroupMitigationProductResponseEnvelope + path := "radar/attacks/layer7/timeseries_groups/mitigation_product" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of attacks by vertical used over time. +func (r *AttackLayer7TimeseriesGroupService) Vertical(ctx context.Context, query AttackLayer7TimeseriesGroupVerticalParams, opts ...option.RequestOption) (res *AttackLayer7TimeseriesGroupVerticalResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7TimeseriesGroupVerticalResponseEnvelope + path := "radar/attacks/layer7/timeseries_groups/vertical" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AttackLayer7TimeseriesGroupGetResponse struct { + Meta AttackLayer7TimeseriesGroupGetResponseMeta `json:"meta,required"` + Serie0 AttackLayer7TimeseriesGroupGetResponseSerie0 `json:"serie_0,required"` + JSON attackLayer7TimeseriesGroupGetResponseJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupGetResponseJSON contains the JSON metadata for the +// struct [AttackLayer7TimeseriesGroupGetResponse] +type attackLayer7TimeseriesGroupGetResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupGetResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupGetResponseMeta struct { + AggInterval string `json:"aggInterval,required"` + DateRange []AttackLayer7TimeseriesGroupGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated time.Time `json:"lastUpdated,required" format:"date-time"` + ConfidenceInfo AttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer7TimeseriesGroupGetResponseMetaJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupGetResponseMetaJSON contains the JSON metadata for +// the struct [AttackLayer7TimeseriesGroupGetResponseMeta] +type attackLayer7TimeseriesGroupGetResponseMetaJSON struct { + AggInterval apijson.Field + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer7TimeseriesGroupGetResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupGetResponseMetaDateRangeJSON contains the JSON +// metadata for the struct [AttackLayer7TimeseriesGroupGetResponseMetaDateRange] +type attackLayer7TimeseriesGroupGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfo struct { + Annotations []AttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct +// [AttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfo] +type attackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoAnnotationJSON contains +// the JSON metadata for the struct +// [AttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoAnnotation] +type attackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupGetResponseSerie0 struct { + AccessRules []string `json:"ACCESS_RULES,required"` + APIShield []string `json:"API_SHIELD,required"` + BotManagement []string `json:"BOT_MANAGEMENT,required"` + DataLossPrevention []string `json:"DATA_LOSS_PREVENTION,required"` + DDOS []string `json:"DDOS,required"` + IPReputation []string `json:"IP_REPUTATION,required"` + Timestamps []time.Time `json:"timestamps,required" format:"date-time"` + WAF []string `json:"WAF,required"` + JSON attackLayer7TimeseriesGroupGetResponseSerie0JSON `json:"-"` +} + +// attackLayer7TimeseriesGroupGetResponseSerie0JSON contains the JSON metadata for +// the struct [AttackLayer7TimeseriesGroupGetResponseSerie0] +type attackLayer7TimeseriesGroupGetResponseSerie0JSON struct { + AccessRules apijson.Field + APIShield apijson.Field + BotManagement apijson.Field + DataLossPrevention apijson.Field + DDOS apijson.Field + IPReputation apijson.Field + Timestamps apijson.Field + WAF apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupGetResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupGetResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupHTTPMethodResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AttackLayer7TimeseriesGroupHTTPMethodResponseSerie0 `json:"serie_0,required"` + JSON attackLayer7TimeseriesGroupHTTPMethodResponseJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupHTTPMethodResponseJSON contains the JSON metadata for +// the struct [AttackLayer7TimeseriesGroupHTTPMethodResponse] +type attackLayer7TimeseriesGroupHTTPMethodResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupHTTPMethodResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupHTTPMethodResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupHTTPMethodResponseSerie0 struct { + Get []string `json:"GET,required"` + Timestamps []string `json:"timestamps,required"` + JSON attackLayer7TimeseriesGroupHTTPMethodResponseSerie0JSON `json:"-"` +} + +// attackLayer7TimeseriesGroupHTTPMethodResponseSerie0JSON contains the JSON +// metadata for the struct [AttackLayer7TimeseriesGroupHTTPMethodResponseSerie0] +type attackLayer7TimeseriesGroupHTTPMethodResponseSerie0JSON struct { + Get apijson.Field + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupHTTPMethodResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupHTTPMethodResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupHTTPVersionResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AttackLayer7TimeseriesGroupHTTPVersionResponseSerie0 `json:"serie_0,required"` + JSON attackLayer7TimeseriesGroupHTTPVersionResponseJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupHTTPVersionResponseJSON contains the JSON metadata +// for the struct [AttackLayer7TimeseriesGroupHTTPVersionResponse] +type attackLayer7TimeseriesGroupHTTPVersionResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupHTTPVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupHTTPVersionResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupHTTPVersionResponseSerie0 struct { + HTTP1X []string `json:"HTTP/1.x,required"` + Timestamps []string `json:"timestamps,required"` + JSON attackLayer7TimeseriesGroupHTTPVersionResponseSerie0JSON `json:"-"` +} + +// attackLayer7TimeseriesGroupHTTPVersionResponseSerie0JSON contains the JSON +// metadata for the struct [AttackLayer7TimeseriesGroupHTTPVersionResponseSerie0] +type attackLayer7TimeseriesGroupHTTPVersionResponseSerie0JSON struct { + HTTP1X apijson.Field + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupHTTPVersionResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupHTTPVersionResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupIndustryResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AttackLayer7TimeseriesGroupIndustryResponseSerie0 `json:"serie_0,required"` + JSON attackLayer7TimeseriesGroupIndustryResponseJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupIndustryResponseJSON contains the JSON metadata for +// the struct [AttackLayer7TimeseriesGroupIndustryResponse] +type attackLayer7TimeseriesGroupIndustryResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupIndustryResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupIndustryResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupIndustryResponseSerie0 struct { + Timestamps []string `json:"timestamps,required"` + ExtraFields map[string][]string `json:"-,extras"` + JSON attackLayer7TimeseriesGroupIndustryResponseSerie0JSON `json:"-"` +} + +// attackLayer7TimeseriesGroupIndustryResponseSerie0JSON contains the JSON metadata +// for the struct [AttackLayer7TimeseriesGroupIndustryResponseSerie0] +type attackLayer7TimeseriesGroupIndustryResponseSerie0JSON struct { + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupIndustryResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupIndustryResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupIPVersionResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AttackLayer7TimeseriesGroupIPVersionResponseSerie0 `json:"serie_0,required"` + JSON attackLayer7TimeseriesGroupIPVersionResponseJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupIPVersionResponseJSON contains the JSON metadata for +// the struct [AttackLayer7TimeseriesGroupIPVersionResponse] +type attackLayer7TimeseriesGroupIPVersionResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupIPVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupIPVersionResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupIPVersionResponseSerie0 struct { + IPv4 []string `json:"IPv4,required"` + IPv6 []string `json:"IPv6,required"` + Timestamps []string `json:"timestamps,required"` + JSON attackLayer7TimeseriesGroupIPVersionResponseSerie0JSON `json:"-"` +} + +// attackLayer7TimeseriesGroupIPVersionResponseSerie0JSON contains the JSON +// metadata for the struct [AttackLayer7TimeseriesGroupIPVersionResponseSerie0] +type attackLayer7TimeseriesGroupIPVersionResponseSerie0JSON struct { + IPv4 apijson.Field + IPv6 apijson.Field + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupIPVersionResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupIPVersionResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupManagedRulesResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AttackLayer7TimeseriesGroupManagedRulesResponseSerie0 `json:"serie_0,required"` + JSON attackLayer7TimeseriesGroupManagedRulesResponseJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupManagedRulesResponseJSON contains the JSON metadata +// for the struct [AttackLayer7TimeseriesGroupManagedRulesResponse] +type attackLayer7TimeseriesGroupManagedRulesResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupManagedRulesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupManagedRulesResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupManagedRulesResponseSerie0 struct { + Bot []string `json:"Bot,required"` + Timestamps []string `json:"timestamps,required"` + JSON attackLayer7TimeseriesGroupManagedRulesResponseSerie0JSON `json:"-"` +} + +// attackLayer7TimeseriesGroupManagedRulesResponseSerie0JSON contains the JSON +// metadata for the struct [AttackLayer7TimeseriesGroupManagedRulesResponseSerie0] +type attackLayer7TimeseriesGroupManagedRulesResponseSerie0JSON struct { + Bot apijson.Field + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupManagedRulesResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupManagedRulesResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupMitigationProductResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AttackLayer7TimeseriesGroupMitigationProductResponseSerie0 `json:"serie_0,required"` + JSON attackLayer7TimeseriesGroupMitigationProductResponseJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupMitigationProductResponseJSON contains the JSON +// metadata for the struct [AttackLayer7TimeseriesGroupMitigationProductResponse] +type attackLayer7TimeseriesGroupMitigationProductResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupMitigationProductResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupMitigationProductResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupMitigationProductResponseSerie0 struct { + DDOS []string `json:"DDOS,required"` + Timestamps []string `json:"timestamps,required"` + JSON attackLayer7TimeseriesGroupMitigationProductResponseSerie0JSON `json:"-"` +} + +// attackLayer7TimeseriesGroupMitigationProductResponseSerie0JSON contains the JSON +// metadata for the struct +// [AttackLayer7TimeseriesGroupMitigationProductResponseSerie0] +type attackLayer7TimeseriesGroupMitigationProductResponseSerie0JSON struct { + DDOS apijson.Field + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupMitigationProductResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupMitigationProductResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupVerticalResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 AttackLayer7TimeseriesGroupVerticalResponseSerie0 `json:"serie_0,required"` + JSON attackLayer7TimeseriesGroupVerticalResponseJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupVerticalResponseJSON contains the JSON metadata for +// the struct [AttackLayer7TimeseriesGroupVerticalResponse] +type attackLayer7TimeseriesGroupVerticalResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupVerticalResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupVerticalResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupVerticalResponseSerie0 struct { + Timestamps []string `json:"timestamps,required"` + ExtraFields map[string][]string `json:"-,extras"` + JSON attackLayer7TimeseriesGroupVerticalResponseSerie0JSON `json:"-"` +} + +// attackLayer7TimeseriesGroupVerticalResponseSerie0JSON contains the JSON metadata +// for the struct [AttackLayer7TimeseriesGroupVerticalResponseSerie0] +type attackLayer7TimeseriesGroupVerticalResponseSerie0JSON struct { + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupVerticalResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupVerticalResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupGetParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AttackLayer7TimeseriesGroupGetParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7TimeseriesGroupGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7TimeseriesGroupGetParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AttackLayer7TimeseriesGroupGetParams]'s query parameters as +// `url.Values`. +func (r AttackLayer7TimeseriesGroupGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AttackLayer7TimeseriesGroupGetParamsAggInterval string + +const ( + AttackLayer7TimeseriesGroupGetParamsAggInterval15m AttackLayer7TimeseriesGroupGetParamsAggInterval = "15m" + AttackLayer7TimeseriesGroupGetParamsAggInterval1h AttackLayer7TimeseriesGroupGetParamsAggInterval = "1h" + AttackLayer7TimeseriesGroupGetParamsAggInterval1d AttackLayer7TimeseriesGroupGetParamsAggInterval = "1d" + AttackLayer7TimeseriesGroupGetParamsAggInterval1w AttackLayer7TimeseriesGroupGetParamsAggInterval = "1w" +) + +type AttackLayer7TimeseriesGroupGetParamsDateRange string + +const ( + AttackLayer7TimeseriesGroupGetParamsDateRange1d AttackLayer7TimeseriesGroupGetParamsDateRange = "1d" + AttackLayer7TimeseriesGroupGetParamsDateRange2d AttackLayer7TimeseriesGroupGetParamsDateRange = "2d" + AttackLayer7TimeseriesGroupGetParamsDateRange7d AttackLayer7TimeseriesGroupGetParamsDateRange = "7d" + AttackLayer7TimeseriesGroupGetParamsDateRange14d AttackLayer7TimeseriesGroupGetParamsDateRange = "14d" + AttackLayer7TimeseriesGroupGetParamsDateRange28d AttackLayer7TimeseriesGroupGetParamsDateRange = "28d" + AttackLayer7TimeseriesGroupGetParamsDateRange12w AttackLayer7TimeseriesGroupGetParamsDateRange = "12w" + AttackLayer7TimeseriesGroupGetParamsDateRange24w AttackLayer7TimeseriesGroupGetParamsDateRange = "24w" + AttackLayer7TimeseriesGroupGetParamsDateRange52w AttackLayer7TimeseriesGroupGetParamsDateRange = "52w" + AttackLayer7TimeseriesGroupGetParamsDateRange1dControl AttackLayer7TimeseriesGroupGetParamsDateRange = "1dControl" + AttackLayer7TimeseriesGroupGetParamsDateRange2dControl AttackLayer7TimeseriesGroupGetParamsDateRange = "2dControl" + AttackLayer7TimeseriesGroupGetParamsDateRange7dControl AttackLayer7TimeseriesGroupGetParamsDateRange = "7dControl" + AttackLayer7TimeseriesGroupGetParamsDateRange14dControl AttackLayer7TimeseriesGroupGetParamsDateRange = "14dControl" + AttackLayer7TimeseriesGroupGetParamsDateRange28dControl AttackLayer7TimeseriesGroupGetParamsDateRange = "28dControl" + AttackLayer7TimeseriesGroupGetParamsDateRange12wControl AttackLayer7TimeseriesGroupGetParamsDateRange = "12wControl" + AttackLayer7TimeseriesGroupGetParamsDateRange24wControl AttackLayer7TimeseriesGroupGetParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7TimeseriesGroupGetParamsFormat string + +const ( + AttackLayer7TimeseriesGroupGetParamsFormatJson AttackLayer7TimeseriesGroupGetParamsFormat = "JSON" + AttackLayer7TimeseriesGroupGetParamsFormatCsv AttackLayer7TimeseriesGroupGetParamsFormat = "CSV" +) + +type AttackLayer7TimeseriesGroupGetResponseEnvelope struct { + Result AttackLayer7TimeseriesGroupGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7TimeseriesGroupGetResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupGetResponseEnvelopeJSON contains the JSON metadata +// for the struct [AttackLayer7TimeseriesGroupGetResponseEnvelope] +type attackLayer7TimeseriesGroupGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupHTTPMethodParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7TimeseriesGroupHTTPMethodParamsFormat] `query:"format"` + // Filter for http version. + HTTPVersion param.Field[[]AttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer7TimeseriesGroupHTTPMethodParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of L7 mitigation products. + MitigationProduct param.Field[[]AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct] `query:"mitigationProduct"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Normalization method applied. Refer to + // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + Normalization param.Field[AttackLayer7TimeseriesGroupHTTPMethodParamsNormalization] `query:"normalization"` +} + +// URLQuery serializes [AttackLayer7TimeseriesGroupHTTPMethodParams]'s query +// parameters as `url.Values`. +func (r AttackLayer7TimeseriesGroupHTTPMethodParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval string + +const ( + AttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval15m AttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval = "15m" + AttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval1h AttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval = "1h" + AttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval1d AttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval = "1d" + AttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval1w AttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval = "1w" +) + +type AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange string + +const ( + AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange1d AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "1d" + AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange2d AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "2d" + AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange7d AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "7d" + AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange14d AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "14d" + AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange28d AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "28d" + AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange12w AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "12w" + AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange24w AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "24w" + AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange52w AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "52w" + AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange1dControl AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "1dControl" + AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange2dControl AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "2dControl" + AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange7dControl AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "7dControl" + AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange14dControl AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "14dControl" + AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange28dControl AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "28dControl" + AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange12wControl AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "12wControl" + AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange24wControl AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7TimeseriesGroupHTTPMethodParamsFormat string + +const ( + AttackLayer7TimeseriesGroupHTTPMethodParamsFormatJson AttackLayer7TimeseriesGroupHTTPMethodParamsFormat = "JSON" + AttackLayer7TimeseriesGroupHTTPMethodParamsFormatCsv AttackLayer7TimeseriesGroupHTTPMethodParamsFormat = "CSV" +) + +type AttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersion string + +const ( + AttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersionHttPv1 AttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersion = "HTTPv1" + AttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersionHttPv2 AttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersion = "HTTPv2" + AttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersionHttPv3 AttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersion = "HTTPv3" +) + +type AttackLayer7TimeseriesGroupHTTPMethodParamsIPVersion string + +const ( + AttackLayer7TimeseriesGroupHTTPMethodParamsIPVersionIPv4 AttackLayer7TimeseriesGroupHTTPMethodParamsIPVersion = "IPv4" + AttackLayer7TimeseriesGroupHTTPMethodParamsIPVersionIPv6 AttackLayer7TimeseriesGroupHTTPMethodParamsIPVersion = "IPv6" +) + +type AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct string + +const ( + AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductDDOS AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct = "DDOS" + AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductWAF AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct = "WAF" + AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductBotManagement AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct = "BOT_MANAGEMENT" + AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductAccessRules AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct = "ACCESS_RULES" + AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductIPReputation AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct = "IP_REPUTATION" + AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductAPIShield AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct = "API_SHIELD" + AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductDataLossPrevention AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct = "DATA_LOSS_PREVENTION" +) + +// Normalization method applied. Refer to +// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). +type AttackLayer7TimeseriesGroupHTTPMethodParamsNormalization string + +const ( + AttackLayer7TimeseriesGroupHTTPMethodParamsNormalizationPercentage AttackLayer7TimeseriesGroupHTTPMethodParamsNormalization = "PERCENTAGE" + AttackLayer7TimeseriesGroupHTTPMethodParamsNormalizationMin0Max AttackLayer7TimeseriesGroupHTTPMethodParamsNormalization = "MIN0_MAX" +) + +type AttackLayer7TimeseriesGroupHTTPMethodResponseEnvelope struct { + Result AttackLayer7TimeseriesGroupHTTPMethodResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7TimeseriesGroupHTTPMethodResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupHTTPMethodResponseEnvelopeJSON contains the JSON +// metadata for the struct [AttackLayer7TimeseriesGroupHTTPMethodResponseEnvelope] +type attackLayer7TimeseriesGroupHTTPMethodResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupHTTPMethodResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupHTTPMethodResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupHTTPVersionParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7TimeseriesGroupHTTPVersionParamsFormat] `query:"format"` + // Filter for http method. + HTTPMethod param.Field[[]AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod] `query:"httpMethod"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer7TimeseriesGroupHTTPVersionParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of L7 mitigation products. + MitigationProduct param.Field[[]AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct] `query:"mitigationProduct"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Normalization method applied. Refer to + // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + Normalization param.Field[AttackLayer7TimeseriesGroupHTTPVersionParamsNormalization] `query:"normalization"` +} + +// URLQuery serializes [AttackLayer7TimeseriesGroupHTTPVersionParams]'s query +// parameters as `url.Values`. +func (r AttackLayer7TimeseriesGroupHTTPVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval string + +const ( + AttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval15m AttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval = "15m" + AttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval1h AttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval = "1h" + AttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval1d AttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval = "1d" + AttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval1w AttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval = "1w" +) + +type AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange string + +const ( + AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange1d AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "1d" + AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange2d AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "2d" + AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange7d AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "7d" + AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange14d AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "14d" + AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange28d AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "28d" + AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange12w AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "12w" + AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange24w AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "24w" + AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange52w AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "52w" + AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange1dControl AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "1dControl" + AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange2dControl AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "2dControl" + AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange7dControl AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "7dControl" + AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange14dControl AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "14dControl" + AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange28dControl AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "28dControl" + AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange12wControl AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "12wControl" + AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange24wControl AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7TimeseriesGroupHTTPVersionParamsFormat string + +const ( + AttackLayer7TimeseriesGroupHTTPVersionParamsFormatJson AttackLayer7TimeseriesGroupHTTPVersionParamsFormat = "JSON" + AttackLayer7TimeseriesGroupHTTPVersionParamsFormatCsv AttackLayer7TimeseriesGroupHTTPVersionParamsFormat = "CSV" +) + +type AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod string + +const ( + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodGet AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "GET" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodPost AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "POST" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodDelete AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "DELETE" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodPut AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "PUT" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodHead AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "HEAD" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodPurge AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "PURGE" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodOptions AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "OPTIONS" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodPropfind AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "PROPFIND" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodMkcol AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "MKCOL" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodPatch AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "PATCH" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodACL AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "ACL" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodBcopy AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "BCOPY" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodBdelete AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "BDELETE" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodBmove AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "BMOVE" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodBpropfind AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "BPROPFIND" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodBproppatch AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "BPROPPATCH" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodCheckin AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "CHECKIN" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodCheckout AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "CHECKOUT" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodConnect AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "CONNECT" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodCopy AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "COPY" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodLabel AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "LABEL" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodLock AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "LOCK" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodMerge AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "MERGE" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodMkactivity AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "MKACTIVITY" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodMkworkspace AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "MKWORKSPACE" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodMove AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "MOVE" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodNotify AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "NOTIFY" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodOrderpatch AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "ORDERPATCH" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodPoll AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "POLL" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodProppatch AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "PROPPATCH" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodReport AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "REPORT" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodSearch AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "SEARCH" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodSubscribe AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "SUBSCRIBE" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodTrace AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "TRACE" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodUncheckout AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "UNCHECKOUT" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodUnlock AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "UNLOCK" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodUnsubscribe AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "UNSUBSCRIBE" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodUpdate AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "UPDATE" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodVersioncontrol AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "VERSIONCONTROL" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodBaselinecontrol AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "BASELINECONTROL" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodXmsenumatts AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "XMSENUMATTS" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodRpcOutData AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "RPC_OUT_DATA" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodRpcInData AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "RPC_IN_DATA" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodJson AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "JSON" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodCook AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "COOK" + AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodTrack AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "TRACK" +) + +type AttackLayer7TimeseriesGroupHTTPVersionParamsIPVersion string + +const ( + AttackLayer7TimeseriesGroupHTTPVersionParamsIPVersionIPv4 AttackLayer7TimeseriesGroupHTTPVersionParamsIPVersion = "IPv4" + AttackLayer7TimeseriesGroupHTTPVersionParamsIPVersionIPv6 AttackLayer7TimeseriesGroupHTTPVersionParamsIPVersion = "IPv6" +) + +type AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct string + +const ( + AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductDDOS AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct = "DDOS" + AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductWAF AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct = "WAF" + AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductBotManagement AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct = "BOT_MANAGEMENT" + AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductAccessRules AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct = "ACCESS_RULES" + AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductIPReputation AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct = "IP_REPUTATION" + AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductAPIShield AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct = "API_SHIELD" + AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductDataLossPrevention AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct = "DATA_LOSS_PREVENTION" +) + +// Normalization method applied. Refer to +// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). +type AttackLayer7TimeseriesGroupHTTPVersionParamsNormalization string + +const ( + AttackLayer7TimeseriesGroupHTTPVersionParamsNormalizationPercentage AttackLayer7TimeseriesGroupHTTPVersionParamsNormalization = "PERCENTAGE" + AttackLayer7TimeseriesGroupHTTPVersionParamsNormalizationMin0Max AttackLayer7TimeseriesGroupHTTPVersionParamsNormalization = "MIN0_MAX" +) + +type AttackLayer7TimeseriesGroupHTTPVersionResponseEnvelope struct { + Result AttackLayer7TimeseriesGroupHTTPVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7TimeseriesGroupHTTPVersionResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupHTTPVersionResponseEnvelopeJSON contains the JSON +// metadata for the struct [AttackLayer7TimeseriesGroupHTTPVersionResponseEnvelope] +type attackLayer7TimeseriesGroupHTTPVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupHTTPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupHTTPVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupIndustryParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AttackLayer7TimeseriesGroupIndustryParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7TimeseriesGroupIndustryParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7TimeseriesGroupIndustryParamsFormat] `query:"format"` + // Filter for http method. + HTTPMethod param.Field[[]AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod] `query:"httpMethod"` + // Filter for http version. + HTTPVersion param.Field[[]AttackLayer7TimeseriesGroupIndustryParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer7TimeseriesGroupIndustryParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects (eg browsers, verticals, etc) to the top items over + // the time range. + LimitPerGroup param.Field[int64] `query:"limitPerGroup"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of L7 mitigation products. + MitigationProduct param.Field[[]AttackLayer7TimeseriesGroupIndustryParamsMitigationProduct] `query:"mitigationProduct"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Normalization method applied. Refer to + // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + Normalization param.Field[AttackLayer7TimeseriesGroupIndustryParamsNormalization] `query:"normalization"` +} + +// URLQuery serializes [AttackLayer7TimeseriesGroupIndustryParams]'s query +// parameters as `url.Values`. +func (r AttackLayer7TimeseriesGroupIndustryParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AttackLayer7TimeseriesGroupIndustryParamsAggInterval string + +const ( + AttackLayer7TimeseriesGroupIndustryParamsAggInterval15m AttackLayer7TimeseriesGroupIndustryParamsAggInterval = "15m" + AttackLayer7TimeseriesGroupIndustryParamsAggInterval1h AttackLayer7TimeseriesGroupIndustryParamsAggInterval = "1h" + AttackLayer7TimeseriesGroupIndustryParamsAggInterval1d AttackLayer7TimeseriesGroupIndustryParamsAggInterval = "1d" + AttackLayer7TimeseriesGroupIndustryParamsAggInterval1w AttackLayer7TimeseriesGroupIndustryParamsAggInterval = "1w" +) + +type AttackLayer7TimeseriesGroupIndustryParamsDateRange string + +const ( + AttackLayer7TimeseriesGroupIndustryParamsDateRange1d AttackLayer7TimeseriesGroupIndustryParamsDateRange = "1d" + AttackLayer7TimeseriesGroupIndustryParamsDateRange2d AttackLayer7TimeseriesGroupIndustryParamsDateRange = "2d" + AttackLayer7TimeseriesGroupIndustryParamsDateRange7d AttackLayer7TimeseriesGroupIndustryParamsDateRange = "7d" + AttackLayer7TimeseriesGroupIndustryParamsDateRange14d AttackLayer7TimeseriesGroupIndustryParamsDateRange = "14d" + AttackLayer7TimeseriesGroupIndustryParamsDateRange28d AttackLayer7TimeseriesGroupIndustryParamsDateRange = "28d" + AttackLayer7TimeseriesGroupIndustryParamsDateRange12w AttackLayer7TimeseriesGroupIndustryParamsDateRange = "12w" + AttackLayer7TimeseriesGroupIndustryParamsDateRange24w AttackLayer7TimeseriesGroupIndustryParamsDateRange = "24w" + AttackLayer7TimeseriesGroupIndustryParamsDateRange52w AttackLayer7TimeseriesGroupIndustryParamsDateRange = "52w" + AttackLayer7TimeseriesGroupIndustryParamsDateRange1dControl AttackLayer7TimeseriesGroupIndustryParamsDateRange = "1dControl" + AttackLayer7TimeseriesGroupIndustryParamsDateRange2dControl AttackLayer7TimeseriesGroupIndustryParamsDateRange = "2dControl" + AttackLayer7TimeseriesGroupIndustryParamsDateRange7dControl AttackLayer7TimeseriesGroupIndustryParamsDateRange = "7dControl" + AttackLayer7TimeseriesGroupIndustryParamsDateRange14dControl AttackLayer7TimeseriesGroupIndustryParamsDateRange = "14dControl" + AttackLayer7TimeseriesGroupIndustryParamsDateRange28dControl AttackLayer7TimeseriesGroupIndustryParamsDateRange = "28dControl" + AttackLayer7TimeseriesGroupIndustryParamsDateRange12wControl AttackLayer7TimeseriesGroupIndustryParamsDateRange = "12wControl" + AttackLayer7TimeseriesGroupIndustryParamsDateRange24wControl AttackLayer7TimeseriesGroupIndustryParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7TimeseriesGroupIndustryParamsFormat string + +const ( + AttackLayer7TimeseriesGroupIndustryParamsFormatJson AttackLayer7TimeseriesGroupIndustryParamsFormat = "JSON" + AttackLayer7TimeseriesGroupIndustryParamsFormatCsv AttackLayer7TimeseriesGroupIndustryParamsFormat = "CSV" +) + +type AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod string + +const ( + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodGet AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "GET" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodPost AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "POST" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodDelete AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "DELETE" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodPut AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "PUT" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodHead AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "HEAD" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodPurge AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "PURGE" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodOptions AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "OPTIONS" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodPropfind AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "PROPFIND" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodMkcol AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "MKCOL" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodPatch AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "PATCH" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodACL AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "ACL" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodBcopy AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "BCOPY" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodBdelete AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "BDELETE" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodBmove AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "BMOVE" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodBpropfind AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "BPROPFIND" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodBproppatch AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "BPROPPATCH" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodCheckin AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "CHECKIN" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodCheckout AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "CHECKOUT" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodConnect AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "CONNECT" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodCopy AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "COPY" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodLabel AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "LABEL" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodLock AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "LOCK" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodMerge AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "MERGE" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodMkactivity AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "MKACTIVITY" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodMkworkspace AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "MKWORKSPACE" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodMove AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "MOVE" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodNotify AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "NOTIFY" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodOrderpatch AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "ORDERPATCH" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodPoll AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "POLL" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodProppatch AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "PROPPATCH" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodReport AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "REPORT" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodSearch AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "SEARCH" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodSubscribe AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "SUBSCRIBE" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodTrace AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "TRACE" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodUncheckout AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "UNCHECKOUT" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodUnlock AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "UNLOCK" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodUnsubscribe AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "UNSUBSCRIBE" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodUpdate AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "UPDATE" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodVersioncontrol AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "VERSIONCONTROL" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodBaselinecontrol AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "BASELINECONTROL" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodXmsenumatts AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "XMSENUMATTS" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodRpcOutData AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "RPC_OUT_DATA" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodRpcInData AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "RPC_IN_DATA" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodJson AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "JSON" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodCook AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "COOK" + AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodTrack AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "TRACK" +) + +type AttackLayer7TimeseriesGroupIndustryParamsHTTPVersion string + +const ( + AttackLayer7TimeseriesGroupIndustryParamsHTTPVersionHttPv1 AttackLayer7TimeseriesGroupIndustryParamsHTTPVersion = "HTTPv1" + AttackLayer7TimeseriesGroupIndustryParamsHTTPVersionHttPv2 AttackLayer7TimeseriesGroupIndustryParamsHTTPVersion = "HTTPv2" + AttackLayer7TimeseriesGroupIndustryParamsHTTPVersionHttPv3 AttackLayer7TimeseriesGroupIndustryParamsHTTPVersion = "HTTPv3" +) + +type AttackLayer7TimeseriesGroupIndustryParamsIPVersion string + +const ( + AttackLayer7TimeseriesGroupIndustryParamsIPVersionIPv4 AttackLayer7TimeseriesGroupIndustryParamsIPVersion = "IPv4" + AttackLayer7TimeseriesGroupIndustryParamsIPVersionIPv6 AttackLayer7TimeseriesGroupIndustryParamsIPVersion = "IPv6" +) + +type AttackLayer7TimeseriesGroupIndustryParamsMitigationProduct string + +const ( + AttackLayer7TimeseriesGroupIndustryParamsMitigationProductDDOS AttackLayer7TimeseriesGroupIndustryParamsMitigationProduct = "DDOS" + AttackLayer7TimeseriesGroupIndustryParamsMitigationProductWAF AttackLayer7TimeseriesGroupIndustryParamsMitigationProduct = "WAF" + AttackLayer7TimeseriesGroupIndustryParamsMitigationProductBotManagement AttackLayer7TimeseriesGroupIndustryParamsMitigationProduct = "BOT_MANAGEMENT" + AttackLayer7TimeseriesGroupIndustryParamsMitigationProductAccessRules AttackLayer7TimeseriesGroupIndustryParamsMitigationProduct = "ACCESS_RULES" + AttackLayer7TimeseriesGroupIndustryParamsMitigationProductIPReputation AttackLayer7TimeseriesGroupIndustryParamsMitigationProduct = "IP_REPUTATION" + AttackLayer7TimeseriesGroupIndustryParamsMitigationProductAPIShield AttackLayer7TimeseriesGroupIndustryParamsMitigationProduct = "API_SHIELD" + AttackLayer7TimeseriesGroupIndustryParamsMitigationProductDataLossPrevention AttackLayer7TimeseriesGroupIndustryParamsMitigationProduct = "DATA_LOSS_PREVENTION" +) + +// Normalization method applied. Refer to +// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). +type AttackLayer7TimeseriesGroupIndustryParamsNormalization string + +const ( + AttackLayer7TimeseriesGroupIndustryParamsNormalizationPercentage AttackLayer7TimeseriesGroupIndustryParamsNormalization = "PERCENTAGE" + AttackLayer7TimeseriesGroupIndustryParamsNormalizationMin0Max AttackLayer7TimeseriesGroupIndustryParamsNormalization = "MIN0_MAX" +) + +type AttackLayer7TimeseriesGroupIndustryResponseEnvelope struct { + Result AttackLayer7TimeseriesGroupIndustryResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7TimeseriesGroupIndustryResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupIndustryResponseEnvelopeJSON contains the JSON +// metadata for the struct [AttackLayer7TimeseriesGroupIndustryResponseEnvelope] +type attackLayer7TimeseriesGroupIndustryResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupIndustryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupIndustryResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupIPVersionParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AttackLayer7TimeseriesGroupIPVersionParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7TimeseriesGroupIPVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7TimeseriesGroupIPVersionParamsFormat] `query:"format"` + // Filter for http method. + HTTPMethod param.Field[[]AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod] `query:"httpMethod"` + // Filter for http version. + HTTPVersion param.Field[[]AttackLayer7TimeseriesGroupIPVersionParamsHTTPVersion] `query:"httpVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of L7 mitigation products. + MitigationProduct param.Field[[]AttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct] `query:"mitigationProduct"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Normalization method applied. Refer to + // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + Normalization param.Field[AttackLayer7TimeseriesGroupIPVersionParamsNormalization] `query:"normalization"` +} + +// URLQuery serializes [AttackLayer7TimeseriesGroupIPVersionParams]'s query +// parameters as `url.Values`. +func (r AttackLayer7TimeseriesGroupIPVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AttackLayer7TimeseriesGroupIPVersionParamsAggInterval string + +const ( + AttackLayer7TimeseriesGroupIPVersionParamsAggInterval15m AttackLayer7TimeseriesGroupIPVersionParamsAggInterval = "15m" + AttackLayer7TimeseriesGroupIPVersionParamsAggInterval1h AttackLayer7TimeseriesGroupIPVersionParamsAggInterval = "1h" + AttackLayer7TimeseriesGroupIPVersionParamsAggInterval1d AttackLayer7TimeseriesGroupIPVersionParamsAggInterval = "1d" + AttackLayer7TimeseriesGroupIPVersionParamsAggInterval1w AttackLayer7TimeseriesGroupIPVersionParamsAggInterval = "1w" +) + +type AttackLayer7TimeseriesGroupIPVersionParamsDateRange string + +const ( + AttackLayer7TimeseriesGroupIPVersionParamsDateRange1d AttackLayer7TimeseriesGroupIPVersionParamsDateRange = "1d" + AttackLayer7TimeseriesGroupIPVersionParamsDateRange2d AttackLayer7TimeseriesGroupIPVersionParamsDateRange = "2d" + AttackLayer7TimeseriesGroupIPVersionParamsDateRange7d AttackLayer7TimeseriesGroupIPVersionParamsDateRange = "7d" + AttackLayer7TimeseriesGroupIPVersionParamsDateRange14d AttackLayer7TimeseriesGroupIPVersionParamsDateRange = "14d" + AttackLayer7TimeseriesGroupIPVersionParamsDateRange28d AttackLayer7TimeseriesGroupIPVersionParamsDateRange = "28d" + AttackLayer7TimeseriesGroupIPVersionParamsDateRange12w AttackLayer7TimeseriesGroupIPVersionParamsDateRange = "12w" + AttackLayer7TimeseriesGroupIPVersionParamsDateRange24w AttackLayer7TimeseriesGroupIPVersionParamsDateRange = "24w" + AttackLayer7TimeseriesGroupIPVersionParamsDateRange52w AttackLayer7TimeseriesGroupIPVersionParamsDateRange = "52w" + AttackLayer7TimeseriesGroupIPVersionParamsDateRange1dControl AttackLayer7TimeseriesGroupIPVersionParamsDateRange = "1dControl" + AttackLayer7TimeseriesGroupIPVersionParamsDateRange2dControl AttackLayer7TimeseriesGroupIPVersionParamsDateRange = "2dControl" + AttackLayer7TimeseriesGroupIPVersionParamsDateRange7dControl AttackLayer7TimeseriesGroupIPVersionParamsDateRange = "7dControl" + AttackLayer7TimeseriesGroupIPVersionParamsDateRange14dControl AttackLayer7TimeseriesGroupIPVersionParamsDateRange = "14dControl" + AttackLayer7TimeseriesGroupIPVersionParamsDateRange28dControl AttackLayer7TimeseriesGroupIPVersionParamsDateRange = "28dControl" + AttackLayer7TimeseriesGroupIPVersionParamsDateRange12wControl AttackLayer7TimeseriesGroupIPVersionParamsDateRange = "12wControl" + AttackLayer7TimeseriesGroupIPVersionParamsDateRange24wControl AttackLayer7TimeseriesGroupIPVersionParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7TimeseriesGroupIPVersionParamsFormat string + +const ( + AttackLayer7TimeseriesGroupIPVersionParamsFormatJson AttackLayer7TimeseriesGroupIPVersionParamsFormat = "JSON" + AttackLayer7TimeseriesGroupIPVersionParamsFormatCsv AttackLayer7TimeseriesGroupIPVersionParamsFormat = "CSV" +) + +type AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod string + +const ( + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodGet AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "GET" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodPost AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "POST" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodDelete AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "DELETE" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodPut AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "PUT" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodHead AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "HEAD" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodPurge AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "PURGE" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodOptions AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "OPTIONS" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodPropfind AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "PROPFIND" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodMkcol AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "MKCOL" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodPatch AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "PATCH" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodACL AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "ACL" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodBcopy AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "BCOPY" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodBdelete AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "BDELETE" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodBmove AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "BMOVE" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodBpropfind AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "BPROPFIND" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodBproppatch AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "BPROPPATCH" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodCheckin AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "CHECKIN" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodCheckout AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "CHECKOUT" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodConnect AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "CONNECT" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodCopy AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "COPY" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodLabel AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "LABEL" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodLock AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "LOCK" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodMerge AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "MERGE" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodMkactivity AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "MKACTIVITY" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodMkworkspace AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "MKWORKSPACE" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodMove AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "MOVE" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodNotify AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "NOTIFY" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodOrderpatch AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "ORDERPATCH" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodPoll AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "POLL" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodProppatch AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "PROPPATCH" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodReport AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "REPORT" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodSearch AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "SEARCH" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodSubscribe AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "SUBSCRIBE" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodTrace AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "TRACE" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodUncheckout AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "UNCHECKOUT" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodUnlock AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "UNLOCK" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodUnsubscribe AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "UNSUBSCRIBE" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodUpdate AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "UPDATE" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodVersioncontrol AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "VERSIONCONTROL" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodBaselinecontrol AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "BASELINECONTROL" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodXmsenumatts AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "XMSENUMATTS" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodRpcOutData AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "RPC_OUT_DATA" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodRpcInData AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "RPC_IN_DATA" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodJson AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "JSON" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodCook AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "COOK" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodTrack AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "TRACK" +) + +type AttackLayer7TimeseriesGroupIPVersionParamsHTTPVersion string + +const ( + AttackLayer7TimeseriesGroupIPVersionParamsHTTPVersionHttPv1 AttackLayer7TimeseriesGroupIPVersionParamsHTTPVersion = "HTTPv1" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPVersionHttPv2 AttackLayer7TimeseriesGroupIPVersionParamsHTTPVersion = "HTTPv2" + AttackLayer7TimeseriesGroupIPVersionParamsHTTPVersionHttPv3 AttackLayer7TimeseriesGroupIPVersionParamsHTTPVersion = "HTTPv3" +) + +type AttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct string + +const ( + AttackLayer7TimeseriesGroupIPVersionParamsMitigationProductDDOS AttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct = "DDOS" + AttackLayer7TimeseriesGroupIPVersionParamsMitigationProductWAF AttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct = "WAF" + AttackLayer7TimeseriesGroupIPVersionParamsMitigationProductBotManagement AttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct = "BOT_MANAGEMENT" + AttackLayer7TimeseriesGroupIPVersionParamsMitigationProductAccessRules AttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct = "ACCESS_RULES" + AttackLayer7TimeseriesGroupIPVersionParamsMitigationProductIPReputation AttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct = "IP_REPUTATION" + AttackLayer7TimeseriesGroupIPVersionParamsMitigationProductAPIShield AttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct = "API_SHIELD" + AttackLayer7TimeseriesGroupIPVersionParamsMitigationProductDataLossPrevention AttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct = "DATA_LOSS_PREVENTION" +) + +// Normalization method applied. Refer to +// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). +type AttackLayer7TimeseriesGroupIPVersionParamsNormalization string + +const ( + AttackLayer7TimeseriesGroupIPVersionParamsNormalizationPercentage AttackLayer7TimeseriesGroupIPVersionParamsNormalization = "PERCENTAGE" + AttackLayer7TimeseriesGroupIPVersionParamsNormalizationMin0Max AttackLayer7TimeseriesGroupIPVersionParamsNormalization = "MIN0_MAX" +) + +type AttackLayer7TimeseriesGroupIPVersionResponseEnvelope struct { + Result AttackLayer7TimeseriesGroupIPVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7TimeseriesGroupIPVersionResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupIPVersionResponseEnvelopeJSON contains the JSON +// metadata for the struct [AttackLayer7TimeseriesGroupIPVersionResponseEnvelope] +type attackLayer7TimeseriesGroupIPVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupIPVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupManagedRulesParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AttackLayer7TimeseriesGroupManagedRulesParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7TimeseriesGroupManagedRulesParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7TimeseriesGroupManagedRulesParamsFormat] `query:"format"` + // Filter for http method. + HTTPMethod param.Field[[]AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod] `query:"httpMethod"` + // Filter for http version. + HTTPVersion param.Field[[]AttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer7TimeseriesGroupManagedRulesParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of L7 mitigation products. + MitigationProduct param.Field[[]AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct] `query:"mitigationProduct"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Normalization method applied. Refer to + // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + Normalization param.Field[AttackLayer7TimeseriesGroupManagedRulesParamsNormalization] `query:"normalization"` +} + +// URLQuery serializes [AttackLayer7TimeseriesGroupManagedRulesParams]'s query +// parameters as `url.Values`. +func (r AttackLayer7TimeseriesGroupManagedRulesParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AttackLayer7TimeseriesGroupManagedRulesParamsAggInterval string + +const ( + AttackLayer7TimeseriesGroupManagedRulesParamsAggInterval15m AttackLayer7TimeseriesGroupManagedRulesParamsAggInterval = "15m" + AttackLayer7TimeseriesGroupManagedRulesParamsAggInterval1h AttackLayer7TimeseriesGroupManagedRulesParamsAggInterval = "1h" + AttackLayer7TimeseriesGroupManagedRulesParamsAggInterval1d AttackLayer7TimeseriesGroupManagedRulesParamsAggInterval = "1d" + AttackLayer7TimeseriesGroupManagedRulesParamsAggInterval1w AttackLayer7TimeseriesGroupManagedRulesParamsAggInterval = "1w" +) + +type AttackLayer7TimeseriesGroupManagedRulesParamsDateRange string + +const ( + AttackLayer7TimeseriesGroupManagedRulesParamsDateRange1d AttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "1d" + AttackLayer7TimeseriesGroupManagedRulesParamsDateRange2d AttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "2d" + AttackLayer7TimeseriesGroupManagedRulesParamsDateRange7d AttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "7d" + AttackLayer7TimeseriesGroupManagedRulesParamsDateRange14d AttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "14d" + AttackLayer7TimeseriesGroupManagedRulesParamsDateRange28d AttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "28d" + AttackLayer7TimeseriesGroupManagedRulesParamsDateRange12w AttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "12w" + AttackLayer7TimeseriesGroupManagedRulesParamsDateRange24w AttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "24w" + AttackLayer7TimeseriesGroupManagedRulesParamsDateRange52w AttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "52w" + AttackLayer7TimeseriesGroupManagedRulesParamsDateRange1dControl AttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "1dControl" + AttackLayer7TimeseriesGroupManagedRulesParamsDateRange2dControl AttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "2dControl" + AttackLayer7TimeseriesGroupManagedRulesParamsDateRange7dControl AttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "7dControl" + AttackLayer7TimeseriesGroupManagedRulesParamsDateRange14dControl AttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "14dControl" + AttackLayer7TimeseriesGroupManagedRulesParamsDateRange28dControl AttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "28dControl" + AttackLayer7TimeseriesGroupManagedRulesParamsDateRange12wControl AttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "12wControl" + AttackLayer7TimeseriesGroupManagedRulesParamsDateRange24wControl AttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7TimeseriesGroupManagedRulesParamsFormat string + +const ( + AttackLayer7TimeseriesGroupManagedRulesParamsFormatJson AttackLayer7TimeseriesGroupManagedRulesParamsFormat = "JSON" + AttackLayer7TimeseriesGroupManagedRulesParamsFormatCsv AttackLayer7TimeseriesGroupManagedRulesParamsFormat = "CSV" +) + +type AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod string + +const ( + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodGet AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "GET" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodPost AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "POST" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodDelete AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "DELETE" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodPut AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "PUT" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodHead AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "HEAD" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodPurge AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "PURGE" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodOptions AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "OPTIONS" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodPropfind AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "PROPFIND" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodMkcol AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "MKCOL" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodPatch AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "PATCH" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodACL AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "ACL" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodBcopy AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "BCOPY" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodBdelete AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "BDELETE" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodBmove AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "BMOVE" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodBpropfind AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "BPROPFIND" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodBproppatch AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "BPROPPATCH" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodCheckin AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "CHECKIN" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodCheckout AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "CHECKOUT" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodConnect AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "CONNECT" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodCopy AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "COPY" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodLabel AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "LABEL" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodLock AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "LOCK" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodMerge AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "MERGE" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodMkactivity AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "MKACTIVITY" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodMkworkspace AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "MKWORKSPACE" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodMove AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "MOVE" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodNotify AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "NOTIFY" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodOrderpatch AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "ORDERPATCH" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodPoll AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "POLL" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodProppatch AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "PROPPATCH" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodReport AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "REPORT" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodSearch AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "SEARCH" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodSubscribe AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "SUBSCRIBE" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodTrace AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "TRACE" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodUncheckout AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "UNCHECKOUT" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodUnlock AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "UNLOCK" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodUnsubscribe AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "UNSUBSCRIBE" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodUpdate AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "UPDATE" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodVersioncontrol AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "VERSIONCONTROL" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodBaselinecontrol AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "BASELINECONTROL" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodXmsenumatts AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "XMSENUMATTS" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodRpcOutData AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "RPC_OUT_DATA" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodRpcInData AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "RPC_IN_DATA" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodJson AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "JSON" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodCook AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "COOK" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodTrack AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "TRACK" +) + +type AttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersion string + +const ( + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersionHttPv1 AttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersion = "HTTPv1" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersionHttPv2 AttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersion = "HTTPv2" + AttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersionHttPv3 AttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersion = "HTTPv3" +) + +type AttackLayer7TimeseriesGroupManagedRulesParamsIPVersion string + +const ( + AttackLayer7TimeseriesGroupManagedRulesParamsIPVersionIPv4 AttackLayer7TimeseriesGroupManagedRulesParamsIPVersion = "IPv4" + AttackLayer7TimeseriesGroupManagedRulesParamsIPVersionIPv6 AttackLayer7TimeseriesGroupManagedRulesParamsIPVersion = "IPv6" +) + +type AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct string + +const ( + AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductDDOS AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct = "DDOS" + AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductWAF AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct = "WAF" + AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductBotManagement AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct = "BOT_MANAGEMENT" + AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductAccessRules AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct = "ACCESS_RULES" + AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductIPReputation AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct = "IP_REPUTATION" + AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductAPIShield AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct = "API_SHIELD" + AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductDataLossPrevention AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct = "DATA_LOSS_PREVENTION" +) + +// Normalization method applied. Refer to +// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). +type AttackLayer7TimeseriesGroupManagedRulesParamsNormalization string + +const ( + AttackLayer7TimeseriesGroupManagedRulesParamsNormalizationPercentage AttackLayer7TimeseriesGroupManagedRulesParamsNormalization = "PERCENTAGE" + AttackLayer7TimeseriesGroupManagedRulesParamsNormalizationMin0Max AttackLayer7TimeseriesGroupManagedRulesParamsNormalization = "MIN0_MAX" +) + +type AttackLayer7TimeseriesGroupManagedRulesResponseEnvelope struct { + Result AttackLayer7TimeseriesGroupManagedRulesResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7TimeseriesGroupManagedRulesResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupManagedRulesResponseEnvelopeJSON contains the JSON +// metadata for the struct +// [AttackLayer7TimeseriesGroupManagedRulesResponseEnvelope] +type attackLayer7TimeseriesGroupManagedRulesResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupManagedRulesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupManagedRulesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupMitigationProductParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AttackLayer7TimeseriesGroupMitigationProductParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7TimeseriesGroupMitigationProductParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7TimeseriesGroupMitigationProductParamsFormat] `query:"format"` + // Filter for http method. + HTTPMethod param.Field[[]AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod] `query:"httpMethod"` + // Filter for http version. + HTTPVersion param.Field[[]AttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer7TimeseriesGroupMitigationProductParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Normalization method applied. Refer to + // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + Normalization param.Field[AttackLayer7TimeseriesGroupMitigationProductParamsNormalization] `query:"normalization"` +} + +// URLQuery serializes [AttackLayer7TimeseriesGroupMitigationProductParams]'s query +// parameters as `url.Values`. +func (r AttackLayer7TimeseriesGroupMitigationProductParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AttackLayer7TimeseriesGroupMitigationProductParamsAggInterval string + +const ( + AttackLayer7TimeseriesGroupMitigationProductParamsAggInterval15m AttackLayer7TimeseriesGroupMitigationProductParamsAggInterval = "15m" + AttackLayer7TimeseriesGroupMitigationProductParamsAggInterval1h AttackLayer7TimeseriesGroupMitigationProductParamsAggInterval = "1h" + AttackLayer7TimeseriesGroupMitigationProductParamsAggInterval1d AttackLayer7TimeseriesGroupMitigationProductParamsAggInterval = "1d" + AttackLayer7TimeseriesGroupMitigationProductParamsAggInterval1w AttackLayer7TimeseriesGroupMitigationProductParamsAggInterval = "1w" +) + +type AttackLayer7TimeseriesGroupMitigationProductParamsDateRange string + +const ( + AttackLayer7TimeseriesGroupMitigationProductParamsDateRange1d AttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "1d" + AttackLayer7TimeseriesGroupMitigationProductParamsDateRange2d AttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "2d" + AttackLayer7TimeseriesGroupMitigationProductParamsDateRange7d AttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "7d" + AttackLayer7TimeseriesGroupMitigationProductParamsDateRange14d AttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "14d" + AttackLayer7TimeseriesGroupMitigationProductParamsDateRange28d AttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "28d" + AttackLayer7TimeseriesGroupMitigationProductParamsDateRange12w AttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "12w" + AttackLayer7TimeseriesGroupMitigationProductParamsDateRange24w AttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "24w" + AttackLayer7TimeseriesGroupMitigationProductParamsDateRange52w AttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "52w" + AttackLayer7TimeseriesGroupMitigationProductParamsDateRange1dControl AttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "1dControl" + AttackLayer7TimeseriesGroupMitigationProductParamsDateRange2dControl AttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "2dControl" + AttackLayer7TimeseriesGroupMitigationProductParamsDateRange7dControl AttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "7dControl" + AttackLayer7TimeseriesGroupMitigationProductParamsDateRange14dControl AttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "14dControl" + AttackLayer7TimeseriesGroupMitigationProductParamsDateRange28dControl AttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "28dControl" + AttackLayer7TimeseriesGroupMitigationProductParamsDateRange12wControl AttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "12wControl" + AttackLayer7TimeseriesGroupMitigationProductParamsDateRange24wControl AttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7TimeseriesGroupMitigationProductParamsFormat string + +const ( + AttackLayer7TimeseriesGroupMitigationProductParamsFormatJson AttackLayer7TimeseriesGroupMitigationProductParamsFormat = "JSON" + AttackLayer7TimeseriesGroupMitigationProductParamsFormatCsv AttackLayer7TimeseriesGroupMitigationProductParamsFormat = "CSV" +) + +type AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod string + +const ( + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodGet AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "GET" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodPost AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "POST" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodDelete AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "DELETE" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodPut AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "PUT" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodHead AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "HEAD" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodPurge AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "PURGE" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodOptions AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "OPTIONS" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodPropfind AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "PROPFIND" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodMkcol AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "MKCOL" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodPatch AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "PATCH" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodACL AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "ACL" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodBcopy AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "BCOPY" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodBdelete AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "BDELETE" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodBmove AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "BMOVE" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodBpropfind AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "BPROPFIND" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodBproppatch AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "BPROPPATCH" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodCheckin AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "CHECKIN" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodCheckout AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "CHECKOUT" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodConnect AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "CONNECT" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodCopy AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "COPY" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodLabel AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "LABEL" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodLock AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "LOCK" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodMerge AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "MERGE" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodMkactivity AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "MKACTIVITY" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodMkworkspace AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "MKWORKSPACE" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodMove AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "MOVE" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodNotify AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "NOTIFY" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodOrderpatch AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "ORDERPATCH" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodPoll AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "POLL" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodProppatch AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "PROPPATCH" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodReport AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "REPORT" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodSearch AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "SEARCH" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodSubscribe AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "SUBSCRIBE" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodTrace AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "TRACE" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodUncheckout AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "UNCHECKOUT" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodUnlock AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "UNLOCK" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodUnsubscribe AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "UNSUBSCRIBE" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodUpdate AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "UPDATE" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodVersioncontrol AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "VERSIONCONTROL" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodBaselinecontrol AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "BASELINECONTROL" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodXmsenumatts AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "XMSENUMATTS" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodRpcOutData AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "RPC_OUT_DATA" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodRpcInData AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "RPC_IN_DATA" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodJson AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "JSON" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodCook AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "COOK" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodTrack AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "TRACK" +) + +type AttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersion string + +const ( + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersionHttPv1 AttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersion = "HTTPv1" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersionHttPv2 AttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersion = "HTTPv2" + AttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersionHttPv3 AttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersion = "HTTPv3" +) + +type AttackLayer7TimeseriesGroupMitigationProductParamsIPVersion string + +const ( + AttackLayer7TimeseriesGroupMitigationProductParamsIPVersionIPv4 AttackLayer7TimeseriesGroupMitigationProductParamsIPVersion = "IPv4" + AttackLayer7TimeseriesGroupMitigationProductParamsIPVersionIPv6 AttackLayer7TimeseriesGroupMitigationProductParamsIPVersion = "IPv6" +) + +// Normalization method applied. Refer to +// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). +type AttackLayer7TimeseriesGroupMitigationProductParamsNormalization string + +const ( + AttackLayer7TimeseriesGroupMitigationProductParamsNormalizationPercentage AttackLayer7TimeseriesGroupMitigationProductParamsNormalization = "PERCENTAGE" + AttackLayer7TimeseriesGroupMitigationProductParamsNormalizationMin0Max AttackLayer7TimeseriesGroupMitigationProductParamsNormalization = "MIN0_MAX" +) + +type AttackLayer7TimeseriesGroupMitigationProductResponseEnvelope struct { + Result AttackLayer7TimeseriesGroupMitigationProductResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7TimeseriesGroupMitigationProductResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupMitigationProductResponseEnvelopeJSON contains the +// JSON metadata for the struct +// [AttackLayer7TimeseriesGroupMitigationProductResponseEnvelope] +type attackLayer7TimeseriesGroupMitigationProductResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupMitigationProductResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupMitigationProductResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TimeseriesGroupVerticalParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[AttackLayer7TimeseriesGroupVerticalParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7TimeseriesGroupVerticalParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7TimeseriesGroupVerticalParamsFormat] `query:"format"` + // Filter for http method. + HTTPMethod param.Field[[]AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod] `query:"httpMethod"` + // Filter for http version. + HTTPVersion param.Field[[]AttackLayer7TimeseriesGroupVerticalParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]AttackLayer7TimeseriesGroupVerticalParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects (eg browsers, verticals, etc) to the top items over + // the time range. + LimitPerGroup param.Field[int64] `query:"limitPerGroup"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of L7 mitigation products. + MitigationProduct param.Field[[]AttackLayer7TimeseriesGroupVerticalParamsMitigationProduct] `query:"mitigationProduct"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Normalization method applied. Refer to + // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + Normalization param.Field[AttackLayer7TimeseriesGroupVerticalParamsNormalization] `query:"normalization"` +} + +// URLQuery serializes [AttackLayer7TimeseriesGroupVerticalParams]'s query +// parameters as `url.Values`. +func (r AttackLayer7TimeseriesGroupVerticalParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type AttackLayer7TimeseriesGroupVerticalParamsAggInterval string + +const ( + AttackLayer7TimeseriesGroupVerticalParamsAggInterval15m AttackLayer7TimeseriesGroupVerticalParamsAggInterval = "15m" + AttackLayer7TimeseriesGroupVerticalParamsAggInterval1h AttackLayer7TimeseriesGroupVerticalParamsAggInterval = "1h" + AttackLayer7TimeseriesGroupVerticalParamsAggInterval1d AttackLayer7TimeseriesGroupVerticalParamsAggInterval = "1d" + AttackLayer7TimeseriesGroupVerticalParamsAggInterval1w AttackLayer7TimeseriesGroupVerticalParamsAggInterval = "1w" +) + +type AttackLayer7TimeseriesGroupVerticalParamsDateRange string + +const ( + AttackLayer7TimeseriesGroupVerticalParamsDateRange1d AttackLayer7TimeseriesGroupVerticalParamsDateRange = "1d" + AttackLayer7TimeseriesGroupVerticalParamsDateRange2d AttackLayer7TimeseriesGroupVerticalParamsDateRange = "2d" + AttackLayer7TimeseriesGroupVerticalParamsDateRange7d AttackLayer7TimeseriesGroupVerticalParamsDateRange = "7d" + AttackLayer7TimeseriesGroupVerticalParamsDateRange14d AttackLayer7TimeseriesGroupVerticalParamsDateRange = "14d" + AttackLayer7TimeseriesGroupVerticalParamsDateRange28d AttackLayer7TimeseriesGroupVerticalParamsDateRange = "28d" + AttackLayer7TimeseriesGroupVerticalParamsDateRange12w AttackLayer7TimeseriesGroupVerticalParamsDateRange = "12w" + AttackLayer7TimeseriesGroupVerticalParamsDateRange24w AttackLayer7TimeseriesGroupVerticalParamsDateRange = "24w" + AttackLayer7TimeseriesGroupVerticalParamsDateRange52w AttackLayer7TimeseriesGroupVerticalParamsDateRange = "52w" + AttackLayer7TimeseriesGroupVerticalParamsDateRange1dControl AttackLayer7TimeseriesGroupVerticalParamsDateRange = "1dControl" + AttackLayer7TimeseriesGroupVerticalParamsDateRange2dControl AttackLayer7TimeseriesGroupVerticalParamsDateRange = "2dControl" + AttackLayer7TimeseriesGroupVerticalParamsDateRange7dControl AttackLayer7TimeseriesGroupVerticalParamsDateRange = "7dControl" + AttackLayer7TimeseriesGroupVerticalParamsDateRange14dControl AttackLayer7TimeseriesGroupVerticalParamsDateRange = "14dControl" + AttackLayer7TimeseriesGroupVerticalParamsDateRange28dControl AttackLayer7TimeseriesGroupVerticalParamsDateRange = "28dControl" + AttackLayer7TimeseriesGroupVerticalParamsDateRange12wControl AttackLayer7TimeseriesGroupVerticalParamsDateRange = "12wControl" + AttackLayer7TimeseriesGroupVerticalParamsDateRange24wControl AttackLayer7TimeseriesGroupVerticalParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7TimeseriesGroupVerticalParamsFormat string + +const ( + AttackLayer7TimeseriesGroupVerticalParamsFormatJson AttackLayer7TimeseriesGroupVerticalParamsFormat = "JSON" + AttackLayer7TimeseriesGroupVerticalParamsFormatCsv AttackLayer7TimeseriesGroupVerticalParamsFormat = "CSV" +) + +type AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod string + +const ( + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodGet AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "GET" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodPost AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "POST" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodDelete AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "DELETE" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodPut AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "PUT" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodHead AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "HEAD" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodPurge AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "PURGE" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodOptions AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "OPTIONS" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodPropfind AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "PROPFIND" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodMkcol AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "MKCOL" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodPatch AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "PATCH" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodACL AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "ACL" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodBcopy AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "BCOPY" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodBdelete AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "BDELETE" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodBmove AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "BMOVE" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodBpropfind AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "BPROPFIND" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodBproppatch AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "BPROPPATCH" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodCheckin AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "CHECKIN" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodCheckout AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "CHECKOUT" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodConnect AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "CONNECT" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodCopy AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "COPY" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodLabel AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "LABEL" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodLock AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "LOCK" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodMerge AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "MERGE" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodMkactivity AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "MKACTIVITY" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodMkworkspace AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "MKWORKSPACE" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodMove AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "MOVE" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodNotify AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "NOTIFY" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodOrderpatch AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "ORDERPATCH" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodPoll AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "POLL" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodProppatch AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "PROPPATCH" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodReport AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "REPORT" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodSearch AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "SEARCH" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodSubscribe AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "SUBSCRIBE" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodTrace AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "TRACE" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodUncheckout AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "UNCHECKOUT" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodUnlock AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "UNLOCK" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodUnsubscribe AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "UNSUBSCRIBE" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodUpdate AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "UPDATE" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodVersioncontrol AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "VERSIONCONTROL" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodBaselinecontrol AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "BASELINECONTROL" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodXmsenumatts AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "XMSENUMATTS" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodRpcOutData AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "RPC_OUT_DATA" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodRpcInData AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "RPC_IN_DATA" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodJson AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "JSON" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodCook AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "COOK" + AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodTrack AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "TRACK" +) + +type AttackLayer7TimeseriesGroupVerticalParamsHTTPVersion string + +const ( + AttackLayer7TimeseriesGroupVerticalParamsHTTPVersionHttPv1 AttackLayer7TimeseriesGroupVerticalParamsHTTPVersion = "HTTPv1" + AttackLayer7TimeseriesGroupVerticalParamsHTTPVersionHttPv2 AttackLayer7TimeseriesGroupVerticalParamsHTTPVersion = "HTTPv2" + AttackLayer7TimeseriesGroupVerticalParamsHTTPVersionHttPv3 AttackLayer7TimeseriesGroupVerticalParamsHTTPVersion = "HTTPv3" +) + +type AttackLayer7TimeseriesGroupVerticalParamsIPVersion string + +const ( + AttackLayer7TimeseriesGroupVerticalParamsIPVersionIPv4 AttackLayer7TimeseriesGroupVerticalParamsIPVersion = "IPv4" + AttackLayer7TimeseriesGroupVerticalParamsIPVersionIPv6 AttackLayer7TimeseriesGroupVerticalParamsIPVersion = "IPv6" +) + +type AttackLayer7TimeseriesGroupVerticalParamsMitigationProduct string + +const ( + AttackLayer7TimeseriesGroupVerticalParamsMitigationProductDDOS AttackLayer7TimeseriesGroupVerticalParamsMitigationProduct = "DDOS" + AttackLayer7TimeseriesGroupVerticalParamsMitigationProductWAF AttackLayer7TimeseriesGroupVerticalParamsMitigationProduct = "WAF" + AttackLayer7TimeseriesGroupVerticalParamsMitigationProductBotManagement AttackLayer7TimeseriesGroupVerticalParamsMitigationProduct = "BOT_MANAGEMENT" + AttackLayer7TimeseriesGroupVerticalParamsMitigationProductAccessRules AttackLayer7TimeseriesGroupVerticalParamsMitigationProduct = "ACCESS_RULES" + AttackLayer7TimeseriesGroupVerticalParamsMitigationProductIPReputation AttackLayer7TimeseriesGroupVerticalParamsMitigationProduct = "IP_REPUTATION" + AttackLayer7TimeseriesGroupVerticalParamsMitigationProductAPIShield AttackLayer7TimeseriesGroupVerticalParamsMitigationProduct = "API_SHIELD" + AttackLayer7TimeseriesGroupVerticalParamsMitigationProductDataLossPrevention AttackLayer7TimeseriesGroupVerticalParamsMitigationProduct = "DATA_LOSS_PREVENTION" +) + +// Normalization method applied. Refer to +// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). +type AttackLayer7TimeseriesGroupVerticalParamsNormalization string + +const ( + AttackLayer7TimeseriesGroupVerticalParamsNormalizationPercentage AttackLayer7TimeseriesGroupVerticalParamsNormalization = "PERCENTAGE" + AttackLayer7TimeseriesGroupVerticalParamsNormalizationMin0Max AttackLayer7TimeseriesGroupVerticalParamsNormalization = "MIN0_MAX" +) + +type AttackLayer7TimeseriesGroupVerticalResponseEnvelope struct { + Result AttackLayer7TimeseriesGroupVerticalResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7TimeseriesGroupVerticalResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7TimeseriesGroupVerticalResponseEnvelopeJSON contains the JSON +// metadata for the struct [AttackLayer7TimeseriesGroupVerticalResponseEnvelope] +type attackLayer7TimeseriesGroupVerticalResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TimeseriesGroupVerticalResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TimeseriesGroupVerticalResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/attacklayer7timeseriesgroup_test.go b/radar/attacklayer7timeseriesgroup_test.go new file mode 100644 index 00000000000..85a32c5bd82 --- /dev/null +++ b/radar/attacklayer7timeseriesgroup_test.go @@ -0,0 +1,321 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestAttackLayer7TimeseriesGroupGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.TimeseriesGroups.Get(context.TODO(), radar.AttackLayer7TimeseriesGroupGetParams{ + AggInterval: cloudflare.F(radar.AttackLayer7TimeseriesGroupGetParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7TimeseriesGroupGetParamsDateRange{radar.AttackLayer7TimeseriesGroupGetParamsDateRange1d, radar.AttackLayer7TimeseriesGroupGetParamsDateRange2d, radar.AttackLayer7TimeseriesGroupGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7TimeseriesGroupGetParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAttackLayer7TimeseriesGroupHTTPMethodWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.TimeseriesGroups.HTTPMethod(context.TODO(), radar.AttackLayer7TimeseriesGroupHTTPMethodParams{ + AggInterval: cloudflare.F(radar.AttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange{radar.AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange1d, radar.AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange2d, radar.AttackLayer7TimeseriesGroupHTTPMethodParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7TimeseriesGroupHTTPMethodParamsFormatJson), + HTTPVersion: cloudflare.F([]radar.AttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersion{radar.AttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersionHttPv1, radar.AttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersionHttPv2, radar.AttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.AttackLayer7TimeseriesGroupHTTPMethodParamsIPVersion{radar.AttackLayer7TimeseriesGroupHTTPMethodParamsIPVersionIPv4, radar.AttackLayer7TimeseriesGroupHTTPMethodParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + MitigationProduct: cloudflare.F([]radar.AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct{radar.AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductDDOS, radar.AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductWAF, radar.AttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductBotManagement}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Normalization: cloudflare.F(radar.AttackLayer7TimeseriesGroupHTTPMethodParamsNormalizationPercentage), + }) + 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 TestAttackLayer7TimeseriesGroupHTTPVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.TimeseriesGroups.HTTPVersion(context.TODO(), radar.AttackLayer7TimeseriesGroupHTTPVersionParams{ + AggInterval: cloudflare.F(radar.AttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange{radar.AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange1d, radar.AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange2d, radar.AttackLayer7TimeseriesGroupHTTPVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7TimeseriesGroupHTTPVersionParamsFormatJson), + HTTPMethod: cloudflare.F([]radar.AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod{radar.AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodGet, radar.AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodPost, radar.AttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodDelete}), + IPVersion: cloudflare.F([]radar.AttackLayer7TimeseriesGroupHTTPVersionParamsIPVersion{radar.AttackLayer7TimeseriesGroupHTTPVersionParamsIPVersionIPv4, radar.AttackLayer7TimeseriesGroupHTTPVersionParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + MitigationProduct: cloudflare.F([]radar.AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct{radar.AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductDDOS, radar.AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductWAF, radar.AttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductBotManagement}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Normalization: cloudflare.F(radar.AttackLayer7TimeseriesGroupHTTPVersionParamsNormalizationPercentage), + }) + 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 TestAttackLayer7TimeseriesGroupIndustryWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.TimeseriesGroups.Industry(context.TODO(), radar.AttackLayer7TimeseriesGroupIndustryParams{ + AggInterval: cloudflare.F(radar.AttackLayer7TimeseriesGroupIndustryParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7TimeseriesGroupIndustryParamsDateRange{radar.AttackLayer7TimeseriesGroupIndustryParamsDateRange1d, radar.AttackLayer7TimeseriesGroupIndustryParamsDateRange2d, radar.AttackLayer7TimeseriesGroupIndustryParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7TimeseriesGroupIndustryParamsFormatJson), + HTTPMethod: cloudflare.F([]radar.AttackLayer7TimeseriesGroupIndustryParamsHTTPMethod{radar.AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodGet, radar.AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodPost, radar.AttackLayer7TimeseriesGroupIndustryParamsHTTPMethodDelete}), + HTTPVersion: cloudflare.F([]radar.AttackLayer7TimeseriesGroupIndustryParamsHTTPVersion{radar.AttackLayer7TimeseriesGroupIndustryParamsHTTPVersionHttPv1, radar.AttackLayer7TimeseriesGroupIndustryParamsHTTPVersionHttPv2, radar.AttackLayer7TimeseriesGroupIndustryParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.AttackLayer7TimeseriesGroupIndustryParamsIPVersion{radar.AttackLayer7TimeseriesGroupIndustryParamsIPVersionIPv4, radar.AttackLayer7TimeseriesGroupIndustryParamsIPVersionIPv6}), + LimitPerGroup: cloudflare.F(int64(4)), + Location: cloudflare.F([]string{"string", "string", "string"}), + MitigationProduct: cloudflare.F([]radar.AttackLayer7TimeseriesGroupIndustryParamsMitigationProduct{radar.AttackLayer7TimeseriesGroupIndustryParamsMitigationProductDDOS, radar.AttackLayer7TimeseriesGroupIndustryParamsMitigationProductWAF, radar.AttackLayer7TimeseriesGroupIndustryParamsMitigationProductBotManagement}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Normalization: cloudflare.F(radar.AttackLayer7TimeseriesGroupIndustryParamsNormalizationPercentage), + }) + 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 TestAttackLayer7TimeseriesGroupIPVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.TimeseriesGroups.IPVersion(context.TODO(), radar.AttackLayer7TimeseriesGroupIPVersionParams{ + AggInterval: cloudflare.F(radar.AttackLayer7TimeseriesGroupIPVersionParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7TimeseriesGroupIPVersionParamsDateRange{radar.AttackLayer7TimeseriesGroupIPVersionParamsDateRange1d, radar.AttackLayer7TimeseriesGroupIPVersionParamsDateRange2d, radar.AttackLayer7TimeseriesGroupIPVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7TimeseriesGroupIPVersionParamsFormatJson), + HTTPMethod: cloudflare.F([]radar.AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod{radar.AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodGet, radar.AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodPost, radar.AttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodDelete}), + HTTPVersion: cloudflare.F([]radar.AttackLayer7TimeseriesGroupIPVersionParamsHTTPVersion{radar.AttackLayer7TimeseriesGroupIPVersionParamsHTTPVersionHttPv1, radar.AttackLayer7TimeseriesGroupIPVersionParamsHTTPVersionHttPv2, radar.AttackLayer7TimeseriesGroupIPVersionParamsHTTPVersionHttPv3}), + Location: cloudflare.F([]string{"string", "string", "string"}), + MitigationProduct: cloudflare.F([]radar.AttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct{radar.AttackLayer7TimeseriesGroupIPVersionParamsMitigationProductDDOS, radar.AttackLayer7TimeseriesGroupIPVersionParamsMitigationProductWAF, radar.AttackLayer7TimeseriesGroupIPVersionParamsMitigationProductBotManagement}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Normalization: cloudflare.F(radar.AttackLayer7TimeseriesGroupIPVersionParamsNormalizationPercentage), + }) + 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 TestAttackLayer7TimeseriesGroupManagedRulesWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.TimeseriesGroups.ManagedRules(context.TODO(), radar.AttackLayer7TimeseriesGroupManagedRulesParams{ + AggInterval: cloudflare.F(radar.AttackLayer7TimeseriesGroupManagedRulesParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7TimeseriesGroupManagedRulesParamsDateRange{radar.AttackLayer7TimeseriesGroupManagedRulesParamsDateRange1d, radar.AttackLayer7TimeseriesGroupManagedRulesParamsDateRange2d, radar.AttackLayer7TimeseriesGroupManagedRulesParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7TimeseriesGroupManagedRulesParamsFormatJson), + HTTPMethod: cloudflare.F([]radar.AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod{radar.AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodGet, radar.AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodPost, radar.AttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodDelete}), + HTTPVersion: cloudflare.F([]radar.AttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersion{radar.AttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersionHttPv1, radar.AttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersionHttPv2, radar.AttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.AttackLayer7TimeseriesGroupManagedRulesParamsIPVersion{radar.AttackLayer7TimeseriesGroupManagedRulesParamsIPVersionIPv4, radar.AttackLayer7TimeseriesGroupManagedRulesParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + MitigationProduct: cloudflare.F([]radar.AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct{radar.AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductDDOS, radar.AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductWAF, radar.AttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductBotManagement}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Normalization: cloudflare.F(radar.AttackLayer7TimeseriesGroupManagedRulesParamsNormalizationPercentage), + }) + 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 TestAttackLayer7TimeseriesGroupMitigationProductWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.TimeseriesGroups.MitigationProduct(context.TODO(), radar.AttackLayer7TimeseriesGroupMitigationProductParams{ + AggInterval: cloudflare.F(radar.AttackLayer7TimeseriesGroupMitigationProductParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7TimeseriesGroupMitigationProductParamsDateRange{radar.AttackLayer7TimeseriesGroupMitigationProductParamsDateRange1d, radar.AttackLayer7TimeseriesGroupMitigationProductParamsDateRange2d, radar.AttackLayer7TimeseriesGroupMitigationProductParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7TimeseriesGroupMitigationProductParamsFormatJson), + HTTPMethod: cloudflare.F([]radar.AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod{radar.AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodGet, radar.AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodPost, radar.AttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodDelete}), + HTTPVersion: cloudflare.F([]radar.AttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersion{radar.AttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersionHttPv1, radar.AttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersionHttPv2, radar.AttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.AttackLayer7TimeseriesGroupMitigationProductParamsIPVersion{radar.AttackLayer7TimeseriesGroupMitigationProductParamsIPVersionIPv4, radar.AttackLayer7TimeseriesGroupMitigationProductParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Normalization: cloudflare.F(radar.AttackLayer7TimeseriesGroupMitigationProductParamsNormalizationPercentage), + }) + 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 TestAttackLayer7TimeseriesGroupVerticalWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.TimeseriesGroups.Vertical(context.TODO(), radar.AttackLayer7TimeseriesGroupVerticalParams{ + AggInterval: cloudflare.F(radar.AttackLayer7TimeseriesGroupVerticalParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7TimeseriesGroupVerticalParamsDateRange{radar.AttackLayer7TimeseriesGroupVerticalParamsDateRange1d, radar.AttackLayer7TimeseriesGroupVerticalParamsDateRange2d, radar.AttackLayer7TimeseriesGroupVerticalParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7TimeseriesGroupVerticalParamsFormatJson), + HTTPMethod: cloudflare.F([]radar.AttackLayer7TimeseriesGroupVerticalParamsHTTPMethod{radar.AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodGet, radar.AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodPost, radar.AttackLayer7TimeseriesGroupVerticalParamsHTTPMethodDelete}), + HTTPVersion: cloudflare.F([]radar.AttackLayer7TimeseriesGroupVerticalParamsHTTPVersion{radar.AttackLayer7TimeseriesGroupVerticalParamsHTTPVersionHttPv1, radar.AttackLayer7TimeseriesGroupVerticalParamsHTTPVersionHttPv2, radar.AttackLayer7TimeseriesGroupVerticalParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.AttackLayer7TimeseriesGroupVerticalParamsIPVersion{radar.AttackLayer7TimeseriesGroupVerticalParamsIPVersionIPv4, radar.AttackLayer7TimeseriesGroupVerticalParamsIPVersionIPv6}), + LimitPerGroup: cloudflare.F(int64(4)), + Location: cloudflare.F([]string{"string", "string", "string"}), + MitigationProduct: cloudflare.F([]radar.AttackLayer7TimeseriesGroupVerticalParamsMitigationProduct{radar.AttackLayer7TimeseriesGroupVerticalParamsMitigationProductDDOS, radar.AttackLayer7TimeseriesGroupVerticalParamsMitigationProductWAF, radar.AttackLayer7TimeseriesGroupVerticalParamsMitigationProductBotManagement}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Normalization: cloudflare.F(radar.AttackLayer7TimeseriesGroupVerticalParamsNormalizationPercentage), + }) + 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/radar/attacklayer7top.go b/radar/attacklayer7top.go new file mode 100644 index 00000000000..2071fd8bf01 --- /dev/null +++ b/radar/attacklayer7top.go @@ -0,0 +1,842 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AttackLayer7TopService 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 [NewAttackLayer7TopService] method +// instead. +type AttackLayer7TopService struct { + Options []option.RequestOption + Locations *AttackLayer7TopLocationService + Ases *AttackLayer7TopAseService +} + +// NewAttackLayer7TopService 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 NewAttackLayer7TopService(opts ...option.RequestOption) (r *AttackLayer7TopService) { + r = &AttackLayer7TopService{} + r.Options = opts + r.Locations = NewAttackLayer7TopLocationService(opts...) + r.Ases = NewAttackLayer7TopAseService(opts...) + return +} + +// Get the top attacks from origin to target location. Values are a percentage out +// of the total layer 7 attacks (with billing country). The attack magnitude can be +// defined by the number of mitigated requests or by the number of zones affected. +// You can optionally limit the number of attacks per origin/target location +// (useful if all the top attacks are from or to the same location). +func (r *AttackLayer7TopService) Attacks(ctx context.Context, query AttackLayer7TopAttacksParams, opts ...option.RequestOption) (res *AttackLayer7TopAttacksResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7TopAttacksResponseEnvelope + path := "radar/attacks/layer7/top/attacks" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the Industry of attacks. +func (r *AttackLayer7TopService) Industry(ctx context.Context, query AttackLayer7TopIndustryParams, opts ...option.RequestOption) (res *AttackLayer7TopIndustryResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7TopIndustryResponseEnvelope + path := "radar/attacks/layer7/top/industry" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the Verticals of attacks. +func (r *AttackLayer7TopService) Vertical(ctx context.Context, query AttackLayer7TopVerticalParams, opts ...option.RequestOption) (res *AttackLayer7TopVerticalResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7TopVerticalResponseEnvelope + path := "radar/attacks/layer7/top/vertical" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AttackLayer7TopAttacksResponse struct { + Meta AttackLayer7TopAttacksResponseMeta `json:"meta,required"` + Top0 []AttackLayer7TopAttacksResponseTop0 `json:"top_0,required"` + JSON attackLayer7TopAttacksResponseJSON `json:"-"` +} + +// attackLayer7TopAttacksResponseJSON contains the JSON metadata for the struct +// [AttackLayer7TopAttacksResponse] +type attackLayer7TopAttacksResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopAttacksResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopAttacksResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopAttacksResponseMeta struct { + DateRange []AttackLayer7TopAttacksResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo AttackLayer7TopAttacksResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer7TopAttacksResponseMetaJSON `json:"-"` +} + +// attackLayer7TopAttacksResponseMetaJSON contains the JSON metadata for the struct +// [AttackLayer7TopAttacksResponseMeta] +type attackLayer7TopAttacksResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopAttacksResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopAttacksResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopAttacksResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer7TopAttacksResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer7TopAttacksResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [AttackLayer7TopAttacksResponseMetaDateRange] +type attackLayer7TopAttacksResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopAttacksResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopAttacksResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopAttacksResponseMetaConfidenceInfo struct { + Annotations []AttackLayer7TopAttacksResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer7TopAttacksResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer7TopAttacksResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [AttackLayer7TopAttacksResponseMetaConfidenceInfo] +type attackLayer7TopAttacksResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopAttacksResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopAttacksResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopAttacksResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer7TopAttacksResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer7TopAttacksResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [AttackLayer7TopAttacksResponseMetaConfidenceInfoAnnotation] +type attackLayer7TopAttacksResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopAttacksResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopAttacksResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopAttacksResponseTop0 struct { + OriginCountryAlpha2 string `json:"originCountryAlpha2,required"` + OriginCountryName string `json:"originCountryName,required"` + TargetCountryAlpha2 string `json:"targetCountryAlpha2,required"` + TargetCountryName string `json:"targetCountryName,required"` + Value string `json:"value,required"` + JSON attackLayer7TopAttacksResponseTop0JSON `json:"-"` +} + +// attackLayer7TopAttacksResponseTop0JSON contains the JSON metadata for the struct +// [AttackLayer7TopAttacksResponseTop0] +type attackLayer7TopAttacksResponseTop0JSON struct { + OriginCountryAlpha2 apijson.Field + OriginCountryName apijson.Field + TargetCountryAlpha2 apijson.Field + TargetCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopAttacksResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopAttacksResponseTop0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopIndustryResponse struct { + Meta AttackLayer7TopIndustryResponseMeta `json:"meta,required"` + Top0 []AttackLayer7TopIndustryResponseTop0 `json:"top_0,required"` + JSON attackLayer7TopIndustryResponseJSON `json:"-"` +} + +// attackLayer7TopIndustryResponseJSON contains the JSON metadata for the struct +// [AttackLayer7TopIndustryResponse] +type attackLayer7TopIndustryResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopIndustryResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopIndustryResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopIndustryResponseMeta struct { + DateRange []AttackLayer7TopIndustryResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo AttackLayer7TopIndustryResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer7TopIndustryResponseMetaJSON `json:"-"` +} + +// attackLayer7TopIndustryResponseMetaJSON contains the JSON metadata for the +// struct [AttackLayer7TopIndustryResponseMeta] +type attackLayer7TopIndustryResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopIndustryResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopIndustryResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopIndustryResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer7TopIndustryResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer7TopIndustryResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [AttackLayer7TopIndustryResponseMetaDateRange] +type attackLayer7TopIndustryResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopIndustryResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopIndustryResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopIndustryResponseMetaConfidenceInfo struct { + Annotations []AttackLayer7TopIndustryResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer7TopIndustryResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer7TopIndustryResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [AttackLayer7TopIndustryResponseMetaConfidenceInfo] +type attackLayer7TopIndustryResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopIndustryResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopIndustryResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopIndustryResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer7TopIndustryResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer7TopIndustryResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [AttackLayer7TopIndustryResponseMetaConfidenceInfoAnnotation] +type attackLayer7TopIndustryResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopIndustryResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopIndustryResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopIndustryResponseTop0 struct { + Name string `json:"name,required"` + Value string `json:"value,required"` + JSON attackLayer7TopIndustryResponseTop0JSON `json:"-"` +} + +// attackLayer7TopIndustryResponseTop0JSON contains the JSON metadata for the +// struct [AttackLayer7TopIndustryResponseTop0] +type attackLayer7TopIndustryResponseTop0JSON struct { + Name apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopIndustryResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopIndustryResponseTop0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopVerticalResponse struct { + Meta AttackLayer7TopVerticalResponseMeta `json:"meta,required"` + Top0 []AttackLayer7TopVerticalResponseTop0 `json:"top_0,required"` + JSON attackLayer7TopVerticalResponseJSON `json:"-"` +} + +// attackLayer7TopVerticalResponseJSON contains the JSON metadata for the struct +// [AttackLayer7TopVerticalResponse] +type attackLayer7TopVerticalResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopVerticalResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopVerticalResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopVerticalResponseMeta struct { + DateRange []AttackLayer7TopVerticalResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo AttackLayer7TopVerticalResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer7TopVerticalResponseMetaJSON `json:"-"` +} + +// attackLayer7TopVerticalResponseMetaJSON contains the JSON metadata for the +// struct [AttackLayer7TopVerticalResponseMeta] +type attackLayer7TopVerticalResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopVerticalResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopVerticalResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopVerticalResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer7TopVerticalResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer7TopVerticalResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [AttackLayer7TopVerticalResponseMetaDateRange] +type attackLayer7TopVerticalResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopVerticalResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopVerticalResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopVerticalResponseMetaConfidenceInfo struct { + Annotations []AttackLayer7TopVerticalResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer7TopVerticalResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer7TopVerticalResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [AttackLayer7TopVerticalResponseMetaConfidenceInfo] +type attackLayer7TopVerticalResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopVerticalResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopVerticalResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopVerticalResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer7TopVerticalResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer7TopVerticalResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [AttackLayer7TopVerticalResponseMetaConfidenceInfoAnnotation] +type attackLayer7TopVerticalResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopVerticalResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopVerticalResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopVerticalResponseTop0 struct { + Name string `json:"name,required"` + Value string `json:"value,required"` + JSON attackLayer7TopVerticalResponseTop0JSON `json:"-"` +} + +// attackLayer7TopVerticalResponseTop0JSON contains the JSON metadata for the +// struct [AttackLayer7TopVerticalResponseTop0] +type attackLayer7TopVerticalResponseTop0JSON struct { + Name apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopVerticalResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopVerticalResponseTop0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopAttacksParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7TopAttacksParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7TopAttacksParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of attack origin/target location attack limits. Together with + // `limitPerLocation`, limits how many objects will be fetched per origin/target + // location. + LimitDirection param.Field[AttackLayer7TopAttacksParamsLimitDirection] `query:"limitDirection"` + // Limit the number of attacks per origin/target (refer to `limitDirection` + // parameter) location. + LimitPerLocation param.Field[int64] `query:"limitPerLocation"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Attack magnitude can be defined by total requests mitigated or by total zones + // attacked. + Magnitude param.Field[AttackLayer7TopAttacksParamsMagnitude] `query:"magnitude"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AttackLayer7TopAttacksParams]'s query parameters as +// `url.Values`. +func (r AttackLayer7TopAttacksParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer7TopAttacksParamsDateRange string + +const ( + AttackLayer7TopAttacksParamsDateRange1d AttackLayer7TopAttacksParamsDateRange = "1d" + AttackLayer7TopAttacksParamsDateRange2d AttackLayer7TopAttacksParamsDateRange = "2d" + AttackLayer7TopAttacksParamsDateRange7d AttackLayer7TopAttacksParamsDateRange = "7d" + AttackLayer7TopAttacksParamsDateRange14d AttackLayer7TopAttacksParamsDateRange = "14d" + AttackLayer7TopAttacksParamsDateRange28d AttackLayer7TopAttacksParamsDateRange = "28d" + AttackLayer7TopAttacksParamsDateRange12w AttackLayer7TopAttacksParamsDateRange = "12w" + AttackLayer7TopAttacksParamsDateRange24w AttackLayer7TopAttacksParamsDateRange = "24w" + AttackLayer7TopAttacksParamsDateRange52w AttackLayer7TopAttacksParamsDateRange = "52w" + AttackLayer7TopAttacksParamsDateRange1dControl AttackLayer7TopAttacksParamsDateRange = "1dControl" + AttackLayer7TopAttacksParamsDateRange2dControl AttackLayer7TopAttacksParamsDateRange = "2dControl" + AttackLayer7TopAttacksParamsDateRange7dControl AttackLayer7TopAttacksParamsDateRange = "7dControl" + AttackLayer7TopAttacksParamsDateRange14dControl AttackLayer7TopAttacksParamsDateRange = "14dControl" + AttackLayer7TopAttacksParamsDateRange28dControl AttackLayer7TopAttacksParamsDateRange = "28dControl" + AttackLayer7TopAttacksParamsDateRange12wControl AttackLayer7TopAttacksParamsDateRange = "12wControl" + AttackLayer7TopAttacksParamsDateRange24wControl AttackLayer7TopAttacksParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7TopAttacksParamsFormat string + +const ( + AttackLayer7TopAttacksParamsFormatJson AttackLayer7TopAttacksParamsFormat = "JSON" + AttackLayer7TopAttacksParamsFormatCsv AttackLayer7TopAttacksParamsFormat = "CSV" +) + +// Array of attack origin/target location attack limits. Together with +// `limitPerLocation`, limits how many objects will be fetched per origin/target +// location. +type AttackLayer7TopAttacksParamsLimitDirection string + +const ( + AttackLayer7TopAttacksParamsLimitDirectionOrigin AttackLayer7TopAttacksParamsLimitDirection = "ORIGIN" + AttackLayer7TopAttacksParamsLimitDirectionTarget AttackLayer7TopAttacksParamsLimitDirection = "TARGET" +) + +// Attack magnitude can be defined by total requests mitigated or by total zones +// attacked. +type AttackLayer7TopAttacksParamsMagnitude string + +const ( + AttackLayer7TopAttacksParamsMagnitudeAffectedZones AttackLayer7TopAttacksParamsMagnitude = "AFFECTED_ZONES" + AttackLayer7TopAttacksParamsMagnitudeMitigatedRequests AttackLayer7TopAttacksParamsMagnitude = "MITIGATED_REQUESTS" +) + +type AttackLayer7TopAttacksResponseEnvelope struct { + Result AttackLayer7TopAttacksResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7TopAttacksResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7TopAttacksResponseEnvelopeJSON contains the JSON metadata for the +// struct [AttackLayer7TopAttacksResponseEnvelope] +type attackLayer7TopAttacksResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopAttacksResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopAttacksResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopIndustryParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7TopIndustryParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7TopIndustryParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AttackLayer7TopIndustryParams]'s query parameters as +// `url.Values`. +func (r AttackLayer7TopIndustryParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer7TopIndustryParamsDateRange string + +const ( + AttackLayer7TopIndustryParamsDateRange1d AttackLayer7TopIndustryParamsDateRange = "1d" + AttackLayer7TopIndustryParamsDateRange2d AttackLayer7TopIndustryParamsDateRange = "2d" + AttackLayer7TopIndustryParamsDateRange7d AttackLayer7TopIndustryParamsDateRange = "7d" + AttackLayer7TopIndustryParamsDateRange14d AttackLayer7TopIndustryParamsDateRange = "14d" + AttackLayer7TopIndustryParamsDateRange28d AttackLayer7TopIndustryParamsDateRange = "28d" + AttackLayer7TopIndustryParamsDateRange12w AttackLayer7TopIndustryParamsDateRange = "12w" + AttackLayer7TopIndustryParamsDateRange24w AttackLayer7TopIndustryParamsDateRange = "24w" + AttackLayer7TopIndustryParamsDateRange52w AttackLayer7TopIndustryParamsDateRange = "52w" + AttackLayer7TopIndustryParamsDateRange1dControl AttackLayer7TopIndustryParamsDateRange = "1dControl" + AttackLayer7TopIndustryParamsDateRange2dControl AttackLayer7TopIndustryParamsDateRange = "2dControl" + AttackLayer7TopIndustryParamsDateRange7dControl AttackLayer7TopIndustryParamsDateRange = "7dControl" + AttackLayer7TopIndustryParamsDateRange14dControl AttackLayer7TopIndustryParamsDateRange = "14dControl" + AttackLayer7TopIndustryParamsDateRange28dControl AttackLayer7TopIndustryParamsDateRange = "28dControl" + AttackLayer7TopIndustryParamsDateRange12wControl AttackLayer7TopIndustryParamsDateRange = "12wControl" + AttackLayer7TopIndustryParamsDateRange24wControl AttackLayer7TopIndustryParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7TopIndustryParamsFormat string + +const ( + AttackLayer7TopIndustryParamsFormatJson AttackLayer7TopIndustryParamsFormat = "JSON" + AttackLayer7TopIndustryParamsFormatCsv AttackLayer7TopIndustryParamsFormat = "CSV" +) + +type AttackLayer7TopIndustryResponseEnvelope struct { + Result AttackLayer7TopIndustryResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7TopIndustryResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7TopIndustryResponseEnvelopeJSON contains the JSON metadata for the +// struct [AttackLayer7TopIndustryResponseEnvelope] +type attackLayer7TopIndustryResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopIndustryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopIndustryResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopVerticalParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7TopVerticalParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7TopVerticalParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AttackLayer7TopVerticalParams]'s query parameters as +// `url.Values`. +func (r AttackLayer7TopVerticalParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer7TopVerticalParamsDateRange string + +const ( + AttackLayer7TopVerticalParamsDateRange1d AttackLayer7TopVerticalParamsDateRange = "1d" + AttackLayer7TopVerticalParamsDateRange2d AttackLayer7TopVerticalParamsDateRange = "2d" + AttackLayer7TopVerticalParamsDateRange7d AttackLayer7TopVerticalParamsDateRange = "7d" + AttackLayer7TopVerticalParamsDateRange14d AttackLayer7TopVerticalParamsDateRange = "14d" + AttackLayer7TopVerticalParamsDateRange28d AttackLayer7TopVerticalParamsDateRange = "28d" + AttackLayer7TopVerticalParamsDateRange12w AttackLayer7TopVerticalParamsDateRange = "12w" + AttackLayer7TopVerticalParamsDateRange24w AttackLayer7TopVerticalParamsDateRange = "24w" + AttackLayer7TopVerticalParamsDateRange52w AttackLayer7TopVerticalParamsDateRange = "52w" + AttackLayer7TopVerticalParamsDateRange1dControl AttackLayer7TopVerticalParamsDateRange = "1dControl" + AttackLayer7TopVerticalParamsDateRange2dControl AttackLayer7TopVerticalParamsDateRange = "2dControl" + AttackLayer7TopVerticalParamsDateRange7dControl AttackLayer7TopVerticalParamsDateRange = "7dControl" + AttackLayer7TopVerticalParamsDateRange14dControl AttackLayer7TopVerticalParamsDateRange = "14dControl" + AttackLayer7TopVerticalParamsDateRange28dControl AttackLayer7TopVerticalParamsDateRange = "28dControl" + AttackLayer7TopVerticalParamsDateRange12wControl AttackLayer7TopVerticalParamsDateRange = "12wControl" + AttackLayer7TopVerticalParamsDateRange24wControl AttackLayer7TopVerticalParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7TopVerticalParamsFormat string + +const ( + AttackLayer7TopVerticalParamsFormatJson AttackLayer7TopVerticalParamsFormat = "JSON" + AttackLayer7TopVerticalParamsFormatCsv AttackLayer7TopVerticalParamsFormat = "CSV" +) + +type AttackLayer7TopVerticalResponseEnvelope struct { + Result AttackLayer7TopVerticalResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7TopVerticalResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7TopVerticalResponseEnvelopeJSON contains the JSON metadata for the +// struct [AttackLayer7TopVerticalResponseEnvelope] +type attackLayer7TopVerticalResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopVerticalResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopVerticalResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/attacklayer7top_test.go b/radar/attacklayer7top_test.go new file mode 100644 index 00000000000..d642741dac8 --- /dev/null +++ b/radar/attacklayer7top_test.go @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestAttackLayer7TopAttacksWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.Top.Attacks(context.TODO(), radar.AttackLayer7TopAttacksParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7TopAttacksParamsDateRange{radar.AttackLayer7TopAttacksParamsDateRange1d, radar.AttackLayer7TopAttacksParamsDateRange2d, radar.AttackLayer7TopAttacksParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7TopAttacksParamsFormatJson), + Limit: cloudflare.F(int64(5)), + LimitDirection: cloudflare.F(radar.AttackLayer7TopAttacksParamsLimitDirectionOrigin), + LimitPerLocation: cloudflare.F(int64(10)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Magnitude: cloudflare.F(radar.AttackLayer7TopAttacksParamsMagnitudeMitigatedRequests), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAttackLayer7TopIndustryWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.Top.Industry(context.TODO(), radar.AttackLayer7TopIndustryParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7TopIndustryParamsDateRange{radar.AttackLayer7TopIndustryParamsDateRange1d, radar.AttackLayer7TopIndustryParamsDateRange2d, radar.AttackLayer7TopIndustryParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7TopIndustryParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAttackLayer7TopVerticalWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.Top.Vertical(context.TODO(), radar.AttackLayer7TopVerticalParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7TopVerticalParamsDateRange{radar.AttackLayer7TopVerticalParamsDateRange1d, radar.AttackLayer7TopVerticalParamsDateRange2d, radar.AttackLayer7TopVerticalParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7TopVerticalParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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/radar/attacklayer7topase.go b/radar/attacklayer7topase.go new file mode 100644 index 00000000000..05d41c96092 --- /dev/null +++ b/radar/attacklayer7topase.go @@ -0,0 +1,291 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AttackLayer7TopAseService 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 [NewAttackLayer7TopAseService] method +// instead. +type AttackLayer7TopAseService struct { + Options []option.RequestOption +} + +// NewAttackLayer7TopAseService 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 NewAttackLayer7TopAseService(opts ...option.RequestOption) (r *AttackLayer7TopAseService) { + r = &AttackLayer7TopAseService{} + r.Options = opts + return +} + +// Get the top origin Autonomous Systems of and by layer 7 attacks. Values are a +// percentage out of the total layer 7 attacks. The origin Autonomous Systems is +// determined by the client IP. +func (r *AttackLayer7TopAseService) Origin(ctx context.Context, query AttackLayer7TopAseOriginParams, opts ...option.RequestOption) (res *AttackLayer7TopAseOriginResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7TopAseOriginResponseEnvelope + path := "radar/attacks/layer7/top/ases/origin" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AttackLayer7TopAseOriginResponse struct { + Meta AttackLayer7TopAseOriginResponseMeta `json:"meta,required"` + Top0 []AttackLayer7TopAseOriginResponseTop0 `json:"top_0,required"` + JSON attackLayer7TopAseOriginResponseJSON `json:"-"` +} + +// attackLayer7TopAseOriginResponseJSON contains the JSON metadata for the struct +// [AttackLayer7TopAseOriginResponse] +type attackLayer7TopAseOriginResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopAseOriginResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopAseOriginResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopAseOriginResponseMeta struct { + DateRange []AttackLayer7TopAseOriginResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo AttackLayer7TopAseOriginResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer7TopAseOriginResponseMetaJSON `json:"-"` +} + +// attackLayer7TopAseOriginResponseMetaJSON contains the JSON metadata for the +// struct [AttackLayer7TopAseOriginResponseMeta] +type attackLayer7TopAseOriginResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopAseOriginResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopAseOriginResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopAseOriginResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer7TopAseOriginResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer7TopAseOriginResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [AttackLayer7TopAseOriginResponseMetaDateRange] +type attackLayer7TopAseOriginResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopAseOriginResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopAseOriginResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopAseOriginResponseMetaConfidenceInfo struct { + Annotations []AttackLayer7TopAseOriginResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer7TopAseOriginResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer7TopAseOriginResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [AttackLayer7TopAseOriginResponseMetaConfidenceInfo] +type attackLayer7TopAseOriginResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopAseOriginResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopAseOriginResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopAseOriginResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer7TopAseOriginResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer7TopAseOriginResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [AttackLayer7TopAseOriginResponseMetaConfidenceInfoAnnotation] +type attackLayer7TopAseOriginResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopAseOriginResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopAseOriginResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopAseOriginResponseTop0 struct { + OriginASN string `json:"originAsn,required"` + OriginASNName string `json:"originAsnName,required"` + Rank float64 `json:"rank,required"` + Value string `json:"value,required"` + JSON attackLayer7TopAseOriginResponseTop0JSON `json:"-"` +} + +// attackLayer7TopAseOriginResponseTop0JSON contains the JSON metadata for the +// struct [AttackLayer7TopAseOriginResponseTop0] +type attackLayer7TopAseOriginResponseTop0JSON struct { + OriginASN apijson.Field + OriginASNName apijson.Field + Rank apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopAseOriginResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopAseOriginResponseTop0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopAseOriginParams struct { + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7TopAseOriginParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7TopAseOriginParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AttackLayer7TopAseOriginParams]'s query parameters as +// `url.Values`. +func (r AttackLayer7TopAseOriginParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer7TopAseOriginParamsDateRange string + +const ( + AttackLayer7TopAseOriginParamsDateRange1d AttackLayer7TopAseOriginParamsDateRange = "1d" + AttackLayer7TopAseOriginParamsDateRange2d AttackLayer7TopAseOriginParamsDateRange = "2d" + AttackLayer7TopAseOriginParamsDateRange7d AttackLayer7TopAseOriginParamsDateRange = "7d" + AttackLayer7TopAseOriginParamsDateRange14d AttackLayer7TopAseOriginParamsDateRange = "14d" + AttackLayer7TopAseOriginParamsDateRange28d AttackLayer7TopAseOriginParamsDateRange = "28d" + AttackLayer7TopAseOriginParamsDateRange12w AttackLayer7TopAseOriginParamsDateRange = "12w" + AttackLayer7TopAseOriginParamsDateRange24w AttackLayer7TopAseOriginParamsDateRange = "24w" + AttackLayer7TopAseOriginParamsDateRange52w AttackLayer7TopAseOriginParamsDateRange = "52w" + AttackLayer7TopAseOriginParamsDateRange1dControl AttackLayer7TopAseOriginParamsDateRange = "1dControl" + AttackLayer7TopAseOriginParamsDateRange2dControl AttackLayer7TopAseOriginParamsDateRange = "2dControl" + AttackLayer7TopAseOriginParamsDateRange7dControl AttackLayer7TopAseOriginParamsDateRange = "7dControl" + AttackLayer7TopAseOriginParamsDateRange14dControl AttackLayer7TopAseOriginParamsDateRange = "14dControl" + AttackLayer7TopAseOriginParamsDateRange28dControl AttackLayer7TopAseOriginParamsDateRange = "28dControl" + AttackLayer7TopAseOriginParamsDateRange12wControl AttackLayer7TopAseOriginParamsDateRange = "12wControl" + AttackLayer7TopAseOriginParamsDateRange24wControl AttackLayer7TopAseOriginParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7TopAseOriginParamsFormat string + +const ( + AttackLayer7TopAseOriginParamsFormatJson AttackLayer7TopAseOriginParamsFormat = "JSON" + AttackLayer7TopAseOriginParamsFormatCsv AttackLayer7TopAseOriginParamsFormat = "CSV" +) + +type AttackLayer7TopAseOriginResponseEnvelope struct { + Result AttackLayer7TopAseOriginResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7TopAseOriginResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7TopAseOriginResponseEnvelopeJSON contains the JSON metadata for the +// struct [AttackLayer7TopAseOriginResponseEnvelope] +type attackLayer7TopAseOriginResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopAseOriginResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopAseOriginResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/attacklayer7topase_test.go b/radar/attacklayer7topase_test.go new file mode 100644 index 00000000000..a6e6ba6ba4d --- /dev/null +++ b/radar/attacklayer7topase_test.go @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestAttackLayer7TopAseOriginWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.Top.Ases.Origin(context.TODO(), radar.AttackLayer7TopAseOriginParams{ + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7TopAseOriginParamsDateRange{radar.AttackLayer7TopAseOriginParamsDateRange1d, radar.AttackLayer7TopAseOriginParamsDateRange2d, radar.AttackLayer7TopAseOriginParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7TopAseOriginParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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/radar/attacklayer7toplocation.go b/radar/attacklayer7toplocation.go new file mode 100644 index 00000000000..f5b848c4e3c --- /dev/null +++ b/radar/attacklayer7toplocation.go @@ -0,0 +1,546 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AttackLayer7TopLocationService 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 +// [NewAttackLayer7TopLocationService] method instead. +type AttackLayer7TopLocationService struct { + Options []option.RequestOption +} + +// NewAttackLayer7TopLocationService 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 NewAttackLayer7TopLocationService(opts ...option.RequestOption) (r *AttackLayer7TopLocationService) { + r = &AttackLayer7TopLocationService{} + r.Options = opts + return +} + +// Get the top origin locations of and by layer 7 attacks. Values are a percentage +// out of the total layer 7 attacks. The origin location is determined by the +// client IP. +func (r *AttackLayer7TopLocationService) Origin(ctx context.Context, query AttackLayer7TopLocationOriginParams, opts ...option.RequestOption) (res *AttackLayer7TopLocationOriginResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7TopLocationOriginResponseEnvelope + path := "radar/attacks/layer7/top/locations/origin" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the top target locations of and by layer 7 attacks. Values are a percentage +// out of the total layer 7 attacks. The target location is determined by the +// attacked zone's billing country, when available. +func (r *AttackLayer7TopLocationService) Target(ctx context.Context, query AttackLayer7TopLocationTargetParams, opts ...option.RequestOption) (res *AttackLayer7TopLocationTargetResponse, err error) { + opts = append(r.Options[:], opts...) + var env AttackLayer7TopLocationTargetResponseEnvelope + path := "radar/attacks/layer7/top/locations/target" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AttackLayer7TopLocationOriginResponse struct { + Meta AttackLayer7TopLocationOriginResponseMeta `json:"meta,required"` + Top0 []AttackLayer7TopLocationOriginResponseTop0 `json:"top_0,required"` + JSON attackLayer7TopLocationOriginResponseJSON `json:"-"` +} + +// attackLayer7TopLocationOriginResponseJSON contains the JSON metadata for the +// struct [AttackLayer7TopLocationOriginResponse] +type attackLayer7TopLocationOriginResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopLocationOriginResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopLocationOriginResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopLocationOriginResponseMeta struct { + DateRange []AttackLayer7TopLocationOriginResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo AttackLayer7TopLocationOriginResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer7TopLocationOriginResponseMetaJSON `json:"-"` +} + +// attackLayer7TopLocationOriginResponseMetaJSON contains the JSON metadata for the +// struct [AttackLayer7TopLocationOriginResponseMeta] +type attackLayer7TopLocationOriginResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopLocationOriginResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopLocationOriginResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopLocationOriginResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer7TopLocationOriginResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer7TopLocationOriginResponseMetaDateRangeJSON contains the JSON +// metadata for the struct [AttackLayer7TopLocationOriginResponseMetaDateRange] +type attackLayer7TopLocationOriginResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopLocationOriginResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopLocationOriginResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopLocationOriginResponseMetaConfidenceInfo struct { + Annotations []AttackLayer7TopLocationOriginResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer7TopLocationOriginResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer7TopLocationOriginResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct +// [AttackLayer7TopLocationOriginResponseMetaConfidenceInfo] +type attackLayer7TopLocationOriginResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopLocationOriginResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopLocationOriginResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopLocationOriginResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer7TopLocationOriginResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer7TopLocationOriginResponseMetaConfidenceInfoAnnotationJSON contains +// the JSON metadata for the struct +// [AttackLayer7TopLocationOriginResponseMetaConfidenceInfoAnnotation] +type attackLayer7TopLocationOriginResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopLocationOriginResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopLocationOriginResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopLocationOriginResponseTop0 struct { + OriginCountryAlpha2 string `json:"originCountryAlpha2,required"` + OriginCountryName string `json:"originCountryName,required"` + Rank float64 `json:"rank,required"` + Value string `json:"value,required"` + JSON attackLayer7TopLocationOriginResponseTop0JSON `json:"-"` +} + +// attackLayer7TopLocationOriginResponseTop0JSON contains the JSON metadata for the +// struct [AttackLayer7TopLocationOriginResponseTop0] +type attackLayer7TopLocationOriginResponseTop0JSON struct { + OriginCountryAlpha2 apijson.Field + OriginCountryName apijson.Field + Rank apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopLocationOriginResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopLocationOriginResponseTop0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopLocationTargetResponse struct { + Meta AttackLayer7TopLocationTargetResponseMeta `json:"meta,required"` + Top0 []AttackLayer7TopLocationTargetResponseTop0 `json:"top_0,required"` + JSON attackLayer7TopLocationTargetResponseJSON `json:"-"` +} + +// attackLayer7TopLocationTargetResponseJSON contains the JSON metadata for the +// struct [AttackLayer7TopLocationTargetResponse] +type attackLayer7TopLocationTargetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopLocationTargetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopLocationTargetResponseJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopLocationTargetResponseMeta struct { + DateRange []AttackLayer7TopLocationTargetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo AttackLayer7TopLocationTargetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON attackLayer7TopLocationTargetResponseMetaJSON `json:"-"` +} + +// attackLayer7TopLocationTargetResponseMetaJSON contains the JSON metadata for the +// struct [AttackLayer7TopLocationTargetResponseMeta] +type attackLayer7TopLocationTargetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopLocationTargetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopLocationTargetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopLocationTargetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON attackLayer7TopLocationTargetResponseMetaDateRangeJSON `json:"-"` +} + +// attackLayer7TopLocationTargetResponseMetaDateRangeJSON contains the JSON +// metadata for the struct [AttackLayer7TopLocationTargetResponseMetaDateRange] +type attackLayer7TopLocationTargetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopLocationTargetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopLocationTargetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopLocationTargetResponseMetaConfidenceInfo struct { + Annotations []AttackLayer7TopLocationTargetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON attackLayer7TopLocationTargetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// attackLayer7TopLocationTargetResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct +// [AttackLayer7TopLocationTargetResponseMetaConfidenceInfo] +type attackLayer7TopLocationTargetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopLocationTargetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopLocationTargetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopLocationTargetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON attackLayer7TopLocationTargetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// attackLayer7TopLocationTargetResponseMetaConfidenceInfoAnnotationJSON contains +// the JSON metadata for the struct +// [AttackLayer7TopLocationTargetResponseMetaConfidenceInfoAnnotation] +type attackLayer7TopLocationTargetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopLocationTargetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopLocationTargetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopLocationTargetResponseTop0 struct { + Rank float64 `json:"rank,required"` + TargetCountryAlpha2 string `json:"targetCountryAlpha2,required"` + TargetCountryName string `json:"targetCountryName,required"` + Value string `json:"value,required"` + JSON attackLayer7TopLocationTargetResponseTop0JSON `json:"-"` +} + +// attackLayer7TopLocationTargetResponseTop0JSON contains the JSON metadata for the +// struct [AttackLayer7TopLocationTargetResponseTop0] +type attackLayer7TopLocationTargetResponseTop0JSON struct { + Rank apijson.Field + TargetCountryAlpha2 apijson.Field + TargetCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopLocationTargetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopLocationTargetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopLocationOriginParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7TopLocationOriginParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7TopLocationOriginParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AttackLayer7TopLocationOriginParams]'s query parameters as +// `url.Values`. +func (r AttackLayer7TopLocationOriginParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer7TopLocationOriginParamsDateRange string + +const ( + AttackLayer7TopLocationOriginParamsDateRange1d AttackLayer7TopLocationOriginParamsDateRange = "1d" + AttackLayer7TopLocationOriginParamsDateRange2d AttackLayer7TopLocationOriginParamsDateRange = "2d" + AttackLayer7TopLocationOriginParamsDateRange7d AttackLayer7TopLocationOriginParamsDateRange = "7d" + AttackLayer7TopLocationOriginParamsDateRange14d AttackLayer7TopLocationOriginParamsDateRange = "14d" + AttackLayer7TopLocationOriginParamsDateRange28d AttackLayer7TopLocationOriginParamsDateRange = "28d" + AttackLayer7TopLocationOriginParamsDateRange12w AttackLayer7TopLocationOriginParamsDateRange = "12w" + AttackLayer7TopLocationOriginParamsDateRange24w AttackLayer7TopLocationOriginParamsDateRange = "24w" + AttackLayer7TopLocationOriginParamsDateRange52w AttackLayer7TopLocationOriginParamsDateRange = "52w" + AttackLayer7TopLocationOriginParamsDateRange1dControl AttackLayer7TopLocationOriginParamsDateRange = "1dControl" + AttackLayer7TopLocationOriginParamsDateRange2dControl AttackLayer7TopLocationOriginParamsDateRange = "2dControl" + AttackLayer7TopLocationOriginParamsDateRange7dControl AttackLayer7TopLocationOriginParamsDateRange = "7dControl" + AttackLayer7TopLocationOriginParamsDateRange14dControl AttackLayer7TopLocationOriginParamsDateRange = "14dControl" + AttackLayer7TopLocationOriginParamsDateRange28dControl AttackLayer7TopLocationOriginParamsDateRange = "28dControl" + AttackLayer7TopLocationOriginParamsDateRange12wControl AttackLayer7TopLocationOriginParamsDateRange = "12wControl" + AttackLayer7TopLocationOriginParamsDateRange24wControl AttackLayer7TopLocationOriginParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7TopLocationOriginParamsFormat string + +const ( + AttackLayer7TopLocationOriginParamsFormatJson AttackLayer7TopLocationOriginParamsFormat = "JSON" + AttackLayer7TopLocationOriginParamsFormatCsv AttackLayer7TopLocationOriginParamsFormat = "CSV" +) + +type AttackLayer7TopLocationOriginResponseEnvelope struct { + Result AttackLayer7TopLocationOriginResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7TopLocationOriginResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7TopLocationOriginResponseEnvelopeJSON contains the JSON metadata for +// the struct [AttackLayer7TopLocationOriginResponseEnvelope] +type attackLayer7TopLocationOriginResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopLocationOriginResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopLocationOriginResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AttackLayer7TopLocationTargetParams struct { + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]AttackLayer7TopLocationTargetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[AttackLayer7TopLocationTargetParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [AttackLayer7TopLocationTargetParams]'s query parameters as +// `url.Values`. +func (r AttackLayer7TopLocationTargetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AttackLayer7TopLocationTargetParamsDateRange string + +const ( + AttackLayer7TopLocationTargetParamsDateRange1d AttackLayer7TopLocationTargetParamsDateRange = "1d" + AttackLayer7TopLocationTargetParamsDateRange2d AttackLayer7TopLocationTargetParamsDateRange = "2d" + AttackLayer7TopLocationTargetParamsDateRange7d AttackLayer7TopLocationTargetParamsDateRange = "7d" + AttackLayer7TopLocationTargetParamsDateRange14d AttackLayer7TopLocationTargetParamsDateRange = "14d" + AttackLayer7TopLocationTargetParamsDateRange28d AttackLayer7TopLocationTargetParamsDateRange = "28d" + AttackLayer7TopLocationTargetParamsDateRange12w AttackLayer7TopLocationTargetParamsDateRange = "12w" + AttackLayer7TopLocationTargetParamsDateRange24w AttackLayer7TopLocationTargetParamsDateRange = "24w" + AttackLayer7TopLocationTargetParamsDateRange52w AttackLayer7TopLocationTargetParamsDateRange = "52w" + AttackLayer7TopLocationTargetParamsDateRange1dControl AttackLayer7TopLocationTargetParamsDateRange = "1dControl" + AttackLayer7TopLocationTargetParamsDateRange2dControl AttackLayer7TopLocationTargetParamsDateRange = "2dControl" + AttackLayer7TopLocationTargetParamsDateRange7dControl AttackLayer7TopLocationTargetParamsDateRange = "7dControl" + AttackLayer7TopLocationTargetParamsDateRange14dControl AttackLayer7TopLocationTargetParamsDateRange = "14dControl" + AttackLayer7TopLocationTargetParamsDateRange28dControl AttackLayer7TopLocationTargetParamsDateRange = "28dControl" + AttackLayer7TopLocationTargetParamsDateRange12wControl AttackLayer7TopLocationTargetParamsDateRange = "12wControl" + AttackLayer7TopLocationTargetParamsDateRange24wControl AttackLayer7TopLocationTargetParamsDateRange = "24wControl" +) + +// Format results are returned in. +type AttackLayer7TopLocationTargetParamsFormat string + +const ( + AttackLayer7TopLocationTargetParamsFormatJson AttackLayer7TopLocationTargetParamsFormat = "JSON" + AttackLayer7TopLocationTargetParamsFormatCsv AttackLayer7TopLocationTargetParamsFormat = "CSV" +) + +type AttackLayer7TopLocationTargetResponseEnvelope struct { + Result AttackLayer7TopLocationTargetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON attackLayer7TopLocationTargetResponseEnvelopeJSON `json:"-"` +} + +// attackLayer7TopLocationTargetResponseEnvelopeJSON contains the JSON metadata for +// the struct [AttackLayer7TopLocationTargetResponseEnvelope] +type attackLayer7TopLocationTargetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackLayer7TopLocationTargetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackLayer7TopLocationTargetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/attacklayer7toplocation_test.go b/radar/attacklayer7toplocation_test.go new file mode 100644 index 00000000000..8d2f66665ae --- /dev/null +++ b/radar/attacklayer7toplocation_test.go @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestAttackLayer7TopLocationOriginWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.Top.Locations.Origin(context.TODO(), radar.AttackLayer7TopLocationOriginParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7TopLocationOriginParamsDateRange{radar.AttackLayer7TopLocationOriginParamsDateRange1d, radar.AttackLayer7TopLocationOriginParamsDateRange2d, radar.AttackLayer7TopLocationOriginParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7TopLocationOriginParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestAttackLayer7TopLocationTargetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Attacks.Layer7.Top.Locations.Target(context.TODO(), radar.AttackLayer7TopLocationTargetParams{ + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.AttackLayer7TopLocationTargetParamsDateRange{radar.AttackLayer7TopLocationTargetParamsDateRange1d, radar.AttackLayer7TopLocationTargetParamsDateRange2d, radar.AttackLayer7TopLocationTargetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.AttackLayer7TopLocationTargetParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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/radar/bgp.go b/radar/bgp.go new file mode 100644 index 00000000000..dd359835e67 --- /dev/null +++ b/radar/bgp.go @@ -0,0 +1,315 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// BGPService 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 [NewBGPService] method instead. +type BGPService struct { + Options []option.RequestOption + Leaks *BGPLeakService + Top *BGPTopService + Hijacks *BGPHijackService + Routes *BGPRouteService +} + +// NewBGPService 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 NewBGPService(opts ...option.RequestOption) (r *BGPService) { + r = &BGPService{} + r.Options = opts + r.Leaks = NewBGPLeakService(opts...) + r.Top = NewBGPTopService(opts...) + r.Hijacks = NewBGPHijackService(opts...) + r.Routes = NewBGPRouteService(opts...) + return +} + +// Gets BGP updates change over time. Raw values are returned. When requesting +// updates of an autonomous system (AS), only BGP updates of type announcement are +// returned. +func (r *BGPService) Timeseries(ctx context.Context, query BGPTimeseriesParams, opts ...option.RequestOption) (res *BGPTimeseriesResponse, err error) { + opts = append(r.Options[:], opts...) + var env BGPTimeseriesResponseEnvelope + path := "radar/bgp/timeseries" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type BGPTimeseriesResponse struct { + Meta BGPTimeseriesResponseMeta `json:"meta,required"` + Serie0 BGPTimeseriesResponseSerie0 `json:"serie_0,required"` + JSON bgpTimeseriesResponseJSON `json:"-"` +} + +// bgpTimeseriesResponseJSON contains the JSON metadata for the struct +// [BGPTimeseriesResponse] +type bgpTimeseriesResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTimeseriesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTimeseriesResponseJSON) RawJSON() string { + return r.raw +} + +type BGPTimeseriesResponseMeta struct { + AggInterval string `json:"aggInterval,required"` + DateRange []BGPTimeseriesResponseMetaDateRange `json:"dateRange,required"` + LastUpdated time.Time `json:"lastUpdated,required" format:"date-time"` + ConfidenceInfo BGPTimeseriesResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON bgpTimeseriesResponseMetaJSON `json:"-"` +} + +// bgpTimeseriesResponseMetaJSON contains the JSON metadata for the struct +// [BGPTimeseriesResponseMeta] +type bgpTimeseriesResponseMetaJSON struct { + AggInterval apijson.Field + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTimeseriesResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTimeseriesResponseMetaJSON) RawJSON() string { + return r.raw +} + +type BGPTimeseriesResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON bgpTimeseriesResponseMetaDateRangeJSON `json:"-"` +} + +// bgpTimeseriesResponseMetaDateRangeJSON contains the JSON metadata for the struct +// [BGPTimeseriesResponseMetaDateRange] +type bgpTimeseriesResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTimeseriesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTimeseriesResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type BGPTimeseriesResponseMetaConfidenceInfo struct { + Annotations []BGPTimeseriesResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON bgpTimeseriesResponseMetaConfidenceInfoJSON `json:"-"` +} + +// bgpTimeseriesResponseMetaConfidenceInfoJSON contains the JSON metadata for the +// struct [BGPTimeseriesResponseMetaConfidenceInfo] +type bgpTimeseriesResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTimeseriesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTimeseriesResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type BGPTimeseriesResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON bgpTimeseriesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// bgpTimeseriesResponseMetaConfidenceInfoAnnotationJSON contains the JSON metadata +// for the struct [BGPTimeseriesResponseMetaConfidenceInfoAnnotation] +type bgpTimeseriesResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTimeseriesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTimeseriesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type BGPTimeseriesResponseSerie0 struct { + Timestamps []time.Time `json:"timestamps,required" format:"date-time"` + Values []string `json:"values,required"` + JSON bgpTimeseriesResponseSerie0JSON `json:"-"` +} + +// bgpTimeseriesResponseSerie0JSON contains the JSON metadata for the struct +// [BGPTimeseriesResponseSerie0] +type bgpTimeseriesResponseSerie0JSON struct { + Timestamps apijson.Field + Values apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTimeseriesResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTimeseriesResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type BGPTimeseriesParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[BGPTimeseriesParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]BGPTimeseriesParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[BGPTimeseriesParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Array of BGP network prefixes. + Prefix param.Field[[]string] `query:"prefix"` + // Array of BGP update types. + UpdateType param.Field[[]BGPTimeseriesParamsUpdateType] `query:"updateType"` +} + +// URLQuery serializes [BGPTimeseriesParams]'s query parameters as `url.Values`. +func (r BGPTimeseriesParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type BGPTimeseriesParamsAggInterval string + +const ( + BGPTimeseriesParamsAggInterval15m BGPTimeseriesParamsAggInterval = "15m" + BGPTimeseriesParamsAggInterval1h BGPTimeseriesParamsAggInterval = "1h" + BGPTimeseriesParamsAggInterval1d BGPTimeseriesParamsAggInterval = "1d" + BGPTimeseriesParamsAggInterval1w BGPTimeseriesParamsAggInterval = "1w" +) + +type BGPTimeseriesParamsDateRange string + +const ( + BGPTimeseriesParamsDateRange1d BGPTimeseriesParamsDateRange = "1d" + BGPTimeseriesParamsDateRange2d BGPTimeseriesParamsDateRange = "2d" + BGPTimeseriesParamsDateRange7d BGPTimeseriesParamsDateRange = "7d" + BGPTimeseriesParamsDateRange14d BGPTimeseriesParamsDateRange = "14d" + BGPTimeseriesParamsDateRange28d BGPTimeseriesParamsDateRange = "28d" + BGPTimeseriesParamsDateRange12w BGPTimeseriesParamsDateRange = "12w" + BGPTimeseriesParamsDateRange24w BGPTimeseriesParamsDateRange = "24w" + BGPTimeseriesParamsDateRange52w BGPTimeseriesParamsDateRange = "52w" + BGPTimeseriesParamsDateRange1dControl BGPTimeseriesParamsDateRange = "1dControl" + BGPTimeseriesParamsDateRange2dControl BGPTimeseriesParamsDateRange = "2dControl" + BGPTimeseriesParamsDateRange7dControl BGPTimeseriesParamsDateRange = "7dControl" + BGPTimeseriesParamsDateRange14dControl BGPTimeseriesParamsDateRange = "14dControl" + BGPTimeseriesParamsDateRange28dControl BGPTimeseriesParamsDateRange = "28dControl" + BGPTimeseriesParamsDateRange12wControl BGPTimeseriesParamsDateRange = "12wControl" + BGPTimeseriesParamsDateRange24wControl BGPTimeseriesParamsDateRange = "24wControl" +) + +// Format results are returned in. +type BGPTimeseriesParamsFormat string + +const ( + BGPTimeseriesParamsFormatJson BGPTimeseriesParamsFormat = "JSON" + BGPTimeseriesParamsFormatCsv BGPTimeseriesParamsFormat = "CSV" +) + +type BGPTimeseriesParamsUpdateType string + +const ( + BGPTimeseriesParamsUpdateTypeAnnouncement BGPTimeseriesParamsUpdateType = "ANNOUNCEMENT" + BGPTimeseriesParamsUpdateTypeWithdrawal BGPTimeseriesParamsUpdateType = "WITHDRAWAL" +) + +type BGPTimeseriesResponseEnvelope struct { + Result BGPTimeseriesResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON bgpTimeseriesResponseEnvelopeJSON `json:"-"` +} + +// bgpTimeseriesResponseEnvelopeJSON contains the JSON metadata for the struct +// [BGPTimeseriesResponseEnvelope] +type bgpTimeseriesResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTimeseriesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTimeseriesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/bgp_test.go b/radar/bgp_test.go new file mode 100644 index 00000000000..ff2f9ce9fc4 --- /dev/null +++ b/radar/bgp_test.go @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestBGPTimeseriesWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.BGP.Timeseries(context.TODO(), radar.BGPTimeseriesParams{ + AggInterval: cloudflare.F(radar.BGPTimeseriesParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.BGPTimeseriesParamsDateRange{radar.BGPTimeseriesParamsDateRange1d, radar.BGPTimeseriesParamsDateRange2d, radar.BGPTimeseriesParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.BGPTimeseriesParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + Prefix: cloudflare.F([]string{"string", "string", "string"}), + UpdateType: cloudflare.F([]radar.BGPTimeseriesParamsUpdateType{radar.BGPTimeseriesParamsUpdateTypeAnnouncement, radar.BGPTimeseriesParamsUpdateTypeWithdrawal}), + }) + 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/radar/bgphijack.go b/radar/bgphijack.go new file mode 100644 index 00000000000..0594985eaa7 --- /dev/null +++ b/radar/bgphijack.go @@ -0,0 +1,317 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// BGPHijackService 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 [NewBGPHijackService] method instead. +type BGPHijackService struct { + Options []option.RequestOption +} + +// NewBGPHijackService 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 NewBGPHijackService(opts ...option.RequestOption) (r *BGPHijackService) { + r = &BGPHijackService{} + r.Options = opts + return +} + +// Get the BGP hijack events. (Beta) +func (r *BGPHijackService) Events(ctx context.Context, query BGPHijackEventsParams, opts ...option.RequestOption) (res *BGPHijackEventsResponse, err error) { + opts = append(r.Options[:], opts...) + var env BGPHijackEventsResponseEnvelope + path := "radar/bgp/hijacks/events" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type BGPHijackEventsResponse struct { + ASNInfo []BGPHijackEventsResponseASNInfo `json:"asn_info,required"` + Events []BGPHijackEventsResponseEvent `json:"events,required"` + TotalMonitors int64 `json:"total_monitors,required"` + JSON bgpHijackEventsResponseJSON `json:"-"` +} + +// bgpHijackEventsResponseJSON contains the JSON metadata for the struct +// [BGPHijackEventsResponse] +type bgpHijackEventsResponseJSON struct { + ASNInfo apijson.Field + Events apijson.Field + TotalMonitors apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPHijackEventsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpHijackEventsResponseJSON) RawJSON() string { + return r.raw +} + +type BGPHijackEventsResponseASNInfo struct { + ASN int64 `json:"asn,required"` + CountryCode string `json:"country_code,required"` + OrgName string `json:"org_name,required"` + JSON bgpHijackEventsResponseASNInfoJSON `json:"-"` +} + +// bgpHijackEventsResponseASNInfoJSON contains the JSON metadata for the struct +// [BGPHijackEventsResponseASNInfo] +type bgpHijackEventsResponseASNInfoJSON struct { + ASN apijson.Field + CountryCode apijson.Field + OrgName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPHijackEventsResponseASNInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpHijackEventsResponseASNInfoJSON) RawJSON() string { + return r.raw +} + +type BGPHijackEventsResponseEvent struct { + ID int64 `json:"id,required"` + ConfidenceScore int64 `json:"confidence_score,required"` + Duration int64 `json:"duration,required"` + EventType int64 `json:"event_type,required"` + HijackMsgsCount int64 `json:"hijack_msgs_count,required"` + HijackerASN int64 `json:"hijacker_asn,required"` + HijackerCountry string `json:"hijacker_country,required"` + IsStale bool `json:"is_stale,required"` + MaxHijackTs string `json:"max_hijack_ts,required"` + MaxMsgTs string `json:"max_msg_ts,required"` + MinHijackTs string `json:"min_hijack_ts,required"` + OnGoingCount int64 `json:"on_going_count,required"` + PeerASNs []int64 `json:"peer_asns,required"` + PeerIPCount int64 `json:"peer_ip_count,required"` + Prefixes []string `json:"prefixes,required"` + Tags []BGPHijackEventsResponseEventsTag `json:"tags,required"` + VictimASNs []int64 `json:"victim_asns,required"` + VictimCountries []string `json:"victim_countries,required"` + JSON bgpHijackEventsResponseEventJSON `json:"-"` +} + +// bgpHijackEventsResponseEventJSON contains the JSON metadata for the struct +// [BGPHijackEventsResponseEvent] +type bgpHijackEventsResponseEventJSON struct { + ID apijson.Field + ConfidenceScore apijson.Field + Duration apijson.Field + EventType apijson.Field + HijackMsgsCount apijson.Field + HijackerASN apijson.Field + HijackerCountry apijson.Field + IsStale apijson.Field + MaxHijackTs apijson.Field + MaxMsgTs apijson.Field + MinHijackTs apijson.Field + OnGoingCount apijson.Field + PeerASNs apijson.Field + PeerIPCount apijson.Field + Prefixes apijson.Field + Tags apijson.Field + VictimASNs apijson.Field + VictimCountries apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPHijackEventsResponseEvent) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpHijackEventsResponseEventJSON) RawJSON() string { + return r.raw +} + +type BGPHijackEventsResponseEventsTag struct { + Name string `json:"name,required"` + Score int64 `json:"score,required"` + JSON bgpHijackEventsResponseEventsTagJSON `json:"-"` +} + +// bgpHijackEventsResponseEventsTagJSON contains the JSON metadata for the struct +// [BGPHijackEventsResponseEventsTag] +type bgpHijackEventsResponseEventsTagJSON struct { + Name apijson.Field + Score apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPHijackEventsResponseEventsTag) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpHijackEventsResponseEventsTagJSON) RawJSON() string { + return r.raw +} + +type BGPHijackEventsParams struct { + // End of the date range (inclusive). + DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"` + // Shorthand date ranges for the last X days - use when you don't need specific + // start and end dates. + DateRange param.Field[BGPHijackEventsParamsDateRange] `query:"dateRange"` + // Start of the date range (inclusive). + DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` + // The unique identifier of a event + EventID param.Field[int64] `query:"eventId"` + // Format results are returned in. + Format param.Field[BGPHijackEventsParamsFormat] `query:"format"` + // The potential hijacker AS of a BGP hijack event + HijackerASN param.Field[int64] `query:"hijackerAsn"` + // The potential hijacker or victim AS of a BGP hijack event + InvolvedASN param.Field[int64] `query:"involvedAsn"` + // The country code of the potential hijacker or victim AS of a BGP hijack event + InvolvedCountry param.Field[string] `query:"involvedCountry"` + // The maximum confidence score to filter events (1-4 low, 5-7 mid, 8+ high) + MaxConfidence param.Field[int64] `query:"maxConfidence"` + // The minimum confidence score to filter events (1-4 low, 5-7 mid, 8+ high) + MinConfidence param.Field[int64] `query:"minConfidence"` + // Current page number, starting from 1 + Page param.Field[int64] `query:"page"` + // Number of entries per page + PerPage param.Field[int64] `query:"per_page"` + // The prefix hijacked during a BGP hijack event + Prefix param.Field[string] `query:"prefix"` + // Sort events by field + SortBy param.Field[BGPHijackEventsParamsSortBy] `query:"sortBy"` + // Sort order + SortOrder param.Field[BGPHijackEventsParamsSortOrder] `query:"sortOrder"` + // The potential victim AS of a BGP hijack event + VictimASN param.Field[int64] `query:"victimAsn"` +} + +// URLQuery serializes [BGPHijackEventsParams]'s query parameters as `url.Values`. +func (r BGPHijackEventsParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Shorthand date ranges for the last X days - use when you don't need specific +// start and end dates. +type BGPHijackEventsParamsDateRange string + +const ( + BGPHijackEventsParamsDateRange1d BGPHijackEventsParamsDateRange = "1d" + BGPHijackEventsParamsDateRange2d BGPHijackEventsParamsDateRange = "2d" + BGPHijackEventsParamsDateRange7d BGPHijackEventsParamsDateRange = "7d" + BGPHijackEventsParamsDateRange14d BGPHijackEventsParamsDateRange = "14d" + BGPHijackEventsParamsDateRange28d BGPHijackEventsParamsDateRange = "28d" + BGPHijackEventsParamsDateRange12w BGPHijackEventsParamsDateRange = "12w" + BGPHijackEventsParamsDateRange24w BGPHijackEventsParamsDateRange = "24w" + BGPHijackEventsParamsDateRange52w BGPHijackEventsParamsDateRange = "52w" + BGPHijackEventsParamsDateRange1dControl BGPHijackEventsParamsDateRange = "1dControl" + BGPHijackEventsParamsDateRange2dControl BGPHijackEventsParamsDateRange = "2dControl" + BGPHijackEventsParamsDateRange7dControl BGPHijackEventsParamsDateRange = "7dControl" + BGPHijackEventsParamsDateRange14dControl BGPHijackEventsParamsDateRange = "14dControl" + BGPHijackEventsParamsDateRange28dControl BGPHijackEventsParamsDateRange = "28dControl" + BGPHijackEventsParamsDateRange12wControl BGPHijackEventsParamsDateRange = "12wControl" + BGPHijackEventsParamsDateRange24wControl BGPHijackEventsParamsDateRange = "24wControl" +) + +// Format results are returned in. +type BGPHijackEventsParamsFormat string + +const ( + BGPHijackEventsParamsFormatJson BGPHijackEventsParamsFormat = "JSON" + BGPHijackEventsParamsFormatCsv BGPHijackEventsParamsFormat = "CSV" +) + +// Sort events by field +type BGPHijackEventsParamsSortBy string + +const ( + BGPHijackEventsParamsSortByID BGPHijackEventsParamsSortBy = "ID" + BGPHijackEventsParamsSortByTime BGPHijackEventsParamsSortBy = "TIME" + BGPHijackEventsParamsSortByConfidence BGPHijackEventsParamsSortBy = "CONFIDENCE" +) + +// Sort order +type BGPHijackEventsParamsSortOrder string + +const ( + BGPHijackEventsParamsSortOrderAsc BGPHijackEventsParamsSortOrder = "ASC" + BGPHijackEventsParamsSortOrderDesc BGPHijackEventsParamsSortOrder = "DESC" +) + +type BGPHijackEventsResponseEnvelope struct { + Result BGPHijackEventsResponse `json:"result,required"` + ResultInfo BGPHijackEventsResponseEnvelopeResultInfo `json:"result_info,required"` + Success bool `json:"success,required"` + JSON bgpHijackEventsResponseEnvelopeJSON `json:"-"` +} + +// bgpHijackEventsResponseEnvelopeJSON contains the JSON metadata for the struct +// [BGPHijackEventsResponseEnvelope] +type bgpHijackEventsResponseEnvelopeJSON struct { + Result apijson.Field + ResultInfo apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPHijackEventsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpHijackEventsResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type BGPHijackEventsResponseEnvelopeResultInfo struct { + Count int64 `json:"count,required"` + Page int64 `json:"page,required"` + PerPage int64 `json:"per_page,required"` + TotalCount int64 `json:"total_count,required"` + JSON bgpHijackEventsResponseEnvelopeResultInfoJSON `json:"-"` +} + +// bgpHijackEventsResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [BGPHijackEventsResponseEnvelopeResultInfo] +type bgpHijackEventsResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPHijackEventsResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpHijackEventsResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/radar/bgphijack_test.go b/radar/bgphijack_test.go new file mode 100644 index 00000000000..395da2731ae --- /dev/null +++ b/radar/bgphijack_test.go @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestBGPHijackEventsWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.BGP.Hijacks.Events(context.TODO(), radar.BGPHijackEventsParams{ + DateEnd: cloudflare.F(time.Now()), + DateRange: cloudflare.F(radar.BGPHijackEventsParamsDateRange7d), + DateStart: cloudflare.F(time.Now()), + EventID: cloudflare.F(int64(0)), + Format: cloudflare.F(radar.BGPHijackEventsParamsFormatJson), + HijackerASN: cloudflare.F(int64(0)), + InvolvedASN: cloudflare.F(int64(0)), + InvolvedCountry: cloudflare.F("string"), + MaxConfidence: cloudflare.F(int64(0)), + MinConfidence: cloudflare.F(int64(0)), + Page: cloudflare.F(int64(0)), + PerPage: cloudflare.F(int64(0)), + Prefix: cloudflare.F("string"), + SortBy: cloudflare.F(radar.BGPHijackEventsParamsSortByTime), + SortOrder: cloudflare.F(radar.BGPHijackEventsParamsSortOrderDesc), + VictimASN: cloudflare.F(int64(0)), + }) + 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/radar/bgpleak.go b/radar/bgpleak.go new file mode 100644 index 00000000000..aadbb995e55 --- /dev/null +++ b/radar/bgpleak.go @@ -0,0 +1,277 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// BGPLeakService 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 [NewBGPLeakService] method instead. +type BGPLeakService struct { + Options []option.RequestOption +} + +// NewBGPLeakService 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 NewBGPLeakService(opts ...option.RequestOption) (r *BGPLeakService) { + r = &BGPLeakService{} + r.Options = opts + return +} + +// Get the BGP route leak events (Beta). +func (r *BGPLeakService) Events(ctx context.Context, query BGPLeakEventsParams, opts ...option.RequestOption) (res *BGPLeakEventsResponse, err error) { + opts = append(r.Options[:], opts...) + var env BGPLeakEventsResponseEnvelope + path := "radar/bgp/leaks/events" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type BGPLeakEventsResponse struct { + ASNInfo []BGPLeakEventsResponseASNInfo `json:"asn_info,required"` + Events []BGPLeakEventsResponseEvent `json:"events,required"` + JSON bgpLeakEventsResponseJSON `json:"-"` +} + +// bgpLeakEventsResponseJSON contains the JSON metadata for the struct +// [BGPLeakEventsResponse] +type bgpLeakEventsResponseJSON struct { + ASNInfo apijson.Field + Events apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPLeakEventsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpLeakEventsResponseJSON) RawJSON() string { + return r.raw +} + +type BGPLeakEventsResponseASNInfo struct { + ASN int64 `json:"asn,required"` + CountryCode string `json:"country_code,required"` + OrgName string `json:"org_name,required"` + JSON bgpLeakEventsResponseASNInfoJSON `json:"-"` +} + +// bgpLeakEventsResponseASNInfoJSON contains the JSON metadata for the struct +// [BGPLeakEventsResponseASNInfo] +type bgpLeakEventsResponseASNInfoJSON struct { + ASN apijson.Field + CountryCode apijson.Field + OrgName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPLeakEventsResponseASNInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpLeakEventsResponseASNInfoJSON) RawJSON() string { + return r.raw +} + +type BGPLeakEventsResponseEvent struct { + ID int64 `json:"id,required"` + Countries []string `json:"countries,required"` + DetectedTs string `json:"detected_ts,required"` + Finished bool `json:"finished,required"` + LeakASN int64 `json:"leak_asn,required"` + LeakCount int64 `json:"leak_count,required"` + LeakSeg []int64 `json:"leak_seg,required"` + LeakType int64 `json:"leak_type,required"` + MaxTs string `json:"max_ts,required"` + MinTs string `json:"min_ts,required"` + OriginCount int64 `json:"origin_count,required"` + PeerCount int64 `json:"peer_count,required"` + PrefixCount int64 `json:"prefix_count,required"` + JSON bgpLeakEventsResponseEventJSON `json:"-"` +} + +// bgpLeakEventsResponseEventJSON contains the JSON metadata for the struct +// [BGPLeakEventsResponseEvent] +type bgpLeakEventsResponseEventJSON struct { + ID apijson.Field + Countries apijson.Field + DetectedTs apijson.Field + Finished apijson.Field + LeakASN apijson.Field + LeakCount apijson.Field + LeakSeg apijson.Field + LeakType apijson.Field + MaxTs apijson.Field + MinTs apijson.Field + OriginCount apijson.Field + PeerCount apijson.Field + PrefixCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPLeakEventsResponseEvent) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpLeakEventsResponseEventJSON) RawJSON() string { + return r.raw +} + +type BGPLeakEventsParams struct { + // End of the date range (inclusive). + DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"` + // Shorthand date ranges for the last X days - use when you don't need specific + // start and end dates. + DateRange param.Field[BGPLeakEventsParamsDateRange] `query:"dateRange"` + // Start of the date range (inclusive). + DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` + // The unique identifier of a event + EventID param.Field[int64] `query:"eventId"` + // Format results are returned in. + Format param.Field[BGPLeakEventsParamsFormat] `query:"format"` + // ASN that is causing or affected by a route leak event + InvolvedASN param.Field[int64] `query:"involvedAsn"` + // Country code of a involved ASN in a route leak event + InvolvedCountry param.Field[string] `query:"involvedCountry"` + // The leaking AS of a route leak event + LeakASN param.Field[int64] `query:"leakAsn"` + // Current page number, starting from 1 + Page param.Field[int64] `query:"page"` + // Number of entries per page + PerPage param.Field[int64] `query:"per_page"` + // Sort events by field + SortBy param.Field[BGPLeakEventsParamsSortBy] `query:"sortBy"` + // Sort order + SortOrder param.Field[BGPLeakEventsParamsSortOrder] `query:"sortOrder"` +} + +// URLQuery serializes [BGPLeakEventsParams]'s query parameters as `url.Values`. +func (r BGPLeakEventsParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Shorthand date ranges for the last X days - use when you don't need specific +// start and end dates. +type BGPLeakEventsParamsDateRange string + +const ( + BGPLeakEventsParamsDateRange1d BGPLeakEventsParamsDateRange = "1d" + BGPLeakEventsParamsDateRange2d BGPLeakEventsParamsDateRange = "2d" + BGPLeakEventsParamsDateRange7d BGPLeakEventsParamsDateRange = "7d" + BGPLeakEventsParamsDateRange14d BGPLeakEventsParamsDateRange = "14d" + BGPLeakEventsParamsDateRange28d BGPLeakEventsParamsDateRange = "28d" + BGPLeakEventsParamsDateRange12w BGPLeakEventsParamsDateRange = "12w" + BGPLeakEventsParamsDateRange24w BGPLeakEventsParamsDateRange = "24w" + BGPLeakEventsParamsDateRange52w BGPLeakEventsParamsDateRange = "52w" + BGPLeakEventsParamsDateRange1dControl BGPLeakEventsParamsDateRange = "1dControl" + BGPLeakEventsParamsDateRange2dControl BGPLeakEventsParamsDateRange = "2dControl" + BGPLeakEventsParamsDateRange7dControl BGPLeakEventsParamsDateRange = "7dControl" + BGPLeakEventsParamsDateRange14dControl BGPLeakEventsParamsDateRange = "14dControl" + BGPLeakEventsParamsDateRange28dControl BGPLeakEventsParamsDateRange = "28dControl" + BGPLeakEventsParamsDateRange12wControl BGPLeakEventsParamsDateRange = "12wControl" + BGPLeakEventsParamsDateRange24wControl BGPLeakEventsParamsDateRange = "24wControl" +) + +// Format results are returned in. +type BGPLeakEventsParamsFormat string + +const ( + BGPLeakEventsParamsFormatJson BGPLeakEventsParamsFormat = "JSON" + BGPLeakEventsParamsFormatCsv BGPLeakEventsParamsFormat = "CSV" +) + +// Sort events by field +type BGPLeakEventsParamsSortBy string + +const ( + BGPLeakEventsParamsSortByID BGPLeakEventsParamsSortBy = "ID" + BGPLeakEventsParamsSortByLeaks BGPLeakEventsParamsSortBy = "LEAKS" + BGPLeakEventsParamsSortByPeers BGPLeakEventsParamsSortBy = "PEERS" + BGPLeakEventsParamsSortByPrefixes BGPLeakEventsParamsSortBy = "PREFIXES" + BGPLeakEventsParamsSortByOrigins BGPLeakEventsParamsSortBy = "ORIGINS" + BGPLeakEventsParamsSortByTime BGPLeakEventsParamsSortBy = "TIME" +) + +// Sort order +type BGPLeakEventsParamsSortOrder string + +const ( + BGPLeakEventsParamsSortOrderAsc BGPLeakEventsParamsSortOrder = "ASC" + BGPLeakEventsParamsSortOrderDesc BGPLeakEventsParamsSortOrder = "DESC" +) + +type BGPLeakEventsResponseEnvelope struct { + Result BGPLeakEventsResponse `json:"result,required"` + ResultInfo BGPLeakEventsResponseEnvelopeResultInfo `json:"result_info,required"` + Success bool `json:"success,required"` + JSON bgpLeakEventsResponseEnvelopeJSON `json:"-"` +} + +// bgpLeakEventsResponseEnvelopeJSON contains the JSON metadata for the struct +// [BGPLeakEventsResponseEnvelope] +type bgpLeakEventsResponseEnvelopeJSON struct { + Result apijson.Field + ResultInfo apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPLeakEventsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpLeakEventsResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type BGPLeakEventsResponseEnvelopeResultInfo struct { + Count int64 `json:"count,required"` + Page int64 `json:"page,required"` + PerPage int64 `json:"per_page,required"` + TotalCount int64 `json:"total_count,required"` + JSON bgpLeakEventsResponseEnvelopeResultInfoJSON `json:"-"` +} + +// bgpLeakEventsResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [BGPLeakEventsResponseEnvelopeResultInfo] +type bgpLeakEventsResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPLeakEventsResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpLeakEventsResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/radar/bgpleak_test.go b/radar/bgpleak_test.go new file mode 100644 index 00000000000..3486a8e9d69 --- /dev/null +++ b/radar/bgpleak_test.go @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestBGPLeakEventsWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.BGP.Leaks.Events(context.TODO(), radar.BGPLeakEventsParams{ + DateEnd: cloudflare.F(time.Now()), + DateRange: cloudflare.F(radar.BGPLeakEventsParamsDateRange7d), + DateStart: cloudflare.F(time.Now()), + EventID: cloudflare.F(int64(0)), + Format: cloudflare.F(radar.BGPLeakEventsParamsFormatJson), + InvolvedASN: cloudflare.F(int64(0)), + InvolvedCountry: cloudflare.F("string"), + LeakASN: cloudflare.F(int64(0)), + Page: cloudflare.F(int64(0)), + PerPage: cloudflare.F(int64(0)), + SortBy: cloudflare.F(radar.BGPLeakEventsParamsSortByTime), + SortOrder: cloudflare.F(radar.BGPLeakEventsParamsSortOrderDesc), + }) + 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/radar/bgproute.go b/radar/bgproute.go new file mode 100644 index 00000000000..947ace63ecc --- /dev/null +++ b/radar/bgproute.go @@ -0,0 +1,710 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// BGPRouteService 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 [NewBGPRouteService] method instead. +type BGPRouteService struct { + Options []option.RequestOption +} + +// NewBGPRouteService 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 NewBGPRouteService(opts ...option.RequestOption) (r *BGPRouteService) { + r = &BGPRouteService{} + r.Options = opts + return +} + +// List all Multi-origin AS (MOAS) prefixes on the global routing tables. +func (r *BGPRouteService) Moas(ctx context.Context, query BGPRouteMoasParams, opts ...option.RequestOption) (res *BGPRouteMoasResponse, err error) { + opts = append(r.Options[:], opts...) + var env BGPRouteMoasResponseEnvelope + path := "radar/bgp/routes/moas" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lookup prefix-to-origin mapping on global routing tables. +func (r *BGPRouteService) Pfx2as(ctx context.Context, query BGPRoutePfx2asParams, opts ...option.RequestOption) (res *BGPRoutePfx2asResponse, err error) { + opts = append(r.Options[:], opts...) + var env BGPRoutePfx2asResponseEnvelope + path := "radar/bgp/routes/pfx2as" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the BGP routing table stats (Beta). +func (r *BGPRouteService) Stats(ctx context.Context, query BGPRouteStatsParams, opts ...option.RequestOption) (res *BGPRouteStatsResponse, err error) { + opts = append(r.Options[:], opts...) + var env BGPRouteStatsResponseEnvelope + path := "radar/bgp/routes/stats" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets time-series data for the announced IP space count, represented as the +// number of IPv4 /24s and IPv6 /48s, for a given ASN. +func (r *BGPRouteService) Timeseries(ctx context.Context, query BGPRouteTimeseriesParams, opts ...option.RequestOption) (res *BGPRouteTimeseriesResponse, err error) { + opts = append(r.Options[:], opts...) + var env BGPRouteTimeseriesResponseEnvelope + path := "radar/bgp/routes/timeseries" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type BGPRouteMoasResponse struct { + Meta BGPRouteMoasResponseMeta `json:"meta,required"` + Moas []BGPRouteMoasResponseMoa `json:"moas,required"` + JSON bgpRouteMoasResponseJSON `json:"-"` +} + +// bgpRouteMoasResponseJSON contains the JSON metadata for the struct +// [BGPRouteMoasResponse] +type bgpRouteMoasResponseJSON struct { + Meta apijson.Field + Moas apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRouteMoasResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRouteMoasResponseJSON) RawJSON() string { + return r.raw +} + +type BGPRouteMoasResponseMeta struct { + DataTime string `json:"data_time,required"` + QueryTime string `json:"query_time,required"` + TotalPeers int64 `json:"total_peers,required"` + JSON bgpRouteMoasResponseMetaJSON `json:"-"` +} + +// bgpRouteMoasResponseMetaJSON contains the JSON metadata for the struct +// [BGPRouteMoasResponseMeta] +type bgpRouteMoasResponseMetaJSON struct { + DataTime apijson.Field + QueryTime apijson.Field + TotalPeers apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRouteMoasResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRouteMoasResponseMetaJSON) RawJSON() string { + return r.raw +} + +type BGPRouteMoasResponseMoa struct { + Origins []BGPRouteMoasResponseMoasOrigin `json:"origins,required"` + Prefix string `json:"prefix,required"` + JSON bgpRouteMoasResponseMoaJSON `json:"-"` +} + +// bgpRouteMoasResponseMoaJSON contains the JSON metadata for the struct +// [BGPRouteMoasResponseMoa] +type bgpRouteMoasResponseMoaJSON struct { + Origins apijson.Field + Prefix apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRouteMoasResponseMoa) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRouteMoasResponseMoaJSON) RawJSON() string { + return r.raw +} + +type BGPRouteMoasResponseMoasOrigin struct { + Origin int64 `json:"origin,required"` + PeerCount int64 `json:"peer_count,required"` + RpkiValidation string `json:"rpki_validation,required"` + JSON bgpRouteMoasResponseMoasOriginJSON `json:"-"` +} + +// bgpRouteMoasResponseMoasOriginJSON contains the JSON metadata for the struct +// [BGPRouteMoasResponseMoasOrigin] +type bgpRouteMoasResponseMoasOriginJSON struct { + Origin apijson.Field + PeerCount apijson.Field + RpkiValidation apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRouteMoasResponseMoasOrigin) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRouteMoasResponseMoasOriginJSON) RawJSON() string { + return r.raw +} + +type BGPRoutePfx2asResponse struct { + Meta BGPRoutePfx2asResponseMeta `json:"meta,required"` + PrefixOrigins []BGPRoutePfx2asResponsePrefixOrigin `json:"prefix_origins,required"` + JSON bgpRoutePfx2asResponseJSON `json:"-"` +} + +// bgpRoutePfx2asResponseJSON contains the JSON metadata for the struct +// [BGPRoutePfx2asResponse] +type bgpRoutePfx2asResponseJSON struct { + Meta apijson.Field + PrefixOrigins apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRoutePfx2asResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRoutePfx2asResponseJSON) RawJSON() string { + return r.raw +} + +type BGPRoutePfx2asResponseMeta struct { + DataTime string `json:"data_time,required"` + QueryTime string `json:"query_time,required"` + TotalPeers int64 `json:"total_peers,required"` + JSON bgpRoutePfx2asResponseMetaJSON `json:"-"` +} + +// bgpRoutePfx2asResponseMetaJSON contains the JSON metadata for the struct +// [BGPRoutePfx2asResponseMeta] +type bgpRoutePfx2asResponseMetaJSON struct { + DataTime apijson.Field + QueryTime apijson.Field + TotalPeers apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRoutePfx2asResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRoutePfx2asResponseMetaJSON) RawJSON() string { + return r.raw +} + +type BGPRoutePfx2asResponsePrefixOrigin struct { + Origin int64 `json:"origin,required"` + PeerCount int64 `json:"peer_count,required"` + Prefix string `json:"prefix,required"` + RpkiValidation string `json:"rpki_validation,required"` + JSON bgpRoutePfx2asResponsePrefixOriginJSON `json:"-"` +} + +// bgpRoutePfx2asResponsePrefixOriginJSON contains the JSON metadata for the struct +// [BGPRoutePfx2asResponsePrefixOrigin] +type bgpRoutePfx2asResponsePrefixOriginJSON struct { + Origin apijson.Field + PeerCount apijson.Field + Prefix apijson.Field + RpkiValidation apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRoutePfx2asResponsePrefixOrigin) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRoutePfx2asResponsePrefixOriginJSON) RawJSON() string { + return r.raw +} + +type BGPRouteStatsResponse struct { + Meta BGPRouteStatsResponseMeta `json:"meta,required"` + Stats BGPRouteStatsResponseStats `json:"stats,required"` + JSON bgpRouteStatsResponseJSON `json:"-"` +} + +// bgpRouteStatsResponseJSON contains the JSON metadata for the struct +// [BGPRouteStatsResponse] +type bgpRouteStatsResponseJSON struct { + Meta apijson.Field + Stats apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRouteStatsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRouteStatsResponseJSON) RawJSON() string { + return r.raw +} + +type BGPRouteStatsResponseMeta struct { + DataTime string `json:"data_time,required"` + QueryTime string `json:"query_time,required"` + TotalPeers int64 `json:"total_peers,required"` + JSON bgpRouteStatsResponseMetaJSON `json:"-"` +} + +// bgpRouteStatsResponseMetaJSON contains the JSON metadata for the struct +// [BGPRouteStatsResponseMeta] +type bgpRouteStatsResponseMetaJSON struct { + DataTime apijson.Field + QueryTime apijson.Field + TotalPeers apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRouteStatsResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRouteStatsResponseMetaJSON) RawJSON() string { + return r.raw +} + +type BGPRouteStatsResponseStats struct { + DistinctOrigins int64 `json:"distinct_origins,required"` + DistinctOriginsIPV4 int64 `json:"distinct_origins_ipv4,required"` + DistinctOriginsIPV6 int64 `json:"distinct_origins_ipv6,required"` + DistinctPrefixes int64 `json:"distinct_prefixes,required"` + DistinctPrefixesIPV4 int64 `json:"distinct_prefixes_ipv4,required"` + DistinctPrefixesIPV6 int64 `json:"distinct_prefixes_ipv6,required"` + RoutesInvalid int64 `json:"routes_invalid,required"` + RoutesInvalidIPV4 int64 `json:"routes_invalid_ipv4,required"` + RoutesInvalidIPV6 int64 `json:"routes_invalid_ipv6,required"` + RoutesTotal int64 `json:"routes_total,required"` + RoutesTotalIPV4 int64 `json:"routes_total_ipv4,required"` + RoutesTotalIPV6 int64 `json:"routes_total_ipv6,required"` + RoutesUnknown int64 `json:"routes_unknown,required"` + RoutesUnknownIPV4 int64 `json:"routes_unknown_ipv4,required"` + RoutesUnknownIPV6 int64 `json:"routes_unknown_ipv6,required"` + RoutesValid int64 `json:"routes_valid,required"` + RoutesValidIPV4 int64 `json:"routes_valid_ipv4,required"` + RoutesValidIPV6 int64 `json:"routes_valid_ipv6,required"` + JSON bgpRouteStatsResponseStatsJSON `json:"-"` +} + +// bgpRouteStatsResponseStatsJSON contains the JSON metadata for the struct +// [BGPRouteStatsResponseStats] +type bgpRouteStatsResponseStatsJSON struct { + DistinctOrigins apijson.Field + DistinctOriginsIPV4 apijson.Field + DistinctOriginsIPV6 apijson.Field + DistinctPrefixes apijson.Field + DistinctPrefixesIPV4 apijson.Field + DistinctPrefixesIPV6 apijson.Field + RoutesInvalid apijson.Field + RoutesInvalidIPV4 apijson.Field + RoutesInvalidIPV6 apijson.Field + RoutesTotal apijson.Field + RoutesTotalIPV4 apijson.Field + RoutesTotalIPV6 apijson.Field + RoutesUnknown apijson.Field + RoutesUnknownIPV4 apijson.Field + RoutesUnknownIPV6 apijson.Field + RoutesValid apijson.Field + RoutesValidIPV4 apijson.Field + RoutesValidIPV6 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRouteStatsResponseStats) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRouteStatsResponseStatsJSON) RawJSON() string { + return r.raw +} + +type BGPRouteTimeseriesResponse struct { + Meta BGPRouteTimeseriesResponseMeta `json:"meta,required"` + SerieIPV4_24s BGPRouteTimeseriesResponseSerieIPV4_24s `json:"serie_ipv4_24s,required"` + SerieIPV6_48s BGPRouteTimeseriesResponseSerieIPV6_48s `json:"serie_ipv6_48s,required"` + JSON bgpRouteTimeseriesResponseJSON `json:"-"` +} + +// bgpRouteTimeseriesResponseJSON contains the JSON metadata for the struct +// [BGPRouteTimeseriesResponse] +type bgpRouteTimeseriesResponseJSON struct { + Meta apijson.Field + SerieIPV4_24s apijson.Field + SerieIPV6_48s apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRouteTimeseriesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRouteTimeseriesResponseJSON) RawJSON() string { + return r.raw +} + +type BGPRouteTimeseriesResponseMeta struct { + DateRange []BGPRouteTimeseriesResponseMetaDateRange `json:"dateRange,required"` + JSON bgpRouteTimeseriesResponseMetaJSON `json:"-"` +} + +// bgpRouteTimeseriesResponseMetaJSON contains the JSON metadata for the struct +// [BGPRouteTimeseriesResponseMeta] +type bgpRouteTimeseriesResponseMetaJSON struct { + DateRange apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRouteTimeseriesResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRouteTimeseriesResponseMetaJSON) RawJSON() string { + return r.raw +} + +type BGPRouteTimeseriesResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON bgpRouteTimeseriesResponseMetaDateRangeJSON `json:"-"` +} + +// bgpRouteTimeseriesResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [BGPRouteTimeseriesResponseMetaDateRange] +type bgpRouteTimeseriesResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRouteTimeseriesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRouteTimeseriesResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type BGPRouteTimeseriesResponseSerieIPV4_24s struct { + Timestamps []time.Time `json:"timestamps,required" format:"date-time"` + Values []int64 `json:"values,required"` + JSON bgpRouteTimeseriesResponseSerieIPV4_24sJSON `json:"-"` +} + +// bgpRouteTimeseriesResponseSerieIPV4_24sJSON contains the JSON metadata for the +// struct [BGPRouteTimeseriesResponseSerieIPV4_24s] +type bgpRouteTimeseriesResponseSerieIPV4_24sJSON struct { + Timestamps apijson.Field + Values apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRouteTimeseriesResponseSerieIPV4_24s) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRouteTimeseriesResponseSerieIPV4_24sJSON) RawJSON() string { + return r.raw +} + +type BGPRouteTimeseriesResponseSerieIPV6_48s struct { + Timestamps []time.Time `json:"timestamps,required" format:"date-time"` + Values []int64 `json:"values,required"` + JSON bgpRouteTimeseriesResponseSerieIPV6_48sJSON `json:"-"` +} + +// bgpRouteTimeseriesResponseSerieIPV6_48sJSON contains the JSON metadata for the +// struct [BGPRouteTimeseriesResponseSerieIPV6_48s] +type bgpRouteTimeseriesResponseSerieIPV6_48sJSON struct { + Timestamps apijson.Field + Values apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRouteTimeseriesResponseSerieIPV6_48s) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRouteTimeseriesResponseSerieIPV6_48sJSON) RawJSON() string { + return r.raw +} + +type BGPRouteMoasParams struct { + // Format results are returned in. + Format param.Field[BGPRouteMoasParamsFormat] `query:"format"` + // Lookup only RPKI invalid MOASes + InvalidOnly param.Field[bool] `query:"invalid_only"` + // Lookup MOASes originated by the given ASN + Origin param.Field[int64] `query:"origin"` + // Lookup MOASes by prefix + Prefix param.Field[string] `query:"prefix"` +} + +// URLQuery serializes [BGPRouteMoasParams]'s query parameters as `url.Values`. +func (r BGPRouteMoasParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Format results are returned in. +type BGPRouteMoasParamsFormat string + +const ( + BGPRouteMoasParamsFormatJson BGPRouteMoasParamsFormat = "JSON" + BGPRouteMoasParamsFormatCsv BGPRouteMoasParamsFormat = "CSV" +) + +type BGPRouteMoasResponseEnvelope struct { + Result BGPRouteMoasResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON bgpRouteMoasResponseEnvelopeJSON `json:"-"` +} + +// bgpRouteMoasResponseEnvelopeJSON contains the JSON metadata for the struct +// [BGPRouteMoasResponseEnvelope] +type bgpRouteMoasResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRouteMoasResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRouteMoasResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type BGPRoutePfx2asParams struct { + // Format results are returned in. + Format param.Field[BGPRoutePfx2asParamsFormat] `query:"format"` + // Lookup prefixes originated by the given ASN + Origin param.Field[int64] `query:"origin"` + // Lookup origins of the given prefix + Prefix param.Field[string] `query:"prefix"` + // Return only results with matching rpki status: valid, invalid or unknown + RpkiStatus param.Field[BGPRoutePfx2asParamsRpkiStatus] `query:"rpkiStatus"` +} + +// URLQuery serializes [BGPRoutePfx2asParams]'s query parameters as `url.Values`. +func (r BGPRoutePfx2asParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Format results are returned in. +type BGPRoutePfx2asParamsFormat string + +const ( + BGPRoutePfx2asParamsFormatJson BGPRoutePfx2asParamsFormat = "JSON" + BGPRoutePfx2asParamsFormatCsv BGPRoutePfx2asParamsFormat = "CSV" +) + +// Return only results with matching rpki status: valid, invalid or unknown +type BGPRoutePfx2asParamsRpkiStatus string + +const ( + BGPRoutePfx2asParamsRpkiStatusValid BGPRoutePfx2asParamsRpkiStatus = "VALID" + BGPRoutePfx2asParamsRpkiStatusInvalid BGPRoutePfx2asParamsRpkiStatus = "INVALID" + BGPRoutePfx2asParamsRpkiStatusUnknown BGPRoutePfx2asParamsRpkiStatus = "UNKNOWN" +) + +type BGPRoutePfx2asResponseEnvelope struct { + Result BGPRoutePfx2asResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON bgpRoutePfx2asResponseEnvelopeJSON `json:"-"` +} + +// bgpRoutePfx2asResponseEnvelopeJSON contains the JSON metadata for the struct +// [BGPRoutePfx2asResponseEnvelope] +type bgpRoutePfx2asResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRoutePfx2asResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRoutePfx2asResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type BGPRouteStatsParams struct { + // Single ASN as integer. + ASN param.Field[int64] `query:"asn"` + // Format results are returned in. + Format param.Field[BGPRouteStatsParamsFormat] `query:"format"` + // Location Alpha2 code. + Location param.Field[string] `query:"location"` +} + +// URLQuery serializes [BGPRouteStatsParams]'s query parameters as `url.Values`. +func (r BGPRouteStatsParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Format results are returned in. +type BGPRouteStatsParamsFormat string + +const ( + BGPRouteStatsParamsFormatJson BGPRouteStatsParamsFormat = "JSON" + BGPRouteStatsParamsFormatCsv BGPRouteStatsParamsFormat = "CSV" +) + +type BGPRouteStatsResponseEnvelope struct { + Result BGPRouteStatsResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON bgpRouteStatsResponseEnvelopeJSON `json:"-"` +} + +// bgpRouteStatsResponseEnvelopeJSON contains the JSON metadata for the struct +// [BGPRouteStatsResponseEnvelope] +type bgpRouteStatsResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRouteStatsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRouteStatsResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type BGPRouteTimeseriesParams struct { + // Single ASN as integer. + ASN param.Field[int64] `query:"asn"` + // End of the date range (inclusive). + DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"` + // Shorthand date ranges for the last X days - use when you don't need specific + // start and end dates. + DateRange param.Field[BGPRouteTimeseriesParamsDateRange] `query:"dateRange"` + // Start of the date range (inclusive). + DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[BGPRouteTimeseriesParamsFormat] `query:"format"` +} + +// URLQuery serializes [BGPRouteTimeseriesParams]'s query parameters as +// `url.Values`. +func (r BGPRouteTimeseriesParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Shorthand date ranges for the last X days - use when you don't need specific +// start and end dates. +type BGPRouteTimeseriesParamsDateRange string + +const ( + BGPRouteTimeseriesParamsDateRange1d BGPRouteTimeseriesParamsDateRange = "1d" + BGPRouteTimeseriesParamsDateRange2d BGPRouteTimeseriesParamsDateRange = "2d" + BGPRouteTimeseriesParamsDateRange7d BGPRouteTimeseriesParamsDateRange = "7d" + BGPRouteTimeseriesParamsDateRange14d BGPRouteTimeseriesParamsDateRange = "14d" + BGPRouteTimeseriesParamsDateRange28d BGPRouteTimeseriesParamsDateRange = "28d" + BGPRouteTimeseriesParamsDateRange12w BGPRouteTimeseriesParamsDateRange = "12w" + BGPRouteTimeseriesParamsDateRange24w BGPRouteTimeseriesParamsDateRange = "24w" + BGPRouteTimeseriesParamsDateRange52w BGPRouteTimeseriesParamsDateRange = "52w" + BGPRouteTimeseriesParamsDateRange1dControl BGPRouteTimeseriesParamsDateRange = "1dControl" + BGPRouteTimeseriesParamsDateRange2dControl BGPRouteTimeseriesParamsDateRange = "2dControl" + BGPRouteTimeseriesParamsDateRange7dControl BGPRouteTimeseriesParamsDateRange = "7dControl" + BGPRouteTimeseriesParamsDateRange14dControl BGPRouteTimeseriesParamsDateRange = "14dControl" + BGPRouteTimeseriesParamsDateRange28dControl BGPRouteTimeseriesParamsDateRange = "28dControl" + BGPRouteTimeseriesParamsDateRange12wControl BGPRouteTimeseriesParamsDateRange = "12wControl" + BGPRouteTimeseriesParamsDateRange24wControl BGPRouteTimeseriesParamsDateRange = "24wControl" +) + +// Format results are returned in. +type BGPRouteTimeseriesParamsFormat string + +const ( + BGPRouteTimeseriesParamsFormatJson BGPRouteTimeseriesParamsFormat = "JSON" + BGPRouteTimeseriesParamsFormatCsv BGPRouteTimeseriesParamsFormat = "CSV" +) + +type BGPRouteTimeseriesResponseEnvelope struct { + Result BGPRouteTimeseriesResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON bgpRouteTimeseriesResponseEnvelopeJSON `json:"-"` +} + +// bgpRouteTimeseriesResponseEnvelopeJSON contains the JSON metadata for the struct +// [BGPRouteTimeseriesResponseEnvelope] +type bgpRouteTimeseriesResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPRouteTimeseriesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpRouteTimeseriesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/bgproute_test.go b/radar/bgproute_test.go new file mode 100644 index 00000000000..1fc6a108e24 --- /dev/null +++ b/radar/bgproute_test.go @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestBGPRouteMoasWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.BGP.Routes.Moas(context.TODO(), radar.BGPRouteMoasParams{ + Format: cloudflare.F(radar.BGPRouteMoasParamsFormatJson), + InvalidOnly: cloudflare.F(true), + Origin: cloudflare.F(int64(0)), + Prefix: cloudflare.F("string"), + }) + 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 TestBGPRoutePfx2asWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.BGP.Routes.Pfx2as(context.TODO(), radar.BGPRoutePfx2asParams{ + Format: cloudflare.F(radar.BGPRoutePfx2asParamsFormatJson), + Origin: cloudflare.F(int64(0)), + Prefix: cloudflare.F("1.1.1.0/24"), + RpkiStatus: cloudflare.F(radar.BGPRoutePfx2asParamsRpkiStatusInvalid), + }) + 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 TestBGPRouteStatsWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.BGP.Routes.Stats(context.TODO(), radar.BGPRouteStatsParams{ + ASN: cloudflare.F(int64(0)), + Format: cloudflare.F(radar.BGPRouteStatsParamsFormatJson), + Location: cloudflare.F("US"), + }) + 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 TestBGPRouteTimeseriesWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.BGP.Routes.Timeseries(context.TODO(), radar.BGPRouteTimeseriesParams{ + ASN: cloudflare.F(int64(0)), + DateEnd: cloudflare.F(time.Now()), + DateRange: cloudflare.F(radar.BGPRouteTimeseriesParamsDateRange7d), + DateStart: cloudflare.F(time.Now()), + Format: cloudflare.F(radar.BGPRouteTimeseriesParamsFormatJson), + }) + 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/radar/bgptop.go b/radar/bgptop.go new file mode 100644 index 00000000000..b4bddace264 --- /dev/null +++ b/radar/bgptop.go @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// BGPTopService 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 [NewBGPTopService] method instead. +type BGPTopService struct { + Options []option.RequestOption + Ases *BGPTopAseService +} + +// NewBGPTopService 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 NewBGPTopService(opts ...option.RequestOption) (r *BGPTopService) { + r = &BGPTopService{} + r.Options = opts + r.Ases = NewBGPTopAseService(opts...) + return +} + +// Get the top network prefixes by BGP updates. Values are a percentage out of the +// total BGP updates. +func (r *BGPTopService) Prefixes(ctx context.Context, query BGPTopPrefixesParams, opts ...option.RequestOption) (res *BGPTopPrefixesResponse, err error) { + opts = append(r.Options[:], opts...) + var env BGPTopPrefixesResponseEnvelope + path := "radar/bgp/top/prefixes" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type BGPTopPrefixesResponse struct { + Meta BGPTopPrefixesResponseMeta `json:"meta,required"` + Top0 []BGPTopPrefixesResponseTop0 `json:"top_0,required"` + JSON bgpTopPrefixesResponseJSON `json:"-"` +} + +// bgpTopPrefixesResponseJSON contains the JSON metadata for the struct +// [BGPTopPrefixesResponse] +type bgpTopPrefixesResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTopPrefixesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTopPrefixesResponseJSON) RawJSON() string { + return r.raw +} + +type BGPTopPrefixesResponseMeta struct { + DateRange []BGPTopPrefixesResponseMetaDateRange `json:"dateRange,required"` + JSON bgpTopPrefixesResponseMetaJSON `json:"-"` +} + +// bgpTopPrefixesResponseMetaJSON contains the JSON metadata for the struct +// [BGPTopPrefixesResponseMeta] +type bgpTopPrefixesResponseMetaJSON struct { + DateRange apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTopPrefixesResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTopPrefixesResponseMetaJSON) RawJSON() string { + return r.raw +} + +type BGPTopPrefixesResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON bgpTopPrefixesResponseMetaDateRangeJSON `json:"-"` +} + +// bgpTopPrefixesResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [BGPTopPrefixesResponseMetaDateRange] +type bgpTopPrefixesResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTopPrefixesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTopPrefixesResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type BGPTopPrefixesResponseTop0 struct { + Prefix string `json:"prefix,required"` + Value string `json:"value,required"` + JSON bgpTopPrefixesResponseTop0JSON `json:"-"` +} + +// bgpTopPrefixesResponseTop0JSON contains the JSON metadata for the struct +// [BGPTopPrefixesResponseTop0] +type bgpTopPrefixesResponseTop0JSON struct { + Prefix apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTopPrefixesResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTopPrefixesResponseTop0JSON) RawJSON() string { + return r.raw +} + +type BGPTopPrefixesParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]BGPTopPrefixesParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[BGPTopPrefixesParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Array of BGP update types. + UpdateType param.Field[[]BGPTopPrefixesParamsUpdateType] `query:"updateType"` +} + +// URLQuery serializes [BGPTopPrefixesParams]'s query parameters as `url.Values`. +func (r BGPTopPrefixesParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type BGPTopPrefixesParamsDateRange string + +const ( + BGPTopPrefixesParamsDateRange1d BGPTopPrefixesParamsDateRange = "1d" + BGPTopPrefixesParamsDateRange2d BGPTopPrefixesParamsDateRange = "2d" + BGPTopPrefixesParamsDateRange7d BGPTopPrefixesParamsDateRange = "7d" + BGPTopPrefixesParamsDateRange14d BGPTopPrefixesParamsDateRange = "14d" + BGPTopPrefixesParamsDateRange28d BGPTopPrefixesParamsDateRange = "28d" + BGPTopPrefixesParamsDateRange12w BGPTopPrefixesParamsDateRange = "12w" + BGPTopPrefixesParamsDateRange24w BGPTopPrefixesParamsDateRange = "24w" + BGPTopPrefixesParamsDateRange52w BGPTopPrefixesParamsDateRange = "52w" + BGPTopPrefixesParamsDateRange1dControl BGPTopPrefixesParamsDateRange = "1dControl" + BGPTopPrefixesParamsDateRange2dControl BGPTopPrefixesParamsDateRange = "2dControl" + BGPTopPrefixesParamsDateRange7dControl BGPTopPrefixesParamsDateRange = "7dControl" + BGPTopPrefixesParamsDateRange14dControl BGPTopPrefixesParamsDateRange = "14dControl" + BGPTopPrefixesParamsDateRange28dControl BGPTopPrefixesParamsDateRange = "28dControl" + BGPTopPrefixesParamsDateRange12wControl BGPTopPrefixesParamsDateRange = "12wControl" + BGPTopPrefixesParamsDateRange24wControl BGPTopPrefixesParamsDateRange = "24wControl" +) + +// Format results are returned in. +type BGPTopPrefixesParamsFormat string + +const ( + BGPTopPrefixesParamsFormatJson BGPTopPrefixesParamsFormat = "JSON" + BGPTopPrefixesParamsFormatCsv BGPTopPrefixesParamsFormat = "CSV" +) + +type BGPTopPrefixesParamsUpdateType string + +const ( + BGPTopPrefixesParamsUpdateTypeAnnouncement BGPTopPrefixesParamsUpdateType = "ANNOUNCEMENT" + BGPTopPrefixesParamsUpdateTypeWithdrawal BGPTopPrefixesParamsUpdateType = "WITHDRAWAL" +) + +type BGPTopPrefixesResponseEnvelope struct { + Result BGPTopPrefixesResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON bgpTopPrefixesResponseEnvelopeJSON `json:"-"` +} + +// bgpTopPrefixesResponseEnvelopeJSON contains the JSON metadata for the struct +// [BGPTopPrefixesResponseEnvelope] +type bgpTopPrefixesResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTopPrefixesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTopPrefixesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/bgptop_test.go b/radar/bgptop_test.go new file mode 100644 index 00000000000..e85729f73bc --- /dev/null +++ b/radar/bgptop_test.go @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestBGPTopPrefixesWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.BGP.Top.Prefixes(context.TODO(), radar.BGPTopPrefixesParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.BGPTopPrefixesParamsDateRange{radar.BGPTopPrefixesParamsDateRange1d, radar.BGPTopPrefixesParamsDateRange2d, radar.BGPTopPrefixesParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.BGPTopPrefixesParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Name: cloudflare.F([]string{"string", "string", "string"}), + UpdateType: cloudflare.F([]radar.BGPTopPrefixesParamsUpdateType{radar.BGPTopPrefixesParamsUpdateTypeAnnouncement, radar.BGPTopPrefixesParamsUpdateTypeWithdrawal}), + }) + 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/radar/bgptopase.go b/radar/bgptopase.go new file mode 100644 index 00000000000..b7a89763fbe --- /dev/null +++ b/radar/bgptopase.go @@ -0,0 +1,373 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// BGPTopAseService 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 [NewBGPTopAseService] method instead. +type BGPTopAseService struct { + Options []option.RequestOption +} + +// NewBGPTopAseService 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 NewBGPTopAseService(opts ...option.RequestOption) (r *BGPTopAseService) { + r = &BGPTopAseService{} + r.Options = opts + return +} + +// Get the top autonomous systems (AS) by BGP updates (announcements only). Values +// are a percentage out of the total updates. +func (r *BGPTopAseService) Get(ctx context.Context, query BGPTopAseGetParams, opts ...option.RequestOption) (res *BGPTopAseGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env BGPTopAseGetResponseEnvelope + path := "radar/bgp/top/ases" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the full list of autonomous systems on the global routing table ordered by +// announced prefixes count. The data comes from public BGP MRT data archives and +// updates every 2 hours. +func (r *BGPTopAseService) Prefixes(ctx context.Context, query BGPTopAsePrefixesParams, opts ...option.RequestOption) (res *BGPTopAsePrefixesResponse, err error) { + opts = append(r.Options[:], opts...) + var env BGPTopAsePrefixesResponseEnvelope + path := "radar/bgp/top/ases/prefixes" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type BGPTopAseGetResponse struct { + Meta BGPTopAseGetResponseMeta `json:"meta,required"` + Top0 []BGPTopAseGetResponseTop0 `json:"top_0,required"` + JSON bgpTopAseGetResponseJSON `json:"-"` +} + +// bgpTopAseGetResponseJSON contains the JSON metadata for the struct +// [BGPTopAseGetResponse] +type bgpTopAseGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTopAseGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTopAseGetResponseJSON) RawJSON() string { + return r.raw +} + +type BGPTopAseGetResponseMeta struct { + DateRange []BGPTopAseGetResponseMetaDateRange `json:"dateRange,required"` + JSON bgpTopAseGetResponseMetaJSON `json:"-"` +} + +// bgpTopAseGetResponseMetaJSON contains the JSON metadata for the struct +// [BGPTopAseGetResponseMeta] +type bgpTopAseGetResponseMetaJSON struct { + DateRange apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTopAseGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTopAseGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type BGPTopAseGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON bgpTopAseGetResponseMetaDateRangeJSON `json:"-"` +} + +// bgpTopAseGetResponseMetaDateRangeJSON contains the JSON metadata for the struct +// [BGPTopAseGetResponseMetaDateRange] +type bgpTopAseGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTopAseGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTopAseGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type BGPTopAseGetResponseTop0 struct { + ASN int64 `json:"asn,required"` + AsName string `json:"ASName,required"` + // Percentage of updates by this AS out of the total updates by all autonomous + // systems. + Value string `json:"value,required"` + JSON bgpTopAseGetResponseTop0JSON `json:"-"` +} + +// bgpTopAseGetResponseTop0JSON contains the JSON metadata for the struct +// [BGPTopAseGetResponseTop0] +type bgpTopAseGetResponseTop0JSON struct { + ASN apijson.Field + AsName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTopAseGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTopAseGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type BGPTopAsePrefixesResponse struct { + ASNs []BGPTopAsePrefixesResponseASN `json:"asns,required"` + Meta BGPTopAsePrefixesResponseMeta `json:"meta,required"` + JSON bgpTopAsePrefixesResponseJSON `json:"-"` +} + +// bgpTopAsePrefixesResponseJSON contains the JSON metadata for the struct +// [BGPTopAsePrefixesResponse] +type bgpTopAsePrefixesResponseJSON struct { + ASNs apijson.Field + Meta apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTopAsePrefixesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTopAsePrefixesResponseJSON) RawJSON() string { + return r.raw +} + +type BGPTopAsePrefixesResponseASN struct { + ASN int64 `json:"asn,required"` + Country string `json:"country,required"` + Name string `json:"name,required"` + PfxsCount int64 `json:"pfxs_count,required"` + JSON bgpTopAsePrefixesResponseASNJSON `json:"-"` +} + +// bgpTopAsePrefixesResponseASNJSON contains the JSON metadata for the struct +// [BGPTopAsePrefixesResponseASN] +type bgpTopAsePrefixesResponseASNJSON struct { + ASN apijson.Field + Country apijson.Field + Name apijson.Field + PfxsCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTopAsePrefixesResponseASN) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTopAsePrefixesResponseASNJSON) RawJSON() string { + return r.raw +} + +type BGPTopAsePrefixesResponseMeta struct { + DataTime string `json:"data_time,required"` + QueryTime string `json:"query_time,required"` + TotalPeers int64 `json:"total_peers,required"` + JSON bgpTopAsePrefixesResponseMetaJSON `json:"-"` +} + +// bgpTopAsePrefixesResponseMetaJSON contains the JSON metadata for the struct +// [BGPTopAsePrefixesResponseMeta] +type bgpTopAsePrefixesResponseMetaJSON struct { + DataTime apijson.Field + QueryTime apijson.Field + TotalPeers apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTopAsePrefixesResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTopAsePrefixesResponseMetaJSON) RawJSON() string { + return r.raw +} + +type BGPTopAseGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]BGPTopAseGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[BGPTopAseGetParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Array of BGP network prefixes. + Prefix param.Field[[]string] `query:"prefix"` + // Array of BGP update types. + UpdateType param.Field[[]BGPTopAseGetParamsUpdateType] `query:"updateType"` +} + +// URLQuery serializes [BGPTopAseGetParams]'s query parameters as `url.Values`. +func (r BGPTopAseGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type BGPTopAseGetParamsDateRange string + +const ( + BGPTopAseGetParamsDateRange1d BGPTopAseGetParamsDateRange = "1d" + BGPTopAseGetParamsDateRange2d BGPTopAseGetParamsDateRange = "2d" + BGPTopAseGetParamsDateRange7d BGPTopAseGetParamsDateRange = "7d" + BGPTopAseGetParamsDateRange14d BGPTopAseGetParamsDateRange = "14d" + BGPTopAseGetParamsDateRange28d BGPTopAseGetParamsDateRange = "28d" + BGPTopAseGetParamsDateRange12w BGPTopAseGetParamsDateRange = "12w" + BGPTopAseGetParamsDateRange24w BGPTopAseGetParamsDateRange = "24w" + BGPTopAseGetParamsDateRange52w BGPTopAseGetParamsDateRange = "52w" + BGPTopAseGetParamsDateRange1dControl BGPTopAseGetParamsDateRange = "1dControl" + BGPTopAseGetParamsDateRange2dControl BGPTopAseGetParamsDateRange = "2dControl" + BGPTopAseGetParamsDateRange7dControl BGPTopAseGetParamsDateRange = "7dControl" + BGPTopAseGetParamsDateRange14dControl BGPTopAseGetParamsDateRange = "14dControl" + BGPTopAseGetParamsDateRange28dControl BGPTopAseGetParamsDateRange = "28dControl" + BGPTopAseGetParamsDateRange12wControl BGPTopAseGetParamsDateRange = "12wControl" + BGPTopAseGetParamsDateRange24wControl BGPTopAseGetParamsDateRange = "24wControl" +) + +// Format results are returned in. +type BGPTopAseGetParamsFormat string + +const ( + BGPTopAseGetParamsFormatJson BGPTopAseGetParamsFormat = "JSON" + BGPTopAseGetParamsFormatCsv BGPTopAseGetParamsFormat = "CSV" +) + +type BGPTopAseGetParamsUpdateType string + +const ( + BGPTopAseGetParamsUpdateTypeAnnouncement BGPTopAseGetParamsUpdateType = "ANNOUNCEMENT" + BGPTopAseGetParamsUpdateTypeWithdrawal BGPTopAseGetParamsUpdateType = "WITHDRAWAL" +) + +type BGPTopAseGetResponseEnvelope struct { + Result BGPTopAseGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON bgpTopAseGetResponseEnvelopeJSON `json:"-"` +} + +// bgpTopAseGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [BGPTopAseGetResponseEnvelope] +type bgpTopAseGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTopAseGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTopAseGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type BGPTopAsePrefixesParams struct { + // Alpha-2 country code. + Country param.Field[string] `query:"country"` + // Format results are returned in. + Format param.Field[BGPTopAsePrefixesParamsFormat] `query:"format"` + // Maximum number of ASes to return + Limit param.Field[int64] `query:"limit"` +} + +// URLQuery serializes [BGPTopAsePrefixesParams]'s query parameters as +// `url.Values`. +func (r BGPTopAsePrefixesParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Format results are returned in. +type BGPTopAsePrefixesParamsFormat string + +const ( + BGPTopAsePrefixesParamsFormatJson BGPTopAsePrefixesParamsFormat = "JSON" + BGPTopAsePrefixesParamsFormatCsv BGPTopAsePrefixesParamsFormat = "CSV" +) + +type BGPTopAsePrefixesResponseEnvelope struct { + Result BGPTopAsePrefixesResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON bgpTopAsePrefixesResponseEnvelopeJSON `json:"-"` +} + +// bgpTopAsePrefixesResponseEnvelopeJSON contains the JSON metadata for the struct +// [BGPTopAsePrefixesResponseEnvelope] +type bgpTopAsePrefixesResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BGPTopAsePrefixesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r bgpTopAsePrefixesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/bgptopase_test.go b/radar/bgptopase_test.go new file mode 100644 index 00000000000..84ed23c0e70 --- /dev/null +++ b/radar/bgptopase_test.go @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestBGPTopAseGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.BGP.Top.Ases.Get(context.TODO(), radar.BGPTopAseGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.BGPTopAseGetParamsDateRange{radar.BGPTopAseGetParamsDateRange1d, radar.BGPTopAseGetParamsDateRange2d, radar.BGPTopAseGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.BGPTopAseGetParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Name: cloudflare.F([]string{"string", "string", "string"}), + Prefix: cloudflare.F([]string{"string", "string", "string"}), + UpdateType: cloudflare.F([]radar.BGPTopAseGetParamsUpdateType{radar.BGPTopAseGetParamsUpdateTypeAnnouncement, radar.BGPTopAseGetParamsUpdateTypeWithdrawal}), + }) + 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 TestBGPTopAsePrefixesWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.BGP.Top.Ases.Prefixes(context.TODO(), radar.BGPTopAsePrefixesParams{ + Country: cloudflare.F("NZ"), + Format: cloudflare.F(radar.BGPTopAsePrefixesParamsFormatJson), + Limit: cloudflare.F(int64(10)), + }) + 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/radar/connectiontampering.go b/radar/connectiontampering.go new file mode 100644 index 00000000000..b6945cc0eb1 --- /dev/null +++ b/radar/connectiontampering.go @@ -0,0 +1,592 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ConnectionTamperingService 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 [NewConnectionTamperingService] +// method instead. +type ConnectionTamperingService struct { + Options []option.RequestOption +} + +// NewConnectionTamperingService 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 NewConnectionTamperingService(opts ...option.RequestOption) (r *ConnectionTamperingService) { + r = &ConnectionTamperingService{} + r.Options = opts + return +} + +// Distribution of connection tampering types over a given time period. +func (r *ConnectionTamperingService) Summary(ctx context.Context, query ConnectionTamperingSummaryParams, opts ...option.RequestOption) (res *ConnectionTamperingSummaryResponse, err error) { + opts = append(r.Options[:], opts...) + var env ConnectionTamperingSummaryResponseEnvelope + path := "radar/connection_tampering/summary" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Distribution of connection tampering types over time. +func (r *ConnectionTamperingService) TimeseriesGroups(ctx context.Context, query ConnectionTamperingTimeseriesGroupsParams, opts ...option.RequestOption) (res *ConnectionTamperingTimeseriesGroupsResponse, err error) { + opts = append(r.Options[:], opts...) + var env ConnectionTamperingTimeseriesGroupsResponseEnvelope + path := "radar/connection_tampering/timeseries_groups" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ConnectionTamperingSummaryResponse struct { + Meta ConnectionTamperingSummaryResponseMeta `json:"meta,required"` + Summary0 ConnectionTamperingSummaryResponseSummary0 `json:"summary_0,required"` + JSON connectionTamperingSummaryResponseJSON `json:"-"` +} + +// connectionTamperingSummaryResponseJSON contains the JSON metadata for the struct +// [ConnectionTamperingSummaryResponse] +type connectionTamperingSummaryResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectionTamperingSummaryResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectionTamperingSummaryResponseJSON) RawJSON() string { + return r.raw +} + +type ConnectionTamperingSummaryResponseMeta struct { + DateRange []ConnectionTamperingSummaryResponseMetaDateRange `json:"dateRange,required"` + ConfidenceInfo ConnectionTamperingSummaryResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON connectionTamperingSummaryResponseMetaJSON `json:"-"` +} + +// connectionTamperingSummaryResponseMetaJSON contains the JSON metadata for the +// struct [ConnectionTamperingSummaryResponseMeta] +type connectionTamperingSummaryResponseMetaJSON struct { + DateRange apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectionTamperingSummaryResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectionTamperingSummaryResponseMetaJSON) RawJSON() string { + return r.raw +} + +type ConnectionTamperingSummaryResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON connectionTamperingSummaryResponseMetaDateRangeJSON `json:"-"` +} + +// connectionTamperingSummaryResponseMetaDateRangeJSON contains the JSON metadata +// for the struct [ConnectionTamperingSummaryResponseMetaDateRange] +type connectionTamperingSummaryResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectionTamperingSummaryResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectionTamperingSummaryResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type ConnectionTamperingSummaryResponseMetaConfidenceInfo struct { + Annotations []ConnectionTamperingSummaryResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON connectionTamperingSummaryResponseMetaConfidenceInfoJSON `json:"-"` +} + +// connectionTamperingSummaryResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [ConnectionTamperingSummaryResponseMetaConfidenceInfo] +type connectionTamperingSummaryResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectionTamperingSummaryResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectionTamperingSummaryResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type ConnectionTamperingSummaryResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON connectionTamperingSummaryResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// connectionTamperingSummaryResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [ConnectionTamperingSummaryResponseMetaConfidenceInfoAnnotation] +type connectionTamperingSummaryResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectionTamperingSummaryResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectionTamperingSummaryResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type ConnectionTamperingSummaryResponseSummary0 struct { + // Connections matching signatures for tampering later in the connection, after the + // transfer of multiple data packets. + LaterInFlow string `json:"later_in_flow,required"` + // Connections that do not match any tampering signatures. + NoMatch string `json:"no_match,required"` + // Connections matching signatures for tampering after the receipt of a SYN packet + // and ACK packet, meaning the TCP connection was successfully established but the + // server did not receive any subsequent packets. + PostAck string `json:"post_ack,required"` + // Connections matching signatures for tampering after the receipt of a packet with + // PSH flag set, following connection establishment. + PostPsh string `json:"post_psh,required"` + // Connections matching signatures for tampering after the receipt of only a single + // SYN packet, and before the handshake completes. + PostSyn string `json:"post_syn,required"` + JSON connectionTamperingSummaryResponseSummary0JSON `json:"-"` +} + +// connectionTamperingSummaryResponseSummary0JSON contains the JSON metadata for +// the struct [ConnectionTamperingSummaryResponseSummary0] +type connectionTamperingSummaryResponseSummary0JSON struct { + LaterInFlow apijson.Field + NoMatch apijson.Field + PostAck apijson.Field + PostPsh apijson.Field + PostSyn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectionTamperingSummaryResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectionTamperingSummaryResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type ConnectionTamperingTimeseriesGroupsResponse struct { + Meta ConnectionTamperingTimeseriesGroupsResponseMeta `json:"meta,required"` + Serie0 ConnectionTamperingTimeseriesGroupsResponseSerie0 `json:"serie_0,required"` + JSON connectionTamperingTimeseriesGroupsResponseJSON `json:"-"` +} + +// connectionTamperingTimeseriesGroupsResponseJSON contains the JSON metadata for +// the struct [ConnectionTamperingTimeseriesGroupsResponse] +type connectionTamperingTimeseriesGroupsResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectionTamperingTimeseriesGroupsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectionTamperingTimeseriesGroupsResponseJSON) RawJSON() string { + return r.raw +} + +type ConnectionTamperingTimeseriesGroupsResponseMeta struct { + AggInterval string `json:"aggInterval,required"` + DateRange []ConnectionTamperingTimeseriesGroupsResponseMetaDateRange `json:"dateRange,required"` + LastUpdated time.Time `json:"lastUpdated,required" format:"date-time"` + ConfidenceInfo ConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON connectionTamperingTimeseriesGroupsResponseMetaJSON `json:"-"` +} + +// connectionTamperingTimeseriesGroupsResponseMetaJSON contains the JSON metadata +// for the struct [ConnectionTamperingTimeseriesGroupsResponseMeta] +type connectionTamperingTimeseriesGroupsResponseMetaJSON struct { + AggInterval apijson.Field + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectionTamperingTimeseriesGroupsResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectionTamperingTimeseriesGroupsResponseMetaJSON) RawJSON() string { + return r.raw +} + +type ConnectionTamperingTimeseriesGroupsResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON connectionTamperingTimeseriesGroupsResponseMetaDateRangeJSON `json:"-"` +} + +// connectionTamperingTimeseriesGroupsResponseMetaDateRangeJSON contains the JSON +// metadata for the struct +// [ConnectionTamperingTimeseriesGroupsResponseMetaDateRange] +type connectionTamperingTimeseriesGroupsResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectionTamperingTimeseriesGroupsResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectionTamperingTimeseriesGroupsResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type ConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfo struct { + Annotations []ConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON connectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoJSON `json:"-"` +} + +// connectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoJSON contains the +// JSON metadata for the struct +// [ConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfo] +type connectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type ConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON connectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// connectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoAnnotationJSON +// contains the JSON metadata for the struct +// [ConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoAnnotation] +type connectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type ConnectionTamperingTimeseriesGroupsResponseSerie0 struct { + // Connections matching signatures for tampering later in the connection, after the + // transfer of multiple data packets. + LaterInFlow []string `json:"later_in_flow,required"` + // Connections that do not match any tampering signatures. + NoMatch []string `json:"no_match,required"` + // Connections matching signatures for tampering after the receipt of a SYN packet + // and ACK packet, meaning the TCP connection was successfully established but the + // server did not receive any subsequent packets. + PostAck []string `json:"post_ack,required"` + // Connections matching signatures for tampering after the receipt of a packet with + // PSH flag set, following connection establishment. + PostPsh []string `json:"post_psh,required"` + // Connections matching signatures for tampering after the receipt of only a single + // SYN packet, and before the handshake completes. + PostSyn []string `json:"post_syn,required"` + Timestamps []time.Time `json:"timestamps,required" format:"date-time"` + JSON connectionTamperingTimeseriesGroupsResponseSerie0JSON `json:"-"` +} + +// connectionTamperingTimeseriesGroupsResponseSerie0JSON contains the JSON metadata +// for the struct [ConnectionTamperingTimeseriesGroupsResponseSerie0] +type connectionTamperingTimeseriesGroupsResponseSerie0JSON struct { + LaterInFlow apijson.Field + NoMatch apijson.Field + PostAck apijson.Field + PostPsh apijson.Field + PostSyn apijson.Field + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectionTamperingTimeseriesGroupsResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectionTamperingTimeseriesGroupsResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type ConnectionTamperingSummaryParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]ConnectionTamperingSummaryParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[ConnectionTamperingSummaryParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [ConnectionTamperingSummaryParams]'s query parameters as +// `url.Values`. +func (r ConnectionTamperingSummaryParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type ConnectionTamperingSummaryParamsDateRange string + +const ( + ConnectionTamperingSummaryParamsDateRange1d ConnectionTamperingSummaryParamsDateRange = "1d" + ConnectionTamperingSummaryParamsDateRange2d ConnectionTamperingSummaryParamsDateRange = "2d" + ConnectionTamperingSummaryParamsDateRange7d ConnectionTamperingSummaryParamsDateRange = "7d" + ConnectionTamperingSummaryParamsDateRange14d ConnectionTamperingSummaryParamsDateRange = "14d" + ConnectionTamperingSummaryParamsDateRange28d ConnectionTamperingSummaryParamsDateRange = "28d" + ConnectionTamperingSummaryParamsDateRange12w ConnectionTamperingSummaryParamsDateRange = "12w" + ConnectionTamperingSummaryParamsDateRange24w ConnectionTamperingSummaryParamsDateRange = "24w" + ConnectionTamperingSummaryParamsDateRange52w ConnectionTamperingSummaryParamsDateRange = "52w" + ConnectionTamperingSummaryParamsDateRange1dControl ConnectionTamperingSummaryParamsDateRange = "1dControl" + ConnectionTamperingSummaryParamsDateRange2dControl ConnectionTamperingSummaryParamsDateRange = "2dControl" + ConnectionTamperingSummaryParamsDateRange7dControl ConnectionTamperingSummaryParamsDateRange = "7dControl" + ConnectionTamperingSummaryParamsDateRange14dControl ConnectionTamperingSummaryParamsDateRange = "14dControl" + ConnectionTamperingSummaryParamsDateRange28dControl ConnectionTamperingSummaryParamsDateRange = "28dControl" + ConnectionTamperingSummaryParamsDateRange12wControl ConnectionTamperingSummaryParamsDateRange = "12wControl" + ConnectionTamperingSummaryParamsDateRange24wControl ConnectionTamperingSummaryParamsDateRange = "24wControl" +) + +// Format results are returned in. +type ConnectionTamperingSummaryParamsFormat string + +const ( + ConnectionTamperingSummaryParamsFormatJson ConnectionTamperingSummaryParamsFormat = "JSON" + ConnectionTamperingSummaryParamsFormatCsv ConnectionTamperingSummaryParamsFormat = "CSV" +) + +type ConnectionTamperingSummaryResponseEnvelope struct { + Result ConnectionTamperingSummaryResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON connectionTamperingSummaryResponseEnvelopeJSON `json:"-"` +} + +// connectionTamperingSummaryResponseEnvelopeJSON contains the JSON metadata for +// the struct [ConnectionTamperingSummaryResponseEnvelope] +type connectionTamperingSummaryResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectionTamperingSummaryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectionTamperingSummaryResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConnectionTamperingTimeseriesGroupsParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[ConnectionTamperingTimeseriesGroupsParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]ConnectionTamperingTimeseriesGroupsParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[ConnectionTamperingTimeseriesGroupsParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [ConnectionTamperingTimeseriesGroupsParams]'s query +// parameters as `url.Values`. +func (r ConnectionTamperingTimeseriesGroupsParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type ConnectionTamperingTimeseriesGroupsParamsAggInterval string + +const ( + ConnectionTamperingTimeseriesGroupsParamsAggInterval15m ConnectionTamperingTimeseriesGroupsParamsAggInterval = "15m" + ConnectionTamperingTimeseriesGroupsParamsAggInterval1h ConnectionTamperingTimeseriesGroupsParamsAggInterval = "1h" + ConnectionTamperingTimeseriesGroupsParamsAggInterval1d ConnectionTamperingTimeseriesGroupsParamsAggInterval = "1d" + ConnectionTamperingTimeseriesGroupsParamsAggInterval1w ConnectionTamperingTimeseriesGroupsParamsAggInterval = "1w" +) + +type ConnectionTamperingTimeseriesGroupsParamsDateRange string + +const ( + ConnectionTamperingTimeseriesGroupsParamsDateRange1d ConnectionTamperingTimeseriesGroupsParamsDateRange = "1d" + ConnectionTamperingTimeseriesGroupsParamsDateRange2d ConnectionTamperingTimeseriesGroupsParamsDateRange = "2d" + ConnectionTamperingTimeseriesGroupsParamsDateRange7d ConnectionTamperingTimeseriesGroupsParamsDateRange = "7d" + ConnectionTamperingTimeseriesGroupsParamsDateRange14d ConnectionTamperingTimeseriesGroupsParamsDateRange = "14d" + ConnectionTamperingTimeseriesGroupsParamsDateRange28d ConnectionTamperingTimeseriesGroupsParamsDateRange = "28d" + ConnectionTamperingTimeseriesGroupsParamsDateRange12w ConnectionTamperingTimeseriesGroupsParamsDateRange = "12w" + ConnectionTamperingTimeseriesGroupsParamsDateRange24w ConnectionTamperingTimeseriesGroupsParamsDateRange = "24w" + ConnectionTamperingTimeseriesGroupsParamsDateRange52w ConnectionTamperingTimeseriesGroupsParamsDateRange = "52w" + ConnectionTamperingTimeseriesGroupsParamsDateRange1dControl ConnectionTamperingTimeseriesGroupsParamsDateRange = "1dControl" + ConnectionTamperingTimeseriesGroupsParamsDateRange2dControl ConnectionTamperingTimeseriesGroupsParamsDateRange = "2dControl" + ConnectionTamperingTimeseriesGroupsParamsDateRange7dControl ConnectionTamperingTimeseriesGroupsParamsDateRange = "7dControl" + ConnectionTamperingTimeseriesGroupsParamsDateRange14dControl ConnectionTamperingTimeseriesGroupsParamsDateRange = "14dControl" + ConnectionTamperingTimeseriesGroupsParamsDateRange28dControl ConnectionTamperingTimeseriesGroupsParamsDateRange = "28dControl" + ConnectionTamperingTimeseriesGroupsParamsDateRange12wControl ConnectionTamperingTimeseriesGroupsParamsDateRange = "12wControl" + ConnectionTamperingTimeseriesGroupsParamsDateRange24wControl ConnectionTamperingTimeseriesGroupsParamsDateRange = "24wControl" +) + +// Format results are returned in. +type ConnectionTamperingTimeseriesGroupsParamsFormat string + +const ( + ConnectionTamperingTimeseriesGroupsParamsFormatJson ConnectionTamperingTimeseriesGroupsParamsFormat = "JSON" + ConnectionTamperingTimeseriesGroupsParamsFormatCsv ConnectionTamperingTimeseriesGroupsParamsFormat = "CSV" +) + +type ConnectionTamperingTimeseriesGroupsResponseEnvelope struct { + Result ConnectionTamperingTimeseriesGroupsResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON connectionTamperingTimeseriesGroupsResponseEnvelopeJSON `json:"-"` +} + +// connectionTamperingTimeseriesGroupsResponseEnvelopeJSON contains the JSON +// metadata for the struct [ConnectionTamperingTimeseriesGroupsResponseEnvelope] +type connectionTamperingTimeseriesGroupsResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectionTamperingTimeseriesGroupsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectionTamperingTimeseriesGroupsResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/connectiontampering_test.go b/radar/connectiontampering_test.go new file mode 100644 index 00000000000..202bbfe6653 --- /dev/null +++ b/radar/connectiontampering_test.go @@ -0,0 +1,83 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestConnectionTamperingSummaryWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.ConnectionTampering.Summary(context.TODO(), radar.ConnectionTamperingSummaryParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.ConnectionTamperingSummaryParamsDateRange{radar.ConnectionTamperingSummaryParamsDateRange1d, radar.ConnectionTamperingSummaryParamsDateRange2d, radar.ConnectionTamperingSummaryParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.ConnectionTamperingSummaryParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestConnectionTamperingTimeseriesGroupsWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.ConnectionTampering.TimeseriesGroups(context.TODO(), radar.ConnectionTamperingTimeseriesGroupsParams{ + AggInterval: cloudflare.F(radar.ConnectionTamperingTimeseriesGroupsParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.ConnectionTamperingTimeseriesGroupsParamsDateRange{radar.ConnectionTamperingTimeseriesGroupsParamsDateRange1d, radar.ConnectionTamperingTimeseriesGroupsParamsDateRange2d, radar.ConnectionTamperingTimeseriesGroupsParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.ConnectionTamperingTimeseriesGroupsParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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/radar/dataset.go b/radar/dataset.go new file mode 100644 index 00000000000..62f56de151e --- /dev/null +++ b/radar/dataset.go @@ -0,0 +1,284 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DatasetService 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 [NewDatasetService] method instead. +type DatasetService struct { + Options []option.RequestOption +} + +// NewDatasetService 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 NewDatasetService(opts ...option.RequestOption) (r *DatasetService) { + r = &DatasetService{} + r.Options = opts + return +} + +// Get a list of datasets. +func (r *DatasetService) List(ctx context.Context, query DatasetListParams, opts ...option.RequestOption) (res *DatasetListResponse, err error) { + opts = append(r.Options[:], opts...) + var env DatasetListResponseEnvelope + path := "radar/datasets" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a url to download a single dataset. +func (r *DatasetService) Download(ctx context.Context, params DatasetDownloadParams, opts ...option.RequestOption) (res *DatasetDownloadResponse, err error) { + opts = append(r.Options[:], opts...) + var env DatasetDownloadResponseEnvelope + path := "radar/datasets/download" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the csv content of a given dataset by alias or id. When getting the content +// by alias the latest dataset is returned, optionally filtered by the latest +// available at a given date. +func (r *DatasetService) Get(ctx context.Context, alias string, query DatasetGetParams, opts ...option.RequestOption) (res *string, err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "text/csv")}, opts...) + path := fmt.Sprintf("radar/datasets/%s", alias) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +type DatasetListResponse struct { + Datasets []DatasetListResponseDataset `json:"datasets,required"` + JSON datasetListResponseJSON `json:"-"` +} + +// datasetListResponseJSON contains the JSON metadata for the struct +// [DatasetListResponse] +type datasetListResponseJSON struct { + Datasets apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatasetListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r datasetListResponseJSON) RawJSON() string { + return r.raw +} + +type DatasetListResponseDataset struct { + ID int64 `json:"id,required"` + Description string `json:"description,required"` + Meta interface{} `json:"meta,required"` + Tags []string `json:"tags,required"` + Title string `json:"title,required"` + Type string `json:"type,required"` + JSON datasetListResponseDatasetJSON `json:"-"` +} + +// datasetListResponseDatasetJSON contains the JSON metadata for the struct +// [DatasetListResponseDataset] +type datasetListResponseDatasetJSON struct { + ID apijson.Field + Description apijson.Field + Meta apijson.Field + Tags apijson.Field + Title apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatasetListResponseDataset) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r datasetListResponseDatasetJSON) RawJSON() string { + return r.raw +} + +type DatasetDownloadResponse struct { + Dataset DatasetDownloadResponseDataset `json:"dataset,required"` + JSON datasetDownloadResponseJSON `json:"-"` +} + +// datasetDownloadResponseJSON contains the JSON metadata for the struct +// [DatasetDownloadResponse] +type datasetDownloadResponseJSON struct { + Dataset apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatasetDownloadResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r datasetDownloadResponseJSON) RawJSON() string { + return r.raw +} + +type DatasetDownloadResponseDataset struct { + URL string `json:"url,required"` + JSON datasetDownloadResponseDatasetJSON `json:"-"` +} + +// datasetDownloadResponseDatasetJSON contains the JSON metadata for the struct +// [DatasetDownloadResponseDataset] +type datasetDownloadResponseDatasetJSON struct { + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatasetDownloadResponseDataset) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r datasetDownloadResponseDatasetJSON) RawJSON() string { + return r.raw +} + +type DatasetListParams struct { + // Dataset type. + DatasetType param.Field[DatasetListParamsDatasetType] `query:"datasetType"` + // Format results are returned in. + Format param.Field[DatasetListParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Number of objects to skip before grabbing results. + Offset param.Field[int64] `query:"offset"` +} + +// URLQuery serializes [DatasetListParams]'s query parameters as `url.Values`. +func (r DatasetListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Dataset type. +type DatasetListParamsDatasetType string + +const ( + DatasetListParamsDatasetTypeRankingBucket DatasetListParamsDatasetType = "RANKING_BUCKET" + DatasetListParamsDatasetTypeReport DatasetListParamsDatasetType = "REPORT" +) + +// Format results are returned in. +type DatasetListParamsFormat string + +const ( + DatasetListParamsFormatJson DatasetListParamsFormat = "JSON" + DatasetListParamsFormatCsv DatasetListParamsFormat = "CSV" +) + +type DatasetListResponseEnvelope struct { + Result DatasetListResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON datasetListResponseEnvelopeJSON `json:"-"` +} + +// datasetListResponseEnvelopeJSON contains the JSON metadata for the struct +// [DatasetListResponseEnvelope] +type datasetListResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatasetListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r datasetListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DatasetDownloadParams struct { + DatasetID param.Field[int64] `json:"datasetId,required"` + // Format results are returned in. + Format param.Field[DatasetDownloadParamsFormat] `query:"format"` +} + +func (r DatasetDownloadParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// URLQuery serializes [DatasetDownloadParams]'s query parameters as `url.Values`. +func (r DatasetDownloadParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Format results are returned in. +type DatasetDownloadParamsFormat string + +const ( + DatasetDownloadParamsFormatJson DatasetDownloadParamsFormat = "JSON" + DatasetDownloadParamsFormatCsv DatasetDownloadParamsFormat = "CSV" +) + +type DatasetDownloadResponseEnvelope struct { + Result DatasetDownloadResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON datasetDownloadResponseEnvelopeJSON `json:"-"` +} + +// datasetDownloadResponseEnvelopeJSON contains the JSON metadata for the struct +// [DatasetDownloadResponseEnvelope] +type datasetDownloadResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DatasetDownloadResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r datasetDownloadResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DatasetGetParams struct { + // Filter dataset alias by date + Date param.Field[string] `query:"date"` +} + +// URLQuery serializes [DatasetGetParams]'s query parameters as `url.Values`. +func (r DatasetGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/radar/dataset_test.go b/radar/dataset_test.go new file mode 100644 index 00000000000..8c9d265c101 --- /dev/null +++ b/radar/dataset_test.go @@ -0,0 +1,101 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestDatasetListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Datasets.List(context.TODO(), radar.DatasetListParams{ + DatasetType: cloudflare.F(radar.DatasetListParamsDatasetTypeRankingBucket), + Format: cloudflare.F(radar.DatasetListParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Offset: cloudflare.F(int64(0)), + }) + 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 TestDatasetDownloadWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Datasets.Download(context.TODO(), radar.DatasetDownloadParams{ + DatasetID: cloudflare.F(int64(3)), + Format: cloudflare.F(radar.DatasetDownloadParamsFormatJson), + }) + 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 TestDatasetGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Datasets.Get( + context.TODO(), + "ranking_top_1000", + radar.DatasetGetParams{ + Date: cloudflare.F("string"), + }, + ) + 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/radar/dns.go b/radar/dns.go new file mode 100644 index 00000000000..192db4f7bba --- /dev/null +++ b/radar/dns.go @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// DNSService 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 [NewDNSService] method instead. +type DNSService struct { + Options []option.RequestOption + Top *DNSTopService +} + +// NewDNSService 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 NewDNSService(opts ...option.RequestOption) (r *DNSService) { + r = &DNSService{} + r.Options = opts + r.Top = NewDNSTopService(opts...) + return +} diff --git a/radar/dnstop.go b/radar/dnstop.go new file mode 100644 index 00000000000..e9f348e928c --- /dev/null +++ b/radar/dnstop.go @@ -0,0 +1,544 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DNSTopService 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 [NewDNSTopService] method instead. +type DNSTopService struct { + Options []option.RequestOption +} + +// NewDNSTopService 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 NewDNSTopService(opts ...option.RequestOption) (r *DNSTopService) { + r = &DNSTopService{} + r.Options = opts + return +} + +// Get top autonomous systems by DNS queries made to Cloudflare's public DNS +// resolver. +func (r *DNSTopService) Ases(ctx context.Context, query DNSTopAsesParams, opts ...option.RequestOption) (res *DNSTopAsesResponse, err error) { + opts = append(r.Options[:], opts...) + var env DNSTopAsesResponseEnvelope + path := "radar/dns/top/ases" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get top locations by DNS queries made to Cloudflare's public DNS resolver. +func (r *DNSTopService) Locations(ctx context.Context, query DNSTopLocationsParams, opts ...option.RequestOption) (res *DNSTopLocationsResponse, err error) { + opts = append(r.Options[:], opts...) + var env DNSTopLocationsResponseEnvelope + path := "radar/dns/top/locations" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DNSTopAsesResponse struct { + Meta DNSTopAsesResponseMeta `json:"meta,required"` + Top0 []DNSTopAsesResponseTop0 `json:"top_0,required"` + JSON dnsTopAsesResponseJSON `json:"-"` +} + +// dnsTopAsesResponseJSON contains the JSON metadata for the struct +// [DNSTopAsesResponse] +type dnsTopAsesResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSTopAsesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsTopAsesResponseJSON) RawJSON() string { + return r.raw +} + +type DNSTopAsesResponseMeta struct { + DateRange []DNSTopAsesResponseMetaDateRange `json:"dateRange,required"` + ConfidenceInfo DNSTopAsesResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON dnsTopAsesResponseMetaJSON `json:"-"` +} + +// dnsTopAsesResponseMetaJSON contains the JSON metadata for the struct +// [DNSTopAsesResponseMeta] +type dnsTopAsesResponseMetaJSON struct { + DateRange apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSTopAsesResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsTopAsesResponseMetaJSON) RawJSON() string { + return r.raw +} + +type DNSTopAsesResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON dnsTopAsesResponseMetaDateRangeJSON `json:"-"` +} + +// dnsTopAsesResponseMetaDateRangeJSON contains the JSON metadata for the struct +// [DNSTopAsesResponseMetaDateRange] +type dnsTopAsesResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSTopAsesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsTopAsesResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type DNSTopAsesResponseMetaConfidenceInfo struct { + Annotations []DNSTopAsesResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON dnsTopAsesResponseMetaConfidenceInfoJSON `json:"-"` +} + +// dnsTopAsesResponseMetaConfidenceInfoJSON contains the JSON metadata for the +// struct [DNSTopAsesResponseMetaConfidenceInfo] +type dnsTopAsesResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSTopAsesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsTopAsesResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type DNSTopAsesResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON dnsTopAsesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// dnsTopAsesResponseMetaConfidenceInfoAnnotationJSON contains the JSON metadata +// for the struct [DNSTopAsesResponseMetaConfidenceInfoAnnotation] +type dnsTopAsesResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSTopAsesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsTopAsesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type DNSTopAsesResponseTop0 struct { + ClientASN int64 `json:"clientASN,required"` + ClientAsName string `json:"clientASName,required"` + Value string `json:"value,required"` + JSON dnsTopAsesResponseTop0JSON `json:"-"` +} + +// dnsTopAsesResponseTop0JSON contains the JSON metadata for the struct +// [DNSTopAsesResponseTop0] +type dnsTopAsesResponseTop0JSON struct { + ClientASN apijson.Field + ClientAsName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSTopAsesResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsTopAsesResponseTop0JSON) RawJSON() string { + return r.raw +} + +type DNSTopLocationsResponse struct { + Meta DNSTopLocationsResponseMeta `json:"meta,required"` + Top0 []DNSTopLocationsResponseTop0 `json:"top_0,required"` + JSON dnsTopLocationsResponseJSON `json:"-"` +} + +// dnsTopLocationsResponseJSON contains the JSON metadata for the struct +// [DNSTopLocationsResponse] +type dnsTopLocationsResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSTopLocationsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsTopLocationsResponseJSON) RawJSON() string { + return r.raw +} + +type DNSTopLocationsResponseMeta struct { + DateRange []DNSTopLocationsResponseMetaDateRange `json:"dateRange,required"` + ConfidenceInfo DNSTopLocationsResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON dnsTopLocationsResponseMetaJSON `json:"-"` +} + +// dnsTopLocationsResponseMetaJSON contains the JSON metadata for the struct +// [DNSTopLocationsResponseMeta] +type dnsTopLocationsResponseMetaJSON struct { + DateRange apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSTopLocationsResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsTopLocationsResponseMetaJSON) RawJSON() string { + return r.raw +} + +type DNSTopLocationsResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON dnsTopLocationsResponseMetaDateRangeJSON `json:"-"` +} + +// dnsTopLocationsResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [DNSTopLocationsResponseMetaDateRange] +type dnsTopLocationsResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSTopLocationsResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsTopLocationsResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type DNSTopLocationsResponseMetaConfidenceInfo struct { + Annotations []DNSTopLocationsResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON dnsTopLocationsResponseMetaConfidenceInfoJSON `json:"-"` +} + +// dnsTopLocationsResponseMetaConfidenceInfoJSON contains the JSON metadata for the +// struct [DNSTopLocationsResponseMetaConfidenceInfo] +type dnsTopLocationsResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSTopLocationsResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsTopLocationsResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type DNSTopLocationsResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON dnsTopLocationsResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// dnsTopLocationsResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct [DNSTopLocationsResponseMetaConfidenceInfoAnnotation] +type dnsTopLocationsResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSTopLocationsResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsTopLocationsResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type DNSTopLocationsResponseTop0 struct { + ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` + ClientCountryName string `json:"clientCountryName,required"` + Value string `json:"value,required"` + JSON dnsTopLocationsResponseTop0JSON `json:"-"` +} + +// dnsTopLocationsResponseTop0JSON contains the JSON metadata for the struct +// [DNSTopLocationsResponseTop0] +type dnsTopLocationsResponseTop0JSON struct { + ClientCountryAlpha2 apijson.Field + ClientCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSTopLocationsResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsTopLocationsResponseTop0JSON) RawJSON() string { + return r.raw +} + +type DNSTopAsesParams struct { + // Array of domain names. + Domain param.Field[[]string] `query:"domain,required"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]DNSTopAsesParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[DNSTopAsesParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [DNSTopAsesParams]'s query parameters as `url.Values`. +func (r DNSTopAsesParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type DNSTopAsesParamsDateRange string + +const ( + DNSTopAsesParamsDateRange1d DNSTopAsesParamsDateRange = "1d" + DNSTopAsesParamsDateRange2d DNSTopAsesParamsDateRange = "2d" + DNSTopAsesParamsDateRange7d DNSTopAsesParamsDateRange = "7d" + DNSTopAsesParamsDateRange14d DNSTopAsesParamsDateRange = "14d" + DNSTopAsesParamsDateRange28d DNSTopAsesParamsDateRange = "28d" + DNSTopAsesParamsDateRange12w DNSTopAsesParamsDateRange = "12w" + DNSTopAsesParamsDateRange24w DNSTopAsesParamsDateRange = "24w" + DNSTopAsesParamsDateRange52w DNSTopAsesParamsDateRange = "52w" + DNSTopAsesParamsDateRange1dControl DNSTopAsesParamsDateRange = "1dControl" + DNSTopAsesParamsDateRange2dControl DNSTopAsesParamsDateRange = "2dControl" + DNSTopAsesParamsDateRange7dControl DNSTopAsesParamsDateRange = "7dControl" + DNSTopAsesParamsDateRange14dControl DNSTopAsesParamsDateRange = "14dControl" + DNSTopAsesParamsDateRange28dControl DNSTopAsesParamsDateRange = "28dControl" + DNSTopAsesParamsDateRange12wControl DNSTopAsesParamsDateRange = "12wControl" + DNSTopAsesParamsDateRange24wControl DNSTopAsesParamsDateRange = "24wControl" +) + +// Format results are returned in. +type DNSTopAsesParamsFormat string + +const ( + DNSTopAsesParamsFormatJson DNSTopAsesParamsFormat = "JSON" + DNSTopAsesParamsFormatCsv DNSTopAsesParamsFormat = "CSV" +) + +type DNSTopAsesResponseEnvelope struct { + Result DNSTopAsesResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON dnsTopAsesResponseEnvelopeJSON `json:"-"` +} + +// dnsTopAsesResponseEnvelopeJSON contains the JSON metadata for the struct +// [DNSTopAsesResponseEnvelope] +type dnsTopAsesResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSTopAsesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsTopAsesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DNSTopLocationsParams struct { + // Array of domain names. + Domain param.Field[[]string] `query:"domain,required"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]DNSTopLocationsParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[DNSTopLocationsParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [DNSTopLocationsParams]'s query parameters as `url.Values`. +func (r DNSTopLocationsParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type DNSTopLocationsParamsDateRange string + +const ( + DNSTopLocationsParamsDateRange1d DNSTopLocationsParamsDateRange = "1d" + DNSTopLocationsParamsDateRange2d DNSTopLocationsParamsDateRange = "2d" + DNSTopLocationsParamsDateRange7d DNSTopLocationsParamsDateRange = "7d" + DNSTopLocationsParamsDateRange14d DNSTopLocationsParamsDateRange = "14d" + DNSTopLocationsParamsDateRange28d DNSTopLocationsParamsDateRange = "28d" + DNSTopLocationsParamsDateRange12w DNSTopLocationsParamsDateRange = "12w" + DNSTopLocationsParamsDateRange24w DNSTopLocationsParamsDateRange = "24w" + DNSTopLocationsParamsDateRange52w DNSTopLocationsParamsDateRange = "52w" + DNSTopLocationsParamsDateRange1dControl DNSTopLocationsParamsDateRange = "1dControl" + DNSTopLocationsParamsDateRange2dControl DNSTopLocationsParamsDateRange = "2dControl" + DNSTopLocationsParamsDateRange7dControl DNSTopLocationsParamsDateRange = "7dControl" + DNSTopLocationsParamsDateRange14dControl DNSTopLocationsParamsDateRange = "14dControl" + DNSTopLocationsParamsDateRange28dControl DNSTopLocationsParamsDateRange = "28dControl" + DNSTopLocationsParamsDateRange12wControl DNSTopLocationsParamsDateRange = "12wControl" + DNSTopLocationsParamsDateRange24wControl DNSTopLocationsParamsDateRange = "24wControl" +) + +// Format results are returned in. +type DNSTopLocationsParamsFormat string + +const ( + DNSTopLocationsParamsFormatJson DNSTopLocationsParamsFormat = "JSON" + DNSTopLocationsParamsFormatCsv DNSTopLocationsParamsFormat = "CSV" +) + +type DNSTopLocationsResponseEnvelope struct { + Result DNSTopLocationsResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON dnsTopLocationsResponseEnvelopeJSON `json:"-"` +} + +// dnsTopLocationsResponseEnvelopeJSON contains the JSON metadata for the struct +// [DNSTopLocationsResponseEnvelope] +type dnsTopLocationsResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DNSTopLocationsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dnsTopLocationsResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/dnstop_test.go b/radar/dnstop_test.go new file mode 100644 index 00000000000..d975173e193 --- /dev/null +++ b/radar/dnstop_test.go @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestDNSTopAsesWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.DNS.Top.Ases(context.TODO(), radar.DNSTopAsesParams{ + Domain: cloudflare.F([]string{"string", "string", "string"}), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.DNSTopAsesParamsDateRange{radar.DNSTopAsesParamsDateRange1d, radar.DNSTopAsesParamsDateRange2d, radar.DNSTopAsesParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.DNSTopAsesParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestDNSTopLocationsWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.DNS.Top.Locations(context.TODO(), radar.DNSTopLocationsParams{ + Domain: cloudflare.F([]string{"string", "string", "string"}), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.DNSTopLocationsParamsDateRange{radar.DNSTopLocationsParamsDateRange1d, radar.DNSTopLocationsParamsDateRange2d, radar.DNSTopLocationsParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.DNSTopLocationsParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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/radar/email.go b/radar/email.go new file mode 100644 index 00000000000..0fff4979a23 --- /dev/null +++ b/radar/email.go @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// EmailService 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 [NewEmailService] method instead. +type EmailService struct { + Options []option.RequestOption + Routing *EmailRoutingService + Security *EmailSecurityService +} + +// NewEmailService 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 NewEmailService(opts ...option.RequestOption) (r *EmailService) { + r = &EmailService{} + r.Options = opts + r.Routing = NewEmailRoutingService(opts...) + r.Security = NewEmailSecurityService(opts...) + return +} diff --git a/radar/emailrouting.go b/radar/emailrouting.go new file mode 100644 index 00000000000..9d2a3adc7ae --- /dev/null +++ b/radar/emailrouting.go @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// EmailRoutingService 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 [NewEmailRoutingService] method +// instead. +type EmailRoutingService struct { + Options []option.RequestOption + Summary *EmailRoutingSummaryService + TimeseriesGroups *EmailRoutingTimeseriesGroupService +} + +// NewEmailRoutingService 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 NewEmailRoutingService(opts ...option.RequestOption) (r *EmailRoutingService) { + r = &EmailRoutingService{} + r.Options = opts + r.Summary = NewEmailRoutingSummaryService(opts...) + r.TimeseriesGroups = NewEmailRoutingTimeseriesGroupService(opts...) + return +} diff --git a/radar/emailroutingsummary.go b/radar/emailroutingsummary.go new file mode 100644 index 00000000000..cd46ec106fc --- /dev/null +++ b/radar/emailroutingsummary.go @@ -0,0 +1,1790 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// EmailRoutingSummaryService 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 [NewEmailRoutingSummaryService] +// method instead. +type EmailRoutingSummaryService struct { + Options []option.RequestOption +} + +// NewEmailRoutingSummaryService 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 NewEmailRoutingSummaryService(opts ...option.RequestOption) (r *EmailRoutingSummaryService) { + r = &EmailRoutingSummaryService{} + r.Options = opts + return +} + +// Percentage distribution of emails classified per ARC validation. +func (r *EmailRoutingSummaryService) ARC(ctx context.Context, query EmailRoutingSummaryARCParams, opts ...option.RequestOption) (res *EmailRoutingSummaryARCResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailRoutingSummaryARCResponseEnvelope + path := "radar/email/routing/summary/arc" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified per DKIM validation. +func (r *EmailRoutingSummaryService) DKIM(ctx context.Context, query EmailRoutingSummaryDKIMParams, opts ...option.RequestOption) (res *EmailRoutingSummaryDKIMResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailRoutingSummaryDKIMResponseEnvelope + path := "radar/email/routing/summary/dkim" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified per DMARC validation. +func (r *EmailRoutingSummaryService) DMARC(ctx context.Context, query EmailRoutingSummaryDMARCParams, opts ...option.RequestOption) (res *EmailRoutingSummaryDMARCResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailRoutingSummaryDMARCResponseEnvelope + path := "radar/email/routing/summary/dmarc" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails by Encrypted +func (r *EmailRoutingSummaryService) Encrypted(ctx context.Context, query EmailRoutingSummaryEncryptedParams, opts ...option.RequestOption) (res *EmailRoutingSummaryEncryptedResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailRoutingSummaryEncryptedResponseEnvelope + path := "radar/email/routing/summary/encrypted" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails by Ip Version. +func (r *EmailRoutingSummaryService) IPVersion(ctx context.Context, query EmailRoutingSummaryIPVersionParams, opts ...option.RequestOption) (res *EmailRoutingSummaryIPVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailRoutingSummaryIPVersionResponseEnvelope + path := "radar/email/routing/summary/ip_version" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified per SPF validation. +func (r *EmailRoutingSummaryService) SPF(ctx context.Context, query EmailRoutingSummarySPFParams, opts ...option.RequestOption) (res *EmailRoutingSummarySPFResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailRoutingSummarySPFResponseEnvelope + path := "radar/email/routing/summary/spf" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type EmailRoutingSummaryARCResponse struct { + Meta EmailRoutingSummaryARCResponseMeta `json:"meta,required"` + Summary0 EmailRoutingSummaryARCResponseSummary0 `json:"summary_0,required"` + JSON emailRoutingSummaryARCResponseJSON `json:"-"` +} + +// emailRoutingSummaryARCResponseJSON contains the JSON metadata for the struct +// [EmailRoutingSummaryARCResponse] +type emailRoutingSummaryARCResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryARCResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryARCResponseJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryARCResponseMeta struct { + DateRange []EmailRoutingSummaryARCResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo EmailRoutingSummaryARCResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailRoutingSummaryARCResponseMetaJSON `json:"-"` +} + +// emailRoutingSummaryARCResponseMetaJSON contains the JSON metadata for the struct +// [EmailRoutingSummaryARCResponseMeta] +type emailRoutingSummaryARCResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryARCResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryARCResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryARCResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailRoutingSummaryARCResponseMetaDateRangeJSON `json:"-"` +} + +// emailRoutingSummaryARCResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [EmailRoutingSummaryARCResponseMetaDateRange] +type emailRoutingSummaryARCResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryARCResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryARCResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryARCResponseMetaConfidenceInfo struct { + Annotations []EmailRoutingSummaryARCResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailRoutingSummaryARCResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailRoutingSummaryARCResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [EmailRoutingSummaryARCResponseMetaConfidenceInfo] +type emailRoutingSummaryARCResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryARCResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryARCResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryARCResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailRoutingSummaryARCResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailRoutingSummaryARCResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [EmailRoutingSummaryARCResponseMetaConfidenceInfoAnnotation] +type emailRoutingSummaryARCResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryARCResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryARCResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryARCResponseSummary0 struct { + Fail string `json:"FAIL,required"` + None string `json:"NONE,required"` + Pass string `json:"PASS,required"` + JSON emailRoutingSummaryARCResponseSummary0JSON `json:"-"` +} + +// emailRoutingSummaryARCResponseSummary0JSON contains the JSON metadata for the +// struct [EmailRoutingSummaryARCResponseSummary0] +type emailRoutingSummaryARCResponseSummary0JSON struct { + Fail apijson.Field + None apijson.Field + Pass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryARCResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryARCResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryDKIMResponse struct { + Meta EmailRoutingSummaryDKIMResponseMeta `json:"meta,required"` + Summary0 EmailRoutingSummaryDKIMResponseSummary0 `json:"summary_0,required"` + JSON emailRoutingSummaryDKIMResponseJSON `json:"-"` +} + +// emailRoutingSummaryDKIMResponseJSON contains the JSON metadata for the struct +// [EmailRoutingSummaryDKIMResponse] +type emailRoutingSummaryDKIMResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryDKIMResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryDKIMResponseJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryDKIMResponseMeta struct { + DateRange []EmailRoutingSummaryDKIMResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo EmailRoutingSummaryDKIMResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailRoutingSummaryDKIMResponseMetaJSON `json:"-"` +} + +// emailRoutingSummaryDKIMResponseMetaJSON contains the JSON metadata for the +// struct [EmailRoutingSummaryDKIMResponseMeta] +type emailRoutingSummaryDKIMResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryDKIMResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryDKIMResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryDKIMResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailRoutingSummaryDKIMResponseMetaDateRangeJSON `json:"-"` +} + +// emailRoutingSummaryDKIMResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [EmailRoutingSummaryDKIMResponseMetaDateRange] +type emailRoutingSummaryDKIMResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryDKIMResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryDKIMResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryDKIMResponseMetaConfidenceInfo struct { + Annotations []EmailRoutingSummaryDKIMResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailRoutingSummaryDKIMResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailRoutingSummaryDKIMResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [EmailRoutingSummaryDKIMResponseMetaConfidenceInfo] +type emailRoutingSummaryDKIMResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryDKIMResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryDKIMResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryDKIMResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailRoutingSummaryDKIMResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailRoutingSummaryDKIMResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [EmailRoutingSummaryDKIMResponseMetaConfidenceInfoAnnotation] +type emailRoutingSummaryDKIMResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryDKIMResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryDKIMResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryDKIMResponseSummary0 struct { + Fail string `json:"FAIL,required"` + None string `json:"NONE,required"` + Pass string `json:"PASS,required"` + JSON emailRoutingSummaryDKIMResponseSummary0JSON `json:"-"` +} + +// emailRoutingSummaryDKIMResponseSummary0JSON contains the JSON metadata for the +// struct [EmailRoutingSummaryDKIMResponseSummary0] +type emailRoutingSummaryDKIMResponseSummary0JSON struct { + Fail apijson.Field + None apijson.Field + Pass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryDKIMResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryDKIMResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryDMARCResponse struct { + Meta EmailRoutingSummaryDMARCResponseMeta `json:"meta,required"` + Summary0 EmailRoutingSummaryDMARCResponseSummary0 `json:"summary_0,required"` + JSON emailRoutingSummaryDMARCResponseJSON `json:"-"` +} + +// emailRoutingSummaryDMARCResponseJSON contains the JSON metadata for the struct +// [EmailRoutingSummaryDMARCResponse] +type emailRoutingSummaryDMARCResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryDMARCResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryDMARCResponseJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryDMARCResponseMeta struct { + DateRange []EmailRoutingSummaryDMARCResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo EmailRoutingSummaryDMARCResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailRoutingSummaryDMARCResponseMetaJSON `json:"-"` +} + +// emailRoutingSummaryDMARCResponseMetaJSON contains the JSON metadata for the +// struct [EmailRoutingSummaryDMARCResponseMeta] +type emailRoutingSummaryDMARCResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryDMARCResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryDMARCResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryDMARCResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailRoutingSummaryDMARCResponseMetaDateRangeJSON `json:"-"` +} + +// emailRoutingSummaryDMARCResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [EmailRoutingSummaryDMARCResponseMetaDateRange] +type emailRoutingSummaryDMARCResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryDMARCResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryDMARCResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryDMARCResponseMetaConfidenceInfo struct { + Annotations []EmailRoutingSummaryDMARCResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailRoutingSummaryDMARCResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailRoutingSummaryDMARCResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [EmailRoutingSummaryDMARCResponseMetaConfidenceInfo] +type emailRoutingSummaryDMARCResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryDMARCResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryDMARCResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryDMARCResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailRoutingSummaryDMARCResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailRoutingSummaryDMARCResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [EmailRoutingSummaryDMARCResponseMetaConfidenceInfoAnnotation] +type emailRoutingSummaryDMARCResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryDMARCResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryDMARCResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryDMARCResponseSummary0 struct { + Fail string `json:"FAIL,required"` + None string `json:"NONE,required"` + Pass string `json:"PASS,required"` + JSON emailRoutingSummaryDMARCResponseSummary0JSON `json:"-"` +} + +// emailRoutingSummaryDMARCResponseSummary0JSON contains the JSON metadata for the +// struct [EmailRoutingSummaryDMARCResponseSummary0] +type emailRoutingSummaryDMARCResponseSummary0JSON struct { + Fail apijson.Field + None apijson.Field + Pass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryDMARCResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryDMARCResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryEncryptedResponse struct { + Meta EmailRoutingSummaryEncryptedResponseMeta `json:"meta,required"` + Summary0 EmailRoutingSummaryEncryptedResponseSummary0 `json:"summary_0,required"` + JSON emailRoutingSummaryEncryptedResponseJSON `json:"-"` +} + +// emailRoutingSummaryEncryptedResponseJSON contains the JSON metadata for the +// struct [EmailRoutingSummaryEncryptedResponse] +type emailRoutingSummaryEncryptedResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryEncryptedResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryEncryptedResponseJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryEncryptedResponseMeta struct { + DateRange []EmailRoutingSummaryEncryptedResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo EmailRoutingSummaryEncryptedResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailRoutingSummaryEncryptedResponseMetaJSON `json:"-"` +} + +// emailRoutingSummaryEncryptedResponseMetaJSON contains the JSON metadata for the +// struct [EmailRoutingSummaryEncryptedResponseMeta] +type emailRoutingSummaryEncryptedResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryEncryptedResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryEncryptedResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryEncryptedResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailRoutingSummaryEncryptedResponseMetaDateRangeJSON `json:"-"` +} + +// emailRoutingSummaryEncryptedResponseMetaDateRangeJSON contains the JSON metadata +// for the struct [EmailRoutingSummaryEncryptedResponseMetaDateRange] +type emailRoutingSummaryEncryptedResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryEncryptedResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryEncryptedResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryEncryptedResponseMetaConfidenceInfo struct { + Annotations []EmailRoutingSummaryEncryptedResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailRoutingSummaryEncryptedResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailRoutingSummaryEncryptedResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [EmailRoutingSummaryEncryptedResponseMetaConfidenceInfo] +type emailRoutingSummaryEncryptedResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryEncryptedResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryEncryptedResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryEncryptedResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailRoutingSummaryEncryptedResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailRoutingSummaryEncryptedResponseMetaConfidenceInfoAnnotationJSON contains +// the JSON metadata for the struct +// [EmailRoutingSummaryEncryptedResponseMetaConfidenceInfoAnnotation] +type emailRoutingSummaryEncryptedResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryEncryptedResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryEncryptedResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryEncryptedResponseSummary0 struct { + Encrypted string `json:"ENCRYPTED,required"` + NotEncrypted string `json:"NOT_ENCRYPTED,required"` + JSON emailRoutingSummaryEncryptedResponseSummary0JSON `json:"-"` +} + +// emailRoutingSummaryEncryptedResponseSummary0JSON contains the JSON metadata for +// the struct [EmailRoutingSummaryEncryptedResponseSummary0] +type emailRoutingSummaryEncryptedResponseSummary0JSON struct { + Encrypted apijson.Field + NotEncrypted apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryEncryptedResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryEncryptedResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryIPVersionResponse struct { + Meta EmailRoutingSummaryIPVersionResponseMeta `json:"meta,required"` + Summary0 EmailRoutingSummaryIPVersionResponseSummary0 `json:"summary_0,required"` + JSON emailRoutingSummaryIPVersionResponseJSON `json:"-"` +} + +// emailRoutingSummaryIPVersionResponseJSON contains the JSON metadata for the +// struct [EmailRoutingSummaryIPVersionResponse] +type emailRoutingSummaryIPVersionResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryIPVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryIPVersionResponseJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryIPVersionResponseMeta struct { + DateRange []EmailRoutingSummaryIPVersionResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo EmailRoutingSummaryIPVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailRoutingSummaryIPVersionResponseMetaJSON `json:"-"` +} + +// emailRoutingSummaryIPVersionResponseMetaJSON contains the JSON metadata for the +// struct [EmailRoutingSummaryIPVersionResponseMeta] +type emailRoutingSummaryIPVersionResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryIPVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryIPVersionResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryIPVersionResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailRoutingSummaryIPVersionResponseMetaDateRangeJSON `json:"-"` +} + +// emailRoutingSummaryIPVersionResponseMetaDateRangeJSON contains the JSON metadata +// for the struct [EmailRoutingSummaryIPVersionResponseMetaDateRange] +type emailRoutingSummaryIPVersionResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryIPVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryIPVersionResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryIPVersionResponseMetaConfidenceInfo struct { + Annotations []EmailRoutingSummaryIPVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailRoutingSummaryIPVersionResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailRoutingSummaryIPVersionResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [EmailRoutingSummaryIPVersionResponseMetaConfidenceInfo] +type emailRoutingSummaryIPVersionResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryIPVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryIPVersionResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryIPVersionResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailRoutingSummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailRoutingSummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON contains +// the JSON metadata for the struct +// [EmailRoutingSummaryIPVersionResponseMetaConfidenceInfoAnnotation] +type emailRoutingSummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryIPVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryIPVersionResponseSummary0 struct { + IPv4 string `json:"IPv4,required"` + IPv6 string `json:"IPv6,required"` + JSON emailRoutingSummaryIPVersionResponseSummary0JSON `json:"-"` +} + +// emailRoutingSummaryIPVersionResponseSummary0JSON contains the JSON metadata for +// the struct [EmailRoutingSummaryIPVersionResponseSummary0] +type emailRoutingSummaryIPVersionResponseSummary0JSON struct { + IPv4 apijson.Field + IPv6 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryIPVersionResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryIPVersionResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummarySPFResponse struct { + Meta EmailRoutingSummarySPFResponseMeta `json:"meta,required"` + Summary0 EmailRoutingSummarySPFResponseSummary0 `json:"summary_0,required"` + JSON emailRoutingSummarySPFResponseJSON `json:"-"` +} + +// emailRoutingSummarySPFResponseJSON contains the JSON metadata for the struct +// [EmailRoutingSummarySPFResponse] +type emailRoutingSummarySPFResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummarySPFResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummarySPFResponseJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummarySPFResponseMeta struct { + DateRange []EmailRoutingSummarySPFResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo EmailRoutingSummarySPFResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailRoutingSummarySPFResponseMetaJSON `json:"-"` +} + +// emailRoutingSummarySPFResponseMetaJSON contains the JSON metadata for the struct +// [EmailRoutingSummarySPFResponseMeta] +type emailRoutingSummarySPFResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummarySPFResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummarySPFResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummarySPFResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailRoutingSummarySPFResponseMetaDateRangeJSON `json:"-"` +} + +// emailRoutingSummarySPFResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [EmailRoutingSummarySPFResponseMetaDateRange] +type emailRoutingSummarySPFResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummarySPFResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummarySPFResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummarySPFResponseMetaConfidenceInfo struct { + Annotations []EmailRoutingSummarySPFResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailRoutingSummarySPFResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailRoutingSummarySPFResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [EmailRoutingSummarySPFResponseMetaConfidenceInfo] +type emailRoutingSummarySPFResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummarySPFResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummarySPFResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummarySPFResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailRoutingSummarySPFResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailRoutingSummarySPFResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [EmailRoutingSummarySPFResponseMetaConfidenceInfoAnnotation] +type emailRoutingSummarySPFResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummarySPFResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummarySPFResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummarySPFResponseSummary0 struct { + Fail string `json:"FAIL,required"` + None string `json:"NONE,required"` + Pass string `json:"PASS,required"` + JSON emailRoutingSummarySPFResponseSummary0JSON `json:"-"` +} + +// emailRoutingSummarySPFResponseSummary0JSON contains the JSON metadata for the +// struct [EmailRoutingSummarySPFResponseSummary0] +type emailRoutingSummarySPFResponseSummary0JSON struct { + Fail apijson.Field + None apijson.Field + Pass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummarySPFResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummarySPFResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryARCParams struct { + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailRoutingSummaryARCParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailRoutingSummaryARCParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailRoutingSummaryARCParamsDMARC] `query:"dmarc"` + // Filter for encrypted emails. + Encrypted param.Field[[]EmailRoutingSummaryARCParamsEncrypted] `query:"encrypted"` + // Format results are returned in. + Format param.Field[EmailRoutingSummaryARCParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]EmailRoutingSummaryARCParamsIPVersion] `query:"ipVersion"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailRoutingSummaryARCParamsSPF] `query:"spf"` +} + +// URLQuery serializes [EmailRoutingSummaryARCParams]'s query parameters as +// `url.Values`. +func (r EmailRoutingSummaryARCParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type EmailRoutingSummaryARCParamsDateRange string + +const ( + EmailRoutingSummaryARCParamsDateRange1d EmailRoutingSummaryARCParamsDateRange = "1d" + EmailRoutingSummaryARCParamsDateRange2d EmailRoutingSummaryARCParamsDateRange = "2d" + EmailRoutingSummaryARCParamsDateRange7d EmailRoutingSummaryARCParamsDateRange = "7d" + EmailRoutingSummaryARCParamsDateRange14d EmailRoutingSummaryARCParamsDateRange = "14d" + EmailRoutingSummaryARCParamsDateRange28d EmailRoutingSummaryARCParamsDateRange = "28d" + EmailRoutingSummaryARCParamsDateRange12w EmailRoutingSummaryARCParamsDateRange = "12w" + EmailRoutingSummaryARCParamsDateRange24w EmailRoutingSummaryARCParamsDateRange = "24w" + EmailRoutingSummaryARCParamsDateRange52w EmailRoutingSummaryARCParamsDateRange = "52w" + EmailRoutingSummaryARCParamsDateRange1dControl EmailRoutingSummaryARCParamsDateRange = "1dControl" + EmailRoutingSummaryARCParamsDateRange2dControl EmailRoutingSummaryARCParamsDateRange = "2dControl" + EmailRoutingSummaryARCParamsDateRange7dControl EmailRoutingSummaryARCParamsDateRange = "7dControl" + EmailRoutingSummaryARCParamsDateRange14dControl EmailRoutingSummaryARCParamsDateRange = "14dControl" + EmailRoutingSummaryARCParamsDateRange28dControl EmailRoutingSummaryARCParamsDateRange = "28dControl" + EmailRoutingSummaryARCParamsDateRange12wControl EmailRoutingSummaryARCParamsDateRange = "12wControl" + EmailRoutingSummaryARCParamsDateRange24wControl EmailRoutingSummaryARCParamsDateRange = "24wControl" +) + +type EmailRoutingSummaryARCParamsDKIM string + +const ( + EmailRoutingSummaryARCParamsDKIMPass EmailRoutingSummaryARCParamsDKIM = "PASS" + EmailRoutingSummaryARCParamsDKIMNone EmailRoutingSummaryARCParamsDKIM = "NONE" + EmailRoutingSummaryARCParamsDKIMFail EmailRoutingSummaryARCParamsDKIM = "FAIL" +) + +type EmailRoutingSummaryARCParamsDMARC string + +const ( + EmailRoutingSummaryARCParamsDMARCPass EmailRoutingSummaryARCParamsDMARC = "PASS" + EmailRoutingSummaryARCParamsDMARCNone EmailRoutingSummaryARCParamsDMARC = "NONE" + EmailRoutingSummaryARCParamsDMARCFail EmailRoutingSummaryARCParamsDMARC = "FAIL" +) + +type EmailRoutingSummaryARCParamsEncrypted string + +const ( + EmailRoutingSummaryARCParamsEncryptedEncrypted EmailRoutingSummaryARCParamsEncrypted = "ENCRYPTED" + EmailRoutingSummaryARCParamsEncryptedNotEncrypted EmailRoutingSummaryARCParamsEncrypted = "NOT_ENCRYPTED" +) + +// Format results are returned in. +type EmailRoutingSummaryARCParamsFormat string + +const ( + EmailRoutingSummaryARCParamsFormatJson EmailRoutingSummaryARCParamsFormat = "JSON" + EmailRoutingSummaryARCParamsFormatCsv EmailRoutingSummaryARCParamsFormat = "CSV" +) + +type EmailRoutingSummaryARCParamsIPVersion string + +const ( + EmailRoutingSummaryARCParamsIPVersionIPv4 EmailRoutingSummaryARCParamsIPVersion = "IPv4" + EmailRoutingSummaryARCParamsIPVersionIPv6 EmailRoutingSummaryARCParamsIPVersion = "IPv6" +) + +type EmailRoutingSummaryARCParamsSPF string + +const ( + EmailRoutingSummaryARCParamsSPFPass EmailRoutingSummaryARCParamsSPF = "PASS" + EmailRoutingSummaryARCParamsSPFNone EmailRoutingSummaryARCParamsSPF = "NONE" + EmailRoutingSummaryARCParamsSPFFail EmailRoutingSummaryARCParamsSPF = "FAIL" +) + +type EmailRoutingSummaryARCResponseEnvelope struct { + Result EmailRoutingSummaryARCResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailRoutingSummaryARCResponseEnvelopeJSON `json:"-"` +} + +// emailRoutingSummaryARCResponseEnvelopeJSON contains the JSON metadata for the +// struct [EmailRoutingSummaryARCResponseEnvelope] +type emailRoutingSummaryARCResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryARCResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryARCResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryDKIMParams struct { + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailRoutingSummaryDKIMParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailRoutingSummaryDKIMParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dmarc. + DMARC param.Field[[]EmailRoutingSummaryDKIMParamsDMARC] `query:"dmarc"` + // Filter for encrypted emails. + Encrypted param.Field[[]EmailRoutingSummaryDKIMParamsEncrypted] `query:"encrypted"` + // Format results are returned in. + Format param.Field[EmailRoutingSummaryDKIMParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]EmailRoutingSummaryDKIMParamsIPVersion] `query:"ipVersion"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailRoutingSummaryDKIMParamsSPF] `query:"spf"` +} + +// URLQuery serializes [EmailRoutingSummaryDKIMParams]'s query parameters as +// `url.Values`. +func (r EmailRoutingSummaryDKIMParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type EmailRoutingSummaryDKIMParamsARC string + +const ( + EmailRoutingSummaryDKIMParamsARCPass EmailRoutingSummaryDKIMParamsARC = "PASS" + EmailRoutingSummaryDKIMParamsARCNone EmailRoutingSummaryDKIMParamsARC = "NONE" + EmailRoutingSummaryDKIMParamsARCFail EmailRoutingSummaryDKIMParamsARC = "FAIL" +) + +type EmailRoutingSummaryDKIMParamsDateRange string + +const ( + EmailRoutingSummaryDKIMParamsDateRange1d EmailRoutingSummaryDKIMParamsDateRange = "1d" + EmailRoutingSummaryDKIMParamsDateRange2d EmailRoutingSummaryDKIMParamsDateRange = "2d" + EmailRoutingSummaryDKIMParamsDateRange7d EmailRoutingSummaryDKIMParamsDateRange = "7d" + EmailRoutingSummaryDKIMParamsDateRange14d EmailRoutingSummaryDKIMParamsDateRange = "14d" + EmailRoutingSummaryDKIMParamsDateRange28d EmailRoutingSummaryDKIMParamsDateRange = "28d" + EmailRoutingSummaryDKIMParamsDateRange12w EmailRoutingSummaryDKIMParamsDateRange = "12w" + EmailRoutingSummaryDKIMParamsDateRange24w EmailRoutingSummaryDKIMParamsDateRange = "24w" + EmailRoutingSummaryDKIMParamsDateRange52w EmailRoutingSummaryDKIMParamsDateRange = "52w" + EmailRoutingSummaryDKIMParamsDateRange1dControl EmailRoutingSummaryDKIMParamsDateRange = "1dControl" + EmailRoutingSummaryDKIMParamsDateRange2dControl EmailRoutingSummaryDKIMParamsDateRange = "2dControl" + EmailRoutingSummaryDKIMParamsDateRange7dControl EmailRoutingSummaryDKIMParamsDateRange = "7dControl" + EmailRoutingSummaryDKIMParamsDateRange14dControl EmailRoutingSummaryDKIMParamsDateRange = "14dControl" + EmailRoutingSummaryDKIMParamsDateRange28dControl EmailRoutingSummaryDKIMParamsDateRange = "28dControl" + EmailRoutingSummaryDKIMParamsDateRange12wControl EmailRoutingSummaryDKIMParamsDateRange = "12wControl" + EmailRoutingSummaryDKIMParamsDateRange24wControl EmailRoutingSummaryDKIMParamsDateRange = "24wControl" +) + +type EmailRoutingSummaryDKIMParamsDMARC string + +const ( + EmailRoutingSummaryDKIMParamsDMARCPass EmailRoutingSummaryDKIMParamsDMARC = "PASS" + EmailRoutingSummaryDKIMParamsDMARCNone EmailRoutingSummaryDKIMParamsDMARC = "NONE" + EmailRoutingSummaryDKIMParamsDMARCFail EmailRoutingSummaryDKIMParamsDMARC = "FAIL" +) + +type EmailRoutingSummaryDKIMParamsEncrypted string + +const ( + EmailRoutingSummaryDKIMParamsEncryptedEncrypted EmailRoutingSummaryDKIMParamsEncrypted = "ENCRYPTED" + EmailRoutingSummaryDKIMParamsEncryptedNotEncrypted EmailRoutingSummaryDKIMParamsEncrypted = "NOT_ENCRYPTED" +) + +// Format results are returned in. +type EmailRoutingSummaryDKIMParamsFormat string + +const ( + EmailRoutingSummaryDKIMParamsFormatJson EmailRoutingSummaryDKIMParamsFormat = "JSON" + EmailRoutingSummaryDKIMParamsFormatCsv EmailRoutingSummaryDKIMParamsFormat = "CSV" +) + +type EmailRoutingSummaryDKIMParamsIPVersion string + +const ( + EmailRoutingSummaryDKIMParamsIPVersionIPv4 EmailRoutingSummaryDKIMParamsIPVersion = "IPv4" + EmailRoutingSummaryDKIMParamsIPVersionIPv6 EmailRoutingSummaryDKIMParamsIPVersion = "IPv6" +) + +type EmailRoutingSummaryDKIMParamsSPF string + +const ( + EmailRoutingSummaryDKIMParamsSPFPass EmailRoutingSummaryDKIMParamsSPF = "PASS" + EmailRoutingSummaryDKIMParamsSPFNone EmailRoutingSummaryDKIMParamsSPF = "NONE" + EmailRoutingSummaryDKIMParamsSPFFail EmailRoutingSummaryDKIMParamsSPF = "FAIL" +) + +type EmailRoutingSummaryDKIMResponseEnvelope struct { + Result EmailRoutingSummaryDKIMResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailRoutingSummaryDKIMResponseEnvelopeJSON `json:"-"` +} + +// emailRoutingSummaryDKIMResponseEnvelopeJSON contains the JSON metadata for the +// struct [EmailRoutingSummaryDKIMResponseEnvelope] +type emailRoutingSummaryDKIMResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryDKIMResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryDKIMResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryDMARCParams struct { + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailRoutingSummaryDMARCParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailRoutingSummaryDMARCParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailRoutingSummaryDMARCParamsDKIM] `query:"dkim"` + // Filter for encrypted emails. + Encrypted param.Field[[]EmailRoutingSummaryDMARCParamsEncrypted] `query:"encrypted"` + // Format results are returned in. + Format param.Field[EmailRoutingSummaryDMARCParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]EmailRoutingSummaryDMARCParamsIPVersion] `query:"ipVersion"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailRoutingSummaryDMARCParamsSPF] `query:"spf"` +} + +// URLQuery serializes [EmailRoutingSummaryDMARCParams]'s query parameters as +// `url.Values`. +func (r EmailRoutingSummaryDMARCParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type EmailRoutingSummaryDMARCParamsARC string + +const ( + EmailRoutingSummaryDMARCParamsARCPass EmailRoutingSummaryDMARCParamsARC = "PASS" + EmailRoutingSummaryDMARCParamsARCNone EmailRoutingSummaryDMARCParamsARC = "NONE" + EmailRoutingSummaryDMARCParamsARCFail EmailRoutingSummaryDMARCParamsARC = "FAIL" +) + +type EmailRoutingSummaryDMARCParamsDateRange string + +const ( + EmailRoutingSummaryDMARCParamsDateRange1d EmailRoutingSummaryDMARCParamsDateRange = "1d" + EmailRoutingSummaryDMARCParamsDateRange2d EmailRoutingSummaryDMARCParamsDateRange = "2d" + EmailRoutingSummaryDMARCParamsDateRange7d EmailRoutingSummaryDMARCParamsDateRange = "7d" + EmailRoutingSummaryDMARCParamsDateRange14d EmailRoutingSummaryDMARCParamsDateRange = "14d" + EmailRoutingSummaryDMARCParamsDateRange28d EmailRoutingSummaryDMARCParamsDateRange = "28d" + EmailRoutingSummaryDMARCParamsDateRange12w EmailRoutingSummaryDMARCParamsDateRange = "12w" + EmailRoutingSummaryDMARCParamsDateRange24w EmailRoutingSummaryDMARCParamsDateRange = "24w" + EmailRoutingSummaryDMARCParamsDateRange52w EmailRoutingSummaryDMARCParamsDateRange = "52w" + EmailRoutingSummaryDMARCParamsDateRange1dControl EmailRoutingSummaryDMARCParamsDateRange = "1dControl" + EmailRoutingSummaryDMARCParamsDateRange2dControl EmailRoutingSummaryDMARCParamsDateRange = "2dControl" + EmailRoutingSummaryDMARCParamsDateRange7dControl EmailRoutingSummaryDMARCParamsDateRange = "7dControl" + EmailRoutingSummaryDMARCParamsDateRange14dControl EmailRoutingSummaryDMARCParamsDateRange = "14dControl" + EmailRoutingSummaryDMARCParamsDateRange28dControl EmailRoutingSummaryDMARCParamsDateRange = "28dControl" + EmailRoutingSummaryDMARCParamsDateRange12wControl EmailRoutingSummaryDMARCParamsDateRange = "12wControl" + EmailRoutingSummaryDMARCParamsDateRange24wControl EmailRoutingSummaryDMARCParamsDateRange = "24wControl" +) + +type EmailRoutingSummaryDMARCParamsDKIM string + +const ( + EmailRoutingSummaryDMARCParamsDKIMPass EmailRoutingSummaryDMARCParamsDKIM = "PASS" + EmailRoutingSummaryDMARCParamsDKIMNone EmailRoutingSummaryDMARCParamsDKIM = "NONE" + EmailRoutingSummaryDMARCParamsDKIMFail EmailRoutingSummaryDMARCParamsDKIM = "FAIL" +) + +type EmailRoutingSummaryDMARCParamsEncrypted string + +const ( + EmailRoutingSummaryDMARCParamsEncryptedEncrypted EmailRoutingSummaryDMARCParamsEncrypted = "ENCRYPTED" + EmailRoutingSummaryDMARCParamsEncryptedNotEncrypted EmailRoutingSummaryDMARCParamsEncrypted = "NOT_ENCRYPTED" +) + +// Format results are returned in. +type EmailRoutingSummaryDMARCParamsFormat string + +const ( + EmailRoutingSummaryDMARCParamsFormatJson EmailRoutingSummaryDMARCParamsFormat = "JSON" + EmailRoutingSummaryDMARCParamsFormatCsv EmailRoutingSummaryDMARCParamsFormat = "CSV" +) + +type EmailRoutingSummaryDMARCParamsIPVersion string + +const ( + EmailRoutingSummaryDMARCParamsIPVersionIPv4 EmailRoutingSummaryDMARCParamsIPVersion = "IPv4" + EmailRoutingSummaryDMARCParamsIPVersionIPv6 EmailRoutingSummaryDMARCParamsIPVersion = "IPv6" +) + +type EmailRoutingSummaryDMARCParamsSPF string + +const ( + EmailRoutingSummaryDMARCParamsSPFPass EmailRoutingSummaryDMARCParamsSPF = "PASS" + EmailRoutingSummaryDMARCParamsSPFNone EmailRoutingSummaryDMARCParamsSPF = "NONE" + EmailRoutingSummaryDMARCParamsSPFFail EmailRoutingSummaryDMARCParamsSPF = "FAIL" +) + +type EmailRoutingSummaryDMARCResponseEnvelope struct { + Result EmailRoutingSummaryDMARCResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailRoutingSummaryDMARCResponseEnvelopeJSON `json:"-"` +} + +// emailRoutingSummaryDMARCResponseEnvelopeJSON contains the JSON metadata for the +// struct [EmailRoutingSummaryDMARCResponseEnvelope] +type emailRoutingSummaryDMARCResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryDMARCResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryDMARCResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryEncryptedParams struct { + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailRoutingSummaryEncryptedParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailRoutingSummaryEncryptedParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailRoutingSummaryEncryptedParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailRoutingSummaryEncryptedParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailRoutingSummaryEncryptedParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]EmailRoutingSummaryEncryptedParamsIPVersion] `query:"ipVersion"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailRoutingSummaryEncryptedParamsSPF] `query:"spf"` +} + +// URLQuery serializes [EmailRoutingSummaryEncryptedParams]'s query parameters as +// `url.Values`. +func (r EmailRoutingSummaryEncryptedParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type EmailRoutingSummaryEncryptedParamsARC string + +const ( + EmailRoutingSummaryEncryptedParamsARCPass EmailRoutingSummaryEncryptedParamsARC = "PASS" + EmailRoutingSummaryEncryptedParamsARCNone EmailRoutingSummaryEncryptedParamsARC = "NONE" + EmailRoutingSummaryEncryptedParamsARCFail EmailRoutingSummaryEncryptedParamsARC = "FAIL" +) + +type EmailRoutingSummaryEncryptedParamsDateRange string + +const ( + EmailRoutingSummaryEncryptedParamsDateRange1d EmailRoutingSummaryEncryptedParamsDateRange = "1d" + EmailRoutingSummaryEncryptedParamsDateRange2d EmailRoutingSummaryEncryptedParamsDateRange = "2d" + EmailRoutingSummaryEncryptedParamsDateRange7d EmailRoutingSummaryEncryptedParamsDateRange = "7d" + EmailRoutingSummaryEncryptedParamsDateRange14d EmailRoutingSummaryEncryptedParamsDateRange = "14d" + EmailRoutingSummaryEncryptedParamsDateRange28d EmailRoutingSummaryEncryptedParamsDateRange = "28d" + EmailRoutingSummaryEncryptedParamsDateRange12w EmailRoutingSummaryEncryptedParamsDateRange = "12w" + EmailRoutingSummaryEncryptedParamsDateRange24w EmailRoutingSummaryEncryptedParamsDateRange = "24w" + EmailRoutingSummaryEncryptedParamsDateRange52w EmailRoutingSummaryEncryptedParamsDateRange = "52w" + EmailRoutingSummaryEncryptedParamsDateRange1dControl EmailRoutingSummaryEncryptedParamsDateRange = "1dControl" + EmailRoutingSummaryEncryptedParamsDateRange2dControl EmailRoutingSummaryEncryptedParamsDateRange = "2dControl" + EmailRoutingSummaryEncryptedParamsDateRange7dControl EmailRoutingSummaryEncryptedParamsDateRange = "7dControl" + EmailRoutingSummaryEncryptedParamsDateRange14dControl EmailRoutingSummaryEncryptedParamsDateRange = "14dControl" + EmailRoutingSummaryEncryptedParamsDateRange28dControl EmailRoutingSummaryEncryptedParamsDateRange = "28dControl" + EmailRoutingSummaryEncryptedParamsDateRange12wControl EmailRoutingSummaryEncryptedParamsDateRange = "12wControl" + EmailRoutingSummaryEncryptedParamsDateRange24wControl EmailRoutingSummaryEncryptedParamsDateRange = "24wControl" +) + +type EmailRoutingSummaryEncryptedParamsDKIM string + +const ( + EmailRoutingSummaryEncryptedParamsDKIMPass EmailRoutingSummaryEncryptedParamsDKIM = "PASS" + EmailRoutingSummaryEncryptedParamsDKIMNone EmailRoutingSummaryEncryptedParamsDKIM = "NONE" + EmailRoutingSummaryEncryptedParamsDKIMFail EmailRoutingSummaryEncryptedParamsDKIM = "FAIL" +) + +type EmailRoutingSummaryEncryptedParamsDMARC string + +const ( + EmailRoutingSummaryEncryptedParamsDMARCPass EmailRoutingSummaryEncryptedParamsDMARC = "PASS" + EmailRoutingSummaryEncryptedParamsDMARCNone EmailRoutingSummaryEncryptedParamsDMARC = "NONE" + EmailRoutingSummaryEncryptedParamsDMARCFail EmailRoutingSummaryEncryptedParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailRoutingSummaryEncryptedParamsFormat string + +const ( + EmailRoutingSummaryEncryptedParamsFormatJson EmailRoutingSummaryEncryptedParamsFormat = "JSON" + EmailRoutingSummaryEncryptedParamsFormatCsv EmailRoutingSummaryEncryptedParamsFormat = "CSV" +) + +type EmailRoutingSummaryEncryptedParamsIPVersion string + +const ( + EmailRoutingSummaryEncryptedParamsIPVersionIPv4 EmailRoutingSummaryEncryptedParamsIPVersion = "IPv4" + EmailRoutingSummaryEncryptedParamsIPVersionIPv6 EmailRoutingSummaryEncryptedParamsIPVersion = "IPv6" +) + +type EmailRoutingSummaryEncryptedParamsSPF string + +const ( + EmailRoutingSummaryEncryptedParamsSPFPass EmailRoutingSummaryEncryptedParamsSPF = "PASS" + EmailRoutingSummaryEncryptedParamsSPFNone EmailRoutingSummaryEncryptedParamsSPF = "NONE" + EmailRoutingSummaryEncryptedParamsSPFFail EmailRoutingSummaryEncryptedParamsSPF = "FAIL" +) + +type EmailRoutingSummaryEncryptedResponseEnvelope struct { + Result EmailRoutingSummaryEncryptedResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailRoutingSummaryEncryptedResponseEnvelopeJSON `json:"-"` +} + +// emailRoutingSummaryEncryptedResponseEnvelopeJSON contains the JSON metadata for +// the struct [EmailRoutingSummaryEncryptedResponseEnvelope] +type emailRoutingSummaryEncryptedResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryEncryptedResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryEncryptedResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummaryIPVersionParams struct { + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailRoutingSummaryIPVersionParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailRoutingSummaryIPVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailRoutingSummaryIPVersionParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailRoutingSummaryIPVersionParamsDMARC] `query:"dmarc"` + // Filter for encrypted emails. + Encrypted param.Field[[]EmailRoutingSummaryIPVersionParamsEncrypted] `query:"encrypted"` + // Format results are returned in. + Format param.Field[EmailRoutingSummaryIPVersionParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailRoutingSummaryIPVersionParamsSPF] `query:"spf"` +} + +// URLQuery serializes [EmailRoutingSummaryIPVersionParams]'s query parameters as +// `url.Values`. +func (r EmailRoutingSummaryIPVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type EmailRoutingSummaryIPVersionParamsARC string + +const ( + EmailRoutingSummaryIPVersionParamsARCPass EmailRoutingSummaryIPVersionParamsARC = "PASS" + EmailRoutingSummaryIPVersionParamsARCNone EmailRoutingSummaryIPVersionParamsARC = "NONE" + EmailRoutingSummaryIPVersionParamsARCFail EmailRoutingSummaryIPVersionParamsARC = "FAIL" +) + +type EmailRoutingSummaryIPVersionParamsDateRange string + +const ( + EmailRoutingSummaryIPVersionParamsDateRange1d EmailRoutingSummaryIPVersionParamsDateRange = "1d" + EmailRoutingSummaryIPVersionParamsDateRange2d EmailRoutingSummaryIPVersionParamsDateRange = "2d" + EmailRoutingSummaryIPVersionParamsDateRange7d EmailRoutingSummaryIPVersionParamsDateRange = "7d" + EmailRoutingSummaryIPVersionParamsDateRange14d EmailRoutingSummaryIPVersionParamsDateRange = "14d" + EmailRoutingSummaryIPVersionParamsDateRange28d EmailRoutingSummaryIPVersionParamsDateRange = "28d" + EmailRoutingSummaryIPVersionParamsDateRange12w EmailRoutingSummaryIPVersionParamsDateRange = "12w" + EmailRoutingSummaryIPVersionParamsDateRange24w EmailRoutingSummaryIPVersionParamsDateRange = "24w" + EmailRoutingSummaryIPVersionParamsDateRange52w EmailRoutingSummaryIPVersionParamsDateRange = "52w" + EmailRoutingSummaryIPVersionParamsDateRange1dControl EmailRoutingSummaryIPVersionParamsDateRange = "1dControl" + EmailRoutingSummaryIPVersionParamsDateRange2dControl EmailRoutingSummaryIPVersionParamsDateRange = "2dControl" + EmailRoutingSummaryIPVersionParamsDateRange7dControl EmailRoutingSummaryIPVersionParamsDateRange = "7dControl" + EmailRoutingSummaryIPVersionParamsDateRange14dControl EmailRoutingSummaryIPVersionParamsDateRange = "14dControl" + EmailRoutingSummaryIPVersionParamsDateRange28dControl EmailRoutingSummaryIPVersionParamsDateRange = "28dControl" + EmailRoutingSummaryIPVersionParamsDateRange12wControl EmailRoutingSummaryIPVersionParamsDateRange = "12wControl" + EmailRoutingSummaryIPVersionParamsDateRange24wControl EmailRoutingSummaryIPVersionParamsDateRange = "24wControl" +) + +type EmailRoutingSummaryIPVersionParamsDKIM string + +const ( + EmailRoutingSummaryIPVersionParamsDKIMPass EmailRoutingSummaryIPVersionParamsDKIM = "PASS" + EmailRoutingSummaryIPVersionParamsDKIMNone EmailRoutingSummaryIPVersionParamsDKIM = "NONE" + EmailRoutingSummaryIPVersionParamsDKIMFail EmailRoutingSummaryIPVersionParamsDKIM = "FAIL" +) + +type EmailRoutingSummaryIPVersionParamsDMARC string + +const ( + EmailRoutingSummaryIPVersionParamsDMARCPass EmailRoutingSummaryIPVersionParamsDMARC = "PASS" + EmailRoutingSummaryIPVersionParamsDMARCNone EmailRoutingSummaryIPVersionParamsDMARC = "NONE" + EmailRoutingSummaryIPVersionParamsDMARCFail EmailRoutingSummaryIPVersionParamsDMARC = "FAIL" +) + +type EmailRoutingSummaryIPVersionParamsEncrypted string + +const ( + EmailRoutingSummaryIPVersionParamsEncryptedEncrypted EmailRoutingSummaryIPVersionParamsEncrypted = "ENCRYPTED" + EmailRoutingSummaryIPVersionParamsEncryptedNotEncrypted EmailRoutingSummaryIPVersionParamsEncrypted = "NOT_ENCRYPTED" +) + +// Format results are returned in. +type EmailRoutingSummaryIPVersionParamsFormat string + +const ( + EmailRoutingSummaryIPVersionParamsFormatJson EmailRoutingSummaryIPVersionParamsFormat = "JSON" + EmailRoutingSummaryIPVersionParamsFormatCsv EmailRoutingSummaryIPVersionParamsFormat = "CSV" +) + +type EmailRoutingSummaryIPVersionParamsSPF string + +const ( + EmailRoutingSummaryIPVersionParamsSPFPass EmailRoutingSummaryIPVersionParamsSPF = "PASS" + EmailRoutingSummaryIPVersionParamsSPFNone EmailRoutingSummaryIPVersionParamsSPF = "NONE" + EmailRoutingSummaryIPVersionParamsSPFFail EmailRoutingSummaryIPVersionParamsSPF = "FAIL" +) + +type EmailRoutingSummaryIPVersionResponseEnvelope struct { + Result EmailRoutingSummaryIPVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailRoutingSummaryIPVersionResponseEnvelopeJSON `json:"-"` +} + +// emailRoutingSummaryIPVersionResponseEnvelopeJSON contains the JSON metadata for +// the struct [EmailRoutingSummaryIPVersionResponseEnvelope] +type emailRoutingSummaryIPVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummaryIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummaryIPVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingSummarySPFParams struct { + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailRoutingSummarySPFParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailRoutingSummarySPFParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailRoutingSummarySPFParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailRoutingSummarySPFParamsDMARC] `query:"dmarc"` + // Filter for encrypted emails. + Encrypted param.Field[[]EmailRoutingSummarySPFParamsEncrypted] `query:"encrypted"` + // Format results are returned in. + Format param.Field[EmailRoutingSummarySPFParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]EmailRoutingSummarySPFParamsIPVersion] `query:"ipVersion"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [EmailRoutingSummarySPFParams]'s query parameters as +// `url.Values`. +func (r EmailRoutingSummarySPFParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type EmailRoutingSummarySPFParamsARC string + +const ( + EmailRoutingSummarySPFParamsARCPass EmailRoutingSummarySPFParamsARC = "PASS" + EmailRoutingSummarySPFParamsARCNone EmailRoutingSummarySPFParamsARC = "NONE" + EmailRoutingSummarySPFParamsARCFail EmailRoutingSummarySPFParamsARC = "FAIL" +) + +type EmailRoutingSummarySPFParamsDateRange string + +const ( + EmailRoutingSummarySPFParamsDateRange1d EmailRoutingSummarySPFParamsDateRange = "1d" + EmailRoutingSummarySPFParamsDateRange2d EmailRoutingSummarySPFParamsDateRange = "2d" + EmailRoutingSummarySPFParamsDateRange7d EmailRoutingSummarySPFParamsDateRange = "7d" + EmailRoutingSummarySPFParamsDateRange14d EmailRoutingSummarySPFParamsDateRange = "14d" + EmailRoutingSummarySPFParamsDateRange28d EmailRoutingSummarySPFParamsDateRange = "28d" + EmailRoutingSummarySPFParamsDateRange12w EmailRoutingSummarySPFParamsDateRange = "12w" + EmailRoutingSummarySPFParamsDateRange24w EmailRoutingSummarySPFParamsDateRange = "24w" + EmailRoutingSummarySPFParamsDateRange52w EmailRoutingSummarySPFParamsDateRange = "52w" + EmailRoutingSummarySPFParamsDateRange1dControl EmailRoutingSummarySPFParamsDateRange = "1dControl" + EmailRoutingSummarySPFParamsDateRange2dControl EmailRoutingSummarySPFParamsDateRange = "2dControl" + EmailRoutingSummarySPFParamsDateRange7dControl EmailRoutingSummarySPFParamsDateRange = "7dControl" + EmailRoutingSummarySPFParamsDateRange14dControl EmailRoutingSummarySPFParamsDateRange = "14dControl" + EmailRoutingSummarySPFParamsDateRange28dControl EmailRoutingSummarySPFParamsDateRange = "28dControl" + EmailRoutingSummarySPFParamsDateRange12wControl EmailRoutingSummarySPFParamsDateRange = "12wControl" + EmailRoutingSummarySPFParamsDateRange24wControl EmailRoutingSummarySPFParamsDateRange = "24wControl" +) + +type EmailRoutingSummarySPFParamsDKIM string + +const ( + EmailRoutingSummarySPFParamsDKIMPass EmailRoutingSummarySPFParamsDKIM = "PASS" + EmailRoutingSummarySPFParamsDKIMNone EmailRoutingSummarySPFParamsDKIM = "NONE" + EmailRoutingSummarySPFParamsDKIMFail EmailRoutingSummarySPFParamsDKIM = "FAIL" +) + +type EmailRoutingSummarySPFParamsDMARC string + +const ( + EmailRoutingSummarySPFParamsDMARCPass EmailRoutingSummarySPFParamsDMARC = "PASS" + EmailRoutingSummarySPFParamsDMARCNone EmailRoutingSummarySPFParamsDMARC = "NONE" + EmailRoutingSummarySPFParamsDMARCFail EmailRoutingSummarySPFParamsDMARC = "FAIL" +) + +type EmailRoutingSummarySPFParamsEncrypted string + +const ( + EmailRoutingSummarySPFParamsEncryptedEncrypted EmailRoutingSummarySPFParamsEncrypted = "ENCRYPTED" + EmailRoutingSummarySPFParamsEncryptedNotEncrypted EmailRoutingSummarySPFParamsEncrypted = "NOT_ENCRYPTED" +) + +// Format results are returned in. +type EmailRoutingSummarySPFParamsFormat string + +const ( + EmailRoutingSummarySPFParamsFormatJson EmailRoutingSummarySPFParamsFormat = "JSON" + EmailRoutingSummarySPFParamsFormatCsv EmailRoutingSummarySPFParamsFormat = "CSV" +) + +type EmailRoutingSummarySPFParamsIPVersion string + +const ( + EmailRoutingSummarySPFParamsIPVersionIPv4 EmailRoutingSummarySPFParamsIPVersion = "IPv4" + EmailRoutingSummarySPFParamsIPVersionIPv6 EmailRoutingSummarySPFParamsIPVersion = "IPv6" +) + +type EmailRoutingSummarySPFResponseEnvelope struct { + Result EmailRoutingSummarySPFResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailRoutingSummarySPFResponseEnvelopeJSON `json:"-"` +} + +// emailRoutingSummarySPFResponseEnvelopeJSON contains the JSON metadata for the +// struct [EmailRoutingSummarySPFResponseEnvelope] +type emailRoutingSummarySPFResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingSummarySPFResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingSummarySPFResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/emailroutingsummary_test.go b/radar/emailroutingsummary_test.go new file mode 100644 index 00000000000..2cf82c1200d --- /dev/null +++ b/radar/emailroutingsummary_test.go @@ -0,0 +1,226 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestEmailRoutingSummaryARCWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Routing.Summary.ARC(context.TODO(), radar.EmailRoutingSummaryARCParams{ + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailRoutingSummaryARCParamsDateRange{radar.EmailRoutingSummaryARCParamsDateRange1d, radar.EmailRoutingSummaryARCParamsDateRange2d, radar.EmailRoutingSummaryARCParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailRoutingSummaryARCParamsDKIM{radar.EmailRoutingSummaryARCParamsDKIMPass, radar.EmailRoutingSummaryARCParamsDKIMNone, radar.EmailRoutingSummaryARCParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailRoutingSummaryARCParamsDMARC{radar.EmailRoutingSummaryARCParamsDMARCPass, radar.EmailRoutingSummaryARCParamsDMARCNone, radar.EmailRoutingSummaryARCParamsDMARCFail}), + Encrypted: cloudflare.F([]radar.EmailRoutingSummaryARCParamsEncrypted{radar.EmailRoutingSummaryARCParamsEncryptedEncrypted, radar.EmailRoutingSummaryARCParamsEncryptedNotEncrypted}), + Format: cloudflare.F(radar.EmailRoutingSummaryARCParamsFormatJson), + IPVersion: cloudflare.F([]radar.EmailRoutingSummaryARCParamsIPVersion{radar.EmailRoutingSummaryARCParamsIPVersionIPv4, radar.EmailRoutingSummaryARCParamsIPVersionIPv6}), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailRoutingSummaryARCParamsSPF{radar.EmailRoutingSummaryARCParamsSPFPass, radar.EmailRoutingSummaryARCParamsSPFNone, radar.EmailRoutingSummaryARCParamsSPFFail}), + }) + 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 TestEmailRoutingSummaryDKIMWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Routing.Summary.DKIM(context.TODO(), radar.EmailRoutingSummaryDKIMParams{ + ARC: cloudflare.F([]radar.EmailRoutingSummaryDKIMParamsARC{radar.EmailRoutingSummaryDKIMParamsARCPass, radar.EmailRoutingSummaryDKIMParamsARCNone, radar.EmailRoutingSummaryDKIMParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailRoutingSummaryDKIMParamsDateRange{radar.EmailRoutingSummaryDKIMParamsDateRange1d, radar.EmailRoutingSummaryDKIMParamsDateRange2d, radar.EmailRoutingSummaryDKIMParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DMARC: cloudflare.F([]radar.EmailRoutingSummaryDKIMParamsDMARC{radar.EmailRoutingSummaryDKIMParamsDMARCPass, radar.EmailRoutingSummaryDKIMParamsDMARCNone, radar.EmailRoutingSummaryDKIMParamsDMARCFail}), + Encrypted: cloudflare.F([]radar.EmailRoutingSummaryDKIMParamsEncrypted{radar.EmailRoutingSummaryDKIMParamsEncryptedEncrypted, radar.EmailRoutingSummaryDKIMParamsEncryptedNotEncrypted}), + Format: cloudflare.F(radar.EmailRoutingSummaryDKIMParamsFormatJson), + IPVersion: cloudflare.F([]radar.EmailRoutingSummaryDKIMParamsIPVersion{radar.EmailRoutingSummaryDKIMParamsIPVersionIPv4, radar.EmailRoutingSummaryDKIMParamsIPVersionIPv6}), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailRoutingSummaryDKIMParamsSPF{radar.EmailRoutingSummaryDKIMParamsSPFPass, radar.EmailRoutingSummaryDKIMParamsSPFNone, radar.EmailRoutingSummaryDKIMParamsSPFFail}), + }) + 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 TestEmailRoutingSummaryDMARCWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Routing.Summary.DMARC(context.TODO(), radar.EmailRoutingSummaryDMARCParams{ + ARC: cloudflare.F([]radar.EmailRoutingSummaryDMARCParamsARC{radar.EmailRoutingSummaryDMARCParamsARCPass, radar.EmailRoutingSummaryDMARCParamsARCNone, radar.EmailRoutingSummaryDMARCParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailRoutingSummaryDMARCParamsDateRange{radar.EmailRoutingSummaryDMARCParamsDateRange1d, radar.EmailRoutingSummaryDMARCParamsDateRange2d, radar.EmailRoutingSummaryDMARCParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailRoutingSummaryDMARCParamsDKIM{radar.EmailRoutingSummaryDMARCParamsDKIMPass, radar.EmailRoutingSummaryDMARCParamsDKIMNone, radar.EmailRoutingSummaryDMARCParamsDKIMFail}), + Encrypted: cloudflare.F([]radar.EmailRoutingSummaryDMARCParamsEncrypted{radar.EmailRoutingSummaryDMARCParamsEncryptedEncrypted, radar.EmailRoutingSummaryDMARCParamsEncryptedNotEncrypted}), + Format: cloudflare.F(radar.EmailRoutingSummaryDMARCParamsFormatJson), + IPVersion: cloudflare.F([]radar.EmailRoutingSummaryDMARCParamsIPVersion{radar.EmailRoutingSummaryDMARCParamsIPVersionIPv4, radar.EmailRoutingSummaryDMARCParamsIPVersionIPv6}), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailRoutingSummaryDMARCParamsSPF{radar.EmailRoutingSummaryDMARCParamsSPFPass, radar.EmailRoutingSummaryDMARCParamsSPFNone, radar.EmailRoutingSummaryDMARCParamsSPFFail}), + }) + 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 TestEmailRoutingSummaryEncryptedWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Routing.Summary.Encrypted(context.TODO(), radar.EmailRoutingSummaryEncryptedParams{ + ARC: cloudflare.F([]radar.EmailRoutingSummaryEncryptedParamsARC{radar.EmailRoutingSummaryEncryptedParamsARCPass, radar.EmailRoutingSummaryEncryptedParamsARCNone, radar.EmailRoutingSummaryEncryptedParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailRoutingSummaryEncryptedParamsDateRange{radar.EmailRoutingSummaryEncryptedParamsDateRange1d, radar.EmailRoutingSummaryEncryptedParamsDateRange2d, radar.EmailRoutingSummaryEncryptedParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailRoutingSummaryEncryptedParamsDKIM{radar.EmailRoutingSummaryEncryptedParamsDKIMPass, radar.EmailRoutingSummaryEncryptedParamsDKIMNone, radar.EmailRoutingSummaryEncryptedParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailRoutingSummaryEncryptedParamsDMARC{radar.EmailRoutingSummaryEncryptedParamsDMARCPass, radar.EmailRoutingSummaryEncryptedParamsDMARCNone, radar.EmailRoutingSummaryEncryptedParamsDMARCFail}), + Format: cloudflare.F(radar.EmailRoutingSummaryEncryptedParamsFormatJson), + IPVersion: cloudflare.F([]radar.EmailRoutingSummaryEncryptedParamsIPVersion{radar.EmailRoutingSummaryEncryptedParamsIPVersionIPv4, radar.EmailRoutingSummaryEncryptedParamsIPVersionIPv6}), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailRoutingSummaryEncryptedParamsSPF{radar.EmailRoutingSummaryEncryptedParamsSPFPass, radar.EmailRoutingSummaryEncryptedParamsSPFNone, radar.EmailRoutingSummaryEncryptedParamsSPFFail}), + }) + 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 TestEmailRoutingSummaryIPVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Routing.Summary.IPVersion(context.TODO(), radar.EmailRoutingSummaryIPVersionParams{ + ARC: cloudflare.F([]radar.EmailRoutingSummaryIPVersionParamsARC{radar.EmailRoutingSummaryIPVersionParamsARCPass, radar.EmailRoutingSummaryIPVersionParamsARCNone, radar.EmailRoutingSummaryIPVersionParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailRoutingSummaryIPVersionParamsDateRange{radar.EmailRoutingSummaryIPVersionParamsDateRange1d, radar.EmailRoutingSummaryIPVersionParamsDateRange2d, radar.EmailRoutingSummaryIPVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailRoutingSummaryIPVersionParamsDKIM{radar.EmailRoutingSummaryIPVersionParamsDKIMPass, radar.EmailRoutingSummaryIPVersionParamsDKIMNone, radar.EmailRoutingSummaryIPVersionParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailRoutingSummaryIPVersionParamsDMARC{radar.EmailRoutingSummaryIPVersionParamsDMARCPass, radar.EmailRoutingSummaryIPVersionParamsDMARCNone, radar.EmailRoutingSummaryIPVersionParamsDMARCFail}), + Encrypted: cloudflare.F([]radar.EmailRoutingSummaryIPVersionParamsEncrypted{radar.EmailRoutingSummaryIPVersionParamsEncryptedEncrypted, radar.EmailRoutingSummaryIPVersionParamsEncryptedNotEncrypted}), + Format: cloudflare.F(radar.EmailRoutingSummaryIPVersionParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailRoutingSummaryIPVersionParamsSPF{radar.EmailRoutingSummaryIPVersionParamsSPFPass, radar.EmailRoutingSummaryIPVersionParamsSPFNone, radar.EmailRoutingSummaryIPVersionParamsSPFFail}), + }) + 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 TestEmailRoutingSummarySPFWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Routing.Summary.SPF(context.TODO(), radar.EmailRoutingSummarySPFParams{ + ARC: cloudflare.F([]radar.EmailRoutingSummarySPFParamsARC{radar.EmailRoutingSummarySPFParamsARCPass, radar.EmailRoutingSummarySPFParamsARCNone, radar.EmailRoutingSummarySPFParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailRoutingSummarySPFParamsDateRange{radar.EmailRoutingSummarySPFParamsDateRange1d, radar.EmailRoutingSummarySPFParamsDateRange2d, radar.EmailRoutingSummarySPFParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailRoutingSummarySPFParamsDKIM{radar.EmailRoutingSummarySPFParamsDKIMPass, radar.EmailRoutingSummarySPFParamsDKIMNone, radar.EmailRoutingSummarySPFParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailRoutingSummarySPFParamsDMARC{radar.EmailRoutingSummarySPFParamsDMARCPass, radar.EmailRoutingSummarySPFParamsDMARCNone, radar.EmailRoutingSummarySPFParamsDMARCFail}), + Encrypted: cloudflare.F([]radar.EmailRoutingSummarySPFParamsEncrypted{radar.EmailRoutingSummarySPFParamsEncryptedEncrypted, radar.EmailRoutingSummarySPFParamsEncryptedNotEncrypted}), + Format: cloudflare.F(radar.EmailRoutingSummarySPFParamsFormatJson), + IPVersion: cloudflare.F([]radar.EmailRoutingSummarySPFParamsIPVersion{radar.EmailRoutingSummarySPFParamsIPVersionIPv4, radar.EmailRoutingSummarySPFParamsIPVersionIPv6}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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/radar/emailroutingtimeseriesgroup.go b/radar/emailroutingtimeseriesgroup.go new file mode 100644 index 00000000000..61c850796eb --- /dev/null +++ b/radar/emailroutingtimeseriesgroup.go @@ -0,0 +1,1232 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// EmailRoutingTimeseriesGroupService 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 +// [NewEmailRoutingTimeseriesGroupService] method instead. +type EmailRoutingTimeseriesGroupService struct { + Options []option.RequestOption +} + +// NewEmailRoutingTimeseriesGroupService 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 NewEmailRoutingTimeseriesGroupService(opts ...option.RequestOption) (r *EmailRoutingTimeseriesGroupService) { + r = &EmailRoutingTimeseriesGroupService{} + r.Options = opts + return +} + +// Percentage distribution of emails classified per Arc validation over time. +func (r *EmailRoutingTimeseriesGroupService) ARC(ctx context.Context, query EmailRoutingTimeseriesGroupARCParams, opts ...option.RequestOption) (res *EmailRoutingTimeseriesGroupARCResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailRoutingTimeseriesGroupARCResponseEnvelope + path := "radar/email/routing/timeseries_groups/arc" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified per DKIM validation over time. +func (r *EmailRoutingTimeseriesGroupService) DKIM(ctx context.Context, query EmailRoutingTimeseriesGroupDKIMParams, opts ...option.RequestOption) (res *EmailRoutingTimeseriesGroupDKIMResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailRoutingTimeseriesGroupDKIMResponseEnvelope + path := "radar/email/routing/timeseries_groups/dkim" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified per DMARC validation over time. +func (r *EmailRoutingTimeseriesGroupService) DMARC(ctx context.Context, query EmailRoutingTimeseriesGroupDMARCParams, opts ...option.RequestOption) (res *EmailRoutingTimeseriesGroupDMARCResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailRoutingTimeseriesGroupDMARCResponseEnvelope + path := "radar/email/routing/timeseries_groups/dmarc" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails by Encrypted over time. +func (r *EmailRoutingTimeseriesGroupService) Encrypted(ctx context.Context, query EmailRoutingTimeseriesGroupEncryptedParams, opts ...option.RequestOption) (res *EmailRoutingTimeseriesGroupEncryptedResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailRoutingTimeseriesGroupEncryptedResponseEnvelope + path := "radar/email/routing/timeseries_groups/encrypted" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails by Ip Version over time. +func (r *EmailRoutingTimeseriesGroupService) IPVersion(ctx context.Context, query EmailRoutingTimeseriesGroupIPVersionParams, opts ...option.RequestOption) (res *EmailRoutingTimeseriesGroupIPVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailRoutingTimeseriesGroupIPVersionResponseEnvelope + path := "radar/email/routing/timeseries_groups/ip_version" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified per SPF validation over time. +func (r *EmailRoutingTimeseriesGroupService) SPF(ctx context.Context, query EmailRoutingTimeseriesGroupSPFParams, opts ...option.RequestOption) (res *EmailRoutingTimeseriesGroupSPFResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailRoutingTimeseriesGroupSPFResponseEnvelope + path := "radar/email/routing/timeseries_groups/spf" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type EmailRoutingTimeseriesGroupARCResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 EmailRoutingTimeseriesGroupARCResponseSerie0 `json:"serie_0,required"` + JSON emailRoutingTimeseriesGroupARCResponseJSON `json:"-"` +} + +// emailRoutingTimeseriesGroupARCResponseJSON contains the JSON metadata for the +// struct [EmailRoutingTimeseriesGroupARCResponse] +type emailRoutingTimeseriesGroupARCResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingTimeseriesGroupARCResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingTimeseriesGroupARCResponseJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingTimeseriesGroupARCResponseSerie0 struct { + Fail []string `json:"FAIL,required"` + None []string `json:"NONE,required"` + Pass []string `json:"PASS,required"` + JSON emailRoutingTimeseriesGroupARCResponseSerie0JSON `json:"-"` +} + +// emailRoutingTimeseriesGroupARCResponseSerie0JSON contains the JSON metadata for +// the struct [EmailRoutingTimeseriesGroupARCResponseSerie0] +type emailRoutingTimeseriesGroupARCResponseSerie0JSON struct { + Fail apijson.Field + None apijson.Field + Pass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingTimeseriesGroupARCResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingTimeseriesGroupARCResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type EmailRoutingTimeseriesGroupDKIMResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 EmailRoutingTimeseriesGroupDKIMResponseSerie0 `json:"serie_0,required"` + JSON emailRoutingTimeseriesGroupDKIMResponseJSON `json:"-"` +} + +// emailRoutingTimeseriesGroupDKIMResponseJSON contains the JSON metadata for the +// struct [EmailRoutingTimeseriesGroupDKIMResponse] +type emailRoutingTimeseriesGroupDKIMResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingTimeseriesGroupDKIMResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingTimeseriesGroupDKIMResponseJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingTimeseriesGroupDKIMResponseSerie0 struct { + Fail []string `json:"FAIL,required"` + None []string `json:"NONE,required"` + Pass []string `json:"PASS,required"` + JSON emailRoutingTimeseriesGroupDKIMResponseSerie0JSON `json:"-"` +} + +// emailRoutingTimeseriesGroupDKIMResponseSerie0JSON contains the JSON metadata for +// the struct [EmailRoutingTimeseriesGroupDKIMResponseSerie0] +type emailRoutingTimeseriesGroupDKIMResponseSerie0JSON struct { + Fail apijson.Field + None apijson.Field + Pass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingTimeseriesGroupDKIMResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingTimeseriesGroupDKIMResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type EmailRoutingTimeseriesGroupDMARCResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 EmailRoutingTimeseriesGroupDMARCResponseSerie0 `json:"serie_0,required"` + JSON emailRoutingTimeseriesGroupDMARCResponseJSON `json:"-"` +} + +// emailRoutingTimeseriesGroupDMARCResponseJSON contains the JSON metadata for the +// struct [EmailRoutingTimeseriesGroupDMARCResponse] +type emailRoutingTimeseriesGroupDMARCResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingTimeseriesGroupDMARCResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingTimeseriesGroupDMARCResponseJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingTimeseriesGroupDMARCResponseSerie0 struct { + Fail []string `json:"FAIL,required"` + None []string `json:"NONE,required"` + Pass []string `json:"PASS,required"` + JSON emailRoutingTimeseriesGroupDMARCResponseSerie0JSON `json:"-"` +} + +// emailRoutingTimeseriesGroupDMARCResponseSerie0JSON contains the JSON metadata +// for the struct [EmailRoutingTimeseriesGroupDMARCResponseSerie0] +type emailRoutingTimeseriesGroupDMARCResponseSerie0JSON struct { + Fail apijson.Field + None apijson.Field + Pass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingTimeseriesGroupDMARCResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingTimeseriesGroupDMARCResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type EmailRoutingTimeseriesGroupEncryptedResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 EmailRoutingTimeseriesGroupEncryptedResponseSerie0 `json:"serie_0,required"` + JSON emailRoutingTimeseriesGroupEncryptedResponseJSON `json:"-"` +} + +// emailRoutingTimeseriesGroupEncryptedResponseJSON contains the JSON metadata for +// the struct [EmailRoutingTimeseriesGroupEncryptedResponse] +type emailRoutingTimeseriesGroupEncryptedResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingTimeseriesGroupEncryptedResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingTimeseriesGroupEncryptedResponseJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingTimeseriesGroupEncryptedResponseSerie0 struct { + Encrypted []string `json:"ENCRYPTED,required"` + NotEncrypted []string `json:"NOT_ENCRYPTED,required"` + JSON emailRoutingTimeseriesGroupEncryptedResponseSerie0JSON `json:"-"` +} + +// emailRoutingTimeseriesGroupEncryptedResponseSerie0JSON contains the JSON +// metadata for the struct [EmailRoutingTimeseriesGroupEncryptedResponseSerie0] +type emailRoutingTimeseriesGroupEncryptedResponseSerie0JSON struct { + Encrypted apijson.Field + NotEncrypted apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingTimeseriesGroupEncryptedResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingTimeseriesGroupEncryptedResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type EmailRoutingTimeseriesGroupIPVersionResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 EmailRoutingTimeseriesGroupIPVersionResponseSerie0 `json:"serie_0,required"` + JSON emailRoutingTimeseriesGroupIPVersionResponseJSON `json:"-"` +} + +// emailRoutingTimeseriesGroupIPVersionResponseJSON contains the JSON metadata for +// the struct [EmailRoutingTimeseriesGroupIPVersionResponse] +type emailRoutingTimeseriesGroupIPVersionResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingTimeseriesGroupIPVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingTimeseriesGroupIPVersionResponseJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingTimeseriesGroupIPVersionResponseSerie0 struct { + IPv4 []string `json:"IPv4,required"` + IPv6 []string `json:"IPv6,required"` + JSON emailRoutingTimeseriesGroupIPVersionResponseSerie0JSON `json:"-"` +} + +// emailRoutingTimeseriesGroupIPVersionResponseSerie0JSON contains the JSON +// metadata for the struct [EmailRoutingTimeseriesGroupIPVersionResponseSerie0] +type emailRoutingTimeseriesGroupIPVersionResponseSerie0JSON struct { + IPv4 apijson.Field + IPv6 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingTimeseriesGroupIPVersionResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingTimeseriesGroupIPVersionResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type EmailRoutingTimeseriesGroupSPFResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 EmailRoutingTimeseriesGroupSPFResponseSerie0 `json:"serie_0,required"` + JSON emailRoutingTimeseriesGroupSPFResponseJSON `json:"-"` +} + +// emailRoutingTimeseriesGroupSPFResponseJSON contains the JSON metadata for the +// struct [EmailRoutingTimeseriesGroupSPFResponse] +type emailRoutingTimeseriesGroupSPFResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingTimeseriesGroupSPFResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingTimeseriesGroupSPFResponseJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingTimeseriesGroupSPFResponseSerie0 struct { + Fail []string `json:"FAIL,required"` + None []string `json:"NONE,required"` + Pass []string `json:"PASS,required"` + JSON emailRoutingTimeseriesGroupSPFResponseSerie0JSON `json:"-"` +} + +// emailRoutingTimeseriesGroupSPFResponseSerie0JSON contains the JSON metadata for +// the struct [EmailRoutingTimeseriesGroupSPFResponseSerie0] +type emailRoutingTimeseriesGroupSPFResponseSerie0JSON struct { + Fail apijson.Field + None apijson.Field + Pass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingTimeseriesGroupSPFResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingTimeseriesGroupSPFResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type EmailRoutingTimeseriesGroupARCParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[EmailRoutingTimeseriesGroupARCParamsAggInterval] `query:"aggInterval"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailRoutingTimeseriesGroupARCParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailRoutingTimeseriesGroupARCParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailRoutingTimeseriesGroupARCParamsDMARC] `query:"dmarc"` + // Filter for encrypted emails. + Encrypted param.Field[[]EmailRoutingTimeseriesGroupARCParamsEncrypted] `query:"encrypted"` + // Format results are returned in. + Format param.Field[EmailRoutingTimeseriesGroupARCParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]EmailRoutingTimeseriesGroupARCParamsIPVersion] `query:"ipVersion"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailRoutingTimeseriesGroupARCParamsSPF] `query:"spf"` +} + +// URLQuery serializes [EmailRoutingTimeseriesGroupARCParams]'s query parameters as +// `url.Values`. +func (r EmailRoutingTimeseriesGroupARCParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type EmailRoutingTimeseriesGroupARCParamsAggInterval string + +const ( + EmailRoutingTimeseriesGroupARCParamsAggInterval15m EmailRoutingTimeseriesGroupARCParamsAggInterval = "15m" + EmailRoutingTimeseriesGroupARCParamsAggInterval1h EmailRoutingTimeseriesGroupARCParamsAggInterval = "1h" + EmailRoutingTimeseriesGroupARCParamsAggInterval1d EmailRoutingTimeseriesGroupARCParamsAggInterval = "1d" + EmailRoutingTimeseriesGroupARCParamsAggInterval1w EmailRoutingTimeseriesGroupARCParamsAggInterval = "1w" +) + +type EmailRoutingTimeseriesGroupARCParamsDateRange string + +const ( + EmailRoutingTimeseriesGroupARCParamsDateRange1d EmailRoutingTimeseriesGroupARCParamsDateRange = "1d" + EmailRoutingTimeseriesGroupARCParamsDateRange2d EmailRoutingTimeseriesGroupARCParamsDateRange = "2d" + EmailRoutingTimeseriesGroupARCParamsDateRange7d EmailRoutingTimeseriesGroupARCParamsDateRange = "7d" + EmailRoutingTimeseriesGroupARCParamsDateRange14d EmailRoutingTimeseriesGroupARCParamsDateRange = "14d" + EmailRoutingTimeseriesGroupARCParamsDateRange28d EmailRoutingTimeseriesGroupARCParamsDateRange = "28d" + EmailRoutingTimeseriesGroupARCParamsDateRange12w EmailRoutingTimeseriesGroupARCParamsDateRange = "12w" + EmailRoutingTimeseriesGroupARCParamsDateRange24w EmailRoutingTimeseriesGroupARCParamsDateRange = "24w" + EmailRoutingTimeseriesGroupARCParamsDateRange52w EmailRoutingTimeseriesGroupARCParamsDateRange = "52w" + EmailRoutingTimeseriesGroupARCParamsDateRange1dControl EmailRoutingTimeseriesGroupARCParamsDateRange = "1dControl" + EmailRoutingTimeseriesGroupARCParamsDateRange2dControl EmailRoutingTimeseriesGroupARCParamsDateRange = "2dControl" + EmailRoutingTimeseriesGroupARCParamsDateRange7dControl EmailRoutingTimeseriesGroupARCParamsDateRange = "7dControl" + EmailRoutingTimeseriesGroupARCParamsDateRange14dControl EmailRoutingTimeseriesGroupARCParamsDateRange = "14dControl" + EmailRoutingTimeseriesGroupARCParamsDateRange28dControl EmailRoutingTimeseriesGroupARCParamsDateRange = "28dControl" + EmailRoutingTimeseriesGroupARCParamsDateRange12wControl EmailRoutingTimeseriesGroupARCParamsDateRange = "12wControl" + EmailRoutingTimeseriesGroupARCParamsDateRange24wControl EmailRoutingTimeseriesGroupARCParamsDateRange = "24wControl" +) + +type EmailRoutingTimeseriesGroupARCParamsDKIM string + +const ( + EmailRoutingTimeseriesGroupARCParamsDKIMPass EmailRoutingTimeseriesGroupARCParamsDKIM = "PASS" + EmailRoutingTimeseriesGroupARCParamsDKIMNone EmailRoutingTimeseriesGroupARCParamsDKIM = "NONE" + EmailRoutingTimeseriesGroupARCParamsDKIMFail EmailRoutingTimeseriesGroupARCParamsDKIM = "FAIL" +) + +type EmailRoutingTimeseriesGroupARCParamsDMARC string + +const ( + EmailRoutingTimeseriesGroupARCParamsDMARCPass EmailRoutingTimeseriesGroupARCParamsDMARC = "PASS" + EmailRoutingTimeseriesGroupARCParamsDMARCNone EmailRoutingTimeseriesGroupARCParamsDMARC = "NONE" + EmailRoutingTimeseriesGroupARCParamsDMARCFail EmailRoutingTimeseriesGroupARCParamsDMARC = "FAIL" +) + +type EmailRoutingTimeseriesGroupARCParamsEncrypted string + +const ( + EmailRoutingTimeseriesGroupARCParamsEncryptedEncrypted EmailRoutingTimeseriesGroupARCParamsEncrypted = "ENCRYPTED" + EmailRoutingTimeseriesGroupARCParamsEncryptedNotEncrypted EmailRoutingTimeseriesGroupARCParamsEncrypted = "NOT_ENCRYPTED" +) + +// Format results are returned in. +type EmailRoutingTimeseriesGroupARCParamsFormat string + +const ( + EmailRoutingTimeseriesGroupARCParamsFormatJson EmailRoutingTimeseriesGroupARCParamsFormat = "JSON" + EmailRoutingTimeseriesGroupARCParamsFormatCsv EmailRoutingTimeseriesGroupARCParamsFormat = "CSV" +) + +type EmailRoutingTimeseriesGroupARCParamsIPVersion string + +const ( + EmailRoutingTimeseriesGroupARCParamsIPVersionIPv4 EmailRoutingTimeseriesGroupARCParamsIPVersion = "IPv4" + EmailRoutingTimeseriesGroupARCParamsIPVersionIPv6 EmailRoutingTimeseriesGroupARCParamsIPVersion = "IPv6" +) + +type EmailRoutingTimeseriesGroupARCParamsSPF string + +const ( + EmailRoutingTimeseriesGroupARCParamsSPFPass EmailRoutingTimeseriesGroupARCParamsSPF = "PASS" + EmailRoutingTimeseriesGroupARCParamsSPFNone EmailRoutingTimeseriesGroupARCParamsSPF = "NONE" + EmailRoutingTimeseriesGroupARCParamsSPFFail EmailRoutingTimeseriesGroupARCParamsSPF = "FAIL" +) + +type EmailRoutingTimeseriesGroupARCResponseEnvelope struct { + Result EmailRoutingTimeseriesGroupARCResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailRoutingTimeseriesGroupARCResponseEnvelopeJSON `json:"-"` +} + +// emailRoutingTimeseriesGroupARCResponseEnvelopeJSON contains the JSON metadata +// for the struct [EmailRoutingTimeseriesGroupARCResponseEnvelope] +type emailRoutingTimeseriesGroupARCResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingTimeseriesGroupARCResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingTimeseriesGroupARCResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingTimeseriesGroupDKIMParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[EmailRoutingTimeseriesGroupDKIMParamsAggInterval] `query:"aggInterval"` + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailRoutingTimeseriesGroupDKIMParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailRoutingTimeseriesGroupDKIMParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dmarc. + DMARC param.Field[[]EmailRoutingTimeseriesGroupDKIMParamsDMARC] `query:"dmarc"` + // Filter for encrypted emails. + Encrypted param.Field[[]EmailRoutingTimeseriesGroupDKIMParamsEncrypted] `query:"encrypted"` + // Format results are returned in. + Format param.Field[EmailRoutingTimeseriesGroupDKIMParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]EmailRoutingTimeseriesGroupDKIMParamsIPVersion] `query:"ipVersion"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailRoutingTimeseriesGroupDKIMParamsSPF] `query:"spf"` +} + +// URLQuery serializes [EmailRoutingTimeseriesGroupDKIMParams]'s query parameters +// as `url.Values`. +func (r EmailRoutingTimeseriesGroupDKIMParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type EmailRoutingTimeseriesGroupDKIMParamsAggInterval string + +const ( + EmailRoutingTimeseriesGroupDKIMParamsAggInterval15m EmailRoutingTimeseriesGroupDKIMParamsAggInterval = "15m" + EmailRoutingTimeseriesGroupDKIMParamsAggInterval1h EmailRoutingTimeseriesGroupDKIMParamsAggInterval = "1h" + EmailRoutingTimeseriesGroupDKIMParamsAggInterval1d EmailRoutingTimeseriesGroupDKIMParamsAggInterval = "1d" + EmailRoutingTimeseriesGroupDKIMParamsAggInterval1w EmailRoutingTimeseriesGroupDKIMParamsAggInterval = "1w" +) + +type EmailRoutingTimeseriesGroupDKIMParamsARC string + +const ( + EmailRoutingTimeseriesGroupDKIMParamsARCPass EmailRoutingTimeseriesGroupDKIMParamsARC = "PASS" + EmailRoutingTimeseriesGroupDKIMParamsARCNone EmailRoutingTimeseriesGroupDKIMParamsARC = "NONE" + EmailRoutingTimeseriesGroupDKIMParamsARCFail EmailRoutingTimeseriesGroupDKIMParamsARC = "FAIL" +) + +type EmailRoutingTimeseriesGroupDKIMParamsDateRange string + +const ( + EmailRoutingTimeseriesGroupDKIMParamsDateRange1d EmailRoutingTimeseriesGroupDKIMParamsDateRange = "1d" + EmailRoutingTimeseriesGroupDKIMParamsDateRange2d EmailRoutingTimeseriesGroupDKIMParamsDateRange = "2d" + EmailRoutingTimeseriesGroupDKIMParamsDateRange7d EmailRoutingTimeseriesGroupDKIMParamsDateRange = "7d" + EmailRoutingTimeseriesGroupDKIMParamsDateRange14d EmailRoutingTimeseriesGroupDKIMParamsDateRange = "14d" + EmailRoutingTimeseriesGroupDKIMParamsDateRange28d EmailRoutingTimeseriesGroupDKIMParamsDateRange = "28d" + EmailRoutingTimeseriesGroupDKIMParamsDateRange12w EmailRoutingTimeseriesGroupDKIMParamsDateRange = "12w" + EmailRoutingTimeseriesGroupDKIMParamsDateRange24w EmailRoutingTimeseriesGroupDKIMParamsDateRange = "24w" + EmailRoutingTimeseriesGroupDKIMParamsDateRange52w EmailRoutingTimeseriesGroupDKIMParamsDateRange = "52w" + EmailRoutingTimeseriesGroupDKIMParamsDateRange1dControl EmailRoutingTimeseriesGroupDKIMParamsDateRange = "1dControl" + EmailRoutingTimeseriesGroupDKIMParamsDateRange2dControl EmailRoutingTimeseriesGroupDKIMParamsDateRange = "2dControl" + EmailRoutingTimeseriesGroupDKIMParamsDateRange7dControl EmailRoutingTimeseriesGroupDKIMParamsDateRange = "7dControl" + EmailRoutingTimeseriesGroupDKIMParamsDateRange14dControl EmailRoutingTimeseriesGroupDKIMParamsDateRange = "14dControl" + EmailRoutingTimeseriesGroupDKIMParamsDateRange28dControl EmailRoutingTimeseriesGroupDKIMParamsDateRange = "28dControl" + EmailRoutingTimeseriesGroupDKIMParamsDateRange12wControl EmailRoutingTimeseriesGroupDKIMParamsDateRange = "12wControl" + EmailRoutingTimeseriesGroupDKIMParamsDateRange24wControl EmailRoutingTimeseriesGroupDKIMParamsDateRange = "24wControl" +) + +type EmailRoutingTimeseriesGroupDKIMParamsDMARC string + +const ( + EmailRoutingTimeseriesGroupDKIMParamsDMARCPass EmailRoutingTimeseriesGroupDKIMParamsDMARC = "PASS" + EmailRoutingTimeseriesGroupDKIMParamsDMARCNone EmailRoutingTimeseriesGroupDKIMParamsDMARC = "NONE" + EmailRoutingTimeseriesGroupDKIMParamsDMARCFail EmailRoutingTimeseriesGroupDKIMParamsDMARC = "FAIL" +) + +type EmailRoutingTimeseriesGroupDKIMParamsEncrypted string + +const ( + EmailRoutingTimeseriesGroupDKIMParamsEncryptedEncrypted EmailRoutingTimeseriesGroupDKIMParamsEncrypted = "ENCRYPTED" + EmailRoutingTimeseriesGroupDKIMParamsEncryptedNotEncrypted EmailRoutingTimeseriesGroupDKIMParamsEncrypted = "NOT_ENCRYPTED" +) + +// Format results are returned in. +type EmailRoutingTimeseriesGroupDKIMParamsFormat string + +const ( + EmailRoutingTimeseriesGroupDKIMParamsFormatJson EmailRoutingTimeseriesGroupDKIMParamsFormat = "JSON" + EmailRoutingTimeseriesGroupDKIMParamsFormatCsv EmailRoutingTimeseriesGroupDKIMParamsFormat = "CSV" +) + +type EmailRoutingTimeseriesGroupDKIMParamsIPVersion string + +const ( + EmailRoutingTimeseriesGroupDKIMParamsIPVersionIPv4 EmailRoutingTimeseriesGroupDKIMParamsIPVersion = "IPv4" + EmailRoutingTimeseriesGroupDKIMParamsIPVersionIPv6 EmailRoutingTimeseriesGroupDKIMParamsIPVersion = "IPv6" +) + +type EmailRoutingTimeseriesGroupDKIMParamsSPF string + +const ( + EmailRoutingTimeseriesGroupDKIMParamsSPFPass EmailRoutingTimeseriesGroupDKIMParamsSPF = "PASS" + EmailRoutingTimeseriesGroupDKIMParamsSPFNone EmailRoutingTimeseriesGroupDKIMParamsSPF = "NONE" + EmailRoutingTimeseriesGroupDKIMParamsSPFFail EmailRoutingTimeseriesGroupDKIMParamsSPF = "FAIL" +) + +type EmailRoutingTimeseriesGroupDKIMResponseEnvelope struct { + Result EmailRoutingTimeseriesGroupDKIMResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailRoutingTimeseriesGroupDKIMResponseEnvelopeJSON `json:"-"` +} + +// emailRoutingTimeseriesGroupDKIMResponseEnvelopeJSON contains the JSON metadata +// for the struct [EmailRoutingTimeseriesGroupDKIMResponseEnvelope] +type emailRoutingTimeseriesGroupDKIMResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingTimeseriesGroupDKIMResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingTimeseriesGroupDKIMResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingTimeseriesGroupDMARCParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[EmailRoutingTimeseriesGroupDMARCParamsAggInterval] `query:"aggInterval"` + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailRoutingTimeseriesGroupDMARCParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailRoutingTimeseriesGroupDMARCParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailRoutingTimeseriesGroupDMARCParamsDKIM] `query:"dkim"` + // Filter for encrypted emails. + Encrypted param.Field[[]EmailRoutingTimeseriesGroupDMARCParamsEncrypted] `query:"encrypted"` + // Format results are returned in. + Format param.Field[EmailRoutingTimeseriesGroupDMARCParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]EmailRoutingTimeseriesGroupDMARCParamsIPVersion] `query:"ipVersion"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailRoutingTimeseriesGroupDMARCParamsSPF] `query:"spf"` +} + +// URLQuery serializes [EmailRoutingTimeseriesGroupDMARCParams]'s query parameters +// as `url.Values`. +func (r EmailRoutingTimeseriesGroupDMARCParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type EmailRoutingTimeseriesGroupDMARCParamsAggInterval string + +const ( + EmailRoutingTimeseriesGroupDMARCParamsAggInterval15m EmailRoutingTimeseriesGroupDMARCParamsAggInterval = "15m" + EmailRoutingTimeseriesGroupDMARCParamsAggInterval1h EmailRoutingTimeseriesGroupDMARCParamsAggInterval = "1h" + EmailRoutingTimeseriesGroupDMARCParamsAggInterval1d EmailRoutingTimeseriesGroupDMARCParamsAggInterval = "1d" + EmailRoutingTimeseriesGroupDMARCParamsAggInterval1w EmailRoutingTimeseriesGroupDMARCParamsAggInterval = "1w" +) + +type EmailRoutingTimeseriesGroupDMARCParamsARC string + +const ( + EmailRoutingTimeseriesGroupDMARCParamsARCPass EmailRoutingTimeseriesGroupDMARCParamsARC = "PASS" + EmailRoutingTimeseriesGroupDMARCParamsARCNone EmailRoutingTimeseriesGroupDMARCParamsARC = "NONE" + EmailRoutingTimeseriesGroupDMARCParamsARCFail EmailRoutingTimeseriesGroupDMARCParamsARC = "FAIL" +) + +type EmailRoutingTimeseriesGroupDMARCParamsDateRange string + +const ( + EmailRoutingTimeseriesGroupDMARCParamsDateRange1d EmailRoutingTimeseriesGroupDMARCParamsDateRange = "1d" + EmailRoutingTimeseriesGroupDMARCParamsDateRange2d EmailRoutingTimeseriesGroupDMARCParamsDateRange = "2d" + EmailRoutingTimeseriesGroupDMARCParamsDateRange7d EmailRoutingTimeseriesGroupDMARCParamsDateRange = "7d" + EmailRoutingTimeseriesGroupDMARCParamsDateRange14d EmailRoutingTimeseriesGroupDMARCParamsDateRange = "14d" + EmailRoutingTimeseriesGroupDMARCParamsDateRange28d EmailRoutingTimeseriesGroupDMARCParamsDateRange = "28d" + EmailRoutingTimeseriesGroupDMARCParamsDateRange12w EmailRoutingTimeseriesGroupDMARCParamsDateRange = "12w" + EmailRoutingTimeseriesGroupDMARCParamsDateRange24w EmailRoutingTimeseriesGroupDMARCParamsDateRange = "24w" + EmailRoutingTimeseriesGroupDMARCParamsDateRange52w EmailRoutingTimeseriesGroupDMARCParamsDateRange = "52w" + EmailRoutingTimeseriesGroupDMARCParamsDateRange1dControl EmailRoutingTimeseriesGroupDMARCParamsDateRange = "1dControl" + EmailRoutingTimeseriesGroupDMARCParamsDateRange2dControl EmailRoutingTimeseriesGroupDMARCParamsDateRange = "2dControl" + EmailRoutingTimeseriesGroupDMARCParamsDateRange7dControl EmailRoutingTimeseriesGroupDMARCParamsDateRange = "7dControl" + EmailRoutingTimeseriesGroupDMARCParamsDateRange14dControl EmailRoutingTimeseriesGroupDMARCParamsDateRange = "14dControl" + EmailRoutingTimeseriesGroupDMARCParamsDateRange28dControl EmailRoutingTimeseriesGroupDMARCParamsDateRange = "28dControl" + EmailRoutingTimeseriesGroupDMARCParamsDateRange12wControl EmailRoutingTimeseriesGroupDMARCParamsDateRange = "12wControl" + EmailRoutingTimeseriesGroupDMARCParamsDateRange24wControl EmailRoutingTimeseriesGroupDMARCParamsDateRange = "24wControl" +) + +type EmailRoutingTimeseriesGroupDMARCParamsDKIM string + +const ( + EmailRoutingTimeseriesGroupDMARCParamsDKIMPass EmailRoutingTimeseriesGroupDMARCParamsDKIM = "PASS" + EmailRoutingTimeseriesGroupDMARCParamsDKIMNone EmailRoutingTimeseriesGroupDMARCParamsDKIM = "NONE" + EmailRoutingTimeseriesGroupDMARCParamsDKIMFail EmailRoutingTimeseriesGroupDMARCParamsDKIM = "FAIL" +) + +type EmailRoutingTimeseriesGroupDMARCParamsEncrypted string + +const ( + EmailRoutingTimeseriesGroupDMARCParamsEncryptedEncrypted EmailRoutingTimeseriesGroupDMARCParamsEncrypted = "ENCRYPTED" + EmailRoutingTimeseriesGroupDMARCParamsEncryptedNotEncrypted EmailRoutingTimeseriesGroupDMARCParamsEncrypted = "NOT_ENCRYPTED" +) + +// Format results are returned in. +type EmailRoutingTimeseriesGroupDMARCParamsFormat string + +const ( + EmailRoutingTimeseriesGroupDMARCParamsFormatJson EmailRoutingTimeseriesGroupDMARCParamsFormat = "JSON" + EmailRoutingTimeseriesGroupDMARCParamsFormatCsv EmailRoutingTimeseriesGroupDMARCParamsFormat = "CSV" +) + +type EmailRoutingTimeseriesGroupDMARCParamsIPVersion string + +const ( + EmailRoutingTimeseriesGroupDMARCParamsIPVersionIPv4 EmailRoutingTimeseriesGroupDMARCParamsIPVersion = "IPv4" + EmailRoutingTimeseriesGroupDMARCParamsIPVersionIPv6 EmailRoutingTimeseriesGroupDMARCParamsIPVersion = "IPv6" +) + +type EmailRoutingTimeseriesGroupDMARCParamsSPF string + +const ( + EmailRoutingTimeseriesGroupDMARCParamsSPFPass EmailRoutingTimeseriesGroupDMARCParamsSPF = "PASS" + EmailRoutingTimeseriesGroupDMARCParamsSPFNone EmailRoutingTimeseriesGroupDMARCParamsSPF = "NONE" + EmailRoutingTimeseriesGroupDMARCParamsSPFFail EmailRoutingTimeseriesGroupDMARCParamsSPF = "FAIL" +) + +type EmailRoutingTimeseriesGroupDMARCResponseEnvelope struct { + Result EmailRoutingTimeseriesGroupDMARCResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailRoutingTimeseriesGroupDMARCResponseEnvelopeJSON `json:"-"` +} + +// emailRoutingTimeseriesGroupDMARCResponseEnvelopeJSON contains the JSON metadata +// for the struct [EmailRoutingTimeseriesGroupDMARCResponseEnvelope] +type emailRoutingTimeseriesGroupDMARCResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingTimeseriesGroupDMARCResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingTimeseriesGroupDMARCResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingTimeseriesGroupEncryptedParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[EmailRoutingTimeseriesGroupEncryptedParamsAggInterval] `query:"aggInterval"` + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailRoutingTimeseriesGroupEncryptedParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailRoutingTimeseriesGroupEncryptedParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailRoutingTimeseriesGroupEncryptedParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailRoutingTimeseriesGroupEncryptedParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailRoutingTimeseriesGroupEncryptedParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]EmailRoutingTimeseriesGroupEncryptedParamsIPVersion] `query:"ipVersion"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailRoutingTimeseriesGroupEncryptedParamsSPF] `query:"spf"` +} + +// URLQuery serializes [EmailRoutingTimeseriesGroupEncryptedParams]'s query +// parameters as `url.Values`. +func (r EmailRoutingTimeseriesGroupEncryptedParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type EmailRoutingTimeseriesGroupEncryptedParamsAggInterval string + +const ( + EmailRoutingTimeseriesGroupEncryptedParamsAggInterval15m EmailRoutingTimeseriesGroupEncryptedParamsAggInterval = "15m" + EmailRoutingTimeseriesGroupEncryptedParamsAggInterval1h EmailRoutingTimeseriesGroupEncryptedParamsAggInterval = "1h" + EmailRoutingTimeseriesGroupEncryptedParamsAggInterval1d EmailRoutingTimeseriesGroupEncryptedParamsAggInterval = "1d" + EmailRoutingTimeseriesGroupEncryptedParamsAggInterval1w EmailRoutingTimeseriesGroupEncryptedParamsAggInterval = "1w" +) + +type EmailRoutingTimeseriesGroupEncryptedParamsARC string + +const ( + EmailRoutingTimeseriesGroupEncryptedParamsARCPass EmailRoutingTimeseriesGroupEncryptedParamsARC = "PASS" + EmailRoutingTimeseriesGroupEncryptedParamsARCNone EmailRoutingTimeseriesGroupEncryptedParamsARC = "NONE" + EmailRoutingTimeseriesGroupEncryptedParamsARCFail EmailRoutingTimeseriesGroupEncryptedParamsARC = "FAIL" +) + +type EmailRoutingTimeseriesGroupEncryptedParamsDateRange string + +const ( + EmailRoutingTimeseriesGroupEncryptedParamsDateRange1d EmailRoutingTimeseriesGroupEncryptedParamsDateRange = "1d" + EmailRoutingTimeseriesGroupEncryptedParamsDateRange2d EmailRoutingTimeseriesGroupEncryptedParamsDateRange = "2d" + EmailRoutingTimeseriesGroupEncryptedParamsDateRange7d EmailRoutingTimeseriesGroupEncryptedParamsDateRange = "7d" + EmailRoutingTimeseriesGroupEncryptedParamsDateRange14d EmailRoutingTimeseriesGroupEncryptedParamsDateRange = "14d" + EmailRoutingTimeseriesGroupEncryptedParamsDateRange28d EmailRoutingTimeseriesGroupEncryptedParamsDateRange = "28d" + EmailRoutingTimeseriesGroupEncryptedParamsDateRange12w EmailRoutingTimeseriesGroupEncryptedParamsDateRange = "12w" + EmailRoutingTimeseriesGroupEncryptedParamsDateRange24w EmailRoutingTimeseriesGroupEncryptedParamsDateRange = "24w" + EmailRoutingTimeseriesGroupEncryptedParamsDateRange52w EmailRoutingTimeseriesGroupEncryptedParamsDateRange = "52w" + EmailRoutingTimeseriesGroupEncryptedParamsDateRange1dControl EmailRoutingTimeseriesGroupEncryptedParamsDateRange = "1dControl" + EmailRoutingTimeseriesGroupEncryptedParamsDateRange2dControl EmailRoutingTimeseriesGroupEncryptedParamsDateRange = "2dControl" + EmailRoutingTimeseriesGroupEncryptedParamsDateRange7dControl EmailRoutingTimeseriesGroupEncryptedParamsDateRange = "7dControl" + EmailRoutingTimeseriesGroupEncryptedParamsDateRange14dControl EmailRoutingTimeseriesGroupEncryptedParamsDateRange = "14dControl" + EmailRoutingTimeseriesGroupEncryptedParamsDateRange28dControl EmailRoutingTimeseriesGroupEncryptedParamsDateRange = "28dControl" + EmailRoutingTimeseriesGroupEncryptedParamsDateRange12wControl EmailRoutingTimeseriesGroupEncryptedParamsDateRange = "12wControl" + EmailRoutingTimeseriesGroupEncryptedParamsDateRange24wControl EmailRoutingTimeseriesGroupEncryptedParamsDateRange = "24wControl" +) + +type EmailRoutingTimeseriesGroupEncryptedParamsDKIM string + +const ( + EmailRoutingTimeseriesGroupEncryptedParamsDKIMPass EmailRoutingTimeseriesGroupEncryptedParamsDKIM = "PASS" + EmailRoutingTimeseriesGroupEncryptedParamsDKIMNone EmailRoutingTimeseriesGroupEncryptedParamsDKIM = "NONE" + EmailRoutingTimeseriesGroupEncryptedParamsDKIMFail EmailRoutingTimeseriesGroupEncryptedParamsDKIM = "FAIL" +) + +type EmailRoutingTimeseriesGroupEncryptedParamsDMARC string + +const ( + EmailRoutingTimeseriesGroupEncryptedParamsDMARCPass EmailRoutingTimeseriesGroupEncryptedParamsDMARC = "PASS" + EmailRoutingTimeseriesGroupEncryptedParamsDMARCNone EmailRoutingTimeseriesGroupEncryptedParamsDMARC = "NONE" + EmailRoutingTimeseriesGroupEncryptedParamsDMARCFail EmailRoutingTimeseriesGroupEncryptedParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailRoutingTimeseriesGroupEncryptedParamsFormat string + +const ( + EmailRoutingTimeseriesGroupEncryptedParamsFormatJson EmailRoutingTimeseriesGroupEncryptedParamsFormat = "JSON" + EmailRoutingTimeseriesGroupEncryptedParamsFormatCsv EmailRoutingTimeseriesGroupEncryptedParamsFormat = "CSV" +) + +type EmailRoutingTimeseriesGroupEncryptedParamsIPVersion string + +const ( + EmailRoutingTimeseriesGroupEncryptedParamsIPVersionIPv4 EmailRoutingTimeseriesGroupEncryptedParamsIPVersion = "IPv4" + EmailRoutingTimeseriesGroupEncryptedParamsIPVersionIPv6 EmailRoutingTimeseriesGroupEncryptedParamsIPVersion = "IPv6" +) + +type EmailRoutingTimeseriesGroupEncryptedParamsSPF string + +const ( + EmailRoutingTimeseriesGroupEncryptedParamsSPFPass EmailRoutingTimeseriesGroupEncryptedParamsSPF = "PASS" + EmailRoutingTimeseriesGroupEncryptedParamsSPFNone EmailRoutingTimeseriesGroupEncryptedParamsSPF = "NONE" + EmailRoutingTimeseriesGroupEncryptedParamsSPFFail EmailRoutingTimeseriesGroupEncryptedParamsSPF = "FAIL" +) + +type EmailRoutingTimeseriesGroupEncryptedResponseEnvelope struct { + Result EmailRoutingTimeseriesGroupEncryptedResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailRoutingTimeseriesGroupEncryptedResponseEnvelopeJSON `json:"-"` +} + +// emailRoutingTimeseriesGroupEncryptedResponseEnvelopeJSON contains the JSON +// metadata for the struct [EmailRoutingTimeseriesGroupEncryptedResponseEnvelope] +type emailRoutingTimeseriesGroupEncryptedResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingTimeseriesGroupEncryptedResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingTimeseriesGroupEncryptedResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingTimeseriesGroupIPVersionParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[EmailRoutingTimeseriesGroupIPVersionParamsAggInterval] `query:"aggInterval"` + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailRoutingTimeseriesGroupIPVersionParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailRoutingTimeseriesGroupIPVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailRoutingTimeseriesGroupIPVersionParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailRoutingTimeseriesGroupIPVersionParamsDMARC] `query:"dmarc"` + // Filter for encrypted emails. + Encrypted param.Field[[]EmailRoutingTimeseriesGroupIPVersionParamsEncrypted] `query:"encrypted"` + // Format results are returned in. + Format param.Field[EmailRoutingTimeseriesGroupIPVersionParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailRoutingTimeseriesGroupIPVersionParamsSPF] `query:"spf"` +} + +// URLQuery serializes [EmailRoutingTimeseriesGroupIPVersionParams]'s query +// parameters as `url.Values`. +func (r EmailRoutingTimeseriesGroupIPVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type EmailRoutingTimeseriesGroupIPVersionParamsAggInterval string + +const ( + EmailRoutingTimeseriesGroupIPVersionParamsAggInterval15m EmailRoutingTimeseriesGroupIPVersionParamsAggInterval = "15m" + EmailRoutingTimeseriesGroupIPVersionParamsAggInterval1h EmailRoutingTimeseriesGroupIPVersionParamsAggInterval = "1h" + EmailRoutingTimeseriesGroupIPVersionParamsAggInterval1d EmailRoutingTimeseriesGroupIPVersionParamsAggInterval = "1d" + EmailRoutingTimeseriesGroupIPVersionParamsAggInterval1w EmailRoutingTimeseriesGroupIPVersionParamsAggInterval = "1w" +) + +type EmailRoutingTimeseriesGroupIPVersionParamsARC string + +const ( + EmailRoutingTimeseriesGroupIPVersionParamsARCPass EmailRoutingTimeseriesGroupIPVersionParamsARC = "PASS" + EmailRoutingTimeseriesGroupIPVersionParamsARCNone EmailRoutingTimeseriesGroupIPVersionParamsARC = "NONE" + EmailRoutingTimeseriesGroupIPVersionParamsARCFail EmailRoutingTimeseriesGroupIPVersionParamsARC = "FAIL" +) + +type EmailRoutingTimeseriesGroupIPVersionParamsDateRange string + +const ( + EmailRoutingTimeseriesGroupIPVersionParamsDateRange1d EmailRoutingTimeseriesGroupIPVersionParamsDateRange = "1d" + EmailRoutingTimeseriesGroupIPVersionParamsDateRange2d EmailRoutingTimeseriesGroupIPVersionParamsDateRange = "2d" + EmailRoutingTimeseriesGroupIPVersionParamsDateRange7d EmailRoutingTimeseriesGroupIPVersionParamsDateRange = "7d" + EmailRoutingTimeseriesGroupIPVersionParamsDateRange14d EmailRoutingTimeseriesGroupIPVersionParamsDateRange = "14d" + EmailRoutingTimeseriesGroupIPVersionParamsDateRange28d EmailRoutingTimeseriesGroupIPVersionParamsDateRange = "28d" + EmailRoutingTimeseriesGroupIPVersionParamsDateRange12w EmailRoutingTimeseriesGroupIPVersionParamsDateRange = "12w" + EmailRoutingTimeseriesGroupIPVersionParamsDateRange24w EmailRoutingTimeseriesGroupIPVersionParamsDateRange = "24w" + EmailRoutingTimeseriesGroupIPVersionParamsDateRange52w EmailRoutingTimeseriesGroupIPVersionParamsDateRange = "52w" + EmailRoutingTimeseriesGroupIPVersionParamsDateRange1dControl EmailRoutingTimeseriesGroupIPVersionParamsDateRange = "1dControl" + EmailRoutingTimeseriesGroupIPVersionParamsDateRange2dControl EmailRoutingTimeseriesGroupIPVersionParamsDateRange = "2dControl" + EmailRoutingTimeseriesGroupIPVersionParamsDateRange7dControl EmailRoutingTimeseriesGroupIPVersionParamsDateRange = "7dControl" + EmailRoutingTimeseriesGroupIPVersionParamsDateRange14dControl EmailRoutingTimeseriesGroupIPVersionParamsDateRange = "14dControl" + EmailRoutingTimeseriesGroupIPVersionParamsDateRange28dControl EmailRoutingTimeseriesGroupIPVersionParamsDateRange = "28dControl" + EmailRoutingTimeseriesGroupIPVersionParamsDateRange12wControl EmailRoutingTimeseriesGroupIPVersionParamsDateRange = "12wControl" + EmailRoutingTimeseriesGroupIPVersionParamsDateRange24wControl EmailRoutingTimeseriesGroupIPVersionParamsDateRange = "24wControl" +) + +type EmailRoutingTimeseriesGroupIPVersionParamsDKIM string + +const ( + EmailRoutingTimeseriesGroupIPVersionParamsDKIMPass EmailRoutingTimeseriesGroupIPVersionParamsDKIM = "PASS" + EmailRoutingTimeseriesGroupIPVersionParamsDKIMNone EmailRoutingTimeseriesGroupIPVersionParamsDKIM = "NONE" + EmailRoutingTimeseriesGroupIPVersionParamsDKIMFail EmailRoutingTimeseriesGroupIPVersionParamsDKIM = "FAIL" +) + +type EmailRoutingTimeseriesGroupIPVersionParamsDMARC string + +const ( + EmailRoutingTimeseriesGroupIPVersionParamsDMARCPass EmailRoutingTimeseriesGroupIPVersionParamsDMARC = "PASS" + EmailRoutingTimeseriesGroupIPVersionParamsDMARCNone EmailRoutingTimeseriesGroupIPVersionParamsDMARC = "NONE" + EmailRoutingTimeseriesGroupIPVersionParamsDMARCFail EmailRoutingTimeseriesGroupIPVersionParamsDMARC = "FAIL" +) + +type EmailRoutingTimeseriesGroupIPVersionParamsEncrypted string + +const ( + EmailRoutingTimeseriesGroupIPVersionParamsEncryptedEncrypted EmailRoutingTimeseriesGroupIPVersionParamsEncrypted = "ENCRYPTED" + EmailRoutingTimeseriesGroupIPVersionParamsEncryptedNotEncrypted EmailRoutingTimeseriesGroupIPVersionParamsEncrypted = "NOT_ENCRYPTED" +) + +// Format results are returned in. +type EmailRoutingTimeseriesGroupIPVersionParamsFormat string + +const ( + EmailRoutingTimeseriesGroupIPVersionParamsFormatJson EmailRoutingTimeseriesGroupIPVersionParamsFormat = "JSON" + EmailRoutingTimeseriesGroupIPVersionParamsFormatCsv EmailRoutingTimeseriesGroupIPVersionParamsFormat = "CSV" +) + +type EmailRoutingTimeseriesGroupIPVersionParamsSPF string + +const ( + EmailRoutingTimeseriesGroupIPVersionParamsSPFPass EmailRoutingTimeseriesGroupIPVersionParamsSPF = "PASS" + EmailRoutingTimeseriesGroupIPVersionParamsSPFNone EmailRoutingTimeseriesGroupIPVersionParamsSPF = "NONE" + EmailRoutingTimeseriesGroupIPVersionParamsSPFFail EmailRoutingTimeseriesGroupIPVersionParamsSPF = "FAIL" +) + +type EmailRoutingTimeseriesGroupIPVersionResponseEnvelope struct { + Result EmailRoutingTimeseriesGroupIPVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailRoutingTimeseriesGroupIPVersionResponseEnvelopeJSON `json:"-"` +} + +// emailRoutingTimeseriesGroupIPVersionResponseEnvelopeJSON contains the JSON +// metadata for the struct [EmailRoutingTimeseriesGroupIPVersionResponseEnvelope] +type emailRoutingTimeseriesGroupIPVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingTimeseriesGroupIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingTimeseriesGroupIPVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailRoutingTimeseriesGroupSPFParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[EmailRoutingTimeseriesGroupSPFParamsAggInterval] `query:"aggInterval"` + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailRoutingTimeseriesGroupSPFParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailRoutingTimeseriesGroupSPFParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailRoutingTimeseriesGroupSPFParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailRoutingTimeseriesGroupSPFParamsDMARC] `query:"dmarc"` + // Filter for encrypted emails. + Encrypted param.Field[[]EmailRoutingTimeseriesGroupSPFParamsEncrypted] `query:"encrypted"` + // Format results are returned in. + Format param.Field[EmailRoutingTimeseriesGroupSPFParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]EmailRoutingTimeseriesGroupSPFParamsIPVersion] `query:"ipVersion"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [EmailRoutingTimeseriesGroupSPFParams]'s query parameters as +// `url.Values`. +func (r EmailRoutingTimeseriesGroupSPFParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type EmailRoutingTimeseriesGroupSPFParamsAggInterval string + +const ( + EmailRoutingTimeseriesGroupSPFParamsAggInterval15m EmailRoutingTimeseriesGroupSPFParamsAggInterval = "15m" + EmailRoutingTimeseriesGroupSPFParamsAggInterval1h EmailRoutingTimeseriesGroupSPFParamsAggInterval = "1h" + EmailRoutingTimeseriesGroupSPFParamsAggInterval1d EmailRoutingTimeseriesGroupSPFParamsAggInterval = "1d" + EmailRoutingTimeseriesGroupSPFParamsAggInterval1w EmailRoutingTimeseriesGroupSPFParamsAggInterval = "1w" +) + +type EmailRoutingTimeseriesGroupSPFParamsARC string + +const ( + EmailRoutingTimeseriesGroupSPFParamsARCPass EmailRoutingTimeseriesGroupSPFParamsARC = "PASS" + EmailRoutingTimeseriesGroupSPFParamsARCNone EmailRoutingTimeseriesGroupSPFParamsARC = "NONE" + EmailRoutingTimeseriesGroupSPFParamsARCFail EmailRoutingTimeseriesGroupSPFParamsARC = "FAIL" +) + +type EmailRoutingTimeseriesGroupSPFParamsDateRange string + +const ( + EmailRoutingTimeseriesGroupSPFParamsDateRange1d EmailRoutingTimeseriesGroupSPFParamsDateRange = "1d" + EmailRoutingTimeseriesGroupSPFParamsDateRange2d EmailRoutingTimeseriesGroupSPFParamsDateRange = "2d" + EmailRoutingTimeseriesGroupSPFParamsDateRange7d EmailRoutingTimeseriesGroupSPFParamsDateRange = "7d" + EmailRoutingTimeseriesGroupSPFParamsDateRange14d EmailRoutingTimeseriesGroupSPFParamsDateRange = "14d" + EmailRoutingTimeseriesGroupSPFParamsDateRange28d EmailRoutingTimeseriesGroupSPFParamsDateRange = "28d" + EmailRoutingTimeseriesGroupSPFParamsDateRange12w EmailRoutingTimeseriesGroupSPFParamsDateRange = "12w" + EmailRoutingTimeseriesGroupSPFParamsDateRange24w EmailRoutingTimeseriesGroupSPFParamsDateRange = "24w" + EmailRoutingTimeseriesGroupSPFParamsDateRange52w EmailRoutingTimeseriesGroupSPFParamsDateRange = "52w" + EmailRoutingTimeseriesGroupSPFParamsDateRange1dControl EmailRoutingTimeseriesGroupSPFParamsDateRange = "1dControl" + EmailRoutingTimeseriesGroupSPFParamsDateRange2dControl EmailRoutingTimeseriesGroupSPFParamsDateRange = "2dControl" + EmailRoutingTimeseriesGroupSPFParamsDateRange7dControl EmailRoutingTimeseriesGroupSPFParamsDateRange = "7dControl" + EmailRoutingTimeseriesGroupSPFParamsDateRange14dControl EmailRoutingTimeseriesGroupSPFParamsDateRange = "14dControl" + EmailRoutingTimeseriesGroupSPFParamsDateRange28dControl EmailRoutingTimeseriesGroupSPFParamsDateRange = "28dControl" + EmailRoutingTimeseriesGroupSPFParamsDateRange12wControl EmailRoutingTimeseriesGroupSPFParamsDateRange = "12wControl" + EmailRoutingTimeseriesGroupSPFParamsDateRange24wControl EmailRoutingTimeseriesGroupSPFParamsDateRange = "24wControl" +) + +type EmailRoutingTimeseriesGroupSPFParamsDKIM string + +const ( + EmailRoutingTimeseriesGroupSPFParamsDKIMPass EmailRoutingTimeseriesGroupSPFParamsDKIM = "PASS" + EmailRoutingTimeseriesGroupSPFParamsDKIMNone EmailRoutingTimeseriesGroupSPFParamsDKIM = "NONE" + EmailRoutingTimeseriesGroupSPFParamsDKIMFail EmailRoutingTimeseriesGroupSPFParamsDKIM = "FAIL" +) + +type EmailRoutingTimeseriesGroupSPFParamsDMARC string + +const ( + EmailRoutingTimeseriesGroupSPFParamsDMARCPass EmailRoutingTimeseriesGroupSPFParamsDMARC = "PASS" + EmailRoutingTimeseriesGroupSPFParamsDMARCNone EmailRoutingTimeseriesGroupSPFParamsDMARC = "NONE" + EmailRoutingTimeseriesGroupSPFParamsDMARCFail EmailRoutingTimeseriesGroupSPFParamsDMARC = "FAIL" +) + +type EmailRoutingTimeseriesGroupSPFParamsEncrypted string + +const ( + EmailRoutingTimeseriesGroupSPFParamsEncryptedEncrypted EmailRoutingTimeseriesGroupSPFParamsEncrypted = "ENCRYPTED" + EmailRoutingTimeseriesGroupSPFParamsEncryptedNotEncrypted EmailRoutingTimeseriesGroupSPFParamsEncrypted = "NOT_ENCRYPTED" +) + +// Format results are returned in. +type EmailRoutingTimeseriesGroupSPFParamsFormat string + +const ( + EmailRoutingTimeseriesGroupSPFParamsFormatJson EmailRoutingTimeseriesGroupSPFParamsFormat = "JSON" + EmailRoutingTimeseriesGroupSPFParamsFormatCsv EmailRoutingTimeseriesGroupSPFParamsFormat = "CSV" +) + +type EmailRoutingTimeseriesGroupSPFParamsIPVersion string + +const ( + EmailRoutingTimeseriesGroupSPFParamsIPVersionIPv4 EmailRoutingTimeseriesGroupSPFParamsIPVersion = "IPv4" + EmailRoutingTimeseriesGroupSPFParamsIPVersionIPv6 EmailRoutingTimeseriesGroupSPFParamsIPVersion = "IPv6" +) + +type EmailRoutingTimeseriesGroupSPFResponseEnvelope struct { + Result EmailRoutingTimeseriesGroupSPFResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailRoutingTimeseriesGroupSPFResponseEnvelopeJSON `json:"-"` +} + +// emailRoutingTimeseriesGroupSPFResponseEnvelopeJSON contains the JSON metadata +// for the struct [EmailRoutingTimeseriesGroupSPFResponseEnvelope] +type emailRoutingTimeseriesGroupSPFResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailRoutingTimeseriesGroupSPFResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailRoutingTimeseriesGroupSPFResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/emailroutingtimeseriesgroup_test.go b/radar/emailroutingtimeseriesgroup_test.go new file mode 100644 index 00000000000..c40c608b321 --- /dev/null +++ b/radar/emailroutingtimeseriesgroup_test.go @@ -0,0 +1,232 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestEmailRoutingTimeseriesGroupARCWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Routing.TimeseriesGroups.ARC(context.TODO(), radar.EmailRoutingTimeseriesGroupARCParams{ + AggInterval: cloudflare.F(radar.EmailRoutingTimeseriesGroupARCParamsAggInterval1h), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailRoutingTimeseriesGroupARCParamsDateRange{radar.EmailRoutingTimeseriesGroupARCParamsDateRange1d, radar.EmailRoutingTimeseriesGroupARCParamsDateRange2d, radar.EmailRoutingTimeseriesGroupARCParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailRoutingTimeseriesGroupARCParamsDKIM{radar.EmailRoutingTimeseriesGroupARCParamsDKIMPass, radar.EmailRoutingTimeseriesGroupARCParamsDKIMNone, radar.EmailRoutingTimeseriesGroupARCParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailRoutingTimeseriesGroupARCParamsDMARC{radar.EmailRoutingTimeseriesGroupARCParamsDMARCPass, radar.EmailRoutingTimeseriesGroupARCParamsDMARCNone, radar.EmailRoutingTimeseriesGroupARCParamsDMARCFail}), + Encrypted: cloudflare.F([]radar.EmailRoutingTimeseriesGroupARCParamsEncrypted{radar.EmailRoutingTimeseriesGroupARCParamsEncryptedEncrypted, radar.EmailRoutingTimeseriesGroupARCParamsEncryptedNotEncrypted}), + Format: cloudflare.F(radar.EmailRoutingTimeseriesGroupARCParamsFormatJson), + IPVersion: cloudflare.F([]radar.EmailRoutingTimeseriesGroupARCParamsIPVersion{radar.EmailRoutingTimeseriesGroupARCParamsIPVersionIPv4, radar.EmailRoutingTimeseriesGroupARCParamsIPVersionIPv6}), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailRoutingTimeseriesGroupARCParamsSPF{radar.EmailRoutingTimeseriesGroupARCParamsSPFPass, radar.EmailRoutingTimeseriesGroupARCParamsSPFNone, radar.EmailRoutingTimeseriesGroupARCParamsSPFFail}), + }) + 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 TestEmailRoutingTimeseriesGroupDKIMWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Routing.TimeseriesGroups.DKIM(context.TODO(), radar.EmailRoutingTimeseriesGroupDKIMParams{ + AggInterval: cloudflare.F(radar.EmailRoutingTimeseriesGroupDKIMParamsAggInterval1h), + ARC: cloudflare.F([]radar.EmailRoutingTimeseriesGroupDKIMParamsARC{radar.EmailRoutingTimeseriesGroupDKIMParamsARCPass, radar.EmailRoutingTimeseriesGroupDKIMParamsARCNone, radar.EmailRoutingTimeseriesGroupDKIMParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailRoutingTimeseriesGroupDKIMParamsDateRange{radar.EmailRoutingTimeseriesGroupDKIMParamsDateRange1d, radar.EmailRoutingTimeseriesGroupDKIMParamsDateRange2d, radar.EmailRoutingTimeseriesGroupDKIMParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DMARC: cloudflare.F([]radar.EmailRoutingTimeseriesGroupDKIMParamsDMARC{radar.EmailRoutingTimeseriesGroupDKIMParamsDMARCPass, radar.EmailRoutingTimeseriesGroupDKIMParamsDMARCNone, radar.EmailRoutingTimeseriesGroupDKIMParamsDMARCFail}), + Encrypted: cloudflare.F([]radar.EmailRoutingTimeseriesGroupDKIMParamsEncrypted{radar.EmailRoutingTimeseriesGroupDKIMParamsEncryptedEncrypted, radar.EmailRoutingTimeseriesGroupDKIMParamsEncryptedNotEncrypted}), + Format: cloudflare.F(radar.EmailRoutingTimeseriesGroupDKIMParamsFormatJson), + IPVersion: cloudflare.F([]radar.EmailRoutingTimeseriesGroupDKIMParamsIPVersion{radar.EmailRoutingTimeseriesGroupDKIMParamsIPVersionIPv4, radar.EmailRoutingTimeseriesGroupDKIMParamsIPVersionIPv6}), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailRoutingTimeseriesGroupDKIMParamsSPF{radar.EmailRoutingTimeseriesGroupDKIMParamsSPFPass, radar.EmailRoutingTimeseriesGroupDKIMParamsSPFNone, radar.EmailRoutingTimeseriesGroupDKIMParamsSPFFail}), + }) + 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 TestEmailRoutingTimeseriesGroupDMARCWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Routing.TimeseriesGroups.DMARC(context.TODO(), radar.EmailRoutingTimeseriesGroupDMARCParams{ + AggInterval: cloudflare.F(radar.EmailRoutingTimeseriesGroupDMARCParamsAggInterval1h), + ARC: cloudflare.F([]radar.EmailRoutingTimeseriesGroupDMARCParamsARC{radar.EmailRoutingTimeseriesGroupDMARCParamsARCPass, radar.EmailRoutingTimeseriesGroupDMARCParamsARCNone, radar.EmailRoutingTimeseriesGroupDMARCParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailRoutingTimeseriesGroupDMARCParamsDateRange{radar.EmailRoutingTimeseriesGroupDMARCParamsDateRange1d, radar.EmailRoutingTimeseriesGroupDMARCParamsDateRange2d, radar.EmailRoutingTimeseriesGroupDMARCParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailRoutingTimeseriesGroupDMARCParamsDKIM{radar.EmailRoutingTimeseriesGroupDMARCParamsDKIMPass, radar.EmailRoutingTimeseriesGroupDMARCParamsDKIMNone, radar.EmailRoutingTimeseriesGroupDMARCParamsDKIMFail}), + Encrypted: cloudflare.F([]radar.EmailRoutingTimeseriesGroupDMARCParamsEncrypted{radar.EmailRoutingTimeseriesGroupDMARCParamsEncryptedEncrypted, radar.EmailRoutingTimeseriesGroupDMARCParamsEncryptedNotEncrypted}), + Format: cloudflare.F(radar.EmailRoutingTimeseriesGroupDMARCParamsFormatJson), + IPVersion: cloudflare.F([]radar.EmailRoutingTimeseriesGroupDMARCParamsIPVersion{radar.EmailRoutingTimeseriesGroupDMARCParamsIPVersionIPv4, radar.EmailRoutingTimeseriesGroupDMARCParamsIPVersionIPv6}), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailRoutingTimeseriesGroupDMARCParamsSPF{radar.EmailRoutingTimeseriesGroupDMARCParamsSPFPass, radar.EmailRoutingTimeseriesGroupDMARCParamsSPFNone, radar.EmailRoutingTimeseriesGroupDMARCParamsSPFFail}), + }) + 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 TestEmailRoutingTimeseriesGroupEncryptedWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Routing.TimeseriesGroups.Encrypted(context.TODO(), radar.EmailRoutingTimeseriesGroupEncryptedParams{ + AggInterval: cloudflare.F(radar.EmailRoutingTimeseriesGroupEncryptedParamsAggInterval1h), + ARC: cloudflare.F([]radar.EmailRoutingTimeseriesGroupEncryptedParamsARC{radar.EmailRoutingTimeseriesGroupEncryptedParamsARCPass, radar.EmailRoutingTimeseriesGroupEncryptedParamsARCNone, radar.EmailRoutingTimeseriesGroupEncryptedParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailRoutingTimeseriesGroupEncryptedParamsDateRange{radar.EmailRoutingTimeseriesGroupEncryptedParamsDateRange1d, radar.EmailRoutingTimeseriesGroupEncryptedParamsDateRange2d, radar.EmailRoutingTimeseriesGroupEncryptedParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailRoutingTimeseriesGroupEncryptedParamsDKIM{radar.EmailRoutingTimeseriesGroupEncryptedParamsDKIMPass, radar.EmailRoutingTimeseriesGroupEncryptedParamsDKIMNone, radar.EmailRoutingTimeseriesGroupEncryptedParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailRoutingTimeseriesGroupEncryptedParamsDMARC{radar.EmailRoutingTimeseriesGroupEncryptedParamsDMARCPass, radar.EmailRoutingTimeseriesGroupEncryptedParamsDMARCNone, radar.EmailRoutingTimeseriesGroupEncryptedParamsDMARCFail}), + Format: cloudflare.F(radar.EmailRoutingTimeseriesGroupEncryptedParamsFormatJson), + IPVersion: cloudflare.F([]radar.EmailRoutingTimeseriesGroupEncryptedParamsIPVersion{radar.EmailRoutingTimeseriesGroupEncryptedParamsIPVersionIPv4, radar.EmailRoutingTimeseriesGroupEncryptedParamsIPVersionIPv6}), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailRoutingTimeseriesGroupEncryptedParamsSPF{radar.EmailRoutingTimeseriesGroupEncryptedParamsSPFPass, radar.EmailRoutingTimeseriesGroupEncryptedParamsSPFNone, radar.EmailRoutingTimeseriesGroupEncryptedParamsSPFFail}), + }) + 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 TestEmailRoutingTimeseriesGroupIPVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Routing.TimeseriesGroups.IPVersion(context.TODO(), radar.EmailRoutingTimeseriesGroupIPVersionParams{ + AggInterval: cloudflare.F(radar.EmailRoutingTimeseriesGroupIPVersionParamsAggInterval1h), + ARC: cloudflare.F([]radar.EmailRoutingTimeseriesGroupIPVersionParamsARC{radar.EmailRoutingTimeseriesGroupIPVersionParamsARCPass, radar.EmailRoutingTimeseriesGroupIPVersionParamsARCNone, radar.EmailRoutingTimeseriesGroupIPVersionParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailRoutingTimeseriesGroupIPVersionParamsDateRange{radar.EmailRoutingTimeseriesGroupIPVersionParamsDateRange1d, radar.EmailRoutingTimeseriesGroupIPVersionParamsDateRange2d, radar.EmailRoutingTimeseriesGroupIPVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailRoutingTimeseriesGroupIPVersionParamsDKIM{radar.EmailRoutingTimeseriesGroupIPVersionParamsDKIMPass, radar.EmailRoutingTimeseriesGroupIPVersionParamsDKIMNone, radar.EmailRoutingTimeseriesGroupIPVersionParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailRoutingTimeseriesGroupIPVersionParamsDMARC{radar.EmailRoutingTimeseriesGroupIPVersionParamsDMARCPass, radar.EmailRoutingTimeseriesGroupIPVersionParamsDMARCNone, radar.EmailRoutingTimeseriesGroupIPVersionParamsDMARCFail}), + Encrypted: cloudflare.F([]radar.EmailRoutingTimeseriesGroupIPVersionParamsEncrypted{radar.EmailRoutingTimeseriesGroupIPVersionParamsEncryptedEncrypted, radar.EmailRoutingTimeseriesGroupIPVersionParamsEncryptedNotEncrypted}), + Format: cloudflare.F(radar.EmailRoutingTimeseriesGroupIPVersionParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailRoutingTimeseriesGroupIPVersionParamsSPF{radar.EmailRoutingTimeseriesGroupIPVersionParamsSPFPass, radar.EmailRoutingTimeseriesGroupIPVersionParamsSPFNone, radar.EmailRoutingTimeseriesGroupIPVersionParamsSPFFail}), + }) + 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 TestEmailRoutingTimeseriesGroupSPFWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Routing.TimeseriesGroups.SPF(context.TODO(), radar.EmailRoutingTimeseriesGroupSPFParams{ + AggInterval: cloudflare.F(radar.EmailRoutingTimeseriesGroupSPFParamsAggInterval1h), + ARC: cloudflare.F([]radar.EmailRoutingTimeseriesGroupSPFParamsARC{radar.EmailRoutingTimeseriesGroupSPFParamsARCPass, radar.EmailRoutingTimeseriesGroupSPFParamsARCNone, radar.EmailRoutingTimeseriesGroupSPFParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailRoutingTimeseriesGroupSPFParamsDateRange{radar.EmailRoutingTimeseriesGroupSPFParamsDateRange1d, radar.EmailRoutingTimeseriesGroupSPFParamsDateRange2d, radar.EmailRoutingTimeseriesGroupSPFParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailRoutingTimeseriesGroupSPFParamsDKIM{radar.EmailRoutingTimeseriesGroupSPFParamsDKIMPass, radar.EmailRoutingTimeseriesGroupSPFParamsDKIMNone, radar.EmailRoutingTimeseriesGroupSPFParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailRoutingTimeseriesGroupSPFParamsDMARC{radar.EmailRoutingTimeseriesGroupSPFParamsDMARCPass, radar.EmailRoutingTimeseriesGroupSPFParamsDMARCNone, radar.EmailRoutingTimeseriesGroupSPFParamsDMARCFail}), + Encrypted: cloudflare.F([]radar.EmailRoutingTimeseriesGroupSPFParamsEncrypted{radar.EmailRoutingTimeseriesGroupSPFParamsEncryptedEncrypted, radar.EmailRoutingTimeseriesGroupSPFParamsEncryptedNotEncrypted}), + Format: cloudflare.F(radar.EmailRoutingTimeseriesGroupSPFParamsFormatJson), + IPVersion: cloudflare.F([]radar.EmailRoutingTimeseriesGroupSPFParamsIPVersion{radar.EmailRoutingTimeseriesGroupSPFParamsIPVersionIPv4, radar.EmailRoutingTimeseriesGroupSPFParamsIPVersionIPv6}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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/radar/emailsecurity.go b/radar/emailsecurity.go new file mode 100644 index 00000000000..ab087b9d280 --- /dev/null +++ b/radar/emailsecurity.go @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// EmailSecurityService 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 [NewEmailSecurityService] method +// instead. +type EmailSecurityService struct { + Options []option.RequestOption + Top *EmailSecurityTopService + Summary *EmailSecuritySummaryService + TimeseriesGroups *EmailSecurityTimeseriesGroupService +} + +// NewEmailSecurityService 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 NewEmailSecurityService(opts ...option.RequestOption) (r *EmailSecurityService) { + r = &EmailSecurityService{} + r.Options = opts + r.Top = NewEmailSecurityTopService(opts...) + r.Summary = NewEmailSecuritySummaryService(opts...) + r.TimeseriesGroups = NewEmailSecurityTimeseriesGroupService(opts...) + return +} diff --git a/radar/emailsecuritysummary.go b/radar/emailsecuritysummary.go new file mode 100644 index 00000000000..7a544ada3d1 --- /dev/null +++ b/radar/emailsecuritysummary.go @@ -0,0 +1,2649 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// EmailSecuritySummaryService 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 [NewEmailSecuritySummaryService] +// method instead. +type EmailSecuritySummaryService struct { + Options []option.RequestOption +} + +// NewEmailSecuritySummaryService 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 NewEmailSecuritySummaryService(opts ...option.RequestOption) (r *EmailSecuritySummaryService) { + r = &EmailSecuritySummaryService{} + r.Options = opts + return +} + +// Percentage distribution of emails classified per ARC validation. +func (r *EmailSecuritySummaryService) ARC(ctx context.Context, query EmailSecuritySummaryARCParams, opts ...option.RequestOption) (res *EmailSecuritySummaryARCResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecuritySummaryARCResponseEnvelope + path := "radar/email/security/summary/arc" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified per DKIM validation. +func (r *EmailSecuritySummaryService) DKIM(ctx context.Context, query EmailSecuritySummaryDKIMParams, opts ...option.RequestOption) (res *EmailSecuritySummaryDKIMResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecuritySummaryDKIMResponseEnvelope + path := "radar/email/security/summary/dkim" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified per DMARC validation. +func (r *EmailSecuritySummaryService) DMARC(ctx context.Context, query EmailSecuritySummaryDMARCParams, opts ...option.RequestOption) (res *EmailSecuritySummaryDMARCResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecuritySummaryDMARCResponseEnvelope + path := "radar/email/security/summary/dmarc" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified as MALICIOUS. +func (r *EmailSecuritySummaryService) Malicious(ctx context.Context, query EmailSecuritySummaryMaliciousParams, opts ...option.RequestOption) (res *EmailSecuritySummaryMaliciousResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecuritySummaryMaliciousResponseEnvelope + path := "radar/email/security/summary/malicious" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Proportion of emails categorized as either spam or legitimate (non-spam). +func (r *EmailSecuritySummaryService) Spam(ctx context.Context, query EmailSecuritySummarySpamParams, opts ...option.RequestOption) (res *EmailSecuritySummarySpamResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecuritySummarySpamResponseEnvelope + path := "radar/email/security/summary/spam" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified per SPF validation. +func (r *EmailSecuritySummaryService) SPF(ctx context.Context, query EmailSecuritySummarySPFParams, opts ...option.RequestOption) (res *EmailSecuritySummarySPFResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecuritySummarySPFResponseEnvelope + path := "radar/email/security/summary/spf" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Proportion of emails categorized as either spoof or legitimate (non-spoof). +func (r *EmailSecuritySummaryService) Spoof(ctx context.Context, query EmailSecuritySummarySpoofParams, opts ...option.RequestOption) (res *EmailSecuritySummarySpoofResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecuritySummarySpoofResponseEnvelope + path := "radar/email/security/summary/spoof" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified in Threat Categories. +func (r *EmailSecuritySummaryService) ThreatCategory(ctx context.Context, query EmailSecuritySummaryThreatCategoryParams, opts ...option.RequestOption) (res *EmailSecuritySummaryThreatCategoryResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecuritySummaryThreatCategoryResponseEnvelope + path := "radar/email/security/summary/threat_category" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified per TLS Version. +func (r *EmailSecuritySummaryService) TLSVersion(ctx context.Context, query EmailSecuritySummaryTLSVersionParams, opts ...option.RequestOption) (res *EmailSecuritySummaryTLSVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecuritySummaryTLSVersionResponseEnvelope + path := "radar/email/security/summary/tls_version" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type EmailSecuritySummaryARCResponse struct { + Meta EmailSecuritySummaryARCResponseMeta `json:"meta,required"` + Summary0 EmailSecuritySummaryARCResponseSummary0 `json:"summary_0,required"` + JSON emailSecuritySummaryARCResponseJSON `json:"-"` +} + +// emailSecuritySummaryARCResponseJSON contains the JSON metadata for the struct +// [EmailSecuritySummaryARCResponse] +type emailSecuritySummaryARCResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryARCResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryARCResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryARCResponseMeta struct { + DateRange []EmailSecuritySummaryARCResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo EmailSecuritySummaryARCResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailSecuritySummaryARCResponseMetaJSON `json:"-"` +} + +// emailSecuritySummaryARCResponseMetaJSON contains the JSON metadata for the +// struct [EmailSecuritySummaryARCResponseMeta] +type emailSecuritySummaryARCResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryARCResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryARCResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryARCResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailSecuritySummaryARCResponseMetaDateRangeJSON `json:"-"` +} + +// emailSecuritySummaryARCResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [EmailSecuritySummaryARCResponseMetaDateRange] +type emailSecuritySummaryARCResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryARCResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryARCResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryARCResponseMetaConfidenceInfo struct { + Annotations []EmailSecuritySummaryARCResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailSecuritySummaryARCResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailSecuritySummaryARCResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [EmailSecuritySummaryARCResponseMetaConfidenceInfo] +type emailSecuritySummaryARCResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryARCResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryARCResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryARCResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailSecuritySummaryARCResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailSecuritySummaryARCResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [EmailSecuritySummaryARCResponseMetaConfidenceInfoAnnotation] +type emailSecuritySummaryARCResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryARCResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryARCResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryARCResponseSummary0 struct { + Fail string `json:"FAIL,required"` + None string `json:"NONE,required"` + Pass string `json:"PASS,required"` + JSON emailSecuritySummaryARCResponseSummary0JSON `json:"-"` +} + +// emailSecuritySummaryARCResponseSummary0JSON contains the JSON metadata for the +// struct [EmailSecuritySummaryARCResponseSummary0] +type emailSecuritySummaryARCResponseSummary0JSON struct { + Fail apijson.Field + None apijson.Field + Pass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryARCResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryARCResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryDKIMResponse struct { + Meta EmailSecuritySummaryDKIMResponseMeta `json:"meta,required"` + Summary0 EmailSecuritySummaryDKIMResponseSummary0 `json:"summary_0,required"` + JSON emailSecuritySummaryDKIMResponseJSON `json:"-"` +} + +// emailSecuritySummaryDKIMResponseJSON contains the JSON metadata for the struct +// [EmailSecuritySummaryDKIMResponse] +type emailSecuritySummaryDKIMResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryDKIMResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryDKIMResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryDKIMResponseMeta struct { + DateRange []EmailSecuritySummaryDKIMResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo EmailSecuritySummaryDKIMResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailSecuritySummaryDKIMResponseMetaJSON `json:"-"` +} + +// emailSecuritySummaryDKIMResponseMetaJSON contains the JSON metadata for the +// struct [EmailSecuritySummaryDKIMResponseMeta] +type emailSecuritySummaryDKIMResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryDKIMResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryDKIMResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryDKIMResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailSecuritySummaryDKIMResponseMetaDateRangeJSON `json:"-"` +} + +// emailSecuritySummaryDKIMResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [EmailSecuritySummaryDKIMResponseMetaDateRange] +type emailSecuritySummaryDKIMResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryDKIMResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryDKIMResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryDKIMResponseMetaConfidenceInfo struct { + Annotations []EmailSecuritySummaryDKIMResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailSecuritySummaryDKIMResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailSecuritySummaryDKIMResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [EmailSecuritySummaryDKIMResponseMetaConfidenceInfo] +type emailSecuritySummaryDKIMResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryDKIMResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryDKIMResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryDKIMResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailSecuritySummaryDKIMResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailSecuritySummaryDKIMResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [EmailSecuritySummaryDKIMResponseMetaConfidenceInfoAnnotation] +type emailSecuritySummaryDKIMResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryDKIMResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryDKIMResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryDKIMResponseSummary0 struct { + Fail string `json:"FAIL,required"` + None string `json:"NONE,required"` + Pass string `json:"PASS,required"` + JSON emailSecuritySummaryDKIMResponseSummary0JSON `json:"-"` +} + +// emailSecuritySummaryDKIMResponseSummary0JSON contains the JSON metadata for the +// struct [EmailSecuritySummaryDKIMResponseSummary0] +type emailSecuritySummaryDKIMResponseSummary0JSON struct { + Fail apijson.Field + None apijson.Field + Pass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryDKIMResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryDKIMResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryDMARCResponse struct { + Meta EmailSecuritySummaryDMARCResponseMeta `json:"meta,required"` + Summary0 EmailSecuritySummaryDMARCResponseSummary0 `json:"summary_0,required"` + JSON emailSecuritySummaryDMARCResponseJSON `json:"-"` +} + +// emailSecuritySummaryDMARCResponseJSON contains the JSON metadata for the struct +// [EmailSecuritySummaryDMARCResponse] +type emailSecuritySummaryDMARCResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryDMARCResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryDMARCResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryDMARCResponseMeta struct { + DateRange []EmailSecuritySummaryDMARCResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo EmailSecuritySummaryDMARCResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailSecuritySummaryDMARCResponseMetaJSON `json:"-"` +} + +// emailSecuritySummaryDMARCResponseMetaJSON contains the JSON metadata for the +// struct [EmailSecuritySummaryDMARCResponseMeta] +type emailSecuritySummaryDMARCResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryDMARCResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryDMARCResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryDMARCResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailSecuritySummaryDMARCResponseMetaDateRangeJSON `json:"-"` +} + +// emailSecuritySummaryDMARCResponseMetaDateRangeJSON contains the JSON metadata +// for the struct [EmailSecuritySummaryDMARCResponseMetaDateRange] +type emailSecuritySummaryDMARCResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryDMARCResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryDMARCResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryDMARCResponseMetaConfidenceInfo struct { + Annotations []EmailSecuritySummaryDMARCResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailSecuritySummaryDMARCResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailSecuritySummaryDMARCResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [EmailSecuritySummaryDMARCResponseMetaConfidenceInfo] +type emailSecuritySummaryDMARCResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryDMARCResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryDMARCResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryDMARCResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailSecuritySummaryDMARCResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailSecuritySummaryDMARCResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [EmailSecuritySummaryDMARCResponseMetaConfidenceInfoAnnotation] +type emailSecuritySummaryDMARCResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryDMARCResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryDMARCResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryDMARCResponseSummary0 struct { + Fail string `json:"FAIL,required"` + None string `json:"NONE,required"` + Pass string `json:"PASS,required"` + JSON emailSecuritySummaryDMARCResponseSummary0JSON `json:"-"` +} + +// emailSecuritySummaryDMARCResponseSummary0JSON contains the JSON metadata for the +// struct [EmailSecuritySummaryDMARCResponseSummary0] +type emailSecuritySummaryDMARCResponseSummary0JSON struct { + Fail apijson.Field + None apijson.Field + Pass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryDMARCResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryDMARCResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryMaliciousResponse struct { + Meta EmailSecuritySummaryMaliciousResponseMeta `json:"meta,required"` + Summary0 EmailSecuritySummaryMaliciousResponseSummary0 `json:"summary_0,required"` + JSON emailSecuritySummaryMaliciousResponseJSON `json:"-"` +} + +// emailSecuritySummaryMaliciousResponseJSON contains the JSON metadata for the +// struct [EmailSecuritySummaryMaliciousResponse] +type emailSecuritySummaryMaliciousResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryMaliciousResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryMaliciousResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryMaliciousResponseMeta struct { + DateRange []EmailSecuritySummaryMaliciousResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo EmailSecuritySummaryMaliciousResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailSecuritySummaryMaliciousResponseMetaJSON `json:"-"` +} + +// emailSecuritySummaryMaliciousResponseMetaJSON contains the JSON metadata for the +// struct [EmailSecuritySummaryMaliciousResponseMeta] +type emailSecuritySummaryMaliciousResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryMaliciousResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryMaliciousResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryMaliciousResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailSecuritySummaryMaliciousResponseMetaDateRangeJSON `json:"-"` +} + +// emailSecuritySummaryMaliciousResponseMetaDateRangeJSON contains the JSON +// metadata for the struct [EmailSecuritySummaryMaliciousResponseMetaDateRange] +type emailSecuritySummaryMaliciousResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryMaliciousResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryMaliciousResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryMaliciousResponseMetaConfidenceInfo struct { + Annotations []EmailSecuritySummaryMaliciousResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailSecuritySummaryMaliciousResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailSecuritySummaryMaliciousResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct +// [EmailSecuritySummaryMaliciousResponseMetaConfidenceInfo] +type emailSecuritySummaryMaliciousResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryMaliciousResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryMaliciousResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryMaliciousResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailSecuritySummaryMaliciousResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailSecuritySummaryMaliciousResponseMetaConfidenceInfoAnnotationJSON contains +// the JSON metadata for the struct +// [EmailSecuritySummaryMaliciousResponseMetaConfidenceInfoAnnotation] +type emailSecuritySummaryMaliciousResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryMaliciousResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryMaliciousResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryMaliciousResponseSummary0 struct { + Malicious string `json:"MALICIOUS,required"` + NotMalicious string `json:"NOT_MALICIOUS,required"` + JSON emailSecuritySummaryMaliciousResponseSummary0JSON `json:"-"` +} + +// emailSecuritySummaryMaliciousResponseSummary0JSON contains the JSON metadata for +// the struct [EmailSecuritySummaryMaliciousResponseSummary0] +type emailSecuritySummaryMaliciousResponseSummary0JSON struct { + Malicious apijson.Field + NotMalicious apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryMaliciousResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryMaliciousResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySpamResponse struct { + Meta EmailSecuritySummarySpamResponseMeta `json:"meta,required"` + Summary0 EmailSecuritySummarySpamResponseSummary0 `json:"summary_0,required"` + JSON emailSecuritySummarySpamResponseJSON `json:"-"` +} + +// emailSecuritySummarySpamResponseJSON contains the JSON metadata for the struct +// [EmailSecuritySummarySpamResponse] +type emailSecuritySummarySpamResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySpamResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySpamResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySpamResponseMeta struct { + DateRange []EmailSecuritySummarySpamResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo EmailSecuritySummarySpamResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailSecuritySummarySpamResponseMetaJSON `json:"-"` +} + +// emailSecuritySummarySpamResponseMetaJSON contains the JSON metadata for the +// struct [EmailSecuritySummarySpamResponseMeta] +type emailSecuritySummarySpamResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySpamResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySpamResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySpamResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailSecuritySummarySpamResponseMetaDateRangeJSON `json:"-"` +} + +// emailSecuritySummarySpamResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [EmailSecuritySummarySpamResponseMetaDateRange] +type emailSecuritySummarySpamResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySpamResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySpamResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySpamResponseMetaConfidenceInfo struct { + Annotations []EmailSecuritySummarySpamResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailSecuritySummarySpamResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailSecuritySummarySpamResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [EmailSecuritySummarySpamResponseMetaConfidenceInfo] +type emailSecuritySummarySpamResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySpamResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySpamResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySpamResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailSecuritySummarySpamResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailSecuritySummarySpamResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [EmailSecuritySummarySpamResponseMetaConfidenceInfoAnnotation] +type emailSecuritySummarySpamResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySpamResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySpamResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySpamResponseSummary0 struct { + NotSpam string `json:"NOT_SPAM,required"` + Spam string `json:"SPAM,required"` + JSON emailSecuritySummarySpamResponseSummary0JSON `json:"-"` +} + +// emailSecuritySummarySpamResponseSummary0JSON contains the JSON metadata for the +// struct [EmailSecuritySummarySpamResponseSummary0] +type emailSecuritySummarySpamResponseSummary0JSON struct { + NotSpam apijson.Field + Spam apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySpamResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySpamResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySPFResponse struct { + Meta EmailSecuritySummarySPFResponseMeta `json:"meta,required"` + Summary0 EmailSecuritySummarySPFResponseSummary0 `json:"summary_0,required"` + JSON emailSecuritySummarySPFResponseJSON `json:"-"` +} + +// emailSecuritySummarySPFResponseJSON contains the JSON metadata for the struct +// [EmailSecuritySummarySPFResponse] +type emailSecuritySummarySPFResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySPFResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySPFResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySPFResponseMeta struct { + DateRange []EmailSecuritySummarySPFResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo EmailSecuritySummarySPFResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailSecuritySummarySPFResponseMetaJSON `json:"-"` +} + +// emailSecuritySummarySPFResponseMetaJSON contains the JSON metadata for the +// struct [EmailSecuritySummarySPFResponseMeta] +type emailSecuritySummarySPFResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySPFResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySPFResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySPFResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailSecuritySummarySPFResponseMetaDateRangeJSON `json:"-"` +} + +// emailSecuritySummarySPFResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [EmailSecuritySummarySPFResponseMetaDateRange] +type emailSecuritySummarySPFResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySPFResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySPFResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySPFResponseMetaConfidenceInfo struct { + Annotations []EmailSecuritySummarySPFResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailSecuritySummarySPFResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailSecuritySummarySPFResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [EmailSecuritySummarySPFResponseMetaConfidenceInfo] +type emailSecuritySummarySPFResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySPFResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySPFResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySPFResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailSecuritySummarySPFResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailSecuritySummarySPFResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [EmailSecuritySummarySPFResponseMetaConfidenceInfoAnnotation] +type emailSecuritySummarySPFResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySPFResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySPFResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySPFResponseSummary0 struct { + Fail string `json:"FAIL,required"` + None string `json:"NONE,required"` + Pass string `json:"PASS,required"` + JSON emailSecuritySummarySPFResponseSummary0JSON `json:"-"` +} + +// emailSecuritySummarySPFResponseSummary0JSON contains the JSON metadata for the +// struct [EmailSecuritySummarySPFResponseSummary0] +type emailSecuritySummarySPFResponseSummary0JSON struct { + Fail apijson.Field + None apijson.Field + Pass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySPFResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySPFResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySpoofResponse struct { + Meta EmailSecuritySummarySpoofResponseMeta `json:"meta,required"` + Summary0 EmailSecuritySummarySpoofResponseSummary0 `json:"summary_0,required"` + JSON emailSecuritySummarySpoofResponseJSON `json:"-"` +} + +// emailSecuritySummarySpoofResponseJSON contains the JSON metadata for the struct +// [EmailSecuritySummarySpoofResponse] +type emailSecuritySummarySpoofResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySpoofResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySpoofResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySpoofResponseMeta struct { + DateRange []EmailSecuritySummarySpoofResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo EmailSecuritySummarySpoofResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailSecuritySummarySpoofResponseMetaJSON `json:"-"` +} + +// emailSecuritySummarySpoofResponseMetaJSON contains the JSON metadata for the +// struct [EmailSecuritySummarySpoofResponseMeta] +type emailSecuritySummarySpoofResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySpoofResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySpoofResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySpoofResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailSecuritySummarySpoofResponseMetaDateRangeJSON `json:"-"` +} + +// emailSecuritySummarySpoofResponseMetaDateRangeJSON contains the JSON metadata +// for the struct [EmailSecuritySummarySpoofResponseMetaDateRange] +type emailSecuritySummarySpoofResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySpoofResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySpoofResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySpoofResponseMetaConfidenceInfo struct { + Annotations []EmailSecuritySummarySpoofResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailSecuritySummarySpoofResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailSecuritySummarySpoofResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [EmailSecuritySummarySpoofResponseMetaConfidenceInfo] +type emailSecuritySummarySpoofResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySpoofResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySpoofResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySpoofResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailSecuritySummarySpoofResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailSecuritySummarySpoofResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [EmailSecuritySummarySpoofResponseMetaConfidenceInfoAnnotation] +type emailSecuritySummarySpoofResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySpoofResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySpoofResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySpoofResponseSummary0 struct { + NotSpoof string `json:"NOT_SPOOF,required"` + Spoof string `json:"SPOOF,required"` + JSON emailSecuritySummarySpoofResponseSummary0JSON `json:"-"` +} + +// emailSecuritySummarySpoofResponseSummary0JSON contains the JSON metadata for the +// struct [EmailSecuritySummarySpoofResponseSummary0] +type emailSecuritySummarySpoofResponseSummary0JSON struct { + NotSpoof apijson.Field + Spoof apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySpoofResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySpoofResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryThreatCategoryResponse struct { + Meta EmailSecuritySummaryThreatCategoryResponseMeta `json:"meta,required"` + Summary0 EmailSecuritySummaryThreatCategoryResponseSummary0 `json:"summary_0,required"` + JSON emailSecuritySummaryThreatCategoryResponseJSON `json:"-"` +} + +// emailSecuritySummaryThreatCategoryResponseJSON contains the JSON metadata for +// the struct [EmailSecuritySummaryThreatCategoryResponse] +type emailSecuritySummaryThreatCategoryResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryThreatCategoryResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryThreatCategoryResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryThreatCategoryResponseMeta struct { + DateRange []EmailSecuritySummaryThreatCategoryResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo EmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailSecuritySummaryThreatCategoryResponseMetaJSON `json:"-"` +} + +// emailSecuritySummaryThreatCategoryResponseMetaJSON contains the JSON metadata +// for the struct [EmailSecuritySummaryThreatCategoryResponseMeta] +type emailSecuritySummaryThreatCategoryResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryThreatCategoryResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryThreatCategoryResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryThreatCategoryResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailSecuritySummaryThreatCategoryResponseMetaDateRangeJSON `json:"-"` +} + +// emailSecuritySummaryThreatCategoryResponseMetaDateRangeJSON contains the JSON +// metadata for the struct +// [EmailSecuritySummaryThreatCategoryResponseMetaDateRange] +type emailSecuritySummaryThreatCategoryResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryThreatCategoryResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryThreatCategoryResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfo struct { + Annotations []EmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoJSON contains the +// JSON metadata for the struct +// [EmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfo] +type emailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoAnnotationJSON +// contains the JSON metadata for the struct +// [EmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoAnnotation] +type emailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryThreatCategoryResponseSummary0 struct { + BrandImpersonation string `json:"BrandImpersonation,required"` + CredentialHarvester string `json:"CredentialHarvester,required"` + IdentityDeception string `json:"IdentityDeception,required"` + Link string `json:"Link,required"` + JSON emailSecuritySummaryThreatCategoryResponseSummary0JSON `json:"-"` +} + +// emailSecuritySummaryThreatCategoryResponseSummary0JSON contains the JSON +// metadata for the struct [EmailSecuritySummaryThreatCategoryResponseSummary0] +type emailSecuritySummaryThreatCategoryResponseSummary0JSON struct { + BrandImpersonation apijson.Field + CredentialHarvester apijson.Field + IdentityDeception apijson.Field + Link apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryThreatCategoryResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryThreatCategoryResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryTLSVersionResponse struct { + Meta EmailSecuritySummaryTLSVersionResponseMeta `json:"meta,required"` + Summary0 EmailSecuritySummaryTLSVersionResponseSummary0 `json:"summary_0,required"` + JSON emailSecuritySummaryTLSVersionResponseJSON `json:"-"` +} + +// emailSecuritySummaryTLSVersionResponseJSON contains the JSON metadata for the +// struct [EmailSecuritySummaryTLSVersionResponse] +type emailSecuritySummaryTLSVersionResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryTLSVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryTLSVersionResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryTLSVersionResponseMeta struct { + DateRange []EmailSecuritySummaryTLSVersionResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo EmailSecuritySummaryTLSVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailSecuritySummaryTLSVersionResponseMetaJSON `json:"-"` +} + +// emailSecuritySummaryTLSVersionResponseMetaJSON contains the JSON metadata for +// the struct [EmailSecuritySummaryTLSVersionResponseMeta] +type emailSecuritySummaryTLSVersionResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryTLSVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryTLSVersionResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryTLSVersionResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailSecuritySummaryTLSVersionResponseMetaDateRangeJSON `json:"-"` +} + +// emailSecuritySummaryTLSVersionResponseMetaDateRangeJSON contains the JSON +// metadata for the struct [EmailSecuritySummaryTLSVersionResponseMetaDateRange] +type emailSecuritySummaryTLSVersionResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryTLSVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryTLSVersionResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryTLSVersionResponseMetaConfidenceInfo struct { + Annotations []EmailSecuritySummaryTLSVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailSecuritySummaryTLSVersionResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailSecuritySummaryTLSVersionResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct +// [EmailSecuritySummaryTLSVersionResponseMetaConfidenceInfo] +type emailSecuritySummaryTLSVersionResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryTLSVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryTLSVersionResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryTLSVersionResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailSecuritySummaryTLSVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailSecuritySummaryTLSVersionResponseMetaConfidenceInfoAnnotationJSON contains +// the JSON metadata for the struct +// [EmailSecuritySummaryTLSVersionResponseMetaConfidenceInfoAnnotation] +type emailSecuritySummaryTLSVersionResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryTLSVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryTLSVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryTLSVersionResponseSummary0 struct { + TLS1_0 string `json:"TLS 1.0,required"` + TLS1_1 string `json:"TLS 1.1,required"` + TLS1_2 string `json:"TLS 1.2,required"` + TLS1_3 string `json:"TLS 1.3,required"` + JSON emailSecuritySummaryTLSVersionResponseSummary0JSON `json:"-"` +} + +// emailSecuritySummaryTLSVersionResponseSummary0JSON contains the JSON metadata +// for the struct [EmailSecuritySummaryTLSVersionResponseSummary0] +type emailSecuritySummaryTLSVersionResponseSummary0JSON struct { + TLS1_0 apijson.Field + TLS1_1 apijson.Field + TLS1_2 apijson.Field + TLS1_3 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryTLSVersionResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryTLSVersionResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryARCParams struct { + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecuritySummaryARCParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecuritySummaryARCParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecuritySummaryARCParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecuritySummaryARCParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecuritySummaryARCParamsSPF] `query:"spf"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecuritySummaryARCParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecuritySummaryARCParams]'s query parameters as +// `url.Values`. +func (r EmailSecuritySummaryARCParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type EmailSecuritySummaryARCParamsDateRange string + +const ( + EmailSecuritySummaryARCParamsDateRange1d EmailSecuritySummaryARCParamsDateRange = "1d" + EmailSecuritySummaryARCParamsDateRange2d EmailSecuritySummaryARCParamsDateRange = "2d" + EmailSecuritySummaryARCParamsDateRange7d EmailSecuritySummaryARCParamsDateRange = "7d" + EmailSecuritySummaryARCParamsDateRange14d EmailSecuritySummaryARCParamsDateRange = "14d" + EmailSecuritySummaryARCParamsDateRange28d EmailSecuritySummaryARCParamsDateRange = "28d" + EmailSecuritySummaryARCParamsDateRange12w EmailSecuritySummaryARCParamsDateRange = "12w" + EmailSecuritySummaryARCParamsDateRange24w EmailSecuritySummaryARCParamsDateRange = "24w" + EmailSecuritySummaryARCParamsDateRange52w EmailSecuritySummaryARCParamsDateRange = "52w" + EmailSecuritySummaryARCParamsDateRange1dControl EmailSecuritySummaryARCParamsDateRange = "1dControl" + EmailSecuritySummaryARCParamsDateRange2dControl EmailSecuritySummaryARCParamsDateRange = "2dControl" + EmailSecuritySummaryARCParamsDateRange7dControl EmailSecuritySummaryARCParamsDateRange = "7dControl" + EmailSecuritySummaryARCParamsDateRange14dControl EmailSecuritySummaryARCParamsDateRange = "14dControl" + EmailSecuritySummaryARCParamsDateRange28dControl EmailSecuritySummaryARCParamsDateRange = "28dControl" + EmailSecuritySummaryARCParamsDateRange12wControl EmailSecuritySummaryARCParamsDateRange = "12wControl" + EmailSecuritySummaryARCParamsDateRange24wControl EmailSecuritySummaryARCParamsDateRange = "24wControl" +) + +type EmailSecuritySummaryARCParamsDKIM string + +const ( + EmailSecuritySummaryARCParamsDKIMPass EmailSecuritySummaryARCParamsDKIM = "PASS" + EmailSecuritySummaryARCParamsDKIMNone EmailSecuritySummaryARCParamsDKIM = "NONE" + EmailSecuritySummaryARCParamsDKIMFail EmailSecuritySummaryARCParamsDKIM = "FAIL" +) + +type EmailSecuritySummaryARCParamsDMARC string + +const ( + EmailSecuritySummaryARCParamsDMARCPass EmailSecuritySummaryARCParamsDMARC = "PASS" + EmailSecuritySummaryARCParamsDMARCNone EmailSecuritySummaryARCParamsDMARC = "NONE" + EmailSecuritySummaryARCParamsDMARCFail EmailSecuritySummaryARCParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecuritySummaryARCParamsFormat string + +const ( + EmailSecuritySummaryARCParamsFormatJson EmailSecuritySummaryARCParamsFormat = "JSON" + EmailSecuritySummaryARCParamsFormatCsv EmailSecuritySummaryARCParamsFormat = "CSV" +) + +type EmailSecuritySummaryARCParamsSPF string + +const ( + EmailSecuritySummaryARCParamsSPFPass EmailSecuritySummaryARCParamsSPF = "PASS" + EmailSecuritySummaryARCParamsSPFNone EmailSecuritySummaryARCParamsSPF = "NONE" + EmailSecuritySummaryARCParamsSPFFail EmailSecuritySummaryARCParamsSPF = "FAIL" +) + +type EmailSecuritySummaryARCParamsTLSVersion string + +const ( + EmailSecuritySummaryARCParamsTLSVersionTlSv1_0 EmailSecuritySummaryARCParamsTLSVersion = "TLSv1_0" + EmailSecuritySummaryARCParamsTLSVersionTlSv1_1 EmailSecuritySummaryARCParamsTLSVersion = "TLSv1_1" + EmailSecuritySummaryARCParamsTLSVersionTlSv1_2 EmailSecuritySummaryARCParamsTLSVersion = "TLSv1_2" + EmailSecuritySummaryARCParamsTLSVersionTlSv1_3 EmailSecuritySummaryARCParamsTLSVersion = "TLSv1_3" +) + +type EmailSecuritySummaryARCResponseEnvelope struct { + Result EmailSecuritySummaryARCResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecuritySummaryARCResponseEnvelopeJSON `json:"-"` +} + +// emailSecuritySummaryARCResponseEnvelopeJSON contains the JSON metadata for the +// struct [EmailSecuritySummaryARCResponseEnvelope] +type emailSecuritySummaryARCResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryARCResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryARCResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryDKIMParams struct { + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecuritySummaryDKIMParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecuritySummaryDKIMParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecuritySummaryDKIMParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecuritySummaryDKIMParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecuritySummaryDKIMParamsSPF] `query:"spf"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecuritySummaryDKIMParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecuritySummaryDKIMParams]'s query parameters as +// `url.Values`. +func (r EmailSecuritySummaryDKIMParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type EmailSecuritySummaryDKIMParamsARC string + +const ( + EmailSecuritySummaryDKIMParamsARCPass EmailSecuritySummaryDKIMParamsARC = "PASS" + EmailSecuritySummaryDKIMParamsARCNone EmailSecuritySummaryDKIMParamsARC = "NONE" + EmailSecuritySummaryDKIMParamsARCFail EmailSecuritySummaryDKIMParamsARC = "FAIL" +) + +type EmailSecuritySummaryDKIMParamsDateRange string + +const ( + EmailSecuritySummaryDKIMParamsDateRange1d EmailSecuritySummaryDKIMParamsDateRange = "1d" + EmailSecuritySummaryDKIMParamsDateRange2d EmailSecuritySummaryDKIMParamsDateRange = "2d" + EmailSecuritySummaryDKIMParamsDateRange7d EmailSecuritySummaryDKIMParamsDateRange = "7d" + EmailSecuritySummaryDKIMParamsDateRange14d EmailSecuritySummaryDKIMParamsDateRange = "14d" + EmailSecuritySummaryDKIMParamsDateRange28d EmailSecuritySummaryDKIMParamsDateRange = "28d" + EmailSecuritySummaryDKIMParamsDateRange12w EmailSecuritySummaryDKIMParamsDateRange = "12w" + EmailSecuritySummaryDKIMParamsDateRange24w EmailSecuritySummaryDKIMParamsDateRange = "24w" + EmailSecuritySummaryDKIMParamsDateRange52w EmailSecuritySummaryDKIMParamsDateRange = "52w" + EmailSecuritySummaryDKIMParamsDateRange1dControl EmailSecuritySummaryDKIMParamsDateRange = "1dControl" + EmailSecuritySummaryDKIMParamsDateRange2dControl EmailSecuritySummaryDKIMParamsDateRange = "2dControl" + EmailSecuritySummaryDKIMParamsDateRange7dControl EmailSecuritySummaryDKIMParamsDateRange = "7dControl" + EmailSecuritySummaryDKIMParamsDateRange14dControl EmailSecuritySummaryDKIMParamsDateRange = "14dControl" + EmailSecuritySummaryDKIMParamsDateRange28dControl EmailSecuritySummaryDKIMParamsDateRange = "28dControl" + EmailSecuritySummaryDKIMParamsDateRange12wControl EmailSecuritySummaryDKIMParamsDateRange = "12wControl" + EmailSecuritySummaryDKIMParamsDateRange24wControl EmailSecuritySummaryDKIMParamsDateRange = "24wControl" +) + +type EmailSecuritySummaryDKIMParamsDMARC string + +const ( + EmailSecuritySummaryDKIMParamsDMARCPass EmailSecuritySummaryDKIMParamsDMARC = "PASS" + EmailSecuritySummaryDKIMParamsDMARCNone EmailSecuritySummaryDKIMParamsDMARC = "NONE" + EmailSecuritySummaryDKIMParamsDMARCFail EmailSecuritySummaryDKIMParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecuritySummaryDKIMParamsFormat string + +const ( + EmailSecuritySummaryDKIMParamsFormatJson EmailSecuritySummaryDKIMParamsFormat = "JSON" + EmailSecuritySummaryDKIMParamsFormatCsv EmailSecuritySummaryDKIMParamsFormat = "CSV" +) + +type EmailSecuritySummaryDKIMParamsSPF string + +const ( + EmailSecuritySummaryDKIMParamsSPFPass EmailSecuritySummaryDKIMParamsSPF = "PASS" + EmailSecuritySummaryDKIMParamsSPFNone EmailSecuritySummaryDKIMParamsSPF = "NONE" + EmailSecuritySummaryDKIMParamsSPFFail EmailSecuritySummaryDKIMParamsSPF = "FAIL" +) + +type EmailSecuritySummaryDKIMParamsTLSVersion string + +const ( + EmailSecuritySummaryDKIMParamsTLSVersionTlSv1_0 EmailSecuritySummaryDKIMParamsTLSVersion = "TLSv1_0" + EmailSecuritySummaryDKIMParamsTLSVersionTlSv1_1 EmailSecuritySummaryDKIMParamsTLSVersion = "TLSv1_1" + EmailSecuritySummaryDKIMParamsTLSVersionTlSv1_2 EmailSecuritySummaryDKIMParamsTLSVersion = "TLSv1_2" + EmailSecuritySummaryDKIMParamsTLSVersionTlSv1_3 EmailSecuritySummaryDKIMParamsTLSVersion = "TLSv1_3" +) + +type EmailSecuritySummaryDKIMResponseEnvelope struct { + Result EmailSecuritySummaryDKIMResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecuritySummaryDKIMResponseEnvelopeJSON `json:"-"` +} + +// emailSecuritySummaryDKIMResponseEnvelopeJSON contains the JSON metadata for the +// struct [EmailSecuritySummaryDKIMResponseEnvelope] +type emailSecuritySummaryDKIMResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryDKIMResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryDKIMResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryDMARCParams struct { + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecuritySummaryDMARCParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecuritySummaryDMARCParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecuritySummaryDMARCParamsDKIM] `query:"dkim"` + // Format results are returned in. + Format param.Field[EmailSecuritySummaryDMARCParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecuritySummaryDMARCParamsSPF] `query:"spf"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecuritySummaryDMARCParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecuritySummaryDMARCParams]'s query parameters as +// `url.Values`. +func (r EmailSecuritySummaryDMARCParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type EmailSecuritySummaryDMARCParamsARC string + +const ( + EmailSecuritySummaryDMARCParamsARCPass EmailSecuritySummaryDMARCParamsARC = "PASS" + EmailSecuritySummaryDMARCParamsARCNone EmailSecuritySummaryDMARCParamsARC = "NONE" + EmailSecuritySummaryDMARCParamsARCFail EmailSecuritySummaryDMARCParamsARC = "FAIL" +) + +type EmailSecuritySummaryDMARCParamsDateRange string + +const ( + EmailSecuritySummaryDMARCParamsDateRange1d EmailSecuritySummaryDMARCParamsDateRange = "1d" + EmailSecuritySummaryDMARCParamsDateRange2d EmailSecuritySummaryDMARCParamsDateRange = "2d" + EmailSecuritySummaryDMARCParamsDateRange7d EmailSecuritySummaryDMARCParamsDateRange = "7d" + EmailSecuritySummaryDMARCParamsDateRange14d EmailSecuritySummaryDMARCParamsDateRange = "14d" + EmailSecuritySummaryDMARCParamsDateRange28d EmailSecuritySummaryDMARCParamsDateRange = "28d" + EmailSecuritySummaryDMARCParamsDateRange12w EmailSecuritySummaryDMARCParamsDateRange = "12w" + EmailSecuritySummaryDMARCParamsDateRange24w EmailSecuritySummaryDMARCParamsDateRange = "24w" + EmailSecuritySummaryDMARCParamsDateRange52w EmailSecuritySummaryDMARCParamsDateRange = "52w" + EmailSecuritySummaryDMARCParamsDateRange1dControl EmailSecuritySummaryDMARCParamsDateRange = "1dControl" + EmailSecuritySummaryDMARCParamsDateRange2dControl EmailSecuritySummaryDMARCParamsDateRange = "2dControl" + EmailSecuritySummaryDMARCParamsDateRange7dControl EmailSecuritySummaryDMARCParamsDateRange = "7dControl" + EmailSecuritySummaryDMARCParamsDateRange14dControl EmailSecuritySummaryDMARCParamsDateRange = "14dControl" + EmailSecuritySummaryDMARCParamsDateRange28dControl EmailSecuritySummaryDMARCParamsDateRange = "28dControl" + EmailSecuritySummaryDMARCParamsDateRange12wControl EmailSecuritySummaryDMARCParamsDateRange = "12wControl" + EmailSecuritySummaryDMARCParamsDateRange24wControl EmailSecuritySummaryDMARCParamsDateRange = "24wControl" +) + +type EmailSecuritySummaryDMARCParamsDKIM string + +const ( + EmailSecuritySummaryDMARCParamsDKIMPass EmailSecuritySummaryDMARCParamsDKIM = "PASS" + EmailSecuritySummaryDMARCParamsDKIMNone EmailSecuritySummaryDMARCParamsDKIM = "NONE" + EmailSecuritySummaryDMARCParamsDKIMFail EmailSecuritySummaryDMARCParamsDKIM = "FAIL" +) + +// Format results are returned in. +type EmailSecuritySummaryDMARCParamsFormat string + +const ( + EmailSecuritySummaryDMARCParamsFormatJson EmailSecuritySummaryDMARCParamsFormat = "JSON" + EmailSecuritySummaryDMARCParamsFormatCsv EmailSecuritySummaryDMARCParamsFormat = "CSV" +) + +type EmailSecuritySummaryDMARCParamsSPF string + +const ( + EmailSecuritySummaryDMARCParamsSPFPass EmailSecuritySummaryDMARCParamsSPF = "PASS" + EmailSecuritySummaryDMARCParamsSPFNone EmailSecuritySummaryDMARCParamsSPF = "NONE" + EmailSecuritySummaryDMARCParamsSPFFail EmailSecuritySummaryDMARCParamsSPF = "FAIL" +) + +type EmailSecuritySummaryDMARCParamsTLSVersion string + +const ( + EmailSecuritySummaryDMARCParamsTLSVersionTlSv1_0 EmailSecuritySummaryDMARCParamsTLSVersion = "TLSv1_0" + EmailSecuritySummaryDMARCParamsTLSVersionTlSv1_1 EmailSecuritySummaryDMARCParamsTLSVersion = "TLSv1_1" + EmailSecuritySummaryDMARCParamsTLSVersionTlSv1_2 EmailSecuritySummaryDMARCParamsTLSVersion = "TLSv1_2" + EmailSecuritySummaryDMARCParamsTLSVersionTlSv1_3 EmailSecuritySummaryDMARCParamsTLSVersion = "TLSv1_3" +) + +type EmailSecuritySummaryDMARCResponseEnvelope struct { + Result EmailSecuritySummaryDMARCResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecuritySummaryDMARCResponseEnvelopeJSON `json:"-"` +} + +// emailSecuritySummaryDMARCResponseEnvelopeJSON contains the JSON metadata for the +// struct [EmailSecuritySummaryDMARCResponseEnvelope] +type emailSecuritySummaryDMARCResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryDMARCResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryDMARCResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryMaliciousParams struct { + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecuritySummaryMaliciousParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecuritySummaryMaliciousParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecuritySummaryMaliciousParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecuritySummaryMaliciousParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecuritySummaryMaliciousParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecuritySummaryMaliciousParamsSPF] `query:"spf"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecuritySummaryMaliciousParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecuritySummaryMaliciousParams]'s query parameters as +// `url.Values`. +func (r EmailSecuritySummaryMaliciousParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type EmailSecuritySummaryMaliciousParamsARC string + +const ( + EmailSecuritySummaryMaliciousParamsARCPass EmailSecuritySummaryMaliciousParamsARC = "PASS" + EmailSecuritySummaryMaliciousParamsARCNone EmailSecuritySummaryMaliciousParamsARC = "NONE" + EmailSecuritySummaryMaliciousParamsARCFail EmailSecuritySummaryMaliciousParamsARC = "FAIL" +) + +type EmailSecuritySummaryMaliciousParamsDateRange string + +const ( + EmailSecuritySummaryMaliciousParamsDateRange1d EmailSecuritySummaryMaliciousParamsDateRange = "1d" + EmailSecuritySummaryMaliciousParamsDateRange2d EmailSecuritySummaryMaliciousParamsDateRange = "2d" + EmailSecuritySummaryMaliciousParamsDateRange7d EmailSecuritySummaryMaliciousParamsDateRange = "7d" + EmailSecuritySummaryMaliciousParamsDateRange14d EmailSecuritySummaryMaliciousParamsDateRange = "14d" + EmailSecuritySummaryMaliciousParamsDateRange28d EmailSecuritySummaryMaliciousParamsDateRange = "28d" + EmailSecuritySummaryMaliciousParamsDateRange12w EmailSecuritySummaryMaliciousParamsDateRange = "12w" + EmailSecuritySummaryMaliciousParamsDateRange24w EmailSecuritySummaryMaliciousParamsDateRange = "24w" + EmailSecuritySummaryMaliciousParamsDateRange52w EmailSecuritySummaryMaliciousParamsDateRange = "52w" + EmailSecuritySummaryMaliciousParamsDateRange1dControl EmailSecuritySummaryMaliciousParamsDateRange = "1dControl" + EmailSecuritySummaryMaliciousParamsDateRange2dControl EmailSecuritySummaryMaliciousParamsDateRange = "2dControl" + EmailSecuritySummaryMaliciousParamsDateRange7dControl EmailSecuritySummaryMaliciousParamsDateRange = "7dControl" + EmailSecuritySummaryMaliciousParamsDateRange14dControl EmailSecuritySummaryMaliciousParamsDateRange = "14dControl" + EmailSecuritySummaryMaliciousParamsDateRange28dControl EmailSecuritySummaryMaliciousParamsDateRange = "28dControl" + EmailSecuritySummaryMaliciousParamsDateRange12wControl EmailSecuritySummaryMaliciousParamsDateRange = "12wControl" + EmailSecuritySummaryMaliciousParamsDateRange24wControl EmailSecuritySummaryMaliciousParamsDateRange = "24wControl" +) + +type EmailSecuritySummaryMaliciousParamsDKIM string + +const ( + EmailSecuritySummaryMaliciousParamsDKIMPass EmailSecuritySummaryMaliciousParamsDKIM = "PASS" + EmailSecuritySummaryMaliciousParamsDKIMNone EmailSecuritySummaryMaliciousParamsDKIM = "NONE" + EmailSecuritySummaryMaliciousParamsDKIMFail EmailSecuritySummaryMaliciousParamsDKIM = "FAIL" +) + +type EmailSecuritySummaryMaliciousParamsDMARC string + +const ( + EmailSecuritySummaryMaliciousParamsDMARCPass EmailSecuritySummaryMaliciousParamsDMARC = "PASS" + EmailSecuritySummaryMaliciousParamsDMARCNone EmailSecuritySummaryMaliciousParamsDMARC = "NONE" + EmailSecuritySummaryMaliciousParamsDMARCFail EmailSecuritySummaryMaliciousParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecuritySummaryMaliciousParamsFormat string + +const ( + EmailSecuritySummaryMaliciousParamsFormatJson EmailSecuritySummaryMaliciousParamsFormat = "JSON" + EmailSecuritySummaryMaliciousParamsFormatCsv EmailSecuritySummaryMaliciousParamsFormat = "CSV" +) + +type EmailSecuritySummaryMaliciousParamsSPF string + +const ( + EmailSecuritySummaryMaliciousParamsSPFPass EmailSecuritySummaryMaliciousParamsSPF = "PASS" + EmailSecuritySummaryMaliciousParamsSPFNone EmailSecuritySummaryMaliciousParamsSPF = "NONE" + EmailSecuritySummaryMaliciousParamsSPFFail EmailSecuritySummaryMaliciousParamsSPF = "FAIL" +) + +type EmailSecuritySummaryMaliciousParamsTLSVersion string + +const ( + EmailSecuritySummaryMaliciousParamsTLSVersionTlSv1_0 EmailSecuritySummaryMaliciousParamsTLSVersion = "TLSv1_0" + EmailSecuritySummaryMaliciousParamsTLSVersionTlSv1_1 EmailSecuritySummaryMaliciousParamsTLSVersion = "TLSv1_1" + EmailSecuritySummaryMaliciousParamsTLSVersionTlSv1_2 EmailSecuritySummaryMaliciousParamsTLSVersion = "TLSv1_2" + EmailSecuritySummaryMaliciousParamsTLSVersionTlSv1_3 EmailSecuritySummaryMaliciousParamsTLSVersion = "TLSv1_3" +) + +type EmailSecuritySummaryMaliciousResponseEnvelope struct { + Result EmailSecuritySummaryMaliciousResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecuritySummaryMaliciousResponseEnvelopeJSON `json:"-"` +} + +// emailSecuritySummaryMaliciousResponseEnvelopeJSON contains the JSON metadata for +// the struct [EmailSecuritySummaryMaliciousResponseEnvelope] +type emailSecuritySummaryMaliciousResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryMaliciousResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryMaliciousResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySpamParams struct { + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecuritySummarySpamParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecuritySummarySpamParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecuritySummarySpamParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecuritySummarySpamParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecuritySummarySpamParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecuritySummarySpamParamsSPF] `query:"spf"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecuritySummarySpamParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecuritySummarySpamParams]'s query parameters as +// `url.Values`. +func (r EmailSecuritySummarySpamParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type EmailSecuritySummarySpamParamsARC string + +const ( + EmailSecuritySummarySpamParamsARCPass EmailSecuritySummarySpamParamsARC = "PASS" + EmailSecuritySummarySpamParamsARCNone EmailSecuritySummarySpamParamsARC = "NONE" + EmailSecuritySummarySpamParamsARCFail EmailSecuritySummarySpamParamsARC = "FAIL" +) + +type EmailSecuritySummarySpamParamsDateRange string + +const ( + EmailSecuritySummarySpamParamsDateRange1d EmailSecuritySummarySpamParamsDateRange = "1d" + EmailSecuritySummarySpamParamsDateRange2d EmailSecuritySummarySpamParamsDateRange = "2d" + EmailSecuritySummarySpamParamsDateRange7d EmailSecuritySummarySpamParamsDateRange = "7d" + EmailSecuritySummarySpamParamsDateRange14d EmailSecuritySummarySpamParamsDateRange = "14d" + EmailSecuritySummarySpamParamsDateRange28d EmailSecuritySummarySpamParamsDateRange = "28d" + EmailSecuritySummarySpamParamsDateRange12w EmailSecuritySummarySpamParamsDateRange = "12w" + EmailSecuritySummarySpamParamsDateRange24w EmailSecuritySummarySpamParamsDateRange = "24w" + EmailSecuritySummarySpamParamsDateRange52w EmailSecuritySummarySpamParamsDateRange = "52w" + EmailSecuritySummarySpamParamsDateRange1dControl EmailSecuritySummarySpamParamsDateRange = "1dControl" + EmailSecuritySummarySpamParamsDateRange2dControl EmailSecuritySummarySpamParamsDateRange = "2dControl" + EmailSecuritySummarySpamParamsDateRange7dControl EmailSecuritySummarySpamParamsDateRange = "7dControl" + EmailSecuritySummarySpamParamsDateRange14dControl EmailSecuritySummarySpamParamsDateRange = "14dControl" + EmailSecuritySummarySpamParamsDateRange28dControl EmailSecuritySummarySpamParamsDateRange = "28dControl" + EmailSecuritySummarySpamParamsDateRange12wControl EmailSecuritySummarySpamParamsDateRange = "12wControl" + EmailSecuritySummarySpamParamsDateRange24wControl EmailSecuritySummarySpamParamsDateRange = "24wControl" +) + +type EmailSecuritySummarySpamParamsDKIM string + +const ( + EmailSecuritySummarySpamParamsDKIMPass EmailSecuritySummarySpamParamsDKIM = "PASS" + EmailSecuritySummarySpamParamsDKIMNone EmailSecuritySummarySpamParamsDKIM = "NONE" + EmailSecuritySummarySpamParamsDKIMFail EmailSecuritySummarySpamParamsDKIM = "FAIL" +) + +type EmailSecuritySummarySpamParamsDMARC string + +const ( + EmailSecuritySummarySpamParamsDMARCPass EmailSecuritySummarySpamParamsDMARC = "PASS" + EmailSecuritySummarySpamParamsDMARCNone EmailSecuritySummarySpamParamsDMARC = "NONE" + EmailSecuritySummarySpamParamsDMARCFail EmailSecuritySummarySpamParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecuritySummarySpamParamsFormat string + +const ( + EmailSecuritySummarySpamParamsFormatJson EmailSecuritySummarySpamParamsFormat = "JSON" + EmailSecuritySummarySpamParamsFormatCsv EmailSecuritySummarySpamParamsFormat = "CSV" +) + +type EmailSecuritySummarySpamParamsSPF string + +const ( + EmailSecuritySummarySpamParamsSPFPass EmailSecuritySummarySpamParamsSPF = "PASS" + EmailSecuritySummarySpamParamsSPFNone EmailSecuritySummarySpamParamsSPF = "NONE" + EmailSecuritySummarySpamParamsSPFFail EmailSecuritySummarySpamParamsSPF = "FAIL" +) + +type EmailSecuritySummarySpamParamsTLSVersion string + +const ( + EmailSecuritySummarySpamParamsTLSVersionTlSv1_0 EmailSecuritySummarySpamParamsTLSVersion = "TLSv1_0" + EmailSecuritySummarySpamParamsTLSVersionTlSv1_1 EmailSecuritySummarySpamParamsTLSVersion = "TLSv1_1" + EmailSecuritySummarySpamParamsTLSVersionTlSv1_2 EmailSecuritySummarySpamParamsTLSVersion = "TLSv1_2" + EmailSecuritySummarySpamParamsTLSVersionTlSv1_3 EmailSecuritySummarySpamParamsTLSVersion = "TLSv1_3" +) + +type EmailSecuritySummarySpamResponseEnvelope struct { + Result EmailSecuritySummarySpamResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecuritySummarySpamResponseEnvelopeJSON `json:"-"` +} + +// emailSecuritySummarySpamResponseEnvelopeJSON contains the JSON metadata for the +// struct [EmailSecuritySummarySpamResponseEnvelope] +type emailSecuritySummarySpamResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySpamResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySpamResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySPFParams struct { + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecuritySummarySPFParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecuritySummarySPFParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecuritySummarySPFParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecuritySummarySPFParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecuritySummarySPFParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecuritySummarySPFParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecuritySummarySPFParams]'s query parameters as +// `url.Values`. +func (r EmailSecuritySummarySPFParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type EmailSecuritySummarySPFParamsARC string + +const ( + EmailSecuritySummarySPFParamsARCPass EmailSecuritySummarySPFParamsARC = "PASS" + EmailSecuritySummarySPFParamsARCNone EmailSecuritySummarySPFParamsARC = "NONE" + EmailSecuritySummarySPFParamsARCFail EmailSecuritySummarySPFParamsARC = "FAIL" +) + +type EmailSecuritySummarySPFParamsDateRange string + +const ( + EmailSecuritySummarySPFParamsDateRange1d EmailSecuritySummarySPFParamsDateRange = "1d" + EmailSecuritySummarySPFParamsDateRange2d EmailSecuritySummarySPFParamsDateRange = "2d" + EmailSecuritySummarySPFParamsDateRange7d EmailSecuritySummarySPFParamsDateRange = "7d" + EmailSecuritySummarySPFParamsDateRange14d EmailSecuritySummarySPFParamsDateRange = "14d" + EmailSecuritySummarySPFParamsDateRange28d EmailSecuritySummarySPFParamsDateRange = "28d" + EmailSecuritySummarySPFParamsDateRange12w EmailSecuritySummarySPFParamsDateRange = "12w" + EmailSecuritySummarySPFParamsDateRange24w EmailSecuritySummarySPFParamsDateRange = "24w" + EmailSecuritySummarySPFParamsDateRange52w EmailSecuritySummarySPFParamsDateRange = "52w" + EmailSecuritySummarySPFParamsDateRange1dControl EmailSecuritySummarySPFParamsDateRange = "1dControl" + EmailSecuritySummarySPFParamsDateRange2dControl EmailSecuritySummarySPFParamsDateRange = "2dControl" + EmailSecuritySummarySPFParamsDateRange7dControl EmailSecuritySummarySPFParamsDateRange = "7dControl" + EmailSecuritySummarySPFParamsDateRange14dControl EmailSecuritySummarySPFParamsDateRange = "14dControl" + EmailSecuritySummarySPFParamsDateRange28dControl EmailSecuritySummarySPFParamsDateRange = "28dControl" + EmailSecuritySummarySPFParamsDateRange12wControl EmailSecuritySummarySPFParamsDateRange = "12wControl" + EmailSecuritySummarySPFParamsDateRange24wControl EmailSecuritySummarySPFParamsDateRange = "24wControl" +) + +type EmailSecuritySummarySPFParamsDKIM string + +const ( + EmailSecuritySummarySPFParamsDKIMPass EmailSecuritySummarySPFParamsDKIM = "PASS" + EmailSecuritySummarySPFParamsDKIMNone EmailSecuritySummarySPFParamsDKIM = "NONE" + EmailSecuritySummarySPFParamsDKIMFail EmailSecuritySummarySPFParamsDKIM = "FAIL" +) + +type EmailSecuritySummarySPFParamsDMARC string + +const ( + EmailSecuritySummarySPFParamsDMARCPass EmailSecuritySummarySPFParamsDMARC = "PASS" + EmailSecuritySummarySPFParamsDMARCNone EmailSecuritySummarySPFParamsDMARC = "NONE" + EmailSecuritySummarySPFParamsDMARCFail EmailSecuritySummarySPFParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecuritySummarySPFParamsFormat string + +const ( + EmailSecuritySummarySPFParamsFormatJson EmailSecuritySummarySPFParamsFormat = "JSON" + EmailSecuritySummarySPFParamsFormatCsv EmailSecuritySummarySPFParamsFormat = "CSV" +) + +type EmailSecuritySummarySPFParamsTLSVersion string + +const ( + EmailSecuritySummarySPFParamsTLSVersionTlSv1_0 EmailSecuritySummarySPFParamsTLSVersion = "TLSv1_0" + EmailSecuritySummarySPFParamsTLSVersionTlSv1_1 EmailSecuritySummarySPFParamsTLSVersion = "TLSv1_1" + EmailSecuritySummarySPFParamsTLSVersionTlSv1_2 EmailSecuritySummarySPFParamsTLSVersion = "TLSv1_2" + EmailSecuritySummarySPFParamsTLSVersionTlSv1_3 EmailSecuritySummarySPFParamsTLSVersion = "TLSv1_3" +) + +type EmailSecuritySummarySPFResponseEnvelope struct { + Result EmailSecuritySummarySPFResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecuritySummarySPFResponseEnvelopeJSON `json:"-"` +} + +// emailSecuritySummarySPFResponseEnvelopeJSON contains the JSON metadata for the +// struct [EmailSecuritySummarySPFResponseEnvelope] +type emailSecuritySummarySPFResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySPFResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySPFResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummarySpoofParams struct { + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecuritySummarySpoofParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecuritySummarySpoofParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecuritySummarySpoofParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecuritySummarySpoofParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecuritySummarySpoofParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecuritySummarySpoofParamsSPF] `query:"spf"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecuritySummarySpoofParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecuritySummarySpoofParams]'s query parameters as +// `url.Values`. +func (r EmailSecuritySummarySpoofParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type EmailSecuritySummarySpoofParamsARC string + +const ( + EmailSecuritySummarySpoofParamsARCPass EmailSecuritySummarySpoofParamsARC = "PASS" + EmailSecuritySummarySpoofParamsARCNone EmailSecuritySummarySpoofParamsARC = "NONE" + EmailSecuritySummarySpoofParamsARCFail EmailSecuritySummarySpoofParamsARC = "FAIL" +) + +type EmailSecuritySummarySpoofParamsDateRange string + +const ( + EmailSecuritySummarySpoofParamsDateRange1d EmailSecuritySummarySpoofParamsDateRange = "1d" + EmailSecuritySummarySpoofParamsDateRange2d EmailSecuritySummarySpoofParamsDateRange = "2d" + EmailSecuritySummarySpoofParamsDateRange7d EmailSecuritySummarySpoofParamsDateRange = "7d" + EmailSecuritySummarySpoofParamsDateRange14d EmailSecuritySummarySpoofParamsDateRange = "14d" + EmailSecuritySummarySpoofParamsDateRange28d EmailSecuritySummarySpoofParamsDateRange = "28d" + EmailSecuritySummarySpoofParamsDateRange12w EmailSecuritySummarySpoofParamsDateRange = "12w" + EmailSecuritySummarySpoofParamsDateRange24w EmailSecuritySummarySpoofParamsDateRange = "24w" + EmailSecuritySummarySpoofParamsDateRange52w EmailSecuritySummarySpoofParamsDateRange = "52w" + EmailSecuritySummarySpoofParamsDateRange1dControl EmailSecuritySummarySpoofParamsDateRange = "1dControl" + EmailSecuritySummarySpoofParamsDateRange2dControl EmailSecuritySummarySpoofParamsDateRange = "2dControl" + EmailSecuritySummarySpoofParamsDateRange7dControl EmailSecuritySummarySpoofParamsDateRange = "7dControl" + EmailSecuritySummarySpoofParamsDateRange14dControl EmailSecuritySummarySpoofParamsDateRange = "14dControl" + EmailSecuritySummarySpoofParamsDateRange28dControl EmailSecuritySummarySpoofParamsDateRange = "28dControl" + EmailSecuritySummarySpoofParamsDateRange12wControl EmailSecuritySummarySpoofParamsDateRange = "12wControl" + EmailSecuritySummarySpoofParamsDateRange24wControl EmailSecuritySummarySpoofParamsDateRange = "24wControl" +) + +type EmailSecuritySummarySpoofParamsDKIM string + +const ( + EmailSecuritySummarySpoofParamsDKIMPass EmailSecuritySummarySpoofParamsDKIM = "PASS" + EmailSecuritySummarySpoofParamsDKIMNone EmailSecuritySummarySpoofParamsDKIM = "NONE" + EmailSecuritySummarySpoofParamsDKIMFail EmailSecuritySummarySpoofParamsDKIM = "FAIL" +) + +type EmailSecuritySummarySpoofParamsDMARC string + +const ( + EmailSecuritySummarySpoofParamsDMARCPass EmailSecuritySummarySpoofParamsDMARC = "PASS" + EmailSecuritySummarySpoofParamsDMARCNone EmailSecuritySummarySpoofParamsDMARC = "NONE" + EmailSecuritySummarySpoofParamsDMARCFail EmailSecuritySummarySpoofParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecuritySummarySpoofParamsFormat string + +const ( + EmailSecuritySummarySpoofParamsFormatJson EmailSecuritySummarySpoofParamsFormat = "JSON" + EmailSecuritySummarySpoofParamsFormatCsv EmailSecuritySummarySpoofParamsFormat = "CSV" +) + +type EmailSecuritySummarySpoofParamsSPF string + +const ( + EmailSecuritySummarySpoofParamsSPFPass EmailSecuritySummarySpoofParamsSPF = "PASS" + EmailSecuritySummarySpoofParamsSPFNone EmailSecuritySummarySpoofParamsSPF = "NONE" + EmailSecuritySummarySpoofParamsSPFFail EmailSecuritySummarySpoofParamsSPF = "FAIL" +) + +type EmailSecuritySummarySpoofParamsTLSVersion string + +const ( + EmailSecuritySummarySpoofParamsTLSVersionTlSv1_0 EmailSecuritySummarySpoofParamsTLSVersion = "TLSv1_0" + EmailSecuritySummarySpoofParamsTLSVersionTlSv1_1 EmailSecuritySummarySpoofParamsTLSVersion = "TLSv1_1" + EmailSecuritySummarySpoofParamsTLSVersionTlSv1_2 EmailSecuritySummarySpoofParamsTLSVersion = "TLSv1_2" + EmailSecuritySummarySpoofParamsTLSVersionTlSv1_3 EmailSecuritySummarySpoofParamsTLSVersion = "TLSv1_3" +) + +type EmailSecuritySummarySpoofResponseEnvelope struct { + Result EmailSecuritySummarySpoofResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecuritySummarySpoofResponseEnvelopeJSON `json:"-"` +} + +// emailSecuritySummarySpoofResponseEnvelopeJSON contains the JSON metadata for the +// struct [EmailSecuritySummarySpoofResponseEnvelope] +type emailSecuritySummarySpoofResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummarySpoofResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummarySpoofResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryThreatCategoryParams struct { + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecuritySummaryThreatCategoryParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecuritySummaryThreatCategoryParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecuritySummaryThreatCategoryParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecuritySummaryThreatCategoryParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecuritySummaryThreatCategoryParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecuritySummaryThreatCategoryParamsSPF] `query:"spf"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecuritySummaryThreatCategoryParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecuritySummaryThreatCategoryParams]'s query +// parameters as `url.Values`. +func (r EmailSecuritySummaryThreatCategoryParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type EmailSecuritySummaryThreatCategoryParamsARC string + +const ( + EmailSecuritySummaryThreatCategoryParamsARCPass EmailSecuritySummaryThreatCategoryParamsARC = "PASS" + EmailSecuritySummaryThreatCategoryParamsARCNone EmailSecuritySummaryThreatCategoryParamsARC = "NONE" + EmailSecuritySummaryThreatCategoryParamsARCFail EmailSecuritySummaryThreatCategoryParamsARC = "FAIL" +) + +type EmailSecuritySummaryThreatCategoryParamsDateRange string + +const ( + EmailSecuritySummaryThreatCategoryParamsDateRange1d EmailSecuritySummaryThreatCategoryParamsDateRange = "1d" + EmailSecuritySummaryThreatCategoryParamsDateRange2d EmailSecuritySummaryThreatCategoryParamsDateRange = "2d" + EmailSecuritySummaryThreatCategoryParamsDateRange7d EmailSecuritySummaryThreatCategoryParamsDateRange = "7d" + EmailSecuritySummaryThreatCategoryParamsDateRange14d EmailSecuritySummaryThreatCategoryParamsDateRange = "14d" + EmailSecuritySummaryThreatCategoryParamsDateRange28d EmailSecuritySummaryThreatCategoryParamsDateRange = "28d" + EmailSecuritySummaryThreatCategoryParamsDateRange12w EmailSecuritySummaryThreatCategoryParamsDateRange = "12w" + EmailSecuritySummaryThreatCategoryParamsDateRange24w EmailSecuritySummaryThreatCategoryParamsDateRange = "24w" + EmailSecuritySummaryThreatCategoryParamsDateRange52w EmailSecuritySummaryThreatCategoryParamsDateRange = "52w" + EmailSecuritySummaryThreatCategoryParamsDateRange1dControl EmailSecuritySummaryThreatCategoryParamsDateRange = "1dControl" + EmailSecuritySummaryThreatCategoryParamsDateRange2dControl EmailSecuritySummaryThreatCategoryParamsDateRange = "2dControl" + EmailSecuritySummaryThreatCategoryParamsDateRange7dControl EmailSecuritySummaryThreatCategoryParamsDateRange = "7dControl" + EmailSecuritySummaryThreatCategoryParamsDateRange14dControl EmailSecuritySummaryThreatCategoryParamsDateRange = "14dControl" + EmailSecuritySummaryThreatCategoryParamsDateRange28dControl EmailSecuritySummaryThreatCategoryParamsDateRange = "28dControl" + EmailSecuritySummaryThreatCategoryParamsDateRange12wControl EmailSecuritySummaryThreatCategoryParamsDateRange = "12wControl" + EmailSecuritySummaryThreatCategoryParamsDateRange24wControl EmailSecuritySummaryThreatCategoryParamsDateRange = "24wControl" +) + +type EmailSecuritySummaryThreatCategoryParamsDKIM string + +const ( + EmailSecuritySummaryThreatCategoryParamsDKIMPass EmailSecuritySummaryThreatCategoryParamsDKIM = "PASS" + EmailSecuritySummaryThreatCategoryParamsDKIMNone EmailSecuritySummaryThreatCategoryParamsDKIM = "NONE" + EmailSecuritySummaryThreatCategoryParamsDKIMFail EmailSecuritySummaryThreatCategoryParamsDKIM = "FAIL" +) + +type EmailSecuritySummaryThreatCategoryParamsDMARC string + +const ( + EmailSecuritySummaryThreatCategoryParamsDMARCPass EmailSecuritySummaryThreatCategoryParamsDMARC = "PASS" + EmailSecuritySummaryThreatCategoryParamsDMARCNone EmailSecuritySummaryThreatCategoryParamsDMARC = "NONE" + EmailSecuritySummaryThreatCategoryParamsDMARCFail EmailSecuritySummaryThreatCategoryParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecuritySummaryThreatCategoryParamsFormat string + +const ( + EmailSecuritySummaryThreatCategoryParamsFormatJson EmailSecuritySummaryThreatCategoryParamsFormat = "JSON" + EmailSecuritySummaryThreatCategoryParamsFormatCsv EmailSecuritySummaryThreatCategoryParamsFormat = "CSV" +) + +type EmailSecuritySummaryThreatCategoryParamsSPF string + +const ( + EmailSecuritySummaryThreatCategoryParamsSPFPass EmailSecuritySummaryThreatCategoryParamsSPF = "PASS" + EmailSecuritySummaryThreatCategoryParamsSPFNone EmailSecuritySummaryThreatCategoryParamsSPF = "NONE" + EmailSecuritySummaryThreatCategoryParamsSPFFail EmailSecuritySummaryThreatCategoryParamsSPF = "FAIL" +) + +type EmailSecuritySummaryThreatCategoryParamsTLSVersion string + +const ( + EmailSecuritySummaryThreatCategoryParamsTLSVersionTlSv1_0 EmailSecuritySummaryThreatCategoryParamsTLSVersion = "TLSv1_0" + EmailSecuritySummaryThreatCategoryParamsTLSVersionTlSv1_1 EmailSecuritySummaryThreatCategoryParamsTLSVersion = "TLSv1_1" + EmailSecuritySummaryThreatCategoryParamsTLSVersionTlSv1_2 EmailSecuritySummaryThreatCategoryParamsTLSVersion = "TLSv1_2" + EmailSecuritySummaryThreatCategoryParamsTLSVersionTlSv1_3 EmailSecuritySummaryThreatCategoryParamsTLSVersion = "TLSv1_3" +) + +type EmailSecuritySummaryThreatCategoryResponseEnvelope struct { + Result EmailSecuritySummaryThreatCategoryResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecuritySummaryThreatCategoryResponseEnvelopeJSON `json:"-"` +} + +// emailSecuritySummaryThreatCategoryResponseEnvelopeJSON contains the JSON +// metadata for the struct [EmailSecuritySummaryThreatCategoryResponseEnvelope] +type emailSecuritySummaryThreatCategoryResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryThreatCategoryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryThreatCategoryResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailSecuritySummaryTLSVersionParams struct { + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecuritySummaryTLSVersionParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecuritySummaryTLSVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecuritySummaryTLSVersionParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecuritySummaryTLSVersionParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecuritySummaryTLSVersionParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecuritySummaryTLSVersionParamsSPF] `query:"spf"` +} + +// URLQuery serializes [EmailSecuritySummaryTLSVersionParams]'s query parameters as +// `url.Values`. +func (r EmailSecuritySummaryTLSVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type EmailSecuritySummaryTLSVersionParamsARC string + +const ( + EmailSecuritySummaryTLSVersionParamsARCPass EmailSecuritySummaryTLSVersionParamsARC = "PASS" + EmailSecuritySummaryTLSVersionParamsARCNone EmailSecuritySummaryTLSVersionParamsARC = "NONE" + EmailSecuritySummaryTLSVersionParamsARCFail EmailSecuritySummaryTLSVersionParamsARC = "FAIL" +) + +type EmailSecuritySummaryTLSVersionParamsDateRange string + +const ( + EmailSecuritySummaryTLSVersionParamsDateRange1d EmailSecuritySummaryTLSVersionParamsDateRange = "1d" + EmailSecuritySummaryTLSVersionParamsDateRange2d EmailSecuritySummaryTLSVersionParamsDateRange = "2d" + EmailSecuritySummaryTLSVersionParamsDateRange7d EmailSecuritySummaryTLSVersionParamsDateRange = "7d" + EmailSecuritySummaryTLSVersionParamsDateRange14d EmailSecuritySummaryTLSVersionParamsDateRange = "14d" + EmailSecuritySummaryTLSVersionParamsDateRange28d EmailSecuritySummaryTLSVersionParamsDateRange = "28d" + EmailSecuritySummaryTLSVersionParamsDateRange12w EmailSecuritySummaryTLSVersionParamsDateRange = "12w" + EmailSecuritySummaryTLSVersionParamsDateRange24w EmailSecuritySummaryTLSVersionParamsDateRange = "24w" + EmailSecuritySummaryTLSVersionParamsDateRange52w EmailSecuritySummaryTLSVersionParamsDateRange = "52w" + EmailSecuritySummaryTLSVersionParamsDateRange1dControl EmailSecuritySummaryTLSVersionParamsDateRange = "1dControl" + EmailSecuritySummaryTLSVersionParamsDateRange2dControl EmailSecuritySummaryTLSVersionParamsDateRange = "2dControl" + EmailSecuritySummaryTLSVersionParamsDateRange7dControl EmailSecuritySummaryTLSVersionParamsDateRange = "7dControl" + EmailSecuritySummaryTLSVersionParamsDateRange14dControl EmailSecuritySummaryTLSVersionParamsDateRange = "14dControl" + EmailSecuritySummaryTLSVersionParamsDateRange28dControl EmailSecuritySummaryTLSVersionParamsDateRange = "28dControl" + EmailSecuritySummaryTLSVersionParamsDateRange12wControl EmailSecuritySummaryTLSVersionParamsDateRange = "12wControl" + EmailSecuritySummaryTLSVersionParamsDateRange24wControl EmailSecuritySummaryTLSVersionParamsDateRange = "24wControl" +) + +type EmailSecuritySummaryTLSVersionParamsDKIM string + +const ( + EmailSecuritySummaryTLSVersionParamsDKIMPass EmailSecuritySummaryTLSVersionParamsDKIM = "PASS" + EmailSecuritySummaryTLSVersionParamsDKIMNone EmailSecuritySummaryTLSVersionParamsDKIM = "NONE" + EmailSecuritySummaryTLSVersionParamsDKIMFail EmailSecuritySummaryTLSVersionParamsDKIM = "FAIL" +) + +type EmailSecuritySummaryTLSVersionParamsDMARC string + +const ( + EmailSecuritySummaryTLSVersionParamsDMARCPass EmailSecuritySummaryTLSVersionParamsDMARC = "PASS" + EmailSecuritySummaryTLSVersionParamsDMARCNone EmailSecuritySummaryTLSVersionParamsDMARC = "NONE" + EmailSecuritySummaryTLSVersionParamsDMARCFail EmailSecuritySummaryTLSVersionParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecuritySummaryTLSVersionParamsFormat string + +const ( + EmailSecuritySummaryTLSVersionParamsFormatJson EmailSecuritySummaryTLSVersionParamsFormat = "JSON" + EmailSecuritySummaryTLSVersionParamsFormatCsv EmailSecuritySummaryTLSVersionParamsFormat = "CSV" +) + +type EmailSecuritySummaryTLSVersionParamsSPF string + +const ( + EmailSecuritySummaryTLSVersionParamsSPFPass EmailSecuritySummaryTLSVersionParamsSPF = "PASS" + EmailSecuritySummaryTLSVersionParamsSPFNone EmailSecuritySummaryTLSVersionParamsSPF = "NONE" + EmailSecuritySummaryTLSVersionParamsSPFFail EmailSecuritySummaryTLSVersionParamsSPF = "FAIL" +) + +type EmailSecuritySummaryTLSVersionResponseEnvelope struct { + Result EmailSecuritySummaryTLSVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecuritySummaryTLSVersionResponseEnvelopeJSON `json:"-"` +} + +// emailSecuritySummaryTLSVersionResponseEnvelopeJSON contains the JSON metadata +// for the struct [EmailSecuritySummaryTLSVersionResponseEnvelope] +type emailSecuritySummaryTLSVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecuritySummaryTLSVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecuritySummaryTLSVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/emailsecuritysummary_test.go b/radar/emailsecuritysummary_test.go new file mode 100644 index 00000000000..89cbbdd5efe --- /dev/null +++ b/radar/emailsecuritysummary_test.go @@ -0,0 +1,326 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestEmailSecuritySummaryARCWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.Summary.ARC(context.TODO(), radar.EmailSecuritySummaryARCParams{ + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecuritySummaryARCParamsDateRange{radar.EmailSecuritySummaryARCParamsDateRange1d, radar.EmailSecuritySummaryARCParamsDateRange2d, radar.EmailSecuritySummaryARCParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecuritySummaryARCParamsDKIM{radar.EmailSecuritySummaryARCParamsDKIMPass, radar.EmailSecuritySummaryARCParamsDKIMNone, radar.EmailSecuritySummaryARCParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailSecuritySummaryARCParamsDMARC{radar.EmailSecuritySummaryARCParamsDMARCPass, radar.EmailSecuritySummaryARCParamsDMARCNone, radar.EmailSecuritySummaryARCParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecuritySummaryARCParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecuritySummaryARCParamsSPF{radar.EmailSecuritySummaryARCParamsSPFPass, radar.EmailSecuritySummaryARCParamsSPFNone, radar.EmailSecuritySummaryARCParamsSPFFail}), + TLSVersion: cloudflare.F([]radar.EmailSecuritySummaryARCParamsTLSVersion{radar.EmailSecuritySummaryARCParamsTLSVersionTlSv1_0, radar.EmailSecuritySummaryARCParamsTLSVersionTlSv1_1, radar.EmailSecuritySummaryARCParamsTLSVersionTlSv1_2}), + }) + 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 TestEmailSecuritySummaryDKIMWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.Summary.DKIM(context.TODO(), radar.EmailSecuritySummaryDKIMParams{ + ARC: cloudflare.F([]radar.EmailSecuritySummaryDKIMParamsARC{radar.EmailSecuritySummaryDKIMParamsARCPass, radar.EmailSecuritySummaryDKIMParamsARCNone, radar.EmailSecuritySummaryDKIMParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecuritySummaryDKIMParamsDateRange{radar.EmailSecuritySummaryDKIMParamsDateRange1d, radar.EmailSecuritySummaryDKIMParamsDateRange2d, radar.EmailSecuritySummaryDKIMParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DMARC: cloudflare.F([]radar.EmailSecuritySummaryDKIMParamsDMARC{radar.EmailSecuritySummaryDKIMParamsDMARCPass, radar.EmailSecuritySummaryDKIMParamsDMARCNone, radar.EmailSecuritySummaryDKIMParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecuritySummaryDKIMParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecuritySummaryDKIMParamsSPF{radar.EmailSecuritySummaryDKIMParamsSPFPass, radar.EmailSecuritySummaryDKIMParamsSPFNone, radar.EmailSecuritySummaryDKIMParamsSPFFail}), + TLSVersion: cloudflare.F([]radar.EmailSecuritySummaryDKIMParamsTLSVersion{radar.EmailSecuritySummaryDKIMParamsTLSVersionTlSv1_0, radar.EmailSecuritySummaryDKIMParamsTLSVersionTlSv1_1, radar.EmailSecuritySummaryDKIMParamsTLSVersionTlSv1_2}), + }) + 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 TestEmailSecuritySummaryDMARCWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.Summary.DMARC(context.TODO(), radar.EmailSecuritySummaryDMARCParams{ + ARC: cloudflare.F([]radar.EmailSecuritySummaryDMARCParamsARC{radar.EmailSecuritySummaryDMARCParamsARCPass, radar.EmailSecuritySummaryDMARCParamsARCNone, radar.EmailSecuritySummaryDMARCParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecuritySummaryDMARCParamsDateRange{radar.EmailSecuritySummaryDMARCParamsDateRange1d, radar.EmailSecuritySummaryDMARCParamsDateRange2d, radar.EmailSecuritySummaryDMARCParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecuritySummaryDMARCParamsDKIM{radar.EmailSecuritySummaryDMARCParamsDKIMPass, radar.EmailSecuritySummaryDMARCParamsDKIMNone, radar.EmailSecuritySummaryDMARCParamsDKIMFail}), + Format: cloudflare.F(radar.EmailSecuritySummaryDMARCParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecuritySummaryDMARCParamsSPF{radar.EmailSecuritySummaryDMARCParamsSPFPass, radar.EmailSecuritySummaryDMARCParamsSPFNone, radar.EmailSecuritySummaryDMARCParamsSPFFail}), + TLSVersion: cloudflare.F([]radar.EmailSecuritySummaryDMARCParamsTLSVersion{radar.EmailSecuritySummaryDMARCParamsTLSVersionTlSv1_0, radar.EmailSecuritySummaryDMARCParamsTLSVersionTlSv1_1, radar.EmailSecuritySummaryDMARCParamsTLSVersionTlSv1_2}), + }) + 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 TestEmailSecuritySummaryMaliciousWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.Summary.Malicious(context.TODO(), radar.EmailSecuritySummaryMaliciousParams{ + ARC: cloudflare.F([]radar.EmailSecuritySummaryMaliciousParamsARC{radar.EmailSecuritySummaryMaliciousParamsARCPass, radar.EmailSecuritySummaryMaliciousParamsARCNone, radar.EmailSecuritySummaryMaliciousParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecuritySummaryMaliciousParamsDateRange{radar.EmailSecuritySummaryMaliciousParamsDateRange1d, radar.EmailSecuritySummaryMaliciousParamsDateRange2d, radar.EmailSecuritySummaryMaliciousParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecuritySummaryMaliciousParamsDKIM{radar.EmailSecuritySummaryMaliciousParamsDKIMPass, radar.EmailSecuritySummaryMaliciousParamsDKIMNone, radar.EmailSecuritySummaryMaliciousParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailSecuritySummaryMaliciousParamsDMARC{radar.EmailSecuritySummaryMaliciousParamsDMARCPass, radar.EmailSecuritySummaryMaliciousParamsDMARCNone, radar.EmailSecuritySummaryMaliciousParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecuritySummaryMaliciousParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecuritySummaryMaliciousParamsSPF{radar.EmailSecuritySummaryMaliciousParamsSPFPass, radar.EmailSecuritySummaryMaliciousParamsSPFNone, radar.EmailSecuritySummaryMaliciousParamsSPFFail}), + TLSVersion: cloudflare.F([]radar.EmailSecuritySummaryMaliciousParamsTLSVersion{radar.EmailSecuritySummaryMaliciousParamsTLSVersionTlSv1_0, radar.EmailSecuritySummaryMaliciousParamsTLSVersionTlSv1_1, radar.EmailSecuritySummaryMaliciousParamsTLSVersionTlSv1_2}), + }) + 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 TestEmailSecuritySummarySpamWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.Summary.Spam(context.TODO(), radar.EmailSecuritySummarySpamParams{ + ARC: cloudflare.F([]radar.EmailSecuritySummarySpamParamsARC{radar.EmailSecuritySummarySpamParamsARCPass, radar.EmailSecuritySummarySpamParamsARCNone, radar.EmailSecuritySummarySpamParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecuritySummarySpamParamsDateRange{radar.EmailSecuritySummarySpamParamsDateRange1d, radar.EmailSecuritySummarySpamParamsDateRange2d, radar.EmailSecuritySummarySpamParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecuritySummarySpamParamsDKIM{radar.EmailSecuritySummarySpamParamsDKIMPass, radar.EmailSecuritySummarySpamParamsDKIMNone, radar.EmailSecuritySummarySpamParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailSecuritySummarySpamParamsDMARC{radar.EmailSecuritySummarySpamParamsDMARCPass, radar.EmailSecuritySummarySpamParamsDMARCNone, radar.EmailSecuritySummarySpamParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecuritySummarySpamParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecuritySummarySpamParamsSPF{radar.EmailSecuritySummarySpamParamsSPFPass, radar.EmailSecuritySummarySpamParamsSPFNone, radar.EmailSecuritySummarySpamParamsSPFFail}), + TLSVersion: cloudflare.F([]radar.EmailSecuritySummarySpamParamsTLSVersion{radar.EmailSecuritySummarySpamParamsTLSVersionTlSv1_0, radar.EmailSecuritySummarySpamParamsTLSVersionTlSv1_1, radar.EmailSecuritySummarySpamParamsTLSVersionTlSv1_2}), + }) + 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 TestEmailSecuritySummarySPFWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.Summary.SPF(context.TODO(), radar.EmailSecuritySummarySPFParams{ + ARC: cloudflare.F([]radar.EmailSecuritySummarySPFParamsARC{radar.EmailSecuritySummarySPFParamsARCPass, radar.EmailSecuritySummarySPFParamsARCNone, radar.EmailSecuritySummarySPFParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecuritySummarySPFParamsDateRange{radar.EmailSecuritySummarySPFParamsDateRange1d, radar.EmailSecuritySummarySPFParamsDateRange2d, radar.EmailSecuritySummarySPFParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecuritySummarySPFParamsDKIM{radar.EmailSecuritySummarySPFParamsDKIMPass, radar.EmailSecuritySummarySPFParamsDKIMNone, radar.EmailSecuritySummarySPFParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailSecuritySummarySPFParamsDMARC{radar.EmailSecuritySummarySPFParamsDMARCPass, radar.EmailSecuritySummarySPFParamsDMARCNone, radar.EmailSecuritySummarySPFParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecuritySummarySPFParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + TLSVersion: cloudflare.F([]radar.EmailSecuritySummarySPFParamsTLSVersion{radar.EmailSecuritySummarySPFParamsTLSVersionTlSv1_0, radar.EmailSecuritySummarySPFParamsTLSVersionTlSv1_1, radar.EmailSecuritySummarySPFParamsTLSVersionTlSv1_2}), + }) + 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 TestEmailSecuritySummarySpoofWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.Summary.Spoof(context.TODO(), radar.EmailSecuritySummarySpoofParams{ + ARC: cloudflare.F([]radar.EmailSecuritySummarySpoofParamsARC{radar.EmailSecuritySummarySpoofParamsARCPass, radar.EmailSecuritySummarySpoofParamsARCNone, radar.EmailSecuritySummarySpoofParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecuritySummarySpoofParamsDateRange{radar.EmailSecuritySummarySpoofParamsDateRange1d, radar.EmailSecuritySummarySpoofParamsDateRange2d, radar.EmailSecuritySummarySpoofParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecuritySummarySpoofParamsDKIM{radar.EmailSecuritySummarySpoofParamsDKIMPass, radar.EmailSecuritySummarySpoofParamsDKIMNone, radar.EmailSecuritySummarySpoofParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailSecuritySummarySpoofParamsDMARC{radar.EmailSecuritySummarySpoofParamsDMARCPass, radar.EmailSecuritySummarySpoofParamsDMARCNone, radar.EmailSecuritySummarySpoofParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecuritySummarySpoofParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecuritySummarySpoofParamsSPF{radar.EmailSecuritySummarySpoofParamsSPFPass, radar.EmailSecuritySummarySpoofParamsSPFNone, radar.EmailSecuritySummarySpoofParamsSPFFail}), + TLSVersion: cloudflare.F([]radar.EmailSecuritySummarySpoofParamsTLSVersion{radar.EmailSecuritySummarySpoofParamsTLSVersionTlSv1_0, radar.EmailSecuritySummarySpoofParamsTLSVersionTlSv1_1, radar.EmailSecuritySummarySpoofParamsTLSVersionTlSv1_2}), + }) + 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 TestEmailSecuritySummaryThreatCategoryWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.Summary.ThreatCategory(context.TODO(), radar.EmailSecuritySummaryThreatCategoryParams{ + ARC: cloudflare.F([]radar.EmailSecuritySummaryThreatCategoryParamsARC{radar.EmailSecuritySummaryThreatCategoryParamsARCPass, radar.EmailSecuritySummaryThreatCategoryParamsARCNone, radar.EmailSecuritySummaryThreatCategoryParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecuritySummaryThreatCategoryParamsDateRange{radar.EmailSecuritySummaryThreatCategoryParamsDateRange1d, radar.EmailSecuritySummaryThreatCategoryParamsDateRange2d, radar.EmailSecuritySummaryThreatCategoryParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecuritySummaryThreatCategoryParamsDKIM{radar.EmailSecuritySummaryThreatCategoryParamsDKIMPass, radar.EmailSecuritySummaryThreatCategoryParamsDKIMNone, radar.EmailSecuritySummaryThreatCategoryParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailSecuritySummaryThreatCategoryParamsDMARC{radar.EmailSecuritySummaryThreatCategoryParamsDMARCPass, radar.EmailSecuritySummaryThreatCategoryParamsDMARCNone, radar.EmailSecuritySummaryThreatCategoryParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecuritySummaryThreatCategoryParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecuritySummaryThreatCategoryParamsSPF{radar.EmailSecuritySummaryThreatCategoryParamsSPFPass, radar.EmailSecuritySummaryThreatCategoryParamsSPFNone, radar.EmailSecuritySummaryThreatCategoryParamsSPFFail}), + TLSVersion: cloudflare.F([]radar.EmailSecuritySummaryThreatCategoryParamsTLSVersion{radar.EmailSecuritySummaryThreatCategoryParamsTLSVersionTlSv1_0, radar.EmailSecuritySummaryThreatCategoryParamsTLSVersionTlSv1_1, radar.EmailSecuritySummaryThreatCategoryParamsTLSVersionTlSv1_2}), + }) + 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 TestEmailSecuritySummaryTLSVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.Summary.TLSVersion(context.TODO(), radar.EmailSecuritySummaryTLSVersionParams{ + ARC: cloudflare.F([]radar.EmailSecuritySummaryTLSVersionParamsARC{radar.EmailSecuritySummaryTLSVersionParamsARCPass, radar.EmailSecuritySummaryTLSVersionParamsARCNone, radar.EmailSecuritySummaryTLSVersionParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecuritySummaryTLSVersionParamsDateRange{radar.EmailSecuritySummaryTLSVersionParamsDateRange1d, radar.EmailSecuritySummaryTLSVersionParamsDateRange2d, radar.EmailSecuritySummaryTLSVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecuritySummaryTLSVersionParamsDKIM{radar.EmailSecuritySummaryTLSVersionParamsDKIMPass, radar.EmailSecuritySummaryTLSVersionParamsDKIMNone, radar.EmailSecuritySummaryTLSVersionParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailSecuritySummaryTLSVersionParamsDMARC{radar.EmailSecuritySummaryTLSVersionParamsDMARCPass, radar.EmailSecuritySummaryTLSVersionParamsDMARCNone, radar.EmailSecuritySummaryTLSVersionParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecuritySummaryTLSVersionParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecuritySummaryTLSVersionParamsSPF{radar.EmailSecuritySummaryTLSVersionParamsSPFPass, radar.EmailSecuritySummaryTLSVersionParamsSPFNone, radar.EmailSecuritySummaryTLSVersionParamsSPFFail}), + }) + 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/radar/emailsecuritytimeseriesgroup.go b/radar/emailsecuritytimeseriesgroup.go new file mode 100644 index 00000000000..bc08ba538f2 --- /dev/null +++ b/radar/emailsecuritytimeseriesgroup.go @@ -0,0 +1,1810 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// EmailSecurityTimeseriesGroupService 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 +// [NewEmailSecurityTimeseriesGroupService] method instead. +type EmailSecurityTimeseriesGroupService struct { + Options []option.RequestOption +} + +// NewEmailSecurityTimeseriesGroupService 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 NewEmailSecurityTimeseriesGroupService(opts ...option.RequestOption) (r *EmailSecurityTimeseriesGroupService) { + r = &EmailSecurityTimeseriesGroupService{} + r.Options = opts + return +} + +// Percentage distribution of emails classified per Arc validation over time. +func (r *EmailSecurityTimeseriesGroupService) ARC(ctx context.Context, query EmailSecurityTimeseriesGroupARCParams, opts ...option.RequestOption) (res *EmailSecurityTimeseriesGroupARCResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecurityTimeseriesGroupARCResponseEnvelope + path := "radar/email/security/timeseries_groups/arc" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified per DKIM validation over time. +func (r *EmailSecurityTimeseriesGroupService) DKIM(ctx context.Context, query EmailSecurityTimeseriesGroupDKIMParams, opts ...option.RequestOption) (res *EmailSecurityTimeseriesGroupDKIMResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecurityTimeseriesGroupDKIMResponseEnvelope + path := "radar/email/security/timeseries_groups/dkim" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified per DMARC validation over time. +func (r *EmailSecurityTimeseriesGroupService) DMARC(ctx context.Context, query EmailSecurityTimeseriesGroupDMARCParams, opts ...option.RequestOption) (res *EmailSecurityTimeseriesGroupDMARCResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecurityTimeseriesGroupDMARCResponseEnvelope + path := "radar/email/security/timeseries_groups/dmarc" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified as MALICIOUS over time. +func (r *EmailSecurityTimeseriesGroupService) Malicious(ctx context.Context, query EmailSecurityTimeseriesGroupMaliciousParams, opts ...option.RequestOption) (res *EmailSecurityTimeseriesGroupMaliciousResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecurityTimeseriesGroupMaliciousResponseEnvelope + path := "radar/email/security/timeseries_groups/malicious" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified as SPAM over time. +func (r *EmailSecurityTimeseriesGroupService) Spam(ctx context.Context, query EmailSecurityTimeseriesGroupSpamParams, opts ...option.RequestOption) (res *EmailSecurityTimeseriesGroupSpamResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecurityTimeseriesGroupSpamResponseEnvelope + path := "radar/email/security/timeseries_groups/spam" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified per SPF validation over time. +func (r *EmailSecurityTimeseriesGroupService) SPF(ctx context.Context, query EmailSecurityTimeseriesGroupSPFParams, opts ...option.RequestOption) (res *EmailSecurityTimeseriesGroupSPFResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecurityTimeseriesGroupSPFResponseEnvelope + path := "radar/email/security/timeseries_groups/spf" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified as SPOOF over time. +func (r *EmailSecurityTimeseriesGroupService) Spoof(ctx context.Context, query EmailSecurityTimeseriesGroupSpoofParams, opts ...option.RequestOption) (res *EmailSecurityTimeseriesGroupSpoofResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecurityTimeseriesGroupSpoofResponseEnvelope + path := "radar/email/security/timeseries_groups/spoof" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified in Threat Categories over time. +func (r *EmailSecurityTimeseriesGroupService) ThreatCategory(ctx context.Context, query EmailSecurityTimeseriesGroupThreatCategoryParams, opts ...option.RequestOption) (res *EmailSecurityTimeseriesGroupThreatCategoryResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecurityTimeseriesGroupThreatCategoryResponseEnvelope + path := "radar/email/security/timeseries_groups/threat_category" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of emails classified per TLS Version over time. +func (r *EmailSecurityTimeseriesGroupService) TLSVersion(ctx context.Context, query EmailSecurityTimeseriesGroupTLSVersionParams, opts ...option.RequestOption) (res *EmailSecurityTimeseriesGroupTLSVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecurityTimeseriesGroupTLSVersionResponseEnvelope + path := "radar/email/security/timeseries_groups/tls_version" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type EmailSecurityTimeseriesGroupARCResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 EmailSecurityTimeseriesGroupARCResponseSerie0 `json:"serie_0,required"` + JSON emailSecurityTimeseriesGroupARCResponseJSON `json:"-"` +} + +// emailSecurityTimeseriesGroupARCResponseJSON contains the JSON metadata for the +// struct [EmailSecurityTimeseriesGroupARCResponse] +type emailSecurityTimeseriesGroupARCResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupARCResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupARCResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupARCResponseSerie0 struct { + Fail []string `json:"FAIL,required"` + None []string `json:"NONE,required"` + Pass []string `json:"PASS,required"` + JSON emailSecurityTimeseriesGroupARCResponseSerie0JSON `json:"-"` +} + +// emailSecurityTimeseriesGroupARCResponseSerie0JSON contains the JSON metadata for +// the struct [EmailSecurityTimeseriesGroupARCResponseSerie0] +type emailSecurityTimeseriesGroupARCResponseSerie0JSON struct { + Fail apijson.Field + None apijson.Field + Pass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupARCResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupARCResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupDKIMResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 EmailSecurityTimeseriesGroupDKIMResponseSerie0 `json:"serie_0,required"` + JSON emailSecurityTimeseriesGroupDKIMResponseJSON `json:"-"` +} + +// emailSecurityTimeseriesGroupDKIMResponseJSON contains the JSON metadata for the +// struct [EmailSecurityTimeseriesGroupDKIMResponse] +type emailSecurityTimeseriesGroupDKIMResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupDKIMResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupDKIMResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupDKIMResponseSerie0 struct { + Fail []string `json:"FAIL,required"` + None []string `json:"NONE,required"` + Pass []string `json:"PASS,required"` + JSON emailSecurityTimeseriesGroupDKIMResponseSerie0JSON `json:"-"` +} + +// emailSecurityTimeseriesGroupDKIMResponseSerie0JSON contains the JSON metadata +// for the struct [EmailSecurityTimeseriesGroupDKIMResponseSerie0] +type emailSecurityTimeseriesGroupDKIMResponseSerie0JSON struct { + Fail apijson.Field + None apijson.Field + Pass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupDKIMResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupDKIMResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupDMARCResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 EmailSecurityTimeseriesGroupDMARCResponseSerie0 `json:"serie_0,required"` + JSON emailSecurityTimeseriesGroupDMARCResponseJSON `json:"-"` +} + +// emailSecurityTimeseriesGroupDMARCResponseJSON contains the JSON metadata for the +// struct [EmailSecurityTimeseriesGroupDMARCResponse] +type emailSecurityTimeseriesGroupDMARCResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupDMARCResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupDMARCResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupDMARCResponseSerie0 struct { + Fail []string `json:"FAIL,required"` + None []string `json:"NONE,required"` + Pass []string `json:"PASS,required"` + JSON emailSecurityTimeseriesGroupDMARCResponseSerie0JSON `json:"-"` +} + +// emailSecurityTimeseriesGroupDMARCResponseSerie0JSON contains the JSON metadata +// for the struct [EmailSecurityTimeseriesGroupDMARCResponseSerie0] +type emailSecurityTimeseriesGroupDMARCResponseSerie0JSON struct { + Fail apijson.Field + None apijson.Field + Pass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupDMARCResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupDMARCResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupMaliciousResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 EmailSecurityTimeseriesGroupMaliciousResponseSerie0 `json:"serie_0,required"` + JSON emailSecurityTimeseriesGroupMaliciousResponseJSON `json:"-"` +} + +// emailSecurityTimeseriesGroupMaliciousResponseJSON contains the JSON metadata for +// the struct [EmailSecurityTimeseriesGroupMaliciousResponse] +type emailSecurityTimeseriesGroupMaliciousResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupMaliciousResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupMaliciousResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupMaliciousResponseSerie0 struct { + Malicious []string `json:"MALICIOUS,required"` + NotMalicious []string `json:"NOT_MALICIOUS,required"` + JSON emailSecurityTimeseriesGroupMaliciousResponseSerie0JSON `json:"-"` +} + +// emailSecurityTimeseriesGroupMaliciousResponseSerie0JSON contains the JSON +// metadata for the struct [EmailSecurityTimeseriesGroupMaliciousResponseSerie0] +type emailSecurityTimeseriesGroupMaliciousResponseSerie0JSON struct { + Malicious apijson.Field + NotMalicious apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupMaliciousResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupMaliciousResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupSpamResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 EmailSecurityTimeseriesGroupSpamResponseSerie0 `json:"serie_0,required"` + JSON emailSecurityTimeseriesGroupSpamResponseJSON `json:"-"` +} + +// emailSecurityTimeseriesGroupSpamResponseJSON contains the JSON metadata for the +// struct [EmailSecurityTimeseriesGroupSpamResponse] +type emailSecurityTimeseriesGroupSpamResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupSpamResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupSpamResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupSpamResponseSerie0 struct { + NotSpam []string `json:"NOT_SPAM,required"` + Spam []string `json:"SPAM,required"` + JSON emailSecurityTimeseriesGroupSpamResponseSerie0JSON `json:"-"` +} + +// emailSecurityTimeseriesGroupSpamResponseSerie0JSON contains the JSON metadata +// for the struct [EmailSecurityTimeseriesGroupSpamResponseSerie0] +type emailSecurityTimeseriesGroupSpamResponseSerie0JSON struct { + NotSpam apijson.Field + Spam apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupSpamResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupSpamResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupSPFResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 EmailSecurityTimeseriesGroupSPFResponseSerie0 `json:"serie_0,required"` + JSON emailSecurityTimeseriesGroupSPFResponseJSON `json:"-"` +} + +// emailSecurityTimeseriesGroupSPFResponseJSON contains the JSON metadata for the +// struct [EmailSecurityTimeseriesGroupSPFResponse] +type emailSecurityTimeseriesGroupSPFResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupSPFResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupSPFResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupSPFResponseSerie0 struct { + Fail []string `json:"FAIL,required"` + None []string `json:"NONE,required"` + Pass []string `json:"PASS,required"` + JSON emailSecurityTimeseriesGroupSPFResponseSerie0JSON `json:"-"` +} + +// emailSecurityTimeseriesGroupSPFResponseSerie0JSON contains the JSON metadata for +// the struct [EmailSecurityTimeseriesGroupSPFResponseSerie0] +type emailSecurityTimeseriesGroupSPFResponseSerie0JSON struct { + Fail apijson.Field + None apijson.Field + Pass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupSPFResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupSPFResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupSpoofResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 EmailSecurityTimeseriesGroupSpoofResponseSerie0 `json:"serie_0,required"` + JSON emailSecurityTimeseriesGroupSpoofResponseJSON `json:"-"` +} + +// emailSecurityTimeseriesGroupSpoofResponseJSON contains the JSON metadata for the +// struct [EmailSecurityTimeseriesGroupSpoofResponse] +type emailSecurityTimeseriesGroupSpoofResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupSpoofResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupSpoofResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupSpoofResponseSerie0 struct { + NotSpoof []string `json:"NOT_SPOOF,required"` + Spoof []string `json:"SPOOF,required"` + JSON emailSecurityTimeseriesGroupSpoofResponseSerie0JSON `json:"-"` +} + +// emailSecurityTimeseriesGroupSpoofResponseSerie0JSON contains the JSON metadata +// for the struct [EmailSecurityTimeseriesGroupSpoofResponseSerie0] +type emailSecurityTimeseriesGroupSpoofResponseSerie0JSON struct { + NotSpoof apijson.Field + Spoof apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupSpoofResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupSpoofResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupThreatCategoryResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 EmailSecurityTimeseriesGroupThreatCategoryResponseSerie0 `json:"serie_0,required"` + JSON emailSecurityTimeseriesGroupThreatCategoryResponseJSON `json:"-"` +} + +// emailSecurityTimeseriesGroupThreatCategoryResponseJSON contains the JSON +// metadata for the struct [EmailSecurityTimeseriesGroupThreatCategoryResponse] +type emailSecurityTimeseriesGroupThreatCategoryResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupThreatCategoryResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupThreatCategoryResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupThreatCategoryResponseSerie0 struct { + BrandImpersonation []string `json:"BrandImpersonation,required"` + CredentialHarvester []string `json:"CredentialHarvester,required"` + IdentityDeception []string `json:"IdentityDeception,required"` + Link []string `json:"Link,required"` + JSON emailSecurityTimeseriesGroupThreatCategoryResponseSerie0JSON `json:"-"` +} + +// emailSecurityTimeseriesGroupThreatCategoryResponseSerie0JSON contains the JSON +// metadata for the struct +// [EmailSecurityTimeseriesGroupThreatCategoryResponseSerie0] +type emailSecurityTimeseriesGroupThreatCategoryResponseSerie0JSON struct { + BrandImpersonation apijson.Field + CredentialHarvester apijson.Field + IdentityDeception apijson.Field + Link apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupThreatCategoryResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupThreatCategoryResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupTLSVersionResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 EmailSecurityTimeseriesGroupTLSVersionResponseSerie0 `json:"serie_0,required"` + JSON emailSecurityTimeseriesGroupTLSVersionResponseJSON `json:"-"` +} + +// emailSecurityTimeseriesGroupTLSVersionResponseJSON contains the JSON metadata +// for the struct [EmailSecurityTimeseriesGroupTLSVersionResponse] +type emailSecurityTimeseriesGroupTLSVersionResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupTLSVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupTLSVersionResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupTLSVersionResponseSerie0 struct { + TLS1_0 []string `json:"TLS 1.0,required"` + TLS1_1 []string `json:"TLS 1.1,required"` + TLS1_2 []string `json:"TLS 1.2,required"` + TLS1_3 []string `json:"TLS 1.3,required"` + JSON emailSecurityTimeseriesGroupTLSVersionResponseSerie0JSON `json:"-"` +} + +// emailSecurityTimeseriesGroupTLSVersionResponseSerie0JSON contains the JSON +// metadata for the struct [EmailSecurityTimeseriesGroupTLSVersionResponseSerie0] +type emailSecurityTimeseriesGroupTLSVersionResponseSerie0JSON struct { + TLS1_0 apijson.Field + TLS1_1 apijson.Field + TLS1_2 apijson.Field + TLS1_3 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupTLSVersionResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupTLSVersionResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupARCParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[EmailSecurityTimeseriesGroupARCParamsAggInterval] `query:"aggInterval"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecurityTimeseriesGroupARCParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecurityTimeseriesGroupARCParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecurityTimeseriesGroupARCParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecurityTimeseriesGroupARCParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecurityTimeseriesGroupARCParamsSPF] `query:"spf"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecurityTimeseriesGroupARCParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecurityTimeseriesGroupARCParams]'s query parameters +// as `url.Values`. +func (r EmailSecurityTimeseriesGroupARCParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type EmailSecurityTimeseriesGroupARCParamsAggInterval string + +const ( + EmailSecurityTimeseriesGroupARCParamsAggInterval15m EmailSecurityTimeseriesGroupARCParamsAggInterval = "15m" + EmailSecurityTimeseriesGroupARCParamsAggInterval1h EmailSecurityTimeseriesGroupARCParamsAggInterval = "1h" + EmailSecurityTimeseriesGroupARCParamsAggInterval1d EmailSecurityTimeseriesGroupARCParamsAggInterval = "1d" + EmailSecurityTimeseriesGroupARCParamsAggInterval1w EmailSecurityTimeseriesGroupARCParamsAggInterval = "1w" +) + +type EmailSecurityTimeseriesGroupARCParamsDateRange string + +const ( + EmailSecurityTimeseriesGroupARCParamsDateRange1d EmailSecurityTimeseriesGroupARCParamsDateRange = "1d" + EmailSecurityTimeseriesGroupARCParamsDateRange2d EmailSecurityTimeseriesGroupARCParamsDateRange = "2d" + EmailSecurityTimeseriesGroupARCParamsDateRange7d EmailSecurityTimeseriesGroupARCParamsDateRange = "7d" + EmailSecurityTimeseriesGroupARCParamsDateRange14d EmailSecurityTimeseriesGroupARCParamsDateRange = "14d" + EmailSecurityTimeseriesGroupARCParamsDateRange28d EmailSecurityTimeseriesGroupARCParamsDateRange = "28d" + EmailSecurityTimeseriesGroupARCParamsDateRange12w EmailSecurityTimeseriesGroupARCParamsDateRange = "12w" + EmailSecurityTimeseriesGroupARCParamsDateRange24w EmailSecurityTimeseriesGroupARCParamsDateRange = "24w" + EmailSecurityTimeseriesGroupARCParamsDateRange52w EmailSecurityTimeseriesGroupARCParamsDateRange = "52w" + EmailSecurityTimeseriesGroupARCParamsDateRange1dControl EmailSecurityTimeseriesGroupARCParamsDateRange = "1dControl" + EmailSecurityTimeseriesGroupARCParamsDateRange2dControl EmailSecurityTimeseriesGroupARCParamsDateRange = "2dControl" + EmailSecurityTimeseriesGroupARCParamsDateRange7dControl EmailSecurityTimeseriesGroupARCParamsDateRange = "7dControl" + EmailSecurityTimeseriesGroupARCParamsDateRange14dControl EmailSecurityTimeseriesGroupARCParamsDateRange = "14dControl" + EmailSecurityTimeseriesGroupARCParamsDateRange28dControl EmailSecurityTimeseriesGroupARCParamsDateRange = "28dControl" + EmailSecurityTimeseriesGroupARCParamsDateRange12wControl EmailSecurityTimeseriesGroupARCParamsDateRange = "12wControl" + EmailSecurityTimeseriesGroupARCParamsDateRange24wControl EmailSecurityTimeseriesGroupARCParamsDateRange = "24wControl" +) + +type EmailSecurityTimeseriesGroupARCParamsDKIM string + +const ( + EmailSecurityTimeseriesGroupARCParamsDKIMPass EmailSecurityTimeseriesGroupARCParamsDKIM = "PASS" + EmailSecurityTimeseriesGroupARCParamsDKIMNone EmailSecurityTimeseriesGroupARCParamsDKIM = "NONE" + EmailSecurityTimeseriesGroupARCParamsDKIMFail EmailSecurityTimeseriesGroupARCParamsDKIM = "FAIL" +) + +type EmailSecurityTimeseriesGroupARCParamsDMARC string + +const ( + EmailSecurityTimeseriesGroupARCParamsDMARCPass EmailSecurityTimeseriesGroupARCParamsDMARC = "PASS" + EmailSecurityTimeseriesGroupARCParamsDMARCNone EmailSecurityTimeseriesGroupARCParamsDMARC = "NONE" + EmailSecurityTimeseriesGroupARCParamsDMARCFail EmailSecurityTimeseriesGroupARCParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecurityTimeseriesGroupARCParamsFormat string + +const ( + EmailSecurityTimeseriesGroupARCParamsFormatJson EmailSecurityTimeseriesGroupARCParamsFormat = "JSON" + EmailSecurityTimeseriesGroupARCParamsFormatCsv EmailSecurityTimeseriesGroupARCParamsFormat = "CSV" +) + +type EmailSecurityTimeseriesGroupARCParamsSPF string + +const ( + EmailSecurityTimeseriesGroupARCParamsSPFPass EmailSecurityTimeseriesGroupARCParamsSPF = "PASS" + EmailSecurityTimeseriesGroupARCParamsSPFNone EmailSecurityTimeseriesGroupARCParamsSPF = "NONE" + EmailSecurityTimeseriesGroupARCParamsSPFFail EmailSecurityTimeseriesGroupARCParamsSPF = "FAIL" +) + +type EmailSecurityTimeseriesGroupARCParamsTLSVersion string + +const ( + EmailSecurityTimeseriesGroupARCParamsTLSVersionTlSv1_0 EmailSecurityTimeseriesGroupARCParamsTLSVersion = "TLSv1_0" + EmailSecurityTimeseriesGroupARCParamsTLSVersionTlSv1_1 EmailSecurityTimeseriesGroupARCParamsTLSVersion = "TLSv1_1" + EmailSecurityTimeseriesGroupARCParamsTLSVersionTlSv1_2 EmailSecurityTimeseriesGroupARCParamsTLSVersion = "TLSv1_2" + EmailSecurityTimeseriesGroupARCParamsTLSVersionTlSv1_3 EmailSecurityTimeseriesGroupARCParamsTLSVersion = "TLSv1_3" +) + +type EmailSecurityTimeseriesGroupARCResponseEnvelope struct { + Result EmailSecurityTimeseriesGroupARCResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecurityTimeseriesGroupARCResponseEnvelopeJSON `json:"-"` +} + +// emailSecurityTimeseriesGroupARCResponseEnvelopeJSON contains the JSON metadata +// for the struct [EmailSecurityTimeseriesGroupARCResponseEnvelope] +type emailSecurityTimeseriesGroupARCResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupARCResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupARCResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupDKIMParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[EmailSecurityTimeseriesGroupDKIMParamsAggInterval] `query:"aggInterval"` + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecurityTimeseriesGroupDKIMParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecurityTimeseriesGroupDKIMParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecurityTimeseriesGroupDKIMParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecurityTimeseriesGroupDKIMParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecurityTimeseriesGroupDKIMParamsSPF] `query:"spf"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecurityTimeseriesGroupDKIMParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecurityTimeseriesGroupDKIMParams]'s query parameters +// as `url.Values`. +func (r EmailSecurityTimeseriesGroupDKIMParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type EmailSecurityTimeseriesGroupDKIMParamsAggInterval string + +const ( + EmailSecurityTimeseriesGroupDKIMParamsAggInterval15m EmailSecurityTimeseriesGroupDKIMParamsAggInterval = "15m" + EmailSecurityTimeseriesGroupDKIMParamsAggInterval1h EmailSecurityTimeseriesGroupDKIMParamsAggInterval = "1h" + EmailSecurityTimeseriesGroupDKIMParamsAggInterval1d EmailSecurityTimeseriesGroupDKIMParamsAggInterval = "1d" + EmailSecurityTimeseriesGroupDKIMParamsAggInterval1w EmailSecurityTimeseriesGroupDKIMParamsAggInterval = "1w" +) + +type EmailSecurityTimeseriesGroupDKIMParamsARC string + +const ( + EmailSecurityTimeseriesGroupDKIMParamsARCPass EmailSecurityTimeseriesGroupDKIMParamsARC = "PASS" + EmailSecurityTimeseriesGroupDKIMParamsARCNone EmailSecurityTimeseriesGroupDKIMParamsARC = "NONE" + EmailSecurityTimeseriesGroupDKIMParamsARCFail EmailSecurityTimeseriesGroupDKIMParamsARC = "FAIL" +) + +type EmailSecurityTimeseriesGroupDKIMParamsDateRange string + +const ( + EmailSecurityTimeseriesGroupDKIMParamsDateRange1d EmailSecurityTimeseriesGroupDKIMParamsDateRange = "1d" + EmailSecurityTimeseriesGroupDKIMParamsDateRange2d EmailSecurityTimeseriesGroupDKIMParamsDateRange = "2d" + EmailSecurityTimeseriesGroupDKIMParamsDateRange7d EmailSecurityTimeseriesGroupDKIMParamsDateRange = "7d" + EmailSecurityTimeseriesGroupDKIMParamsDateRange14d EmailSecurityTimeseriesGroupDKIMParamsDateRange = "14d" + EmailSecurityTimeseriesGroupDKIMParamsDateRange28d EmailSecurityTimeseriesGroupDKIMParamsDateRange = "28d" + EmailSecurityTimeseriesGroupDKIMParamsDateRange12w EmailSecurityTimeseriesGroupDKIMParamsDateRange = "12w" + EmailSecurityTimeseriesGroupDKIMParamsDateRange24w EmailSecurityTimeseriesGroupDKIMParamsDateRange = "24w" + EmailSecurityTimeseriesGroupDKIMParamsDateRange52w EmailSecurityTimeseriesGroupDKIMParamsDateRange = "52w" + EmailSecurityTimeseriesGroupDKIMParamsDateRange1dControl EmailSecurityTimeseriesGroupDKIMParamsDateRange = "1dControl" + EmailSecurityTimeseriesGroupDKIMParamsDateRange2dControl EmailSecurityTimeseriesGroupDKIMParamsDateRange = "2dControl" + EmailSecurityTimeseriesGroupDKIMParamsDateRange7dControl EmailSecurityTimeseriesGroupDKIMParamsDateRange = "7dControl" + EmailSecurityTimeseriesGroupDKIMParamsDateRange14dControl EmailSecurityTimeseriesGroupDKIMParamsDateRange = "14dControl" + EmailSecurityTimeseriesGroupDKIMParamsDateRange28dControl EmailSecurityTimeseriesGroupDKIMParamsDateRange = "28dControl" + EmailSecurityTimeseriesGroupDKIMParamsDateRange12wControl EmailSecurityTimeseriesGroupDKIMParamsDateRange = "12wControl" + EmailSecurityTimeseriesGroupDKIMParamsDateRange24wControl EmailSecurityTimeseriesGroupDKIMParamsDateRange = "24wControl" +) + +type EmailSecurityTimeseriesGroupDKIMParamsDMARC string + +const ( + EmailSecurityTimeseriesGroupDKIMParamsDMARCPass EmailSecurityTimeseriesGroupDKIMParamsDMARC = "PASS" + EmailSecurityTimeseriesGroupDKIMParamsDMARCNone EmailSecurityTimeseriesGroupDKIMParamsDMARC = "NONE" + EmailSecurityTimeseriesGroupDKIMParamsDMARCFail EmailSecurityTimeseriesGroupDKIMParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecurityTimeseriesGroupDKIMParamsFormat string + +const ( + EmailSecurityTimeseriesGroupDKIMParamsFormatJson EmailSecurityTimeseriesGroupDKIMParamsFormat = "JSON" + EmailSecurityTimeseriesGroupDKIMParamsFormatCsv EmailSecurityTimeseriesGroupDKIMParamsFormat = "CSV" +) + +type EmailSecurityTimeseriesGroupDKIMParamsSPF string + +const ( + EmailSecurityTimeseriesGroupDKIMParamsSPFPass EmailSecurityTimeseriesGroupDKIMParamsSPF = "PASS" + EmailSecurityTimeseriesGroupDKIMParamsSPFNone EmailSecurityTimeseriesGroupDKIMParamsSPF = "NONE" + EmailSecurityTimeseriesGroupDKIMParamsSPFFail EmailSecurityTimeseriesGroupDKIMParamsSPF = "FAIL" +) + +type EmailSecurityTimeseriesGroupDKIMParamsTLSVersion string + +const ( + EmailSecurityTimeseriesGroupDKIMParamsTLSVersionTlSv1_0 EmailSecurityTimeseriesGroupDKIMParamsTLSVersion = "TLSv1_0" + EmailSecurityTimeseriesGroupDKIMParamsTLSVersionTlSv1_1 EmailSecurityTimeseriesGroupDKIMParamsTLSVersion = "TLSv1_1" + EmailSecurityTimeseriesGroupDKIMParamsTLSVersionTlSv1_2 EmailSecurityTimeseriesGroupDKIMParamsTLSVersion = "TLSv1_2" + EmailSecurityTimeseriesGroupDKIMParamsTLSVersionTlSv1_3 EmailSecurityTimeseriesGroupDKIMParamsTLSVersion = "TLSv1_3" +) + +type EmailSecurityTimeseriesGroupDKIMResponseEnvelope struct { + Result EmailSecurityTimeseriesGroupDKIMResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecurityTimeseriesGroupDKIMResponseEnvelopeJSON `json:"-"` +} + +// emailSecurityTimeseriesGroupDKIMResponseEnvelopeJSON contains the JSON metadata +// for the struct [EmailSecurityTimeseriesGroupDKIMResponseEnvelope] +type emailSecurityTimeseriesGroupDKIMResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupDKIMResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupDKIMResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupDMARCParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[EmailSecurityTimeseriesGroupDMARCParamsAggInterval] `query:"aggInterval"` + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecurityTimeseriesGroupDMARCParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecurityTimeseriesGroupDMARCParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecurityTimeseriesGroupDMARCParamsDKIM] `query:"dkim"` + // Format results are returned in. + Format param.Field[EmailSecurityTimeseriesGroupDMARCParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecurityTimeseriesGroupDMARCParamsSPF] `query:"spf"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecurityTimeseriesGroupDMARCParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecurityTimeseriesGroupDMARCParams]'s query parameters +// as `url.Values`. +func (r EmailSecurityTimeseriesGroupDMARCParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type EmailSecurityTimeseriesGroupDMARCParamsAggInterval string + +const ( + EmailSecurityTimeseriesGroupDMARCParamsAggInterval15m EmailSecurityTimeseriesGroupDMARCParamsAggInterval = "15m" + EmailSecurityTimeseriesGroupDMARCParamsAggInterval1h EmailSecurityTimeseriesGroupDMARCParamsAggInterval = "1h" + EmailSecurityTimeseriesGroupDMARCParamsAggInterval1d EmailSecurityTimeseriesGroupDMARCParamsAggInterval = "1d" + EmailSecurityTimeseriesGroupDMARCParamsAggInterval1w EmailSecurityTimeseriesGroupDMARCParamsAggInterval = "1w" +) + +type EmailSecurityTimeseriesGroupDMARCParamsARC string + +const ( + EmailSecurityTimeseriesGroupDMARCParamsARCPass EmailSecurityTimeseriesGroupDMARCParamsARC = "PASS" + EmailSecurityTimeseriesGroupDMARCParamsARCNone EmailSecurityTimeseriesGroupDMARCParamsARC = "NONE" + EmailSecurityTimeseriesGroupDMARCParamsARCFail EmailSecurityTimeseriesGroupDMARCParamsARC = "FAIL" +) + +type EmailSecurityTimeseriesGroupDMARCParamsDateRange string + +const ( + EmailSecurityTimeseriesGroupDMARCParamsDateRange1d EmailSecurityTimeseriesGroupDMARCParamsDateRange = "1d" + EmailSecurityTimeseriesGroupDMARCParamsDateRange2d EmailSecurityTimeseriesGroupDMARCParamsDateRange = "2d" + EmailSecurityTimeseriesGroupDMARCParamsDateRange7d EmailSecurityTimeseriesGroupDMARCParamsDateRange = "7d" + EmailSecurityTimeseriesGroupDMARCParamsDateRange14d EmailSecurityTimeseriesGroupDMARCParamsDateRange = "14d" + EmailSecurityTimeseriesGroupDMARCParamsDateRange28d EmailSecurityTimeseriesGroupDMARCParamsDateRange = "28d" + EmailSecurityTimeseriesGroupDMARCParamsDateRange12w EmailSecurityTimeseriesGroupDMARCParamsDateRange = "12w" + EmailSecurityTimeseriesGroupDMARCParamsDateRange24w EmailSecurityTimeseriesGroupDMARCParamsDateRange = "24w" + EmailSecurityTimeseriesGroupDMARCParamsDateRange52w EmailSecurityTimeseriesGroupDMARCParamsDateRange = "52w" + EmailSecurityTimeseriesGroupDMARCParamsDateRange1dControl EmailSecurityTimeseriesGroupDMARCParamsDateRange = "1dControl" + EmailSecurityTimeseriesGroupDMARCParamsDateRange2dControl EmailSecurityTimeseriesGroupDMARCParamsDateRange = "2dControl" + EmailSecurityTimeseriesGroupDMARCParamsDateRange7dControl EmailSecurityTimeseriesGroupDMARCParamsDateRange = "7dControl" + EmailSecurityTimeseriesGroupDMARCParamsDateRange14dControl EmailSecurityTimeseriesGroupDMARCParamsDateRange = "14dControl" + EmailSecurityTimeseriesGroupDMARCParamsDateRange28dControl EmailSecurityTimeseriesGroupDMARCParamsDateRange = "28dControl" + EmailSecurityTimeseriesGroupDMARCParamsDateRange12wControl EmailSecurityTimeseriesGroupDMARCParamsDateRange = "12wControl" + EmailSecurityTimeseriesGroupDMARCParamsDateRange24wControl EmailSecurityTimeseriesGroupDMARCParamsDateRange = "24wControl" +) + +type EmailSecurityTimeseriesGroupDMARCParamsDKIM string + +const ( + EmailSecurityTimeseriesGroupDMARCParamsDKIMPass EmailSecurityTimeseriesGroupDMARCParamsDKIM = "PASS" + EmailSecurityTimeseriesGroupDMARCParamsDKIMNone EmailSecurityTimeseriesGroupDMARCParamsDKIM = "NONE" + EmailSecurityTimeseriesGroupDMARCParamsDKIMFail EmailSecurityTimeseriesGroupDMARCParamsDKIM = "FAIL" +) + +// Format results are returned in. +type EmailSecurityTimeseriesGroupDMARCParamsFormat string + +const ( + EmailSecurityTimeseriesGroupDMARCParamsFormatJson EmailSecurityTimeseriesGroupDMARCParamsFormat = "JSON" + EmailSecurityTimeseriesGroupDMARCParamsFormatCsv EmailSecurityTimeseriesGroupDMARCParamsFormat = "CSV" +) + +type EmailSecurityTimeseriesGroupDMARCParamsSPF string + +const ( + EmailSecurityTimeseriesGroupDMARCParamsSPFPass EmailSecurityTimeseriesGroupDMARCParamsSPF = "PASS" + EmailSecurityTimeseriesGroupDMARCParamsSPFNone EmailSecurityTimeseriesGroupDMARCParamsSPF = "NONE" + EmailSecurityTimeseriesGroupDMARCParamsSPFFail EmailSecurityTimeseriesGroupDMARCParamsSPF = "FAIL" +) + +type EmailSecurityTimeseriesGroupDMARCParamsTLSVersion string + +const ( + EmailSecurityTimeseriesGroupDMARCParamsTLSVersionTlSv1_0 EmailSecurityTimeseriesGroupDMARCParamsTLSVersion = "TLSv1_0" + EmailSecurityTimeseriesGroupDMARCParamsTLSVersionTlSv1_1 EmailSecurityTimeseriesGroupDMARCParamsTLSVersion = "TLSv1_1" + EmailSecurityTimeseriesGroupDMARCParamsTLSVersionTlSv1_2 EmailSecurityTimeseriesGroupDMARCParamsTLSVersion = "TLSv1_2" + EmailSecurityTimeseriesGroupDMARCParamsTLSVersionTlSv1_3 EmailSecurityTimeseriesGroupDMARCParamsTLSVersion = "TLSv1_3" +) + +type EmailSecurityTimeseriesGroupDMARCResponseEnvelope struct { + Result EmailSecurityTimeseriesGroupDMARCResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecurityTimeseriesGroupDMARCResponseEnvelopeJSON `json:"-"` +} + +// emailSecurityTimeseriesGroupDMARCResponseEnvelopeJSON contains the JSON metadata +// for the struct [EmailSecurityTimeseriesGroupDMARCResponseEnvelope] +type emailSecurityTimeseriesGroupDMARCResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupDMARCResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupDMARCResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupMaliciousParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[EmailSecurityTimeseriesGroupMaliciousParamsAggInterval] `query:"aggInterval"` + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecurityTimeseriesGroupMaliciousParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecurityTimeseriesGroupMaliciousParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecurityTimeseriesGroupMaliciousParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecurityTimeseriesGroupMaliciousParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecurityTimeseriesGroupMaliciousParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecurityTimeseriesGroupMaliciousParamsSPF] `query:"spf"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecurityTimeseriesGroupMaliciousParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecurityTimeseriesGroupMaliciousParams]'s query +// parameters as `url.Values`. +func (r EmailSecurityTimeseriesGroupMaliciousParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type EmailSecurityTimeseriesGroupMaliciousParamsAggInterval string + +const ( + EmailSecurityTimeseriesGroupMaliciousParamsAggInterval15m EmailSecurityTimeseriesGroupMaliciousParamsAggInterval = "15m" + EmailSecurityTimeseriesGroupMaliciousParamsAggInterval1h EmailSecurityTimeseriesGroupMaliciousParamsAggInterval = "1h" + EmailSecurityTimeseriesGroupMaliciousParamsAggInterval1d EmailSecurityTimeseriesGroupMaliciousParamsAggInterval = "1d" + EmailSecurityTimeseriesGroupMaliciousParamsAggInterval1w EmailSecurityTimeseriesGroupMaliciousParamsAggInterval = "1w" +) + +type EmailSecurityTimeseriesGroupMaliciousParamsARC string + +const ( + EmailSecurityTimeseriesGroupMaliciousParamsARCPass EmailSecurityTimeseriesGroupMaliciousParamsARC = "PASS" + EmailSecurityTimeseriesGroupMaliciousParamsARCNone EmailSecurityTimeseriesGroupMaliciousParamsARC = "NONE" + EmailSecurityTimeseriesGroupMaliciousParamsARCFail EmailSecurityTimeseriesGroupMaliciousParamsARC = "FAIL" +) + +type EmailSecurityTimeseriesGroupMaliciousParamsDateRange string + +const ( + EmailSecurityTimeseriesGroupMaliciousParamsDateRange1d EmailSecurityTimeseriesGroupMaliciousParamsDateRange = "1d" + EmailSecurityTimeseriesGroupMaliciousParamsDateRange2d EmailSecurityTimeseriesGroupMaliciousParamsDateRange = "2d" + EmailSecurityTimeseriesGroupMaliciousParamsDateRange7d EmailSecurityTimeseriesGroupMaliciousParamsDateRange = "7d" + EmailSecurityTimeseriesGroupMaliciousParamsDateRange14d EmailSecurityTimeseriesGroupMaliciousParamsDateRange = "14d" + EmailSecurityTimeseriesGroupMaliciousParamsDateRange28d EmailSecurityTimeseriesGroupMaliciousParamsDateRange = "28d" + EmailSecurityTimeseriesGroupMaliciousParamsDateRange12w EmailSecurityTimeseriesGroupMaliciousParamsDateRange = "12w" + EmailSecurityTimeseriesGroupMaliciousParamsDateRange24w EmailSecurityTimeseriesGroupMaliciousParamsDateRange = "24w" + EmailSecurityTimeseriesGroupMaliciousParamsDateRange52w EmailSecurityTimeseriesGroupMaliciousParamsDateRange = "52w" + EmailSecurityTimeseriesGroupMaliciousParamsDateRange1dControl EmailSecurityTimeseriesGroupMaliciousParamsDateRange = "1dControl" + EmailSecurityTimeseriesGroupMaliciousParamsDateRange2dControl EmailSecurityTimeseriesGroupMaliciousParamsDateRange = "2dControl" + EmailSecurityTimeseriesGroupMaliciousParamsDateRange7dControl EmailSecurityTimeseriesGroupMaliciousParamsDateRange = "7dControl" + EmailSecurityTimeseriesGroupMaliciousParamsDateRange14dControl EmailSecurityTimeseriesGroupMaliciousParamsDateRange = "14dControl" + EmailSecurityTimeseriesGroupMaliciousParamsDateRange28dControl EmailSecurityTimeseriesGroupMaliciousParamsDateRange = "28dControl" + EmailSecurityTimeseriesGroupMaliciousParamsDateRange12wControl EmailSecurityTimeseriesGroupMaliciousParamsDateRange = "12wControl" + EmailSecurityTimeseriesGroupMaliciousParamsDateRange24wControl EmailSecurityTimeseriesGroupMaliciousParamsDateRange = "24wControl" +) + +type EmailSecurityTimeseriesGroupMaliciousParamsDKIM string + +const ( + EmailSecurityTimeseriesGroupMaliciousParamsDKIMPass EmailSecurityTimeseriesGroupMaliciousParamsDKIM = "PASS" + EmailSecurityTimeseriesGroupMaliciousParamsDKIMNone EmailSecurityTimeseriesGroupMaliciousParamsDKIM = "NONE" + EmailSecurityTimeseriesGroupMaliciousParamsDKIMFail EmailSecurityTimeseriesGroupMaliciousParamsDKIM = "FAIL" +) + +type EmailSecurityTimeseriesGroupMaliciousParamsDMARC string + +const ( + EmailSecurityTimeseriesGroupMaliciousParamsDMARCPass EmailSecurityTimeseriesGroupMaliciousParamsDMARC = "PASS" + EmailSecurityTimeseriesGroupMaliciousParamsDMARCNone EmailSecurityTimeseriesGroupMaliciousParamsDMARC = "NONE" + EmailSecurityTimeseriesGroupMaliciousParamsDMARCFail EmailSecurityTimeseriesGroupMaliciousParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecurityTimeseriesGroupMaliciousParamsFormat string + +const ( + EmailSecurityTimeseriesGroupMaliciousParamsFormatJson EmailSecurityTimeseriesGroupMaliciousParamsFormat = "JSON" + EmailSecurityTimeseriesGroupMaliciousParamsFormatCsv EmailSecurityTimeseriesGroupMaliciousParamsFormat = "CSV" +) + +type EmailSecurityTimeseriesGroupMaliciousParamsSPF string + +const ( + EmailSecurityTimeseriesGroupMaliciousParamsSPFPass EmailSecurityTimeseriesGroupMaliciousParamsSPF = "PASS" + EmailSecurityTimeseriesGroupMaliciousParamsSPFNone EmailSecurityTimeseriesGroupMaliciousParamsSPF = "NONE" + EmailSecurityTimeseriesGroupMaliciousParamsSPFFail EmailSecurityTimeseriesGroupMaliciousParamsSPF = "FAIL" +) + +type EmailSecurityTimeseriesGroupMaliciousParamsTLSVersion string + +const ( + EmailSecurityTimeseriesGroupMaliciousParamsTLSVersionTlSv1_0 EmailSecurityTimeseriesGroupMaliciousParamsTLSVersion = "TLSv1_0" + EmailSecurityTimeseriesGroupMaliciousParamsTLSVersionTlSv1_1 EmailSecurityTimeseriesGroupMaliciousParamsTLSVersion = "TLSv1_1" + EmailSecurityTimeseriesGroupMaliciousParamsTLSVersionTlSv1_2 EmailSecurityTimeseriesGroupMaliciousParamsTLSVersion = "TLSv1_2" + EmailSecurityTimeseriesGroupMaliciousParamsTLSVersionTlSv1_3 EmailSecurityTimeseriesGroupMaliciousParamsTLSVersion = "TLSv1_3" +) + +type EmailSecurityTimeseriesGroupMaliciousResponseEnvelope struct { + Result EmailSecurityTimeseriesGroupMaliciousResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecurityTimeseriesGroupMaliciousResponseEnvelopeJSON `json:"-"` +} + +// emailSecurityTimeseriesGroupMaliciousResponseEnvelopeJSON contains the JSON +// metadata for the struct [EmailSecurityTimeseriesGroupMaliciousResponseEnvelope] +type emailSecurityTimeseriesGroupMaliciousResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupMaliciousResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupMaliciousResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupSpamParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[EmailSecurityTimeseriesGroupSpamParamsAggInterval] `query:"aggInterval"` + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecurityTimeseriesGroupSpamParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecurityTimeseriesGroupSpamParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecurityTimeseriesGroupSpamParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecurityTimeseriesGroupSpamParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecurityTimeseriesGroupSpamParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecurityTimeseriesGroupSpamParamsSPF] `query:"spf"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecurityTimeseriesGroupSpamParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecurityTimeseriesGroupSpamParams]'s query parameters +// as `url.Values`. +func (r EmailSecurityTimeseriesGroupSpamParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type EmailSecurityTimeseriesGroupSpamParamsAggInterval string + +const ( + EmailSecurityTimeseriesGroupSpamParamsAggInterval15m EmailSecurityTimeseriesGroupSpamParamsAggInterval = "15m" + EmailSecurityTimeseriesGroupSpamParamsAggInterval1h EmailSecurityTimeseriesGroupSpamParamsAggInterval = "1h" + EmailSecurityTimeseriesGroupSpamParamsAggInterval1d EmailSecurityTimeseriesGroupSpamParamsAggInterval = "1d" + EmailSecurityTimeseriesGroupSpamParamsAggInterval1w EmailSecurityTimeseriesGroupSpamParamsAggInterval = "1w" +) + +type EmailSecurityTimeseriesGroupSpamParamsARC string + +const ( + EmailSecurityTimeseriesGroupSpamParamsARCPass EmailSecurityTimeseriesGroupSpamParamsARC = "PASS" + EmailSecurityTimeseriesGroupSpamParamsARCNone EmailSecurityTimeseriesGroupSpamParamsARC = "NONE" + EmailSecurityTimeseriesGroupSpamParamsARCFail EmailSecurityTimeseriesGroupSpamParamsARC = "FAIL" +) + +type EmailSecurityTimeseriesGroupSpamParamsDateRange string + +const ( + EmailSecurityTimeseriesGroupSpamParamsDateRange1d EmailSecurityTimeseriesGroupSpamParamsDateRange = "1d" + EmailSecurityTimeseriesGroupSpamParamsDateRange2d EmailSecurityTimeseriesGroupSpamParamsDateRange = "2d" + EmailSecurityTimeseriesGroupSpamParamsDateRange7d EmailSecurityTimeseriesGroupSpamParamsDateRange = "7d" + EmailSecurityTimeseriesGroupSpamParamsDateRange14d EmailSecurityTimeseriesGroupSpamParamsDateRange = "14d" + EmailSecurityTimeseriesGroupSpamParamsDateRange28d EmailSecurityTimeseriesGroupSpamParamsDateRange = "28d" + EmailSecurityTimeseriesGroupSpamParamsDateRange12w EmailSecurityTimeseriesGroupSpamParamsDateRange = "12w" + EmailSecurityTimeseriesGroupSpamParamsDateRange24w EmailSecurityTimeseriesGroupSpamParamsDateRange = "24w" + EmailSecurityTimeseriesGroupSpamParamsDateRange52w EmailSecurityTimeseriesGroupSpamParamsDateRange = "52w" + EmailSecurityTimeseriesGroupSpamParamsDateRange1dControl EmailSecurityTimeseriesGroupSpamParamsDateRange = "1dControl" + EmailSecurityTimeseriesGroupSpamParamsDateRange2dControl EmailSecurityTimeseriesGroupSpamParamsDateRange = "2dControl" + EmailSecurityTimeseriesGroupSpamParamsDateRange7dControl EmailSecurityTimeseriesGroupSpamParamsDateRange = "7dControl" + EmailSecurityTimeseriesGroupSpamParamsDateRange14dControl EmailSecurityTimeseriesGroupSpamParamsDateRange = "14dControl" + EmailSecurityTimeseriesGroupSpamParamsDateRange28dControl EmailSecurityTimeseriesGroupSpamParamsDateRange = "28dControl" + EmailSecurityTimeseriesGroupSpamParamsDateRange12wControl EmailSecurityTimeseriesGroupSpamParamsDateRange = "12wControl" + EmailSecurityTimeseriesGroupSpamParamsDateRange24wControl EmailSecurityTimeseriesGroupSpamParamsDateRange = "24wControl" +) + +type EmailSecurityTimeseriesGroupSpamParamsDKIM string + +const ( + EmailSecurityTimeseriesGroupSpamParamsDKIMPass EmailSecurityTimeseriesGroupSpamParamsDKIM = "PASS" + EmailSecurityTimeseriesGroupSpamParamsDKIMNone EmailSecurityTimeseriesGroupSpamParamsDKIM = "NONE" + EmailSecurityTimeseriesGroupSpamParamsDKIMFail EmailSecurityTimeseriesGroupSpamParamsDKIM = "FAIL" +) + +type EmailSecurityTimeseriesGroupSpamParamsDMARC string + +const ( + EmailSecurityTimeseriesGroupSpamParamsDMARCPass EmailSecurityTimeseriesGroupSpamParamsDMARC = "PASS" + EmailSecurityTimeseriesGroupSpamParamsDMARCNone EmailSecurityTimeseriesGroupSpamParamsDMARC = "NONE" + EmailSecurityTimeseriesGroupSpamParamsDMARCFail EmailSecurityTimeseriesGroupSpamParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecurityTimeseriesGroupSpamParamsFormat string + +const ( + EmailSecurityTimeseriesGroupSpamParamsFormatJson EmailSecurityTimeseriesGroupSpamParamsFormat = "JSON" + EmailSecurityTimeseriesGroupSpamParamsFormatCsv EmailSecurityTimeseriesGroupSpamParamsFormat = "CSV" +) + +type EmailSecurityTimeseriesGroupSpamParamsSPF string + +const ( + EmailSecurityTimeseriesGroupSpamParamsSPFPass EmailSecurityTimeseriesGroupSpamParamsSPF = "PASS" + EmailSecurityTimeseriesGroupSpamParamsSPFNone EmailSecurityTimeseriesGroupSpamParamsSPF = "NONE" + EmailSecurityTimeseriesGroupSpamParamsSPFFail EmailSecurityTimeseriesGroupSpamParamsSPF = "FAIL" +) + +type EmailSecurityTimeseriesGroupSpamParamsTLSVersion string + +const ( + EmailSecurityTimeseriesGroupSpamParamsTLSVersionTlSv1_0 EmailSecurityTimeseriesGroupSpamParamsTLSVersion = "TLSv1_0" + EmailSecurityTimeseriesGroupSpamParamsTLSVersionTlSv1_1 EmailSecurityTimeseriesGroupSpamParamsTLSVersion = "TLSv1_1" + EmailSecurityTimeseriesGroupSpamParamsTLSVersionTlSv1_2 EmailSecurityTimeseriesGroupSpamParamsTLSVersion = "TLSv1_2" + EmailSecurityTimeseriesGroupSpamParamsTLSVersionTlSv1_3 EmailSecurityTimeseriesGroupSpamParamsTLSVersion = "TLSv1_3" +) + +type EmailSecurityTimeseriesGroupSpamResponseEnvelope struct { + Result EmailSecurityTimeseriesGroupSpamResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecurityTimeseriesGroupSpamResponseEnvelopeJSON `json:"-"` +} + +// emailSecurityTimeseriesGroupSpamResponseEnvelopeJSON contains the JSON metadata +// for the struct [EmailSecurityTimeseriesGroupSpamResponseEnvelope] +type emailSecurityTimeseriesGroupSpamResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupSpamResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupSpamResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupSPFParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[EmailSecurityTimeseriesGroupSPFParamsAggInterval] `query:"aggInterval"` + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecurityTimeseriesGroupSPFParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecurityTimeseriesGroupSPFParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecurityTimeseriesGroupSPFParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecurityTimeseriesGroupSPFParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecurityTimeseriesGroupSPFParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecurityTimeseriesGroupSPFParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecurityTimeseriesGroupSPFParams]'s query parameters +// as `url.Values`. +func (r EmailSecurityTimeseriesGroupSPFParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type EmailSecurityTimeseriesGroupSPFParamsAggInterval string + +const ( + EmailSecurityTimeseriesGroupSPFParamsAggInterval15m EmailSecurityTimeseriesGroupSPFParamsAggInterval = "15m" + EmailSecurityTimeseriesGroupSPFParamsAggInterval1h EmailSecurityTimeseriesGroupSPFParamsAggInterval = "1h" + EmailSecurityTimeseriesGroupSPFParamsAggInterval1d EmailSecurityTimeseriesGroupSPFParamsAggInterval = "1d" + EmailSecurityTimeseriesGroupSPFParamsAggInterval1w EmailSecurityTimeseriesGroupSPFParamsAggInterval = "1w" +) + +type EmailSecurityTimeseriesGroupSPFParamsARC string + +const ( + EmailSecurityTimeseriesGroupSPFParamsARCPass EmailSecurityTimeseriesGroupSPFParamsARC = "PASS" + EmailSecurityTimeseriesGroupSPFParamsARCNone EmailSecurityTimeseriesGroupSPFParamsARC = "NONE" + EmailSecurityTimeseriesGroupSPFParamsARCFail EmailSecurityTimeseriesGroupSPFParamsARC = "FAIL" +) + +type EmailSecurityTimeseriesGroupSPFParamsDateRange string + +const ( + EmailSecurityTimeseriesGroupSPFParamsDateRange1d EmailSecurityTimeseriesGroupSPFParamsDateRange = "1d" + EmailSecurityTimeseriesGroupSPFParamsDateRange2d EmailSecurityTimeseriesGroupSPFParamsDateRange = "2d" + EmailSecurityTimeseriesGroupSPFParamsDateRange7d EmailSecurityTimeseriesGroupSPFParamsDateRange = "7d" + EmailSecurityTimeseriesGroupSPFParamsDateRange14d EmailSecurityTimeseriesGroupSPFParamsDateRange = "14d" + EmailSecurityTimeseriesGroupSPFParamsDateRange28d EmailSecurityTimeseriesGroupSPFParamsDateRange = "28d" + EmailSecurityTimeseriesGroupSPFParamsDateRange12w EmailSecurityTimeseriesGroupSPFParamsDateRange = "12w" + EmailSecurityTimeseriesGroupSPFParamsDateRange24w EmailSecurityTimeseriesGroupSPFParamsDateRange = "24w" + EmailSecurityTimeseriesGroupSPFParamsDateRange52w EmailSecurityTimeseriesGroupSPFParamsDateRange = "52w" + EmailSecurityTimeseriesGroupSPFParamsDateRange1dControl EmailSecurityTimeseriesGroupSPFParamsDateRange = "1dControl" + EmailSecurityTimeseriesGroupSPFParamsDateRange2dControl EmailSecurityTimeseriesGroupSPFParamsDateRange = "2dControl" + EmailSecurityTimeseriesGroupSPFParamsDateRange7dControl EmailSecurityTimeseriesGroupSPFParamsDateRange = "7dControl" + EmailSecurityTimeseriesGroupSPFParamsDateRange14dControl EmailSecurityTimeseriesGroupSPFParamsDateRange = "14dControl" + EmailSecurityTimeseriesGroupSPFParamsDateRange28dControl EmailSecurityTimeseriesGroupSPFParamsDateRange = "28dControl" + EmailSecurityTimeseriesGroupSPFParamsDateRange12wControl EmailSecurityTimeseriesGroupSPFParamsDateRange = "12wControl" + EmailSecurityTimeseriesGroupSPFParamsDateRange24wControl EmailSecurityTimeseriesGroupSPFParamsDateRange = "24wControl" +) + +type EmailSecurityTimeseriesGroupSPFParamsDKIM string + +const ( + EmailSecurityTimeseriesGroupSPFParamsDKIMPass EmailSecurityTimeseriesGroupSPFParamsDKIM = "PASS" + EmailSecurityTimeseriesGroupSPFParamsDKIMNone EmailSecurityTimeseriesGroupSPFParamsDKIM = "NONE" + EmailSecurityTimeseriesGroupSPFParamsDKIMFail EmailSecurityTimeseriesGroupSPFParamsDKIM = "FAIL" +) + +type EmailSecurityTimeseriesGroupSPFParamsDMARC string + +const ( + EmailSecurityTimeseriesGroupSPFParamsDMARCPass EmailSecurityTimeseriesGroupSPFParamsDMARC = "PASS" + EmailSecurityTimeseriesGroupSPFParamsDMARCNone EmailSecurityTimeseriesGroupSPFParamsDMARC = "NONE" + EmailSecurityTimeseriesGroupSPFParamsDMARCFail EmailSecurityTimeseriesGroupSPFParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecurityTimeseriesGroupSPFParamsFormat string + +const ( + EmailSecurityTimeseriesGroupSPFParamsFormatJson EmailSecurityTimeseriesGroupSPFParamsFormat = "JSON" + EmailSecurityTimeseriesGroupSPFParamsFormatCsv EmailSecurityTimeseriesGroupSPFParamsFormat = "CSV" +) + +type EmailSecurityTimeseriesGroupSPFParamsTLSVersion string + +const ( + EmailSecurityTimeseriesGroupSPFParamsTLSVersionTlSv1_0 EmailSecurityTimeseriesGroupSPFParamsTLSVersion = "TLSv1_0" + EmailSecurityTimeseriesGroupSPFParamsTLSVersionTlSv1_1 EmailSecurityTimeseriesGroupSPFParamsTLSVersion = "TLSv1_1" + EmailSecurityTimeseriesGroupSPFParamsTLSVersionTlSv1_2 EmailSecurityTimeseriesGroupSPFParamsTLSVersion = "TLSv1_2" + EmailSecurityTimeseriesGroupSPFParamsTLSVersionTlSv1_3 EmailSecurityTimeseriesGroupSPFParamsTLSVersion = "TLSv1_3" +) + +type EmailSecurityTimeseriesGroupSPFResponseEnvelope struct { + Result EmailSecurityTimeseriesGroupSPFResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecurityTimeseriesGroupSPFResponseEnvelopeJSON `json:"-"` +} + +// emailSecurityTimeseriesGroupSPFResponseEnvelopeJSON contains the JSON metadata +// for the struct [EmailSecurityTimeseriesGroupSPFResponseEnvelope] +type emailSecurityTimeseriesGroupSPFResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupSPFResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupSPFResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupSpoofParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[EmailSecurityTimeseriesGroupSpoofParamsAggInterval] `query:"aggInterval"` + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecurityTimeseriesGroupSpoofParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecurityTimeseriesGroupSpoofParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecurityTimeseriesGroupSpoofParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecurityTimeseriesGroupSpoofParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecurityTimeseriesGroupSpoofParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecurityTimeseriesGroupSpoofParamsSPF] `query:"spf"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecurityTimeseriesGroupSpoofParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecurityTimeseriesGroupSpoofParams]'s query parameters +// as `url.Values`. +func (r EmailSecurityTimeseriesGroupSpoofParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type EmailSecurityTimeseriesGroupSpoofParamsAggInterval string + +const ( + EmailSecurityTimeseriesGroupSpoofParamsAggInterval15m EmailSecurityTimeseriesGroupSpoofParamsAggInterval = "15m" + EmailSecurityTimeseriesGroupSpoofParamsAggInterval1h EmailSecurityTimeseriesGroupSpoofParamsAggInterval = "1h" + EmailSecurityTimeseriesGroupSpoofParamsAggInterval1d EmailSecurityTimeseriesGroupSpoofParamsAggInterval = "1d" + EmailSecurityTimeseriesGroupSpoofParamsAggInterval1w EmailSecurityTimeseriesGroupSpoofParamsAggInterval = "1w" +) + +type EmailSecurityTimeseriesGroupSpoofParamsARC string + +const ( + EmailSecurityTimeseriesGroupSpoofParamsARCPass EmailSecurityTimeseriesGroupSpoofParamsARC = "PASS" + EmailSecurityTimeseriesGroupSpoofParamsARCNone EmailSecurityTimeseriesGroupSpoofParamsARC = "NONE" + EmailSecurityTimeseriesGroupSpoofParamsARCFail EmailSecurityTimeseriesGroupSpoofParamsARC = "FAIL" +) + +type EmailSecurityTimeseriesGroupSpoofParamsDateRange string + +const ( + EmailSecurityTimeseriesGroupSpoofParamsDateRange1d EmailSecurityTimeseriesGroupSpoofParamsDateRange = "1d" + EmailSecurityTimeseriesGroupSpoofParamsDateRange2d EmailSecurityTimeseriesGroupSpoofParamsDateRange = "2d" + EmailSecurityTimeseriesGroupSpoofParamsDateRange7d EmailSecurityTimeseriesGroupSpoofParamsDateRange = "7d" + EmailSecurityTimeseriesGroupSpoofParamsDateRange14d EmailSecurityTimeseriesGroupSpoofParamsDateRange = "14d" + EmailSecurityTimeseriesGroupSpoofParamsDateRange28d EmailSecurityTimeseriesGroupSpoofParamsDateRange = "28d" + EmailSecurityTimeseriesGroupSpoofParamsDateRange12w EmailSecurityTimeseriesGroupSpoofParamsDateRange = "12w" + EmailSecurityTimeseriesGroupSpoofParamsDateRange24w EmailSecurityTimeseriesGroupSpoofParamsDateRange = "24w" + EmailSecurityTimeseriesGroupSpoofParamsDateRange52w EmailSecurityTimeseriesGroupSpoofParamsDateRange = "52w" + EmailSecurityTimeseriesGroupSpoofParamsDateRange1dControl EmailSecurityTimeseriesGroupSpoofParamsDateRange = "1dControl" + EmailSecurityTimeseriesGroupSpoofParamsDateRange2dControl EmailSecurityTimeseriesGroupSpoofParamsDateRange = "2dControl" + EmailSecurityTimeseriesGroupSpoofParamsDateRange7dControl EmailSecurityTimeseriesGroupSpoofParamsDateRange = "7dControl" + EmailSecurityTimeseriesGroupSpoofParamsDateRange14dControl EmailSecurityTimeseriesGroupSpoofParamsDateRange = "14dControl" + EmailSecurityTimeseriesGroupSpoofParamsDateRange28dControl EmailSecurityTimeseriesGroupSpoofParamsDateRange = "28dControl" + EmailSecurityTimeseriesGroupSpoofParamsDateRange12wControl EmailSecurityTimeseriesGroupSpoofParamsDateRange = "12wControl" + EmailSecurityTimeseriesGroupSpoofParamsDateRange24wControl EmailSecurityTimeseriesGroupSpoofParamsDateRange = "24wControl" +) + +type EmailSecurityTimeseriesGroupSpoofParamsDKIM string + +const ( + EmailSecurityTimeseriesGroupSpoofParamsDKIMPass EmailSecurityTimeseriesGroupSpoofParamsDKIM = "PASS" + EmailSecurityTimeseriesGroupSpoofParamsDKIMNone EmailSecurityTimeseriesGroupSpoofParamsDKIM = "NONE" + EmailSecurityTimeseriesGroupSpoofParamsDKIMFail EmailSecurityTimeseriesGroupSpoofParamsDKIM = "FAIL" +) + +type EmailSecurityTimeseriesGroupSpoofParamsDMARC string + +const ( + EmailSecurityTimeseriesGroupSpoofParamsDMARCPass EmailSecurityTimeseriesGroupSpoofParamsDMARC = "PASS" + EmailSecurityTimeseriesGroupSpoofParamsDMARCNone EmailSecurityTimeseriesGroupSpoofParamsDMARC = "NONE" + EmailSecurityTimeseriesGroupSpoofParamsDMARCFail EmailSecurityTimeseriesGroupSpoofParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecurityTimeseriesGroupSpoofParamsFormat string + +const ( + EmailSecurityTimeseriesGroupSpoofParamsFormatJson EmailSecurityTimeseriesGroupSpoofParamsFormat = "JSON" + EmailSecurityTimeseriesGroupSpoofParamsFormatCsv EmailSecurityTimeseriesGroupSpoofParamsFormat = "CSV" +) + +type EmailSecurityTimeseriesGroupSpoofParamsSPF string + +const ( + EmailSecurityTimeseriesGroupSpoofParamsSPFPass EmailSecurityTimeseriesGroupSpoofParamsSPF = "PASS" + EmailSecurityTimeseriesGroupSpoofParamsSPFNone EmailSecurityTimeseriesGroupSpoofParamsSPF = "NONE" + EmailSecurityTimeseriesGroupSpoofParamsSPFFail EmailSecurityTimeseriesGroupSpoofParamsSPF = "FAIL" +) + +type EmailSecurityTimeseriesGroupSpoofParamsTLSVersion string + +const ( + EmailSecurityTimeseriesGroupSpoofParamsTLSVersionTlSv1_0 EmailSecurityTimeseriesGroupSpoofParamsTLSVersion = "TLSv1_0" + EmailSecurityTimeseriesGroupSpoofParamsTLSVersionTlSv1_1 EmailSecurityTimeseriesGroupSpoofParamsTLSVersion = "TLSv1_1" + EmailSecurityTimeseriesGroupSpoofParamsTLSVersionTlSv1_2 EmailSecurityTimeseriesGroupSpoofParamsTLSVersion = "TLSv1_2" + EmailSecurityTimeseriesGroupSpoofParamsTLSVersionTlSv1_3 EmailSecurityTimeseriesGroupSpoofParamsTLSVersion = "TLSv1_3" +) + +type EmailSecurityTimeseriesGroupSpoofResponseEnvelope struct { + Result EmailSecurityTimeseriesGroupSpoofResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecurityTimeseriesGroupSpoofResponseEnvelopeJSON `json:"-"` +} + +// emailSecurityTimeseriesGroupSpoofResponseEnvelopeJSON contains the JSON metadata +// for the struct [EmailSecurityTimeseriesGroupSpoofResponseEnvelope] +type emailSecurityTimeseriesGroupSpoofResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupSpoofResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupSpoofResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupThreatCategoryParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[EmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval] `query:"aggInterval"` + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecurityTimeseriesGroupThreatCategoryParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecurityTimeseriesGroupThreatCategoryParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecurityTimeseriesGroupThreatCategoryParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecurityTimeseriesGroupThreatCategoryParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecurityTimeseriesGroupThreatCategoryParamsSPF] `query:"spf"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecurityTimeseriesGroupThreatCategoryParams]'s query +// parameters as `url.Values`. +func (r EmailSecurityTimeseriesGroupThreatCategoryParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type EmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval string + +const ( + EmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval15m EmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval = "15m" + EmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval1h EmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval = "1h" + EmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval1d EmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval = "1d" + EmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval1w EmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval = "1w" +) + +type EmailSecurityTimeseriesGroupThreatCategoryParamsARC string + +const ( + EmailSecurityTimeseriesGroupThreatCategoryParamsARCPass EmailSecurityTimeseriesGroupThreatCategoryParamsARC = "PASS" + EmailSecurityTimeseriesGroupThreatCategoryParamsARCNone EmailSecurityTimeseriesGroupThreatCategoryParamsARC = "NONE" + EmailSecurityTimeseriesGroupThreatCategoryParamsARCFail EmailSecurityTimeseriesGroupThreatCategoryParamsARC = "FAIL" +) + +type EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange string + +const ( + EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange1d EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "1d" + EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange2d EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "2d" + EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange7d EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "7d" + EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange14d EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "14d" + EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange28d EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "28d" + EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange12w EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "12w" + EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange24w EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "24w" + EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange52w EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "52w" + EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange1dControl EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "1dControl" + EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange2dControl EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "2dControl" + EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange7dControl EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "7dControl" + EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange14dControl EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "14dControl" + EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange28dControl EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "28dControl" + EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange12wControl EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "12wControl" + EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange24wControl EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "24wControl" +) + +type EmailSecurityTimeseriesGroupThreatCategoryParamsDKIM string + +const ( + EmailSecurityTimeseriesGroupThreatCategoryParamsDKIMPass EmailSecurityTimeseriesGroupThreatCategoryParamsDKIM = "PASS" + EmailSecurityTimeseriesGroupThreatCategoryParamsDKIMNone EmailSecurityTimeseriesGroupThreatCategoryParamsDKIM = "NONE" + EmailSecurityTimeseriesGroupThreatCategoryParamsDKIMFail EmailSecurityTimeseriesGroupThreatCategoryParamsDKIM = "FAIL" +) + +type EmailSecurityTimeseriesGroupThreatCategoryParamsDMARC string + +const ( + EmailSecurityTimeseriesGroupThreatCategoryParamsDMARCPass EmailSecurityTimeseriesGroupThreatCategoryParamsDMARC = "PASS" + EmailSecurityTimeseriesGroupThreatCategoryParamsDMARCNone EmailSecurityTimeseriesGroupThreatCategoryParamsDMARC = "NONE" + EmailSecurityTimeseriesGroupThreatCategoryParamsDMARCFail EmailSecurityTimeseriesGroupThreatCategoryParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecurityTimeseriesGroupThreatCategoryParamsFormat string + +const ( + EmailSecurityTimeseriesGroupThreatCategoryParamsFormatJson EmailSecurityTimeseriesGroupThreatCategoryParamsFormat = "JSON" + EmailSecurityTimeseriesGroupThreatCategoryParamsFormatCsv EmailSecurityTimeseriesGroupThreatCategoryParamsFormat = "CSV" +) + +type EmailSecurityTimeseriesGroupThreatCategoryParamsSPF string + +const ( + EmailSecurityTimeseriesGroupThreatCategoryParamsSPFPass EmailSecurityTimeseriesGroupThreatCategoryParamsSPF = "PASS" + EmailSecurityTimeseriesGroupThreatCategoryParamsSPFNone EmailSecurityTimeseriesGroupThreatCategoryParamsSPF = "NONE" + EmailSecurityTimeseriesGroupThreatCategoryParamsSPFFail EmailSecurityTimeseriesGroupThreatCategoryParamsSPF = "FAIL" +) + +type EmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersion string + +const ( + EmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersionTlSv1_0 EmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersion = "TLSv1_0" + EmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersionTlSv1_1 EmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersion = "TLSv1_1" + EmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersionTlSv1_2 EmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersion = "TLSv1_2" + EmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersionTlSv1_3 EmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersion = "TLSv1_3" +) + +type EmailSecurityTimeseriesGroupThreatCategoryResponseEnvelope struct { + Result EmailSecurityTimeseriesGroupThreatCategoryResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecurityTimeseriesGroupThreatCategoryResponseEnvelopeJSON `json:"-"` +} + +// emailSecurityTimeseriesGroupThreatCategoryResponseEnvelopeJSON contains the JSON +// metadata for the struct +// [EmailSecurityTimeseriesGroupThreatCategoryResponseEnvelope] +type emailSecurityTimeseriesGroupThreatCategoryResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupThreatCategoryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupThreatCategoryResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTimeseriesGroupTLSVersionParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[EmailSecurityTimeseriesGroupTLSVersionParamsAggInterval] `query:"aggInterval"` + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecurityTimeseriesGroupTLSVersionParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecurityTimeseriesGroupTLSVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecurityTimeseriesGroupTLSVersionParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecurityTimeseriesGroupTLSVersionParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecurityTimeseriesGroupTLSVersionParamsFormat] `query:"format"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecurityTimeseriesGroupTLSVersionParamsSPF] `query:"spf"` +} + +// URLQuery serializes [EmailSecurityTimeseriesGroupTLSVersionParams]'s query +// parameters as `url.Values`. +func (r EmailSecurityTimeseriesGroupTLSVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type EmailSecurityTimeseriesGroupTLSVersionParamsAggInterval string + +const ( + EmailSecurityTimeseriesGroupTLSVersionParamsAggInterval15m EmailSecurityTimeseriesGroupTLSVersionParamsAggInterval = "15m" + EmailSecurityTimeseriesGroupTLSVersionParamsAggInterval1h EmailSecurityTimeseriesGroupTLSVersionParamsAggInterval = "1h" + EmailSecurityTimeseriesGroupTLSVersionParamsAggInterval1d EmailSecurityTimeseriesGroupTLSVersionParamsAggInterval = "1d" + EmailSecurityTimeseriesGroupTLSVersionParamsAggInterval1w EmailSecurityTimeseriesGroupTLSVersionParamsAggInterval = "1w" +) + +type EmailSecurityTimeseriesGroupTLSVersionParamsARC string + +const ( + EmailSecurityTimeseriesGroupTLSVersionParamsARCPass EmailSecurityTimeseriesGroupTLSVersionParamsARC = "PASS" + EmailSecurityTimeseriesGroupTLSVersionParamsARCNone EmailSecurityTimeseriesGroupTLSVersionParamsARC = "NONE" + EmailSecurityTimeseriesGroupTLSVersionParamsARCFail EmailSecurityTimeseriesGroupTLSVersionParamsARC = "FAIL" +) + +type EmailSecurityTimeseriesGroupTLSVersionParamsDateRange string + +const ( + EmailSecurityTimeseriesGroupTLSVersionParamsDateRange1d EmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "1d" + EmailSecurityTimeseriesGroupTLSVersionParamsDateRange2d EmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "2d" + EmailSecurityTimeseriesGroupTLSVersionParamsDateRange7d EmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "7d" + EmailSecurityTimeseriesGroupTLSVersionParamsDateRange14d EmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "14d" + EmailSecurityTimeseriesGroupTLSVersionParamsDateRange28d EmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "28d" + EmailSecurityTimeseriesGroupTLSVersionParamsDateRange12w EmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "12w" + EmailSecurityTimeseriesGroupTLSVersionParamsDateRange24w EmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "24w" + EmailSecurityTimeseriesGroupTLSVersionParamsDateRange52w EmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "52w" + EmailSecurityTimeseriesGroupTLSVersionParamsDateRange1dControl EmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "1dControl" + EmailSecurityTimeseriesGroupTLSVersionParamsDateRange2dControl EmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "2dControl" + EmailSecurityTimeseriesGroupTLSVersionParamsDateRange7dControl EmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "7dControl" + EmailSecurityTimeseriesGroupTLSVersionParamsDateRange14dControl EmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "14dControl" + EmailSecurityTimeseriesGroupTLSVersionParamsDateRange28dControl EmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "28dControl" + EmailSecurityTimeseriesGroupTLSVersionParamsDateRange12wControl EmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "12wControl" + EmailSecurityTimeseriesGroupTLSVersionParamsDateRange24wControl EmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "24wControl" +) + +type EmailSecurityTimeseriesGroupTLSVersionParamsDKIM string + +const ( + EmailSecurityTimeseriesGroupTLSVersionParamsDKIMPass EmailSecurityTimeseriesGroupTLSVersionParamsDKIM = "PASS" + EmailSecurityTimeseriesGroupTLSVersionParamsDKIMNone EmailSecurityTimeseriesGroupTLSVersionParamsDKIM = "NONE" + EmailSecurityTimeseriesGroupTLSVersionParamsDKIMFail EmailSecurityTimeseriesGroupTLSVersionParamsDKIM = "FAIL" +) + +type EmailSecurityTimeseriesGroupTLSVersionParamsDMARC string + +const ( + EmailSecurityTimeseriesGroupTLSVersionParamsDMARCPass EmailSecurityTimeseriesGroupTLSVersionParamsDMARC = "PASS" + EmailSecurityTimeseriesGroupTLSVersionParamsDMARCNone EmailSecurityTimeseriesGroupTLSVersionParamsDMARC = "NONE" + EmailSecurityTimeseriesGroupTLSVersionParamsDMARCFail EmailSecurityTimeseriesGroupTLSVersionParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecurityTimeseriesGroupTLSVersionParamsFormat string + +const ( + EmailSecurityTimeseriesGroupTLSVersionParamsFormatJson EmailSecurityTimeseriesGroupTLSVersionParamsFormat = "JSON" + EmailSecurityTimeseriesGroupTLSVersionParamsFormatCsv EmailSecurityTimeseriesGroupTLSVersionParamsFormat = "CSV" +) + +type EmailSecurityTimeseriesGroupTLSVersionParamsSPF string + +const ( + EmailSecurityTimeseriesGroupTLSVersionParamsSPFPass EmailSecurityTimeseriesGroupTLSVersionParamsSPF = "PASS" + EmailSecurityTimeseriesGroupTLSVersionParamsSPFNone EmailSecurityTimeseriesGroupTLSVersionParamsSPF = "NONE" + EmailSecurityTimeseriesGroupTLSVersionParamsSPFFail EmailSecurityTimeseriesGroupTLSVersionParamsSPF = "FAIL" +) + +type EmailSecurityTimeseriesGroupTLSVersionResponseEnvelope struct { + Result EmailSecurityTimeseriesGroupTLSVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecurityTimeseriesGroupTLSVersionResponseEnvelopeJSON `json:"-"` +} + +// emailSecurityTimeseriesGroupTLSVersionResponseEnvelopeJSON contains the JSON +// metadata for the struct [EmailSecurityTimeseriesGroupTLSVersionResponseEnvelope] +type emailSecurityTimeseriesGroupTLSVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTimeseriesGroupTLSVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTimeseriesGroupTLSVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/emailsecuritytimeseriesgroup_test.go b/radar/emailsecuritytimeseriesgroup_test.go new file mode 100644 index 00000000000..f51a38a25e1 --- /dev/null +++ b/radar/emailsecuritytimeseriesgroup_test.go @@ -0,0 +1,335 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestEmailSecurityTimeseriesGroupARCWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.TimeseriesGroups.ARC(context.TODO(), radar.EmailSecurityTimeseriesGroupARCParams{ + AggInterval: cloudflare.F(radar.EmailSecurityTimeseriesGroupARCParamsAggInterval1h), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecurityTimeseriesGroupARCParamsDateRange{radar.EmailSecurityTimeseriesGroupARCParamsDateRange1d, radar.EmailSecurityTimeseriesGroupARCParamsDateRange2d, radar.EmailSecurityTimeseriesGroupARCParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecurityTimeseriesGroupARCParamsDKIM{radar.EmailSecurityTimeseriesGroupARCParamsDKIMPass, radar.EmailSecurityTimeseriesGroupARCParamsDKIMNone, radar.EmailSecurityTimeseriesGroupARCParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailSecurityTimeseriesGroupARCParamsDMARC{radar.EmailSecurityTimeseriesGroupARCParamsDMARCPass, radar.EmailSecurityTimeseriesGroupARCParamsDMARCNone, radar.EmailSecurityTimeseriesGroupARCParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecurityTimeseriesGroupARCParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecurityTimeseriesGroupARCParamsSPF{radar.EmailSecurityTimeseriesGroupARCParamsSPFPass, radar.EmailSecurityTimeseriesGroupARCParamsSPFNone, radar.EmailSecurityTimeseriesGroupARCParamsSPFFail}), + TLSVersion: cloudflare.F([]radar.EmailSecurityTimeseriesGroupARCParamsTLSVersion{radar.EmailSecurityTimeseriesGroupARCParamsTLSVersionTlSv1_0, radar.EmailSecurityTimeseriesGroupARCParamsTLSVersionTlSv1_1, radar.EmailSecurityTimeseriesGroupARCParamsTLSVersionTlSv1_2}), + }) + 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 TestEmailSecurityTimeseriesGroupDKIMWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.TimeseriesGroups.DKIM(context.TODO(), radar.EmailSecurityTimeseriesGroupDKIMParams{ + AggInterval: cloudflare.F(radar.EmailSecurityTimeseriesGroupDKIMParamsAggInterval1h), + ARC: cloudflare.F([]radar.EmailSecurityTimeseriesGroupDKIMParamsARC{radar.EmailSecurityTimeseriesGroupDKIMParamsARCPass, radar.EmailSecurityTimeseriesGroupDKIMParamsARCNone, radar.EmailSecurityTimeseriesGroupDKIMParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecurityTimeseriesGroupDKIMParamsDateRange{radar.EmailSecurityTimeseriesGroupDKIMParamsDateRange1d, radar.EmailSecurityTimeseriesGroupDKIMParamsDateRange2d, radar.EmailSecurityTimeseriesGroupDKIMParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DMARC: cloudflare.F([]radar.EmailSecurityTimeseriesGroupDKIMParamsDMARC{radar.EmailSecurityTimeseriesGroupDKIMParamsDMARCPass, radar.EmailSecurityTimeseriesGroupDKIMParamsDMARCNone, radar.EmailSecurityTimeseriesGroupDKIMParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecurityTimeseriesGroupDKIMParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecurityTimeseriesGroupDKIMParamsSPF{radar.EmailSecurityTimeseriesGroupDKIMParamsSPFPass, radar.EmailSecurityTimeseriesGroupDKIMParamsSPFNone, radar.EmailSecurityTimeseriesGroupDKIMParamsSPFFail}), + TLSVersion: cloudflare.F([]radar.EmailSecurityTimeseriesGroupDKIMParamsTLSVersion{radar.EmailSecurityTimeseriesGroupDKIMParamsTLSVersionTlSv1_0, radar.EmailSecurityTimeseriesGroupDKIMParamsTLSVersionTlSv1_1, radar.EmailSecurityTimeseriesGroupDKIMParamsTLSVersionTlSv1_2}), + }) + 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 TestEmailSecurityTimeseriesGroupDMARCWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.TimeseriesGroups.DMARC(context.TODO(), radar.EmailSecurityTimeseriesGroupDMARCParams{ + AggInterval: cloudflare.F(radar.EmailSecurityTimeseriesGroupDMARCParamsAggInterval1h), + ARC: cloudflare.F([]radar.EmailSecurityTimeseriesGroupDMARCParamsARC{radar.EmailSecurityTimeseriesGroupDMARCParamsARCPass, radar.EmailSecurityTimeseriesGroupDMARCParamsARCNone, radar.EmailSecurityTimeseriesGroupDMARCParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecurityTimeseriesGroupDMARCParamsDateRange{radar.EmailSecurityTimeseriesGroupDMARCParamsDateRange1d, radar.EmailSecurityTimeseriesGroupDMARCParamsDateRange2d, radar.EmailSecurityTimeseriesGroupDMARCParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecurityTimeseriesGroupDMARCParamsDKIM{radar.EmailSecurityTimeseriesGroupDMARCParamsDKIMPass, radar.EmailSecurityTimeseriesGroupDMARCParamsDKIMNone, radar.EmailSecurityTimeseriesGroupDMARCParamsDKIMFail}), + Format: cloudflare.F(radar.EmailSecurityTimeseriesGroupDMARCParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecurityTimeseriesGroupDMARCParamsSPF{radar.EmailSecurityTimeseriesGroupDMARCParamsSPFPass, radar.EmailSecurityTimeseriesGroupDMARCParamsSPFNone, radar.EmailSecurityTimeseriesGroupDMARCParamsSPFFail}), + TLSVersion: cloudflare.F([]radar.EmailSecurityTimeseriesGroupDMARCParamsTLSVersion{radar.EmailSecurityTimeseriesGroupDMARCParamsTLSVersionTlSv1_0, radar.EmailSecurityTimeseriesGroupDMARCParamsTLSVersionTlSv1_1, radar.EmailSecurityTimeseriesGroupDMARCParamsTLSVersionTlSv1_2}), + }) + 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 TestEmailSecurityTimeseriesGroupMaliciousWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.TimeseriesGroups.Malicious(context.TODO(), radar.EmailSecurityTimeseriesGroupMaliciousParams{ + AggInterval: cloudflare.F(radar.EmailSecurityTimeseriesGroupMaliciousParamsAggInterval1h), + ARC: cloudflare.F([]radar.EmailSecurityTimeseriesGroupMaliciousParamsARC{radar.EmailSecurityTimeseriesGroupMaliciousParamsARCPass, radar.EmailSecurityTimeseriesGroupMaliciousParamsARCNone, radar.EmailSecurityTimeseriesGroupMaliciousParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecurityTimeseriesGroupMaliciousParamsDateRange{radar.EmailSecurityTimeseriesGroupMaliciousParamsDateRange1d, radar.EmailSecurityTimeseriesGroupMaliciousParamsDateRange2d, radar.EmailSecurityTimeseriesGroupMaliciousParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecurityTimeseriesGroupMaliciousParamsDKIM{radar.EmailSecurityTimeseriesGroupMaliciousParamsDKIMPass, radar.EmailSecurityTimeseriesGroupMaliciousParamsDKIMNone, radar.EmailSecurityTimeseriesGroupMaliciousParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailSecurityTimeseriesGroupMaliciousParamsDMARC{radar.EmailSecurityTimeseriesGroupMaliciousParamsDMARCPass, radar.EmailSecurityTimeseriesGroupMaliciousParamsDMARCNone, radar.EmailSecurityTimeseriesGroupMaliciousParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecurityTimeseriesGroupMaliciousParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecurityTimeseriesGroupMaliciousParamsSPF{radar.EmailSecurityTimeseriesGroupMaliciousParamsSPFPass, radar.EmailSecurityTimeseriesGroupMaliciousParamsSPFNone, radar.EmailSecurityTimeseriesGroupMaliciousParamsSPFFail}), + TLSVersion: cloudflare.F([]radar.EmailSecurityTimeseriesGroupMaliciousParamsTLSVersion{radar.EmailSecurityTimeseriesGroupMaliciousParamsTLSVersionTlSv1_0, radar.EmailSecurityTimeseriesGroupMaliciousParamsTLSVersionTlSv1_1, radar.EmailSecurityTimeseriesGroupMaliciousParamsTLSVersionTlSv1_2}), + }) + 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 TestEmailSecurityTimeseriesGroupSpamWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.TimeseriesGroups.Spam(context.TODO(), radar.EmailSecurityTimeseriesGroupSpamParams{ + AggInterval: cloudflare.F(radar.EmailSecurityTimeseriesGroupSpamParamsAggInterval1h), + ARC: cloudflare.F([]radar.EmailSecurityTimeseriesGroupSpamParamsARC{radar.EmailSecurityTimeseriesGroupSpamParamsARCPass, radar.EmailSecurityTimeseriesGroupSpamParamsARCNone, radar.EmailSecurityTimeseriesGroupSpamParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecurityTimeseriesGroupSpamParamsDateRange{radar.EmailSecurityTimeseriesGroupSpamParamsDateRange1d, radar.EmailSecurityTimeseriesGroupSpamParamsDateRange2d, radar.EmailSecurityTimeseriesGroupSpamParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecurityTimeseriesGroupSpamParamsDKIM{radar.EmailSecurityTimeseriesGroupSpamParamsDKIMPass, radar.EmailSecurityTimeseriesGroupSpamParamsDKIMNone, radar.EmailSecurityTimeseriesGroupSpamParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailSecurityTimeseriesGroupSpamParamsDMARC{radar.EmailSecurityTimeseriesGroupSpamParamsDMARCPass, radar.EmailSecurityTimeseriesGroupSpamParamsDMARCNone, radar.EmailSecurityTimeseriesGroupSpamParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecurityTimeseriesGroupSpamParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecurityTimeseriesGroupSpamParamsSPF{radar.EmailSecurityTimeseriesGroupSpamParamsSPFPass, radar.EmailSecurityTimeseriesGroupSpamParamsSPFNone, radar.EmailSecurityTimeseriesGroupSpamParamsSPFFail}), + TLSVersion: cloudflare.F([]radar.EmailSecurityTimeseriesGroupSpamParamsTLSVersion{radar.EmailSecurityTimeseriesGroupSpamParamsTLSVersionTlSv1_0, radar.EmailSecurityTimeseriesGroupSpamParamsTLSVersionTlSv1_1, radar.EmailSecurityTimeseriesGroupSpamParamsTLSVersionTlSv1_2}), + }) + 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 TestEmailSecurityTimeseriesGroupSPFWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.TimeseriesGroups.SPF(context.TODO(), radar.EmailSecurityTimeseriesGroupSPFParams{ + AggInterval: cloudflare.F(radar.EmailSecurityTimeseriesGroupSPFParamsAggInterval1h), + ARC: cloudflare.F([]radar.EmailSecurityTimeseriesGroupSPFParamsARC{radar.EmailSecurityTimeseriesGroupSPFParamsARCPass, radar.EmailSecurityTimeseriesGroupSPFParamsARCNone, radar.EmailSecurityTimeseriesGroupSPFParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecurityTimeseriesGroupSPFParamsDateRange{radar.EmailSecurityTimeseriesGroupSPFParamsDateRange1d, radar.EmailSecurityTimeseriesGroupSPFParamsDateRange2d, radar.EmailSecurityTimeseriesGroupSPFParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecurityTimeseriesGroupSPFParamsDKIM{radar.EmailSecurityTimeseriesGroupSPFParamsDKIMPass, radar.EmailSecurityTimeseriesGroupSPFParamsDKIMNone, radar.EmailSecurityTimeseriesGroupSPFParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailSecurityTimeseriesGroupSPFParamsDMARC{radar.EmailSecurityTimeseriesGroupSPFParamsDMARCPass, radar.EmailSecurityTimeseriesGroupSPFParamsDMARCNone, radar.EmailSecurityTimeseriesGroupSPFParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecurityTimeseriesGroupSPFParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + TLSVersion: cloudflare.F([]radar.EmailSecurityTimeseriesGroupSPFParamsTLSVersion{radar.EmailSecurityTimeseriesGroupSPFParamsTLSVersionTlSv1_0, radar.EmailSecurityTimeseriesGroupSPFParamsTLSVersionTlSv1_1, radar.EmailSecurityTimeseriesGroupSPFParamsTLSVersionTlSv1_2}), + }) + 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 TestEmailSecurityTimeseriesGroupSpoofWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.TimeseriesGroups.Spoof(context.TODO(), radar.EmailSecurityTimeseriesGroupSpoofParams{ + AggInterval: cloudflare.F(radar.EmailSecurityTimeseriesGroupSpoofParamsAggInterval1h), + ARC: cloudflare.F([]radar.EmailSecurityTimeseriesGroupSpoofParamsARC{radar.EmailSecurityTimeseriesGroupSpoofParamsARCPass, radar.EmailSecurityTimeseriesGroupSpoofParamsARCNone, radar.EmailSecurityTimeseriesGroupSpoofParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecurityTimeseriesGroupSpoofParamsDateRange{radar.EmailSecurityTimeseriesGroupSpoofParamsDateRange1d, radar.EmailSecurityTimeseriesGroupSpoofParamsDateRange2d, radar.EmailSecurityTimeseriesGroupSpoofParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecurityTimeseriesGroupSpoofParamsDKIM{radar.EmailSecurityTimeseriesGroupSpoofParamsDKIMPass, radar.EmailSecurityTimeseriesGroupSpoofParamsDKIMNone, radar.EmailSecurityTimeseriesGroupSpoofParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailSecurityTimeseriesGroupSpoofParamsDMARC{radar.EmailSecurityTimeseriesGroupSpoofParamsDMARCPass, radar.EmailSecurityTimeseriesGroupSpoofParamsDMARCNone, radar.EmailSecurityTimeseriesGroupSpoofParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecurityTimeseriesGroupSpoofParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecurityTimeseriesGroupSpoofParamsSPF{radar.EmailSecurityTimeseriesGroupSpoofParamsSPFPass, radar.EmailSecurityTimeseriesGroupSpoofParamsSPFNone, radar.EmailSecurityTimeseriesGroupSpoofParamsSPFFail}), + TLSVersion: cloudflare.F([]radar.EmailSecurityTimeseriesGroupSpoofParamsTLSVersion{radar.EmailSecurityTimeseriesGroupSpoofParamsTLSVersionTlSv1_0, radar.EmailSecurityTimeseriesGroupSpoofParamsTLSVersionTlSv1_1, radar.EmailSecurityTimeseriesGroupSpoofParamsTLSVersionTlSv1_2}), + }) + 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 TestEmailSecurityTimeseriesGroupThreatCategoryWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.TimeseriesGroups.ThreatCategory(context.TODO(), radar.EmailSecurityTimeseriesGroupThreatCategoryParams{ + AggInterval: cloudflare.F(radar.EmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval1h), + ARC: cloudflare.F([]radar.EmailSecurityTimeseriesGroupThreatCategoryParamsARC{radar.EmailSecurityTimeseriesGroupThreatCategoryParamsARCPass, radar.EmailSecurityTimeseriesGroupThreatCategoryParamsARCNone, radar.EmailSecurityTimeseriesGroupThreatCategoryParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange{radar.EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange1d, radar.EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange2d, radar.EmailSecurityTimeseriesGroupThreatCategoryParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecurityTimeseriesGroupThreatCategoryParamsDKIM{radar.EmailSecurityTimeseriesGroupThreatCategoryParamsDKIMPass, radar.EmailSecurityTimeseriesGroupThreatCategoryParamsDKIMNone, radar.EmailSecurityTimeseriesGroupThreatCategoryParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailSecurityTimeseriesGroupThreatCategoryParamsDMARC{radar.EmailSecurityTimeseriesGroupThreatCategoryParamsDMARCPass, radar.EmailSecurityTimeseriesGroupThreatCategoryParamsDMARCNone, radar.EmailSecurityTimeseriesGroupThreatCategoryParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecurityTimeseriesGroupThreatCategoryParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecurityTimeseriesGroupThreatCategoryParamsSPF{radar.EmailSecurityTimeseriesGroupThreatCategoryParamsSPFPass, radar.EmailSecurityTimeseriesGroupThreatCategoryParamsSPFNone, radar.EmailSecurityTimeseriesGroupThreatCategoryParamsSPFFail}), + TLSVersion: cloudflare.F([]radar.EmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersion{radar.EmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersionTlSv1_0, radar.EmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersionTlSv1_1, radar.EmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersionTlSv1_2}), + }) + 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 TestEmailSecurityTimeseriesGroupTLSVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.TimeseriesGroups.TLSVersion(context.TODO(), radar.EmailSecurityTimeseriesGroupTLSVersionParams{ + AggInterval: cloudflare.F(radar.EmailSecurityTimeseriesGroupTLSVersionParamsAggInterval1h), + ARC: cloudflare.F([]radar.EmailSecurityTimeseriesGroupTLSVersionParamsARC{radar.EmailSecurityTimeseriesGroupTLSVersionParamsARCPass, radar.EmailSecurityTimeseriesGroupTLSVersionParamsARCNone, radar.EmailSecurityTimeseriesGroupTLSVersionParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecurityTimeseriesGroupTLSVersionParamsDateRange{radar.EmailSecurityTimeseriesGroupTLSVersionParamsDateRange1d, radar.EmailSecurityTimeseriesGroupTLSVersionParamsDateRange2d, radar.EmailSecurityTimeseriesGroupTLSVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecurityTimeseriesGroupTLSVersionParamsDKIM{radar.EmailSecurityTimeseriesGroupTLSVersionParamsDKIMPass, radar.EmailSecurityTimeseriesGroupTLSVersionParamsDKIMNone, radar.EmailSecurityTimeseriesGroupTLSVersionParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailSecurityTimeseriesGroupTLSVersionParamsDMARC{radar.EmailSecurityTimeseriesGroupTLSVersionParamsDMARCPass, radar.EmailSecurityTimeseriesGroupTLSVersionParamsDMARCNone, radar.EmailSecurityTimeseriesGroupTLSVersionParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecurityTimeseriesGroupTLSVersionParamsFormatJson), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecurityTimeseriesGroupTLSVersionParamsSPF{radar.EmailSecurityTimeseriesGroupTLSVersionParamsSPFPass, radar.EmailSecurityTimeseriesGroupTLSVersionParamsSPFNone, radar.EmailSecurityTimeseriesGroupTLSVersionParamsSPFFail}), + }) + 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/radar/emailsecuritytop.go b/radar/emailsecuritytop.go new file mode 100644 index 00000000000..6c23b0e6c52 --- /dev/null +++ b/radar/emailsecuritytop.go @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// EmailSecurityTopService 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 [NewEmailSecurityTopService] method +// instead. +type EmailSecurityTopService struct { + Options []option.RequestOption + Tlds *EmailSecurityTopTldService +} + +// NewEmailSecurityTopService 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 NewEmailSecurityTopService(opts ...option.RequestOption) (r *EmailSecurityTopService) { + r = &EmailSecurityTopService{} + r.Options = opts + r.Tlds = NewEmailSecurityTopTldService(opts...) + return +} diff --git a/radar/emailsecuritytoptld.go b/radar/emailsecuritytoptld.go new file mode 100644 index 00000000000..d4ef96eb7d5 --- /dev/null +++ b/radar/emailsecuritytoptld.go @@ -0,0 +1,345 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// EmailSecurityTopTldService 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 [NewEmailSecurityTopTldService] +// method instead. +type EmailSecurityTopTldService struct { + Options []option.RequestOption + Malicious *EmailSecurityTopTldMaliciousService + Spam *EmailSecurityTopTldSpamService + Spoof *EmailSecurityTopTldSpoofService +} + +// NewEmailSecurityTopTldService 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 NewEmailSecurityTopTldService(opts ...option.RequestOption) (r *EmailSecurityTopTldService) { + r = &EmailSecurityTopTldService{} + r.Options = opts + r.Malicious = NewEmailSecurityTopTldMaliciousService(opts...) + r.Spam = NewEmailSecurityTopTldSpamService(opts...) + r.Spoof = NewEmailSecurityTopTldSpoofService(opts...) + return +} + +// Get the top TLDs by email messages. Values are a percentage out of the total +// emails. +func (r *EmailSecurityTopTldService) Get(ctx context.Context, query EmailSecurityTopTldGetParams, opts ...option.RequestOption) (res *EmailSecurityTopTldGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecurityTopTldGetResponseEnvelope + path := "radar/email/security/top/tlds" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type EmailSecurityTopTldGetResponse struct { + Meta EmailSecurityTopTldGetResponseMeta `json:"meta,required"` + Top0 []EmailSecurityTopTldGetResponseTop0 `json:"top_0,required"` + JSON emailSecurityTopTldGetResponseJSON `json:"-"` +} + +// emailSecurityTopTldGetResponseJSON contains the JSON metadata for the struct +// [EmailSecurityTopTldGetResponse] +type emailSecurityTopTldGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldGetResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldGetResponseMeta struct { + DateRange []EmailSecurityTopTldGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo EmailSecurityTopTldGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailSecurityTopTldGetResponseMetaJSON `json:"-"` +} + +// emailSecurityTopTldGetResponseMetaJSON contains the JSON metadata for the struct +// [EmailSecurityTopTldGetResponseMeta] +type emailSecurityTopTldGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailSecurityTopTldGetResponseMetaDateRangeJSON `json:"-"` +} + +// emailSecurityTopTldGetResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [EmailSecurityTopTldGetResponseMetaDateRange] +type emailSecurityTopTldGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldGetResponseMetaConfidenceInfo struct { + Annotations []EmailSecurityTopTldGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailSecurityTopTldGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailSecurityTopTldGetResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [EmailSecurityTopTldGetResponseMetaConfidenceInfo] +type emailSecurityTopTldGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailSecurityTopTldGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailSecurityTopTldGetResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [EmailSecurityTopTldGetResponseMetaConfidenceInfoAnnotation] +type emailSecurityTopTldGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldGetResponseTop0 struct { + Name string `json:"name,required"` + Value string `json:"value,required"` + JSON emailSecurityTopTldGetResponseTop0JSON `json:"-"` +} + +// emailSecurityTopTldGetResponseTop0JSON contains the JSON metadata for the struct +// [EmailSecurityTopTldGetResponseTop0] +type emailSecurityTopTldGetResponseTop0JSON struct { + Name apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldGetParams struct { + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecurityTopTldGetParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecurityTopTldGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecurityTopTldGetParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecurityTopTldGetParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecurityTopTldGetParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecurityTopTldGetParamsSPF] `query:"spf"` + // Filter for TLDs by category. + TldCategory param.Field[EmailSecurityTopTldGetParamsTldCategory] `query:"tldCategory"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecurityTopTldGetParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecurityTopTldGetParams]'s query parameters as +// `url.Values`. +func (r EmailSecurityTopTldGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type EmailSecurityTopTldGetParamsARC string + +const ( + EmailSecurityTopTldGetParamsARCPass EmailSecurityTopTldGetParamsARC = "PASS" + EmailSecurityTopTldGetParamsARCNone EmailSecurityTopTldGetParamsARC = "NONE" + EmailSecurityTopTldGetParamsARCFail EmailSecurityTopTldGetParamsARC = "FAIL" +) + +type EmailSecurityTopTldGetParamsDateRange string + +const ( + EmailSecurityTopTldGetParamsDateRange1d EmailSecurityTopTldGetParamsDateRange = "1d" + EmailSecurityTopTldGetParamsDateRange2d EmailSecurityTopTldGetParamsDateRange = "2d" + EmailSecurityTopTldGetParamsDateRange7d EmailSecurityTopTldGetParamsDateRange = "7d" + EmailSecurityTopTldGetParamsDateRange14d EmailSecurityTopTldGetParamsDateRange = "14d" + EmailSecurityTopTldGetParamsDateRange28d EmailSecurityTopTldGetParamsDateRange = "28d" + EmailSecurityTopTldGetParamsDateRange12w EmailSecurityTopTldGetParamsDateRange = "12w" + EmailSecurityTopTldGetParamsDateRange24w EmailSecurityTopTldGetParamsDateRange = "24w" + EmailSecurityTopTldGetParamsDateRange52w EmailSecurityTopTldGetParamsDateRange = "52w" + EmailSecurityTopTldGetParamsDateRange1dControl EmailSecurityTopTldGetParamsDateRange = "1dControl" + EmailSecurityTopTldGetParamsDateRange2dControl EmailSecurityTopTldGetParamsDateRange = "2dControl" + EmailSecurityTopTldGetParamsDateRange7dControl EmailSecurityTopTldGetParamsDateRange = "7dControl" + EmailSecurityTopTldGetParamsDateRange14dControl EmailSecurityTopTldGetParamsDateRange = "14dControl" + EmailSecurityTopTldGetParamsDateRange28dControl EmailSecurityTopTldGetParamsDateRange = "28dControl" + EmailSecurityTopTldGetParamsDateRange12wControl EmailSecurityTopTldGetParamsDateRange = "12wControl" + EmailSecurityTopTldGetParamsDateRange24wControl EmailSecurityTopTldGetParamsDateRange = "24wControl" +) + +type EmailSecurityTopTldGetParamsDKIM string + +const ( + EmailSecurityTopTldGetParamsDKIMPass EmailSecurityTopTldGetParamsDKIM = "PASS" + EmailSecurityTopTldGetParamsDKIMNone EmailSecurityTopTldGetParamsDKIM = "NONE" + EmailSecurityTopTldGetParamsDKIMFail EmailSecurityTopTldGetParamsDKIM = "FAIL" +) + +type EmailSecurityTopTldGetParamsDMARC string + +const ( + EmailSecurityTopTldGetParamsDMARCPass EmailSecurityTopTldGetParamsDMARC = "PASS" + EmailSecurityTopTldGetParamsDMARCNone EmailSecurityTopTldGetParamsDMARC = "NONE" + EmailSecurityTopTldGetParamsDMARCFail EmailSecurityTopTldGetParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecurityTopTldGetParamsFormat string + +const ( + EmailSecurityTopTldGetParamsFormatJson EmailSecurityTopTldGetParamsFormat = "JSON" + EmailSecurityTopTldGetParamsFormatCsv EmailSecurityTopTldGetParamsFormat = "CSV" +) + +type EmailSecurityTopTldGetParamsSPF string + +const ( + EmailSecurityTopTldGetParamsSPFPass EmailSecurityTopTldGetParamsSPF = "PASS" + EmailSecurityTopTldGetParamsSPFNone EmailSecurityTopTldGetParamsSPF = "NONE" + EmailSecurityTopTldGetParamsSPFFail EmailSecurityTopTldGetParamsSPF = "FAIL" +) + +// Filter for TLDs by category. +type EmailSecurityTopTldGetParamsTldCategory string + +const ( + EmailSecurityTopTldGetParamsTldCategoryClassic EmailSecurityTopTldGetParamsTldCategory = "CLASSIC" + EmailSecurityTopTldGetParamsTldCategoryCountry EmailSecurityTopTldGetParamsTldCategory = "COUNTRY" +) + +type EmailSecurityTopTldGetParamsTLSVersion string + +const ( + EmailSecurityTopTldGetParamsTLSVersionTlSv1_0 EmailSecurityTopTldGetParamsTLSVersion = "TLSv1_0" + EmailSecurityTopTldGetParamsTLSVersionTlSv1_1 EmailSecurityTopTldGetParamsTLSVersion = "TLSv1_1" + EmailSecurityTopTldGetParamsTLSVersionTlSv1_2 EmailSecurityTopTldGetParamsTLSVersion = "TLSv1_2" + EmailSecurityTopTldGetParamsTLSVersionTlSv1_3 EmailSecurityTopTldGetParamsTLSVersion = "TLSv1_3" +) + +type EmailSecurityTopTldGetResponseEnvelope struct { + Result EmailSecurityTopTldGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecurityTopTldGetResponseEnvelopeJSON `json:"-"` +} + +// emailSecurityTopTldGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [EmailSecurityTopTldGetResponseEnvelope] +type emailSecurityTopTldGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/emailsecuritytoptld_test.go b/radar/emailsecuritytoptld_test.go new file mode 100644 index 00000000000..07539d5ab53 --- /dev/null +++ b/radar/emailsecuritytoptld_test.go @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestEmailSecurityTopTldGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.Top.Tlds.Get(context.TODO(), radar.EmailSecurityTopTldGetParams{ + ARC: cloudflare.F([]radar.EmailSecurityTopTldGetParamsARC{radar.EmailSecurityTopTldGetParamsARCPass, radar.EmailSecurityTopTldGetParamsARCNone, radar.EmailSecurityTopTldGetParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecurityTopTldGetParamsDateRange{radar.EmailSecurityTopTldGetParamsDateRange1d, radar.EmailSecurityTopTldGetParamsDateRange2d, radar.EmailSecurityTopTldGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecurityTopTldGetParamsDKIM{radar.EmailSecurityTopTldGetParamsDKIMPass, radar.EmailSecurityTopTldGetParamsDKIMNone, radar.EmailSecurityTopTldGetParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailSecurityTopTldGetParamsDMARC{radar.EmailSecurityTopTldGetParamsDMARCPass, radar.EmailSecurityTopTldGetParamsDMARCNone, radar.EmailSecurityTopTldGetParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecurityTopTldGetParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecurityTopTldGetParamsSPF{radar.EmailSecurityTopTldGetParamsSPFPass, radar.EmailSecurityTopTldGetParamsSPFNone, radar.EmailSecurityTopTldGetParamsSPFFail}), + TldCategory: cloudflare.F(radar.EmailSecurityTopTldGetParamsTldCategoryClassic), + TLSVersion: cloudflare.F([]radar.EmailSecurityTopTldGetParamsTLSVersion{radar.EmailSecurityTopTldGetParamsTLSVersionTlSv1_0, radar.EmailSecurityTopTldGetParamsTLSVersionTlSv1_1, radar.EmailSecurityTopTldGetParamsTLSVersionTlSv1_2}), + }) + 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/radar/emailsecuritytoptldmalicious.go b/radar/emailsecuritytoptldmalicious.go new file mode 100644 index 00000000000..ce71823bba7 --- /dev/null +++ b/radar/emailsecuritytoptldmalicious.go @@ -0,0 +1,348 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// EmailSecurityTopTldMaliciousService 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 +// [NewEmailSecurityTopTldMaliciousService] method instead. +type EmailSecurityTopTldMaliciousService struct { + Options []option.RequestOption +} + +// NewEmailSecurityTopTldMaliciousService 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 NewEmailSecurityTopTldMaliciousService(opts ...option.RequestOption) (r *EmailSecurityTopTldMaliciousService) { + r = &EmailSecurityTopTldMaliciousService{} + r.Options = opts + return +} + +// Get the TLDs by emails classified as malicious or not. +func (r *EmailSecurityTopTldMaliciousService) Get(ctx context.Context, malicious EmailSecurityTopTldMaliciousGetParamsMalicious, query EmailSecurityTopTldMaliciousGetParams, opts ...option.RequestOption) (res *EmailSecurityTopTldMaliciousGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecurityTopTldMaliciousGetResponseEnvelope + path := fmt.Sprintf("radar/email/security/top/tlds/malicious/%v", malicious) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type EmailSecurityTopTldMaliciousGetResponse struct { + Meta EmailSecurityTopTldMaliciousGetResponseMeta `json:"meta,required"` + Top0 []EmailSecurityTopTldMaliciousGetResponseTop0 `json:"top_0,required"` + JSON emailSecurityTopTldMaliciousGetResponseJSON `json:"-"` +} + +// emailSecurityTopTldMaliciousGetResponseJSON contains the JSON metadata for the +// struct [EmailSecurityTopTldMaliciousGetResponse] +type emailSecurityTopTldMaliciousGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldMaliciousGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldMaliciousGetResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldMaliciousGetResponseMeta struct { + DateRange []EmailSecurityTopTldMaliciousGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo EmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailSecurityTopTldMaliciousGetResponseMetaJSON `json:"-"` +} + +// emailSecurityTopTldMaliciousGetResponseMetaJSON contains the JSON metadata for +// the struct [EmailSecurityTopTldMaliciousGetResponseMeta] +type emailSecurityTopTldMaliciousGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldMaliciousGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldMaliciousGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldMaliciousGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailSecurityTopTldMaliciousGetResponseMetaDateRangeJSON `json:"-"` +} + +// emailSecurityTopTldMaliciousGetResponseMetaDateRangeJSON contains the JSON +// metadata for the struct [EmailSecurityTopTldMaliciousGetResponseMetaDateRange] +type emailSecurityTopTldMaliciousGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldMaliciousGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldMaliciousGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfo struct { + Annotations []EmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct +// [EmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfo] +type emailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoAnnotationJSON contains +// the JSON metadata for the struct +// [EmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoAnnotation] +type emailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldMaliciousGetResponseTop0 struct { + Name string `json:"name,required"` + Value string `json:"value,required"` + JSON emailSecurityTopTldMaliciousGetResponseTop0JSON `json:"-"` +} + +// emailSecurityTopTldMaliciousGetResponseTop0JSON contains the JSON metadata for +// the struct [EmailSecurityTopTldMaliciousGetResponseTop0] +type emailSecurityTopTldMaliciousGetResponseTop0JSON struct { + Name apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldMaliciousGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldMaliciousGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldMaliciousGetParams struct { + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecurityTopTldMaliciousGetParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecurityTopTldMaliciousGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecurityTopTldMaliciousGetParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecurityTopTldMaliciousGetParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecurityTopTldMaliciousGetParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecurityTopTldMaliciousGetParamsSPF] `query:"spf"` + // Filter for TLDs by category. + TldCategory param.Field[EmailSecurityTopTldMaliciousGetParamsTldCategory] `query:"tldCategory"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecurityTopTldMaliciousGetParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecurityTopTldMaliciousGetParams]'s query parameters +// as `url.Values`. +func (r EmailSecurityTopTldMaliciousGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Malicious. +type EmailSecurityTopTldMaliciousGetParamsMalicious string + +const ( + EmailSecurityTopTldMaliciousGetParamsMaliciousMalicious EmailSecurityTopTldMaliciousGetParamsMalicious = "MALICIOUS" + EmailSecurityTopTldMaliciousGetParamsMaliciousNotMalicious EmailSecurityTopTldMaliciousGetParamsMalicious = "NOT_MALICIOUS" +) + +type EmailSecurityTopTldMaliciousGetParamsARC string + +const ( + EmailSecurityTopTldMaliciousGetParamsARCPass EmailSecurityTopTldMaliciousGetParamsARC = "PASS" + EmailSecurityTopTldMaliciousGetParamsARCNone EmailSecurityTopTldMaliciousGetParamsARC = "NONE" + EmailSecurityTopTldMaliciousGetParamsARCFail EmailSecurityTopTldMaliciousGetParamsARC = "FAIL" +) + +type EmailSecurityTopTldMaliciousGetParamsDateRange string + +const ( + EmailSecurityTopTldMaliciousGetParamsDateRange1d EmailSecurityTopTldMaliciousGetParamsDateRange = "1d" + EmailSecurityTopTldMaliciousGetParamsDateRange2d EmailSecurityTopTldMaliciousGetParamsDateRange = "2d" + EmailSecurityTopTldMaliciousGetParamsDateRange7d EmailSecurityTopTldMaliciousGetParamsDateRange = "7d" + EmailSecurityTopTldMaliciousGetParamsDateRange14d EmailSecurityTopTldMaliciousGetParamsDateRange = "14d" + EmailSecurityTopTldMaliciousGetParamsDateRange28d EmailSecurityTopTldMaliciousGetParamsDateRange = "28d" + EmailSecurityTopTldMaliciousGetParamsDateRange12w EmailSecurityTopTldMaliciousGetParamsDateRange = "12w" + EmailSecurityTopTldMaliciousGetParamsDateRange24w EmailSecurityTopTldMaliciousGetParamsDateRange = "24w" + EmailSecurityTopTldMaliciousGetParamsDateRange52w EmailSecurityTopTldMaliciousGetParamsDateRange = "52w" + EmailSecurityTopTldMaliciousGetParamsDateRange1dControl EmailSecurityTopTldMaliciousGetParamsDateRange = "1dControl" + EmailSecurityTopTldMaliciousGetParamsDateRange2dControl EmailSecurityTopTldMaliciousGetParamsDateRange = "2dControl" + EmailSecurityTopTldMaliciousGetParamsDateRange7dControl EmailSecurityTopTldMaliciousGetParamsDateRange = "7dControl" + EmailSecurityTopTldMaliciousGetParamsDateRange14dControl EmailSecurityTopTldMaliciousGetParamsDateRange = "14dControl" + EmailSecurityTopTldMaliciousGetParamsDateRange28dControl EmailSecurityTopTldMaliciousGetParamsDateRange = "28dControl" + EmailSecurityTopTldMaliciousGetParamsDateRange12wControl EmailSecurityTopTldMaliciousGetParamsDateRange = "12wControl" + EmailSecurityTopTldMaliciousGetParamsDateRange24wControl EmailSecurityTopTldMaliciousGetParamsDateRange = "24wControl" +) + +type EmailSecurityTopTldMaliciousGetParamsDKIM string + +const ( + EmailSecurityTopTldMaliciousGetParamsDKIMPass EmailSecurityTopTldMaliciousGetParamsDKIM = "PASS" + EmailSecurityTopTldMaliciousGetParamsDKIMNone EmailSecurityTopTldMaliciousGetParamsDKIM = "NONE" + EmailSecurityTopTldMaliciousGetParamsDKIMFail EmailSecurityTopTldMaliciousGetParamsDKIM = "FAIL" +) + +type EmailSecurityTopTldMaliciousGetParamsDMARC string + +const ( + EmailSecurityTopTldMaliciousGetParamsDMARCPass EmailSecurityTopTldMaliciousGetParamsDMARC = "PASS" + EmailSecurityTopTldMaliciousGetParamsDMARCNone EmailSecurityTopTldMaliciousGetParamsDMARC = "NONE" + EmailSecurityTopTldMaliciousGetParamsDMARCFail EmailSecurityTopTldMaliciousGetParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecurityTopTldMaliciousGetParamsFormat string + +const ( + EmailSecurityTopTldMaliciousGetParamsFormatJson EmailSecurityTopTldMaliciousGetParamsFormat = "JSON" + EmailSecurityTopTldMaliciousGetParamsFormatCsv EmailSecurityTopTldMaliciousGetParamsFormat = "CSV" +) + +type EmailSecurityTopTldMaliciousGetParamsSPF string + +const ( + EmailSecurityTopTldMaliciousGetParamsSPFPass EmailSecurityTopTldMaliciousGetParamsSPF = "PASS" + EmailSecurityTopTldMaliciousGetParamsSPFNone EmailSecurityTopTldMaliciousGetParamsSPF = "NONE" + EmailSecurityTopTldMaliciousGetParamsSPFFail EmailSecurityTopTldMaliciousGetParamsSPF = "FAIL" +) + +// Filter for TLDs by category. +type EmailSecurityTopTldMaliciousGetParamsTldCategory string + +const ( + EmailSecurityTopTldMaliciousGetParamsTldCategoryClassic EmailSecurityTopTldMaliciousGetParamsTldCategory = "CLASSIC" + EmailSecurityTopTldMaliciousGetParamsTldCategoryCountry EmailSecurityTopTldMaliciousGetParamsTldCategory = "COUNTRY" +) + +type EmailSecurityTopTldMaliciousGetParamsTLSVersion string + +const ( + EmailSecurityTopTldMaliciousGetParamsTLSVersionTlSv1_0 EmailSecurityTopTldMaliciousGetParamsTLSVersion = "TLSv1_0" + EmailSecurityTopTldMaliciousGetParamsTLSVersionTlSv1_1 EmailSecurityTopTldMaliciousGetParamsTLSVersion = "TLSv1_1" + EmailSecurityTopTldMaliciousGetParamsTLSVersionTlSv1_2 EmailSecurityTopTldMaliciousGetParamsTLSVersion = "TLSv1_2" + EmailSecurityTopTldMaliciousGetParamsTLSVersionTlSv1_3 EmailSecurityTopTldMaliciousGetParamsTLSVersion = "TLSv1_3" +) + +type EmailSecurityTopTldMaliciousGetResponseEnvelope struct { + Result EmailSecurityTopTldMaliciousGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecurityTopTldMaliciousGetResponseEnvelopeJSON `json:"-"` +} + +// emailSecurityTopTldMaliciousGetResponseEnvelopeJSON contains the JSON metadata +// for the struct [EmailSecurityTopTldMaliciousGetResponseEnvelope] +type emailSecurityTopTldMaliciousGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldMaliciousGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldMaliciousGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/emailsecuritytoptldmalicious_test.go b/radar/emailsecuritytoptldmalicious_test.go new file mode 100644 index 00000000000..67484a15dec --- /dev/null +++ b/radar/emailsecuritytoptldmalicious_test.go @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestEmailSecurityTopTldMaliciousGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.Top.Tlds.Malicious.Get( + context.TODO(), + radar.EmailSecurityTopTldMaliciousGetParamsMaliciousMalicious, + radar.EmailSecurityTopTldMaliciousGetParams{ + ARC: cloudflare.F([]radar.EmailSecurityTopTldMaliciousGetParamsARC{radar.EmailSecurityTopTldMaliciousGetParamsARCPass, radar.EmailSecurityTopTldMaliciousGetParamsARCNone, radar.EmailSecurityTopTldMaliciousGetParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecurityTopTldMaliciousGetParamsDateRange{radar.EmailSecurityTopTldMaliciousGetParamsDateRange1d, radar.EmailSecurityTopTldMaliciousGetParamsDateRange2d, radar.EmailSecurityTopTldMaliciousGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecurityTopTldMaliciousGetParamsDKIM{radar.EmailSecurityTopTldMaliciousGetParamsDKIMPass, radar.EmailSecurityTopTldMaliciousGetParamsDKIMNone, radar.EmailSecurityTopTldMaliciousGetParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailSecurityTopTldMaliciousGetParamsDMARC{radar.EmailSecurityTopTldMaliciousGetParamsDMARCPass, radar.EmailSecurityTopTldMaliciousGetParamsDMARCNone, radar.EmailSecurityTopTldMaliciousGetParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecurityTopTldMaliciousGetParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecurityTopTldMaliciousGetParamsSPF{radar.EmailSecurityTopTldMaliciousGetParamsSPFPass, radar.EmailSecurityTopTldMaliciousGetParamsSPFNone, radar.EmailSecurityTopTldMaliciousGetParamsSPFFail}), + TldCategory: cloudflare.F(radar.EmailSecurityTopTldMaliciousGetParamsTldCategoryClassic), + TLSVersion: cloudflare.F([]radar.EmailSecurityTopTldMaliciousGetParamsTLSVersion{radar.EmailSecurityTopTldMaliciousGetParamsTLSVersionTlSv1_0, radar.EmailSecurityTopTldMaliciousGetParamsTLSVersionTlSv1_1, radar.EmailSecurityTopTldMaliciousGetParamsTLSVersionTlSv1_2}), + }, + ) + 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/radar/emailsecuritytoptldspam.go b/radar/emailsecuritytoptldspam.go new file mode 100644 index 00000000000..5b26bf3ff00 --- /dev/null +++ b/radar/emailsecuritytoptldspam.go @@ -0,0 +1,347 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// EmailSecurityTopTldSpamService 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 +// [NewEmailSecurityTopTldSpamService] method instead. +type EmailSecurityTopTldSpamService struct { + Options []option.RequestOption +} + +// NewEmailSecurityTopTldSpamService 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 NewEmailSecurityTopTldSpamService(opts ...option.RequestOption) (r *EmailSecurityTopTldSpamService) { + r = &EmailSecurityTopTldSpamService{} + r.Options = opts + return +} + +// Get the top TLDs by emails classified as Spam or not. +func (r *EmailSecurityTopTldSpamService) Get(ctx context.Context, spam EmailSecurityTopTldSpamGetParamsSpam, query EmailSecurityTopTldSpamGetParams, opts ...option.RequestOption) (res *EmailSecurityTopTldSpamGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecurityTopTldSpamGetResponseEnvelope + path := fmt.Sprintf("radar/email/security/top/tlds/spam/%v", spam) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type EmailSecurityTopTldSpamGetResponse struct { + Meta EmailSecurityTopTldSpamGetResponseMeta `json:"meta,required"` + Top0 []EmailSecurityTopTldSpamGetResponseTop0 `json:"top_0,required"` + JSON emailSecurityTopTldSpamGetResponseJSON `json:"-"` +} + +// emailSecurityTopTldSpamGetResponseJSON contains the JSON metadata for the struct +// [EmailSecurityTopTldSpamGetResponse] +type emailSecurityTopTldSpamGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldSpamGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldSpamGetResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldSpamGetResponseMeta struct { + DateRange []EmailSecurityTopTldSpamGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo EmailSecurityTopTldSpamGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailSecurityTopTldSpamGetResponseMetaJSON `json:"-"` +} + +// emailSecurityTopTldSpamGetResponseMetaJSON contains the JSON metadata for the +// struct [EmailSecurityTopTldSpamGetResponseMeta] +type emailSecurityTopTldSpamGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldSpamGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldSpamGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldSpamGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailSecurityTopTldSpamGetResponseMetaDateRangeJSON `json:"-"` +} + +// emailSecurityTopTldSpamGetResponseMetaDateRangeJSON contains the JSON metadata +// for the struct [EmailSecurityTopTldSpamGetResponseMetaDateRange] +type emailSecurityTopTldSpamGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldSpamGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldSpamGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldSpamGetResponseMetaConfidenceInfo struct { + Annotations []EmailSecurityTopTldSpamGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailSecurityTopTldSpamGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailSecurityTopTldSpamGetResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [EmailSecurityTopTldSpamGetResponseMetaConfidenceInfo] +type emailSecurityTopTldSpamGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldSpamGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldSpamGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldSpamGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailSecurityTopTldSpamGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailSecurityTopTldSpamGetResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [EmailSecurityTopTldSpamGetResponseMetaConfidenceInfoAnnotation] +type emailSecurityTopTldSpamGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldSpamGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldSpamGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldSpamGetResponseTop0 struct { + Name string `json:"name,required"` + Value string `json:"value,required"` + JSON emailSecurityTopTldSpamGetResponseTop0JSON `json:"-"` +} + +// emailSecurityTopTldSpamGetResponseTop0JSON contains the JSON metadata for the +// struct [EmailSecurityTopTldSpamGetResponseTop0] +type emailSecurityTopTldSpamGetResponseTop0JSON struct { + Name apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldSpamGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldSpamGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldSpamGetParams struct { + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecurityTopTldSpamGetParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecurityTopTldSpamGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecurityTopTldSpamGetParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecurityTopTldSpamGetParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecurityTopTldSpamGetParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecurityTopTldSpamGetParamsSPF] `query:"spf"` + // Filter for TLDs by category. + TldCategory param.Field[EmailSecurityTopTldSpamGetParamsTldCategory] `query:"tldCategory"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecurityTopTldSpamGetParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecurityTopTldSpamGetParams]'s query parameters as +// `url.Values`. +func (r EmailSecurityTopTldSpamGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Spam. +type EmailSecurityTopTldSpamGetParamsSpam string + +const ( + EmailSecurityTopTldSpamGetParamsSpamSpam EmailSecurityTopTldSpamGetParamsSpam = "SPAM" + EmailSecurityTopTldSpamGetParamsSpamNotSpam EmailSecurityTopTldSpamGetParamsSpam = "NOT_SPAM" +) + +type EmailSecurityTopTldSpamGetParamsARC string + +const ( + EmailSecurityTopTldSpamGetParamsARCPass EmailSecurityTopTldSpamGetParamsARC = "PASS" + EmailSecurityTopTldSpamGetParamsARCNone EmailSecurityTopTldSpamGetParamsARC = "NONE" + EmailSecurityTopTldSpamGetParamsARCFail EmailSecurityTopTldSpamGetParamsARC = "FAIL" +) + +type EmailSecurityTopTldSpamGetParamsDateRange string + +const ( + EmailSecurityTopTldSpamGetParamsDateRange1d EmailSecurityTopTldSpamGetParamsDateRange = "1d" + EmailSecurityTopTldSpamGetParamsDateRange2d EmailSecurityTopTldSpamGetParamsDateRange = "2d" + EmailSecurityTopTldSpamGetParamsDateRange7d EmailSecurityTopTldSpamGetParamsDateRange = "7d" + EmailSecurityTopTldSpamGetParamsDateRange14d EmailSecurityTopTldSpamGetParamsDateRange = "14d" + EmailSecurityTopTldSpamGetParamsDateRange28d EmailSecurityTopTldSpamGetParamsDateRange = "28d" + EmailSecurityTopTldSpamGetParamsDateRange12w EmailSecurityTopTldSpamGetParamsDateRange = "12w" + EmailSecurityTopTldSpamGetParamsDateRange24w EmailSecurityTopTldSpamGetParamsDateRange = "24w" + EmailSecurityTopTldSpamGetParamsDateRange52w EmailSecurityTopTldSpamGetParamsDateRange = "52w" + EmailSecurityTopTldSpamGetParamsDateRange1dControl EmailSecurityTopTldSpamGetParamsDateRange = "1dControl" + EmailSecurityTopTldSpamGetParamsDateRange2dControl EmailSecurityTopTldSpamGetParamsDateRange = "2dControl" + EmailSecurityTopTldSpamGetParamsDateRange7dControl EmailSecurityTopTldSpamGetParamsDateRange = "7dControl" + EmailSecurityTopTldSpamGetParamsDateRange14dControl EmailSecurityTopTldSpamGetParamsDateRange = "14dControl" + EmailSecurityTopTldSpamGetParamsDateRange28dControl EmailSecurityTopTldSpamGetParamsDateRange = "28dControl" + EmailSecurityTopTldSpamGetParamsDateRange12wControl EmailSecurityTopTldSpamGetParamsDateRange = "12wControl" + EmailSecurityTopTldSpamGetParamsDateRange24wControl EmailSecurityTopTldSpamGetParamsDateRange = "24wControl" +) + +type EmailSecurityTopTldSpamGetParamsDKIM string + +const ( + EmailSecurityTopTldSpamGetParamsDKIMPass EmailSecurityTopTldSpamGetParamsDKIM = "PASS" + EmailSecurityTopTldSpamGetParamsDKIMNone EmailSecurityTopTldSpamGetParamsDKIM = "NONE" + EmailSecurityTopTldSpamGetParamsDKIMFail EmailSecurityTopTldSpamGetParamsDKIM = "FAIL" +) + +type EmailSecurityTopTldSpamGetParamsDMARC string + +const ( + EmailSecurityTopTldSpamGetParamsDMARCPass EmailSecurityTopTldSpamGetParamsDMARC = "PASS" + EmailSecurityTopTldSpamGetParamsDMARCNone EmailSecurityTopTldSpamGetParamsDMARC = "NONE" + EmailSecurityTopTldSpamGetParamsDMARCFail EmailSecurityTopTldSpamGetParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecurityTopTldSpamGetParamsFormat string + +const ( + EmailSecurityTopTldSpamGetParamsFormatJson EmailSecurityTopTldSpamGetParamsFormat = "JSON" + EmailSecurityTopTldSpamGetParamsFormatCsv EmailSecurityTopTldSpamGetParamsFormat = "CSV" +) + +type EmailSecurityTopTldSpamGetParamsSPF string + +const ( + EmailSecurityTopTldSpamGetParamsSPFPass EmailSecurityTopTldSpamGetParamsSPF = "PASS" + EmailSecurityTopTldSpamGetParamsSPFNone EmailSecurityTopTldSpamGetParamsSPF = "NONE" + EmailSecurityTopTldSpamGetParamsSPFFail EmailSecurityTopTldSpamGetParamsSPF = "FAIL" +) + +// Filter for TLDs by category. +type EmailSecurityTopTldSpamGetParamsTldCategory string + +const ( + EmailSecurityTopTldSpamGetParamsTldCategoryClassic EmailSecurityTopTldSpamGetParamsTldCategory = "CLASSIC" + EmailSecurityTopTldSpamGetParamsTldCategoryCountry EmailSecurityTopTldSpamGetParamsTldCategory = "COUNTRY" +) + +type EmailSecurityTopTldSpamGetParamsTLSVersion string + +const ( + EmailSecurityTopTldSpamGetParamsTLSVersionTlSv1_0 EmailSecurityTopTldSpamGetParamsTLSVersion = "TLSv1_0" + EmailSecurityTopTldSpamGetParamsTLSVersionTlSv1_1 EmailSecurityTopTldSpamGetParamsTLSVersion = "TLSv1_1" + EmailSecurityTopTldSpamGetParamsTLSVersionTlSv1_2 EmailSecurityTopTldSpamGetParamsTLSVersion = "TLSv1_2" + EmailSecurityTopTldSpamGetParamsTLSVersionTlSv1_3 EmailSecurityTopTldSpamGetParamsTLSVersion = "TLSv1_3" +) + +type EmailSecurityTopTldSpamGetResponseEnvelope struct { + Result EmailSecurityTopTldSpamGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecurityTopTldSpamGetResponseEnvelopeJSON `json:"-"` +} + +// emailSecurityTopTldSpamGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [EmailSecurityTopTldSpamGetResponseEnvelope] +type emailSecurityTopTldSpamGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldSpamGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldSpamGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/emailsecuritytoptldspam_test.go b/radar/emailsecuritytoptldspam_test.go new file mode 100644 index 00000000000..1c50be3f037 --- /dev/null +++ b/radar/emailsecuritytoptldspam_test.go @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestEmailSecurityTopTldSpamGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.Top.Tlds.Spam.Get( + context.TODO(), + radar.EmailSecurityTopTldSpamGetParamsSpamSpam, + radar.EmailSecurityTopTldSpamGetParams{ + ARC: cloudflare.F([]radar.EmailSecurityTopTldSpamGetParamsARC{radar.EmailSecurityTopTldSpamGetParamsARCPass, radar.EmailSecurityTopTldSpamGetParamsARCNone, radar.EmailSecurityTopTldSpamGetParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecurityTopTldSpamGetParamsDateRange{radar.EmailSecurityTopTldSpamGetParamsDateRange1d, radar.EmailSecurityTopTldSpamGetParamsDateRange2d, radar.EmailSecurityTopTldSpamGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecurityTopTldSpamGetParamsDKIM{radar.EmailSecurityTopTldSpamGetParamsDKIMPass, radar.EmailSecurityTopTldSpamGetParamsDKIMNone, radar.EmailSecurityTopTldSpamGetParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailSecurityTopTldSpamGetParamsDMARC{radar.EmailSecurityTopTldSpamGetParamsDMARCPass, radar.EmailSecurityTopTldSpamGetParamsDMARCNone, radar.EmailSecurityTopTldSpamGetParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecurityTopTldSpamGetParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecurityTopTldSpamGetParamsSPF{radar.EmailSecurityTopTldSpamGetParamsSPFPass, radar.EmailSecurityTopTldSpamGetParamsSPFNone, radar.EmailSecurityTopTldSpamGetParamsSPFFail}), + TldCategory: cloudflare.F(radar.EmailSecurityTopTldSpamGetParamsTldCategoryClassic), + TLSVersion: cloudflare.F([]radar.EmailSecurityTopTldSpamGetParamsTLSVersion{radar.EmailSecurityTopTldSpamGetParamsTLSVersionTlSv1_0, radar.EmailSecurityTopTldSpamGetParamsTLSVersionTlSv1_1, radar.EmailSecurityTopTldSpamGetParamsTLSVersionTlSv1_2}), + }, + ) + 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/radar/emailsecuritytoptldspoof.go b/radar/emailsecuritytoptldspoof.go new file mode 100644 index 00000000000..e8a0fd38df2 --- /dev/null +++ b/radar/emailsecuritytoptldspoof.go @@ -0,0 +1,347 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// EmailSecurityTopTldSpoofService 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 +// [NewEmailSecurityTopTldSpoofService] method instead. +type EmailSecurityTopTldSpoofService struct { + Options []option.RequestOption +} + +// NewEmailSecurityTopTldSpoofService 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 NewEmailSecurityTopTldSpoofService(opts ...option.RequestOption) (r *EmailSecurityTopTldSpoofService) { + r = &EmailSecurityTopTldSpoofService{} + r.Options = opts + return +} + +// Get the TLDs by emails classified as spoof or not. +func (r *EmailSecurityTopTldSpoofService) Get(ctx context.Context, spoof EmailSecurityTopTldSpoofGetParamsSpoof, query EmailSecurityTopTldSpoofGetParams, opts ...option.RequestOption) (res *EmailSecurityTopTldSpoofGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env EmailSecurityTopTldSpoofGetResponseEnvelope + path := fmt.Sprintf("radar/email/security/top/tlds/spoof/%v", spoof) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type EmailSecurityTopTldSpoofGetResponse struct { + Meta EmailSecurityTopTldSpoofGetResponseMeta `json:"meta,required"` + Top0 []EmailSecurityTopTldSpoofGetResponseTop0 `json:"top_0,required"` + JSON emailSecurityTopTldSpoofGetResponseJSON `json:"-"` +} + +// emailSecurityTopTldSpoofGetResponseJSON contains the JSON metadata for the +// struct [EmailSecurityTopTldSpoofGetResponse] +type emailSecurityTopTldSpoofGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldSpoofGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldSpoofGetResponseJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldSpoofGetResponseMeta struct { + DateRange []EmailSecurityTopTldSpoofGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo EmailSecurityTopTldSpoofGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON emailSecurityTopTldSpoofGetResponseMetaJSON `json:"-"` +} + +// emailSecurityTopTldSpoofGetResponseMetaJSON contains the JSON metadata for the +// struct [EmailSecurityTopTldSpoofGetResponseMeta] +type emailSecurityTopTldSpoofGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldSpoofGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldSpoofGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldSpoofGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON emailSecurityTopTldSpoofGetResponseMetaDateRangeJSON `json:"-"` +} + +// emailSecurityTopTldSpoofGetResponseMetaDateRangeJSON contains the JSON metadata +// for the struct [EmailSecurityTopTldSpoofGetResponseMetaDateRange] +type emailSecurityTopTldSpoofGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldSpoofGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldSpoofGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldSpoofGetResponseMetaConfidenceInfo struct { + Annotations []EmailSecurityTopTldSpoofGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON emailSecurityTopTldSpoofGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// emailSecurityTopTldSpoofGetResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [EmailSecurityTopTldSpoofGetResponseMetaConfidenceInfo] +type emailSecurityTopTldSpoofGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldSpoofGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldSpoofGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldSpoofGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON emailSecurityTopTldSpoofGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// emailSecurityTopTldSpoofGetResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [EmailSecurityTopTldSpoofGetResponseMetaConfidenceInfoAnnotation] +type emailSecurityTopTldSpoofGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldSpoofGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldSpoofGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldSpoofGetResponseTop0 struct { + Name string `json:"name,required"` + Value string `json:"value,required"` + JSON emailSecurityTopTldSpoofGetResponseTop0JSON `json:"-"` +} + +// emailSecurityTopTldSpoofGetResponseTop0JSON contains the JSON metadata for the +// struct [EmailSecurityTopTldSpoofGetResponseTop0] +type emailSecurityTopTldSpoofGetResponseTop0JSON struct { + Name apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldSpoofGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldSpoofGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type EmailSecurityTopTldSpoofGetParams struct { + // Filter for arc (Authenticated Received Chain). + ARC param.Field[[]EmailSecurityTopTldSpoofGetParamsARC] `query:"arc"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]EmailSecurityTopTldSpoofGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for dkim. + DKIM param.Field[[]EmailSecurityTopTldSpoofGetParamsDKIM] `query:"dkim"` + // Filter for dmarc. + DMARC param.Field[[]EmailSecurityTopTldSpoofGetParamsDMARC] `query:"dmarc"` + // Format results are returned in. + Format param.Field[EmailSecurityTopTldSpoofGetParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for spf. + SPF param.Field[[]EmailSecurityTopTldSpoofGetParamsSPF] `query:"spf"` + // Filter for TLDs by category. + TldCategory param.Field[EmailSecurityTopTldSpoofGetParamsTldCategory] `query:"tldCategory"` + // Filter for tls version. + TLSVersion param.Field[[]EmailSecurityTopTldSpoofGetParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [EmailSecurityTopTldSpoofGetParams]'s query parameters as +// `url.Values`. +func (r EmailSecurityTopTldSpoofGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Spoof. +type EmailSecurityTopTldSpoofGetParamsSpoof string + +const ( + EmailSecurityTopTldSpoofGetParamsSpoofSpoof EmailSecurityTopTldSpoofGetParamsSpoof = "SPOOF" + EmailSecurityTopTldSpoofGetParamsSpoofNotSpoof EmailSecurityTopTldSpoofGetParamsSpoof = "NOT_SPOOF" +) + +type EmailSecurityTopTldSpoofGetParamsARC string + +const ( + EmailSecurityTopTldSpoofGetParamsARCPass EmailSecurityTopTldSpoofGetParamsARC = "PASS" + EmailSecurityTopTldSpoofGetParamsARCNone EmailSecurityTopTldSpoofGetParamsARC = "NONE" + EmailSecurityTopTldSpoofGetParamsARCFail EmailSecurityTopTldSpoofGetParamsARC = "FAIL" +) + +type EmailSecurityTopTldSpoofGetParamsDateRange string + +const ( + EmailSecurityTopTldSpoofGetParamsDateRange1d EmailSecurityTopTldSpoofGetParamsDateRange = "1d" + EmailSecurityTopTldSpoofGetParamsDateRange2d EmailSecurityTopTldSpoofGetParamsDateRange = "2d" + EmailSecurityTopTldSpoofGetParamsDateRange7d EmailSecurityTopTldSpoofGetParamsDateRange = "7d" + EmailSecurityTopTldSpoofGetParamsDateRange14d EmailSecurityTopTldSpoofGetParamsDateRange = "14d" + EmailSecurityTopTldSpoofGetParamsDateRange28d EmailSecurityTopTldSpoofGetParamsDateRange = "28d" + EmailSecurityTopTldSpoofGetParamsDateRange12w EmailSecurityTopTldSpoofGetParamsDateRange = "12w" + EmailSecurityTopTldSpoofGetParamsDateRange24w EmailSecurityTopTldSpoofGetParamsDateRange = "24w" + EmailSecurityTopTldSpoofGetParamsDateRange52w EmailSecurityTopTldSpoofGetParamsDateRange = "52w" + EmailSecurityTopTldSpoofGetParamsDateRange1dControl EmailSecurityTopTldSpoofGetParamsDateRange = "1dControl" + EmailSecurityTopTldSpoofGetParamsDateRange2dControl EmailSecurityTopTldSpoofGetParamsDateRange = "2dControl" + EmailSecurityTopTldSpoofGetParamsDateRange7dControl EmailSecurityTopTldSpoofGetParamsDateRange = "7dControl" + EmailSecurityTopTldSpoofGetParamsDateRange14dControl EmailSecurityTopTldSpoofGetParamsDateRange = "14dControl" + EmailSecurityTopTldSpoofGetParamsDateRange28dControl EmailSecurityTopTldSpoofGetParamsDateRange = "28dControl" + EmailSecurityTopTldSpoofGetParamsDateRange12wControl EmailSecurityTopTldSpoofGetParamsDateRange = "12wControl" + EmailSecurityTopTldSpoofGetParamsDateRange24wControl EmailSecurityTopTldSpoofGetParamsDateRange = "24wControl" +) + +type EmailSecurityTopTldSpoofGetParamsDKIM string + +const ( + EmailSecurityTopTldSpoofGetParamsDKIMPass EmailSecurityTopTldSpoofGetParamsDKIM = "PASS" + EmailSecurityTopTldSpoofGetParamsDKIMNone EmailSecurityTopTldSpoofGetParamsDKIM = "NONE" + EmailSecurityTopTldSpoofGetParamsDKIMFail EmailSecurityTopTldSpoofGetParamsDKIM = "FAIL" +) + +type EmailSecurityTopTldSpoofGetParamsDMARC string + +const ( + EmailSecurityTopTldSpoofGetParamsDMARCPass EmailSecurityTopTldSpoofGetParamsDMARC = "PASS" + EmailSecurityTopTldSpoofGetParamsDMARCNone EmailSecurityTopTldSpoofGetParamsDMARC = "NONE" + EmailSecurityTopTldSpoofGetParamsDMARCFail EmailSecurityTopTldSpoofGetParamsDMARC = "FAIL" +) + +// Format results are returned in. +type EmailSecurityTopTldSpoofGetParamsFormat string + +const ( + EmailSecurityTopTldSpoofGetParamsFormatJson EmailSecurityTopTldSpoofGetParamsFormat = "JSON" + EmailSecurityTopTldSpoofGetParamsFormatCsv EmailSecurityTopTldSpoofGetParamsFormat = "CSV" +) + +type EmailSecurityTopTldSpoofGetParamsSPF string + +const ( + EmailSecurityTopTldSpoofGetParamsSPFPass EmailSecurityTopTldSpoofGetParamsSPF = "PASS" + EmailSecurityTopTldSpoofGetParamsSPFNone EmailSecurityTopTldSpoofGetParamsSPF = "NONE" + EmailSecurityTopTldSpoofGetParamsSPFFail EmailSecurityTopTldSpoofGetParamsSPF = "FAIL" +) + +// Filter for TLDs by category. +type EmailSecurityTopTldSpoofGetParamsTldCategory string + +const ( + EmailSecurityTopTldSpoofGetParamsTldCategoryClassic EmailSecurityTopTldSpoofGetParamsTldCategory = "CLASSIC" + EmailSecurityTopTldSpoofGetParamsTldCategoryCountry EmailSecurityTopTldSpoofGetParamsTldCategory = "COUNTRY" +) + +type EmailSecurityTopTldSpoofGetParamsTLSVersion string + +const ( + EmailSecurityTopTldSpoofGetParamsTLSVersionTlSv1_0 EmailSecurityTopTldSpoofGetParamsTLSVersion = "TLSv1_0" + EmailSecurityTopTldSpoofGetParamsTLSVersionTlSv1_1 EmailSecurityTopTldSpoofGetParamsTLSVersion = "TLSv1_1" + EmailSecurityTopTldSpoofGetParamsTLSVersionTlSv1_2 EmailSecurityTopTldSpoofGetParamsTLSVersion = "TLSv1_2" + EmailSecurityTopTldSpoofGetParamsTLSVersionTlSv1_3 EmailSecurityTopTldSpoofGetParamsTLSVersion = "TLSv1_3" +) + +type EmailSecurityTopTldSpoofGetResponseEnvelope struct { + Result EmailSecurityTopTldSpoofGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON emailSecurityTopTldSpoofGetResponseEnvelopeJSON `json:"-"` +} + +// emailSecurityTopTldSpoofGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [EmailSecurityTopTldSpoofGetResponseEnvelope] +type emailSecurityTopTldSpoofGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EmailSecurityTopTldSpoofGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r emailSecurityTopTldSpoofGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/emailsecuritytoptldspoof_test.go b/radar/emailsecuritytoptldspoof_test.go new file mode 100644 index 00000000000..b3acf7580f4 --- /dev/null +++ b/radar/emailsecuritytoptldspoof_test.go @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestEmailSecurityTopTldSpoofGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Email.Security.Top.Tlds.Spoof.Get( + context.TODO(), + radar.EmailSecurityTopTldSpoofGetParamsSpoofSpoof, + radar.EmailSecurityTopTldSpoofGetParams{ + ARC: cloudflare.F([]radar.EmailSecurityTopTldSpoofGetParamsARC{radar.EmailSecurityTopTldSpoofGetParamsARCPass, radar.EmailSecurityTopTldSpoofGetParamsARCNone, radar.EmailSecurityTopTldSpoofGetParamsARCFail}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.EmailSecurityTopTldSpoofGetParamsDateRange{radar.EmailSecurityTopTldSpoofGetParamsDateRange1d, radar.EmailSecurityTopTldSpoofGetParamsDateRange2d, radar.EmailSecurityTopTldSpoofGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DKIM: cloudflare.F([]radar.EmailSecurityTopTldSpoofGetParamsDKIM{radar.EmailSecurityTopTldSpoofGetParamsDKIMPass, radar.EmailSecurityTopTldSpoofGetParamsDKIMNone, radar.EmailSecurityTopTldSpoofGetParamsDKIMFail}), + DMARC: cloudflare.F([]radar.EmailSecurityTopTldSpoofGetParamsDMARC{radar.EmailSecurityTopTldSpoofGetParamsDMARCPass, radar.EmailSecurityTopTldSpoofGetParamsDMARCNone, radar.EmailSecurityTopTldSpoofGetParamsDMARCFail}), + Format: cloudflare.F(radar.EmailSecurityTopTldSpoofGetParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Name: cloudflare.F([]string{"string", "string", "string"}), + SPF: cloudflare.F([]radar.EmailSecurityTopTldSpoofGetParamsSPF{radar.EmailSecurityTopTldSpoofGetParamsSPFPass, radar.EmailSecurityTopTldSpoofGetParamsSPFNone, radar.EmailSecurityTopTldSpoofGetParamsSPFFail}), + TldCategory: cloudflare.F(radar.EmailSecurityTopTldSpoofGetParamsTldCategoryClassic), + TLSVersion: cloudflare.F([]radar.EmailSecurityTopTldSpoofGetParamsTLSVersion{radar.EmailSecurityTopTldSpoofGetParamsTLSVersionTlSv1_0, radar.EmailSecurityTopTldSpoofGetParamsTLSVersionTlSv1_1, radar.EmailSecurityTopTldSpoofGetParamsTLSVersionTlSv1_2}), + }, + ) + 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/radar/entity.go b/radar/entity.go new file mode 100644 index 00000000000..2c7e31f0ce6 --- /dev/null +++ b/radar/entity.go @@ -0,0 +1,151 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// EntityService 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 [NewEntityService] method instead. +type EntityService struct { + Options []option.RequestOption + ASNs *EntityASNService + Locations *EntityLocationService +} + +// NewEntityService 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 NewEntityService(opts ...option.RequestOption) (r *EntityService) { + r = &EntityService{} + r.Options = opts + r.ASNs = NewEntityASNService(opts...) + r.Locations = NewEntityLocationService(opts...) + return +} + +// Get IP address information. +func (r *EntityService) Get(ctx context.Context, query EntityGetParams, opts ...option.RequestOption) (res *EntityGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env EntityGetResponseEnvelope + path := "radar/entities/ip" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type EntityGetResponse struct { + IP EntityGetResponseIP `json:"ip,required"` + JSON entityGetResponseJSON `json:"-"` +} + +// entityGetResponseJSON contains the JSON metadata for the struct +// [EntityGetResponse] +type entityGetResponseJSON struct { + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityGetResponseJSON) RawJSON() string { + return r.raw +} + +type EntityGetResponseIP struct { + ASN string `json:"asn,required"` + ASNLocation string `json:"asnLocation,required"` + ASNName string `json:"asnName,required"` + ASNOrgName string `json:"asnOrgName,required"` + IP string `json:"ip,required"` + IPVersion string `json:"ipVersion,required"` + Location string `json:"location,required"` + LocationName string `json:"locationName,required"` + JSON entityGetResponseIPJSON `json:"-"` +} + +// entityGetResponseIPJSON contains the JSON metadata for the struct +// [EntityGetResponseIP] +type entityGetResponseIPJSON struct { + ASN apijson.Field + ASNLocation apijson.Field + ASNName apijson.Field + ASNOrgName apijson.Field + IP apijson.Field + IPVersion apijson.Field + Location apijson.Field + LocationName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityGetResponseIP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityGetResponseIPJSON) RawJSON() string { + return r.raw +} + +type EntityGetParams struct { + // IP address. + IP param.Field[string] `query:"ip,required"` + // Format results are returned in. + Format param.Field[EntityGetParamsFormat] `query:"format"` +} + +// URLQuery serializes [EntityGetParams]'s query parameters as `url.Values`. +func (r EntityGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Format results are returned in. +type EntityGetParamsFormat string + +const ( + EntityGetParamsFormatJson EntityGetParamsFormat = "JSON" + EntityGetParamsFormatCsv EntityGetParamsFormat = "CSV" +) + +type EntityGetResponseEnvelope struct { + Result EntityGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON entityGetResponseEnvelopeJSON `json:"-"` +} + +// entityGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [EntityGetResponseEnvelope] +type entityGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/entity_test.go b/radar/entity_test.go new file mode 100644 index 00000000000..a39840f8af8 --- /dev/null +++ b/radar/entity_test.go @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestEntityGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Entities.Get(context.TODO(), radar.EntityGetParams{ + IP: cloudflare.F("8.8.8.8"), + Format: cloudflare.F(radar.EntityGetParamsFormatJson), + }) + 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/radar/entityasn.go b/radar/entityasn.go new file mode 100644 index 00000000000..8d731578d0a --- /dev/null +++ b/radar/entityasn.go @@ -0,0 +1,711 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// EntityASNService 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 [NewEntityASNService] method instead. +type EntityASNService struct { + Options []option.RequestOption +} + +// NewEntityASNService 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 NewEntityASNService(opts ...option.RequestOption) (r *EntityASNService) { + r = &EntityASNService{} + r.Options = opts + return +} + +// Gets a list of autonomous systems (AS). +func (r *EntityASNService) List(ctx context.Context, query EntityASNListParams, opts ...option.RequestOption) (res *EntityASNListResponse, err error) { + opts = append(r.Options[:], opts...) + var env EntityASNListResponseEnvelope + path := "radar/entities/asns" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the requested autonomous system information. A confidence level below `5` +// indicates a low level of confidence in the traffic data - normally this happens +// because Cloudflare has a small amount of traffic from/to this AS). Population +// estimates come from APNIC (refer to https://labs.apnic.net/?p=526). +func (r *EntityASNService) Get(ctx context.Context, asn int64, query EntityASNGetParams, opts ...option.RequestOption) (res *EntityASNGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env EntityASNGetResponseEnvelope + path := fmt.Sprintf("radar/entities/asns/%v", asn) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the requested autonomous system information based on IP address. Population +// estimates come from APNIC (refer to https://labs.apnic.net/?p=526). +func (r *EntityASNService) IP(ctx context.Context, query EntityASNIPParams, opts ...option.RequestOption) (res *EntityAsnipResponse, err error) { + opts = append(r.Options[:], opts...) + var env EntityAsnipResponseEnvelope + path := "radar/entities/asns/ip" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get AS-level relationship for given networks. +func (r *EntityASNService) Rel(ctx context.Context, asn int64, query EntityASNRelParams, opts ...option.RequestOption) (res *EntityASNRelResponse, err error) { + opts = append(r.Options[:], opts...) + var env EntityASNRelResponseEnvelope + path := fmt.Sprintf("radar/entities/asns/%v/rel", asn) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type EntityASNListResponse struct { + ASNs []EntityASNListResponseASN `json:"asns,required"` + JSON entityASNListResponseJSON `json:"-"` +} + +// entityASNListResponseJSON contains the JSON metadata for the struct +// [EntityASNListResponse] +type entityASNListResponseJSON struct { + ASNs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityASNListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityASNListResponseJSON) RawJSON() string { + return r.raw +} + +type EntityASNListResponseASN struct { + ASN int64 `json:"asn,required"` + Country string `json:"country,required"` + CountryName string `json:"countryName,required"` + Name string `json:"name,required"` + Aka string `json:"aka"` + // Deprecated field. Please use 'aka'. + NameLong string `json:"nameLong"` + OrgName string `json:"orgName"` + Website string `json:"website"` + JSON entityASNListResponseASNJSON `json:"-"` +} + +// entityASNListResponseASNJSON contains the JSON metadata for the struct +// [EntityASNListResponseASN] +type entityASNListResponseASNJSON struct { + ASN apijson.Field + Country apijson.Field + CountryName apijson.Field + Name apijson.Field + Aka apijson.Field + NameLong apijson.Field + OrgName apijson.Field + Website apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityASNListResponseASN) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityASNListResponseASNJSON) RawJSON() string { + return r.raw +} + +type EntityASNGetResponse struct { + ASN EntityASNGetResponseASN `json:"asn,required"` + JSON entityASNGetResponseJSON `json:"-"` +} + +// entityASNGetResponseJSON contains the JSON metadata for the struct +// [EntityASNGetResponse] +type entityASNGetResponseJSON struct { + ASN apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityASNGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityASNGetResponseJSON) RawJSON() string { + return r.raw +} + +type EntityASNGetResponseASN struct { + ASN int64 `json:"asn,required"` + ConfidenceLevel int64 `json:"confidenceLevel,required"` + Country string `json:"country,required"` + CountryName string `json:"countryName,required"` + EstimatedUsers EntityASNGetResponseASNEstimatedUsers `json:"estimatedUsers,required"` + Name string `json:"name,required"` + OrgName string `json:"orgName,required"` + Related []EntityASNGetResponseASNRelated `json:"related,required"` + // Regional Internet Registry + Source string `json:"source,required"` + Website string `json:"website,required"` + Aka string `json:"aka"` + // Deprecated field. Please use 'aka'. + NameLong string `json:"nameLong"` + JSON entityASNGetResponseASNJSON `json:"-"` +} + +// entityASNGetResponseASNJSON contains the JSON metadata for the struct +// [EntityASNGetResponseASN] +type entityASNGetResponseASNJSON struct { + ASN apijson.Field + ConfidenceLevel apijson.Field + Country apijson.Field + CountryName apijson.Field + EstimatedUsers apijson.Field + Name apijson.Field + OrgName apijson.Field + Related apijson.Field + Source apijson.Field + Website apijson.Field + Aka apijson.Field + NameLong apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityASNGetResponseASN) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityASNGetResponseASNJSON) RawJSON() string { + return r.raw +} + +type EntityASNGetResponseASNEstimatedUsers struct { + Locations []EntityASNGetResponseASNEstimatedUsersLocation `json:"locations,required"` + // Total estimated users + EstimatedUsers int64 `json:"estimatedUsers"` + JSON entityASNGetResponseASNEstimatedUsersJSON `json:"-"` +} + +// entityASNGetResponseASNEstimatedUsersJSON contains the JSON metadata for the +// struct [EntityASNGetResponseASNEstimatedUsers] +type entityASNGetResponseASNEstimatedUsersJSON struct { + Locations apijson.Field + EstimatedUsers apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityASNGetResponseASNEstimatedUsers) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityASNGetResponseASNEstimatedUsersJSON) RawJSON() string { + return r.raw +} + +type EntityASNGetResponseASNEstimatedUsersLocation struct { + LocationAlpha2 string `json:"locationAlpha2,required"` + LocationName string `json:"locationName,required"` + // Estimated users per location + EstimatedUsers int64 `json:"estimatedUsers"` + JSON entityASNGetResponseASNEstimatedUsersLocationJSON `json:"-"` +} + +// entityASNGetResponseASNEstimatedUsersLocationJSON contains the JSON metadata for +// the struct [EntityASNGetResponseASNEstimatedUsersLocation] +type entityASNGetResponseASNEstimatedUsersLocationJSON struct { + LocationAlpha2 apijson.Field + LocationName apijson.Field + EstimatedUsers apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityASNGetResponseASNEstimatedUsersLocation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityASNGetResponseASNEstimatedUsersLocationJSON) RawJSON() string { + return r.raw +} + +type EntityASNGetResponseASNRelated struct { + ASN int64 `json:"asn,required"` + Name string `json:"name,required"` + Aka string `json:"aka"` + // Total estimated users + EstimatedUsers int64 `json:"estimatedUsers"` + JSON entityASNGetResponseASNRelatedJSON `json:"-"` +} + +// entityASNGetResponseASNRelatedJSON contains the JSON metadata for the struct +// [EntityASNGetResponseASNRelated] +type entityASNGetResponseASNRelatedJSON struct { + ASN apijson.Field + Name apijson.Field + Aka apijson.Field + EstimatedUsers apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityASNGetResponseASNRelated) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityASNGetResponseASNRelatedJSON) RawJSON() string { + return r.raw +} + +type EntityAsnipResponse struct { + ASN EntityAsnipResponseASN `json:"asn,required"` + JSON entityAsnipResponseJSON `json:"-"` +} + +// entityAsnipResponseJSON contains the JSON metadata for the struct +// [EntityAsnipResponse] +type entityAsnipResponseJSON struct { + ASN apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityAsnipResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityAsnipResponseJSON) RawJSON() string { + return r.raw +} + +type EntityAsnipResponseASN struct { + ASN int64 `json:"asn,required"` + Country string `json:"country,required"` + CountryName string `json:"countryName,required"` + EstimatedUsers EntityAsnipResponseASNEstimatedUsers `json:"estimatedUsers,required"` + Name string `json:"name,required"` + OrgName string `json:"orgName,required"` + Related []EntityAsnipResponseASNRelated `json:"related,required"` + // Regional Internet Registry + Source string `json:"source,required"` + Website string `json:"website,required"` + Aka string `json:"aka"` + // Deprecated field. Please use 'aka'. + NameLong string `json:"nameLong"` + JSON entityAsnipResponseASNJSON `json:"-"` +} + +// entityAsnipResponseASNJSON contains the JSON metadata for the struct +// [EntityAsnipResponseASN] +type entityAsnipResponseASNJSON struct { + ASN apijson.Field + Country apijson.Field + CountryName apijson.Field + EstimatedUsers apijson.Field + Name apijson.Field + OrgName apijson.Field + Related apijson.Field + Source apijson.Field + Website apijson.Field + Aka apijson.Field + NameLong apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityAsnipResponseASN) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityAsnipResponseASNJSON) RawJSON() string { + return r.raw +} + +type EntityAsnipResponseASNEstimatedUsers struct { + Locations []EntityAsnipResponseASNEstimatedUsersLocation `json:"locations,required"` + // Total estimated users + EstimatedUsers int64 `json:"estimatedUsers"` + JSON entityAsnipResponseASNEstimatedUsersJSON `json:"-"` +} + +// entityAsnipResponseASNEstimatedUsersJSON contains the JSON metadata for the +// struct [EntityAsnipResponseASNEstimatedUsers] +type entityAsnipResponseASNEstimatedUsersJSON struct { + Locations apijson.Field + EstimatedUsers apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityAsnipResponseASNEstimatedUsers) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityAsnipResponseASNEstimatedUsersJSON) RawJSON() string { + return r.raw +} + +type EntityAsnipResponseASNEstimatedUsersLocation struct { + LocationAlpha2 string `json:"locationAlpha2,required"` + LocationName string `json:"locationName,required"` + // Estimated users per location + EstimatedUsers int64 `json:"estimatedUsers"` + JSON entityAsnipResponseASNEstimatedUsersLocationJSON `json:"-"` +} + +// entityAsnipResponseASNEstimatedUsersLocationJSON contains the JSON metadata for +// the struct [EntityAsnipResponseASNEstimatedUsersLocation] +type entityAsnipResponseASNEstimatedUsersLocationJSON struct { + LocationAlpha2 apijson.Field + LocationName apijson.Field + EstimatedUsers apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityAsnipResponseASNEstimatedUsersLocation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityAsnipResponseASNEstimatedUsersLocationJSON) RawJSON() string { + return r.raw +} + +type EntityAsnipResponseASNRelated struct { + ASN int64 `json:"asn,required"` + Name string `json:"name,required"` + Aka string `json:"aka"` + // Total estimated users + EstimatedUsers int64 `json:"estimatedUsers"` + JSON entityAsnipResponseASNRelatedJSON `json:"-"` +} + +// entityAsnipResponseASNRelatedJSON contains the JSON metadata for the struct +// [EntityAsnipResponseASNRelated] +type entityAsnipResponseASNRelatedJSON struct { + ASN apijson.Field + Name apijson.Field + Aka apijson.Field + EstimatedUsers apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityAsnipResponseASNRelated) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityAsnipResponseASNRelatedJSON) RawJSON() string { + return r.raw +} + +type EntityASNRelResponse struct { + Meta EntityASNRelResponseMeta `json:"meta,required"` + Rels []EntityASNRelResponseRel `json:"rels,required"` + JSON entityASNRelResponseJSON `json:"-"` +} + +// entityASNRelResponseJSON contains the JSON metadata for the struct +// [EntityASNRelResponse] +type entityASNRelResponseJSON struct { + Meta apijson.Field + Rels apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityASNRelResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityASNRelResponseJSON) RawJSON() string { + return r.raw +} + +type EntityASNRelResponseMeta struct { + DataTime string `json:"data_time,required"` + QueryTime string `json:"query_time,required"` + TotalPeers int64 `json:"total_peers,required"` + JSON entityASNRelResponseMetaJSON `json:"-"` +} + +// entityASNRelResponseMetaJSON contains the JSON metadata for the struct +// [EntityASNRelResponseMeta] +type entityASNRelResponseMetaJSON struct { + DataTime apijson.Field + QueryTime apijson.Field + TotalPeers apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityASNRelResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityASNRelResponseMetaJSON) RawJSON() string { + return r.raw +} + +type EntityASNRelResponseRel struct { + Asn1 int64 `json:"asn1,required"` + Asn1Country string `json:"asn1_country,required"` + Asn1Name string `json:"asn1_name,required"` + Asn2 int64 `json:"asn2,required"` + Asn2Country string `json:"asn2_country,required"` + Asn2Name string `json:"asn2_name,required"` + Rel string `json:"rel,required"` + JSON entityASNRelResponseRelJSON `json:"-"` +} + +// entityASNRelResponseRelJSON contains the JSON metadata for the struct +// [EntityASNRelResponseRel] +type entityASNRelResponseRelJSON struct { + Asn1 apijson.Field + Asn1Country apijson.Field + Asn1Name apijson.Field + Asn2 apijson.Field + Asn2Country apijson.Field + Asn2Name apijson.Field + Rel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityASNRelResponseRel) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityASNRelResponseRelJSON) RawJSON() string { + return r.raw +} + +type EntityASNListParams struct { + // Comma separated list of ASNs. + ASN param.Field[string] `query:"asn"` + // Format results are returned in. + Format param.Field[EntityASNListParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Location Alpha2 to filter results. + Location param.Field[string] `query:"location"` + // Number of objects to skip before grabbing results. + Offset param.Field[int64] `query:"offset"` + // Order asn list. + OrderBy param.Field[EntityASNListParamsOrderBy] `query:"orderBy"` +} + +// URLQuery serializes [EntityASNListParams]'s query parameters as `url.Values`. +func (r EntityASNListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Format results are returned in. +type EntityASNListParamsFormat string + +const ( + EntityASNListParamsFormatJson EntityASNListParamsFormat = "JSON" + EntityASNListParamsFormatCsv EntityASNListParamsFormat = "CSV" +) + +// Order asn list. +type EntityASNListParamsOrderBy string + +const ( + EntityASNListParamsOrderByASN EntityASNListParamsOrderBy = "ASN" + EntityASNListParamsOrderByPopulation EntityASNListParamsOrderBy = "POPULATION" +) + +type EntityASNListResponseEnvelope struct { + Result EntityASNListResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON entityASNListResponseEnvelopeJSON `json:"-"` +} + +// entityASNListResponseEnvelopeJSON contains the JSON metadata for the struct +// [EntityASNListResponseEnvelope] +type entityASNListResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityASNListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityASNListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EntityASNGetParams struct { + // Format results are returned in. + Format param.Field[EntityASNGetParamsFormat] `query:"format"` +} + +// URLQuery serializes [EntityASNGetParams]'s query parameters as `url.Values`. +func (r EntityASNGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Format results are returned in. +type EntityASNGetParamsFormat string + +const ( + EntityASNGetParamsFormatJson EntityASNGetParamsFormat = "JSON" + EntityASNGetParamsFormatCsv EntityASNGetParamsFormat = "CSV" +) + +type EntityASNGetResponseEnvelope struct { + Result EntityASNGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON entityASNGetResponseEnvelopeJSON `json:"-"` +} + +// entityASNGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [EntityASNGetResponseEnvelope] +type entityASNGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityASNGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityASNGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EntityASNIPParams struct { + // IP address. + IP param.Field[string] `query:"ip,required"` + // Format results are returned in. + Format param.Field[EntityAsnipParamsFormat] `query:"format"` +} + +// URLQuery serializes [EntityASNIPParams]'s query parameters as `url.Values`. +func (r EntityASNIPParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Format results are returned in. +type EntityAsnipParamsFormat string + +const ( + EntityAsnipParamsFormatJson EntityAsnipParamsFormat = "JSON" + EntityAsnipParamsFormatCsv EntityAsnipParamsFormat = "CSV" +) + +type EntityAsnipResponseEnvelope struct { + Result EntityAsnipResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON entityAsnipResponseEnvelopeJSON `json:"-"` +} + +// entityAsnipResponseEnvelopeJSON contains the JSON metadata for the struct +// [EntityAsnipResponseEnvelope] +type entityAsnipResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityAsnipResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityAsnipResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EntityASNRelParams struct { + // Get the AS relationship of ASN2 with respect to the given ASN + Asn2 param.Field[int64] `query:"asn2"` + // Format results are returned in. + Format param.Field[EntityASNRelParamsFormat] `query:"format"` +} + +// URLQuery serializes [EntityASNRelParams]'s query parameters as `url.Values`. +func (r EntityASNRelParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Format results are returned in. +type EntityASNRelParamsFormat string + +const ( + EntityASNRelParamsFormatJson EntityASNRelParamsFormat = "JSON" + EntityASNRelParamsFormatCsv EntityASNRelParamsFormat = "CSV" +) + +type EntityASNRelResponseEnvelope struct { + Result EntityASNRelResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON entityASNRelResponseEnvelopeJSON `json:"-"` +} + +// entityASNRelResponseEnvelopeJSON contains the JSON metadata for the struct +// [EntityASNRelResponseEnvelope] +type entityASNRelResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityASNRelResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityASNRelResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/entityasn_test.go b/radar/entityasn_test.go new file mode 100644 index 00000000000..abea898b279 --- /dev/null +++ b/radar/entityasn_test.go @@ -0,0 +1,134 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestEntityASNListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Entities.ASNs.List(context.TODO(), radar.EntityASNListParams{ + ASN: cloudflare.F("174,7922"), + Format: cloudflare.F(radar.EntityASNListParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F("US"), + Offset: cloudflare.F(int64(0)), + OrderBy: cloudflare.F(radar.EntityASNListParamsOrderByASN), + }) + 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 TestEntityASNGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Entities.ASNs.Get( + context.TODO(), + int64(3), + radar.EntityASNGetParams{ + Format: cloudflare.F(radar.EntityASNGetParamsFormatJson), + }, + ) + 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 TestEntityASNIPWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Entities.ASNs.IP(context.TODO(), radar.EntityASNIPParams{ + IP: cloudflare.F("8.8.8.8"), + Format: cloudflare.F(radar.EntityAsnipParamsFormatJson), + }) + 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 TestEntityASNRelWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Entities.ASNs.Rel( + context.TODO(), + int64(3), + radar.EntityASNRelParams{ + Asn2: cloudflare.F(int64(0)), + Format: cloudflare.F(radar.EntityASNRelParamsFormatJson), + }, + ) + 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/radar/entitylocation.go b/radar/entitylocation.go new file mode 100644 index 00000000000..929d2a584b9 --- /dev/null +++ b/radar/entitylocation.go @@ -0,0 +1,260 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// EntityLocationService 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 [NewEntityLocationService] method +// instead. +type EntityLocationService struct { + Options []option.RequestOption +} + +// NewEntityLocationService 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 NewEntityLocationService(opts ...option.RequestOption) (r *EntityLocationService) { + r = &EntityLocationService{} + r.Options = opts + return +} + +// Get a list of locations. +func (r *EntityLocationService) List(ctx context.Context, query EntityLocationListParams, opts ...option.RequestOption) (res *EntityLocationListResponse, err error) { + opts = append(r.Options[:], opts...) + var env EntityLocationListResponseEnvelope + path := "radar/entities/locations" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the requested location information. A confidence level below `5` indicates a +// low level of confidence in the traffic data - normally this happens because +// Cloudflare has a small amount of traffic from/to this location). +func (r *EntityLocationService) Get(ctx context.Context, location string, query EntityLocationGetParams, opts ...option.RequestOption) (res *EntityLocationGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env EntityLocationGetResponseEnvelope + path := fmt.Sprintf("radar/entities/locations/%s", location) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type EntityLocationListResponse struct { + Locations []EntityLocationListResponseLocation `json:"locations,required"` + JSON entityLocationListResponseJSON `json:"-"` +} + +// entityLocationListResponseJSON contains the JSON metadata for the struct +// [EntityLocationListResponse] +type entityLocationListResponseJSON struct { + Locations apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityLocationListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityLocationListResponseJSON) RawJSON() string { + return r.raw +} + +type EntityLocationListResponseLocation struct { + Alpha2 string `json:"alpha2,required"` + Latitude string `json:"latitude,required"` + Longitude string `json:"longitude,required"` + Name string `json:"name,required"` + JSON entityLocationListResponseLocationJSON `json:"-"` +} + +// entityLocationListResponseLocationJSON contains the JSON metadata for the struct +// [EntityLocationListResponseLocation] +type entityLocationListResponseLocationJSON struct { + Alpha2 apijson.Field + Latitude apijson.Field + Longitude apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityLocationListResponseLocation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityLocationListResponseLocationJSON) RawJSON() string { + return r.raw +} + +type EntityLocationGetResponse struct { + Location EntityLocationGetResponseLocation `json:"location,required"` + JSON entityLocationGetResponseJSON `json:"-"` +} + +// entityLocationGetResponseJSON contains the JSON metadata for the struct +// [EntityLocationGetResponse] +type entityLocationGetResponseJSON struct { + Location apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityLocationGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityLocationGetResponseJSON) RawJSON() string { + return r.raw +} + +type EntityLocationGetResponseLocation struct { + Alpha2 string `json:"alpha2,required"` + ConfidenceLevel int64 `json:"confidenceLevel,required"` + Latitude string `json:"latitude,required"` + Longitude string `json:"longitude,required"` + Name string `json:"name,required"` + Region string `json:"region,required"` + Subregion string `json:"subregion,required"` + JSON entityLocationGetResponseLocationJSON `json:"-"` +} + +// entityLocationGetResponseLocationJSON contains the JSON metadata for the struct +// [EntityLocationGetResponseLocation] +type entityLocationGetResponseLocationJSON struct { + Alpha2 apijson.Field + ConfidenceLevel apijson.Field + Latitude apijson.Field + Longitude apijson.Field + Name apijson.Field + Region apijson.Field + Subregion apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityLocationGetResponseLocation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityLocationGetResponseLocationJSON) RawJSON() string { + return r.raw +} + +type EntityLocationListParams struct { + // Format results are returned in. + Format param.Field[EntityLocationListParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Comma separated list of locations. + Location param.Field[string] `query:"location"` + // Number of objects to skip before grabbing results. + Offset param.Field[int64] `query:"offset"` +} + +// URLQuery serializes [EntityLocationListParams]'s query parameters as +// `url.Values`. +func (r EntityLocationListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Format results are returned in. +type EntityLocationListParamsFormat string + +const ( + EntityLocationListParamsFormatJson EntityLocationListParamsFormat = "JSON" + EntityLocationListParamsFormatCsv EntityLocationListParamsFormat = "CSV" +) + +type EntityLocationListResponseEnvelope struct { + Result EntityLocationListResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON entityLocationListResponseEnvelopeJSON `json:"-"` +} + +// entityLocationListResponseEnvelopeJSON contains the JSON metadata for the struct +// [EntityLocationListResponseEnvelope] +type entityLocationListResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityLocationListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityLocationListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EntityLocationGetParams struct { + // Format results are returned in. + Format param.Field[EntityLocationGetParamsFormat] `query:"format"` +} + +// URLQuery serializes [EntityLocationGetParams]'s query parameters as +// `url.Values`. +func (r EntityLocationGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Format results are returned in. +type EntityLocationGetParamsFormat string + +const ( + EntityLocationGetParamsFormatJson EntityLocationGetParamsFormat = "JSON" + EntityLocationGetParamsFormatCsv EntityLocationGetParamsFormat = "CSV" +) + +type EntityLocationGetResponseEnvelope struct { + Result EntityLocationGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON entityLocationGetResponseEnvelopeJSON `json:"-"` +} + +// entityLocationGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [EntityLocationGetResponseEnvelope] +type entityLocationGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EntityLocationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r entityLocationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/entitylocation_test.go b/radar/entitylocation_test.go new file mode 100644 index 00000000000..9004167a055 --- /dev/null +++ b/radar/entitylocation_test.go @@ -0,0 +1,74 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestEntityLocationListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Entities.Locations.List(context.TODO(), radar.EntityLocationListParams{ + Format: cloudflare.F(radar.EntityLocationListParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F("US,CA"), + Offset: cloudflare.F(int64(0)), + }) + 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 TestEntityLocationGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Entities.Locations.Get( + context.TODO(), + "US", + radar.EntityLocationGetParams{ + Format: cloudflare.F(radar.EntityLocationGetParamsFormatJson), + }, + ) + 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/radar/http.go b/radar/http.go new file mode 100644 index 00000000000..05143800791 --- /dev/null +++ b/radar/http.go @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPService 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 [NewHTTPService] method instead. +type HTTPService struct { + Options []option.RequestOption + Top *HTTPTopService + Locations *HTTPLocationService + Ases *HTTPAseService + Summary *HTTPSummaryService + TimeseriesGroups *HTTPTimeseriesGroupService +} + +// NewHTTPService 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 NewHTTPService(opts ...option.RequestOption) (r *HTTPService) { + r = &HTTPService{} + r.Options = opts + r.Top = NewHTTPTopService(opts...) + r.Locations = NewHTTPLocationService(opts...) + r.Ases = NewHTTPAseService(opts...) + r.Summary = NewHTTPSummaryService(opts...) + r.TimeseriesGroups = NewHTTPTimeseriesGroupService(opts...) + return +} diff --git a/radar/httpase.go b/radar/httpase.go new file mode 100644 index 00000000000..37a6cf78d5c --- /dev/null +++ b/radar/httpase.go @@ -0,0 +1,377 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPAseService 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 [NewHTTPAseService] method instead. +type HTTPAseService struct { + Options []option.RequestOption + BotClass *HTTPAseBotClassService + DeviceType *HTTPAseDeviceTypeService + HTTPProtocol *HTTPAseHTTPProtocolService + HTTPMethod *HTTPAseHTTPMethodService + IPVersion *HTTPAseIPVersionService + OS *HTTPAseOSService + TLSVersion *HTTPAseTLSVersionService +} + +// NewHTTPAseService 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 NewHTTPAseService(opts ...option.RequestOption) (r *HTTPAseService) { + r = &HTTPAseService{} + r.Options = opts + r.BotClass = NewHTTPAseBotClassService(opts...) + r.DeviceType = NewHTTPAseDeviceTypeService(opts...) + r.HTTPProtocol = NewHTTPAseHTTPProtocolService(opts...) + r.HTTPMethod = NewHTTPAseHTTPMethodService(opts...) + r.IPVersion = NewHTTPAseIPVersionService(opts...) + r.OS = NewHTTPAseOSService(opts...) + r.TLSVersion = NewHTTPAseTLSVersionService(opts...) + return +} + +// Get the top autonomous systems by HTTP traffic. Values are a percentage out of +// the total traffic. +func (r *HTTPAseService) Get(ctx context.Context, query HTTPAseGetParams, opts ...option.RequestOption) (res *HTTPAseGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPAseGetResponseEnvelope + path := "radar/http/top/ases" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPAseGetResponse struct { + Meta HTTPAseGetResponseMeta `json:"meta,required"` + Top0 []HTTPAseGetResponseTop0 `json:"top_0,required"` + JSON httpAseGetResponseJSON `json:"-"` +} + +// httpAseGetResponseJSON contains the JSON metadata for the struct +// [HTTPAseGetResponse] +type httpAseGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseGetResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPAseGetResponseMeta struct { + DateRange []HTTPAseGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo HTTPAseGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpAseGetResponseMetaJSON `json:"-"` +} + +// httpAseGetResponseMetaJSON contains the JSON metadata for the struct +// [HTTPAseGetResponseMeta] +type httpAseGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPAseGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpAseGetResponseMetaDateRangeJSON `json:"-"` +} + +// httpAseGetResponseMetaDateRangeJSON contains the JSON metadata for the struct +// [HTTPAseGetResponseMetaDateRange] +type httpAseGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPAseGetResponseMetaConfidenceInfo struct { + Annotations []HTTPAseGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpAseGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpAseGetResponseMetaConfidenceInfoJSON contains the JSON metadata for the +// struct [HTTPAseGetResponseMetaConfidenceInfo] +type httpAseGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPAseGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpAseGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpAseGetResponseMetaConfidenceInfoAnnotationJSON contains the JSON metadata +// for the struct [HTTPAseGetResponseMetaConfidenceInfoAnnotation] +type httpAseGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPAseGetResponseTop0 struct { + ClientASN int64 `json:"clientASN,required"` + ClientAsName string `json:"clientASName,required"` + Value string `json:"value,required"` + JSON httpAseGetResponseTop0JSON `json:"-"` +} + +// httpAseGetResponseTop0JSON contains the JSON metadata for the struct +// [HTTPAseGetResponseTop0] +type httpAseGetResponseTop0JSON struct { + ClientASN apijson.Field + ClientAsName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type HTTPAseGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPAseGetParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPAseGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPAseGetParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPAseGetParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPAseGetParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPAseGetParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPAseGetParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPAseGetParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPAseGetParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPAseGetParams]'s query parameters as `url.Values`. +func (r HTTPAseGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type HTTPAseGetParamsBotClass string + +const ( + HTTPAseGetParamsBotClassLikelyAutomated HTTPAseGetParamsBotClass = "LIKELY_AUTOMATED" + HTTPAseGetParamsBotClassLikelyHuman HTTPAseGetParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPAseGetParamsDateRange string + +const ( + HTTPAseGetParamsDateRange1d HTTPAseGetParamsDateRange = "1d" + HTTPAseGetParamsDateRange2d HTTPAseGetParamsDateRange = "2d" + HTTPAseGetParamsDateRange7d HTTPAseGetParamsDateRange = "7d" + HTTPAseGetParamsDateRange14d HTTPAseGetParamsDateRange = "14d" + HTTPAseGetParamsDateRange28d HTTPAseGetParamsDateRange = "28d" + HTTPAseGetParamsDateRange12w HTTPAseGetParamsDateRange = "12w" + HTTPAseGetParamsDateRange24w HTTPAseGetParamsDateRange = "24w" + HTTPAseGetParamsDateRange52w HTTPAseGetParamsDateRange = "52w" + HTTPAseGetParamsDateRange1dControl HTTPAseGetParamsDateRange = "1dControl" + HTTPAseGetParamsDateRange2dControl HTTPAseGetParamsDateRange = "2dControl" + HTTPAseGetParamsDateRange7dControl HTTPAseGetParamsDateRange = "7dControl" + HTTPAseGetParamsDateRange14dControl HTTPAseGetParamsDateRange = "14dControl" + HTTPAseGetParamsDateRange28dControl HTTPAseGetParamsDateRange = "28dControl" + HTTPAseGetParamsDateRange12wControl HTTPAseGetParamsDateRange = "12wControl" + HTTPAseGetParamsDateRange24wControl HTTPAseGetParamsDateRange = "24wControl" +) + +type HTTPAseGetParamsDeviceType string + +const ( + HTTPAseGetParamsDeviceTypeDesktop HTTPAseGetParamsDeviceType = "DESKTOP" + HTTPAseGetParamsDeviceTypeMobile HTTPAseGetParamsDeviceType = "MOBILE" + HTTPAseGetParamsDeviceTypeOther HTTPAseGetParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPAseGetParamsFormat string + +const ( + HTTPAseGetParamsFormatJson HTTPAseGetParamsFormat = "JSON" + HTTPAseGetParamsFormatCsv HTTPAseGetParamsFormat = "CSV" +) + +type HTTPAseGetParamsHTTPProtocol string + +const ( + HTTPAseGetParamsHTTPProtocolHTTP HTTPAseGetParamsHTTPProtocol = "HTTP" + HTTPAseGetParamsHTTPProtocolHTTPS HTTPAseGetParamsHTTPProtocol = "HTTPS" +) + +type HTTPAseGetParamsHTTPVersion string + +const ( + HTTPAseGetParamsHTTPVersionHttPv1 HTTPAseGetParamsHTTPVersion = "HTTPv1" + HTTPAseGetParamsHTTPVersionHttPv2 HTTPAseGetParamsHTTPVersion = "HTTPv2" + HTTPAseGetParamsHTTPVersionHttPv3 HTTPAseGetParamsHTTPVersion = "HTTPv3" +) + +type HTTPAseGetParamsIPVersion string + +const ( + HTTPAseGetParamsIPVersionIPv4 HTTPAseGetParamsIPVersion = "IPv4" + HTTPAseGetParamsIPVersionIPv6 HTTPAseGetParamsIPVersion = "IPv6" +) + +type HTTPAseGetParamsOS string + +const ( + HTTPAseGetParamsOSWindows HTTPAseGetParamsOS = "WINDOWS" + HTTPAseGetParamsOSMacosx HTTPAseGetParamsOS = "MACOSX" + HTTPAseGetParamsOSIos HTTPAseGetParamsOS = "IOS" + HTTPAseGetParamsOSAndroid HTTPAseGetParamsOS = "ANDROID" + HTTPAseGetParamsOSChromeos HTTPAseGetParamsOS = "CHROMEOS" + HTTPAseGetParamsOSLinux HTTPAseGetParamsOS = "LINUX" + HTTPAseGetParamsOSSmartTv HTTPAseGetParamsOS = "SMART_TV" +) + +type HTTPAseGetParamsTLSVersion string + +const ( + HTTPAseGetParamsTLSVersionTlSv1_0 HTTPAseGetParamsTLSVersion = "TLSv1_0" + HTTPAseGetParamsTLSVersionTlSv1_1 HTTPAseGetParamsTLSVersion = "TLSv1_1" + HTTPAseGetParamsTLSVersionTlSv1_2 HTTPAseGetParamsTLSVersion = "TLSv1_2" + HTTPAseGetParamsTLSVersionTlSv1_3 HTTPAseGetParamsTLSVersion = "TLSv1_3" + HTTPAseGetParamsTLSVersionTlSvQuic HTTPAseGetParamsTLSVersion = "TLSvQUIC" +) + +type HTTPAseGetResponseEnvelope struct { + Result HTTPAseGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpAseGetResponseEnvelopeJSON `json:"-"` +} + +// httpAseGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [HTTPAseGetResponseEnvelope] +type httpAseGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httpase_test.go b/radar/httpase_test.go new file mode 100644 index 00000000000..6d7ca8335c0 --- /dev/null +++ b/radar/httpase_test.go @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPAseGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Ases.Get(context.TODO(), radar.HTTPAseGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPAseGetParamsBotClass{radar.HTTPAseGetParamsBotClassLikelyAutomated, radar.HTTPAseGetParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPAseGetParamsDateRange{radar.HTTPAseGetParamsDateRange1d, radar.HTTPAseGetParamsDateRange2d, radar.HTTPAseGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPAseGetParamsDeviceType{radar.HTTPAseGetParamsDeviceTypeDesktop, radar.HTTPAseGetParamsDeviceTypeMobile, radar.HTTPAseGetParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPAseGetParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPAseGetParamsHTTPProtocol{radar.HTTPAseGetParamsHTTPProtocolHTTP, radar.HTTPAseGetParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPAseGetParamsHTTPVersion{radar.HTTPAseGetParamsHTTPVersionHttPv1, radar.HTTPAseGetParamsHTTPVersionHttPv2, radar.HTTPAseGetParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPAseGetParamsIPVersion{radar.HTTPAseGetParamsIPVersionIPv4, radar.HTTPAseGetParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPAseGetParamsOS{radar.HTTPAseGetParamsOSWindows, radar.HTTPAseGetParamsOSMacosx, radar.HTTPAseGetParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPAseGetParamsTLSVersion{radar.HTTPAseGetParamsTLSVersionTlSv1_0, radar.HTTPAseGetParamsTLSVersionTlSv1_1, radar.HTTPAseGetParamsTLSVersionTlSv1_2}), + }) + 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/radar/httpasebotclass.go b/radar/httpasebotclass.go new file mode 100644 index 00000000000..7102e32fcde --- /dev/null +++ b/radar/httpasebotclass.go @@ -0,0 +1,366 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPAseBotClassService 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 [NewHTTPAseBotClassService] method +// instead. +type HTTPAseBotClassService struct { + Options []option.RequestOption +} + +// NewHTTPAseBotClassService 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 NewHTTPAseBotClassService(opts ...option.RequestOption) (r *HTTPAseBotClassService) { + r = &HTTPAseBotClassService{} + r.Options = opts + return +} + +// Get the top autonomous systems (AS), by HTTP traffic, of the requested bot +// class. These two categories use Cloudflare's bot score - refer to +// [Bot Scores](https://developers.cloudflare.com/bots/concepts/bot-score) for more +// information. Values are a percentage out of the total traffic. +func (r *HTTPAseBotClassService) Get(ctx context.Context, botClass HTTPAseBotClassGetParamsBotClass, query HTTPAseBotClassGetParams, opts ...option.RequestOption) (res *HTTPAseBotClassGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPAseBotClassGetResponseEnvelope + path := fmt.Sprintf("radar/http/top/ases/bot_class/%v", botClass) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPAseBotClassGetResponse struct { + Meta HTTPAseBotClassGetResponseMeta `json:"meta,required"` + Top0 []HTTPAseBotClassGetResponseTop0 `json:"top_0,required"` + JSON httpAseBotClassGetResponseJSON `json:"-"` +} + +// httpAseBotClassGetResponseJSON contains the JSON metadata for the struct +// [HTTPAseBotClassGetResponse] +type httpAseBotClassGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseBotClassGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseBotClassGetResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPAseBotClassGetResponseMeta struct { + DateRange []HTTPAseBotClassGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo HTTPAseBotClassGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpAseBotClassGetResponseMetaJSON `json:"-"` +} + +// httpAseBotClassGetResponseMetaJSON contains the JSON metadata for the struct +// [HTTPAseBotClassGetResponseMeta] +type httpAseBotClassGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseBotClassGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseBotClassGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPAseBotClassGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpAseBotClassGetResponseMetaDateRangeJSON `json:"-"` +} + +// httpAseBotClassGetResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [HTTPAseBotClassGetResponseMetaDateRange] +type httpAseBotClassGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseBotClassGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseBotClassGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPAseBotClassGetResponseMetaConfidenceInfo struct { + Annotations []HTTPAseBotClassGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpAseBotClassGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpAseBotClassGetResponseMetaConfidenceInfoJSON contains the JSON metadata for +// the struct [HTTPAseBotClassGetResponseMetaConfidenceInfo] +type httpAseBotClassGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseBotClassGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseBotClassGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPAseBotClassGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpAseBotClassGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpAseBotClassGetResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct [HTTPAseBotClassGetResponseMetaConfidenceInfoAnnotation] +type httpAseBotClassGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseBotClassGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseBotClassGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPAseBotClassGetResponseTop0 struct { + ClientASN int64 `json:"clientASN,required"` + ClientAsName string `json:"clientASName,required"` + Value string `json:"value,required"` + JSON httpAseBotClassGetResponseTop0JSON `json:"-"` +} + +// httpAseBotClassGetResponseTop0JSON contains the JSON metadata for the struct +// [HTTPAseBotClassGetResponseTop0] +type httpAseBotClassGetResponseTop0JSON struct { + ClientASN apijson.Field + ClientAsName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseBotClassGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseBotClassGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type HTTPAseBotClassGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPAseBotClassGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPAseBotClassGetParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPAseBotClassGetParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPAseBotClassGetParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPAseBotClassGetParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPAseBotClassGetParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPAseBotClassGetParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPAseBotClassGetParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPAseBotClassGetParams]'s query parameters as +// `url.Values`. +func (r HTTPAseBotClassGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Bot class. +type HTTPAseBotClassGetParamsBotClass string + +const ( + HTTPAseBotClassGetParamsBotClassLikelyAutomated HTTPAseBotClassGetParamsBotClass = "LIKELY_AUTOMATED" + HTTPAseBotClassGetParamsBotClassLikelyHuman HTTPAseBotClassGetParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPAseBotClassGetParamsDateRange string + +const ( + HTTPAseBotClassGetParamsDateRange1d HTTPAseBotClassGetParamsDateRange = "1d" + HTTPAseBotClassGetParamsDateRange2d HTTPAseBotClassGetParamsDateRange = "2d" + HTTPAseBotClassGetParamsDateRange7d HTTPAseBotClassGetParamsDateRange = "7d" + HTTPAseBotClassGetParamsDateRange14d HTTPAseBotClassGetParamsDateRange = "14d" + HTTPAseBotClassGetParamsDateRange28d HTTPAseBotClassGetParamsDateRange = "28d" + HTTPAseBotClassGetParamsDateRange12w HTTPAseBotClassGetParamsDateRange = "12w" + HTTPAseBotClassGetParamsDateRange24w HTTPAseBotClassGetParamsDateRange = "24w" + HTTPAseBotClassGetParamsDateRange52w HTTPAseBotClassGetParamsDateRange = "52w" + HTTPAseBotClassGetParamsDateRange1dControl HTTPAseBotClassGetParamsDateRange = "1dControl" + HTTPAseBotClassGetParamsDateRange2dControl HTTPAseBotClassGetParamsDateRange = "2dControl" + HTTPAseBotClassGetParamsDateRange7dControl HTTPAseBotClassGetParamsDateRange = "7dControl" + HTTPAseBotClassGetParamsDateRange14dControl HTTPAseBotClassGetParamsDateRange = "14dControl" + HTTPAseBotClassGetParamsDateRange28dControl HTTPAseBotClassGetParamsDateRange = "28dControl" + HTTPAseBotClassGetParamsDateRange12wControl HTTPAseBotClassGetParamsDateRange = "12wControl" + HTTPAseBotClassGetParamsDateRange24wControl HTTPAseBotClassGetParamsDateRange = "24wControl" +) + +type HTTPAseBotClassGetParamsDeviceType string + +const ( + HTTPAseBotClassGetParamsDeviceTypeDesktop HTTPAseBotClassGetParamsDeviceType = "DESKTOP" + HTTPAseBotClassGetParamsDeviceTypeMobile HTTPAseBotClassGetParamsDeviceType = "MOBILE" + HTTPAseBotClassGetParamsDeviceTypeOther HTTPAseBotClassGetParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPAseBotClassGetParamsFormat string + +const ( + HTTPAseBotClassGetParamsFormatJson HTTPAseBotClassGetParamsFormat = "JSON" + HTTPAseBotClassGetParamsFormatCsv HTTPAseBotClassGetParamsFormat = "CSV" +) + +type HTTPAseBotClassGetParamsHTTPProtocol string + +const ( + HTTPAseBotClassGetParamsHTTPProtocolHTTP HTTPAseBotClassGetParamsHTTPProtocol = "HTTP" + HTTPAseBotClassGetParamsHTTPProtocolHTTPS HTTPAseBotClassGetParamsHTTPProtocol = "HTTPS" +) + +type HTTPAseBotClassGetParamsHTTPVersion string + +const ( + HTTPAseBotClassGetParamsHTTPVersionHttPv1 HTTPAseBotClassGetParamsHTTPVersion = "HTTPv1" + HTTPAseBotClassGetParamsHTTPVersionHttPv2 HTTPAseBotClassGetParamsHTTPVersion = "HTTPv2" + HTTPAseBotClassGetParamsHTTPVersionHttPv3 HTTPAseBotClassGetParamsHTTPVersion = "HTTPv3" +) + +type HTTPAseBotClassGetParamsIPVersion string + +const ( + HTTPAseBotClassGetParamsIPVersionIPv4 HTTPAseBotClassGetParamsIPVersion = "IPv4" + HTTPAseBotClassGetParamsIPVersionIPv6 HTTPAseBotClassGetParamsIPVersion = "IPv6" +) + +type HTTPAseBotClassGetParamsOS string + +const ( + HTTPAseBotClassGetParamsOSWindows HTTPAseBotClassGetParamsOS = "WINDOWS" + HTTPAseBotClassGetParamsOSMacosx HTTPAseBotClassGetParamsOS = "MACOSX" + HTTPAseBotClassGetParamsOSIos HTTPAseBotClassGetParamsOS = "IOS" + HTTPAseBotClassGetParamsOSAndroid HTTPAseBotClassGetParamsOS = "ANDROID" + HTTPAseBotClassGetParamsOSChromeos HTTPAseBotClassGetParamsOS = "CHROMEOS" + HTTPAseBotClassGetParamsOSLinux HTTPAseBotClassGetParamsOS = "LINUX" + HTTPAseBotClassGetParamsOSSmartTv HTTPAseBotClassGetParamsOS = "SMART_TV" +) + +type HTTPAseBotClassGetParamsTLSVersion string + +const ( + HTTPAseBotClassGetParamsTLSVersionTlSv1_0 HTTPAseBotClassGetParamsTLSVersion = "TLSv1_0" + HTTPAseBotClassGetParamsTLSVersionTlSv1_1 HTTPAseBotClassGetParamsTLSVersion = "TLSv1_1" + HTTPAseBotClassGetParamsTLSVersionTlSv1_2 HTTPAseBotClassGetParamsTLSVersion = "TLSv1_2" + HTTPAseBotClassGetParamsTLSVersionTlSv1_3 HTTPAseBotClassGetParamsTLSVersion = "TLSv1_3" + HTTPAseBotClassGetParamsTLSVersionTlSvQuic HTTPAseBotClassGetParamsTLSVersion = "TLSvQUIC" +) + +type HTTPAseBotClassGetResponseEnvelope struct { + Result HTTPAseBotClassGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpAseBotClassGetResponseEnvelopeJSON `json:"-"` +} + +// httpAseBotClassGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [HTTPAseBotClassGetResponseEnvelope] +type httpAseBotClassGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseBotClassGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseBotClassGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httpasebotclass_test.go b/radar/httpasebotclass_test.go new file mode 100644 index 00000000000..7a2a059a8e1 --- /dev/null +++ b/radar/httpasebotclass_test.go @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPAseBotClassGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Ases.BotClass.Get( + context.TODO(), + radar.HTTPAseBotClassGetParamsBotClassLikelyAutomated, + radar.HTTPAseBotClassGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPAseBotClassGetParamsDateRange{radar.HTTPAseBotClassGetParamsDateRange1d, radar.HTTPAseBotClassGetParamsDateRange2d, radar.HTTPAseBotClassGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPAseBotClassGetParamsDeviceType{radar.HTTPAseBotClassGetParamsDeviceTypeDesktop, radar.HTTPAseBotClassGetParamsDeviceTypeMobile, radar.HTTPAseBotClassGetParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPAseBotClassGetParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPAseBotClassGetParamsHTTPProtocol{radar.HTTPAseBotClassGetParamsHTTPProtocolHTTP, radar.HTTPAseBotClassGetParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPAseBotClassGetParamsHTTPVersion{radar.HTTPAseBotClassGetParamsHTTPVersionHttPv1, radar.HTTPAseBotClassGetParamsHTTPVersionHttPv2, radar.HTTPAseBotClassGetParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPAseBotClassGetParamsIPVersion{radar.HTTPAseBotClassGetParamsIPVersionIPv4, radar.HTTPAseBotClassGetParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPAseBotClassGetParamsOS{radar.HTTPAseBotClassGetParamsOSWindows, radar.HTTPAseBotClassGetParamsOSMacosx, radar.HTTPAseBotClassGetParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPAseBotClassGetParamsTLSVersion{radar.HTTPAseBotClassGetParamsTLSVersionTlSv1_0, radar.HTTPAseBotClassGetParamsTLSVersionTlSv1_1, radar.HTTPAseBotClassGetParamsTLSVersionTlSv1_2}), + }, + ) + 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/radar/httpasedevicetype.go b/radar/httpasedevicetype.go new file mode 100644 index 00000000000..f72f613eadd --- /dev/null +++ b/radar/httpasedevicetype.go @@ -0,0 +1,366 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPAseDeviceTypeService 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 [NewHTTPAseDeviceTypeService] method +// instead. +type HTTPAseDeviceTypeService struct { + Options []option.RequestOption +} + +// NewHTTPAseDeviceTypeService 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 NewHTTPAseDeviceTypeService(opts ...option.RequestOption) (r *HTTPAseDeviceTypeService) { + r = &HTTPAseDeviceTypeService{} + r.Options = opts + return +} + +// Get the top autonomous systems (AS), by HTTP traffic, of the requested device +// type. Values are a percentage out of the total traffic. +func (r *HTTPAseDeviceTypeService) Get(ctx context.Context, deviceType HTTPAseDeviceTypeGetParamsDeviceType, query HTTPAseDeviceTypeGetParams, opts ...option.RequestOption) (res *HTTPAseDeviceTypeGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPAseDeviceTypeGetResponseEnvelope + path := fmt.Sprintf("radar/http/top/ases/device_type/%v", deviceType) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPAseDeviceTypeGetResponse struct { + Meta HTTPAseDeviceTypeGetResponseMeta `json:"meta,required"` + Top0 []HTTPAseDeviceTypeGetResponseTop0 `json:"top_0,required"` + JSON httpAseDeviceTypeGetResponseJSON `json:"-"` +} + +// httpAseDeviceTypeGetResponseJSON contains the JSON metadata for the struct +// [HTTPAseDeviceTypeGetResponse] +type httpAseDeviceTypeGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseDeviceTypeGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseDeviceTypeGetResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPAseDeviceTypeGetResponseMeta struct { + DateRange []HTTPAseDeviceTypeGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo HTTPAseDeviceTypeGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpAseDeviceTypeGetResponseMetaJSON `json:"-"` +} + +// httpAseDeviceTypeGetResponseMetaJSON contains the JSON metadata for the struct +// [HTTPAseDeviceTypeGetResponseMeta] +type httpAseDeviceTypeGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseDeviceTypeGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseDeviceTypeGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPAseDeviceTypeGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpAseDeviceTypeGetResponseMetaDateRangeJSON `json:"-"` +} + +// httpAseDeviceTypeGetResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [HTTPAseDeviceTypeGetResponseMetaDateRange] +type httpAseDeviceTypeGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseDeviceTypeGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseDeviceTypeGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPAseDeviceTypeGetResponseMetaConfidenceInfo struct { + Annotations []HTTPAseDeviceTypeGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpAseDeviceTypeGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpAseDeviceTypeGetResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [HTTPAseDeviceTypeGetResponseMetaConfidenceInfo] +type httpAseDeviceTypeGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseDeviceTypeGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseDeviceTypeGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPAseDeviceTypeGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpAseDeviceTypeGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpAseDeviceTypeGetResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [HTTPAseDeviceTypeGetResponseMetaConfidenceInfoAnnotation] +type httpAseDeviceTypeGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseDeviceTypeGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseDeviceTypeGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPAseDeviceTypeGetResponseTop0 struct { + ClientASN int64 `json:"clientASN,required"` + ClientAsName string `json:"clientASName,required"` + Value string `json:"value,required"` + JSON httpAseDeviceTypeGetResponseTop0JSON `json:"-"` +} + +// httpAseDeviceTypeGetResponseTop0JSON contains the JSON metadata for the struct +// [HTTPAseDeviceTypeGetResponseTop0] +type httpAseDeviceTypeGetResponseTop0JSON struct { + ClientASN apijson.Field + ClientAsName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseDeviceTypeGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseDeviceTypeGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type HTTPAseDeviceTypeGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPAseDeviceTypeGetParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPAseDeviceTypeGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[HTTPAseDeviceTypeGetParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPAseDeviceTypeGetParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPAseDeviceTypeGetParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPAseDeviceTypeGetParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPAseDeviceTypeGetParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPAseDeviceTypeGetParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPAseDeviceTypeGetParams]'s query parameters as +// `url.Values`. +func (r HTTPAseDeviceTypeGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Device type. +type HTTPAseDeviceTypeGetParamsDeviceType string + +const ( + HTTPAseDeviceTypeGetParamsDeviceTypeDesktop HTTPAseDeviceTypeGetParamsDeviceType = "DESKTOP" + HTTPAseDeviceTypeGetParamsDeviceTypeMobile HTTPAseDeviceTypeGetParamsDeviceType = "MOBILE" + HTTPAseDeviceTypeGetParamsDeviceTypeOther HTTPAseDeviceTypeGetParamsDeviceType = "OTHER" +) + +type HTTPAseDeviceTypeGetParamsBotClass string + +const ( + HTTPAseDeviceTypeGetParamsBotClassLikelyAutomated HTTPAseDeviceTypeGetParamsBotClass = "LIKELY_AUTOMATED" + HTTPAseDeviceTypeGetParamsBotClassLikelyHuman HTTPAseDeviceTypeGetParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPAseDeviceTypeGetParamsDateRange string + +const ( + HTTPAseDeviceTypeGetParamsDateRange1d HTTPAseDeviceTypeGetParamsDateRange = "1d" + HTTPAseDeviceTypeGetParamsDateRange2d HTTPAseDeviceTypeGetParamsDateRange = "2d" + HTTPAseDeviceTypeGetParamsDateRange7d HTTPAseDeviceTypeGetParamsDateRange = "7d" + HTTPAseDeviceTypeGetParamsDateRange14d HTTPAseDeviceTypeGetParamsDateRange = "14d" + HTTPAseDeviceTypeGetParamsDateRange28d HTTPAseDeviceTypeGetParamsDateRange = "28d" + HTTPAseDeviceTypeGetParamsDateRange12w HTTPAseDeviceTypeGetParamsDateRange = "12w" + HTTPAseDeviceTypeGetParamsDateRange24w HTTPAseDeviceTypeGetParamsDateRange = "24w" + HTTPAseDeviceTypeGetParamsDateRange52w HTTPAseDeviceTypeGetParamsDateRange = "52w" + HTTPAseDeviceTypeGetParamsDateRange1dControl HTTPAseDeviceTypeGetParamsDateRange = "1dControl" + HTTPAseDeviceTypeGetParamsDateRange2dControl HTTPAseDeviceTypeGetParamsDateRange = "2dControl" + HTTPAseDeviceTypeGetParamsDateRange7dControl HTTPAseDeviceTypeGetParamsDateRange = "7dControl" + HTTPAseDeviceTypeGetParamsDateRange14dControl HTTPAseDeviceTypeGetParamsDateRange = "14dControl" + HTTPAseDeviceTypeGetParamsDateRange28dControl HTTPAseDeviceTypeGetParamsDateRange = "28dControl" + HTTPAseDeviceTypeGetParamsDateRange12wControl HTTPAseDeviceTypeGetParamsDateRange = "12wControl" + HTTPAseDeviceTypeGetParamsDateRange24wControl HTTPAseDeviceTypeGetParamsDateRange = "24wControl" +) + +// Format results are returned in. +type HTTPAseDeviceTypeGetParamsFormat string + +const ( + HTTPAseDeviceTypeGetParamsFormatJson HTTPAseDeviceTypeGetParamsFormat = "JSON" + HTTPAseDeviceTypeGetParamsFormatCsv HTTPAseDeviceTypeGetParamsFormat = "CSV" +) + +type HTTPAseDeviceTypeGetParamsHTTPProtocol string + +const ( + HTTPAseDeviceTypeGetParamsHTTPProtocolHTTP HTTPAseDeviceTypeGetParamsHTTPProtocol = "HTTP" + HTTPAseDeviceTypeGetParamsHTTPProtocolHTTPS HTTPAseDeviceTypeGetParamsHTTPProtocol = "HTTPS" +) + +type HTTPAseDeviceTypeGetParamsHTTPVersion string + +const ( + HTTPAseDeviceTypeGetParamsHTTPVersionHttPv1 HTTPAseDeviceTypeGetParamsHTTPVersion = "HTTPv1" + HTTPAseDeviceTypeGetParamsHTTPVersionHttPv2 HTTPAseDeviceTypeGetParamsHTTPVersion = "HTTPv2" + HTTPAseDeviceTypeGetParamsHTTPVersionHttPv3 HTTPAseDeviceTypeGetParamsHTTPVersion = "HTTPv3" +) + +type HTTPAseDeviceTypeGetParamsIPVersion string + +const ( + HTTPAseDeviceTypeGetParamsIPVersionIPv4 HTTPAseDeviceTypeGetParamsIPVersion = "IPv4" + HTTPAseDeviceTypeGetParamsIPVersionIPv6 HTTPAseDeviceTypeGetParamsIPVersion = "IPv6" +) + +type HTTPAseDeviceTypeGetParamsOS string + +const ( + HTTPAseDeviceTypeGetParamsOSWindows HTTPAseDeviceTypeGetParamsOS = "WINDOWS" + HTTPAseDeviceTypeGetParamsOSMacosx HTTPAseDeviceTypeGetParamsOS = "MACOSX" + HTTPAseDeviceTypeGetParamsOSIos HTTPAseDeviceTypeGetParamsOS = "IOS" + HTTPAseDeviceTypeGetParamsOSAndroid HTTPAseDeviceTypeGetParamsOS = "ANDROID" + HTTPAseDeviceTypeGetParamsOSChromeos HTTPAseDeviceTypeGetParamsOS = "CHROMEOS" + HTTPAseDeviceTypeGetParamsOSLinux HTTPAseDeviceTypeGetParamsOS = "LINUX" + HTTPAseDeviceTypeGetParamsOSSmartTv HTTPAseDeviceTypeGetParamsOS = "SMART_TV" +) + +type HTTPAseDeviceTypeGetParamsTLSVersion string + +const ( + HTTPAseDeviceTypeGetParamsTLSVersionTlSv1_0 HTTPAseDeviceTypeGetParamsTLSVersion = "TLSv1_0" + HTTPAseDeviceTypeGetParamsTLSVersionTlSv1_1 HTTPAseDeviceTypeGetParamsTLSVersion = "TLSv1_1" + HTTPAseDeviceTypeGetParamsTLSVersionTlSv1_2 HTTPAseDeviceTypeGetParamsTLSVersion = "TLSv1_2" + HTTPAseDeviceTypeGetParamsTLSVersionTlSv1_3 HTTPAseDeviceTypeGetParamsTLSVersion = "TLSv1_3" + HTTPAseDeviceTypeGetParamsTLSVersionTlSvQuic HTTPAseDeviceTypeGetParamsTLSVersion = "TLSvQUIC" +) + +type HTTPAseDeviceTypeGetResponseEnvelope struct { + Result HTTPAseDeviceTypeGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpAseDeviceTypeGetResponseEnvelopeJSON `json:"-"` +} + +// httpAseDeviceTypeGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [HTTPAseDeviceTypeGetResponseEnvelope] +type httpAseDeviceTypeGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseDeviceTypeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseDeviceTypeGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httpasedevicetype_test.go b/radar/httpasedevicetype_test.go new file mode 100644 index 00000000000..db94d051b20 --- /dev/null +++ b/radar/httpasedevicetype_test.go @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPAseDeviceTypeGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Ases.DeviceType.Get( + context.TODO(), + radar.HTTPAseDeviceTypeGetParamsDeviceTypeDesktop, + radar.HTTPAseDeviceTypeGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPAseDeviceTypeGetParamsBotClass{radar.HTTPAseDeviceTypeGetParamsBotClassLikelyAutomated, radar.HTTPAseDeviceTypeGetParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPAseDeviceTypeGetParamsDateRange{radar.HTTPAseDeviceTypeGetParamsDateRange1d, radar.HTTPAseDeviceTypeGetParamsDateRange2d, radar.HTTPAseDeviceTypeGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.HTTPAseDeviceTypeGetParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPAseDeviceTypeGetParamsHTTPProtocol{radar.HTTPAseDeviceTypeGetParamsHTTPProtocolHTTP, radar.HTTPAseDeviceTypeGetParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPAseDeviceTypeGetParamsHTTPVersion{radar.HTTPAseDeviceTypeGetParamsHTTPVersionHttPv1, radar.HTTPAseDeviceTypeGetParamsHTTPVersionHttPv2, radar.HTTPAseDeviceTypeGetParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPAseDeviceTypeGetParamsIPVersion{radar.HTTPAseDeviceTypeGetParamsIPVersionIPv4, radar.HTTPAseDeviceTypeGetParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPAseDeviceTypeGetParamsOS{radar.HTTPAseDeviceTypeGetParamsOSWindows, radar.HTTPAseDeviceTypeGetParamsOSMacosx, radar.HTTPAseDeviceTypeGetParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPAseDeviceTypeGetParamsTLSVersion{radar.HTTPAseDeviceTypeGetParamsTLSVersionTlSv1_0, radar.HTTPAseDeviceTypeGetParamsTLSVersionTlSv1_1, radar.HTTPAseDeviceTypeGetParamsTLSVersionTlSv1_2}), + }, + ) + 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/radar/httpasehttpmethod.go b/radar/httpasehttpmethod.go new file mode 100644 index 00000000000..8032c4ba823 --- /dev/null +++ b/radar/httpasehttpmethod.go @@ -0,0 +1,366 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPAseHTTPMethodService 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 [NewHTTPAseHTTPMethodService] method +// instead. +type HTTPAseHTTPMethodService struct { + Options []option.RequestOption +} + +// NewHTTPAseHTTPMethodService 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 NewHTTPAseHTTPMethodService(opts ...option.RequestOption) (r *HTTPAseHTTPMethodService) { + r = &HTTPAseHTTPMethodService{} + r.Options = opts + return +} + +// Get the top autonomous systems (AS), by HTTP traffic, of the requested HTTP +// protocol version. Values are a percentage out of the total traffic. +func (r *HTTPAseHTTPMethodService) Get(ctx context.Context, httpVersion HTTPAseHTTPMethodGetParamsHTTPVersion, query HTTPAseHTTPMethodGetParams, opts ...option.RequestOption) (res *HTTPAseHTTPMethodGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPAseHTTPMethodGetResponseEnvelope + path := fmt.Sprintf("radar/http/top/ases/http_version/%v", httpVersion) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPAseHTTPMethodGetResponse struct { + Meta HTTPAseHTTPMethodGetResponseMeta `json:"meta,required"` + Top0 []HTTPAseHTTPMethodGetResponseTop0 `json:"top_0,required"` + JSON httpAseHTTPMethodGetResponseJSON `json:"-"` +} + +// httpAseHTTPMethodGetResponseJSON contains the JSON metadata for the struct +// [HTTPAseHTTPMethodGetResponse] +type httpAseHTTPMethodGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseHTTPMethodGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseHTTPMethodGetResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPAseHTTPMethodGetResponseMeta struct { + DateRange []HTTPAseHTTPMethodGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo HTTPAseHTTPMethodGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpAseHTTPMethodGetResponseMetaJSON `json:"-"` +} + +// httpAseHTTPMethodGetResponseMetaJSON contains the JSON metadata for the struct +// [HTTPAseHTTPMethodGetResponseMeta] +type httpAseHTTPMethodGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseHTTPMethodGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseHTTPMethodGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPAseHTTPMethodGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpAseHTTPMethodGetResponseMetaDateRangeJSON `json:"-"` +} + +// httpAseHTTPMethodGetResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [HTTPAseHTTPMethodGetResponseMetaDateRange] +type httpAseHTTPMethodGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseHTTPMethodGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseHTTPMethodGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPAseHTTPMethodGetResponseMetaConfidenceInfo struct { + Annotations []HTTPAseHTTPMethodGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpAseHTTPMethodGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpAseHTTPMethodGetResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [HTTPAseHTTPMethodGetResponseMetaConfidenceInfo] +type httpAseHTTPMethodGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseHTTPMethodGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseHTTPMethodGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPAseHTTPMethodGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpAseHTTPMethodGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpAseHTTPMethodGetResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [HTTPAseHTTPMethodGetResponseMetaConfidenceInfoAnnotation] +type httpAseHTTPMethodGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseHTTPMethodGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseHTTPMethodGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPAseHTTPMethodGetResponseTop0 struct { + ClientASN int64 `json:"clientASN,required"` + ClientAsName string `json:"clientASName,required"` + Value string `json:"value,required"` + JSON httpAseHTTPMethodGetResponseTop0JSON `json:"-"` +} + +// httpAseHTTPMethodGetResponseTop0JSON contains the JSON metadata for the struct +// [HTTPAseHTTPMethodGetResponseTop0] +type httpAseHTTPMethodGetResponseTop0JSON struct { + ClientASN apijson.Field + ClientAsName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseHTTPMethodGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseHTTPMethodGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type HTTPAseHTTPMethodGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPAseHTTPMethodGetParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPAseHTTPMethodGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPAseHTTPMethodGetParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPAseHTTPMethodGetParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPAseHTTPMethodGetParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for ip version. + IPVersion param.Field[[]HTTPAseHTTPMethodGetParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPAseHTTPMethodGetParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPAseHTTPMethodGetParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPAseHTTPMethodGetParams]'s query parameters as +// `url.Values`. +func (r HTTPAseHTTPMethodGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// HTTP version. +type HTTPAseHTTPMethodGetParamsHTTPVersion string + +const ( + HTTPAseHTTPMethodGetParamsHTTPVersionHttPv1 HTTPAseHTTPMethodGetParamsHTTPVersion = "HTTPv1" + HTTPAseHTTPMethodGetParamsHTTPVersionHttPv2 HTTPAseHTTPMethodGetParamsHTTPVersion = "HTTPv2" + HTTPAseHTTPMethodGetParamsHTTPVersionHttPv3 HTTPAseHTTPMethodGetParamsHTTPVersion = "HTTPv3" +) + +type HTTPAseHTTPMethodGetParamsBotClass string + +const ( + HTTPAseHTTPMethodGetParamsBotClassLikelyAutomated HTTPAseHTTPMethodGetParamsBotClass = "LIKELY_AUTOMATED" + HTTPAseHTTPMethodGetParamsBotClassLikelyHuman HTTPAseHTTPMethodGetParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPAseHTTPMethodGetParamsDateRange string + +const ( + HTTPAseHTTPMethodGetParamsDateRange1d HTTPAseHTTPMethodGetParamsDateRange = "1d" + HTTPAseHTTPMethodGetParamsDateRange2d HTTPAseHTTPMethodGetParamsDateRange = "2d" + HTTPAseHTTPMethodGetParamsDateRange7d HTTPAseHTTPMethodGetParamsDateRange = "7d" + HTTPAseHTTPMethodGetParamsDateRange14d HTTPAseHTTPMethodGetParamsDateRange = "14d" + HTTPAseHTTPMethodGetParamsDateRange28d HTTPAseHTTPMethodGetParamsDateRange = "28d" + HTTPAseHTTPMethodGetParamsDateRange12w HTTPAseHTTPMethodGetParamsDateRange = "12w" + HTTPAseHTTPMethodGetParamsDateRange24w HTTPAseHTTPMethodGetParamsDateRange = "24w" + HTTPAseHTTPMethodGetParamsDateRange52w HTTPAseHTTPMethodGetParamsDateRange = "52w" + HTTPAseHTTPMethodGetParamsDateRange1dControl HTTPAseHTTPMethodGetParamsDateRange = "1dControl" + HTTPAseHTTPMethodGetParamsDateRange2dControl HTTPAseHTTPMethodGetParamsDateRange = "2dControl" + HTTPAseHTTPMethodGetParamsDateRange7dControl HTTPAseHTTPMethodGetParamsDateRange = "7dControl" + HTTPAseHTTPMethodGetParamsDateRange14dControl HTTPAseHTTPMethodGetParamsDateRange = "14dControl" + HTTPAseHTTPMethodGetParamsDateRange28dControl HTTPAseHTTPMethodGetParamsDateRange = "28dControl" + HTTPAseHTTPMethodGetParamsDateRange12wControl HTTPAseHTTPMethodGetParamsDateRange = "12wControl" + HTTPAseHTTPMethodGetParamsDateRange24wControl HTTPAseHTTPMethodGetParamsDateRange = "24wControl" +) + +type HTTPAseHTTPMethodGetParamsDeviceType string + +const ( + HTTPAseHTTPMethodGetParamsDeviceTypeDesktop HTTPAseHTTPMethodGetParamsDeviceType = "DESKTOP" + HTTPAseHTTPMethodGetParamsDeviceTypeMobile HTTPAseHTTPMethodGetParamsDeviceType = "MOBILE" + HTTPAseHTTPMethodGetParamsDeviceTypeOther HTTPAseHTTPMethodGetParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPAseHTTPMethodGetParamsFormat string + +const ( + HTTPAseHTTPMethodGetParamsFormatJson HTTPAseHTTPMethodGetParamsFormat = "JSON" + HTTPAseHTTPMethodGetParamsFormatCsv HTTPAseHTTPMethodGetParamsFormat = "CSV" +) + +type HTTPAseHTTPMethodGetParamsHTTPProtocol string + +const ( + HTTPAseHTTPMethodGetParamsHTTPProtocolHTTP HTTPAseHTTPMethodGetParamsHTTPProtocol = "HTTP" + HTTPAseHTTPMethodGetParamsHTTPProtocolHTTPS HTTPAseHTTPMethodGetParamsHTTPProtocol = "HTTPS" +) + +type HTTPAseHTTPMethodGetParamsIPVersion string + +const ( + HTTPAseHTTPMethodGetParamsIPVersionIPv4 HTTPAseHTTPMethodGetParamsIPVersion = "IPv4" + HTTPAseHTTPMethodGetParamsIPVersionIPv6 HTTPAseHTTPMethodGetParamsIPVersion = "IPv6" +) + +type HTTPAseHTTPMethodGetParamsOS string + +const ( + HTTPAseHTTPMethodGetParamsOSWindows HTTPAseHTTPMethodGetParamsOS = "WINDOWS" + HTTPAseHTTPMethodGetParamsOSMacosx HTTPAseHTTPMethodGetParamsOS = "MACOSX" + HTTPAseHTTPMethodGetParamsOSIos HTTPAseHTTPMethodGetParamsOS = "IOS" + HTTPAseHTTPMethodGetParamsOSAndroid HTTPAseHTTPMethodGetParamsOS = "ANDROID" + HTTPAseHTTPMethodGetParamsOSChromeos HTTPAseHTTPMethodGetParamsOS = "CHROMEOS" + HTTPAseHTTPMethodGetParamsOSLinux HTTPAseHTTPMethodGetParamsOS = "LINUX" + HTTPAseHTTPMethodGetParamsOSSmartTv HTTPAseHTTPMethodGetParamsOS = "SMART_TV" +) + +type HTTPAseHTTPMethodGetParamsTLSVersion string + +const ( + HTTPAseHTTPMethodGetParamsTLSVersionTlSv1_0 HTTPAseHTTPMethodGetParamsTLSVersion = "TLSv1_0" + HTTPAseHTTPMethodGetParamsTLSVersionTlSv1_1 HTTPAseHTTPMethodGetParamsTLSVersion = "TLSv1_1" + HTTPAseHTTPMethodGetParamsTLSVersionTlSv1_2 HTTPAseHTTPMethodGetParamsTLSVersion = "TLSv1_2" + HTTPAseHTTPMethodGetParamsTLSVersionTlSv1_3 HTTPAseHTTPMethodGetParamsTLSVersion = "TLSv1_3" + HTTPAseHTTPMethodGetParamsTLSVersionTlSvQuic HTTPAseHTTPMethodGetParamsTLSVersion = "TLSvQUIC" +) + +type HTTPAseHTTPMethodGetResponseEnvelope struct { + Result HTTPAseHTTPMethodGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpAseHTTPMethodGetResponseEnvelopeJSON `json:"-"` +} + +// httpAseHTTPMethodGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [HTTPAseHTTPMethodGetResponseEnvelope] +type httpAseHTTPMethodGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseHTTPMethodGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseHTTPMethodGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httpasehttpmethod_test.go b/radar/httpasehttpmethod_test.go new file mode 100644 index 00000000000..cd8908b8013 --- /dev/null +++ b/radar/httpasehttpmethod_test.go @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPAseHTTPMethodGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Ases.HTTPMethod.Get( + context.TODO(), + radar.HTTPAseHTTPMethodGetParamsHTTPVersionHttPv1, + radar.HTTPAseHTTPMethodGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPAseHTTPMethodGetParamsBotClass{radar.HTTPAseHTTPMethodGetParamsBotClassLikelyAutomated, radar.HTTPAseHTTPMethodGetParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPAseHTTPMethodGetParamsDateRange{radar.HTTPAseHTTPMethodGetParamsDateRange1d, radar.HTTPAseHTTPMethodGetParamsDateRange2d, radar.HTTPAseHTTPMethodGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPAseHTTPMethodGetParamsDeviceType{radar.HTTPAseHTTPMethodGetParamsDeviceTypeDesktop, radar.HTTPAseHTTPMethodGetParamsDeviceTypeMobile, radar.HTTPAseHTTPMethodGetParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPAseHTTPMethodGetParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPAseHTTPMethodGetParamsHTTPProtocol{radar.HTTPAseHTTPMethodGetParamsHTTPProtocolHTTP, radar.HTTPAseHTTPMethodGetParamsHTTPProtocolHTTPS}), + IPVersion: cloudflare.F([]radar.HTTPAseHTTPMethodGetParamsIPVersion{radar.HTTPAseHTTPMethodGetParamsIPVersionIPv4, radar.HTTPAseHTTPMethodGetParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPAseHTTPMethodGetParamsOS{radar.HTTPAseHTTPMethodGetParamsOSWindows, radar.HTTPAseHTTPMethodGetParamsOSMacosx, radar.HTTPAseHTTPMethodGetParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPAseHTTPMethodGetParamsTLSVersion{radar.HTTPAseHTTPMethodGetParamsTLSVersionTlSv1_0, radar.HTTPAseHTTPMethodGetParamsTLSVersionTlSv1_1, radar.HTTPAseHTTPMethodGetParamsTLSVersionTlSv1_2}), + }, + ) + 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/radar/httpasehttpprotocol.go b/radar/httpasehttpprotocol.go new file mode 100644 index 00000000000..db9cdc48324 --- /dev/null +++ b/radar/httpasehttpprotocol.go @@ -0,0 +1,356 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPAseHTTPProtocolService 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 [NewHTTPAseHTTPProtocolService] +// method instead. +type HTTPAseHTTPProtocolService struct { + Options []option.RequestOption +} + +// NewHTTPAseHTTPProtocolService 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 NewHTTPAseHTTPProtocolService(opts ...option.RequestOption) (r *HTTPAseHTTPProtocolService) { + r = &HTTPAseHTTPProtocolService{} + r.Options = opts + return +} + +// Get the top autonomous systems (AS), by HTTP traffic, of the requested HTTP +// protocol. Values are a percentage out of the total traffic. +func (r *HTTPAseHTTPProtocolService) Get(ctx context.Context, httpProtocol HTTPAseHTTPProtocolGetParamsHTTPProtocol, query HTTPAseHTTPProtocolGetParams, opts ...option.RequestOption) (res *HTTPAseHTTPProtocolGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPAseHTTPProtocolGetResponseEnvelope + path := fmt.Sprintf("radar/http/top/ases/http_protocol/%v", httpProtocol) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPAseHTTPProtocolGetResponse struct { + Meta HTTPAseHTTPProtocolGetResponseMeta `json:"meta,required"` + Top0 []HTTPAseHTTPProtocolGetResponseTop0 `json:"top_0,required"` + JSON httpAseHTTPProtocolGetResponseJSON `json:"-"` +} + +// httpAseHTTPProtocolGetResponseJSON contains the JSON metadata for the struct +// [HTTPAseHTTPProtocolGetResponse] +type httpAseHTTPProtocolGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseHTTPProtocolGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseHTTPProtocolGetResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPAseHTTPProtocolGetResponseMeta struct { + DateRange []HTTPAseHTTPProtocolGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo HTTPAseHTTPProtocolGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpAseHTTPProtocolGetResponseMetaJSON `json:"-"` +} + +// httpAseHTTPProtocolGetResponseMetaJSON contains the JSON metadata for the struct +// [HTTPAseHTTPProtocolGetResponseMeta] +type httpAseHTTPProtocolGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseHTTPProtocolGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseHTTPProtocolGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPAseHTTPProtocolGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpAseHTTPProtocolGetResponseMetaDateRangeJSON `json:"-"` +} + +// httpAseHTTPProtocolGetResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [HTTPAseHTTPProtocolGetResponseMetaDateRange] +type httpAseHTTPProtocolGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseHTTPProtocolGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseHTTPProtocolGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPAseHTTPProtocolGetResponseMetaConfidenceInfo struct { + Annotations []HTTPAseHTTPProtocolGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpAseHTTPProtocolGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpAseHTTPProtocolGetResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [HTTPAseHTTPProtocolGetResponseMetaConfidenceInfo] +type httpAseHTTPProtocolGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseHTTPProtocolGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseHTTPProtocolGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPAseHTTPProtocolGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpAseHTTPProtocolGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpAseHTTPProtocolGetResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [HTTPAseHTTPProtocolGetResponseMetaConfidenceInfoAnnotation] +type httpAseHTTPProtocolGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseHTTPProtocolGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseHTTPProtocolGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPAseHTTPProtocolGetResponseTop0 struct { + ClientASN int64 `json:"clientASN,required"` + ClientAsName string `json:"clientASName,required"` + Value string `json:"value,required"` + JSON httpAseHTTPProtocolGetResponseTop0JSON `json:"-"` +} + +// httpAseHTTPProtocolGetResponseTop0JSON contains the JSON metadata for the struct +// [HTTPAseHTTPProtocolGetResponseTop0] +type httpAseHTTPProtocolGetResponseTop0JSON struct { + ClientASN apijson.Field + ClientAsName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseHTTPProtocolGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseHTTPProtocolGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type HTTPAseHTTPProtocolGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPAseHTTPProtocolGetParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPAseHTTPProtocolGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPAseHTTPProtocolGetParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPAseHTTPProtocolGetParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]HTTPAseHTTPProtocolGetParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPAseHTTPProtocolGetParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPAseHTTPProtocolGetParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPAseHTTPProtocolGetParams]'s query parameters as +// `url.Values`. +func (r HTTPAseHTTPProtocolGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// HTTP Protocol. +type HTTPAseHTTPProtocolGetParamsHTTPProtocol string + +const ( + HTTPAseHTTPProtocolGetParamsHTTPProtocolHTTP HTTPAseHTTPProtocolGetParamsHTTPProtocol = "HTTP" + HTTPAseHTTPProtocolGetParamsHTTPProtocolHTTPS HTTPAseHTTPProtocolGetParamsHTTPProtocol = "HTTPS" +) + +type HTTPAseHTTPProtocolGetParamsBotClass string + +const ( + HTTPAseHTTPProtocolGetParamsBotClassLikelyAutomated HTTPAseHTTPProtocolGetParamsBotClass = "LIKELY_AUTOMATED" + HTTPAseHTTPProtocolGetParamsBotClassLikelyHuman HTTPAseHTTPProtocolGetParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPAseHTTPProtocolGetParamsDateRange string + +const ( + HTTPAseHTTPProtocolGetParamsDateRange1d HTTPAseHTTPProtocolGetParamsDateRange = "1d" + HTTPAseHTTPProtocolGetParamsDateRange2d HTTPAseHTTPProtocolGetParamsDateRange = "2d" + HTTPAseHTTPProtocolGetParamsDateRange7d HTTPAseHTTPProtocolGetParamsDateRange = "7d" + HTTPAseHTTPProtocolGetParamsDateRange14d HTTPAseHTTPProtocolGetParamsDateRange = "14d" + HTTPAseHTTPProtocolGetParamsDateRange28d HTTPAseHTTPProtocolGetParamsDateRange = "28d" + HTTPAseHTTPProtocolGetParamsDateRange12w HTTPAseHTTPProtocolGetParamsDateRange = "12w" + HTTPAseHTTPProtocolGetParamsDateRange24w HTTPAseHTTPProtocolGetParamsDateRange = "24w" + HTTPAseHTTPProtocolGetParamsDateRange52w HTTPAseHTTPProtocolGetParamsDateRange = "52w" + HTTPAseHTTPProtocolGetParamsDateRange1dControl HTTPAseHTTPProtocolGetParamsDateRange = "1dControl" + HTTPAseHTTPProtocolGetParamsDateRange2dControl HTTPAseHTTPProtocolGetParamsDateRange = "2dControl" + HTTPAseHTTPProtocolGetParamsDateRange7dControl HTTPAseHTTPProtocolGetParamsDateRange = "7dControl" + HTTPAseHTTPProtocolGetParamsDateRange14dControl HTTPAseHTTPProtocolGetParamsDateRange = "14dControl" + HTTPAseHTTPProtocolGetParamsDateRange28dControl HTTPAseHTTPProtocolGetParamsDateRange = "28dControl" + HTTPAseHTTPProtocolGetParamsDateRange12wControl HTTPAseHTTPProtocolGetParamsDateRange = "12wControl" + HTTPAseHTTPProtocolGetParamsDateRange24wControl HTTPAseHTTPProtocolGetParamsDateRange = "24wControl" +) + +type HTTPAseHTTPProtocolGetParamsDeviceType string + +const ( + HTTPAseHTTPProtocolGetParamsDeviceTypeDesktop HTTPAseHTTPProtocolGetParamsDeviceType = "DESKTOP" + HTTPAseHTTPProtocolGetParamsDeviceTypeMobile HTTPAseHTTPProtocolGetParamsDeviceType = "MOBILE" + HTTPAseHTTPProtocolGetParamsDeviceTypeOther HTTPAseHTTPProtocolGetParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPAseHTTPProtocolGetParamsFormat string + +const ( + HTTPAseHTTPProtocolGetParamsFormatJson HTTPAseHTTPProtocolGetParamsFormat = "JSON" + HTTPAseHTTPProtocolGetParamsFormatCsv HTTPAseHTTPProtocolGetParamsFormat = "CSV" +) + +type HTTPAseHTTPProtocolGetParamsIPVersion string + +const ( + HTTPAseHTTPProtocolGetParamsIPVersionIPv4 HTTPAseHTTPProtocolGetParamsIPVersion = "IPv4" + HTTPAseHTTPProtocolGetParamsIPVersionIPv6 HTTPAseHTTPProtocolGetParamsIPVersion = "IPv6" +) + +type HTTPAseHTTPProtocolGetParamsOS string + +const ( + HTTPAseHTTPProtocolGetParamsOSWindows HTTPAseHTTPProtocolGetParamsOS = "WINDOWS" + HTTPAseHTTPProtocolGetParamsOSMacosx HTTPAseHTTPProtocolGetParamsOS = "MACOSX" + HTTPAseHTTPProtocolGetParamsOSIos HTTPAseHTTPProtocolGetParamsOS = "IOS" + HTTPAseHTTPProtocolGetParamsOSAndroid HTTPAseHTTPProtocolGetParamsOS = "ANDROID" + HTTPAseHTTPProtocolGetParamsOSChromeos HTTPAseHTTPProtocolGetParamsOS = "CHROMEOS" + HTTPAseHTTPProtocolGetParamsOSLinux HTTPAseHTTPProtocolGetParamsOS = "LINUX" + HTTPAseHTTPProtocolGetParamsOSSmartTv HTTPAseHTTPProtocolGetParamsOS = "SMART_TV" +) + +type HTTPAseHTTPProtocolGetParamsTLSVersion string + +const ( + HTTPAseHTTPProtocolGetParamsTLSVersionTlSv1_0 HTTPAseHTTPProtocolGetParamsTLSVersion = "TLSv1_0" + HTTPAseHTTPProtocolGetParamsTLSVersionTlSv1_1 HTTPAseHTTPProtocolGetParamsTLSVersion = "TLSv1_1" + HTTPAseHTTPProtocolGetParamsTLSVersionTlSv1_2 HTTPAseHTTPProtocolGetParamsTLSVersion = "TLSv1_2" + HTTPAseHTTPProtocolGetParamsTLSVersionTlSv1_3 HTTPAseHTTPProtocolGetParamsTLSVersion = "TLSv1_3" + HTTPAseHTTPProtocolGetParamsTLSVersionTlSvQuic HTTPAseHTTPProtocolGetParamsTLSVersion = "TLSvQUIC" +) + +type HTTPAseHTTPProtocolGetResponseEnvelope struct { + Result HTTPAseHTTPProtocolGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpAseHTTPProtocolGetResponseEnvelopeJSON `json:"-"` +} + +// httpAseHTTPProtocolGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [HTTPAseHTTPProtocolGetResponseEnvelope] +type httpAseHTTPProtocolGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseHTTPProtocolGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseHTTPProtocolGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httpasehttpprotocol_test.go b/radar/httpasehttpprotocol_test.go new file mode 100644 index 00000000000..01213638a65 --- /dev/null +++ b/radar/httpasehttpprotocol_test.go @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPAseHTTPProtocolGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Ases.HTTPProtocol.Get( + context.TODO(), + radar.HTTPAseHTTPProtocolGetParamsHTTPProtocolHTTP, + radar.HTTPAseHTTPProtocolGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPAseHTTPProtocolGetParamsBotClass{radar.HTTPAseHTTPProtocolGetParamsBotClassLikelyAutomated, radar.HTTPAseHTTPProtocolGetParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPAseHTTPProtocolGetParamsDateRange{radar.HTTPAseHTTPProtocolGetParamsDateRange1d, radar.HTTPAseHTTPProtocolGetParamsDateRange2d, radar.HTTPAseHTTPProtocolGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPAseHTTPProtocolGetParamsDeviceType{radar.HTTPAseHTTPProtocolGetParamsDeviceTypeDesktop, radar.HTTPAseHTTPProtocolGetParamsDeviceTypeMobile, radar.HTTPAseHTTPProtocolGetParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPAseHTTPProtocolGetParamsFormatJson), + IPVersion: cloudflare.F([]radar.HTTPAseHTTPProtocolGetParamsIPVersion{radar.HTTPAseHTTPProtocolGetParamsIPVersionIPv4, radar.HTTPAseHTTPProtocolGetParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPAseHTTPProtocolGetParamsOS{radar.HTTPAseHTTPProtocolGetParamsOSWindows, radar.HTTPAseHTTPProtocolGetParamsOSMacosx, radar.HTTPAseHTTPProtocolGetParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPAseHTTPProtocolGetParamsTLSVersion{radar.HTTPAseHTTPProtocolGetParamsTLSVersionTlSv1_0, radar.HTTPAseHTTPProtocolGetParamsTLSVersionTlSv1_1, radar.HTTPAseHTTPProtocolGetParamsTLSVersionTlSv1_2}), + }, + ) + 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/radar/httpaseipversion.go b/radar/httpaseipversion.go new file mode 100644 index 00000000000..0cfb4e22045 --- /dev/null +++ b/radar/httpaseipversion.go @@ -0,0 +1,366 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPAseIPVersionService 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 [NewHTTPAseIPVersionService] method +// instead. +type HTTPAseIPVersionService struct { + Options []option.RequestOption +} + +// NewHTTPAseIPVersionService 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 NewHTTPAseIPVersionService(opts ...option.RequestOption) (r *HTTPAseIPVersionService) { + r = &HTTPAseIPVersionService{} + r.Options = opts + return +} + +// Get the top autonomous systems, by HTTP traffic, of the requested IP protocol +// version. Values are a percentage out of the total traffic. +func (r *HTTPAseIPVersionService) Get(ctx context.Context, ipVersion HTTPAseIPVersionGetParamsIPVersion, query HTTPAseIPVersionGetParams, opts ...option.RequestOption) (res *HTTPAseIPVersionGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPAseIPVersionGetResponseEnvelope + path := fmt.Sprintf("radar/http/top/ases/ip_version/%v", ipVersion) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPAseIPVersionGetResponse struct { + Meta HTTPAseIPVersionGetResponseMeta `json:"meta,required"` + Top0 []HTTPAseIPVersionGetResponseTop0 `json:"top_0,required"` + JSON httpAseIPVersionGetResponseJSON `json:"-"` +} + +// httpAseIPVersionGetResponseJSON contains the JSON metadata for the struct +// [HTTPAseIPVersionGetResponse] +type httpAseIPVersionGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseIPVersionGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseIPVersionGetResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPAseIPVersionGetResponseMeta struct { + DateRange []HTTPAseIPVersionGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo HTTPAseIPVersionGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpAseIPVersionGetResponseMetaJSON `json:"-"` +} + +// httpAseIPVersionGetResponseMetaJSON contains the JSON metadata for the struct +// [HTTPAseIPVersionGetResponseMeta] +type httpAseIPVersionGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseIPVersionGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseIPVersionGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPAseIPVersionGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpAseIPVersionGetResponseMetaDateRangeJSON `json:"-"` +} + +// httpAseIPVersionGetResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [HTTPAseIPVersionGetResponseMetaDateRange] +type httpAseIPVersionGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseIPVersionGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseIPVersionGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPAseIPVersionGetResponseMetaConfidenceInfo struct { + Annotations []HTTPAseIPVersionGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpAseIPVersionGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpAseIPVersionGetResponseMetaConfidenceInfoJSON contains the JSON metadata for +// the struct [HTTPAseIPVersionGetResponseMetaConfidenceInfo] +type httpAseIPVersionGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseIPVersionGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseIPVersionGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPAseIPVersionGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpAseIPVersionGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpAseIPVersionGetResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [HTTPAseIPVersionGetResponseMetaConfidenceInfoAnnotation] +type httpAseIPVersionGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseIPVersionGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseIPVersionGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPAseIPVersionGetResponseTop0 struct { + ClientASN int64 `json:"clientASN,required"` + ClientAsName string `json:"clientASName,required"` + Value string `json:"value,required"` + JSON httpAseIPVersionGetResponseTop0JSON `json:"-"` +} + +// httpAseIPVersionGetResponseTop0JSON contains the JSON metadata for the struct +// [HTTPAseIPVersionGetResponseTop0] +type httpAseIPVersionGetResponseTop0JSON struct { + ClientASN apijson.Field + ClientAsName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseIPVersionGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseIPVersionGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type HTTPAseIPVersionGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPAseIPVersionGetParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPAseIPVersionGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPAseIPVersionGetParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPAseIPVersionGetParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPAseIPVersionGetParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPAseIPVersionGetParamsHTTPVersion] `query:"httpVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPAseIPVersionGetParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPAseIPVersionGetParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPAseIPVersionGetParams]'s query parameters as +// `url.Values`. +func (r HTTPAseIPVersionGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// IP version. +type HTTPAseIPVersionGetParamsIPVersion string + +const ( + HTTPAseIPVersionGetParamsIPVersionIPv4 HTTPAseIPVersionGetParamsIPVersion = "IPv4" + HTTPAseIPVersionGetParamsIPVersionIPv6 HTTPAseIPVersionGetParamsIPVersion = "IPv6" +) + +type HTTPAseIPVersionGetParamsBotClass string + +const ( + HTTPAseIPVersionGetParamsBotClassLikelyAutomated HTTPAseIPVersionGetParamsBotClass = "LIKELY_AUTOMATED" + HTTPAseIPVersionGetParamsBotClassLikelyHuman HTTPAseIPVersionGetParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPAseIPVersionGetParamsDateRange string + +const ( + HTTPAseIPVersionGetParamsDateRange1d HTTPAseIPVersionGetParamsDateRange = "1d" + HTTPAseIPVersionGetParamsDateRange2d HTTPAseIPVersionGetParamsDateRange = "2d" + HTTPAseIPVersionGetParamsDateRange7d HTTPAseIPVersionGetParamsDateRange = "7d" + HTTPAseIPVersionGetParamsDateRange14d HTTPAseIPVersionGetParamsDateRange = "14d" + HTTPAseIPVersionGetParamsDateRange28d HTTPAseIPVersionGetParamsDateRange = "28d" + HTTPAseIPVersionGetParamsDateRange12w HTTPAseIPVersionGetParamsDateRange = "12w" + HTTPAseIPVersionGetParamsDateRange24w HTTPAseIPVersionGetParamsDateRange = "24w" + HTTPAseIPVersionGetParamsDateRange52w HTTPAseIPVersionGetParamsDateRange = "52w" + HTTPAseIPVersionGetParamsDateRange1dControl HTTPAseIPVersionGetParamsDateRange = "1dControl" + HTTPAseIPVersionGetParamsDateRange2dControl HTTPAseIPVersionGetParamsDateRange = "2dControl" + HTTPAseIPVersionGetParamsDateRange7dControl HTTPAseIPVersionGetParamsDateRange = "7dControl" + HTTPAseIPVersionGetParamsDateRange14dControl HTTPAseIPVersionGetParamsDateRange = "14dControl" + HTTPAseIPVersionGetParamsDateRange28dControl HTTPAseIPVersionGetParamsDateRange = "28dControl" + HTTPAseIPVersionGetParamsDateRange12wControl HTTPAseIPVersionGetParamsDateRange = "12wControl" + HTTPAseIPVersionGetParamsDateRange24wControl HTTPAseIPVersionGetParamsDateRange = "24wControl" +) + +type HTTPAseIPVersionGetParamsDeviceType string + +const ( + HTTPAseIPVersionGetParamsDeviceTypeDesktop HTTPAseIPVersionGetParamsDeviceType = "DESKTOP" + HTTPAseIPVersionGetParamsDeviceTypeMobile HTTPAseIPVersionGetParamsDeviceType = "MOBILE" + HTTPAseIPVersionGetParamsDeviceTypeOther HTTPAseIPVersionGetParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPAseIPVersionGetParamsFormat string + +const ( + HTTPAseIPVersionGetParamsFormatJson HTTPAseIPVersionGetParamsFormat = "JSON" + HTTPAseIPVersionGetParamsFormatCsv HTTPAseIPVersionGetParamsFormat = "CSV" +) + +type HTTPAseIPVersionGetParamsHTTPProtocol string + +const ( + HTTPAseIPVersionGetParamsHTTPProtocolHTTP HTTPAseIPVersionGetParamsHTTPProtocol = "HTTP" + HTTPAseIPVersionGetParamsHTTPProtocolHTTPS HTTPAseIPVersionGetParamsHTTPProtocol = "HTTPS" +) + +type HTTPAseIPVersionGetParamsHTTPVersion string + +const ( + HTTPAseIPVersionGetParamsHTTPVersionHttPv1 HTTPAseIPVersionGetParamsHTTPVersion = "HTTPv1" + HTTPAseIPVersionGetParamsHTTPVersionHttPv2 HTTPAseIPVersionGetParamsHTTPVersion = "HTTPv2" + HTTPAseIPVersionGetParamsHTTPVersionHttPv3 HTTPAseIPVersionGetParamsHTTPVersion = "HTTPv3" +) + +type HTTPAseIPVersionGetParamsOS string + +const ( + HTTPAseIPVersionGetParamsOSWindows HTTPAseIPVersionGetParamsOS = "WINDOWS" + HTTPAseIPVersionGetParamsOSMacosx HTTPAseIPVersionGetParamsOS = "MACOSX" + HTTPAseIPVersionGetParamsOSIos HTTPAseIPVersionGetParamsOS = "IOS" + HTTPAseIPVersionGetParamsOSAndroid HTTPAseIPVersionGetParamsOS = "ANDROID" + HTTPAseIPVersionGetParamsOSChromeos HTTPAseIPVersionGetParamsOS = "CHROMEOS" + HTTPAseIPVersionGetParamsOSLinux HTTPAseIPVersionGetParamsOS = "LINUX" + HTTPAseIPVersionGetParamsOSSmartTv HTTPAseIPVersionGetParamsOS = "SMART_TV" +) + +type HTTPAseIPVersionGetParamsTLSVersion string + +const ( + HTTPAseIPVersionGetParamsTLSVersionTlSv1_0 HTTPAseIPVersionGetParamsTLSVersion = "TLSv1_0" + HTTPAseIPVersionGetParamsTLSVersionTlSv1_1 HTTPAseIPVersionGetParamsTLSVersion = "TLSv1_1" + HTTPAseIPVersionGetParamsTLSVersionTlSv1_2 HTTPAseIPVersionGetParamsTLSVersion = "TLSv1_2" + HTTPAseIPVersionGetParamsTLSVersionTlSv1_3 HTTPAseIPVersionGetParamsTLSVersion = "TLSv1_3" + HTTPAseIPVersionGetParamsTLSVersionTlSvQuic HTTPAseIPVersionGetParamsTLSVersion = "TLSvQUIC" +) + +type HTTPAseIPVersionGetResponseEnvelope struct { + Result HTTPAseIPVersionGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpAseIPVersionGetResponseEnvelopeJSON `json:"-"` +} + +// httpAseIPVersionGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [HTTPAseIPVersionGetResponseEnvelope] +type httpAseIPVersionGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseIPVersionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseIPVersionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httpaseipversion_test.go b/radar/httpaseipversion_test.go new file mode 100644 index 00000000000..1af21a03f65 --- /dev/null +++ b/radar/httpaseipversion_test.go @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPAseIPVersionGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Ases.IPVersion.Get( + context.TODO(), + radar.HTTPAseIPVersionGetParamsIPVersionIPv4, + radar.HTTPAseIPVersionGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPAseIPVersionGetParamsBotClass{radar.HTTPAseIPVersionGetParamsBotClassLikelyAutomated, radar.HTTPAseIPVersionGetParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPAseIPVersionGetParamsDateRange{radar.HTTPAseIPVersionGetParamsDateRange1d, radar.HTTPAseIPVersionGetParamsDateRange2d, radar.HTTPAseIPVersionGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPAseIPVersionGetParamsDeviceType{radar.HTTPAseIPVersionGetParamsDeviceTypeDesktop, radar.HTTPAseIPVersionGetParamsDeviceTypeMobile, radar.HTTPAseIPVersionGetParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPAseIPVersionGetParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPAseIPVersionGetParamsHTTPProtocol{radar.HTTPAseIPVersionGetParamsHTTPProtocolHTTP, radar.HTTPAseIPVersionGetParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPAseIPVersionGetParamsHTTPVersion{radar.HTTPAseIPVersionGetParamsHTTPVersionHttPv1, radar.HTTPAseIPVersionGetParamsHTTPVersionHttPv2, radar.HTTPAseIPVersionGetParamsHTTPVersionHttPv3}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPAseIPVersionGetParamsOS{radar.HTTPAseIPVersionGetParamsOSWindows, radar.HTTPAseIPVersionGetParamsOSMacosx, radar.HTTPAseIPVersionGetParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPAseIPVersionGetParamsTLSVersion{radar.HTTPAseIPVersionGetParamsTLSVersionTlSv1_0, radar.HTTPAseIPVersionGetParamsTLSVersionTlSv1_1, radar.HTTPAseIPVersionGetParamsTLSVersionTlSv1_2}), + }, + ) + 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/radar/httpaseos.go b/radar/httpaseos.go new file mode 100644 index 00000000000..ebbf34ffc3d --- /dev/null +++ b/radar/httpaseos.go @@ -0,0 +1,363 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPAseOSService 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 [NewHTTPAseOSService] method instead. +type HTTPAseOSService struct { + Options []option.RequestOption +} + +// NewHTTPAseOSService 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 NewHTTPAseOSService(opts ...option.RequestOption) (r *HTTPAseOSService) { + r = &HTTPAseOSService{} + r.Options = opts + return +} + +// Get the top autonomous systems, by HTTP traffic, of the requested operating +// systems. Values are a percentage out of the total traffic. +func (r *HTTPAseOSService) Get(ctx context.Context, os HTTPAseOSGetParamsOS, query HTTPAseOSGetParams, opts ...option.RequestOption) (res *HTTPAseOSGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPAseOSGetResponseEnvelope + path := fmt.Sprintf("radar/http/top/ases/os/%v", os) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPAseOSGetResponse struct { + Meta HTTPAseOSGetResponseMeta `json:"meta,required"` + Top0 []HTTPAseOSGetResponseTop0 `json:"top_0,required"` + JSON httpAseOSGetResponseJSON `json:"-"` +} + +// httpAseOSGetResponseJSON contains the JSON metadata for the struct +// [HTTPAseOSGetResponse] +type httpAseOSGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseOSGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseOSGetResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPAseOSGetResponseMeta struct { + DateRange []HTTPAseOSGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo HTTPAseOSGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpAseOSGetResponseMetaJSON `json:"-"` +} + +// httpAseOSGetResponseMetaJSON contains the JSON metadata for the struct +// [HTTPAseOSGetResponseMeta] +type httpAseOSGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseOSGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseOSGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPAseOSGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpAseOSGetResponseMetaDateRangeJSON `json:"-"` +} + +// httpAseOSGetResponseMetaDateRangeJSON contains the JSON metadata for the struct +// [HTTPAseOSGetResponseMetaDateRange] +type httpAseOSGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseOSGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseOSGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPAseOSGetResponseMetaConfidenceInfo struct { + Annotations []HTTPAseOSGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpAseOSGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpAseOSGetResponseMetaConfidenceInfoJSON contains the JSON metadata for the +// struct [HTTPAseOSGetResponseMetaConfidenceInfo] +type httpAseOSGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseOSGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseOSGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPAseOSGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpAseOSGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpAseOSGetResponseMetaConfidenceInfoAnnotationJSON contains the JSON metadata +// for the struct [HTTPAseOSGetResponseMetaConfidenceInfoAnnotation] +type httpAseOSGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseOSGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseOSGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPAseOSGetResponseTop0 struct { + ClientASN int64 `json:"clientASN,required"` + ClientAsName string `json:"clientASName,required"` + Value string `json:"value,required"` + JSON httpAseOSGetResponseTop0JSON `json:"-"` +} + +// httpAseOSGetResponseTop0JSON contains the JSON metadata for the struct +// [HTTPAseOSGetResponseTop0] +type httpAseOSGetResponseTop0JSON struct { + ClientASN apijson.Field + ClientAsName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseOSGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseOSGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type HTTPAseOSGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPAseOSGetParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPAseOSGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPAseOSGetParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPAseOSGetParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPAseOSGetParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPAseOSGetParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPAseOSGetParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPAseOSGetParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPAseOSGetParams]'s query parameters as `url.Values`. +func (r HTTPAseOSGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// IP version. +type HTTPAseOSGetParamsOS string + +const ( + HTTPAseOSGetParamsOSWindows HTTPAseOSGetParamsOS = "WINDOWS" + HTTPAseOSGetParamsOSMacosx HTTPAseOSGetParamsOS = "MACOSX" + HTTPAseOSGetParamsOSIos HTTPAseOSGetParamsOS = "IOS" + HTTPAseOSGetParamsOSAndroid HTTPAseOSGetParamsOS = "ANDROID" + HTTPAseOSGetParamsOSChromeos HTTPAseOSGetParamsOS = "CHROMEOS" + HTTPAseOSGetParamsOSLinux HTTPAseOSGetParamsOS = "LINUX" + HTTPAseOSGetParamsOSSmartTv HTTPAseOSGetParamsOS = "SMART_TV" +) + +type HTTPAseOSGetParamsBotClass string + +const ( + HTTPAseOSGetParamsBotClassLikelyAutomated HTTPAseOSGetParamsBotClass = "LIKELY_AUTOMATED" + HTTPAseOSGetParamsBotClassLikelyHuman HTTPAseOSGetParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPAseOSGetParamsDateRange string + +const ( + HTTPAseOSGetParamsDateRange1d HTTPAseOSGetParamsDateRange = "1d" + HTTPAseOSGetParamsDateRange2d HTTPAseOSGetParamsDateRange = "2d" + HTTPAseOSGetParamsDateRange7d HTTPAseOSGetParamsDateRange = "7d" + HTTPAseOSGetParamsDateRange14d HTTPAseOSGetParamsDateRange = "14d" + HTTPAseOSGetParamsDateRange28d HTTPAseOSGetParamsDateRange = "28d" + HTTPAseOSGetParamsDateRange12w HTTPAseOSGetParamsDateRange = "12w" + HTTPAseOSGetParamsDateRange24w HTTPAseOSGetParamsDateRange = "24w" + HTTPAseOSGetParamsDateRange52w HTTPAseOSGetParamsDateRange = "52w" + HTTPAseOSGetParamsDateRange1dControl HTTPAseOSGetParamsDateRange = "1dControl" + HTTPAseOSGetParamsDateRange2dControl HTTPAseOSGetParamsDateRange = "2dControl" + HTTPAseOSGetParamsDateRange7dControl HTTPAseOSGetParamsDateRange = "7dControl" + HTTPAseOSGetParamsDateRange14dControl HTTPAseOSGetParamsDateRange = "14dControl" + HTTPAseOSGetParamsDateRange28dControl HTTPAseOSGetParamsDateRange = "28dControl" + HTTPAseOSGetParamsDateRange12wControl HTTPAseOSGetParamsDateRange = "12wControl" + HTTPAseOSGetParamsDateRange24wControl HTTPAseOSGetParamsDateRange = "24wControl" +) + +type HTTPAseOSGetParamsDeviceType string + +const ( + HTTPAseOSGetParamsDeviceTypeDesktop HTTPAseOSGetParamsDeviceType = "DESKTOP" + HTTPAseOSGetParamsDeviceTypeMobile HTTPAseOSGetParamsDeviceType = "MOBILE" + HTTPAseOSGetParamsDeviceTypeOther HTTPAseOSGetParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPAseOSGetParamsFormat string + +const ( + HTTPAseOSGetParamsFormatJson HTTPAseOSGetParamsFormat = "JSON" + HTTPAseOSGetParamsFormatCsv HTTPAseOSGetParamsFormat = "CSV" +) + +type HTTPAseOSGetParamsHTTPProtocol string + +const ( + HTTPAseOSGetParamsHTTPProtocolHTTP HTTPAseOSGetParamsHTTPProtocol = "HTTP" + HTTPAseOSGetParamsHTTPProtocolHTTPS HTTPAseOSGetParamsHTTPProtocol = "HTTPS" +) + +type HTTPAseOSGetParamsHTTPVersion string + +const ( + HTTPAseOSGetParamsHTTPVersionHttPv1 HTTPAseOSGetParamsHTTPVersion = "HTTPv1" + HTTPAseOSGetParamsHTTPVersionHttPv2 HTTPAseOSGetParamsHTTPVersion = "HTTPv2" + HTTPAseOSGetParamsHTTPVersionHttPv3 HTTPAseOSGetParamsHTTPVersion = "HTTPv3" +) + +type HTTPAseOSGetParamsIPVersion string + +const ( + HTTPAseOSGetParamsIPVersionIPv4 HTTPAseOSGetParamsIPVersion = "IPv4" + HTTPAseOSGetParamsIPVersionIPv6 HTTPAseOSGetParamsIPVersion = "IPv6" +) + +type HTTPAseOSGetParamsTLSVersion string + +const ( + HTTPAseOSGetParamsTLSVersionTlSv1_0 HTTPAseOSGetParamsTLSVersion = "TLSv1_0" + HTTPAseOSGetParamsTLSVersionTlSv1_1 HTTPAseOSGetParamsTLSVersion = "TLSv1_1" + HTTPAseOSGetParamsTLSVersionTlSv1_2 HTTPAseOSGetParamsTLSVersion = "TLSv1_2" + HTTPAseOSGetParamsTLSVersionTlSv1_3 HTTPAseOSGetParamsTLSVersion = "TLSv1_3" + HTTPAseOSGetParamsTLSVersionTlSvQuic HTTPAseOSGetParamsTLSVersion = "TLSvQUIC" +) + +type HTTPAseOSGetResponseEnvelope struct { + Result HTTPAseOSGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpAseOSGetResponseEnvelopeJSON `json:"-"` +} + +// httpAseOSGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [HTTPAseOSGetResponseEnvelope] +type httpAseOSGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseOSGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseOSGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httpaseos_test.go b/radar/httpaseos_test.go new file mode 100644 index 00000000000..172d8bf8315 --- /dev/null +++ b/radar/httpaseos_test.go @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPAseOSGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Ases.OS.Get( + context.TODO(), + radar.HTTPAseOSGetParamsOSWindows, + radar.HTTPAseOSGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPAseOSGetParamsBotClass{radar.HTTPAseOSGetParamsBotClassLikelyAutomated, radar.HTTPAseOSGetParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPAseOSGetParamsDateRange{radar.HTTPAseOSGetParamsDateRange1d, radar.HTTPAseOSGetParamsDateRange2d, radar.HTTPAseOSGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPAseOSGetParamsDeviceType{radar.HTTPAseOSGetParamsDeviceTypeDesktop, radar.HTTPAseOSGetParamsDeviceTypeMobile, radar.HTTPAseOSGetParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPAseOSGetParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPAseOSGetParamsHTTPProtocol{radar.HTTPAseOSGetParamsHTTPProtocolHTTP, radar.HTTPAseOSGetParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPAseOSGetParamsHTTPVersion{radar.HTTPAseOSGetParamsHTTPVersionHttPv1, radar.HTTPAseOSGetParamsHTTPVersionHttPv2, radar.HTTPAseOSGetParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPAseOSGetParamsIPVersion{radar.HTTPAseOSGetParamsIPVersionIPv4, radar.HTTPAseOSGetParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + TLSVersion: cloudflare.F([]radar.HTTPAseOSGetParamsTLSVersion{radar.HTTPAseOSGetParamsTLSVersionTlSv1_0, radar.HTTPAseOSGetParamsTLSVersionTlSv1_1, radar.HTTPAseOSGetParamsTLSVersionTlSv1_2}), + }, + ) + 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/radar/httpasetlsversion.go b/radar/httpasetlsversion.go new file mode 100644 index 00000000000..22d221f25e2 --- /dev/null +++ b/radar/httpasetlsversion.go @@ -0,0 +1,366 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPAseTLSVersionService 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 [NewHTTPAseTLSVersionService] method +// instead. +type HTTPAseTLSVersionService struct { + Options []option.RequestOption +} + +// NewHTTPAseTLSVersionService 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 NewHTTPAseTLSVersionService(opts ...option.RequestOption) (r *HTTPAseTLSVersionService) { + r = &HTTPAseTLSVersionService{} + r.Options = opts + return +} + +// Get the top autonomous systems (AS), by HTTP traffic, of the requested TLS +// protocol version. Values are a percentage out of the total traffic. +func (r *HTTPAseTLSVersionService) Get(ctx context.Context, tlsVersion HTTPAseTLSVersionGetParamsTLSVersion, query HTTPAseTLSVersionGetParams, opts ...option.RequestOption) (res *HTTPAseTLSVersionGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPAseTLSVersionGetResponseEnvelope + path := fmt.Sprintf("radar/http/top/ases/tls_version/%v", tlsVersion) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPAseTLSVersionGetResponse struct { + Meta HTTPAseTLSVersionGetResponseMeta `json:"meta,required"` + Top0 []HTTPAseTLSVersionGetResponseTop0 `json:"top_0,required"` + JSON httpAseTLSVersionGetResponseJSON `json:"-"` +} + +// httpAseTLSVersionGetResponseJSON contains the JSON metadata for the struct +// [HTTPAseTLSVersionGetResponse] +type httpAseTLSVersionGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseTLSVersionGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseTLSVersionGetResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPAseTLSVersionGetResponseMeta struct { + DateRange []HTTPAseTLSVersionGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo HTTPAseTLSVersionGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpAseTLSVersionGetResponseMetaJSON `json:"-"` +} + +// httpAseTLSVersionGetResponseMetaJSON contains the JSON metadata for the struct +// [HTTPAseTLSVersionGetResponseMeta] +type httpAseTLSVersionGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseTLSVersionGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseTLSVersionGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPAseTLSVersionGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpAseTLSVersionGetResponseMetaDateRangeJSON `json:"-"` +} + +// httpAseTLSVersionGetResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [HTTPAseTLSVersionGetResponseMetaDateRange] +type httpAseTLSVersionGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseTLSVersionGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseTLSVersionGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPAseTLSVersionGetResponseMetaConfidenceInfo struct { + Annotations []HTTPAseTLSVersionGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpAseTLSVersionGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpAseTLSVersionGetResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [HTTPAseTLSVersionGetResponseMetaConfidenceInfo] +type httpAseTLSVersionGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseTLSVersionGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseTLSVersionGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPAseTLSVersionGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpAseTLSVersionGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpAseTLSVersionGetResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [HTTPAseTLSVersionGetResponseMetaConfidenceInfoAnnotation] +type httpAseTLSVersionGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseTLSVersionGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseTLSVersionGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPAseTLSVersionGetResponseTop0 struct { + ClientASN int64 `json:"clientASN,required"` + ClientAsName string `json:"clientASName,required"` + Value string `json:"value,required"` + JSON httpAseTLSVersionGetResponseTop0JSON `json:"-"` +} + +// httpAseTLSVersionGetResponseTop0JSON contains the JSON metadata for the struct +// [HTTPAseTLSVersionGetResponseTop0] +type httpAseTLSVersionGetResponseTop0JSON struct { + ClientASN apijson.Field + ClientAsName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseTLSVersionGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseTLSVersionGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type HTTPAseTLSVersionGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPAseTLSVersionGetParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPAseTLSVersionGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPAseTLSVersionGetParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPAseTLSVersionGetParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPAseTLSVersionGetParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPAseTLSVersionGetParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPAseTLSVersionGetParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPAseTLSVersionGetParamsOS] `query:"os"` +} + +// URLQuery serializes [HTTPAseTLSVersionGetParams]'s query parameters as +// `url.Values`. +func (r HTTPAseTLSVersionGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// TLS version. +type HTTPAseTLSVersionGetParamsTLSVersion string + +const ( + HTTPAseTLSVersionGetParamsTLSVersionTlSv1_0 HTTPAseTLSVersionGetParamsTLSVersion = "TLSv1_0" + HTTPAseTLSVersionGetParamsTLSVersionTlSv1_1 HTTPAseTLSVersionGetParamsTLSVersion = "TLSv1_1" + HTTPAseTLSVersionGetParamsTLSVersionTlSv1_2 HTTPAseTLSVersionGetParamsTLSVersion = "TLSv1_2" + HTTPAseTLSVersionGetParamsTLSVersionTlSv1_3 HTTPAseTLSVersionGetParamsTLSVersion = "TLSv1_3" + HTTPAseTLSVersionGetParamsTLSVersionTlSvQuic HTTPAseTLSVersionGetParamsTLSVersion = "TLSvQUIC" +) + +type HTTPAseTLSVersionGetParamsBotClass string + +const ( + HTTPAseTLSVersionGetParamsBotClassLikelyAutomated HTTPAseTLSVersionGetParamsBotClass = "LIKELY_AUTOMATED" + HTTPAseTLSVersionGetParamsBotClassLikelyHuman HTTPAseTLSVersionGetParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPAseTLSVersionGetParamsDateRange string + +const ( + HTTPAseTLSVersionGetParamsDateRange1d HTTPAseTLSVersionGetParamsDateRange = "1d" + HTTPAseTLSVersionGetParamsDateRange2d HTTPAseTLSVersionGetParamsDateRange = "2d" + HTTPAseTLSVersionGetParamsDateRange7d HTTPAseTLSVersionGetParamsDateRange = "7d" + HTTPAseTLSVersionGetParamsDateRange14d HTTPAseTLSVersionGetParamsDateRange = "14d" + HTTPAseTLSVersionGetParamsDateRange28d HTTPAseTLSVersionGetParamsDateRange = "28d" + HTTPAseTLSVersionGetParamsDateRange12w HTTPAseTLSVersionGetParamsDateRange = "12w" + HTTPAseTLSVersionGetParamsDateRange24w HTTPAseTLSVersionGetParamsDateRange = "24w" + HTTPAseTLSVersionGetParamsDateRange52w HTTPAseTLSVersionGetParamsDateRange = "52w" + HTTPAseTLSVersionGetParamsDateRange1dControl HTTPAseTLSVersionGetParamsDateRange = "1dControl" + HTTPAseTLSVersionGetParamsDateRange2dControl HTTPAseTLSVersionGetParamsDateRange = "2dControl" + HTTPAseTLSVersionGetParamsDateRange7dControl HTTPAseTLSVersionGetParamsDateRange = "7dControl" + HTTPAseTLSVersionGetParamsDateRange14dControl HTTPAseTLSVersionGetParamsDateRange = "14dControl" + HTTPAseTLSVersionGetParamsDateRange28dControl HTTPAseTLSVersionGetParamsDateRange = "28dControl" + HTTPAseTLSVersionGetParamsDateRange12wControl HTTPAseTLSVersionGetParamsDateRange = "12wControl" + HTTPAseTLSVersionGetParamsDateRange24wControl HTTPAseTLSVersionGetParamsDateRange = "24wControl" +) + +type HTTPAseTLSVersionGetParamsDeviceType string + +const ( + HTTPAseTLSVersionGetParamsDeviceTypeDesktop HTTPAseTLSVersionGetParamsDeviceType = "DESKTOP" + HTTPAseTLSVersionGetParamsDeviceTypeMobile HTTPAseTLSVersionGetParamsDeviceType = "MOBILE" + HTTPAseTLSVersionGetParamsDeviceTypeOther HTTPAseTLSVersionGetParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPAseTLSVersionGetParamsFormat string + +const ( + HTTPAseTLSVersionGetParamsFormatJson HTTPAseTLSVersionGetParamsFormat = "JSON" + HTTPAseTLSVersionGetParamsFormatCsv HTTPAseTLSVersionGetParamsFormat = "CSV" +) + +type HTTPAseTLSVersionGetParamsHTTPProtocol string + +const ( + HTTPAseTLSVersionGetParamsHTTPProtocolHTTP HTTPAseTLSVersionGetParamsHTTPProtocol = "HTTP" + HTTPAseTLSVersionGetParamsHTTPProtocolHTTPS HTTPAseTLSVersionGetParamsHTTPProtocol = "HTTPS" +) + +type HTTPAseTLSVersionGetParamsHTTPVersion string + +const ( + HTTPAseTLSVersionGetParamsHTTPVersionHttPv1 HTTPAseTLSVersionGetParamsHTTPVersion = "HTTPv1" + HTTPAseTLSVersionGetParamsHTTPVersionHttPv2 HTTPAseTLSVersionGetParamsHTTPVersion = "HTTPv2" + HTTPAseTLSVersionGetParamsHTTPVersionHttPv3 HTTPAseTLSVersionGetParamsHTTPVersion = "HTTPv3" +) + +type HTTPAseTLSVersionGetParamsIPVersion string + +const ( + HTTPAseTLSVersionGetParamsIPVersionIPv4 HTTPAseTLSVersionGetParamsIPVersion = "IPv4" + HTTPAseTLSVersionGetParamsIPVersionIPv6 HTTPAseTLSVersionGetParamsIPVersion = "IPv6" +) + +type HTTPAseTLSVersionGetParamsOS string + +const ( + HTTPAseTLSVersionGetParamsOSWindows HTTPAseTLSVersionGetParamsOS = "WINDOWS" + HTTPAseTLSVersionGetParamsOSMacosx HTTPAseTLSVersionGetParamsOS = "MACOSX" + HTTPAseTLSVersionGetParamsOSIos HTTPAseTLSVersionGetParamsOS = "IOS" + HTTPAseTLSVersionGetParamsOSAndroid HTTPAseTLSVersionGetParamsOS = "ANDROID" + HTTPAseTLSVersionGetParamsOSChromeos HTTPAseTLSVersionGetParamsOS = "CHROMEOS" + HTTPAseTLSVersionGetParamsOSLinux HTTPAseTLSVersionGetParamsOS = "LINUX" + HTTPAseTLSVersionGetParamsOSSmartTv HTTPAseTLSVersionGetParamsOS = "SMART_TV" +) + +type HTTPAseTLSVersionGetResponseEnvelope struct { + Result HTTPAseTLSVersionGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpAseTLSVersionGetResponseEnvelopeJSON `json:"-"` +} + +// httpAseTLSVersionGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [HTTPAseTLSVersionGetResponseEnvelope] +type httpAseTLSVersionGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPAseTLSVersionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpAseTLSVersionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httpasetlsversion_test.go b/radar/httpasetlsversion_test.go new file mode 100644 index 00000000000..fa8d7ef6c09 --- /dev/null +++ b/radar/httpasetlsversion_test.go @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPAseTLSVersionGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Ases.TLSVersion.Get( + context.TODO(), + radar.HTTPAseTLSVersionGetParamsTLSVersionTlSv1_0, + radar.HTTPAseTLSVersionGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPAseTLSVersionGetParamsBotClass{radar.HTTPAseTLSVersionGetParamsBotClassLikelyAutomated, radar.HTTPAseTLSVersionGetParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPAseTLSVersionGetParamsDateRange{radar.HTTPAseTLSVersionGetParamsDateRange1d, radar.HTTPAseTLSVersionGetParamsDateRange2d, radar.HTTPAseTLSVersionGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPAseTLSVersionGetParamsDeviceType{radar.HTTPAseTLSVersionGetParamsDeviceTypeDesktop, radar.HTTPAseTLSVersionGetParamsDeviceTypeMobile, radar.HTTPAseTLSVersionGetParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPAseTLSVersionGetParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPAseTLSVersionGetParamsHTTPProtocol{radar.HTTPAseTLSVersionGetParamsHTTPProtocolHTTP, radar.HTTPAseTLSVersionGetParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPAseTLSVersionGetParamsHTTPVersion{radar.HTTPAseTLSVersionGetParamsHTTPVersionHttPv1, radar.HTTPAseTLSVersionGetParamsHTTPVersionHttPv2, radar.HTTPAseTLSVersionGetParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPAseTLSVersionGetParamsIPVersion{radar.HTTPAseTLSVersionGetParamsIPVersionIPv4, radar.HTTPAseTLSVersionGetParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPAseTLSVersionGetParamsOS{radar.HTTPAseTLSVersionGetParamsOSWindows, radar.HTTPAseTLSVersionGetParamsOSMacosx, radar.HTTPAseTLSVersionGetParamsOSIos}), + }, + ) + 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/radar/httplocation.go b/radar/httplocation.go new file mode 100644 index 00000000000..e7d0d442222 --- /dev/null +++ b/radar/httplocation.go @@ -0,0 +1,378 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPLocationService 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 [NewHTTPLocationService] method +// instead. +type HTTPLocationService struct { + Options []option.RequestOption + BotClass *HTTPLocationBotClassService + DeviceType *HTTPLocationDeviceTypeService + HTTPProtocol *HTTPLocationHTTPProtocolService + HTTPMethod *HTTPLocationHTTPMethodService + IPVersion *HTTPLocationIPVersionService + OS *HTTPLocationOSService + TLSVersion *HTTPLocationTLSVersionService +} + +// NewHTTPLocationService 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 NewHTTPLocationService(opts ...option.RequestOption) (r *HTTPLocationService) { + r = &HTTPLocationService{} + r.Options = opts + r.BotClass = NewHTTPLocationBotClassService(opts...) + r.DeviceType = NewHTTPLocationDeviceTypeService(opts...) + r.HTTPProtocol = NewHTTPLocationHTTPProtocolService(opts...) + r.HTTPMethod = NewHTTPLocationHTTPMethodService(opts...) + r.IPVersion = NewHTTPLocationIPVersionService(opts...) + r.OS = NewHTTPLocationOSService(opts...) + r.TLSVersion = NewHTTPLocationTLSVersionService(opts...) + return +} + +// Get the top locations by HTTP traffic. Values are a percentage out of the total +// traffic. +func (r *HTTPLocationService) Get(ctx context.Context, query HTTPLocationGetParams, opts ...option.RequestOption) (res *HTTPLocationGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPLocationGetResponseEnvelope + path := "radar/http/top/locations" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPLocationGetResponse struct { + Meta HTTPLocationGetResponseMeta `json:"meta,required"` + Top0 []HTTPLocationGetResponseTop0 `json:"top_0,required"` + JSON httpLocationGetResponseJSON `json:"-"` +} + +// httpLocationGetResponseJSON contains the JSON metadata for the struct +// [HTTPLocationGetResponse] +type httpLocationGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationGetResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationGetResponseMeta struct { + DateRange []HTTPLocationGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo HTTPLocationGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpLocationGetResponseMetaJSON `json:"-"` +} + +// httpLocationGetResponseMetaJSON contains the JSON metadata for the struct +// [HTTPLocationGetResponseMeta] +type httpLocationGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpLocationGetResponseMetaDateRangeJSON `json:"-"` +} + +// httpLocationGetResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [HTTPLocationGetResponseMetaDateRange] +type httpLocationGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationGetResponseMetaConfidenceInfo struct { + Annotations []HTTPLocationGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpLocationGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpLocationGetResponseMetaConfidenceInfoJSON contains the JSON metadata for the +// struct [HTTPLocationGetResponseMetaConfidenceInfo] +type httpLocationGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpLocationGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpLocationGetResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct [HTTPLocationGetResponseMetaConfidenceInfoAnnotation] +type httpLocationGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationGetResponseTop0 struct { + ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` + ClientCountryName string `json:"clientCountryName,required"` + Value string `json:"value,required"` + JSON httpLocationGetResponseTop0JSON `json:"-"` +} + +// httpLocationGetResponseTop0JSON contains the JSON metadata for the struct +// [HTTPLocationGetResponseTop0] +type httpLocationGetResponseTop0JSON struct { + ClientCountryAlpha2 apijson.Field + ClientCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type HTTPLocationGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPLocationGetParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPLocationGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPLocationGetParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPLocationGetParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPLocationGetParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPLocationGetParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPLocationGetParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPLocationGetParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPLocationGetParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPLocationGetParams]'s query parameters as `url.Values`. +func (r HTTPLocationGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type HTTPLocationGetParamsBotClass string + +const ( + HTTPLocationGetParamsBotClassLikelyAutomated HTTPLocationGetParamsBotClass = "LIKELY_AUTOMATED" + HTTPLocationGetParamsBotClassLikelyHuman HTTPLocationGetParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPLocationGetParamsDateRange string + +const ( + HTTPLocationGetParamsDateRange1d HTTPLocationGetParamsDateRange = "1d" + HTTPLocationGetParamsDateRange2d HTTPLocationGetParamsDateRange = "2d" + HTTPLocationGetParamsDateRange7d HTTPLocationGetParamsDateRange = "7d" + HTTPLocationGetParamsDateRange14d HTTPLocationGetParamsDateRange = "14d" + HTTPLocationGetParamsDateRange28d HTTPLocationGetParamsDateRange = "28d" + HTTPLocationGetParamsDateRange12w HTTPLocationGetParamsDateRange = "12w" + HTTPLocationGetParamsDateRange24w HTTPLocationGetParamsDateRange = "24w" + HTTPLocationGetParamsDateRange52w HTTPLocationGetParamsDateRange = "52w" + HTTPLocationGetParamsDateRange1dControl HTTPLocationGetParamsDateRange = "1dControl" + HTTPLocationGetParamsDateRange2dControl HTTPLocationGetParamsDateRange = "2dControl" + HTTPLocationGetParamsDateRange7dControl HTTPLocationGetParamsDateRange = "7dControl" + HTTPLocationGetParamsDateRange14dControl HTTPLocationGetParamsDateRange = "14dControl" + HTTPLocationGetParamsDateRange28dControl HTTPLocationGetParamsDateRange = "28dControl" + HTTPLocationGetParamsDateRange12wControl HTTPLocationGetParamsDateRange = "12wControl" + HTTPLocationGetParamsDateRange24wControl HTTPLocationGetParamsDateRange = "24wControl" +) + +type HTTPLocationGetParamsDeviceType string + +const ( + HTTPLocationGetParamsDeviceTypeDesktop HTTPLocationGetParamsDeviceType = "DESKTOP" + HTTPLocationGetParamsDeviceTypeMobile HTTPLocationGetParamsDeviceType = "MOBILE" + HTTPLocationGetParamsDeviceTypeOther HTTPLocationGetParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPLocationGetParamsFormat string + +const ( + HTTPLocationGetParamsFormatJson HTTPLocationGetParamsFormat = "JSON" + HTTPLocationGetParamsFormatCsv HTTPLocationGetParamsFormat = "CSV" +) + +type HTTPLocationGetParamsHTTPProtocol string + +const ( + HTTPLocationGetParamsHTTPProtocolHTTP HTTPLocationGetParamsHTTPProtocol = "HTTP" + HTTPLocationGetParamsHTTPProtocolHTTPS HTTPLocationGetParamsHTTPProtocol = "HTTPS" +) + +type HTTPLocationGetParamsHTTPVersion string + +const ( + HTTPLocationGetParamsHTTPVersionHttPv1 HTTPLocationGetParamsHTTPVersion = "HTTPv1" + HTTPLocationGetParamsHTTPVersionHttPv2 HTTPLocationGetParamsHTTPVersion = "HTTPv2" + HTTPLocationGetParamsHTTPVersionHttPv3 HTTPLocationGetParamsHTTPVersion = "HTTPv3" +) + +type HTTPLocationGetParamsIPVersion string + +const ( + HTTPLocationGetParamsIPVersionIPv4 HTTPLocationGetParamsIPVersion = "IPv4" + HTTPLocationGetParamsIPVersionIPv6 HTTPLocationGetParamsIPVersion = "IPv6" +) + +type HTTPLocationGetParamsOS string + +const ( + HTTPLocationGetParamsOSWindows HTTPLocationGetParamsOS = "WINDOWS" + HTTPLocationGetParamsOSMacosx HTTPLocationGetParamsOS = "MACOSX" + HTTPLocationGetParamsOSIos HTTPLocationGetParamsOS = "IOS" + HTTPLocationGetParamsOSAndroid HTTPLocationGetParamsOS = "ANDROID" + HTTPLocationGetParamsOSChromeos HTTPLocationGetParamsOS = "CHROMEOS" + HTTPLocationGetParamsOSLinux HTTPLocationGetParamsOS = "LINUX" + HTTPLocationGetParamsOSSmartTv HTTPLocationGetParamsOS = "SMART_TV" +) + +type HTTPLocationGetParamsTLSVersion string + +const ( + HTTPLocationGetParamsTLSVersionTlSv1_0 HTTPLocationGetParamsTLSVersion = "TLSv1_0" + HTTPLocationGetParamsTLSVersionTlSv1_1 HTTPLocationGetParamsTLSVersion = "TLSv1_1" + HTTPLocationGetParamsTLSVersionTlSv1_2 HTTPLocationGetParamsTLSVersion = "TLSv1_2" + HTTPLocationGetParamsTLSVersionTlSv1_3 HTTPLocationGetParamsTLSVersion = "TLSv1_3" + HTTPLocationGetParamsTLSVersionTlSvQuic HTTPLocationGetParamsTLSVersion = "TLSvQUIC" +) + +type HTTPLocationGetResponseEnvelope struct { + Result HTTPLocationGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpLocationGetResponseEnvelopeJSON `json:"-"` +} + +// httpLocationGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [HTTPLocationGetResponseEnvelope] +type httpLocationGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httplocation_test.go b/radar/httplocation_test.go new file mode 100644 index 00000000000..a54edbe2c35 --- /dev/null +++ b/radar/httplocation_test.go @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPLocationGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Locations.Get(context.TODO(), radar.HTTPLocationGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPLocationGetParamsBotClass{radar.HTTPLocationGetParamsBotClassLikelyAutomated, radar.HTTPLocationGetParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPLocationGetParamsDateRange{radar.HTTPLocationGetParamsDateRange1d, radar.HTTPLocationGetParamsDateRange2d, radar.HTTPLocationGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPLocationGetParamsDeviceType{radar.HTTPLocationGetParamsDeviceTypeDesktop, radar.HTTPLocationGetParamsDeviceTypeMobile, radar.HTTPLocationGetParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPLocationGetParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPLocationGetParamsHTTPProtocol{radar.HTTPLocationGetParamsHTTPProtocolHTTP, radar.HTTPLocationGetParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPLocationGetParamsHTTPVersion{radar.HTTPLocationGetParamsHTTPVersionHttPv1, radar.HTTPLocationGetParamsHTTPVersionHttPv2, radar.HTTPLocationGetParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPLocationGetParamsIPVersion{radar.HTTPLocationGetParamsIPVersionIPv4, radar.HTTPLocationGetParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPLocationGetParamsOS{radar.HTTPLocationGetParamsOSWindows, radar.HTTPLocationGetParamsOSMacosx, radar.HTTPLocationGetParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPLocationGetParamsTLSVersion{radar.HTTPLocationGetParamsTLSVersionTlSv1_0, radar.HTTPLocationGetParamsTLSVersionTlSv1_1, radar.HTTPLocationGetParamsTLSVersionTlSv1_2}), + }) + 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/radar/httplocationbotclass.go b/radar/httplocationbotclass.go new file mode 100644 index 00000000000..efaa36d6d63 --- /dev/null +++ b/radar/httplocationbotclass.go @@ -0,0 +1,367 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPLocationBotClassService 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 [NewHTTPLocationBotClassService] +// method instead. +type HTTPLocationBotClassService struct { + Options []option.RequestOption +} + +// NewHTTPLocationBotClassService 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 NewHTTPLocationBotClassService(opts ...option.RequestOption) (r *HTTPLocationBotClassService) { + r = &HTTPLocationBotClassService{} + r.Options = opts + return +} + +// Get the top locations, by HTTP traffic, of the requested bot class. These two +// categories use Cloudflare's bot score - refer to [Bot +// scores])https://developers.cloudflare.com/bots/concepts/bot-score). Values are a +// percentage out of the total traffic. +func (r *HTTPLocationBotClassService) Get(ctx context.Context, botClass HTTPLocationBotClassGetParamsBotClass, query HTTPLocationBotClassGetParams, opts ...option.RequestOption) (res *HTTPLocationBotClassGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPLocationBotClassGetResponseEnvelope + path := fmt.Sprintf("radar/http/top/locations/bot_class/%v", botClass) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPLocationBotClassGetResponse struct { + Meta HTTPLocationBotClassGetResponseMeta `json:"meta,required"` + Top0 []HTTPLocationBotClassGetResponseTop0 `json:"top_0,required"` + JSON httpLocationBotClassGetResponseJSON `json:"-"` +} + +// httpLocationBotClassGetResponseJSON contains the JSON metadata for the struct +// [HTTPLocationBotClassGetResponse] +type httpLocationBotClassGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationBotClassGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationBotClassGetResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationBotClassGetResponseMeta struct { + DateRange []HTTPLocationBotClassGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo HTTPLocationBotClassGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpLocationBotClassGetResponseMetaJSON `json:"-"` +} + +// httpLocationBotClassGetResponseMetaJSON contains the JSON metadata for the +// struct [HTTPLocationBotClassGetResponseMeta] +type httpLocationBotClassGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationBotClassGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationBotClassGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationBotClassGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpLocationBotClassGetResponseMetaDateRangeJSON `json:"-"` +} + +// httpLocationBotClassGetResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [HTTPLocationBotClassGetResponseMetaDateRange] +type httpLocationBotClassGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationBotClassGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationBotClassGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationBotClassGetResponseMetaConfidenceInfo struct { + Annotations []HTTPLocationBotClassGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpLocationBotClassGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpLocationBotClassGetResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [HTTPLocationBotClassGetResponseMetaConfidenceInfo] +type httpLocationBotClassGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationBotClassGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationBotClassGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationBotClassGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpLocationBotClassGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpLocationBotClassGetResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [HTTPLocationBotClassGetResponseMetaConfidenceInfoAnnotation] +type httpLocationBotClassGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationBotClassGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationBotClassGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationBotClassGetResponseTop0 struct { + ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` + ClientCountryName string `json:"clientCountryName,required"` + Value string `json:"value,required"` + JSON httpLocationBotClassGetResponseTop0JSON `json:"-"` +} + +// httpLocationBotClassGetResponseTop0JSON contains the JSON metadata for the +// struct [HTTPLocationBotClassGetResponseTop0] +type httpLocationBotClassGetResponseTop0JSON struct { + ClientCountryAlpha2 apijson.Field + ClientCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationBotClassGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationBotClassGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type HTTPLocationBotClassGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPLocationBotClassGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPLocationBotClassGetParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPLocationBotClassGetParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPLocationBotClassGetParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPLocationBotClassGetParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPLocationBotClassGetParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPLocationBotClassGetParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPLocationBotClassGetParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPLocationBotClassGetParams]'s query parameters as +// `url.Values`. +func (r HTTPLocationBotClassGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Bot class. +type HTTPLocationBotClassGetParamsBotClass string + +const ( + HTTPLocationBotClassGetParamsBotClassLikelyAutomated HTTPLocationBotClassGetParamsBotClass = "LIKELY_AUTOMATED" + HTTPLocationBotClassGetParamsBotClassLikelyHuman HTTPLocationBotClassGetParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPLocationBotClassGetParamsDateRange string + +const ( + HTTPLocationBotClassGetParamsDateRange1d HTTPLocationBotClassGetParamsDateRange = "1d" + HTTPLocationBotClassGetParamsDateRange2d HTTPLocationBotClassGetParamsDateRange = "2d" + HTTPLocationBotClassGetParamsDateRange7d HTTPLocationBotClassGetParamsDateRange = "7d" + HTTPLocationBotClassGetParamsDateRange14d HTTPLocationBotClassGetParamsDateRange = "14d" + HTTPLocationBotClassGetParamsDateRange28d HTTPLocationBotClassGetParamsDateRange = "28d" + HTTPLocationBotClassGetParamsDateRange12w HTTPLocationBotClassGetParamsDateRange = "12w" + HTTPLocationBotClassGetParamsDateRange24w HTTPLocationBotClassGetParamsDateRange = "24w" + HTTPLocationBotClassGetParamsDateRange52w HTTPLocationBotClassGetParamsDateRange = "52w" + HTTPLocationBotClassGetParamsDateRange1dControl HTTPLocationBotClassGetParamsDateRange = "1dControl" + HTTPLocationBotClassGetParamsDateRange2dControl HTTPLocationBotClassGetParamsDateRange = "2dControl" + HTTPLocationBotClassGetParamsDateRange7dControl HTTPLocationBotClassGetParamsDateRange = "7dControl" + HTTPLocationBotClassGetParamsDateRange14dControl HTTPLocationBotClassGetParamsDateRange = "14dControl" + HTTPLocationBotClassGetParamsDateRange28dControl HTTPLocationBotClassGetParamsDateRange = "28dControl" + HTTPLocationBotClassGetParamsDateRange12wControl HTTPLocationBotClassGetParamsDateRange = "12wControl" + HTTPLocationBotClassGetParamsDateRange24wControl HTTPLocationBotClassGetParamsDateRange = "24wControl" +) + +type HTTPLocationBotClassGetParamsDeviceType string + +const ( + HTTPLocationBotClassGetParamsDeviceTypeDesktop HTTPLocationBotClassGetParamsDeviceType = "DESKTOP" + HTTPLocationBotClassGetParamsDeviceTypeMobile HTTPLocationBotClassGetParamsDeviceType = "MOBILE" + HTTPLocationBotClassGetParamsDeviceTypeOther HTTPLocationBotClassGetParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPLocationBotClassGetParamsFormat string + +const ( + HTTPLocationBotClassGetParamsFormatJson HTTPLocationBotClassGetParamsFormat = "JSON" + HTTPLocationBotClassGetParamsFormatCsv HTTPLocationBotClassGetParamsFormat = "CSV" +) + +type HTTPLocationBotClassGetParamsHTTPProtocol string + +const ( + HTTPLocationBotClassGetParamsHTTPProtocolHTTP HTTPLocationBotClassGetParamsHTTPProtocol = "HTTP" + HTTPLocationBotClassGetParamsHTTPProtocolHTTPS HTTPLocationBotClassGetParamsHTTPProtocol = "HTTPS" +) + +type HTTPLocationBotClassGetParamsHTTPVersion string + +const ( + HTTPLocationBotClassGetParamsHTTPVersionHttPv1 HTTPLocationBotClassGetParamsHTTPVersion = "HTTPv1" + HTTPLocationBotClassGetParamsHTTPVersionHttPv2 HTTPLocationBotClassGetParamsHTTPVersion = "HTTPv2" + HTTPLocationBotClassGetParamsHTTPVersionHttPv3 HTTPLocationBotClassGetParamsHTTPVersion = "HTTPv3" +) + +type HTTPLocationBotClassGetParamsIPVersion string + +const ( + HTTPLocationBotClassGetParamsIPVersionIPv4 HTTPLocationBotClassGetParamsIPVersion = "IPv4" + HTTPLocationBotClassGetParamsIPVersionIPv6 HTTPLocationBotClassGetParamsIPVersion = "IPv6" +) + +type HTTPLocationBotClassGetParamsOS string + +const ( + HTTPLocationBotClassGetParamsOSWindows HTTPLocationBotClassGetParamsOS = "WINDOWS" + HTTPLocationBotClassGetParamsOSMacosx HTTPLocationBotClassGetParamsOS = "MACOSX" + HTTPLocationBotClassGetParamsOSIos HTTPLocationBotClassGetParamsOS = "IOS" + HTTPLocationBotClassGetParamsOSAndroid HTTPLocationBotClassGetParamsOS = "ANDROID" + HTTPLocationBotClassGetParamsOSChromeos HTTPLocationBotClassGetParamsOS = "CHROMEOS" + HTTPLocationBotClassGetParamsOSLinux HTTPLocationBotClassGetParamsOS = "LINUX" + HTTPLocationBotClassGetParamsOSSmartTv HTTPLocationBotClassGetParamsOS = "SMART_TV" +) + +type HTTPLocationBotClassGetParamsTLSVersion string + +const ( + HTTPLocationBotClassGetParamsTLSVersionTlSv1_0 HTTPLocationBotClassGetParamsTLSVersion = "TLSv1_0" + HTTPLocationBotClassGetParamsTLSVersionTlSv1_1 HTTPLocationBotClassGetParamsTLSVersion = "TLSv1_1" + HTTPLocationBotClassGetParamsTLSVersionTlSv1_2 HTTPLocationBotClassGetParamsTLSVersion = "TLSv1_2" + HTTPLocationBotClassGetParamsTLSVersionTlSv1_3 HTTPLocationBotClassGetParamsTLSVersion = "TLSv1_3" + HTTPLocationBotClassGetParamsTLSVersionTlSvQuic HTTPLocationBotClassGetParamsTLSVersion = "TLSvQUIC" +) + +type HTTPLocationBotClassGetResponseEnvelope struct { + Result HTTPLocationBotClassGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpLocationBotClassGetResponseEnvelopeJSON `json:"-"` +} + +// httpLocationBotClassGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [HTTPLocationBotClassGetResponseEnvelope] +type httpLocationBotClassGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationBotClassGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationBotClassGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httplocationbotclass_test.go b/radar/httplocationbotclass_test.go new file mode 100644 index 00000000000..d961f529e2f --- /dev/null +++ b/radar/httplocationbotclass_test.go @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPLocationBotClassGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Locations.BotClass.Get( + context.TODO(), + radar.HTTPLocationBotClassGetParamsBotClassLikelyAutomated, + radar.HTTPLocationBotClassGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPLocationBotClassGetParamsDateRange{radar.HTTPLocationBotClassGetParamsDateRange1d, radar.HTTPLocationBotClassGetParamsDateRange2d, radar.HTTPLocationBotClassGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPLocationBotClassGetParamsDeviceType{radar.HTTPLocationBotClassGetParamsDeviceTypeDesktop, radar.HTTPLocationBotClassGetParamsDeviceTypeMobile, radar.HTTPLocationBotClassGetParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPLocationBotClassGetParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPLocationBotClassGetParamsHTTPProtocol{radar.HTTPLocationBotClassGetParamsHTTPProtocolHTTP, radar.HTTPLocationBotClassGetParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPLocationBotClassGetParamsHTTPVersion{radar.HTTPLocationBotClassGetParamsHTTPVersionHttPv1, radar.HTTPLocationBotClassGetParamsHTTPVersionHttPv2, radar.HTTPLocationBotClassGetParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPLocationBotClassGetParamsIPVersion{radar.HTTPLocationBotClassGetParamsIPVersionIPv4, radar.HTTPLocationBotClassGetParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPLocationBotClassGetParamsOS{radar.HTTPLocationBotClassGetParamsOSWindows, radar.HTTPLocationBotClassGetParamsOSMacosx, radar.HTTPLocationBotClassGetParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPLocationBotClassGetParamsTLSVersion{radar.HTTPLocationBotClassGetParamsTLSVersionTlSv1_0, radar.HTTPLocationBotClassGetParamsTLSVersionTlSv1_1, radar.HTTPLocationBotClassGetParamsTLSVersionTlSv1_2}), + }, + ) + 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/radar/httplocationdevicetype.go b/radar/httplocationdevicetype.go new file mode 100644 index 00000000000..f3c410c10f3 --- /dev/null +++ b/radar/httplocationdevicetype.go @@ -0,0 +1,366 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPLocationDeviceTypeService 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 [NewHTTPLocationDeviceTypeService] +// method instead. +type HTTPLocationDeviceTypeService struct { + Options []option.RequestOption +} + +// NewHTTPLocationDeviceTypeService 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 NewHTTPLocationDeviceTypeService(opts ...option.RequestOption) (r *HTTPLocationDeviceTypeService) { + r = &HTTPLocationDeviceTypeService{} + r.Options = opts + return +} + +// Get the top locations, by HTTP traffic, of the requested device type. Values are +// a percentage out of the total traffic. +func (r *HTTPLocationDeviceTypeService) Get(ctx context.Context, deviceType HTTPLocationDeviceTypeGetParamsDeviceType, query HTTPLocationDeviceTypeGetParams, opts ...option.RequestOption) (res *HTTPLocationDeviceTypeGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPLocationDeviceTypeGetResponseEnvelope + path := fmt.Sprintf("radar/http/top/locations/device_type/%v", deviceType) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPLocationDeviceTypeGetResponse struct { + Meta HTTPLocationDeviceTypeGetResponseMeta `json:"meta,required"` + Top0 []HTTPLocationDeviceTypeGetResponseTop0 `json:"top_0,required"` + JSON httpLocationDeviceTypeGetResponseJSON `json:"-"` +} + +// httpLocationDeviceTypeGetResponseJSON contains the JSON metadata for the struct +// [HTTPLocationDeviceTypeGetResponse] +type httpLocationDeviceTypeGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationDeviceTypeGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationDeviceTypeGetResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationDeviceTypeGetResponseMeta struct { + DateRange []HTTPLocationDeviceTypeGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo HTTPLocationDeviceTypeGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpLocationDeviceTypeGetResponseMetaJSON `json:"-"` +} + +// httpLocationDeviceTypeGetResponseMetaJSON contains the JSON metadata for the +// struct [HTTPLocationDeviceTypeGetResponseMeta] +type httpLocationDeviceTypeGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationDeviceTypeGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationDeviceTypeGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationDeviceTypeGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpLocationDeviceTypeGetResponseMetaDateRangeJSON `json:"-"` +} + +// httpLocationDeviceTypeGetResponseMetaDateRangeJSON contains the JSON metadata +// for the struct [HTTPLocationDeviceTypeGetResponseMetaDateRange] +type httpLocationDeviceTypeGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationDeviceTypeGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationDeviceTypeGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationDeviceTypeGetResponseMetaConfidenceInfo struct { + Annotations []HTTPLocationDeviceTypeGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpLocationDeviceTypeGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpLocationDeviceTypeGetResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [HTTPLocationDeviceTypeGetResponseMetaConfidenceInfo] +type httpLocationDeviceTypeGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationDeviceTypeGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationDeviceTypeGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationDeviceTypeGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpLocationDeviceTypeGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpLocationDeviceTypeGetResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [HTTPLocationDeviceTypeGetResponseMetaConfidenceInfoAnnotation] +type httpLocationDeviceTypeGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationDeviceTypeGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationDeviceTypeGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationDeviceTypeGetResponseTop0 struct { + ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` + ClientCountryName string `json:"clientCountryName,required"` + Value string `json:"value,required"` + JSON httpLocationDeviceTypeGetResponseTop0JSON `json:"-"` +} + +// httpLocationDeviceTypeGetResponseTop0JSON contains the JSON metadata for the +// struct [HTTPLocationDeviceTypeGetResponseTop0] +type httpLocationDeviceTypeGetResponseTop0JSON struct { + ClientCountryAlpha2 apijson.Field + ClientCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationDeviceTypeGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationDeviceTypeGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type HTTPLocationDeviceTypeGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPLocationDeviceTypeGetParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPLocationDeviceTypeGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[HTTPLocationDeviceTypeGetParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPLocationDeviceTypeGetParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPLocationDeviceTypeGetParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPLocationDeviceTypeGetParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPLocationDeviceTypeGetParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPLocationDeviceTypeGetParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPLocationDeviceTypeGetParams]'s query parameters as +// `url.Values`. +func (r HTTPLocationDeviceTypeGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Device type. +type HTTPLocationDeviceTypeGetParamsDeviceType string + +const ( + HTTPLocationDeviceTypeGetParamsDeviceTypeDesktop HTTPLocationDeviceTypeGetParamsDeviceType = "DESKTOP" + HTTPLocationDeviceTypeGetParamsDeviceTypeMobile HTTPLocationDeviceTypeGetParamsDeviceType = "MOBILE" + HTTPLocationDeviceTypeGetParamsDeviceTypeOther HTTPLocationDeviceTypeGetParamsDeviceType = "OTHER" +) + +type HTTPLocationDeviceTypeGetParamsBotClass string + +const ( + HTTPLocationDeviceTypeGetParamsBotClassLikelyAutomated HTTPLocationDeviceTypeGetParamsBotClass = "LIKELY_AUTOMATED" + HTTPLocationDeviceTypeGetParamsBotClassLikelyHuman HTTPLocationDeviceTypeGetParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPLocationDeviceTypeGetParamsDateRange string + +const ( + HTTPLocationDeviceTypeGetParamsDateRange1d HTTPLocationDeviceTypeGetParamsDateRange = "1d" + HTTPLocationDeviceTypeGetParamsDateRange2d HTTPLocationDeviceTypeGetParamsDateRange = "2d" + HTTPLocationDeviceTypeGetParamsDateRange7d HTTPLocationDeviceTypeGetParamsDateRange = "7d" + HTTPLocationDeviceTypeGetParamsDateRange14d HTTPLocationDeviceTypeGetParamsDateRange = "14d" + HTTPLocationDeviceTypeGetParamsDateRange28d HTTPLocationDeviceTypeGetParamsDateRange = "28d" + HTTPLocationDeviceTypeGetParamsDateRange12w HTTPLocationDeviceTypeGetParamsDateRange = "12w" + HTTPLocationDeviceTypeGetParamsDateRange24w HTTPLocationDeviceTypeGetParamsDateRange = "24w" + HTTPLocationDeviceTypeGetParamsDateRange52w HTTPLocationDeviceTypeGetParamsDateRange = "52w" + HTTPLocationDeviceTypeGetParamsDateRange1dControl HTTPLocationDeviceTypeGetParamsDateRange = "1dControl" + HTTPLocationDeviceTypeGetParamsDateRange2dControl HTTPLocationDeviceTypeGetParamsDateRange = "2dControl" + HTTPLocationDeviceTypeGetParamsDateRange7dControl HTTPLocationDeviceTypeGetParamsDateRange = "7dControl" + HTTPLocationDeviceTypeGetParamsDateRange14dControl HTTPLocationDeviceTypeGetParamsDateRange = "14dControl" + HTTPLocationDeviceTypeGetParamsDateRange28dControl HTTPLocationDeviceTypeGetParamsDateRange = "28dControl" + HTTPLocationDeviceTypeGetParamsDateRange12wControl HTTPLocationDeviceTypeGetParamsDateRange = "12wControl" + HTTPLocationDeviceTypeGetParamsDateRange24wControl HTTPLocationDeviceTypeGetParamsDateRange = "24wControl" +) + +// Format results are returned in. +type HTTPLocationDeviceTypeGetParamsFormat string + +const ( + HTTPLocationDeviceTypeGetParamsFormatJson HTTPLocationDeviceTypeGetParamsFormat = "JSON" + HTTPLocationDeviceTypeGetParamsFormatCsv HTTPLocationDeviceTypeGetParamsFormat = "CSV" +) + +type HTTPLocationDeviceTypeGetParamsHTTPProtocol string + +const ( + HTTPLocationDeviceTypeGetParamsHTTPProtocolHTTP HTTPLocationDeviceTypeGetParamsHTTPProtocol = "HTTP" + HTTPLocationDeviceTypeGetParamsHTTPProtocolHTTPS HTTPLocationDeviceTypeGetParamsHTTPProtocol = "HTTPS" +) + +type HTTPLocationDeviceTypeGetParamsHTTPVersion string + +const ( + HTTPLocationDeviceTypeGetParamsHTTPVersionHttPv1 HTTPLocationDeviceTypeGetParamsHTTPVersion = "HTTPv1" + HTTPLocationDeviceTypeGetParamsHTTPVersionHttPv2 HTTPLocationDeviceTypeGetParamsHTTPVersion = "HTTPv2" + HTTPLocationDeviceTypeGetParamsHTTPVersionHttPv3 HTTPLocationDeviceTypeGetParamsHTTPVersion = "HTTPv3" +) + +type HTTPLocationDeviceTypeGetParamsIPVersion string + +const ( + HTTPLocationDeviceTypeGetParamsIPVersionIPv4 HTTPLocationDeviceTypeGetParamsIPVersion = "IPv4" + HTTPLocationDeviceTypeGetParamsIPVersionIPv6 HTTPLocationDeviceTypeGetParamsIPVersion = "IPv6" +) + +type HTTPLocationDeviceTypeGetParamsOS string + +const ( + HTTPLocationDeviceTypeGetParamsOSWindows HTTPLocationDeviceTypeGetParamsOS = "WINDOWS" + HTTPLocationDeviceTypeGetParamsOSMacosx HTTPLocationDeviceTypeGetParamsOS = "MACOSX" + HTTPLocationDeviceTypeGetParamsOSIos HTTPLocationDeviceTypeGetParamsOS = "IOS" + HTTPLocationDeviceTypeGetParamsOSAndroid HTTPLocationDeviceTypeGetParamsOS = "ANDROID" + HTTPLocationDeviceTypeGetParamsOSChromeos HTTPLocationDeviceTypeGetParamsOS = "CHROMEOS" + HTTPLocationDeviceTypeGetParamsOSLinux HTTPLocationDeviceTypeGetParamsOS = "LINUX" + HTTPLocationDeviceTypeGetParamsOSSmartTv HTTPLocationDeviceTypeGetParamsOS = "SMART_TV" +) + +type HTTPLocationDeviceTypeGetParamsTLSVersion string + +const ( + HTTPLocationDeviceTypeGetParamsTLSVersionTlSv1_0 HTTPLocationDeviceTypeGetParamsTLSVersion = "TLSv1_0" + HTTPLocationDeviceTypeGetParamsTLSVersionTlSv1_1 HTTPLocationDeviceTypeGetParamsTLSVersion = "TLSv1_1" + HTTPLocationDeviceTypeGetParamsTLSVersionTlSv1_2 HTTPLocationDeviceTypeGetParamsTLSVersion = "TLSv1_2" + HTTPLocationDeviceTypeGetParamsTLSVersionTlSv1_3 HTTPLocationDeviceTypeGetParamsTLSVersion = "TLSv1_3" + HTTPLocationDeviceTypeGetParamsTLSVersionTlSvQuic HTTPLocationDeviceTypeGetParamsTLSVersion = "TLSvQUIC" +) + +type HTTPLocationDeviceTypeGetResponseEnvelope struct { + Result HTTPLocationDeviceTypeGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpLocationDeviceTypeGetResponseEnvelopeJSON `json:"-"` +} + +// httpLocationDeviceTypeGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [HTTPLocationDeviceTypeGetResponseEnvelope] +type httpLocationDeviceTypeGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationDeviceTypeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationDeviceTypeGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httplocationdevicetype_test.go b/radar/httplocationdevicetype_test.go new file mode 100644 index 00000000000..77289a629de --- /dev/null +++ b/radar/httplocationdevicetype_test.go @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPLocationDeviceTypeGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Locations.DeviceType.Get( + context.TODO(), + radar.HTTPLocationDeviceTypeGetParamsDeviceTypeDesktop, + radar.HTTPLocationDeviceTypeGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPLocationDeviceTypeGetParamsBotClass{radar.HTTPLocationDeviceTypeGetParamsBotClassLikelyAutomated, radar.HTTPLocationDeviceTypeGetParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPLocationDeviceTypeGetParamsDateRange{radar.HTTPLocationDeviceTypeGetParamsDateRange1d, radar.HTTPLocationDeviceTypeGetParamsDateRange2d, radar.HTTPLocationDeviceTypeGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.HTTPLocationDeviceTypeGetParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPLocationDeviceTypeGetParamsHTTPProtocol{radar.HTTPLocationDeviceTypeGetParamsHTTPProtocolHTTP, radar.HTTPLocationDeviceTypeGetParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPLocationDeviceTypeGetParamsHTTPVersion{radar.HTTPLocationDeviceTypeGetParamsHTTPVersionHttPv1, radar.HTTPLocationDeviceTypeGetParamsHTTPVersionHttPv2, radar.HTTPLocationDeviceTypeGetParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPLocationDeviceTypeGetParamsIPVersion{radar.HTTPLocationDeviceTypeGetParamsIPVersionIPv4, radar.HTTPLocationDeviceTypeGetParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPLocationDeviceTypeGetParamsOS{radar.HTTPLocationDeviceTypeGetParamsOSWindows, radar.HTTPLocationDeviceTypeGetParamsOSMacosx, radar.HTTPLocationDeviceTypeGetParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPLocationDeviceTypeGetParamsTLSVersion{radar.HTTPLocationDeviceTypeGetParamsTLSVersionTlSv1_0, radar.HTTPLocationDeviceTypeGetParamsTLSVersionTlSv1_1, radar.HTTPLocationDeviceTypeGetParamsTLSVersionTlSv1_2}), + }, + ) + 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/radar/httplocationhttpmethod.go b/radar/httplocationhttpmethod.go new file mode 100644 index 00000000000..c15c739d246 --- /dev/null +++ b/radar/httplocationhttpmethod.go @@ -0,0 +1,366 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPLocationHTTPMethodService 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 [NewHTTPLocationHTTPMethodService] +// method instead. +type HTTPLocationHTTPMethodService struct { + Options []option.RequestOption +} + +// NewHTTPLocationHTTPMethodService 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 NewHTTPLocationHTTPMethodService(opts ...option.RequestOption) (r *HTTPLocationHTTPMethodService) { + r = &HTTPLocationHTTPMethodService{} + r.Options = opts + return +} + +// Get the top locations, by HTTP traffic, of the requested HTTP protocol. Values +// are a percentage out of the total traffic. +func (r *HTTPLocationHTTPMethodService) Get(ctx context.Context, httpVersion HTTPLocationHTTPMethodGetParamsHTTPVersion, query HTTPLocationHTTPMethodGetParams, opts ...option.RequestOption) (res *HTTPLocationHTTPMethodGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPLocationHTTPMethodGetResponseEnvelope + path := fmt.Sprintf("radar/http/top/locations/http_version/%v", httpVersion) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPLocationHTTPMethodGetResponse struct { + Meta HTTPLocationHTTPMethodGetResponseMeta `json:"meta,required"` + Top0 []HTTPLocationHTTPMethodGetResponseTop0 `json:"top_0,required"` + JSON httpLocationHTTPMethodGetResponseJSON `json:"-"` +} + +// httpLocationHTTPMethodGetResponseJSON contains the JSON metadata for the struct +// [HTTPLocationHTTPMethodGetResponse] +type httpLocationHTTPMethodGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationHTTPMethodGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationHTTPMethodGetResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationHTTPMethodGetResponseMeta struct { + DateRange []HTTPLocationHTTPMethodGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo HTTPLocationHTTPMethodGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpLocationHTTPMethodGetResponseMetaJSON `json:"-"` +} + +// httpLocationHTTPMethodGetResponseMetaJSON contains the JSON metadata for the +// struct [HTTPLocationHTTPMethodGetResponseMeta] +type httpLocationHTTPMethodGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationHTTPMethodGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationHTTPMethodGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationHTTPMethodGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpLocationHTTPMethodGetResponseMetaDateRangeJSON `json:"-"` +} + +// httpLocationHTTPMethodGetResponseMetaDateRangeJSON contains the JSON metadata +// for the struct [HTTPLocationHTTPMethodGetResponseMetaDateRange] +type httpLocationHTTPMethodGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationHTTPMethodGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationHTTPMethodGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationHTTPMethodGetResponseMetaConfidenceInfo struct { + Annotations []HTTPLocationHTTPMethodGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpLocationHTTPMethodGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpLocationHTTPMethodGetResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [HTTPLocationHTTPMethodGetResponseMetaConfidenceInfo] +type httpLocationHTTPMethodGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationHTTPMethodGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationHTTPMethodGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationHTTPMethodGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpLocationHTTPMethodGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpLocationHTTPMethodGetResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [HTTPLocationHTTPMethodGetResponseMetaConfidenceInfoAnnotation] +type httpLocationHTTPMethodGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationHTTPMethodGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationHTTPMethodGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationHTTPMethodGetResponseTop0 struct { + ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` + ClientCountryName string `json:"clientCountryName,required"` + Value string `json:"value,required"` + JSON httpLocationHTTPMethodGetResponseTop0JSON `json:"-"` +} + +// httpLocationHTTPMethodGetResponseTop0JSON contains the JSON metadata for the +// struct [HTTPLocationHTTPMethodGetResponseTop0] +type httpLocationHTTPMethodGetResponseTop0JSON struct { + ClientCountryAlpha2 apijson.Field + ClientCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationHTTPMethodGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationHTTPMethodGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type HTTPLocationHTTPMethodGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPLocationHTTPMethodGetParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPLocationHTTPMethodGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPLocationHTTPMethodGetParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPLocationHTTPMethodGetParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPLocationHTTPMethodGetParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for ip version. + IPVersion param.Field[[]HTTPLocationHTTPMethodGetParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPLocationHTTPMethodGetParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPLocationHTTPMethodGetParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPLocationHTTPMethodGetParams]'s query parameters as +// `url.Values`. +func (r HTTPLocationHTTPMethodGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// HTTP version. +type HTTPLocationHTTPMethodGetParamsHTTPVersion string + +const ( + HTTPLocationHTTPMethodGetParamsHTTPVersionHttPv1 HTTPLocationHTTPMethodGetParamsHTTPVersion = "HTTPv1" + HTTPLocationHTTPMethodGetParamsHTTPVersionHttPv2 HTTPLocationHTTPMethodGetParamsHTTPVersion = "HTTPv2" + HTTPLocationHTTPMethodGetParamsHTTPVersionHttPv3 HTTPLocationHTTPMethodGetParamsHTTPVersion = "HTTPv3" +) + +type HTTPLocationHTTPMethodGetParamsBotClass string + +const ( + HTTPLocationHTTPMethodGetParamsBotClassLikelyAutomated HTTPLocationHTTPMethodGetParamsBotClass = "LIKELY_AUTOMATED" + HTTPLocationHTTPMethodGetParamsBotClassLikelyHuman HTTPLocationHTTPMethodGetParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPLocationHTTPMethodGetParamsDateRange string + +const ( + HTTPLocationHTTPMethodGetParamsDateRange1d HTTPLocationHTTPMethodGetParamsDateRange = "1d" + HTTPLocationHTTPMethodGetParamsDateRange2d HTTPLocationHTTPMethodGetParamsDateRange = "2d" + HTTPLocationHTTPMethodGetParamsDateRange7d HTTPLocationHTTPMethodGetParamsDateRange = "7d" + HTTPLocationHTTPMethodGetParamsDateRange14d HTTPLocationHTTPMethodGetParamsDateRange = "14d" + HTTPLocationHTTPMethodGetParamsDateRange28d HTTPLocationHTTPMethodGetParamsDateRange = "28d" + HTTPLocationHTTPMethodGetParamsDateRange12w HTTPLocationHTTPMethodGetParamsDateRange = "12w" + HTTPLocationHTTPMethodGetParamsDateRange24w HTTPLocationHTTPMethodGetParamsDateRange = "24w" + HTTPLocationHTTPMethodGetParamsDateRange52w HTTPLocationHTTPMethodGetParamsDateRange = "52w" + HTTPLocationHTTPMethodGetParamsDateRange1dControl HTTPLocationHTTPMethodGetParamsDateRange = "1dControl" + HTTPLocationHTTPMethodGetParamsDateRange2dControl HTTPLocationHTTPMethodGetParamsDateRange = "2dControl" + HTTPLocationHTTPMethodGetParamsDateRange7dControl HTTPLocationHTTPMethodGetParamsDateRange = "7dControl" + HTTPLocationHTTPMethodGetParamsDateRange14dControl HTTPLocationHTTPMethodGetParamsDateRange = "14dControl" + HTTPLocationHTTPMethodGetParamsDateRange28dControl HTTPLocationHTTPMethodGetParamsDateRange = "28dControl" + HTTPLocationHTTPMethodGetParamsDateRange12wControl HTTPLocationHTTPMethodGetParamsDateRange = "12wControl" + HTTPLocationHTTPMethodGetParamsDateRange24wControl HTTPLocationHTTPMethodGetParamsDateRange = "24wControl" +) + +type HTTPLocationHTTPMethodGetParamsDeviceType string + +const ( + HTTPLocationHTTPMethodGetParamsDeviceTypeDesktop HTTPLocationHTTPMethodGetParamsDeviceType = "DESKTOP" + HTTPLocationHTTPMethodGetParamsDeviceTypeMobile HTTPLocationHTTPMethodGetParamsDeviceType = "MOBILE" + HTTPLocationHTTPMethodGetParamsDeviceTypeOther HTTPLocationHTTPMethodGetParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPLocationHTTPMethodGetParamsFormat string + +const ( + HTTPLocationHTTPMethodGetParamsFormatJson HTTPLocationHTTPMethodGetParamsFormat = "JSON" + HTTPLocationHTTPMethodGetParamsFormatCsv HTTPLocationHTTPMethodGetParamsFormat = "CSV" +) + +type HTTPLocationHTTPMethodGetParamsHTTPProtocol string + +const ( + HTTPLocationHTTPMethodGetParamsHTTPProtocolHTTP HTTPLocationHTTPMethodGetParamsHTTPProtocol = "HTTP" + HTTPLocationHTTPMethodGetParamsHTTPProtocolHTTPS HTTPLocationHTTPMethodGetParamsHTTPProtocol = "HTTPS" +) + +type HTTPLocationHTTPMethodGetParamsIPVersion string + +const ( + HTTPLocationHTTPMethodGetParamsIPVersionIPv4 HTTPLocationHTTPMethodGetParamsIPVersion = "IPv4" + HTTPLocationHTTPMethodGetParamsIPVersionIPv6 HTTPLocationHTTPMethodGetParamsIPVersion = "IPv6" +) + +type HTTPLocationHTTPMethodGetParamsOS string + +const ( + HTTPLocationHTTPMethodGetParamsOSWindows HTTPLocationHTTPMethodGetParamsOS = "WINDOWS" + HTTPLocationHTTPMethodGetParamsOSMacosx HTTPLocationHTTPMethodGetParamsOS = "MACOSX" + HTTPLocationHTTPMethodGetParamsOSIos HTTPLocationHTTPMethodGetParamsOS = "IOS" + HTTPLocationHTTPMethodGetParamsOSAndroid HTTPLocationHTTPMethodGetParamsOS = "ANDROID" + HTTPLocationHTTPMethodGetParamsOSChromeos HTTPLocationHTTPMethodGetParamsOS = "CHROMEOS" + HTTPLocationHTTPMethodGetParamsOSLinux HTTPLocationHTTPMethodGetParamsOS = "LINUX" + HTTPLocationHTTPMethodGetParamsOSSmartTv HTTPLocationHTTPMethodGetParamsOS = "SMART_TV" +) + +type HTTPLocationHTTPMethodGetParamsTLSVersion string + +const ( + HTTPLocationHTTPMethodGetParamsTLSVersionTlSv1_0 HTTPLocationHTTPMethodGetParamsTLSVersion = "TLSv1_0" + HTTPLocationHTTPMethodGetParamsTLSVersionTlSv1_1 HTTPLocationHTTPMethodGetParamsTLSVersion = "TLSv1_1" + HTTPLocationHTTPMethodGetParamsTLSVersionTlSv1_2 HTTPLocationHTTPMethodGetParamsTLSVersion = "TLSv1_2" + HTTPLocationHTTPMethodGetParamsTLSVersionTlSv1_3 HTTPLocationHTTPMethodGetParamsTLSVersion = "TLSv1_3" + HTTPLocationHTTPMethodGetParamsTLSVersionTlSvQuic HTTPLocationHTTPMethodGetParamsTLSVersion = "TLSvQUIC" +) + +type HTTPLocationHTTPMethodGetResponseEnvelope struct { + Result HTTPLocationHTTPMethodGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpLocationHTTPMethodGetResponseEnvelopeJSON `json:"-"` +} + +// httpLocationHTTPMethodGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [HTTPLocationHTTPMethodGetResponseEnvelope] +type httpLocationHTTPMethodGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationHTTPMethodGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationHTTPMethodGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httplocationhttpmethod_test.go b/radar/httplocationhttpmethod_test.go new file mode 100644 index 00000000000..cda9ab05bef --- /dev/null +++ b/radar/httplocationhttpmethod_test.go @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPLocationHTTPMethodGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Locations.HTTPMethod.Get( + context.TODO(), + radar.HTTPLocationHTTPMethodGetParamsHTTPVersionHttPv1, + radar.HTTPLocationHTTPMethodGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPLocationHTTPMethodGetParamsBotClass{radar.HTTPLocationHTTPMethodGetParamsBotClassLikelyAutomated, radar.HTTPLocationHTTPMethodGetParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPLocationHTTPMethodGetParamsDateRange{radar.HTTPLocationHTTPMethodGetParamsDateRange1d, radar.HTTPLocationHTTPMethodGetParamsDateRange2d, radar.HTTPLocationHTTPMethodGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPLocationHTTPMethodGetParamsDeviceType{radar.HTTPLocationHTTPMethodGetParamsDeviceTypeDesktop, radar.HTTPLocationHTTPMethodGetParamsDeviceTypeMobile, radar.HTTPLocationHTTPMethodGetParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPLocationHTTPMethodGetParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPLocationHTTPMethodGetParamsHTTPProtocol{radar.HTTPLocationHTTPMethodGetParamsHTTPProtocolHTTP, radar.HTTPLocationHTTPMethodGetParamsHTTPProtocolHTTPS}), + IPVersion: cloudflare.F([]radar.HTTPLocationHTTPMethodGetParamsIPVersion{radar.HTTPLocationHTTPMethodGetParamsIPVersionIPv4, radar.HTTPLocationHTTPMethodGetParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPLocationHTTPMethodGetParamsOS{radar.HTTPLocationHTTPMethodGetParamsOSWindows, radar.HTTPLocationHTTPMethodGetParamsOSMacosx, radar.HTTPLocationHTTPMethodGetParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPLocationHTTPMethodGetParamsTLSVersion{radar.HTTPLocationHTTPMethodGetParamsTLSVersionTlSv1_0, radar.HTTPLocationHTTPMethodGetParamsTLSVersionTlSv1_1, radar.HTTPLocationHTTPMethodGetParamsTLSVersionTlSv1_2}), + }, + ) + 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/radar/httplocationhttpprotocol.go b/radar/httplocationhttpprotocol.go new file mode 100644 index 00000000000..b6bf46dc843 --- /dev/null +++ b/radar/httplocationhttpprotocol.go @@ -0,0 +1,356 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPLocationHTTPProtocolService 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 +// [NewHTTPLocationHTTPProtocolService] method instead. +type HTTPLocationHTTPProtocolService struct { + Options []option.RequestOption +} + +// NewHTTPLocationHTTPProtocolService 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 NewHTTPLocationHTTPProtocolService(opts ...option.RequestOption) (r *HTTPLocationHTTPProtocolService) { + r = &HTTPLocationHTTPProtocolService{} + r.Options = opts + return +} + +// Get the top locations, by HTTP traffic, of the requested HTTP protocol. Values +// are a percentage out of the total traffic. +func (r *HTTPLocationHTTPProtocolService) Get(ctx context.Context, httpProtocol HTTPLocationHTTPProtocolGetParamsHTTPProtocol, query HTTPLocationHTTPProtocolGetParams, opts ...option.RequestOption) (res *HTTPLocationHTTPProtocolGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPLocationHTTPProtocolGetResponseEnvelope + path := fmt.Sprintf("radar/http/top/locations/http_protocol/%v", httpProtocol) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPLocationHTTPProtocolGetResponse struct { + Meta HTTPLocationHTTPProtocolGetResponseMeta `json:"meta,required"` + Top0 []HTTPLocationHTTPProtocolGetResponseTop0 `json:"top_0,required"` + JSON httpLocationHTTPProtocolGetResponseJSON `json:"-"` +} + +// httpLocationHTTPProtocolGetResponseJSON contains the JSON metadata for the +// struct [HTTPLocationHTTPProtocolGetResponse] +type httpLocationHTTPProtocolGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationHTTPProtocolGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationHTTPProtocolGetResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationHTTPProtocolGetResponseMeta struct { + DateRange []HTTPLocationHTTPProtocolGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo HTTPLocationHTTPProtocolGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpLocationHTTPProtocolGetResponseMetaJSON `json:"-"` +} + +// httpLocationHTTPProtocolGetResponseMetaJSON contains the JSON metadata for the +// struct [HTTPLocationHTTPProtocolGetResponseMeta] +type httpLocationHTTPProtocolGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationHTTPProtocolGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationHTTPProtocolGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationHTTPProtocolGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpLocationHTTPProtocolGetResponseMetaDateRangeJSON `json:"-"` +} + +// httpLocationHTTPProtocolGetResponseMetaDateRangeJSON contains the JSON metadata +// for the struct [HTTPLocationHTTPProtocolGetResponseMetaDateRange] +type httpLocationHTTPProtocolGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationHTTPProtocolGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationHTTPProtocolGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationHTTPProtocolGetResponseMetaConfidenceInfo struct { + Annotations []HTTPLocationHTTPProtocolGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpLocationHTTPProtocolGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpLocationHTTPProtocolGetResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [HTTPLocationHTTPProtocolGetResponseMetaConfidenceInfo] +type httpLocationHTTPProtocolGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationHTTPProtocolGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationHTTPProtocolGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationHTTPProtocolGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpLocationHTTPProtocolGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpLocationHTTPProtocolGetResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [HTTPLocationHTTPProtocolGetResponseMetaConfidenceInfoAnnotation] +type httpLocationHTTPProtocolGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationHTTPProtocolGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationHTTPProtocolGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationHTTPProtocolGetResponseTop0 struct { + ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` + ClientCountryName string `json:"clientCountryName,required"` + Value string `json:"value,required"` + JSON httpLocationHTTPProtocolGetResponseTop0JSON `json:"-"` +} + +// httpLocationHTTPProtocolGetResponseTop0JSON contains the JSON metadata for the +// struct [HTTPLocationHTTPProtocolGetResponseTop0] +type httpLocationHTTPProtocolGetResponseTop0JSON struct { + ClientCountryAlpha2 apijson.Field + ClientCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationHTTPProtocolGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationHTTPProtocolGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type HTTPLocationHTTPProtocolGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPLocationHTTPProtocolGetParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPLocationHTTPProtocolGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPLocationHTTPProtocolGetParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPLocationHTTPProtocolGetParamsFormat] `query:"format"` + // Filter for ip version. + IPVersion param.Field[[]HTTPLocationHTTPProtocolGetParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPLocationHTTPProtocolGetParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPLocationHTTPProtocolGetParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPLocationHTTPProtocolGetParams]'s query parameters as +// `url.Values`. +func (r HTTPLocationHTTPProtocolGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// HTTP Protocol. +type HTTPLocationHTTPProtocolGetParamsHTTPProtocol string + +const ( + HTTPLocationHTTPProtocolGetParamsHTTPProtocolHTTP HTTPLocationHTTPProtocolGetParamsHTTPProtocol = "HTTP" + HTTPLocationHTTPProtocolGetParamsHTTPProtocolHTTPS HTTPLocationHTTPProtocolGetParamsHTTPProtocol = "HTTPS" +) + +type HTTPLocationHTTPProtocolGetParamsBotClass string + +const ( + HTTPLocationHTTPProtocolGetParamsBotClassLikelyAutomated HTTPLocationHTTPProtocolGetParamsBotClass = "LIKELY_AUTOMATED" + HTTPLocationHTTPProtocolGetParamsBotClassLikelyHuman HTTPLocationHTTPProtocolGetParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPLocationHTTPProtocolGetParamsDateRange string + +const ( + HTTPLocationHTTPProtocolGetParamsDateRange1d HTTPLocationHTTPProtocolGetParamsDateRange = "1d" + HTTPLocationHTTPProtocolGetParamsDateRange2d HTTPLocationHTTPProtocolGetParamsDateRange = "2d" + HTTPLocationHTTPProtocolGetParamsDateRange7d HTTPLocationHTTPProtocolGetParamsDateRange = "7d" + HTTPLocationHTTPProtocolGetParamsDateRange14d HTTPLocationHTTPProtocolGetParamsDateRange = "14d" + HTTPLocationHTTPProtocolGetParamsDateRange28d HTTPLocationHTTPProtocolGetParamsDateRange = "28d" + HTTPLocationHTTPProtocolGetParamsDateRange12w HTTPLocationHTTPProtocolGetParamsDateRange = "12w" + HTTPLocationHTTPProtocolGetParamsDateRange24w HTTPLocationHTTPProtocolGetParamsDateRange = "24w" + HTTPLocationHTTPProtocolGetParamsDateRange52w HTTPLocationHTTPProtocolGetParamsDateRange = "52w" + HTTPLocationHTTPProtocolGetParamsDateRange1dControl HTTPLocationHTTPProtocolGetParamsDateRange = "1dControl" + HTTPLocationHTTPProtocolGetParamsDateRange2dControl HTTPLocationHTTPProtocolGetParamsDateRange = "2dControl" + HTTPLocationHTTPProtocolGetParamsDateRange7dControl HTTPLocationHTTPProtocolGetParamsDateRange = "7dControl" + HTTPLocationHTTPProtocolGetParamsDateRange14dControl HTTPLocationHTTPProtocolGetParamsDateRange = "14dControl" + HTTPLocationHTTPProtocolGetParamsDateRange28dControl HTTPLocationHTTPProtocolGetParamsDateRange = "28dControl" + HTTPLocationHTTPProtocolGetParamsDateRange12wControl HTTPLocationHTTPProtocolGetParamsDateRange = "12wControl" + HTTPLocationHTTPProtocolGetParamsDateRange24wControl HTTPLocationHTTPProtocolGetParamsDateRange = "24wControl" +) + +type HTTPLocationHTTPProtocolGetParamsDeviceType string + +const ( + HTTPLocationHTTPProtocolGetParamsDeviceTypeDesktop HTTPLocationHTTPProtocolGetParamsDeviceType = "DESKTOP" + HTTPLocationHTTPProtocolGetParamsDeviceTypeMobile HTTPLocationHTTPProtocolGetParamsDeviceType = "MOBILE" + HTTPLocationHTTPProtocolGetParamsDeviceTypeOther HTTPLocationHTTPProtocolGetParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPLocationHTTPProtocolGetParamsFormat string + +const ( + HTTPLocationHTTPProtocolGetParamsFormatJson HTTPLocationHTTPProtocolGetParamsFormat = "JSON" + HTTPLocationHTTPProtocolGetParamsFormatCsv HTTPLocationHTTPProtocolGetParamsFormat = "CSV" +) + +type HTTPLocationHTTPProtocolGetParamsIPVersion string + +const ( + HTTPLocationHTTPProtocolGetParamsIPVersionIPv4 HTTPLocationHTTPProtocolGetParamsIPVersion = "IPv4" + HTTPLocationHTTPProtocolGetParamsIPVersionIPv6 HTTPLocationHTTPProtocolGetParamsIPVersion = "IPv6" +) + +type HTTPLocationHTTPProtocolGetParamsOS string + +const ( + HTTPLocationHTTPProtocolGetParamsOSWindows HTTPLocationHTTPProtocolGetParamsOS = "WINDOWS" + HTTPLocationHTTPProtocolGetParamsOSMacosx HTTPLocationHTTPProtocolGetParamsOS = "MACOSX" + HTTPLocationHTTPProtocolGetParamsOSIos HTTPLocationHTTPProtocolGetParamsOS = "IOS" + HTTPLocationHTTPProtocolGetParamsOSAndroid HTTPLocationHTTPProtocolGetParamsOS = "ANDROID" + HTTPLocationHTTPProtocolGetParamsOSChromeos HTTPLocationHTTPProtocolGetParamsOS = "CHROMEOS" + HTTPLocationHTTPProtocolGetParamsOSLinux HTTPLocationHTTPProtocolGetParamsOS = "LINUX" + HTTPLocationHTTPProtocolGetParamsOSSmartTv HTTPLocationHTTPProtocolGetParamsOS = "SMART_TV" +) + +type HTTPLocationHTTPProtocolGetParamsTLSVersion string + +const ( + HTTPLocationHTTPProtocolGetParamsTLSVersionTlSv1_0 HTTPLocationHTTPProtocolGetParamsTLSVersion = "TLSv1_0" + HTTPLocationHTTPProtocolGetParamsTLSVersionTlSv1_1 HTTPLocationHTTPProtocolGetParamsTLSVersion = "TLSv1_1" + HTTPLocationHTTPProtocolGetParamsTLSVersionTlSv1_2 HTTPLocationHTTPProtocolGetParamsTLSVersion = "TLSv1_2" + HTTPLocationHTTPProtocolGetParamsTLSVersionTlSv1_3 HTTPLocationHTTPProtocolGetParamsTLSVersion = "TLSv1_3" + HTTPLocationHTTPProtocolGetParamsTLSVersionTlSvQuic HTTPLocationHTTPProtocolGetParamsTLSVersion = "TLSvQUIC" +) + +type HTTPLocationHTTPProtocolGetResponseEnvelope struct { + Result HTTPLocationHTTPProtocolGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpLocationHTTPProtocolGetResponseEnvelopeJSON `json:"-"` +} + +// httpLocationHTTPProtocolGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [HTTPLocationHTTPProtocolGetResponseEnvelope] +type httpLocationHTTPProtocolGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationHTTPProtocolGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationHTTPProtocolGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httplocationhttpprotocol_test.go b/radar/httplocationhttpprotocol_test.go new file mode 100644 index 00000000000..35a3c61d954 --- /dev/null +++ b/radar/httplocationhttpprotocol_test.go @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPLocationHTTPProtocolGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Locations.HTTPProtocol.Get( + context.TODO(), + radar.HTTPLocationHTTPProtocolGetParamsHTTPProtocolHTTP, + radar.HTTPLocationHTTPProtocolGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPLocationHTTPProtocolGetParamsBotClass{radar.HTTPLocationHTTPProtocolGetParamsBotClassLikelyAutomated, radar.HTTPLocationHTTPProtocolGetParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPLocationHTTPProtocolGetParamsDateRange{radar.HTTPLocationHTTPProtocolGetParamsDateRange1d, radar.HTTPLocationHTTPProtocolGetParamsDateRange2d, radar.HTTPLocationHTTPProtocolGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPLocationHTTPProtocolGetParamsDeviceType{radar.HTTPLocationHTTPProtocolGetParamsDeviceTypeDesktop, radar.HTTPLocationHTTPProtocolGetParamsDeviceTypeMobile, radar.HTTPLocationHTTPProtocolGetParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPLocationHTTPProtocolGetParamsFormatJson), + IPVersion: cloudflare.F([]radar.HTTPLocationHTTPProtocolGetParamsIPVersion{radar.HTTPLocationHTTPProtocolGetParamsIPVersionIPv4, radar.HTTPLocationHTTPProtocolGetParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPLocationHTTPProtocolGetParamsOS{radar.HTTPLocationHTTPProtocolGetParamsOSWindows, radar.HTTPLocationHTTPProtocolGetParamsOSMacosx, radar.HTTPLocationHTTPProtocolGetParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPLocationHTTPProtocolGetParamsTLSVersion{radar.HTTPLocationHTTPProtocolGetParamsTLSVersionTlSv1_0, radar.HTTPLocationHTTPProtocolGetParamsTLSVersionTlSv1_1, radar.HTTPLocationHTTPProtocolGetParamsTLSVersionTlSv1_2}), + }, + ) + 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/radar/httplocationipversion.go b/radar/httplocationipversion.go new file mode 100644 index 00000000000..bb982e70d2f --- /dev/null +++ b/radar/httplocationipversion.go @@ -0,0 +1,366 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPLocationIPVersionService 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 [NewHTTPLocationIPVersionService] +// method instead. +type HTTPLocationIPVersionService struct { + Options []option.RequestOption +} + +// NewHTTPLocationIPVersionService 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 NewHTTPLocationIPVersionService(opts ...option.RequestOption) (r *HTTPLocationIPVersionService) { + r = &HTTPLocationIPVersionService{} + r.Options = opts + return +} + +// Get the top locations, by HTTP traffic, of the requested IP protocol version. +// Values are a percentage out of the total traffic. +func (r *HTTPLocationIPVersionService) Get(ctx context.Context, ipVersion HTTPLocationIPVersionGetParamsIPVersion, query HTTPLocationIPVersionGetParams, opts ...option.RequestOption) (res *HTTPLocationIPVersionGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPLocationIPVersionGetResponseEnvelope + path := fmt.Sprintf("radar/http/top/locations/ip_version/%v", ipVersion) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPLocationIPVersionGetResponse struct { + Meta HTTPLocationIPVersionGetResponseMeta `json:"meta,required"` + Top0 []HTTPLocationIPVersionGetResponseTop0 `json:"top_0,required"` + JSON httpLocationIPVersionGetResponseJSON `json:"-"` +} + +// httpLocationIPVersionGetResponseJSON contains the JSON metadata for the struct +// [HTTPLocationIPVersionGetResponse] +type httpLocationIPVersionGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationIPVersionGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationIPVersionGetResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationIPVersionGetResponseMeta struct { + DateRange []HTTPLocationIPVersionGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo HTTPLocationIPVersionGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpLocationIPVersionGetResponseMetaJSON `json:"-"` +} + +// httpLocationIPVersionGetResponseMetaJSON contains the JSON metadata for the +// struct [HTTPLocationIPVersionGetResponseMeta] +type httpLocationIPVersionGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationIPVersionGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationIPVersionGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationIPVersionGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpLocationIPVersionGetResponseMetaDateRangeJSON `json:"-"` +} + +// httpLocationIPVersionGetResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [HTTPLocationIPVersionGetResponseMetaDateRange] +type httpLocationIPVersionGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationIPVersionGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationIPVersionGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationIPVersionGetResponseMetaConfidenceInfo struct { + Annotations []HTTPLocationIPVersionGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpLocationIPVersionGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpLocationIPVersionGetResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [HTTPLocationIPVersionGetResponseMetaConfidenceInfo] +type httpLocationIPVersionGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationIPVersionGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationIPVersionGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationIPVersionGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpLocationIPVersionGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpLocationIPVersionGetResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [HTTPLocationIPVersionGetResponseMetaConfidenceInfoAnnotation] +type httpLocationIPVersionGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationIPVersionGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationIPVersionGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationIPVersionGetResponseTop0 struct { + ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` + ClientCountryName string `json:"clientCountryName,required"` + Value string `json:"value,required"` + JSON httpLocationIPVersionGetResponseTop0JSON `json:"-"` +} + +// httpLocationIPVersionGetResponseTop0JSON contains the JSON metadata for the +// struct [HTTPLocationIPVersionGetResponseTop0] +type httpLocationIPVersionGetResponseTop0JSON struct { + ClientCountryAlpha2 apijson.Field + ClientCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationIPVersionGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationIPVersionGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type HTTPLocationIPVersionGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPLocationIPVersionGetParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPLocationIPVersionGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPLocationIPVersionGetParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPLocationIPVersionGetParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPLocationIPVersionGetParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPLocationIPVersionGetParamsHTTPVersion] `query:"httpVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPLocationIPVersionGetParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPLocationIPVersionGetParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPLocationIPVersionGetParams]'s query parameters as +// `url.Values`. +func (r HTTPLocationIPVersionGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// IP version. +type HTTPLocationIPVersionGetParamsIPVersion string + +const ( + HTTPLocationIPVersionGetParamsIPVersionIPv4 HTTPLocationIPVersionGetParamsIPVersion = "IPv4" + HTTPLocationIPVersionGetParamsIPVersionIPv6 HTTPLocationIPVersionGetParamsIPVersion = "IPv6" +) + +type HTTPLocationIPVersionGetParamsBotClass string + +const ( + HTTPLocationIPVersionGetParamsBotClassLikelyAutomated HTTPLocationIPVersionGetParamsBotClass = "LIKELY_AUTOMATED" + HTTPLocationIPVersionGetParamsBotClassLikelyHuman HTTPLocationIPVersionGetParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPLocationIPVersionGetParamsDateRange string + +const ( + HTTPLocationIPVersionGetParamsDateRange1d HTTPLocationIPVersionGetParamsDateRange = "1d" + HTTPLocationIPVersionGetParamsDateRange2d HTTPLocationIPVersionGetParamsDateRange = "2d" + HTTPLocationIPVersionGetParamsDateRange7d HTTPLocationIPVersionGetParamsDateRange = "7d" + HTTPLocationIPVersionGetParamsDateRange14d HTTPLocationIPVersionGetParamsDateRange = "14d" + HTTPLocationIPVersionGetParamsDateRange28d HTTPLocationIPVersionGetParamsDateRange = "28d" + HTTPLocationIPVersionGetParamsDateRange12w HTTPLocationIPVersionGetParamsDateRange = "12w" + HTTPLocationIPVersionGetParamsDateRange24w HTTPLocationIPVersionGetParamsDateRange = "24w" + HTTPLocationIPVersionGetParamsDateRange52w HTTPLocationIPVersionGetParamsDateRange = "52w" + HTTPLocationIPVersionGetParamsDateRange1dControl HTTPLocationIPVersionGetParamsDateRange = "1dControl" + HTTPLocationIPVersionGetParamsDateRange2dControl HTTPLocationIPVersionGetParamsDateRange = "2dControl" + HTTPLocationIPVersionGetParamsDateRange7dControl HTTPLocationIPVersionGetParamsDateRange = "7dControl" + HTTPLocationIPVersionGetParamsDateRange14dControl HTTPLocationIPVersionGetParamsDateRange = "14dControl" + HTTPLocationIPVersionGetParamsDateRange28dControl HTTPLocationIPVersionGetParamsDateRange = "28dControl" + HTTPLocationIPVersionGetParamsDateRange12wControl HTTPLocationIPVersionGetParamsDateRange = "12wControl" + HTTPLocationIPVersionGetParamsDateRange24wControl HTTPLocationIPVersionGetParamsDateRange = "24wControl" +) + +type HTTPLocationIPVersionGetParamsDeviceType string + +const ( + HTTPLocationIPVersionGetParamsDeviceTypeDesktop HTTPLocationIPVersionGetParamsDeviceType = "DESKTOP" + HTTPLocationIPVersionGetParamsDeviceTypeMobile HTTPLocationIPVersionGetParamsDeviceType = "MOBILE" + HTTPLocationIPVersionGetParamsDeviceTypeOther HTTPLocationIPVersionGetParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPLocationIPVersionGetParamsFormat string + +const ( + HTTPLocationIPVersionGetParamsFormatJson HTTPLocationIPVersionGetParamsFormat = "JSON" + HTTPLocationIPVersionGetParamsFormatCsv HTTPLocationIPVersionGetParamsFormat = "CSV" +) + +type HTTPLocationIPVersionGetParamsHTTPProtocol string + +const ( + HTTPLocationIPVersionGetParamsHTTPProtocolHTTP HTTPLocationIPVersionGetParamsHTTPProtocol = "HTTP" + HTTPLocationIPVersionGetParamsHTTPProtocolHTTPS HTTPLocationIPVersionGetParamsHTTPProtocol = "HTTPS" +) + +type HTTPLocationIPVersionGetParamsHTTPVersion string + +const ( + HTTPLocationIPVersionGetParamsHTTPVersionHttPv1 HTTPLocationIPVersionGetParamsHTTPVersion = "HTTPv1" + HTTPLocationIPVersionGetParamsHTTPVersionHttPv2 HTTPLocationIPVersionGetParamsHTTPVersion = "HTTPv2" + HTTPLocationIPVersionGetParamsHTTPVersionHttPv3 HTTPLocationIPVersionGetParamsHTTPVersion = "HTTPv3" +) + +type HTTPLocationIPVersionGetParamsOS string + +const ( + HTTPLocationIPVersionGetParamsOSWindows HTTPLocationIPVersionGetParamsOS = "WINDOWS" + HTTPLocationIPVersionGetParamsOSMacosx HTTPLocationIPVersionGetParamsOS = "MACOSX" + HTTPLocationIPVersionGetParamsOSIos HTTPLocationIPVersionGetParamsOS = "IOS" + HTTPLocationIPVersionGetParamsOSAndroid HTTPLocationIPVersionGetParamsOS = "ANDROID" + HTTPLocationIPVersionGetParamsOSChromeos HTTPLocationIPVersionGetParamsOS = "CHROMEOS" + HTTPLocationIPVersionGetParamsOSLinux HTTPLocationIPVersionGetParamsOS = "LINUX" + HTTPLocationIPVersionGetParamsOSSmartTv HTTPLocationIPVersionGetParamsOS = "SMART_TV" +) + +type HTTPLocationIPVersionGetParamsTLSVersion string + +const ( + HTTPLocationIPVersionGetParamsTLSVersionTlSv1_0 HTTPLocationIPVersionGetParamsTLSVersion = "TLSv1_0" + HTTPLocationIPVersionGetParamsTLSVersionTlSv1_1 HTTPLocationIPVersionGetParamsTLSVersion = "TLSv1_1" + HTTPLocationIPVersionGetParamsTLSVersionTlSv1_2 HTTPLocationIPVersionGetParamsTLSVersion = "TLSv1_2" + HTTPLocationIPVersionGetParamsTLSVersionTlSv1_3 HTTPLocationIPVersionGetParamsTLSVersion = "TLSv1_3" + HTTPLocationIPVersionGetParamsTLSVersionTlSvQuic HTTPLocationIPVersionGetParamsTLSVersion = "TLSvQUIC" +) + +type HTTPLocationIPVersionGetResponseEnvelope struct { + Result HTTPLocationIPVersionGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpLocationIPVersionGetResponseEnvelopeJSON `json:"-"` +} + +// httpLocationIPVersionGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [HTTPLocationIPVersionGetResponseEnvelope] +type httpLocationIPVersionGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationIPVersionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationIPVersionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httplocationipversion_test.go b/radar/httplocationipversion_test.go new file mode 100644 index 00000000000..3f61e422c46 --- /dev/null +++ b/radar/httplocationipversion_test.go @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPLocationIPVersionGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Locations.IPVersion.Get( + context.TODO(), + radar.HTTPLocationIPVersionGetParamsIPVersionIPv4, + radar.HTTPLocationIPVersionGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPLocationIPVersionGetParamsBotClass{radar.HTTPLocationIPVersionGetParamsBotClassLikelyAutomated, radar.HTTPLocationIPVersionGetParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPLocationIPVersionGetParamsDateRange{radar.HTTPLocationIPVersionGetParamsDateRange1d, radar.HTTPLocationIPVersionGetParamsDateRange2d, radar.HTTPLocationIPVersionGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPLocationIPVersionGetParamsDeviceType{radar.HTTPLocationIPVersionGetParamsDeviceTypeDesktop, radar.HTTPLocationIPVersionGetParamsDeviceTypeMobile, radar.HTTPLocationIPVersionGetParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPLocationIPVersionGetParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPLocationIPVersionGetParamsHTTPProtocol{radar.HTTPLocationIPVersionGetParamsHTTPProtocolHTTP, radar.HTTPLocationIPVersionGetParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPLocationIPVersionGetParamsHTTPVersion{radar.HTTPLocationIPVersionGetParamsHTTPVersionHttPv1, radar.HTTPLocationIPVersionGetParamsHTTPVersionHttPv2, radar.HTTPLocationIPVersionGetParamsHTTPVersionHttPv3}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPLocationIPVersionGetParamsOS{radar.HTTPLocationIPVersionGetParamsOSWindows, radar.HTTPLocationIPVersionGetParamsOSMacosx, radar.HTTPLocationIPVersionGetParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPLocationIPVersionGetParamsTLSVersion{radar.HTTPLocationIPVersionGetParamsTLSVersionTlSv1_0, radar.HTTPLocationIPVersionGetParamsTLSVersionTlSv1_1, radar.HTTPLocationIPVersionGetParamsTLSVersionTlSv1_2}), + }, + ) + 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/radar/httplocationos.go b/radar/httplocationos.go new file mode 100644 index 00000000000..eb4f70943b2 --- /dev/null +++ b/radar/httplocationos.go @@ -0,0 +1,365 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPLocationOSService 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 [NewHTTPLocationOSService] method +// instead. +type HTTPLocationOSService struct { + Options []option.RequestOption +} + +// NewHTTPLocationOSService 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 NewHTTPLocationOSService(opts ...option.RequestOption) (r *HTTPLocationOSService) { + r = &HTTPLocationOSService{} + r.Options = opts + return +} + +// Get the top locations, by HTTP traffic, of the requested operating systems. +// Values are a percentage out of the total traffic. +func (r *HTTPLocationOSService) Get(ctx context.Context, os HTTPLocationOSGetParamsOS, query HTTPLocationOSGetParams, opts ...option.RequestOption) (res *HTTPLocationOSGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPLocationOSGetResponseEnvelope + path := fmt.Sprintf("radar/http/top/locations/os/%v", os) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPLocationOSGetResponse struct { + Meta HTTPLocationOSGetResponseMeta `json:"meta,required"` + Top0 []HTTPLocationOSGetResponseTop0 `json:"top_0,required"` + JSON httpLocationOSGetResponseJSON `json:"-"` +} + +// httpLocationOSGetResponseJSON contains the JSON metadata for the struct +// [HTTPLocationOSGetResponse] +type httpLocationOSGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationOSGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationOSGetResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationOSGetResponseMeta struct { + DateRange []HTTPLocationOSGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo HTTPLocationOSGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpLocationOSGetResponseMetaJSON `json:"-"` +} + +// httpLocationOSGetResponseMetaJSON contains the JSON metadata for the struct +// [HTTPLocationOSGetResponseMeta] +type httpLocationOSGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationOSGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationOSGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationOSGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpLocationOSGetResponseMetaDateRangeJSON `json:"-"` +} + +// httpLocationOSGetResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [HTTPLocationOSGetResponseMetaDateRange] +type httpLocationOSGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationOSGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationOSGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationOSGetResponseMetaConfidenceInfo struct { + Annotations []HTTPLocationOSGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpLocationOSGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpLocationOSGetResponseMetaConfidenceInfoJSON contains the JSON metadata for +// the struct [HTTPLocationOSGetResponseMetaConfidenceInfo] +type httpLocationOSGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationOSGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationOSGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationOSGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpLocationOSGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpLocationOSGetResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct [HTTPLocationOSGetResponseMetaConfidenceInfoAnnotation] +type httpLocationOSGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationOSGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationOSGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationOSGetResponseTop0 struct { + ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` + ClientCountryName string `json:"clientCountryName,required"` + Value string `json:"value,required"` + JSON httpLocationOSGetResponseTop0JSON `json:"-"` +} + +// httpLocationOSGetResponseTop0JSON contains the JSON metadata for the struct +// [HTTPLocationOSGetResponseTop0] +type httpLocationOSGetResponseTop0JSON struct { + ClientCountryAlpha2 apijson.Field + ClientCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationOSGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationOSGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type HTTPLocationOSGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPLocationOSGetParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPLocationOSGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPLocationOSGetParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPLocationOSGetParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPLocationOSGetParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPLocationOSGetParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPLocationOSGetParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPLocationOSGetParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPLocationOSGetParams]'s query parameters as +// `url.Values`. +func (r HTTPLocationOSGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// IP version. +type HTTPLocationOSGetParamsOS string + +const ( + HTTPLocationOSGetParamsOSWindows HTTPLocationOSGetParamsOS = "WINDOWS" + HTTPLocationOSGetParamsOSMacosx HTTPLocationOSGetParamsOS = "MACOSX" + HTTPLocationOSGetParamsOSIos HTTPLocationOSGetParamsOS = "IOS" + HTTPLocationOSGetParamsOSAndroid HTTPLocationOSGetParamsOS = "ANDROID" + HTTPLocationOSGetParamsOSChromeos HTTPLocationOSGetParamsOS = "CHROMEOS" + HTTPLocationOSGetParamsOSLinux HTTPLocationOSGetParamsOS = "LINUX" + HTTPLocationOSGetParamsOSSmartTv HTTPLocationOSGetParamsOS = "SMART_TV" +) + +type HTTPLocationOSGetParamsBotClass string + +const ( + HTTPLocationOSGetParamsBotClassLikelyAutomated HTTPLocationOSGetParamsBotClass = "LIKELY_AUTOMATED" + HTTPLocationOSGetParamsBotClassLikelyHuman HTTPLocationOSGetParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPLocationOSGetParamsDateRange string + +const ( + HTTPLocationOSGetParamsDateRange1d HTTPLocationOSGetParamsDateRange = "1d" + HTTPLocationOSGetParamsDateRange2d HTTPLocationOSGetParamsDateRange = "2d" + HTTPLocationOSGetParamsDateRange7d HTTPLocationOSGetParamsDateRange = "7d" + HTTPLocationOSGetParamsDateRange14d HTTPLocationOSGetParamsDateRange = "14d" + HTTPLocationOSGetParamsDateRange28d HTTPLocationOSGetParamsDateRange = "28d" + HTTPLocationOSGetParamsDateRange12w HTTPLocationOSGetParamsDateRange = "12w" + HTTPLocationOSGetParamsDateRange24w HTTPLocationOSGetParamsDateRange = "24w" + HTTPLocationOSGetParamsDateRange52w HTTPLocationOSGetParamsDateRange = "52w" + HTTPLocationOSGetParamsDateRange1dControl HTTPLocationOSGetParamsDateRange = "1dControl" + HTTPLocationOSGetParamsDateRange2dControl HTTPLocationOSGetParamsDateRange = "2dControl" + HTTPLocationOSGetParamsDateRange7dControl HTTPLocationOSGetParamsDateRange = "7dControl" + HTTPLocationOSGetParamsDateRange14dControl HTTPLocationOSGetParamsDateRange = "14dControl" + HTTPLocationOSGetParamsDateRange28dControl HTTPLocationOSGetParamsDateRange = "28dControl" + HTTPLocationOSGetParamsDateRange12wControl HTTPLocationOSGetParamsDateRange = "12wControl" + HTTPLocationOSGetParamsDateRange24wControl HTTPLocationOSGetParamsDateRange = "24wControl" +) + +type HTTPLocationOSGetParamsDeviceType string + +const ( + HTTPLocationOSGetParamsDeviceTypeDesktop HTTPLocationOSGetParamsDeviceType = "DESKTOP" + HTTPLocationOSGetParamsDeviceTypeMobile HTTPLocationOSGetParamsDeviceType = "MOBILE" + HTTPLocationOSGetParamsDeviceTypeOther HTTPLocationOSGetParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPLocationOSGetParamsFormat string + +const ( + HTTPLocationOSGetParamsFormatJson HTTPLocationOSGetParamsFormat = "JSON" + HTTPLocationOSGetParamsFormatCsv HTTPLocationOSGetParamsFormat = "CSV" +) + +type HTTPLocationOSGetParamsHTTPProtocol string + +const ( + HTTPLocationOSGetParamsHTTPProtocolHTTP HTTPLocationOSGetParamsHTTPProtocol = "HTTP" + HTTPLocationOSGetParamsHTTPProtocolHTTPS HTTPLocationOSGetParamsHTTPProtocol = "HTTPS" +) + +type HTTPLocationOSGetParamsHTTPVersion string + +const ( + HTTPLocationOSGetParamsHTTPVersionHttPv1 HTTPLocationOSGetParamsHTTPVersion = "HTTPv1" + HTTPLocationOSGetParamsHTTPVersionHttPv2 HTTPLocationOSGetParamsHTTPVersion = "HTTPv2" + HTTPLocationOSGetParamsHTTPVersionHttPv3 HTTPLocationOSGetParamsHTTPVersion = "HTTPv3" +) + +type HTTPLocationOSGetParamsIPVersion string + +const ( + HTTPLocationOSGetParamsIPVersionIPv4 HTTPLocationOSGetParamsIPVersion = "IPv4" + HTTPLocationOSGetParamsIPVersionIPv6 HTTPLocationOSGetParamsIPVersion = "IPv6" +) + +type HTTPLocationOSGetParamsTLSVersion string + +const ( + HTTPLocationOSGetParamsTLSVersionTlSv1_0 HTTPLocationOSGetParamsTLSVersion = "TLSv1_0" + HTTPLocationOSGetParamsTLSVersionTlSv1_1 HTTPLocationOSGetParamsTLSVersion = "TLSv1_1" + HTTPLocationOSGetParamsTLSVersionTlSv1_2 HTTPLocationOSGetParamsTLSVersion = "TLSv1_2" + HTTPLocationOSGetParamsTLSVersionTlSv1_3 HTTPLocationOSGetParamsTLSVersion = "TLSv1_3" + HTTPLocationOSGetParamsTLSVersionTlSvQuic HTTPLocationOSGetParamsTLSVersion = "TLSvQUIC" +) + +type HTTPLocationOSGetResponseEnvelope struct { + Result HTTPLocationOSGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpLocationOSGetResponseEnvelopeJSON `json:"-"` +} + +// httpLocationOSGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [HTTPLocationOSGetResponseEnvelope] +type httpLocationOSGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationOSGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationOSGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httplocationos_test.go b/radar/httplocationos_test.go new file mode 100644 index 00000000000..735e1da8af7 --- /dev/null +++ b/radar/httplocationos_test.go @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPLocationOSGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Locations.OS.Get( + context.TODO(), + radar.HTTPLocationOSGetParamsOSWindows, + radar.HTTPLocationOSGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPLocationOSGetParamsBotClass{radar.HTTPLocationOSGetParamsBotClassLikelyAutomated, radar.HTTPLocationOSGetParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPLocationOSGetParamsDateRange{radar.HTTPLocationOSGetParamsDateRange1d, radar.HTTPLocationOSGetParamsDateRange2d, radar.HTTPLocationOSGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPLocationOSGetParamsDeviceType{radar.HTTPLocationOSGetParamsDeviceTypeDesktop, radar.HTTPLocationOSGetParamsDeviceTypeMobile, radar.HTTPLocationOSGetParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPLocationOSGetParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPLocationOSGetParamsHTTPProtocol{radar.HTTPLocationOSGetParamsHTTPProtocolHTTP, radar.HTTPLocationOSGetParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPLocationOSGetParamsHTTPVersion{radar.HTTPLocationOSGetParamsHTTPVersionHttPv1, radar.HTTPLocationOSGetParamsHTTPVersionHttPv2, radar.HTTPLocationOSGetParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPLocationOSGetParamsIPVersion{radar.HTTPLocationOSGetParamsIPVersionIPv4, radar.HTTPLocationOSGetParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + TLSVersion: cloudflare.F([]radar.HTTPLocationOSGetParamsTLSVersion{radar.HTTPLocationOSGetParamsTLSVersionTlSv1_0, radar.HTTPLocationOSGetParamsTLSVersionTlSv1_1, radar.HTTPLocationOSGetParamsTLSVersionTlSv1_2}), + }, + ) + 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/radar/httplocationtlsversion.go b/radar/httplocationtlsversion.go new file mode 100644 index 00000000000..b280d0f6624 --- /dev/null +++ b/radar/httplocationtlsversion.go @@ -0,0 +1,366 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPLocationTLSVersionService 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 [NewHTTPLocationTLSVersionService] +// method instead. +type HTTPLocationTLSVersionService struct { + Options []option.RequestOption +} + +// NewHTTPLocationTLSVersionService 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 NewHTTPLocationTLSVersionService(opts ...option.RequestOption) (r *HTTPLocationTLSVersionService) { + r = &HTTPLocationTLSVersionService{} + r.Options = opts + return +} + +// Get the top locations, by HTTP traffic, of the requested TLS protocol version. +// Values are a percentage out of the total traffic. +func (r *HTTPLocationTLSVersionService) Get(ctx context.Context, tlsVersion HTTPLocationTLSVersionGetParamsTLSVersion, query HTTPLocationTLSVersionGetParams, opts ...option.RequestOption) (res *HTTPLocationTLSVersionGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPLocationTLSVersionGetResponseEnvelope + path := fmt.Sprintf("radar/http/top/locations/tls_version/%v", tlsVersion) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPLocationTLSVersionGetResponse struct { + Meta HTTPLocationTLSVersionGetResponseMeta `json:"meta,required"` + Top0 []HTTPLocationTLSVersionGetResponseTop0 `json:"top_0,required"` + JSON httpLocationTLSVersionGetResponseJSON `json:"-"` +} + +// httpLocationTLSVersionGetResponseJSON contains the JSON metadata for the struct +// [HTTPLocationTLSVersionGetResponse] +type httpLocationTLSVersionGetResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationTLSVersionGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationTLSVersionGetResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationTLSVersionGetResponseMeta struct { + DateRange []HTTPLocationTLSVersionGetResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo HTTPLocationTLSVersionGetResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpLocationTLSVersionGetResponseMetaJSON `json:"-"` +} + +// httpLocationTLSVersionGetResponseMetaJSON contains the JSON metadata for the +// struct [HTTPLocationTLSVersionGetResponseMeta] +type httpLocationTLSVersionGetResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationTLSVersionGetResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationTLSVersionGetResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationTLSVersionGetResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpLocationTLSVersionGetResponseMetaDateRangeJSON `json:"-"` +} + +// httpLocationTLSVersionGetResponseMetaDateRangeJSON contains the JSON metadata +// for the struct [HTTPLocationTLSVersionGetResponseMetaDateRange] +type httpLocationTLSVersionGetResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationTLSVersionGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationTLSVersionGetResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationTLSVersionGetResponseMetaConfidenceInfo struct { + Annotations []HTTPLocationTLSVersionGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpLocationTLSVersionGetResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpLocationTLSVersionGetResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [HTTPLocationTLSVersionGetResponseMetaConfidenceInfo] +type httpLocationTLSVersionGetResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationTLSVersionGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationTLSVersionGetResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationTLSVersionGetResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpLocationTLSVersionGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpLocationTLSVersionGetResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [HTTPLocationTLSVersionGetResponseMetaConfidenceInfoAnnotation] +type httpLocationTLSVersionGetResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationTLSVersionGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationTLSVersionGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPLocationTLSVersionGetResponseTop0 struct { + ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` + ClientCountryName string `json:"clientCountryName,required"` + Value string `json:"value,required"` + JSON httpLocationTLSVersionGetResponseTop0JSON `json:"-"` +} + +// httpLocationTLSVersionGetResponseTop0JSON contains the JSON metadata for the +// struct [HTTPLocationTLSVersionGetResponseTop0] +type httpLocationTLSVersionGetResponseTop0JSON struct { + ClientCountryAlpha2 apijson.Field + ClientCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationTLSVersionGetResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationTLSVersionGetResponseTop0JSON) RawJSON() string { + return r.raw +} + +type HTTPLocationTLSVersionGetParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPLocationTLSVersionGetParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPLocationTLSVersionGetParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPLocationTLSVersionGetParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPLocationTLSVersionGetParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPLocationTLSVersionGetParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPLocationTLSVersionGetParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPLocationTLSVersionGetParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPLocationTLSVersionGetParamsOS] `query:"os"` +} + +// URLQuery serializes [HTTPLocationTLSVersionGetParams]'s query parameters as +// `url.Values`. +func (r HTTPLocationTLSVersionGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// TLS version. +type HTTPLocationTLSVersionGetParamsTLSVersion string + +const ( + HTTPLocationTLSVersionGetParamsTLSVersionTlSv1_0 HTTPLocationTLSVersionGetParamsTLSVersion = "TLSv1_0" + HTTPLocationTLSVersionGetParamsTLSVersionTlSv1_1 HTTPLocationTLSVersionGetParamsTLSVersion = "TLSv1_1" + HTTPLocationTLSVersionGetParamsTLSVersionTlSv1_2 HTTPLocationTLSVersionGetParamsTLSVersion = "TLSv1_2" + HTTPLocationTLSVersionGetParamsTLSVersionTlSv1_3 HTTPLocationTLSVersionGetParamsTLSVersion = "TLSv1_3" + HTTPLocationTLSVersionGetParamsTLSVersionTlSvQuic HTTPLocationTLSVersionGetParamsTLSVersion = "TLSvQUIC" +) + +type HTTPLocationTLSVersionGetParamsBotClass string + +const ( + HTTPLocationTLSVersionGetParamsBotClassLikelyAutomated HTTPLocationTLSVersionGetParamsBotClass = "LIKELY_AUTOMATED" + HTTPLocationTLSVersionGetParamsBotClassLikelyHuman HTTPLocationTLSVersionGetParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPLocationTLSVersionGetParamsDateRange string + +const ( + HTTPLocationTLSVersionGetParamsDateRange1d HTTPLocationTLSVersionGetParamsDateRange = "1d" + HTTPLocationTLSVersionGetParamsDateRange2d HTTPLocationTLSVersionGetParamsDateRange = "2d" + HTTPLocationTLSVersionGetParamsDateRange7d HTTPLocationTLSVersionGetParamsDateRange = "7d" + HTTPLocationTLSVersionGetParamsDateRange14d HTTPLocationTLSVersionGetParamsDateRange = "14d" + HTTPLocationTLSVersionGetParamsDateRange28d HTTPLocationTLSVersionGetParamsDateRange = "28d" + HTTPLocationTLSVersionGetParamsDateRange12w HTTPLocationTLSVersionGetParamsDateRange = "12w" + HTTPLocationTLSVersionGetParamsDateRange24w HTTPLocationTLSVersionGetParamsDateRange = "24w" + HTTPLocationTLSVersionGetParamsDateRange52w HTTPLocationTLSVersionGetParamsDateRange = "52w" + HTTPLocationTLSVersionGetParamsDateRange1dControl HTTPLocationTLSVersionGetParamsDateRange = "1dControl" + HTTPLocationTLSVersionGetParamsDateRange2dControl HTTPLocationTLSVersionGetParamsDateRange = "2dControl" + HTTPLocationTLSVersionGetParamsDateRange7dControl HTTPLocationTLSVersionGetParamsDateRange = "7dControl" + HTTPLocationTLSVersionGetParamsDateRange14dControl HTTPLocationTLSVersionGetParamsDateRange = "14dControl" + HTTPLocationTLSVersionGetParamsDateRange28dControl HTTPLocationTLSVersionGetParamsDateRange = "28dControl" + HTTPLocationTLSVersionGetParamsDateRange12wControl HTTPLocationTLSVersionGetParamsDateRange = "12wControl" + HTTPLocationTLSVersionGetParamsDateRange24wControl HTTPLocationTLSVersionGetParamsDateRange = "24wControl" +) + +type HTTPLocationTLSVersionGetParamsDeviceType string + +const ( + HTTPLocationTLSVersionGetParamsDeviceTypeDesktop HTTPLocationTLSVersionGetParamsDeviceType = "DESKTOP" + HTTPLocationTLSVersionGetParamsDeviceTypeMobile HTTPLocationTLSVersionGetParamsDeviceType = "MOBILE" + HTTPLocationTLSVersionGetParamsDeviceTypeOther HTTPLocationTLSVersionGetParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPLocationTLSVersionGetParamsFormat string + +const ( + HTTPLocationTLSVersionGetParamsFormatJson HTTPLocationTLSVersionGetParamsFormat = "JSON" + HTTPLocationTLSVersionGetParamsFormatCsv HTTPLocationTLSVersionGetParamsFormat = "CSV" +) + +type HTTPLocationTLSVersionGetParamsHTTPProtocol string + +const ( + HTTPLocationTLSVersionGetParamsHTTPProtocolHTTP HTTPLocationTLSVersionGetParamsHTTPProtocol = "HTTP" + HTTPLocationTLSVersionGetParamsHTTPProtocolHTTPS HTTPLocationTLSVersionGetParamsHTTPProtocol = "HTTPS" +) + +type HTTPLocationTLSVersionGetParamsHTTPVersion string + +const ( + HTTPLocationTLSVersionGetParamsHTTPVersionHttPv1 HTTPLocationTLSVersionGetParamsHTTPVersion = "HTTPv1" + HTTPLocationTLSVersionGetParamsHTTPVersionHttPv2 HTTPLocationTLSVersionGetParamsHTTPVersion = "HTTPv2" + HTTPLocationTLSVersionGetParamsHTTPVersionHttPv3 HTTPLocationTLSVersionGetParamsHTTPVersion = "HTTPv3" +) + +type HTTPLocationTLSVersionGetParamsIPVersion string + +const ( + HTTPLocationTLSVersionGetParamsIPVersionIPv4 HTTPLocationTLSVersionGetParamsIPVersion = "IPv4" + HTTPLocationTLSVersionGetParamsIPVersionIPv6 HTTPLocationTLSVersionGetParamsIPVersion = "IPv6" +) + +type HTTPLocationTLSVersionGetParamsOS string + +const ( + HTTPLocationTLSVersionGetParamsOSWindows HTTPLocationTLSVersionGetParamsOS = "WINDOWS" + HTTPLocationTLSVersionGetParamsOSMacosx HTTPLocationTLSVersionGetParamsOS = "MACOSX" + HTTPLocationTLSVersionGetParamsOSIos HTTPLocationTLSVersionGetParamsOS = "IOS" + HTTPLocationTLSVersionGetParamsOSAndroid HTTPLocationTLSVersionGetParamsOS = "ANDROID" + HTTPLocationTLSVersionGetParamsOSChromeos HTTPLocationTLSVersionGetParamsOS = "CHROMEOS" + HTTPLocationTLSVersionGetParamsOSLinux HTTPLocationTLSVersionGetParamsOS = "LINUX" + HTTPLocationTLSVersionGetParamsOSSmartTv HTTPLocationTLSVersionGetParamsOS = "SMART_TV" +) + +type HTTPLocationTLSVersionGetResponseEnvelope struct { + Result HTTPLocationTLSVersionGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpLocationTLSVersionGetResponseEnvelopeJSON `json:"-"` +} + +// httpLocationTLSVersionGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [HTTPLocationTLSVersionGetResponseEnvelope] +type httpLocationTLSVersionGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPLocationTLSVersionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpLocationTLSVersionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httplocationtlsversion_test.go b/radar/httplocationtlsversion_test.go new file mode 100644 index 00000000000..daf1452bf19 --- /dev/null +++ b/radar/httplocationtlsversion_test.go @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPLocationTLSVersionGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Locations.TLSVersion.Get( + context.TODO(), + radar.HTTPLocationTLSVersionGetParamsTLSVersionTlSv1_0, + radar.HTTPLocationTLSVersionGetParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPLocationTLSVersionGetParamsBotClass{radar.HTTPLocationTLSVersionGetParamsBotClassLikelyAutomated, radar.HTTPLocationTLSVersionGetParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPLocationTLSVersionGetParamsDateRange{radar.HTTPLocationTLSVersionGetParamsDateRange1d, radar.HTTPLocationTLSVersionGetParamsDateRange2d, radar.HTTPLocationTLSVersionGetParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPLocationTLSVersionGetParamsDeviceType{radar.HTTPLocationTLSVersionGetParamsDeviceTypeDesktop, radar.HTTPLocationTLSVersionGetParamsDeviceTypeMobile, radar.HTTPLocationTLSVersionGetParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPLocationTLSVersionGetParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPLocationTLSVersionGetParamsHTTPProtocol{radar.HTTPLocationTLSVersionGetParamsHTTPProtocolHTTP, radar.HTTPLocationTLSVersionGetParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPLocationTLSVersionGetParamsHTTPVersion{radar.HTTPLocationTLSVersionGetParamsHTTPVersionHttPv1, radar.HTTPLocationTLSVersionGetParamsHTTPVersionHttPv2, radar.HTTPLocationTLSVersionGetParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPLocationTLSVersionGetParamsIPVersion{radar.HTTPLocationTLSVersionGetParamsIPVersionIPv4, radar.HTTPLocationTLSVersionGetParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPLocationTLSVersionGetParamsOS{radar.HTTPLocationTLSVersionGetParamsOSWindows, radar.HTTPLocationTLSVersionGetParamsOSMacosx, radar.HTTPLocationTLSVersionGetParamsOSIos}), + }, + ) + 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/radar/httpsummary.go b/radar/httpsummary.go new file mode 100644 index 00000000000..1fd32b5a0ab --- /dev/null +++ b/radar/httpsummary.go @@ -0,0 +1,2279 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPSummaryService 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 [NewHTTPSummaryService] method +// instead. +type HTTPSummaryService struct { + Options []option.RequestOption +} + +// NewHTTPSummaryService 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 NewHTTPSummaryService(opts ...option.RequestOption) (r *HTTPSummaryService) { + r = &HTTPSummaryService{} + r.Options = opts + return +} + +// Percentage distribution of bot-generated traffic to genuine human traffic, as +// classified by Cloudflare. Visit +// https://developers.cloudflare.com/radar/concepts/bot-classes/ for more +// information. +func (r *HTTPSummaryService) BotClass(ctx context.Context, query HTTPSummaryBotClassParams, opts ...option.RequestOption) (res *HTTPSummaryBotClassResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPSummaryBotClassResponseEnvelope + path := "radar/http/summary/bot_class" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage of Internet traffic generated by mobile, desktop, and other types of +// devices, over a given time period. +func (r *HTTPSummaryService) DeviceType(ctx context.Context, query HTTPSummaryDeviceTypeParams, opts ...option.RequestOption) (res *HTTPSummaryDeviceTypeResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPSummaryDeviceTypeResponseEnvelope + path := "radar/http/summary/device_type" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of traffic per HTTP protocol over a given time period. +func (r *HTTPSummaryService) HTTPProtocol(ctx context.Context, query HTTPSummaryHTTPProtocolParams, opts ...option.RequestOption) (res *HTTPSummaryHTTPProtocolResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPSummaryHTTPProtocolResponseEnvelope + path := "radar/http/summary/http_protocol" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of traffic per HTTP protocol version over a given time +// period. +func (r *HTTPSummaryService) HTTPVersion(ctx context.Context, query HTTPSummaryHTTPVersionParams, opts ...option.RequestOption) (res *HTTPSummaryHTTPVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPSummaryHTTPVersionResponseEnvelope + path := "radar/http/summary/http_version" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of Internet traffic based on IP protocol versions, such +// as IPv4 and IPv6, over a given time period. +func (r *HTTPSummaryService) IPVersion(ctx context.Context, query HTTPSummaryIPVersionParams, opts ...option.RequestOption) (res *HTTPSummaryIPVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPSummaryIPVersionResponseEnvelope + path := "radar/http/summary/ip_version" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of Internet traffic generated by different operating +// systems like Windows, macOS, Android, iOS, and others, over a given time period. +func (r *HTTPSummaryService) OS(ctx context.Context, query HTTPSummaryOSParams, opts ...option.RequestOption) (res *HTTPSummaryOSResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPSummaryOSResponseEnvelope + path := "radar/http/summary/os" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Percentage distribution of traffic per TLS protocol version, over a given time +// period. +func (r *HTTPSummaryService) TLSVersion(ctx context.Context, query HTTPSummaryTLSVersionParams, opts ...option.RequestOption) (res *HTTPSummaryTLSVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPSummaryTLSVersionResponseEnvelope + path := "radar/http/summary/tls_version" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPSummaryBotClassResponse struct { + Meta HTTPSummaryBotClassResponseMeta `json:"meta,required"` + Summary0 HTTPSummaryBotClassResponseSummary0 `json:"summary_0,required"` + JSON httpSummaryBotClassResponseJSON `json:"-"` +} + +// httpSummaryBotClassResponseJSON contains the JSON metadata for the struct +// [HTTPSummaryBotClassResponse] +type httpSummaryBotClassResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryBotClassResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryBotClassResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryBotClassResponseMeta struct { + DateRange []HTTPSummaryBotClassResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo HTTPSummaryBotClassResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpSummaryBotClassResponseMetaJSON `json:"-"` +} + +// httpSummaryBotClassResponseMetaJSON contains the JSON metadata for the struct +// [HTTPSummaryBotClassResponseMeta] +type httpSummaryBotClassResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryBotClassResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryBotClassResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryBotClassResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpSummaryBotClassResponseMetaDateRangeJSON `json:"-"` +} + +// httpSummaryBotClassResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [HTTPSummaryBotClassResponseMetaDateRange] +type httpSummaryBotClassResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryBotClassResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryBotClassResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryBotClassResponseMetaConfidenceInfo struct { + Annotations []HTTPSummaryBotClassResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpSummaryBotClassResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpSummaryBotClassResponseMetaConfidenceInfoJSON contains the JSON metadata for +// the struct [HTTPSummaryBotClassResponseMetaConfidenceInfo] +type httpSummaryBotClassResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryBotClassResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryBotClassResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryBotClassResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpSummaryBotClassResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpSummaryBotClassResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [HTTPSummaryBotClassResponseMetaConfidenceInfoAnnotation] +type httpSummaryBotClassResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryBotClassResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryBotClassResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryBotClassResponseSummary0 struct { + Bot string `json:"bot,required"` + Human string `json:"human,required"` + JSON httpSummaryBotClassResponseSummary0JSON `json:"-"` +} + +// httpSummaryBotClassResponseSummary0JSON contains the JSON metadata for the +// struct [HTTPSummaryBotClassResponseSummary0] +type httpSummaryBotClassResponseSummary0JSON struct { + Bot apijson.Field + Human apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryBotClassResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryBotClassResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryDeviceTypeResponse struct { + Meta HTTPSummaryDeviceTypeResponseMeta `json:"meta,required"` + Summary0 HTTPSummaryDeviceTypeResponseSummary0 `json:"summary_0,required"` + JSON httpSummaryDeviceTypeResponseJSON `json:"-"` +} + +// httpSummaryDeviceTypeResponseJSON contains the JSON metadata for the struct +// [HTTPSummaryDeviceTypeResponse] +type httpSummaryDeviceTypeResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryDeviceTypeResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryDeviceTypeResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryDeviceTypeResponseMeta struct { + DateRange []HTTPSummaryDeviceTypeResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo HTTPSummaryDeviceTypeResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpSummaryDeviceTypeResponseMetaJSON `json:"-"` +} + +// httpSummaryDeviceTypeResponseMetaJSON contains the JSON metadata for the struct +// [HTTPSummaryDeviceTypeResponseMeta] +type httpSummaryDeviceTypeResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryDeviceTypeResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryDeviceTypeResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryDeviceTypeResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpSummaryDeviceTypeResponseMetaDateRangeJSON `json:"-"` +} + +// httpSummaryDeviceTypeResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [HTTPSummaryDeviceTypeResponseMetaDateRange] +type httpSummaryDeviceTypeResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryDeviceTypeResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryDeviceTypeResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryDeviceTypeResponseMetaConfidenceInfo struct { + Annotations []HTTPSummaryDeviceTypeResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpSummaryDeviceTypeResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpSummaryDeviceTypeResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [HTTPSummaryDeviceTypeResponseMetaConfidenceInfo] +type httpSummaryDeviceTypeResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryDeviceTypeResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryDeviceTypeResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryDeviceTypeResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpSummaryDeviceTypeResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpSummaryDeviceTypeResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [HTTPSummaryDeviceTypeResponseMetaConfidenceInfoAnnotation] +type httpSummaryDeviceTypeResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryDeviceTypeResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryDeviceTypeResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryDeviceTypeResponseSummary0 struct { + Desktop string `json:"desktop,required"` + Mobile string `json:"mobile,required"` + Other string `json:"other,required"` + JSON httpSummaryDeviceTypeResponseSummary0JSON `json:"-"` +} + +// httpSummaryDeviceTypeResponseSummary0JSON contains the JSON metadata for the +// struct [HTTPSummaryDeviceTypeResponseSummary0] +type httpSummaryDeviceTypeResponseSummary0JSON struct { + Desktop apijson.Field + Mobile apijson.Field + Other apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryDeviceTypeResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryDeviceTypeResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryHTTPProtocolResponse struct { + Meta HTTPSummaryHTTPProtocolResponseMeta `json:"meta,required"` + Summary0 HTTPSummaryHTTPProtocolResponseSummary0 `json:"summary_0,required"` + JSON httpSummaryHTTPProtocolResponseJSON `json:"-"` +} + +// httpSummaryHTTPProtocolResponseJSON contains the JSON metadata for the struct +// [HTTPSummaryHTTPProtocolResponse] +type httpSummaryHTTPProtocolResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryHTTPProtocolResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryHTTPProtocolResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryHTTPProtocolResponseMeta struct { + DateRange []HTTPSummaryHTTPProtocolResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo HTTPSummaryHTTPProtocolResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpSummaryHTTPProtocolResponseMetaJSON `json:"-"` +} + +// httpSummaryHTTPProtocolResponseMetaJSON contains the JSON metadata for the +// struct [HTTPSummaryHTTPProtocolResponseMeta] +type httpSummaryHTTPProtocolResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryHTTPProtocolResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryHTTPProtocolResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryHTTPProtocolResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpSummaryHTTPProtocolResponseMetaDateRangeJSON `json:"-"` +} + +// httpSummaryHTTPProtocolResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [HTTPSummaryHTTPProtocolResponseMetaDateRange] +type httpSummaryHTTPProtocolResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryHTTPProtocolResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryHTTPProtocolResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryHTTPProtocolResponseMetaConfidenceInfo struct { + Annotations []HTTPSummaryHTTPProtocolResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpSummaryHTTPProtocolResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpSummaryHTTPProtocolResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [HTTPSummaryHTTPProtocolResponseMetaConfidenceInfo] +type httpSummaryHTTPProtocolResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryHTTPProtocolResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryHTTPProtocolResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryHTTPProtocolResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpSummaryHTTPProtocolResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpSummaryHTTPProtocolResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [HTTPSummaryHTTPProtocolResponseMetaConfidenceInfoAnnotation] +type httpSummaryHTTPProtocolResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryHTTPProtocolResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryHTTPProtocolResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryHTTPProtocolResponseSummary0 struct { + HTTP string `json:"http,required"` + HTTPS string `json:"https,required"` + JSON httpSummaryHTTPProtocolResponseSummary0JSON `json:"-"` +} + +// httpSummaryHTTPProtocolResponseSummary0JSON contains the JSON metadata for the +// struct [HTTPSummaryHTTPProtocolResponseSummary0] +type httpSummaryHTTPProtocolResponseSummary0JSON struct { + HTTP apijson.Field + HTTPS apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryHTTPProtocolResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryHTTPProtocolResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryHTTPVersionResponse struct { + Meta HTTPSummaryHTTPVersionResponseMeta `json:"meta,required"` + Summary0 HTTPSummaryHTTPVersionResponseSummary0 `json:"summary_0,required"` + JSON httpSummaryHTTPVersionResponseJSON `json:"-"` +} + +// httpSummaryHTTPVersionResponseJSON contains the JSON metadata for the struct +// [HTTPSummaryHTTPVersionResponse] +type httpSummaryHTTPVersionResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryHTTPVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryHTTPVersionResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryHTTPVersionResponseMeta struct { + DateRange []HTTPSummaryHTTPVersionResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo HTTPSummaryHTTPVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpSummaryHTTPVersionResponseMetaJSON `json:"-"` +} + +// httpSummaryHTTPVersionResponseMetaJSON contains the JSON metadata for the struct +// [HTTPSummaryHTTPVersionResponseMeta] +type httpSummaryHTTPVersionResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryHTTPVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryHTTPVersionResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryHTTPVersionResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpSummaryHTTPVersionResponseMetaDateRangeJSON `json:"-"` +} + +// httpSummaryHTTPVersionResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [HTTPSummaryHTTPVersionResponseMetaDateRange] +type httpSummaryHTTPVersionResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryHTTPVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryHTTPVersionResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryHTTPVersionResponseMetaConfidenceInfo struct { + Annotations []HTTPSummaryHTTPVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpSummaryHTTPVersionResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpSummaryHTTPVersionResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [HTTPSummaryHTTPVersionResponseMetaConfidenceInfo] +type httpSummaryHTTPVersionResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryHTTPVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryHTTPVersionResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryHTTPVersionResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpSummaryHTTPVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpSummaryHTTPVersionResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [HTTPSummaryHTTPVersionResponseMetaConfidenceInfoAnnotation] +type httpSummaryHTTPVersionResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryHTTPVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryHTTPVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryHTTPVersionResponseSummary0 struct { + HTTP1X string `json:"HTTP/1.x,required"` + HTTP2 string `json:"HTTP/2,required"` + HTTP3 string `json:"HTTP/3,required"` + JSON httpSummaryHTTPVersionResponseSummary0JSON `json:"-"` +} + +// httpSummaryHTTPVersionResponseSummary0JSON contains the JSON metadata for the +// struct [HTTPSummaryHTTPVersionResponseSummary0] +type httpSummaryHTTPVersionResponseSummary0JSON struct { + HTTP1X apijson.Field + HTTP2 apijson.Field + HTTP3 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryHTTPVersionResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryHTTPVersionResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryIPVersionResponse struct { + Meta HTTPSummaryIPVersionResponseMeta `json:"meta,required"` + Summary0 HTTPSummaryIPVersionResponseSummary0 `json:"summary_0,required"` + JSON httpSummaryIPVersionResponseJSON `json:"-"` +} + +// httpSummaryIPVersionResponseJSON contains the JSON metadata for the struct +// [HTTPSummaryIPVersionResponse] +type httpSummaryIPVersionResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryIPVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryIPVersionResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryIPVersionResponseMeta struct { + DateRange []HTTPSummaryIPVersionResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo HTTPSummaryIPVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpSummaryIPVersionResponseMetaJSON `json:"-"` +} + +// httpSummaryIPVersionResponseMetaJSON contains the JSON metadata for the struct +// [HTTPSummaryIPVersionResponseMeta] +type httpSummaryIPVersionResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryIPVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryIPVersionResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryIPVersionResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpSummaryIPVersionResponseMetaDateRangeJSON `json:"-"` +} + +// httpSummaryIPVersionResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [HTTPSummaryIPVersionResponseMetaDateRange] +type httpSummaryIPVersionResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryIPVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryIPVersionResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryIPVersionResponseMetaConfidenceInfo struct { + Annotations []HTTPSummaryIPVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpSummaryIPVersionResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpSummaryIPVersionResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [HTTPSummaryIPVersionResponseMetaConfidenceInfo] +type httpSummaryIPVersionResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryIPVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryIPVersionResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryIPVersionResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpSummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpSummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [HTTPSummaryIPVersionResponseMetaConfidenceInfoAnnotation] +type httpSummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryIPVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryIPVersionResponseSummary0 struct { + IPv4 string `json:"IPv4,required"` + IPv6 string `json:"IPv6,required"` + JSON httpSummaryIPVersionResponseSummary0JSON `json:"-"` +} + +// httpSummaryIPVersionResponseSummary0JSON contains the JSON metadata for the +// struct [HTTPSummaryIPVersionResponseSummary0] +type httpSummaryIPVersionResponseSummary0JSON struct { + IPv4 apijson.Field + IPv6 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryIPVersionResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryIPVersionResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryOSResponse struct { + Meta HTTPSummaryOSResponseMeta `json:"meta,required"` + Summary0 HTTPSummaryOSResponseSummary0 `json:"summary_0,required"` + JSON httpSummaryOSResponseJSON `json:"-"` +} + +// httpSummaryOSResponseJSON contains the JSON metadata for the struct +// [HTTPSummaryOSResponse] +type httpSummaryOSResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryOSResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryOSResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryOSResponseMeta struct { + DateRange []HTTPSummaryOSResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo HTTPSummaryOSResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpSummaryOSResponseMetaJSON `json:"-"` +} + +// httpSummaryOSResponseMetaJSON contains the JSON metadata for the struct +// [HTTPSummaryOSResponseMeta] +type httpSummaryOSResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryOSResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryOSResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryOSResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpSummaryOSResponseMetaDateRangeJSON `json:"-"` +} + +// httpSummaryOSResponseMetaDateRangeJSON contains the JSON metadata for the struct +// [HTTPSummaryOSResponseMetaDateRange] +type httpSummaryOSResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryOSResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryOSResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryOSResponseMetaConfidenceInfo struct { + Annotations []HTTPSummaryOSResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpSummaryOSResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpSummaryOSResponseMetaConfidenceInfoJSON contains the JSON metadata for the +// struct [HTTPSummaryOSResponseMetaConfidenceInfo] +type httpSummaryOSResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryOSResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryOSResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryOSResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpSummaryOSResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpSummaryOSResponseMetaConfidenceInfoAnnotationJSON contains the JSON metadata +// for the struct [HTTPSummaryOSResponseMetaConfidenceInfoAnnotation] +type httpSummaryOSResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryOSResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryOSResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryOSResponseSummary0 struct { + Android string `json:"ANDROID,required"` + Ios string `json:"IOS,required"` + JSON httpSummaryOSResponseSummary0JSON `json:"-"` +} + +// httpSummaryOSResponseSummary0JSON contains the JSON metadata for the struct +// [HTTPSummaryOSResponseSummary0] +type httpSummaryOSResponseSummary0JSON struct { + Android apijson.Field + Ios apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryOSResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryOSResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryTLSVersionResponse struct { + Meta HTTPSummaryTLSVersionResponseMeta `json:"meta,required"` + Summary0 HTTPSummaryTLSVersionResponseSummary0 `json:"summary_0,required"` + JSON httpSummaryTLSVersionResponseJSON `json:"-"` +} + +// httpSummaryTLSVersionResponseJSON contains the JSON metadata for the struct +// [HTTPSummaryTLSVersionResponse] +type httpSummaryTLSVersionResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryTLSVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryTLSVersionResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryTLSVersionResponseMeta struct { + DateRange []HTTPSummaryTLSVersionResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo HTTPSummaryTLSVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpSummaryTLSVersionResponseMetaJSON `json:"-"` +} + +// httpSummaryTLSVersionResponseMetaJSON contains the JSON metadata for the struct +// [HTTPSummaryTLSVersionResponseMeta] +type httpSummaryTLSVersionResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryTLSVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryTLSVersionResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryTLSVersionResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpSummaryTLSVersionResponseMetaDateRangeJSON `json:"-"` +} + +// httpSummaryTLSVersionResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [HTTPSummaryTLSVersionResponseMetaDateRange] +type httpSummaryTLSVersionResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryTLSVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryTLSVersionResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryTLSVersionResponseMetaConfidenceInfo struct { + Annotations []HTTPSummaryTLSVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpSummaryTLSVersionResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpSummaryTLSVersionResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [HTTPSummaryTLSVersionResponseMetaConfidenceInfo] +type httpSummaryTLSVersionResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryTLSVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryTLSVersionResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryTLSVersionResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpSummaryTLSVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpSummaryTLSVersionResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [HTTPSummaryTLSVersionResponseMetaConfidenceInfoAnnotation] +type httpSummaryTLSVersionResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryTLSVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryTLSVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryTLSVersionResponseSummary0 struct { + TLS1_0 string `json:"TLS 1.0,required"` + TLS1_1 string `json:"TLS 1.1,required"` + TLS1_2 string `json:"TLS 1.2,required"` + TLS1_3 string `json:"TLS 1.3,required"` + TLSQuic string `json:"TLS QUIC,required"` + JSON httpSummaryTLSVersionResponseSummary0JSON `json:"-"` +} + +// httpSummaryTLSVersionResponseSummary0JSON contains the JSON metadata for the +// struct [HTTPSummaryTLSVersionResponseSummary0] +type httpSummaryTLSVersionResponseSummary0JSON struct { + TLS1_0 apijson.Field + TLS1_1 apijson.Field + TLS1_2 apijson.Field + TLS1_3 apijson.Field + TLSQuic apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryTLSVersionResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryTLSVersionResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryBotClassParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPSummaryBotClassParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPSummaryBotClassParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPSummaryBotClassParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPSummaryBotClassParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPSummaryBotClassParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPSummaryBotClassParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPSummaryBotClassParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPSummaryBotClassParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPSummaryBotClassParams]'s query parameters as +// `url.Values`. +func (r HTTPSummaryBotClassParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type HTTPSummaryBotClassParamsDateRange string + +const ( + HTTPSummaryBotClassParamsDateRange1d HTTPSummaryBotClassParamsDateRange = "1d" + HTTPSummaryBotClassParamsDateRange2d HTTPSummaryBotClassParamsDateRange = "2d" + HTTPSummaryBotClassParamsDateRange7d HTTPSummaryBotClassParamsDateRange = "7d" + HTTPSummaryBotClassParamsDateRange14d HTTPSummaryBotClassParamsDateRange = "14d" + HTTPSummaryBotClassParamsDateRange28d HTTPSummaryBotClassParamsDateRange = "28d" + HTTPSummaryBotClassParamsDateRange12w HTTPSummaryBotClassParamsDateRange = "12w" + HTTPSummaryBotClassParamsDateRange24w HTTPSummaryBotClassParamsDateRange = "24w" + HTTPSummaryBotClassParamsDateRange52w HTTPSummaryBotClassParamsDateRange = "52w" + HTTPSummaryBotClassParamsDateRange1dControl HTTPSummaryBotClassParamsDateRange = "1dControl" + HTTPSummaryBotClassParamsDateRange2dControl HTTPSummaryBotClassParamsDateRange = "2dControl" + HTTPSummaryBotClassParamsDateRange7dControl HTTPSummaryBotClassParamsDateRange = "7dControl" + HTTPSummaryBotClassParamsDateRange14dControl HTTPSummaryBotClassParamsDateRange = "14dControl" + HTTPSummaryBotClassParamsDateRange28dControl HTTPSummaryBotClassParamsDateRange = "28dControl" + HTTPSummaryBotClassParamsDateRange12wControl HTTPSummaryBotClassParamsDateRange = "12wControl" + HTTPSummaryBotClassParamsDateRange24wControl HTTPSummaryBotClassParamsDateRange = "24wControl" +) + +type HTTPSummaryBotClassParamsDeviceType string + +const ( + HTTPSummaryBotClassParamsDeviceTypeDesktop HTTPSummaryBotClassParamsDeviceType = "DESKTOP" + HTTPSummaryBotClassParamsDeviceTypeMobile HTTPSummaryBotClassParamsDeviceType = "MOBILE" + HTTPSummaryBotClassParamsDeviceTypeOther HTTPSummaryBotClassParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPSummaryBotClassParamsFormat string + +const ( + HTTPSummaryBotClassParamsFormatJson HTTPSummaryBotClassParamsFormat = "JSON" + HTTPSummaryBotClassParamsFormatCsv HTTPSummaryBotClassParamsFormat = "CSV" +) + +type HTTPSummaryBotClassParamsHTTPProtocol string + +const ( + HTTPSummaryBotClassParamsHTTPProtocolHTTP HTTPSummaryBotClassParamsHTTPProtocol = "HTTP" + HTTPSummaryBotClassParamsHTTPProtocolHTTPS HTTPSummaryBotClassParamsHTTPProtocol = "HTTPS" +) + +type HTTPSummaryBotClassParamsHTTPVersion string + +const ( + HTTPSummaryBotClassParamsHTTPVersionHttPv1 HTTPSummaryBotClassParamsHTTPVersion = "HTTPv1" + HTTPSummaryBotClassParamsHTTPVersionHttPv2 HTTPSummaryBotClassParamsHTTPVersion = "HTTPv2" + HTTPSummaryBotClassParamsHTTPVersionHttPv3 HTTPSummaryBotClassParamsHTTPVersion = "HTTPv3" +) + +type HTTPSummaryBotClassParamsIPVersion string + +const ( + HTTPSummaryBotClassParamsIPVersionIPv4 HTTPSummaryBotClassParamsIPVersion = "IPv4" + HTTPSummaryBotClassParamsIPVersionIPv6 HTTPSummaryBotClassParamsIPVersion = "IPv6" +) + +type HTTPSummaryBotClassParamsOS string + +const ( + HTTPSummaryBotClassParamsOSWindows HTTPSummaryBotClassParamsOS = "WINDOWS" + HTTPSummaryBotClassParamsOSMacosx HTTPSummaryBotClassParamsOS = "MACOSX" + HTTPSummaryBotClassParamsOSIos HTTPSummaryBotClassParamsOS = "IOS" + HTTPSummaryBotClassParamsOSAndroid HTTPSummaryBotClassParamsOS = "ANDROID" + HTTPSummaryBotClassParamsOSChromeos HTTPSummaryBotClassParamsOS = "CHROMEOS" + HTTPSummaryBotClassParamsOSLinux HTTPSummaryBotClassParamsOS = "LINUX" + HTTPSummaryBotClassParamsOSSmartTv HTTPSummaryBotClassParamsOS = "SMART_TV" +) + +type HTTPSummaryBotClassParamsTLSVersion string + +const ( + HTTPSummaryBotClassParamsTLSVersionTlSv1_0 HTTPSummaryBotClassParamsTLSVersion = "TLSv1_0" + HTTPSummaryBotClassParamsTLSVersionTlSv1_1 HTTPSummaryBotClassParamsTLSVersion = "TLSv1_1" + HTTPSummaryBotClassParamsTLSVersionTlSv1_2 HTTPSummaryBotClassParamsTLSVersion = "TLSv1_2" + HTTPSummaryBotClassParamsTLSVersionTlSv1_3 HTTPSummaryBotClassParamsTLSVersion = "TLSv1_3" + HTTPSummaryBotClassParamsTLSVersionTlSvQuic HTTPSummaryBotClassParamsTLSVersion = "TLSvQUIC" +) + +type HTTPSummaryBotClassResponseEnvelope struct { + Result HTTPSummaryBotClassResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpSummaryBotClassResponseEnvelopeJSON `json:"-"` +} + +// httpSummaryBotClassResponseEnvelopeJSON contains the JSON metadata for the +// struct [HTTPSummaryBotClassResponseEnvelope] +type httpSummaryBotClassResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryBotClassResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryBotClassResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryDeviceTypeParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPSummaryDeviceTypeParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPSummaryDeviceTypeParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[HTTPSummaryDeviceTypeParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPSummaryDeviceTypeParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPSummaryDeviceTypeParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPSummaryDeviceTypeParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPSummaryDeviceTypeParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPSummaryDeviceTypeParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPSummaryDeviceTypeParams]'s query parameters as +// `url.Values`. +func (r HTTPSummaryDeviceTypeParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type HTTPSummaryDeviceTypeParamsBotClass string + +const ( + HTTPSummaryDeviceTypeParamsBotClassLikelyAutomated HTTPSummaryDeviceTypeParamsBotClass = "LIKELY_AUTOMATED" + HTTPSummaryDeviceTypeParamsBotClassLikelyHuman HTTPSummaryDeviceTypeParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPSummaryDeviceTypeParamsDateRange string + +const ( + HTTPSummaryDeviceTypeParamsDateRange1d HTTPSummaryDeviceTypeParamsDateRange = "1d" + HTTPSummaryDeviceTypeParamsDateRange2d HTTPSummaryDeviceTypeParamsDateRange = "2d" + HTTPSummaryDeviceTypeParamsDateRange7d HTTPSummaryDeviceTypeParamsDateRange = "7d" + HTTPSummaryDeviceTypeParamsDateRange14d HTTPSummaryDeviceTypeParamsDateRange = "14d" + HTTPSummaryDeviceTypeParamsDateRange28d HTTPSummaryDeviceTypeParamsDateRange = "28d" + HTTPSummaryDeviceTypeParamsDateRange12w HTTPSummaryDeviceTypeParamsDateRange = "12w" + HTTPSummaryDeviceTypeParamsDateRange24w HTTPSummaryDeviceTypeParamsDateRange = "24w" + HTTPSummaryDeviceTypeParamsDateRange52w HTTPSummaryDeviceTypeParamsDateRange = "52w" + HTTPSummaryDeviceTypeParamsDateRange1dControl HTTPSummaryDeviceTypeParamsDateRange = "1dControl" + HTTPSummaryDeviceTypeParamsDateRange2dControl HTTPSummaryDeviceTypeParamsDateRange = "2dControl" + HTTPSummaryDeviceTypeParamsDateRange7dControl HTTPSummaryDeviceTypeParamsDateRange = "7dControl" + HTTPSummaryDeviceTypeParamsDateRange14dControl HTTPSummaryDeviceTypeParamsDateRange = "14dControl" + HTTPSummaryDeviceTypeParamsDateRange28dControl HTTPSummaryDeviceTypeParamsDateRange = "28dControl" + HTTPSummaryDeviceTypeParamsDateRange12wControl HTTPSummaryDeviceTypeParamsDateRange = "12wControl" + HTTPSummaryDeviceTypeParamsDateRange24wControl HTTPSummaryDeviceTypeParamsDateRange = "24wControl" +) + +// Format results are returned in. +type HTTPSummaryDeviceTypeParamsFormat string + +const ( + HTTPSummaryDeviceTypeParamsFormatJson HTTPSummaryDeviceTypeParamsFormat = "JSON" + HTTPSummaryDeviceTypeParamsFormatCsv HTTPSummaryDeviceTypeParamsFormat = "CSV" +) + +type HTTPSummaryDeviceTypeParamsHTTPProtocol string + +const ( + HTTPSummaryDeviceTypeParamsHTTPProtocolHTTP HTTPSummaryDeviceTypeParamsHTTPProtocol = "HTTP" + HTTPSummaryDeviceTypeParamsHTTPProtocolHTTPS HTTPSummaryDeviceTypeParamsHTTPProtocol = "HTTPS" +) + +type HTTPSummaryDeviceTypeParamsHTTPVersion string + +const ( + HTTPSummaryDeviceTypeParamsHTTPVersionHttPv1 HTTPSummaryDeviceTypeParamsHTTPVersion = "HTTPv1" + HTTPSummaryDeviceTypeParamsHTTPVersionHttPv2 HTTPSummaryDeviceTypeParamsHTTPVersion = "HTTPv2" + HTTPSummaryDeviceTypeParamsHTTPVersionHttPv3 HTTPSummaryDeviceTypeParamsHTTPVersion = "HTTPv3" +) + +type HTTPSummaryDeviceTypeParamsIPVersion string + +const ( + HTTPSummaryDeviceTypeParamsIPVersionIPv4 HTTPSummaryDeviceTypeParamsIPVersion = "IPv4" + HTTPSummaryDeviceTypeParamsIPVersionIPv6 HTTPSummaryDeviceTypeParamsIPVersion = "IPv6" +) + +type HTTPSummaryDeviceTypeParamsOS string + +const ( + HTTPSummaryDeviceTypeParamsOSWindows HTTPSummaryDeviceTypeParamsOS = "WINDOWS" + HTTPSummaryDeviceTypeParamsOSMacosx HTTPSummaryDeviceTypeParamsOS = "MACOSX" + HTTPSummaryDeviceTypeParamsOSIos HTTPSummaryDeviceTypeParamsOS = "IOS" + HTTPSummaryDeviceTypeParamsOSAndroid HTTPSummaryDeviceTypeParamsOS = "ANDROID" + HTTPSummaryDeviceTypeParamsOSChromeos HTTPSummaryDeviceTypeParamsOS = "CHROMEOS" + HTTPSummaryDeviceTypeParamsOSLinux HTTPSummaryDeviceTypeParamsOS = "LINUX" + HTTPSummaryDeviceTypeParamsOSSmartTv HTTPSummaryDeviceTypeParamsOS = "SMART_TV" +) + +type HTTPSummaryDeviceTypeParamsTLSVersion string + +const ( + HTTPSummaryDeviceTypeParamsTLSVersionTlSv1_0 HTTPSummaryDeviceTypeParamsTLSVersion = "TLSv1_0" + HTTPSummaryDeviceTypeParamsTLSVersionTlSv1_1 HTTPSummaryDeviceTypeParamsTLSVersion = "TLSv1_1" + HTTPSummaryDeviceTypeParamsTLSVersionTlSv1_2 HTTPSummaryDeviceTypeParamsTLSVersion = "TLSv1_2" + HTTPSummaryDeviceTypeParamsTLSVersionTlSv1_3 HTTPSummaryDeviceTypeParamsTLSVersion = "TLSv1_3" + HTTPSummaryDeviceTypeParamsTLSVersionTlSvQuic HTTPSummaryDeviceTypeParamsTLSVersion = "TLSvQUIC" +) + +type HTTPSummaryDeviceTypeResponseEnvelope struct { + Result HTTPSummaryDeviceTypeResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpSummaryDeviceTypeResponseEnvelopeJSON `json:"-"` +} + +// httpSummaryDeviceTypeResponseEnvelopeJSON contains the JSON metadata for the +// struct [HTTPSummaryDeviceTypeResponseEnvelope] +type httpSummaryDeviceTypeResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryDeviceTypeResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryDeviceTypeResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryHTTPProtocolParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPSummaryHTTPProtocolParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPSummaryHTTPProtocolParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPSummaryHTTPProtocolParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPSummaryHTTPProtocolParamsFormat] `query:"format"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPSummaryHTTPProtocolParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPSummaryHTTPProtocolParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPSummaryHTTPProtocolParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPSummaryHTTPProtocolParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPSummaryHTTPProtocolParams]'s query parameters as +// `url.Values`. +func (r HTTPSummaryHTTPProtocolParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type HTTPSummaryHTTPProtocolParamsBotClass string + +const ( + HTTPSummaryHTTPProtocolParamsBotClassLikelyAutomated HTTPSummaryHTTPProtocolParamsBotClass = "LIKELY_AUTOMATED" + HTTPSummaryHTTPProtocolParamsBotClassLikelyHuman HTTPSummaryHTTPProtocolParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPSummaryHTTPProtocolParamsDateRange string + +const ( + HTTPSummaryHTTPProtocolParamsDateRange1d HTTPSummaryHTTPProtocolParamsDateRange = "1d" + HTTPSummaryHTTPProtocolParamsDateRange2d HTTPSummaryHTTPProtocolParamsDateRange = "2d" + HTTPSummaryHTTPProtocolParamsDateRange7d HTTPSummaryHTTPProtocolParamsDateRange = "7d" + HTTPSummaryHTTPProtocolParamsDateRange14d HTTPSummaryHTTPProtocolParamsDateRange = "14d" + HTTPSummaryHTTPProtocolParamsDateRange28d HTTPSummaryHTTPProtocolParamsDateRange = "28d" + HTTPSummaryHTTPProtocolParamsDateRange12w HTTPSummaryHTTPProtocolParamsDateRange = "12w" + HTTPSummaryHTTPProtocolParamsDateRange24w HTTPSummaryHTTPProtocolParamsDateRange = "24w" + HTTPSummaryHTTPProtocolParamsDateRange52w HTTPSummaryHTTPProtocolParamsDateRange = "52w" + HTTPSummaryHTTPProtocolParamsDateRange1dControl HTTPSummaryHTTPProtocolParamsDateRange = "1dControl" + HTTPSummaryHTTPProtocolParamsDateRange2dControl HTTPSummaryHTTPProtocolParamsDateRange = "2dControl" + HTTPSummaryHTTPProtocolParamsDateRange7dControl HTTPSummaryHTTPProtocolParamsDateRange = "7dControl" + HTTPSummaryHTTPProtocolParamsDateRange14dControl HTTPSummaryHTTPProtocolParamsDateRange = "14dControl" + HTTPSummaryHTTPProtocolParamsDateRange28dControl HTTPSummaryHTTPProtocolParamsDateRange = "28dControl" + HTTPSummaryHTTPProtocolParamsDateRange12wControl HTTPSummaryHTTPProtocolParamsDateRange = "12wControl" + HTTPSummaryHTTPProtocolParamsDateRange24wControl HTTPSummaryHTTPProtocolParamsDateRange = "24wControl" +) + +type HTTPSummaryHTTPProtocolParamsDeviceType string + +const ( + HTTPSummaryHTTPProtocolParamsDeviceTypeDesktop HTTPSummaryHTTPProtocolParamsDeviceType = "DESKTOP" + HTTPSummaryHTTPProtocolParamsDeviceTypeMobile HTTPSummaryHTTPProtocolParamsDeviceType = "MOBILE" + HTTPSummaryHTTPProtocolParamsDeviceTypeOther HTTPSummaryHTTPProtocolParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPSummaryHTTPProtocolParamsFormat string + +const ( + HTTPSummaryHTTPProtocolParamsFormatJson HTTPSummaryHTTPProtocolParamsFormat = "JSON" + HTTPSummaryHTTPProtocolParamsFormatCsv HTTPSummaryHTTPProtocolParamsFormat = "CSV" +) + +type HTTPSummaryHTTPProtocolParamsHTTPVersion string + +const ( + HTTPSummaryHTTPProtocolParamsHTTPVersionHttPv1 HTTPSummaryHTTPProtocolParamsHTTPVersion = "HTTPv1" + HTTPSummaryHTTPProtocolParamsHTTPVersionHttPv2 HTTPSummaryHTTPProtocolParamsHTTPVersion = "HTTPv2" + HTTPSummaryHTTPProtocolParamsHTTPVersionHttPv3 HTTPSummaryHTTPProtocolParamsHTTPVersion = "HTTPv3" +) + +type HTTPSummaryHTTPProtocolParamsIPVersion string + +const ( + HTTPSummaryHTTPProtocolParamsIPVersionIPv4 HTTPSummaryHTTPProtocolParamsIPVersion = "IPv4" + HTTPSummaryHTTPProtocolParamsIPVersionIPv6 HTTPSummaryHTTPProtocolParamsIPVersion = "IPv6" +) + +type HTTPSummaryHTTPProtocolParamsOS string + +const ( + HTTPSummaryHTTPProtocolParamsOSWindows HTTPSummaryHTTPProtocolParamsOS = "WINDOWS" + HTTPSummaryHTTPProtocolParamsOSMacosx HTTPSummaryHTTPProtocolParamsOS = "MACOSX" + HTTPSummaryHTTPProtocolParamsOSIos HTTPSummaryHTTPProtocolParamsOS = "IOS" + HTTPSummaryHTTPProtocolParamsOSAndroid HTTPSummaryHTTPProtocolParamsOS = "ANDROID" + HTTPSummaryHTTPProtocolParamsOSChromeos HTTPSummaryHTTPProtocolParamsOS = "CHROMEOS" + HTTPSummaryHTTPProtocolParamsOSLinux HTTPSummaryHTTPProtocolParamsOS = "LINUX" + HTTPSummaryHTTPProtocolParamsOSSmartTv HTTPSummaryHTTPProtocolParamsOS = "SMART_TV" +) + +type HTTPSummaryHTTPProtocolParamsTLSVersion string + +const ( + HTTPSummaryHTTPProtocolParamsTLSVersionTlSv1_0 HTTPSummaryHTTPProtocolParamsTLSVersion = "TLSv1_0" + HTTPSummaryHTTPProtocolParamsTLSVersionTlSv1_1 HTTPSummaryHTTPProtocolParamsTLSVersion = "TLSv1_1" + HTTPSummaryHTTPProtocolParamsTLSVersionTlSv1_2 HTTPSummaryHTTPProtocolParamsTLSVersion = "TLSv1_2" + HTTPSummaryHTTPProtocolParamsTLSVersionTlSv1_3 HTTPSummaryHTTPProtocolParamsTLSVersion = "TLSv1_3" + HTTPSummaryHTTPProtocolParamsTLSVersionTlSvQuic HTTPSummaryHTTPProtocolParamsTLSVersion = "TLSvQUIC" +) + +type HTTPSummaryHTTPProtocolResponseEnvelope struct { + Result HTTPSummaryHTTPProtocolResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpSummaryHTTPProtocolResponseEnvelopeJSON `json:"-"` +} + +// httpSummaryHTTPProtocolResponseEnvelopeJSON contains the JSON metadata for the +// struct [HTTPSummaryHTTPProtocolResponseEnvelope] +type httpSummaryHTTPProtocolResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryHTTPProtocolResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryHTTPProtocolResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryHTTPVersionParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPSummaryHTTPVersionParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPSummaryHTTPVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPSummaryHTTPVersionParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPSummaryHTTPVersionParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPSummaryHTTPVersionParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for ip version. + IPVersion param.Field[[]HTTPSummaryHTTPVersionParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPSummaryHTTPVersionParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPSummaryHTTPVersionParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPSummaryHTTPVersionParams]'s query parameters as +// `url.Values`. +func (r HTTPSummaryHTTPVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type HTTPSummaryHTTPVersionParamsBotClass string + +const ( + HTTPSummaryHTTPVersionParamsBotClassLikelyAutomated HTTPSummaryHTTPVersionParamsBotClass = "LIKELY_AUTOMATED" + HTTPSummaryHTTPVersionParamsBotClassLikelyHuman HTTPSummaryHTTPVersionParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPSummaryHTTPVersionParamsDateRange string + +const ( + HTTPSummaryHTTPVersionParamsDateRange1d HTTPSummaryHTTPVersionParamsDateRange = "1d" + HTTPSummaryHTTPVersionParamsDateRange2d HTTPSummaryHTTPVersionParamsDateRange = "2d" + HTTPSummaryHTTPVersionParamsDateRange7d HTTPSummaryHTTPVersionParamsDateRange = "7d" + HTTPSummaryHTTPVersionParamsDateRange14d HTTPSummaryHTTPVersionParamsDateRange = "14d" + HTTPSummaryHTTPVersionParamsDateRange28d HTTPSummaryHTTPVersionParamsDateRange = "28d" + HTTPSummaryHTTPVersionParamsDateRange12w HTTPSummaryHTTPVersionParamsDateRange = "12w" + HTTPSummaryHTTPVersionParamsDateRange24w HTTPSummaryHTTPVersionParamsDateRange = "24w" + HTTPSummaryHTTPVersionParamsDateRange52w HTTPSummaryHTTPVersionParamsDateRange = "52w" + HTTPSummaryHTTPVersionParamsDateRange1dControl HTTPSummaryHTTPVersionParamsDateRange = "1dControl" + HTTPSummaryHTTPVersionParamsDateRange2dControl HTTPSummaryHTTPVersionParamsDateRange = "2dControl" + HTTPSummaryHTTPVersionParamsDateRange7dControl HTTPSummaryHTTPVersionParamsDateRange = "7dControl" + HTTPSummaryHTTPVersionParamsDateRange14dControl HTTPSummaryHTTPVersionParamsDateRange = "14dControl" + HTTPSummaryHTTPVersionParamsDateRange28dControl HTTPSummaryHTTPVersionParamsDateRange = "28dControl" + HTTPSummaryHTTPVersionParamsDateRange12wControl HTTPSummaryHTTPVersionParamsDateRange = "12wControl" + HTTPSummaryHTTPVersionParamsDateRange24wControl HTTPSummaryHTTPVersionParamsDateRange = "24wControl" +) + +type HTTPSummaryHTTPVersionParamsDeviceType string + +const ( + HTTPSummaryHTTPVersionParamsDeviceTypeDesktop HTTPSummaryHTTPVersionParamsDeviceType = "DESKTOP" + HTTPSummaryHTTPVersionParamsDeviceTypeMobile HTTPSummaryHTTPVersionParamsDeviceType = "MOBILE" + HTTPSummaryHTTPVersionParamsDeviceTypeOther HTTPSummaryHTTPVersionParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPSummaryHTTPVersionParamsFormat string + +const ( + HTTPSummaryHTTPVersionParamsFormatJson HTTPSummaryHTTPVersionParamsFormat = "JSON" + HTTPSummaryHTTPVersionParamsFormatCsv HTTPSummaryHTTPVersionParamsFormat = "CSV" +) + +type HTTPSummaryHTTPVersionParamsHTTPProtocol string + +const ( + HTTPSummaryHTTPVersionParamsHTTPProtocolHTTP HTTPSummaryHTTPVersionParamsHTTPProtocol = "HTTP" + HTTPSummaryHTTPVersionParamsHTTPProtocolHTTPS HTTPSummaryHTTPVersionParamsHTTPProtocol = "HTTPS" +) + +type HTTPSummaryHTTPVersionParamsIPVersion string + +const ( + HTTPSummaryHTTPVersionParamsIPVersionIPv4 HTTPSummaryHTTPVersionParamsIPVersion = "IPv4" + HTTPSummaryHTTPVersionParamsIPVersionIPv6 HTTPSummaryHTTPVersionParamsIPVersion = "IPv6" +) + +type HTTPSummaryHTTPVersionParamsOS string + +const ( + HTTPSummaryHTTPVersionParamsOSWindows HTTPSummaryHTTPVersionParamsOS = "WINDOWS" + HTTPSummaryHTTPVersionParamsOSMacosx HTTPSummaryHTTPVersionParamsOS = "MACOSX" + HTTPSummaryHTTPVersionParamsOSIos HTTPSummaryHTTPVersionParamsOS = "IOS" + HTTPSummaryHTTPVersionParamsOSAndroid HTTPSummaryHTTPVersionParamsOS = "ANDROID" + HTTPSummaryHTTPVersionParamsOSChromeos HTTPSummaryHTTPVersionParamsOS = "CHROMEOS" + HTTPSummaryHTTPVersionParamsOSLinux HTTPSummaryHTTPVersionParamsOS = "LINUX" + HTTPSummaryHTTPVersionParamsOSSmartTv HTTPSummaryHTTPVersionParamsOS = "SMART_TV" +) + +type HTTPSummaryHTTPVersionParamsTLSVersion string + +const ( + HTTPSummaryHTTPVersionParamsTLSVersionTlSv1_0 HTTPSummaryHTTPVersionParamsTLSVersion = "TLSv1_0" + HTTPSummaryHTTPVersionParamsTLSVersionTlSv1_1 HTTPSummaryHTTPVersionParamsTLSVersion = "TLSv1_1" + HTTPSummaryHTTPVersionParamsTLSVersionTlSv1_2 HTTPSummaryHTTPVersionParamsTLSVersion = "TLSv1_2" + HTTPSummaryHTTPVersionParamsTLSVersionTlSv1_3 HTTPSummaryHTTPVersionParamsTLSVersion = "TLSv1_3" + HTTPSummaryHTTPVersionParamsTLSVersionTlSvQuic HTTPSummaryHTTPVersionParamsTLSVersion = "TLSvQUIC" +) + +type HTTPSummaryHTTPVersionResponseEnvelope struct { + Result HTTPSummaryHTTPVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpSummaryHTTPVersionResponseEnvelopeJSON `json:"-"` +} + +// httpSummaryHTTPVersionResponseEnvelopeJSON contains the JSON metadata for the +// struct [HTTPSummaryHTTPVersionResponseEnvelope] +type httpSummaryHTTPVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryHTTPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryHTTPVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryIPVersionParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPSummaryIPVersionParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPSummaryIPVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPSummaryIPVersionParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPSummaryIPVersionParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPSummaryIPVersionParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPSummaryIPVersionParamsHTTPVersion] `query:"httpVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPSummaryIPVersionParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPSummaryIPVersionParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPSummaryIPVersionParams]'s query parameters as +// `url.Values`. +func (r HTTPSummaryIPVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type HTTPSummaryIPVersionParamsBotClass string + +const ( + HTTPSummaryIPVersionParamsBotClassLikelyAutomated HTTPSummaryIPVersionParamsBotClass = "LIKELY_AUTOMATED" + HTTPSummaryIPVersionParamsBotClassLikelyHuman HTTPSummaryIPVersionParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPSummaryIPVersionParamsDateRange string + +const ( + HTTPSummaryIPVersionParamsDateRange1d HTTPSummaryIPVersionParamsDateRange = "1d" + HTTPSummaryIPVersionParamsDateRange2d HTTPSummaryIPVersionParamsDateRange = "2d" + HTTPSummaryIPVersionParamsDateRange7d HTTPSummaryIPVersionParamsDateRange = "7d" + HTTPSummaryIPVersionParamsDateRange14d HTTPSummaryIPVersionParamsDateRange = "14d" + HTTPSummaryIPVersionParamsDateRange28d HTTPSummaryIPVersionParamsDateRange = "28d" + HTTPSummaryIPVersionParamsDateRange12w HTTPSummaryIPVersionParamsDateRange = "12w" + HTTPSummaryIPVersionParamsDateRange24w HTTPSummaryIPVersionParamsDateRange = "24w" + HTTPSummaryIPVersionParamsDateRange52w HTTPSummaryIPVersionParamsDateRange = "52w" + HTTPSummaryIPVersionParamsDateRange1dControl HTTPSummaryIPVersionParamsDateRange = "1dControl" + HTTPSummaryIPVersionParamsDateRange2dControl HTTPSummaryIPVersionParamsDateRange = "2dControl" + HTTPSummaryIPVersionParamsDateRange7dControl HTTPSummaryIPVersionParamsDateRange = "7dControl" + HTTPSummaryIPVersionParamsDateRange14dControl HTTPSummaryIPVersionParamsDateRange = "14dControl" + HTTPSummaryIPVersionParamsDateRange28dControl HTTPSummaryIPVersionParamsDateRange = "28dControl" + HTTPSummaryIPVersionParamsDateRange12wControl HTTPSummaryIPVersionParamsDateRange = "12wControl" + HTTPSummaryIPVersionParamsDateRange24wControl HTTPSummaryIPVersionParamsDateRange = "24wControl" +) + +type HTTPSummaryIPVersionParamsDeviceType string + +const ( + HTTPSummaryIPVersionParamsDeviceTypeDesktop HTTPSummaryIPVersionParamsDeviceType = "DESKTOP" + HTTPSummaryIPVersionParamsDeviceTypeMobile HTTPSummaryIPVersionParamsDeviceType = "MOBILE" + HTTPSummaryIPVersionParamsDeviceTypeOther HTTPSummaryIPVersionParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPSummaryIPVersionParamsFormat string + +const ( + HTTPSummaryIPVersionParamsFormatJson HTTPSummaryIPVersionParamsFormat = "JSON" + HTTPSummaryIPVersionParamsFormatCsv HTTPSummaryIPVersionParamsFormat = "CSV" +) + +type HTTPSummaryIPVersionParamsHTTPProtocol string + +const ( + HTTPSummaryIPVersionParamsHTTPProtocolHTTP HTTPSummaryIPVersionParamsHTTPProtocol = "HTTP" + HTTPSummaryIPVersionParamsHTTPProtocolHTTPS HTTPSummaryIPVersionParamsHTTPProtocol = "HTTPS" +) + +type HTTPSummaryIPVersionParamsHTTPVersion string + +const ( + HTTPSummaryIPVersionParamsHTTPVersionHttPv1 HTTPSummaryIPVersionParamsHTTPVersion = "HTTPv1" + HTTPSummaryIPVersionParamsHTTPVersionHttPv2 HTTPSummaryIPVersionParamsHTTPVersion = "HTTPv2" + HTTPSummaryIPVersionParamsHTTPVersionHttPv3 HTTPSummaryIPVersionParamsHTTPVersion = "HTTPv3" +) + +type HTTPSummaryIPVersionParamsOS string + +const ( + HTTPSummaryIPVersionParamsOSWindows HTTPSummaryIPVersionParamsOS = "WINDOWS" + HTTPSummaryIPVersionParamsOSMacosx HTTPSummaryIPVersionParamsOS = "MACOSX" + HTTPSummaryIPVersionParamsOSIos HTTPSummaryIPVersionParamsOS = "IOS" + HTTPSummaryIPVersionParamsOSAndroid HTTPSummaryIPVersionParamsOS = "ANDROID" + HTTPSummaryIPVersionParamsOSChromeos HTTPSummaryIPVersionParamsOS = "CHROMEOS" + HTTPSummaryIPVersionParamsOSLinux HTTPSummaryIPVersionParamsOS = "LINUX" + HTTPSummaryIPVersionParamsOSSmartTv HTTPSummaryIPVersionParamsOS = "SMART_TV" +) + +type HTTPSummaryIPVersionParamsTLSVersion string + +const ( + HTTPSummaryIPVersionParamsTLSVersionTlSv1_0 HTTPSummaryIPVersionParamsTLSVersion = "TLSv1_0" + HTTPSummaryIPVersionParamsTLSVersionTlSv1_1 HTTPSummaryIPVersionParamsTLSVersion = "TLSv1_1" + HTTPSummaryIPVersionParamsTLSVersionTlSv1_2 HTTPSummaryIPVersionParamsTLSVersion = "TLSv1_2" + HTTPSummaryIPVersionParamsTLSVersionTlSv1_3 HTTPSummaryIPVersionParamsTLSVersion = "TLSv1_3" + HTTPSummaryIPVersionParamsTLSVersionTlSvQuic HTTPSummaryIPVersionParamsTLSVersion = "TLSvQUIC" +) + +type HTTPSummaryIPVersionResponseEnvelope struct { + Result HTTPSummaryIPVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpSummaryIPVersionResponseEnvelopeJSON `json:"-"` +} + +// httpSummaryIPVersionResponseEnvelopeJSON contains the JSON metadata for the +// struct [HTTPSummaryIPVersionResponseEnvelope] +type httpSummaryIPVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryIPVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryOSParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPSummaryOSParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPSummaryOSParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPSummaryOSParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPSummaryOSParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPSummaryOSParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPSummaryOSParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPSummaryOSParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPSummaryOSParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPSummaryOSParams]'s query parameters as `url.Values`. +func (r HTTPSummaryOSParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type HTTPSummaryOSParamsBotClass string + +const ( + HTTPSummaryOSParamsBotClassLikelyAutomated HTTPSummaryOSParamsBotClass = "LIKELY_AUTOMATED" + HTTPSummaryOSParamsBotClassLikelyHuman HTTPSummaryOSParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPSummaryOSParamsDateRange string + +const ( + HTTPSummaryOSParamsDateRange1d HTTPSummaryOSParamsDateRange = "1d" + HTTPSummaryOSParamsDateRange2d HTTPSummaryOSParamsDateRange = "2d" + HTTPSummaryOSParamsDateRange7d HTTPSummaryOSParamsDateRange = "7d" + HTTPSummaryOSParamsDateRange14d HTTPSummaryOSParamsDateRange = "14d" + HTTPSummaryOSParamsDateRange28d HTTPSummaryOSParamsDateRange = "28d" + HTTPSummaryOSParamsDateRange12w HTTPSummaryOSParamsDateRange = "12w" + HTTPSummaryOSParamsDateRange24w HTTPSummaryOSParamsDateRange = "24w" + HTTPSummaryOSParamsDateRange52w HTTPSummaryOSParamsDateRange = "52w" + HTTPSummaryOSParamsDateRange1dControl HTTPSummaryOSParamsDateRange = "1dControl" + HTTPSummaryOSParamsDateRange2dControl HTTPSummaryOSParamsDateRange = "2dControl" + HTTPSummaryOSParamsDateRange7dControl HTTPSummaryOSParamsDateRange = "7dControl" + HTTPSummaryOSParamsDateRange14dControl HTTPSummaryOSParamsDateRange = "14dControl" + HTTPSummaryOSParamsDateRange28dControl HTTPSummaryOSParamsDateRange = "28dControl" + HTTPSummaryOSParamsDateRange12wControl HTTPSummaryOSParamsDateRange = "12wControl" + HTTPSummaryOSParamsDateRange24wControl HTTPSummaryOSParamsDateRange = "24wControl" +) + +type HTTPSummaryOSParamsDeviceType string + +const ( + HTTPSummaryOSParamsDeviceTypeDesktop HTTPSummaryOSParamsDeviceType = "DESKTOP" + HTTPSummaryOSParamsDeviceTypeMobile HTTPSummaryOSParamsDeviceType = "MOBILE" + HTTPSummaryOSParamsDeviceTypeOther HTTPSummaryOSParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPSummaryOSParamsFormat string + +const ( + HTTPSummaryOSParamsFormatJson HTTPSummaryOSParamsFormat = "JSON" + HTTPSummaryOSParamsFormatCsv HTTPSummaryOSParamsFormat = "CSV" +) + +type HTTPSummaryOSParamsHTTPProtocol string + +const ( + HTTPSummaryOSParamsHTTPProtocolHTTP HTTPSummaryOSParamsHTTPProtocol = "HTTP" + HTTPSummaryOSParamsHTTPProtocolHTTPS HTTPSummaryOSParamsHTTPProtocol = "HTTPS" +) + +type HTTPSummaryOSParamsHTTPVersion string + +const ( + HTTPSummaryOSParamsHTTPVersionHttPv1 HTTPSummaryOSParamsHTTPVersion = "HTTPv1" + HTTPSummaryOSParamsHTTPVersionHttPv2 HTTPSummaryOSParamsHTTPVersion = "HTTPv2" + HTTPSummaryOSParamsHTTPVersionHttPv3 HTTPSummaryOSParamsHTTPVersion = "HTTPv3" +) + +type HTTPSummaryOSParamsIPVersion string + +const ( + HTTPSummaryOSParamsIPVersionIPv4 HTTPSummaryOSParamsIPVersion = "IPv4" + HTTPSummaryOSParamsIPVersionIPv6 HTTPSummaryOSParamsIPVersion = "IPv6" +) + +type HTTPSummaryOSParamsTLSVersion string + +const ( + HTTPSummaryOSParamsTLSVersionTlSv1_0 HTTPSummaryOSParamsTLSVersion = "TLSv1_0" + HTTPSummaryOSParamsTLSVersionTlSv1_1 HTTPSummaryOSParamsTLSVersion = "TLSv1_1" + HTTPSummaryOSParamsTLSVersionTlSv1_2 HTTPSummaryOSParamsTLSVersion = "TLSv1_2" + HTTPSummaryOSParamsTLSVersionTlSv1_3 HTTPSummaryOSParamsTLSVersion = "TLSv1_3" + HTTPSummaryOSParamsTLSVersionTlSvQuic HTTPSummaryOSParamsTLSVersion = "TLSvQUIC" +) + +type HTTPSummaryOSResponseEnvelope struct { + Result HTTPSummaryOSResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpSummaryOSResponseEnvelopeJSON `json:"-"` +} + +// httpSummaryOSResponseEnvelopeJSON contains the JSON metadata for the struct +// [HTTPSummaryOSResponseEnvelope] +type httpSummaryOSResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryOSResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryOSResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HTTPSummaryTLSVersionParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPSummaryTLSVersionParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPSummaryTLSVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPSummaryTLSVersionParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPSummaryTLSVersionParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPSummaryTLSVersionParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPSummaryTLSVersionParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPSummaryTLSVersionParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPSummaryTLSVersionParamsOS] `query:"os"` +} + +// URLQuery serializes [HTTPSummaryTLSVersionParams]'s query parameters as +// `url.Values`. +func (r HTTPSummaryTLSVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type HTTPSummaryTLSVersionParamsBotClass string + +const ( + HTTPSummaryTLSVersionParamsBotClassLikelyAutomated HTTPSummaryTLSVersionParamsBotClass = "LIKELY_AUTOMATED" + HTTPSummaryTLSVersionParamsBotClassLikelyHuman HTTPSummaryTLSVersionParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPSummaryTLSVersionParamsDateRange string + +const ( + HTTPSummaryTLSVersionParamsDateRange1d HTTPSummaryTLSVersionParamsDateRange = "1d" + HTTPSummaryTLSVersionParamsDateRange2d HTTPSummaryTLSVersionParamsDateRange = "2d" + HTTPSummaryTLSVersionParamsDateRange7d HTTPSummaryTLSVersionParamsDateRange = "7d" + HTTPSummaryTLSVersionParamsDateRange14d HTTPSummaryTLSVersionParamsDateRange = "14d" + HTTPSummaryTLSVersionParamsDateRange28d HTTPSummaryTLSVersionParamsDateRange = "28d" + HTTPSummaryTLSVersionParamsDateRange12w HTTPSummaryTLSVersionParamsDateRange = "12w" + HTTPSummaryTLSVersionParamsDateRange24w HTTPSummaryTLSVersionParamsDateRange = "24w" + HTTPSummaryTLSVersionParamsDateRange52w HTTPSummaryTLSVersionParamsDateRange = "52w" + HTTPSummaryTLSVersionParamsDateRange1dControl HTTPSummaryTLSVersionParamsDateRange = "1dControl" + HTTPSummaryTLSVersionParamsDateRange2dControl HTTPSummaryTLSVersionParamsDateRange = "2dControl" + HTTPSummaryTLSVersionParamsDateRange7dControl HTTPSummaryTLSVersionParamsDateRange = "7dControl" + HTTPSummaryTLSVersionParamsDateRange14dControl HTTPSummaryTLSVersionParamsDateRange = "14dControl" + HTTPSummaryTLSVersionParamsDateRange28dControl HTTPSummaryTLSVersionParamsDateRange = "28dControl" + HTTPSummaryTLSVersionParamsDateRange12wControl HTTPSummaryTLSVersionParamsDateRange = "12wControl" + HTTPSummaryTLSVersionParamsDateRange24wControl HTTPSummaryTLSVersionParamsDateRange = "24wControl" +) + +type HTTPSummaryTLSVersionParamsDeviceType string + +const ( + HTTPSummaryTLSVersionParamsDeviceTypeDesktop HTTPSummaryTLSVersionParamsDeviceType = "DESKTOP" + HTTPSummaryTLSVersionParamsDeviceTypeMobile HTTPSummaryTLSVersionParamsDeviceType = "MOBILE" + HTTPSummaryTLSVersionParamsDeviceTypeOther HTTPSummaryTLSVersionParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPSummaryTLSVersionParamsFormat string + +const ( + HTTPSummaryTLSVersionParamsFormatJson HTTPSummaryTLSVersionParamsFormat = "JSON" + HTTPSummaryTLSVersionParamsFormatCsv HTTPSummaryTLSVersionParamsFormat = "CSV" +) + +type HTTPSummaryTLSVersionParamsHTTPProtocol string + +const ( + HTTPSummaryTLSVersionParamsHTTPProtocolHTTP HTTPSummaryTLSVersionParamsHTTPProtocol = "HTTP" + HTTPSummaryTLSVersionParamsHTTPProtocolHTTPS HTTPSummaryTLSVersionParamsHTTPProtocol = "HTTPS" +) + +type HTTPSummaryTLSVersionParamsHTTPVersion string + +const ( + HTTPSummaryTLSVersionParamsHTTPVersionHttPv1 HTTPSummaryTLSVersionParamsHTTPVersion = "HTTPv1" + HTTPSummaryTLSVersionParamsHTTPVersionHttPv2 HTTPSummaryTLSVersionParamsHTTPVersion = "HTTPv2" + HTTPSummaryTLSVersionParamsHTTPVersionHttPv3 HTTPSummaryTLSVersionParamsHTTPVersion = "HTTPv3" +) + +type HTTPSummaryTLSVersionParamsIPVersion string + +const ( + HTTPSummaryTLSVersionParamsIPVersionIPv4 HTTPSummaryTLSVersionParamsIPVersion = "IPv4" + HTTPSummaryTLSVersionParamsIPVersionIPv6 HTTPSummaryTLSVersionParamsIPVersion = "IPv6" +) + +type HTTPSummaryTLSVersionParamsOS string + +const ( + HTTPSummaryTLSVersionParamsOSWindows HTTPSummaryTLSVersionParamsOS = "WINDOWS" + HTTPSummaryTLSVersionParamsOSMacosx HTTPSummaryTLSVersionParamsOS = "MACOSX" + HTTPSummaryTLSVersionParamsOSIos HTTPSummaryTLSVersionParamsOS = "IOS" + HTTPSummaryTLSVersionParamsOSAndroid HTTPSummaryTLSVersionParamsOS = "ANDROID" + HTTPSummaryTLSVersionParamsOSChromeos HTTPSummaryTLSVersionParamsOS = "CHROMEOS" + HTTPSummaryTLSVersionParamsOSLinux HTTPSummaryTLSVersionParamsOS = "LINUX" + HTTPSummaryTLSVersionParamsOSSmartTv HTTPSummaryTLSVersionParamsOS = "SMART_TV" +) + +type HTTPSummaryTLSVersionResponseEnvelope struct { + Result HTTPSummaryTLSVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpSummaryTLSVersionResponseEnvelopeJSON `json:"-"` +} + +// httpSummaryTLSVersionResponseEnvelopeJSON contains the JSON metadata for the +// struct [HTTPSummaryTLSVersionResponseEnvelope] +type httpSummaryTLSVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPSummaryTLSVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpSummaryTLSVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httpsummary_test.go b/radar/httpsummary_test.go new file mode 100644 index 00000000000..09db8054892 --- /dev/null +++ b/radar/httpsummary_test.go @@ -0,0 +1,289 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPSummaryBotClassWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Summary.BotClass(context.TODO(), radar.HTTPSummaryBotClassParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPSummaryBotClassParamsDateRange{radar.HTTPSummaryBotClassParamsDateRange1d, radar.HTTPSummaryBotClassParamsDateRange2d, radar.HTTPSummaryBotClassParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPSummaryBotClassParamsDeviceType{radar.HTTPSummaryBotClassParamsDeviceTypeDesktop, radar.HTTPSummaryBotClassParamsDeviceTypeMobile, radar.HTTPSummaryBotClassParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPSummaryBotClassParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPSummaryBotClassParamsHTTPProtocol{radar.HTTPSummaryBotClassParamsHTTPProtocolHTTP, radar.HTTPSummaryBotClassParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPSummaryBotClassParamsHTTPVersion{radar.HTTPSummaryBotClassParamsHTTPVersionHttPv1, radar.HTTPSummaryBotClassParamsHTTPVersionHttPv2, radar.HTTPSummaryBotClassParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPSummaryBotClassParamsIPVersion{radar.HTTPSummaryBotClassParamsIPVersionIPv4, radar.HTTPSummaryBotClassParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPSummaryBotClassParamsOS{radar.HTTPSummaryBotClassParamsOSWindows, radar.HTTPSummaryBotClassParamsOSMacosx, radar.HTTPSummaryBotClassParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPSummaryBotClassParamsTLSVersion{radar.HTTPSummaryBotClassParamsTLSVersionTlSv1_0, radar.HTTPSummaryBotClassParamsTLSVersionTlSv1_1, radar.HTTPSummaryBotClassParamsTLSVersionTlSv1_2}), + }) + 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 TestHTTPSummaryDeviceTypeWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Summary.DeviceType(context.TODO(), radar.HTTPSummaryDeviceTypeParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPSummaryDeviceTypeParamsBotClass{radar.HTTPSummaryDeviceTypeParamsBotClassLikelyAutomated, radar.HTTPSummaryDeviceTypeParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPSummaryDeviceTypeParamsDateRange{radar.HTTPSummaryDeviceTypeParamsDateRange1d, radar.HTTPSummaryDeviceTypeParamsDateRange2d, radar.HTTPSummaryDeviceTypeParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.HTTPSummaryDeviceTypeParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPSummaryDeviceTypeParamsHTTPProtocol{radar.HTTPSummaryDeviceTypeParamsHTTPProtocolHTTP, radar.HTTPSummaryDeviceTypeParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPSummaryDeviceTypeParamsHTTPVersion{radar.HTTPSummaryDeviceTypeParamsHTTPVersionHttPv1, radar.HTTPSummaryDeviceTypeParamsHTTPVersionHttPv2, radar.HTTPSummaryDeviceTypeParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPSummaryDeviceTypeParamsIPVersion{radar.HTTPSummaryDeviceTypeParamsIPVersionIPv4, radar.HTTPSummaryDeviceTypeParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPSummaryDeviceTypeParamsOS{radar.HTTPSummaryDeviceTypeParamsOSWindows, radar.HTTPSummaryDeviceTypeParamsOSMacosx, radar.HTTPSummaryDeviceTypeParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPSummaryDeviceTypeParamsTLSVersion{radar.HTTPSummaryDeviceTypeParamsTLSVersionTlSv1_0, radar.HTTPSummaryDeviceTypeParamsTLSVersionTlSv1_1, radar.HTTPSummaryDeviceTypeParamsTLSVersionTlSv1_2}), + }) + 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 TestHTTPSummaryHTTPProtocolWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Summary.HTTPProtocol(context.TODO(), radar.HTTPSummaryHTTPProtocolParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPSummaryHTTPProtocolParamsBotClass{radar.HTTPSummaryHTTPProtocolParamsBotClassLikelyAutomated, radar.HTTPSummaryHTTPProtocolParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPSummaryHTTPProtocolParamsDateRange{radar.HTTPSummaryHTTPProtocolParamsDateRange1d, radar.HTTPSummaryHTTPProtocolParamsDateRange2d, radar.HTTPSummaryHTTPProtocolParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPSummaryHTTPProtocolParamsDeviceType{radar.HTTPSummaryHTTPProtocolParamsDeviceTypeDesktop, radar.HTTPSummaryHTTPProtocolParamsDeviceTypeMobile, radar.HTTPSummaryHTTPProtocolParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPSummaryHTTPProtocolParamsFormatJson), + HTTPVersion: cloudflare.F([]radar.HTTPSummaryHTTPProtocolParamsHTTPVersion{radar.HTTPSummaryHTTPProtocolParamsHTTPVersionHttPv1, radar.HTTPSummaryHTTPProtocolParamsHTTPVersionHttPv2, radar.HTTPSummaryHTTPProtocolParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPSummaryHTTPProtocolParamsIPVersion{radar.HTTPSummaryHTTPProtocolParamsIPVersionIPv4, radar.HTTPSummaryHTTPProtocolParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPSummaryHTTPProtocolParamsOS{radar.HTTPSummaryHTTPProtocolParamsOSWindows, radar.HTTPSummaryHTTPProtocolParamsOSMacosx, radar.HTTPSummaryHTTPProtocolParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPSummaryHTTPProtocolParamsTLSVersion{radar.HTTPSummaryHTTPProtocolParamsTLSVersionTlSv1_0, radar.HTTPSummaryHTTPProtocolParamsTLSVersionTlSv1_1, radar.HTTPSummaryHTTPProtocolParamsTLSVersionTlSv1_2}), + }) + 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 TestHTTPSummaryHTTPVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Summary.HTTPVersion(context.TODO(), radar.HTTPSummaryHTTPVersionParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPSummaryHTTPVersionParamsBotClass{radar.HTTPSummaryHTTPVersionParamsBotClassLikelyAutomated, radar.HTTPSummaryHTTPVersionParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPSummaryHTTPVersionParamsDateRange{radar.HTTPSummaryHTTPVersionParamsDateRange1d, radar.HTTPSummaryHTTPVersionParamsDateRange2d, radar.HTTPSummaryHTTPVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPSummaryHTTPVersionParamsDeviceType{radar.HTTPSummaryHTTPVersionParamsDeviceTypeDesktop, radar.HTTPSummaryHTTPVersionParamsDeviceTypeMobile, radar.HTTPSummaryHTTPVersionParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPSummaryHTTPVersionParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPSummaryHTTPVersionParamsHTTPProtocol{radar.HTTPSummaryHTTPVersionParamsHTTPProtocolHTTP, radar.HTTPSummaryHTTPVersionParamsHTTPProtocolHTTPS}), + IPVersion: cloudflare.F([]radar.HTTPSummaryHTTPVersionParamsIPVersion{radar.HTTPSummaryHTTPVersionParamsIPVersionIPv4, radar.HTTPSummaryHTTPVersionParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPSummaryHTTPVersionParamsOS{radar.HTTPSummaryHTTPVersionParamsOSWindows, radar.HTTPSummaryHTTPVersionParamsOSMacosx, radar.HTTPSummaryHTTPVersionParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPSummaryHTTPVersionParamsTLSVersion{radar.HTTPSummaryHTTPVersionParamsTLSVersionTlSv1_0, radar.HTTPSummaryHTTPVersionParamsTLSVersionTlSv1_1, radar.HTTPSummaryHTTPVersionParamsTLSVersionTlSv1_2}), + }) + 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 TestHTTPSummaryIPVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Summary.IPVersion(context.TODO(), radar.HTTPSummaryIPVersionParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPSummaryIPVersionParamsBotClass{radar.HTTPSummaryIPVersionParamsBotClassLikelyAutomated, radar.HTTPSummaryIPVersionParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPSummaryIPVersionParamsDateRange{radar.HTTPSummaryIPVersionParamsDateRange1d, radar.HTTPSummaryIPVersionParamsDateRange2d, radar.HTTPSummaryIPVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPSummaryIPVersionParamsDeviceType{radar.HTTPSummaryIPVersionParamsDeviceTypeDesktop, radar.HTTPSummaryIPVersionParamsDeviceTypeMobile, radar.HTTPSummaryIPVersionParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPSummaryIPVersionParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPSummaryIPVersionParamsHTTPProtocol{radar.HTTPSummaryIPVersionParamsHTTPProtocolHTTP, radar.HTTPSummaryIPVersionParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPSummaryIPVersionParamsHTTPVersion{radar.HTTPSummaryIPVersionParamsHTTPVersionHttPv1, radar.HTTPSummaryIPVersionParamsHTTPVersionHttPv2, radar.HTTPSummaryIPVersionParamsHTTPVersionHttPv3}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPSummaryIPVersionParamsOS{radar.HTTPSummaryIPVersionParamsOSWindows, radar.HTTPSummaryIPVersionParamsOSMacosx, radar.HTTPSummaryIPVersionParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPSummaryIPVersionParamsTLSVersion{radar.HTTPSummaryIPVersionParamsTLSVersionTlSv1_0, radar.HTTPSummaryIPVersionParamsTLSVersionTlSv1_1, radar.HTTPSummaryIPVersionParamsTLSVersionTlSv1_2}), + }) + 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 TestHTTPSummaryOSWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Summary.OS(context.TODO(), radar.HTTPSummaryOSParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPSummaryOSParamsBotClass{radar.HTTPSummaryOSParamsBotClassLikelyAutomated, radar.HTTPSummaryOSParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPSummaryOSParamsDateRange{radar.HTTPSummaryOSParamsDateRange1d, radar.HTTPSummaryOSParamsDateRange2d, radar.HTTPSummaryOSParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPSummaryOSParamsDeviceType{radar.HTTPSummaryOSParamsDeviceTypeDesktop, radar.HTTPSummaryOSParamsDeviceTypeMobile, radar.HTTPSummaryOSParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPSummaryOSParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPSummaryOSParamsHTTPProtocol{radar.HTTPSummaryOSParamsHTTPProtocolHTTP, radar.HTTPSummaryOSParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPSummaryOSParamsHTTPVersion{radar.HTTPSummaryOSParamsHTTPVersionHttPv1, radar.HTTPSummaryOSParamsHTTPVersionHttPv2, radar.HTTPSummaryOSParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPSummaryOSParamsIPVersion{radar.HTTPSummaryOSParamsIPVersionIPv4, radar.HTTPSummaryOSParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + TLSVersion: cloudflare.F([]radar.HTTPSummaryOSParamsTLSVersion{radar.HTTPSummaryOSParamsTLSVersionTlSv1_0, radar.HTTPSummaryOSParamsTLSVersionTlSv1_1, radar.HTTPSummaryOSParamsTLSVersionTlSv1_2}), + }) + 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 TestHTTPSummaryTLSVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Summary.TLSVersion(context.TODO(), radar.HTTPSummaryTLSVersionParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPSummaryTLSVersionParamsBotClass{radar.HTTPSummaryTLSVersionParamsBotClassLikelyAutomated, radar.HTTPSummaryTLSVersionParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPSummaryTLSVersionParamsDateRange{radar.HTTPSummaryTLSVersionParamsDateRange1d, radar.HTTPSummaryTLSVersionParamsDateRange2d, radar.HTTPSummaryTLSVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPSummaryTLSVersionParamsDeviceType{radar.HTTPSummaryTLSVersionParamsDeviceTypeDesktop, radar.HTTPSummaryTLSVersionParamsDeviceTypeMobile, radar.HTTPSummaryTLSVersionParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPSummaryTLSVersionParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPSummaryTLSVersionParamsHTTPProtocol{radar.HTTPSummaryTLSVersionParamsHTTPProtocolHTTP, radar.HTTPSummaryTLSVersionParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPSummaryTLSVersionParamsHTTPVersion{radar.HTTPSummaryTLSVersionParamsHTTPVersionHttPv1, radar.HTTPSummaryTLSVersionParamsHTTPVersionHttPv2, radar.HTTPSummaryTLSVersionParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPSummaryTLSVersionParamsIPVersion{radar.HTTPSummaryTLSVersionParamsIPVersionIPv4, radar.HTTPSummaryTLSVersionParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPSummaryTLSVersionParamsOS{radar.HTTPSummaryTLSVersionParamsOSWindows, radar.HTTPSummaryTLSVersionParamsOSMacosx, radar.HTTPSummaryTLSVersionParamsOSIos}), + }) + 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/radar/httptimeseriesgroup.go b/radar/httptimeseriesgroup.go new file mode 100644 index 00000000000..915b8c162cc --- /dev/null +++ b/radar/httptimeseriesgroup.go @@ -0,0 +1,2115 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPTimeseriesGroupService 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 [NewHTTPTimeseriesGroupService] +// method instead. +type HTTPTimeseriesGroupService struct { + Options []option.RequestOption +} + +// NewHTTPTimeseriesGroupService 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 NewHTTPTimeseriesGroupService(opts ...option.RequestOption) (r *HTTPTimeseriesGroupService) { + r = &HTTPTimeseriesGroupService{} + r.Options = opts + return +} + +// Get a time series of the percentage distribution of traffic classified as +// automated or human. Visit +// https://developers.cloudflare.com/radar/concepts/bot-classes/ for more +// information. +func (r *HTTPTimeseriesGroupService) BotClass(ctx context.Context, query HTTPTimeseriesGroupBotClassParams, opts ...option.RequestOption) (res *HTTPTimeseriesGroupBotClassResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPTimeseriesGroupBotClassResponseEnvelope + path := "radar/http/timeseries_groups/bot_class" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a time series of the percentage distribution of traffic of the top user +// agents. +func (r *HTTPTimeseriesGroupService) Browser(ctx context.Context, query HTTPTimeseriesGroupBrowserParams, opts ...option.RequestOption) (res *HTTPTimeseriesGroupBrowserResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPTimeseriesGroupBrowserResponseEnvelope + path := "radar/http/timeseries_groups/browser" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a time series of the percentage distribution of traffic of the top user +// agents aggregated in families. +func (r *HTTPTimeseriesGroupService) BrowserFamily(ctx context.Context, query HTTPTimeseriesGroupBrowserFamilyParams, opts ...option.RequestOption) (res *HTTPTimeseriesGroupBrowserFamilyResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPTimeseriesGroupBrowserFamilyResponseEnvelope + path := "radar/http/timeseries_groups/browser_family" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a time series of the percentage distribution of traffic per device type. +func (r *HTTPTimeseriesGroupService) DeviceType(ctx context.Context, query HTTPTimeseriesGroupDeviceTypeParams, opts ...option.RequestOption) (res *HTTPTimeseriesGroupDeviceTypeResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPTimeseriesGroupDeviceTypeResponseEnvelope + path := "radar/http/timeseries_groups/device_type" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a time series of the percentage distribution of traffic per HTTP protocol. +func (r *HTTPTimeseriesGroupService) HTTPProtocol(ctx context.Context, query HTTPTimeseriesGroupHTTPProtocolParams, opts ...option.RequestOption) (res *HTTPTimeseriesGroupHTTPProtocolResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPTimeseriesGroupHTTPProtocolResponseEnvelope + path := "radar/http/timeseries_groups/http_protocol" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a time series of the percentage distribution of traffic per HTTP protocol +// version. +func (r *HTTPTimeseriesGroupService) HTTPVersion(ctx context.Context, query HTTPTimeseriesGroupHTTPVersionParams, opts ...option.RequestOption) (res *HTTPTimeseriesGroupHTTPVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPTimeseriesGroupHTTPVersionResponseEnvelope + path := "radar/http/timeseries_groups/http_version" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a time series of the percentage distribution of traffic per IP protocol +// version. +func (r *HTTPTimeseriesGroupService) IPVersion(ctx context.Context, query HTTPTimeseriesGroupIPVersionParams, opts ...option.RequestOption) (res *HTTPTimeseriesGroupIPVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPTimeseriesGroupIPVersionResponseEnvelope + path := "radar/http/timeseries_groups/ip_version" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a time series of the percentage distribution of traffic of the top operating +// systems. +func (r *HTTPTimeseriesGroupService) OS(ctx context.Context, query HTTPTimeseriesGroupOSParams, opts ...option.RequestOption) (res *HTTPTimeseriesGroupOSResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPTimeseriesGroupOSResponseEnvelope + path := "radar/http/timeseries_groups/os" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a time series of the percentage distribution of traffic per TLS protocol +// version. +func (r *HTTPTimeseriesGroupService) TLSVersion(ctx context.Context, query HTTPTimeseriesGroupTLSVersionParams, opts ...option.RequestOption) (res *HTTPTimeseriesGroupTLSVersionResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPTimeseriesGroupTLSVersionResponseEnvelope + path := "radar/http/timeseries_groups/tls_version" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPTimeseriesGroupBotClassResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 HTTPTimeseriesGroupBotClassResponseSerie0 `json:"serie_0,required"` + JSON httpTimeseriesGroupBotClassResponseJSON `json:"-"` +} + +// httpTimeseriesGroupBotClassResponseJSON contains the JSON metadata for the +// struct [HTTPTimeseriesGroupBotClassResponse] +type httpTimeseriesGroupBotClassResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupBotClassResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupBotClassResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupBotClassResponseSerie0 struct { + Bot []string `json:"bot,required"` + Human []string `json:"human,required"` + Timestamps []string `json:"timestamps,required"` + JSON httpTimeseriesGroupBotClassResponseSerie0JSON `json:"-"` +} + +// httpTimeseriesGroupBotClassResponseSerie0JSON contains the JSON metadata for the +// struct [HTTPTimeseriesGroupBotClassResponseSerie0] +type httpTimeseriesGroupBotClassResponseSerie0JSON struct { + Bot apijson.Field + Human apijson.Field + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupBotClassResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupBotClassResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupBrowserResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 HTTPTimeseriesGroupBrowserResponseSerie0 `json:"serie_0,required"` + JSON httpTimeseriesGroupBrowserResponseJSON `json:"-"` +} + +// httpTimeseriesGroupBrowserResponseJSON contains the JSON metadata for the struct +// [HTTPTimeseriesGroupBrowserResponse] +type httpTimeseriesGroupBrowserResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupBrowserResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupBrowserResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupBrowserResponseSerie0 struct { + Timestamps []string `json:"timestamps,required"` + ExtraFields map[string][]string `json:"-,extras"` + JSON httpTimeseriesGroupBrowserResponseSerie0JSON `json:"-"` +} + +// httpTimeseriesGroupBrowserResponseSerie0JSON contains the JSON metadata for the +// struct [HTTPTimeseriesGroupBrowserResponseSerie0] +type httpTimeseriesGroupBrowserResponseSerie0JSON struct { + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupBrowserResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupBrowserResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupBrowserFamilyResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 HTTPTimeseriesGroupBrowserFamilyResponseSerie0 `json:"serie_0,required"` + JSON httpTimeseriesGroupBrowserFamilyResponseJSON `json:"-"` +} + +// httpTimeseriesGroupBrowserFamilyResponseJSON contains the JSON metadata for the +// struct [HTTPTimeseriesGroupBrowserFamilyResponse] +type httpTimeseriesGroupBrowserFamilyResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupBrowserFamilyResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupBrowserFamilyResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupBrowserFamilyResponseSerie0 struct { + Timestamps []string `json:"timestamps,required"` + ExtraFields map[string][]string `json:"-,extras"` + JSON httpTimeseriesGroupBrowserFamilyResponseSerie0JSON `json:"-"` +} + +// httpTimeseriesGroupBrowserFamilyResponseSerie0JSON contains the JSON metadata +// for the struct [HTTPTimeseriesGroupBrowserFamilyResponseSerie0] +type httpTimeseriesGroupBrowserFamilyResponseSerie0JSON struct { + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupBrowserFamilyResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupBrowserFamilyResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupDeviceTypeResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 HTTPTimeseriesGroupDeviceTypeResponseSerie0 `json:"serie_0,required"` + JSON httpTimeseriesGroupDeviceTypeResponseJSON `json:"-"` +} + +// httpTimeseriesGroupDeviceTypeResponseJSON contains the JSON metadata for the +// struct [HTTPTimeseriesGroupDeviceTypeResponse] +type httpTimeseriesGroupDeviceTypeResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupDeviceTypeResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupDeviceTypeResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupDeviceTypeResponseSerie0 struct { + Desktop []string `json:"desktop,required"` + Mobile []string `json:"mobile,required"` + Other []string `json:"other,required"` + Timestamps []string `json:"timestamps,required"` + JSON httpTimeseriesGroupDeviceTypeResponseSerie0JSON `json:"-"` +} + +// httpTimeseriesGroupDeviceTypeResponseSerie0JSON contains the JSON metadata for +// the struct [HTTPTimeseriesGroupDeviceTypeResponseSerie0] +type httpTimeseriesGroupDeviceTypeResponseSerie0JSON struct { + Desktop apijson.Field + Mobile apijson.Field + Other apijson.Field + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupDeviceTypeResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupDeviceTypeResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupHTTPProtocolResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 HTTPTimeseriesGroupHTTPProtocolResponseSerie0 `json:"serie_0,required"` + JSON httpTimeseriesGroupHTTPProtocolResponseJSON `json:"-"` +} + +// httpTimeseriesGroupHTTPProtocolResponseJSON contains the JSON metadata for the +// struct [HTTPTimeseriesGroupHTTPProtocolResponse] +type httpTimeseriesGroupHTTPProtocolResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupHTTPProtocolResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupHTTPProtocolResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupHTTPProtocolResponseSerie0 struct { + HTTP []string `json:"http,required"` + HTTPS []string `json:"https,required"` + Timestamps []string `json:"timestamps,required"` + JSON httpTimeseriesGroupHTTPProtocolResponseSerie0JSON `json:"-"` +} + +// httpTimeseriesGroupHTTPProtocolResponseSerie0JSON contains the JSON metadata for +// the struct [HTTPTimeseriesGroupHTTPProtocolResponseSerie0] +type httpTimeseriesGroupHTTPProtocolResponseSerie0JSON struct { + HTTP apijson.Field + HTTPS apijson.Field + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupHTTPProtocolResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupHTTPProtocolResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupHTTPVersionResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 HTTPTimeseriesGroupHTTPVersionResponseSerie0 `json:"serie_0,required"` + JSON httpTimeseriesGroupHTTPVersionResponseJSON `json:"-"` +} + +// httpTimeseriesGroupHTTPVersionResponseJSON contains the JSON metadata for the +// struct [HTTPTimeseriesGroupHTTPVersionResponse] +type httpTimeseriesGroupHTTPVersionResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupHTTPVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupHTTPVersionResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupHTTPVersionResponseSerie0 struct { + HTTP1X []string `json:"HTTP/1.x,required"` + HTTP2 []string `json:"HTTP/2,required"` + HTTP3 []string `json:"HTTP/3,required"` + Timestamps []string `json:"timestamps,required"` + JSON httpTimeseriesGroupHTTPVersionResponseSerie0JSON `json:"-"` +} + +// httpTimeseriesGroupHTTPVersionResponseSerie0JSON contains the JSON metadata for +// the struct [HTTPTimeseriesGroupHTTPVersionResponseSerie0] +type httpTimeseriesGroupHTTPVersionResponseSerie0JSON struct { + HTTP1X apijson.Field + HTTP2 apijson.Field + HTTP3 apijson.Field + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupHTTPVersionResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupHTTPVersionResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupIPVersionResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 HTTPTimeseriesGroupIPVersionResponseSerie0 `json:"serie_0,required"` + JSON httpTimeseriesGroupIPVersionResponseJSON `json:"-"` +} + +// httpTimeseriesGroupIPVersionResponseJSON contains the JSON metadata for the +// struct [HTTPTimeseriesGroupIPVersionResponse] +type httpTimeseriesGroupIPVersionResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupIPVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupIPVersionResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupIPVersionResponseSerie0 struct { + IPv4 []string `json:"IPv4,required"` + IPv6 []string `json:"IPv6,required"` + Timestamps []string `json:"timestamps,required"` + JSON httpTimeseriesGroupIPVersionResponseSerie0JSON `json:"-"` +} + +// httpTimeseriesGroupIPVersionResponseSerie0JSON contains the JSON metadata for +// the struct [HTTPTimeseriesGroupIPVersionResponseSerie0] +type httpTimeseriesGroupIPVersionResponseSerie0JSON struct { + IPv4 apijson.Field + IPv6 apijson.Field + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupIPVersionResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupIPVersionResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupOSResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 HTTPTimeseriesGroupOSResponseSerie0 `json:"serie_0,required"` + JSON httpTimeseriesGroupOSResponseJSON `json:"-"` +} + +// httpTimeseriesGroupOSResponseJSON contains the JSON metadata for the struct +// [HTTPTimeseriesGroupOSResponse] +type httpTimeseriesGroupOSResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupOSResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupOSResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupOSResponseSerie0 struct { + Timestamps []string `json:"timestamps,required"` + ExtraFields map[string][]string `json:"-,extras"` + JSON httpTimeseriesGroupOSResponseSerie0JSON `json:"-"` +} + +// httpTimeseriesGroupOSResponseSerie0JSON contains the JSON metadata for the +// struct [HTTPTimeseriesGroupOSResponseSerie0] +type httpTimeseriesGroupOSResponseSerie0JSON struct { + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupOSResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupOSResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupTLSVersionResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 HTTPTimeseriesGroupTLSVersionResponseSerie0 `json:"serie_0,required"` + JSON httpTimeseriesGroupTLSVersionResponseJSON `json:"-"` +} + +// httpTimeseriesGroupTLSVersionResponseJSON contains the JSON metadata for the +// struct [HTTPTimeseriesGroupTLSVersionResponse] +type httpTimeseriesGroupTLSVersionResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupTLSVersionResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupTLSVersionResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupTLSVersionResponseSerie0 struct { + Timestamps []string `json:"timestamps,required"` + TLS1_0 []string `json:"TLS 1.0,required"` + TLS1_1 []string `json:"TLS 1.1,required"` + TLS1_2 []string `json:"TLS 1.2,required"` + TLS1_3 []string `json:"TLS 1.3,required"` + TLSQuic []string `json:"TLS QUIC,required"` + JSON httpTimeseriesGroupTLSVersionResponseSerie0JSON `json:"-"` +} + +// httpTimeseriesGroupTLSVersionResponseSerie0JSON contains the JSON metadata for +// the struct [HTTPTimeseriesGroupTLSVersionResponseSerie0] +type httpTimeseriesGroupTLSVersionResponseSerie0JSON struct { + Timestamps apijson.Field + TLS1_0 apijson.Field + TLS1_1 apijson.Field + TLS1_2 apijson.Field + TLS1_3 apijson.Field + TLSQuic apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupTLSVersionResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupTLSVersionResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupBotClassParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[HTTPTimeseriesGroupBotClassParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPTimeseriesGroupBotClassParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPTimeseriesGroupBotClassParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPTimeseriesGroupBotClassParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPTimeseriesGroupBotClassParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPTimeseriesGroupBotClassParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPTimeseriesGroupBotClassParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPTimeseriesGroupBotClassParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPTimeseriesGroupBotClassParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPTimeseriesGroupBotClassParams]'s query parameters as +// `url.Values`. +func (r HTTPTimeseriesGroupBotClassParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type HTTPTimeseriesGroupBotClassParamsAggInterval string + +const ( + HTTPTimeseriesGroupBotClassParamsAggInterval15m HTTPTimeseriesGroupBotClassParamsAggInterval = "15m" + HTTPTimeseriesGroupBotClassParamsAggInterval1h HTTPTimeseriesGroupBotClassParamsAggInterval = "1h" + HTTPTimeseriesGroupBotClassParamsAggInterval1d HTTPTimeseriesGroupBotClassParamsAggInterval = "1d" + HTTPTimeseriesGroupBotClassParamsAggInterval1w HTTPTimeseriesGroupBotClassParamsAggInterval = "1w" +) + +type HTTPTimeseriesGroupBotClassParamsDateRange string + +const ( + HTTPTimeseriesGroupBotClassParamsDateRange1d HTTPTimeseriesGroupBotClassParamsDateRange = "1d" + HTTPTimeseriesGroupBotClassParamsDateRange2d HTTPTimeseriesGroupBotClassParamsDateRange = "2d" + HTTPTimeseriesGroupBotClassParamsDateRange7d HTTPTimeseriesGroupBotClassParamsDateRange = "7d" + HTTPTimeseriesGroupBotClassParamsDateRange14d HTTPTimeseriesGroupBotClassParamsDateRange = "14d" + HTTPTimeseriesGroupBotClassParamsDateRange28d HTTPTimeseriesGroupBotClassParamsDateRange = "28d" + HTTPTimeseriesGroupBotClassParamsDateRange12w HTTPTimeseriesGroupBotClassParamsDateRange = "12w" + HTTPTimeseriesGroupBotClassParamsDateRange24w HTTPTimeseriesGroupBotClassParamsDateRange = "24w" + HTTPTimeseriesGroupBotClassParamsDateRange52w HTTPTimeseriesGroupBotClassParamsDateRange = "52w" + HTTPTimeseriesGroupBotClassParamsDateRange1dControl HTTPTimeseriesGroupBotClassParamsDateRange = "1dControl" + HTTPTimeseriesGroupBotClassParamsDateRange2dControl HTTPTimeseriesGroupBotClassParamsDateRange = "2dControl" + HTTPTimeseriesGroupBotClassParamsDateRange7dControl HTTPTimeseriesGroupBotClassParamsDateRange = "7dControl" + HTTPTimeseriesGroupBotClassParamsDateRange14dControl HTTPTimeseriesGroupBotClassParamsDateRange = "14dControl" + HTTPTimeseriesGroupBotClassParamsDateRange28dControl HTTPTimeseriesGroupBotClassParamsDateRange = "28dControl" + HTTPTimeseriesGroupBotClassParamsDateRange12wControl HTTPTimeseriesGroupBotClassParamsDateRange = "12wControl" + HTTPTimeseriesGroupBotClassParamsDateRange24wControl HTTPTimeseriesGroupBotClassParamsDateRange = "24wControl" +) + +type HTTPTimeseriesGroupBotClassParamsDeviceType string + +const ( + HTTPTimeseriesGroupBotClassParamsDeviceTypeDesktop HTTPTimeseriesGroupBotClassParamsDeviceType = "DESKTOP" + HTTPTimeseriesGroupBotClassParamsDeviceTypeMobile HTTPTimeseriesGroupBotClassParamsDeviceType = "MOBILE" + HTTPTimeseriesGroupBotClassParamsDeviceTypeOther HTTPTimeseriesGroupBotClassParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPTimeseriesGroupBotClassParamsFormat string + +const ( + HTTPTimeseriesGroupBotClassParamsFormatJson HTTPTimeseriesGroupBotClassParamsFormat = "JSON" + HTTPTimeseriesGroupBotClassParamsFormatCsv HTTPTimeseriesGroupBotClassParamsFormat = "CSV" +) + +type HTTPTimeseriesGroupBotClassParamsHTTPProtocol string + +const ( + HTTPTimeseriesGroupBotClassParamsHTTPProtocolHTTP HTTPTimeseriesGroupBotClassParamsHTTPProtocol = "HTTP" + HTTPTimeseriesGroupBotClassParamsHTTPProtocolHTTPS HTTPTimeseriesGroupBotClassParamsHTTPProtocol = "HTTPS" +) + +type HTTPTimeseriesGroupBotClassParamsHTTPVersion string + +const ( + HTTPTimeseriesGroupBotClassParamsHTTPVersionHttPv1 HTTPTimeseriesGroupBotClassParamsHTTPVersion = "HTTPv1" + HTTPTimeseriesGroupBotClassParamsHTTPVersionHttPv2 HTTPTimeseriesGroupBotClassParamsHTTPVersion = "HTTPv2" + HTTPTimeseriesGroupBotClassParamsHTTPVersionHttPv3 HTTPTimeseriesGroupBotClassParamsHTTPVersion = "HTTPv3" +) + +type HTTPTimeseriesGroupBotClassParamsIPVersion string + +const ( + HTTPTimeseriesGroupBotClassParamsIPVersionIPv4 HTTPTimeseriesGroupBotClassParamsIPVersion = "IPv4" + HTTPTimeseriesGroupBotClassParamsIPVersionIPv6 HTTPTimeseriesGroupBotClassParamsIPVersion = "IPv6" +) + +type HTTPTimeseriesGroupBotClassParamsOS string + +const ( + HTTPTimeseriesGroupBotClassParamsOSWindows HTTPTimeseriesGroupBotClassParamsOS = "WINDOWS" + HTTPTimeseriesGroupBotClassParamsOSMacosx HTTPTimeseriesGroupBotClassParamsOS = "MACOSX" + HTTPTimeseriesGroupBotClassParamsOSIos HTTPTimeseriesGroupBotClassParamsOS = "IOS" + HTTPTimeseriesGroupBotClassParamsOSAndroid HTTPTimeseriesGroupBotClassParamsOS = "ANDROID" + HTTPTimeseriesGroupBotClassParamsOSChromeos HTTPTimeseriesGroupBotClassParamsOS = "CHROMEOS" + HTTPTimeseriesGroupBotClassParamsOSLinux HTTPTimeseriesGroupBotClassParamsOS = "LINUX" + HTTPTimeseriesGroupBotClassParamsOSSmartTv HTTPTimeseriesGroupBotClassParamsOS = "SMART_TV" +) + +type HTTPTimeseriesGroupBotClassParamsTLSVersion string + +const ( + HTTPTimeseriesGroupBotClassParamsTLSVersionTlSv1_0 HTTPTimeseriesGroupBotClassParamsTLSVersion = "TLSv1_0" + HTTPTimeseriesGroupBotClassParamsTLSVersionTlSv1_1 HTTPTimeseriesGroupBotClassParamsTLSVersion = "TLSv1_1" + HTTPTimeseriesGroupBotClassParamsTLSVersionTlSv1_2 HTTPTimeseriesGroupBotClassParamsTLSVersion = "TLSv1_2" + HTTPTimeseriesGroupBotClassParamsTLSVersionTlSv1_3 HTTPTimeseriesGroupBotClassParamsTLSVersion = "TLSv1_3" + HTTPTimeseriesGroupBotClassParamsTLSVersionTlSvQuic HTTPTimeseriesGroupBotClassParamsTLSVersion = "TLSvQUIC" +) + +type HTTPTimeseriesGroupBotClassResponseEnvelope struct { + Result HTTPTimeseriesGroupBotClassResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpTimeseriesGroupBotClassResponseEnvelopeJSON `json:"-"` +} + +// httpTimeseriesGroupBotClassResponseEnvelopeJSON contains the JSON metadata for +// the struct [HTTPTimeseriesGroupBotClassResponseEnvelope] +type httpTimeseriesGroupBotClassResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupBotClassResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupBotClassResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupBrowserParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[HTTPTimeseriesGroupBrowserParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPTimeseriesGroupBrowserParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPTimeseriesGroupBrowserParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPTimeseriesGroupBrowserParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPTimeseriesGroupBrowserParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPTimeseriesGroupBrowserParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPTimeseriesGroupBrowserParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPTimeseriesGroupBrowserParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects (eg browsers, verticals, etc) to the top items over + // the time range. + LimitPerGroup param.Field[int64] `query:"limitPerGroup"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPTimeseriesGroupBrowserParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPTimeseriesGroupBrowserParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPTimeseriesGroupBrowserParams]'s query parameters as +// `url.Values`. +func (r HTTPTimeseriesGroupBrowserParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type HTTPTimeseriesGroupBrowserParamsAggInterval string + +const ( + HTTPTimeseriesGroupBrowserParamsAggInterval15m HTTPTimeseriesGroupBrowserParamsAggInterval = "15m" + HTTPTimeseriesGroupBrowserParamsAggInterval1h HTTPTimeseriesGroupBrowserParamsAggInterval = "1h" + HTTPTimeseriesGroupBrowserParamsAggInterval1d HTTPTimeseriesGroupBrowserParamsAggInterval = "1d" + HTTPTimeseriesGroupBrowserParamsAggInterval1w HTTPTimeseriesGroupBrowserParamsAggInterval = "1w" +) + +type HTTPTimeseriesGroupBrowserParamsBotClass string + +const ( + HTTPTimeseriesGroupBrowserParamsBotClassLikelyAutomated HTTPTimeseriesGroupBrowserParamsBotClass = "LIKELY_AUTOMATED" + HTTPTimeseriesGroupBrowserParamsBotClassLikelyHuman HTTPTimeseriesGroupBrowserParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPTimeseriesGroupBrowserParamsDateRange string + +const ( + HTTPTimeseriesGroupBrowserParamsDateRange1d HTTPTimeseriesGroupBrowserParamsDateRange = "1d" + HTTPTimeseriesGroupBrowserParamsDateRange2d HTTPTimeseriesGroupBrowserParamsDateRange = "2d" + HTTPTimeseriesGroupBrowserParamsDateRange7d HTTPTimeseriesGroupBrowserParamsDateRange = "7d" + HTTPTimeseriesGroupBrowserParamsDateRange14d HTTPTimeseriesGroupBrowserParamsDateRange = "14d" + HTTPTimeseriesGroupBrowserParamsDateRange28d HTTPTimeseriesGroupBrowserParamsDateRange = "28d" + HTTPTimeseriesGroupBrowserParamsDateRange12w HTTPTimeseriesGroupBrowserParamsDateRange = "12w" + HTTPTimeseriesGroupBrowserParamsDateRange24w HTTPTimeseriesGroupBrowserParamsDateRange = "24w" + HTTPTimeseriesGroupBrowserParamsDateRange52w HTTPTimeseriesGroupBrowserParamsDateRange = "52w" + HTTPTimeseriesGroupBrowserParamsDateRange1dControl HTTPTimeseriesGroupBrowserParamsDateRange = "1dControl" + HTTPTimeseriesGroupBrowserParamsDateRange2dControl HTTPTimeseriesGroupBrowserParamsDateRange = "2dControl" + HTTPTimeseriesGroupBrowserParamsDateRange7dControl HTTPTimeseriesGroupBrowserParamsDateRange = "7dControl" + HTTPTimeseriesGroupBrowserParamsDateRange14dControl HTTPTimeseriesGroupBrowserParamsDateRange = "14dControl" + HTTPTimeseriesGroupBrowserParamsDateRange28dControl HTTPTimeseriesGroupBrowserParamsDateRange = "28dControl" + HTTPTimeseriesGroupBrowserParamsDateRange12wControl HTTPTimeseriesGroupBrowserParamsDateRange = "12wControl" + HTTPTimeseriesGroupBrowserParamsDateRange24wControl HTTPTimeseriesGroupBrowserParamsDateRange = "24wControl" +) + +type HTTPTimeseriesGroupBrowserParamsDeviceType string + +const ( + HTTPTimeseriesGroupBrowserParamsDeviceTypeDesktop HTTPTimeseriesGroupBrowserParamsDeviceType = "DESKTOP" + HTTPTimeseriesGroupBrowserParamsDeviceTypeMobile HTTPTimeseriesGroupBrowserParamsDeviceType = "MOBILE" + HTTPTimeseriesGroupBrowserParamsDeviceTypeOther HTTPTimeseriesGroupBrowserParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPTimeseriesGroupBrowserParamsFormat string + +const ( + HTTPTimeseriesGroupBrowserParamsFormatJson HTTPTimeseriesGroupBrowserParamsFormat = "JSON" + HTTPTimeseriesGroupBrowserParamsFormatCsv HTTPTimeseriesGroupBrowserParamsFormat = "CSV" +) + +type HTTPTimeseriesGroupBrowserParamsHTTPProtocol string + +const ( + HTTPTimeseriesGroupBrowserParamsHTTPProtocolHTTP HTTPTimeseriesGroupBrowserParamsHTTPProtocol = "HTTP" + HTTPTimeseriesGroupBrowserParamsHTTPProtocolHTTPS HTTPTimeseriesGroupBrowserParamsHTTPProtocol = "HTTPS" +) + +type HTTPTimeseriesGroupBrowserParamsHTTPVersion string + +const ( + HTTPTimeseriesGroupBrowserParamsHTTPVersionHttPv1 HTTPTimeseriesGroupBrowserParamsHTTPVersion = "HTTPv1" + HTTPTimeseriesGroupBrowserParamsHTTPVersionHttPv2 HTTPTimeseriesGroupBrowserParamsHTTPVersion = "HTTPv2" + HTTPTimeseriesGroupBrowserParamsHTTPVersionHttPv3 HTTPTimeseriesGroupBrowserParamsHTTPVersion = "HTTPv3" +) + +type HTTPTimeseriesGroupBrowserParamsIPVersion string + +const ( + HTTPTimeseriesGroupBrowserParamsIPVersionIPv4 HTTPTimeseriesGroupBrowserParamsIPVersion = "IPv4" + HTTPTimeseriesGroupBrowserParamsIPVersionIPv6 HTTPTimeseriesGroupBrowserParamsIPVersion = "IPv6" +) + +type HTTPTimeseriesGroupBrowserParamsOS string + +const ( + HTTPTimeseriesGroupBrowserParamsOSWindows HTTPTimeseriesGroupBrowserParamsOS = "WINDOWS" + HTTPTimeseriesGroupBrowserParamsOSMacosx HTTPTimeseriesGroupBrowserParamsOS = "MACOSX" + HTTPTimeseriesGroupBrowserParamsOSIos HTTPTimeseriesGroupBrowserParamsOS = "IOS" + HTTPTimeseriesGroupBrowserParamsOSAndroid HTTPTimeseriesGroupBrowserParamsOS = "ANDROID" + HTTPTimeseriesGroupBrowserParamsOSChromeos HTTPTimeseriesGroupBrowserParamsOS = "CHROMEOS" + HTTPTimeseriesGroupBrowserParamsOSLinux HTTPTimeseriesGroupBrowserParamsOS = "LINUX" + HTTPTimeseriesGroupBrowserParamsOSSmartTv HTTPTimeseriesGroupBrowserParamsOS = "SMART_TV" +) + +type HTTPTimeseriesGroupBrowserParamsTLSVersion string + +const ( + HTTPTimeseriesGroupBrowserParamsTLSVersionTlSv1_0 HTTPTimeseriesGroupBrowserParamsTLSVersion = "TLSv1_0" + HTTPTimeseriesGroupBrowserParamsTLSVersionTlSv1_1 HTTPTimeseriesGroupBrowserParamsTLSVersion = "TLSv1_1" + HTTPTimeseriesGroupBrowserParamsTLSVersionTlSv1_2 HTTPTimeseriesGroupBrowserParamsTLSVersion = "TLSv1_2" + HTTPTimeseriesGroupBrowserParamsTLSVersionTlSv1_3 HTTPTimeseriesGroupBrowserParamsTLSVersion = "TLSv1_3" + HTTPTimeseriesGroupBrowserParamsTLSVersionTlSvQuic HTTPTimeseriesGroupBrowserParamsTLSVersion = "TLSvQUIC" +) + +type HTTPTimeseriesGroupBrowserResponseEnvelope struct { + Result HTTPTimeseriesGroupBrowserResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpTimeseriesGroupBrowserResponseEnvelopeJSON `json:"-"` +} + +// httpTimeseriesGroupBrowserResponseEnvelopeJSON contains the JSON metadata for +// the struct [HTTPTimeseriesGroupBrowserResponseEnvelope] +type httpTimeseriesGroupBrowserResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupBrowserResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupBrowserResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupBrowserFamilyParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[HTTPTimeseriesGroupBrowserFamilyParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPTimeseriesGroupBrowserFamilyParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPTimeseriesGroupBrowserFamilyParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPTimeseriesGroupBrowserFamilyParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPTimeseriesGroupBrowserFamilyParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPTimeseriesGroupBrowserFamilyParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPTimeseriesGroupBrowserFamilyParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPTimeseriesGroupBrowserFamilyParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPTimeseriesGroupBrowserFamilyParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPTimeseriesGroupBrowserFamilyParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPTimeseriesGroupBrowserFamilyParams]'s query parameters +// as `url.Values`. +func (r HTTPTimeseriesGroupBrowserFamilyParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type HTTPTimeseriesGroupBrowserFamilyParamsAggInterval string + +const ( + HTTPTimeseriesGroupBrowserFamilyParamsAggInterval15m HTTPTimeseriesGroupBrowserFamilyParamsAggInterval = "15m" + HTTPTimeseriesGroupBrowserFamilyParamsAggInterval1h HTTPTimeseriesGroupBrowserFamilyParamsAggInterval = "1h" + HTTPTimeseriesGroupBrowserFamilyParamsAggInterval1d HTTPTimeseriesGroupBrowserFamilyParamsAggInterval = "1d" + HTTPTimeseriesGroupBrowserFamilyParamsAggInterval1w HTTPTimeseriesGroupBrowserFamilyParamsAggInterval = "1w" +) + +type HTTPTimeseriesGroupBrowserFamilyParamsBotClass string + +const ( + HTTPTimeseriesGroupBrowserFamilyParamsBotClassLikelyAutomated HTTPTimeseriesGroupBrowserFamilyParamsBotClass = "LIKELY_AUTOMATED" + HTTPTimeseriesGroupBrowserFamilyParamsBotClassLikelyHuman HTTPTimeseriesGroupBrowserFamilyParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPTimeseriesGroupBrowserFamilyParamsDateRange string + +const ( + HTTPTimeseriesGroupBrowserFamilyParamsDateRange1d HTTPTimeseriesGroupBrowserFamilyParamsDateRange = "1d" + HTTPTimeseriesGroupBrowserFamilyParamsDateRange2d HTTPTimeseriesGroupBrowserFamilyParamsDateRange = "2d" + HTTPTimeseriesGroupBrowserFamilyParamsDateRange7d HTTPTimeseriesGroupBrowserFamilyParamsDateRange = "7d" + HTTPTimeseriesGroupBrowserFamilyParamsDateRange14d HTTPTimeseriesGroupBrowserFamilyParamsDateRange = "14d" + HTTPTimeseriesGroupBrowserFamilyParamsDateRange28d HTTPTimeseriesGroupBrowserFamilyParamsDateRange = "28d" + HTTPTimeseriesGroupBrowserFamilyParamsDateRange12w HTTPTimeseriesGroupBrowserFamilyParamsDateRange = "12w" + HTTPTimeseriesGroupBrowserFamilyParamsDateRange24w HTTPTimeseriesGroupBrowserFamilyParamsDateRange = "24w" + HTTPTimeseriesGroupBrowserFamilyParamsDateRange52w HTTPTimeseriesGroupBrowserFamilyParamsDateRange = "52w" + HTTPTimeseriesGroupBrowserFamilyParamsDateRange1dControl HTTPTimeseriesGroupBrowserFamilyParamsDateRange = "1dControl" + HTTPTimeseriesGroupBrowserFamilyParamsDateRange2dControl HTTPTimeseriesGroupBrowserFamilyParamsDateRange = "2dControl" + HTTPTimeseriesGroupBrowserFamilyParamsDateRange7dControl HTTPTimeseriesGroupBrowserFamilyParamsDateRange = "7dControl" + HTTPTimeseriesGroupBrowserFamilyParamsDateRange14dControl HTTPTimeseriesGroupBrowserFamilyParamsDateRange = "14dControl" + HTTPTimeseriesGroupBrowserFamilyParamsDateRange28dControl HTTPTimeseriesGroupBrowserFamilyParamsDateRange = "28dControl" + HTTPTimeseriesGroupBrowserFamilyParamsDateRange12wControl HTTPTimeseriesGroupBrowserFamilyParamsDateRange = "12wControl" + HTTPTimeseriesGroupBrowserFamilyParamsDateRange24wControl HTTPTimeseriesGroupBrowserFamilyParamsDateRange = "24wControl" +) + +type HTTPTimeseriesGroupBrowserFamilyParamsDeviceType string + +const ( + HTTPTimeseriesGroupBrowserFamilyParamsDeviceTypeDesktop HTTPTimeseriesGroupBrowserFamilyParamsDeviceType = "DESKTOP" + HTTPTimeseriesGroupBrowserFamilyParamsDeviceTypeMobile HTTPTimeseriesGroupBrowserFamilyParamsDeviceType = "MOBILE" + HTTPTimeseriesGroupBrowserFamilyParamsDeviceTypeOther HTTPTimeseriesGroupBrowserFamilyParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPTimeseriesGroupBrowserFamilyParamsFormat string + +const ( + HTTPTimeseriesGroupBrowserFamilyParamsFormatJson HTTPTimeseriesGroupBrowserFamilyParamsFormat = "JSON" + HTTPTimeseriesGroupBrowserFamilyParamsFormatCsv HTTPTimeseriesGroupBrowserFamilyParamsFormat = "CSV" +) + +type HTTPTimeseriesGroupBrowserFamilyParamsHTTPProtocol string + +const ( + HTTPTimeseriesGroupBrowserFamilyParamsHTTPProtocolHTTP HTTPTimeseriesGroupBrowserFamilyParamsHTTPProtocol = "HTTP" + HTTPTimeseriesGroupBrowserFamilyParamsHTTPProtocolHTTPS HTTPTimeseriesGroupBrowserFamilyParamsHTTPProtocol = "HTTPS" +) + +type HTTPTimeseriesGroupBrowserFamilyParamsHTTPVersion string + +const ( + HTTPTimeseriesGroupBrowserFamilyParamsHTTPVersionHttPv1 HTTPTimeseriesGroupBrowserFamilyParamsHTTPVersion = "HTTPv1" + HTTPTimeseriesGroupBrowserFamilyParamsHTTPVersionHttPv2 HTTPTimeseriesGroupBrowserFamilyParamsHTTPVersion = "HTTPv2" + HTTPTimeseriesGroupBrowserFamilyParamsHTTPVersionHttPv3 HTTPTimeseriesGroupBrowserFamilyParamsHTTPVersion = "HTTPv3" +) + +type HTTPTimeseriesGroupBrowserFamilyParamsIPVersion string + +const ( + HTTPTimeseriesGroupBrowserFamilyParamsIPVersionIPv4 HTTPTimeseriesGroupBrowserFamilyParamsIPVersion = "IPv4" + HTTPTimeseriesGroupBrowserFamilyParamsIPVersionIPv6 HTTPTimeseriesGroupBrowserFamilyParamsIPVersion = "IPv6" +) + +type HTTPTimeseriesGroupBrowserFamilyParamsOS string + +const ( + HTTPTimeseriesGroupBrowserFamilyParamsOSWindows HTTPTimeseriesGroupBrowserFamilyParamsOS = "WINDOWS" + HTTPTimeseriesGroupBrowserFamilyParamsOSMacosx HTTPTimeseriesGroupBrowserFamilyParamsOS = "MACOSX" + HTTPTimeseriesGroupBrowserFamilyParamsOSIos HTTPTimeseriesGroupBrowserFamilyParamsOS = "IOS" + HTTPTimeseriesGroupBrowserFamilyParamsOSAndroid HTTPTimeseriesGroupBrowserFamilyParamsOS = "ANDROID" + HTTPTimeseriesGroupBrowserFamilyParamsOSChromeos HTTPTimeseriesGroupBrowserFamilyParamsOS = "CHROMEOS" + HTTPTimeseriesGroupBrowserFamilyParamsOSLinux HTTPTimeseriesGroupBrowserFamilyParamsOS = "LINUX" + HTTPTimeseriesGroupBrowserFamilyParamsOSSmartTv HTTPTimeseriesGroupBrowserFamilyParamsOS = "SMART_TV" +) + +type HTTPTimeseriesGroupBrowserFamilyParamsTLSVersion string + +const ( + HTTPTimeseriesGroupBrowserFamilyParamsTLSVersionTlSv1_0 HTTPTimeseriesGroupBrowserFamilyParamsTLSVersion = "TLSv1_0" + HTTPTimeseriesGroupBrowserFamilyParamsTLSVersionTlSv1_1 HTTPTimeseriesGroupBrowserFamilyParamsTLSVersion = "TLSv1_1" + HTTPTimeseriesGroupBrowserFamilyParamsTLSVersionTlSv1_2 HTTPTimeseriesGroupBrowserFamilyParamsTLSVersion = "TLSv1_2" + HTTPTimeseriesGroupBrowserFamilyParamsTLSVersionTlSv1_3 HTTPTimeseriesGroupBrowserFamilyParamsTLSVersion = "TLSv1_3" + HTTPTimeseriesGroupBrowserFamilyParamsTLSVersionTlSvQuic HTTPTimeseriesGroupBrowserFamilyParamsTLSVersion = "TLSvQUIC" +) + +type HTTPTimeseriesGroupBrowserFamilyResponseEnvelope struct { + Result HTTPTimeseriesGroupBrowserFamilyResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpTimeseriesGroupBrowserFamilyResponseEnvelopeJSON `json:"-"` +} + +// httpTimeseriesGroupBrowserFamilyResponseEnvelopeJSON contains the JSON metadata +// for the struct [HTTPTimeseriesGroupBrowserFamilyResponseEnvelope] +type httpTimeseriesGroupBrowserFamilyResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupBrowserFamilyResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupBrowserFamilyResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupDeviceTypeParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[HTTPTimeseriesGroupDeviceTypeParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPTimeseriesGroupDeviceTypeParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPTimeseriesGroupDeviceTypeParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[HTTPTimeseriesGroupDeviceTypeParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPTimeseriesGroupDeviceTypeParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPTimeseriesGroupDeviceTypeParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPTimeseriesGroupDeviceTypeParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPTimeseriesGroupDeviceTypeParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPTimeseriesGroupDeviceTypeParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPTimeseriesGroupDeviceTypeParams]'s query parameters as +// `url.Values`. +func (r HTTPTimeseriesGroupDeviceTypeParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type HTTPTimeseriesGroupDeviceTypeParamsAggInterval string + +const ( + HTTPTimeseriesGroupDeviceTypeParamsAggInterval15m HTTPTimeseriesGroupDeviceTypeParamsAggInterval = "15m" + HTTPTimeseriesGroupDeviceTypeParamsAggInterval1h HTTPTimeseriesGroupDeviceTypeParamsAggInterval = "1h" + HTTPTimeseriesGroupDeviceTypeParamsAggInterval1d HTTPTimeseriesGroupDeviceTypeParamsAggInterval = "1d" + HTTPTimeseriesGroupDeviceTypeParamsAggInterval1w HTTPTimeseriesGroupDeviceTypeParamsAggInterval = "1w" +) + +type HTTPTimeseriesGroupDeviceTypeParamsBotClass string + +const ( + HTTPTimeseriesGroupDeviceTypeParamsBotClassLikelyAutomated HTTPTimeseriesGroupDeviceTypeParamsBotClass = "LIKELY_AUTOMATED" + HTTPTimeseriesGroupDeviceTypeParamsBotClassLikelyHuman HTTPTimeseriesGroupDeviceTypeParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPTimeseriesGroupDeviceTypeParamsDateRange string + +const ( + HTTPTimeseriesGroupDeviceTypeParamsDateRange1d HTTPTimeseriesGroupDeviceTypeParamsDateRange = "1d" + HTTPTimeseriesGroupDeviceTypeParamsDateRange2d HTTPTimeseriesGroupDeviceTypeParamsDateRange = "2d" + HTTPTimeseriesGroupDeviceTypeParamsDateRange7d HTTPTimeseriesGroupDeviceTypeParamsDateRange = "7d" + HTTPTimeseriesGroupDeviceTypeParamsDateRange14d HTTPTimeseriesGroupDeviceTypeParamsDateRange = "14d" + HTTPTimeseriesGroupDeviceTypeParamsDateRange28d HTTPTimeseriesGroupDeviceTypeParamsDateRange = "28d" + HTTPTimeseriesGroupDeviceTypeParamsDateRange12w HTTPTimeseriesGroupDeviceTypeParamsDateRange = "12w" + HTTPTimeseriesGroupDeviceTypeParamsDateRange24w HTTPTimeseriesGroupDeviceTypeParamsDateRange = "24w" + HTTPTimeseriesGroupDeviceTypeParamsDateRange52w HTTPTimeseriesGroupDeviceTypeParamsDateRange = "52w" + HTTPTimeseriesGroupDeviceTypeParamsDateRange1dControl HTTPTimeseriesGroupDeviceTypeParamsDateRange = "1dControl" + HTTPTimeseriesGroupDeviceTypeParamsDateRange2dControl HTTPTimeseriesGroupDeviceTypeParamsDateRange = "2dControl" + HTTPTimeseriesGroupDeviceTypeParamsDateRange7dControl HTTPTimeseriesGroupDeviceTypeParamsDateRange = "7dControl" + HTTPTimeseriesGroupDeviceTypeParamsDateRange14dControl HTTPTimeseriesGroupDeviceTypeParamsDateRange = "14dControl" + HTTPTimeseriesGroupDeviceTypeParamsDateRange28dControl HTTPTimeseriesGroupDeviceTypeParamsDateRange = "28dControl" + HTTPTimeseriesGroupDeviceTypeParamsDateRange12wControl HTTPTimeseriesGroupDeviceTypeParamsDateRange = "12wControl" + HTTPTimeseriesGroupDeviceTypeParamsDateRange24wControl HTTPTimeseriesGroupDeviceTypeParamsDateRange = "24wControl" +) + +// Format results are returned in. +type HTTPTimeseriesGroupDeviceTypeParamsFormat string + +const ( + HTTPTimeseriesGroupDeviceTypeParamsFormatJson HTTPTimeseriesGroupDeviceTypeParamsFormat = "JSON" + HTTPTimeseriesGroupDeviceTypeParamsFormatCsv HTTPTimeseriesGroupDeviceTypeParamsFormat = "CSV" +) + +type HTTPTimeseriesGroupDeviceTypeParamsHTTPProtocol string + +const ( + HTTPTimeseriesGroupDeviceTypeParamsHTTPProtocolHTTP HTTPTimeseriesGroupDeviceTypeParamsHTTPProtocol = "HTTP" + HTTPTimeseriesGroupDeviceTypeParamsHTTPProtocolHTTPS HTTPTimeseriesGroupDeviceTypeParamsHTTPProtocol = "HTTPS" +) + +type HTTPTimeseriesGroupDeviceTypeParamsHTTPVersion string + +const ( + HTTPTimeseriesGroupDeviceTypeParamsHTTPVersionHttPv1 HTTPTimeseriesGroupDeviceTypeParamsHTTPVersion = "HTTPv1" + HTTPTimeseriesGroupDeviceTypeParamsHTTPVersionHttPv2 HTTPTimeseriesGroupDeviceTypeParamsHTTPVersion = "HTTPv2" + HTTPTimeseriesGroupDeviceTypeParamsHTTPVersionHttPv3 HTTPTimeseriesGroupDeviceTypeParamsHTTPVersion = "HTTPv3" +) + +type HTTPTimeseriesGroupDeviceTypeParamsIPVersion string + +const ( + HTTPTimeseriesGroupDeviceTypeParamsIPVersionIPv4 HTTPTimeseriesGroupDeviceTypeParamsIPVersion = "IPv4" + HTTPTimeseriesGroupDeviceTypeParamsIPVersionIPv6 HTTPTimeseriesGroupDeviceTypeParamsIPVersion = "IPv6" +) + +type HTTPTimeseriesGroupDeviceTypeParamsOS string + +const ( + HTTPTimeseriesGroupDeviceTypeParamsOSWindows HTTPTimeseriesGroupDeviceTypeParamsOS = "WINDOWS" + HTTPTimeseriesGroupDeviceTypeParamsOSMacosx HTTPTimeseriesGroupDeviceTypeParamsOS = "MACOSX" + HTTPTimeseriesGroupDeviceTypeParamsOSIos HTTPTimeseriesGroupDeviceTypeParamsOS = "IOS" + HTTPTimeseriesGroupDeviceTypeParamsOSAndroid HTTPTimeseriesGroupDeviceTypeParamsOS = "ANDROID" + HTTPTimeseriesGroupDeviceTypeParamsOSChromeos HTTPTimeseriesGroupDeviceTypeParamsOS = "CHROMEOS" + HTTPTimeseriesGroupDeviceTypeParamsOSLinux HTTPTimeseriesGroupDeviceTypeParamsOS = "LINUX" + HTTPTimeseriesGroupDeviceTypeParamsOSSmartTv HTTPTimeseriesGroupDeviceTypeParamsOS = "SMART_TV" +) + +type HTTPTimeseriesGroupDeviceTypeParamsTLSVersion string + +const ( + HTTPTimeseriesGroupDeviceTypeParamsTLSVersionTlSv1_0 HTTPTimeseriesGroupDeviceTypeParamsTLSVersion = "TLSv1_0" + HTTPTimeseriesGroupDeviceTypeParamsTLSVersionTlSv1_1 HTTPTimeseriesGroupDeviceTypeParamsTLSVersion = "TLSv1_1" + HTTPTimeseriesGroupDeviceTypeParamsTLSVersionTlSv1_2 HTTPTimeseriesGroupDeviceTypeParamsTLSVersion = "TLSv1_2" + HTTPTimeseriesGroupDeviceTypeParamsTLSVersionTlSv1_3 HTTPTimeseriesGroupDeviceTypeParamsTLSVersion = "TLSv1_3" + HTTPTimeseriesGroupDeviceTypeParamsTLSVersionTlSvQuic HTTPTimeseriesGroupDeviceTypeParamsTLSVersion = "TLSvQUIC" +) + +type HTTPTimeseriesGroupDeviceTypeResponseEnvelope struct { + Result HTTPTimeseriesGroupDeviceTypeResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpTimeseriesGroupDeviceTypeResponseEnvelopeJSON `json:"-"` +} + +// httpTimeseriesGroupDeviceTypeResponseEnvelopeJSON contains the JSON metadata for +// the struct [HTTPTimeseriesGroupDeviceTypeResponseEnvelope] +type httpTimeseriesGroupDeviceTypeResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupDeviceTypeResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupDeviceTypeResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupHTTPProtocolParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[HTTPTimeseriesGroupHTTPProtocolParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPTimeseriesGroupHTTPProtocolParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPTimeseriesGroupHTTPProtocolParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPTimeseriesGroupHTTPProtocolParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPTimeseriesGroupHTTPProtocolParamsFormat] `query:"format"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPTimeseriesGroupHTTPProtocolParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPTimeseriesGroupHTTPProtocolParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPTimeseriesGroupHTTPProtocolParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPTimeseriesGroupHTTPProtocolParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPTimeseriesGroupHTTPProtocolParams]'s query parameters +// as `url.Values`. +func (r HTTPTimeseriesGroupHTTPProtocolParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type HTTPTimeseriesGroupHTTPProtocolParamsAggInterval string + +const ( + HTTPTimeseriesGroupHTTPProtocolParamsAggInterval15m HTTPTimeseriesGroupHTTPProtocolParamsAggInterval = "15m" + HTTPTimeseriesGroupHTTPProtocolParamsAggInterval1h HTTPTimeseriesGroupHTTPProtocolParamsAggInterval = "1h" + HTTPTimeseriesGroupHTTPProtocolParamsAggInterval1d HTTPTimeseriesGroupHTTPProtocolParamsAggInterval = "1d" + HTTPTimeseriesGroupHTTPProtocolParamsAggInterval1w HTTPTimeseriesGroupHTTPProtocolParamsAggInterval = "1w" +) + +type HTTPTimeseriesGroupHTTPProtocolParamsBotClass string + +const ( + HTTPTimeseriesGroupHTTPProtocolParamsBotClassLikelyAutomated HTTPTimeseriesGroupHTTPProtocolParamsBotClass = "LIKELY_AUTOMATED" + HTTPTimeseriesGroupHTTPProtocolParamsBotClassLikelyHuman HTTPTimeseriesGroupHTTPProtocolParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPTimeseriesGroupHTTPProtocolParamsDateRange string + +const ( + HTTPTimeseriesGroupHTTPProtocolParamsDateRange1d HTTPTimeseriesGroupHTTPProtocolParamsDateRange = "1d" + HTTPTimeseriesGroupHTTPProtocolParamsDateRange2d HTTPTimeseriesGroupHTTPProtocolParamsDateRange = "2d" + HTTPTimeseriesGroupHTTPProtocolParamsDateRange7d HTTPTimeseriesGroupHTTPProtocolParamsDateRange = "7d" + HTTPTimeseriesGroupHTTPProtocolParamsDateRange14d HTTPTimeseriesGroupHTTPProtocolParamsDateRange = "14d" + HTTPTimeseriesGroupHTTPProtocolParamsDateRange28d HTTPTimeseriesGroupHTTPProtocolParamsDateRange = "28d" + HTTPTimeseriesGroupHTTPProtocolParamsDateRange12w HTTPTimeseriesGroupHTTPProtocolParamsDateRange = "12w" + HTTPTimeseriesGroupHTTPProtocolParamsDateRange24w HTTPTimeseriesGroupHTTPProtocolParamsDateRange = "24w" + HTTPTimeseriesGroupHTTPProtocolParamsDateRange52w HTTPTimeseriesGroupHTTPProtocolParamsDateRange = "52w" + HTTPTimeseriesGroupHTTPProtocolParamsDateRange1dControl HTTPTimeseriesGroupHTTPProtocolParamsDateRange = "1dControl" + HTTPTimeseriesGroupHTTPProtocolParamsDateRange2dControl HTTPTimeseriesGroupHTTPProtocolParamsDateRange = "2dControl" + HTTPTimeseriesGroupHTTPProtocolParamsDateRange7dControl HTTPTimeseriesGroupHTTPProtocolParamsDateRange = "7dControl" + HTTPTimeseriesGroupHTTPProtocolParamsDateRange14dControl HTTPTimeseriesGroupHTTPProtocolParamsDateRange = "14dControl" + HTTPTimeseriesGroupHTTPProtocolParamsDateRange28dControl HTTPTimeseriesGroupHTTPProtocolParamsDateRange = "28dControl" + HTTPTimeseriesGroupHTTPProtocolParamsDateRange12wControl HTTPTimeseriesGroupHTTPProtocolParamsDateRange = "12wControl" + HTTPTimeseriesGroupHTTPProtocolParamsDateRange24wControl HTTPTimeseriesGroupHTTPProtocolParamsDateRange = "24wControl" +) + +type HTTPTimeseriesGroupHTTPProtocolParamsDeviceType string + +const ( + HTTPTimeseriesGroupHTTPProtocolParamsDeviceTypeDesktop HTTPTimeseriesGroupHTTPProtocolParamsDeviceType = "DESKTOP" + HTTPTimeseriesGroupHTTPProtocolParamsDeviceTypeMobile HTTPTimeseriesGroupHTTPProtocolParamsDeviceType = "MOBILE" + HTTPTimeseriesGroupHTTPProtocolParamsDeviceTypeOther HTTPTimeseriesGroupHTTPProtocolParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPTimeseriesGroupHTTPProtocolParamsFormat string + +const ( + HTTPTimeseriesGroupHTTPProtocolParamsFormatJson HTTPTimeseriesGroupHTTPProtocolParamsFormat = "JSON" + HTTPTimeseriesGroupHTTPProtocolParamsFormatCsv HTTPTimeseriesGroupHTTPProtocolParamsFormat = "CSV" +) + +type HTTPTimeseriesGroupHTTPProtocolParamsHTTPVersion string + +const ( + HTTPTimeseriesGroupHTTPProtocolParamsHTTPVersionHttPv1 HTTPTimeseriesGroupHTTPProtocolParamsHTTPVersion = "HTTPv1" + HTTPTimeseriesGroupHTTPProtocolParamsHTTPVersionHttPv2 HTTPTimeseriesGroupHTTPProtocolParamsHTTPVersion = "HTTPv2" + HTTPTimeseriesGroupHTTPProtocolParamsHTTPVersionHttPv3 HTTPTimeseriesGroupHTTPProtocolParamsHTTPVersion = "HTTPv3" +) + +type HTTPTimeseriesGroupHTTPProtocolParamsIPVersion string + +const ( + HTTPTimeseriesGroupHTTPProtocolParamsIPVersionIPv4 HTTPTimeseriesGroupHTTPProtocolParamsIPVersion = "IPv4" + HTTPTimeseriesGroupHTTPProtocolParamsIPVersionIPv6 HTTPTimeseriesGroupHTTPProtocolParamsIPVersion = "IPv6" +) + +type HTTPTimeseriesGroupHTTPProtocolParamsOS string + +const ( + HTTPTimeseriesGroupHTTPProtocolParamsOSWindows HTTPTimeseriesGroupHTTPProtocolParamsOS = "WINDOWS" + HTTPTimeseriesGroupHTTPProtocolParamsOSMacosx HTTPTimeseriesGroupHTTPProtocolParamsOS = "MACOSX" + HTTPTimeseriesGroupHTTPProtocolParamsOSIos HTTPTimeseriesGroupHTTPProtocolParamsOS = "IOS" + HTTPTimeseriesGroupHTTPProtocolParamsOSAndroid HTTPTimeseriesGroupHTTPProtocolParamsOS = "ANDROID" + HTTPTimeseriesGroupHTTPProtocolParamsOSChromeos HTTPTimeseriesGroupHTTPProtocolParamsOS = "CHROMEOS" + HTTPTimeseriesGroupHTTPProtocolParamsOSLinux HTTPTimeseriesGroupHTTPProtocolParamsOS = "LINUX" + HTTPTimeseriesGroupHTTPProtocolParamsOSSmartTv HTTPTimeseriesGroupHTTPProtocolParamsOS = "SMART_TV" +) + +type HTTPTimeseriesGroupHTTPProtocolParamsTLSVersion string + +const ( + HTTPTimeseriesGroupHTTPProtocolParamsTLSVersionTlSv1_0 HTTPTimeseriesGroupHTTPProtocolParamsTLSVersion = "TLSv1_0" + HTTPTimeseriesGroupHTTPProtocolParamsTLSVersionTlSv1_1 HTTPTimeseriesGroupHTTPProtocolParamsTLSVersion = "TLSv1_1" + HTTPTimeseriesGroupHTTPProtocolParamsTLSVersionTlSv1_2 HTTPTimeseriesGroupHTTPProtocolParamsTLSVersion = "TLSv1_2" + HTTPTimeseriesGroupHTTPProtocolParamsTLSVersionTlSv1_3 HTTPTimeseriesGroupHTTPProtocolParamsTLSVersion = "TLSv1_3" + HTTPTimeseriesGroupHTTPProtocolParamsTLSVersionTlSvQuic HTTPTimeseriesGroupHTTPProtocolParamsTLSVersion = "TLSvQUIC" +) + +type HTTPTimeseriesGroupHTTPProtocolResponseEnvelope struct { + Result HTTPTimeseriesGroupHTTPProtocolResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpTimeseriesGroupHTTPProtocolResponseEnvelopeJSON `json:"-"` +} + +// httpTimeseriesGroupHTTPProtocolResponseEnvelopeJSON contains the JSON metadata +// for the struct [HTTPTimeseriesGroupHTTPProtocolResponseEnvelope] +type httpTimeseriesGroupHTTPProtocolResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupHTTPProtocolResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupHTTPProtocolResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupHTTPVersionParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[HTTPTimeseriesGroupHTTPVersionParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPTimeseriesGroupHTTPVersionParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPTimeseriesGroupHTTPVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPTimeseriesGroupHTTPVersionParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPTimeseriesGroupHTTPVersionParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPTimeseriesGroupHTTPVersionParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for ip version. + IPVersion param.Field[[]HTTPTimeseriesGroupHTTPVersionParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPTimeseriesGroupHTTPVersionParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPTimeseriesGroupHTTPVersionParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPTimeseriesGroupHTTPVersionParams]'s query parameters as +// `url.Values`. +func (r HTTPTimeseriesGroupHTTPVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type HTTPTimeseriesGroupHTTPVersionParamsAggInterval string + +const ( + HTTPTimeseriesGroupHTTPVersionParamsAggInterval15m HTTPTimeseriesGroupHTTPVersionParamsAggInterval = "15m" + HTTPTimeseriesGroupHTTPVersionParamsAggInterval1h HTTPTimeseriesGroupHTTPVersionParamsAggInterval = "1h" + HTTPTimeseriesGroupHTTPVersionParamsAggInterval1d HTTPTimeseriesGroupHTTPVersionParamsAggInterval = "1d" + HTTPTimeseriesGroupHTTPVersionParamsAggInterval1w HTTPTimeseriesGroupHTTPVersionParamsAggInterval = "1w" +) + +type HTTPTimeseriesGroupHTTPVersionParamsBotClass string + +const ( + HTTPTimeseriesGroupHTTPVersionParamsBotClassLikelyAutomated HTTPTimeseriesGroupHTTPVersionParamsBotClass = "LIKELY_AUTOMATED" + HTTPTimeseriesGroupHTTPVersionParamsBotClassLikelyHuman HTTPTimeseriesGroupHTTPVersionParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPTimeseriesGroupHTTPVersionParamsDateRange string + +const ( + HTTPTimeseriesGroupHTTPVersionParamsDateRange1d HTTPTimeseriesGroupHTTPVersionParamsDateRange = "1d" + HTTPTimeseriesGroupHTTPVersionParamsDateRange2d HTTPTimeseriesGroupHTTPVersionParamsDateRange = "2d" + HTTPTimeseriesGroupHTTPVersionParamsDateRange7d HTTPTimeseriesGroupHTTPVersionParamsDateRange = "7d" + HTTPTimeseriesGroupHTTPVersionParamsDateRange14d HTTPTimeseriesGroupHTTPVersionParamsDateRange = "14d" + HTTPTimeseriesGroupHTTPVersionParamsDateRange28d HTTPTimeseriesGroupHTTPVersionParamsDateRange = "28d" + HTTPTimeseriesGroupHTTPVersionParamsDateRange12w HTTPTimeseriesGroupHTTPVersionParamsDateRange = "12w" + HTTPTimeseriesGroupHTTPVersionParamsDateRange24w HTTPTimeseriesGroupHTTPVersionParamsDateRange = "24w" + HTTPTimeseriesGroupHTTPVersionParamsDateRange52w HTTPTimeseriesGroupHTTPVersionParamsDateRange = "52w" + HTTPTimeseriesGroupHTTPVersionParamsDateRange1dControl HTTPTimeseriesGroupHTTPVersionParamsDateRange = "1dControl" + HTTPTimeseriesGroupHTTPVersionParamsDateRange2dControl HTTPTimeseriesGroupHTTPVersionParamsDateRange = "2dControl" + HTTPTimeseriesGroupHTTPVersionParamsDateRange7dControl HTTPTimeseriesGroupHTTPVersionParamsDateRange = "7dControl" + HTTPTimeseriesGroupHTTPVersionParamsDateRange14dControl HTTPTimeseriesGroupHTTPVersionParamsDateRange = "14dControl" + HTTPTimeseriesGroupHTTPVersionParamsDateRange28dControl HTTPTimeseriesGroupHTTPVersionParamsDateRange = "28dControl" + HTTPTimeseriesGroupHTTPVersionParamsDateRange12wControl HTTPTimeseriesGroupHTTPVersionParamsDateRange = "12wControl" + HTTPTimeseriesGroupHTTPVersionParamsDateRange24wControl HTTPTimeseriesGroupHTTPVersionParamsDateRange = "24wControl" +) + +type HTTPTimeseriesGroupHTTPVersionParamsDeviceType string + +const ( + HTTPTimeseriesGroupHTTPVersionParamsDeviceTypeDesktop HTTPTimeseriesGroupHTTPVersionParamsDeviceType = "DESKTOP" + HTTPTimeseriesGroupHTTPVersionParamsDeviceTypeMobile HTTPTimeseriesGroupHTTPVersionParamsDeviceType = "MOBILE" + HTTPTimeseriesGroupHTTPVersionParamsDeviceTypeOther HTTPTimeseriesGroupHTTPVersionParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPTimeseriesGroupHTTPVersionParamsFormat string + +const ( + HTTPTimeseriesGroupHTTPVersionParamsFormatJson HTTPTimeseriesGroupHTTPVersionParamsFormat = "JSON" + HTTPTimeseriesGroupHTTPVersionParamsFormatCsv HTTPTimeseriesGroupHTTPVersionParamsFormat = "CSV" +) + +type HTTPTimeseriesGroupHTTPVersionParamsHTTPProtocol string + +const ( + HTTPTimeseriesGroupHTTPVersionParamsHTTPProtocolHTTP HTTPTimeseriesGroupHTTPVersionParamsHTTPProtocol = "HTTP" + HTTPTimeseriesGroupHTTPVersionParamsHTTPProtocolHTTPS HTTPTimeseriesGroupHTTPVersionParamsHTTPProtocol = "HTTPS" +) + +type HTTPTimeseriesGroupHTTPVersionParamsIPVersion string + +const ( + HTTPTimeseriesGroupHTTPVersionParamsIPVersionIPv4 HTTPTimeseriesGroupHTTPVersionParamsIPVersion = "IPv4" + HTTPTimeseriesGroupHTTPVersionParamsIPVersionIPv6 HTTPTimeseriesGroupHTTPVersionParamsIPVersion = "IPv6" +) + +type HTTPTimeseriesGroupHTTPVersionParamsOS string + +const ( + HTTPTimeseriesGroupHTTPVersionParamsOSWindows HTTPTimeseriesGroupHTTPVersionParamsOS = "WINDOWS" + HTTPTimeseriesGroupHTTPVersionParamsOSMacosx HTTPTimeseriesGroupHTTPVersionParamsOS = "MACOSX" + HTTPTimeseriesGroupHTTPVersionParamsOSIos HTTPTimeseriesGroupHTTPVersionParamsOS = "IOS" + HTTPTimeseriesGroupHTTPVersionParamsOSAndroid HTTPTimeseriesGroupHTTPVersionParamsOS = "ANDROID" + HTTPTimeseriesGroupHTTPVersionParamsOSChromeos HTTPTimeseriesGroupHTTPVersionParamsOS = "CHROMEOS" + HTTPTimeseriesGroupHTTPVersionParamsOSLinux HTTPTimeseriesGroupHTTPVersionParamsOS = "LINUX" + HTTPTimeseriesGroupHTTPVersionParamsOSSmartTv HTTPTimeseriesGroupHTTPVersionParamsOS = "SMART_TV" +) + +type HTTPTimeseriesGroupHTTPVersionParamsTLSVersion string + +const ( + HTTPTimeseriesGroupHTTPVersionParamsTLSVersionTlSv1_0 HTTPTimeseriesGroupHTTPVersionParamsTLSVersion = "TLSv1_0" + HTTPTimeseriesGroupHTTPVersionParamsTLSVersionTlSv1_1 HTTPTimeseriesGroupHTTPVersionParamsTLSVersion = "TLSv1_1" + HTTPTimeseriesGroupHTTPVersionParamsTLSVersionTlSv1_2 HTTPTimeseriesGroupHTTPVersionParamsTLSVersion = "TLSv1_2" + HTTPTimeseriesGroupHTTPVersionParamsTLSVersionTlSv1_3 HTTPTimeseriesGroupHTTPVersionParamsTLSVersion = "TLSv1_3" + HTTPTimeseriesGroupHTTPVersionParamsTLSVersionTlSvQuic HTTPTimeseriesGroupHTTPVersionParamsTLSVersion = "TLSvQUIC" +) + +type HTTPTimeseriesGroupHTTPVersionResponseEnvelope struct { + Result HTTPTimeseriesGroupHTTPVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpTimeseriesGroupHTTPVersionResponseEnvelopeJSON `json:"-"` +} + +// httpTimeseriesGroupHTTPVersionResponseEnvelopeJSON contains the JSON metadata +// for the struct [HTTPTimeseriesGroupHTTPVersionResponseEnvelope] +type httpTimeseriesGroupHTTPVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupHTTPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupHTTPVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupIPVersionParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[HTTPTimeseriesGroupIPVersionParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPTimeseriesGroupIPVersionParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPTimeseriesGroupIPVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPTimeseriesGroupIPVersionParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPTimeseriesGroupIPVersionParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPTimeseriesGroupIPVersionParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPTimeseriesGroupIPVersionParamsHTTPVersion] `query:"httpVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPTimeseriesGroupIPVersionParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPTimeseriesGroupIPVersionParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPTimeseriesGroupIPVersionParams]'s query parameters as +// `url.Values`. +func (r HTTPTimeseriesGroupIPVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type HTTPTimeseriesGroupIPVersionParamsAggInterval string + +const ( + HTTPTimeseriesGroupIPVersionParamsAggInterval15m HTTPTimeseriesGroupIPVersionParamsAggInterval = "15m" + HTTPTimeseriesGroupIPVersionParamsAggInterval1h HTTPTimeseriesGroupIPVersionParamsAggInterval = "1h" + HTTPTimeseriesGroupIPVersionParamsAggInterval1d HTTPTimeseriesGroupIPVersionParamsAggInterval = "1d" + HTTPTimeseriesGroupIPVersionParamsAggInterval1w HTTPTimeseriesGroupIPVersionParamsAggInterval = "1w" +) + +type HTTPTimeseriesGroupIPVersionParamsBotClass string + +const ( + HTTPTimeseriesGroupIPVersionParamsBotClassLikelyAutomated HTTPTimeseriesGroupIPVersionParamsBotClass = "LIKELY_AUTOMATED" + HTTPTimeseriesGroupIPVersionParamsBotClassLikelyHuman HTTPTimeseriesGroupIPVersionParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPTimeseriesGroupIPVersionParamsDateRange string + +const ( + HTTPTimeseriesGroupIPVersionParamsDateRange1d HTTPTimeseriesGroupIPVersionParamsDateRange = "1d" + HTTPTimeseriesGroupIPVersionParamsDateRange2d HTTPTimeseriesGroupIPVersionParamsDateRange = "2d" + HTTPTimeseriesGroupIPVersionParamsDateRange7d HTTPTimeseriesGroupIPVersionParamsDateRange = "7d" + HTTPTimeseriesGroupIPVersionParamsDateRange14d HTTPTimeseriesGroupIPVersionParamsDateRange = "14d" + HTTPTimeseriesGroupIPVersionParamsDateRange28d HTTPTimeseriesGroupIPVersionParamsDateRange = "28d" + HTTPTimeseriesGroupIPVersionParamsDateRange12w HTTPTimeseriesGroupIPVersionParamsDateRange = "12w" + HTTPTimeseriesGroupIPVersionParamsDateRange24w HTTPTimeseriesGroupIPVersionParamsDateRange = "24w" + HTTPTimeseriesGroupIPVersionParamsDateRange52w HTTPTimeseriesGroupIPVersionParamsDateRange = "52w" + HTTPTimeseriesGroupIPVersionParamsDateRange1dControl HTTPTimeseriesGroupIPVersionParamsDateRange = "1dControl" + HTTPTimeseriesGroupIPVersionParamsDateRange2dControl HTTPTimeseriesGroupIPVersionParamsDateRange = "2dControl" + HTTPTimeseriesGroupIPVersionParamsDateRange7dControl HTTPTimeseriesGroupIPVersionParamsDateRange = "7dControl" + HTTPTimeseriesGroupIPVersionParamsDateRange14dControl HTTPTimeseriesGroupIPVersionParamsDateRange = "14dControl" + HTTPTimeseriesGroupIPVersionParamsDateRange28dControl HTTPTimeseriesGroupIPVersionParamsDateRange = "28dControl" + HTTPTimeseriesGroupIPVersionParamsDateRange12wControl HTTPTimeseriesGroupIPVersionParamsDateRange = "12wControl" + HTTPTimeseriesGroupIPVersionParamsDateRange24wControl HTTPTimeseriesGroupIPVersionParamsDateRange = "24wControl" +) + +type HTTPTimeseriesGroupIPVersionParamsDeviceType string + +const ( + HTTPTimeseriesGroupIPVersionParamsDeviceTypeDesktop HTTPTimeseriesGroupIPVersionParamsDeviceType = "DESKTOP" + HTTPTimeseriesGroupIPVersionParamsDeviceTypeMobile HTTPTimeseriesGroupIPVersionParamsDeviceType = "MOBILE" + HTTPTimeseriesGroupIPVersionParamsDeviceTypeOther HTTPTimeseriesGroupIPVersionParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPTimeseriesGroupIPVersionParamsFormat string + +const ( + HTTPTimeseriesGroupIPVersionParamsFormatJson HTTPTimeseriesGroupIPVersionParamsFormat = "JSON" + HTTPTimeseriesGroupIPVersionParamsFormatCsv HTTPTimeseriesGroupIPVersionParamsFormat = "CSV" +) + +type HTTPTimeseriesGroupIPVersionParamsHTTPProtocol string + +const ( + HTTPTimeseriesGroupIPVersionParamsHTTPProtocolHTTP HTTPTimeseriesGroupIPVersionParamsHTTPProtocol = "HTTP" + HTTPTimeseriesGroupIPVersionParamsHTTPProtocolHTTPS HTTPTimeseriesGroupIPVersionParamsHTTPProtocol = "HTTPS" +) + +type HTTPTimeseriesGroupIPVersionParamsHTTPVersion string + +const ( + HTTPTimeseriesGroupIPVersionParamsHTTPVersionHttPv1 HTTPTimeseriesGroupIPVersionParamsHTTPVersion = "HTTPv1" + HTTPTimeseriesGroupIPVersionParamsHTTPVersionHttPv2 HTTPTimeseriesGroupIPVersionParamsHTTPVersion = "HTTPv2" + HTTPTimeseriesGroupIPVersionParamsHTTPVersionHttPv3 HTTPTimeseriesGroupIPVersionParamsHTTPVersion = "HTTPv3" +) + +type HTTPTimeseriesGroupIPVersionParamsOS string + +const ( + HTTPTimeseriesGroupIPVersionParamsOSWindows HTTPTimeseriesGroupIPVersionParamsOS = "WINDOWS" + HTTPTimeseriesGroupIPVersionParamsOSMacosx HTTPTimeseriesGroupIPVersionParamsOS = "MACOSX" + HTTPTimeseriesGroupIPVersionParamsOSIos HTTPTimeseriesGroupIPVersionParamsOS = "IOS" + HTTPTimeseriesGroupIPVersionParamsOSAndroid HTTPTimeseriesGroupIPVersionParamsOS = "ANDROID" + HTTPTimeseriesGroupIPVersionParamsOSChromeos HTTPTimeseriesGroupIPVersionParamsOS = "CHROMEOS" + HTTPTimeseriesGroupIPVersionParamsOSLinux HTTPTimeseriesGroupIPVersionParamsOS = "LINUX" + HTTPTimeseriesGroupIPVersionParamsOSSmartTv HTTPTimeseriesGroupIPVersionParamsOS = "SMART_TV" +) + +type HTTPTimeseriesGroupIPVersionParamsTLSVersion string + +const ( + HTTPTimeseriesGroupIPVersionParamsTLSVersionTlSv1_0 HTTPTimeseriesGroupIPVersionParamsTLSVersion = "TLSv1_0" + HTTPTimeseriesGroupIPVersionParamsTLSVersionTlSv1_1 HTTPTimeseriesGroupIPVersionParamsTLSVersion = "TLSv1_1" + HTTPTimeseriesGroupIPVersionParamsTLSVersionTlSv1_2 HTTPTimeseriesGroupIPVersionParamsTLSVersion = "TLSv1_2" + HTTPTimeseriesGroupIPVersionParamsTLSVersionTlSv1_3 HTTPTimeseriesGroupIPVersionParamsTLSVersion = "TLSv1_3" + HTTPTimeseriesGroupIPVersionParamsTLSVersionTlSvQuic HTTPTimeseriesGroupIPVersionParamsTLSVersion = "TLSvQUIC" +) + +type HTTPTimeseriesGroupIPVersionResponseEnvelope struct { + Result HTTPTimeseriesGroupIPVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpTimeseriesGroupIPVersionResponseEnvelopeJSON `json:"-"` +} + +// httpTimeseriesGroupIPVersionResponseEnvelopeJSON contains the JSON metadata for +// the struct [HTTPTimeseriesGroupIPVersionResponseEnvelope] +type httpTimeseriesGroupIPVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupIPVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupOSParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[HTTPTimeseriesGroupOSParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPTimeseriesGroupOSParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPTimeseriesGroupOSParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPTimeseriesGroupOSParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPTimeseriesGroupOSParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPTimeseriesGroupOSParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPTimeseriesGroupOSParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPTimeseriesGroupOSParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPTimeseriesGroupOSParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPTimeseriesGroupOSParams]'s query parameters as +// `url.Values`. +func (r HTTPTimeseriesGroupOSParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type HTTPTimeseriesGroupOSParamsAggInterval string + +const ( + HTTPTimeseriesGroupOSParamsAggInterval15m HTTPTimeseriesGroupOSParamsAggInterval = "15m" + HTTPTimeseriesGroupOSParamsAggInterval1h HTTPTimeseriesGroupOSParamsAggInterval = "1h" + HTTPTimeseriesGroupOSParamsAggInterval1d HTTPTimeseriesGroupOSParamsAggInterval = "1d" + HTTPTimeseriesGroupOSParamsAggInterval1w HTTPTimeseriesGroupOSParamsAggInterval = "1w" +) + +type HTTPTimeseriesGroupOSParamsBotClass string + +const ( + HTTPTimeseriesGroupOSParamsBotClassLikelyAutomated HTTPTimeseriesGroupOSParamsBotClass = "LIKELY_AUTOMATED" + HTTPTimeseriesGroupOSParamsBotClassLikelyHuman HTTPTimeseriesGroupOSParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPTimeseriesGroupOSParamsDateRange string + +const ( + HTTPTimeseriesGroupOSParamsDateRange1d HTTPTimeseriesGroupOSParamsDateRange = "1d" + HTTPTimeseriesGroupOSParamsDateRange2d HTTPTimeseriesGroupOSParamsDateRange = "2d" + HTTPTimeseriesGroupOSParamsDateRange7d HTTPTimeseriesGroupOSParamsDateRange = "7d" + HTTPTimeseriesGroupOSParamsDateRange14d HTTPTimeseriesGroupOSParamsDateRange = "14d" + HTTPTimeseriesGroupOSParamsDateRange28d HTTPTimeseriesGroupOSParamsDateRange = "28d" + HTTPTimeseriesGroupOSParamsDateRange12w HTTPTimeseriesGroupOSParamsDateRange = "12w" + HTTPTimeseriesGroupOSParamsDateRange24w HTTPTimeseriesGroupOSParamsDateRange = "24w" + HTTPTimeseriesGroupOSParamsDateRange52w HTTPTimeseriesGroupOSParamsDateRange = "52w" + HTTPTimeseriesGroupOSParamsDateRange1dControl HTTPTimeseriesGroupOSParamsDateRange = "1dControl" + HTTPTimeseriesGroupOSParamsDateRange2dControl HTTPTimeseriesGroupOSParamsDateRange = "2dControl" + HTTPTimeseriesGroupOSParamsDateRange7dControl HTTPTimeseriesGroupOSParamsDateRange = "7dControl" + HTTPTimeseriesGroupOSParamsDateRange14dControl HTTPTimeseriesGroupOSParamsDateRange = "14dControl" + HTTPTimeseriesGroupOSParamsDateRange28dControl HTTPTimeseriesGroupOSParamsDateRange = "28dControl" + HTTPTimeseriesGroupOSParamsDateRange12wControl HTTPTimeseriesGroupOSParamsDateRange = "12wControl" + HTTPTimeseriesGroupOSParamsDateRange24wControl HTTPTimeseriesGroupOSParamsDateRange = "24wControl" +) + +type HTTPTimeseriesGroupOSParamsDeviceType string + +const ( + HTTPTimeseriesGroupOSParamsDeviceTypeDesktop HTTPTimeseriesGroupOSParamsDeviceType = "DESKTOP" + HTTPTimeseriesGroupOSParamsDeviceTypeMobile HTTPTimeseriesGroupOSParamsDeviceType = "MOBILE" + HTTPTimeseriesGroupOSParamsDeviceTypeOther HTTPTimeseriesGroupOSParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPTimeseriesGroupOSParamsFormat string + +const ( + HTTPTimeseriesGroupOSParamsFormatJson HTTPTimeseriesGroupOSParamsFormat = "JSON" + HTTPTimeseriesGroupOSParamsFormatCsv HTTPTimeseriesGroupOSParamsFormat = "CSV" +) + +type HTTPTimeseriesGroupOSParamsHTTPProtocol string + +const ( + HTTPTimeseriesGroupOSParamsHTTPProtocolHTTP HTTPTimeseriesGroupOSParamsHTTPProtocol = "HTTP" + HTTPTimeseriesGroupOSParamsHTTPProtocolHTTPS HTTPTimeseriesGroupOSParamsHTTPProtocol = "HTTPS" +) + +type HTTPTimeseriesGroupOSParamsHTTPVersion string + +const ( + HTTPTimeseriesGroupOSParamsHTTPVersionHttPv1 HTTPTimeseriesGroupOSParamsHTTPVersion = "HTTPv1" + HTTPTimeseriesGroupOSParamsHTTPVersionHttPv2 HTTPTimeseriesGroupOSParamsHTTPVersion = "HTTPv2" + HTTPTimeseriesGroupOSParamsHTTPVersionHttPv3 HTTPTimeseriesGroupOSParamsHTTPVersion = "HTTPv3" +) + +type HTTPTimeseriesGroupOSParamsIPVersion string + +const ( + HTTPTimeseriesGroupOSParamsIPVersionIPv4 HTTPTimeseriesGroupOSParamsIPVersion = "IPv4" + HTTPTimeseriesGroupOSParamsIPVersionIPv6 HTTPTimeseriesGroupOSParamsIPVersion = "IPv6" +) + +type HTTPTimeseriesGroupOSParamsTLSVersion string + +const ( + HTTPTimeseriesGroupOSParamsTLSVersionTlSv1_0 HTTPTimeseriesGroupOSParamsTLSVersion = "TLSv1_0" + HTTPTimeseriesGroupOSParamsTLSVersionTlSv1_1 HTTPTimeseriesGroupOSParamsTLSVersion = "TLSv1_1" + HTTPTimeseriesGroupOSParamsTLSVersionTlSv1_2 HTTPTimeseriesGroupOSParamsTLSVersion = "TLSv1_2" + HTTPTimeseriesGroupOSParamsTLSVersionTlSv1_3 HTTPTimeseriesGroupOSParamsTLSVersion = "TLSv1_3" + HTTPTimeseriesGroupOSParamsTLSVersionTlSvQuic HTTPTimeseriesGroupOSParamsTLSVersion = "TLSvQUIC" +) + +type HTTPTimeseriesGroupOSResponseEnvelope struct { + Result HTTPTimeseriesGroupOSResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpTimeseriesGroupOSResponseEnvelopeJSON `json:"-"` +} + +// httpTimeseriesGroupOSResponseEnvelopeJSON contains the JSON metadata for the +// struct [HTTPTimeseriesGroupOSResponseEnvelope] +type httpTimeseriesGroupOSResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupOSResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupOSResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HTTPTimeseriesGroupTLSVersionParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[HTTPTimeseriesGroupTLSVersionParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPTimeseriesGroupTLSVersionParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPTimeseriesGroupTLSVersionParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPTimeseriesGroupTLSVersionParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPTimeseriesGroupTLSVersionParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPTimeseriesGroupTLSVersionParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPTimeseriesGroupTLSVersionParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPTimeseriesGroupTLSVersionParamsIPVersion] `query:"ipVersion"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPTimeseriesGroupTLSVersionParamsOS] `query:"os"` +} + +// URLQuery serializes [HTTPTimeseriesGroupTLSVersionParams]'s query parameters as +// `url.Values`. +func (r HTTPTimeseriesGroupTLSVersionParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type HTTPTimeseriesGroupTLSVersionParamsAggInterval string + +const ( + HTTPTimeseriesGroupTLSVersionParamsAggInterval15m HTTPTimeseriesGroupTLSVersionParamsAggInterval = "15m" + HTTPTimeseriesGroupTLSVersionParamsAggInterval1h HTTPTimeseriesGroupTLSVersionParamsAggInterval = "1h" + HTTPTimeseriesGroupTLSVersionParamsAggInterval1d HTTPTimeseriesGroupTLSVersionParamsAggInterval = "1d" + HTTPTimeseriesGroupTLSVersionParamsAggInterval1w HTTPTimeseriesGroupTLSVersionParamsAggInterval = "1w" +) + +type HTTPTimeseriesGroupTLSVersionParamsBotClass string + +const ( + HTTPTimeseriesGroupTLSVersionParamsBotClassLikelyAutomated HTTPTimeseriesGroupTLSVersionParamsBotClass = "LIKELY_AUTOMATED" + HTTPTimeseriesGroupTLSVersionParamsBotClassLikelyHuman HTTPTimeseriesGroupTLSVersionParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPTimeseriesGroupTLSVersionParamsDateRange string + +const ( + HTTPTimeseriesGroupTLSVersionParamsDateRange1d HTTPTimeseriesGroupTLSVersionParamsDateRange = "1d" + HTTPTimeseriesGroupTLSVersionParamsDateRange2d HTTPTimeseriesGroupTLSVersionParamsDateRange = "2d" + HTTPTimeseriesGroupTLSVersionParamsDateRange7d HTTPTimeseriesGroupTLSVersionParamsDateRange = "7d" + HTTPTimeseriesGroupTLSVersionParamsDateRange14d HTTPTimeseriesGroupTLSVersionParamsDateRange = "14d" + HTTPTimeseriesGroupTLSVersionParamsDateRange28d HTTPTimeseriesGroupTLSVersionParamsDateRange = "28d" + HTTPTimeseriesGroupTLSVersionParamsDateRange12w HTTPTimeseriesGroupTLSVersionParamsDateRange = "12w" + HTTPTimeseriesGroupTLSVersionParamsDateRange24w HTTPTimeseriesGroupTLSVersionParamsDateRange = "24w" + HTTPTimeseriesGroupTLSVersionParamsDateRange52w HTTPTimeseriesGroupTLSVersionParamsDateRange = "52w" + HTTPTimeseriesGroupTLSVersionParamsDateRange1dControl HTTPTimeseriesGroupTLSVersionParamsDateRange = "1dControl" + HTTPTimeseriesGroupTLSVersionParamsDateRange2dControl HTTPTimeseriesGroupTLSVersionParamsDateRange = "2dControl" + HTTPTimeseriesGroupTLSVersionParamsDateRange7dControl HTTPTimeseriesGroupTLSVersionParamsDateRange = "7dControl" + HTTPTimeseriesGroupTLSVersionParamsDateRange14dControl HTTPTimeseriesGroupTLSVersionParamsDateRange = "14dControl" + HTTPTimeseriesGroupTLSVersionParamsDateRange28dControl HTTPTimeseriesGroupTLSVersionParamsDateRange = "28dControl" + HTTPTimeseriesGroupTLSVersionParamsDateRange12wControl HTTPTimeseriesGroupTLSVersionParamsDateRange = "12wControl" + HTTPTimeseriesGroupTLSVersionParamsDateRange24wControl HTTPTimeseriesGroupTLSVersionParamsDateRange = "24wControl" +) + +type HTTPTimeseriesGroupTLSVersionParamsDeviceType string + +const ( + HTTPTimeseriesGroupTLSVersionParamsDeviceTypeDesktop HTTPTimeseriesGroupTLSVersionParamsDeviceType = "DESKTOP" + HTTPTimeseriesGroupTLSVersionParamsDeviceTypeMobile HTTPTimeseriesGroupTLSVersionParamsDeviceType = "MOBILE" + HTTPTimeseriesGroupTLSVersionParamsDeviceTypeOther HTTPTimeseriesGroupTLSVersionParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPTimeseriesGroupTLSVersionParamsFormat string + +const ( + HTTPTimeseriesGroupTLSVersionParamsFormatJson HTTPTimeseriesGroupTLSVersionParamsFormat = "JSON" + HTTPTimeseriesGroupTLSVersionParamsFormatCsv HTTPTimeseriesGroupTLSVersionParamsFormat = "CSV" +) + +type HTTPTimeseriesGroupTLSVersionParamsHTTPProtocol string + +const ( + HTTPTimeseriesGroupTLSVersionParamsHTTPProtocolHTTP HTTPTimeseriesGroupTLSVersionParamsHTTPProtocol = "HTTP" + HTTPTimeseriesGroupTLSVersionParamsHTTPProtocolHTTPS HTTPTimeseriesGroupTLSVersionParamsHTTPProtocol = "HTTPS" +) + +type HTTPTimeseriesGroupTLSVersionParamsHTTPVersion string + +const ( + HTTPTimeseriesGroupTLSVersionParamsHTTPVersionHttPv1 HTTPTimeseriesGroupTLSVersionParamsHTTPVersion = "HTTPv1" + HTTPTimeseriesGroupTLSVersionParamsHTTPVersionHttPv2 HTTPTimeseriesGroupTLSVersionParamsHTTPVersion = "HTTPv2" + HTTPTimeseriesGroupTLSVersionParamsHTTPVersionHttPv3 HTTPTimeseriesGroupTLSVersionParamsHTTPVersion = "HTTPv3" +) + +type HTTPTimeseriesGroupTLSVersionParamsIPVersion string + +const ( + HTTPTimeseriesGroupTLSVersionParamsIPVersionIPv4 HTTPTimeseriesGroupTLSVersionParamsIPVersion = "IPv4" + HTTPTimeseriesGroupTLSVersionParamsIPVersionIPv6 HTTPTimeseriesGroupTLSVersionParamsIPVersion = "IPv6" +) + +type HTTPTimeseriesGroupTLSVersionParamsOS string + +const ( + HTTPTimeseriesGroupTLSVersionParamsOSWindows HTTPTimeseriesGroupTLSVersionParamsOS = "WINDOWS" + HTTPTimeseriesGroupTLSVersionParamsOSMacosx HTTPTimeseriesGroupTLSVersionParamsOS = "MACOSX" + HTTPTimeseriesGroupTLSVersionParamsOSIos HTTPTimeseriesGroupTLSVersionParamsOS = "IOS" + HTTPTimeseriesGroupTLSVersionParamsOSAndroid HTTPTimeseriesGroupTLSVersionParamsOS = "ANDROID" + HTTPTimeseriesGroupTLSVersionParamsOSChromeos HTTPTimeseriesGroupTLSVersionParamsOS = "CHROMEOS" + HTTPTimeseriesGroupTLSVersionParamsOSLinux HTTPTimeseriesGroupTLSVersionParamsOS = "LINUX" + HTTPTimeseriesGroupTLSVersionParamsOSSmartTv HTTPTimeseriesGroupTLSVersionParamsOS = "SMART_TV" +) + +type HTTPTimeseriesGroupTLSVersionResponseEnvelope struct { + Result HTTPTimeseriesGroupTLSVersionResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpTimeseriesGroupTLSVersionResponseEnvelopeJSON `json:"-"` +} + +// httpTimeseriesGroupTLSVersionResponseEnvelopeJSON contains the JSON metadata for +// the struct [HTTPTimeseriesGroupTLSVersionResponseEnvelope] +type httpTimeseriesGroupTLSVersionResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTimeseriesGroupTLSVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTimeseriesGroupTLSVersionResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httptimeseriesgroup_test.go b/radar/httptimeseriesgroup_test.go new file mode 100644 index 00000000000..38f1706d2ed --- /dev/null +++ b/radar/httptimeseriesgroup_test.go @@ -0,0 +1,379 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPTimeseriesGroupBotClassWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.TimeseriesGroups.BotClass(context.TODO(), radar.HTTPTimeseriesGroupBotClassParams{ + AggInterval: cloudflare.F(radar.HTTPTimeseriesGroupBotClassParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPTimeseriesGroupBotClassParamsDateRange{radar.HTTPTimeseriesGroupBotClassParamsDateRange1d, radar.HTTPTimeseriesGroupBotClassParamsDateRange2d, radar.HTTPTimeseriesGroupBotClassParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPTimeseriesGroupBotClassParamsDeviceType{radar.HTTPTimeseriesGroupBotClassParamsDeviceTypeDesktop, radar.HTTPTimeseriesGroupBotClassParamsDeviceTypeMobile, radar.HTTPTimeseriesGroupBotClassParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPTimeseriesGroupBotClassParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPTimeseriesGroupBotClassParamsHTTPProtocol{radar.HTTPTimeseriesGroupBotClassParamsHTTPProtocolHTTP, radar.HTTPTimeseriesGroupBotClassParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPTimeseriesGroupBotClassParamsHTTPVersion{radar.HTTPTimeseriesGroupBotClassParamsHTTPVersionHttPv1, radar.HTTPTimeseriesGroupBotClassParamsHTTPVersionHttPv2, radar.HTTPTimeseriesGroupBotClassParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPTimeseriesGroupBotClassParamsIPVersion{radar.HTTPTimeseriesGroupBotClassParamsIPVersionIPv4, radar.HTTPTimeseriesGroupBotClassParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPTimeseriesGroupBotClassParamsOS{radar.HTTPTimeseriesGroupBotClassParamsOSWindows, radar.HTTPTimeseriesGroupBotClassParamsOSMacosx, radar.HTTPTimeseriesGroupBotClassParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPTimeseriesGroupBotClassParamsTLSVersion{radar.HTTPTimeseriesGroupBotClassParamsTLSVersionTlSv1_0, radar.HTTPTimeseriesGroupBotClassParamsTLSVersionTlSv1_1, radar.HTTPTimeseriesGroupBotClassParamsTLSVersionTlSv1_2}), + }) + 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 TestHTTPTimeseriesGroupBrowserWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.TimeseriesGroups.Browser(context.TODO(), radar.HTTPTimeseriesGroupBrowserParams{ + AggInterval: cloudflare.F(radar.HTTPTimeseriesGroupBrowserParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPTimeseriesGroupBrowserParamsBotClass{radar.HTTPTimeseriesGroupBrowserParamsBotClassLikelyAutomated, radar.HTTPTimeseriesGroupBrowserParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPTimeseriesGroupBrowserParamsDateRange{radar.HTTPTimeseriesGroupBrowserParamsDateRange1d, radar.HTTPTimeseriesGroupBrowserParamsDateRange2d, radar.HTTPTimeseriesGroupBrowserParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPTimeseriesGroupBrowserParamsDeviceType{radar.HTTPTimeseriesGroupBrowserParamsDeviceTypeDesktop, radar.HTTPTimeseriesGroupBrowserParamsDeviceTypeMobile, radar.HTTPTimeseriesGroupBrowserParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPTimeseriesGroupBrowserParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPTimeseriesGroupBrowserParamsHTTPProtocol{radar.HTTPTimeseriesGroupBrowserParamsHTTPProtocolHTTP, radar.HTTPTimeseriesGroupBrowserParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPTimeseriesGroupBrowserParamsHTTPVersion{radar.HTTPTimeseriesGroupBrowserParamsHTTPVersionHttPv1, radar.HTTPTimeseriesGroupBrowserParamsHTTPVersionHttPv2, radar.HTTPTimeseriesGroupBrowserParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPTimeseriesGroupBrowserParamsIPVersion{radar.HTTPTimeseriesGroupBrowserParamsIPVersionIPv4, radar.HTTPTimeseriesGroupBrowserParamsIPVersionIPv6}), + LimitPerGroup: cloudflare.F(int64(4)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPTimeseriesGroupBrowserParamsOS{radar.HTTPTimeseriesGroupBrowserParamsOSWindows, radar.HTTPTimeseriesGroupBrowserParamsOSMacosx, radar.HTTPTimeseriesGroupBrowserParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPTimeseriesGroupBrowserParamsTLSVersion{radar.HTTPTimeseriesGroupBrowserParamsTLSVersionTlSv1_0, radar.HTTPTimeseriesGroupBrowserParamsTLSVersionTlSv1_1, radar.HTTPTimeseriesGroupBrowserParamsTLSVersionTlSv1_2}), + }) + 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 TestHTTPTimeseriesGroupBrowserFamilyWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.TimeseriesGroups.BrowserFamily(context.TODO(), radar.HTTPTimeseriesGroupBrowserFamilyParams{ + AggInterval: cloudflare.F(radar.HTTPTimeseriesGroupBrowserFamilyParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPTimeseriesGroupBrowserFamilyParamsBotClass{radar.HTTPTimeseriesGroupBrowserFamilyParamsBotClassLikelyAutomated, radar.HTTPTimeseriesGroupBrowserFamilyParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPTimeseriesGroupBrowserFamilyParamsDateRange{radar.HTTPTimeseriesGroupBrowserFamilyParamsDateRange1d, radar.HTTPTimeseriesGroupBrowserFamilyParamsDateRange2d, radar.HTTPTimeseriesGroupBrowserFamilyParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPTimeseriesGroupBrowserFamilyParamsDeviceType{radar.HTTPTimeseriesGroupBrowserFamilyParamsDeviceTypeDesktop, radar.HTTPTimeseriesGroupBrowserFamilyParamsDeviceTypeMobile, radar.HTTPTimeseriesGroupBrowserFamilyParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPTimeseriesGroupBrowserFamilyParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPTimeseriesGroupBrowserFamilyParamsHTTPProtocol{radar.HTTPTimeseriesGroupBrowserFamilyParamsHTTPProtocolHTTP, radar.HTTPTimeseriesGroupBrowserFamilyParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPTimeseriesGroupBrowserFamilyParamsHTTPVersion{radar.HTTPTimeseriesGroupBrowserFamilyParamsHTTPVersionHttPv1, radar.HTTPTimeseriesGroupBrowserFamilyParamsHTTPVersionHttPv2, radar.HTTPTimeseriesGroupBrowserFamilyParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPTimeseriesGroupBrowserFamilyParamsIPVersion{radar.HTTPTimeseriesGroupBrowserFamilyParamsIPVersionIPv4, radar.HTTPTimeseriesGroupBrowserFamilyParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPTimeseriesGroupBrowserFamilyParamsOS{radar.HTTPTimeseriesGroupBrowserFamilyParamsOSWindows, radar.HTTPTimeseriesGroupBrowserFamilyParamsOSMacosx, radar.HTTPTimeseriesGroupBrowserFamilyParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPTimeseriesGroupBrowserFamilyParamsTLSVersion{radar.HTTPTimeseriesGroupBrowserFamilyParamsTLSVersionTlSv1_0, radar.HTTPTimeseriesGroupBrowserFamilyParamsTLSVersionTlSv1_1, radar.HTTPTimeseriesGroupBrowserFamilyParamsTLSVersionTlSv1_2}), + }) + 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 TestHTTPTimeseriesGroupDeviceTypeWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.TimeseriesGroups.DeviceType(context.TODO(), radar.HTTPTimeseriesGroupDeviceTypeParams{ + AggInterval: cloudflare.F(radar.HTTPTimeseriesGroupDeviceTypeParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPTimeseriesGroupDeviceTypeParamsBotClass{radar.HTTPTimeseriesGroupDeviceTypeParamsBotClassLikelyAutomated, radar.HTTPTimeseriesGroupDeviceTypeParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPTimeseriesGroupDeviceTypeParamsDateRange{radar.HTTPTimeseriesGroupDeviceTypeParamsDateRange1d, radar.HTTPTimeseriesGroupDeviceTypeParamsDateRange2d, radar.HTTPTimeseriesGroupDeviceTypeParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.HTTPTimeseriesGroupDeviceTypeParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPTimeseriesGroupDeviceTypeParamsHTTPProtocol{radar.HTTPTimeseriesGroupDeviceTypeParamsHTTPProtocolHTTP, radar.HTTPTimeseriesGroupDeviceTypeParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPTimeseriesGroupDeviceTypeParamsHTTPVersion{radar.HTTPTimeseriesGroupDeviceTypeParamsHTTPVersionHttPv1, radar.HTTPTimeseriesGroupDeviceTypeParamsHTTPVersionHttPv2, radar.HTTPTimeseriesGroupDeviceTypeParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPTimeseriesGroupDeviceTypeParamsIPVersion{radar.HTTPTimeseriesGroupDeviceTypeParamsIPVersionIPv4, radar.HTTPTimeseriesGroupDeviceTypeParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPTimeseriesGroupDeviceTypeParamsOS{radar.HTTPTimeseriesGroupDeviceTypeParamsOSWindows, radar.HTTPTimeseriesGroupDeviceTypeParamsOSMacosx, radar.HTTPTimeseriesGroupDeviceTypeParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPTimeseriesGroupDeviceTypeParamsTLSVersion{radar.HTTPTimeseriesGroupDeviceTypeParamsTLSVersionTlSv1_0, radar.HTTPTimeseriesGroupDeviceTypeParamsTLSVersionTlSv1_1, radar.HTTPTimeseriesGroupDeviceTypeParamsTLSVersionTlSv1_2}), + }) + 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 TestHTTPTimeseriesGroupHTTPProtocolWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.TimeseriesGroups.HTTPProtocol(context.TODO(), radar.HTTPTimeseriesGroupHTTPProtocolParams{ + AggInterval: cloudflare.F(radar.HTTPTimeseriesGroupHTTPProtocolParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPTimeseriesGroupHTTPProtocolParamsBotClass{radar.HTTPTimeseriesGroupHTTPProtocolParamsBotClassLikelyAutomated, radar.HTTPTimeseriesGroupHTTPProtocolParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPTimeseriesGroupHTTPProtocolParamsDateRange{radar.HTTPTimeseriesGroupHTTPProtocolParamsDateRange1d, radar.HTTPTimeseriesGroupHTTPProtocolParamsDateRange2d, radar.HTTPTimeseriesGroupHTTPProtocolParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPTimeseriesGroupHTTPProtocolParamsDeviceType{radar.HTTPTimeseriesGroupHTTPProtocolParamsDeviceTypeDesktop, radar.HTTPTimeseriesGroupHTTPProtocolParamsDeviceTypeMobile, radar.HTTPTimeseriesGroupHTTPProtocolParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPTimeseriesGroupHTTPProtocolParamsFormatJson), + HTTPVersion: cloudflare.F([]radar.HTTPTimeseriesGroupHTTPProtocolParamsHTTPVersion{radar.HTTPTimeseriesGroupHTTPProtocolParamsHTTPVersionHttPv1, radar.HTTPTimeseriesGroupHTTPProtocolParamsHTTPVersionHttPv2, radar.HTTPTimeseriesGroupHTTPProtocolParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPTimeseriesGroupHTTPProtocolParamsIPVersion{radar.HTTPTimeseriesGroupHTTPProtocolParamsIPVersionIPv4, radar.HTTPTimeseriesGroupHTTPProtocolParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPTimeseriesGroupHTTPProtocolParamsOS{radar.HTTPTimeseriesGroupHTTPProtocolParamsOSWindows, radar.HTTPTimeseriesGroupHTTPProtocolParamsOSMacosx, radar.HTTPTimeseriesGroupHTTPProtocolParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPTimeseriesGroupHTTPProtocolParamsTLSVersion{radar.HTTPTimeseriesGroupHTTPProtocolParamsTLSVersionTlSv1_0, radar.HTTPTimeseriesGroupHTTPProtocolParamsTLSVersionTlSv1_1, radar.HTTPTimeseriesGroupHTTPProtocolParamsTLSVersionTlSv1_2}), + }) + 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 TestHTTPTimeseriesGroupHTTPVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.TimeseriesGroups.HTTPVersion(context.TODO(), radar.HTTPTimeseriesGroupHTTPVersionParams{ + AggInterval: cloudflare.F(radar.HTTPTimeseriesGroupHTTPVersionParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPTimeseriesGroupHTTPVersionParamsBotClass{radar.HTTPTimeseriesGroupHTTPVersionParamsBotClassLikelyAutomated, radar.HTTPTimeseriesGroupHTTPVersionParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPTimeseriesGroupHTTPVersionParamsDateRange{radar.HTTPTimeseriesGroupHTTPVersionParamsDateRange1d, radar.HTTPTimeseriesGroupHTTPVersionParamsDateRange2d, radar.HTTPTimeseriesGroupHTTPVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPTimeseriesGroupHTTPVersionParamsDeviceType{radar.HTTPTimeseriesGroupHTTPVersionParamsDeviceTypeDesktop, radar.HTTPTimeseriesGroupHTTPVersionParamsDeviceTypeMobile, radar.HTTPTimeseriesGroupHTTPVersionParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPTimeseriesGroupHTTPVersionParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPTimeseriesGroupHTTPVersionParamsHTTPProtocol{radar.HTTPTimeseriesGroupHTTPVersionParamsHTTPProtocolHTTP, radar.HTTPTimeseriesGroupHTTPVersionParamsHTTPProtocolHTTPS}), + IPVersion: cloudflare.F([]radar.HTTPTimeseriesGroupHTTPVersionParamsIPVersion{radar.HTTPTimeseriesGroupHTTPVersionParamsIPVersionIPv4, radar.HTTPTimeseriesGroupHTTPVersionParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPTimeseriesGroupHTTPVersionParamsOS{radar.HTTPTimeseriesGroupHTTPVersionParamsOSWindows, radar.HTTPTimeseriesGroupHTTPVersionParamsOSMacosx, radar.HTTPTimeseriesGroupHTTPVersionParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPTimeseriesGroupHTTPVersionParamsTLSVersion{radar.HTTPTimeseriesGroupHTTPVersionParamsTLSVersionTlSv1_0, radar.HTTPTimeseriesGroupHTTPVersionParamsTLSVersionTlSv1_1, radar.HTTPTimeseriesGroupHTTPVersionParamsTLSVersionTlSv1_2}), + }) + 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 TestHTTPTimeseriesGroupIPVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.TimeseriesGroups.IPVersion(context.TODO(), radar.HTTPTimeseriesGroupIPVersionParams{ + AggInterval: cloudflare.F(radar.HTTPTimeseriesGroupIPVersionParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPTimeseriesGroupIPVersionParamsBotClass{radar.HTTPTimeseriesGroupIPVersionParamsBotClassLikelyAutomated, radar.HTTPTimeseriesGroupIPVersionParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPTimeseriesGroupIPVersionParamsDateRange{radar.HTTPTimeseriesGroupIPVersionParamsDateRange1d, radar.HTTPTimeseriesGroupIPVersionParamsDateRange2d, radar.HTTPTimeseriesGroupIPVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPTimeseriesGroupIPVersionParamsDeviceType{radar.HTTPTimeseriesGroupIPVersionParamsDeviceTypeDesktop, radar.HTTPTimeseriesGroupIPVersionParamsDeviceTypeMobile, radar.HTTPTimeseriesGroupIPVersionParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPTimeseriesGroupIPVersionParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPTimeseriesGroupIPVersionParamsHTTPProtocol{radar.HTTPTimeseriesGroupIPVersionParamsHTTPProtocolHTTP, radar.HTTPTimeseriesGroupIPVersionParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPTimeseriesGroupIPVersionParamsHTTPVersion{radar.HTTPTimeseriesGroupIPVersionParamsHTTPVersionHttPv1, radar.HTTPTimeseriesGroupIPVersionParamsHTTPVersionHttPv2, radar.HTTPTimeseriesGroupIPVersionParamsHTTPVersionHttPv3}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPTimeseriesGroupIPVersionParamsOS{radar.HTTPTimeseriesGroupIPVersionParamsOSWindows, radar.HTTPTimeseriesGroupIPVersionParamsOSMacosx, radar.HTTPTimeseriesGroupIPVersionParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPTimeseriesGroupIPVersionParamsTLSVersion{radar.HTTPTimeseriesGroupIPVersionParamsTLSVersionTlSv1_0, radar.HTTPTimeseriesGroupIPVersionParamsTLSVersionTlSv1_1, radar.HTTPTimeseriesGroupIPVersionParamsTLSVersionTlSv1_2}), + }) + 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 TestHTTPTimeseriesGroupOSWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.TimeseriesGroups.OS(context.TODO(), radar.HTTPTimeseriesGroupOSParams{ + AggInterval: cloudflare.F(radar.HTTPTimeseriesGroupOSParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPTimeseriesGroupOSParamsBotClass{radar.HTTPTimeseriesGroupOSParamsBotClassLikelyAutomated, radar.HTTPTimeseriesGroupOSParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPTimeseriesGroupOSParamsDateRange{radar.HTTPTimeseriesGroupOSParamsDateRange1d, radar.HTTPTimeseriesGroupOSParamsDateRange2d, radar.HTTPTimeseriesGroupOSParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPTimeseriesGroupOSParamsDeviceType{radar.HTTPTimeseriesGroupOSParamsDeviceTypeDesktop, radar.HTTPTimeseriesGroupOSParamsDeviceTypeMobile, radar.HTTPTimeseriesGroupOSParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPTimeseriesGroupOSParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPTimeseriesGroupOSParamsHTTPProtocol{radar.HTTPTimeseriesGroupOSParamsHTTPProtocolHTTP, radar.HTTPTimeseriesGroupOSParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPTimeseriesGroupOSParamsHTTPVersion{radar.HTTPTimeseriesGroupOSParamsHTTPVersionHttPv1, radar.HTTPTimeseriesGroupOSParamsHTTPVersionHttPv2, radar.HTTPTimeseriesGroupOSParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPTimeseriesGroupOSParamsIPVersion{radar.HTTPTimeseriesGroupOSParamsIPVersionIPv4, radar.HTTPTimeseriesGroupOSParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + TLSVersion: cloudflare.F([]radar.HTTPTimeseriesGroupOSParamsTLSVersion{radar.HTTPTimeseriesGroupOSParamsTLSVersionTlSv1_0, radar.HTTPTimeseriesGroupOSParamsTLSVersionTlSv1_1, radar.HTTPTimeseriesGroupOSParamsTLSVersionTlSv1_2}), + }) + 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 TestHTTPTimeseriesGroupTLSVersionWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.TimeseriesGroups.TLSVersion(context.TODO(), radar.HTTPTimeseriesGroupTLSVersionParams{ + AggInterval: cloudflare.F(radar.HTTPTimeseriesGroupTLSVersionParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPTimeseriesGroupTLSVersionParamsBotClass{radar.HTTPTimeseriesGroupTLSVersionParamsBotClassLikelyAutomated, radar.HTTPTimeseriesGroupTLSVersionParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPTimeseriesGroupTLSVersionParamsDateRange{radar.HTTPTimeseriesGroupTLSVersionParamsDateRange1d, radar.HTTPTimeseriesGroupTLSVersionParamsDateRange2d, radar.HTTPTimeseriesGroupTLSVersionParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPTimeseriesGroupTLSVersionParamsDeviceType{radar.HTTPTimeseriesGroupTLSVersionParamsDeviceTypeDesktop, radar.HTTPTimeseriesGroupTLSVersionParamsDeviceTypeMobile, radar.HTTPTimeseriesGroupTLSVersionParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPTimeseriesGroupTLSVersionParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPTimeseriesGroupTLSVersionParamsHTTPProtocol{radar.HTTPTimeseriesGroupTLSVersionParamsHTTPProtocolHTTP, radar.HTTPTimeseriesGroupTLSVersionParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPTimeseriesGroupTLSVersionParamsHTTPVersion{radar.HTTPTimeseriesGroupTLSVersionParamsHTTPVersionHttPv1, radar.HTTPTimeseriesGroupTLSVersionParamsHTTPVersionHttPv2, radar.HTTPTimeseriesGroupTLSVersionParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPTimeseriesGroupTLSVersionParamsIPVersion{radar.HTTPTimeseriesGroupTLSVersionParamsIPVersionIPv4, radar.HTTPTimeseriesGroupTLSVersionParamsIPVersionIPv6}), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPTimeseriesGroupTLSVersionParamsOS{radar.HTTPTimeseriesGroupTLSVersionParamsOSWindows, radar.HTTPTimeseriesGroupTLSVersionParamsOSMacosx, radar.HTTPTimeseriesGroupTLSVersionParamsOSIos}), + }) + 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/radar/httptop.go b/radar/httptop.go new file mode 100644 index 00000000000..8b546e0818a --- /dev/null +++ b/radar/httptop.go @@ -0,0 +1,691 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HTTPTopService 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 [NewHTTPTopService] method instead. +type HTTPTopService struct { + Options []option.RequestOption +} + +// NewHTTPTopService 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 NewHTTPTopService(opts ...option.RequestOption) (r *HTTPTopService) { + r = &HTTPTopService{} + r.Options = opts + return +} + +// Get the top user agents aggregated in families by HTTP traffic. Values are a +// percentage out of the total traffic. +func (r *HTTPTopService) BrowserFamilies(ctx context.Context, query HTTPTopBrowserFamiliesParams, opts ...option.RequestOption) (res *HTTPTopBrowserFamiliesResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPTopBrowserFamiliesResponseEnvelope + path := "radar/http/top/browser_families" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the top user agents by HTTP traffic. Values are a percentage out of the +// total traffic. +func (r *HTTPTopService) Browsers(ctx context.Context, query HTTPTopBrowsersParams, opts ...option.RequestOption) (res *HTTPTopBrowsersResponse, err error) { + opts = append(r.Options[:], opts...) + var env HTTPTopBrowsersResponseEnvelope + path := "radar/http/top/browsers" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HTTPTopBrowserFamiliesResponse struct { + Meta HTTPTopBrowserFamiliesResponseMeta `json:"meta,required"` + Top0 []HTTPTopBrowserFamiliesResponseTop0 `json:"top_0,required"` + JSON httpTopBrowserFamiliesResponseJSON `json:"-"` +} + +// httpTopBrowserFamiliesResponseJSON contains the JSON metadata for the struct +// [HTTPTopBrowserFamiliesResponse] +type httpTopBrowserFamiliesResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTopBrowserFamiliesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTopBrowserFamiliesResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPTopBrowserFamiliesResponseMeta struct { + DateRange []HTTPTopBrowserFamiliesResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo HTTPTopBrowserFamiliesResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpTopBrowserFamiliesResponseMetaJSON `json:"-"` +} + +// httpTopBrowserFamiliesResponseMetaJSON contains the JSON metadata for the struct +// [HTTPTopBrowserFamiliesResponseMeta] +type httpTopBrowserFamiliesResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTopBrowserFamiliesResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTopBrowserFamiliesResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPTopBrowserFamiliesResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpTopBrowserFamiliesResponseMetaDateRangeJSON `json:"-"` +} + +// httpTopBrowserFamiliesResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [HTTPTopBrowserFamiliesResponseMetaDateRange] +type httpTopBrowserFamiliesResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTopBrowserFamiliesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTopBrowserFamiliesResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPTopBrowserFamiliesResponseMetaConfidenceInfo struct { + Annotations []HTTPTopBrowserFamiliesResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpTopBrowserFamiliesResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpTopBrowserFamiliesResponseMetaConfidenceInfoJSON contains the JSON metadata +// for the struct [HTTPTopBrowserFamiliesResponseMetaConfidenceInfo] +type httpTopBrowserFamiliesResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTopBrowserFamiliesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTopBrowserFamiliesResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPTopBrowserFamiliesResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpTopBrowserFamiliesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpTopBrowserFamiliesResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [HTTPTopBrowserFamiliesResponseMetaConfidenceInfoAnnotation] +type httpTopBrowserFamiliesResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTopBrowserFamiliesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTopBrowserFamiliesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPTopBrowserFamiliesResponseTop0 struct { + Name string `json:"name,required"` + Value string `json:"value,required"` + JSON httpTopBrowserFamiliesResponseTop0JSON `json:"-"` +} + +// httpTopBrowserFamiliesResponseTop0JSON contains the JSON metadata for the struct +// [HTTPTopBrowserFamiliesResponseTop0] +type httpTopBrowserFamiliesResponseTop0JSON struct { + Name apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTopBrowserFamiliesResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTopBrowserFamiliesResponseTop0JSON) RawJSON() string { + return r.raw +} + +type HTTPTopBrowsersResponse struct { + Meta HTTPTopBrowsersResponseMeta `json:"meta,required"` + Top0 []HTTPTopBrowsersResponseTop0 `json:"top_0,required"` + JSON httpTopBrowsersResponseJSON `json:"-"` +} + +// httpTopBrowsersResponseJSON contains the JSON metadata for the struct +// [HTTPTopBrowsersResponse] +type httpTopBrowsersResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTopBrowsersResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTopBrowsersResponseJSON) RawJSON() string { + return r.raw +} + +type HTTPTopBrowsersResponseMeta struct { + DateRange []HTTPTopBrowsersResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo HTTPTopBrowsersResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON httpTopBrowsersResponseMetaJSON `json:"-"` +} + +// httpTopBrowsersResponseMetaJSON contains the JSON metadata for the struct +// [HTTPTopBrowsersResponseMeta] +type httpTopBrowsersResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTopBrowsersResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTopBrowsersResponseMetaJSON) RawJSON() string { + return r.raw +} + +type HTTPTopBrowsersResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON httpTopBrowsersResponseMetaDateRangeJSON `json:"-"` +} + +// httpTopBrowsersResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [HTTPTopBrowsersResponseMetaDateRange] +type httpTopBrowsersResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTopBrowsersResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTopBrowsersResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type HTTPTopBrowsersResponseMetaConfidenceInfo struct { + Annotations []HTTPTopBrowsersResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON httpTopBrowsersResponseMetaConfidenceInfoJSON `json:"-"` +} + +// httpTopBrowsersResponseMetaConfidenceInfoJSON contains the JSON metadata for the +// struct [HTTPTopBrowsersResponseMetaConfidenceInfo] +type httpTopBrowsersResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTopBrowsersResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTopBrowsersResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type HTTPTopBrowsersResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON httpTopBrowsersResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// httpTopBrowsersResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct [HTTPTopBrowsersResponseMetaConfidenceInfoAnnotation] +type httpTopBrowsersResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTopBrowsersResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTopBrowsersResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type HTTPTopBrowsersResponseTop0 struct { + Name string `json:"name,required"` + Value string `json:"value,required"` + JSON httpTopBrowsersResponseTop0JSON `json:"-"` +} + +// httpTopBrowsersResponseTop0JSON contains the JSON metadata for the struct +// [HTTPTopBrowsersResponseTop0] +type httpTopBrowsersResponseTop0JSON struct { + Name apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTopBrowsersResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTopBrowsersResponseTop0JSON) RawJSON() string { + return r.raw +} + +type HTTPTopBrowserFamiliesParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPTopBrowserFamiliesParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPTopBrowserFamiliesParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPTopBrowserFamiliesParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPTopBrowserFamiliesParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPTopBrowserFamiliesParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPTopBrowserFamiliesParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPTopBrowserFamiliesParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPTopBrowserFamiliesParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPTopBrowserFamiliesParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPTopBrowserFamiliesParams]'s query parameters as +// `url.Values`. +func (r HTTPTopBrowserFamiliesParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type HTTPTopBrowserFamiliesParamsBotClass string + +const ( + HTTPTopBrowserFamiliesParamsBotClassLikelyAutomated HTTPTopBrowserFamiliesParamsBotClass = "LIKELY_AUTOMATED" + HTTPTopBrowserFamiliesParamsBotClassLikelyHuman HTTPTopBrowserFamiliesParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPTopBrowserFamiliesParamsDateRange string + +const ( + HTTPTopBrowserFamiliesParamsDateRange1d HTTPTopBrowserFamiliesParamsDateRange = "1d" + HTTPTopBrowserFamiliesParamsDateRange2d HTTPTopBrowserFamiliesParamsDateRange = "2d" + HTTPTopBrowserFamiliesParamsDateRange7d HTTPTopBrowserFamiliesParamsDateRange = "7d" + HTTPTopBrowserFamiliesParamsDateRange14d HTTPTopBrowserFamiliesParamsDateRange = "14d" + HTTPTopBrowserFamiliesParamsDateRange28d HTTPTopBrowserFamiliesParamsDateRange = "28d" + HTTPTopBrowserFamiliesParamsDateRange12w HTTPTopBrowserFamiliesParamsDateRange = "12w" + HTTPTopBrowserFamiliesParamsDateRange24w HTTPTopBrowserFamiliesParamsDateRange = "24w" + HTTPTopBrowserFamiliesParamsDateRange52w HTTPTopBrowserFamiliesParamsDateRange = "52w" + HTTPTopBrowserFamiliesParamsDateRange1dControl HTTPTopBrowserFamiliesParamsDateRange = "1dControl" + HTTPTopBrowserFamiliesParamsDateRange2dControl HTTPTopBrowserFamiliesParamsDateRange = "2dControl" + HTTPTopBrowserFamiliesParamsDateRange7dControl HTTPTopBrowserFamiliesParamsDateRange = "7dControl" + HTTPTopBrowserFamiliesParamsDateRange14dControl HTTPTopBrowserFamiliesParamsDateRange = "14dControl" + HTTPTopBrowserFamiliesParamsDateRange28dControl HTTPTopBrowserFamiliesParamsDateRange = "28dControl" + HTTPTopBrowserFamiliesParamsDateRange12wControl HTTPTopBrowserFamiliesParamsDateRange = "12wControl" + HTTPTopBrowserFamiliesParamsDateRange24wControl HTTPTopBrowserFamiliesParamsDateRange = "24wControl" +) + +type HTTPTopBrowserFamiliesParamsDeviceType string + +const ( + HTTPTopBrowserFamiliesParamsDeviceTypeDesktop HTTPTopBrowserFamiliesParamsDeviceType = "DESKTOP" + HTTPTopBrowserFamiliesParamsDeviceTypeMobile HTTPTopBrowserFamiliesParamsDeviceType = "MOBILE" + HTTPTopBrowserFamiliesParamsDeviceTypeOther HTTPTopBrowserFamiliesParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPTopBrowserFamiliesParamsFormat string + +const ( + HTTPTopBrowserFamiliesParamsFormatJson HTTPTopBrowserFamiliesParamsFormat = "JSON" + HTTPTopBrowserFamiliesParamsFormatCsv HTTPTopBrowserFamiliesParamsFormat = "CSV" +) + +type HTTPTopBrowserFamiliesParamsHTTPProtocol string + +const ( + HTTPTopBrowserFamiliesParamsHTTPProtocolHTTP HTTPTopBrowserFamiliesParamsHTTPProtocol = "HTTP" + HTTPTopBrowserFamiliesParamsHTTPProtocolHTTPS HTTPTopBrowserFamiliesParamsHTTPProtocol = "HTTPS" +) + +type HTTPTopBrowserFamiliesParamsHTTPVersion string + +const ( + HTTPTopBrowserFamiliesParamsHTTPVersionHttPv1 HTTPTopBrowserFamiliesParamsHTTPVersion = "HTTPv1" + HTTPTopBrowserFamiliesParamsHTTPVersionHttPv2 HTTPTopBrowserFamiliesParamsHTTPVersion = "HTTPv2" + HTTPTopBrowserFamiliesParamsHTTPVersionHttPv3 HTTPTopBrowserFamiliesParamsHTTPVersion = "HTTPv3" +) + +type HTTPTopBrowserFamiliesParamsIPVersion string + +const ( + HTTPTopBrowserFamiliesParamsIPVersionIPv4 HTTPTopBrowserFamiliesParamsIPVersion = "IPv4" + HTTPTopBrowserFamiliesParamsIPVersionIPv6 HTTPTopBrowserFamiliesParamsIPVersion = "IPv6" +) + +type HTTPTopBrowserFamiliesParamsOS string + +const ( + HTTPTopBrowserFamiliesParamsOSWindows HTTPTopBrowserFamiliesParamsOS = "WINDOWS" + HTTPTopBrowserFamiliesParamsOSMacosx HTTPTopBrowserFamiliesParamsOS = "MACOSX" + HTTPTopBrowserFamiliesParamsOSIos HTTPTopBrowserFamiliesParamsOS = "IOS" + HTTPTopBrowserFamiliesParamsOSAndroid HTTPTopBrowserFamiliesParamsOS = "ANDROID" + HTTPTopBrowserFamiliesParamsOSChromeos HTTPTopBrowserFamiliesParamsOS = "CHROMEOS" + HTTPTopBrowserFamiliesParamsOSLinux HTTPTopBrowserFamiliesParamsOS = "LINUX" + HTTPTopBrowserFamiliesParamsOSSmartTv HTTPTopBrowserFamiliesParamsOS = "SMART_TV" +) + +type HTTPTopBrowserFamiliesParamsTLSVersion string + +const ( + HTTPTopBrowserFamiliesParamsTLSVersionTlSv1_0 HTTPTopBrowserFamiliesParamsTLSVersion = "TLSv1_0" + HTTPTopBrowserFamiliesParamsTLSVersionTlSv1_1 HTTPTopBrowserFamiliesParamsTLSVersion = "TLSv1_1" + HTTPTopBrowserFamiliesParamsTLSVersionTlSv1_2 HTTPTopBrowserFamiliesParamsTLSVersion = "TLSv1_2" + HTTPTopBrowserFamiliesParamsTLSVersionTlSv1_3 HTTPTopBrowserFamiliesParamsTLSVersion = "TLSv1_3" + HTTPTopBrowserFamiliesParamsTLSVersionTlSvQuic HTTPTopBrowserFamiliesParamsTLSVersion = "TLSvQUIC" +) + +type HTTPTopBrowserFamiliesResponseEnvelope struct { + Result HTTPTopBrowserFamiliesResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpTopBrowserFamiliesResponseEnvelopeJSON `json:"-"` +} + +// httpTopBrowserFamiliesResponseEnvelopeJSON contains the JSON metadata for the +// struct [HTTPTopBrowserFamiliesResponseEnvelope] +type httpTopBrowserFamiliesResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTopBrowserFamiliesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTopBrowserFamiliesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HTTPTopBrowsersParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Filter for bot class. Refer to + // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). + BotClass param.Field[[]HTTPTopBrowsersParamsBotClass] `query:"botClass"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]HTTPTopBrowsersParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Filter for device type. + DeviceType param.Field[[]HTTPTopBrowsersParamsDeviceType] `query:"deviceType"` + // Format results are returned in. + Format param.Field[HTTPTopBrowsersParamsFormat] `query:"format"` + // Filter for http protocol. + HTTPProtocol param.Field[[]HTTPTopBrowsersParamsHTTPProtocol] `query:"httpProtocol"` + // Filter for http version. + HTTPVersion param.Field[[]HTTPTopBrowsersParamsHTTPVersion] `query:"httpVersion"` + // Filter for ip version. + IPVersion param.Field[[]HTTPTopBrowsersParamsIPVersion] `query:"ipVersion"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Filter for os name. + OS param.Field[[]HTTPTopBrowsersParamsOS] `query:"os"` + // Filter for tls version. + TLSVersion param.Field[[]HTTPTopBrowsersParamsTLSVersion] `query:"tlsVersion"` +} + +// URLQuery serializes [HTTPTopBrowsersParams]'s query parameters as `url.Values`. +func (r HTTPTopBrowsersParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type HTTPTopBrowsersParamsBotClass string + +const ( + HTTPTopBrowsersParamsBotClassLikelyAutomated HTTPTopBrowsersParamsBotClass = "LIKELY_AUTOMATED" + HTTPTopBrowsersParamsBotClassLikelyHuman HTTPTopBrowsersParamsBotClass = "LIKELY_HUMAN" +) + +type HTTPTopBrowsersParamsDateRange string + +const ( + HTTPTopBrowsersParamsDateRange1d HTTPTopBrowsersParamsDateRange = "1d" + HTTPTopBrowsersParamsDateRange2d HTTPTopBrowsersParamsDateRange = "2d" + HTTPTopBrowsersParamsDateRange7d HTTPTopBrowsersParamsDateRange = "7d" + HTTPTopBrowsersParamsDateRange14d HTTPTopBrowsersParamsDateRange = "14d" + HTTPTopBrowsersParamsDateRange28d HTTPTopBrowsersParamsDateRange = "28d" + HTTPTopBrowsersParamsDateRange12w HTTPTopBrowsersParamsDateRange = "12w" + HTTPTopBrowsersParamsDateRange24w HTTPTopBrowsersParamsDateRange = "24w" + HTTPTopBrowsersParamsDateRange52w HTTPTopBrowsersParamsDateRange = "52w" + HTTPTopBrowsersParamsDateRange1dControl HTTPTopBrowsersParamsDateRange = "1dControl" + HTTPTopBrowsersParamsDateRange2dControl HTTPTopBrowsersParamsDateRange = "2dControl" + HTTPTopBrowsersParamsDateRange7dControl HTTPTopBrowsersParamsDateRange = "7dControl" + HTTPTopBrowsersParamsDateRange14dControl HTTPTopBrowsersParamsDateRange = "14dControl" + HTTPTopBrowsersParamsDateRange28dControl HTTPTopBrowsersParamsDateRange = "28dControl" + HTTPTopBrowsersParamsDateRange12wControl HTTPTopBrowsersParamsDateRange = "12wControl" + HTTPTopBrowsersParamsDateRange24wControl HTTPTopBrowsersParamsDateRange = "24wControl" +) + +type HTTPTopBrowsersParamsDeviceType string + +const ( + HTTPTopBrowsersParamsDeviceTypeDesktop HTTPTopBrowsersParamsDeviceType = "DESKTOP" + HTTPTopBrowsersParamsDeviceTypeMobile HTTPTopBrowsersParamsDeviceType = "MOBILE" + HTTPTopBrowsersParamsDeviceTypeOther HTTPTopBrowsersParamsDeviceType = "OTHER" +) + +// Format results are returned in. +type HTTPTopBrowsersParamsFormat string + +const ( + HTTPTopBrowsersParamsFormatJson HTTPTopBrowsersParamsFormat = "JSON" + HTTPTopBrowsersParamsFormatCsv HTTPTopBrowsersParamsFormat = "CSV" +) + +type HTTPTopBrowsersParamsHTTPProtocol string + +const ( + HTTPTopBrowsersParamsHTTPProtocolHTTP HTTPTopBrowsersParamsHTTPProtocol = "HTTP" + HTTPTopBrowsersParamsHTTPProtocolHTTPS HTTPTopBrowsersParamsHTTPProtocol = "HTTPS" +) + +type HTTPTopBrowsersParamsHTTPVersion string + +const ( + HTTPTopBrowsersParamsHTTPVersionHttPv1 HTTPTopBrowsersParamsHTTPVersion = "HTTPv1" + HTTPTopBrowsersParamsHTTPVersionHttPv2 HTTPTopBrowsersParamsHTTPVersion = "HTTPv2" + HTTPTopBrowsersParamsHTTPVersionHttPv3 HTTPTopBrowsersParamsHTTPVersion = "HTTPv3" +) + +type HTTPTopBrowsersParamsIPVersion string + +const ( + HTTPTopBrowsersParamsIPVersionIPv4 HTTPTopBrowsersParamsIPVersion = "IPv4" + HTTPTopBrowsersParamsIPVersionIPv6 HTTPTopBrowsersParamsIPVersion = "IPv6" +) + +type HTTPTopBrowsersParamsOS string + +const ( + HTTPTopBrowsersParamsOSWindows HTTPTopBrowsersParamsOS = "WINDOWS" + HTTPTopBrowsersParamsOSMacosx HTTPTopBrowsersParamsOS = "MACOSX" + HTTPTopBrowsersParamsOSIos HTTPTopBrowsersParamsOS = "IOS" + HTTPTopBrowsersParamsOSAndroid HTTPTopBrowsersParamsOS = "ANDROID" + HTTPTopBrowsersParamsOSChromeos HTTPTopBrowsersParamsOS = "CHROMEOS" + HTTPTopBrowsersParamsOSLinux HTTPTopBrowsersParamsOS = "LINUX" + HTTPTopBrowsersParamsOSSmartTv HTTPTopBrowsersParamsOS = "SMART_TV" +) + +type HTTPTopBrowsersParamsTLSVersion string + +const ( + HTTPTopBrowsersParamsTLSVersionTlSv1_0 HTTPTopBrowsersParamsTLSVersion = "TLSv1_0" + HTTPTopBrowsersParamsTLSVersionTlSv1_1 HTTPTopBrowsersParamsTLSVersion = "TLSv1_1" + HTTPTopBrowsersParamsTLSVersionTlSv1_2 HTTPTopBrowsersParamsTLSVersion = "TLSv1_2" + HTTPTopBrowsersParamsTLSVersionTlSv1_3 HTTPTopBrowsersParamsTLSVersion = "TLSv1_3" + HTTPTopBrowsersParamsTLSVersionTlSvQuic HTTPTopBrowsersParamsTLSVersion = "TLSvQUIC" +) + +type HTTPTopBrowsersResponseEnvelope struct { + Result HTTPTopBrowsersResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON httpTopBrowsersResponseEnvelopeJSON `json:"-"` +} + +// httpTopBrowsersResponseEnvelopeJSON contains the JSON metadata for the struct +// [HTTPTopBrowsersResponseEnvelope] +type httpTopBrowsersResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HTTPTopBrowsersResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r httpTopBrowsersResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/httptop_test.go b/radar/httptop_test.go new file mode 100644 index 00000000000..9f7d1d150d7 --- /dev/null +++ b/radar/httptop_test.go @@ -0,0 +1,98 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestHTTPTopBrowserFamiliesWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Top.BrowserFamilies(context.TODO(), radar.HTTPTopBrowserFamiliesParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPTopBrowserFamiliesParamsBotClass{radar.HTTPTopBrowserFamiliesParamsBotClassLikelyAutomated, radar.HTTPTopBrowserFamiliesParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPTopBrowserFamiliesParamsDateRange{radar.HTTPTopBrowserFamiliesParamsDateRange1d, radar.HTTPTopBrowserFamiliesParamsDateRange2d, radar.HTTPTopBrowserFamiliesParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPTopBrowserFamiliesParamsDeviceType{radar.HTTPTopBrowserFamiliesParamsDeviceTypeDesktop, radar.HTTPTopBrowserFamiliesParamsDeviceTypeMobile, radar.HTTPTopBrowserFamiliesParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPTopBrowserFamiliesParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPTopBrowserFamiliesParamsHTTPProtocol{radar.HTTPTopBrowserFamiliesParamsHTTPProtocolHTTP, radar.HTTPTopBrowserFamiliesParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPTopBrowserFamiliesParamsHTTPVersion{radar.HTTPTopBrowserFamiliesParamsHTTPVersionHttPv1, radar.HTTPTopBrowserFamiliesParamsHTTPVersionHttPv2, radar.HTTPTopBrowserFamiliesParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPTopBrowserFamiliesParamsIPVersion{radar.HTTPTopBrowserFamiliesParamsIPVersionIPv4, radar.HTTPTopBrowserFamiliesParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPTopBrowserFamiliesParamsOS{radar.HTTPTopBrowserFamiliesParamsOSWindows, radar.HTTPTopBrowserFamiliesParamsOSMacosx, radar.HTTPTopBrowserFamiliesParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPTopBrowserFamiliesParamsTLSVersion{radar.HTTPTopBrowserFamiliesParamsTLSVersionTlSv1_0, radar.HTTPTopBrowserFamiliesParamsTLSVersionTlSv1_1, radar.HTTPTopBrowserFamiliesParamsTLSVersionTlSv1_2}), + }) + 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 TestHTTPTopBrowsersWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.HTTP.Top.Browsers(context.TODO(), radar.HTTPTopBrowsersParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BotClass: cloudflare.F([]radar.HTTPTopBrowsersParamsBotClass{radar.HTTPTopBrowsersParamsBotClassLikelyAutomated, radar.HTTPTopBrowsersParamsBotClassLikelyHuman}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.HTTPTopBrowsersParamsDateRange{radar.HTTPTopBrowsersParamsDateRange1d, radar.HTTPTopBrowsersParamsDateRange2d, radar.HTTPTopBrowsersParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DeviceType: cloudflare.F([]radar.HTTPTopBrowsersParamsDeviceType{radar.HTTPTopBrowsersParamsDeviceTypeDesktop, radar.HTTPTopBrowsersParamsDeviceTypeMobile, radar.HTTPTopBrowsersParamsDeviceTypeOther}), + Format: cloudflare.F(radar.HTTPTopBrowsersParamsFormatJson), + HTTPProtocol: cloudflare.F([]radar.HTTPTopBrowsersParamsHTTPProtocol{radar.HTTPTopBrowsersParamsHTTPProtocolHTTP, radar.HTTPTopBrowsersParamsHTTPProtocolHTTPS}), + HTTPVersion: cloudflare.F([]radar.HTTPTopBrowsersParamsHTTPVersion{radar.HTTPTopBrowsersParamsHTTPVersionHttPv1, radar.HTTPTopBrowsersParamsHTTPVersionHttPv2, radar.HTTPTopBrowsersParamsHTTPVersionHttPv3}), + IPVersion: cloudflare.F([]radar.HTTPTopBrowsersParamsIPVersion{radar.HTTPTopBrowsersParamsIPVersionIPv4, radar.HTTPTopBrowsersParamsIPVersionIPv6}), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OS: cloudflare.F([]radar.HTTPTopBrowsersParamsOS{radar.HTTPTopBrowsersParamsOSWindows, radar.HTTPTopBrowsersParamsOSMacosx, radar.HTTPTopBrowsersParamsOSIos}), + TLSVersion: cloudflare.F([]radar.HTTPTopBrowsersParamsTLSVersion{radar.HTTPTopBrowsersParamsTLSVersionTlSv1_0, radar.HTTPTopBrowsersParamsTLSVersionTlSv1_1, radar.HTTPTopBrowsersParamsTLSVersionTlSv1_2}), + }) + 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/radar/netflow.go b/radar/netflow.go new file mode 100644 index 00000000000..eb30ccb3871 --- /dev/null +++ b/radar/netflow.go @@ -0,0 +1,327 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// NetflowService 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 [NewNetflowService] method instead. +type NetflowService struct { + Options []option.RequestOption + Top *NetflowTopService +} + +// NewNetflowService 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 NewNetflowService(opts ...option.RequestOption) (r *NetflowService) { + r = &NetflowService{} + r.Options = opts + r.Top = NewNetflowTopService(opts...) + return +} + +// Get network traffic change over time. Visit +// https://en.wikipedia.org/wiki/NetFlow for more information on NetFlows. +func (r *NetflowService) Timeseries(ctx context.Context, query NetflowTimeseriesParams, opts ...option.RequestOption) (res *NetflowTimeseriesResponse, err error) { + opts = append(r.Options[:], opts...) + var env NetflowTimeseriesResponseEnvelope + path := "radar/netflows/timeseries" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type NetflowTimeseriesResponse struct { + Meta NetflowTimeseriesResponseMeta `json:"meta,required"` + Serie0 NetflowTimeseriesResponseSerie0 `json:"serie_0,required"` + JSON netflowTimeseriesResponseJSON `json:"-"` +} + +// netflowTimeseriesResponseJSON contains the JSON metadata for the struct +// [NetflowTimeseriesResponse] +type netflowTimeseriesResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetflowTimeseriesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r netflowTimeseriesResponseJSON) RawJSON() string { + return r.raw +} + +type NetflowTimeseriesResponseMeta struct { + AggInterval string `json:"aggInterval,required"` + DateRange []NetflowTimeseriesResponseMetaDateRange `json:"dateRange,required"` + LastUpdated time.Time `json:"lastUpdated,required" format:"date-time"` + ConfidenceInfo NetflowTimeseriesResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON netflowTimeseriesResponseMetaJSON `json:"-"` +} + +// netflowTimeseriesResponseMetaJSON contains the JSON metadata for the struct +// [NetflowTimeseriesResponseMeta] +type netflowTimeseriesResponseMetaJSON struct { + AggInterval apijson.Field + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetflowTimeseriesResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r netflowTimeseriesResponseMetaJSON) RawJSON() string { + return r.raw +} + +type NetflowTimeseriesResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON netflowTimeseriesResponseMetaDateRangeJSON `json:"-"` +} + +// netflowTimeseriesResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [NetflowTimeseriesResponseMetaDateRange] +type netflowTimeseriesResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetflowTimeseriesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r netflowTimeseriesResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type NetflowTimeseriesResponseMetaConfidenceInfo struct { + Annotations []NetflowTimeseriesResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON netflowTimeseriesResponseMetaConfidenceInfoJSON `json:"-"` +} + +// netflowTimeseriesResponseMetaConfidenceInfoJSON contains the JSON metadata for +// the struct [NetflowTimeseriesResponseMetaConfidenceInfo] +type netflowTimeseriesResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetflowTimeseriesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r netflowTimeseriesResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type NetflowTimeseriesResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON netflowTimeseriesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// netflowTimeseriesResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct [NetflowTimeseriesResponseMetaConfidenceInfoAnnotation] +type netflowTimeseriesResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetflowTimeseriesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r netflowTimeseriesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type NetflowTimeseriesResponseSerie0 struct { + Timestamps []time.Time `json:"timestamps,required" format:"date-time"` + Values []string `json:"values,required"` + JSON netflowTimeseriesResponseSerie0JSON `json:"-"` +} + +// netflowTimeseriesResponseSerie0JSON contains the JSON metadata for the struct +// [NetflowTimeseriesResponseSerie0] +type netflowTimeseriesResponseSerie0JSON struct { + Timestamps apijson.Field + Values apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetflowTimeseriesResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r netflowTimeseriesResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type NetflowTimeseriesParams struct { + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[NetflowTimeseriesParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]NetflowTimeseriesParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[NetflowTimeseriesParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Normalization method applied. Refer to + // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). + Normalization param.Field[NetflowTimeseriesParamsNormalization] `query:"normalization"` + // Array of network traffic product types. + Product param.Field[[]NetflowTimeseriesParamsProduct] `query:"product"` +} + +// URLQuery serializes [NetflowTimeseriesParams]'s query parameters as +// `url.Values`. +func (r NetflowTimeseriesParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type NetflowTimeseriesParamsAggInterval string + +const ( + NetflowTimeseriesParamsAggInterval15m NetflowTimeseriesParamsAggInterval = "15m" + NetflowTimeseriesParamsAggInterval1h NetflowTimeseriesParamsAggInterval = "1h" + NetflowTimeseriesParamsAggInterval1d NetflowTimeseriesParamsAggInterval = "1d" + NetflowTimeseriesParamsAggInterval1w NetflowTimeseriesParamsAggInterval = "1w" +) + +type NetflowTimeseriesParamsDateRange string + +const ( + NetflowTimeseriesParamsDateRange1d NetflowTimeseriesParamsDateRange = "1d" + NetflowTimeseriesParamsDateRange2d NetflowTimeseriesParamsDateRange = "2d" + NetflowTimeseriesParamsDateRange7d NetflowTimeseriesParamsDateRange = "7d" + NetflowTimeseriesParamsDateRange14d NetflowTimeseriesParamsDateRange = "14d" + NetflowTimeseriesParamsDateRange28d NetflowTimeseriesParamsDateRange = "28d" + NetflowTimeseriesParamsDateRange12w NetflowTimeseriesParamsDateRange = "12w" + NetflowTimeseriesParamsDateRange24w NetflowTimeseriesParamsDateRange = "24w" + NetflowTimeseriesParamsDateRange52w NetflowTimeseriesParamsDateRange = "52w" + NetflowTimeseriesParamsDateRange1dControl NetflowTimeseriesParamsDateRange = "1dControl" + NetflowTimeseriesParamsDateRange2dControl NetflowTimeseriesParamsDateRange = "2dControl" + NetflowTimeseriesParamsDateRange7dControl NetflowTimeseriesParamsDateRange = "7dControl" + NetflowTimeseriesParamsDateRange14dControl NetflowTimeseriesParamsDateRange = "14dControl" + NetflowTimeseriesParamsDateRange28dControl NetflowTimeseriesParamsDateRange = "28dControl" + NetflowTimeseriesParamsDateRange12wControl NetflowTimeseriesParamsDateRange = "12wControl" + NetflowTimeseriesParamsDateRange24wControl NetflowTimeseriesParamsDateRange = "24wControl" +) + +// Format results are returned in. +type NetflowTimeseriesParamsFormat string + +const ( + NetflowTimeseriesParamsFormatJson NetflowTimeseriesParamsFormat = "JSON" + NetflowTimeseriesParamsFormatCsv NetflowTimeseriesParamsFormat = "CSV" +) + +// Normalization method applied. Refer to +// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). +type NetflowTimeseriesParamsNormalization string + +const ( + NetflowTimeseriesParamsNormalizationPercentageChange NetflowTimeseriesParamsNormalization = "PERCENTAGE_CHANGE" + NetflowTimeseriesParamsNormalizationMin0Max NetflowTimeseriesParamsNormalization = "MIN0_MAX" +) + +type NetflowTimeseriesParamsProduct string + +const ( + NetflowTimeseriesParamsProductHTTP NetflowTimeseriesParamsProduct = "HTTP" + NetflowTimeseriesParamsProductAll NetflowTimeseriesParamsProduct = "ALL" +) + +type NetflowTimeseriesResponseEnvelope struct { + Result NetflowTimeseriesResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON netflowTimeseriesResponseEnvelopeJSON `json:"-"` +} + +// netflowTimeseriesResponseEnvelopeJSON contains the JSON metadata for the struct +// [NetflowTimeseriesResponseEnvelope] +type netflowTimeseriesResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetflowTimeseriesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r netflowTimeseriesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/netflow_test.go b/radar/netflow_test.go new file mode 100644 index 00000000000..01a990bd25c --- /dev/null +++ b/radar/netflow_test.go @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestNetflowTimeseriesWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Netflows.Timeseries(context.TODO(), radar.NetflowTimeseriesParams{ + AggInterval: cloudflare.F(radar.NetflowTimeseriesParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.NetflowTimeseriesParamsDateRange{radar.NetflowTimeseriesParamsDateRange1d, radar.NetflowTimeseriesParamsDateRange2d, radar.NetflowTimeseriesParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.NetflowTimeseriesParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + Normalization: cloudflare.F(radar.NetflowTimeseriesParamsNormalizationMin0Max), + Product: cloudflare.F([]radar.NetflowTimeseriesParamsProduct{radar.NetflowTimeseriesParamsProductHTTP, radar.NetflowTimeseriesParamsProductAll}), + }) + 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/radar/netflowtop.go b/radar/netflowtop.go new file mode 100644 index 00000000000..c8b9ce538c6 --- /dev/null +++ b/radar/netflowtop.go @@ -0,0 +1,330 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// NetflowTopService 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 [NewNetflowTopService] method instead. +type NetflowTopService struct { + Options []option.RequestOption +} + +// NewNetflowTopService 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 NewNetflowTopService(opts ...option.RequestOption) (r *NetflowTopService) { + r = &NetflowTopService{} + r.Options = opts + return +} + +// Get the top autonomous systems (AS) by network traffic (NetFlows) over a given +// time period. Visit https://en.wikipedia.org/wiki/NetFlow for more information. +func (r *NetflowTopService) Ases(ctx context.Context, query NetflowTopAsesParams, opts ...option.RequestOption) (res *NetflowTopAsesResponse, err error) { + opts = append(r.Options[:], opts...) + var env NetflowTopAsesResponseEnvelope + path := "radar/netflows/top/ases" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the top locations by network traffic (NetFlows) over a given time period. +// Visit https://en.wikipedia.org/wiki/NetFlow for more information. +func (r *NetflowTopService) Locations(ctx context.Context, query NetflowTopLocationsParams, opts ...option.RequestOption) (res *NetflowTopLocationsResponse, err error) { + opts = append(r.Options[:], opts...) + var env NetflowTopLocationsResponseEnvelope + path := "radar/netflows/top/locations" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type NetflowTopAsesResponse struct { + Top0 []NetflowTopAsesResponseTop0 `json:"top_0,required"` + JSON netflowTopAsesResponseJSON `json:"-"` +} + +// netflowTopAsesResponseJSON contains the JSON metadata for the struct +// [NetflowTopAsesResponse] +type netflowTopAsesResponseJSON struct { + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetflowTopAsesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r netflowTopAsesResponseJSON) RawJSON() string { + return r.raw +} + +type NetflowTopAsesResponseTop0 struct { + ClientASN float64 `json:"clientASN,required"` + ClientAsName string `json:"clientASName,required"` + Value string `json:"value,required"` + JSON netflowTopAsesResponseTop0JSON `json:"-"` +} + +// netflowTopAsesResponseTop0JSON contains the JSON metadata for the struct +// [NetflowTopAsesResponseTop0] +type netflowTopAsesResponseTop0JSON struct { + ClientASN apijson.Field + ClientAsName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetflowTopAsesResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r netflowTopAsesResponseTop0JSON) RawJSON() string { + return r.raw +} + +type NetflowTopLocationsResponse struct { + Top0 []NetflowTopLocationsResponseTop0 `json:"top_0,required"` + JSON netflowTopLocationsResponseJSON `json:"-"` +} + +// netflowTopLocationsResponseJSON contains the JSON metadata for the struct +// [NetflowTopLocationsResponse] +type netflowTopLocationsResponseJSON struct { + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetflowTopLocationsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r netflowTopLocationsResponseJSON) RawJSON() string { + return r.raw +} + +type NetflowTopLocationsResponseTop0 struct { + ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` + ClientCountryName string `json:"clientCountryName,required"` + Value string `json:"value,required"` + JSON netflowTopLocationsResponseTop0JSON `json:"-"` +} + +// netflowTopLocationsResponseTop0JSON contains the JSON metadata for the struct +// [NetflowTopLocationsResponseTop0] +type netflowTopLocationsResponseTop0JSON struct { + ClientCountryAlpha2 apijson.Field + ClientCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetflowTopLocationsResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r netflowTopLocationsResponseTop0JSON) RawJSON() string { + return r.raw +} + +type NetflowTopAsesParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]NetflowTopAsesParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[NetflowTopAsesParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [NetflowTopAsesParams]'s query parameters as `url.Values`. +func (r NetflowTopAsesParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type NetflowTopAsesParamsDateRange string + +const ( + NetflowTopAsesParamsDateRange1d NetflowTopAsesParamsDateRange = "1d" + NetflowTopAsesParamsDateRange2d NetflowTopAsesParamsDateRange = "2d" + NetflowTopAsesParamsDateRange7d NetflowTopAsesParamsDateRange = "7d" + NetflowTopAsesParamsDateRange14d NetflowTopAsesParamsDateRange = "14d" + NetflowTopAsesParamsDateRange28d NetflowTopAsesParamsDateRange = "28d" + NetflowTopAsesParamsDateRange12w NetflowTopAsesParamsDateRange = "12w" + NetflowTopAsesParamsDateRange24w NetflowTopAsesParamsDateRange = "24w" + NetflowTopAsesParamsDateRange52w NetflowTopAsesParamsDateRange = "52w" + NetflowTopAsesParamsDateRange1dControl NetflowTopAsesParamsDateRange = "1dControl" + NetflowTopAsesParamsDateRange2dControl NetflowTopAsesParamsDateRange = "2dControl" + NetflowTopAsesParamsDateRange7dControl NetflowTopAsesParamsDateRange = "7dControl" + NetflowTopAsesParamsDateRange14dControl NetflowTopAsesParamsDateRange = "14dControl" + NetflowTopAsesParamsDateRange28dControl NetflowTopAsesParamsDateRange = "28dControl" + NetflowTopAsesParamsDateRange12wControl NetflowTopAsesParamsDateRange = "12wControl" + NetflowTopAsesParamsDateRange24wControl NetflowTopAsesParamsDateRange = "24wControl" +) + +// Format results are returned in. +type NetflowTopAsesParamsFormat string + +const ( + NetflowTopAsesParamsFormatJson NetflowTopAsesParamsFormat = "JSON" + NetflowTopAsesParamsFormatCsv NetflowTopAsesParamsFormat = "CSV" +) + +type NetflowTopAsesResponseEnvelope struct { + Result NetflowTopAsesResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON netflowTopAsesResponseEnvelopeJSON `json:"-"` +} + +// netflowTopAsesResponseEnvelopeJSON contains the JSON metadata for the struct +// [NetflowTopAsesResponseEnvelope] +type netflowTopAsesResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetflowTopAsesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r netflowTopAsesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NetflowTopLocationsParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]NetflowTopLocationsParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[NetflowTopLocationsParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [NetflowTopLocationsParams]'s query parameters as +// `url.Values`. +func (r NetflowTopLocationsParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type NetflowTopLocationsParamsDateRange string + +const ( + NetflowTopLocationsParamsDateRange1d NetflowTopLocationsParamsDateRange = "1d" + NetflowTopLocationsParamsDateRange2d NetflowTopLocationsParamsDateRange = "2d" + NetflowTopLocationsParamsDateRange7d NetflowTopLocationsParamsDateRange = "7d" + NetflowTopLocationsParamsDateRange14d NetflowTopLocationsParamsDateRange = "14d" + NetflowTopLocationsParamsDateRange28d NetflowTopLocationsParamsDateRange = "28d" + NetflowTopLocationsParamsDateRange12w NetflowTopLocationsParamsDateRange = "12w" + NetflowTopLocationsParamsDateRange24w NetflowTopLocationsParamsDateRange = "24w" + NetflowTopLocationsParamsDateRange52w NetflowTopLocationsParamsDateRange = "52w" + NetflowTopLocationsParamsDateRange1dControl NetflowTopLocationsParamsDateRange = "1dControl" + NetflowTopLocationsParamsDateRange2dControl NetflowTopLocationsParamsDateRange = "2dControl" + NetflowTopLocationsParamsDateRange7dControl NetflowTopLocationsParamsDateRange = "7dControl" + NetflowTopLocationsParamsDateRange14dControl NetflowTopLocationsParamsDateRange = "14dControl" + NetflowTopLocationsParamsDateRange28dControl NetflowTopLocationsParamsDateRange = "28dControl" + NetflowTopLocationsParamsDateRange12wControl NetflowTopLocationsParamsDateRange = "12wControl" + NetflowTopLocationsParamsDateRange24wControl NetflowTopLocationsParamsDateRange = "24wControl" +) + +// Format results are returned in. +type NetflowTopLocationsParamsFormat string + +const ( + NetflowTopLocationsParamsFormatJson NetflowTopLocationsParamsFormat = "JSON" + NetflowTopLocationsParamsFormatCsv NetflowTopLocationsParamsFormat = "CSV" +) + +type NetflowTopLocationsResponseEnvelope struct { + Result NetflowTopLocationsResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON netflowTopLocationsResponseEnvelopeJSON `json:"-"` +} + +// netflowTopLocationsResponseEnvelopeJSON contains the JSON metadata for the +// struct [NetflowTopLocationsResponseEnvelope] +type netflowTopLocationsResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetflowTopLocationsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r netflowTopLocationsResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/netflowtop_test.go b/radar/netflowtop_test.go new file mode 100644 index 00000000000..621039c6d21 --- /dev/null +++ b/radar/netflowtop_test.go @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestNetflowTopAsesWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Netflows.Top.Ases(context.TODO(), radar.NetflowTopAsesParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.NetflowTopAsesParamsDateRange{radar.NetflowTopAsesParamsDateRange1d, radar.NetflowTopAsesParamsDateRange2d, radar.NetflowTopAsesParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.NetflowTopAsesParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestNetflowTopLocationsWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Netflows.Top.Locations(context.TODO(), radar.NetflowTopLocationsParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.NetflowTopLocationsParamsDateRange{radar.NetflowTopLocationsParamsDateRange1d, radar.NetflowTopLocationsParamsDateRange2d, radar.NetflowTopLocationsParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.NetflowTopLocationsParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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/radar/quality.go b/radar/quality.go new file mode 100644 index 00000000000..18fdb1d7fa4 --- /dev/null +++ b/radar/quality.go @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// QualityService 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 [NewQualityService] method instead. +type QualityService struct { + Options []option.RequestOption + IQI *QualityIQIService + Speed *QualitySpeedService +} + +// NewQualityService 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 NewQualityService(opts ...option.RequestOption) (r *QualityService) { + r = &QualityService{} + r.Options = opts + r.IQI = NewQualityIQIService(opts...) + r.Speed = NewQualitySpeedService(opts...) + return +} diff --git a/radar/qualityiqi.go b/radar/qualityiqi.go new file mode 100644 index 00000000000..a4e5518bf65 --- /dev/null +++ b/radar/qualityiqi.go @@ -0,0 +1,481 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// QualityIQIService 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 [NewQualityIQIService] method instead. +type QualityIQIService struct { + Options []option.RequestOption +} + +// NewQualityIQIService 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 NewQualityIQIService(opts ...option.RequestOption) (r *QualityIQIService) { + r = &QualityIQIService{} + r.Options = opts + return +} + +// Get a summary (percentiles) of bandwidth, latency or DNS response time from the +// Radar Internet Quality Index (IQI). +func (r *QualityIQIService) Summary(ctx context.Context, query QualityIQISummaryParams, opts ...option.RequestOption) (res *QualityIQISummaryResponse, err error) { + opts = append(r.Options[:], opts...) + var env QualityIQISummaryResponseEnvelope + path := "radar/quality/iqi/summary" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a time series (percentiles) of bandwidth, latency or DNS response time from +// the Radar Internet Quality Index (IQI). +func (r *QualityIQIService) TimeseriesGroups(ctx context.Context, query QualityIQITimeseriesGroupsParams, opts ...option.RequestOption) (res *QualityIQITimeseriesGroupsResponse, err error) { + opts = append(r.Options[:], opts...) + var env QualityIQITimeseriesGroupsResponseEnvelope + path := "radar/quality/iqi/timeseries_groups" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type QualityIQISummaryResponse struct { + Meta QualityIQISummaryResponseMeta `json:"meta,required"` + Summary0 QualityIQISummaryResponseSummary0 `json:"summary_0,required"` + JSON qualityIQISummaryResponseJSON `json:"-"` +} + +// qualityIQISummaryResponseJSON contains the JSON metadata for the struct +// [QualityIQISummaryResponse] +type qualityIQISummaryResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualityIQISummaryResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualityIQISummaryResponseJSON) RawJSON() string { + return r.raw +} + +type QualityIQISummaryResponseMeta struct { + DateRange []QualityIQISummaryResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo QualityIQISummaryResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON qualityIQISummaryResponseMetaJSON `json:"-"` +} + +// qualityIQISummaryResponseMetaJSON contains the JSON metadata for the struct +// [QualityIQISummaryResponseMeta] +type qualityIQISummaryResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualityIQISummaryResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualityIQISummaryResponseMetaJSON) RawJSON() string { + return r.raw +} + +type QualityIQISummaryResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON qualityIQISummaryResponseMetaDateRangeJSON `json:"-"` +} + +// qualityIQISummaryResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [QualityIQISummaryResponseMetaDateRange] +type qualityIQISummaryResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualityIQISummaryResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualityIQISummaryResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type QualityIQISummaryResponseMetaConfidenceInfo struct { + Annotations []QualityIQISummaryResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON qualityIQISummaryResponseMetaConfidenceInfoJSON `json:"-"` +} + +// qualityIQISummaryResponseMetaConfidenceInfoJSON contains the JSON metadata for +// the struct [QualityIQISummaryResponseMetaConfidenceInfo] +type qualityIQISummaryResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualityIQISummaryResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualityIQISummaryResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type QualityIQISummaryResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON qualityIQISummaryResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// qualityIQISummaryResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct [QualityIQISummaryResponseMetaConfidenceInfoAnnotation] +type qualityIQISummaryResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualityIQISummaryResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualityIQISummaryResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type QualityIQISummaryResponseSummary0 struct { + P25 string `json:"p25,required"` + P50 string `json:"p50,required"` + P75 string `json:"p75,required"` + JSON qualityIQISummaryResponseSummary0JSON `json:"-"` +} + +// qualityIQISummaryResponseSummary0JSON contains the JSON metadata for the struct +// [QualityIQISummaryResponseSummary0] +type qualityIQISummaryResponseSummary0JSON struct { + P25 apijson.Field + P50 apijson.Field + P75 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualityIQISummaryResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualityIQISummaryResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type QualityIQITimeseriesGroupsResponse struct { + Meta interface{} `json:"meta,required"` + Serie0 QualityIQITimeseriesGroupsResponseSerie0 `json:"serie_0,required"` + JSON qualityIQITimeseriesGroupsResponseJSON `json:"-"` +} + +// qualityIQITimeseriesGroupsResponseJSON contains the JSON metadata for the struct +// [QualityIQITimeseriesGroupsResponse] +type qualityIQITimeseriesGroupsResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualityIQITimeseriesGroupsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualityIQITimeseriesGroupsResponseJSON) RawJSON() string { + return r.raw +} + +type QualityIQITimeseriesGroupsResponseSerie0 struct { + P25 []string `json:"p25,required"` + P50 []string `json:"p50,required"` + P75 []string `json:"p75,required"` + Timestamps []string `json:"timestamps,required"` + JSON qualityIQITimeseriesGroupsResponseSerie0JSON `json:"-"` +} + +// qualityIQITimeseriesGroupsResponseSerie0JSON contains the JSON metadata for the +// struct [QualityIQITimeseriesGroupsResponseSerie0] +type qualityIQITimeseriesGroupsResponseSerie0JSON struct { + P25 apijson.Field + P50 apijson.Field + P75 apijson.Field + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualityIQITimeseriesGroupsResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualityIQITimeseriesGroupsResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type QualityIQISummaryParams struct { + // Which metric to return: bandwidth, latency or DNS response time. + Metric param.Field[QualityIQISummaryParamsMetric] `query:"metric,required"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]QualityIQISummaryParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[QualityIQISummaryParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [QualityIQISummaryParams]'s query parameters as +// `url.Values`. +func (r QualityIQISummaryParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Which metric to return: bandwidth, latency or DNS response time. +type QualityIQISummaryParamsMetric string + +const ( + QualityIQISummaryParamsMetricBandwidth QualityIQISummaryParamsMetric = "BANDWIDTH" + QualityIQISummaryParamsMetricDNS QualityIQISummaryParamsMetric = "DNS" + QualityIQISummaryParamsMetricLatency QualityIQISummaryParamsMetric = "LATENCY" +) + +type QualityIQISummaryParamsDateRange string + +const ( + QualityIQISummaryParamsDateRange1d QualityIQISummaryParamsDateRange = "1d" + QualityIQISummaryParamsDateRange2d QualityIQISummaryParamsDateRange = "2d" + QualityIQISummaryParamsDateRange7d QualityIQISummaryParamsDateRange = "7d" + QualityIQISummaryParamsDateRange14d QualityIQISummaryParamsDateRange = "14d" + QualityIQISummaryParamsDateRange28d QualityIQISummaryParamsDateRange = "28d" + QualityIQISummaryParamsDateRange12w QualityIQISummaryParamsDateRange = "12w" + QualityIQISummaryParamsDateRange24w QualityIQISummaryParamsDateRange = "24w" + QualityIQISummaryParamsDateRange52w QualityIQISummaryParamsDateRange = "52w" + QualityIQISummaryParamsDateRange1dControl QualityIQISummaryParamsDateRange = "1dControl" + QualityIQISummaryParamsDateRange2dControl QualityIQISummaryParamsDateRange = "2dControl" + QualityIQISummaryParamsDateRange7dControl QualityIQISummaryParamsDateRange = "7dControl" + QualityIQISummaryParamsDateRange14dControl QualityIQISummaryParamsDateRange = "14dControl" + QualityIQISummaryParamsDateRange28dControl QualityIQISummaryParamsDateRange = "28dControl" + QualityIQISummaryParamsDateRange12wControl QualityIQISummaryParamsDateRange = "12wControl" + QualityIQISummaryParamsDateRange24wControl QualityIQISummaryParamsDateRange = "24wControl" +) + +// Format results are returned in. +type QualityIQISummaryParamsFormat string + +const ( + QualityIQISummaryParamsFormatJson QualityIQISummaryParamsFormat = "JSON" + QualityIQISummaryParamsFormatCsv QualityIQISummaryParamsFormat = "CSV" +) + +type QualityIQISummaryResponseEnvelope struct { + Result QualityIQISummaryResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON qualityIQISummaryResponseEnvelopeJSON `json:"-"` +} + +// qualityIQISummaryResponseEnvelopeJSON contains the JSON metadata for the struct +// [QualityIQISummaryResponseEnvelope] +type qualityIQISummaryResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualityIQISummaryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualityIQISummaryResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type QualityIQITimeseriesGroupsParams struct { + // Which metric to return: bandwidth, latency or DNS response time. + Metric param.Field[QualityIQITimeseriesGroupsParamsMetric] `query:"metric,required"` + // Aggregation interval results should be returned in (for example, in 15 minutes + // or 1 hour intervals). Refer to + // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). + AggInterval param.Field[QualityIQITimeseriesGroupsParamsAggInterval] `query:"aggInterval"` + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]QualityIQITimeseriesGroupsParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[QualityIQITimeseriesGroupsParamsFormat] `query:"format"` + // Enable interpolation for all series (using the average). + Interpolation param.Field[bool] `query:"interpolation"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [QualityIQITimeseriesGroupsParams]'s query parameters as +// `url.Values`. +func (r QualityIQITimeseriesGroupsParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Which metric to return: bandwidth, latency or DNS response time. +type QualityIQITimeseriesGroupsParamsMetric string + +const ( + QualityIQITimeseriesGroupsParamsMetricBandwidth QualityIQITimeseriesGroupsParamsMetric = "BANDWIDTH" + QualityIQITimeseriesGroupsParamsMetricDNS QualityIQITimeseriesGroupsParamsMetric = "DNS" + QualityIQITimeseriesGroupsParamsMetricLatency QualityIQITimeseriesGroupsParamsMetric = "LATENCY" +) + +// Aggregation interval results should be returned in (for example, in 15 minutes +// or 1 hour intervals). Refer to +// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). +type QualityIQITimeseriesGroupsParamsAggInterval string + +const ( + QualityIQITimeseriesGroupsParamsAggInterval15m QualityIQITimeseriesGroupsParamsAggInterval = "15m" + QualityIQITimeseriesGroupsParamsAggInterval1h QualityIQITimeseriesGroupsParamsAggInterval = "1h" + QualityIQITimeseriesGroupsParamsAggInterval1d QualityIQITimeseriesGroupsParamsAggInterval = "1d" + QualityIQITimeseriesGroupsParamsAggInterval1w QualityIQITimeseriesGroupsParamsAggInterval = "1w" +) + +type QualityIQITimeseriesGroupsParamsDateRange string + +const ( + QualityIQITimeseriesGroupsParamsDateRange1d QualityIQITimeseriesGroupsParamsDateRange = "1d" + QualityIQITimeseriesGroupsParamsDateRange2d QualityIQITimeseriesGroupsParamsDateRange = "2d" + QualityIQITimeseriesGroupsParamsDateRange7d QualityIQITimeseriesGroupsParamsDateRange = "7d" + QualityIQITimeseriesGroupsParamsDateRange14d QualityIQITimeseriesGroupsParamsDateRange = "14d" + QualityIQITimeseriesGroupsParamsDateRange28d QualityIQITimeseriesGroupsParamsDateRange = "28d" + QualityIQITimeseriesGroupsParamsDateRange12w QualityIQITimeseriesGroupsParamsDateRange = "12w" + QualityIQITimeseriesGroupsParamsDateRange24w QualityIQITimeseriesGroupsParamsDateRange = "24w" + QualityIQITimeseriesGroupsParamsDateRange52w QualityIQITimeseriesGroupsParamsDateRange = "52w" + QualityIQITimeseriesGroupsParamsDateRange1dControl QualityIQITimeseriesGroupsParamsDateRange = "1dControl" + QualityIQITimeseriesGroupsParamsDateRange2dControl QualityIQITimeseriesGroupsParamsDateRange = "2dControl" + QualityIQITimeseriesGroupsParamsDateRange7dControl QualityIQITimeseriesGroupsParamsDateRange = "7dControl" + QualityIQITimeseriesGroupsParamsDateRange14dControl QualityIQITimeseriesGroupsParamsDateRange = "14dControl" + QualityIQITimeseriesGroupsParamsDateRange28dControl QualityIQITimeseriesGroupsParamsDateRange = "28dControl" + QualityIQITimeseriesGroupsParamsDateRange12wControl QualityIQITimeseriesGroupsParamsDateRange = "12wControl" + QualityIQITimeseriesGroupsParamsDateRange24wControl QualityIQITimeseriesGroupsParamsDateRange = "24wControl" +) + +// Format results are returned in. +type QualityIQITimeseriesGroupsParamsFormat string + +const ( + QualityIQITimeseriesGroupsParamsFormatJson QualityIQITimeseriesGroupsParamsFormat = "JSON" + QualityIQITimeseriesGroupsParamsFormatCsv QualityIQITimeseriesGroupsParamsFormat = "CSV" +) + +type QualityIQITimeseriesGroupsResponseEnvelope struct { + Result QualityIQITimeseriesGroupsResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON qualityIQITimeseriesGroupsResponseEnvelopeJSON `json:"-"` +} + +// qualityIQITimeseriesGroupsResponseEnvelopeJSON contains the JSON metadata for +// the struct [QualityIQITimeseriesGroupsResponseEnvelope] +type qualityIQITimeseriesGroupsResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualityIQITimeseriesGroupsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualityIQITimeseriesGroupsResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/qualityiqi_test.go b/radar/qualityiqi_test.go new file mode 100644 index 00000000000..092e990a33e --- /dev/null +++ b/radar/qualityiqi_test.go @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestQualityIQISummaryWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Quality.IQI.Summary(context.TODO(), radar.QualityIQISummaryParams{ + Metric: cloudflare.F(radar.QualityIQISummaryParamsMetricBandwidth), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.QualityIQISummaryParamsDateRange{radar.QualityIQISummaryParamsDateRange1d, radar.QualityIQISummaryParamsDateRange2d, radar.QualityIQISummaryParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.QualityIQISummaryParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestQualityIQITimeseriesGroupsWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Quality.IQI.TimeseriesGroups(context.TODO(), radar.QualityIQITimeseriesGroupsParams{ + Metric: cloudflare.F(radar.QualityIQITimeseriesGroupsParamsMetricBandwidth), + AggInterval: cloudflare.F(radar.QualityIQITimeseriesGroupsParamsAggInterval1h), + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.QualityIQITimeseriesGroupsParamsDateRange{radar.QualityIQITimeseriesGroupsParamsDateRange1d, radar.QualityIQITimeseriesGroupsParamsDateRange2d, radar.QualityIQITimeseriesGroupsParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.QualityIQITimeseriesGroupsParamsFormatJson), + Interpolation: cloudflare.F(true), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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/radar/qualityspeed.go b/radar/qualityspeed.go new file mode 100644 index 00000000000..41990f64973 --- /dev/null +++ b/radar/qualityspeed.go @@ -0,0 +1,412 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// QualitySpeedService 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 [NewQualitySpeedService] method +// instead. +type QualitySpeedService struct { + Options []option.RequestOption + Top *QualitySpeedTopService +} + +// NewQualitySpeedService 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 NewQualitySpeedService(opts ...option.RequestOption) (r *QualitySpeedService) { + r = &QualitySpeedService{} + r.Options = opts + r.Top = NewQualitySpeedTopService(opts...) + return +} + +// Get an histogram from the previous 90 days of Cloudflare Speed Test data, split +// into fixed bandwidth (Mbps), latency (ms) or jitter (ms) buckets. +func (r *QualitySpeedService) Histogram(ctx context.Context, query QualitySpeedHistogramParams, opts ...option.RequestOption) (res *QualitySpeedHistogramResponse, err error) { + opts = append(r.Options[:], opts...) + var env QualitySpeedHistogramResponseEnvelope + path := "radar/quality/speed/histogram" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a summary of bandwidth, latency, jitter and packet loss, from the previous +// 90 days of Cloudflare Speed Test data. +func (r *QualitySpeedService) Summary(ctx context.Context, query QualitySpeedSummaryParams, opts ...option.RequestOption) (res *QualitySpeedSummaryResponse, err error) { + opts = append(r.Options[:], opts...) + var env QualitySpeedSummaryResponseEnvelope + path := "radar/quality/speed/summary" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type QualitySpeedHistogramResponse struct { + Histogram0 QualitySpeedHistogramResponseHistogram0 `json:"histogram_0,required"` + Meta interface{} `json:"meta,required"` + JSON qualitySpeedHistogramResponseJSON `json:"-"` +} + +// qualitySpeedHistogramResponseJSON contains the JSON metadata for the struct +// [QualitySpeedHistogramResponse] +type qualitySpeedHistogramResponseJSON struct { + Histogram0 apijson.Field + Meta apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedHistogramResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedHistogramResponseJSON) RawJSON() string { + return r.raw +} + +type QualitySpeedHistogramResponseHistogram0 struct { + BandwidthDownload []string `json:"bandwidthDownload,required"` + BandwidthUpload []string `json:"bandwidthUpload,required"` + BucketMin []string `json:"bucketMin,required"` + JSON qualitySpeedHistogramResponseHistogram0JSON `json:"-"` +} + +// qualitySpeedHistogramResponseHistogram0JSON contains the JSON metadata for the +// struct [QualitySpeedHistogramResponseHistogram0] +type qualitySpeedHistogramResponseHistogram0JSON struct { + BandwidthDownload apijson.Field + BandwidthUpload apijson.Field + BucketMin apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedHistogramResponseHistogram0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedHistogramResponseHistogram0JSON) RawJSON() string { + return r.raw +} + +type QualitySpeedSummaryResponse struct { + Meta QualitySpeedSummaryResponseMeta `json:"meta,required"` + Summary0 QualitySpeedSummaryResponseSummary0 `json:"summary_0,required"` + JSON qualitySpeedSummaryResponseJSON `json:"-"` +} + +// qualitySpeedSummaryResponseJSON contains the JSON metadata for the struct +// [QualitySpeedSummaryResponse] +type qualitySpeedSummaryResponseJSON struct { + Meta apijson.Field + Summary0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedSummaryResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedSummaryResponseJSON) RawJSON() string { + return r.raw +} + +type QualitySpeedSummaryResponseMeta struct { + DateRange []QualitySpeedSummaryResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + Normalization string `json:"normalization,required"` + ConfidenceInfo QualitySpeedSummaryResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON qualitySpeedSummaryResponseMetaJSON `json:"-"` +} + +// qualitySpeedSummaryResponseMetaJSON contains the JSON metadata for the struct +// [QualitySpeedSummaryResponseMeta] +type qualitySpeedSummaryResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + Normalization apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedSummaryResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedSummaryResponseMetaJSON) RawJSON() string { + return r.raw +} + +type QualitySpeedSummaryResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON qualitySpeedSummaryResponseMetaDateRangeJSON `json:"-"` +} + +// qualitySpeedSummaryResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [QualitySpeedSummaryResponseMetaDateRange] +type qualitySpeedSummaryResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedSummaryResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedSummaryResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type QualitySpeedSummaryResponseMetaConfidenceInfo struct { + Annotations []QualitySpeedSummaryResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON qualitySpeedSummaryResponseMetaConfidenceInfoJSON `json:"-"` +} + +// qualitySpeedSummaryResponseMetaConfidenceInfoJSON contains the JSON metadata for +// the struct [QualitySpeedSummaryResponseMetaConfidenceInfo] +type qualitySpeedSummaryResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedSummaryResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedSummaryResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type QualitySpeedSummaryResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON qualitySpeedSummaryResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// qualitySpeedSummaryResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [QualitySpeedSummaryResponseMetaConfidenceInfoAnnotation] +type qualitySpeedSummaryResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedSummaryResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedSummaryResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type QualitySpeedSummaryResponseSummary0 struct { + BandwidthDownload string `json:"bandwidthDownload,required"` + BandwidthUpload string `json:"bandwidthUpload,required"` + JitterIdle string `json:"jitterIdle,required"` + JitterLoaded string `json:"jitterLoaded,required"` + LatencyIdle string `json:"latencyIdle,required"` + LatencyLoaded string `json:"latencyLoaded,required"` + PacketLoss string `json:"packetLoss,required"` + JSON qualitySpeedSummaryResponseSummary0JSON `json:"-"` +} + +// qualitySpeedSummaryResponseSummary0JSON contains the JSON metadata for the +// struct [QualitySpeedSummaryResponseSummary0] +type qualitySpeedSummaryResponseSummary0JSON struct { + BandwidthDownload apijson.Field + BandwidthUpload apijson.Field + JitterIdle apijson.Field + JitterLoaded apijson.Field + LatencyIdle apijson.Field + LatencyLoaded apijson.Field + PacketLoss apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedSummaryResponseSummary0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedSummaryResponseSummary0JSON) RawJSON() string { + return r.raw +} + +type QualitySpeedHistogramParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // The width for every bucket in the histogram. + BucketSize param.Field[int64] `query:"bucketSize"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // Format results are returned in. + Format param.Field[QualitySpeedHistogramParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Metrics to be returned. + MetricGroup param.Field[QualitySpeedHistogramParamsMetricGroup] `query:"metricGroup"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [QualitySpeedHistogramParams]'s query parameters as +// `url.Values`. +func (r QualitySpeedHistogramParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Format results are returned in. +type QualitySpeedHistogramParamsFormat string + +const ( + QualitySpeedHistogramParamsFormatJson QualitySpeedHistogramParamsFormat = "JSON" + QualitySpeedHistogramParamsFormatCsv QualitySpeedHistogramParamsFormat = "CSV" +) + +// Metrics to be returned. +type QualitySpeedHistogramParamsMetricGroup string + +const ( + QualitySpeedHistogramParamsMetricGroupBandwidth QualitySpeedHistogramParamsMetricGroup = "BANDWIDTH" + QualitySpeedHistogramParamsMetricGroupLatency QualitySpeedHistogramParamsMetricGroup = "LATENCY" + QualitySpeedHistogramParamsMetricGroupJitter QualitySpeedHistogramParamsMetricGroup = "JITTER" +) + +type QualitySpeedHistogramResponseEnvelope struct { + Result QualitySpeedHistogramResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON qualitySpeedHistogramResponseEnvelopeJSON `json:"-"` +} + +// qualitySpeedHistogramResponseEnvelopeJSON contains the JSON metadata for the +// struct [QualitySpeedHistogramResponseEnvelope] +type qualitySpeedHistogramResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedHistogramResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedHistogramResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type QualitySpeedSummaryParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // Format results are returned in. + Format param.Field[QualitySpeedSummaryParamsFormat] `query:"format"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [QualitySpeedSummaryParams]'s query parameters as +// `url.Values`. +func (r QualitySpeedSummaryParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Format results are returned in. +type QualitySpeedSummaryParamsFormat string + +const ( + QualitySpeedSummaryParamsFormatJson QualitySpeedSummaryParamsFormat = "JSON" + QualitySpeedSummaryParamsFormatCsv QualitySpeedSummaryParamsFormat = "CSV" +) + +type QualitySpeedSummaryResponseEnvelope struct { + Result QualitySpeedSummaryResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON qualitySpeedSummaryResponseEnvelopeJSON `json:"-"` +} + +// qualitySpeedSummaryResponseEnvelopeJSON contains the JSON metadata for the +// struct [QualitySpeedSummaryResponseEnvelope] +type qualitySpeedSummaryResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedSummaryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedSummaryResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/qualityspeed_test.go b/radar/qualityspeed_test.go new file mode 100644 index 00000000000..0b1e5aac61a --- /dev/null +++ b/radar/qualityspeed_test.go @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestQualitySpeedHistogramWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Quality.Speed.Histogram(context.TODO(), radar.QualitySpeedHistogramParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + BucketSize: cloudflare.F(int64(0)), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.QualitySpeedHistogramParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + MetricGroup: cloudflare.F(radar.QualitySpeedHistogramParamsMetricGroupBandwidth), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestQualitySpeedSummaryWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Quality.Speed.Summary(context.TODO(), radar.QualitySpeedSummaryParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.QualitySpeedSummaryParamsFormatJson), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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/radar/qualityspeedtop.go b/radar/qualityspeedtop.go new file mode 100644 index 00000000000..f655fd72ee8 --- /dev/null +++ b/radar/qualityspeedtop.go @@ -0,0 +1,558 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// QualitySpeedTopService 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 [NewQualitySpeedTopService] method +// instead. +type QualitySpeedTopService struct { + Options []option.RequestOption +} + +// NewQualitySpeedTopService 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 NewQualitySpeedTopService(opts ...option.RequestOption) (r *QualitySpeedTopService) { + r = &QualitySpeedTopService{} + r.Options = opts + return +} + +// Get the top autonomous systems by bandwidth, latency, jitter or packet loss, +// from the previous 90 days of Cloudflare Speed Test data. +func (r *QualitySpeedTopService) Ases(ctx context.Context, query QualitySpeedTopAsesParams, opts ...option.RequestOption) (res *QualitySpeedTopAsesResponse, err error) { + opts = append(r.Options[:], opts...) + var env QualitySpeedTopAsesResponseEnvelope + path := "radar/quality/speed/top/ases" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the top locations by bandwidth, latency, jitter or packet loss, from the +// previous 90 days of Cloudflare Speed Test data. +func (r *QualitySpeedTopService) Locations(ctx context.Context, query QualitySpeedTopLocationsParams, opts ...option.RequestOption) (res *QualitySpeedTopLocationsResponse, err error) { + opts = append(r.Options[:], opts...) + var env QualitySpeedTopLocationsResponseEnvelope + path := "radar/quality/speed/top/locations" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type QualitySpeedTopAsesResponse struct { + Meta QualitySpeedTopAsesResponseMeta `json:"meta,required"` + Top0 []QualitySpeedTopAsesResponseTop0 `json:"top_0,required"` + JSON qualitySpeedTopAsesResponseJSON `json:"-"` +} + +// qualitySpeedTopAsesResponseJSON contains the JSON metadata for the struct +// [QualitySpeedTopAsesResponse] +type qualitySpeedTopAsesResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedTopAsesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedTopAsesResponseJSON) RawJSON() string { + return r.raw +} + +type QualitySpeedTopAsesResponseMeta struct { + DateRange []QualitySpeedTopAsesResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo QualitySpeedTopAsesResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON qualitySpeedTopAsesResponseMetaJSON `json:"-"` +} + +// qualitySpeedTopAsesResponseMetaJSON contains the JSON metadata for the struct +// [QualitySpeedTopAsesResponseMeta] +type qualitySpeedTopAsesResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedTopAsesResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedTopAsesResponseMetaJSON) RawJSON() string { + return r.raw +} + +type QualitySpeedTopAsesResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON qualitySpeedTopAsesResponseMetaDateRangeJSON `json:"-"` +} + +// qualitySpeedTopAsesResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [QualitySpeedTopAsesResponseMetaDateRange] +type qualitySpeedTopAsesResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedTopAsesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedTopAsesResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type QualitySpeedTopAsesResponseMetaConfidenceInfo struct { + Annotations []QualitySpeedTopAsesResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON qualitySpeedTopAsesResponseMetaConfidenceInfoJSON `json:"-"` +} + +// qualitySpeedTopAsesResponseMetaConfidenceInfoJSON contains the JSON metadata for +// the struct [QualitySpeedTopAsesResponseMetaConfidenceInfo] +type qualitySpeedTopAsesResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedTopAsesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedTopAsesResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type QualitySpeedTopAsesResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON qualitySpeedTopAsesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// qualitySpeedTopAsesResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct +// [QualitySpeedTopAsesResponseMetaConfidenceInfoAnnotation] +type qualitySpeedTopAsesResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedTopAsesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedTopAsesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type QualitySpeedTopAsesResponseTop0 struct { + BandwidthDownload string `json:"bandwidthDownload,required"` + BandwidthUpload string `json:"bandwidthUpload,required"` + ClientASN float64 `json:"clientASN,required"` + ClientAsName string `json:"clientASName,required"` + JitterIdle string `json:"jitterIdle,required"` + JitterLoaded string `json:"jitterLoaded,required"` + LatencyIdle string `json:"latencyIdle,required"` + LatencyLoaded string `json:"latencyLoaded,required"` + NumTests float64 `json:"numTests,required"` + RankPower float64 `json:"rankPower,required"` + JSON qualitySpeedTopAsesResponseTop0JSON `json:"-"` +} + +// qualitySpeedTopAsesResponseTop0JSON contains the JSON metadata for the struct +// [QualitySpeedTopAsesResponseTop0] +type qualitySpeedTopAsesResponseTop0JSON struct { + BandwidthDownload apijson.Field + BandwidthUpload apijson.Field + ClientASN apijson.Field + ClientAsName apijson.Field + JitterIdle apijson.Field + JitterLoaded apijson.Field + LatencyIdle apijson.Field + LatencyLoaded apijson.Field + NumTests apijson.Field + RankPower apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedTopAsesResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedTopAsesResponseTop0JSON) RawJSON() string { + return r.raw +} + +type QualitySpeedTopLocationsResponse struct { + Meta QualitySpeedTopLocationsResponseMeta `json:"meta,required"` + Top0 []QualitySpeedTopLocationsResponseTop0 `json:"top_0,required"` + JSON qualitySpeedTopLocationsResponseJSON `json:"-"` +} + +// qualitySpeedTopLocationsResponseJSON contains the JSON metadata for the struct +// [QualitySpeedTopLocationsResponse] +type qualitySpeedTopLocationsResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedTopLocationsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedTopLocationsResponseJSON) RawJSON() string { + return r.raw +} + +type QualitySpeedTopLocationsResponseMeta struct { + DateRange []QualitySpeedTopLocationsResponseMetaDateRange `json:"dateRange,required"` + LastUpdated string `json:"lastUpdated,required"` + ConfidenceInfo QualitySpeedTopLocationsResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON qualitySpeedTopLocationsResponseMetaJSON `json:"-"` +} + +// qualitySpeedTopLocationsResponseMetaJSON contains the JSON metadata for the +// struct [QualitySpeedTopLocationsResponseMeta] +type qualitySpeedTopLocationsResponseMetaJSON struct { + DateRange apijson.Field + LastUpdated apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedTopLocationsResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedTopLocationsResponseMetaJSON) RawJSON() string { + return r.raw +} + +type QualitySpeedTopLocationsResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON qualitySpeedTopLocationsResponseMetaDateRangeJSON `json:"-"` +} + +// qualitySpeedTopLocationsResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [QualitySpeedTopLocationsResponseMetaDateRange] +type qualitySpeedTopLocationsResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedTopLocationsResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedTopLocationsResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type QualitySpeedTopLocationsResponseMetaConfidenceInfo struct { + Annotations []QualitySpeedTopLocationsResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON qualitySpeedTopLocationsResponseMetaConfidenceInfoJSON `json:"-"` +} + +// qualitySpeedTopLocationsResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [QualitySpeedTopLocationsResponseMetaConfidenceInfo] +type qualitySpeedTopLocationsResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedTopLocationsResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedTopLocationsResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type QualitySpeedTopLocationsResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON qualitySpeedTopLocationsResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// qualitySpeedTopLocationsResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [QualitySpeedTopLocationsResponseMetaConfidenceInfoAnnotation] +type qualitySpeedTopLocationsResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedTopLocationsResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedTopLocationsResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type QualitySpeedTopLocationsResponseTop0 struct { + BandwidthDownload string `json:"bandwidthDownload,required"` + BandwidthUpload string `json:"bandwidthUpload,required"` + ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` + ClientCountryName string `json:"clientCountryName,required"` + JitterIdle string `json:"jitterIdle,required"` + JitterLoaded string `json:"jitterLoaded,required"` + LatencyIdle string `json:"latencyIdle,required"` + LatencyLoaded string `json:"latencyLoaded,required"` + NumTests float64 `json:"numTests,required"` + RankPower float64 `json:"rankPower,required"` + JSON qualitySpeedTopLocationsResponseTop0JSON `json:"-"` +} + +// qualitySpeedTopLocationsResponseTop0JSON contains the JSON metadata for the +// struct [QualitySpeedTopLocationsResponseTop0] +type qualitySpeedTopLocationsResponseTop0JSON struct { + BandwidthDownload apijson.Field + BandwidthUpload apijson.Field + ClientCountryAlpha2 apijson.Field + ClientCountryName apijson.Field + JitterIdle apijson.Field + JitterLoaded apijson.Field + LatencyIdle apijson.Field + LatencyLoaded apijson.Field + NumTests apijson.Field + RankPower apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedTopLocationsResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedTopLocationsResponseTop0JSON) RawJSON() string { + return r.raw +} + +type QualitySpeedTopAsesParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // Format results are returned in. + Format param.Field[QualitySpeedTopAsesParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Metric to order the results by. + OrderBy param.Field[QualitySpeedTopAsesParamsOrderBy] `query:"orderBy"` + // Reverse the order of results. + Reverse param.Field[bool] `query:"reverse"` +} + +// URLQuery serializes [QualitySpeedTopAsesParams]'s query parameters as +// `url.Values`. +func (r QualitySpeedTopAsesParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Format results are returned in. +type QualitySpeedTopAsesParamsFormat string + +const ( + QualitySpeedTopAsesParamsFormatJson QualitySpeedTopAsesParamsFormat = "JSON" + QualitySpeedTopAsesParamsFormatCsv QualitySpeedTopAsesParamsFormat = "CSV" +) + +// Metric to order the results by. +type QualitySpeedTopAsesParamsOrderBy string + +const ( + QualitySpeedTopAsesParamsOrderByBandwidthDownload QualitySpeedTopAsesParamsOrderBy = "BANDWIDTH_DOWNLOAD" + QualitySpeedTopAsesParamsOrderByBandwidthUpload QualitySpeedTopAsesParamsOrderBy = "BANDWIDTH_UPLOAD" + QualitySpeedTopAsesParamsOrderByLatencyIdle QualitySpeedTopAsesParamsOrderBy = "LATENCY_IDLE" + QualitySpeedTopAsesParamsOrderByLatencyLoaded QualitySpeedTopAsesParamsOrderBy = "LATENCY_LOADED" + QualitySpeedTopAsesParamsOrderByJitterIdle QualitySpeedTopAsesParamsOrderBy = "JITTER_IDLE" + QualitySpeedTopAsesParamsOrderByJitterLoaded QualitySpeedTopAsesParamsOrderBy = "JITTER_LOADED" +) + +type QualitySpeedTopAsesResponseEnvelope struct { + Result QualitySpeedTopAsesResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON qualitySpeedTopAsesResponseEnvelopeJSON `json:"-"` +} + +// qualitySpeedTopAsesResponseEnvelopeJSON contains the JSON metadata for the +// struct [QualitySpeedTopAsesResponseEnvelope] +type qualitySpeedTopAsesResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedTopAsesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedTopAsesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type QualitySpeedTopLocationsParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // Format results are returned in. + Format param.Field[QualitySpeedTopLocationsParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // Metric to order the results by. + OrderBy param.Field[QualitySpeedTopLocationsParamsOrderBy] `query:"orderBy"` + // Reverse the order of results. + Reverse param.Field[bool] `query:"reverse"` +} + +// URLQuery serializes [QualitySpeedTopLocationsParams]'s query parameters as +// `url.Values`. +func (r QualitySpeedTopLocationsParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Format results are returned in. +type QualitySpeedTopLocationsParamsFormat string + +const ( + QualitySpeedTopLocationsParamsFormatJson QualitySpeedTopLocationsParamsFormat = "JSON" + QualitySpeedTopLocationsParamsFormatCsv QualitySpeedTopLocationsParamsFormat = "CSV" +) + +// Metric to order the results by. +type QualitySpeedTopLocationsParamsOrderBy string + +const ( + QualitySpeedTopLocationsParamsOrderByBandwidthDownload QualitySpeedTopLocationsParamsOrderBy = "BANDWIDTH_DOWNLOAD" + QualitySpeedTopLocationsParamsOrderByBandwidthUpload QualitySpeedTopLocationsParamsOrderBy = "BANDWIDTH_UPLOAD" + QualitySpeedTopLocationsParamsOrderByLatencyIdle QualitySpeedTopLocationsParamsOrderBy = "LATENCY_IDLE" + QualitySpeedTopLocationsParamsOrderByLatencyLoaded QualitySpeedTopLocationsParamsOrderBy = "LATENCY_LOADED" + QualitySpeedTopLocationsParamsOrderByJitterIdle QualitySpeedTopLocationsParamsOrderBy = "JITTER_IDLE" + QualitySpeedTopLocationsParamsOrderByJitterLoaded QualitySpeedTopLocationsParamsOrderBy = "JITTER_LOADED" +) + +type QualitySpeedTopLocationsResponseEnvelope struct { + Result QualitySpeedTopLocationsResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON qualitySpeedTopLocationsResponseEnvelopeJSON `json:"-"` +} + +// qualitySpeedTopLocationsResponseEnvelopeJSON contains the JSON metadata for the +// struct [QualitySpeedTopLocationsResponseEnvelope] +type qualitySpeedTopLocationsResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *QualitySpeedTopLocationsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r qualitySpeedTopLocationsResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/qualityspeedtop_test.go b/radar/qualityspeedtop_test.go new file mode 100644 index 00000000000..65e41ee4d11 --- /dev/null +++ b/radar/qualityspeedtop_test.go @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestQualitySpeedTopAsesWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Quality.Speed.Top.Ases(context.TODO(), radar.QualitySpeedTopAsesParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.QualitySpeedTopAsesParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OrderBy: cloudflare.F(radar.QualitySpeedTopAsesParamsOrderByBandwidthDownload), + Reverse: cloudflare.F(true), + }) + 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 TestQualitySpeedTopLocationsWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Quality.Speed.Top.Locations(context.TODO(), radar.QualitySpeedTopLocationsParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.QualitySpeedTopLocationsParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + OrderBy: cloudflare.F(radar.QualitySpeedTopLocationsParamsOrderByBandwidthDownload), + Reverse: cloudflare.F(true), + }) + 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/radar/radar.go b/radar/radar.go new file mode 100644 index 00000000000..3a66ec74208 --- /dev/null +++ b/radar/radar.go @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// RadarService 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 [NewRadarService] method instead. +type RadarService struct { + Options []option.RequestOption + Annotations *AnnotationService + BGP *BGPService + Datasets *DatasetService + DNS *DNSService + Netflows *NetflowService + Search *SearchService + VerifiedBots *VerifiedBotService + AS112 *AS112Service + ConnectionTampering *ConnectionTamperingService + Email *EmailService + Attacks *AttackService + Entities *EntityService + HTTP *HTTPService + Quality *QualityService + Ranking *RankingService + TrafficAnomalies *TrafficAnomalyService +} + +// NewRadarService 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 NewRadarService(opts ...option.RequestOption) (r *RadarService) { + r = &RadarService{} + r.Options = opts + r.Annotations = NewAnnotationService(opts...) + r.BGP = NewBGPService(opts...) + r.Datasets = NewDatasetService(opts...) + r.DNS = NewDNSService(opts...) + r.Netflows = NewNetflowService(opts...) + r.Search = NewSearchService(opts...) + r.VerifiedBots = NewVerifiedBotService(opts...) + r.AS112 = NewAS112Service(opts...) + r.ConnectionTampering = NewConnectionTamperingService(opts...) + r.Email = NewEmailService(opts...) + r.Attacks = NewAttackService(opts...) + r.Entities = NewEntityService(opts...) + r.HTTP = NewHTTPService(opts...) + r.Quality = NewQualityService(opts...) + r.Ranking = NewRankingService(opts...) + r.TrafficAnomalies = NewTrafficAnomalyService(opts...) + return +} diff --git a/radar/ranking.go b/radar/ranking.go new file mode 100644 index 00000000000..72c63f6c29e --- /dev/null +++ b/radar/ranking.go @@ -0,0 +1,428 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// RankingService 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 [NewRankingService] method instead. +type RankingService struct { + Options []option.RequestOption + Domain *RankingDomainService +} + +// NewRankingService 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 NewRankingService(opts ...option.RequestOption) (r *RankingService) { + r = &RankingService{} + r.Options = opts + r.Domain = NewRankingDomainService(opts...) + return +} + +// Gets Domains Rank updates change over time. Raw values are returned. +func (r *RankingService) TimeseriesGroups(ctx context.Context, query RankingTimeseriesGroupsParams, opts ...option.RequestOption) (res *RankingTimeseriesGroupsResponse, err error) { + opts = append(r.Options[:], opts...) + var env RankingTimeseriesGroupsResponseEnvelope + path := "radar/ranking/timeseries_groups" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get top or trending domains based on their rank. Popular domains are domains of +// broad appeal based on how people use the Internet. Trending domains are domains +// that are generating a surge in interest. For more information on top domains, +// see https://blog.cloudflare.com/radar-domain-rankings/. +func (r *RankingService) Top(ctx context.Context, query RankingTopParams, opts ...option.RequestOption) (res *RankingTopResponse, err error) { + opts = append(r.Options[:], opts...) + var env RankingTopResponseEnvelope + path := "radar/ranking/top" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type RankingTimeseriesGroupsResponse struct { + Meta RankingTimeseriesGroupsResponseMeta `json:"meta,required"` + Serie0 RankingTimeseriesGroupsResponseSerie0 `json:"serie_0,required"` + JSON rankingTimeseriesGroupsResponseJSON `json:"-"` +} + +// rankingTimeseriesGroupsResponseJSON contains the JSON metadata for the struct +// [RankingTimeseriesGroupsResponse] +type rankingTimeseriesGroupsResponseJSON struct { + Meta apijson.Field + Serie0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RankingTimeseriesGroupsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rankingTimeseriesGroupsResponseJSON) RawJSON() string { + return r.raw +} + +type RankingTimeseriesGroupsResponseMeta struct { + DateRange []RankingTimeseriesGroupsResponseMetaDateRange `json:"dateRange,required"` + JSON rankingTimeseriesGroupsResponseMetaJSON `json:"-"` +} + +// rankingTimeseriesGroupsResponseMetaJSON contains the JSON metadata for the +// struct [RankingTimeseriesGroupsResponseMeta] +type rankingTimeseriesGroupsResponseMetaJSON struct { + DateRange apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RankingTimeseriesGroupsResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rankingTimeseriesGroupsResponseMetaJSON) RawJSON() string { + return r.raw +} + +type RankingTimeseriesGroupsResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON rankingTimeseriesGroupsResponseMetaDateRangeJSON `json:"-"` +} + +// rankingTimeseriesGroupsResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [RankingTimeseriesGroupsResponseMetaDateRange] +type rankingTimeseriesGroupsResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RankingTimeseriesGroupsResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rankingTimeseriesGroupsResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type RankingTimeseriesGroupsResponseSerie0 struct { + Timestamps []string `json:"timestamps,required"` + ExtraFields map[string][]RankingTimeseriesGroupsResponseSerie0 `json:"-,extras"` + JSON rankingTimeseriesGroupsResponseSerie0JSON `json:"-"` +} + +// rankingTimeseriesGroupsResponseSerie0JSON contains the JSON metadata for the +// struct [RankingTimeseriesGroupsResponseSerie0] +type rankingTimeseriesGroupsResponseSerie0JSON struct { + Timestamps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RankingTimeseriesGroupsResponseSerie0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rankingTimeseriesGroupsResponseSerie0JSON) RawJSON() string { + return r.raw +} + +type RankingTopResponse struct { + Meta RankingTopResponseMeta `json:"meta,required"` + Top0 []RankingTopResponseTop0 `json:"top_0,required"` + JSON rankingTopResponseJSON `json:"-"` +} + +// rankingTopResponseJSON contains the JSON metadata for the struct +// [RankingTopResponse] +type rankingTopResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RankingTopResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rankingTopResponseJSON) RawJSON() string { + return r.raw +} + +type RankingTopResponseMeta struct { + Top0 RankingTopResponseMetaTop0 `json:"top_0,required"` + JSON rankingTopResponseMetaJSON `json:"-"` +} + +// rankingTopResponseMetaJSON contains the JSON metadata for the struct +// [RankingTopResponseMeta] +type rankingTopResponseMetaJSON struct { + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RankingTopResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rankingTopResponseMetaJSON) RawJSON() string { + return r.raw +} + +type RankingTopResponseMetaTop0 struct { + Date string `json:"date,required"` + JSON rankingTopResponseMetaTop0JSON `json:"-"` +} + +// rankingTopResponseMetaTop0JSON contains the JSON metadata for the struct +// [RankingTopResponseMetaTop0] +type rankingTopResponseMetaTop0JSON struct { + Date apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RankingTopResponseMetaTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rankingTopResponseMetaTop0JSON) RawJSON() string { + return r.raw +} + +type RankingTopResponseTop0 struct { + Categories []RankingTopResponseTop0Category `json:"categories,required"` + Domain string `json:"domain,required"` + Rank int64 `json:"rank,required"` + // Only available in TRENDING rankings. + PctRankChange float64 `json:"pctRankChange"` + JSON rankingTopResponseTop0JSON `json:"-"` +} + +// rankingTopResponseTop0JSON contains the JSON metadata for the struct +// [RankingTopResponseTop0] +type rankingTopResponseTop0JSON struct { + Categories apijson.Field + Domain apijson.Field + Rank apijson.Field + PctRankChange apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RankingTopResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rankingTopResponseTop0JSON) RawJSON() string { + return r.raw +} + +type RankingTopResponseTop0Category struct { + ID float64 `json:"id,required"` + Name string `json:"name,required"` + SuperCategoryID float64 `json:"superCategoryId,required"` + JSON rankingTopResponseTop0CategoryJSON `json:"-"` +} + +// rankingTopResponseTop0CategoryJSON contains the JSON metadata for the struct +// [RankingTopResponseTop0Category] +type rankingTopResponseTop0CategoryJSON struct { + ID apijson.Field + Name apijson.Field + SuperCategoryID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RankingTopResponseTop0Category) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rankingTopResponseTop0CategoryJSON) RawJSON() string { + return r.raw +} + +type RankingTimeseriesGroupsParams struct { + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]RankingTimeseriesGroupsParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Array of comma separated list of domains names. + Domains param.Field[[]string] `query:"domains"` + // Format results are returned in. + Format param.Field[RankingTimeseriesGroupsParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of locations (alpha-2 country codes). + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // The ranking type. + RankingType param.Field[RankingTimeseriesGroupsParamsRankingType] `query:"rankingType"` +} + +// URLQuery serializes [RankingTimeseriesGroupsParams]'s query parameters as +// `url.Values`. +func (r RankingTimeseriesGroupsParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type RankingTimeseriesGroupsParamsDateRange string + +const ( + RankingTimeseriesGroupsParamsDateRange1d RankingTimeseriesGroupsParamsDateRange = "1d" + RankingTimeseriesGroupsParamsDateRange2d RankingTimeseriesGroupsParamsDateRange = "2d" + RankingTimeseriesGroupsParamsDateRange7d RankingTimeseriesGroupsParamsDateRange = "7d" + RankingTimeseriesGroupsParamsDateRange14d RankingTimeseriesGroupsParamsDateRange = "14d" + RankingTimeseriesGroupsParamsDateRange28d RankingTimeseriesGroupsParamsDateRange = "28d" + RankingTimeseriesGroupsParamsDateRange12w RankingTimeseriesGroupsParamsDateRange = "12w" + RankingTimeseriesGroupsParamsDateRange24w RankingTimeseriesGroupsParamsDateRange = "24w" + RankingTimeseriesGroupsParamsDateRange52w RankingTimeseriesGroupsParamsDateRange = "52w" + RankingTimeseriesGroupsParamsDateRange1dControl RankingTimeseriesGroupsParamsDateRange = "1dControl" + RankingTimeseriesGroupsParamsDateRange2dControl RankingTimeseriesGroupsParamsDateRange = "2dControl" + RankingTimeseriesGroupsParamsDateRange7dControl RankingTimeseriesGroupsParamsDateRange = "7dControl" + RankingTimeseriesGroupsParamsDateRange14dControl RankingTimeseriesGroupsParamsDateRange = "14dControl" + RankingTimeseriesGroupsParamsDateRange28dControl RankingTimeseriesGroupsParamsDateRange = "28dControl" + RankingTimeseriesGroupsParamsDateRange12wControl RankingTimeseriesGroupsParamsDateRange = "12wControl" + RankingTimeseriesGroupsParamsDateRange24wControl RankingTimeseriesGroupsParamsDateRange = "24wControl" +) + +// Format results are returned in. +type RankingTimeseriesGroupsParamsFormat string + +const ( + RankingTimeseriesGroupsParamsFormatJson RankingTimeseriesGroupsParamsFormat = "JSON" + RankingTimeseriesGroupsParamsFormatCsv RankingTimeseriesGroupsParamsFormat = "CSV" +) + +// The ranking type. +type RankingTimeseriesGroupsParamsRankingType string + +const ( + RankingTimeseriesGroupsParamsRankingTypePopular RankingTimeseriesGroupsParamsRankingType = "POPULAR" + RankingTimeseriesGroupsParamsRankingTypeTrendingRise RankingTimeseriesGroupsParamsRankingType = "TRENDING_RISE" + RankingTimeseriesGroupsParamsRankingTypeTrendingSteady RankingTimeseriesGroupsParamsRankingType = "TRENDING_STEADY" +) + +type RankingTimeseriesGroupsResponseEnvelope struct { + Result RankingTimeseriesGroupsResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON rankingTimeseriesGroupsResponseEnvelopeJSON `json:"-"` +} + +// rankingTimeseriesGroupsResponseEnvelopeJSON contains the JSON metadata for the +// struct [RankingTimeseriesGroupsResponseEnvelope] +type rankingTimeseriesGroupsResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RankingTimeseriesGroupsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rankingTimeseriesGroupsResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RankingTopParams struct { + // Array of dates to filter the ranking. + Date param.Field[[]string] `query:"date"` + // Format results are returned in. + Format param.Field[RankingTopParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of locations (alpha-2 country codes). + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // The ranking type. + RankingType param.Field[RankingTopParamsRankingType] `query:"rankingType"` +} + +// URLQuery serializes [RankingTopParams]'s query parameters as `url.Values`. +func (r RankingTopParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Format results are returned in. +type RankingTopParamsFormat string + +const ( + RankingTopParamsFormatJson RankingTopParamsFormat = "JSON" + RankingTopParamsFormatCsv RankingTopParamsFormat = "CSV" +) + +// The ranking type. +type RankingTopParamsRankingType string + +const ( + RankingTopParamsRankingTypePopular RankingTopParamsRankingType = "POPULAR" + RankingTopParamsRankingTypeTrendingRise RankingTopParamsRankingType = "TRENDING_RISE" + RankingTopParamsRankingTypeTrendingSteady RankingTopParamsRankingType = "TRENDING_STEADY" +) + +type RankingTopResponseEnvelope struct { + Result RankingTopResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON rankingTopResponseEnvelopeJSON `json:"-"` +} + +// rankingTopResponseEnvelopeJSON contains the JSON metadata for the struct +// [RankingTopResponseEnvelope] +type rankingTopResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RankingTopResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rankingTopResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/ranking_test.go b/radar/ranking_test.go new file mode 100644 index 00000000000..cbcf4264686 --- /dev/null +++ b/radar/ranking_test.go @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestRankingTimeseriesGroupsWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Ranking.TimeseriesGroups(context.TODO(), radar.RankingTimeseriesGroupsParams{ + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.RankingTimeseriesGroupsParamsDateRange{radar.RankingTimeseriesGroupsParamsDateRange1d, radar.RankingTimeseriesGroupsParamsDateRange2d, radar.RankingTimeseriesGroupsParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Domains: cloudflare.F([]string{"string", "string", "string"}), + Format: cloudflare.F(radar.RankingTimeseriesGroupsParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + RankingType: cloudflare.F(radar.RankingTimeseriesGroupsParamsRankingTypePopular), + }) + 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 TestRankingTopWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Ranking.Top(context.TODO(), radar.RankingTopParams{ + Date: cloudflare.F([]string{"string", "string", "string"}), + Format: cloudflare.F(radar.RankingTopParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + RankingType: cloudflare.F(radar.RankingTopParamsRankingTypePopular), + }) + 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/radar/rankingdomain.go b/radar/rankingdomain.go new file mode 100644 index 00000000000..895a10bdecb --- /dev/null +++ b/radar/rankingdomain.go @@ -0,0 +1,210 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// RankingDomainService 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 [NewRankingDomainService] method +// instead. +type RankingDomainService struct { + Options []option.RequestOption +} + +// NewRankingDomainService 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 NewRankingDomainService(opts ...option.RequestOption) (r *RankingDomainService) { + r = &RankingDomainService{} + r.Options = opts + return +} + +// Gets Domains Rank details. Cloudflare provides an ordered rank for the top 100 +// domains, but for the remainder it only provides ranking buckets like top 200 +// thousand, top one million, etc.. These are available through Radar datasets +// endpoints. +func (r *RankingDomainService) Get(ctx context.Context, domain string, query RankingDomainGetParams, opts ...option.RequestOption) (res *RankingDomainGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RankingDomainGetResponseEnvelope + path := fmt.Sprintf("radar/ranking/domain/%s", domain) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type RankingDomainGetResponse struct { + Details0 RankingDomainGetResponseDetails0 `json:"details_0,required"` + JSON rankingDomainGetResponseJSON `json:"-"` +} + +// rankingDomainGetResponseJSON contains the JSON metadata for the struct +// [RankingDomainGetResponse] +type rankingDomainGetResponseJSON struct { + Details0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RankingDomainGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rankingDomainGetResponseJSON) RawJSON() string { + return r.raw +} + +type RankingDomainGetResponseDetails0 struct { + Categories []RankingDomainGetResponseDetails0Category `json:"categories,required"` + TopLocations []RankingDomainGetResponseDetails0TopLocation `json:"top_locations,required"` + // Only available in POPULAR ranking for the most recent ranking. + Bucket string `json:"bucket"` + Rank int64 `json:"rank"` + JSON rankingDomainGetResponseDetails0JSON `json:"-"` +} + +// rankingDomainGetResponseDetails0JSON contains the JSON metadata for the struct +// [RankingDomainGetResponseDetails0] +type rankingDomainGetResponseDetails0JSON struct { + Categories apijson.Field + TopLocations apijson.Field + Bucket apijson.Field + Rank apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RankingDomainGetResponseDetails0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rankingDomainGetResponseDetails0JSON) RawJSON() string { + return r.raw +} + +type RankingDomainGetResponseDetails0Category struct { + ID float64 `json:"id,required"` + Name string `json:"name,required"` + SuperCategoryID float64 `json:"superCategoryId,required"` + JSON rankingDomainGetResponseDetails0CategoryJSON `json:"-"` +} + +// rankingDomainGetResponseDetails0CategoryJSON contains the JSON metadata for the +// struct [RankingDomainGetResponseDetails0Category] +type rankingDomainGetResponseDetails0CategoryJSON struct { + ID apijson.Field + Name apijson.Field + SuperCategoryID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RankingDomainGetResponseDetails0Category) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rankingDomainGetResponseDetails0CategoryJSON) RawJSON() string { + return r.raw +} + +type RankingDomainGetResponseDetails0TopLocation struct { + LocationCode string `json:"locationCode,required"` + LocationName string `json:"locationName,required"` + Rank int64 `json:"rank,required"` + JSON rankingDomainGetResponseDetails0TopLocationJSON `json:"-"` +} + +// rankingDomainGetResponseDetails0TopLocationJSON contains the JSON metadata for +// the struct [RankingDomainGetResponseDetails0TopLocation] +type rankingDomainGetResponseDetails0TopLocationJSON struct { + LocationCode apijson.Field + LocationName apijson.Field + Rank apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RankingDomainGetResponseDetails0TopLocation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rankingDomainGetResponseDetails0TopLocationJSON) RawJSON() string { + return r.raw +} + +type RankingDomainGetParams struct { + // Array of dates to filter the ranking. + Date param.Field[[]string] `query:"date"` + // Format results are returned in. + Format param.Field[RankingDomainGetParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` + // The ranking type. + RankingType param.Field[RankingDomainGetParamsRankingType] `query:"rankingType"` +} + +// URLQuery serializes [RankingDomainGetParams]'s query parameters as `url.Values`. +func (r RankingDomainGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Format results are returned in. +type RankingDomainGetParamsFormat string + +const ( + RankingDomainGetParamsFormatJson RankingDomainGetParamsFormat = "JSON" + RankingDomainGetParamsFormatCsv RankingDomainGetParamsFormat = "CSV" +) + +// The ranking type. +type RankingDomainGetParamsRankingType string + +const ( + RankingDomainGetParamsRankingTypePopular RankingDomainGetParamsRankingType = "POPULAR" + RankingDomainGetParamsRankingTypeTrendingRise RankingDomainGetParamsRankingType = "TRENDING_RISE" + RankingDomainGetParamsRankingTypeTrendingSteady RankingDomainGetParamsRankingType = "TRENDING_STEADY" +) + +type RankingDomainGetResponseEnvelope struct { + Result RankingDomainGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON rankingDomainGetResponseEnvelopeJSON `json:"-"` +} + +// rankingDomainGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RankingDomainGetResponseEnvelope] +type rankingDomainGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RankingDomainGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rankingDomainGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/rankingdomain_test.go b/radar/rankingdomain_test.go new file mode 100644 index 00000000000..e72a8bcf9f9 --- /dev/null +++ b/radar/rankingdomain_test.go @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestRankingDomainGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Ranking.Domain.Get( + context.TODO(), + "google.com", + radar.RankingDomainGetParams{ + Date: cloudflare.F([]string{"string", "string", "string"}), + Format: cloudflare.F(radar.RankingDomainGetParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Name: cloudflare.F([]string{"string", "string", "string"}), + RankingType: cloudflare.F(radar.RankingDomainGetParamsRankingTypePopular), + }, + ) + 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/radar/search.go b/radar/search.go new file mode 100644 index 00000000000..df707c6c372 --- /dev/null +++ b/radar/search.go @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SearchService 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 [NewSearchService] method instead. +type SearchService struct { + Options []option.RequestOption +} + +// NewSearchService 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 NewSearchService(opts ...option.RequestOption) (r *SearchService) { + r = &SearchService{} + r.Options = opts + return +} + +// Lets you search for locations, autonomous systems (AS) and reports. +func (r *SearchService) Global(ctx context.Context, query SearchGlobalParams, opts ...option.RequestOption) (res *SearchGlobalResponse, err error) { + opts = append(r.Options[:], opts...) + var env SearchGlobalResponseEnvelope + path := "radar/search/global" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type SearchGlobalResponse struct { + Search []SearchGlobalResponseSearch `json:"search,required"` + JSON searchGlobalResponseJSON `json:"-"` +} + +// searchGlobalResponseJSON contains the JSON metadata for the struct +// [SearchGlobalResponse] +type searchGlobalResponseJSON struct { + Search apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SearchGlobalResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r searchGlobalResponseJSON) RawJSON() string { + return r.raw +} + +type SearchGlobalResponseSearch struct { + Code string `json:"code,required"` + Name string `json:"name,required"` + Type string `json:"type,required"` + JSON searchGlobalResponseSearchJSON `json:"-"` +} + +// searchGlobalResponseSearchJSON contains the JSON metadata for the struct +// [SearchGlobalResponseSearch] +type searchGlobalResponseSearchJSON struct { + Code apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SearchGlobalResponseSearch) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r searchGlobalResponseSearchJSON) RawJSON() string { + return r.raw +} + +type SearchGlobalParams struct { + // Search for locations, AS and reports. + Query param.Field[string] `query:"query,required"` + // Search types to be excluded from results. + Exclude param.Field[[]SearchGlobalParamsExclude] `query:"exclude"` + // Format results are returned in. + Format param.Field[SearchGlobalParamsFormat] `query:"format"` + // Search types to be included in results. + Include param.Field[[]SearchGlobalParamsInclude] `query:"include"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Limit the number of objects per search category. + LimitPerGroup param.Field[float64] `query:"limitPerGroup"` +} + +// URLQuery serializes [SearchGlobalParams]'s query parameters as `url.Values`. +func (r SearchGlobalParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type SearchGlobalParamsExclude string + +const ( + SearchGlobalParamsExcludeSpecialEvents SearchGlobalParamsExclude = "SPECIAL_EVENTS" + SearchGlobalParamsExcludeNotebooks SearchGlobalParamsExclude = "NOTEBOOKS" + SearchGlobalParamsExcludeLocations SearchGlobalParamsExclude = "LOCATIONS" + SearchGlobalParamsExcludeASNs SearchGlobalParamsExclude = "ASNS" +) + +// Format results are returned in. +type SearchGlobalParamsFormat string + +const ( + SearchGlobalParamsFormatJson SearchGlobalParamsFormat = "JSON" + SearchGlobalParamsFormatCsv SearchGlobalParamsFormat = "CSV" +) + +type SearchGlobalParamsInclude string + +const ( + SearchGlobalParamsIncludeSpecialEvents SearchGlobalParamsInclude = "SPECIAL_EVENTS" + SearchGlobalParamsIncludeNotebooks SearchGlobalParamsInclude = "NOTEBOOKS" + SearchGlobalParamsIncludeLocations SearchGlobalParamsInclude = "LOCATIONS" + SearchGlobalParamsIncludeASNs SearchGlobalParamsInclude = "ASNS" +) + +type SearchGlobalResponseEnvelope struct { + Result SearchGlobalResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON searchGlobalResponseEnvelopeJSON `json:"-"` +} + +// searchGlobalResponseEnvelopeJSON contains the JSON metadata for the struct +// [SearchGlobalResponseEnvelope] +type searchGlobalResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SearchGlobalResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r searchGlobalResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/search_test.go b/radar/search_test.go new file mode 100644 index 00000000000..e1c6594203e --- /dev/null +++ b/radar/search_test.go @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestSearchGlobalWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.Search.Global(context.TODO(), radar.SearchGlobalParams{ + Query: cloudflare.F("United"), + Exclude: cloudflare.F([]radar.SearchGlobalParamsExclude{radar.SearchGlobalParamsExcludeSpecialEvents, radar.SearchGlobalParamsExcludeNotebooks, radar.SearchGlobalParamsExcludeLocations}), + Format: cloudflare.F(radar.SearchGlobalParamsFormatJson), + Include: cloudflare.F([]radar.SearchGlobalParamsInclude{radar.SearchGlobalParamsIncludeSpecialEvents, radar.SearchGlobalParamsIncludeNotebooks, radar.SearchGlobalParamsIncludeLocations}), + Limit: cloudflare.F(int64(5)), + LimitPerGroup: cloudflare.F(0.000000), + }) + 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/radar/trafficanomaly.go b/radar/trafficanomaly.go new file mode 100644 index 00000000000..8ab61cfd6eb --- /dev/null +++ b/radar/trafficanomaly.go @@ -0,0 +1,270 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// TrafficAnomalyService 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 [NewTrafficAnomalyService] method +// instead. +type TrafficAnomalyService struct { + Options []option.RequestOption + Locations *TrafficAnomalyLocationService +} + +// NewTrafficAnomalyService 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 NewTrafficAnomalyService(opts ...option.RequestOption) (r *TrafficAnomalyService) { + r = &TrafficAnomalyService{} + r.Options = opts + r.Locations = NewTrafficAnomalyLocationService(opts...) + return +} + +// Internet traffic anomalies are signals that might point to an outage, These +// alerts are automatically detected by Radar and then manually verified by our +// team. This endpoint returns the latest alerts. +func (r *TrafficAnomalyService) Get(ctx context.Context, query TrafficAnomalyGetParams, opts ...option.RequestOption) (res *TrafficAnomalyGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env TrafficAnomalyGetResponseEnvelope + path := "radar/traffic_anomalies" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TrafficAnomalyGetResponse struct { + TrafficAnomalies []TrafficAnomalyGetResponseTrafficAnomaly `json:"trafficAnomalies,required"` + JSON trafficAnomalyGetResponseJSON `json:"-"` +} + +// trafficAnomalyGetResponseJSON contains the JSON metadata for the struct +// [TrafficAnomalyGetResponse] +type trafficAnomalyGetResponseJSON struct { + TrafficAnomalies apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TrafficAnomalyGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r trafficAnomalyGetResponseJSON) RawJSON() string { + return r.raw +} + +type TrafficAnomalyGetResponseTrafficAnomaly struct { + StartDate string `json:"startDate,required"` + Status string `json:"status,required"` + Type string `json:"type,required"` + UUID string `json:"uuid,required"` + ASNDetails TrafficAnomalyGetResponseTrafficAnomaliesASNDetails `json:"asnDetails"` + EndDate string `json:"endDate"` + LocationDetails TrafficAnomalyGetResponseTrafficAnomaliesLocationDetails `json:"locationDetails"` + VisibleInDataSources []string `json:"visibleInDataSources"` + JSON trafficAnomalyGetResponseTrafficAnomalyJSON `json:"-"` +} + +// trafficAnomalyGetResponseTrafficAnomalyJSON contains the JSON metadata for the +// struct [TrafficAnomalyGetResponseTrafficAnomaly] +type trafficAnomalyGetResponseTrafficAnomalyJSON struct { + StartDate apijson.Field + Status apijson.Field + Type apijson.Field + UUID apijson.Field + ASNDetails apijson.Field + EndDate apijson.Field + LocationDetails apijson.Field + VisibleInDataSources apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TrafficAnomalyGetResponseTrafficAnomaly) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r trafficAnomalyGetResponseTrafficAnomalyJSON) RawJSON() string { + return r.raw +} + +type TrafficAnomalyGetResponseTrafficAnomaliesASNDetails struct { + ASN string `json:"asn,required"` + Name string `json:"name,required"` + Locations TrafficAnomalyGetResponseTrafficAnomaliesASNDetailsLocations `json:"locations"` + JSON trafficAnomalyGetResponseTrafficAnomaliesASNDetailsJSON `json:"-"` +} + +// trafficAnomalyGetResponseTrafficAnomaliesASNDetailsJSON contains the JSON +// metadata for the struct [TrafficAnomalyGetResponseTrafficAnomaliesASNDetails] +type trafficAnomalyGetResponseTrafficAnomaliesASNDetailsJSON struct { + ASN apijson.Field + Name apijson.Field + Locations apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TrafficAnomalyGetResponseTrafficAnomaliesASNDetails) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r trafficAnomalyGetResponseTrafficAnomaliesASNDetailsJSON) RawJSON() string { + return r.raw +} + +type TrafficAnomalyGetResponseTrafficAnomaliesASNDetailsLocations struct { + Code string `json:"code,required"` + Name string `json:"name,required"` + JSON trafficAnomalyGetResponseTrafficAnomaliesASNDetailsLocationsJSON `json:"-"` +} + +// trafficAnomalyGetResponseTrafficAnomaliesASNDetailsLocationsJSON contains the +// JSON metadata for the struct +// [TrafficAnomalyGetResponseTrafficAnomaliesASNDetailsLocations] +type trafficAnomalyGetResponseTrafficAnomaliesASNDetailsLocationsJSON struct { + Code apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TrafficAnomalyGetResponseTrafficAnomaliesASNDetailsLocations) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r trafficAnomalyGetResponseTrafficAnomaliesASNDetailsLocationsJSON) RawJSON() string { + return r.raw +} + +type TrafficAnomalyGetResponseTrafficAnomaliesLocationDetails struct { + Code string `json:"code,required"` + Name string `json:"name,required"` + JSON trafficAnomalyGetResponseTrafficAnomaliesLocationDetailsJSON `json:"-"` +} + +// trafficAnomalyGetResponseTrafficAnomaliesLocationDetailsJSON contains the JSON +// metadata for the struct +// [TrafficAnomalyGetResponseTrafficAnomaliesLocationDetails] +type trafficAnomalyGetResponseTrafficAnomaliesLocationDetailsJSON struct { + Code apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TrafficAnomalyGetResponseTrafficAnomaliesLocationDetails) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r trafficAnomalyGetResponseTrafficAnomaliesLocationDetailsJSON) RawJSON() string { + return r.raw +} + +type TrafficAnomalyGetParams struct { + // Single ASN as integer. + ASN param.Field[int64] `query:"asn"` + // End of the date range (inclusive). + DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"` + // Shorthand date ranges for the last X days - use when you don't need specific + // start and end dates. + DateRange param.Field[TrafficAnomalyGetParamsDateRange] `query:"dateRange"` + // Start of the date range (inclusive). + DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[TrafficAnomalyGetParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Location Alpha2 code. + Location param.Field[string] `query:"location"` + // Number of objects to skip before grabbing results. + Offset param.Field[int64] `query:"offset"` + Status param.Field[TrafficAnomalyGetParamsStatus] `query:"status"` +} + +// URLQuery serializes [TrafficAnomalyGetParams]'s query parameters as +// `url.Values`. +func (r TrafficAnomalyGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Shorthand date ranges for the last X days - use when you don't need specific +// start and end dates. +type TrafficAnomalyGetParamsDateRange string + +const ( + TrafficAnomalyGetParamsDateRange1d TrafficAnomalyGetParamsDateRange = "1d" + TrafficAnomalyGetParamsDateRange2d TrafficAnomalyGetParamsDateRange = "2d" + TrafficAnomalyGetParamsDateRange7d TrafficAnomalyGetParamsDateRange = "7d" + TrafficAnomalyGetParamsDateRange14d TrafficAnomalyGetParamsDateRange = "14d" + TrafficAnomalyGetParamsDateRange28d TrafficAnomalyGetParamsDateRange = "28d" + TrafficAnomalyGetParamsDateRange12w TrafficAnomalyGetParamsDateRange = "12w" + TrafficAnomalyGetParamsDateRange24w TrafficAnomalyGetParamsDateRange = "24w" + TrafficAnomalyGetParamsDateRange52w TrafficAnomalyGetParamsDateRange = "52w" + TrafficAnomalyGetParamsDateRange1dControl TrafficAnomalyGetParamsDateRange = "1dControl" + TrafficAnomalyGetParamsDateRange2dControl TrafficAnomalyGetParamsDateRange = "2dControl" + TrafficAnomalyGetParamsDateRange7dControl TrafficAnomalyGetParamsDateRange = "7dControl" + TrafficAnomalyGetParamsDateRange14dControl TrafficAnomalyGetParamsDateRange = "14dControl" + TrafficAnomalyGetParamsDateRange28dControl TrafficAnomalyGetParamsDateRange = "28dControl" + TrafficAnomalyGetParamsDateRange12wControl TrafficAnomalyGetParamsDateRange = "12wControl" + TrafficAnomalyGetParamsDateRange24wControl TrafficAnomalyGetParamsDateRange = "24wControl" +) + +// Format results are returned in. +type TrafficAnomalyGetParamsFormat string + +const ( + TrafficAnomalyGetParamsFormatJson TrafficAnomalyGetParamsFormat = "JSON" + TrafficAnomalyGetParamsFormatCsv TrafficAnomalyGetParamsFormat = "CSV" +) + +type TrafficAnomalyGetParamsStatus string + +const ( + TrafficAnomalyGetParamsStatusVerified TrafficAnomalyGetParamsStatus = "VERIFIED" + TrafficAnomalyGetParamsStatusUnverified TrafficAnomalyGetParamsStatus = "UNVERIFIED" +) + +type TrafficAnomalyGetResponseEnvelope struct { + Result TrafficAnomalyGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON trafficAnomalyGetResponseEnvelopeJSON `json:"-"` +} + +// trafficAnomalyGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [TrafficAnomalyGetResponseEnvelope] +type trafficAnomalyGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TrafficAnomalyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r trafficAnomalyGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/trafficanomaly_test.go b/radar/trafficanomaly_test.go new file mode 100644 index 00000000000..1c6ee3aa7b2 --- /dev/null +++ b/radar/trafficanomaly_test.go @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestTrafficAnomalyGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.TrafficAnomalies.Get(context.TODO(), radar.TrafficAnomalyGetParams{ + ASN: cloudflare.F(int64(0)), + DateEnd: cloudflare.F(time.Now()), + DateRange: cloudflare.F(radar.TrafficAnomalyGetParamsDateRange7d), + DateStart: cloudflare.F(time.Now()), + Format: cloudflare.F(radar.TrafficAnomalyGetParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F("US"), + Offset: cloudflare.F(int64(0)), + Status: cloudflare.F(radar.TrafficAnomalyGetParamsStatusVerified), + }) + 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/radar/trafficanomalylocation.go b/radar/trafficanomalylocation.go new file mode 100644 index 00000000000..98f4371fb6b --- /dev/null +++ b/radar/trafficanomalylocation.go @@ -0,0 +1,179 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// TrafficAnomalyLocationService 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 [NewTrafficAnomalyLocationService] +// method instead. +type TrafficAnomalyLocationService struct { + Options []option.RequestOption +} + +// NewTrafficAnomalyLocationService 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 NewTrafficAnomalyLocationService(opts ...option.RequestOption) (r *TrafficAnomalyLocationService) { + r = &TrafficAnomalyLocationService{} + r.Options = opts + return +} + +// Internet traffic anomalies are signals that might point to an outage, These +// alerts are automatically detected by Radar and then manually verified by our +// team. This endpoint returns the sum of alerts grouped by location. +func (r *TrafficAnomalyLocationService) Get(ctx context.Context, query TrafficAnomalyLocationGetParams, opts ...option.RequestOption) (res *TrafficAnomalyLocationGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env TrafficAnomalyLocationGetResponseEnvelope + path := "radar/traffic_anomalies/locations" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TrafficAnomalyLocationGetResponse struct { + TrafficAnomalies []TrafficAnomalyLocationGetResponseTrafficAnomaly `json:"trafficAnomalies,required"` + JSON trafficAnomalyLocationGetResponseJSON `json:"-"` +} + +// trafficAnomalyLocationGetResponseJSON contains the JSON metadata for the struct +// [TrafficAnomalyLocationGetResponse] +type trafficAnomalyLocationGetResponseJSON struct { + TrafficAnomalies apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TrafficAnomalyLocationGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r trafficAnomalyLocationGetResponseJSON) RawJSON() string { + return r.raw +} + +type TrafficAnomalyLocationGetResponseTrafficAnomaly struct { + ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` + ClientCountryName string `json:"clientCountryName,required"` + Value string `json:"value,required"` + JSON trafficAnomalyLocationGetResponseTrafficAnomalyJSON `json:"-"` +} + +// trafficAnomalyLocationGetResponseTrafficAnomalyJSON contains the JSON metadata +// for the struct [TrafficAnomalyLocationGetResponseTrafficAnomaly] +type trafficAnomalyLocationGetResponseTrafficAnomalyJSON struct { + ClientCountryAlpha2 apijson.Field + ClientCountryName apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TrafficAnomalyLocationGetResponseTrafficAnomaly) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r trafficAnomalyLocationGetResponseTrafficAnomalyJSON) RawJSON() string { + return r.raw +} + +type TrafficAnomalyLocationGetParams struct { + // End of the date range (inclusive). + DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"` + // Shorthand date ranges for the last X days - use when you don't need specific + // start and end dates. + DateRange param.Field[TrafficAnomalyLocationGetParamsDateRange] `query:"dateRange"` + // Start of the date range (inclusive). + DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[TrafficAnomalyLocationGetParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + Status param.Field[TrafficAnomalyLocationGetParamsStatus] `query:"status"` +} + +// URLQuery serializes [TrafficAnomalyLocationGetParams]'s query parameters as +// `url.Values`. +func (r TrafficAnomalyLocationGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Shorthand date ranges for the last X days - use when you don't need specific +// start and end dates. +type TrafficAnomalyLocationGetParamsDateRange string + +const ( + TrafficAnomalyLocationGetParamsDateRange1d TrafficAnomalyLocationGetParamsDateRange = "1d" + TrafficAnomalyLocationGetParamsDateRange2d TrafficAnomalyLocationGetParamsDateRange = "2d" + TrafficAnomalyLocationGetParamsDateRange7d TrafficAnomalyLocationGetParamsDateRange = "7d" + TrafficAnomalyLocationGetParamsDateRange14d TrafficAnomalyLocationGetParamsDateRange = "14d" + TrafficAnomalyLocationGetParamsDateRange28d TrafficAnomalyLocationGetParamsDateRange = "28d" + TrafficAnomalyLocationGetParamsDateRange12w TrafficAnomalyLocationGetParamsDateRange = "12w" + TrafficAnomalyLocationGetParamsDateRange24w TrafficAnomalyLocationGetParamsDateRange = "24w" + TrafficAnomalyLocationGetParamsDateRange52w TrafficAnomalyLocationGetParamsDateRange = "52w" + TrafficAnomalyLocationGetParamsDateRange1dControl TrafficAnomalyLocationGetParamsDateRange = "1dControl" + TrafficAnomalyLocationGetParamsDateRange2dControl TrafficAnomalyLocationGetParamsDateRange = "2dControl" + TrafficAnomalyLocationGetParamsDateRange7dControl TrafficAnomalyLocationGetParamsDateRange = "7dControl" + TrafficAnomalyLocationGetParamsDateRange14dControl TrafficAnomalyLocationGetParamsDateRange = "14dControl" + TrafficAnomalyLocationGetParamsDateRange28dControl TrafficAnomalyLocationGetParamsDateRange = "28dControl" + TrafficAnomalyLocationGetParamsDateRange12wControl TrafficAnomalyLocationGetParamsDateRange = "12wControl" + TrafficAnomalyLocationGetParamsDateRange24wControl TrafficAnomalyLocationGetParamsDateRange = "24wControl" +) + +// Format results are returned in. +type TrafficAnomalyLocationGetParamsFormat string + +const ( + TrafficAnomalyLocationGetParamsFormatJson TrafficAnomalyLocationGetParamsFormat = "JSON" + TrafficAnomalyLocationGetParamsFormatCsv TrafficAnomalyLocationGetParamsFormat = "CSV" +) + +type TrafficAnomalyLocationGetParamsStatus string + +const ( + TrafficAnomalyLocationGetParamsStatusVerified TrafficAnomalyLocationGetParamsStatus = "VERIFIED" + TrafficAnomalyLocationGetParamsStatusUnverified TrafficAnomalyLocationGetParamsStatus = "UNVERIFIED" +) + +type TrafficAnomalyLocationGetResponseEnvelope struct { + Result TrafficAnomalyLocationGetResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON trafficAnomalyLocationGetResponseEnvelopeJSON `json:"-"` +} + +// trafficAnomalyLocationGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [TrafficAnomalyLocationGetResponseEnvelope] +type trafficAnomalyLocationGetResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TrafficAnomalyLocationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r trafficAnomalyLocationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/trafficanomalylocation_test.go b/radar/trafficanomalylocation_test.go new file mode 100644 index 00000000000..89671cf2330 --- /dev/null +++ b/radar/trafficanomalylocation_test.go @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestTrafficAnomalyLocationGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.TrafficAnomalies.Locations.Get(context.TODO(), radar.TrafficAnomalyLocationGetParams{ + DateEnd: cloudflare.F(time.Now()), + DateRange: cloudflare.F(radar.TrafficAnomalyLocationGetParamsDateRange7d), + DateStart: cloudflare.F(time.Now()), + Format: cloudflare.F(radar.TrafficAnomalyLocationGetParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Status: cloudflare.F(radar.TrafficAnomalyLocationGetParamsStatusVerified), + }) + 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/radar/verifiedbot.go b/radar/verifiedbot.go new file mode 100644 index 00000000000..efc73a04f66 --- /dev/null +++ b/radar/verifiedbot.go @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// VerifiedBotService 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 [NewVerifiedBotService] method +// instead. +type VerifiedBotService struct { + Options []option.RequestOption + Top *VerifiedBotTopService +} + +// NewVerifiedBotService 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 NewVerifiedBotService(opts ...option.RequestOption) (r *VerifiedBotService) { + r = &VerifiedBotService{} + r.Options = opts + r.Top = NewVerifiedBotTopService(opts...) + return +} diff --git a/radar/verifiedbottop.go b/radar/verifiedbottop.go new file mode 100644 index 00000000000..5b023189c29 --- /dev/null +++ b/radar/verifiedbottop.go @@ -0,0 +1,544 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// VerifiedBotTopService 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 [NewVerifiedBotTopService] method +// instead. +type VerifiedBotTopService struct { + Options []option.RequestOption +} + +// NewVerifiedBotTopService 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 NewVerifiedBotTopService(opts ...option.RequestOption) (r *VerifiedBotTopService) { + r = &VerifiedBotTopService{} + r.Options = opts + return +} + +// Get top verified bots by HTTP requests, with owner and category. +func (r *VerifiedBotTopService) Bots(ctx context.Context, query VerifiedBotTopBotsParams, opts ...option.RequestOption) (res *VerifiedBotTopBotsResponse, err error) { + opts = append(r.Options[:], opts...) + var env VerifiedBotTopBotsResponseEnvelope + path := "radar/verified_bots/top/bots" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get top verified bot categories by HTTP requests, along with their corresponding +// percentage, over the total verified bot HTTP requests. +func (r *VerifiedBotTopService) Categories(ctx context.Context, query VerifiedBotTopCategoriesParams, opts ...option.RequestOption) (res *VerifiedBotTopCategoriesResponse, err error) { + opts = append(r.Options[:], opts...) + var env VerifiedBotTopCategoriesResponseEnvelope + path := "radar/verified_bots/top/categories" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type VerifiedBotTopBotsResponse struct { + Meta VerifiedBotTopBotsResponseMeta `json:"meta,required"` + Top0 []VerifiedBotTopBotsResponseTop0 `json:"top_0,required"` + JSON verifiedBotTopBotsResponseJSON `json:"-"` +} + +// verifiedBotTopBotsResponseJSON contains the JSON metadata for the struct +// [VerifiedBotTopBotsResponse] +type verifiedBotTopBotsResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerifiedBotTopBotsResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verifiedBotTopBotsResponseJSON) RawJSON() string { + return r.raw +} + +type VerifiedBotTopBotsResponseMeta struct { + DateRange []VerifiedBotTopBotsResponseMetaDateRange `json:"dateRange,required"` + ConfidenceInfo VerifiedBotTopBotsResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON verifiedBotTopBotsResponseMetaJSON `json:"-"` +} + +// verifiedBotTopBotsResponseMetaJSON contains the JSON metadata for the struct +// [VerifiedBotTopBotsResponseMeta] +type verifiedBotTopBotsResponseMetaJSON struct { + DateRange apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerifiedBotTopBotsResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verifiedBotTopBotsResponseMetaJSON) RawJSON() string { + return r.raw +} + +type VerifiedBotTopBotsResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON verifiedBotTopBotsResponseMetaDateRangeJSON `json:"-"` +} + +// verifiedBotTopBotsResponseMetaDateRangeJSON contains the JSON metadata for the +// struct [VerifiedBotTopBotsResponseMetaDateRange] +type verifiedBotTopBotsResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerifiedBotTopBotsResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verifiedBotTopBotsResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type VerifiedBotTopBotsResponseMetaConfidenceInfo struct { + Annotations []VerifiedBotTopBotsResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON verifiedBotTopBotsResponseMetaConfidenceInfoJSON `json:"-"` +} + +// verifiedBotTopBotsResponseMetaConfidenceInfoJSON contains the JSON metadata for +// the struct [VerifiedBotTopBotsResponseMetaConfidenceInfo] +type verifiedBotTopBotsResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerifiedBotTopBotsResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verifiedBotTopBotsResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type VerifiedBotTopBotsResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON verifiedBotTopBotsResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// verifiedBotTopBotsResponseMetaConfidenceInfoAnnotationJSON contains the JSON +// metadata for the struct [VerifiedBotTopBotsResponseMetaConfidenceInfoAnnotation] +type verifiedBotTopBotsResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerifiedBotTopBotsResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verifiedBotTopBotsResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type VerifiedBotTopBotsResponseTop0 struct { + BotCategory string `json:"botCategory,required"` + BotName string `json:"botName,required"` + BotOwner string `json:"botOwner,required"` + Value string `json:"value,required"` + JSON verifiedBotTopBotsResponseTop0JSON `json:"-"` +} + +// verifiedBotTopBotsResponseTop0JSON contains the JSON metadata for the struct +// [VerifiedBotTopBotsResponseTop0] +type verifiedBotTopBotsResponseTop0JSON struct { + BotCategory apijson.Field + BotName apijson.Field + BotOwner apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerifiedBotTopBotsResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verifiedBotTopBotsResponseTop0JSON) RawJSON() string { + return r.raw +} + +type VerifiedBotTopCategoriesResponse struct { + Meta VerifiedBotTopCategoriesResponseMeta `json:"meta,required"` + Top0 []VerifiedBotTopCategoriesResponseTop0 `json:"top_0,required"` + JSON verifiedBotTopCategoriesResponseJSON `json:"-"` +} + +// verifiedBotTopCategoriesResponseJSON contains the JSON metadata for the struct +// [VerifiedBotTopCategoriesResponse] +type verifiedBotTopCategoriesResponseJSON struct { + Meta apijson.Field + Top0 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerifiedBotTopCategoriesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verifiedBotTopCategoriesResponseJSON) RawJSON() string { + return r.raw +} + +type VerifiedBotTopCategoriesResponseMeta struct { + DateRange []VerifiedBotTopCategoriesResponseMetaDateRange `json:"dateRange,required"` + ConfidenceInfo VerifiedBotTopCategoriesResponseMetaConfidenceInfo `json:"confidenceInfo"` + JSON verifiedBotTopCategoriesResponseMetaJSON `json:"-"` +} + +// verifiedBotTopCategoriesResponseMetaJSON contains the JSON metadata for the +// struct [VerifiedBotTopCategoriesResponseMeta] +type verifiedBotTopCategoriesResponseMetaJSON struct { + DateRange apijson.Field + ConfidenceInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerifiedBotTopCategoriesResponseMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verifiedBotTopCategoriesResponseMetaJSON) RawJSON() string { + return r.raw +} + +type VerifiedBotTopCategoriesResponseMetaDateRange struct { + // Adjusted end of date range. + EndTime time.Time `json:"endTime,required" format:"date-time"` + // Adjusted start of date range. + StartTime time.Time `json:"startTime,required" format:"date-time"` + JSON verifiedBotTopCategoriesResponseMetaDateRangeJSON `json:"-"` +} + +// verifiedBotTopCategoriesResponseMetaDateRangeJSON contains the JSON metadata for +// the struct [VerifiedBotTopCategoriesResponseMetaDateRange] +type verifiedBotTopCategoriesResponseMetaDateRangeJSON struct { + EndTime apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerifiedBotTopCategoriesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verifiedBotTopCategoriesResponseMetaDateRangeJSON) RawJSON() string { + return r.raw +} + +type VerifiedBotTopCategoriesResponseMetaConfidenceInfo struct { + Annotations []VerifiedBotTopCategoriesResponseMetaConfidenceInfoAnnotation `json:"annotations"` + Level int64 `json:"level"` + JSON verifiedBotTopCategoriesResponseMetaConfidenceInfoJSON `json:"-"` +} + +// verifiedBotTopCategoriesResponseMetaConfidenceInfoJSON contains the JSON +// metadata for the struct [VerifiedBotTopCategoriesResponseMetaConfidenceInfo] +type verifiedBotTopCategoriesResponseMetaConfidenceInfoJSON struct { + Annotations apijson.Field + Level apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerifiedBotTopCategoriesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verifiedBotTopCategoriesResponseMetaConfidenceInfoJSON) RawJSON() string { + return r.raw +} + +type VerifiedBotTopCategoriesResponseMetaConfidenceInfoAnnotation struct { + DataSource string `json:"dataSource,required"` + Description string `json:"description,required"` + EventType string `json:"eventType,required"` + IsInstantaneous interface{} `json:"isInstantaneous,required"` + EndTime time.Time `json:"endTime" format:"date-time"` + LinkedURL string `json:"linkedUrl"` + StartTime time.Time `json:"startTime" format:"date-time"` + JSON verifiedBotTopCategoriesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` +} + +// verifiedBotTopCategoriesResponseMetaConfidenceInfoAnnotationJSON contains the +// JSON metadata for the struct +// [VerifiedBotTopCategoriesResponseMetaConfidenceInfoAnnotation] +type verifiedBotTopCategoriesResponseMetaConfidenceInfoAnnotationJSON struct { + DataSource apijson.Field + Description apijson.Field + EventType apijson.Field + IsInstantaneous apijson.Field + EndTime apijson.Field + LinkedURL apijson.Field + StartTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerifiedBotTopCategoriesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verifiedBotTopCategoriesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { + return r.raw +} + +type VerifiedBotTopCategoriesResponseTop0 struct { + BotCategory string `json:"botCategory,required"` + Value string `json:"value,required"` + JSON verifiedBotTopCategoriesResponseTop0JSON `json:"-"` +} + +// verifiedBotTopCategoriesResponseTop0JSON contains the JSON metadata for the +// struct [VerifiedBotTopCategoriesResponseTop0] +type verifiedBotTopCategoriesResponseTop0JSON struct { + BotCategory apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerifiedBotTopCategoriesResponseTop0) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verifiedBotTopCategoriesResponseTop0JSON) RawJSON() string { + return r.raw +} + +type VerifiedBotTopBotsParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]VerifiedBotTopBotsParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[VerifiedBotTopBotsParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [VerifiedBotTopBotsParams]'s query parameters as +// `url.Values`. +func (r VerifiedBotTopBotsParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type VerifiedBotTopBotsParamsDateRange string + +const ( + VerifiedBotTopBotsParamsDateRange1d VerifiedBotTopBotsParamsDateRange = "1d" + VerifiedBotTopBotsParamsDateRange2d VerifiedBotTopBotsParamsDateRange = "2d" + VerifiedBotTopBotsParamsDateRange7d VerifiedBotTopBotsParamsDateRange = "7d" + VerifiedBotTopBotsParamsDateRange14d VerifiedBotTopBotsParamsDateRange = "14d" + VerifiedBotTopBotsParamsDateRange28d VerifiedBotTopBotsParamsDateRange = "28d" + VerifiedBotTopBotsParamsDateRange12w VerifiedBotTopBotsParamsDateRange = "12w" + VerifiedBotTopBotsParamsDateRange24w VerifiedBotTopBotsParamsDateRange = "24w" + VerifiedBotTopBotsParamsDateRange52w VerifiedBotTopBotsParamsDateRange = "52w" + VerifiedBotTopBotsParamsDateRange1dControl VerifiedBotTopBotsParamsDateRange = "1dControl" + VerifiedBotTopBotsParamsDateRange2dControl VerifiedBotTopBotsParamsDateRange = "2dControl" + VerifiedBotTopBotsParamsDateRange7dControl VerifiedBotTopBotsParamsDateRange = "7dControl" + VerifiedBotTopBotsParamsDateRange14dControl VerifiedBotTopBotsParamsDateRange = "14dControl" + VerifiedBotTopBotsParamsDateRange28dControl VerifiedBotTopBotsParamsDateRange = "28dControl" + VerifiedBotTopBotsParamsDateRange12wControl VerifiedBotTopBotsParamsDateRange = "12wControl" + VerifiedBotTopBotsParamsDateRange24wControl VerifiedBotTopBotsParamsDateRange = "24wControl" +) + +// Format results are returned in. +type VerifiedBotTopBotsParamsFormat string + +const ( + VerifiedBotTopBotsParamsFormatJson VerifiedBotTopBotsParamsFormat = "JSON" + VerifiedBotTopBotsParamsFormatCsv VerifiedBotTopBotsParamsFormat = "CSV" +) + +type VerifiedBotTopBotsResponseEnvelope struct { + Result VerifiedBotTopBotsResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON verifiedBotTopBotsResponseEnvelopeJSON `json:"-"` +} + +// verifiedBotTopBotsResponseEnvelopeJSON contains the JSON metadata for the struct +// [VerifiedBotTopBotsResponseEnvelope] +type verifiedBotTopBotsResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerifiedBotTopBotsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verifiedBotTopBotsResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type VerifiedBotTopCategoriesParams struct { + // Array of comma separated list of ASNs, start with `-` to exclude from results. + // For example, `-174, 3356` excludes results from AS174, but includes results from + // AS3356. + ASN param.Field[[]string] `query:"asn"` + // Array of comma separated list of continents (alpha-2 continent codes). Start + // with `-` to exclude from results. For example, `-EU,NA` excludes results from + // Europe, but includes results from North America. + Continent param.Field[[]string] `query:"continent"` + // End of the date range (inclusive). + DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` + // For example, use `7d` and `7dControl` to compare this week with the previous + // week. Use this parameter or set specific start and end dates (`dateStart` and + // `dateEnd` parameters). + DateRange param.Field[[]VerifiedBotTopCategoriesParamsDateRange] `query:"dateRange"` + // Array of datetimes to filter the start of a series. + DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` + // Format results are returned in. + Format param.Field[VerifiedBotTopCategoriesParamsFormat] `query:"format"` + // Limit the number of objects in the response. + Limit param.Field[int64] `query:"limit"` + // Array of comma separated list of locations (alpha-2 country codes). Start with + // `-` to exclude from results. For example, `-US,PT` excludes results from the US, + // but includes results from PT. + Location param.Field[[]string] `query:"location"` + // Array of names that will be used to name the series in responses. + Name param.Field[[]string] `query:"name"` +} + +// URLQuery serializes [VerifiedBotTopCategoriesParams]'s query parameters as +// `url.Values`. +func (r VerifiedBotTopCategoriesParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type VerifiedBotTopCategoriesParamsDateRange string + +const ( + VerifiedBotTopCategoriesParamsDateRange1d VerifiedBotTopCategoriesParamsDateRange = "1d" + VerifiedBotTopCategoriesParamsDateRange2d VerifiedBotTopCategoriesParamsDateRange = "2d" + VerifiedBotTopCategoriesParamsDateRange7d VerifiedBotTopCategoriesParamsDateRange = "7d" + VerifiedBotTopCategoriesParamsDateRange14d VerifiedBotTopCategoriesParamsDateRange = "14d" + VerifiedBotTopCategoriesParamsDateRange28d VerifiedBotTopCategoriesParamsDateRange = "28d" + VerifiedBotTopCategoriesParamsDateRange12w VerifiedBotTopCategoriesParamsDateRange = "12w" + VerifiedBotTopCategoriesParamsDateRange24w VerifiedBotTopCategoriesParamsDateRange = "24w" + VerifiedBotTopCategoriesParamsDateRange52w VerifiedBotTopCategoriesParamsDateRange = "52w" + VerifiedBotTopCategoriesParamsDateRange1dControl VerifiedBotTopCategoriesParamsDateRange = "1dControl" + VerifiedBotTopCategoriesParamsDateRange2dControl VerifiedBotTopCategoriesParamsDateRange = "2dControl" + VerifiedBotTopCategoriesParamsDateRange7dControl VerifiedBotTopCategoriesParamsDateRange = "7dControl" + VerifiedBotTopCategoriesParamsDateRange14dControl VerifiedBotTopCategoriesParamsDateRange = "14dControl" + VerifiedBotTopCategoriesParamsDateRange28dControl VerifiedBotTopCategoriesParamsDateRange = "28dControl" + VerifiedBotTopCategoriesParamsDateRange12wControl VerifiedBotTopCategoriesParamsDateRange = "12wControl" + VerifiedBotTopCategoriesParamsDateRange24wControl VerifiedBotTopCategoriesParamsDateRange = "24wControl" +) + +// Format results are returned in. +type VerifiedBotTopCategoriesParamsFormat string + +const ( + VerifiedBotTopCategoriesParamsFormatJson VerifiedBotTopCategoriesParamsFormat = "JSON" + VerifiedBotTopCategoriesParamsFormatCsv VerifiedBotTopCategoriesParamsFormat = "CSV" +) + +type VerifiedBotTopCategoriesResponseEnvelope struct { + Result VerifiedBotTopCategoriesResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON verifiedBotTopCategoriesResponseEnvelopeJSON `json:"-"` +} + +// verifiedBotTopCategoriesResponseEnvelopeJSON contains the JSON metadata for the +// struct [VerifiedBotTopCategoriesResponseEnvelope] +type verifiedBotTopCategoriesResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerifiedBotTopCategoriesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verifiedBotTopCategoriesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/radar/verifiedbottop_test.go b/radar/verifiedbottop_test.go new file mode 100644 index 00000000000..2c40bccf6e2 --- /dev/null +++ b/radar/verifiedbottop_test.go @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package radar_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/radar" +) + +func TestVerifiedBotTopBotsWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.VerifiedBots.Top.Bots(context.TODO(), radar.VerifiedBotTopBotsParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.VerifiedBotTopBotsParamsDateRange{radar.VerifiedBotTopBotsParamsDateRange1d, radar.VerifiedBotTopBotsParamsDateRange2d, radar.VerifiedBotTopBotsParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.VerifiedBotTopBotsParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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 TestVerifiedBotTopCategoriesWithOptionalParams(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("user@example.com"), + ) + _, err := client.Radar.VerifiedBots.Top.Categories(context.TODO(), radar.VerifiedBotTopCategoriesParams{ + ASN: cloudflare.F([]string{"string", "string", "string"}), + Continent: cloudflare.F([]string{"string", "string", "string"}), + DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + DateRange: cloudflare.F([]radar.VerifiedBotTopCategoriesParamsDateRange{radar.VerifiedBotTopCategoriesParamsDateRange1d, radar.VerifiedBotTopCategoriesParamsDateRange2d, radar.VerifiedBotTopCategoriesParamsDateRange7d}), + DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), + Format: cloudflare.F(radar.VerifiedBotTopCategoriesParamsFormatJson), + Limit: cloudflare.F(int64(5)), + Location: cloudflare.F([]string{"string", "string", "string"}), + Name: cloudflare.F([]string{"string", "string", "string"}), + }) + 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/radarannotation.go b/radarannotation.go deleted file mode 100644 index 517e6018591..00000000000 --- a/radarannotation.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarAnnotationService 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 [NewRadarAnnotationService] method -// instead. -type RadarAnnotationService struct { - Options []option.RequestOption - Outages *RadarAnnotationOutageService -} - -// NewRadarAnnotationService 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 NewRadarAnnotationService(opts ...option.RequestOption) (r *RadarAnnotationService) { - r = &RadarAnnotationService{} - r.Options = opts - r.Outages = NewRadarAnnotationOutageService(opts...) - return -} diff --git a/radarannotationoutage.go b/radarannotationoutage.go deleted file mode 100644 index 71beef567e2..00000000000 --- a/radarannotationoutage.go +++ /dev/null @@ -1,426 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarAnnotationOutageService 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 [NewRadarAnnotationOutageService] -// method instead. -type RadarAnnotationOutageService struct { - Options []option.RequestOption -} - -// NewRadarAnnotationOutageService 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 NewRadarAnnotationOutageService(opts ...option.RequestOption) (r *RadarAnnotationOutageService) { - r = &RadarAnnotationOutageService{} - r.Options = opts - return -} - -// Get latest Internet outages and anomalies. -func (r *RadarAnnotationOutageService) Get(ctx context.Context, query RadarAnnotationOutageGetParams, opts ...option.RequestOption) (res *RadarAnnotationOutageGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAnnotationOutageGetResponseEnvelope - path := "radar/annotations/outages" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the number of outages for locations. -func (r *RadarAnnotationOutageService) Locations(ctx context.Context, query RadarAnnotationOutageLocationsParams, opts ...option.RequestOption) (res *RadarAnnotationOutageLocationsResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAnnotationOutageLocationsResponseEnvelope - path := "radar/annotations/outages/locations" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarAnnotationOutageGetResponse struct { - Annotations []RadarAnnotationOutageGetResponseAnnotation `json:"annotations,required"` - JSON radarAnnotationOutageGetResponseJSON `json:"-"` -} - -// radarAnnotationOutageGetResponseJSON contains the JSON metadata for the struct -// [RadarAnnotationOutageGetResponse] -type radarAnnotationOutageGetResponseJSON struct { - Annotations apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAnnotationOutageGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAnnotationOutageGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAnnotationOutageGetResponseAnnotation struct { - ID string `json:"id,required"` - ASNs []int64 `json:"asns,required"` - ASNsDetails []RadarAnnotationOutageGetResponseAnnotationsASNsDetail `json:"asnsDetails,required"` - DataSource string `json:"dataSource,required"` - EventType string `json:"eventType,required"` - Locations []string `json:"locations,required"` - LocationsDetails []RadarAnnotationOutageGetResponseAnnotationsLocationsDetail `json:"locationsDetails,required"` - Outage RadarAnnotationOutageGetResponseAnnotationsOutage `json:"outage,required"` - StartDate string `json:"startDate,required"` - Description string `json:"description"` - EndDate string `json:"endDate"` - LinkedURL string `json:"linkedUrl"` - Scope string `json:"scope"` - JSON radarAnnotationOutageGetResponseAnnotationJSON `json:"-"` -} - -// radarAnnotationOutageGetResponseAnnotationJSON contains the JSON metadata for -// the struct [RadarAnnotationOutageGetResponseAnnotation] -type radarAnnotationOutageGetResponseAnnotationJSON struct { - ID apijson.Field - ASNs apijson.Field - ASNsDetails apijson.Field - DataSource apijson.Field - EventType apijson.Field - Locations apijson.Field - LocationsDetails apijson.Field - Outage apijson.Field - StartDate apijson.Field - Description apijson.Field - EndDate apijson.Field - LinkedURL apijson.Field - Scope apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAnnotationOutageGetResponseAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAnnotationOutageGetResponseAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAnnotationOutageGetResponseAnnotationsASNsDetail struct { - ASN string `json:"asn,required"` - Name string `json:"name,required"` - Locations RadarAnnotationOutageGetResponseAnnotationsASNsDetailsLocations `json:"locations"` - JSON radarAnnotationOutageGetResponseAnnotationsASNsDetailJSON `json:"-"` -} - -// radarAnnotationOutageGetResponseAnnotationsASNsDetailJSON contains the JSON -// metadata for the struct [RadarAnnotationOutageGetResponseAnnotationsASNsDetail] -type radarAnnotationOutageGetResponseAnnotationsASNsDetailJSON struct { - ASN apijson.Field - Name apijson.Field - Locations apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAnnotationOutageGetResponseAnnotationsASNsDetail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAnnotationOutageGetResponseAnnotationsASNsDetailJSON) RawJSON() string { - return r.raw -} - -type RadarAnnotationOutageGetResponseAnnotationsASNsDetailsLocations struct { - Code string `json:"code,required"` - Name string `json:"name,required"` - JSON radarAnnotationOutageGetResponseAnnotationsASNsDetailsLocationsJSON `json:"-"` -} - -// radarAnnotationOutageGetResponseAnnotationsASNsDetailsLocationsJSON contains the -// JSON metadata for the struct -// [RadarAnnotationOutageGetResponseAnnotationsASNsDetailsLocations] -type radarAnnotationOutageGetResponseAnnotationsASNsDetailsLocationsJSON struct { - Code apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAnnotationOutageGetResponseAnnotationsASNsDetailsLocations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAnnotationOutageGetResponseAnnotationsASNsDetailsLocationsJSON) RawJSON() string { - return r.raw -} - -type RadarAnnotationOutageGetResponseAnnotationsLocationsDetail struct { - Code string `json:"code,required"` - Name string `json:"name,required"` - JSON radarAnnotationOutageGetResponseAnnotationsLocationsDetailJSON `json:"-"` -} - -// radarAnnotationOutageGetResponseAnnotationsLocationsDetailJSON contains the JSON -// metadata for the struct -// [RadarAnnotationOutageGetResponseAnnotationsLocationsDetail] -type radarAnnotationOutageGetResponseAnnotationsLocationsDetailJSON struct { - Code apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAnnotationOutageGetResponseAnnotationsLocationsDetail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAnnotationOutageGetResponseAnnotationsLocationsDetailJSON) RawJSON() string { - return r.raw -} - -type RadarAnnotationOutageGetResponseAnnotationsOutage struct { - OutageCause string `json:"outageCause,required"` - OutageType string `json:"outageType,required"` - JSON radarAnnotationOutageGetResponseAnnotationsOutageJSON `json:"-"` -} - -// radarAnnotationOutageGetResponseAnnotationsOutageJSON contains the JSON metadata -// for the struct [RadarAnnotationOutageGetResponseAnnotationsOutage] -type radarAnnotationOutageGetResponseAnnotationsOutageJSON struct { - OutageCause apijson.Field - OutageType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAnnotationOutageGetResponseAnnotationsOutage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAnnotationOutageGetResponseAnnotationsOutageJSON) RawJSON() string { - return r.raw -} - -type RadarAnnotationOutageLocationsResponse struct { - Annotations []RadarAnnotationOutageLocationsResponseAnnotation `json:"annotations,required"` - JSON radarAnnotationOutageLocationsResponseJSON `json:"-"` -} - -// radarAnnotationOutageLocationsResponseJSON contains the JSON metadata for the -// struct [RadarAnnotationOutageLocationsResponse] -type radarAnnotationOutageLocationsResponseJSON struct { - Annotations apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAnnotationOutageLocationsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAnnotationOutageLocationsResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAnnotationOutageLocationsResponseAnnotation struct { - ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` - ClientCountryName string `json:"clientCountryName,required"` - Value string `json:"value,required"` - JSON radarAnnotationOutageLocationsResponseAnnotationJSON `json:"-"` -} - -// radarAnnotationOutageLocationsResponseAnnotationJSON contains the JSON metadata -// for the struct [RadarAnnotationOutageLocationsResponseAnnotation] -type radarAnnotationOutageLocationsResponseAnnotationJSON struct { - ClientCountryAlpha2 apijson.Field - ClientCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAnnotationOutageLocationsResponseAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAnnotationOutageLocationsResponseAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAnnotationOutageGetParams struct { - // Single ASN as integer. - ASN param.Field[int64] `query:"asn"` - // End of the date range (inclusive). - DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"` - // Shorthand date ranges for the last X days - use when you don't need specific - // start and end dates. - DateRange param.Field[RadarAnnotationOutageGetParamsDateRange] `query:"dateRange"` - // Start of the date range (inclusive). - DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAnnotationOutageGetParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Location Alpha2 code. - Location param.Field[string] `query:"location"` - // Number of objects to skip before grabbing results. - Offset param.Field[int64] `query:"offset"` -} - -// URLQuery serializes [RadarAnnotationOutageGetParams]'s query parameters as -// `url.Values`. -func (r RadarAnnotationOutageGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Shorthand date ranges for the last X days - use when you don't need specific -// start and end dates. -type RadarAnnotationOutageGetParamsDateRange string - -const ( - RadarAnnotationOutageGetParamsDateRange1d RadarAnnotationOutageGetParamsDateRange = "1d" - RadarAnnotationOutageGetParamsDateRange2d RadarAnnotationOutageGetParamsDateRange = "2d" - RadarAnnotationOutageGetParamsDateRange7d RadarAnnotationOutageGetParamsDateRange = "7d" - RadarAnnotationOutageGetParamsDateRange14d RadarAnnotationOutageGetParamsDateRange = "14d" - RadarAnnotationOutageGetParamsDateRange28d RadarAnnotationOutageGetParamsDateRange = "28d" - RadarAnnotationOutageGetParamsDateRange12w RadarAnnotationOutageGetParamsDateRange = "12w" - RadarAnnotationOutageGetParamsDateRange24w RadarAnnotationOutageGetParamsDateRange = "24w" - RadarAnnotationOutageGetParamsDateRange52w RadarAnnotationOutageGetParamsDateRange = "52w" - RadarAnnotationOutageGetParamsDateRange1dControl RadarAnnotationOutageGetParamsDateRange = "1dControl" - RadarAnnotationOutageGetParamsDateRange2dControl RadarAnnotationOutageGetParamsDateRange = "2dControl" - RadarAnnotationOutageGetParamsDateRange7dControl RadarAnnotationOutageGetParamsDateRange = "7dControl" - RadarAnnotationOutageGetParamsDateRange14dControl RadarAnnotationOutageGetParamsDateRange = "14dControl" - RadarAnnotationOutageGetParamsDateRange28dControl RadarAnnotationOutageGetParamsDateRange = "28dControl" - RadarAnnotationOutageGetParamsDateRange12wControl RadarAnnotationOutageGetParamsDateRange = "12wControl" - RadarAnnotationOutageGetParamsDateRange24wControl RadarAnnotationOutageGetParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAnnotationOutageGetParamsFormat string - -const ( - RadarAnnotationOutageGetParamsFormatJson RadarAnnotationOutageGetParamsFormat = "JSON" - RadarAnnotationOutageGetParamsFormatCsv RadarAnnotationOutageGetParamsFormat = "CSV" -) - -type RadarAnnotationOutageGetResponseEnvelope struct { - Result RadarAnnotationOutageGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAnnotationOutageGetResponseEnvelopeJSON `json:"-"` -} - -// radarAnnotationOutageGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarAnnotationOutageGetResponseEnvelope] -type radarAnnotationOutageGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAnnotationOutageGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAnnotationOutageGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAnnotationOutageLocationsParams struct { - // End of the date range (inclusive). - DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"` - // Shorthand date ranges for the last X days - use when you don't need specific - // start and end dates. - DateRange param.Field[RadarAnnotationOutageLocationsParamsDateRange] `query:"dateRange"` - // Start of the date range (inclusive). - DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAnnotationOutageLocationsParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` -} - -// URLQuery serializes [RadarAnnotationOutageLocationsParams]'s query parameters as -// `url.Values`. -func (r RadarAnnotationOutageLocationsParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Shorthand date ranges for the last X days - use when you don't need specific -// start and end dates. -type RadarAnnotationOutageLocationsParamsDateRange string - -const ( - RadarAnnotationOutageLocationsParamsDateRange1d RadarAnnotationOutageLocationsParamsDateRange = "1d" - RadarAnnotationOutageLocationsParamsDateRange2d RadarAnnotationOutageLocationsParamsDateRange = "2d" - RadarAnnotationOutageLocationsParamsDateRange7d RadarAnnotationOutageLocationsParamsDateRange = "7d" - RadarAnnotationOutageLocationsParamsDateRange14d RadarAnnotationOutageLocationsParamsDateRange = "14d" - RadarAnnotationOutageLocationsParamsDateRange28d RadarAnnotationOutageLocationsParamsDateRange = "28d" - RadarAnnotationOutageLocationsParamsDateRange12w RadarAnnotationOutageLocationsParamsDateRange = "12w" - RadarAnnotationOutageLocationsParamsDateRange24w RadarAnnotationOutageLocationsParamsDateRange = "24w" - RadarAnnotationOutageLocationsParamsDateRange52w RadarAnnotationOutageLocationsParamsDateRange = "52w" - RadarAnnotationOutageLocationsParamsDateRange1dControl RadarAnnotationOutageLocationsParamsDateRange = "1dControl" - RadarAnnotationOutageLocationsParamsDateRange2dControl RadarAnnotationOutageLocationsParamsDateRange = "2dControl" - RadarAnnotationOutageLocationsParamsDateRange7dControl RadarAnnotationOutageLocationsParamsDateRange = "7dControl" - RadarAnnotationOutageLocationsParamsDateRange14dControl RadarAnnotationOutageLocationsParamsDateRange = "14dControl" - RadarAnnotationOutageLocationsParamsDateRange28dControl RadarAnnotationOutageLocationsParamsDateRange = "28dControl" - RadarAnnotationOutageLocationsParamsDateRange12wControl RadarAnnotationOutageLocationsParamsDateRange = "12wControl" - RadarAnnotationOutageLocationsParamsDateRange24wControl RadarAnnotationOutageLocationsParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAnnotationOutageLocationsParamsFormat string - -const ( - RadarAnnotationOutageLocationsParamsFormatJson RadarAnnotationOutageLocationsParamsFormat = "JSON" - RadarAnnotationOutageLocationsParamsFormatCsv RadarAnnotationOutageLocationsParamsFormat = "CSV" -) - -type RadarAnnotationOutageLocationsResponseEnvelope struct { - Result RadarAnnotationOutageLocationsResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAnnotationOutageLocationsResponseEnvelopeJSON `json:"-"` -} - -// radarAnnotationOutageLocationsResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarAnnotationOutageLocationsResponseEnvelope] -type radarAnnotationOutageLocationsResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAnnotationOutageLocationsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAnnotationOutageLocationsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarannotationoutage_test.go b/radarannotationoutage_test.go deleted file mode 100644 index 2422d7a63a3..00000000000 --- a/radarannotationoutage_test.go +++ /dev/null @@ -1,78 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarAnnotationOutageGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Annotations.Outages.Get(context.TODO(), cloudflare.RadarAnnotationOutageGetParams{ - ASN: cloudflare.F(int64(0)), - DateEnd: cloudflare.F(time.Now()), - DateRange: cloudflare.F(cloudflare.RadarAnnotationOutageGetParamsDateRange7d), - DateStart: cloudflare.F(time.Now()), - Format: cloudflare.F(cloudflare.RadarAnnotationOutageGetParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F("US"), - Offset: cloudflare.F(int64(0)), - }) - 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 TestRadarAnnotationOutageLocationsWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Annotations.Outages.Locations(context.TODO(), cloudflare.RadarAnnotationOutageLocationsParams{ - DateEnd: cloudflare.F(time.Now()), - DateRange: cloudflare.F(cloudflare.RadarAnnotationOutageLocationsParamsDateRange7d), - DateStart: cloudflare.F(time.Now()), - Format: cloudflare.F(cloudflare.RadarAnnotationOutageLocationsParamsFormatJson), - Limit: cloudflare.F(int64(5)), - }) - 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/radaras112.go b/radaras112.go deleted file mode 100644 index c39a3a0989a..00000000000 --- a/radaras112.go +++ /dev/null @@ -1,310 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarAS112Service 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 [NewRadarAS112Service] method instead. -type RadarAS112Service struct { - Options []option.RequestOption - Summary *RadarAS112SummaryService - TimeseriesGroups *RadarAS112TimeseriesGroupService - Top *RadarAS112TopService -} - -// NewRadarAS112Service 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 NewRadarAS112Service(opts ...option.RequestOption) (r *RadarAS112Service) { - r = &RadarAS112Service{} - r.Options = opts - r.Summary = NewRadarAS112SummaryService(opts...) - r.TimeseriesGroups = NewRadarAS112TimeseriesGroupService(opts...) - r.Top = NewRadarAS112TopService(opts...) - return -} - -// Get AS112 queries change over time. -func (r *RadarAS112Service) Timeseries(ctx context.Context, query RadarAS112TimeseriesParams, opts ...option.RequestOption) (res *RadarAS112TimeseriesResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAS112TimeseriesResponseEnvelope - path := "radar/as112/timeseries" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarAS112TimeseriesResponse struct { - Meta RadarAS112TimeseriesResponseMeta `json:"meta,required"` - Serie0 RadarAS112TimeseriesResponseSerie0 `json:"serie_0,required"` - JSON radarAS112TimeseriesResponseJSON `json:"-"` -} - -// radarAS112TimeseriesResponseJSON contains the JSON metadata for the struct -// [RadarAS112TimeseriesResponse] -type radarAS112TimeseriesResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesResponseMeta struct { - AggInterval string `json:"aggInterval,required"` - DateRange []RadarAS112TimeseriesResponseMetaDateRange `json:"dateRange,required"` - LastUpdated time.Time `json:"lastUpdated,required" format:"date-time"` - ConfidenceInfo RadarAS112TimeseriesResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAS112TimeseriesResponseMetaJSON `json:"-"` -} - -// radarAS112TimeseriesResponseMetaJSON contains the JSON metadata for the struct -// [RadarAS112TimeseriesResponseMeta] -type radarAS112TimeseriesResponseMetaJSON struct { - AggInterval apijson.Field - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAS112TimeseriesResponseMetaDateRangeJSON `json:"-"` -} - -// radarAS112TimeseriesResponseMetaDateRangeJSON contains the JSON metadata for the -// struct [RadarAS112TimeseriesResponseMetaDateRange] -type radarAS112TimeseriesResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesResponseMetaConfidenceInfo struct { - Annotations []RadarAS112TimeseriesResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAS112TimeseriesResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAS112TimeseriesResponseMetaConfidenceInfoJSON contains the JSON metadata -// for the struct [RadarAS112TimeseriesResponseMetaConfidenceInfo] -type radarAS112TimeseriesResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAS112TimeseriesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAS112TimeseriesResponseMetaConfidenceInfoAnnotationJSON contains the JSON -// metadata for the struct -// [RadarAS112TimeseriesResponseMetaConfidenceInfoAnnotation] -type radarAS112TimeseriesResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesResponseSerie0 struct { - Timestamps []time.Time `json:"timestamps,required" format:"date-time"` - Values []string `json:"values,required"` - JSON radarAS112TimeseriesResponseSerie0JSON `json:"-"` -} - -// radarAS112TimeseriesResponseSerie0JSON contains the JSON metadata for the struct -// [RadarAS112TimeseriesResponseSerie0] -type radarAS112TimeseriesResponseSerie0JSON struct { - Timestamps apijson.Field - Values apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAS112TimeseriesParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAS112TimeseriesParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAS112TimeseriesParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAS112TimeseriesParams]'s query parameters as -// `url.Values`. -func (r RadarAS112TimeseriesParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAS112TimeseriesParamsAggInterval string - -const ( - RadarAS112TimeseriesParamsAggInterval15m RadarAS112TimeseriesParamsAggInterval = "15m" - RadarAS112TimeseriesParamsAggInterval1h RadarAS112TimeseriesParamsAggInterval = "1h" - RadarAS112TimeseriesParamsAggInterval1d RadarAS112TimeseriesParamsAggInterval = "1d" - RadarAS112TimeseriesParamsAggInterval1w RadarAS112TimeseriesParamsAggInterval = "1w" -) - -type RadarAS112TimeseriesParamsDateRange string - -const ( - RadarAS112TimeseriesParamsDateRange1d RadarAS112TimeseriesParamsDateRange = "1d" - RadarAS112TimeseriesParamsDateRange2d RadarAS112TimeseriesParamsDateRange = "2d" - RadarAS112TimeseriesParamsDateRange7d RadarAS112TimeseriesParamsDateRange = "7d" - RadarAS112TimeseriesParamsDateRange14d RadarAS112TimeseriesParamsDateRange = "14d" - RadarAS112TimeseriesParamsDateRange28d RadarAS112TimeseriesParamsDateRange = "28d" - RadarAS112TimeseriesParamsDateRange12w RadarAS112TimeseriesParamsDateRange = "12w" - RadarAS112TimeseriesParamsDateRange24w RadarAS112TimeseriesParamsDateRange = "24w" - RadarAS112TimeseriesParamsDateRange52w RadarAS112TimeseriesParamsDateRange = "52w" - RadarAS112TimeseriesParamsDateRange1dControl RadarAS112TimeseriesParamsDateRange = "1dControl" - RadarAS112TimeseriesParamsDateRange2dControl RadarAS112TimeseriesParamsDateRange = "2dControl" - RadarAS112TimeseriesParamsDateRange7dControl RadarAS112TimeseriesParamsDateRange = "7dControl" - RadarAS112TimeseriesParamsDateRange14dControl RadarAS112TimeseriesParamsDateRange = "14dControl" - RadarAS112TimeseriesParamsDateRange28dControl RadarAS112TimeseriesParamsDateRange = "28dControl" - RadarAS112TimeseriesParamsDateRange12wControl RadarAS112TimeseriesParamsDateRange = "12wControl" - RadarAS112TimeseriesParamsDateRange24wControl RadarAS112TimeseriesParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAS112TimeseriesParamsFormat string - -const ( - RadarAS112TimeseriesParamsFormatJson RadarAS112TimeseriesParamsFormat = "JSON" - RadarAS112TimeseriesParamsFormatCsv RadarAS112TimeseriesParamsFormat = "CSV" -) - -type RadarAS112TimeseriesResponseEnvelope struct { - Result RadarAS112TimeseriesResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAS112TimeseriesResponseEnvelopeJSON `json:"-"` -} - -// radarAS112TimeseriesResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarAS112TimeseriesResponseEnvelope] -type radarAS112TimeseriesResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radaras112_test.go b/radaras112_test.go deleted file mode 100644 index fc1addb1323..00000000000 --- a/radaras112_test.go +++ /dev/null @@ -1,49 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarAS112TimeseriesWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.AS112.Timeseries(context.TODO(), cloudflare.RadarAS112TimeseriesParams{ - AggInterval: cloudflare.F(cloudflare.RadarAS112TimeseriesParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAS112TimeseriesParamsDateRange{cloudflare.RadarAS112TimeseriesParamsDateRange1d, cloudflare.RadarAS112TimeseriesParamsDateRange2d, cloudflare.RadarAS112TimeseriesParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAS112TimeseriesParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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/radaras112summary.go b/radaras112summary.go deleted file mode 100644 index d7cf2f3d9be..00000000000 --- a/radaras112summary.go +++ /dev/null @@ -1,1571 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarAS112SummaryService 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 [NewRadarAS112SummaryService] method -// instead. -type RadarAS112SummaryService struct { - Options []option.RequestOption -} - -// NewRadarAS112SummaryService 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 NewRadarAS112SummaryService(opts ...option.RequestOption) (r *RadarAS112SummaryService) { - r = &RadarAS112SummaryService{} - r.Options = opts - return -} - -// Percentage distribution of DNS queries to AS112 by DNSSEC support. -func (r *RadarAS112SummaryService) DNSSEC(ctx context.Context, query RadarAS112SummaryDNSSECParams, opts ...option.RequestOption) (res *RadarAS112SummaryDNSSECResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAS112SummaryDNSSECResponseEnvelope - path := "radar/as112/summary/dnssec" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of DNS queries, to AS112, by EDNS support. -func (r *RadarAS112SummaryService) Edns(ctx context.Context, query RadarAS112SummaryEdnsParams, opts ...option.RequestOption) (res *RadarAS112SummaryEdnsResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAS112SummaryEdnsResponseEnvelope - path := "radar/as112/summary/edns" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of DNS queries to AS112 per IP Version. -func (r *RadarAS112SummaryService) IPVersion(ctx context.Context, query RadarAS112SummaryIPVersionParams, opts ...option.RequestOption) (res *RadarAS112SummaryIPVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAS112SummaryIPVersionResponseEnvelope - path := "radar/as112/summary/ip_version" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of DNS queries to AS112 per protocol. -func (r *RadarAS112SummaryService) Protocol(ctx context.Context, query RadarAS112SummaryProtocolParams, opts ...option.RequestOption) (res *RadarAS112SummaryProtocolResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAS112SummaryProtocolResponseEnvelope - path := "radar/as112/summary/protocol" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of DNS queries to AS112 by Query Type. -func (r *RadarAS112SummaryService) QueryType(ctx context.Context, query RadarAS112SummaryQueryTypeParams, opts ...option.RequestOption) (res *RadarAS112SummaryQueryTypeResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAS112SummaryQueryTypeResponseEnvelope - path := "radar/as112/summary/query_type" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of AS112 dns requests classified per Response Codes. -func (r *RadarAS112SummaryService) ResponseCodes(ctx context.Context, query RadarAS112SummaryResponseCodesParams, opts ...option.RequestOption) (res *RadarAS112SummaryResponseCodesResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAS112SummaryResponseCodesResponseEnvelope - path := "radar/as112/summary/response_codes" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarAS112SummaryDNSSECResponse struct { - Meta RadarAS112SummaryDNSSECResponseMeta `json:"meta,required"` - Summary0 RadarAS112SummaryDNSSECResponseSummary0 `json:"summary_0,required"` - JSON radarAS112SummaryDNSSECResponseJSON `json:"-"` -} - -// radarAS112SummaryDNSSECResponseJSON contains the JSON metadata for the struct -// [RadarAS112SummaryDNSSECResponse] -type radarAS112SummaryDNSSECResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryDNSSECResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryDNSSECResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryDNSSECResponseMeta struct { - DateRange []RadarAS112SummaryDNSSECResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarAS112SummaryDNSSECResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAS112SummaryDNSSECResponseMetaJSON `json:"-"` -} - -// radarAS112SummaryDNSSECResponseMetaJSON contains the JSON metadata for the -// struct [RadarAS112SummaryDNSSECResponseMeta] -type radarAS112SummaryDNSSECResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryDNSSECResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryDNSSECResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryDNSSECResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAS112SummaryDNSSECResponseMetaDateRangeJSON `json:"-"` -} - -// radarAS112SummaryDNSSECResponseMetaDateRangeJSON contains the JSON metadata for -// the struct [RadarAS112SummaryDNSSECResponseMetaDateRange] -type radarAS112SummaryDNSSECResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryDNSSECResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryDNSSECResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryDNSSECResponseMetaConfidenceInfo struct { - Annotations []RadarAS112SummaryDNSSECResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAS112SummaryDNSSECResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAS112SummaryDNSSECResponseMetaConfidenceInfoJSON contains the JSON metadata -// for the struct [RadarAS112SummaryDNSSECResponseMetaConfidenceInfo] -type radarAS112SummaryDNSSECResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryDNSSECResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryDNSSECResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryDNSSECResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAS112SummaryDNSSECResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAS112SummaryDNSSECResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarAS112SummaryDNSSECResponseMetaConfidenceInfoAnnotation] -type radarAS112SummaryDNSSECResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryDNSSECResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryDNSSECResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryDNSSECResponseSummary0 struct { - NotSupported string `json:"NOT_SUPPORTED,required"` - Supported string `json:"SUPPORTED,required"` - JSON radarAS112SummaryDNSSECResponseSummary0JSON `json:"-"` -} - -// radarAS112SummaryDNSSECResponseSummary0JSON contains the JSON metadata for the -// struct [RadarAS112SummaryDNSSECResponseSummary0] -type radarAS112SummaryDNSSECResponseSummary0JSON struct { - NotSupported apijson.Field - Supported apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryDNSSECResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryDNSSECResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryEdnsResponse struct { - Meta RadarAS112SummaryEdnsResponseMeta `json:"meta,required"` - Summary0 RadarAS112SummaryEdnsResponseSummary0 `json:"summary_0,required"` - JSON radarAS112SummaryEdnsResponseJSON `json:"-"` -} - -// radarAS112SummaryEdnsResponseJSON contains the JSON metadata for the struct -// [RadarAS112SummaryEdnsResponse] -type radarAS112SummaryEdnsResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryEdnsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryEdnsResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryEdnsResponseMeta struct { - DateRange []RadarAS112SummaryEdnsResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarAS112SummaryEdnsResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAS112SummaryEdnsResponseMetaJSON `json:"-"` -} - -// radarAS112SummaryEdnsResponseMetaJSON contains the JSON metadata for the struct -// [RadarAS112SummaryEdnsResponseMeta] -type radarAS112SummaryEdnsResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryEdnsResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryEdnsResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryEdnsResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAS112SummaryEdnsResponseMetaDateRangeJSON `json:"-"` -} - -// radarAS112SummaryEdnsResponseMetaDateRangeJSON contains the JSON metadata for -// the struct [RadarAS112SummaryEdnsResponseMetaDateRange] -type radarAS112SummaryEdnsResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryEdnsResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryEdnsResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryEdnsResponseMetaConfidenceInfo struct { - Annotations []RadarAS112SummaryEdnsResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAS112SummaryEdnsResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAS112SummaryEdnsResponseMetaConfidenceInfoJSON contains the JSON metadata -// for the struct [RadarAS112SummaryEdnsResponseMetaConfidenceInfo] -type radarAS112SummaryEdnsResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryEdnsResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryEdnsResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryEdnsResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAS112SummaryEdnsResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAS112SummaryEdnsResponseMetaConfidenceInfoAnnotationJSON contains the JSON -// metadata for the struct -// [RadarAS112SummaryEdnsResponseMetaConfidenceInfoAnnotation] -type radarAS112SummaryEdnsResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryEdnsResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryEdnsResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryEdnsResponseSummary0 struct { - NotSupported string `json:"NOT_SUPPORTED,required"` - Supported string `json:"SUPPORTED,required"` - JSON radarAS112SummaryEdnsResponseSummary0JSON `json:"-"` -} - -// radarAS112SummaryEdnsResponseSummary0JSON contains the JSON metadata for the -// struct [RadarAS112SummaryEdnsResponseSummary0] -type radarAS112SummaryEdnsResponseSummary0JSON struct { - NotSupported apijson.Field - Supported apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryEdnsResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryEdnsResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryIPVersionResponse struct { - Meta RadarAS112SummaryIPVersionResponseMeta `json:"meta,required"` - Summary0 RadarAS112SummaryIPVersionResponseSummary0 `json:"summary_0,required"` - JSON radarAS112SummaryIPVersionResponseJSON `json:"-"` -} - -// radarAS112SummaryIPVersionResponseJSON contains the JSON metadata for the struct -// [RadarAS112SummaryIPVersionResponse] -type radarAS112SummaryIPVersionResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryIPVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryIPVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryIPVersionResponseMeta struct { - DateRange []RadarAS112SummaryIPVersionResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarAS112SummaryIPVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAS112SummaryIPVersionResponseMetaJSON `json:"-"` -} - -// radarAS112SummaryIPVersionResponseMetaJSON contains the JSON metadata for the -// struct [RadarAS112SummaryIPVersionResponseMeta] -type radarAS112SummaryIPVersionResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryIPVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryIPVersionResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryIPVersionResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAS112SummaryIPVersionResponseMetaDateRangeJSON `json:"-"` -} - -// radarAS112SummaryIPVersionResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarAS112SummaryIPVersionResponseMetaDateRange] -type radarAS112SummaryIPVersionResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryIPVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryIPVersionResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryIPVersionResponseMetaConfidenceInfo struct { - Annotations []RadarAS112SummaryIPVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAS112SummaryIPVersionResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAS112SummaryIPVersionResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarAS112SummaryIPVersionResponseMetaConfidenceInfo] -type radarAS112SummaryIPVersionResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryIPVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryIPVersionResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryIPVersionResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAS112SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAS112SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarAS112SummaryIPVersionResponseMetaConfidenceInfoAnnotation] -type radarAS112SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryIPVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryIPVersionResponseSummary0 struct { - IPv4 string `json:"IPv4,required"` - IPv6 string `json:"IPv6,required"` - JSON radarAS112SummaryIPVersionResponseSummary0JSON `json:"-"` -} - -// radarAS112SummaryIPVersionResponseSummary0JSON contains the JSON metadata for -// the struct [RadarAS112SummaryIPVersionResponseSummary0] -type radarAS112SummaryIPVersionResponseSummary0JSON struct { - IPv4 apijson.Field - IPv6 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryIPVersionResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryIPVersionResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryProtocolResponse struct { - Meta RadarAS112SummaryProtocolResponseMeta `json:"meta,required"` - Summary0 RadarAS112SummaryProtocolResponseSummary0 `json:"summary_0,required"` - JSON radarAS112SummaryProtocolResponseJSON `json:"-"` -} - -// radarAS112SummaryProtocolResponseJSON contains the JSON metadata for the struct -// [RadarAS112SummaryProtocolResponse] -type radarAS112SummaryProtocolResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryProtocolResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryProtocolResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryProtocolResponseMeta struct { - DateRange []RadarAS112SummaryProtocolResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarAS112SummaryProtocolResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAS112SummaryProtocolResponseMetaJSON `json:"-"` -} - -// radarAS112SummaryProtocolResponseMetaJSON contains the JSON metadata for the -// struct [RadarAS112SummaryProtocolResponseMeta] -type radarAS112SummaryProtocolResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryProtocolResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryProtocolResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryProtocolResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAS112SummaryProtocolResponseMetaDateRangeJSON `json:"-"` -} - -// radarAS112SummaryProtocolResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarAS112SummaryProtocolResponseMetaDateRange] -type radarAS112SummaryProtocolResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryProtocolResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryProtocolResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryProtocolResponseMetaConfidenceInfo struct { - Annotations []RadarAS112SummaryProtocolResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAS112SummaryProtocolResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAS112SummaryProtocolResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarAS112SummaryProtocolResponseMetaConfidenceInfo] -type radarAS112SummaryProtocolResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryProtocolResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryProtocolResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryProtocolResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAS112SummaryProtocolResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAS112SummaryProtocolResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarAS112SummaryProtocolResponseMetaConfidenceInfoAnnotation] -type radarAS112SummaryProtocolResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryProtocolResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryProtocolResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryProtocolResponseSummary0 struct { - Tcp string `json:"tcp,required"` - Udp string `json:"udp,required"` - JSON radarAS112SummaryProtocolResponseSummary0JSON `json:"-"` -} - -// radarAS112SummaryProtocolResponseSummary0JSON contains the JSON metadata for the -// struct [RadarAS112SummaryProtocolResponseSummary0] -type radarAS112SummaryProtocolResponseSummary0JSON struct { - Tcp apijson.Field - Udp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryProtocolResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryProtocolResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryQueryTypeResponse struct { - Meta RadarAS112SummaryQueryTypeResponseMeta `json:"meta,required"` - Summary0 RadarAS112SummaryQueryTypeResponseSummary0 `json:"summary_0,required"` - JSON radarAS112SummaryQueryTypeResponseJSON `json:"-"` -} - -// radarAS112SummaryQueryTypeResponseJSON contains the JSON metadata for the struct -// [RadarAS112SummaryQueryTypeResponse] -type radarAS112SummaryQueryTypeResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryQueryTypeResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryQueryTypeResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryQueryTypeResponseMeta struct { - DateRange []RadarAS112SummaryQueryTypeResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarAS112SummaryQueryTypeResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAS112SummaryQueryTypeResponseMetaJSON `json:"-"` -} - -// radarAS112SummaryQueryTypeResponseMetaJSON contains the JSON metadata for the -// struct [RadarAS112SummaryQueryTypeResponseMeta] -type radarAS112SummaryQueryTypeResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryQueryTypeResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryQueryTypeResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryQueryTypeResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAS112SummaryQueryTypeResponseMetaDateRangeJSON `json:"-"` -} - -// radarAS112SummaryQueryTypeResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarAS112SummaryQueryTypeResponseMetaDateRange] -type radarAS112SummaryQueryTypeResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryQueryTypeResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryQueryTypeResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryQueryTypeResponseMetaConfidenceInfo struct { - Annotations []RadarAS112SummaryQueryTypeResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAS112SummaryQueryTypeResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAS112SummaryQueryTypeResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarAS112SummaryQueryTypeResponseMetaConfidenceInfo] -type radarAS112SummaryQueryTypeResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryQueryTypeResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryQueryTypeResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryQueryTypeResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAS112SummaryQueryTypeResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAS112SummaryQueryTypeResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarAS112SummaryQueryTypeResponseMetaConfidenceInfoAnnotation] -type radarAS112SummaryQueryTypeResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryQueryTypeResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryQueryTypeResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryQueryTypeResponseSummary0 struct { - A string `json:"A,required"` - AAAA string `json:"AAAA,required"` - PTR string `json:"PTR,required"` - Soa string `json:"SOA,required"` - SRV string `json:"SRV,required"` - JSON radarAS112SummaryQueryTypeResponseSummary0JSON `json:"-"` -} - -// radarAS112SummaryQueryTypeResponseSummary0JSON contains the JSON metadata for -// the struct [RadarAS112SummaryQueryTypeResponseSummary0] -type radarAS112SummaryQueryTypeResponseSummary0JSON struct { - A apijson.Field - AAAA apijson.Field - PTR apijson.Field - Soa apijson.Field - SRV apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryQueryTypeResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryQueryTypeResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryResponseCodesResponse struct { - Meta RadarAS112SummaryResponseCodesResponseMeta `json:"meta,required"` - Summary0 RadarAS112SummaryResponseCodesResponseSummary0 `json:"summary_0,required"` - JSON radarAS112SummaryResponseCodesResponseJSON `json:"-"` -} - -// radarAS112SummaryResponseCodesResponseJSON contains the JSON metadata for the -// struct [RadarAS112SummaryResponseCodesResponse] -type radarAS112SummaryResponseCodesResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryResponseCodesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryResponseCodesResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryResponseCodesResponseMeta struct { - DateRange []RadarAS112SummaryResponseCodesResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarAS112SummaryResponseCodesResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAS112SummaryResponseCodesResponseMetaJSON `json:"-"` -} - -// radarAS112SummaryResponseCodesResponseMetaJSON contains the JSON metadata for -// the struct [RadarAS112SummaryResponseCodesResponseMeta] -type radarAS112SummaryResponseCodesResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryResponseCodesResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryResponseCodesResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryResponseCodesResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAS112SummaryResponseCodesResponseMetaDateRangeJSON `json:"-"` -} - -// radarAS112SummaryResponseCodesResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarAS112SummaryResponseCodesResponseMetaDateRange] -type radarAS112SummaryResponseCodesResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryResponseCodesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryResponseCodesResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryResponseCodesResponseMetaConfidenceInfo struct { - Annotations []RadarAS112SummaryResponseCodesResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAS112SummaryResponseCodesResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAS112SummaryResponseCodesResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarAS112SummaryResponseCodesResponseMetaConfidenceInfo] -type radarAS112SummaryResponseCodesResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryResponseCodesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryResponseCodesResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryResponseCodesResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAS112SummaryResponseCodesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAS112SummaryResponseCodesResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarAS112SummaryResponseCodesResponseMetaConfidenceInfoAnnotation] -type radarAS112SummaryResponseCodesResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryResponseCodesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryResponseCodesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryResponseCodesResponseSummary0 struct { - Noerror string `json:"NOERROR,required"` - Nxdomain string `json:"NXDOMAIN,required"` - JSON radarAS112SummaryResponseCodesResponseSummary0JSON `json:"-"` -} - -// radarAS112SummaryResponseCodesResponseSummary0JSON contains the JSON metadata -// for the struct [RadarAS112SummaryResponseCodesResponseSummary0] -type radarAS112SummaryResponseCodesResponseSummary0JSON struct { - Noerror apijson.Field - Nxdomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryResponseCodesResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryResponseCodesResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryDNSSECParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAS112SummaryDNSSECParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAS112SummaryDNSSECParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAS112SummaryDNSSECParams]'s query parameters as -// `url.Values`. -func (r RadarAS112SummaryDNSSECParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAS112SummaryDNSSECParamsDateRange string - -const ( - RadarAS112SummaryDNSSECParamsDateRange1d RadarAS112SummaryDNSSECParamsDateRange = "1d" - RadarAS112SummaryDNSSECParamsDateRange2d RadarAS112SummaryDNSSECParamsDateRange = "2d" - RadarAS112SummaryDNSSECParamsDateRange7d RadarAS112SummaryDNSSECParamsDateRange = "7d" - RadarAS112SummaryDNSSECParamsDateRange14d RadarAS112SummaryDNSSECParamsDateRange = "14d" - RadarAS112SummaryDNSSECParamsDateRange28d RadarAS112SummaryDNSSECParamsDateRange = "28d" - RadarAS112SummaryDNSSECParamsDateRange12w RadarAS112SummaryDNSSECParamsDateRange = "12w" - RadarAS112SummaryDNSSECParamsDateRange24w RadarAS112SummaryDNSSECParamsDateRange = "24w" - RadarAS112SummaryDNSSECParamsDateRange52w RadarAS112SummaryDNSSECParamsDateRange = "52w" - RadarAS112SummaryDNSSECParamsDateRange1dControl RadarAS112SummaryDNSSECParamsDateRange = "1dControl" - RadarAS112SummaryDNSSECParamsDateRange2dControl RadarAS112SummaryDNSSECParamsDateRange = "2dControl" - RadarAS112SummaryDNSSECParamsDateRange7dControl RadarAS112SummaryDNSSECParamsDateRange = "7dControl" - RadarAS112SummaryDNSSECParamsDateRange14dControl RadarAS112SummaryDNSSECParamsDateRange = "14dControl" - RadarAS112SummaryDNSSECParamsDateRange28dControl RadarAS112SummaryDNSSECParamsDateRange = "28dControl" - RadarAS112SummaryDNSSECParamsDateRange12wControl RadarAS112SummaryDNSSECParamsDateRange = "12wControl" - RadarAS112SummaryDNSSECParamsDateRange24wControl RadarAS112SummaryDNSSECParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAS112SummaryDNSSECParamsFormat string - -const ( - RadarAS112SummaryDNSSECParamsFormatJson RadarAS112SummaryDNSSECParamsFormat = "JSON" - RadarAS112SummaryDNSSECParamsFormatCsv RadarAS112SummaryDNSSECParamsFormat = "CSV" -) - -type RadarAS112SummaryDNSSECResponseEnvelope struct { - Result RadarAS112SummaryDNSSECResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAS112SummaryDNSSECResponseEnvelopeJSON `json:"-"` -} - -// radarAS112SummaryDNSSECResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarAS112SummaryDNSSECResponseEnvelope] -type radarAS112SummaryDNSSECResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryDNSSECResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryDNSSECResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryEdnsParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAS112SummaryEdnsParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAS112SummaryEdnsParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAS112SummaryEdnsParams]'s query parameters as -// `url.Values`. -func (r RadarAS112SummaryEdnsParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAS112SummaryEdnsParamsDateRange string - -const ( - RadarAS112SummaryEdnsParamsDateRange1d RadarAS112SummaryEdnsParamsDateRange = "1d" - RadarAS112SummaryEdnsParamsDateRange2d RadarAS112SummaryEdnsParamsDateRange = "2d" - RadarAS112SummaryEdnsParamsDateRange7d RadarAS112SummaryEdnsParamsDateRange = "7d" - RadarAS112SummaryEdnsParamsDateRange14d RadarAS112SummaryEdnsParamsDateRange = "14d" - RadarAS112SummaryEdnsParamsDateRange28d RadarAS112SummaryEdnsParamsDateRange = "28d" - RadarAS112SummaryEdnsParamsDateRange12w RadarAS112SummaryEdnsParamsDateRange = "12w" - RadarAS112SummaryEdnsParamsDateRange24w RadarAS112SummaryEdnsParamsDateRange = "24w" - RadarAS112SummaryEdnsParamsDateRange52w RadarAS112SummaryEdnsParamsDateRange = "52w" - RadarAS112SummaryEdnsParamsDateRange1dControl RadarAS112SummaryEdnsParamsDateRange = "1dControl" - RadarAS112SummaryEdnsParamsDateRange2dControl RadarAS112SummaryEdnsParamsDateRange = "2dControl" - RadarAS112SummaryEdnsParamsDateRange7dControl RadarAS112SummaryEdnsParamsDateRange = "7dControl" - RadarAS112SummaryEdnsParamsDateRange14dControl RadarAS112SummaryEdnsParamsDateRange = "14dControl" - RadarAS112SummaryEdnsParamsDateRange28dControl RadarAS112SummaryEdnsParamsDateRange = "28dControl" - RadarAS112SummaryEdnsParamsDateRange12wControl RadarAS112SummaryEdnsParamsDateRange = "12wControl" - RadarAS112SummaryEdnsParamsDateRange24wControl RadarAS112SummaryEdnsParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAS112SummaryEdnsParamsFormat string - -const ( - RadarAS112SummaryEdnsParamsFormatJson RadarAS112SummaryEdnsParamsFormat = "JSON" - RadarAS112SummaryEdnsParamsFormatCsv RadarAS112SummaryEdnsParamsFormat = "CSV" -) - -type RadarAS112SummaryEdnsResponseEnvelope struct { - Result RadarAS112SummaryEdnsResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAS112SummaryEdnsResponseEnvelopeJSON `json:"-"` -} - -// radarAS112SummaryEdnsResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarAS112SummaryEdnsResponseEnvelope] -type radarAS112SummaryEdnsResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryEdnsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryEdnsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryIPVersionParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAS112SummaryIPVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAS112SummaryIPVersionParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAS112SummaryIPVersionParams]'s query parameters as -// `url.Values`. -func (r RadarAS112SummaryIPVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAS112SummaryIPVersionParamsDateRange string - -const ( - RadarAS112SummaryIPVersionParamsDateRange1d RadarAS112SummaryIPVersionParamsDateRange = "1d" - RadarAS112SummaryIPVersionParamsDateRange2d RadarAS112SummaryIPVersionParamsDateRange = "2d" - RadarAS112SummaryIPVersionParamsDateRange7d RadarAS112SummaryIPVersionParamsDateRange = "7d" - RadarAS112SummaryIPVersionParamsDateRange14d RadarAS112SummaryIPVersionParamsDateRange = "14d" - RadarAS112SummaryIPVersionParamsDateRange28d RadarAS112SummaryIPVersionParamsDateRange = "28d" - RadarAS112SummaryIPVersionParamsDateRange12w RadarAS112SummaryIPVersionParamsDateRange = "12w" - RadarAS112SummaryIPVersionParamsDateRange24w RadarAS112SummaryIPVersionParamsDateRange = "24w" - RadarAS112SummaryIPVersionParamsDateRange52w RadarAS112SummaryIPVersionParamsDateRange = "52w" - RadarAS112SummaryIPVersionParamsDateRange1dControl RadarAS112SummaryIPVersionParamsDateRange = "1dControl" - RadarAS112SummaryIPVersionParamsDateRange2dControl RadarAS112SummaryIPVersionParamsDateRange = "2dControl" - RadarAS112SummaryIPVersionParamsDateRange7dControl RadarAS112SummaryIPVersionParamsDateRange = "7dControl" - RadarAS112SummaryIPVersionParamsDateRange14dControl RadarAS112SummaryIPVersionParamsDateRange = "14dControl" - RadarAS112SummaryIPVersionParamsDateRange28dControl RadarAS112SummaryIPVersionParamsDateRange = "28dControl" - RadarAS112SummaryIPVersionParamsDateRange12wControl RadarAS112SummaryIPVersionParamsDateRange = "12wControl" - RadarAS112SummaryIPVersionParamsDateRange24wControl RadarAS112SummaryIPVersionParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAS112SummaryIPVersionParamsFormat string - -const ( - RadarAS112SummaryIPVersionParamsFormatJson RadarAS112SummaryIPVersionParamsFormat = "JSON" - RadarAS112SummaryIPVersionParamsFormatCsv RadarAS112SummaryIPVersionParamsFormat = "CSV" -) - -type RadarAS112SummaryIPVersionResponseEnvelope struct { - Result RadarAS112SummaryIPVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAS112SummaryIPVersionResponseEnvelopeJSON `json:"-"` -} - -// radarAS112SummaryIPVersionResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarAS112SummaryIPVersionResponseEnvelope] -type radarAS112SummaryIPVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryIPVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryProtocolParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAS112SummaryProtocolParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAS112SummaryProtocolParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAS112SummaryProtocolParams]'s query parameters as -// `url.Values`. -func (r RadarAS112SummaryProtocolParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAS112SummaryProtocolParamsDateRange string - -const ( - RadarAS112SummaryProtocolParamsDateRange1d RadarAS112SummaryProtocolParamsDateRange = "1d" - RadarAS112SummaryProtocolParamsDateRange2d RadarAS112SummaryProtocolParamsDateRange = "2d" - RadarAS112SummaryProtocolParamsDateRange7d RadarAS112SummaryProtocolParamsDateRange = "7d" - RadarAS112SummaryProtocolParamsDateRange14d RadarAS112SummaryProtocolParamsDateRange = "14d" - RadarAS112SummaryProtocolParamsDateRange28d RadarAS112SummaryProtocolParamsDateRange = "28d" - RadarAS112SummaryProtocolParamsDateRange12w RadarAS112SummaryProtocolParamsDateRange = "12w" - RadarAS112SummaryProtocolParamsDateRange24w RadarAS112SummaryProtocolParamsDateRange = "24w" - RadarAS112SummaryProtocolParamsDateRange52w RadarAS112SummaryProtocolParamsDateRange = "52w" - RadarAS112SummaryProtocolParamsDateRange1dControl RadarAS112SummaryProtocolParamsDateRange = "1dControl" - RadarAS112SummaryProtocolParamsDateRange2dControl RadarAS112SummaryProtocolParamsDateRange = "2dControl" - RadarAS112SummaryProtocolParamsDateRange7dControl RadarAS112SummaryProtocolParamsDateRange = "7dControl" - RadarAS112SummaryProtocolParamsDateRange14dControl RadarAS112SummaryProtocolParamsDateRange = "14dControl" - RadarAS112SummaryProtocolParamsDateRange28dControl RadarAS112SummaryProtocolParamsDateRange = "28dControl" - RadarAS112SummaryProtocolParamsDateRange12wControl RadarAS112SummaryProtocolParamsDateRange = "12wControl" - RadarAS112SummaryProtocolParamsDateRange24wControl RadarAS112SummaryProtocolParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAS112SummaryProtocolParamsFormat string - -const ( - RadarAS112SummaryProtocolParamsFormatJson RadarAS112SummaryProtocolParamsFormat = "JSON" - RadarAS112SummaryProtocolParamsFormatCsv RadarAS112SummaryProtocolParamsFormat = "CSV" -) - -type RadarAS112SummaryProtocolResponseEnvelope struct { - Result RadarAS112SummaryProtocolResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAS112SummaryProtocolResponseEnvelopeJSON `json:"-"` -} - -// radarAS112SummaryProtocolResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarAS112SummaryProtocolResponseEnvelope] -type radarAS112SummaryProtocolResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryProtocolResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryProtocolResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryQueryTypeParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAS112SummaryQueryTypeParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAS112SummaryQueryTypeParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAS112SummaryQueryTypeParams]'s query parameters as -// `url.Values`. -func (r RadarAS112SummaryQueryTypeParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAS112SummaryQueryTypeParamsDateRange string - -const ( - RadarAS112SummaryQueryTypeParamsDateRange1d RadarAS112SummaryQueryTypeParamsDateRange = "1d" - RadarAS112SummaryQueryTypeParamsDateRange2d RadarAS112SummaryQueryTypeParamsDateRange = "2d" - RadarAS112SummaryQueryTypeParamsDateRange7d RadarAS112SummaryQueryTypeParamsDateRange = "7d" - RadarAS112SummaryQueryTypeParamsDateRange14d RadarAS112SummaryQueryTypeParamsDateRange = "14d" - RadarAS112SummaryQueryTypeParamsDateRange28d RadarAS112SummaryQueryTypeParamsDateRange = "28d" - RadarAS112SummaryQueryTypeParamsDateRange12w RadarAS112SummaryQueryTypeParamsDateRange = "12w" - RadarAS112SummaryQueryTypeParamsDateRange24w RadarAS112SummaryQueryTypeParamsDateRange = "24w" - RadarAS112SummaryQueryTypeParamsDateRange52w RadarAS112SummaryQueryTypeParamsDateRange = "52w" - RadarAS112SummaryQueryTypeParamsDateRange1dControl RadarAS112SummaryQueryTypeParamsDateRange = "1dControl" - RadarAS112SummaryQueryTypeParamsDateRange2dControl RadarAS112SummaryQueryTypeParamsDateRange = "2dControl" - RadarAS112SummaryQueryTypeParamsDateRange7dControl RadarAS112SummaryQueryTypeParamsDateRange = "7dControl" - RadarAS112SummaryQueryTypeParamsDateRange14dControl RadarAS112SummaryQueryTypeParamsDateRange = "14dControl" - RadarAS112SummaryQueryTypeParamsDateRange28dControl RadarAS112SummaryQueryTypeParamsDateRange = "28dControl" - RadarAS112SummaryQueryTypeParamsDateRange12wControl RadarAS112SummaryQueryTypeParamsDateRange = "12wControl" - RadarAS112SummaryQueryTypeParamsDateRange24wControl RadarAS112SummaryQueryTypeParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAS112SummaryQueryTypeParamsFormat string - -const ( - RadarAS112SummaryQueryTypeParamsFormatJson RadarAS112SummaryQueryTypeParamsFormat = "JSON" - RadarAS112SummaryQueryTypeParamsFormatCsv RadarAS112SummaryQueryTypeParamsFormat = "CSV" -) - -type RadarAS112SummaryQueryTypeResponseEnvelope struct { - Result RadarAS112SummaryQueryTypeResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAS112SummaryQueryTypeResponseEnvelopeJSON `json:"-"` -} - -// radarAS112SummaryQueryTypeResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarAS112SummaryQueryTypeResponseEnvelope] -type radarAS112SummaryQueryTypeResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryQueryTypeResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryQueryTypeResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112SummaryResponseCodesParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAS112SummaryResponseCodesParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAS112SummaryResponseCodesParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAS112SummaryResponseCodesParams]'s query parameters as -// `url.Values`. -func (r RadarAS112SummaryResponseCodesParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAS112SummaryResponseCodesParamsDateRange string - -const ( - RadarAS112SummaryResponseCodesParamsDateRange1d RadarAS112SummaryResponseCodesParamsDateRange = "1d" - RadarAS112SummaryResponseCodesParamsDateRange2d RadarAS112SummaryResponseCodesParamsDateRange = "2d" - RadarAS112SummaryResponseCodesParamsDateRange7d RadarAS112SummaryResponseCodesParamsDateRange = "7d" - RadarAS112SummaryResponseCodesParamsDateRange14d RadarAS112SummaryResponseCodesParamsDateRange = "14d" - RadarAS112SummaryResponseCodesParamsDateRange28d RadarAS112SummaryResponseCodesParamsDateRange = "28d" - RadarAS112SummaryResponseCodesParamsDateRange12w RadarAS112SummaryResponseCodesParamsDateRange = "12w" - RadarAS112SummaryResponseCodesParamsDateRange24w RadarAS112SummaryResponseCodesParamsDateRange = "24w" - RadarAS112SummaryResponseCodesParamsDateRange52w RadarAS112SummaryResponseCodesParamsDateRange = "52w" - RadarAS112SummaryResponseCodesParamsDateRange1dControl RadarAS112SummaryResponseCodesParamsDateRange = "1dControl" - RadarAS112SummaryResponseCodesParamsDateRange2dControl RadarAS112SummaryResponseCodesParamsDateRange = "2dControl" - RadarAS112SummaryResponseCodesParamsDateRange7dControl RadarAS112SummaryResponseCodesParamsDateRange = "7dControl" - RadarAS112SummaryResponseCodesParamsDateRange14dControl RadarAS112SummaryResponseCodesParamsDateRange = "14dControl" - RadarAS112SummaryResponseCodesParamsDateRange28dControl RadarAS112SummaryResponseCodesParamsDateRange = "28dControl" - RadarAS112SummaryResponseCodesParamsDateRange12wControl RadarAS112SummaryResponseCodesParamsDateRange = "12wControl" - RadarAS112SummaryResponseCodesParamsDateRange24wControl RadarAS112SummaryResponseCodesParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAS112SummaryResponseCodesParamsFormat string - -const ( - RadarAS112SummaryResponseCodesParamsFormatJson RadarAS112SummaryResponseCodesParamsFormat = "JSON" - RadarAS112SummaryResponseCodesParamsFormatCsv RadarAS112SummaryResponseCodesParamsFormat = "CSV" -) - -type RadarAS112SummaryResponseCodesResponseEnvelope struct { - Result RadarAS112SummaryResponseCodesResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAS112SummaryResponseCodesResponseEnvelopeJSON `json:"-"` -} - -// radarAS112SummaryResponseCodesResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarAS112SummaryResponseCodesResponseEnvelope] -type radarAS112SummaryResponseCodesResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112SummaryResponseCodesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112SummaryResponseCodesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radaras112summary_test.go b/radaras112summary_test.go deleted file mode 100644 index aab7125d203..00000000000 --- a/radaras112summary_test.go +++ /dev/null @@ -1,213 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarAS112SummaryDNSSECWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.AS112.Summary.DNSSEC(context.TODO(), cloudflare.RadarAS112SummaryDNSSECParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAS112SummaryDNSSECParamsDateRange{cloudflare.RadarAS112SummaryDNSSECParamsDateRange1d, cloudflare.RadarAS112SummaryDNSSECParamsDateRange2d, cloudflare.RadarAS112SummaryDNSSECParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAS112SummaryDNSSECParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAS112SummaryEdnsWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.AS112.Summary.Edns(context.TODO(), cloudflare.RadarAS112SummaryEdnsParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAS112SummaryEdnsParamsDateRange{cloudflare.RadarAS112SummaryEdnsParamsDateRange1d, cloudflare.RadarAS112SummaryEdnsParamsDateRange2d, cloudflare.RadarAS112SummaryEdnsParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAS112SummaryEdnsParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAS112SummaryIPVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.AS112.Summary.IPVersion(context.TODO(), cloudflare.RadarAS112SummaryIPVersionParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAS112SummaryIPVersionParamsDateRange{cloudflare.RadarAS112SummaryIPVersionParamsDateRange1d, cloudflare.RadarAS112SummaryIPVersionParamsDateRange2d, cloudflare.RadarAS112SummaryIPVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAS112SummaryIPVersionParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAS112SummaryProtocolWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.AS112.Summary.Protocol(context.TODO(), cloudflare.RadarAS112SummaryProtocolParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAS112SummaryProtocolParamsDateRange{cloudflare.RadarAS112SummaryProtocolParamsDateRange1d, cloudflare.RadarAS112SummaryProtocolParamsDateRange2d, cloudflare.RadarAS112SummaryProtocolParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAS112SummaryProtocolParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAS112SummaryQueryTypeWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.AS112.Summary.QueryType(context.TODO(), cloudflare.RadarAS112SummaryQueryTypeParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAS112SummaryQueryTypeParamsDateRange{cloudflare.RadarAS112SummaryQueryTypeParamsDateRange1d, cloudflare.RadarAS112SummaryQueryTypeParamsDateRange2d, cloudflare.RadarAS112SummaryQueryTypeParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAS112SummaryQueryTypeParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAS112SummaryResponseCodesWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.AS112.Summary.ResponseCodes(context.TODO(), cloudflare.RadarAS112SummaryResponseCodesParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAS112SummaryResponseCodesParamsDateRange{cloudflare.RadarAS112SummaryResponseCodesParamsDateRange1d, cloudflare.RadarAS112SummaryResponseCodesParamsDateRange2d, cloudflare.RadarAS112SummaryResponseCodesParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAS112SummaryResponseCodesParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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/radaras112timeseriesgroup.go b/radaras112timeseriesgroup.go deleted file mode 100644 index 155d59dde10..00000000000 --- a/radaras112timeseriesgroup.go +++ /dev/null @@ -1,1013 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarAS112TimeseriesGroupService 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 -// [NewRadarAS112TimeseriesGroupService] method instead. -type RadarAS112TimeseriesGroupService struct { - Options []option.RequestOption -} - -// NewRadarAS112TimeseriesGroupService 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 NewRadarAS112TimeseriesGroupService(opts ...option.RequestOption) (r *RadarAS112TimeseriesGroupService) { - r = &RadarAS112TimeseriesGroupService{} - r.Options = opts - return -} - -// Percentage distribution of DNS AS112 queries by DNSSEC support over time. -func (r *RadarAS112TimeseriesGroupService) DNSSEC(ctx context.Context, query RadarAS112TimeseriesGroupDNSSECParams, opts ...option.RequestOption) (res *RadarAS112TimeseriesGroupDNSSECResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAS112TimeseriesGroupDNSSECResponseEnvelope - path := "radar/as112/timeseries_groups/dnssec" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of AS112 DNS queries by EDNS support over time. -func (r *RadarAS112TimeseriesGroupService) Edns(ctx context.Context, query RadarAS112TimeseriesGroupEdnsParams, opts ...option.RequestOption) (res *RadarAS112TimeseriesGroupEdnsResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAS112TimeseriesGroupEdnsResponseEnvelope - path := "radar/as112/timeseries_groups/edns" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of AS112 DNS queries by IP Version over time. -func (r *RadarAS112TimeseriesGroupService) IPVersion(ctx context.Context, query RadarAS112TimeseriesGroupIPVersionParams, opts ...option.RequestOption) (res *RadarAS112TimeseriesGroupIPVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAS112TimeseriesGroupIPVersionResponseEnvelope - path := "radar/as112/timeseries_groups/ip_version" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of AS112 dns requests classified per Protocol over time. -func (r *RadarAS112TimeseriesGroupService) Protocol(ctx context.Context, query RadarAS112TimeseriesGroupProtocolParams, opts ...option.RequestOption) (res *RadarAS112TimeseriesGroupProtocolResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAS112TimeseriesGroupProtocolResponseEnvelope - path := "radar/as112/timeseries_groups/protocol" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of AS112 DNS queries by Query Type over time. -func (r *RadarAS112TimeseriesGroupService) QueryType(ctx context.Context, query RadarAS112TimeseriesGroupQueryTypeParams, opts ...option.RequestOption) (res *RadarAS112TimeseriesGroupQueryTypeResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAS112TimeseriesGroupQueryTypeResponseEnvelope - path := "radar/as112/timeseries_groups/query_type" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of AS112 dns requests classified per Response Codes over -// time. -func (r *RadarAS112TimeseriesGroupService) ResponseCodes(ctx context.Context, query RadarAS112TimeseriesGroupResponseCodesParams, opts ...option.RequestOption) (res *RadarAS112TimeseriesGroupResponseCodesResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAS112TimeseriesGroupResponseCodesResponseEnvelope - path := "radar/as112/timeseries_groups/response_codes" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarAS112TimeseriesGroupDNSSECResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAS112TimeseriesGroupDNSSECResponseSerie0 `json:"serie_0,required"` - JSON radarAS112TimeseriesGroupDNSSECResponseJSON `json:"-"` -} - -// radarAS112TimeseriesGroupDNSSECResponseJSON contains the JSON metadata for the -// struct [RadarAS112TimeseriesGroupDNSSECResponse] -type radarAS112TimeseriesGroupDNSSECResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesGroupDNSSECResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesGroupDNSSECResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesGroupDNSSECResponseSerie0 struct { - NotSupported []string `json:"NOT_SUPPORTED,required"` - Supported []string `json:"SUPPORTED,required"` - JSON radarAS112TimeseriesGroupDNSSECResponseSerie0JSON `json:"-"` -} - -// radarAS112TimeseriesGroupDNSSECResponseSerie0JSON contains the JSON metadata for -// the struct [RadarAS112TimeseriesGroupDNSSECResponseSerie0] -type radarAS112TimeseriesGroupDNSSECResponseSerie0JSON struct { - NotSupported apijson.Field - Supported apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesGroupDNSSECResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesGroupDNSSECResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesGroupEdnsResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAS112TimeseriesGroupEdnsResponseSerie0 `json:"serie_0,required"` - JSON radarAS112TimeseriesGroupEdnsResponseJSON `json:"-"` -} - -// radarAS112TimeseriesGroupEdnsResponseJSON contains the JSON metadata for the -// struct [RadarAS112TimeseriesGroupEdnsResponse] -type radarAS112TimeseriesGroupEdnsResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesGroupEdnsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesGroupEdnsResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesGroupEdnsResponseSerie0 struct { - NotSupported []string `json:"NOT_SUPPORTED,required"` - Supported []string `json:"SUPPORTED,required"` - JSON radarAS112TimeseriesGroupEdnsResponseSerie0JSON `json:"-"` -} - -// radarAS112TimeseriesGroupEdnsResponseSerie0JSON contains the JSON metadata for -// the struct [RadarAS112TimeseriesGroupEdnsResponseSerie0] -type radarAS112TimeseriesGroupEdnsResponseSerie0JSON struct { - NotSupported apijson.Field - Supported apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesGroupEdnsResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesGroupEdnsResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesGroupIPVersionResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAS112TimeseriesGroupIPVersionResponseSerie0 `json:"serie_0,required"` - JSON radarAS112TimeseriesGroupIPVersionResponseJSON `json:"-"` -} - -// radarAS112TimeseriesGroupIPVersionResponseJSON contains the JSON metadata for -// the struct [RadarAS112TimeseriesGroupIPVersionResponse] -type radarAS112TimeseriesGroupIPVersionResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesGroupIPVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesGroupIPVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesGroupIPVersionResponseSerie0 struct { - IPv4 []string `json:"IPv4,required"` - IPv6 []string `json:"IPv6,required"` - JSON radarAS112TimeseriesGroupIPVersionResponseSerie0JSON `json:"-"` -} - -// radarAS112TimeseriesGroupIPVersionResponseSerie0JSON contains the JSON metadata -// for the struct [RadarAS112TimeseriesGroupIPVersionResponseSerie0] -type radarAS112TimeseriesGroupIPVersionResponseSerie0JSON struct { - IPv4 apijson.Field - IPv6 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesGroupIPVersionResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesGroupIPVersionResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesGroupProtocolResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAS112TimeseriesGroupProtocolResponseSerie0 `json:"serie_0,required"` - JSON radarAS112TimeseriesGroupProtocolResponseJSON `json:"-"` -} - -// radarAS112TimeseriesGroupProtocolResponseJSON contains the JSON metadata for the -// struct [RadarAS112TimeseriesGroupProtocolResponse] -type radarAS112TimeseriesGroupProtocolResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesGroupProtocolResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesGroupProtocolResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesGroupProtocolResponseSerie0 struct { - Tcp []string `json:"tcp,required"` - Udp []string `json:"udp,required"` - JSON radarAS112TimeseriesGroupProtocolResponseSerie0JSON `json:"-"` -} - -// radarAS112TimeseriesGroupProtocolResponseSerie0JSON contains the JSON metadata -// for the struct [RadarAS112TimeseriesGroupProtocolResponseSerie0] -type radarAS112TimeseriesGroupProtocolResponseSerie0JSON struct { - Tcp apijson.Field - Udp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesGroupProtocolResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesGroupProtocolResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesGroupQueryTypeResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAS112TimeseriesGroupQueryTypeResponseSerie0 `json:"serie_0,required"` - JSON radarAS112TimeseriesGroupQueryTypeResponseJSON `json:"-"` -} - -// radarAS112TimeseriesGroupQueryTypeResponseJSON contains the JSON metadata for -// the struct [RadarAS112TimeseriesGroupQueryTypeResponse] -type radarAS112TimeseriesGroupQueryTypeResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesGroupQueryTypeResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesGroupQueryTypeResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesGroupQueryTypeResponseSerie0 struct { - A []string `json:"A,required"` - AAAA []string `json:"AAAA,required"` - PTR []string `json:"PTR,required"` - Soa []string `json:"SOA,required"` - SRV []string `json:"SRV,required"` - JSON radarAS112TimeseriesGroupQueryTypeResponseSerie0JSON `json:"-"` -} - -// radarAS112TimeseriesGroupQueryTypeResponseSerie0JSON contains the JSON metadata -// for the struct [RadarAS112TimeseriesGroupQueryTypeResponseSerie0] -type radarAS112TimeseriesGroupQueryTypeResponseSerie0JSON struct { - A apijson.Field - AAAA apijson.Field - PTR apijson.Field - Soa apijson.Field - SRV apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesGroupQueryTypeResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesGroupQueryTypeResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesGroupResponseCodesResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAS112TimeseriesGroupResponseCodesResponseSerie0 `json:"serie_0,required"` - JSON radarAS112TimeseriesGroupResponseCodesResponseJSON `json:"-"` -} - -// radarAS112TimeseriesGroupResponseCodesResponseJSON contains the JSON metadata -// for the struct [RadarAS112TimeseriesGroupResponseCodesResponse] -type radarAS112TimeseriesGroupResponseCodesResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesGroupResponseCodesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesGroupResponseCodesResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesGroupResponseCodesResponseSerie0 struct { - Noerror []string `json:"NOERROR,required"` - Nxdomain []string `json:"NXDOMAIN,required"` - JSON radarAS112TimeseriesGroupResponseCodesResponseSerie0JSON `json:"-"` -} - -// radarAS112TimeseriesGroupResponseCodesResponseSerie0JSON contains the JSON -// metadata for the struct [RadarAS112TimeseriesGroupResponseCodesResponseSerie0] -type radarAS112TimeseriesGroupResponseCodesResponseSerie0JSON struct { - Noerror apijson.Field - Nxdomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesGroupResponseCodesResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesGroupResponseCodesResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesGroupDNSSECParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAS112TimeseriesGroupDNSSECParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAS112TimeseriesGroupDNSSECParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAS112TimeseriesGroupDNSSECParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAS112TimeseriesGroupDNSSECParams]'s query parameters -// as `url.Values`. -func (r RadarAS112TimeseriesGroupDNSSECParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAS112TimeseriesGroupDNSSECParamsAggInterval string - -const ( - RadarAS112TimeseriesGroupDNSSECParamsAggInterval15m RadarAS112TimeseriesGroupDNSSECParamsAggInterval = "15m" - RadarAS112TimeseriesGroupDNSSECParamsAggInterval1h RadarAS112TimeseriesGroupDNSSECParamsAggInterval = "1h" - RadarAS112TimeseriesGroupDNSSECParamsAggInterval1d RadarAS112TimeseriesGroupDNSSECParamsAggInterval = "1d" - RadarAS112TimeseriesGroupDNSSECParamsAggInterval1w RadarAS112TimeseriesGroupDNSSECParamsAggInterval = "1w" -) - -type RadarAS112TimeseriesGroupDNSSECParamsDateRange string - -const ( - RadarAS112TimeseriesGroupDNSSECParamsDateRange1d RadarAS112TimeseriesGroupDNSSECParamsDateRange = "1d" - RadarAS112TimeseriesGroupDNSSECParamsDateRange2d RadarAS112TimeseriesGroupDNSSECParamsDateRange = "2d" - RadarAS112TimeseriesGroupDNSSECParamsDateRange7d RadarAS112TimeseriesGroupDNSSECParamsDateRange = "7d" - RadarAS112TimeseriesGroupDNSSECParamsDateRange14d RadarAS112TimeseriesGroupDNSSECParamsDateRange = "14d" - RadarAS112TimeseriesGroupDNSSECParamsDateRange28d RadarAS112TimeseriesGroupDNSSECParamsDateRange = "28d" - RadarAS112TimeseriesGroupDNSSECParamsDateRange12w RadarAS112TimeseriesGroupDNSSECParamsDateRange = "12w" - RadarAS112TimeseriesGroupDNSSECParamsDateRange24w RadarAS112TimeseriesGroupDNSSECParamsDateRange = "24w" - RadarAS112TimeseriesGroupDNSSECParamsDateRange52w RadarAS112TimeseriesGroupDNSSECParamsDateRange = "52w" - RadarAS112TimeseriesGroupDNSSECParamsDateRange1dControl RadarAS112TimeseriesGroupDNSSECParamsDateRange = "1dControl" - RadarAS112TimeseriesGroupDNSSECParamsDateRange2dControl RadarAS112TimeseriesGroupDNSSECParamsDateRange = "2dControl" - RadarAS112TimeseriesGroupDNSSECParamsDateRange7dControl RadarAS112TimeseriesGroupDNSSECParamsDateRange = "7dControl" - RadarAS112TimeseriesGroupDNSSECParamsDateRange14dControl RadarAS112TimeseriesGroupDNSSECParamsDateRange = "14dControl" - RadarAS112TimeseriesGroupDNSSECParamsDateRange28dControl RadarAS112TimeseriesGroupDNSSECParamsDateRange = "28dControl" - RadarAS112TimeseriesGroupDNSSECParamsDateRange12wControl RadarAS112TimeseriesGroupDNSSECParamsDateRange = "12wControl" - RadarAS112TimeseriesGroupDNSSECParamsDateRange24wControl RadarAS112TimeseriesGroupDNSSECParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAS112TimeseriesGroupDNSSECParamsFormat string - -const ( - RadarAS112TimeseriesGroupDNSSECParamsFormatJson RadarAS112TimeseriesGroupDNSSECParamsFormat = "JSON" - RadarAS112TimeseriesGroupDNSSECParamsFormatCsv RadarAS112TimeseriesGroupDNSSECParamsFormat = "CSV" -) - -type RadarAS112TimeseriesGroupDNSSECResponseEnvelope struct { - Result RadarAS112TimeseriesGroupDNSSECResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAS112TimeseriesGroupDNSSECResponseEnvelopeJSON `json:"-"` -} - -// radarAS112TimeseriesGroupDNSSECResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarAS112TimeseriesGroupDNSSECResponseEnvelope] -type radarAS112TimeseriesGroupDNSSECResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesGroupDNSSECResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesGroupDNSSECResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesGroupEdnsParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAS112TimeseriesGroupEdnsParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAS112TimeseriesGroupEdnsParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAS112TimeseriesGroupEdnsParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAS112TimeseriesGroupEdnsParams]'s query parameters as -// `url.Values`. -func (r RadarAS112TimeseriesGroupEdnsParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAS112TimeseriesGroupEdnsParamsAggInterval string - -const ( - RadarAS112TimeseriesGroupEdnsParamsAggInterval15m RadarAS112TimeseriesGroupEdnsParamsAggInterval = "15m" - RadarAS112TimeseriesGroupEdnsParamsAggInterval1h RadarAS112TimeseriesGroupEdnsParamsAggInterval = "1h" - RadarAS112TimeseriesGroupEdnsParamsAggInterval1d RadarAS112TimeseriesGroupEdnsParamsAggInterval = "1d" - RadarAS112TimeseriesGroupEdnsParamsAggInterval1w RadarAS112TimeseriesGroupEdnsParamsAggInterval = "1w" -) - -type RadarAS112TimeseriesGroupEdnsParamsDateRange string - -const ( - RadarAS112TimeseriesGroupEdnsParamsDateRange1d RadarAS112TimeseriesGroupEdnsParamsDateRange = "1d" - RadarAS112TimeseriesGroupEdnsParamsDateRange2d RadarAS112TimeseriesGroupEdnsParamsDateRange = "2d" - RadarAS112TimeseriesGroupEdnsParamsDateRange7d RadarAS112TimeseriesGroupEdnsParamsDateRange = "7d" - RadarAS112TimeseriesGroupEdnsParamsDateRange14d RadarAS112TimeseriesGroupEdnsParamsDateRange = "14d" - RadarAS112TimeseriesGroupEdnsParamsDateRange28d RadarAS112TimeseriesGroupEdnsParamsDateRange = "28d" - RadarAS112TimeseriesGroupEdnsParamsDateRange12w RadarAS112TimeseriesGroupEdnsParamsDateRange = "12w" - RadarAS112TimeseriesGroupEdnsParamsDateRange24w RadarAS112TimeseriesGroupEdnsParamsDateRange = "24w" - RadarAS112TimeseriesGroupEdnsParamsDateRange52w RadarAS112TimeseriesGroupEdnsParamsDateRange = "52w" - RadarAS112TimeseriesGroupEdnsParamsDateRange1dControl RadarAS112TimeseriesGroupEdnsParamsDateRange = "1dControl" - RadarAS112TimeseriesGroupEdnsParamsDateRange2dControl RadarAS112TimeseriesGroupEdnsParamsDateRange = "2dControl" - RadarAS112TimeseriesGroupEdnsParamsDateRange7dControl RadarAS112TimeseriesGroupEdnsParamsDateRange = "7dControl" - RadarAS112TimeseriesGroupEdnsParamsDateRange14dControl RadarAS112TimeseriesGroupEdnsParamsDateRange = "14dControl" - RadarAS112TimeseriesGroupEdnsParamsDateRange28dControl RadarAS112TimeseriesGroupEdnsParamsDateRange = "28dControl" - RadarAS112TimeseriesGroupEdnsParamsDateRange12wControl RadarAS112TimeseriesGroupEdnsParamsDateRange = "12wControl" - RadarAS112TimeseriesGroupEdnsParamsDateRange24wControl RadarAS112TimeseriesGroupEdnsParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAS112TimeseriesGroupEdnsParamsFormat string - -const ( - RadarAS112TimeseriesGroupEdnsParamsFormatJson RadarAS112TimeseriesGroupEdnsParamsFormat = "JSON" - RadarAS112TimeseriesGroupEdnsParamsFormatCsv RadarAS112TimeseriesGroupEdnsParamsFormat = "CSV" -) - -type RadarAS112TimeseriesGroupEdnsResponseEnvelope struct { - Result RadarAS112TimeseriesGroupEdnsResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAS112TimeseriesGroupEdnsResponseEnvelopeJSON `json:"-"` -} - -// radarAS112TimeseriesGroupEdnsResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarAS112TimeseriesGroupEdnsResponseEnvelope] -type radarAS112TimeseriesGroupEdnsResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesGroupEdnsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesGroupEdnsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesGroupIPVersionParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAS112TimeseriesGroupIPVersionParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAS112TimeseriesGroupIPVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAS112TimeseriesGroupIPVersionParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAS112TimeseriesGroupIPVersionParams]'s query -// parameters as `url.Values`. -func (r RadarAS112TimeseriesGroupIPVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAS112TimeseriesGroupIPVersionParamsAggInterval string - -const ( - RadarAS112TimeseriesGroupIPVersionParamsAggInterval15m RadarAS112TimeseriesGroupIPVersionParamsAggInterval = "15m" - RadarAS112TimeseriesGroupIPVersionParamsAggInterval1h RadarAS112TimeseriesGroupIPVersionParamsAggInterval = "1h" - RadarAS112TimeseriesGroupIPVersionParamsAggInterval1d RadarAS112TimeseriesGroupIPVersionParamsAggInterval = "1d" - RadarAS112TimeseriesGroupIPVersionParamsAggInterval1w RadarAS112TimeseriesGroupIPVersionParamsAggInterval = "1w" -) - -type RadarAS112TimeseriesGroupIPVersionParamsDateRange string - -const ( - RadarAS112TimeseriesGroupIPVersionParamsDateRange1d RadarAS112TimeseriesGroupIPVersionParamsDateRange = "1d" - RadarAS112TimeseriesGroupIPVersionParamsDateRange2d RadarAS112TimeseriesGroupIPVersionParamsDateRange = "2d" - RadarAS112TimeseriesGroupIPVersionParamsDateRange7d RadarAS112TimeseriesGroupIPVersionParamsDateRange = "7d" - RadarAS112TimeseriesGroupIPVersionParamsDateRange14d RadarAS112TimeseriesGroupIPVersionParamsDateRange = "14d" - RadarAS112TimeseriesGroupIPVersionParamsDateRange28d RadarAS112TimeseriesGroupIPVersionParamsDateRange = "28d" - RadarAS112TimeseriesGroupIPVersionParamsDateRange12w RadarAS112TimeseriesGroupIPVersionParamsDateRange = "12w" - RadarAS112TimeseriesGroupIPVersionParamsDateRange24w RadarAS112TimeseriesGroupIPVersionParamsDateRange = "24w" - RadarAS112TimeseriesGroupIPVersionParamsDateRange52w RadarAS112TimeseriesGroupIPVersionParamsDateRange = "52w" - RadarAS112TimeseriesGroupIPVersionParamsDateRange1dControl RadarAS112TimeseriesGroupIPVersionParamsDateRange = "1dControl" - RadarAS112TimeseriesGroupIPVersionParamsDateRange2dControl RadarAS112TimeseriesGroupIPVersionParamsDateRange = "2dControl" - RadarAS112TimeseriesGroupIPVersionParamsDateRange7dControl RadarAS112TimeseriesGroupIPVersionParamsDateRange = "7dControl" - RadarAS112TimeseriesGroupIPVersionParamsDateRange14dControl RadarAS112TimeseriesGroupIPVersionParamsDateRange = "14dControl" - RadarAS112TimeseriesGroupIPVersionParamsDateRange28dControl RadarAS112TimeseriesGroupIPVersionParamsDateRange = "28dControl" - RadarAS112TimeseriesGroupIPVersionParamsDateRange12wControl RadarAS112TimeseriesGroupIPVersionParamsDateRange = "12wControl" - RadarAS112TimeseriesGroupIPVersionParamsDateRange24wControl RadarAS112TimeseriesGroupIPVersionParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAS112TimeseriesGroupIPVersionParamsFormat string - -const ( - RadarAS112TimeseriesGroupIPVersionParamsFormatJson RadarAS112TimeseriesGroupIPVersionParamsFormat = "JSON" - RadarAS112TimeseriesGroupIPVersionParamsFormatCsv RadarAS112TimeseriesGroupIPVersionParamsFormat = "CSV" -) - -type RadarAS112TimeseriesGroupIPVersionResponseEnvelope struct { - Result RadarAS112TimeseriesGroupIPVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAS112TimeseriesGroupIPVersionResponseEnvelopeJSON `json:"-"` -} - -// radarAS112TimeseriesGroupIPVersionResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarAS112TimeseriesGroupIPVersionResponseEnvelope] -type radarAS112TimeseriesGroupIPVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesGroupIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesGroupIPVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesGroupProtocolParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAS112TimeseriesGroupProtocolParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAS112TimeseriesGroupProtocolParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAS112TimeseriesGroupProtocolParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAS112TimeseriesGroupProtocolParams]'s query parameters -// as `url.Values`. -func (r RadarAS112TimeseriesGroupProtocolParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAS112TimeseriesGroupProtocolParamsAggInterval string - -const ( - RadarAS112TimeseriesGroupProtocolParamsAggInterval15m RadarAS112TimeseriesGroupProtocolParamsAggInterval = "15m" - RadarAS112TimeseriesGroupProtocolParamsAggInterval1h RadarAS112TimeseriesGroupProtocolParamsAggInterval = "1h" - RadarAS112TimeseriesGroupProtocolParamsAggInterval1d RadarAS112TimeseriesGroupProtocolParamsAggInterval = "1d" - RadarAS112TimeseriesGroupProtocolParamsAggInterval1w RadarAS112TimeseriesGroupProtocolParamsAggInterval = "1w" -) - -type RadarAS112TimeseriesGroupProtocolParamsDateRange string - -const ( - RadarAS112TimeseriesGroupProtocolParamsDateRange1d RadarAS112TimeseriesGroupProtocolParamsDateRange = "1d" - RadarAS112TimeseriesGroupProtocolParamsDateRange2d RadarAS112TimeseriesGroupProtocolParamsDateRange = "2d" - RadarAS112TimeseriesGroupProtocolParamsDateRange7d RadarAS112TimeseriesGroupProtocolParamsDateRange = "7d" - RadarAS112TimeseriesGroupProtocolParamsDateRange14d RadarAS112TimeseriesGroupProtocolParamsDateRange = "14d" - RadarAS112TimeseriesGroupProtocolParamsDateRange28d RadarAS112TimeseriesGroupProtocolParamsDateRange = "28d" - RadarAS112TimeseriesGroupProtocolParamsDateRange12w RadarAS112TimeseriesGroupProtocolParamsDateRange = "12w" - RadarAS112TimeseriesGroupProtocolParamsDateRange24w RadarAS112TimeseriesGroupProtocolParamsDateRange = "24w" - RadarAS112TimeseriesGroupProtocolParamsDateRange52w RadarAS112TimeseriesGroupProtocolParamsDateRange = "52w" - RadarAS112TimeseriesGroupProtocolParamsDateRange1dControl RadarAS112TimeseriesGroupProtocolParamsDateRange = "1dControl" - RadarAS112TimeseriesGroupProtocolParamsDateRange2dControl RadarAS112TimeseriesGroupProtocolParamsDateRange = "2dControl" - RadarAS112TimeseriesGroupProtocolParamsDateRange7dControl RadarAS112TimeseriesGroupProtocolParamsDateRange = "7dControl" - RadarAS112TimeseriesGroupProtocolParamsDateRange14dControl RadarAS112TimeseriesGroupProtocolParamsDateRange = "14dControl" - RadarAS112TimeseriesGroupProtocolParamsDateRange28dControl RadarAS112TimeseriesGroupProtocolParamsDateRange = "28dControl" - RadarAS112TimeseriesGroupProtocolParamsDateRange12wControl RadarAS112TimeseriesGroupProtocolParamsDateRange = "12wControl" - RadarAS112TimeseriesGroupProtocolParamsDateRange24wControl RadarAS112TimeseriesGroupProtocolParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAS112TimeseriesGroupProtocolParamsFormat string - -const ( - RadarAS112TimeseriesGroupProtocolParamsFormatJson RadarAS112TimeseriesGroupProtocolParamsFormat = "JSON" - RadarAS112TimeseriesGroupProtocolParamsFormatCsv RadarAS112TimeseriesGroupProtocolParamsFormat = "CSV" -) - -type RadarAS112TimeseriesGroupProtocolResponseEnvelope struct { - Result RadarAS112TimeseriesGroupProtocolResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAS112TimeseriesGroupProtocolResponseEnvelopeJSON `json:"-"` -} - -// radarAS112TimeseriesGroupProtocolResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarAS112TimeseriesGroupProtocolResponseEnvelope] -type radarAS112TimeseriesGroupProtocolResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesGroupProtocolResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesGroupProtocolResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesGroupQueryTypeParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAS112TimeseriesGroupQueryTypeParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAS112TimeseriesGroupQueryTypeParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAS112TimeseriesGroupQueryTypeParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAS112TimeseriesGroupQueryTypeParams]'s query -// parameters as `url.Values`. -func (r RadarAS112TimeseriesGroupQueryTypeParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAS112TimeseriesGroupQueryTypeParamsAggInterval string - -const ( - RadarAS112TimeseriesGroupQueryTypeParamsAggInterval15m RadarAS112TimeseriesGroupQueryTypeParamsAggInterval = "15m" - RadarAS112TimeseriesGroupQueryTypeParamsAggInterval1h RadarAS112TimeseriesGroupQueryTypeParamsAggInterval = "1h" - RadarAS112TimeseriesGroupQueryTypeParamsAggInterval1d RadarAS112TimeseriesGroupQueryTypeParamsAggInterval = "1d" - RadarAS112TimeseriesGroupQueryTypeParamsAggInterval1w RadarAS112TimeseriesGroupQueryTypeParamsAggInterval = "1w" -) - -type RadarAS112TimeseriesGroupQueryTypeParamsDateRange string - -const ( - RadarAS112TimeseriesGroupQueryTypeParamsDateRange1d RadarAS112TimeseriesGroupQueryTypeParamsDateRange = "1d" - RadarAS112TimeseriesGroupQueryTypeParamsDateRange2d RadarAS112TimeseriesGroupQueryTypeParamsDateRange = "2d" - RadarAS112TimeseriesGroupQueryTypeParamsDateRange7d RadarAS112TimeseriesGroupQueryTypeParamsDateRange = "7d" - RadarAS112TimeseriesGroupQueryTypeParamsDateRange14d RadarAS112TimeseriesGroupQueryTypeParamsDateRange = "14d" - RadarAS112TimeseriesGroupQueryTypeParamsDateRange28d RadarAS112TimeseriesGroupQueryTypeParamsDateRange = "28d" - RadarAS112TimeseriesGroupQueryTypeParamsDateRange12w RadarAS112TimeseriesGroupQueryTypeParamsDateRange = "12w" - RadarAS112TimeseriesGroupQueryTypeParamsDateRange24w RadarAS112TimeseriesGroupQueryTypeParamsDateRange = "24w" - RadarAS112TimeseriesGroupQueryTypeParamsDateRange52w RadarAS112TimeseriesGroupQueryTypeParamsDateRange = "52w" - RadarAS112TimeseriesGroupQueryTypeParamsDateRange1dControl RadarAS112TimeseriesGroupQueryTypeParamsDateRange = "1dControl" - RadarAS112TimeseriesGroupQueryTypeParamsDateRange2dControl RadarAS112TimeseriesGroupQueryTypeParamsDateRange = "2dControl" - RadarAS112TimeseriesGroupQueryTypeParamsDateRange7dControl RadarAS112TimeseriesGroupQueryTypeParamsDateRange = "7dControl" - RadarAS112TimeseriesGroupQueryTypeParamsDateRange14dControl RadarAS112TimeseriesGroupQueryTypeParamsDateRange = "14dControl" - RadarAS112TimeseriesGroupQueryTypeParamsDateRange28dControl RadarAS112TimeseriesGroupQueryTypeParamsDateRange = "28dControl" - RadarAS112TimeseriesGroupQueryTypeParamsDateRange12wControl RadarAS112TimeseriesGroupQueryTypeParamsDateRange = "12wControl" - RadarAS112TimeseriesGroupQueryTypeParamsDateRange24wControl RadarAS112TimeseriesGroupQueryTypeParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAS112TimeseriesGroupQueryTypeParamsFormat string - -const ( - RadarAS112TimeseriesGroupQueryTypeParamsFormatJson RadarAS112TimeseriesGroupQueryTypeParamsFormat = "JSON" - RadarAS112TimeseriesGroupQueryTypeParamsFormatCsv RadarAS112TimeseriesGroupQueryTypeParamsFormat = "CSV" -) - -type RadarAS112TimeseriesGroupQueryTypeResponseEnvelope struct { - Result RadarAS112TimeseriesGroupQueryTypeResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAS112TimeseriesGroupQueryTypeResponseEnvelopeJSON `json:"-"` -} - -// radarAS112TimeseriesGroupQueryTypeResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarAS112TimeseriesGroupQueryTypeResponseEnvelope] -type radarAS112TimeseriesGroupQueryTypeResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesGroupQueryTypeResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesGroupQueryTypeResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TimeseriesGroupResponseCodesParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAS112TimeseriesGroupResponseCodesParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAS112TimeseriesGroupResponseCodesParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAS112TimeseriesGroupResponseCodesParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAS112TimeseriesGroupResponseCodesParams]'s query -// parameters as `url.Values`. -func (r RadarAS112TimeseriesGroupResponseCodesParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAS112TimeseriesGroupResponseCodesParamsAggInterval string - -const ( - RadarAS112TimeseriesGroupResponseCodesParamsAggInterval15m RadarAS112TimeseriesGroupResponseCodesParamsAggInterval = "15m" - RadarAS112TimeseriesGroupResponseCodesParamsAggInterval1h RadarAS112TimeseriesGroupResponseCodesParamsAggInterval = "1h" - RadarAS112TimeseriesGroupResponseCodesParamsAggInterval1d RadarAS112TimeseriesGroupResponseCodesParamsAggInterval = "1d" - RadarAS112TimeseriesGroupResponseCodesParamsAggInterval1w RadarAS112TimeseriesGroupResponseCodesParamsAggInterval = "1w" -) - -type RadarAS112TimeseriesGroupResponseCodesParamsDateRange string - -const ( - RadarAS112TimeseriesGroupResponseCodesParamsDateRange1d RadarAS112TimeseriesGroupResponseCodesParamsDateRange = "1d" - RadarAS112TimeseriesGroupResponseCodesParamsDateRange2d RadarAS112TimeseriesGroupResponseCodesParamsDateRange = "2d" - RadarAS112TimeseriesGroupResponseCodesParamsDateRange7d RadarAS112TimeseriesGroupResponseCodesParamsDateRange = "7d" - RadarAS112TimeseriesGroupResponseCodesParamsDateRange14d RadarAS112TimeseriesGroupResponseCodesParamsDateRange = "14d" - RadarAS112TimeseriesGroupResponseCodesParamsDateRange28d RadarAS112TimeseriesGroupResponseCodesParamsDateRange = "28d" - RadarAS112TimeseriesGroupResponseCodesParamsDateRange12w RadarAS112TimeseriesGroupResponseCodesParamsDateRange = "12w" - RadarAS112TimeseriesGroupResponseCodesParamsDateRange24w RadarAS112TimeseriesGroupResponseCodesParamsDateRange = "24w" - RadarAS112TimeseriesGroupResponseCodesParamsDateRange52w RadarAS112TimeseriesGroupResponseCodesParamsDateRange = "52w" - RadarAS112TimeseriesGroupResponseCodesParamsDateRange1dControl RadarAS112TimeseriesGroupResponseCodesParamsDateRange = "1dControl" - RadarAS112TimeseriesGroupResponseCodesParamsDateRange2dControl RadarAS112TimeseriesGroupResponseCodesParamsDateRange = "2dControl" - RadarAS112TimeseriesGroupResponseCodesParamsDateRange7dControl RadarAS112TimeseriesGroupResponseCodesParamsDateRange = "7dControl" - RadarAS112TimeseriesGroupResponseCodesParamsDateRange14dControl RadarAS112TimeseriesGroupResponseCodesParamsDateRange = "14dControl" - RadarAS112TimeseriesGroupResponseCodesParamsDateRange28dControl RadarAS112TimeseriesGroupResponseCodesParamsDateRange = "28dControl" - RadarAS112TimeseriesGroupResponseCodesParamsDateRange12wControl RadarAS112TimeseriesGroupResponseCodesParamsDateRange = "12wControl" - RadarAS112TimeseriesGroupResponseCodesParamsDateRange24wControl RadarAS112TimeseriesGroupResponseCodesParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAS112TimeseriesGroupResponseCodesParamsFormat string - -const ( - RadarAS112TimeseriesGroupResponseCodesParamsFormatJson RadarAS112TimeseriesGroupResponseCodesParamsFormat = "JSON" - RadarAS112TimeseriesGroupResponseCodesParamsFormatCsv RadarAS112TimeseriesGroupResponseCodesParamsFormat = "CSV" -) - -type RadarAS112TimeseriesGroupResponseCodesResponseEnvelope struct { - Result RadarAS112TimeseriesGroupResponseCodesResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAS112TimeseriesGroupResponseCodesResponseEnvelopeJSON `json:"-"` -} - -// radarAS112TimeseriesGroupResponseCodesResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarAS112TimeseriesGroupResponseCodesResponseEnvelope] -type radarAS112TimeseriesGroupResponseCodesResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TimeseriesGroupResponseCodesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TimeseriesGroupResponseCodesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radaras112timeseriesgroup_test.go b/radaras112timeseriesgroup_test.go deleted file mode 100644 index be431c781ab..00000000000 --- a/radaras112timeseriesgroup_test.go +++ /dev/null @@ -1,219 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarAS112TimeseriesGroupDNSSECWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.AS112.TimeseriesGroups.DNSSEC(context.TODO(), cloudflare.RadarAS112TimeseriesGroupDNSSECParams{ - AggInterval: cloudflare.F(cloudflare.RadarAS112TimeseriesGroupDNSSECParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAS112TimeseriesGroupDNSSECParamsDateRange{cloudflare.RadarAS112TimeseriesGroupDNSSECParamsDateRange1d, cloudflare.RadarAS112TimeseriesGroupDNSSECParamsDateRange2d, cloudflare.RadarAS112TimeseriesGroupDNSSECParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAS112TimeseriesGroupDNSSECParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAS112TimeseriesGroupEdnsWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.AS112.TimeseriesGroups.Edns(context.TODO(), cloudflare.RadarAS112TimeseriesGroupEdnsParams{ - AggInterval: cloudflare.F(cloudflare.RadarAS112TimeseriesGroupEdnsParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAS112TimeseriesGroupEdnsParamsDateRange{cloudflare.RadarAS112TimeseriesGroupEdnsParamsDateRange1d, cloudflare.RadarAS112TimeseriesGroupEdnsParamsDateRange2d, cloudflare.RadarAS112TimeseriesGroupEdnsParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAS112TimeseriesGroupEdnsParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAS112TimeseriesGroupIPVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.AS112.TimeseriesGroups.IPVersion(context.TODO(), cloudflare.RadarAS112TimeseriesGroupIPVersionParams{ - AggInterval: cloudflare.F(cloudflare.RadarAS112TimeseriesGroupIPVersionParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAS112TimeseriesGroupIPVersionParamsDateRange{cloudflare.RadarAS112TimeseriesGroupIPVersionParamsDateRange1d, cloudflare.RadarAS112TimeseriesGroupIPVersionParamsDateRange2d, cloudflare.RadarAS112TimeseriesGroupIPVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAS112TimeseriesGroupIPVersionParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAS112TimeseriesGroupProtocolWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.AS112.TimeseriesGroups.Protocol(context.TODO(), cloudflare.RadarAS112TimeseriesGroupProtocolParams{ - AggInterval: cloudflare.F(cloudflare.RadarAS112TimeseriesGroupProtocolParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAS112TimeseriesGroupProtocolParamsDateRange{cloudflare.RadarAS112TimeseriesGroupProtocolParamsDateRange1d, cloudflare.RadarAS112TimeseriesGroupProtocolParamsDateRange2d, cloudflare.RadarAS112TimeseriesGroupProtocolParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAS112TimeseriesGroupProtocolParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAS112TimeseriesGroupQueryTypeWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.AS112.TimeseriesGroups.QueryType(context.TODO(), cloudflare.RadarAS112TimeseriesGroupQueryTypeParams{ - AggInterval: cloudflare.F(cloudflare.RadarAS112TimeseriesGroupQueryTypeParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAS112TimeseriesGroupQueryTypeParamsDateRange{cloudflare.RadarAS112TimeseriesGroupQueryTypeParamsDateRange1d, cloudflare.RadarAS112TimeseriesGroupQueryTypeParamsDateRange2d, cloudflare.RadarAS112TimeseriesGroupQueryTypeParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAS112TimeseriesGroupQueryTypeParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAS112TimeseriesGroupResponseCodesWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.AS112.TimeseriesGroups.ResponseCodes(context.TODO(), cloudflare.RadarAS112TimeseriesGroupResponseCodesParams{ - AggInterval: cloudflare.F(cloudflare.RadarAS112TimeseriesGroupResponseCodesParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAS112TimeseriesGroupResponseCodesParamsDateRange{cloudflare.RadarAS112TimeseriesGroupResponseCodesParamsDateRange1d, cloudflare.RadarAS112TimeseriesGroupResponseCodesParamsDateRange2d, cloudflare.RadarAS112TimeseriesGroupResponseCodesParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAS112TimeseriesGroupResponseCodesParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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/radaras112top.go b/radaras112top.go deleted file mode 100644 index 05cc66585e7..00000000000 --- a/radaras112top.go +++ /dev/null @@ -1,1087 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarAS112TopService 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 [NewRadarAS112TopService] method -// instead. -type RadarAS112TopService struct { - Options []option.RequestOption -} - -// NewRadarAS112TopService 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 NewRadarAS112TopService(opts ...option.RequestOption) (r *RadarAS112TopService) { - r = &RadarAS112TopService{} - r.Options = opts - return -} - -// Get the top locations by DNS queries DNSSEC support to AS112. -func (r *RadarAS112TopService) DNSSEC(ctx context.Context, dnssec RadarAS112TopDNSSECParamsDNSSEC, query RadarAS112TopDNSSECParams, opts ...option.RequestOption) (res *RadarAS112TopDNSSECResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAS112TopDNSSECResponseEnvelope - path := fmt.Sprintf("radar/as112/top/locations/dnssec/%v", dnssec) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the top locations, by DNS queries EDNS support to AS112. -func (r *RadarAS112TopService) Edns(ctx context.Context, edns RadarAS112TopEdnsParamsEdns, query RadarAS112TopEdnsParams, opts ...option.RequestOption) (res *RadarAS112TopEdnsResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAS112TopEdnsResponseEnvelope - path := fmt.Sprintf("radar/as112/top/locations/edns/%v", edns) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the top locations by DNS queries IP version to AS112. -func (r *RadarAS112TopService) IPVersion(ctx context.Context, ipVersion RadarAS112TopIPVersionParamsIPVersion, query RadarAS112TopIPVersionParams, opts ...option.RequestOption) (res *RadarAS112TopIPVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAS112TopIPVersionResponseEnvelope - path := fmt.Sprintf("radar/as112/top/locations/ip_version/%v", ipVersion) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the top locations by AS112 DNS queries. Values are a percentage out of the -// total queries. -func (r *RadarAS112TopService) Locations(ctx context.Context, query RadarAS112TopLocationsParams, opts ...option.RequestOption) (res *RadarAS112TopLocationsResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAS112TopLocationsResponseEnvelope - path := "radar/as112/top/locations" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarAS112TopDNSSECResponse struct { - Meta RadarAS112TopDNSSECResponseMeta `json:"meta,required"` - Top0 []RadarAS112TopDNSSECResponseTop0 `json:"top_0,required"` - JSON radarAS112TopDNSSECResponseJSON `json:"-"` -} - -// radarAS112TopDNSSECResponseJSON contains the JSON metadata for the struct -// [RadarAS112TopDNSSECResponse] -type radarAS112TopDNSSECResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopDNSSECResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopDNSSECResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopDNSSECResponseMeta struct { - DateRange []RadarAS112TopDNSSECResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarAS112TopDNSSECResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAS112TopDNSSECResponseMetaJSON `json:"-"` -} - -// radarAS112TopDNSSECResponseMetaJSON contains the JSON metadata for the struct -// [RadarAS112TopDNSSECResponseMeta] -type radarAS112TopDNSSECResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopDNSSECResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopDNSSECResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopDNSSECResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAS112TopDNSSECResponseMetaDateRangeJSON `json:"-"` -} - -// radarAS112TopDNSSECResponseMetaDateRangeJSON contains the JSON metadata for the -// struct [RadarAS112TopDNSSECResponseMetaDateRange] -type radarAS112TopDNSSECResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopDNSSECResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopDNSSECResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopDNSSECResponseMetaConfidenceInfo struct { - Annotations []RadarAS112TopDNSSECResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAS112TopDNSSECResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAS112TopDNSSECResponseMetaConfidenceInfoJSON contains the JSON metadata for -// the struct [RadarAS112TopDNSSECResponseMetaConfidenceInfo] -type radarAS112TopDNSSECResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopDNSSECResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopDNSSECResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopDNSSECResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAS112TopDNSSECResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAS112TopDNSSECResponseMetaConfidenceInfoAnnotationJSON contains the JSON -// metadata for the struct -// [RadarAS112TopDNSSECResponseMetaConfidenceInfoAnnotation] -type radarAS112TopDNSSECResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopDNSSECResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopDNSSECResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopDNSSECResponseTop0 struct { - ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` - ClientCountryName string `json:"clientCountryName,required"` - Value string `json:"value,required"` - JSON radarAS112TopDNSSECResponseTop0JSON `json:"-"` -} - -// radarAS112TopDNSSECResponseTop0JSON contains the JSON metadata for the struct -// [RadarAS112TopDNSSECResponseTop0] -type radarAS112TopDNSSECResponseTop0JSON struct { - ClientCountryAlpha2 apijson.Field - ClientCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopDNSSECResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopDNSSECResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopEdnsResponse struct { - Meta RadarAS112TopEdnsResponseMeta `json:"meta,required"` - Top0 []RadarAS112TopEdnsResponseTop0 `json:"top_0,required"` - JSON radarAS112TopEdnsResponseJSON `json:"-"` -} - -// radarAS112TopEdnsResponseJSON contains the JSON metadata for the struct -// [RadarAS112TopEdnsResponse] -type radarAS112TopEdnsResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopEdnsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopEdnsResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopEdnsResponseMeta struct { - DateRange []RadarAS112TopEdnsResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarAS112TopEdnsResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAS112TopEdnsResponseMetaJSON `json:"-"` -} - -// radarAS112TopEdnsResponseMetaJSON contains the JSON metadata for the struct -// [RadarAS112TopEdnsResponseMeta] -type radarAS112TopEdnsResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopEdnsResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopEdnsResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopEdnsResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAS112TopEdnsResponseMetaDateRangeJSON `json:"-"` -} - -// radarAS112TopEdnsResponseMetaDateRangeJSON contains the JSON metadata for the -// struct [RadarAS112TopEdnsResponseMetaDateRange] -type radarAS112TopEdnsResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopEdnsResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopEdnsResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopEdnsResponseMetaConfidenceInfo struct { - Annotations []RadarAS112TopEdnsResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAS112TopEdnsResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAS112TopEdnsResponseMetaConfidenceInfoJSON contains the JSON metadata for -// the struct [RadarAS112TopEdnsResponseMetaConfidenceInfo] -type radarAS112TopEdnsResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopEdnsResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopEdnsResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopEdnsResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAS112TopEdnsResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAS112TopEdnsResponseMetaConfidenceInfoAnnotationJSON contains the JSON -// metadata for the struct [RadarAS112TopEdnsResponseMetaConfidenceInfoAnnotation] -type radarAS112TopEdnsResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopEdnsResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopEdnsResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopEdnsResponseTop0 struct { - ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` - ClientCountryName string `json:"clientCountryName,required"` - Value string `json:"value,required"` - JSON radarAS112TopEdnsResponseTop0JSON `json:"-"` -} - -// radarAS112TopEdnsResponseTop0JSON contains the JSON metadata for the struct -// [RadarAS112TopEdnsResponseTop0] -type radarAS112TopEdnsResponseTop0JSON struct { - ClientCountryAlpha2 apijson.Field - ClientCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopEdnsResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopEdnsResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopIPVersionResponse struct { - Meta RadarAS112TopIPVersionResponseMeta `json:"meta,required"` - Top0 []RadarAS112TopIPVersionResponseTop0 `json:"top_0,required"` - JSON radarAS112TopIPVersionResponseJSON `json:"-"` -} - -// radarAS112TopIPVersionResponseJSON contains the JSON metadata for the struct -// [RadarAS112TopIPVersionResponse] -type radarAS112TopIPVersionResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopIPVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopIPVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopIPVersionResponseMeta struct { - DateRange []RadarAS112TopIPVersionResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarAS112TopIPVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAS112TopIPVersionResponseMetaJSON `json:"-"` -} - -// radarAS112TopIPVersionResponseMetaJSON contains the JSON metadata for the struct -// [RadarAS112TopIPVersionResponseMeta] -type radarAS112TopIPVersionResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopIPVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopIPVersionResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopIPVersionResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAS112TopIPVersionResponseMetaDateRangeJSON `json:"-"` -} - -// radarAS112TopIPVersionResponseMetaDateRangeJSON contains the JSON metadata for -// the struct [RadarAS112TopIPVersionResponseMetaDateRange] -type radarAS112TopIPVersionResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopIPVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopIPVersionResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopIPVersionResponseMetaConfidenceInfo struct { - Annotations []RadarAS112TopIPVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAS112TopIPVersionResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAS112TopIPVersionResponseMetaConfidenceInfoJSON contains the JSON metadata -// for the struct [RadarAS112TopIPVersionResponseMetaConfidenceInfo] -type radarAS112TopIPVersionResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopIPVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopIPVersionResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopIPVersionResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAS112TopIPVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAS112TopIPVersionResponseMetaConfidenceInfoAnnotationJSON contains the JSON -// metadata for the struct -// [RadarAS112TopIPVersionResponseMetaConfidenceInfoAnnotation] -type radarAS112TopIPVersionResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopIPVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopIPVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopIPVersionResponseTop0 struct { - ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` - ClientCountryName string `json:"clientCountryName,required"` - Value string `json:"value,required"` - JSON radarAS112TopIPVersionResponseTop0JSON `json:"-"` -} - -// radarAS112TopIPVersionResponseTop0JSON contains the JSON metadata for the struct -// [RadarAS112TopIPVersionResponseTop0] -type radarAS112TopIPVersionResponseTop0JSON struct { - ClientCountryAlpha2 apijson.Field - ClientCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopIPVersionResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopIPVersionResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopLocationsResponse struct { - Meta RadarAS112TopLocationsResponseMeta `json:"meta,required"` - Top0 []RadarAS112TopLocationsResponseTop0 `json:"top_0,required"` - JSON radarAS112TopLocationsResponseJSON `json:"-"` -} - -// radarAS112TopLocationsResponseJSON contains the JSON metadata for the struct -// [RadarAS112TopLocationsResponse] -type radarAS112TopLocationsResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopLocationsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopLocationsResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopLocationsResponseMeta struct { - DateRange []RadarAS112TopLocationsResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarAS112TopLocationsResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAS112TopLocationsResponseMetaJSON `json:"-"` -} - -// radarAS112TopLocationsResponseMetaJSON contains the JSON metadata for the struct -// [RadarAS112TopLocationsResponseMeta] -type radarAS112TopLocationsResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopLocationsResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopLocationsResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopLocationsResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAS112TopLocationsResponseMetaDateRangeJSON `json:"-"` -} - -// radarAS112TopLocationsResponseMetaDateRangeJSON contains the JSON metadata for -// the struct [RadarAS112TopLocationsResponseMetaDateRange] -type radarAS112TopLocationsResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopLocationsResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopLocationsResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopLocationsResponseMetaConfidenceInfo struct { - Annotations []RadarAS112TopLocationsResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAS112TopLocationsResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAS112TopLocationsResponseMetaConfidenceInfoJSON contains the JSON metadata -// for the struct [RadarAS112TopLocationsResponseMetaConfidenceInfo] -type radarAS112TopLocationsResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopLocationsResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopLocationsResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopLocationsResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAS112TopLocationsResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAS112TopLocationsResponseMetaConfidenceInfoAnnotationJSON contains the JSON -// metadata for the struct -// [RadarAS112TopLocationsResponseMetaConfidenceInfoAnnotation] -type radarAS112TopLocationsResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopLocationsResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopLocationsResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopLocationsResponseTop0 struct { - ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` - ClientCountryName string `json:"clientCountryName,required"` - Value string `json:"value,required"` - JSON radarAS112TopLocationsResponseTop0JSON `json:"-"` -} - -// radarAS112TopLocationsResponseTop0JSON contains the JSON metadata for the struct -// [RadarAS112TopLocationsResponseTop0] -type radarAS112TopLocationsResponseTop0JSON struct { - ClientCountryAlpha2 apijson.Field - ClientCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopLocationsResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopLocationsResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopDNSSECParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAS112TopDNSSECParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAS112TopDNSSECParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAS112TopDNSSECParams]'s query parameters as -// `url.Values`. -func (r RadarAS112TopDNSSECParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// DNSSEC. -type RadarAS112TopDNSSECParamsDNSSEC string - -const ( - RadarAS112TopDNSSECParamsDNSSECSupported RadarAS112TopDNSSECParamsDNSSEC = "SUPPORTED" - RadarAS112TopDNSSECParamsDNSSECNotSupported RadarAS112TopDNSSECParamsDNSSEC = "NOT_SUPPORTED" -) - -type RadarAS112TopDNSSECParamsDateRange string - -const ( - RadarAS112TopDNSSECParamsDateRange1d RadarAS112TopDNSSECParamsDateRange = "1d" - RadarAS112TopDNSSECParamsDateRange2d RadarAS112TopDNSSECParamsDateRange = "2d" - RadarAS112TopDNSSECParamsDateRange7d RadarAS112TopDNSSECParamsDateRange = "7d" - RadarAS112TopDNSSECParamsDateRange14d RadarAS112TopDNSSECParamsDateRange = "14d" - RadarAS112TopDNSSECParamsDateRange28d RadarAS112TopDNSSECParamsDateRange = "28d" - RadarAS112TopDNSSECParamsDateRange12w RadarAS112TopDNSSECParamsDateRange = "12w" - RadarAS112TopDNSSECParamsDateRange24w RadarAS112TopDNSSECParamsDateRange = "24w" - RadarAS112TopDNSSECParamsDateRange52w RadarAS112TopDNSSECParamsDateRange = "52w" - RadarAS112TopDNSSECParamsDateRange1dControl RadarAS112TopDNSSECParamsDateRange = "1dControl" - RadarAS112TopDNSSECParamsDateRange2dControl RadarAS112TopDNSSECParamsDateRange = "2dControl" - RadarAS112TopDNSSECParamsDateRange7dControl RadarAS112TopDNSSECParamsDateRange = "7dControl" - RadarAS112TopDNSSECParamsDateRange14dControl RadarAS112TopDNSSECParamsDateRange = "14dControl" - RadarAS112TopDNSSECParamsDateRange28dControl RadarAS112TopDNSSECParamsDateRange = "28dControl" - RadarAS112TopDNSSECParamsDateRange12wControl RadarAS112TopDNSSECParamsDateRange = "12wControl" - RadarAS112TopDNSSECParamsDateRange24wControl RadarAS112TopDNSSECParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAS112TopDNSSECParamsFormat string - -const ( - RadarAS112TopDNSSECParamsFormatJson RadarAS112TopDNSSECParamsFormat = "JSON" - RadarAS112TopDNSSECParamsFormatCsv RadarAS112TopDNSSECParamsFormat = "CSV" -) - -type RadarAS112TopDNSSECResponseEnvelope struct { - Result RadarAS112TopDNSSECResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAS112TopDNSSECResponseEnvelopeJSON `json:"-"` -} - -// radarAS112TopDNSSECResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarAS112TopDNSSECResponseEnvelope] -type radarAS112TopDNSSECResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopDNSSECResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopDNSSECResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopEdnsParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAS112TopEdnsParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAS112TopEdnsParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAS112TopEdnsParams]'s query parameters as -// `url.Values`. -func (r RadarAS112TopEdnsParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// EDNS. -type RadarAS112TopEdnsParamsEdns string - -const ( - RadarAS112TopEdnsParamsEdnsSupported RadarAS112TopEdnsParamsEdns = "SUPPORTED" - RadarAS112TopEdnsParamsEdnsNotSupported RadarAS112TopEdnsParamsEdns = "NOT_SUPPORTED" -) - -type RadarAS112TopEdnsParamsDateRange string - -const ( - RadarAS112TopEdnsParamsDateRange1d RadarAS112TopEdnsParamsDateRange = "1d" - RadarAS112TopEdnsParamsDateRange2d RadarAS112TopEdnsParamsDateRange = "2d" - RadarAS112TopEdnsParamsDateRange7d RadarAS112TopEdnsParamsDateRange = "7d" - RadarAS112TopEdnsParamsDateRange14d RadarAS112TopEdnsParamsDateRange = "14d" - RadarAS112TopEdnsParamsDateRange28d RadarAS112TopEdnsParamsDateRange = "28d" - RadarAS112TopEdnsParamsDateRange12w RadarAS112TopEdnsParamsDateRange = "12w" - RadarAS112TopEdnsParamsDateRange24w RadarAS112TopEdnsParamsDateRange = "24w" - RadarAS112TopEdnsParamsDateRange52w RadarAS112TopEdnsParamsDateRange = "52w" - RadarAS112TopEdnsParamsDateRange1dControl RadarAS112TopEdnsParamsDateRange = "1dControl" - RadarAS112TopEdnsParamsDateRange2dControl RadarAS112TopEdnsParamsDateRange = "2dControl" - RadarAS112TopEdnsParamsDateRange7dControl RadarAS112TopEdnsParamsDateRange = "7dControl" - RadarAS112TopEdnsParamsDateRange14dControl RadarAS112TopEdnsParamsDateRange = "14dControl" - RadarAS112TopEdnsParamsDateRange28dControl RadarAS112TopEdnsParamsDateRange = "28dControl" - RadarAS112TopEdnsParamsDateRange12wControl RadarAS112TopEdnsParamsDateRange = "12wControl" - RadarAS112TopEdnsParamsDateRange24wControl RadarAS112TopEdnsParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAS112TopEdnsParamsFormat string - -const ( - RadarAS112TopEdnsParamsFormatJson RadarAS112TopEdnsParamsFormat = "JSON" - RadarAS112TopEdnsParamsFormatCsv RadarAS112TopEdnsParamsFormat = "CSV" -) - -type RadarAS112TopEdnsResponseEnvelope struct { - Result RadarAS112TopEdnsResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAS112TopEdnsResponseEnvelopeJSON `json:"-"` -} - -// radarAS112TopEdnsResponseEnvelopeJSON contains the JSON metadata for the struct -// [RadarAS112TopEdnsResponseEnvelope] -type radarAS112TopEdnsResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopEdnsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopEdnsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopIPVersionParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAS112TopIPVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAS112TopIPVersionParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAS112TopIPVersionParams]'s query parameters as -// `url.Values`. -func (r RadarAS112TopIPVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// IP Version. -type RadarAS112TopIPVersionParamsIPVersion string - -const ( - RadarAS112TopIPVersionParamsIPVersionIPv4 RadarAS112TopIPVersionParamsIPVersion = "IPv4" - RadarAS112TopIPVersionParamsIPVersionIPv6 RadarAS112TopIPVersionParamsIPVersion = "IPv6" -) - -type RadarAS112TopIPVersionParamsDateRange string - -const ( - RadarAS112TopIPVersionParamsDateRange1d RadarAS112TopIPVersionParamsDateRange = "1d" - RadarAS112TopIPVersionParamsDateRange2d RadarAS112TopIPVersionParamsDateRange = "2d" - RadarAS112TopIPVersionParamsDateRange7d RadarAS112TopIPVersionParamsDateRange = "7d" - RadarAS112TopIPVersionParamsDateRange14d RadarAS112TopIPVersionParamsDateRange = "14d" - RadarAS112TopIPVersionParamsDateRange28d RadarAS112TopIPVersionParamsDateRange = "28d" - RadarAS112TopIPVersionParamsDateRange12w RadarAS112TopIPVersionParamsDateRange = "12w" - RadarAS112TopIPVersionParamsDateRange24w RadarAS112TopIPVersionParamsDateRange = "24w" - RadarAS112TopIPVersionParamsDateRange52w RadarAS112TopIPVersionParamsDateRange = "52w" - RadarAS112TopIPVersionParamsDateRange1dControl RadarAS112TopIPVersionParamsDateRange = "1dControl" - RadarAS112TopIPVersionParamsDateRange2dControl RadarAS112TopIPVersionParamsDateRange = "2dControl" - RadarAS112TopIPVersionParamsDateRange7dControl RadarAS112TopIPVersionParamsDateRange = "7dControl" - RadarAS112TopIPVersionParamsDateRange14dControl RadarAS112TopIPVersionParamsDateRange = "14dControl" - RadarAS112TopIPVersionParamsDateRange28dControl RadarAS112TopIPVersionParamsDateRange = "28dControl" - RadarAS112TopIPVersionParamsDateRange12wControl RadarAS112TopIPVersionParamsDateRange = "12wControl" - RadarAS112TopIPVersionParamsDateRange24wControl RadarAS112TopIPVersionParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAS112TopIPVersionParamsFormat string - -const ( - RadarAS112TopIPVersionParamsFormatJson RadarAS112TopIPVersionParamsFormat = "JSON" - RadarAS112TopIPVersionParamsFormatCsv RadarAS112TopIPVersionParamsFormat = "CSV" -) - -type RadarAS112TopIPVersionResponseEnvelope struct { - Result RadarAS112TopIPVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAS112TopIPVersionResponseEnvelopeJSON `json:"-"` -} - -// radarAS112TopIPVersionResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarAS112TopIPVersionResponseEnvelope] -type radarAS112TopIPVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopIPVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAS112TopLocationsParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAS112TopLocationsParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAS112TopLocationsParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAS112TopLocationsParams]'s query parameters as -// `url.Values`. -func (r RadarAS112TopLocationsParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAS112TopLocationsParamsDateRange string - -const ( - RadarAS112TopLocationsParamsDateRange1d RadarAS112TopLocationsParamsDateRange = "1d" - RadarAS112TopLocationsParamsDateRange2d RadarAS112TopLocationsParamsDateRange = "2d" - RadarAS112TopLocationsParamsDateRange7d RadarAS112TopLocationsParamsDateRange = "7d" - RadarAS112TopLocationsParamsDateRange14d RadarAS112TopLocationsParamsDateRange = "14d" - RadarAS112TopLocationsParamsDateRange28d RadarAS112TopLocationsParamsDateRange = "28d" - RadarAS112TopLocationsParamsDateRange12w RadarAS112TopLocationsParamsDateRange = "12w" - RadarAS112TopLocationsParamsDateRange24w RadarAS112TopLocationsParamsDateRange = "24w" - RadarAS112TopLocationsParamsDateRange52w RadarAS112TopLocationsParamsDateRange = "52w" - RadarAS112TopLocationsParamsDateRange1dControl RadarAS112TopLocationsParamsDateRange = "1dControl" - RadarAS112TopLocationsParamsDateRange2dControl RadarAS112TopLocationsParamsDateRange = "2dControl" - RadarAS112TopLocationsParamsDateRange7dControl RadarAS112TopLocationsParamsDateRange = "7dControl" - RadarAS112TopLocationsParamsDateRange14dControl RadarAS112TopLocationsParamsDateRange = "14dControl" - RadarAS112TopLocationsParamsDateRange28dControl RadarAS112TopLocationsParamsDateRange = "28dControl" - RadarAS112TopLocationsParamsDateRange12wControl RadarAS112TopLocationsParamsDateRange = "12wControl" - RadarAS112TopLocationsParamsDateRange24wControl RadarAS112TopLocationsParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAS112TopLocationsParamsFormat string - -const ( - RadarAS112TopLocationsParamsFormatJson RadarAS112TopLocationsParamsFormat = "JSON" - RadarAS112TopLocationsParamsFormatCsv RadarAS112TopLocationsParamsFormat = "CSV" -) - -type RadarAS112TopLocationsResponseEnvelope struct { - Result RadarAS112TopLocationsResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAS112TopLocationsResponseEnvelopeJSON `json:"-"` -} - -// radarAS112TopLocationsResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarAS112TopLocationsResponseEnvelope] -type radarAS112TopLocationsResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAS112TopLocationsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAS112TopLocationsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radaras112top_test.go b/radaras112top_test.go deleted file mode 100644 index b85552773fb..00000000000 --- a/radaras112top_test.go +++ /dev/null @@ -1,163 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarAS112TopDNSSECWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.AS112.Top.DNSSEC( - context.TODO(), - cloudflare.RadarAS112TopDNSSECParamsDNSSECSupported, - cloudflare.RadarAS112TopDNSSECParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAS112TopDNSSECParamsDateRange{cloudflare.RadarAS112TopDNSSECParamsDateRange1d, cloudflare.RadarAS112TopDNSSECParamsDateRange2d, cloudflare.RadarAS112TopDNSSECParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAS112TopDNSSECParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }, - ) - 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 TestRadarAS112TopEdnsWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.AS112.Top.Edns( - context.TODO(), - cloudflare.RadarAS112TopEdnsParamsEdnsSupported, - cloudflare.RadarAS112TopEdnsParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAS112TopEdnsParamsDateRange{cloudflare.RadarAS112TopEdnsParamsDateRange1d, cloudflare.RadarAS112TopEdnsParamsDateRange2d, cloudflare.RadarAS112TopEdnsParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAS112TopEdnsParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }, - ) - 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 TestRadarAS112TopIPVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.AS112.Top.IPVersion( - context.TODO(), - cloudflare.RadarAS112TopIPVersionParamsIPVersionIPv4, - cloudflare.RadarAS112TopIPVersionParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAS112TopIPVersionParamsDateRange{cloudflare.RadarAS112TopIPVersionParamsDateRange1d, cloudflare.RadarAS112TopIPVersionParamsDateRange2d, cloudflare.RadarAS112TopIPVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAS112TopIPVersionParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }, - ) - 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 TestRadarAS112TopLocationsWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.AS112.Top.Locations(context.TODO(), cloudflare.RadarAS112TopLocationsParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAS112TopLocationsParamsDateRange{cloudflare.RadarAS112TopLocationsParamsDateRange1d, cloudflare.RadarAS112TopLocationsParamsDateRange2d, cloudflare.RadarAS112TopLocationsParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAS112TopLocationsParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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/radarattack.go b/radarattack.go deleted file mode 100644 index 91a7ac3bfb0..00000000000 --- a/radarattack.go +++ /dev/null @@ -1,29 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarAttackService 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 [NewRadarAttackService] method -// instead. -type RadarAttackService struct { - Options []option.RequestOption - Layer3 *RadarAttackLayer3Service - Layer7 *RadarAttackLayer7Service -} - -// NewRadarAttackService 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 NewRadarAttackService(opts ...option.RequestOption) (r *RadarAttackService) { - r = &RadarAttackService{} - r.Options = opts - r.Layer3 = NewRadarAttackLayer3Service(opts...) - r.Layer7 = NewRadarAttackLayer7Service(opts...) - return -} diff --git a/radarattacklayer3.go b/radarattacklayer3.go deleted file mode 100644 index 5d5cf0cf007..00000000000 --- a/radarattacklayer3.go +++ /dev/null @@ -1,256 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarAttackLayer3Service 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 [NewRadarAttackLayer3Service] method -// instead. -type RadarAttackLayer3Service struct { - Options []option.RequestOption - Summary *RadarAttackLayer3SummaryService - TimeseriesGroups *RadarAttackLayer3TimeseriesGroupService - Top *RadarAttackLayer3TopService -} - -// NewRadarAttackLayer3Service 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 NewRadarAttackLayer3Service(opts ...option.RequestOption) (r *RadarAttackLayer3Service) { - r = &RadarAttackLayer3Service{} - r.Options = opts - r.Summary = NewRadarAttackLayer3SummaryService(opts...) - r.TimeseriesGroups = NewRadarAttackLayer3TimeseriesGroupService(opts...) - r.Top = NewRadarAttackLayer3TopService(opts...) - return -} - -// Get attacks change over time by bytes. -func (r *RadarAttackLayer3Service) Timeseries(ctx context.Context, query RadarAttackLayer3TimeseriesParams, opts ...option.RequestOption) (res *RadarAttackLayer3TimeseriesResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3TimeseriesResponseEnvelope - path := "radar/attacks/layer3/timeseries" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarAttackLayer3TimeseriesResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAttackLayer3TimeseriesResponseSerie0 `json:"serie_0,required"` - JSON radarAttackLayer3TimeseriesResponseJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesResponseJSON contains the JSON metadata for the -// struct [RadarAttackLayer3TimeseriesResponse] -type radarAttackLayer3TimeseriesResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesResponseSerie0 struct { - Timestamps []string `json:"timestamps,required"` - Values []string `json:"values,required"` - JSON radarAttackLayer3TimeseriesResponseSerie0JSON `json:"-"` -} - -// radarAttackLayer3TimeseriesResponseSerie0JSON contains the JSON metadata for the -// struct [RadarAttackLayer3TimeseriesResponseSerie0] -type radarAttackLayer3TimeseriesResponseSerie0JSON struct { - Timestamps apijson.Field - Values apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAttackLayer3TimeseriesParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3TimeseriesParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Together with the `location` parameter, will apply the filter to origin or - // target location. - Direction param.Field[RadarAttackLayer3TimeseriesParamsDirection] `query:"direction"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3TimeseriesParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer3TimeseriesParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Measurement units, eg. bytes. - Metric param.Field[RadarAttackLayer3TimeseriesParamsMetric] `query:"metric"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Normalization method applied. Refer to - // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). - Normalization param.Field[RadarAttackLayer3TimeseriesParamsNormalization] `query:"normalization"` - // Array of L3/4 attack types. - Protocol param.Field[[]RadarAttackLayer3TimeseriesParamsProtocol] `query:"protocol"` -} - -// URLQuery serializes [RadarAttackLayer3TimeseriesParams]'s query parameters as -// `url.Values`. -func (r RadarAttackLayer3TimeseriesParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAttackLayer3TimeseriesParamsAggInterval string - -const ( - RadarAttackLayer3TimeseriesParamsAggInterval15m RadarAttackLayer3TimeseriesParamsAggInterval = "15m" - RadarAttackLayer3TimeseriesParamsAggInterval1h RadarAttackLayer3TimeseriesParamsAggInterval = "1h" - RadarAttackLayer3TimeseriesParamsAggInterval1d RadarAttackLayer3TimeseriesParamsAggInterval = "1d" - RadarAttackLayer3TimeseriesParamsAggInterval1w RadarAttackLayer3TimeseriesParamsAggInterval = "1w" -) - -type RadarAttackLayer3TimeseriesParamsDateRange string - -const ( - RadarAttackLayer3TimeseriesParamsDateRange1d RadarAttackLayer3TimeseriesParamsDateRange = "1d" - RadarAttackLayer3TimeseriesParamsDateRange2d RadarAttackLayer3TimeseriesParamsDateRange = "2d" - RadarAttackLayer3TimeseriesParamsDateRange7d RadarAttackLayer3TimeseriesParamsDateRange = "7d" - RadarAttackLayer3TimeseriesParamsDateRange14d RadarAttackLayer3TimeseriesParamsDateRange = "14d" - RadarAttackLayer3TimeseriesParamsDateRange28d RadarAttackLayer3TimeseriesParamsDateRange = "28d" - RadarAttackLayer3TimeseriesParamsDateRange12w RadarAttackLayer3TimeseriesParamsDateRange = "12w" - RadarAttackLayer3TimeseriesParamsDateRange24w RadarAttackLayer3TimeseriesParamsDateRange = "24w" - RadarAttackLayer3TimeseriesParamsDateRange52w RadarAttackLayer3TimeseriesParamsDateRange = "52w" - RadarAttackLayer3TimeseriesParamsDateRange1dControl RadarAttackLayer3TimeseriesParamsDateRange = "1dControl" - RadarAttackLayer3TimeseriesParamsDateRange2dControl RadarAttackLayer3TimeseriesParamsDateRange = "2dControl" - RadarAttackLayer3TimeseriesParamsDateRange7dControl RadarAttackLayer3TimeseriesParamsDateRange = "7dControl" - RadarAttackLayer3TimeseriesParamsDateRange14dControl RadarAttackLayer3TimeseriesParamsDateRange = "14dControl" - RadarAttackLayer3TimeseriesParamsDateRange28dControl RadarAttackLayer3TimeseriesParamsDateRange = "28dControl" - RadarAttackLayer3TimeseriesParamsDateRange12wControl RadarAttackLayer3TimeseriesParamsDateRange = "12wControl" - RadarAttackLayer3TimeseriesParamsDateRange24wControl RadarAttackLayer3TimeseriesParamsDateRange = "24wControl" -) - -// Together with the `location` parameter, will apply the filter to origin or -// target location. -type RadarAttackLayer3TimeseriesParamsDirection string - -const ( - RadarAttackLayer3TimeseriesParamsDirectionOrigin RadarAttackLayer3TimeseriesParamsDirection = "ORIGIN" - RadarAttackLayer3TimeseriesParamsDirectionTarget RadarAttackLayer3TimeseriesParamsDirection = "TARGET" -) - -// Format results are returned in. -type RadarAttackLayer3TimeseriesParamsFormat string - -const ( - RadarAttackLayer3TimeseriesParamsFormatJson RadarAttackLayer3TimeseriesParamsFormat = "JSON" - RadarAttackLayer3TimeseriesParamsFormatCsv RadarAttackLayer3TimeseriesParamsFormat = "CSV" -) - -type RadarAttackLayer3TimeseriesParamsIPVersion string - -const ( - RadarAttackLayer3TimeseriesParamsIPVersionIPv4 RadarAttackLayer3TimeseriesParamsIPVersion = "IPv4" - RadarAttackLayer3TimeseriesParamsIPVersionIPv6 RadarAttackLayer3TimeseriesParamsIPVersion = "IPv6" -) - -// Measurement units, eg. bytes. -type RadarAttackLayer3TimeseriesParamsMetric string - -const ( - RadarAttackLayer3TimeseriesParamsMetricBytes RadarAttackLayer3TimeseriesParamsMetric = "BYTES" - RadarAttackLayer3TimeseriesParamsMetricBytesOld RadarAttackLayer3TimeseriesParamsMetric = "BYTES_OLD" -) - -// Normalization method applied. Refer to -// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). -type RadarAttackLayer3TimeseriesParamsNormalization string - -const ( - RadarAttackLayer3TimeseriesParamsNormalizationPercentageChange RadarAttackLayer3TimeseriesParamsNormalization = "PERCENTAGE_CHANGE" - RadarAttackLayer3TimeseriesParamsNormalizationMin0Max RadarAttackLayer3TimeseriesParamsNormalization = "MIN0_MAX" -) - -type RadarAttackLayer3TimeseriesParamsProtocol string - -const ( - RadarAttackLayer3TimeseriesParamsProtocolUdp RadarAttackLayer3TimeseriesParamsProtocol = "UDP" - RadarAttackLayer3TimeseriesParamsProtocolTcp RadarAttackLayer3TimeseriesParamsProtocol = "TCP" - RadarAttackLayer3TimeseriesParamsProtocolIcmp RadarAttackLayer3TimeseriesParamsProtocol = "ICMP" - RadarAttackLayer3TimeseriesParamsProtocolGRE RadarAttackLayer3TimeseriesParamsProtocol = "GRE" -) - -type RadarAttackLayer3TimeseriesResponseEnvelope struct { - Result RadarAttackLayer3TimeseriesResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3TimeseriesResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarAttackLayer3TimeseriesResponseEnvelope] -type radarAttackLayer3TimeseriesResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarattacklayer3_test.go b/radarattacklayer3_test.go deleted file mode 100644 index 299c8512005..00000000000 --- a/radarattacklayer3_test.go +++ /dev/null @@ -1,54 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarAttackLayer3TimeseriesWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.Timeseries(context.TODO(), cloudflare.RadarAttackLayer3TimeseriesParams{ - AggInterval: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesParamsDateRange{cloudflare.RadarAttackLayer3TimeseriesParamsDateRange1d, cloudflare.RadarAttackLayer3TimeseriesParamsDateRange2d, cloudflare.RadarAttackLayer3TimeseriesParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Direction: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesParamsDirectionOrigin), - Format: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesParamsIPVersion{cloudflare.RadarAttackLayer3TimeseriesParamsIPVersionIPv4, cloudflare.RadarAttackLayer3TimeseriesParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Metric: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesParamsMetricBytes), - Name: cloudflare.F([]string{"string", "string", "string"}), - Normalization: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesParamsNormalizationMin0Max), - Protocol: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesParamsProtocol{cloudflare.RadarAttackLayer3TimeseriesParamsProtocolUdp, cloudflare.RadarAttackLayer3TimeseriesParamsProtocolTcp, cloudflare.RadarAttackLayer3TimeseriesParamsProtocolIcmp}), - }) - 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/radarattacklayer3summary.go b/radarattacklayer3summary.go deleted file mode 100644 index ecb8cb0e176..00000000000 --- a/radarattacklayer3summary.go +++ /dev/null @@ -1,1685 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarAttackLayer3SummaryService 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 -// [NewRadarAttackLayer3SummaryService] method instead. -type RadarAttackLayer3SummaryService struct { - Options []option.RequestOption -} - -// NewRadarAttackLayer3SummaryService 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 NewRadarAttackLayer3SummaryService(opts ...option.RequestOption) (r *RadarAttackLayer3SummaryService) { - r = &RadarAttackLayer3SummaryService{} - r.Options = opts - return -} - -// Percentage distribution of attacks by bitrate. -func (r *RadarAttackLayer3SummaryService) Bitrate(ctx context.Context, query RadarAttackLayer3SummaryBitrateParams, opts ...option.RequestOption) (res *RadarAttackLayer3SummaryBitrateResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3SummaryBitrateResponseEnvelope - path := "radar/attacks/layer3/summary/bitrate" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by duration. -func (r *RadarAttackLayer3SummaryService) Duration(ctx context.Context, query RadarAttackLayer3SummaryDurationParams, opts ...option.RequestOption) (res *RadarAttackLayer3SummaryDurationResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3SummaryDurationResponseEnvelope - path := "radar/attacks/layer3/summary/duration" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of network protocols in layer 3/4 attacks over a given -// time period. -func (r *RadarAttackLayer3SummaryService) Get(ctx context.Context, query RadarAttackLayer3SummaryGetParams, opts ...option.RequestOption) (res *RadarAttackLayer3SummaryGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3SummaryGetResponseEnvelope - path := "radar/attacks/layer3/summary" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by ip version used. -func (r *RadarAttackLayer3SummaryService) IPVersion(ctx context.Context, query RadarAttackLayer3SummaryIPVersionParams, opts ...option.RequestOption) (res *RadarAttackLayer3SummaryIPVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3SummaryIPVersionResponseEnvelope - path := "radar/attacks/layer3/summary/ip_version" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by protocol used. -func (r *RadarAttackLayer3SummaryService) Protocol(ctx context.Context, query RadarAttackLayer3SummaryProtocolParams, opts ...option.RequestOption) (res *RadarAttackLayer3SummaryProtocolResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3SummaryProtocolResponseEnvelope - path := "radar/attacks/layer3/summary/protocol" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by vector. -func (r *RadarAttackLayer3SummaryService) Vector(ctx context.Context, query RadarAttackLayer3SummaryVectorParams, opts ...option.RequestOption) (res *RadarAttackLayer3SummaryVectorResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3SummaryVectorResponseEnvelope - path := "radar/attacks/layer3/summary/vector" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarAttackLayer3SummaryBitrateResponse struct { - Meta RadarAttackLayer3SummaryBitrateResponseMeta `json:"meta,required"` - Summary0 RadarAttackLayer3SummaryBitrateResponseSummary0 `json:"summary_0,required"` - JSON radarAttackLayer3SummaryBitrateResponseJSON `json:"-"` -} - -// radarAttackLayer3SummaryBitrateResponseJSON contains the JSON metadata for the -// struct [RadarAttackLayer3SummaryBitrateResponse] -type radarAttackLayer3SummaryBitrateResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryBitrateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryBitrateResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryBitrateResponseMeta struct { - DateRange []RadarAttackLayer3SummaryBitrateResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarAttackLayer3SummaryBitrateResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer3SummaryBitrateResponseMetaJSON `json:"-"` -} - -// radarAttackLayer3SummaryBitrateResponseMetaJSON contains the JSON metadata for -// the struct [RadarAttackLayer3SummaryBitrateResponseMeta] -type radarAttackLayer3SummaryBitrateResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryBitrateResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryBitrateResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryBitrateResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer3SummaryBitrateResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer3SummaryBitrateResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarAttackLayer3SummaryBitrateResponseMetaDateRange] -type radarAttackLayer3SummaryBitrateResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryBitrateResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryBitrateResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryBitrateResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer3SummaryBitrateResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer3SummaryBitrateResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer3SummaryBitrateResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer3SummaryBitrateResponseMetaConfidenceInfo] -type radarAttackLayer3SummaryBitrateResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryBitrateResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryBitrateResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryBitrateResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer3SummaryBitrateResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer3SummaryBitrateResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarAttackLayer3SummaryBitrateResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer3SummaryBitrateResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryBitrateResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryBitrateResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryBitrateResponseSummary0 struct { - Number1GbpsTo10Gbps string `json:"_1_GBPS_TO_10_GBPS,required"` - Number10GbpsTo100Gbps string `json:"_10_GBPS_TO_100_GBPS,required"` - Number500MbpsTo1Gbps string `json:"_500_MBPS_TO_1_GBPS,required"` - Over100Gbps string `json:"OVER_100_GBPS,required"` - Under500Mbps string `json:"UNDER_500_MBPS,required"` - JSON radarAttackLayer3SummaryBitrateResponseSummary0JSON `json:"-"` -} - -// radarAttackLayer3SummaryBitrateResponseSummary0JSON contains the JSON metadata -// for the struct [RadarAttackLayer3SummaryBitrateResponseSummary0] -type radarAttackLayer3SummaryBitrateResponseSummary0JSON struct { - Number1GbpsTo10Gbps apijson.Field - Number10GbpsTo100Gbps apijson.Field - Number500MbpsTo1Gbps apijson.Field - Over100Gbps apijson.Field - Under500Mbps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryBitrateResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryBitrateResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryDurationResponse struct { - Meta RadarAttackLayer3SummaryDurationResponseMeta `json:"meta,required"` - Summary0 RadarAttackLayer3SummaryDurationResponseSummary0 `json:"summary_0,required"` - JSON radarAttackLayer3SummaryDurationResponseJSON `json:"-"` -} - -// radarAttackLayer3SummaryDurationResponseJSON contains the JSON metadata for the -// struct [RadarAttackLayer3SummaryDurationResponse] -type radarAttackLayer3SummaryDurationResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryDurationResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryDurationResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryDurationResponseMeta struct { - DateRange []RadarAttackLayer3SummaryDurationResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarAttackLayer3SummaryDurationResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer3SummaryDurationResponseMetaJSON `json:"-"` -} - -// radarAttackLayer3SummaryDurationResponseMetaJSON contains the JSON metadata for -// the struct [RadarAttackLayer3SummaryDurationResponseMeta] -type radarAttackLayer3SummaryDurationResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryDurationResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryDurationResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryDurationResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer3SummaryDurationResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer3SummaryDurationResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarAttackLayer3SummaryDurationResponseMetaDateRange] -type radarAttackLayer3SummaryDurationResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryDurationResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryDurationResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryDurationResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer3SummaryDurationResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer3SummaryDurationResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer3SummaryDurationResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer3SummaryDurationResponseMetaConfidenceInfo] -type radarAttackLayer3SummaryDurationResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryDurationResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryDurationResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryDurationResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer3SummaryDurationResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer3SummaryDurationResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarAttackLayer3SummaryDurationResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer3SummaryDurationResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryDurationResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryDurationResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryDurationResponseSummary0 struct { - Number1HourTo3Hours string `json:"_1_HOUR_TO_3_HOURS,required"` - Number10MinsTo20Mins string `json:"_10_MINS_TO_20_MINS,required"` - Number20MinsTo40Mins string `json:"_20_MINS_TO_40_MINS,required"` - Number40MinsTo1Hour string `json:"_40_MINS_TO_1_HOUR,required"` - Over3Hours string `json:"OVER_3_HOURS,required"` - Under10Mins string `json:"UNDER_10_MINS,required"` - JSON radarAttackLayer3SummaryDurationResponseSummary0JSON `json:"-"` -} - -// radarAttackLayer3SummaryDurationResponseSummary0JSON contains the JSON metadata -// for the struct [RadarAttackLayer3SummaryDurationResponseSummary0] -type radarAttackLayer3SummaryDurationResponseSummary0JSON struct { - Number1HourTo3Hours apijson.Field - Number10MinsTo20Mins apijson.Field - Number20MinsTo40Mins apijson.Field - Number40MinsTo1Hour apijson.Field - Over3Hours apijson.Field - Under10Mins apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryDurationResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryDurationResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryGetResponse struct { - Meta RadarAttackLayer3SummaryGetResponseMeta `json:"meta,required"` - Summary0 RadarAttackLayer3SummaryGetResponseSummary0 `json:"summary_0,required"` - JSON radarAttackLayer3SummaryGetResponseJSON `json:"-"` -} - -// radarAttackLayer3SummaryGetResponseJSON contains the JSON metadata for the -// struct [RadarAttackLayer3SummaryGetResponse] -type radarAttackLayer3SummaryGetResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryGetResponseMeta struct { - DateRange []RadarAttackLayer3SummaryGetResponseMetaDateRange `json:"dateRange,required"` - ConfidenceInfo RadarAttackLayer3SummaryGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer3SummaryGetResponseMetaJSON `json:"-"` -} - -// radarAttackLayer3SummaryGetResponseMetaJSON contains the JSON metadata for the -// struct [RadarAttackLayer3SummaryGetResponseMeta] -type radarAttackLayer3SummaryGetResponseMetaJSON struct { - DateRange apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer3SummaryGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer3SummaryGetResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarAttackLayer3SummaryGetResponseMetaDateRange] -type radarAttackLayer3SummaryGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryGetResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer3SummaryGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer3SummaryGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer3SummaryGetResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarAttackLayer3SummaryGetResponseMetaConfidenceInfo] -type radarAttackLayer3SummaryGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer3SummaryGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer3SummaryGetResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer3SummaryGetResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer3SummaryGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryGetResponseSummary0 struct { - GRE string `json:"gre,required"` - Icmp string `json:"icmp,required"` - Tcp string `json:"tcp,required"` - Udp string `json:"udp,required"` - JSON radarAttackLayer3SummaryGetResponseSummary0JSON `json:"-"` -} - -// radarAttackLayer3SummaryGetResponseSummary0JSON contains the JSON metadata for -// the struct [RadarAttackLayer3SummaryGetResponseSummary0] -type radarAttackLayer3SummaryGetResponseSummary0JSON struct { - GRE apijson.Field - Icmp apijson.Field - Tcp apijson.Field - Udp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryGetResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryGetResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryIPVersionResponse struct { - Meta RadarAttackLayer3SummaryIPVersionResponseMeta `json:"meta,required"` - Summary0 RadarAttackLayer3SummaryIPVersionResponseSummary0 `json:"summary_0,required"` - JSON radarAttackLayer3SummaryIPVersionResponseJSON `json:"-"` -} - -// radarAttackLayer3SummaryIPVersionResponseJSON contains the JSON metadata for the -// struct [RadarAttackLayer3SummaryIPVersionResponse] -type radarAttackLayer3SummaryIPVersionResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryIPVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryIPVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryIPVersionResponseMeta struct { - DateRange []RadarAttackLayer3SummaryIPVersionResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarAttackLayer3SummaryIPVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer3SummaryIPVersionResponseMetaJSON `json:"-"` -} - -// radarAttackLayer3SummaryIPVersionResponseMetaJSON contains the JSON metadata for -// the struct [RadarAttackLayer3SummaryIPVersionResponseMeta] -type radarAttackLayer3SummaryIPVersionResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryIPVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryIPVersionResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryIPVersionResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer3SummaryIPVersionResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer3SummaryIPVersionResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarAttackLayer3SummaryIPVersionResponseMetaDateRange] -type radarAttackLayer3SummaryIPVersionResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryIPVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryIPVersionResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryIPVersionResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer3SummaryIPVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer3SummaryIPVersionResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer3SummaryIPVersionResponseMetaConfidenceInfoJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer3SummaryIPVersionResponseMetaConfidenceInfo] -type radarAttackLayer3SummaryIPVersionResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryIPVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryIPVersionResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryIPVersionResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer3SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer3SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarAttackLayer3SummaryIPVersionResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer3SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryIPVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryIPVersionResponseSummary0 struct { - IPv4 string `json:"IPv4,required"` - IPv6 string `json:"IPv6,required"` - JSON radarAttackLayer3SummaryIPVersionResponseSummary0JSON `json:"-"` -} - -// radarAttackLayer3SummaryIPVersionResponseSummary0JSON contains the JSON metadata -// for the struct [RadarAttackLayer3SummaryIPVersionResponseSummary0] -type radarAttackLayer3SummaryIPVersionResponseSummary0JSON struct { - IPv4 apijson.Field - IPv6 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryIPVersionResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryIPVersionResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryProtocolResponse struct { - Meta RadarAttackLayer3SummaryProtocolResponseMeta `json:"meta,required"` - Summary0 RadarAttackLayer3SummaryProtocolResponseSummary0 `json:"summary_0,required"` - JSON radarAttackLayer3SummaryProtocolResponseJSON `json:"-"` -} - -// radarAttackLayer3SummaryProtocolResponseJSON contains the JSON metadata for the -// struct [RadarAttackLayer3SummaryProtocolResponse] -type radarAttackLayer3SummaryProtocolResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryProtocolResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryProtocolResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryProtocolResponseMeta struct { - DateRange []RadarAttackLayer3SummaryProtocolResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarAttackLayer3SummaryProtocolResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer3SummaryProtocolResponseMetaJSON `json:"-"` -} - -// radarAttackLayer3SummaryProtocolResponseMetaJSON contains the JSON metadata for -// the struct [RadarAttackLayer3SummaryProtocolResponseMeta] -type radarAttackLayer3SummaryProtocolResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryProtocolResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryProtocolResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryProtocolResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer3SummaryProtocolResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer3SummaryProtocolResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarAttackLayer3SummaryProtocolResponseMetaDateRange] -type radarAttackLayer3SummaryProtocolResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryProtocolResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryProtocolResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryProtocolResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer3SummaryProtocolResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer3SummaryProtocolResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer3SummaryProtocolResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer3SummaryProtocolResponseMetaConfidenceInfo] -type radarAttackLayer3SummaryProtocolResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryProtocolResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryProtocolResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryProtocolResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer3SummaryProtocolResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer3SummaryProtocolResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarAttackLayer3SummaryProtocolResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer3SummaryProtocolResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryProtocolResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryProtocolResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryProtocolResponseSummary0 struct { - GRE string `json:"GRE,required"` - Icmp string `json:"ICMP,required"` - Tcp string `json:"TCP,required"` - Udp string `json:"UDP,required"` - JSON radarAttackLayer3SummaryProtocolResponseSummary0JSON `json:"-"` -} - -// radarAttackLayer3SummaryProtocolResponseSummary0JSON contains the JSON metadata -// for the struct [RadarAttackLayer3SummaryProtocolResponseSummary0] -type radarAttackLayer3SummaryProtocolResponseSummary0JSON struct { - GRE apijson.Field - Icmp apijson.Field - Tcp apijson.Field - Udp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryProtocolResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryProtocolResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryVectorResponse struct { - Meta RadarAttackLayer3SummaryVectorResponseMeta `json:"meta,required"` - Summary0 map[string][]string `json:"summary_0,required"` - JSON radarAttackLayer3SummaryVectorResponseJSON `json:"-"` -} - -// radarAttackLayer3SummaryVectorResponseJSON contains the JSON metadata for the -// struct [RadarAttackLayer3SummaryVectorResponse] -type radarAttackLayer3SummaryVectorResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryVectorResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryVectorResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryVectorResponseMeta struct { - DateRange []RadarAttackLayer3SummaryVectorResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarAttackLayer3SummaryVectorResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer3SummaryVectorResponseMetaJSON `json:"-"` -} - -// radarAttackLayer3SummaryVectorResponseMetaJSON contains the JSON metadata for -// the struct [RadarAttackLayer3SummaryVectorResponseMeta] -type radarAttackLayer3SummaryVectorResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryVectorResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryVectorResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryVectorResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer3SummaryVectorResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer3SummaryVectorResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarAttackLayer3SummaryVectorResponseMetaDateRange] -type radarAttackLayer3SummaryVectorResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryVectorResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryVectorResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryVectorResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer3SummaryVectorResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer3SummaryVectorResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer3SummaryVectorResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer3SummaryVectorResponseMetaConfidenceInfo] -type radarAttackLayer3SummaryVectorResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryVectorResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryVectorResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryVectorResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer3SummaryVectorResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer3SummaryVectorResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarAttackLayer3SummaryVectorResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer3SummaryVectorResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryVectorResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryVectorResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryBitrateParams struct { - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3SummaryBitrateParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Together with the `location` parameter, will apply the filter to origin or - // target location. - Direction param.Field[RadarAttackLayer3SummaryBitrateParamsDirection] `query:"direction"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3SummaryBitrateParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer3SummaryBitrateParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Array of L3/4 attack types. - Protocol param.Field[[]RadarAttackLayer3SummaryBitrateParamsProtocol] `query:"protocol"` -} - -// URLQuery serializes [RadarAttackLayer3SummaryBitrateParams]'s query parameters -// as `url.Values`. -func (r RadarAttackLayer3SummaryBitrateParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer3SummaryBitrateParamsDateRange string - -const ( - RadarAttackLayer3SummaryBitrateParamsDateRange1d RadarAttackLayer3SummaryBitrateParamsDateRange = "1d" - RadarAttackLayer3SummaryBitrateParamsDateRange2d RadarAttackLayer3SummaryBitrateParamsDateRange = "2d" - RadarAttackLayer3SummaryBitrateParamsDateRange7d RadarAttackLayer3SummaryBitrateParamsDateRange = "7d" - RadarAttackLayer3SummaryBitrateParamsDateRange14d RadarAttackLayer3SummaryBitrateParamsDateRange = "14d" - RadarAttackLayer3SummaryBitrateParamsDateRange28d RadarAttackLayer3SummaryBitrateParamsDateRange = "28d" - RadarAttackLayer3SummaryBitrateParamsDateRange12w RadarAttackLayer3SummaryBitrateParamsDateRange = "12w" - RadarAttackLayer3SummaryBitrateParamsDateRange24w RadarAttackLayer3SummaryBitrateParamsDateRange = "24w" - RadarAttackLayer3SummaryBitrateParamsDateRange52w RadarAttackLayer3SummaryBitrateParamsDateRange = "52w" - RadarAttackLayer3SummaryBitrateParamsDateRange1dControl RadarAttackLayer3SummaryBitrateParamsDateRange = "1dControl" - RadarAttackLayer3SummaryBitrateParamsDateRange2dControl RadarAttackLayer3SummaryBitrateParamsDateRange = "2dControl" - RadarAttackLayer3SummaryBitrateParamsDateRange7dControl RadarAttackLayer3SummaryBitrateParamsDateRange = "7dControl" - RadarAttackLayer3SummaryBitrateParamsDateRange14dControl RadarAttackLayer3SummaryBitrateParamsDateRange = "14dControl" - RadarAttackLayer3SummaryBitrateParamsDateRange28dControl RadarAttackLayer3SummaryBitrateParamsDateRange = "28dControl" - RadarAttackLayer3SummaryBitrateParamsDateRange12wControl RadarAttackLayer3SummaryBitrateParamsDateRange = "12wControl" - RadarAttackLayer3SummaryBitrateParamsDateRange24wControl RadarAttackLayer3SummaryBitrateParamsDateRange = "24wControl" -) - -// Together with the `location` parameter, will apply the filter to origin or -// target location. -type RadarAttackLayer3SummaryBitrateParamsDirection string - -const ( - RadarAttackLayer3SummaryBitrateParamsDirectionOrigin RadarAttackLayer3SummaryBitrateParamsDirection = "ORIGIN" - RadarAttackLayer3SummaryBitrateParamsDirectionTarget RadarAttackLayer3SummaryBitrateParamsDirection = "TARGET" -) - -// Format results are returned in. -type RadarAttackLayer3SummaryBitrateParamsFormat string - -const ( - RadarAttackLayer3SummaryBitrateParamsFormatJson RadarAttackLayer3SummaryBitrateParamsFormat = "JSON" - RadarAttackLayer3SummaryBitrateParamsFormatCsv RadarAttackLayer3SummaryBitrateParamsFormat = "CSV" -) - -type RadarAttackLayer3SummaryBitrateParamsIPVersion string - -const ( - RadarAttackLayer3SummaryBitrateParamsIPVersionIPv4 RadarAttackLayer3SummaryBitrateParamsIPVersion = "IPv4" - RadarAttackLayer3SummaryBitrateParamsIPVersionIPv6 RadarAttackLayer3SummaryBitrateParamsIPVersion = "IPv6" -) - -type RadarAttackLayer3SummaryBitrateParamsProtocol string - -const ( - RadarAttackLayer3SummaryBitrateParamsProtocolUdp RadarAttackLayer3SummaryBitrateParamsProtocol = "UDP" - RadarAttackLayer3SummaryBitrateParamsProtocolTcp RadarAttackLayer3SummaryBitrateParamsProtocol = "TCP" - RadarAttackLayer3SummaryBitrateParamsProtocolIcmp RadarAttackLayer3SummaryBitrateParamsProtocol = "ICMP" - RadarAttackLayer3SummaryBitrateParamsProtocolGRE RadarAttackLayer3SummaryBitrateParamsProtocol = "GRE" -) - -type RadarAttackLayer3SummaryBitrateResponseEnvelope struct { - Result RadarAttackLayer3SummaryBitrateResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3SummaryBitrateResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3SummaryBitrateResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarAttackLayer3SummaryBitrateResponseEnvelope] -type radarAttackLayer3SummaryBitrateResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryBitrateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryBitrateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryDurationParams struct { - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3SummaryDurationParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Together with the `location` parameter, will apply the filter to origin or - // target location. - Direction param.Field[RadarAttackLayer3SummaryDurationParamsDirection] `query:"direction"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3SummaryDurationParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer3SummaryDurationParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Array of L3/4 attack types. - Protocol param.Field[[]RadarAttackLayer3SummaryDurationParamsProtocol] `query:"protocol"` -} - -// URLQuery serializes [RadarAttackLayer3SummaryDurationParams]'s query parameters -// as `url.Values`. -func (r RadarAttackLayer3SummaryDurationParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer3SummaryDurationParamsDateRange string - -const ( - RadarAttackLayer3SummaryDurationParamsDateRange1d RadarAttackLayer3SummaryDurationParamsDateRange = "1d" - RadarAttackLayer3SummaryDurationParamsDateRange2d RadarAttackLayer3SummaryDurationParamsDateRange = "2d" - RadarAttackLayer3SummaryDurationParamsDateRange7d RadarAttackLayer3SummaryDurationParamsDateRange = "7d" - RadarAttackLayer3SummaryDurationParamsDateRange14d RadarAttackLayer3SummaryDurationParamsDateRange = "14d" - RadarAttackLayer3SummaryDurationParamsDateRange28d RadarAttackLayer3SummaryDurationParamsDateRange = "28d" - RadarAttackLayer3SummaryDurationParamsDateRange12w RadarAttackLayer3SummaryDurationParamsDateRange = "12w" - RadarAttackLayer3SummaryDurationParamsDateRange24w RadarAttackLayer3SummaryDurationParamsDateRange = "24w" - RadarAttackLayer3SummaryDurationParamsDateRange52w RadarAttackLayer3SummaryDurationParamsDateRange = "52w" - RadarAttackLayer3SummaryDurationParamsDateRange1dControl RadarAttackLayer3SummaryDurationParamsDateRange = "1dControl" - RadarAttackLayer3SummaryDurationParamsDateRange2dControl RadarAttackLayer3SummaryDurationParamsDateRange = "2dControl" - RadarAttackLayer3SummaryDurationParamsDateRange7dControl RadarAttackLayer3SummaryDurationParamsDateRange = "7dControl" - RadarAttackLayer3SummaryDurationParamsDateRange14dControl RadarAttackLayer3SummaryDurationParamsDateRange = "14dControl" - RadarAttackLayer3SummaryDurationParamsDateRange28dControl RadarAttackLayer3SummaryDurationParamsDateRange = "28dControl" - RadarAttackLayer3SummaryDurationParamsDateRange12wControl RadarAttackLayer3SummaryDurationParamsDateRange = "12wControl" - RadarAttackLayer3SummaryDurationParamsDateRange24wControl RadarAttackLayer3SummaryDurationParamsDateRange = "24wControl" -) - -// Together with the `location` parameter, will apply the filter to origin or -// target location. -type RadarAttackLayer3SummaryDurationParamsDirection string - -const ( - RadarAttackLayer3SummaryDurationParamsDirectionOrigin RadarAttackLayer3SummaryDurationParamsDirection = "ORIGIN" - RadarAttackLayer3SummaryDurationParamsDirectionTarget RadarAttackLayer3SummaryDurationParamsDirection = "TARGET" -) - -// Format results are returned in. -type RadarAttackLayer3SummaryDurationParamsFormat string - -const ( - RadarAttackLayer3SummaryDurationParamsFormatJson RadarAttackLayer3SummaryDurationParamsFormat = "JSON" - RadarAttackLayer3SummaryDurationParamsFormatCsv RadarAttackLayer3SummaryDurationParamsFormat = "CSV" -) - -type RadarAttackLayer3SummaryDurationParamsIPVersion string - -const ( - RadarAttackLayer3SummaryDurationParamsIPVersionIPv4 RadarAttackLayer3SummaryDurationParamsIPVersion = "IPv4" - RadarAttackLayer3SummaryDurationParamsIPVersionIPv6 RadarAttackLayer3SummaryDurationParamsIPVersion = "IPv6" -) - -type RadarAttackLayer3SummaryDurationParamsProtocol string - -const ( - RadarAttackLayer3SummaryDurationParamsProtocolUdp RadarAttackLayer3SummaryDurationParamsProtocol = "UDP" - RadarAttackLayer3SummaryDurationParamsProtocolTcp RadarAttackLayer3SummaryDurationParamsProtocol = "TCP" - RadarAttackLayer3SummaryDurationParamsProtocolIcmp RadarAttackLayer3SummaryDurationParamsProtocol = "ICMP" - RadarAttackLayer3SummaryDurationParamsProtocolGRE RadarAttackLayer3SummaryDurationParamsProtocol = "GRE" -) - -type RadarAttackLayer3SummaryDurationResponseEnvelope struct { - Result RadarAttackLayer3SummaryDurationResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3SummaryDurationResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3SummaryDurationResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarAttackLayer3SummaryDurationResponseEnvelope] -type radarAttackLayer3SummaryDurationResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryDurationResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryDurationResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3SummaryGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3SummaryGetParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAttackLayer3SummaryGetParams]'s query parameters as -// `url.Values`. -func (r RadarAttackLayer3SummaryGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer3SummaryGetParamsDateRange string - -const ( - RadarAttackLayer3SummaryGetParamsDateRange1d RadarAttackLayer3SummaryGetParamsDateRange = "1d" - RadarAttackLayer3SummaryGetParamsDateRange2d RadarAttackLayer3SummaryGetParamsDateRange = "2d" - RadarAttackLayer3SummaryGetParamsDateRange7d RadarAttackLayer3SummaryGetParamsDateRange = "7d" - RadarAttackLayer3SummaryGetParamsDateRange14d RadarAttackLayer3SummaryGetParamsDateRange = "14d" - RadarAttackLayer3SummaryGetParamsDateRange28d RadarAttackLayer3SummaryGetParamsDateRange = "28d" - RadarAttackLayer3SummaryGetParamsDateRange12w RadarAttackLayer3SummaryGetParamsDateRange = "12w" - RadarAttackLayer3SummaryGetParamsDateRange24w RadarAttackLayer3SummaryGetParamsDateRange = "24w" - RadarAttackLayer3SummaryGetParamsDateRange52w RadarAttackLayer3SummaryGetParamsDateRange = "52w" - RadarAttackLayer3SummaryGetParamsDateRange1dControl RadarAttackLayer3SummaryGetParamsDateRange = "1dControl" - RadarAttackLayer3SummaryGetParamsDateRange2dControl RadarAttackLayer3SummaryGetParamsDateRange = "2dControl" - RadarAttackLayer3SummaryGetParamsDateRange7dControl RadarAttackLayer3SummaryGetParamsDateRange = "7dControl" - RadarAttackLayer3SummaryGetParamsDateRange14dControl RadarAttackLayer3SummaryGetParamsDateRange = "14dControl" - RadarAttackLayer3SummaryGetParamsDateRange28dControl RadarAttackLayer3SummaryGetParamsDateRange = "28dControl" - RadarAttackLayer3SummaryGetParamsDateRange12wControl RadarAttackLayer3SummaryGetParamsDateRange = "12wControl" - RadarAttackLayer3SummaryGetParamsDateRange24wControl RadarAttackLayer3SummaryGetParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer3SummaryGetParamsFormat string - -const ( - RadarAttackLayer3SummaryGetParamsFormatJson RadarAttackLayer3SummaryGetParamsFormat = "JSON" - RadarAttackLayer3SummaryGetParamsFormatCsv RadarAttackLayer3SummaryGetParamsFormat = "CSV" -) - -type RadarAttackLayer3SummaryGetResponseEnvelope struct { - Result RadarAttackLayer3SummaryGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3SummaryGetResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3SummaryGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarAttackLayer3SummaryGetResponseEnvelope] -type radarAttackLayer3SummaryGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryIPVersionParams struct { - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3SummaryIPVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Together with the `location` parameter, will apply the filter to origin or - // target location. - Direction param.Field[RadarAttackLayer3SummaryIPVersionParamsDirection] `query:"direction"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3SummaryIPVersionParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Array of L3/4 attack types. - Protocol param.Field[[]RadarAttackLayer3SummaryIPVersionParamsProtocol] `query:"protocol"` -} - -// URLQuery serializes [RadarAttackLayer3SummaryIPVersionParams]'s query parameters -// as `url.Values`. -func (r RadarAttackLayer3SummaryIPVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer3SummaryIPVersionParamsDateRange string - -const ( - RadarAttackLayer3SummaryIPVersionParamsDateRange1d RadarAttackLayer3SummaryIPVersionParamsDateRange = "1d" - RadarAttackLayer3SummaryIPVersionParamsDateRange2d RadarAttackLayer3SummaryIPVersionParamsDateRange = "2d" - RadarAttackLayer3SummaryIPVersionParamsDateRange7d RadarAttackLayer3SummaryIPVersionParamsDateRange = "7d" - RadarAttackLayer3SummaryIPVersionParamsDateRange14d RadarAttackLayer3SummaryIPVersionParamsDateRange = "14d" - RadarAttackLayer3SummaryIPVersionParamsDateRange28d RadarAttackLayer3SummaryIPVersionParamsDateRange = "28d" - RadarAttackLayer3SummaryIPVersionParamsDateRange12w RadarAttackLayer3SummaryIPVersionParamsDateRange = "12w" - RadarAttackLayer3SummaryIPVersionParamsDateRange24w RadarAttackLayer3SummaryIPVersionParamsDateRange = "24w" - RadarAttackLayer3SummaryIPVersionParamsDateRange52w RadarAttackLayer3SummaryIPVersionParamsDateRange = "52w" - RadarAttackLayer3SummaryIPVersionParamsDateRange1dControl RadarAttackLayer3SummaryIPVersionParamsDateRange = "1dControl" - RadarAttackLayer3SummaryIPVersionParamsDateRange2dControl RadarAttackLayer3SummaryIPVersionParamsDateRange = "2dControl" - RadarAttackLayer3SummaryIPVersionParamsDateRange7dControl RadarAttackLayer3SummaryIPVersionParamsDateRange = "7dControl" - RadarAttackLayer3SummaryIPVersionParamsDateRange14dControl RadarAttackLayer3SummaryIPVersionParamsDateRange = "14dControl" - RadarAttackLayer3SummaryIPVersionParamsDateRange28dControl RadarAttackLayer3SummaryIPVersionParamsDateRange = "28dControl" - RadarAttackLayer3SummaryIPVersionParamsDateRange12wControl RadarAttackLayer3SummaryIPVersionParamsDateRange = "12wControl" - RadarAttackLayer3SummaryIPVersionParamsDateRange24wControl RadarAttackLayer3SummaryIPVersionParamsDateRange = "24wControl" -) - -// Together with the `location` parameter, will apply the filter to origin or -// target location. -type RadarAttackLayer3SummaryIPVersionParamsDirection string - -const ( - RadarAttackLayer3SummaryIPVersionParamsDirectionOrigin RadarAttackLayer3SummaryIPVersionParamsDirection = "ORIGIN" - RadarAttackLayer3SummaryIPVersionParamsDirectionTarget RadarAttackLayer3SummaryIPVersionParamsDirection = "TARGET" -) - -// Format results are returned in. -type RadarAttackLayer3SummaryIPVersionParamsFormat string - -const ( - RadarAttackLayer3SummaryIPVersionParamsFormatJson RadarAttackLayer3SummaryIPVersionParamsFormat = "JSON" - RadarAttackLayer3SummaryIPVersionParamsFormatCsv RadarAttackLayer3SummaryIPVersionParamsFormat = "CSV" -) - -type RadarAttackLayer3SummaryIPVersionParamsProtocol string - -const ( - RadarAttackLayer3SummaryIPVersionParamsProtocolUdp RadarAttackLayer3SummaryIPVersionParamsProtocol = "UDP" - RadarAttackLayer3SummaryIPVersionParamsProtocolTcp RadarAttackLayer3SummaryIPVersionParamsProtocol = "TCP" - RadarAttackLayer3SummaryIPVersionParamsProtocolIcmp RadarAttackLayer3SummaryIPVersionParamsProtocol = "ICMP" - RadarAttackLayer3SummaryIPVersionParamsProtocolGRE RadarAttackLayer3SummaryIPVersionParamsProtocol = "GRE" -) - -type RadarAttackLayer3SummaryIPVersionResponseEnvelope struct { - Result RadarAttackLayer3SummaryIPVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3SummaryIPVersionResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3SummaryIPVersionResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarAttackLayer3SummaryIPVersionResponseEnvelope] -type radarAttackLayer3SummaryIPVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryIPVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryProtocolParams struct { - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3SummaryProtocolParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Together with the `location` parameter, will apply the filter to origin or - // target location. - Direction param.Field[RadarAttackLayer3SummaryProtocolParamsDirection] `query:"direction"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3SummaryProtocolParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer3SummaryProtocolParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAttackLayer3SummaryProtocolParams]'s query parameters -// as `url.Values`. -func (r RadarAttackLayer3SummaryProtocolParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer3SummaryProtocolParamsDateRange string - -const ( - RadarAttackLayer3SummaryProtocolParamsDateRange1d RadarAttackLayer3SummaryProtocolParamsDateRange = "1d" - RadarAttackLayer3SummaryProtocolParamsDateRange2d RadarAttackLayer3SummaryProtocolParamsDateRange = "2d" - RadarAttackLayer3SummaryProtocolParamsDateRange7d RadarAttackLayer3SummaryProtocolParamsDateRange = "7d" - RadarAttackLayer3SummaryProtocolParamsDateRange14d RadarAttackLayer3SummaryProtocolParamsDateRange = "14d" - RadarAttackLayer3SummaryProtocolParamsDateRange28d RadarAttackLayer3SummaryProtocolParamsDateRange = "28d" - RadarAttackLayer3SummaryProtocolParamsDateRange12w RadarAttackLayer3SummaryProtocolParamsDateRange = "12w" - RadarAttackLayer3SummaryProtocolParamsDateRange24w RadarAttackLayer3SummaryProtocolParamsDateRange = "24w" - RadarAttackLayer3SummaryProtocolParamsDateRange52w RadarAttackLayer3SummaryProtocolParamsDateRange = "52w" - RadarAttackLayer3SummaryProtocolParamsDateRange1dControl RadarAttackLayer3SummaryProtocolParamsDateRange = "1dControl" - RadarAttackLayer3SummaryProtocolParamsDateRange2dControl RadarAttackLayer3SummaryProtocolParamsDateRange = "2dControl" - RadarAttackLayer3SummaryProtocolParamsDateRange7dControl RadarAttackLayer3SummaryProtocolParamsDateRange = "7dControl" - RadarAttackLayer3SummaryProtocolParamsDateRange14dControl RadarAttackLayer3SummaryProtocolParamsDateRange = "14dControl" - RadarAttackLayer3SummaryProtocolParamsDateRange28dControl RadarAttackLayer3SummaryProtocolParamsDateRange = "28dControl" - RadarAttackLayer3SummaryProtocolParamsDateRange12wControl RadarAttackLayer3SummaryProtocolParamsDateRange = "12wControl" - RadarAttackLayer3SummaryProtocolParamsDateRange24wControl RadarAttackLayer3SummaryProtocolParamsDateRange = "24wControl" -) - -// Together with the `location` parameter, will apply the filter to origin or -// target location. -type RadarAttackLayer3SummaryProtocolParamsDirection string - -const ( - RadarAttackLayer3SummaryProtocolParamsDirectionOrigin RadarAttackLayer3SummaryProtocolParamsDirection = "ORIGIN" - RadarAttackLayer3SummaryProtocolParamsDirectionTarget RadarAttackLayer3SummaryProtocolParamsDirection = "TARGET" -) - -// Format results are returned in. -type RadarAttackLayer3SummaryProtocolParamsFormat string - -const ( - RadarAttackLayer3SummaryProtocolParamsFormatJson RadarAttackLayer3SummaryProtocolParamsFormat = "JSON" - RadarAttackLayer3SummaryProtocolParamsFormatCsv RadarAttackLayer3SummaryProtocolParamsFormat = "CSV" -) - -type RadarAttackLayer3SummaryProtocolParamsIPVersion string - -const ( - RadarAttackLayer3SummaryProtocolParamsIPVersionIPv4 RadarAttackLayer3SummaryProtocolParamsIPVersion = "IPv4" - RadarAttackLayer3SummaryProtocolParamsIPVersionIPv6 RadarAttackLayer3SummaryProtocolParamsIPVersion = "IPv6" -) - -type RadarAttackLayer3SummaryProtocolResponseEnvelope struct { - Result RadarAttackLayer3SummaryProtocolResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3SummaryProtocolResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3SummaryProtocolResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarAttackLayer3SummaryProtocolResponseEnvelope] -type radarAttackLayer3SummaryProtocolResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryProtocolResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryProtocolResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3SummaryVectorParams struct { - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3SummaryVectorParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Together with the `location` parameter, will apply the filter to origin or - // target location. - Direction param.Field[RadarAttackLayer3SummaryVectorParamsDirection] `query:"direction"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3SummaryVectorParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer3SummaryVectorParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Array of L3/4 attack types. - Protocol param.Field[[]RadarAttackLayer3SummaryVectorParamsProtocol] `query:"protocol"` -} - -// URLQuery serializes [RadarAttackLayer3SummaryVectorParams]'s query parameters as -// `url.Values`. -func (r RadarAttackLayer3SummaryVectorParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer3SummaryVectorParamsDateRange string - -const ( - RadarAttackLayer3SummaryVectorParamsDateRange1d RadarAttackLayer3SummaryVectorParamsDateRange = "1d" - RadarAttackLayer3SummaryVectorParamsDateRange2d RadarAttackLayer3SummaryVectorParamsDateRange = "2d" - RadarAttackLayer3SummaryVectorParamsDateRange7d RadarAttackLayer3SummaryVectorParamsDateRange = "7d" - RadarAttackLayer3SummaryVectorParamsDateRange14d RadarAttackLayer3SummaryVectorParamsDateRange = "14d" - RadarAttackLayer3SummaryVectorParamsDateRange28d RadarAttackLayer3SummaryVectorParamsDateRange = "28d" - RadarAttackLayer3SummaryVectorParamsDateRange12w RadarAttackLayer3SummaryVectorParamsDateRange = "12w" - RadarAttackLayer3SummaryVectorParamsDateRange24w RadarAttackLayer3SummaryVectorParamsDateRange = "24w" - RadarAttackLayer3SummaryVectorParamsDateRange52w RadarAttackLayer3SummaryVectorParamsDateRange = "52w" - RadarAttackLayer3SummaryVectorParamsDateRange1dControl RadarAttackLayer3SummaryVectorParamsDateRange = "1dControl" - RadarAttackLayer3SummaryVectorParamsDateRange2dControl RadarAttackLayer3SummaryVectorParamsDateRange = "2dControl" - RadarAttackLayer3SummaryVectorParamsDateRange7dControl RadarAttackLayer3SummaryVectorParamsDateRange = "7dControl" - RadarAttackLayer3SummaryVectorParamsDateRange14dControl RadarAttackLayer3SummaryVectorParamsDateRange = "14dControl" - RadarAttackLayer3SummaryVectorParamsDateRange28dControl RadarAttackLayer3SummaryVectorParamsDateRange = "28dControl" - RadarAttackLayer3SummaryVectorParamsDateRange12wControl RadarAttackLayer3SummaryVectorParamsDateRange = "12wControl" - RadarAttackLayer3SummaryVectorParamsDateRange24wControl RadarAttackLayer3SummaryVectorParamsDateRange = "24wControl" -) - -// Together with the `location` parameter, will apply the filter to origin or -// target location. -type RadarAttackLayer3SummaryVectorParamsDirection string - -const ( - RadarAttackLayer3SummaryVectorParamsDirectionOrigin RadarAttackLayer3SummaryVectorParamsDirection = "ORIGIN" - RadarAttackLayer3SummaryVectorParamsDirectionTarget RadarAttackLayer3SummaryVectorParamsDirection = "TARGET" -) - -// Format results are returned in. -type RadarAttackLayer3SummaryVectorParamsFormat string - -const ( - RadarAttackLayer3SummaryVectorParamsFormatJson RadarAttackLayer3SummaryVectorParamsFormat = "JSON" - RadarAttackLayer3SummaryVectorParamsFormatCsv RadarAttackLayer3SummaryVectorParamsFormat = "CSV" -) - -type RadarAttackLayer3SummaryVectorParamsIPVersion string - -const ( - RadarAttackLayer3SummaryVectorParamsIPVersionIPv4 RadarAttackLayer3SummaryVectorParamsIPVersion = "IPv4" - RadarAttackLayer3SummaryVectorParamsIPVersionIPv6 RadarAttackLayer3SummaryVectorParamsIPVersion = "IPv6" -) - -type RadarAttackLayer3SummaryVectorParamsProtocol string - -const ( - RadarAttackLayer3SummaryVectorParamsProtocolUdp RadarAttackLayer3SummaryVectorParamsProtocol = "UDP" - RadarAttackLayer3SummaryVectorParamsProtocolTcp RadarAttackLayer3SummaryVectorParamsProtocol = "TCP" - RadarAttackLayer3SummaryVectorParamsProtocolIcmp RadarAttackLayer3SummaryVectorParamsProtocol = "ICMP" - RadarAttackLayer3SummaryVectorParamsProtocolGRE RadarAttackLayer3SummaryVectorParamsProtocol = "GRE" -) - -type RadarAttackLayer3SummaryVectorResponseEnvelope struct { - Result RadarAttackLayer3SummaryVectorResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3SummaryVectorResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3SummaryVectorResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarAttackLayer3SummaryVectorResponseEnvelope] -type radarAttackLayer3SummaryVectorResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3SummaryVectorResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3SummaryVectorResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarattacklayer3summary_test.go b/radarattacklayer3summary_test.go deleted file mode 100644 index efcb4eee3d5..00000000000 --- a/radarattacklayer3summary_test.go +++ /dev/null @@ -1,221 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarAttackLayer3SummaryBitrateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.Summary.Bitrate(context.TODO(), cloudflare.RadarAttackLayer3SummaryBitrateParams{ - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3SummaryBitrateParamsDateRange{cloudflare.RadarAttackLayer3SummaryBitrateParamsDateRange1d, cloudflare.RadarAttackLayer3SummaryBitrateParamsDateRange2d, cloudflare.RadarAttackLayer3SummaryBitrateParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Direction: cloudflare.F(cloudflare.RadarAttackLayer3SummaryBitrateParamsDirectionOrigin), - Format: cloudflare.F(cloudflare.RadarAttackLayer3SummaryBitrateParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer3SummaryBitrateParamsIPVersion{cloudflare.RadarAttackLayer3SummaryBitrateParamsIPVersionIPv4, cloudflare.RadarAttackLayer3SummaryBitrateParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]cloudflare.RadarAttackLayer3SummaryBitrateParamsProtocol{cloudflare.RadarAttackLayer3SummaryBitrateParamsProtocolUdp, cloudflare.RadarAttackLayer3SummaryBitrateParamsProtocolTcp, cloudflare.RadarAttackLayer3SummaryBitrateParamsProtocolIcmp}), - }) - 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 TestRadarAttackLayer3SummaryDurationWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.Summary.Duration(context.TODO(), cloudflare.RadarAttackLayer3SummaryDurationParams{ - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3SummaryDurationParamsDateRange{cloudflare.RadarAttackLayer3SummaryDurationParamsDateRange1d, cloudflare.RadarAttackLayer3SummaryDurationParamsDateRange2d, cloudflare.RadarAttackLayer3SummaryDurationParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Direction: cloudflare.F(cloudflare.RadarAttackLayer3SummaryDurationParamsDirectionOrigin), - Format: cloudflare.F(cloudflare.RadarAttackLayer3SummaryDurationParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer3SummaryDurationParamsIPVersion{cloudflare.RadarAttackLayer3SummaryDurationParamsIPVersionIPv4, cloudflare.RadarAttackLayer3SummaryDurationParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]cloudflare.RadarAttackLayer3SummaryDurationParamsProtocol{cloudflare.RadarAttackLayer3SummaryDurationParamsProtocolUdp, cloudflare.RadarAttackLayer3SummaryDurationParamsProtocolTcp, cloudflare.RadarAttackLayer3SummaryDurationParamsProtocolIcmp}), - }) - 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 TestRadarAttackLayer3SummaryGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.Summary.Get(context.TODO(), cloudflare.RadarAttackLayer3SummaryGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3SummaryGetParamsDateRange{cloudflare.RadarAttackLayer3SummaryGetParamsDateRange1d, cloudflare.RadarAttackLayer3SummaryGetParamsDateRange2d, cloudflare.RadarAttackLayer3SummaryGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer3SummaryGetParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAttackLayer3SummaryIPVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.Summary.IPVersion(context.TODO(), cloudflare.RadarAttackLayer3SummaryIPVersionParams{ - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3SummaryIPVersionParamsDateRange{cloudflare.RadarAttackLayer3SummaryIPVersionParamsDateRange1d, cloudflare.RadarAttackLayer3SummaryIPVersionParamsDateRange2d, cloudflare.RadarAttackLayer3SummaryIPVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Direction: cloudflare.F(cloudflare.RadarAttackLayer3SummaryIPVersionParamsDirectionOrigin), - Format: cloudflare.F(cloudflare.RadarAttackLayer3SummaryIPVersionParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]cloudflare.RadarAttackLayer3SummaryIPVersionParamsProtocol{cloudflare.RadarAttackLayer3SummaryIPVersionParamsProtocolUdp, cloudflare.RadarAttackLayer3SummaryIPVersionParamsProtocolTcp, cloudflare.RadarAttackLayer3SummaryIPVersionParamsProtocolIcmp}), - }) - 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 TestRadarAttackLayer3SummaryProtocolWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.Summary.Protocol(context.TODO(), cloudflare.RadarAttackLayer3SummaryProtocolParams{ - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3SummaryProtocolParamsDateRange{cloudflare.RadarAttackLayer3SummaryProtocolParamsDateRange1d, cloudflare.RadarAttackLayer3SummaryProtocolParamsDateRange2d, cloudflare.RadarAttackLayer3SummaryProtocolParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Direction: cloudflare.F(cloudflare.RadarAttackLayer3SummaryProtocolParamsDirectionOrigin), - Format: cloudflare.F(cloudflare.RadarAttackLayer3SummaryProtocolParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer3SummaryProtocolParamsIPVersion{cloudflare.RadarAttackLayer3SummaryProtocolParamsIPVersionIPv4, cloudflare.RadarAttackLayer3SummaryProtocolParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAttackLayer3SummaryVectorWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.Summary.Vector(context.TODO(), cloudflare.RadarAttackLayer3SummaryVectorParams{ - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3SummaryVectorParamsDateRange{cloudflare.RadarAttackLayer3SummaryVectorParamsDateRange1d, cloudflare.RadarAttackLayer3SummaryVectorParamsDateRange2d, cloudflare.RadarAttackLayer3SummaryVectorParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Direction: cloudflare.F(cloudflare.RadarAttackLayer3SummaryVectorParamsDirectionOrigin), - Format: cloudflare.F(cloudflare.RadarAttackLayer3SummaryVectorParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer3SummaryVectorParamsIPVersion{cloudflare.RadarAttackLayer3SummaryVectorParamsIPVersionIPv4, cloudflare.RadarAttackLayer3SummaryVectorParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]cloudflare.RadarAttackLayer3SummaryVectorParamsProtocol{cloudflare.RadarAttackLayer3SummaryVectorParamsProtocolUdp, cloudflare.RadarAttackLayer3SummaryVectorParamsProtocolTcp, cloudflare.RadarAttackLayer3SummaryVectorParamsProtocolIcmp}), - }) - 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/radarattacklayer3timeseriesgroup.go b/radarattacklayer3timeseriesgroup.go deleted file mode 100644 index 3bd6571a03c..00000000000 --- a/radarattacklayer3timeseriesgroup.go +++ /dev/null @@ -1,1725 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarAttackLayer3TimeseriesGroupService 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 -// [NewRadarAttackLayer3TimeseriesGroupService] method instead. -type RadarAttackLayer3TimeseriesGroupService struct { - Options []option.RequestOption -} - -// NewRadarAttackLayer3TimeseriesGroupService 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 NewRadarAttackLayer3TimeseriesGroupService(opts ...option.RequestOption) (r *RadarAttackLayer3TimeseriesGroupService) { - r = &RadarAttackLayer3TimeseriesGroupService{} - r.Options = opts - return -} - -// Percentage distribution of attacks by bitrate over time. -func (r *RadarAttackLayer3TimeseriesGroupService) Bitrate(ctx context.Context, query RadarAttackLayer3TimeseriesGroupBitrateParams, opts ...option.RequestOption) (res *RadarAttackLayer3TimeseriesGroupBitrateResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3TimeseriesGroupBitrateResponseEnvelope - path := "radar/attacks/layer3/timeseries_groups/bitrate" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by duration over time. -func (r *RadarAttackLayer3TimeseriesGroupService) Duration(ctx context.Context, query RadarAttackLayer3TimeseriesGroupDurationParams, opts ...option.RequestOption) (res *RadarAttackLayer3TimeseriesGroupDurationResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3TimeseriesGroupDurationResponseEnvelope - path := "radar/attacks/layer3/timeseries_groups/duration" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a timeseries of the percentage distribution of network protocols in Layer -// 3/4 attacks. -func (r *RadarAttackLayer3TimeseriesGroupService) Get(ctx context.Context, query RadarAttackLayer3TimeseriesGroupGetParams, opts ...option.RequestOption) (res *RadarAttackLayer3TimeseriesGroupGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3TimeseriesGroupGetResponseEnvelope - path := "radar/attacks/layer3/timeseries_groups" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by industry used over time. -func (r *RadarAttackLayer3TimeseriesGroupService) Industry(ctx context.Context, query RadarAttackLayer3TimeseriesGroupIndustryParams, opts ...option.RequestOption) (res *RadarAttackLayer3TimeseriesGroupIndustryResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3TimeseriesGroupIndustryResponseEnvelope - path := "radar/attacks/layer3/timeseries_groups/industry" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by ip version used over time. -func (r *RadarAttackLayer3TimeseriesGroupService) IPVersion(ctx context.Context, query RadarAttackLayer3TimeseriesGroupIPVersionParams, opts ...option.RequestOption) (res *RadarAttackLayer3TimeseriesGroupIPVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3TimeseriesGroupIPVersionResponseEnvelope - path := "radar/attacks/layer3/timeseries_groups/ip_version" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by protocol used over time. -func (r *RadarAttackLayer3TimeseriesGroupService) Protocol(ctx context.Context, query RadarAttackLayer3TimeseriesGroupProtocolParams, opts ...option.RequestOption) (res *RadarAttackLayer3TimeseriesGroupProtocolResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3TimeseriesGroupProtocolResponseEnvelope - path := "radar/attacks/layer3/timeseries_groups/protocol" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by vector used over time. -func (r *RadarAttackLayer3TimeseriesGroupService) Vector(ctx context.Context, query RadarAttackLayer3TimeseriesGroupVectorParams, opts ...option.RequestOption) (res *RadarAttackLayer3TimeseriesGroupVectorResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3TimeseriesGroupVectorResponseEnvelope - path := "radar/attacks/layer3/timeseries_groups/vector" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by vertical used over time. -func (r *RadarAttackLayer3TimeseriesGroupService) Vertical(ctx context.Context, query RadarAttackLayer3TimeseriesGroupVerticalParams, opts ...option.RequestOption) (res *RadarAttackLayer3TimeseriesGroupVerticalResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3TimeseriesGroupVerticalResponseEnvelope - path := "radar/attacks/layer3/timeseries_groups/vertical" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarAttackLayer3TimeseriesGroupBitrateResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAttackLayer3TimeseriesGroupBitrateResponseSerie0 `json:"serie_0,required"` - JSON radarAttackLayer3TimeseriesGroupBitrateResponseJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupBitrateResponseJSON contains the JSON metadata -// for the struct [RadarAttackLayer3TimeseriesGroupBitrateResponse] -type radarAttackLayer3TimeseriesGroupBitrateResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupBitrateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupBitrateResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupBitrateResponseSerie0 struct { - Number1GbpsTo10Gbps []string `json:"_1_GBPS_TO_10_GBPS,required"` - Number10GbpsTo100Gbps []string `json:"_10_GBPS_TO_100_GBPS,required"` - Number500MbpsTo1Gbps []string `json:"_500_MBPS_TO_1_GBPS,required"` - Over100Gbps []string `json:"OVER_100_GBPS,required"` - Timestamps []string `json:"timestamps,required"` - Under500Mbps []string `json:"UNDER_500_MBPS,required"` - JSON radarAttackLayer3TimeseriesGroupBitrateResponseSerie0JSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupBitrateResponseSerie0JSON contains the JSON -// metadata for the struct [RadarAttackLayer3TimeseriesGroupBitrateResponseSerie0] -type radarAttackLayer3TimeseriesGroupBitrateResponseSerie0JSON struct { - Number1GbpsTo10Gbps apijson.Field - Number10GbpsTo100Gbps apijson.Field - Number500MbpsTo1Gbps apijson.Field - Over100Gbps apijson.Field - Timestamps apijson.Field - Under500Mbps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupBitrateResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupBitrateResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupDurationResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAttackLayer3TimeseriesGroupDurationResponseSerie0 `json:"serie_0,required"` - JSON radarAttackLayer3TimeseriesGroupDurationResponseJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupDurationResponseJSON contains the JSON metadata -// for the struct [RadarAttackLayer3TimeseriesGroupDurationResponse] -type radarAttackLayer3TimeseriesGroupDurationResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupDurationResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupDurationResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupDurationResponseSerie0 struct { - Number1HourTo3Hours []string `json:"_1_HOUR_TO_3_HOURS,required"` - Number10MinsTo20Mins []string `json:"_10_MINS_TO_20_MINS,required"` - Number20MinsTo40Mins []string `json:"_20_MINS_TO_40_MINS,required"` - Number40MinsTo1Hour []string `json:"_40_MINS_TO_1_HOUR,required"` - Over3Hours []string `json:"OVER_3_HOURS,required"` - Timestamps []string `json:"timestamps,required"` - Under10Mins []string `json:"UNDER_10_MINS,required"` - JSON radarAttackLayer3TimeseriesGroupDurationResponseSerie0JSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupDurationResponseSerie0JSON contains the JSON -// metadata for the struct [RadarAttackLayer3TimeseriesGroupDurationResponseSerie0] -type radarAttackLayer3TimeseriesGroupDurationResponseSerie0JSON struct { - Number1HourTo3Hours apijson.Field - Number10MinsTo20Mins apijson.Field - Number20MinsTo40Mins apijson.Field - Number40MinsTo1Hour apijson.Field - Over3Hours apijson.Field - Timestamps apijson.Field - Under10Mins apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupDurationResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupDurationResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupGetResponse struct { - Meta RadarAttackLayer3TimeseriesGroupGetResponseMeta `json:"meta,required"` - Serie0 RadarAttackLayer3TimeseriesGroupGetResponseSerie0 `json:"serie_0,required"` - JSON radarAttackLayer3TimeseriesGroupGetResponseJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupGetResponseJSON contains the JSON metadata for -// the struct [RadarAttackLayer3TimeseriesGroupGetResponse] -type radarAttackLayer3TimeseriesGroupGetResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupGetResponseMeta struct { - AggInterval string `json:"aggInterval,required"` - DateRange []RadarAttackLayer3TimeseriesGroupGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated time.Time `json:"lastUpdated,required" format:"date-time"` - ConfidenceInfo RadarAttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer3TimeseriesGroupGetResponseMetaJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupGetResponseMetaJSON contains the JSON metadata -// for the struct [RadarAttackLayer3TimeseriesGroupGetResponseMeta] -type radarAttackLayer3TimeseriesGroupGetResponseMetaJSON struct { - AggInterval apijson.Field - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer3TimeseriesGroupGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupGetResponseMetaDateRangeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer3TimeseriesGroupGetResponseMetaDateRange] -type radarAttackLayer3TimeseriesGroupGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfo] -type radarAttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarAttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupGetResponseSerie0 struct { - GRE []string `json:"gre,required"` - Icmp []string `json:"icmp,required"` - Tcp []string `json:"tcp,required"` - Timestamps []string `json:"timestamps,required"` - Udp []string `json:"udp,required"` - JSON radarAttackLayer3TimeseriesGroupGetResponseSerie0JSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupGetResponseSerie0JSON contains the JSON metadata -// for the struct [RadarAttackLayer3TimeseriesGroupGetResponseSerie0] -type radarAttackLayer3TimeseriesGroupGetResponseSerie0JSON struct { - GRE apijson.Field - Icmp apijson.Field - Tcp apijson.Field - Timestamps apijson.Field - Udp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupGetResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupGetResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupIndustryResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAttackLayer3TimeseriesGroupIndustryResponseSerie0 `json:"serie_0,required"` - JSON radarAttackLayer3TimeseriesGroupIndustryResponseJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupIndustryResponseJSON contains the JSON metadata -// for the struct [RadarAttackLayer3TimeseriesGroupIndustryResponse] -type radarAttackLayer3TimeseriesGroupIndustryResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupIndustryResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupIndustryResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupIndustryResponseSerie0 struct { - Timestamps []string `json:"timestamps,required"` - ExtraFields map[string][]string `json:"-,extras"` - JSON radarAttackLayer3TimeseriesGroupIndustryResponseSerie0JSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupIndustryResponseSerie0JSON contains the JSON -// metadata for the struct [RadarAttackLayer3TimeseriesGroupIndustryResponseSerie0] -type radarAttackLayer3TimeseriesGroupIndustryResponseSerie0JSON struct { - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupIndustryResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupIndustryResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupIPVersionResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAttackLayer3TimeseriesGroupIPVersionResponseSerie0 `json:"serie_0,required"` - JSON radarAttackLayer3TimeseriesGroupIPVersionResponseJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupIPVersionResponseJSON contains the JSON metadata -// for the struct [RadarAttackLayer3TimeseriesGroupIPVersionResponse] -type radarAttackLayer3TimeseriesGroupIPVersionResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupIPVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupIPVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupIPVersionResponseSerie0 struct { - IPv4 []string `json:"IPv4,required"` - IPv6 []string `json:"IPv6,required"` - Timestamps []string `json:"timestamps,required"` - JSON radarAttackLayer3TimeseriesGroupIPVersionResponseSerie0JSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupIPVersionResponseSerie0JSON contains the JSON -// metadata for the struct -// [RadarAttackLayer3TimeseriesGroupIPVersionResponseSerie0] -type radarAttackLayer3TimeseriesGroupIPVersionResponseSerie0JSON struct { - IPv4 apijson.Field - IPv6 apijson.Field - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupIPVersionResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupIPVersionResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupProtocolResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAttackLayer3TimeseriesGroupProtocolResponseSerie0 `json:"serie_0,required"` - JSON radarAttackLayer3TimeseriesGroupProtocolResponseJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupProtocolResponseJSON contains the JSON metadata -// for the struct [RadarAttackLayer3TimeseriesGroupProtocolResponse] -type radarAttackLayer3TimeseriesGroupProtocolResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupProtocolResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupProtocolResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupProtocolResponseSerie0 struct { - GRE []string `json:"GRE,required"` - Icmp []string `json:"ICMP,required"` - Tcp []string `json:"TCP,required"` - Timestamps []string `json:"timestamps,required"` - Udp []string `json:"UDP,required"` - JSON radarAttackLayer3TimeseriesGroupProtocolResponseSerie0JSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupProtocolResponseSerie0JSON contains the JSON -// metadata for the struct [RadarAttackLayer3TimeseriesGroupProtocolResponseSerie0] -type radarAttackLayer3TimeseriesGroupProtocolResponseSerie0JSON struct { - GRE apijson.Field - Icmp apijson.Field - Tcp apijson.Field - Timestamps apijson.Field - Udp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupProtocolResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupProtocolResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupVectorResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAttackLayer3TimeseriesGroupVectorResponseSerie0 `json:"serie_0,required"` - JSON radarAttackLayer3TimeseriesGroupVectorResponseJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupVectorResponseJSON contains the JSON metadata -// for the struct [RadarAttackLayer3TimeseriesGroupVectorResponse] -type radarAttackLayer3TimeseriesGroupVectorResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupVectorResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupVectorResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupVectorResponseSerie0 struct { - Timestamps []string `json:"timestamps,required"` - ExtraFields map[string][]string `json:"-,extras"` - JSON radarAttackLayer3TimeseriesGroupVectorResponseSerie0JSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupVectorResponseSerie0JSON contains the JSON -// metadata for the struct [RadarAttackLayer3TimeseriesGroupVectorResponseSerie0] -type radarAttackLayer3TimeseriesGroupVectorResponseSerie0JSON struct { - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupVectorResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupVectorResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupVerticalResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAttackLayer3TimeseriesGroupVerticalResponseSerie0 `json:"serie_0,required"` - JSON radarAttackLayer3TimeseriesGroupVerticalResponseJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupVerticalResponseJSON contains the JSON metadata -// for the struct [RadarAttackLayer3TimeseriesGroupVerticalResponse] -type radarAttackLayer3TimeseriesGroupVerticalResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupVerticalResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupVerticalResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupVerticalResponseSerie0 struct { - Timestamps []string `json:"timestamps,required"` - ExtraFields map[string][]string `json:"-,extras"` - JSON radarAttackLayer3TimeseriesGroupVerticalResponseSerie0JSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupVerticalResponseSerie0JSON contains the JSON -// metadata for the struct [RadarAttackLayer3TimeseriesGroupVerticalResponseSerie0] -type radarAttackLayer3TimeseriesGroupVerticalResponseSerie0JSON struct { - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupVerticalResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupVerticalResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupBitrateParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAttackLayer3TimeseriesGroupBitrateParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Together with the `location` parameter, will apply the filter to origin or - // target location. - Direction param.Field[RadarAttackLayer3TimeseriesGroupBitrateParamsDirection] `query:"direction"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3TimeseriesGroupBitrateParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer3TimeseriesGroupBitrateParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Normalization method applied. Refer to - // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). - Normalization param.Field[RadarAttackLayer3TimeseriesGroupBitrateParamsNormalization] `query:"normalization"` - // Array of L3/4 attack types. - Protocol param.Field[[]RadarAttackLayer3TimeseriesGroupBitrateParamsProtocol] `query:"protocol"` -} - -// URLQuery serializes [RadarAttackLayer3TimeseriesGroupBitrateParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer3TimeseriesGroupBitrateParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAttackLayer3TimeseriesGroupBitrateParamsAggInterval string - -const ( - RadarAttackLayer3TimeseriesGroupBitrateParamsAggInterval15m RadarAttackLayer3TimeseriesGroupBitrateParamsAggInterval = "15m" - RadarAttackLayer3TimeseriesGroupBitrateParamsAggInterval1h RadarAttackLayer3TimeseriesGroupBitrateParamsAggInterval = "1h" - RadarAttackLayer3TimeseriesGroupBitrateParamsAggInterval1d RadarAttackLayer3TimeseriesGroupBitrateParamsAggInterval = "1d" - RadarAttackLayer3TimeseriesGroupBitrateParamsAggInterval1w RadarAttackLayer3TimeseriesGroupBitrateParamsAggInterval = "1w" -) - -type RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange string - -const ( - RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange1d RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange = "1d" - RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange2d RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange = "2d" - RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange7d RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange = "7d" - RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange14d RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange = "14d" - RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange28d RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange = "28d" - RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange12w RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange = "12w" - RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange24w RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange = "24w" - RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange52w RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange = "52w" - RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange1dControl RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange = "1dControl" - RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange2dControl RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange = "2dControl" - RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange7dControl RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange = "7dControl" - RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange14dControl RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange = "14dControl" - RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange28dControl RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange = "28dControl" - RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange12wControl RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange = "12wControl" - RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange24wControl RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange = "24wControl" -) - -// Together with the `location` parameter, will apply the filter to origin or -// target location. -type RadarAttackLayer3TimeseriesGroupBitrateParamsDirection string - -const ( - RadarAttackLayer3TimeseriesGroupBitrateParamsDirectionOrigin RadarAttackLayer3TimeseriesGroupBitrateParamsDirection = "ORIGIN" - RadarAttackLayer3TimeseriesGroupBitrateParamsDirectionTarget RadarAttackLayer3TimeseriesGroupBitrateParamsDirection = "TARGET" -) - -// Format results are returned in. -type RadarAttackLayer3TimeseriesGroupBitrateParamsFormat string - -const ( - RadarAttackLayer3TimeseriesGroupBitrateParamsFormatJson RadarAttackLayer3TimeseriesGroupBitrateParamsFormat = "JSON" - RadarAttackLayer3TimeseriesGroupBitrateParamsFormatCsv RadarAttackLayer3TimeseriesGroupBitrateParamsFormat = "CSV" -) - -type RadarAttackLayer3TimeseriesGroupBitrateParamsIPVersion string - -const ( - RadarAttackLayer3TimeseriesGroupBitrateParamsIPVersionIPv4 RadarAttackLayer3TimeseriesGroupBitrateParamsIPVersion = "IPv4" - RadarAttackLayer3TimeseriesGroupBitrateParamsIPVersionIPv6 RadarAttackLayer3TimeseriesGroupBitrateParamsIPVersion = "IPv6" -) - -// Normalization method applied. Refer to -// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). -type RadarAttackLayer3TimeseriesGroupBitrateParamsNormalization string - -const ( - RadarAttackLayer3TimeseriesGroupBitrateParamsNormalizationPercentage RadarAttackLayer3TimeseriesGroupBitrateParamsNormalization = "PERCENTAGE" - RadarAttackLayer3TimeseriesGroupBitrateParamsNormalizationMin0Max RadarAttackLayer3TimeseriesGroupBitrateParamsNormalization = "MIN0_MAX" -) - -type RadarAttackLayer3TimeseriesGroupBitrateParamsProtocol string - -const ( - RadarAttackLayer3TimeseriesGroupBitrateParamsProtocolUdp RadarAttackLayer3TimeseriesGroupBitrateParamsProtocol = "UDP" - RadarAttackLayer3TimeseriesGroupBitrateParamsProtocolTcp RadarAttackLayer3TimeseriesGroupBitrateParamsProtocol = "TCP" - RadarAttackLayer3TimeseriesGroupBitrateParamsProtocolIcmp RadarAttackLayer3TimeseriesGroupBitrateParamsProtocol = "ICMP" - RadarAttackLayer3TimeseriesGroupBitrateParamsProtocolGRE RadarAttackLayer3TimeseriesGroupBitrateParamsProtocol = "GRE" -) - -type RadarAttackLayer3TimeseriesGroupBitrateResponseEnvelope struct { - Result RadarAttackLayer3TimeseriesGroupBitrateResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3TimeseriesGroupBitrateResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupBitrateResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer3TimeseriesGroupBitrateResponseEnvelope] -type radarAttackLayer3TimeseriesGroupBitrateResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupBitrateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupBitrateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupDurationParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAttackLayer3TimeseriesGroupDurationParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3TimeseriesGroupDurationParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Together with the `location` parameter, will apply the filter to origin or - // target location. - Direction param.Field[RadarAttackLayer3TimeseriesGroupDurationParamsDirection] `query:"direction"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3TimeseriesGroupDurationParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer3TimeseriesGroupDurationParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Normalization method applied. Refer to - // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). - Normalization param.Field[RadarAttackLayer3TimeseriesGroupDurationParamsNormalization] `query:"normalization"` - // Array of L3/4 attack types. - Protocol param.Field[[]RadarAttackLayer3TimeseriesGroupDurationParamsProtocol] `query:"protocol"` -} - -// URLQuery serializes [RadarAttackLayer3TimeseriesGroupDurationParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer3TimeseriesGroupDurationParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAttackLayer3TimeseriesGroupDurationParamsAggInterval string - -const ( - RadarAttackLayer3TimeseriesGroupDurationParamsAggInterval15m RadarAttackLayer3TimeseriesGroupDurationParamsAggInterval = "15m" - RadarAttackLayer3TimeseriesGroupDurationParamsAggInterval1h RadarAttackLayer3TimeseriesGroupDurationParamsAggInterval = "1h" - RadarAttackLayer3TimeseriesGroupDurationParamsAggInterval1d RadarAttackLayer3TimeseriesGroupDurationParamsAggInterval = "1d" - RadarAttackLayer3TimeseriesGroupDurationParamsAggInterval1w RadarAttackLayer3TimeseriesGroupDurationParamsAggInterval = "1w" -) - -type RadarAttackLayer3TimeseriesGroupDurationParamsDateRange string - -const ( - RadarAttackLayer3TimeseriesGroupDurationParamsDateRange1d RadarAttackLayer3TimeseriesGroupDurationParamsDateRange = "1d" - RadarAttackLayer3TimeseriesGroupDurationParamsDateRange2d RadarAttackLayer3TimeseriesGroupDurationParamsDateRange = "2d" - RadarAttackLayer3TimeseriesGroupDurationParamsDateRange7d RadarAttackLayer3TimeseriesGroupDurationParamsDateRange = "7d" - RadarAttackLayer3TimeseriesGroupDurationParamsDateRange14d RadarAttackLayer3TimeseriesGroupDurationParamsDateRange = "14d" - RadarAttackLayer3TimeseriesGroupDurationParamsDateRange28d RadarAttackLayer3TimeseriesGroupDurationParamsDateRange = "28d" - RadarAttackLayer3TimeseriesGroupDurationParamsDateRange12w RadarAttackLayer3TimeseriesGroupDurationParamsDateRange = "12w" - RadarAttackLayer3TimeseriesGroupDurationParamsDateRange24w RadarAttackLayer3TimeseriesGroupDurationParamsDateRange = "24w" - RadarAttackLayer3TimeseriesGroupDurationParamsDateRange52w RadarAttackLayer3TimeseriesGroupDurationParamsDateRange = "52w" - RadarAttackLayer3TimeseriesGroupDurationParamsDateRange1dControl RadarAttackLayer3TimeseriesGroupDurationParamsDateRange = "1dControl" - RadarAttackLayer3TimeseriesGroupDurationParamsDateRange2dControl RadarAttackLayer3TimeseriesGroupDurationParamsDateRange = "2dControl" - RadarAttackLayer3TimeseriesGroupDurationParamsDateRange7dControl RadarAttackLayer3TimeseriesGroupDurationParamsDateRange = "7dControl" - RadarAttackLayer3TimeseriesGroupDurationParamsDateRange14dControl RadarAttackLayer3TimeseriesGroupDurationParamsDateRange = "14dControl" - RadarAttackLayer3TimeseriesGroupDurationParamsDateRange28dControl RadarAttackLayer3TimeseriesGroupDurationParamsDateRange = "28dControl" - RadarAttackLayer3TimeseriesGroupDurationParamsDateRange12wControl RadarAttackLayer3TimeseriesGroupDurationParamsDateRange = "12wControl" - RadarAttackLayer3TimeseriesGroupDurationParamsDateRange24wControl RadarAttackLayer3TimeseriesGroupDurationParamsDateRange = "24wControl" -) - -// Together with the `location` parameter, will apply the filter to origin or -// target location. -type RadarAttackLayer3TimeseriesGroupDurationParamsDirection string - -const ( - RadarAttackLayer3TimeseriesGroupDurationParamsDirectionOrigin RadarAttackLayer3TimeseriesGroupDurationParamsDirection = "ORIGIN" - RadarAttackLayer3TimeseriesGroupDurationParamsDirectionTarget RadarAttackLayer3TimeseriesGroupDurationParamsDirection = "TARGET" -) - -// Format results are returned in. -type RadarAttackLayer3TimeseriesGroupDurationParamsFormat string - -const ( - RadarAttackLayer3TimeseriesGroupDurationParamsFormatJson RadarAttackLayer3TimeseriesGroupDurationParamsFormat = "JSON" - RadarAttackLayer3TimeseriesGroupDurationParamsFormatCsv RadarAttackLayer3TimeseriesGroupDurationParamsFormat = "CSV" -) - -type RadarAttackLayer3TimeseriesGroupDurationParamsIPVersion string - -const ( - RadarAttackLayer3TimeseriesGroupDurationParamsIPVersionIPv4 RadarAttackLayer3TimeseriesGroupDurationParamsIPVersion = "IPv4" - RadarAttackLayer3TimeseriesGroupDurationParamsIPVersionIPv6 RadarAttackLayer3TimeseriesGroupDurationParamsIPVersion = "IPv6" -) - -// Normalization method applied. Refer to -// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). -type RadarAttackLayer3TimeseriesGroupDurationParamsNormalization string - -const ( - RadarAttackLayer3TimeseriesGroupDurationParamsNormalizationPercentage RadarAttackLayer3TimeseriesGroupDurationParamsNormalization = "PERCENTAGE" - RadarAttackLayer3TimeseriesGroupDurationParamsNormalizationMin0Max RadarAttackLayer3TimeseriesGroupDurationParamsNormalization = "MIN0_MAX" -) - -type RadarAttackLayer3TimeseriesGroupDurationParamsProtocol string - -const ( - RadarAttackLayer3TimeseriesGroupDurationParamsProtocolUdp RadarAttackLayer3TimeseriesGroupDurationParamsProtocol = "UDP" - RadarAttackLayer3TimeseriesGroupDurationParamsProtocolTcp RadarAttackLayer3TimeseriesGroupDurationParamsProtocol = "TCP" - RadarAttackLayer3TimeseriesGroupDurationParamsProtocolIcmp RadarAttackLayer3TimeseriesGroupDurationParamsProtocol = "ICMP" - RadarAttackLayer3TimeseriesGroupDurationParamsProtocolGRE RadarAttackLayer3TimeseriesGroupDurationParamsProtocol = "GRE" -) - -type RadarAttackLayer3TimeseriesGroupDurationResponseEnvelope struct { - Result RadarAttackLayer3TimeseriesGroupDurationResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3TimeseriesGroupDurationResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupDurationResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer3TimeseriesGroupDurationResponseEnvelope] -type radarAttackLayer3TimeseriesGroupDurationResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupDurationResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupDurationResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupGetParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAttackLayer3TimeseriesGroupGetParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3TimeseriesGroupGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3TimeseriesGroupGetParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAttackLayer3TimeseriesGroupGetParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer3TimeseriesGroupGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAttackLayer3TimeseriesGroupGetParamsAggInterval string - -const ( - RadarAttackLayer3TimeseriesGroupGetParamsAggInterval15m RadarAttackLayer3TimeseriesGroupGetParamsAggInterval = "15m" - RadarAttackLayer3TimeseriesGroupGetParamsAggInterval1h RadarAttackLayer3TimeseriesGroupGetParamsAggInterval = "1h" - RadarAttackLayer3TimeseriesGroupGetParamsAggInterval1d RadarAttackLayer3TimeseriesGroupGetParamsAggInterval = "1d" - RadarAttackLayer3TimeseriesGroupGetParamsAggInterval1w RadarAttackLayer3TimeseriesGroupGetParamsAggInterval = "1w" -) - -type RadarAttackLayer3TimeseriesGroupGetParamsDateRange string - -const ( - RadarAttackLayer3TimeseriesGroupGetParamsDateRange1d RadarAttackLayer3TimeseriesGroupGetParamsDateRange = "1d" - RadarAttackLayer3TimeseriesGroupGetParamsDateRange2d RadarAttackLayer3TimeseriesGroupGetParamsDateRange = "2d" - RadarAttackLayer3TimeseriesGroupGetParamsDateRange7d RadarAttackLayer3TimeseriesGroupGetParamsDateRange = "7d" - RadarAttackLayer3TimeseriesGroupGetParamsDateRange14d RadarAttackLayer3TimeseriesGroupGetParamsDateRange = "14d" - RadarAttackLayer3TimeseriesGroupGetParamsDateRange28d RadarAttackLayer3TimeseriesGroupGetParamsDateRange = "28d" - RadarAttackLayer3TimeseriesGroupGetParamsDateRange12w RadarAttackLayer3TimeseriesGroupGetParamsDateRange = "12w" - RadarAttackLayer3TimeseriesGroupGetParamsDateRange24w RadarAttackLayer3TimeseriesGroupGetParamsDateRange = "24w" - RadarAttackLayer3TimeseriesGroupGetParamsDateRange52w RadarAttackLayer3TimeseriesGroupGetParamsDateRange = "52w" - RadarAttackLayer3TimeseriesGroupGetParamsDateRange1dControl RadarAttackLayer3TimeseriesGroupGetParamsDateRange = "1dControl" - RadarAttackLayer3TimeseriesGroupGetParamsDateRange2dControl RadarAttackLayer3TimeseriesGroupGetParamsDateRange = "2dControl" - RadarAttackLayer3TimeseriesGroupGetParamsDateRange7dControl RadarAttackLayer3TimeseriesGroupGetParamsDateRange = "7dControl" - RadarAttackLayer3TimeseriesGroupGetParamsDateRange14dControl RadarAttackLayer3TimeseriesGroupGetParamsDateRange = "14dControl" - RadarAttackLayer3TimeseriesGroupGetParamsDateRange28dControl RadarAttackLayer3TimeseriesGroupGetParamsDateRange = "28dControl" - RadarAttackLayer3TimeseriesGroupGetParamsDateRange12wControl RadarAttackLayer3TimeseriesGroupGetParamsDateRange = "12wControl" - RadarAttackLayer3TimeseriesGroupGetParamsDateRange24wControl RadarAttackLayer3TimeseriesGroupGetParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer3TimeseriesGroupGetParamsFormat string - -const ( - RadarAttackLayer3TimeseriesGroupGetParamsFormatJson RadarAttackLayer3TimeseriesGroupGetParamsFormat = "JSON" - RadarAttackLayer3TimeseriesGroupGetParamsFormatCsv RadarAttackLayer3TimeseriesGroupGetParamsFormat = "CSV" -) - -type RadarAttackLayer3TimeseriesGroupGetResponseEnvelope struct { - Result RadarAttackLayer3TimeseriesGroupGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3TimeseriesGroupGetResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarAttackLayer3TimeseriesGroupGetResponseEnvelope] -type radarAttackLayer3TimeseriesGroupGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupIndustryParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAttackLayer3TimeseriesGroupIndustryParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Together with the `location` parameter, will apply the filter to origin or - // target location. - Direction param.Field[RadarAttackLayer3TimeseriesGroupIndustryParamsDirection] `query:"direction"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3TimeseriesGroupIndustryParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer3TimeseriesGroupIndustryParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects (eg browsers, verticals, etc) to the top items over - // the time range. - LimitPerGroup param.Field[int64] `query:"limitPerGroup"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Normalization method applied. Refer to - // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). - Normalization param.Field[RadarAttackLayer3TimeseriesGroupIndustryParamsNormalization] `query:"normalization"` -} - -// URLQuery serializes [RadarAttackLayer3TimeseriesGroupIndustryParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer3TimeseriesGroupIndustryParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAttackLayer3TimeseriesGroupIndustryParamsAggInterval string - -const ( - RadarAttackLayer3TimeseriesGroupIndustryParamsAggInterval15m RadarAttackLayer3TimeseriesGroupIndustryParamsAggInterval = "15m" - RadarAttackLayer3TimeseriesGroupIndustryParamsAggInterval1h RadarAttackLayer3TimeseriesGroupIndustryParamsAggInterval = "1h" - RadarAttackLayer3TimeseriesGroupIndustryParamsAggInterval1d RadarAttackLayer3TimeseriesGroupIndustryParamsAggInterval = "1d" - RadarAttackLayer3TimeseriesGroupIndustryParamsAggInterval1w RadarAttackLayer3TimeseriesGroupIndustryParamsAggInterval = "1w" -) - -type RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange string - -const ( - RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange1d RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange = "1d" - RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange2d RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange = "2d" - RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange7d RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange = "7d" - RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange14d RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange = "14d" - RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange28d RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange = "28d" - RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange12w RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange = "12w" - RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange24w RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange = "24w" - RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange52w RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange = "52w" - RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange1dControl RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange = "1dControl" - RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange2dControl RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange = "2dControl" - RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange7dControl RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange = "7dControl" - RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange14dControl RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange = "14dControl" - RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange28dControl RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange = "28dControl" - RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange12wControl RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange = "12wControl" - RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange24wControl RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange = "24wControl" -) - -// Together with the `location` parameter, will apply the filter to origin or -// target location. -type RadarAttackLayer3TimeseriesGroupIndustryParamsDirection string - -const ( - RadarAttackLayer3TimeseriesGroupIndustryParamsDirectionOrigin RadarAttackLayer3TimeseriesGroupIndustryParamsDirection = "ORIGIN" - RadarAttackLayer3TimeseriesGroupIndustryParamsDirectionTarget RadarAttackLayer3TimeseriesGroupIndustryParamsDirection = "TARGET" -) - -// Format results are returned in. -type RadarAttackLayer3TimeseriesGroupIndustryParamsFormat string - -const ( - RadarAttackLayer3TimeseriesGroupIndustryParamsFormatJson RadarAttackLayer3TimeseriesGroupIndustryParamsFormat = "JSON" - RadarAttackLayer3TimeseriesGroupIndustryParamsFormatCsv RadarAttackLayer3TimeseriesGroupIndustryParamsFormat = "CSV" -) - -type RadarAttackLayer3TimeseriesGroupIndustryParamsIPVersion string - -const ( - RadarAttackLayer3TimeseriesGroupIndustryParamsIPVersionIPv4 RadarAttackLayer3TimeseriesGroupIndustryParamsIPVersion = "IPv4" - RadarAttackLayer3TimeseriesGroupIndustryParamsIPVersionIPv6 RadarAttackLayer3TimeseriesGroupIndustryParamsIPVersion = "IPv6" -) - -// Normalization method applied. Refer to -// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). -type RadarAttackLayer3TimeseriesGroupIndustryParamsNormalization string - -const ( - RadarAttackLayer3TimeseriesGroupIndustryParamsNormalizationPercentage RadarAttackLayer3TimeseriesGroupIndustryParamsNormalization = "PERCENTAGE" - RadarAttackLayer3TimeseriesGroupIndustryParamsNormalizationMin0Max RadarAttackLayer3TimeseriesGroupIndustryParamsNormalization = "MIN0_MAX" -) - -type RadarAttackLayer3TimeseriesGroupIndustryResponseEnvelope struct { - Result RadarAttackLayer3TimeseriesGroupIndustryResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3TimeseriesGroupIndustryResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupIndustryResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer3TimeseriesGroupIndustryResponseEnvelope] -type radarAttackLayer3TimeseriesGroupIndustryResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupIndustryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupIndustryResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupIPVersionParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAttackLayer3TimeseriesGroupIPVersionParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Together with the `location` parameter, will apply the filter to origin or - // target location. - Direction param.Field[RadarAttackLayer3TimeseriesGroupIPVersionParamsDirection] `query:"direction"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3TimeseriesGroupIPVersionParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Normalization method applied. Refer to - // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). - Normalization param.Field[RadarAttackLayer3TimeseriesGroupIPVersionParamsNormalization] `query:"normalization"` - // Array of L3/4 attack types. - Protocol param.Field[[]RadarAttackLayer3TimeseriesGroupIPVersionParamsProtocol] `query:"protocol"` -} - -// URLQuery serializes [RadarAttackLayer3TimeseriesGroupIPVersionParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer3TimeseriesGroupIPVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAttackLayer3TimeseriesGroupIPVersionParamsAggInterval string - -const ( - RadarAttackLayer3TimeseriesGroupIPVersionParamsAggInterval15m RadarAttackLayer3TimeseriesGroupIPVersionParamsAggInterval = "15m" - RadarAttackLayer3TimeseriesGroupIPVersionParamsAggInterval1h RadarAttackLayer3TimeseriesGroupIPVersionParamsAggInterval = "1h" - RadarAttackLayer3TimeseriesGroupIPVersionParamsAggInterval1d RadarAttackLayer3TimeseriesGroupIPVersionParamsAggInterval = "1d" - RadarAttackLayer3TimeseriesGroupIPVersionParamsAggInterval1w RadarAttackLayer3TimeseriesGroupIPVersionParamsAggInterval = "1w" -) - -type RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange string - -const ( - RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange1d RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange = "1d" - RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange2d RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange = "2d" - RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange7d RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange = "7d" - RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange14d RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange = "14d" - RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange28d RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange = "28d" - RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange12w RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange = "12w" - RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange24w RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange = "24w" - RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange52w RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange = "52w" - RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange1dControl RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange = "1dControl" - RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange2dControl RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange = "2dControl" - RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange7dControl RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange = "7dControl" - RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange14dControl RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange = "14dControl" - RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange28dControl RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange = "28dControl" - RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange12wControl RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange = "12wControl" - RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange24wControl RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange = "24wControl" -) - -// Together with the `location` parameter, will apply the filter to origin or -// target location. -type RadarAttackLayer3TimeseriesGroupIPVersionParamsDirection string - -const ( - RadarAttackLayer3TimeseriesGroupIPVersionParamsDirectionOrigin RadarAttackLayer3TimeseriesGroupIPVersionParamsDirection = "ORIGIN" - RadarAttackLayer3TimeseriesGroupIPVersionParamsDirectionTarget RadarAttackLayer3TimeseriesGroupIPVersionParamsDirection = "TARGET" -) - -// Format results are returned in. -type RadarAttackLayer3TimeseriesGroupIPVersionParamsFormat string - -const ( - RadarAttackLayer3TimeseriesGroupIPVersionParamsFormatJson RadarAttackLayer3TimeseriesGroupIPVersionParamsFormat = "JSON" - RadarAttackLayer3TimeseriesGroupIPVersionParamsFormatCsv RadarAttackLayer3TimeseriesGroupIPVersionParamsFormat = "CSV" -) - -// Normalization method applied. Refer to -// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). -type RadarAttackLayer3TimeseriesGroupIPVersionParamsNormalization string - -const ( - RadarAttackLayer3TimeseriesGroupIPVersionParamsNormalizationPercentage RadarAttackLayer3TimeseriesGroupIPVersionParamsNormalization = "PERCENTAGE" - RadarAttackLayer3TimeseriesGroupIPVersionParamsNormalizationMin0Max RadarAttackLayer3TimeseriesGroupIPVersionParamsNormalization = "MIN0_MAX" -) - -type RadarAttackLayer3TimeseriesGroupIPVersionParamsProtocol string - -const ( - RadarAttackLayer3TimeseriesGroupIPVersionParamsProtocolUdp RadarAttackLayer3TimeseriesGroupIPVersionParamsProtocol = "UDP" - RadarAttackLayer3TimeseriesGroupIPVersionParamsProtocolTcp RadarAttackLayer3TimeseriesGroupIPVersionParamsProtocol = "TCP" - RadarAttackLayer3TimeseriesGroupIPVersionParamsProtocolIcmp RadarAttackLayer3TimeseriesGroupIPVersionParamsProtocol = "ICMP" - RadarAttackLayer3TimeseriesGroupIPVersionParamsProtocolGRE RadarAttackLayer3TimeseriesGroupIPVersionParamsProtocol = "GRE" -) - -type RadarAttackLayer3TimeseriesGroupIPVersionResponseEnvelope struct { - Result RadarAttackLayer3TimeseriesGroupIPVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3TimeseriesGroupIPVersionResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupIPVersionResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer3TimeseriesGroupIPVersionResponseEnvelope] -type radarAttackLayer3TimeseriesGroupIPVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupIPVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupProtocolParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAttackLayer3TimeseriesGroupProtocolParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Together with the `location` parameter, will apply the filter to origin or - // target location. - Direction param.Field[RadarAttackLayer3TimeseriesGroupProtocolParamsDirection] `query:"direction"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3TimeseriesGroupProtocolParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer3TimeseriesGroupProtocolParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Normalization method applied. Refer to - // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). - Normalization param.Field[RadarAttackLayer3TimeseriesGroupProtocolParamsNormalization] `query:"normalization"` -} - -// URLQuery serializes [RadarAttackLayer3TimeseriesGroupProtocolParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer3TimeseriesGroupProtocolParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAttackLayer3TimeseriesGroupProtocolParamsAggInterval string - -const ( - RadarAttackLayer3TimeseriesGroupProtocolParamsAggInterval15m RadarAttackLayer3TimeseriesGroupProtocolParamsAggInterval = "15m" - RadarAttackLayer3TimeseriesGroupProtocolParamsAggInterval1h RadarAttackLayer3TimeseriesGroupProtocolParamsAggInterval = "1h" - RadarAttackLayer3TimeseriesGroupProtocolParamsAggInterval1d RadarAttackLayer3TimeseriesGroupProtocolParamsAggInterval = "1d" - RadarAttackLayer3TimeseriesGroupProtocolParamsAggInterval1w RadarAttackLayer3TimeseriesGroupProtocolParamsAggInterval = "1w" -) - -type RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange string - -const ( - RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange1d RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange = "1d" - RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange2d RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange = "2d" - RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange7d RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange = "7d" - RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange14d RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange = "14d" - RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange28d RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange = "28d" - RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange12w RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange = "12w" - RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange24w RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange = "24w" - RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange52w RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange = "52w" - RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange1dControl RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange = "1dControl" - RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange2dControl RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange = "2dControl" - RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange7dControl RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange = "7dControl" - RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange14dControl RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange = "14dControl" - RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange28dControl RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange = "28dControl" - RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange12wControl RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange = "12wControl" - RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange24wControl RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange = "24wControl" -) - -// Together with the `location` parameter, will apply the filter to origin or -// target location. -type RadarAttackLayer3TimeseriesGroupProtocolParamsDirection string - -const ( - RadarAttackLayer3TimeseriesGroupProtocolParamsDirectionOrigin RadarAttackLayer3TimeseriesGroupProtocolParamsDirection = "ORIGIN" - RadarAttackLayer3TimeseriesGroupProtocolParamsDirectionTarget RadarAttackLayer3TimeseriesGroupProtocolParamsDirection = "TARGET" -) - -// Format results are returned in. -type RadarAttackLayer3TimeseriesGroupProtocolParamsFormat string - -const ( - RadarAttackLayer3TimeseriesGroupProtocolParamsFormatJson RadarAttackLayer3TimeseriesGroupProtocolParamsFormat = "JSON" - RadarAttackLayer3TimeseriesGroupProtocolParamsFormatCsv RadarAttackLayer3TimeseriesGroupProtocolParamsFormat = "CSV" -) - -type RadarAttackLayer3TimeseriesGroupProtocolParamsIPVersion string - -const ( - RadarAttackLayer3TimeseriesGroupProtocolParamsIPVersionIPv4 RadarAttackLayer3TimeseriesGroupProtocolParamsIPVersion = "IPv4" - RadarAttackLayer3TimeseriesGroupProtocolParamsIPVersionIPv6 RadarAttackLayer3TimeseriesGroupProtocolParamsIPVersion = "IPv6" -) - -// Normalization method applied. Refer to -// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). -type RadarAttackLayer3TimeseriesGroupProtocolParamsNormalization string - -const ( - RadarAttackLayer3TimeseriesGroupProtocolParamsNormalizationPercentage RadarAttackLayer3TimeseriesGroupProtocolParamsNormalization = "PERCENTAGE" - RadarAttackLayer3TimeseriesGroupProtocolParamsNormalizationMin0Max RadarAttackLayer3TimeseriesGroupProtocolParamsNormalization = "MIN0_MAX" -) - -type RadarAttackLayer3TimeseriesGroupProtocolResponseEnvelope struct { - Result RadarAttackLayer3TimeseriesGroupProtocolResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3TimeseriesGroupProtocolResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupProtocolResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer3TimeseriesGroupProtocolResponseEnvelope] -type radarAttackLayer3TimeseriesGroupProtocolResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupProtocolResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupProtocolResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupVectorParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAttackLayer3TimeseriesGroupVectorParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3TimeseriesGroupVectorParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Together with the `location` parameter, will apply the filter to origin or - // target location. - Direction param.Field[RadarAttackLayer3TimeseriesGroupVectorParamsDirection] `query:"direction"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3TimeseriesGroupVectorParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer3TimeseriesGroupVectorParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects (eg browsers, verticals, etc) to the top items over - // the time range. - LimitPerGroup param.Field[int64] `query:"limitPerGroup"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Normalization method applied. Refer to - // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). - Normalization param.Field[RadarAttackLayer3TimeseriesGroupVectorParamsNormalization] `query:"normalization"` - // Array of L3/4 attack types. - Protocol param.Field[[]RadarAttackLayer3TimeseriesGroupVectorParamsProtocol] `query:"protocol"` -} - -// URLQuery serializes [RadarAttackLayer3TimeseriesGroupVectorParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer3TimeseriesGroupVectorParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAttackLayer3TimeseriesGroupVectorParamsAggInterval string - -const ( - RadarAttackLayer3TimeseriesGroupVectorParamsAggInterval15m RadarAttackLayer3TimeseriesGroupVectorParamsAggInterval = "15m" - RadarAttackLayer3TimeseriesGroupVectorParamsAggInterval1h RadarAttackLayer3TimeseriesGroupVectorParamsAggInterval = "1h" - RadarAttackLayer3TimeseriesGroupVectorParamsAggInterval1d RadarAttackLayer3TimeseriesGroupVectorParamsAggInterval = "1d" - RadarAttackLayer3TimeseriesGroupVectorParamsAggInterval1w RadarAttackLayer3TimeseriesGroupVectorParamsAggInterval = "1w" -) - -type RadarAttackLayer3TimeseriesGroupVectorParamsDateRange string - -const ( - RadarAttackLayer3TimeseriesGroupVectorParamsDateRange1d RadarAttackLayer3TimeseriesGroupVectorParamsDateRange = "1d" - RadarAttackLayer3TimeseriesGroupVectorParamsDateRange2d RadarAttackLayer3TimeseriesGroupVectorParamsDateRange = "2d" - RadarAttackLayer3TimeseriesGroupVectorParamsDateRange7d RadarAttackLayer3TimeseriesGroupVectorParamsDateRange = "7d" - RadarAttackLayer3TimeseriesGroupVectorParamsDateRange14d RadarAttackLayer3TimeseriesGroupVectorParamsDateRange = "14d" - RadarAttackLayer3TimeseriesGroupVectorParamsDateRange28d RadarAttackLayer3TimeseriesGroupVectorParamsDateRange = "28d" - RadarAttackLayer3TimeseriesGroupVectorParamsDateRange12w RadarAttackLayer3TimeseriesGroupVectorParamsDateRange = "12w" - RadarAttackLayer3TimeseriesGroupVectorParamsDateRange24w RadarAttackLayer3TimeseriesGroupVectorParamsDateRange = "24w" - RadarAttackLayer3TimeseriesGroupVectorParamsDateRange52w RadarAttackLayer3TimeseriesGroupVectorParamsDateRange = "52w" - RadarAttackLayer3TimeseriesGroupVectorParamsDateRange1dControl RadarAttackLayer3TimeseriesGroupVectorParamsDateRange = "1dControl" - RadarAttackLayer3TimeseriesGroupVectorParamsDateRange2dControl RadarAttackLayer3TimeseriesGroupVectorParamsDateRange = "2dControl" - RadarAttackLayer3TimeseriesGroupVectorParamsDateRange7dControl RadarAttackLayer3TimeseriesGroupVectorParamsDateRange = "7dControl" - RadarAttackLayer3TimeseriesGroupVectorParamsDateRange14dControl RadarAttackLayer3TimeseriesGroupVectorParamsDateRange = "14dControl" - RadarAttackLayer3TimeseriesGroupVectorParamsDateRange28dControl RadarAttackLayer3TimeseriesGroupVectorParamsDateRange = "28dControl" - RadarAttackLayer3TimeseriesGroupVectorParamsDateRange12wControl RadarAttackLayer3TimeseriesGroupVectorParamsDateRange = "12wControl" - RadarAttackLayer3TimeseriesGroupVectorParamsDateRange24wControl RadarAttackLayer3TimeseriesGroupVectorParamsDateRange = "24wControl" -) - -// Together with the `location` parameter, will apply the filter to origin or -// target location. -type RadarAttackLayer3TimeseriesGroupVectorParamsDirection string - -const ( - RadarAttackLayer3TimeseriesGroupVectorParamsDirectionOrigin RadarAttackLayer3TimeseriesGroupVectorParamsDirection = "ORIGIN" - RadarAttackLayer3TimeseriesGroupVectorParamsDirectionTarget RadarAttackLayer3TimeseriesGroupVectorParamsDirection = "TARGET" -) - -// Format results are returned in. -type RadarAttackLayer3TimeseriesGroupVectorParamsFormat string - -const ( - RadarAttackLayer3TimeseriesGroupVectorParamsFormatJson RadarAttackLayer3TimeseriesGroupVectorParamsFormat = "JSON" - RadarAttackLayer3TimeseriesGroupVectorParamsFormatCsv RadarAttackLayer3TimeseriesGroupVectorParamsFormat = "CSV" -) - -type RadarAttackLayer3TimeseriesGroupVectorParamsIPVersion string - -const ( - RadarAttackLayer3TimeseriesGroupVectorParamsIPVersionIPv4 RadarAttackLayer3TimeseriesGroupVectorParamsIPVersion = "IPv4" - RadarAttackLayer3TimeseriesGroupVectorParamsIPVersionIPv6 RadarAttackLayer3TimeseriesGroupVectorParamsIPVersion = "IPv6" -) - -// Normalization method applied. Refer to -// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). -type RadarAttackLayer3TimeseriesGroupVectorParamsNormalization string - -const ( - RadarAttackLayer3TimeseriesGroupVectorParamsNormalizationPercentage RadarAttackLayer3TimeseriesGroupVectorParamsNormalization = "PERCENTAGE" - RadarAttackLayer3TimeseriesGroupVectorParamsNormalizationMin0Max RadarAttackLayer3TimeseriesGroupVectorParamsNormalization = "MIN0_MAX" -) - -type RadarAttackLayer3TimeseriesGroupVectorParamsProtocol string - -const ( - RadarAttackLayer3TimeseriesGroupVectorParamsProtocolUdp RadarAttackLayer3TimeseriesGroupVectorParamsProtocol = "UDP" - RadarAttackLayer3TimeseriesGroupVectorParamsProtocolTcp RadarAttackLayer3TimeseriesGroupVectorParamsProtocol = "TCP" - RadarAttackLayer3TimeseriesGroupVectorParamsProtocolIcmp RadarAttackLayer3TimeseriesGroupVectorParamsProtocol = "ICMP" - RadarAttackLayer3TimeseriesGroupVectorParamsProtocolGRE RadarAttackLayer3TimeseriesGroupVectorParamsProtocol = "GRE" -) - -type RadarAttackLayer3TimeseriesGroupVectorResponseEnvelope struct { - Result RadarAttackLayer3TimeseriesGroupVectorResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3TimeseriesGroupVectorResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupVectorResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarAttackLayer3TimeseriesGroupVectorResponseEnvelope] -type radarAttackLayer3TimeseriesGroupVectorResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupVectorResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupVectorResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TimeseriesGroupVerticalParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAttackLayer3TimeseriesGroupVerticalParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Together with the `location` parameter, will apply the filter to origin or - // target location. - Direction param.Field[RadarAttackLayer3TimeseriesGroupVerticalParamsDirection] `query:"direction"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3TimeseriesGroupVerticalParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer3TimeseriesGroupVerticalParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects (eg browsers, verticals, etc) to the top items over - // the time range. - LimitPerGroup param.Field[int64] `query:"limitPerGroup"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Normalization method applied. Refer to - // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). - Normalization param.Field[RadarAttackLayer3TimeseriesGroupVerticalParamsNormalization] `query:"normalization"` -} - -// URLQuery serializes [RadarAttackLayer3TimeseriesGroupVerticalParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer3TimeseriesGroupVerticalParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAttackLayer3TimeseriesGroupVerticalParamsAggInterval string - -const ( - RadarAttackLayer3TimeseriesGroupVerticalParamsAggInterval15m RadarAttackLayer3TimeseriesGroupVerticalParamsAggInterval = "15m" - RadarAttackLayer3TimeseriesGroupVerticalParamsAggInterval1h RadarAttackLayer3TimeseriesGroupVerticalParamsAggInterval = "1h" - RadarAttackLayer3TimeseriesGroupVerticalParamsAggInterval1d RadarAttackLayer3TimeseriesGroupVerticalParamsAggInterval = "1d" - RadarAttackLayer3TimeseriesGroupVerticalParamsAggInterval1w RadarAttackLayer3TimeseriesGroupVerticalParamsAggInterval = "1w" -) - -type RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange string - -const ( - RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange1d RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange = "1d" - RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange2d RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange = "2d" - RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange7d RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange = "7d" - RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange14d RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange = "14d" - RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange28d RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange = "28d" - RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange12w RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange = "12w" - RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange24w RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange = "24w" - RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange52w RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange = "52w" - RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange1dControl RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange = "1dControl" - RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange2dControl RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange = "2dControl" - RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange7dControl RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange = "7dControl" - RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange14dControl RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange = "14dControl" - RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange28dControl RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange = "28dControl" - RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange12wControl RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange = "12wControl" - RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange24wControl RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange = "24wControl" -) - -// Together with the `location` parameter, will apply the filter to origin or -// target location. -type RadarAttackLayer3TimeseriesGroupVerticalParamsDirection string - -const ( - RadarAttackLayer3TimeseriesGroupVerticalParamsDirectionOrigin RadarAttackLayer3TimeseriesGroupVerticalParamsDirection = "ORIGIN" - RadarAttackLayer3TimeseriesGroupVerticalParamsDirectionTarget RadarAttackLayer3TimeseriesGroupVerticalParamsDirection = "TARGET" -) - -// Format results are returned in. -type RadarAttackLayer3TimeseriesGroupVerticalParamsFormat string - -const ( - RadarAttackLayer3TimeseriesGroupVerticalParamsFormatJson RadarAttackLayer3TimeseriesGroupVerticalParamsFormat = "JSON" - RadarAttackLayer3TimeseriesGroupVerticalParamsFormatCsv RadarAttackLayer3TimeseriesGroupVerticalParamsFormat = "CSV" -) - -type RadarAttackLayer3TimeseriesGroupVerticalParamsIPVersion string - -const ( - RadarAttackLayer3TimeseriesGroupVerticalParamsIPVersionIPv4 RadarAttackLayer3TimeseriesGroupVerticalParamsIPVersion = "IPv4" - RadarAttackLayer3TimeseriesGroupVerticalParamsIPVersionIPv6 RadarAttackLayer3TimeseriesGroupVerticalParamsIPVersion = "IPv6" -) - -// Normalization method applied. Refer to -// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). -type RadarAttackLayer3TimeseriesGroupVerticalParamsNormalization string - -const ( - RadarAttackLayer3TimeseriesGroupVerticalParamsNormalizationPercentage RadarAttackLayer3TimeseriesGroupVerticalParamsNormalization = "PERCENTAGE" - RadarAttackLayer3TimeseriesGroupVerticalParamsNormalizationMin0Max RadarAttackLayer3TimeseriesGroupVerticalParamsNormalization = "MIN0_MAX" -) - -type RadarAttackLayer3TimeseriesGroupVerticalResponseEnvelope struct { - Result RadarAttackLayer3TimeseriesGroupVerticalResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3TimeseriesGroupVerticalResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3TimeseriesGroupVerticalResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer3TimeseriesGroupVerticalResponseEnvelope] -type radarAttackLayer3TimeseriesGroupVerticalResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TimeseriesGroupVerticalResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TimeseriesGroupVerticalResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarattacklayer3timeseriesgroup_test.go b/radarattacklayer3timeseriesgroup_test.go deleted file mode 100644 index a7291ca48ae..00000000000 --- a/radarattacklayer3timeseriesgroup_test.go +++ /dev/null @@ -1,307 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarAttackLayer3TimeseriesGroupBitrateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.TimeseriesGroups.Bitrate(context.TODO(), cloudflare.RadarAttackLayer3TimeseriesGroupBitrateParams{ - AggInterval: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupBitrateParamsAggInterval1h), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange{cloudflare.RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange1d, cloudflare.RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange2d, cloudflare.RadarAttackLayer3TimeseriesGroupBitrateParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Direction: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupBitrateParamsDirectionOrigin), - Format: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupBitrateParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesGroupBitrateParamsIPVersion{cloudflare.RadarAttackLayer3TimeseriesGroupBitrateParamsIPVersionIPv4, cloudflare.RadarAttackLayer3TimeseriesGroupBitrateParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Normalization: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupBitrateParamsNormalizationPercentage), - Protocol: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesGroupBitrateParamsProtocol{cloudflare.RadarAttackLayer3TimeseriesGroupBitrateParamsProtocolUdp, cloudflare.RadarAttackLayer3TimeseriesGroupBitrateParamsProtocolTcp, cloudflare.RadarAttackLayer3TimeseriesGroupBitrateParamsProtocolIcmp}), - }) - 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 TestRadarAttackLayer3TimeseriesGroupDurationWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.TimeseriesGroups.Duration(context.TODO(), cloudflare.RadarAttackLayer3TimeseriesGroupDurationParams{ - AggInterval: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupDurationParamsAggInterval1h), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesGroupDurationParamsDateRange{cloudflare.RadarAttackLayer3TimeseriesGroupDurationParamsDateRange1d, cloudflare.RadarAttackLayer3TimeseriesGroupDurationParamsDateRange2d, cloudflare.RadarAttackLayer3TimeseriesGroupDurationParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Direction: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupDurationParamsDirectionOrigin), - Format: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupDurationParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesGroupDurationParamsIPVersion{cloudflare.RadarAttackLayer3TimeseriesGroupDurationParamsIPVersionIPv4, cloudflare.RadarAttackLayer3TimeseriesGroupDurationParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Normalization: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupDurationParamsNormalizationPercentage), - Protocol: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesGroupDurationParamsProtocol{cloudflare.RadarAttackLayer3TimeseriesGroupDurationParamsProtocolUdp, cloudflare.RadarAttackLayer3TimeseriesGroupDurationParamsProtocolTcp, cloudflare.RadarAttackLayer3TimeseriesGroupDurationParamsProtocolIcmp}), - }) - 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 TestRadarAttackLayer3TimeseriesGroupGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.TimeseriesGroups.Get(context.TODO(), cloudflare.RadarAttackLayer3TimeseriesGroupGetParams{ - AggInterval: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupGetParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesGroupGetParamsDateRange{cloudflare.RadarAttackLayer3TimeseriesGroupGetParamsDateRange1d, cloudflare.RadarAttackLayer3TimeseriesGroupGetParamsDateRange2d, cloudflare.RadarAttackLayer3TimeseriesGroupGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupGetParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAttackLayer3TimeseriesGroupIndustryWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.TimeseriesGroups.Industry(context.TODO(), cloudflare.RadarAttackLayer3TimeseriesGroupIndustryParams{ - AggInterval: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupIndustryParamsAggInterval1h), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange{cloudflare.RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange1d, cloudflare.RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange2d, cloudflare.RadarAttackLayer3TimeseriesGroupIndustryParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Direction: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupIndustryParamsDirectionOrigin), - Format: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupIndustryParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesGroupIndustryParamsIPVersion{cloudflare.RadarAttackLayer3TimeseriesGroupIndustryParamsIPVersionIPv4, cloudflare.RadarAttackLayer3TimeseriesGroupIndustryParamsIPVersionIPv6}), - LimitPerGroup: cloudflare.F(int64(4)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Normalization: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupIndustryParamsNormalizationPercentage), - }) - 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 TestRadarAttackLayer3TimeseriesGroupIPVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.TimeseriesGroups.IPVersion(context.TODO(), cloudflare.RadarAttackLayer3TimeseriesGroupIPVersionParams{ - AggInterval: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupIPVersionParamsAggInterval1h), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange{cloudflare.RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange1d, cloudflare.RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange2d, cloudflare.RadarAttackLayer3TimeseriesGroupIPVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Direction: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupIPVersionParamsDirectionOrigin), - Format: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupIPVersionParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Normalization: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupIPVersionParamsNormalizationPercentage), - Protocol: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesGroupIPVersionParamsProtocol{cloudflare.RadarAttackLayer3TimeseriesGroupIPVersionParamsProtocolUdp, cloudflare.RadarAttackLayer3TimeseriesGroupIPVersionParamsProtocolTcp, cloudflare.RadarAttackLayer3TimeseriesGroupIPVersionParamsProtocolIcmp}), - }) - 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 TestRadarAttackLayer3TimeseriesGroupProtocolWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.TimeseriesGroups.Protocol(context.TODO(), cloudflare.RadarAttackLayer3TimeseriesGroupProtocolParams{ - AggInterval: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupProtocolParamsAggInterval1h), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange{cloudflare.RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange1d, cloudflare.RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange2d, cloudflare.RadarAttackLayer3TimeseriesGroupProtocolParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Direction: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupProtocolParamsDirectionOrigin), - Format: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupProtocolParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesGroupProtocolParamsIPVersion{cloudflare.RadarAttackLayer3TimeseriesGroupProtocolParamsIPVersionIPv4, cloudflare.RadarAttackLayer3TimeseriesGroupProtocolParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Normalization: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupProtocolParamsNormalizationPercentage), - }) - 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 TestRadarAttackLayer3TimeseriesGroupVectorWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.TimeseriesGroups.Vector(context.TODO(), cloudflare.RadarAttackLayer3TimeseriesGroupVectorParams{ - AggInterval: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupVectorParamsAggInterval1h), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesGroupVectorParamsDateRange{cloudflare.RadarAttackLayer3TimeseriesGroupVectorParamsDateRange1d, cloudflare.RadarAttackLayer3TimeseriesGroupVectorParamsDateRange2d, cloudflare.RadarAttackLayer3TimeseriesGroupVectorParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Direction: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupVectorParamsDirectionOrigin), - Format: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupVectorParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesGroupVectorParamsIPVersion{cloudflare.RadarAttackLayer3TimeseriesGroupVectorParamsIPVersionIPv4, cloudflare.RadarAttackLayer3TimeseriesGroupVectorParamsIPVersionIPv6}), - LimitPerGroup: cloudflare.F(int64(4)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Normalization: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupVectorParamsNormalizationPercentage), - Protocol: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesGroupVectorParamsProtocol{cloudflare.RadarAttackLayer3TimeseriesGroupVectorParamsProtocolUdp, cloudflare.RadarAttackLayer3TimeseriesGroupVectorParamsProtocolTcp, cloudflare.RadarAttackLayer3TimeseriesGroupVectorParamsProtocolIcmp}), - }) - 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 TestRadarAttackLayer3TimeseriesGroupVerticalWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.TimeseriesGroups.Vertical(context.TODO(), cloudflare.RadarAttackLayer3TimeseriesGroupVerticalParams{ - AggInterval: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupVerticalParamsAggInterval1h), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange{cloudflare.RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange1d, cloudflare.RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange2d, cloudflare.RadarAttackLayer3TimeseriesGroupVerticalParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Direction: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupVerticalParamsDirectionOrigin), - Format: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupVerticalParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer3TimeseriesGroupVerticalParamsIPVersion{cloudflare.RadarAttackLayer3TimeseriesGroupVerticalParamsIPVersionIPv4, cloudflare.RadarAttackLayer3TimeseriesGroupVerticalParamsIPVersionIPv6}), - LimitPerGroup: cloudflare.F(int64(4)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Normalization: cloudflare.F(cloudflare.RadarAttackLayer3TimeseriesGroupVerticalParamsNormalizationPercentage), - }) - 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/radarattacklayer3top.go b/radarattacklayer3top.go deleted file mode 100644 index 212616b4cc3..00000000000 --- a/radarattacklayer3top.go +++ /dev/null @@ -1,871 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarAttackLayer3TopService 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 [NewRadarAttackLayer3TopService] -// method instead. -type RadarAttackLayer3TopService struct { - Options []option.RequestOption - Locations *RadarAttackLayer3TopLocationService -} - -// NewRadarAttackLayer3TopService 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 NewRadarAttackLayer3TopService(opts ...option.RequestOption) (r *RadarAttackLayer3TopService) { - r = &RadarAttackLayer3TopService{} - r.Options = opts - r.Locations = NewRadarAttackLayer3TopLocationService(opts...) - return -} - -// Get the top attacks from origin to target location. Values are a percentage out -// of the total layer 3 attacks (with billing country). You can optionally limit -// the number of attacks per origin/target location (useful if all the top attacks -// are from or to the same location). -func (r *RadarAttackLayer3TopService) Attacks(ctx context.Context, query RadarAttackLayer3TopAttacksParams, opts ...option.RequestOption) (res *RadarAttackLayer3TopAttacksResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3TopAttacksResponseEnvelope - path := "radar/attacks/layer3/top/attacks" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the Industry of attacks. -func (r *RadarAttackLayer3TopService) Industry(ctx context.Context, query RadarAttackLayer3TopIndustryParams, opts ...option.RequestOption) (res *RadarAttackLayer3TopIndustryResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3TopIndustryResponseEnvelope - path := "radar/attacks/layer3/top/industry" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the Verticals of attacks. -func (r *RadarAttackLayer3TopService) Vertical(ctx context.Context, query RadarAttackLayer3TopVerticalParams, opts ...option.RequestOption) (res *RadarAttackLayer3TopVerticalResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3TopVerticalResponseEnvelope - path := "radar/attacks/layer3/top/vertical" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarAttackLayer3TopAttacksResponse struct { - Meta RadarAttackLayer3TopAttacksResponseMeta `json:"meta,required"` - Top0 []RadarAttackLayer3TopAttacksResponseTop0 `json:"top_0,required"` - JSON radarAttackLayer3TopAttacksResponseJSON `json:"-"` -} - -// radarAttackLayer3TopAttacksResponseJSON contains the JSON metadata for the -// struct [RadarAttackLayer3TopAttacksResponse] -type radarAttackLayer3TopAttacksResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopAttacksResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopAttacksResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopAttacksResponseMeta struct { - DateRange []RadarAttackLayer3TopAttacksResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarAttackLayer3TopAttacksResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer3TopAttacksResponseMetaJSON `json:"-"` -} - -// radarAttackLayer3TopAttacksResponseMetaJSON contains the JSON metadata for the -// struct [RadarAttackLayer3TopAttacksResponseMeta] -type radarAttackLayer3TopAttacksResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopAttacksResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopAttacksResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopAttacksResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer3TopAttacksResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer3TopAttacksResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarAttackLayer3TopAttacksResponseMetaDateRange] -type radarAttackLayer3TopAttacksResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopAttacksResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopAttacksResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopAttacksResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer3TopAttacksResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer3TopAttacksResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer3TopAttacksResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarAttackLayer3TopAttacksResponseMetaConfidenceInfo] -type radarAttackLayer3TopAttacksResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopAttacksResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopAttacksResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopAttacksResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer3TopAttacksResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer3TopAttacksResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer3TopAttacksResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer3TopAttacksResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopAttacksResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopAttacksResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopAttacksResponseTop0 struct { - OriginCountryAlpha2 string `json:"originCountryAlpha2,required"` - OriginCountryName string `json:"originCountryName,required"` - Value string `json:"value,required"` - JSON radarAttackLayer3TopAttacksResponseTop0JSON `json:"-"` -} - -// radarAttackLayer3TopAttacksResponseTop0JSON contains the JSON metadata for the -// struct [RadarAttackLayer3TopAttacksResponseTop0] -type radarAttackLayer3TopAttacksResponseTop0JSON struct { - OriginCountryAlpha2 apijson.Field - OriginCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopAttacksResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopAttacksResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopIndustryResponse struct { - Meta RadarAttackLayer3TopIndustryResponseMeta `json:"meta,required"` - Top0 []RadarAttackLayer3TopIndustryResponseTop0 `json:"top_0,required"` - JSON radarAttackLayer3TopIndustryResponseJSON `json:"-"` -} - -// radarAttackLayer3TopIndustryResponseJSON contains the JSON metadata for the -// struct [RadarAttackLayer3TopIndustryResponse] -type radarAttackLayer3TopIndustryResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopIndustryResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopIndustryResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopIndustryResponseMeta struct { - DateRange []RadarAttackLayer3TopIndustryResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarAttackLayer3TopIndustryResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer3TopIndustryResponseMetaJSON `json:"-"` -} - -// radarAttackLayer3TopIndustryResponseMetaJSON contains the JSON metadata for the -// struct [RadarAttackLayer3TopIndustryResponseMeta] -type radarAttackLayer3TopIndustryResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopIndustryResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopIndustryResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopIndustryResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer3TopIndustryResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer3TopIndustryResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarAttackLayer3TopIndustryResponseMetaDateRange] -type radarAttackLayer3TopIndustryResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopIndustryResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopIndustryResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopIndustryResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer3TopIndustryResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer3TopIndustryResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer3TopIndustryResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarAttackLayer3TopIndustryResponseMetaConfidenceInfo] -type radarAttackLayer3TopIndustryResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopIndustryResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopIndustryResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopIndustryResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer3TopIndustryResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer3TopIndustryResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarAttackLayer3TopIndustryResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer3TopIndustryResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopIndustryResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopIndustryResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopIndustryResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON radarAttackLayer3TopIndustryResponseTop0JSON `json:"-"` -} - -// radarAttackLayer3TopIndustryResponseTop0JSON contains the JSON metadata for the -// struct [RadarAttackLayer3TopIndustryResponseTop0] -type radarAttackLayer3TopIndustryResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopIndustryResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopIndustryResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopVerticalResponse struct { - Meta RadarAttackLayer3TopVerticalResponseMeta `json:"meta,required"` - Top0 []RadarAttackLayer3TopVerticalResponseTop0 `json:"top_0,required"` - JSON radarAttackLayer3TopVerticalResponseJSON `json:"-"` -} - -// radarAttackLayer3TopVerticalResponseJSON contains the JSON metadata for the -// struct [RadarAttackLayer3TopVerticalResponse] -type radarAttackLayer3TopVerticalResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopVerticalResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopVerticalResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopVerticalResponseMeta struct { - DateRange []RadarAttackLayer3TopVerticalResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarAttackLayer3TopVerticalResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer3TopVerticalResponseMetaJSON `json:"-"` -} - -// radarAttackLayer3TopVerticalResponseMetaJSON contains the JSON metadata for the -// struct [RadarAttackLayer3TopVerticalResponseMeta] -type radarAttackLayer3TopVerticalResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopVerticalResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopVerticalResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopVerticalResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer3TopVerticalResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer3TopVerticalResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarAttackLayer3TopVerticalResponseMetaDateRange] -type radarAttackLayer3TopVerticalResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopVerticalResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopVerticalResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopVerticalResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer3TopVerticalResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer3TopVerticalResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer3TopVerticalResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarAttackLayer3TopVerticalResponseMetaConfidenceInfo] -type radarAttackLayer3TopVerticalResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopVerticalResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopVerticalResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopVerticalResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer3TopVerticalResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer3TopVerticalResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarAttackLayer3TopVerticalResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer3TopVerticalResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopVerticalResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopVerticalResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopVerticalResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON radarAttackLayer3TopVerticalResponseTop0JSON `json:"-"` -} - -// radarAttackLayer3TopVerticalResponseTop0JSON contains the JSON metadata for the -// struct [RadarAttackLayer3TopVerticalResponseTop0] -type radarAttackLayer3TopVerticalResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopVerticalResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopVerticalResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopAttacksParams struct { - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3TopAttacksParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3TopAttacksParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer3TopAttacksParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of attack origin/target location attack limits. Together with - // `limitPerLocation`, limits how many objects will be fetched per origin/target - // location. - LimitDirection param.Field[RadarAttackLayer3TopAttacksParamsLimitDirection] `query:"limitDirection"` - // Limit the number of attacks per origin/target (refer to `limitDirection` - // parameter) location. - LimitPerLocation param.Field[int64] `query:"limitPerLocation"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Array of L3/4 attack types. - Protocol param.Field[[]RadarAttackLayer3TopAttacksParamsProtocol] `query:"protocol"` -} - -// URLQuery serializes [RadarAttackLayer3TopAttacksParams]'s query parameters as -// `url.Values`. -func (r RadarAttackLayer3TopAttacksParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer3TopAttacksParamsDateRange string - -const ( - RadarAttackLayer3TopAttacksParamsDateRange1d RadarAttackLayer3TopAttacksParamsDateRange = "1d" - RadarAttackLayer3TopAttacksParamsDateRange2d RadarAttackLayer3TopAttacksParamsDateRange = "2d" - RadarAttackLayer3TopAttacksParamsDateRange7d RadarAttackLayer3TopAttacksParamsDateRange = "7d" - RadarAttackLayer3TopAttacksParamsDateRange14d RadarAttackLayer3TopAttacksParamsDateRange = "14d" - RadarAttackLayer3TopAttacksParamsDateRange28d RadarAttackLayer3TopAttacksParamsDateRange = "28d" - RadarAttackLayer3TopAttacksParamsDateRange12w RadarAttackLayer3TopAttacksParamsDateRange = "12w" - RadarAttackLayer3TopAttacksParamsDateRange24w RadarAttackLayer3TopAttacksParamsDateRange = "24w" - RadarAttackLayer3TopAttacksParamsDateRange52w RadarAttackLayer3TopAttacksParamsDateRange = "52w" - RadarAttackLayer3TopAttacksParamsDateRange1dControl RadarAttackLayer3TopAttacksParamsDateRange = "1dControl" - RadarAttackLayer3TopAttacksParamsDateRange2dControl RadarAttackLayer3TopAttacksParamsDateRange = "2dControl" - RadarAttackLayer3TopAttacksParamsDateRange7dControl RadarAttackLayer3TopAttacksParamsDateRange = "7dControl" - RadarAttackLayer3TopAttacksParamsDateRange14dControl RadarAttackLayer3TopAttacksParamsDateRange = "14dControl" - RadarAttackLayer3TopAttacksParamsDateRange28dControl RadarAttackLayer3TopAttacksParamsDateRange = "28dControl" - RadarAttackLayer3TopAttacksParamsDateRange12wControl RadarAttackLayer3TopAttacksParamsDateRange = "12wControl" - RadarAttackLayer3TopAttacksParamsDateRange24wControl RadarAttackLayer3TopAttacksParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer3TopAttacksParamsFormat string - -const ( - RadarAttackLayer3TopAttacksParamsFormatJson RadarAttackLayer3TopAttacksParamsFormat = "JSON" - RadarAttackLayer3TopAttacksParamsFormatCsv RadarAttackLayer3TopAttacksParamsFormat = "CSV" -) - -type RadarAttackLayer3TopAttacksParamsIPVersion string - -const ( - RadarAttackLayer3TopAttacksParamsIPVersionIPv4 RadarAttackLayer3TopAttacksParamsIPVersion = "IPv4" - RadarAttackLayer3TopAttacksParamsIPVersionIPv6 RadarAttackLayer3TopAttacksParamsIPVersion = "IPv6" -) - -// Array of attack origin/target location attack limits. Together with -// `limitPerLocation`, limits how many objects will be fetched per origin/target -// location. -type RadarAttackLayer3TopAttacksParamsLimitDirection string - -const ( - RadarAttackLayer3TopAttacksParamsLimitDirectionOrigin RadarAttackLayer3TopAttacksParamsLimitDirection = "ORIGIN" - RadarAttackLayer3TopAttacksParamsLimitDirectionTarget RadarAttackLayer3TopAttacksParamsLimitDirection = "TARGET" -) - -type RadarAttackLayer3TopAttacksParamsProtocol string - -const ( - RadarAttackLayer3TopAttacksParamsProtocolUdp RadarAttackLayer3TopAttacksParamsProtocol = "UDP" - RadarAttackLayer3TopAttacksParamsProtocolTcp RadarAttackLayer3TopAttacksParamsProtocol = "TCP" - RadarAttackLayer3TopAttacksParamsProtocolIcmp RadarAttackLayer3TopAttacksParamsProtocol = "ICMP" - RadarAttackLayer3TopAttacksParamsProtocolGRE RadarAttackLayer3TopAttacksParamsProtocol = "GRE" -) - -type RadarAttackLayer3TopAttacksResponseEnvelope struct { - Result RadarAttackLayer3TopAttacksResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3TopAttacksResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3TopAttacksResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarAttackLayer3TopAttacksResponseEnvelope] -type radarAttackLayer3TopAttacksResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopAttacksResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopAttacksResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopIndustryParams struct { - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3TopIndustryParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3TopIndustryParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer3TopIndustryParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Array of L3/4 attack types. - Protocol param.Field[[]RadarAttackLayer3TopIndustryParamsProtocol] `query:"protocol"` -} - -// URLQuery serializes [RadarAttackLayer3TopIndustryParams]'s query parameters as -// `url.Values`. -func (r RadarAttackLayer3TopIndustryParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer3TopIndustryParamsDateRange string - -const ( - RadarAttackLayer3TopIndustryParamsDateRange1d RadarAttackLayer3TopIndustryParamsDateRange = "1d" - RadarAttackLayer3TopIndustryParamsDateRange2d RadarAttackLayer3TopIndustryParamsDateRange = "2d" - RadarAttackLayer3TopIndustryParamsDateRange7d RadarAttackLayer3TopIndustryParamsDateRange = "7d" - RadarAttackLayer3TopIndustryParamsDateRange14d RadarAttackLayer3TopIndustryParamsDateRange = "14d" - RadarAttackLayer3TopIndustryParamsDateRange28d RadarAttackLayer3TopIndustryParamsDateRange = "28d" - RadarAttackLayer3TopIndustryParamsDateRange12w RadarAttackLayer3TopIndustryParamsDateRange = "12w" - RadarAttackLayer3TopIndustryParamsDateRange24w RadarAttackLayer3TopIndustryParamsDateRange = "24w" - RadarAttackLayer3TopIndustryParamsDateRange52w RadarAttackLayer3TopIndustryParamsDateRange = "52w" - RadarAttackLayer3TopIndustryParamsDateRange1dControl RadarAttackLayer3TopIndustryParamsDateRange = "1dControl" - RadarAttackLayer3TopIndustryParamsDateRange2dControl RadarAttackLayer3TopIndustryParamsDateRange = "2dControl" - RadarAttackLayer3TopIndustryParamsDateRange7dControl RadarAttackLayer3TopIndustryParamsDateRange = "7dControl" - RadarAttackLayer3TopIndustryParamsDateRange14dControl RadarAttackLayer3TopIndustryParamsDateRange = "14dControl" - RadarAttackLayer3TopIndustryParamsDateRange28dControl RadarAttackLayer3TopIndustryParamsDateRange = "28dControl" - RadarAttackLayer3TopIndustryParamsDateRange12wControl RadarAttackLayer3TopIndustryParamsDateRange = "12wControl" - RadarAttackLayer3TopIndustryParamsDateRange24wControl RadarAttackLayer3TopIndustryParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer3TopIndustryParamsFormat string - -const ( - RadarAttackLayer3TopIndustryParamsFormatJson RadarAttackLayer3TopIndustryParamsFormat = "JSON" - RadarAttackLayer3TopIndustryParamsFormatCsv RadarAttackLayer3TopIndustryParamsFormat = "CSV" -) - -type RadarAttackLayer3TopIndustryParamsIPVersion string - -const ( - RadarAttackLayer3TopIndustryParamsIPVersionIPv4 RadarAttackLayer3TopIndustryParamsIPVersion = "IPv4" - RadarAttackLayer3TopIndustryParamsIPVersionIPv6 RadarAttackLayer3TopIndustryParamsIPVersion = "IPv6" -) - -type RadarAttackLayer3TopIndustryParamsProtocol string - -const ( - RadarAttackLayer3TopIndustryParamsProtocolUdp RadarAttackLayer3TopIndustryParamsProtocol = "UDP" - RadarAttackLayer3TopIndustryParamsProtocolTcp RadarAttackLayer3TopIndustryParamsProtocol = "TCP" - RadarAttackLayer3TopIndustryParamsProtocolIcmp RadarAttackLayer3TopIndustryParamsProtocol = "ICMP" - RadarAttackLayer3TopIndustryParamsProtocolGRE RadarAttackLayer3TopIndustryParamsProtocol = "GRE" -) - -type RadarAttackLayer3TopIndustryResponseEnvelope struct { - Result RadarAttackLayer3TopIndustryResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3TopIndustryResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3TopIndustryResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarAttackLayer3TopIndustryResponseEnvelope] -type radarAttackLayer3TopIndustryResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopIndustryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopIndustryResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopVerticalParams struct { - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3TopVerticalParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3TopVerticalParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer3TopVerticalParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Array of L3/4 attack types. - Protocol param.Field[[]RadarAttackLayer3TopVerticalParamsProtocol] `query:"protocol"` -} - -// URLQuery serializes [RadarAttackLayer3TopVerticalParams]'s query parameters as -// `url.Values`. -func (r RadarAttackLayer3TopVerticalParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer3TopVerticalParamsDateRange string - -const ( - RadarAttackLayer3TopVerticalParamsDateRange1d RadarAttackLayer3TopVerticalParamsDateRange = "1d" - RadarAttackLayer3TopVerticalParamsDateRange2d RadarAttackLayer3TopVerticalParamsDateRange = "2d" - RadarAttackLayer3TopVerticalParamsDateRange7d RadarAttackLayer3TopVerticalParamsDateRange = "7d" - RadarAttackLayer3TopVerticalParamsDateRange14d RadarAttackLayer3TopVerticalParamsDateRange = "14d" - RadarAttackLayer3TopVerticalParamsDateRange28d RadarAttackLayer3TopVerticalParamsDateRange = "28d" - RadarAttackLayer3TopVerticalParamsDateRange12w RadarAttackLayer3TopVerticalParamsDateRange = "12w" - RadarAttackLayer3TopVerticalParamsDateRange24w RadarAttackLayer3TopVerticalParamsDateRange = "24w" - RadarAttackLayer3TopVerticalParamsDateRange52w RadarAttackLayer3TopVerticalParamsDateRange = "52w" - RadarAttackLayer3TopVerticalParamsDateRange1dControl RadarAttackLayer3TopVerticalParamsDateRange = "1dControl" - RadarAttackLayer3TopVerticalParamsDateRange2dControl RadarAttackLayer3TopVerticalParamsDateRange = "2dControl" - RadarAttackLayer3TopVerticalParamsDateRange7dControl RadarAttackLayer3TopVerticalParamsDateRange = "7dControl" - RadarAttackLayer3TopVerticalParamsDateRange14dControl RadarAttackLayer3TopVerticalParamsDateRange = "14dControl" - RadarAttackLayer3TopVerticalParamsDateRange28dControl RadarAttackLayer3TopVerticalParamsDateRange = "28dControl" - RadarAttackLayer3TopVerticalParamsDateRange12wControl RadarAttackLayer3TopVerticalParamsDateRange = "12wControl" - RadarAttackLayer3TopVerticalParamsDateRange24wControl RadarAttackLayer3TopVerticalParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer3TopVerticalParamsFormat string - -const ( - RadarAttackLayer3TopVerticalParamsFormatJson RadarAttackLayer3TopVerticalParamsFormat = "JSON" - RadarAttackLayer3TopVerticalParamsFormatCsv RadarAttackLayer3TopVerticalParamsFormat = "CSV" -) - -type RadarAttackLayer3TopVerticalParamsIPVersion string - -const ( - RadarAttackLayer3TopVerticalParamsIPVersionIPv4 RadarAttackLayer3TopVerticalParamsIPVersion = "IPv4" - RadarAttackLayer3TopVerticalParamsIPVersionIPv6 RadarAttackLayer3TopVerticalParamsIPVersion = "IPv6" -) - -type RadarAttackLayer3TopVerticalParamsProtocol string - -const ( - RadarAttackLayer3TopVerticalParamsProtocolUdp RadarAttackLayer3TopVerticalParamsProtocol = "UDP" - RadarAttackLayer3TopVerticalParamsProtocolTcp RadarAttackLayer3TopVerticalParamsProtocol = "TCP" - RadarAttackLayer3TopVerticalParamsProtocolIcmp RadarAttackLayer3TopVerticalParamsProtocol = "ICMP" - RadarAttackLayer3TopVerticalParamsProtocolGRE RadarAttackLayer3TopVerticalParamsProtocol = "GRE" -) - -type RadarAttackLayer3TopVerticalResponseEnvelope struct { - Result RadarAttackLayer3TopVerticalResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3TopVerticalResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3TopVerticalResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarAttackLayer3TopVerticalResponseEnvelope] -type radarAttackLayer3TopVerticalResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopVerticalResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopVerticalResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarattacklayer3top_test.go b/radarattacklayer3top_test.go deleted file mode 100644 index 37116ff6ea0..00000000000 --- a/radarattacklayer3top_test.go +++ /dev/null @@ -1,122 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarAttackLayer3TopAttacksWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.Top.Attacks(context.TODO(), cloudflare.RadarAttackLayer3TopAttacksParams{ - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3TopAttacksParamsDateRange{cloudflare.RadarAttackLayer3TopAttacksParamsDateRange1d, cloudflare.RadarAttackLayer3TopAttacksParamsDateRange2d, cloudflare.RadarAttackLayer3TopAttacksParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer3TopAttacksParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer3TopAttacksParamsIPVersion{cloudflare.RadarAttackLayer3TopAttacksParamsIPVersionIPv4, cloudflare.RadarAttackLayer3TopAttacksParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - LimitDirection: cloudflare.F(cloudflare.RadarAttackLayer3TopAttacksParamsLimitDirectionOrigin), - LimitPerLocation: cloudflare.F(int64(10)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]cloudflare.RadarAttackLayer3TopAttacksParamsProtocol{cloudflare.RadarAttackLayer3TopAttacksParamsProtocolUdp, cloudflare.RadarAttackLayer3TopAttacksParamsProtocolTcp, cloudflare.RadarAttackLayer3TopAttacksParamsProtocolIcmp}), - }) - 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 TestRadarAttackLayer3TopIndustryWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.Top.Industry(context.TODO(), cloudflare.RadarAttackLayer3TopIndustryParams{ - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3TopIndustryParamsDateRange{cloudflare.RadarAttackLayer3TopIndustryParamsDateRange1d, cloudflare.RadarAttackLayer3TopIndustryParamsDateRange2d, cloudflare.RadarAttackLayer3TopIndustryParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer3TopIndustryParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer3TopIndustryParamsIPVersion{cloudflare.RadarAttackLayer3TopIndustryParamsIPVersionIPv4, cloudflare.RadarAttackLayer3TopIndustryParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]cloudflare.RadarAttackLayer3TopIndustryParamsProtocol{cloudflare.RadarAttackLayer3TopIndustryParamsProtocolUdp, cloudflare.RadarAttackLayer3TopIndustryParamsProtocolTcp, cloudflare.RadarAttackLayer3TopIndustryParamsProtocolIcmp}), - }) - 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 TestRadarAttackLayer3TopVerticalWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.Top.Vertical(context.TODO(), cloudflare.RadarAttackLayer3TopVerticalParams{ - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3TopVerticalParamsDateRange{cloudflare.RadarAttackLayer3TopVerticalParamsDateRange1d, cloudflare.RadarAttackLayer3TopVerticalParamsDateRange2d, cloudflare.RadarAttackLayer3TopVerticalParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer3TopVerticalParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer3TopVerticalParamsIPVersion{cloudflare.RadarAttackLayer3TopVerticalParamsIPVersionIPv4, cloudflare.RadarAttackLayer3TopVerticalParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]cloudflare.RadarAttackLayer3TopVerticalParamsProtocol{cloudflare.RadarAttackLayer3TopVerticalParamsProtocolUdp, cloudflare.RadarAttackLayer3TopVerticalParamsProtocolTcp, cloudflare.RadarAttackLayer3TopVerticalParamsProtocolIcmp}), - }) - 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/radarattacklayer3toplocation.go b/radarattacklayer3toplocation.go deleted file mode 100644 index b3555140b3f..00000000000 --- a/radarattacklayer3toplocation.go +++ /dev/null @@ -1,588 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarAttackLayer3TopLocationService 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 -// [NewRadarAttackLayer3TopLocationService] method instead. -type RadarAttackLayer3TopLocationService struct { - Options []option.RequestOption -} - -// NewRadarAttackLayer3TopLocationService 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 NewRadarAttackLayer3TopLocationService(opts ...option.RequestOption) (r *RadarAttackLayer3TopLocationService) { - r = &RadarAttackLayer3TopLocationService{} - r.Options = opts - return -} - -// Get the origin locations of attacks. -func (r *RadarAttackLayer3TopLocationService) Origin(ctx context.Context, query RadarAttackLayer3TopLocationOriginParams, opts ...option.RequestOption) (res *RadarAttackLayer3TopLocationOriginResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3TopLocationOriginResponseEnvelope - path := "radar/attacks/layer3/top/locations/origin" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the target locations of attacks. -func (r *RadarAttackLayer3TopLocationService) Target(ctx context.Context, query RadarAttackLayer3TopLocationTargetParams, opts ...option.RequestOption) (res *RadarAttackLayer3TopLocationTargetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer3TopLocationTargetResponseEnvelope - path := "radar/attacks/layer3/top/locations/target" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarAttackLayer3TopLocationOriginResponse struct { - Meta RadarAttackLayer3TopLocationOriginResponseMeta `json:"meta,required"` - Top0 []RadarAttackLayer3TopLocationOriginResponseTop0 `json:"top_0,required"` - JSON radarAttackLayer3TopLocationOriginResponseJSON `json:"-"` -} - -// radarAttackLayer3TopLocationOriginResponseJSON contains the JSON metadata for -// the struct [RadarAttackLayer3TopLocationOriginResponse] -type radarAttackLayer3TopLocationOriginResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopLocationOriginResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopLocationOriginResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopLocationOriginResponseMeta struct { - DateRange []RadarAttackLayer3TopLocationOriginResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarAttackLayer3TopLocationOriginResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer3TopLocationOriginResponseMetaJSON `json:"-"` -} - -// radarAttackLayer3TopLocationOriginResponseMetaJSON contains the JSON metadata -// for the struct [RadarAttackLayer3TopLocationOriginResponseMeta] -type radarAttackLayer3TopLocationOriginResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopLocationOriginResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopLocationOriginResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopLocationOriginResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer3TopLocationOriginResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer3TopLocationOriginResponseMetaDateRangeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer3TopLocationOriginResponseMetaDateRange] -type radarAttackLayer3TopLocationOriginResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopLocationOriginResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopLocationOriginResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopLocationOriginResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer3TopLocationOriginResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer3TopLocationOriginResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer3TopLocationOriginResponseMetaConfidenceInfoJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer3TopLocationOriginResponseMetaConfidenceInfo] -type radarAttackLayer3TopLocationOriginResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopLocationOriginResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopLocationOriginResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopLocationOriginResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer3TopLocationOriginResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer3TopLocationOriginResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarAttackLayer3TopLocationOriginResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer3TopLocationOriginResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopLocationOriginResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopLocationOriginResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopLocationOriginResponseTop0 struct { - OriginCountryAlpha2 string `json:"originCountryAlpha2,required"` - OriginCountryName string `json:"originCountryName,required"` - Rank float64 `json:"rank,required"` - Value string `json:"value,required"` - JSON radarAttackLayer3TopLocationOriginResponseTop0JSON `json:"-"` -} - -// radarAttackLayer3TopLocationOriginResponseTop0JSON contains the JSON metadata -// for the struct [RadarAttackLayer3TopLocationOriginResponseTop0] -type radarAttackLayer3TopLocationOriginResponseTop0JSON struct { - OriginCountryAlpha2 apijson.Field - OriginCountryName apijson.Field - Rank apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopLocationOriginResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopLocationOriginResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopLocationTargetResponse struct { - Meta RadarAttackLayer3TopLocationTargetResponseMeta `json:"meta,required"` - Top0 []RadarAttackLayer3TopLocationTargetResponseTop0 `json:"top_0,required"` - JSON radarAttackLayer3TopLocationTargetResponseJSON `json:"-"` -} - -// radarAttackLayer3TopLocationTargetResponseJSON contains the JSON metadata for -// the struct [RadarAttackLayer3TopLocationTargetResponse] -type radarAttackLayer3TopLocationTargetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopLocationTargetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopLocationTargetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopLocationTargetResponseMeta struct { - DateRange []RadarAttackLayer3TopLocationTargetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarAttackLayer3TopLocationTargetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer3TopLocationTargetResponseMetaJSON `json:"-"` -} - -// radarAttackLayer3TopLocationTargetResponseMetaJSON contains the JSON metadata -// for the struct [RadarAttackLayer3TopLocationTargetResponseMeta] -type radarAttackLayer3TopLocationTargetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopLocationTargetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopLocationTargetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopLocationTargetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer3TopLocationTargetResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer3TopLocationTargetResponseMetaDateRangeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer3TopLocationTargetResponseMetaDateRange] -type radarAttackLayer3TopLocationTargetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopLocationTargetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopLocationTargetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopLocationTargetResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer3TopLocationTargetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer3TopLocationTargetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer3TopLocationTargetResponseMetaConfidenceInfoJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer3TopLocationTargetResponseMetaConfidenceInfo] -type radarAttackLayer3TopLocationTargetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopLocationTargetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopLocationTargetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopLocationTargetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer3TopLocationTargetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer3TopLocationTargetResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarAttackLayer3TopLocationTargetResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer3TopLocationTargetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopLocationTargetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopLocationTargetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopLocationTargetResponseTop0 struct { - Rank float64 `json:"rank,required"` - TargetCountryAlpha2 string `json:"targetCountryAlpha2,required"` - TargetCountryName string `json:"targetCountryName,required"` - Value string `json:"value,required"` - JSON radarAttackLayer3TopLocationTargetResponseTop0JSON `json:"-"` -} - -// radarAttackLayer3TopLocationTargetResponseTop0JSON contains the JSON metadata -// for the struct [RadarAttackLayer3TopLocationTargetResponseTop0] -type radarAttackLayer3TopLocationTargetResponseTop0JSON struct { - Rank apijson.Field - TargetCountryAlpha2 apijson.Field - TargetCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopLocationTargetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopLocationTargetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopLocationOriginParams struct { - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3TopLocationOriginParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3TopLocationOriginParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer3TopLocationOriginParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Array of L3/4 attack types. - Protocol param.Field[[]RadarAttackLayer3TopLocationOriginParamsProtocol] `query:"protocol"` -} - -// URLQuery serializes [RadarAttackLayer3TopLocationOriginParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer3TopLocationOriginParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer3TopLocationOriginParamsDateRange string - -const ( - RadarAttackLayer3TopLocationOriginParamsDateRange1d RadarAttackLayer3TopLocationOriginParamsDateRange = "1d" - RadarAttackLayer3TopLocationOriginParamsDateRange2d RadarAttackLayer3TopLocationOriginParamsDateRange = "2d" - RadarAttackLayer3TopLocationOriginParamsDateRange7d RadarAttackLayer3TopLocationOriginParamsDateRange = "7d" - RadarAttackLayer3TopLocationOriginParamsDateRange14d RadarAttackLayer3TopLocationOriginParamsDateRange = "14d" - RadarAttackLayer3TopLocationOriginParamsDateRange28d RadarAttackLayer3TopLocationOriginParamsDateRange = "28d" - RadarAttackLayer3TopLocationOriginParamsDateRange12w RadarAttackLayer3TopLocationOriginParamsDateRange = "12w" - RadarAttackLayer3TopLocationOriginParamsDateRange24w RadarAttackLayer3TopLocationOriginParamsDateRange = "24w" - RadarAttackLayer3TopLocationOriginParamsDateRange52w RadarAttackLayer3TopLocationOriginParamsDateRange = "52w" - RadarAttackLayer3TopLocationOriginParamsDateRange1dControl RadarAttackLayer3TopLocationOriginParamsDateRange = "1dControl" - RadarAttackLayer3TopLocationOriginParamsDateRange2dControl RadarAttackLayer3TopLocationOriginParamsDateRange = "2dControl" - RadarAttackLayer3TopLocationOriginParamsDateRange7dControl RadarAttackLayer3TopLocationOriginParamsDateRange = "7dControl" - RadarAttackLayer3TopLocationOriginParamsDateRange14dControl RadarAttackLayer3TopLocationOriginParamsDateRange = "14dControl" - RadarAttackLayer3TopLocationOriginParamsDateRange28dControl RadarAttackLayer3TopLocationOriginParamsDateRange = "28dControl" - RadarAttackLayer3TopLocationOriginParamsDateRange12wControl RadarAttackLayer3TopLocationOriginParamsDateRange = "12wControl" - RadarAttackLayer3TopLocationOriginParamsDateRange24wControl RadarAttackLayer3TopLocationOriginParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer3TopLocationOriginParamsFormat string - -const ( - RadarAttackLayer3TopLocationOriginParamsFormatJson RadarAttackLayer3TopLocationOriginParamsFormat = "JSON" - RadarAttackLayer3TopLocationOriginParamsFormatCsv RadarAttackLayer3TopLocationOriginParamsFormat = "CSV" -) - -type RadarAttackLayer3TopLocationOriginParamsIPVersion string - -const ( - RadarAttackLayer3TopLocationOriginParamsIPVersionIPv4 RadarAttackLayer3TopLocationOriginParamsIPVersion = "IPv4" - RadarAttackLayer3TopLocationOriginParamsIPVersionIPv6 RadarAttackLayer3TopLocationOriginParamsIPVersion = "IPv6" -) - -type RadarAttackLayer3TopLocationOriginParamsProtocol string - -const ( - RadarAttackLayer3TopLocationOriginParamsProtocolUdp RadarAttackLayer3TopLocationOriginParamsProtocol = "UDP" - RadarAttackLayer3TopLocationOriginParamsProtocolTcp RadarAttackLayer3TopLocationOriginParamsProtocol = "TCP" - RadarAttackLayer3TopLocationOriginParamsProtocolIcmp RadarAttackLayer3TopLocationOriginParamsProtocol = "ICMP" - RadarAttackLayer3TopLocationOriginParamsProtocolGRE RadarAttackLayer3TopLocationOriginParamsProtocol = "GRE" -) - -type RadarAttackLayer3TopLocationOriginResponseEnvelope struct { - Result RadarAttackLayer3TopLocationOriginResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3TopLocationOriginResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3TopLocationOriginResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarAttackLayer3TopLocationOriginResponseEnvelope] -type radarAttackLayer3TopLocationOriginResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopLocationOriginResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopLocationOriginResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer3TopLocationTargetParams struct { - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer3TopLocationTargetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer3TopLocationTargetParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer3TopLocationTargetParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Array of L3/4 attack types. - Protocol param.Field[[]RadarAttackLayer3TopLocationTargetParamsProtocol] `query:"protocol"` -} - -// URLQuery serializes [RadarAttackLayer3TopLocationTargetParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer3TopLocationTargetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer3TopLocationTargetParamsDateRange string - -const ( - RadarAttackLayer3TopLocationTargetParamsDateRange1d RadarAttackLayer3TopLocationTargetParamsDateRange = "1d" - RadarAttackLayer3TopLocationTargetParamsDateRange2d RadarAttackLayer3TopLocationTargetParamsDateRange = "2d" - RadarAttackLayer3TopLocationTargetParamsDateRange7d RadarAttackLayer3TopLocationTargetParamsDateRange = "7d" - RadarAttackLayer3TopLocationTargetParamsDateRange14d RadarAttackLayer3TopLocationTargetParamsDateRange = "14d" - RadarAttackLayer3TopLocationTargetParamsDateRange28d RadarAttackLayer3TopLocationTargetParamsDateRange = "28d" - RadarAttackLayer3TopLocationTargetParamsDateRange12w RadarAttackLayer3TopLocationTargetParamsDateRange = "12w" - RadarAttackLayer3TopLocationTargetParamsDateRange24w RadarAttackLayer3TopLocationTargetParamsDateRange = "24w" - RadarAttackLayer3TopLocationTargetParamsDateRange52w RadarAttackLayer3TopLocationTargetParamsDateRange = "52w" - RadarAttackLayer3TopLocationTargetParamsDateRange1dControl RadarAttackLayer3TopLocationTargetParamsDateRange = "1dControl" - RadarAttackLayer3TopLocationTargetParamsDateRange2dControl RadarAttackLayer3TopLocationTargetParamsDateRange = "2dControl" - RadarAttackLayer3TopLocationTargetParamsDateRange7dControl RadarAttackLayer3TopLocationTargetParamsDateRange = "7dControl" - RadarAttackLayer3TopLocationTargetParamsDateRange14dControl RadarAttackLayer3TopLocationTargetParamsDateRange = "14dControl" - RadarAttackLayer3TopLocationTargetParamsDateRange28dControl RadarAttackLayer3TopLocationTargetParamsDateRange = "28dControl" - RadarAttackLayer3TopLocationTargetParamsDateRange12wControl RadarAttackLayer3TopLocationTargetParamsDateRange = "12wControl" - RadarAttackLayer3TopLocationTargetParamsDateRange24wControl RadarAttackLayer3TopLocationTargetParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer3TopLocationTargetParamsFormat string - -const ( - RadarAttackLayer3TopLocationTargetParamsFormatJson RadarAttackLayer3TopLocationTargetParamsFormat = "JSON" - RadarAttackLayer3TopLocationTargetParamsFormatCsv RadarAttackLayer3TopLocationTargetParamsFormat = "CSV" -) - -type RadarAttackLayer3TopLocationTargetParamsIPVersion string - -const ( - RadarAttackLayer3TopLocationTargetParamsIPVersionIPv4 RadarAttackLayer3TopLocationTargetParamsIPVersion = "IPv4" - RadarAttackLayer3TopLocationTargetParamsIPVersionIPv6 RadarAttackLayer3TopLocationTargetParamsIPVersion = "IPv6" -) - -type RadarAttackLayer3TopLocationTargetParamsProtocol string - -const ( - RadarAttackLayer3TopLocationTargetParamsProtocolUdp RadarAttackLayer3TopLocationTargetParamsProtocol = "UDP" - RadarAttackLayer3TopLocationTargetParamsProtocolTcp RadarAttackLayer3TopLocationTargetParamsProtocol = "TCP" - RadarAttackLayer3TopLocationTargetParamsProtocolIcmp RadarAttackLayer3TopLocationTargetParamsProtocol = "ICMP" - RadarAttackLayer3TopLocationTargetParamsProtocolGRE RadarAttackLayer3TopLocationTargetParamsProtocol = "GRE" -) - -type RadarAttackLayer3TopLocationTargetResponseEnvelope struct { - Result RadarAttackLayer3TopLocationTargetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer3TopLocationTargetResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer3TopLocationTargetResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarAttackLayer3TopLocationTargetResponseEnvelope] -type radarAttackLayer3TopLocationTargetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer3TopLocationTargetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer3TopLocationTargetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarattacklayer3toplocation_test.go b/radarattacklayer3toplocation_test.go deleted file mode 100644 index 1279ed8147a..00000000000 --- a/radarattacklayer3toplocation_test.go +++ /dev/null @@ -1,85 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarAttackLayer3TopLocationOriginWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.Top.Locations.Origin(context.TODO(), cloudflare.RadarAttackLayer3TopLocationOriginParams{ - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3TopLocationOriginParamsDateRange{cloudflare.RadarAttackLayer3TopLocationOriginParamsDateRange1d, cloudflare.RadarAttackLayer3TopLocationOriginParamsDateRange2d, cloudflare.RadarAttackLayer3TopLocationOriginParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer3TopLocationOriginParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer3TopLocationOriginParamsIPVersion{cloudflare.RadarAttackLayer3TopLocationOriginParamsIPVersionIPv4, cloudflare.RadarAttackLayer3TopLocationOriginParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]cloudflare.RadarAttackLayer3TopLocationOriginParamsProtocol{cloudflare.RadarAttackLayer3TopLocationOriginParamsProtocolUdp, cloudflare.RadarAttackLayer3TopLocationOriginParamsProtocolTcp, cloudflare.RadarAttackLayer3TopLocationOriginParamsProtocolIcmp}), - }) - 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 TestRadarAttackLayer3TopLocationTargetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer3.Top.Locations.Target(context.TODO(), cloudflare.RadarAttackLayer3TopLocationTargetParams{ - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer3TopLocationTargetParamsDateRange{cloudflare.RadarAttackLayer3TopLocationTargetParamsDateRange1d, cloudflare.RadarAttackLayer3TopLocationTargetParamsDateRange2d, cloudflare.RadarAttackLayer3TopLocationTargetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer3TopLocationTargetParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer3TopLocationTargetParamsIPVersion{cloudflare.RadarAttackLayer3TopLocationTargetParamsIPVersionIPv4, cloudflare.RadarAttackLayer3TopLocationTargetParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Protocol: cloudflare.F([]cloudflare.RadarAttackLayer3TopLocationTargetParamsProtocol{cloudflare.RadarAttackLayer3TopLocationTargetParamsProtocolUdp, cloudflare.RadarAttackLayer3TopLocationTargetParamsProtocolTcp, cloudflare.RadarAttackLayer3TopLocationTargetParamsProtocolIcmp}), - }) - 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/radarattacklayer7.go b/radarattacklayer7.go deleted file mode 100644 index b5f8f13bd90..00000000000 --- a/radarattacklayer7.go +++ /dev/null @@ -1,338 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarAttackLayer7Service 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 [NewRadarAttackLayer7Service] method -// instead. -type RadarAttackLayer7Service struct { - Options []option.RequestOption - Summary *RadarAttackLayer7SummaryService - TimeseriesGroups *RadarAttackLayer7TimeseriesGroupService - Top *RadarAttackLayer7TopService -} - -// NewRadarAttackLayer7Service 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 NewRadarAttackLayer7Service(opts ...option.RequestOption) (r *RadarAttackLayer7Service) { - r = &RadarAttackLayer7Service{} - r.Options = opts - r.Summary = NewRadarAttackLayer7SummaryService(opts...) - r.TimeseriesGroups = NewRadarAttackLayer7TimeseriesGroupService(opts...) - r.Top = NewRadarAttackLayer7TopService(opts...) - return -} - -// Get a timeseries of Layer 7 attacks. Values represent HTTP requests and are -// normalized using min-max by default. -func (r *RadarAttackLayer7Service) Timeseries(ctx context.Context, query RadarAttackLayer7TimeseriesParams, opts ...option.RequestOption) (res *RadarAttackLayer7TimeseriesResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7TimeseriesResponseEnvelope - path := "radar/attacks/layer7/timeseries" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarAttackLayer7TimeseriesResponse struct { - Meta RadarAttackLayer7TimeseriesResponseMeta `json:"meta,required"` - Serie0 RadarAttackLayer7TimeseriesResponseSerie0 `json:"serie_0,required"` - JSON radarAttackLayer7TimeseriesResponseJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesResponseJSON contains the JSON metadata for the -// struct [RadarAttackLayer7TimeseriesResponse] -type radarAttackLayer7TimeseriesResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesResponseMeta struct { - AggInterval string `json:"aggInterval,required"` - DateRange []RadarAttackLayer7TimeseriesResponseMetaDateRange `json:"dateRange,required"` - LastUpdated time.Time `json:"lastUpdated,required" format:"date-time"` - ConfidenceInfo RadarAttackLayer7TimeseriesResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer7TimeseriesResponseMetaJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesResponseMetaJSON contains the JSON metadata for the -// struct [RadarAttackLayer7TimeseriesResponseMeta] -type radarAttackLayer7TimeseriesResponseMetaJSON struct { - AggInterval apijson.Field - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer7TimeseriesResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarAttackLayer7TimeseriesResponseMetaDateRange] -type radarAttackLayer7TimeseriesResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer7TimeseriesResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer7TimeseriesResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarAttackLayer7TimeseriesResponseMetaConfidenceInfo] -type radarAttackLayer7TimeseriesResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer7TimeseriesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer7TimeseriesResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer7TimeseriesResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesResponseSerie0 struct { - Timestamps []time.Time `json:"timestamps,required" format:"date-time"` - Values []string `json:"values,required"` - JSON radarAttackLayer7TimeseriesResponseSerie0JSON `json:"-"` -} - -// radarAttackLayer7TimeseriesResponseSerie0JSON contains the JSON metadata for the -// struct [RadarAttackLayer7TimeseriesResponseSerie0] -type radarAttackLayer7TimeseriesResponseSerie0JSON struct { - Timestamps apijson.Field - Values apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAttackLayer7TimeseriesParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of L7 attack types. - Attack param.Field[[]RadarAttackLayer7TimeseriesParamsAttack] `query:"attack"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7TimeseriesParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7TimeseriesParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Normalization method applied. Refer to - // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). - Normalization param.Field[RadarAttackLayer7TimeseriesParamsNormalization] `query:"normalization"` -} - -// URLQuery serializes [RadarAttackLayer7TimeseriesParams]'s query parameters as -// `url.Values`. -func (r RadarAttackLayer7TimeseriesParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAttackLayer7TimeseriesParamsAggInterval string - -const ( - RadarAttackLayer7TimeseriesParamsAggInterval15m RadarAttackLayer7TimeseriesParamsAggInterval = "15m" - RadarAttackLayer7TimeseriesParamsAggInterval1h RadarAttackLayer7TimeseriesParamsAggInterval = "1h" - RadarAttackLayer7TimeseriesParamsAggInterval1d RadarAttackLayer7TimeseriesParamsAggInterval = "1d" - RadarAttackLayer7TimeseriesParamsAggInterval1w RadarAttackLayer7TimeseriesParamsAggInterval = "1w" -) - -type RadarAttackLayer7TimeseriesParamsAttack string - -const ( - RadarAttackLayer7TimeseriesParamsAttackDDOS RadarAttackLayer7TimeseriesParamsAttack = "DDOS" - RadarAttackLayer7TimeseriesParamsAttackWAF RadarAttackLayer7TimeseriesParamsAttack = "WAF" - RadarAttackLayer7TimeseriesParamsAttackBotManagement RadarAttackLayer7TimeseriesParamsAttack = "BOT_MANAGEMENT" - RadarAttackLayer7TimeseriesParamsAttackAccessRules RadarAttackLayer7TimeseriesParamsAttack = "ACCESS_RULES" - RadarAttackLayer7TimeseriesParamsAttackIPReputation RadarAttackLayer7TimeseriesParamsAttack = "IP_REPUTATION" - RadarAttackLayer7TimeseriesParamsAttackAPIShield RadarAttackLayer7TimeseriesParamsAttack = "API_SHIELD" - RadarAttackLayer7TimeseriesParamsAttackDataLossPrevention RadarAttackLayer7TimeseriesParamsAttack = "DATA_LOSS_PREVENTION" -) - -type RadarAttackLayer7TimeseriesParamsDateRange string - -const ( - RadarAttackLayer7TimeseriesParamsDateRange1d RadarAttackLayer7TimeseriesParamsDateRange = "1d" - RadarAttackLayer7TimeseriesParamsDateRange2d RadarAttackLayer7TimeseriesParamsDateRange = "2d" - RadarAttackLayer7TimeseriesParamsDateRange7d RadarAttackLayer7TimeseriesParamsDateRange = "7d" - RadarAttackLayer7TimeseriesParamsDateRange14d RadarAttackLayer7TimeseriesParamsDateRange = "14d" - RadarAttackLayer7TimeseriesParamsDateRange28d RadarAttackLayer7TimeseriesParamsDateRange = "28d" - RadarAttackLayer7TimeseriesParamsDateRange12w RadarAttackLayer7TimeseriesParamsDateRange = "12w" - RadarAttackLayer7TimeseriesParamsDateRange24w RadarAttackLayer7TimeseriesParamsDateRange = "24w" - RadarAttackLayer7TimeseriesParamsDateRange52w RadarAttackLayer7TimeseriesParamsDateRange = "52w" - RadarAttackLayer7TimeseriesParamsDateRange1dControl RadarAttackLayer7TimeseriesParamsDateRange = "1dControl" - RadarAttackLayer7TimeseriesParamsDateRange2dControl RadarAttackLayer7TimeseriesParamsDateRange = "2dControl" - RadarAttackLayer7TimeseriesParamsDateRange7dControl RadarAttackLayer7TimeseriesParamsDateRange = "7dControl" - RadarAttackLayer7TimeseriesParamsDateRange14dControl RadarAttackLayer7TimeseriesParamsDateRange = "14dControl" - RadarAttackLayer7TimeseriesParamsDateRange28dControl RadarAttackLayer7TimeseriesParamsDateRange = "28dControl" - RadarAttackLayer7TimeseriesParamsDateRange12wControl RadarAttackLayer7TimeseriesParamsDateRange = "12wControl" - RadarAttackLayer7TimeseriesParamsDateRange24wControl RadarAttackLayer7TimeseriesParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7TimeseriesParamsFormat string - -const ( - RadarAttackLayer7TimeseriesParamsFormatJson RadarAttackLayer7TimeseriesParamsFormat = "JSON" - RadarAttackLayer7TimeseriesParamsFormatCsv RadarAttackLayer7TimeseriesParamsFormat = "CSV" -) - -// Normalization method applied. Refer to -// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). -type RadarAttackLayer7TimeseriesParamsNormalization string - -const ( - RadarAttackLayer7TimeseriesParamsNormalizationPercentageChange RadarAttackLayer7TimeseriesParamsNormalization = "PERCENTAGE_CHANGE" - RadarAttackLayer7TimeseriesParamsNormalizationMin0Max RadarAttackLayer7TimeseriesParamsNormalization = "MIN0_MAX" -) - -type RadarAttackLayer7TimeseriesResponseEnvelope struct { - Result RadarAttackLayer7TimeseriesResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7TimeseriesResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarAttackLayer7TimeseriesResponseEnvelope] -type radarAttackLayer7TimeseriesResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarattacklayer7_test.go b/radarattacklayer7_test.go deleted file mode 100644 index 48487f8459c..00000000000 --- a/radarattacklayer7_test.go +++ /dev/null @@ -1,51 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarAttackLayer7TimeseriesWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.Timeseries(context.TODO(), cloudflare.RadarAttackLayer7TimeseriesParams{ - AggInterval: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Attack: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesParamsAttack{cloudflare.RadarAttackLayer7TimeseriesParamsAttackDDOS, cloudflare.RadarAttackLayer7TimeseriesParamsAttackWAF, cloudflare.RadarAttackLayer7TimeseriesParamsAttackBotManagement}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesParamsDateRange{cloudflare.RadarAttackLayer7TimeseriesParamsDateRange1d, cloudflare.RadarAttackLayer7TimeseriesParamsDateRange2d, cloudflare.RadarAttackLayer7TimeseriesParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Normalization: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesParamsNormalizationMin0Max), - }) - 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/radarattacklayer7summary.go b/radarattacklayer7summary.go deleted file mode 100644 index 6b5a2c07c5f..00000000000 --- a/radarattacklayer7summary.go +++ /dev/null @@ -1,1927 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarAttackLayer7SummaryService 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 -// [NewRadarAttackLayer7SummaryService] method instead. -type RadarAttackLayer7SummaryService struct { - Options []option.RequestOption -} - -// NewRadarAttackLayer7SummaryService 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 NewRadarAttackLayer7SummaryService(opts ...option.RequestOption) (r *RadarAttackLayer7SummaryService) { - r = &RadarAttackLayer7SummaryService{} - r.Options = opts - return -} - -// Percentage distribution of mitigation techniques in Layer 7 attacks. -func (r *RadarAttackLayer7SummaryService) Get(ctx context.Context, query RadarAttackLayer7SummaryGetParams, opts ...option.RequestOption) (res *RadarAttackLayer7SummaryGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7SummaryGetResponseEnvelope - path := "radar/attacks/layer7/summary" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by http method used. -func (r *RadarAttackLayer7SummaryService) HTTPMethod(ctx context.Context, query RadarAttackLayer7SummaryHTTPMethodParams, opts ...option.RequestOption) (res *RadarAttackLayer7SummaryHTTPMethodResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7SummaryHTTPMethodResponseEnvelope - path := "radar/attacks/layer7/summary/http_method" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by http version used. -func (r *RadarAttackLayer7SummaryService) HTTPVersion(ctx context.Context, query RadarAttackLayer7SummaryHTTPVersionParams, opts ...option.RequestOption) (res *RadarAttackLayer7SummaryHTTPVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7SummaryHTTPVersionResponseEnvelope - path := "radar/attacks/layer7/summary/http_version" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by ip version used. -func (r *RadarAttackLayer7SummaryService) IPVersion(ctx context.Context, query RadarAttackLayer7SummaryIPVersionParams, opts ...option.RequestOption) (res *RadarAttackLayer7SummaryIPVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7SummaryIPVersionResponseEnvelope - path := "radar/attacks/layer7/summary/ip_version" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by managed rules used. -func (r *RadarAttackLayer7SummaryService) ManagedRules(ctx context.Context, query RadarAttackLayer7SummaryManagedRulesParams, opts ...option.RequestOption) (res *RadarAttackLayer7SummaryManagedRulesResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7SummaryManagedRulesResponseEnvelope - path := "radar/attacks/layer7/summary/managed_rules" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by mitigation product used. -func (r *RadarAttackLayer7SummaryService) MitigationProduct(ctx context.Context, query RadarAttackLayer7SummaryMitigationProductParams, opts ...option.RequestOption) (res *RadarAttackLayer7SummaryMitigationProductResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7SummaryMitigationProductResponseEnvelope - path := "radar/attacks/layer7/summary/mitigation_product" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarAttackLayer7SummaryGetResponse struct { - Meta RadarAttackLayer7SummaryGetResponseMeta `json:"meta,required"` - Summary0 RadarAttackLayer7SummaryGetResponseSummary0 `json:"summary_0,required"` - JSON radarAttackLayer7SummaryGetResponseJSON `json:"-"` -} - -// radarAttackLayer7SummaryGetResponseJSON contains the JSON metadata for the -// struct [RadarAttackLayer7SummaryGetResponse] -type radarAttackLayer7SummaryGetResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryGetResponseMeta struct { - DateRange []RadarAttackLayer7SummaryGetResponseMetaDateRange `json:"dateRange,required"` - ConfidenceInfo RadarAttackLayer7SummaryGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer7SummaryGetResponseMetaJSON `json:"-"` -} - -// radarAttackLayer7SummaryGetResponseMetaJSON contains the JSON metadata for the -// struct [RadarAttackLayer7SummaryGetResponseMeta] -type radarAttackLayer7SummaryGetResponseMetaJSON struct { - DateRange apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer7SummaryGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer7SummaryGetResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarAttackLayer7SummaryGetResponseMetaDateRange] -type radarAttackLayer7SummaryGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryGetResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer7SummaryGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer7SummaryGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer7SummaryGetResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarAttackLayer7SummaryGetResponseMetaConfidenceInfo] -type radarAttackLayer7SummaryGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer7SummaryGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer7SummaryGetResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer7SummaryGetResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer7SummaryGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryGetResponseSummary0 struct { - AccessRules string `json:"ACCESS_RULES,required"` - APIShield string `json:"API_SHIELD,required"` - BotManagement string `json:"BOT_MANAGEMENT,required"` - DataLossPrevention string `json:"DATA_LOSS_PREVENTION,required"` - DDOS string `json:"DDOS,required"` - IPReputation string `json:"IP_REPUTATION,required"` - WAF string `json:"WAF,required"` - JSON radarAttackLayer7SummaryGetResponseSummary0JSON `json:"-"` -} - -// radarAttackLayer7SummaryGetResponseSummary0JSON contains the JSON metadata for -// the struct [RadarAttackLayer7SummaryGetResponseSummary0] -type radarAttackLayer7SummaryGetResponseSummary0JSON struct { - AccessRules apijson.Field - APIShield apijson.Field - BotManagement apijson.Field - DataLossPrevention apijson.Field - DDOS apijson.Field - IPReputation apijson.Field - WAF apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryGetResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryGetResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryHTTPMethodResponse struct { - Meta RadarAttackLayer7SummaryHTTPMethodResponseMeta `json:"meta,required"` - Summary0 RadarAttackLayer7SummaryHTTPMethodResponseSummary0 `json:"summary_0,required"` - JSON radarAttackLayer7SummaryHTTPMethodResponseJSON `json:"-"` -} - -// radarAttackLayer7SummaryHTTPMethodResponseJSON contains the JSON metadata for -// the struct [RadarAttackLayer7SummaryHTTPMethodResponse] -type radarAttackLayer7SummaryHTTPMethodResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryHTTPMethodResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryHTTPMethodResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryHTTPMethodResponseMeta struct { - DateRange []RadarAttackLayer7SummaryHTTPMethodResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarAttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer7SummaryHTTPMethodResponseMetaJSON `json:"-"` -} - -// radarAttackLayer7SummaryHTTPMethodResponseMetaJSON contains the JSON metadata -// for the struct [RadarAttackLayer7SummaryHTTPMethodResponseMeta] -type radarAttackLayer7SummaryHTTPMethodResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryHTTPMethodResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryHTTPMethodResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryHTTPMethodResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer7SummaryHTTPMethodResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer7SummaryHTTPMethodResponseMetaDateRangeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer7SummaryHTTPMethodResponseMetaDateRange] -type radarAttackLayer7SummaryHTTPMethodResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryHTTPMethodResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryHTTPMethodResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfo] -type radarAttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarAttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryHTTPMethodResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryHTTPMethodResponseSummary0 struct { - Get string `json:"GET,required"` - Post string `json:"POST,required"` - JSON radarAttackLayer7SummaryHTTPMethodResponseSummary0JSON `json:"-"` -} - -// radarAttackLayer7SummaryHTTPMethodResponseSummary0JSON contains the JSON -// metadata for the struct [RadarAttackLayer7SummaryHTTPMethodResponseSummary0] -type radarAttackLayer7SummaryHTTPMethodResponseSummary0JSON struct { - Get apijson.Field - Post apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryHTTPMethodResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryHTTPMethodResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryHTTPVersionResponse struct { - Meta RadarAttackLayer7SummaryHTTPVersionResponseMeta `json:"meta,required"` - Summary0 RadarAttackLayer7SummaryHTTPVersionResponseSummary0 `json:"summary_0,required"` - JSON radarAttackLayer7SummaryHTTPVersionResponseJSON `json:"-"` -} - -// radarAttackLayer7SummaryHTTPVersionResponseJSON contains the JSON metadata for -// the struct [RadarAttackLayer7SummaryHTTPVersionResponse] -type radarAttackLayer7SummaryHTTPVersionResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryHTTPVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryHTTPVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryHTTPVersionResponseMeta struct { - DateRange []RadarAttackLayer7SummaryHTTPVersionResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarAttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer7SummaryHTTPVersionResponseMetaJSON `json:"-"` -} - -// radarAttackLayer7SummaryHTTPVersionResponseMetaJSON contains the JSON metadata -// for the struct [RadarAttackLayer7SummaryHTTPVersionResponseMeta] -type radarAttackLayer7SummaryHTTPVersionResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryHTTPVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryHTTPVersionResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryHTTPVersionResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer7SummaryHTTPVersionResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer7SummaryHTTPVersionResponseMetaDateRangeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer7SummaryHTTPVersionResponseMetaDateRange] -type radarAttackLayer7SummaryHTTPVersionResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryHTTPVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryHTTPVersionResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfo] -type radarAttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarAttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryHTTPVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryHTTPVersionResponseSummary0 struct { - HTTP1X string `json:"HTTP/1.x,required"` - HTTP2 string `json:"HTTP/2,required"` - HTTP3 string `json:"HTTP/3,required"` - JSON radarAttackLayer7SummaryHTTPVersionResponseSummary0JSON `json:"-"` -} - -// radarAttackLayer7SummaryHTTPVersionResponseSummary0JSON contains the JSON -// metadata for the struct [RadarAttackLayer7SummaryHTTPVersionResponseSummary0] -type radarAttackLayer7SummaryHTTPVersionResponseSummary0JSON struct { - HTTP1X apijson.Field - HTTP2 apijson.Field - HTTP3 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryHTTPVersionResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryHTTPVersionResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryIPVersionResponse struct { - Meta RadarAttackLayer7SummaryIPVersionResponseMeta `json:"meta,required"` - Summary0 RadarAttackLayer7SummaryIPVersionResponseSummary0 `json:"summary_0,required"` - JSON radarAttackLayer7SummaryIPVersionResponseJSON `json:"-"` -} - -// radarAttackLayer7SummaryIPVersionResponseJSON contains the JSON metadata for the -// struct [RadarAttackLayer7SummaryIPVersionResponse] -type radarAttackLayer7SummaryIPVersionResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryIPVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryIPVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryIPVersionResponseMeta struct { - DateRange []RadarAttackLayer7SummaryIPVersionResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarAttackLayer7SummaryIPVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer7SummaryIPVersionResponseMetaJSON `json:"-"` -} - -// radarAttackLayer7SummaryIPVersionResponseMetaJSON contains the JSON metadata for -// the struct [RadarAttackLayer7SummaryIPVersionResponseMeta] -type radarAttackLayer7SummaryIPVersionResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryIPVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryIPVersionResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryIPVersionResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer7SummaryIPVersionResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer7SummaryIPVersionResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarAttackLayer7SummaryIPVersionResponseMetaDateRange] -type radarAttackLayer7SummaryIPVersionResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryIPVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryIPVersionResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryIPVersionResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer7SummaryIPVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer7SummaryIPVersionResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer7SummaryIPVersionResponseMetaConfidenceInfoJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer7SummaryIPVersionResponseMetaConfidenceInfo] -type radarAttackLayer7SummaryIPVersionResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryIPVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryIPVersionResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryIPVersionResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer7SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer7SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarAttackLayer7SummaryIPVersionResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer7SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryIPVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryIPVersionResponseSummary0 struct { - IPv4 string `json:"IPv4,required"` - IPv6 string `json:"IPv6,required"` - JSON radarAttackLayer7SummaryIPVersionResponseSummary0JSON `json:"-"` -} - -// radarAttackLayer7SummaryIPVersionResponseSummary0JSON contains the JSON metadata -// for the struct [RadarAttackLayer7SummaryIPVersionResponseSummary0] -type radarAttackLayer7SummaryIPVersionResponseSummary0JSON struct { - IPv4 apijson.Field - IPv6 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryIPVersionResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryIPVersionResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryManagedRulesResponse struct { - Meta RadarAttackLayer7SummaryManagedRulesResponseMeta `json:"meta,required"` - Summary0 RadarAttackLayer7SummaryManagedRulesResponseSummary0 `json:"summary_0,required"` - JSON radarAttackLayer7SummaryManagedRulesResponseJSON `json:"-"` -} - -// radarAttackLayer7SummaryManagedRulesResponseJSON contains the JSON metadata for -// the struct [RadarAttackLayer7SummaryManagedRulesResponse] -type radarAttackLayer7SummaryManagedRulesResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryManagedRulesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryManagedRulesResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryManagedRulesResponseMeta struct { - DateRange []RadarAttackLayer7SummaryManagedRulesResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarAttackLayer7SummaryManagedRulesResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer7SummaryManagedRulesResponseMetaJSON `json:"-"` -} - -// radarAttackLayer7SummaryManagedRulesResponseMetaJSON contains the JSON metadata -// for the struct [RadarAttackLayer7SummaryManagedRulesResponseMeta] -type radarAttackLayer7SummaryManagedRulesResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryManagedRulesResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryManagedRulesResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryManagedRulesResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer7SummaryManagedRulesResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer7SummaryManagedRulesResponseMetaDateRangeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer7SummaryManagedRulesResponseMetaDateRange] -type radarAttackLayer7SummaryManagedRulesResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryManagedRulesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryManagedRulesResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryManagedRulesResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer7SummaryManagedRulesResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer7SummaryManagedRulesResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer7SummaryManagedRulesResponseMetaConfidenceInfoJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer7SummaryManagedRulesResponseMetaConfidenceInfo] -type radarAttackLayer7SummaryManagedRulesResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryManagedRulesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryManagedRulesResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryManagedRulesResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer7SummaryManagedRulesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer7SummaryManagedRulesResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarAttackLayer7SummaryManagedRulesResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer7SummaryManagedRulesResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryManagedRulesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryManagedRulesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryManagedRulesResponseSummary0 struct { - Bot string `json:"Bot,required"` - HTTPAnomaly string `json:"HTTP Anomaly,required"` - JSON radarAttackLayer7SummaryManagedRulesResponseSummary0JSON `json:"-"` -} - -// radarAttackLayer7SummaryManagedRulesResponseSummary0JSON contains the JSON -// metadata for the struct [RadarAttackLayer7SummaryManagedRulesResponseSummary0] -type radarAttackLayer7SummaryManagedRulesResponseSummary0JSON struct { - Bot apijson.Field - HTTPAnomaly apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryManagedRulesResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryManagedRulesResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryMitigationProductResponse struct { - Meta RadarAttackLayer7SummaryMitigationProductResponseMeta `json:"meta,required"` - Summary0 RadarAttackLayer7SummaryMitigationProductResponseSummary0 `json:"summary_0,required"` - JSON radarAttackLayer7SummaryMitigationProductResponseJSON `json:"-"` -} - -// radarAttackLayer7SummaryMitigationProductResponseJSON contains the JSON metadata -// for the struct [RadarAttackLayer7SummaryMitigationProductResponse] -type radarAttackLayer7SummaryMitigationProductResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryMitigationProductResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryMitigationProductResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryMitigationProductResponseMeta struct { - DateRange []RadarAttackLayer7SummaryMitigationProductResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarAttackLayer7SummaryMitigationProductResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer7SummaryMitigationProductResponseMetaJSON `json:"-"` -} - -// radarAttackLayer7SummaryMitigationProductResponseMetaJSON contains the JSON -// metadata for the struct [RadarAttackLayer7SummaryMitigationProductResponseMeta] -type radarAttackLayer7SummaryMitigationProductResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryMitigationProductResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryMitigationProductResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryMitigationProductResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer7SummaryMitigationProductResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer7SummaryMitigationProductResponseMetaDateRangeJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer7SummaryMitigationProductResponseMetaDateRange] -type radarAttackLayer7SummaryMitigationProductResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryMitigationProductResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryMitigationProductResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryMitigationProductResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer7SummaryMitigationProductResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer7SummaryMitigationProductResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer7SummaryMitigationProductResponseMetaConfidenceInfoJSON contains -// the JSON metadata for the struct -// [RadarAttackLayer7SummaryMitigationProductResponseMetaConfidenceInfo] -type radarAttackLayer7SummaryMitigationProductResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryMitigationProductResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryMitigationProductResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryMitigationProductResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer7SummaryMitigationProductResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer7SummaryMitigationProductResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarAttackLayer7SummaryMitigationProductResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer7SummaryMitigationProductResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryMitigationProductResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryMitigationProductResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryMitigationProductResponseSummary0 struct { - DDOS string `json:"DDOS,required"` - WAF string `json:"WAF,required"` - JSON radarAttackLayer7SummaryMitigationProductResponseSummary0JSON `json:"-"` -} - -// radarAttackLayer7SummaryMitigationProductResponseSummary0JSON contains the JSON -// metadata for the struct -// [RadarAttackLayer7SummaryMitigationProductResponseSummary0] -type radarAttackLayer7SummaryMitigationProductResponseSummary0JSON struct { - DDOS apijson.Field - WAF apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryMitigationProductResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryMitigationProductResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7SummaryGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7SummaryGetParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAttackLayer7SummaryGetParams]'s query parameters as -// `url.Values`. -func (r RadarAttackLayer7SummaryGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer7SummaryGetParamsDateRange string - -const ( - RadarAttackLayer7SummaryGetParamsDateRange1d RadarAttackLayer7SummaryGetParamsDateRange = "1d" - RadarAttackLayer7SummaryGetParamsDateRange2d RadarAttackLayer7SummaryGetParamsDateRange = "2d" - RadarAttackLayer7SummaryGetParamsDateRange7d RadarAttackLayer7SummaryGetParamsDateRange = "7d" - RadarAttackLayer7SummaryGetParamsDateRange14d RadarAttackLayer7SummaryGetParamsDateRange = "14d" - RadarAttackLayer7SummaryGetParamsDateRange28d RadarAttackLayer7SummaryGetParamsDateRange = "28d" - RadarAttackLayer7SummaryGetParamsDateRange12w RadarAttackLayer7SummaryGetParamsDateRange = "12w" - RadarAttackLayer7SummaryGetParamsDateRange24w RadarAttackLayer7SummaryGetParamsDateRange = "24w" - RadarAttackLayer7SummaryGetParamsDateRange52w RadarAttackLayer7SummaryGetParamsDateRange = "52w" - RadarAttackLayer7SummaryGetParamsDateRange1dControl RadarAttackLayer7SummaryGetParamsDateRange = "1dControl" - RadarAttackLayer7SummaryGetParamsDateRange2dControl RadarAttackLayer7SummaryGetParamsDateRange = "2dControl" - RadarAttackLayer7SummaryGetParamsDateRange7dControl RadarAttackLayer7SummaryGetParamsDateRange = "7dControl" - RadarAttackLayer7SummaryGetParamsDateRange14dControl RadarAttackLayer7SummaryGetParamsDateRange = "14dControl" - RadarAttackLayer7SummaryGetParamsDateRange28dControl RadarAttackLayer7SummaryGetParamsDateRange = "28dControl" - RadarAttackLayer7SummaryGetParamsDateRange12wControl RadarAttackLayer7SummaryGetParamsDateRange = "12wControl" - RadarAttackLayer7SummaryGetParamsDateRange24wControl RadarAttackLayer7SummaryGetParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7SummaryGetParamsFormat string - -const ( - RadarAttackLayer7SummaryGetParamsFormatJson RadarAttackLayer7SummaryGetParamsFormat = "JSON" - RadarAttackLayer7SummaryGetParamsFormatCsv RadarAttackLayer7SummaryGetParamsFormat = "CSV" -) - -type RadarAttackLayer7SummaryGetResponseEnvelope struct { - Result RadarAttackLayer7SummaryGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7SummaryGetResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7SummaryGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarAttackLayer7SummaryGetResponseEnvelope] -type radarAttackLayer7SummaryGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryHTTPMethodParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7SummaryHTTPMethodParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7SummaryHTTPMethodParamsFormat] `query:"format"` - // Filter for http version. - HTTPVersion param.Field[[]RadarAttackLayer7SummaryHTTPMethodParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer7SummaryHTTPMethodParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of L7 mitigation products. - MitigationProduct param.Field[[]RadarAttackLayer7SummaryHTTPMethodParamsMitigationProduct] `query:"mitigationProduct"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAttackLayer7SummaryHTTPMethodParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer7SummaryHTTPMethodParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer7SummaryHTTPMethodParamsDateRange string - -const ( - RadarAttackLayer7SummaryHTTPMethodParamsDateRange1d RadarAttackLayer7SummaryHTTPMethodParamsDateRange = "1d" - RadarAttackLayer7SummaryHTTPMethodParamsDateRange2d RadarAttackLayer7SummaryHTTPMethodParamsDateRange = "2d" - RadarAttackLayer7SummaryHTTPMethodParamsDateRange7d RadarAttackLayer7SummaryHTTPMethodParamsDateRange = "7d" - RadarAttackLayer7SummaryHTTPMethodParamsDateRange14d RadarAttackLayer7SummaryHTTPMethodParamsDateRange = "14d" - RadarAttackLayer7SummaryHTTPMethodParamsDateRange28d RadarAttackLayer7SummaryHTTPMethodParamsDateRange = "28d" - RadarAttackLayer7SummaryHTTPMethodParamsDateRange12w RadarAttackLayer7SummaryHTTPMethodParamsDateRange = "12w" - RadarAttackLayer7SummaryHTTPMethodParamsDateRange24w RadarAttackLayer7SummaryHTTPMethodParamsDateRange = "24w" - RadarAttackLayer7SummaryHTTPMethodParamsDateRange52w RadarAttackLayer7SummaryHTTPMethodParamsDateRange = "52w" - RadarAttackLayer7SummaryHTTPMethodParamsDateRange1dControl RadarAttackLayer7SummaryHTTPMethodParamsDateRange = "1dControl" - RadarAttackLayer7SummaryHTTPMethodParamsDateRange2dControl RadarAttackLayer7SummaryHTTPMethodParamsDateRange = "2dControl" - RadarAttackLayer7SummaryHTTPMethodParamsDateRange7dControl RadarAttackLayer7SummaryHTTPMethodParamsDateRange = "7dControl" - RadarAttackLayer7SummaryHTTPMethodParamsDateRange14dControl RadarAttackLayer7SummaryHTTPMethodParamsDateRange = "14dControl" - RadarAttackLayer7SummaryHTTPMethodParamsDateRange28dControl RadarAttackLayer7SummaryHTTPMethodParamsDateRange = "28dControl" - RadarAttackLayer7SummaryHTTPMethodParamsDateRange12wControl RadarAttackLayer7SummaryHTTPMethodParamsDateRange = "12wControl" - RadarAttackLayer7SummaryHTTPMethodParamsDateRange24wControl RadarAttackLayer7SummaryHTTPMethodParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7SummaryHTTPMethodParamsFormat string - -const ( - RadarAttackLayer7SummaryHTTPMethodParamsFormatJson RadarAttackLayer7SummaryHTTPMethodParamsFormat = "JSON" - RadarAttackLayer7SummaryHTTPMethodParamsFormatCsv RadarAttackLayer7SummaryHTTPMethodParamsFormat = "CSV" -) - -type RadarAttackLayer7SummaryHTTPMethodParamsHTTPVersion string - -const ( - RadarAttackLayer7SummaryHTTPMethodParamsHTTPVersionHttPv1 RadarAttackLayer7SummaryHTTPMethodParamsHTTPVersion = "HTTPv1" - RadarAttackLayer7SummaryHTTPMethodParamsHTTPVersionHttPv2 RadarAttackLayer7SummaryHTTPMethodParamsHTTPVersion = "HTTPv2" - RadarAttackLayer7SummaryHTTPMethodParamsHTTPVersionHttPv3 RadarAttackLayer7SummaryHTTPMethodParamsHTTPVersion = "HTTPv3" -) - -type RadarAttackLayer7SummaryHTTPMethodParamsIPVersion string - -const ( - RadarAttackLayer7SummaryHTTPMethodParamsIPVersionIPv4 RadarAttackLayer7SummaryHTTPMethodParamsIPVersion = "IPv4" - RadarAttackLayer7SummaryHTTPMethodParamsIPVersionIPv6 RadarAttackLayer7SummaryHTTPMethodParamsIPVersion = "IPv6" -) - -type RadarAttackLayer7SummaryHTTPMethodParamsMitigationProduct string - -const ( - RadarAttackLayer7SummaryHTTPMethodParamsMitigationProductDDOS RadarAttackLayer7SummaryHTTPMethodParamsMitigationProduct = "DDOS" - RadarAttackLayer7SummaryHTTPMethodParamsMitigationProductWAF RadarAttackLayer7SummaryHTTPMethodParamsMitigationProduct = "WAF" - RadarAttackLayer7SummaryHTTPMethodParamsMitigationProductBotManagement RadarAttackLayer7SummaryHTTPMethodParamsMitigationProduct = "BOT_MANAGEMENT" - RadarAttackLayer7SummaryHTTPMethodParamsMitigationProductAccessRules RadarAttackLayer7SummaryHTTPMethodParamsMitigationProduct = "ACCESS_RULES" - RadarAttackLayer7SummaryHTTPMethodParamsMitigationProductIPReputation RadarAttackLayer7SummaryHTTPMethodParamsMitigationProduct = "IP_REPUTATION" - RadarAttackLayer7SummaryHTTPMethodParamsMitigationProductAPIShield RadarAttackLayer7SummaryHTTPMethodParamsMitigationProduct = "API_SHIELD" - RadarAttackLayer7SummaryHTTPMethodParamsMitigationProductDataLossPrevention RadarAttackLayer7SummaryHTTPMethodParamsMitigationProduct = "DATA_LOSS_PREVENTION" -) - -type RadarAttackLayer7SummaryHTTPMethodResponseEnvelope struct { - Result RadarAttackLayer7SummaryHTTPMethodResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7SummaryHTTPMethodResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7SummaryHTTPMethodResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarAttackLayer7SummaryHTTPMethodResponseEnvelope] -type radarAttackLayer7SummaryHTTPMethodResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryHTTPMethodResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryHTTPMethodResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryHTTPVersionParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7SummaryHTTPVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7SummaryHTTPVersionParamsFormat] `query:"format"` - // Filter for http method. - HTTPMethod param.Field[[]RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod] `query:"httpMethod"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer7SummaryHTTPVersionParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of L7 mitigation products. - MitigationProduct param.Field[[]RadarAttackLayer7SummaryHTTPVersionParamsMitigationProduct] `query:"mitigationProduct"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAttackLayer7SummaryHTTPVersionParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer7SummaryHTTPVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer7SummaryHTTPVersionParamsDateRange string - -const ( - RadarAttackLayer7SummaryHTTPVersionParamsDateRange1d RadarAttackLayer7SummaryHTTPVersionParamsDateRange = "1d" - RadarAttackLayer7SummaryHTTPVersionParamsDateRange2d RadarAttackLayer7SummaryHTTPVersionParamsDateRange = "2d" - RadarAttackLayer7SummaryHTTPVersionParamsDateRange7d RadarAttackLayer7SummaryHTTPVersionParamsDateRange = "7d" - RadarAttackLayer7SummaryHTTPVersionParamsDateRange14d RadarAttackLayer7SummaryHTTPVersionParamsDateRange = "14d" - RadarAttackLayer7SummaryHTTPVersionParamsDateRange28d RadarAttackLayer7SummaryHTTPVersionParamsDateRange = "28d" - RadarAttackLayer7SummaryHTTPVersionParamsDateRange12w RadarAttackLayer7SummaryHTTPVersionParamsDateRange = "12w" - RadarAttackLayer7SummaryHTTPVersionParamsDateRange24w RadarAttackLayer7SummaryHTTPVersionParamsDateRange = "24w" - RadarAttackLayer7SummaryHTTPVersionParamsDateRange52w RadarAttackLayer7SummaryHTTPVersionParamsDateRange = "52w" - RadarAttackLayer7SummaryHTTPVersionParamsDateRange1dControl RadarAttackLayer7SummaryHTTPVersionParamsDateRange = "1dControl" - RadarAttackLayer7SummaryHTTPVersionParamsDateRange2dControl RadarAttackLayer7SummaryHTTPVersionParamsDateRange = "2dControl" - RadarAttackLayer7SummaryHTTPVersionParamsDateRange7dControl RadarAttackLayer7SummaryHTTPVersionParamsDateRange = "7dControl" - RadarAttackLayer7SummaryHTTPVersionParamsDateRange14dControl RadarAttackLayer7SummaryHTTPVersionParamsDateRange = "14dControl" - RadarAttackLayer7SummaryHTTPVersionParamsDateRange28dControl RadarAttackLayer7SummaryHTTPVersionParamsDateRange = "28dControl" - RadarAttackLayer7SummaryHTTPVersionParamsDateRange12wControl RadarAttackLayer7SummaryHTTPVersionParamsDateRange = "12wControl" - RadarAttackLayer7SummaryHTTPVersionParamsDateRange24wControl RadarAttackLayer7SummaryHTTPVersionParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7SummaryHTTPVersionParamsFormat string - -const ( - RadarAttackLayer7SummaryHTTPVersionParamsFormatJson RadarAttackLayer7SummaryHTTPVersionParamsFormat = "JSON" - RadarAttackLayer7SummaryHTTPVersionParamsFormatCsv RadarAttackLayer7SummaryHTTPVersionParamsFormat = "CSV" -) - -type RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod string - -const ( - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodGet RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "GET" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodPost RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "POST" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodDelete RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "DELETE" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodPut RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "PUT" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodHead RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "HEAD" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodPurge RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "PURGE" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodOptions RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "OPTIONS" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodPropfind RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "PROPFIND" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodMkcol RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "MKCOL" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodPatch RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "PATCH" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodACL RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "ACL" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodBcopy RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "BCOPY" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodBdelete RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "BDELETE" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodBmove RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "BMOVE" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodBpropfind RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "BPROPFIND" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodBproppatch RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "BPROPPATCH" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodCheckin RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "CHECKIN" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodCheckout RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "CHECKOUT" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodConnect RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "CONNECT" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodCopy RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "COPY" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodLabel RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "LABEL" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodLock RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "LOCK" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodMerge RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "MERGE" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodMkactivity RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "MKACTIVITY" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodMkworkspace RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "MKWORKSPACE" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodMove RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "MOVE" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodNotify RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "NOTIFY" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodOrderpatch RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "ORDERPATCH" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodPoll RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "POLL" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodProppatch RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "PROPPATCH" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodReport RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "REPORT" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodSearch RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "SEARCH" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodSubscribe RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "SUBSCRIBE" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodTrace RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "TRACE" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodUncheckout RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "UNCHECKOUT" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodUnlock RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "UNLOCK" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodUnsubscribe RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "UNSUBSCRIBE" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodUpdate RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "UPDATE" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodVersioncontrol RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "VERSIONCONTROL" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodBaselinecontrol RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "BASELINECONTROL" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodXmsenumatts RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "XMSENUMATTS" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodRpcOutData RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "RPC_OUT_DATA" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodRpcInData RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "RPC_IN_DATA" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodJson RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "JSON" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodCook RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "COOK" - RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodTrack RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod = "TRACK" -) - -type RadarAttackLayer7SummaryHTTPVersionParamsIPVersion string - -const ( - RadarAttackLayer7SummaryHTTPVersionParamsIPVersionIPv4 RadarAttackLayer7SummaryHTTPVersionParamsIPVersion = "IPv4" - RadarAttackLayer7SummaryHTTPVersionParamsIPVersionIPv6 RadarAttackLayer7SummaryHTTPVersionParamsIPVersion = "IPv6" -) - -type RadarAttackLayer7SummaryHTTPVersionParamsMitigationProduct string - -const ( - RadarAttackLayer7SummaryHTTPVersionParamsMitigationProductDDOS RadarAttackLayer7SummaryHTTPVersionParamsMitigationProduct = "DDOS" - RadarAttackLayer7SummaryHTTPVersionParamsMitigationProductWAF RadarAttackLayer7SummaryHTTPVersionParamsMitigationProduct = "WAF" - RadarAttackLayer7SummaryHTTPVersionParamsMitigationProductBotManagement RadarAttackLayer7SummaryHTTPVersionParamsMitigationProduct = "BOT_MANAGEMENT" - RadarAttackLayer7SummaryHTTPVersionParamsMitigationProductAccessRules RadarAttackLayer7SummaryHTTPVersionParamsMitigationProduct = "ACCESS_RULES" - RadarAttackLayer7SummaryHTTPVersionParamsMitigationProductIPReputation RadarAttackLayer7SummaryHTTPVersionParamsMitigationProduct = "IP_REPUTATION" - RadarAttackLayer7SummaryHTTPVersionParamsMitigationProductAPIShield RadarAttackLayer7SummaryHTTPVersionParamsMitigationProduct = "API_SHIELD" - RadarAttackLayer7SummaryHTTPVersionParamsMitigationProductDataLossPrevention RadarAttackLayer7SummaryHTTPVersionParamsMitigationProduct = "DATA_LOSS_PREVENTION" -) - -type RadarAttackLayer7SummaryHTTPVersionResponseEnvelope struct { - Result RadarAttackLayer7SummaryHTTPVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7SummaryHTTPVersionResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7SummaryHTTPVersionResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarAttackLayer7SummaryHTTPVersionResponseEnvelope] -type radarAttackLayer7SummaryHTTPVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryHTTPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryHTTPVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryIPVersionParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7SummaryIPVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7SummaryIPVersionParamsFormat] `query:"format"` - // Filter for http method. - HTTPMethod param.Field[[]RadarAttackLayer7SummaryIPVersionParamsHTTPMethod] `query:"httpMethod"` - // Filter for http version. - HTTPVersion param.Field[[]RadarAttackLayer7SummaryIPVersionParamsHTTPVersion] `query:"httpVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of L7 mitigation products. - MitigationProduct param.Field[[]RadarAttackLayer7SummaryIPVersionParamsMitigationProduct] `query:"mitigationProduct"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAttackLayer7SummaryIPVersionParams]'s query parameters -// as `url.Values`. -func (r RadarAttackLayer7SummaryIPVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer7SummaryIPVersionParamsDateRange string - -const ( - RadarAttackLayer7SummaryIPVersionParamsDateRange1d RadarAttackLayer7SummaryIPVersionParamsDateRange = "1d" - RadarAttackLayer7SummaryIPVersionParamsDateRange2d RadarAttackLayer7SummaryIPVersionParamsDateRange = "2d" - RadarAttackLayer7SummaryIPVersionParamsDateRange7d RadarAttackLayer7SummaryIPVersionParamsDateRange = "7d" - RadarAttackLayer7SummaryIPVersionParamsDateRange14d RadarAttackLayer7SummaryIPVersionParamsDateRange = "14d" - RadarAttackLayer7SummaryIPVersionParamsDateRange28d RadarAttackLayer7SummaryIPVersionParamsDateRange = "28d" - RadarAttackLayer7SummaryIPVersionParamsDateRange12w RadarAttackLayer7SummaryIPVersionParamsDateRange = "12w" - RadarAttackLayer7SummaryIPVersionParamsDateRange24w RadarAttackLayer7SummaryIPVersionParamsDateRange = "24w" - RadarAttackLayer7SummaryIPVersionParamsDateRange52w RadarAttackLayer7SummaryIPVersionParamsDateRange = "52w" - RadarAttackLayer7SummaryIPVersionParamsDateRange1dControl RadarAttackLayer7SummaryIPVersionParamsDateRange = "1dControl" - RadarAttackLayer7SummaryIPVersionParamsDateRange2dControl RadarAttackLayer7SummaryIPVersionParamsDateRange = "2dControl" - RadarAttackLayer7SummaryIPVersionParamsDateRange7dControl RadarAttackLayer7SummaryIPVersionParamsDateRange = "7dControl" - RadarAttackLayer7SummaryIPVersionParamsDateRange14dControl RadarAttackLayer7SummaryIPVersionParamsDateRange = "14dControl" - RadarAttackLayer7SummaryIPVersionParamsDateRange28dControl RadarAttackLayer7SummaryIPVersionParamsDateRange = "28dControl" - RadarAttackLayer7SummaryIPVersionParamsDateRange12wControl RadarAttackLayer7SummaryIPVersionParamsDateRange = "12wControl" - RadarAttackLayer7SummaryIPVersionParamsDateRange24wControl RadarAttackLayer7SummaryIPVersionParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7SummaryIPVersionParamsFormat string - -const ( - RadarAttackLayer7SummaryIPVersionParamsFormatJson RadarAttackLayer7SummaryIPVersionParamsFormat = "JSON" - RadarAttackLayer7SummaryIPVersionParamsFormatCsv RadarAttackLayer7SummaryIPVersionParamsFormat = "CSV" -) - -type RadarAttackLayer7SummaryIPVersionParamsHTTPMethod string - -const ( - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodGet RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "GET" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodPost RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "POST" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodDelete RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "DELETE" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodPut RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "PUT" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodHead RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "HEAD" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodPurge RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "PURGE" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodOptions RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "OPTIONS" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodPropfind RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "PROPFIND" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodMkcol RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "MKCOL" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodPatch RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "PATCH" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodACL RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "ACL" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodBcopy RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "BCOPY" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodBdelete RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "BDELETE" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodBmove RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "BMOVE" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodBpropfind RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "BPROPFIND" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodBproppatch RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "BPROPPATCH" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodCheckin RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "CHECKIN" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodCheckout RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "CHECKOUT" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodConnect RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "CONNECT" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodCopy RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "COPY" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodLabel RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "LABEL" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodLock RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "LOCK" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodMerge RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "MERGE" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodMkactivity RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "MKACTIVITY" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodMkworkspace RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "MKWORKSPACE" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodMove RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "MOVE" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodNotify RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "NOTIFY" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodOrderpatch RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "ORDERPATCH" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodPoll RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "POLL" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodProppatch RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "PROPPATCH" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodReport RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "REPORT" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodSearch RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "SEARCH" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodSubscribe RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "SUBSCRIBE" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodTrace RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "TRACE" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodUncheckout RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "UNCHECKOUT" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodUnlock RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "UNLOCK" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodUnsubscribe RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "UNSUBSCRIBE" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodUpdate RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "UPDATE" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodVersioncontrol RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "VERSIONCONTROL" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodBaselinecontrol RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "BASELINECONTROL" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodXmsenumatts RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "XMSENUMATTS" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodRpcOutData RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "RPC_OUT_DATA" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodRpcInData RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "RPC_IN_DATA" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodJson RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "JSON" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodCook RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "COOK" - RadarAttackLayer7SummaryIPVersionParamsHTTPMethodTrack RadarAttackLayer7SummaryIPVersionParamsHTTPMethod = "TRACK" -) - -type RadarAttackLayer7SummaryIPVersionParamsHTTPVersion string - -const ( - RadarAttackLayer7SummaryIPVersionParamsHTTPVersionHttPv1 RadarAttackLayer7SummaryIPVersionParamsHTTPVersion = "HTTPv1" - RadarAttackLayer7SummaryIPVersionParamsHTTPVersionHttPv2 RadarAttackLayer7SummaryIPVersionParamsHTTPVersion = "HTTPv2" - RadarAttackLayer7SummaryIPVersionParamsHTTPVersionHttPv3 RadarAttackLayer7SummaryIPVersionParamsHTTPVersion = "HTTPv3" -) - -type RadarAttackLayer7SummaryIPVersionParamsMitigationProduct string - -const ( - RadarAttackLayer7SummaryIPVersionParamsMitigationProductDDOS RadarAttackLayer7SummaryIPVersionParamsMitigationProduct = "DDOS" - RadarAttackLayer7SummaryIPVersionParamsMitigationProductWAF RadarAttackLayer7SummaryIPVersionParamsMitigationProduct = "WAF" - RadarAttackLayer7SummaryIPVersionParamsMitigationProductBotManagement RadarAttackLayer7SummaryIPVersionParamsMitigationProduct = "BOT_MANAGEMENT" - RadarAttackLayer7SummaryIPVersionParamsMitigationProductAccessRules RadarAttackLayer7SummaryIPVersionParamsMitigationProduct = "ACCESS_RULES" - RadarAttackLayer7SummaryIPVersionParamsMitigationProductIPReputation RadarAttackLayer7SummaryIPVersionParamsMitigationProduct = "IP_REPUTATION" - RadarAttackLayer7SummaryIPVersionParamsMitigationProductAPIShield RadarAttackLayer7SummaryIPVersionParamsMitigationProduct = "API_SHIELD" - RadarAttackLayer7SummaryIPVersionParamsMitigationProductDataLossPrevention RadarAttackLayer7SummaryIPVersionParamsMitigationProduct = "DATA_LOSS_PREVENTION" -) - -type RadarAttackLayer7SummaryIPVersionResponseEnvelope struct { - Result RadarAttackLayer7SummaryIPVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7SummaryIPVersionResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7SummaryIPVersionResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarAttackLayer7SummaryIPVersionResponseEnvelope] -type radarAttackLayer7SummaryIPVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryIPVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryManagedRulesParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7SummaryManagedRulesParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7SummaryManagedRulesParamsFormat] `query:"format"` - // Filter for http method. - HTTPMethod param.Field[[]RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod] `query:"httpMethod"` - // Filter for http version. - HTTPVersion param.Field[[]RadarAttackLayer7SummaryManagedRulesParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer7SummaryManagedRulesParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of L7 mitigation products. - MitigationProduct param.Field[[]RadarAttackLayer7SummaryManagedRulesParamsMitigationProduct] `query:"mitigationProduct"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAttackLayer7SummaryManagedRulesParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer7SummaryManagedRulesParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer7SummaryManagedRulesParamsDateRange string - -const ( - RadarAttackLayer7SummaryManagedRulesParamsDateRange1d RadarAttackLayer7SummaryManagedRulesParamsDateRange = "1d" - RadarAttackLayer7SummaryManagedRulesParamsDateRange2d RadarAttackLayer7SummaryManagedRulesParamsDateRange = "2d" - RadarAttackLayer7SummaryManagedRulesParamsDateRange7d RadarAttackLayer7SummaryManagedRulesParamsDateRange = "7d" - RadarAttackLayer7SummaryManagedRulesParamsDateRange14d RadarAttackLayer7SummaryManagedRulesParamsDateRange = "14d" - RadarAttackLayer7SummaryManagedRulesParamsDateRange28d RadarAttackLayer7SummaryManagedRulesParamsDateRange = "28d" - RadarAttackLayer7SummaryManagedRulesParamsDateRange12w RadarAttackLayer7SummaryManagedRulesParamsDateRange = "12w" - RadarAttackLayer7SummaryManagedRulesParamsDateRange24w RadarAttackLayer7SummaryManagedRulesParamsDateRange = "24w" - RadarAttackLayer7SummaryManagedRulesParamsDateRange52w RadarAttackLayer7SummaryManagedRulesParamsDateRange = "52w" - RadarAttackLayer7SummaryManagedRulesParamsDateRange1dControl RadarAttackLayer7SummaryManagedRulesParamsDateRange = "1dControl" - RadarAttackLayer7SummaryManagedRulesParamsDateRange2dControl RadarAttackLayer7SummaryManagedRulesParamsDateRange = "2dControl" - RadarAttackLayer7SummaryManagedRulesParamsDateRange7dControl RadarAttackLayer7SummaryManagedRulesParamsDateRange = "7dControl" - RadarAttackLayer7SummaryManagedRulesParamsDateRange14dControl RadarAttackLayer7SummaryManagedRulesParamsDateRange = "14dControl" - RadarAttackLayer7SummaryManagedRulesParamsDateRange28dControl RadarAttackLayer7SummaryManagedRulesParamsDateRange = "28dControl" - RadarAttackLayer7SummaryManagedRulesParamsDateRange12wControl RadarAttackLayer7SummaryManagedRulesParamsDateRange = "12wControl" - RadarAttackLayer7SummaryManagedRulesParamsDateRange24wControl RadarAttackLayer7SummaryManagedRulesParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7SummaryManagedRulesParamsFormat string - -const ( - RadarAttackLayer7SummaryManagedRulesParamsFormatJson RadarAttackLayer7SummaryManagedRulesParamsFormat = "JSON" - RadarAttackLayer7SummaryManagedRulesParamsFormatCsv RadarAttackLayer7SummaryManagedRulesParamsFormat = "CSV" -) - -type RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod string - -const ( - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodGet RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "GET" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodPost RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "POST" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodDelete RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "DELETE" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodPut RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "PUT" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodHead RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "HEAD" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodPurge RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "PURGE" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodOptions RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "OPTIONS" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodPropfind RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "PROPFIND" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodMkcol RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "MKCOL" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodPatch RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "PATCH" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodACL RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "ACL" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodBcopy RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "BCOPY" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodBdelete RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "BDELETE" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodBmove RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "BMOVE" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodBpropfind RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "BPROPFIND" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodBproppatch RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "BPROPPATCH" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodCheckin RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "CHECKIN" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodCheckout RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "CHECKOUT" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodConnect RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "CONNECT" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodCopy RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "COPY" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodLabel RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "LABEL" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodLock RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "LOCK" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodMerge RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "MERGE" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodMkactivity RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "MKACTIVITY" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodMkworkspace RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "MKWORKSPACE" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodMove RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "MOVE" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodNotify RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "NOTIFY" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodOrderpatch RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "ORDERPATCH" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodPoll RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "POLL" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodProppatch RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "PROPPATCH" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodReport RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "REPORT" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodSearch RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "SEARCH" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodSubscribe RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "SUBSCRIBE" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodTrace RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "TRACE" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodUncheckout RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "UNCHECKOUT" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodUnlock RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "UNLOCK" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodUnsubscribe RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "UNSUBSCRIBE" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodUpdate RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "UPDATE" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodVersioncontrol RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "VERSIONCONTROL" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodBaselinecontrol RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "BASELINECONTROL" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodXmsenumatts RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "XMSENUMATTS" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodRpcOutData RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "RPC_OUT_DATA" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodRpcInData RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "RPC_IN_DATA" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodJson RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "JSON" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodCook RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "COOK" - RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodTrack RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod = "TRACK" -) - -type RadarAttackLayer7SummaryManagedRulesParamsHTTPVersion string - -const ( - RadarAttackLayer7SummaryManagedRulesParamsHTTPVersionHttPv1 RadarAttackLayer7SummaryManagedRulesParamsHTTPVersion = "HTTPv1" - RadarAttackLayer7SummaryManagedRulesParamsHTTPVersionHttPv2 RadarAttackLayer7SummaryManagedRulesParamsHTTPVersion = "HTTPv2" - RadarAttackLayer7SummaryManagedRulesParamsHTTPVersionHttPv3 RadarAttackLayer7SummaryManagedRulesParamsHTTPVersion = "HTTPv3" -) - -type RadarAttackLayer7SummaryManagedRulesParamsIPVersion string - -const ( - RadarAttackLayer7SummaryManagedRulesParamsIPVersionIPv4 RadarAttackLayer7SummaryManagedRulesParamsIPVersion = "IPv4" - RadarAttackLayer7SummaryManagedRulesParamsIPVersionIPv6 RadarAttackLayer7SummaryManagedRulesParamsIPVersion = "IPv6" -) - -type RadarAttackLayer7SummaryManagedRulesParamsMitigationProduct string - -const ( - RadarAttackLayer7SummaryManagedRulesParamsMitigationProductDDOS RadarAttackLayer7SummaryManagedRulesParamsMitigationProduct = "DDOS" - RadarAttackLayer7SummaryManagedRulesParamsMitigationProductWAF RadarAttackLayer7SummaryManagedRulesParamsMitigationProduct = "WAF" - RadarAttackLayer7SummaryManagedRulesParamsMitigationProductBotManagement RadarAttackLayer7SummaryManagedRulesParamsMitigationProduct = "BOT_MANAGEMENT" - RadarAttackLayer7SummaryManagedRulesParamsMitigationProductAccessRules RadarAttackLayer7SummaryManagedRulesParamsMitigationProduct = "ACCESS_RULES" - RadarAttackLayer7SummaryManagedRulesParamsMitigationProductIPReputation RadarAttackLayer7SummaryManagedRulesParamsMitigationProduct = "IP_REPUTATION" - RadarAttackLayer7SummaryManagedRulesParamsMitigationProductAPIShield RadarAttackLayer7SummaryManagedRulesParamsMitigationProduct = "API_SHIELD" - RadarAttackLayer7SummaryManagedRulesParamsMitigationProductDataLossPrevention RadarAttackLayer7SummaryManagedRulesParamsMitigationProduct = "DATA_LOSS_PREVENTION" -) - -type RadarAttackLayer7SummaryManagedRulesResponseEnvelope struct { - Result RadarAttackLayer7SummaryManagedRulesResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7SummaryManagedRulesResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7SummaryManagedRulesResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarAttackLayer7SummaryManagedRulesResponseEnvelope] -type radarAttackLayer7SummaryManagedRulesResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryManagedRulesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryManagedRulesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7SummaryMitigationProductParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7SummaryMitigationProductParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7SummaryMitigationProductParamsFormat] `query:"format"` - // Filter for http method. - HTTPMethod param.Field[[]RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod] `query:"httpMethod"` - // Filter for http version. - HTTPVersion param.Field[[]RadarAttackLayer7SummaryMitigationProductParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer7SummaryMitigationProductParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAttackLayer7SummaryMitigationProductParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer7SummaryMitigationProductParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer7SummaryMitigationProductParamsDateRange string - -const ( - RadarAttackLayer7SummaryMitigationProductParamsDateRange1d RadarAttackLayer7SummaryMitigationProductParamsDateRange = "1d" - RadarAttackLayer7SummaryMitigationProductParamsDateRange2d RadarAttackLayer7SummaryMitigationProductParamsDateRange = "2d" - RadarAttackLayer7SummaryMitigationProductParamsDateRange7d RadarAttackLayer7SummaryMitigationProductParamsDateRange = "7d" - RadarAttackLayer7SummaryMitigationProductParamsDateRange14d RadarAttackLayer7SummaryMitigationProductParamsDateRange = "14d" - RadarAttackLayer7SummaryMitigationProductParamsDateRange28d RadarAttackLayer7SummaryMitigationProductParamsDateRange = "28d" - RadarAttackLayer7SummaryMitigationProductParamsDateRange12w RadarAttackLayer7SummaryMitigationProductParamsDateRange = "12w" - RadarAttackLayer7SummaryMitigationProductParamsDateRange24w RadarAttackLayer7SummaryMitigationProductParamsDateRange = "24w" - RadarAttackLayer7SummaryMitigationProductParamsDateRange52w RadarAttackLayer7SummaryMitigationProductParamsDateRange = "52w" - RadarAttackLayer7SummaryMitigationProductParamsDateRange1dControl RadarAttackLayer7SummaryMitigationProductParamsDateRange = "1dControl" - RadarAttackLayer7SummaryMitigationProductParamsDateRange2dControl RadarAttackLayer7SummaryMitigationProductParamsDateRange = "2dControl" - RadarAttackLayer7SummaryMitigationProductParamsDateRange7dControl RadarAttackLayer7SummaryMitigationProductParamsDateRange = "7dControl" - RadarAttackLayer7SummaryMitigationProductParamsDateRange14dControl RadarAttackLayer7SummaryMitigationProductParamsDateRange = "14dControl" - RadarAttackLayer7SummaryMitigationProductParamsDateRange28dControl RadarAttackLayer7SummaryMitigationProductParamsDateRange = "28dControl" - RadarAttackLayer7SummaryMitigationProductParamsDateRange12wControl RadarAttackLayer7SummaryMitigationProductParamsDateRange = "12wControl" - RadarAttackLayer7SummaryMitigationProductParamsDateRange24wControl RadarAttackLayer7SummaryMitigationProductParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7SummaryMitigationProductParamsFormat string - -const ( - RadarAttackLayer7SummaryMitigationProductParamsFormatJson RadarAttackLayer7SummaryMitigationProductParamsFormat = "JSON" - RadarAttackLayer7SummaryMitigationProductParamsFormatCsv RadarAttackLayer7SummaryMitigationProductParamsFormat = "CSV" -) - -type RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod string - -const ( - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodGet RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "GET" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodPost RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "POST" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodDelete RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "DELETE" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodPut RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "PUT" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodHead RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "HEAD" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodPurge RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "PURGE" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodOptions RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "OPTIONS" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodPropfind RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "PROPFIND" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodMkcol RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "MKCOL" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodPatch RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "PATCH" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodACL RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "ACL" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodBcopy RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "BCOPY" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodBdelete RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "BDELETE" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodBmove RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "BMOVE" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodBpropfind RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "BPROPFIND" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodBproppatch RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "BPROPPATCH" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodCheckin RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "CHECKIN" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodCheckout RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "CHECKOUT" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodConnect RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "CONNECT" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodCopy RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "COPY" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodLabel RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "LABEL" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodLock RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "LOCK" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodMerge RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "MERGE" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodMkactivity RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "MKACTIVITY" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodMkworkspace RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "MKWORKSPACE" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodMove RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "MOVE" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodNotify RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "NOTIFY" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodOrderpatch RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "ORDERPATCH" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodPoll RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "POLL" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodProppatch RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "PROPPATCH" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodReport RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "REPORT" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodSearch RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "SEARCH" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodSubscribe RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "SUBSCRIBE" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodTrace RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "TRACE" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodUncheckout RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "UNCHECKOUT" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodUnlock RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "UNLOCK" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodUnsubscribe RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "UNSUBSCRIBE" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodUpdate RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "UPDATE" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodVersioncontrol RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "VERSIONCONTROL" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodBaselinecontrol RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "BASELINECONTROL" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodXmsenumatts RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "XMSENUMATTS" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodRpcOutData RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "RPC_OUT_DATA" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodRpcInData RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "RPC_IN_DATA" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodJson RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "JSON" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodCook RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "COOK" - RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodTrack RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod = "TRACK" -) - -type RadarAttackLayer7SummaryMitigationProductParamsHTTPVersion string - -const ( - RadarAttackLayer7SummaryMitigationProductParamsHTTPVersionHttPv1 RadarAttackLayer7SummaryMitigationProductParamsHTTPVersion = "HTTPv1" - RadarAttackLayer7SummaryMitigationProductParamsHTTPVersionHttPv2 RadarAttackLayer7SummaryMitigationProductParamsHTTPVersion = "HTTPv2" - RadarAttackLayer7SummaryMitigationProductParamsHTTPVersionHttPv3 RadarAttackLayer7SummaryMitigationProductParamsHTTPVersion = "HTTPv3" -) - -type RadarAttackLayer7SummaryMitigationProductParamsIPVersion string - -const ( - RadarAttackLayer7SummaryMitigationProductParamsIPVersionIPv4 RadarAttackLayer7SummaryMitigationProductParamsIPVersion = "IPv4" - RadarAttackLayer7SummaryMitigationProductParamsIPVersionIPv6 RadarAttackLayer7SummaryMitigationProductParamsIPVersion = "IPv6" -) - -type RadarAttackLayer7SummaryMitigationProductResponseEnvelope struct { - Result RadarAttackLayer7SummaryMitigationProductResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7SummaryMitigationProductResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7SummaryMitigationProductResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer7SummaryMitigationProductResponseEnvelope] -type radarAttackLayer7SummaryMitigationProductResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7SummaryMitigationProductResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7SummaryMitigationProductResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarattacklayer7summary_test.go b/radarattacklayer7summary_test.go deleted file mode 100644 index c707c64fbf7..00000000000 --- a/radarattacklayer7summary_test.go +++ /dev/null @@ -1,229 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarAttackLayer7SummaryGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.Summary.Get(context.TODO(), cloudflare.RadarAttackLayer7SummaryGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryGetParamsDateRange{cloudflare.RadarAttackLayer7SummaryGetParamsDateRange1d, cloudflare.RadarAttackLayer7SummaryGetParamsDateRange2d, cloudflare.RadarAttackLayer7SummaryGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7SummaryGetParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAttackLayer7SummaryHTTPMethodWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.Summary.HTTPMethod(context.TODO(), cloudflare.RadarAttackLayer7SummaryHTTPMethodParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryHTTPMethodParamsDateRange{cloudflare.RadarAttackLayer7SummaryHTTPMethodParamsDateRange1d, cloudflare.RadarAttackLayer7SummaryHTTPMethodParamsDateRange2d, cloudflare.RadarAttackLayer7SummaryHTTPMethodParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7SummaryHTTPMethodParamsFormatJson), - HTTPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryHTTPMethodParamsHTTPVersion{cloudflare.RadarAttackLayer7SummaryHTTPMethodParamsHTTPVersionHttPv1, cloudflare.RadarAttackLayer7SummaryHTTPMethodParamsHTTPVersionHttPv2, cloudflare.RadarAttackLayer7SummaryHTTPMethodParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryHTTPMethodParamsIPVersion{cloudflare.RadarAttackLayer7SummaryHTTPMethodParamsIPVersionIPv4, cloudflare.RadarAttackLayer7SummaryHTTPMethodParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - MitigationProduct: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryHTTPMethodParamsMitigationProduct{cloudflare.RadarAttackLayer7SummaryHTTPMethodParamsMitigationProductDDOS, cloudflare.RadarAttackLayer7SummaryHTTPMethodParamsMitigationProductWAF, cloudflare.RadarAttackLayer7SummaryHTTPMethodParamsMitigationProductBotManagement}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAttackLayer7SummaryHTTPVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.Summary.HTTPVersion(context.TODO(), cloudflare.RadarAttackLayer7SummaryHTTPVersionParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryHTTPVersionParamsDateRange{cloudflare.RadarAttackLayer7SummaryHTTPVersionParamsDateRange1d, cloudflare.RadarAttackLayer7SummaryHTTPVersionParamsDateRange2d, cloudflare.RadarAttackLayer7SummaryHTTPVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7SummaryHTTPVersionParamsFormatJson), - HTTPMethod: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethod{cloudflare.RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodGet, cloudflare.RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodPost, cloudflare.RadarAttackLayer7SummaryHTTPVersionParamsHTTPMethodDelete}), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryHTTPVersionParamsIPVersion{cloudflare.RadarAttackLayer7SummaryHTTPVersionParamsIPVersionIPv4, cloudflare.RadarAttackLayer7SummaryHTTPVersionParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - MitigationProduct: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryHTTPVersionParamsMitigationProduct{cloudflare.RadarAttackLayer7SummaryHTTPVersionParamsMitigationProductDDOS, cloudflare.RadarAttackLayer7SummaryHTTPVersionParamsMitigationProductWAF, cloudflare.RadarAttackLayer7SummaryHTTPVersionParamsMitigationProductBotManagement}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAttackLayer7SummaryIPVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.Summary.IPVersion(context.TODO(), cloudflare.RadarAttackLayer7SummaryIPVersionParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryIPVersionParamsDateRange{cloudflare.RadarAttackLayer7SummaryIPVersionParamsDateRange1d, cloudflare.RadarAttackLayer7SummaryIPVersionParamsDateRange2d, cloudflare.RadarAttackLayer7SummaryIPVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7SummaryIPVersionParamsFormatJson), - HTTPMethod: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryIPVersionParamsHTTPMethod{cloudflare.RadarAttackLayer7SummaryIPVersionParamsHTTPMethodGet, cloudflare.RadarAttackLayer7SummaryIPVersionParamsHTTPMethodPost, cloudflare.RadarAttackLayer7SummaryIPVersionParamsHTTPMethodDelete}), - HTTPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryIPVersionParamsHTTPVersion{cloudflare.RadarAttackLayer7SummaryIPVersionParamsHTTPVersionHttPv1, cloudflare.RadarAttackLayer7SummaryIPVersionParamsHTTPVersionHttPv2, cloudflare.RadarAttackLayer7SummaryIPVersionParamsHTTPVersionHttPv3}), - Location: cloudflare.F([]string{"string", "string", "string"}), - MitigationProduct: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryIPVersionParamsMitigationProduct{cloudflare.RadarAttackLayer7SummaryIPVersionParamsMitigationProductDDOS, cloudflare.RadarAttackLayer7SummaryIPVersionParamsMitigationProductWAF, cloudflare.RadarAttackLayer7SummaryIPVersionParamsMitigationProductBotManagement}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAttackLayer7SummaryManagedRulesWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.Summary.ManagedRules(context.TODO(), cloudflare.RadarAttackLayer7SummaryManagedRulesParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryManagedRulesParamsDateRange{cloudflare.RadarAttackLayer7SummaryManagedRulesParamsDateRange1d, cloudflare.RadarAttackLayer7SummaryManagedRulesParamsDateRange2d, cloudflare.RadarAttackLayer7SummaryManagedRulesParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7SummaryManagedRulesParamsFormatJson), - HTTPMethod: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryManagedRulesParamsHTTPMethod{cloudflare.RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodGet, cloudflare.RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodPost, cloudflare.RadarAttackLayer7SummaryManagedRulesParamsHTTPMethodDelete}), - HTTPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryManagedRulesParamsHTTPVersion{cloudflare.RadarAttackLayer7SummaryManagedRulesParamsHTTPVersionHttPv1, cloudflare.RadarAttackLayer7SummaryManagedRulesParamsHTTPVersionHttPv2, cloudflare.RadarAttackLayer7SummaryManagedRulesParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryManagedRulesParamsIPVersion{cloudflare.RadarAttackLayer7SummaryManagedRulesParamsIPVersionIPv4, cloudflare.RadarAttackLayer7SummaryManagedRulesParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - MitigationProduct: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryManagedRulesParamsMitigationProduct{cloudflare.RadarAttackLayer7SummaryManagedRulesParamsMitigationProductDDOS, cloudflare.RadarAttackLayer7SummaryManagedRulesParamsMitigationProductWAF, cloudflare.RadarAttackLayer7SummaryManagedRulesParamsMitigationProductBotManagement}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAttackLayer7SummaryMitigationProductWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.Summary.MitigationProduct(context.TODO(), cloudflare.RadarAttackLayer7SummaryMitigationProductParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryMitigationProductParamsDateRange{cloudflare.RadarAttackLayer7SummaryMitigationProductParamsDateRange1d, cloudflare.RadarAttackLayer7SummaryMitigationProductParamsDateRange2d, cloudflare.RadarAttackLayer7SummaryMitigationProductParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7SummaryMitigationProductParamsFormatJson), - HTTPMethod: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryMitigationProductParamsHTTPMethod{cloudflare.RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodGet, cloudflare.RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodPost, cloudflare.RadarAttackLayer7SummaryMitigationProductParamsHTTPMethodDelete}), - HTTPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryMitigationProductParamsHTTPVersion{cloudflare.RadarAttackLayer7SummaryMitigationProductParamsHTTPVersionHttPv1, cloudflare.RadarAttackLayer7SummaryMitigationProductParamsHTTPVersionHttPv2, cloudflare.RadarAttackLayer7SummaryMitigationProductParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7SummaryMitigationProductParamsIPVersion{cloudflare.RadarAttackLayer7SummaryMitigationProductParamsIPVersionIPv4, cloudflare.RadarAttackLayer7SummaryMitigationProductParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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/radarattacklayer7timeseriesgroup.go b/radarattacklayer7timeseriesgroup.go deleted file mode 100644 index aac54d360ae..00000000000 --- a/radarattacklayer7timeseriesgroup.go +++ /dev/null @@ -1,2073 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarAttackLayer7TimeseriesGroupService 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 -// [NewRadarAttackLayer7TimeseriesGroupService] method instead. -type RadarAttackLayer7TimeseriesGroupService struct { - Options []option.RequestOption -} - -// NewRadarAttackLayer7TimeseriesGroupService 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 NewRadarAttackLayer7TimeseriesGroupService(opts ...option.RequestOption) (r *RadarAttackLayer7TimeseriesGroupService) { - r = &RadarAttackLayer7TimeseriesGroupService{} - r.Options = opts - return -} - -// Get a time series of the percentual distribution of mitigation techniques, over -// time. -func (r *RadarAttackLayer7TimeseriesGroupService) Get(ctx context.Context, query RadarAttackLayer7TimeseriesGroupGetParams, opts ...option.RequestOption) (res *RadarAttackLayer7TimeseriesGroupGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7TimeseriesGroupGetResponseEnvelope - path := "radar/attacks/layer7/timeseries_groups" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by http method used over time. -func (r *RadarAttackLayer7TimeseriesGroupService) HTTPMethod(ctx context.Context, query RadarAttackLayer7TimeseriesGroupHTTPMethodParams, opts ...option.RequestOption) (res *RadarAttackLayer7TimeseriesGroupHTTPMethodResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7TimeseriesGroupHTTPMethodResponseEnvelope - path := "radar/attacks/layer7/timeseries_groups/http_method" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by http version used over time. -func (r *RadarAttackLayer7TimeseriesGroupService) HTTPVersion(ctx context.Context, query RadarAttackLayer7TimeseriesGroupHTTPVersionParams, opts ...option.RequestOption) (res *RadarAttackLayer7TimeseriesGroupHTTPVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7TimeseriesGroupHTTPVersionResponseEnvelope - path := "radar/attacks/layer7/timeseries_groups/http_version" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by industry used over time. -func (r *RadarAttackLayer7TimeseriesGroupService) Industry(ctx context.Context, query RadarAttackLayer7TimeseriesGroupIndustryParams, opts ...option.RequestOption) (res *RadarAttackLayer7TimeseriesGroupIndustryResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7TimeseriesGroupIndustryResponseEnvelope - path := "radar/attacks/layer7/timeseries_groups/industry" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by ip version used over time. -func (r *RadarAttackLayer7TimeseriesGroupService) IPVersion(ctx context.Context, query RadarAttackLayer7TimeseriesGroupIPVersionParams, opts ...option.RequestOption) (res *RadarAttackLayer7TimeseriesGroupIPVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7TimeseriesGroupIPVersionResponseEnvelope - path := "radar/attacks/layer7/timeseries_groups/ip_version" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by managed rules used over time. -func (r *RadarAttackLayer7TimeseriesGroupService) ManagedRules(ctx context.Context, query RadarAttackLayer7TimeseriesGroupManagedRulesParams, opts ...option.RequestOption) (res *RadarAttackLayer7TimeseriesGroupManagedRulesResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7TimeseriesGroupManagedRulesResponseEnvelope - path := "radar/attacks/layer7/timeseries_groups/managed_rules" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by mitigation product used over time. -func (r *RadarAttackLayer7TimeseriesGroupService) MitigationProduct(ctx context.Context, query RadarAttackLayer7TimeseriesGroupMitigationProductParams, opts ...option.RequestOption) (res *RadarAttackLayer7TimeseriesGroupMitigationProductResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7TimeseriesGroupMitigationProductResponseEnvelope - path := "radar/attacks/layer7/timeseries_groups/mitigation_product" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of attacks by vertical used over time. -func (r *RadarAttackLayer7TimeseriesGroupService) Vertical(ctx context.Context, query RadarAttackLayer7TimeseriesGroupVerticalParams, opts ...option.RequestOption) (res *RadarAttackLayer7TimeseriesGroupVerticalResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7TimeseriesGroupVerticalResponseEnvelope - path := "radar/attacks/layer7/timeseries_groups/vertical" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarAttackLayer7TimeseriesGroupGetResponse struct { - Meta RadarAttackLayer7TimeseriesGroupGetResponseMeta `json:"meta,required"` - Serie0 RadarAttackLayer7TimeseriesGroupGetResponseSerie0 `json:"serie_0,required"` - JSON radarAttackLayer7TimeseriesGroupGetResponseJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupGetResponseJSON contains the JSON metadata for -// the struct [RadarAttackLayer7TimeseriesGroupGetResponse] -type radarAttackLayer7TimeseriesGroupGetResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupGetResponseMeta struct { - AggInterval string `json:"aggInterval,required"` - DateRange []RadarAttackLayer7TimeseriesGroupGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated time.Time `json:"lastUpdated,required" format:"date-time"` - ConfidenceInfo RadarAttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer7TimeseriesGroupGetResponseMetaJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupGetResponseMetaJSON contains the JSON metadata -// for the struct [RadarAttackLayer7TimeseriesGroupGetResponseMeta] -type radarAttackLayer7TimeseriesGroupGetResponseMetaJSON struct { - AggInterval apijson.Field - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer7TimeseriesGroupGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupGetResponseMetaDateRangeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer7TimeseriesGroupGetResponseMetaDateRange] -type radarAttackLayer7TimeseriesGroupGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfo] -type radarAttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarAttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupGetResponseSerie0 struct { - AccessRules []string `json:"ACCESS_RULES,required"` - APIShield []string `json:"API_SHIELD,required"` - BotManagement []string `json:"BOT_MANAGEMENT,required"` - DataLossPrevention []string `json:"DATA_LOSS_PREVENTION,required"` - DDOS []string `json:"DDOS,required"` - IPReputation []string `json:"IP_REPUTATION,required"` - Timestamps []time.Time `json:"timestamps,required" format:"date-time"` - WAF []string `json:"WAF,required"` - JSON radarAttackLayer7TimeseriesGroupGetResponseSerie0JSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupGetResponseSerie0JSON contains the JSON metadata -// for the struct [RadarAttackLayer7TimeseriesGroupGetResponseSerie0] -type radarAttackLayer7TimeseriesGroupGetResponseSerie0JSON struct { - AccessRules apijson.Field - APIShield apijson.Field - BotManagement apijson.Field - DataLossPrevention apijson.Field - DDOS apijson.Field - IPReputation apijson.Field - Timestamps apijson.Field - WAF apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupGetResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupGetResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupHTTPMethodResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAttackLayer7TimeseriesGroupHTTPMethodResponseSerie0 `json:"serie_0,required"` - JSON radarAttackLayer7TimeseriesGroupHTTPMethodResponseJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupHTTPMethodResponseJSON contains the JSON -// metadata for the struct [RadarAttackLayer7TimeseriesGroupHTTPMethodResponse] -type radarAttackLayer7TimeseriesGroupHTTPMethodResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupHTTPMethodResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupHTTPMethodResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupHTTPMethodResponseSerie0 struct { - Get []string `json:"GET,required"` - Timestamps []string `json:"timestamps,required"` - JSON radarAttackLayer7TimeseriesGroupHTTPMethodResponseSerie0JSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupHTTPMethodResponseSerie0JSON contains the JSON -// metadata for the struct -// [RadarAttackLayer7TimeseriesGroupHTTPMethodResponseSerie0] -type radarAttackLayer7TimeseriesGroupHTTPMethodResponseSerie0JSON struct { - Get apijson.Field - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupHTTPMethodResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupHTTPMethodResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupHTTPVersionResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAttackLayer7TimeseriesGroupHTTPVersionResponseSerie0 `json:"serie_0,required"` - JSON radarAttackLayer7TimeseriesGroupHTTPVersionResponseJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupHTTPVersionResponseJSON contains the JSON -// metadata for the struct [RadarAttackLayer7TimeseriesGroupHTTPVersionResponse] -type radarAttackLayer7TimeseriesGroupHTTPVersionResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupHTTPVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupHTTPVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupHTTPVersionResponseSerie0 struct { - HTTP1X []string `json:"HTTP/1.x,required"` - Timestamps []string `json:"timestamps,required"` - JSON radarAttackLayer7TimeseriesGroupHTTPVersionResponseSerie0JSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupHTTPVersionResponseSerie0JSON contains the JSON -// metadata for the struct -// [RadarAttackLayer7TimeseriesGroupHTTPVersionResponseSerie0] -type radarAttackLayer7TimeseriesGroupHTTPVersionResponseSerie0JSON struct { - HTTP1X apijson.Field - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupHTTPVersionResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupHTTPVersionResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupIndustryResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAttackLayer7TimeseriesGroupIndustryResponseSerie0 `json:"serie_0,required"` - JSON radarAttackLayer7TimeseriesGroupIndustryResponseJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupIndustryResponseJSON contains the JSON metadata -// for the struct [RadarAttackLayer7TimeseriesGroupIndustryResponse] -type radarAttackLayer7TimeseriesGroupIndustryResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupIndustryResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupIndustryResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupIndustryResponseSerie0 struct { - Timestamps []string `json:"timestamps,required"` - ExtraFields map[string][]string `json:"-,extras"` - JSON radarAttackLayer7TimeseriesGroupIndustryResponseSerie0JSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupIndustryResponseSerie0JSON contains the JSON -// metadata for the struct [RadarAttackLayer7TimeseriesGroupIndustryResponseSerie0] -type radarAttackLayer7TimeseriesGroupIndustryResponseSerie0JSON struct { - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupIndustryResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupIndustryResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupIPVersionResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAttackLayer7TimeseriesGroupIPVersionResponseSerie0 `json:"serie_0,required"` - JSON radarAttackLayer7TimeseriesGroupIPVersionResponseJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupIPVersionResponseJSON contains the JSON metadata -// for the struct [RadarAttackLayer7TimeseriesGroupIPVersionResponse] -type radarAttackLayer7TimeseriesGroupIPVersionResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupIPVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupIPVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupIPVersionResponseSerie0 struct { - IPv4 []string `json:"IPv4,required"` - IPv6 []string `json:"IPv6,required"` - Timestamps []string `json:"timestamps,required"` - JSON radarAttackLayer7TimeseriesGroupIPVersionResponseSerie0JSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupIPVersionResponseSerie0JSON contains the JSON -// metadata for the struct -// [RadarAttackLayer7TimeseriesGroupIPVersionResponseSerie0] -type radarAttackLayer7TimeseriesGroupIPVersionResponseSerie0JSON struct { - IPv4 apijson.Field - IPv6 apijson.Field - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupIPVersionResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupIPVersionResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupManagedRulesResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAttackLayer7TimeseriesGroupManagedRulesResponseSerie0 `json:"serie_0,required"` - JSON radarAttackLayer7TimeseriesGroupManagedRulesResponseJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupManagedRulesResponseJSON contains the JSON -// metadata for the struct [RadarAttackLayer7TimeseriesGroupManagedRulesResponse] -type radarAttackLayer7TimeseriesGroupManagedRulesResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupManagedRulesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupManagedRulesResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupManagedRulesResponseSerie0 struct { - Bot []string `json:"Bot,required"` - Timestamps []string `json:"timestamps,required"` - JSON radarAttackLayer7TimeseriesGroupManagedRulesResponseSerie0JSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupManagedRulesResponseSerie0JSON contains the JSON -// metadata for the struct -// [RadarAttackLayer7TimeseriesGroupManagedRulesResponseSerie0] -type radarAttackLayer7TimeseriesGroupManagedRulesResponseSerie0JSON struct { - Bot apijson.Field - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupManagedRulesResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupManagedRulesResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupMitigationProductResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAttackLayer7TimeseriesGroupMitigationProductResponseSerie0 `json:"serie_0,required"` - JSON radarAttackLayer7TimeseriesGroupMitigationProductResponseJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupMitigationProductResponseJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer7TimeseriesGroupMitigationProductResponse] -type radarAttackLayer7TimeseriesGroupMitigationProductResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupMitigationProductResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupMitigationProductResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupMitigationProductResponseSerie0 struct { - DDOS []string `json:"DDOS,required"` - Timestamps []string `json:"timestamps,required"` - JSON radarAttackLayer7TimeseriesGroupMitigationProductResponseSerie0JSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupMitigationProductResponseSerie0JSON contains the -// JSON metadata for the struct -// [RadarAttackLayer7TimeseriesGroupMitigationProductResponseSerie0] -type radarAttackLayer7TimeseriesGroupMitigationProductResponseSerie0JSON struct { - DDOS apijson.Field - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupMitigationProductResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupMitigationProductResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupVerticalResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarAttackLayer7TimeseriesGroupVerticalResponseSerie0 `json:"serie_0,required"` - JSON radarAttackLayer7TimeseriesGroupVerticalResponseJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupVerticalResponseJSON contains the JSON metadata -// for the struct [RadarAttackLayer7TimeseriesGroupVerticalResponse] -type radarAttackLayer7TimeseriesGroupVerticalResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupVerticalResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupVerticalResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupVerticalResponseSerie0 struct { - Timestamps []string `json:"timestamps,required"` - ExtraFields map[string][]string `json:"-,extras"` - JSON radarAttackLayer7TimeseriesGroupVerticalResponseSerie0JSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupVerticalResponseSerie0JSON contains the JSON -// metadata for the struct [RadarAttackLayer7TimeseriesGroupVerticalResponseSerie0] -type radarAttackLayer7TimeseriesGroupVerticalResponseSerie0JSON struct { - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupVerticalResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupVerticalResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupGetParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAttackLayer7TimeseriesGroupGetParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7TimeseriesGroupGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7TimeseriesGroupGetParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAttackLayer7TimeseriesGroupGetParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer7TimeseriesGroupGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAttackLayer7TimeseriesGroupGetParamsAggInterval string - -const ( - RadarAttackLayer7TimeseriesGroupGetParamsAggInterval15m RadarAttackLayer7TimeseriesGroupGetParamsAggInterval = "15m" - RadarAttackLayer7TimeseriesGroupGetParamsAggInterval1h RadarAttackLayer7TimeseriesGroupGetParamsAggInterval = "1h" - RadarAttackLayer7TimeseriesGroupGetParamsAggInterval1d RadarAttackLayer7TimeseriesGroupGetParamsAggInterval = "1d" - RadarAttackLayer7TimeseriesGroupGetParamsAggInterval1w RadarAttackLayer7TimeseriesGroupGetParamsAggInterval = "1w" -) - -type RadarAttackLayer7TimeseriesGroupGetParamsDateRange string - -const ( - RadarAttackLayer7TimeseriesGroupGetParamsDateRange1d RadarAttackLayer7TimeseriesGroupGetParamsDateRange = "1d" - RadarAttackLayer7TimeseriesGroupGetParamsDateRange2d RadarAttackLayer7TimeseriesGroupGetParamsDateRange = "2d" - RadarAttackLayer7TimeseriesGroupGetParamsDateRange7d RadarAttackLayer7TimeseriesGroupGetParamsDateRange = "7d" - RadarAttackLayer7TimeseriesGroupGetParamsDateRange14d RadarAttackLayer7TimeseriesGroupGetParamsDateRange = "14d" - RadarAttackLayer7TimeseriesGroupGetParamsDateRange28d RadarAttackLayer7TimeseriesGroupGetParamsDateRange = "28d" - RadarAttackLayer7TimeseriesGroupGetParamsDateRange12w RadarAttackLayer7TimeseriesGroupGetParamsDateRange = "12w" - RadarAttackLayer7TimeseriesGroupGetParamsDateRange24w RadarAttackLayer7TimeseriesGroupGetParamsDateRange = "24w" - RadarAttackLayer7TimeseriesGroupGetParamsDateRange52w RadarAttackLayer7TimeseriesGroupGetParamsDateRange = "52w" - RadarAttackLayer7TimeseriesGroupGetParamsDateRange1dControl RadarAttackLayer7TimeseriesGroupGetParamsDateRange = "1dControl" - RadarAttackLayer7TimeseriesGroupGetParamsDateRange2dControl RadarAttackLayer7TimeseriesGroupGetParamsDateRange = "2dControl" - RadarAttackLayer7TimeseriesGroupGetParamsDateRange7dControl RadarAttackLayer7TimeseriesGroupGetParamsDateRange = "7dControl" - RadarAttackLayer7TimeseriesGroupGetParamsDateRange14dControl RadarAttackLayer7TimeseriesGroupGetParamsDateRange = "14dControl" - RadarAttackLayer7TimeseriesGroupGetParamsDateRange28dControl RadarAttackLayer7TimeseriesGroupGetParamsDateRange = "28dControl" - RadarAttackLayer7TimeseriesGroupGetParamsDateRange12wControl RadarAttackLayer7TimeseriesGroupGetParamsDateRange = "12wControl" - RadarAttackLayer7TimeseriesGroupGetParamsDateRange24wControl RadarAttackLayer7TimeseriesGroupGetParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7TimeseriesGroupGetParamsFormat string - -const ( - RadarAttackLayer7TimeseriesGroupGetParamsFormatJson RadarAttackLayer7TimeseriesGroupGetParamsFormat = "JSON" - RadarAttackLayer7TimeseriesGroupGetParamsFormatCsv RadarAttackLayer7TimeseriesGroupGetParamsFormat = "CSV" -) - -type RadarAttackLayer7TimeseriesGroupGetResponseEnvelope struct { - Result RadarAttackLayer7TimeseriesGroupGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7TimeseriesGroupGetResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarAttackLayer7TimeseriesGroupGetResponseEnvelope] -type radarAttackLayer7TimeseriesGroupGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupHTTPMethodParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7TimeseriesGroupHTTPMethodParamsFormat] `query:"format"` - // Filter for http version. - HTTPVersion param.Field[[]RadarAttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer7TimeseriesGroupHTTPMethodParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of L7 mitigation products. - MitigationProduct param.Field[[]RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct] `query:"mitigationProduct"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Normalization method applied. Refer to - // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). - Normalization param.Field[RadarAttackLayer7TimeseriesGroupHTTPMethodParamsNormalization] `query:"normalization"` -} - -// URLQuery serializes [RadarAttackLayer7TimeseriesGroupHTTPMethodParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer7TimeseriesGroupHTTPMethodParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval string - -const ( - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval15m RadarAttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval = "15m" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval1h RadarAttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval = "1h" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval1d RadarAttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval = "1d" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval1w RadarAttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval = "1w" -) - -type RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange string - -const ( - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange1d RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "1d" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange2d RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "2d" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange7d RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "7d" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange14d RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "14d" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange28d RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "28d" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange12w RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "12w" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange24w RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "24w" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange52w RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "52w" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange1dControl RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "1dControl" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange2dControl RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "2dControl" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange7dControl RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "7dControl" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange14dControl RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "14dControl" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange28dControl RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "28dControl" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange12wControl RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "12wControl" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange24wControl RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7TimeseriesGroupHTTPMethodParamsFormat string - -const ( - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsFormatJson RadarAttackLayer7TimeseriesGroupHTTPMethodParamsFormat = "JSON" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsFormatCsv RadarAttackLayer7TimeseriesGroupHTTPMethodParamsFormat = "CSV" -) - -type RadarAttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersion string - -const ( - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersionHttPv1 RadarAttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersion = "HTTPv1" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersionHttPv2 RadarAttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersion = "HTTPv2" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersionHttPv3 RadarAttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersion = "HTTPv3" -) - -type RadarAttackLayer7TimeseriesGroupHTTPMethodParamsIPVersion string - -const ( - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsIPVersionIPv4 RadarAttackLayer7TimeseriesGroupHTTPMethodParamsIPVersion = "IPv4" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsIPVersionIPv6 RadarAttackLayer7TimeseriesGroupHTTPMethodParamsIPVersion = "IPv6" -) - -type RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct string - -const ( - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductDDOS RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct = "DDOS" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductWAF RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct = "WAF" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductBotManagement RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct = "BOT_MANAGEMENT" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductAccessRules RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct = "ACCESS_RULES" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductIPReputation RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct = "IP_REPUTATION" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductAPIShield RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct = "API_SHIELD" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductDataLossPrevention RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct = "DATA_LOSS_PREVENTION" -) - -// Normalization method applied. Refer to -// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). -type RadarAttackLayer7TimeseriesGroupHTTPMethodParamsNormalization string - -const ( - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsNormalizationPercentage RadarAttackLayer7TimeseriesGroupHTTPMethodParamsNormalization = "PERCENTAGE" - RadarAttackLayer7TimeseriesGroupHTTPMethodParamsNormalizationMin0Max RadarAttackLayer7TimeseriesGroupHTTPMethodParamsNormalization = "MIN0_MAX" -) - -type RadarAttackLayer7TimeseriesGroupHTTPMethodResponseEnvelope struct { - Result RadarAttackLayer7TimeseriesGroupHTTPMethodResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7TimeseriesGroupHTTPMethodResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupHTTPMethodResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer7TimeseriesGroupHTTPMethodResponseEnvelope] -type radarAttackLayer7TimeseriesGroupHTTPMethodResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupHTTPMethodResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupHTTPMethodResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupHTTPVersionParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7TimeseriesGroupHTTPVersionParamsFormat] `query:"format"` - // Filter for http method. - HTTPMethod param.Field[[]RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod] `query:"httpMethod"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer7TimeseriesGroupHTTPVersionParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of L7 mitigation products. - MitigationProduct param.Field[[]RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct] `query:"mitigationProduct"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Normalization method applied. Refer to - // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). - Normalization param.Field[RadarAttackLayer7TimeseriesGroupHTTPVersionParamsNormalization] `query:"normalization"` -} - -// URLQuery serializes [RadarAttackLayer7TimeseriesGroupHTTPVersionParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer7TimeseriesGroupHTTPVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval string - -const ( - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval15m RadarAttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval = "15m" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval1h RadarAttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval = "1h" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval1d RadarAttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval = "1d" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval1w RadarAttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval = "1w" -) - -type RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange string - -const ( - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange1d RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "1d" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange2d RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "2d" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange7d RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "7d" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange14d RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "14d" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange28d RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "28d" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange12w RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "12w" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange24w RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "24w" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange52w RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "52w" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange1dControl RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "1dControl" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange2dControl RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "2dControl" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange7dControl RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "7dControl" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange14dControl RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "14dControl" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange28dControl RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "28dControl" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange12wControl RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "12wControl" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange24wControl RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7TimeseriesGroupHTTPVersionParamsFormat string - -const ( - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsFormatJson RadarAttackLayer7TimeseriesGroupHTTPVersionParamsFormat = "JSON" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsFormatCsv RadarAttackLayer7TimeseriesGroupHTTPVersionParamsFormat = "CSV" -) - -type RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod string - -const ( - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodGet RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "GET" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodPost RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "POST" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodDelete RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "DELETE" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodPut RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "PUT" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodHead RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "HEAD" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodPurge RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "PURGE" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodOptions RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "OPTIONS" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodPropfind RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "PROPFIND" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodMkcol RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "MKCOL" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodPatch RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "PATCH" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodACL RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "ACL" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodBcopy RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "BCOPY" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodBdelete RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "BDELETE" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodBmove RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "BMOVE" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodBpropfind RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "BPROPFIND" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodBproppatch RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "BPROPPATCH" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodCheckin RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "CHECKIN" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodCheckout RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "CHECKOUT" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodConnect RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "CONNECT" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodCopy RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "COPY" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodLabel RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "LABEL" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodLock RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "LOCK" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodMerge RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "MERGE" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodMkactivity RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "MKACTIVITY" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodMkworkspace RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "MKWORKSPACE" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodMove RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "MOVE" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodNotify RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "NOTIFY" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodOrderpatch RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "ORDERPATCH" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodPoll RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "POLL" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodProppatch RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "PROPPATCH" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodReport RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "REPORT" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodSearch RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "SEARCH" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodSubscribe RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "SUBSCRIBE" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodTrace RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "TRACE" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodUncheckout RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "UNCHECKOUT" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodUnlock RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "UNLOCK" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodUnsubscribe RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "UNSUBSCRIBE" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodUpdate RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "UPDATE" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodVersioncontrol RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "VERSIONCONTROL" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodBaselinecontrol RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "BASELINECONTROL" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodXmsenumatts RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "XMSENUMATTS" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodRpcOutData RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "RPC_OUT_DATA" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodRpcInData RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "RPC_IN_DATA" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodJson RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "JSON" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodCook RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "COOK" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodTrack RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod = "TRACK" -) - -type RadarAttackLayer7TimeseriesGroupHTTPVersionParamsIPVersion string - -const ( - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsIPVersionIPv4 RadarAttackLayer7TimeseriesGroupHTTPVersionParamsIPVersion = "IPv4" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsIPVersionIPv6 RadarAttackLayer7TimeseriesGroupHTTPVersionParamsIPVersion = "IPv6" -) - -type RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct string - -const ( - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductDDOS RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct = "DDOS" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductWAF RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct = "WAF" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductBotManagement RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct = "BOT_MANAGEMENT" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductAccessRules RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct = "ACCESS_RULES" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductIPReputation RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct = "IP_REPUTATION" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductAPIShield RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct = "API_SHIELD" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductDataLossPrevention RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct = "DATA_LOSS_PREVENTION" -) - -// Normalization method applied. Refer to -// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). -type RadarAttackLayer7TimeseriesGroupHTTPVersionParamsNormalization string - -const ( - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsNormalizationPercentage RadarAttackLayer7TimeseriesGroupHTTPVersionParamsNormalization = "PERCENTAGE" - RadarAttackLayer7TimeseriesGroupHTTPVersionParamsNormalizationMin0Max RadarAttackLayer7TimeseriesGroupHTTPVersionParamsNormalization = "MIN0_MAX" -) - -type RadarAttackLayer7TimeseriesGroupHTTPVersionResponseEnvelope struct { - Result RadarAttackLayer7TimeseriesGroupHTTPVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7TimeseriesGroupHTTPVersionResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupHTTPVersionResponseEnvelopeJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer7TimeseriesGroupHTTPVersionResponseEnvelope] -type radarAttackLayer7TimeseriesGroupHTTPVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupHTTPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupHTTPVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupIndustryParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAttackLayer7TimeseriesGroupIndustryParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7TimeseriesGroupIndustryParamsFormat] `query:"format"` - // Filter for http method. - HTTPMethod param.Field[[]RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod] `query:"httpMethod"` - // Filter for http version. - HTTPVersion param.Field[[]RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer7TimeseriesGroupIndustryParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects (eg browsers, verticals, etc) to the top items over - // the time range. - LimitPerGroup param.Field[int64] `query:"limitPerGroup"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of L7 mitigation products. - MitigationProduct param.Field[[]RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProduct] `query:"mitigationProduct"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Normalization method applied. Refer to - // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). - Normalization param.Field[RadarAttackLayer7TimeseriesGroupIndustryParamsNormalization] `query:"normalization"` -} - -// URLQuery serializes [RadarAttackLayer7TimeseriesGroupIndustryParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer7TimeseriesGroupIndustryParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAttackLayer7TimeseriesGroupIndustryParamsAggInterval string - -const ( - RadarAttackLayer7TimeseriesGroupIndustryParamsAggInterval15m RadarAttackLayer7TimeseriesGroupIndustryParamsAggInterval = "15m" - RadarAttackLayer7TimeseriesGroupIndustryParamsAggInterval1h RadarAttackLayer7TimeseriesGroupIndustryParamsAggInterval = "1h" - RadarAttackLayer7TimeseriesGroupIndustryParamsAggInterval1d RadarAttackLayer7TimeseriesGroupIndustryParamsAggInterval = "1d" - RadarAttackLayer7TimeseriesGroupIndustryParamsAggInterval1w RadarAttackLayer7TimeseriesGroupIndustryParamsAggInterval = "1w" -) - -type RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange string - -const ( - RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange1d RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange = "1d" - RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange2d RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange = "2d" - RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange7d RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange = "7d" - RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange14d RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange = "14d" - RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange28d RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange = "28d" - RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange12w RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange = "12w" - RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange24w RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange = "24w" - RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange52w RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange = "52w" - RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange1dControl RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange = "1dControl" - RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange2dControl RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange = "2dControl" - RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange7dControl RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange = "7dControl" - RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange14dControl RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange = "14dControl" - RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange28dControl RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange = "28dControl" - RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange12wControl RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange = "12wControl" - RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange24wControl RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7TimeseriesGroupIndustryParamsFormat string - -const ( - RadarAttackLayer7TimeseriesGroupIndustryParamsFormatJson RadarAttackLayer7TimeseriesGroupIndustryParamsFormat = "JSON" - RadarAttackLayer7TimeseriesGroupIndustryParamsFormatCsv RadarAttackLayer7TimeseriesGroupIndustryParamsFormat = "CSV" -) - -type RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod string - -const ( - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodGet RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "GET" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodPost RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "POST" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodDelete RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "DELETE" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodPut RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "PUT" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodHead RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "HEAD" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodPurge RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "PURGE" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodOptions RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "OPTIONS" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodPropfind RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "PROPFIND" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodMkcol RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "MKCOL" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodPatch RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "PATCH" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodACL RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "ACL" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodBcopy RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "BCOPY" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodBdelete RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "BDELETE" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodBmove RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "BMOVE" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodBpropfind RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "BPROPFIND" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodBproppatch RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "BPROPPATCH" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodCheckin RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "CHECKIN" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodCheckout RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "CHECKOUT" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodConnect RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "CONNECT" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodCopy RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "COPY" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodLabel RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "LABEL" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodLock RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "LOCK" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodMerge RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "MERGE" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodMkactivity RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "MKACTIVITY" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodMkworkspace RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "MKWORKSPACE" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodMove RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "MOVE" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodNotify RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "NOTIFY" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodOrderpatch RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "ORDERPATCH" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodPoll RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "POLL" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodProppatch RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "PROPPATCH" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodReport RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "REPORT" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodSearch RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "SEARCH" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodSubscribe RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "SUBSCRIBE" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodTrace RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "TRACE" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodUncheckout RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "UNCHECKOUT" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodUnlock RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "UNLOCK" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodUnsubscribe RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "UNSUBSCRIBE" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodUpdate RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "UPDATE" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodVersioncontrol RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "VERSIONCONTROL" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodBaselinecontrol RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "BASELINECONTROL" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodXmsenumatts RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "XMSENUMATTS" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodRpcOutData RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "RPC_OUT_DATA" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodRpcInData RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "RPC_IN_DATA" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodJson RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "JSON" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodCook RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "COOK" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodTrack RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod = "TRACK" -) - -type RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPVersion string - -const ( - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPVersionHttPv1 RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPVersion = "HTTPv1" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPVersionHttPv2 RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPVersion = "HTTPv2" - RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPVersionHttPv3 RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPVersion = "HTTPv3" -) - -type RadarAttackLayer7TimeseriesGroupIndustryParamsIPVersion string - -const ( - RadarAttackLayer7TimeseriesGroupIndustryParamsIPVersionIPv4 RadarAttackLayer7TimeseriesGroupIndustryParamsIPVersion = "IPv4" - RadarAttackLayer7TimeseriesGroupIndustryParamsIPVersionIPv6 RadarAttackLayer7TimeseriesGroupIndustryParamsIPVersion = "IPv6" -) - -type RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProduct string - -const ( - RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProductDDOS RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProduct = "DDOS" - RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProductWAF RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProduct = "WAF" - RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProductBotManagement RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProduct = "BOT_MANAGEMENT" - RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProductAccessRules RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProduct = "ACCESS_RULES" - RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProductIPReputation RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProduct = "IP_REPUTATION" - RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProductAPIShield RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProduct = "API_SHIELD" - RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProductDataLossPrevention RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProduct = "DATA_LOSS_PREVENTION" -) - -// Normalization method applied. Refer to -// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). -type RadarAttackLayer7TimeseriesGroupIndustryParamsNormalization string - -const ( - RadarAttackLayer7TimeseriesGroupIndustryParamsNormalizationPercentage RadarAttackLayer7TimeseriesGroupIndustryParamsNormalization = "PERCENTAGE" - RadarAttackLayer7TimeseriesGroupIndustryParamsNormalizationMin0Max RadarAttackLayer7TimeseriesGroupIndustryParamsNormalization = "MIN0_MAX" -) - -type RadarAttackLayer7TimeseriesGroupIndustryResponseEnvelope struct { - Result RadarAttackLayer7TimeseriesGroupIndustryResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7TimeseriesGroupIndustryResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupIndustryResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer7TimeseriesGroupIndustryResponseEnvelope] -type radarAttackLayer7TimeseriesGroupIndustryResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupIndustryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupIndustryResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupIPVersionParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAttackLayer7TimeseriesGroupIPVersionParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7TimeseriesGroupIPVersionParamsFormat] `query:"format"` - // Filter for http method. - HTTPMethod param.Field[[]RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod] `query:"httpMethod"` - // Filter for http version. - HTTPVersion param.Field[[]RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPVersion] `query:"httpVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of L7 mitigation products. - MitigationProduct param.Field[[]RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct] `query:"mitigationProduct"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Normalization method applied. Refer to - // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). - Normalization param.Field[RadarAttackLayer7TimeseriesGroupIPVersionParamsNormalization] `query:"normalization"` -} - -// URLQuery serializes [RadarAttackLayer7TimeseriesGroupIPVersionParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer7TimeseriesGroupIPVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAttackLayer7TimeseriesGroupIPVersionParamsAggInterval string - -const ( - RadarAttackLayer7TimeseriesGroupIPVersionParamsAggInterval15m RadarAttackLayer7TimeseriesGroupIPVersionParamsAggInterval = "15m" - RadarAttackLayer7TimeseriesGroupIPVersionParamsAggInterval1h RadarAttackLayer7TimeseriesGroupIPVersionParamsAggInterval = "1h" - RadarAttackLayer7TimeseriesGroupIPVersionParamsAggInterval1d RadarAttackLayer7TimeseriesGroupIPVersionParamsAggInterval = "1d" - RadarAttackLayer7TimeseriesGroupIPVersionParamsAggInterval1w RadarAttackLayer7TimeseriesGroupIPVersionParamsAggInterval = "1w" -) - -type RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange string - -const ( - RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange1d RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange = "1d" - RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange2d RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange = "2d" - RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange7d RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange = "7d" - RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange14d RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange = "14d" - RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange28d RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange = "28d" - RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange12w RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange = "12w" - RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange24w RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange = "24w" - RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange52w RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange = "52w" - RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange1dControl RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange = "1dControl" - RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange2dControl RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange = "2dControl" - RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange7dControl RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange = "7dControl" - RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange14dControl RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange = "14dControl" - RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange28dControl RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange = "28dControl" - RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange12wControl RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange = "12wControl" - RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange24wControl RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7TimeseriesGroupIPVersionParamsFormat string - -const ( - RadarAttackLayer7TimeseriesGroupIPVersionParamsFormatJson RadarAttackLayer7TimeseriesGroupIPVersionParamsFormat = "JSON" - RadarAttackLayer7TimeseriesGroupIPVersionParamsFormatCsv RadarAttackLayer7TimeseriesGroupIPVersionParamsFormat = "CSV" -) - -type RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod string - -const ( - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodGet RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "GET" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodPost RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "POST" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodDelete RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "DELETE" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodPut RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "PUT" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodHead RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "HEAD" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodPurge RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "PURGE" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodOptions RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "OPTIONS" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodPropfind RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "PROPFIND" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodMkcol RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "MKCOL" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodPatch RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "PATCH" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodACL RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "ACL" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodBcopy RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "BCOPY" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodBdelete RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "BDELETE" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodBmove RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "BMOVE" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodBpropfind RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "BPROPFIND" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodBproppatch RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "BPROPPATCH" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodCheckin RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "CHECKIN" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodCheckout RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "CHECKOUT" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodConnect RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "CONNECT" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodCopy RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "COPY" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodLabel RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "LABEL" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodLock RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "LOCK" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodMerge RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "MERGE" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodMkactivity RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "MKACTIVITY" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodMkworkspace RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "MKWORKSPACE" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodMove RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "MOVE" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodNotify RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "NOTIFY" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodOrderpatch RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "ORDERPATCH" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodPoll RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "POLL" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodProppatch RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "PROPPATCH" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodReport RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "REPORT" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodSearch RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "SEARCH" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodSubscribe RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "SUBSCRIBE" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodTrace RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "TRACE" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodUncheckout RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "UNCHECKOUT" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodUnlock RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "UNLOCK" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodUnsubscribe RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "UNSUBSCRIBE" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodUpdate RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "UPDATE" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodVersioncontrol RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "VERSIONCONTROL" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodBaselinecontrol RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "BASELINECONTROL" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodXmsenumatts RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "XMSENUMATTS" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodRpcOutData RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "RPC_OUT_DATA" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodRpcInData RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "RPC_IN_DATA" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodJson RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "JSON" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodCook RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "COOK" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodTrack RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod = "TRACK" -) - -type RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPVersion string - -const ( - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPVersionHttPv1 RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPVersion = "HTTPv1" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPVersionHttPv2 RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPVersion = "HTTPv2" - RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPVersionHttPv3 RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPVersion = "HTTPv3" -) - -type RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct string - -const ( - RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProductDDOS RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct = "DDOS" - RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProductWAF RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct = "WAF" - RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProductBotManagement RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct = "BOT_MANAGEMENT" - RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProductAccessRules RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct = "ACCESS_RULES" - RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProductIPReputation RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct = "IP_REPUTATION" - RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProductAPIShield RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct = "API_SHIELD" - RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProductDataLossPrevention RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct = "DATA_LOSS_PREVENTION" -) - -// Normalization method applied. Refer to -// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). -type RadarAttackLayer7TimeseriesGroupIPVersionParamsNormalization string - -const ( - RadarAttackLayer7TimeseriesGroupIPVersionParamsNormalizationPercentage RadarAttackLayer7TimeseriesGroupIPVersionParamsNormalization = "PERCENTAGE" - RadarAttackLayer7TimeseriesGroupIPVersionParamsNormalizationMin0Max RadarAttackLayer7TimeseriesGroupIPVersionParamsNormalization = "MIN0_MAX" -) - -type RadarAttackLayer7TimeseriesGroupIPVersionResponseEnvelope struct { - Result RadarAttackLayer7TimeseriesGroupIPVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7TimeseriesGroupIPVersionResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupIPVersionResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer7TimeseriesGroupIPVersionResponseEnvelope] -type radarAttackLayer7TimeseriesGroupIPVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupIPVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupManagedRulesParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAttackLayer7TimeseriesGroupManagedRulesParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7TimeseriesGroupManagedRulesParamsFormat] `query:"format"` - // Filter for http method. - HTTPMethod param.Field[[]RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod] `query:"httpMethod"` - // Filter for http version. - HTTPVersion param.Field[[]RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer7TimeseriesGroupManagedRulesParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of L7 mitigation products. - MitigationProduct param.Field[[]RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct] `query:"mitigationProduct"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Normalization method applied. Refer to - // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). - Normalization param.Field[RadarAttackLayer7TimeseriesGroupManagedRulesParamsNormalization] `query:"normalization"` -} - -// URLQuery serializes [RadarAttackLayer7TimeseriesGroupManagedRulesParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer7TimeseriesGroupManagedRulesParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAttackLayer7TimeseriesGroupManagedRulesParamsAggInterval string - -const ( - RadarAttackLayer7TimeseriesGroupManagedRulesParamsAggInterval15m RadarAttackLayer7TimeseriesGroupManagedRulesParamsAggInterval = "15m" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsAggInterval1h RadarAttackLayer7TimeseriesGroupManagedRulesParamsAggInterval = "1h" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsAggInterval1d RadarAttackLayer7TimeseriesGroupManagedRulesParamsAggInterval = "1d" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsAggInterval1w RadarAttackLayer7TimeseriesGroupManagedRulesParamsAggInterval = "1w" -) - -type RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange string - -const ( - RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange1d RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "1d" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange2d RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "2d" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange7d RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "7d" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange14d RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "14d" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange28d RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "28d" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange12w RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "12w" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange24w RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "24w" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange52w RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "52w" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange1dControl RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "1dControl" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange2dControl RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "2dControl" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange7dControl RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "7dControl" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange14dControl RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "14dControl" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange28dControl RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "28dControl" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange12wControl RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "12wControl" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange24wControl RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7TimeseriesGroupManagedRulesParamsFormat string - -const ( - RadarAttackLayer7TimeseriesGroupManagedRulesParamsFormatJson RadarAttackLayer7TimeseriesGroupManagedRulesParamsFormat = "JSON" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsFormatCsv RadarAttackLayer7TimeseriesGroupManagedRulesParamsFormat = "CSV" -) - -type RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod string - -const ( - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodGet RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "GET" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodPost RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "POST" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodDelete RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "DELETE" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodPut RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "PUT" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodHead RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "HEAD" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodPurge RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "PURGE" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodOptions RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "OPTIONS" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodPropfind RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "PROPFIND" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodMkcol RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "MKCOL" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodPatch RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "PATCH" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodACL RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "ACL" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodBcopy RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "BCOPY" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodBdelete RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "BDELETE" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodBmove RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "BMOVE" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodBpropfind RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "BPROPFIND" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodBproppatch RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "BPROPPATCH" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodCheckin RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "CHECKIN" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodCheckout RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "CHECKOUT" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodConnect RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "CONNECT" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodCopy RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "COPY" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodLabel RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "LABEL" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodLock RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "LOCK" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodMerge RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "MERGE" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodMkactivity RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "MKACTIVITY" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodMkworkspace RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "MKWORKSPACE" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodMove RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "MOVE" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodNotify RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "NOTIFY" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodOrderpatch RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "ORDERPATCH" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodPoll RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "POLL" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodProppatch RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "PROPPATCH" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodReport RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "REPORT" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodSearch RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "SEARCH" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodSubscribe RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "SUBSCRIBE" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodTrace RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "TRACE" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodUncheckout RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "UNCHECKOUT" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodUnlock RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "UNLOCK" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodUnsubscribe RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "UNSUBSCRIBE" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodUpdate RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "UPDATE" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodVersioncontrol RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "VERSIONCONTROL" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodBaselinecontrol RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "BASELINECONTROL" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodXmsenumatts RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "XMSENUMATTS" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodRpcOutData RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "RPC_OUT_DATA" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodRpcInData RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "RPC_IN_DATA" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodJson RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "JSON" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodCook RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "COOK" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodTrack RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod = "TRACK" -) - -type RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersion string - -const ( - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersionHttPv1 RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersion = "HTTPv1" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersionHttPv2 RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersion = "HTTPv2" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersionHttPv3 RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersion = "HTTPv3" -) - -type RadarAttackLayer7TimeseriesGroupManagedRulesParamsIPVersion string - -const ( - RadarAttackLayer7TimeseriesGroupManagedRulesParamsIPVersionIPv4 RadarAttackLayer7TimeseriesGroupManagedRulesParamsIPVersion = "IPv4" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsIPVersionIPv6 RadarAttackLayer7TimeseriesGroupManagedRulesParamsIPVersion = "IPv6" -) - -type RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct string - -const ( - RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductDDOS RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct = "DDOS" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductWAF RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct = "WAF" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductBotManagement RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct = "BOT_MANAGEMENT" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductAccessRules RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct = "ACCESS_RULES" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductIPReputation RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct = "IP_REPUTATION" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductAPIShield RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct = "API_SHIELD" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductDataLossPrevention RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct = "DATA_LOSS_PREVENTION" -) - -// Normalization method applied. Refer to -// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). -type RadarAttackLayer7TimeseriesGroupManagedRulesParamsNormalization string - -const ( - RadarAttackLayer7TimeseriesGroupManagedRulesParamsNormalizationPercentage RadarAttackLayer7TimeseriesGroupManagedRulesParamsNormalization = "PERCENTAGE" - RadarAttackLayer7TimeseriesGroupManagedRulesParamsNormalizationMin0Max RadarAttackLayer7TimeseriesGroupManagedRulesParamsNormalization = "MIN0_MAX" -) - -type RadarAttackLayer7TimeseriesGroupManagedRulesResponseEnvelope struct { - Result RadarAttackLayer7TimeseriesGroupManagedRulesResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7TimeseriesGroupManagedRulesResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupManagedRulesResponseEnvelopeJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer7TimeseriesGroupManagedRulesResponseEnvelope] -type radarAttackLayer7TimeseriesGroupManagedRulesResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupManagedRulesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupManagedRulesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupMitigationProductParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAttackLayer7TimeseriesGroupMitigationProductParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7TimeseriesGroupMitigationProductParamsFormat] `query:"format"` - // Filter for http method. - HTTPMethod param.Field[[]RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod] `query:"httpMethod"` - // Filter for http version. - HTTPVersion param.Field[[]RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer7TimeseriesGroupMitigationProductParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Normalization method applied. Refer to - // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). - Normalization param.Field[RadarAttackLayer7TimeseriesGroupMitigationProductParamsNormalization] `query:"normalization"` -} - -// URLQuery serializes [RadarAttackLayer7TimeseriesGroupMitigationProductParams]'s -// query parameters as `url.Values`. -func (r RadarAttackLayer7TimeseriesGroupMitigationProductParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAttackLayer7TimeseriesGroupMitigationProductParamsAggInterval string - -const ( - RadarAttackLayer7TimeseriesGroupMitigationProductParamsAggInterval15m RadarAttackLayer7TimeseriesGroupMitigationProductParamsAggInterval = "15m" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsAggInterval1h RadarAttackLayer7TimeseriesGroupMitigationProductParamsAggInterval = "1h" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsAggInterval1d RadarAttackLayer7TimeseriesGroupMitigationProductParamsAggInterval = "1d" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsAggInterval1w RadarAttackLayer7TimeseriesGroupMitigationProductParamsAggInterval = "1w" -) - -type RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange string - -const ( - RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange1d RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "1d" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange2d RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "2d" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange7d RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "7d" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange14d RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "14d" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange28d RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "28d" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange12w RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "12w" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange24w RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "24w" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange52w RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "52w" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange1dControl RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "1dControl" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange2dControl RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "2dControl" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange7dControl RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "7dControl" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange14dControl RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "14dControl" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange28dControl RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "28dControl" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange12wControl RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "12wControl" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange24wControl RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7TimeseriesGroupMitigationProductParamsFormat string - -const ( - RadarAttackLayer7TimeseriesGroupMitigationProductParamsFormatJson RadarAttackLayer7TimeseriesGroupMitigationProductParamsFormat = "JSON" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsFormatCsv RadarAttackLayer7TimeseriesGroupMitigationProductParamsFormat = "CSV" -) - -type RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod string - -const ( - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodGet RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "GET" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodPost RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "POST" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodDelete RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "DELETE" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodPut RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "PUT" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodHead RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "HEAD" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodPurge RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "PURGE" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodOptions RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "OPTIONS" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodPropfind RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "PROPFIND" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodMkcol RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "MKCOL" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodPatch RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "PATCH" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodACL RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "ACL" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodBcopy RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "BCOPY" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodBdelete RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "BDELETE" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodBmove RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "BMOVE" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodBpropfind RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "BPROPFIND" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodBproppatch RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "BPROPPATCH" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodCheckin RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "CHECKIN" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodCheckout RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "CHECKOUT" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodConnect RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "CONNECT" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodCopy RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "COPY" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodLabel RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "LABEL" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodLock RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "LOCK" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodMerge RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "MERGE" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodMkactivity RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "MKACTIVITY" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodMkworkspace RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "MKWORKSPACE" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodMove RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "MOVE" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodNotify RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "NOTIFY" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodOrderpatch RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "ORDERPATCH" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodPoll RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "POLL" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodProppatch RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "PROPPATCH" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodReport RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "REPORT" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodSearch RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "SEARCH" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodSubscribe RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "SUBSCRIBE" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodTrace RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "TRACE" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodUncheckout RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "UNCHECKOUT" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodUnlock RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "UNLOCK" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodUnsubscribe RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "UNSUBSCRIBE" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodUpdate RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "UPDATE" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodVersioncontrol RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "VERSIONCONTROL" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodBaselinecontrol RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "BASELINECONTROL" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodXmsenumatts RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "XMSENUMATTS" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodRpcOutData RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "RPC_OUT_DATA" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodRpcInData RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "RPC_IN_DATA" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodJson RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "JSON" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodCook RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "COOK" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodTrack RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod = "TRACK" -) - -type RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersion string - -const ( - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersionHttPv1 RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersion = "HTTPv1" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersionHttPv2 RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersion = "HTTPv2" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersionHttPv3 RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersion = "HTTPv3" -) - -type RadarAttackLayer7TimeseriesGroupMitigationProductParamsIPVersion string - -const ( - RadarAttackLayer7TimeseriesGroupMitigationProductParamsIPVersionIPv4 RadarAttackLayer7TimeseriesGroupMitigationProductParamsIPVersion = "IPv4" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsIPVersionIPv6 RadarAttackLayer7TimeseriesGroupMitigationProductParamsIPVersion = "IPv6" -) - -// Normalization method applied. Refer to -// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). -type RadarAttackLayer7TimeseriesGroupMitigationProductParamsNormalization string - -const ( - RadarAttackLayer7TimeseriesGroupMitigationProductParamsNormalizationPercentage RadarAttackLayer7TimeseriesGroupMitigationProductParamsNormalization = "PERCENTAGE" - RadarAttackLayer7TimeseriesGroupMitigationProductParamsNormalizationMin0Max RadarAttackLayer7TimeseriesGroupMitigationProductParamsNormalization = "MIN0_MAX" -) - -type RadarAttackLayer7TimeseriesGroupMitigationProductResponseEnvelope struct { - Result RadarAttackLayer7TimeseriesGroupMitigationProductResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7TimeseriesGroupMitigationProductResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupMitigationProductResponseEnvelopeJSON contains -// the JSON metadata for the struct -// [RadarAttackLayer7TimeseriesGroupMitigationProductResponseEnvelope] -type radarAttackLayer7TimeseriesGroupMitigationProductResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupMitigationProductResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupMitigationProductResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TimeseriesGroupVerticalParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarAttackLayer7TimeseriesGroupVerticalParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7TimeseriesGroupVerticalParamsFormat] `query:"format"` - // Filter for http method. - HTTPMethod param.Field[[]RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod] `query:"httpMethod"` - // Filter for http version. - HTTPVersion param.Field[[]RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarAttackLayer7TimeseriesGroupVerticalParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects (eg browsers, verticals, etc) to the top items over - // the time range. - LimitPerGroup param.Field[int64] `query:"limitPerGroup"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of L7 mitigation products. - MitigationProduct param.Field[[]RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProduct] `query:"mitigationProduct"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Normalization method applied. Refer to - // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). - Normalization param.Field[RadarAttackLayer7TimeseriesGroupVerticalParamsNormalization] `query:"normalization"` -} - -// URLQuery serializes [RadarAttackLayer7TimeseriesGroupVerticalParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer7TimeseriesGroupVerticalParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarAttackLayer7TimeseriesGroupVerticalParamsAggInterval string - -const ( - RadarAttackLayer7TimeseriesGroupVerticalParamsAggInterval15m RadarAttackLayer7TimeseriesGroupVerticalParamsAggInterval = "15m" - RadarAttackLayer7TimeseriesGroupVerticalParamsAggInterval1h RadarAttackLayer7TimeseriesGroupVerticalParamsAggInterval = "1h" - RadarAttackLayer7TimeseriesGroupVerticalParamsAggInterval1d RadarAttackLayer7TimeseriesGroupVerticalParamsAggInterval = "1d" - RadarAttackLayer7TimeseriesGroupVerticalParamsAggInterval1w RadarAttackLayer7TimeseriesGroupVerticalParamsAggInterval = "1w" -) - -type RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange string - -const ( - RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange1d RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange = "1d" - RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange2d RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange = "2d" - RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange7d RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange = "7d" - RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange14d RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange = "14d" - RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange28d RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange = "28d" - RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange12w RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange = "12w" - RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange24w RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange = "24w" - RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange52w RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange = "52w" - RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange1dControl RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange = "1dControl" - RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange2dControl RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange = "2dControl" - RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange7dControl RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange = "7dControl" - RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange14dControl RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange = "14dControl" - RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange28dControl RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange = "28dControl" - RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange12wControl RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange = "12wControl" - RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange24wControl RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7TimeseriesGroupVerticalParamsFormat string - -const ( - RadarAttackLayer7TimeseriesGroupVerticalParamsFormatJson RadarAttackLayer7TimeseriesGroupVerticalParamsFormat = "JSON" - RadarAttackLayer7TimeseriesGroupVerticalParamsFormatCsv RadarAttackLayer7TimeseriesGroupVerticalParamsFormat = "CSV" -) - -type RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod string - -const ( - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodGet RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "GET" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodPost RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "POST" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodDelete RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "DELETE" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodPut RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "PUT" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodHead RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "HEAD" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodPurge RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "PURGE" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodOptions RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "OPTIONS" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodPropfind RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "PROPFIND" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodMkcol RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "MKCOL" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodPatch RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "PATCH" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodACL RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "ACL" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodBcopy RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "BCOPY" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodBdelete RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "BDELETE" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodBmove RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "BMOVE" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodBpropfind RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "BPROPFIND" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodBproppatch RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "BPROPPATCH" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodCheckin RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "CHECKIN" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodCheckout RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "CHECKOUT" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodConnect RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "CONNECT" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodCopy RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "COPY" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodLabel RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "LABEL" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodLock RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "LOCK" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodMerge RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "MERGE" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodMkactivity RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "MKACTIVITY" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodMkworkspace RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "MKWORKSPACE" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodMove RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "MOVE" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodNotify RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "NOTIFY" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodOrderpatch RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "ORDERPATCH" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodPoll RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "POLL" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodProppatch RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "PROPPATCH" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodReport RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "REPORT" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodSearch RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "SEARCH" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodSubscribe RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "SUBSCRIBE" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodTrace RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "TRACE" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodUncheckout RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "UNCHECKOUT" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodUnlock RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "UNLOCK" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodUnsubscribe RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "UNSUBSCRIBE" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodUpdate RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "UPDATE" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodVersioncontrol RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "VERSIONCONTROL" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodBaselinecontrol RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "BASELINECONTROL" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodXmsenumatts RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "XMSENUMATTS" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodRpcOutData RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "RPC_OUT_DATA" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodRpcInData RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "RPC_IN_DATA" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodJson RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "JSON" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodCook RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "COOK" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodTrack RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod = "TRACK" -) - -type RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPVersion string - -const ( - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPVersionHttPv1 RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPVersion = "HTTPv1" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPVersionHttPv2 RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPVersion = "HTTPv2" - RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPVersionHttPv3 RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPVersion = "HTTPv3" -) - -type RadarAttackLayer7TimeseriesGroupVerticalParamsIPVersion string - -const ( - RadarAttackLayer7TimeseriesGroupVerticalParamsIPVersionIPv4 RadarAttackLayer7TimeseriesGroupVerticalParamsIPVersion = "IPv4" - RadarAttackLayer7TimeseriesGroupVerticalParamsIPVersionIPv6 RadarAttackLayer7TimeseriesGroupVerticalParamsIPVersion = "IPv6" -) - -type RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProduct string - -const ( - RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProductDDOS RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProduct = "DDOS" - RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProductWAF RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProduct = "WAF" - RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProductBotManagement RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProduct = "BOT_MANAGEMENT" - RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProductAccessRules RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProduct = "ACCESS_RULES" - RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProductIPReputation RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProduct = "IP_REPUTATION" - RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProductAPIShield RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProduct = "API_SHIELD" - RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProductDataLossPrevention RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProduct = "DATA_LOSS_PREVENTION" -) - -// Normalization method applied. Refer to -// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). -type RadarAttackLayer7TimeseriesGroupVerticalParamsNormalization string - -const ( - RadarAttackLayer7TimeseriesGroupVerticalParamsNormalizationPercentage RadarAttackLayer7TimeseriesGroupVerticalParamsNormalization = "PERCENTAGE" - RadarAttackLayer7TimeseriesGroupVerticalParamsNormalizationMin0Max RadarAttackLayer7TimeseriesGroupVerticalParamsNormalization = "MIN0_MAX" -) - -type RadarAttackLayer7TimeseriesGroupVerticalResponseEnvelope struct { - Result RadarAttackLayer7TimeseriesGroupVerticalResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7TimeseriesGroupVerticalResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7TimeseriesGroupVerticalResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer7TimeseriesGroupVerticalResponseEnvelope] -type radarAttackLayer7TimeseriesGroupVerticalResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TimeseriesGroupVerticalResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TimeseriesGroupVerticalResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarattacklayer7timeseriesgroup_test.go b/radarattacklayer7timeseriesgroup_test.go deleted file mode 100644 index 5185540c10e..00000000000 --- a/radarattacklayer7timeseriesgroup_test.go +++ /dev/null @@ -1,320 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarAttackLayer7TimeseriesGroupGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.TimeseriesGroups.Get(context.TODO(), cloudflare.RadarAttackLayer7TimeseriesGroupGetParams{ - AggInterval: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupGetParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupGetParamsDateRange{cloudflare.RadarAttackLayer7TimeseriesGroupGetParamsDateRange1d, cloudflare.RadarAttackLayer7TimeseriesGroupGetParamsDateRange2d, cloudflare.RadarAttackLayer7TimeseriesGroupGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupGetParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAttackLayer7TimeseriesGroupHTTPMethodWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.TimeseriesGroups.HTTPMethod(context.TODO(), cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParams{ - AggInterval: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange{cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange1d, cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange2d, cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParamsFormatJson), - HTTPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersion{cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersionHttPv1, cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersionHttPv2, cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParamsIPVersion{cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParamsIPVersionIPv4, cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - MitigationProduct: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProduct{cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductDDOS, cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductWAF, cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParamsMitigationProductBotManagement}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Normalization: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupHTTPMethodParamsNormalizationPercentage), - }) - 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 TestRadarAttackLayer7TimeseriesGroupHTTPVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.TimeseriesGroups.HTTPVersion(context.TODO(), cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParams{ - AggInterval: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange{cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange1d, cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange2d, cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParamsFormatJson), - HTTPMethod: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethod{cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodGet, cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodPost, cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParamsHTTPMethodDelete}), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParamsIPVersion{cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParamsIPVersionIPv4, cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - MitigationProduct: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProduct{cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductDDOS, cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductWAF, cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParamsMitigationProductBotManagement}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Normalization: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupHTTPVersionParamsNormalizationPercentage), - }) - 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 TestRadarAttackLayer7TimeseriesGroupIndustryWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.TimeseriesGroups.Industry(context.TODO(), cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParams{ - AggInterval: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange{cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange1d, cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange2d, cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsFormatJson), - HTTPMethod: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethod{cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodGet, cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodPost, cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPMethodDelete}), - HTTPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPVersion{cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPVersionHttPv1, cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPVersionHttPv2, cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsIPVersion{cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsIPVersionIPv4, cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsIPVersionIPv6}), - LimitPerGroup: cloudflare.F(int64(4)), - Location: cloudflare.F([]string{"string", "string", "string"}), - MitigationProduct: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProduct{cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProductDDOS, cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProductWAF, cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsMitigationProductBotManagement}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Normalization: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupIndustryParamsNormalizationPercentage), - }) - 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 TestRadarAttackLayer7TimeseriesGroupIPVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.TimeseriesGroups.IPVersion(context.TODO(), cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParams{ - AggInterval: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange{cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange1d, cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange2d, cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsFormatJson), - HTTPMethod: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethod{cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodGet, cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodPost, cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPMethodDelete}), - HTTPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPVersion{cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPVersionHttPv1, cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPVersionHttPv2, cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsHTTPVersionHttPv3}), - Location: cloudflare.F([]string{"string", "string", "string"}), - MitigationProduct: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProduct{cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProductDDOS, cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProductWAF, cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsMitigationProductBotManagement}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Normalization: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupIPVersionParamsNormalizationPercentage), - }) - 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 TestRadarAttackLayer7TimeseriesGroupManagedRulesWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.TimeseriesGroups.ManagedRules(context.TODO(), cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParams{ - AggInterval: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange{cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange1d, cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange2d, cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsFormatJson), - HTTPMethod: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethod{cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodGet, cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodPost, cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPMethodDelete}), - HTTPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersion{cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersionHttPv1, cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersionHttPv2, cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsIPVersion{cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsIPVersionIPv4, cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - MitigationProduct: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProduct{cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductDDOS, cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductWAF, cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsMitigationProductBotManagement}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Normalization: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupManagedRulesParamsNormalizationPercentage), - }) - 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 TestRadarAttackLayer7TimeseriesGroupMitigationProductWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.TimeseriesGroups.MitigationProduct(context.TODO(), cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParams{ - AggInterval: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange{cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange1d, cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange2d, cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParamsFormatJson), - HTTPMethod: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethod{cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodGet, cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodPost, cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPMethodDelete}), - HTTPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersion{cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersionHttPv1, cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersionHttPv2, cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParamsIPVersion{cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParamsIPVersionIPv4, cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Normalization: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupMitigationProductParamsNormalizationPercentage), - }) - 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 TestRadarAttackLayer7TimeseriesGroupVerticalWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.TimeseriesGroups.Vertical(context.TODO(), cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParams{ - AggInterval: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange{cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange1d, cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange2d, cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsFormatJson), - HTTPMethod: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethod{cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodGet, cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodPost, cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPMethodDelete}), - HTTPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPVersion{cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPVersionHttPv1, cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPVersionHttPv2, cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsIPVersion{cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsIPVersionIPv4, cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsIPVersionIPv6}), - LimitPerGroup: cloudflare.F(int64(4)), - Location: cloudflare.F([]string{"string", "string", "string"}), - MitigationProduct: cloudflare.F([]cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProduct{cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProductDDOS, cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProductWAF, cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsMitigationProductBotManagement}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Normalization: cloudflare.F(cloudflare.RadarAttackLayer7TimeseriesGroupVerticalParamsNormalizationPercentage), - }) - 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/radarattacklayer7top.go b/radarattacklayer7top.go deleted file mode 100644 index e595f843f8e..00000000000 --- a/radarattacklayer7top.go +++ /dev/null @@ -1,842 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarAttackLayer7TopService 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 [NewRadarAttackLayer7TopService] -// method instead. -type RadarAttackLayer7TopService struct { - Options []option.RequestOption - Locations *RadarAttackLayer7TopLocationService - Ases *RadarAttackLayer7TopAseService -} - -// NewRadarAttackLayer7TopService 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 NewRadarAttackLayer7TopService(opts ...option.RequestOption) (r *RadarAttackLayer7TopService) { - r = &RadarAttackLayer7TopService{} - r.Options = opts - r.Locations = NewRadarAttackLayer7TopLocationService(opts...) - r.Ases = NewRadarAttackLayer7TopAseService(opts...) - return -} - -// Get the top attacks from origin to target location. Values are a percentage out -// of the total layer 7 attacks (with billing country). The attack magnitude can be -// defined by the number of mitigated requests or by the number of zones affected. -// You can optionally limit the number of attacks per origin/target location -// (useful if all the top attacks are from or to the same location). -func (r *RadarAttackLayer7TopService) Attacks(ctx context.Context, query RadarAttackLayer7TopAttacksParams, opts ...option.RequestOption) (res *RadarAttackLayer7TopAttacksResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7TopAttacksResponseEnvelope - path := "radar/attacks/layer7/top/attacks" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the Industry of attacks. -func (r *RadarAttackLayer7TopService) Industry(ctx context.Context, query RadarAttackLayer7TopIndustryParams, opts ...option.RequestOption) (res *RadarAttackLayer7TopIndustryResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7TopIndustryResponseEnvelope - path := "radar/attacks/layer7/top/industry" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the Verticals of attacks. -func (r *RadarAttackLayer7TopService) Vertical(ctx context.Context, query RadarAttackLayer7TopVerticalParams, opts ...option.RequestOption) (res *RadarAttackLayer7TopVerticalResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7TopVerticalResponseEnvelope - path := "radar/attacks/layer7/top/vertical" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarAttackLayer7TopAttacksResponse struct { - Meta RadarAttackLayer7TopAttacksResponseMeta `json:"meta,required"` - Top0 []RadarAttackLayer7TopAttacksResponseTop0 `json:"top_0,required"` - JSON radarAttackLayer7TopAttacksResponseJSON `json:"-"` -} - -// radarAttackLayer7TopAttacksResponseJSON contains the JSON metadata for the -// struct [RadarAttackLayer7TopAttacksResponse] -type radarAttackLayer7TopAttacksResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopAttacksResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopAttacksResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopAttacksResponseMeta struct { - DateRange []RadarAttackLayer7TopAttacksResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarAttackLayer7TopAttacksResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer7TopAttacksResponseMetaJSON `json:"-"` -} - -// radarAttackLayer7TopAttacksResponseMetaJSON contains the JSON metadata for the -// struct [RadarAttackLayer7TopAttacksResponseMeta] -type radarAttackLayer7TopAttacksResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopAttacksResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopAttacksResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopAttacksResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer7TopAttacksResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer7TopAttacksResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarAttackLayer7TopAttacksResponseMetaDateRange] -type radarAttackLayer7TopAttacksResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopAttacksResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopAttacksResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopAttacksResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer7TopAttacksResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer7TopAttacksResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer7TopAttacksResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarAttackLayer7TopAttacksResponseMetaConfidenceInfo] -type radarAttackLayer7TopAttacksResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopAttacksResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopAttacksResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopAttacksResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer7TopAttacksResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer7TopAttacksResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer7TopAttacksResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer7TopAttacksResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopAttacksResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopAttacksResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopAttacksResponseTop0 struct { - OriginCountryAlpha2 string `json:"originCountryAlpha2,required"` - OriginCountryName string `json:"originCountryName,required"` - TargetCountryAlpha2 string `json:"targetCountryAlpha2,required"` - TargetCountryName string `json:"targetCountryName,required"` - Value string `json:"value,required"` - JSON radarAttackLayer7TopAttacksResponseTop0JSON `json:"-"` -} - -// radarAttackLayer7TopAttacksResponseTop0JSON contains the JSON metadata for the -// struct [RadarAttackLayer7TopAttacksResponseTop0] -type radarAttackLayer7TopAttacksResponseTop0JSON struct { - OriginCountryAlpha2 apijson.Field - OriginCountryName apijson.Field - TargetCountryAlpha2 apijson.Field - TargetCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopAttacksResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopAttacksResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopIndustryResponse struct { - Meta RadarAttackLayer7TopIndustryResponseMeta `json:"meta,required"` - Top0 []RadarAttackLayer7TopIndustryResponseTop0 `json:"top_0,required"` - JSON radarAttackLayer7TopIndustryResponseJSON `json:"-"` -} - -// radarAttackLayer7TopIndustryResponseJSON contains the JSON metadata for the -// struct [RadarAttackLayer7TopIndustryResponse] -type radarAttackLayer7TopIndustryResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopIndustryResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopIndustryResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopIndustryResponseMeta struct { - DateRange []RadarAttackLayer7TopIndustryResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarAttackLayer7TopIndustryResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer7TopIndustryResponseMetaJSON `json:"-"` -} - -// radarAttackLayer7TopIndustryResponseMetaJSON contains the JSON metadata for the -// struct [RadarAttackLayer7TopIndustryResponseMeta] -type radarAttackLayer7TopIndustryResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopIndustryResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopIndustryResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopIndustryResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer7TopIndustryResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer7TopIndustryResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarAttackLayer7TopIndustryResponseMetaDateRange] -type radarAttackLayer7TopIndustryResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopIndustryResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopIndustryResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopIndustryResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer7TopIndustryResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer7TopIndustryResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer7TopIndustryResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarAttackLayer7TopIndustryResponseMetaConfidenceInfo] -type radarAttackLayer7TopIndustryResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopIndustryResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopIndustryResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopIndustryResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer7TopIndustryResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer7TopIndustryResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarAttackLayer7TopIndustryResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer7TopIndustryResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopIndustryResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopIndustryResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopIndustryResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON radarAttackLayer7TopIndustryResponseTop0JSON `json:"-"` -} - -// radarAttackLayer7TopIndustryResponseTop0JSON contains the JSON metadata for the -// struct [RadarAttackLayer7TopIndustryResponseTop0] -type radarAttackLayer7TopIndustryResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopIndustryResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopIndustryResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopVerticalResponse struct { - Meta RadarAttackLayer7TopVerticalResponseMeta `json:"meta,required"` - Top0 []RadarAttackLayer7TopVerticalResponseTop0 `json:"top_0,required"` - JSON radarAttackLayer7TopVerticalResponseJSON `json:"-"` -} - -// radarAttackLayer7TopVerticalResponseJSON contains the JSON metadata for the -// struct [RadarAttackLayer7TopVerticalResponse] -type radarAttackLayer7TopVerticalResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopVerticalResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopVerticalResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopVerticalResponseMeta struct { - DateRange []RadarAttackLayer7TopVerticalResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarAttackLayer7TopVerticalResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer7TopVerticalResponseMetaJSON `json:"-"` -} - -// radarAttackLayer7TopVerticalResponseMetaJSON contains the JSON metadata for the -// struct [RadarAttackLayer7TopVerticalResponseMeta] -type radarAttackLayer7TopVerticalResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopVerticalResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopVerticalResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopVerticalResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer7TopVerticalResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer7TopVerticalResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarAttackLayer7TopVerticalResponseMetaDateRange] -type radarAttackLayer7TopVerticalResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopVerticalResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopVerticalResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopVerticalResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer7TopVerticalResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer7TopVerticalResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer7TopVerticalResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarAttackLayer7TopVerticalResponseMetaConfidenceInfo] -type radarAttackLayer7TopVerticalResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopVerticalResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopVerticalResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopVerticalResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer7TopVerticalResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer7TopVerticalResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarAttackLayer7TopVerticalResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer7TopVerticalResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopVerticalResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopVerticalResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopVerticalResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON radarAttackLayer7TopVerticalResponseTop0JSON `json:"-"` -} - -// radarAttackLayer7TopVerticalResponseTop0JSON contains the JSON metadata for the -// struct [RadarAttackLayer7TopVerticalResponseTop0] -type radarAttackLayer7TopVerticalResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopVerticalResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopVerticalResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopAttacksParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7TopAttacksParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7TopAttacksParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of attack origin/target location attack limits. Together with - // `limitPerLocation`, limits how many objects will be fetched per origin/target - // location. - LimitDirection param.Field[RadarAttackLayer7TopAttacksParamsLimitDirection] `query:"limitDirection"` - // Limit the number of attacks per origin/target (refer to `limitDirection` - // parameter) location. - LimitPerLocation param.Field[int64] `query:"limitPerLocation"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Attack magnitude can be defined by total requests mitigated or by total zones - // attacked. - Magnitude param.Field[RadarAttackLayer7TopAttacksParamsMagnitude] `query:"magnitude"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAttackLayer7TopAttacksParams]'s query parameters as -// `url.Values`. -func (r RadarAttackLayer7TopAttacksParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer7TopAttacksParamsDateRange string - -const ( - RadarAttackLayer7TopAttacksParamsDateRange1d RadarAttackLayer7TopAttacksParamsDateRange = "1d" - RadarAttackLayer7TopAttacksParamsDateRange2d RadarAttackLayer7TopAttacksParamsDateRange = "2d" - RadarAttackLayer7TopAttacksParamsDateRange7d RadarAttackLayer7TopAttacksParamsDateRange = "7d" - RadarAttackLayer7TopAttacksParamsDateRange14d RadarAttackLayer7TopAttacksParamsDateRange = "14d" - RadarAttackLayer7TopAttacksParamsDateRange28d RadarAttackLayer7TopAttacksParamsDateRange = "28d" - RadarAttackLayer7TopAttacksParamsDateRange12w RadarAttackLayer7TopAttacksParamsDateRange = "12w" - RadarAttackLayer7TopAttacksParamsDateRange24w RadarAttackLayer7TopAttacksParamsDateRange = "24w" - RadarAttackLayer7TopAttacksParamsDateRange52w RadarAttackLayer7TopAttacksParamsDateRange = "52w" - RadarAttackLayer7TopAttacksParamsDateRange1dControl RadarAttackLayer7TopAttacksParamsDateRange = "1dControl" - RadarAttackLayer7TopAttacksParamsDateRange2dControl RadarAttackLayer7TopAttacksParamsDateRange = "2dControl" - RadarAttackLayer7TopAttacksParamsDateRange7dControl RadarAttackLayer7TopAttacksParamsDateRange = "7dControl" - RadarAttackLayer7TopAttacksParamsDateRange14dControl RadarAttackLayer7TopAttacksParamsDateRange = "14dControl" - RadarAttackLayer7TopAttacksParamsDateRange28dControl RadarAttackLayer7TopAttacksParamsDateRange = "28dControl" - RadarAttackLayer7TopAttacksParamsDateRange12wControl RadarAttackLayer7TopAttacksParamsDateRange = "12wControl" - RadarAttackLayer7TopAttacksParamsDateRange24wControl RadarAttackLayer7TopAttacksParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7TopAttacksParamsFormat string - -const ( - RadarAttackLayer7TopAttacksParamsFormatJson RadarAttackLayer7TopAttacksParamsFormat = "JSON" - RadarAttackLayer7TopAttacksParamsFormatCsv RadarAttackLayer7TopAttacksParamsFormat = "CSV" -) - -// Array of attack origin/target location attack limits. Together with -// `limitPerLocation`, limits how many objects will be fetched per origin/target -// location. -type RadarAttackLayer7TopAttacksParamsLimitDirection string - -const ( - RadarAttackLayer7TopAttacksParamsLimitDirectionOrigin RadarAttackLayer7TopAttacksParamsLimitDirection = "ORIGIN" - RadarAttackLayer7TopAttacksParamsLimitDirectionTarget RadarAttackLayer7TopAttacksParamsLimitDirection = "TARGET" -) - -// Attack magnitude can be defined by total requests mitigated or by total zones -// attacked. -type RadarAttackLayer7TopAttacksParamsMagnitude string - -const ( - RadarAttackLayer7TopAttacksParamsMagnitudeAffectedZones RadarAttackLayer7TopAttacksParamsMagnitude = "AFFECTED_ZONES" - RadarAttackLayer7TopAttacksParamsMagnitudeMitigatedRequests RadarAttackLayer7TopAttacksParamsMagnitude = "MITIGATED_REQUESTS" -) - -type RadarAttackLayer7TopAttacksResponseEnvelope struct { - Result RadarAttackLayer7TopAttacksResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7TopAttacksResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7TopAttacksResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarAttackLayer7TopAttacksResponseEnvelope] -type radarAttackLayer7TopAttacksResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopAttacksResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopAttacksResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopIndustryParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7TopIndustryParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7TopIndustryParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAttackLayer7TopIndustryParams]'s query parameters as -// `url.Values`. -func (r RadarAttackLayer7TopIndustryParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer7TopIndustryParamsDateRange string - -const ( - RadarAttackLayer7TopIndustryParamsDateRange1d RadarAttackLayer7TopIndustryParamsDateRange = "1d" - RadarAttackLayer7TopIndustryParamsDateRange2d RadarAttackLayer7TopIndustryParamsDateRange = "2d" - RadarAttackLayer7TopIndustryParamsDateRange7d RadarAttackLayer7TopIndustryParamsDateRange = "7d" - RadarAttackLayer7TopIndustryParamsDateRange14d RadarAttackLayer7TopIndustryParamsDateRange = "14d" - RadarAttackLayer7TopIndustryParamsDateRange28d RadarAttackLayer7TopIndustryParamsDateRange = "28d" - RadarAttackLayer7TopIndustryParamsDateRange12w RadarAttackLayer7TopIndustryParamsDateRange = "12w" - RadarAttackLayer7TopIndustryParamsDateRange24w RadarAttackLayer7TopIndustryParamsDateRange = "24w" - RadarAttackLayer7TopIndustryParamsDateRange52w RadarAttackLayer7TopIndustryParamsDateRange = "52w" - RadarAttackLayer7TopIndustryParamsDateRange1dControl RadarAttackLayer7TopIndustryParamsDateRange = "1dControl" - RadarAttackLayer7TopIndustryParamsDateRange2dControl RadarAttackLayer7TopIndustryParamsDateRange = "2dControl" - RadarAttackLayer7TopIndustryParamsDateRange7dControl RadarAttackLayer7TopIndustryParamsDateRange = "7dControl" - RadarAttackLayer7TopIndustryParamsDateRange14dControl RadarAttackLayer7TopIndustryParamsDateRange = "14dControl" - RadarAttackLayer7TopIndustryParamsDateRange28dControl RadarAttackLayer7TopIndustryParamsDateRange = "28dControl" - RadarAttackLayer7TopIndustryParamsDateRange12wControl RadarAttackLayer7TopIndustryParamsDateRange = "12wControl" - RadarAttackLayer7TopIndustryParamsDateRange24wControl RadarAttackLayer7TopIndustryParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7TopIndustryParamsFormat string - -const ( - RadarAttackLayer7TopIndustryParamsFormatJson RadarAttackLayer7TopIndustryParamsFormat = "JSON" - RadarAttackLayer7TopIndustryParamsFormatCsv RadarAttackLayer7TopIndustryParamsFormat = "CSV" -) - -type RadarAttackLayer7TopIndustryResponseEnvelope struct { - Result RadarAttackLayer7TopIndustryResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7TopIndustryResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7TopIndustryResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarAttackLayer7TopIndustryResponseEnvelope] -type radarAttackLayer7TopIndustryResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopIndustryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopIndustryResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopVerticalParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7TopVerticalParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7TopVerticalParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAttackLayer7TopVerticalParams]'s query parameters as -// `url.Values`. -func (r RadarAttackLayer7TopVerticalParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer7TopVerticalParamsDateRange string - -const ( - RadarAttackLayer7TopVerticalParamsDateRange1d RadarAttackLayer7TopVerticalParamsDateRange = "1d" - RadarAttackLayer7TopVerticalParamsDateRange2d RadarAttackLayer7TopVerticalParamsDateRange = "2d" - RadarAttackLayer7TopVerticalParamsDateRange7d RadarAttackLayer7TopVerticalParamsDateRange = "7d" - RadarAttackLayer7TopVerticalParamsDateRange14d RadarAttackLayer7TopVerticalParamsDateRange = "14d" - RadarAttackLayer7TopVerticalParamsDateRange28d RadarAttackLayer7TopVerticalParamsDateRange = "28d" - RadarAttackLayer7TopVerticalParamsDateRange12w RadarAttackLayer7TopVerticalParamsDateRange = "12w" - RadarAttackLayer7TopVerticalParamsDateRange24w RadarAttackLayer7TopVerticalParamsDateRange = "24w" - RadarAttackLayer7TopVerticalParamsDateRange52w RadarAttackLayer7TopVerticalParamsDateRange = "52w" - RadarAttackLayer7TopVerticalParamsDateRange1dControl RadarAttackLayer7TopVerticalParamsDateRange = "1dControl" - RadarAttackLayer7TopVerticalParamsDateRange2dControl RadarAttackLayer7TopVerticalParamsDateRange = "2dControl" - RadarAttackLayer7TopVerticalParamsDateRange7dControl RadarAttackLayer7TopVerticalParamsDateRange = "7dControl" - RadarAttackLayer7TopVerticalParamsDateRange14dControl RadarAttackLayer7TopVerticalParamsDateRange = "14dControl" - RadarAttackLayer7TopVerticalParamsDateRange28dControl RadarAttackLayer7TopVerticalParamsDateRange = "28dControl" - RadarAttackLayer7TopVerticalParamsDateRange12wControl RadarAttackLayer7TopVerticalParamsDateRange = "12wControl" - RadarAttackLayer7TopVerticalParamsDateRange24wControl RadarAttackLayer7TopVerticalParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7TopVerticalParamsFormat string - -const ( - RadarAttackLayer7TopVerticalParamsFormatJson RadarAttackLayer7TopVerticalParamsFormat = "JSON" - RadarAttackLayer7TopVerticalParamsFormatCsv RadarAttackLayer7TopVerticalParamsFormat = "CSV" -) - -type RadarAttackLayer7TopVerticalResponseEnvelope struct { - Result RadarAttackLayer7TopVerticalResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7TopVerticalResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7TopVerticalResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarAttackLayer7TopVerticalResponseEnvelope] -type radarAttackLayer7TopVerticalResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopVerticalResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopVerticalResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarattacklayer7top_test.go b/radarattacklayer7top_test.go deleted file mode 100644 index 44e921138d7..00000000000 --- a/radarattacklayer7top_test.go +++ /dev/null @@ -1,120 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarAttackLayer7TopAttacksWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.Top.Attacks(context.TODO(), cloudflare.RadarAttackLayer7TopAttacksParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7TopAttacksParamsDateRange{cloudflare.RadarAttackLayer7TopAttacksParamsDateRange1d, cloudflare.RadarAttackLayer7TopAttacksParamsDateRange2d, cloudflare.RadarAttackLayer7TopAttacksParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7TopAttacksParamsFormatJson), - Limit: cloudflare.F(int64(5)), - LimitDirection: cloudflare.F(cloudflare.RadarAttackLayer7TopAttacksParamsLimitDirectionOrigin), - LimitPerLocation: cloudflare.F(int64(10)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Magnitude: cloudflare.F(cloudflare.RadarAttackLayer7TopAttacksParamsMagnitudeMitigatedRequests), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAttackLayer7TopIndustryWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.Top.Industry(context.TODO(), cloudflare.RadarAttackLayer7TopIndustryParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7TopIndustryParamsDateRange{cloudflare.RadarAttackLayer7TopIndustryParamsDateRange1d, cloudflare.RadarAttackLayer7TopIndustryParamsDateRange2d, cloudflare.RadarAttackLayer7TopIndustryParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7TopIndustryParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAttackLayer7TopVerticalWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.Top.Vertical(context.TODO(), cloudflare.RadarAttackLayer7TopVerticalParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7TopVerticalParamsDateRange{cloudflare.RadarAttackLayer7TopVerticalParamsDateRange1d, cloudflare.RadarAttackLayer7TopVerticalParamsDateRange2d, cloudflare.RadarAttackLayer7TopVerticalParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7TopVerticalParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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/radarattacklayer7topase.go b/radarattacklayer7topase.go deleted file mode 100644 index 750145f3d60..00000000000 --- a/radarattacklayer7topase.go +++ /dev/null @@ -1,292 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarAttackLayer7TopAseService 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 -// [NewRadarAttackLayer7TopAseService] method instead. -type RadarAttackLayer7TopAseService struct { - Options []option.RequestOption -} - -// NewRadarAttackLayer7TopAseService 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 NewRadarAttackLayer7TopAseService(opts ...option.RequestOption) (r *RadarAttackLayer7TopAseService) { - r = &RadarAttackLayer7TopAseService{} - r.Options = opts - return -} - -// Get the top origin Autonomous Systems of and by layer 7 attacks. Values are a -// percentage out of the total layer 7 attacks. The origin Autonomous Systems is -// determined by the client IP. -func (r *RadarAttackLayer7TopAseService) Origin(ctx context.Context, query RadarAttackLayer7TopAseOriginParams, opts ...option.RequestOption) (res *RadarAttackLayer7TopAseOriginResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7TopAseOriginResponseEnvelope - path := "radar/attacks/layer7/top/ases/origin" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarAttackLayer7TopAseOriginResponse struct { - Meta RadarAttackLayer7TopAseOriginResponseMeta `json:"meta,required"` - Top0 []RadarAttackLayer7TopAseOriginResponseTop0 `json:"top_0,required"` - JSON radarAttackLayer7TopAseOriginResponseJSON `json:"-"` -} - -// radarAttackLayer7TopAseOriginResponseJSON contains the JSON metadata for the -// struct [RadarAttackLayer7TopAseOriginResponse] -type radarAttackLayer7TopAseOriginResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopAseOriginResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopAseOriginResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopAseOriginResponseMeta struct { - DateRange []RadarAttackLayer7TopAseOriginResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarAttackLayer7TopAseOriginResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer7TopAseOriginResponseMetaJSON `json:"-"` -} - -// radarAttackLayer7TopAseOriginResponseMetaJSON contains the JSON metadata for the -// struct [RadarAttackLayer7TopAseOriginResponseMeta] -type radarAttackLayer7TopAseOriginResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopAseOriginResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopAseOriginResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopAseOriginResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer7TopAseOriginResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer7TopAseOriginResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarAttackLayer7TopAseOriginResponseMetaDateRange] -type radarAttackLayer7TopAseOriginResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopAseOriginResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopAseOriginResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopAseOriginResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer7TopAseOriginResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer7TopAseOriginResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer7TopAseOriginResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer7TopAseOriginResponseMetaConfidenceInfo] -type radarAttackLayer7TopAseOriginResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopAseOriginResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopAseOriginResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopAseOriginResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer7TopAseOriginResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer7TopAseOriginResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarAttackLayer7TopAseOriginResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer7TopAseOriginResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopAseOriginResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopAseOriginResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopAseOriginResponseTop0 struct { - OriginASN string `json:"originAsn,required"` - OriginASNName string `json:"originAsnName,required"` - Rank float64 `json:"rank,required"` - Value string `json:"value,required"` - JSON radarAttackLayer7TopAseOriginResponseTop0JSON `json:"-"` -} - -// radarAttackLayer7TopAseOriginResponseTop0JSON contains the JSON metadata for the -// struct [RadarAttackLayer7TopAseOriginResponseTop0] -type radarAttackLayer7TopAseOriginResponseTop0JSON struct { - OriginASN apijson.Field - OriginASNName apijson.Field - Rank apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopAseOriginResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopAseOriginResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopAseOriginParams struct { - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7TopAseOriginParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7TopAseOriginParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAttackLayer7TopAseOriginParams]'s query parameters as -// `url.Values`. -func (r RadarAttackLayer7TopAseOriginParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer7TopAseOriginParamsDateRange string - -const ( - RadarAttackLayer7TopAseOriginParamsDateRange1d RadarAttackLayer7TopAseOriginParamsDateRange = "1d" - RadarAttackLayer7TopAseOriginParamsDateRange2d RadarAttackLayer7TopAseOriginParamsDateRange = "2d" - RadarAttackLayer7TopAseOriginParamsDateRange7d RadarAttackLayer7TopAseOriginParamsDateRange = "7d" - RadarAttackLayer7TopAseOriginParamsDateRange14d RadarAttackLayer7TopAseOriginParamsDateRange = "14d" - RadarAttackLayer7TopAseOriginParamsDateRange28d RadarAttackLayer7TopAseOriginParamsDateRange = "28d" - RadarAttackLayer7TopAseOriginParamsDateRange12w RadarAttackLayer7TopAseOriginParamsDateRange = "12w" - RadarAttackLayer7TopAseOriginParamsDateRange24w RadarAttackLayer7TopAseOriginParamsDateRange = "24w" - RadarAttackLayer7TopAseOriginParamsDateRange52w RadarAttackLayer7TopAseOriginParamsDateRange = "52w" - RadarAttackLayer7TopAseOriginParamsDateRange1dControl RadarAttackLayer7TopAseOriginParamsDateRange = "1dControl" - RadarAttackLayer7TopAseOriginParamsDateRange2dControl RadarAttackLayer7TopAseOriginParamsDateRange = "2dControl" - RadarAttackLayer7TopAseOriginParamsDateRange7dControl RadarAttackLayer7TopAseOriginParamsDateRange = "7dControl" - RadarAttackLayer7TopAseOriginParamsDateRange14dControl RadarAttackLayer7TopAseOriginParamsDateRange = "14dControl" - RadarAttackLayer7TopAseOriginParamsDateRange28dControl RadarAttackLayer7TopAseOriginParamsDateRange = "28dControl" - RadarAttackLayer7TopAseOriginParamsDateRange12wControl RadarAttackLayer7TopAseOriginParamsDateRange = "12wControl" - RadarAttackLayer7TopAseOriginParamsDateRange24wControl RadarAttackLayer7TopAseOriginParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7TopAseOriginParamsFormat string - -const ( - RadarAttackLayer7TopAseOriginParamsFormatJson RadarAttackLayer7TopAseOriginParamsFormat = "JSON" - RadarAttackLayer7TopAseOriginParamsFormatCsv RadarAttackLayer7TopAseOriginParamsFormat = "CSV" -) - -type RadarAttackLayer7TopAseOriginResponseEnvelope struct { - Result RadarAttackLayer7TopAseOriginResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7TopAseOriginResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7TopAseOriginResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarAttackLayer7TopAseOriginResponseEnvelope] -type radarAttackLayer7TopAseOriginResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopAseOriginResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopAseOriginResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarattacklayer7topase_test.go b/radarattacklayer7topase_test.go deleted file mode 100644 index 8c0eb989cbc..00000000000 --- a/radarattacklayer7topase_test.go +++ /dev/null @@ -1,48 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarAttackLayer7TopAseOriginWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.Top.Ases.Origin(context.TODO(), cloudflare.RadarAttackLayer7TopAseOriginParams{ - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7TopAseOriginParamsDateRange{cloudflare.RadarAttackLayer7TopAseOriginParamsDateRange1d, cloudflare.RadarAttackLayer7TopAseOriginParamsDateRange2d, cloudflare.RadarAttackLayer7TopAseOriginParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7TopAseOriginParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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/radarattacklayer7toplocation.go b/radarattacklayer7toplocation.go deleted file mode 100644 index 7dd8145414d..00000000000 --- a/radarattacklayer7toplocation.go +++ /dev/null @@ -1,548 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarAttackLayer7TopLocationService 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 -// [NewRadarAttackLayer7TopLocationService] method instead. -type RadarAttackLayer7TopLocationService struct { - Options []option.RequestOption -} - -// NewRadarAttackLayer7TopLocationService 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 NewRadarAttackLayer7TopLocationService(opts ...option.RequestOption) (r *RadarAttackLayer7TopLocationService) { - r = &RadarAttackLayer7TopLocationService{} - r.Options = opts - return -} - -// Get the top origin locations of and by layer 7 attacks. Values are a percentage -// out of the total layer 7 attacks. The origin location is determined by the -// client IP. -func (r *RadarAttackLayer7TopLocationService) Origin(ctx context.Context, query RadarAttackLayer7TopLocationOriginParams, opts ...option.RequestOption) (res *RadarAttackLayer7TopLocationOriginResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7TopLocationOriginResponseEnvelope - path := "radar/attacks/layer7/top/locations/origin" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the top target locations of and by layer 7 attacks. Values are a percentage -// out of the total layer 7 attacks. The target location is determined by the -// attacked zone's billing country, when available. -func (r *RadarAttackLayer7TopLocationService) Target(ctx context.Context, query RadarAttackLayer7TopLocationTargetParams, opts ...option.RequestOption) (res *RadarAttackLayer7TopLocationTargetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarAttackLayer7TopLocationTargetResponseEnvelope - path := "radar/attacks/layer7/top/locations/target" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarAttackLayer7TopLocationOriginResponse struct { - Meta RadarAttackLayer7TopLocationOriginResponseMeta `json:"meta,required"` - Top0 []RadarAttackLayer7TopLocationOriginResponseTop0 `json:"top_0,required"` - JSON radarAttackLayer7TopLocationOriginResponseJSON `json:"-"` -} - -// radarAttackLayer7TopLocationOriginResponseJSON contains the JSON metadata for -// the struct [RadarAttackLayer7TopLocationOriginResponse] -type radarAttackLayer7TopLocationOriginResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopLocationOriginResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopLocationOriginResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopLocationOriginResponseMeta struct { - DateRange []RadarAttackLayer7TopLocationOriginResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarAttackLayer7TopLocationOriginResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer7TopLocationOriginResponseMetaJSON `json:"-"` -} - -// radarAttackLayer7TopLocationOriginResponseMetaJSON contains the JSON metadata -// for the struct [RadarAttackLayer7TopLocationOriginResponseMeta] -type radarAttackLayer7TopLocationOriginResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopLocationOriginResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopLocationOriginResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopLocationOriginResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer7TopLocationOriginResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer7TopLocationOriginResponseMetaDateRangeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer7TopLocationOriginResponseMetaDateRange] -type radarAttackLayer7TopLocationOriginResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopLocationOriginResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopLocationOriginResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopLocationOriginResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer7TopLocationOriginResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer7TopLocationOriginResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer7TopLocationOriginResponseMetaConfidenceInfoJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer7TopLocationOriginResponseMetaConfidenceInfo] -type radarAttackLayer7TopLocationOriginResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopLocationOriginResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopLocationOriginResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopLocationOriginResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer7TopLocationOriginResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer7TopLocationOriginResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarAttackLayer7TopLocationOriginResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer7TopLocationOriginResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopLocationOriginResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopLocationOriginResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopLocationOriginResponseTop0 struct { - OriginCountryAlpha2 string `json:"originCountryAlpha2,required"` - OriginCountryName string `json:"originCountryName,required"` - Rank float64 `json:"rank,required"` - Value string `json:"value,required"` - JSON radarAttackLayer7TopLocationOriginResponseTop0JSON `json:"-"` -} - -// radarAttackLayer7TopLocationOriginResponseTop0JSON contains the JSON metadata -// for the struct [RadarAttackLayer7TopLocationOriginResponseTop0] -type radarAttackLayer7TopLocationOriginResponseTop0JSON struct { - OriginCountryAlpha2 apijson.Field - OriginCountryName apijson.Field - Rank apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopLocationOriginResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopLocationOriginResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopLocationTargetResponse struct { - Meta RadarAttackLayer7TopLocationTargetResponseMeta `json:"meta,required"` - Top0 []RadarAttackLayer7TopLocationTargetResponseTop0 `json:"top_0,required"` - JSON radarAttackLayer7TopLocationTargetResponseJSON `json:"-"` -} - -// radarAttackLayer7TopLocationTargetResponseJSON contains the JSON metadata for -// the struct [RadarAttackLayer7TopLocationTargetResponse] -type radarAttackLayer7TopLocationTargetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopLocationTargetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopLocationTargetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopLocationTargetResponseMeta struct { - DateRange []RadarAttackLayer7TopLocationTargetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarAttackLayer7TopLocationTargetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarAttackLayer7TopLocationTargetResponseMetaJSON `json:"-"` -} - -// radarAttackLayer7TopLocationTargetResponseMetaJSON contains the JSON metadata -// for the struct [RadarAttackLayer7TopLocationTargetResponseMeta] -type radarAttackLayer7TopLocationTargetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopLocationTargetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopLocationTargetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopLocationTargetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarAttackLayer7TopLocationTargetResponseMetaDateRangeJSON `json:"-"` -} - -// radarAttackLayer7TopLocationTargetResponseMetaDateRangeJSON contains the JSON -// metadata for the struct -// [RadarAttackLayer7TopLocationTargetResponseMetaDateRange] -type radarAttackLayer7TopLocationTargetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopLocationTargetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopLocationTargetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopLocationTargetResponseMetaConfidenceInfo struct { - Annotations []RadarAttackLayer7TopLocationTargetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarAttackLayer7TopLocationTargetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarAttackLayer7TopLocationTargetResponseMetaConfidenceInfoJSON contains the -// JSON metadata for the struct -// [RadarAttackLayer7TopLocationTargetResponseMetaConfidenceInfo] -type radarAttackLayer7TopLocationTargetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopLocationTargetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopLocationTargetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopLocationTargetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarAttackLayer7TopLocationTargetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarAttackLayer7TopLocationTargetResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarAttackLayer7TopLocationTargetResponseMetaConfidenceInfoAnnotation] -type radarAttackLayer7TopLocationTargetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopLocationTargetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopLocationTargetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopLocationTargetResponseTop0 struct { - Rank float64 `json:"rank,required"` - TargetCountryAlpha2 string `json:"targetCountryAlpha2,required"` - TargetCountryName string `json:"targetCountryName,required"` - Value string `json:"value,required"` - JSON radarAttackLayer7TopLocationTargetResponseTop0JSON `json:"-"` -} - -// radarAttackLayer7TopLocationTargetResponseTop0JSON contains the JSON metadata -// for the struct [RadarAttackLayer7TopLocationTargetResponseTop0] -type radarAttackLayer7TopLocationTargetResponseTop0JSON struct { - Rank apijson.Field - TargetCountryAlpha2 apijson.Field - TargetCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopLocationTargetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopLocationTargetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopLocationOriginParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7TopLocationOriginParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7TopLocationOriginParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAttackLayer7TopLocationOriginParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer7TopLocationOriginParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer7TopLocationOriginParamsDateRange string - -const ( - RadarAttackLayer7TopLocationOriginParamsDateRange1d RadarAttackLayer7TopLocationOriginParamsDateRange = "1d" - RadarAttackLayer7TopLocationOriginParamsDateRange2d RadarAttackLayer7TopLocationOriginParamsDateRange = "2d" - RadarAttackLayer7TopLocationOriginParamsDateRange7d RadarAttackLayer7TopLocationOriginParamsDateRange = "7d" - RadarAttackLayer7TopLocationOriginParamsDateRange14d RadarAttackLayer7TopLocationOriginParamsDateRange = "14d" - RadarAttackLayer7TopLocationOriginParamsDateRange28d RadarAttackLayer7TopLocationOriginParamsDateRange = "28d" - RadarAttackLayer7TopLocationOriginParamsDateRange12w RadarAttackLayer7TopLocationOriginParamsDateRange = "12w" - RadarAttackLayer7TopLocationOriginParamsDateRange24w RadarAttackLayer7TopLocationOriginParamsDateRange = "24w" - RadarAttackLayer7TopLocationOriginParamsDateRange52w RadarAttackLayer7TopLocationOriginParamsDateRange = "52w" - RadarAttackLayer7TopLocationOriginParamsDateRange1dControl RadarAttackLayer7TopLocationOriginParamsDateRange = "1dControl" - RadarAttackLayer7TopLocationOriginParamsDateRange2dControl RadarAttackLayer7TopLocationOriginParamsDateRange = "2dControl" - RadarAttackLayer7TopLocationOriginParamsDateRange7dControl RadarAttackLayer7TopLocationOriginParamsDateRange = "7dControl" - RadarAttackLayer7TopLocationOriginParamsDateRange14dControl RadarAttackLayer7TopLocationOriginParamsDateRange = "14dControl" - RadarAttackLayer7TopLocationOriginParamsDateRange28dControl RadarAttackLayer7TopLocationOriginParamsDateRange = "28dControl" - RadarAttackLayer7TopLocationOriginParamsDateRange12wControl RadarAttackLayer7TopLocationOriginParamsDateRange = "12wControl" - RadarAttackLayer7TopLocationOriginParamsDateRange24wControl RadarAttackLayer7TopLocationOriginParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7TopLocationOriginParamsFormat string - -const ( - RadarAttackLayer7TopLocationOriginParamsFormatJson RadarAttackLayer7TopLocationOriginParamsFormat = "JSON" - RadarAttackLayer7TopLocationOriginParamsFormatCsv RadarAttackLayer7TopLocationOriginParamsFormat = "CSV" -) - -type RadarAttackLayer7TopLocationOriginResponseEnvelope struct { - Result RadarAttackLayer7TopLocationOriginResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7TopLocationOriginResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7TopLocationOriginResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarAttackLayer7TopLocationOriginResponseEnvelope] -type radarAttackLayer7TopLocationOriginResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopLocationOriginResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopLocationOriginResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarAttackLayer7TopLocationTargetParams struct { - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarAttackLayer7TopLocationTargetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarAttackLayer7TopLocationTargetParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarAttackLayer7TopLocationTargetParams]'s query -// parameters as `url.Values`. -func (r RadarAttackLayer7TopLocationTargetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarAttackLayer7TopLocationTargetParamsDateRange string - -const ( - RadarAttackLayer7TopLocationTargetParamsDateRange1d RadarAttackLayer7TopLocationTargetParamsDateRange = "1d" - RadarAttackLayer7TopLocationTargetParamsDateRange2d RadarAttackLayer7TopLocationTargetParamsDateRange = "2d" - RadarAttackLayer7TopLocationTargetParamsDateRange7d RadarAttackLayer7TopLocationTargetParamsDateRange = "7d" - RadarAttackLayer7TopLocationTargetParamsDateRange14d RadarAttackLayer7TopLocationTargetParamsDateRange = "14d" - RadarAttackLayer7TopLocationTargetParamsDateRange28d RadarAttackLayer7TopLocationTargetParamsDateRange = "28d" - RadarAttackLayer7TopLocationTargetParamsDateRange12w RadarAttackLayer7TopLocationTargetParamsDateRange = "12w" - RadarAttackLayer7TopLocationTargetParamsDateRange24w RadarAttackLayer7TopLocationTargetParamsDateRange = "24w" - RadarAttackLayer7TopLocationTargetParamsDateRange52w RadarAttackLayer7TopLocationTargetParamsDateRange = "52w" - RadarAttackLayer7TopLocationTargetParamsDateRange1dControl RadarAttackLayer7TopLocationTargetParamsDateRange = "1dControl" - RadarAttackLayer7TopLocationTargetParamsDateRange2dControl RadarAttackLayer7TopLocationTargetParamsDateRange = "2dControl" - RadarAttackLayer7TopLocationTargetParamsDateRange7dControl RadarAttackLayer7TopLocationTargetParamsDateRange = "7dControl" - RadarAttackLayer7TopLocationTargetParamsDateRange14dControl RadarAttackLayer7TopLocationTargetParamsDateRange = "14dControl" - RadarAttackLayer7TopLocationTargetParamsDateRange28dControl RadarAttackLayer7TopLocationTargetParamsDateRange = "28dControl" - RadarAttackLayer7TopLocationTargetParamsDateRange12wControl RadarAttackLayer7TopLocationTargetParamsDateRange = "12wControl" - RadarAttackLayer7TopLocationTargetParamsDateRange24wControl RadarAttackLayer7TopLocationTargetParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarAttackLayer7TopLocationTargetParamsFormat string - -const ( - RadarAttackLayer7TopLocationTargetParamsFormatJson RadarAttackLayer7TopLocationTargetParamsFormat = "JSON" - RadarAttackLayer7TopLocationTargetParamsFormatCsv RadarAttackLayer7TopLocationTargetParamsFormat = "CSV" -) - -type RadarAttackLayer7TopLocationTargetResponseEnvelope struct { - Result RadarAttackLayer7TopLocationTargetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarAttackLayer7TopLocationTargetResponseEnvelopeJSON `json:"-"` -} - -// radarAttackLayer7TopLocationTargetResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarAttackLayer7TopLocationTargetResponseEnvelope] -type radarAttackLayer7TopLocationTargetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarAttackLayer7TopLocationTargetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarAttackLayer7TopLocationTargetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarattacklayer7toplocation_test.go b/radarattacklayer7toplocation_test.go deleted file mode 100644 index 257167b2b74..00000000000 --- a/radarattacklayer7toplocation_test.go +++ /dev/null @@ -1,80 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarAttackLayer7TopLocationOriginWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.Top.Locations.Origin(context.TODO(), cloudflare.RadarAttackLayer7TopLocationOriginParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7TopLocationOriginParamsDateRange{cloudflare.RadarAttackLayer7TopLocationOriginParamsDateRange1d, cloudflare.RadarAttackLayer7TopLocationOriginParamsDateRange2d, cloudflare.RadarAttackLayer7TopLocationOriginParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7TopLocationOriginParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarAttackLayer7TopLocationTargetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Attacks.Layer7.Top.Locations.Target(context.TODO(), cloudflare.RadarAttackLayer7TopLocationTargetParams{ - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarAttackLayer7TopLocationTargetParamsDateRange{cloudflare.RadarAttackLayer7TopLocationTargetParamsDateRange1d, cloudflare.RadarAttackLayer7TopLocationTargetParamsDateRange2d, cloudflare.RadarAttackLayer7TopLocationTargetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarAttackLayer7TopLocationTargetParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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/radarbgp.go b/radarbgp.go deleted file mode 100644 index 7cbfaf0e004..00000000000 --- a/radarbgp.go +++ /dev/null @@ -1,316 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarBGPService 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 [NewRadarBGPService] method instead. -type RadarBGPService struct { - Options []option.RequestOption - Leaks *RadarBGPLeakService - Top *RadarBGPTopService - Hijacks *RadarBGPHijackService - Routes *RadarBGPRouteService -} - -// NewRadarBGPService 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 NewRadarBGPService(opts ...option.RequestOption) (r *RadarBGPService) { - r = &RadarBGPService{} - r.Options = opts - r.Leaks = NewRadarBGPLeakService(opts...) - r.Top = NewRadarBGPTopService(opts...) - r.Hijacks = NewRadarBGPHijackService(opts...) - r.Routes = NewRadarBGPRouteService(opts...) - return -} - -// Gets BGP updates change over time. Raw values are returned. When requesting -// updates of an autonomous system (AS), only BGP updates of type announcement are -// returned. -func (r *RadarBGPService) Timeseries(ctx context.Context, query RadarBGPTimeseriesParams, opts ...option.RequestOption) (res *RadarBGPTimeseriesResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarBGPTimeseriesResponseEnvelope - path := "radar/bgp/timeseries" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarBGPTimeseriesResponse struct { - Meta RadarBGPTimeseriesResponseMeta `json:"meta,required"` - Serie0 RadarBGPTimeseriesResponseSerie0 `json:"serie_0,required"` - JSON radarBGPTimeseriesResponseJSON `json:"-"` -} - -// radarBGPTimeseriesResponseJSON contains the JSON metadata for the struct -// [RadarBGPTimeseriesResponse] -type radarBGPTimeseriesResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTimeseriesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTimeseriesResponseJSON) RawJSON() string { - return r.raw -} - -type RadarBGPTimeseriesResponseMeta struct { - AggInterval string `json:"aggInterval,required"` - DateRange []RadarBGPTimeseriesResponseMetaDateRange `json:"dateRange,required"` - LastUpdated time.Time `json:"lastUpdated,required" format:"date-time"` - ConfidenceInfo RadarBGPTimeseriesResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarBGPTimeseriesResponseMetaJSON `json:"-"` -} - -// radarBGPTimeseriesResponseMetaJSON contains the JSON metadata for the struct -// [RadarBGPTimeseriesResponseMeta] -type radarBGPTimeseriesResponseMetaJSON struct { - AggInterval apijson.Field - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTimeseriesResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTimeseriesResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarBGPTimeseriesResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarBGPTimeseriesResponseMetaDateRangeJSON `json:"-"` -} - -// radarBGPTimeseriesResponseMetaDateRangeJSON contains the JSON metadata for the -// struct [RadarBGPTimeseriesResponseMetaDateRange] -type radarBGPTimeseriesResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTimeseriesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTimeseriesResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarBGPTimeseriesResponseMetaConfidenceInfo struct { - Annotations []RadarBGPTimeseriesResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarBGPTimeseriesResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarBGPTimeseriesResponseMetaConfidenceInfoJSON contains the JSON metadata for -// the struct [RadarBGPTimeseriesResponseMetaConfidenceInfo] -type radarBGPTimeseriesResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTimeseriesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTimeseriesResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarBGPTimeseriesResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarBGPTimeseriesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarBGPTimeseriesResponseMetaConfidenceInfoAnnotationJSON contains the JSON -// metadata for the struct [RadarBGPTimeseriesResponseMetaConfidenceInfoAnnotation] -type radarBGPTimeseriesResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTimeseriesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTimeseriesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarBGPTimeseriesResponseSerie0 struct { - Timestamps []time.Time `json:"timestamps,required" format:"date-time"` - Values []string `json:"values,required"` - JSON radarBGPTimeseriesResponseSerie0JSON `json:"-"` -} - -// radarBGPTimeseriesResponseSerie0JSON contains the JSON metadata for the struct -// [RadarBGPTimeseriesResponseSerie0] -type radarBGPTimeseriesResponseSerie0JSON struct { - Timestamps apijson.Field - Values apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTimeseriesResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTimeseriesResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarBGPTimeseriesParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarBGPTimeseriesParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarBGPTimeseriesParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarBGPTimeseriesParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Array of BGP network prefixes. - Prefix param.Field[[]string] `query:"prefix"` - // Array of BGP update types. - UpdateType param.Field[[]RadarBGPTimeseriesParamsUpdateType] `query:"updateType"` -} - -// URLQuery serializes [RadarBGPTimeseriesParams]'s query parameters as -// `url.Values`. -func (r RadarBGPTimeseriesParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarBGPTimeseriesParamsAggInterval string - -const ( - RadarBGPTimeseriesParamsAggInterval15m RadarBGPTimeseriesParamsAggInterval = "15m" - RadarBGPTimeseriesParamsAggInterval1h RadarBGPTimeseriesParamsAggInterval = "1h" - RadarBGPTimeseriesParamsAggInterval1d RadarBGPTimeseriesParamsAggInterval = "1d" - RadarBGPTimeseriesParamsAggInterval1w RadarBGPTimeseriesParamsAggInterval = "1w" -) - -type RadarBGPTimeseriesParamsDateRange string - -const ( - RadarBGPTimeseriesParamsDateRange1d RadarBGPTimeseriesParamsDateRange = "1d" - RadarBGPTimeseriesParamsDateRange2d RadarBGPTimeseriesParamsDateRange = "2d" - RadarBGPTimeseriesParamsDateRange7d RadarBGPTimeseriesParamsDateRange = "7d" - RadarBGPTimeseriesParamsDateRange14d RadarBGPTimeseriesParamsDateRange = "14d" - RadarBGPTimeseriesParamsDateRange28d RadarBGPTimeseriesParamsDateRange = "28d" - RadarBGPTimeseriesParamsDateRange12w RadarBGPTimeseriesParamsDateRange = "12w" - RadarBGPTimeseriesParamsDateRange24w RadarBGPTimeseriesParamsDateRange = "24w" - RadarBGPTimeseriesParamsDateRange52w RadarBGPTimeseriesParamsDateRange = "52w" - RadarBGPTimeseriesParamsDateRange1dControl RadarBGPTimeseriesParamsDateRange = "1dControl" - RadarBGPTimeseriesParamsDateRange2dControl RadarBGPTimeseriesParamsDateRange = "2dControl" - RadarBGPTimeseriesParamsDateRange7dControl RadarBGPTimeseriesParamsDateRange = "7dControl" - RadarBGPTimeseriesParamsDateRange14dControl RadarBGPTimeseriesParamsDateRange = "14dControl" - RadarBGPTimeseriesParamsDateRange28dControl RadarBGPTimeseriesParamsDateRange = "28dControl" - RadarBGPTimeseriesParamsDateRange12wControl RadarBGPTimeseriesParamsDateRange = "12wControl" - RadarBGPTimeseriesParamsDateRange24wControl RadarBGPTimeseriesParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarBGPTimeseriesParamsFormat string - -const ( - RadarBGPTimeseriesParamsFormatJson RadarBGPTimeseriesParamsFormat = "JSON" - RadarBGPTimeseriesParamsFormatCsv RadarBGPTimeseriesParamsFormat = "CSV" -) - -type RadarBGPTimeseriesParamsUpdateType string - -const ( - RadarBGPTimeseriesParamsUpdateTypeAnnouncement RadarBGPTimeseriesParamsUpdateType = "ANNOUNCEMENT" - RadarBGPTimeseriesParamsUpdateTypeWithdrawal RadarBGPTimeseriesParamsUpdateType = "WITHDRAWAL" -) - -type RadarBGPTimeseriesResponseEnvelope struct { - Result RadarBGPTimeseriesResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarBGPTimeseriesResponseEnvelopeJSON `json:"-"` -} - -// radarBGPTimeseriesResponseEnvelopeJSON contains the JSON metadata for the struct -// [RadarBGPTimeseriesResponseEnvelope] -type radarBGPTimeseriesResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTimeseriesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTimeseriesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarbgp_test.go b/radarbgp_test.go deleted file mode 100644 index d99d975211d..00000000000 --- a/radarbgp_test.go +++ /dev/null @@ -1,49 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarBGPTimeseriesWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.BGP.Timeseries(context.TODO(), cloudflare.RadarBGPTimeseriesParams{ - AggInterval: cloudflare.F(cloudflare.RadarBGPTimeseriesParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarBGPTimeseriesParamsDateRange{cloudflare.RadarBGPTimeseriesParamsDateRange1d, cloudflare.RadarBGPTimeseriesParamsDateRange2d, cloudflare.RadarBGPTimeseriesParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarBGPTimeseriesParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - Prefix: cloudflare.F([]string{"string", "string", "string"}), - UpdateType: cloudflare.F([]cloudflare.RadarBGPTimeseriesParamsUpdateType{cloudflare.RadarBGPTimeseriesParamsUpdateTypeAnnouncement, cloudflare.RadarBGPTimeseriesParamsUpdateTypeWithdrawal}), - }) - 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/radarbgphijack.go b/radarbgphijack.go deleted file mode 100644 index c224b974d89..00000000000 --- a/radarbgphijack.go +++ /dev/null @@ -1,319 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarBGPHijackService 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 [NewRadarBGPHijackService] method -// instead. -type RadarBGPHijackService struct { - Options []option.RequestOption -} - -// NewRadarBGPHijackService 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 NewRadarBGPHijackService(opts ...option.RequestOption) (r *RadarBGPHijackService) { - r = &RadarBGPHijackService{} - r.Options = opts - return -} - -// Get the BGP hijack events. (Beta) -func (r *RadarBGPHijackService) Events(ctx context.Context, query RadarBGPHijackEventsParams, opts ...option.RequestOption) (res *RadarBGPHijackEventsResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarBGPHijackEventsResponseEnvelope - path := "radar/bgp/hijacks/events" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarBGPHijackEventsResponse struct { - ASNInfo []RadarBGPHijackEventsResponseASNInfo `json:"asn_info,required"` - Events []RadarBGPHijackEventsResponseEvent `json:"events,required"` - TotalMonitors int64 `json:"total_monitors,required"` - JSON radarBGPHijackEventsResponseJSON `json:"-"` -} - -// radarBGPHijackEventsResponseJSON contains the JSON metadata for the struct -// [RadarBGPHijackEventsResponse] -type radarBGPHijackEventsResponseJSON struct { - ASNInfo apijson.Field - Events apijson.Field - TotalMonitors apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPHijackEventsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPHijackEventsResponseJSON) RawJSON() string { - return r.raw -} - -type RadarBGPHijackEventsResponseASNInfo struct { - ASN int64 `json:"asn,required"` - CountryCode string `json:"country_code,required"` - OrgName string `json:"org_name,required"` - JSON radarBGPHijackEventsResponseASNInfoJSON `json:"-"` -} - -// radarBGPHijackEventsResponseASNInfoJSON contains the JSON metadata for the -// struct [RadarBGPHijackEventsResponseASNInfo] -type radarBGPHijackEventsResponseASNInfoJSON struct { - ASN apijson.Field - CountryCode apijson.Field - OrgName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPHijackEventsResponseASNInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPHijackEventsResponseASNInfoJSON) RawJSON() string { - return r.raw -} - -type RadarBGPHijackEventsResponseEvent struct { - ID int64 `json:"id,required"` - ConfidenceScore int64 `json:"confidence_score,required"` - Duration int64 `json:"duration,required"` - EventType int64 `json:"event_type,required"` - HijackMsgsCount int64 `json:"hijack_msgs_count,required"` - HijackerASN int64 `json:"hijacker_asn,required"` - HijackerCountry string `json:"hijacker_country,required"` - IsStale bool `json:"is_stale,required"` - MaxHijackTs string `json:"max_hijack_ts,required"` - MaxMsgTs string `json:"max_msg_ts,required"` - MinHijackTs string `json:"min_hijack_ts,required"` - OnGoingCount int64 `json:"on_going_count,required"` - PeerASNs []int64 `json:"peer_asns,required"` - PeerIPCount int64 `json:"peer_ip_count,required"` - Prefixes []string `json:"prefixes,required"` - Tags []RadarBGPHijackEventsResponseEventsTag `json:"tags,required"` - VictimASNs []int64 `json:"victim_asns,required"` - VictimCountries []string `json:"victim_countries,required"` - JSON radarBGPHijackEventsResponseEventJSON `json:"-"` -} - -// radarBGPHijackEventsResponseEventJSON contains the JSON metadata for the struct -// [RadarBGPHijackEventsResponseEvent] -type radarBGPHijackEventsResponseEventJSON struct { - ID apijson.Field - ConfidenceScore apijson.Field - Duration apijson.Field - EventType apijson.Field - HijackMsgsCount apijson.Field - HijackerASN apijson.Field - HijackerCountry apijson.Field - IsStale apijson.Field - MaxHijackTs apijson.Field - MaxMsgTs apijson.Field - MinHijackTs apijson.Field - OnGoingCount apijson.Field - PeerASNs apijson.Field - PeerIPCount apijson.Field - Prefixes apijson.Field - Tags apijson.Field - VictimASNs apijson.Field - VictimCountries apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPHijackEventsResponseEvent) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPHijackEventsResponseEventJSON) RawJSON() string { - return r.raw -} - -type RadarBGPHijackEventsResponseEventsTag struct { - Name string `json:"name,required"` - Score int64 `json:"score,required"` - JSON radarBGPHijackEventsResponseEventsTagJSON `json:"-"` -} - -// radarBGPHijackEventsResponseEventsTagJSON contains the JSON metadata for the -// struct [RadarBGPHijackEventsResponseEventsTag] -type radarBGPHijackEventsResponseEventsTagJSON struct { - Name apijson.Field - Score apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPHijackEventsResponseEventsTag) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPHijackEventsResponseEventsTagJSON) RawJSON() string { - return r.raw -} - -type RadarBGPHijackEventsParams struct { - // End of the date range (inclusive). - DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"` - // Shorthand date ranges for the last X days - use when you don't need specific - // start and end dates. - DateRange param.Field[RadarBGPHijackEventsParamsDateRange] `query:"dateRange"` - // Start of the date range (inclusive). - DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` - // The unique identifier of a event - EventID param.Field[int64] `query:"eventId"` - // Format results are returned in. - Format param.Field[RadarBGPHijackEventsParamsFormat] `query:"format"` - // The potential hijacker AS of a BGP hijack event - HijackerASN param.Field[int64] `query:"hijackerAsn"` - // The potential hijacker or victim AS of a BGP hijack event - InvolvedASN param.Field[int64] `query:"involvedAsn"` - // The country code of the potential hijacker or victim AS of a BGP hijack event - InvolvedCountry param.Field[string] `query:"involvedCountry"` - // The maximum confidence score to filter events (1-4 low, 5-7 mid, 8+ high) - MaxConfidence param.Field[int64] `query:"maxConfidence"` - // The minimum confidence score to filter events (1-4 low, 5-7 mid, 8+ high) - MinConfidence param.Field[int64] `query:"minConfidence"` - // Current page number, starting from 1 - Page param.Field[int64] `query:"page"` - // Number of entries per page - PerPage param.Field[int64] `query:"per_page"` - // The prefix hijacked during a BGP hijack event - Prefix param.Field[string] `query:"prefix"` - // Sort events by field - SortBy param.Field[RadarBGPHijackEventsParamsSortBy] `query:"sortBy"` - // Sort order - SortOrder param.Field[RadarBGPHijackEventsParamsSortOrder] `query:"sortOrder"` - // The potential victim AS of a BGP hijack event - VictimASN param.Field[int64] `query:"victimAsn"` -} - -// URLQuery serializes [RadarBGPHijackEventsParams]'s query parameters as -// `url.Values`. -func (r RadarBGPHijackEventsParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Shorthand date ranges for the last X days - use when you don't need specific -// start and end dates. -type RadarBGPHijackEventsParamsDateRange string - -const ( - RadarBGPHijackEventsParamsDateRange1d RadarBGPHijackEventsParamsDateRange = "1d" - RadarBGPHijackEventsParamsDateRange2d RadarBGPHijackEventsParamsDateRange = "2d" - RadarBGPHijackEventsParamsDateRange7d RadarBGPHijackEventsParamsDateRange = "7d" - RadarBGPHijackEventsParamsDateRange14d RadarBGPHijackEventsParamsDateRange = "14d" - RadarBGPHijackEventsParamsDateRange28d RadarBGPHijackEventsParamsDateRange = "28d" - RadarBGPHijackEventsParamsDateRange12w RadarBGPHijackEventsParamsDateRange = "12w" - RadarBGPHijackEventsParamsDateRange24w RadarBGPHijackEventsParamsDateRange = "24w" - RadarBGPHijackEventsParamsDateRange52w RadarBGPHijackEventsParamsDateRange = "52w" - RadarBGPHijackEventsParamsDateRange1dControl RadarBGPHijackEventsParamsDateRange = "1dControl" - RadarBGPHijackEventsParamsDateRange2dControl RadarBGPHijackEventsParamsDateRange = "2dControl" - RadarBGPHijackEventsParamsDateRange7dControl RadarBGPHijackEventsParamsDateRange = "7dControl" - RadarBGPHijackEventsParamsDateRange14dControl RadarBGPHijackEventsParamsDateRange = "14dControl" - RadarBGPHijackEventsParamsDateRange28dControl RadarBGPHijackEventsParamsDateRange = "28dControl" - RadarBGPHijackEventsParamsDateRange12wControl RadarBGPHijackEventsParamsDateRange = "12wControl" - RadarBGPHijackEventsParamsDateRange24wControl RadarBGPHijackEventsParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarBGPHijackEventsParamsFormat string - -const ( - RadarBGPHijackEventsParamsFormatJson RadarBGPHijackEventsParamsFormat = "JSON" - RadarBGPHijackEventsParamsFormatCsv RadarBGPHijackEventsParamsFormat = "CSV" -) - -// Sort events by field -type RadarBGPHijackEventsParamsSortBy string - -const ( - RadarBGPHijackEventsParamsSortByID RadarBGPHijackEventsParamsSortBy = "ID" - RadarBGPHijackEventsParamsSortByTime RadarBGPHijackEventsParamsSortBy = "TIME" - RadarBGPHijackEventsParamsSortByConfidence RadarBGPHijackEventsParamsSortBy = "CONFIDENCE" -) - -// Sort order -type RadarBGPHijackEventsParamsSortOrder string - -const ( - RadarBGPHijackEventsParamsSortOrderAsc RadarBGPHijackEventsParamsSortOrder = "ASC" - RadarBGPHijackEventsParamsSortOrderDesc RadarBGPHijackEventsParamsSortOrder = "DESC" -) - -type RadarBGPHijackEventsResponseEnvelope struct { - Result RadarBGPHijackEventsResponse `json:"result,required"` - ResultInfo RadarBGPHijackEventsResponseEnvelopeResultInfo `json:"result_info,required"` - Success bool `json:"success,required"` - JSON radarBGPHijackEventsResponseEnvelopeJSON `json:"-"` -} - -// radarBGPHijackEventsResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarBGPHijackEventsResponseEnvelope] -type radarBGPHijackEventsResponseEnvelopeJSON struct { - Result apijson.Field - ResultInfo apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPHijackEventsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPHijackEventsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarBGPHijackEventsResponseEnvelopeResultInfo struct { - Count int64 `json:"count,required"` - Page int64 `json:"page,required"` - PerPage int64 `json:"per_page,required"` - TotalCount int64 `json:"total_count,required"` - JSON radarBGPHijackEventsResponseEnvelopeResultInfoJSON `json:"-"` -} - -// radarBGPHijackEventsResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [RadarBGPHijackEventsResponseEnvelopeResultInfo] -type radarBGPHijackEventsResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPHijackEventsResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPHijackEventsResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/radarbgphijack_test.go b/radarbgphijack_test.go deleted file mode 100644 index 86bb901a2dc..00000000000 --- a/radarbgphijack_test.go +++ /dev/null @@ -1,56 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarBGPHijackEventsWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.BGP.Hijacks.Events(context.TODO(), cloudflare.RadarBGPHijackEventsParams{ - DateEnd: cloudflare.F(time.Now()), - DateRange: cloudflare.F(cloudflare.RadarBGPHijackEventsParamsDateRange7d), - DateStart: cloudflare.F(time.Now()), - EventID: cloudflare.F(int64(0)), - Format: cloudflare.F(cloudflare.RadarBGPHijackEventsParamsFormatJson), - HijackerASN: cloudflare.F(int64(0)), - InvolvedASN: cloudflare.F(int64(0)), - InvolvedCountry: cloudflare.F("string"), - MaxConfidence: cloudflare.F(int64(0)), - MinConfidence: cloudflare.F(int64(0)), - Page: cloudflare.F(int64(0)), - PerPage: cloudflare.F(int64(0)), - Prefix: cloudflare.F("string"), - SortBy: cloudflare.F(cloudflare.RadarBGPHijackEventsParamsSortByTime), - SortOrder: cloudflare.F(cloudflare.RadarBGPHijackEventsParamsSortOrderDesc), - VictimASN: cloudflare.F(int64(0)), - }) - 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/radarbgpleak.go b/radarbgpleak.go deleted file mode 100644 index 7cbda02f10c..00000000000 --- a/radarbgpleak.go +++ /dev/null @@ -1,279 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarBGPLeakService 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 [NewRadarBGPLeakService] method -// instead. -type RadarBGPLeakService struct { - Options []option.RequestOption -} - -// NewRadarBGPLeakService 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 NewRadarBGPLeakService(opts ...option.RequestOption) (r *RadarBGPLeakService) { - r = &RadarBGPLeakService{} - r.Options = opts - return -} - -// Get the BGP route leak events (Beta). -func (r *RadarBGPLeakService) Events(ctx context.Context, query RadarBGPLeakEventsParams, opts ...option.RequestOption) (res *RadarBGPLeakEventsResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarBGPLeakEventsResponseEnvelope - path := "radar/bgp/leaks/events" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarBGPLeakEventsResponse struct { - ASNInfo []RadarBGPLeakEventsResponseASNInfo `json:"asn_info,required"` - Events []RadarBGPLeakEventsResponseEvent `json:"events,required"` - JSON radarBGPLeakEventsResponseJSON `json:"-"` -} - -// radarBGPLeakEventsResponseJSON contains the JSON metadata for the struct -// [RadarBGPLeakEventsResponse] -type radarBGPLeakEventsResponseJSON struct { - ASNInfo apijson.Field - Events apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPLeakEventsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPLeakEventsResponseJSON) RawJSON() string { - return r.raw -} - -type RadarBGPLeakEventsResponseASNInfo struct { - ASN int64 `json:"asn,required"` - CountryCode string `json:"country_code,required"` - OrgName string `json:"org_name,required"` - JSON radarBGPLeakEventsResponseASNInfoJSON `json:"-"` -} - -// radarBGPLeakEventsResponseASNInfoJSON contains the JSON metadata for the struct -// [RadarBGPLeakEventsResponseASNInfo] -type radarBGPLeakEventsResponseASNInfoJSON struct { - ASN apijson.Field - CountryCode apijson.Field - OrgName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPLeakEventsResponseASNInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPLeakEventsResponseASNInfoJSON) RawJSON() string { - return r.raw -} - -type RadarBGPLeakEventsResponseEvent struct { - ID int64 `json:"id,required"` - Countries []string `json:"countries,required"` - DetectedTs string `json:"detected_ts,required"` - Finished bool `json:"finished,required"` - LeakASN int64 `json:"leak_asn,required"` - LeakCount int64 `json:"leak_count,required"` - LeakSeg []int64 `json:"leak_seg,required"` - LeakType int64 `json:"leak_type,required"` - MaxTs string `json:"max_ts,required"` - MinTs string `json:"min_ts,required"` - OriginCount int64 `json:"origin_count,required"` - PeerCount int64 `json:"peer_count,required"` - PrefixCount int64 `json:"prefix_count,required"` - JSON radarBGPLeakEventsResponseEventJSON `json:"-"` -} - -// radarBGPLeakEventsResponseEventJSON contains the JSON metadata for the struct -// [RadarBGPLeakEventsResponseEvent] -type radarBGPLeakEventsResponseEventJSON struct { - ID apijson.Field - Countries apijson.Field - DetectedTs apijson.Field - Finished apijson.Field - LeakASN apijson.Field - LeakCount apijson.Field - LeakSeg apijson.Field - LeakType apijson.Field - MaxTs apijson.Field - MinTs apijson.Field - OriginCount apijson.Field - PeerCount apijson.Field - PrefixCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPLeakEventsResponseEvent) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPLeakEventsResponseEventJSON) RawJSON() string { - return r.raw -} - -type RadarBGPLeakEventsParams struct { - // End of the date range (inclusive). - DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"` - // Shorthand date ranges for the last X days - use when you don't need specific - // start and end dates. - DateRange param.Field[RadarBGPLeakEventsParamsDateRange] `query:"dateRange"` - // Start of the date range (inclusive). - DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` - // The unique identifier of a event - EventID param.Field[int64] `query:"eventId"` - // Format results are returned in. - Format param.Field[RadarBGPLeakEventsParamsFormat] `query:"format"` - // ASN that is causing or affected by a route leak event - InvolvedASN param.Field[int64] `query:"involvedAsn"` - // Country code of a involved ASN in a route leak event - InvolvedCountry param.Field[string] `query:"involvedCountry"` - // The leaking AS of a route leak event - LeakASN param.Field[int64] `query:"leakAsn"` - // Current page number, starting from 1 - Page param.Field[int64] `query:"page"` - // Number of entries per page - PerPage param.Field[int64] `query:"per_page"` - // Sort events by field - SortBy param.Field[RadarBGPLeakEventsParamsSortBy] `query:"sortBy"` - // Sort order - SortOrder param.Field[RadarBGPLeakEventsParamsSortOrder] `query:"sortOrder"` -} - -// URLQuery serializes [RadarBGPLeakEventsParams]'s query parameters as -// `url.Values`. -func (r RadarBGPLeakEventsParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Shorthand date ranges for the last X days - use when you don't need specific -// start and end dates. -type RadarBGPLeakEventsParamsDateRange string - -const ( - RadarBGPLeakEventsParamsDateRange1d RadarBGPLeakEventsParamsDateRange = "1d" - RadarBGPLeakEventsParamsDateRange2d RadarBGPLeakEventsParamsDateRange = "2d" - RadarBGPLeakEventsParamsDateRange7d RadarBGPLeakEventsParamsDateRange = "7d" - RadarBGPLeakEventsParamsDateRange14d RadarBGPLeakEventsParamsDateRange = "14d" - RadarBGPLeakEventsParamsDateRange28d RadarBGPLeakEventsParamsDateRange = "28d" - RadarBGPLeakEventsParamsDateRange12w RadarBGPLeakEventsParamsDateRange = "12w" - RadarBGPLeakEventsParamsDateRange24w RadarBGPLeakEventsParamsDateRange = "24w" - RadarBGPLeakEventsParamsDateRange52w RadarBGPLeakEventsParamsDateRange = "52w" - RadarBGPLeakEventsParamsDateRange1dControl RadarBGPLeakEventsParamsDateRange = "1dControl" - RadarBGPLeakEventsParamsDateRange2dControl RadarBGPLeakEventsParamsDateRange = "2dControl" - RadarBGPLeakEventsParamsDateRange7dControl RadarBGPLeakEventsParamsDateRange = "7dControl" - RadarBGPLeakEventsParamsDateRange14dControl RadarBGPLeakEventsParamsDateRange = "14dControl" - RadarBGPLeakEventsParamsDateRange28dControl RadarBGPLeakEventsParamsDateRange = "28dControl" - RadarBGPLeakEventsParamsDateRange12wControl RadarBGPLeakEventsParamsDateRange = "12wControl" - RadarBGPLeakEventsParamsDateRange24wControl RadarBGPLeakEventsParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarBGPLeakEventsParamsFormat string - -const ( - RadarBGPLeakEventsParamsFormatJson RadarBGPLeakEventsParamsFormat = "JSON" - RadarBGPLeakEventsParamsFormatCsv RadarBGPLeakEventsParamsFormat = "CSV" -) - -// Sort events by field -type RadarBGPLeakEventsParamsSortBy string - -const ( - RadarBGPLeakEventsParamsSortByID RadarBGPLeakEventsParamsSortBy = "ID" - RadarBGPLeakEventsParamsSortByLeaks RadarBGPLeakEventsParamsSortBy = "LEAKS" - RadarBGPLeakEventsParamsSortByPeers RadarBGPLeakEventsParamsSortBy = "PEERS" - RadarBGPLeakEventsParamsSortByPrefixes RadarBGPLeakEventsParamsSortBy = "PREFIXES" - RadarBGPLeakEventsParamsSortByOrigins RadarBGPLeakEventsParamsSortBy = "ORIGINS" - RadarBGPLeakEventsParamsSortByTime RadarBGPLeakEventsParamsSortBy = "TIME" -) - -// Sort order -type RadarBGPLeakEventsParamsSortOrder string - -const ( - RadarBGPLeakEventsParamsSortOrderAsc RadarBGPLeakEventsParamsSortOrder = "ASC" - RadarBGPLeakEventsParamsSortOrderDesc RadarBGPLeakEventsParamsSortOrder = "DESC" -) - -type RadarBGPLeakEventsResponseEnvelope struct { - Result RadarBGPLeakEventsResponse `json:"result,required"` - ResultInfo RadarBGPLeakEventsResponseEnvelopeResultInfo `json:"result_info,required"` - Success bool `json:"success,required"` - JSON radarBGPLeakEventsResponseEnvelopeJSON `json:"-"` -} - -// radarBGPLeakEventsResponseEnvelopeJSON contains the JSON metadata for the struct -// [RadarBGPLeakEventsResponseEnvelope] -type radarBGPLeakEventsResponseEnvelopeJSON struct { - Result apijson.Field - ResultInfo apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPLeakEventsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPLeakEventsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarBGPLeakEventsResponseEnvelopeResultInfo struct { - Count int64 `json:"count,required"` - Page int64 `json:"page,required"` - PerPage int64 `json:"per_page,required"` - TotalCount int64 `json:"total_count,required"` - JSON radarBGPLeakEventsResponseEnvelopeResultInfoJSON `json:"-"` -} - -// radarBGPLeakEventsResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [RadarBGPLeakEventsResponseEnvelopeResultInfo] -type radarBGPLeakEventsResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPLeakEventsResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPLeakEventsResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/radarbgpleak_test.go b/radarbgpleak_test.go deleted file mode 100644 index 094d96fb136..00000000000 --- a/radarbgpleak_test.go +++ /dev/null @@ -1,52 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarBGPLeakEventsWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.BGP.Leaks.Events(context.TODO(), cloudflare.RadarBGPLeakEventsParams{ - DateEnd: cloudflare.F(time.Now()), - DateRange: cloudflare.F(cloudflare.RadarBGPLeakEventsParamsDateRange7d), - DateStart: cloudflare.F(time.Now()), - EventID: cloudflare.F(int64(0)), - Format: cloudflare.F(cloudflare.RadarBGPLeakEventsParamsFormatJson), - InvolvedASN: cloudflare.F(int64(0)), - InvolvedCountry: cloudflare.F("string"), - LeakASN: cloudflare.F(int64(0)), - Page: cloudflare.F(int64(0)), - PerPage: cloudflare.F(int64(0)), - SortBy: cloudflare.F(cloudflare.RadarBGPLeakEventsParamsSortByTime), - SortOrder: cloudflare.F(cloudflare.RadarBGPLeakEventsParamsSortOrderDesc), - }) - 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/radarbgproute.go b/radarbgproute.go deleted file mode 100644 index b59cfa25421..00000000000 --- a/radarbgproute.go +++ /dev/null @@ -1,714 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarBGPRouteService 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 [NewRadarBGPRouteService] method -// instead. -type RadarBGPRouteService struct { - Options []option.RequestOption -} - -// NewRadarBGPRouteService 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 NewRadarBGPRouteService(opts ...option.RequestOption) (r *RadarBGPRouteService) { - r = &RadarBGPRouteService{} - r.Options = opts - return -} - -// List all Multi-origin AS (MOAS) prefixes on the global routing tables. -func (r *RadarBGPRouteService) Moas(ctx context.Context, query RadarBGPRouteMoasParams, opts ...option.RequestOption) (res *RadarBGPRouteMoasResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarBGPRouteMoasResponseEnvelope - path := "radar/bgp/routes/moas" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lookup prefix-to-origin mapping on global routing tables. -func (r *RadarBGPRouteService) Pfx2as(ctx context.Context, query RadarBGPRoutePfx2asParams, opts ...option.RequestOption) (res *RadarBGPRoutePfx2asResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarBGPRoutePfx2asResponseEnvelope - path := "radar/bgp/routes/pfx2as" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the BGP routing table stats (Beta). -func (r *RadarBGPRouteService) Stats(ctx context.Context, query RadarBGPRouteStatsParams, opts ...option.RequestOption) (res *RadarBGPRouteStatsResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarBGPRouteStatsResponseEnvelope - path := "radar/bgp/routes/stats" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets time-series data for the announced IP space count, represented as the -// number of IPv4 /24s and IPv6 /48s, for a given ASN. -func (r *RadarBGPRouteService) Timeseries(ctx context.Context, query RadarBGPRouteTimeseriesParams, opts ...option.RequestOption) (res *RadarBGPRouteTimeseriesResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarBGPRouteTimeseriesResponseEnvelope - path := "radar/bgp/routes/timeseries" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarBGPRouteMoasResponse struct { - Meta RadarBGPRouteMoasResponseMeta `json:"meta,required"` - Moas []RadarBGPRouteMoasResponseMoa `json:"moas,required"` - JSON radarBGPRouteMoasResponseJSON `json:"-"` -} - -// radarBGPRouteMoasResponseJSON contains the JSON metadata for the struct -// [RadarBGPRouteMoasResponse] -type radarBGPRouteMoasResponseJSON struct { - Meta apijson.Field - Moas apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRouteMoasResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRouteMoasResponseJSON) RawJSON() string { - return r.raw -} - -type RadarBGPRouteMoasResponseMeta struct { - DataTime string `json:"data_time,required"` - QueryTime string `json:"query_time,required"` - TotalPeers int64 `json:"total_peers,required"` - JSON radarBGPRouteMoasResponseMetaJSON `json:"-"` -} - -// radarBGPRouteMoasResponseMetaJSON contains the JSON metadata for the struct -// [RadarBGPRouteMoasResponseMeta] -type radarBGPRouteMoasResponseMetaJSON struct { - DataTime apijson.Field - QueryTime apijson.Field - TotalPeers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRouteMoasResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRouteMoasResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarBGPRouteMoasResponseMoa struct { - Origins []RadarBGPRouteMoasResponseMoasOrigin `json:"origins,required"` - Prefix string `json:"prefix,required"` - JSON radarBGPRouteMoasResponseMoaJSON `json:"-"` -} - -// radarBGPRouteMoasResponseMoaJSON contains the JSON metadata for the struct -// [RadarBGPRouteMoasResponseMoa] -type radarBGPRouteMoasResponseMoaJSON struct { - Origins apijson.Field - Prefix apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRouteMoasResponseMoa) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRouteMoasResponseMoaJSON) RawJSON() string { - return r.raw -} - -type RadarBGPRouteMoasResponseMoasOrigin struct { - Origin int64 `json:"origin,required"` - PeerCount int64 `json:"peer_count,required"` - RpkiValidation string `json:"rpki_validation,required"` - JSON radarBGPRouteMoasResponseMoasOriginJSON `json:"-"` -} - -// radarBGPRouteMoasResponseMoasOriginJSON contains the JSON metadata for the -// struct [RadarBGPRouteMoasResponseMoasOrigin] -type radarBGPRouteMoasResponseMoasOriginJSON struct { - Origin apijson.Field - PeerCount apijson.Field - RpkiValidation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRouteMoasResponseMoasOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRouteMoasResponseMoasOriginJSON) RawJSON() string { - return r.raw -} - -type RadarBGPRoutePfx2asResponse struct { - Meta RadarBGPRoutePfx2asResponseMeta `json:"meta,required"` - PrefixOrigins []RadarBGPRoutePfx2asResponsePrefixOrigin `json:"prefix_origins,required"` - JSON radarBGPRoutePfx2asResponseJSON `json:"-"` -} - -// radarBGPRoutePfx2asResponseJSON contains the JSON metadata for the struct -// [RadarBGPRoutePfx2asResponse] -type radarBGPRoutePfx2asResponseJSON struct { - Meta apijson.Field - PrefixOrigins apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRoutePfx2asResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRoutePfx2asResponseJSON) RawJSON() string { - return r.raw -} - -type RadarBGPRoutePfx2asResponseMeta struct { - DataTime string `json:"data_time,required"` - QueryTime string `json:"query_time,required"` - TotalPeers int64 `json:"total_peers,required"` - JSON radarBGPRoutePfx2asResponseMetaJSON `json:"-"` -} - -// radarBGPRoutePfx2asResponseMetaJSON contains the JSON metadata for the struct -// [RadarBGPRoutePfx2asResponseMeta] -type radarBGPRoutePfx2asResponseMetaJSON struct { - DataTime apijson.Field - QueryTime apijson.Field - TotalPeers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRoutePfx2asResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRoutePfx2asResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarBGPRoutePfx2asResponsePrefixOrigin struct { - Origin int64 `json:"origin,required"` - PeerCount int64 `json:"peer_count,required"` - Prefix string `json:"prefix,required"` - RpkiValidation string `json:"rpki_validation,required"` - JSON radarBGPRoutePfx2asResponsePrefixOriginJSON `json:"-"` -} - -// radarBGPRoutePfx2asResponsePrefixOriginJSON contains the JSON metadata for the -// struct [RadarBGPRoutePfx2asResponsePrefixOrigin] -type radarBGPRoutePfx2asResponsePrefixOriginJSON struct { - Origin apijson.Field - PeerCount apijson.Field - Prefix apijson.Field - RpkiValidation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRoutePfx2asResponsePrefixOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRoutePfx2asResponsePrefixOriginJSON) RawJSON() string { - return r.raw -} - -type RadarBGPRouteStatsResponse struct { - Meta RadarBGPRouteStatsResponseMeta `json:"meta,required"` - Stats RadarBGPRouteStatsResponseStats `json:"stats,required"` - JSON radarBGPRouteStatsResponseJSON `json:"-"` -} - -// radarBGPRouteStatsResponseJSON contains the JSON metadata for the struct -// [RadarBGPRouteStatsResponse] -type radarBGPRouteStatsResponseJSON struct { - Meta apijson.Field - Stats apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRouteStatsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRouteStatsResponseJSON) RawJSON() string { - return r.raw -} - -type RadarBGPRouteStatsResponseMeta struct { - DataTime string `json:"data_time,required"` - QueryTime string `json:"query_time,required"` - TotalPeers int64 `json:"total_peers,required"` - JSON radarBGPRouteStatsResponseMetaJSON `json:"-"` -} - -// radarBGPRouteStatsResponseMetaJSON contains the JSON metadata for the struct -// [RadarBGPRouteStatsResponseMeta] -type radarBGPRouteStatsResponseMetaJSON struct { - DataTime apijson.Field - QueryTime apijson.Field - TotalPeers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRouteStatsResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRouteStatsResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarBGPRouteStatsResponseStats struct { - DistinctOrigins int64 `json:"distinct_origins,required"` - DistinctOriginsIPV4 int64 `json:"distinct_origins_ipv4,required"` - DistinctOriginsIPV6 int64 `json:"distinct_origins_ipv6,required"` - DistinctPrefixes int64 `json:"distinct_prefixes,required"` - DistinctPrefixesIPV4 int64 `json:"distinct_prefixes_ipv4,required"` - DistinctPrefixesIPV6 int64 `json:"distinct_prefixes_ipv6,required"` - RoutesInvalid int64 `json:"routes_invalid,required"` - RoutesInvalidIPV4 int64 `json:"routes_invalid_ipv4,required"` - RoutesInvalidIPV6 int64 `json:"routes_invalid_ipv6,required"` - RoutesTotal int64 `json:"routes_total,required"` - RoutesTotalIPV4 int64 `json:"routes_total_ipv4,required"` - RoutesTotalIPV6 int64 `json:"routes_total_ipv6,required"` - RoutesUnknown int64 `json:"routes_unknown,required"` - RoutesUnknownIPV4 int64 `json:"routes_unknown_ipv4,required"` - RoutesUnknownIPV6 int64 `json:"routes_unknown_ipv6,required"` - RoutesValid int64 `json:"routes_valid,required"` - RoutesValidIPV4 int64 `json:"routes_valid_ipv4,required"` - RoutesValidIPV6 int64 `json:"routes_valid_ipv6,required"` - JSON radarBGPRouteStatsResponseStatsJSON `json:"-"` -} - -// radarBGPRouteStatsResponseStatsJSON contains the JSON metadata for the struct -// [RadarBGPRouteStatsResponseStats] -type radarBGPRouteStatsResponseStatsJSON struct { - DistinctOrigins apijson.Field - DistinctOriginsIPV4 apijson.Field - DistinctOriginsIPV6 apijson.Field - DistinctPrefixes apijson.Field - DistinctPrefixesIPV4 apijson.Field - DistinctPrefixesIPV6 apijson.Field - RoutesInvalid apijson.Field - RoutesInvalidIPV4 apijson.Field - RoutesInvalidIPV6 apijson.Field - RoutesTotal apijson.Field - RoutesTotalIPV4 apijson.Field - RoutesTotalIPV6 apijson.Field - RoutesUnknown apijson.Field - RoutesUnknownIPV4 apijson.Field - RoutesUnknownIPV6 apijson.Field - RoutesValid apijson.Field - RoutesValidIPV4 apijson.Field - RoutesValidIPV6 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRouteStatsResponseStats) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRouteStatsResponseStatsJSON) RawJSON() string { - return r.raw -} - -type RadarBGPRouteTimeseriesResponse struct { - Meta RadarBGPRouteTimeseriesResponseMeta `json:"meta,required"` - SerieIPV4_24s RadarBGPRouteTimeseriesResponseSerieIPV4_24s `json:"serie_ipv4_24s,required"` - SerieIPV6_48s RadarBGPRouteTimeseriesResponseSerieIPV6_48s `json:"serie_ipv6_48s,required"` - JSON radarBGPRouteTimeseriesResponseJSON `json:"-"` -} - -// radarBGPRouteTimeseriesResponseJSON contains the JSON metadata for the struct -// [RadarBGPRouteTimeseriesResponse] -type radarBGPRouteTimeseriesResponseJSON struct { - Meta apijson.Field - SerieIPV4_24s apijson.Field - SerieIPV6_48s apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRouteTimeseriesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRouteTimeseriesResponseJSON) RawJSON() string { - return r.raw -} - -type RadarBGPRouteTimeseriesResponseMeta struct { - DateRange []RadarBGPRouteTimeseriesResponseMetaDateRange `json:"dateRange,required"` - JSON radarBGPRouteTimeseriesResponseMetaJSON `json:"-"` -} - -// radarBGPRouteTimeseriesResponseMetaJSON contains the JSON metadata for the -// struct [RadarBGPRouteTimeseriesResponseMeta] -type radarBGPRouteTimeseriesResponseMetaJSON struct { - DateRange apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRouteTimeseriesResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRouteTimeseriesResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarBGPRouteTimeseriesResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarBGPRouteTimeseriesResponseMetaDateRangeJSON `json:"-"` -} - -// radarBGPRouteTimeseriesResponseMetaDateRangeJSON contains the JSON metadata for -// the struct [RadarBGPRouteTimeseriesResponseMetaDateRange] -type radarBGPRouteTimeseriesResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRouteTimeseriesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRouteTimeseriesResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarBGPRouteTimeseriesResponseSerieIPV4_24s struct { - Timestamps []time.Time `json:"timestamps,required" format:"date-time"` - Values []int64 `json:"values,required"` - JSON radarBGPRouteTimeseriesResponseSerieIPV4_24sJSON `json:"-"` -} - -// radarBGPRouteTimeseriesResponseSerieIPV4_24sJSON contains the JSON metadata for -// the struct [RadarBGPRouteTimeseriesResponseSerieIPV4_24s] -type radarBGPRouteTimeseriesResponseSerieIPV4_24sJSON struct { - Timestamps apijson.Field - Values apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRouteTimeseriesResponseSerieIPV4_24s) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRouteTimeseriesResponseSerieIPV4_24sJSON) RawJSON() string { - return r.raw -} - -type RadarBGPRouteTimeseriesResponseSerieIPV6_48s struct { - Timestamps []time.Time `json:"timestamps,required" format:"date-time"` - Values []int64 `json:"values,required"` - JSON radarBGPRouteTimeseriesResponseSerieIPV6_48sJSON `json:"-"` -} - -// radarBGPRouteTimeseriesResponseSerieIPV6_48sJSON contains the JSON metadata for -// the struct [RadarBGPRouteTimeseriesResponseSerieIPV6_48s] -type radarBGPRouteTimeseriesResponseSerieIPV6_48sJSON struct { - Timestamps apijson.Field - Values apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRouteTimeseriesResponseSerieIPV6_48s) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRouteTimeseriesResponseSerieIPV6_48sJSON) RawJSON() string { - return r.raw -} - -type RadarBGPRouteMoasParams struct { - // Format results are returned in. - Format param.Field[RadarBGPRouteMoasParamsFormat] `query:"format"` - // Lookup only RPKI invalid MOASes - InvalidOnly param.Field[bool] `query:"invalid_only"` - // Lookup MOASes originated by the given ASN - Origin param.Field[int64] `query:"origin"` - // Lookup MOASes by prefix - Prefix param.Field[string] `query:"prefix"` -} - -// URLQuery serializes [RadarBGPRouteMoasParams]'s query parameters as -// `url.Values`. -func (r RadarBGPRouteMoasParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Format results are returned in. -type RadarBGPRouteMoasParamsFormat string - -const ( - RadarBGPRouteMoasParamsFormatJson RadarBGPRouteMoasParamsFormat = "JSON" - RadarBGPRouteMoasParamsFormatCsv RadarBGPRouteMoasParamsFormat = "CSV" -) - -type RadarBGPRouteMoasResponseEnvelope struct { - Result RadarBGPRouteMoasResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarBGPRouteMoasResponseEnvelopeJSON `json:"-"` -} - -// radarBGPRouteMoasResponseEnvelopeJSON contains the JSON metadata for the struct -// [RadarBGPRouteMoasResponseEnvelope] -type radarBGPRouteMoasResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRouteMoasResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRouteMoasResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarBGPRoutePfx2asParams struct { - // Format results are returned in. - Format param.Field[RadarBGPRoutePfx2asParamsFormat] `query:"format"` - // Lookup prefixes originated by the given ASN - Origin param.Field[int64] `query:"origin"` - // Lookup origins of the given prefix - Prefix param.Field[string] `query:"prefix"` - // Return only results with matching rpki status: valid, invalid or unknown - RpkiStatus param.Field[RadarBGPRoutePfx2asParamsRpkiStatus] `query:"rpkiStatus"` -} - -// URLQuery serializes [RadarBGPRoutePfx2asParams]'s query parameters as -// `url.Values`. -func (r RadarBGPRoutePfx2asParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Format results are returned in. -type RadarBGPRoutePfx2asParamsFormat string - -const ( - RadarBGPRoutePfx2asParamsFormatJson RadarBGPRoutePfx2asParamsFormat = "JSON" - RadarBGPRoutePfx2asParamsFormatCsv RadarBGPRoutePfx2asParamsFormat = "CSV" -) - -// Return only results with matching rpki status: valid, invalid or unknown -type RadarBGPRoutePfx2asParamsRpkiStatus string - -const ( - RadarBGPRoutePfx2asParamsRpkiStatusValid RadarBGPRoutePfx2asParamsRpkiStatus = "VALID" - RadarBGPRoutePfx2asParamsRpkiStatusInvalid RadarBGPRoutePfx2asParamsRpkiStatus = "INVALID" - RadarBGPRoutePfx2asParamsRpkiStatusUnknown RadarBGPRoutePfx2asParamsRpkiStatus = "UNKNOWN" -) - -type RadarBGPRoutePfx2asResponseEnvelope struct { - Result RadarBGPRoutePfx2asResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarBGPRoutePfx2asResponseEnvelopeJSON `json:"-"` -} - -// radarBGPRoutePfx2asResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarBGPRoutePfx2asResponseEnvelope] -type radarBGPRoutePfx2asResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRoutePfx2asResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRoutePfx2asResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarBGPRouteStatsParams struct { - // Single ASN as integer. - ASN param.Field[int64] `query:"asn"` - // Format results are returned in. - Format param.Field[RadarBGPRouteStatsParamsFormat] `query:"format"` - // Location Alpha2 code. - Location param.Field[string] `query:"location"` -} - -// URLQuery serializes [RadarBGPRouteStatsParams]'s query parameters as -// `url.Values`. -func (r RadarBGPRouteStatsParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Format results are returned in. -type RadarBGPRouteStatsParamsFormat string - -const ( - RadarBGPRouteStatsParamsFormatJson RadarBGPRouteStatsParamsFormat = "JSON" - RadarBGPRouteStatsParamsFormatCsv RadarBGPRouteStatsParamsFormat = "CSV" -) - -type RadarBGPRouteStatsResponseEnvelope struct { - Result RadarBGPRouteStatsResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarBGPRouteStatsResponseEnvelopeJSON `json:"-"` -} - -// radarBGPRouteStatsResponseEnvelopeJSON contains the JSON metadata for the struct -// [RadarBGPRouteStatsResponseEnvelope] -type radarBGPRouteStatsResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRouteStatsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRouteStatsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarBGPRouteTimeseriesParams struct { - // Single ASN as integer. - ASN param.Field[int64] `query:"asn"` - // End of the date range (inclusive). - DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"` - // Shorthand date ranges for the last X days - use when you don't need specific - // start and end dates. - DateRange param.Field[RadarBGPRouteTimeseriesParamsDateRange] `query:"dateRange"` - // Start of the date range (inclusive). - DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarBGPRouteTimeseriesParamsFormat] `query:"format"` -} - -// URLQuery serializes [RadarBGPRouteTimeseriesParams]'s query parameters as -// `url.Values`. -func (r RadarBGPRouteTimeseriesParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Shorthand date ranges for the last X days - use when you don't need specific -// start and end dates. -type RadarBGPRouteTimeseriesParamsDateRange string - -const ( - RadarBGPRouteTimeseriesParamsDateRange1d RadarBGPRouteTimeseriesParamsDateRange = "1d" - RadarBGPRouteTimeseriesParamsDateRange2d RadarBGPRouteTimeseriesParamsDateRange = "2d" - RadarBGPRouteTimeseriesParamsDateRange7d RadarBGPRouteTimeseriesParamsDateRange = "7d" - RadarBGPRouteTimeseriesParamsDateRange14d RadarBGPRouteTimeseriesParamsDateRange = "14d" - RadarBGPRouteTimeseriesParamsDateRange28d RadarBGPRouteTimeseriesParamsDateRange = "28d" - RadarBGPRouteTimeseriesParamsDateRange12w RadarBGPRouteTimeseriesParamsDateRange = "12w" - RadarBGPRouteTimeseriesParamsDateRange24w RadarBGPRouteTimeseriesParamsDateRange = "24w" - RadarBGPRouteTimeseriesParamsDateRange52w RadarBGPRouteTimeseriesParamsDateRange = "52w" - RadarBGPRouteTimeseriesParamsDateRange1dControl RadarBGPRouteTimeseriesParamsDateRange = "1dControl" - RadarBGPRouteTimeseriesParamsDateRange2dControl RadarBGPRouteTimeseriesParamsDateRange = "2dControl" - RadarBGPRouteTimeseriesParamsDateRange7dControl RadarBGPRouteTimeseriesParamsDateRange = "7dControl" - RadarBGPRouteTimeseriesParamsDateRange14dControl RadarBGPRouteTimeseriesParamsDateRange = "14dControl" - RadarBGPRouteTimeseriesParamsDateRange28dControl RadarBGPRouteTimeseriesParamsDateRange = "28dControl" - RadarBGPRouteTimeseriesParamsDateRange12wControl RadarBGPRouteTimeseriesParamsDateRange = "12wControl" - RadarBGPRouteTimeseriesParamsDateRange24wControl RadarBGPRouteTimeseriesParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarBGPRouteTimeseriesParamsFormat string - -const ( - RadarBGPRouteTimeseriesParamsFormatJson RadarBGPRouteTimeseriesParamsFormat = "JSON" - RadarBGPRouteTimeseriesParamsFormatCsv RadarBGPRouteTimeseriesParamsFormat = "CSV" -) - -type RadarBGPRouteTimeseriesResponseEnvelope struct { - Result RadarBGPRouteTimeseriesResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarBGPRouteTimeseriesResponseEnvelopeJSON `json:"-"` -} - -// radarBGPRouteTimeseriesResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarBGPRouteTimeseriesResponseEnvelope] -type radarBGPRouteTimeseriesResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPRouteTimeseriesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPRouteTimeseriesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarbgproute_test.go b/radarbgproute_test.go deleted file mode 100644 index 2c00ce6b696..00000000000 --- a/radarbgproute_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarBGPRouteMoasWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.BGP.Routes.Moas(context.TODO(), cloudflare.RadarBGPRouteMoasParams{ - Format: cloudflare.F(cloudflare.RadarBGPRouteMoasParamsFormatJson), - InvalidOnly: cloudflare.F(true), - Origin: cloudflare.F(int64(0)), - Prefix: cloudflare.F("string"), - }) - 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 TestRadarBGPRoutePfx2asWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.BGP.Routes.Pfx2as(context.TODO(), cloudflare.RadarBGPRoutePfx2asParams{ - Format: cloudflare.F(cloudflare.RadarBGPRoutePfx2asParamsFormatJson), - Origin: cloudflare.F(int64(0)), - Prefix: cloudflare.F("1.1.1.0/24"), - RpkiStatus: cloudflare.F(cloudflare.RadarBGPRoutePfx2asParamsRpkiStatusInvalid), - }) - 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 TestRadarBGPRouteStatsWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.BGP.Routes.Stats(context.TODO(), cloudflare.RadarBGPRouteStatsParams{ - ASN: cloudflare.F(int64(0)), - Format: cloudflare.F(cloudflare.RadarBGPRouteStatsParamsFormatJson), - Location: cloudflare.F("US"), - }) - 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 TestRadarBGPRouteTimeseriesWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.BGP.Routes.Timeseries(context.TODO(), cloudflare.RadarBGPRouteTimeseriesParams{ - ASN: cloudflare.F(int64(0)), - DateEnd: cloudflare.F(time.Now()), - DateRange: cloudflare.F(cloudflare.RadarBGPRouteTimeseriesParamsDateRange7d), - DateStart: cloudflare.F(time.Now()), - Format: cloudflare.F(cloudflare.RadarBGPRouteTimeseriesParamsFormatJson), - }) - 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/radarbgptop.go b/radarbgptop.go deleted file mode 100644 index c96ebb1805b..00000000000 --- a/radarbgptop.go +++ /dev/null @@ -1,232 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarBGPTopService 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 [NewRadarBGPTopService] method -// instead. -type RadarBGPTopService struct { - Options []option.RequestOption - Ases *RadarBGPTopAseService -} - -// NewRadarBGPTopService 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 NewRadarBGPTopService(opts ...option.RequestOption) (r *RadarBGPTopService) { - r = &RadarBGPTopService{} - r.Options = opts - r.Ases = NewRadarBGPTopAseService(opts...) - return -} - -// Get the top network prefixes by BGP updates. Values are a percentage out of the -// total BGP updates. -func (r *RadarBGPTopService) Prefixes(ctx context.Context, query RadarBGPTopPrefixesParams, opts ...option.RequestOption) (res *RadarBGPTopPrefixesResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarBGPTopPrefixesResponseEnvelope - path := "radar/bgp/top/prefixes" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarBGPTopPrefixesResponse struct { - Meta RadarBGPTopPrefixesResponseMeta `json:"meta,required"` - Top0 []RadarBGPTopPrefixesResponseTop0 `json:"top_0,required"` - JSON radarBGPTopPrefixesResponseJSON `json:"-"` -} - -// radarBGPTopPrefixesResponseJSON contains the JSON metadata for the struct -// [RadarBGPTopPrefixesResponse] -type radarBGPTopPrefixesResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTopPrefixesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTopPrefixesResponseJSON) RawJSON() string { - return r.raw -} - -type RadarBGPTopPrefixesResponseMeta struct { - DateRange []RadarBGPTopPrefixesResponseMetaDateRange `json:"dateRange,required"` - JSON radarBGPTopPrefixesResponseMetaJSON `json:"-"` -} - -// radarBGPTopPrefixesResponseMetaJSON contains the JSON metadata for the struct -// [RadarBGPTopPrefixesResponseMeta] -type radarBGPTopPrefixesResponseMetaJSON struct { - DateRange apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTopPrefixesResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTopPrefixesResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarBGPTopPrefixesResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarBGPTopPrefixesResponseMetaDateRangeJSON `json:"-"` -} - -// radarBGPTopPrefixesResponseMetaDateRangeJSON contains the JSON metadata for the -// struct [RadarBGPTopPrefixesResponseMetaDateRange] -type radarBGPTopPrefixesResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTopPrefixesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTopPrefixesResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarBGPTopPrefixesResponseTop0 struct { - Prefix string `json:"prefix,required"` - Value string `json:"value,required"` - JSON radarBGPTopPrefixesResponseTop0JSON `json:"-"` -} - -// radarBGPTopPrefixesResponseTop0JSON contains the JSON metadata for the struct -// [RadarBGPTopPrefixesResponseTop0] -type radarBGPTopPrefixesResponseTop0JSON struct { - Prefix apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTopPrefixesResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTopPrefixesResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarBGPTopPrefixesParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarBGPTopPrefixesParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarBGPTopPrefixesParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Array of BGP update types. - UpdateType param.Field[[]RadarBGPTopPrefixesParamsUpdateType] `query:"updateType"` -} - -// URLQuery serializes [RadarBGPTopPrefixesParams]'s query parameters as -// `url.Values`. -func (r RadarBGPTopPrefixesParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarBGPTopPrefixesParamsDateRange string - -const ( - RadarBGPTopPrefixesParamsDateRange1d RadarBGPTopPrefixesParamsDateRange = "1d" - RadarBGPTopPrefixesParamsDateRange2d RadarBGPTopPrefixesParamsDateRange = "2d" - RadarBGPTopPrefixesParamsDateRange7d RadarBGPTopPrefixesParamsDateRange = "7d" - RadarBGPTopPrefixesParamsDateRange14d RadarBGPTopPrefixesParamsDateRange = "14d" - RadarBGPTopPrefixesParamsDateRange28d RadarBGPTopPrefixesParamsDateRange = "28d" - RadarBGPTopPrefixesParamsDateRange12w RadarBGPTopPrefixesParamsDateRange = "12w" - RadarBGPTopPrefixesParamsDateRange24w RadarBGPTopPrefixesParamsDateRange = "24w" - RadarBGPTopPrefixesParamsDateRange52w RadarBGPTopPrefixesParamsDateRange = "52w" - RadarBGPTopPrefixesParamsDateRange1dControl RadarBGPTopPrefixesParamsDateRange = "1dControl" - RadarBGPTopPrefixesParamsDateRange2dControl RadarBGPTopPrefixesParamsDateRange = "2dControl" - RadarBGPTopPrefixesParamsDateRange7dControl RadarBGPTopPrefixesParamsDateRange = "7dControl" - RadarBGPTopPrefixesParamsDateRange14dControl RadarBGPTopPrefixesParamsDateRange = "14dControl" - RadarBGPTopPrefixesParamsDateRange28dControl RadarBGPTopPrefixesParamsDateRange = "28dControl" - RadarBGPTopPrefixesParamsDateRange12wControl RadarBGPTopPrefixesParamsDateRange = "12wControl" - RadarBGPTopPrefixesParamsDateRange24wControl RadarBGPTopPrefixesParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarBGPTopPrefixesParamsFormat string - -const ( - RadarBGPTopPrefixesParamsFormatJson RadarBGPTopPrefixesParamsFormat = "JSON" - RadarBGPTopPrefixesParamsFormatCsv RadarBGPTopPrefixesParamsFormat = "CSV" -) - -type RadarBGPTopPrefixesParamsUpdateType string - -const ( - RadarBGPTopPrefixesParamsUpdateTypeAnnouncement RadarBGPTopPrefixesParamsUpdateType = "ANNOUNCEMENT" - RadarBGPTopPrefixesParamsUpdateTypeWithdrawal RadarBGPTopPrefixesParamsUpdateType = "WITHDRAWAL" -) - -type RadarBGPTopPrefixesResponseEnvelope struct { - Result RadarBGPTopPrefixesResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarBGPTopPrefixesResponseEnvelopeJSON `json:"-"` -} - -// radarBGPTopPrefixesResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarBGPTopPrefixesResponseEnvelope] -type radarBGPTopPrefixesResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTopPrefixesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTopPrefixesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarbgptop_test.go b/radarbgptop_test.go deleted file mode 100644 index 60cada0a40b..00000000000 --- a/radarbgptop_test.go +++ /dev/null @@ -1,48 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarBGPTopPrefixesWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.BGP.Top.Prefixes(context.TODO(), cloudflare.RadarBGPTopPrefixesParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarBGPTopPrefixesParamsDateRange{cloudflare.RadarBGPTopPrefixesParamsDateRange1d, cloudflare.RadarBGPTopPrefixesParamsDateRange2d, cloudflare.RadarBGPTopPrefixesParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarBGPTopPrefixesParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Name: cloudflare.F([]string{"string", "string", "string"}), - UpdateType: cloudflare.F([]cloudflare.RadarBGPTopPrefixesParamsUpdateType{cloudflare.RadarBGPTopPrefixesParamsUpdateTypeAnnouncement, cloudflare.RadarBGPTopPrefixesParamsUpdateTypeWithdrawal}), - }) - 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/radarbgptopase.go b/radarbgptopase.go deleted file mode 100644 index 449c4b968c7..00000000000 --- a/radarbgptopase.go +++ /dev/null @@ -1,375 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarBGPTopAseService 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 [NewRadarBGPTopAseService] method -// instead. -type RadarBGPTopAseService struct { - Options []option.RequestOption -} - -// NewRadarBGPTopAseService 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 NewRadarBGPTopAseService(opts ...option.RequestOption) (r *RadarBGPTopAseService) { - r = &RadarBGPTopAseService{} - r.Options = opts - return -} - -// Get the top autonomous systems (AS) by BGP updates (announcements only). Values -// are a percentage out of the total updates. -func (r *RadarBGPTopAseService) Get(ctx context.Context, query RadarBGPTopAseGetParams, opts ...option.RequestOption) (res *RadarBGPTopAseGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarBGPTopAseGetResponseEnvelope - path := "radar/bgp/top/ases" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the full list of autonomous systems on the global routing table ordered by -// announced prefixes count. The data comes from public BGP MRT data archives and -// updates every 2 hours. -func (r *RadarBGPTopAseService) Prefixes(ctx context.Context, query RadarBGPTopAsePrefixesParams, opts ...option.RequestOption) (res *RadarBGPTopAsePrefixesResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarBGPTopAsePrefixesResponseEnvelope - path := "radar/bgp/top/ases/prefixes" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarBGPTopAseGetResponse struct { - Meta RadarBGPTopAseGetResponseMeta `json:"meta,required"` - Top0 []RadarBGPTopAseGetResponseTop0 `json:"top_0,required"` - JSON radarBGPTopAseGetResponseJSON `json:"-"` -} - -// radarBGPTopAseGetResponseJSON contains the JSON metadata for the struct -// [RadarBGPTopAseGetResponse] -type radarBGPTopAseGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTopAseGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTopAseGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarBGPTopAseGetResponseMeta struct { - DateRange []RadarBGPTopAseGetResponseMetaDateRange `json:"dateRange,required"` - JSON radarBGPTopAseGetResponseMetaJSON `json:"-"` -} - -// radarBGPTopAseGetResponseMetaJSON contains the JSON metadata for the struct -// [RadarBGPTopAseGetResponseMeta] -type radarBGPTopAseGetResponseMetaJSON struct { - DateRange apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTopAseGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTopAseGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarBGPTopAseGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarBGPTopAseGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarBGPTopAseGetResponseMetaDateRangeJSON contains the JSON metadata for the -// struct [RadarBGPTopAseGetResponseMetaDateRange] -type radarBGPTopAseGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTopAseGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTopAseGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarBGPTopAseGetResponseTop0 struct { - ASN int64 `json:"asn,required"` - AsName string `json:"ASName,required"` - // Percentage of updates by this AS out of the total updates by all autonomous - // systems. - Value string `json:"value,required"` - JSON radarBGPTopAseGetResponseTop0JSON `json:"-"` -} - -// radarBGPTopAseGetResponseTop0JSON contains the JSON metadata for the struct -// [RadarBGPTopAseGetResponseTop0] -type radarBGPTopAseGetResponseTop0JSON struct { - ASN apijson.Field - AsName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTopAseGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTopAseGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarBGPTopAsePrefixesResponse struct { - ASNs []RadarBGPTopAsePrefixesResponseASN `json:"asns,required"` - Meta RadarBGPTopAsePrefixesResponseMeta `json:"meta,required"` - JSON radarBGPTopAsePrefixesResponseJSON `json:"-"` -} - -// radarBGPTopAsePrefixesResponseJSON contains the JSON metadata for the struct -// [RadarBGPTopAsePrefixesResponse] -type radarBGPTopAsePrefixesResponseJSON struct { - ASNs apijson.Field - Meta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTopAsePrefixesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTopAsePrefixesResponseJSON) RawJSON() string { - return r.raw -} - -type RadarBGPTopAsePrefixesResponseASN struct { - ASN int64 `json:"asn,required"` - Country string `json:"country,required"` - Name string `json:"name,required"` - PfxsCount int64 `json:"pfxs_count,required"` - JSON radarBGPTopAsePrefixesResponseASNJSON `json:"-"` -} - -// radarBGPTopAsePrefixesResponseASNJSON contains the JSON metadata for the struct -// [RadarBGPTopAsePrefixesResponseASN] -type radarBGPTopAsePrefixesResponseASNJSON struct { - ASN apijson.Field - Country apijson.Field - Name apijson.Field - PfxsCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTopAsePrefixesResponseASN) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTopAsePrefixesResponseASNJSON) RawJSON() string { - return r.raw -} - -type RadarBGPTopAsePrefixesResponseMeta struct { - DataTime string `json:"data_time,required"` - QueryTime string `json:"query_time,required"` - TotalPeers int64 `json:"total_peers,required"` - JSON radarBGPTopAsePrefixesResponseMetaJSON `json:"-"` -} - -// radarBGPTopAsePrefixesResponseMetaJSON contains the JSON metadata for the struct -// [RadarBGPTopAsePrefixesResponseMeta] -type radarBGPTopAsePrefixesResponseMetaJSON struct { - DataTime apijson.Field - QueryTime apijson.Field - TotalPeers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTopAsePrefixesResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTopAsePrefixesResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarBGPTopAseGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarBGPTopAseGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarBGPTopAseGetParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Array of BGP network prefixes. - Prefix param.Field[[]string] `query:"prefix"` - // Array of BGP update types. - UpdateType param.Field[[]RadarBGPTopAseGetParamsUpdateType] `query:"updateType"` -} - -// URLQuery serializes [RadarBGPTopAseGetParams]'s query parameters as -// `url.Values`. -func (r RadarBGPTopAseGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarBGPTopAseGetParamsDateRange string - -const ( - RadarBGPTopAseGetParamsDateRange1d RadarBGPTopAseGetParamsDateRange = "1d" - RadarBGPTopAseGetParamsDateRange2d RadarBGPTopAseGetParamsDateRange = "2d" - RadarBGPTopAseGetParamsDateRange7d RadarBGPTopAseGetParamsDateRange = "7d" - RadarBGPTopAseGetParamsDateRange14d RadarBGPTopAseGetParamsDateRange = "14d" - RadarBGPTopAseGetParamsDateRange28d RadarBGPTopAseGetParamsDateRange = "28d" - RadarBGPTopAseGetParamsDateRange12w RadarBGPTopAseGetParamsDateRange = "12w" - RadarBGPTopAseGetParamsDateRange24w RadarBGPTopAseGetParamsDateRange = "24w" - RadarBGPTopAseGetParamsDateRange52w RadarBGPTopAseGetParamsDateRange = "52w" - RadarBGPTopAseGetParamsDateRange1dControl RadarBGPTopAseGetParamsDateRange = "1dControl" - RadarBGPTopAseGetParamsDateRange2dControl RadarBGPTopAseGetParamsDateRange = "2dControl" - RadarBGPTopAseGetParamsDateRange7dControl RadarBGPTopAseGetParamsDateRange = "7dControl" - RadarBGPTopAseGetParamsDateRange14dControl RadarBGPTopAseGetParamsDateRange = "14dControl" - RadarBGPTopAseGetParamsDateRange28dControl RadarBGPTopAseGetParamsDateRange = "28dControl" - RadarBGPTopAseGetParamsDateRange12wControl RadarBGPTopAseGetParamsDateRange = "12wControl" - RadarBGPTopAseGetParamsDateRange24wControl RadarBGPTopAseGetParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarBGPTopAseGetParamsFormat string - -const ( - RadarBGPTopAseGetParamsFormatJson RadarBGPTopAseGetParamsFormat = "JSON" - RadarBGPTopAseGetParamsFormatCsv RadarBGPTopAseGetParamsFormat = "CSV" -) - -type RadarBGPTopAseGetParamsUpdateType string - -const ( - RadarBGPTopAseGetParamsUpdateTypeAnnouncement RadarBGPTopAseGetParamsUpdateType = "ANNOUNCEMENT" - RadarBGPTopAseGetParamsUpdateTypeWithdrawal RadarBGPTopAseGetParamsUpdateType = "WITHDRAWAL" -) - -type RadarBGPTopAseGetResponseEnvelope struct { - Result RadarBGPTopAseGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarBGPTopAseGetResponseEnvelopeJSON `json:"-"` -} - -// radarBGPTopAseGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [RadarBGPTopAseGetResponseEnvelope] -type radarBGPTopAseGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTopAseGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTopAseGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarBGPTopAsePrefixesParams struct { - // Alpha-2 country code. - Country param.Field[string] `query:"country"` - // Format results are returned in. - Format param.Field[RadarBGPTopAsePrefixesParamsFormat] `query:"format"` - // Maximum number of ASes to return - Limit param.Field[int64] `query:"limit"` -} - -// URLQuery serializes [RadarBGPTopAsePrefixesParams]'s query parameters as -// `url.Values`. -func (r RadarBGPTopAsePrefixesParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Format results are returned in. -type RadarBGPTopAsePrefixesParamsFormat string - -const ( - RadarBGPTopAsePrefixesParamsFormatJson RadarBGPTopAsePrefixesParamsFormat = "JSON" - RadarBGPTopAsePrefixesParamsFormatCsv RadarBGPTopAsePrefixesParamsFormat = "CSV" -) - -type RadarBGPTopAsePrefixesResponseEnvelope struct { - Result RadarBGPTopAsePrefixesResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarBGPTopAsePrefixesResponseEnvelopeJSON `json:"-"` -} - -// radarBGPTopAsePrefixesResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarBGPTopAsePrefixesResponseEnvelope] -type radarBGPTopAsePrefixesResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarBGPTopAsePrefixesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarBGPTopAsePrefixesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarbgptopase_test.go b/radarbgptopase_test.go deleted file mode 100644 index 6ffdb048db1..00000000000 --- a/radarbgptopase_test.go +++ /dev/null @@ -1,77 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarBGPTopAseGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.BGP.Top.Ases.Get(context.TODO(), cloudflare.RadarBGPTopAseGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarBGPTopAseGetParamsDateRange{cloudflare.RadarBGPTopAseGetParamsDateRange1d, cloudflare.RadarBGPTopAseGetParamsDateRange2d, cloudflare.RadarBGPTopAseGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarBGPTopAseGetParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Name: cloudflare.F([]string{"string", "string", "string"}), - Prefix: cloudflare.F([]string{"string", "string", "string"}), - UpdateType: cloudflare.F([]cloudflare.RadarBGPTopAseGetParamsUpdateType{cloudflare.RadarBGPTopAseGetParamsUpdateTypeAnnouncement, cloudflare.RadarBGPTopAseGetParamsUpdateTypeWithdrawal}), - }) - 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 TestRadarBGPTopAsePrefixesWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.BGP.Top.Ases.Prefixes(context.TODO(), cloudflare.RadarBGPTopAsePrefixesParams{ - Country: cloudflare.F("NZ"), - Format: cloudflare.F(cloudflare.RadarBGPTopAsePrefixesParamsFormatJson), - Limit: cloudflare.F(int64(10)), - }) - 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/radarconnectiontampering.go b/radarconnectiontampering.go deleted file mode 100644 index 897504b7e52..00000000000 --- a/radarconnectiontampering.go +++ /dev/null @@ -1,594 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarConnectionTamperingService 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 -// [NewRadarConnectionTamperingService] method instead. -type RadarConnectionTamperingService struct { - Options []option.RequestOption -} - -// NewRadarConnectionTamperingService 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 NewRadarConnectionTamperingService(opts ...option.RequestOption) (r *RadarConnectionTamperingService) { - r = &RadarConnectionTamperingService{} - r.Options = opts - return -} - -// Distribution of connection tampering types over a given time period. -func (r *RadarConnectionTamperingService) Summary(ctx context.Context, query RadarConnectionTamperingSummaryParams, opts ...option.RequestOption) (res *RadarConnectionTamperingSummaryResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarConnectionTamperingSummaryResponseEnvelope - path := "radar/connection_tampering/summary" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Distribution of connection tampering types over time. -func (r *RadarConnectionTamperingService) TimeseriesGroups(ctx context.Context, query RadarConnectionTamperingTimeseriesGroupsParams, opts ...option.RequestOption) (res *RadarConnectionTamperingTimeseriesGroupsResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarConnectionTamperingTimeseriesGroupsResponseEnvelope - path := "radar/connection_tampering/timeseries_groups" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarConnectionTamperingSummaryResponse struct { - Meta RadarConnectionTamperingSummaryResponseMeta `json:"meta,required"` - Summary0 RadarConnectionTamperingSummaryResponseSummary0 `json:"summary_0,required"` - JSON radarConnectionTamperingSummaryResponseJSON `json:"-"` -} - -// radarConnectionTamperingSummaryResponseJSON contains the JSON metadata for the -// struct [RadarConnectionTamperingSummaryResponse] -type radarConnectionTamperingSummaryResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarConnectionTamperingSummaryResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarConnectionTamperingSummaryResponseJSON) RawJSON() string { - return r.raw -} - -type RadarConnectionTamperingSummaryResponseMeta struct { - DateRange []RadarConnectionTamperingSummaryResponseMetaDateRange `json:"dateRange,required"` - ConfidenceInfo RadarConnectionTamperingSummaryResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarConnectionTamperingSummaryResponseMetaJSON `json:"-"` -} - -// radarConnectionTamperingSummaryResponseMetaJSON contains the JSON metadata for -// the struct [RadarConnectionTamperingSummaryResponseMeta] -type radarConnectionTamperingSummaryResponseMetaJSON struct { - DateRange apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarConnectionTamperingSummaryResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarConnectionTamperingSummaryResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarConnectionTamperingSummaryResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarConnectionTamperingSummaryResponseMetaDateRangeJSON `json:"-"` -} - -// radarConnectionTamperingSummaryResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarConnectionTamperingSummaryResponseMetaDateRange] -type radarConnectionTamperingSummaryResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarConnectionTamperingSummaryResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarConnectionTamperingSummaryResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarConnectionTamperingSummaryResponseMetaConfidenceInfo struct { - Annotations []RadarConnectionTamperingSummaryResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarConnectionTamperingSummaryResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarConnectionTamperingSummaryResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarConnectionTamperingSummaryResponseMetaConfidenceInfo] -type radarConnectionTamperingSummaryResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarConnectionTamperingSummaryResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarConnectionTamperingSummaryResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarConnectionTamperingSummaryResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarConnectionTamperingSummaryResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarConnectionTamperingSummaryResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarConnectionTamperingSummaryResponseMetaConfidenceInfoAnnotation] -type radarConnectionTamperingSummaryResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarConnectionTamperingSummaryResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarConnectionTamperingSummaryResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarConnectionTamperingSummaryResponseSummary0 struct { - // Connections matching signatures for tampering later in the connection, after the - // transfer of multiple data packets. - LaterInFlow string `json:"later_in_flow,required"` - // Connections that do not match any tampering signatures. - NoMatch string `json:"no_match,required"` - // Connections matching signatures for tampering after the receipt of a SYN packet - // and ACK packet, meaning the TCP connection was successfully established but the - // server did not receive any subsequent packets. - PostAck string `json:"post_ack,required"` - // Connections matching signatures for tampering after the receipt of a packet with - // PSH flag set, following connection establishment. - PostPsh string `json:"post_psh,required"` - // Connections matching signatures for tampering after the receipt of only a single - // SYN packet, and before the handshake completes. - PostSyn string `json:"post_syn,required"` - JSON radarConnectionTamperingSummaryResponseSummary0JSON `json:"-"` -} - -// radarConnectionTamperingSummaryResponseSummary0JSON contains the JSON metadata -// for the struct [RadarConnectionTamperingSummaryResponseSummary0] -type radarConnectionTamperingSummaryResponseSummary0JSON struct { - LaterInFlow apijson.Field - NoMatch apijson.Field - PostAck apijson.Field - PostPsh apijson.Field - PostSyn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarConnectionTamperingSummaryResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarConnectionTamperingSummaryResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarConnectionTamperingTimeseriesGroupsResponse struct { - Meta RadarConnectionTamperingTimeseriesGroupsResponseMeta `json:"meta,required"` - Serie0 RadarConnectionTamperingTimeseriesGroupsResponseSerie0 `json:"serie_0,required"` - JSON radarConnectionTamperingTimeseriesGroupsResponseJSON `json:"-"` -} - -// radarConnectionTamperingTimeseriesGroupsResponseJSON contains the JSON metadata -// for the struct [RadarConnectionTamperingTimeseriesGroupsResponse] -type radarConnectionTamperingTimeseriesGroupsResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarConnectionTamperingTimeseriesGroupsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarConnectionTamperingTimeseriesGroupsResponseJSON) RawJSON() string { - return r.raw -} - -type RadarConnectionTamperingTimeseriesGroupsResponseMeta struct { - AggInterval string `json:"aggInterval,required"` - DateRange []RadarConnectionTamperingTimeseriesGroupsResponseMetaDateRange `json:"dateRange,required"` - LastUpdated time.Time `json:"lastUpdated,required" format:"date-time"` - ConfidenceInfo RadarConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarConnectionTamperingTimeseriesGroupsResponseMetaJSON `json:"-"` -} - -// radarConnectionTamperingTimeseriesGroupsResponseMetaJSON contains the JSON -// metadata for the struct [RadarConnectionTamperingTimeseriesGroupsResponseMeta] -type radarConnectionTamperingTimeseriesGroupsResponseMetaJSON struct { - AggInterval apijson.Field - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarConnectionTamperingTimeseriesGroupsResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarConnectionTamperingTimeseriesGroupsResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarConnectionTamperingTimeseriesGroupsResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarConnectionTamperingTimeseriesGroupsResponseMetaDateRangeJSON `json:"-"` -} - -// radarConnectionTamperingTimeseriesGroupsResponseMetaDateRangeJSON contains the -// JSON metadata for the struct -// [RadarConnectionTamperingTimeseriesGroupsResponseMetaDateRange] -type radarConnectionTamperingTimeseriesGroupsResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarConnectionTamperingTimeseriesGroupsResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarConnectionTamperingTimeseriesGroupsResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfo struct { - Annotations []RadarConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoJSON contains -// the JSON metadata for the struct -// [RadarConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfo] -type radarConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoAnnotation] -type radarConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarConnectionTamperingTimeseriesGroupsResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarConnectionTamperingTimeseriesGroupsResponseSerie0 struct { - // Connections matching signatures for tampering later in the connection, after the - // transfer of multiple data packets. - LaterInFlow []string `json:"later_in_flow,required"` - // Connections that do not match any tampering signatures. - NoMatch []string `json:"no_match,required"` - // Connections matching signatures for tampering after the receipt of a SYN packet - // and ACK packet, meaning the TCP connection was successfully established but the - // server did not receive any subsequent packets. - PostAck []string `json:"post_ack,required"` - // Connections matching signatures for tampering after the receipt of a packet with - // PSH flag set, following connection establishment. - PostPsh []string `json:"post_psh,required"` - // Connections matching signatures for tampering after the receipt of only a single - // SYN packet, and before the handshake completes. - PostSyn []string `json:"post_syn,required"` - Timestamps []time.Time `json:"timestamps,required" format:"date-time"` - JSON radarConnectionTamperingTimeseriesGroupsResponseSerie0JSON `json:"-"` -} - -// radarConnectionTamperingTimeseriesGroupsResponseSerie0JSON contains the JSON -// metadata for the struct [RadarConnectionTamperingTimeseriesGroupsResponseSerie0] -type radarConnectionTamperingTimeseriesGroupsResponseSerie0JSON struct { - LaterInFlow apijson.Field - NoMatch apijson.Field - PostAck apijson.Field - PostPsh apijson.Field - PostSyn apijson.Field - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarConnectionTamperingTimeseriesGroupsResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarConnectionTamperingTimeseriesGroupsResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarConnectionTamperingSummaryParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarConnectionTamperingSummaryParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarConnectionTamperingSummaryParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarConnectionTamperingSummaryParams]'s query parameters -// as `url.Values`. -func (r RadarConnectionTamperingSummaryParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarConnectionTamperingSummaryParamsDateRange string - -const ( - RadarConnectionTamperingSummaryParamsDateRange1d RadarConnectionTamperingSummaryParamsDateRange = "1d" - RadarConnectionTamperingSummaryParamsDateRange2d RadarConnectionTamperingSummaryParamsDateRange = "2d" - RadarConnectionTamperingSummaryParamsDateRange7d RadarConnectionTamperingSummaryParamsDateRange = "7d" - RadarConnectionTamperingSummaryParamsDateRange14d RadarConnectionTamperingSummaryParamsDateRange = "14d" - RadarConnectionTamperingSummaryParamsDateRange28d RadarConnectionTamperingSummaryParamsDateRange = "28d" - RadarConnectionTamperingSummaryParamsDateRange12w RadarConnectionTamperingSummaryParamsDateRange = "12w" - RadarConnectionTamperingSummaryParamsDateRange24w RadarConnectionTamperingSummaryParamsDateRange = "24w" - RadarConnectionTamperingSummaryParamsDateRange52w RadarConnectionTamperingSummaryParamsDateRange = "52w" - RadarConnectionTamperingSummaryParamsDateRange1dControl RadarConnectionTamperingSummaryParamsDateRange = "1dControl" - RadarConnectionTamperingSummaryParamsDateRange2dControl RadarConnectionTamperingSummaryParamsDateRange = "2dControl" - RadarConnectionTamperingSummaryParamsDateRange7dControl RadarConnectionTamperingSummaryParamsDateRange = "7dControl" - RadarConnectionTamperingSummaryParamsDateRange14dControl RadarConnectionTamperingSummaryParamsDateRange = "14dControl" - RadarConnectionTamperingSummaryParamsDateRange28dControl RadarConnectionTamperingSummaryParamsDateRange = "28dControl" - RadarConnectionTamperingSummaryParamsDateRange12wControl RadarConnectionTamperingSummaryParamsDateRange = "12wControl" - RadarConnectionTamperingSummaryParamsDateRange24wControl RadarConnectionTamperingSummaryParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarConnectionTamperingSummaryParamsFormat string - -const ( - RadarConnectionTamperingSummaryParamsFormatJson RadarConnectionTamperingSummaryParamsFormat = "JSON" - RadarConnectionTamperingSummaryParamsFormatCsv RadarConnectionTamperingSummaryParamsFormat = "CSV" -) - -type RadarConnectionTamperingSummaryResponseEnvelope struct { - Result RadarConnectionTamperingSummaryResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarConnectionTamperingSummaryResponseEnvelopeJSON `json:"-"` -} - -// radarConnectionTamperingSummaryResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarConnectionTamperingSummaryResponseEnvelope] -type radarConnectionTamperingSummaryResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarConnectionTamperingSummaryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarConnectionTamperingSummaryResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarConnectionTamperingTimeseriesGroupsParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarConnectionTamperingTimeseriesGroupsParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarConnectionTamperingTimeseriesGroupsParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarConnectionTamperingTimeseriesGroupsParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarConnectionTamperingTimeseriesGroupsParams]'s query -// parameters as `url.Values`. -func (r RadarConnectionTamperingTimeseriesGroupsParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarConnectionTamperingTimeseriesGroupsParamsAggInterval string - -const ( - RadarConnectionTamperingTimeseriesGroupsParamsAggInterval15m RadarConnectionTamperingTimeseriesGroupsParamsAggInterval = "15m" - RadarConnectionTamperingTimeseriesGroupsParamsAggInterval1h RadarConnectionTamperingTimeseriesGroupsParamsAggInterval = "1h" - RadarConnectionTamperingTimeseriesGroupsParamsAggInterval1d RadarConnectionTamperingTimeseriesGroupsParamsAggInterval = "1d" - RadarConnectionTamperingTimeseriesGroupsParamsAggInterval1w RadarConnectionTamperingTimeseriesGroupsParamsAggInterval = "1w" -) - -type RadarConnectionTamperingTimeseriesGroupsParamsDateRange string - -const ( - RadarConnectionTamperingTimeseriesGroupsParamsDateRange1d RadarConnectionTamperingTimeseriesGroupsParamsDateRange = "1d" - RadarConnectionTamperingTimeseriesGroupsParamsDateRange2d RadarConnectionTamperingTimeseriesGroupsParamsDateRange = "2d" - RadarConnectionTamperingTimeseriesGroupsParamsDateRange7d RadarConnectionTamperingTimeseriesGroupsParamsDateRange = "7d" - RadarConnectionTamperingTimeseriesGroupsParamsDateRange14d RadarConnectionTamperingTimeseriesGroupsParamsDateRange = "14d" - RadarConnectionTamperingTimeseriesGroupsParamsDateRange28d RadarConnectionTamperingTimeseriesGroupsParamsDateRange = "28d" - RadarConnectionTamperingTimeseriesGroupsParamsDateRange12w RadarConnectionTamperingTimeseriesGroupsParamsDateRange = "12w" - RadarConnectionTamperingTimeseriesGroupsParamsDateRange24w RadarConnectionTamperingTimeseriesGroupsParamsDateRange = "24w" - RadarConnectionTamperingTimeseriesGroupsParamsDateRange52w RadarConnectionTamperingTimeseriesGroupsParamsDateRange = "52w" - RadarConnectionTamperingTimeseriesGroupsParamsDateRange1dControl RadarConnectionTamperingTimeseriesGroupsParamsDateRange = "1dControl" - RadarConnectionTamperingTimeseriesGroupsParamsDateRange2dControl RadarConnectionTamperingTimeseriesGroupsParamsDateRange = "2dControl" - RadarConnectionTamperingTimeseriesGroupsParamsDateRange7dControl RadarConnectionTamperingTimeseriesGroupsParamsDateRange = "7dControl" - RadarConnectionTamperingTimeseriesGroupsParamsDateRange14dControl RadarConnectionTamperingTimeseriesGroupsParamsDateRange = "14dControl" - RadarConnectionTamperingTimeseriesGroupsParamsDateRange28dControl RadarConnectionTamperingTimeseriesGroupsParamsDateRange = "28dControl" - RadarConnectionTamperingTimeseriesGroupsParamsDateRange12wControl RadarConnectionTamperingTimeseriesGroupsParamsDateRange = "12wControl" - RadarConnectionTamperingTimeseriesGroupsParamsDateRange24wControl RadarConnectionTamperingTimeseriesGroupsParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarConnectionTamperingTimeseriesGroupsParamsFormat string - -const ( - RadarConnectionTamperingTimeseriesGroupsParamsFormatJson RadarConnectionTamperingTimeseriesGroupsParamsFormat = "JSON" - RadarConnectionTamperingTimeseriesGroupsParamsFormatCsv RadarConnectionTamperingTimeseriesGroupsParamsFormat = "CSV" -) - -type RadarConnectionTamperingTimeseriesGroupsResponseEnvelope struct { - Result RadarConnectionTamperingTimeseriesGroupsResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarConnectionTamperingTimeseriesGroupsResponseEnvelopeJSON `json:"-"` -} - -// radarConnectionTamperingTimeseriesGroupsResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [RadarConnectionTamperingTimeseriesGroupsResponseEnvelope] -type radarConnectionTamperingTimeseriesGroupsResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarConnectionTamperingTimeseriesGroupsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarConnectionTamperingTimeseriesGroupsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarconnectiontampering_test.go b/radarconnectiontampering_test.go deleted file mode 100644 index 2b348ad4727..00000000000 --- a/radarconnectiontampering_test.go +++ /dev/null @@ -1,82 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarConnectionTamperingSummaryWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.ConnectionTampering.Summary(context.TODO(), cloudflare.RadarConnectionTamperingSummaryParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarConnectionTamperingSummaryParamsDateRange{cloudflare.RadarConnectionTamperingSummaryParamsDateRange1d, cloudflare.RadarConnectionTamperingSummaryParamsDateRange2d, cloudflare.RadarConnectionTamperingSummaryParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarConnectionTamperingSummaryParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarConnectionTamperingTimeseriesGroupsWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.ConnectionTampering.TimeseriesGroups(context.TODO(), cloudflare.RadarConnectionTamperingTimeseriesGroupsParams{ - AggInterval: cloudflare.F(cloudflare.RadarConnectionTamperingTimeseriesGroupsParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarConnectionTamperingTimeseriesGroupsParamsDateRange{cloudflare.RadarConnectionTamperingTimeseriesGroupsParamsDateRange1d, cloudflare.RadarConnectionTamperingTimeseriesGroupsParamsDateRange2d, cloudflare.RadarConnectionTamperingTimeseriesGroupsParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarConnectionTamperingTimeseriesGroupsParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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/radardataset.go b/radardataset.go deleted file mode 100644 index 45385555c8d..00000000000 --- a/radardataset.go +++ /dev/null @@ -1,286 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarDatasetService 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 [NewRadarDatasetService] method -// instead. -type RadarDatasetService struct { - Options []option.RequestOption -} - -// NewRadarDatasetService 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 NewRadarDatasetService(opts ...option.RequestOption) (r *RadarDatasetService) { - r = &RadarDatasetService{} - r.Options = opts - return -} - -// Get a list of datasets. -func (r *RadarDatasetService) List(ctx context.Context, query RadarDatasetListParams, opts ...option.RequestOption) (res *RadarDatasetListResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarDatasetListResponseEnvelope - path := "radar/datasets" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a url to download a single dataset. -func (r *RadarDatasetService) Download(ctx context.Context, params RadarDatasetDownloadParams, opts ...option.RequestOption) (res *RadarDatasetDownloadResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarDatasetDownloadResponseEnvelope - path := "radar/datasets/download" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the csv content of a given dataset by alias or id. When getting the content -// by alias the latest dataset is returned, optionally filtered by the latest -// available at a given date. -func (r *RadarDatasetService) Get(ctx context.Context, alias string, query RadarDatasetGetParams, opts ...option.RequestOption) (res *string, err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "text/csv")}, opts...) - path := fmt.Sprintf("radar/datasets/%s", alias) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -type RadarDatasetListResponse struct { - Datasets []RadarDatasetListResponseDataset `json:"datasets,required"` - JSON radarDatasetListResponseJSON `json:"-"` -} - -// radarDatasetListResponseJSON contains the JSON metadata for the struct -// [RadarDatasetListResponse] -type radarDatasetListResponseJSON struct { - Datasets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDatasetListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDatasetListResponseJSON) RawJSON() string { - return r.raw -} - -type RadarDatasetListResponseDataset struct { - ID int64 `json:"id,required"` - Description string `json:"description,required"` - Meta interface{} `json:"meta,required"` - Tags []string `json:"tags,required"` - Title string `json:"title,required"` - Type string `json:"type,required"` - JSON radarDatasetListResponseDatasetJSON `json:"-"` -} - -// radarDatasetListResponseDatasetJSON contains the JSON metadata for the struct -// [RadarDatasetListResponseDataset] -type radarDatasetListResponseDatasetJSON struct { - ID apijson.Field - Description apijson.Field - Meta apijson.Field - Tags apijson.Field - Title apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDatasetListResponseDataset) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDatasetListResponseDatasetJSON) RawJSON() string { - return r.raw -} - -type RadarDatasetDownloadResponse struct { - Dataset RadarDatasetDownloadResponseDataset `json:"dataset,required"` - JSON radarDatasetDownloadResponseJSON `json:"-"` -} - -// radarDatasetDownloadResponseJSON contains the JSON metadata for the struct -// [RadarDatasetDownloadResponse] -type radarDatasetDownloadResponseJSON struct { - Dataset apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDatasetDownloadResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDatasetDownloadResponseJSON) RawJSON() string { - return r.raw -} - -type RadarDatasetDownloadResponseDataset struct { - URL string `json:"url,required"` - JSON radarDatasetDownloadResponseDatasetJSON `json:"-"` -} - -// radarDatasetDownloadResponseDatasetJSON contains the JSON metadata for the -// struct [RadarDatasetDownloadResponseDataset] -type radarDatasetDownloadResponseDatasetJSON struct { - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDatasetDownloadResponseDataset) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDatasetDownloadResponseDatasetJSON) RawJSON() string { - return r.raw -} - -type RadarDatasetListParams struct { - // Dataset type. - DatasetType param.Field[RadarDatasetListParamsDatasetType] `query:"datasetType"` - // Format results are returned in. - Format param.Field[RadarDatasetListParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Number of objects to skip before grabbing results. - Offset param.Field[int64] `query:"offset"` -} - -// URLQuery serializes [RadarDatasetListParams]'s query parameters as `url.Values`. -func (r RadarDatasetListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Dataset type. -type RadarDatasetListParamsDatasetType string - -const ( - RadarDatasetListParamsDatasetTypeRankingBucket RadarDatasetListParamsDatasetType = "RANKING_BUCKET" - RadarDatasetListParamsDatasetTypeReport RadarDatasetListParamsDatasetType = "REPORT" -) - -// Format results are returned in. -type RadarDatasetListParamsFormat string - -const ( - RadarDatasetListParamsFormatJson RadarDatasetListParamsFormat = "JSON" - RadarDatasetListParamsFormatCsv RadarDatasetListParamsFormat = "CSV" -) - -type RadarDatasetListResponseEnvelope struct { - Result RadarDatasetListResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarDatasetListResponseEnvelopeJSON `json:"-"` -} - -// radarDatasetListResponseEnvelopeJSON contains the JSON metadata for the struct -// [RadarDatasetListResponseEnvelope] -type radarDatasetListResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDatasetListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDatasetListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarDatasetDownloadParams struct { - DatasetID param.Field[int64] `json:"datasetId,required"` - // Format results are returned in. - Format param.Field[RadarDatasetDownloadParamsFormat] `query:"format"` -} - -func (r RadarDatasetDownloadParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// URLQuery serializes [RadarDatasetDownloadParams]'s query parameters as -// `url.Values`. -func (r RadarDatasetDownloadParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Format results are returned in. -type RadarDatasetDownloadParamsFormat string - -const ( - RadarDatasetDownloadParamsFormatJson RadarDatasetDownloadParamsFormat = "JSON" - RadarDatasetDownloadParamsFormatCsv RadarDatasetDownloadParamsFormat = "CSV" -) - -type RadarDatasetDownloadResponseEnvelope struct { - Result RadarDatasetDownloadResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarDatasetDownloadResponseEnvelopeJSON `json:"-"` -} - -// radarDatasetDownloadResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarDatasetDownloadResponseEnvelope] -type radarDatasetDownloadResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDatasetDownloadResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDatasetDownloadResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarDatasetGetParams struct { - // Filter dataset alias by date - Date param.Field[string] `query:"date"` -} - -// URLQuery serializes [RadarDatasetGetParams]'s query parameters as `url.Values`. -func (r RadarDatasetGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} diff --git a/radardataset_test.go b/radardataset_test.go deleted file mode 100644 index 590be4764da..00000000000 --- a/radardataset_test.go +++ /dev/null @@ -1,100 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarDatasetListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Datasets.List(context.TODO(), cloudflare.RadarDatasetListParams{ - DatasetType: cloudflare.F(cloudflare.RadarDatasetListParamsDatasetTypeRankingBucket), - Format: cloudflare.F(cloudflare.RadarDatasetListParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Offset: cloudflare.F(int64(0)), - }) - 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 TestRadarDatasetDownloadWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Datasets.Download(context.TODO(), cloudflare.RadarDatasetDownloadParams{ - DatasetID: cloudflare.F(int64(3)), - Format: cloudflare.F(cloudflare.RadarDatasetDownloadParamsFormatJson), - }) - 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 TestRadarDatasetGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Datasets.Get( - context.TODO(), - "ranking_top_1000", - cloudflare.RadarDatasetGetParams{ - Date: cloudflare.F("string"), - }, - ) - 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/radardns.go b/radardns.go deleted file mode 100644 index 8e0425ae521..00000000000 --- a/radardns.go +++ /dev/null @@ -1,26 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarDNSService 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 [NewRadarDNSService] method instead. -type RadarDNSService struct { - Options []option.RequestOption - Top *RadarDNSTopService -} - -// NewRadarDNSService 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 NewRadarDNSService(opts ...option.RequestOption) (r *RadarDNSService) { - r = &RadarDNSService{} - r.Options = opts - r.Top = NewRadarDNSTopService(opts...) - return -} diff --git a/radardnstop.go b/radardnstop.go deleted file mode 100644 index 875c9b73651..00000000000 --- a/radardnstop.go +++ /dev/null @@ -1,547 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarDNSTopService 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 [NewRadarDNSTopService] method -// instead. -type RadarDNSTopService struct { - Options []option.RequestOption -} - -// NewRadarDNSTopService 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 NewRadarDNSTopService(opts ...option.RequestOption) (r *RadarDNSTopService) { - r = &RadarDNSTopService{} - r.Options = opts - return -} - -// Get top autonomous systems by DNS queries made to Cloudflare's public DNS -// resolver. -func (r *RadarDNSTopService) Ases(ctx context.Context, query RadarDNSTopAsesParams, opts ...option.RequestOption) (res *RadarDNSTopAsesResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarDNSTopAsesResponseEnvelope - path := "radar/dns/top/ases" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get top locations by DNS queries made to Cloudflare's public DNS resolver. -func (r *RadarDNSTopService) Locations(ctx context.Context, query RadarDNSTopLocationsParams, opts ...option.RequestOption) (res *RadarDNSTopLocationsResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarDNSTopLocationsResponseEnvelope - path := "radar/dns/top/locations" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarDNSTopAsesResponse struct { - Meta RadarDNSTopAsesResponseMeta `json:"meta,required"` - Top0 []RadarDNSTopAsesResponseTop0 `json:"top_0,required"` - JSON radarDNSTopAsesResponseJSON `json:"-"` -} - -// radarDNSTopAsesResponseJSON contains the JSON metadata for the struct -// [RadarDNSTopAsesResponse] -type radarDNSTopAsesResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDNSTopAsesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDNSTopAsesResponseJSON) RawJSON() string { - return r.raw -} - -type RadarDNSTopAsesResponseMeta struct { - DateRange []RadarDNSTopAsesResponseMetaDateRange `json:"dateRange,required"` - ConfidenceInfo RadarDNSTopAsesResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarDNSTopAsesResponseMetaJSON `json:"-"` -} - -// radarDNSTopAsesResponseMetaJSON contains the JSON metadata for the struct -// [RadarDNSTopAsesResponseMeta] -type radarDNSTopAsesResponseMetaJSON struct { - DateRange apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDNSTopAsesResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDNSTopAsesResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarDNSTopAsesResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarDNSTopAsesResponseMetaDateRangeJSON `json:"-"` -} - -// radarDNSTopAsesResponseMetaDateRangeJSON contains the JSON metadata for the -// struct [RadarDNSTopAsesResponseMetaDateRange] -type radarDNSTopAsesResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDNSTopAsesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDNSTopAsesResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarDNSTopAsesResponseMetaConfidenceInfo struct { - Annotations []RadarDNSTopAsesResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarDNSTopAsesResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarDNSTopAsesResponseMetaConfidenceInfoJSON contains the JSON metadata for the -// struct [RadarDNSTopAsesResponseMetaConfidenceInfo] -type radarDNSTopAsesResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDNSTopAsesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDNSTopAsesResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarDNSTopAsesResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarDNSTopAsesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarDNSTopAsesResponseMetaConfidenceInfoAnnotationJSON contains the JSON -// metadata for the struct [RadarDNSTopAsesResponseMetaConfidenceInfoAnnotation] -type radarDNSTopAsesResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDNSTopAsesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDNSTopAsesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarDNSTopAsesResponseTop0 struct { - ClientASN int64 `json:"clientASN,required"` - ClientAsName string `json:"clientASName,required"` - Value string `json:"value,required"` - JSON radarDNSTopAsesResponseTop0JSON `json:"-"` -} - -// radarDNSTopAsesResponseTop0JSON contains the JSON metadata for the struct -// [RadarDNSTopAsesResponseTop0] -type radarDNSTopAsesResponseTop0JSON struct { - ClientASN apijson.Field - ClientAsName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDNSTopAsesResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDNSTopAsesResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarDNSTopLocationsResponse struct { - Meta RadarDNSTopLocationsResponseMeta `json:"meta,required"` - Top0 []RadarDNSTopLocationsResponseTop0 `json:"top_0,required"` - JSON radarDNSTopLocationsResponseJSON `json:"-"` -} - -// radarDNSTopLocationsResponseJSON contains the JSON metadata for the struct -// [RadarDNSTopLocationsResponse] -type radarDNSTopLocationsResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDNSTopLocationsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDNSTopLocationsResponseJSON) RawJSON() string { - return r.raw -} - -type RadarDNSTopLocationsResponseMeta struct { - DateRange []RadarDNSTopLocationsResponseMetaDateRange `json:"dateRange,required"` - ConfidenceInfo RadarDNSTopLocationsResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarDNSTopLocationsResponseMetaJSON `json:"-"` -} - -// radarDNSTopLocationsResponseMetaJSON contains the JSON metadata for the struct -// [RadarDNSTopLocationsResponseMeta] -type radarDNSTopLocationsResponseMetaJSON struct { - DateRange apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDNSTopLocationsResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDNSTopLocationsResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarDNSTopLocationsResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarDNSTopLocationsResponseMetaDateRangeJSON `json:"-"` -} - -// radarDNSTopLocationsResponseMetaDateRangeJSON contains the JSON metadata for the -// struct [RadarDNSTopLocationsResponseMetaDateRange] -type radarDNSTopLocationsResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDNSTopLocationsResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDNSTopLocationsResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarDNSTopLocationsResponseMetaConfidenceInfo struct { - Annotations []RadarDNSTopLocationsResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarDNSTopLocationsResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarDNSTopLocationsResponseMetaConfidenceInfoJSON contains the JSON metadata -// for the struct [RadarDNSTopLocationsResponseMetaConfidenceInfo] -type radarDNSTopLocationsResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDNSTopLocationsResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDNSTopLocationsResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarDNSTopLocationsResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarDNSTopLocationsResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarDNSTopLocationsResponseMetaConfidenceInfoAnnotationJSON contains the JSON -// metadata for the struct -// [RadarDNSTopLocationsResponseMetaConfidenceInfoAnnotation] -type radarDNSTopLocationsResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDNSTopLocationsResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDNSTopLocationsResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarDNSTopLocationsResponseTop0 struct { - ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` - ClientCountryName string `json:"clientCountryName,required"` - Value string `json:"value,required"` - JSON radarDNSTopLocationsResponseTop0JSON `json:"-"` -} - -// radarDNSTopLocationsResponseTop0JSON contains the JSON metadata for the struct -// [RadarDNSTopLocationsResponseTop0] -type radarDNSTopLocationsResponseTop0JSON struct { - ClientCountryAlpha2 apijson.Field - ClientCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDNSTopLocationsResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDNSTopLocationsResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarDNSTopAsesParams struct { - // Array of domain names. - Domain param.Field[[]string] `query:"domain,required"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarDNSTopAsesParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarDNSTopAsesParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarDNSTopAsesParams]'s query parameters as `url.Values`. -func (r RadarDNSTopAsesParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarDNSTopAsesParamsDateRange string - -const ( - RadarDNSTopAsesParamsDateRange1d RadarDNSTopAsesParamsDateRange = "1d" - RadarDNSTopAsesParamsDateRange2d RadarDNSTopAsesParamsDateRange = "2d" - RadarDNSTopAsesParamsDateRange7d RadarDNSTopAsesParamsDateRange = "7d" - RadarDNSTopAsesParamsDateRange14d RadarDNSTopAsesParamsDateRange = "14d" - RadarDNSTopAsesParamsDateRange28d RadarDNSTopAsesParamsDateRange = "28d" - RadarDNSTopAsesParamsDateRange12w RadarDNSTopAsesParamsDateRange = "12w" - RadarDNSTopAsesParamsDateRange24w RadarDNSTopAsesParamsDateRange = "24w" - RadarDNSTopAsesParamsDateRange52w RadarDNSTopAsesParamsDateRange = "52w" - RadarDNSTopAsesParamsDateRange1dControl RadarDNSTopAsesParamsDateRange = "1dControl" - RadarDNSTopAsesParamsDateRange2dControl RadarDNSTopAsesParamsDateRange = "2dControl" - RadarDNSTopAsesParamsDateRange7dControl RadarDNSTopAsesParamsDateRange = "7dControl" - RadarDNSTopAsesParamsDateRange14dControl RadarDNSTopAsesParamsDateRange = "14dControl" - RadarDNSTopAsesParamsDateRange28dControl RadarDNSTopAsesParamsDateRange = "28dControl" - RadarDNSTopAsesParamsDateRange12wControl RadarDNSTopAsesParamsDateRange = "12wControl" - RadarDNSTopAsesParamsDateRange24wControl RadarDNSTopAsesParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarDNSTopAsesParamsFormat string - -const ( - RadarDNSTopAsesParamsFormatJson RadarDNSTopAsesParamsFormat = "JSON" - RadarDNSTopAsesParamsFormatCsv RadarDNSTopAsesParamsFormat = "CSV" -) - -type RadarDNSTopAsesResponseEnvelope struct { - Result RadarDNSTopAsesResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarDNSTopAsesResponseEnvelopeJSON `json:"-"` -} - -// radarDNSTopAsesResponseEnvelopeJSON contains the JSON metadata for the struct -// [RadarDNSTopAsesResponseEnvelope] -type radarDNSTopAsesResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDNSTopAsesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDNSTopAsesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarDNSTopLocationsParams struct { - // Array of domain names. - Domain param.Field[[]string] `query:"domain,required"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarDNSTopLocationsParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarDNSTopLocationsParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarDNSTopLocationsParams]'s query parameters as -// `url.Values`. -func (r RadarDNSTopLocationsParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarDNSTopLocationsParamsDateRange string - -const ( - RadarDNSTopLocationsParamsDateRange1d RadarDNSTopLocationsParamsDateRange = "1d" - RadarDNSTopLocationsParamsDateRange2d RadarDNSTopLocationsParamsDateRange = "2d" - RadarDNSTopLocationsParamsDateRange7d RadarDNSTopLocationsParamsDateRange = "7d" - RadarDNSTopLocationsParamsDateRange14d RadarDNSTopLocationsParamsDateRange = "14d" - RadarDNSTopLocationsParamsDateRange28d RadarDNSTopLocationsParamsDateRange = "28d" - RadarDNSTopLocationsParamsDateRange12w RadarDNSTopLocationsParamsDateRange = "12w" - RadarDNSTopLocationsParamsDateRange24w RadarDNSTopLocationsParamsDateRange = "24w" - RadarDNSTopLocationsParamsDateRange52w RadarDNSTopLocationsParamsDateRange = "52w" - RadarDNSTopLocationsParamsDateRange1dControl RadarDNSTopLocationsParamsDateRange = "1dControl" - RadarDNSTopLocationsParamsDateRange2dControl RadarDNSTopLocationsParamsDateRange = "2dControl" - RadarDNSTopLocationsParamsDateRange7dControl RadarDNSTopLocationsParamsDateRange = "7dControl" - RadarDNSTopLocationsParamsDateRange14dControl RadarDNSTopLocationsParamsDateRange = "14dControl" - RadarDNSTopLocationsParamsDateRange28dControl RadarDNSTopLocationsParamsDateRange = "28dControl" - RadarDNSTopLocationsParamsDateRange12wControl RadarDNSTopLocationsParamsDateRange = "12wControl" - RadarDNSTopLocationsParamsDateRange24wControl RadarDNSTopLocationsParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarDNSTopLocationsParamsFormat string - -const ( - RadarDNSTopLocationsParamsFormatJson RadarDNSTopLocationsParamsFormat = "JSON" - RadarDNSTopLocationsParamsFormatCsv RadarDNSTopLocationsParamsFormat = "CSV" -) - -type RadarDNSTopLocationsResponseEnvelope struct { - Result RadarDNSTopLocationsResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarDNSTopLocationsResponseEnvelopeJSON `json:"-"` -} - -// radarDNSTopLocationsResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarDNSTopLocationsResponseEnvelope] -type radarDNSTopLocationsResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarDNSTopLocationsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarDNSTopLocationsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radardnstop_test.go b/radardnstop_test.go deleted file mode 100644 index ad36f56fca8..00000000000 --- a/radardnstop_test.go +++ /dev/null @@ -1,85 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarDNSTopAsesWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.DNS.Top.Ases(context.TODO(), cloudflare.RadarDNSTopAsesParams{ - Domain: cloudflare.F([]string{"string", "string", "string"}), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarDNSTopAsesParamsDateRange{cloudflare.RadarDNSTopAsesParamsDateRange1d, cloudflare.RadarDNSTopAsesParamsDateRange2d, cloudflare.RadarDNSTopAsesParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarDNSTopAsesParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarDNSTopLocationsWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.DNS.Top.Locations(context.TODO(), cloudflare.RadarDNSTopLocationsParams{ - Domain: cloudflare.F([]string{"string", "string", "string"}), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarDNSTopLocationsParamsDateRange{cloudflare.RadarDNSTopLocationsParamsDateRange1d, cloudflare.RadarDNSTopLocationsParamsDateRange2d, cloudflare.RadarDNSTopLocationsParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarDNSTopLocationsParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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/radaremail.go b/radaremail.go deleted file mode 100644 index cd0b43d48d7..00000000000 --- a/radaremail.go +++ /dev/null @@ -1,28 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarEmailService 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 [NewRadarEmailService] method instead. -type RadarEmailService struct { - Options []option.RequestOption - Routing *RadarEmailRoutingService - Security *RadarEmailSecurityService -} - -// NewRadarEmailService 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 NewRadarEmailService(opts ...option.RequestOption) (r *RadarEmailService) { - r = &RadarEmailService{} - r.Options = opts - r.Routing = NewRadarEmailRoutingService(opts...) - r.Security = NewRadarEmailSecurityService(opts...) - return -} diff --git a/radaremailrouting.go b/radaremailrouting.go deleted file mode 100644 index 31c24ade4fd..00000000000 --- a/radaremailrouting.go +++ /dev/null @@ -1,29 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarEmailRoutingService 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 [NewRadarEmailRoutingService] method -// instead. -type RadarEmailRoutingService struct { - Options []option.RequestOption - Summary *RadarEmailRoutingSummaryService - TimeseriesGroups *RadarEmailRoutingTimeseriesGroupService -} - -// NewRadarEmailRoutingService 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 NewRadarEmailRoutingService(opts ...option.RequestOption) (r *RadarEmailRoutingService) { - r = &RadarEmailRoutingService{} - r.Options = opts - r.Summary = NewRadarEmailRoutingSummaryService(opts...) - r.TimeseriesGroups = NewRadarEmailRoutingTimeseriesGroupService(opts...) - return -} diff --git a/radaremailroutingsummary.go b/radaremailroutingsummary.go deleted file mode 100644 index 92f5c912455..00000000000 --- a/radaremailroutingsummary.go +++ /dev/null @@ -1,1793 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarEmailRoutingSummaryService 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 -// [NewRadarEmailRoutingSummaryService] method instead. -type RadarEmailRoutingSummaryService struct { - Options []option.RequestOption -} - -// NewRadarEmailRoutingSummaryService 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 NewRadarEmailRoutingSummaryService(opts ...option.RequestOption) (r *RadarEmailRoutingSummaryService) { - r = &RadarEmailRoutingSummaryService{} - r.Options = opts - return -} - -// Percentage distribution of emails classified per ARC validation. -func (r *RadarEmailRoutingSummaryService) ARC(ctx context.Context, query RadarEmailRoutingSummaryARCParams, opts ...option.RequestOption) (res *RadarEmailRoutingSummaryARCResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailRoutingSummaryARCResponseEnvelope - path := "radar/email/routing/summary/arc" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified per DKIM validation. -func (r *RadarEmailRoutingSummaryService) DKIM(ctx context.Context, query RadarEmailRoutingSummaryDKIMParams, opts ...option.RequestOption) (res *RadarEmailRoutingSummaryDKIMResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailRoutingSummaryDKIMResponseEnvelope - path := "radar/email/routing/summary/dkim" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified per DMARC validation. -func (r *RadarEmailRoutingSummaryService) DMARC(ctx context.Context, query RadarEmailRoutingSummaryDMARCParams, opts ...option.RequestOption) (res *RadarEmailRoutingSummaryDMARCResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailRoutingSummaryDMARCResponseEnvelope - path := "radar/email/routing/summary/dmarc" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails by Encrypted -func (r *RadarEmailRoutingSummaryService) Encrypted(ctx context.Context, query RadarEmailRoutingSummaryEncryptedParams, opts ...option.RequestOption) (res *RadarEmailRoutingSummaryEncryptedResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailRoutingSummaryEncryptedResponseEnvelope - path := "radar/email/routing/summary/encrypted" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails by Ip Version. -func (r *RadarEmailRoutingSummaryService) IPVersion(ctx context.Context, query RadarEmailRoutingSummaryIPVersionParams, opts ...option.RequestOption) (res *RadarEmailRoutingSummaryIPVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailRoutingSummaryIPVersionResponseEnvelope - path := "radar/email/routing/summary/ip_version" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified per SPF validation. -func (r *RadarEmailRoutingSummaryService) SPF(ctx context.Context, query RadarEmailRoutingSummarySPFParams, opts ...option.RequestOption) (res *RadarEmailRoutingSummarySPFResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailRoutingSummarySPFResponseEnvelope - path := "radar/email/routing/summary/spf" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarEmailRoutingSummaryARCResponse struct { - Meta RadarEmailRoutingSummaryARCResponseMeta `json:"meta,required"` - Summary0 RadarEmailRoutingSummaryARCResponseSummary0 `json:"summary_0,required"` - JSON radarEmailRoutingSummaryARCResponseJSON `json:"-"` -} - -// radarEmailRoutingSummaryARCResponseJSON contains the JSON metadata for the -// struct [RadarEmailRoutingSummaryARCResponse] -type radarEmailRoutingSummaryARCResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryARCResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryARCResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryARCResponseMeta struct { - DateRange []RadarEmailRoutingSummaryARCResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarEmailRoutingSummaryARCResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailRoutingSummaryARCResponseMetaJSON `json:"-"` -} - -// radarEmailRoutingSummaryARCResponseMetaJSON contains the JSON metadata for the -// struct [RadarEmailRoutingSummaryARCResponseMeta] -type radarEmailRoutingSummaryARCResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryARCResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryARCResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryARCResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailRoutingSummaryARCResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailRoutingSummaryARCResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarEmailRoutingSummaryARCResponseMetaDateRange] -type radarEmailRoutingSummaryARCResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryARCResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryARCResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryARCResponseMetaConfidenceInfo struct { - Annotations []RadarEmailRoutingSummaryARCResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailRoutingSummaryARCResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailRoutingSummaryARCResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarEmailRoutingSummaryARCResponseMetaConfidenceInfo] -type radarEmailRoutingSummaryARCResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryARCResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryARCResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryARCResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailRoutingSummaryARCResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailRoutingSummaryARCResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarEmailRoutingSummaryARCResponseMetaConfidenceInfoAnnotation] -type radarEmailRoutingSummaryARCResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryARCResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryARCResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryARCResponseSummary0 struct { - Fail string `json:"FAIL,required"` - None string `json:"NONE,required"` - Pass string `json:"PASS,required"` - JSON radarEmailRoutingSummaryARCResponseSummary0JSON `json:"-"` -} - -// radarEmailRoutingSummaryARCResponseSummary0JSON contains the JSON metadata for -// the struct [RadarEmailRoutingSummaryARCResponseSummary0] -type radarEmailRoutingSummaryARCResponseSummary0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryARCResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryARCResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryDKIMResponse struct { - Meta RadarEmailRoutingSummaryDKIMResponseMeta `json:"meta,required"` - Summary0 RadarEmailRoutingSummaryDKIMResponseSummary0 `json:"summary_0,required"` - JSON radarEmailRoutingSummaryDKIMResponseJSON `json:"-"` -} - -// radarEmailRoutingSummaryDKIMResponseJSON contains the JSON metadata for the -// struct [RadarEmailRoutingSummaryDKIMResponse] -type radarEmailRoutingSummaryDKIMResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryDKIMResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryDKIMResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryDKIMResponseMeta struct { - DateRange []RadarEmailRoutingSummaryDKIMResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarEmailRoutingSummaryDKIMResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailRoutingSummaryDKIMResponseMetaJSON `json:"-"` -} - -// radarEmailRoutingSummaryDKIMResponseMetaJSON contains the JSON metadata for the -// struct [RadarEmailRoutingSummaryDKIMResponseMeta] -type radarEmailRoutingSummaryDKIMResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryDKIMResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryDKIMResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryDKIMResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailRoutingSummaryDKIMResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailRoutingSummaryDKIMResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarEmailRoutingSummaryDKIMResponseMetaDateRange] -type radarEmailRoutingSummaryDKIMResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryDKIMResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryDKIMResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryDKIMResponseMetaConfidenceInfo struct { - Annotations []RadarEmailRoutingSummaryDKIMResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailRoutingSummaryDKIMResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailRoutingSummaryDKIMResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarEmailRoutingSummaryDKIMResponseMetaConfidenceInfo] -type radarEmailRoutingSummaryDKIMResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryDKIMResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryDKIMResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryDKIMResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailRoutingSummaryDKIMResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailRoutingSummaryDKIMResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarEmailRoutingSummaryDKIMResponseMetaConfidenceInfoAnnotation] -type radarEmailRoutingSummaryDKIMResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryDKIMResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryDKIMResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryDKIMResponseSummary0 struct { - Fail string `json:"FAIL,required"` - None string `json:"NONE,required"` - Pass string `json:"PASS,required"` - JSON radarEmailRoutingSummaryDKIMResponseSummary0JSON `json:"-"` -} - -// radarEmailRoutingSummaryDKIMResponseSummary0JSON contains the JSON metadata for -// the struct [RadarEmailRoutingSummaryDKIMResponseSummary0] -type radarEmailRoutingSummaryDKIMResponseSummary0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryDKIMResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryDKIMResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryDMARCResponse struct { - Meta RadarEmailRoutingSummaryDMARCResponseMeta `json:"meta,required"` - Summary0 RadarEmailRoutingSummaryDMARCResponseSummary0 `json:"summary_0,required"` - JSON radarEmailRoutingSummaryDMARCResponseJSON `json:"-"` -} - -// radarEmailRoutingSummaryDMARCResponseJSON contains the JSON metadata for the -// struct [RadarEmailRoutingSummaryDMARCResponse] -type radarEmailRoutingSummaryDMARCResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryDMARCResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryDMARCResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryDMARCResponseMeta struct { - DateRange []RadarEmailRoutingSummaryDMARCResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarEmailRoutingSummaryDMARCResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailRoutingSummaryDMARCResponseMetaJSON `json:"-"` -} - -// radarEmailRoutingSummaryDMARCResponseMetaJSON contains the JSON metadata for the -// struct [RadarEmailRoutingSummaryDMARCResponseMeta] -type radarEmailRoutingSummaryDMARCResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryDMARCResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryDMARCResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryDMARCResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailRoutingSummaryDMARCResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailRoutingSummaryDMARCResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarEmailRoutingSummaryDMARCResponseMetaDateRange] -type radarEmailRoutingSummaryDMARCResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryDMARCResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryDMARCResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryDMARCResponseMetaConfidenceInfo struct { - Annotations []RadarEmailRoutingSummaryDMARCResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailRoutingSummaryDMARCResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailRoutingSummaryDMARCResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarEmailRoutingSummaryDMARCResponseMetaConfidenceInfo] -type radarEmailRoutingSummaryDMARCResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryDMARCResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryDMARCResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryDMARCResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailRoutingSummaryDMARCResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailRoutingSummaryDMARCResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarEmailRoutingSummaryDMARCResponseMetaConfidenceInfoAnnotation] -type radarEmailRoutingSummaryDMARCResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryDMARCResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryDMARCResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryDMARCResponseSummary0 struct { - Fail string `json:"FAIL,required"` - None string `json:"NONE,required"` - Pass string `json:"PASS,required"` - JSON radarEmailRoutingSummaryDMARCResponseSummary0JSON `json:"-"` -} - -// radarEmailRoutingSummaryDMARCResponseSummary0JSON contains the JSON metadata for -// the struct [RadarEmailRoutingSummaryDMARCResponseSummary0] -type radarEmailRoutingSummaryDMARCResponseSummary0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryDMARCResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryDMARCResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryEncryptedResponse struct { - Meta RadarEmailRoutingSummaryEncryptedResponseMeta `json:"meta,required"` - Summary0 RadarEmailRoutingSummaryEncryptedResponseSummary0 `json:"summary_0,required"` - JSON radarEmailRoutingSummaryEncryptedResponseJSON `json:"-"` -} - -// radarEmailRoutingSummaryEncryptedResponseJSON contains the JSON metadata for the -// struct [RadarEmailRoutingSummaryEncryptedResponse] -type radarEmailRoutingSummaryEncryptedResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryEncryptedResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryEncryptedResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryEncryptedResponseMeta struct { - DateRange []RadarEmailRoutingSummaryEncryptedResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarEmailRoutingSummaryEncryptedResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailRoutingSummaryEncryptedResponseMetaJSON `json:"-"` -} - -// radarEmailRoutingSummaryEncryptedResponseMetaJSON contains the JSON metadata for -// the struct [RadarEmailRoutingSummaryEncryptedResponseMeta] -type radarEmailRoutingSummaryEncryptedResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryEncryptedResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryEncryptedResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryEncryptedResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailRoutingSummaryEncryptedResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailRoutingSummaryEncryptedResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarEmailRoutingSummaryEncryptedResponseMetaDateRange] -type radarEmailRoutingSummaryEncryptedResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryEncryptedResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryEncryptedResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryEncryptedResponseMetaConfidenceInfo struct { - Annotations []RadarEmailRoutingSummaryEncryptedResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailRoutingSummaryEncryptedResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailRoutingSummaryEncryptedResponseMetaConfidenceInfoJSON contains the -// JSON metadata for the struct -// [RadarEmailRoutingSummaryEncryptedResponseMetaConfidenceInfo] -type radarEmailRoutingSummaryEncryptedResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryEncryptedResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryEncryptedResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryEncryptedResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailRoutingSummaryEncryptedResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailRoutingSummaryEncryptedResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarEmailRoutingSummaryEncryptedResponseMetaConfidenceInfoAnnotation] -type radarEmailRoutingSummaryEncryptedResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryEncryptedResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryEncryptedResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryEncryptedResponseSummary0 struct { - Encrypted string `json:"ENCRYPTED,required"` - NotEncrypted string `json:"NOT_ENCRYPTED,required"` - JSON radarEmailRoutingSummaryEncryptedResponseSummary0JSON `json:"-"` -} - -// radarEmailRoutingSummaryEncryptedResponseSummary0JSON contains the JSON metadata -// for the struct [RadarEmailRoutingSummaryEncryptedResponseSummary0] -type radarEmailRoutingSummaryEncryptedResponseSummary0JSON struct { - Encrypted apijson.Field - NotEncrypted apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryEncryptedResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryEncryptedResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryIPVersionResponse struct { - Meta RadarEmailRoutingSummaryIPVersionResponseMeta `json:"meta,required"` - Summary0 RadarEmailRoutingSummaryIPVersionResponseSummary0 `json:"summary_0,required"` - JSON radarEmailRoutingSummaryIPVersionResponseJSON `json:"-"` -} - -// radarEmailRoutingSummaryIPVersionResponseJSON contains the JSON metadata for the -// struct [RadarEmailRoutingSummaryIPVersionResponse] -type radarEmailRoutingSummaryIPVersionResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryIPVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryIPVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryIPVersionResponseMeta struct { - DateRange []RadarEmailRoutingSummaryIPVersionResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarEmailRoutingSummaryIPVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailRoutingSummaryIPVersionResponseMetaJSON `json:"-"` -} - -// radarEmailRoutingSummaryIPVersionResponseMetaJSON contains the JSON metadata for -// the struct [RadarEmailRoutingSummaryIPVersionResponseMeta] -type radarEmailRoutingSummaryIPVersionResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryIPVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryIPVersionResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryIPVersionResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailRoutingSummaryIPVersionResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailRoutingSummaryIPVersionResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarEmailRoutingSummaryIPVersionResponseMetaDateRange] -type radarEmailRoutingSummaryIPVersionResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryIPVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryIPVersionResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryIPVersionResponseMetaConfidenceInfo struct { - Annotations []RadarEmailRoutingSummaryIPVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailRoutingSummaryIPVersionResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailRoutingSummaryIPVersionResponseMetaConfidenceInfoJSON contains the -// JSON metadata for the struct -// [RadarEmailRoutingSummaryIPVersionResponseMetaConfidenceInfo] -type radarEmailRoutingSummaryIPVersionResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryIPVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryIPVersionResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryIPVersionResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailRoutingSummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailRoutingSummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarEmailRoutingSummaryIPVersionResponseMetaConfidenceInfoAnnotation] -type radarEmailRoutingSummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryIPVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryIPVersionResponseSummary0 struct { - IPv4 string `json:"IPv4,required"` - IPv6 string `json:"IPv6,required"` - JSON radarEmailRoutingSummaryIPVersionResponseSummary0JSON `json:"-"` -} - -// radarEmailRoutingSummaryIPVersionResponseSummary0JSON contains the JSON metadata -// for the struct [RadarEmailRoutingSummaryIPVersionResponseSummary0] -type radarEmailRoutingSummaryIPVersionResponseSummary0JSON struct { - IPv4 apijson.Field - IPv6 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryIPVersionResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryIPVersionResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummarySPFResponse struct { - Meta RadarEmailRoutingSummarySPFResponseMeta `json:"meta,required"` - Summary0 RadarEmailRoutingSummarySPFResponseSummary0 `json:"summary_0,required"` - JSON radarEmailRoutingSummarySPFResponseJSON `json:"-"` -} - -// radarEmailRoutingSummarySPFResponseJSON contains the JSON metadata for the -// struct [RadarEmailRoutingSummarySPFResponse] -type radarEmailRoutingSummarySPFResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummarySPFResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummarySPFResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummarySPFResponseMeta struct { - DateRange []RadarEmailRoutingSummarySPFResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarEmailRoutingSummarySPFResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailRoutingSummarySPFResponseMetaJSON `json:"-"` -} - -// radarEmailRoutingSummarySPFResponseMetaJSON contains the JSON metadata for the -// struct [RadarEmailRoutingSummarySPFResponseMeta] -type radarEmailRoutingSummarySPFResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummarySPFResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummarySPFResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummarySPFResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailRoutingSummarySPFResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailRoutingSummarySPFResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarEmailRoutingSummarySPFResponseMetaDateRange] -type radarEmailRoutingSummarySPFResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummarySPFResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummarySPFResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummarySPFResponseMetaConfidenceInfo struct { - Annotations []RadarEmailRoutingSummarySPFResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailRoutingSummarySPFResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailRoutingSummarySPFResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarEmailRoutingSummarySPFResponseMetaConfidenceInfo] -type radarEmailRoutingSummarySPFResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummarySPFResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummarySPFResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummarySPFResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailRoutingSummarySPFResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailRoutingSummarySPFResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarEmailRoutingSummarySPFResponseMetaConfidenceInfoAnnotation] -type radarEmailRoutingSummarySPFResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummarySPFResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummarySPFResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummarySPFResponseSummary0 struct { - Fail string `json:"FAIL,required"` - None string `json:"NONE,required"` - Pass string `json:"PASS,required"` - JSON radarEmailRoutingSummarySPFResponseSummary0JSON `json:"-"` -} - -// radarEmailRoutingSummarySPFResponseSummary0JSON contains the JSON metadata for -// the struct [RadarEmailRoutingSummarySPFResponseSummary0] -type radarEmailRoutingSummarySPFResponseSummary0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummarySPFResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummarySPFResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryARCParams struct { - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailRoutingSummaryARCParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailRoutingSummaryARCParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailRoutingSummaryARCParamsDMARC] `query:"dmarc"` - // Filter for encrypted emails. - Encrypted param.Field[[]RadarEmailRoutingSummaryARCParamsEncrypted] `query:"encrypted"` - // Format results are returned in. - Format param.Field[RadarEmailRoutingSummaryARCParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarEmailRoutingSummaryARCParamsIPVersion] `query:"ipVersion"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailRoutingSummaryARCParamsSPF] `query:"spf"` -} - -// URLQuery serializes [RadarEmailRoutingSummaryARCParams]'s query parameters as -// `url.Values`. -func (r RadarEmailRoutingSummaryARCParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarEmailRoutingSummaryARCParamsDateRange string - -const ( - RadarEmailRoutingSummaryARCParamsDateRange1d RadarEmailRoutingSummaryARCParamsDateRange = "1d" - RadarEmailRoutingSummaryARCParamsDateRange2d RadarEmailRoutingSummaryARCParamsDateRange = "2d" - RadarEmailRoutingSummaryARCParamsDateRange7d RadarEmailRoutingSummaryARCParamsDateRange = "7d" - RadarEmailRoutingSummaryARCParamsDateRange14d RadarEmailRoutingSummaryARCParamsDateRange = "14d" - RadarEmailRoutingSummaryARCParamsDateRange28d RadarEmailRoutingSummaryARCParamsDateRange = "28d" - RadarEmailRoutingSummaryARCParamsDateRange12w RadarEmailRoutingSummaryARCParamsDateRange = "12w" - RadarEmailRoutingSummaryARCParamsDateRange24w RadarEmailRoutingSummaryARCParamsDateRange = "24w" - RadarEmailRoutingSummaryARCParamsDateRange52w RadarEmailRoutingSummaryARCParamsDateRange = "52w" - RadarEmailRoutingSummaryARCParamsDateRange1dControl RadarEmailRoutingSummaryARCParamsDateRange = "1dControl" - RadarEmailRoutingSummaryARCParamsDateRange2dControl RadarEmailRoutingSummaryARCParamsDateRange = "2dControl" - RadarEmailRoutingSummaryARCParamsDateRange7dControl RadarEmailRoutingSummaryARCParamsDateRange = "7dControl" - RadarEmailRoutingSummaryARCParamsDateRange14dControl RadarEmailRoutingSummaryARCParamsDateRange = "14dControl" - RadarEmailRoutingSummaryARCParamsDateRange28dControl RadarEmailRoutingSummaryARCParamsDateRange = "28dControl" - RadarEmailRoutingSummaryARCParamsDateRange12wControl RadarEmailRoutingSummaryARCParamsDateRange = "12wControl" - RadarEmailRoutingSummaryARCParamsDateRange24wControl RadarEmailRoutingSummaryARCParamsDateRange = "24wControl" -) - -type RadarEmailRoutingSummaryARCParamsDKIM string - -const ( - RadarEmailRoutingSummaryARCParamsDKIMPass RadarEmailRoutingSummaryARCParamsDKIM = "PASS" - RadarEmailRoutingSummaryARCParamsDKIMNone RadarEmailRoutingSummaryARCParamsDKIM = "NONE" - RadarEmailRoutingSummaryARCParamsDKIMFail RadarEmailRoutingSummaryARCParamsDKIM = "FAIL" -) - -type RadarEmailRoutingSummaryARCParamsDMARC string - -const ( - RadarEmailRoutingSummaryARCParamsDMARCPass RadarEmailRoutingSummaryARCParamsDMARC = "PASS" - RadarEmailRoutingSummaryARCParamsDMARCNone RadarEmailRoutingSummaryARCParamsDMARC = "NONE" - RadarEmailRoutingSummaryARCParamsDMARCFail RadarEmailRoutingSummaryARCParamsDMARC = "FAIL" -) - -type RadarEmailRoutingSummaryARCParamsEncrypted string - -const ( - RadarEmailRoutingSummaryARCParamsEncryptedEncrypted RadarEmailRoutingSummaryARCParamsEncrypted = "ENCRYPTED" - RadarEmailRoutingSummaryARCParamsEncryptedNotEncrypted RadarEmailRoutingSummaryARCParamsEncrypted = "NOT_ENCRYPTED" -) - -// Format results are returned in. -type RadarEmailRoutingSummaryARCParamsFormat string - -const ( - RadarEmailRoutingSummaryARCParamsFormatJson RadarEmailRoutingSummaryARCParamsFormat = "JSON" - RadarEmailRoutingSummaryARCParamsFormatCsv RadarEmailRoutingSummaryARCParamsFormat = "CSV" -) - -type RadarEmailRoutingSummaryARCParamsIPVersion string - -const ( - RadarEmailRoutingSummaryARCParamsIPVersionIPv4 RadarEmailRoutingSummaryARCParamsIPVersion = "IPv4" - RadarEmailRoutingSummaryARCParamsIPVersionIPv6 RadarEmailRoutingSummaryARCParamsIPVersion = "IPv6" -) - -type RadarEmailRoutingSummaryARCParamsSPF string - -const ( - RadarEmailRoutingSummaryARCParamsSPFPass RadarEmailRoutingSummaryARCParamsSPF = "PASS" - RadarEmailRoutingSummaryARCParamsSPFNone RadarEmailRoutingSummaryARCParamsSPF = "NONE" - RadarEmailRoutingSummaryARCParamsSPFFail RadarEmailRoutingSummaryARCParamsSPF = "FAIL" -) - -type RadarEmailRoutingSummaryARCResponseEnvelope struct { - Result RadarEmailRoutingSummaryARCResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailRoutingSummaryARCResponseEnvelopeJSON `json:"-"` -} - -// radarEmailRoutingSummaryARCResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarEmailRoutingSummaryARCResponseEnvelope] -type radarEmailRoutingSummaryARCResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryARCResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryARCResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryDKIMParams struct { - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailRoutingSummaryDKIMParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailRoutingSummaryDKIMParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailRoutingSummaryDKIMParamsDMARC] `query:"dmarc"` - // Filter for encrypted emails. - Encrypted param.Field[[]RadarEmailRoutingSummaryDKIMParamsEncrypted] `query:"encrypted"` - // Format results are returned in. - Format param.Field[RadarEmailRoutingSummaryDKIMParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarEmailRoutingSummaryDKIMParamsIPVersion] `query:"ipVersion"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailRoutingSummaryDKIMParamsSPF] `query:"spf"` -} - -// URLQuery serializes [RadarEmailRoutingSummaryDKIMParams]'s query parameters as -// `url.Values`. -func (r RadarEmailRoutingSummaryDKIMParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarEmailRoutingSummaryDKIMParamsARC string - -const ( - RadarEmailRoutingSummaryDKIMParamsARCPass RadarEmailRoutingSummaryDKIMParamsARC = "PASS" - RadarEmailRoutingSummaryDKIMParamsARCNone RadarEmailRoutingSummaryDKIMParamsARC = "NONE" - RadarEmailRoutingSummaryDKIMParamsARCFail RadarEmailRoutingSummaryDKIMParamsARC = "FAIL" -) - -type RadarEmailRoutingSummaryDKIMParamsDateRange string - -const ( - RadarEmailRoutingSummaryDKIMParamsDateRange1d RadarEmailRoutingSummaryDKIMParamsDateRange = "1d" - RadarEmailRoutingSummaryDKIMParamsDateRange2d RadarEmailRoutingSummaryDKIMParamsDateRange = "2d" - RadarEmailRoutingSummaryDKIMParamsDateRange7d RadarEmailRoutingSummaryDKIMParamsDateRange = "7d" - RadarEmailRoutingSummaryDKIMParamsDateRange14d RadarEmailRoutingSummaryDKIMParamsDateRange = "14d" - RadarEmailRoutingSummaryDKIMParamsDateRange28d RadarEmailRoutingSummaryDKIMParamsDateRange = "28d" - RadarEmailRoutingSummaryDKIMParamsDateRange12w RadarEmailRoutingSummaryDKIMParamsDateRange = "12w" - RadarEmailRoutingSummaryDKIMParamsDateRange24w RadarEmailRoutingSummaryDKIMParamsDateRange = "24w" - RadarEmailRoutingSummaryDKIMParamsDateRange52w RadarEmailRoutingSummaryDKIMParamsDateRange = "52w" - RadarEmailRoutingSummaryDKIMParamsDateRange1dControl RadarEmailRoutingSummaryDKIMParamsDateRange = "1dControl" - RadarEmailRoutingSummaryDKIMParamsDateRange2dControl RadarEmailRoutingSummaryDKIMParamsDateRange = "2dControl" - RadarEmailRoutingSummaryDKIMParamsDateRange7dControl RadarEmailRoutingSummaryDKIMParamsDateRange = "7dControl" - RadarEmailRoutingSummaryDKIMParamsDateRange14dControl RadarEmailRoutingSummaryDKIMParamsDateRange = "14dControl" - RadarEmailRoutingSummaryDKIMParamsDateRange28dControl RadarEmailRoutingSummaryDKIMParamsDateRange = "28dControl" - RadarEmailRoutingSummaryDKIMParamsDateRange12wControl RadarEmailRoutingSummaryDKIMParamsDateRange = "12wControl" - RadarEmailRoutingSummaryDKIMParamsDateRange24wControl RadarEmailRoutingSummaryDKIMParamsDateRange = "24wControl" -) - -type RadarEmailRoutingSummaryDKIMParamsDMARC string - -const ( - RadarEmailRoutingSummaryDKIMParamsDMARCPass RadarEmailRoutingSummaryDKIMParamsDMARC = "PASS" - RadarEmailRoutingSummaryDKIMParamsDMARCNone RadarEmailRoutingSummaryDKIMParamsDMARC = "NONE" - RadarEmailRoutingSummaryDKIMParamsDMARCFail RadarEmailRoutingSummaryDKIMParamsDMARC = "FAIL" -) - -type RadarEmailRoutingSummaryDKIMParamsEncrypted string - -const ( - RadarEmailRoutingSummaryDKIMParamsEncryptedEncrypted RadarEmailRoutingSummaryDKIMParamsEncrypted = "ENCRYPTED" - RadarEmailRoutingSummaryDKIMParamsEncryptedNotEncrypted RadarEmailRoutingSummaryDKIMParamsEncrypted = "NOT_ENCRYPTED" -) - -// Format results are returned in. -type RadarEmailRoutingSummaryDKIMParamsFormat string - -const ( - RadarEmailRoutingSummaryDKIMParamsFormatJson RadarEmailRoutingSummaryDKIMParamsFormat = "JSON" - RadarEmailRoutingSummaryDKIMParamsFormatCsv RadarEmailRoutingSummaryDKIMParamsFormat = "CSV" -) - -type RadarEmailRoutingSummaryDKIMParamsIPVersion string - -const ( - RadarEmailRoutingSummaryDKIMParamsIPVersionIPv4 RadarEmailRoutingSummaryDKIMParamsIPVersion = "IPv4" - RadarEmailRoutingSummaryDKIMParamsIPVersionIPv6 RadarEmailRoutingSummaryDKIMParamsIPVersion = "IPv6" -) - -type RadarEmailRoutingSummaryDKIMParamsSPF string - -const ( - RadarEmailRoutingSummaryDKIMParamsSPFPass RadarEmailRoutingSummaryDKIMParamsSPF = "PASS" - RadarEmailRoutingSummaryDKIMParamsSPFNone RadarEmailRoutingSummaryDKIMParamsSPF = "NONE" - RadarEmailRoutingSummaryDKIMParamsSPFFail RadarEmailRoutingSummaryDKIMParamsSPF = "FAIL" -) - -type RadarEmailRoutingSummaryDKIMResponseEnvelope struct { - Result RadarEmailRoutingSummaryDKIMResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailRoutingSummaryDKIMResponseEnvelopeJSON `json:"-"` -} - -// radarEmailRoutingSummaryDKIMResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarEmailRoutingSummaryDKIMResponseEnvelope] -type radarEmailRoutingSummaryDKIMResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryDKIMResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryDKIMResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryDMARCParams struct { - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailRoutingSummaryDMARCParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailRoutingSummaryDMARCParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailRoutingSummaryDMARCParamsDKIM] `query:"dkim"` - // Filter for encrypted emails. - Encrypted param.Field[[]RadarEmailRoutingSummaryDMARCParamsEncrypted] `query:"encrypted"` - // Format results are returned in. - Format param.Field[RadarEmailRoutingSummaryDMARCParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarEmailRoutingSummaryDMARCParamsIPVersion] `query:"ipVersion"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailRoutingSummaryDMARCParamsSPF] `query:"spf"` -} - -// URLQuery serializes [RadarEmailRoutingSummaryDMARCParams]'s query parameters as -// `url.Values`. -func (r RadarEmailRoutingSummaryDMARCParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarEmailRoutingSummaryDMARCParamsARC string - -const ( - RadarEmailRoutingSummaryDMARCParamsARCPass RadarEmailRoutingSummaryDMARCParamsARC = "PASS" - RadarEmailRoutingSummaryDMARCParamsARCNone RadarEmailRoutingSummaryDMARCParamsARC = "NONE" - RadarEmailRoutingSummaryDMARCParamsARCFail RadarEmailRoutingSummaryDMARCParamsARC = "FAIL" -) - -type RadarEmailRoutingSummaryDMARCParamsDateRange string - -const ( - RadarEmailRoutingSummaryDMARCParamsDateRange1d RadarEmailRoutingSummaryDMARCParamsDateRange = "1d" - RadarEmailRoutingSummaryDMARCParamsDateRange2d RadarEmailRoutingSummaryDMARCParamsDateRange = "2d" - RadarEmailRoutingSummaryDMARCParamsDateRange7d RadarEmailRoutingSummaryDMARCParamsDateRange = "7d" - RadarEmailRoutingSummaryDMARCParamsDateRange14d RadarEmailRoutingSummaryDMARCParamsDateRange = "14d" - RadarEmailRoutingSummaryDMARCParamsDateRange28d RadarEmailRoutingSummaryDMARCParamsDateRange = "28d" - RadarEmailRoutingSummaryDMARCParamsDateRange12w RadarEmailRoutingSummaryDMARCParamsDateRange = "12w" - RadarEmailRoutingSummaryDMARCParamsDateRange24w RadarEmailRoutingSummaryDMARCParamsDateRange = "24w" - RadarEmailRoutingSummaryDMARCParamsDateRange52w RadarEmailRoutingSummaryDMARCParamsDateRange = "52w" - RadarEmailRoutingSummaryDMARCParamsDateRange1dControl RadarEmailRoutingSummaryDMARCParamsDateRange = "1dControl" - RadarEmailRoutingSummaryDMARCParamsDateRange2dControl RadarEmailRoutingSummaryDMARCParamsDateRange = "2dControl" - RadarEmailRoutingSummaryDMARCParamsDateRange7dControl RadarEmailRoutingSummaryDMARCParamsDateRange = "7dControl" - RadarEmailRoutingSummaryDMARCParamsDateRange14dControl RadarEmailRoutingSummaryDMARCParamsDateRange = "14dControl" - RadarEmailRoutingSummaryDMARCParamsDateRange28dControl RadarEmailRoutingSummaryDMARCParamsDateRange = "28dControl" - RadarEmailRoutingSummaryDMARCParamsDateRange12wControl RadarEmailRoutingSummaryDMARCParamsDateRange = "12wControl" - RadarEmailRoutingSummaryDMARCParamsDateRange24wControl RadarEmailRoutingSummaryDMARCParamsDateRange = "24wControl" -) - -type RadarEmailRoutingSummaryDMARCParamsDKIM string - -const ( - RadarEmailRoutingSummaryDMARCParamsDKIMPass RadarEmailRoutingSummaryDMARCParamsDKIM = "PASS" - RadarEmailRoutingSummaryDMARCParamsDKIMNone RadarEmailRoutingSummaryDMARCParamsDKIM = "NONE" - RadarEmailRoutingSummaryDMARCParamsDKIMFail RadarEmailRoutingSummaryDMARCParamsDKIM = "FAIL" -) - -type RadarEmailRoutingSummaryDMARCParamsEncrypted string - -const ( - RadarEmailRoutingSummaryDMARCParamsEncryptedEncrypted RadarEmailRoutingSummaryDMARCParamsEncrypted = "ENCRYPTED" - RadarEmailRoutingSummaryDMARCParamsEncryptedNotEncrypted RadarEmailRoutingSummaryDMARCParamsEncrypted = "NOT_ENCRYPTED" -) - -// Format results are returned in. -type RadarEmailRoutingSummaryDMARCParamsFormat string - -const ( - RadarEmailRoutingSummaryDMARCParamsFormatJson RadarEmailRoutingSummaryDMARCParamsFormat = "JSON" - RadarEmailRoutingSummaryDMARCParamsFormatCsv RadarEmailRoutingSummaryDMARCParamsFormat = "CSV" -) - -type RadarEmailRoutingSummaryDMARCParamsIPVersion string - -const ( - RadarEmailRoutingSummaryDMARCParamsIPVersionIPv4 RadarEmailRoutingSummaryDMARCParamsIPVersion = "IPv4" - RadarEmailRoutingSummaryDMARCParamsIPVersionIPv6 RadarEmailRoutingSummaryDMARCParamsIPVersion = "IPv6" -) - -type RadarEmailRoutingSummaryDMARCParamsSPF string - -const ( - RadarEmailRoutingSummaryDMARCParamsSPFPass RadarEmailRoutingSummaryDMARCParamsSPF = "PASS" - RadarEmailRoutingSummaryDMARCParamsSPFNone RadarEmailRoutingSummaryDMARCParamsSPF = "NONE" - RadarEmailRoutingSummaryDMARCParamsSPFFail RadarEmailRoutingSummaryDMARCParamsSPF = "FAIL" -) - -type RadarEmailRoutingSummaryDMARCResponseEnvelope struct { - Result RadarEmailRoutingSummaryDMARCResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailRoutingSummaryDMARCResponseEnvelopeJSON `json:"-"` -} - -// radarEmailRoutingSummaryDMARCResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarEmailRoutingSummaryDMARCResponseEnvelope] -type radarEmailRoutingSummaryDMARCResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryDMARCResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryDMARCResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryEncryptedParams struct { - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailRoutingSummaryEncryptedParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailRoutingSummaryEncryptedParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailRoutingSummaryEncryptedParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailRoutingSummaryEncryptedParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailRoutingSummaryEncryptedParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarEmailRoutingSummaryEncryptedParamsIPVersion] `query:"ipVersion"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailRoutingSummaryEncryptedParamsSPF] `query:"spf"` -} - -// URLQuery serializes [RadarEmailRoutingSummaryEncryptedParams]'s query parameters -// as `url.Values`. -func (r RadarEmailRoutingSummaryEncryptedParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarEmailRoutingSummaryEncryptedParamsARC string - -const ( - RadarEmailRoutingSummaryEncryptedParamsARCPass RadarEmailRoutingSummaryEncryptedParamsARC = "PASS" - RadarEmailRoutingSummaryEncryptedParamsARCNone RadarEmailRoutingSummaryEncryptedParamsARC = "NONE" - RadarEmailRoutingSummaryEncryptedParamsARCFail RadarEmailRoutingSummaryEncryptedParamsARC = "FAIL" -) - -type RadarEmailRoutingSummaryEncryptedParamsDateRange string - -const ( - RadarEmailRoutingSummaryEncryptedParamsDateRange1d RadarEmailRoutingSummaryEncryptedParamsDateRange = "1d" - RadarEmailRoutingSummaryEncryptedParamsDateRange2d RadarEmailRoutingSummaryEncryptedParamsDateRange = "2d" - RadarEmailRoutingSummaryEncryptedParamsDateRange7d RadarEmailRoutingSummaryEncryptedParamsDateRange = "7d" - RadarEmailRoutingSummaryEncryptedParamsDateRange14d RadarEmailRoutingSummaryEncryptedParamsDateRange = "14d" - RadarEmailRoutingSummaryEncryptedParamsDateRange28d RadarEmailRoutingSummaryEncryptedParamsDateRange = "28d" - RadarEmailRoutingSummaryEncryptedParamsDateRange12w RadarEmailRoutingSummaryEncryptedParamsDateRange = "12w" - RadarEmailRoutingSummaryEncryptedParamsDateRange24w RadarEmailRoutingSummaryEncryptedParamsDateRange = "24w" - RadarEmailRoutingSummaryEncryptedParamsDateRange52w RadarEmailRoutingSummaryEncryptedParamsDateRange = "52w" - RadarEmailRoutingSummaryEncryptedParamsDateRange1dControl RadarEmailRoutingSummaryEncryptedParamsDateRange = "1dControl" - RadarEmailRoutingSummaryEncryptedParamsDateRange2dControl RadarEmailRoutingSummaryEncryptedParamsDateRange = "2dControl" - RadarEmailRoutingSummaryEncryptedParamsDateRange7dControl RadarEmailRoutingSummaryEncryptedParamsDateRange = "7dControl" - RadarEmailRoutingSummaryEncryptedParamsDateRange14dControl RadarEmailRoutingSummaryEncryptedParamsDateRange = "14dControl" - RadarEmailRoutingSummaryEncryptedParamsDateRange28dControl RadarEmailRoutingSummaryEncryptedParamsDateRange = "28dControl" - RadarEmailRoutingSummaryEncryptedParamsDateRange12wControl RadarEmailRoutingSummaryEncryptedParamsDateRange = "12wControl" - RadarEmailRoutingSummaryEncryptedParamsDateRange24wControl RadarEmailRoutingSummaryEncryptedParamsDateRange = "24wControl" -) - -type RadarEmailRoutingSummaryEncryptedParamsDKIM string - -const ( - RadarEmailRoutingSummaryEncryptedParamsDKIMPass RadarEmailRoutingSummaryEncryptedParamsDKIM = "PASS" - RadarEmailRoutingSummaryEncryptedParamsDKIMNone RadarEmailRoutingSummaryEncryptedParamsDKIM = "NONE" - RadarEmailRoutingSummaryEncryptedParamsDKIMFail RadarEmailRoutingSummaryEncryptedParamsDKIM = "FAIL" -) - -type RadarEmailRoutingSummaryEncryptedParamsDMARC string - -const ( - RadarEmailRoutingSummaryEncryptedParamsDMARCPass RadarEmailRoutingSummaryEncryptedParamsDMARC = "PASS" - RadarEmailRoutingSummaryEncryptedParamsDMARCNone RadarEmailRoutingSummaryEncryptedParamsDMARC = "NONE" - RadarEmailRoutingSummaryEncryptedParamsDMARCFail RadarEmailRoutingSummaryEncryptedParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailRoutingSummaryEncryptedParamsFormat string - -const ( - RadarEmailRoutingSummaryEncryptedParamsFormatJson RadarEmailRoutingSummaryEncryptedParamsFormat = "JSON" - RadarEmailRoutingSummaryEncryptedParamsFormatCsv RadarEmailRoutingSummaryEncryptedParamsFormat = "CSV" -) - -type RadarEmailRoutingSummaryEncryptedParamsIPVersion string - -const ( - RadarEmailRoutingSummaryEncryptedParamsIPVersionIPv4 RadarEmailRoutingSummaryEncryptedParamsIPVersion = "IPv4" - RadarEmailRoutingSummaryEncryptedParamsIPVersionIPv6 RadarEmailRoutingSummaryEncryptedParamsIPVersion = "IPv6" -) - -type RadarEmailRoutingSummaryEncryptedParamsSPF string - -const ( - RadarEmailRoutingSummaryEncryptedParamsSPFPass RadarEmailRoutingSummaryEncryptedParamsSPF = "PASS" - RadarEmailRoutingSummaryEncryptedParamsSPFNone RadarEmailRoutingSummaryEncryptedParamsSPF = "NONE" - RadarEmailRoutingSummaryEncryptedParamsSPFFail RadarEmailRoutingSummaryEncryptedParamsSPF = "FAIL" -) - -type RadarEmailRoutingSummaryEncryptedResponseEnvelope struct { - Result RadarEmailRoutingSummaryEncryptedResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailRoutingSummaryEncryptedResponseEnvelopeJSON `json:"-"` -} - -// radarEmailRoutingSummaryEncryptedResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarEmailRoutingSummaryEncryptedResponseEnvelope] -type radarEmailRoutingSummaryEncryptedResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryEncryptedResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryEncryptedResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummaryIPVersionParams struct { - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailRoutingSummaryIPVersionParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailRoutingSummaryIPVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailRoutingSummaryIPVersionParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailRoutingSummaryIPVersionParamsDMARC] `query:"dmarc"` - // Filter for encrypted emails. - Encrypted param.Field[[]RadarEmailRoutingSummaryIPVersionParamsEncrypted] `query:"encrypted"` - // Format results are returned in. - Format param.Field[RadarEmailRoutingSummaryIPVersionParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailRoutingSummaryIPVersionParamsSPF] `query:"spf"` -} - -// URLQuery serializes [RadarEmailRoutingSummaryIPVersionParams]'s query parameters -// as `url.Values`. -func (r RadarEmailRoutingSummaryIPVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarEmailRoutingSummaryIPVersionParamsARC string - -const ( - RadarEmailRoutingSummaryIPVersionParamsARCPass RadarEmailRoutingSummaryIPVersionParamsARC = "PASS" - RadarEmailRoutingSummaryIPVersionParamsARCNone RadarEmailRoutingSummaryIPVersionParamsARC = "NONE" - RadarEmailRoutingSummaryIPVersionParamsARCFail RadarEmailRoutingSummaryIPVersionParamsARC = "FAIL" -) - -type RadarEmailRoutingSummaryIPVersionParamsDateRange string - -const ( - RadarEmailRoutingSummaryIPVersionParamsDateRange1d RadarEmailRoutingSummaryIPVersionParamsDateRange = "1d" - RadarEmailRoutingSummaryIPVersionParamsDateRange2d RadarEmailRoutingSummaryIPVersionParamsDateRange = "2d" - RadarEmailRoutingSummaryIPVersionParamsDateRange7d RadarEmailRoutingSummaryIPVersionParamsDateRange = "7d" - RadarEmailRoutingSummaryIPVersionParamsDateRange14d RadarEmailRoutingSummaryIPVersionParamsDateRange = "14d" - RadarEmailRoutingSummaryIPVersionParamsDateRange28d RadarEmailRoutingSummaryIPVersionParamsDateRange = "28d" - RadarEmailRoutingSummaryIPVersionParamsDateRange12w RadarEmailRoutingSummaryIPVersionParamsDateRange = "12w" - RadarEmailRoutingSummaryIPVersionParamsDateRange24w RadarEmailRoutingSummaryIPVersionParamsDateRange = "24w" - RadarEmailRoutingSummaryIPVersionParamsDateRange52w RadarEmailRoutingSummaryIPVersionParamsDateRange = "52w" - RadarEmailRoutingSummaryIPVersionParamsDateRange1dControl RadarEmailRoutingSummaryIPVersionParamsDateRange = "1dControl" - RadarEmailRoutingSummaryIPVersionParamsDateRange2dControl RadarEmailRoutingSummaryIPVersionParamsDateRange = "2dControl" - RadarEmailRoutingSummaryIPVersionParamsDateRange7dControl RadarEmailRoutingSummaryIPVersionParamsDateRange = "7dControl" - RadarEmailRoutingSummaryIPVersionParamsDateRange14dControl RadarEmailRoutingSummaryIPVersionParamsDateRange = "14dControl" - RadarEmailRoutingSummaryIPVersionParamsDateRange28dControl RadarEmailRoutingSummaryIPVersionParamsDateRange = "28dControl" - RadarEmailRoutingSummaryIPVersionParamsDateRange12wControl RadarEmailRoutingSummaryIPVersionParamsDateRange = "12wControl" - RadarEmailRoutingSummaryIPVersionParamsDateRange24wControl RadarEmailRoutingSummaryIPVersionParamsDateRange = "24wControl" -) - -type RadarEmailRoutingSummaryIPVersionParamsDKIM string - -const ( - RadarEmailRoutingSummaryIPVersionParamsDKIMPass RadarEmailRoutingSummaryIPVersionParamsDKIM = "PASS" - RadarEmailRoutingSummaryIPVersionParamsDKIMNone RadarEmailRoutingSummaryIPVersionParamsDKIM = "NONE" - RadarEmailRoutingSummaryIPVersionParamsDKIMFail RadarEmailRoutingSummaryIPVersionParamsDKIM = "FAIL" -) - -type RadarEmailRoutingSummaryIPVersionParamsDMARC string - -const ( - RadarEmailRoutingSummaryIPVersionParamsDMARCPass RadarEmailRoutingSummaryIPVersionParamsDMARC = "PASS" - RadarEmailRoutingSummaryIPVersionParamsDMARCNone RadarEmailRoutingSummaryIPVersionParamsDMARC = "NONE" - RadarEmailRoutingSummaryIPVersionParamsDMARCFail RadarEmailRoutingSummaryIPVersionParamsDMARC = "FAIL" -) - -type RadarEmailRoutingSummaryIPVersionParamsEncrypted string - -const ( - RadarEmailRoutingSummaryIPVersionParamsEncryptedEncrypted RadarEmailRoutingSummaryIPVersionParamsEncrypted = "ENCRYPTED" - RadarEmailRoutingSummaryIPVersionParamsEncryptedNotEncrypted RadarEmailRoutingSummaryIPVersionParamsEncrypted = "NOT_ENCRYPTED" -) - -// Format results are returned in. -type RadarEmailRoutingSummaryIPVersionParamsFormat string - -const ( - RadarEmailRoutingSummaryIPVersionParamsFormatJson RadarEmailRoutingSummaryIPVersionParamsFormat = "JSON" - RadarEmailRoutingSummaryIPVersionParamsFormatCsv RadarEmailRoutingSummaryIPVersionParamsFormat = "CSV" -) - -type RadarEmailRoutingSummaryIPVersionParamsSPF string - -const ( - RadarEmailRoutingSummaryIPVersionParamsSPFPass RadarEmailRoutingSummaryIPVersionParamsSPF = "PASS" - RadarEmailRoutingSummaryIPVersionParamsSPFNone RadarEmailRoutingSummaryIPVersionParamsSPF = "NONE" - RadarEmailRoutingSummaryIPVersionParamsSPFFail RadarEmailRoutingSummaryIPVersionParamsSPF = "FAIL" -) - -type RadarEmailRoutingSummaryIPVersionResponseEnvelope struct { - Result RadarEmailRoutingSummaryIPVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailRoutingSummaryIPVersionResponseEnvelopeJSON `json:"-"` -} - -// radarEmailRoutingSummaryIPVersionResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarEmailRoutingSummaryIPVersionResponseEnvelope] -type radarEmailRoutingSummaryIPVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummaryIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummaryIPVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingSummarySPFParams struct { - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailRoutingSummarySPFParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailRoutingSummarySPFParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailRoutingSummarySPFParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailRoutingSummarySPFParamsDMARC] `query:"dmarc"` - // Filter for encrypted emails. - Encrypted param.Field[[]RadarEmailRoutingSummarySPFParamsEncrypted] `query:"encrypted"` - // Format results are returned in. - Format param.Field[RadarEmailRoutingSummarySPFParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarEmailRoutingSummarySPFParamsIPVersion] `query:"ipVersion"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarEmailRoutingSummarySPFParams]'s query parameters as -// `url.Values`. -func (r RadarEmailRoutingSummarySPFParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarEmailRoutingSummarySPFParamsARC string - -const ( - RadarEmailRoutingSummarySPFParamsARCPass RadarEmailRoutingSummarySPFParamsARC = "PASS" - RadarEmailRoutingSummarySPFParamsARCNone RadarEmailRoutingSummarySPFParamsARC = "NONE" - RadarEmailRoutingSummarySPFParamsARCFail RadarEmailRoutingSummarySPFParamsARC = "FAIL" -) - -type RadarEmailRoutingSummarySPFParamsDateRange string - -const ( - RadarEmailRoutingSummarySPFParamsDateRange1d RadarEmailRoutingSummarySPFParamsDateRange = "1d" - RadarEmailRoutingSummarySPFParamsDateRange2d RadarEmailRoutingSummarySPFParamsDateRange = "2d" - RadarEmailRoutingSummarySPFParamsDateRange7d RadarEmailRoutingSummarySPFParamsDateRange = "7d" - RadarEmailRoutingSummarySPFParamsDateRange14d RadarEmailRoutingSummarySPFParamsDateRange = "14d" - RadarEmailRoutingSummarySPFParamsDateRange28d RadarEmailRoutingSummarySPFParamsDateRange = "28d" - RadarEmailRoutingSummarySPFParamsDateRange12w RadarEmailRoutingSummarySPFParamsDateRange = "12w" - RadarEmailRoutingSummarySPFParamsDateRange24w RadarEmailRoutingSummarySPFParamsDateRange = "24w" - RadarEmailRoutingSummarySPFParamsDateRange52w RadarEmailRoutingSummarySPFParamsDateRange = "52w" - RadarEmailRoutingSummarySPFParamsDateRange1dControl RadarEmailRoutingSummarySPFParamsDateRange = "1dControl" - RadarEmailRoutingSummarySPFParamsDateRange2dControl RadarEmailRoutingSummarySPFParamsDateRange = "2dControl" - RadarEmailRoutingSummarySPFParamsDateRange7dControl RadarEmailRoutingSummarySPFParamsDateRange = "7dControl" - RadarEmailRoutingSummarySPFParamsDateRange14dControl RadarEmailRoutingSummarySPFParamsDateRange = "14dControl" - RadarEmailRoutingSummarySPFParamsDateRange28dControl RadarEmailRoutingSummarySPFParamsDateRange = "28dControl" - RadarEmailRoutingSummarySPFParamsDateRange12wControl RadarEmailRoutingSummarySPFParamsDateRange = "12wControl" - RadarEmailRoutingSummarySPFParamsDateRange24wControl RadarEmailRoutingSummarySPFParamsDateRange = "24wControl" -) - -type RadarEmailRoutingSummarySPFParamsDKIM string - -const ( - RadarEmailRoutingSummarySPFParamsDKIMPass RadarEmailRoutingSummarySPFParamsDKIM = "PASS" - RadarEmailRoutingSummarySPFParamsDKIMNone RadarEmailRoutingSummarySPFParamsDKIM = "NONE" - RadarEmailRoutingSummarySPFParamsDKIMFail RadarEmailRoutingSummarySPFParamsDKIM = "FAIL" -) - -type RadarEmailRoutingSummarySPFParamsDMARC string - -const ( - RadarEmailRoutingSummarySPFParamsDMARCPass RadarEmailRoutingSummarySPFParamsDMARC = "PASS" - RadarEmailRoutingSummarySPFParamsDMARCNone RadarEmailRoutingSummarySPFParamsDMARC = "NONE" - RadarEmailRoutingSummarySPFParamsDMARCFail RadarEmailRoutingSummarySPFParamsDMARC = "FAIL" -) - -type RadarEmailRoutingSummarySPFParamsEncrypted string - -const ( - RadarEmailRoutingSummarySPFParamsEncryptedEncrypted RadarEmailRoutingSummarySPFParamsEncrypted = "ENCRYPTED" - RadarEmailRoutingSummarySPFParamsEncryptedNotEncrypted RadarEmailRoutingSummarySPFParamsEncrypted = "NOT_ENCRYPTED" -) - -// Format results are returned in. -type RadarEmailRoutingSummarySPFParamsFormat string - -const ( - RadarEmailRoutingSummarySPFParamsFormatJson RadarEmailRoutingSummarySPFParamsFormat = "JSON" - RadarEmailRoutingSummarySPFParamsFormatCsv RadarEmailRoutingSummarySPFParamsFormat = "CSV" -) - -type RadarEmailRoutingSummarySPFParamsIPVersion string - -const ( - RadarEmailRoutingSummarySPFParamsIPVersionIPv4 RadarEmailRoutingSummarySPFParamsIPVersion = "IPv4" - RadarEmailRoutingSummarySPFParamsIPVersionIPv6 RadarEmailRoutingSummarySPFParamsIPVersion = "IPv6" -) - -type RadarEmailRoutingSummarySPFResponseEnvelope struct { - Result RadarEmailRoutingSummarySPFResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailRoutingSummarySPFResponseEnvelopeJSON `json:"-"` -} - -// radarEmailRoutingSummarySPFResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarEmailRoutingSummarySPFResponseEnvelope] -type radarEmailRoutingSummarySPFResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingSummarySPFResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingSummarySPFResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radaremailroutingsummary_test.go b/radaremailroutingsummary_test.go deleted file mode 100644 index 0ce932f2a52..00000000000 --- a/radaremailroutingsummary_test.go +++ /dev/null @@ -1,225 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarEmailRoutingSummaryARCWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Routing.Summary.ARC(context.TODO(), cloudflare.RadarEmailRoutingSummaryARCParams{ - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryARCParamsDateRange{cloudflare.RadarEmailRoutingSummaryARCParamsDateRange1d, cloudflare.RadarEmailRoutingSummaryARCParamsDateRange2d, cloudflare.RadarEmailRoutingSummaryARCParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryARCParamsDKIM{cloudflare.RadarEmailRoutingSummaryARCParamsDKIMPass, cloudflare.RadarEmailRoutingSummaryARCParamsDKIMNone, cloudflare.RadarEmailRoutingSummaryARCParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryARCParamsDMARC{cloudflare.RadarEmailRoutingSummaryARCParamsDMARCPass, cloudflare.RadarEmailRoutingSummaryARCParamsDMARCNone, cloudflare.RadarEmailRoutingSummaryARCParamsDMARCFail}), - Encrypted: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryARCParamsEncrypted{cloudflare.RadarEmailRoutingSummaryARCParamsEncryptedEncrypted, cloudflare.RadarEmailRoutingSummaryARCParamsEncryptedNotEncrypted}), - Format: cloudflare.F(cloudflare.RadarEmailRoutingSummaryARCParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryARCParamsIPVersion{cloudflare.RadarEmailRoutingSummaryARCParamsIPVersionIPv4, cloudflare.RadarEmailRoutingSummaryARCParamsIPVersionIPv6}), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryARCParamsSPF{cloudflare.RadarEmailRoutingSummaryARCParamsSPFPass, cloudflare.RadarEmailRoutingSummaryARCParamsSPFNone, cloudflare.RadarEmailRoutingSummaryARCParamsSPFFail}), - }) - 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 TestRadarEmailRoutingSummaryDKIMWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Routing.Summary.DKIM(context.TODO(), cloudflare.RadarEmailRoutingSummaryDKIMParams{ - ARC: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryDKIMParamsARC{cloudflare.RadarEmailRoutingSummaryDKIMParamsARCPass, cloudflare.RadarEmailRoutingSummaryDKIMParamsARCNone, cloudflare.RadarEmailRoutingSummaryDKIMParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryDKIMParamsDateRange{cloudflare.RadarEmailRoutingSummaryDKIMParamsDateRange1d, cloudflare.RadarEmailRoutingSummaryDKIMParamsDateRange2d, cloudflare.RadarEmailRoutingSummaryDKIMParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DMARC: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryDKIMParamsDMARC{cloudflare.RadarEmailRoutingSummaryDKIMParamsDMARCPass, cloudflare.RadarEmailRoutingSummaryDKIMParamsDMARCNone, cloudflare.RadarEmailRoutingSummaryDKIMParamsDMARCFail}), - Encrypted: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryDKIMParamsEncrypted{cloudflare.RadarEmailRoutingSummaryDKIMParamsEncryptedEncrypted, cloudflare.RadarEmailRoutingSummaryDKIMParamsEncryptedNotEncrypted}), - Format: cloudflare.F(cloudflare.RadarEmailRoutingSummaryDKIMParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryDKIMParamsIPVersion{cloudflare.RadarEmailRoutingSummaryDKIMParamsIPVersionIPv4, cloudflare.RadarEmailRoutingSummaryDKIMParamsIPVersionIPv6}), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryDKIMParamsSPF{cloudflare.RadarEmailRoutingSummaryDKIMParamsSPFPass, cloudflare.RadarEmailRoutingSummaryDKIMParamsSPFNone, cloudflare.RadarEmailRoutingSummaryDKIMParamsSPFFail}), - }) - 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 TestRadarEmailRoutingSummaryDMARCWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Routing.Summary.DMARC(context.TODO(), cloudflare.RadarEmailRoutingSummaryDMARCParams{ - ARC: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryDMARCParamsARC{cloudflare.RadarEmailRoutingSummaryDMARCParamsARCPass, cloudflare.RadarEmailRoutingSummaryDMARCParamsARCNone, cloudflare.RadarEmailRoutingSummaryDMARCParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryDMARCParamsDateRange{cloudflare.RadarEmailRoutingSummaryDMARCParamsDateRange1d, cloudflare.RadarEmailRoutingSummaryDMARCParamsDateRange2d, cloudflare.RadarEmailRoutingSummaryDMARCParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryDMARCParamsDKIM{cloudflare.RadarEmailRoutingSummaryDMARCParamsDKIMPass, cloudflare.RadarEmailRoutingSummaryDMARCParamsDKIMNone, cloudflare.RadarEmailRoutingSummaryDMARCParamsDKIMFail}), - Encrypted: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryDMARCParamsEncrypted{cloudflare.RadarEmailRoutingSummaryDMARCParamsEncryptedEncrypted, cloudflare.RadarEmailRoutingSummaryDMARCParamsEncryptedNotEncrypted}), - Format: cloudflare.F(cloudflare.RadarEmailRoutingSummaryDMARCParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryDMARCParamsIPVersion{cloudflare.RadarEmailRoutingSummaryDMARCParamsIPVersionIPv4, cloudflare.RadarEmailRoutingSummaryDMARCParamsIPVersionIPv6}), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryDMARCParamsSPF{cloudflare.RadarEmailRoutingSummaryDMARCParamsSPFPass, cloudflare.RadarEmailRoutingSummaryDMARCParamsSPFNone, cloudflare.RadarEmailRoutingSummaryDMARCParamsSPFFail}), - }) - 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 TestRadarEmailRoutingSummaryEncryptedWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Routing.Summary.Encrypted(context.TODO(), cloudflare.RadarEmailRoutingSummaryEncryptedParams{ - ARC: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryEncryptedParamsARC{cloudflare.RadarEmailRoutingSummaryEncryptedParamsARCPass, cloudflare.RadarEmailRoutingSummaryEncryptedParamsARCNone, cloudflare.RadarEmailRoutingSummaryEncryptedParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryEncryptedParamsDateRange{cloudflare.RadarEmailRoutingSummaryEncryptedParamsDateRange1d, cloudflare.RadarEmailRoutingSummaryEncryptedParamsDateRange2d, cloudflare.RadarEmailRoutingSummaryEncryptedParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryEncryptedParamsDKIM{cloudflare.RadarEmailRoutingSummaryEncryptedParamsDKIMPass, cloudflare.RadarEmailRoutingSummaryEncryptedParamsDKIMNone, cloudflare.RadarEmailRoutingSummaryEncryptedParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryEncryptedParamsDMARC{cloudflare.RadarEmailRoutingSummaryEncryptedParamsDMARCPass, cloudflare.RadarEmailRoutingSummaryEncryptedParamsDMARCNone, cloudflare.RadarEmailRoutingSummaryEncryptedParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailRoutingSummaryEncryptedParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryEncryptedParamsIPVersion{cloudflare.RadarEmailRoutingSummaryEncryptedParamsIPVersionIPv4, cloudflare.RadarEmailRoutingSummaryEncryptedParamsIPVersionIPv6}), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryEncryptedParamsSPF{cloudflare.RadarEmailRoutingSummaryEncryptedParamsSPFPass, cloudflare.RadarEmailRoutingSummaryEncryptedParamsSPFNone, cloudflare.RadarEmailRoutingSummaryEncryptedParamsSPFFail}), - }) - 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 TestRadarEmailRoutingSummaryIPVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Routing.Summary.IPVersion(context.TODO(), cloudflare.RadarEmailRoutingSummaryIPVersionParams{ - ARC: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryIPVersionParamsARC{cloudflare.RadarEmailRoutingSummaryIPVersionParamsARCPass, cloudflare.RadarEmailRoutingSummaryIPVersionParamsARCNone, cloudflare.RadarEmailRoutingSummaryIPVersionParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryIPVersionParamsDateRange{cloudflare.RadarEmailRoutingSummaryIPVersionParamsDateRange1d, cloudflare.RadarEmailRoutingSummaryIPVersionParamsDateRange2d, cloudflare.RadarEmailRoutingSummaryIPVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryIPVersionParamsDKIM{cloudflare.RadarEmailRoutingSummaryIPVersionParamsDKIMPass, cloudflare.RadarEmailRoutingSummaryIPVersionParamsDKIMNone, cloudflare.RadarEmailRoutingSummaryIPVersionParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryIPVersionParamsDMARC{cloudflare.RadarEmailRoutingSummaryIPVersionParamsDMARCPass, cloudflare.RadarEmailRoutingSummaryIPVersionParamsDMARCNone, cloudflare.RadarEmailRoutingSummaryIPVersionParamsDMARCFail}), - Encrypted: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryIPVersionParamsEncrypted{cloudflare.RadarEmailRoutingSummaryIPVersionParamsEncryptedEncrypted, cloudflare.RadarEmailRoutingSummaryIPVersionParamsEncryptedNotEncrypted}), - Format: cloudflare.F(cloudflare.RadarEmailRoutingSummaryIPVersionParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailRoutingSummaryIPVersionParamsSPF{cloudflare.RadarEmailRoutingSummaryIPVersionParamsSPFPass, cloudflare.RadarEmailRoutingSummaryIPVersionParamsSPFNone, cloudflare.RadarEmailRoutingSummaryIPVersionParamsSPFFail}), - }) - 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 TestRadarEmailRoutingSummarySPFWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Routing.Summary.SPF(context.TODO(), cloudflare.RadarEmailRoutingSummarySPFParams{ - ARC: cloudflare.F([]cloudflare.RadarEmailRoutingSummarySPFParamsARC{cloudflare.RadarEmailRoutingSummarySPFParamsARCPass, cloudflare.RadarEmailRoutingSummarySPFParamsARCNone, cloudflare.RadarEmailRoutingSummarySPFParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailRoutingSummarySPFParamsDateRange{cloudflare.RadarEmailRoutingSummarySPFParamsDateRange1d, cloudflare.RadarEmailRoutingSummarySPFParamsDateRange2d, cloudflare.RadarEmailRoutingSummarySPFParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailRoutingSummarySPFParamsDKIM{cloudflare.RadarEmailRoutingSummarySPFParamsDKIMPass, cloudflare.RadarEmailRoutingSummarySPFParamsDKIMNone, cloudflare.RadarEmailRoutingSummarySPFParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailRoutingSummarySPFParamsDMARC{cloudflare.RadarEmailRoutingSummarySPFParamsDMARCPass, cloudflare.RadarEmailRoutingSummarySPFParamsDMARCNone, cloudflare.RadarEmailRoutingSummarySPFParamsDMARCFail}), - Encrypted: cloudflare.F([]cloudflare.RadarEmailRoutingSummarySPFParamsEncrypted{cloudflare.RadarEmailRoutingSummarySPFParamsEncryptedEncrypted, cloudflare.RadarEmailRoutingSummarySPFParamsEncryptedNotEncrypted}), - Format: cloudflare.F(cloudflare.RadarEmailRoutingSummarySPFParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarEmailRoutingSummarySPFParamsIPVersion{cloudflare.RadarEmailRoutingSummarySPFParamsIPVersionIPv4, cloudflare.RadarEmailRoutingSummarySPFParamsIPVersionIPv6}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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/radaremailroutingtimeseriesgroup.go b/radaremailroutingtimeseriesgroup.go deleted file mode 100644 index 90baca09110..00000000000 --- a/radaremailroutingtimeseriesgroup.go +++ /dev/null @@ -1,1236 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarEmailRoutingTimeseriesGroupService 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 -// [NewRadarEmailRoutingTimeseriesGroupService] method instead. -type RadarEmailRoutingTimeseriesGroupService struct { - Options []option.RequestOption -} - -// NewRadarEmailRoutingTimeseriesGroupService 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 NewRadarEmailRoutingTimeseriesGroupService(opts ...option.RequestOption) (r *RadarEmailRoutingTimeseriesGroupService) { - r = &RadarEmailRoutingTimeseriesGroupService{} - r.Options = opts - return -} - -// Percentage distribution of emails classified per Arc validation over time. -func (r *RadarEmailRoutingTimeseriesGroupService) ARC(ctx context.Context, query RadarEmailRoutingTimeseriesGroupARCParams, opts ...option.RequestOption) (res *RadarEmailRoutingTimeseriesGroupARCResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailRoutingTimeseriesGroupARCResponseEnvelope - path := "radar/email/routing/timeseries_groups/arc" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified per DKIM validation over time. -func (r *RadarEmailRoutingTimeseriesGroupService) DKIM(ctx context.Context, query RadarEmailRoutingTimeseriesGroupDKIMParams, opts ...option.RequestOption) (res *RadarEmailRoutingTimeseriesGroupDKIMResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailRoutingTimeseriesGroupDKIMResponseEnvelope - path := "radar/email/routing/timeseries_groups/dkim" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified per DMARC validation over time. -func (r *RadarEmailRoutingTimeseriesGroupService) DMARC(ctx context.Context, query RadarEmailRoutingTimeseriesGroupDMARCParams, opts ...option.RequestOption) (res *RadarEmailRoutingTimeseriesGroupDMARCResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailRoutingTimeseriesGroupDMARCResponseEnvelope - path := "radar/email/routing/timeseries_groups/dmarc" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails by Encrypted over time. -func (r *RadarEmailRoutingTimeseriesGroupService) Encrypted(ctx context.Context, query RadarEmailRoutingTimeseriesGroupEncryptedParams, opts ...option.RequestOption) (res *RadarEmailRoutingTimeseriesGroupEncryptedResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailRoutingTimeseriesGroupEncryptedResponseEnvelope - path := "radar/email/routing/timeseries_groups/encrypted" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails by Ip Version over time. -func (r *RadarEmailRoutingTimeseriesGroupService) IPVersion(ctx context.Context, query RadarEmailRoutingTimeseriesGroupIPVersionParams, opts ...option.RequestOption) (res *RadarEmailRoutingTimeseriesGroupIPVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailRoutingTimeseriesGroupIPVersionResponseEnvelope - path := "radar/email/routing/timeseries_groups/ip_version" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified per SPF validation over time. -func (r *RadarEmailRoutingTimeseriesGroupService) SPF(ctx context.Context, query RadarEmailRoutingTimeseriesGroupSPFParams, opts ...option.RequestOption) (res *RadarEmailRoutingTimeseriesGroupSPFResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailRoutingTimeseriesGroupSPFResponseEnvelope - path := "radar/email/routing/timeseries_groups/spf" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarEmailRoutingTimeseriesGroupARCResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarEmailRoutingTimeseriesGroupARCResponseSerie0 `json:"serie_0,required"` - JSON radarEmailRoutingTimeseriesGroupARCResponseJSON `json:"-"` -} - -// radarEmailRoutingTimeseriesGroupARCResponseJSON contains the JSON metadata for -// the struct [RadarEmailRoutingTimeseriesGroupARCResponse] -type radarEmailRoutingTimeseriesGroupARCResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingTimeseriesGroupARCResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingTimeseriesGroupARCResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingTimeseriesGroupARCResponseSerie0 struct { - Fail []string `json:"FAIL,required"` - None []string `json:"NONE,required"` - Pass []string `json:"PASS,required"` - JSON radarEmailRoutingTimeseriesGroupARCResponseSerie0JSON `json:"-"` -} - -// radarEmailRoutingTimeseriesGroupARCResponseSerie0JSON contains the JSON metadata -// for the struct [RadarEmailRoutingTimeseriesGroupARCResponseSerie0] -type radarEmailRoutingTimeseriesGroupARCResponseSerie0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingTimeseriesGroupARCResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingTimeseriesGroupARCResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingTimeseriesGroupDKIMResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarEmailRoutingTimeseriesGroupDKIMResponseSerie0 `json:"serie_0,required"` - JSON radarEmailRoutingTimeseriesGroupDKIMResponseJSON `json:"-"` -} - -// radarEmailRoutingTimeseriesGroupDKIMResponseJSON contains the JSON metadata for -// the struct [RadarEmailRoutingTimeseriesGroupDKIMResponse] -type radarEmailRoutingTimeseriesGroupDKIMResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingTimeseriesGroupDKIMResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingTimeseriesGroupDKIMResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingTimeseriesGroupDKIMResponseSerie0 struct { - Fail []string `json:"FAIL,required"` - None []string `json:"NONE,required"` - Pass []string `json:"PASS,required"` - JSON radarEmailRoutingTimeseriesGroupDKIMResponseSerie0JSON `json:"-"` -} - -// radarEmailRoutingTimeseriesGroupDKIMResponseSerie0JSON contains the JSON -// metadata for the struct [RadarEmailRoutingTimeseriesGroupDKIMResponseSerie0] -type radarEmailRoutingTimeseriesGroupDKIMResponseSerie0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingTimeseriesGroupDKIMResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingTimeseriesGroupDKIMResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingTimeseriesGroupDMARCResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarEmailRoutingTimeseriesGroupDMARCResponseSerie0 `json:"serie_0,required"` - JSON radarEmailRoutingTimeseriesGroupDMARCResponseJSON `json:"-"` -} - -// radarEmailRoutingTimeseriesGroupDMARCResponseJSON contains the JSON metadata for -// the struct [RadarEmailRoutingTimeseriesGroupDMARCResponse] -type radarEmailRoutingTimeseriesGroupDMARCResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingTimeseriesGroupDMARCResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingTimeseriesGroupDMARCResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingTimeseriesGroupDMARCResponseSerie0 struct { - Fail []string `json:"FAIL,required"` - None []string `json:"NONE,required"` - Pass []string `json:"PASS,required"` - JSON radarEmailRoutingTimeseriesGroupDMARCResponseSerie0JSON `json:"-"` -} - -// radarEmailRoutingTimeseriesGroupDMARCResponseSerie0JSON contains the JSON -// metadata for the struct [RadarEmailRoutingTimeseriesGroupDMARCResponseSerie0] -type radarEmailRoutingTimeseriesGroupDMARCResponseSerie0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingTimeseriesGroupDMARCResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingTimeseriesGroupDMARCResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingTimeseriesGroupEncryptedResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarEmailRoutingTimeseriesGroupEncryptedResponseSerie0 `json:"serie_0,required"` - JSON radarEmailRoutingTimeseriesGroupEncryptedResponseJSON `json:"-"` -} - -// radarEmailRoutingTimeseriesGroupEncryptedResponseJSON contains the JSON metadata -// for the struct [RadarEmailRoutingTimeseriesGroupEncryptedResponse] -type radarEmailRoutingTimeseriesGroupEncryptedResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingTimeseriesGroupEncryptedResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingTimeseriesGroupEncryptedResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingTimeseriesGroupEncryptedResponseSerie0 struct { - Encrypted []string `json:"ENCRYPTED,required"` - NotEncrypted []string `json:"NOT_ENCRYPTED,required"` - JSON radarEmailRoutingTimeseriesGroupEncryptedResponseSerie0JSON `json:"-"` -} - -// radarEmailRoutingTimeseriesGroupEncryptedResponseSerie0JSON contains the JSON -// metadata for the struct -// [RadarEmailRoutingTimeseriesGroupEncryptedResponseSerie0] -type radarEmailRoutingTimeseriesGroupEncryptedResponseSerie0JSON struct { - Encrypted apijson.Field - NotEncrypted apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingTimeseriesGroupEncryptedResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingTimeseriesGroupEncryptedResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingTimeseriesGroupIPVersionResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarEmailRoutingTimeseriesGroupIPVersionResponseSerie0 `json:"serie_0,required"` - JSON radarEmailRoutingTimeseriesGroupIPVersionResponseJSON `json:"-"` -} - -// radarEmailRoutingTimeseriesGroupIPVersionResponseJSON contains the JSON metadata -// for the struct [RadarEmailRoutingTimeseriesGroupIPVersionResponse] -type radarEmailRoutingTimeseriesGroupIPVersionResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingTimeseriesGroupIPVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingTimeseriesGroupIPVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingTimeseriesGroupIPVersionResponseSerie0 struct { - IPv4 []string `json:"IPv4,required"` - IPv6 []string `json:"IPv6,required"` - JSON radarEmailRoutingTimeseriesGroupIPVersionResponseSerie0JSON `json:"-"` -} - -// radarEmailRoutingTimeseriesGroupIPVersionResponseSerie0JSON contains the JSON -// metadata for the struct -// [RadarEmailRoutingTimeseriesGroupIPVersionResponseSerie0] -type radarEmailRoutingTimeseriesGroupIPVersionResponseSerie0JSON struct { - IPv4 apijson.Field - IPv6 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingTimeseriesGroupIPVersionResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingTimeseriesGroupIPVersionResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingTimeseriesGroupSPFResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarEmailRoutingTimeseriesGroupSPFResponseSerie0 `json:"serie_0,required"` - JSON radarEmailRoutingTimeseriesGroupSPFResponseJSON `json:"-"` -} - -// radarEmailRoutingTimeseriesGroupSPFResponseJSON contains the JSON metadata for -// the struct [RadarEmailRoutingTimeseriesGroupSPFResponse] -type radarEmailRoutingTimeseriesGroupSPFResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingTimeseriesGroupSPFResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingTimeseriesGroupSPFResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingTimeseriesGroupSPFResponseSerie0 struct { - Fail []string `json:"FAIL,required"` - None []string `json:"NONE,required"` - Pass []string `json:"PASS,required"` - JSON radarEmailRoutingTimeseriesGroupSPFResponseSerie0JSON `json:"-"` -} - -// radarEmailRoutingTimeseriesGroupSPFResponseSerie0JSON contains the JSON metadata -// for the struct [RadarEmailRoutingTimeseriesGroupSPFResponseSerie0] -type radarEmailRoutingTimeseriesGroupSPFResponseSerie0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingTimeseriesGroupSPFResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingTimeseriesGroupSPFResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingTimeseriesGroupARCParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarEmailRoutingTimeseriesGroupARCParamsAggInterval] `query:"aggInterval"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailRoutingTimeseriesGroupARCParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailRoutingTimeseriesGroupARCParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailRoutingTimeseriesGroupARCParamsDMARC] `query:"dmarc"` - // Filter for encrypted emails. - Encrypted param.Field[[]RadarEmailRoutingTimeseriesGroupARCParamsEncrypted] `query:"encrypted"` - // Format results are returned in. - Format param.Field[RadarEmailRoutingTimeseriesGroupARCParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarEmailRoutingTimeseriesGroupARCParamsIPVersion] `query:"ipVersion"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailRoutingTimeseriesGroupARCParamsSPF] `query:"spf"` -} - -// URLQuery serializes [RadarEmailRoutingTimeseriesGroupARCParams]'s query -// parameters as `url.Values`. -func (r RadarEmailRoutingTimeseriesGroupARCParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarEmailRoutingTimeseriesGroupARCParamsAggInterval string - -const ( - RadarEmailRoutingTimeseriesGroupARCParamsAggInterval15m RadarEmailRoutingTimeseriesGroupARCParamsAggInterval = "15m" - RadarEmailRoutingTimeseriesGroupARCParamsAggInterval1h RadarEmailRoutingTimeseriesGroupARCParamsAggInterval = "1h" - RadarEmailRoutingTimeseriesGroupARCParamsAggInterval1d RadarEmailRoutingTimeseriesGroupARCParamsAggInterval = "1d" - RadarEmailRoutingTimeseriesGroupARCParamsAggInterval1w RadarEmailRoutingTimeseriesGroupARCParamsAggInterval = "1w" -) - -type RadarEmailRoutingTimeseriesGroupARCParamsDateRange string - -const ( - RadarEmailRoutingTimeseriesGroupARCParamsDateRange1d RadarEmailRoutingTimeseriesGroupARCParamsDateRange = "1d" - RadarEmailRoutingTimeseriesGroupARCParamsDateRange2d RadarEmailRoutingTimeseriesGroupARCParamsDateRange = "2d" - RadarEmailRoutingTimeseriesGroupARCParamsDateRange7d RadarEmailRoutingTimeseriesGroupARCParamsDateRange = "7d" - RadarEmailRoutingTimeseriesGroupARCParamsDateRange14d RadarEmailRoutingTimeseriesGroupARCParamsDateRange = "14d" - RadarEmailRoutingTimeseriesGroupARCParamsDateRange28d RadarEmailRoutingTimeseriesGroupARCParamsDateRange = "28d" - RadarEmailRoutingTimeseriesGroupARCParamsDateRange12w RadarEmailRoutingTimeseriesGroupARCParamsDateRange = "12w" - RadarEmailRoutingTimeseriesGroupARCParamsDateRange24w RadarEmailRoutingTimeseriesGroupARCParamsDateRange = "24w" - RadarEmailRoutingTimeseriesGroupARCParamsDateRange52w RadarEmailRoutingTimeseriesGroupARCParamsDateRange = "52w" - RadarEmailRoutingTimeseriesGroupARCParamsDateRange1dControl RadarEmailRoutingTimeseriesGroupARCParamsDateRange = "1dControl" - RadarEmailRoutingTimeseriesGroupARCParamsDateRange2dControl RadarEmailRoutingTimeseriesGroupARCParamsDateRange = "2dControl" - RadarEmailRoutingTimeseriesGroupARCParamsDateRange7dControl RadarEmailRoutingTimeseriesGroupARCParamsDateRange = "7dControl" - RadarEmailRoutingTimeseriesGroupARCParamsDateRange14dControl RadarEmailRoutingTimeseriesGroupARCParamsDateRange = "14dControl" - RadarEmailRoutingTimeseriesGroupARCParamsDateRange28dControl RadarEmailRoutingTimeseriesGroupARCParamsDateRange = "28dControl" - RadarEmailRoutingTimeseriesGroupARCParamsDateRange12wControl RadarEmailRoutingTimeseriesGroupARCParamsDateRange = "12wControl" - RadarEmailRoutingTimeseriesGroupARCParamsDateRange24wControl RadarEmailRoutingTimeseriesGroupARCParamsDateRange = "24wControl" -) - -type RadarEmailRoutingTimeseriesGroupARCParamsDKIM string - -const ( - RadarEmailRoutingTimeseriesGroupARCParamsDKIMPass RadarEmailRoutingTimeseriesGroupARCParamsDKIM = "PASS" - RadarEmailRoutingTimeseriesGroupARCParamsDKIMNone RadarEmailRoutingTimeseriesGroupARCParamsDKIM = "NONE" - RadarEmailRoutingTimeseriesGroupARCParamsDKIMFail RadarEmailRoutingTimeseriesGroupARCParamsDKIM = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupARCParamsDMARC string - -const ( - RadarEmailRoutingTimeseriesGroupARCParamsDMARCPass RadarEmailRoutingTimeseriesGroupARCParamsDMARC = "PASS" - RadarEmailRoutingTimeseriesGroupARCParamsDMARCNone RadarEmailRoutingTimeseriesGroupARCParamsDMARC = "NONE" - RadarEmailRoutingTimeseriesGroupARCParamsDMARCFail RadarEmailRoutingTimeseriesGroupARCParamsDMARC = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupARCParamsEncrypted string - -const ( - RadarEmailRoutingTimeseriesGroupARCParamsEncryptedEncrypted RadarEmailRoutingTimeseriesGroupARCParamsEncrypted = "ENCRYPTED" - RadarEmailRoutingTimeseriesGroupARCParamsEncryptedNotEncrypted RadarEmailRoutingTimeseriesGroupARCParamsEncrypted = "NOT_ENCRYPTED" -) - -// Format results are returned in. -type RadarEmailRoutingTimeseriesGroupARCParamsFormat string - -const ( - RadarEmailRoutingTimeseriesGroupARCParamsFormatJson RadarEmailRoutingTimeseriesGroupARCParamsFormat = "JSON" - RadarEmailRoutingTimeseriesGroupARCParamsFormatCsv RadarEmailRoutingTimeseriesGroupARCParamsFormat = "CSV" -) - -type RadarEmailRoutingTimeseriesGroupARCParamsIPVersion string - -const ( - RadarEmailRoutingTimeseriesGroupARCParamsIPVersionIPv4 RadarEmailRoutingTimeseriesGroupARCParamsIPVersion = "IPv4" - RadarEmailRoutingTimeseriesGroupARCParamsIPVersionIPv6 RadarEmailRoutingTimeseriesGroupARCParamsIPVersion = "IPv6" -) - -type RadarEmailRoutingTimeseriesGroupARCParamsSPF string - -const ( - RadarEmailRoutingTimeseriesGroupARCParamsSPFPass RadarEmailRoutingTimeseriesGroupARCParamsSPF = "PASS" - RadarEmailRoutingTimeseriesGroupARCParamsSPFNone RadarEmailRoutingTimeseriesGroupARCParamsSPF = "NONE" - RadarEmailRoutingTimeseriesGroupARCParamsSPFFail RadarEmailRoutingTimeseriesGroupARCParamsSPF = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupARCResponseEnvelope struct { - Result RadarEmailRoutingTimeseriesGroupARCResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailRoutingTimeseriesGroupARCResponseEnvelopeJSON `json:"-"` -} - -// radarEmailRoutingTimeseriesGroupARCResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarEmailRoutingTimeseriesGroupARCResponseEnvelope] -type radarEmailRoutingTimeseriesGroupARCResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingTimeseriesGroupARCResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingTimeseriesGroupARCResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingTimeseriesGroupDKIMParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarEmailRoutingTimeseriesGroupDKIMParamsAggInterval] `query:"aggInterval"` - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailRoutingTimeseriesGroupDKIMParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailRoutingTimeseriesGroupDKIMParamsDMARC] `query:"dmarc"` - // Filter for encrypted emails. - Encrypted param.Field[[]RadarEmailRoutingTimeseriesGroupDKIMParamsEncrypted] `query:"encrypted"` - // Format results are returned in. - Format param.Field[RadarEmailRoutingTimeseriesGroupDKIMParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarEmailRoutingTimeseriesGroupDKIMParamsIPVersion] `query:"ipVersion"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailRoutingTimeseriesGroupDKIMParamsSPF] `query:"spf"` -} - -// URLQuery serializes [RadarEmailRoutingTimeseriesGroupDKIMParams]'s query -// parameters as `url.Values`. -func (r RadarEmailRoutingTimeseriesGroupDKIMParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarEmailRoutingTimeseriesGroupDKIMParamsAggInterval string - -const ( - RadarEmailRoutingTimeseriesGroupDKIMParamsAggInterval15m RadarEmailRoutingTimeseriesGroupDKIMParamsAggInterval = "15m" - RadarEmailRoutingTimeseriesGroupDKIMParamsAggInterval1h RadarEmailRoutingTimeseriesGroupDKIMParamsAggInterval = "1h" - RadarEmailRoutingTimeseriesGroupDKIMParamsAggInterval1d RadarEmailRoutingTimeseriesGroupDKIMParamsAggInterval = "1d" - RadarEmailRoutingTimeseriesGroupDKIMParamsAggInterval1w RadarEmailRoutingTimeseriesGroupDKIMParamsAggInterval = "1w" -) - -type RadarEmailRoutingTimeseriesGroupDKIMParamsARC string - -const ( - RadarEmailRoutingTimeseriesGroupDKIMParamsARCPass RadarEmailRoutingTimeseriesGroupDKIMParamsARC = "PASS" - RadarEmailRoutingTimeseriesGroupDKIMParamsARCNone RadarEmailRoutingTimeseriesGroupDKIMParamsARC = "NONE" - RadarEmailRoutingTimeseriesGroupDKIMParamsARCFail RadarEmailRoutingTimeseriesGroupDKIMParamsARC = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange string - -const ( - RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange1d RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange = "1d" - RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange2d RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange = "2d" - RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange7d RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange = "7d" - RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange14d RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange = "14d" - RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange28d RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange = "28d" - RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange12w RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange = "12w" - RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange24w RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange = "24w" - RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange52w RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange = "52w" - RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange1dControl RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange = "1dControl" - RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange2dControl RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange = "2dControl" - RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange7dControl RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange = "7dControl" - RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange14dControl RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange = "14dControl" - RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange28dControl RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange = "28dControl" - RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange12wControl RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange = "12wControl" - RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange24wControl RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange = "24wControl" -) - -type RadarEmailRoutingTimeseriesGroupDKIMParamsDMARC string - -const ( - RadarEmailRoutingTimeseriesGroupDKIMParamsDMARCPass RadarEmailRoutingTimeseriesGroupDKIMParamsDMARC = "PASS" - RadarEmailRoutingTimeseriesGroupDKIMParamsDMARCNone RadarEmailRoutingTimeseriesGroupDKIMParamsDMARC = "NONE" - RadarEmailRoutingTimeseriesGroupDKIMParamsDMARCFail RadarEmailRoutingTimeseriesGroupDKIMParamsDMARC = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupDKIMParamsEncrypted string - -const ( - RadarEmailRoutingTimeseriesGroupDKIMParamsEncryptedEncrypted RadarEmailRoutingTimeseriesGroupDKIMParamsEncrypted = "ENCRYPTED" - RadarEmailRoutingTimeseriesGroupDKIMParamsEncryptedNotEncrypted RadarEmailRoutingTimeseriesGroupDKIMParamsEncrypted = "NOT_ENCRYPTED" -) - -// Format results are returned in. -type RadarEmailRoutingTimeseriesGroupDKIMParamsFormat string - -const ( - RadarEmailRoutingTimeseriesGroupDKIMParamsFormatJson RadarEmailRoutingTimeseriesGroupDKIMParamsFormat = "JSON" - RadarEmailRoutingTimeseriesGroupDKIMParamsFormatCsv RadarEmailRoutingTimeseriesGroupDKIMParamsFormat = "CSV" -) - -type RadarEmailRoutingTimeseriesGroupDKIMParamsIPVersion string - -const ( - RadarEmailRoutingTimeseriesGroupDKIMParamsIPVersionIPv4 RadarEmailRoutingTimeseriesGroupDKIMParamsIPVersion = "IPv4" - RadarEmailRoutingTimeseriesGroupDKIMParamsIPVersionIPv6 RadarEmailRoutingTimeseriesGroupDKIMParamsIPVersion = "IPv6" -) - -type RadarEmailRoutingTimeseriesGroupDKIMParamsSPF string - -const ( - RadarEmailRoutingTimeseriesGroupDKIMParamsSPFPass RadarEmailRoutingTimeseriesGroupDKIMParamsSPF = "PASS" - RadarEmailRoutingTimeseriesGroupDKIMParamsSPFNone RadarEmailRoutingTimeseriesGroupDKIMParamsSPF = "NONE" - RadarEmailRoutingTimeseriesGroupDKIMParamsSPFFail RadarEmailRoutingTimeseriesGroupDKIMParamsSPF = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupDKIMResponseEnvelope struct { - Result RadarEmailRoutingTimeseriesGroupDKIMResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailRoutingTimeseriesGroupDKIMResponseEnvelopeJSON `json:"-"` -} - -// radarEmailRoutingTimeseriesGroupDKIMResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarEmailRoutingTimeseriesGroupDKIMResponseEnvelope] -type radarEmailRoutingTimeseriesGroupDKIMResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingTimeseriesGroupDKIMResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingTimeseriesGroupDKIMResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingTimeseriesGroupDMARCParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarEmailRoutingTimeseriesGroupDMARCParamsAggInterval] `query:"aggInterval"` - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailRoutingTimeseriesGroupDMARCParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailRoutingTimeseriesGroupDMARCParamsDKIM] `query:"dkim"` - // Filter for encrypted emails. - Encrypted param.Field[[]RadarEmailRoutingTimeseriesGroupDMARCParamsEncrypted] `query:"encrypted"` - // Format results are returned in. - Format param.Field[RadarEmailRoutingTimeseriesGroupDMARCParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarEmailRoutingTimeseriesGroupDMARCParamsIPVersion] `query:"ipVersion"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailRoutingTimeseriesGroupDMARCParamsSPF] `query:"spf"` -} - -// URLQuery serializes [RadarEmailRoutingTimeseriesGroupDMARCParams]'s query -// parameters as `url.Values`. -func (r RadarEmailRoutingTimeseriesGroupDMARCParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarEmailRoutingTimeseriesGroupDMARCParamsAggInterval string - -const ( - RadarEmailRoutingTimeseriesGroupDMARCParamsAggInterval15m RadarEmailRoutingTimeseriesGroupDMARCParamsAggInterval = "15m" - RadarEmailRoutingTimeseriesGroupDMARCParamsAggInterval1h RadarEmailRoutingTimeseriesGroupDMARCParamsAggInterval = "1h" - RadarEmailRoutingTimeseriesGroupDMARCParamsAggInterval1d RadarEmailRoutingTimeseriesGroupDMARCParamsAggInterval = "1d" - RadarEmailRoutingTimeseriesGroupDMARCParamsAggInterval1w RadarEmailRoutingTimeseriesGroupDMARCParamsAggInterval = "1w" -) - -type RadarEmailRoutingTimeseriesGroupDMARCParamsARC string - -const ( - RadarEmailRoutingTimeseriesGroupDMARCParamsARCPass RadarEmailRoutingTimeseriesGroupDMARCParamsARC = "PASS" - RadarEmailRoutingTimeseriesGroupDMARCParamsARCNone RadarEmailRoutingTimeseriesGroupDMARCParamsARC = "NONE" - RadarEmailRoutingTimeseriesGroupDMARCParamsARCFail RadarEmailRoutingTimeseriesGroupDMARCParamsARC = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange string - -const ( - RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange1d RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange = "1d" - RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange2d RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange = "2d" - RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange7d RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange = "7d" - RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange14d RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange = "14d" - RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange28d RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange = "28d" - RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange12w RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange = "12w" - RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange24w RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange = "24w" - RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange52w RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange = "52w" - RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange1dControl RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange = "1dControl" - RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange2dControl RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange = "2dControl" - RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange7dControl RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange = "7dControl" - RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange14dControl RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange = "14dControl" - RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange28dControl RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange = "28dControl" - RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange12wControl RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange = "12wControl" - RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange24wControl RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange = "24wControl" -) - -type RadarEmailRoutingTimeseriesGroupDMARCParamsDKIM string - -const ( - RadarEmailRoutingTimeseriesGroupDMARCParamsDKIMPass RadarEmailRoutingTimeseriesGroupDMARCParamsDKIM = "PASS" - RadarEmailRoutingTimeseriesGroupDMARCParamsDKIMNone RadarEmailRoutingTimeseriesGroupDMARCParamsDKIM = "NONE" - RadarEmailRoutingTimeseriesGroupDMARCParamsDKIMFail RadarEmailRoutingTimeseriesGroupDMARCParamsDKIM = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupDMARCParamsEncrypted string - -const ( - RadarEmailRoutingTimeseriesGroupDMARCParamsEncryptedEncrypted RadarEmailRoutingTimeseriesGroupDMARCParamsEncrypted = "ENCRYPTED" - RadarEmailRoutingTimeseriesGroupDMARCParamsEncryptedNotEncrypted RadarEmailRoutingTimeseriesGroupDMARCParamsEncrypted = "NOT_ENCRYPTED" -) - -// Format results are returned in. -type RadarEmailRoutingTimeseriesGroupDMARCParamsFormat string - -const ( - RadarEmailRoutingTimeseriesGroupDMARCParamsFormatJson RadarEmailRoutingTimeseriesGroupDMARCParamsFormat = "JSON" - RadarEmailRoutingTimeseriesGroupDMARCParamsFormatCsv RadarEmailRoutingTimeseriesGroupDMARCParamsFormat = "CSV" -) - -type RadarEmailRoutingTimeseriesGroupDMARCParamsIPVersion string - -const ( - RadarEmailRoutingTimeseriesGroupDMARCParamsIPVersionIPv4 RadarEmailRoutingTimeseriesGroupDMARCParamsIPVersion = "IPv4" - RadarEmailRoutingTimeseriesGroupDMARCParamsIPVersionIPv6 RadarEmailRoutingTimeseriesGroupDMARCParamsIPVersion = "IPv6" -) - -type RadarEmailRoutingTimeseriesGroupDMARCParamsSPF string - -const ( - RadarEmailRoutingTimeseriesGroupDMARCParamsSPFPass RadarEmailRoutingTimeseriesGroupDMARCParamsSPF = "PASS" - RadarEmailRoutingTimeseriesGroupDMARCParamsSPFNone RadarEmailRoutingTimeseriesGroupDMARCParamsSPF = "NONE" - RadarEmailRoutingTimeseriesGroupDMARCParamsSPFFail RadarEmailRoutingTimeseriesGroupDMARCParamsSPF = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupDMARCResponseEnvelope struct { - Result RadarEmailRoutingTimeseriesGroupDMARCResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailRoutingTimeseriesGroupDMARCResponseEnvelopeJSON `json:"-"` -} - -// radarEmailRoutingTimeseriesGroupDMARCResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarEmailRoutingTimeseriesGroupDMARCResponseEnvelope] -type radarEmailRoutingTimeseriesGroupDMARCResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingTimeseriesGroupDMARCResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingTimeseriesGroupDMARCResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingTimeseriesGroupEncryptedParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarEmailRoutingTimeseriesGroupEncryptedParamsAggInterval] `query:"aggInterval"` - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailRoutingTimeseriesGroupEncryptedParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailRoutingTimeseriesGroupEncryptedParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailRoutingTimeseriesGroupEncryptedParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailRoutingTimeseriesGroupEncryptedParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarEmailRoutingTimeseriesGroupEncryptedParamsIPVersion] `query:"ipVersion"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailRoutingTimeseriesGroupEncryptedParamsSPF] `query:"spf"` -} - -// URLQuery serializes [RadarEmailRoutingTimeseriesGroupEncryptedParams]'s query -// parameters as `url.Values`. -func (r RadarEmailRoutingTimeseriesGroupEncryptedParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarEmailRoutingTimeseriesGroupEncryptedParamsAggInterval string - -const ( - RadarEmailRoutingTimeseriesGroupEncryptedParamsAggInterval15m RadarEmailRoutingTimeseriesGroupEncryptedParamsAggInterval = "15m" - RadarEmailRoutingTimeseriesGroupEncryptedParamsAggInterval1h RadarEmailRoutingTimeseriesGroupEncryptedParamsAggInterval = "1h" - RadarEmailRoutingTimeseriesGroupEncryptedParamsAggInterval1d RadarEmailRoutingTimeseriesGroupEncryptedParamsAggInterval = "1d" - RadarEmailRoutingTimeseriesGroupEncryptedParamsAggInterval1w RadarEmailRoutingTimeseriesGroupEncryptedParamsAggInterval = "1w" -) - -type RadarEmailRoutingTimeseriesGroupEncryptedParamsARC string - -const ( - RadarEmailRoutingTimeseriesGroupEncryptedParamsARCPass RadarEmailRoutingTimeseriesGroupEncryptedParamsARC = "PASS" - RadarEmailRoutingTimeseriesGroupEncryptedParamsARCNone RadarEmailRoutingTimeseriesGroupEncryptedParamsARC = "NONE" - RadarEmailRoutingTimeseriesGroupEncryptedParamsARCFail RadarEmailRoutingTimeseriesGroupEncryptedParamsARC = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange string - -const ( - RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange1d RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange = "1d" - RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange2d RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange = "2d" - RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange7d RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange = "7d" - RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange14d RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange = "14d" - RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange28d RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange = "28d" - RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange12w RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange = "12w" - RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange24w RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange = "24w" - RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange52w RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange = "52w" - RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange1dControl RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange = "1dControl" - RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange2dControl RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange = "2dControl" - RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange7dControl RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange = "7dControl" - RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange14dControl RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange = "14dControl" - RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange28dControl RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange = "28dControl" - RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange12wControl RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange = "12wControl" - RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange24wControl RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange = "24wControl" -) - -type RadarEmailRoutingTimeseriesGroupEncryptedParamsDKIM string - -const ( - RadarEmailRoutingTimeseriesGroupEncryptedParamsDKIMPass RadarEmailRoutingTimeseriesGroupEncryptedParamsDKIM = "PASS" - RadarEmailRoutingTimeseriesGroupEncryptedParamsDKIMNone RadarEmailRoutingTimeseriesGroupEncryptedParamsDKIM = "NONE" - RadarEmailRoutingTimeseriesGroupEncryptedParamsDKIMFail RadarEmailRoutingTimeseriesGroupEncryptedParamsDKIM = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupEncryptedParamsDMARC string - -const ( - RadarEmailRoutingTimeseriesGroupEncryptedParamsDMARCPass RadarEmailRoutingTimeseriesGroupEncryptedParamsDMARC = "PASS" - RadarEmailRoutingTimeseriesGroupEncryptedParamsDMARCNone RadarEmailRoutingTimeseriesGroupEncryptedParamsDMARC = "NONE" - RadarEmailRoutingTimeseriesGroupEncryptedParamsDMARCFail RadarEmailRoutingTimeseriesGroupEncryptedParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailRoutingTimeseriesGroupEncryptedParamsFormat string - -const ( - RadarEmailRoutingTimeseriesGroupEncryptedParamsFormatJson RadarEmailRoutingTimeseriesGroupEncryptedParamsFormat = "JSON" - RadarEmailRoutingTimeseriesGroupEncryptedParamsFormatCsv RadarEmailRoutingTimeseriesGroupEncryptedParamsFormat = "CSV" -) - -type RadarEmailRoutingTimeseriesGroupEncryptedParamsIPVersion string - -const ( - RadarEmailRoutingTimeseriesGroupEncryptedParamsIPVersionIPv4 RadarEmailRoutingTimeseriesGroupEncryptedParamsIPVersion = "IPv4" - RadarEmailRoutingTimeseriesGroupEncryptedParamsIPVersionIPv6 RadarEmailRoutingTimeseriesGroupEncryptedParamsIPVersion = "IPv6" -) - -type RadarEmailRoutingTimeseriesGroupEncryptedParamsSPF string - -const ( - RadarEmailRoutingTimeseriesGroupEncryptedParamsSPFPass RadarEmailRoutingTimeseriesGroupEncryptedParamsSPF = "PASS" - RadarEmailRoutingTimeseriesGroupEncryptedParamsSPFNone RadarEmailRoutingTimeseriesGroupEncryptedParamsSPF = "NONE" - RadarEmailRoutingTimeseriesGroupEncryptedParamsSPFFail RadarEmailRoutingTimeseriesGroupEncryptedParamsSPF = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupEncryptedResponseEnvelope struct { - Result RadarEmailRoutingTimeseriesGroupEncryptedResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailRoutingTimeseriesGroupEncryptedResponseEnvelopeJSON `json:"-"` -} - -// radarEmailRoutingTimeseriesGroupEncryptedResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [RadarEmailRoutingTimeseriesGroupEncryptedResponseEnvelope] -type radarEmailRoutingTimeseriesGroupEncryptedResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingTimeseriesGroupEncryptedResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingTimeseriesGroupEncryptedResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingTimeseriesGroupIPVersionParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarEmailRoutingTimeseriesGroupIPVersionParamsAggInterval] `query:"aggInterval"` - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailRoutingTimeseriesGroupIPVersionParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailRoutingTimeseriesGroupIPVersionParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailRoutingTimeseriesGroupIPVersionParamsDMARC] `query:"dmarc"` - // Filter for encrypted emails. - Encrypted param.Field[[]RadarEmailRoutingTimeseriesGroupIPVersionParamsEncrypted] `query:"encrypted"` - // Format results are returned in. - Format param.Field[RadarEmailRoutingTimeseriesGroupIPVersionParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailRoutingTimeseriesGroupIPVersionParamsSPF] `query:"spf"` -} - -// URLQuery serializes [RadarEmailRoutingTimeseriesGroupIPVersionParams]'s query -// parameters as `url.Values`. -func (r RadarEmailRoutingTimeseriesGroupIPVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarEmailRoutingTimeseriesGroupIPVersionParamsAggInterval string - -const ( - RadarEmailRoutingTimeseriesGroupIPVersionParamsAggInterval15m RadarEmailRoutingTimeseriesGroupIPVersionParamsAggInterval = "15m" - RadarEmailRoutingTimeseriesGroupIPVersionParamsAggInterval1h RadarEmailRoutingTimeseriesGroupIPVersionParamsAggInterval = "1h" - RadarEmailRoutingTimeseriesGroupIPVersionParamsAggInterval1d RadarEmailRoutingTimeseriesGroupIPVersionParamsAggInterval = "1d" - RadarEmailRoutingTimeseriesGroupIPVersionParamsAggInterval1w RadarEmailRoutingTimeseriesGroupIPVersionParamsAggInterval = "1w" -) - -type RadarEmailRoutingTimeseriesGroupIPVersionParamsARC string - -const ( - RadarEmailRoutingTimeseriesGroupIPVersionParamsARCPass RadarEmailRoutingTimeseriesGroupIPVersionParamsARC = "PASS" - RadarEmailRoutingTimeseriesGroupIPVersionParamsARCNone RadarEmailRoutingTimeseriesGroupIPVersionParamsARC = "NONE" - RadarEmailRoutingTimeseriesGroupIPVersionParamsARCFail RadarEmailRoutingTimeseriesGroupIPVersionParamsARC = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange string - -const ( - RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange1d RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange = "1d" - RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange2d RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange = "2d" - RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange7d RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange = "7d" - RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange14d RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange = "14d" - RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange28d RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange = "28d" - RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange12w RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange = "12w" - RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange24w RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange = "24w" - RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange52w RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange = "52w" - RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange1dControl RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange = "1dControl" - RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange2dControl RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange = "2dControl" - RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange7dControl RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange = "7dControl" - RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange14dControl RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange = "14dControl" - RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange28dControl RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange = "28dControl" - RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange12wControl RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange = "12wControl" - RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange24wControl RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange = "24wControl" -) - -type RadarEmailRoutingTimeseriesGroupIPVersionParamsDKIM string - -const ( - RadarEmailRoutingTimeseriesGroupIPVersionParamsDKIMPass RadarEmailRoutingTimeseriesGroupIPVersionParamsDKIM = "PASS" - RadarEmailRoutingTimeseriesGroupIPVersionParamsDKIMNone RadarEmailRoutingTimeseriesGroupIPVersionParamsDKIM = "NONE" - RadarEmailRoutingTimeseriesGroupIPVersionParamsDKIMFail RadarEmailRoutingTimeseriesGroupIPVersionParamsDKIM = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupIPVersionParamsDMARC string - -const ( - RadarEmailRoutingTimeseriesGroupIPVersionParamsDMARCPass RadarEmailRoutingTimeseriesGroupIPVersionParamsDMARC = "PASS" - RadarEmailRoutingTimeseriesGroupIPVersionParamsDMARCNone RadarEmailRoutingTimeseriesGroupIPVersionParamsDMARC = "NONE" - RadarEmailRoutingTimeseriesGroupIPVersionParamsDMARCFail RadarEmailRoutingTimeseriesGroupIPVersionParamsDMARC = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupIPVersionParamsEncrypted string - -const ( - RadarEmailRoutingTimeseriesGroupIPVersionParamsEncryptedEncrypted RadarEmailRoutingTimeseriesGroupIPVersionParamsEncrypted = "ENCRYPTED" - RadarEmailRoutingTimeseriesGroupIPVersionParamsEncryptedNotEncrypted RadarEmailRoutingTimeseriesGroupIPVersionParamsEncrypted = "NOT_ENCRYPTED" -) - -// Format results are returned in. -type RadarEmailRoutingTimeseriesGroupIPVersionParamsFormat string - -const ( - RadarEmailRoutingTimeseriesGroupIPVersionParamsFormatJson RadarEmailRoutingTimeseriesGroupIPVersionParamsFormat = "JSON" - RadarEmailRoutingTimeseriesGroupIPVersionParamsFormatCsv RadarEmailRoutingTimeseriesGroupIPVersionParamsFormat = "CSV" -) - -type RadarEmailRoutingTimeseriesGroupIPVersionParamsSPF string - -const ( - RadarEmailRoutingTimeseriesGroupIPVersionParamsSPFPass RadarEmailRoutingTimeseriesGroupIPVersionParamsSPF = "PASS" - RadarEmailRoutingTimeseriesGroupIPVersionParamsSPFNone RadarEmailRoutingTimeseriesGroupIPVersionParamsSPF = "NONE" - RadarEmailRoutingTimeseriesGroupIPVersionParamsSPFFail RadarEmailRoutingTimeseriesGroupIPVersionParamsSPF = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupIPVersionResponseEnvelope struct { - Result RadarEmailRoutingTimeseriesGroupIPVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailRoutingTimeseriesGroupIPVersionResponseEnvelopeJSON `json:"-"` -} - -// radarEmailRoutingTimeseriesGroupIPVersionResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [RadarEmailRoutingTimeseriesGroupIPVersionResponseEnvelope] -type radarEmailRoutingTimeseriesGroupIPVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingTimeseriesGroupIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingTimeseriesGroupIPVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailRoutingTimeseriesGroupSPFParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarEmailRoutingTimeseriesGroupSPFParamsAggInterval] `query:"aggInterval"` - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailRoutingTimeseriesGroupSPFParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailRoutingTimeseriesGroupSPFParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailRoutingTimeseriesGroupSPFParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailRoutingTimeseriesGroupSPFParamsDMARC] `query:"dmarc"` - // Filter for encrypted emails. - Encrypted param.Field[[]RadarEmailRoutingTimeseriesGroupSPFParamsEncrypted] `query:"encrypted"` - // Format results are returned in. - Format param.Field[RadarEmailRoutingTimeseriesGroupSPFParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarEmailRoutingTimeseriesGroupSPFParamsIPVersion] `query:"ipVersion"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarEmailRoutingTimeseriesGroupSPFParams]'s query -// parameters as `url.Values`. -func (r RadarEmailRoutingTimeseriesGroupSPFParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarEmailRoutingTimeseriesGroupSPFParamsAggInterval string - -const ( - RadarEmailRoutingTimeseriesGroupSPFParamsAggInterval15m RadarEmailRoutingTimeseriesGroupSPFParamsAggInterval = "15m" - RadarEmailRoutingTimeseriesGroupSPFParamsAggInterval1h RadarEmailRoutingTimeseriesGroupSPFParamsAggInterval = "1h" - RadarEmailRoutingTimeseriesGroupSPFParamsAggInterval1d RadarEmailRoutingTimeseriesGroupSPFParamsAggInterval = "1d" - RadarEmailRoutingTimeseriesGroupSPFParamsAggInterval1w RadarEmailRoutingTimeseriesGroupSPFParamsAggInterval = "1w" -) - -type RadarEmailRoutingTimeseriesGroupSPFParamsARC string - -const ( - RadarEmailRoutingTimeseriesGroupSPFParamsARCPass RadarEmailRoutingTimeseriesGroupSPFParamsARC = "PASS" - RadarEmailRoutingTimeseriesGroupSPFParamsARCNone RadarEmailRoutingTimeseriesGroupSPFParamsARC = "NONE" - RadarEmailRoutingTimeseriesGroupSPFParamsARCFail RadarEmailRoutingTimeseriesGroupSPFParamsARC = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupSPFParamsDateRange string - -const ( - RadarEmailRoutingTimeseriesGroupSPFParamsDateRange1d RadarEmailRoutingTimeseriesGroupSPFParamsDateRange = "1d" - RadarEmailRoutingTimeseriesGroupSPFParamsDateRange2d RadarEmailRoutingTimeseriesGroupSPFParamsDateRange = "2d" - RadarEmailRoutingTimeseriesGroupSPFParamsDateRange7d RadarEmailRoutingTimeseriesGroupSPFParamsDateRange = "7d" - RadarEmailRoutingTimeseriesGroupSPFParamsDateRange14d RadarEmailRoutingTimeseriesGroupSPFParamsDateRange = "14d" - RadarEmailRoutingTimeseriesGroupSPFParamsDateRange28d RadarEmailRoutingTimeseriesGroupSPFParamsDateRange = "28d" - RadarEmailRoutingTimeseriesGroupSPFParamsDateRange12w RadarEmailRoutingTimeseriesGroupSPFParamsDateRange = "12w" - RadarEmailRoutingTimeseriesGroupSPFParamsDateRange24w RadarEmailRoutingTimeseriesGroupSPFParamsDateRange = "24w" - RadarEmailRoutingTimeseriesGroupSPFParamsDateRange52w RadarEmailRoutingTimeseriesGroupSPFParamsDateRange = "52w" - RadarEmailRoutingTimeseriesGroupSPFParamsDateRange1dControl RadarEmailRoutingTimeseriesGroupSPFParamsDateRange = "1dControl" - RadarEmailRoutingTimeseriesGroupSPFParamsDateRange2dControl RadarEmailRoutingTimeseriesGroupSPFParamsDateRange = "2dControl" - RadarEmailRoutingTimeseriesGroupSPFParamsDateRange7dControl RadarEmailRoutingTimeseriesGroupSPFParamsDateRange = "7dControl" - RadarEmailRoutingTimeseriesGroupSPFParamsDateRange14dControl RadarEmailRoutingTimeseriesGroupSPFParamsDateRange = "14dControl" - RadarEmailRoutingTimeseriesGroupSPFParamsDateRange28dControl RadarEmailRoutingTimeseriesGroupSPFParamsDateRange = "28dControl" - RadarEmailRoutingTimeseriesGroupSPFParamsDateRange12wControl RadarEmailRoutingTimeseriesGroupSPFParamsDateRange = "12wControl" - RadarEmailRoutingTimeseriesGroupSPFParamsDateRange24wControl RadarEmailRoutingTimeseriesGroupSPFParamsDateRange = "24wControl" -) - -type RadarEmailRoutingTimeseriesGroupSPFParamsDKIM string - -const ( - RadarEmailRoutingTimeseriesGroupSPFParamsDKIMPass RadarEmailRoutingTimeseriesGroupSPFParamsDKIM = "PASS" - RadarEmailRoutingTimeseriesGroupSPFParamsDKIMNone RadarEmailRoutingTimeseriesGroupSPFParamsDKIM = "NONE" - RadarEmailRoutingTimeseriesGroupSPFParamsDKIMFail RadarEmailRoutingTimeseriesGroupSPFParamsDKIM = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupSPFParamsDMARC string - -const ( - RadarEmailRoutingTimeseriesGroupSPFParamsDMARCPass RadarEmailRoutingTimeseriesGroupSPFParamsDMARC = "PASS" - RadarEmailRoutingTimeseriesGroupSPFParamsDMARCNone RadarEmailRoutingTimeseriesGroupSPFParamsDMARC = "NONE" - RadarEmailRoutingTimeseriesGroupSPFParamsDMARCFail RadarEmailRoutingTimeseriesGroupSPFParamsDMARC = "FAIL" -) - -type RadarEmailRoutingTimeseriesGroupSPFParamsEncrypted string - -const ( - RadarEmailRoutingTimeseriesGroupSPFParamsEncryptedEncrypted RadarEmailRoutingTimeseriesGroupSPFParamsEncrypted = "ENCRYPTED" - RadarEmailRoutingTimeseriesGroupSPFParamsEncryptedNotEncrypted RadarEmailRoutingTimeseriesGroupSPFParamsEncrypted = "NOT_ENCRYPTED" -) - -// Format results are returned in. -type RadarEmailRoutingTimeseriesGroupSPFParamsFormat string - -const ( - RadarEmailRoutingTimeseriesGroupSPFParamsFormatJson RadarEmailRoutingTimeseriesGroupSPFParamsFormat = "JSON" - RadarEmailRoutingTimeseriesGroupSPFParamsFormatCsv RadarEmailRoutingTimeseriesGroupSPFParamsFormat = "CSV" -) - -type RadarEmailRoutingTimeseriesGroupSPFParamsIPVersion string - -const ( - RadarEmailRoutingTimeseriesGroupSPFParamsIPVersionIPv4 RadarEmailRoutingTimeseriesGroupSPFParamsIPVersion = "IPv4" - RadarEmailRoutingTimeseriesGroupSPFParamsIPVersionIPv6 RadarEmailRoutingTimeseriesGroupSPFParamsIPVersion = "IPv6" -) - -type RadarEmailRoutingTimeseriesGroupSPFResponseEnvelope struct { - Result RadarEmailRoutingTimeseriesGroupSPFResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailRoutingTimeseriesGroupSPFResponseEnvelopeJSON `json:"-"` -} - -// radarEmailRoutingTimeseriesGroupSPFResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarEmailRoutingTimeseriesGroupSPFResponseEnvelope] -type radarEmailRoutingTimeseriesGroupSPFResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailRoutingTimeseriesGroupSPFResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailRoutingTimeseriesGroupSPFResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radaremailroutingtimeseriesgroup_test.go b/radaremailroutingtimeseriesgroup_test.go deleted file mode 100644 index f8805c47ea1..00000000000 --- a/radaremailroutingtimeseriesgroup_test.go +++ /dev/null @@ -1,231 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarEmailRoutingTimeseriesGroupARCWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Routing.TimeseriesGroups.ARC(context.TODO(), cloudflare.RadarEmailRoutingTimeseriesGroupARCParams{ - AggInterval: cloudflare.F(cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsAggInterval1h), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsDateRange{cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsDateRange1d, cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsDateRange2d, cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsDKIM{cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsDKIMPass, cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsDKIMNone, cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsDMARC{cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsDMARCPass, cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsDMARCNone, cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsDMARCFail}), - Encrypted: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsEncrypted{cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsEncryptedEncrypted, cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsEncryptedNotEncrypted}), - Format: cloudflare.F(cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsIPVersion{cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsIPVersionIPv4, cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsIPVersionIPv6}), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsSPF{cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsSPFPass, cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsSPFNone, cloudflare.RadarEmailRoutingTimeseriesGroupARCParamsSPFFail}), - }) - 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 TestRadarEmailRoutingTimeseriesGroupDKIMWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Routing.TimeseriesGroups.DKIM(context.TODO(), cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParams{ - AggInterval: cloudflare.F(cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsAggInterval1h), - ARC: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsARC{cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsARCPass, cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsARCNone, cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange{cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange1d, cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange2d, cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DMARC: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsDMARC{cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsDMARCPass, cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsDMARCNone, cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsDMARCFail}), - Encrypted: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsEncrypted{cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsEncryptedEncrypted, cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsEncryptedNotEncrypted}), - Format: cloudflare.F(cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsIPVersion{cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsIPVersionIPv4, cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsIPVersionIPv6}), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsSPF{cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsSPFPass, cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsSPFNone, cloudflare.RadarEmailRoutingTimeseriesGroupDKIMParamsSPFFail}), - }) - 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 TestRadarEmailRoutingTimeseriesGroupDMARCWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Routing.TimeseriesGroups.DMARC(context.TODO(), cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParams{ - AggInterval: cloudflare.F(cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsAggInterval1h), - ARC: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsARC{cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsARCPass, cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsARCNone, cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange{cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange1d, cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange2d, cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsDKIM{cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsDKIMPass, cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsDKIMNone, cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsDKIMFail}), - Encrypted: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsEncrypted{cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsEncryptedEncrypted, cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsEncryptedNotEncrypted}), - Format: cloudflare.F(cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsIPVersion{cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsIPVersionIPv4, cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsIPVersionIPv6}), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsSPF{cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsSPFPass, cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsSPFNone, cloudflare.RadarEmailRoutingTimeseriesGroupDMARCParamsSPFFail}), - }) - 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 TestRadarEmailRoutingTimeseriesGroupEncryptedWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Routing.TimeseriesGroups.Encrypted(context.TODO(), cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParams{ - AggInterval: cloudflare.F(cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsAggInterval1h), - ARC: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsARC{cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsARCPass, cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsARCNone, cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange{cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange1d, cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange2d, cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsDKIM{cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsDKIMPass, cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsDKIMNone, cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsDMARC{cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsDMARCPass, cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsDMARCNone, cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsIPVersion{cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsIPVersionIPv4, cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsIPVersionIPv6}), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsSPF{cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsSPFPass, cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsSPFNone, cloudflare.RadarEmailRoutingTimeseriesGroupEncryptedParamsSPFFail}), - }) - 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 TestRadarEmailRoutingTimeseriesGroupIPVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Routing.TimeseriesGroups.IPVersion(context.TODO(), cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParams{ - AggInterval: cloudflare.F(cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsAggInterval1h), - ARC: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsARC{cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsARCPass, cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsARCNone, cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange{cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange1d, cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange2d, cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsDKIM{cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsDKIMPass, cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsDKIMNone, cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsDMARC{cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsDMARCPass, cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsDMARCNone, cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsDMARCFail}), - Encrypted: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsEncrypted{cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsEncryptedEncrypted, cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsEncryptedNotEncrypted}), - Format: cloudflare.F(cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsSPF{cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsSPFPass, cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsSPFNone, cloudflare.RadarEmailRoutingTimeseriesGroupIPVersionParamsSPFFail}), - }) - 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 TestRadarEmailRoutingTimeseriesGroupSPFWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Routing.TimeseriesGroups.SPF(context.TODO(), cloudflare.RadarEmailRoutingTimeseriesGroupSPFParams{ - AggInterval: cloudflare.F(cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsAggInterval1h), - ARC: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsARC{cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsARCPass, cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsARCNone, cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsDateRange{cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsDateRange1d, cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsDateRange2d, cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsDKIM{cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsDKIMPass, cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsDKIMNone, cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsDMARC{cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsDMARCPass, cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsDMARCNone, cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsDMARCFail}), - Encrypted: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsEncrypted{cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsEncryptedEncrypted, cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsEncryptedNotEncrypted}), - Format: cloudflare.F(cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsIPVersion{cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsIPVersionIPv4, cloudflare.RadarEmailRoutingTimeseriesGroupSPFParamsIPVersionIPv6}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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/radaremailsecurity.go b/radaremailsecurity.go deleted file mode 100644 index cb3855a813f..00000000000 --- a/radaremailsecurity.go +++ /dev/null @@ -1,31 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarEmailSecurityService 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 [NewRadarEmailSecurityService] method -// instead. -type RadarEmailSecurityService struct { - Options []option.RequestOption - Top *RadarEmailSecurityTopService - Summary *RadarEmailSecuritySummaryService - TimeseriesGroups *RadarEmailSecurityTimeseriesGroupService -} - -// NewRadarEmailSecurityService 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 NewRadarEmailSecurityService(opts ...option.RequestOption) (r *RadarEmailSecurityService) { - r = &RadarEmailSecurityService{} - r.Options = opts - r.Top = NewRadarEmailSecurityTopService(opts...) - r.Summary = NewRadarEmailSecuritySummaryService(opts...) - r.TimeseriesGroups = NewRadarEmailSecurityTimeseriesGroupService(opts...) - return -} diff --git a/radaremailsecuritysummary.go b/radaremailsecuritysummary.go deleted file mode 100644 index 448923d5547..00000000000 --- a/radaremailsecuritysummary.go +++ /dev/null @@ -1,2657 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarEmailSecuritySummaryService 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 -// [NewRadarEmailSecuritySummaryService] method instead. -type RadarEmailSecuritySummaryService struct { - Options []option.RequestOption -} - -// NewRadarEmailSecuritySummaryService 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 NewRadarEmailSecuritySummaryService(opts ...option.RequestOption) (r *RadarEmailSecuritySummaryService) { - r = &RadarEmailSecuritySummaryService{} - r.Options = opts - return -} - -// Percentage distribution of emails classified per ARC validation. -func (r *RadarEmailSecuritySummaryService) ARC(ctx context.Context, query RadarEmailSecuritySummaryARCParams, opts ...option.RequestOption) (res *RadarEmailSecuritySummaryARCResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecuritySummaryARCResponseEnvelope - path := "radar/email/security/summary/arc" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified per DKIM validation. -func (r *RadarEmailSecuritySummaryService) DKIM(ctx context.Context, query RadarEmailSecuritySummaryDKIMParams, opts ...option.RequestOption) (res *RadarEmailSecuritySummaryDKIMResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecuritySummaryDKIMResponseEnvelope - path := "radar/email/security/summary/dkim" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified per DMARC validation. -func (r *RadarEmailSecuritySummaryService) DMARC(ctx context.Context, query RadarEmailSecuritySummaryDMARCParams, opts ...option.RequestOption) (res *RadarEmailSecuritySummaryDMARCResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecuritySummaryDMARCResponseEnvelope - path := "radar/email/security/summary/dmarc" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified as MALICIOUS. -func (r *RadarEmailSecuritySummaryService) Malicious(ctx context.Context, query RadarEmailSecuritySummaryMaliciousParams, opts ...option.RequestOption) (res *RadarEmailSecuritySummaryMaliciousResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecuritySummaryMaliciousResponseEnvelope - path := "radar/email/security/summary/malicious" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Proportion of emails categorized as either spam or legitimate (non-spam). -func (r *RadarEmailSecuritySummaryService) Spam(ctx context.Context, query RadarEmailSecuritySummarySpamParams, opts ...option.RequestOption) (res *RadarEmailSecuritySummarySpamResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecuritySummarySpamResponseEnvelope - path := "radar/email/security/summary/spam" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified per SPF validation. -func (r *RadarEmailSecuritySummaryService) SPF(ctx context.Context, query RadarEmailSecuritySummarySPFParams, opts ...option.RequestOption) (res *RadarEmailSecuritySummarySPFResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecuritySummarySPFResponseEnvelope - path := "radar/email/security/summary/spf" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Proportion of emails categorized as either spoof or legitimate (non-spoof). -func (r *RadarEmailSecuritySummaryService) Spoof(ctx context.Context, query RadarEmailSecuritySummarySpoofParams, opts ...option.RequestOption) (res *RadarEmailSecuritySummarySpoofResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecuritySummarySpoofResponseEnvelope - path := "radar/email/security/summary/spoof" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified in Threat Categories. -func (r *RadarEmailSecuritySummaryService) ThreatCategory(ctx context.Context, query RadarEmailSecuritySummaryThreatCategoryParams, opts ...option.RequestOption) (res *RadarEmailSecuritySummaryThreatCategoryResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecuritySummaryThreatCategoryResponseEnvelope - path := "radar/email/security/summary/threat_category" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified per TLS Version. -func (r *RadarEmailSecuritySummaryService) TLSVersion(ctx context.Context, query RadarEmailSecuritySummaryTLSVersionParams, opts ...option.RequestOption) (res *RadarEmailSecuritySummaryTLSVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecuritySummaryTLSVersionResponseEnvelope - path := "radar/email/security/summary/tls_version" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarEmailSecuritySummaryARCResponse struct { - Meta RadarEmailSecuritySummaryARCResponseMeta `json:"meta,required"` - Summary0 RadarEmailSecuritySummaryARCResponseSummary0 `json:"summary_0,required"` - JSON radarEmailSecuritySummaryARCResponseJSON `json:"-"` -} - -// radarEmailSecuritySummaryARCResponseJSON contains the JSON metadata for the -// struct [RadarEmailSecuritySummaryARCResponse] -type radarEmailSecuritySummaryARCResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryARCResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryARCResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryARCResponseMeta struct { - DateRange []RadarEmailSecuritySummaryARCResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarEmailSecuritySummaryARCResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailSecuritySummaryARCResponseMetaJSON `json:"-"` -} - -// radarEmailSecuritySummaryARCResponseMetaJSON contains the JSON metadata for the -// struct [RadarEmailSecuritySummaryARCResponseMeta] -type radarEmailSecuritySummaryARCResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryARCResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryARCResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryARCResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailSecuritySummaryARCResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailSecuritySummaryARCResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarEmailSecuritySummaryARCResponseMetaDateRange] -type radarEmailSecuritySummaryARCResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryARCResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryARCResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryARCResponseMetaConfidenceInfo struct { - Annotations []RadarEmailSecuritySummaryARCResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailSecuritySummaryARCResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailSecuritySummaryARCResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarEmailSecuritySummaryARCResponseMetaConfidenceInfo] -type radarEmailSecuritySummaryARCResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryARCResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryARCResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryARCResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailSecuritySummaryARCResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailSecuritySummaryARCResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarEmailSecuritySummaryARCResponseMetaConfidenceInfoAnnotation] -type radarEmailSecuritySummaryARCResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryARCResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryARCResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryARCResponseSummary0 struct { - Fail string `json:"FAIL,required"` - None string `json:"NONE,required"` - Pass string `json:"PASS,required"` - JSON radarEmailSecuritySummaryARCResponseSummary0JSON `json:"-"` -} - -// radarEmailSecuritySummaryARCResponseSummary0JSON contains the JSON metadata for -// the struct [RadarEmailSecuritySummaryARCResponseSummary0] -type radarEmailSecuritySummaryARCResponseSummary0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryARCResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryARCResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryDKIMResponse struct { - Meta RadarEmailSecuritySummaryDKIMResponseMeta `json:"meta,required"` - Summary0 RadarEmailSecuritySummaryDKIMResponseSummary0 `json:"summary_0,required"` - JSON radarEmailSecuritySummaryDKIMResponseJSON `json:"-"` -} - -// radarEmailSecuritySummaryDKIMResponseJSON contains the JSON metadata for the -// struct [RadarEmailSecuritySummaryDKIMResponse] -type radarEmailSecuritySummaryDKIMResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryDKIMResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryDKIMResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryDKIMResponseMeta struct { - DateRange []RadarEmailSecuritySummaryDKIMResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarEmailSecuritySummaryDKIMResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailSecuritySummaryDKIMResponseMetaJSON `json:"-"` -} - -// radarEmailSecuritySummaryDKIMResponseMetaJSON contains the JSON metadata for the -// struct [RadarEmailSecuritySummaryDKIMResponseMeta] -type radarEmailSecuritySummaryDKIMResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryDKIMResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryDKIMResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryDKIMResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailSecuritySummaryDKIMResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailSecuritySummaryDKIMResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarEmailSecuritySummaryDKIMResponseMetaDateRange] -type radarEmailSecuritySummaryDKIMResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryDKIMResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryDKIMResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryDKIMResponseMetaConfidenceInfo struct { - Annotations []RadarEmailSecuritySummaryDKIMResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailSecuritySummaryDKIMResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailSecuritySummaryDKIMResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarEmailSecuritySummaryDKIMResponseMetaConfidenceInfo] -type radarEmailSecuritySummaryDKIMResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryDKIMResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryDKIMResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryDKIMResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailSecuritySummaryDKIMResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailSecuritySummaryDKIMResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarEmailSecuritySummaryDKIMResponseMetaConfidenceInfoAnnotation] -type radarEmailSecuritySummaryDKIMResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryDKIMResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryDKIMResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryDKIMResponseSummary0 struct { - Fail string `json:"FAIL,required"` - None string `json:"NONE,required"` - Pass string `json:"PASS,required"` - JSON radarEmailSecuritySummaryDKIMResponseSummary0JSON `json:"-"` -} - -// radarEmailSecuritySummaryDKIMResponseSummary0JSON contains the JSON metadata for -// the struct [RadarEmailSecuritySummaryDKIMResponseSummary0] -type radarEmailSecuritySummaryDKIMResponseSummary0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryDKIMResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryDKIMResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryDMARCResponse struct { - Meta RadarEmailSecuritySummaryDMARCResponseMeta `json:"meta,required"` - Summary0 RadarEmailSecuritySummaryDMARCResponseSummary0 `json:"summary_0,required"` - JSON radarEmailSecuritySummaryDMARCResponseJSON `json:"-"` -} - -// radarEmailSecuritySummaryDMARCResponseJSON contains the JSON metadata for the -// struct [RadarEmailSecuritySummaryDMARCResponse] -type radarEmailSecuritySummaryDMARCResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryDMARCResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryDMARCResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryDMARCResponseMeta struct { - DateRange []RadarEmailSecuritySummaryDMARCResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarEmailSecuritySummaryDMARCResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailSecuritySummaryDMARCResponseMetaJSON `json:"-"` -} - -// radarEmailSecuritySummaryDMARCResponseMetaJSON contains the JSON metadata for -// the struct [RadarEmailSecuritySummaryDMARCResponseMeta] -type radarEmailSecuritySummaryDMARCResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryDMARCResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryDMARCResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryDMARCResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailSecuritySummaryDMARCResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailSecuritySummaryDMARCResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarEmailSecuritySummaryDMARCResponseMetaDateRange] -type radarEmailSecuritySummaryDMARCResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryDMARCResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryDMARCResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryDMARCResponseMetaConfidenceInfo struct { - Annotations []RadarEmailSecuritySummaryDMARCResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailSecuritySummaryDMARCResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailSecuritySummaryDMARCResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarEmailSecuritySummaryDMARCResponseMetaConfidenceInfo] -type radarEmailSecuritySummaryDMARCResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryDMARCResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryDMARCResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryDMARCResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailSecuritySummaryDMARCResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailSecuritySummaryDMARCResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarEmailSecuritySummaryDMARCResponseMetaConfidenceInfoAnnotation] -type radarEmailSecuritySummaryDMARCResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryDMARCResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryDMARCResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryDMARCResponseSummary0 struct { - Fail string `json:"FAIL,required"` - None string `json:"NONE,required"` - Pass string `json:"PASS,required"` - JSON radarEmailSecuritySummaryDMARCResponseSummary0JSON `json:"-"` -} - -// radarEmailSecuritySummaryDMARCResponseSummary0JSON contains the JSON metadata -// for the struct [RadarEmailSecuritySummaryDMARCResponseSummary0] -type radarEmailSecuritySummaryDMARCResponseSummary0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryDMARCResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryDMARCResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryMaliciousResponse struct { - Meta RadarEmailSecuritySummaryMaliciousResponseMeta `json:"meta,required"` - Summary0 RadarEmailSecuritySummaryMaliciousResponseSummary0 `json:"summary_0,required"` - JSON radarEmailSecuritySummaryMaliciousResponseJSON `json:"-"` -} - -// radarEmailSecuritySummaryMaliciousResponseJSON contains the JSON metadata for -// the struct [RadarEmailSecuritySummaryMaliciousResponse] -type radarEmailSecuritySummaryMaliciousResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryMaliciousResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryMaliciousResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryMaliciousResponseMeta struct { - DateRange []RadarEmailSecuritySummaryMaliciousResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarEmailSecuritySummaryMaliciousResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailSecuritySummaryMaliciousResponseMetaJSON `json:"-"` -} - -// radarEmailSecuritySummaryMaliciousResponseMetaJSON contains the JSON metadata -// for the struct [RadarEmailSecuritySummaryMaliciousResponseMeta] -type radarEmailSecuritySummaryMaliciousResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryMaliciousResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryMaliciousResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryMaliciousResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailSecuritySummaryMaliciousResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailSecuritySummaryMaliciousResponseMetaDateRangeJSON contains the JSON -// metadata for the struct -// [RadarEmailSecuritySummaryMaliciousResponseMetaDateRange] -type radarEmailSecuritySummaryMaliciousResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryMaliciousResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryMaliciousResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryMaliciousResponseMetaConfidenceInfo struct { - Annotations []RadarEmailSecuritySummaryMaliciousResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailSecuritySummaryMaliciousResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailSecuritySummaryMaliciousResponseMetaConfidenceInfoJSON contains the -// JSON metadata for the struct -// [RadarEmailSecuritySummaryMaliciousResponseMetaConfidenceInfo] -type radarEmailSecuritySummaryMaliciousResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryMaliciousResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryMaliciousResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryMaliciousResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailSecuritySummaryMaliciousResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailSecuritySummaryMaliciousResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarEmailSecuritySummaryMaliciousResponseMetaConfidenceInfoAnnotation] -type radarEmailSecuritySummaryMaliciousResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryMaliciousResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryMaliciousResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryMaliciousResponseSummary0 struct { - Malicious string `json:"MALICIOUS,required"` - NotMalicious string `json:"NOT_MALICIOUS,required"` - JSON radarEmailSecuritySummaryMaliciousResponseSummary0JSON `json:"-"` -} - -// radarEmailSecuritySummaryMaliciousResponseSummary0JSON contains the JSON -// metadata for the struct [RadarEmailSecuritySummaryMaliciousResponseSummary0] -type radarEmailSecuritySummaryMaliciousResponseSummary0JSON struct { - Malicious apijson.Field - NotMalicious apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryMaliciousResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryMaliciousResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySpamResponse struct { - Meta RadarEmailSecuritySummarySpamResponseMeta `json:"meta,required"` - Summary0 RadarEmailSecuritySummarySpamResponseSummary0 `json:"summary_0,required"` - JSON radarEmailSecuritySummarySpamResponseJSON `json:"-"` -} - -// radarEmailSecuritySummarySpamResponseJSON contains the JSON metadata for the -// struct [RadarEmailSecuritySummarySpamResponse] -type radarEmailSecuritySummarySpamResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySpamResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySpamResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySpamResponseMeta struct { - DateRange []RadarEmailSecuritySummarySpamResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarEmailSecuritySummarySpamResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailSecuritySummarySpamResponseMetaJSON `json:"-"` -} - -// radarEmailSecuritySummarySpamResponseMetaJSON contains the JSON metadata for the -// struct [RadarEmailSecuritySummarySpamResponseMeta] -type radarEmailSecuritySummarySpamResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySpamResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySpamResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySpamResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailSecuritySummarySpamResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailSecuritySummarySpamResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarEmailSecuritySummarySpamResponseMetaDateRange] -type radarEmailSecuritySummarySpamResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySpamResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySpamResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySpamResponseMetaConfidenceInfo struct { - Annotations []RadarEmailSecuritySummarySpamResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailSecuritySummarySpamResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailSecuritySummarySpamResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarEmailSecuritySummarySpamResponseMetaConfidenceInfo] -type radarEmailSecuritySummarySpamResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySpamResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySpamResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySpamResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailSecuritySummarySpamResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailSecuritySummarySpamResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarEmailSecuritySummarySpamResponseMetaConfidenceInfoAnnotation] -type radarEmailSecuritySummarySpamResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySpamResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySpamResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySpamResponseSummary0 struct { - NotSpam string `json:"NOT_SPAM,required"` - Spam string `json:"SPAM,required"` - JSON radarEmailSecuritySummarySpamResponseSummary0JSON `json:"-"` -} - -// radarEmailSecuritySummarySpamResponseSummary0JSON contains the JSON metadata for -// the struct [RadarEmailSecuritySummarySpamResponseSummary0] -type radarEmailSecuritySummarySpamResponseSummary0JSON struct { - NotSpam apijson.Field - Spam apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySpamResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySpamResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySPFResponse struct { - Meta RadarEmailSecuritySummarySPFResponseMeta `json:"meta,required"` - Summary0 RadarEmailSecuritySummarySPFResponseSummary0 `json:"summary_0,required"` - JSON radarEmailSecuritySummarySPFResponseJSON `json:"-"` -} - -// radarEmailSecuritySummarySPFResponseJSON contains the JSON metadata for the -// struct [RadarEmailSecuritySummarySPFResponse] -type radarEmailSecuritySummarySPFResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySPFResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySPFResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySPFResponseMeta struct { - DateRange []RadarEmailSecuritySummarySPFResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarEmailSecuritySummarySPFResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailSecuritySummarySPFResponseMetaJSON `json:"-"` -} - -// radarEmailSecuritySummarySPFResponseMetaJSON contains the JSON metadata for the -// struct [RadarEmailSecuritySummarySPFResponseMeta] -type radarEmailSecuritySummarySPFResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySPFResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySPFResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySPFResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailSecuritySummarySPFResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailSecuritySummarySPFResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarEmailSecuritySummarySPFResponseMetaDateRange] -type radarEmailSecuritySummarySPFResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySPFResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySPFResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySPFResponseMetaConfidenceInfo struct { - Annotations []RadarEmailSecuritySummarySPFResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailSecuritySummarySPFResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailSecuritySummarySPFResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarEmailSecuritySummarySPFResponseMetaConfidenceInfo] -type radarEmailSecuritySummarySPFResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySPFResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySPFResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySPFResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailSecuritySummarySPFResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailSecuritySummarySPFResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarEmailSecuritySummarySPFResponseMetaConfidenceInfoAnnotation] -type radarEmailSecuritySummarySPFResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySPFResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySPFResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySPFResponseSummary0 struct { - Fail string `json:"FAIL,required"` - None string `json:"NONE,required"` - Pass string `json:"PASS,required"` - JSON radarEmailSecuritySummarySPFResponseSummary0JSON `json:"-"` -} - -// radarEmailSecuritySummarySPFResponseSummary0JSON contains the JSON metadata for -// the struct [RadarEmailSecuritySummarySPFResponseSummary0] -type radarEmailSecuritySummarySPFResponseSummary0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySPFResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySPFResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySpoofResponse struct { - Meta RadarEmailSecuritySummarySpoofResponseMeta `json:"meta,required"` - Summary0 RadarEmailSecuritySummarySpoofResponseSummary0 `json:"summary_0,required"` - JSON radarEmailSecuritySummarySpoofResponseJSON `json:"-"` -} - -// radarEmailSecuritySummarySpoofResponseJSON contains the JSON metadata for the -// struct [RadarEmailSecuritySummarySpoofResponse] -type radarEmailSecuritySummarySpoofResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySpoofResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySpoofResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySpoofResponseMeta struct { - DateRange []RadarEmailSecuritySummarySpoofResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarEmailSecuritySummarySpoofResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailSecuritySummarySpoofResponseMetaJSON `json:"-"` -} - -// radarEmailSecuritySummarySpoofResponseMetaJSON contains the JSON metadata for -// the struct [RadarEmailSecuritySummarySpoofResponseMeta] -type radarEmailSecuritySummarySpoofResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySpoofResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySpoofResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySpoofResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailSecuritySummarySpoofResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailSecuritySummarySpoofResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarEmailSecuritySummarySpoofResponseMetaDateRange] -type radarEmailSecuritySummarySpoofResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySpoofResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySpoofResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySpoofResponseMetaConfidenceInfo struct { - Annotations []RadarEmailSecuritySummarySpoofResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailSecuritySummarySpoofResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailSecuritySummarySpoofResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarEmailSecuritySummarySpoofResponseMetaConfidenceInfo] -type radarEmailSecuritySummarySpoofResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySpoofResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySpoofResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySpoofResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailSecuritySummarySpoofResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailSecuritySummarySpoofResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarEmailSecuritySummarySpoofResponseMetaConfidenceInfoAnnotation] -type radarEmailSecuritySummarySpoofResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySpoofResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySpoofResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySpoofResponseSummary0 struct { - NotSpoof string `json:"NOT_SPOOF,required"` - Spoof string `json:"SPOOF,required"` - JSON radarEmailSecuritySummarySpoofResponseSummary0JSON `json:"-"` -} - -// radarEmailSecuritySummarySpoofResponseSummary0JSON contains the JSON metadata -// for the struct [RadarEmailSecuritySummarySpoofResponseSummary0] -type radarEmailSecuritySummarySpoofResponseSummary0JSON struct { - NotSpoof apijson.Field - Spoof apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySpoofResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySpoofResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryThreatCategoryResponse struct { - Meta RadarEmailSecuritySummaryThreatCategoryResponseMeta `json:"meta,required"` - Summary0 RadarEmailSecuritySummaryThreatCategoryResponseSummary0 `json:"summary_0,required"` - JSON radarEmailSecuritySummaryThreatCategoryResponseJSON `json:"-"` -} - -// radarEmailSecuritySummaryThreatCategoryResponseJSON contains the JSON metadata -// for the struct [RadarEmailSecuritySummaryThreatCategoryResponse] -type radarEmailSecuritySummaryThreatCategoryResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryThreatCategoryResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryThreatCategoryResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryThreatCategoryResponseMeta struct { - DateRange []RadarEmailSecuritySummaryThreatCategoryResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarEmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailSecuritySummaryThreatCategoryResponseMetaJSON `json:"-"` -} - -// radarEmailSecuritySummaryThreatCategoryResponseMetaJSON contains the JSON -// metadata for the struct [RadarEmailSecuritySummaryThreatCategoryResponseMeta] -type radarEmailSecuritySummaryThreatCategoryResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryThreatCategoryResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryThreatCategoryResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryThreatCategoryResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailSecuritySummaryThreatCategoryResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailSecuritySummaryThreatCategoryResponseMetaDateRangeJSON contains the -// JSON metadata for the struct -// [RadarEmailSecuritySummaryThreatCategoryResponseMetaDateRange] -type radarEmailSecuritySummaryThreatCategoryResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryThreatCategoryResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryThreatCategoryResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfo struct { - Annotations []RadarEmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoJSON contains -// the JSON metadata for the struct -// [RadarEmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfo] -type radarEmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarEmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoAnnotation] -type radarEmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryThreatCategoryResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryThreatCategoryResponseSummary0 struct { - BrandImpersonation string `json:"BrandImpersonation,required"` - CredentialHarvester string `json:"CredentialHarvester,required"` - IdentityDeception string `json:"IdentityDeception,required"` - Link string `json:"Link,required"` - JSON radarEmailSecuritySummaryThreatCategoryResponseSummary0JSON `json:"-"` -} - -// radarEmailSecuritySummaryThreatCategoryResponseSummary0JSON contains the JSON -// metadata for the struct -// [RadarEmailSecuritySummaryThreatCategoryResponseSummary0] -type radarEmailSecuritySummaryThreatCategoryResponseSummary0JSON struct { - BrandImpersonation apijson.Field - CredentialHarvester apijson.Field - IdentityDeception apijson.Field - Link apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryThreatCategoryResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryThreatCategoryResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryTLSVersionResponse struct { - Meta RadarEmailSecuritySummaryTLSVersionResponseMeta `json:"meta,required"` - Summary0 RadarEmailSecuritySummaryTLSVersionResponseSummary0 `json:"summary_0,required"` - JSON radarEmailSecuritySummaryTLSVersionResponseJSON `json:"-"` -} - -// radarEmailSecuritySummaryTLSVersionResponseJSON contains the JSON metadata for -// the struct [RadarEmailSecuritySummaryTLSVersionResponse] -type radarEmailSecuritySummaryTLSVersionResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryTLSVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryTLSVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryTLSVersionResponseMeta struct { - DateRange []RadarEmailSecuritySummaryTLSVersionResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarEmailSecuritySummaryTLSVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailSecuritySummaryTLSVersionResponseMetaJSON `json:"-"` -} - -// radarEmailSecuritySummaryTLSVersionResponseMetaJSON contains the JSON metadata -// for the struct [RadarEmailSecuritySummaryTLSVersionResponseMeta] -type radarEmailSecuritySummaryTLSVersionResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryTLSVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryTLSVersionResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryTLSVersionResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailSecuritySummaryTLSVersionResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailSecuritySummaryTLSVersionResponseMetaDateRangeJSON contains the JSON -// metadata for the struct -// [RadarEmailSecuritySummaryTLSVersionResponseMetaDateRange] -type radarEmailSecuritySummaryTLSVersionResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryTLSVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryTLSVersionResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryTLSVersionResponseMetaConfidenceInfo struct { - Annotations []RadarEmailSecuritySummaryTLSVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailSecuritySummaryTLSVersionResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailSecuritySummaryTLSVersionResponseMetaConfidenceInfoJSON contains the -// JSON metadata for the struct -// [RadarEmailSecuritySummaryTLSVersionResponseMetaConfidenceInfo] -type radarEmailSecuritySummaryTLSVersionResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryTLSVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryTLSVersionResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryTLSVersionResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailSecuritySummaryTLSVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailSecuritySummaryTLSVersionResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarEmailSecuritySummaryTLSVersionResponseMetaConfidenceInfoAnnotation] -type radarEmailSecuritySummaryTLSVersionResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryTLSVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryTLSVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryTLSVersionResponseSummary0 struct { - TLS1_0 string `json:"TLS 1.0,required"` - TLS1_1 string `json:"TLS 1.1,required"` - TLS1_2 string `json:"TLS 1.2,required"` - TLS1_3 string `json:"TLS 1.3,required"` - JSON radarEmailSecuritySummaryTLSVersionResponseSummary0JSON `json:"-"` -} - -// radarEmailSecuritySummaryTLSVersionResponseSummary0JSON contains the JSON -// metadata for the struct [RadarEmailSecuritySummaryTLSVersionResponseSummary0] -type radarEmailSecuritySummaryTLSVersionResponseSummary0JSON struct { - TLS1_0 apijson.Field - TLS1_1 apijson.Field - TLS1_2 apijson.Field - TLS1_3 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryTLSVersionResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryTLSVersionResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryARCParams struct { - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecuritySummaryARCParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecuritySummaryARCParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecuritySummaryARCParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecuritySummaryARCParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecuritySummaryARCParamsSPF] `query:"spf"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecuritySummaryARCParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecuritySummaryARCParams]'s query parameters as -// `url.Values`. -func (r RadarEmailSecuritySummaryARCParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarEmailSecuritySummaryARCParamsDateRange string - -const ( - RadarEmailSecuritySummaryARCParamsDateRange1d RadarEmailSecuritySummaryARCParamsDateRange = "1d" - RadarEmailSecuritySummaryARCParamsDateRange2d RadarEmailSecuritySummaryARCParamsDateRange = "2d" - RadarEmailSecuritySummaryARCParamsDateRange7d RadarEmailSecuritySummaryARCParamsDateRange = "7d" - RadarEmailSecuritySummaryARCParamsDateRange14d RadarEmailSecuritySummaryARCParamsDateRange = "14d" - RadarEmailSecuritySummaryARCParamsDateRange28d RadarEmailSecuritySummaryARCParamsDateRange = "28d" - RadarEmailSecuritySummaryARCParamsDateRange12w RadarEmailSecuritySummaryARCParamsDateRange = "12w" - RadarEmailSecuritySummaryARCParamsDateRange24w RadarEmailSecuritySummaryARCParamsDateRange = "24w" - RadarEmailSecuritySummaryARCParamsDateRange52w RadarEmailSecuritySummaryARCParamsDateRange = "52w" - RadarEmailSecuritySummaryARCParamsDateRange1dControl RadarEmailSecuritySummaryARCParamsDateRange = "1dControl" - RadarEmailSecuritySummaryARCParamsDateRange2dControl RadarEmailSecuritySummaryARCParamsDateRange = "2dControl" - RadarEmailSecuritySummaryARCParamsDateRange7dControl RadarEmailSecuritySummaryARCParamsDateRange = "7dControl" - RadarEmailSecuritySummaryARCParamsDateRange14dControl RadarEmailSecuritySummaryARCParamsDateRange = "14dControl" - RadarEmailSecuritySummaryARCParamsDateRange28dControl RadarEmailSecuritySummaryARCParamsDateRange = "28dControl" - RadarEmailSecuritySummaryARCParamsDateRange12wControl RadarEmailSecuritySummaryARCParamsDateRange = "12wControl" - RadarEmailSecuritySummaryARCParamsDateRange24wControl RadarEmailSecuritySummaryARCParamsDateRange = "24wControl" -) - -type RadarEmailSecuritySummaryARCParamsDKIM string - -const ( - RadarEmailSecuritySummaryARCParamsDKIMPass RadarEmailSecuritySummaryARCParamsDKIM = "PASS" - RadarEmailSecuritySummaryARCParamsDKIMNone RadarEmailSecuritySummaryARCParamsDKIM = "NONE" - RadarEmailSecuritySummaryARCParamsDKIMFail RadarEmailSecuritySummaryARCParamsDKIM = "FAIL" -) - -type RadarEmailSecuritySummaryARCParamsDMARC string - -const ( - RadarEmailSecuritySummaryARCParamsDMARCPass RadarEmailSecuritySummaryARCParamsDMARC = "PASS" - RadarEmailSecuritySummaryARCParamsDMARCNone RadarEmailSecuritySummaryARCParamsDMARC = "NONE" - RadarEmailSecuritySummaryARCParamsDMARCFail RadarEmailSecuritySummaryARCParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecuritySummaryARCParamsFormat string - -const ( - RadarEmailSecuritySummaryARCParamsFormatJson RadarEmailSecuritySummaryARCParamsFormat = "JSON" - RadarEmailSecuritySummaryARCParamsFormatCsv RadarEmailSecuritySummaryARCParamsFormat = "CSV" -) - -type RadarEmailSecuritySummaryARCParamsSPF string - -const ( - RadarEmailSecuritySummaryARCParamsSPFPass RadarEmailSecuritySummaryARCParamsSPF = "PASS" - RadarEmailSecuritySummaryARCParamsSPFNone RadarEmailSecuritySummaryARCParamsSPF = "NONE" - RadarEmailSecuritySummaryARCParamsSPFFail RadarEmailSecuritySummaryARCParamsSPF = "FAIL" -) - -type RadarEmailSecuritySummaryARCParamsTLSVersion string - -const ( - RadarEmailSecuritySummaryARCParamsTLSVersionTlSv1_0 RadarEmailSecuritySummaryARCParamsTLSVersion = "TLSv1_0" - RadarEmailSecuritySummaryARCParamsTLSVersionTlSv1_1 RadarEmailSecuritySummaryARCParamsTLSVersion = "TLSv1_1" - RadarEmailSecuritySummaryARCParamsTLSVersionTlSv1_2 RadarEmailSecuritySummaryARCParamsTLSVersion = "TLSv1_2" - RadarEmailSecuritySummaryARCParamsTLSVersionTlSv1_3 RadarEmailSecuritySummaryARCParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecuritySummaryARCResponseEnvelope struct { - Result RadarEmailSecuritySummaryARCResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecuritySummaryARCResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecuritySummaryARCResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarEmailSecuritySummaryARCResponseEnvelope] -type radarEmailSecuritySummaryARCResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryARCResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryARCResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryDKIMParams struct { - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecuritySummaryDKIMParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecuritySummaryDKIMParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecuritySummaryDKIMParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecuritySummaryDKIMParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecuritySummaryDKIMParamsSPF] `query:"spf"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecuritySummaryDKIMParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecuritySummaryDKIMParams]'s query parameters as -// `url.Values`. -func (r RadarEmailSecuritySummaryDKIMParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarEmailSecuritySummaryDKIMParamsARC string - -const ( - RadarEmailSecuritySummaryDKIMParamsARCPass RadarEmailSecuritySummaryDKIMParamsARC = "PASS" - RadarEmailSecuritySummaryDKIMParamsARCNone RadarEmailSecuritySummaryDKIMParamsARC = "NONE" - RadarEmailSecuritySummaryDKIMParamsARCFail RadarEmailSecuritySummaryDKIMParamsARC = "FAIL" -) - -type RadarEmailSecuritySummaryDKIMParamsDateRange string - -const ( - RadarEmailSecuritySummaryDKIMParamsDateRange1d RadarEmailSecuritySummaryDKIMParamsDateRange = "1d" - RadarEmailSecuritySummaryDKIMParamsDateRange2d RadarEmailSecuritySummaryDKIMParamsDateRange = "2d" - RadarEmailSecuritySummaryDKIMParamsDateRange7d RadarEmailSecuritySummaryDKIMParamsDateRange = "7d" - RadarEmailSecuritySummaryDKIMParamsDateRange14d RadarEmailSecuritySummaryDKIMParamsDateRange = "14d" - RadarEmailSecuritySummaryDKIMParamsDateRange28d RadarEmailSecuritySummaryDKIMParamsDateRange = "28d" - RadarEmailSecuritySummaryDKIMParamsDateRange12w RadarEmailSecuritySummaryDKIMParamsDateRange = "12w" - RadarEmailSecuritySummaryDKIMParamsDateRange24w RadarEmailSecuritySummaryDKIMParamsDateRange = "24w" - RadarEmailSecuritySummaryDKIMParamsDateRange52w RadarEmailSecuritySummaryDKIMParamsDateRange = "52w" - RadarEmailSecuritySummaryDKIMParamsDateRange1dControl RadarEmailSecuritySummaryDKIMParamsDateRange = "1dControl" - RadarEmailSecuritySummaryDKIMParamsDateRange2dControl RadarEmailSecuritySummaryDKIMParamsDateRange = "2dControl" - RadarEmailSecuritySummaryDKIMParamsDateRange7dControl RadarEmailSecuritySummaryDKIMParamsDateRange = "7dControl" - RadarEmailSecuritySummaryDKIMParamsDateRange14dControl RadarEmailSecuritySummaryDKIMParamsDateRange = "14dControl" - RadarEmailSecuritySummaryDKIMParamsDateRange28dControl RadarEmailSecuritySummaryDKIMParamsDateRange = "28dControl" - RadarEmailSecuritySummaryDKIMParamsDateRange12wControl RadarEmailSecuritySummaryDKIMParamsDateRange = "12wControl" - RadarEmailSecuritySummaryDKIMParamsDateRange24wControl RadarEmailSecuritySummaryDKIMParamsDateRange = "24wControl" -) - -type RadarEmailSecuritySummaryDKIMParamsDMARC string - -const ( - RadarEmailSecuritySummaryDKIMParamsDMARCPass RadarEmailSecuritySummaryDKIMParamsDMARC = "PASS" - RadarEmailSecuritySummaryDKIMParamsDMARCNone RadarEmailSecuritySummaryDKIMParamsDMARC = "NONE" - RadarEmailSecuritySummaryDKIMParamsDMARCFail RadarEmailSecuritySummaryDKIMParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecuritySummaryDKIMParamsFormat string - -const ( - RadarEmailSecuritySummaryDKIMParamsFormatJson RadarEmailSecuritySummaryDKIMParamsFormat = "JSON" - RadarEmailSecuritySummaryDKIMParamsFormatCsv RadarEmailSecuritySummaryDKIMParamsFormat = "CSV" -) - -type RadarEmailSecuritySummaryDKIMParamsSPF string - -const ( - RadarEmailSecuritySummaryDKIMParamsSPFPass RadarEmailSecuritySummaryDKIMParamsSPF = "PASS" - RadarEmailSecuritySummaryDKIMParamsSPFNone RadarEmailSecuritySummaryDKIMParamsSPF = "NONE" - RadarEmailSecuritySummaryDKIMParamsSPFFail RadarEmailSecuritySummaryDKIMParamsSPF = "FAIL" -) - -type RadarEmailSecuritySummaryDKIMParamsTLSVersion string - -const ( - RadarEmailSecuritySummaryDKIMParamsTLSVersionTlSv1_0 RadarEmailSecuritySummaryDKIMParamsTLSVersion = "TLSv1_0" - RadarEmailSecuritySummaryDKIMParamsTLSVersionTlSv1_1 RadarEmailSecuritySummaryDKIMParamsTLSVersion = "TLSv1_1" - RadarEmailSecuritySummaryDKIMParamsTLSVersionTlSv1_2 RadarEmailSecuritySummaryDKIMParamsTLSVersion = "TLSv1_2" - RadarEmailSecuritySummaryDKIMParamsTLSVersionTlSv1_3 RadarEmailSecuritySummaryDKIMParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecuritySummaryDKIMResponseEnvelope struct { - Result RadarEmailSecuritySummaryDKIMResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecuritySummaryDKIMResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecuritySummaryDKIMResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarEmailSecuritySummaryDKIMResponseEnvelope] -type radarEmailSecuritySummaryDKIMResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryDKIMResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryDKIMResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryDMARCParams struct { - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecuritySummaryDMARCParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecuritySummaryDMARCParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecuritySummaryDMARCParamsDKIM] `query:"dkim"` - // Format results are returned in. - Format param.Field[RadarEmailSecuritySummaryDMARCParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecuritySummaryDMARCParamsSPF] `query:"spf"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecuritySummaryDMARCParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecuritySummaryDMARCParams]'s query parameters as -// `url.Values`. -func (r RadarEmailSecuritySummaryDMARCParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarEmailSecuritySummaryDMARCParamsARC string - -const ( - RadarEmailSecuritySummaryDMARCParamsARCPass RadarEmailSecuritySummaryDMARCParamsARC = "PASS" - RadarEmailSecuritySummaryDMARCParamsARCNone RadarEmailSecuritySummaryDMARCParamsARC = "NONE" - RadarEmailSecuritySummaryDMARCParamsARCFail RadarEmailSecuritySummaryDMARCParamsARC = "FAIL" -) - -type RadarEmailSecuritySummaryDMARCParamsDateRange string - -const ( - RadarEmailSecuritySummaryDMARCParamsDateRange1d RadarEmailSecuritySummaryDMARCParamsDateRange = "1d" - RadarEmailSecuritySummaryDMARCParamsDateRange2d RadarEmailSecuritySummaryDMARCParamsDateRange = "2d" - RadarEmailSecuritySummaryDMARCParamsDateRange7d RadarEmailSecuritySummaryDMARCParamsDateRange = "7d" - RadarEmailSecuritySummaryDMARCParamsDateRange14d RadarEmailSecuritySummaryDMARCParamsDateRange = "14d" - RadarEmailSecuritySummaryDMARCParamsDateRange28d RadarEmailSecuritySummaryDMARCParamsDateRange = "28d" - RadarEmailSecuritySummaryDMARCParamsDateRange12w RadarEmailSecuritySummaryDMARCParamsDateRange = "12w" - RadarEmailSecuritySummaryDMARCParamsDateRange24w RadarEmailSecuritySummaryDMARCParamsDateRange = "24w" - RadarEmailSecuritySummaryDMARCParamsDateRange52w RadarEmailSecuritySummaryDMARCParamsDateRange = "52w" - RadarEmailSecuritySummaryDMARCParamsDateRange1dControl RadarEmailSecuritySummaryDMARCParamsDateRange = "1dControl" - RadarEmailSecuritySummaryDMARCParamsDateRange2dControl RadarEmailSecuritySummaryDMARCParamsDateRange = "2dControl" - RadarEmailSecuritySummaryDMARCParamsDateRange7dControl RadarEmailSecuritySummaryDMARCParamsDateRange = "7dControl" - RadarEmailSecuritySummaryDMARCParamsDateRange14dControl RadarEmailSecuritySummaryDMARCParamsDateRange = "14dControl" - RadarEmailSecuritySummaryDMARCParamsDateRange28dControl RadarEmailSecuritySummaryDMARCParamsDateRange = "28dControl" - RadarEmailSecuritySummaryDMARCParamsDateRange12wControl RadarEmailSecuritySummaryDMARCParamsDateRange = "12wControl" - RadarEmailSecuritySummaryDMARCParamsDateRange24wControl RadarEmailSecuritySummaryDMARCParamsDateRange = "24wControl" -) - -type RadarEmailSecuritySummaryDMARCParamsDKIM string - -const ( - RadarEmailSecuritySummaryDMARCParamsDKIMPass RadarEmailSecuritySummaryDMARCParamsDKIM = "PASS" - RadarEmailSecuritySummaryDMARCParamsDKIMNone RadarEmailSecuritySummaryDMARCParamsDKIM = "NONE" - RadarEmailSecuritySummaryDMARCParamsDKIMFail RadarEmailSecuritySummaryDMARCParamsDKIM = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecuritySummaryDMARCParamsFormat string - -const ( - RadarEmailSecuritySummaryDMARCParamsFormatJson RadarEmailSecuritySummaryDMARCParamsFormat = "JSON" - RadarEmailSecuritySummaryDMARCParamsFormatCsv RadarEmailSecuritySummaryDMARCParamsFormat = "CSV" -) - -type RadarEmailSecuritySummaryDMARCParamsSPF string - -const ( - RadarEmailSecuritySummaryDMARCParamsSPFPass RadarEmailSecuritySummaryDMARCParamsSPF = "PASS" - RadarEmailSecuritySummaryDMARCParamsSPFNone RadarEmailSecuritySummaryDMARCParamsSPF = "NONE" - RadarEmailSecuritySummaryDMARCParamsSPFFail RadarEmailSecuritySummaryDMARCParamsSPF = "FAIL" -) - -type RadarEmailSecuritySummaryDMARCParamsTLSVersion string - -const ( - RadarEmailSecuritySummaryDMARCParamsTLSVersionTlSv1_0 RadarEmailSecuritySummaryDMARCParamsTLSVersion = "TLSv1_0" - RadarEmailSecuritySummaryDMARCParamsTLSVersionTlSv1_1 RadarEmailSecuritySummaryDMARCParamsTLSVersion = "TLSv1_1" - RadarEmailSecuritySummaryDMARCParamsTLSVersionTlSv1_2 RadarEmailSecuritySummaryDMARCParamsTLSVersion = "TLSv1_2" - RadarEmailSecuritySummaryDMARCParamsTLSVersionTlSv1_3 RadarEmailSecuritySummaryDMARCParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecuritySummaryDMARCResponseEnvelope struct { - Result RadarEmailSecuritySummaryDMARCResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecuritySummaryDMARCResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecuritySummaryDMARCResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarEmailSecuritySummaryDMARCResponseEnvelope] -type radarEmailSecuritySummaryDMARCResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryDMARCResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryDMARCResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryMaliciousParams struct { - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecuritySummaryMaliciousParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecuritySummaryMaliciousParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecuritySummaryMaliciousParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecuritySummaryMaliciousParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecuritySummaryMaliciousParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecuritySummaryMaliciousParamsSPF] `query:"spf"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecuritySummaryMaliciousParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecuritySummaryMaliciousParams]'s query -// parameters as `url.Values`. -func (r RadarEmailSecuritySummaryMaliciousParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarEmailSecuritySummaryMaliciousParamsARC string - -const ( - RadarEmailSecuritySummaryMaliciousParamsARCPass RadarEmailSecuritySummaryMaliciousParamsARC = "PASS" - RadarEmailSecuritySummaryMaliciousParamsARCNone RadarEmailSecuritySummaryMaliciousParamsARC = "NONE" - RadarEmailSecuritySummaryMaliciousParamsARCFail RadarEmailSecuritySummaryMaliciousParamsARC = "FAIL" -) - -type RadarEmailSecuritySummaryMaliciousParamsDateRange string - -const ( - RadarEmailSecuritySummaryMaliciousParamsDateRange1d RadarEmailSecuritySummaryMaliciousParamsDateRange = "1d" - RadarEmailSecuritySummaryMaliciousParamsDateRange2d RadarEmailSecuritySummaryMaliciousParamsDateRange = "2d" - RadarEmailSecuritySummaryMaliciousParamsDateRange7d RadarEmailSecuritySummaryMaliciousParamsDateRange = "7d" - RadarEmailSecuritySummaryMaliciousParamsDateRange14d RadarEmailSecuritySummaryMaliciousParamsDateRange = "14d" - RadarEmailSecuritySummaryMaliciousParamsDateRange28d RadarEmailSecuritySummaryMaliciousParamsDateRange = "28d" - RadarEmailSecuritySummaryMaliciousParamsDateRange12w RadarEmailSecuritySummaryMaliciousParamsDateRange = "12w" - RadarEmailSecuritySummaryMaliciousParamsDateRange24w RadarEmailSecuritySummaryMaliciousParamsDateRange = "24w" - RadarEmailSecuritySummaryMaliciousParamsDateRange52w RadarEmailSecuritySummaryMaliciousParamsDateRange = "52w" - RadarEmailSecuritySummaryMaliciousParamsDateRange1dControl RadarEmailSecuritySummaryMaliciousParamsDateRange = "1dControl" - RadarEmailSecuritySummaryMaliciousParamsDateRange2dControl RadarEmailSecuritySummaryMaliciousParamsDateRange = "2dControl" - RadarEmailSecuritySummaryMaliciousParamsDateRange7dControl RadarEmailSecuritySummaryMaliciousParamsDateRange = "7dControl" - RadarEmailSecuritySummaryMaliciousParamsDateRange14dControl RadarEmailSecuritySummaryMaliciousParamsDateRange = "14dControl" - RadarEmailSecuritySummaryMaliciousParamsDateRange28dControl RadarEmailSecuritySummaryMaliciousParamsDateRange = "28dControl" - RadarEmailSecuritySummaryMaliciousParamsDateRange12wControl RadarEmailSecuritySummaryMaliciousParamsDateRange = "12wControl" - RadarEmailSecuritySummaryMaliciousParamsDateRange24wControl RadarEmailSecuritySummaryMaliciousParamsDateRange = "24wControl" -) - -type RadarEmailSecuritySummaryMaliciousParamsDKIM string - -const ( - RadarEmailSecuritySummaryMaliciousParamsDKIMPass RadarEmailSecuritySummaryMaliciousParamsDKIM = "PASS" - RadarEmailSecuritySummaryMaliciousParamsDKIMNone RadarEmailSecuritySummaryMaliciousParamsDKIM = "NONE" - RadarEmailSecuritySummaryMaliciousParamsDKIMFail RadarEmailSecuritySummaryMaliciousParamsDKIM = "FAIL" -) - -type RadarEmailSecuritySummaryMaliciousParamsDMARC string - -const ( - RadarEmailSecuritySummaryMaliciousParamsDMARCPass RadarEmailSecuritySummaryMaliciousParamsDMARC = "PASS" - RadarEmailSecuritySummaryMaliciousParamsDMARCNone RadarEmailSecuritySummaryMaliciousParamsDMARC = "NONE" - RadarEmailSecuritySummaryMaliciousParamsDMARCFail RadarEmailSecuritySummaryMaliciousParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecuritySummaryMaliciousParamsFormat string - -const ( - RadarEmailSecuritySummaryMaliciousParamsFormatJson RadarEmailSecuritySummaryMaliciousParamsFormat = "JSON" - RadarEmailSecuritySummaryMaliciousParamsFormatCsv RadarEmailSecuritySummaryMaliciousParamsFormat = "CSV" -) - -type RadarEmailSecuritySummaryMaliciousParamsSPF string - -const ( - RadarEmailSecuritySummaryMaliciousParamsSPFPass RadarEmailSecuritySummaryMaliciousParamsSPF = "PASS" - RadarEmailSecuritySummaryMaliciousParamsSPFNone RadarEmailSecuritySummaryMaliciousParamsSPF = "NONE" - RadarEmailSecuritySummaryMaliciousParamsSPFFail RadarEmailSecuritySummaryMaliciousParamsSPF = "FAIL" -) - -type RadarEmailSecuritySummaryMaliciousParamsTLSVersion string - -const ( - RadarEmailSecuritySummaryMaliciousParamsTLSVersionTlSv1_0 RadarEmailSecuritySummaryMaliciousParamsTLSVersion = "TLSv1_0" - RadarEmailSecuritySummaryMaliciousParamsTLSVersionTlSv1_1 RadarEmailSecuritySummaryMaliciousParamsTLSVersion = "TLSv1_1" - RadarEmailSecuritySummaryMaliciousParamsTLSVersionTlSv1_2 RadarEmailSecuritySummaryMaliciousParamsTLSVersion = "TLSv1_2" - RadarEmailSecuritySummaryMaliciousParamsTLSVersionTlSv1_3 RadarEmailSecuritySummaryMaliciousParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecuritySummaryMaliciousResponseEnvelope struct { - Result RadarEmailSecuritySummaryMaliciousResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecuritySummaryMaliciousResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecuritySummaryMaliciousResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarEmailSecuritySummaryMaliciousResponseEnvelope] -type radarEmailSecuritySummaryMaliciousResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryMaliciousResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryMaliciousResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySpamParams struct { - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecuritySummarySpamParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecuritySummarySpamParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecuritySummarySpamParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecuritySummarySpamParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecuritySummarySpamParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecuritySummarySpamParamsSPF] `query:"spf"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecuritySummarySpamParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecuritySummarySpamParams]'s query parameters as -// `url.Values`. -func (r RadarEmailSecuritySummarySpamParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarEmailSecuritySummarySpamParamsARC string - -const ( - RadarEmailSecuritySummarySpamParamsARCPass RadarEmailSecuritySummarySpamParamsARC = "PASS" - RadarEmailSecuritySummarySpamParamsARCNone RadarEmailSecuritySummarySpamParamsARC = "NONE" - RadarEmailSecuritySummarySpamParamsARCFail RadarEmailSecuritySummarySpamParamsARC = "FAIL" -) - -type RadarEmailSecuritySummarySpamParamsDateRange string - -const ( - RadarEmailSecuritySummarySpamParamsDateRange1d RadarEmailSecuritySummarySpamParamsDateRange = "1d" - RadarEmailSecuritySummarySpamParamsDateRange2d RadarEmailSecuritySummarySpamParamsDateRange = "2d" - RadarEmailSecuritySummarySpamParamsDateRange7d RadarEmailSecuritySummarySpamParamsDateRange = "7d" - RadarEmailSecuritySummarySpamParamsDateRange14d RadarEmailSecuritySummarySpamParamsDateRange = "14d" - RadarEmailSecuritySummarySpamParamsDateRange28d RadarEmailSecuritySummarySpamParamsDateRange = "28d" - RadarEmailSecuritySummarySpamParamsDateRange12w RadarEmailSecuritySummarySpamParamsDateRange = "12w" - RadarEmailSecuritySummarySpamParamsDateRange24w RadarEmailSecuritySummarySpamParamsDateRange = "24w" - RadarEmailSecuritySummarySpamParamsDateRange52w RadarEmailSecuritySummarySpamParamsDateRange = "52w" - RadarEmailSecuritySummarySpamParamsDateRange1dControl RadarEmailSecuritySummarySpamParamsDateRange = "1dControl" - RadarEmailSecuritySummarySpamParamsDateRange2dControl RadarEmailSecuritySummarySpamParamsDateRange = "2dControl" - RadarEmailSecuritySummarySpamParamsDateRange7dControl RadarEmailSecuritySummarySpamParamsDateRange = "7dControl" - RadarEmailSecuritySummarySpamParamsDateRange14dControl RadarEmailSecuritySummarySpamParamsDateRange = "14dControl" - RadarEmailSecuritySummarySpamParamsDateRange28dControl RadarEmailSecuritySummarySpamParamsDateRange = "28dControl" - RadarEmailSecuritySummarySpamParamsDateRange12wControl RadarEmailSecuritySummarySpamParamsDateRange = "12wControl" - RadarEmailSecuritySummarySpamParamsDateRange24wControl RadarEmailSecuritySummarySpamParamsDateRange = "24wControl" -) - -type RadarEmailSecuritySummarySpamParamsDKIM string - -const ( - RadarEmailSecuritySummarySpamParamsDKIMPass RadarEmailSecuritySummarySpamParamsDKIM = "PASS" - RadarEmailSecuritySummarySpamParamsDKIMNone RadarEmailSecuritySummarySpamParamsDKIM = "NONE" - RadarEmailSecuritySummarySpamParamsDKIMFail RadarEmailSecuritySummarySpamParamsDKIM = "FAIL" -) - -type RadarEmailSecuritySummarySpamParamsDMARC string - -const ( - RadarEmailSecuritySummarySpamParamsDMARCPass RadarEmailSecuritySummarySpamParamsDMARC = "PASS" - RadarEmailSecuritySummarySpamParamsDMARCNone RadarEmailSecuritySummarySpamParamsDMARC = "NONE" - RadarEmailSecuritySummarySpamParamsDMARCFail RadarEmailSecuritySummarySpamParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecuritySummarySpamParamsFormat string - -const ( - RadarEmailSecuritySummarySpamParamsFormatJson RadarEmailSecuritySummarySpamParamsFormat = "JSON" - RadarEmailSecuritySummarySpamParamsFormatCsv RadarEmailSecuritySummarySpamParamsFormat = "CSV" -) - -type RadarEmailSecuritySummarySpamParamsSPF string - -const ( - RadarEmailSecuritySummarySpamParamsSPFPass RadarEmailSecuritySummarySpamParamsSPF = "PASS" - RadarEmailSecuritySummarySpamParamsSPFNone RadarEmailSecuritySummarySpamParamsSPF = "NONE" - RadarEmailSecuritySummarySpamParamsSPFFail RadarEmailSecuritySummarySpamParamsSPF = "FAIL" -) - -type RadarEmailSecuritySummarySpamParamsTLSVersion string - -const ( - RadarEmailSecuritySummarySpamParamsTLSVersionTlSv1_0 RadarEmailSecuritySummarySpamParamsTLSVersion = "TLSv1_0" - RadarEmailSecuritySummarySpamParamsTLSVersionTlSv1_1 RadarEmailSecuritySummarySpamParamsTLSVersion = "TLSv1_1" - RadarEmailSecuritySummarySpamParamsTLSVersionTlSv1_2 RadarEmailSecuritySummarySpamParamsTLSVersion = "TLSv1_2" - RadarEmailSecuritySummarySpamParamsTLSVersionTlSv1_3 RadarEmailSecuritySummarySpamParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecuritySummarySpamResponseEnvelope struct { - Result RadarEmailSecuritySummarySpamResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecuritySummarySpamResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecuritySummarySpamResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarEmailSecuritySummarySpamResponseEnvelope] -type radarEmailSecuritySummarySpamResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySpamResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySpamResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySPFParams struct { - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecuritySummarySPFParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecuritySummarySPFParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecuritySummarySPFParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecuritySummarySPFParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecuritySummarySPFParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecuritySummarySPFParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecuritySummarySPFParams]'s query parameters as -// `url.Values`. -func (r RadarEmailSecuritySummarySPFParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarEmailSecuritySummarySPFParamsARC string - -const ( - RadarEmailSecuritySummarySPFParamsARCPass RadarEmailSecuritySummarySPFParamsARC = "PASS" - RadarEmailSecuritySummarySPFParamsARCNone RadarEmailSecuritySummarySPFParamsARC = "NONE" - RadarEmailSecuritySummarySPFParamsARCFail RadarEmailSecuritySummarySPFParamsARC = "FAIL" -) - -type RadarEmailSecuritySummarySPFParamsDateRange string - -const ( - RadarEmailSecuritySummarySPFParamsDateRange1d RadarEmailSecuritySummarySPFParamsDateRange = "1d" - RadarEmailSecuritySummarySPFParamsDateRange2d RadarEmailSecuritySummarySPFParamsDateRange = "2d" - RadarEmailSecuritySummarySPFParamsDateRange7d RadarEmailSecuritySummarySPFParamsDateRange = "7d" - RadarEmailSecuritySummarySPFParamsDateRange14d RadarEmailSecuritySummarySPFParamsDateRange = "14d" - RadarEmailSecuritySummarySPFParamsDateRange28d RadarEmailSecuritySummarySPFParamsDateRange = "28d" - RadarEmailSecuritySummarySPFParamsDateRange12w RadarEmailSecuritySummarySPFParamsDateRange = "12w" - RadarEmailSecuritySummarySPFParamsDateRange24w RadarEmailSecuritySummarySPFParamsDateRange = "24w" - RadarEmailSecuritySummarySPFParamsDateRange52w RadarEmailSecuritySummarySPFParamsDateRange = "52w" - RadarEmailSecuritySummarySPFParamsDateRange1dControl RadarEmailSecuritySummarySPFParamsDateRange = "1dControl" - RadarEmailSecuritySummarySPFParamsDateRange2dControl RadarEmailSecuritySummarySPFParamsDateRange = "2dControl" - RadarEmailSecuritySummarySPFParamsDateRange7dControl RadarEmailSecuritySummarySPFParamsDateRange = "7dControl" - RadarEmailSecuritySummarySPFParamsDateRange14dControl RadarEmailSecuritySummarySPFParamsDateRange = "14dControl" - RadarEmailSecuritySummarySPFParamsDateRange28dControl RadarEmailSecuritySummarySPFParamsDateRange = "28dControl" - RadarEmailSecuritySummarySPFParamsDateRange12wControl RadarEmailSecuritySummarySPFParamsDateRange = "12wControl" - RadarEmailSecuritySummarySPFParamsDateRange24wControl RadarEmailSecuritySummarySPFParamsDateRange = "24wControl" -) - -type RadarEmailSecuritySummarySPFParamsDKIM string - -const ( - RadarEmailSecuritySummarySPFParamsDKIMPass RadarEmailSecuritySummarySPFParamsDKIM = "PASS" - RadarEmailSecuritySummarySPFParamsDKIMNone RadarEmailSecuritySummarySPFParamsDKIM = "NONE" - RadarEmailSecuritySummarySPFParamsDKIMFail RadarEmailSecuritySummarySPFParamsDKIM = "FAIL" -) - -type RadarEmailSecuritySummarySPFParamsDMARC string - -const ( - RadarEmailSecuritySummarySPFParamsDMARCPass RadarEmailSecuritySummarySPFParamsDMARC = "PASS" - RadarEmailSecuritySummarySPFParamsDMARCNone RadarEmailSecuritySummarySPFParamsDMARC = "NONE" - RadarEmailSecuritySummarySPFParamsDMARCFail RadarEmailSecuritySummarySPFParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecuritySummarySPFParamsFormat string - -const ( - RadarEmailSecuritySummarySPFParamsFormatJson RadarEmailSecuritySummarySPFParamsFormat = "JSON" - RadarEmailSecuritySummarySPFParamsFormatCsv RadarEmailSecuritySummarySPFParamsFormat = "CSV" -) - -type RadarEmailSecuritySummarySPFParamsTLSVersion string - -const ( - RadarEmailSecuritySummarySPFParamsTLSVersionTlSv1_0 RadarEmailSecuritySummarySPFParamsTLSVersion = "TLSv1_0" - RadarEmailSecuritySummarySPFParamsTLSVersionTlSv1_1 RadarEmailSecuritySummarySPFParamsTLSVersion = "TLSv1_1" - RadarEmailSecuritySummarySPFParamsTLSVersionTlSv1_2 RadarEmailSecuritySummarySPFParamsTLSVersion = "TLSv1_2" - RadarEmailSecuritySummarySPFParamsTLSVersionTlSv1_3 RadarEmailSecuritySummarySPFParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecuritySummarySPFResponseEnvelope struct { - Result RadarEmailSecuritySummarySPFResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecuritySummarySPFResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecuritySummarySPFResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarEmailSecuritySummarySPFResponseEnvelope] -type radarEmailSecuritySummarySPFResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySPFResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySPFResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummarySpoofParams struct { - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecuritySummarySpoofParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecuritySummarySpoofParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecuritySummarySpoofParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecuritySummarySpoofParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecuritySummarySpoofParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecuritySummarySpoofParamsSPF] `query:"spf"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecuritySummarySpoofParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecuritySummarySpoofParams]'s query parameters as -// `url.Values`. -func (r RadarEmailSecuritySummarySpoofParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarEmailSecuritySummarySpoofParamsARC string - -const ( - RadarEmailSecuritySummarySpoofParamsARCPass RadarEmailSecuritySummarySpoofParamsARC = "PASS" - RadarEmailSecuritySummarySpoofParamsARCNone RadarEmailSecuritySummarySpoofParamsARC = "NONE" - RadarEmailSecuritySummarySpoofParamsARCFail RadarEmailSecuritySummarySpoofParamsARC = "FAIL" -) - -type RadarEmailSecuritySummarySpoofParamsDateRange string - -const ( - RadarEmailSecuritySummarySpoofParamsDateRange1d RadarEmailSecuritySummarySpoofParamsDateRange = "1d" - RadarEmailSecuritySummarySpoofParamsDateRange2d RadarEmailSecuritySummarySpoofParamsDateRange = "2d" - RadarEmailSecuritySummarySpoofParamsDateRange7d RadarEmailSecuritySummarySpoofParamsDateRange = "7d" - RadarEmailSecuritySummarySpoofParamsDateRange14d RadarEmailSecuritySummarySpoofParamsDateRange = "14d" - RadarEmailSecuritySummarySpoofParamsDateRange28d RadarEmailSecuritySummarySpoofParamsDateRange = "28d" - RadarEmailSecuritySummarySpoofParamsDateRange12w RadarEmailSecuritySummarySpoofParamsDateRange = "12w" - RadarEmailSecuritySummarySpoofParamsDateRange24w RadarEmailSecuritySummarySpoofParamsDateRange = "24w" - RadarEmailSecuritySummarySpoofParamsDateRange52w RadarEmailSecuritySummarySpoofParamsDateRange = "52w" - RadarEmailSecuritySummarySpoofParamsDateRange1dControl RadarEmailSecuritySummarySpoofParamsDateRange = "1dControl" - RadarEmailSecuritySummarySpoofParamsDateRange2dControl RadarEmailSecuritySummarySpoofParamsDateRange = "2dControl" - RadarEmailSecuritySummarySpoofParamsDateRange7dControl RadarEmailSecuritySummarySpoofParamsDateRange = "7dControl" - RadarEmailSecuritySummarySpoofParamsDateRange14dControl RadarEmailSecuritySummarySpoofParamsDateRange = "14dControl" - RadarEmailSecuritySummarySpoofParamsDateRange28dControl RadarEmailSecuritySummarySpoofParamsDateRange = "28dControl" - RadarEmailSecuritySummarySpoofParamsDateRange12wControl RadarEmailSecuritySummarySpoofParamsDateRange = "12wControl" - RadarEmailSecuritySummarySpoofParamsDateRange24wControl RadarEmailSecuritySummarySpoofParamsDateRange = "24wControl" -) - -type RadarEmailSecuritySummarySpoofParamsDKIM string - -const ( - RadarEmailSecuritySummarySpoofParamsDKIMPass RadarEmailSecuritySummarySpoofParamsDKIM = "PASS" - RadarEmailSecuritySummarySpoofParamsDKIMNone RadarEmailSecuritySummarySpoofParamsDKIM = "NONE" - RadarEmailSecuritySummarySpoofParamsDKIMFail RadarEmailSecuritySummarySpoofParamsDKIM = "FAIL" -) - -type RadarEmailSecuritySummarySpoofParamsDMARC string - -const ( - RadarEmailSecuritySummarySpoofParamsDMARCPass RadarEmailSecuritySummarySpoofParamsDMARC = "PASS" - RadarEmailSecuritySummarySpoofParamsDMARCNone RadarEmailSecuritySummarySpoofParamsDMARC = "NONE" - RadarEmailSecuritySummarySpoofParamsDMARCFail RadarEmailSecuritySummarySpoofParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecuritySummarySpoofParamsFormat string - -const ( - RadarEmailSecuritySummarySpoofParamsFormatJson RadarEmailSecuritySummarySpoofParamsFormat = "JSON" - RadarEmailSecuritySummarySpoofParamsFormatCsv RadarEmailSecuritySummarySpoofParamsFormat = "CSV" -) - -type RadarEmailSecuritySummarySpoofParamsSPF string - -const ( - RadarEmailSecuritySummarySpoofParamsSPFPass RadarEmailSecuritySummarySpoofParamsSPF = "PASS" - RadarEmailSecuritySummarySpoofParamsSPFNone RadarEmailSecuritySummarySpoofParamsSPF = "NONE" - RadarEmailSecuritySummarySpoofParamsSPFFail RadarEmailSecuritySummarySpoofParamsSPF = "FAIL" -) - -type RadarEmailSecuritySummarySpoofParamsTLSVersion string - -const ( - RadarEmailSecuritySummarySpoofParamsTLSVersionTlSv1_0 RadarEmailSecuritySummarySpoofParamsTLSVersion = "TLSv1_0" - RadarEmailSecuritySummarySpoofParamsTLSVersionTlSv1_1 RadarEmailSecuritySummarySpoofParamsTLSVersion = "TLSv1_1" - RadarEmailSecuritySummarySpoofParamsTLSVersionTlSv1_2 RadarEmailSecuritySummarySpoofParamsTLSVersion = "TLSv1_2" - RadarEmailSecuritySummarySpoofParamsTLSVersionTlSv1_3 RadarEmailSecuritySummarySpoofParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecuritySummarySpoofResponseEnvelope struct { - Result RadarEmailSecuritySummarySpoofResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecuritySummarySpoofResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecuritySummarySpoofResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarEmailSecuritySummarySpoofResponseEnvelope] -type radarEmailSecuritySummarySpoofResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummarySpoofResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummarySpoofResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryThreatCategoryParams struct { - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecuritySummaryThreatCategoryParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecuritySummaryThreatCategoryParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecuritySummaryThreatCategoryParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecuritySummaryThreatCategoryParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecuritySummaryThreatCategoryParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecuritySummaryThreatCategoryParamsSPF] `query:"spf"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecuritySummaryThreatCategoryParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecuritySummaryThreatCategoryParams]'s query -// parameters as `url.Values`. -func (r RadarEmailSecuritySummaryThreatCategoryParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarEmailSecuritySummaryThreatCategoryParamsARC string - -const ( - RadarEmailSecuritySummaryThreatCategoryParamsARCPass RadarEmailSecuritySummaryThreatCategoryParamsARC = "PASS" - RadarEmailSecuritySummaryThreatCategoryParamsARCNone RadarEmailSecuritySummaryThreatCategoryParamsARC = "NONE" - RadarEmailSecuritySummaryThreatCategoryParamsARCFail RadarEmailSecuritySummaryThreatCategoryParamsARC = "FAIL" -) - -type RadarEmailSecuritySummaryThreatCategoryParamsDateRange string - -const ( - RadarEmailSecuritySummaryThreatCategoryParamsDateRange1d RadarEmailSecuritySummaryThreatCategoryParamsDateRange = "1d" - RadarEmailSecuritySummaryThreatCategoryParamsDateRange2d RadarEmailSecuritySummaryThreatCategoryParamsDateRange = "2d" - RadarEmailSecuritySummaryThreatCategoryParamsDateRange7d RadarEmailSecuritySummaryThreatCategoryParamsDateRange = "7d" - RadarEmailSecuritySummaryThreatCategoryParamsDateRange14d RadarEmailSecuritySummaryThreatCategoryParamsDateRange = "14d" - RadarEmailSecuritySummaryThreatCategoryParamsDateRange28d RadarEmailSecuritySummaryThreatCategoryParamsDateRange = "28d" - RadarEmailSecuritySummaryThreatCategoryParamsDateRange12w RadarEmailSecuritySummaryThreatCategoryParamsDateRange = "12w" - RadarEmailSecuritySummaryThreatCategoryParamsDateRange24w RadarEmailSecuritySummaryThreatCategoryParamsDateRange = "24w" - RadarEmailSecuritySummaryThreatCategoryParamsDateRange52w RadarEmailSecuritySummaryThreatCategoryParamsDateRange = "52w" - RadarEmailSecuritySummaryThreatCategoryParamsDateRange1dControl RadarEmailSecuritySummaryThreatCategoryParamsDateRange = "1dControl" - RadarEmailSecuritySummaryThreatCategoryParamsDateRange2dControl RadarEmailSecuritySummaryThreatCategoryParamsDateRange = "2dControl" - RadarEmailSecuritySummaryThreatCategoryParamsDateRange7dControl RadarEmailSecuritySummaryThreatCategoryParamsDateRange = "7dControl" - RadarEmailSecuritySummaryThreatCategoryParamsDateRange14dControl RadarEmailSecuritySummaryThreatCategoryParamsDateRange = "14dControl" - RadarEmailSecuritySummaryThreatCategoryParamsDateRange28dControl RadarEmailSecuritySummaryThreatCategoryParamsDateRange = "28dControl" - RadarEmailSecuritySummaryThreatCategoryParamsDateRange12wControl RadarEmailSecuritySummaryThreatCategoryParamsDateRange = "12wControl" - RadarEmailSecuritySummaryThreatCategoryParamsDateRange24wControl RadarEmailSecuritySummaryThreatCategoryParamsDateRange = "24wControl" -) - -type RadarEmailSecuritySummaryThreatCategoryParamsDKIM string - -const ( - RadarEmailSecuritySummaryThreatCategoryParamsDKIMPass RadarEmailSecuritySummaryThreatCategoryParamsDKIM = "PASS" - RadarEmailSecuritySummaryThreatCategoryParamsDKIMNone RadarEmailSecuritySummaryThreatCategoryParamsDKIM = "NONE" - RadarEmailSecuritySummaryThreatCategoryParamsDKIMFail RadarEmailSecuritySummaryThreatCategoryParamsDKIM = "FAIL" -) - -type RadarEmailSecuritySummaryThreatCategoryParamsDMARC string - -const ( - RadarEmailSecuritySummaryThreatCategoryParamsDMARCPass RadarEmailSecuritySummaryThreatCategoryParamsDMARC = "PASS" - RadarEmailSecuritySummaryThreatCategoryParamsDMARCNone RadarEmailSecuritySummaryThreatCategoryParamsDMARC = "NONE" - RadarEmailSecuritySummaryThreatCategoryParamsDMARCFail RadarEmailSecuritySummaryThreatCategoryParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecuritySummaryThreatCategoryParamsFormat string - -const ( - RadarEmailSecuritySummaryThreatCategoryParamsFormatJson RadarEmailSecuritySummaryThreatCategoryParamsFormat = "JSON" - RadarEmailSecuritySummaryThreatCategoryParamsFormatCsv RadarEmailSecuritySummaryThreatCategoryParamsFormat = "CSV" -) - -type RadarEmailSecuritySummaryThreatCategoryParamsSPF string - -const ( - RadarEmailSecuritySummaryThreatCategoryParamsSPFPass RadarEmailSecuritySummaryThreatCategoryParamsSPF = "PASS" - RadarEmailSecuritySummaryThreatCategoryParamsSPFNone RadarEmailSecuritySummaryThreatCategoryParamsSPF = "NONE" - RadarEmailSecuritySummaryThreatCategoryParamsSPFFail RadarEmailSecuritySummaryThreatCategoryParamsSPF = "FAIL" -) - -type RadarEmailSecuritySummaryThreatCategoryParamsTLSVersion string - -const ( - RadarEmailSecuritySummaryThreatCategoryParamsTLSVersionTlSv1_0 RadarEmailSecuritySummaryThreatCategoryParamsTLSVersion = "TLSv1_0" - RadarEmailSecuritySummaryThreatCategoryParamsTLSVersionTlSv1_1 RadarEmailSecuritySummaryThreatCategoryParamsTLSVersion = "TLSv1_1" - RadarEmailSecuritySummaryThreatCategoryParamsTLSVersionTlSv1_2 RadarEmailSecuritySummaryThreatCategoryParamsTLSVersion = "TLSv1_2" - RadarEmailSecuritySummaryThreatCategoryParamsTLSVersionTlSv1_3 RadarEmailSecuritySummaryThreatCategoryParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecuritySummaryThreatCategoryResponseEnvelope struct { - Result RadarEmailSecuritySummaryThreatCategoryResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecuritySummaryThreatCategoryResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecuritySummaryThreatCategoryResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [RadarEmailSecuritySummaryThreatCategoryResponseEnvelope] -type radarEmailSecuritySummaryThreatCategoryResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryThreatCategoryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryThreatCategoryResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecuritySummaryTLSVersionParams struct { - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecuritySummaryTLSVersionParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecuritySummaryTLSVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecuritySummaryTLSVersionParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecuritySummaryTLSVersionParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecuritySummaryTLSVersionParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecuritySummaryTLSVersionParamsSPF] `query:"spf"` -} - -// URLQuery serializes [RadarEmailSecuritySummaryTLSVersionParams]'s query -// parameters as `url.Values`. -func (r RadarEmailSecuritySummaryTLSVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarEmailSecuritySummaryTLSVersionParamsARC string - -const ( - RadarEmailSecuritySummaryTLSVersionParamsARCPass RadarEmailSecuritySummaryTLSVersionParamsARC = "PASS" - RadarEmailSecuritySummaryTLSVersionParamsARCNone RadarEmailSecuritySummaryTLSVersionParamsARC = "NONE" - RadarEmailSecuritySummaryTLSVersionParamsARCFail RadarEmailSecuritySummaryTLSVersionParamsARC = "FAIL" -) - -type RadarEmailSecuritySummaryTLSVersionParamsDateRange string - -const ( - RadarEmailSecuritySummaryTLSVersionParamsDateRange1d RadarEmailSecuritySummaryTLSVersionParamsDateRange = "1d" - RadarEmailSecuritySummaryTLSVersionParamsDateRange2d RadarEmailSecuritySummaryTLSVersionParamsDateRange = "2d" - RadarEmailSecuritySummaryTLSVersionParamsDateRange7d RadarEmailSecuritySummaryTLSVersionParamsDateRange = "7d" - RadarEmailSecuritySummaryTLSVersionParamsDateRange14d RadarEmailSecuritySummaryTLSVersionParamsDateRange = "14d" - RadarEmailSecuritySummaryTLSVersionParamsDateRange28d RadarEmailSecuritySummaryTLSVersionParamsDateRange = "28d" - RadarEmailSecuritySummaryTLSVersionParamsDateRange12w RadarEmailSecuritySummaryTLSVersionParamsDateRange = "12w" - RadarEmailSecuritySummaryTLSVersionParamsDateRange24w RadarEmailSecuritySummaryTLSVersionParamsDateRange = "24w" - RadarEmailSecuritySummaryTLSVersionParamsDateRange52w RadarEmailSecuritySummaryTLSVersionParamsDateRange = "52w" - RadarEmailSecuritySummaryTLSVersionParamsDateRange1dControl RadarEmailSecuritySummaryTLSVersionParamsDateRange = "1dControl" - RadarEmailSecuritySummaryTLSVersionParamsDateRange2dControl RadarEmailSecuritySummaryTLSVersionParamsDateRange = "2dControl" - RadarEmailSecuritySummaryTLSVersionParamsDateRange7dControl RadarEmailSecuritySummaryTLSVersionParamsDateRange = "7dControl" - RadarEmailSecuritySummaryTLSVersionParamsDateRange14dControl RadarEmailSecuritySummaryTLSVersionParamsDateRange = "14dControl" - RadarEmailSecuritySummaryTLSVersionParamsDateRange28dControl RadarEmailSecuritySummaryTLSVersionParamsDateRange = "28dControl" - RadarEmailSecuritySummaryTLSVersionParamsDateRange12wControl RadarEmailSecuritySummaryTLSVersionParamsDateRange = "12wControl" - RadarEmailSecuritySummaryTLSVersionParamsDateRange24wControl RadarEmailSecuritySummaryTLSVersionParamsDateRange = "24wControl" -) - -type RadarEmailSecuritySummaryTLSVersionParamsDKIM string - -const ( - RadarEmailSecuritySummaryTLSVersionParamsDKIMPass RadarEmailSecuritySummaryTLSVersionParamsDKIM = "PASS" - RadarEmailSecuritySummaryTLSVersionParamsDKIMNone RadarEmailSecuritySummaryTLSVersionParamsDKIM = "NONE" - RadarEmailSecuritySummaryTLSVersionParamsDKIMFail RadarEmailSecuritySummaryTLSVersionParamsDKIM = "FAIL" -) - -type RadarEmailSecuritySummaryTLSVersionParamsDMARC string - -const ( - RadarEmailSecuritySummaryTLSVersionParamsDMARCPass RadarEmailSecuritySummaryTLSVersionParamsDMARC = "PASS" - RadarEmailSecuritySummaryTLSVersionParamsDMARCNone RadarEmailSecuritySummaryTLSVersionParamsDMARC = "NONE" - RadarEmailSecuritySummaryTLSVersionParamsDMARCFail RadarEmailSecuritySummaryTLSVersionParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecuritySummaryTLSVersionParamsFormat string - -const ( - RadarEmailSecuritySummaryTLSVersionParamsFormatJson RadarEmailSecuritySummaryTLSVersionParamsFormat = "JSON" - RadarEmailSecuritySummaryTLSVersionParamsFormatCsv RadarEmailSecuritySummaryTLSVersionParamsFormat = "CSV" -) - -type RadarEmailSecuritySummaryTLSVersionParamsSPF string - -const ( - RadarEmailSecuritySummaryTLSVersionParamsSPFPass RadarEmailSecuritySummaryTLSVersionParamsSPF = "PASS" - RadarEmailSecuritySummaryTLSVersionParamsSPFNone RadarEmailSecuritySummaryTLSVersionParamsSPF = "NONE" - RadarEmailSecuritySummaryTLSVersionParamsSPFFail RadarEmailSecuritySummaryTLSVersionParamsSPF = "FAIL" -) - -type RadarEmailSecuritySummaryTLSVersionResponseEnvelope struct { - Result RadarEmailSecuritySummaryTLSVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecuritySummaryTLSVersionResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecuritySummaryTLSVersionResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarEmailSecuritySummaryTLSVersionResponseEnvelope] -type radarEmailSecuritySummaryTLSVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecuritySummaryTLSVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecuritySummaryTLSVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radaremailsecuritysummary_test.go b/radaremailsecuritysummary_test.go deleted file mode 100644 index 74cf5da7212..00000000000 --- a/radaremailsecuritysummary_test.go +++ /dev/null @@ -1,325 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarEmailSecuritySummaryARCWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.Summary.ARC(context.TODO(), cloudflare.RadarEmailSecuritySummaryARCParams{ - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryARCParamsDateRange{cloudflare.RadarEmailSecuritySummaryARCParamsDateRange1d, cloudflare.RadarEmailSecuritySummaryARCParamsDateRange2d, cloudflare.RadarEmailSecuritySummaryARCParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryARCParamsDKIM{cloudflare.RadarEmailSecuritySummaryARCParamsDKIMPass, cloudflare.RadarEmailSecuritySummaryARCParamsDKIMNone, cloudflare.RadarEmailSecuritySummaryARCParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryARCParamsDMARC{cloudflare.RadarEmailSecuritySummaryARCParamsDMARCPass, cloudflare.RadarEmailSecuritySummaryARCParamsDMARCNone, cloudflare.RadarEmailSecuritySummaryARCParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecuritySummaryARCParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryARCParamsSPF{cloudflare.RadarEmailSecuritySummaryARCParamsSPFPass, cloudflare.RadarEmailSecuritySummaryARCParamsSPFNone, cloudflare.RadarEmailSecuritySummaryARCParamsSPFFail}), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryARCParamsTLSVersion{cloudflare.RadarEmailSecuritySummaryARCParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecuritySummaryARCParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecuritySummaryARCParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarEmailSecuritySummaryDKIMWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.Summary.DKIM(context.TODO(), cloudflare.RadarEmailSecuritySummaryDKIMParams{ - ARC: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryDKIMParamsARC{cloudflare.RadarEmailSecuritySummaryDKIMParamsARCPass, cloudflare.RadarEmailSecuritySummaryDKIMParamsARCNone, cloudflare.RadarEmailSecuritySummaryDKIMParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryDKIMParamsDateRange{cloudflare.RadarEmailSecuritySummaryDKIMParamsDateRange1d, cloudflare.RadarEmailSecuritySummaryDKIMParamsDateRange2d, cloudflare.RadarEmailSecuritySummaryDKIMParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryDKIMParamsDMARC{cloudflare.RadarEmailSecuritySummaryDKIMParamsDMARCPass, cloudflare.RadarEmailSecuritySummaryDKIMParamsDMARCNone, cloudflare.RadarEmailSecuritySummaryDKIMParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecuritySummaryDKIMParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryDKIMParamsSPF{cloudflare.RadarEmailSecuritySummaryDKIMParamsSPFPass, cloudflare.RadarEmailSecuritySummaryDKIMParamsSPFNone, cloudflare.RadarEmailSecuritySummaryDKIMParamsSPFFail}), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryDKIMParamsTLSVersion{cloudflare.RadarEmailSecuritySummaryDKIMParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecuritySummaryDKIMParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecuritySummaryDKIMParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarEmailSecuritySummaryDMARCWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.Summary.DMARC(context.TODO(), cloudflare.RadarEmailSecuritySummaryDMARCParams{ - ARC: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryDMARCParamsARC{cloudflare.RadarEmailSecuritySummaryDMARCParamsARCPass, cloudflare.RadarEmailSecuritySummaryDMARCParamsARCNone, cloudflare.RadarEmailSecuritySummaryDMARCParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryDMARCParamsDateRange{cloudflare.RadarEmailSecuritySummaryDMARCParamsDateRange1d, cloudflare.RadarEmailSecuritySummaryDMARCParamsDateRange2d, cloudflare.RadarEmailSecuritySummaryDMARCParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryDMARCParamsDKIM{cloudflare.RadarEmailSecuritySummaryDMARCParamsDKIMPass, cloudflare.RadarEmailSecuritySummaryDMARCParamsDKIMNone, cloudflare.RadarEmailSecuritySummaryDMARCParamsDKIMFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecuritySummaryDMARCParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryDMARCParamsSPF{cloudflare.RadarEmailSecuritySummaryDMARCParamsSPFPass, cloudflare.RadarEmailSecuritySummaryDMARCParamsSPFNone, cloudflare.RadarEmailSecuritySummaryDMARCParamsSPFFail}), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryDMARCParamsTLSVersion{cloudflare.RadarEmailSecuritySummaryDMARCParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecuritySummaryDMARCParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecuritySummaryDMARCParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarEmailSecuritySummaryMaliciousWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.Summary.Malicious(context.TODO(), cloudflare.RadarEmailSecuritySummaryMaliciousParams{ - ARC: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryMaliciousParamsARC{cloudflare.RadarEmailSecuritySummaryMaliciousParamsARCPass, cloudflare.RadarEmailSecuritySummaryMaliciousParamsARCNone, cloudflare.RadarEmailSecuritySummaryMaliciousParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryMaliciousParamsDateRange{cloudflare.RadarEmailSecuritySummaryMaliciousParamsDateRange1d, cloudflare.RadarEmailSecuritySummaryMaliciousParamsDateRange2d, cloudflare.RadarEmailSecuritySummaryMaliciousParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryMaliciousParamsDKIM{cloudflare.RadarEmailSecuritySummaryMaliciousParamsDKIMPass, cloudflare.RadarEmailSecuritySummaryMaliciousParamsDKIMNone, cloudflare.RadarEmailSecuritySummaryMaliciousParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryMaliciousParamsDMARC{cloudflare.RadarEmailSecuritySummaryMaliciousParamsDMARCPass, cloudflare.RadarEmailSecuritySummaryMaliciousParamsDMARCNone, cloudflare.RadarEmailSecuritySummaryMaliciousParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecuritySummaryMaliciousParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryMaliciousParamsSPF{cloudflare.RadarEmailSecuritySummaryMaliciousParamsSPFPass, cloudflare.RadarEmailSecuritySummaryMaliciousParamsSPFNone, cloudflare.RadarEmailSecuritySummaryMaliciousParamsSPFFail}), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryMaliciousParamsTLSVersion{cloudflare.RadarEmailSecuritySummaryMaliciousParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecuritySummaryMaliciousParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecuritySummaryMaliciousParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarEmailSecuritySummarySpamWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.Summary.Spam(context.TODO(), cloudflare.RadarEmailSecuritySummarySpamParams{ - ARC: cloudflare.F([]cloudflare.RadarEmailSecuritySummarySpamParamsARC{cloudflare.RadarEmailSecuritySummarySpamParamsARCPass, cloudflare.RadarEmailSecuritySummarySpamParamsARCNone, cloudflare.RadarEmailSecuritySummarySpamParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecuritySummarySpamParamsDateRange{cloudflare.RadarEmailSecuritySummarySpamParamsDateRange1d, cloudflare.RadarEmailSecuritySummarySpamParamsDateRange2d, cloudflare.RadarEmailSecuritySummarySpamParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecuritySummarySpamParamsDKIM{cloudflare.RadarEmailSecuritySummarySpamParamsDKIMPass, cloudflare.RadarEmailSecuritySummarySpamParamsDKIMNone, cloudflare.RadarEmailSecuritySummarySpamParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecuritySummarySpamParamsDMARC{cloudflare.RadarEmailSecuritySummarySpamParamsDMARCPass, cloudflare.RadarEmailSecuritySummarySpamParamsDMARCNone, cloudflare.RadarEmailSecuritySummarySpamParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecuritySummarySpamParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecuritySummarySpamParamsSPF{cloudflare.RadarEmailSecuritySummarySpamParamsSPFPass, cloudflare.RadarEmailSecuritySummarySpamParamsSPFNone, cloudflare.RadarEmailSecuritySummarySpamParamsSPFFail}), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecuritySummarySpamParamsTLSVersion{cloudflare.RadarEmailSecuritySummarySpamParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecuritySummarySpamParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecuritySummarySpamParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarEmailSecuritySummarySPFWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.Summary.SPF(context.TODO(), cloudflare.RadarEmailSecuritySummarySPFParams{ - ARC: cloudflare.F([]cloudflare.RadarEmailSecuritySummarySPFParamsARC{cloudflare.RadarEmailSecuritySummarySPFParamsARCPass, cloudflare.RadarEmailSecuritySummarySPFParamsARCNone, cloudflare.RadarEmailSecuritySummarySPFParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecuritySummarySPFParamsDateRange{cloudflare.RadarEmailSecuritySummarySPFParamsDateRange1d, cloudflare.RadarEmailSecuritySummarySPFParamsDateRange2d, cloudflare.RadarEmailSecuritySummarySPFParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecuritySummarySPFParamsDKIM{cloudflare.RadarEmailSecuritySummarySPFParamsDKIMPass, cloudflare.RadarEmailSecuritySummarySPFParamsDKIMNone, cloudflare.RadarEmailSecuritySummarySPFParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecuritySummarySPFParamsDMARC{cloudflare.RadarEmailSecuritySummarySPFParamsDMARCPass, cloudflare.RadarEmailSecuritySummarySPFParamsDMARCNone, cloudflare.RadarEmailSecuritySummarySPFParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecuritySummarySPFParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecuritySummarySPFParamsTLSVersion{cloudflare.RadarEmailSecuritySummarySPFParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecuritySummarySPFParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecuritySummarySPFParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarEmailSecuritySummarySpoofWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.Summary.Spoof(context.TODO(), cloudflare.RadarEmailSecuritySummarySpoofParams{ - ARC: cloudflare.F([]cloudflare.RadarEmailSecuritySummarySpoofParamsARC{cloudflare.RadarEmailSecuritySummarySpoofParamsARCPass, cloudflare.RadarEmailSecuritySummarySpoofParamsARCNone, cloudflare.RadarEmailSecuritySummarySpoofParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecuritySummarySpoofParamsDateRange{cloudflare.RadarEmailSecuritySummarySpoofParamsDateRange1d, cloudflare.RadarEmailSecuritySummarySpoofParamsDateRange2d, cloudflare.RadarEmailSecuritySummarySpoofParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecuritySummarySpoofParamsDKIM{cloudflare.RadarEmailSecuritySummarySpoofParamsDKIMPass, cloudflare.RadarEmailSecuritySummarySpoofParamsDKIMNone, cloudflare.RadarEmailSecuritySummarySpoofParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecuritySummarySpoofParamsDMARC{cloudflare.RadarEmailSecuritySummarySpoofParamsDMARCPass, cloudflare.RadarEmailSecuritySummarySpoofParamsDMARCNone, cloudflare.RadarEmailSecuritySummarySpoofParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecuritySummarySpoofParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecuritySummarySpoofParamsSPF{cloudflare.RadarEmailSecuritySummarySpoofParamsSPFPass, cloudflare.RadarEmailSecuritySummarySpoofParamsSPFNone, cloudflare.RadarEmailSecuritySummarySpoofParamsSPFFail}), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecuritySummarySpoofParamsTLSVersion{cloudflare.RadarEmailSecuritySummarySpoofParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecuritySummarySpoofParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecuritySummarySpoofParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarEmailSecuritySummaryThreatCategoryWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.Summary.ThreatCategory(context.TODO(), cloudflare.RadarEmailSecuritySummaryThreatCategoryParams{ - ARC: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsARC{cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsARCPass, cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsARCNone, cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsDateRange{cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsDateRange1d, cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsDateRange2d, cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsDKIM{cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsDKIMPass, cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsDKIMNone, cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsDMARC{cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsDMARCPass, cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsDMARCNone, cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsSPF{cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsSPFPass, cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsSPFNone, cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsSPFFail}), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsTLSVersion{cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecuritySummaryThreatCategoryParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarEmailSecuritySummaryTLSVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.Summary.TLSVersion(context.TODO(), cloudflare.RadarEmailSecuritySummaryTLSVersionParams{ - ARC: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryTLSVersionParamsARC{cloudflare.RadarEmailSecuritySummaryTLSVersionParamsARCPass, cloudflare.RadarEmailSecuritySummaryTLSVersionParamsARCNone, cloudflare.RadarEmailSecuritySummaryTLSVersionParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryTLSVersionParamsDateRange{cloudflare.RadarEmailSecuritySummaryTLSVersionParamsDateRange1d, cloudflare.RadarEmailSecuritySummaryTLSVersionParamsDateRange2d, cloudflare.RadarEmailSecuritySummaryTLSVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryTLSVersionParamsDKIM{cloudflare.RadarEmailSecuritySummaryTLSVersionParamsDKIMPass, cloudflare.RadarEmailSecuritySummaryTLSVersionParamsDKIMNone, cloudflare.RadarEmailSecuritySummaryTLSVersionParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryTLSVersionParamsDMARC{cloudflare.RadarEmailSecuritySummaryTLSVersionParamsDMARCPass, cloudflare.RadarEmailSecuritySummaryTLSVersionParamsDMARCNone, cloudflare.RadarEmailSecuritySummaryTLSVersionParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecuritySummaryTLSVersionParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecuritySummaryTLSVersionParamsSPF{cloudflare.RadarEmailSecuritySummaryTLSVersionParamsSPFPass, cloudflare.RadarEmailSecuritySummaryTLSVersionParamsSPFNone, cloudflare.RadarEmailSecuritySummaryTLSVersionParamsSPFFail}), - }) - 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/radaremailsecuritytimeseriesgroup.go b/radaremailsecuritytimeseriesgroup.go deleted file mode 100644 index a07b16adb3e..00000000000 --- a/radaremailsecuritytimeseriesgroup.go +++ /dev/null @@ -1,1815 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarEmailSecurityTimeseriesGroupService 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 -// [NewRadarEmailSecurityTimeseriesGroupService] method instead. -type RadarEmailSecurityTimeseriesGroupService struct { - Options []option.RequestOption -} - -// NewRadarEmailSecurityTimeseriesGroupService 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 NewRadarEmailSecurityTimeseriesGroupService(opts ...option.RequestOption) (r *RadarEmailSecurityTimeseriesGroupService) { - r = &RadarEmailSecurityTimeseriesGroupService{} - r.Options = opts - return -} - -// Percentage distribution of emails classified per Arc validation over time. -func (r *RadarEmailSecurityTimeseriesGroupService) ARC(ctx context.Context, query RadarEmailSecurityTimeseriesGroupARCParams, opts ...option.RequestOption) (res *RadarEmailSecurityTimeseriesGroupARCResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecurityTimeseriesGroupARCResponseEnvelope - path := "radar/email/security/timeseries_groups/arc" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified per DKIM validation over time. -func (r *RadarEmailSecurityTimeseriesGroupService) DKIM(ctx context.Context, query RadarEmailSecurityTimeseriesGroupDKIMParams, opts ...option.RequestOption) (res *RadarEmailSecurityTimeseriesGroupDKIMResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecurityTimeseriesGroupDKIMResponseEnvelope - path := "radar/email/security/timeseries_groups/dkim" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified per DMARC validation over time. -func (r *RadarEmailSecurityTimeseriesGroupService) DMARC(ctx context.Context, query RadarEmailSecurityTimeseriesGroupDMARCParams, opts ...option.RequestOption) (res *RadarEmailSecurityTimeseriesGroupDMARCResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecurityTimeseriesGroupDMARCResponseEnvelope - path := "radar/email/security/timeseries_groups/dmarc" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified as MALICIOUS over time. -func (r *RadarEmailSecurityTimeseriesGroupService) Malicious(ctx context.Context, query RadarEmailSecurityTimeseriesGroupMaliciousParams, opts ...option.RequestOption) (res *RadarEmailSecurityTimeseriesGroupMaliciousResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecurityTimeseriesGroupMaliciousResponseEnvelope - path := "radar/email/security/timeseries_groups/malicious" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified as SPAM over time. -func (r *RadarEmailSecurityTimeseriesGroupService) Spam(ctx context.Context, query RadarEmailSecurityTimeseriesGroupSpamParams, opts ...option.RequestOption) (res *RadarEmailSecurityTimeseriesGroupSpamResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecurityTimeseriesGroupSpamResponseEnvelope - path := "radar/email/security/timeseries_groups/spam" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified per SPF validation over time. -func (r *RadarEmailSecurityTimeseriesGroupService) SPF(ctx context.Context, query RadarEmailSecurityTimeseriesGroupSPFParams, opts ...option.RequestOption) (res *RadarEmailSecurityTimeseriesGroupSPFResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecurityTimeseriesGroupSPFResponseEnvelope - path := "radar/email/security/timeseries_groups/spf" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified as SPOOF over time. -func (r *RadarEmailSecurityTimeseriesGroupService) Spoof(ctx context.Context, query RadarEmailSecurityTimeseriesGroupSpoofParams, opts ...option.RequestOption) (res *RadarEmailSecurityTimeseriesGroupSpoofResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecurityTimeseriesGroupSpoofResponseEnvelope - path := "radar/email/security/timeseries_groups/spoof" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified in Threat Categories over time. -func (r *RadarEmailSecurityTimeseriesGroupService) ThreatCategory(ctx context.Context, query RadarEmailSecurityTimeseriesGroupThreatCategoryParams, opts ...option.RequestOption) (res *RadarEmailSecurityTimeseriesGroupThreatCategoryResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecurityTimeseriesGroupThreatCategoryResponseEnvelope - path := "radar/email/security/timeseries_groups/threat_category" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of emails classified per TLS Version over time. -func (r *RadarEmailSecurityTimeseriesGroupService) TLSVersion(ctx context.Context, query RadarEmailSecurityTimeseriesGroupTLSVersionParams, opts ...option.RequestOption) (res *RadarEmailSecurityTimeseriesGroupTLSVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecurityTimeseriesGroupTLSVersionResponseEnvelope - path := "radar/email/security/timeseries_groups/tls_version" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarEmailSecurityTimeseriesGroupARCResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarEmailSecurityTimeseriesGroupARCResponseSerie0 `json:"serie_0,required"` - JSON radarEmailSecurityTimeseriesGroupARCResponseJSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupARCResponseJSON contains the JSON metadata for -// the struct [RadarEmailSecurityTimeseriesGroupARCResponse] -type radarEmailSecurityTimeseriesGroupARCResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupARCResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupARCResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupARCResponseSerie0 struct { - Fail []string `json:"FAIL,required"` - None []string `json:"NONE,required"` - Pass []string `json:"PASS,required"` - JSON radarEmailSecurityTimeseriesGroupARCResponseSerie0JSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupARCResponseSerie0JSON contains the JSON -// metadata for the struct [RadarEmailSecurityTimeseriesGroupARCResponseSerie0] -type radarEmailSecurityTimeseriesGroupARCResponseSerie0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupARCResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupARCResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupDKIMResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarEmailSecurityTimeseriesGroupDKIMResponseSerie0 `json:"serie_0,required"` - JSON radarEmailSecurityTimeseriesGroupDKIMResponseJSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupDKIMResponseJSON contains the JSON metadata for -// the struct [RadarEmailSecurityTimeseriesGroupDKIMResponse] -type radarEmailSecurityTimeseriesGroupDKIMResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupDKIMResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupDKIMResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupDKIMResponseSerie0 struct { - Fail []string `json:"FAIL,required"` - None []string `json:"NONE,required"` - Pass []string `json:"PASS,required"` - JSON radarEmailSecurityTimeseriesGroupDKIMResponseSerie0JSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupDKIMResponseSerie0JSON contains the JSON -// metadata for the struct [RadarEmailSecurityTimeseriesGroupDKIMResponseSerie0] -type radarEmailSecurityTimeseriesGroupDKIMResponseSerie0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupDKIMResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupDKIMResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupDMARCResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarEmailSecurityTimeseriesGroupDMARCResponseSerie0 `json:"serie_0,required"` - JSON radarEmailSecurityTimeseriesGroupDMARCResponseJSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupDMARCResponseJSON contains the JSON metadata -// for the struct [RadarEmailSecurityTimeseriesGroupDMARCResponse] -type radarEmailSecurityTimeseriesGroupDMARCResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupDMARCResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupDMARCResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupDMARCResponseSerie0 struct { - Fail []string `json:"FAIL,required"` - None []string `json:"NONE,required"` - Pass []string `json:"PASS,required"` - JSON radarEmailSecurityTimeseriesGroupDMARCResponseSerie0JSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupDMARCResponseSerie0JSON contains the JSON -// metadata for the struct [RadarEmailSecurityTimeseriesGroupDMARCResponseSerie0] -type radarEmailSecurityTimeseriesGroupDMARCResponseSerie0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupDMARCResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupDMARCResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupMaliciousResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarEmailSecurityTimeseriesGroupMaliciousResponseSerie0 `json:"serie_0,required"` - JSON radarEmailSecurityTimeseriesGroupMaliciousResponseJSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupMaliciousResponseJSON contains the JSON -// metadata for the struct [RadarEmailSecurityTimeseriesGroupMaliciousResponse] -type radarEmailSecurityTimeseriesGroupMaliciousResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupMaliciousResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupMaliciousResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupMaliciousResponseSerie0 struct { - Malicious []string `json:"MALICIOUS,required"` - NotMalicious []string `json:"NOT_MALICIOUS,required"` - JSON radarEmailSecurityTimeseriesGroupMaliciousResponseSerie0JSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupMaliciousResponseSerie0JSON contains the JSON -// metadata for the struct -// [RadarEmailSecurityTimeseriesGroupMaliciousResponseSerie0] -type radarEmailSecurityTimeseriesGroupMaliciousResponseSerie0JSON struct { - Malicious apijson.Field - NotMalicious apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupMaliciousResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupMaliciousResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupSpamResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarEmailSecurityTimeseriesGroupSpamResponseSerie0 `json:"serie_0,required"` - JSON radarEmailSecurityTimeseriesGroupSpamResponseJSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupSpamResponseJSON contains the JSON metadata for -// the struct [RadarEmailSecurityTimeseriesGroupSpamResponse] -type radarEmailSecurityTimeseriesGroupSpamResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupSpamResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupSpamResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupSpamResponseSerie0 struct { - NotSpam []string `json:"NOT_SPAM,required"` - Spam []string `json:"SPAM,required"` - JSON radarEmailSecurityTimeseriesGroupSpamResponseSerie0JSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupSpamResponseSerie0JSON contains the JSON -// metadata for the struct [RadarEmailSecurityTimeseriesGroupSpamResponseSerie0] -type radarEmailSecurityTimeseriesGroupSpamResponseSerie0JSON struct { - NotSpam apijson.Field - Spam apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupSpamResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupSpamResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupSPFResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarEmailSecurityTimeseriesGroupSPFResponseSerie0 `json:"serie_0,required"` - JSON radarEmailSecurityTimeseriesGroupSPFResponseJSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupSPFResponseJSON contains the JSON metadata for -// the struct [RadarEmailSecurityTimeseriesGroupSPFResponse] -type radarEmailSecurityTimeseriesGroupSPFResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupSPFResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupSPFResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupSPFResponseSerie0 struct { - Fail []string `json:"FAIL,required"` - None []string `json:"NONE,required"` - Pass []string `json:"PASS,required"` - JSON radarEmailSecurityTimeseriesGroupSPFResponseSerie0JSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupSPFResponseSerie0JSON contains the JSON -// metadata for the struct [RadarEmailSecurityTimeseriesGroupSPFResponseSerie0] -type radarEmailSecurityTimeseriesGroupSPFResponseSerie0JSON struct { - Fail apijson.Field - None apijson.Field - Pass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupSPFResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupSPFResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupSpoofResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarEmailSecurityTimeseriesGroupSpoofResponseSerie0 `json:"serie_0,required"` - JSON radarEmailSecurityTimeseriesGroupSpoofResponseJSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupSpoofResponseJSON contains the JSON metadata -// for the struct [RadarEmailSecurityTimeseriesGroupSpoofResponse] -type radarEmailSecurityTimeseriesGroupSpoofResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupSpoofResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupSpoofResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupSpoofResponseSerie0 struct { - NotSpoof []string `json:"NOT_SPOOF,required"` - Spoof []string `json:"SPOOF,required"` - JSON radarEmailSecurityTimeseriesGroupSpoofResponseSerie0JSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupSpoofResponseSerie0JSON contains the JSON -// metadata for the struct [RadarEmailSecurityTimeseriesGroupSpoofResponseSerie0] -type radarEmailSecurityTimeseriesGroupSpoofResponseSerie0JSON struct { - NotSpoof apijson.Field - Spoof apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupSpoofResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupSpoofResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupThreatCategoryResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarEmailSecurityTimeseriesGroupThreatCategoryResponseSerie0 `json:"serie_0,required"` - JSON radarEmailSecurityTimeseriesGroupThreatCategoryResponseJSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupThreatCategoryResponseJSON contains the JSON -// metadata for the struct -// [RadarEmailSecurityTimeseriesGroupThreatCategoryResponse] -type radarEmailSecurityTimeseriesGroupThreatCategoryResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupThreatCategoryResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupThreatCategoryResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupThreatCategoryResponseSerie0 struct { - BrandImpersonation []string `json:"BrandImpersonation,required"` - CredentialHarvester []string `json:"CredentialHarvester,required"` - IdentityDeception []string `json:"IdentityDeception,required"` - Link []string `json:"Link,required"` - JSON radarEmailSecurityTimeseriesGroupThreatCategoryResponseSerie0JSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupThreatCategoryResponseSerie0JSON contains the -// JSON metadata for the struct -// [RadarEmailSecurityTimeseriesGroupThreatCategoryResponseSerie0] -type radarEmailSecurityTimeseriesGroupThreatCategoryResponseSerie0JSON struct { - BrandImpersonation apijson.Field - CredentialHarvester apijson.Field - IdentityDeception apijson.Field - Link apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupThreatCategoryResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupThreatCategoryResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupTLSVersionResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarEmailSecurityTimeseriesGroupTLSVersionResponseSerie0 `json:"serie_0,required"` - JSON radarEmailSecurityTimeseriesGroupTLSVersionResponseJSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupTLSVersionResponseJSON contains the JSON -// metadata for the struct [RadarEmailSecurityTimeseriesGroupTLSVersionResponse] -type radarEmailSecurityTimeseriesGroupTLSVersionResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupTLSVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupTLSVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupTLSVersionResponseSerie0 struct { - TLS1_0 []string `json:"TLS 1.0,required"` - TLS1_1 []string `json:"TLS 1.1,required"` - TLS1_2 []string `json:"TLS 1.2,required"` - TLS1_3 []string `json:"TLS 1.3,required"` - JSON radarEmailSecurityTimeseriesGroupTLSVersionResponseSerie0JSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupTLSVersionResponseSerie0JSON contains the JSON -// metadata for the struct -// [RadarEmailSecurityTimeseriesGroupTLSVersionResponseSerie0] -type radarEmailSecurityTimeseriesGroupTLSVersionResponseSerie0JSON struct { - TLS1_0 apijson.Field - TLS1_1 apijson.Field - TLS1_2 apijson.Field - TLS1_3 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupTLSVersionResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupTLSVersionResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupARCParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarEmailSecurityTimeseriesGroupARCParamsAggInterval] `query:"aggInterval"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecurityTimeseriesGroupARCParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecurityTimeseriesGroupARCParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecurityTimeseriesGroupARCParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecurityTimeseriesGroupARCParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecurityTimeseriesGroupARCParamsSPF] `query:"spf"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecurityTimeseriesGroupARCParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecurityTimeseriesGroupARCParams]'s query -// parameters as `url.Values`. -func (r RadarEmailSecurityTimeseriesGroupARCParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarEmailSecurityTimeseriesGroupARCParamsAggInterval string - -const ( - RadarEmailSecurityTimeseriesGroupARCParamsAggInterval15m RadarEmailSecurityTimeseriesGroupARCParamsAggInterval = "15m" - RadarEmailSecurityTimeseriesGroupARCParamsAggInterval1h RadarEmailSecurityTimeseriesGroupARCParamsAggInterval = "1h" - RadarEmailSecurityTimeseriesGroupARCParamsAggInterval1d RadarEmailSecurityTimeseriesGroupARCParamsAggInterval = "1d" - RadarEmailSecurityTimeseriesGroupARCParamsAggInterval1w RadarEmailSecurityTimeseriesGroupARCParamsAggInterval = "1w" -) - -type RadarEmailSecurityTimeseriesGroupARCParamsDateRange string - -const ( - RadarEmailSecurityTimeseriesGroupARCParamsDateRange1d RadarEmailSecurityTimeseriesGroupARCParamsDateRange = "1d" - RadarEmailSecurityTimeseriesGroupARCParamsDateRange2d RadarEmailSecurityTimeseriesGroupARCParamsDateRange = "2d" - RadarEmailSecurityTimeseriesGroupARCParamsDateRange7d RadarEmailSecurityTimeseriesGroupARCParamsDateRange = "7d" - RadarEmailSecurityTimeseriesGroupARCParamsDateRange14d RadarEmailSecurityTimeseriesGroupARCParamsDateRange = "14d" - RadarEmailSecurityTimeseriesGroupARCParamsDateRange28d RadarEmailSecurityTimeseriesGroupARCParamsDateRange = "28d" - RadarEmailSecurityTimeseriesGroupARCParamsDateRange12w RadarEmailSecurityTimeseriesGroupARCParamsDateRange = "12w" - RadarEmailSecurityTimeseriesGroupARCParamsDateRange24w RadarEmailSecurityTimeseriesGroupARCParamsDateRange = "24w" - RadarEmailSecurityTimeseriesGroupARCParamsDateRange52w RadarEmailSecurityTimeseriesGroupARCParamsDateRange = "52w" - RadarEmailSecurityTimeseriesGroupARCParamsDateRange1dControl RadarEmailSecurityTimeseriesGroupARCParamsDateRange = "1dControl" - RadarEmailSecurityTimeseriesGroupARCParamsDateRange2dControl RadarEmailSecurityTimeseriesGroupARCParamsDateRange = "2dControl" - RadarEmailSecurityTimeseriesGroupARCParamsDateRange7dControl RadarEmailSecurityTimeseriesGroupARCParamsDateRange = "7dControl" - RadarEmailSecurityTimeseriesGroupARCParamsDateRange14dControl RadarEmailSecurityTimeseriesGroupARCParamsDateRange = "14dControl" - RadarEmailSecurityTimeseriesGroupARCParamsDateRange28dControl RadarEmailSecurityTimeseriesGroupARCParamsDateRange = "28dControl" - RadarEmailSecurityTimeseriesGroupARCParamsDateRange12wControl RadarEmailSecurityTimeseriesGroupARCParamsDateRange = "12wControl" - RadarEmailSecurityTimeseriesGroupARCParamsDateRange24wControl RadarEmailSecurityTimeseriesGroupARCParamsDateRange = "24wControl" -) - -type RadarEmailSecurityTimeseriesGroupARCParamsDKIM string - -const ( - RadarEmailSecurityTimeseriesGroupARCParamsDKIMPass RadarEmailSecurityTimeseriesGroupARCParamsDKIM = "PASS" - RadarEmailSecurityTimeseriesGroupARCParamsDKIMNone RadarEmailSecurityTimeseriesGroupARCParamsDKIM = "NONE" - RadarEmailSecurityTimeseriesGroupARCParamsDKIMFail RadarEmailSecurityTimeseriesGroupARCParamsDKIM = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupARCParamsDMARC string - -const ( - RadarEmailSecurityTimeseriesGroupARCParamsDMARCPass RadarEmailSecurityTimeseriesGroupARCParamsDMARC = "PASS" - RadarEmailSecurityTimeseriesGroupARCParamsDMARCNone RadarEmailSecurityTimeseriesGroupARCParamsDMARC = "NONE" - RadarEmailSecurityTimeseriesGroupARCParamsDMARCFail RadarEmailSecurityTimeseriesGroupARCParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecurityTimeseriesGroupARCParamsFormat string - -const ( - RadarEmailSecurityTimeseriesGroupARCParamsFormatJson RadarEmailSecurityTimeseriesGroupARCParamsFormat = "JSON" - RadarEmailSecurityTimeseriesGroupARCParamsFormatCsv RadarEmailSecurityTimeseriesGroupARCParamsFormat = "CSV" -) - -type RadarEmailSecurityTimeseriesGroupARCParamsSPF string - -const ( - RadarEmailSecurityTimeseriesGroupARCParamsSPFPass RadarEmailSecurityTimeseriesGroupARCParamsSPF = "PASS" - RadarEmailSecurityTimeseriesGroupARCParamsSPFNone RadarEmailSecurityTimeseriesGroupARCParamsSPF = "NONE" - RadarEmailSecurityTimeseriesGroupARCParamsSPFFail RadarEmailSecurityTimeseriesGroupARCParamsSPF = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupARCParamsTLSVersion string - -const ( - RadarEmailSecurityTimeseriesGroupARCParamsTLSVersionTlSv1_0 RadarEmailSecurityTimeseriesGroupARCParamsTLSVersion = "TLSv1_0" - RadarEmailSecurityTimeseriesGroupARCParamsTLSVersionTlSv1_1 RadarEmailSecurityTimeseriesGroupARCParamsTLSVersion = "TLSv1_1" - RadarEmailSecurityTimeseriesGroupARCParamsTLSVersionTlSv1_2 RadarEmailSecurityTimeseriesGroupARCParamsTLSVersion = "TLSv1_2" - RadarEmailSecurityTimeseriesGroupARCParamsTLSVersionTlSv1_3 RadarEmailSecurityTimeseriesGroupARCParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecurityTimeseriesGroupARCResponseEnvelope struct { - Result RadarEmailSecurityTimeseriesGroupARCResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecurityTimeseriesGroupARCResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupARCResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarEmailSecurityTimeseriesGroupARCResponseEnvelope] -type radarEmailSecurityTimeseriesGroupARCResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupARCResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupARCResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupDKIMParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarEmailSecurityTimeseriesGroupDKIMParamsAggInterval] `query:"aggInterval"` - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecurityTimeseriesGroupDKIMParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecurityTimeseriesGroupDKIMParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecurityTimeseriesGroupDKIMParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecurityTimeseriesGroupDKIMParamsSPF] `query:"spf"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecurityTimeseriesGroupDKIMParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecurityTimeseriesGroupDKIMParams]'s query -// parameters as `url.Values`. -func (r RadarEmailSecurityTimeseriesGroupDKIMParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarEmailSecurityTimeseriesGroupDKIMParamsAggInterval string - -const ( - RadarEmailSecurityTimeseriesGroupDKIMParamsAggInterval15m RadarEmailSecurityTimeseriesGroupDKIMParamsAggInterval = "15m" - RadarEmailSecurityTimeseriesGroupDKIMParamsAggInterval1h RadarEmailSecurityTimeseriesGroupDKIMParamsAggInterval = "1h" - RadarEmailSecurityTimeseriesGroupDKIMParamsAggInterval1d RadarEmailSecurityTimeseriesGroupDKIMParamsAggInterval = "1d" - RadarEmailSecurityTimeseriesGroupDKIMParamsAggInterval1w RadarEmailSecurityTimeseriesGroupDKIMParamsAggInterval = "1w" -) - -type RadarEmailSecurityTimeseriesGroupDKIMParamsARC string - -const ( - RadarEmailSecurityTimeseriesGroupDKIMParamsARCPass RadarEmailSecurityTimeseriesGroupDKIMParamsARC = "PASS" - RadarEmailSecurityTimeseriesGroupDKIMParamsARCNone RadarEmailSecurityTimeseriesGroupDKIMParamsARC = "NONE" - RadarEmailSecurityTimeseriesGroupDKIMParamsARCFail RadarEmailSecurityTimeseriesGroupDKIMParamsARC = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange string - -const ( - RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange1d RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange = "1d" - RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange2d RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange = "2d" - RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange7d RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange = "7d" - RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange14d RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange = "14d" - RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange28d RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange = "28d" - RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange12w RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange = "12w" - RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange24w RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange = "24w" - RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange52w RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange = "52w" - RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange1dControl RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange = "1dControl" - RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange2dControl RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange = "2dControl" - RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange7dControl RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange = "7dControl" - RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange14dControl RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange = "14dControl" - RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange28dControl RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange = "28dControl" - RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange12wControl RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange = "12wControl" - RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange24wControl RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange = "24wControl" -) - -type RadarEmailSecurityTimeseriesGroupDKIMParamsDMARC string - -const ( - RadarEmailSecurityTimeseriesGroupDKIMParamsDMARCPass RadarEmailSecurityTimeseriesGroupDKIMParamsDMARC = "PASS" - RadarEmailSecurityTimeseriesGroupDKIMParamsDMARCNone RadarEmailSecurityTimeseriesGroupDKIMParamsDMARC = "NONE" - RadarEmailSecurityTimeseriesGroupDKIMParamsDMARCFail RadarEmailSecurityTimeseriesGroupDKIMParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecurityTimeseriesGroupDKIMParamsFormat string - -const ( - RadarEmailSecurityTimeseriesGroupDKIMParamsFormatJson RadarEmailSecurityTimeseriesGroupDKIMParamsFormat = "JSON" - RadarEmailSecurityTimeseriesGroupDKIMParamsFormatCsv RadarEmailSecurityTimeseriesGroupDKIMParamsFormat = "CSV" -) - -type RadarEmailSecurityTimeseriesGroupDKIMParamsSPF string - -const ( - RadarEmailSecurityTimeseriesGroupDKIMParamsSPFPass RadarEmailSecurityTimeseriesGroupDKIMParamsSPF = "PASS" - RadarEmailSecurityTimeseriesGroupDKIMParamsSPFNone RadarEmailSecurityTimeseriesGroupDKIMParamsSPF = "NONE" - RadarEmailSecurityTimeseriesGroupDKIMParamsSPFFail RadarEmailSecurityTimeseriesGroupDKIMParamsSPF = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupDKIMParamsTLSVersion string - -const ( - RadarEmailSecurityTimeseriesGroupDKIMParamsTLSVersionTlSv1_0 RadarEmailSecurityTimeseriesGroupDKIMParamsTLSVersion = "TLSv1_0" - RadarEmailSecurityTimeseriesGroupDKIMParamsTLSVersionTlSv1_1 RadarEmailSecurityTimeseriesGroupDKIMParamsTLSVersion = "TLSv1_1" - RadarEmailSecurityTimeseriesGroupDKIMParamsTLSVersionTlSv1_2 RadarEmailSecurityTimeseriesGroupDKIMParamsTLSVersion = "TLSv1_2" - RadarEmailSecurityTimeseriesGroupDKIMParamsTLSVersionTlSv1_3 RadarEmailSecurityTimeseriesGroupDKIMParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecurityTimeseriesGroupDKIMResponseEnvelope struct { - Result RadarEmailSecurityTimeseriesGroupDKIMResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecurityTimeseriesGroupDKIMResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupDKIMResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarEmailSecurityTimeseriesGroupDKIMResponseEnvelope] -type radarEmailSecurityTimeseriesGroupDKIMResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupDKIMResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupDKIMResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupDMARCParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarEmailSecurityTimeseriesGroupDMARCParamsAggInterval] `query:"aggInterval"` - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecurityTimeseriesGroupDMARCParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecurityTimeseriesGroupDMARCParamsDKIM] `query:"dkim"` - // Format results are returned in. - Format param.Field[RadarEmailSecurityTimeseriesGroupDMARCParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecurityTimeseriesGroupDMARCParamsSPF] `query:"spf"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecurityTimeseriesGroupDMARCParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecurityTimeseriesGroupDMARCParams]'s query -// parameters as `url.Values`. -func (r RadarEmailSecurityTimeseriesGroupDMARCParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarEmailSecurityTimeseriesGroupDMARCParamsAggInterval string - -const ( - RadarEmailSecurityTimeseriesGroupDMARCParamsAggInterval15m RadarEmailSecurityTimeseriesGroupDMARCParamsAggInterval = "15m" - RadarEmailSecurityTimeseriesGroupDMARCParamsAggInterval1h RadarEmailSecurityTimeseriesGroupDMARCParamsAggInterval = "1h" - RadarEmailSecurityTimeseriesGroupDMARCParamsAggInterval1d RadarEmailSecurityTimeseriesGroupDMARCParamsAggInterval = "1d" - RadarEmailSecurityTimeseriesGroupDMARCParamsAggInterval1w RadarEmailSecurityTimeseriesGroupDMARCParamsAggInterval = "1w" -) - -type RadarEmailSecurityTimeseriesGroupDMARCParamsARC string - -const ( - RadarEmailSecurityTimeseriesGroupDMARCParamsARCPass RadarEmailSecurityTimeseriesGroupDMARCParamsARC = "PASS" - RadarEmailSecurityTimeseriesGroupDMARCParamsARCNone RadarEmailSecurityTimeseriesGroupDMARCParamsARC = "NONE" - RadarEmailSecurityTimeseriesGroupDMARCParamsARCFail RadarEmailSecurityTimeseriesGroupDMARCParamsARC = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange string - -const ( - RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange1d RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange = "1d" - RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange2d RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange = "2d" - RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange7d RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange = "7d" - RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange14d RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange = "14d" - RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange28d RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange = "28d" - RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange12w RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange = "12w" - RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange24w RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange = "24w" - RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange52w RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange = "52w" - RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange1dControl RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange = "1dControl" - RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange2dControl RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange = "2dControl" - RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange7dControl RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange = "7dControl" - RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange14dControl RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange = "14dControl" - RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange28dControl RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange = "28dControl" - RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange12wControl RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange = "12wControl" - RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange24wControl RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange = "24wControl" -) - -type RadarEmailSecurityTimeseriesGroupDMARCParamsDKIM string - -const ( - RadarEmailSecurityTimeseriesGroupDMARCParamsDKIMPass RadarEmailSecurityTimeseriesGroupDMARCParamsDKIM = "PASS" - RadarEmailSecurityTimeseriesGroupDMARCParamsDKIMNone RadarEmailSecurityTimeseriesGroupDMARCParamsDKIM = "NONE" - RadarEmailSecurityTimeseriesGroupDMARCParamsDKIMFail RadarEmailSecurityTimeseriesGroupDMARCParamsDKIM = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecurityTimeseriesGroupDMARCParamsFormat string - -const ( - RadarEmailSecurityTimeseriesGroupDMARCParamsFormatJson RadarEmailSecurityTimeseriesGroupDMARCParamsFormat = "JSON" - RadarEmailSecurityTimeseriesGroupDMARCParamsFormatCsv RadarEmailSecurityTimeseriesGroupDMARCParamsFormat = "CSV" -) - -type RadarEmailSecurityTimeseriesGroupDMARCParamsSPF string - -const ( - RadarEmailSecurityTimeseriesGroupDMARCParamsSPFPass RadarEmailSecurityTimeseriesGroupDMARCParamsSPF = "PASS" - RadarEmailSecurityTimeseriesGroupDMARCParamsSPFNone RadarEmailSecurityTimeseriesGroupDMARCParamsSPF = "NONE" - RadarEmailSecurityTimeseriesGroupDMARCParamsSPFFail RadarEmailSecurityTimeseriesGroupDMARCParamsSPF = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupDMARCParamsTLSVersion string - -const ( - RadarEmailSecurityTimeseriesGroupDMARCParamsTLSVersionTlSv1_0 RadarEmailSecurityTimeseriesGroupDMARCParamsTLSVersion = "TLSv1_0" - RadarEmailSecurityTimeseriesGroupDMARCParamsTLSVersionTlSv1_1 RadarEmailSecurityTimeseriesGroupDMARCParamsTLSVersion = "TLSv1_1" - RadarEmailSecurityTimeseriesGroupDMARCParamsTLSVersionTlSv1_2 RadarEmailSecurityTimeseriesGroupDMARCParamsTLSVersion = "TLSv1_2" - RadarEmailSecurityTimeseriesGroupDMARCParamsTLSVersionTlSv1_3 RadarEmailSecurityTimeseriesGroupDMARCParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecurityTimeseriesGroupDMARCResponseEnvelope struct { - Result RadarEmailSecurityTimeseriesGroupDMARCResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecurityTimeseriesGroupDMARCResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupDMARCResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarEmailSecurityTimeseriesGroupDMARCResponseEnvelope] -type radarEmailSecurityTimeseriesGroupDMARCResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupDMARCResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupDMARCResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupMaliciousParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarEmailSecurityTimeseriesGroupMaliciousParamsAggInterval] `query:"aggInterval"` - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecurityTimeseriesGroupMaliciousParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecurityTimeseriesGroupMaliciousParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecurityTimeseriesGroupMaliciousParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecurityTimeseriesGroupMaliciousParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecurityTimeseriesGroupMaliciousParamsSPF] `query:"spf"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecurityTimeseriesGroupMaliciousParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecurityTimeseriesGroupMaliciousParams]'s query -// parameters as `url.Values`. -func (r RadarEmailSecurityTimeseriesGroupMaliciousParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarEmailSecurityTimeseriesGroupMaliciousParamsAggInterval string - -const ( - RadarEmailSecurityTimeseriesGroupMaliciousParamsAggInterval15m RadarEmailSecurityTimeseriesGroupMaliciousParamsAggInterval = "15m" - RadarEmailSecurityTimeseriesGroupMaliciousParamsAggInterval1h RadarEmailSecurityTimeseriesGroupMaliciousParamsAggInterval = "1h" - RadarEmailSecurityTimeseriesGroupMaliciousParamsAggInterval1d RadarEmailSecurityTimeseriesGroupMaliciousParamsAggInterval = "1d" - RadarEmailSecurityTimeseriesGroupMaliciousParamsAggInterval1w RadarEmailSecurityTimeseriesGroupMaliciousParamsAggInterval = "1w" -) - -type RadarEmailSecurityTimeseriesGroupMaliciousParamsARC string - -const ( - RadarEmailSecurityTimeseriesGroupMaliciousParamsARCPass RadarEmailSecurityTimeseriesGroupMaliciousParamsARC = "PASS" - RadarEmailSecurityTimeseriesGroupMaliciousParamsARCNone RadarEmailSecurityTimeseriesGroupMaliciousParamsARC = "NONE" - RadarEmailSecurityTimeseriesGroupMaliciousParamsARCFail RadarEmailSecurityTimeseriesGroupMaliciousParamsARC = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange string - -const ( - RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange1d RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange = "1d" - RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange2d RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange = "2d" - RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange7d RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange = "7d" - RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange14d RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange = "14d" - RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange28d RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange = "28d" - RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange12w RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange = "12w" - RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange24w RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange = "24w" - RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange52w RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange = "52w" - RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange1dControl RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange = "1dControl" - RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange2dControl RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange = "2dControl" - RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange7dControl RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange = "7dControl" - RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange14dControl RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange = "14dControl" - RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange28dControl RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange = "28dControl" - RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange12wControl RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange = "12wControl" - RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange24wControl RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange = "24wControl" -) - -type RadarEmailSecurityTimeseriesGroupMaliciousParamsDKIM string - -const ( - RadarEmailSecurityTimeseriesGroupMaliciousParamsDKIMPass RadarEmailSecurityTimeseriesGroupMaliciousParamsDKIM = "PASS" - RadarEmailSecurityTimeseriesGroupMaliciousParamsDKIMNone RadarEmailSecurityTimeseriesGroupMaliciousParamsDKIM = "NONE" - RadarEmailSecurityTimeseriesGroupMaliciousParamsDKIMFail RadarEmailSecurityTimeseriesGroupMaliciousParamsDKIM = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupMaliciousParamsDMARC string - -const ( - RadarEmailSecurityTimeseriesGroupMaliciousParamsDMARCPass RadarEmailSecurityTimeseriesGroupMaliciousParamsDMARC = "PASS" - RadarEmailSecurityTimeseriesGroupMaliciousParamsDMARCNone RadarEmailSecurityTimeseriesGroupMaliciousParamsDMARC = "NONE" - RadarEmailSecurityTimeseriesGroupMaliciousParamsDMARCFail RadarEmailSecurityTimeseriesGroupMaliciousParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecurityTimeseriesGroupMaliciousParamsFormat string - -const ( - RadarEmailSecurityTimeseriesGroupMaliciousParamsFormatJson RadarEmailSecurityTimeseriesGroupMaliciousParamsFormat = "JSON" - RadarEmailSecurityTimeseriesGroupMaliciousParamsFormatCsv RadarEmailSecurityTimeseriesGroupMaliciousParamsFormat = "CSV" -) - -type RadarEmailSecurityTimeseriesGroupMaliciousParamsSPF string - -const ( - RadarEmailSecurityTimeseriesGroupMaliciousParamsSPFPass RadarEmailSecurityTimeseriesGroupMaliciousParamsSPF = "PASS" - RadarEmailSecurityTimeseriesGroupMaliciousParamsSPFNone RadarEmailSecurityTimeseriesGroupMaliciousParamsSPF = "NONE" - RadarEmailSecurityTimeseriesGroupMaliciousParamsSPFFail RadarEmailSecurityTimeseriesGroupMaliciousParamsSPF = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupMaliciousParamsTLSVersion string - -const ( - RadarEmailSecurityTimeseriesGroupMaliciousParamsTLSVersionTlSv1_0 RadarEmailSecurityTimeseriesGroupMaliciousParamsTLSVersion = "TLSv1_0" - RadarEmailSecurityTimeseriesGroupMaliciousParamsTLSVersionTlSv1_1 RadarEmailSecurityTimeseriesGroupMaliciousParamsTLSVersion = "TLSv1_1" - RadarEmailSecurityTimeseriesGroupMaliciousParamsTLSVersionTlSv1_2 RadarEmailSecurityTimeseriesGroupMaliciousParamsTLSVersion = "TLSv1_2" - RadarEmailSecurityTimeseriesGroupMaliciousParamsTLSVersionTlSv1_3 RadarEmailSecurityTimeseriesGroupMaliciousParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecurityTimeseriesGroupMaliciousResponseEnvelope struct { - Result RadarEmailSecurityTimeseriesGroupMaliciousResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecurityTimeseriesGroupMaliciousResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupMaliciousResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [RadarEmailSecurityTimeseriesGroupMaliciousResponseEnvelope] -type radarEmailSecurityTimeseriesGroupMaliciousResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupMaliciousResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupMaliciousResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupSpamParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarEmailSecurityTimeseriesGroupSpamParamsAggInterval] `query:"aggInterval"` - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecurityTimeseriesGroupSpamParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecurityTimeseriesGroupSpamParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecurityTimeseriesGroupSpamParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecurityTimeseriesGroupSpamParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecurityTimeseriesGroupSpamParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecurityTimeseriesGroupSpamParamsSPF] `query:"spf"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecurityTimeseriesGroupSpamParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecurityTimeseriesGroupSpamParams]'s query -// parameters as `url.Values`. -func (r RadarEmailSecurityTimeseriesGroupSpamParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarEmailSecurityTimeseriesGroupSpamParamsAggInterval string - -const ( - RadarEmailSecurityTimeseriesGroupSpamParamsAggInterval15m RadarEmailSecurityTimeseriesGroupSpamParamsAggInterval = "15m" - RadarEmailSecurityTimeseriesGroupSpamParamsAggInterval1h RadarEmailSecurityTimeseriesGroupSpamParamsAggInterval = "1h" - RadarEmailSecurityTimeseriesGroupSpamParamsAggInterval1d RadarEmailSecurityTimeseriesGroupSpamParamsAggInterval = "1d" - RadarEmailSecurityTimeseriesGroupSpamParamsAggInterval1w RadarEmailSecurityTimeseriesGroupSpamParamsAggInterval = "1w" -) - -type RadarEmailSecurityTimeseriesGroupSpamParamsARC string - -const ( - RadarEmailSecurityTimeseriesGroupSpamParamsARCPass RadarEmailSecurityTimeseriesGroupSpamParamsARC = "PASS" - RadarEmailSecurityTimeseriesGroupSpamParamsARCNone RadarEmailSecurityTimeseriesGroupSpamParamsARC = "NONE" - RadarEmailSecurityTimeseriesGroupSpamParamsARCFail RadarEmailSecurityTimeseriesGroupSpamParamsARC = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupSpamParamsDateRange string - -const ( - RadarEmailSecurityTimeseriesGroupSpamParamsDateRange1d RadarEmailSecurityTimeseriesGroupSpamParamsDateRange = "1d" - RadarEmailSecurityTimeseriesGroupSpamParamsDateRange2d RadarEmailSecurityTimeseriesGroupSpamParamsDateRange = "2d" - RadarEmailSecurityTimeseriesGroupSpamParamsDateRange7d RadarEmailSecurityTimeseriesGroupSpamParamsDateRange = "7d" - RadarEmailSecurityTimeseriesGroupSpamParamsDateRange14d RadarEmailSecurityTimeseriesGroupSpamParamsDateRange = "14d" - RadarEmailSecurityTimeseriesGroupSpamParamsDateRange28d RadarEmailSecurityTimeseriesGroupSpamParamsDateRange = "28d" - RadarEmailSecurityTimeseriesGroupSpamParamsDateRange12w RadarEmailSecurityTimeseriesGroupSpamParamsDateRange = "12w" - RadarEmailSecurityTimeseriesGroupSpamParamsDateRange24w RadarEmailSecurityTimeseriesGroupSpamParamsDateRange = "24w" - RadarEmailSecurityTimeseriesGroupSpamParamsDateRange52w RadarEmailSecurityTimeseriesGroupSpamParamsDateRange = "52w" - RadarEmailSecurityTimeseriesGroupSpamParamsDateRange1dControl RadarEmailSecurityTimeseriesGroupSpamParamsDateRange = "1dControl" - RadarEmailSecurityTimeseriesGroupSpamParamsDateRange2dControl RadarEmailSecurityTimeseriesGroupSpamParamsDateRange = "2dControl" - RadarEmailSecurityTimeseriesGroupSpamParamsDateRange7dControl RadarEmailSecurityTimeseriesGroupSpamParamsDateRange = "7dControl" - RadarEmailSecurityTimeseriesGroupSpamParamsDateRange14dControl RadarEmailSecurityTimeseriesGroupSpamParamsDateRange = "14dControl" - RadarEmailSecurityTimeseriesGroupSpamParamsDateRange28dControl RadarEmailSecurityTimeseriesGroupSpamParamsDateRange = "28dControl" - RadarEmailSecurityTimeseriesGroupSpamParamsDateRange12wControl RadarEmailSecurityTimeseriesGroupSpamParamsDateRange = "12wControl" - RadarEmailSecurityTimeseriesGroupSpamParamsDateRange24wControl RadarEmailSecurityTimeseriesGroupSpamParamsDateRange = "24wControl" -) - -type RadarEmailSecurityTimeseriesGroupSpamParamsDKIM string - -const ( - RadarEmailSecurityTimeseriesGroupSpamParamsDKIMPass RadarEmailSecurityTimeseriesGroupSpamParamsDKIM = "PASS" - RadarEmailSecurityTimeseriesGroupSpamParamsDKIMNone RadarEmailSecurityTimeseriesGroupSpamParamsDKIM = "NONE" - RadarEmailSecurityTimeseriesGroupSpamParamsDKIMFail RadarEmailSecurityTimeseriesGroupSpamParamsDKIM = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupSpamParamsDMARC string - -const ( - RadarEmailSecurityTimeseriesGroupSpamParamsDMARCPass RadarEmailSecurityTimeseriesGroupSpamParamsDMARC = "PASS" - RadarEmailSecurityTimeseriesGroupSpamParamsDMARCNone RadarEmailSecurityTimeseriesGroupSpamParamsDMARC = "NONE" - RadarEmailSecurityTimeseriesGroupSpamParamsDMARCFail RadarEmailSecurityTimeseriesGroupSpamParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecurityTimeseriesGroupSpamParamsFormat string - -const ( - RadarEmailSecurityTimeseriesGroupSpamParamsFormatJson RadarEmailSecurityTimeseriesGroupSpamParamsFormat = "JSON" - RadarEmailSecurityTimeseriesGroupSpamParamsFormatCsv RadarEmailSecurityTimeseriesGroupSpamParamsFormat = "CSV" -) - -type RadarEmailSecurityTimeseriesGroupSpamParamsSPF string - -const ( - RadarEmailSecurityTimeseriesGroupSpamParamsSPFPass RadarEmailSecurityTimeseriesGroupSpamParamsSPF = "PASS" - RadarEmailSecurityTimeseriesGroupSpamParamsSPFNone RadarEmailSecurityTimeseriesGroupSpamParamsSPF = "NONE" - RadarEmailSecurityTimeseriesGroupSpamParamsSPFFail RadarEmailSecurityTimeseriesGroupSpamParamsSPF = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupSpamParamsTLSVersion string - -const ( - RadarEmailSecurityTimeseriesGroupSpamParamsTLSVersionTlSv1_0 RadarEmailSecurityTimeseriesGroupSpamParamsTLSVersion = "TLSv1_0" - RadarEmailSecurityTimeseriesGroupSpamParamsTLSVersionTlSv1_1 RadarEmailSecurityTimeseriesGroupSpamParamsTLSVersion = "TLSv1_1" - RadarEmailSecurityTimeseriesGroupSpamParamsTLSVersionTlSv1_2 RadarEmailSecurityTimeseriesGroupSpamParamsTLSVersion = "TLSv1_2" - RadarEmailSecurityTimeseriesGroupSpamParamsTLSVersionTlSv1_3 RadarEmailSecurityTimeseriesGroupSpamParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecurityTimeseriesGroupSpamResponseEnvelope struct { - Result RadarEmailSecurityTimeseriesGroupSpamResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecurityTimeseriesGroupSpamResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupSpamResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarEmailSecurityTimeseriesGroupSpamResponseEnvelope] -type radarEmailSecurityTimeseriesGroupSpamResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupSpamResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupSpamResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupSPFParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarEmailSecurityTimeseriesGroupSPFParamsAggInterval] `query:"aggInterval"` - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecurityTimeseriesGroupSPFParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecurityTimeseriesGroupSPFParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecurityTimeseriesGroupSPFParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecurityTimeseriesGroupSPFParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecurityTimeseriesGroupSPFParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecurityTimeseriesGroupSPFParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecurityTimeseriesGroupSPFParams]'s query -// parameters as `url.Values`. -func (r RadarEmailSecurityTimeseriesGroupSPFParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarEmailSecurityTimeseriesGroupSPFParamsAggInterval string - -const ( - RadarEmailSecurityTimeseriesGroupSPFParamsAggInterval15m RadarEmailSecurityTimeseriesGroupSPFParamsAggInterval = "15m" - RadarEmailSecurityTimeseriesGroupSPFParamsAggInterval1h RadarEmailSecurityTimeseriesGroupSPFParamsAggInterval = "1h" - RadarEmailSecurityTimeseriesGroupSPFParamsAggInterval1d RadarEmailSecurityTimeseriesGroupSPFParamsAggInterval = "1d" - RadarEmailSecurityTimeseriesGroupSPFParamsAggInterval1w RadarEmailSecurityTimeseriesGroupSPFParamsAggInterval = "1w" -) - -type RadarEmailSecurityTimeseriesGroupSPFParamsARC string - -const ( - RadarEmailSecurityTimeseriesGroupSPFParamsARCPass RadarEmailSecurityTimeseriesGroupSPFParamsARC = "PASS" - RadarEmailSecurityTimeseriesGroupSPFParamsARCNone RadarEmailSecurityTimeseriesGroupSPFParamsARC = "NONE" - RadarEmailSecurityTimeseriesGroupSPFParamsARCFail RadarEmailSecurityTimeseriesGroupSPFParamsARC = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupSPFParamsDateRange string - -const ( - RadarEmailSecurityTimeseriesGroupSPFParamsDateRange1d RadarEmailSecurityTimeseriesGroupSPFParamsDateRange = "1d" - RadarEmailSecurityTimeseriesGroupSPFParamsDateRange2d RadarEmailSecurityTimeseriesGroupSPFParamsDateRange = "2d" - RadarEmailSecurityTimeseriesGroupSPFParamsDateRange7d RadarEmailSecurityTimeseriesGroupSPFParamsDateRange = "7d" - RadarEmailSecurityTimeseriesGroupSPFParamsDateRange14d RadarEmailSecurityTimeseriesGroupSPFParamsDateRange = "14d" - RadarEmailSecurityTimeseriesGroupSPFParamsDateRange28d RadarEmailSecurityTimeseriesGroupSPFParamsDateRange = "28d" - RadarEmailSecurityTimeseriesGroupSPFParamsDateRange12w RadarEmailSecurityTimeseriesGroupSPFParamsDateRange = "12w" - RadarEmailSecurityTimeseriesGroupSPFParamsDateRange24w RadarEmailSecurityTimeseriesGroupSPFParamsDateRange = "24w" - RadarEmailSecurityTimeseriesGroupSPFParamsDateRange52w RadarEmailSecurityTimeseriesGroupSPFParamsDateRange = "52w" - RadarEmailSecurityTimeseriesGroupSPFParamsDateRange1dControl RadarEmailSecurityTimeseriesGroupSPFParamsDateRange = "1dControl" - RadarEmailSecurityTimeseriesGroupSPFParamsDateRange2dControl RadarEmailSecurityTimeseriesGroupSPFParamsDateRange = "2dControl" - RadarEmailSecurityTimeseriesGroupSPFParamsDateRange7dControl RadarEmailSecurityTimeseriesGroupSPFParamsDateRange = "7dControl" - RadarEmailSecurityTimeseriesGroupSPFParamsDateRange14dControl RadarEmailSecurityTimeseriesGroupSPFParamsDateRange = "14dControl" - RadarEmailSecurityTimeseriesGroupSPFParamsDateRange28dControl RadarEmailSecurityTimeseriesGroupSPFParamsDateRange = "28dControl" - RadarEmailSecurityTimeseriesGroupSPFParamsDateRange12wControl RadarEmailSecurityTimeseriesGroupSPFParamsDateRange = "12wControl" - RadarEmailSecurityTimeseriesGroupSPFParamsDateRange24wControl RadarEmailSecurityTimeseriesGroupSPFParamsDateRange = "24wControl" -) - -type RadarEmailSecurityTimeseriesGroupSPFParamsDKIM string - -const ( - RadarEmailSecurityTimeseriesGroupSPFParamsDKIMPass RadarEmailSecurityTimeseriesGroupSPFParamsDKIM = "PASS" - RadarEmailSecurityTimeseriesGroupSPFParamsDKIMNone RadarEmailSecurityTimeseriesGroupSPFParamsDKIM = "NONE" - RadarEmailSecurityTimeseriesGroupSPFParamsDKIMFail RadarEmailSecurityTimeseriesGroupSPFParamsDKIM = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupSPFParamsDMARC string - -const ( - RadarEmailSecurityTimeseriesGroupSPFParamsDMARCPass RadarEmailSecurityTimeseriesGroupSPFParamsDMARC = "PASS" - RadarEmailSecurityTimeseriesGroupSPFParamsDMARCNone RadarEmailSecurityTimeseriesGroupSPFParamsDMARC = "NONE" - RadarEmailSecurityTimeseriesGroupSPFParamsDMARCFail RadarEmailSecurityTimeseriesGroupSPFParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecurityTimeseriesGroupSPFParamsFormat string - -const ( - RadarEmailSecurityTimeseriesGroupSPFParamsFormatJson RadarEmailSecurityTimeseriesGroupSPFParamsFormat = "JSON" - RadarEmailSecurityTimeseriesGroupSPFParamsFormatCsv RadarEmailSecurityTimeseriesGroupSPFParamsFormat = "CSV" -) - -type RadarEmailSecurityTimeseriesGroupSPFParamsTLSVersion string - -const ( - RadarEmailSecurityTimeseriesGroupSPFParamsTLSVersionTlSv1_0 RadarEmailSecurityTimeseriesGroupSPFParamsTLSVersion = "TLSv1_0" - RadarEmailSecurityTimeseriesGroupSPFParamsTLSVersionTlSv1_1 RadarEmailSecurityTimeseriesGroupSPFParamsTLSVersion = "TLSv1_1" - RadarEmailSecurityTimeseriesGroupSPFParamsTLSVersionTlSv1_2 RadarEmailSecurityTimeseriesGroupSPFParamsTLSVersion = "TLSv1_2" - RadarEmailSecurityTimeseriesGroupSPFParamsTLSVersionTlSv1_3 RadarEmailSecurityTimeseriesGroupSPFParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecurityTimeseriesGroupSPFResponseEnvelope struct { - Result RadarEmailSecurityTimeseriesGroupSPFResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecurityTimeseriesGroupSPFResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupSPFResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarEmailSecurityTimeseriesGroupSPFResponseEnvelope] -type radarEmailSecurityTimeseriesGroupSPFResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupSPFResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupSPFResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupSpoofParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarEmailSecurityTimeseriesGroupSpoofParamsAggInterval] `query:"aggInterval"` - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecurityTimeseriesGroupSpoofParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecurityTimeseriesGroupSpoofParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecurityTimeseriesGroupSpoofParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecurityTimeseriesGroupSpoofParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecurityTimeseriesGroupSpoofParamsSPF] `query:"spf"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecurityTimeseriesGroupSpoofParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecurityTimeseriesGroupSpoofParams]'s query -// parameters as `url.Values`. -func (r RadarEmailSecurityTimeseriesGroupSpoofParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarEmailSecurityTimeseriesGroupSpoofParamsAggInterval string - -const ( - RadarEmailSecurityTimeseriesGroupSpoofParamsAggInterval15m RadarEmailSecurityTimeseriesGroupSpoofParamsAggInterval = "15m" - RadarEmailSecurityTimeseriesGroupSpoofParamsAggInterval1h RadarEmailSecurityTimeseriesGroupSpoofParamsAggInterval = "1h" - RadarEmailSecurityTimeseriesGroupSpoofParamsAggInterval1d RadarEmailSecurityTimeseriesGroupSpoofParamsAggInterval = "1d" - RadarEmailSecurityTimeseriesGroupSpoofParamsAggInterval1w RadarEmailSecurityTimeseriesGroupSpoofParamsAggInterval = "1w" -) - -type RadarEmailSecurityTimeseriesGroupSpoofParamsARC string - -const ( - RadarEmailSecurityTimeseriesGroupSpoofParamsARCPass RadarEmailSecurityTimeseriesGroupSpoofParamsARC = "PASS" - RadarEmailSecurityTimeseriesGroupSpoofParamsARCNone RadarEmailSecurityTimeseriesGroupSpoofParamsARC = "NONE" - RadarEmailSecurityTimeseriesGroupSpoofParamsARCFail RadarEmailSecurityTimeseriesGroupSpoofParamsARC = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange string - -const ( - RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange1d RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange = "1d" - RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange2d RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange = "2d" - RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange7d RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange = "7d" - RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange14d RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange = "14d" - RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange28d RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange = "28d" - RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange12w RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange = "12w" - RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange24w RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange = "24w" - RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange52w RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange = "52w" - RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange1dControl RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange = "1dControl" - RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange2dControl RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange = "2dControl" - RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange7dControl RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange = "7dControl" - RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange14dControl RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange = "14dControl" - RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange28dControl RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange = "28dControl" - RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange12wControl RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange = "12wControl" - RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange24wControl RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange = "24wControl" -) - -type RadarEmailSecurityTimeseriesGroupSpoofParamsDKIM string - -const ( - RadarEmailSecurityTimeseriesGroupSpoofParamsDKIMPass RadarEmailSecurityTimeseriesGroupSpoofParamsDKIM = "PASS" - RadarEmailSecurityTimeseriesGroupSpoofParamsDKIMNone RadarEmailSecurityTimeseriesGroupSpoofParamsDKIM = "NONE" - RadarEmailSecurityTimeseriesGroupSpoofParamsDKIMFail RadarEmailSecurityTimeseriesGroupSpoofParamsDKIM = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupSpoofParamsDMARC string - -const ( - RadarEmailSecurityTimeseriesGroupSpoofParamsDMARCPass RadarEmailSecurityTimeseriesGroupSpoofParamsDMARC = "PASS" - RadarEmailSecurityTimeseriesGroupSpoofParamsDMARCNone RadarEmailSecurityTimeseriesGroupSpoofParamsDMARC = "NONE" - RadarEmailSecurityTimeseriesGroupSpoofParamsDMARCFail RadarEmailSecurityTimeseriesGroupSpoofParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecurityTimeseriesGroupSpoofParamsFormat string - -const ( - RadarEmailSecurityTimeseriesGroupSpoofParamsFormatJson RadarEmailSecurityTimeseriesGroupSpoofParamsFormat = "JSON" - RadarEmailSecurityTimeseriesGroupSpoofParamsFormatCsv RadarEmailSecurityTimeseriesGroupSpoofParamsFormat = "CSV" -) - -type RadarEmailSecurityTimeseriesGroupSpoofParamsSPF string - -const ( - RadarEmailSecurityTimeseriesGroupSpoofParamsSPFPass RadarEmailSecurityTimeseriesGroupSpoofParamsSPF = "PASS" - RadarEmailSecurityTimeseriesGroupSpoofParamsSPFNone RadarEmailSecurityTimeseriesGroupSpoofParamsSPF = "NONE" - RadarEmailSecurityTimeseriesGroupSpoofParamsSPFFail RadarEmailSecurityTimeseriesGroupSpoofParamsSPF = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupSpoofParamsTLSVersion string - -const ( - RadarEmailSecurityTimeseriesGroupSpoofParamsTLSVersionTlSv1_0 RadarEmailSecurityTimeseriesGroupSpoofParamsTLSVersion = "TLSv1_0" - RadarEmailSecurityTimeseriesGroupSpoofParamsTLSVersionTlSv1_1 RadarEmailSecurityTimeseriesGroupSpoofParamsTLSVersion = "TLSv1_1" - RadarEmailSecurityTimeseriesGroupSpoofParamsTLSVersionTlSv1_2 RadarEmailSecurityTimeseriesGroupSpoofParamsTLSVersion = "TLSv1_2" - RadarEmailSecurityTimeseriesGroupSpoofParamsTLSVersionTlSv1_3 RadarEmailSecurityTimeseriesGroupSpoofParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecurityTimeseriesGroupSpoofResponseEnvelope struct { - Result RadarEmailSecurityTimeseriesGroupSpoofResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecurityTimeseriesGroupSpoofResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupSpoofResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarEmailSecurityTimeseriesGroupSpoofResponseEnvelope] -type radarEmailSecurityTimeseriesGroupSpoofResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupSpoofResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupSpoofResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupThreatCategoryParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarEmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval] `query:"aggInterval"` - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecurityTimeseriesGroupThreatCategoryParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecurityTimeseriesGroupThreatCategoryParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecurityTimeseriesGroupThreatCategoryParamsSPF] `query:"spf"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecurityTimeseriesGroupThreatCategoryParams]'s -// query parameters as `url.Values`. -func (r RadarEmailSecurityTimeseriesGroupThreatCategoryParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarEmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval string - -const ( - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval15m RadarEmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval = "15m" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval1h RadarEmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval = "1h" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval1d RadarEmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval = "1d" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval1w RadarEmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval = "1w" -) - -type RadarEmailSecurityTimeseriesGroupThreatCategoryParamsARC string - -const ( - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsARCPass RadarEmailSecurityTimeseriesGroupThreatCategoryParamsARC = "PASS" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsARCNone RadarEmailSecurityTimeseriesGroupThreatCategoryParamsARC = "NONE" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsARCFail RadarEmailSecurityTimeseriesGroupThreatCategoryParamsARC = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange string - -const ( - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange1d RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "1d" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange2d RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "2d" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange7d RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "7d" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange14d RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "14d" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange28d RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "28d" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange12w RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "12w" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange24w RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "24w" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange52w RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "52w" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange1dControl RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "1dControl" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange2dControl RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "2dControl" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange7dControl RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "7dControl" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange14dControl RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "14dControl" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange28dControl RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "28dControl" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange12wControl RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "12wControl" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange24wControl RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange = "24wControl" -) - -type RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDKIM string - -const ( - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDKIMPass RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDKIM = "PASS" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDKIMNone RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDKIM = "NONE" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDKIMFail RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDKIM = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDMARC string - -const ( - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDMARCPass RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDMARC = "PASS" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDMARCNone RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDMARC = "NONE" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDMARCFail RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecurityTimeseriesGroupThreatCategoryParamsFormat string - -const ( - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsFormatJson RadarEmailSecurityTimeseriesGroupThreatCategoryParamsFormat = "JSON" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsFormatCsv RadarEmailSecurityTimeseriesGroupThreatCategoryParamsFormat = "CSV" -) - -type RadarEmailSecurityTimeseriesGroupThreatCategoryParamsSPF string - -const ( - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsSPFPass RadarEmailSecurityTimeseriesGroupThreatCategoryParamsSPF = "PASS" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsSPFNone RadarEmailSecurityTimeseriesGroupThreatCategoryParamsSPF = "NONE" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsSPFFail RadarEmailSecurityTimeseriesGroupThreatCategoryParamsSPF = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersion string - -const ( - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersionTlSv1_0 RadarEmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersion = "TLSv1_0" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersionTlSv1_1 RadarEmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersion = "TLSv1_1" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersionTlSv1_2 RadarEmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersion = "TLSv1_2" - RadarEmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersionTlSv1_3 RadarEmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecurityTimeseriesGroupThreatCategoryResponseEnvelope struct { - Result RadarEmailSecurityTimeseriesGroupThreatCategoryResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecurityTimeseriesGroupThreatCategoryResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupThreatCategoryResponseEnvelopeJSON contains the -// JSON metadata for the struct -// [RadarEmailSecurityTimeseriesGroupThreatCategoryResponseEnvelope] -type radarEmailSecurityTimeseriesGroupThreatCategoryResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupThreatCategoryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupThreatCategoryResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTimeseriesGroupTLSVersionParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarEmailSecurityTimeseriesGroupTLSVersionParamsAggInterval] `query:"aggInterval"` - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecurityTimeseriesGroupTLSVersionParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecurityTimeseriesGroupTLSVersionParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecurityTimeseriesGroupTLSVersionParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecurityTimeseriesGroupTLSVersionParamsFormat] `query:"format"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecurityTimeseriesGroupTLSVersionParamsSPF] `query:"spf"` -} - -// URLQuery serializes [RadarEmailSecurityTimeseriesGroupTLSVersionParams]'s query -// parameters as `url.Values`. -func (r RadarEmailSecurityTimeseriesGroupTLSVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarEmailSecurityTimeseriesGroupTLSVersionParamsAggInterval string - -const ( - RadarEmailSecurityTimeseriesGroupTLSVersionParamsAggInterval15m RadarEmailSecurityTimeseriesGroupTLSVersionParamsAggInterval = "15m" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsAggInterval1h RadarEmailSecurityTimeseriesGroupTLSVersionParamsAggInterval = "1h" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsAggInterval1d RadarEmailSecurityTimeseriesGroupTLSVersionParamsAggInterval = "1d" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsAggInterval1w RadarEmailSecurityTimeseriesGroupTLSVersionParamsAggInterval = "1w" -) - -type RadarEmailSecurityTimeseriesGroupTLSVersionParamsARC string - -const ( - RadarEmailSecurityTimeseriesGroupTLSVersionParamsARCPass RadarEmailSecurityTimeseriesGroupTLSVersionParamsARC = "PASS" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsARCNone RadarEmailSecurityTimeseriesGroupTLSVersionParamsARC = "NONE" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsARCFail RadarEmailSecurityTimeseriesGroupTLSVersionParamsARC = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange string - -const ( - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange1d RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "1d" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange2d RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "2d" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange7d RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "7d" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange14d RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "14d" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange28d RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "28d" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange12w RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "12w" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange24w RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "24w" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange52w RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "52w" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange1dControl RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "1dControl" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange2dControl RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "2dControl" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange7dControl RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "7dControl" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange14dControl RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "14dControl" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange28dControl RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "28dControl" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange12wControl RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "12wControl" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange24wControl RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange = "24wControl" -) - -type RadarEmailSecurityTimeseriesGroupTLSVersionParamsDKIM string - -const ( - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDKIMPass RadarEmailSecurityTimeseriesGroupTLSVersionParamsDKIM = "PASS" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDKIMNone RadarEmailSecurityTimeseriesGroupTLSVersionParamsDKIM = "NONE" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDKIMFail RadarEmailSecurityTimeseriesGroupTLSVersionParamsDKIM = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupTLSVersionParamsDMARC string - -const ( - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDMARCPass RadarEmailSecurityTimeseriesGroupTLSVersionParamsDMARC = "PASS" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDMARCNone RadarEmailSecurityTimeseriesGroupTLSVersionParamsDMARC = "NONE" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsDMARCFail RadarEmailSecurityTimeseriesGroupTLSVersionParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecurityTimeseriesGroupTLSVersionParamsFormat string - -const ( - RadarEmailSecurityTimeseriesGroupTLSVersionParamsFormatJson RadarEmailSecurityTimeseriesGroupTLSVersionParamsFormat = "JSON" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsFormatCsv RadarEmailSecurityTimeseriesGroupTLSVersionParamsFormat = "CSV" -) - -type RadarEmailSecurityTimeseriesGroupTLSVersionParamsSPF string - -const ( - RadarEmailSecurityTimeseriesGroupTLSVersionParamsSPFPass RadarEmailSecurityTimeseriesGroupTLSVersionParamsSPF = "PASS" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsSPFNone RadarEmailSecurityTimeseriesGroupTLSVersionParamsSPF = "NONE" - RadarEmailSecurityTimeseriesGroupTLSVersionParamsSPFFail RadarEmailSecurityTimeseriesGroupTLSVersionParamsSPF = "FAIL" -) - -type RadarEmailSecurityTimeseriesGroupTLSVersionResponseEnvelope struct { - Result RadarEmailSecurityTimeseriesGroupTLSVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecurityTimeseriesGroupTLSVersionResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecurityTimeseriesGroupTLSVersionResponseEnvelopeJSON contains the -// JSON metadata for the struct -// [RadarEmailSecurityTimeseriesGroupTLSVersionResponseEnvelope] -type radarEmailSecurityTimeseriesGroupTLSVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTimeseriesGroupTLSVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTimeseriesGroupTLSVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radaremailsecuritytimeseriesgroup_test.go b/radaremailsecuritytimeseriesgroup_test.go deleted file mode 100644 index a5033831376..00000000000 --- a/radaremailsecuritytimeseriesgroup_test.go +++ /dev/null @@ -1,334 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarEmailSecurityTimeseriesGroupARCWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.TimeseriesGroups.ARC(context.TODO(), cloudflare.RadarEmailSecurityTimeseriesGroupARCParams{ - AggInterval: cloudflare.F(cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsAggInterval1h), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsDateRange{cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsDateRange1d, cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsDateRange2d, cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsDKIM{cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsDKIMPass, cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsDKIMNone, cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsDMARC{cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsDMARCPass, cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsDMARCNone, cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsSPF{cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsSPFPass, cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsSPFNone, cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsSPFFail}), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsTLSVersion{cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecurityTimeseriesGroupARCParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarEmailSecurityTimeseriesGroupDKIMWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.TimeseriesGroups.DKIM(context.TODO(), cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParams{ - AggInterval: cloudflare.F(cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsAggInterval1h), - ARC: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsARC{cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsARCPass, cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsARCNone, cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange{cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange1d, cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange2d, cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsDMARC{cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsDMARCPass, cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsDMARCNone, cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsSPF{cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsSPFPass, cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsSPFNone, cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsSPFFail}), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsTLSVersion{cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecurityTimeseriesGroupDKIMParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarEmailSecurityTimeseriesGroupDMARCWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.TimeseriesGroups.DMARC(context.TODO(), cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParams{ - AggInterval: cloudflare.F(cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsAggInterval1h), - ARC: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsARC{cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsARCPass, cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsARCNone, cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange{cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange1d, cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange2d, cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsDKIM{cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsDKIMPass, cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsDKIMNone, cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsDKIMFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsSPF{cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsSPFPass, cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsSPFNone, cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsSPFFail}), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsTLSVersion{cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecurityTimeseriesGroupDMARCParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarEmailSecurityTimeseriesGroupMaliciousWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.TimeseriesGroups.Malicious(context.TODO(), cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParams{ - AggInterval: cloudflare.F(cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsAggInterval1h), - ARC: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsARC{cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsARCPass, cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsARCNone, cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange{cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange1d, cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange2d, cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsDKIM{cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsDKIMPass, cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsDKIMNone, cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsDMARC{cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsDMARCPass, cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsDMARCNone, cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsSPF{cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsSPFPass, cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsSPFNone, cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsSPFFail}), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsTLSVersion{cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecurityTimeseriesGroupMaliciousParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarEmailSecurityTimeseriesGroupSpamWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.TimeseriesGroups.Spam(context.TODO(), cloudflare.RadarEmailSecurityTimeseriesGroupSpamParams{ - AggInterval: cloudflare.F(cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsAggInterval1h), - ARC: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsARC{cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsARCPass, cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsARCNone, cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsDateRange{cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsDateRange1d, cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsDateRange2d, cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsDKIM{cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsDKIMPass, cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsDKIMNone, cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsDMARC{cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsDMARCPass, cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsDMARCNone, cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsSPF{cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsSPFPass, cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsSPFNone, cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsSPFFail}), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsTLSVersion{cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecurityTimeseriesGroupSpamParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarEmailSecurityTimeseriesGroupSPFWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.TimeseriesGroups.SPF(context.TODO(), cloudflare.RadarEmailSecurityTimeseriesGroupSPFParams{ - AggInterval: cloudflare.F(cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsAggInterval1h), - ARC: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsARC{cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsARCPass, cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsARCNone, cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsDateRange{cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsDateRange1d, cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsDateRange2d, cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsDKIM{cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsDKIMPass, cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsDKIMNone, cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsDMARC{cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsDMARCPass, cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsDMARCNone, cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsTLSVersion{cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecurityTimeseriesGroupSPFParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarEmailSecurityTimeseriesGroupSpoofWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.TimeseriesGroups.Spoof(context.TODO(), cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParams{ - AggInterval: cloudflare.F(cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsAggInterval1h), - ARC: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsARC{cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsARCPass, cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsARCNone, cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange{cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange1d, cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange2d, cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsDKIM{cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsDKIMPass, cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsDKIMNone, cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsDMARC{cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsDMARCPass, cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsDMARCNone, cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsSPF{cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsSPFPass, cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsSPFNone, cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsSPFFail}), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsTLSVersion{cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecurityTimeseriesGroupSpoofParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarEmailSecurityTimeseriesGroupThreatCategoryWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.TimeseriesGroups.ThreatCategory(context.TODO(), cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParams{ - AggInterval: cloudflare.F(cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsAggInterval1h), - ARC: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsARC{cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsARCPass, cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsARCNone, cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange{cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange1d, cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange2d, cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDKIM{cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDKIMPass, cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDKIMNone, cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDMARC{cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDMARCPass, cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDMARCNone, cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsSPF{cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsSPFPass, cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsSPFNone, cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsSPFFail}), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersion{cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecurityTimeseriesGroupThreatCategoryParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarEmailSecurityTimeseriesGroupTLSVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.TimeseriesGroups.TLSVersion(context.TODO(), cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParams{ - AggInterval: cloudflare.F(cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsAggInterval1h), - ARC: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsARC{cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsARCPass, cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsARCNone, cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange{cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange1d, cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange2d, cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsDKIM{cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsDKIMPass, cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsDKIMNone, cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsDMARC{cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsDMARCPass, cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsDMARCNone, cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsFormatJson), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsSPF{cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsSPFPass, cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsSPFNone, cloudflare.RadarEmailSecurityTimeseriesGroupTLSVersionParamsSPFFail}), - }) - 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/radaremailsecuritytop.go b/radaremailsecuritytop.go deleted file mode 100644 index 07de49b25fe..00000000000 --- a/radaremailsecuritytop.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarEmailSecurityTopService 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 [NewRadarEmailSecurityTopService] -// method instead. -type RadarEmailSecurityTopService struct { - Options []option.RequestOption - Tlds *RadarEmailSecurityTopTldService -} - -// NewRadarEmailSecurityTopService 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 NewRadarEmailSecurityTopService(opts ...option.RequestOption) (r *RadarEmailSecurityTopService) { - r = &RadarEmailSecurityTopService{} - r.Options = opts - r.Tlds = NewRadarEmailSecurityTopTldService(opts...) - return -} diff --git a/radaremailsecuritytoptld.go b/radaremailsecuritytoptld.go deleted file mode 100644 index b3804997c11..00000000000 --- a/radaremailsecuritytoptld.go +++ /dev/null @@ -1,345 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarEmailSecurityTopTldService 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 -// [NewRadarEmailSecurityTopTldService] method instead. -type RadarEmailSecurityTopTldService struct { - Options []option.RequestOption - Malicious *RadarEmailSecurityTopTldMaliciousService - Spam *RadarEmailSecurityTopTldSpamService - Spoof *RadarEmailSecurityTopTldSpoofService -} - -// NewRadarEmailSecurityTopTldService 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 NewRadarEmailSecurityTopTldService(opts ...option.RequestOption) (r *RadarEmailSecurityTopTldService) { - r = &RadarEmailSecurityTopTldService{} - r.Options = opts - r.Malicious = NewRadarEmailSecurityTopTldMaliciousService(opts...) - r.Spam = NewRadarEmailSecurityTopTldSpamService(opts...) - r.Spoof = NewRadarEmailSecurityTopTldSpoofService(opts...) - return -} - -// Get the top TLDs by email messages. Values are a percentage out of the total -// emails. -func (r *RadarEmailSecurityTopTldService) Get(ctx context.Context, query RadarEmailSecurityTopTldGetParams, opts ...option.RequestOption) (res *RadarEmailSecurityTopTldGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecurityTopTldGetResponseEnvelope - path := "radar/email/security/top/tlds" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarEmailSecurityTopTldGetResponse struct { - Meta RadarEmailSecurityTopTldGetResponseMeta `json:"meta,required"` - Top0 []RadarEmailSecurityTopTldGetResponseTop0 `json:"top_0,required"` - JSON radarEmailSecurityTopTldGetResponseJSON `json:"-"` -} - -// radarEmailSecurityTopTldGetResponseJSON contains the JSON metadata for the -// struct [RadarEmailSecurityTopTldGetResponse] -type radarEmailSecurityTopTldGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldGetResponseMeta struct { - DateRange []RadarEmailSecurityTopTldGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarEmailSecurityTopTldGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailSecurityTopTldGetResponseMetaJSON `json:"-"` -} - -// radarEmailSecurityTopTldGetResponseMetaJSON contains the JSON metadata for the -// struct [RadarEmailSecurityTopTldGetResponseMeta] -type radarEmailSecurityTopTldGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailSecurityTopTldGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailSecurityTopTldGetResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarEmailSecurityTopTldGetResponseMetaDateRange] -type radarEmailSecurityTopTldGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldGetResponseMetaConfidenceInfo struct { - Annotations []RadarEmailSecurityTopTldGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailSecurityTopTldGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailSecurityTopTldGetResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarEmailSecurityTopTldGetResponseMetaConfidenceInfo] -type radarEmailSecurityTopTldGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailSecurityTopTldGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailSecurityTopTldGetResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarEmailSecurityTopTldGetResponseMetaConfidenceInfoAnnotation] -type radarEmailSecurityTopTldGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldGetResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON radarEmailSecurityTopTldGetResponseTop0JSON `json:"-"` -} - -// radarEmailSecurityTopTldGetResponseTop0JSON contains the JSON metadata for the -// struct [RadarEmailSecurityTopTldGetResponseTop0] -type radarEmailSecurityTopTldGetResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldGetParams struct { - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecurityTopTldGetParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecurityTopTldGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecurityTopTldGetParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecurityTopTldGetParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecurityTopTldGetParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecurityTopTldGetParamsSPF] `query:"spf"` - // Filter for TLDs by category. - TldCategory param.Field[RadarEmailSecurityTopTldGetParamsTldCategory] `query:"tldCategory"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecurityTopTldGetParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecurityTopTldGetParams]'s query parameters as -// `url.Values`. -func (r RadarEmailSecurityTopTldGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarEmailSecurityTopTldGetParamsARC string - -const ( - RadarEmailSecurityTopTldGetParamsARCPass RadarEmailSecurityTopTldGetParamsARC = "PASS" - RadarEmailSecurityTopTldGetParamsARCNone RadarEmailSecurityTopTldGetParamsARC = "NONE" - RadarEmailSecurityTopTldGetParamsARCFail RadarEmailSecurityTopTldGetParamsARC = "FAIL" -) - -type RadarEmailSecurityTopTldGetParamsDateRange string - -const ( - RadarEmailSecurityTopTldGetParamsDateRange1d RadarEmailSecurityTopTldGetParamsDateRange = "1d" - RadarEmailSecurityTopTldGetParamsDateRange2d RadarEmailSecurityTopTldGetParamsDateRange = "2d" - RadarEmailSecurityTopTldGetParamsDateRange7d RadarEmailSecurityTopTldGetParamsDateRange = "7d" - RadarEmailSecurityTopTldGetParamsDateRange14d RadarEmailSecurityTopTldGetParamsDateRange = "14d" - RadarEmailSecurityTopTldGetParamsDateRange28d RadarEmailSecurityTopTldGetParamsDateRange = "28d" - RadarEmailSecurityTopTldGetParamsDateRange12w RadarEmailSecurityTopTldGetParamsDateRange = "12w" - RadarEmailSecurityTopTldGetParamsDateRange24w RadarEmailSecurityTopTldGetParamsDateRange = "24w" - RadarEmailSecurityTopTldGetParamsDateRange52w RadarEmailSecurityTopTldGetParamsDateRange = "52w" - RadarEmailSecurityTopTldGetParamsDateRange1dControl RadarEmailSecurityTopTldGetParamsDateRange = "1dControl" - RadarEmailSecurityTopTldGetParamsDateRange2dControl RadarEmailSecurityTopTldGetParamsDateRange = "2dControl" - RadarEmailSecurityTopTldGetParamsDateRange7dControl RadarEmailSecurityTopTldGetParamsDateRange = "7dControl" - RadarEmailSecurityTopTldGetParamsDateRange14dControl RadarEmailSecurityTopTldGetParamsDateRange = "14dControl" - RadarEmailSecurityTopTldGetParamsDateRange28dControl RadarEmailSecurityTopTldGetParamsDateRange = "28dControl" - RadarEmailSecurityTopTldGetParamsDateRange12wControl RadarEmailSecurityTopTldGetParamsDateRange = "12wControl" - RadarEmailSecurityTopTldGetParamsDateRange24wControl RadarEmailSecurityTopTldGetParamsDateRange = "24wControl" -) - -type RadarEmailSecurityTopTldGetParamsDKIM string - -const ( - RadarEmailSecurityTopTldGetParamsDKIMPass RadarEmailSecurityTopTldGetParamsDKIM = "PASS" - RadarEmailSecurityTopTldGetParamsDKIMNone RadarEmailSecurityTopTldGetParamsDKIM = "NONE" - RadarEmailSecurityTopTldGetParamsDKIMFail RadarEmailSecurityTopTldGetParamsDKIM = "FAIL" -) - -type RadarEmailSecurityTopTldGetParamsDMARC string - -const ( - RadarEmailSecurityTopTldGetParamsDMARCPass RadarEmailSecurityTopTldGetParamsDMARC = "PASS" - RadarEmailSecurityTopTldGetParamsDMARCNone RadarEmailSecurityTopTldGetParamsDMARC = "NONE" - RadarEmailSecurityTopTldGetParamsDMARCFail RadarEmailSecurityTopTldGetParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecurityTopTldGetParamsFormat string - -const ( - RadarEmailSecurityTopTldGetParamsFormatJson RadarEmailSecurityTopTldGetParamsFormat = "JSON" - RadarEmailSecurityTopTldGetParamsFormatCsv RadarEmailSecurityTopTldGetParamsFormat = "CSV" -) - -type RadarEmailSecurityTopTldGetParamsSPF string - -const ( - RadarEmailSecurityTopTldGetParamsSPFPass RadarEmailSecurityTopTldGetParamsSPF = "PASS" - RadarEmailSecurityTopTldGetParamsSPFNone RadarEmailSecurityTopTldGetParamsSPF = "NONE" - RadarEmailSecurityTopTldGetParamsSPFFail RadarEmailSecurityTopTldGetParamsSPF = "FAIL" -) - -// Filter for TLDs by category. -type RadarEmailSecurityTopTldGetParamsTldCategory string - -const ( - RadarEmailSecurityTopTldGetParamsTldCategoryClassic RadarEmailSecurityTopTldGetParamsTldCategory = "CLASSIC" - RadarEmailSecurityTopTldGetParamsTldCategoryCountry RadarEmailSecurityTopTldGetParamsTldCategory = "COUNTRY" -) - -type RadarEmailSecurityTopTldGetParamsTLSVersion string - -const ( - RadarEmailSecurityTopTldGetParamsTLSVersionTlSv1_0 RadarEmailSecurityTopTldGetParamsTLSVersion = "TLSv1_0" - RadarEmailSecurityTopTldGetParamsTLSVersionTlSv1_1 RadarEmailSecurityTopTldGetParamsTLSVersion = "TLSv1_1" - RadarEmailSecurityTopTldGetParamsTLSVersionTlSv1_2 RadarEmailSecurityTopTldGetParamsTLSVersion = "TLSv1_2" - RadarEmailSecurityTopTldGetParamsTLSVersionTlSv1_3 RadarEmailSecurityTopTldGetParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecurityTopTldGetResponseEnvelope struct { - Result RadarEmailSecurityTopTldGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecurityTopTldGetResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecurityTopTldGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarEmailSecurityTopTldGetResponseEnvelope] -type radarEmailSecurityTopTldGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radaremailsecuritytoptld_test.go b/radaremailsecuritytoptld_test.go deleted file mode 100644 index d729ec6a60d..00000000000 --- a/radaremailsecuritytoptld_test.go +++ /dev/null @@ -1,52 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarEmailSecurityTopTldGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.Top.Tlds.Get(context.TODO(), cloudflare.RadarEmailSecurityTopTldGetParams{ - ARC: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldGetParamsARC{cloudflare.RadarEmailSecurityTopTldGetParamsARCPass, cloudflare.RadarEmailSecurityTopTldGetParamsARCNone, cloudflare.RadarEmailSecurityTopTldGetParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldGetParamsDateRange{cloudflare.RadarEmailSecurityTopTldGetParamsDateRange1d, cloudflare.RadarEmailSecurityTopTldGetParamsDateRange2d, cloudflare.RadarEmailSecurityTopTldGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldGetParamsDKIM{cloudflare.RadarEmailSecurityTopTldGetParamsDKIMPass, cloudflare.RadarEmailSecurityTopTldGetParamsDKIMNone, cloudflare.RadarEmailSecurityTopTldGetParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldGetParamsDMARC{cloudflare.RadarEmailSecurityTopTldGetParamsDMARCPass, cloudflare.RadarEmailSecurityTopTldGetParamsDMARCNone, cloudflare.RadarEmailSecurityTopTldGetParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecurityTopTldGetParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldGetParamsSPF{cloudflare.RadarEmailSecurityTopTldGetParamsSPFPass, cloudflare.RadarEmailSecurityTopTldGetParamsSPFNone, cloudflare.RadarEmailSecurityTopTldGetParamsSPFFail}), - TldCategory: cloudflare.F(cloudflare.RadarEmailSecurityTopTldGetParamsTldCategoryClassic), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldGetParamsTLSVersion{cloudflare.RadarEmailSecurityTopTldGetParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecurityTopTldGetParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecurityTopTldGetParamsTLSVersionTlSv1_2}), - }) - 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/radaremailsecuritytoptldmalicious.go b/radaremailsecuritytoptldmalicious.go deleted file mode 100644 index 1c5ce1260a9..00000000000 --- a/radaremailsecuritytoptldmalicious.go +++ /dev/null @@ -1,349 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarEmailSecurityTopTldMaliciousService 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 -// [NewRadarEmailSecurityTopTldMaliciousService] method instead. -type RadarEmailSecurityTopTldMaliciousService struct { - Options []option.RequestOption -} - -// NewRadarEmailSecurityTopTldMaliciousService 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 NewRadarEmailSecurityTopTldMaliciousService(opts ...option.RequestOption) (r *RadarEmailSecurityTopTldMaliciousService) { - r = &RadarEmailSecurityTopTldMaliciousService{} - r.Options = opts - return -} - -// Get the TLDs by emails classified as malicious or not. -func (r *RadarEmailSecurityTopTldMaliciousService) Get(ctx context.Context, malicious RadarEmailSecurityTopTldMaliciousGetParamsMalicious, query RadarEmailSecurityTopTldMaliciousGetParams, opts ...option.RequestOption) (res *RadarEmailSecurityTopTldMaliciousGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecurityTopTldMaliciousGetResponseEnvelope - path := fmt.Sprintf("radar/email/security/top/tlds/malicious/%v", malicious) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarEmailSecurityTopTldMaliciousGetResponse struct { - Meta RadarEmailSecurityTopTldMaliciousGetResponseMeta `json:"meta,required"` - Top0 []RadarEmailSecurityTopTldMaliciousGetResponseTop0 `json:"top_0,required"` - JSON radarEmailSecurityTopTldMaliciousGetResponseJSON `json:"-"` -} - -// radarEmailSecurityTopTldMaliciousGetResponseJSON contains the JSON metadata for -// the struct [RadarEmailSecurityTopTldMaliciousGetResponse] -type radarEmailSecurityTopTldMaliciousGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldMaliciousGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldMaliciousGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldMaliciousGetResponseMeta struct { - DateRange []RadarEmailSecurityTopTldMaliciousGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarEmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailSecurityTopTldMaliciousGetResponseMetaJSON `json:"-"` -} - -// radarEmailSecurityTopTldMaliciousGetResponseMetaJSON contains the JSON metadata -// for the struct [RadarEmailSecurityTopTldMaliciousGetResponseMeta] -type radarEmailSecurityTopTldMaliciousGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldMaliciousGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldMaliciousGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldMaliciousGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailSecurityTopTldMaliciousGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailSecurityTopTldMaliciousGetResponseMetaDateRangeJSON contains the JSON -// metadata for the struct -// [RadarEmailSecurityTopTldMaliciousGetResponseMetaDateRange] -type radarEmailSecurityTopTldMaliciousGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldMaliciousGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldMaliciousGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfo struct { - Annotations []RadarEmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoJSON contains the -// JSON metadata for the struct -// [RadarEmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfo] -type radarEmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarEmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoAnnotation] -type radarEmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldMaliciousGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldMaliciousGetResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON radarEmailSecurityTopTldMaliciousGetResponseTop0JSON `json:"-"` -} - -// radarEmailSecurityTopTldMaliciousGetResponseTop0JSON contains the JSON metadata -// for the struct [RadarEmailSecurityTopTldMaliciousGetResponseTop0] -type radarEmailSecurityTopTldMaliciousGetResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldMaliciousGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldMaliciousGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldMaliciousGetParams struct { - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecurityTopTldMaliciousGetParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecurityTopTldMaliciousGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecurityTopTldMaliciousGetParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecurityTopTldMaliciousGetParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecurityTopTldMaliciousGetParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecurityTopTldMaliciousGetParamsSPF] `query:"spf"` - // Filter for TLDs by category. - TldCategory param.Field[RadarEmailSecurityTopTldMaliciousGetParamsTldCategory] `query:"tldCategory"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecurityTopTldMaliciousGetParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecurityTopTldMaliciousGetParams]'s query -// parameters as `url.Values`. -func (r RadarEmailSecurityTopTldMaliciousGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Malicious. -type RadarEmailSecurityTopTldMaliciousGetParamsMalicious string - -const ( - RadarEmailSecurityTopTldMaliciousGetParamsMaliciousMalicious RadarEmailSecurityTopTldMaliciousGetParamsMalicious = "MALICIOUS" - RadarEmailSecurityTopTldMaliciousGetParamsMaliciousNotMalicious RadarEmailSecurityTopTldMaliciousGetParamsMalicious = "NOT_MALICIOUS" -) - -type RadarEmailSecurityTopTldMaliciousGetParamsARC string - -const ( - RadarEmailSecurityTopTldMaliciousGetParamsARCPass RadarEmailSecurityTopTldMaliciousGetParamsARC = "PASS" - RadarEmailSecurityTopTldMaliciousGetParamsARCNone RadarEmailSecurityTopTldMaliciousGetParamsARC = "NONE" - RadarEmailSecurityTopTldMaliciousGetParamsARCFail RadarEmailSecurityTopTldMaliciousGetParamsARC = "FAIL" -) - -type RadarEmailSecurityTopTldMaliciousGetParamsDateRange string - -const ( - RadarEmailSecurityTopTldMaliciousGetParamsDateRange1d RadarEmailSecurityTopTldMaliciousGetParamsDateRange = "1d" - RadarEmailSecurityTopTldMaliciousGetParamsDateRange2d RadarEmailSecurityTopTldMaliciousGetParamsDateRange = "2d" - RadarEmailSecurityTopTldMaliciousGetParamsDateRange7d RadarEmailSecurityTopTldMaliciousGetParamsDateRange = "7d" - RadarEmailSecurityTopTldMaliciousGetParamsDateRange14d RadarEmailSecurityTopTldMaliciousGetParamsDateRange = "14d" - RadarEmailSecurityTopTldMaliciousGetParamsDateRange28d RadarEmailSecurityTopTldMaliciousGetParamsDateRange = "28d" - RadarEmailSecurityTopTldMaliciousGetParamsDateRange12w RadarEmailSecurityTopTldMaliciousGetParamsDateRange = "12w" - RadarEmailSecurityTopTldMaliciousGetParamsDateRange24w RadarEmailSecurityTopTldMaliciousGetParamsDateRange = "24w" - RadarEmailSecurityTopTldMaliciousGetParamsDateRange52w RadarEmailSecurityTopTldMaliciousGetParamsDateRange = "52w" - RadarEmailSecurityTopTldMaliciousGetParamsDateRange1dControl RadarEmailSecurityTopTldMaliciousGetParamsDateRange = "1dControl" - RadarEmailSecurityTopTldMaliciousGetParamsDateRange2dControl RadarEmailSecurityTopTldMaliciousGetParamsDateRange = "2dControl" - RadarEmailSecurityTopTldMaliciousGetParamsDateRange7dControl RadarEmailSecurityTopTldMaliciousGetParamsDateRange = "7dControl" - RadarEmailSecurityTopTldMaliciousGetParamsDateRange14dControl RadarEmailSecurityTopTldMaliciousGetParamsDateRange = "14dControl" - RadarEmailSecurityTopTldMaliciousGetParamsDateRange28dControl RadarEmailSecurityTopTldMaliciousGetParamsDateRange = "28dControl" - RadarEmailSecurityTopTldMaliciousGetParamsDateRange12wControl RadarEmailSecurityTopTldMaliciousGetParamsDateRange = "12wControl" - RadarEmailSecurityTopTldMaliciousGetParamsDateRange24wControl RadarEmailSecurityTopTldMaliciousGetParamsDateRange = "24wControl" -) - -type RadarEmailSecurityTopTldMaliciousGetParamsDKIM string - -const ( - RadarEmailSecurityTopTldMaliciousGetParamsDKIMPass RadarEmailSecurityTopTldMaliciousGetParamsDKIM = "PASS" - RadarEmailSecurityTopTldMaliciousGetParamsDKIMNone RadarEmailSecurityTopTldMaliciousGetParamsDKIM = "NONE" - RadarEmailSecurityTopTldMaliciousGetParamsDKIMFail RadarEmailSecurityTopTldMaliciousGetParamsDKIM = "FAIL" -) - -type RadarEmailSecurityTopTldMaliciousGetParamsDMARC string - -const ( - RadarEmailSecurityTopTldMaliciousGetParamsDMARCPass RadarEmailSecurityTopTldMaliciousGetParamsDMARC = "PASS" - RadarEmailSecurityTopTldMaliciousGetParamsDMARCNone RadarEmailSecurityTopTldMaliciousGetParamsDMARC = "NONE" - RadarEmailSecurityTopTldMaliciousGetParamsDMARCFail RadarEmailSecurityTopTldMaliciousGetParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecurityTopTldMaliciousGetParamsFormat string - -const ( - RadarEmailSecurityTopTldMaliciousGetParamsFormatJson RadarEmailSecurityTopTldMaliciousGetParamsFormat = "JSON" - RadarEmailSecurityTopTldMaliciousGetParamsFormatCsv RadarEmailSecurityTopTldMaliciousGetParamsFormat = "CSV" -) - -type RadarEmailSecurityTopTldMaliciousGetParamsSPF string - -const ( - RadarEmailSecurityTopTldMaliciousGetParamsSPFPass RadarEmailSecurityTopTldMaliciousGetParamsSPF = "PASS" - RadarEmailSecurityTopTldMaliciousGetParamsSPFNone RadarEmailSecurityTopTldMaliciousGetParamsSPF = "NONE" - RadarEmailSecurityTopTldMaliciousGetParamsSPFFail RadarEmailSecurityTopTldMaliciousGetParamsSPF = "FAIL" -) - -// Filter for TLDs by category. -type RadarEmailSecurityTopTldMaliciousGetParamsTldCategory string - -const ( - RadarEmailSecurityTopTldMaliciousGetParamsTldCategoryClassic RadarEmailSecurityTopTldMaliciousGetParamsTldCategory = "CLASSIC" - RadarEmailSecurityTopTldMaliciousGetParamsTldCategoryCountry RadarEmailSecurityTopTldMaliciousGetParamsTldCategory = "COUNTRY" -) - -type RadarEmailSecurityTopTldMaliciousGetParamsTLSVersion string - -const ( - RadarEmailSecurityTopTldMaliciousGetParamsTLSVersionTlSv1_0 RadarEmailSecurityTopTldMaliciousGetParamsTLSVersion = "TLSv1_0" - RadarEmailSecurityTopTldMaliciousGetParamsTLSVersionTlSv1_1 RadarEmailSecurityTopTldMaliciousGetParamsTLSVersion = "TLSv1_1" - RadarEmailSecurityTopTldMaliciousGetParamsTLSVersionTlSv1_2 RadarEmailSecurityTopTldMaliciousGetParamsTLSVersion = "TLSv1_2" - RadarEmailSecurityTopTldMaliciousGetParamsTLSVersionTlSv1_3 RadarEmailSecurityTopTldMaliciousGetParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecurityTopTldMaliciousGetResponseEnvelope struct { - Result RadarEmailSecurityTopTldMaliciousGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecurityTopTldMaliciousGetResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecurityTopTldMaliciousGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarEmailSecurityTopTldMaliciousGetResponseEnvelope] -type radarEmailSecurityTopTldMaliciousGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldMaliciousGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldMaliciousGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radaremailsecuritytoptldmalicious_test.go b/radaremailsecuritytoptldmalicious_test.go deleted file mode 100644 index 745562a8419..00000000000 --- a/radaremailsecuritytoptldmalicious_test.go +++ /dev/null @@ -1,56 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarEmailSecurityTopTldMaliciousGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.Top.Tlds.Malicious.Get( - context.TODO(), - cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsMaliciousMalicious, - cloudflare.RadarEmailSecurityTopTldMaliciousGetParams{ - ARC: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsARC{cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsARCPass, cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsARCNone, cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsDateRange{cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsDateRange1d, cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsDateRange2d, cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsDKIM{cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsDKIMPass, cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsDKIMNone, cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsDMARC{cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsDMARCPass, cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsDMARCNone, cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsSPF{cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsSPFPass, cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsSPFNone, cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsSPFFail}), - TldCategory: cloudflare.F(cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsTldCategoryClassic), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsTLSVersion{cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecurityTopTldMaliciousGetParamsTLSVersionTlSv1_2}), - }, - ) - 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/radaremailsecuritytoptldspam.go b/radaremailsecuritytoptldspam.go deleted file mode 100644 index a0fc5ee6679..00000000000 --- a/radaremailsecuritytoptldspam.go +++ /dev/null @@ -1,348 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarEmailSecurityTopTldSpamService 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 -// [NewRadarEmailSecurityTopTldSpamService] method instead. -type RadarEmailSecurityTopTldSpamService struct { - Options []option.RequestOption -} - -// NewRadarEmailSecurityTopTldSpamService 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 NewRadarEmailSecurityTopTldSpamService(opts ...option.RequestOption) (r *RadarEmailSecurityTopTldSpamService) { - r = &RadarEmailSecurityTopTldSpamService{} - r.Options = opts - return -} - -// Get the top TLDs by emails classified as Spam or not. -func (r *RadarEmailSecurityTopTldSpamService) Get(ctx context.Context, spam RadarEmailSecurityTopTldSpamGetParamsSpam, query RadarEmailSecurityTopTldSpamGetParams, opts ...option.RequestOption) (res *RadarEmailSecurityTopTldSpamGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecurityTopTldSpamGetResponseEnvelope - path := fmt.Sprintf("radar/email/security/top/tlds/spam/%v", spam) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarEmailSecurityTopTldSpamGetResponse struct { - Meta RadarEmailSecurityTopTldSpamGetResponseMeta `json:"meta,required"` - Top0 []RadarEmailSecurityTopTldSpamGetResponseTop0 `json:"top_0,required"` - JSON radarEmailSecurityTopTldSpamGetResponseJSON `json:"-"` -} - -// radarEmailSecurityTopTldSpamGetResponseJSON contains the JSON metadata for the -// struct [RadarEmailSecurityTopTldSpamGetResponse] -type radarEmailSecurityTopTldSpamGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldSpamGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldSpamGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldSpamGetResponseMeta struct { - DateRange []RadarEmailSecurityTopTldSpamGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarEmailSecurityTopTldSpamGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailSecurityTopTldSpamGetResponseMetaJSON `json:"-"` -} - -// radarEmailSecurityTopTldSpamGetResponseMetaJSON contains the JSON metadata for -// the struct [RadarEmailSecurityTopTldSpamGetResponseMeta] -type radarEmailSecurityTopTldSpamGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldSpamGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldSpamGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldSpamGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailSecurityTopTldSpamGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailSecurityTopTldSpamGetResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarEmailSecurityTopTldSpamGetResponseMetaDateRange] -type radarEmailSecurityTopTldSpamGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldSpamGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldSpamGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldSpamGetResponseMetaConfidenceInfo struct { - Annotations []RadarEmailSecurityTopTldSpamGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailSecurityTopTldSpamGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailSecurityTopTldSpamGetResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarEmailSecurityTopTldSpamGetResponseMetaConfidenceInfo] -type radarEmailSecurityTopTldSpamGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldSpamGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldSpamGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldSpamGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailSecurityTopTldSpamGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailSecurityTopTldSpamGetResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarEmailSecurityTopTldSpamGetResponseMetaConfidenceInfoAnnotation] -type radarEmailSecurityTopTldSpamGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldSpamGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldSpamGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldSpamGetResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON radarEmailSecurityTopTldSpamGetResponseTop0JSON `json:"-"` -} - -// radarEmailSecurityTopTldSpamGetResponseTop0JSON contains the JSON metadata for -// the struct [RadarEmailSecurityTopTldSpamGetResponseTop0] -type radarEmailSecurityTopTldSpamGetResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldSpamGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldSpamGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldSpamGetParams struct { - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecurityTopTldSpamGetParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecurityTopTldSpamGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecurityTopTldSpamGetParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecurityTopTldSpamGetParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecurityTopTldSpamGetParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecurityTopTldSpamGetParamsSPF] `query:"spf"` - // Filter for TLDs by category. - TldCategory param.Field[RadarEmailSecurityTopTldSpamGetParamsTldCategory] `query:"tldCategory"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecurityTopTldSpamGetParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecurityTopTldSpamGetParams]'s query parameters -// as `url.Values`. -func (r RadarEmailSecurityTopTldSpamGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Spam. -type RadarEmailSecurityTopTldSpamGetParamsSpam string - -const ( - RadarEmailSecurityTopTldSpamGetParamsSpamSpam RadarEmailSecurityTopTldSpamGetParamsSpam = "SPAM" - RadarEmailSecurityTopTldSpamGetParamsSpamNotSpam RadarEmailSecurityTopTldSpamGetParamsSpam = "NOT_SPAM" -) - -type RadarEmailSecurityTopTldSpamGetParamsARC string - -const ( - RadarEmailSecurityTopTldSpamGetParamsARCPass RadarEmailSecurityTopTldSpamGetParamsARC = "PASS" - RadarEmailSecurityTopTldSpamGetParamsARCNone RadarEmailSecurityTopTldSpamGetParamsARC = "NONE" - RadarEmailSecurityTopTldSpamGetParamsARCFail RadarEmailSecurityTopTldSpamGetParamsARC = "FAIL" -) - -type RadarEmailSecurityTopTldSpamGetParamsDateRange string - -const ( - RadarEmailSecurityTopTldSpamGetParamsDateRange1d RadarEmailSecurityTopTldSpamGetParamsDateRange = "1d" - RadarEmailSecurityTopTldSpamGetParamsDateRange2d RadarEmailSecurityTopTldSpamGetParamsDateRange = "2d" - RadarEmailSecurityTopTldSpamGetParamsDateRange7d RadarEmailSecurityTopTldSpamGetParamsDateRange = "7d" - RadarEmailSecurityTopTldSpamGetParamsDateRange14d RadarEmailSecurityTopTldSpamGetParamsDateRange = "14d" - RadarEmailSecurityTopTldSpamGetParamsDateRange28d RadarEmailSecurityTopTldSpamGetParamsDateRange = "28d" - RadarEmailSecurityTopTldSpamGetParamsDateRange12w RadarEmailSecurityTopTldSpamGetParamsDateRange = "12w" - RadarEmailSecurityTopTldSpamGetParamsDateRange24w RadarEmailSecurityTopTldSpamGetParamsDateRange = "24w" - RadarEmailSecurityTopTldSpamGetParamsDateRange52w RadarEmailSecurityTopTldSpamGetParamsDateRange = "52w" - RadarEmailSecurityTopTldSpamGetParamsDateRange1dControl RadarEmailSecurityTopTldSpamGetParamsDateRange = "1dControl" - RadarEmailSecurityTopTldSpamGetParamsDateRange2dControl RadarEmailSecurityTopTldSpamGetParamsDateRange = "2dControl" - RadarEmailSecurityTopTldSpamGetParamsDateRange7dControl RadarEmailSecurityTopTldSpamGetParamsDateRange = "7dControl" - RadarEmailSecurityTopTldSpamGetParamsDateRange14dControl RadarEmailSecurityTopTldSpamGetParamsDateRange = "14dControl" - RadarEmailSecurityTopTldSpamGetParamsDateRange28dControl RadarEmailSecurityTopTldSpamGetParamsDateRange = "28dControl" - RadarEmailSecurityTopTldSpamGetParamsDateRange12wControl RadarEmailSecurityTopTldSpamGetParamsDateRange = "12wControl" - RadarEmailSecurityTopTldSpamGetParamsDateRange24wControl RadarEmailSecurityTopTldSpamGetParamsDateRange = "24wControl" -) - -type RadarEmailSecurityTopTldSpamGetParamsDKIM string - -const ( - RadarEmailSecurityTopTldSpamGetParamsDKIMPass RadarEmailSecurityTopTldSpamGetParamsDKIM = "PASS" - RadarEmailSecurityTopTldSpamGetParamsDKIMNone RadarEmailSecurityTopTldSpamGetParamsDKIM = "NONE" - RadarEmailSecurityTopTldSpamGetParamsDKIMFail RadarEmailSecurityTopTldSpamGetParamsDKIM = "FAIL" -) - -type RadarEmailSecurityTopTldSpamGetParamsDMARC string - -const ( - RadarEmailSecurityTopTldSpamGetParamsDMARCPass RadarEmailSecurityTopTldSpamGetParamsDMARC = "PASS" - RadarEmailSecurityTopTldSpamGetParamsDMARCNone RadarEmailSecurityTopTldSpamGetParamsDMARC = "NONE" - RadarEmailSecurityTopTldSpamGetParamsDMARCFail RadarEmailSecurityTopTldSpamGetParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecurityTopTldSpamGetParamsFormat string - -const ( - RadarEmailSecurityTopTldSpamGetParamsFormatJson RadarEmailSecurityTopTldSpamGetParamsFormat = "JSON" - RadarEmailSecurityTopTldSpamGetParamsFormatCsv RadarEmailSecurityTopTldSpamGetParamsFormat = "CSV" -) - -type RadarEmailSecurityTopTldSpamGetParamsSPF string - -const ( - RadarEmailSecurityTopTldSpamGetParamsSPFPass RadarEmailSecurityTopTldSpamGetParamsSPF = "PASS" - RadarEmailSecurityTopTldSpamGetParamsSPFNone RadarEmailSecurityTopTldSpamGetParamsSPF = "NONE" - RadarEmailSecurityTopTldSpamGetParamsSPFFail RadarEmailSecurityTopTldSpamGetParamsSPF = "FAIL" -) - -// Filter for TLDs by category. -type RadarEmailSecurityTopTldSpamGetParamsTldCategory string - -const ( - RadarEmailSecurityTopTldSpamGetParamsTldCategoryClassic RadarEmailSecurityTopTldSpamGetParamsTldCategory = "CLASSIC" - RadarEmailSecurityTopTldSpamGetParamsTldCategoryCountry RadarEmailSecurityTopTldSpamGetParamsTldCategory = "COUNTRY" -) - -type RadarEmailSecurityTopTldSpamGetParamsTLSVersion string - -const ( - RadarEmailSecurityTopTldSpamGetParamsTLSVersionTlSv1_0 RadarEmailSecurityTopTldSpamGetParamsTLSVersion = "TLSv1_0" - RadarEmailSecurityTopTldSpamGetParamsTLSVersionTlSv1_1 RadarEmailSecurityTopTldSpamGetParamsTLSVersion = "TLSv1_1" - RadarEmailSecurityTopTldSpamGetParamsTLSVersionTlSv1_2 RadarEmailSecurityTopTldSpamGetParamsTLSVersion = "TLSv1_2" - RadarEmailSecurityTopTldSpamGetParamsTLSVersionTlSv1_3 RadarEmailSecurityTopTldSpamGetParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecurityTopTldSpamGetResponseEnvelope struct { - Result RadarEmailSecurityTopTldSpamGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecurityTopTldSpamGetResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecurityTopTldSpamGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarEmailSecurityTopTldSpamGetResponseEnvelope] -type radarEmailSecurityTopTldSpamGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldSpamGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldSpamGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radaremailsecuritytoptldspam_test.go b/radaremailsecuritytoptldspam_test.go deleted file mode 100644 index 796e78b2d01..00000000000 --- a/radaremailsecuritytoptldspam_test.go +++ /dev/null @@ -1,56 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarEmailSecurityTopTldSpamGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.Top.Tlds.Spam.Get( - context.TODO(), - cloudflare.RadarEmailSecurityTopTldSpamGetParamsSpamSpam, - cloudflare.RadarEmailSecurityTopTldSpamGetParams{ - ARC: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldSpamGetParamsARC{cloudflare.RadarEmailSecurityTopTldSpamGetParamsARCPass, cloudflare.RadarEmailSecurityTopTldSpamGetParamsARCNone, cloudflare.RadarEmailSecurityTopTldSpamGetParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldSpamGetParamsDateRange{cloudflare.RadarEmailSecurityTopTldSpamGetParamsDateRange1d, cloudflare.RadarEmailSecurityTopTldSpamGetParamsDateRange2d, cloudflare.RadarEmailSecurityTopTldSpamGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldSpamGetParamsDKIM{cloudflare.RadarEmailSecurityTopTldSpamGetParamsDKIMPass, cloudflare.RadarEmailSecurityTopTldSpamGetParamsDKIMNone, cloudflare.RadarEmailSecurityTopTldSpamGetParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldSpamGetParamsDMARC{cloudflare.RadarEmailSecurityTopTldSpamGetParamsDMARCPass, cloudflare.RadarEmailSecurityTopTldSpamGetParamsDMARCNone, cloudflare.RadarEmailSecurityTopTldSpamGetParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecurityTopTldSpamGetParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldSpamGetParamsSPF{cloudflare.RadarEmailSecurityTopTldSpamGetParamsSPFPass, cloudflare.RadarEmailSecurityTopTldSpamGetParamsSPFNone, cloudflare.RadarEmailSecurityTopTldSpamGetParamsSPFFail}), - TldCategory: cloudflare.F(cloudflare.RadarEmailSecurityTopTldSpamGetParamsTldCategoryClassic), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldSpamGetParamsTLSVersion{cloudflare.RadarEmailSecurityTopTldSpamGetParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecurityTopTldSpamGetParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecurityTopTldSpamGetParamsTLSVersionTlSv1_2}), - }, - ) - 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/radaremailsecuritytoptldspoof.go b/radaremailsecuritytoptldspoof.go deleted file mode 100644 index 87518dce3a7..00000000000 --- a/radaremailsecuritytoptldspoof.go +++ /dev/null @@ -1,348 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarEmailSecurityTopTldSpoofService 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 -// [NewRadarEmailSecurityTopTldSpoofService] method instead. -type RadarEmailSecurityTopTldSpoofService struct { - Options []option.RequestOption -} - -// NewRadarEmailSecurityTopTldSpoofService 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 NewRadarEmailSecurityTopTldSpoofService(opts ...option.RequestOption) (r *RadarEmailSecurityTopTldSpoofService) { - r = &RadarEmailSecurityTopTldSpoofService{} - r.Options = opts - return -} - -// Get the TLDs by emails classified as spoof or not. -func (r *RadarEmailSecurityTopTldSpoofService) Get(ctx context.Context, spoof RadarEmailSecurityTopTldSpoofGetParamsSpoof, query RadarEmailSecurityTopTldSpoofGetParams, opts ...option.RequestOption) (res *RadarEmailSecurityTopTldSpoofGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEmailSecurityTopTldSpoofGetResponseEnvelope - path := fmt.Sprintf("radar/email/security/top/tlds/spoof/%v", spoof) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarEmailSecurityTopTldSpoofGetResponse struct { - Meta RadarEmailSecurityTopTldSpoofGetResponseMeta `json:"meta,required"` - Top0 []RadarEmailSecurityTopTldSpoofGetResponseTop0 `json:"top_0,required"` - JSON radarEmailSecurityTopTldSpoofGetResponseJSON `json:"-"` -} - -// radarEmailSecurityTopTldSpoofGetResponseJSON contains the JSON metadata for the -// struct [RadarEmailSecurityTopTldSpoofGetResponse] -type radarEmailSecurityTopTldSpoofGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldSpoofGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldSpoofGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldSpoofGetResponseMeta struct { - DateRange []RadarEmailSecurityTopTldSpoofGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarEmailSecurityTopTldSpoofGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarEmailSecurityTopTldSpoofGetResponseMetaJSON `json:"-"` -} - -// radarEmailSecurityTopTldSpoofGetResponseMetaJSON contains the JSON metadata for -// the struct [RadarEmailSecurityTopTldSpoofGetResponseMeta] -type radarEmailSecurityTopTldSpoofGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldSpoofGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldSpoofGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldSpoofGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarEmailSecurityTopTldSpoofGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarEmailSecurityTopTldSpoofGetResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarEmailSecurityTopTldSpoofGetResponseMetaDateRange] -type radarEmailSecurityTopTldSpoofGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldSpoofGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldSpoofGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldSpoofGetResponseMetaConfidenceInfo struct { - Annotations []RadarEmailSecurityTopTldSpoofGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarEmailSecurityTopTldSpoofGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarEmailSecurityTopTldSpoofGetResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarEmailSecurityTopTldSpoofGetResponseMetaConfidenceInfo] -type radarEmailSecurityTopTldSpoofGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldSpoofGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldSpoofGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldSpoofGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarEmailSecurityTopTldSpoofGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarEmailSecurityTopTldSpoofGetResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarEmailSecurityTopTldSpoofGetResponseMetaConfidenceInfoAnnotation] -type radarEmailSecurityTopTldSpoofGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldSpoofGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldSpoofGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldSpoofGetResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON radarEmailSecurityTopTldSpoofGetResponseTop0JSON `json:"-"` -} - -// radarEmailSecurityTopTldSpoofGetResponseTop0JSON contains the JSON metadata for -// the struct [RadarEmailSecurityTopTldSpoofGetResponseTop0] -type radarEmailSecurityTopTldSpoofGetResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldSpoofGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldSpoofGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarEmailSecurityTopTldSpoofGetParams struct { - // Filter for arc (Authenticated Received Chain). - ARC param.Field[[]RadarEmailSecurityTopTldSpoofGetParamsARC] `query:"arc"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarEmailSecurityTopTldSpoofGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for dkim. - DKIM param.Field[[]RadarEmailSecurityTopTldSpoofGetParamsDKIM] `query:"dkim"` - // Filter for dmarc. - DMARC param.Field[[]RadarEmailSecurityTopTldSpoofGetParamsDMARC] `query:"dmarc"` - // Format results are returned in. - Format param.Field[RadarEmailSecurityTopTldSpoofGetParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for spf. - SPF param.Field[[]RadarEmailSecurityTopTldSpoofGetParamsSPF] `query:"spf"` - // Filter for TLDs by category. - TldCategory param.Field[RadarEmailSecurityTopTldSpoofGetParamsTldCategory] `query:"tldCategory"` - // Filter for tls version. - TLSVersion param.Field[[]RadarEmailSecurityTopTldSpoofGetParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarEmailSecurityTopTldSpoofGetParams]'s query parameters -// as `url.Values`. -func (r RadarEmailSecurityTopTldSpoofGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Spoof. -type RadarEmailSecurityTopTldSpoofGetParamsSpoof string - -const ( - RadarEmailSecurityTopTldSpoofGetParamsSpoofSpoof RadarEmailSecurityTopTldSpoofGetParamsSpoof = "SPOOF" - RadarEmailSecurityTopTldSpoofGetParamsSpoofNotSpoof RadarEmailSecurityTopTldSpoofGetParamsSpoof = "NOT_SPOOF" -) - -type RadarEmailSecurityTopTldSpoofGetParamsARC string - -const ( - RadarEmailSecurityTopTldSpoofGetParamsARCPass RadarEmailSecurityTopTldSpoofGetParamsARC = "PASS" - RadarEmailSecurityTopTldSpoofGetParamsARCNone RadarEmailSecurityTopTldSpoofGetParamsARC = "NONE" - RadarEmailSecurityTopTldSpoofGetParamsARCFail RadarEmailSecurityTopTldSpoofGetParamsARC = "FAIL" -) - -type RadarEmailSecurityTopTldSpoofGetParamsDateRange string - -const ( - RadarEmailSecurityTopTldSpoofGetParamsDateRange1d RadarEmailSecurityTopTldSpoofGetParamsDateRange = "1d" - RadarEmailSecurityTopTldSpoofGetParamsDateRange2d RadarEmailSecurityTopTldSpoofGetParamsDateRange = "2d" - RadarEmailSecurityTopTldSpoofGetParamsDateRange7d RadarEmailSecurityTopTldSpoofGetParamsDateRange = "7d" - RadarEmailSecurityTopTldSpoofGetParamsDateRange14d RadarEmailSecurityTopTldSpoofGetParamsDateRange = "14d" - RadarEmailSecurityTopTldSpoofGetParamsDateRange28d RadarEmailSecurityTopTldSpoofGetParamsDateRange = "28d" - RadarEmailSecurityTopTldSpoofGetParamsDateRange12w RadarEmailSecurityTopTldSpoofGetParamsDateRange = "12w" - RadarEmailSecurityTopTldSpoofGetParamsDateRange24w RadarEmailSecurityTopTldSpoofGetParamsDateRange = "24w" - RadarEmailSecurityTopTldSpoofGetParamsDateRange52w RadarEmailSecurityTopTldSpoofGetParamsDateRange = "52w" - RadarEmailSecurityTopTldSpoofGetParamsDateRange1dControl RadarEmailSecurityTopTldSpoofGetParamsDateRange = "1dControl" - RadarEmailSecurityTopTldSpoofGetParamsDateRange2dControl RadarEmailSecurityTopTldSpoofGetParamsDateRange = "2dControl" - RadarEmailSecurityTopTldSpoofGetParamsDateRange7dControl RadarEmailSecurityTopTldSpoofGetParamsDateRange = "7dControl" - RadarEmailSecurityTopTldSpoofGetParamsDateRange14dControl RadarEmailSecurityTopTldSpoofGetParamsDateRange = "14dControl" - RadarEmailSecurityTopTldSpoofGetParamsDateRange28dControl RadarEmailSecurityTopTldSpoofGetParamsDateRange = "28dControl" - RadarEmailSecurityTopTldSpoofGetParamsDateRange12wControl RadarEmailSecurityTopTldSpoofGetParamsDateRange = "12wControl" - RadarEmailSecurityTopTldSpoofGetParamsDateRange24wControl RadarEmailSecurityTopTldSpoofGetParamsDateRange = "24wControl" -) - -type RadarEmailSecurityTopTldSpoofGetParamsDKIM string - -const ( - RadarEmailSecurityTopTldSpoofGetParamsDKIMPass RadarEmailSecurityTopTldSpoofGetParamsDKIM = "PASS" - RadarEmailSecurityTopTldSpoofGetParamsDKIMNone RadarEmailSecurityTopTldSpoofGetParamsDKIM = "NONE" - RadarEmailSecurityTopTldSpoofGetParamsDKIMFail RadarEmailSecurityTopTldSpoofGetParamsDKIM = "FAIL" -) - -type RadarEmailSecurityTopTldSpoofGetParamsDMARC string - -const ( - RadarEmailSecurityTopTldSpoofGetParamsDMARCPass RadarEmailSecurityTopTldSpoofGetParamsDMARC = "PASS" - RadarEmailSecurityTopTldSpoofGetParamsDMARCNone RadarEmailSecurityTopTldSpoofGetParamsDMARC = "NONE" - RadarEmailSecurityTopTldSpoofGetParamsDMARCFail RadarEmailSecurityTopTldSpoofGetParamsDMARC = "FAIL" -) - -// Format results are returned in. -type RadarEmailSecurityTopTldSpoofGetParamsFormat string - -const ( - RadarEmailSecurityTopTldSpoofGetParamsFormatJson RadarEmailSecurityTopTldSpoofGetParamsFormat = "JSON" - RadarEmailSecurityTopTldSpoofGetParamsFormatCsv RadarEmailSecurityTopTldSpoofGetParamsFormat = "CSV" -) - -type RadarEmailSecurityTopTldSpoofGetParamsSPF string - -const ( - RadarEmailSecurityTopTldSpoofGetParamsSPFPass RadarEmailSecurityTopTldSpoofGetParamsSPF = "PASS" - RadarEmailSecurityTopTldSpoofGetParamsSPFNone RadarEmailSecurityTopTldSpoofGetParamsSPF = "NONE" - RadarEmailSecurityTopTldSpoofGetParamsSPFFail RadarEmailSecurityTopTldSpoofGetParamsSPF = "FAIL" -) - -// Filter for TLDs by category. -type RadarEmailSecurityTopTldSpoofGetParamsTldCategory string - -const ( - RadarEmailSecurityTopTldSpoofGetParamsTldCategoryClassic RadarEmailSecurityTopTldSpoofGetParamsTldCategory = "CLASSIC" - RadarEmailSecurityTopTldSpoofGetParamsTldCategoryCountry RadarEmailSecurityTopTldSpoofGetParamsTldCategory = "COUNTRY" -) - -type RadarEmailSecurityTopTldSpoofGetParamsTLSVersion string - -const ( - RadarEmailSecurityTopTldSpoofGetParamsTLSVersionTlSv1_0 RadarEmailSecurityTopTldSpoofGetParamsTLSVersion = "TLSv1_0" - RadarEmailSecurityTopTldSpoofGetParamsTLSVersionTlSv1_1 RadarEmailSecurityTopTldSpoofGetParamsTLSVersion = "TLSv1_1" - RadarEmailSecurityTopTldSpoofGetParamsTLSVersionTlSv1_2 RadarEmailSecurityTopTldSpoofGetParamsTLSVersion = "TLSv1_2" - RadarEmailSecurityTopTldSpoofGetParamsTLSVersionTlSv1_3 RadarEmailSecurityTopTldSpoofGetParamsTLSVersion = "TLSv1_3" -) - -type RadarEmailSecurityTopTldSpoofGetResponseEnvelope struct { - Result RadarEmailSecurityTopTldSpoofGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEmailSecurityTopTldSpoofGetResponseEnvelopeJSON `json:"-"` -} - -// radarEmailSecurityTopTldSpoofGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarEmailSecurityTopTldSpoofGetResponseEnvelope] -type radarEmailSecurityTopTldSpoofGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEmailSecurityTopTldSpoofGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEmailSecurityTopTldSpoofGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radaremailsecuritytoptldspoof_test.go b/radaremailsecuritytoptldspoof_test.go deleted file mode 100644 index 032f335c306..00000000000 --- a/radaremailsecuritytoptldspoof_test.go +++ /dev/null @@ -1,56 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarEmailSecurityTopTldSpoofGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Email.Security.Top.Tlds.Spoof.Get( - context.TODO(), - cloudflare.RadarEmailSecurityTopTldSpoofGetParamsSpoofSpoof, - cloudflare.RadarEmailSecurityTopTldSpoofGetParams{ - ARC: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldSpoofGetParamsARC{cloudflare.RadarEmailSecurityTopTldSpoofGetParamsARCPass, cloudflare.RadarEmailSecurityTopTldSpoofGetParamsARCNone, cloudflare.RadarEmailSecurityTopTldSpoofGetParamsARCFail}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldSpoofGetParamsDateRange{cloudflare.RadarEmailSecurityTopTldSpoofGetParamsDateRange1d, cloudflare.RadarEmailSecurityTopTldSpoofGetParamsDateRange2d, cloudflare.RadarEmailSecurityTopTldSpoofGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DKIM: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldSpoofGetParamsDKIM{cloudflare.RadarEmailSecurityTopTldSpoofGetParamsDKIMPass, cloudflare.RadarEmailSecurityTopTldSpoofGetParamsDKIMNone, cloudflare.RadarEmailSecurityTopTldSpoofGetParamsDKIMFail}), - DMARC: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldSpoofGetParamsDMARC{cloudflare.RadarEmailSecurityTopTldSpoofGetParamsDMARCPass, cloudflare.RadarEmailSecurityTopTldSpoofGetParamsDMARCNone, cloudflare.RadarEmailSecurityTopTldSpoofGetParamsDMARCFail}), - Format: cloudflare.F(cloudflare.RadarEmailSecurityTopTldSpoofGetParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Name: cloudflare.F([]string{"string", "string", "string"}), - SPF: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldSpoofGetParamsSPF{cloudflare.RadarEmailSecurityTopTldSpoofGetParamsSPFPass, cloudflare.RadarEmailSecurityTopTldSpoofGetParamsSPFNone, cloudflare.RadarEmailSecurityTopTldSpoofGetParamsSPFFail}), - TldCategory: cloudflare.F(cloudflare.RadarEmailSecurityTopTldSpoofGetParamsTldCategoryClassic), - TLSVersion: cloudflare.F([]cloudflare.RadarEmailSecurityTopTldSpoofGetParamsTLSVersion{cloudflare.RadarEmailSecurityTopTldSpoofGetParamsTLSVersionTlSv1_0, cloudflare.RadarEmailSecurityTopTldSpoofGetParamsTLSVersionTlSv1_1, cloudflare.RadarEmailSecurityTopTldSpoofGetParamsTLSVersionTlSv1_2}), - }, - ) - 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/radarentity.go b/radarentity.go deleted file mode 100644 index 1245b39160d..00000000000 --- a/radarentity.go +++ /dev/null @@ -1,152 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarEntityService 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 [NewRadarEntityService] method -// instead. -type RadarEntityService struct { - Options []option.RequestOption - ASNs *RadarEntityASNService - Locations *RadarEntityLocationService -} - -// NewRadarEntityService 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 NewRadarEntityService(opts ...option.RequestOption) (r *RadarEntityService) { - r = &RadarEntityService{} - r.Options = opts - r.ASNs = NewRadarEntityASNService(opts...) - r.Locations = NewRadarEntityLocationService(opts...) - return -} - -// Get IP address information. -func (r *RadarEntityService) Get(ctx context.Context, query RadarEntityGetParams, opts ...option.RequestOption) (res *RadarEntityGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEntityGetResponseEnvelope - path := "radar/entities/ip" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarEntityGetResponse struct { - IP RadarEntityGetResponseIP `json:"ip,required"` - JSON radarEntityGetResponseJSON `json:"-"` -} - -// radarEntityGetResponseJSON contains the JSON metadata for the struct -// [RadarEntityGetResponse] -type radarEntityGetResponseJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEntityGetResponseIP struct { - ASN string `json:"asn,required"` - ASNLocation string `json:"asnLocation,required"` - ASNName string `json:"asnName,required"` - ASNOrgName string `json:"asnOrgName,required"` - IP string `json:"ip,required"` - IPVersion string `json:"ipVersion,required"` - Location string `json:"location,required"` - LocationName string `json:"locationName,required"` - JSON radarEntityGetResponseIPJSON `json:"-"` -} - -// radarEntityGetResponseIPJSON contains the JSON metadata for the struct -// [RadarEntityGetResponseIP] -type radarEntityGetResponseIPJSON struct { - ASN apijson.Field - ASNLocation apijson.Field - ASNName apijson.Field - ASNOrgName apijson.Field - IP apijson.Field - IPVersion apijson.Field - Location apijson.Field - LocationName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityGetResponseIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityGetResponseIPJSON) RawJSON() string { - return r.raw -} - -type RadarEntityGetParams struct { - // IP address. - IP param.Field[string] `query:"ip,required"` - // Format results are returned in. - Format param.Field[RadarEntityGetParamsFormat] `query:"format"` -} - -// URLQuery serializes [RadarEntityGetParams]'s query parameters as `url.Values`. -func (r RadarEntityGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Format results are returned in. -type RadarEntityGetParamsFormat string - -const ( - RadarEntityGetParamsFormatJson RadarEntityGetParamsFormat = "JSON" - RadarEntityGetParamsFormatCsv RadarEntityGetParamsFormat = "CSV" -) - -type RadarEntityGetResponseEnvelope struct { - Result RadarEntityGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEntityGetResponseEnvelopeJSON `json:"-"` -} - -// radarEntityGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [RadarEntityGetResponseEnvelope] -type radarEntityGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarentity_test.go b/radarentity_test.go deleted file mode 100644 index 7b801700a77..00000000000 --- a/radarentity_test.go +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarEntityGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Entities.Get(context.TODO(), cloudflare.RadarEntityGetParams{ - IP: cloudflare.F("8.8.8.8"), - Format: cloudflare.F(cloudflare.RadarEntityGetParamsFormatJson), - }) - 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/radarentityasn.go b/radarentityasn.go deleted file mode 100644 index 867c15f01f7..00000000000 --- a/radarentityasn.go +++ /dev/null @@ -1,715 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarEntityASNService 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 [NewRadarEntityASNService] method -// instead. -type RadarEntityASNService struct { - Options []option.RequestOption -} - -// NewRadarEntityASNService 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 NewRadarEntityASNService(opts ...option.RequestOption) (r *RadarEntityASNService) { - r = &RadarEntityASNService{} - r.Options = opts - return -} - -// Gets a list of autonomous systems (AS). -func (r *RadarEntityASNService) List(ctx context.Context, query RadarEntityASNListParams, opts ...option.RequestOption) (res *RadarEntityASNListResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEntityASNListResponseEnvelope - path := "radar/entities/asns" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the requested autonomous system information. A confidence level below `5` -// indicates a low level of confidence in the traffic data - normally this happens -// because Cloudflare has a small amount of traffic from/to this AS). Population -// estimates come from APNIC (refer to https://labs.apnic.net/?p=526). -func (r *RadarEntityASNService) Get(ctx context.Context, asn int64, query RadarEntityASNGetParams, opts ...option.RequestOption) (res *RadarEntityASNGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEntityASNGetResponseEnvelope - path := fmt.Sprintf("radar/entities/asns/%v", asn) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the requested autonomous system information based on IP address. Population -// estimates come from APNIC (refer to https://labs.apnic.net/?p=526). -func (r *RadarEntityASNService) IP(ctx context.Context, query RadarEntityASNIPParams, opts ...option.RequestOption) (res *RadarEntityAsnipResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEntityAsnipResponseEnvelope - path := "radar/entities/asns/ip" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get AS-level relationship for given networks. -func (r *RadarEntityASNService) Rel(ctx context.Context, asn int64, query RadarEntityASNRelParams, opts ...option.RequestOption) (res *RadarEntityASNRelResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEntityASNRelResponseEnvelope - path := fmt.Sprintf("radar/entities/asns/%v/rel", asn) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarEntityASNListResponse struct { - ASNs []RadarEntityASNListResponseASN `json:"asns,required"` - JSON radarEntityASNListResponseJSON `json:"-"` -} - -// radarEntityASNListResponseJSON contains the JSON metadata for the struct -// [RadarEntityASNListResponse] -type radarEntityASNListResponseJSON struct { - ASNs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityASNListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityASNListResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEntityASNListResponseASN struct { - ASN int64 `json:"asn,required"` - Country string `json:"country,required"` - CountryName string `json:"countryName,required"` - Name string `json:"name,required"` - Aka string `json:"aka"` - // Deprecated field. Please use 'aka'. - NameLong string `json:"nameLong"` - OrgName string `json:"orgName"` - Website string `json:"website"` - JSON radarEntityASNListResponseASNJSON `json:"-"` -} - -// radarEntityASNListResponseASNJSON contains the JSON metadata for the struct -// [RadarEntityASNListResponseASN] -type radarEntityASNListResponseASNJSON struct { - ASN apijson.Field - Country apijson.Field - CountryName apijson.Field - Name apijson.Field - Aka apijson.Field - NameLong apijson.Field - OrgName apijson.Field - Website apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityASNListResponseASN) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityASNListResponseASNJSON) RawJSON() string { - return r.raw -} - -type RadarEntityASNGetResponse struct { - ASN RadarEntityASNGetResponseASN `json:"asn,required"` - JSON radarEntityASNGetResponseJSON `json:"-"` -} - -// radarEntityASNGetResponseJSON contains the JSON metadata for the struct -// [RadarEntityASNGetResponse] -type radarEntityASNGetResponseJSON struct { - ASN apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityASNGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityASNGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEntityASNGetResponseASN struct { - ASN int64 `json:"asn,required"` - ConfidenceLevel int64 `json:"confidenceLevel,required"` - Country string `json:"country,required"` - CountryName string `json:"countryName,required"` - EstimatedUsers RadarEntityASNGetResponseASNEstimatedUsers `json:"estimatedUsers,required"` - Name string `json:"name,required"` - OrgName string `json:"orgName,required"` - Related []RadarEntityASNGetResponseASNRelated `json:"related,required"` - // Regional Internet Registry - Source string `json:"source,required"` - Website string `json:"website,required"` - Aka string `json:"aka"` - // Deprecated field. Please use 'aka'. - NameLong string `json:"nameLong"` - JSON radarEntityASNGetResponseASNJSON `json:"-"` -} - -// radarEntityASNGetResponseASNJSON contains the JSON metadata for the struct -// [RadarEntityASNGetResponseASN] -type radarEntityASNGetResponseASNJSON struct { - ASN apijson.Field - ConfidenceLevel apijson.Field - Country apijson.Field - CountryName apijson.Field - EstimatedUsers apijson.Field - Name apijson.Field - OrgName apijson.Field - Related apijson.Field - Source apijson.Field - Website apijson.Field - Aka apijson.Field - NameLong apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityASNGetResponseASN) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityASNGetResponseASNJSON) RawJSON() string { - return r.raw -} - -type RadarEntityASNGetResponseASNEstimatedUsers struct { - Locations []RadarEntityASNGetResponseASNEstimatedUsersLocation `json:"locations,required"` - // Total estimated users - EstimatedUsers int64 `json:"estimatedUsers"` - JSON radarEntityASNGetResponseASNEstimatedUsersJSON `json:"-"` -} - -// radarEntityASNGetResponseASNEstimatedUsersJSON contains the JSON metadata for -// the struct [RadarEntityASNGetResponseASNEstimatedUsers] -type radarEntityASNGetResponseASNEstimatedUsersJSON struct { - Locations apijson.Field - EstimatedUsers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityASNGetResponseASNEstimatedUsers) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityASNGetResponseASNEstimatedUsersJSON) RawJSON() string { - return r.raw -} - -type RadarEntityASNGetResponseASNEstimatedUsersLocation struct { - LocationAlpha2 string `json:"locationAlpha2,required"` - LocationName string `json:"locationName,required"` - // Estimated users per location - EstimatedUsers int64 `json:"estimatedUsers"` - JSON radarEntityASNGetResponseASNEstimatedUsersLocationJSON `json:"-"` -} - -// radarEntityASNGetResponseASNEstimatedUsersLocationJSON contains the JSON -// metadata for the struct [RadarEntityASNGetResponseASNEstimatedUsersLocation] -type radarEntityASNGetResponseASNEstimatedUsersLocationJSON struct { - LocationAlpha2 apijson.Field - LocationName apijson.Field - EstimatedUsers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityASNGetResponseASNEstimatedUsersLocation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityASNGetResponseASNEstimatedUsersLocationJSON) RawJSON() string { - return r.raw -} - -type RadarEntityASNGetResponseASNRelated struct { - ASN int64 `json:"asn,required"` - Name string `json:"name,required"` - Aka string `json:"aka"` - // Total estimated users - EstimatedUsers int64 `json:"estimatedUsers"` - JSON radarEntityASNGetResponseASNRelatedJSON `json:"-"` -} - -// radarEntityASNGetResponseASNRelatedJSON contains the JSON metadata for the -// struct [RadarEntityASNGetResponseASNRelated] -type radarEntityASNGetResponseASNRelatedJSON struct { - ASN apijson.Field - Name apijson.Field - Aka apijson.Field - EstimatedUsers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityASNGetResponseASNRelated) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityASNGetResponseASNRelatedJSON) RawJSON() string { - return r.raw -} - -type RadarEntityAsnipResponse struct { - ASN RadarEntityAsnipResponseASN `json:"asn,required"` - JSON radarEntityAsnipResponseJSON `json:"-"` -} - -// radarEntityAsnipResponseJSON contains the JSON metadata for the struct -// [RadarEntityAsnipResponse] -type radarEntityAsnipResponseJSON struct { - ASN apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityAsnipResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityAsnipResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEntityAsnipResponseASN struct { - ASN int64 `json:"asn,required"` - Country string `json:"country,required"` - CountryName string `json:"countryName,required"` - EstimatedUsers RadarEntityAsnipResponseASNEstimatedUsers `json:"estimatedUsers,required"` - Name string `json:"name,required"` - OrgName string `json:"orgName,required"` - Related []RadarEntityAsnipResponseASNRelated `json:"related,required"` - // Regional Internet Registry - Source string `json:"source,required"` - Website string `json:"website,required"` - Aka string `json:"aka"` - // Deprecated field. Please use 'aka'. - NameLong string `json:"nameLong"` - JSON radarEntityAsnipResponseASNJSON `json:"-"` -} - -// radarEntityAsnipResponseASNJSON contains the JSON metadata for the struct -// [RadarEntityAsnipResponseASN] -type radarEntityAsnipResponseASNJSON struct { - ASN apijson.Field - Country apijson.Field - CountryName apijson.Field - EstimatedUsers apijson.Field - Name apijson.Field - OrgName apijson.Field - Related apijson.Field - Source apijson.Field - Website apijson.Field - Aka apijson.Field - NameLong apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityAsnipResponseASN) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityAsnipResponseASNJSON) RawJSON() string { - return r.raw -} - -type RadarEntityAsnipResponseASNEstimatedUsers struct { - Locations []RadarEntityAsnipResponseASNEstimatedUsersLocation `json:"locations,required"` - // Total estimated users - EstimatedUsers int64 `json:"estimatedUsers"` - JSON radarEntityAsnipResponseASNEstimatedUsersJSON `json:"-"` -} - -// radarEntityAsnipResponseASNEstimatedUsersJSON contains the JSON metadata for the -// struct [RadarEntityAsnipResponseASNEstimatedUsers] -type radarEntityAsnipResponseASNEstimatedUsersJSON struct { - Locations apijson.Field - EstimatedUsers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityAsnipResponseASNEstimatedUsers) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityAsnipResponseASNEstimatedUsersJSON) RawJSON() string { - return r.raw -} - -type RadarEntityAsnipResponseASNEstimatedUsersLocation struct { - LocationAlpha2 string `json:"locationAlpha2,required"` - LocationName string `json:"locationName,required"` - // Estimated users per location - EstimatedUsers int64 `json:"estimatedUsers"` - JSON radarEntityAsnipResponseASNEstimatedUsersLocationJSON `json:"-"` -} - -// radarEntityAsnipResponseASNEstimatedUsersLocationJSON contains the JSON metadata -// for the struct [RadarEntityAsnipResponseASNEstimatedUsersLocation] -type radarEntityAsnipResponseASNEstimatedUsersLocationJSON struct { - LocationAlpha2 apijson.Field - LocationName apijson.Field - EstimatedUsers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityAsnipResponseASNEstimatedUsersLocation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityAsnipResponseASNEstimatedUsersLocationJSON) RawJSON() string { - return r.raw -} - -type RadarEntityAsnipResponseASNRelated struct { - ASN int64 `json:"asn,required"` - Name string `json:"name,required"` - Aka string `json:"aka"` - // Total estimated users - EstimatedUsers int64 `json:"estimatedUsers"` - JSON radarEntityAsnipResponseASNRelatedJSON `json:"-"` -} - -// radarEntityAsnipResponseASNRelatedJSON contains the JSON metadata for the struct -// [RadarEntityAsnipResponseASNRelated] -type radarEntityAsnipResponseASNRelatedJSON struct { - ASN apijson.Field - Name apijson.Field - Aka apijson.Field - EstimatedUsers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityAsnipResponseASNRelated) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityAsnipResponseASNRelatedJSON) RawJSON() string { - return r.raw -} - -type RadarEntityASNRelResponse struct { - Meta RadarEntityASNRelResponseMeta `json:"meta,required"` - Rels []RadarEntityASNRelResponseRel `json:"rels,required"` - JSON radarEntityASNRelResponseJSON `json:"-"` -} - -// radarEntityASNRelResponseJSON contains the JSON metadata for the struct -// [RadarEntityASNRelResponse] -type radarEntityASNRelResponseJSON struct { - Meta apijson.Field - Rels apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityASNRelResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityASNRelResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEntityASNRelResponseMeta struct { - DataTime string `json:"data_time,required"` - QueryTime string `json:"query_time,required"` - TotalPeers int64 `json:"total_peers,required"` - JSON radarEntityASNRelResponseMetaJSON `json:"-"` -} - -// radarEntityASNRelResponseMetaJSON contains the JSON metadata for the struct -// [RadarEntityASNRelResponseMeta] -type radarEntityASNRelResponseMetaJSON struct { - DataTime apijson.Field - QueryTime apijson.Field - TotalPeers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityASNRelResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityASNRelResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarEntityASNRelResponseRel struct { - Asn1 int64 `json:"asn1,required"` - Asn1Country string `json:"asn1_country,required"` - Asn1Name string `json:"asn1_name,required"` - Asn2 int64 `json:"asn2,required"` - Asn2Country string `json:"asn2_country,required"` - Asn2Name string `json:"asn2_name,required"` - Rel string `json:"rel,required"` - JSON radarEntityASNRelResponseRelJSON `json:"-"` -} - -// radarEntityASNRelResponseRelJSON contains the JSON metadata for the struct -// [RadarEntityASNRelResponseRel] -type radarEntityASNRelResponseRelJSON struct { - Asn1 apijson.Field - Asn1Country apijson.Field - Asn1Name apijson.Field - Asn2 apijson.Field - Asn2Country apijson.Field - Asn2Name apijson.Field - Rel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityASNRelResponseRel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityASNRelResponseRelJSON) RawJSON() string { - return r.raw -} - -type RadarEntityASNListParams struct { - // Comma separated list of ASNs. - ASN param.Field[string] `query:"asn"` - // Format results are returned in. - Format param.Field[RadarEntityASNListParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Location Alpha2 to filter results. - Location param.Field[string] `query:"location"` - // Number of objects to skip before grabbing results. - Offset param.Field[int64] `query:"offset"` - // Order asn list. - OrderBy param.Field[RadarEntityASNListParamsOrderBy] `query:"orderBy"` -} - -// URLQuery serializes [RadarEntityASNListParams]'s query parameters as -// `url.Values`. -func (r RadarEntityASNListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Format results are returned in. -type RadarEntityASNListParamsFormat string - -const ( - RadarEntityASNListParamsFormatJson RadarEntityASNListParamsFormat = "JSON" - RadarEntityASNListParamsFormatCsv RadarEntityASNListParamsFormat = "CSV" -) - -// Order asn list. -type RadarEntityASNListParamsOrderBy string - -const ( - RadarEntityASNListParamsOrderByASN RadarEntityASNListParamsOrderBy = "ASN" - RadarEntityASNListParamsOrderByPopulation RadarEntityASNListParamsOrderBy = "POPULATION" -) - -type RadarEntityASNListResponseEnvelope struct { - Result RadarEntityASNListResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEntityASNListResponseEnvelopeJSON `json:"-"` -} - -// radarEntityASNListResponseEnvelopeJSON contains the JSON metadata for the struct -// [RadarEntityASNListResponseEnvelope] -type radarEntityASNListResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityASNListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityASNListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEntityASNGetParams struct { - // Format results are returned in. - Format param.Field[RadarEntityASNGetParamsFormat] `query:"format"` -} - -// URLQuery serializes [RadarEntityASNGetParams]'s query parameters as -// `url.Values`. -func (r RadarEntityASNGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Format results are returned in. -type RadarEntityASNGetParamsFormat string - -const ( - RadarEntityASNGetParamsFormatJson RadarEntityASNGetParamsFormat = "JSON" - RadarEntityASNGetParamsFormatCsv RadarEntityASNGetParamsFormat = "CSV" -) - -type RadarEntityASNGetResponseEnvelope struct { - Result RadarEntityASNGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEntityASNGetResponseEnvelopeJSON `json:"-"` -} - -// radarEntityASNGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [RadarEntityASNGetResponseEnvelope] -type radarEntityASNGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityASNGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityASNGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEntityASNIPParams struct { - // IP address. - IP param.Field[string] `query:"ip,required"` - // Format results are returned in. - Format param.Field[RadarEntityAsnipParamsFormat] `query:"format"` -} - -// URLQuery serializes [RadarEntityASNIPParams]'s query parameters as `url.Values`. -func (r RadarEntityASNIPParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Format results are returned in. -type RadarEntityAsnipParamsFormat string - -const ( - RadarEntityAsnipParamsFormatJson RadarEntityAsnipParamsFormat = "JSON" - RadarEntityAsnipParamsFormatCsv RadarEntityAsnipParamsFormat = "CSV" -) - -type RadarEntityAsnipResponseEnvelope struct { - Result RadarEntityAsnipResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEntityAsnipResponseEnvelopeJSON `json:"-"` -} - -// radarEntityAsnipResponseEnvelopeJSON contains the JSON metadata for the struct -// [RadarEntityAsnipResponseEnvelope] -type radarEntityAsnipResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityAsnipResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityAsnipResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEntityASNRelParams struct { - // Get the AS relationship of ASN2 with respect to the given ASN - Asn2 param.Field[int64] `query:"asn2"` - // Format results are returned in. - Format param.Field[RadarEntityASNRelParamsFormat] `query:"format"` -} - -// URLQuery serializes [RadarEntityASNRelParams]'s query parameters as -// `url.Values`. -func (r RadarEntityASNRelParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Format results are returned in. -type RadarEntityASNRelParamsFormat string - -const ( - RadarEntityASNRelParamsFormatJson RadarEntityASNRelParamsFormat = "JSON" - RadarEntityASNRelParamsFormatCsv RadarEntityASNRelParamsFormat = "CSV" -) - -type RadarEntityASNRelResponseEnvelope struct { - Result RadarEntityASNRelResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEntityASNRelResponseEnvelopeJSON `json:"-"` -} - -// radarEntityASNRelResponseEnvelopeJSON contains the JSON metadata for the struct -// [RadarEntityASNRelResponseEnvelope] -type radarEntityASNRelResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityASNRelResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityASNRelResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarentityasn_test.go b/radarentityasn_test.go deleted file mode 100644 index 20266650313..00000000000 --- a/radarentityasn_test.go +++ /dev/null @@ -1,133 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarEntityASNListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Entities.ASNs.List(context.TODO(), cloudflare.RadarEntityASNListParams{ - ASN: cloudflare.F("174,7922"), - Format: cloudflare.F(cloudflare.RadarEntityASNListParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F("US"), - Offset: cloudflare.F(int64(0)), - OrderBy: cloudflare.F(cloudflare.RadarEntityASNListParamsOrderByASN), - }) - 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 TestRadarEntityASNGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Entities.ASNs.Get( - context.TODO(), - int64(3), - cloudflare.RadarEntityASNGetParams{ - Format: cloudflare.F(cloudflare.RadarEntityASNGetParamsFormatJson), - }, - ) - 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 TestRadarEntityASNIPWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Entities.ASNs.IP(context.TODO(), cloudflare.RadarEntityASNIPParams{ - IP: cloudflare.F("8.8.8.8"), - Format: cloudflare.F(cloudflare.RadarEntityAsnipParamsFormatJson), - }) - 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 TestRadarEntityASNRelWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Entities.ASNs.Rel( - context.TODO(), - int64(3), - cloudflare.RadarEntityASNRelParams{ - Asn2: cloudflare.F(int64(0)), - Format: cloudflare.F(cloudflare.RadarEntityASNRelParamsFormatJson), - }, - ) - 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/radarentitylocation.go b/radarentitylocation.go deleted file mode 100644 index c68976392a8..00000000000 --- a/radarentitylocation.go +++ /dev/null @@ -1,260 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarEntityLocationService 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 [NewRadarEntityLocationService] -// method instead. -type RadarEntityLocationService struct { - Options []option.RequestOption -} - -// NewRadarEntityLocationService 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 NewRadarEntityLocationService(opts ...option.RequestOption) (r *RadarEntityLocationService) { - r = &RadarEntityLocationService{} - r.Options = opts - return -} - -// Get a list of locations. -func (r *RadarEntityLocationService) List(ctx context.Context, query RadarEntityLocationListParams, opts ...option.RequestOption) (res *RadarEntityLocationListResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEntityLocationListResponseEnvelope - path := "radar/entities/locations" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the requested location information. A confidence level below `5` indicates a -// low level of confidence in the traffic data - normally this happens because -// Cloudflare has a small amount of traffic from/to this location). -func (r *RadarEntityLocationService) Get(ctx context.Context, location string, query RadarEntityLocationGetParams, opts ...option.RequestOption) (res *RadarEntityLocationGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarEntityLocationGetResponseEnvelope - path := fmt.Sprintf("radar/entities/locations/%s", location) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarEntityLocationListResponse struct { - Locations []RadarEntityLocationListResponseLocation `json:"locations,required"` - JSON radarEntityLocationListResponseJSON `json:"-"` -} - -// radarEntityLocationListResponseJSON contains the JSON metadata for the struct -// [RadarEntityLocationListResponse] -type radarEntityLocationListResponseJSON struct { - Locations apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityLocationListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityLocationListResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEntityLocationListResponseLocation struct { - Alpha2 string `json:"alpha2,required"` - Latitude string `json:"latitude,required"` - Longitude string `json:"longitude,required"` - Name string `json:"name,required"` - JSON radarEntityLocationListResponseLocationJSON `json:"-"` -} - -// radarEntityLocationListResponseLocationJSON contains the JSON metadata for the -// struct [RadarEntityLocationListResponseLocation] -type radarEntityLocationListResponseLocationJSON struct { - Alpha2 apijson.Field - Latitude apijson.Field - Longitude apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityLocationListResponseLocation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityLocationListResponseLocationJSON) RawJSON() string { - return r.raw -} - -type RadarEntityLocationGetResponse struct { - Location RadarEntityLocationGetResponseLocation `json:"location,required"` - JSON radarEntityLocationGetResponseJSON `json:"-"` -} - -// radarEntityLocationGetResponseJSON contains the JSON metadata for the struct -// [RadarEntityLocationGetResponse] -type radarEntityLocationGetResponseJSON struct { - Location apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityLocationGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityLocationGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarEntityLocationGetResponseLocation struct { - Alpha2 string `json:"alpha2,required"` - ConfidenceLevel int64 `json:"confidenceLevel,required"` - Latitude string `json:"latitude,required"` - Longitude string `json:"longitude,required"` - Name string `json:"name,required"` - Region string `json:"region,required"` - Subregion string `json:"subregion,required"` - JSON radarEntityLocationGetResponseLocationJSON `json:"-"` -} - -// radarEntityLocationGetResponseLocationJSON contains the JSON metadata for the -// struct [RadarEntityLocationGetResponseLocation] -type radarEntityLocationGetResponseLocationJSON struct { - Alpha2 apijson.Field - ConfidenceLevel apijson.Field - Latitude apijson.Field - Longitude apijson.Field - Name apijson.Field - Region apijson.Field - Subregion apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityLocationGetResponseLocation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityLocationGetResponseLocationJSON) RawJSON() string { - return r.raw -} - -type RadarEntityLocationListParams struct { - // Format results are returned in. - Format param.Field[RadarEntityLocationListParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Comma separated list of locations. - Location param.Field[string] `query:"location"` - // Number of objects to skip before grabbing results. - Offset param.Field[int64] `query:"offset"` -} - -// URLQuery serializes [RadarEntityLocationListParams]'s query parameters as -// `url.Values`. -func (r RadarEntityLocationListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Format results are returned in. -type RadarEntityLocationListParamsFormat string - -const ( - RadarEntityLocationListParamsFormatJson RadarEntityLocationListParamsFormat = "JSON" - RadarEntityLocationListParamsFormatCsv RadarEntityLocationListParamsFormat = "CSV" -) - -type RadarEntityLocationListResponseEnvelope struct { - Result RadarEntityLocationListResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEntityLocationListResponseEnvelopeJSON `json:"-"` -} - -// radarEntityLocationListResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarEntityLocationListResponseEnvelope] -type radarEntityLocationListResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityLocationListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityLocationListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarEntityLocationGetParams struct { - // Format results are returned in. - Format param.Field[RadarEntityLocationGetParamsFormat] `query:"format"` -} - -// URLQuery serializes [RadarEntityLocationGetParams]'s query parameters as -// `url.Values`. -func (r RadarEntityLocationGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Format results are returned in. -type RadarEntityLocationGetParamsFormat string - -const ( - RadarEntityLocationGetParamsFormatJson RadarEntityLocationGetParamsFormat = "JSON" - RadarEntityLocationGetParamsFormatCsv RadarEntityLocationGetParamsFormat = "CSV" -) - -type RadarEntityLocationGetResponseEnvelope struct { - Result RadarEntityLocationGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarEntityLocationGetResponseEnvelopeJSON `json:"-"` -} - -// radarEntityLocationGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarEntityLocationGetResponseEnvelope] -type radarEntityLocationGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarEntityLocationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarEntityLocationGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarentitylocation_test.go b/radarentitylocation_test.go deleted file mode 100644 index 65b29b8bd9e..00000000000 --- a/radarentitylocation_test.go +++ /dev/null @@ -1,73 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarEntityLocationListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Entities.Locations.List(context.TODO(), cloudflare.RadarEntityLocationListParams{ - Format: cloudflare.F(cloudflare.RadarEntityLocationListParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F("US,CA"), - Offset: cloudflare.F(int64(0)), - }) - 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 TestRadarEntityLocationGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Entities.Locations.Get( - context.TODO(), - "US", - cloudflare.RadarEntityLocationGetParams{ - Format: cloudflare.F(cloudflare.RadarEntityLocationGetParamsFormatJson), - }, - ) - 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/radarhttp.go b/radarhttp.go deleted file mode 100644 index 9599d89a568..00000000000 --- a/radarhttp.go +++ /dev/null @@ -1,34 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPService 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 [NewRadarHTTPService] method instead. -type RadarHTTPService struct { - Options []option.RequestOption - Top *RadarHTTPTopService - Locations *RadarHTTPLocationService - Ases *RadarHTTPAseService - Summary *RadarHTTPSummaryService - TimeseriesGroups *RadarHTTPTimeseriesGroupService -} - -// NewRadarHTTPService 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 NewRadarHTTPService(opts ...option.RequestOption) (r *RadarHTTPService) { - r = &RadarHTTPService{} - r.Options = opts - r.Top = NewRadarHTTPTopService(opts...) - r.Locations = NewRadarHTTPLocationService(opts...) - r.Ases = NewRadarHTTPAseService(opts...) - r.Summary = NewRadarHTTPSummaryService(opts...) - r.TimeseriesGroups = NewRadarHTTPTimeseriesGroupService(opts...) - return -} diff --git a/radarhttpase.go b/radarhttpase.go deleted file mode 100644 index 153afcf3f63..00000000000 --- a/radarhttpase.go +++ /dev/null @@ -1,378 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPAseService 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 [NewRadarHTTPAseService] method -// instead. -type RadarHTTPAseService struct { - Options []option.RequestOption - BotClass *RadarHTTPAseBotClassService - DeviceType *RadarHTTPAseDeviceTypeService - HTTPProtocol *RadarHTTPAseHTTPProtocolService - HTTPMethod *RadarHTTPAseHTTPMethodService - IPVersion *RadarHTTPAseIPVersionService - OS *RadarHTTPAseOSService - TLSVersion *RadarHTTPAseTLSVersionService -} - -// NewRadarHTTPAseService 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 NewRadarHTTPAseService(opts ...option.RequestOption) (r *RadarHTTPAseService) { - r = &RadarHTTPAseService{} - r.Options = opts - r.BotClass = NewRadarHTTPAseBotClassService(opts...) - r.DeviceType = NewRadarHTTPAseDeviceTypeService(opts...) - r.HTTPProtocol = NewRadarHTTPAseHTTPProtocolService(opts...) - r.HTTPMethod = NewRadarHTTPAseHTTPMethodService(opts...) - r.IPVersion = NewRadarHTTPAseIPVersionService(opts...) - r.OS = NewRadarHTTPAseOSService(opts...) - r.TLSVersion = NewRadarHTTPAseTLSVersionService(opts...) - return -} - -// Get the top autonomous systems by HTTP traffic. Values are a percentage out of -// the total traffic. -func (r *RadarHTTPAseService) Get(ctx context.Context, query RadarHTTPAseGetParams, opts ...option.RequestOption) (res *RadarHTTPAseGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPAseGetResponseEnvelope - path := "radar/http/top/ases" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPAseGetResponse struct { - Meta RadarHTTPAseGetResponseMeta `json:"meta,required"` - Top0 []RadarHTTPAseGetResponseTop0 `json:"top_0,required"` - JSON radarHTTPAseGetResponseJSON `json:"-"` -} - -// radarHTTPAseGetResponseJSON contains the JSON metadata for the struct -// [RadarHTTPAseGetResponse] -type radarHTTPAseGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseGetResponseMeta struct { - DateRange []RadarHTTPAseGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarHTTPAseGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPAseGetResponseMetaJSON `json:"-"` -} - -// radarHTTPAseGetResponseMetaJSON contains the JSON metadata for the struct -// [RadarHTTPAseGetResponseMeta] -type radarHTTPAseGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPAseGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPAseGetResponseMetaDateRangeJSON contains the JSON metadata for the -// struct [RadarHTTPAseGetResponseMetaDateRange] -type radarHTTPAseGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseGetResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPAseGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPAseGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPAseGetResponseMetaConfidenceInfoJSON contains the JSON metadata for the -// struct [RadarHTTPAseGetResponseMetaConfidenceInfo] -type radarHTTPAseGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPAseGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPAseGetResponseMetaConfidenceInfoAnnotationJSON contains the JSON -// metadata for the struct [RadarHTTPAseGetResponseMetaConfidenceInfoAnnotation] -type radarHTTPAseGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseGetResponseTop0 struct { - ClientASN int64 `json:"clientASN,required"` - ClientAsName string `json:"clientASName,required"` - Value string `json:"value,required"` - JSON radarHTTPAseGetResponseTop0JSON `json:"-"` -} - -// radarHTTPAseGetResponseTop0JSON contains the JSON metadata for the struct -// [RadarHTTPAseGetResponseTop0] -type radarHTTPAseGetResponseTop0JSON struct { - ClientASN apijson.Field - ClientAsName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPAseGetParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPAseGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPAseGetParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPAseGetParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPAseGetParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPAseGetParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPAseGetParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPAseGetParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPAseGetParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPAseGetParams]'s query parameters as `url.Values`. -func (r RadarHTTPAseGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarHTTPAseGetParamsBotClass string - -const ( - RadarHTTPAseGetParamsBotClassLikelyAutomated RadarHTTPAseGetParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPAseGetParamsBotClassLikelyHuman RadarHTTPAseGetParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPAseGetParamsDateRange string - -const ( - RadarHTTPAseGetParamsDateRange1d RadarHTTPAseGetParamsDateRange = "1d" - RadarHTTPAseGetParamsDateRange2d RadarHTTPAseGetParamsDateRange = "2d" - RadarHTTPAseGetParamsDateRange7d RadarHTTPAseGetParamsDateRange = "7d" - RadarHTTPAseGetParamsDateRange14d RadarHTTPAseGetParamsDateRange = "14d" - RadarHTTPAseGetParamsDateRange28d RadarHTTPAseGetParamsDateRange = "28d" - RadarHTTPAseGetParamsDateRange12w RadarHTTPAseGetParamsDateRange = "12w" - RadarHTTPAseGetParamsDateRange24w RadarHTTPAseGetParamsDateRange = "24w" - RadarHTTPAseGetParamsDateRange52w RadarHTTPAseGetParamsDateRange = "52w" - RadarHTTPAseGetParamsDateRange1dControl RadarHTTPAseGetParamsDateRange = "1dControl" - RadarHTTPAseGetParamsDateRange2dControl RadarHTTPAseGetParamsDateRange = "2dControl" - RadarHTTPAseGetParamsDateRange7dControl RadarHTTPAseGetParamsDateRange = "7dControl" - RadarHTTPAseGetParamsDateRange14dControl RadarHTTPAseGetParamsDateRange = "14dControl" - RadarHTTPAseGetParamsDateRange28dControl RadarHTTPAseGetParamsDateRange = "28dControl" - RadarHTTPAseGetParamsDateRange12wControl RadarHTTPAseGetParamsDateRange = "12wControl" - RadarHTTPAseGetParamsDateRange24wControl RadarHTTPAseGetParamsDateRange = "24wControl" -) - -type RadarHTTPAseGetParamsDeviceType string - -const ( - RadarHTTPAseGetParamsDeviceTypeDesktop RadarHTTPAseGetParamsDeviceType = "DESKTOP" - RadarHTTPAseGetParamsDeviceTypeMobile RadarHTTPAseGetParamsDeviceType = "MOBILE" - RadarHTTPAseGetParamsDeviceTypeOther RadarHTTPAseGetParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPAseGetParamsFormat string - -const ( - RadarHTTPAseGetParamsFormatJson RadarHTTPAseGetParamsFormat = "JSON" - RadarHTTPAseGetParamsFormatCsv RadarHTTPAseGetParamsFormat = "CSV" -) - -type RadarHTTPAseGetParamsHTTPProtocol string - -const ( - RadarHTTPAseGetParamsHTTPProtocolHTTP RadarHTTPAseGetParamsHTTPProtocol = "HTTP" - RadarHTTPAseGetParamsHTTPProtocolHTTPS RadarHTTPAseGetParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPAseGetParamsHTTPVersion string - -const ( - RadarHTTPAseGetParamsHTTPVersionHttPv1 RadarHTTPAseGetParamsHTTPVersion = "HTTPv1" - RadarHTTPAseGetParamsHTTPVersionHttPv2 RadarHTTPAseGetParamsHTTPVersion = "HTTPv2" - RadarHTTPAseGetParamsHTTPVersionHttPv3 RadarHTTPAseGetParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPAseGetParamsIPVersion string - -const ( - RadarHTTPAseGetParamsIPVersionIPv4 RadarHTTPAseGetParamsIPVersion = "IPv4" - RadarHTTPAseGetParamsIPVersionIPv6 RadarHTTPAseGetParamsIPVersion = "IPv6" -) - -type RadarHTTPAseGetParamsOS string - -const ( - RadarHTTPAseGetParamsOSWindows RadarHTTPAseGetParamsOS = "WINDOWS" - RadarHTTPAseGetParamsOSMacosx RadarHTTPAseGetParamsOS = "MACOSX" - RadarHTTPAseGetParamsOSIos RadarHTTPAseGetParamsOS = "IOS" - RadarHTTPAseGetParamsOSAndroid RadarHTTPAseGetParamsOS = "ANDROID" - RadarHTTPAseGetParamsOSChromeos RadarHTTPAseGetParamsOS = "CHROMEOS" - RadarHTTPAseGetParamsOSLinux RadarHTTPAseGetParamsOS = "LINUX" - RadarHTTPAseGetParamsOSSmartTv RadarHTTPAseGetParamsOS = "SMART_TV" -) - -type RadarHTTPAseGetParamsTLSVersion string - -const ( - RadarHTTPAseGetParamsTLSVersionTlSv1_0 RadarHTTPAseGetParamsTLSVersion = "TLSv1_0" - RadarHTTPAseGetParamsTLSVersionTlSv1_1 RadarHTTPAseGetParamsTLSVersion = "TLSv1_1" - RadarHTTPAseGetParamsTLSVersionTlSv1_2 RadarHTTPAseGetParamsTLSVersion = "TLSv1_2" - RadarHTTPAseGetParamsTLSVersionTlSv1_3 RadarHTTPAseGetParamsTLSVersion = "TLSv1_3" - RadarHTTPAseGetParamsTLSVersionTlSvQuic RadarHTTPAseGetParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPAseGetResponseEnvelope struct { - Result RadarHTTPAseGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPAseGetResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPAseGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [RadarHTTPAseGetResponseEnvelope] -type radarHTTPAseGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttpase_test.go b/radarhttpase_test.go deleted file mode 100644 index 0d715bd1015..00000000000 --- a/radarhttpase_test.go +++ /dev/null @@ -1,56 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPAseGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Ases.Get(context.TODO(), cloudflare.RadarHTTPAseGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPAseGetParamsBotClass{cloudflare.RadarHTTPAseGetParamsBotClassLikelyAutomated, cloudflare.RadarHTTPAseGetParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPAseGetParamsDateRange{cloudflare.RadarHTTPAseGetParamsDateRange1d, cloudflare.RadarHTTPAseGetParamsDateRange2d, cloudflare.RadarHTTPAseGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPAseGetParamsDeviceType{cloudflare.RadarHTTPAseGetParamsDeviceTypeDesktop, cloudflare.RadarHTTPAseGetParamsDeviceTypeMobile, cloudflare.RadarHTTPAseGetParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPAseGetParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPAseGetParamsHTTPProtocol{cloudflare.RadarHTTPAseGetParamsHTTPProtocolHTTP, cloudflare.RadarHTTPAseGetParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPAseGetParamsHTTPVersion{cloudflare.RadarHTTPAseGetParamsHTTPVersionHttPv1, cloudflare.RadarHTTPAseGetParamsHTTPVersionHttPv2, cloudflare.RadarHTTPAseGetParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPAseGetParamsIPVersion{cloudflare.RadarHTTPAseGetParamsIPVersionIPv4, cloudflare.RadarHTTPAseGetParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPAseGetParamsOS{cloudflare.RadarHTTPAseGetParamsOSWindows, cloudflare.RadarHTTPAseGetParamsOSMacosx, cloudflare.RadarHTTPAseGetParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPAseGetParamsTLSVersion{cloudflare.RadarHTTPAseGetParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPAseGetParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPAseGetParamsTLSVersionTlSv1_2}), - }) - 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/radarhttpasebotclass.go b/radarhttpasebotclass.go deleted file mode 100644 index e45575c4295..00000000000 --- a/radarhttpasebotclass.go +++ /dev/null @@ -1,367 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPAseBotClassService 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 [NewRadarHTTPAseBotClassService] -// method instead. -type RadarHTTPAseBotClassService struct { - Options []option.RequestOption -} - -// NewRadarHTTPAseBotClassService 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 NewRadarHTTPAseBotClassService(opts ...option.RequestOption) (r *RadarHTTPAseBotClassService) { - r = &RadarHTTPAseBotClassService{} - r.Options = opts - return -} - -// Get the top autonomous systems (AS), by HTTP traffic, of the requested bot -// class. These two categories use Cloudflare's bot score - refer to -// [Bot Scores](https://developers.cloudflare.com/bots/concepts/bot-score) for more -// information. Values are a percentage out of the total traffic. -func (r *RadarHTTPAseBotClassService) Get(ctx context.Context, botClass RadarHTTPAseBotClassGetParamsBotClass, query RadarHTTPAseBotClassGetParams, opts ...option.RequestOption) (res *RadarHTTPAseBotClassGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPAseBotClassGetResponseEnvelope - path := fmt.Sprintf("radar/http/top/ases/bot_class/%v", botClass) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPAseBotClassGetResponse struct { - Meta RadarHTTPAseBotClassGetResponseMeta `json:"meta,required"` - Top0 []RadarHTTPAseBotClassGetResponseTop0 `json:"top_0,required"` - JSON radarHTTPAseBotClassGetResponseJSON `json:"-"` -} - -// radarHTTPAseBotClassGetResponseJSON contains the JSON metadata for the struct -// [RadarHTTPAseBotClassGetResponse] -type radarHTTPAseBotClassGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseBotClassGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseBotClassGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseBotClassGetResponseMeta struct { - DateRange []RadarHTTPAseBotClassGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarHTTPAseBotClassGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPAseBotClassGetResponseMetaJSON `json:"-"` -} - -// radarHTTPAseBotClassGetResponseMetaJSON contains the JSON metadata for the -// struct [RadarHTTPAseBotClassGetResponseMeta] -type radarHTTPAseBotClassGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseBotClassGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseBotClassGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseBotClassGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPAseBotClassGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPAseBotClassGetResponseMetaDateRangeJSON contains the JSON metadata for -// the struct [RadarHTTPAseBotClassGetResponseMetaDateRange] -type radarHTTPAseBotClassGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseBotClassGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseBotClassGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseBotClassGetResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPAseBotClassGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPAseBotClassGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPAseBotClassGetResponseMetaConfidenceInfoJSON contains the JSON metadata -// for the struct [RadarHTTPAseBotClassGetResponseMetaConfidenceInfo] -type radarHTTPAseBotClassGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseBotClassGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseBotClassGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseBotClassGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPAseBotClassGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPAseBotClassGetResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarHTTPAseBotClassGetResponseMetaConfidenceInfoAnnotation] -type radarHTTPAseBotClassGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseBotClassGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseBotClassGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseBotClassGetResponseTop0 struct { - ClientASN int64 `json:"clientASN,required"` - ClientAsName string `json:"clientASName,required"` - Value string `json:"value,required"` - JSON radarHTTPAseBotClassGetResponseTop0JSON `json:"-"` -} - -// radarHTTPAseBotClassGetResponseTop0JSON contains the JSON metadata for the -// struct [RadarHTTPAseBotClassGetResponseTop0] -type radarHTTPAseBotClassGetResponseTop0JSON struct { - ClientASN apijson.Field - ClientAsName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseBotClassGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseBotClassGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseBotClassGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPAseBotClassGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPAseBotClassGetParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPAseBotClassGetParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPAseBotClassGetParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPAseBotClassGetParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPAseBotClassGetParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPAseBotClassGetParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPAseBotClassGetParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPAseBotClassGetParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPAseBotClassGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Bot class. -type RadarHTTPAseBotClassGetParamsBotClass string - -const ( - RadarHTTPAseBotClassGetParamsBotClassLikelyAutomated RadarHTTPAseBotClassGetParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPAseBotClassGetParamsBotClassLikelyHuman RadarHTTPAseBotClassGetParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPAseBotClassGetParamsDateRange string - -const ( - RadarHTTPAseBotClassGetParamsDateRange1d RadarHTTPAseBotClassGetParamsDateRange = "1d" - RadarHTTPAseBotClassGetParamsDateRange2d RadarHTTPAseBotClassGetParamsDateRange = "2d" - RadarHTTPAseBotClassGetParamsDateRange7d RadarHTTPAseBotClassGetParamsDateRange = "7d" - RadarHTTPAseBotClassGetParamsDateRange14d RadarHTTPAseBotClassGetParamsDateRange = "14d" - RadarHTTPAseBotClassGetParamsDateRange28d RadarHTTPAseBotClassGetParamsDateRange = "28d" - RadarHTTPAseBotClassGetParamsDateRange12w RadarHTTPAseBotClassGetParamsDateRange = "12w" - RadarHTTPAseBotClassGetParamsDateRange24w RadarHTTPAseBotClassGetParamsDateRange = "24w" - RadarHTTPAseBotClassGetParamsDateRange52w RadarHTTPAseBotClassGetParamsDateRange = "52w" - RadarHTTPAseBotClassGetParamsDateRange1dControl RadarHTTPAseBotClassGetParamsDateRange = "1dControl" - RadarHTTPAseBotClassGetParamsDateRange2dControl RadarHTTPAseBotClassGetParamsDateRange = "2dControl" - RadarHTTPAseBotClassGetParamsDateRange7dControl RadarHTTPAseBotClassGetParamsDateRange = "7dControl" - RadarHTTPAseBotClassGetParamsDateRange14dControl RadarHTTPAseBotClassGetParamsDateRange = "14dControl" - RadarHTTPAseBotClassGetParamsDateRange28dControl RadarHTTPAseBotClassGetParamsDateRange = "28dControl" - RadarHTTPAseBotClassGetParamsDateRange12wControl RadarHTTPAseBotClassGetParamsDateRange = "12wControl" - RadarHTTPAseBotClassGetParamsDateRange24wControl RadarHTTPAseBotClassGetParamsDateRange = "24wControl" -) - -type RadarHTTPAseBotClassGetParamsDeviceType string - -const ( - RadarHTTPAseBotClassGetParamsDeviceTypeDesktop RadarHTTPAseBotClassGetParamsDeviceType = "DESKTOP" - RadarHTTPAseBotClassGetParamsDeviceTypeMobile RadarHTTPAseBotClassGetParamsDeviceType = "MOBILE" - RadarHTTPAseBotClassGetParamsDeviceTypeOther RadarHTTPAseBotClassGetParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPAseBotClassGetParamsFormat string - -const ( - RadarHTTPAseBotClassGetParamsFormatJson RadarHTTPAseBotClassGetParamsFormat = "JSON" - RadarHTTPAseBotClassGetParamsFormatCsv RadarHTTPAseBotClassGetParamsFormat = "CSV" -) - -type RadarHTTPAseBotClassGetParamsHTTPProtocol string - -const ( - RadarHTTPAseBotClassGetParamsHTTPProtocolHTTP RadarHTTPAseBotClassGetParamsHTTPProtocol = "HTTP" - RadarHTTPAseBotClassGetParamsHTTPProtocolHTTPS RadarHTTPAseBotClassGetParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPAseBotClassGetParamsHTTPVersion string - -const ( - RadarHTTPAseBotClassGetParamsHTTPVersionHttPv1 RadarHTTPAseBotClassGetParamsHTTPVersion = "HTTPv1" - RadarHTTPAseBotClassGetParamsHTTPVersionHttPv2 RadarHTTPAseBotClassGetParamsHTTPVersion = "HTTPv2" - RadarHTTPAseBotClassGetParamsHTTPVersionHttPv3 RadarHTTPAseBotClassGetParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPAseBotClassGetParamsIPVersion string - -const ( - RadarHTTPAseBotClassGetParamsIPVersionIPv4 RadarHTTPAseBotClassGetParamsIPVersion = "IPv4" - RadarHTTPAseBotClassGetParamsIPVersionIPv6 RadarHTTPAseBotClassGetParamsIPVersion = "IPv6" -) - -type RadarHTTPAseBotClassGetParamsOS string - -const ( - RadarHTTPAseBotClassGetParamsOSWindows RadarHTTPAseBotClassGetParamsOS = "WINDOWS" - RadarHTTPAseBotClassGetParamsOSMacosx RadarHTTPAseBotClassGetParamsOS = "MACOSX" - RadarHTTPAseBotClassGetParamsOSIos RadarHTTPAseBotClassGetParamsOS = "IOS" - RadarHTTPAseBotClassGetParamsOSAndroid RadarHTTPAseBotClassGetParamsOS = "ANDROID" - RadarHTTPAseBotClassGetParamsOSChromeos RadarHTTPAseBotClassGetParamsOS = "CHROMEOS" - RadarHTTPAseBotClassGetParamsOSLinux RadarHTTPAseBotClassGetParamsOS = "LINUX" - RadarHTTPAseBotClassGetParamsOSSmartTv RadarHTTPAseBotClassGetParamsOS = "SMART_TV" -) - -type RadarHTTPAseBotClassGetParamsTLSVersion string - -const ( - RadarHTTPAseBotClassGetParamsTLSVersionTlSv1_0 RadarHTTPAseBotClassGetParamsTLSVersion = "TLSv1_0" - RadarHTTPAseBotClassGetParamsTLSVersionTlSv1_1 RadarHTTPAseBotClassGetParamsTLSVersion = "TLSv1_1" - RadarHTTPAseBotClassGetParamsTLSVersionTlSv1_2 RadarHTTPAseBotClassGetParamsTLSVersion = "TLSv1_2" - RadarHTTPAseBotClassGetParamsTLSVersionTlSv1_3 RadarHTTPAseBotClassGetParamsTLSVersion = "TLSv1_3" - RadarHTTPAseBotClassGetParamsTLSVersionTlSvQuic RadarHTTPAseBotClassGetParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPAseBotClassGetResponseEnvelope struct { - Result RadarHTTPAseBotClassGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPAseBotClassGetResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPAseBotClassGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarHTTPAseBotClassGetResponseEnvelope] -type radarHTTPAseBotClassGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseBotClassGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseBotClassGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttpasebotclass_test.go b/radarhttpasebotclass_test.go deleted file mode 100644 index dc7d9ea4730..00000000000 --- a/radarhttpasebotclass_test.go +++ /dev/null @@ -1,59 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPAseBotClassGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Ases.BotClass.Get( - context.TODO(), - cloudflare.RadarHTTPAseBotClassGetParamsBotClassLikelyAutomated, - cloudflare.RadarHTTPAseBotClassGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPAseBotClassGetParamsDateRange{cloudflare.RadarHTTPAseBotClassGetParamsDateRange1d, cloudflare.RadarHTTPAseBotClassGetParamsDateRange2d, cloudflare.RadarHTTPAseBotClassGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPAseBotClassGetParamsDeviceType{cloudflare.RadarHTTPAseBotClassGetParamsDeviceTypeDesktop, cloudflare.RadarHTTPAseBotClassGetParamsDeviceTypeMobile, cloudflare.RadarHTTPAseBotClassGetParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPAseBotClassGetParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPAseBotClassGetParamsHTTPProtocol{cloudflare.RadarHTTPAseBotClassGetParamsHTTPProtocolHTTP, cloudflare.RadarHTTPAseBotClassGetParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPAseBotClassGetParamsHTTPVersion{cloudflare.RadarHTTPAseBotClassGetParamsHTTPVersionHttPv1, cloudflare.RadarHTTPAseBotClassGetParamsHTTPVersionHttPv2, cloudflare.RadarHTTPAseBotClassGetParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPAseBotClassGetParamsIPVersion{cloudflare.RadarHTTPAseBotClassGetParamsIPVersionIPv4, cloudflare.RadarHTTPAseBotClassGetParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPAseBotClassGetParamsOS{cloudflare.RadarHTTPAseBotClassGetParamsOSWindows, cloudflare.RadarHTTPAseBotClassGetParamsOSMacosx, cloudflare.RadarHTTPAseBotClassGetParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPAseBotClassGetParamsTLSVersion{cloudflare.RadarHTTPAseBotClassGetParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPAseBotClassGetParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPAseBotClassGetParamsTLSVersionTlSv1_2}), - }, - ) - 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/radarhttpasedevicetype.go b/radarhttpasedevicetype.go deleted file mode 100644 index 533e4b52fbe..00000000000 --- a/radarhttpasedevicetype.go +++ /dev/null @@ -1,366 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPAseDeviceTypeService 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 [NewRadarHTTPAseDeviceTypeService] -// method instead. -type RadarHTTPAseDeviceTypeService struct { - Options []option.RequestOption -} - -// NewRadarHTTPAseDeviceTypeService 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 NewRadarHTTPAseDeviceTypeService(opts ...option.RequestOption) (r *RadarHTTPAseDeviceTypeService) { - r = &RadarHTTPAseDeviceTypeService{} - r.Options = opts - return -} - -// Get the top autonomous systems (AS), by HTTP traffic, of the requested device -// type. Values are a percentage out of the total traffic. -func (r *RadarHTTPAseDeviceTypeService) Get(ctx context.Context, deviceType RadarHTTPAseDeviceTypeGetParamsDeviceType, query RadarHTTPAseDeviceTypeGetParams, opts ...option.RequestOption) (res *RadarHTTPAseDeviceTypeGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPAseDeviceTypeGetResponseEnvelope - path := fmt.Sprintf("radar/http/top/ases/device_type/%v", deviceType) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPAseDeviceTypeGetResponse struct { - Meta RadarHTTPAseDeviceTypeGetResponseMeta `json:"meta,required"` - Top0 []RadarHTTPAseDeviceTypeGetResponseTop0 `json:"top_0,required"` - JSON radarHTTPAseDeviceTypeGetResponseJSON `json:"-"` -} - -// radarHTTPAseDeviceTypeGetResponseJSON contains the JSON metadata for the struct -// [RadarHTTPAseDeviceTypeGetResponse] -type radarHTTPAseDeviceTypeGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseDeviceTypeGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseDeviceTypeGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseDeviceTypeGetResponseMeta struct { - DateRange []RadarHTTPAseDeviceTypeGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarHTTPAseDeviceTypeGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPAseDeviceTypeGetResponseMetaJSON `json:"-"` -} - -// radarHTTPAseDeviceTypeGetResponseMetaJSON contains the JSON metadata for the -// struct [RadarHTTPAseDeviceTypeGetResponseMeta] -type radarHTTPAseDeviceTypeGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseDeviceTypeGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseDeviceTypeGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseDeviceTypeGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPAseDeviceTypeGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPAseDeviceTypeGetResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarHTTPAseDeviceTypeGetResponseMetaDateRange] -type radarHTTPAseDeviceTypeGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseDeviceTypeGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseDeviceTypeGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseDeviceTypeGetResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPAseDeviceTypeGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPAseDeviceTypeGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPAseDeviceTypeGetResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarHTTPAseDeviceTypeGetResponseMetaConfidenceInfo] -type radarHTTPAseDeviceTypeGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseDeviceTypeGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseDeviceTypeGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseDeviceTypeGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPAseDeviceTypeGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPAseDeviceTypeGetResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarHTTPAseDeviceTypeGetResponseMetaConfidenceInfoAnnotation] -type radarHTTPAseDeviceTypeGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseDeviceTypeGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseDeviceTypeGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseDeviceTypeGetResponseTop0 struct { - ClientASN int64 `json:"clientASN,required"` - ClientAsName string `json:"clientASName,required"` - Value string `json:"value,required"` - JSON radarHTTPAseDeviceTypeGetResponseTop0JSON `json:"-"` -} - -// radarHTTPAseDeviceTypeGetResponseTop0JSON contains the JSON metadata for the -// struct [RadarHTTPAseDeviceTypeGetResponseTop0] -type radarHTTPAseDeviceTypeGetResponseTop0JSON struct { - ClientASN apijson.Field - ClientAsName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseDeviceTypeGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseDeviceTypeGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseDeviceTypeGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPAseDeviceTypeGetParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPAseDeviceTypeGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarHTTPAseDeviceTypeGetParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPAseDeviceTypeGetParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPAseDeviceTypeGetParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPAseDeviceTypeGetParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPAseDeviceTypeGetParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPAseDeviceTypeGetParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPAseDeviceTypeGetParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPAseDeviceTypeGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Device type. -type RadarHTTPAseDeviceTypeGetParamsDeviceType string - -const ( - RadarHTTPAseDeviceTypeGetParamsDeviceTypeDesktop RadarHTTPAseDeviceTypeGetParamsDeviceType = "DESKTOP" - RadarHTTPAseDeviceTypeGetParamsDeviceTypeMobile RadarHTTPAseDeviceTypeGetParamsDeviceType = "MOBILE" - RadarHTTPAseDeviceTypeGetParamsDeviceTypeOther RadarHTTPAseDeviceTypeGetParamsDeviceType = "OTHER" -) - -type RadarHTTPAseDeviceTypeGetParamsBotClass string - -const ( - RadarHTTPAseDeviceTypeGetParamsBotClassLikelyAutomated RadarHTTPAseDeviceTypeGetParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPAseDeviceTypeGetParamsBotClassLikelyHuman RadarHTTPAseDeviceTypeGetParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPAseDeviceTypeGetParamsDateRange string - -const ( - RadarHTTPAseDeviceTypeGetParamsDateRange1d RadarHTTPAseDeviceTypeGetParamsDateRange = "1d" - RadarHTTPAseDeviceTypeGetParamsDateRange2d RadarHTTPAseDeviceTypeGetParamsDateRange = "2d" - RadarHTTPAseDeviceTypeGetParamsDateRange7d RadarHTTPAseDeviceTypeGetParamsDateRange = "7d" - RadarHTTPAseDeviceTypeGetParamsDateRange14d RadarHTTPAseDeviceTypeGetParamsDateRange = "14d" - RadarHTTPAseDeviceTypeGetParamsDateRange28d RadarHTTPAseDeviceTypeGetParamsDateRange = "28d" - RadarHTTPAseDeviceTypeGetParamsDateRange12w RadarHTTPAseDeviceTypeGetParamsDateRange = "12w" - RadarHTTPAseDeviceTypeGetParamsDateRange24w RadarHTTPAseDeviceTypeGetParamsDateRange = "24w" - RadarHTTPAseDeviceTypeGetParamsDateRange52w RadarHTTPAseDeviceTypeGetParamsDateRange = "52w" - RadarHTTPAseDeviceTypeGetParamsDateRange1dControl RadarHTTPAseDeviceTypeGetParamsDateRange = "1dControl" - RadarHTTPAseDeviceTypeGetParamsDateRange2dControl RadarHTTPAseDeviceTypeGetParamsDateRange = "2dControl" - RadarHTTPAseDeviceTypeGetParamsDateRange7dControl RadarHTTPAseDeviceTypeGetParamsDateRange = "7dControl" - RadarHTTPAseDeviceTypeGetParamsDateRange14dControl RadarHTTPAseDeviceTypeGetParamsDateRange = "14dControl" - RadarHTTPAseDeviceTypeGetParamsDateRange28dControl RadarHTTPAseDeviceTypeGetParamsDateRange = "28dControl" - RadarHTTPAseDeviceTypeGetParamsDateRange12wControl RadarHTTPAseDeviceTypeGetParamsDateRange = "12wControl" - RadarHTTPAseDeviceTypeGetParamsDateRange24wControl RadarHTTPAseDeviceTypeGetParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarHTTPAseDeviceTypeGetParamsFormat string - -const ( - RadarHTTPAseDeviceTypeGetParamsFormatJson RadarHTTPAseDeviceTypeGetParamsFormat = "JSON" - RadarHTTPAseDeviceTypeGetParamsFormatCsv RadarHTTPAseDeviceTypeGetParamsFormat = "CSV" -) - -type RadarHTTPAseDeviceTypeGetParamsHTTPProtocol string - -const ( - RadarHTTPAseDeviceTypeGetParamsHTTPProtocolHTTP RadarHTTPAseDeviceTypeGetParamsHTTPProtocol = "HTTP" - RadarHTTPAseDeviceTypeGetParamsHTTPProtocolHTTPS RadarHTTPAseDeviceTypeGetParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPAseDeviceTypeGetParamsHTTPVersion string - -const ( - RadarHTTPAseDeviceTypeGetParamsHTTPVersionHttPv1 RadarHTTPAseDeviceTypeGetParamsHTTPVersion = "HTTPv1" - RadarHTTPAseDeviceTypeGetParamsHTTPVersionHttPv2 RadarHTTPAseDeviceTypeGetParamsHTTPVersion = "HTTPv2" - RadarHTTPAseDeviceTypeGetParamsHTTPVersionHttPv3 RadarHTTPAseDeviceTypeGetParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPAseDeviceTypeGetParamsIPVersion string - -const ( - RadarHTTPAseDeviceTypeGetParamsIPVersionIPv4 RadarHTTPAseDeviceTypeGetParamsIPVersion = "IPv4" - RadarHTTPAseDeviceTypeGetParamsIPVersionIPv6 RadarHTTPAseDeviceTypeGetParamsIPVersion = "IPv6" -) - -type RadarHTTPAseDeviceTypeGetParamsOS string - -const ( - RadarHTTPAseDeviceTypeGetParamsOSWindows RadarHTTPAseDeviceTypeGetParamsOS = "WINDOWS" - RadarHTTPAseDeviceTypeGetParamsOSMacosx RadarHTTPAseDeviceTypeGetParamsOS = "MACOSX" - RadarHTTPAseDeviceTypeGetParamsOSIos RadarHTTPAseDeviceTypeGetParamsOS = "IOS" - RadarHTTPAseDeviceTypeGetParamsOSAndroid RadarHTTPAseDeviceTypeGetParamsOS = "ANDROID" - RadarHTTPAseDeviceTypeGetParamsOSChromeos RadarHTTPAseDeviceTypeGetParamsOS = "CHROMEOS" - RadarHTTPAseDeviceTypeGetParamsOSLinux RadarHTTPAseDeviceTypeGetParamsOS = "LINUX" - RadarHTTPAseDeviceTypeGetParamsOSSmartTv RadarHTTPAseDeviceTypeGetParamsOS = "SMART_TV" -) - -type RadarHTTPAseDeviceTypeGetParamsTLSVersion string - -const ( - RadarHTTPAseDeviceTypeGetParamsTLSVersionTlSv1_0 RadarHTTPAseDeviceTypeGetParamsTLSVersion = "TLSv1_0" - RadarHTTPAseDeviceTypeGetParamsTLSVersionTlSv1_1 RadarHTTPAseDeviceTypeGetParamsTLSVersion = "TLSv1_1" - RadarHTTPAseDeviceTypeGetParamsTLSVersionTlSv1_2 RadarHTTPAseDeviceTypeGetParamsTLSVersion = "TLSv1_2" - RadarHTTPAseDeviceTypeGetParamsTLSVersionTlSv1_3 RadarHTTPAseDeviceTypeGetParamsTLSVersion = "TLSv1_3" - RadarHTTPAseDeviceTypeGetParamsTLSVersionTlSvQuic RadarHTTPAseDeviceTypeGetParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPAseDeviceTypeGetResponseEnvelope struct { - Result RadarHTTPAseDeviceTypeGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPAseDeviceTypeGetResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPAseDeviceTypeGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarHTTPAseDeviceTypeGetResponseEnvelope] -type radarHTTPAseDeviceTypeGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseDeviceTypeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseDeviceTypeGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttpasedevicetype_test.go b/radarhttpasedevicetype_test.go deleted file mode 100644 index 6a0e89270e0..00000000000 --- a/radarhttpasedevicetype_test.go +++ /dev/null @@ -1,59 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPAseDeviceTypeGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Ases.DeviceType.Get( - context.TODO(), - cloudflare.RadarHTTPAseDeviceTypeGetParamsDeviceTypeDesktop, - cloudflare.RadarHTTPAseDeviceTypeGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPAseDeviceTypeGetParamsBotClass{cloudflare.RadarHTTPAseDeviceTypeGetParamsBotClassLikelyAutomated, cloudflare.RadarHTTPAseDeviceTypeGetParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPAseDeviceTypeGetParamsDateRange{cloudflare.RadarHTTPAseDeviceTypeGetParamsDateRange1d, cloudflare.RadarHTTPAseDeviceTypeGetParamsDateRange2d, cloudflare.RadarHTTPAseDeviceTypeGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarHTTPAseDeviceTypeGetParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPAseDeviceTypeGetParamsHTTPProtocol{cloudflare.RadarHTTPAseDeviceTypeGetParamsHTTPProtocolHTTP, cloudflare.RadarHTTPAseDeviceTypeGetParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPAseDeviceTypeGetParamsHTTPVersion{cloudflare.RadarHTTPAseDeviceTypeGetParamsHTTPVersionHttPv1, cloudflare.RadarHTTPAseDeviceTypeGetParamsHTTPVersionHttPv2, cloudflare.RadarHTTPAseDeviceTypeGetParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPAseDeviceTypeGetParamsIPVersion{cloudflare.RadarHTTPAseDeviceTypeGetParamsIPVersionIPv4, cloudflare.RadarHTTPAseDeviceTypeGetParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPAseDeviceTypeGetParamsOS{cloudflare.RadarHTTPAseDeviceTypeGetParamsOSWindows, cloudflare.RadarHTTPAseDeviceTypeGetParamsOSMacosx, cloudflare.RadarHTTPAseDeviceTypeGetParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPAseDeviceTypeGetParamsTLSVersion{cloudflare.RadarHTTPAseDeviceTypeGetParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPAseDeviceTypeGetParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPAseDeviceTypeGetParamsTLSVersionTlSv1_2}), - }, - ) - 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/radarhttpasehttpmethod.go b/radarhttpasehttpmethod.go deleted file mode 100644 index ac63a481a3f..00000000000 --- a/radarhttpasehttpmethod.go +++ /dev/null @@ -1,366 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPAseHTTPMethodService 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 [NewRadarHTTPAseHTTPMethodService] -// method instead. -type RadarHTTPAseHTTPMethodService struct { - Options []option.RequestOption -} - -// NewRadarHTTPAseHTTPMethodService 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 NewRadarHTTPAseHTTPMethodService(opts ...option.RequestOption) (r *RadarHTTPAseHTTPMethodService) { - r = &RadarHTTPAseHTTPMethodService{} - r.Options = opts - return -} - -// Get the top autonomous systems (AS), by HTTP traffic, of the requested HTTP -// protocol version. Values are a percentage out of the total traffic. -func (r *RadarHTTPAseHTTPMethodService) Get(ctx context.Context, httpVersion RadarHTTPAseHTTPMethodGetParamsHTTPVersion, query RadarHTTPAseHTTPMethodGetParams, opts ...option.RequestOption) (res *RadarHTTPAseHTTPMethodGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPAseHTTPMethodGetResponseEnvelope - path := fmt.Sprintf("radar/http/top/ases/http_version/%v", httpVersion) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPAseHTTPMethodGetResponse struct { - Meta RadarHTTPAseHTTPMethodGetResponseMeta `json:"meta,required"` - Top0 []RadarHTTPAseHTTPMethodGetResponseTop0 `json:"top_0,required"` - JSON radarHTTPAseHTTPMethodGetResponseJSON `json:"-"` -} - -// radarHTTPAseHTTPMethodGetResponseJSON contains the JSON metadata for the struct -// [RadarHTTPAseHTTPMethodGetResponse] -type radarHTTPAseHTTPMethodGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseHTTPMethodGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseHTTPMethodGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseHTTPMethodGetResponseMeta struct { - DateRange []RadarHTTPAseHTTPMethodGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarHTTPAseHTTPMethodGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPAseHTTPMethodGetResponseMetaJSON `json:"-"` -} - -// radarHTTPAseHTTPMethodGetResponseMetaJSON contains the JSON metadata for the -// struct [RadarHTTPAseHTTPMethodGetResponseMeta] -type radarHTTPAseHTTPMethodGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseHTTPMethodGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseHTTPMethodGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseHTTPMethodGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPAseHTTPMethodGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPAseHTTPMethodGetResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarHTTPAseHTTPMethodGetResponseMetaDateRange] -type radarHTTPAseHTTPMethodGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseHTTPMethodGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseHTTPMethodGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseHTTPMethodGetResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPAseHTTPMethodGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPAseHTTPMethodGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPAseHTTPMethodGetResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarHTTPAseHTTPMethodGetResponseMetaConfidenceInfo] -type radarHTTPAseHTTPMethodGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseHTTPMethodGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseHTTPMethodGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseHTTPMethodGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPAseHTTPMethodGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPAseHTTPMethodGetResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarHTTPAseHTTPMethodGetResponseMetaConfidenceInfoAnnotation] -type radarHTTPAseHTTPMethodGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseHTTPMethodGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseHTTPMethodGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseHTTPMethodGetResponseTop0 struct { - ClientASN int64 `json:"clientASN,required"` - ClientAsName string `json:"clientASName,required"` - Value string `json:"value,required"` - JSON radarHTTPAseHTTPMethodGetResponseTop0JSON `json:"-"` -} - -// radarHTTPAseHTTPMethodGetResponseTop0JSON contains the JSON metadata for the -// struct [RadarHTTPAseHTTPMethodGetResponseTop0] -type radarHTTPAseHTTPMethodGetResponseTop0JSON struct { - ClientASN apijson.Field - ClientAsName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseHTTPMethodGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseHTTPMethodGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseHTTPMethodGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPAseHTTPMethodGetParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPAseHTTPMethodGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPAseHTTPMethodGetParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPAseHTTPMethodGetParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPAseHTTPMethodGetParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPAseHTTPMethodGetParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPAseHTTPMethodGetParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPAseHTTPMethodGetParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPAseHTTPMethodGetParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPAseHTTPMethodGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// HTTP version. -type RadarHTTPAseHTTPMethodGetParamsHTTPVersion string - -const ( - RadarHTTPAseHTTPMethodGetParamsHTTPVersionHttPv1 RadarHTTPAseHTTPMethodGetParamsHTTPVersion = "HTTPv1" - RadarHTTPAseHTTPMethodGetParamsHTTPVersionHttPv2 RadarHTTPAseHTTPMethodGetParamsHTTPVersion = "HTTPv2" - RadarHTTPAseHTTPMethodGetParamsHTTPVersionHttPv3 RadarHTTPAseHTTPMethodGetParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPAseHTTPMethodGetParamsBotClass string - -const ( - RadarHTTPAseHTTPMethodGetParamsBotClassLikelyAutomated RadarHTTPAseHTTPMethodGetParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPAseHTTPMethodGetParamsBotClassLikelyHuman RadarHTTPAseHTTPMethodGetParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPAseHTTPMethodGetParamsDateRange string - -const ( - RadarHTTPAseHTTPMethodGetParamsDateRange1d RadarHTTPAseHTTPMethodGetParamsDateRange = "1d" - RadarHTTPAseHTTPMethodGetParamsDateRange2d RadarHTTPAseHTTPMethodGetParamsDateRange = "2d" - RadarHTTPAseHTTPMethodGetParamsDateRange7d RadarHTTPAseHTTPMethodGetParamsDateRange = "7d" - RadarHTTPAseHTTPMethodGetParamsDateRange14d RadarHTTPAseHTTPMethodGetParamsDateRange = "14d" - RadarHTTPAseHTTPMethodGetParamsDateRange28d RadarHTTPAseHTTPMethodGetParamsDateRange = "28d" - RadarHTTPAseHTTPMethodGetParamsDateRange12w RadarHTTPAseHTTPMethodGetParamsDateRange = "12w" - RadarHTTPAseHTTPMethodGetParamsDateRange24w RadarHTTPAseHTTPMethodGetParamsDateRange = "24w" - RadarHTTPAseHTTPMethodGetParamsDateRange52w RadarHTTPAseHTTPMethodGetParamsDateRange = "52w" - RadarHTTPAseHTTPMethodGetParamsDateRange1dControl RadarHTTPAseHTTPMethodGetParamsDateRange = "1dControl" - RadarHTTPAseHTTPMethodGetParamsDateRange2dControl RadarHTTPAseHTTPMethodGetParamsDateRange = "2dControl" - RadarHTTPAseHTTPMethodGetParamsDateRange7dControl RadarHTTPAseHTTPMethodGetParamsDateRange = "7dControl" - RadarHTTPAseHTTPMethodGetParamsDateRange14dControl RadarHTTPAseHTTPMethodGetParamsDateRange = "14dControl" - RadarHTTPAseHTTPMethodGetParamsDateRange28dControl RadarHTTPAseHTTPMethodGetParamsDateRange = "28dControl" - RadarHTTPAseHTTPMethodGetParamsDateRange12wControl RadarHTTPAseHTTPMethodGetParamsDateRange = "12wControl" - RadarHTTPAseHTTPMethodGetParamsDateRange24wControl RadarHTTPAseHTTPMethodGetParamsDateRange = "24wControl" -) - -type RadarHTTPAseHTTPMethodGetParamsDeviceType string - -const ( - RadarHTTPAseHTTPMethodGetParamsDeviceTypeDesktop RadarHTTPAseHTTPMethodGetParamsDeviceType = "DESKTOP" - RadarHTTPAseHTTPMethodGetParamsDeviceTypeMobile RadarHTTPAseHTTPMethodGetParamsDeviceType = "MOBILE" - RadarHTTPAseHTTPMethodGetParamsDeviceTypeOther RadarHTTPAseHTTPMethodGetParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPAseHTTPMethodGetParamsFormat string - -const ( - RadarHTTPAseHTTPMethodGetParamsFormatJson RadarHTTPAseHTTPMethodGetParamsFormat = "JSON" - RadarHTTPAseHTTPMethodGetParamsFormatCsv RadarHTTPAseHTTPMethodGetParamsFormat = "CSV" -) - -type RadarHTTPAseHTTPMethodGetParamsHTTPProtocol string - -const ( - RadarHTTPAseHTTPMethodGetParamsHTTPProtocolHTTP RadarHTTPAseHTTPMethodGetParamsHTTPProtocol = "HTTP" - RadarHTTPAseHTTPMethodGetParamsHTTPProtocolHTTPS RadarHTTPAseHTTPMethodGetParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPAseHTTPMethodGetParamsIPVersion string - -const ( - RadarHTTPAseHTTPMethodGetParamsIPVersionIPv4 RadarHTTPAseHTTPMethodGetParamsIPVersion = "IPv4" - RadarHTTPAseHTTPMethodGetParamsIPVersionIPv6 RadarHTTPAseHTTPMethodGetParamsIPVersion = "IPv6" -) - -type RadarHTTPAseHTTPMethodGetParamsOS string - -const ( - RadarHTTPAseHTTPMethodGetParamsOSWindows RadarHTTPAseHTTPMethodGetParamsOS = "WINDOWS" - RadarHTTPAseHTTPMethodGetParamsOSMacosx RadarHTTPAseHTTPMethodGetParamsOS = "MACOSX" - RadarHTTPAseHTTPMethodGetParamsOSIos RadarHTTPAseHTTPMethodGetParamsOS = "IOS" - RadarHTTPAseHTTPMethodGetParamsOSAndroid RadarHTTPAseHTTPMethodGetParamsOS = "ANDROID" - RadarHTTPAseHTTPMethodGetParamsOSChromeos RadarHTTPAseHTTPMethodGetParamsOS = "CHROMEOS" - RadarHTTPAseHTTPMethodGetParamsOSLinux RadarHTTPAseHTTPMethodGetParamsOS = "LINUX" - RadarHTTPAseHTTPMethodGetParamsOSSmartTv RadarHTTPAseHTTPMethodGetParamsOS = "SMART_TV" -) - -type RadarHTTPAseHTTPMethodGetParamsTLSVersion string - -const ( - RadarHTTPAseHTTPMethodGetParamsTLSVersionTlSv1_0 RadarHTTPAseHTTPMethodGetParamsTLSVersion = "TLSv1_0" - RadarHTTPAseHTTPMethodGetParamsTLSVersionTlSv1_1 RadarHTTPAseHTTPMethodGetParamsTLSVersion = "TLSv1_1" - RadarHTTPAseHTTPMethodGetParamsTLSVersionTlSv1_2 RadarHTTPAseHTTPMethodGetParamsTLSVersion = "TLSv1_2" - RadarHTTPAseHTTPMethodGetParamsTLSVersionTlSv1_3 RadarHTTPAseHTTPMethodGetParamsTLSVersion = "TLSv1_3" - RadarHTTPAseHTTPMethodGetParamsTLSVersionTlSvQuic RadarHTTPAseHTTPMethodGetParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPAseHTTPMethodGetResponseEnvelope struct { - Result RadarHTTPAseHTTPMethodGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPAseHTTPMethodGetResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPAseHTTPMethodGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarHTTPAseHTTPMethodGetResponseEnvelope] -type radarHTTPAseHTTPMethodGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseHTTPMethodGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseHTTPMethodGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttpasehttpmethod_test.go b/radarhttpasehttpmethod_test.go deleted file mode 100644 index e7dc39299c1..00000000000 --- a/radarhttpasehttpmethod_test.go +++ /dev/null @@ -1,59 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPAseHTTPMethodGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Ases.HTTPMethod.Get( - context.TODO(), - cloudflare.RadarHTTPAseHTTPMethodGetParamsHTTPVersionHttPv1, - cloudflare.RadarHTTPAseHTTPMethodGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPAseHTTPMethodGetParamsBotClass{cloudflare.RadarHTTPAseHTTPMethodGetParamsBotClassLikelyAutomated, cloudflare.RadarHTTPAseHTTPMethodGetParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPAseHTTPMethodGetParamsDateRange{cloudflare.RadarHTTPAseHTTPMethodGetParamsDateRange1d, cloudflare.RadarHTTPAseHTTPMethodGetParamsDateRange2d, cloudflare.RadarHTTPAseHTTPMethodGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPAseHTTPMethodGetParamsDeviceType{cloudflare.RadarHTTPAseHTTPMethodGetParamsDeviceTypeDesktop, cloudflare.RadarHTTPAseHTTPMethodGetParamsDeviceTypeMobile, cloudflare.RadarHTTPAseHTTPMethodGetParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPAseHTTPMethodGetParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPAseHTTPMethodGetParamsHTTPProtocol{cloudflare.RadarHTTPAseHTTPMethodGetParamsHTTPProtocolHTTP, cloudflare.RadarHTTPAseHTTPMethodGetParamsHTTPProtocolHTTPS}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPAseHTTPMethodGetParamsIPVersion{cloudflare.RadarHTTPAseHTTPMethodGetParamsIPVersionIPv4, cloudflare.RadarHTTPAseHTTPMethodGetParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPAseHTTPMethodGetParamsOS{cloudflare.RadarHTTPAseHTTPMethodGetParamsOSWindows, cloudflare.RadarHTTPAseHTTPMethodGetParamsOSMacosx, cloudflare.RadarHTTPAseHTTPMethodGetParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPAseHTTPMethodGetParamsTLSVersion{cloudflare.RadarHTTPAseHTTPMethodGetParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPAseHTTPMethodGetParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPAseHTTPMethodGetParamsTLSVersionTlSv1_2}), - }, - ) - 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/radarhttpasehttpprotocol.go b/radarhttpasehttpprotocol.go deleted file mode 100644 index 074857b218f..00000000000 --- a/radarhttpasehttpprotocol.go +++ /dev/null @@ -1,356 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPAseHTTPProtocolService 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 -// [NewRadarHTTPAseHTTPProtocolService] method instead. -type RadarHTTPAseHTTPProtocolService struct { - Options []option.RequestOption -} - -// NewRadarHTTPAseHTTPProtocolService 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 NewRadarHTTPAseHTTPProtocolService(opts ...option.RequestOption) (r *RadarHTTPAseHTTPProtocolService) { - r = &RadarHTTPAseHTTPProtocolService{} - r.Options = opts - return -} - -// Get the top autonomous systems (AS), by HTTP traffic, of the requested HTTP -// protocol. Values are a percentage out of the total traffic. -func (r *RadarHTTPAseHTTPProtocolService) Get(ctx context.Context, httpProtocol RadarHTTPAseHTTPProtocolGetParamsHTTPProtocol, query RadarHTTPAseHTTPProtocolGetParams, opts ...option.RequestOption) (res *RadarHTTPAseHTTPProtocolGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPAseHTTPProtocolGetResponseEnvelope - path := fmt.Sprintf("radar/http/top/ases/http_protocol/%v", httpProtocol) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPAseHTTPProtocolGetResponse struct { - Meta RadarHTTPAseHTTPProtocolGetResponseMeta `json:"meta,required"` - Top0 []RadarHTTPAseHTTPProtocolGetResponseTop0 `json:"top_0,required"` - JSON radarHTTPAseHTTPProtocolGetResponseJSON `json:"-"` -} - -// radarHTTPAseHTTPProtocolGetResponseJSON contains the JSON metadata for the -// struct [RadarHTTPAseHTTPProtocolGetResponse] -type radarHTTPAseHTTPProtocolGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseHTTPProtocolGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseHTTPProtocolGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseHTTPProtocolGetResponseMeta struct { - DateRange []RadarHTTPAseHTTPProtocolGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarHTTPAseHTTPProtocolGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPAseHTTPProtocolGetResponseMetaJSON `json:"-"` -} - -// radarHTTPAseHTTPProtocolGetResponseMetaJSON contains the JSON metadata for the -// struct [RadarHTTPAseHTTPProtocolGetResponseMeta] -type radarHTTPAseHTTPProtocolGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseHTTPProtocolGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseHTTPProtocolGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseHTTPProtocolGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPAseHTTPProtocolGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPAseHTTPProtocolGetResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarHTTPAseHTTPProtocolGetResponseMetaDateRange] -type radarHTTPAseHTTPProtocolGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseHTTPProtocolGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseHTTPProtocolGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseHTTPProtocolGetResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPAseHTTPProtocolGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPAseHTTPProtocolGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPAseHTTPProtocolGetResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarHTTPAseHTTPProtocolGetResponseMetaConfidenceInfo] -type radarHTTPAseHTTPProtocolGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseHTTPProtocolGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseHTTPProtocolGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseHTTPProtocolGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPAseHTTPProtocolGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPAseHTTPProtocolGetResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarHTTPAseHTTPProtocolGetResponseMetaConfidenceInfoAnnotation] -type radarHTTPAseHTTPProtocolGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseHTTPProtocolGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseHTTPProtocolGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseHTTPProtocolGetResponseTop0 struct { - ClientASN int64 `json:"clientASN,required"` - ClientAsName string `json:"clientASName,required"` - Value string `json:"value,required"` - JSON radarHTTPAseHTTPProtocolGetResponseTop0JSON `json:"-"` -} - -// radarHTTPAseHTTPProtocolGetResponseTop0JSON contains the JSON metadata for the -// struct [RadarHTTPAseHTTPProtocolGetResponseTop0] -type radarHTTPAseHTTPProtocolGetResponseTop0JSON struct { - ClientASN apijson.Field - ClientAsName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseHTTPProtocolGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseHTTPProtocolGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseHTTPProtocolGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPAseHTTPProtocolGetParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPAseHTTPProtocolGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPAseHTTPProtocolGetParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPAseHTTPProtocolGetParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPAseHTTPProtocolGetParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPAseHTTPProtocolGetParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPAseHTTPProtocolGetParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPAseHTTPProtocolGetParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPAseHTTPProtocolGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// HTTP Protocol. -type RadarHTTPAseHTTPProtocolGetParamsHTTPProtocol string - -const ( - RadarHTTPAseHTTPProtocolGetParamsHTTPProtocolHTTP RadarHTTPAseHTTPProtocolGetParamsHTTPProtocol = "HTTP" - RadarHTTPAseHTTPProtocolGetParamsHTTPProtocolHTTPS RadarHTTPAseHTTPProtocolGetParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPAseHTTPProtocolGetParamsBotClass string - -const ( - RadarHTTPAseHTTPProtocolGetParamsBotClassLikelyAutomated RadarHTTPAseHTTPProtocolGetParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPAseHTTPProtocolGetParamsBotClassLikelyHuman RadarHTTPAseHTTPProtocolGetParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPAseHTTPProtocolGetParamsDateRange string - -const ( - RadarHTTPAseHTTPProtocolGetParamsDateRange1d RadarHTTPAseHTTPProtocolGetParamsDateRange = "1d" - RadarHTTPAseHTTPProtocolGetParamsDateRange2d RadarHTTPAseHTTPProtocolGetParamsDateRange = "2d" - RadarHTTPAseHTTPProtocolGetParamsDateRange7d RadarHTTPAseHTTPProtocolGetParamsDateRange = "7d" - RadarHTTPAseHTTPProtocolGetParamsDateRange14d RadarHTTPAseHTTPProtocolGetParamsDateRange = "14d" - RadarHTTPAseHTTPProtocolGetParamsDateRange28d RadarHTTPAseHTTPProtocolGetParamsDateRange = "28d" - RadarHTTPAseHTTPProtocolGetParamsDateRange12w RadarHTTPAseHTTPProtocolGetParamsDateRange = "12w" - RadarHTTPAseHTTPProtocolGetParamsDateRange24w RadarHTTPAseHTTPProtocolGetParamsDateRange = "24w" - RadarHTTPAseHTTPProtocolGetParamsDateRange52w RadarHTTPAseHTTPProtocolGetParamsDateRange = "52w" - RadarHTTPAseHTTPProtocolGetParamsDateRange1dControl RadarHTTPAseHTTPProtocolGetParamsDateRange = "1dControl" - RadarHTTPAseHTTPProtocolGetParamsDateRange2dControl RadarHTTPAseHTTPProtocolGetParamsDateRange = "2dControl" - RadarHTTPAseHTTPProtocolGetParamsDateRange7dControl RadarHTTPAseHTTPProtocolGetParamsDateRange = "7dControl" - RadarHTTPAseHTTPProtocolGetParamsDateRange14dControl RadarHTTPAseHTTPProtocolGetParamsDateRange = "14dControl" - RadarHTTPAseHTTPProtocolGetParamsDateRange28dControl RadarHTTPAseHTTPProtocolGetParamsDateRange = "28dControl" - RadarHTTPAseHTTPProtocolGetParamsDateRange12wControl RadarHTTPAseHTTPProtocolGetParamsDateRange = "12wControl" - RadarHTTPAseHTTPProtocolGetParamsDateRange24wControl RadarHTTPAseHTTPProtocolGetParamsDateRange = "24wControl" -) - -type RadarHTTPAseHTTPProtocolGetParamsDeviceType string - -const ( - RadarHTTPAseHTTPProtocolGetParamsDeviceTypeDesktop RadarHTTPAseHTTPProtocolGetParamsDeviceType = "DESKTOP" - RadarHTTPAseHTTPProtocolGetParamsDeviceTypeMobile RadarHTTPAseHTTPProtocolGetParamsDeviceType = "MOBILE" - RadarHTTPAseHTTPProtocolGetParamsDeviceTypeOther RadarHTTPAseHTTPProtocolGetParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPAseHTTPProtocolGetParamsFormat string - -const ( - RadarHTTPAseHTTPProtocolGetParamsFormatJson RadarHTTPAseHTTPProtocolGetParamsFormat = "JSON" - RadarHTTPAseHTTPProtocolGetParamsFormatCsv RadarHTTPAseHTTPProtocolGetParamsFormat = "CSV" -) - -type RadarHTTPAseHTTPProtocolGetParamsIPVersion string - -const ( - RadarHTTPAseHTTPProtocolGetParamsIPVersionIPv4 RadarHTTPAseHTTPProtocolGetParamsIPVersion = "IPv4" - RadarHTTPAseHTTPProtocolGetParamsIPVersionIPv6 RadarHTTPAseHTTPProtocolGetParamsIPVersion = "IPv6" -) - -type RadarHTTPAseHTTPProtocolGetParamsOS string - -const ( - RadarHTTPAseHTTPProtocolGetParamsOSWindows RadarHTTPAseHTTPProtocolGetParamsOS = "WINDOWS" - RadarHTTPAseHTTPProtocolGetParamsOSMacosx RadarHTTPAseHTTPProtocolGetParamsOS = "MACOSX" - RadarHTTPAseHTTPProtocolGetParamsOSIos RadarHTTPAseHTTPProtocolGetParamsOS = "IOS" - RadarHTTPAseHTTPProtocolGetParamsOSAndroid RadarHTTPAseHTTPProtocolGetParamsOS = "ANDROID" - RadarHTTPAseHTTPProtocolGetParamsOSChromeos RadarHTTPAseHTTPProtocolGetParamsOS = "CHROMEOS" - RadarHTTPAseHTTPProtocolGetParamsOSLinux RadarHTTPAseHTTPProtocolGetParamsOS = "LINUX" - RadarHTTPAseHTTPProtocolGetParamsOSSmartTv RadarHTTPAseHTTPProtocolGetParamsOS = "SMART_TV" -) - -type RadarHTTPAseHTTPProtocolGetParamsTLSVersion string - -const ( - RadarHTTPAseHTTPProtocolGetParamsTLSVersionTlSv1_0 RadarHTTPAseHTTPProtocolGetParamsTLSVersion = "TLSv1_0" - RadarHTTPAseHTTPProtocolGetParamsTLSVersionTlSv1_1 RadarHTTPAseHTTPProtocolGetParamsTLSVersion = "TLSv1_1" - RadarHTTPAseHTTPProtocolGetParamsTLSVersionTlSv1_2 RadarHTTPAseHTTPProtocolGetParamsTLSVersion = "TLSv1_2" - RadarHTTPAseHTTPProtocolGetParamsTLSVersionTlSv1_3 RadarHTTPAseHTTPProtocolGetParamsTLSVersion = "TLSv1_3" - RadarHTTPAseHTTPProtocolGetParamsTLSVersionTlSvQuic RadarHTTPAseHTTPProtocolGetParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPAseHTTPProtocolGetResponseEnvelope struct { - Result RadarHTTPAseHTTPProtocolGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPAseHTTPProtocolGetResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPAseHTTPProtocolGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarHTTPAseHTTPProtocolGetResponseEnvelope] -type radarHTTPAseHTTPProtocolGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseHTTPProtocolGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseHTTPProtocolGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttpasehttpprotocol_test.go b/radarhttpasehttpprotocol_test.go deleted file mode 100644 index 2e2d0478b9e..00000000000 --- a/radarhttpasehttpprotocol_test.go +++ /dev/null @@ -1,58 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPAseHTTPProtocolGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Ases.HTTPProtocol.Get( - context.TODO(), - cloudflare.RadarHTTPAseHTTPProtocolGetParamsHTTPProtocolHTTP, - cloudflare.RadarHTTPAseHTTPProtocolGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPAseHTTPProtocolGetParamsBotClass{cloudflare.RadarHTTPAseHTTPProtocolGetParamsBotClassLikelyAutomated, cloudflare.RadarHTTPAseHTTPProtocolGetParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPAseHTTPProtocolGetParamsDateRange{cloudflare.RadarHTTPAseHTTPProtocolGetParamsDateRange1d, cloudflare.RadarHTTPAseHTTPProtocolGetParamsDateRange2d, cloudflare.RadarHTTPAseHTTPProtocolGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPAseHTTPProtocolGetParamsDeviceType{cloudflare.RadarHTTPAseHTTPProtocolGetParamsDeviceTypeDesktop, cloudflare.RadarHTTPAseHTTPProtocolGetParamsDeviceTypeMobile, cloudflare.RadarHTTPAseHTTPProtocolGetParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPAseHTTPProtocolGetParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPAseHTTPProtocolGetParamsIPVersion{cloudflare.RadarHTTPAseHTTPProtocolGetParamsIPVersionIPv4, cloudflare.RadarHTTPAseHTTPProtocolGetParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPAseHTTPProtocolGetParamsOS{cloudflare.RadarHTTPAseHTTPProtocolGetParamsOSWindows, cloudflare.RadarHTTPAseHTTPProtocolGetParamsOSMacosx, cloudflare.RadarHTTPAseHTTPProtocolGetParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPAseHTTPProtocolGetParamsTLSVersion{cloudflare.RadarHTTPAseHTTPProtocolGetParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPAseHTTPProtocolGetParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPAseHTTPProtocolGetParamsTLSVersionTlSv1_2}), - }, - ) - 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/radarhttpaseipversion.go b/radarhttpaseipversion.go deleted file mode 100644 index 4efc1e99de3..00000000000 --- a/radarhttpaseipversion.go +++ /dev/null @@ -1,366 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPAseIPVersionService 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 [NewRadarHTTPAseIPVersionService] -// method instead. -type RadarHTTPAseIPVersionService struct { - Options []option.RequestOption -} - -// NewRadarHTTPAseIPVersionService 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 NewRadarHTTPAseIPVersionService(opts ...option.RequestOption) (r *RadarHTTPAseIPVersionService) { - r = &RadarHTTPAseIPVersionService{} - r.Options = opts - return -} - -// Get the top autonomous systems, by HTTP traffic, of the requested IP protocol -// version. Values are a percentage out of the total traffic. -func (r *RadarHTTPAseIPVersionService) Get(ctx context.Context, ipVersion RadarHTTPAseIPVersionGetParamsIPVersion, query RadarHTTPAseIPVersionGetParams, opts ...option.RequestOption) (res *RadarHTTPAseIPVersionGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPAseIPVersionGetResponseEnvelope - path := fmt.Sprintf("radar/http/top/ases/ip_version/%v", ipVersion) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPAseIPVersionGetResponse struct { - Meta RadarHTTPAseIPVersionGetResponseMeta `json:"meta,required"` - Top0 []RadarHTTPAseIPVersionGetResponseTop0 `json:"top_0,required"` - JSON radarHTTPAseIPVersionGetResponseJSON `json:"-"` -} - -// radarHTTPAseIPVersionGetResponseJSON contains the JSON metadata for the struct -// [RadarHTTPAseIPVersionGetResponse] -type radarHTTPAseIPVersionGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseIPVersionGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseIPVersionGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseIPVersionGetResponseMeta struct { - DateRange []RadarHTTPAseIPVersionGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarHTTPAseIPVersionGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPAseIPVersionGetResponseMetaJSON `json:"-"` -} - -// radarHTTPAseIPVersionGetResponseMetaJSON contains the JSON metadata for the -// struct [RadarHTTPAseIPVersionGetResponseMeta] -type radarHTTPAseIPVersionGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseIPVersionGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseIPVersionGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseIPVersionGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPAseIPVersionGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPAseIPVersionGetResponseMetaDateRangeJSON contains the JSON metadata for -// the struct [RadarHTTPAseIPVersionGetResponseMetaDateRange] -type radarHTTPAseIPVersionGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseIPVersionGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseIPVersionGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseIPVersionGetResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPAseIPVersionGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPAseIPVersionGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPAseIPVersionGetResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarHTTPAseIPVersionGetResponseMetaConfidenceInfo] -type radarHTTPAseIPVersionGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseIPVersionGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseIPVersionGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseIPVersionGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPAseIPVersionGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPAseIPVersionGetResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarHTTPAseIPVersionGetResponseMetaConfidenceInfoAnnotation] -type radarHTTPAseIPVersionGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseIPVersionGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseIPVersionGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseIPVersionGetResponseTop0 struct { - ClientASN int64 `json:"clientASN,required"` - ClientAsName string `json:"clientASName,required"` - Value string `json:"value,required"` - JSON radarHTTPAseIPVersionGetResponseTop0JSON `json:"-"` -} - -// radarHTTPAseIPVersionGetResponseTop0JSON contains the JSON metadata for the -// struct [RadarHTTPAseIPVersionGetResponseTop0] -type radarHTTPAseIPVersionGetResponseTop0JSON struct { - ClientASN apijson.Field - ClientAsName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseIPVersionGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseIPVersionGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseIPVersionGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPAseIPVersionGetParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPAseIPVersionGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPAseIPVersionGetParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPAseIPVersionGetParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPAseIPVersionGetParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPAseIPVersionGetParamsHTTPVersion] `query:"httpVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPAseIPVersionGetParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPAseIPVersionGetParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPAseIPVersionGetParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPAseIPVersionGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// IP version. -type RadarHTTPAseIPVersionGetParamsIPVersion string - -const ( - RadarHTTPAseIPVersionGetParamsIPVersionIPv4 RadarHTTPAseIPVersionGetParamsIPVersion = "IPv4" - RadarHTTPAseIPVersionGetParamsIPVersionIPv6 RadarHTTPAseIPVersionGetParamsIPVersion = "IPv6" -) - -type RadarHTTPAseIPVersionGetParamsBotClass string - -const ( - RadarHTTPAseIPVersionGetParamsBotClassLikelyAutomated RadarHTTPAseIPVersionGetParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPAseIPVersionGetParamsBotClassLikelyHuman RadarHTTPAseIPVersionGetParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPAseIPVersionGetParamsDateRange string - -const ( - RadarHTTPAseIPVersionGetParamsDateRange1d RadarHTTPAseIPVersionGetParamsDateRange = "1d" - RadarHTTPAseIPVersionGetParamsDateRange2d RadarHTTPAseIPVersionGetParamsDateRange = "2d" - RadarHTTPAseIPVersionGetParamsDateRange7d RadarHTTPAseIPVersionGetParamsDateRange = "7d" - RadarHTTPAseIPVersionGetParamsDateRange14d RadarHTTPAseIPVersionGetParamsDateRange = "14d" - RadarHTTPAseIPVersionGetParamsDateRange28d RadarHTTPAseIPVersionGetParamsDateRange = "28d" - RadarHTTPAseIPVersionGetParamsDateRange12w RadarHTTPAseIPVersionGetParamsDateRange = "12w" - RadarHTTPAseIPVersionGetParamsDateRange24w RadarHTTPAseIPVersionGetParamsDateRange = "24w" - RadarHTTPAseIPVersionGetParamsDateRange52w RadarHTTPAseIPVersionGetParamsDateRange = "52w" - RadarHTTPAseIPVersionGetParamsDateRange1dControl RadarHTTPAseIPVersionGetParamsDateRange = "1dControl" - RadarHTTPAseIPVersionGetParamsDateRange2dControl RadarHTTPAseIPVersionGetParamsDateRange = "2dControl" - RadarHTTPAseIPVersionGetParamsDateRange7dControl RadarHTTPAseIPVersionGetParamsDateRange = "7dControl" - RadarHTTPAseIPVersionGetParamsDateRange14dControl RadarHTTPAseIPVersionGetParamsDateRange = "14dControl" - RadarHTTPAseIPVersionGetParamsDateRange28dControl RadarHTTPAseIPVersionGetParamsDateRange = "28dControl" - RadarHTTPAseIPVersionGetParamsDateRange12wControl RadarHTTPAseIPVersionGetParamsDateRange = "12wControl" - RadarHTTPAseIPVersionGetParamsDateRange24wControl RadarHTTPAseIPVersionGetParamsDateRange = "24wControl" -) - -type RadarHTTPAseIPVersionGetParamsDeviceType string - -const ( - RadarHTTPAseIPVersionGetParamsDeviceTypeDesktop RadarHTTPAseIPVersionGetParamsDeviceType = "DESKTOP" - RadarHTTPAseIPVersionGetParamsDeviceTypeMobile RadarHTTPAseIPVersionGetParamsDeviceType = "MOBILE" - RadarHTTPAseIPVersionGetParamsDeviceTypeOther RadarHTTPAseIPVersionGetParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPAseIPVersionGetParamsFormat string - -const ( - RadarHTTPAseIPVersionGetParamsFormatJson RadarHTTPAseIPVersionGetParamsFormat = "JSON" - RadarHTTPAseIPVersionGetParamsFormatCsv RadarHTTPAseIPVersionGetParamsFormat = "CSV" -) - -type RadarHTTPAseIPVersionGetParamsHTTPProtocol string - -const ( - RadarHTTPAseIPVersionGetParamsHTTPProtocolHTTP RadarHTTPAseIPVersionGetParamsHTTPProtocol = "HTTP" - RadarHTTPAseIPVersionGetParamsHTTPProtocolHTTPS RadarHTTPAseIPVersionGetParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPAseIPVersionGetParamsHTTPVersion string - -const ( - RadarHTTPAseIPVersionGetParamsHTTPVersionHttPv1 RadarHTTPAseIPVersionGetParamsHTTPVersion = "HTTPv1" - RadarHTTPAseIPVersionGetParamsHTTPVersionHttPv2 RadarHTTPAseIPVersionGetParamsHTTPVersion = "HTTPv2" - RadarHTTPAseIPVersionGetParamsHTTPVersionHttPv3 RadarHTTPAseIPVersionGetParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPAseIPVersionGetParamsOS string - -const ( - RadarHTTPAseIPVersionGetParamsOSWindows RadarHTTPAseIPVersionGetParamsOS = "WINDOWS" - RadarHTTPAseIPVersionGetParamsOSMacosx RadarHTTPAseIPVersionGetParamsOS = "MACOSX" - RadarHTTPAseIPVersionGetParamsOSIos RadarHTTPAseIPVersionGetParamsOS = "IOS" - RadarHTTPAseIPVersionGetParamsOSAndroid RadarHTTPAseIPVersionGetParamsOS = "ANDROID" - RadarHTTPAseIPVersionGetParamsOSChromeos RadarHTTPAseIPVersionGetParamsOS = "CHROMEOS" - RadarHTTPAseIPVersionGetParamsOSLinux RadarHTTPAseIPVersionGetParamsOS = "LINUX" - RadarHTTPAseIPVersionGetParamsOSSmartTv RadarHTTPAseIPVersionGetParamsOS = "SMART_TV" -) - -type RadarHTTPAseIPVersionGetParamsTLSVersion string - -const ( - RadarHTTPAseIPVersionGetParamsTLSVersionTlSv1_0 RadarHTTPAseIPVersionGetParamsTLSVersion = "TLSv1_0" - RadarHTTPAseIPVersionGetParamsTLSVersionTlSv1_1 RadarHTTPAseIPVersionGetParamsTLSVersion = "TLSv1_1" - RadarHTTPAseIPVersionGetParamsTLSVersionTlSv1_2 RadarHTTPAseIPVersionGetParamsTLSVersion = "TLSv1_2" - RadarHTTPAseIPVersionGetParamsTLSVersionTlSv1_3 RadarHTTPAseIPVersionGetParamsTLSVersion = "TLSv1_3" - RadarHTTPAseIPVersionGetParamsTLSVersionTlSvQuic RadarHTTPAseIPVersionGetParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPAseIPVersionGetResponseEnvelope struct { - Result RadarHTTPAseIPVersionGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPAseIPVersionGetResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPAseIPVersionGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarHTTPAseIPVersionGetResponseEnvelope] -type radarHTTPAseIPVersionGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseIPVersionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseIPVersionGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttpaseipversion_test.go b/radarhttpaseipversion_test.go deleted file mode 100644 index 98c2e9bb3a7..00000000000 --- a/radarhttpaseipversion_test.go +++ /dev/null @@ -1,59 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPAseIPVersionGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Ases.IPVersion.Get( - context.TODO(), - cloudflare.RadarHTTPAseIPVersionGetParamsIPVersionIPv4, - cloudflare.RadarHTTPAseIPVersionGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPAseIPVersionGetParamsBotClass{cloudflare.RadarHTTPAseIPVersionGetParamsBotClassLikelyAutomated, cloudflare.RadarHTTPAseIPVersionGetParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPAseIPVersionGetParamsDateRange{cloudflare.RadarHTTPAseIPVersionGetParamsDateRange1d, cloudflare.RadarHTTPAseIPVersionGetParamsDateRange2d, cloudflare.RadarHTTPAseIPVersionGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPAseIPVersionGetParamsDeviceType{cloudflare.RadarHTTPAseIPVersionGetParamsDeviceTypeDesktop, cloudflare.RadarHTTPAseIPVersionGetParamsDeviceTypeMobile, cloudflare.RadarHTTPAseIPVersionGetParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPAseIPVersionGetParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPAseIPVersionGetParamsHTTPProtocol{cloudflare.RadarHTTPAseIPVersionGetParamsHTTPProtocolHTTP, cloudflare.RadarHTTPAseIPVersionGetParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPAseIPVersionGetParamsHTTPVersion{cloudflare.RadarHTTPAseIPVersionGetParamsHTTPVersionHttPv1, cloudflare.RadarHTTPAseIPVersionGetParamsHTTPVersionHttPv2, cloudflare.RadarHTTPAseIPVersionGetParamsHTTPVersionHttPv3}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPAseIPVersionGetParamsOS{cloudflare.RadarHTTPAseIPVersionGetParamsOSWindows, cloudflare.RadarHTTPAseIPVersionGetParamsOSMacosx, cloudflare.RadarHTTPAseIPVersionGetParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPAseIPVersionGetParamsTLSVersion{cloudflare.RadarHTTPAseIPVersionGetParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPAseIPVersionGetParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPAseIPVersionGetParamsTLSVersionTlSv1_2}), - }, - ) - 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/radarhttpaseos.go b/radarhttpaseos.go deleted file mode 100644 index 8a49d823204..00000000000 --- a/radarhttpaseos.go +++ /dev/null @@ -1,365 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPAseOSService 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 [NewRadarHTTPAseOSService] method -// instead. -type RadarHTTPAseOSService struct { - Options []option.RequestOption -} - -// NewRadarHTTPAseOSService 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 NewRadarHTTPAseOSService(opts ...option.RequestOption) (r *RadarHTTPAseOSService) { - r = &RadarHTTPAseOSService{} - r.Options = opts - return -} - -// Get the top autonomous systems, by HTTP traffic, of the requested operating -// systems. Values are a percentage out of the total traffic. -func (r *RadarHTTPAseOSService) Get(ctx context.Context, os RadarHTTPAseOSGetParamsOS, query RadarHTTPAseOSGetParams, opts ...option.RequestOption) (res *RadarHTTPAseOSGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPAseOSGetResponseEnvelope - path := fmt.Sprintf("radar/http/top/ases/os/%v", os) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPAseOSGetResponse struct { - Meta RadarHTTPAseOSGetResponseMeta `json:"meta,required"` - Top0 []RadarHTTPAseOSGetResponseTop0 `json:"top_0,required"` - JSON radarHTTPAseOSGetResponseJSON `json:"-"` -} - -// radarHTTPAseOSGetResponseJSON contains the JSON metadata for the struct -// [RadarHTTPAseOSGetResponse] -type radarHTTPAseOSGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseOSGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseOSGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseOSGetResponseMeta struct { - DateRange []RadarHTTPAseOSGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarHTTPAseOSGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPAseOSGetResponseMetaJSON `json:"-"` -} - -// radarHTTPAseOSGetResponseMetaJSON contains the JSON metadata for the struct -// [RadarHTTPAseOSGetResponseMeta] -type radarHTTPAseOSGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseOSGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseOSGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseOSGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPAseOSGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPAseOSGetResponseMetaDateRangeJSON contains the JSON metadata for the -// struct [RadarHTTPAseOSGetResponseMetaDateRange] -type radarHTTPAseOSGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseOSGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseOSGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseOSGetResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPAseOSGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPAseOSGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPAseOSGetResponseMetaConfidenceInfoJSON contains the JSON metadata for -// the struct [RadarHTTPAseOSGetResponseMetaConfidenceInfo] -type radarHTTPAseOSGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseOSGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseOSGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseOSGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPAseOSGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPAseOSGetResponseMetaConfidenceInfoAnnotationJSON contains the JSON -// metadata for the struct [RadarHTTPAseOSGetResponseMetaConfidenceInfoAnnotation] -type radarHTTPAseOSGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseOSGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseOSGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseOSGetResponseTop0 struct { - ClientASN int64 `json:"clientASN,required"` - ClientAsName string `json:"clientASName,required"` - Value string `json:"value,required"` - JSON radarHTTPAseOSGetResponseTop0JSON `json:"-"` -} - -// radarHTTPAseOSGetResponseTop0JSON contains the JSON metadata for the struct -// [RadarHTTPAseOSGetResponseTop0] -type radarHTTPAseOSGetResponseTop0JSON struct { - ClientASN apijson.Field - ClientAsName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseOSGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseOSGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseOSGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPAseOSGetParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPAseOSGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPAseOSGetParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPAseOSGetParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPAseOSGetParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPAseOSGetParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPAseOSGetParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPAseOSGetParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPAseOSGetParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPAseOSGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// IP version. -type RadarHTTPAseOSGetParamsOS string - -const ( - RadarHTTPAseOSGetParamsOSWindows RadarHTTPAseOSGetParamsOS = "WINDOWS" - RadarHTTPAseOSGetParamsOSMacosx RadarHTTPAseOSGetParamsOS = "MACOSX" - RadarHTTPAseOSGetParamsOSIos RadarHTTPAseOSGetParamsOS = "IOS" - RadarHTTPAseOSGetParamsOSAndroid RadarHTTPAseOSGetParamsOS = "ANDROID" - RadarHTTPAseOSGetParamsOSChromeos RadarHTTPAseOSGetParamsOS = "CHROMEOS" - RadarHTTPAseOSGetParamsOSLinux RadarHTTPAseOSGetParamsOS = "LINUX" - RadarHTTPAseOSGetParamsOSSmartTv RadarHTTPAseOSGetParamsOS = "SMART_TV" -) - -type RadarHTTPAseOSGetParamsBotClass string - -const ( - RadarHTTPAseOSGetParamsBotClassLikelyAutomated RadarHTTPAseOSGetParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPAseOSGetParamsBotClassLikelyHuman RadarHTTPAseOSGetParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPAseOSGetParamsDateRange string - -const ( - RadarHTTPAseOSGetParamsDateRange1d RadarHTTPAseOSGetParamsDateRange = "1d" - RadarHTTPAseOSGetParamsDateRange2d RadarHTTPAseOSGetParamsDateRange = "2d" - RadarHTTPAseOSGetParamsDateRange7d RadarHTTPAseOSGetParamsDateRange = "7d" - RadarHTTPAseOSGetParamsDateRange14d RadarHTTPAseOSGetParamsDateRange = "14d" - RadarHTTPAseOSGetParamsDateRange28d RadarHTTPAseOSGetParamsDateRange = "28d" - RadarHTTPAseOSGetParamsDateRange12w RadarHTTPAseOSGetParamsDateRange = "12w" - RadarHTTPAseOSGetParamsDateRange24w RadarHTTPAseOSGetParamsDateRange = "24w" - RadarHTTPAseOSGetParamsDateRange52w RadarHTTPAseOSGetParamsDateRange = "52w" - RadarHTTPAseOSGetParamsDateRange1dControl RadarHTTPAseOSGetParamsDateRange = "1dControl" - RadarHTTPAseOSGetParamsDateRange2dControl RadarHTTPAseOSGetParamsDateRange = "2dControl" - RadarHTTPAseOSGetParamsDateRange7dControl RadarHTTPAseOSGetParamsDateRange = "7dControl" - RadarHTTPAseOSGetParamsDateRange14dControl RadarHTTPAseOSGetParamsDateRange = "14dControl" - RadarHTTPAseOSGetParamsDateRange28dControl RadarHTTPAseOSGetParamsDateRange = "28dControl" - RadarHTTPAseOSGetParamsDateRange12wControl RadarHTTPAseOSGetParamsDateRange = "12wControl" - RadarHTTPAseOSGetParamsDateRange24wControl RadarHTTPAseOSGetParamsDateRange = "24wControl" -) - -type RadarHTTPAseOSGetParamsDeviceType string - -const ( - RadarHTTPAseOSGetParamsDeviceTypeDesktop RadarHTTPAseOSGetParamsDeviceType = "DESKTOP" - RadarHTTPAseOSGetParamsDeviceTypeMobile RadarHTTPAseOSGetParamsDeviceType = "MOBILE" - RadarHTTPAseOSGetParamsDeviceTypeOther RadarHTTPAseOSGetParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPAseOSGetParamsFormat string - -const ( - RadarHTTPAseOSGetParamsFormatJson RadarHTTPAseOSGetParamsFormat = "JSON" - RadarHTTPAseOSGetParamsFormatCsv RadarHTTPAseOSGetParamsFormat = "CSV" -) - -type RadarHTTPAseOSGetParamsHTTPProtocol string - -const ( - RadarHTTPAseOSGetParamsHTTPProtocolHTTP RadarHTTPAseOSGetParamsHTTPProtocol = "HTTP" - RadarHTTPAseOSGetParamsHTTPProtocolHTTPS RadarHTTPAseOSGetParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPAseOSGetParamsHTTPVersion string - -const ( - RadarHTTPAseOSGetParamsHTTPVersionHttPv1 RadarHTTPAseOSGetParamsHTTPVersion = "HTTPv1" - RadarHTTPAseOSGetParamsHTTPVersionHttPv2 RadarHTTPAseOSGetParamsHTTPVersion = "HTTPv2" - RadarHTTPAseOSGetParamsHTTPVersionHttPv3 RadarHTTPAseOSGetParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPAseOSGetParamsIPVersion string - -const ( - RadarHTTPAseOSGetParamsIPVersionIPv4 RadarHTTPAseOSGetParamsIPVersion = "IPv4" - RadarHTTPAseOSGetParamsIPVersionIPv6 RadarHTTPAseOSGetParamsIPVersion = "IPv6" -) - -type RadarHTTPAseOSGetParamsTLSVersion string - -const ( - RadarHTTPAseOSGetParamsTLSVersionTlSv1_0 RadarHTTPAseOSGetParamsTLSVersion = "TLSv1_0" - RadarHTTPAseOSGetParamsTLSVersionTlSv1_1 RadarHTTPAseOSGetParamsTLSVersion = "TLSv1_1" - RadarHTTPAseOSGetParamsTLSVersionTlSv1_2 RadarHTTPAseOSGetParamsTLSVersion = "TLSv1_2" - RadarHTTPAseOSGetParamsTLSVersionTlSv1_3 RadarHTTPAseOSGetParamsTLSVersion = "TLSv1_3" - RadarHTTPAseOSGetParamsTLSVersionTlSvQuic RadarHTTPAseOSGetParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPAseOSGetResponseEnvelope struct { - Result RadarHTTPAseOSGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPAseOSGetResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPAseOSGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [RadarHTTPAseOSGetResponseEnvelope] -type radarHTTPAseOSGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseOSGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseOSGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttpaseos_test.go b/radarhttpaseos_test.go deleted file mode 100644 index 26bece2de1a..00000000000 --- a/radarhttpaseos_test.go +++ /dev/null @@ -1,59 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPAseOSGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Ases.OS.Get( - context.TODO(), - cloudflare.RadarHTTPAseOSGetParamsOSWindows, - cloudflare.RadarHTTPAseOSGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPAseOSGetParamsBotClass{cloudflare.RadarHTTPAseOSGetParamsBotClassLikelyAutomated, cloudflare.RadarHTTPAseOSGetParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPAseOSGetParamsDateRange{cloudflare.RadarHTTPAseOSGetParamsDateRange1d, cloudflare.RadarHTTPAseOSGetParamsDateRange2d, cloudflare.RadarHTTPAseOSGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPAseOSGetParamsDeviceType{cloudflare.RadarHTTPAseOSGetParamsDeviceTypeDesktop, cloudflare.RadarHTTPAseOSGetParamsDeviceTypeMobile, cloudflare.RadarHTTPAseOSGetParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPAseOSGetParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPAseOSGetParamsHTTPProtocol{cloudflare.RadarHTTPAseOSGetParamsHTTPProtocolHTTP, cloudflare.RadarHTTPAseOSGetParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPAseOSGetParamsHTTPVersion{cloudflare.RadarHTTPAseOSGetParamsHTTPVersionHttPv1, cloudflare.RadarHTTPAseOSGetParamsHTTPVersionHttPv2, cloudflare.RadarHTTPAseOSGetParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPAseOSGetParamsIPVersion{cloudflare.RadarHTTPAseOSGetParamsIPVersionIPv4, cloudflare.RadarHTTPAseOSGetParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPAseOSGetParamsTLSVersion{cloudflare.RadarHTTPAseOSGetParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPAseOSGetParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPAseOSGetParamsTLSVersionTlSv1_2}), - }, - ) - 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/radarhttpasetlsversion.go b/radarhttpasetlsversion.go deleted file mode 100644 index e85293c151d..00000000000 --- a/radarhttpasetlsversion.go +++ /dev/null @@ -1,366 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPAseTLSVersionService 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 [NewRadarHTTPAseTLSVersionService] -// method instead. -type RadarHTTPAseTLSVersionService struct { - Options []option.RequestOption -} - -// NewRadarHTTPAseTLSVersionService 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 NewRadarHTTPAseTLSVersionService(opts ...option.RequestOption) (r *RadarHTTPAseTLSVersionService) { - r = &RadarHTTPAseTLSVersionService{} - r.Options = opts - return -} - -// Get the top autonomous systems (AS), by HTTP traffic, of the requested TLS -// protocol version. Values are a percentage out of the total traffic. -func (r *RadarHTTPAseTLSVersionService) Get(ctx context.Context, tlsVersion RadarHTTPAseTLSVersionGetParamsTLSVersion, query RadarHTTPAseTLSVersionGetParams, opts ...option.RequestOption) (res *RadarHTTPAseTLSVersionGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPAseTLSVersionGetResponseEnvelope - path := fmt.Sprintf("radar/http/top/ases/tls_version/%v", tlsVersion) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPAseTLSVersionGetResponse struct { - Meta RadarHTTPAseTLSVersionGetResponseMeta `json:"meta,required"` - Top0 []RadarHTTPAseTLSVersionGetResponseTop0 `json:"top_0,required"` - JSON radarHTTPAseTLSVersionGetResponseJSON `json:"-"` -} - -// radarHTTPAseTLSVersionGetResponseJSON contains the JSON metadata for the struct -// [RadarHTTPAseTLSVersionGetResponse] -type radarHTTPAseTLSVersionGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseTLSVersionGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseTLSVersionGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseTLSVersionGetResponseMeta struct { - DateRange []RadarHTTPAseTLSVersionGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarHTTPAseTLSVersionGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPAseTLSVersionGetResponseMetaJSON `json:"-"` -} - -// radarHTTPAseTLSVersionGetResponseMetaJSON contains the JSON metadata for the -// struct [RadarHTTPAseTLSVersionGetResponseMeta] -type radarHTTPAseTLSVersionGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseTLSVersionGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseTLSVersionGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseTLSVersionGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPAseTLSVersionGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPAseTLSVersionGetResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarHTTPAseTLSVersionGetResponseMetaDateRange] -type radarHTTPAseTLSVersionGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseTLSVersionGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseTLSVersionGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseTLSVersionGetResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPAseTLSVersionGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPAseTLSVersionGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPAseTLSVersionGetResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarHTTPAseTLSVersionGetResponseMetaConfidenceInfo] -type radarHTTPAseTLSVersionGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseTLSVersionGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseTLSVersionGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseTLSVersionGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPAseTLSVersionGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPAseTLSVersionGetResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarHTTPAseTLSVersionGetResponseMetaConfidenceInfoAnnotation] -type radarHTTPAseTLSVersionGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseTLSVersionGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseTLSVersionGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseTLSVersionGetResponseTop0 struct { - ClientASN int64 `json:"clientASN,required"` - ClientAsName string `json:"clientASName,required"` - Value string `json:"value,required"` - JSON radarHTTPAseTLSVersionGetResponseTop0JSON `json:"-"` -} - -// radarHTTPAseTLSVersionGetResponseTop0JSON contains the JSON metadata for the -// struct [RadarHTTPAseTLSVersionGetResponseTop0] -type radarHTTPAseTLSVersionGetResponseTop0JSON struct { - ClientASN apijson.Field - ClientAsName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseTLSVersionGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseTLSVersionGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPAseTLSVersionGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPAseTLSVersionGetParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPAseTLSVersionGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPAseTLSVersionGetParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPAseTLSVersionGetParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPAseTLSVersionGetParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPAseTLSVersionGetParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPAseTLSVersionGetParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPAseTLSVersionGetParamsOS] `query:"os"` -} - -// URLQuery serializes [RadarHTTPAseTLSVersionGetParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPAseTLSVersionGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// TLS version. -type RadarHTTPAseTLSVersionGetParamsTLSVersion string - -const ( - RadarHTTPAseTLSVersionGetParamsTLSVersionTlSv1_0 RadarHTTPAseTLSVersionGetParamsTLSVersion = "TLSv1_0" - RadarHTTPAseTLSVersionGetParamsTLSVersionTlSv1_1 RadarHTTPAseTLSVersionGetParamsTLSVersion = "TLSv1_1" - RadarHTTPAseTLSVersionGetParamsTLSVersionTlSv1_2 RadarHTTPAseTLSVersionGetParamsTLSVersion = "TLSv1_2" - RadarHTTPAseTLSVersionGetParamsTLSVersionTlSv1_3 RadarHTTPAseTLSVersionGetParamsTLSVersion = "TLSv1_3" - RadarHTTPAseTLSVersionGetParamsTLSVersionTlSvQuic RadarHTTPAseTLSVersionGetParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPAseTLSVersionGetParamsBotClass string - -const ( - RadarHTTPAseTLSVersionGetParamsBotClassLikelyAutomated RadarHTTPAseTLSVersionGetParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPAseTLSVersionGetParamsBotClassLikelyHuman RadarHTTPAseTLSVersionGetParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPAseTLSVersionGetParamsDateRange string - -const ( - RadarHTTPAseTLSVersionGetParamsDateRange1d RadarHTTPAseTLSVersionGetParamsDateRange = "1d" - RadarHTTPAseTLSVersionGetParamsDateRange2d RadarHTTPAseTLSVersionGetParamsDateRange = "2d" - RadarHTTPAseTLSVersionGetParamsDateRange7d RadarHTTPAseTLSVersionGetParamsDateRange = "7d" - RadarHTTPAseTLSVersionGetParamsDateRange14d RadarHTTPAseTLSVersionGetParamsDateRange = "14d" - RadarHTTPAseTLSVersionGetParamsDateRange28d RadarHTTPAseTLSVersionGetParamsDateRange = "28d" - RadarHTTPAseTLSVersionGetParamsDateRange12w RadarHTTPAseTLSVersionGetParamsDateRange = "12w" - RadarHTTPAseTLSVersionGetParamsDateRange24w RadarHTTPAseTLSVersionGetParamsDateRange = "24w" - RadarHTTPAseTLSVersionGetParamsDateRange52w RadarHTTPAseTLSVersionGetParamsDateRange = "52w" - RadarHTTPAseTLSVersionGetParamsDateRange1dControl RadarHTTPAseTLSVersionGetParamsDateRange = "1dControl" - RadarHTTPAseTLSVersionGetParamsDateRange2dControl RadarHTTPAseTLSVersionGetParamsDateRange = "2dControl" - RadarHTTPAseTLSVersionGetParamsDateRange7dControl RadarHTTPAseTLSVersionGetParamsDateRange = "7dControl" - RadarHTTPAseTLSVersionGetParamsDateRange14dControl RadarHTTPAseTLSVersionGetParamsDateRange = "14dControl" - RadarHTTPAseTLSVersionGetParamsDateRange28dControl RadarHTTPAseTLSVersionGetParamsDateRange = "28dControl" - RadarHTTPAseTLSVersionGetParamsDateRange12wControl RadarHTTPAseTLSVersionGetParamsDateRange = "12wControl" - RadarHTTPAseTLSVersionGetParamsDateRange24wControl RadarHTTPAseTLSVersionGetParamsDateRange = "24wControl" -) - -type RadarHTTPAseTLSVersionGetParamsDeviceType string - -const ( - RadarHTTPAseTLSVersionGetParamsDeviceTypeDesktop RadarHTTPAseTLSVersionGetParamsDeviceType = "DESKTOP" - RadarHTTPAseTLSVersionGetParamsDeviceTypeMobile RadarHTTPAseTLSVersionGetParamsDeviceType = "MOBILE" - RadarHTTPAseTLSVersionGetParamsDeviceTypeOther RadarHTTPAseTLSVersionGetParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPAseTLSVersionGetParamsFormat string - -const ( - RadarHTTPAseTLSVersionGetParamsFormatJson RadarHTTPAseTLSVersionGetParamsFormat = "JSON" - RadarHTTPAseTLSVersionGetParamsFormatCsv RadarHTTPAseTLSVersionGetParamsFormat = "CSV" -) - -type RadarHTTPAseTLSVersionGetParamsHTTPProtocol string - -const ( - RadarHTTPAseTLSVersionGetParamsHTTPProtocolHTTP RadarHTTPAseTLSVersionGetParamsHTTPProtocol = "HTTP" - RadarHTTPAseTLSVersionGetParamsHTTPProtocolHTTPS RadarHTTPAseTLSVersionGetParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPAseTLSVersionGetParamsHTTPVersion string - -const ( - RadarHTTPAseTLSVersionGetParamsHTTPVersionHttPv1 RadarHTTPAseTLSVersionGetParamsHTTPVersion = "HTTPv1" - RadarHTTPAseTLSVersionGetParamsHTTPVersionHttPv2 RadarHTTPAseTLSVersionGetParamsHTTPVersion = "HTTPv2" - RadarHTTPAseTLSVersionGetParamsHTTPVersionHttPv3 RadarHTTPAseTLSVersionGetParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPAseTLSVersionGetParamsIPVersion string - -const ( - RadarHTTPAseTLSVersionGetParamsIPVersionIPv4 RadarHTTPAseTLSVersionGetParamsIPVersion = "IPv4" - RadarHTTPAseTLSVersionGetParamsIPVersionIPv6 RadarHTTPAseTLSVersionGetParamsIPVersion = "IPv6" -) - -type RadarHTTPAseTLSVersionGetParamsOS string - -const ( - RadarHTTPAseTLSVersionGetParamsOSWindows RadarHTTPAseTLSVersionGetParamsOS = "WINDOWS" - RadarHTTPAseTLSVersionGetParamsOSMacosx RadarHTTPAseTLSVersionGetParamsOS = "MACOSX" - RadarHTTPAseTLSVersionGetParamsOSIos RadarHTTPAseTLSVersionGetParamsOS = "IOS" - RadarHTTPAseTLSVersionGetParamsOSAndroid RadarHTTPAseTLSVersionGetParamsOS = "ANDROID" - RadarHTTPAseTLSVersionGetParamsOSChromeos RadarHTTPAseTLSVersionGetParamsOS = "CHROMEOS" - RadarHTTPAseTLSVersionGetParamsOSLinux RadarHTTPAseTLSVersionGetParamsOS = "LINUX" - RadarHTTPAseTLSVersionGetParamsOSSmartTv RadarHTTPAseTLSVersionGetParamsOS = "SMART_TV" -) - -type RadarHTTPAseTLSVersionGetResponseEnvelope struct { - Result RadarHTTPAseTLSVersionGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPAseTLSVersionGetResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPAseTLSVersionGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarHTTPAseTLSVersionGetResponseEnvelope] -type radarHTTPAseTLSVersionGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPAseTLSVersionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPAseTLSVersionGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttpasetlsversion_test.go b/radarhttpasetlsversion_test.go deleted file mode 100644 index 25de37e42df..00000000000 --- a/radarhttpasetlsversion_test.go +++ /dev/null @@ -1,59 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPAseTLSVersionGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Ases.TLSVersion.Get( - context.TODO(), - cloudflare.RadarHTTPAseTLSVersionGetParamsTLSVersionTlSv1_0, - cloudflare.RadarHTTPAseTLSVersionGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPAseTLSVersionGetParamsBotClass{cloudflare.RadarHTTPAseTLSVersionGetParamsBotClassLikelyAutomated, cloudflare.RadarHTTPAseTLSVersionGetParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPAseTLSVersionGetParamsDateRange{cloudflare.RadarHTTPAseTLSVersionGetParamsDateRange1d, cloudflare.RadarHTTPAseTLSVersionGetParamsDateRange2d, cloudflare.RadarHTTPAseTLSVersionGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPAseTLSVersionGetParamsDeviceType{cloudflare.RadarHTTPAseTLSVersionGetParamsDeviceTypeDesktop, cloudflare.RadarHTTPAseTLSVersionGetParamsDeviceTypeMobile, cloudflare.RadarHTTPAseTLSVersionGetParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPAseTLSVersionGetParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPAseTLSVersionGetParamsHTTPProtocol{cloudflare.RadarHTTPAseTLSVersionGetParamsHTTPProtocolHTTP, cloudflare.RadarHTTPAseTLSVersionGetParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPAseTLSVersionGetParamsHTTPVersion{cloudflare.RadarHTTPAseTLSVersionGetParamsHTTPVersionHttPv1, cloudflare.RadarHTTPAseTLSVersionGetParamsHTTPVersionHttPv2, cloudflare.RadarHTTPAseTLSVersionGetParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPAseTLSVersionGetParamsIPVersion{cloudflare.RadarHTTPAseTLSVersionGetParamsIPVersionIPv4, cloudflare.RadarHTTPAseTLSVersionGetParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPAseTLSVersionGetParamsOS{cloudflare.RadarHTTPAseTLSVersionGetParamsOSWindows, cloudflare.RadarHTTPAseTLSVersionGetParamsOSMacosx, cloudflare.RadarHTTPAseTLSVersionGetParamsOSIos}), - }, - ) - 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/radarhttplocation.go b/radarhttplocation.go deleted file mode 100644 index 6c7b3c5ef50..00000000000 --- a/radarhttplocation.go +++ /dev/null @@ -1,380 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPLocationService 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 [NewRadarHTTPLocationService] method -// instead. -type RadarHTTPLocationService struct { - Options []option.RequestOption - BotClass *RadarHTTPLocationBotClassService - DeviceType *RadarHTTPLocationDeviceTypeService - HTTPProtocol *RadarHTTPLocationHTTPProtocolService - HTTPMethod *RadarHTTPLocationHTTPMethodService - IPVersion *RadarHTTPLocationIPVersionService - OS *RadarHTTPLocationOSService - TLSVersion *RadarHTTPLocationTLSVersionService -} - -// NewRadarHTTPLocationService 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 NewRadarHTTPLocationService(opts ...option.RequestOption) (r *RadarHTTPLocationService) { - r = &RadarHTTPLocationService{} - r.Options = opts - r.BotClass = NewRadarHTTPLocationBotClassService(opts...) - r.DeviceType = NewRadarHTTPLocationDeviceTypeService(opts...) - r.HTTPProtocol = NewRadarHTTPLocationHTTPProtocolService(opts...) - r.HTTPMethod = NewRadarHTTPLocationHTTPMethodService(opts...) - r.IPVersion = NewRadarHTTPLocationIPVersionService(opts...) - r.OS = NewRadarHTTPLocationOSService(opts...) - r.TLSVersion = NewRadarHTTPLocationTLSVersionService(opts...) - return -} - -// Get the top locations by HTTP traffic. Values are a percentage out of the total -// traffic. -func (r *RadarHTTPLocationService) Get(ctx context.Context, query RadarHTTPLocationGetParams, opts ...option.RequestOption) (res *RadarHTTPLocationGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPLocationGetResponseEnvelope - path := "radar/http/top/locations" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPLocationGetResponse struct { - Meta RadarHTTPLocationGetResponseMeta `json:"meta,required"` - Top0 []RadarHTTPLocationGetResponseTop0 `json:"top_0,required"` - JSON radarHTTPLocationGetResponseJSON `json:"-"` -} - -// radarHTTPLocationGetResponseJSON contains the JSON metadata for the struct -// [RadarHTTPLocationGetResponse] -type radarHTTPLocationGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationGetResponseMeta struct { - DateRange []RadarHTTPLocationGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarHTTPLocationGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPLocationGetResponseMetaJSON `json:"-"` -} - -// radarHTTPLocationGetResponseMetaJSON contains the JSON metadata for the struct -// [RadarHTTPLocationGetResponseMeta] -type radarHTTPLocationGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPLocationGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPLocationGetResponseMetaDateRangeJSON contains the JSON metadata for the -// struct [RadarHTTPLocationGetResponseMetaDateRange] -type radarHTTPLocationGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationGetResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPLocationGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPLocationGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPLocationGetResponseMetaConfidenceInfoJSON contains the JSON metadata -// for the struct [RadarHTTPLocationGetResponseMetaConfidenceInfo] -type radarHTTPLocationGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPLocationGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPLocationGetResponseMetaConfidenceInfoAnnotationJSON contains the JSON -// metadata for the struct -// [RadarHTTPLocationGetResponseMetaConfidenceInfoAnnotation] -type radarHTTPLocationGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationGetResponseTop0 struct { - ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` - ClientCountryName string `json:"clientCountryName,required"` - Value string `json:"value,required"` - JSON radarHTTPLocationGetResponseTop0JSON `json:"-"` -} - -// radarHTTPLocationGetResponseTop0JSON contains the JSON metadata for the struct -// [RadarHTTPLocationGetResponseTop0] -type radarHTTPLocationGetResponseTop0JSON struct { - ClientCountryAlpha2 apijson.Field - ClientCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPLocationGetParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPLocationGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPLocationGetParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPLocationGetParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPLocationGetParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPLocationGetParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPLocationGetParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPLocationGetParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPLocationGetParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPLocationGetParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPLocationGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarHTTPLocationGetParamsBotClass string - -const ( - RadarHTTPLocationGetParamsBotClassLikelyAutomated RadarHTTPLocationGetParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPLocationGetParamsBotClassLikelyHuman RadarHTTPLocationGetParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPLocationGetParamsDateRange string - -const ( - RadarHTTPLocationGetParamsDateRange1d RadarHTTPLocationGetParamsDateRange = "1d" - RadarHTTPLocationGetParamsDateRange2d RadarHTTPLocationGetParamsDateRange = "2d" - RadarHTTPLocationGetParamsDateRange7d RadarHTTPLocationGetParamsDateRange = "7d" - RadarHTTPLocationGetParamsDateRange14d RadarHTTPLocationGetParamsDateRange = "14d" - RadarHTTPLocationGetParamsDateRange28d RadarHTTPLocationGetParamsDateRange = "28d" - RadarHTTPLocationGetParamsDateRange12w RadarHTTPLocationGetParamsDateRange = "12w" - RadarHTTPLocationGetParamsDateRange24w RadarHTTPLocationGetParamsDateRange = "24w" - RadarHTTPLocationGetParamsDateRange52w RadarHTTPLocationGetParamsDateRange = "52w" - RadarHTTPLocationGetParamsDateRange1dControl RadarHTTPLocationGetParamsDateRange = "1dControl" - RadarHTTPLocationGetParamsDateRange2dControl RadarHTTPLocationGetParamsDateRange = "2dControl" - RadarHTTPLocationGetParamsDateRange7dControl RadarHTTPLocationGetParamsDateRange = "7dControl" - RadarHTTPLocationGetParamsDateRange14dControl RadarHTTPLocationGetParamsDateRange = "14dControl" - RadarHTTPLocationGetParamsDateRange28dControl RadarHTTPLocationGetParamsDateRange = "28dControl" - RadarHTTPLocationGetParamsDateRange12wControl RadarHTTPLocationGetParamsDateRange = "12wControl" - RadarHTTPLocationGetParamsDateRange24wControl RadarHTTPLocationGetParamsDateRange = "24wControl" -) - -type RadarHTTPLocationGetParamsDeviceType string - -const ( - RadarHTTPLocationGetParamsDeviceTypeDesktop RadarHTTPLocationGetParamsDeviceType = "DESKTOP" - RadarHTTPLocationGetParamsDeviceTypeMobile RadarHTTPLocationGetParamsDeviceType = "MOBILE" - RadarHTTPLocationGetParamsDeviceTypeOther RadarHTTPLocationGetParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPLocationGetParamsFormat string - -const ( - RadarHTTPLocationGetParamsFormatJson RadarHTTPLocationGetParamsFormat = "JSON" - RadarHTTPLocationGetParamsFormatCsv RadarHTTPLocationGetParamsFormat = "CSV" -) - -type RadarHTTPLocationGetParamsHTTPProtocol string - -const ( - RadarHTTPLocationGetParamsHTTPProtocolHTTP RadarHTTPLocationGetParamsHTTPProtocol = "HTTP" - RadarHTTPLocationGetParamsHTTPProtocolHTTPS RadarHTTPLocationGetParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPLocationGetParamsHTTPVersion string - -const ( - RadarHTTPLocationGetParamsHTTPVersionHttPv1 RadarHTTPLocationGetParamsHTTPVersion = "HTTPv1" - RadarHTTPLocationGetParamsHTTPVersionHttPv2 RadarHTTPLocationGetParamsHTTPVersion = "HTTPv2" - RadarHTTPLocationGetParamsHTTPVersionHttPv3 RadarHTTPLocationGetParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPLocationGetParamsIPVersion string - -const ( - RadarHTTPLocationGetParamsIPVersionIPv4 RadarHTTPLocationGetParamsIPVersion = "IPv4" - RadarHTTPLocationGetParamsIPVersionIPv6 RadarHTTPLocationGetParamsIPVersion = "IPv6" -) - -type RadarHTTPLocationGetParamsOS string - -const ( - RadarHTTPLocationGetParamsOSWindows RadarHTTPLocationGetParamsOS = "WINDOWS" - RadarHTTPLocationGetParamsOSMacosx RadarHTTPLocationGetParamsOS = "MACOSX" - RadarHTTPLocationGetParamsOSIos RadarHTTPLocationGetParamsOS = "IOS" - RadarHTTPLocationGetParamsOSAndroid RadarHTTPLocationGetParamsOS = "ANDROID" - RadarHTTPLocationGetParamsOSChromeos RadarHTTPLocationGetParamsOS = "CHROMEOS" - RadarHTTPLocationGetParamsOSLinux RadarHTTPLocationGetParamsOS = "LINUX" - RadarHTTPLocationGetParamsOSSmartTv RadarHTTPLocationGetParamsOS = "SMART_TV" -) - -type RadarHTTPLocationGetParamsTLSVersion string - -const ( - RadarHTTPLocationGetParamsTLSVersionTlSv1_0 RadarHTTPLocationGetParamsTLSVersion = "TLSv1_0" - RadarHTTPLocationGetParamsTLSVersionTlSv1_1 RadarHTTPLocationGetParamsTLSVersion = "TLSv1_1" - RadarHTTPLocationGetParamsTLSVersionTlSv1_2 RadarHTTPLocationGetParamsTLSVersion = "TLSv1_2" - RadarHTTPLocationGetParamsTLSVersionTlSv1_3 RadarHTTPLocationGetParamsTLSVersion = "TLSv1_3" - RadarHTTPLocationGetParamsTLSVersionTlSvQuic RadarHTTPLocationGetParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPLocationGetResponseEnvelope struct { - Result RadarHTTPLocationGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPLocationGetResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPLocationGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarHTTPLocationGetResponseEnvelope] -type radarHTTPLocationGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttplocation_test.go b/radarhttplocation_test.go deleted file mode 100644 index dcca6ba3d78..00000000000 --- a/radarhttplocation_test.go +++ /dev/null @@ -1,56 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPLocationGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Locations.Get(context.TODO(), cloudflare.RadarHTTPLocationGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPLocationGetParamsBotClass{cloudflare.RadarHTTPLocationGetParamsBotClassLikelyAutomated, cloudflare.RadarHTTPLocationGetParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPLocationGetParamsDateRange{cloudflare.RadarHTTPLocationGetParamsDateRange1d, cloudflare.RadarHTTPLocationGetParamsDateRange2d, cloudflare.RadarHTTPLocationGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPLocationGetParamsDeviceType{cloudflare.RadarHTTPLocationGetParamsDeviceTypeDesktop, cloudflare.RadarHTTPLocationGetParamsDeviceTypeMobile, cloudflare.RadarHTTPLocationGetParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPLocationGetParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPLocationGetParamsHTTPProtocol{cloudflare.RadarHTTPLocationGetParamsHTTPProtocolHTTP, cloudflare.RadarHTTPLocationGetParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPLocationGetParamsHTTPVersion{cloudflare.RadarHTTPLocationGetParamsHTTPVersionHttPv1, cloudflare.RadarHTTPLocationGetParamsHTTPVersionHttPv2, cloudflare.RadarHTTPLocationGetParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPLocationGetParamsIPVersion{cloudflare.RadarHTTPLocationGetParamsIPVersionIPv4, cloudflare.RadarHTTPLocationGetParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPLocationGetParamsOS{cloudflare.RadarHTTPLocationGetParamsOSWindows, cloudflare.RadarHTTPLocationGetParamsOSMacosx, cloudflare.RadarHTTPLocationGetParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPLocationGetParamsTLSVersion{cloudflare.RadarHTTPLocationGetParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPLocationGetParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPLocationGetParamsTLSVersionTlSv1_2}), - }) - 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/radarhttplocationbotclass.go b/radarhttplocationbotclass.go deleted file mode 100644 index d7dcb198392..00000000000 --- a/radarhttplocationbotclass.go +++ /dev/null @@ -1,367 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPLocationBotClassService 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 -// [NewRadarHTTPLocationBotClassService] method instead. -type RadarHTTPLocationBotClassService struct { - Options []option.RequestOption -} - -// NewRadarHTTPLocationBotClassService 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 NewRadarHTTPLocationBotClassService(opts ...option.RequestOption) (r *RadarHTTPLocationBotClassService) { - r = &RadarHTTPLocationBotClassService{} - r.Options = opts - return -} - -// Get the top locations, by HTTP traffic, of the requested bot class. These two -// categories use Cloudflare's bot score - refer to [Bot -// scores])https://developers.cloudflare.com/bots/concepts/bot-score). Values are a -// percentage out of the total traffic. -func (r *RadarHTTPLocationBotClassService) Get(ctx context.Context, botClass RadarHTTPLocationBotClassGetParamsBotClass, query RadarHTTPLocationBotClassGetParams, opts ...option.RequestOption) (res *RadarHTTPLocationBotClassGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPLocationBotClassGetResponseEnvelope - path := fmt.Sprintf("radar/http/top/locations/bot_class/%v", botClass) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPLocationBotClassGetResponse struct { - Meta RadarHTTPLocationBotClassGetResponseMeta `json:"meta,required"` - Top0 []RadarHTTPLocationBotClassGetResponseTop0 `json:"top_0,required"` - JSON radarHTTPLocationBotClassGetResponseJSON `json:"-"` -} - -// radarHTTPLocationBotClassGetResponseJSON contains the JSON metadata for the -// struct [RadarHTTPLocationBotClassGetResponse] -type radarHTTPLocationBotClassGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationBotClassGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationBotClassGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationBotClassGetResponseMeta struct { - DateRange []RadarHTTPLocationBotClassGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarHTTPLocationBotClassGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPLocationBotClassGetResponseMetaJSON `json:"-"` -} - -// radarHTTPLocationBotClassGetResponseMetaJSON contains the JSON metadata for the -// struct [RadarHTTPLocationBotClassGetResponseMeta] -type radarHTTPLocationBotClassGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationBotClassGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationBotClassGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationBotClassGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPLocationBotClassGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPLocationBotClassGetResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarHTTPLocationBotClassGetResponseMetaDateRange] -type radarHTTPLocationBotClassGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationBotClassGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationBotClassGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationBotClassGetResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPLocationBotClassGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPLocationBotClassGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPLocationBotClassGetResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarHTTPLocationBotClassGetResponseMetaConfidenceInfo] -type radarHTTPLocationBotClassGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationBotClassGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationBotClassGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationBotClassGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPLocationBotClassGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPLocationBotClassGetResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarHTTPLocationBotClassGetResponseMetaConfidenceInfoAnnotation] -type radarHTTPLocationBotClassGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationBotClassGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationBotClassGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationBotClassGetResponseTop0 struct { - ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` - ClientCountryName string `json:"clientCountryName,required"` - Value string `json:"value,required"` - JSON radarHTTPLocationBotClassGetResponseTop0JSON `json:"-"` -} - -// radarHTTPLocationBotClassGetResponseTop0JSON contains the JSON metadata for the -// struct [RadarHTTPLocationBotClassGetResponseTop0] -type radarHTTPLocationBotClassGetResponseTop0JSON struct { - ClientCountryAlpha2 apijson.Field - ClientCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationBotClassGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationBotClassGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationBotClassGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPLocationBotClassGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPLocationBotClassGetParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPLocationBotClassGetParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPLocationBotClassGetParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPLocationBotClassGetParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPLocationBotClassGetParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPLocationBotClassGetParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPLocationBotClassGetParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPLocationBotClassGetParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPLocationBotClassGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Bot class. -type RadarHTTPLocationBotClassGetParamsBotClass string - -const ( - RadarHTTPLocationBotClassGetParamsBotClassLikelyAutomated RadarHTTPLocationBotClassGetParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPLocationBotClassGetParamsBotClassLikelyHuman RadarHTTPLocationBotClassGetParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPLocationBotClassGetParamsDateRange string - -const ( - RadarHTTPLocationBotClassGetParamsDateRange1d RadarHTTPLocationBotClassGetParamsDateRange = "1d" - RadarHTTPLocationBotClassGetParamsDateRange2d RadarHTTPLocationBotClassGetParamsDateRange = "2d" - RadarHTTPLocationBotClassGetParamsDateRange7d RadarHTTPLocationBotClassGetParamsDateRange = "7d" - RadarHTTPLocationBotClassGetParamsDateRange14d RadarHTTPLocationBotClassGetParamsDateRange = "14d" - RadarHTTPLocationBotClassGetParamsDateRange28d RadarHTTPLocationBotClassGetParamsDateRange = "28d" - RadarHTTPLocationBotClassGetParamsDateRange12w RadarHTTPLocationBotClassGetParamsDateRange = "12w" - RadarHTTPLocationBotClassGetParamsDateRange24w RadarHTTPLocationBotClassGetParamsDateRange = "24w" - RadarHTTPLocationBotClassGetParamsDateRange52w RadarHTTPLocationBotClassGetParamsDateRange = "52w" - RadarHTTPLocationBotClassGetParamsDateRange1dControl RadarHTTPLocationBotClassGetParamsDateRange = "1dControl" - RadarHTTPLocationBotClassGetParamsDateRange2dControl RadarHTTPLocationBotClassGetParamsDateRange = "2dControl" - RadarHTTPLocationBotClassGetParamsDateRange7dControl RadarHTTPLocationBotClassGetParamsDateRange = "7dControl" - RadarHTTPLocationBotClassGetParamsDateRange14dControl RadarHTTPLocationBotClassGetParamsDateRange = "14dControl" - RadarHTTPLocationBotClassGetParamsDateRange28dControl RadarHTTPLocationBotClassGetParamsDateRange = "28dControl" - RadarHTTPLocationBotClassGetParamsDateRange12wControl RadarHTTPLocationBotClassGetParamsDateRange = "12wControl" - RadarHTTPLocationBotClassGetParamsDateRange24wControl RadarHTTPLocationBotClassGetParamsDateRange = "24wControl" -) - -type RadarHTTPLocationBotClassGetParamsDeviceType string - -const ( - RadarHTTPLocationBotClassGetParamsDeviceTypeDesktop RadarHTTPLocationBotClassGetParamsDeviceType = "DESKTOP" - RadarHTTPLocationBotClassGetParamsDeviceTypeMobile RadarHTTPLocationBotClassGetParamsDeviceType = "MOBILE" - RadarHTTPLocationBotClassGetParamsDeviceTypeOther RadarHTTPLocationBotClassGetParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPLocationBotClassGetParamsFormat string - -const ( - RadarHTTPLocationBotClassGetParamsFormatJson RadarHTTPLocationBotClassGetParamsFormat = "JSON" - RadarHTTPLocationBotClassGetParamsFormatCsv RadarHTTPLocationBotClassGetParamsFormat = "CSV" -) - -type RadarHTTPLocationBotClassGetParamsHTTPProtocol string - -const ( - RadarHTTPLocationBotClassGetParamsHTTPProtocolHTTP RadarHTTPLocationBotClassGetParamsHTTPProtocol = "HTTP" - RadarHTTPLocationBotClassGetParamsHTTPProtocolHTTPS RadarHTTPLocationBotClassGetParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPLocationBotClassGetParamsHTTPVersion string - -const ( - RadarHTTPLocationBotClassGetParamsHTTPVersionHttPv1 RadarHTTPLocationBotClassGetParamsHTTPVersion = "HTTPv1" - RadarHTTPLocationBotClassGetParamsHTTPVersionHttPv2 RadarHTTPLocationBotClassGetParamsHTTPVersion = "HTTPv2" - RadarHTTPLocationBotClassGetParamsHTTPVersionHttPv3 RadarHTTPLocationBotClassGetParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPLocationBotClassGetParamsIPVersion string - -const ( - RadarHTTPLocationBotClassGetParamsIPVersionIPv4 RadarHTTPLocationBotClassGetParamsIPVersion = "IPv4" - RadarHTTPLocationBotClassGetParamsIPVersionIPv6 RadarHTTPLocationBotClassGetParamsIPVersion = "IPv6" -) - -type RadarHTTPLocationBotClassGetParamsOS string - -const ( - RadarHTTPLocationBotClassGetParamsOSWindows RadarHTTPLocationBotClassGetParamsOS = "WINDOWS" - RadarHTTPLocationBotClassGetParamsOSMacosx RadarHTTPLocationBotClassGetParamsOS = "MACOSX" - RadarHTTPLocationBotClassGetParamsOSIos RadarHTTPLocationBotClassGetParamsOS = "IOS" - RadarHTTPLocationBotClassGetParamsOSAndroid RadarHTTPLocationBotClassGetParamsOS = "ANDROID" - RadarHTTPLocationBotClassGetParamsOSChromeos RadarHTTPLocationBotClassGetParamsOS = "CHROMEOS" - RadarHTTPLocationBotClassGetParamsOSLinux RadarHTTPLocationBotClassGetParamsOS = "LINUX" - RadarHTTPLocationBotClassGetParamsOSSmartTv RadarHTTPLocationBotClassGetParamsOS = "SMART_TV" -) - -type RadarHTTPLocationBotClassGetParamsTLSVersion string - -const ( - RadarHTTPLocationBotClassGetParamsTLSVersionTlSv1_0 RadarHTTPLocationBotClassGetParamsTLSVersion = "TLSv1_0" - RadarHTTPLocationBotClassGetParamsTLSVersionTlSv1_1 RadarHTTPLocationBotClassGetParamsTLSVersion = "TLSv1_1" - RadarHTTPLocationBotClassGetParamsTLSVersionTlSv1_2 RadarHTTPLocationBotClassGetParamsTLSVersion = "TLSv1_2" - RadarHTTPLocationBotClassGetParamsTLSVersionTlSv1_3 RadarHTTPLocationBotClassGetParamsTLSVersion = "TLSv1_3" - RadarHTTPLocationBotClassGetParamsTLSVersionTlSvQuic RadarHTTPLocationBotClassGetParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPLocationBotClassGetResponseEnvelope struct { - Result RadarHTTPLocationBotClassGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPLocationBotClassGetResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPLocationBotClassGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarHTTPLocationBotClassGetResponseEnvelope] -type radarHTTPLocationBotClassGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationBotClassGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationBotClassGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttplocationbotclass_test.go b/radarhttplocationbotclass_test.go deleted file mode 100644 index 30e84504a54..00000000000 --- a/radarhttplocationbotclass_test.go +++ /dev/null @@ -1,59 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPLocationBotClassGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Locations.BotClass.Get( - context.TODO(), - cloudflare.RadarHTTPLocationBotClassGetParamsBotClassLikelyAutomated, - cloudflare.RadarHTTPLocationBotClassGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPLocationBotClassGetParamsDateRange{cloudflare.RadarHTTPLocationBotClassGetParamsDateRange1d, cloudflare.RadarHTTPLocationBotClassGetParamsDateRange2d, cloudflare.RadarHTTPLocationBotClassGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPLocationBotClassGetParamsDeviceType{cloudflare.RadarHTTPLocationBotClassGetParamsDeviceTypeDesktop, cloudflare.RadarHTTPLocationBotClassGetParamsDeviceTypeMobile, cloudflare.RadarHTTPLocationBotClassGetParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPLocationBotClassGetParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPLocationBotClassGetParamsHTTPProtocol{cloudflare.RadarHTTPLocationBotClassGetParamsHTTPProtocolHTTP, cloudflare.RadarHTTPLocationBotClassGetParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPLocationBotClassGetParamsHTTPVersion{cloudflare.RadarHTTPLocationBotClassGetParamsHTTPVersionHttPv1, cloudflare.RadarHTTPLocationBotClassGetParamsHTTPVersionHttPv2, cloudflare.RadarHTTPLocationBotClassGetParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPLocationBotClassGetParamsIPVersion{cloudflare.RadarHTTPLocationBotClassGetParamsIPVersionIPv4, cloudflare.RadarHTTPLocationBotClassGetParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPLocationBotClassGetParamsOS{cloudflare.RadarHTTPLocationBotClassGetParamsOSWindows, cloudflare.RadarHTTPLocationBotClassGetParamsOSMacosx, cloudflare.RadarHTTPLocationBotClassGetParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPLocationBotClassGetParamsTLSVersion{cloudflare.RadarHTTPLocationBotClassGetParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPLocationBotClassGetParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPLocationBotClassGetParamsTLSVersionTlSv1_2}), - }, - ) - 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/radarhttplocationdevicetype.go b/radarhttplocationdevicetype.go deleted file mode 100644 index edf264a9084..00000000000 --- a/radarhttplocationdevicetype.go +++ /dev/null @@ -1,367 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPLocationDeviceTypeService 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 -// [NewRadarHTTPLocationDeviceTypeService] method instead. -type RadarHTTPLocationDeviceTypeService struct { - Options []option.RequestOption -} - -// NewRadarHTTPLocationDeviceTypeService 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 NewRadarHTTPLocationDeviceTypeService(opts ...option.RequestOption) (r *RadarHTTPLocationDeviceTypeService) { - r = &RadarHTTPLocationDeviceTypeService{} - r.Options = opts - return -} - -// Get the top locations, by HTTP traffic, of the requested device type. Values are -// a percentage out of the total traffic. -func (r *RadarHTTPLocationDeviceTypeService) Get(ctx context.Context, deviceType RadarHTTPLocationDeviceTypeGetParamsDeviceType, query RadarHTTPLocationDeviceTypeGetParams, opts ...option.RequestOption) (res *RadarHTTPLocationDeviceTypeGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPLocationDeviceTypeGetResponseEnvelope - path := fmt.Sprintf("radar/http/top/locations/device_type/%v", deviceType) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPLocationDeviceTypeGetResponse struct { - Meta RadarHTTPLocationDeviceTypeGetResponseMeta `json:"meta,required"` - Top0 []RadarHTTPLocationDeviceTypeGetResponseTop0 `json:"top_0,required"` - JSON radarHTTPLocationDeviceTypeGetResponseJSON `json:"-"` -} - -// radarHTTPLocationDeviceTypeGetResponseJSON contains the JSON metadata for the -// struct [RadarHTTPLocationDeviceTypeGetResponse] -type radarHTTPLocationDeviceTypeGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationDeviceTypeGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationDeviceTypeGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationDeviceTypeGetResponseMeta struct { - DateRange []RadarHTTPLocationDeviceTypeGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarHTTPLocationDeviceTypeGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPLocationDeviceTypeGetResponseMetaJSON `json:"-"` -} - -// radarHTTPLocationDeviceTypeGetResponseMetaJSON contains the JSON metadata for -// the struct [RadarHTTPLocationDeviceTypeGetResponseMeta] -type radarHTTPLocationDeviceTypeGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationDeviceTypeGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationDeviceTypeGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationDeviceTypeGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPLocationDeviceTypeGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPLocationDeviceTypeGetResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarHTTPLocationDeviceTypeGetResponseMetaDateRange] -type radarHTTPLocationDeviceTypeGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationDeviceTypeGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationDeviceTypeGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationDeviceTypeGetResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPLocationDeviceTypeGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPLocationDeviceTypeGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPLocationDeviceTypeGetResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarHTTPLocationDeviceTypeGetResponseMetaConfidenceInfo] -type radarHTTPLocationDeviceTypeGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationDeviceTypeGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationDeviceTypeGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationDeviceTypeGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPLocationDeviceTypeGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPLocationDeviceTypeGetResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarHTTPLocationDeviceTypeGetResponseMetaConfidenceInfoAnnotation] -type radarHTTPLocationDeviceTypeGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationDeviceTypeGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationDeviceTypeGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationDeviceTypeGetResponseTop0 struct { - ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` - ClientCountryName string `json:"clientCountryName,required"` - Value string `json:"value,required"` - JSON radarHTTPLocationDeviceTypeGetResponseTop0JSON `json:"-"` -} - -// radarHTTPLocationDeviceTypeGetResponseTop0JSON contains the JSON metadata for -// the struct [RadarHTTPLocationDeviceTypeGetResponseTop0] -type radarHTTPLocationDeviceTypeGetResponseTop0JSON struct { - ClientCountryAlpha2 apijson.Field - ClientCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationDeviceTypeGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationDeviceTypeGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationDeviceTypeGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPLocationDeviceTypeGetParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPLocationDeviceTypeGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarHTTPLocationDeviceTypeGetParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPLocationDeviceTypeGetParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPLocationDeviceTypeGetParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPLocationDeviceTypeGetParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPLocationDeviceTypeGetParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPLocationDeviceTypeGetParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPLocationDeviceTypeGetParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPLocationDeviceTypeGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Device type. -type RadarHTTPLocationDeviceTypeGetParamsDeviceType string - -const ( - RadarHTTPLocationDeviceTypeGetParamsDeviceTypeDesktop RadarHTTPLocationDeviceTypeGetParamsDeviceType = "DESKTOP" - RadarHTTPLocationDeviceTypeGetParamsDeviceTypeMobile RadarHTTPLocationDeviceTypeGetParamsDeviceType = "MOBILE" - RadarHTTPLocationDeviceTypeGetParamsDeviceTypeOther RadarHTTPLocationDeviceTypeGetParamsDeviceType = "OTHER" -) - -type RadarHTTPLocationDeviceTypeGetParamsBotClass string - -const ( - RadarHTTPLocationDeviceTypeGetParamsBotClassLikelyAutomated RadarHTTPLocationDeviceTypeGetParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPLocationDeviceTypeGetParamsBotClassLikelyHuman RadarHTTPLocationDeviceTypeGetParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPLocationDeviceTypeGetParamsDateRange string - -const ( - RadarHTTPLocationDeviceTypeGetParamsDateRange1d RadarHTTPLocationDeviceTypeGetParamsDateRange = "1d" - RadarHTTPLocationDeviceTypeGetParamsDateRange2d RadarHTTPLocationDeviceTypeGetParamsDateRange = "2d" - RadarHTTPLocationDeviceTypeGetParamsDateRange7d RadarHTTPLocationDeviceTypeGetParamsDateRange = "7d" - RadarHTTPLocationDeviceTypeGetParamsDateRange14d RadarHTTPLocationDeviceTypeGetParamsDateRange = "14d" - RadarHTTPLocationDeviceTypeGetParamsDateRange28d RadarHTTPLocationDeviceTypeGetParamsDateRange = "28d" - RadarHTTPLocationDeviceTypeGetParamsDateRange12w RadarHTTPLocationDeviceTypeGetParamsDateRange = "12w" - RadarHTTPLocationDeviceTypeGetParamsDateRange24w RadarHTTPLocationDeviceTypeGetParamsDateRange = "24w" - RadarHTTPLocationDeviceTypeGetParamsDateRange52w RadarHTTPLocationDeviceTypeGetParamsDateRange = "52w" - RadarHTTPLocationDeviceTypeGetParamsDateRange1dControl RadarHTTPLocationDeviceTypeGetParamsDateRange = "1dControl" - RadarHTTPLocationDeviceTypeGetParamsDateRange2dControl RadarHTTPLocationDeviceTypeGetParamsDateRange = "2dControl" - RadarHTTPLocationDeviceTypeGetParamsDateRange7dControl RadarHTTPLocationDeviceTypeGetParamsDateRange = "7dControl" - RadarHTTPLocationDeviceTypeGetParamsDateRange14dControl RadarHTTPLocationDeviceTypeGetParamsDateRange = "14dControl" - RadarHTTPLocationDeviceTypeGetParamsDateRange28dControl RadarHTTPLocationDeviceTypeGetParamsDateRange = "28dControl" - RadarHTTPLocationDeviceTypeGetParamsDateRange12wControl RadarHTTPLocationDeviceTypeGetParamsDateRange = "12wControl" - RadarHTTPLocationDeviceTypeGetParamsDateRange24wControl RadarHTTPLocationDeviceTypeGetParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarHTTPLocationDeviceTypeGetParamsFormat string - -const ( - RadarHTTPLocationDeviceTypeGetParamsFormatJson RadarHTTPLocationDeviceTypeGetParamsFormat = "JSON" - RadarHTTPLocationDeviceTypeGetParamsFormatCsv RadarHTTPLocationDeviceTypeGetParamsFormat = "CSV" -) - -type RadarHTTPLocationDeviceTypeGetParamsHTTPProtocol string - -const ( - RadarHTTPLocationDeviceTypeGetParamsHTTPProtocolHTTP RadarHTTPLocationDeviceTypeGetParamsHTTPProtocol = "HTTP" - RadarHTTPLocationDeviceTypeGetParamsHTTPProtocolHTTPS RadarHTTPLocationDeviceTypeGetParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPLocationDeviceTypeGetParamsHTTPVersion string - -const ( - RadarHTTPLocationDeviceTypeGetParamsHTTPVersionHttPv1 RadarHTTPLocationDeviceTypeGetParamsHTTPVersion = "HTTPv1" - RadarHTTPLocationDeviceTypeGetParamsHTTPVersionHttPv2 RadarHTTPLocationDeviceTypeGetParamsHTTPVersion = "HTTPv2" - RadarHTTPLocationDeviceTypeGetParamsHTTPVersionHttPv3 RadarHTTPLocationDeviceTypeGetParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPLocationDeviceTypeGetParamsIPVersion string - -const ( - RadarHTTPLocationDeviceTypeGetParamsIPVersionIPv4 RadarHTTPLocationDeviceTypeGetParamsIPVersion = "IPv4" - RadarHTTPLocationDeviceTypeGetParamsIPVersionIPv6 RadarHTTPLocationDeviceTypeGetParamsIPVersion = "IPv6" -) - -type RadarHTTPLocationDeviceTypeGetParamsOS string - -const ( - RadarHTTPLocationDeviceTypeGetParamsOSWindows RadarHTTPLocationDeviceTypeGetParamsOS = "WINDOWS" - RadarHTTPLocationDeviceTypeGetParamsOSMacosx RadarHTTPLocationDeviceTypeGetParamsOS = "MACOSX" - RadarHTTPLocationDeviceTypeGetParamsOSIos RadarHTTPLocationDeviceTypeGetParamsOS = "IOS" - RadarHTTPLocationDeviceTypeGetParamsOSAndroid RadarHTTPLocationDeviceTypeGetParamsOS = "ANDROID" - RadarHTTPLocationDeviceTypeGetParamsOSChromeos RadarHTTPLocationDeviceTypeGetParamsOS = "CHROMEOS" - RadarHTTPLocationDeviceTypeGetParamsOSLinux RadarHTTPLocationDeviceTypeGetParamsOS = "LINUX" - RadarHTTPLocationDeviceTypeGetParamsOSSmartTv RadarHTTPLocationDeviceTypeGetParamsOS = "SMART_TV" -) - -type RadarHTTPLocationDeviceTypeGetParamsTLSVersion string - -const ( - RadarHTTPLocationDeviceTypeGetParamsTLSVersionTlSv1_0 RadarHTTPLocationDeviceTypeGetParamsTLSVersion = "TLSv1_0" - RadarHTTPLocationDeviceTypeGetParamsTLSVersionTlSv1_1 RadarHTTPLocationDeviceTypeGetParamsTLSVersion = "TLSv1_1" - RadarHTTPLocationDeviceTypeGetParamsTLSVersionTlSv1_2 RadarHTTPLocationDeviceTypeGetParamsTLSVersion = "TLSv1_2" - RadarHTTPLocationDeviceTypeGetParamsTLSVersionTlSv1_3 RadarHTTPLocationDeviceTypeGetParamsTLSVersion = "TLSv1_3" - RadarHTTPLocationDeviceTypeGetParamsTLSVersionTlSvQuic RadarHTTPLocationDeviceTypeGetParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPLocationDeviceTypeGetResponseEnvelope struct { - Result RadarHTTPLocationDeviceTypeGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPLocationDeviceTypeGetResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPLocationDeviceTypeGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarHTTPLocationDeviceTypeGetResponseEnvelope] -type radarHTTPLocationDeviceTypeGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationDeviceTypeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationDeviceTypeGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttplocationdevicetype_test.go b/radarhttplocationdevicetype_test.go deleted file mode 100644 index b67fa5a85ed..00000000000 --- a/radarhttplocationdevicetype_test.go +++ /dev/null @@ -1,59 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPLocationDeviceTypeGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Locations.DeviceType.Get( - context.TODO(), - cloudflare.RadarHTTPLocationDeviceTypeGetParamsDeviceTypeDesktop, - cloudflare.RadarHTTPLocationDeviceTypeGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPLocationDeviceTypeGetParamsBotClass{cloudflare.RadarHTTPLocationDeviceTypeGetParamsBotClassLikelyAutomated, cloudflare.RadarHTTPLocationDeviceTypeGetParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPLocationDeviceTypeGetParamsDateRange{cloudflare.RadarHTTPLocationDeviceTypeGetParamsDateRange1d, cloudflare.RadarHTTPLocationDeviceTypeGetParamsDateRange2d, cloudflare.RadarHTTPLocationDeviceTypeGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarHTTPLocationDeviceTypeGetParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPLocationDeviceTypeGetParamsHTTPProtocol{cloudflare.RadarHTTPLocationDeviceTypeGetParamsHTTPProtocolHTTP, cloudflare.RadarHTTPLocationDeviceTypeGetParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPLocationDeviceTypeGetParamsHTTPVersion{cloudflare.RadarHTTPLocationDeviceTypeGetParamsHTTPVersionHttPv1, cloudflare.RadarHTTPLocationDeviceTypeGetParamsHTTPVersionHttPv2, cloudflare.RadarHTTPLocationDeviceTypeGetParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPLocationDeviceTypeGetParamsIPVersion{cloudflare.RadarHTTPLocationDeviceTypeGetParamsIPVersionIPv4, cloudflare.RadarHTTPLocationDeviceTypeGetParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPLocationDeviceTypeGetParamsOS{cloudflare.RadarHTTPLocationDeviceTypeGetParamsOSWindows, cloudflare.RadarHTTPLocationDeviceTypeGetParamsOSMacosx, cloudflare.RadarHTTPLocationDeviceTypeGetParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPLocationDeviceTypeGetParamsTLSVersion{cloudflare.RadarHTTPLocationDeviceTypeGetParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPLocationDeviceTypeGetParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPLocationDeviceTypeGetParamsTLSVersionTlSv1_2}), - }, - ) - 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/radarhttplocationhttpmethod.go b/radarhttplocationhttpmethod.go deleted file mode 100644 index e8c5aef1836..00000000000 --- a/radarhttplocationhttpmethod.go +++ /dev/null @@ -1,367 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPLocationHTTPMethodService 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 -// [NewRadarHTTPLocationHTTPMethodService] method instead. -type RadarHTTPLocationHTTPMethodService struct { - Options []option.RequestOption -} - -// NewRadarHTTPLocationHTTPMethodService 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 NewRadarHTTPLocationHTTPMethodService(opts ...option.RequestOption) (r *RadarHTTPLocationHTTPMethodService) { - r = &RadarHTTPLocationHTTPMethodService{} - r.Options = opts - return -} - -// Get the top locations, by HTTP traffic, of the requested HTTP protocol. Values -// are a percentage out of the total traffic. -func (r *RadarHTTPLocationHTTPMethodService) Get(ctx context.Context, httpVersion RadarHTTPLocationHTTPMethodGetParamsHTTPVersion, query RadarHTTPLocationHTTPMethodGetParams, opts ...option.RequestOption) (res *RadarHTTPLocationHTTPMethodGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPLocationHTTPMethodGetResponseEnvelope - path := fmt.Sprintf("radar/http/top/locations/http_version/%v", httpVersion) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPLocationHTTPMethodGetResponse struct { - Meta RadarHTTPLocationHTTPMethodGetResponseMeta `json:"meta,required"` - Top0 []RadarHTTPLocationHTTPMethodGetResponseTop0 `json:"top_0,required"` - JSON radarHTTPLocationHTTPMethodGetResponseJSON `json:"-"` -} - -// radarHTTPLocationHTTPMethodGetResponseJSON contains the JSON metadata for the -// struct [RadarHTTPLocationHTTPMethodGetResponse] -type radarHTTPLocationHTTPMethodGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationHTTPMethodGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationHTTPMethodGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationHTTPMethodGetResponseMeta struct { - DateRange []RadarHTTPLocationHTTPMethodGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarHTTPLocationHTTPMethodGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPLocationHTTPMethodGetResponseMetaJSON `json:"-"` -} - -// radarHTTPLocationHTTPMethodGetResponseMetaJSON contains the JSON metadata for -// the struct [RadarHTTPLocationHTTPMethodGetResponseMeta] -type radarHTTPLocationHTTPMethodGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationHTTPMethodGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationHTTPMethodGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationHTTPMethodGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPLocationHTTPMethodGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPLocationHTTPMethodGetResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarHTTPLocationHTTPMethodGetResponseMetaDateRange] -type radarHTTPLocationHTTPMethodGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationHTTPMethodGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationHTTPMethodGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationHTTPMethodGetResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPLocationHTTPMethodGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPLocationHTTPMethodGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPLocationHTTPMethodGetResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarHTTPLocationHTTPMethodGetResponseMetaConfidenceInfo] -type radarHTTPLocationHTTPMethodGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationHTTPMethodGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationHTTPMethodGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationHTTPMethodGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPLocationHTTPMethodGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPLocationHTTPMethodGetResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarHTTPLocationHTTPMethodGetResponseMetaConfidenceInfoAnnotation] -type radarHTTPLocationHTTPMethodGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationHTTPMethodGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationHTTPMethodGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationHTTPMethodGetResponseTop0 struct { - ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` - ClientCountryName string `json:"clientCountryName,required"` - Value string `json:"value,required"` - JSON radarHTTPLocationHTTPMethodGetResponseTop0JSON `json:"-"` -} - -// radarHTTPLocationHTTPMethodGetResponseTop0JSON contains the JSON metadata for -// the struct [RadarHTTPLocationHTTPMethodGetResponseTop0] -type radarHTTPLocationHTTPMethodGetResponseTop0JSON struct { - ClientCountryAlpha2 apijson.Field - ClientCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationHTTPMethodGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationHTTPMethodGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationHTTPMethodGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPLocationHTTPMethodGetParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPLocationHTTPMethodGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPLocationHTTPMethodGetParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPLocationHTTPMethodGetParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPLocationHTTPMethodGetParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPLocationHTTPMethodGetParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPLocationHTTPMethodGetParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPLocationHTTPMethodGetParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPLocationHTTPMethodGetParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPLocationHTTPMethodGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// HTTP version. -type RadarHTTPLocationHTTPMethodGetParamsHTTPVersion string - -const ( - RadarHTTPLocationHTTPMethodGetParamsHTTPVersionHttPv1 RadarHTTPLocationHTTPMethodGetParamsHTTPVersion = "HTTPv1" - RadarHTTPLocationHTTPMethodGetParamsHTTPVersionHttPv2 RadarHTTPLocationHTTPMethodGetParamsHTTPVersion = "HTTPv2" - RadarHTTPLocationHTTPMethodGetParamsHTTPVersionHttPv3 RadarHTTPLocationHTTPMethodGetParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPLocationHTTPMethodGetParamsBotClass string - -const ( - RadarHTTPLocationHTTPMethodGetParamsBotClassLikelyAutomated RadarHTTPLocationHTTPMethodGetParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPLocationHTTPMethodGetParamsBotClassLikelyHuman RadarHTTPLocationHTTPMethodGetParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPLocationHTTPMethodGetParamsDateRange string - -const ( - RadarHTTPLocationHTTPMethodGetParamsDateRange1d RadarHTTPLocationHTTPMethodGetParamsDateRange = "1d" - RadarHTTPLocationHTTPMethodGetParamsDateRange2d RadarHTTPLocationHTTPMethodGetParamsDateRange = "2d" - RadarHTTPLocationHTTPMethodGetParamsDateRange7d RadarHTTPLocationHTTPMethodGetParamsDateRange = "7d" - RadarHTTPLocationHTTPMethodGetParamsDateRange14d RadarHTTPLocationHTTPMethodGetParamsDateRange = "14d" - RadarHTTPLocationHTTPMethodGetParamsDateRange28d RadarHTTPLocationHTTPMethodGetParamsDateRange = "28d" - RadarHTTPLocationHTTPMethodGetParamsDateRange12w RadarHTTPLocationHTTPMethodGetParamsDateRange = "12w" - RadarHTTPLocationHTTPMethodGetParamsDateRange24w RadarHTTPLocationHTTPMethodGetParamsDateRange = "24w" - RadarHTTPLocationHTTPMethodGetParamsDateRange52w RadarHTTPLocationHTTPMethodGetParamsDateRange = "52w" - RadarHTTPLocationHTTPMethodGetParamsDateRange1dControl RadarHTTPLocationHTTPMethodGetParamsDateRange = "1dControl" - RadarHTTPLocationHTTPMethodGetParamsDateRange2dControl RadarHTTPLocationHTTPMethodGetParamsDateRange = "2dControl" - RadarHTTPLocationHTTPMethodGetParamsDateRange7dControl RadarHTTPLocationHTTPMethodGetParamsDateRange = "7dControl" - RadarHTTPLocationHTTPMethodGetParamsDateRange14dControl RadarHTTPLocationHTTPMethodGetParamsDateRange = "14dControl" - RadarHTTPLocationHTTPMethodGetParamsDateRange28dControl RadarHTTPLocationHTTPMethodGetParamsDateRange = "28dControl" - RadarHTTPLocationHTTPMethodGetParamsDateRange12wControl RadarHTTPLocationHTTPMethodGetParamsDateRange = "12wControl" - RadarHTTPLocationHTTPMethodGetParamsDateRange24wControl RadarHTTPLocationHTTPMethodGetParamsDateRange = "24wControl" -) - -type RadarHTTPLocationHTTPMethodGetParamsDeviceType string - -const ( - RadarHTTPLocationHTTPMethodGetParamsDeviceTypeDesktop RadarHTTPLocationHTTPMethodGetParamsDeviceType = "DESKTOP" - RadarHTTPLocationHTTPMethodGetParamsDeviceTypeMobile RadarHTTPLocationHTTPMethodGetParamsDeviceType = "MOBILE" - RadarHTTPLocationHTTPMethodGetParamsDeviceTypeOther RadarHTTPLocationHTTPMethodGetParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPLocationHTTPMethodGetParamsFormat string - -const ( - RadarHTTPLocationHTTPMethodGetParamsFormatJson RadarHTTPLocationHTTPMethodGetParamsFormat = "JSON" - RadarHTTPLocationHTTPMethodGetParamsFormatCsv RadarHTTPLocationHTTPMethodGetParamsFormat = "CSV" -) - -type RadarHTTPLocationHTTPMethodGetParamsHTTPProtocol string - -const ( - RadarHTTPLocationHTTPMethodGetParamsHTTPProtocolHTTP RadarHTTPLocationHTTPMethodGetParamsHTTPProtocol = "HTTP" - RadarHTTPLocationHTTPMethodGetParamsHTTPProtocolHTTPS RadarHTTPLocationHTTPMethodGetParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPLocationHTTPMethodGetParamsIPVersion string - -const ( - RadarHTTPLocationHTTPMethodGetParamsIPVersionIPv4 RadarHTTPLocationHTTPMethodGetParamsIPVersion = "IPv4" - RadarHTTPLocationHTTPMethodGetParamsIPVersionIPv6 RadarHTTPLocationHTTPMethodGetParamsIPVersion = "IPv6" -) - -type RadarHTTPLocationHTTPMethodGetParamsOS string - -const ( - RadarHTTPLocationHTTPMethodGetParamsOSWindows RadarHTTPLocationHTTPMethodGetParamsOS = "WINDOWS" - RadarHTTPLocationHTTPMethodGetParamsOSMacosx RadarHTTPLocationHTTPMethodGetParamsOS = "MACOSX" - RadarHTTPLocationHTTPMethodGetParamsOSIos RadarHTTPLocationHTTPMethodGetParamsOS = "IOS" - RadarHTTPLocationHTTPMethodGetParamsOSAndroid RadarHTTPLocationHTTPMethodGetParamsOS = "ANDROID" - RadarHTTPLocationHTTPMethodGetParamsOSChromeos RadarHTTPLocationHTTPMethodGetParamsOS = "CHROMEOS" - RadarHTTPLocationHTTPMethodGetParamsOSLinux RadarHTTPLocationHTTPMethodGetParamsOS = "LINUX" - RadarHTTPLocationHTTPMethodGetParamsOSSmartTv RadarHTTPLocationHTTPMethodGetParamsOS = "SMART_TV" -) - -type RadarHTTPLocationHTTPMethodGetParamsTLSVersion string - -const ( - RadarHTTPLocationHTTPMethodGetParamsTLSVersionTlSv1_0 RadarHTTPLocationHTTPMethodGetParamsTLSVersion = "TLSv1_0" - RadarHTTPLocationHTTPMethodGetParamsTLSVersionTlSv1_1 RadarHTTPLocationHTTPMethodGetParamsTLSVersion = "TLSv1_1" - RadarHTTPLocationHTTPMethodGetParamsTLSVersionTlSv1_2 RadarHTTPLocationHTTPMethodGetParamsTLSVersion = "TLSv1_2" - RadarHTTPLocationHTTPMethodGetParamsTLSVersionTlSv1_3 RadarHTTPLocationHTTPMethodGetParamsTLSVersion = "TLSv1_3" - RadarHTTPLocationHTTPMethodGetParamsTLSVersionTlSvQuic RadarHTTPLocationHTTPMethodGetParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPLocationHTTPMethodGetResponseEnvelope struct { - Result RadarHTTPLocationHTTPMethodGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPLocationHTTPMethodGetResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPLocationHTTPMethodGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarHTTPLocationHTTPMethodGetResponseEnvelope] -type radarHTTPLocationHTTPMethodGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationHTTPMethodGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationHTTPMethodGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttplocationhttpmethod_test.go b/radarhttplocationhttpmethod_test.go deleted file mode 100644 index 6e9c7d078c9..00000000000 --- a/radarhttplocationhttpmethod_test.go +++ /dev/null @@ -1,59 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPLocationHTTPMethodGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Locations.HTTPMethod.Get( - context.TODO(), - cloudflare.RadarHTTPLocationHTTPMethodGetParamsHTTPVersionHttPv1, - cloudflare.RadarHTTPLocationHTTPMethodGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPLocationHTTPMethodGetParamsBotClass{cloudflare.RadarHTTPLocationHTTPMethodGetParamsBotClassLikelyAutomated, cloudflare.RadarHTTPLocationHTTPMethodGetParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPLocationHTTPMethodGetParamsDateRange{cloudflare.RadarHTTPLocationHTTPMethodGetParamsDateRange1d, cloudflare.RadarHTTPLocationHTTPMethodGetParamsDateRange2d, cloudflare.RadarHTTPLocationHTTPMethodGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPLocationHTTPMethodGetParamsDeviceType{cloudflare.RadarHTTPLocationHTTPMethodGetParamsDeviceTypeDesktop, cloudflare.RadarHTTPLocationHTTPMethodGetParamsDeviceTypeMobile, cloudflare.RadarHTTPLocationHTTPMethodGetParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPLocationHTTPMethodGetParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPLocationHTTPMethodGetParamsHTTPProtocol{cloudflare.RadarHTTPLocationHTTPMethodGetParamsHTTPProtocolHTTP, cloudflare.RadarHTTPLocationHTTPMethodGetParamsHTTPProtocolHTTPS}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPLocationHTTPMethodGetParamsIPVersion{cloudflare.RadarHTTPLocationHTTPMethodGetParamsIPVersionIPv4, cloudflare.RadarHTTPLocationHTTPMethodGetParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPLocationHTTPMethodGetParamsOS{cloudflare.RadarHTTPLocationHTTPMethodGetParamsOSWindows, cloudflare.RadarHTTPLocationHTTPMethodGetParamsOSMacosx, cloudflare.RadarHTTPLocationHTTPMethodGetParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPLocationHTTPMethodGetParamsTLSVersion{cloudflare.RadarHTTPLocationHTTPMethodGetParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPLocationHTTPMethodGetParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPLocationHTTPMethodGetParamsTLSVersionTlSv1_2}), - }, - ) - 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/radarhttplocationhttpprotocol.go b/radarhttplocationhttpprotocol.go deleted file mode 100644 index 1d0ac9a87dc..00000000000 --- a/radarhttplocationhttpprotocol.go +++ /dev/null @@ -1,357 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPLocationHTTPProtocolService 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 -// [NewRadarHTTPLocationHTTPProtocolService] method instead. -type RadarHTTPLocationHTTPProtocolService struct { - Options []option.RequestOption -} - -// NewRadarHTTPLocationHTTPProtocolService 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 NewRadarHTTPLocationHTTPProtocolService(opts ...option.RequestOption) (r *RadarHTTPLocationHTTPProtocolService) { - r = &RadarHTTPLocationHTTPProtocolService{} - r.Options = opts - return -} - -// Get the top locations, by HTTP traffic, of the requested HTTP protocol. Values -// are a percentage out of the total traffic. -func (r *RadarHTTPLocationHTTPProtocolService) Get(ctx context.Context, httpProtocol RadarHTTPLocationHTTPProtocolGetParamsHTTPProtocol, query RadarHTTPLocationHTTPProtocolGetParams, opts ...option.RequestOption) (res *RadarHTTPLocationHTTPProtocolGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPLocationHTTPProtocolGetResponseEnvelope - path := fmt.Sprintf("radar/http/top/locations/http_protocol/%v", httpProtocol) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPLocationHTTPProtocolGetResponse struct { - Meta RadarHTTPLocationHTTPProtocolGetResponseMeta `json:"meta,required"` - Top0 []RadarHTTPLocationHTTPProtocolGetResponseTop0 `json:"top_0,required"` - JSON radarHTTPLocationHTTPProtocolGetResponseJSON `json:"-"` -} - -// radarHTTPLocationHTTPProtocolGetResponseJSON contains the JSON metadata for the -// struct [RadarHTTPLocationHTTPProtocolGetResponse] -type radarHTTPLocationHTTPProtocolGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationHTTPProtocolGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationHTTPProtocolGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationHTTPProtocolGetResponseMeta struct { - DateRange []RadarHTTPLocationHTTPProtocolGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarHTTPLocationHTTPProtocolGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPLocationHTTPProtocolGetResponseMetaJSON `json:"-"` -} - -// radarHTTPLocationHTTPProtocolGetResponseMetaJSON contains the JSON metadata for -// the struct [RadarHTTPLocationHTTPProtocolGetResponseMeta] -type radarHTTPLocationHTTPProtocolGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationHTTPProtocolGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationHTTPProtocolGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationHTTPProtocolGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPLocationHTTPProtocolGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPLocationHTTPProtocolGetResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarHTTPLocationHTTPProtocolGetResponseMetaDateRange] -type radarHTTPLocationHTTPProtocolGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationHTTPProtocolGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationHTTPProtocolGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationHTTPProtocolGetResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPLocationHTTPProtocolGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPLocationHTTPProtocolGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPLocationHTTPProtocolGetResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarHTTPLocationHTTPProtocolGetResponseMetaConfidenceInfo] -type radarHTTPLocationHTTPProtocolGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationHTTPProtocolGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationHTTPProtocolGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationHTTPProtocolGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPLocationHTTPProtocolGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPLocationHTTPProtocolGetResponseMetaConfidenceInfoAnnotationJSON -// contains the JSON metadata for the struct -// [RadarHTTPLocationHTTPProtocolGetResponseMetaConfidenceInfoAnnotation] -type radarHTTPLocationHTTPProtocolGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationHTTPProtocolGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationHTTPProtocolGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationHTTPProtocolGetResponseTop0 struct { - ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` - ClientCountryName string `json:"clientCountryName,required"` - Value string `json:"value,required"` - JSON radarHTTPLocationHTTPProtocolGetResponseTop0JSON `json:"-"` -} - -// radarHTTPLocationHTTPProtocolGetResponseTop0JSON contains the JSON metadata for -// the struct [RadarHTTPLocationHTTPProtocolGetResponseTop0] -type radarHTTPLocationHTTPProtocolGetResponseTop0JSON struct { - ClientCountryAlpha2 apijson.Field - ClientCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationHTTPProtocolGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationHTTPProtocolGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationHTTPProtocolGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPLocationHTTPProtocolGetParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPLocationHTTPProtocolGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPLocationHTTPProtocolGetParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPLocationHTTPProtocolGetParamsFormat] `query:"format"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPLocationHTTPProtocolGetParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPLocationHTTPProtocolGetParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPLocationHTTPProtocolGetParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPLocationHTTPProtocolGetParams]'s query parameters -// as `url.Values`. -func (r RadarHTTPLocationHTTPProtocolGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// HTTP Protocol. -type RadarHTTPLocationHTTPProtocolGetParamsHTTPProtocol string - -const ( - RadarHTTPLocationHTTPProtocolGetParamsHTTPProtocolHTTP RadarHTTPLocationHTTPProtocolGetParamsHTTPProtocol = "HTTP" - RadarHTTPLocationHTTPProtocolGetParamsHTTPProtocolHTTPS RadarHTTPLocationHTTPProtocolGetParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPLocationHTTPProtocolGetParamsBotClass string - -const ( - RadarHTTPLocationHTTPProtocolGetParamsBotClassLikelyAutomated RadarHTTPLocationHTTPProtocolGetParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPLocationHTTPProtocolGetParamsBotClassLikelyHuman RadarHTTPLocationHTTPProtocolGetParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPLocationHTTPProtocolGetParamsDateRange string - -const ( - RadarHTTPLocationHTTPProtocolGetParamsDateRange1d RadarHTTPLocationHTTPProtocolGetParamsDateRange = "1d" - RadarHTTPLocationHTTPProtocolGetParamsDateRange2d RadarHTTPLocationHTTPProtocolGetParamsDateRange = "2d" - RadarHTTPLocationHTTPProtocolGetParamsDateRange7d RadarHTTPLocationHTTPProtocolGetParamsDateRange = "7d" - RadarHTTPLocationHTTPProtocolGetParamsDateRange14d RadarHTTPLocationHTTPProtocolGetParamsDateRange = "14d" - RadarHTTPLocationHTTPProtocolGetParamsDateRange28d RadarHTTPLocationHTTPProtocolGetParamsDateRange = "28d" - RadarHTTPLocationHTTPProtocolGetParamsDateRange12w RadarHTTPLocationHTTPProtocolGetParamsDateRange = "12w" - RadarHTTPLocationHTTPProtocolGetParamsDateRange24w RadarHTTPLocationHTTPProtocolGetParamsDateRange = "24w" - RadarHTTPLocationHTTPProtocolGetParamsDateRange52w RadarHTTPLocationHTTPProtocolGetParamsDateRange = "52w" - RadarHTTPLocationHTTPProtocolGetParamsDateRange1dControl RadarHTTPLocationHTTPProtocolGetParamsDateRange = "1dControl" - RadarHTTPLocationHTTPProtocolGetParamsDateRange2dControl RadarHTTPLocationHTTPProtocolGetParamsDateRange = "2dControl" - RadarHTTPLocationHTTPProtocolGetParamsDateRange7dControl RadarHTTPLocationHTTPProtocolGetParamsDateRange = "7dControl" - RadarHTTPLocationHTTPProtocolGetParamsDateRange14dControl RadarHTTPLocationHTTPProtocolGetParamsDateRange = "14dControl" - RadarHTTPLocationHTTPProtocolGetParamsDateRange28dControl RadarHTTPLocationHTTPProtocolGetParamsDateRange = "28dControl" - RadarHTTPLocationHTTPProtocolGetParamsDateRange12wControl RadarHTTPLocationHTTPProtocolGetParamsDateRange = "12wControl" - RadarHTTPLocationHTTPProtocolGetParamsDateRange24wControl RadarHTTPLocationHTTPProtocolGetParamsDateRange = "24wControl" -) - -type RadarHTTPLocationHTTPProtocolGetParamsDeviceType string - -const ( - RadarHTTPLocationHTTPProtocolGetParamsDeviceTypeDesktop RadarHTTPLocationHTTPProtocolGetParamsDeviceType = "DESKTOP" - RadarHTTPLocationHTTPProtocolGetParamsDeviceTypeMobile RadarHTTPLocationHTTPProtocolGetParamsDeviceType = "MOBILE" - RadarHTTPLocationHTTPProtocolGetParamsDeviceTypeOther RadarHTTPLocationHTTPProtocolGetParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPLocationHTTPProtocolGetParamsFormat string - -const ( - RadarHTTPLocationHTTPProtocolGetParamsFormatJson RadarHTTPLocationHTTPProtocolGetParamsFormat = "JSON" - RadarHTTPLocationHTTPProtocolGetParamsFormatCsv RadarHTTPLocationHTTPProtocolGetParamsFormat = "CSV" -) - -type RadarHTTPLocationHTTPProtocolGetParamsIPVersion string - -const ( - RadarHTTPLocationHTTPProtocolGetParamsIPVersionIPv4 RadarHTTPLocationHTTPProtocolGetParamsIPVersion = "IPv4" - RadarHTTPLocationHTTPProtocolGetParamsIPVersionIPv6 RadarHTTPLocationHTTPProtocolGetParamsIPVersion = "IPv6" -) - -type RadarHTTPLocationHTTPProtocolGetParamsOS string - -const ( - RadarHTTPLocationHTTPProtocolGetParamsOSWindows RadarHTTPLocationHTTPProtocolGetParamsOS = "WINDOWS" - RadarHTTPLocationHTTPProtocolGetParamsOSMacosx RadarHTTPLocationHTTPProtocolGetParamsOS = "MACOSX" - RadarHTTPLocationHTTPProtocolGetParamsOSIos RadarHTTPLocationHTTPProtocolGetParamsOS = "IOS" - RadarHTTPLocationHTTPProtocolGetParamsOSAndroid RadarHTTPLocationHTTPProtocolGetParamsOS = "ANDROID" - RadarHTTPLocationHTTPProtocolGetParamsOSChromeos RadarHTTPLocationHTTPProtocolGetParamsOS = "CHROMEOS" - RadarHTTPLocationHTTPProtocolGetParamsOSLinux RadarHTTPLocationHTTPProtocolGetParamsOS = "LINUX" - RadarHTTPLocationHTTPProtocolGetParamsOSSmartTv RadarHTTPLocationHTTPProtocolGetParamsOS = "SMART_TV" -) - -type RadarHTTPLocationHTTPProtocolGetParamsTLSVersion string - -const ( - RadarHTTPLocationHTTPProtocolGetParamsTLSVersionTlSv1_0 RadarHTTPLocationHTTPProtocolGetParamsTLSVersion = "TLSv1_0" - RadarHTTPLocationHTTPProtocolGetParamsTLSVersionTlSv1_1 RadarHTTPLocationHTTPProtocolGetParamsTLSVersion = "TLSv1_1" - RadarHTTPLocationHTTPProtocolGetParamsTLSVersionTlSv1_2 RadarHTTPLocationHTTPProtocolGetParamsTLSVersion = "TLSv1_2" - RadarHTTPLocationHTTPProtocolGetParamsTLSVersionTlSv1_3 RadarHTTPLocationHTTPProtocolGetParamsTLSVersion = "TLSv1_3" - RadarHTTPLocationHTTPProtocolGetParamsTLSVersionTlSvQuic RadarHTTPLocationHTTPProtocolGetParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPLocationHTTPProtocolGetResponseEnvelope struct { - Result RadarHTTPLocationHTTPProtocolGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPLocationHTTPProtocolGetResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPLocationHTTPProtocolGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarHTTPLocationHTTPProtocolGetResponseEnvelope] -type radarHTTPLocationHTTPProtocolGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationHTTPProtocolGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationHTTPProtocolGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttplocationhttpprotocol_test.go b/radarhttplocationhttpprotocol_test.go deleted file mode 100644 index 63f3f0e909d..00000000000 --- a/radarhttplocationhttpprotocol_test.go +++ /dev/null @@ -1,58 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPLocationHTTPProtocolGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Locations.HTTPProtocol.Get( - context.TODO(), - cloudflare.RadarHTTPLocationHTTPProtocolGetParamsHTTPProtocolHTTP, - cloudflare.RadarHTTPLocationHTTPProtocolGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPLocationHTTPProtocolGetParamsBotClass{cloudflare.RadarHTTPLocationHTTPProtocolGetParamsBotClassLikelyAutomated, cloudflare.RadarHTTPLocationHTTPProtocolGetParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPLocationHTTPProtocolGetParamsDateRange{cloudflare.RadarHTTPLocationHTTPProtocolGetParamsDateRange1d, cloudflare.RadarHTTPLocationHTTPProtocolGetParamsDateRange2d, cloudflare.RadarHTTPLocationHTTPProtocolGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPLocationHTTPProtocolGetParamsDeviceType{cloudflare.RadarHTTPLocationHTTPProtocolGetParamsDeviceTypeDesktop, cloudflare.RadarHTTPLocationHTTPProtocolGetParamsDeviceTypeMobile, cloudflare.RadarHTTPLocationHTTPProtocolGetParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPLocationHTTPProtocolGetParamsFormatJson), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPLocationHTTPProtocolGetParamsIPVersion{cloudflare.RadarHTTPLocationHTTPProtocolGetParamsIPVersionIPv4, cloudflare.RadarHTTPLocationHTTPProtocolGetParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPLocationHTTPProtocolGetParamsOS{cloudflare.RadarHTTPLocationHTTPProtocolGetParamsOSWindows, cloudflare.RadarHTTPLocationHTTPProtocolGetParamsOSMacosx, cloudflare.RadarHTTPLocationHTTPProtocolGetParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPLocationHTTPProtocolGetParamsTLSVersion{cloudflare.RadarHTTPLocationHTTPProtocolGetParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPLocationHTTPProtocolGetParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPLocationHTTPProtocolGetParamsTLSVersionTlSv1_2}), - }, - ) - 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/radarhttplocationipversion.go b/radarhttplocationipversion.go deleted file mode 100644 index 908e7c23f63..00000000000 --- a/radarhttplocationipversion.go +++ /dev/null @@ -1,367 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPLocationIPVersionService 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 -// [NewRadarHTTPLocationIPVersionService] method instead. -type RadarHTTPLocationIPVersionService struct { - Options []option.RequestOption -} - -// NewRadarHTTPLocationIPVersionService 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 NewRadarHTTPLocationIPVersionService(opts ...option.RequestOption) (r *RadarHTTPLocationIPVersionService) { - r = &RadarHTTPLocationIPVersionService{} - r.Options = opts - return -} - -// Get the top locations, by HTTP traffic, of the requested IP protocol version. -// Values are a percentage out of the total traffic. -func (r *RadarHTTPLocationIPVersionService) Get(ctx context.Context, ipVersion RadarHTTPLocationIPVersionGetParamsIPVersion, query RadarHTTPLocationIPVersionGetParams, opts ...option.RequestOption) (res *RadarHTTPLocationIPVersionGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPLocationIPVersionGetResponseEnvelope - path := fmt.Sprintf("radar/http/top/locations/ip_version/%v", ipVersion) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPLocationIPVersionGetResponse struct { - Meta RadarHTTPLocationIPVersionGetResponseMeta `json:"meta,required"` - Top0 []RadarHTTPLocationIPVersionGetResponseTop0 `json:"top_0,required"` - JSON radarHTTPLocationIPVersionGetResponseJSON `json:"-"` -} - -// radarHTTPLocationIPVersionGetResponseJSON contains the JSON metadata for the -// struct [RadarHTTPLocationIPVersionGetResponse] -type radarHTTPLocationIPVersionGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationIPVersionGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationIPVersionGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationIPVersionGetResponseMeta struct { - DateRange []RadarHTTPLocationIPVersionGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarHTTPLocationIPVersionGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPLocationIPVersionGetResponseMetaJSON `json:"-"` -} - -// radarHTTPLocationIPVersionGetResponseMetaJSON contains the JSON metadata for the -// struct [RadarHTTPLocationIPVersionGetResponseMeta] -type radarHTTPLocationIPVersionGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationIPVersionGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationIPVersionGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationIPVersionGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPLocationIPVersionGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPLocationIPVersionGetResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarHTTPLocationIPVersionGetResponseMetaDateRange] -type radarHTTPLocationIPVersionGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationIPVersionGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationIPVersionGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationIPVersionGetResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPLocationIPVersionGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPLocationIPVersionGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPLocationIPVersionGetResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarHTTPLocationIPVersionGetResponseMetaConfidenceInfo] -type radarHTTPLocationIPVersionGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationIPVersionGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationIPVersionGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationIPVersionGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPLocationIPVersionGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPLocationIPVersionGetResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarHTTPLocationIPVersionGetResponseMetaConfidenceInfoAnnotation] -type radarHTTPLocationIPVersionGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationIPVersionGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationIPVersionGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationIPVersionGetResponseTop0 struct { - ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` - ClientCountryName string `json:"clientCountryName,required"` - Value string `json:"value,required"` - JSON radarHTTPLocationIPVersionGetResponseTop0JSON `json:"-"` -} - -// radarHTTPLocationIPVersionGetResponseTop0JSON contains the JSON metadata for the -// struct [RadarHTTPLocationIPVersionGetResponseTop0] -type radarHTTPLocationIPVersionGetResponseTop0JSON struct { - ClientCountryAlpha2 apijson.Field - ClientCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationIPVersionGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationIPVersionGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationIPVersionGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPLocationIPVersionGetParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPLocationIPVersionGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPLocationIPVersionGetParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPLocationIPVersionGetParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPLocationIPVersionGetParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPLocationIPVersionGetParamsHTTPVersion] `query:"httpVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPLocationIPVersionGetParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPLocationIPVersionGetParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPLocationIPVersionGetParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPLocationIPVersionGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// IP version. -type RadarHTTPLocationIPVersionGetParamsIPVersion string - -const ( - RadarHTTPLocationIPVersionGetParamsIPVersionIPv4 RadarHTTPLocationIPVersionGetParamsIPVersion = "IPv4" - RadarHTTPLocationIPVersionGetParamsIPVersionIPv6 RadarHTTPLocationIPVersionGetParamsIPVersion = "IPv6" -) - -type RadarHTTPLocationIPVersionGetParamsBotClass string - -const ( - RadarHTTPLocationIPVersionGetParamsBotClassLikelyAutomated RadarHTTPLocationIPVersionGetParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPLocationIPVersionGetParamsBotClassLikelyHuman RadarHTTPLocationIPVersionGetParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPLocationIPVersionGetParamsDateRange string - -const ( - RadarHTTPLocationIPVersionGetParamsDateRange1d RadarHTTPLocationIPVersionGetParamsDateRange = "1d" - RadarHTTPLocationIPVersionGetParamsDateRange2d RadarHTTPLocationIPVersionGetParamsDateRange = "2d" - RadarHTTPLocationIPVersionGetParamsDateRange7d RadarHTTPLocationIPVersionGetParamsDateRange = "7d" - RadarHTTPLocationIPVersionGetParamsDateRange14d RadarHTTPLocationIPVersionGetParamsDateRange = "14d" - RadarHTTPLocationIPVersionGetParamsDateRange28d RadarHTTPLocationIPVersionGetParamsDateRange = "28d" - RadarHTTPLocationIPVersionGetParamsDateRange12w RadarHTTPLocationIPVersionGetParamsDateRange = "12w" - RadarHTTPLocationIPVersionGetParamsDateRange24w RadarHTTPLocationIPVersionGetParamsDateRange = "24w" - RadarHTTPLocationIPVersionGetParamsDateRange52w RadarHTTPLocationIPVersionGetParamsDateRange = "52w" - RadarHTTPLocationIPVersionGetParamsDateRange1dControl RadarHTTPLocationIPVersionGetParamsDateRange = "1dControl" - RadarHTTPLocationIPVersionGetParamsDateRange2dControl RadarHTTPLocationIPVersionGetParamsDateRange = "2dControl" - RadarHTTPLocationIPVersionGetParamsDateRange7dControl RadarHTTPLocationIPVersionGetParamsDateRange = "7dControl" - RadarHTTPLocationIPVersionGetParamsDateRange14dControl RadarHTTPLocationIPVersionGetParamsDateRange = "14dControl" - RadarHTTPLocationIPVersionGetParamsDateRange28dControl RadarHTTPLocationIPVersionGetParamsDateRange = "28dControl" - RadarHTTPLocationIPVersionGetParamsDateRange12wControl RadarHTTPLocationIPVersionGetParamsDateRange = "12wControl" - RadarHTTPLocationIPVersionGetParamsDateRange24wControl RadarHTTPLocationIPVersionGetParamsDateRange = "24wControl" -) - -type RadarHTTPLocationIPVersionGetParamsDeviceType string - -const ( - RadarHTTPLocationIPVersionGetParamsDeviceTypeDesktop RadarHTTPLocationIPVersionGetParamsDeviceType = "DESKTOP" - RadarHTTPLocationIPVersionGetParamsDeviceTypeMobile RadarHTTPLocationIPVersionGetParamsDeviceType = "MOBILE" - RadarHTTPLocationIPVersionGetParamsDeviceTypeOther RadarHTTPLocationIPVersionGetParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPLocationIPVersionGetParamsFormat string - -const ( - RadarHTTPLocationIPVersionGetParamsFormatJson RadarHTTPLocationIPVersionGetParamsFormat = "JSON" - RadarHTTPLocationIPVersionGetParamsFormatCsv RadarHTTPLocationIPVersionGetParamsFormat = "CSV" -) - -type RadarHTTPLocationIPVersionGetParamsHTTPProtocol string - -const ( - RadarHTTPLocationIPVersionGetParamsHTTPProtocolHTTP RadarHTTPLocationIPVersionGetParamsHTTPProtocol = "HTTP" - RadarHTTPLocationIPVersionGetParamsHTTPProtocolHTTPS RadarHTTPLocationIPVersionGetParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPLocationIPVersionGetParamsHTTPVersion string - -const ( - RadarHTTPLocationIPVersionGetParamsHTTPVersionHttPv1 RadarHTTPLocationIPVersionGetParamsHTTPVersion = "HTTPv1" - RadarHTTPLocationIPVersionGetParamsHTTPVersionHttPv2 RadarHTTPLocationIPVersionGetParamsHTTPVersion = "HTTPv2" - RadarHTTPLocationIPVersionGetParamsHTTPVersionHttPv3 RadarHTTPLocationIPVersionGetParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPLocationIPVersionGetParamsOS string - -const ( - RadarHTTPLocationIPVersionGetParamsOSWindows RadarHTTPLocationIPVersionGetParamsOS = "WINDOWS" - RadarHTTPLocationIPVersionGetParamsOSMacosx RadarHTTPLocationIPVersionGetParamsOS = "MACOSX" - RadarHTTPLocationIPVersionGetParamsOSIos RadarHTTPLocationIPVersionGetParamsOS = "IOS" - RadarHTTPLocationIPVersionGetParamsOSAndroid RadarHTTPLocationIPVersionGetParamsOS = "ANDROID" - RadarHTTPLocationIPVersionGetParamsOSChromeos RadarHTTPLocationIPVersionGetParamsOS = "CHROMEOS" - RadarHTTPLocationIPVersionGetParamsOSLinux RadarHTTPLocationIPVersionGetParamsOS = "LINUX" - RadarHTTPLocationIPVersionGetParamsOSSmartTv RadarHTTPLocationIPVersionGetParamsOS = "SMART_TV" -) - -type RadarHTTPLocationIPVersionGetParamsTLSVersion string - -const ( - RadarHTTPLocationIPVersionGetParamsTLSVersionTlSv1_0 RadarHTTPLocationIPVersionGetParamsTLSVersion = "TLSv1_0" - RadarHTTPLocationIPVersionGetParamsTLSVersionTlSv1_1 RadarHTTPLocationIPVersionGetParamsTLSVersion = "TLSv1_1" - RadarHTTPLocationIPVersionGetParamsTLSVersionTlSv1_2 RadarHTTPLocationIPVersionGetParamsTLSVersion = "TLSv1_2" - RadarHTTPLocationIPVersionGetParamsTLSVersionTlSv1_3 RadarHTTPLocationIPVersionGetParamsTLSVersion = "TLSv1_3" - RadarHTTPLocationIPVersionGetParamsTLSVersionTlSvQuic RadarHTTPLocationIPVersionGetParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPLocationIPVersionGetResponseEnvelope struct { - Result RadarHTTPLocationIPVersionGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPLocationIPVersionGetResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPLocationIPVersionGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarHTTPLocationIPVersionGetResponseEnvelope] -type radarHTTPLocationIPVersionGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationIPVersionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationIPVersionGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttplocationipversion_test.go b/radarhttplocationipversion_test.go deleted file mode 100644 index 645d9029471..00000000000 --- a/radarhttplocationipversion_test.go +++ /dev/null @@ -1,59 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPLocationIPVersionGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Locations.IPVersion.Get( - context.TODO(), - cloudflare.RadarHTTPLocationIPVersionGetParamsIPVersionIPv4, - cloudflare.RadarHTTPLocationIPVersionGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPLocationIPVersionGetParamsBotClass{cloudflare.RadarHTTPLocationIPVersionGetParamsBotClassLikelyAutomated, cloudflare.RadarHTTPLocationIPVersionGetParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPLocationIPVersionGetParamsDateRange{cloudflare.RadarHTTPLocationIPVersionGetParamsDateRange1d, cloudflare.RadarHTTPLocationIPVersionGetParamsDateRange2d, cloudflare.RadarHTTPLocationIPVersionGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPLocationIPVersionGetParamsDeviceType{cloudflare.RadarHTTPLocationIPVersionGetParamsDeviceTypeDesktop, cloudflare.RadarHTTPLocationIPVersionGetParamsDeviceTypeMobile, cloudflare.RadarHTTPLocationIPVersionGetParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPLocationIPVersionGetParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPLocationIPVersionGetParamsHTTPProtocol{cloudflare.RadarHTTPLocationIPVersionGetParamsHTTPProtocolHTTP, cloudflare.RadarHTTPLocationIPVersionGetParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPLocationIPVersionGetParamsHTTPVersion{cloudflare.RadarHTTPLocationIPVersionGetParamsHTTPVersionHttPv1, cloudflare.RadarHTTPLocationIPVersionGetParamsHTTPVersionHttPv2, cloudflare.RadarHTTPLocationIPVersionGetParamsHTTPVersionHttPv3}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPLocationIPVersionGetParamsOS{cloudflare.RadarHTTPLocationIPVersionGetParamsOSWindows, cloudflare.RadarHTTPLocationIPVersionGetParamsOSMacosx, cloudflare.RadarHTTPLocationIPVersionGetParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPLocationIPVersionGetParamsTLSVersion{cloudflare.RadarHTTPLocationIPVersionGetParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPLocationIPVersionGetParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPLocationIPVersionGetParamsTLSVersionTlSv1_2}), - }, - ) - 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/radarhttplocationos.go b/radarhttplocationos.go deleted file mode 100644 index b29271276fe..00000000000 --- a/radarhttplocationos.go +++ /dev/null @@ -1,366 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPLocationOSService 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 [NewRadarHTTPLocationOSService] -// method instead. -type RadarHTTPLocationOSService struct { - Options []option.RequestOption -} - -// NewRadarHTTPLocationOSService 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 NewRadarHTTPLocationOSService(opts ...option.RequestOption) (r *RadarHTTPLocationOSService) { - r = &RadarHTTPLocationOSService{} - r.Options = opts - return -} - -// Get the top locations, by HTTP traffic, of the requested operating systems. -// Values are a percentage out of the total traffic. -func (r *RadarHTTPLocationOSService) Get(ctx context.Context, os RadarHTTPLocationOSGetParamsOS, query RadarHTTPLocationOSGetParams, opts ...option.RequestOption) (res *RadarHTTPLocationOSGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPLocationOSGetResponseEnvelope - path := fmt.Sprintf("radar/http/top/locations/os/%v", os) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPLocationOSGetResponse struct { - Meta RadarHTTPLocationOSGetResponseMeta `json:"meta,required"` - Top0 []RadarHTTPLocationOSGetResponseTop0 `json:"top_0,required"` - JSON radarHTTPLocationOSGetResponseJSON `json:"-"` -} - -// radarHTTPLocationOSGetResponseJSON contains the JSON metadata for the struct -// [RadarHTTPLocationOSGetResponse] -type radarHTTPLocationOSGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationOSGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationOSGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationOSGetResponseMeta struct { - DateRange []RadarHTTPLocationOSGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarHTTPLocationOSGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPLocationOSGetResponseMetaJSON `json:"-"` -} - -// radarHTTPLocationOSGetResponseMetaJSON contains the JSON metadata for the struct -// [RadarHTTPLocationOSGetResponseMeta] -type radarHTTPLocationOSGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationOSGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationOSGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationOSGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPLocationOSGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPLocationOSGetResponseMetaDateRangeJSON contains the JSON metadata for -// the struct [RadarHTTPLocationOSGetResponseMetaDateRange] -type radarHTTPLocationOSGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationOSGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationOSGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationOSGetResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPLocationOSGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPLocationOSGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPLocationOSGetResponseMetaConfidenceInfoJSON contains the JSON metadata -// for the struct [RadarHTTPLocationOSGetResponseMetaConfidenceInfo] -type radarHTTPLocationOSGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationOSGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationOSGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationOSGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPLocationOSGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPLocationOSGetResponseMetaConfidenceInfoAnnotationJSON contains the JSON -// metadata for the struct -// [RadarHTTPLocationOSGetResponseMetaConfidenceInfoAnnotation] -type radarHTTPLocationOSGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationOSGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationOSGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationOSGetResponseTop0 struct { - ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` - ClientCountryName string `json:"clientCountryName,required"` - Value string `json:"value,required"` - JSON radarHTTPLocationOSGetResponseTop0JSON `json:"-"` -} - -// radarHTTPLocationOSGetResponseTop0JSON contains the JSON metadata for the struct -// [RadarHTTPLocationOSGetResponseTop0] -type radarHTTPLocationOSGetResponseTop0JSON struct { - ClientCountryAlpha2 apijson.Field - ClientCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationOSGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationOSGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationOSGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPLocationOSGetParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPLocationOSGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPLocationOSGetParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPLocationOSGetParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPLocationOSGetParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPLocationOSGetParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPLocationOSGetParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPLocationOSGetParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPLocationOSGetParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPLocationOSGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// IP version. -type RadarHTTPLocationOSGetParamsOS string - -const ( - RadarHTTPLocationOSGetParamsOSWindows RadarHTTPLocationOSGetParamsOS = "WINDOWS" - RadarHTTPLocationOSGetParamsOSMacosx RadarHTTPLocationOSGetParamsOS = "MACOSX" - RadarHTTPLocationOSGetParamsOSIos RadarHTTPLocationOSGetParamsOS = "IOS" - RadarHTTPLocationOSGetParamsOSAndroid RadarHTTPLocationOSGetParamsOS = "ANDROID" - RadarHTTPLocationOSGetParamsOSChromeos RadarHTTPLocationOSGetParamsOS = "CHROMEOS" - RadarHTTPLocationOSGetParamsOSLinux RadarHTTPLocationOSGetParamsOS = "LINUX" - RadarHTTPLocationOSGetParamsOSSmartTv RadarHTTPLocationOSGetParamsOS = "SMART_TV" -) - -type RadarHTTPLocationOSGetParamsBotClass string - -const ( - RadarHTTPLocationOSGetParamsBotClassLikelyAutomated RadarHTTPLocationOSGetParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPLocationOSGetParamsBotClassLikelyHuman RadarHTTPLocationOSGetParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPLocationOSGetParamsDateRange string - -const ( - RadarHTTPLocationOSGetParamsDateRange1d RadarHTTPLocationOSGetParamsDateRange = "1d" - RadarHTTPLocationOSGetParamsDateRange2d RadarHTTPLocationOSGetParamsDateRange = "2d" - RadarHTTPLocationOSGetParamsDateRange7d RadarHTTPLocationOSGetParamsDateRange = "7d" - RadarHTTPLocationOSGetParamsDateRange14d RadarHTTPLocationOSGetParamsDateRange = "14d" - RadarHTTPLocationOSGetParamsDateRange28d RadarHTTPLocationOSGetParamsDateRange = "28d" - RadarHTTPLocationOSGetParamsDateRange12w RadarHTTPLocationOSGetParamsDateRange = "12w" - RadarHTTPLocationOSGetParamsDateRange24w RadarHTTPLocationOSGetParamsDateRange = "24w" - RadarHTTPLocationOSGetParamsDateRange52w RadarHTTPLocationOSGetParamsDateRange = "52w" - RadarHTTPLocationOSGetParamsDateRange1dControl RadarHTTPLocationOSGetParamsDateRange = "1dControl" - RadarHTTPLocationOSGetParamsDateRange2dControl RadarHTTPLocationOSGetParamsDateRange = "2dControl" - RadarHTTPLocationOSGetParamsDateRange7dControl RadarHTTPLocationOSGetParamsDateRange = "7dControl" - RadarHTTPLocationOSGetParamsDateRange14dControl RadarHTTPLocationOSGetParamsDateRange = "14dControl" - RadarHTTPLocationOSGetParamsDateRange28dControl RadarHTTPLocationOSGetParamsDateRange = "28dControl" - RadarHTTPLocationOSGetParamsDateRange12wControl RadarHTTPLocationOSGetParamsDateRange = "12wControl" - RadarHTTPLocationOSGetParamsDateRange24wControl RadarHTTPLocationOSGetParamsDateRange = "24wControl" -) - -type RadarHTTPLocationOSGetParamsDeviceType string - -const ( - RadarHTTPLocationOSGetParamsDeviceTypeDesktop RadarHTTPLocationOSGetParamsDeviceType = "DESKTOP" - RadarHTTPLocationOSGetParamsDeviceTypeMobile RadarHTTPLocationOSGetParamsDeviceType = "MOBILE" - RadarHTTPLocationOSGetParamsDeviceTypeOther RadarHTTPLocationOSGetParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPLocationOSGetParamsFormat string - -const ( - RadarHTTPLocationOSGetParamsFormatJson RadarHTTPLocationOSGetParamsFormat = "JSON" - RadarHTTPLocationOSGetParamsFormatCsv RadarHTTPLocationOSGetParamsFormat = "CSV" -) - -type RadarHTTPLocationOSGetParamsHTTPProtocol string - -const ( - RadarHTTPLocationOSGetParamsHTTPProtocolHTTP RadarHTTPLocationOSGetParamsHTTPProtocol = "HTTP" - RadarHTTPLocationOSGetParamsHTTPProtocolHTTPS RadarHTTPLocationOSGetParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPLocationOSGetParamsHTTPVersion string - -const ( - RadarHTTPLocationOSGetParamsHTTPVersionHttPv1 RadarHTTPLocationOSGetParamsHTTPVersion = "HTTPv1" - RadarHTTPLocationOSGetParamsHTTPVersionHttPv2 RadarHTTPLocationOSGetParamsHTTPVersion = "HTTPv2" - RadarHTTPLocationOSGetParamsHTTPVersionHttPv3 RadarHTTPLocationOSGetParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPLocationOSGetParamsIPVersion string - -const ( - RadarHTTPLocationOSGetParamsIPVersionIPv4 RadarHTTPLocationOSGetParamsIPVersion = "IPv4" - RadarHTTPLocationOSGetParamsIPVersionIPv6 RadarHTTPLocationOSGetParamsIPVersion = "IPv6" -) - -type RadarHTTPLocationOSGetParamsTLSVersion string - -const ( - RadarHTTPLocationOSGetParamsTLSVersionTlSv1_0 RadarHTTPLocationOSGetParamsTLSVersion = "TLSv1_0" - RadarHTTPLocationOSGetParamsTLSVersionTlSv1_1 RadarHTTPLocationOSGetParamsTLSVersion = "TLSv1_1" - RadarHTTPLocationOSGetParamsTLSVersionTlSv1_2 RadarHTTPLocationOSGetParamsTLSVersion = "TLSv1_2" - RadarHTTPLocationOSGetParamsTLSVersionTlSv1_3 RadarHTTPLocationOSGetParamsTLSVersion = "TLSv1_3" - RadarHTTPLocationOSGetParamsTLSVersionTlSvQuic RadarHTTPLocationOSGetParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPLocationOSGetResponseEnvelope struct { - Result RadarHTTPLocationOSGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPLocationOSGetResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPLocationOSGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarHTTPLocationOSGetResponseEnvelope] -type radarHTTPLocationOSGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationOSGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationOSGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttplocationos_test.go b/radarhttplocationos_test.go deleted file mode 100644 index cdb3e8059de..00000000000 --- a/radarhttplocationos_test.go +++ /dev/null @@ -1,59 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPLocationOSGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Locations.OS.Get( - context.TODO(), - cloudflare.RadarHTTPLocationOSGetParamsOSWindows, - cloudflare.RadarHTTPLocationOSGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPLocationOSGetParamsBotClass{cloudflare.RadarHTTPLocationOSGetParamsBotClassLikelyAutomated, cloudflare.RadarHTTPLocationOSGetParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPLocationOSGetParamsDateRange{cloudflare.RadarHTTPLocationOSGetParamsDateRange1d, cloudflare.RadarHTTPLocationOSGetParamsDateRange2d, cloudflare.RadarHTTPLocationOSGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPLocationOSGetParamsDeviceType{cloudflare.RadarHTTPLocationOSGetParamsDeviceTypeDesktop, cloudflare.RadarHTTPLocationOSGetParamsDeviceTypeMobile, cloudflare.RadarHTTPLocationOSGetParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPLocationOSGetParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPLocationOSGetParamsHTTPProtocol{cloudflare.RadarHTTPLocationOSGetParamsHTTPProtocolHTTP, cloudflare.RadarHTTPLocationOSGetParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPLocationOSGetParamsHTTPVersion{cloudflare.RadarHTTPLocationOSGetParamsHTTPVersionHttPv1, cloudflare.RadarHTTPLocationOSGetParamsHTTPVersionHttPv2, cloudflare.RadarHTTPLocationOSGetParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPLocationOSGetParamsIPVersion{cloudflare.RadarHTTPLocationOSGetParamsIPVersionIPv4, cloudflare.RadarHTTPLocationOSGetParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPLocationOSGetParamsTLSVersion{cloudflare.RadarHTTPLocationOSGetParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPLocationOSGetParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPLocationOSGetParamsTLSVersionTlSv1_2}), - }, - ) - 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/radarhttplocationtlsversion.go b/radarhttplocationtlsversion.go deleted file mode 100644 index bd0fc8f4484..00000000000 --- a/radarhttplocationtlsversion.go +++ /dev/null @@ -1,367 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPLocationTLSVersionService 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 -// [NewRadarHTTPLocationTLSVersionService] method instead. -type RadarHTTPLocationTLSVersionService struct { - Options []option.RequestOption -} - -// NewRadarHTTPLocationTLSVersionService 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 NewRadarHTTPLocationTLSVersionService(opts ...option.RequestOption) (r *RadarHTTPLocationTLSVersionService) { - r = &RadarHTTPLocationTLSVersionService{} - r.Options = opts - return -} - -// Get the top locations, by HTTP traffic, of the requested TLS protocol version. -// Values are a percentage out of the total traffic. -func (r *RadarHTTPLocationTLSVersionService) Get(ctx context.Context, tlsVersion RadarHTTPLocationTLSVersionGetParamsTLSVersion, query RadarHTTPLocationTLSVersionGetParams, opts ...option.RequestOption) (res *RadarHTTPLocationTLSVersionGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPLocationTLSVersionGetResponseEnvelope - path := fmt.Sprintf("radar/http/top/locations/tls_version/%v", tlsVersion) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPLocationTLSVersionGetResponse struct { - Meta RadarHTTPLocationTLSVersionGetResponseMeta `json:"meta,required"` - Top0 []RadarHTTPLocationTLSVersionGetResponseTop0 `json:"top_0,required"` - JSON radarHTTPLocationTLSVersionGetResponseJSON `json:"-"` -} - -// radarHTTPLocationTLSVersionGetResponseJSON contains the JSON metadata for the -// struct [RadarHTTPLocationTLSVersionGetResponse] -type radarHTTPLocationTLSVersionGetResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationTLSVersionGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationTLSVersionGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationTLSVersionGetResponseMeta struct { - DateRange []RadarHTTPLocationTLSVersionGetResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarHTTPLocationTLSVersionGetResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPLocationTLSVersionGetResponseMetaJSON `json:"-"` -} - -// radarHTTPLocationTLSVersionGetResponseMetaJSON contains the JSON metadata for -// the struct [RadarHTTPLocationTLSVersionGetResponseMeta] -type radarHTTPLocationTLSVersionGetResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationTLSVersionGetResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationTLSVersionGetResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationTLSVersionGetResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPLocationTLSVersionGetResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPLocationTLSVersionGetResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarHTTPLocationTLSVersionGetResponseMetaDateRange] -type radarHTTPLocationTLSVersionGetResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationTLSVersionGetResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationTLSVersionGetResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationTLSVersionGetResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPLocationTLSVersionGetResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPLocationTLSVersionGetResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPLocationTLSVersionGetResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarHTTPLocationTLSVersionGetResponseMetaConfidenceInfo] -type radarHTTPLocationTLSVersionGetResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationTLSVersionGetResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationTLSVersionGetResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationTLSVersionGetResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPLocationTLSVersionGetResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPLocationTLSVersionGetResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarHTTPLocationTLSVersionGetResponseMetaConfidenceInfoAnnotation] -type radarHTTPLocationTLSVersionGetResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationTLSVersionGetResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationTLSVersionGetResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationTLSVersionGetResponseTop0 struct { - ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` - ClientCountryName string `json:"clientCountryName,required"` - Value string `json:"value,required"` - JSON radarHTTPLocationTLSVersionGetResponseTop0JSON `json:"-"` -} - -// radarHTTPLocationTLSVersionGetResponseTop0JSON contains the JSON metadata for -// the struct [RadarHTTPLocationTLSVersionGetResponseTop0] -type radarHTTPLocationTLSVersionGetResponseTop0JSON struct { - ClientCountryAlpha2 apijson.Field - ClientCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationTLSVersionGetResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationTLSVersionGetResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPLocationTLSVersionGetParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPLocationTLSVersionGetParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPLocationTLSVersionGetParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPLocationTLSVersionGetParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPLocationTLSVersionGetParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPLocationTLSVersionGetParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPLocationTLSVersionGetParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPLocationTLSVersionGetParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPLocationTLSVersionGetParamsOS] `query:"os"` -} - -// URLQuery serializes [RadarHTTPLocationTLSVersionGetParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPLocationTLSVersionGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// TLS version. -type RadarHTTPLocationTLSVersionGetParamsTLSVersion string - -const ( - RadarHTTPLocationTLSVersionGetParamsTLSVersionTlSv1_0 RadarHTTPLocationTLSVersionGetParamsTLSVersion = "TLSv1_0" - RadarHTTPLocationTLSVersionGetParamsTLSVersionTlSv1_1 RadarHTTPLocationTLSVersionGetParamsTLSVersion = "TLSv1_1" - RadarHTTPLocationTLSVersionGetParamsTLSVersionTlSv1_2 RadarHTTPLocationTLSVersionGetParamsTLSVersion = "TLSv1_2" - RadarHTTPLocationTLSVersionGetParamsTLSVersionTlSv1_3 RadarHTTPLocationTLSVersionGetParamsTLSVersion = "TLSv1_3" - RadarHTTPLocationTLSVersionGetParamsTLSVersionTlSvQuic RadarHTTPLocationTLSVersionGetParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPLocationTLSVersionGetParamsBotClass string - -const ( - RadarHTTPLocationTLSVersionGetParamsBotClassLikelyAutomated RadarHTTPLocationTLSVersionGetParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPLocationTLSVersionGetParamsBotClassLikelyHuman RadarHTTPLocationTLSVersionGetParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPLocationTLSVersionGetParamsDateRange string - -const ( - RadarHTTPLocationTLSVersionGetParamsDateRange1d RadarHTTPLocationTLSVersionGetParamsDateRange = "1d" - RadarHTTPLocationTLSVersionGetParamsDateRange2d RadarHTTPLocationTLSVersionGetParamsDateRange = "2d" - RadarHTTPLocationTLSVersionGetParamsDateRange7d RadarHTTPLocationTLSVersionGetParamsDateRange = "7d" - RadarHTTPLocationTLSVersionGetParamsDateRange14d RadarHTTPLocationTLSVersionGetParamsDateRange = "14d" - RadarHTTPLocationTLSVersionGetParamsDateRange28d RadarHTTPLocationTLSVersionGetParamsDateRange = "28d" - RadarHTTPLocationTLSVersionGetParamsDateRange12w RadarHTTPLocationTLSVersionGetParamsDateRange = "12w" - RadarHTTPLocationTLSVersionGetParamsDateRange24w RadarHTTPLocationTLSVersionGetParamsDateRange = "24w" - RadarHTTPLocationTLSVersionGetParamsDateRange52w RadarHTTPLocationTLSVersionGetParamsDateRange = "52w" - RadarHTTPLocationTLSVersionGetParamsDateRange1dControl RadarHTTPLocationTLSVersionGetParamsDateRange = "1dControl" - RadarHTTPLocationTLSVersionGetParamsDateRange2dControl RadarHTTPLocationTLSVersionGetParamsDateRange = "2dControl" - RadarHTTPLocationTLSVersionGetParamsDateRange7dControl RadarHTTPLocationTLSVersionGetParamsDateRange = "7dControl" - RadarHTTPLocationTLSVersionGetParamsDateRange14dControl RadarHTTPLocationTLSVersionGetParamsDateRange = "14dControl" - RadarHTTPLocationTLSVersionGetParamsDateRange28dControl RadarHTTPLocationTLSVersionGetParamsDateRange = "28dControl" - RadarHTTPLocationTLSVersionGetParamsDateRange12wControl RadarHTTPLocationTLSVersionGetParamsDateRange = "12wControl" - RadarHTTPLocationTLSVersionGetParamsDateRange24wControl RadarHTTPLocationTLSVersionGetParamsDateRange = "24wControl" -) - -type RadarHTTPLocationTLSVersionGetParamsDeviceType string - -const ( - RadarHTTPLocationTLSVersionGetParamsDeviceTypeDesktop RadarHTTPLocationTLSVersionGetParamsDeviceType = "DESKTOP" - RadarHTTPLocationTLSVersionGetParamsDeviceTypeMobile RadarHTTPLocationTLSVersionGetParamsDeviceType = "MOBILE" - RadarHTTPLocationTLSVersionGetParamsDeviceTypeOther RadarHTTPLocationTLSVersionGetParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPLocationTLSVersionGetParamsFormat string - -const ( - RadarHTTPLocationTLSVersionGetParamsFormatJson RadarHTTPLocationTLSVersionGetParamsFormat = "JSON" - RadarHTTPLocationTLSVersionGetParamsFormatCsv RadarHTTPLocationTLSVersionGetParamsFormat = "CSV" -) - -type RadarHTTPLocationTLSVersionGetParamsHTTPProtocol string - -const ( - RadarHTTPLocationTLSVersionGetParamsHTTPProtocolHTTP RadarHTTPLocationTLSVersionGetParamsHTTPProtocol = "HTTP" - RadarHTTPLocationTLSVersionGetParamsHTTPProtocolHTTPS RadarHTTPLocationTLSVersionGetParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPLocationTLSVersionGetParamsHTTPVersion string - -const ( - RadarHTTPLocationTLSVersionGetParamsHTTPVersionHttPv1 RadarHTTPLocationTLSVersionGetParamsHTTPVersion = "HTTPv1" - RadarHTTPLocationTLSVersionGetParamsHTTPVersionHttPv2 RadarHTTPLocationTLSVersionGetParamsHTTPVersion = "HTTPv2" - RadarHTTPLocationTLSVersionGetParamsHTTPVersionHttPv3 RadarHTTPLocationTLSVersionGetParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPLocationTLSVersionGetParamsIPVersion string - -const ( - RadarHTTPLocationTLSVersionGetParamsIPVersionIPv4 RadarHTTPLocationTLSVersionGetParamsIPVersion = "IPv4" - RadarHTTPLocationTLSVersionGetParamsIPVersionIPv6 RadarHTTPLocationTLSVersionGetParamsIPVersion = "IPv6" -) - -type RadarHTTPLocationTLSVersionGetParamsOS string - -const ( - RadarHTTPLocationTLSVersionGetParamsOSWindows RadarHTTPLocationTLSVersionGetParamsOS = "WINDOWS" - RadarHTTPLocationTLSVersionGetParamsOSMacosx RadarHTTPLocationTLSVersionGetParamsOS = "MACOSX" - RadarHTTPLocationTLSVersionGetParamsOSIos RadarHTTPLocationTLSVersionGetParamsOS = "IOS" - RadarHTTPLocationTLSVersionGetParamsOSAndroid RadarHTTPLocationTLSVersionGetParamsOS = "ANDROID" - RadarHTTPLocationTLSVersionGetParamsOSChromeos RadarHTTPLocationTLSVersionGetParamsOS = "CHROMEOS" - RadarHTTPLocationTLSVersionGetParamsOSLinux RadarHTTPLocationTLSVersionGetParamsOS = "LINUX" - RadarHTTPLocationTLSVersionGetParamsOSSmartTv RadarHTTPLocationTLSVersionGetParamsOS = "SMART_TV" -) - -type RadarHTTPLocationTLSVersionGetResponseEnvelope struct { - Result RadarHTTPLocationTLSVersionGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPLocationTLSVersionGetResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPLocationTLSVersionGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarHTTPLocationTLSVersionGetResponseEnvelope] -type radarHTTPLocationTLSVersionGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPLocationTLSVersionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPLocationTLSVersionGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttplocationtlsversion_test.go b/radarhttplocationtlsversion_test.go deleted file mode 100644 index d097f7dd22a..00000000000 --- a/radarhttplocationtlsversion_test.go +++ /dev/null @@ -1,59 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPLocationTLSVersionGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Locations.TLSVersion.Get( - context.TODO(), - cloudflare.RadarHTTPLocationTLSVersionGetParamsTLSVersionTlSv1_0, - cloudflare.RadarHTTPLocationTLSVersionGetParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPLocationTLSVersionGetParamsBotClass{cloudflare.RadarHTTPLocationTLSVersionGetParamsBotClassLikelyAutomated, cloudflare.RadarHTTPLocationTLSVersionGetParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPLocationTLSVersionGetParamsDateRange{cloudflare.RadarHTTPLocationTLSVersionGetParamsDateRange1d, cloudflare.RadarHTTPLocationTLSVersionGetParamsDateRange2d, cloudflare.RadarHTTPLocationTLSVersionGetParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPLocationTLSVersionGetParamsDeviceType{cloudflare.RadarHTTPLocationTLSVersionGetParamsDeviceTypeDesktop, cloudflare.RadarHTTPLocationTLSVersionGetParamsDeviceTypeMobile, cloudflare.RadarHTTPLocationTLSVersionGetParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPLocationTLSVersionGetParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPLocationTLSVersionGetParamsHTTPProtocol{cloudflare.RadarHTTPLocationTLSVersionGetParamsHTTPProtocolHTTP, cloudflare.RadarHTTPLocationTLSVersionGetParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPLocationTLSVersionGetParamsHTTPVersion{cloudflare.RadarHTTPLocationTLSVersionGetParamsHTTPVersionHttPv1, cloudflare.RadarHTTPLocationTLSVersionGetParamsHTTPVersionHttPv2, cloudflare.RadarHTTPLocationTLSVersionGetParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPLocationTLSVersionGetParamsIPVersion{cloudflare.RadarHTTPLocationTLSVersionGetParamsIPVersionIPv4, cloudflare.RadarHTTPLocationTLSVersionGetParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPLocationTLSVersionGetParamsOS{cloudflare.RadarHTTPLocationTLSVersionGetParamsOSWindows, cloudflare.RadarHTTPLocationTLSVersionGetParamsOSMacosx, cloudflare.RadarHTTPLocationTLSVersionGetParamsOSIos}), - }, - ) - 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/radarhttpsummary.go b/radarhttpsummary.go deleted file mode 100644 index 8cb1bbb264a..00000000000 --- a/radarhttpsummary.go +++ /dev/null @@ -1,2280 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPSummaryService 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 [NewRadarHTTPSummaryService] method -// instead. -type RadarHTTPSummaryService struct { - Options []option.RequestOption -} - -// NewRadarHTTPSummaryService 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 NewRadarHTTPSummaryService(opts ...option.RequestOption) (r *RadarHTTPSummaryService) { - r = &RadarHTTPSummaryService{} - r.Options = opts - return -} - -// Percentage distribution of bot-generated traffic to genuine human traffic, as -// classified by Cloudflare. Visit -// https://developers.cloudflare.com/radar/concepts/bot-classes/ for more -// information. -func (r *RadarHTTPSummaryService) BotClass(ctx context.Context, query RadarHTTPSummaryBotClassParams, opts ...option.RequestOption) (res *RadarHTTPSummaryBotClassResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPSummaryBotClassResponseEnvelope - path := "radar/http/summary/bot_class" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage of Internet traffic generated by mobile, desktop, and other types of -// devices, over a given time period. -func (r *RadarHTTPSummaryService) DeviceType(ctx context.Context, query RadarHTTPSummaryDeviceTypeParams, opts ...option.RequestOption) (res *RadarHTTPSummaryDeviceTypeResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPSummaryDeviceTypeResponseEnvelope - path := "radar/http/summary/device_type" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of traffic per HTTP protocol over a given time period. -func (r *RadarHTTPSummaryService) HTTPProtocol(ctx context.Context, query RadarHTTPSummaryHTTPProtocolParams, opts ...option.RequestOption) (res *RadarHTTPSummaryHTTPProtocolResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPSummaryHTTPProtocolResponseEnvelope - path := "radar/http/summary/http_protocol" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of traffic per HTTP protocol version over a given time -// period. -func (r *RadarHTTPSummaryService) HTTPVersion(ctx context.Context, query RadarHTTPSummaryHTTPVersionParams, opts ...option.RequestOption) (res *RadarHTTPSummaryHTTPVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPSummaryHTTPVersionResponseEnvelope - path := "radar/http/summary/http_version" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of Internet traffic based on IP protocol versions, such -// as IPv4 and IPv6, over a given time period. -func (r *RadarHTTPSummaryService) IPVersion(ctx context.Context, query RadarHTTPSummaryIPVersionParams, opts ...option.RequestOption) (res *RadarHTTPSummaryIPVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPSummaryIPVersionResponseEnvelope - path := "radar/http/summary/ip_version" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of Internet traffic generated by different operating -// systems like Windows, macOS, Android, iOS, and others, over a given time period. -func (r *RadarHTTPSummaryService) OS(ctx context.Context, query RadarHTTPSummaryOSParams, opts ...option.RequestOption) (res *RadarHTTPSummaryOSResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPSummaryOSResponseEnvelope - path := "radar/http/summary/os" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Percentage distribution of traffic per TLS protocol version, over a given time -// period. -func (r *RadarHTTPSummaryService) TLSVersion(ctx context.Context, query RadarHTTPSummaryTLSVersionParams, opts ...option.RequestOption) (res *RadarHTTPSummaryTLSVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPSummaryTLSVersionResponseEnvelope - path := "radar/http/summary/tls_version" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPSummaryBotClassResponse struct { - Meta RadarHTTPSummaryBotClassResponseMeta `json:"meta,required"` - Summary0 RadarHTTPSummaryBotClassResponseSummary0 `json:"summary_0,required"` - JSON radarHTTPSummaryBotClassResponseJSON `json:"-"` -} - -// radarHTTPSummaryBotClassResponseJSON contains the JSON metadata for the struct -// [RadarHTTPSummaryBotClassResponse] -type radarHTTPSummaryBotClassResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryBotClassResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryBotClassResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryBotClassResponseMeta struct { - DateRange []RadarHTTPSummaryBotClassResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarHTTPSummaryBotClassResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPSummaryBotClassResponseMetaJSON `json:"-"` -} - -// radarHTTPSummaryBotClassResponseMetaJSON contains the JSON metadata for the -// struct [RadarHTTPSummaryBotClassResponseMeta] -type radarHTTPSummaryBotClassResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryBotClassResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryBotClassResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryBotClassResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPSummaryBotClassResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPSummaryBotClassResponseMetaDateRangeJSON contains the JSON metadata for -// the struct [RadarHTTPSummaryBotClassResponseMetaDateRange] -type radarHTTPSummaryBotClassResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryBotClassResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryBotClassResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryBotClassResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPSummaryBotClassResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPSummaryBotClassResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPSummaryBotClassResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarHTTPSummaryBotClassResponseMetaConfidenceInfo] -type radarHTTPSummaryBotClassResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryBotClassResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryBotClassResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryBotClassResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPSummaryBotClassResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPSummaryBotClassResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarHTTPSummaryBotClassResponseMetaConfidenceInfoAnnotation] -type radarHTTPSummaryBotClassResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryBotClassResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryBotClassResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryBotClassResponseSummary0 struct { - Bot string `json:"bot,required"` - Human string `json:"human,required"` - JSON radarHTTPSummaryBotClassResponseSummary0JSON `json:"-"` -} - -// radarHTTPSummaryBotClassResponseSummary0JSON contains the JSON metadata for the -// struct [RadarHTTPSummaryBotClassResponseSummary0] -type radarHTTPSummaryBotClassResponseSummary0JSON struct { - Bot apijson.Field - Human apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryBotClassResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryBotClassResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryDeviceTypeResponse struct { - Meta RadarHTTPSummaryDeviceTypeResponseMeta `json:"meta,required"` - Summary0 RadarHTTPSummaryDeviceTypeResponseSummary0 `json:"summary_0,required"` - JSON radarHTTPSummaryDeviceTypeResponseJSON `json:"-"` -} - -// radarHTTPSummaryDeviceTypeResponseJSON contains the JSON metadata for the struct -// [RadarHTTPSummaryDeviceTypeResponse] -type radarHTTPSummaryDeviceTypeResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryDeviceTypeResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryDeviceTypeResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryDeviceTypeResponseMeta struct { - DateRange []RadarHTTPSummaryDeviceTypeResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarHTTPSummaryDeviceTypeResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPSummaryDeviceTypeResponseMetaJSON `json:"-"` -} - -// radarHTTPSummaryDeviceTypeResponseMetaJSON contains the JSON metadata for the -// struct [RadarHTTPSummaryDeviceTypeResponseMeta] -type radarHTTPSummaryDeviceTypeResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryDeviceTypeResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryDeviceTypeResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryDeviceTypeResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPSummaryDeviceTypeResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPSummaryDeviceTypeResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarHTTPSummaryDeviceTypeResponseMetaDateRange] -type radarHTTPSummaryDeviceTypeResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryDeviceTypeResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryDeviceTypeResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryDeviceTypeResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPSummaryDeviceTypeResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPSummaryDeviceTypeResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPSummaryDeviceTypeResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarHTTPSummaryDeviceTypeResponseMetaConfidenceInfo] -type radarHTTPSummaryDeviceTypeResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryDeviceTypeResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryDeviceTypeResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryDeviceTypeResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPSummaryDeviceTypeResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPSummaryDeviceTypeResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarHTTPSummaryDeviceTypeResponseMetaConfidenceInfoAnnotation] -type radarHTTPSummaryDeviceTypeResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryDeviceTypeResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryDeviceTypeResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryDeviceTypeResponseSummary0 struct { - Desktop string `json:"desktop,required"` - Mobile string `json:"mobile,required"` - Other string `json:"other,required"` - JSON radarHTTPSummaryDeviceTypeResponseSummary0JSON `json:"-"` -} - -// radarHTTPSummaryDeviceTypeResponseSummary0JSON contains the JSON metadata for -// the struct [RadarHTTPSummaryDeviceTypeResponseSummary0] -type radarHTTPSummaryDeviceTypeResponseSummary0JSON struct { - Desktop apijson.Field - Mobile apijson.Field - Other apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryDeviceTypeResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryDeviceTypeResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryHTTPProtocolResponse struct { - Meta RadarHTTPSummaryHTTPProtocolResponseMeta `json:"meta,required"` - Summary0 RadarHTTPSummaryHTTPProtocolResponseSummary0 `json:"summary_0,required"` - JSON radarHTTPSummaryHTTPProtocolResponseJSON `json:"-"` -} - -// radarHTTPSummaryHTTPProtocolResponseJSON contains the JSON metadata for the -// struct [RadarHTTPSummaryHTTPProtocolResponse] -type radarHTTPSummaryHTTPProtocolResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryHTTPProtocolResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryHTTPProtocolResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryHTTPProtocolResponseMeta struct { - DateRange []RadarHTTPSummaryHTTPProtocolResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarHTTPSummaryHTTPProtocolResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPSummaryHTTPProtocolResponseMetaJSON `json:"-"` -} - -// radarHTTPSummaryHTTPProtocolResponseMetaJSON contains the JSON metadata for the -// struct [RadarHTTPSummaryHTTPProtocolResponseMeta] -type radarHTTPSummaryHTTPProtocolResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryHTTPProtocolResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryHTTPProtocolResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryHTTPProtocolResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPSummaryHTTPProtocolResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPSummaryHTTPProtocolResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarHTTPSummaryHTTPProtocolResponseMetaDateRange] -type radarHTTPSummaryHTTPProtocolResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryHTTPProtocolResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryHTTPProtocolResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryHTTPProtocolResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPSummaryHTTPProtocolResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPSummaryHTTPProtocolResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPSummaryHTTPProtocolResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarHTTPSummaryHTTPProtocolResponseMetaConfidenceInfo] -type radarHTTPSummaryHTTPProtocolResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryHTTPProtocolResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryHTTPProtocolResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryHTTPProtocolResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPSummaryHTTPProtocolResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPSummaryHTTPProtocolResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarHTTPSummaryHTTPProtocolResponseMetaConfidenceInfoAnnotation] -type radarHTTPSummaryHTTPProtocolResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryHTTPProtocolResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryHTTPProtocolResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryHTTPProtocolResponseSummary0 struct { - HTTP string `json:"http,required"` - HTTPS string `json:"https,required"` - JSON radarHTTPSummaryHTTPProtocolResponseSummary0JSON `json:"-"` -} - -// radarHTTPSummaryHTTPProtocolResponseSummary0JSON contains the JSON metadata for -// the struct [RadarHTTPSummaryHTTPProtocolResponseSummary0] -type radarHTTPSummaryHTTPProtocolResponseSummary0JSON struct { - HTTP apijson.Field - HTTPS apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryHTTPProtocolResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryHTTPProtocolResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryHTTPVersionResponse struct { - Meta RadarHTTPSummaryHTTPVersionResponseMeta `json:"meta,required"` - Summary0 RadarHTTPSummaryHTTPVersionResponseSummary0 `json:"summary_0,required"` - JSON radarHTTPSummaryHTTPVersionResponseJSON `json:"-"` -} - -// radarHTTPSummaryHTTPVersionResponseJSON contains the JSON metadata for the -// struct [RadarHTTPSummaryHTTPVersionResponse] -type radarHTTPSummaryHTTPVersionResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryHTTPVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryHTTPVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryHTTPVersionResponseMeta struct { - DateRange []RadarHTTPSummaryHTTPVersionResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarHTTPSummaryHTTPVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPSummaryHTTPVersionResponseMetaJSON `json:"-"` -} - -// radarHTTPSummaryHTTPVersionResponseMetaJSON contains the JSON metadata for the -// struct [RadarHTTPSummaryHTTPVersionResponseMeta] -type radarHTTPSummaryHTTPVersionResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryHTTPVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryHTTPVersionResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryHTTPVersionResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPSummaryHTTPVersionResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPSummaryHTTPVersionResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarHTTPSummaryHTTPVersionResponseMetaDateRange] -type radarHTTPSummaryHTTPVersionResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryHTTPVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryHTTPVersionResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryHTTPVersionResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPSummaryHTTPVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPSummaryHTTPVersionResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPSummaryHTTPVersionResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarHTTPSummaryHTTPVersionResponseMetaConfidenceInfo] -type radarHTTPSummaryHTTPVersionResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryHTTPVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryHTTPVersionResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryHTTPVersionResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPSummaryHTTPVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPSummaryHTTPVersionResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarHTTPSummaryHTTPVersionResponseMetaConfidenceInfoAnnotation] -type radarHTTPSummaryHTTPVersionResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryHTTPVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryHTTPVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryHTTPVersionResponseSummary0 struct { - HTTP1X string `json:"HTTP/1.x,required"` - HTTP2 string `json:"HTTP/2,required"` - HTTP3 string `json:"HTTP/3,required"` - JSON radarHTTPSummaryHTTPVersionResponseSummary0JSON `json:"-"` -} - -// radarHTTPSummaryHTTPVersionResponseSummary0JSON contains the JSON metadata for -// the struct [RadarHTTPSummaryHTTPVersionResponseSummary0] -type radarHTTPSummaryHTTPVersionResponseSummary0JSON struct { - HTTP1X apijson.Field - HTTP2 apijson.Field - HTTP3 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryHTTPVersionResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryHTTPVersionResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryIPVersionResponse struct { - Meta RadarHTTPSummaryIPVersionResponseMeta `json:"meta,required"` - Summary0 RadarHTTPSummaryIPVersionResponseSummary0 `json:"summary_0,required"` - JSON radarHTTPSummaryIPVersionResponseJSON `json:"-"` -} - -// radarHTTPSummaryIPVersionResponseJSON contains the JSON metadata for the struct -// [RadarHTTPSummaryIPVersionResponse] -type radarHTTPSummaryIPVersionResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryIPVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryIPVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryIPVersionResponseMeta struct { - DateRange []RadarHTTPSummaryIPVersionResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarHTTPSummaryIPVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPSummaryIPVersionResponseMetaJSON `json:"-"` -} - -// radarHTTPSummaryIPVersionResponseMetaJSON contains the JSON metadata for the -// struct [RadarHTTPSummaryIPVersionResponseMeta] -type radarHTTPSummaryIPVersionResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryIPVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryIPVersionResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryIPVersionResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPSummaryIPVersionResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPSummaryIPVersionResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarHTTPSummaryIPVersionResponseMetaDateRange] -type radarHTTPSummaryIPVersionResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryIPVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryIPVersionResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryIPVersionResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPSummaryIPVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPSummaryIPVersionResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPSummaryIPVersionResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarHTTPSummaryIPVersionResponseMetaConfidenceInfo] -type radarHTTPSummaryIPVersionResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryIPVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryIPVersionResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryIPVersionResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPSummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPSummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarHTTPSummaryIPVersionResponseMetaConfidenceInfoAnnotation] -type radarHTTPSummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryIPVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryIPVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryIPVersionResponseSummary0 struct { - IPv4 string `json:"IPv4,required"` - IPv6 string `json:"IPv6,required"` - JSON radarHTTPSummaryIPVersionResponseSummary0JSON `json:"-"` -} - -// radarHTTPSummaryIPVersionResponseSummary0JSON contains the JSON metadata for the -// struct [RadarHTTPSummaryIPVersionResponseSummary0] -type radarHTTPSummaryIPVersionResponseSummary0JSON struct { - IPv4 apijson.Field - IPv6 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryIPVersionResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryIPVersionResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryOSResponse struct { - Meta RadarHTTPSummaryOSResponseMeta `json:"meta,required"` - Summary0 RadarHTTPSummaryOSResponseSummary0 `json:"summary_0,required"` - JSON radarHTTPSummaryOSResponseJSON `json:"-"` -} - -// radarHTTPSummaryOSResponseJSON contains the JSON metadata for the struct -// [RadarHTTPSummaryOSResponse] -type radarHTTPSummaryOSResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryOSResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryOSResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryOSResponseMeta struct { - DateRange []RadarHTTPSummaryOSResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarHTTPSummaryOSResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPSummaryOSResponseMetaJSON `json:"-"` -} - -// radarHTTPSummaryOSResponseMetaJSON contains the JSON metadata for the struct -// [RadarHTTPSummaryOSResponseMeta] -type radarHTTPSummaryOSResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryOSResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryOSResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryOSResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPSummaryOSResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPSummaryOSResponseMetaDateRangeJSON contains the JSON metadata for the -// struct [RadarHTTPSummaryOSResponseMetaDateRange] -type radarHTTPSummaryOSResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryOSResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryOSResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryOSResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPSummaryOSResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPSummaryOSResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPSummaryOSResponseMetaConfidenceInfoJSON contains the JSON metadata for -// the struct [RadarHTTPSummaryOSResponseMetaConfidenceInfo] -type radarHTTPSummaryOSResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryOSResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryOSResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryOSResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPSummaryOSResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPSummaryOSResponseMetaConfidenceInfoAnnotationJSON contains the JSON -// metadata for the struct [RadarHTTPSummaryOSResponseMetaConfidenceInfoAnnotation] -type radarHTTPSummaryOSResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryOSResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryOSResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryOSResponseSummary0 struct { - Android string `json:"ANDROID,required"` - Ios string `json:"IOS,required"` - JSON radarHTTPSummaryOSResponseSummary0JSON `json:"-"` -} - -// radarHTTPSummaryOSResponseSummary0JSON contains the JSON metadata for the struct -// [RadarHTTPSummaryOSResponseSummary0] -type radarHTTPSummaryOSResponseSummary0JSON struct { - Android apijson.Field - Ios apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryOSResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryOSResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryTLSVersionResponse struct { - Meta RadarHTTPSummaryTLSVersionResponseMeta `json:"meta,required"` - Summary0 RadarHTTPSummaryTLSVersionResponseSummary0 `json:"summary_0,required"` - JSON radarHTTPSummaryTLSVersionResponseJSON `json:"-"` -} - -// radarHTTPSummaryTLSVersionResponseJSON contains the JSON metadata for the struct -// [RadarHTTPSummaryTLSVersionResponse] -type radarHTTPSummaryTLSVersionResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryTLSVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryTLSVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryTLSVersionResponseMeta struct { - DateRange []RadarHTTPSummaryTLSVersionResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarHTTPSummaryTLSVersionResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPSummaryTLSVersionResponseMetaJSON `json:"-"` -} - -// radarHTTPSummaryTLSVersionResponseMetaJSON contains the JSON metadata for the -// struct [RadarHTTPSummaryTLSVersionResponseMeta] -type radarHTTPSummaryTLSVersionResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryTLSVersionResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryTLSVersionResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryTLSVersionResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPSummaryTLSVersionResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPSummaryTLSVersionResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarHTTPSummaryTLSVersionResponseMetaDateRange] -type radarHTTPSummaryTLSVersionResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryTLSVersionResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryTLSVersionResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryTLSVersionResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPSummaryTLSVersionResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPSummaryTLSVersionResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPSummaryTLSVersionResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarHTTPSummaryTLSVersionResponseMetaConfidenceInfo] -type radarHTTPSummaryTLSVersionResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryTLSVersionResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryTLSVersionResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryTLSVersionResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPSummaryTLSVersionResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPSummaryTLSVersionResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarHTTPSummaryTLSVersionResponseMetaConfidenceInfoAnnotation] -type radarHTTPSummaryTLSVersionResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryTLSVersionResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryTLSVersionResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryTLSVersionResponseSummary0 struct { - TLS1_0 string `json:"TLS 1.0,required"` - TLS1_1 string `json:"TLS 1.1,required"` - TLS1_2 string `json:"TLS 1.2,required"` - TLS1_3 string `json:"TLS 1.3,required"` - TLSQuic string `json:"TLS QUIC,required"` - JSON radarHTTPSummaryTLSVersionResponseSummary0JSON `json:"-"` -} - -// radarHTTPSummaryTLSVersionResponseSummary0JSON contains the JSON metadata for -// the struct [RadarHTTPSummaryTLSVersionResponseSummary0] -type radarHTTPSummaryTLSVersionResponseSummary0JSON struct { - TLS1_0 apijson.Field - TLS1_1 apijson.Field - TLS1_2 apijson.Field - TLS1_3 apijson.Field - TLSQuic apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryTLSVersionResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryTLSVersionResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryBotClassParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPSummaryBotClassParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPSummaryBotClassParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPSummaryBotClassParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPSummaryBotClassParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPSummaryBotClassParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPSummaryBotClassParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPSummaryBotClassParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPSummaryBotClassParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPSummaryBotClassParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPSummaryBotClassParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarHTTPSummaryBotClassParamsDateRange string - -const ( - RadarHTTPSummaryBotClassParamsDateRange1d RadarHTTPSummaryBotClassParamsDateRange = "1d" - RadarHTTPSummaryBotClassParamsDateRange2d RadarHTTPSummaryBotClassParamsDateRange = "2d" - RadarHTTPSummaryBotClassParamsDateRange7d RadarHTTPSummaryBotClassParamsDateRange = "7d" - RadarHTTPSummaryBotClassParamsDateRange14d RadarHTTPSummaryBotClassParamsDateRange = "14d" - RadarHTTPSummaryBotClassParamsDateRange28d RadarHTTPSummaryBotClassParamsDateRange = "28d" - RadarHTTPSummaryBotClassParamsDateRange12w RadarHTTPSummaryBotClassParamsDateRange = "12w" - RadarHTTPSummaryBotClassParamsDateRange24w RadarHTTPSummaryBotClassParamsDateRange = "24w" - RadarHTTPSummaryBotClassParamsDateRange52w RadarHTTPSummaryBotClassParamsDateRange = "52w" - RadarHTTPSummaryBotClassParamsDateRange1dControl RadarHTTPSummaryBotClassParamsDateRange = "1dControl" - RadarHTTPSummaryBotClassParamsDateRange2dControl RadarHTTPSummaryBotClassParamsDateRange = "2dControl" - RadarHTTPSummaryBotClassParamsDateRange7dControl RadarHTTPSummaryBotClassParamsDateRange = "7dControl" - RadarHTTPSummaryBotClassParamsDateRange14dControl RadarHTTPSummaryBotClassParamsDateRange = "14dControl" - RadarHTTPSummaryBotClassParamsDateRange28dControl RadarHTTPSummaryBotClassParamsDateRange = "28dControl" - RadarHTTPSummaryBotClassParamsDateRange12wControl RadarHTTPSummaryBotClassParamsDateRange = "12wControl" - RadarHTTPSummaryBotClassParamsDateRange24wControl RadarHTTPSummaryBotClassParamsDateRange = "24wControl" -) - -type RadarHTTPSummaryBotClassParamsDeviceType string - -const ( - RadarHTTPSummaryBotClassParamsDeviceTypeDesktop RadarHTTPSummaryBotClassParamsDeviceType = "DESKTOP" - RadarHTTPSummaryBotClassParamsDeviceTypeMobile RadarHTTPSummaryBotClassParamsDeviceType = "MOBILE" - RadarHTTPSummaryBotClassParamsDeviceTypeOther RadarHTTPSummaryBotClassParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPSummaryBotClassParamsFormat string - -const ( - RadarHTTPSummaryBotClassParamsFormatJson RadarHTTPSummaryBotClassParamsFormat = "JSON" - RadarHTTPSummaryBotClassParamsFormatCsv RadarHTTPSummaryBotClassParamsFormat = "CSV" -) - -type RadarHTTPSummaryBotClassParamsHTTPProtocol string - -const ( - RadarHTTPSummaryBotClassParamsHTTPProtocolHTTP RadarHTTPSummaryBotClassParamsHTTPProtocol = "HTTP" - RadarHTTPSummaryBotClassParamsHTTPProtocolHTTPS RadarHTTPSummaryBotClassParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPSummaryBotClassParamsHTTPVersion string - -const ( - RadarHTTPSummaryBotClassParamsHTTPVersionHttPv1 RadarHTTPSummaryBotClassParamsHTTPVersion = "HTTPv1" - RadarHTTPSummaryBotClassParamsHTTPVersionHttPv2 RadarHTTPSummaryBotClassParamsHTTPVersion = "HTTPv2" - RadarHTTPSummaryBotClassParamsHTTPVersionHttPv3 RadarHTTPSummaryBotClassParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPSummaryBotClassParamsIPVersion string - -const ( - RadarHTTPSummaryBotClassParamsIPVersionIPv4 RadarHTTPSummaryBotClassParamsIPVersion = "IPv4" - RadarHTTPSummaryBotClassParamsIPVersionIPv6 RadarHTTPSummaryBotClassParamsIPVersion = "IPv6" -) - -type RadarHTTPSummaryBotClassParamsOS string - -const ( - RadarHTTPSummaryBotClassParamsOSWindows RadarHTTPSummaryBotClassParamsOS = "WINDOWS" - RadarHTTPSummaryBotClassParamsOSMacosx RadarHTTPSummaryBotClassParamsOS = "MACOSX" - RadarHTTPSummaryBotClassParamsOSIos RadarHTTPSummaryBotClassParamsOS = "IOS" - RadarHTTPSummaryBotClassParamsOSAndroid RadarHTTPSummaryBotClassParamsOS = "ANDROID" - RadarHTTPSummaryBotClassParamsOSChromeos RadarHTTPSummaryBotClassParamsOS = "CHROMEOS" - RadarHTTPSummaryBotClassParamsOSLinux RadarHTTPSummaryBotClassParamsOS = "LINUX" - RadarHTTPSummaryBotClassParamsOSSmartTv RadarHTTPSummaryBotClassParamsOS = "SMART_TV" -) - -type RadarHTTPSummaryBotClassParamsTLSVersion string - -const ( - RadarHTTPSummaryBotClassParamsTLSVersionTlSv1_0 RadarHTTPSummaryBotClassParamsTLSVersion = "TLSv1_0" - RadarHTTPSummaryBotClassParamsTLSVersionTlSv1_1 RadarHTTPSummaryBotClassParamsTLSVersion = "TLSv1_1" - RadarHTTPSummaryBotClassParamsTLSVersionTlSv1_2 RadarHTTPSummaryBotClassParamsTLSVersion = "TLSv1_2" - RadarHTTPSummaryBotClassParamsTLSVersionTlSv1_3 RadarHTTPSummaryBotClassParamsTLSVersion = "TLSv1_3" - RadarHTTPSummaryBotClassParamsTLSVersionTlSvQuic RadarHTTPSummaryBotClassParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPSummaryBotClassResponseEnvelope struct { - Result RadarHTTPSummaryBotClassResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPSummaryBotClassResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPSummaryBotClassResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarHTTPSummaryBotClassResponseEnvelope] -type radarHTTPSummaryBotClassResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryBotClassResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryBotClassResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryDeviceTypeParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPSummaryDeviceTypeParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPSummaryDeviceTypeParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarHTTPSummaryDeviceTypeParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPSummaryDeviceTypeParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPSummaryDeviceTypeParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPSummaryDeviceTypeParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPSummaryDeviceTypeParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPSummaryDeviceTypeParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPSummaryDeviceTypeParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPSummaryDeviceTypeParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarHTTPSummaryDeviceTypeParamsBotClass string - -const ( - RadarHTTPSummaryDeviceTypeParamsBotClassLikelyAutomated RadarHTTPSummaryDeviceTypeParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPSummaryDeviceTypeParamsBotClassLikelyHuman RadarHTTPSummaryDeviceTypeParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPSummaryDeviceTypeParamsDateRange string - -const ( - RadarHTTPSummaryDeviceTypeParamsDateRange1d RadarHTTPSummaryDeviceTypeParamsDateRange = "1d" - RadarHTTPSummaryDeviceTypeParamsDateRange2d RadarHTTPSummaryDeviceTypeParamsDateRange = "2d" - RadarHTTPSummaryDeviceTypeParamsDateRange7d RadarHTTPSummaryDeviceTypeParamsDateRange = "7d" - RadarHTTPSummaryDeviceTypeParamsDateRange14d RadarHTTPSummaryDeviceTypeParamsDateRange = "14d" - RadarHTTPSummaryDeviceTypeParamsDateRange28d RadarHTTPSummaryDeviceTypeParamsDateRange = "28d" - RadarHTTPSummaryDeviceTypeParamsDateRange12w RadarHTTPSummaryDeviceTypeParamsDateRange = "12w" - RadarHTTPSummaryDeviceTypeParamsDateRange24w RadarHTTPSummaryDeviceTypeParamsDateRange = "24w" - RadarHTTPSummaryDeviceTypeParamsDateRange52w RadarHTTPSummaryDeviceTypeParamsDateRange = "52w" - RadarHTTPSummaryDeviceTypeParamsDateRange1dControl RadarHTTPSummaryDeviceTypeParamsDateRange = "1dControl" - RadarHTTPSummaryDeviceTypeParamsDateRange2dControl RadarHTTPSummaryDeviceTypeParamsDateRange = "2dControl" - RadarHTTPSummaryDeviceTypeParamsDateRange7dControl RadarHTTPSummaryDeviceTypeParamsDateRange = "7dControl" - RadarHTTPSummaryDeviceTypeParamsDateRange14dControl RadarHTTPSummaryDeviceTypeParamsDateRange = "14dControl" - RadarHTTPSummaryDeviceTypeParamsDateRange28dControl RadarHTTPSummaryDeviceTypeParamsDateRange = "28dControl" - RadarHTTPSummaryDeviceTypeParamsDateRange12wControl RadarHTTPSummaryDeviceTypeParamsDateRange = "12wControl" - RadarHTTPSummaryDeviceTypeParamsDateRange24wControl RadarHTTPSummaryDeviceTypeParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarHTTPSummaryDeviceTypeParamsFormat string - -const ( - RadarHTTPSummaryDeviceTypeParamsFormatJson RadarHTTPSummaryDeviceTypeParamsFormat = "JSON" - RadarHTTPSummaryDeviceTypeParamsFormatCsv RadarHTTPSummaryDeviceTypeParamsFormat = "CSV" -) - -type RadarHTTPSummaryDeviceTypeParamsHTTPProtocol string - -const ( - RadarHTTPSummaryDeviceTypeParamsHTTPProtocolHTTP RadarHTTPSummaryDeviceTypeParamsHTTPProtocol = "HTTP" - RadarHTTPSummaryDeviceTypeParamsHTTPProtocolHTTPS RadarHTTPSummaryDeviceTypeParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPSummaryDeviceTypeParamsHTTPVersion string - -const ( - RadarHTTPSummaryDeviceTypeParamsHTTPVersionHttPv1 RadarHTTPSummaryDeviceTypeParamsHTTPVersion = "HTTPv1" - RadarHTTPSummaryDeviceTypeParamsHTTPVersionHttPv2 RadarHTTPSummaryDeviceTypeParamsHTTPVersion = "HTTPv2" - RadarHTTPSummaryDeviceTypeParamsHTTPVersionHttPv3 RadarHTTPSummaryDeviceTypeParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPSummaryDeviceTypeParamsIPVersion string - -const ( - RadarHTTPSummaryDeviceTypeParamsIPVersionIPv4 RadarHTTPSummaryDeviceTypeParamsIPVersion = "IPv4" - RadarHTTPSummaryDeviceTypeParamsIPVersionIPv6 RadarHTTPSummaryDeviceTypeParamsIPVersion = "IPv6" -) - -type RadarHTTPSummaryDeviceTypeParamsOS string - -const ( - RadarHTTPSummaryDeviceTypeParamsOSWindows RadarHTTPSummaryDeviceTypeParamsOS = "WINDOWS" - RadarHTTPSummaryDeviceTypeParamsOSMacosx RadarHTTPSummaryDeviceTypeParamsOS = "MACOSX" - RadarHTTPSummaryDeviceTypeParamsOSIos RadarHTTPSummaryDeviceTypeParamsOS = "IOS" - RadarHTTPSummaryDeviceTypeParamsOSAndroid RadarHTTPSummaryDeviceTypeParamsOS = "ANDROID" - RadarHTTPSummaryDeviceTypeParamsOSChromeos RadarHTTPSummaryDeviceTypeParamsOS = "CHROMEOS" - RadarHTTPSummaryDeviceTypeParamsOSLinux RadarHTTPSummaryDeviceTypeParamsOS = "LINUX" - RadarHTTPSummaryDeviceTypeParamsOSSmartTv RadarHTTPSummaryDeviceTypeParamsOS = "SMART_TV" -) - -type RadarHTTPSummaryDeviceTypeParamsTLSVersion string - -const ( - RadarHTTPSummaryDeviceTypeParamsTLSVersionTlSv1_0 RadarHTTPSummaryDeviceTypeParamsTLSVersion = "TLSv1_0" - RadarHTTPSummaryDeviceTypeParamsTLSVersionTlSv1_1 RadarHTTPSummaryDeviceTypeParamsTLSVersion = "TLSv1_1" - RadarHTTPSummaryDeviceTypeParamsTLSVersionTlSv1_2 RadarHTTPSummaryDeviceTypeParamsTLSVersion = "TLSv1_2" - RadarHTTPSummaryDeviceTypeParamsTLSVersionTlSv1_3 RadarHTTPSummaryDeviceTypeParamsTLSVersion = "TLSv1_3" - RadarHTTPSummaryDeviceTypeParamsTLSVersionTlSvQuic RadarHTTPSummaryDeviceTypeParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPSummaryDeviceTypeResponseEnvelope struct { - Result RadarHTTPSummaryDeviceTypeResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPSummaryDeviceTypeResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPSummaryDeviceTypeResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarHTTPSummaryDeviceTypeResponseEnvelope] -type radarHTTPSummaryDeviceTypeResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryDeviceTypeResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryDeviceTypeResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryHTTPProtocolParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPSummaryHTTPProtocolParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPSummaryHTTPProtocolParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPSummaryHTTPProtocolParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPSummaryHTTPProtocolParamsFormat] `query:"format"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPSummaryHTTPProtocolParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPSummaryHTTPProtocolParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPSummaryHTTPProtocolParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPSummaryHTTPProtocolParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPSummaryHTTPProtocolParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPSummaryHTTPProtocolParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarHTTPSummaryHTTPProtocolParamsBotClass string - -const ( - RadarHTTPSummaryHTTPProtocolParamsBotClassLikelyAutomated RadarHTTPSummaryHTTPProtocolParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPSummaryHTTPProtocolParamsBotClassLikelyHuman RadarHTTPSummaryHTTPProtocolParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPSummaryHTTPProtocolParamsDateRange string - -const ( - RadarHTTPSummaryHTTPProtocolParamsDateRange1d RadarHTTPSummaryHTTPProtocolParamsDateRange = "1d" - RadarHTTPSummaryHTTPProtocolParamsDateRange2d RadarHTTPSummaryHTTPProtocolParamsDateRange = "2d" - RadarHTTPSummaryHTTPProtocolParamsDateRange7d RadarHTTPSummaryHTTPProtocolParamsDateRange = "7d" - RadarHTTPSummaryHTTPProtocolParamsDateRange14d RadarHTTPSummaryHTTPProtocolParamsDateRange = "14d" - RadarHTTPSummaryHTTPProtocolParamsDateRange28d RadarHTTPSummaryHTTPProtocolParamsDateRange = "28d" - RadarHTTPSummaryHTTPProtocolParamsDateRange12w RadarHTTPSummaryHTTPProtocolParamsDateRange = "12w" - RadarHTTPSummaryHTTPProtocolParamsDateRange24w RadarHTTPSummaryHTTPProtocolParamsDateRange = "24w" - RadarHTTPSummaryHTTPProtocolParamsDateRange52w RadarHTTPSummaryHTTPProtocolParamsDateRange = "52w" - RadarHTTPSummaryHTTPProtocolParamsDateRange1dControl RadarHTTPSummaryHTTPProtocolParamsDateRange = "1dControl" - RadarHTTPSummaryHTTPProtocolParamsDateRange2dControl RadarHTTPSummaryHTTPProtocolParamsDateRange = "2dControl" - RadarHTTPSummaryHTTPProtocolParamsDateRange7dControl RadarHTTPSummaryHTTPProtocolParamsDateRange = "7dControl" - RadarHTTPSummaryHTTPProtocolParamsDateRange14dControl RadarHTTPSummaryHTTPProtocolParamsDateRange = "14dControl" - RadarHTTPSummaryHTTPProtocolParamsDateRange28dControl RadarHTTPSummaryHTTPProtocolParamsDateRange = "28dControl" - RadarHTTPSummaryHTTPProtocolParamsDateRange12wControl RadarHTTPSummaryHTTPProtocolParamsDateRange = "12wControl" - RadarHTTPSummaryHTTPProtocolParamsDateRange24wControl RadarHTTPSummaryHTTPProtocolParamsDateRange = "24wControl" -) - -type RadarHTTPSummaryHTTPProtocolParamsDeviceType string - -const ( - RadarHTTPSummaryHTTPProtocolParamsDeviceTypeDesktop RadarHTTPSummaryHTTPProtocolParamsDeviceType = "DESKTOP" - RadarHTTPSummaryHTTPProtocolParamsDeviceTypeMobile RadarHTTPSummaryHTTPProtocolParamsDeviceType = "MOBILE" - RadarHTTPSummaryHTTPProtocolParamsDeviceTypeOther RadarHTTPSummaryHTTPProtocolParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPSummaryHTTPProtocolParamsFormat string - -const ( - RadarHTTPSummaryHTTPProtocolParamsFormatJson RadarHTTPSummaryHTTPProtocolParamsFormat = "JSON" - RadarHTTPSummaryHTTPProtocolParamsFormatCsv RadarHTTPSummaryHTTPProtocolParamsFormat = "CSV" -) - -type RadarHTTPSummaryHTTPProtocolParamsHTTPVersion string - -const ( - RadarHTTPSummaryHTTPProtocolParamsHTTPVersionHttPv1 RadarHTTPSummaryHTTPProtocolParamsHTTPVersion = "HTTPv1" - RadarHTTPSummaryHTTPProtocolParamsHTTPVersionHttPv2 RadarHTTPSummaryHTTPProtocolParamsHTTPVersion = "HTTPv2" - RadarHTTPSummaryHTTPProtocolParamsHTTPVersionHttPv3 RadarHTTPSummaryHTTPProtocolParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPSummaryHTTPProtocolParamsIPVersion string - -const ( - RadarHTTPSummaryHTTPProtocolParamsIPVersionIPv4 RadarHTTPSummaryHTTPProtocolParamsIPVersion = "IPv4" - RadarHTTPSummaryHTTPProtocolParamsIPVersionIPv6 RadarHTTPSummaryHTTPProtocolParamsIPVersion = "IPv6" -) - -type RadarHTTPSummaryHTTPProtocolParamsOS string - -const ( - RadarHTTPSummaryHTTPProtocolParamsOSWindows RadarHTTPSummaryHTTPProtocolParamsOS = "WINDOWS" - RadarHTTPSummaryHTTPProtocolParamsOSMacosx RadarHTTPSummaryHTTPProtocolParamsOS = "MACOSX" - RadarHTTPSummaryHTTPProtocolParamsOSIos RadarHTTPSummaryHTTPProtocolParamsOS = "IOS" - RadarHTTPSummaryHTTPProtocolParamsOSAndroid RadarHTTPSummaryHTTPProtocolParamsOS = "ANDROID" - RadarHTTPSummaryHTTPProtocolParamsOSChromeos RadarHTTPSummaryHTTPProtocolParamsOS = "CHROMEOS" - RadarHTTPSummaryHTTPProtocolParamsOSLinux RadarHTTPSummaryHTTPProtocolParamsOS = "LINUX" - RadarHTTPSummaryHTTPProtocolParamsOSSmartTv RadarHTTPSummaryHTTPProtocolParamsOS = "SMART_TV" -) - -type RadarHTTPSummaryHTTPProtocolParamsTLSVersion string - -const ( - RadarHTTPSummaryHTTPProtocolParamsTLSVersionTlSv1_0 RadarHTTPSummaryHTTPProtocolParamsTLSVersion = "TLSv1_0" - RadarHTTPSummaryHTTPProtocolParamsTLSVersionTlSv1_1 RadarHTTPSummaryHTTPProtocolParamsTLSVersion = "TLSv1_1" - RadarHTTPSummaryHTTPProtocolParamsTLSVersionTlSv1_2 RadarHTTPSummaryHTTPProtocolParamsTLSVersion = "TLSv1_2" - RadarHTTPSummaryHTTPProtocolParamsTLSVersionTlSv1_3 RadarHTTPSummaryHTTPProtocolParamsTLSVersion = "TLSv1_3" - RadarHTTPSummaryHTTPProtocolParamsTLSVersionTlSvQuic RadarHTTPSummaryHTTPProtocolParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPSummaryHTTPProtocolResponseEnvelope struct { - Result RadarHTTPSummaryHTTPProtocolResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPSummaryHTTPProtocolResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPSummaryHTTPProtocolResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarHTTPSummaryHTTPProtocolResponseEnvelope] -type radarHTTPSummaryHTTPProtocolResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryHTTPProtocolResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryHTTPProtocolResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryHTTPVersionParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPSummaryHTTPVersionParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPSummaryHTTPVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPSummaryHTTPVersionParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPSummaryHTTPVersionParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPSummaryHTTPVersionParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPSummaryHTTPVersionParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPSummaryHTTPVersionParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPSummaryHTTPVersionParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPSummaryHTTPVersionParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPSummaryHTTPVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarHTTPSummaryHTTPVersionParamsBotClass string - -const ( - RadarHTTPSummaryHTTPVersionParamsBotClassLikelyAutomated RadarHTTPSummaryHTTPVersionParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPSummaryHTTPVersionParamsBotClassLikelyHuman RadarHTTPSummaryHTTPVersionParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPSummaryHTTPVersionParamsDateRange string - -const ( - RadarHTTPSummaryHTTPVersionParamsDateRange1d RadarHTTPSummaryHTTPVersionParamsDateRange = "1d" - RadarHTTPSummaryHTTPVersionParamsDateRange2d RadarHTTPSummaryHTTPVersionParamsDateRange = "2d" - RadarHTTPSummaryHTTPVersionParamsDateRange7d RadarHTTPSummaryHTTPVersionParamsDateRange = "7d" - RadarHTTPSummaryHTTPVersionParamsDateRange14d RadarHTTPSummaryHTTPVersionParamsDateRange = "14d" - RadarHTTPSummaryHTTPVersionParamsDateRange28d RadarHTTPSummaryHTTPVersionParamsDateRange = "28d" - RadarHTTPSummaryHTTPVersionParamsDateRange12w RadarHTTPSummaryHTTPVersionParamsDateRange = "12w" - RadarHTTPSummaryHTTPVersionParamsDateRange24w RadarHTTPSummaryHTTPVersionParamsDateRange = "24w" - RadarHTTPSummaryHTTPVersionParamsDateRange52w RadarHTTPSummaryHTTPVersionParamsDateRange = "52w" - RadarHTTPSummaryHTTPVersionParamsDateRange1dControl RadarHTTPSummaryHTTPVersionParamsDateRange = "1dControl" - RadarHTTPSummaryHTTPVersionParamsDateRange2dControl RadarHTTPSummaryHTTPVersionParamsDateRange = "2dControl" - RadarHTTPSummaryHTTPVersionParamsDateRange7dControl RadarHTTPSummaryHTTPVersionParamsDateRange = "7dControl" - RadarHTTPSummaryHTTPVersionParamsDateRange14dControl RadarHTTPSummaryHTTPVersionParamsDateRange = "14dControl" - RadarHTTPSummaryHTTPVersionParamsDateRange28dControl RadarHTTPSummaryHTTPVersionParamsDateRange = "28dControl" - RadarHTTPSummaryHTTPVersionParamsDateRange12wControl RadarHTTPSummaryHTTPVersionParamsDateRange = "12wControl" - RadarHTTPSummaryHTTPVersionParamsDateRange24wControl RadarHTTPSummaryHTTPVersionParamsDateRange = "24wControl" -) - -type RadarHTTPSummaryHTTPVersionParamsDeviceType string - -const ( - RadarHTTPSummaryHTTPVersionParamsDeviceTypeDesktop RadarHTTPSummaryHTTPVersionParamsDeviceType = "DESKTOP" - RadarHTTPSummaryHTTPVersionParamsDeviceTypeMobile RadarHTTPSummaryHTTPVersionParamsDeviceType = "MOBILE" - RadarHTTPSummaryHTTPVersionParamsDeviceTypeOther RadarHTTPSummaryHTTPVersionParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPSummaryHTTPVersionParamsFormat string - -const ( - RadarHTTPSummaryHTTPVersionParamsFormatJson RadarHTTPSummaryHTTPVersionParamsFormat = "JSON" - RadarHTTPSummaryHTTPVersionParamsFormatCsv RadarHTTPSummaryHTTPVersionParamsFormat = "CSV" -) - -type RadarHTTPSummaryHTTPVersionParamsHTTPProtocol string - -const ( - RadarHTTPSummaryHTTPVersionParamsHTTPProtocolHTTP RadarHTTPSummaryHTTPVersionParamsHTTPProtocol = "HTTP" - RadarHTTPSummaryHTTPVersionParamsHTTPProtocolHTTPS RadarHTTPSummaryHTTPVersionParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPSummaryHTTPVersionParamsIPVersion string - -const ( - RadarHTTPSummaryHTTPVersionParamsIPVersionIPv4 RadarHTTPSummaryHTTPVersionParamsIPVersion = "IPv4" - RadarHTTPSummaryHTTPVersionParamsIPVersionIPv6 RadarHTTPSummaryHTTPVersionParamsIPVersion = "IPv6" -) - -type RadarHTTPSummaryHTTPVersionParamsOS string - -const ( - RadarHTTPSummaryHTTPVersionParamsOSWindows RadarHTTPSummaryHTTPVersionParamsOS = "WINDOWS" - RadarHTTPSummaryHTTPVersionParamsOSMacosx RadarHTTPSummaryHTTPVersionParamsOS = "MACOSX" - RadarHTTPSummaryHTTPVersionParamsOSIos RadarHTTPSummaryHTTPVersionParamsOS = "IOS" - RadarHTTPSummaryHTTPVersionParamsOSAndroid RadarHTTPSummaryHTTPVersionParamsOS = "ANDROID" - RadarHTTPSummaryHTTPVersionParamsOSChromeos RadarHTTPSummaryHTTPVersionParamsOS = "CHROMEOS" - RadarHTTPSummaryHTTPVersionParamsOSLinux RadarHTTPSummaryHTTPVersionParamsOS = "LINUX" - RadarHTTPSummaryHTTPVersionParamsOSSmartTv RadarHTTPSummaryHTTPVersionParamsOS = "SMART_TV" -) - -type RadarHTTPSummaryHTTPVersionParamsTLSVersion string - -const ( - RadarHTTPSummaryHTTPVersionParamsTLSVersionTlSv1_0 RadarHTTPSummaryHTTPVersionParamsTLSVersion = "TLSv1_0" - RadarHTTPSummaryHTTPVersionParamsTLSVersionTlSv1_1 RadarHTTPSummaryHTTPVersionParamsTLSVersion = "TLSv1_1" - RadarHTTPSummaryHTTPVersionParamsTLSVersionTlSv1_2 RadarHTTPSummaryHTTPVersionParamsTLSVersion = "TLSv1_2" - RadarHTTPSummaryHTTPVersionParamsTLSVersionTlSv1_3 RadarHTTPSummaryHTTPVersionParamsTLSVersion = "TLSv1_3" - RadarHTTPSummaryHTTPVersionParamsTLSVersionTlSvQuic RadarHTTPSummaryHTTPVersionParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPSummaryHTTPVersionResponseEnvelope struct { - Result RadarHTTPSummaryHTTPVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPSummaryHTTPVersionResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPSummaryHTTPVersionResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarHTTPSummaryHTTPVersionResponseEnvelope] -type radarHTTPSummaryHTTPVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryHTTPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryHTTPVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryIPVersionParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPSummaryIPVersionParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPSummaryIPVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPSummaryIPVersionParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPSummaryIPVersionParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPSummaryIPVersionParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPSummaryIPVersionParamsHTTPVersion] `query:"httpVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPSummaryIPVersionParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPSummaryIPVersionParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPSummaryIPVersionParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPSummaryIPVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarHTTPSummaryIPVersionParamsBotClass string - -const ( - RadarHTTPSummaryIPVersionParamsBotClassLikelyAutomated RadarHTTPSummaryIPVersionParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPSummaryIPVersionParamsBotClassLikelyHuman RadarHTTPSummaryIPVersionParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPSummaryIPVersionParamsDateRange string - -const ( - RadarHTTPSummaryIPVersionParamsDateRange1d RadarHTTPSummaryIPVersionParamsDateRange = "1d" - RadarHTTPSummaryIPVersionParamsDateRange2d RadarHTTPSummaryIPVersionParamsDateRange = "2d" - RadarHTTPSummaryIPVersionParamsDateRange7d RadarHTTPSummaryIPVersionParamsDateRange = "7d" - RadarHTTPSummaryIPVersionParamsDateRange14d RadarHTTPSummaryIPVersionParamsDateRange = "14d" - RadarHTTPSummaryIPVersionParamsDateRange28d RadarHTTPSummaryIPVersionParamsDateRange = "28d" - RadarHTTPSummaryIPVersionParamsDateRange12w RadarHTTPSummaryIPVersionParamsDateRange = "12w" - RadarHTTPSummaryIPVersionParamsDateRange24w RadarHTTPSummaryIPVersionParamsDateRange = "24w" - RadarHTTPSummaryIPVersionParamsDateRange52w RadarHTTPSummaryIPVersionParamsDateRange = "52w" - RadarHTTPSummaryIPVersionParamsDateRange1dControl RadarHTTPSummaryIPVersionParamsDateRange = "1dControl" - RadarHTTPSummaryIPVersionParamsDateRange2dControl RadarHTTPSummaryIPVersionParamsDateRange = "2dControl" - RadarHTTPSummaryIPVersionParamsDateRange7dControl RadarHTTPSummaryIPVersionParamsDateRange = "7dControl" - RadarHTTPSummaryIPVersionParamsDateRange14dControl RadarHTTPSummaryIPVersionParamsDateRange = "14dControl" - RadarHTTPSummaryIPVersionParamsDateRange28dControl RadarHTTPSummaryIPVersionParamsDateRange = "28dControl" - RadarHTTPSummaryIPVersionParamsDateRange12wControl RadarHTTPSummaryIPVersionParamsDateRange = "12wControl" - RadarHTTPSummaryIPVersionParamsDateRange24wControl RadarHTTPSummaryIPVersionParamsDateRange = "24wControl" -) - -type RadarHTTPSummaryIPVersionParamsDeviceType string - -const ( - RadarHTTPSummaryIPVersionParamsDeviceTypeDesktop RadarHTTPSummaryIPVersionParamsDeviceType = "DESKTOP" - RadarHTTPSummaryIPVersionParamsDeviceTypeMobile RadarHTTPSummaryIPVersionParamsDeviceType = "MOBILE" - RadarHTTPSummaryIPVersionParamsDeviceTypeOther RadarHTTPSummaryIPVersionParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPSummaryIPVersionParamsFormat string - -const ( - RadarHTTPSummaryIPVersionParamsFormatJson RadarHTTPSummaryIPVersionParamsFormat = "JSON" - RadarHTTPSummaryIPVersionParamsFormatCsv RadarHTTPSummaryIPVersionParamsFormat = "CSV" -) - -type RadarHTTPSummaryIPVersionParamsHTTPProtocol string - -const ( - RadarHTTPSummaryIPVersionParamsHTTPProtocolHTTP RadarHTTPSummaryIPVersionParamsHTTPProtocol = "HTTP" - RadarHTTPSummaryIPVersionParamsHTTPProtocolHTTPS RadarHTTPSummaryIPVersionParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPSummaryIPVersionParamsHTTPVersion string - -const ( - RadarHTTPSummaryIPVersionParamsHTTPVersionHttPv1 RadarHTTPSummaryIPVersionParamsHTTPVersion = "HTTPv1" - RadarHTTPSummaryIPVersionParamsHTTPVersionHttPv2 RadarHTTPSummaryIPVersionParamsHTTPVersion = "HTTPv2" - RadarHTTPSummaryIPVersionParamsHTTPVersionHttPv3 RadarHTTPSummaryIPVersionParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPSummaryIPVersionParamsOS string - -const ( - RadarHTTPSummaryIPVersionParamsOSWindows RadarHTTPSummaryIPVersionParamsOS = "WINDOWS" - RadarHTTPSummaryIPVersionParamsOSMacosx RadarHTTPSummaryIPVersionParamsOS = "MACOSX" - RadarHTTPSummaryIPVersionParamsOSIos RadarHTTPSummaryIPVersionParamsOS = "IOS" - RadarHTTPSummaryIPVersionParamsOSAndroid RadarHTTPSummaryIPVersionParamsOS = "ANDROID" - RadarHTTPSummaryIPVersionParamsOSChromeos RadarHTTPSummaryIPVersionParamsOS = "CHROMEOS" - RadarHTTPSummaryIPVersionParamsOSLinux RadarHTTPSummaryIPVersionParamsOS = "LINUX" - RadarHTTPSummaryIPVersionParamsOSSmartTv RadarHTTPSummaryIPVersionParamsOS = "SMART_TV" -) - -type RadarHTTPSummaryIPVersionParamsTLSVersion string - -const ( - RadarHTTPSummaryIPVersionParamsTLSVersionTlSv1_0 RadarHTTPSummaryIPVersionParamsTLSVersion = "TLSv1_0" - RadarHTTPSummaryIPVersionParamsTLSVersionTlSv1_1 RadarHTTPSummaryIPVersionParamsTLSVersion = "TLSv1_1" - RadarHTTPSummaryIPVersionParamsTLSVersionTlSv1_2 RadarHTTPSummaryIPVersionParamsTLSVersion = "TLSv1_2" - RadarHTTPSummaryIPVersionParamsTLSVersionTlSv1_3 RadarHTTPSummaryIPVersionParamsTLSVersion = "TLSv1_3" - RadarHTTPSummaryIPVersionParamsTLSVersionTlSvQuic RadarHTTPSummaryIPVersionParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPSummaryIPVersionResponseEnvelope struct { - Result RadarHTTPSummaryIPVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPSummaryIPVersionResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPSummaryIPVersionResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarHTTPSummaryIPVersionResponseEnvelope] -type radarHTTPSummaryIPVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryIPVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryOSParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPSummaryOSParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPSummaryOSParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPSummaryOSParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPSummaryOSParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPSummaryOSParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPSummaryOSParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPSummaryOSParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPSummaryOSParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPSummaryOSParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPSummaryOSParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarHTTPSummaryOSParamsBotClass string - -const ( - RadarHTTPSummaryOSParamsBotClassLikelyAutomated RadarHTTPSummaryOSParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPSummaryOSParamsBotClassLikelyHuman RadarHTTPSummaryOSParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPSummaryOSParamsDateRange string - -const ( - RadarHTTPSummaryOSParamsDateRange1d RadarHTTPSummaryOSParamsDateRange = "1d" - RadarHTTPSummaryOSParamsDateRange2d RadarHTTPSummaryOSParamsDateRange = "2d" - RadarHTTPSummaryOSParamsDateRange7d RadarHTTPSummaryOSParamsDateRange = "7d" - RadarHTTPSummaryOSParamsDateRange14d RadarHTTPSummaryOSParamsDateRange = "14d" - RadarHTTPSummaryOSParamsDateRange28d RadarHTTPSummaryOSParamsDateRange = "28d" - RadarHTTPSummaryOSParamsDateRange12w RadarHTTPSummaryOSParamsDateRange = "12w" - RadarHTTPSummaryOSParamsDateRange24w RadarHTTPSummaryOSParamsDateRange = "24w" - RadarHTTPSummaryOSParamsDateRange52w RadarHTTPSummaryOSParamsDateRange = "52w" - RadarHTTPSummaryOSParamsDateRange1dControl RadarHTTPSummaryOSParamsDateRange = "1dControl" - RadarHTTPSummaryOSParamsDateRange2dControl RadarHTTPSummaryOSParamsDateRange = "2dControl" - RadarHTTPSummaryOSParamsDateRange7dControl RadarHTTPSummaryOSParamsDateRange = "7dControl" - RadarHTTPSummaryOSParamsDateRange14dControl RadarHTTPSummaryOSParamsDateRange = "14dControl" - RadarHTTPSummaryOSParamsDateRange28dControl RadarHTTPSummaryOSParamsDateRange = "28dControl" - RadarHTTPSummaryOSParamsDateRange12wControl RadarHTTPSummaryOSParamsDateRange = "12wControl" - RadarHTTPSummaryOSParamsDateRange24wControl RadarHTTPSummaryOSParamsDateRange = "24wControl" -) - -type RadarHTTPSummaryOSParamsDeviceType string - -const ( - RadarHTTPSummaryOSParamsDeviceTypeDesktop RadarHTTPSummaryOSParamsDeviceType = "DESKTOP" - RadarHTTPSummaryOSParamsDeviceTypeMobile RadarHTTPSummaryOSParamsDeviceType = "MOBILE" - RadarHTTPSummaryOSParamsDeviceTypeOther RadarHTTPSummaryOSParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPSummaryOSParamsFormat string - -const ( - RadarHTTPSummaryOSParamsFormatJson RadarHTTPSummaryOSParamsFormat = "JSON" - RadarHTTPSummaryOSParamsFormatCsv RadarHTTPSummaryOSParamsFormat = "CSV" -) - -type RadarHTTPSummaryOSParamsHTTPProtocol string - -const ( - RadarHTTPSummaryOSParamsHTTPProtocolHTTP RadarHTTPSummaryOSParamsHTTPProtocol = "HTTP" - RadarHTTPSummaryOSParamsHTTPProtocolHTTPS RadarHTTPSummaryOSParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPSummaryOSParamsHTTPVersion string - -const ( - RadarHTTPSummaryOSParamsHTTPVersionHttPv1 RadarHTTPSummaryOSParamsHTTPVersion = "HTTPv1" - RadarHTTPSummaryOSParamsHTTPVersionHttPv2 RadarHTTPSummaryOSParamsHTTPVersion = "HTTPv2" - RadarHTTPSummaryOSParamsHTTPVersionHttPv3 RadarHTTPSummaryOSParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPSummaryOSParamsIPVersion string - -const ( - RadarHTTPSummaryOSParamsIPVersionIPv4 RadarHTTPSummaryOSParamsIPVersion = "IPv4" - RadarHTTPSummaryOSParamsIPVersionIPv6 RadarHTTPSummaryOSParamsIPVersion = "IPv6" -) - -type RadarHTTPSummaryOSParamsTLSVersion string - -const ( - RadarHTTPSummaryOSParamsTLSVersionTlSv1_0 RadarHTTPSummaryOSParamsTLSVersion = "TLSv1_0" - RadarHTTPSummaryOSParamsTLSVersionTlSv1_1 RadarHTTPSummaryOSParamsTLSVersion = "TLSv1_1" - RadarHTTPSummaryOSParamsTLSVersionTlSv1_2 RadarHTTPSummaryOSParamsTLSVersion = "TLSv1_2" - RadarHTTPSummaryOSParamsTLSVersionTlSv1_3 RadarHTTPSummaryOSParamsTLSVersion = "TLSv1_3" - RadarHTTPSummaryOSParamsTLSVersionTlSvQuic RadarHTTPSummaryOSParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPSummaryOSResponseEnvelope struct { - Result RadarHTTPSummaryOSResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPSummaryOSResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPSummaryOSResponseEnvelopeJSON contains the JSON metadata for the struct -// [RadarHTTPSummaryOSResponseEnvelope] -type radarHTTPSummaryOSResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryOSResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryOSResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPSummaryTLSVersionParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPSummaryTLSVersionParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPSummaryTLSVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPSummaryTLSVersionParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPSummaryTLSVersionParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPSummaryTLSVersionParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPSummaryTLSVersionParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPSummaryTLSVersionParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPSummaryTLSVersionParamsOS] `query:"os"` -} - -// URLQuery serializes [RadarHTTPSummaryTLSVersionParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPSummaryTLSVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarHTTPSummaryTLSVersionParamsBotClass string - -const ( - RadarHTTPSummaryTLSVersionParamsBotClassLikelyAutomated RadarHTTPSummaryTLSVersionParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPSummaryTLSVersionParamsBotClassLikelyHuman RadarHTTPSummaryTLSVersionParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPSummaryTLSVersionParamsDateRange string - -const ( - RadarHTTPSummaryTLSVersionParamsDateRange1d RadarHTTPSummaryTLSVersionParamsDateRange = "1d" - RadarHTTPSummaryTLSVersionParamsDateRange2d RadarHTTPSummaryTLSVersionParamsDateRange = "2d" - RadarHTTPSummaryTLSVersionParamsDateRange7d RadarHTTPSummaryTLSVersionParamsDateRange = "7d" - RadarHTTPSummaryTLSVersionParamsDateRange14d RadarHTTPSummaryTLSVersionParamsDateRange = "14d" - RadarHTTPSummaryTLSVersionParamsDateRange28d RadarHTTPSummaryTLSVersionParamsDateRange = "28d" - RadarHTTPSummaryTLSVersionParamsDateRange12w RadarHTTPSummaryTLSVersionParamsDateRange = "12w" - RadarHTTPSummaryTLSVersionParamsDateRange24w RadarHTTPSummaryTLSVersionParamsDateRange = "24w" - RadarHTTPSummaryTLSVersionParamsDateRange52w RadarHTTPSummaryTLSVersionParamsDateRange = "52w" - RadarHTTPSummaryTLSVersionParamsDateRange1dControl RadarHTTPSummaryTLSVersionParamsDateRange = "1dControl" - RadarHTTPSummaryTLSVersionParamsDateRange2dControl RadarHTTPSummaryTLSVersionParamsDateRange = "2dControl" - RadarHTTPSummaryTLSVersionParamsDateRange7dControl RadarHTTPSummaryTLSVersionParamsDateRange = "7dControl" - RadarHTTPSummaryTLSVersionParamsDateRange14dControl RadarHTTPSummaryTLSVersionParamsDateRange = "14dControl" - RadarHTTPSummaryTLSVersionParamsDateRange28dControl RadarHTTPSummaryTLSVersionParamsDateRange = "28dControl" - RadarHTTPSummaryTLSVersionParamsDateRange12wControl RadarHTTPSummaryTLSVersionParamsDateRange = "12wControl" - RadarHTTPSummaryTLSVersionParamsDateRange24wControl RadarHTTPSummaryTLSVersionParamsDateRange = "24wControl" -) - -type RadarHTTPSummaryTLSVersionParamsDeviceType string - -const ( - RadarHTTPSummaryTLSVersionParamsDeviceTypeDesktop RadarHTTPSummaryTLSVersionParamsDeviceType = "DESKTOP" - RadarHTTPSummaryTLSVersionParamsDeviceTypeMobile RadarHTTPSummaryTLSVersionParamsDeviceType = "MOBILE" - RadarHTTPSummaryTLSVersionParamsDeviceTypeOther RadarHTTPSummaryTLSVersionParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPSummaryTLSVersionParamsFormat string - -const ( - RadarHTTPSummaryTLSVersionParamsFormatJson RadarHTTPSummaryTLSVersionParamsFormat = "JSON" - RadarHTTPSummaryTLSVersionParamsFormatCsv RadarHTTPSummaryTLSVersionParamsFormat = "CSV" -) - -type RadarHTTPSummaryTLSVersionParamsHTTPProtocol string - -const ( - RadarHTTPSummaryTLSVersionParamsHTTPProtocolHTTP RadarHTTPSummaryTLSVersionParamsHTTPProtocol = "HTTP" - RadarHTTPSummaryTLSVersionParamsHTTPProtocolHTTPS RadarHTTPSummaryTLSVersionParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPSummaryTLSVersionParamsHTTPVersion string - -const ( - RadarHTTPSummaryTLSVersionParamsHTTPVersionHttPv1 RadarHTTPSummaryTLSVersionParamsHTTPVersion = "HTTPv1" - RadarHTTPSummaryTLSVersionParamsHTTPVersionHttPv2 RadarHTTPSummaryTLSVersionParamsHTTPVersion = "HTTPv2" - RadarHTTPSummaryTLSVersionParamsHTTPVersionHttPv3 RadarHTTPSummaryTLSVersionParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPSummaryTLSVersionParamsIPVersion string - -const ( - RadarHTTPSummaryTLSVersionParamsIPVersionIPv4 RadarHTTPSummaryTLSVersionParamsIPVersion = "IPv4" - RadarHTTPSummaryTLSVersionParamsIPVersionIPv6 RadarHTTPSummaryTLSVersionParamsIPVersion = "IPv6" -) - -type RadarHTTPSummaryTLSVersionParamsOS string - -const ( - RadarHTTPSummaryTLSVersionParamsOSWindows RadarHTTPSummaryTLSVersionParamsOS = "WINDOWS" - RadarHTTPSummaryTLSVersionParamsOSMacosx RadarHTTPSummaryTLSVersionParamsOS = "MACOSX" - RadarHTTPSummaryTLSVersionParamsOSIos RadarHTTPSummaryTLSVersionParamsOS = "IOS" - RadarHTTPSummaryTLSVersionParamsOSAndroid RadarHTTPSummaryTLSVersionParamsOS = "ANDROID" - RadarHTTPSummaryTLSVersionParamsOSChromeos RadarHTTPSummaryTLSVersionParamsOS = "CHROMEOS" - RadarHTTPSummaryTLSVersionParamsOSLinux RadarHTTPSummaryTLSVersionParamsOS = "LINUX" - RadarHTTPSummaryTLSVersionParamsOSSmartTv RadarHTTPSummaryTLSVersionParamsOS = "SMART_TV" -) - -type RadarHTTPSummaryTLSVersionResponseEnvelope struct { - Result RadarHTTPSummaryTLSVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPSummaryTLSVersionResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPSummaryTLSVersionResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarHTTPSummaryTLSVersionResponseEnvelope] -type radarHTTPSummaryTLSVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPSummaryTLSVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPSummaryTLSVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttpsummary_test.go b/radarhttpsummary_test.go deleted file mode 100644 index 9e288dcbd4d..00000000000 --- a/radarhttpsummary_test.go +++ /dev/null @@ -1,288 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPSummaryBotClassWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Summary.BotClass(context.TODO(), cloudflare.RadarHTTPSummaryBotClassParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPSummaryBotClassParamsDateRange{cloudflare.RadarHTTPSummaryBotClassParamsDateRange1d, cloudflare.RadarHTTPSummaryBotClassParamsDateRange2d, cloudflare.RadarHTTPSummaryBotClassParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPSummaryBotClassParamsDeviceType{cloudflare.RadarHTTPSummaryBotClassParamsDeviceTypeDesktop, cloudflare.RadarHTTPSummaryBotClassParamsDeviceTypeMobile, cloudflare.RadarHTTPSummaryBotClassParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPSummaryBotClassParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPSummaryBotClassParamsHTTPProtocol{cloudflare.RadarHTTPSummaryBotClassParamsHTTPProtocolHTTP, cloudflare.RadarHTTPSummaryBotClassParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPSummaryBotClassParamsHTTPVersion{cloudflare.RadarHTTPSummaryBotClassParamsHTTPVersionHttPv1, cloudflare.RadarHTTPSummaryBotClassParamsHTTPVersionHttPv2, cloudflare.RadarHTTPSummaryBotClassParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPSummaryBotClassParamsIPVersion{cloudflare.RadarHTTPSummaryBotClassParamsIPVersionIPv4, cloudflare.RadarHTTPSummaryBotClassParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPSummaryBotClassParamsOS{cloudflare.RadarHTTPSummaryBotClassParamsOSWindows, cloudflare.RadarHTTPSummaryBotClassParamsOSMacosx, cloudflare.RadarHTTPSummaryBotClassParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPSummaryBotClassParamsTLSVersion{cloudflare.RadarHTTPSummaryBotClassParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPSummaryBotClassParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPSummaryBotClassParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarHTTPSummaryDeviceTypeWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Summary.DeviceType(context.TODO(), cloudflare.RadarHTTPSummaryDeviceTypeParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPSummaryDeviceTypeParamsBotClass{cloudflare.RadarHTTPSummaryDeviceTypeParamsBotClassLikelyAutomated, cloudflare.RadarHTTPSummaryDeviceTypeParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPSummaryDeviceTypeParamsDateRange{cloudflare.RadarHTTPSummaryDeviceTypeParamsDateRange1d, cloudflare.RadarHTTPSummaryDeviceTypeParamsDateRange2d, cloudflare.RadarHTTPSummaryDeviceTypeParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarHTTPSummaryDeviceTypeParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPSummaryDeviceTypeParamsHTTPProtocol{cloudflare.RadarHTTPSummaryDeviceTypeParamsHTTPProtocolHTTP, cloudflare.RadarHTTPSummaryDeviceTypeParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPSummaryDeviceTypeParamsHTTPVersion{cloudflare.RadarHTTPSummaryDeviceTypeParamsHTTPVersionHttPv1, cloudflare.RadarHTTPSummaryDeviceTypeParamsHTTPVersionHttPv2, cloudflare.RadarHTTPSummaryDeviceTypeParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPSummaryDeviceTypeParamsIPVersion{cloudflare.RadarHTTPSummaryDeviceTypeParamsIPVersionIPv4, cloudflare.RadarHTTPSummaryDeviceTypeParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPSummaryDeviceTypeParamsOS{cloudflare.RadarHTTPSummaryDeviceTypeParamsOSWindows, cloudflare.RadarHTTPSummaryDeviceTypeParamsOSMacosx, cloudflare.RadarHTTPSummaryDeviceTypeParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPSummaryDeviceTypeParamsTLSVersion{cloudflare.RadarHTTPSummaryDeviceTypeParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPSummaryDeviceTypeParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPSummaryDeviceTypeParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarHTTPSummaryHTTPProtocolWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Summary.HTTPProtocol(context.TODO(), cloudflare.RadarHTTPSummaryHTTPProtocolParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPSummaryHTTPProtocolParamsBotClass{cloudflare.RadarHTTPSummaryHTTPProtocolParamsBotClassLikelyAutomated, cloudflare.RadarHTTPSummaryHTTPProtocolParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPSummaryHTTPProtocolParamsDateRange{cloudflare.RadarHTTPSummaryHTTPProtocolParamsDateRange1d, cloudflare.RadarHTTPSummaryHTTPProtocolParamsDateRange2d, cloudflare.RadarHTTPSummaryHTTPProtocolParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPSummaryHTTPProtocolParamsDeviceType{cloudflare.RadarHTTPSummaryHTTPProtocolParamsDeviceTypeDesktop, cloudflare.RadarHTTPSummaryHTTPProtocolParamsDeviceTypeMobile, cloudflare.RadarHTTPSummaryHTTPProtocolParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPSummaryHTTPProtocolParamsFormatJson), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPSummaryHTTPProtocolParamsHTTPVersion{cloudflare.RadarHTTPSummaryHTTPProtocolParamsHTTPVersionHttPv1, cloudflare.RadarHTTPSummaryHTTPProtocolParamsHTTPVersionHttPv2, cloudflare.RadarHTTPSummaryHTTPProtocolParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPSummaryHTTPProtocolParamsIPVersion{cloudflare.RadarHTTPSummaryHTTPProtocolParamsIPVersionIPv4, cloudflare.RadarHTTPSummaryHTTPProtocolParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPSummaryHTTPProtocolParamsOS{cloudflare.RadarHTTPSummaryHTTPProtocolParamsOSWindows, cloudflare.RadarHTTPSummaryHTTPProtocolParamsOSMacosx, cloudflare.RadarHTTPSummaryHTTPProtocolParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPSummaryHTTPProtocolParamsTLSVersion{cloudflare.RadarHTTPSummaryHTTPProtocolParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPSummaryHTTPProtocolParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPSummaryHTTPProtocolParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarHTTPSummaryHTTPVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Summary.HTTPVersion(context.TODO(), cloudflare.RadarHTTPSummaryHTTPVersionParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPSummaryHTTPVersionParamsBotClass{cloudflare.RadarHTTPSummaryHTTPVersionParamsBotClassLikelyAutomated, cloudflare.RadarHTTPSummaryHTTPVersionParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPSummaryHTTPVersionParamsDateRange{cloudflare.RadarHTTPSummaryHTTPVersionParamsDateRange1d, cloudflare.RadarHTTPSummaryHTTPVersionParamsDateRange2d, cloudflare.RadarHTTPSummaryHTTPVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPSummaryHTTPVersionParamsDeviceType{cloudflare.RadarHTTPSummaryHTTPVersionParamsDeviceTypeDesktop, cloudflare.RadarHTTPSummaryHTTPVersionParamsDeviceTypeMobile, cloudflare.RadarHTTPSummaryHTTPVersionParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPSummaryHTTPVersionParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPSummaryHTTPVersionParamsHTTPProtocol{cloudflare.RadarHTTPSummaryHTTPVersionParamsHTTPProtocolHTTP, cloudflare.RadarHTTPSummaryHTTPVersionParamsHTTPProtocolHTTPS}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPSummaryHTTPVersionParamsIPVersion{cloudflare.RadarHTTPSummaryHTTPVersionParamsIPVersionIPv4, cloudflare.RadarHTTPSummaryHTTPVersionParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPSummaryHTTPVersionParamsOS{cloudflare.RadarHTTPSummaryHTTPVersionParamsOSWindows, cloudflare.RadarHTTPSummaryHTTPVersionParamsOSMacosx, cloudflare.RadarHTTPSummaryHTTPVersionParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPSummaryHTTPVersionParamsTLSVersion{cloudflare.RadarHTTPSummaryHTTPVersionParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPSummaryHTTPVersionParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPSummaryHTTPVersionParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarHTTPSummaryIPVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Summary.IPVersion(context.TODO(), cloudflare.RadarHTTPSummaryIPVersionParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPSummaryIPVersionParamsBotClass{cloudflare.RadarHTTPSummaryIPVersionParamsBotClassLikelyAutomated, cloudflare.RadarHTTPSummaryIPVersionParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPSummaryIPVersionParamsDateRange{cloudflare.RadarHTTPSummaryIPVersionParamsDateRange1d, cloudflare.RadarHTTPSummaryIPVersionParamsDateRange2d, cloudflare.RadarHTTPSummaryIPVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPSummaryIPVersionParamsDeviceType{cloudflare.RadarHTTPSummaryIPVersionParamsDeviceTypeDesktop, cloudflare.RadarHTTPSummaryIPVersionParamsDeviceTypeMobile, cloudflare.RadarHTTPSummaryIPVersionParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPSummaryIPVersionParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPSummaryIPVersionParamsHTTPProtocol{cloudflare.RadarHTTPSummaryIPVersionParamsHTTPProtocolHTTP, cloudflare.RadarHTTPSummaryIPVersionParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPSummaryIPVersionParamsHTTPVersion{cloudflare.RadarHTTPSummaryIPVersionParamsHTTPVersionHttPv1, cloudflare.RadarHTTPSummaryIPVersionParamsHTTPVersionHttPv2, cloudflare.RadarHTTPSummaryIPVersionParamsHTTPVersionHttPv3}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPSummaryIPVersionParamsOS{cloudflare.RadarHTTPSummaryIPVersionParamsOSWindows, cloudflare.RadarHTTPSummaryIPVersionParamsOSMacosx, cloudflare.RadarHTTPSummaryIPVersionParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPSummaryIPVersionParamsTLSVersion{cloudflare.RadarHTTPSummaryIPVersionParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPSummaryIPVersionParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPSummaryIPVersionParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarHTTPSummaryOSWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Summary.OS(context.TODO(), cloudflare.RadarHTTPSummaryOSParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPSummaryOSParamsBotClass{cloudflare.RadarHTTPSummaryOSParamsBotClassLikelyAutomated, cloudflare.RadarHTTPSummaryOSParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPSummaryOSParamsDateRange{cloudflare.RadarHTTPSummaryOSParamsDateRange1d, cloudflare.RadarHTTPSummaryOSParamsDateRange2d, cloudflare.RadarHTTPSummaryOSParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPSummaryOSParamsDeviceType{cloudflare.RadarHTTPSummaryOSParamsDeviceTypeDesktop, cloudflare.RadarHTTPSummaryOSParamsDeviceTypeMobile, cloudflare.RadarHTTPSummaryOSParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPSummaryOSParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPSummaryOSParamsHTTPProtocol{cloudflare.RadarHTTPSummaryOSParamsHTTPProtocolHTTP, cloudflare.RadarHTTPSummaryOSParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPSummaryOSParamsHTTPVersion{cloudflare.RadarHTTPSummaryOSParamsHTTPVersionHttPv1, cloudflare.RadarHTTPSummaryOSParamsHTTPVersionHttPv2, cloudflare.RadarHTTPSummaryOSParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPSummaryOSParamsIPVersion{cloudflare.RadarHTTPSummaryOSParamsIPVersionIPv4, cloudflare.RadarHTTPSummaryOSParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPSummaryOSParamsTLSVersion{cloudflare.RadarHTTPSummaryOSParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPSummaryOSParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPSummaryOSParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarHTTPSummaryTLSVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Summary.TLSVersion(context.TODO(), cloudflare.RadarHTTPSummaryTLSVersionParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPSummaryTLSVersionParamsBotClass{cloudflare.RadarHTTPSummaryTLSVersionParamsBotClassLikelyAutomated, cloudflare.RadarHTTPSummaryTLSVersionParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPSummaryTLSVersionParamsDateRange{cloudflare.RadarHTTPSummaryTLSVersionParamsDateRange1d, cloudflare.RadarHTTPSummaryTLSVersionParamsDateRange2d, cloudflare.RadarHTTPSummaryTLSVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPSummaryTLSVersionParamsDeviceType{cloudflare.RadarHTTPSummaryTLSVersionParamsDeviceTypeDesktop, cloudflare.RadarHTTPSummaryTLSVersionParamsDeviceTypeMobile, cloudflare.RadarHTTPSummaryTLSVersionParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPSummaryTLSVersionParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPSummaryTLSVersionParamsHTTPProtocol{cloudflare.RadarHTTPSummaryTLSVersionParamsHTTPProtocolHTTP, cloudflare.RadarHTTPSummaryTLSVersionParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPSummaryTLSVersionParamsHTTPVersion{cloudflare.RadarHTTPSummaryTLSVersionParamsHTTPVersionHttPv1, cloudflare.RadarHTTPSummaryTLSVersionParamsHTTPVersionHttPv2, cloudflare.RadarHTTPSummaryTLSVersionParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPSummaryTLSVersionParamsIPVersion{cloudflare.RadarHTTPSummaryTLSVersionParamsIPVersionIPv4, cloudflare.RadarHTTPSummaryTLSVersionParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPSummaryTLSVersionParamsOS{cloudflare.RadarHTTPSummaryTLSVersionParamsOSWindows, cloudflare.RadarHTTPSummaryTLSVersionParamsOSMacosx, cloudflare.RadarHTTPSummaryTLSVersionParamsOSIos}), - }) - 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/radarhttptimeseriesgroup.go b/radarhttptimeseriesgroup.go deleted file mode 100644 index 6c3645d23d2..00000000000 --- a/radarhttptimeseriesgroup.go +++ /dev/null @@ -1,2115 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPTimeseriesGroupService 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 -// [NewRadarHTTPTimeseriesGroupService] method instead. -type RadarHTTPTimeseriesGroupService struct { - Options []option.RequestOption -} - -// NewRadarHTTPTimeseriesGroupService 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 NewRadarHTTPTimeseriesGroupService(opts ...option.RequestOption) (r *RadarHTTPTimeseriesGroupService) { - r = &RadarHTTPTimeseriesGroupService{} - r.Options = opts - return -} - -// Get a time series of the percentage distribution of traffic classified as -// automated or human. Visit -// https://developers.cloudflare.com/radar/concepts/bot-classes/ for more -// information. -func (r *RadarHTTPTimeseriesGroupService) BotClass(ctx context.Context, query RadarHTTPTimeseriesGroupBotClassParams, opts ...option.RequestOption) (res *RadarHTTPTimeseriesGroupBotClassResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPTimeseriesGroupBotClassResponseEnvelope - path := "radar/http/timeseries_groups/bot_class" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a time series of the percentage distribution of traffic of the top user -// agents. -func (r *RadarHTTPTimeseriesGroupService) Browser(ctx context.Context, query RadarHTTPTimeseriesGroupBrowserParams, opts ...option.RequestOption) (res *RadarHTTPTimeseriesGroupBrowserResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPTimeseriesGroupBrowserResponseEnvelope - path := "radar/http/timeseries_groups/browser" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a time series of the percentage distribution of traffic of the top user -// agents aggregated in families. -func (r *RadarHTTPTimeseriesGroupService) BrowserFamily(ctx context.Context, query RadarHTTPTimeseriesGroupBrowserFamilyParams, opts ...option.RequestOption) (res *RadarHTTPTimeseriesGroupBrowserFamilyResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPTimeseriesGroupBrowserFamilyResponseEnvelope - path := "radar/http/timeseries_groups/browser_family" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a time series of the percentage distribution of traffic per device type. -func (r *RadarHTTPTimeseriesGroupService) DeviceType(ctx context.Context, query RadarHTTPTimeseriesGroupDeviceTypeParams, opts ...option.RequestOption) (res *RadarHTTPTimeseriesGroupDeviceTypeResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPTimeseriesGroupDeviceTypeResponseEnvelope - path := "radar/http/timeseries_groups/device_type" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a time series of the percentage distribution of traffic per HTTP protocol. -func (r *RadarHTTPTimeseriesGroupService) HTTPProtocol(ctx context.Context, query RadarHTTPTimeseriesGroupHTTPProtocolParams, opts ...option.RequestOption) (res *RadarHTTPTimeseriesGroupHTTPProtocolResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPTimeseriesGroupHTTPProtocolResponseEnvelope - path := "radar/http/timeseries_groups/http_protocol" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a time series of the percentage distribution of traffic per HTTP protocol -// version. -func (r *RadarHTTPTimeseriesGroupService) HTTPVersion(ctx context.Context, query RadarHTTPTimeseriesGroupHTTPVersionParams, opts ...option.RequestOption) (res *RadarHTTPTimeseriesGroupHTTPVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPTimeseriesGroupHTTPVersionResponseEnvelope - path := "radar/http/timeseries_groups/http_version" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a time series of the percentage distribution of traffic per IP protocol -// version. -func (r *RadarHTTPTimeseriesGroupService) IPVersion(ctx context.Context, query RadarHTTPTimeseriesGroupIPVersionParams, opts ...option.RequestOption) (res *RadarHTTPTimeseriesGroupIPVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPTimeseriesGroupIPVersionResponseEnvelope - path := "radar/http/timeseries_groups/ip_version" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a time series of the percentage distribution of traffic of the top operating -// systems. -func (r *RadarHTTPTimeseriesGroupService) OS(ctx context.Context, query RadarHTTPTimeseriesGroupOSParams, opts ...option.RequestOption) (res *RadarHTTPTimeseriesGroupOSResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPTimeseriesGroupOSResponseEnvelope - path := "radar/http/timeseries_groups/os" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a time series of the percentage distribution of traffic per TLS protocol -// version. -func (r *RadarHTTPTimeseriesGroupService) TLSVersion(ctx context.Context, query RadarHTTPTimeseriesGroupTLSVersionParams, opts ...option.RequestOption) (res *RadarHTTPTimeseriesGroupTLSVersionResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPTimeseriesGroupTLSVersionResponseEnvelope - path := "radar/http/timeseries_groups/tls_version" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPTimeseriesGroupBotClassResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarHTTPTimeseriesGroupBotClassResponseSerie0 `json:"serie_0,required"` - JSON radarHTTPTimeseriesGroupBotClassResponseJSON `json:"-"` -} - -// radarHTTPTimeseriesGroupBotClassResponseJSON contains the JSON metadata for the -// struct [RadarHTTPTimeseriesGroupBotClassResponse] -type radarHTTPTimeseriesGroupBotClassResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupBotClassResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupBotClassResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupBotClassResponseSerie0 struct { - Bot []string `json:"bot,required"` - Human []string `json:"human,required"` - Timestamps []string `json:"timestamps,required"` - JSON radarHTTPTimeseriesGroupBotClassResponseSerie0JSON `json:"-"` -} - -// radarHTTPTimeseriesGroupBotClassResponseSerie0JSON contains the JSON metadata -// for the struct [RadarHTTPTimeseriesGroupBotClassResponseSerie0] -type radarHTTPTimeseriesGroupBotClassResponseSerie0JSON struct { - Bot apijson.Field - Human apijson.Field - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupBotClassResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupBotClassResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupBrowserResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarHTTPTimeseriesGroupBrowserResponseSerie0 `json:"serie_0,required"` - JSON radarHTTPTimeseriesGroupBrowserResponseJSON `json:"-"` -} - -// radarHTTPTimeseriesGroupBrowserResponseJSON contains the JSON metadata for the -// struct [RadarHTTPTimeseriesGroupBrowserResponse] -type radarHTTPTimeseriesGroupBrowserResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupBrowserResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupBrowserResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupBrowserResponseSerie0 struct { - Timestamps []string `json:"timestamps,required"` - ExtraFields map[string][]string `json:"-,extras"` - JSON radarHTTPTimeseriesGroupBrowserResponseSerie0JSON `json:"-"` -} - -// radarHTTPTimeseriesGroupBrowserResponseSerie0JSON contains the JSON metadata for -// the struct [RadarHTTPTimeseriesGroupBrowserResponseSerie0] -type radarHTTPTimeseriesGroupBrowserResponseSerie0JSON struct { - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupBrowserResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupBrowserResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupBrowserFamilyResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarHTTPTimeseriesGroupBrowserFamilyResponseSerie0 `json:"serie_0,required"` - JSON radarHTTPTimeseriesGroupBrowserFamilyResponseJSON `json:"-"` -} - -// radarHTTPTimeseriesGroupBrowserFamilyResponseJSON contains the JSON metadata for -// the struct [RadarHTTPTimeseriesGroupBrowserFamilyResponse] -type radarHTTPTimeseriesGroupBrowserFamilyResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupBrowserFamilyResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupBrowserFamilyResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupBrowserFamilyResponseSerie0 struct { - Timestamps []string `json:"timestamps,required"` - ExtraFields map[string][]string `json:"-,extras"` - JSON radarHTTPTimeseriesGroupBrowserFamilyResponseSerie0JSON `json:"-"` -} - -// radarHTTPTimeseriesGroupBrowserFamilyResponseSerie0JSON contains the JSON -// metadata for the struct [RadarHTTPTimeseriesGroupBrowserFamilyResponseSerie0] -type radarHTTPTimeseriesGroupBrowserFamilyResponseSerie0JSON struct { - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupBrowserFamilyResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupBrowserFamilyResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupDeviceTypeResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarHTTPTimeseriesGroupDeviceTypeResponseSerie0 `json:"serie_0,required"` - JSON radarHTTPTimeseriesGroupDeviceTypeResponseJSON `json:"-"` -} - -// radarHTTPTimeseriesGroupDeviceTypeResponseJSON contains the JSON metadata for -// the struct [RadarHTTPTimeseriesGroupDeviceTypeResponse] -type radarHTTPTimeseriesGroupDeviceTypeResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupDeviceTypeResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupDeviceTypeResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupDeviceTypeResponseSerie0 struct { - Desktop []string `json:"desktop,required"` - Mobile []string `json:"mobile,required"` - Other []string `json:"other,required"` - Timestamps []string `json:"timestamps,required"` - JSON radarHTTPTimeseriesGroupDeviceTypeResponseSerie0JSON `json:"-"` -} - -// radarHTTPTimeseriesGroupDeviceTypeResponseSerie0JSON contains the JSON metadata -// for the struct [RadarHTTPTimeseriesGroupDeviceTypeResponseSerie0] -type radarHTTPTimeseriesGroupDeviceTypeResponseSerie0JSON struct { - Desktop apijson.Field - Mobile apijson.Field - Other apijson.Field - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupDeviceTypeResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupDeviceTypeResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupHTTPProtocolResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarHTTPTimeseriesGroupHTTPProtocolResponseSerie0 `json:"serie_0,required"` - JSON radarHTTPTimeseriesGroupHTTPProtocolResponseJSON `json:"-"` -} - -// radarHTTPTimeseriesGroupHTTPProtocolResponseJSON contains the JSON metadata for -// the struct [RadarHTTPTimeseriesGroupHTTPProtocolResponse] -type radarHTTPTimeseriesGroupHTTPProtocolResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupHTTPProtocolResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupHTTPProtocolResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupHTTPProtocolResponseSerie0 struct { - HTTP []string `json:"http,required"` - HTTPS []string `json:"https,required"` - Timestamps []string `json:"timestamps,required"` - JSON radarHTTPTimeseriesGroupHTTPProtocolResponseSerie0JSON `json:"-"` -} - -// radarHTTPTimeseriesGroupHTTPProtocolResponseSerie0JSON contains the JSON -// metadata for the struct [RadarHTTPTimeseriesGroupHTTPProtocolResponseSerie0] -type radarHTTPTimeseriesGroupHTTPProtocolResponseSerie0JSON struct { - HTTP apijson.Field - HTTPS apijson.Field - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupHTTPProtocolResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupHTTPProtocolResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupHTTPVersionResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarHTTPTimeseriesGroupHTTPVersionResponseSerie0 `json:"serie_0,required"` - JSON radarHTTPTimeseriesGroupHTTPVersionResponseJSON `json:"-"` -} - -// radarHTTPTimeseriesGroupHTTPVersionResponseJSON contains the JSON metadata for -// the struct [RadarHTTPTimeseriesGroupHTTPVersionResponse] -type radarHTTPTimeseriesGroupHTTPVersionResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupHTTPVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupHTTPVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupHTTPVersionResponseSerie0 struct { - HTTP1X []string `json:"HTTP/1.x,required"` - HTTP2 []string `json:"HTTP/2,required"` - HTTP3 []string `json:"HTTP/3,required"` - Timestamps []string `json:"timestamps,required"` - JSON radarHTTPTimeseriesGroupHTTPVersionResponseSerie0JSON `json:"-"` -} - -// radarHTTPTimeseriesGroupHTTPVersionResponseSerie0JSON contains the JSON metadata -// for the struct [RadarHTTPTimeseriesGroupHTTPVersionResponseSerie0] -type radarHTTPTimeseriesGroupHTTPVersionResponseSerie0JSON struct { - HTTP1X apijson.Field - HTTP2 apijson.Field - HTTP3 apijson.Field - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupHTTPVersionResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupHTTPVersionResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupIPVersionResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarHTTPTimeseriesGroupIPVersionResponseSerie0 `json:"serie_0,required"` - JSON radarHTTPTimeseriesGroupIPVersionResponseJSON `json:"-"` -} - -// radarHTTPTimeseriesGroupIPVersionResponseJSON contains the JSON metadata for the -// struct [RadarHTTPTimeseriesGroupIPVersionResponse] -type radarHTTPTimeseriesGroupIPVersionResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupIPVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupIPVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupIPVersionResponseSerie0 struct { - IPv4 []string `json:"IPv4,required"` - IPv6 []string `json:"IPv6,required"` - Timestamps []string `json:"timestamps,required"` - JSON radarHTTPTimeseriesGroupIPVersionResponseSerie0JSON `json:"-"` -} - -// radarHTTPTimeseriesGroupIPVersionResponseSerie0JSON contains the JSON metadata -// for the struct [RadarHTTPTimeseriesGroupIPVersionResponseSerie0] -type radarHTTPTimeseriesGroupIPVersionResponseSerie0JSON struct { - IPv4 apijson.Field - IPv6 apijson.Field - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupIPVersionResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupIPVersionResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupOSResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarHTTPTimeseriesGroupOSResponseSerie0 `json:"serie_0,required"` - JSON radarHTTPTimeseriesGroupOSResponseJSON `json:"-"` -} - -// radarHTTPTimeseriesGroupOSResponseJSON contains the JSON metadata for the struct -// [RadarHTTPTimeseriesGroupOSResponse] -type radarHTTPTimeseriesGroupOSResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupOSResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupOSResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupOSResponseSerie0 struct { - Timestamps []string `json:"timestamps,required"` - ExtraFields map[string][]string `json:"-,extras"` - JSON radarHTTPTimeseriesGroupOSResponseSerie0JSON `json:"-"` -} - -// radarHTTPTimeseriesGroupOSResponseSerie0JSON contains the JSON metadata for the -// struct [RadarHTTPTimeseriesGroupOSResponseSerie0] -type radarHTTPTimeseriesGroupOSResponseSerie0JSON struct { - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupOSResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupOSResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupTLSVersionResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarHTTPTimeseriesGroupTLSVersionResponseSerie0 `json:"serie_0,required"` - JSON radarHTTPTimeseriesGroupTLSVersionResponseJSON `json:"-"` -} - -// radarHTTPTimeseriesGroupTLSVersionResponseJSON contains the JSON metadata for -// the struct [RadarHTTPTimeseriesGroupTLSVersionResponse] -type radarHTTPTimeseriesGroupTLSVersionResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupTLSVersionResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupTLSVersionResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupTLSVersionResponseSerie0 struct { - Timestamps []string `json:"timestamps,required"` - TLS1_0 []string `json:"TLS 1.0,required"` - TLS1_1 []string `json:"TLS 1.1,required"` - TLS1_2 []string `json:"TLS 1.2,required"` - TLS1_3 []string `json:"TLS 1.3,required"` - TLSQuic []string `json:"TLS QUIC,required"` - JSON radarHTTPTimeseriesGroupTLSVersionResponseSerie0JSON `json:"-"` -} - -// radarHTTPTimeseriesGroupTLSVersionResponseSerie0JSON contains the JSON metadata -// for the struct [RadarHTTPTimeseriesGroupTLSVersionResponseSerie0] -type radarHTTPTimeseriesGroupTLSVersionResponseSerie0JSON struct { - Timestamps apijson.Field - TLS1_0 apijson.Field - TLS1_1 apijson.Field - TLS1_2 apijson.Field - TLS1_3 apijson.Field - TLSQuic apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupTLSVersionResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupTLSVersionResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupBotClassParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarHTTPTimeseriesGroupBotClassParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPTimeseriesGroupBotClassParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPTimeseriesGroupBotClassParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPTimeseriesGroupBotClassParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPTimeseriesGroupBotClassParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPTimeseriesGroupBotClassParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPTimeseriesGroupBotClassParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPTimeseriesGroupBotClassParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPTimeseriesGroupBotClassParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPTimeseriesGroupBotClassParams]'s query parameters -// as `url.Values`. -func (r RadarHTTPTimeseriesGroupBotClassParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarHTTPTimeseriesGroupBotClassParamsAggInterval string - -const ( - RadarHTTPTimeseriesGroupBotClassParamsAggInterval15m RadarHTTPTimeseriesGroupBotClassParamsAggInterval = "15m" - RadarHTTPTimeseriesGroupBotClassParamsAggInterval1h RadarHTTPTimeseriesGroupBotClassParamsAggInterval = "1h" - RadarHTTPTimeseriesGroupBotClassParamsAggInterval1d RadarHTTPTimeseriesGroupBotClassParamsAggInterval = "1d" - RadarHTTPTimeseriesGroupBotClassParamsAggInterval1w RadarHTTPTimeseriesGroupBotClassParamsAggInterval = "1w" -) - -type RadarHTTPTimeseriesGroupBotClassParamsDateRange string - -const ( - RadarHTTPTimeseriesGroupBotClassParamsDateRange1d RadarHTTPTimeseriesGroupBotClassParamsDateRange = "1d" - RadarHTTPTimeseriesGroupBotClassParamsDateRange2d RadarHTTPTimeseriesGroupBotClassParamsDateRange = "2d" - RadarHTTPTimeseriesGroupBotClassParamsDateRange7d RadarHTTPTimeseriesGroupBotClassParamsDateRange = "7d" - RadarHTTPTimeseriesGroupBotClassParamsDateRange14d RadarHTTPTimeseriesGroupBotClassParamsDateRange = "14d" - RadarHTTPTimeseriesGroupBotClassParamsDateRange28d RadarHTTPTimeseriesGroupBotClassParamsDateRange = "28d" - RadarHTTPTimeseriesGroupBotClassParamsDateRange12w RadarHTTPTimeseriesGroupBotClassParamsDateRange = "12w" - RadarHTTPTimeseriesGroupBotClassParamsDateRange24w RadarHTTPTimeseriesGroupBotClassParamsDateRange = "24w" - RadarHTTPTimeseriesGroupBotClassParamsDateRange52w RadarHTTPTimeseriesGroupBotClassParamsDateRange = "52w" - RadarHTTPTimeseriesGroupBotClassParamsDateRange1dControl RadarHTTPTimeseriesGroupBotClassParamsDateRange = "1dControl" - RadarHTTPTimeseriesGroupBotClassParamsDateRange2dControl RadarHTTPTimeseriesGroupBotClassParamsDateRange = "2dControl" - RadarHTTPTimeseriesGroupBotClassParamsDateRange7dControl RadarHTTPTimeseriesGroupBotClassParamsDateRange = "7dControl" - RadarHTTPTimeseriesGroupBotClassParamsDateRange14dControl RadarHTTPTimeseriesGroupBotClassParamsDateRange = "14dControl" - RadarHTTPTimeseriesGroupBotClassParamsDateRange28dControl RadarHTTPTimeseriesGroupBotClassParamsDateRange = "28dControl" - RadarHTTPTimeseriesGroupBotClassParamsDateRange12wControl RadarHTTPTimeseriesGroupBotClassParamsDateRange = "12wControl" - RadarHTTPTimeseriesGroupBotClassParamsDateRange24wControl RadarHTTPTimeseriesGroupBotClassParamsDateRange = "24wControl" -) - -type RadarHTTPTimeseriesGroupBotClassParamsDeviceType string - -const ( - RadarHTTPTimeseriesGroupBotClassParamsDeviceTypeDesktop RadarHTTPTimeseriesGroupBotClassParamsDeviceType = "DESKTOP" - RadarHTTPTimeseriesGroupBotClassParamsDeviceTypeMobile RadarHTTPTimeseriesGroupBotClassParamsDeviceType = "MOBILE" - RadarHTTPTimeseriesGroupBotClassParamsDeviceTypeOther RadarHTTPTimeseriesGroupBotClassParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPTimeseriesGroupBotClassParamsFormat string - -const ( - RadarHTTPTimeseriesGroupBotClassParamsFormatJson RadarHTTPTimeseriesGroupBotClassParamsFormat = "JSON" - RadarHTTPTimeseriesGroupBotClassParamsFormatCsv RadarHTTPTimeseriesGroupBotClassParamsFormat = "CSV" -) - -type RadarHTTPTimeseriesGroupBotClassParamsHTTPProtocol string - -const ( - RadarHTTPTimeseriesGroupBotClassParamsHTTPProtocolHTTP RadarHTTPTimeseriesGroupBotClassParamsHTTPProtocol = "HTTP" - RadarHTTPTimeseriesGroupBotClassParamsHTTPProtocolHTTPS RadarHTTPTimeseriesGroupBotClassParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPTimeseriesGroupBotClassParamsHTTPVersion string - -const ( - RadarHTTPTimeseriesGroupBotClassParamsHTTPVersionHttPv1 RadarHTTPTimeseriesGroupBotClassParamsHTTPVersion = "HTTPv1" - RadarHTTPTimeseriesGroupBotClassParamsHTTPVersionHttPv2 RadarHTTPTimeseriesGroupBotClassParamsHTTPVersion = "HTTPv2" - RadarHTTPTimeseriesGroupBotClassParamsHTTPVersionHttPv3 RadarHTTPTimeseriesGroupBotClassParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPTimeseriesGroupBotClassParamsIPVersion string - -const ( - RadarHTTPTimeseriesGroupBotClassParamsIPVersionIPv4 RadarHTTPTimeseriesGroupBotClassParamsIPVersion = "IPv4" - RadarHTTPTimeseriesGroupBotClassParamsIPVersionIPv6 RadarHTTPTimeseriesGroupBotClassParamsIPVersion = "IPv6" -) - -type RadarHTTPTimeseriesGroupBotClassParamsOS string - -const ( - RadarHTTPTimeseriesGroupBotClassParamsOSWindows RadarHTTPTimeseriesGroupBotClassParamsOS = "WINDOWS" - RadarHTTPTimeseriesGroupBotClassParamsOSMacosx RadarHTTPTimeseriesGroupBotClassParamsOS = "MACOSX" - RadarHTTPTimeseriesGroupBotClassParamsOSIos RadarHTTPTimeseriesGroupBotClassParamsOS = "IOS" - RadarHTTPTimeseriesGroupBotClassParamsOSAndroid RadarHTTPTimeseriesGroupBotClassParamsOS = "ANDROID" - RadarHTTPTimeseriesGroupBotClassParamsOSChromeos RadarHTTPTimeseriesGroupBotClassParamsOS = "CHROMEOS" - RadarHTTPTimeseriesGroupBotClassParamsOSLinux RadarHTTPTimeseriesGroupBotClassParamsOS = "LINUX" - RadarHTTPTimeseriesGroupBotClassParamsOSSmartTv RadarHTTPTimeseriesGroupBotClassParamsOS = "SMART_TV" -) - -type RadarHTTPTimeseriesGroupBotClassParamsTLSVersion string - -const ( - RadarHTTPTimeseriesGroupBotClassParamsTLSVersionTlSv1_0 RadarHTTPTimeseriesGroupBotClassParamsTLSVersion = "TLSv1_0" - RadarHTTPTimeseriesGroupBotClassParamsTLSVersionTlSv1_1 RadarHTTPTimeseriesGroupBotClassParamsTLSVersion = "TLSv1_1" - RadarHTTPTimeseriesGroupBotClassParamsTLSVersionTlSv1_2 RadarHTTPTimeseriesGroupBotClassParamsTLSVersion = "TLSv1_2" - RadarHTTPTimeseriesGroupBotClassParamsTLSVersionTlSv1_3 RadarHTTPTimeseriesGroupBotClassParamsTLSVersion = "TLSv1_3" - RadarHTTPTimeseriesGroupBotClassParamsTLSVersionTlSvQuic RadarHTTPTimeseriesGroupBotClassParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPTimeseriesGroupBotClassResponseEnvelope struct { - Result RadarHTTPTimeseriesGroupBotClassResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPTimeseriesGroupBotClassResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPTimeseriesGroupBotClassResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarHTTPTimeseriesGroupBotClassResponseEnvelope] -type radarHTTPTimeseriesGroupBotClassResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupBotClassResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupBotClassResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupBrowserParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarHTTPTimeseriesGroupBrowserParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPTimeseriesGroupBrowserParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPTimeseriesGroupBrowserParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPTimeseriesGroupBrowserParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPTimeseriesGroupBrowserParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPTimeseriesGroupBrowserParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPTimeseriesGroupBrowserParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPTimeseriesGroupBrowserParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects (eg browsers, verticals, etc) to the top items over - // the time range. - LimitPerGroup param.Field[int64] `query:"limitPerGroup"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPTimeseriesGroupBrowserParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPTimeseriesGroupBrowserParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPTimeseriesGroupBrowserParams]'s query parameters -// as `url.Values`. -func (r RadarHTTPTimeseriesGroupBrowserParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarHTTPTimeseriesGroupBrowserParamsAggInterval string - -const ( - RadarHTTPTimeseriesGroupBrowserParamsAggInterval15m RadarHTTPTimeseriesGroupBrowserParamsAggInterval = "15m" - RadarHTTPTimeseriesGroupBrowserParamsAggInterval1h RadarHTTPTimeseriesGroupBrowserParamsAggInterval = "1h" - RadarHTTPTimeseriesGroupBrowserParamsAggInterval1d RadarHTTPTimeseriesGroupBrowserParamsAggInterval = "1d" - RadarHTTPTimeseriesGroupBrowserParamsAggInterval1w RadarHTTPTimeseriesGroupBrowserParamsAggInterval = "1w" -) - -type RadarHTTPTimeseriesGroupBrowserParamsBotClass string - -const ( - RadarHTTPTimeseriesGroupBrowserParamsBotClassLikelyAutomated RadarHTTPTimeseriesGroupBrowserParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPTimeseriesGroupBrowserParamsBotClassLikelyHuman RadarHTTPTimeseriesGroupBrowserParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPTimeseriesGroupBrowserParamsDateRange string - -const ( - RadarHTTPTimeseriesGroupBrowserParamsDateRange1d RadarHTTPTimeseriesGroupBrowserParamsDateRange = "1d" - RadarHTTPTimeseriesGroupBrowserParamsDateRange2d RadarHTTPTimeseriesGroupBrowserParamsDateRange = "2d" - RadarHTTPTimeseriesGroupBrowserParamsDateRange7d RadarHTTPTimeseriesGroupBrowserParamsDateRange = "7d" - RadarHTTPTimeseriesGroupBrowserParamsDateRange14d RadarHTTPTimeseriesGroupBrowserParamsDateRange = "14d" - RadarHTTPTimeseriesGroupBrowserParamsDateRange28d RadarHTTPTimeseriesGroupBrowserParamsDateRange = "28d" - RadarHTTPTimeseriesGroupBrowserParamsDateRange12w RadarHTTPTimeseriesGroupBrowserParamsDateRange = "12w" - RadarHTTPTimeseriesGroupBrowserParamsDateRange24w RadarHTTPTimeseriesGroupBrowserParamsDateRange = "24w" - RadarHTTPTimeseriesGroupBrowserParamsDateRange52w RadarHTTPTimeseriesGroupBrowserParamsDateRange = "52w" - RadarHTTPTimeseriesGroupBrowserParamsDateRange1dControl RadarHTTPTimeseriesGroupBrowserParamsDateRange = "1dControl" - RadarHTTPTimeseriesGroupBrowserParamsDateRange2dControl RadarHTTPTimeseriesGroupBrowserParamsDateRange = "2dControl" - RadarHTTPTimeseriesGroupBrowserParamsDateRange7dControl RadarHTTPTimeseriesGroupBrowserParamsDateRange = "7dControl" - RadarHTTPTimeseriesGroupBrowserParamsDateRange14dControl RadarHTTPTimeseriesGroupBrowserParamsDateRange = "14dControl" - RadarHTTPTimeseriesGroupBrowserParamsDateRange28dControl RadarHTTPTimeseriesGroupBrowserParamsDateRange = "28dControl" - RadarHTTPTimeseriesGroupBrowserParamsDateRange12wControl RadarHTTPTimeseriesGroupBrowserParamsDateRange = "12wControl" - RadarHTTPTimeseriesGroupBrowserParamsDateRange24wControl RadarHTTPTimeseriesGroupBrowserParamsDateRange = "24wControl" -) - -type RadarHTTPTimeseriesGroupBrowserParamsDeviceType string - -const ( - RadarHTTPTimeseriesGroupBrowserParamsDeviceTypeDesktop RadarHTTPTimeseriesGroupBrowserParamsDeviceType = "DESKTOP" - RadarHTTPTimeseriesGroupBrowserParamsDeviceTypeMobile RadarHTTPTimeseriesGroupBrowserParamsDeviceType = "MOBILE" - RadarHTTPTimeseriesGroupBrowserParamsDeviceTypeOther RadarHTTPTimeseriesGroupBrowserParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPTimeseriesGroupBrowserParamsFormat string - -const ( - RadarHTTPTimeseriesGroupBrowserParamsFormatJson RadarHTTPTimeseriesGroupBrowserParamsFormat = "JSON" - RadarHTTPTimeseriesGroupBrowserParamsFormatCsv RadarHTTPTimeseriesGroupBrowserParamsFormat = "CSV" -) - -type RadarHTTPTimeseriesGroupBrowserParamsHTTPProtocol string - -const ( - RadarHTTPTimeseriesGroupBrowserParamsHTTPProtocolHTTP RadarHTTPTimeseriesGroupBrowserParamsHTTPProtocol = "HTTP" - RadarHTTPTimeseriesGroupBrowserParamsHTTPProtocolHTTPS RadarHTTPTimeseriesGroupBrowserParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPTimeseriesGroupBrowserParamsHTTPVersion string - -const ( - RadarHTTPTimeseriesGroupBrowserParamsHTTPVersionHttPv1 RadarHTTPTimeseriesGroupBrowserParamsHTTPVersion = "HTTPv1" - RadarHTTPTimeseriesGroupBrowserParamsHTTPVersionHttPv2 RadarHTTPTimeseriesGroupBrowserParamsHTTPVersion = "HTTPv2" - RadarHTTPTimeseriesGroupBrowserParamsHTTPVersionHttPv3 RadarHTTPTimeseriesGroupBrowserParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPTimeseriesGroupBrowserParamsIPVersion string - -const ( - RadarHTTPTimeseriesGroupBrowserParamsIPVersionIPv4 RadarHTTPTimeseriesGroupBrowserParamsIPVersion = "IPv4" - RadarHTTPTimeseriesGroupBrowserParamsIPVersionIPv6 RadarHTTPTimeseriesGroupBrowserParamsIPVersion = "IPv6" -) - -type RadarHTTPTimeseriesGroupBrowserParamsOS string - -const ( - RadarHTTPTimeseriesGroupBrowserParamsOSWindows RadarHTTPTimeseriesGroupBrowserParamsOS = "WINDOWS" - RadarHTTPTimeseriesGroupBrowserParamsOSMacosx RadarHTTPTimeseriesGroupBrowserParamsOS = "MACOSX" - RadarHTTPTimeseriesGroupBrowserParamsOSIos RadarHTTPTimeseriesGroupBrowserParamsOS = "IOS" - RadarHTTPTimeseriesGroupBrowserParamsOSAndroid RadarHTTPTimeseriesGroupBrowserParamsOS = "ANDROID" - RadarHTTPTimeseriesGroupBrowserParamsOSChromeos RadarHTTPTimeseriesGroupBrowserParamsOS = "CHROMEOS" - RadarHTTPTimeseriesGroupBrowserParamsOSLinux RadarHTTPTimeseriesGroupBrowserParamsOS = "LINUX" - RadarHTTPTimeseriesGroupBrowserParamsOSSmartTv RadarHTTPTimeseriesGroupBrowserParamsOS = "SMART_TV" -) - -type RadarHTTPTimeseriesGroupBrowserParamsTLSVersion string - -const ( - RadarHTTPTimeseriesGroupBrowserParamsTLSVersionTlSv1_0 RadarHTTPTimeseriesGroupBrowserParamsTLSVersion = "TLSv1_0" - RadarHTTPTimeseriesGroupBrowserParamsTLSVersionTlSv1_1 RadarHTTPTimeseriesGroupBrowserParamsTLSVersion = "TLSv1_1" - RadarHTTPTimeseriesGroupBrowserParamsTLSVersionTlSv1_2 RadarHTTPTimeseriesGroupBrowserParamsTLSVersion = "TLSv1_2" - RadarHTTPTimeseriesGroupBrowserParamsTLSVersionTlSv1_3 RadarHTTPTimeseriesGroupBrowserParamsTLSVersion = "TLSv1_3" - RadarHTTPTimeseriesGroupBrowserParamsTLSVersionTlSvQuic RadarHTTPTimeseriesGroupBrowserParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPTimeseriesGroupBrowserResponseEnvelope struct { - Result RadarHTTPTimeseriesGroupBrowserResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPTimeseriesGroupBrowserResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPTimeseriesGroupBrowserResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarHTTPTimeseriesGroupBrowserResponseEnvelope] -type radarHTTPTimeseriesGroupBrowserResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupBrowserResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupBrowserResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupBrowserFamilyParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarHTTPTimeseriesGroupBrowserFamilyParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPTimeseriesGroupBrowserFamilyParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPTimeseriesGroupBrowserFamilyParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPTimeseriesGroupBrowserFamilyParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPTimeseriesGroupBrowserFamilyParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPTimeseriesGroupBrowserFamilyParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPTimeseriesGroupBrowserFamilyParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPTimeseriesGroupBrowserFamilyParams]'s query -// parameters as `url.Values`. -func (r RadarHTTPTimeseriesGroupBrowserFamilyParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarHTTPTimeseriesGroupBrowserFamilyParamsAggInterval string - -const ( - RadarHTTPTimeseriesGroupBrowserFamilyParamsAggInterval15m RadarHTTPTimeseriesGroupBrowserFamilyParamsAggInterval = "15m" - RadarHTTPTimeseriesGroupBrowserFamilyParamsAggInterval1h RadarHTTPTimeseriesGroupBrowserFamilyParamsAggInterval = "1h" - RadarHTTPTimeseriesGroupBrowserFamilyParamsAggInterval1d RadarHTTPTimeseriesGroupBrowserFamilyParamsAggInterval = "1d" - RadarHTTPTimeseriesGroupBrowserFamilyParamsAggInterval1w RadarHTTPTimeseriesGroupBrowserFamilyParamsAggInterval = "1w" -) - -type RadarHTTPTimeseriesGroupBrowserFamilyParamsBotClass string - -const ( - RadarHTTPTimeseriesGroupBrowserFamilyParamsBotClassLikelyAutomated RadarHTTPTimeseriesGroupBrowserFamilyParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPTimeseriesGroupBrowserFamilyParamsBotClassLikelyHuman RadarHTTPTimeseriesGroupBrowserFamilyParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange string - -const ( - RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange1d RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange = "1d" - RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange2d RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange = "2d" - RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange7d RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange = "7d" - RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange14d RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange = "14d" - RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange28d RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange = "28d" - RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange12w RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange = "12w" - RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange24w RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange = "24w" - RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange52w RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange = "52w" - RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange1dControl RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange = "1dControl" - RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange2dControl RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange = "2dControl" - RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange7dControl RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange = "7dControl" - RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange14dControl RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange = "14dControl" - RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange28dControl RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange = "28dControl" - RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange12wControl RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange = "12wControl" - RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange24wControl RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange = "24wControl" -) - -type RadarHTTPTimeseriesGroupBrowserFamilyParamsDeviceType string - -const ( - RadarHTTPTimeseriesGroupBrowserFamilyParamsDeviceTypeDesktop RadarHTTPTimeseriesGroupBrowserFamilyParamsDeviceType = "DESKTOP" - RadarHTTPTimeseriesGroupBrowserFamilyParamsDeviceTypeMobile RadarHTTPTimeseriesGroupBrowserFamilyParamsDeviceType = "MOBILE" - RadarHTTPTimeseriesGroupBrowserFamilyParamsDeviceTypeOther RadarHTTPTimeseriesGroupBrowserFamilyParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPTimeseriesGroupBrowserFamilyParamsFormat string - -const ( - RadarHTTPTimeseriesGroupBrowserFamilyParamsFormatJson RadarHTTPTimeseriesGroupBrowserFamilyParamsFormat = "JSON" - RadarHTTPTimeseriesGroupBrowserFamilyParamsFormatCsv RadarHTTPTimeseriesGroupBrowserFamilyParamsFormat = "CSV" -) - -type RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPProtocol string - -const ( - RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPProtocolHTTP RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPProtocol = "HTTP" - RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPProtocolHTTPS RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPVersion string - -const ( - RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPVersionHttPv1 RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPVersion = "HTTPv1" - RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPVersionHttPv2 RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPVersion = "HTTPv2" - RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPVersionHttPv3 RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPTimeseriesGroupBrowserFamilyParamsIPVersion string - -const ( - RadarHTTPTimeseriesGroupBrowserFamilyParamsIPVersionIPv4 RadarHTTPTimeseriesGroupBrowserFamilyParamsIPVersion = "IPv4" - RadarHTTPTimeseriesGroupBrowserFamilyParamsIPVersionIPv6 RadarHTTPTimeseriesGroupBrowserFamilyParamsIPVersion = "IPv6" -) - -type RadarHTTPTimeseriesGroupBrowserFamilyParamsOS string - -const ( - RadarHTTPTimeseriesGroupBrowserFamilyParamsOSWindows RadarHTTPTimeseriesGroupBrowserFamilyParamsOS = "WINDOWS" - RadarHTTPTimeseriesGroupBrowserFamilyParamsOSMacosx RadarHTTPTimeseriesGroupBrowserFamilyParamsOS = "MACOSX" - RadarHTTPTimeseriesGroupBrowserFamilyParamsOSIos RadarHTTPTimeseriesGroupBrowserFamilyParamsOS = "IOS" - RadarHTTPTimeseriesGroupBrowserFamilyParamsOSAndroid RadarHTTPTimeseriesGroupBrowserFamilyParamsOS = "ANDROID" - RadarHTTPTimeseriesGroupBrowserFamilyParamsOSChromeos RadarHTTPTimeseriesGroupBrowserFamilyParamsOS = "CHROMEOS" - RadarHTTPTimeseriesGroupBrowserFamilyParamsOSLinux RadarHTTPTimeseriesGroupBrowserFamilyParamsOS = "LINUX" - RadarHTTPTimeseriesGroupBrowserFamilyParamsOSSmartTv RadarHTTPTimeseriesGroupBrowserFamilyParamsOS = "SMART_TV" -) - -type RadarHTTPTimeseriesGroupBrowserFamilyParamsTLSVersion string - -const ( - RadarHTTPTimeseriesGroupBrowserFamilyParamsTLSVersionTlSv1_0 RadarHTTPTimeseriesGroupBrowserFamilyParamsTLSVersion = "TLSv1_0" - RadarHTTPTimeseriesGroupBrowserFamilyParamsTLSVersionTlSv1_1 RadarHTTPTimeseriesGroupBrowserFamilyParamsTLSVersion = "TLSv1_1" - RadarHTTPTimeseriesGroupBrowserFamilyParamsTLSVersionTlSv1_2 RadarHTTPTimeseriesGroupBrowserFamilyParamsTLSVersion = "TLSv1_2" - RadarHTTPTimeseriesGroupBrowserFamilyParamsTLSVersionTlSv1_3 RadarHTTPTimeseriesGroupBrowserFamilyParamsTLSVersion = "TLSv1_3" - RadarHTTPTimeseriesGroupBrowserFamilyParamsTLSVersionTlSvQuic RadarHTTPTimeseriesGroupBrowserFamilyParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPTimeseriesGroupBrowserFamilyResponseEnvelope struct { - Result RadarHTTPTimeseriesGroupBrowserFamilyResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPTimeseriesGroupBrowserFamilyResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPTimeseriesGroupBrowserFamilyResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarHTTPTimeseriesGroupBrowserFamilyResponseEnvelope] -type radarHTTPTimeseriesGroupBrowserFamilyResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupBrowserFamilyResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupBrowserFamilyResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupDeviceTypeParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarHTTPTimeseriesGroupDeviceTypeParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPTimeseriesGroupDeviceTypeParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarHTTPTimeseriesGroupDeviceTypeParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPTimeseriesGroupDeviceTypeParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPTimeseriesGroupDeviceTypeParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPTimeseriesGroupDeviceTypeParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPTimeseriesGroupDeviceTypeParams]'s query -// parameters as `url.Values`. -func (r RadarHTTPTimeseriesGroupDeviceTypeParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarHTTPTimeseriesGroupDeviceTypeParamsAggInterval string - -const ( - RadarHTTPTimeseriesGroupDeviceTypeParamsAggInterval15m RadarHTTPTimeseriesGroupDeviceTypeParamsAggInterval = "15m" - RadarHTTPTimeseriesGroupDeviceTypeParamsAggInterval1h RadarHTTPTimeseriesGroupDeviceTypeParamsAggInterval = "1h" - RadarHTTPTimeseriesGroupDeviceTypeParamsAggInterval1d RadarHTTPTimeseriesGroupDeviceTypeParamsAggInterval = "1d" - RadarHTTPTimeseriesGroupDeviceTypeParamsAggInterval1w RadarHTTPTimeseriesGroupDeviceTypeParamsAggInterval = "1w" -) - -type RadarHTTPTimeseriesGroupDeviceTypeParamsBotClass string - -const ( - RadarHTTPTimeseriesGroupDeviceTypeParamsBotClassLikelyAutomated RadarHTTPTimeseriesGroupDeviceTypeParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPTimeseriesGroupDeviceTypeParamsBotClassLikelyHuman RadarHTTPTimeseriesGroupDeviceTypeParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange string - -const ( - RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange1d RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange = "1d" - RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange2d RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange = "2d" - RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange7d RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange = "7d" - RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange14d RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange = "14d" - RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange28d RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange = "28d" - RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange12w RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange = "12w" - RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange24w RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange = "24w" - RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange52w RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange = "52w" - RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange1dControl RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange = "1dControl" - RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange2dControl RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange = "2dControl" - RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange7dControl RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange = "7dControl" - RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange14dControl RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange = "14dControl" - RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange28dControl RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange = "28dControl" - RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange12wControl RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange = "12wControl" - RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange24wControl RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarHTTPTimeseriesGroupDeviceTypeParamsFormat string - -const ( - RadarHTTPTimeseriesGroupDeviceTypeParamsFormatJson RadarHTTPTimeseriesGroupDeviceTypeParamsFormat = "JSON" - RadarHTTPTimeseriesGroupDeviceTypeParamsFormatCsv RadarHTTPTimeseriesGroupDeviceTypeParamsFormat = "CSV" -) - -type RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPProtocol string - -const ( - RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPProtocolHTTP RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPProtocol = "HTTP" - RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPProtocolHTTPS RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPVersion string - -const ( - RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPVersionHttPv1 RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPVersion = "HTTPv1" - RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPVersionHttPv2 RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPVersion = "HTTPv2" - RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPVersionHttPv3 RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPTimeseriesGroupDeviceTypeParamsIPVersion string - -const ( - RadarHTTPTimeseriesGroupDeviceTypeParamsIPVersionIPv4 RadarHTTPTimeseriesGroupDeviceTypeParamsIPVersion = "IPv4" - RadarHTTPTimeseriesGroupDeviceTypeParamsIPVersionIPv6 RadarHTTPTimeseriesGroupDeviceTypeParamsIPVersion = "IPv6" -) - -type RadarHTTPTimeseriesGroupDeviceTypeParamsOS string - -const ( - RadarHTTPTimeseriesGroupDeviceTypeParamsOSWindows RadarHTTPTimeseriesGroupDeviceTypeParamsOS = "WINDOWS" - RadarHTTPTimeseriesGroupDeviceTypeParamsOSMacosx RadarHTTPTimeseriesGroupDeviceTypeParamsOS = "MACOSX" - RadarHTTPTimeseriesGroupDeviceTypeParamsOSIos RadarHTTPTimeseriesGroupDeviceTypeParamsOS = "IOS" - RadarHTTPTimeseriesGroupDeviceTypeParamsOSAndroid RadarHTTPTimeseriesGroupDeviceTypeParamsOS = "ANDROID" - RadarHTTPTimeseriesGroupDeviceTypeParamsOSChromeos RadarHTTPTimeseriesGroupDeviceTypeParamsOS = "CHROMEOS" - RadarHTTPTimeseriesGroupDeviceTypeParamsOSLinux RadarHTTPTimeseriesGroupDeviceTypeParamsOS = "LINUX" - RadarHTTPTimeseriesGroupDeviceTypeParamsOSSmartTv RadarHTTPTimeseriesGroupDeviceTypeParamsOS = "SMART_TV" -) - -type RadarHTTPTimeseriesGroupDeviceTypeParamsTLSVersion string - -const ( - RadarHTTPTimeseriesGroupDeviceTypeParamsTLSVersionTlSv1_0 RadarHTTPTimeseriesGroupDeviceTypeParamsTLSVersion = "TLSv1_0" - RadarHTTPTimeseriesGroupDeviceTypeParamsTLSVersionTlSv1_1 RadarHTTPTimeseriesGroupDeviceTypeParamsTLSVersion = "TLSv1_1" - RadarHTTPTimeseriesGroupDeviceTypeParamsTLSVersionTlSv1_2 RadarHTTPTimeseriesGroupDeviceTypeParamsTLSVersion = "TLSv1_2" - RadarHTTPTimeseriesGroupDeviceTypeParamsTLSVersionTlSv1_3 RadarHTTPTimeseriesGroupDeviceTypeParamsTLSVersion = "TLSv1_3" - RadarHTTPTimeseriesGroupDeviceTypeParamsTLSVersionTlSvQuic RadarHTTPTimeseriesGroupDeviceTypeParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPTimeseriesGroupDeviceTypeResponseEnvelope struct { - Result RadarHTTPTimeseriesGroupDeviceTypeResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPTimeseriesGroupDeviceTypeResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPTimeseriesGroupDeviceTypeResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarHTTPTimeseriesGroupDeviceTypeResponseEnvelope] -type radarHTTPTimeseriesGroupDeviceTypeResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupDeviceTypeResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupDeviceTypeResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupHTTPProtocolParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarHTTPTimeseriesGroupHTTPProtocolParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPTimeseriesGroupHTTPProtocolParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPTimeseriesGroupHTTPProtocolParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPTimeseriesGroupHTTPProtocolParamsFormat] `query:"format"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPTimeseriesGroupHTTPProtocolParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPTimeseriesGroupHTTPProtocolParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPTimeseriesGroupHTTPProtocolParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPTimeseriesGroupHTTPProtocolParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPTimeseriesGroupHTTPProtocolParams]'s query -// parameters as `url.Values`. -func (r RadarHTTPTimeseriesGroupHTTPProtocolParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarHTTPTimeseriesGroupHTTPProtocolParamsAggInterval string - -const ( - RadarHTTPTimeseriesGroupHTTPProtocolParamsAggInterval15m RadarHTTPTimeseriesGroupHTTPProtocolParamsAggInterval = "15m" - RadarHTTPTimeseriesGroupHTTPProtocolParamsAggInterval1h RadarHTTPTimeseriesGroupHTTPProtocolParamsAggInterval = "1h" - RadarHTTPTimeseriesGroupHTTPProtocolParamsAggInterval1d RadarHTTPTimeseriesGroupHTTPProtocolParamsAggInterval = "1d" - RadarHTTPTimeseriesGroupHTTPProtocolParamsAggInterval1w RadarHTTPTimeseriesGroupHTTPProtocolParamsAggInterval = "1w" -) - -type RadarHTTPTimeseriesGroupHTTPProtocolParamsBotClass string - -const ( - RadarHTTPTimeseriesGroupHTTPProtocolParamsBotClassLikelyAutomated RadarHTTPTimeseriesGroupHTTPProtocolParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPTimeseriesGroupHTTPProtocolParamsBotClassLikelyHuman RadarHTTPTimeseriesGroupHTTPProtocolParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange string - -const ( - RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange1d RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange = "1d" - RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange2d RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange = "2d" - RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange7d RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange = "7d" - RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange14d RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange = "14d" - RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange28d RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange = "28d" - RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange12w RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange = "12w" - RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange24w RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange = "24w" - RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange52w RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange = "52w" - RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange1dControl RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange = "1dControl" - RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange2dControl RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange = "2dControl" - RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange7dControl RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange = "7dControl" - RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange14dControl RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange = "14dControl" - RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange28dControl RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange = "28dControl" - RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange12wControl RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange = "12wControl" - RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange24wControl RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange = "24wControl" -) - -type RadarHTTPTimeseriesGroupHTTPProtocolParamsDeviceType string - -const ( - RadarHTTPTimeseriesGroupHTTPProtocolParamsDeviceTypeDesktop RadarHTTPTimeseriesGroupHTTPProtocolParamsDeviceType = "DESKTOP" - RadarHTTPTimeseriesGroupHTTPProtocolParamsDeviceTypeMobile RadarHTTPTimeseriesGroupHTTPProtocolParamsDeviceType = "MOBILE" - RadarHTTPTimeseriesGroupHTTPProtocolParamsDeviceTypeOther RadarHTTPTimeseriesGroupHTTPProtocolParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPTimeseriesGroupHTTPProtocolParamsFormat string - -const ( - RadarHTTPTimeseriesGroupHTTPProtocolParamsFormatJson RadarHTTPTimeseriesGroupHTTPProtocolParamsFormat = "JSON" - RadarHTTPTimeseriesGroupHTTPProtocolParamsFormatCsv RadarHTTPTimeseriesGroupHTTPProtocolParamsFormat = "CSV" -) - -type RadarHTTPTimeseriesGroupHTTPProtocolParamsHTTPVersion string - -const ( - RadarHTTPTimeseriesGroupHTTPProtocolParamsHTTPVersionHttPv1 RadarHTTPTimeseriesGroupHTTPProtocolParamsHTTPVersion = "HTTPv1" - RadarHTTPTimeseriesGroupHTTPProtocolParamsHTTPVersionHttPv2 RadarHTTPTimeseriesGroupHTTPProtocolParamsHTTPVersion = "HTTPv2" - RadarHTTPTimeseriesGroupHTTPProtocolParamsHTTPVersionHttPv3 RadarHTTPTimeseriesGroupHTTPProtocolParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPTimeseriesGroupHTTPProtocolParamsIPVersion string - -const ( - RadarHTTPTimeseriesGroupHTTPProtocolParamsIPVersionIPv4 RadarHTTPTimeseriesGroupHTTPProtocolParamsIPVersion = "IPv4" - RadarHTTPTimeseriesGroupHTTPProtocolParamsIPVersionIPv6 RadarHTTPTimeseriesGroupHTTPProtocolParamsIPVersion = "IPv6" -) - -type RadarHTTPTimeseriesGroupHTTPProtocolParamsOS string - -const ( - RadarHTTPTimeseriesGroupHTTPProtocolParamsOSWindows RadarHTTPTimeseriesGroupHTTPProtocolParamsOS = "WINDOWS" - RadarHTTPTimeseriesGroupHTTPProtocolParamsOSMacosx RadarHTTPTimeseriesGroupHTTPProtocolParamsOS = "MACOSX" - RadarHTTPTimeseriesGroupHTTPProtocolParamsOSIos RadarHTTPTimeseriesGroupHTTPProtocolParamsOS = "IOS" - RadarHTTPTimeseriesGroupHTTPProtocolParamsOSAndroid RadarHTTPTimeseriesGroupHTTPProtocolParamsOS = "ANDROID" - RadarHTTPTimeseriesGroupHTTPProtocolParamsOSChromeos RadarHTTPTimeseriesGroupHTTPProtocolParamsOS = "CHROMEOS" - RadarHTTPTimeseriesGroupHTTPProtocolParamsOSLinux RadarHTTPTimeseriesGroupHTTPProtocolParamsOS = "LINUX" - RadarHTTPTimeseriesGroupHTTPProtocolParamsOSSmartTv RadarHTTPTimeseriesGroupHTTPProtocolParamsOS = "SMART_TV" -) - -type RadarHTTPTimeseriesGroupHTTPProtocolParamsTLSVersion string - -const ( - RadarHTTPTimeseriesGroupHTTPProtocolParamsTLSVersionTlSv1_0 RadarHTTPTimeseriesGroupHTTPProtocolParamsTLSVersion = "TLSv1_0" - RadarHTTPTimeseriesGroupHTTPProtocolParamsTLSVersionTlSv1_1 RadarHTTPTimeseriesGroupHTTPProtocolParamsTLSVersion = "TLSv1_1" - RadarHTTPTimeseriesGroupHTTPProtocolParamsTLSVersionTlSv1_2 RadarHTTPTimeseriesGroupHTTPProtocolParamsTLSVersion = "TLSv1_2" - RadarHTTPTimeseriesGroupHTTPProtocolParamsTLSVersionTlSv1_3 RadarHTTPTimeseriesGroupHTTPProtocolParamsTLSVersion = "TLSv1_3" - RadarHTTPTimeseriesGroupHTTPProtocolParamsTLSVersionTlSvQuic RadarHTTPTimeseriesGroupHTTPProtocolParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPTimeseriesGroupHTTPProtocolResponseEnvelope struct { - Result RadarHTTPTimeseriesGroupHTTPProtocolResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPTimeseriesGroupHTTPProtocolResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPTimeseriesGroupHTTPProtocolResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarHTTPTimeseriesGroupHTTPProtocolResponseEnvelope] -type radarHTTPTimeseriesGroupHTTPProtocolResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupHTTPProtocolResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupHTTPProtocolResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupHTTPVersionParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarHTTPTimeseriesGroupHTTPVersionParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPTimeseriesGroupHTTPVersionParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPTimeseriesGroupHTTPVersionParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPTimeseriesGroupHTTPVersionParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPTimeseriesGroupHTTPVersionParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPTimeseriesGroupHTTPVersionParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPTimeseriesGroupHTTPVersionParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPTimeseriesGroupHTTPVersionParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPTimeseriesGroupHTTPVersionParams]'s query -// parameters as `url.Values`. -func (r RadarHTTPTimeseriesGroupHTTPVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarHTTPTimeseriesGroupHTTPVersionParamsAggInterval string - -const ( - RadarHTTPTimeseriesGroupHTTPVersionParamsAggInterval15m RadarHTTPTimeseriesGroupHTTPVersionParamsAggInterval = "15m" - RadarHTTPTimeseriesGroupHTTPVersionParamsAggInterval1h RadarHTTPTimeseriesGroupHTTPVersionParamsAggInterval = "1h" - RadarHTTPTimeseriesGroupHTTPVersionParamsAggInterval1d RadarHTTPTimeseriesGroupHTTPVersionParamsAggInterval = "1d" - RadarHTTPTimeseriesGroupHTTPVersionParamsAggInterval1w RadarHTTPTimeseriesGroupHTTPVersionParamsAggInterval = "1w" -) - -type RadarHTTPTimeseriesGroupHTTPVersionParamsBotClass string - -const ( - RadarHTTPTimeseriesGroupHTTPVersionParamsBotClassLikelyAutomated RadarHTTPTimeseriesGroupHTTPVersionParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPTimeseriesGroupHTTPVersionParamsBotClassLikelyHuman RadarHTTPTimeseriesGroupHTTPVersionParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange string - -const ( - RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange1d RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange = "1d" - RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange2d RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange = "2d" - RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange7d RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange = "7d" - RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange14d RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange = "14d" - RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange28d RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange = "28d" - RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange12w RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange = "12w" - RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange24w RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange = "24w" - RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange52w RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange = "52w" - RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange1dControl RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange = "1dControl" - RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange2dControl RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange = "2dControl" - RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange7dControl RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange = "7dControl" - RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange14dControl RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange = "14dControl" - RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange28dControl RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange = "28dControl" - RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange12wControl RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange = "12wControl" - RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange24wControl RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange = "24wControl" -) - -type RadarHTTPTimeseriesGroupHTTPVersionParamsDeviceType string - -const ( - RadarHTTPTimeseriesGroupHTTPVersionParamsDeviceTypeDesktop RadarHTTPTimeseriesGroupHTTPVersionParamsDeviceType = "DESKTOP" - RadarHTTPTimeseriesGroupHTTPVersionParamsDeviceTypeMobile RadarHTTPTimeseriesGroupHTTPVersionParamsDeviceType = "MOBILE" - RadarHTTPTimeseriesGroupHTTPVersionParamsDeviceTypeOther RadarHTTPTimeseriesGroupHTTPVersionParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPTimeseriesGroupHTTPVersionParamsFormat string - -const ( - RadarHTTPTimeseriesGroupHTTPVersionParamsFormatJson RadarHTTPTimeseriesGroupHTTPVersionParamsFormat = "JSON" - RadarHTTPTimeseriesGroupHTTPVersionParamsFormatCsv RadarHTTPTimeseriesGroupHTTPVersionParamsFormat = "CSV" -) - -type RadarHTTPTimeseriesGroupHTTPVersionParamsHTTPProtocol string - -const ( - RadarHTTPTimeseriesGroupHTTPVersionParamsHTTPProtocolHTTP RadarHTTPTimeseriesGroupHTTPVersionParamsHTTPProtocol = "HTTP" - RadarHTTPTimeseriesGroupHTTPVersionParamsHTTPProtocolHTTPS RadarHTTPTimeseriesGroupHTTPVersionParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPTimeseriesGroupHTTPVersionParamsIPVersion string - -const ( - RadarHTTPTimeseriesGroupHTTPVersionParamsIPVersionIPv4 RadarHTTPTimeseriesGroupHTTPVersionParamsIPVersion = "IPv4" - RadarHTTPTimeseriesGroupHTTPVersionParamsIPVersionIPv6 RadarHTTPTimeseriesGroupHTTPVersionParamsIPVersion = "IPv6" -) - -type RadarHTTPTimeseriesGroupHTTPVersionParamsOS string - -const ( - RadarHTTPTimeseriesGroupHTTPVersionParamsOSWindows RadarHTTPTimeseriesGroupHTTPVersionParamsOS = "WINDOWS" - RadarHTTPTimeseriesGroupHTTPVersionParamsOSMacosx RadarHTTPTimeseriesGroupHTTPVersionParamsOS = "MACOSX" - RadarHTTPTimeseriesGroupHTTPVersionParamsOSIos RadarHTTPTimeseriesGroupHTTPVersionParamsOS = "IOS" - RadarHTTPTimeseriesGroupHTTPVersionParamsOSAndroid RadarHTTPTimeseriesGroupHTTPVersionParamsOS = "ANDROID" - RadarHTTPTimeseriesGroupHTTPVersionParamsOSChromeos RadarHTTPTimeseriesGroupHTTPVersionParamsOS = "CHROMEOS" - RadarHTTPTimeseriesGroupHTTPVersionParamsOSLinux RadarHTTPTimeseriesGroupHTTPVersionParamsOS = "LINUX" - RadarHTTPTimeseriesGroupHTTPVersionParamsOSSmartTv RadarHTTPTimeseriesGroupHTTPVersionParamsOS = "SMART_TV" -) - -type RadarHTTPTimeseriesGroupHTTPVersionParamsTLSVersion string - -const ( - RadarHTTPTimeseriesGroupHTTPVersionParamsTLSVersionTlSv1_0 RadarHTTPTimeseriesGroupHTTPVersionParamsTLSVersion = "TLSv1_0" - RadarHTTPTimeseriesGroupHTTPVersionParamsTLSVersionTlSv1_1 RadarHTTPTimeseriesGroupHTTPVersionParamsTLSVersion = "TLSv1_1" - RadarHTTPTimeseriesGroupHTTPVersionParamsTLSVersionTlSv1_2 RadarHTTPTimeseriesGroupHTTPVersionParamsTLSVersion = "TLSv1_2" - RadarHTTPTimeseriesGroupHTTPVersionParamsTLSVersionTlSv1_3 RadarHTTPTimeseriesGroupHTTPVersionParamsTLSVersion = "TLSv1_3" - RadarHTTPTimeseriesGroupHTTPVersionParamsTLSVersionTlSvQuic RadarHTTPTimeseriesGroupHTTPVersionParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPTimeseriesGroupHTTPVersionResponseEnvelope struct { - Result RadarHTTPTimeseriesGroupHTTPVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPTimeseriesGroupHTTPVersionResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPTimeseriesGroupHTTPVersionResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarHTTPTimeseriesGroupHTTPVersionResponseEnvelope] -type radarHTTPTimeseriesGroupHTTPVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupHTTPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupHTTPVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupIPVersionParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarHTTPTimeseriesGroupIPVersionParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPTimeseriesGroupIPVersionParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPTimeseriesGroupIPVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPTimeseriesGroupIPVersionParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPTimeseriesGroupIPVersionParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPTimeseriesGroupIPVersionParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPTimeseriesGroupIPVersionParamsHTTPVersion] `query:"httpVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPTimeseriesGroupIPVersionParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPTimeseriesGroupIPVersionParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPTimeseriesGroupIPVersionParams]'s query parameters -// as `url.Values`. -func (r RadarHTTPTimeseriesGroupIPVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarHTTPTimeseriesGroupIPVersionParamsAggInterval string - -const ( - RadarHTTPTimeseriesGroupIPVersionParamsAggInterval15m RadarHTTPTimeseriesGroupIPVersionParamsAggInterval = "15m" - RadarHTTPTimeseriesGroupIPVersionParamsAggInterval1h RadarHTTPTimeseriesGroupIPVersionParamsAggInterval = "1h" - RadarHTTPTimeseriesGroupIPVersionParamsAggInterval1d RadarHTTPTimeseriesGroupIPVersionParamsAggInterval = "1d" - RadarHTTPTimeseriesGroupIPVersionParamsAggInterval1w RadarHTTPTimeseriesGroupIPVersionParamsAggInterval = "1w" -) - -type RadarHTTPTimeseriesGroupIPVersionParamsBotClass string - -const ( - RadarHTTPTimeseriesGroupIPVersionParamsBotClassLikelyAutomated RadarHTTPTimeseriesGroupIPVersionParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPTimeseriesGroupIPVersionParamsBotClassLikelyHuman RadarHTTPTimeseriesGroupIPVersionParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPTimeseriesGroupIPVersionParamsDateRange string - -const ( - RadarHTTPTimeseriesGroupIPVersionParamsDateRange1d RadarHTTPTimeseriesGroupIPVersionParamsDateRange = "1d" - RadarHTTPTimeseriesGroupIPVersionParamsDateRange2d RadarHTTPTimeseriesGroupIPVersionParamsDateRange = "2d" - RadarHTTPTimeseriesGroupIPVersionParamsDateRange7d RadarHTTPTimeseriesGroupIPVersionParamsDateRange = "7d" - RadarHTTPTimeseriesGroupIPVersionParamsDateRange14d RadarHTTPTimeseriesGroupIPVersionParamsDateRange = "14d" - RadarHTTPTimeseriesGroupIPVersionParamsDateRange28d RadarHTTPTimeseriesGroupIPVersionParamsDateRange = "28d" - RadarHTTPTimeseriesGroupIPVersionParamsDateRange12w RadarHTTPTimeseriesGroupIPVersionParamsDateRange = "12w" - RadarHTTPTimeseriesGroupIPVersionParamsDateRange24w RadarHTTPTimeseriesGroupIPVersionParamsDateRange = "24w" - RadarHTTPTimeseriesGroupIPVersionParamsDateRange52w RadarHTTPTimeseriesGroupIPVersionParamsDateRange = "52w" - RadarHTTPTimeseriesGroupIPVersionParamsDateRange1dControl RadarHTTPTimeseriesGroupIPVersionParamsDateRange = "1dControl" - RadarHTTPTimeseriesGroupIPVersionParamsDateRange2dControl RadarHTTPTimeseriesGroupIPVersionParamsDateRange = "2dControl" - RadarHTTPTimeseriesGroupIPVersionParamsDateRange7dControl RadarHTTPTimeseriesGroupIPVersionParamsDateRange = "7dControl" - RadarHTTPTimeseriesGroupIPVersionParamsDateRange14dControl RadarHTTPTimeseriesGroupIPVersionParamsDateRange = "14dControl" - RadarHTTPTimeseriesGroupIPVersionParamsDateRange28dControl RadarHTTPTimeseriesGroupIPVersionParamsDateRange = "28dControl" - RadarHTTPTimeseriesGroupIPVersionParamsDateRange12wControl RadarHTTPTimeseriesGroupIPVersionParamsDateRange = "12wControl" - RadarHTTPTimeseriesGroupIPVersionParamsDateRange24wControl RadarHTTPTimeseriesGroupIPVersionParamsDateRange = "24wControl" -) - -type RadarHTTPTimeseriesGroupIPVersionParamsDeviceType string - -const ( - RadarHTTPTimeseriesGroupIPVersionParamsDeviceTypeDesktop RadarHTTPTimeseriesGroupIPVersionParamsDeviceType = "DESKTOP" - RadarHTTPTimeseriesGroupIPVersionParamsDeviceTypeMobile RadarHTTPTimeseriesGroupIPVersionParamsDeviceType = "MOBILE" - RadarHTTPTimeseriesGroupIPVersionParamsDeviceTypeOther RadarHTTPTimeseriesGroupIPVersionParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPTimeseriesGroupIPVersionParamsFormat string - -const ( - RadarHTTPTimeseriesGroupIPVersionParamsFormatJson RadarHTTPTimeseriesGroupIPVersionParamsFormat = "JSON" - RadarHTTPTimeseriesGroupIPVersionParamsFormatCsv RadarHTTPTimeseriesGroupIPVersionParamsFormat = "CSV" -) - -type RadarHTTPTimeseriesGroupIPVersionParamsHTTPProtocol string - -const ( - RadarHTTPTimeseriesGroupIPVersionParamsHTTPProtocolHTTP RadarHTTPTimeseriesGroupIPVersionParamsHTTPProtocol = "HTTP" - RadarHTTPTimeseriesGroupIPVersionParamsHTTPProtocolHTTPS RadarHTTPTimeseriesGroupIPVersionParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPTimeseriesGroupIPVersionParamsHTTPVersion string - -const ( - RadarHTTPTimeseriesGroupIPVersionParamsHTTPVersionHttPv1 RadarHTTPTimeseriesGroupIPVersionParamsHTTPVersion = "HTTPv1" - RadarHTTPTimeseriesGroupIPVersionParamsHTTPVersionHttPv2 RadarHTTPTimeseriesGroupIPVersionParamsHTTPVersion = "HTTPv2" - RadarHTTPTimeseriesGroupIPVersionParamsHTTPVersionHttPv3 RadarHTTPTimeseriesGroupIPVersionParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPTimeseriesGroupIPVersionParamsOS string - -const ( - RadarHTTPTimeseriesGroupIPVersionParamsOSWindows RadarHTTPTimeseriesGroupIPVersionParamsOS = "WINDOWS" - RadarHTTPTimeseriesGroupIPVersionParamsOSMacosx RadarHTTPTimeseriesGroupIPVersionParamsOS = "MACOSX" - RadarHTTPTimeseriesGroupIPVersionParamsOSIos RadarHTTPTimeseriesGroupIPVersionParamsOS = "IOS" - RadarHTTPTimeseriesGroupIPVersionParamsOSAndroid RadarHTTPTimeseriesGroupIPVersionParamsOS = "ANDROID" - RadarHTTPTimeseriesGroupIPVersionParamsOSChromeos RadarHTTPTimeseriesGroupIPVersionParamsOS = "CHROMEOS" - RadarHTTPTimeseriesGroupIPVersionParamsOSLinux RadarHTTPTimeseriesGroupIPVersionParamsOS = "LINUX" - RadarHTTPTimeseriesGroupIPVersionParamsOSSmartTv RadarHTTPTimeseriesGroupIPVersionParamsOS = "SMART_TV" -) - -type RadarHTTPTimeseriesGroupIPVersionParamsTLSVersion string - -const ( - RadarHTTPTimeseriesGroupIPVersionParamsTLSVersionTlSv1_0 RadarHTTPTimeseriesGroupIPVersionParamsTLSVersion = "TLSv1_0" - RadarHTTPTimeseriesGroupIPVersionParamsTLSVersionTlSv1_1 RadarHTTPTimeseriesGroupIPVersionParamsTLSVersion = "TLSv1_1" - RadarHTTPTimeseriesGroupIPVersionParamsTLSVersionTlSv1_2 RadarHTTPTimeseriesGroupIPVersionParamsTLSVersion = "TLSv1_2" - RadarHTTPTimeseriesGroupIPVersionParamsTLSVersionTlSv1_3 RadarHTTPTimeseriesGroupIPVersionParamsTLSVersion = "TLSv1_3" - RadarHTTPTimeseriesGroupIPVersionParamsTLSVersionTlSvQuic RadarHTTPTimeseriesGroupIPVersionParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPTimeseriesGroupIPVersionResponseEnvelope struct { - Result RadarHTTPTimeseriesGroupIPVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPTimeseriesGroupIPVersionResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPTimeseriesGroupIPVersionResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarHTTPTimeseriesGroupIPVersionResponseEnvelope] -type radarHTTPTimeseriesGroupIPVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupIPVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupIPVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupOSParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarHTTPTimeseriesGroupOSParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPTimeseriesGroupOSParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPTimeseriesGroupOSParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPTimeseriesGroupOSParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPTimeseriesGroupOSParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPTimeseriesGroupOSParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPTimeseriesGroupOSParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPTimeseriesGroupOSParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPTimeseriesGroupOSParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPTimeseriesGroupOSParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPTimeseriesGroupOSParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarHTTPTimeseriesGroupOSParamsAggInterval string - -const ( - RadarHTTPTimeseriesGroupOSParamsAggInterval15m RadarHTTPTimeseriesGroupOSParamsAggInterval = "15m" - RadarHTTPTimeseriesGroupOSParamsAggInterval1h RadarHTTPTimeseriesGroupOSParamsAggInterval = "1h" - RadarHTTPTimeseriesGroupOSParamsAggInterval1d RadarHTTPTimeseriesGroupOSParamsAggInterval = "1d" - RadarHTTPTimeseriesGroupOSParamsAggInterval1w RadarHTTPTimeseriesGroupOSParamsAggInterval = "1w" -) - -type RadarHTTPTimeseriesGroupOSParamsBotClass string - -const ( - RadarHTTPTimeseriesGroupOSParamsBotClassLikelyAutomated RadarHTTPTimeseriesGroupOSParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPTimeseriesGroupOSParamsBotClassLikelyHuman RadarHTTPTimeseriesGroupOSParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPTimeseriesGroupOSParamsDateRange string - -const ( - RadarHTTPTimeseriesGroupOSParamsDateRange1d RadarHTTPTimeseriesGroupOSParamsDateRange = "1d" - RadarHTTPTimeseriesGroupOSParamsDateRange2d RadarHTTPTimeseriesGroupOSParamsDateRange = "2d" - RadarHTTPTimeseriesGroupOSParamsDateRange7d RadarHTTPTimeseriesGroupOSParamsDateRange = "7d" - RadarHTTPTimeseriesGroupOSParamsDateRange14d RadarHTTPTimeseriesGroupOSParamsDateRange = "14d" - RadarHTTPTimeseriesGroupOSParamsDateRange28d RadarHTTPTimeseriesGroupOSParamsDateRange = "28d" - RadarHTTPTimeseriesGroupOSParamsDateRange12w RadarHTTPTimeseriesGroupOSParamsDateRange = "12w" - RadarHTTPTimeseriesGroupOSParamsDateRange24w RadarHTTPTimeseriesGroupOSParamsDateRange = "24w" - RadarHTTPTimeseriesGroupOSParamsDateRange52w RadarHTTPTimeseriesGroupOSParamsDateRange = "52w" - RadarHTTPTimeseriesGroupOSParamsDateRange1dControl RadarHTTPTimeseriesGroupOSParamsDateRange = "1dControl" - RadarHTTPTimeseriesGroupOSParamsDateRange2dControl RadarHTTPTimeseriesGroupOSParamsDateRange = "2dControl" - RadarHTTPTimeseriesGroupOSParamsDateRange7dControl RadarHTTPTimeseriesGroupOSParamsDateRange = "7dControl" - RadarHTTPTimeseriesGroupOSParamsDateRange14dControl RadarHTTPTimeseriesGroupOSParamsDateRange = "14dControl" - RadarHTTPTimeseriesGroupOSParamsDateRange28dControl RadarHTTPTimeseriesGroupOSParamsDateRange = "28dControl" - RadarHTTPTimeseriesGroupOSParamsDateRange12wControl RadarHTTPTimeseriesGroupOSParamsDateRange = "12wControl" - RadarHTTPTimeseriesGroupOSParamsDateRange24wControl RadarHTTPTimeseriesGroupOSParamsDateRange = "24wControl" -) - -type RadarHTTPTimeseriesGroupOSParamsDeviceType string - -const ( - RadarHTTPTimeseriesGroupOSParamsDeviceTypeDesktop RadarHTTPTimeseriesGroupOSParamsDeviceType = "DESKTOP" - RadarHTTPTimeseriesGroupOSParamsDeviceTypeMobile RadarHTTPTimeseriesGroupOSParamsDeviceType = "MOBILE" - RadarHTTPTimeseriesGroupOSParamsDeviceTypeOther RadarHTTPTimeseriesGroupOSParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPTimeseriesGroupOSParamsFormat string - -const ( - RadarHTTPTimeseriesGroupOSParamsFormatJson RadarHTTPTimeseriesGroupOSParamsFormat = "JSON" - RadarHTTPTimeseriesGroupOSParamsFormatCsv RadarHTTPTimeseriesGroupOSParamsFormat = "CSV" -) - -type RadarHTTPTimeseriesGroupOSParamsHTTPProtocol string - -const ( - RadarHTTPTimeseriesGroupOSParamsHTTPProtocolHTTP RadarHTTPTimeseriesGroupOSParamsHTTPProtocol = "HTTP" - RadarHTTPTimeseriesGroupOSParamsHTTPProtocolHTTPS RadarHTTPTimeseriesGroupOSParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPTimeseriesGroupOSParamsHTTPVersion string - -const ( - RadarHTTPTimeseriesGroupOSParamsHTTPVersionHttPv1 RadarHTTPTimeseriesGroupOSParamsHTTPVersion = "HTTPv1" - RadarHTTPTimeseriesGroupOSParamsHTTPVersionHttPv2 RadarHTTPTimeseriesGroupOSParamsHTTPVersion = "HTTPv2" - RadarHTTPTimeseriesGroupOSParamsHTTPVersionHttPv3 RadarHTTPTimeseriesGroupOSParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPTimeseriesGroupOSParamsIPVersion string - -const ( - RadarHTTPTimeseriesGroupOSParamsIPVersionIPv4 RadarHTTPTimeseriesGroupOSParamsIPVersion = "IPv4" - RadarHTTPTimeseriesGroupOSParamsIPVersionIPv6 RadarHTTPTimeseriesGroupOSParamsIPVersion = "IPv6" -) - -type RadarHTTPTimeseriesGroupOSParamsTLSVersion string - -const ( - RadarHTTPTimeseriesGroupOSParamsTLSVersionTlSv1_0 RadarHTTPTimeseriesGroupOSParamsTLSVersion = "TLSv1_0" - RadarHTTPTimeseriesGroupOSParamsTLSVersionTlSv1_1 RadarHTTPTimeseriesGroupOSParamsTLSVersion = "TLSv1_1" - RadarHTTPTimeseriesGroupOSParamsTLSVersionTlSv1_2 RadarHTTPTimeseriesGroupOSParamsTLSVersion = "TLSv1_2" - RadarHTTPTimeseriesGroupOSParamsTLSVersionTlSv1_3 RadarHTTPTimeseriesGroupOSParamsTLSVersion = "TLSv1_3" - RadarHTTPTimeseriesGroupOSParamsTLSVersionTlSvQuic RadarHTTPTimeseriesGroupOSParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPTimeseriesGroupOSResponseEnvelope struct { - Result RadarHTTPTimeseriesGroupOSResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPTimeseriesGroupOSResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPTimeseriesGroupOSResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarHTTPTimeseriesGroupOSResponseEnvelope] -type radarHTTPTimeseriesGroupOSResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupOSResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupOSResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTimeseriesGroupTLSVersionParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarHTTPTimeseriesGroupTLSVersionParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPTimeseriesGroupTLSVersionParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPTimeseriesGroupTLSVersionParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPTimeseriesGroupTLSVersionParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPTimeseriesGroupTLSVersionParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPTimeseriesGroupTLSVersionParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPTimeseriesGroupTLSVersionParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPTimeseriesGroupTLSVersionParamsIPVersion] `query:"ipVersion"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPTimeseriesGroupTLSVersionParamsOS] `query:"os"` -} - -// URLQuery serializes [RadarHTTPTimeseriesGroupTLSVersionParams]'s query -// parameters as `url.Values`. -func (r RadarHTTPTimeseriesGroupTLSVersionParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarHTTPTimeseriesGroupTLSVersionParamsAggInterval string - -const ( - RadarHTTPTimeseriesGroupTLSVersionParamsAggInterval15m RadarHTTPTimeseriesGroupTLSVersionParamsAggInterval = "15m" - RadarHTTPTimeseriesGroupTLSVersionParamsAggInterval1h RadarHTTPTimeseriesGroupTLSVersionParamsAggInterval = "1h" - RadarHTTPTimeseriesGroupTLSVersionParamsAggInterval1d RadarHTTPTimeseriesGroupTLSVersionParamsAggInterval = "1d" - RadarHTTPTimeseriesGroupTLSVersionParamsAggInterval1w RadarHTTPTimeseriesGroupTLSVersionParamsAggInterval = "1w" -) - -type RadarHTTPTimeseriesGroupTLSVersionParamsBotClass string - -const ( - RadarHTTPTimeseriesGroupTLSVersionParamsBotClassLikelyAutomated RadarHTTPTimeseriesGroupTLSVersionParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPTimeseriesGroupTLSVersionParamsBotClassLikelyHuman RadarHTTPTimeseriesGroupTLSVersionParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPTimeseriesGroupTLSVersionParamsDateRange string - -const ( - RadarHTTPTimeseriesGroupTLSVersionParamsDateRange1d RadarHTTPTimeseriesGroupTLSVersionParamsDateRange = "1d" - RadarHTTPTimeseriesGroupTLSVersionParamsDateRange2d RadarHTTPTimeseriesGroupTLSVersionParamsDateRange = "2d" - RadarHTTPTimeseriesGroupTLSVersionParamsDateRange7d RadarHTTPTimeseriesGroupTLSVersionParamsDateRange = "7d" - RadarHTTPTimeseriesGroupTLSVersionParamsDateRange14d RadarHTTPTimeseriesGroupTLSVersionParamsDateRange = "14d" - RadarHTTPTimeseriesGroupTLSVersionParamsDateRange28d RadarHTTPTimeseriesGroupTLSVersionParamsDateRange = "28d" - RadarHTTPTimeseriesGroupTLSVersionParamsDateRange12w RadarHTTPTimeseriesGroupTLSVersionParamsDateRange = "12w" - RadarHTTPTimeseriesGroupTLSVersionParamsDateRange24w RadarHTTPTimeseriesGroupTLSVersionParamsDateRange = "24w" - RadarHTTPTimeseriesGroupTLSVersionParamsDateRange52w RadarHTTPTimeseriesGroupTLSVersionParamsDateRange = "52w" - RadarHTTPTimeseriesGroupTLSVersionParamsDateRange1dControl RadarHTTPTimeseriesGroupTLSVersionParamsDateRange = "1dControl" - RadarHTTPTimeseriesGroupTLSVersionParamsDateRange2dControl RadarHTTPTimeseriesGroupTLSVersionParamsDateRange = "2dControl" - RadarHTTPTimeseriesGroupTLSVersionParamsDateRange7dControl RadarHTTPTimeseriesGroupTLSVersionParamsDateRange = "7dControl" - RadarHTTPTimeseriesGroupTLSVersionParamsDateRange14dControl RadarHTTPTimeseriesGroupTLSVersionParamsDateRange = "14dControl" - RadarHTTPTimeseriesGroupTLSVersionParamsDateRange28dControl RadarHTTPTimeseriesGroupTLSVersionParamsDateRange = "28dControl" - RadarHTTPTimeseriesGroupTLSVersionParamsDateRange12wControl RadarHTTPTimeseriesGroupTLSVersionParamsDateRange = "12wControl" - RadarHTTPTimeseriesGroupTLSVersionParamsDateRange24wControl RadarHTTPTimeseriesGroupTLSVersionParamsDateRange = "24wControl" -) - -type RadarHTTPTimeseriesGroupTLSVersionParamsDeviceType string - -const ( - RadarHTTPTimeseriesGroupTLSVersionParamsDeviceTypeDesktop RadarHTTPTimeseriesGroupTLSVersionParamsDeviceType = "DESKTOP" - RadarHTTPTimeseriesGroupTLSVersionParamsDeviceTypeMobile RadarHTTPTimeseriesGroupTLSVersionParamsDeviceType = "MOBILE" - RadarHTTPTimeseriesGroupTLSVersionParamsDeviceTypeOther RadarHTTPTimeseriesGroupTLSVersionParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPTimeseriesGroupTLSVersionParamsFormat string - -const ( - RadarHTTPTimeseriesGroupTLSVersionParamsFormatJson RadarHTTPTimeseriesGroupTLSVersionParamsFormat = "JSON" - RadarHTTPTimeseriesGroupTLSVersionParamsFormatCsv RadarHTTPTimeseriesGroupTLSVersionParamsFormat = "CSV" -) - -type RadarHTTPTimeseriesGroupTLSVersionParamsHTTPProtocol string - -const ( - RadarHTTPTimeseriesGroupTLSVersionParamsHTTPProtocolHTTP RadarHTTPTimeseriesGroupTLSVersionParamsHTTPProtocol = "HTTP" - RadarHTTPTimeseriesGroupTLSVersionParamsHTTPProtocolHTTPS RadarHTTPTimeseriesGroupTLSVersionParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPTimeseriesGroupTLSVersionParamsHTTPVersion string - -const ( - RadarHTTPTimeseriesGroupTLSVersionParamsHTTPVersionHttPv1 RadarHTTPTimeseriesGroupTLSVersionParamsHTTPVersion = "HTTPv1" - RadarHTTPTimeseriesGroupTLSVersionParamsHTTPVersionHttPv2 RadarHTTPTimeseriesGroupTLSVersionParamsHTTPVersion = "HTTPv2" - RadarHTTPTimeseriesGroupTLSVersionParamsHTTPVersionHttPv3 RadarHTTPTimeseriesGroupTLSVersionParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPTimeseriesGroupTLSVersionParamsIPVersion string - -const ( - RadarHTTPTimeseriesGroupTLSVersionParamsIPVersionIPv4 RadarHTTPTimeseriesGroupTLSVersionParamsIPVersion = "IPv4" - RadarHTTPTimeseriesGroupTLSVersionParamsIPVersionIPv6 RadarHTTPTimeseriesGroupTLSVersionParamsIPVersion = "IPv6" -) - -type RadarHTTPTimeseriesGroupTLSVersionParamsOS string - -const ( - RadarHTTPTimeseriesGroupTLSVersionParamsOSWindows RadarHTTPTimeseriesGroupTLSVersionParamsOS = "WINDOWS" - RadarHTTPTimeseriesGroupTLSVersionParamsOSMacosx RadarHTTPTimeseriesGroupTLSVersionParamsOS = "MACOSX" - RadarHTTPTimeseriesGroupTLSVersionParamsOSIos RadarHTTPTimeseriesGroupTLSVersionParamsOS = "IOS" - RadarHTTPTimeseriesGroupTLSVersionParamsOSAndroid RadarHTTPTimeseriesGroupTLSVersionParamsOS = "ANDROID" - RadarHTTPTimeseriesGroupTLSVersionParamsOSChromeos RadarHTTPTimeseriesGroupTLSVersionParamsOS = "CHROMEOS" - RadarHTTPTimeseriesGroupTLSVersionParamsOSLinux RadarHTTPTimeseriesGroupTLSVersionParamsOS = "LINUX" - RadarHTTPTimeseriesGroupTLSVersionParamsOSSmartTv RadarHTTPTimeseriesGroupTLSVersionParamsOS = "SMART_TV" -) - -type RadarHTTPTimeseriesGroupTLSVersionResponseEnvelope struct { - Result RadarHTTPTimeseriesGroupTLSVersionResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPTimeseriesGroupTLSVersionResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPTimeseriesGroupTLSVersionResponseEnvelopeJSON contains the JSON -// metadata for the struct [RadarHTTPTimeseriesGroupTLSVersionResponseEnvelope] -type radarHTTPTimeseriesGroupTLSVersionResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTimeseriesGroupTLSVersionResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTimeseriesGroupTLSVersionResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttptimeseriesgroup_test.go b/radarhttptimeseriesgroup_test.go deleted file mode 100644 index 0472cbd714f..00000000000 --- a/radarhttptimeseriesgroup_test.go +++ /dev/null @@ -1,378 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPTimeseriesGroupBotClassWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.TimeseriesGroups.BotClass(context.TODO(), cloudflare.RadarHTTPTimeseriesGroupBotClassParams{ - AggInterval: cloudflare.F(cloudflare.RadarHTTPTimeseriesGroupBotClassParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBotClassParamsDateRange{cloudflare.RadarHTTPTimeseriesGroupBotClassParamsDateRange1d, cloudflare.RadarHTTPTimeseriesGroupBotClassParamsDateRange2d, cloudflare.RadarHTTPTimeseriesGroupBotClassParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBotClassParamsDeviceType{cloudflare.RadarHTTPTimeseriesGroupBotClassParamsDeviceTypeDesktop, cloudflare.RadarHTTPTimeseriesGroupBotClassParamsDeviceTypeMobile, cloudflare.RadarHTTPTimeseriesGroupBotClassParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPTimeseriesGroupBotClassParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBotClassParamsHTTPProtocol{cloudflare.RadarHTTPTimeseriesGroupBotClassParamsHTTPProtocolHTTP, cloudflare.RadarHTTPTimeseriesGroupBotClassParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBotClassParamsHTTPVersion{cloudflare.RadarHTTPTimeseriesGroupBotClassParamsHTTPVersionHttPv1, cloudflare.RadarHTTPTimeseriesGroupBotClassParamsHTTPVersionHttPv2, cloudflare.RadarHTTPTimeseriesGroupBotClassParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBotClassParamsIPVersion{cloudflare.RadarHTTPTimeseriesGroupBotClassParamsIPVersionIPv4, cloudflare.RadarHTTPTimeseriesGroupBotClassParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBotClassParamsOS{cloudflare.RadarHTTPTimeseriesGroupBotClassParamsOSWindows, cloudflare.RadarHTTPTimeseriesGroupBotClassParamsOSMacosx, cloudflare.RadarHTTPTimeseriesGroupBotClassParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBotClassParamsTLSVersion{cloudflare.RadarHTTPTimeseriesGroupBotClassParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPTimeseriesGroupBotClassParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPTimeseriesGroupBotClassParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarHTTPTimeseriesGroupBrowserWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.TimeseriesGroups.Browser(context.TODO(), cloudflare.RadarHTTPTimeseriesGroupBrowserParams{ - AggInterval: cloudflare.F(cloudflare.RadarHTTPTimeseriesGroupBrowserParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBrowserParamsBotClass{cloudflare.RadarHTTPTimeseriesGroupBrowserParamsBotClassLikelyAutomated, cloudflare.RadarHTTPTimeseriesGroupBrowserParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBrowserParamsDateRange{cloudflare.RadarHTTPTimeseriesGroupBrowserParamsDateRange1d, cloudflare.RadarHTTPTimeseriesGroupBrowserParamsDateRange2d, cloudflare.RadarHTTPTimeseriesGroupBrowserParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBrowserParamsDeviceType{cloudflare.RadarHTTPTimeseriesGroupBrowserParamsDeviceTypeDesktop, cloudflare.RadarHTTPTimeseriesGroupBrowserParamsDeviceTypeMobile, cloudflare.RadarHTTPTimeseriesGroupBrowserParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPTimeseriesGroupBrowserParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBrowserParamsHTTPProtocol{cloudflare.RadarHTTPTimeseriesGroupBrowserParamsHTTPProtocolHTTP, cloudflare.RadarHTTPTimeseriesGroupBrowserParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBrowserParamsHTTPVersion{cloudflare.RadarHTTPTimeseriesGroupBrowserParamsHTTPVersionHttPv1, cloudflare.RadarHTTPTimeseriesGroupBrowserParamsHTTPVersionHttPv2, cloudflare.RadarHTTPTimeseriesGroupBrowserParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBrowserParamsIPVersion{cloudflare.RadarHTTPTimeseriesGroupBrowserParamsIPVersionIPv4, cloudflare.RadarHTTPTimeseriesGroupBrowserParamsIPVersionIPv6}), - LimitPerGroup: cloudflare.F(int64(4)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBrowserParamsOS{cloudflare.RadarHTTPTimeseriesGroupBrowserParamsOSWindows, cloudflare.RadarHTTPTimeseriesGroupBrowserParamsOSMacosx, cloudflare.RadarHTTPTimeseriesGroupBrowserParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBrowserParamsTLSVersion{cloudflare.RadarHTTPTimeseriesGroupBrowserParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPTimeseriesGroupBrowserParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPTimeseriesGroupBrowserParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarHTTPTimeseriesGroupBrowserFamilyWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.TimeseriesGroups.BrowserFamily(context.TODO(), cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParams{ - AggInterval: cloudflare.F(cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsBotClass{cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsBotClassLikelyAutomated, cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange{cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange1d, cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange2d, cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsDeviceType{cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsDeviceTypeDesktop, cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsDeviceTypeMobile, cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPProtocol{cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPProtocolHTTP, cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPVersion{cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPVersionHttPv1, cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPVersionHttPv2, cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsIPVersion{cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsIPVersionIPv4, cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsOS{cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsOSWindows, cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsOSMacosx, cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsTLSVersion{cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPTimeseriesGroupBrowserFamilyParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarHTTPTimeseriesGroupDeviceTypeWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.TimeseriesGroups.DeviceType(context.TODO(), cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParams{ - AggInterval: cloudflare.F(cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsBotClass{cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsBotClassLikelyAutomated, cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange{cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange1d, cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange2d, cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPProtocol{cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPProtocolHTTP, cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPVersion{cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPVersionHttPv1, cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPVersionHttPv2, cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsIPVersion{cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsIPVersionIPv4, cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsOS{cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsOSWindows, cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsOSMacosx, cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsTLSVersion{cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPTimeseriesGroupDeviceTypeParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarHTTPTimeseriesGroupHTTPProtocolWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.TimeseriesGroups.HTTPProtocol(context.TODO(), cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParams{ - AggInterval: cloudflare.F(cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsBotClass{cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsBotClassLikelyAutomated, cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange{cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange1d, cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange2d, cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsDeviceType{cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsDeviceTypeDesktop, cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsDeviceTypeMobile, cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsFormatJson), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsHTTPVersion{cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsHTTPVersionHttPv1, cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsHTTPVersionHttPv2, cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsIPVersion{cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsIPVersionIPv4, cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsOS{cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsOSWindows, cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsOSMacosx, cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsTLSVersion{cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPTimeseriesGroupHTTPProtocolParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarHTTPTimeseriesGroupHTTPVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.TimeseriesGroups.HTTPVersion(context.TODO(), cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParams{ - AggInterval: cloudflare.F(cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsBotClass{cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsBotClassLikelyAutomated, cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange{cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange1d, cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange2d, cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsDeviceType{cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsDeviceTypeDesktop, cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsDeviceTypeMobile, cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsHTTPProtocol{cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsHTTPProtocolHTTP, cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsHTTPProtocolHTTPS}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsIPVersion{cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsIPVersionIPv4, cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsOS{cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsOSWindows, cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsOSMacosx, cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsTLSVersion{cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPTimeseriesGroupHTTPVersionParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarHTTPTimeseriesGroupIPVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.TimeseriesGroups.IPVersion(context.TODO(), cloudflare.RadarHTTPTimeseriesGroupIPVersionParams{ - AggInterval: cloudflare.F(cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsBotClass{cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsBotClassLikelyAutomated, cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsDateRange{cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsDateRange1d, cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsDateRange2d, cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsDeviceType{cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsDeviceTypeDesktop, cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsDeviceTypeMobile, cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsHTTPProtocol{cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsHTTPProtocolHTTP, cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsHTTPVersion{cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsHTTPVersionHttPv1, cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsHTTPVersionHttPv2, cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsHTTPVersionHttPv3}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsOS{cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsOSWindows, cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsOSMacosx, cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsTLSVersion{cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPTimeseriesGroupIPVersionParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarHTTPTimeseriesGroupOSWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.TimeseriesGroups.OS(context.TODO(), cloudflare.RadarHTTPTimeseriesGroupOSParams{ - AggInterval: cloudflare.F(cloudflare.RadarHTTPTimeseriesGroupOSParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupOSParamsBotClass{cloudflare.RadarHTTPTimeseriesGroupOSParamsBotClassLikelyAutomated, cloudflare.RadarHTTPTimeseriesGroupOSParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupOSParamsDateRange{cloudflare.RadarHTTPTimeseriesGroupOSParamsDateRange1d, cloudflare.RadarHTTPTimeseriesGroupOSParamsDateRange2d, cloudflare.RadarHTTPTimeseriesGroupOSParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupOSParamsDeviceType{cloudflare.RadarHTTPTimeseriesGroupOSParamsDeviceTypeDesktop, cloudflare.RadarHTTPTimeseriesGroupOSParamsDeviceTypeMobile, cloudflare.RadarHTTPTimeseriesGroupOSParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPTimeseriesGroupOSParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupOSParamsHTTPProtocol{cloudflare.RadarHTTPTimeseriesGroupOSParamsHTTPProtocolHTTP, cloudflare.RadarHTTPTimeseriesGroupOSParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupOSParamsHTTPVersion{cloudflare.RadarHTTPTimeseriesGroupOSParamsHTTPVersionHttPv1, cloudflare.RadarHTTPTimeseriesGroupOSParamsHTTPVersionHttPv2, cloudflare.RadarHTTPTimeseriesGroupOSParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupOSParamsIPVersion{cloudflare.RadarHTTPTimeseriesGroupOSParamsIPVersionIPv4, cloudflare.RadarHTTPTimeseriesGroupOSParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupOSParamsTLSVersion{cloudflare.RadarHTTPTimeseriesGroupOSParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPTimeseriesGroupOSParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPTimeseriesGroupOSParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarHTTPTimeseriesGroupTLSVersionWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.TimeseriesGroups.TLSVersion(context.TODO(), cloudflare.RadarHTTPTimeseriesGroupTLSVersionParams{ - AggInterval: cloudflare.F(cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsBotClass{cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsBotClassLikelyAutomated, cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsDateRange{cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsDateRange1d, cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsDateRange2d, cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsDeviceType{cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsDeviceTypeDesktop, cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsDeviceTypeMobile, cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsHTTPProtocol{cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsHTTPProtocolHTTP, cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsHTTPVersion{cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsHTTPVersionHttPv1, cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsHTTPVersionHttPv2, cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsIPVersion{cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsIPVersionIPv4, cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsIPVersionIPv6}), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsOS{cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsOSWindows, cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsOSMacosx, cloudflare.RadarHTTPTimeseriesGroupTLSVersionParamsOSIos}), - }) - 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/radarhttptop.go b/radarhttptop.go deleted file mode 100644 index b556861b089..00000000000 --- a/radarhttptop.go +++ /dev/null @@ -1,694 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarHTTPTopService 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 [NewRadarHTTPTopService] method -// instead. -type RadarHTTPTopService struct { - Options []option.RequestOption -} - -// NewRadarHTTPTopService 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 NewRadarHTTPTopService(opts ...option.RequestOption) (r *RadarHTTPTopService) { - r = &RadarHTTPTopService{} - r.Options = opts - return -} - -// Get the top user agents aggregated in families by HTTP traffic. Values are a -// percentage out of the total traffic. -func (r *RadarHTTPTopService) BrowserFamilies(ctx context.Context, query RadarHTTPTopBrowserFamiliesParams, opts ...option.RequestOption) (res *RadarHTTPTopBrowserFamiliesResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPTopBrowserFamiliesResponseEnvelope - path := "radar/http/top/browser_families" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the top user agents by HTTP traffic. Values are a percentage out of the -// total traffic. -func (r *RadarHTTPTopService) Browsers(ctx context.Context, query RadarHTTPTopBrowsersParams, opts ...option.RequestOption) (res *RadarHTTPTopBrowsersResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarHTTPTopBrowsersResponseEnvelope - path := "radar/http/top/browsers" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarHTTPTopBrowserFamiliesResponse struct { - Meta RadarHTTPTopBrowserFamiliesResponseMeta `json:"meta,required"` - Top0 []RadarHTTPTopBrowserFamiliesResponseTop0 `json:"top_0,required"` - JSON radarHTTPTopBrowserFamiliesResponseJSON `json:"-"` -} - -// radarHTTPTopBrowserFamiliesResponseJSON contains the JSON metadata for the -// struct [RadarHTTPTopBrowserFamiliesResponse] -type radarHTTPTopBrowserFamiliesResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTopBrowserFamiliesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTopBrowserFamiliesResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTopBrowserFamiliesResponseMeta struct { - DateRange []RadarHTTPTopBrowserFamiliesResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarHTTPTopBrowserFamiliesResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPTopBrowserFamiliesResponseMetaJSON `json:"-"` -} - -// radarHTTPTopBrowserFamiliesResponseMetaJSON contains the JSON metadata for the -// struct [RadarHTTPTopBrowserFamiliesResponseMeta] -type radarHTTPTopBrowserFamiliesResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTopBrowserFamiliesResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTopBrowserFamiliesResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTopBrowserFamiliesResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPTopBrowserFamiliesResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPTopBrowserFamiliesResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarHTTPTopBrowserFamiliesResponseMetaDateRange] -type radarHTTPTopBrowserFamiliesResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTopBrowserFamiliesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTopBrowserFamiliesResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTopBrowserFamiliesResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPTopBrowserFamiliesResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPTopBrowserFamiliesResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPTopBrowserFamiliesResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarHTTPTopBrowserFamiliesResponseMetaConfidenceInfo] -type radarHTTPTopBrowserFamiliesResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTopBrowserFamiliesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTopBrowserFamiliesResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTopBrowserFamiliesResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPTopBrowserFamiliesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPTopBrowserFamiliesResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarHTTPTopBrowserFamiliesResponseMetaConfidenceInfoAnnotation] -type radarHTTPTopBrowserFamiliesResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTopBrowserFamiliesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTopBrowserFamiliesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTopBrowserFamiliesResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON radarHTTPTopBrowserFamiliesResponseTop0JSON `json:"-"` -} - -// radarHTTPTopBrowserFamiliesResponseTop0JSON contains the JSON metadata for the -// struct [RadarHTTPTopBrowserFamiliesResponseTop0] -type radarHTTPTopBrowserFamiliesResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTopBrowserFamiliesResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTopBrowserFamiliesResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTopBrowsersResponse struct { - Meta RadarHTTPTopBrowsersResponseMeta `json:"meta,required"` - Top0 []RadarHTTPTopBrowsersResponseTop0 `json:"top_0,required"` - JSON radarHTTPTopBrowsersResponseJSON `json:"-"` -} - -// radarHTTPTopBrowsersResponseJSON contains the JSON metadata for the struct -// [RadarHTTPTopBrowsersResponse] -type radarHTTPTopBrowsersResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTopBrowsersResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTopBrowsersResponseJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTopBrowsersResponseMeta struct { - DateRange []RadarHTTPTopBrowsersResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarHTTPTopBrowsersResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarHTTPTopBrowsersResponseMetaJSON `json:"-"` -} - -// radarHTTPTopBrowsersResponseMetaJSON contains the JSON metadata for the struct -// [RadarHTTPTopBrowsersResponseMeta] -type radarHTTPTopBrowsersResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTopBrowsersResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTopBrowsersResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTopBrowsersResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarHTTPTopBrowsersResponseMetaDateRangeJSON `json:"-"` -} - -// radarHTTPTopBrowsersResponseMetaDateRangeJSON contains the JSON metadata for the -// struct [RadarHTTPTopBrowsersResponseMetaDateRange] -type radarHTTPTopBrowsersResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTopBrowsersResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTopBrowsersResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTopBrowsersResponseMetaConfidenceInfo struct { - Annotations []RadarHTTPTopBrowsersResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarHTTPTopBrowsersResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarHTTPTopBrowsersResponseMetaConfidenceInfoJSON contains the JSON metadata -// for the struct [RadarHTTPTopBrowsersResponseMetaConfidenceInfo] -type radarHTTPTopBrowsersResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTopBrowsersResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTopBrowsersResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTopBrowsersResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarHTTPTopBrowsersResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarHTTPTopBrowsersResponseMetaConfidenceInfoAnnotationJSON contains the JSON -// metadata for the struct -// [RadarHTTPTopBrowsersResponseMetaConfidenceInfoAnnotation] -type radarHTTPTopBrowsersResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTopBrowsersResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTopBrowsersResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTopBrowsersResponseTop0 struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON radarHTTPTopBrowsersResponseTop0JSON `json:"-"` -} - -// radarHTTPTopBrowsersResponseTop0JSON contains the JSON metadata for the struct -// [RadarHTTPTopBrowsersResponseTop0] -type radarHTTPTopBrowsersResponseTop0JSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTopBrowsersResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTopBrowsersResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTopBrowserFamiliesParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPTopBrowserFamiliesParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPTopBrowserFamiliesParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPTopBrowserFamiliesParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPTopBrowserFamiliesParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPTopBrowserFamiliesParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPTopBrowserFamiliesParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPTopBrowserFamiliesParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPTopBrowserFamiliesParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPTopBrowserFamiliesParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPTopBrowserFamiliesParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPTopBrowserFamiliesParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarHTTPTopBrowserFamiliesParamsBotClass string - -const ( - RadarHTTPTopBrowserFamiliesParamsBotClassLikelyAutomated RadarHTTPTopBrowserFamiliesParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPTopBrowserFamiliesParamsBotClassLikelyHuman RadarHTTPTopBrowserFamiliesParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPTopBrowserFamiliesParamsDateRange string - -const ( - RadarHTTPTopBrowserFamiliesParamsDateRange1d RadarHTTPTopBrowserFamiliesParamsDateRange = "1d" - RadarHTTPTopBrowserFamiliesParamsDateRange2d RadarHTTPTopBrowserFamiliesParamsDateRange = "2d" - RadarHTTPTopBrowserFamiliesParamsDateRange7d RadarHTTPTopBrowserFamiliesParamsDateRange = "7d" - RadarHTTPTopBrowserFamiliesParamsDateRange14d RadarHTTPTopBrowserFamiliesParamsDateRange = "14d" - RadarHTTPTopBrowserFamiliesParamsDateRange28d RadarHTTPTopBrowserFamiliesParamsDateRange = "28d" - RadarHTTPTopBrowserFamiliesParamsDateRange12w RadarHTTPTopBrowserFamiliesParamsDateRange = "12w" - RadarHTTPTopBrowserFamiliesParamsDateRange24w RadarHTTPTopBrowserFamiliesParamsDateRange = "24w" - RadarHTTPTopBrowserFamiliesParamsDateRange52w RadarHTTPTopBrowserFamiliesParamsDateRange = "52w" - RadarHTTPTopBrowserFamiliesParamsDateRange1dControl RadarHTTPTopBrowserFamiliesParamsDateRange = "1dControl" - RadarHTTPTopBrowserFamiliesParamsDateRange2dControl RadarHTTPTopBrowserFamiliesParamsDateRange = "2dControl" - RadarHTTPTopBrowserFamiliesParamsDateRange7dControl RadarHTTPTopBrowserFamiliesParamsDateRange = "7dControl" - RadarHTTPTopBrowserFamiliesParamsDateRange14dControl RadarHTTPTopBrowserFamiliesParamsDateRange = "14dControl" - RadarHTTPTopBrowserFamiliesParamsDateRange28dControl RadarHTTPTopBrowserFamiliesParamsDateRange = "28dControl" - RadarHTTPTopBrowserFamiliesParamsDateRange12wControl RadarHTTPTopBrowserFamiliesParamsDateRange = "12wControl" - RadarHTTPTopBrowserFamiliesParamsDateRange24wControl RadarHTTPTopBrowserFamiliesParamsDateRange = "24wControl" -) - -type RadarHTTPTopBrowserFamiliesParamsDeviceType string - -const ( - RadarHTTPTopBrowserFamiliesParamsDeviceTypeDesktop RadarHTTPTopBrowserFamiliesParamsDeviceType = "DESKTOP" - RadarHTTPTopBrowserFamiliesParamsDeviceTypeMobile RadarHTTPTopBrowserFamiliesParamsDeviceType = "MOBILE" - RadarHTTPTopBrowserFamiliesParamsDeviceTypeOther RadarHTTPTopBrowserFamiliesParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPTopBrowserFamiliesParamsFormat string - -const ( - RadarHTTPTopBrowserFamiliesParamsFormatJson RadarHTTPTopBrowserFamiliesParamsFormat = "JSON" - RadarHTTPTopBrowserFamiliesParamsFormatCsv RadarHTTPTopBrowserFamiliesParamsFormat = "CSV" -) - -type RadarHTTPTopBrowserFamiliesParamsHTTPProtocol string - -const ( - RadarHTTPTopBrowserFamiliesParamsHTTPProtocolHTTP RadarHTTPTopBrowserFamiliesParamsHTTPProtocol = "HTTP" - RadarHTTPTopBrowserFamiliesParamsHTTPProtocolHTTPS RadarHTTPTopBrowserFamiliesParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPTopBrowserFamiliesParamsHTTPVersion string - -const ( - RadarHTTPTopBrowserFamiliesParamsHTTPVersionHttPv1 RadarHTTPTopBrowserFamiliesParamsHTTPVersion = "HTTPv1" - RadarHTTPTopBrowserFamiliesParamsHTTPVersionHttPv2 RadarHTTPTopBrowserFamiliesParamsHTTPVersion = "HTTPv2" - RadarHTTPTopBrowserFamiliesParamsHTTPVersionHttPv3 RadarHTTPTopBrowserFamiliesParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPTopBrowserFamiliesParamsIPVersion string - -const ( - RadarHTTPTopBrowserFamiliesParamsIPVersionIPv4 RadarHTTPTopBrowserFamiliesParamsIPVersion = "IPv4" - RadarHTTPTopBrowserFamiliesParamsIPVersionIPv6 RadarHTTPTopBrowserFamiliesParamsIPVersion = "IPv6" -) - -type RadarHTTPTopBrowserFamiliesParamsOS string - -const ( - RadarHTTPTopBrowserFamiliesParamsOSWindows RadarHTTPTopBrowserFamiliesParamsOS = "WINDOWS" - RadarHTTPTopBrowserFamiliesParamsOSMacosx RadarHTTPTopBrowserFamiliesParamsOS = "MACOSX" - RadarHTTPTopBrowserFamiliesParamsOSIos RadarHTTPTopBrowserFamiliesParamsOS = "IOS" - RadarHTTPTopBrowserFamiliesParamsOSAndroid RadarHTTPTopBrowserFamiliesParamsOS = "ANDROID" - RadarHTTPTopBrowserFamiliesParamsOSChromeos RadarHTTPTopBrowserFamiliesParamsOS = "CHROMEOS" - RadarHTTPTopBrowserFamiliesParamsOSLinux RadarHTTPTopBrowserFamiliesParamsOS = "LINUX" - RadarHTTPTopBrowserFamiliesParamsOSSmartTv RadarHTTPTopBrowserFamiliesParamsOS = "SMART_TV" -) - -type RadarHTTPTopBrowserFamiliesParamsTLSVersion string - -const ( - RadarHTTPTopBrowserFamiliesParamsTLSVersionTlSv1_0 RadarHTTPTopBrowserFamiliesParamsTLSVersion = "TLSv1_0" - RadarHTTPTopBrowserFamiliesParamsTLSVersionTlSv1_1 RadarHTTPTopBrowserFamiliesParamsTLSVersion = "TLSv1_1" - RadarHTTPTopBrowserFamiliesParamsTLSVersionTlSv1_2 RadarHTTPTopBrowserFamiliesParamsTLSVersion = "TLSv1_2" - RadarHTTPTopBrowserFamiliesParamsTLSVersionTlSv1_3 RadarHTTPTopBrowserFamiliesParamsTLSVersion = "TLSv1_3" - RadarHTTPTopBrowserFamiliesParamsTLSVersionTlSvQuic RadarHTTPTopBrowserFamiliesParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPTopBrowserFamiliesResponseEnvelope struct { - Result RadarHTTPTopBrowserFamiliesResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPTopBrowserFamiliesResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPTopBrowserFamiliesResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarHTTPTopBrowserFamiliesResponseEnvelope] -type radarHTTPTopBrowserFamiliesResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTopBrowserFamiliesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTopBrowserFamiliesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarHTTPTopBrowsersParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Filter for bot class. Refer to - // [Bot classes](https://developers.cloudflare.com/radar/concepts/bot-classes/). - BotClass param.Field[[]RadarHTTPTopBrowsersParamsBotClass] `query:"botClass"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarHTTPTopBrowsersParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Filter for device type. - DeviceType param.Field[[]RadarHTTPTopBrowsersParamsDeviceType] `query:"deviceType"` - // Format results are returned in. - Format param.Field[RadarHTTPTopBrowsersParamsFormat] `query:"format"` - // Filter for http protocol. - HTTPProtocol param.Field[[]RadarHTTPTopBrowsersParamsHTTPProtocol] `query:"httpProtocol"` - // Filter for http version. - HTTPVersion param.Field[[]RadarHTTPTopBrowsersParamsHTTPVersion] `query:"httpVersion"` - // Filter for ip version. - IPVersion param.Field[[]RadarHTTPTopBrowsersParamsIPVersion] `query:"ipVersion"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Filter for os name. - OS param.Field[[]RadarHTTPTopBrowsersParamsOS] `query:"os"` - // Filter for tls version. - TLSVersion param.Field[[]RadarHTTPTopBrowsersParamsTLSVersion] `query:"tlsVersion"` -} - -// URLQuery serializes [RadarHTTPTopBrowsersParams]'s query parameters as -// `url.Values`. -func (r RadarHTTPTopBrowsersParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarHTTPTopBrowsersParamsBotClass string - -const ( - RadarHTTPTopBrowsersParamsBotClassLikelyAutomated RadarHTTPTopBrowsersParamsBotClass = "LIKELY_AUTOMATED" - RadarHTTPTopBrowsersParamsBotClassLikelyHuman RadarHTTPTopBrowsersParamsBotClass = "LIKELY_HUMAN" -) - -type RadarHTTPTopBrowsersParamsDateRange string - -const ( - RadarHTTPTopBrowsersParamsDateRange1d RadarHTTPTopBrowsersParamsDateRange = "1d" - RadarHTTPTopBrowsersParamsDateRange2d RadarHTTPTopBrowsersParamsDateRange = "2d" - RadarHTTPTopBrowsersParamsDateRange7d RadarHTTPTopBrowsersParamsDateRange = "7d" - RadarHTTPTopBrowsersParamsDateRange14d RadarHTTPTopBrowsersParamsDateRange = "14d" - RadarHTTPTopBrowsersParamsDateRange28d RadarHTTPTopBrowsersParamsDateRange = "28d" - RadarHTTPTopBrowsersParamsDateRange12w RadarHTTPTopBrowsersParamsDateRange = "12w" - RadarHTTPTopBrowsersParamsDateRange24w RadarHTTPTopBrowsersParamsDateRange = "24w" - RadarHTTPTopBrowsersParamsDateRange52w RadarHTTPTopBrowsersParamsDateRange = "52w" - RadarHTTPTopBrowsersParamsDateRange1dControl RadarHTTPTopBrowsersParamsDateRange = "1dControl" - RadarHTTPTopBrowsersParamsDateRange2dControl RadarHTTPTopBrowsersParamsDateRange = "2dControl" - RadarHTTPTopBrowsersParamsDateRange7dControl RadarHTTPTopBrowsersParamsDateRange = "7dControl" - RadarHTTPTopBrowsersParamsDateRange14dControl RadarHTTPTopBrowsersParamsDateRange = "14dControl" - RadarHTTPTopBrowsersParamsDateRange28dControl RadarHTTPTopBrowsersParamsDateRange = "28dControl" - RadarHTTPTopBrowsersParamsDateRange12wControl RadarHTTPTopBrowsersParamsDateRange = "12wControl" - RadarHTTPTopBrowsersParamsDateRange24wControl RadarHTTPTopBrowsersParamsDateRange = "24wControl" -) - -type RadarHTTPTopBrowsersParamsDeviceType string - -const ( - RadarHTTPTopBrowsersParamsDeviceTypeDesktop RadarHTTPTopBrowsersParamsDeviceType = "DESKTOP" - RadarHTTPTopBrowsersParamsDeviceTypeMobile RadarHTTPTopBrowsersParamsDeviceType = "MOBILE" - RadarHTTPTopBrowsersParamsDeviceTypeOther RadarHTTPTopBrowsersParamsDeviceType = "OTHER" -) - -// Format results are returned in. -type RadarHTTPTopBrowsersParamsFormat string - -const ( - RadarHTTPTopBrowsersParamsFormatJson RadarHTTPTopBrowsersParamsFormat = "JSON" - RadarHTTPTopBrowsersParamsFormatCsv RadarHTTPTopBrowsersParamsFormat = "CSV" -) - -type RadarHTTPTopBrowsersParamsHTTPProtocol string - -const ( - RadarHTTPTopBrowsersParamsHTTPProtocolHTTP RadarHTTPTopBrowsersParamsHTTPProtocol = "HTTP" - RadarHTTPTopBrowsersParamsHTTPProtocolHTTPS RadarHTTPTopBrowsersParamsHTTPProtocol = "HTTPS" -) - -type RadarHTTPTopBrowsersParamsHTTPVersion string - -const ( - RadarHTTPTopBrowsersParamsHTTPVersionHttPv1 RadarHTTPTopBrowsersParamsHTTPVersion = "HTTPv1" - RadarHTTPTopBrowsersParamsHTTPVersionHttPv2 RadarHTTPTopBrowsersParamsHTTPVersion = "HTTPv2" - RadarHTTPTopBrowsersParamsHTTPVersionHttPv3 RadarHTTPTopBrowsersParamsHTTPVersion = "HTTPv3" -) - -type RadarHTTPTopBrowsersParamsIPVersion string - -const ( - RadarHTTPTopBrowsersParamsIPVersionIPv4 RadarHTTPTopBrowsersParamsIPVersion = "IPv4" - RadarHTTPTopBrowsersParamsIPVersionIPv6 RadarHTTPTopBrowsersParamsIPVersion = "IPv6" -) - -type RadarHTTPTopBrowsersParamsOS string - -const ( - RadarHTTPTopBrowsersParamsOSWindows RadarHTTPTopBrowsersParamsOS = "WINDOWS" - RadarHTTPTopBrowsersParamsOSMacosx RadarHTTPTopBrowsersParamsOS = "MACOSX" - RadarHTTPTopBrowsersParamsOSIos RadarHTTPTopBrowsersParamsOS = "IOS" - RadarHTTPTopBrowsersParamsOSAndroid RadarHTTPTopBrowsersParamsOS = "ANDROID" - RadarHTTPTopBrowsersParamsOSChromeos RadarHTTPTopBrowsersParamsOS = "CHROMEOS" - RadarHTTPTopBrowsersParamsOSLinux RadarHTTPTopBrowsersParamsOS = "LINUX" - RadarHTTPTopBrowsersParamsOSSmartTv RadarHTTPTopBrowsersParamsOS = "SMART_TV" -) - -type RadarHTTPTopBrowsersParamsTLSVersion string - -const ( - RadarHTTPTopBrowsersParamsTLSVersionTlSv1_0 RadarHTTPTopBrowsersParamsTLSVersion = "TLSv1_0" - RadarHTTPTopBrowsersParamsTLSVersionTlSv1_1 RadarHTTPTopBrowsersParamsTLSVersion = "TLSv1_1" - RadarHTTPTopBrowsersParamsTLSVersionTlSv1_2 RadarHTTPTopBrowsersParamsTLSVersion = "TLSv1_2" - RadarHTTPTopBrowsersParamsTLSVersionTlSv1_3 RadarHTTPTopBrowsersParamsTLSVersion = "TLSv1_3" - RadarHTTPTopBrowsersParamsTLSVersionTlSvQuic RadarHTTPTopBrowsersParamsTLSVersion = "TLSvQUIC" -) - -type RadarHTTPTopBrowsersResponseEnvelope struct { - Result RadarHTTPTopBrowsersResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarHTTPTopBrowsersResponseEnvelopeJSON `json:"-"` -} - -// radarHTTPTopBrowsersResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarHTTPTopBrowsersResponseEnvelope] -type radarHTTPTopBrowsersResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarHTTPTopBrowsersResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarHTTPTopBrowsersResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarhttptop_test.go b/radarhttptop_test.go deleted file mode 100644 index 87f8e298ffc..00000000000 --- a/radarhttptop_test.go +++ /dev/null @@ -1,97 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarHTTPTopBrowserFamiliesWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Top.BrowserFamilies(context.TODO(), cloudflare.RadarHTTPTopBrowserFamiliesParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPTopBrowserFamiliesParamsBotClass{cloudflare.RadarHTTPTopBrowserFamiliesParamsBotClassLikelyAutomated, cloudflare.RadarHTTPTopBrowserFamiliesParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPTopBrowserFamiliesParamsDateRange{cloudflare.RadarHTTPTopBrowserFamiliesParamsDateRange1d, cloudflare.RadarHTTPTopBrowserFamiliesParamsDateRange2d, cloudflare.RadarHTTPTopBrowserFamiliesParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPTopBrowserFamiliesParamsDeviceType{cloudflare.RadarHTTPTopBrowserFamiliesParamsDeviceTypeDesktop, cloudflare.RadarHTTPTopBrowserFamiliesParamsDeviceTypeMobile, cloudflare.RadarHTTPTopBrowserFamiliesParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPTopBrowserFamiliesParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPTopBrowserFamiliesParamsHTTPProtocol{cloudflare.RadarHTTPTopBrowserFamiliesParamsHTTPProtocolHTTP, cloudflare.RadarHTTPTopBrowserFamiliesParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPTopBrowserFamiliesParamsHTTPVersion{cloudflare.RadarHTTPTopBrowserFamiliesParamsHTTPVersionHttPv1, cloudflare.RadarHTTPTopBrowserFamiliesParamsHTTPVersionHttPv2, cloudflare.RadarHTTPTopBrowserFamiliesParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPTopBrowserFamiliesParamsIPVersion{cloudflare.RadarHTTPTopBrowserFamiliesParamsIPVersionIPv4, cloudflare.RadarHTTPTopBrowserFamiliesParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPTopBrowserFamiliesParamsOS{cloudflare.RadarHTTPTopBrowserFamiliesParamsOSWindows, cloudflare.RadarHTTPTopBrowserFamiliesParamsOSMacosx, cloudflare.RadarHTTPTopBrowserFamiliesParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPTopBrowserFamiliesParamsTLSVersion{cloudflare.RadarHTTPTopBrowserFamiliesParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPTopBrowserFamiliesParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPTopBrowserFamiliesParamsTLSVersionTlSv1_2}), - }) - 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 TestRadarHTTPTopBrowsersWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.HTTP.Top.Browsers(context.TODO(), cloudflare.RadarHTTPTopBrowsersParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BotClass: cloudflare.F([]cloudflare.RadarHTTPTopBrowsersParamsBotClass{cloudflare.RadarHTTPTopBrowsersParamsBotClassLikelyAutomated, cloudflare.RadarHTTPTopBrowsersParamsBotClassLikelyHuman}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarHTTPTopBrowsersParamsDateRange{cloudflare.RadarHTTPTopBrowsersParamsDateRange1d, cloudflare.RadarHTTPTopBrowsersParamsDateRange2d, cloudflare.RadarHTTPTopBrowsersParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DeviceType: cloudflare.F([]cloudflare.RadarHTTPTopBrowsersParamsDeviceType{cloudflare.RadarHTTPTopBrowsersParamsDeviceTypeDesktop, cloudflare.RadarHTTPTopBrowsersParamsDeviceTypeMobile, cloudflare.RadarHTTPTopBrowsersParamsDeviceTypeOther}), - Format: cloudflare.F(cloudflare.RadarHTTPTopBrowsersParamsFormatJson), - HTTPProtocol: cloudflare.F([]cloudflare.RadarHTTPTopBrowsersParamsHTTPProtocol{cloudflare.RadarHTTPTopBrowsersParamsHTTPProtocolHTTP, cloudflare.RadarHTTPTopBrowsersParamsHTTPProtocolHTTPS}), - HTTPVersion: cloudflare.F([]cloudflare.RadarHTTPTopBrowsersParamsHTTPVersion{cloudflare.RadarHTTPTopBrowsersParamsHTTPVersionHttPv1, cloudflare.RadarHTTPTopBrowsersParamsHTTPVersionHttPv2, cloudflare.RadarHTTPTopBrowsersParamsHTTPVersionHttPv3}), - IPVersion: cloudflare.F([]cloudflare.RadarHTTPTopBrowsersParamsIPVersion{cloudflare.RadarHTTPTopBrowsersParamsIPVersionIPv4, cloudflare.RadarHTTPTopBrowsersParamsIPVersionIPv6}), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OS: cloudflare.F([]cloudflare.RadarHTTPTopBrowsersParamsOS{cloudflare.RadarHTTPTopBrowsersParamsOSWindows, cloudflare.RadarHTTPTopBrowsersParamsOSMacosx, cloudflare.RadarHTTPTopBrowsersParamsOSIos}), - TLSVersion: cloudflare.F([]cloudflare.RadarHTTPTopBrowsersParamsTLSVersion{cloudflare.RadarHTTPTopBrowsersParamsTLSVersionTlSv1_0, cloudflare.RadarHTTPTopBrowsersParamsTLSVersionTlSv1_1, cloudflare.RadarHTTPTopBrowsersParamsTLSVersionTlSv1_2}), - }) - 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/radarnetflow.go b/radarnetflow.go deleted file mode 100644 index 44d586f0e7f..00000000000 --- a/radarnetflow.go +++ /dev/null @@ -1,329 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarNetflowService 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 [NewRadarNetflowService] method -// instead. -type RadarNetflowService struct { - Options []option.RequestOption - Top *RadarNetflowTopService -} - -// NewRadarNetflowService 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 NewRadarNetflowService(opts ...option.RequestOption) (r *RadarNetflowService) { - r = &RadarNetflowService{} - r.Options = opts - r.Top = NewRadarNetflowTopService(opts...) - return -} - -// Get network traffic change over time. Visit -// https://en.wikipedia.org/wiki/NetFlow for more information on NetFlows. -func (r *RadarNetflowService) Timeseries(ctx context.Context, query RadarNetflowTimeseriesParams, opts ...option.RequestOption) (res *RadarNetflowTimeseriesResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarNetflowTimeseriesResponseEnvelope - path := "radar/netflows/timeseries" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarNetflowTimeseriesResponse struct { - Meta RadarNetflowTimeseriesResponseMeta `json:"meta,required"` - Serie0 RadarNetflowTimeseriesResponseSerie0 `json:"serie_0,required"` - JSON radarNetflowTimeseriesResponseJSON `json:"-"` -} - -// radarNetflowTimeseriesResponseJSON contains the JSON metadata for the struct -// [RadarNetflowTimeseriesResponse] -type radarNetflowTimeseriesResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarNetflowTimeseriesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarNetflowTimeseriesResponseJSON) RawJSON() string { - return r.raw -} - -type RadarNetflowTimeseriesResponseMeta struct { - AggInterval string `json:"aggInterval,required"` - DateRange []RadarNetflowTimeseriesResponseMetaDateRange `json:"dateRange,required"` - LastUpdated time.Time `json:"lastUpdated,required" format:"date-time"` - ConfidenceInfo RadarNetflowTimeseriesResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarNetflowTimeseriesResponseMetaJSON `json:"-"` -} - -// radarNetflowTimeseriesResponseMetaJSON contains the JSON metadata for the struct -// [RadarNetflowTimeseriesResponseMeta] -type radarNetflowTimeseriesResponseMetaJSON struct { - AggInterval apijson.Field - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarNetflowTimeseriesResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarNetflowTimeseriesResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarNetflowTimeseriesResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarNetflowTimeseriesResponseMetaDateRangeJSON `json:"-"` -} - -// radarNetflowTimeseriesResponseMetaDateRangeJSON contains the JSON metadata for -// the struct [RadarNetflowTimeseriesResponseMetaDateRange] -type radarNetflowTimeseriesResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarNetflowTimeseriesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarNetflowTimeseriesResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarNetflowTimeseriesResponseMetaConfidenceInfo struct { - Annotations []RadarNetflowTimeseriesResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarNetflowTimeseriesResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarNetflowTimeseriesResponseMetaConfidenceInfoJSON contains the JSON metadata -// for the struct [RadarNetflowTimeseriesResponseMetaConfidenceInfo] -type radarNetflowTimeseriesResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarNetflowTimeseriesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarNetflowTimeseriesResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarNetflowTimeseriesResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarNetflowTimeseriesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarNetflowTimeseriesResponseMetaConfidenceInfoAnnotationJSON contains the JSON -// metadata for the struct -// [RadarNetflowTimeseriesResponseMetaConfidenceInfoAnnotation] -type radarNetflowTimeseriesResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarNetflowTimeseriesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarNetflowTimeseriesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarNetflowTimeseriesResponseSerie0 struct { - Timestamps []time.Time `json:"timestamps,required" format:"date-time"` - Values []string `json:"values,required"` - JSON radarNetflowTimeseriesResponseSerie0JSON `json:"-"` -} - -// radarNetflowTimeseriesResponseSerie0JSON contains the JSON metadata for the -// struct [RadarNetflowTimeseriesResponseSerie0] -type radarNetflowTimeseriesResponseSerie0JSON struct { - Timestamps apijson.Field - Values apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarNetflowTimeseriesResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarNetflowTimeseriesResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarNetflowTimeseriesParams struct { - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarNetflowTimeseriesParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarNetflowTimeseriesParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarNetflowTimeseriesParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Normalization method applied. Refer to - // [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). - Normalization param.Field[RadarNetflowTimeseriesParamsNormalization] `query:"normalization"` - // Array of network traffic product types. - Product param.Field[[]RadarNetflowTimeseriesParamsProduct] `query:"product"` -} - -// URLQuery serializes [RadarNetflowTimeseriesParams]'s query parameters as -// `url.Values`. -func (r RadarNetflowTimeseriesParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarNetflowTimeseriesParamsAggInterval string - -const ( - RadarNetflowTimeseriesParamsAggInterval15m RadarNetflowTimeseriesParamsAggInterval = "15m" - RadarNetflowTimeseriesParamsAggInterval1h RadarNetflowTimeseriesParamsAggInterval = "1h" - RadarNetflowTimeseriesParamsAggInterval1d RadarNetflowTimeseriesParamsAggInterval = "1d" - RadarNetflowTimeseriesParamsAggInterval1w RadarNetflowTimeseriesParamsAggInterval = "1w" -) - -type RadarNetflowTimeseriesParamsDateRange string - -const ( - RadarNetflowTimeseriesParamsDateRange1d RadarNetflowTimeseriesParamsDateRange = "1d" - RadarNetflowTimeseriesParamsDateRange2d RadarNetflowTimeseriesParamsDateRange = "2d" - RadarNetflowTimeseriesParamsDateRange7d RadarNetflowTimeseriesParamsDateRange = "7d" - RadarNetflowTimeseriesParamsDateRange14d RadarNetflowTimeseriesParamsDateRange = "14d" - RadarNetflowTimeseriesParamsDateRange28d RadarNetflowTimeseriesParamsDateRange = "28d" - RadarNetflowTimeseriesParamsDateRange12w RadarNetflowTimeseriesParamsDateRange = "12w" - RadarNetflowTimeseriesParamsDateRange24w RadarNetflowTimeseriesParamsDateRange = "24w" - RadarNetflowTimeseriesParamsDateRange52w RadarNetflowTimeseriesParamsDateRange = "52w" - RadarNetflowTimeseriesParamsDateRange1dControl RadarNetflowTimeseriesParamsDateRange = "1dControl" - RadarNetflowTimeseriesParamsDateRange2dControl RadarNetflowTimeseriesParamsDateRange = "2dControl" - RadarNetflowTimeseriesParamsDateRange7dControl RadarNetflowTimeseriesParamsDateRange = "7dControl" - RadarNetflowTimeseriesParamsDateRange14dControl RadarNetflowTimeseriesParamsDateRange = "14dControl" - RadarNetflowTimeseriesParamsDateRange28dControl RadarNetflowTimeseriesParamsDateRange = "28dControl" - RadarNetflowTimeseriesParamsDateRange12wControl RadarNetflowTimeseriesParamsDateRange = "12wControl" - RadarNetflowTimeseriesParamsDateRange24wControl RadarNetflowTimeseriesParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarNetflowTimeseriesParamsFormat string - -const ( - RadarNetflowTimeseriesParamsFormatJson RadarNetflowTimeseriesParamsFormat = "JSON" - RadarNetflowTimeseriesParamsFormatCsv RadarNetflowTimeseriesParamsFormat = "CSV" -) - -// Normalization method applied. Refer to -// [Normalization methods](https://developers.cloudflare.com/radar/concepts/normalization/). -type RadarNetflowTimeseriesParamsNormalization string - -const ( - RadarNetflowTimeseriesParamsNormalizationPercentageChange RadarNetflowTimeseriesParamsNormalization = "PERCENTAGE_CHANGE" - RadarNetflowTimeseriesParamsNormalizationMin0Max RadarNetflowTimeseriesParamsNormalization = "MIN0_MAX" -) - -type RadarNetflowTimeseriesParamsProduct string - -const ( - RadarNetflowTimeseriesParamsProductHTTP RadarNetflowTimeseriesParamsProduct = "HTTP" - RadarNetflowTimeseriesParamsProductAll RadarNetflowTimeseriesParamsProduct = "ALL" -) - -type RadarNetflowTimeseriesResponseEnvelope struct { - Result RadarNetflowTimeseriesResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarNetflowTimeseriesResponseEnvelopeJSON `json:"-"` -} - -// radarNetflowTimeseriesResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarNetflowTimeseriesResponseEnvelope] -type radarNetflowTimeseriesResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarNetflowTimeseriesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarNetflowTimeseriesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarnetflow_test.go b/radarnetflow_test.go deleted file mode 100644 index f824c9f19f7..00000000000 --- a/radarnetflow_test.go +++ /dev/null @@ -1,51 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarNetflowTimeseriesWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Netflows.Timeseries(context.TODO(), cloudflare.RadarNetflowTimeseriesParams{ - AggInterval: cloudflare.F(cloudflare.RadarNetflowTimeseriesParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarNetflowTimeseriesParamsDateRange{cloudflare.RadarNetflowTimeseriesParamsDateRange1d, cloudflare.RadarNetflowTimeseriesParamsDateRange2d, cloudflare.RadarNetflowTimeseriesParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarNetflowTimeseriesParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - Normalization: cloudflare.F(cloudflare.RadarNetflowTimeseriesParamsNormalizationMin0Max), - Product: cloudflare.F([]cloudflare.RadarNetflowTimeseriesParamsProduct{cloudflare.RadarNetflowTimeseriesParamsProductHTTP, cloudflare.RadarNetflowTimeseriesParamsProductAll}), - }) - 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/radarnetflowtop.go b/radarnetflowtop.go deleted file mode 100644 index f30217ffd6e..00000000000 --- a/radarnetflowtop.go +++ /dev/null @@ -1,332 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarNetflowTopService 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 [NewRadarNetflowTopService] method -// instead. -type RadarNetflowTopService struct { - Options []option.RequestOption -} - -// NewRadarNetflowTopService 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 NewRadarNetflowTopService(opts ...option.RequestOption) (r *RadarNetflowTopService) { - r = &RadarNetflowTopService{} - r.Options = opts - return -} - -// Get the top autonomous systems (AS) by network traffic (NetFlows) over a given -// time period. Visit https://en.wikipedia.org/wiki/NetFlow for more information. -func (r *RadarNetflowTopService) Ases(ctx context.Context, query RadarNetflowTopAsesParams, opts ...option.RequestOption) (res *RadarNetflowTopAsesResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarNetflowTopAsesResponseEnvelope - path := "radar/netflows/top/ases" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the top locations by network traffic (NetFlows) over a given time period. -// Visit https://en.wikipedia.org/wiki/NetFlow for more information. -func (r *RadarNetflowTopService) Locations(ctx context.Context, query RadarNetflowTopLocationsParams, opts ...option.RequestOption) (res *RadarNetflowTopLocationsResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarNetflowTopLocationsResponseEnvelope - path := "radar/netflows/top/locations" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarNetflowTopAsesResponse struct { - Top0 []RadarNetflowTopAsesResponseTop0 `json:"top_0,required"` - JSON radarNetflowTopAsesResponseJSON `json:"-"` -} - -// radarNetflowTopAsesResponseJSON contains the JSON metadata for the struct -// [RadarNetflowTopAsesResponse] -type radarNetflowTopAsesResponseJSON struct { - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarNetflowTopAsesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarNetflowTopAsesResponseJSON) RawJSON() string { - return r.raw -} - -type RadarNetflowTopAsesResponseTop0 struct { - ClientASN float64 `json:"clientASN,required"` - ClientAsName string `json:"clientASName,required"` - Value string `json:"value,required"` - JSON radarNetflowTopAsesResponseTop0JSON `json:"-"` -} - -// radarNetflowTopAsesResponseTop0JSON contains the JSON metadata for the struct -// [RadarNetflowTopAsesResponseTop0] -type radarNetflowTopAsesResponseTop0JSON struct { - ClientASN apijson.Field - ClientAsName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarNetflowTopAsesResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarNetflowTopAsesResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarNetflowTopLocationsResponse struct { - Top0 []RadarNetflowTopLocationsResponseTop0 `json:"top_0,required"` - JSON radarNetflowTopLocationsResponseJSON `json:"-"` -} - -// radarNetflowTopLocationsResponseJSON contains the JSON metadata for the struct -// [RadarNetflowTopLocationsResponse] -type radarNetflowTopLocationsResponseJSON struct { - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarNetflowTopLocationsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarNetflowTopLocationsResponseJSON) RawJSON() string { - return r.raw -} - -type RadarNetflowTopLocationsResponseTop0 struct { - ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` - ClientCountryName string `json:"clientCountryName,required"` - Value string `json:"value,required"` - JSON radarNetflowTopLocationsResponseTop0JSON `json:"-"` -} - -// radarNetflowTopLocationsResponseTop0JSON contains the JSON metadata for the -// struct [RadarNetflowTopLocationsResponseTop0] -type radarNetflowTopLocationsResponseTop0JSON struct { - ClientCountryAlpha2 apijson.Field - ClientCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarNetflowTopLocationsResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarNetflowTopLocationsResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarNetflowTopAsesParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarNetflowTopAsesParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarNetflowTopAsesParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarNetflowTopAsesParams]'s query parameters as -// `url.Values`. -func (r RadarNetflowTopAsesParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarNetflowTopAsesParamsDateRange string - -const ( - RadarNetflowTopAsesParamsDateRange1d RadarNetflowTopAsesParamsDateRange = "1d" - RadarNetflowTopAsesParamsDateRange2d RadarNetflowTopAsesParamsDateRange = "2d" - RadarNetflowTopAsesParamsDateRange7d RadarNetflowTopAsesParamsDateRange = "7d" - RadarNetflowTopAsesParamsDateRange14d RadarNetflowTopAsesParamsDateRange = "14d" - RadarNetflowTopAsesParamsDateRange28d RadarNetflowTopAsesParamsDateRange = "28d" - RadarNetflowTopAsesParamsDateRange12w RadarNetflowTopAsesParamsDateRange = "12w" - RadarNetflowTopAsesParamsDateRange24w RadarNetflowTopAsesParamsDateRange = "24w" - RadarNetflowTopAsesParamsDateRange52w RadarNetflowTopAsesParamsDateRange = "52w" - RadarNetflowTopAsesParamsDateRange1dControl RadarNetflowTopAsesParamsDateRange = "1dControl" - RadarNetflowTopAsesParamsDateRange2dControl RadarNetflowTopAsesParamsDateRange = "2dControl" - RadarNetflowTopAsesParamsDateRange7dControl RadarNetflowTopAsesParamsDateRange = "7dControl" - RadarNetflowTopAsesParamsDateRange14dControl RadarNetflowTopAsesParamsDateRange = "14dControl" - RadarNetflowTopAsesParamsDateRange28dControl RadarNetflowTopAsesParamsDateRange = "28dControl" - RadarNetflowTopAsesParamsDateRange12wControl RadarNetflowTopAsesParamsDateRange = "12wControl" - RadarNetflowTopAsesParamsDateRange24wControl RadarNetflowTopAsesParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarNetflowTopAsesParamsFormat string - -const ( - RadarNetflowTopAsesParamsFormatJson RadarNetflowTopAsesParamsFormat = "JSON" - RadarNetflowTopAsesParamsFormatCsv RadarNetflowTopAsesParamsFormat = "CSV" -) - -type RadarNetflowTopAsesResponseEnvelope struct { - Result RadarNetflowTopAsesResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarNetflowTopAsesResponseEnvelopeJSON `json:"-"` -} - -// radarNetflowTopAsesResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarNetflowTopAsesResponseEnvelope] -type radarNetflowTopAsesResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarNetflowTopAsesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarNetflowTopAsesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarNetflowTopLocationsParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarNetflowTopLocationsParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarNetflowTopLocationsParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarNetflowTopLocationsParams]'s query parameters as -// `url.Values`. -func (r RadarNetflowTopLocationsParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarNetflowTopLocationsParamsDateRange string - -const ( - RadarNetflowTopLocationsParamsDateRange1d RadarNetflowTopLocationsParamsDateRange = "1d" - RadarNetflowTopLocationsParamsDateRange2d RadarNetflowTopLocationsParamsDateRange = "2d" - RadarNetflowTopLocationsParamsDateRange7d RadarNetflowTopLocationsParamsDateRange = "7d" - RadarNetflowTopLocationsParamsDateRange14d RadarNetflowTopLocationsParamsDateRange = "14d" - RadarNetflowTopLocationsParamsDateRange28d RadarNetflowTopLocationsParamsDateRange = "28d" - RadarNetflowTopLocationsParamsDateRange12w RadarNetflowTopLocationsParamsDateRange = "12w" - RadarNetflowTopLocationsParamsDateRange24w RadarNetflowTopLocationsParamsDateRange = "24w" - RadarNetflowTopLocationsParamsDateRange52w RadarNetflowTopLocationsParamsDateRange = "52w" - RadarNetflowTopLocationsParamsDateRange1dControl RadarNetflowTopLocationsParamsDateRange = "1dControl" - RadarNetflowTopLocationsParamsDateRange2dControl RadarNetflowTopLocationsParamsDateRange = "2dControl" - RadarNetflowTopLocationsParamsDateRange7dControl RadarNetflowTopLocationsParamsDateRange = "7dControl" - RadarNetflowTopLocationsParamsDateRange14dControl RadarNetflowTopLocationsParamsDateRange = "14dControl" - RadarNetflowTopLocationsParamsDateRange28dControl RadarNetflowTopLocationsParamsDateRange = "28dControl" - RadarNetflowTopLocationsParamsDateRange12wControl RadarNetflowTopLocationsParamsDateRange = "12wControl" - RadarNetflowTopLocationsParamsDateRange24wControl RadarNetflowTopLocationsParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarNetflowTopLocationsParamsFormat string - -const ( - RadarNetflowTopLocationsParamsFormatJson RadarNetflowTopLocationsParamsFormat = "JSON" - RadarNetflowTopLocationsParamsFormatCsv RadarNetflowTopLocationsParamsFormat = "CSV" -) - -type RadarNetflowTopLocationsResponseEnvelope struct { - Result RadarNetflowTopLocationsResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarNetflowTopLocationsResponseEnvelopeJSON `json:"-"` -} - -// radarNetflowTopLocationsResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarNetflowTopLocationsResponseEnvelope] -type radarNetflowTopLocationsResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarNetflowTopLocationsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarNetflowTopLocationsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarnetflowtop_test.go b/radarnetflowtop_test.go deleted file mode 100644 index 82345fd4050..00000000000 --- a/radarnetflowtop_test.go +++ /dev/null @@ -1,83 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarNetflowTopAsesWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Netflows.Top.Ases(context.TODO(), cloudflare.RadarNetflowTopAsesParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarNetflowTopAsesParamsDateRange{cloudflare.RadarNetflowTopAsesParamsDateRange1d, cloudflare.RadarNetflowTopAsesParamsDateRange2d, cloudflare.RadarNetflowTopAsesParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarNetflowTopAsesParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarNetflowTopLocationsWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Netflows.Top.Locations(context.TODO(), cloudflare.RadarNetflowTopLocationsParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarNetflowTopLocationsParamsDateRange{cloudflare.RadarNetflowTopLocationsParamsDateRange1d, cloudflare.RadarNetflowTopLocationsParamsDateRange2d, cloudflare.RadarNetflowTopLocationsParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarNetflowTopLocationsParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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/radarquality.go b/radarquality.go deleted file mode 100644 index fc847049da8..00000000000 --- a/radarquality.go +++ /dev/null @@ -1,29 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarQualityService 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 [NewRadarQualityService] method -// instead. -type RadarQualityService struct { - Options []option.RequestOption - IQI *RadarQualityIQIService - Speed *RadarQualitySpeedService -} - -// NewRadarQualityService 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 NewRadarQualityService(opts ...option.RequestOption) (r *RadarQualityService) { - r = &RadarQualityService{} - r.Options = opts - r.IQI = NewRadarQualityIQIService(opts...) - r.Speed = NewRadarQualitySpeedService(opts...) - return -} diff --git a/radarqualityiqi.go b/radarqualityiqi.go deleted file mode 100644 index 4d507da9aad..00000000000 --- a/radarqualityiqi.go +++ /dev/null @@ -1,483 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarQualityIQIService 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 [NewRadarQualityIQIService] method -// instead. -type RadarQualityIQIService struct { - Options []option.RequestOption -} - -// NewRadarQualityIQIService 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 NewRadarQualityIQIService(opts ...option.RequestOption) (r *RadarQualityIQIService) { - r = &RadarQualityIQIService{} - r.Options = opts - return -} - -// Get a summary (percentiles) of bandwidth, latency or DNS response time from the -// Radar Internet Quality Index (IQI). -func (r *RadarQualityIQIService) Summary(ctx context.Context, query RadarQualityIQISummaryParams, opts ...option.RequestOption) (res *RadarQualityIQISummaryResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarQualityIQISummaryResponseEnvelope - path := "radar/quality/iqi/summary" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a time series (percentiles) of bandwidth, latency or DNS response time from -// the Radar Internet Quality Index (IQI). -func (r *RadarQualityIQIService) TimeseriesGroups(ctx context.Context, query RadarQualityIQITimeseriesGroupsParams, opts ...option.RequestOption) (res *RadarQualityIQITimeseriesGroupsResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarQualityIQITimeseriesGroupsResponseEnvelope - path := "radar/quality/iqi/timeseries_groups" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarQualityIQISummaryResponse struct { - Meta RadarQualityIQISummaryResponseMeta `json:"meta,required"` - Summary0 RadarQualityIQISummaryResponseSummary0 `json:"summary_0,required"` - JSON radarQualityIQISummaryResponseJSON `json:"-"` -} - -// radarQualityIQISummaryResponseJSON contains the JSON metadata for the struct -// [RadarQualityIQISummaryResponse] -type radarQualityIQISummaryResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualityIQISummaryResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualityIQISummaryResponseJSON) RawJSON() string { - return r.raw -} - -type RadarQualityIQISummaryResponseMeta struct { - DateRange []RadarQualityIQISummaryResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarQualityIQISummaryResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarQualityIQISummaryResponseMetaJSON `json:"-"` -} - -// radarQualityIQISummaryResponseMetaJSON contains the JSON metadata for the struct -// [RadarQualityIQISummaryResponseMeta] -type radarQualityIQISummaryResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualityIQISummaryResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualityIQISummaryResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarQualityIQISummaryResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarQualityIQISummaryResponseMetaDateRangeJSON `json:"-"` -} - -// radarQualityIQISummaryResponseMetaDateRangeJSON contains the JSON metadata for -// the struct [RadarQualityIQISummaryResponseMetaDateRange] -type radarQualityIQISummaryResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualityIQISummaryResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualityIQISummaryResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarQualityIQISummaryResponseMetaConfidenceInfo struct { - Annotations []RadarQualityIQISummaryResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarQualityIQISummaryResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarQualityIQISummaryResponseMetaConfidenceInfoJSON contains the JSON metadata -// for the struct [RadarQualityIQISummaryResponseMetaConfidenceInfo] -type radarQualityIQISummaryResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualityIQISummaryResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualityIQISummaryResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarQualityIQISummaryResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarQualityIQISummaryResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarQualityIQISummaryResponseMetaConfidenceInfoAnnotationJSON contains the JSON -// metadata for the struct -// [RadarQualityIQISummaryResponseMetaConfidenceInfoAnnotation] -type radarQualityIQISummaryResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualityIQISummaryResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualityIQISummaryResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarQualityIQISummaryResponseSummary0 struct { - P25 string `json:"p25,required"` - P50 string `json:"p50,required"` - P75 string `json:"p75,required"` - JSON radarQualityIQISummaryResponseSummary0JSON `json:"-"` -} - -// radarQualityIQISummaryResponseSummary0JSON contains the JSON metadata for the -// struct [RadarQualityIQISummaryResponseSummary0] -type radarQualityIQISummaryResponseSummary0JSON struct { - P25 apijson.Field - P50 apijson.Field - P75 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualityIQISummaryResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualityIQISummaryResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarQualityIQITimeseriesGroupsResponse struct { - Meta interface{} `json:"meta,required"` - Serie0 RadarQualityIQITimeseriesGroupsResponseSerie0 `json:"serie_0,required"` - JSON radarQualityIQITimeseriesGroupsResponseJSON `json:"-"` -} - -// radarQualityIQITimeseriesGroupsResponseJSON contains the JSON metadata for the -// struct [RadarQualityIQITimeseriesGroupsResponse] -type radarQualityIQITimeseriesGroupsResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualityIQITimeseriesGroupsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualityIQITimeseriesGroupsResponseJSON) RawJSON() string { - return r.raw -} - -type RadarQualityIQITimeseriesGroupsResponseSerie0 struct { - P25 []string `json:"p25,required"` - P50 []string `json:"p50,required"` - P75 []string `json:"p75,required"` - Timestamps []string `json:"timestamps,required"` - JSON radarQualityIQITimeseriesGroupsResponseSerie0JSON `json:"-"` -} - -// radarQualityIQITimeseriesGroupsResponseSerie0JSON contains the JSON metadata for -// the struct [RadarQualityIQITimeseriesGroupsResponseSerie0] -type radarQualityIQITimeseriesGroupsResponseSerie0JSON struct { - P25 apijson.Field - P50 apijson.Field - P75 apijson.Field - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualityIQITimeseriesGroupsResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualityIQITimeseriesGroupsResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarQualityIQISummaryParams struct { - // Which metric to return: bandwidth, latency or DNS response time. - Metric param.Field[RadarQualityIQISummaryParamsMetric] `query:"metric,required"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarQualityIQISummaryParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarQualityIQISummaryParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarQualityIQISummaryParams]'s query parameters as -// `url.Values`. -func (r RadarQualityIQISummaryParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Which metric to return: bandwidth, latency or DNS response time. -type RadarQualityIQISummaryParamsMetric string - -const ( - RadarQualityIQISummaryParamsMetricBandwidth RadarQualityIQISummaryParamsMetric = "BANDWIDTH" - RadarQualityIQISummaryParamsMetricDNS RadarQualityIQISummaryParamsMetric = "DNS" - RadarQualityIQISummaryParamsMetricLatency RadarQualityIQISummaryParamsMetric = "LATENCY" -) - -type RadarQualityIQISummaryParamsDateRange string - -const ( - RadarQualityIQISummaryParamsDateRange1d RadarQualityIQISummaryParamsDateRange = "1d" - RadarQualityIQISummaryParamsDateRange2d RadarQualityIQISummaryParamsDateRange = "2d" - RadarQualityIQISummaryParamsDateRange7d RadarQualityIQISummaryParamsDateRange = "7d" - RadarQualityIQISummaryParamsDateRange14d RadarQualityIQISummaryParamsDateRange = "14d" - RadarQualityIQISummaryParamsDateRange28d RadarQualityIQISummaryParamsDateRange = "28d" - RadarQualityIQISummaryParamsDateRange12w RadarQualityIQISummaryParamsDateRange = "12w" - RadarQualityIQISummaryParamsDateRange24w RadarQualityIQISummaryParamsDateRange = "24w" - RadarQualityIQISummaryParamsDateRange52w RadarQualityIQISummaryParamsDateRange = "52w" - RadarQualityIQISummaryParamsDateRange1dControl RadarQualityIQISummaryParamsDateRange = "1dControl" - RadarQualityIQISummaryParamsDateRange2dControl RadarQualityIQISummaryParamsDateRange = "2dControl" - RadarQualityIQISummaryParamsDateRange7dControl RadarQualityIQISummaryParamsDateRange = "7dControl" - RadarQualityIQISummaryParamsDateRange14dControl RadarQualityIQISummaryParamsDateRange = "14dControl" - RadarQualityIQISummaryParamsDateRange28dControl RadarQualityIQISummaryParamsDateRange = "28dControl" - RadarQualityIQISummaryParamsDateRange12wControl RadarQualityIQISummaryParamsDateRange = "12wControl" - RadarQualityIQISummaryParamsDateRange24wControl RadarQualityIQISummaryParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarQualityIQISummaryParamsFormat string - -const ( - RadarQualityIQISummaryParamsFormatJson RadarQualityIQISummaryParamsFormat = "JSON" - RadarQualityIQISummaryParamsFormatCsv RadarQualityIQISummaryParamsFormat = "CSV" -) - -type RadarQualityIQISummaryResponseEnvelope struct { - Result RadarQualityIQISummaryResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarQualityIQISummaryResponseEnvelopeJSON `json:"-"` -} - -// radarQualityIQISummaryResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarQualityIQISummaryResponseEnvelope] -type radarQualityIQISummaryResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualityIQISummaryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualityIQISummaryResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarQualityIQITimeseriesGroupsParams struct { - // Which metric to return: bandwidth, latency or DNS response time. - Metric param.Field[RadarQualityIQITimeseriesGroupsParamsMetric] `query:"metric,required"` - // Aggregation interval results should be returned in (for example, in 15 minutes - // or 1 hour intervals). Refer to - // [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). - AggInterval param.Field[RadarQualityIQITimeseriesGroupsParamsAggInterval] `query:"aggInterval"` - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarQualityIQITimeseriesGroupsParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarQualityIQITimeseriesGroupsParamsFormat] `query:"format"` - // Enable interpolation for all series (using the average). - Interpolation param.Field[bool] `query:"interpolation"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarQualityIQITimeseriesGroupsParams]'s query parameters -// as `url.Values`. -func (r RadarQualityIQITimeseriesGroupsParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Which metric to return: bandwidth, latency or DNS response time. -type RadarQualityIQITimeseriesGroupsParamsMetric string - -const ( - RadarQualityIQITimeseriesGroupsParamsMetricBandwidth RadarQualityIQITimeseriesGroupsParamsMetric = "BANDWIDTH" - RadarQualityIQITimeseriesGroupsParamsMetricDNS RadarQualityIQITimeseriesGroupsParamsMetric = "DNS" - RadarQualityIQITimeseriesGroupsParamsMetricLatency RadarQualityIQITimeseriesGroupsParamsMetric = "LATENCY" -) - -// Aggregation interval results should be returned in (for example, in 15 minutes -// or 1 hour intervals). Refer to -// [Aggregation intervals](https://developers.cloudflare.com/radar/concepts/aggregation-intervals/). -type RadarQualityIQITimeseriesGroupsParamsAggInterval string - -const ( - RadarQualityIQITimeseriesGroupsParamsAggInterval15m RadarQualityIQITimeseriesGroupsParamsAggInterval = "15m" - RadarQualityIQITimeseriesGroupsParamsAggInterval1h RadarQualityIQITimeseriesGroupsParamsAggInterval = "1h" - RadarQualityIQITimeseriesGroupsParamsAggInterval1d RadarQualityIQITimeseriesGroupsParamsAggInterval = "1d" - RadarQualityIQITimeseriesGroupsParamsAggInterval1w RadarQualityIQITimeseriesGroupsParamsAggInterval = "1w" -) - -type RadarQualityIQITimeseriesGroupsParamsDateRange string - -const ( - RadarQualityIQITimeseriesGroupsParamsDateRange1d RadarQualityIQITimeseriesGroupsParamsDateRange = "1d" - RadarQualityIQITimeseriesGroupsParamsDateRange2d RadarQualityIQITimeseriesGroupsParamsDateRange = "2d" - RadarQualityIQITimeseriesGroupsParamsDateRange7d RadarQualityIQITimeseriesGroupsParamsDateRange = "7d" - RadarQualityIQITimeseriesGroupsParamsDateRange14d RadarQualityIQITimeseriesGroupsParamsDateRange = "14d" - RadarQualityIQITimeseriesGroupsParamsDateRange28d RadarQualityIQITimeseriesGroupsParamsDateRange = "28d" - RadarQualityIQITimeseriesGroupsParamsDateRange12w RadarQualityIQITimeseriesGroupsParamsDateRange = "12w" - RadarQualityIQITimeseriesGroupsParamsDateRange24w RadarQualityIQITimeseriesGroupsParamsDateRange = "24w" - RadarQualityIQITimeseriesGroupsParamsDateRange52w RadarQualityIQITimeseriesGroupsParamsDateRange = "52w" - RadarQualityIQITimeseriesGroupsParamsDateRange1dControl RadarQualityIQITimeseriesGroupsParamsDateRange = "1dControl" - RadarQualityIQITimeseriesGroupsParamsDateRange2dControl RadarQualityIQITimeseriesGroupsParamsDateRange = "2dControl" - RadarQualityIQITimeseriesGroupsParamsDateRange7dControl RadarQualityIQITimeseriesGroupsParamsDateRange = "7dControl" - RadarQualityIQITimeseriesGroupsParamsDateRange14dControl RadarQualityIQITimeseriesGroupsParamsDateRange = "14dControl" - RadarQualityIQITimeseriesGroupsParamsDateRange28dControl RadarQualityIQITimeseriesGroupsParamsDateRange = "28dControl" - RadarQualityIQITimeseriesGroupsParamsDateRange12wControl RadarQualityIQITimeseriesGroupsParamsDateRange = "12wControl" - RadarQualityIQITimeseriesGroupsParamsDateRange24wControl RadarQualityIQITimeseriesGroupsParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarQualityIQITimeseriesGroupsParamsFormat string - -const ( - RadarQualityIQITimeseriesGroupsParamsFormatJson RadarQualityIQITimeseriesGroupsParamsFormat = "JSON" - RadarQualityIQITimeseriesGroupsParamsFormatCsv RadarQualityIQITimeseriesGroupsParamsFormat = "CSV" -) - -type RadarQualityIQITimeseriesGroupsResponseEnvelope struct { - Result RadarQualityIQITimeseriesGroupsResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarQualityIQITimeseriesGroupsResponseEnvelopeJSON `json:"-"` -} - -// radarQualityIQITimeseriesGroupsResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarQualityIQITimeseriesGroupsResponseEnvelope] -type radarQualityIQITimeseriesGroupsResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualityIQITimeseriesGroupsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualityIQITimeseriesGroupsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarqualityiqi_test.go b/radarqualityiqi_test.go deleted file mode 100644 index 02d08d4a2bf..00000000000 --- a/radarqualityiqi_test.go +++ /dev/null @@ -1,85 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarQualityIQISummaryWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Quality.IQI.Summary(context.TODO(), cloudflare.RadarQualityIQISummaryParams{ - Metric: cloudflare.F(cloudflare.RadarQualityIQISummaryParamsMetricBandwidth), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarQualityIQISummaryParamsDateRange{cloudflare.RadarQualityIQISummaryParamsDateRange1d, cloudflare.RadarQualityIQISummaryParamsDateRange2d, cloudflare.RadarQualityIQISummaryParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarQualityIQISummaryParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarQualityIQITimeseriesGroupsWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Quality.IQI.TimeseriesGroups(context.TODO(), cloudflare.RadarQualityIQITimeseriesGroupsParams{ - Metric: cloudflare.F(cloudflare.RadarQualityIQITimeseriesGroupsParamsMetricBandwidth), - AggInterval: cloudflare.F(cloudflare.RadarQualityIQITimeseriesGroupsParamsAggInterval1h), - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarQualityIQITimeseriesGroupsParamsDateRange{cloudflare.RadarQualityIQITimeseriesGroupsParamsDateRange1d, cloudflare.RadarQualityIQITimeseriesGroupsParamsDateRange2d, cloudflare.RadarQualityIQITimeseriesGroupsParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarQualityIQITimeseriesGroupsParamsFormatJson), - Interpolation: cloudflare.F(true), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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/radarqualityspeed.go b/radarqualityspeed.go deleted file mode 100644 index a408e2c81f8..00000000000 --- a/radarqualityspeed.go +++ /dev/null @@ -1,412 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarQualitySpeedService 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 [NewRadarQualitySpeedService] method -// instead. -type RadarQualitySpeedService struct { - Options []option.RequestOption - Top *RadarQualitySpeedTopService -} - -// NewRadarQualitySpeedService 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 NewRadarQualitySpeedService(opts ...option.RequestOption) (r *RadarQualitySpeedService) { - r = &RadarQualitySpeedService{} - r.Options = opts - r.Top = NewRadarQualitySpeedTopService(opts...) - return -} - -// Get an histogram from the previous 90 days of Cloudflare Speed Test data, split -// into fixed bandwidth (Mbps), latency (ms) or jitter (ms) buckets. -func (r *RadarQualitySpeedService) Histogram(ctx context.Context, query RadarQualitySpeedHistogramParams, opts ...option.RequestOption) (res *RadarQualitySpeedHistogramResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarQualitySpeedHistogramResponseEnvelope - path := "radar/quality/speed/histogram" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a summary of bandwidth, latency, jitter and packet loss, from the previous -// 90 days of Cloudflare Speed Test data. -func (r *RadarQualitySpeedService) Summary(ctx context.Context, query RadarQualitySpeedSummaryParams, opts ...option.RequestOption) (res *RadarQualitySpeedSummaryResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarQualitySpeedSummaryResponseEnvelope - path := "radar/quality/speed/summary" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarQualitySpeedHistogramResponse struct { - Histogram0 RadarQualitySpeedHistogramResponseHistogram0 `json:"histogram_0,required"` - Meta interface{} `json:"meta,required"` - JSON radarQualitySpeedHistogramResponseJSON `json:"-"` -} - -// radarQualitySpeedHistogramResponseJSON contains the JSON metadata for the struct -// [RadarQualitySpeedHistogramResponse] -type radarQualitySpeedHistogramResponseJSON struct { - Histogram0 apijson.Field - Meta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedHistogramResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedHistogramResponseJSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedHistogramResponseHistogram0 struct { - BandwidthDownload []string `json:"bandwidthDownload,required"` - BandwidthUpload []string `json:"bandwidthUpload,required"` - BucketMin []string `json:"bucketMin,required"` - JSON radarQualitySpeedHistogramResponseHistogram0JSON `json:"-"` -} - -// radarQualitySpeedHistogramResponseHistogram0JSON contains the JSON metadata for -// the struct [RadarQualitySpeedHistogramResponseHistogram0] -type radarQualitySpeedHistogramResponseHistogram0JSON struct { - BandwidthDownload apijson.Field - BandwidthUpload apijson.Field - BucketMin apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedHistogramResponseHistogram0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedHistogramResponseHistogram0JSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedSummaryResponse struct { - Meta RadarQualitySpeedSummaryResponseMeta `json:"meta,required"` - Summary0 RadarQualitySpeedSummaryResponseSummary0 `json:"summary_0,required"` - JSON radarQualitySpeedSummaryResponseJSON `json:"-"` -} - -// radarQualitySpeedSummaryResponseJSON contains the JSON metadata for the struct -// [RadarQualitySpeedSummaryResponse] -type radarQualitySpeedSummaryResponseJSON struct { - Meta apijson.Field - Summary0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedSummaryResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedSummaryResponseJSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedSummaryResponseMeta struct { - DateRange []RadarQualitySpeedSummaryResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - Normalization string `json:"normalization,required"` - ConfidenceInfo RadarQualitySpeedSummaryResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarQualitySpeedSummaryResponseMetaJSON `json:"-"` -} - -// radarQualitySpeedSummaryResponseMetaJSON contains the JSON metadata for the -// struct [RadarQualitySpeedSummaryResponseMeta] -type radarQualitySpeedSummaryResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - Normalization apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedSummaryResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedSummaryResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedSummaryResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarQualitySpeedSummaryResponseMetaDateRangeJSON `json:"-"` -} - -// radarQualitySpeedSummaryResponseMetaDateRangeJSON contains the JSON metadata for -// the struct [RadarQualitySpeedSummaryResponseMetaDateRange] -type radarQualitySpeedSummaryResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedSummaryResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedSummaryResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedSummaryResponseMetaConfidenceInfo struct { - Annotations []RadarQualitySpeedSummaryResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarQualitySpeedSummaryResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarQualitySpeedSummaryResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarQualitySpeedSummaryResponseMetaConfidenceInfo] -type radarQualitySpeedSummaryResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedSummaryResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedSummaryResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedSummaryResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarQualitySpeedSummaryResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarQualitySpeedSummaryResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarQualitySpeedSummaryResponseMetaConfidenceInfoAnnotation] -type radarQualitySpeedSummaryResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedSummaryResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedSummaryResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedSummaryResponseSummary0 struct { - BandwidthDownload string `json:"bandwidthDownload,required"` - BandwidthUpload string `json:"bandwidthUpload,required"` - JitterIdle string `json:"jitterIdle,required"` - JitterLoaded string `json:"jitterLoaded,required"` - LatencyIdle string `json:"latencyIdle,required"` - LatencyLoaded string `json:"latencyLoaded,required"` - PacketLoss string `json:"packetLoss,required"` - JSON radarQualitySpeedSummaryResponseSummary0JSON `json:"-"` -} - -// radarQualitySpeedSummaryResponseSummary0JSON contains the JSON metadata for the -// struct [RadarQualitySpeedSummaryResponseSummary0] -type radarQualitySpeedSummaryResponseSummary0JSON struct { - BandwidthDownload apijson.Field - BandwidthUpload apijson.Field - JitterIdle apijson.Field - JitterLoaded apijson.Field - LatencyIdle apijson.Field - LatencyLoaded apijson.Field - PacketLoss apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedSummaryResponseSummary0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedSummaryResponseSummary0JSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedHistogramParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // The width for every bucket in the histogram. - BucketSize param.Field[int64] `query:"bucketSize"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarQualitySpeedHistogramParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Metrics to be returned. - MetricGroup param.Field[RadarQualitySpeedHistogramParamsMetricGroup] `query:"metricGroup"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarQualitySpeedHistogramParams]'s query parameters as -// `url.Values`. -func (r RadarQualitySpeedHistogramParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Format results are returned in. -type RadarQualitySpeedHistogramParamsFormat string - -const ( - RadarQualitySpeedHistogramParamsFormatJson RadarQualitySpeedHistogramParamsFormat = "JSON" - RadarQualitySpeedHistogramParamsFormatCsv RadarQualitySpeedHistogramParamsFormat = "CSV" -) - -// Metrics to be returned. -type RadarQualitySpeedHistogramParamsMetricGroup string - -const ( - RadarQualitySpeedHistogramParamsMetricGroupBandwidth RadarQualitySpeedHistogramParamsMetricGroup = "BANDWIDTH" - RadarQualitySpeedHistogramParamsMetricGroupLatency RadarQualitySpeedHistogramParamsMetricGroup = "LATENCY" - RadarQualitySpeedHistogramParamsMetricGroupJitter RadarQualitySpeedHistogramParamsMetricGroup = "JITTER" -) - -type RadarQualitySpeedHistogramResponseEnvelope struct { - Result RadarQualitySpeedHistogramResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarQualitySpeedHistogramResponseEnvelopeJSON `json:"-"` -} - -// radarQualitySpeedHistogramResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarQualitySpeedHistogramResponseEnvelope] -type radarQualitySpeedHistogramResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedHistogramResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedHistogramResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedSummaryParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarQualitySpeedSummaryParamsFormat] `query:"format"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarQualitySpeedSummaryParams]'s query parameters as -// `url.Values`. -func (r RadarQualitySpeedSummaryParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Format results are returned in. -type RadarQualitySpeedSummaryParamsFormat string - -const ( - RadarQualitySpeedSummaryParamsFormatJson RadarQualitySpeedSummaryParamsFormat = "JSON" - RadarQualitySpeedSummaryParamsFormatCsv RadarQualitySpeedSummaryParamsFormat = "CSV" -) - -type RadarQualitySpeedSummaryResponseEnvelope struct { - Result RadarQualitySpeedSummaryResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarQualitySpeedSummaryResponseEnvelopeJSON `json:"-"` -} - -// radarQualitySpeedSummaryResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarQualitySpeedSummaryResponseEnvelope] -type radarQualitySpeedSummaryResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedSummaryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedSummaryResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarqualityspeed_test.go b/radarqualityspeed_test.go deleted file mode 100644 index 635da7488d9..00000000000 --- a/radarqualityspeed_test.go +++ /dev/null @@ -1,79 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarQualitySpeedHistogramWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Quality.Speed.Histogram(context.TODO(), cloudflare.RadarQualitySpeedHistogramParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - BucketSize: cloudflare.F(int64(0)), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarQualitySpeedHistogramParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - MetricGroup: cloudflare.F(cloudflare.RadarQualitySpeedHistogramParamsMetricGroupBandwidth), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarQualitySpeedSummaryWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Quality.Speed.Summary(context.TODO(), cloudflare.RadarQualitySpeedSummaryParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarQualitySpeedSummaryParamsFormatJson), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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/radarqualityspeedtop.go b/radarqualityspeedtop.go deleted file mode 100644 index 0d69e7bda11..00000000000 --- a/radarqualityspeedtop.go +++ /dev/null @@ -1,559 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarQualitySpeedTopService 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 [NewRadarQualitySpeedTopService] -// method instead. -type RadarQualitySpeedTopService struct { - Options []option.RequestOption -} - -// NewRadarQualitySpeedTopService 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 NewRadarQualitySpeedTopService(opts ...option.RequestOption) (r *RadarQualitySpeedTopService) { - r = &RadarQualitySpeedTopService{} - r.Options = opts - return -} - -// Get the top autonomous systems by bandwidth, latency, jitter or packet loss, -// from the previous 90 days of Cloudflare Speed Test data. -func (r *RadarQualitySpeedTopService) Ases(ctx context.Context, query RadarQualitySpeedTopAsesParams, opts ...option.RequestOption) (res *RadarQualitySpeedTopAsesResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarQualitySpeedTopAsesResponseEnvelope - path := "radar/quality/speed/top/ases" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the top locations by bandwidth, latency, jitter or packet loss, from the -// previous 90 days of Cloudflare Speed Test data. -func (r *RadarQualitySpeedTopService) Locations(ctx context.Context, query RadarQualitySpeedTopLocationsParams, opts ...option.RequestOption) (res *RadarQualitySpeedTopLocationsResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarQualitySpeedTopLocationsResponseEnvelope - path := "radar/quality/speed/top/locations" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarQualitySpeedTopAsesResponse struct { - Meta RadarQualitySpeedTopAsesResponseMeta `json:"meta,required"` - Top0 []RadarQualitySpeedTopAsesResponseTop0 `json:"top_0,required"` - JSON radarQualitySpeedTopAsesResponseJSON `json:"-"` -} - -// radarQualitySpeedTopAsesResponseJSON contains the JSON metadata for the struct -// [RadarQualitySpeedTopAsesResponse] -type radarQualitySpeedTopAsesResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedTopAsesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedTopAsesResponseJSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedTopAsesResponseMeta struct { - DateRange []RadarQualitySpeedTopAsesResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarQualitySpeedTopAsesResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarQualitySpeedTopAsesResponseMetaJSON `json:"-"` -} - -// radarQualitySpeedTopAsesResponseMetaJSON contains the JSON metadata for the -// struct [RadarQualitySpeedTopAsesResponseMeta] -type radarQualitySpeedTopAsesResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedTopAsesResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedTopAsesResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedTopAsesResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarQualitySpeedTopAsesResponseMetaDateRangeJSON `json:"-"` -} - -// radarQualitySpeedTopAsesResponseMetaDateRangeJSON contains the JSON metadata for -// the struct [RadarQualitySpeedTopAsesResponseMetaDateRange] -type radarQualitySpeedTopAsesResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedTopAsesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedTopAsesResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedTopAsesResponseMetaConfidenceInfo struct { - Annotations []RadarQualitySpeedTopAsesResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarQualitySpeedTopAsesResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarQualitySpeedTopAsesResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct [RadarQualitySpeedTopAsesResponseMetaConfidenceInfo] -type radarQualitySpeedTopAsesResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedTopAsesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedTopAsesResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedTopAsesResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarQualitySpeedTopAsesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarQualitySpeedTopAsesResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarQualitySpeedTopAsesResponseMetaConfidenceInfoAnnotation] -type radarQualitySpeedTopAsesResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedTopAsesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedTopAsesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedTopAsesResponseTop0 struct { - BandwidthDownload string `json:"bandwidthDownload,required"` - BandwidthUpload string `json:"bandwidthUpload,required"` - ClientASN float64 `json:"clientASN,required"` - ClientAsName string `json:"clientASName,required"` - JitterIdle string `json:"jitterIdle,required"` - JitterLoaded string `json:"jitterLoaded,required"` - LatencyIdle string `json:"latencyIdle,required"` - LatencyLoaded string `json:"latencyLoaded,required"` - NumTests float64 `json:"numTests,required"` - RankPower float64 `json:"rankPower,required"` - JSON radarQualitySpeedTopAsesResponseTop0JSON `json:"-"` -} - -// radarQualitySpeedTopAsesResponseTop0JSON contains the JSON metadata for the -// struct [RadarQualitySpeedTopAsesResponseTop0] -type radarQualitySpeedTopAsesResponseTop0JSON struct { - BandwidthDownload apijson.Field - BandwidthUpload apijson.Field - ClientASN apijson.Field - ClientAsName apijson.Field - JitterIdle apijson.Field - JitterLoaded apijson.Field - LatencyIdle apijson.Field - LatencyLoaded apijson.Field - NumTests apijson.Field - RankPower apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedTopAsesResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedTopAsesResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedTopLocationsResponse struct { - Meta RadarQualitySpeedTopLocationsResponseMeta `json:"meta,required"` - Top0 []RadarQualitySpeedTopLocationsResponseTop0 `json:"top_0,required"` - JSON radarQualitySpeedTopLocationsResponseJSON `json:"-"` -} - -// radarQualitySpeedTopLocationsResponseJSON contains the JSON metadata for the -// struct [RadarQualitySpeedTopLocationsResponse] -type radarQualitySpeedTopLocationsResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedTopLocationsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedTopLocationsResponseJSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedTopLocationsResponseMeta struct { - DateRange []RadarQualitySpeedTopLocationsResponseMetaDateRange `json:"dateRange,required"` - LastUpdated string `json:"lastUpdated,required"` - ConfidenceInfo RadarQualitySpeedTopLocationsResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarQualitySpeedTopLocationsResponseMetaJSON `json:"-"` -} - -// radarQualitySpeedTopLocationsResponseMetaJSON contains the JSON metadata for the -// struct [RadarQualitySpeedTopLocationsResponseMeta] -type radarQualitySpeedTopLocationsResponseMetaJSON struct { - DateRange apijson.Field - LastUpdated apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedTopLocationsResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedTopLocationsResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedTopLocationsResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarQualitySpeedTopLocationsResponseMetaDateRangeJSON `json:"-"` -} - -// radarQualitySpeedTopLocationsResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarQualitySpeedTopLocationsResponseMetaDateRange] -type radarQualitySpeedTopLocationsResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedTopLocationsResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedTopLocationsResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedTopLocationsResponseMetaConfidenceInfo struct { - Annotations []RadarQualitySpeedTopLocationsResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarQualitySpeedTopLocationsResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarQualitySpeedTopLocationsResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarQualitySpeedTopLocationsResponseMetaConfidenceInfo] -type radarQualitySpeedTopLocationsResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedTopLocationsResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedTopLocationsResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedTopLocationsResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarQualitySpeedTopLocationsResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarQualitySpeedTopLocationsResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarQualitySpeedTopLocationsResponseMetaConfidenceInfoAnnotation] -type radarQualitySpeedTopLocationsResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedTopLocationsResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedTopLocationsResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedTopLocationsResponseTop0 struct { - BandwidthDownload string `json:"bandwidthDownload,required"` - BandwidthUpload string `json:"bandwidthUpload,required"` - ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` - ClientCountryName string `json:"clientCountryName,required"` - JitterIdle string `json:"jitterIdle,required"` - JitterLoaded string `json:"jitterLoaded,required"` - LatencyIdle string `json:"latencyIdle,required"` - LatencyLoaded string `json:"latencyLoaded,required"` - NumTests float64 `json:"numTests,required"` - RankPower float64 `json:"rankPower,required"` - JSON radarQualitySpeedTopLocationsResponseTop0JSON `json:"-"` -} - -// radarQualitySpeedTopLocationsResponseTop0JSON contains the JSON metadata for the -// struct [RadarQualitySpeedTopLocationsResponseTop0] -type radarQualitySpeedTopLocationsResponseTop0JSON struct { - BandwidthDownload apijson.Field - BandwidthUpload apijson.Field - ClientCountryAlpha2 apijson.Field - ClientCountryName apijson.Field - JitterIdle apijson.Field - JitterLoaded apijson.Field - LatencyIdle apijson.Field - LatencyLoaded apijson.Field - NumTests apijson.Field - RankPower apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedTopLocationsResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedTopLocationsResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedTopAsesParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarQualitySpeedTopAsesParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Metric to order the results by. - OrderBy param.Field[RadarQualitySpeedTopAsesParamsOrderBy] `query:"orderBy"` - // Reverse the order of results. - Reverse param.Field[bool] `query:"reverse"` -} - -// URLQuery serializes [RadarQualitySpeedTopAsesParams]'s query parameters as -// `url.Values`. -func (r RadarQualitySpeedTopAsesParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Format results are returned in. -type RadarQualitySpeedTopAsesParamsFormat string - -const ( - RadarQualitySpeedTopAsesParamsFormatJson RadarQualitySpeedTopAsesParamsFormat = "JSON" - RadarQualitySpeedTopAsesParamsFormatCsv RadarQualitySpeedTopAsesParamsFormat = "CSV" -) - -// Metric to order the results by. -type RadarQualitySpeedTopAsesParamsOrderBy string - -const ( - RadarQualitySpeedTopAsesParamsOrderByBandwidthDownload RadarQualitySpeedTopAsesParamsOrderBy = "BANDWIDTH_DOWNLOAD" - RadarQualitySpeedTopAsesParamsOrderByBandwidthUpload RadarQualitySpeedTopAsesParamsOrderBy = "BANDWIDTH_UPLOAD" - RadarQualitySpeedTopAsesParamsOrderByLatencyIdle RadarQualitySpeedTopAsesParamsOrderBy = "LATENCY_IDLE" - RadarQualitySpeedTopAsesParamsOrderByLatencyLoaded RadarQualitySpeedTopAsesParamsOrderBy = "LATENCY_LOADED" - RadarQualitySpeedTopAsesParamsOrderByJitterIdle RadarQualitySpeedTopAsesParamsOrderBy = "JITTER_IDLE" - RadarQualitySpeedTopAsesParamsOrderByJitterLoaded RadarQualitySpeedTopAsesParamsOrderBy = "JITTER_LOADED" -) - -type RadarQualitySpeedTopAsesResponseEnvelope struct { - Result RadarQualitySpeedTopAsesResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarQualitySpeedTopAsesResponseEnvelopeJSON `json:"-"` -} - -// radarQualitySpeedTopAsesResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarQualitySpeedTopAsesResponseEnvelope] -type radarQualitySpeedTopAsesResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedTopAsesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedTopAsesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarQualitySpeedTopLocationsParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarQualitySpeedTopLocationsParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // Metric to order the results by. - OrderBy param.Field[RadarQualitySpeedTopLocationsParamsOrderBy] `query:"orderBy"` - // Reverse the order of results. - Reverse param.Field[bool] `query:"reverse"` -} - -// URLQuery serializes [RadarQualitySpeedTopLocationsParams]'s query parameters as -// `url.Values`. -func (r RadarQualitySpeedTopLocationsParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Format results are returned in. -type RadarQualitySpeedTopLocationsParamsFormat string - -const ( - RadarQualitySpeedTopLocationsParamsFormatJson RadarQualitySpeedTopLocationsParamsFormat = "JSON" - RadarQualitySpeedTopLocationsParamsFormatCsv RadarQualitySpeedTopLocationsParamsFormat = "CSV" -) - -// Metric to order the results by. -type RadarQualitySpeedTopLocationsParamsOrderBy string - -const ( - RadarQualitySpeedTopLocationsParamsOrderByBandwidthDownload RadarQualitySpeedTopLocationsParamsOrderBy = "BANDWIDTH_DOWNLOAD" - RadarQualitySpeedTopLocationsParamsOrderByBandwidthUpload RadarQualitySpeedTopLocationsParamsOrderBy = "BANDWIDTH_UPLOAD" - RadarQualitySpeedTopLocationsParamsOrderByLatencyIdle RadarQualitySpeedTopLocationsParamsOrderBy = "LATENCY_IDLE" - RadarQualitySpeedTopLocationsParamsOrderByLatencyLoaded RadarQualitySpeedTopLocationsParamsOrderBy = "LATENCY_LOADED" - RadarQualitySpeedTopLocationsParamsOrderByJitterIdle RadarQualitySpeedTopLocationsParamsOrderBy = "JITTER_IDLE" - RadarQualitySpeedTopLocationsParamsOrderByJitterLoaded RadarQualitySpeedTopLocationsParamsOrderBy = "JITTER_LOADED" -) - -type RadarQualitySpeedTopLocationsResponseEnvelope struct { - Result RadarQualitySpeedTopLocationsResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarQualitySpeedTopLocationsResponseEnvelopeJSON `json:"-"` -} - -// radarQualitySpeedTopLocationsResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarQualitySpeedTopLocationsResponseEnvelope] -type radarQualitySpeedTopLocationsResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarQualitySpeedTopLocationsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarQualitySpeedTopLocationsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarqualityspeedtop_test.go b/radarqualityspeedtop_test.go deleted file mode 100644 index 8c4b70a35a9..00000000000 --- a/radarqualityspeedtop_test.go +++ /dev/null @@ -1,83 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarQualitySpeedTopAsesWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Quality.Speed.Top.Ases(context.TODO(), cloudflare.RadarQualitySpeedTopAsesParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarQualitySpeedTopAsesParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OrderBy: cloudflare.F(cloudflare.RadarQualitySpeedTopAsesParamsOrderByBandwidthDownload), - Reverse: cloudflare.F(true), - }) - 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 TestRadarQualitySpeedTopLocationsWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Quality.Speed.Top.Locations(context.TODO(), cloudflare.RadarQualitySpeedTopLocationsParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarQualitySpeedTopLocationsParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - OrderBy: cloudflare.F(cloudflare.RadarQualitySpeedTopLocationsParamsOrderByBandwidthDownload), - Reverse: cloudflare.F(true), - }) - 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/radarranking.go b/radarranking.go deleted file mode 100644 index 22e60097f36..00000000000 --- a/radarranking.go +++ /dev/null @@ -1,429 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarRankingService 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 [NewRadarRankingService] method -// instead. -type RadarRankingService struct { - Options []option.RequestOption - Domain *RadarRankingDomainService -} - -// NewRadarRankingService 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 NewRadarRankingService(opts ...option.RequestOption) (r *RadarRankingService) { - r = &RadarRankingService{} - r.Options = opts - r.Domain = NewRadarRankingDomainService(opts...) - return -} - -// Gets Domains Rank updates change over time. Raw values are returned. -func (r *RadarRankingService) TimeseriesGroups(ctx context.Context, query RadarRankingTimeseriesGroupsParams, opts ...option.RequestOption) (res *RadarRankingTimeseriesGroupsResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarRankingTimeseriesGroupsResponseEnvelope - path := "radar/ranking/timeseries_groups" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get top or trending domains based on their rank. Popular domains are domains of -// broad appeal based on how people use the Internet. Trending domains are domains -// that are generating a surge in interest. For more information on top domains, -// see https://blog.cloudflare.com/radar-domain-rankings/. -func (r *RadarRankingService) Top(ctx context.Context, query RadarRankingTopParams, opts ...option.RequestOption) (res *RadarRankingTopResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarRankingTopResponseEnvelope - path := "radar/ranking/top" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarRankingTimeseriesGroupsResponse struct { - Meta RadarRankingTimeseriesGroupsResponseMeta `json:"meta,required"` - Serie0 RadarRankingTimeseriesGroupsResponseSerie0 `json:"serie_0,required"` - JSON radarRankingTimeseriesGroupsResponseJSON `json:"-"` -} - -// radarRankingTimeseriesGroupsResponseJSON contains the JSON metadata for the -// struct [RadarRankingTimeseriesGroupsResponse] -type radarRankingTimeseriesGroupsResponseJSON struct { - Meta apijson.Field - Serie0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarRankingTimeseriesGroupsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarRankingTimeseriesGroupsResponseJSON) RawJSON() string { - return r.raw -} - -type RadarRankingTimeseriesGroupsResponseMeta struct { - DateRange []RadarRankingTimeseriesGroupsResponseMetaDateRange `json:"dateRange,required"` - JSON radarRankingTimeseriesGroupsResponseMetaJSON `json:"-"` -} - -// radarRankingTimeseriesGroupsResponseMetaJSON contains the JSON metadata for the -// struct [RadarRankingTimeseriesGroupsResponseMeta] -type radarRankingTimeseriesGroupsResponseMetaJSON struct { - DateRange apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarRankingTimeseriesGroupsResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarRankingTimeseriesGroupsResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarRankingTimeseriesGroupsResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarRankingTimeseriesGroupsResponseMetaDateRangeJSON `json:"-"` -} - -// radarRankingTimeseriesGroupsResponseMetaDateRangeJSON contains the JSON metadata -// for the struct [RadarRankingTimeseriesGroupsResponseMetaDateRange] -type radarRankingTimeseriesGroupsResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarRankingTimeseriesGroupsResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarRankingTimeseriesGroupsResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarRankingTimeseriesGroupsResponseSerie0 struct { - Timestamps []string `json:"timestamps,required"` - ExtraFields map[string][]RadarRankingTimeseriesGroupsResponseSerie0 `json:"-,extras"` - JSON radarRankingTimeseriesGroupsResponseSerie0JSON `json:"-"` -} - -// radarRankingTimeseriesGroupsResponseSerie0JSON contains the JSON metadata for -// the struct [RadarRankingTimeseriesGroupsResponseSerie0] -type radarRankingTimeseriesGroupsResponseSerie0JSON struct { - Timestamps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarRankingTimeseriesGroupsResponseSerie0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarRankingTimeseriesGroupsResponseSerie0JSON) RawJSON() string { - return r.raw -} - -type RadarRankingTopResponse struct { - Meta RadarRankingTopResponseMeta `json:"meta,required"` - Top0 []RadarRankingTopResponseTop0 `json:"top_0,required"` - JSON radarRankingTopResponseJSON `json:"-"` -} - -// radarRankingTopResponseJSON contains the JSON metadata for the struct -// [RadarRankingTopResponse] -type radarRankingTopResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarRankingTopResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarRankingTopResponseJSON) RawJSON() string { - return r.raw -} - -type RadarRankingTopResponseMeta struct { - Top0 RadarRankingTopResponseMetaTop0 `json:"top_0,required"` - JSON radarRankingTopResponseMetaJSON `json:"-"` -} - -// radarRankingTopResponseMetaJSON contains the JSON metadata for the struct -// [RadarRankingTopResponseMeta] -type radarRankingTopResponseMetaJSON struct { - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarRankingTopResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarRankingTopResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarRankingTopResponseMetaTop0 struct { - Date string `json:"date,required"` - JSON radarRankingTopResponseMetaTop0JSON `json:"-"` -} - -// radarRankingTopResponseMetaTop0JSON contains the JSON metadata for the struct -// [RadarRankingTopResponseMetaTop0] -type radarRankingTopResponseMetaTop0JSON struct { - Date apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarRankingTopResponseMetaTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarRankingTopResponseMetaTop0JSON) RawJSON() string { - return r.raw -} - -type RadarRankingTopResponseTop0 struct { - Categories []RadarRankingTopResponseTop0Category `json:"categories,required"` - Domain string `json:"domain,required"` - Rank int64 `json:"rank,required"` - // Only available in TRENDING rankings. - PctRankChange float64 `json:"pctRankChange"` - JSON radarRankingTopResponseTop0JSON `json:"-"` -} - -// radarRankingTopResponseTop0JSON contains the JSON metadata for the struct -// [RadarRankingTopResponseTop0] -type radarRankingTopResponseTop0JSON struct { - Categories apijson.Field - Domain apijson.Field - Rank apijson.Field - PctRankChange apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarRankingTopResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarRankingTopResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarRankingTopResponseTop0Category struct { - ID float64 `json:"id,required"` - Name string `json:"name,required"` - SuperCategoryID float64 `json:"superCategoryId,required"` - JSON radarRankingTopResponseTop0CategoryJSON `json:"-"` -} - -// radarRankingTopResponseTop0CategoryJSON contains the JSON metadata for the -// struct [RadarRankingTopResponseTop0Category] -type radarRankingTopResponseTop0CategoryJSON struct { - ID apijson.Field - Name apijson.Field - SuperCategoryID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarRankingTopResponseTop0Category) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarRankingTopResponseTop0CategoryJSON) RawJSON() string { - return r.raw -} - -type RadarRankingTimeseriesGroupsParams struct { - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarRankingTimeseriesGroupsParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Array of comma separated list of domains names. - Domains param.Field[[]string] `query:"domains"` - // Format results are returned in. - Format param.Field[RadarRankingTimeseriesGroupsParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of locations (alpha-2 country codes). - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // The ranking type. - RankingType param.Field[RadarRankingTimeseriesGroupsParamsRankingType] `query:"rankingType"` -} - -// URLQuery serializes [RadarRankingTimeseriesGroupsParams]'s query parameters as -// `url.Values`. -func (r RadarRankingTimeseriesGroupsParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarRankingTimeseriesGroupsParamsDateRange string - -const ( - RadarRankingTimeseriesGroupsParamsDateRange1d RadarRankingTimeseriesGroupsParamsDateRange = "1d" - RadarRankingTimeseriesGroupsParamsDateRange2d RadarRankingTimeseriesGroupsParamsDateRange = "2d" - RadarRankingTimeseriesGroupsParamsDateRange7d RadarRankingTimeseriesGroupsParamsDateRange = "7d" - RadarRankingTimeseriesGroupsParamsDateRange14d RadarRankingTimeseriesGroupsParamsDateRange = "14d" - RadarRankingTimeseriesGroupsParamsDateRange28d RadarRankingTimeseriesGroupsParamsDateRange = "28d" - RadarRankingTimeseriesGroupsParamsDateRange12w RadarRankingTimeseriesGroupsParamsDateRange = "12w" - RadarRankingTimeseriesGroupsParamsDateRange24w RadarRankingTimeseriesGroupsParamsDateRange = "24w" - RadarRankingTimeseriesGroupsParamsDateRange52w RadarRankingTimeseriesGroupsParamsDateRange = "52w" - RadarRankingTimeseriesGroupsParamsDateRange1dControl RadarRankingTimeseriesGroupsParamsDateRange = "1dControl" - RadarRankingTimeseriesGroupsParamsDateRange2dControl RadarRankingTimeseriesGroupsParamsDateRange = "2dControl" - RadarRankingTimeseriesGroupsParamsDateRange7dControl RadarRankingTimeseriesGroupsParamsDateRange = "7dControl" - RadarRankingTimeseriesGroupsParamsDateRange14dControl RadarRankingTimeseriesGroupsParamsDateRange = "14dControl" - RadarRankingTimeseriesGroupsParamsDateRange28dControl RadarRankingTimeseriesGroupsParamsDateRange = "28dControl" - RadarRankingTimeseriesGroupsParamsDateRange12wControl RadarRankingTimeseriesGroupsParamsDateRange = "12wControl" - RadarRankingTimeseriesGroupsParamsDateRange24wControl RadarRankingTimeseriesGroupsParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarRankingTimeseriesGroupsParamsFormat string - -const ( - RadarRankingTimeseriesGroupsParamsFormatJson RadarRankingTimeseriesGroupsParamsFormat = "JSON" - RadarRankingTimeseriesGroupsParamsFormatCsv RadarRankingTimeseriesGroupsParamsFormat = "CSV" -) - -// The ranking type. -type RadarRankingTimeseriesGroupsParamsRankingType string - -const ( - RadarRankingTimeseriesGroupsParamsRankingTypePopular RadarRankingTimeseriesGroupsParamsRankingType = "POPULAR" - RadarRankingTimeseriesGroupsParamsRankingTypeTrendingRise RadarRankingTimeseriesGroupsParamsRankingType = "TRENDING_RISE" - RadarRankingTimeseriesGroupsParamsRankingTypeTrendingSteady RadarRankingTimeseriesGroupsParamsRankingType = "TRENDING_STEADY" -) - -type RadarRankingTimeseriesGroupsResponseEnvelope struct { - Result RadarRankingTimeseriesGroupsResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarRankingTimeseriesGroupsResponseEnvelopeJSON `json:"-"` -} - -// radarRankingTimeseriesGroupsResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarRankingTimeseriesGroupsResponseEnvelope] -type radarRankingTimeseriesGroupsResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarRankingTimeseriesGroupsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarRankingTimeseriesGroupsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarRankingTopParams struct { - // Array of dates to filter the ranking. - Date param.Field[[]string] `query:"date"` - // Format results are returned in. - Format param.Field[RadarRankingTopParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of locations (alpha-2 country codes). - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // The ranking type. - RankingType param.Field[RadarRankingTopParamsRankingType] `query:"rankingType"` -} - -// URLQuery serializes [RadarRankingTopParams]'s query parameters as `url.Values`. -func (r RadarRankingTopParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Format results are returned in. -type RadarRankingTopParamsFormat string - -const ( - RadarRankingTopParamsFormatJson RadarRankingTopParamsFormat = "JSON" - RadarRankingTopParamsFormatCsv RadarRankingTopParamsFormat = "CSV" -) - -// The ranking type. -type RadarRankingTopParamsRankingType string - -const ( - RadarRankingTopParamsRankingTypePopular RadarRankingTopParamsRankingType = "POPULAR" - RadarRankingTopParamsRankingTypeTrendingRise RadarRankingTopParamsRankingType = "TRENDING_RISE" - RadarRankingTopParamsRankingTypeTrendingSteady RadarRankingTopParamsRankingType = "TRENDING_STEADY" -) - -type RadarRankingTopResponseEnvelope struct { - Result RadarRankingTopResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarRankingTopResponseEnvelopeJSON `json:"-"` -} - -// radarRankingTopResponseEnvelopeJSON contains the JSON metadata for the struct -// [RadarRankingTopResponseEnvelope] -type radarRankingTopResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarRankingTopResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarRankingTopResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarranking_test.go b/radarranking_test.go deleted file mode 100644 index cf806a60ced..00000000000 --- a/radarranking_test.go +++ /dev/null @@ -1,80 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarRankingTimeseriesGroupsWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Ranking.TimeseriesGroups(context.TODO(), cloudflare.RadarRankingTimeseriesGroupsParams{ - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarRankingTimeseriesGroupsParamsDateRange{cloudflare.RadarRankingTimeseriesGroupsParamsDateRange1d, cloudflare.RadarRankingTimeseriesGroupsParamsDateRange2d, cloudflare.RadarRankingTimeseriesGroupsParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Domains: cloudflare.F([]string{"string", "string", "string"}), - Format: cloudflare.F(cloudflare.RadarRankingTimeseriesGroupsParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - RankingType: cloudflare.F(cloudflare.RadarRankingTimeseriesGroupsParamsRankingTypePopular), - }) - 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 TestRadarRankingTopWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Ranking.Top(context.TODO(), cloudflare.RadarRankingTopParams{ - Date: cloudflare.F([]string{"string", "string", "string"}), - Format: cloudflare.F(cloudflare.RadarRankingTopParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - RankingType: cloudflare.F(cloudflare.RadarRankingTopParamsRankingTypePopular), - }) - 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/radarrankingdomain.go b/radarrankingdomain.go deleted file mode 100644 index ca5df8530db..00000000000 --- a/radarrankingdomain.go +++ /dev/null @@ -1,211 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarRankingDomainService 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 [NewRadarRankingDomainService] method -// instead. -type RadarRankingDomainService struct { - Options []option.RequestOption -} - -// NewRadarRankingDomainService 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 NewRadarRankingDomainService(opts ...option.RequestOption) (r *RadarRankingDomainService) { - r = &RadarRankingDomainService{} - r.Options = opts - return -} - -// Gets Domains Rank details. Cloudflare provides an ordered rank for the top 100 -// domains, but for the remainder it only provides ranking buckets like top 200 -// thousand, top one million, etc.. These are available through Radar datasets -// endpoints. -func (r *RadarRankingDomainService) Get(ctx context.Context, domain string, query RadarRankingDomainGetParams, opts ...option.RequestOption) (res *RadarRankingDomainGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarRankingDomainGetResponseEnvelope - path := fmt.Sprintf("radar/ranking/domain/%s", domain) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarRankingDomainGetResponse struct { - Details0 RadarRankingDomainGetResponseDetails0 `json:"details_0,required"` - JSON radarRankingDomainGetResponseJSON `json:"-"` -} - -// radarRankingDomainGetResponseJSON contains the JSON metadata for the struct -// [RadarRankingDomainGetResponse] -type radarRankingDomainGetResponseJSON struct { - Details0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarRankingDomainGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarRankingDomainGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarRankingDomainGetResponseDetails0 struct { - Categories []RadarRankingDomainGetResponseDetails0Category `json:"categories,required"` - TopLocations []RadarRankingDomainGetResponseDetails0TopLocation `json:"top_locations,required"` - // Only available in POPULAR ranking for the most recent ranking. - Bucket string `json:"bucket"` - Rank int64 `json:"rank"` - JSON radarRankingDomainGetResponseDetails0JSON `json:"-"` -} - -// radarRankingDomainGetResponseDetails0JSON contains the JSON metadata for the -// struct [RadarRankingDomainGetResponseDetails0] -type radarRankingDomainGetResponseDetails0JSON struct { - Categories apijson.Field - TopLocations apijson.Field - Bucket apijson.Field - Rank apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarRankingDomainGetResponseDetails0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarRankingDomainGetResponseDetails0JSON) RawJSON() string { - return r.raw -} - -type RadarRankingDomainGetResponseDetails0Category struct { - ID float64 `json:"id,required"` - Name string `json:"name,required"` - SuperCategoryID float64 `json:"superCategoryId,required"` - JSON radarRankingDomainGetResponseDetails0CategoryJSON `json:"-"` -} - -// radarRankingDomainGetResponseDetails0CategoryJSON contains the JSON metadata for -// the struct [RadarRankingDomainGetResponseDetails0Category] -type radarRankingDomainGetResponseDetails0CategoryJSON struct { - ID apijson.Field - Name apijson.Field - SuperCategoryID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarRankingDomainGetResponseDetails0Category) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarRankingDomainGetResponseDetails0CategoryJSON) RawJSON() string { - return r.raw -} - -type RadarRankingDomainGetResponseDetails0TopLocation struct { - LocationCode string `json:"locationCode,required"` - LocationName string `json:"locationName,required"` - Rank int64 `json:"rank,required"` - JSON radarRankingDomainGetResponseDetails0TopLocationJSON `json:"-"` -} - -// radarRankingDomainGetResponseDetails0TopLocationJSON contains the JSON metadata -// for the struct [RadarRankingDomainGetResponseDetails0TopLocation] -type radarRankingDomainGetResponseDetails0TopLocationJSON struct { - LocationCode apijson.Field - LocationName apijson.Field - Rank apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarRankingDomainGetResponseDetails0TopLocation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarRankingDomainGetResponseDetails0TopLocationJSON) RawJSON() string { - return r.raw -} - -type RadarRankingDomainGetParams struct { - // Array of dates to filter the ranking. - Date param.Field[[]string] `query:"date"` - // Format results are returned in. - Format param.Field[RadarRankingDomainGetParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` - // The ranking type. - RankingType param.Field[RadarRankingDomainGetParamsRankingType] `query:"rankingType"` -} - -// URLQuery serializes [RadarRankingDomainGetParams]'s query parameters as -// `url.Values`. -func (r RadarRankingDomainGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Format results are returned in. -type RadarRankingDomainGetParamsFormat string - -const ( - RadarRankingDomainGetParamsFormatJson RadarRankingDomainGetParamsFormat = "JSON" - RadarRankingDomainGetParamsFormatCsv RadarRankingDomainGetParamsFormat = "CSV" -) - -// The ranking type. -type RadarRankingDomainGetParamsRankingType string - -const ( - RadarRankingDomainGetParamsRankingTypePopular RadarRankingDomainGetParamsRankingType = "POPULAR" - RadarRankingDomainGetParamsRankingTypeTrendingRise RadarRankingDomainGetParamsRankingType = "TRENDING_RISE" - RadarRankingDomainGetParamsRankingTypeTrendingSteady RadarRankingDomainGetParamsRankingType = "TRENDING_STEADY" -) - -type RadarRankingDomainGetResponseEnvelope struct { - Result RadarRankingDomainGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarRankingDomainGetResponseEnvelopeJSON `json:"-"` -} - -// radarRankingDomainGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarRankingDomainGetResponseEnvelope] -type radarRankingDomainGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarRankingDomainGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarRankingDomainGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarrankingdomain_test.go b/radarrankingdomain_test.go deleted file mode 100644 index 86a1027f181..00000000000 --- a/radarrankingdomain_test.go +++ /dev/null @@ -1,48 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarRankingDomainGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Ranking.Domain.Get( - context.TODO(), - "google.com", - cloudflare.RadarRankingDomainGetParams{ - Date: cloudflare.F([]string{"string", "string", "string"}), - Format: cloudflare.F(cloudflare.RadarRankingDomainGetParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Name: cloudflare.F([]string{"string", "string", "string"}), - RankingType: cloudflare.F(cloudflare.RadarRankingDomainGetParamsRankingTypePopular), - }, - ) - 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/radarsearch.go b/radarsearch.go deleted file mode 100644 index b53831905fe..00000000000 --- a/radarsearch.go +++ /dev/null @@ -1,165 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarSearchService 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 [NewRadarSearchService] method -// instead. -type RadarSearchService struct { - Options []option.RequestOption -} - -// NewRadarSearchService 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 NewRadarSearchService(opts ...option.RequestOption) (r *RadarSearchService) { - r = &RadarSearchService{} - r.Options = opts - return -} - -// Lets you search for locations, autonomous systems (AS) and reports. -func (r *RadarSearchService) Global(ctx context.Context, query RadarSearchGlobalParams, opts ...option.RequestOption) (res *RadarSearchGlobalResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarSearchGlobalResponseEnvelope - path := "radar/search/global" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarSearchGlobalResponse struct { - Search []RadarSearchGlobalResponseSearch `json:"search,required"` - JSON radarSearchGlobalResponseJSON `json:"-"` -} - -// radarSearchGlobalResponseJSON contains the JSON metadata for the struct -// [RadarSearchGlobalResponse] -type radarSearchGlobalResponseJSON struct { - Search apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarSearchGlobalResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarSearchGlobalResponseJSON) RawJSON() string { - return r.raw -} - -type RadarSearchGlobalResponseSearch struct { - Code string `json:"code,required"` - Name string `json:"name,required"` - Type string `json:"type,required"` - JSON radarSearchGlobalResponseSearchJSON `json:"-"` -} - -// radarSearchGlobalResponseSearchJSON contains the JSON metadata for the struct -// [RadarSearchGlobalResponseSearch] -type radarSearchGlobalResponseSearchJSON struct { - Code apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarSearchGlobalResponseSearch) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarSearchGlobalResponseSearchJSON) RawJSON() string { - return r.raw -} - -type RadarSearchGlobalParams struct { - // Search for locations, AS and reports. - Query param.Field[string] `query:"query,required"` - // Search types to be excluded from results. - Exclude param.Field[[]RadarSearchGlobalParamsExclude] `query:"exclude"` - // Format results are returned in. - Format param.Field[RadarSearchGlobalParamsFormat] `query:"format"` - // Search types to be included in results. - Include param.Field[[]RadarSearchGlobalParamsInclude] `query:"include"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Limit the number of objects per search category. - LimitPerGroup param.Field[float64] `query:"limitPerGroup"` -} - -// URLQuery serializes [RadarSearchGlobalParams]'s query parameters as -// `url.Values`. -func (r RadarSearchGlobalParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarSearchGlobalParamsExclude string - -const ( - RadarSearchGlobalParamsExcludeSpecialEvents RadarSearchGlobalParamsExclude = "SPECIAL_EVENTS" - RadarSearchGlobalParamsExcludeNotebooks RadarSearchGlobalParamsExclude = "NOTEBOOKS" - RadarSearchGlobalParamsExcludeLocations RadarSearchGlobalParamsExclude = "LOCATIONS" - RadarSearchGlobalParamsExcludeASNs RadarSearchGlobalParamsExclude = "ASNS" -) - -// Format results are returned in. -type RadarSearchGlobalParamsFormat string - -const ( - RadarSearchGlobalParamsFormatJson RadarSearchGlobalParamsFormat = "JSON" - RadarSearchGlobalParamsFormatCsv RadarSearchGlobalParamsFormat = "CSV" -) - -type RadarSearchGlobalParamsInclude string - -const ( - RadarSearchGlobalParamsIncludeSpecialEvents RadarSearchGlobalParamsInclude = "SPECIAL_EVENTS" - RadarSearchGlobalParamsIncludeNotebooks RadarSearchGlobalParamsInclude = "NOTEBOOKS" - RadarSearchGlobalParamsIncludeLocations RadarSearchGlobalParamsInclude = "LOCATIONS" - RadarSearchGlobalParamsIncludeASNs RadarSearchGlobalParamsInclude = "ASNS" -) - -type RadarSearchGlobalResponseEnvelope struct { - Result RadarSearchGlobalResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarSearchGlobalResponseEnvelopeJSON `json:"-"` -} - -// radarSearchGlobalResponseEnvelopeJSON contains the JSON metadata for the struct -// [RadarSearchGlobalResponseEnvelope] -type radarSearchGlobalResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarSearchGlobalResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarSearchGlobalResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarsearch_test.go b/radarsearch_test.go deleted file mode 100644 index 63f476134de..00000000000 --- a/radarsearch_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarSearchGlobalWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.Search.Global(context.TODO(), cloudflare.RadarSearchGlobalParams{ - Query: cloudflare.F("United"), - Exclude: cloudflare.F([]cloudflare.RadarSearchGlobalParamsExclude{cloudflare.RadarSearchGlobalParamsExcludeSpecialEvents, cloudflare.RadarSearchGlobalParamsExcludeNotebooks, cloudflare.RadarSearchGlobalParamsExcludeLocations}), - Format: cloudflare.F(cloudflare.RadarSearchGlobalParamsFormatJson), - Include: cloudflare.F([]cloudflare.RadarSearchGlobalParamsInclude{cloudflare.RadarSearchGlobalParamsIncludeSpecialEvents, cloudflare.RadarSearchGlobalParamsIncludeNotebooks, cloudflare.RadarSearchGlobalParamsIncludeLocations}), - Limit: cloudflare.F(int64(5)), - LimitPerGroup: cloudflare.F(0.000000), - }) - 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/radartrafficanomaly.go b/radartrafficanomaly.go deleted file mode 100644 index 4639abd0b6c..00000000000 --- a/radartrafficanomaly.go +++ /dev/null @@ -1,271 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarTrafficAnomalyService 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 [NewRadarTrafficAnomalyService] -// method instead. -type RadarTrafficAnomalyService struct { - Options []option.RequestOption - Locations *RadarTrafficAnomalyLocationService -} - -// NewRadarTrafficAnomalyService 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 NewRadarTrafficAnomalyService(opts ...option.RequestOption) (r *RadarTrafficAnomalyService) { - r = &RadarTrafficAnomalyService{} - r.Options = opts - r.Locations = NewRadarTrafficAnomalyLocationService(opts...) - return -} - -// Internet traffic anomalies are signals that might point to an outage, These -// alerts are automatically detected by Radar and then manually verified by our -// team. This endpoint returns the latest alerts. -func (r *RadarTrafficAnomalyService) Get(ctx context.Context, query RadarTrafficAnomalyGetParams, opts ...option.RequestOption) (res *RadarTrafficAnomalyGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarTrafficAnomalyGetResponseEnvelope - path := "radar/traffic_anomalies" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarTrafficAnomalyGetResponse struct { - TrafficAnomalies []RadarTrafficAnomalyGetResponseTrafficAnomaly `json:"trafficAnomalies,required"` - JSON radarTrafficAnomalyGetResponseJSON `json:"-"` -} - -// radarTrafficAnomalyGetResponseJSON contains the JSON metadata for the struct -// [RadarTrafficAnomalyGetResponse] -type radarTrafficAnomalyGetResponseJSON struct { - TrafficAnomalies apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarTrafficAnomalyGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarTrafficAnomalyGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarTrafficAnomalyGetResponseTrafficAnomaly struct { - StartDate string `json:"startDate,required"` - Status string `json:"status,required"` - Type string `json:"type,required"` - UUID string `json:"uuid,required"` - ASNDetails RadarTrafficAnomalyGetResponseTrafficAnomaliesASNDetails `json:"asnDetails"` - EndDate string `json:"endDate"` - LocationDetails RadarTrafficAnomalyGetResponseTrafficAnomaliesLocationDetails `json:"locationDetails"` - VisibleInDataSources []string `json:"visibleInDataSources"` - JSON radarTrafficAnomalyGetResponseTrafficAnomalyJSON `json:"-"` -} - -// radarTrafficAnomalyGetResponseTrafficAnomalyJSON contains the JSON metadata for -// the struct [RadarTrafficAnomalyGetResponseTrafficAnomaly] -type radarTrafficAnomalyGetResponseTrafficAnomalyJSON struct { - StartDate apijson.Field - Status apijson.Field - Type apijson.Field - UUID apijson.Field - ASNDetails apijson.Field - EndDate apijson.Field - LocationDetails apijson.Field - VisibleInDataSources apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarTrafficAnomalyGetResponseTrafficAnomaly) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarTrafficAnomalyGetResponseTrafficAnomalyJSON) RawJSON() string { - return r.raw -} - -type RadarTrafficAnomalyGetResponseTrafficAnomaliesASNDetails struct { - ASN string `json:"asn,required"` - Name string `json:"name,required"` - Locations RadarTrafficAnomalyGetResponseTrafficAnomaliesASNDetailsLocations `json:"locations"` - JSON radarTrafficAnomalyGetResponseTrafficAnomaliesASNDetailsJSON `json:"-"` -} - -// radarTrafficAnomalyGetResponseTrafficAnomaliesASNDetailsJSON contains the JSON -// metadata for the struct -// [RadarTrafficAnomalyGetResponseTrafficAnomaliesASNDetails] -type radarTrafficAnomalyGetResponseTrafficAnomaliesASNDetailsJSON struct { - ASN apijson.Field - Name apijson.Field - Locations apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarTrafficAnomalyGetResponseTrafficAnomaliesASNDetails) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarTrafficAnomalyGetResponseTrafficAnomaliesASNDetailsJSON) RawJSON() string { - return r.raw -} - -type RadarTrafficAnomalyGetResponseTrafficAnomaliesASNDetailsLocations struct { - Code string `json:"code,required"` - Name string `json:"name,required"` - JSON radarTrafficAnomalyGetResponseTrafficAnomaliesASNDetailsLocationsJSON `json:"-"` -} - -// radarTrafficAnomalyGetResponseTrafficAnomaliesASNDetailsLocationsJSON contains -// the JSON metadata for the struct -// [RadarTrafficAnomalyGetResponseTrafficAnomaliesASNDetailsLocations] -type radarTrafficAnomalyGetResponseTrafficAnomaliesASNDetailsLocationsJSON struct { - Code apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarTrafficAnomalyGetResponseTrafficAnomaliesASNDetailsLocations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarTrafficAnomalyGetResponseTrafficAnomaliesASNDetailsLocationsJSON) RawJSON() string { - return r.raw -} - -type RadarTrafficAnomalyGetResponseTrafficAnomaliesLocationDetails struct { - Code string `json:"code,required"` - Name string `json:"name,required"` - JSON radarTrafficAnomalyGetResponseTrafficAnomaliesLocationDetailsJSON `json:"-"` -} - -// radarTrafficAnomalyGetResponseTrafficAnomaliesLocationDetailsJSON contains the -// JSON metadata for the struct -// [RadarTrafficAnomalyGetResponseTrafficAnomaliesLocationDetails] -type radarTrafficAnomalyGetResponseTrafficAnomaliesLocationDetailsJSON struct { - Code apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarTrafficAnomalyGetResponseTrafficAnomaliesLocationDetails) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarTrafficAnomalyGetResponseTrafficAnomaliesLocationDetailsJSON) RawJSON() string { - return r.raw -} - -type RadarTrafficAnomalyGetParams struct { - // Single ASN as integer. - ASN param.Field[int64] `query:"asn"` - // End of the date range (inclusive). - DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"` - // Shorthand date ranges for the last X days - use when you don't need specific - // start and end dates. - DateRange param.Field[RadarTrafficAnomalyGetParamsDateRange] `query:"dateRange"` - // Start of the date range (inclusive). - DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarTrafficAnomalyGetParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Location Alpha2 code. - Location param.Field[string] `query:"location"` - // Number of objects to skip before grabbing results. - Offset param.Field[int64] `query:"offset"` - Status param.Field[RadarTrafficAnomalyGetParamsStatus] `query:"status"` -} - -// URLQuery serializes [RadarTrafficAnomalyGetParams]'s query parameters as -// `url.Values`. -func (r RadarTrafficAnomalyGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Shorthand date ranges for the last X days - use when you don't need specific -// start and end dates. -type RadarTrafficAnomalyGetParamsDateRange string - -const ( - RadarTrafficAnomalyGetParamsDateRange1d RadarTrafficAnomalyGetParamsDateRange = "1d" - RadarTrafficAnomalyGetParamsDateRange2d RadarTrafficAnomalyGetParamsDateRange = "2d" - RadarTrafficAnomalyGetParamsDateRange7d RadarTrafficAnomalyGetParamsDateRange = "7d" - RadarTrafficAnomalyGetParamsDateRange14d RadarTrafficAnomalyGetParamsDateRange = "14d" - RadarTrafficAnomalyGetParamsDateRange28d RadarTrafficAnomalyGetParamsDateRange = "28d" - RadarTrafficAnomalyGetParamsDateRange12w RadarTrafficAnomalyGetParamsDateRange = "12w" - RadarTrafficAnomalyGetParamsDateRange24w RadarTrafficAnomalyGetParamsDateRange = "24w" - RadarTrafficAnomalyGetParamsDateRange52w RadarTrafficAnomalyGetParamsDateRange = "52w" - RadarTrafficAnomalyGetParamsDateRange1dControl RadarTrafficAnomalyGetParamsDateRange = "1dControl" - RadarTrafficAnomalyGetParamsDateRange2dControl RadarTrafficAnomalyGetParamsDateRange = "2dControl" - RadarTrafficAnomalyGetParamsDateRange7dControl RadarTrafficAnomalyGetParamsDateRange = "7dControl" - RadarTrafficAnomalyGetParamsDateRange14dControl RadarTrafficAnomalyGetParamsDateRange = "14dControl" - RadarTrafficAnomalyGetParamsDateRange28dControl RadarTrafficAnomalyGetParamsDateRange = "28dControl" - RadarTrafficAnomalyGetParamsDateRange12wControl RadarTrafficAnomalyGetParamsDateRange = "12wControl" - RadarTrafficAnomalyGetParamsDateRange24wControl RadarTrafficAnomalyGetParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarTrafficAnomalyGetParamsFormat string - -const ( - RadarTrafficAnomalyGetParamsFormatJson RadarTrafficAnomalyGetParamsFormat = "JSON" - RadarTrafficAnomalyGetParamsFormatCsv RadarTrafficAnomalyGetParamsFormat = "CSV" -) - -type RadarTrafficAnomalyGetParamsStatus string - -const ( - RadarTrafficAnomalyGetParamsStatusVerified RadarTrafficAnomalyGetParamsStatus = "VERIFIED" - RadarTrafficAnomalyGetParamsStatusUnverified RadarTrafficAnomalyGetParamsStatus = "UNVERIFIED" -) - -type RadarTrafficAnomalyGetResponseEnvelope struct { - Result RadarTrafficAnomalyGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarTrafficAnomalyGetResponseEnvelopeJSON `json:"-"` -} - -// radarTrafficAnomalyGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarTrafficAnomalyGetResponseEnvelope] -type radarTrafficAnomalyGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarTrafficAnomalyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarTrafficAnomalyGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radartrafficanomaly_test.go b/radartrafficanomaly_test.go deleted file mode 100644 index ec1e88ebd76..00000000000 --- a/radartrafficanomaly_test.go +++ /dev/null @@ -1,49 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarTrafficAnomalyGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.TrafficAnomalies.Get(context.TODO(), cloudflare.RadarTrafficAnomalyGetParams{ - ASN: cloudflare.F(int64(0)), - DateEnd: cloudflare.F(time.Now()), - DateRange: cloudflare.F(cloudflare.RadarTrafficAnomalyGetParamsDateRange7d), - DateStart: cloudflare.F(time.Now()), - Format: cloudflare.F(cloudflare.RadarTrafficAnomalyGetParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F("US"), - Offset: cloudflare.F(int64(0)), - Status: cloudflare.F(cloudflare.RadarTrafficAnomalyGetParamsStatusVerified), - }) - 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/radartrafficanomalylocation.go b/radartrafficanomalylocation.go deleted file mode 100644 index f21521cf79d..00000000000 --- a/radartrafficanomalylocation.go +++ /dev/null @@ -1,179 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarTrafficAnomalyLocationService 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 -// [NewRadarTrafficAnomalyLocationService] method instead. -type RadarTrafficAnomalyLocationService struct { - Options []option.RequestOption -} - -// NewRadarTrafficAnomalyLocationService 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 NewRadarTrafficAnomalyLocationService(opts ...option.RequestOption) (r *RadarTrafficAnomalyLocationService) { - r = &RadarTrafficAnomalyLocationService{} - r.Options = opts - return -} - -// Internet traffic anomalies are signals that might point to an outage, These -// alerts are automatically detected by Radar and then manually verified by our -// team. This endpoint returns the sum of alerts grouped by location. -func (r *RadarTrafficAnomalyLocationService) Get(ctx context.Context, query RadarTrafficAnomalyLocationGetParams, opts ...option.RequestOption) (res *RadarTrafficAnomalyLocationGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarTrafficAnomalyLocationGetResponseEnvelope - path := "radar/traffic_anomalies/locations" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarTrafficAnomalyLocationGetResponse struct { - TrafficAnomalies []RadarTrafficAnomalyLocationGetResponseTrafficAnomaly `json:"trafficAnomalies,required"` - JSON radarTrafficAnomalyLocationGetResponseJSON `json:"-"` -} - -// radarTrafficAnomalyLocationGetResponseJSON contains the JSON metadata for the -// struct [RadarTrafficAnomalyLocationGetResponse] -type radarTrafficAnomalyLocationGetResponseJSON struct { - TrafficAnomalies apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarTrafficAnomalyLocationGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarTrafficAnomalyLocationGetResponseJSON) RawJSON() string { - return r.raw -} - -type RadarTrafficAnomalyLocationGetResponseTrafficAnomaly struct { - ClientCountryAlpha2 string `json:"clientCountryAlpha2,required"` - ClientCountryName string `json:"clientCountryName,required"` - Value string `json:"value,required"` - JSON radarTrafficAnomalyLocationGetResponseTrafficAnomalyJSON `json:"-"` -} - -// radarTrafficAnomalyLocationGetResponseTrafficAnomalyJSON contains the JSON -// metadata for the struct [RadarTrafficAnomalyLocationGetResponseTrafficAnomaly] -type radarTrafficAnomalyLocationGetResponseTrafficAnomalyJSON struct { - ClientCountryAlpha2 apijson.Field - ClientCountryName apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarTrafficAnomalyLocationGetResponseTrafficAnomaly) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarTrafficAnomalyLocationGetResponseTrafficAnomalyJSON) RawJSON() string { - return r.raw -} - -type RadarTrafficAnomalyLocationGetParams struct { - // End of the date range (inclusive). - DateEnd param.Field[time.Time] `query:"dateEnd" format:"date-time"` - // Shorthand date ranges for the last X days - use when you don't need specific - // start and end dates. - DateRange param.Field[RadarTrafficAnomalyLocationGetParamsDateRange] `query:"dateRange"` - // Start of the date range (inclusive). - DateStart param.Field[time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarTrafficAnomalyLocationGetParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - Status param.Field[RadarTrafficAnomalyLocationGetParamsStatus] `query:"status"` -} - -// URLQuery serializes [RadarTrafficAnomalyLocationGetParams]'s query parameters as -// `url.Values`. -func (r RadarTrafficAnomalyLocationGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Shorthand date ranges for the last X days - use when you don't need specific -// start and end dates. -type RadarTrafficAnomalyLocationGetParamsDateRange string - -const ( - RadarTrafficAnomalyLocationGetParamsDateRange1d RadarTrafficAnomalyLocationGetParamsDateRange = "1d" - RadarTrafficAnomalyLocationGetParamsDateRange2d RadarTrafficAnomalyLocationGetParamsDateRange = "2d" - RadarTrafficAnomalyLocationGetParamsDateRange7d RadarTrafficAnomalyLocationGetParamsDateRange = "7d" - RadarTrafficAnomalyLocationGetParamsDateRange14d RadarTrafficAnomalyLocationGetParamsDateRange = "14d" - RadarTrafficAnomalyLocationGetParamsDateRange28d RadarTrafficAnomalyLocationGetParamsDateRange = "28d" - RadarTrafficAnomalyLocationGetParamsDateRange12w RadarTrafficAnomalyLocationGetParamsDateRange = "12w" - RadarTrafficAnomalyLocationGetParamsDateRange24w RadarTrafficAnomalyLocationGetParamsDateRange = "24w" - RadarTrafficAnomalyLocationGetParamsDateRange52w RadarTrafficAnomalyLocationGetParamsDateRange = "52w" - RadarTrafficAnomalyLocationGetParamsDateRange1dControl RadarTrafficAnomalyLocationGetParamsDateRange = "1dControl" - RadarTrafficAnomalyLocationGetParamsDateRange2dControl RadarTrafficAnomalyLocationGetParamsDateRange = "2dControl" - RadarTrafficAnomalyLocationGetParamsDateRange7dControl RadarTrafficAnomalyLocationGetParamsDateRange = "7dControl" - RadarTrafficAnomalyLocationGetParamsDateRange14dControl RadarTrafficAnomalyLocationGetParamsDateRange = "14dControl" - RadarTrafficAnomalyLocationGetParamsDateRange28dControl RadarTrafficAnomalyLocationGetParamsDateRange = "28dControl" - RadarTrafficAnomalyLocationGetParamsDateRange12wControl RadarTrafficAnomalyLocationGetParamsDateRange = "12wControl" - RadarTrafficAnomalyLocationGetParamsDateRange24wControl RadarTrafficAnomalyLocationGetParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarTrafficAnomalyLocationGetParamsFormat string - -const ( - RadarTrafficAnomalyLocationGetParamsFormatJson RadarTrafficAnomalyLocationGetParamsFormat = "JSON" - RadarTrafficAnomalyLocationGetParamsFormatCsv RadarTrafficAnomalyLocationGetParamsFormat = "CSV" -) - -type RadarTrafficAnomalyLocationGetParamsStatus string - -const ( - RadarTrafficAnomalyLocationGetParamsStatusVerified RadarTrafficAnomalyLocationGetParamsStatus = "VERIFIED" - RadarTrafficAnomalyLocationGetParamsStatusUnverified RadarTrafficAnomalyLocationGetParamsStatus = "UNVERIFIED" -) - -type RadarTrafficAnomalyLocationGetResponseEnvelope struct { - Result RadarTrafficAnomalyLocationGetResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarTrafficAnomalyLocationGetResponseEnvelopeJSON `json:"-"` -} - -// radarTrafficAnomalyLocationGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [RadarTrafficAnomalyLocationGetResponseEnvelope] -type radarTrafficAnomalyLocationGetResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarTrafficAnomalyLocationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarTrafficAnomalyLocationGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radartrafficanomalylocation_test.go b/radartrafficanomalylocation_test.go deleted file mode 100644 index 299c7fc81b2..00000000000 --- a/radartrafficanomalylocation_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarTrafficAnomalyLocationGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.TrafficAnomalies.Locations.Get(context.TODO(), cloudflare.RadarTrafficAnomalyLocationGetParams{ - DateEnd: cloudflare.F(time.Now()), - DateRange: cloudflare.F(cloudflare.RadarTrafficAnomalyLocationGetParamsDateRange7d), - DateStart: cloudflare.F(time.Now()), - Format: cloudflare.F(cloudflare.RadarTrafficAnomalyLocationGetParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Status: cloudflare.F(cloudflare.RadarTrafficAnomalyLocationGetParamsStatusVerified), - }) - 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/radarverifiedbot.go b/radarverifiedbot.go deleted file mode 100644 index cffe7eb0a4b..00000000000 --- a/radarverifiedbot.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarVerifiedBotService 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 [NewRadarVerifiedBotService] method -// instead. -type RadarVerifiedBotService struct { - Options []option.RequestOption - Top *RadarVerifiedBotTopService -} - -// NewRadarVerifiedBotService 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 NewRadarVerifiedBotService(opts ...option.RequestOption) (r *RadarVerifiedBotService) { - r = &RadarVerifiedBotService{} - r.Options = opts - r.Top = NewRadarVerifiedBotTopService(opts...) - return -} diff --git a/radarverifiedbottop.go b/radarverifiedbottop.go deleted file mode 100644 index 1c1e60a319a..00000000000 --- a/radarverifiedbottop.go +++ /dev/null @@ -1,546 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RadarVerifiedBotTopService 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 [NewRadarVerifiedBotTopService] -// method instead. -type RadarVerifiedBotTopService struct { - Options []option.RequestOption -} - -// NewRadarVerifiedBotTopService 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 NewRadarVerifiedBotTopService(opts ...option.RequestOption) (r *RadarVerifiedBotTopService) { - r = &RadarVerifiedBotTopService{} - r.Options = opts - return -} - -// Get top verified bots by HTTP requests, with owner and category. -func (r *RadarVerifiedBotTopService) Bots(ctx context.Context, query RadarVerifiedBotTopBotsParams, opts ...option.RequestOption) (res *RadarVerifiedBotTopBotsResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarVerifiedBotTopBotsResponseEnvelope - path := "radar/verified_bots/top/bots" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get top verified bot categories by HTTP requests, along with their corresponding -// percentage, over the total verified bot HTTP requests. -func (r *RadarVerifiedBotTopService) Categories(ctx context.Context, query RadarVerifiedBotTopCategoriesParams, opts ...option.RequestOption) (res *RadarVerifiedBotTopCategoriesResponse, err error) { - opts = append(r.Options[:], opts...) - var env RadarVerifiedBotTopCategoriesResponseEnvelope - path := "radar/verified_bots/top/categories" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RadarVerifiedBotTopBotsResponse struct { - Meta RadarVerifiedBotTopBotsResponseMeta `json:"meta,required"` - Top0 []RadarVerifiedBotTopBotsResponseTop0 `json:"top_0,required"` - JSON radarVerifiedBotTopBotsResponseJSON `json:"-"` -} - -// radarVerifiedBotTopBotsResponseJSON contains the JSON metadata for the struct -// [RadarVerifiedBotTopBotsResponse] -type radarVerifiedBotTopBotsResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarVerifiedBotTopBotsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarVerifiedBotTopBotsResponseJSON) RawJSON() string { - return r.raw -} - -type RadarVerifiedBotTopBotsResponseMeta struct { - DateRange []RadarVerifiedBotTopBotsResponseMetaDateRange `json:"dateRange,required"` - ConfidenceInfo RadarVerifiedBotTopBotsResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarVerifiedBotTopBotsResponseMetaJSON `json:"-"` -} - -// radarVerifiedBotTopBotsResponseMetaJSON contains the JSON metadata for the -// struct [RadarVerifiedBotTopBotsResponseMeta] -type radarVerifiedBotTopBotsResponseMetaJSON struct { - DateRange apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarVerifiedBotTopBotsResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarVerifiedBotTopBotsResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarVerifiedBotTopBotsResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarVerifiedBotTopBotsResponseMetaDateRangeJSON `json:"-"` -} - -// radarVerifiedBotTopBotsResponseMetaDateRangeJSON contains the JSON metadata for -// the struct [RadarVerifiedBotTopBotsResponseMetaDateRange] -type radarVerifiedBotTopBotsResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarVerifiedBotTopBotsResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarVerifiedBotTopBotsResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarVerifiedBotTopBotsResponseMetaConfidenceInfo struct { - Annotations []RadarVerifiedBotTopBotsResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarVerifiedBotTopBotsResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarVerifiedBotTopBotsResponseMetaConfidenceInfoJSON contains the JSON metadata -// for the struct [RadarVerifiedBotTopBotsResponseMetaConfidenceInfo] -type radarVerifiedBotTopBotsResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarVerifiedBotTopBotsResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarVerifiedBotTopBotsResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarVerifiedBotTopBotsResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarVerifiedBotTopBotsResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarVerifiedBotTopBotsResponseMetaConfidenceInfoAnnotationJSON contains the -// JSON metadata for the struct -// [RadarVerifiedBotTopBotsResponseMetaConfidenceInfoAnnotation] -type radarVerifiedBotTopBotsResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarVerifiedBotTopBotsResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarVerifiedBotTopBotsResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarVerifiedBotTopBotsResponseTop0 struct { - BotCategory string `json:"botCategory,required"` - BotName string `json:"botName,required"` - BotOwner string `json:"botOwner,required"` - Value string `json:"value,required"` - JSON radarVerifiedBotTopBotsResponseTop0JSON `json:"-"` -} - -// radarVerifiedBotTopBotsResponseTop0JSON contains the JSON metadata for the -// struct [RadarVerifiedBotTopBotsResponseTop0] -type radarVerifiedBotTopBotsResponseTop0JSON struct { - BotCategory apijson.Field - BotName apijson.Field - BotOwner apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarVerifiedBotTopBotsResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarVerifiedBotTopBotsResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarVerifiedBotTopCategoriesResponse struct { - Meta RadarVerifiedBotTopCategoriesResponseMeta `json:"meta,required"` - Top0 []RadarVerifiedBotTopCategoriesResponseTop0 `json:"top_0,required"` - JSON radarVerifiedBotTopCategoriesResponseJSON `json:"-"` -} - -// radarVerifiedBotTopCategoriesResponseJSON contains the JSON metadata for the -// struct [RadarVerifiedBotTopCategoriesResponse] -type radarVerifiedBotTopCategoriesResponseJSON struct { - Meta apijson.Field - Top0 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarVerifiedBotTopCategoriesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarVerifiedBotTopCategoriesResponseJSON) RawJSON() string { - return r.raw -} - -type RadarVerifiedBotTopCategoriesResponseMeta struct { - DateRange []RadarVerifiedBotTopCategoriesResponseMetaDateRange `json:"dateRange,required"` - ConfidenceInfo RadarVerifiedBotTopCategoriesResponseMetaConfidenceInfo `json:"confidenceInfo"` - JSON radarVerifiedBotTopCategoriesResponseMetaJSON `json:"-"` -} - -// radarVerifiedBotTopCategoriesResponseMetaJSON contains the JSON metadata for the -// struct [RadarVerifiedBotTopCategoriesResponseMeta] -type radarVerifiedBotTopCategoriesResponseMetaJSON struct { - DateRange apijson.Field - ConfidenceInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarVerifiedBotTopCategoriesResponseMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarVerifiedBotTopCategoriesResponseMetaJSON) RawJSON() string { - return r.raw -} - -type RadarVerifiedBotTopCategoriesResponseMetaDateRange struct { - // Adjusted end of date range. - EndTime time.Time `json:"endTime,required" format:"date-time"` - // Adjusted start of date range. - StartTime time.Time `json:"startTime,required" format:"date-time"` - JSON radarVerifiedBotTopCategoriesResponseMetaDateRangeJSON `json:"-"` -} - -// radarVerifiedBotTopCategoriesResponseMetaDateRangeJSON contains the JSON -// metadata for the struct [RadarVerifiedBotTopCategoriesResponseMetaDateRange] -type radarVerifiedBotTopCategoriesResponseMetaDateRangeJSON struct { - EndTime apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarVerifiedBotTopCategoriesResponseMetaDateRange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarVerifiedBotTopCategoriesResponseMetaDateRangeJSON) RawJSON() string { - return r.raw -} - -type RadarVerifiedBotTopCategoriesResponseMetaConfidenceInfo struct { - Annotations []RadarVerifiedBotTopCategoriesResponseMetaConfidenceInfoAnnotation `json:"annotations"` - Level int64 `json:"level"` - JSON radarVerifiedBotTopCategoriesResponseMetaConfidenceInfoJSON `json:"-"` -} - -// radarVerifiedBotTopCategoriesResponseMetaConfidenceInfoJSON contains the JSON -// metadata for the struct -// [RadarVerifiedBotTopCategoriesResponseMetaConfidenceInfo] -type radarVerifiedBotTopCategoriesResponseMetaConfidenceInfoJSON struct { - Annotations apijson.Field - Level apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarVerifiedBotTopCategoriesResponseMetaConfidenceInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarVerifiedBotTopCategoriesResponseMetaConfidenceInfoJSON) RawJSON() string { - return r.raw -} - -type RadarVerifiedBotTopCategoriesResponseMetaConfidenceInfoAnnotation struct { - DataSource string `json:"dataSource,required"` - Description string `json:"description,required"` - EventType string `json:"eventType,required"` - IsInstantaneous interface{} `json:"isInstantaneous,required"` - EndTime time.Time `json:"endTime" format:"date-time"` - LinkedURL string `json:"linkedUrl"` - StartTime time.Time `json:"startTime" format:"date-time"` - JSON radarVerifiedBotTopCategoriesResponseMetaConfidenceInfoAnnotationJSON `json:"-"` -} - -// radarVerifiedBotTopCategoriesResponseMetaConfidenceInfoAnnotationJSON contains -// the JSON metadata for the struct -// [RadarVerifiedBotTopCategoriesResponseMetaConfidenceInfoAnnotation] -type radarVerifiedBotTopCategoriesResponseMetaConfidenceInfoAnnotationJSON struct { - DataSource apijson.Field - Description apijson.Field - EventType apijson.Field - IsInstantaneous apijson.Field - EndTime apijson.Field - LinkedURL apijson.Field - StartTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarVerifiedBotTopCategoriesResponseMetaConfidenceInfoAnnotation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarVerifiedBotTopCategoriesResponseMetaConfidenceInfoAnnotationJSON) RawJSON() string { - return r.raw -} - -type RadarVerifiedBotTopCategoriesResponseTop0 struct { - BotCategory string `json:"botCategory,required"` - Value string `json:"value,required"` - JSON radarVerifiedBotTopCategoriesResponseTop0JSON `json:"-"` -} - -// radarVerifiedBotTopCategoriesResponseTop0JSON contains the JSON metadata for the -// struct [RadarVerifiedBotTopCategoriesResponseTop0] -type radarVerifiedBotTopCategoriesResponseTop0JSON struct { - BotCategory apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarVerifiedBotTopCategoriesResponseTop0) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarVerifiedBotTopCategoriesResponseTop0JSON) RawJSON() string { - return r.raw -} - -type RadarVerifiedBotTopBotsParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarVerifiedBotTopBotsParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarVerifiedBotTopBotsParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarVerifiedBotTopBotsParams]'s query parameters as -// `url.Values`. -func (r RadarVerifiedBotTopBotsParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarVerifiedBotTopBotsParamsDateRange string - -const ( - RadarVerifiedBotTopBotsParamsDateRange1d RadarVerifiedBotTopBotsParamsDateRange = "1d" - RadarVerifiedBotTopBotsParamsDateRange2d RadarVerifiedBotTopBotsParamsDateRange = "2d" - RadarVerifiedBotTopBotsParamsDateRange7d RadarVerifiedBotTopBotsParamsDateRange = "7d" - RadarVerifiedBotTopBotsParamsDateRange14d RadarVerifiedBotTopBotsParamsDateRange = "14d" - RadarVerifiedBotTopBotsParamsDateRange28d RadarVerifiedBotTopBotsParamsDateRange = "28d" - RadarVerifiedBotTopBotsParamsDateRange12w RadarVerifiedBotTopBotsParamsDateRange = "12w" - RadarVerifiedBotTopBotsParamsDateRange24w RadarVerifiedBotTopBotsParamsDateRange = "24w" - RadarVerifiedBotTopBotsParamsDateRange52w RadarVerifiedBotTopBotsParamsDateRange = "52w" - RadarVerifiedBotTopBotsParamsDateRange1dControl RadarVerifiedBotTopBotsParamsDateRange = "1dControl" - RadarVerifiedBotTopBotsParamsDateRange2dControl RadarVerifiedBotTopBotsParamsDateRange = "2dControl" - RadarVerifiedBotTopBotsParamsDateRange7dControl RadarVerifiedBotTopBotsParamsDateRange = "7dControl" - RadarVerifiedBotTopBotsParamsDateRange14dControl RadarVerifiedBotTopBotsParamsDateRange = "14dControl" - RadarVerifiedBotTopBotsParamsDateRange28dControl RadarVerifiedBotTopBotsParamsDateRange = "28dControl" - RadarVerifiedBotTopBotsParamsDateRange12wControl RadarVerifiedBotTopBotsParamsDateRange = "12wControl" - RadarVerifiedBotTopBotsParamsDateRange24wControl RadarVerifiedBotTopBotsParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarVerifiedBotTopBotsParamsFormat string - -const ( - RadarVerifiedBotTopBotsParamsFormatJson RadarVerifiedBotTopBotsParamsFormat = "JSON" - RadarVerifiedBotTopBotsParamsFormatCsv RadarVerifiedBotTopBotsParamsFormat = "CSV" -) - -type RadarVerifiedBotTopBotsResponseEnvelope struct { - Result RadarVerifiedBotTopBotsResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarVerifiedBotTopBotsResponseEnvelopeJSON `json:"-"` -} - -// radarVerifiedBotTopBotsResponseEnvelopeJSON contains the JSON metadata for the -// struct [RadarVerifiedBotTopBotsResponseEnvelope] -type radarVerifiedBotTopBotsResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarVerifiedBotTopBotsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarVerifiedBotTopBotsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RadarVerifiedBotTopCategoriesParams struct { - // Array of comma separated list of ASNs, start with `-` to exclude from results. - // For example, `-174, 3356` excludes results from AS174, but includes results from - // AS3356. - ASN param.Field[[]string] `query:"asn"` - // Array of comma separated list of continents (alpha-2 continent codes). Start - // with `-` to exclude from results. For example, `-EU,NA` excludes results from - // Europe, but includes results from North America. - Continent param.Field[[]string] `query:"continent"` - // End of the date range (inclusive). - DateEnd param.Field[[]time.Time] `query:"dateEnd" format:"date-time"` - // For example, use `7d` and `7dControl` to compare this week with the previous - // week. Use this parameter or set specific start and end dates (`dateStart` and - // `dateEnd` parameters). - DateRange param.Field[[]RadarVerifiedBotTopCategoriesParamsDateRange] `query:"dateRange"` - // Array of datetimes to filter the start of a series. - DateStart param.Field[[]time.Time] `query:"dateStart" format:"date-time"` - // Format results are returned in. - Format param.Field[RadarVerifiedBotTopCategoriesParamsFormat] `query:"format"` - // Limit the number of objects in the response. - Limit param.Field[int64] `query:"limit"` - // Array of comma separated list of locations (alpha-2 country codes). Start with - // `-` to exclude from results. For example, `-US,PT` excludes results from the US, - // but includes results from PT. - Location param.Field[[]string] `query:"location"` - // Array of names that will be used to name the series in responses. - Name param.Field[[]string] `query:"name"` -} - -// URLQuery serializes [RadarVerifiedBotTopCategoriesParams]'s query parameters as -// `url.Values`. -func (r RadarVerifiedBotTopCategoriesParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RadarVerifiedBotTopCategoriesParamsDateRange string - -const ( - RadarVerifiedBotTopCategoriesParamsDateRange1d RadarVerifiedBotTopCategoriesParamsDateRange = "1d" - RadarVerifiedBotTopCategoriesParamsDateRange2d RadarVerifiedBotTopCategoriesParamsDateRange = "2d" - RadarVerifiedBotTopCategoriesParamsDateRange7d RadarVerifiedBotTopCategoriesParamsDateRange = "7d" - RadarVerifiedBotTopCategoriesParamsDateRange14d RadarVerifiedBotTopCategoriesParamsDateRange = "14d" - RadarVerifiedBotTopCategoriesParamsDateRange28d RadarVerifiedBotTopCategoriesParamsDateRange = "28d" - RadarVerifiedBotTopCategoriesParamsDateRange12w RadarVerifiedBotTopCategoriesParamsDateRange = "12w" - RadarVerifiedBotTopCategoriesParamsDateRange24w RadarVerifiedBotTopCategoriesParamsDateRange = "24w" - RadarVerifiedBotTopCategoriesParamsDateRange52w RadarVerifiedBotTopCategoriesParamsDateRange = "52w" - RadarVerifiedBotTopCategoriesParamsDateRange1dControl RadarVerifiedBotTopCategoriesParamsDateRange = "1dControl" - RadarVerifiedBotTopCategoriesParamsDateRange2dControl RadarVerifiedBotTopCategoriesParamsDateRange = "2dControl" - RadarVerifiedBotTopCategoriesParamsDateRange7dControl RadarVerifiedBotTopCategoriesParamsDateRange = "7dControl" - RadarVerifiedBotTopCategoriesParamsDateRange14dControl RadarVerifiedBotTopCategoriesParamsDateRange = "14dControl" - RadarVerifiedBotTopCategoriesParamsDateRange28dControl RadarVerifiedBotTopCategoriesParamsDateRange = "28dControl" - RadarVerifiedBotTopCategoriesParamsDateRange12wControl RadarVerifiedBotTopCategoriesParamsDateRange = "12wControl" - RadarVerifiedBotTopCategoriesParamsDateRange24wControl RadarVerifiedBotTopCategoriesParamsDateRange = "24wControl" -) - -// Format results are returned in. -type RadarVerifiedBotTopCategoriesParamsFormat string - -const ( - RadarVerifiedBotTopCategoriesParamsFormatJson RadarVerifiedBotTopCategoriesParamsFormat = "JSON" - RadarVerifiedBotTopCategoriesParamsFormatCsv RadarVerifiedBotTopCategoriesParamsFormat = "CSV" -) - -type RadarVerifiedBotTopCategoriesResponseEnvelope struct { - Result RadarVerifiedBotTopCategoriesResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON radarVerifiedBotTopCategoriesResponseEnvelopeJSON `json:"-"` -} - -// radarVerifiedBotTopCategoriesResponseEnvelopeJSON contains the JSON metadata for -// the struct [RadarVerifiedBotTopCategoriesResponseEnvelope] -type radarVerifiedBotTopCategoriesResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RadarVerifiedBotTopCategoriesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r radarVerifiedBotTopCategoriesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/radarverifiedbottop_test.go b/radarverifiedbottop_test.go deleted file mode 100644 index 33f391caea8..00000000000 --- a/radarverifiedbottop_test.go +++ /dev/null @@ -1,83 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRadarVerifiedBotTopBotsWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.VerifiedBots.Top.Bots(context.TODO(), cloudflare.RadarVerifiedBotTopBotsParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarVerifiedBotTopBotsParamsDateRange{cloudflare.RadarVerifiedBotTopBotsParamsDateRange1d, cloudflare.RadarVerifiedBotTopBotsParamsDateRange2d, cloudflare.RadarVerifiedBotTopBotsParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarVerifiedBotTopBotsParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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 TestRadarVerifiedBotTopCategoriesWithOptionalParams(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("user@example.com"), - ) - _, err := client.Radar.VerifiedBots.Top.Categories(context.TODO(), cloudflare.RadarVerifiedBotTopCategoriesParams{ - ASN: cloudflare.F([]string{"string", "string", "string"}), - Continent: cloudflare.F([]string{"string", "string", "string"}), - DateEnd: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - DateRange: cloudflare.F([]cloudflare.RadarVerifiedBotTopCategoriesParamsDateRange{cloudflare.RadarVerifiedBotTopCategoriesParamsDateRange1d, cloudflare.RadarVerifiedBotTopCategoriesParamsDateRange2d, cloudflare.RadarVerifiedBotTopCategoriesParamsDateRange7d}), - DateStart: cloudflare.F([]time.Time{time.Now(), time.Now(), time.Now()}), - Format: cloudflare.F(cloudflare.RadarVerifiedBotTopCategoriesParamsFormatJson), - Limit: cloudflare.F(int64(5)), - Location: cloudflare.F([]string{"string", "string", "string"}), - Name: cloudflare.F([]string{"string", "string", "string"}), - }) - 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/rate_limits/aliases.go b/rate_limits/aliases.go new file mode 100644 index 00000000000..6b706e19539 --- /dev/null +++ b/rate_limits/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package rate_limits + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/ratelimit.go b/rate_limits/ratelimit.go similarity index 98% rename from ratelimit.go rename to rate_limits/ratelimit.go index 11a90fcad18..a9bcb9a4189 100644 --- a/ratelimit.go +++ b/rate_limits/ratelimit.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package rate_limits import ( "context" @@ -111,9 +111,10 @@ func (r *RateLimitService) Get(ctx context.Context, zoneIdentifier string, id st return } -// Union satisfied by [RateLimitNewResponseUnknown] or [shared.UnionString]. +// Union satisfied by [rate_limits.RateLimitNewResponseUnknown] or +// [shared.UnionString]. type RateLimitNewResponse interface { - ImplementsRateLimitNewResponse() + ImplementsRateLimitsRateLimitNewResponse() } func init() { @@ -446,9 +447,10 @@ func (r rateLimitDeleteResponseJSON) RawJSON() string { return r.raw } -// Union satisfied by [RateLimitEditResponseUnknown] or [shared.UnionString]. +// Union satisfied by [rate_limits.RateLimitEditResponseUnknown] or +// [shared.UnionString]. type RateLimitEditResponse interface { - ImplementsRateLimitEditResponse() + ImplementsRateLimitsRateLimitEditResponse() } func init() { @@ -462,9 +464,10 @@ func init() { ) } -// Union satisfied by [RateLimitGetResponseUnknown] or [shared.UnionString]. +// Union satisfied by [rate_limits.RateLimitGetResponseUnknown] or +// [shared.UnionString]. type RateLimitGetResponse interface { - ImplementsRateLimitGetResponse() + ImplementsRateLimitsRateLimitGetResponse() } func init() { diff --git a/ratelimit_test.go b/rate_limits/ratelimit_test.go similarity index 95% rename from ratelimit_test.go rename to rate_limits/ratelimit_test.go index fb0b9443523..7618681a37c 100644 --- a/ratelimit_test.go +++ b/rate_limits/ratelimit_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package rate_limits_test import ( "context" @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/rate_limits" ) func TestRateLimitNew(t *testing.T) { @@ -30,7 +31,7 @@ func TestRateLimitNew(t *testing.T) { _, err := client.RateLimits.New( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.RateLimitNewParams{ + rate_limits.RateLimitNewParams{ Body: cloudflare.F[any](map[string]interface{}{}), }, ) @@ -60,7 +61,7 @@ func TestRateLimitListWithOptionalParams(t *testing.T) { _, err := client.RateLimits.List( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.RateLimitListParams{ + rate_limits.RateLimitListParams{ Page: cloudflare.F(1.000000), PerPage: cloudflare.F(1.000000), }, @@ -120,7 +121,7 @@ func TestRateLimitEdit(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "372e67954025e0ba6aaa6d586b9e0b59", - cloudflare.RateLimitEditParams{ + rate_limits.RateLimitEditParams{ Body: cloudflare.F[any](map[string]interface{}{}), }, ) diff --git a/registrar/aliases.go b/registrar/aliases.go new file mode 100644 index 00000000000..d4c397c6ad4 --- /dev/null +++ b/registrar/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package registrar + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/registrar/domain.go b/registrar/domain.go new file mode 100644 index 00000000000..dd30d58980a --- /dev/null +++ b/registrar/domain.go @@ -0,0 +1,582 @@ +// File generated from our OpenAPI spec by Stainless. + +package registrar + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// DomainService 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 [NewDomainService] method instead. +type DomainService struct { + Options []option.RequestOption +} + +// NewDomainService 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 NewDomainService(opts ...option.RequestOption) (r *DomainService) { + r = &DomainService{} + r.Options = opts + return +} + +// Update individual domain. +func (r *DomainService) Update(ctx context.Context, domainName string, params DomainUpdateParams, opts ...option.RequestOption) (res *DomainUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env DomainUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/registrar/domains/%s", params.AccountID, domainName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List domains handled by Registrar. +func (r *DomainService) List(ctx context.Context, query DomainListParams, opts ...option.RequestOption) (res *[]DomainListResponse, err error) { + opts = append(r.Options[:], opts...) + var env DomainListResponseEnvelope + path := fmt.Sprintf("accounts/%s/registrar/domains", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Show individual domain. +func (r *DomainService) Get(ctx context.Context, domainName string, query DomainGetParams, opts ...option.RequestOption) (res *DomainGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env DomainGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/registrar/domains/%s", query.AccountID, domainName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [registrar.DomainUpdateResponseUnknown], +// [registrar.DomainUpdateResponseArray] or [shared.UnionString]. +type DomainUpdateResponse interface { + ImplementsRegistrarDomainUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DomainUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DomainUpdateResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type DomainUpdateResponseArray []interface{} + +func (r DomainUpdateResponseArray) ImplementsRegistrarDomainUpdateResponse() {} + +type DomainListResponse struct { + // Domain identifier. + ID string `json:"id"` + // Shows if a domain is available for transferring into Cloudflare Registrar. + Available bool `json:"available"` + // Indicates if the domain can be registered as a new domain. + CanRegister bool `json:"can_register"` + // Shows time of creation. + CreatedAt time.Time `json:"created_at" format:"date-time"` + // Shows name of current registrar. + CurrentRegistrar string `json:"current_registrar"` + // Shows when domain name registration expires. + ExpiresAt time.Time `json:"expires_at" format:"date-time"` + // Shows whether a registrar lock is in place for a domain. + Locked bool `json:"locked"` + // Shows contact information for domain registrant. + RegistrantContact DomainListResponseRegistrantContact `json:"registrant_contact"` + // A comma-separated list of registry status codes. A full list of status codes can + // be found at + // [EPP Status Codes](https://www.icann.org/resources/pages/epp-status-codes-2014-06-16-en). + RegistryStatuses string `json:"registry_statuses"` + // Whether a particular TLD is currently supported by Cloudflare Registrar. Refer + // to [TLD Policies](https://www.cloudflare.com/tld-policies/) for a list of + // supported TLDs. + SupportedTld bool `json:"supported_tld"` + // Statuses for domain transfers into Cloudflare Registrar. + TransferIn DomainListResponseTransferIn `json:"transfer_in"` + // Last updated. + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON domainListResponseJSON `json:"-"` +} + +// domainListResponseJSON contains the JSON metadata for the struct +// [DomainListResponse] +type domainListResponseJSON struct { + ID apijson.Field + Available apijson.Field + CanRegister apijson.Field + CreatedAt apijson.Field + CurrentRegistrar apijson.Field + ExpiresAt apijson.Field + Locked apijson.Field + RegistrantContact apijson.Field + RegistryStatuses apijson.Field + SupportedTld apijson.Field + TransferIn apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainListResponseJSON) RawJSON() string { + return r.raw +} + +// Shows contact information for domain registrant. +type DomainListResponseRegistrantContact struct { + // Address. + Address string `json:"address,required"` + // City. + City string `json:"city,required"` + // The country in which the user lives. + Country string `json:"country,required,nullable"` + // User's first name + FirstName string `json:"first_name,required,nullable"` + // User's last name + LastName string `json:"last_name,required,nullable"` + // Name of organization. + Organization string `json:"organization,required"` + // User's telephone number + Phone string `json:"phone,required,nullable"` + // State. + State string `json:"state,required"` + // The zipcode or postal code where the user lives. + Zip string `json:"zip,required,nullable"` + // Contact Identifier. + ID string `json:"id"` + // Optional address line for unit, floor, suite, etc. + Address2 string `json:"address2"` + // The contact email address of the user. + Email string `json:"email"` + // Contact fax number. + Fax string `json:"fax"` + JSON domainListResponseRegistrantContactJSON `json:"-"` +} + +// domainListResponseRegistrantContactJSON contains the JSON metadata for the +// struct [DomainListResponseRegistrantContact] +type domainListResponseRegistrantContactJSON struct { + Address apijson.Field + City apijson.Field + Country apijson.Field + FirstName apijson.Field + LastName apijson.Field + Organization apijson.Field + Phone apijson.Field + State apijson.Field + Zip apijson.Field + ID apijson.Field + Address2 apijson.Field + Email apijson.Field + Fax apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainListResponseRegistrantContact) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainListResponseRegistrantContactJSON) RawJSON() string { + return r.raw +} + +// Statuses for domain transfers into Cloudflare Registrar. +type DomainListResponseTransferIn struct { + // Form of authorization has been accepted by the registrant. + AcceptFoa interface{} `json:"accept_foa"` + // Shows transfer status with the registry. + ApproveTransfer interface{} `json:"approve_transfer"` + // Indicates if cancellation is still possible. + CanCancelTransfer bool `json:"can_cancel_transfer"` + // Privacy guards are disabled at the foreign registrar. + DisablePrivacy interface{} `json:"disable_privacy"` + // Auth code has been entered and verified. + EnterAuthCode interface{} `json:"enter_auth_code"` + // Domain is unlocked at the foreign registrar. + UnlockDomain interface{} `json:"unlock_domain"` + JSON domainListResponseTransferInJSON `json:"-"` +} + +// domainListResponseTransferInJSON contains the JSON metadata for the struct +// [DomainListResponseTransferIn] +type domainListResponseTransferInJSON struct { + AcceptFoa apijson.Field + ApproveTransfer apijson.Field + CanCancelTransfer apijson.Field + DisablePrivacy apijson.Field + EnterAuthCode apijson.Field + UnlockDomain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainListResponseTransferIn) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainListResponseTransferInJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [registrar.DomainGetResponseUnknown], +// [registrar.DomainGetResponseArray] or [shared.UnionString]. +type DomainGetResponse interface { + ImplementsRegistrarDomainGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DomainGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DomainGetResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type DomainGetResponseArray []interface{} + +func (r DomainGetResponseArray) ImplementsRegistrarDomainGetResponse() {} + +type DomainUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Auto-renew controls whether subscription is automatically renewed upon domain + // expiration. + AutoRenew param.Field[bool] `json:"auto_renew"` + // Shows whether a registrar lock is in place for a domain. + Locked param.Field[bool] `json:"locked"` + // Privacy option controls redacting WHOIS information. + Privacy param.Field[bool] `json:"privacy"` +} + +func (r DomainUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DomainUpdateResponseEnvelope struct { + Errors []DomainUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []DomainUpdateResponseEnvelopeMessages `json:"messages,required"` + Result DomainUpdateResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success DomainUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON domainUpdateResponseEnvelopeJSON `json:"-"` +} + +// domainUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [DomainUpdateResponseEnvelope] +type domainUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DomainUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON domainUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// domainUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [DomainUpdateResponseEnvelopeErrors] +type domainUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DomainUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON domainUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// domainUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DomainUpdateResponseEnvelopeMessages] +type domainUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DomainUpdateResponseEnvelopeSuccess bool + +const ( + DomainUpdateResponseEnvelopeSuccessTrue DomainUpdateResponseEnvelopeSuccess = true +) + +type DomainListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type DomainListResponseEnvelope struct { + Errors []DomainListResponseEnvelopeErrors `json:"errors,required"` + Messages []DomainListResponseEnvelopeMessages `json:"messages,required"` + Result []DomainListResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success DomainListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DomainListResponseEnvelopeResultInfo `json:"result_info"` + JSON domainListResponseEnvelopeJSON `json:"-"` +} + +// domainListResponseEnvelopeJSON contains the JSON metadata for the struct +// [DomainListResponseEnvelope] +type domainListResponseEnvelopeJSON 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 *DomainListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DomainListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON domainListResponseEnvelopeErrorsJSON `json:"-"` +} + +// domainListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [DomainListResponseEnvelopeErrors] +type domainListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DomainListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON domainListResponseEnvelopeMessagesJSON `json:"-"` +} + +// domainListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [DomainListResponseEnvelopeMessages] +type domainListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DomainListResponseEnvelopeSuccess bool + +const ( + DomainListResponseEnvelopeSuccessTrue DomainListResponseEnvelopeSuccess = true +) + +type DomainListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON domainListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// domainListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [DomainListResponseEnvelopeResultInfo] +type domainListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DomainGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type DomainGetResponseEnvelope struct { + Errors []DomainGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DomainGetResponseEnvelopeMessages `json:"messages,required"` + Result DomainGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success DomainGetResponseEnvelopeSuccess `json:"success,required"` + JSON domainGetResponseEnvelopeJSON `json:"-"` +} + +// domainGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DomainGetResponseEnvelope] +type domainGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DomainGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON domainGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// domainGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [DomainGetResponseEnvelopeErrors] +type domainGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DomainGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON domainGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// domainGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [DomainGetResponseEnvelopeMessages] +type domainGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DomainGetResponseEnvelopeSuccess bool + +const ( + DomainGetResponseEnvelopeSuccessTrue DomainGetResponseEnvelopeSuccess = true +) diff --git a/registrar/domain_test.go b/registrar/domain_test.go new file mode 100644 index 00000000000..4b5ac16a955 --- /dev/null +++ b/registrar/domain_test.go @@ -0,0 +1,104 @@ +// File generated from our OpenAPI spec by Stainless. + +package registrar_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/registrar" +) + +func TestDomainUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Registrar.Domains.Update( + context.TODO(), + "cloudflare.com", + registrar.DomainUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + AutoRenew: cloudflare.F(true), + Locked: cloudflare.F(false), + Privacy: cloudflare.F(true), + }, + ) + 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 TestDomainList(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("user@example.com"), + ) + _, err := client.Registrar.Domains.List(context.TODO(), registrar.DomainListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestDomainGet(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("user@example.com"), + ) + _, err := client.Registrar.Domains.Get( + context.TODO(), + "cloudflare.com", + registrar.DomainGetParams{ + AccountID: cloudflare.F("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/registrar.go b/registrar/registrar.go similarity index 89% rename from registrar.go rename to registrar/registrar.go index e45c6173d54..bb503a24d3c 100644 --- a/registrar.go +++ b/registrar/registrar.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package registrar import ( "github.com/cloudflare/cloudflare-go/option" @@ -12,7 +12,7 @@ import ( // service directly, and instead use the [NewRegistrarService] method instead. type RegistrarService struct { Options []option.RequestOption - Domains *RegistrarDomainService + Domains *DomainService } // NewRegistrarService generates a new service that applies the given options to @@ -21,6 +21,6 @@ type RegistrarService struct { func NewRegistrarService(opts ...option.RequestOption) (r *RegistrarService) { r = &RegistrarService{} r.Options = opts - r.Domains = NewRegistrarDomainService(opts...) + r.Domains = NewDomainService(opts...) return } diff --git a/registrardomain.go b/registrardomain.go deleted file mode 100644 index b51928300e7..00000000000 --- a/registrardomain.go +++ /dev/null @@ -1,583 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// RegistrarDomainService 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 [NewRegistrarDomainService] method -// instead. -type RegistrarDomainService struct { - Options []option.RequestOption -} - -// NewRegistrarDomainService 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 NewRegistrarDomainService(opts ...option.RequestOption) (r *RegistrarDomainService) { - r = &RegistrarDomainService{} - r.Options = opts - return -} - -// Update individual domain. -func (r *RegistrarDomainService) Update(ctx context.Context, domainName string, params RegistrarDomainUpdateParams, opts ...option.RequestOption) (res *RegistrarDomainUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env RegistrarDomainUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/registrar/domains/%s", params.AccountID, domainName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List domains handled by Registrar. -func (r *RegistrarDomainService) List(ctx context.Context, query RegistrarDomainListParams, opts ...option.RequestOption) (res *[]RegistrarDomainListResponse, err error) { - opts = append(r.Options[:], opts...) - var env RegistrarDomainListResponseEnvelope - path := fmt.Sprintf("accounts/%s/registrar/domains", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Show individual domain. -func (r *RegistrarDomainService) Get(ctx context.Context, domainName string, query RegistrarDomainGetParams, opts ...option.RequestOption) (res *RegistrarDomainGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RegistrarDomainGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/registrar/domains/%s", query.AccountID, domainName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [RegistrarDomainUpdateResponseUnknown], -// [RegistrarDomainUpdateResponseArray] or [shared.UnionString]. -type RegistrarDomainUpdateResponse interface { - ImplementsRegistrarDomainUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*RegistrarDomainUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RegistrarDomainUpdateResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type RegistrarDomainUpdateResponseArray []interface{} - -func (r RegistrarDomainUpdateResponseArray) ImplementsRegistrarDomainUpdateResponse() {} - -type RegistrarDomainListResponse struct { - // Domain identifier. - ID string `json:"id"` - // Shows if a domain is available for transferring into Cloudflare Registrar. - Available bool `json:"available"` - // Indicates if the domain can be registered as a new domain. - CanRegister bool `json:"can_register"` - // Shows time of creation. - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Shows name of current registrar. - CurrentRegistrar string `json:"current_registrar"` - // Shows when domain name registration expires. - ExpiresAt time.Time `json:"expires_at" format:"date-time"` - // Shows whether a registrar lock is in place for a domain. - Locked bool `json:"locked"` - // Shows contact information for domain registrant. - RegistrantContact RegistrarDomainListResponseRegistrantContact `json:"registrant_contact"` - // A comma-separated list of registry status codes. A full list of status codes can - // be found at - // [EPP Status Codes](https://www.icann.org/resources/pages/epp-status-codes-2014-06-16-en). - RegistryStatuses string `json:"registry_statuses"` - // Whether a particular TLD is currently supported by Cloudflare Registrar. Refer - // to [TLD Policies](https://www.cloudflare.com/tld-policies/) for a list of - // supported TLDs. - SupportedTld bool `json:"supported_tld"` - // Statuses for domain transfers into Cloudflare Registrar. - TransferIn RegistrarDomainListResponseTransferIn `json:"transfer_in"` - // Last updated. - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON registrarDomainListResponseJSON `json:"-"` -} - -// registrarDomainListResponseJSON contains the JSON metadata for the struct -// [RegistrarDomainListResponse] -type registrarDomainListResponseJSON struct { - ID apijson.Field - Available apijson.Field - CanRegister apijson.Field - CreatedAt apijson.Field - CurrentRegistrar apijson.Field - ExpiresAt apijson.Field - Locked apijson.Field - RegistrantContact apijson.Field - RegistryStatuses apijson.Field - SupportedTld apijson.Field - TransferIn apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegistrarDomainListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r registrarDomainListResponseJSON) RawJSON() string { - return r.raw -} - -// Shows contact information for domain registrant. -type RegistrarDomainListResponseRegistrantContact struct { - // Address. - Address string `json:"address,required"` - // City. - City string `json:"city,required"` - // The country in which the user lives. - Country string `json:"country,required,nullable"` - // User's first name - FirstName string `json:"first_name,required,nullable"` - // User's last name - LastName string `json:"last_name,required,nullable"` - // Name of organization. - Organization string `json:"organization,required"` - // User's telephone number - Phone string `json:"phone,required,nullable"` - // State. - State string `json:"state,required"` - // The zipcode or postal code where the user lives. - Zip string `json:"zip,required,nullable"` - // Contact Identifier. - ID string `json:"id"` - // Optional address line for unit, floor, suite, etc. - Address2 string `json:"address2"` - // The contact email address of the user. - Email string `json:"email"` - // Contact fax number. - Fax string `json:"fax"` - JSON registrarDomainListResponseRegistrantContactJSON `json:"-"` -} - -// registrarDomainListResponseRegistrantContactJSON contains the JSON metadata for -// the struct [RegistrarDomainListResponseRegistrantContact] -type registrarDomainListResponseRegistrantContactJSON struct { - Address apijson.Field - City apijson.Field - Country apijson.Field - FirstName apijson.Field - LastName apijson.Field - Organization apijson.Field - Phone apijson.Field - State apijson.Field - Zip apijson.Field - ID apijson.Field - Address2 apijson.Field - Email apijson.Field - Fax apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegistrarDomainListResponseRegistrantContact) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r registrarDomainListResponseRegistrantContactJSON) RawJSON() string { - return r.raw -} - -// Statuses for domain transfers into Cloudflare Registrar. -type RegistrarDomainListResponseTransferIn struct { - // Form of authorization has been accepted by the registrant. - AcceptFoa interface{} `json:"accept_foa"` - // Shows transfer status with the registry. - ApproveTransfer interface{} `json:"approve_transfer"` - // Indicates if cancellation is still possible. - CanCancelTransfer bool `json:"can_cancel_transfer"` - // Privacy guards are disabled at the foreign registrar. - DisablePrivacy interface{} `json:"disable_privacy"` - // Auth code has been entered and verified. - EnterAuthCode interface{} `json:"enter_auth_code"` - // Domain is unlocked at the foreign registrar. - UnlockDomain interface{} `json:"unlock_domain"` - JSON registrarDomainListResponseTransferInJSON `json:"-"` -} - -// registrarDomainListResponseTransferInJSON contains the JSON metadata for the -// struct [RegistrarDomainListResponseTransferIn] -type registrarDomainListResponseTransferInJSON struct { - AcceptFoa apijson.Field - ApproveTransfer apijson.Field - CanCancelTransfer apijson.Field - DisablePrivacy apijson.Field - EnterAuthCode apijson.Field - UnlockDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegistrarDomainListResponseTransferIn) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r registrarDomainListResponseTransferInJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [RegistrarDomainGetResponseUnknown], -// [RegistrarDomainGetResponseArray] or [shared.UnionString]. -type RegistrarDomainGetResponse interface { - ImplementsRegistrarDomainGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*RegistrarDomainGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RegistrarDomainGetResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type RegistrarDomainGetResponseArray []interface{} - -func (r RegistrarDomainGetResponseArray) ImplementsRegistrarDomainGetResponse() {} - -type RegistrarDomainUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Auto-renew controls whether subscription is automatically renewed upon domain - // expiration. - AutoRenew param.Field[bool] `json:"auto_renew"` - // Shows whether a registrar lock is in place for a domain. - Locked param.Field[bool] `json:"locked"` - // Privacy option controls redacting WHOIS information. - Privacy param.Field[bool] `json:"privacy"` -} - -func (r RegistrarDomainUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RegistrarDomainUpdateResponseEnvelope struct { - Errors []RegistrarDomainUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []RegistrarDomainUpdateResponseEnvelopeMessages `json:"messages,required"` - Result RegistrarDomainUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success RegistrarDomainUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON registrarDomainUpdateResponseEnvelopeJSON `json:"-"` -} - -// registrarDomainUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [RegistrarDomainUpdateResponseEnvelope] -type registrarDomainUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegistrarDomainUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r registrarDomainUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RegistrarDomainUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON registrarDomainUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// registrarDomainUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [RegistrarDomainUpdateResponseEnvelopeErrors] -type registrarDomainUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegistrarDomainUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r registrarDomainUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RegistrarDomainUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON registrarDomainUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// registrarDomainUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [RegistrarDomainUpdateResponseEnvelopeMessages] -type registrarDomainUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegistrarDomainUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r registrarDomainUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RegistrarDomainUpdateResponseEnvelopeSuccess bool - -const ( - RegistrarDomainUpdateResponseEnvelopeSuccessTrue RegistrarDomainUpdateResponseEnvelopeSuccess = true -) - -type RegistrarDomainListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type RegistrarDomainListResponseEnvelope struct { - Errors []RegistrarDomainListResponseEnvelopeErrors `json:"errors,required"` - Messages []RegistrarDomainListResponseEnvelopeMessages `json:"messages,required"` - Result []RegistrarDomainListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success RegistrarDomainListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo RegistrarDomainListResponseEnvelopeResultInfo `json:"result_info"` - JSON registrarDomainListResponseEnvelopeJSON `json:"-"` -} - -// registrarDomainListResponseEnvelopeJSON contains the JSON metadata for the -// struct [RegistrarDomainListResponseEnvelope] -type registrarDomainListResponseEnvelopeJSON 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 *RegistrarDomainListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r registrarDomainListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RegistrarDomainListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON registrarDomainListResponseEnvelopeErrorsJSON `json:"-"` -} - -// registrarDomainListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RegistrarDomainListResponseEnvelopeErrors] -type registrarDomainListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegistrarDomainListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r registrarDomainListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RegistrarDomainListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON registrarDomainListResponseEnvelopeMessagesJSON `json:"-"` -} - -// registrarDomainListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [RegistrarDomainListResponseEnvelopeMessages] -type registrarDomainListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegistrarDomainListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r registrarDomainListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RegistrarDomainListResponseEnvelopeSuccess bool - -const ( - RegistrarDomainListResponseEnvelopeSuccessTrue RegistrarDomainListResponseEnvelopeSuccess = true -) - -type RegistrarDomainListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON registrarDomainListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// registrarDomainListResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [RegistrarDomainListResponseEnvelopeResultInfo] -type registrarDomainListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegistrarDomainListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r registrarDomainListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type RegistrarDomainGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type RegistrarDomainGetResponseEnvelope struct { - Errors []RegistrarDomainGetResponseEnvelopeErrors `json:"errors,required"` - Messages []RegistrarDomainGetResponseEnvelopeMessages `json:"messages,required"` - Result RegistrarDomainGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success RegistrarDomainGetResponseEnvelopeSuccess `json:"success,required"` - JSON registrarDomainGetResponseEnvelopeJSON `json:"-"` -} - -// registrarDomainGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [RegistrarDomainGetResponseEnvelope] -type registrarDomainGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegistrarDomainGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r registrarDomainGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RegistrarDomainGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON registrarDomainGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// registrarDomainGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RegistrarDomainGetResponseEnvelopeErrors] -type registrarDomainGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegistrarDomainGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r registrarDomainGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RegistrarDomainGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON registrarDomainGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// registrarDomainGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [RegistrarDomainGetResponseEnvelopeMessages] -type registrarDomainGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RegistrarDomainGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r registrarDomainGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RegistrarDomainGetResponseEnvelopeSuccess bool - -const ( - RegistrarDomainGetResponseEnvelopeSuccessTrue RegistrarDomainGetResponseEnvelopeSuccess = true -) diff --git a/registrardomain_test.go b/registrardomain_test.go deleted file mode 100644 index 66a0de118b8..00000000000 --- a/registrardomain_test.go +++ /dev/null @@ -1,103 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRegistrarDomainUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Registrar.Domains.Update( - context.TODO(), - "cloudflare.com", - cloudflare.RegistrarDomainUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - AutoRenew: cloudflare.F(true), - Locked: cloudflare.F(false), - Privacy: cloudflare.F(true), - }, - ) - 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 TestRegistrarDomainList(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("user@example.com"), - ) - _, err := client.Registrar.Domains.List(context.TODO(), cloudflare.RegistrarDomainListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestRegistrarDomainGet(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("user@example.com"), - ) - _, err := client.Registrar.Domains.Get( - context.TODO(), - "cloudflare.com", - cloudflare.RegistrarDomainGetParams{ - AccountID: cloudflare.F("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/request_tracers/aliases.go b/request_tracers/aliases.go new file mode 100644 index 00000000000..a0311b5338a --- /dev/null +++ b/request_tracers/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package request_tracers + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/requesttracer.go b/request_tracers/requesttracer.go similarity index 89% rename from requesttracer.go rename to request_tracers/requesttracer.go index f71c695fe2a..26fe935fdc2 100644 --- a/requesttracer.go +++ b/request_tracers/requesttracer.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package request_tracers import ( "github.com/cloudflare/cloudflare-go/option" @@ -13,7 +13,7 @@ import ( // instead. type RequestTracerService struct { Options []option.RequestOption - Traces *RequestTracerTraceService + Traces *TraceService } // NewRequestTracerService generates a new service that applies the given options @@ -22,6 +22,6 @@ type RequestTracerService struct { func NewRequestTracerService(opts ...option.RequestOption) (r *RequestTracerService) { r = &RequestTracerService{} r.Options = opts - r.Traces = NewRequestTracerTraceService(opts...) + r.Traces = NewTraceService(opts...) return } diff --git a/request_tracers/trace.go b/request_tracers/trace.go new file mode 100644 index 00000000000..9ad6195db98 --- /dev/null +++ b/request_tracers/trace.go @@ -0,0 +1,222 @@ +// File generated from our OpenAPI spec by Stainless. + +package request_tracers + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// TraceService 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 [NewTraceService] method instead. +type TraceService struct { + Options []option.RequestOption +} + +// NewTraceService 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 NewTraceService(opts ...option.RequestOption) (r *TraceService) { + r = &TraceService{} + r.Options = opts + return +} + +// Request Trace +func (r *TraceService) New(ctx context.Context, accountIdentifier string, body TraceNewParams, opts ...option.RequestOption) (res *TraceNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env TraceNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/request-tracer/trace", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type RequestTracerTrace []RequestTracerTrace + +// Trace result with an origin status code +type TraceNewResponse struct { + // HTTP Status code of zone response + StatusCode int64 `json:"status_code"` + Trace RequestTracerTrace `json:"trace"` + JSON traceNewResponseJSON `json:"-"` +} + +// traceNewResponseJSON contains the JSON metadata for the struct +// [TraceNewResponse] +type traceNewResponseJSON struct { + StatusCode apijson.Field + Trace apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TraceNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r traceNewResponseJSON) RawJSON() string { + return r.raw +} + +type TraceNewParams struct { + // HTTP Method of tracing request + Method param.Field[string] `json:"method,required"` + // URL to which perform tracing request + URL param.Field[string] `json:"url,required"` + Body param.Field[TraceNewParamsBody] `json:"body"` + // Additional request parameters + Context param.Field[TraceNewParamsContext] `json:"context"` + // Cookies added to tracing request + Cookies param.Field[map[string]string] `json:"cookies"` + // Headers added to tracing request + Headers param.Field[map[string]string] `json:"headers"` + // HTTP Protocol of tracing request + Protocol param.Field[string] `json:"protocol"` + // Skip sending the request to the Origin server after all rules evaluation + SkipResponse param.Field[bool] `json:"skip_response"` +} + +func (r TraceNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type TraceNewParamsBody struct { + // Base64 encoded request body + Base64 param.Field[string] `json:"base64"` + // Arbitrary json as request body + Json param.Field[interface{}] `json:"json"` + // Request body as plain text + PlainText param.Field[string] `json:"plain_text"` +} + +func (r TraceNewParamsBody) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Additional request parameters +type TraceNewParamsContext struct { + // Bot score used for evaluating tracing request processing + BotScore param.Field[int64] `json:"bot_score"` + // Geodata for tracing request + Geoloc param.Field[TraceNewParamsContextGeoloc] `json:"geoloc"` + // Whether to skip any challenges for tracing request (e.g.: captcha) + SkipChallenge param.Field[bool] `json:"skip_challenge"` + // Threat score used for evaluating tracing request processing + ThreatScore param.Field[int64] `json:"threat_score"` +} + +func (r TraceNewParamsContext) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Geodata for tracing request +type TraceNewParamsContextGeoloc struct { + City param.Field[string] `json:"city"` + Continent param.Field[string] `json:"continent"` + IsEuCountry param.Field[bool] `json:"is_eu_country"` + ISOCode param.Field[string] `json:"iso_code"` + Latitude param.Field[float64] `json:"latitude"` + Longitude param.Field[float64] `json:"longitude"` + PostalCode param.Field[string] `json:"postal_code"` + RegionCode param.Field[string] `json:"region_code"` + Subdivision2ISOCode param.Field[string] `json:"subdivision_2_iso_code"` + Timezone param.Field[string] `json:"timezone"` +} + +func (r TraceNewParamsContextGeoloc) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type TraceNewResponseEnvelope struct { + Errors []TraceNewResponseEnvelopeErrors `json:"errors,required"` + Messages []TraceNewResponseEnvelopeMessages `json:"messages,required"` + // Trace result with an origin status code + Result TraceNewResponse `json:"result,required"` + // Whether the API call was successful + Success TraceNewResponseEnvelopeSuccess `json:"success,required"` + JSON traceNewResponseEnvelopeJSON `json:"-"` +} + +// traceNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [TraceNewResponseEnvelope] +type traceNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TraceNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r traceNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TraceNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON traceNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// traceNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [TraceNewResponseEnvelopeErrors] +type traceNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TraceNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r traceNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TraceNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON traceNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// traceNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [TraceNewResponseEnvelopeMessages] +type traceNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TraceNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r traceNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TraceNewResponseEnvelopeSuccess bool + +const ( + TraceNewResponseEnvelopeSuccessTrue TraceNewResponseEnvelopeSuccess = true +) diff --git a/request_tracers/trace_test.go b/request_tracers/trace_test.go new file mode 100644 index 00000000000..e4192c3de2f --- /dev/null +++ b/request_tracers/trace_test.go @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package request_tracers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/request_tracers" +) + +func TestTraceNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.RequestTracers.Traces.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + request_tracers.TraceNewParams{ + Method: cloudflare.F("PUT"), + URL: cloudflare.F("https://some.zone/some_path"), + Body: cloudflare.F(request_tracers.TraceNewParamsBody{ + Base64: cloudflare.F("c29tZV9yZXF1ZXN0X2JvZHk="), + Json: cloudflare.F[any](map[string]interface{}{}), + PlainText: cloudflare.F("string"), + }), + Context: cloudflare.F(request_tracers.TraceNewParamsContext{ + BotScore: cloudflare.F(int64(0)), + Geoloc: cloudflare.F(request_tracers.TraceNewParamsContextGeoloc{ + City: cloudflare.F("London"), + Continent: cloudflare.F("string"), + IsEuCountry: cloudflare.F(true), + ISOCode: cloudflare.F("string"), + Latitude: cloudflare.F(0.000000), + Longitude: cloudflare.F(0.000000), + PostalCode: cloudflare.F("string"), + RegionCode: cloudflare.F("string"), + Subdivision2ISOCode: cloudflare.F("string"), + Timezone: cloudflare.F("string"), + }), + SkipChallenge: cloudflare.F(true), + ThreatScore: cloudflare.F(int64(0)), + }), + Cookies: cloudflare.F(map[string]string{ + "cookie_name_1": "cookie_value_1", + "cookie_name_2": "cookie_value_2", + }), + Headers: cloudflare.F(map[string]string{ + "header_name_1": "header_value_1", + "header_name_2": "header_value_2", + }), + Protocol: cloudflare.F("HTTP/1.1"), + SkipResponse: cloudflare.F(true), + }, + ) + 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/requesttracertrace.go b/requesttracertrace.go deleted file mode 100644 index 795110279f3..00000000000 --- a/requesttracertrace.go +++ /dev/null @@ -1,223 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RequestTracerTraceService 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 [NewRequestTracerTraceService] method -// instead. -type RequestTracerTraceService struct { - Options []option.RequestOption -} - -// NewRequestTracerTraceService 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 NewRequestTracerTraceService(opts ...option.RequestOption) (r *RequestTracerTraceService) { - r = &RequestTracerTraceService{} - r.Options = opts - return -} - -// Request Trace -func (r *RequestTracerTraceService) New(ctx context.Context, accountIdentifier string, body RequestTracerTraceNewParams, opts ...option.RequestOption) (res *RequestTracerTraceNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env RequestTracerTraceNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/request-tracer/trace", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RequestTracerTrace []RequestTracerTrace - -// Trace result with an origin status code -type RequestTracerTraceNewResponse struct { - // HTTP Status code of zone response - StatusCode int64 `json:"status_code"` - Trace RequestTracerTrace `json:"trace"` - JSON requestTracerTraceNewResponseJSON `json:"-"` -} - -// requestTracerTraceNewResponseJSON contains the JSON metadata for the struct -// [RequestTracerTraceNewResponse] -type requestTracerTraceNewResponseJSON struct { - StatusCode apijson.Field - Trace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestTracerTraceNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestTracerTraceNewResponseJSON) RawJSON() string { - return r.raw -} - -type RequestTracerTraceNewParams struct { - // HTTP Method of tracing request - Method param.Field[string] `json:"method,required"` - // URL to which perform tracing request - URL param.Field[string] `json:"url,required"` - Body param.Field[RequestTracerTraceNewParamsBody] `json:"body"` - // Additional request parameters - Context param.Field[RequestTracerTraceNewParamsContext] `json:"context"` - // Cookies added to tracing request - Cookies param.Field[map[string]string] `json:"cookies"` - // Headers added to tracing request - Headers param.Field[map[string]string] `json:"headers"` - // HTTP Protocol of tracing request - Protocol param.Field[string] `json:"protocol"` - // Skip sending the request to the Origin server after all rules evaluation - SkipResponse param.Field[bool] `json:"skip_response"` -} - -func (r RequestTracerTraceNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RequestTracerTraceNewParamsBody struct { - // Base64 encoded request body - Base64 param.Field[string] `json:"base64"` - // Arbitrary json as request body - Json param.Field[interface{}] `json:"json"` - // Request body as plain text - PlainText param.Field[string] `json:"plain_text"` -} - -func (r RequestTracerTraceNewParamsBody) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Additional request parameters -type RequestTracerTraceNewParamsContext struct { - // Bot score used for evaluating tracing request processing - BotScore param.Field[int64] `json:"bot_score"` - // Geodata for tracing request - Geoloc param.Field[RequestTracerTraceNewParamsContextGeoloc] `json:"geoloc"` - // Whether to skip any challenges for tracing request (e.g.: captcha) - SkipChallenge param.Field[bool] `json:"skip_challenge"` - // Threat score used for evaluating tracing request processing - ThreatScore param.Field[int64] `json:"threat_score"` -} - -func (r RequestTracerTraceNewParamsContext) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Geodata for tracing request -type RequestTracerTraceNewParamsContextGeoloc struct { - City param.Field[string] `json:"city"` - Continent param.Field[string] `json:"continent"` - IsEuCountry param.Field[bool] `json:"is_eu_country"` - ISOCode param.Field[string] `json:"iso_code"` - Latitude param.Field[float64] `json:"latitude"` - Longitude param.Field[float64] `json:"longitude"` - PostalCode param.Field[string] `json:"postal_code"` - RegionCode param.Field[string] `json:"region_code"` - Subdivision2ISOCode param.Field[string] `json:"subdivision_2_iso_code"` - Timezone param.Field[string] `json:"timezone"` -} - -func (r RequestTracerTraceNewParamsContextGeoloc) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RequestTracerTraceNewResponseEnvelope struct { - Errors []RequestTracerTraceNewResponseEnvelopeErrors `json:"errors,required"` - Messages []RequestTracerTraceNewResponseEnvelopeMessages `json:"messages,required"` - // Trace result with an origin status code - Result RequestTracerTraceNewResponse `json:"result,required"` - // Whether the API call was successful - Success RequestTracerTraceNewResponseEnvelopeSuccess `json:"success,required"` - JSON requestTracerTraceNewResponseEnvelopeJSON `json:"-"` -} - -// requestTracerTraceNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [RequestTracerTraceNewResponseEnvelope] -type requestTracerTraceNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestTracerTraceNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestTracerTraceNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RequestTracerTraceNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestTracerTraceNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// requestTracerTraceNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [RequestTracerTraceNewResponseEnvelopeErrors] -type requestTracerTraceNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestTracerTraceNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestTracerTraceNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RequestTracerTraceNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON requestTracerTraceNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// requestTracerTraceNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [RequestTracerTraceNewResponseEnvelopeMessages] -type requestTracerTraceNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestTracerTraceNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestTracerTraceNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RequestTracerTraceNewResponseEnvelopeSuccess bool - -const ( - RequestTracerTraceNewResponseEnvelopeSuccessTrue RequestTracerTraceNewResponseEnvelopeSuccess = true -) diff --git a/requesttracertrace_test.go b/requesttracertrace_test.go deleted file mode 100644 index b9691ab7555..00000000000 --- a/requesttracertrace_test.go +++ /dev/null @@ -1,77 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRequestTracerTraceNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.RequestTracers.Traces.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.RequestTracerTraceNewParams{ - Method: cloudflare.F("PUT"), - URL: cloudflare.F("https://some.zone/some_path"), - Body: cloudflare.F(cloudflare.RequestTracerTraceNewParamsBody{ - Base64: cloudflare.F("c29tZV9yZXF1ZXN0X2JvZHk="), - Json: cloudflare.F[any](map[string]interface{}{}), - PlainText: cloudflare.F("string"), - }), - Context: cloudflare.F(cloudflare.RequestTracerTraceNewParamsContext{ - BotScore: cloudflare.F(int64(0)), - Geoloc: cloudflare.F(cloudflare.RequestTracerTraceNewParamsContextGeoloc{ - City: cloudflare.F("London"), - Continent: cloudflare.F("string"), - IsEuCountry: cloudflare.F(true), - ISOCode: cloudflare.F("string"), - Latitude: cloudflare.F(0.000000), - Longitude: cloudflare.F(0.000000), - PostalCode: cloudflare.F("string"), - RegionCode: cloudflare.F("string"), - Subdivision2ISOCode: cloudflare.F("string"), - Timezone: cloudflare.F("string"), - }), - SkipChallenge: cloudflare.F(true), - ThreatScore: cloudflare.F(int64(0)), - }), - Cookies: cloudflare.F(map[string]string{ - "cookie_name_1": "cookie_value_1", - "cookie_name_2": "cookie_value_2", - }), - Headers: cloudflare.F(map[string]string{ - "header_name_1": "header_value_1", - "header_name_2": "header_value_2", - }), - Protocol: cloudflare.F("HTTP/1.1"), - SkipResponse: cloudflare.F(true), - }, - ) - 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/rule.go b/rule.go deleted file mode 100644 index c858c4acaf2..00000000000 --- a/rule.go +++ /dev/null @@ -1,26 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-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 deleted file mode 100644 index 2b19128a73b..00000000000 --- a/rulelist.go +++ /dev/null @@ -1,641 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-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 -} - -// Creates a new list of the specified type. -func (r *RuleListService) New(ctx context.Context, params RuleListNewParams, opts ...option.RequestOption) (res *[]RuleListNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env RuleListNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/rules/lists", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates the description of a list. -func (r *RuleListService) Update(ctx context.Context, listID string, params RuleListUpdateParams, opts ...option.RequestOption) (res *[]RuleListUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env RuleListUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/rules/lists/%s", params.AccountID, listID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches all lists in the account. -func (r *RuleListService) List(ctx context.Context, query RuleListListParams, opts ...option.RequestOption) (res *[]RuleListListResponse, err error) { - opts = append(r.Options[:], opts...) - var env RuleListListResponseEnvelope - path := fmt.Sprintf("accounts/%s/rules/lists", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &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, listID string, body RuleListDeleteParams, opts ...option.RequestOption) (res *RuleListDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env RuleListDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/rules/lists/%s", body.AccountID, listID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the details of a list. -func (r *RuleListService) Get(ctx context.Context, listID string, query RuleListGetParams, opts ...option.RequestOption) (res *[]RuleListGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RuleListGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/rules/lists/%s", query.AccountID, listID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RuleListNewResponse = interface{} - -type RuleListUpdateResponse = interface{} - -type RuleListListResponse 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 RuleListListResponseKind `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 ruleListListResponseJSON `json:"-"` -} - -// ruleListListResponseJSON contains the JSON metadata for the struct -// [RuleListListResponse] -type ruleListListResponseJSON 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 *RuleListListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListListResponseJSON) RawJSON() string { - return r.raw -} - -// The type of the list. Each type supports specific list items (IP addresses, -// ASNs, hostnames or redirects). -type RuleListListResponseKind string - -const ( - RuleListListResponseKindIP RuleListListResponseKind = "ip" - RuleListListResponseKindRedirect RuleListListResponseKind = "redirect" - RuleListListResponseKindHostname RuleListListResponseKind = "hostname" - RuleListListResponseKindASN RuleListListResponseKind = "asn" -) - -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) -} - -func (r ruleListDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type RuleListGetResponse = interface{} - -type RuleListNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The type of the list. Each type supports specific list items (IP addresses, - // ASNs, hostnames or redirects). - Kind param.Field[RuleListNewParamsKind] `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 RuleListNewParams) 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 RuleListNewParamsKind string - -const ( - RuleListNewParamsKindIP RuleListNewParamsKind = "ip" - RuleListNewParamsKindRedirect RuleListNewParamsKind = "redirect" - RuleListNewParamsKindHostname RuleListNewParamsKind = "hostname" - RuleListNewParamsKindASN RuleListNewParamsKind = "asn" -) - -type RuleListNewResponseEnvelope struct { - Errors []RuleListNewResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleListNewResponseEnvelopeMessages `json:"messages,required"` - Result []RuleListNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success RuleListNewResponseEnvelopeSuccess `json:"success,required"` - JSON ruleListNewResponseEnvelopeJSON `json:"-"` -} - -// ruleListNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [RuleListNewResponseEnvelope] -type ruleListNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RuleListNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleListNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleListNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleListNewResponseEnvelopeErrors] -type ruleListNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleListNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleListNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleListNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RuleListNewResponseEnvelopeMessages] -type ruleListNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RuleListNewResponseEnvelopeSuccess bool - -const ( - RuleListNewResponseEnvelopeSuccessTrue RuleListNewResponseEnvelopeSuccess = true -) - -type RuleListUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // 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) -} - -func (r ruleListUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -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) -} - -func (r ruleListUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -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) -} - -func (r ruleListUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RuleListUpdateResponseEnvelopeSuccess bool - -const ( - RuleListUpdateResponseEnvelopeSuccessTrue RuleListUpdateResponseEnvelopeSuccess = true -) - -type RuleListListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type RuleListListResponseEnvelope struct { - Errors []RuleListListResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleListListResponseEnvelopeMessages `json:"messages,required"` - Result []RuleListListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success RuleListListResponseEnvelopeSuccess `json:"success,required"` - JSON ruleListListResponseEnvelopeJSON `json:"-"` -} - -// ruleListListResponseEnvelopeJSON contains the JSON metadata for the struct -// [RuleListListResponseEnvelope] -type ruleListListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RuleListListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleListListResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleListListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RuleListListResponseEnvelopeErrors] -type ruleListListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleListListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleListListResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleListListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RuleListListResponseEnvelopeMessages] -type ruleListListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RuleListListResponseEnvelopeSuccess bool - -const ( - RuleListListResponseEnvelopeSuccessTrue RuleListListResponseEnvelopeSuccess = true -) - -type RuleListDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -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) -} - -func (r ruleListDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -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) -} - -func (r ruleListDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -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) -} - -func (r ruleListDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RuleListDeleteResponseEnvelopeSuccess bool - -const ( - RuleListDeleteResponseEnvelopeSuccessTrue RuleListDeleteResponseEnvelopeSuccess = true -) - -type RuleListGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -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) -} - -func (r ruleListGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -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) -} - -func (r ruleListGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -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) -} - -func (r ruleListGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RuleListGetResponseEnvelopeSuccess bool - -const ( - RuleListGetResponseEnvelopeSuccessTrue RuleListGetResponseEnvelopeSuccess = true -) diff --git a/rulelist_test.go b/rulelist_test.go deleted file mode 100644 index c11b9c81bd3..00000000000 --- a/rulelist_test.go +++ /dev/null @@ -1,160 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRuleListNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Rules.Lists.New(context.TODO(), cloudflare.RuleListNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Kind: cloudflare.F(cloudflare.RuleListNewParamsKindIP), - 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 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("user@example.com"), - ) - _, err := client.Rules.Lists.Update( - context.TODO(), - "2c0fc9fa937b11eaa1b71c4d701ab86e", - cloudflare.RuleListUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - 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 TestRuleListList(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("user@example.com"), - ) - _, err := client.Rules.Lists.List(context.TODO(), cloudflare.RuleListListParams{ - AccountID: cloudflare.F("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()) - } -} - -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("user@example.com"), - ) - _, err := client.Rules.Lists.Delete( - context.TODO(), - "2c0fc9fa937b11eaa1b71c4d701ab86e", - cloudflare.RuleListDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -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("user@example.com"), - ) - _, err := client.Rules.Lists.Get( - context.TODO(), - "2c0fc9fa937b11eaa1b71c4d701ab86e", - cloudflare.RuleListGetParams{ - AccountID: cloudflare.F("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 deleted file mode 100644 index 5e108c6782b..00000000000 --- a/rulelistbulkoperation.go +++ /dev/null @@ -1,131 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-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) -} - -func (r ruleListBulkOperationGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -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) -} - -func (r ruleListBulkOperationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -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) -} - -func (r ruleListBulkOperationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RuleListBulkOperationGetResponseEnvelopeSuccess bool - -const ( - RuleListBulkOperationGetResponseEnvelopeSuccessTrue RuleListBulkOperationGetResponseEnvelopeSuccess = true -) diff --git a/rulelistbulkoperation_test.go b/rulelistbulkoperation_test.go deleted file mode 100644 index 50979eb5f87..00000000000 --- a/rulelistbulkoperation_test.go +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-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("user@example.com"), - ) - _, 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 deleted file mode 100644 index 80f7d662d67..00000000000 --- a/rulelistitem.go +++ /dev/null @@ -1,909 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-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 -} - -// 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) New(ctx context.Context, listID string, params RuleListItemNewParams, opts ...option.RequestOption) (res *RuleListItemNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env RuleListItemNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/rules/lists/%s/items", params.AccountID, listID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &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) Update(ctx context.Context, listID string, params RuleListItemUpdateParams, opts ...option.RequestOption) (res *RuleListItemUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env RuleListItemUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/rules/lists/%s/items", params.AccountID, listID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches all the items in the list. -func (r *RuleListItemService) List(ctx context.Context, listID string, params RuleListItemListParams, opts ...option.RequestOption) (res *[]RuleListItemListResponse, err error) { - opts = append(r.Options[:], opts...) - var env RuleListItemListResponseEnvelope - path := fmt.Sprintf("accounts/%s/rules/lists/%s/items", params.AccountID, listID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &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, listID string, params 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", params.AccountID, listID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - 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 -} - -type RuleListItemNewResponse struct { - // The unique operation ID of the asynchronous action. - OperationID string `json:"operation_id"` - JSON ruleListItemNewResponseJSON `json:"-"` -} - -// ruleListItemNewResponseJSON contains the JSON metadata for the struct -// [RuleListItemNewResponse] -type ruleListItemNewResponseJSON struct { - OperationID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListItemNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListItemNewResponseJSON) RawJSON() string { - return r.raw -} - -type RuleListItemUpdateResponse struct { - // The unique operation ID of the asynchronous action. - OperationID string `json:"operation_id"` - JSON ruleListItemUpdateResponseJSON `json:"-"` -} - -// ruleListItemUpdateResponseJSON contains the JSON metadata for the struct -// [RuleListItemUpdateResponse] -type ruleListItemUpdateResponseJSON struct { - OperationID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListItemUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListItemUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type RuleListItemListResponse = interface{} - -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) -} - -func (r ruleListItemDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// 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.JSON, - Type: reflect.TypeOf(RuleListItemGetResponseListsItemRedirect{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RuleListItemGetResponseListsItemHostname{}), - }, - 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 ruleListItemGetResponseListsItemRedirectJSON) RawJSON() string { - return r.raw -} - -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 ruleListItemGetResponseListsItemHostnameJSON) RawJSON() string { - return r.raw -} - -func (r RuleListItemGetResponseListsItemHostname) ImplementsRuleListItemGetResponse() {} - -type RuleListItemNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[[]RuleListItemNewParamsBody] `json:"body,required"` -} - -func (r RuleListItemNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type RuleListItemNewParamsBody 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[RuleListItemNewParamsBodyHostname] `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[RuleListItemNewParamsBodyRedirect] `json:"redirect"` -} - -func (r RuleListItemNewParamsBody) 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 RuleListItemNewParamsBodyHostname struct { - URLHostname param.Field[string] `json:"url_hostname,required"` -} - -func (r RuleListItemNewParamsBodyHostname) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The definition of the redirect. -type RuleListItemNewParamsBodyRedirect 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[RuleListItemNewParamsBodyRedirectStatusCode] `json:"status_code"` - SubpathMatching param.Field[bool] `json:"subpath_matching"` -} - -func (r RuleListItemNewParamsBodyRedirect) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RuleListItemNewParamsBodyRedirectStatusCode int64 - -const ( - RuleListItemNewParamsBodyRedirectStatusCode301 RuleListItemNewParamsBodyRedirectStatusCode = 301 - RuleListItemNewParamsBodyRedirectStatusCode302 RuleListItemNewParamsBodyRedirectStatusCode = 302 - RuleListItemNewParamsBodyRedirectStatusCode307 RuleListItemNewParamsBodyRedirectStatusCode = 307 - RuleListItemNewParamsBodyRedirectStatusCode308 RuleListItemNewParamsBodyRedirectStatusCode = 308 -) - -type RuleListItemNewResponseEnvelope struct { - Errors []RuleListItemNewResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleListItemNewResponseEnvelopeMessages `json:"messages,required"` - Result RuleListItemNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success RuleListItemNewResponseEnvelopeSuccess `json:"success,required"` - JSON ruleListItemNewResponseEnvelopeJSON `json:"-"` -} - -// ruleListItemNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [RuleListItemNewResponseEnvelope] -type ruleListItemNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListItemNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListItemNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RuleListItemNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleListItemNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleListItemNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RuleListItemNewResponseEnvelopeErrors] -type ruleListItemNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListItemNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListItemNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleListItemNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleListItemNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleListItemNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RuleListItemNewResponseEnvelopeMessages] -type ruleListItemNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListItemNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListItemNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RuleListItemNewResponseEnvelopeSuccess bool - -const ( - RuleListItemNewResponseEnvelopeSuccessTrue RuleListItemNewResponseEnvelopeSuccess = true -) - -type RuleListItemUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[[]RuleListItemUpdateParamsBody] `json:"body,required"` -} - -func (r RuleListItemUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type RuleListItemUpdateParamsBody 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[RuleListItemUpdateParamsBodyHostname] `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[RuleListItemUpdateParamsBodyRedirect] `json:"redirect"` -} - -func (r RuleListItemUpdateParamsBody) 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 RuleListItemUpdateParamsBodyHostname struct { - URLHostname param.Field[string] `json:"url_hostname,required"` -} - -func (r RuleListItemUpdateParamsBodyHostname) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The definition of the redirect. -type RuleListItemUpdateParamsBodyRedirect 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[RuleListItemUpdateParamsBodyRedirectStatusCode] `json:"status_code"` - SubpathMatching param.Field[bool] `json:"subpath_matching"` -} - -func (r RuleListItemUpdateParamsBodyRedirect) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RuleListItemUpdateParamsBodyRedirectStatusCode int64 - -const ( - RuleListItemUpdateParamsBodyRedirectStatusCode301 RuleListItemUpdateParamsBodyRedirectStatusCode = 301 - RuleListItemUpdateParamsBodyRedirectStatusCode302 RuleListItemUpdateParamsBodyRedirectStatusCode = 302 - RuleListItemUpdateParamsBodyRedirectStatusCode307 RuleListItemUpdateParamsBodyRedirectStatusCode = 307 - RuleListItemUpdateParamsBodyRedirectStatusCode308 RuleListItemUpdateParamsBodyRedirectStatusCode = 308 -) - -type RuleListItemUpdateResponseEnvelope struct { - Errors []RuleListItemUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleListItemUpdateResponseEnvelopeMessages `json:"messages,required"` - Result RuleListItemUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success RuleListItemUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON ruleListItemUpdateResponseEnvelopeJSON `json:"-"` -} - -// ruleListItemUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [RuleListItemUpdateResponseEnvelope] -type ruleListItemUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListItemUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListItemUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RuleListItemUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleListItemUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleListItemUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RuleListItemUpdateResponseEnvelopeErrors] -type ruleListItemUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListItemUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListItemUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleListItemUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleListItemUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleListItemUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [RuleListItemUpdateResponseEnvelopeMessages] -type ruleListItemUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListItemUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListItemUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RuleListItemUpdateResponseEnvelopeSuccess bool - -const ( - RuleListItemUpdateResponseEnvelopeSuccessTrue RuleListItemUpdateResponseEnvelopeSuccess = true -) - -type RuleListItemListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // 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 [RuleListItemListParams]'s query parameters as `url.Values`. -func (r RuleListItemListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type RuleListItemListResponseEnvelope struct { - Errors []RuleListItemListResponseEnvelopeErrors `json:"errors,required"` - Messages []RuleListItemListResponseEnvelopeMessages `json:"messages,required"` - Result []RuleListItemListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success RuleListItemListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo RuleListItemListResponseEnvelopeResultInfo `json:"result_info"` - JSON ruleListItemListResponseEnvelopeJSON `json:"-"` -} - -// ruleListItemListResponseEnvelopeJSON contains the JSON metadata for the struct -// [RuleListItemListResponseEnvelope] -type ruleListItemListResponseEnvelopeJSON 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 *RuleListItemListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListItemListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RuleListItemListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleListItemListResponseEnvelopeErrorsJSON `json:"-"` -} - -// ruleListItemListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RuleListItemListResponseEnvelopeErrors] -type ruleListItemListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListItemListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListItemListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type RuleListItemListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON ruleListItemListResponseEnvelopeMessagesJSON `json:"-"` -} - -// ruleListItemListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RuleListItemListResponseEnvelopeMessages] -type ruleListItemListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListItemListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListItemListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RuleListItemListResponseEnvelopeSuccess bool - -const ( - RuleListItemListResponseEnvelopeSuccessTrue RuleListItemListResponseEnvelopeSuccess = true -) - -type RuleListItemListResponseEnvelopeResultInfo struct { - Cursors RuleListItemListResponseEnvelopeResultInfoCursors `json:"cursors"` - JSON ruleListItemListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// ruleListItemListResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [RuleListItemListResponseEnvelopeResultInfo] -type ruleListItemListResponseEnvelopeResultInfoJSON struct { - Cursors apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListItemListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListItemListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type RuleListItemListResponseEnvelopeResultInfoCursors struct { - After string `json:"after"` - Before string `json:"before"` - JSON ruleListItemListResponseEnvelopeResultInfoCursorsJSON `json:"-"` -} - -// ruleListItemListResponseEnvelopeResultInfoCursorsJSON contains the JSON metadata -// for the struct [RuleListItemListResponseEnvelopeResultInfoCursors] -type ruleListItemListResponseEnvelopeResultInfoCursorsJSON struct { - After apijson.Field - Before apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListItemListResponseEnvelopeResultInfoCursors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListItemListResponseEnvelopeResultInfoCursorsJSON) RawJSON() string { - return r.raw -} - -type RuleListItemDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - 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) -} - -func (r ruleListItemDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -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) -} - -func (r ruleListItemDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -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) -} - -func (r ruleListItemDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RuleListItemDeleteResponseEnvelopeSuccess bool - -const ( - RuleListItemDeleteResponseEnvelopeSuccessTrue RuleListItemDeleteResponseEnvelopeSuccess = true -) - -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) -} - -func (r ruleListItemGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -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) -} - -func (r ruleListItemGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -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) -} - -func (r ruleListItemGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RuleListItemGetResponseEnvelopeSuccess bool - -const ( - RuleListItemGetResponseEnvelopeSuccessTrue RuleListItemGetResponseEnvelopeSuccess = true -) diff --git a/rulelistitem_test.go b/rulelistitem_test.go deleted file mode 100644 index 9bd44b65b14..00000000000 --- a/rulelistitem_test.go +++ /dev/null @@ -1,267 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRuleListItemNew(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("user@example.com"), - ) - _, err := client.Rules.Lists.Items.New( - context.TODO(), - "2c0fc9fa937b11eaa1b71c4d701ab86e", - cloudflare.RuleListItemNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F([]cloudflare.RuleListItemNewParamsBody{{ - ASN: cloudflare.F(int64(5567)), - Comment: cloudflare.F("Private IP address"), - Hostname: cloudflare.F(cloudflare.RuleListItemNewParamsBodyHostname{ - URLHostname: cloudflare.F("example.com"), - }), - IP: cloudflare.F("10.0.0.1"), - Redirect: cloudflare.F(cloudflare.RuleListItemNewParamsBodyRedirect{ - IncludeSubdomains: cloudflare.F(true), - PreservePathSuffix: cloudflare.F(true), - PreserveQueryString: cloudflare.F(true), - SourceURL: cloudflare.F("example.com/arch"), - StatusCode: cloudflare.F(cloudflare.RuleListItemNewParamsBodyRedirectStatusCode301), - 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.RuleListItemNewParamsBodyHostname{ - URLHostname: cloudflare.F("example.com"), - }), - IP: cloudflare.F("10.0.0.1"), - Redirect: cloudflare.F(cloudflare.RuleListItemNewParamsBodyRedirect{ - IncludeSubdomains: cloudflare.F(true), - PreservePathSuffix: cloudflare.F(true), - PreserveQueryString: cloudflare.F(true), - SourceURL: cloudflare.F("example.com/arch"), - StatusCode: cloudflare.F(cloudflare.RuleListItemNewParamsBodyRedirectStatusCode301), - 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.RuleListItemNewParamsBodyHostname{ - URLHostname: cloudflare.F("example.com"), - }), - IP: cloudflare.F("10.0.0.1"), - Redirect: cloudflare.F(cloudflare.RuleListItemNewParamsBodyRedirect{ - IncludeSubdomains: cloudflare.F(true), - PreservePathSuffix: cloudflare.F(true), - PreserveQueryString: cloudflare.F(true), - SourceURL: cloudflare.F("example.com/arch"), - StatusCode: cloudflare.F(cloudflare.RuleListItemNewParamsBodyRedirectStatusCode301), - 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 TestRuleListItemUpdate(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("user@example.com"), - ) - _, err := client.Rules.Lists.Items.Update( - context.TODO(), - "2c0fc9fa937b11eaa1b71c4d701ab86e", - cloudflare.RuleListItemUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F([]cloudflare.RuleListItemUpdateParamsBody{{ - ASN: cloudflare.F(int64(5567)), - Comment: cloudflare.F("Private IP address"), - Hostname: cloudflare.F(cloudflare.RuleListItemUpdateParamsBodyHostname{ - URLHostname: cloudflare.F("example.com"), - }), - IP: cloudflare.F("10.0.0.1"), - Redirect: cloudflare.F(cloudflare.RuleListItemUpdateParamsBodyRedirect{ - IncludeSubdomains: cloudflare.F(true), - PreservePathSuffix: cloudflare.F(true), - PreserveQueryString: cloudflare.F(true), - SourceURL: cloudflare.F("example.com/arch"), - StatusCode: cloudflare.F(cloudflare.RuleListItemUpdateParamsBodyRedirectStatusCode301), - 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.RuleListItemUpdateParamsBodyHostname{ - URLHostname: cloudflare.F("example.com"), - }), - IP: cloudflare.F("10.0.0.1"), - Redirect: cloudflare.F(cloudflare.RuleListItemUpdateParamsBodyRedirect{ - IncludeSubdomains: cloudflare.F(true), - PreservePathSuffix: cloudflare.F(true), - PreserveQueryString: cloudflare.F(true), - SourceURL: cloudflare.F("example.com/arch"), - StatusCode: cloudflare.F(cloudflare.RuleListItemUpdateParamsBodyRedirectStatusCode301), - 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.RuleListItemUpdateParamsBodyHostname{ - URLHostname: cloudflare.F("example.com"), - }), - IP: cloudflare.F("10.0.0.1"), - Redirect: cloudflare.F(cloudflare.RuleListItemUpdateParamsBodyRedirect{ - IncludeSubdomains: cloudflare.F(true), - PreservePathSuffix: cloudflare.F(true), - PreserveQueryString: cloudflare.F(true), - SourceURL: cloudflare.F("example.com/arch"), - StatusCode: cloudflare.F(cloudflare.RuleListItemUpdateParamsBodyRedirectStatusCode301), - 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 TestRuleListItemListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Rules.Lists.Items.List( - context.TODO(), - "2c0fc9fa937b11eaa1b71c4d701ab86e", - cloudflare.RuleListItemListParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - 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 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("user@example.com"), - ) - _, err := client.Rules.Lists.Items.Delete( - context.TODO(), - "2c0fc9fa937b11eaa1b71c4d701ab86e", - cloudflare.RuleListItemDeleteParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - 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 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("user@example.com"), - ) - _, 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()) - } -} diff --git a/rules/aliases.go b/rules/aliases.go new file mode 100644 index 00000000000..09b22308b08 --- /dev/null +++ b/rules/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package rules + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/rules/list.go b/rules/list.go new file mode 100644 index 00000000000..6f3f46898ad --- /dev/null +++ b/rules/list.go @@ -0,0 +1,640 @@ +// File generated from our OpenAPI spec by Stainless. + +package rules + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ListService 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 [NewListService] method instead. +type ListService struct { + Options []option.RequestOption + BulkOperations *ListBulkOperationService + Items *ListItemService +} + +// NewListService 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 NewListService(opts ...option.RequestOption) (r *ListService) { + r = &ListService{} + r.Options = opts + r.BulkOperations = NewListBulkOperationService(opts...) + r.Items = NewListItemService(opts...) + return +} + +// Creates a new list of the specified type. +func (r *ListService) New(ctx context.Context, params ListNewParams, opts ...option.RequestOption) (res *ListsList, err error) { + opts = append(r.Options[:], opts...) + var env ListNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates the description of a list. +func (r *ListService) Update(ctx context.Context, listID string, params ListUpdateParams, opts ...option.RequestOption) (res *ListsList, err error) { + opts = append(r.Options[:], opts...) + var env ListUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists/%s", params.AccountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches all lists in the account. +func (r *ListService) List(ctx context.Context, query ListListParams, opts ...option.RequestOption) (res *[]ListsList, err error) { + opts = append(r.Options[:], opts...) + var env ListListResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a specific list and all its items. +func (r *ListService) Delete(ctx context.Context, listID string, body ListDeleteParams, opts ...option.RequestOption) (res *ListDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env ListDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists/%s", body.AccountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the details of a list. +func (r *ListService) Get(ctx context.Context, listID string, query ListGetParams, opts ...option.RequestOption) (res *ListsList, err error) { + opts = append(r.Options[:], opts...) + var env ListGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists/%s", query.AccountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ListsList struct { + // The unique ID of the list. + ID string `json:"id"` + // The RFC 3339 timestamp of when the list was created. + CreatedOn string `json:"created_on"` + // An informative summary of the list. + Description string `json:"description"` + // The type of the list. Each type supports specific list items (IP addresses, + // ASNs, hostnames or redirects). + Kind ListsListKind `json:"kind"` + // The RFC 3339 timestamp of when the list was last modified. + ModifiedOn string `json:"modified_on"` + // An informative name for the list. Use this name in filter and rule expressions. + Name string `json:"name"` + // The number of items in the list. + NumItems float64 `json:"num_items"` + // The number of [filters](/operations/filters-list-filters) referencing the list. + NumReferencingFilters float64 `json:"num_referencing_filters"` + JSON listsListJSON `json:"-"` +} + +// listsListJSON contains the JSON metadata for the struct [ListsList] +type listsListJSON struct { + ID apijson.Field + CreatedOn apijson.Field + Description apijson.Field + Kind apijson.Field + ModifiedOn apijson.Field + Name apijson.Field + NumItems apijson.Field + NumReferencingFilters apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListsList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listsListJSON) RawJSON() string { + return r.raw +} + +// The type of the list. Each type supports specific list items (IP addresses, +// ASNs, hostnames or redirects). +type ListsListKind string + +const ( + ListsListKindIP ListsListKind = "ip" + ListsListKindRedirect ListsListKind = "redirect" + ListsListKindHostname ListsListKind = "hostname" + ListsListKindASN ListsListKind = "asn" +) + +type ListNewResponse = interface{} + +type ListUpdateResponse = interface{} + +type ListDeleteResponse struct { + // The unique ID of the item in the List. + ID string `json:"id"` + JSON listDeleteResponseJSON `json:"-"` +} + +// listDeleteResponseJSON contains the JSON metadata for the struct +// [ListDeleteResponse] +type listDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type ListGetResponse = interface{} + +type ListNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The type of the list. Each type supports specific list items (IP addresses, + // ASNs, hostnames or redirects). + Kind param.Field[ListNewParamsKind] `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 ListNewParams) 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 ListNewParamsKind string + +const ( + ListNewParamsKindIP ListNewParamsKind = "ip" + ListNewParamsKindRedirect ListNewParamsKind = "redirect" + ListNewParamsKindHostname ListNewParamsKind = "hostname" + ListNewParamsKindASN ListNewParamsKind = "asn" +) + +type ListNewResponseEnvelope struct { + Errors []ListNewResponseEnvelopeErrors `json:"errors,required"` + Messages []ListNewResponseEnvelopeMessages `json:"messages,required"` + Result ListsList `json:"result,required,nullable"` + // Whether the API call was successful + Success ListNewResponseEnvelopeSuccess `json:"success,required"` + JSON listNewResponseEnvelopeJSON `json:"-"` +} + +// listNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [ListNewResponseEnvelope] +type listNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ListNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// listNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ListNewResponseEnvelopeErrors] +type listNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ListNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// listNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ListNewResponseEnvelopeMessages] +type listNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ListNewResponseEnvelopeSuccess bool + +const ( + ListNewResponseEnvelopeSuccessTrue ListNewResponseEnvelopeSuccess = true +) + +type ListUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // An informative summary of the list. + Description param.Field[string] `json:"description"` +} + +func (r ListUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ListUpdateResponseEnvelope struct { + Errors []ListUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []ListUpdateResponseEnvelopeMessages `json:"messages,required"` + Result ListsList `json:"result,required,nullable"` + // Whether the API call was successful + Success ListUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON listUpdateResponseEnvelopeJSON `json:"-"` +} + +// listUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [ListUpdateResponseEnvelope] +type listUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ListUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// listUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ListUpdateResponseEnvelopeErrors] +type listUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ListUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// listUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ListUpdateResponseEnvelopeMessages] +type listUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ListUpdateResponseEnvelopeSuccess bool + +const ( + ListUpdateResponseEnvelopeSuccessTrue ListUpdateResponseEnvelopeSuccess = true +) + +type ListListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ListListResponseEnvelope struct { + Errors []ListListResponseEnvelopeErrors `json:"errors,required"` + Messages []ListListResponseEnvelopeMessages `json:"messages,required"` + Result []ListsList `json:"result,required,nullable"` + // Whether the API call was successful + Success ListListResponseEnvelopeSuccess `json:"success,required"` + JSON listListResponseEnvelopeJSON `json:"-"` +} + +// listListResponseEnvelopeJSON contains the JSON metadata for the struct +// [ListListResponseEnvelope] +type listListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ListListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listListResponseEnvelopeErrorsJSON `json:"-"` +} + +// listListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ListListResponseEnvelopeErrors] +type listListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ListListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listListResponseEnvelopeMessagesJSON `json:"-"` +} + +// listListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ListListResponseEnvelopeMessages] +type listListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ListListResponseEnvelopeSuccess bool + +const ( + ListListResponseEnvelopeSuccessTrue ListListResponseEnvelopeSuccess = true +) + +type ListDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ListDeleteResponseEnvelope struct { + Errors []ListDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []ListDeleteResponseEnvelopeMessages `json:"messages,required"` + Result ListDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ListDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON listDeleteResponseEnvelopeJSON `json:"-"` +} + +// listDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [ListDeleteResponseEnvelope] +type listDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ListDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// listDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ListDeleteResponseEnvelopeErrors] +type listDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ListDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// listDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ListDeleteResponseEnvelopeMessages] +type listDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ListDeleteResponseEnvelopeSuccess bool + +const ( + ListDeleteResponseEnvelopeSuccessTrue ListDeleteResponseEnvelopeSuccess = true +) + +type ListGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ListGetResponseEnvelope struct { + Errors []ListGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ListGetResponseEnvelopeMessages `json:"messages,required"` + Result ListsList `json:"result,required,nullable"` + // Whether the API call was successful + Success ListGetResponseEnvelopeSuccess `json:"success,required"` + JSON listGetResponseEnvelopeJSON `json:"-"` +} + +// listGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [ListGetResponseEnvelope] +type listGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ListGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// listGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ListGetResponseEnvelopeErrors] +type listGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ListGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// listGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ListGetResponseEnvelopeMessages] +type listGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ListGetResponseEnvelopeSuccess bool + +const ( + ListGetResponseEnvelopeSuccessTrue ListGetResponseEnvelopeSuccess = true +) diff --git a/rules/list_test.go b/rules/list_test.go new file mode 100644 index 00000000000..bf888cf714d --- /dev/null +++ b/rules/list_test.go @@ -0,0 +1,161 @@ +// File generated from our OpenAPI spec by Stainless. + +package rules_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/rules" +) + +func TestListNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Rules.Lists.New(context.TODO(), rules.ListNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Kind: cloudflare.F(rules.ListNewParamsKindIP), + 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 TestListUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Rules.Lists.Update( + context.TODO(), + "2c0fc9fa937b11eaa1b71c4d701ab86e", + rules.ListUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + 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 TestListList(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("user@example.com"), + ) + _, err := client.Rules.Lists.List(context.TODO(), rules.ListListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestListDelete(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("user@example.com"), + ) + _, err := client.Rules.Lists.Delete( + context.TODO(), + "2c0fc9fa937b11eaa1b71c4d701ab86e", + rules.ListDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestListGet(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("user@example.com"), + ) + _, err := client.Rules.Lists.Get( + context.TODO(), + "2c0fc9fa937b11eaa1b71c4d701ab86e", + rules.ListGetParams{ + AccountID: cloudflare.F("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/rules/listbulkoperation.go b/rules/listbulkoperation.go new file mode 100644 index 00000000000..9768de39686 --- /dev/null +++ b/rules/listbulkoperation.go @@ -0,0 +1,131 @@ +// File generated from our OpenAPI spec by Stainless. + +package rules + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ListBulkOperationService 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 [NewListBulkOperationService] method +// instead. +type ListBulkOperationService struct { + Options []option.RequestOption +} + +// NewListBulkOperationService 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 NewListBulkOperationService(opts ...option.RequestOption) (r *ListBulkOperationService) { + r = &ListBulkOperationService{} + 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 *ListBulkOperationService) Get(ctx context.Context, accountIdentifier string, operationID string, opts ...option.RequestOption) (res *[]ListBulkOperationGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env ListBulkOperationGetResponseEnvelope + 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 ListBulkOperationGetResponse = interface{} + +type ListBulkOperationGetResponseEnvelope struct { + Errors []ListBulkOperationGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ListBulkOperationGetResponseEnvelopeMessages `json:"messages,required"` + Result []ListBulkOperationGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ListBulkOperationGetResponseEnvelopeSuccess `json:"success,required"` + JSON listBulkOperationGetResponseEnvelopeJSON `json:"-"` +} + +// listBulkOperationGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [ListBulkOperationGetResponseEnvelope] +type listBulkOperationGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListBulkOperationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listBulkOperationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ListBulkOperationGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listBulkOperationGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// listBulkOperationGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [ListBulkOperationGetResponseEnvelopeErrors] +type listBulkOperationGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListBulkOperationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listBulkOperationGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ListBulkOperationGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listBulkOperationGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// listBulkOperationGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [ListBulkOperationGetResponseEnvelopeMessages] +type listBulkOperationGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListBulkOperationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listBulkOperationGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ListBulkOperationGetResponseEnvelopeSuccess bool + +const ( + ListBulkOperationGetResponseEnvelopeSuccessTrue ListBulkOperationGetResponseEnvelopeSuccess = true +) diff --git a/rules/listbulkoperation_test.go b/rules/listbulkoperation_test.go new file mode 100644 index 00000000000..0fe299aed56 --- /dev/null +++ b/rules/listbulkoperation_test.go @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package rules_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestListBulkOperationGet(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("user@example.com"), + ) + _, 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/rules/listitem.go b/rules/listitem.go new file mode 100644 index 00000000000..739a20afc16 --- /dev/null +++ b/rules/listitem.go @@ -0,0 +1,908 @@ +// File generated from our OpenAPI spec by Stainless. + +package rules + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// ListItemService 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 [NewListItemService] method instead. +type ListItemService struct { + Options []option.RequestOption +} + +// NewListItemService 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 NewListItemService(opts ...option.RequestOption) (r *ListItemService) { + r = &ListItemService{} + r.Options = opts + 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 *ListItemService) New(ctx context.Context, listID string, params ListItemNewParams, opts ...option.RequestOption) (res *ListItemNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env ListItemNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists/%s/items", params.AccountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &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 *ListItemService) Update(ctx context.Context, listID string, params ListItemUpdateParams, opts ...option.RequestOption) (res *ListItemUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env ListItemUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists/%s/items", params.AccountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches all the items in the list. +func (r *ListItemService) List(ctx context.Context, listID string, params ListItemListParams, opts ...option.RequestOption) (res *[]ListItemListResponse, err error) { + opts = append(r.Options[:], opts...) + var env ListItemListResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists/%s/items", params.AccountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &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 *ListItemService) Delete(ctx context.Context, listID string, params ListItemDeleteParams, opts ...option.RequestOption) (res *ListItemDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env ListItemDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/rules/lists/%s/items", params.AccountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a list item in the list. +func (r *ListItemService) Get(ctx context.Context, accountIdentifier string, listID string, itemID string, opts ...option.RequestOption) (res *ListItemGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env ListItemGetResponseEnvelope + 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 +} + +type ListItemNewResponse struct { + // The unique operation ID of the asynchronous action. + OperationID string `json:"operation_id"` + JSON listItemNewResponseJSON `json:"-"` +} + +// listItemNewResponseJSON contains the JSON metadata for the struct +// [ListItemNewResponse] +type listItemNewResponseJSON struct { + OperationID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemNewResponseJSON) RawJSON() string { + return r.raw +} + +type ListItemUpdateResponse struct { + // The unique operation ID of the asynchronous action. + OperationID string `json:"operation_id"` + JSON listItemUpdateResponseJSON `json:"-"` +} + +// listItemUpdateResponseJSON contains the JSON metadata for the struct +// [ListItemUpdateResponse] +type listItemUpdateResponseJSON struct { + OperationID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemUpdateResponseJSON) RawJSON() string { + return r.raw +} + +type ListItemListResponse = interface{} + +type ListItemDeleteResponse struct { + // The unique operation ID of the asynchronous action. + OperationID string `json:"operation_id"` + JSON listItemDeleteResponseJSON `json:"-"` +} + +// listItemDeleteResponseJSON contains the JSON metadata for the struct +// [ListItemDeleteResponse] +type listItemDeleteResponseJSON struct { + OperationID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemDeleteResponseJSON) RawJSON() string { + return r.raw +} + +// An IPv4 address, an IPv4 CIDR, or an IPv6 CIDR. IPv6 CIDRs are limited to a +// maximum of /64. +// +// Union satisfied by [shared.UnionString], +// [rules.ListItemGetResponseListsItemRedirect], +// [rules.ListItemGetResponseListsItemHostname] or [shared.UnionInt]. +type ListItemGetResponse interface { + ImplementsRulesListItemGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ListItemGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ListItemGetResponseListsItemRedirect{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ListItemGetResponseListsItemHostname{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionInt(0)), + }, + ) +} + +// The definition of the redirect. +type ListItemGetResponseListsItemRedirect 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 ListItemGetResponseListsItemRedirectStatusCode `json:"status_code"` + SubpathMatching bool `json:"subpath_matching"` + JSON listItemGetResponseListsItemRedirectJSON `json:"-"` +} + +// listItemGetResponseListsItemRedirectJSON contains the JSON metadata for the +// struct [ListItemGetResponseListsItemRedirect] +type listItemGetResponseListsItemRedirectJSON 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 *ListItemGetResponseListsItemRedirect) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemGetResponseListsItemRedirectJSON) RawJSON() string { + return r.raw +} + +func (r ListItemGetResponseListsItemRedirect) ImplementsRulesListItemGetResponse() {} + +type ListItemGetResponseListsItemRedirectStatusCode int64 + +const ( + ListItemGetResponseListsItemRedirectStatusCode301 ListItemGetResponseListsItemRedirectStatusCode = 301 + ListItemGetResponseListsItemRedirectStatusCode302 ListItemGetResponseListsItemRedirectStatusCode = 302 + ListItemGetResponseListsItemRedirectStatusCode307 ListItemGetResponseListsItemRedirectStatusCode = 307 + ListItemGetResponseListsItemRedirectStatusCode308 ListItemGetResponseListsItemRedirectStatusCode = 308 +) + +// Valid characters for hostnames are ASCII(7) letters from a to z, the digits from +// 0 to 9, wildcards (\*), and the hyphen (-). +type ListItemGetResponseListsItemHostname struct { + URLHostname string `json:"url_hostname,required"` + JSON listItemGetResponseListsItemHostnameJSON `json:"-"` +} + +// listItemGetResponseListsItemHostnameJSON contains the JSON metadata for the +// struct [ListItemGetResponseListsItemHostname] +type listItemGetResponseListsItemHostnameJSON struct { + URLHostname apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemGetResponseListsItemHostname) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemGetResponseListsItemHostnameJSON) RawJSON() string { + return r.raw +} + +func (r ListItemGetResponseListsItemHostname) ImplementsRulesListItemGetResponse() {} + +type ListItemNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Body param.Field[[]ListItemNewParamsBody] `json:"body,required"` +} + +func (r ListItemNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type ListItemNewParamsBody 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[ListItemNewParamsBodyHostname] `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[ListItemNewParamsBodyRedirect] `json:"redirect"` +} + +func (r ListItemNewParamsBody) 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 ListItemNewParamsBodyHostname struct { + URLHostname param.Field[string] `json:"url_hostname,required"` +} + +func (r ListItemNewParamsBodyHostname) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The definition of the redirect. +type ListItemNewParamsBodyRedirect 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[ListItemNewParamsBodyRedirectStatusCode] `json:"status_code"` + SubpathMatching param.Field[bool] `json:"subpath_matching"` +} + +func (r ListItemNewParamsBodyRedirect) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ListItemNewParamsBodyRedirectStatusCode int64 + +const ( + ListItemNewParamsBodyRedirectStatusCode301 ListItemNewParamsBodyRedirectStatusCode = 301 + ListItemNewParamsBodyRedirectStatusCode302 ListItemNewParamsBodyRedirectStatusCode = 302 + ListItemNewParamsBodyRedirectStatusCode307 ListItemNewParamsBodyRedirectStatusCode = 307 + ListItemNewParamsBodyRedirectStatusCode308 ListItemNewParamsBodyRedirectStatusCode = 308 +) + +type ListItemNewResponseEnvelope struct { + Errors []ListItemNewResponseEnvelopeErrors `json:"errors,required"` + Messages []ListItemNewResponseEnvelopeMessages `json:"messages,required"` + Result ListItemNewResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ListItemNewResponseEnvelopeSuccess `json:"success,required"` + JSON listItemNewResponseEnvelopeJSON `json:"-"` +} + +// listItemNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [ListItemNewResponseEnvelope] +type listItemNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ListItemNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listItemNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// listItemNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ListItemNewResponseEnvelopeErrors] +type listItemNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ListItemNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listItemNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// listItemNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ListItemNewResponseEnvelopeMessages] +type listItemNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ListItemNewResponseEnvelopeSuccess bool + +const ( + ListItemNewResponseEnvelopeSuccessTrue ListItemNewResponseEnvelopeSuccess = true +) + +type ListItemUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Body param.Field[[]ListItemUpdateParamsBody] `json:"body,required"` +} + +func (r ListItemUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type ListItemUpdateParamsBody 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[ListItemUpdateParamsBodyHostname] `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[ListItemUpdateParamsBodyRedirect] `json:"redirect"` +} + +func (r ListItemUpdateParamsBody) 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 ListItemUpdateParamsBodyHostname struct { + URLHostname param.Field[string] `json:"url_hostname,required"` +} + +func (r ListItemUpdateParamsBodyHostname) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The definition of the redirect. +type ListItemUpdateParamsBodyRedirect 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[ListItemUpdateParamsBodyRedirectStatusCode] `json:"status_code"` + SubpathMatching param.Field[bool] `json:"subpath_matching"` +} + +func (r ListItemUpdateParamsBodyRedirect) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ListItemUpdateParamsBodyRedirectStatusCode int64 + +const ( + ListItemUpdateParamsBodyRedirectStatusCode301 ListItemUpdateParamsBodyRedirectStatusCode = 301 + ListItemUpdateParamsBodyRedirectStatusCode302 ListItemUpdateParamsBodyRedirectStatusCode = 302 + ListItemUpdateParamsBodyRedirectStatusCode307 ListItemUpdateParamsBodyRedirectStatusCode = 307 + ListItemUpdateParamsBodyRedirectStatusCode308 ListItemUpdateParamsBodyRedirectStatusCode = 308 +) + +type ListItemUpdateResponseEnvelope struct { + Errors []ListItemUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []ListItemUpdateResponseEnvelopeMessages `json:"messages,required"` + Result ListItemUpdateResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ListItemUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON listItemUpdateResponseEnvelopeJSON `json:"-"` +} + +// listItemUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [ListItemUpdateResponseEnvelope] +type listItemUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ListItemUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listItemUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// listItemUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ListItemUpdateResponseEnvelopeErrors] +type listItemUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ListItemUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listItemUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// listItemUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ListItemUpdateResponseEnvelopeMessages] +type listItemUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ListItemUpdateResponseEnvelopeSuccess bool + +const ( + ListItemUpdateResponseEnvelopeSuccessTrue ListItemUpdateResponseEnvelopeSuccess = true +) + +type ListItemListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // 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 [ListItemListParams]'s query parameters as `url.Values`. +func (r ListItemListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type ListItemListResponseEnvelope struct { + Errors []ListItemListResponseEnvelopeErrors `json:"errors,required"` + Messages []ListItemListResponseEnvelopeMessages `json:"messages,required"` + Result []ListItemListResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ListItemListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo ListItemListResponseEnvelopeResultInfo `json:"result_info"` + JSON listItemListResponseEnvelopeJSON `json:"-"` +} + +// listItemListResponseEnvelopeJSON contains the JSON metadata for the struct +// [ListItemListResponseEnvelope] +type listItemListResponseEnvelopeJSON 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 *ListItemListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ListItemListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listItemListResponseEnvelopeErrorsJSON `json:"-"` +} + +// listItemListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ListItemListResponseEnvelopeErrors] +type listItemListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ListItemListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listItemListResponseEnvelopeMessagesJSON `json:"-"` +} + +// listItemListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ListItemListResponseEnvelopeMessages] +type listItemListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ListItemListResponseEnvelopeSuccess bool + +const ( + ListItemListResponseEnvelopeSuccessTrue ListItemListResponseEnvelopeSuccess = true +) + +type ListItemListResponseEnvelopeResultInfo struct { + Cursors ListItemListResponseEnvelopeResultInfoCursors `json:"cursors"` + JSON listItemListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// listItemListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [ListItemListResponseEnvelopeResultInfo] +type listItemListResponseEnvelopeResultInfoJSON struct { + Cursors apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type ListItemListResponseEnvelopeResultInfoCursors struct { + After string `json:"after"` + Before string `json:"before"` + JSON listItemListResponseEnvelopeResultInfoCursorsJSON `json:"-"` +} + +// listItemListResponseEnvelopeResultInfoCursorsJSON contains the JSON metadata for +// the struct [ListItemListResponseEnvelopeResultInfoCursors] +type listItemListResponseEnvelopeResultInfoCursorsJSON struct { + After apijson.Field + Before apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemListResponseEnvelopeResultInfoCursors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemListResponseEnvelopeResultInfoCursorsJSON) RawJSON() string { + return r.raw +} + +type ListItemDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Items param.Field[[]ListItemDeleteParamsItem] `json:"items"` +} + +func (r ListItemDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ListItemDeleteParamsItem struct { + // The unique ID of the item in the List. + ID param.Field[string] `json:"id"` +} + +func (r ListItemDeleteParamsItem) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ListItemDeleteResponseEnvelope struct { + Errors []ListItemDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []ListItemDeleteResponseEnvelopeMessages `json:"messages,required"` + Result ListItemDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ListItemDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON listItemDeleteResponseEnvelopeJSON `json:"-"` +} + +// listItemDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [ListItemDeleteResponseEnvelope] +type listItemDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ListItemDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listItemDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// listItemDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ListItemDeleteResponseEnvelopeErrors] +type listItemDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ListItemDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listItemDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// listItemDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ListItemDeleteResponseEnvelopeMessages] +type listItemDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ListItemDeleteResponseEnvelopeSuccess bool + +const ( + ListItemDeleteResponseEnvelopeSuccessTrue ListItemDeleteResponseEnvelopeSuccess = true +) + +type ListItemGetResponseEnvelope struct { + Errors []ListItemGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ListItemGetResponseEnvelopeMessages `json:"messages,required"` + // An IPv4 address, an IPv4 CIDR, or an IPv6 CIDR. IPv6 CIDRs are limited to a + // maximum of /64. + Result ListItemGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success ListItemGetResponseEnvelopeSuccess `json:"success,required"` + JSON listItemGetResponseEnvelopeJSON `json:"-"` +} + +// listItemGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [ListItemGetResponseEnvelope] +type listItemGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ListItemGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listItemGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// listItemGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ListItemGetResponseEnvelopeErrors] +type listItemGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ListItemGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON listItemGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// listItemGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ListItemGetResponseEnvelopeMessages] +type listItemGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ListItemGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r listItemGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ListItemGetResponseEnvelopeSuccess bool + +const ( + ListItemGetResponseEnvelopeSuccessTrue ListItemGetResponseEnvelopeSuccess = true +) diff --git a/rules/listitem_test.go b/rules/listitem_test.go new file mode 100644 index 00000000000..20d394a4901 --- /dev/null +++ b/rules/listitem_test.go @@ -0,0 +1,268 @@ +// File generated from our OpenAPI spec by Stainless. + +package rules_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/rules" +) + +func TestListItemNew(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("user@example.com"), + ) + _, err := client.Rules.Lists.Items.New( + context.TODO(), + "2c0fc9fa937b11eaa1b71c4d701ab86e", + rules.ListItemNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: cloudflare.F([]rules.ListItemNewParamsBody{{ + ASN: cloudflare.F(int64(5567)), + Comment: cloudflare.F("Private IP address"), + Hostname: cloudflare.F(rules.ListItemNewParamsBodyHostname{ + URLHostname: cloudflare.F("example.com"), + }), + IP: cloudflare.F("10.0.0.1"), + Redirect: cloudflare.F(rules.ListItemNewParamsBodyRedirect{ + IncludeSubdomains: cloudflare.F(true), + PreservePathSuffix: cloudflare.F(true), + PreserveQueryString: cloudflare.F(true), + SourceURL: cloudflare.F("example.com/arch"), + StatusCode: cloudflare.F(rules.ListItemNewParamsBodyRedirectStatusCode301), + SubpathMatching: cloudflare.F(true), + TargetURL: cloudflare.F("https://archlinux.org/"), + }), + }, { + ASN: cloudflare.F(int64(5567)), + Comment: cloudflare.F("Private IP address"), + Hostname: cloudflare.F(rules.ListItemNewParamsBodyHostname{ + URLHostname: cloudflare.F("example.com"), + }), + IP: cloudflare.F("10.0.0.1"), + Redirect: cloudflare.F(rules.ListItemNewParamsBodyRedirect{ + IncludeSubdomains: cloudflare.F(true), + PreservePathSuffix: cloudflare.F(true), + PreserveQueryString: cloudflare.F(true), + SourceURL: cloudflare.F("example.com/arch"), + StatusCode: cloudflare.F(rules.ListItemNewParamsBodyRedirectStatusCode301), + SubpathMatching: cloudflare.F(true), + TargetURL: cloudflare.F("https://archlinux.org/"), + }), + }, { + ASN: cloudflare.F(int64(5567)), + Comment: cloudflare.F("Private IP address"), + Hostname: cloudflare.F(rules.ListItemNewParamsBodyHostname{ + URLHostname: cloudflare.F("example.com"), + }), + IP: cloudflare.F("10.0.0.1"), + Redirect: cloudflare.F(rules.ListItemNewParamsBodyRedirect{ + IncludeSubdomains: cloudflare.F(true), + PreservePathSuffix: cloudflare.F(true), + PreserveQueryString: cloudflare.F(true), + SourceURL: cloudflare.F("example.com/arch"), + StatusCode: cloudflare.F(rules.ListItemNewParamsBodyRedirectStatusCode301), + 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 TestListItemUpdate(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("user@example.com"), + ) + _, err := client.Rules.Lists.Items.Update( + context.TODO(), + "2c0fc9fa937b11eaa1b71c4d701ab86e", + rules.ListItemUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: cloudflare.F([]rules.ListItemUpdateParamsBody{{ + ASN: cloudflare.F(int64(5567)), + Comment: cloudflare.F("Private IP address"), + Hostname: cloudflare.F(rules.ListItemUpdateParamsBodyHostname{ + URLHostname: cloudflare.F("example.com"), + }), + IP: cloudflare.F("10.0.0.1"), + Redirect: cloudflare.F(rules.ListItemUpdateParamsBodyRedirect{ + IncludeSubdomains: cloudflare.F(true), + PreservePathSuffix: cloudflare.F(true), + PreserveQueryString: cloudflare.F(true), + SourceURL: cloudflare.F("example.com/arch"), + StatusCode: cloudflare.F(rules.ListItemUpdateParamsBodyRedirectStatusCode301), + SubpathMatching: cloudflare.F(true), + TargetURL: cloudflare.F("https://archlinux.org/"), + }), + }, { + ASN: cloudflare.F(int64(5567)), + Comment: cloudflare.F("Private IP address"), + Hostname: cloudflare.F(rules.ListItemUpdateParamsBodyHostname{ + URLHostname: cloudflare.F("example.com"), + }), + IP: cloudflare.F("10.0.0.1"), + Redirect: cloudflare.F(rules.ListItemUpdateParamsBodyRedirect{ + IncludeSubdomains: cloudflare.F(true), + PreservePathSuffix: cloudflare.F(true), + PreserveQueryString: cloudflare.F(true), + SourceURL: cloudflare.F("example.com/arch"), + StatusCode: cloudflare.F(rules.ListItemUpdateParamsBodyRedirectStatusCode301), + SubpathMatching: cloudflare.F(true), + TargetURL: cloudflare.F("https://archlinux.org/"), + }), + }, { + ASN: cloudflare.F(int64(5567)), + Comment: cloudflare.F("Private IP address"), + Hostname: cloudflare.F(rules.ListItemUpdateParamsBodyHostname{ + URLHostname: cloudflare.F("example.com"), + }), + IP: cloudflare.F("10.0.0.1"), + Redirect: cloudflare.F(rules.ListItemUpdateParamsBodyRedirect{ + IncludeSubdomains: cloudflare.F(true), + PreservePathSuffix: cloudflare.F(true), + PreserveQueryString: cloudflare.F(true), + SourceURL: cloudflare.F("example.com/arch"), + StatusCode: cloudflare.F(rules.ListItemUpdateParamsBodyRedirectStatusCode301), + 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 TestListItemListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Rules.Lists.Items.List( + context.TODO(), + "2c0fc9fa937b11eaa1b71c4d701ab86e", + rules.ListItemListParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + 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 TestListItemDeleteWithOptionalParams(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("user@example.com"), + ) + _, err := client.Rules.Lists.Items.Delete( + context.TODO(), + "2c0fc9fa937b11eaa1b71c4d701ab86e", + rules.ListItemDeleteParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Items: cloudflare.F([]rules.ListItemDeleteParamsItem{{ + 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 TestListItemGet(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("user@example.com"), + ) + _, 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()) + } +} diff --git a/rules/rule.go b/rules/rule.go new file mode 100644 index 00000000000..42b21d23589 --- /dev/null +++ b/rules/rule.go @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package rules + +import ( + "github.com/cloudflare/cloudflare-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 *ListService +} + +// 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 = NewListService(opts...) + return +} diff --git a/ruleset.go b/ruleset.go deleted file mode 100644 index 28067313dfe..00000000000 --- a/ruleset.go +++ /dev/null @@ -1,4082 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// RulesetService 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 [NewRulesetService] method instead. -type RulesetService struct { - Options []option.RequestOption - Phases *RulesetPhaseService - Rules *RulesetRuleService - Versions *RulesetVersionService -} - -// NewRulesetService 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 NewRulesetService(opts ...option.RequestOption) (r *RulesetService) { - r = &RulesetService{} - r.Options = opts - r.Phases = NewRulesetPhaseService(opts...) - r.Rules = NewRulesetRuleService(opts...) - r.Versions = NewRulesetVersionService(opts...) - return -} - -// Creates a ruleset. -func (r *RulesetService) New(ctx context.Context, params RulesetNewParams, opts ...option.RequestOption) (res *RulesetNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env RulesetNewResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/rulesets", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates an account or zone ruleset, creating a new version. -func (r *RulesetService) Update(ctx context.Context, rulesetID string, params RulesetUpdateParams, opts ...option.RequestOption) (res *RulesetUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env RulesetUpdateResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/rulesets/%s", accountOrZone, accountOrZoneID, rulesetID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches all rulesets. -func (r *RulesetService) List(ctx context.Context, query RulesetListParams, opts ...option.RequestOption) (res *[]RulesetListResponse, err error) { - opts = append(r.Options[:], opts...) - var env RulesetListResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/rulesets", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes all versions of an existing account or zone ruleset. -func (r *RulesetService) Delete(ctx context.Context, rulesetID string, body RulesetDeleteParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - var accountOrZone string - var accountOrZoneID param.Field[string] - if body.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = body.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = body.ZoneID - } - path := fmt.Sprintf("%s/%s/rulesets/%s", accountOrZone, accountOrZoneID, rulesetID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) - return -} - -// Fetches the latest version of an account or zone ruleset. -func (r *RulesetService) Get(ctx context.Context, rulesetID string, query RulesetGetParams, opts ...option.RequestOption) (res *RulesetGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RulesetGetResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/rulesets/%s", accountOrZone, accountOrZoneID, rulesetID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// A result. -type RulesetNewResponse struct { - // The unique ID of the ruleset. - ID string `json:"id,required"` - // The kind of the ruleset. - Kind RulesetNewResponseKind `json:"kind,required"` - // The timestamp of when the ruleset was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The human-readable name of the ruleset. - Name string `json:"name,required"` - // The phase of the ruleset. - Phase RulesetNewResponsePhase `json:"phase,required"` - // The list of rules in the ruleset. - Rules []RulesetNewResponseRule `json:"rules,required"` - // The version of the ruleset. - Version string `json:"version,required"` - // An informative description of the ruleset. - Description string `json:"description"` - JSON rulesetNewResponseJSON `json:"-"` -} - -// rulesetNewResponseJSON contains the JSON metadata for the struct -// [RulesetNewResponse] -type rulesetNewResponseJSON struct { - ID apijson.Field - Kind apijson.Field - LastUpdated apijson.Field - Name apijson.Field - Phase apijson.Field - Rules apijson.Field - Version apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseJSON) RawJSON() string { - return r.raw -} - -// The kind of the ruleset. -type RulesetNewResponseKind string - -const ( - RulesetNewResponseKindManaged RulesetNewResponseKind = "managed" - RulesetNewResponseKindCustom RulesetNewResponseKind = "custom" - RulesetNewResponseKindRoot RulesetNewResponseKind = "root" - RulesetNewResponseKindZone RulesetNewResponseKind = "zone" -) - -// The phase of the ruleset. -type RulesetNewResponsePhase string - -const ( - RulesetNewResponsePhaseDDOSL4 RulesetNewResponsePhase = "ddos_l4" - RulesetNewResponsePhaseDDOSL7 RulesetNewResponsePhase = "ddos_l7" - RulesetNewResponsePhaseHTTPConfigSettings RulesetNewResponsePhase = "http_config_settings" - RulesetNewResponsePhaseHTTPCustomErrors RulesetNewResponsePhase = "http_custom_errors" - RulesetNewResponsePhaseHTTPLogCustomFields RulesetNewResponsePhase = "http_log_custom_fields" - RulesetNewResponsePhaseHTTPRatelimit RulesetNewResponsePhase = "http_ratelimit" - RulesetNewResponsePhaseHTTPRequestCacheSettings RulesetNewResponsePhase = "http_request_cache_settings" - RulesetNewResponsePhaseHTTPRequestDynamicRedirect RulesetNewResponsePhase = "http_request_dynamic_redirect" - RulesetNewResponsePhaseHTTPRequestFirewallCustom RulesetNewResponsePhase = "http_request_firewall_custom" - RulesetNewResponsePhaseHTTPRequestFirewallManaged RulesetNewResponsePhase = "http_request_firewall_managed" - RulesetNewResponsePhaseHTTPRequestLateTransform RulesetNewResponsePhase = "http_request_late_transform" - RulesetNewResponsePhaseHTTPRequestOrigin RulesetNewResponsePhase = "http_request_origin" - RulesetNewResponsePhaseHTTPRequestRedirect RulesetNewResponsePhase = "http_request_redirect" - RulesetNewResponsePhaseHTTPRequestSanitize RulesetNewResponsePhase = "http_request_sanitize" - RulesetNewResponsePhaseHTTPRequestSbfm RulesetNewResponsePhase = "http_request_sbfm" - RulesetNewResponsePhaseHTTPRequestSelectConfiguration RulesetNewResponsePhase = "http_request_select_configuration" - RulesetNewResponsePhaseHTTPRequestTransform RulesetNewResponsePhase = "http_request_transform" - RulesetNewResponsePhaseHTTPResponseCompression RulesetNewResponsePhase = "http_response_compression" - RulesetNewResponsePhaseHTTPResponseFirewallManaged RulesetNewResponsePhase = "http_response_firewall_managed" - RulesetNewResponsePhaseHTTPResponseHeadersTransform RulesetNewResponsePhase = "http_response_headers_transform" - RulesetNewResponsePhaseMagicTransit RulesetNewResponsePhase = "magic_transit" - RulesetNewResponsePhaseMagicTransitIDsManaged RulesetNewResponsePhase = "magic_transit_ids_managed" - RulesetNewResponsePhaseMagicTransitManaged RulesetNewResponsePhase = "magic_transit_managed" -) - -// Union satisfied by [RulesetNewResponseRulesRulesetsBlockRule], -// [RulesetNewResponseRulesRulesetsExecuteRule], -// [RulesetNewResponseRulesRulesetsLogRule] or -// [RulesetNewResponseRulesRulesetsSkipRule]. -type RulesetNewResponseRule interface { - implementsRulesetNewResponseRule() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*RulesetNewResponseRule)(nil)).Elem(), - "action", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetNewResponseRulesRulesetsBlockRule{}), - DiscriminatorValue: "block", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetNewResponseRulesRulesetsExecuteRule{}), - DiscriminatorValue: "execute", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetNewResponseRulesRulesetsLogRule{}), - DiscriminatorValue: "log", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetNewResponseRulesRulesetsSkipRule{}), - DiscriminatorValue: "skip", - }, - ) -} - -type RulesetNewResponseRulesRulesetsBlockRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetNewResponseRulesRulesetsBlockRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetNewResponseRulesRulesetsBlockRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetNewResponseRulesRulesetsBlockRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetNewResponseRulesRulesetsBlockRuleJSON `json:"-"` -} - -// rulesetNewResponseRulesRulesetsBlockRuleJSON contains the JSON metadata for the -// struct [RulesetNewResponseRulesRulesetsBlockRule] -type rulesetNewResponseRulesRulesetsBlockRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseRulesRulesetsBlockRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseRulesRulesetsBlockRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetNewResponseRulesRulesetsBlockRule) implementsRulesetNewResponseRule() {} - -// The action to perform when the rule matches. -type RulesetNewResponseRulesRulesetsBlockRuleAction string - -const ( - RulesetNewResponseRulesRulesetsBlockRuleActionBlock RulesetNewResponseRulesRulesetsBlockRuleAction = "block" -) - -// The parameters configuring the rule's action. -type RulesetNewResponseRulesRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response RulesetNewResponseRulesRulesetsBlockRuleActionParametersResponse `json:"response"` - JSON rulesetNewResponseRulesRulesetsBlockRuleActionParametersJSON `json:"-"` -} - -// rulesetNewResponseRulesRulesetsBlockRuleActionParametersJSON contains the JSON -// metadata for the struct -// [RulesetNewResponseRulesRulesetsBlockRuleActionParameters] -type rulesetNewResponseRulesRulesetsBlockRuleActionParametersJSON struct { - Response apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseRulesRulesetsBlockRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseRulesRulesetsBlockRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The response to show when the block is applied. -type RulesetNewResponseRulesRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content string `json:"content,required"` - // The type of the content to return. - ContentType string `json:"content_type,required"` - // The status code to return. - StatusCode int64 `json:"status_code,required"` - JSON rulesetNewResponseRulesRulesetsBlockRuleActionParametersResponseJSON `json:"-"` -} - -// rulesetNewResponseRulesRulesetsBlockRuleActionParametersResponseJSON contains -// the JSON metadata for the struct -// [RulesetNewResponseRulesRulesetsBlockRuleActionParametersResponse] -type rulesetNewResponseRulesRulesetsBlockRuleActionParametersResponseJSON struct { - Content apijson.Field - ContentType apijson.Field - StatusCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseRulesRulesetsBlockRuleActionParametersResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseRulesRulesetsBlockRuleActionParametersResponseJSON) RawJSON() string { - return r.raw -} - -// An object configuring the rule's logging behavior. -type RulesetNewResponseRulesRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetNewResponseRulesRulesetsBlockRuleLoggingJSON `json:"-"` -} - -// rulesetNewResponseRulesRulesetsBlockRuleLoggingJSON contains the JSON metadata -// for the struct [RulesetNewResponseRulesRulesetsBlockRuleLogging] -type rulesetNewResponseRulesRulesetsBlockRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseRulesRulesetsBlockRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseRulesRulesetsBlockRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetNewResponseRulesRulesetsExecuteRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetNewResponseRulesRulesetsExecuteRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetNewResponseRulesRulesetsExecuteRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetNewResponseRulesRulesetsExecuteRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetNewResponseRulesRulesetsExecuteRuleJSON `json:"-"` -} - -// rulesetNewResponseRulesRulesetsExecuteRuleJSON contains the JSON metadata for -// the struct [RulesetNewResponseRulesRulesetsExecuteRule] -type rulesetNewResponseRulesRulesetsExecuteRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseRulesRulesetsExecuteRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseRulesRulesetsExecuteRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetNewResponseRulesRulesetsExecuteRule) implementsRulesetNewResponseRule() {} - -// The action to perform when the rule matches. -type RulesetNewResponseRulesRulesetsExecuteRuleAction string - -const ( - RulesetNewResponseRulesRulesetsExecuteRuleActionExecute RulesetNewResponseRulesRulesetsExecuteRuleAction = "execute" -) - -// The parameters configuring the rule's action. -type RulesetNewResponseRulesRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID string `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData RulesetNewResponseRulesRulesetsExecuteRuleActionParametersMatchedData `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverrides `json:"overrides"` - JSON rulesetNewResponseRulesRulesetsExecuteRuleActionParametersJSON `json:"-"` -} - -// rulesetNewResponseRulesRulesetsExecuteRuleActionParametersJSON contains the JSON -// metadata for the struct -// [RulesetNewResponseRulesRulesetsExecuteRuleActionParameters] -type rulesetNewResponseRulesRulesetsExecuteRuleActionParametersJSON struct { - ID apijson.Field - MatchedData apijson.Field - Overrides apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseRulesRulesetsExecuteRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseRulesRulesetsExecuteRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The configuration to use for matched data logging. -type RulesetNewResponseRulesRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey string `json:"public_key,required"` - JSON rulesetNewResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON `json:"-"` -} - -// rulesetNewResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON -// contains the JSON metadata for the struct -// [RulesetNewResponseRulesRulesetsExecuteRuleActionParametersMatchedData] -type rulesetNewResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON struct { - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseRulesRulesetsExecuteRuleActionParametersMatchedData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON) RawJSON() string { - return r.raw -} - -// A set of overrides to apply to the target ruleset. -type RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action string `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories []RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled bool `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules []RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRule `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON `json:"-"` -} - -// rulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON contains -// the JSON metadata for the struct -// [RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverrides] -type rulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON struct { - Action apijson.Field - Categories apijson.Field - Enabled apijson.Field - Rules apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverrides) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON) RawJSON() string { - return r.raw -} - -// A category-level override -type RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category string `json:"category,required"` - // The action to override rules in the category with. - Action string `json:"action"` - // Whether to enable execution of rules in the category. - Enabled bool `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON `json:"-"` -} - -// rulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON -// contains the JSON metadata for the struct -// [RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory] -type rulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON struct { - Category apijson.Field - Action apijson.Field - Enabled apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for rules in the category. -type RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string - -const ( - RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" -) - -// A rule-level override -type RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID string `json:"id,required"` - // The action to override the rule with. - Action string `json:"action"` - // Whether to enable execution of the rule. - Enabled bool `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold int64 `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON `json:"-"` -} - -// rulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON -// contains the JSON metadata for the struct -// [RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRule] -type rulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON struct { - ID apijson.Field - Action apijson.Field - Enabled apijson.Field - ScoreThreshold apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for the rule. -type RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string - -const ( - RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" -) - -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string - -const ( - RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" -) - -// An object configuring the rule's logging behavior. -type RulesetNewResponseRulesRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetNewResponseRulesRulesetsExecuteRuleLoggingJSON `json:"-"` -} - -// rulesetNewResponseRulesRulesetsExecuteRuleLoggingJSON contains the JSON metadata -// for the struct [RulesetNewResponseRulesRulesetsExecuteRuleLogging] -type rulesetNewResponseRulesRulesetsExecuteRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseRulesRulesetsExecuteRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseRulesRulesetsExecuteRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetNewResponseRulesRulesetsLogRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetNewResponseRulesRulesetsLogRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters interface{} `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetNewResponseRulesRulesetsLogRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetNewResponseRulesRulesetsLogRuleJSON `json:"-"` -} - -// rulesetNewResponseRulesRulesetsLogRuleJSON contains the JSON metadata for the -// struct [RulesetNewResponseRulesRulesetsLogRule] -type rulesetNewResponseRulesRulesetsLogRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseRulesRulesetsLogRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseRulesRulesetsLogRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetNewResponseRulesRulesetsLogRule) implementsRulesetNewResponseRule() {} - -// The action to perform when the rule matches. -type RulesetNewResponseRulesRulesetsLogRuleAction string - -const ( - RulesetNewResponseRulesRulesetsLogRuleActionLog RulesetNewResponseRulesRulesetsLogRuleAction = "log" -) - -// An object configuring the rule's logging behavior. -type RulesetNewResponseRulesRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetNewResponseRulesRulesetsLogRuleLoggingJSON `json:"-"` -} - -// rulesetNewResponseRulesRulesetsLogRuleLoggingJSON contains the JSON metadata for -// the struct [RulesetNewResponseRulesRulesetsLogRuleLogging] -type rulesetNewResponseRulesRulesetsLogRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseRulesRulesetsLogRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseRulesRulesetsLogRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetNewResponseRulesRulesetsSkipRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetNewResponseRulesRulesetsSkipRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetNewResponseRulesRulesetsSkipRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetNewResponseRulesRulesetsSkipRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetNewResponseRulesRulesetsSkipRuleJSON `json:"-"` -} - -// rulesetNewResponseRulesRulesetsSkipRuleJSON contains the JSON metadata for the -// struct [RulesetNewResponseRulesRulesetsSkipRule] -type rulesetNewResponseRulesRulesetsSkipRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseRulesRulesetsSkipRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseRulesRulesetsSkipRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetNewResponseRulesRulesetsSkipRule) implementsRulesetNewResponseRule() {} - -// The action to perform when the rule matches. -type RulesetNewResponseRulesRulesetsSkipRuleAction string - -const ( - RulesetNewResponseRulesRulesetsSkipRuleActionSkip RulesetNewResponseRulesRulesetsSkipRuleAction = "skip" -) - -// The parameters configuring the rule's action. -type RulesetNewResponseRulesRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases []RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase `json:"phases"` - // A list of legacy security products to skip the execution of. - Products []RulesetNewResponseRulesRulesetsSkipRuleActionParametersProduct `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules map[string][]string `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset RulesetNewResponseRulesRulesetsSkipRuleActionParametersRuleset `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets []string `json:"rulesets"` - JSON rulesetNewResponseRulesRulesetsSkipRuleActionParametersJSON `json:"-"` -} - -// rulesetNewResponseRulesRulesetsSkipRuleActionParametersJSON contains the JSON -// metadata for the struct -// [RulesetNewResponseRulesRulesetsSkipRuleActionParameters] -type rulesetNewResponseRulesRulesetsSkipRuleActionParametersJSON struct { - Phases apijson.Field - Products apijson.Field - Rules apijson.Field - Ruleset apijson.Field - Rulesets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseRulesRulesetsSkipRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseRulesRulesetsSkipRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// A phase to skip the execution of. -type RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase string - -const ( - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL4 RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL7 RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetNewResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -// The name of a legacy security product to skip the execution of. -type RulesetNewResponseRulesRulesetsSkipRuleActionParametersProduct string - -const ( - RulesetNewResponseRulesRulesetsSkipRuleActionParametersProductBic RulesetNewResponseRulesRulesetsSkipRuleActionParametersProduct = "bic" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersProductHot RulesetNewResponseRulesRulesetsSkipRuleActionParametersProduct = "hot" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetNewResponseRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetNewResponseRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersProductUABlock RulesetNewResponseRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersProductWAF RulesetNewResponseRulesRulesetsSkipRuleActionParametersProduct = "waf" - RulesetNewResponseRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetNewResponseRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) - -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RulesetNewResponseRulesRulesetsSkipRuleActionParametersRuleset string - -const ( - RulesetNewResponseRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetNewResponseRulesRulesetsSkipRuleActionParametersRuleset = "current" -) - -// An object configuring the rule's logging behavior. -type RulesetNewResponseRulesRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetNewResponseRulesRulesetsSkipRuleLoggingJSON `json:"-"` -} - -// rulesetNewResponseRulesRulesetsSkipRuleLoggingJSON contains the JSON metadata -// for the struct [RulesetNewResponseRulesRulesetsSkipRuleLogging] -type rulesetNewResponseRulesRulesetsSkipRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseRulesRulesetsSkipRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseRulesRulesetsSkipRuleLoggingJSON) RawJSON() string { - return r.raw -} - -// A result. -type RulesetUpdateResponse struct { - // The unique ID of the ruleset. - ID string `json:"id,required"` - // The kind of the ruleset. - Kind RulesetUpdateResponseKind `json:"kind,required"` - // The timestamp of when the ruleset was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The human-readable name of the ruleset. - Name string `json:"name,required"` - // The phase of the ruleset. - Phase RulesetUpdateResponsePhase `json:"phase,required"` - // The list of rules in the ruleset. - Rules []RulesetUpdateResponseRule `json:"rules,required"` - // The version of the ruleset. - Version string `json:"version,required"` - // An informative description of the ruleset. - Description string `json:"description"` - JSON rulesetUpdateResponseJSON `json:"-"` -} - -// rulesetUpdateResponseJSON contains the JSON metadata for the struct -// [RulesetUpdateResponse] -type rulesetUpdateResponseJSON struct { - ID apijson.Field - Kind apijson.Field - LastUpdated apijson.Field - Name apijson.Field - Phase apijson.Field - Rules apijson.Field - Version apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// The kind of the ruleset. -type RulesetUpdateResponseKind string - -const ( - RulesetUpdateResponseKindManaged RulesetUpdateResponseKind = "managed" - RulesetUpdateResponseKindCustom RulesetUpdateResponseKind = "custom" - RulesetUpdateResponseKindRoot RulesetUpdateResponseKind = "root" - RulesetUpdateResponseKindZone RulesetUpdateResponseKind = "zone" -) - -// The phase of the ruleset. -type RulesetUpdateResponsePhase string - -const ( - RulesetUpdateResponsePhaseDDOSL4 RulesetUpdateResponsePhase = "ddos_l4" - RulesetUpdateResponsePhaseDDOSL7 RulesetUpdateResponsePhase = "ddos_l7" - RulesetUpdateResponsePhaseHTTPConfigSettings RulesetUpdateResponsePhase = "http_config_settings" - RulesetUpdateResponsePhaseHTTPCustomErrors RulesetUpdateResponsePhase = "http_custom_errors" - RulesetUpdateResponsePhaseHTTPLogCustomFields RulesetUpdateResponsePhase = "http_log_custom_fields" - RulesetUpdateResponsePhaseHTTPRatelimit RulesetUpdateResponsePhase = "http_ratelimit" - RulesetUpdateResponsePhaseHTTPRequestCacheSettings RulesetUpdateResponsePhase = "http_request_cache_settings" - RulesetUpdateResponsePhaseHTTPRequestDynamicRedirect RulesetUpdateResponsePhase = "http_request_dynamic_redirect" - RulesetUpdateResponsePhaseHTTPRequestFirewallCustom RulesetUpdateResponsePhase = "http_request_firewall_custom" - RulesetUpdateResponsePhaseHTTPRequestFirewallManaged RulesetUpdateResponsePhase = "http_request_firewall_managed" - RulesetUpdateResponsePhaseHTTPRequestLateTransform RulesetUpdateResponsePhase = "http_request_late_transform" - RulesetUpdateResponsePhaseHTTPRequestOrigin RulesetUpdateResponsePhase = "http_request_origin" - RulesetUpdateResponsePhaseHTTPRequestRedirect RulesetUpdateResponsePhase = "http_request_redirect" - RulesetUpdateResponsePhaseHTTPRequestSanitize RulesetUpdateResponsePhase = "http_request_sanitize" - RulesetUpdateResponsePhaseHTTPRequestSbfm RulesetUpdateResponsePhase = "http_request_sbfm" - RulesetUpdateResponsePhaseHTTPRequestSelectConfiguration RulesetUpdateResponsePhase = "http_request_select_configuration" - RulesetUpdateResponsePhaseHTTPRequestTransform RulesetUpdateResponsePhase = "http_request_transform" - RulesetUpdateResponsePhaseHTTPResponseCompression RulesetUpdateResponsePhase = "http_response_compression" - RulesetUpdateResponsePhaseHTTPResponseFirewallManaged RulesetUpdateResponsePhase = "http_response_firewall_managed" - RulesetUpdateResponsePhaseHTTPResponseHeadersTransform RulesetUpdateResponsePhase = "http_response_headers_transform" - RulesetUpdateResponsePhaseMagicTransit RulesetUpdateResponsePhase = "magic_transit" - RulesetUpdateResponsePhaseMagicTransitIDsManaged RulesetUpdateResponsePhase = "magic_transit_ids_managed" - RulesetUpdateResponsePhaseMagicTransitManaged RulesetUpdateResponsePhase = "magic_transit_managed" -) - -// Union satisfied by [RulesetUpdateResponseRulesRulesetsBlockRule], -// [RulesetUpdateResponseRulesRulesetsExecuteRule], -// [RulesetUpdateResponseRulesRulesetsLogRule] or -// [RulesetUpdateResponseRulesRulesetsSkipRule]. -type RulesetUpdateResponseRule interface { - implementsRulesetUpdateResponseRule() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*RulesetUpdateResponseRule)(nil)).Elem(), - "action", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetUpdateResponseRulesRulesetsBlockRule{}), - DiscriminatorValue: "block", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetUpdateResponseRulesRulesetsExecuteRule{}), - DiscriminatorValue: "execute", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetUpdateResponseRulesRulesetsLogRule{}), - DiscriminatorValue: "log", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetUpdateResponseRulesRulesetsSkipRule{}), - DiscriminatorValue: "skip", - }, - ) -} - -type RulesetUpdateResponseRulesRulesetsBlockRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetUpdateResponseRulesRulesetsBlockRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetUpdateResponseRulesRulesetsBlockRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetUpdateResponseRulesRulesetsBlockRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetUpdateResponseRulesRulesetsBlockRuleJSON `json:"-"` -} - -// rulesetUpdateResponseRulesRulesetsBlockRuleJSON contains the JSON metadata for -// the struct [RulesetUpdateResponseRulesRulesetsBlockRule] -type rulesetUpdateResponseRulesRulesetsBlockRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseRulesRulesetsBlockRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseRulesRulesetsBlockRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetUpdateResponseRulesRulesetsBlockRule) implementsRulesetUpdateResponseRule() {} - -// The action to perform when the rule matches. -type RulesetUpdateResponseRulesRulesetsBlockRuleAction string - -const ( - RulesetUpdateResponseRulesRulesetsBlockRuleActionBlock RulesetUpdateResponseRulesRulesetsBlockRuleAction = "block" -) - -// The parameters configuring the rule's action. -type RulesetUpdateResponseRulesRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response RulesetUpdateResponseRulesRulesetsBlockRuleActionParametersResponse `json:"response"` - JSON rulesetUpdateResponseRulesRulesetsBlockRuleActionParametersJSON `json:"-"` -} - -// rulesetUpdateResponseRulesRulesetsBlockRuleActionParametersJSON contains the -// JSON metadata for the struct -// [RulesetUpdateResponseRulesRulesetsBlockRuleActionParameters] -type rulesetUpdateResponseRulesRulesetsBlockRuleActionParametersJSON struct { - Response apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseRulesRulesetsBlockRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseRulesRulesetsBlockRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The response to show when the block is applied. -type RulesetUpdateResponseRulesRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content string `json:"content,required"` - // The type of the content to return. - ContentType string `json:"content_type,required"` - // The status code to return. - StatusCode int64 `json:"status_code,required"` - JSON rulesetUpdateResponseRulesRulesetsBlockRuleActionParametersResponseJSON `json:"-"` -} - -// rulesetUpdateResponseRulesRulesetsBlockRuleActionParametersResponseJSON contains -// the JSON metadata for the struct -// [RulesetUpdateResponseRulesRulesetsBlockRuleActionParametersResponse] -type rulesetUpdateResponseRulesRulesetsBlockRuleActionParametersResponseJSON struct { - Content apijson.Field - ContentType apijson.Field - StatusCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseRulesRulesetsBlockRuleActionParametersResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseRulesRulesetsBlockRuleActionParametersResponseJSON) RawJSON() string { - return r.raw -} - -// An object configuring the rule's logging behavior. -type RulesetUpdateResponseRulesRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetUpdateResponseRulesRulesetsBlockRuleLoggingJSON `json:"-"` -} - -// rulesetUpdateResponseRulesRulesetsBlockRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetUpdateResponseRulesRulesetsBlockRuleLogging] -type rulesetUpdateResponseRulesRulesetsBlockRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseRulesRulesetsBlockRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseRulesRulesetsBlockRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetUpdateResponseRulesRulesetsExecuteRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetUpdateResponseRulesRulesetsExecuteRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetUpdateResponseRulesRulesetsExecuteRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetUpdateResponseRulesRulesetsExecuteRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetUpdateResponseRulesRulesetsExecuteRuleJSON `json:"-"` -} - -// rulesetUpdateResponseRulesRulesetsExecuteRuleJSON contains the JSON metadata for -// the struct [RulesetUpdateResponseRulesRulesetsExecuteRule] -type rulesetUpdateResponseRulesRulesetsExecuteRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseRulesRulesetsExecuteRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseRulesRulesetsExecuteRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetUpdateResponseRulesRulesetsExecuteRule) implementsRulesetUpdateResponseRule() {} - -// The action to perform when the rule matches. -type RulesetUpdateResponseRulesRulesetsExecuteRuleAction string - -const ( - RulesetUpdateResponseRulesRulesetsExecuteRuleActionExecute RulesetUpdateResponseRulesRulesetsExecuteRuleAction = "execute" -) - -// The parameters configuring the rule's action. -type RulesetUpdateResponseRulesRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID string `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersMatchedData `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverrides `json:"overrides"` - JSON rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersJSON `json:"-"` -} - -// rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersJSON contains the -// JSON metadata for the struct -// [RulesetUpdateResponseRulesRulesetsExecuteRuleActionParameters] -type rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersJSON struct { - ID apijson.Field - MatchedData apijson.Field - Overrides apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseRulesRulesetsExecuteRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The configuration to use for matched data logging. -type RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey string `json:"public_key,required"` - JSON rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON `json:"-"` -} - -// rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON -// contains the JSON metadata for the struct -// [RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersMatchedData] -type rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON struct { - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersMatchedData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON) RawJSON() string { - return r.raw -} - -// A set of overrides to apply to the target ruleset. -type RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action string `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories []RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled bool `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules []RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRule `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON `json:"-"` -} - -// rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON -// contains the JSON metadata for the struct -// [RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverrides] -type rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON struct { - Action apijson.Field - Categories apijson.Field - Enabled apijson.Field - Rules apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverrides) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON) RawJSON() string { - return r.raw -} - -// A category-level override -type RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category string `json:"category,required"` - // The action to override rules in the category with. - Action string `json:"action"` - // Whether to enable execution of rules in the category. - Enabled bool `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON `json:"-"` -} - -// rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON -// contains the JSON metadata for the struct -// [RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory] -type rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON struct { - Category apijson.Field - Action apijson.Field - Enabled apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for rules in the category. -type RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string - -const ( - RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" -) - -// A rule-level override -type RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID string `json:"id,required"` - // The action to override the rule with. - Action string `json:"action"` - // Whether to enable execution of the rule. - Enabled bool `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold int64 `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON `json:"-"` -} - -// rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON -// contains the JSON metadata for the struct -// [RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRule] -type rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON struct { - ID apijson.Field - Action apijson.Field - Enabled apijson.Field - ScoreThreshold apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for the rule. -type RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string - -const ( - RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" -) - -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string - -const ( - RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" -) - -// An object configuring the rule's logging behavior. -type RulesetUpdateResponseRulesRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetUpdateResponseRulesRulesetsExecuteRuleLoggingJSON `json:"-"` -} - -// rulesetUpdateResponseRulesRulesetsExecuteRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetUpdateResponseRulesRulesetsExecuteRuleLogging] -type rulesetUpdateResponseRulesRulesetsExecuteRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseRulesRulesetsExecuteRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseRulesRulesetsExecuteRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetUpdateResponseRulesRulesetsLogRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetUpdateResponseRulesRulesetsLogRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters interface{} `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetUpdateResponseRulesRulesetsLogRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetUpdateResponseRulesRulesetsLogRuleJSON `json:"-"` -} - -// rulesetUpdateResponseRulesRulesetsLogRuleJSON contains the JSON metadata for the -// struct [RulesetUpdateResponseRulesRulesetsLogRule] -type rulesetUpdateResponseRulesRulesetsLogRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseRulesRulesetsLogRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseRulesRulesetsLogRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetUpdateResponseRulesRulesetsLogRule) implementsRulesetUpdateResponseRule() {} - -// The action to perform when the rule matches. -type RulesetUpdateResponseRulesRulesetsLogRuleAction string - -const ( - RulesetUpdateResponseRulesRulesetsLogRuleActionLog RulesetUpdateResponseRulesRulesetsLogRuleAction = "log" -) - -// An object configuring the rule's logging behavior. -type RulesetUpdateResponseRulesRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetUpdateResponseRulesRulesetsLogRuleLoggingJSON `json:"-"` -} - -// rulesetUpdateResponseRulesRulesetsLogRuleLoggingJSON contains the JSON metadata -// for the struct [RulesetUpdateResponseRulesRulesetsLogRuleLogging] -type rulesetUpdateResponseRulesRulesetsLogRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseRulesRulesetsLogRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseRulesRulesetsLogRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetUpdateResponseRulesRulesetsSkipRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetUpdateResponseRulesRulesetsSkipRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetUpdateResponseRulesRulesetsSkipRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetUpdateResponseRulesRulesetsSkipRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetUpdateResponseRulesRulesetsSkipRuleJSON `json:"-"` -} - -// rulesetUpdateResponseRulesRulesetsSkipRuleJSON contains the JSON metadata for -// the struct [RulesetUpdateResponseRulesRulesetsSkipRule] -type rulesetUpdateResponseRulesRulesetsSkipRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseRulesRulesetsSkipRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseRulesRulesetsSkipRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetUpdateResponseRulesRulesetsSkipRule) implementsRulesetUpdateResponseRule() {} - -// The action to perform when the rule matches. -type RulesetUpdateResponseRulesRulesetsSkipRuleAction string - -const ( - RulesetUpdateResponseRulesRulesetsSkipRuleActionSkip RulesetUpdateResponseRulesRulesetsSkipRuleAction = "skip" -) - -// The parameters configuring the rule's action. -type RulesetUpdateResponseRulesRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases []RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase `json:"phases"` - // A list of legacy security products to skip the execution of. - Products []RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersProduct `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules map[string][]string `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersRuleset `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets []string `json:"rulesets"` - JSON rulesetUpdateResponseRulesRulesetsSkipRuleActionParametersJSON `json:"-"` -} - -// rulesetUpdateResponseRulesRulesetsSkipRuleActionParametersJSON contains the JSON -// metadata for the struct -// [RulesetUpdateResponseRulesRulesetsSkipRuleActionParameters] -type rulesetUpdateResponseRulesRulesetsSkipRuleActionParametersJSON struct { - Phases apijson.Field - Products apijson.Field - Rules apijson.Field - Ruleset apijson.Field - Rulesets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseRulesRulesetsSkipRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseRulesRulesetsSkipRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// A phase to skip the execution of. -type RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase string - -const ( - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL4 RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL7 RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -// The name of a legacy security product to skip the execution of. -type RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersProduct string - -const ( - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersProductBic RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersProduct = "bic" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersProductHot RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersProduct = "hot" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersProductUABlock RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersProductWAF RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersProduct = "waf" - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) - -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersRuleset string - -const ( - RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetUpdateResponseRulesRulesetsSkipRuleActionParametersRuleset = "current" -) - -// An object configuring the rule's logging behavior. -type RulesetUpdateResponseRulesRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetUpdateResponseRulesRulesetsSkipRuleLoggingJSON `json:"-"` -} - -// rulesetUpdateResponseRulesRulesetsSkipRuleLoggingJSON contains the JSON metadata -// for the struct [RulesetUpdateResponseRulesRulesetsSkipRuleLogging] -type rulesetUpdateResponseRulesRulesetsSkipRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseRulesRulesetsSkipRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseRulesRulesetsSkipRuleLoggingJSON) RawJSON() string { - return r.raw -} - -// A ruleset object. -type RulesetListResponse struct { - // The kind of the ruleset. - Kind RulesetListResponseKind `json:"kind,required"` - // The human-readable name of the ruleset. - Name string `json:"name,required"` - // The phase of the ruleset. - Phase RulesetListResponsePhase `json:"phase,required"` - // The unique ID of the ruleset. - ID string `json:"id"` - // An informative description of the ruleset. - Description string `json:"description"` - // The timestamp of when the ruleset was last modified. - LastUpdated time.Time `json:"last_updated" format:"date-time"` - // The version of the ruleset. - Version string `json:"version"` - JSON rulesetListResponseJSON `json:"-"` -} - -// rulesetListResponseJSON contains the JSON metadata for the struct -// [RulesetListResponse] -type rulesetListResponseJSON struct { - Kind apijson.Field - Name apijson.Field - Phase apijson.Field - ID apijson.Field - Description apijson.Field - LastUpdated apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetListResponseJSON) RawJSON() string { - return r.raw -} - -// The kind of the ruleset. -type RulesetListResponseKind string - -const ( - RulesetListResponseKindManaged RulesetListResponseKind = "managed" - RulesetListResponseKindCustom RulesetListResponseKind = "custom" - RulesetListResponseKindRoot RulesetListResponseKind = "root" - RulesetListResponseKindZone RulesetListResponseKind = "zone" -) - -// The phase of the ruleset. -type RulesetListResponsePhase string - -const ( - RulesetListResponsePhaseDDOSL4 RulesetListResponsePhase = "ddos_l4" - RulesetListResponsePhaseDDOSL7 RulesetListResponsePhase = "ddos_l7" - RulesetListResponsePhaseHTTPConfigSettings RulesetListResponsePhase = "http_config_settings" - RulesetListResponsePhaseHTTPCustomErrors RulesetListResponsePhase = "http_custom_errors" - RulesetListResponsePhaseHTTPLogCustomFields RulesetListResponsePhase = "http_log_custom_fields" - RulesetListResponsePhaseHTTPRatelimit RulesetListResponsePhase = "http_ratelimit" - RulesetListResponsePhaseHTTPRequestCacheSettings RulesetListResponsePhase = "http_request_cache_settings" - RulesetListResponsePhaseHTTPRequestDynamicRedirect RulesetListResponsePhase = "http_request_dynamic_redirect" - RulesetListResponsePhaseHTTPRequestFirewallCustom RulesetListResponsePhase = "http_request_firewall_custom" - RulesetListResponsePhaseHTTPRequestFirewallManaged RulesetListResponsePhase = "http_request_firewall_managed" - RulesetListResponsePhaseHTTPRequestLateTransform RulesetListResponsePhase = "http_request_late_transform" - RulesetListResponsePhaseHTTPRequestOrigin RulesetListResponsePhase = "http_request_origin" - RulesetListResponsePhaseHTTPRequestRedirect RulesetListResponsePhase = "http_request_redirect" - RulesetListResponsePhaseHTTPRequestSanitize RulesetListResponsePhase = "http_request_sanitize" - RulesetListResponsePhaseHTTPRequestSbfm RulesetListResponsePhase = "http_request_sbfm" - RulesetListResponsePhaseHTTPRequestSelectConfiguration RulesetListResponsePhase = "http_request_select_configuration" - RulesetListResponsePhaseHTTPRequestTransform RulesetListResponsePhase = "http_request_transform" - RulesetListResponsePhaseHTTPResponseCompression RulesetListResponsePhase = "http_response_compression" - RulesetListResponsePhaseHTTPResponseFirewallManaged RulesetListResponsePhase = "http_response_firewall_managed" - RulesetListResponsePhaseHTTPResponseHeadersTransform RulesetListResponsePhase = "http_response_headers_transform" - RulesetListResponsePhaseMagicTransit RulesetListResponsePhase = "magic_transit" - RulesetListResponsePhaseMagicTransitIDsManaged RulesetListResponsePhase = "magic_transit_ids_managed" - RulesetListResponsePhaseMagicTransitManaged RulesetListResponsePhase = "magic_transit_managed" -) - -// A result. -type RulesetGetResponse struct { - // The unique ID of the ruleset. - ID string `json:"id,required"` - // The kind of the ruleset. - Kind RulesetGetResponseKind `json:"kind,required"` - // The timestamp of when the ruleset was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The human-readable name of the ruleset. - Name string `json:"name,required"` - // The phase of the ruleset. - Phase RulesetGetResponsePhase `json:"phase,required"` - // The list of rules in the ruleset. - Rules []RulesetGetResponseRule `json:"rules,required"` - // The version of the ruleset. - Version string `json:"version,required"` - // An informative description of the ruleset. - Description string `json:"description"` - JSON rulesetGetResponseJSON `json:"-"` -} - -// rulesetGetResponseJSON contains the JSON metadata for the struct -// [RulesetGetResponse] -type rulesetGetResponseJSON struct { - ID apijson.Field - Kind apijson.Field - LastUpdated apijson.Field - Name apijson.Field - Phase apijson.Field - Rules apijson.Field - Version apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseJSON) RawJSON() string { - return r.raw -} - -// The kind of the ruleset. -type RulesetGetResponseKind string - -const ( - RulesetGetResponseKindManaged RulesetGetResponseKind = "managed" - RulesetGetResponseKindCustom RulesetGetResponseKind = "custom" - RulesetGetResponseKindRoot RulesetGetResponseKind = "root" - RulesetGetResponseKindZone RulesetGetResponseKind = "zone" -) - -// The phase of the ruleset. -type RulesetGetResponsePhase string - -const ( - RulesetGetResponsePhaseDDOSL4 RulesetGetResponsePhase = "ddos_l4" - RulesetGetResponsePhaseDDOSL7 RulesetGetResponsePhase = "ddos_l7" - RulesetGetResponsePhaseHTTPConfigSettings RulesetGetResponsePhase = "http_config_settings" - RulesetGetResponsePhaseHTTPCustomErrors RulesetGetResponsePhase = "http_custom_errors" - RulesetGetResponsePhaseHTTPLogCustomFields RulesetGetResponsePhase = "http_log_custom_fields" - RulesetGetResponsePhaseHTTPRatelimit RulesetGetResponsePhase = "http_ratelimit" - RulesetGetResponsePhaseHTTPRequestCacheSettings RulesetGetResponsePhase = "http_request_cache_settings" - RulesetGetResponsePhaseHTTPRequestDynamicRedirect RulesetGetResponsePhase = "http_request_dynamic_redirect" - RulesetGetResponsePhaseHTTPRequestFirewallCustom RulesetGetResponsePhase = "http_request_firewall_custom" - RulesetGetResponsePhaseHTTPRequestFirewallManaged RulesetGetResponsePhase = "http_request_firewall_managed" - RulesetGetResponsePhaseHTTPRequestLateTransform RulesetGetResponsePhase = "http_request_late_transform" - RulesetGetResponsePhaseHTTPRequestOrigin RulesetGetResponsePhase = "http_request_origin" - RulesetGetResponsePhaseHTTPRequestRedirect RulesetGetResponsePhase = "http_request_redirect" - RulesetGetResponsePhaseHTTPRequestSanitize RulesetGetResponsePhase = "http_request_sanitize" - RulesetGetResponsePhaseHTTPRequestSbfm RulesetGetResponsePhase = "http_request_sbfm" - RulesetGetResponsePhaseHTTPRequestSelectConfiguration RulesetGetResponsePhase = "http_request_select_configuration" - RulesetGetResponsePhaseHTTPRequestTransform RulesetGetResponsePhase = "http_request_transform" - RulesetGetResponsePhaseHTTPResponseCompression RulesetGetResponsePhase = "http_response_compression" - RulesetGetResponsePhaseHTTPResponseFirewallManaged RulesetGetResponsePhase = "http_response_firewall_managed" - RulesetGetResponsePhaseHTTPResponseHeadersTransform RulesetGetResponsePhase = "http_response_headers_transform" - RulesetGetResponsePhaseMagicTransit RulesetGetResponsePhase = "magic_transit" - RulesetGetResponsePhaseMagicTransitIDsManaged RulesetGetResponsePhase = "magic_transit_ids_managed" - RulesetGetResponsePhaseMagicTransitManaged RulesetGetResponsePhase = "magic_transit_managed" -) - -// Union satisfied by [RulesetGetResponseRulesRulesetsBlockRule], -// [RulesetGetResponseRulesRulesetsExecuteRule], -// [RulesetGetResponseRulesRulesetsLogRule] or -// [RulesetGetResponseRulesRulesetsSkipRule]. -type RulesetGetResponseRule interface { - implementsRulesetGetResponseRule() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*RulesetGetResponseRule)(nil)).Elem(), - "action", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetGetResponseRulesRulesetsBlockRule{}), - DiscriminatorValue: "block", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetGetResponseRulesRulesetsExecuteRule{}), - DiscriminatorValue: "execute", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetGetResponseRulesRulesetsLogRule{}), - DiscriminatorValue: "log", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetGetResponseRulesRulesetsSkipRule{}), - DiscriminatorValue: "skip", - }, - ) -} - -type RulesetGetResponseRulesRulesetsBlockRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetGetResponseRulesRulesetsBlockRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetGetResponseRulesRulesetsBlockRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetGetResponseRulesRulesetsBlockRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetGetResponseRulesRulesetsBlockRuleJSON `json:"-"` -} - -// rulesetGetResponseRulesRulesetsBlockRuleJSON contains the JSON metadata for the -// struct [RulesetGetResponseRulesRulesetsBlockRule] -type rulesetGetResponseRulesRulesetsBlockRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseRulesRulesetsBlockRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseRulesRulesetsBlockRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetGetResponseRulesRulesetsBlockRule) implementsRulesetGetResponseRule() {} - -// The action to perform when the rule matches. -type RulesetGetResponseRulesRulesetsBlockRuleAction string - -const ( - RulesetGetResponseRulesRulesetsBlockRuleActionBlock RulesetGetResponseRulesRulesetsBlockRuleAction = "block" -) - -// The parameters configuring the rule's action. -type RulesetGetResponseRulesRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response RulesetGetResponseRulesRulesetsBlockRuleActionParametersResponse `json:"response"` - JSON rulesetGetResponseRulesRulesetsBlockRuleActionParametersJSON `json:"-"` -} - -// rulesetGetResponseRulesRulesetsBlockRuleActionParametersJSON contains the JSON -// metadata for the struct -// [RulesetGetResponseRulesRulesetsBlockRuleActionParameters] -type rulesetGetResponseRulesRulesetsBlockRuleActionParametersJSON struct { - Response apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseRulesRulesetsBlockRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseRulesRulesetsBlockRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The response to show when the block is applied. -type RulesetGetResponseRulesRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content string `json:"content,required"` - // The type of the content to return. - ContentType string `json:"content_type,required"` - // The status code to return. - StatusCode int64 `json:"status_code,required"` - JSON rulesetGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON `json:"-"` -} - -// rulesetGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON contains -// the JSON metadata for the struct -// [RulesetGetResponseRulesRulesetsBlockRuleActionParametersResponse] -type rulesetGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON struct { - Content apijson.Field - ContentType apijson.Field - StatusCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseRulesRulesetsBlockRuleActionParametersResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON) RawJSON() string { - return r.raw -} - -// An object configuring the rule's logging behavior. -type RulesetGetResponseRulesRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetGetResponseRulesRulesetsBlockRuleLoggingJSON `json:"-"` -} - -// rulesetGetResponseRulesRulesetsBlockRuleLoggingJSON contains the JSON metadata -// for the struct [RulesetGetResponseRulesRulesetsBlockRuleLogging] -type rulesetGetResponseRulesRulesetsBlockRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseRulesRulesetsBlockRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseRulesRulesetsBlockRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetGetResponseRulesRulesetsExecuteRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetGetResponseRulesRulesetsExecuteRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetGetResponseRulesRulesetsExecuteRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetGetResponseRulesRulesetsExecuteRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetGetResponseRulesRulesetsExecuteRuleJSON `json:"-"` -} - -// rulesetGetResponseRulesRulesetsExecuteRuleJSON contains the JSON metadata for -// the struct [RulesetGetResponseRulesRulesetsExecuteRule] -type rulesetGetResponseRulesRulesetsExecuteRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseRulesRulesetsExecuteRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseRulesRulesetsExecuteRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetGetResponseRulesRulesetsExecuteRule) implementsRulesetGetResponseRule() {} - -// The action to perform when the rule matches. -type RulesetGetResponseRulesRulesetsExecuteRuleAction string - -const ( - RulesetGetResponseRulesRulesetsExecuteRuleActionExecute RulesetGetResponseRulesRulesetsExecuteRuleAction = "execute" -) - -// The parameters configuring the rule's action. -type RulesetGetResponseRulesRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID string `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData RulesetGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverrides `json:"overrides"` - JSON rulesetGetResponseRulesRulesetsExecuteRuleActionParametersJSON `json:"-"` -} - -// rulesetGetResponseRulesRulesetsExecuteRuleActionParametersJSON contains the JSON -// metadata for the struct -// [RulesetGetResponseRulesRulesetsExecuteRuleActionParameters] -type rulesetGetResponseRulesRulesetsExecuteRuleActionParametersJSON struct { - ID apijson.Field - MatchedData apijson.Field - Overrides apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseRulesRulesetsExecuteRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseRulesRulesetsExecuteRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The configuration to use for matched data logging. -type RulesetGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey string `json:"public_key,required"` - JSON rulesetGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON `json:"-"` -} - -// rulesetGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON -// contains the JSON metadata for the struct -// [RulesetGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData] -type rulesetGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON struct { - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON) RawJSON() string { - return r.raw -} - -// A set of overrides to apply to the target ruleset. -type RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action string `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories []RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled bool `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules []RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON `json:"-"` -} - -// rulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON contains -// the JSON metadata for the struct -// [RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverrides] -type rulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON struct { - Action apijson.Field - Categories apijson.Field - Enabled apijson.Field - Rules apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverrides) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON) RawJSON() string { - return r.raw -} - -// A category-level override -type RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category string `json:"category,required"` - // The action to override rules in the category with. - Action string `json:"action"` - // Whether to enable execution of rules in the category. - Enabled bool `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON `json:"-"` -} - -// rulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON -// contains the JSON metadata for the struct -// [RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory] -type rulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON struct { - Category apijson.Field - Action apijson.Field - Enabled apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for rules in the category. -type RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string - -const ( - RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" -) - -// A rule-level override -type RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID string `json:"id,required"` - // The action to override the rule with. - Action string `json:"action"` - // Whether to enable execution of the rule. - Enabled bool `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold int64 `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON `json:"-"` -} - -// rulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON -// contains the JSON metadata for the struct -// [RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule] -type rulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON struct { - ID apijson.Field - Action apijson.Field - Enabled apijson.Field - ScoreThreshold apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for the rule. -type RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string - -const ( - RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" -) - -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string - -const ( - RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" -) - -// An object configuring the rule's logging behavior. -type RulesetGetResponseRulesRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetGetResponseRulesRulesetsExecuteRuleLoggingJSON `json:"-"` -} - -// rulesetGetResponseRulesRulesetsExecuteRuleLoggingJSON contains the JSON metadata -// for the struct [RulesetGetResponseRulesRulesetsExecuteRuleLogging] -type rulesetGetResponseRulesRulesetsExecuteRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseRulesRulesetsExecuteRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseRulesRulesetsExecuteRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetGetResponseRulesRulesetsLogRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetGetResponseRulesRulesetsLogRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters interface{} `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetGetResponseRulesRulesetsLogRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetGetResponseRulesRulesetsLogRuleJSON `json:"-"` -} - -// rulesetGetResponseRulesRulesetsLogRuleJSON contains the JSON metadata for the -// struct [RulesetGetResponseRulesRulesetsLogRule] -type rulesetGetResponseRulesRulesetsLogRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseRulesRulesetsLogRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseRulesRulesetsLogRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetGetResponseRulesRulesetsLogRule) implementsRulesetGetResponseRule() {} - -// The action to perform when the rule matches. -type RulesetGetResponseRulesRulesetsLogRuleAction string - -const ( - RulesetGetResponseRulesRulesetsLogRuleActionLog RulesetGetResponseRulesRulesetsLogRuleAction = "log" -) - -// An object configuring the rule's logging behavior. -type RulesetGetResponseRulesRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetGetResponseRulesRulesetsLogRuleLoggingJSON `json:"-"` -} - -// rulesetGetResponseRulesRulesetsLogRuleLoggingJSON contains the JSON metadata for -// the struct [RulesetGetResponseRulesRulesetsLogRuleLogging] -type rulesetGetResponseRulesRulesetsLogRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseRulesRulesetsLogRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseRulesRulesetsLogRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetGetResponseRulesRulesetsSkipRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetGetResponseRulesRulesetsSkipRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetGetResponseRulesRulesetsSkipRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetGetResponseRulesRulesetsSkipRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetGetResponseRulesRulesetsSkipRuleJSON `json:"-"` -} - -// rulesetGetResponseRulesRulesetsSkipRuleJSON contains the JSON metadata for the -// struct [RulesetGetResponseRulesRulesetsSkipRule] -type rulesetGetResponseRulesRulesetsSkipRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseRulesRulesetsSkipRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseRulesRulesetsSkipRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetGetResponseRulesRulesetsSkipRule) implementsRulesetGetResponseRule() {} - -// The action to perform when the rule matches. -type RulesetGetResponseRulesRulesetsSkipRuleAction string - -const ( - RulesetGetResponseRulesRulesetsSkipRuleActionSkip RulesetGetResponseRulesRulesetsSkipRuleAction = "skip" -) - -// The parameters configuring the rule's action. -type RulesetGetResponseRulesRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases []RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase `json:"phases"` - // A list of legacy security products to skip the execution of. - Products []RulesetGetResponseRulesRulesetsSkipRuleActionParametersProduct `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules map[string][]string `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset RulesetGetResponseRulesRulesetsSkipRuleActionParametersRuleset `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets []string `json:"rulesets"` - JSON rulesetGetResponseRulesRulesetsSkipRuleActionParametersJSON `json:"-"` -} - -// rulesetGetResponseRulesRulesetsSkipRuleActionParametersJSON contains the JSON -// metadata for the struct -// [RulesetGetResponseRulesRulesetsSkipRuleActionParameters] -type rulesetGetResponseRulesRulesetsSkipRuleActionParametersJSON struct { - Phases apijson.Field - Products apijson.Field - Rules apijson.Field - Ruleset apijson.Field - Rulesets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseRulesRulesetsSkipRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseRulesRulesetsSkipRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// A phase to skip the execution of. -type RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase string - -const ( - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL4 RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL7 RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetGetResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -// The name of a legacy security product to skip the execution of. -type RulesetGetResponseRulesRulesetsSkipRuleActionParametersProduct string - -const ( - RulesetGetResponseRulesRulesetsSkipRuleActionParametersProductBic RulesetGetResponseRulesRulesetsSkipRuleActionParametersProduct = "bic" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersProductHot RulesetGetResponseRulesRulesetsSkipRuleActionParametersProduct = "hot" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetGetResponseRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetGetResponseRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersProductUABlock RulesetGetResponseRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersProductWAF RulesetGetResponseRulesRulesetsSkipRuleActionParametersProduct = "waf" - RulesetGetResponseRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetGetResponseRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) - -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RulesetGetResponseRulesRulesetsSkipRuleActionParametersRuleset string - -const ( - RulesetGetResponseRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetGetResponseRulesRulesetsSkipRuleActionParametersRuleset = "current" -) - -// An object configuring the rule's logging behavior. -type RulesetGetResponseRulesRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetGetResponseRulesRulesetsSkipRuleLoggingJSON `json:"-"` -} - -// rulesetGetResponseRulesRulesetsSkipRuleLoggingJSON contains the JSON metadata -// for the struct [RulesetGetResponseRulesRulesetsSkipRuleLogging] -type rulesetGetResponseRulesRulesetsSkipRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseRulesRulesetsSkipRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseRulesRulesetsSkipRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetNewParams struct { - // The kind of the ruleset. - Kind param.Field[RulesetNewParamsKind] `json:"kind,required"` - // The human-readable name of the ruleset. - Name param.Field[string] `json:"name,required"` - // The phase of the ruleset. - Phase param.Field[RulesetNewParamsPhase] `json:"phase,required"` - // The list of rules in the ruleset. - Rules param.Field[[]RulesetNewParamsRule] `json:"rules,required"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // An informative description of the ruleset. - Description param.Field[string] `json:"description"` -} - -func (r RulesetNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The kind of the ruleset. -type RulesetNewParamsKind string - -const ( - RulesetNewParamsKindManaged RulesetNewParamsKind = "managed" - RulesetNewParamsKindCustom RulesetNewParamsKind = "custom" - RulesetNewParamsKindRoot RulesetNewParamsKind = "root" - RulesetNewParamsKindZone RulesetNewParamsKind = "zone" -) - -// The phase of the ruleset. -type RulesetNewParamsPhase string - -const ( - RulesetNewParamsPhaseDDOSL4 RulesetNewParamsPhase = "ddos_l4" - RulesetNewParamsPhaseDDOSL7 RulesetNewParamsPhase = "ddos_l7" - RulesetNewParamsPhaseHTTPConfigSettings RulesetNewParamsPhase = "http_config_settings" - RulesetNewParamsPhaseHTTPCustomErrors RulesetNewParamsPhase = "http_custom_errors" - RulesetNewParamsPhaseHTTPLogCustomFields RulesetNewParamsPhase = "http_log_custom_fields" - RulesetNewParamsPhaseHTTPRatelimit RulesetNewParamsPhase = "http_ratelimit" - RulesetNewParamsPhaseHTTPRequestCacheSettings RulesetNewParamsPhase = "http_request_cache_settings" - RulesetNewParamsPhaseHTTPRequestDynamicRedirect RulesetNewParamsPhase = "http_request_dynamic_redirect" - RulesetNewParamsPhaseHTTPRequestFirewallCustom RulesetNewParamsPhase = "http_request_firewall_custom" - RulesetNewParamsPhaseHTTPRequestFirewallManaged RulesetNewParamsPhase = "http_request_firewall_managed" - RulesetNewParamsPhaseHTTPRequestLateTransform RulesetNewParamsPhase = "http_request_late_transform" - RulesetNewParamsPhaseHTTPRequestOrigin RulesetNewParamsPhase = "http_request_origin" - RulesetNewParamsPhaseHTTPRequestRedirect RulesetNewParamsPhase = "http_request_redirect" - RulesetNewParamsPhaseHTTPRequestSanitize RulesetNewParamsPhase = "http_request_sanitize" - RulesetNewParamsPhaseHTTPRequestSbfm RulesetNewParamsPhase = "http_request_sbfm" - RulesetNewParamsPhaseHTTPRequestSelectConfiguration RulesetNewParamsPhase = "http_request_select_configuration" - RulesetNewParamsPhaseHTTPRequestTransform RulesetNewParamsPhase = "http_request_transform" - RulesetNewParamsPhaseHTTPResponseCompression RulesetNewParamsPhase = "http_response_compression" - RulesetNewParamsPhaseHTTPResponseFirewallManaged RulesetNewParamsPhase = "http_response_firewall_managed" - RulesetNewParamsPhaseHTTPResponseHeadersTransform RulesetNewParamsPhase = "http_response_headers_transform" - RulesetNewParamsPhaseMagicTransit RulesetNewParamsPhase = "magic_transit" - RulesetNewParamsPhaseMagicTransitIDsManaged RulesetNewParamsPhase = "magic_transit_ids_managed" - RulesetNewParamsPhaseMagicTransitManaged RulesetNewParamsPhase = "magic_transit_managed" -) - -// Satisfied by [RulesetNewParamsRulesRulesetsBlockRule], -// [RulesetNewParamsRulesRulesetsExecuteRule], -// [RulesetNewParamsRulesRulesetsLogRule], [RulesetNewParamsRulesRulesetsSkipRule]. -type RulesetNewParamsRule interface { - implementsRulesetNewParamsRule() -} - -type RulesetNewParamsRulesRulesetsBlockRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RulesetNewParamsRulesRulesetsBlockRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[RulesetNewParamsRulesRulesetsBlockRuleActionParameters] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RulesetNewParamsRulesRulesetsBlockRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} - -func (r RulesetNewParamsRulesRulesetsBlockRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetNewParamsRulesRulesetsBlockRule) implementsRulesetNewParamsRule() {} - -// The action to perform when the rule matches. -type RulesetNewParamsRulesRulesetsBlockRuleAction string - -const ( - RulesetNewParamsRulesRulesetsBlockRuleActionBlock RulesetNewParamsRulesRulesetsBlockRuleAction = "block" -) - -// The parameters configuring the rule's action. -type RulesetNewParamsRulesRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response param.Field[RulesetNewParamsRulesRulesetsBlockRuleActionParametersResponse] `json:"response"` -} - -func (r RulesetNewParamsRulesRulesetsBlockRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The response to show when the block is applied. -type RulesetNewParamsRulesRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content param.Field[string] `json:"content,required"` - // The type of the content to return. - ContentType param.Field[string] `json:"content_type,required"` - // The status code to return. - StatusCode param.Field[int64] `json:"status_code,required"` -} - -func (r RulesetNewParamsRulesRulesetsBlockRuleActionParametersResponse) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// An object configuring the rule's logging behavior. -type RulesetNewParamsRulesRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetNewParamsRulesRulesetsBlockRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RulesetNewParamsRulesRulesetsExecuteRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RulesetNewParamsRulesRulesetsExecuteRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[RulesetNewParamsRulesRulesetsExecuteRuleActionParameters] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RulesetNewParamsRulesRulesetsExecuteRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} - -func (r RulesetNewParamsRulesRulesetsExecuteRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetNewParamsRulesRulesetsExecuteRule) implementsRulesetNewParamsRule() {} - -// The action to perform when the rule matches. -type RulesetNewParamsRulesRulesetsExecuteRuleAction string - -const ( - RulesetNewParamsRulesRulesetsExecuteRuleActionExecute RulesetNewParamsRulesRulesetsExecuteRuleAction = "execute" -) - -// The parameters configuring the rule's action. -type RulesetNewParamsRulesRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID param.Field[string] `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData param.Field[RulesetNewParamsRulesRulesetsExecuteRuleActionParametersMatchedData] `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides param.Field[RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverrides] `json:"overrides"` -} - -func (r RulesetNewParamsRulesRulesetsExecuteRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The configuration to use for matched data logging. -type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey param.Field[string] `json:"public_key,required"` -} - -func (r RulesetNewParamsRulesRulesetsExecuteRuleActionParametersMatchedData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A set of overrides to apply to the target ruleset. -type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action param.Field[string] `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories param.Field[[]RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory] `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled param.Field[bool] `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules param.Field[[]RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRule] `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel param.Field[RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel] `json:"sensitivity_level"` -} - -func (r RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverrides) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A category-level override -type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category param.Field[string] `json:"category,required"` - // The action to override rules in the category with. - Action param.Field[string] `json:"action"` - // Whether to enable execution of rules in the category. - Enabled param.Field[bool] `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel param.Field[RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel] `json:"sensitivity_level"` -} - -func (r RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The sensitivity level to use for rules in the category. -type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string - -const ( - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" -) - -// A rule-level override -type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID param.Field[string] `json:"id,required"` - // The action to override the rule with. - Action param.Field[string] `json:"action"` - // Whether to enable execution of the rule. - Enabled param.Field[bool] `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold param.Field[int64] `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel param.Field[RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel] `json:"sensitivity_level"` -} - -func (r RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The sensitivity level to use for the rule. -type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string - -const ( - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" -) - -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string - -const ( - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" -) - -// An object configuring the rule's logging behavior. -type RulesetNewParamsRulesRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetNewParamsRulesRulesetsExecuteRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RulesetNewParamsRulesRulesetsLogRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RulesetNewParamsRulesRulesetsLogRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[interface{}] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RulesetNewParamsRulesRulesetsLogRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} - -func (r RulesetNewParamsRulesRulesetsLogRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetNewParamsRulesRulesetsLogRule) implementsRulesetNewParamsRule() {} - -// The action to perform when the rule matches. -type RulesetNewParamsRulesRulesetsLogRuleAction string - -const ( - RulesetNewParamsRulesRulesetsLogRuleActionLog RulesetNewParamsRulesRulesetsLogRuleAction = "log" -) - -// An object configuring the rule's logging behavior. -type RulesetNewParamsRulesRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetNewParamsRulesRulesetsLogRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RulesetNewParamsRulesRulesetsSkipRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RulesetNewParamsRulesRulesetsSkipRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[RulesetNewParamsRulesRulesetsSkipRuleActionParameters] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RulesetNewParamsRulesRulesetsSkipRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} - -func (r RulesetNewParamsRulesRulesetsSkipRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetNewParamsRulesRulesetsSkipRule) implementsRulesetNewParamsRule() {} - -// The action to perform when the rule matches. -type RulesetNewParamsRulesRulesetsSkipRuleAction string - -const ( - RulesetNewParamsRulesRulesetsSkipRuleActionSkip RulesetNewParamsRulesRulesetsSkipRuleAction = "skip" -) - -// The parameters configuring the rule's action. -type RulesetNewParamsRulesRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases param.Field[[]RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase] `json:"phases"` - // A list of legacy security products to skip the execution of. - Products param.Field[[]RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct] `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules param.Field[map[string][]string] `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset param.Field[RulesetNewParamsRulesRulesetsSkipRuleActionParametersRuleset] `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets param.Field[[]string] `json:"rulesets"` -} - -func (r RulesetNewParamsRulesRulesetsSkipRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A phase to skip the execution of. -type RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase string - -const ( - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseDDOSL4 RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseDDOSL7 RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -// The name of a legacy security product to skip the execution of. -type RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct string - -const ( - RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductBic RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "bic" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductHot RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "hot" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductUABlock RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductWAF RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "waf" - RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) - -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RulesetNewParamsRulesRulesetsSkipRuleActionParametersRuleset string - -const ( - RulesetNewParamsRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetNewParamsRulesRulesetsSkipRuleActionParametersRuleset = "current" -) - -// An object configuring the rule's logging behavior. -type RulesetNewParamsRulesRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetNewParamsRulesRulesetsSkipRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A response object. -type RulesetNewResponseEnvelope struct { - // A list of error messages. - Errors []RulesetNewResponseEnvelopeErrors `json:"errors,required"` - // A list of warning messages. - Messages []RulesetNewResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result RulesetNewResponse `json:"result,required"` - // Whether the API call was successful. - Success RulesetNewResponseEnvelopeSuccess `json:"success,required"` - JSON rulesetNewResponseEnvelopeJSON `json:"-"` -} - -// rulesetNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [RulesetNewResponseEnvelope] -type rulesetNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetNewResponseEnvelopeErrors struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetNewResponseEnvelopeErrorsSource `json:"source"` - JSON rulesetNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// rulesetNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RulesetNewResponseEnvelopeErrors] -type rulesetNewResponseEnvelopeErrorsJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetNewResponseEnvelopeErrorsSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetNewResponseEnvelopeErrorsSourceJSON `json:"-"` -} - -// rulesetNewResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the -// struct [RulesetNewResponseEnvelopeErrorsSource] -type rulesetNewResponseEnvelopeErrorsSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseEnvelopeErrorsSourceJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetNewResponseEnvelopeMessages struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetNewResponseEnvelopeMessagesSource `json:"source"` - JSON rulesetNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// rulesetNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RulesetNewResponseEnvelopeMessages] -type rulesetNewResponseEnvelopeMessagesJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetNewResponseEnvelopeMessagesSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetNewResponseEnvelopeMessagesSourceJSON `json:"-"` -} - -// rulesetNewResponseEnvelopeMessagesSourceJSON contains the JSON metadata for the -// struct [RulesetNewResponseEnvelopeMessagesSource] -type rulesetNewResponseEnvelopeMessagesSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetNewResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetNewResponseEnvelopeMessagesSourceJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type RulesetNewResponseEnvelopeSuccess bool - -const ( - RulesetNewResponseEnvelopeSuccessTrue RulesetNewResponseEnvelopeSuccess = true -) - -type RulesetUpdateParams struct { - // The unique ID of the ruleset. - ID param.Field[string] `json:"id,required"` - // The list of rules in the ruleset. - Rules param.Field[[]RulesetUpdateParamsRule] `json:"rules,required"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // An informative description of the ruleset. - Description param.Field[string] `json:"description"` - // The kind of the ruleset. - Kind param.Field[RulesetUpdateParamsKind] `json:"kind"` - // The human-readable name of the ruleset. - Name param.Field[string] `json:"name"` - // The phase of the ruleset. - Phase param.Field[RulesetUpdateParamsPhase] `json:"phase"` -} - -func (r RulesetUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Satisfied by [RulesetUpdateParamsRulesRulesetsBlockRule], -// [RulesetUpdateParamsRulesRulesetsExecuteRule], -// [RulesetUpdateParamsRulesRulesetsLogRule], -// [RulesetUpdateParamsRulesRulesetsSkipRule]. -type RulesetUpdateParamsRule interface { - implementsRulesetUpdateParamsRule() -} - -type RulesetUpdateParamsRulesRulesetsBlockRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RulesetUpdateParamsRulesRulesetsBlockRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[RulesetUpdateParamsRulesRulesetsBlockRuleActionParameters] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RulesetUpdateParamsRulesRulesetsBlockRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} - -func (r RulesetUpdateParamsRulesRulesetsBlockRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetUpdateParamsRulesRulesetsBlockRule) implementsRulesetUpdateParamsRule() {} - -// The action to perform when the rule matches. -type RulesetUpdateParamsRulesRulesetsBlockRuleAction string - -const ( - RulesetUpdateParamsRulesRulesetsBlockRuleActionBlock RulesetUpdateParamsRulesRulesetsBlockRuleAction = "block" -) - -// The parameters configuring the rule's action. -type RulesetUpdateParamsRulesRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response param.Field[RulesetUpdateParamsRulesRulesetsBlockRuleActionParametersResponse] `json:"response"` -} - -func (r RulesetUpdateParamsRulesRulesetsBlockRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The response to show when the block is applied. -type RulesetUpdateParamsRulesRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content param.Field[string] `json:"content,required"` - // The type of the content to return. - ContentType param.Field[string] `json:"content_type,required"` - // The status code to return. - StatusCode param.Field[int64] `json:"status_code,required"` -} - -func (r RulesetUpdateParamsRulesRulesetsBlockRuleActionParametersResponse) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// An object configuring the rule's logging behavior. -type RulesetUpdateParamsRulesRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetUpdateParamsRulesRulesetsBlockRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RulesetUpdateParamsRulesRulesetsExecuteRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleActionParameters] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} - -func (r RulesetUpdateParamsRulesRulesetsExecuteRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetUpdateParamsRulesRulesetsExecuteRule) implementsRulesetUpdateParamsRule() {} - -// The action to perform when the rule matches. -type RulesetUpdateParamsRulesRulesetsExecuteRuleAction string - -const ( - RulesetUpdateParamsRulesRulesetsExecuteRuleActionExecute RulesetUpdateParamsRulesRulesetsExecuteRuleAction = "execute" -) - -// The parameters configuring the rule's action. -type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID param.Field[string] `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersMatchedData] `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverrides] `json:"overrides"` -} - -func (r RulesetUpdateParamsRulesRulesetsExecuteRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The configuration to use for matched data logging. -type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey param.Field[string] `json:"public_key,required"` -} - -func (r RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersMatchedData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A set of overrides to apply to the target ruleset. -type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action param.Field[string] `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories param.Field[[]RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory] `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled param.Field[bool] `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules param.Field[[]RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRule] `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel] `json:"sensitivity_level"` -} - -func (r RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverrides) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A category-level override -type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category param.Field[string] `json:"category,required"` - // The action to override rules in the category with. - Action param.Field[string] `json:"action"` - // Whether to enable execution of rules in the category. - Enabled param.Field[bool] `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel] `json:"sensitivity_level"` -} - -func (r RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The sensitivity level to use for rules in the category. -type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string - -const ( - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" -) - -// A rule-level override -type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID param.Field[string] `json:"id,required"` - // The action to override the rule with. - Action param.Field[string] `json:"action"` - // Whether to enable execution of the rule. - Enabled param.Field[bool] `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold param.Field[int64] `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel] `json:"sensitivity_level"` -} - -func (r RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The sensitivity level to use for the rule. -type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string - -const ( - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" -) - -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string - -const ( - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" -) - -// An object configuring the rule's logging behavior. -type RulesetUpdateParamsRulesRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetUpdateParamsRulesRulesetsExecuteRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RulesetUpdateParamsRulesRulesetsLogRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RulesetUpdateParamsRulesRulesetsLogRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[interface{}] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RulesetUpdateParamsRulesRulesetsLogRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} - -func (r RulesetUpdateParamsRulesRulesetsLogRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetUpdateParamsRulesRulesetsLogRule) implementsRulesetUpdateParamsRule() {} - -// The action to perform when the rule matches. -type RulesetUpdateParamsRulesRulesetsLogRuleAction string - -const ( - RulesetUpdateParamsRulesRulesetsLogRuleActionLog RulesetUpdateParamsRulesRulesetsLogRuleAction = "log" -) - -// An object configuring the rule's logging behavior. -type RulesetUpdateParamsRulesRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetUpdateParamsRulesRulesetsLogRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RulesetUpdateParamsRulesRulesetsSkipRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RulesetUpdateParamsRulesRulesetsSkipRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[RulesetUpdateParamsRulesRulesetsSkipRuleActionParameters] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RulesetUpdateParamsRulesRulesetsSkipRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} - -func (r RulesetUpdateParamsRulesRulesetsSkipRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetUpdateParamsRulesRulesetsSkipRule) implementsRulesetUpdateParamsRule() {} - -// The action to perform when the rule matches. -type RulesetUpdateParamsRulesRulesetsSkipRuleAction string - -const ( - RulesetUpdateParamsRulesRulesetsSkipRuleActionSkip RulesetUpdateParamsRulesRulesetsSkipRuleAction = "skip" -) - -// The parameters configuring the rule's action. -type RulesetUpdateParamsRulesRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases param.Field[[]RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase] `json:"phases"` - // A list of legacy security products to skip the execution of. - Products param.Field[[]RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct] `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules param.Field[map[string][]string] `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset param.Field[RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset] `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets param.Field[[]string] `json:"rulesets"` -} - -func (r RulesetUpdateParamsRulesRulesetsSkipRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A phase to skip the execution of. -type RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase string - -const ( - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseDDOSL4 RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseDDOSL7 RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -// The name of a legacy security product to skip the execution of. -type RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct string - -const ( - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductBic RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "bic" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductHot RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "hot" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductUABlock RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductWAF RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "waf" - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) - -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset string - -const ( - RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset = "current" -) - -// An object configuring the rule's logging behavior. -type RulesetUpdateParamsRulesRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetUpdateParamsRulesRulesetsSkipRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The kind of the ruleset. -type RulesetUpdateParamsKind string - -const ( - RulesetUpdateParamsKindManaged RulesetUpdateParamsKind = "managed" - RulesetUpdateParamsKindCustom RulesetUpdateParamsKind = "custom" - RulesetUpdateParamsKindRoot RulesetUpdateParamsKind = "root" - RulesetUpdateParamsKindZone RulesetUpdateParamsKind = "zone" -) - -// The phase of the ruleset. -type RulesetUpdateParamsPhase string - -const ( - RulesetUpdateParamsPhaseDDOSL4 RulesetUpdateParamsPhase = "ddos_l4" - RulesetUpdateParamsPhaseDDOSL7 RulesetUpdateParamsPhase = "ddos_l7" - RulesetUpdateParamsPhaseHTTPConfigSettings RulesetUpdateParamsPhase = "http_config_settings" - RulesetUpdateParamsPhaseHTTPCustomErrors RulesetUpdateParamsPhase = "http_custom_errors" - RulesetUpdateParamsPhaseHTTPLogCustomFields RulesetUpdateParamsPhase = "http_log_custom_fields" - RulesetUpdateParamsPhaseHTTPRatelimit RulesetUpdateParamsPhase = "http_ratelimit" - RulesetUpdateParamsPhaseHTTPRequestCacheSettings RulesetUpdateParamsPhase = "http_request_cache_settings" - RulesetUpdateParamsPhaseHTTPRequestDynamicRedirect RulesetUpdateParamsPhase = "http_request_dynamic_redirect" - RulesetUpdateParamsPhaseHTTPRequestFirewallCustom RulesetUpdateParamsPhase = "http_request_firewall_custom" - RulesetUpdateParamsPhaseHTTPRequestFirewallManaged RulesetUpdateParamsPhase = "http_request_firewall_managed" - RulesetUpdateParamsPhaseHTTPRequestLateTransform RulesetUpdateParamsPhase = "http_request_late_transform" - RulesetUpdateParamsPhaseHTTPRequestOrigin RulesetUpdateParamsPhase = "http_request_origin" - RulesetUpdateParamsPhaseHTTPRequestRedirect RulesetUpdateParamsPhase = "http_request_redirect" - RulesetUpdateParamsPhaseHTTPRequestSanitize RulesetUpdateParamsPhase = "http_request_sanitize" - RulesetUpdateParamsPhaseHTTPRequestSbfm RulesetUpdateParamsPhase = "http_request_sbfm" - RulesetUpdateParamsPhaseHTTPRequestSelectConfiguration RulesetUpdateParamsPhase = "http_request_select_configuration" - RulesetUpdateParamsPhaseHTTPRequestTransform RulesetUpdateParamsPhase = "http_request_transform" - RulesetUpdateParamsPhaseHTTPResponseCompression RulesetUpdateParamsPhase = "http_response_compression" - RulesetUpdateParamsPhaseHTTPResponseFirewallManaged RulesetUpdateParamsPhase = "http_response_firewall_managed" - RulesetUpdateParamsPhaseHTTPResponseHeadersTransform RulesetUpdateParamsPhase = "http_response_headers_transform" - RulesetUpdateParamsPhaseMagicTransit RulesetUpdateParamsPhase = "magic_transit" - RulesetUpdateParamsPhaseMagicTransitIDsManaged RulesetUpdateParamsPhase = "magic_transit_ids_managed" - RulesetUpdateParamsPhaseMagicTransitManaged RulesetUpdateParamsPhase = "magic_transit_managed" -) - -// A response object. -type RulesetUpdateResponseEnvelope struct { - // A list of error messages. - Errors []RulesetUpdateResponseEnvelopeErrors `json:"errors,required"` - // A list of warning messages. - Messages []RulesetUpdateResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result RulesetUpdateResponse `json:"result,required"` - // Whether the API call was successful. - Success RulesetUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON rulesetUpdateResponseEnvelopeJSON `json:"-"` -} - -// rulesetUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [RulesetUpdateResponseEnvelope] -type rulesetUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetUpdateResponseEnvelopeErrors struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetUpdateResponseEnvelopeErrorsSource `json:"source"` - JSON rulesetUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// rulesetUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RulesetUpdateResponseEnvelopeErrors] -type rulesetUpdateResponseEnvelopeErrorsJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetUpdateResponseEnvelopeErrorsSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetUpdateResponseEnvelopeErrorsSourceJSON `json:"-"` -} - -// rulesetUpdateResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the -// struct [RulesetUpdateResponseEnvelopeErrorsSource] -type rulesetUpdateResponseEnvelopeErrorsSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseEnvelopeErrorsSourceJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetUpdateResponseEnvelopeMessages struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetUpdateResponseEnvelopeMessagesSource `json:"source"` - JSON rulesetUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// rulesetUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RulesetUpdateResponseEnvelopeMessages] -type rulesetUpdateResponseEnvelopeMessagesJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetUpdateResponseEnvelopeMessagesSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetUpdateResponseEnvelopeMessagesSourceJSON `json:"-"` -} - -// rulesetUpdateResponseEnvelopeMessagesSourceJSON contains the JSON metadata for -// the struct [RulesetUpdateResponseEnvelopeMessagesSource] -type rulesetUpdateResponseEnvelopeMessagesSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetUpdateResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetUpdateResponseEnvelopeMessagesSourceJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type RulesetUpdateResponseEnvelopeSuccess bool - -const ( - RulesetUpdateResponseEnvelopeSuccessTrue RulesetUpdateResponseEnvelopeSuccess = true -) - -type RulesetListParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -// A response object. -type RulesetListResponseEnvelope struct { - // A list of error messages. - Errors []RulesetListResponseEnvelopeErrors `json:"errors,required"` - // A list of warning messages. - Messages []RulesetListResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result []RulesetListResponse `json:"result,required"` - // Whether the API call was successful. - Success RulesetListResponseEnvelopeSuccess `json:"success,required"` - JSON rulesetListResponseEnvelopeJSON `json:"-"` -} - -// rulesetListResponseEnvelopeJSON contains the JSON metadata for the struct -// [RulesetListResponseEnvelope] -type rulesetListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetListResponseEnvelopeErrors struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetListResponseEnvelopeErrorsSource `json:"source"` - JSON rulesetListResponseEnvelopeErrorsJSON `json:"-"` -} - -// rulesetListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RulesetListResponseEnvelopeErrors] -type rulesetListResponseEnvelopeErrorsJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetListResponseEnvelopeErrorsSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetListResponseEnvelopeErrorsSourceJSON `json:"-"` -} - -// rulesetListResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the -// struct [RulesetListResponseEnvelopeErrorsSource] -type rulesetListResponseEnvelopeErrorsSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetListResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetListResponseEnvelopeErrorsSourceJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetListResponseEnvelopeMessages struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetListResponseEnvelopeMessagesSource `json:"source"` - JSON rulesetListResponseEnvelopeMessagesJSON `json:"-"` -} - -// rulesetListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RulesetListResponseEnvelopeMessages] -type rulesetListResponseEnvelopeMessagesJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetListResponseEnvelopeMessagesSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetListResponseEnvelopeMessagesSourceJSON `json:"-"` -} - -// rulesetListResponseEnvelopeMessagesSourceJSON contains the JSON metadata for the -// struct [RulesetListResponseEnvelopeMessagesSource] -type rulesetListResponseEnvelopeMessagesSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetListResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetListResponseEnvelopeMessagesSourceJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type RulesetListResponseEnvelopeSuccess bool - -const ( - RulesetListResponseEnvelopeSuccessTrue RulesetListResponseEnvelopeSuccess = true -) - -type RulesetDeleteParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type RulesetGetParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -// A response object. -type RulesetGetResponseEnvelope struct { - // A list of error messages. - Errors []RulesetGetResponseEnvelopeErrors `json:"errors,required"` - // A list of warning messages. - Messages []RulesetGetResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result RulesetGetResponse `json:"result,required"` - // Whether the API call was successful. - Success RulesetGetResponseEnvelopeSuccess `json:"success,required"` - JSON rulesetGetResponseEnvelopeJSON `json:"-"` -} - -// rulesetGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [RulesetGetResponseEnvelope] -type rulesetGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetGetResponseEnvelopeErrors struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetGetResponseEnvelopeErrorsSource `json:"source"` - JSON rulesetGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// rulesetGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [RulesetGetResponseEnvelopeErrors] -type rulesetGetResponseEnvelopeErrorsJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetGetResponseEnvelopeErrorsSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetGetResponseEnvelopeErrorsSourceJSON `json:"-"` -} - -// rulesetGetResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the -// struct [RulesetGetResponseEnvelopeErrorsSource] -type rulesetGetResponseEnvelopeErrorsSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseEnvelopeErrorsSourceJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetGetResponseEnvelopeMessages struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetGetResponseEnvelopeMessagesSource `json:"source"` - JSON rulesetGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// rulesetGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [RulesetGetResponseEnvelopeMessages] -type rulesetGetResponseEnvelopeMessagesJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetGetResponseEnvelopeMessagesSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetGetResponseEnvelopeMessagesSourceJSON `json:"-"` -} - -// rulesetGetResponseEnvelopeMessagesSourceJSON contains the JSON metadata for the -// struct [RulesetGetResponseEnvelopeMessagesSource] -type rulesetGetResponseEnvelopeMessagesSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetGetResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetGetResponseEnvelopeMessagesSourceJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type RulesetGetResponseEnvelopeSuccess bool - -const ( - RulesetGetResponseEnvelopeSuccessTrue RulesetGetResponseEnvelopeSuccess = true -) diff --git a/ruleset_test.go b/ruleset_test.go deleted file mode 100644 index 54bb1f6de05..00000000000 --- a/ruleset_test.go +++ /dev/null @@ -1,274 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRulesetNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Rulesets.New(context.TODO(), cloudflare.RulesetNewParams{ - Kind: cloudflare.F(cloudflare.RulesetNewParamsKindRoot), - Name: cloudflare.F("My ruleset"), - Phase: cloudflare.F(cloudflare.RulesetNewParamsPhaseHTTPRequestFirewallCustom), - Rules: cloudflare.F([]cloudflare.RulesetNewParamsRule{cloudflare.RulesetNewParamsRulesRulesetsBlockRule(cloudflare.RulesetNewParamsRulesRulesetsBlockRule{ - Action: cloudflare.F(cloudflare.RulesetNewParamsRulesRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(cloudflare.RulesetNewParamsRulesRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(cloudflare.RulesetNewParamsRulesRulesetsBlockRuleActionParametersResponse{ - Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), - ContentType: cloudflare.F("application/json"), - StatusCode: cloudflare.F(int64(400)), - }), - }), - Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("ip.src ne 1.1.1.1"), - ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Logging: cloudflare.F(cloudflare.RulesetNewParamsRulesRulesetsBlockRuleLogging{ - Enabled: cloudflare.F(true), - }), - Ref: cloudflare.F("my_ref"), - }), cloudflare.RulesetNewParamsRulesRulesetsBlockRule(cloudflare.RulesetNewParamsRulesRulesetsBlockRule{ - Action: cloudflare.F(cloudflare.RulesetNewParamsRulesRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(cloudflare.RulesetNewParamsRulesRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(cloudflare.RulesetNewParamsRulesRulesetsBlockRuleActionParametersResponse{ - Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), - ContentType: cloudflare.F("application/json"), - StatusCode: cloudflare.F(int64(400)), - }), - }), - Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("ip.src ne 1.1.1.1"), - ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Logging: cloudflare.F(cloudflare.RulesetNewParamsRulesRulesetsBlockRuleLogging{ - Enabled: cloudflare.F(true), - }), - Ref: cloudflare.F("my_ref"), - }), cloudflare.RulesetNewParamsRulesRulesetsBlockRule(cloudflare.RulesetNewParamsRulesRulesetsBlockRule{ - Action: cloudflare.F(cloudflare.RulesetNewParamsRulesRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(cloudflare.RulesetNewParamsRulesRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(cloudflare.RulesetNewParamsRulesRulesetsBlockRuleActionParametersResponse{ - Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), - ContentType: cloudflare.F("application/json"), - StatusCode: cloudflare.F(int64(400)), - }), - }), - Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("ip.src ne 1.1.1.1"), - ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Logging: cloudflare.F(cloudflare.RulesetNewParamsRulesRulesetsBlockRuleLogging{ - Enabled: cloudflare.F(true), - }), - Ref: cloudflare.F("my_ref"), - })}), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - Description: cloudflare.F("My ruleset to execute managed rulesets"), - }) - 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 TestRulesetUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Rulesets.Update( - context.TODO(), - "2f2feab2026849078ba485f918791bdc", - cloudflare.RulesetUpdateParams{ - ID: cloudflare.F("2f2feab2026849078ba485f918791bdc"), - Rules: cloudflare.F([]cloudflare.RulesetUpdateParamsRule{cloudflare.RulesetUpdateParamsRulesRulesetsBlockRule(cloudflare.RulesetUpdateParamsRulesRulesetsBlockRule{ - Action: cloudflare.F(cloudflare.RulesetUpdateParamsRulesRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(cloudflare.RulesetUpdateParamsRulesRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(cloudflare.RulesetUpdateParamsRulesRulesetsBlockRuleActionParametersResponse{ - Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), - ContentType: cloudflare.F("application/json"), - StatusCode: cloudflare.F(int64(400)), - }), - }), - Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("ip.src ne 1.1.1.1"), - ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Logging: cloudflare.F(cloudflare.RulesetUpdateParamsRulesRulesetsBlockRuleLogging{ - Enabled: cloudflare.F(true), - }), - Ref: cloudflare.F("my_ref"), - }), cloudflare.RulesetUpdateParamsRulesRulesetsBlockRule(cloudflare.RulesetUpdateParamsRulesRulesetsBlockRule{ - Action: cloudflare.F(cloudflare.RulesetUpdateParamsRulesRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(cloudflare.RulesetUpdateParamsRulesRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(cloudflare.RulesetUpdateParamsRulesRulesetsBlockRuleActionParametersResponse{ - Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), - ContentType: cloudflare.F("application/json"), - StatusCode: cloudflare.F(int64(400)), - }), - }), - Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("ip.src ne 1.1.1.1"), - ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Logging: cloudflare.F(cloudflare.RulesetUpdateParamsRulesRulesetsBlockRuleLogging{ - Enabled: cloudflare.F(true), - }), - Ref: cloudflare.F("my_ref"), - }), cloudflare.RulesetUpdateParamsRulesRulesetsBlockRule(cloudflare.RulesetUpdateParamsRulesRulesetsBlockRule{ - Action: cloudflare.F(cloudflare.RulesetUpdateParamsRulesRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(cloudflare.RulesetUpdateParamsRulesRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(cloudflare.RulesetUpdateParamsRulesRulesetsBlockRuleActionParametersResponse{ - Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), - ContentType: cloudflare.F("application/json"), - StatusCode: cloudflare.F(int64(400)), - }), - }), - Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("ip.src ne 1.1.1.1"), - ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Logging: cloudflare.F(cloudflare.RulesetUpdateParamsRulesRulesetsBlockRuleLogging{ - Enabled: cloudflare.F(true), - }), - Ref: cloudflare.F("my_ref"), - })}), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - Description: cloudflare.F("My ruleset to execute managed rulesets"), - Kind: cloudflare.F(cloudflare.RulesetUpdateParamsKindRoot), - Name: cloudflare.F("My ruleset"), - Phase: cloudflare.F(cloudflare.RulesetUpdateParamsPhaseHTTPRequestFirewallCustom), - }, - ) - 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 TestRulesetListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Rulesets.List(context.TODO(), cloudflare.RulesetListParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }) - 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 TestRulesetDeleteWithOptionalParams(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("user@example.com"), - ) - err := client.Rulesets.Delete( - context.TODO(), - "2f2feab2026849078ba485f918791bdc", - cloudflare.RulesetDeleteParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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 TestRulesetGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Rulesets.Get( - context.TODO(), - "2f2feab2026849078ba485f918791bdc", - cloudflare.RulesetGetParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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/rulesetphase.go b/rulesetphase.go deleted file mode 100644 index 8abb88d080f..00000000000 --- a/rulesetphase.go +++ /dev/null @@ -1,2466 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// RulesetPhaseService 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 [NewRulesetPhaseService] method -// instead. -type RulesetPhaseService struct { - Options []option.RequestOption - Versions *RulesetPhaseVersionService -} - -// NewRulesetPhaseService 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 NewRulesetPhaseService(opts ...option.RequestOption) (r *RulesetPhaseService) { - r = &RulesetPhaseService{} - r.Options = opts - r.Versions = NewRulesetPhaseVersionService(opts...) - return -} - -// Updates an account or zone entry point ruleset, creating a new version. -func (r *RulesetPhaseService) Update(ctx context.Context, rulesetPhase RulesetPhaseUpdateParamsRulesetPhase, params RulesetPhaseUpdateParams, opts ...option.RequestOption) (res *RulesetPhaseUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env RulesetPhaseUpdateResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/rulesets/phases/%v/entrypoint", accountOrZone, accountOrZoneID, rulesetPhase) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the latest version of the account or zone entry point ruleset for a -// given phase. -func (r *RulesetPhaseService) Get(ctx context.Context, rulesetPhase RulesetPhaseGetParamsRulesetPhase, query RulesetPhaseGetParams, opts ...option.RequestOption) (res *RulesetPhaseGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RulesetPhaseGetResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/rulesets/phases/%v/entrypoint", accountOrZone, accountOrZoneID, rulesetPhase) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// A result. -type RulesetPhaseUpdateResponse struct { - // The unique ID of the ruleset. - ID string `json:"id,required"` - // The kind of the ruleset. - Kind RulesetPhaseUpdateResponseKind `json:"kind,required"` - // The timestamp of when the ruleset was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The human-readable name of the ruleset. - Name string `json:"name,required"` - // The phase of the ruleset. - Phase RulesetPhaseUpdateResponsePhase `json:"phase,required"` - // The list of rules in the ruleset. - Rules []RulesetPhaseUpdateResponseRule `json:"rules,required"` - // The version of the ruleset. - Version string `json:"version,required"` - // An informative description of the ruleset. - Description string `json:"description"` - JSON rulesetPhaseUpdateResponseJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseJSON contains the JSON metadata for the struct -// [RulesetPhaseUpdateResponse] -type rulesetPhaseUpdateResponseJSON struct { - ID apijson.Field - Kind apijson.Field - LastUpdated apijson.Field - Name apijson.Field - Phase apijson.Field - Rules apijson.Field - Version apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// The kind of the ruleset. -type RulesetPhaseUpdateResponseKind string - -const ( - RulesetPhaseUpdateResponseKindManaged RulesetPhaseUpdateResponseKind = "managed" - RulesetPhaseUpdateResponseKindCustom RulesetPhaseUpdateResponseKind = "custom" - RulesetPhaseUpdateResponseKindRoot RulesetPhaseUpdateResponseKind = "root" - RulesetPhaseUpdateResponseKindZone RulesetPhaseUpdateResponseKind = "zone" -) - -// The phase of the ruleset. -type RulesetPhaseUpdateResponsePhase string - -const ( - RulesetPhaseUpdateResponsePhaseDDOSL4 RulesetPhaseUpdateResponsePhase = "ddos_l4" - RulesetPhaseUpdateResponsePhaseDDOSL7 RulesetPhaseUpdateResponsePhase = "ddos_l7" - RulesetPhaseUpdateResponsePhaseHTTPConfigSettings RulesetPhaseUpdateResponsePhase = "http_config_settings" - RulesetPhaseUpdateResponsePhaseHTTPCustomErrors RulesetPhaseUpdateResponsePhase = "http_custom_errors" - RulesetPhaseUpdateResponsePhaseHTTPLogCustomFields RulesetPhaseUpdateResponsePhase = "http_log_custom_fields" - RulesetPhaseUpdateResponsePhaseHTTPRatelimit RulesetPhaseUpdateResponsePhase = "http_ratelimit" - RulesetPhaseUpdateResponsePhaseHTTPRequestCacheSettings RulesetPhaseUpdateResponsePhase = "http_request_cache_settings" - RulesetPhaseUpdateResponsePhaseHTTPRequestDynamicRedirect RulesetPhaseUpdateResponsePhase = "http_request_dynamic_redirect" - RulesetPhaseUpdateResponsePhaseHTTPRequestFirewallCustom RulesetPhaseUpdateResponsePhase = "http_request_firewall_custom" - RulesetPhaseUpdateResponsePhaseHTTPRequestFirewallManaged RulesetPhaseUpdateResponsePhase = "http_request_firewall_managed" - RulesetPhaseUpdateResponsePhaseHTTPRequestLateTransform RulesetPhaseUpdateResponsePhase = "http_request_late_transform" - RulesetPhaseUpdateResponsePhaseHTTPRequestOrigin RulesetPhaseUpdateResponsePhase = "http_request_origin" - RulesetPhaseUpdateResponsePhaseHTTPRequestRedirect RulesetPhaseUpdateResponsePhase = "http_request_redirect" - RulesetPhaseUpdateResponsePhaseHTTPRequestSanitize RulesetPhaseUpdateResponsePhase = "http_request_sanitize" - RulesetPhaseUpdateResponsePhaseHTTPRequestSbfm RulesetPhaseUpdateResponsePhase = "http_request_sbfm" - RulesetPhaseUpdateResponsePhaseHTTPRequestSelectConfiguration RulesetPhaseUpdateResponsePhase = "http_request_select_configuration" - RulesetPhaseUpdateResponsePhaseHTTPRequestTransform RulesetPhaseUpdateResponsePhase = "http_request_transform" - RulesetPhaseUpdateResponsePhaseHTTPResponseCompression RulesetPhaseUpdateResponsePhase = "http_response_compression" - RulesetPhaseUpdateResponsePhaseHTTPResponseFirewallManaged RulesetPhaseUpdateResponsePhase = "http_response_firewall_managed" - RulesetPhaseUpdateResponsePhaseHTTPResponseHeadersTransform RulesetPhaseUpdateResponsePhase = "http_response_headers_transform" - RulesetPhaseUpdateResponsePhaseMagicTransit RulesetPhaseUpdateResponsePhase = "magic_transit" - RulesetPhaseUpdateResponsePhaseMagicTransitIDsManaged RulesetPhaseUpdateResponsePhase = "magic_transit_ids_managed" - RulesetPhaseUpdateResponsePhaseMagicTransitManaged RulesetPhaseUpdateResponsePhase = "magic_transit_managed" -) - -// Union satisfied by [RulesetPhaseUpdateResponseRulesRulesetsBlockRule], -// [RulesetPhaseUpdateResponseRulesRulesetsExecuteRule], -// [RulesetPhaseUpdateResponseRulesRulesetsLogRule] or -// [RulesetPhaseUpdateResponseRulesRulesetsSkipRule]. -type RulesetPhaseUpdateResponseRule interface { - implementsRulesetPhaseUpdateResponseRule() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*RulesetPhaseUpdateResponseRule)(nil)).Elem(), - "action", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetPhaseUpdateResponseRulesRulesetsBlockRule{}), - DiscriminatorValue: "block", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetPhaseUpdateResponseRulesRulesetsExecuteRule{}), - DiscriminatorValue: "execute", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetPhaseUpdateResponseRulesRulesetsLogRule{}), - DiscriminatorValue: "log", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetPhaseUpdateResponseRulesRulesetsSkipRule{}), - DiscriminatorValue: "skip", - }, - ) -} - -type RulesetPhaseUpdateResponseRulesRulesetsBlockRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetPhaseUpdateResponseRulesRulesetsBlockRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetPhaseUpdateResponseRulesRulesetsBlockRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetPhaseUpdateResponseRulesRulesetsBlockRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetPhaseUpdateResponseRulesRulesetsBlockRuleJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseRulesRulesetsBlockRuleJSON contains the JSON metadata -// for the struct [RulesetPhaseUpdateResponseRulesRulesetsBlockRule] -type rulesetPhaseUpdateResponseRulesRulesetsBlockRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseRulesRulesetsBlockRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseRulesRulesetsBlockRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetPhaseUpdateResponseRulesRulesetsBlockRule) implementsRulesetPhaseUpdateResponseRule() { -} - -// The action to perform when the rule matches. -type RulesetPhaseUpdateResponseRulesRulesetsBlockRuleAction string - -const ( - RulesetPhaseUpdateResponseRulesRulesetsBlockRuleActionBlock RulesetPhaseUpdateResponseRulesRulesetsBlockRuleAction = "block" -) - -// The parameters configuring the rule's action. -type RulesetPhaseUpdateResponseRulesRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response RulesetPhaseUpdateResponseRulesRulesetsBlockRuleActionParametersResponse `json:"response"` - JSON rulesetPhaseUpdateResponseRulesRulesetsBlockRuleActionParametersJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseRulesRulesetsBlockRuleActionParametersJSON contains -// the JSON metadata for the struct -// [RulesetPhaseUpdateResponseRulesRulesetsBlockRuleActionParameters] -type rulesetPhaseUpdateResponseRulesRulesetsBlockRuleActionParametersJSON struct { - Response apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseRulesRulesetsBlockRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseRulesRulesetsBlockRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The response to show when the block is applied. -type RulesetPhaseUpdateResponseRulesRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content string `json:"content,required"` - // The type of the content to return. - ContentType string `json:"content_type,required"` - // The status code to return. - StatusCode int64 `json:"status_code,required"` - JSON rulesetPhaseUpdateResponseRulesRulesetsBlockRuleActionParametersResponseJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseRulesRulesetsBlockRuleActionParametersResponseJSON -// contains the JSON metadata for the struct -// [RulesetPhaseUpdateResponseRulesRulesetsBlockRuleActionParametersResponse] -type rulesetPhaseUpdateResponseRulesRulesetsBlockRuleActionParametersResponseJSON struct { - Content apijson.Field - ContentType apijson.Field - StatusCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseRulesRulesetsBlockRuleActionParametersResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseRulesRulesetsBlockRuleActionParametersResponseJSON) RawJSON() string { - return r.raw -} - -// An object configuring the rule's logging behavior. -type RulesetPhaseUpdateResponseRulesRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetPhaseUpdateResponseRulesRulesetsBlockRuleLoggingJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseRulesRulesetsBlockRuleLoggingJSON contains the JSON -// metadata for the struct -// [RulesetPhaseUpdateResponseRulesRulesetsBlockRuleLogging] -type rulesetPhaseUpdateResponseRulesRulesetsBlockRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseRulesRulesetsBlockRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseRulesRulesetsBlockRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetPhaseUpdateResponseRulesRulesetsExecuteRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleJSON contains the JSON -// metadata for the struct [RulesetPhaseUpdateResponseRulesRulesetsExecuteRule] -type rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseRulesRulesetsExecuteRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetPhaseUpdateResponseRulesRulesetsExecuteRule) implementsRulesetPhaseUpdateResponseRule() { -} - -// The action to perform when the rule matches. -type RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleAction string - -const ( - RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionExecute RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleAction = "execute" -) - -// The parameters configuring the rule's action. -type RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID string `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersMatchedData `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverrides `json:"overrides"` - JSON rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersJSON contains -// the JSON metadata for the struct -// [RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParameters] -type rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersJSON struct { - ID apijson.Field - MatchedData apijson.Field - Overrides apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The configuration to use for matched data logging. -type RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey string `json:"public_key,required"` - JSON rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON -// contains the JSON metadata for the struct -// [RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersMatchedData] -type rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON struct { - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersMatchedData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON) RawJSON() string { - return r.raw -} - -// A set of overrides to apply to the target ruleset. -type RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action string `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories []RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled bool `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules []RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRule `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON -// contains the JSON metadata for the struct -// [RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverrides] -type rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON struct { - Action apijson.Field - Categories apijson.Field - Enabled apijson.Field - Rules apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverrides) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON) RawJSON() string { - return r.raw -} - -// A category-level override -type RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category string `json:"category,required"` - // The action to override rules in the category with. - Action string `json:"action"` - // Whether to enable execution of rules in the category. - Enabled bool `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON -// contains the JSON metadata for the struct -// [RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory] -type rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON struct { - Category apijson.Field - Action apijson.Field - Enabled apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for rules in the category. -type RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string - -const ( - RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" -) - -// A rule-level override -type RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID string `json:"id,required"` - // The action to override the rule with. - Action string `json:"action"` - // Whether to enable execution of the rule. - Enabled bool `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold int64 `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON -// contains the JSON metadata for the struct -// [RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRule] -type rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON struct { - ID apijson.Field - Action apijson.Field - Enabled apijson.Field - ScoreThreshold apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for the rule. -type RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string - -const ( - RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" -) - -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string - -const ( - RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" -) - -// An object configuring the rule's logging behavior. -type RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleLoggingJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleLoggingJSON contains the JSON -// metadata for the struct -// [RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleLogging] -type rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseRulesRulesetsExecuteRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseRulesRulesetsExecuteRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetPhaseUpdateResponseRulesRulesetsLogRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetPhaseUpdateResponseRulesRulesetsLogRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters interface{} `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetPhaseUpdateResponseRulesRulesetsLogRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetPhaseUpdateResponseRulesRulesetsLogRuleJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseRulesRulesetsLogRuleJSON contains the JSON metadata -// for the struct [RulesetPhaseUpdateResponseRulesRulesetsLogRule] -type rulesetPhaseUpdateResponseRulesRulesetsLogRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseRulesRulesetsLogRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseRulesRulesetsLogRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetPhaseUpdateResponseRulesRulesetsLogRule) implementsRulesetPhaseUpdateResponseRule() {} - -// The action to perform when the rule matches. -type RulesetPhaseUpdateResponseRulesRulesetsLogRuleAction string - -const ( - RulesetPhaseUpdateResponseRulesRulesetsLogRuleActionLog RulesetPhaseUpdateResponseRulesRulesetsLogRuleAction = "log" -) - -// An object configuring the rule's logging behavior. -type RulesetPhaseUpdateResponseRulesRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetPhaseUpdateResponseRulesRulesetsLogRuleLoggingJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseRulesRulesetsLogRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetPhaseUpdateResponseRulesRulesetsLogRuleLogging] -type rulesetPhaseUpdateResponseRulesRulesetsLogRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseRulesRulesetsLogRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseRulesRulesetsLogRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetPhaseUpdateResponseRulesRulesetsSkipRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetPhaseUpdateResponseRulesRulesetsSkipRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetPhaseUpdateResponseRulesRulesetsSkipRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetPhaseUpdateResponseRulesRulesetsSkipRuleJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseRulesRulesetsSkipRuleJSON contains the JSON metadata -// for the struct [RulesetPhaseUpdateResponseRulesRulesetsSkipRule] -type rulesetPhaseUpdateResponseRulesRulesetsSkipRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseRulesRulesetsSkipRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseRulesRulesetsSkipRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetPhaseUpdateResponseRulesRulesetsSkipRule) implementsRulesetPhaseUpdateResponseRule() {} - -// The action to perform when the rule matches. -type RulesetPhaseUpdateResponseRulesRulesetsSkipRuleAction string - -const ( - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionSkip RulesetPhaseUpdateResponseRulesRulesetsSkipRuleAction = "skip" -) - -// The parameters configuring the rule's action. -type RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases []RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase `json:"phases"` - // A list of legacy security products to skip the execution of. - Products []RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersProduct `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules map[string][]string `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersRuleset `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets []string `json:"rulesets"` - JSON rulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersJSON contains the -// JSON metadata for the struct -// [RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParameters] -type rulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersJSON struct { - Phases apijson.Field - Products apijson.Field - Rules apijson.Field - Ruleset apijson.Field - Rulesets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// A phase to skip the execution of. -type RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase string - -const ( - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL4 RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL7 RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -// The name of a legacy security product to skip the execution of. -type RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersProduct string - -const ( - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersProductBic RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersProduct = "bic" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersProductHot RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersProduct = "hot" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersProductUABlock RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersProductWAF RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersProduct = "waf" - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) - -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersRuleset string - -const ( - RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetPhaseUpdateResponseRulesRulesetsSkipRuleActionParametersRuleset = "current" -) - -// An object configuring the rule's logging behavior. -type RulesetPhaseUpdateResponseRulesRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetPhaseUpdateResponseRulesRulesetsSkipRuleLoggingJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseRulesRulesetsSkipRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetPhaseUpdateResponseRulesRulesetsSkipRuleLogging] -type rulesetPhaseUpdateResponseRulesRulesetsSkipRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseRulesRulesetsSkipRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseRulesRulesetsSkipRuleLoggingJSON) RawJSON() string { - return r.raw -} - -// A result. -type RulesetPhaseGetResponse struct { - // The unique ID of the ruleset. - ID string `json:"id,required"` - // The kind of the ruleset. - Kind RulesetPhaseGetResponseKind `json:"kind,required"` - // The timestamp of when the ruleset was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The human-readable name of the ruleset. - Name string `json:"name,required"` - // The phase of the ruleset. - Phase RulesetPhaseGetResponsePhase `json:"phase,required"` - // The list of rules in the ruleset. - Rules []RulesetPhaseGetResponseRule `json:"rules,required"` - // The version of the ruleset. - Version string `json:"version,required"` - // An informative description of the ruleset. - Description string `json:"description"` - JSON rulesetPhaseGetResponseJSON `json:"-"` -} - -// rulesetPhaseGetResponseJSON contains the JSON metadata for the struct -// [RulesetPhaseGetResponse] -type rulesetPhaseGetResponseJSON struct { - ID apijson.Field - Kind apijson.Field - LastUpdated apijson.Field - Name apijson.Field - Phase apijson.Field - Rules apijson.Field - Version apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseJSON) RawJSON() string { - return r.raw -} - -// The kind of the ruleset. -type RulesetPhaseGetResponseKind string - -const ( - RulesetPhaseGetResponseKindManaged RulesetPhaseGetResponseKind = "managed" - RulesetPhaseGetResponseKindCustom RulesetPhaseGetResponseKind = "custom" - RulesetPhaseGetResponseKindRoot RulesetPhaseGetResponseKind = "root" - RulesetPhaseGetResponseKindZone RulesetPhaseGetResponseKind = "zone" -) - -// The phase of the ruleset. -type RulesetPhaseGetResponsePhase string - -const ( - RulesetPhaseGetResponsePhaseDDOSL4 RulesetPhaseGetResponsePhase = "ddos_l4" - RulesetPhaseGetResponsePhaseDDOSL7 RulesetPhaseGetResponsePhase = "ddos_l7" - RulesetPhaseGetResponsePhaseHTTPConfigSettings RulesetPhaseGetResponsePhase = "http_config_settings" - RulesetPhaseGetResponsePhaseHTTPCustomErrors RulesetPhaseGetResponsePhase = "http_custom_errors" - RulesetPhaseGetResponsePhaseHTTPLogCustomFields RulesetPhaseGetResponsePhase = "http_log_custom_fields" - RulesetPhaseGetResponsePhaseHTTPRatelimit RulesetPhaseGetResponsePhase = "http_ratelimit" - RulesetPhaseGetResponsePhaseHTTPRequestCacheSettings RulesetPhaseGetResponsePhase = "http_request_cache_settings" - RulesetPhaseGetResponsePhaseHTTPRequestDynamicRedirect RulesetPhaseGetResponsePhase = "http_request_dynamic_redirect" - RulesetPhaseGetResponsePhaseHTTPRequestFirewallCustom RulesetPhaseGetResponsePhase = "http_request_firewall_custom" - RulesetPhaseGetResponsePhaseHTTPRequestFirewallManaged RulesetPhaseGetResponsePhase = "http_request_firewall_managed" - RulesetPhaseGetResponsePhaseHTTPRequestLateTransform RulesetPhaseGetResponsePhase = "http_request_late_transform" - RulesetPhaseGetResponsePhaseHTTPRequestOrigin RulesetPhaseGetResponsePhase = "http_request_origin" - RulesetPhaseGetResponsePhaseHTTPRequestRedirect RulesetPhaseGetResponsePhase = "http_request_redirect" - RulesetPhaseGetResponsePhaseHTTPRequestSanitize RulesetPhaseGetResponsePhase = "http_request_sanitize" - RulesetPhaseGetResponsePhaseHTTPRequestSbfm RulesetPhaseGetResponsePhase = "http_request_sbfm" - RulesetPhaseGetResponsePhaseHTTPRequestSelectConfiguration RulesetPhaseGetResponsePhase = "http_request_select_configuration" - RulesetPhaseGetResponsePhaseHTTPRequestTransform RulesetPhaseGetResponsePhase = "http_request_transform" - RulesetPhaseGetResponsePhaseHTTPResponseCompression RulesetPhaseGetResponsePhase = "http_response_compression" - RulesetPhaseGetResponsePhaseHTTPResponseFirewallManaged RulesetPhaseGetResponsePhase = "http_response_firewall_managed" - RulesetPhaseGetResponsePhaseHTTPResponseHeadersTransform RulesetPhaseGetResponsePhase = "http_response_headers_transform" - RulesetPhaseGetResponsePhaseMagicTransit RulesetPhaseGetResponsePhase = "magic_transit" - RulesetPhaseGetResponsePhaseMagicTransitIDsManaged RulesetPhaseGetResponsePhase = "magic_transit_ids_managed" - RulesetPhaseGetResponsePhaseMagicTransitManaged RulesetPhaseGetResponsePhase = "magic_transit_managed" -) - -// Union satisfied by [RulesetPhaseGetResponseRulesRulesetsBlockRule], -// [RulesetPhaseGetResponseRulesRulesetsExecuteRule], -// [RulesetPhaseGetResponseRulesRulesetsLogRule] or -// [RulesetPhaseGetResponseRulesRulesetsSkipRule]. -type RulesetPhaseGetResponseRule interface { - implementsRulesetPhaseGetResponseRule() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*RulesetPhaseGetResponseRule)(nil)).Elem(), - "action", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetPhaseGetResponseRulesRulesetsBlockRule{}), - DiscriminatorValue: "block", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetPhaseGetResponseRulesRulesetsExecuteRule{}), - DiscriminatorValue: "execute", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetPhaseGetResponseRulesRulesetsLogRule{}), - DiscriminatorValue: "log", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetPhaseGetResponseRulesRulesetsSkipRule{}), - DiscriminatorValue: "skip", - }, - ) -} - -type RulesetPhaseGetResponseRulesRulesetsBlockRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetPhaseGetResponseRulesRulesetsBlockRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetPhaseGetResponseRulesRulesetsBlockRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetPhaseGetResponseRulesRulesetsBlockRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetPhaseGetResponseRulesRulesetsBlockRuleJSON `json:"-"` -} - -// rulesetPhaseGetResponseRulesRulesetsBlockRuleJSON contains the JSON metadata for -// the struct [RulesetPhaseGetResponseRulesRulesetsBlockRule] -type rulesetPhaseGetResponseRulesRulesetsBlockRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseRulesRulesetsBlockRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseRulesRulesetsBlockRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetPhaseGetResponseRulesRulesetsBlockRule) implementsRulesetPhaseGetResponseRule() {} - -// The action to perform when the rule matches. -type RulesetPhaseGetResponseRulesRulesetsBlockRuleAction string - -const ( - RulesetPhaseGetResponseRulesRulesetsBlockRuleActionBlock RulesetPhaseGetResponseRulesRulesetsBlockRuleAction = "block" -) - -// The parameters configuring the rule's action. -type RulesetPhaseGetResponseRulesRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response RulesetPhaseGetResponseRulesRulesetsBlockRuleActionParametersResponse `json:"response"` - JSON rulesetPhaseGetResponseRulesRulesetsBlockRuleActionParametersJSON `json:"-"` -} - -// rulesetPhaseGetResponseRulesRulesetsBlockRuleActionParametersJSON contains the -// JSON metadata for the struct -// [RulesetPhaseGetResponseRulesRulesetsBlockRuleActionParameters] -type rulesetPhaseGetResponseRulesRulesetsBlockRuleActionParametersJSON struct { - Response apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseRulesRulesetsBlockRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseRulesRulesetsBlockRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The response to show when the block is applied. -type RulesetPhaseGetResponseRulesRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content string `json:"content,required"` - // The type of the content to return. - ContentType string `json:"content_type,required"` - // The status code to return. - StatusCode int64 `json:"status_code,required"` - JSON rulesetPhaseGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON `json:"-"` -} - -// rulesetPhaseGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON -// contains the JSON metadata for the struct -// [RulesetPhaseGetResponseRulesRulesetsBlockRuleActionParametersResponse] -type rulesetPhaseGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON struct { - Content apijson.Field - ContentType apijson.Field - StatusCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseRulesRulesetsBlockRuleActionParametersResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON) RawJSON() string { - return r.raw -} - -// An object configuring the rule's logging behavior. -type RulesetPhaseGetResponseRulesRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetPhaseGetResponseRulesRulesetsBlockRuleLoggingJSON `json:"-"` -} - -// rulesetPhaseGetResponseRulesRulesetsBlockRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetPhaseGetResponseRulesRulesetsBlockRuleLogging] -type rulesetPhaseGetResponseRulesRulesetsBlockRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseRulesRulesetsBlockRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseRulesRulesetsBlockRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetPhaseGetResponseRulesRulesetsExecuteRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetPhaseGetResponseRulesRulesetsExecuteRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetPhaseGetResponseRulesRulesetsExecuteRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetPhaseGetResponseRulesRulesetsExecuteRuleJSON `json:"-"` -} - -// rulesetPhaseGetResponseRulesRulesetsExecuteRuleJSON contains the JSON metadata -// for the struct [RulesetPhaseGetResponseRulesRulesetsExecuteRule] -type rulesetPhaseGetResponseRulesRulesetsExecuteRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseRulesRulesetsExecuteRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseRulesRulesetsExecuteRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetPhaseGetResponseRulesRulesetsExecuteRule) implementsRulesetPhaseGetResponseRule() {} - -// The action to perform when the rule matches. -type RulesetPhaseGetResponseRulesRulesetsExecuteRuleAction string - -const ( - RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionExecute RulesetPhaseGetResponseRulesRulesetsExecuteRuleAction = "execute" -) - -// The parameters configuring the rule's action. -type RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID string `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverrides `json:"overrides"` - JSON rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersJSON `json:"-"` -} - -// rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersJSON contains the -// JSON metadata for the struct -// [RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParameters] -type rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersJSON struct { - ID apijson.Field - MatchedData apijson.Field - Overrides apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The configuration to use for matched data logging. -type RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey string `json:"public_key,required"` - JSON rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON `json:"-"` -} - -// rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON -// contains the JSON metadata for the struct -// [RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData] -type rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON struct { - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON) RawJSON() string { - return r.raw -} - -// A set of overrides to apply to the target ruleset. -type RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action string `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories []RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled bool `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules []RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON `json:"-"` -} - -// rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON -// contains the JSON metadata for the struct -// [RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverrides] -type rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON struct { - Action apijson.Field - Categories apijson.Field - Enabled apijson.Field - Rules apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverrides) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON) RawJSON() string { - return r.raw -} - -// A category-level override -type RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category string `json:"category,required"` - // The action to override rules in the category with. - Action string `json:"action"` - // Whether to enable execution of rules in the category. - Enabled bool `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON `json:"-"` -} - -// rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON -// contains the JSON metadata for the struct -// [RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory] -type rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON struct { - Category apijson.Field - Action apijson.Field - Enabled apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for rules in the category. -type RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string - -const ( - RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" -) - -// A rule-level override -type RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID string `json:"id,required"` - // The action to override the rule with. - Action string `json:"action"` - // Whether to enable execution of the rule. - Enabled bool `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold int64 `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON `json:"-"` -} - -// rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON -// contains the JSON metadata for the struct -// [RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule] -type rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON struct { - ID apijson.Field - Action apijson.Field - Enabled apijson.Field - ScoreThreshold apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for the rule. -type RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string - -const ( - RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" -) - -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string - -const ( - RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetPhaseGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" -) - -// An object configuring the rule's logging behavior. -type RulesetPhaseGetResponseRulesRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetPhaseGetResponseRulesRulesetsExecuteRuleLoggingJSON `json:"-"` -} - -// rulesetPhaseGetResponseRulesRulesetsExecuteRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetPhaseGetResponseRulesRulesetsExecuteRuleLogging] -type rulesetPhaseGetResponseRulesRulesetsExecuteRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseRulesRulesetsExecuteRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseRulesRulesetsExecuteRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetPhaseGetResponseRulesRulesetsLogRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetPhaseGetResponseRulesRulesetsLogRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters interface{} `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetPhaseGetResponseRulesRulesetsLogRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetPhaseGetResponseRulesRulesetsLogRuleJSON `json:"-"` -} - -// rulesetPhaseGetResponseRulesRulesetsLogRuleJSON contains the JSON metadata for -// the struct [RulesetPhaseGetResponseRulesRulesetsLogRule] -type rulesetPhaseGetResponseRulesRulesetsLogRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseRulesRulesetsLogRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseRulesRulesetsLogRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetPhaseGetResponseRulesRulesetsLogRule) implementsRulesetPhaseGetResponseRule() {} - -// The action to perform when the rule matches. -type RulesetPhaseGetResponseRulesRulesetsLogRuleAction string - -const ( - RulesetPhaseGetResponseRulesRulesetsLogRuleActionLog RulesetPhaseGetResponseRulesRulesetsLogRuleAction = "log" -) - -// An object configuring the rule's logging behavior. -type RulesetPhaseGetResponseRulesRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetPhaseGetResponseRulesRulesetsLogRuleLoggingJSON `json:"-"` -} - -// rulesetPhaseGetResponseRulesRulesetsLogRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetPhaseGetResponseRulesRulesetsLogRuleLogging] -type rulesetPhaseGetResponseRulesRulesetsLogRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseRulesRulesetsLogRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseRulesRulesetsLogRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetPhaseGetResponseRulesRulesetsSkipRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetPhaseGetResponseRulesRulesetsSkipRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetPhaseGetResponseRulesRulesetsSkipRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetPhaseGetResponseRulesRulesetsSkipRuleJSON `json:"-"` -} - -// rulesetPhaseGetResponseRulesRulesetsSkipRuleJSON contains the JSON metadata for -// the struct [RulesetPhaseGetResponseRulesRulesetsSkipRule] -type rulesetPhaseGetResponseRulesRulesetsSkipRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseRulesRulesetsSkipRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseRulesRulesetsSkipRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetPhaseGetResponseRulesRulesetsSkipRule) implementsRulesetPhaseGetResponseRule() {} - -// The action to perform when the rule matches. -type RulesetPhaseGetResponseRulesRulesetsSkipRuleAction string - -const ( - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionSkip RulesetPhaseGetResponseRulesRulesetsSkipRuleAction = "skip" -) - -// The parameters configuring the rule's action. -type RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases []RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase `json:"phases"` - // A list of legacy security products to skip the execution of. - Products []RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersProduct `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules map[string][]string `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersRuleset `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets []string `json:"rulesets"` - JSON rulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersJSON `json:"-"` -} - -// rulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersJSON contains the -// JSON metadata for the struct -// [RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParameters] -type rulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersJSON struct { - Phases apijson.Field - Products apijson.Field - Rules apijson.Field - Ruleset apijson.Field - Rulesets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// A phase to skip the execution of. -type RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase string - -const ( - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL4 RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL7 RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -// The name of a legacy security product to skip the execution of. -type RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersProduct string - -const ( - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersProductBic RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersProduct = "bic" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersProductHot RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersProduct = "hot" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersProductUABlock RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersProductWAF RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersProduct = "waf" - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) - -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersRuleset string - -const ( - RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetPhaseGetResponseRulesRulesetsSkipRuleActionParametersRuleset = "current" -) - -// An object configuring the rule's logging behavior. -type RulesetPhaseGetResponseRulesRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetPhaseGetResponseRulesRulesetsSkipRuleLoggingJSON `json:"-"` -} - -// rulesetPhaseGetResponseRulesRulesetsSkipRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetPhaseGetResponseRulesRulesetsSkipRuleLogging] -type rulesetPhaseGetResponseRulesRulesetsSkipRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseRulesRulesetsSkipRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseRulesRulesetsSkipRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetPhaseUpdateParams struct { - // The unique ID of the ruleset. - ID param.Field[string] `json:"id,required"` - // The list of rules in the ruleset. - Rules param.Field[[]RulesetPhaseUpdateParamsRule] `json:"rules,required"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // An informative description of the ruleset. - Description param.Field[string] `json:"description"` - // The kind of the ruleset. - Kind param.Field[RulesetPhaseUpdateParamsKind] `json:"kind"` - // The human-readable name of the ruleset. - Name param.Field[string] `json:"name"` - // The phase of the ruleset. - Phase param.Field[RulesetPhaseUpdateParamsPhase] `json:"phase"` -} - -func (r RulesetPhaseUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The phase of the ruleset. -type RulesetPhaseUpdateParamsRulesetPhase string - -const ( - RulesetPhaseUpdateParamsRulesetPhaseDDOSL4 RulesetPhaseUpdateParamsRulesetPhase = "ddos_l4" - RulesetPhaseUpdateParamsRulesetPhaseDDOSL7 RulesetPhaseUpdateParamsRulesetPhase = "ddos_l7" - RulesetPhaseUpdateParamsRulesetPhaseHTTPConfigSettings RulesetPhaseUpdateParamsRulesetPhase = "http_config_settings" - RulesetPhaseUpdateParamsRulesetPhaseHTTPCustomErrors RulesetPhaseUpdateParamsRulesetPhase = "http_custom_errors" - RulesetPhaseUpdateParamsRulesetPhaseHTTPLogCustomFields RulesetPhaseUpdateParamsRulesetPhase = "http_log_custom_fields" - RulesetPhaseUpdateParamsRulesetPhaseHTTPRatelimit RulesetPhaseUpdateParamsRulesetPhase = "http_ratelimit" - RulesetPhaseUpdateParamsRulesetPhaseHTTPRequestCacheSettings RulesetPhaseUpdateParamsRulesetPhase = "http_request_cache_settings" - RulesetPhaseUpdateParamsRulesetPhaseHTTPRequestDynamicRedirect RulesetPhaseUpdateParamsRulesetPhase = "http_request_dynamic_redirect" - RulesetPhaseUpdateParamsRulesetPhaseHTTPRequestFirewallCustom RulesetPhaseUpdateParamsRulesetPhase = "http_request_firewall_custom" - RulesetPhaseUpdateParamsRulesetPhaseHTTPRequestFirewallManaged RulesetPhaseUpdateParamsRulesetPhase = "http_request_firewall_managed" - RulesetPhaseUpdateParamsRulesetPhaseHTTPRequestLateTransform RulesetPhaseUpdateParamsRulesetPhase = "http_request_late_transform" - RulesetPhaseUpdateParamsRulesetPhaseHTTPRequestOrigin RulesetPhaseUpdateParamsRulesetPhase = "http_request_origin" - RulesetPhaseUpdateParamsRulesetPhaseHTTPRequestRedirect RulesetPhaseUpdateParamsRulesetPhase = "http_request_redirect" - RulesetPhaseUpdateParamsRulesetPhaseHTTPRequestSanitize RulesetPhaseUpdateParamsRulesetPhase = "http_request_sanitize" - RulesetPhaseUpdateParamsRulesetPhaseHTTPRequestSbfm RulesetPhaseUpdateParamsRulesetPhase = "http_request_sbfm" - RulesetPhaseUpdateParamsRulesetPhaseHTTPRequestSelectConfiguration RulesetPhaseUpdateParamsRulesetPhase = "http_request_select_configuration" - RulesetPhaseUpdateParamsRulesetPhaseHTTPRequestTransform RulesetPhaseUpdateParamsRulesetPhase = "http_request_transform" - RulesetPhaseUpdateParamsRulesetPhaseHTTPResponseCompression RulesetPhaseUpdateParamsRulesetPhase = "http_response_compression" - RulesetPhaseUpdateParamsRulesetPhaseHTTPResponseFirewallManaged RulesetPhaseUpdateParamsRulesetPhase = "http_response_firewall_managed" - RulesetPhaseUpdateParamsRulesetPhaseHTTPResponseHeadersTransform RulesetPhaseUpdateParamsRulesetPhase = "http_response_headers_transform" - RulesetPhaseUpdateParamsRulesetPhaseMagicTransit RulesetPhaseUpdateParamsRulesetPhase = "magic_transit" - RulesetPhaseUpdateParamsRulesetPhaseMagicTransitIDsManaged RulesetPhaseUpdateParamsRulesetPhase = "magic_transit_ids_managed" - RulesetPhaseUpdateParamsRulesetPhaseMagicTransitManaged RulesetPhaseUpdateParamsRulesetPhase = "magic_transit_managed" -) - -// Satisfied by [RulesetPhaseUpdateParamsRulesRulesetsBlockRule], -// [RulesetPhaseUpdateParamsRulesRulesetsExecuteRule], -// [RulesetPhaseUpdateParamsRulesRulesetsLogRule], -// [RulesetPhaseUpdateParamsRulesRulesetsSkipRule]. -type RulesetPhaseUpdateParamsRule interface { - implementsRulesetPhaseUpdateParamsRule() -} - -type RulesetPhaseUpdateParamsRulesRulesetsBlockRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RulesetPhaseUpdateParamsRulesRulesetsBlockRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[RulesetPhaseUpdateParamsRulesRulesetsBlockRuleActionParameters] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RulesetPhaseUpdateParamsRulesRulesetsBlockRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsBlockRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsBlockRule) implementsRulesetPhaseUpdateParamsRule() {} - -// The action to perform when the rule matches. -type RulesetPhaseUpdateParamsRulesRulesetsBlockRuleAction string - -const ( - RulesetPhaseUpdateParamsRulesRulesetsBlockRuleActionBlock RulesetPhaseUpdateParamsRulesRulesetsBlockRuleAction = "block" -) - -// The parameters configuring the rule's action. -type RulesetPhaseUpdateParamsRulesRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response param.Field[RulesetPhaseUpdateParamsRulesRulesetsBlockRuleActionParametersResponse] `json:"response"` -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsBlockRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The response to show when the block is applied. -type RulesetPhaseUpdateParamsRulesRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content param.Field[string] `json:"content,required"` - // The type of the content to return. - ContentType param.Field[string] `json:"content_type,required"` - // The status code to return. - StatusCode param.Field[int64] `json:"status_code,required"` -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsBlockRuleActionParametersResponse) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// An object configuring the rule's logging behavior. -type RulesetPhaseUpdateParamsRulesRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsBlockRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RulesetPhaseUpdateParamsRulesRulesetsExecuteRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParameters] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsExecuteRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsExecuteRule) implementsRulesetPhaseUpdateParamsRule() {} - -// The action to perform when the rule matches. -type RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleAction string - -const ( - RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionExecute RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleAction = "execute" -) - -// The parameters configuring the rule's action. -type RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID param.Field[string] `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData param.Field[RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersMatchedData] `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides param.Field[RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverrides] `json:"overrides"` -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The configuration to use for matched data logging. -type RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey param.Field[string] `json:"public_key,required"` -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersMatchedData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A set of overrides to apply to the target ruleset. -type RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action param.Field[string] `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories param.Field[[]RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory] `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled param.Field[bool] `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules param.Field[[]RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRule] `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel param.Field[RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel] `json:"sensitivity_level"` -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverrides) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A category-level override -type RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category param.Field[string] `json:"category,required"` - // The action to override rules in the category with. - Action param.Field[string] `json:"action"` - // Whether to enable execution of rules in the category. - Enabled param.Field[bool] `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel param.Field[RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel] `json:"sensitivity_level"` -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The sensitivity level to use for rules in the category. -type RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string - -const ( - RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" -) - -// A rule-level override -type RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID param.Field[string] `json:"id,required"` - // The action to override the rule with. - Action param.Field[string] `json:"action"` - // Whether to enable execution of the rule. - Enabled param.Field[bool] `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold param.Field[int64] `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel param.Field[RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel] `json:"sensitivity_level"` -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The sensitivity level to use for the rule. -type RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string - -const ( - RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" -) - -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string - -const ( - RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" -) - -// An object configuring the rule's logging behavior. -type RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsExecuteRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RulesetPhaseUpdateParamsRulesRulesetsLogRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RulesetPhaseUpdateParamsRulesRulesetsLogRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[interface{}] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RulesetPhaseUpdateParamsRulesRulesetsLogRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsLogRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsLogRule) implementsRulesetPhaseUpdateParamsRule() {} - -// The action to perform when the rule matches. -type RulesetPhaseUpdateParamsRulesRulesetsLogRuleAction string - -const ( - RulesetPhaseUpdateParamsRulesRulesetsLogRuleActionLog RulesetPhaseUpdateParamsRulesRulesetsLogRuleAction = "log" -) - -// An object configuring the rule's logging behavior. -type RulesetPhaseUpdateParamsRulesRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsLogRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RulesetPhaseUpdateParamsRulesRulesetsSkipRule struct { - // The unique ID of the rule. - ID param.Field[string] `json:"id"` - // The action to perform when the rule matches. - Action param.Field[RulesetPhaseUpdateParamsRulesRulesetsSkipRuleAction] `json:"action"` - // The parameters configuring the rule's action. - ActionParameters param.Field[RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParameters] `json:"action_parameters"` - // An informative description of the rule. - Description param.Field[string] `json:"description"` - // Whether the rule should be executed. - Enabled param.Field[bool] `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression param.Field[string] `json:"expression"` - // An object configuring the rule's logging behavior. - Logging param.Field[RulesetPhaseUpdateParamsRulesRulesetsSkipRuleLogging] `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref param.Field[string] `json:"ref"` -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsSkipRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsSkipRule) implementsRulesetPhaseUpdateParamsRule() {} - -// The action to perform when the rule matches. -type RulesetPhaseUpdateParamsRulesRulesetsSkipRuleAction string - -const ( - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionSkip RulesetPhaseUpdateParamsRulesRulesetsSkipRuleAction = "skip" -) - -// The parameters configuring the rule's action. -type RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases param.Field[[]RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase] `json:"phases"` - // A list of legacy security products to skip the execution of. - Products param.Field[[]RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct] `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules param.Field[map[string][]string] `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset param.Field[RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset] `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets param.Field[[]string] `json:"rulesets"` -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParameters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A phase to skip the execution of. -type RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase string - -const ( - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseDDOSL4 RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseDDOSL7 RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -// The name of a legacy security product to skip the execution of. -type RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct string - -const ( - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductBic RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "bic" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductHot RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "hot" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductUABlock RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductWAF RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "waf" - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) - -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset string - -const ( - RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetPhaseUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset = "current" -) - -// An object configuring the rule's logging behavior. -type RulesetPhaseUpdateParamsRulesRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r RulesetPhaseUpdateParamsRulesRulesetsSkipRuleLogging) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The kind of the ruleset. -type RulesetPhaseUpdateParamsKind string - -const ( - RulesetPhaseUpdateParamsKindManaged RulesetPhaseUpdateParamsKind = "managed" - RulesetPhaseUpdateParamsKindCustom RulesetPhaseUpdateParamsKind = "custom" - RulesetPhaseUpdateParamsKindRoot RulesetPhaseUpdateParamsKind = "root" - RulesetPhaseUpdateParamsKindZone RulesetPhaseUpdateParamsKind = "zone" -) - -// The phase of the ruleset. -type RulesetPhaseUpdateParamsPhase string - -const ( - RulesetPhaseUpdateParamsPhaseDDOSL4 RulesetPhaseUpdateParamsPhase = "ddos_l4" - RulesetPhaseUpdateParamsPhaseDDOSL7 RulesetPhaseUpdateParamsPhase = "ddos_l7" - RulesetPhaseUpdateParamsPhaseHTTPConfigSettings RulesetPhaseUpdateParamsPhase = "http_config_settings" - RulesetPhaseUpdateParamsPhaseHTTPCustomErrors RulesetPhaseUpdateParamsPhase = "http_custom_errors" - RulesetPhaseUpdateParamsPhaseHTTPLogCustomFields RulesetPhaseUpdateParamsPhase = "http_log_custom_fields" - RulesetPhaseUpdateParamsPhaseHTTPRatelimit RulesetPhaseUpdateParamsPhase = "http_ratelimit" - RulesetPhaseUpdateParamsPhaseHTTPRequestCacheSettings RulesetPhaseUpdateParamsPhase = "http_request_cache_settings" - RulesetPhaseUpdateParamsPhaseHTTPRequestDynamicRedirect RulesetPhaseUpdateParamsPhase = "http_request_dynamic_redirect" - RulesetPhaseUpdateParamsPhaseHTTPRequestFirewallCustom RulesetPhaseUpdateParamsPhase = "http_request_firewall_custom" - RulesetPhaseUpdateParamsPhaseHTTPRequestFirewallManaged RulesetPhaseUpdateParamsPhase = "http_request_firewall_managed" - RulesetPhaseUpdateParamsPhaseHTTPRequestLateTransform RulesetPhaseUpdateParamsPhase = "http_request_late_transform" - RulesetPhaseUpdateParamsPhaseHTTPRequestOrigin RulesetPhaseUpdateParamsPhase = "http_request_origin" - RulesetPhaseUpdateParamsPhaseHTTPRequestRedirect RulesetPhaseUpdateParamsPhase = "http_request_redirect" - RulesetPhaseUpdateParamsPhaseHTTPRequestSanitize RulesetPhaseUpdateParamsPhase = "http_request_sanitize" - RulesetPhaseUpdateParamsPhaseHTTPRequestSbfm RulesetPhaseUpdateParamsPhase = "http_request_sbfm" - RulesetPhaseUpdateParamsPhaseHTTPRequestSelectConfiguration RulesetPhaseUpdateParamsPhase = "http_request_select_configuration" - RulesetPhaseUpdateParamsPhaseHTTPRequestTransform RulesetPhaseUpdateParamsPhase = "http_request_transform" - RulesetPhaseUpdateParamsPhaseHTTPResponseCompression RulesetPhaseUpdateParamsPhase = "http_response_compression" - RulesetPhaseUpdateParamsPhaseHTTPResponseFirewallManaged RulesetPhaseUpdateParamsPhase = "http_response_firewall_managed" - RulesetPhaseUpdateParamsPhaseHTTPResponseHeadersTransform RulesetPhaseUpdateParamsPhase = "http_response_headers_transform" - RulesetPhaseUpdateParamsPhaseMagicTransit RulesetPhaseUpdateParamsPhase = "magic_transit" - RulesetPhaseUpdateParamsPhaseMagicTransitIDsManaged RulesetPhaseUpdateParamsPhase = "magic_transit_ids_managed" - RulesetPhaseUpdateParamsPhaseMagicTransitManaged RulesetPhaseUpdateParamsPhase = "magic_transit_managed" -) - -// A response object. -type RulesetPhaseUpdateResponseEnvelope struct { - // A list of error messages. - Errors []RulesetPhaseUpdateResponseEnvelopeErrors `json:"errors,required"` - // A list of warning messages. - Messages []RulesetPhaseUpdateResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result RulesetPhaseUpdateResponse `json:"result,required"` - // Whether the API call was successful. - Success RulesetPhaseUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON rulesetPhaseUpdateResponseEnvelopeJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [RulesetPhaseUpdateResponseEnvelope] -type rulesetPhaseUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetPhaseUpdateResponseEnvelopeErrors struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetPhaseUpdateResponseEnvelopeErrorsSource `json:"source"` - JSON rulesetPhaseUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RulesetPhaseUpdateResponseEnvelopeErrors] -type rulesetPhaseUpdateResponseEnvelopeErrorsJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetPhaseUpdateResponseEnvelopeErrorsSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetPhaseUpdateResponseEnvelopeErrorsSourceJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseEnvelopeErrorsSourceJSON contains the JSON metadata -// for the struct [RulesetPhaseUpdateResponseEnvelopeErrorsSource] -type rulesetPhaseUpdateResponseEnvelopeErrorsSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseEnvelopeErrorsSourceJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetPhaseUpdateResponseEnvelopeMessages struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetPhaseUpdateResponseEnvelopeMessagesSource `json:"source"` - JSON rulesetPhaseUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [RulesetPhaseUpdateResponseEnvelopeMessages] -type rulesetPhaseUpdateResponseEnvelopeMessagesJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetPhaseUpdateResponseEnvelopeMessagesSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetPhaseUpdateResponseEnvelopeMessagesSourceJSON `json:"-"` -} - -// rulesetPhaseUpdateResponseEnvelopeMessagesSourceJSON contains the JSON metadata -// for the struct [RulesetPhaseUpdateResponseEnvelopeMessagesSource] -type rulesetPhaseUpdateResponseEnvelopeMessagesSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseUpdateResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseUpdateResponseEnvelopeMessagesSourceJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type RulesetPhaseUpdateResponseEnvelopeSuccess bool - -const ( - RulesetPhaseUpdateResponseEnvelopeSuccessTrue RulesetPhaseUpdateResponseEnvelopeSuccess = true -) - -type RulesetPhaseGetParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -// The phase of the ruleset. -type RulesetPhaseGetParamsRulesetPhase string - -const ( - RulesetPhaseGetParamsRulesetPhaseDDOSL4 RulesetPhaseGetParamsRulesetPhase = "ddos_l4" - RulesetPhaseGetParamsRulesetPhaseDDOSL7 RulesetPhaseGetParamsRulesetPhase = "ddos_l7" - RulesetPhaseGetParamsRulesetPhaseHTTPConfigSettings RulesetPhaseGetParamsRulesetPhase = "http_config_settings" - RulesetPhaseGetParamsRulesetPhaseHTTPCustomErrors RulesetPhaseGetParamsRulesetPhase = "http_custom_errors" - RulesetPhaseGetParamsRulesetPhaseHTTPLogCustomFields RulesetPhaseGetParamsRulesetPhase = "http_log_custom_fields" - RulesetPhaseGetParamsRulesetPhaseHTTPRatelimit RulesetPhaseGetParamsRulesetPhase = "http_ratelimit" - RulesetPhaseGetParamsRulesetPhaseHTTPRequestCacheSettings RulesetPhaseGetParamsRulesetPhase = "http_request_cache_settings" - RulesetPhaseGetParamsRulesetPhaseHTTPRequestDynamicRedirect RulesetPhaseGetParamsRulesetPhase = "http_request_dynamic_redirect" - RulesetPhaseGetParamsRulesetPhaseHTTPRequestFirewallCustom RulesetPhaseGetParamsRulesetPhase = "http_request_firewall_custom" - RulesetPhaseGetParamsRulesetPhaseHTTPRequestFirewallManaged RulesetPhaseGetParamsRulesetPhase = "http_request_firewall_managed" - RulesetPhaseGetParamsRulesetPhaseHTTPRequestLateTransform RulesetPhaseGetParamsRulesetPhase = "http_request_late_transform" - RulesetPhaseGetParamsRulesetPhaseHTTPRequestOrigin RulesetPhaseGetParamsRulesetPhase = "http_request_origin" - RulesetPhaseGetParamsRulesetPhaseHTTPRequestRedirect RulesetPhaseGetParamsRulesetPhase = "http_request_redirect" - RulesetPhaseGetParamsRulesetPhaseHTTPRequestSanitize RulesetPhaseGetParamsRulesetPhase = "http_request_sanitize" - RulesetPhaseGetParamsRulesetPhaseHTTPRequestSbfm RulesetPhaseGetParamsRulesetPhase = "http_request_sbfm" - RulesetPhaseGetParamsRulesetPhaseHTTPRequestSelectConfiguration RulesetPhaseGetParamsRulesetPhase = "http_request_select_configuration" - RulesetPhaseGetParamsRulesetPhaseHTTPRequestTransform RulesetPhaseGetParamsRulesetPhase = "http_request_transform" - RulesetPhaseGetParamsRulesetPhaseHTTPResponseCompression RulesetPhaseGetParamsRulesetPhase = "http_response_compression" - RulesetPhaseGetParamsRulesetPhaseHTTPResponseFirewallManaged RulesetPhaseGetParamsRulesetPhase = "http_response_firewall_managed" - RulesetPhaseGetParamsRulesetPhaseHTTPResponseHeadersTransform RulesetPhaseGetParamsRulesetPhase = "http_response_headers_transform" - RulesetPhaseGetParamsRulesetPhaseMagicTransit RulesetPhaseGetParamsRulesetPhase = "magic_transit" - RulesetPhaseGetParamsRulesetPhaseMagicTransitIDsManaged RulesetPhaseGetParamsRulesetPhase = "magic_transit_ids_managed" - RulesetPhaseGetParamsRulesetPhaseMagicTransitManaged RulesetPhaseGetParamsRulesetPhase = "magic_transit_managed" -) - -// A response object. -type RulesetPhaseGetResponseEnvelope struct { - // A list of error messages. - Errors []RulesetPhaseGetResponseEnvelopeErrors `json:"errors,required"` - // A list of warning messages. - Messages []RulesetPhaseGetResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result RulesetPhaseGetResponse `json:"result,required"` - // Whether the API call was successful. - Success RulesetPhaseGetResponseEnvelopeSuccess `json:"success,required"` - JSON rulesetPhaseGetResponseEnvelopeJSON `json:"-"` -} - -// rulesetPhaseGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [RulesetPhaseGetResponseEnvelope] -type rulesetPhaseGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetPhaseGetResponseEnvelopeErrors struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetPhaseGetResponseEnvelopeErrorsSource `json:"source"` - JSON rulesetPhaseGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// rulesetPhaseGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RulesetPhaseGetResponseEnvelopeErrors] -type rulesetPhaseGetResponseEnvelopeErrorsJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetPhaseGetResponseEnvelopeErrorsSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetPhaseGetResponseEnvelopeErrorsSourceJSON `json:"-"` -} - -// rulesetPhaseGetResponseEnvelopeErrorsSourceJSON contains the JSON metadata for -// the struct [RulesetPhaseGetResponseEnvelopeErrorsSource] -type rulesetPhaseGetResponseEnvelopeErrorsSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseEnvelopeErrorsSourceJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetPhaseGetResponseEnvelopeMessages struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetPhaseGetResponseEnvelopeMessagesSource `json:"source"` - JSON rulesetPhaseGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// rulesetPhaseGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RulesetPhaseGetResponseEnvelopeMessages] -type rulesetPhaseGetResponseEnvelopeMessagesJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetPhaseGetResponseEnvelopeMessagesSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetPhaseGetResponseEnvelopeMessagesSourceJSON `json:"-"` -} - -// rulesetPhaseGetResponseEnvelopeMessagesSourceJSON contains the JSON metadata for -// the struct [RulesetPhaseGetResponseEnvelopeMessagesSource] -type rulesetPhaseGetResponseEnvelopeMessagesSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseGetResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseGetResponseEnvelopeMessagesSourceJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type RulesetPhaseGetResponseEnvelopeSuccess bool - -const ( - RulesetPhaseGetResponseEnvelopeSuccessTrue RulesetPhaseGetResponseEnvelopeSuccess = true -) diff --git a/rulesetphase_test.go b/rulesetphase_test.go deleted file mode 100644 index 12bafc4405b..00000000000 --- a/rulesetphase_test.go +++ /dev/null @@ -1,133 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRulesetPhaseUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Rulesets.Phases.Update( - context.TODO(), - cloudflare.RulesetPhaseUpdateParamsRulesetPhaseHTTPRequestFirewallCustom, - cloudflare.RulesetPhaseUpdateParams{ - ID: cloudflare.F("2f2feab2026849078ba485f918791bdc"), - Rules: cloudflare.F([]cloudflare.RulesetPhaseUpdateParamsRule{cloudflare.RulesetPhaseUpdateParamsRulesRulesetsBlockRule(cloudflare.RulesetPhaseUpdateParamsRulesRulesetsBlockRule{ - Action: cloudflare.F(cloudflare.RulesetPhaseUpdateParamsRulesRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(cloudflare.RulesetPhaseUpdateParamsRulesRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(cloudflare.RulesetPhaseUpdateParamsRulesRulesetsBlockRuleActionParametersResponse{ - Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), - ContentType: cloudflare.F("application/json"), - StatusCode: cloudflare.F(int64(400)), - }), - }), - Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("ip.src ne 1.1.1.1"), - ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Logging: cloudflare.F(cloudflare.RulesetPhaseUpdateParamsRulesRulesetsBlockRuleLogging{ - Enabled: cloudflare.F(true), - }), - Ref: cloudflare.F("my_ref"), - }), cloudflare.RulesetPhaseUpdateParamsRulesRulesetsBlockRule(cloudflare.RulesetPhaseUpdateParamsRulesRulesetsBlockRule{ - Action: cloudflare.F(cloudflare.RulesetPhaseUpdateParamsRulesRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(cloudflare.RulesetPhaseUpdateParamsRulesRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(cloudflare.RulesetPhaseUpdateParamsRulesRulesetsBlockRuleActionParametersResponse{ - Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), - ContentType: cloudflare.F("application/json"), - StatusCode: cloudflare.F(int64(400)), - }), - }), - Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("ip.src ne 1.1.1.1"), - ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Logging: cloudflare.F(cloudflare.RulesetPhaseUpdateParamsRulesRulesetsBlockRuleLogging{ - Enabled: cloudflare.F(true), - }), - Ref: cloudflare.F("my_ref"), - }), cloudflare.RulesetPhaseUpdateParamsRulesRulesetsBlockRule(cloudflare.RulesetPhaseUpdateParamsRulesRulesetsBlockRule{ - Action: cloudflare.F(cloudflare.RulesetPhaseUpdateParamsRulesRulesetsBlockRuleActionBlock), - ActionParameters: cloudflare.F(cloudflare.RulesetPhaseUpdateParamsRulesRulesetsBlockRuleActionParameters{ - Response: cloudflare.F(cloudflare.RulesetPhaseUpdateParamsRulesRulesetsBlockRuleActionParametersResponse{ - Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), - ContentType: cloudflare.F("application/json"), - StatusCode: cloudflare.F(int64(400)), - }), - }), - Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("ip.src ne 1.1.1.1"), - ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), - Logging: cloudflare.F(cloudflare.RulesetPhaseUpdateParamsRulesRulesetsBlockRuleLogging{ - Enabled: cloudflare.F(true), - }), - Ref: cloudflare.F("my_ref"), - })}), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - Description: cloudflare.F("My ruleset to execute managed rulesets"), - Kind: cloudflare.F(cloudflare.RulesetPhaseUpdateParamsKindRoot), - Name: cloudflare.F("My ruleset"), - Phase: cloudflare.F(cloudflare.RulesetPhaseUpdateParamsPhaseHTTPRequestFirewallCustom), - }, - ) - 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 TestRulesetPhaseGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Rulesets.Phases.Get( - context.TODO(), - cloudflare.RulesetPhaseGetParamsRulesetPhaseHTTPRequestFirewallCustom, - cloudflare.RulesetPhaseGetParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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/rulesetphaseversion.go b/rulesetphaseversion.go deleted file mode 100644 index b3054a38ce9..00000000000 --- a/rulesetphaseversion.go +++ /dev/null @@ -1,1317 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// RulesetPhaseVersionService 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 [NewRulesetPhaseVersionService] -// method instead. -type RulesetPhaseVersionService struct { - Options []option.RequestOption -} - -// NewRulesetPhaseVersionService 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 NewRulesetPhaseVersionService(opts ...option.RequestOption) (r *RulesetPhaseVersionService) { - r = &RulesetPhaseVersionService{} - r.Options = opts - return -} - -// Fetches the versions of an account or zone entry point ruleset. -func (r *RulesetPhaseVersionService) List(ctx context.Context, rulesetPhase RulesetPhaseVersionListParamsRulesetPhase, query RulesetPhaseVersionListParams, opts ...option.RequestOption) (res *[]RulesetPhaseVersionListResponse, err error) { - opts = append(r.Options[:], opts...) - var env RulesetPhaseVersionListResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/rulesets/phases/%v/entrypoint/versions", accountOrZone, accountOrZoneID, rulesetPhase) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a specific version of an account or zone entry point ruleset. -func (r *RulesetPhaseVersionService) Get(ctx context.Context, rulesetPhase RulesetPhaseVersionGetParamsRulesetPhase, rulesetVersion string, query RulesetPhaseVersionGetParams, opts ...option.RequestOption) (res *RulesetPhaseVersionGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RulesetPhaseVersionGetResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/rulesets/phases/%v/entrypoint/versions/%s", accountOrZone, accountOrZoneID, rulesetPhase, rulesetVersion) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// A ruleset object. -type RulesetPhaseVersionListResponse struct { - // The kind of the ruleset. - Kind RulesetPhaseVersionListResponseKind `json:"kind,required"` - // The human-readable name of the ruleset. - Name string `json:"name,required"` - // The phase of the ruleset. - Phase RulesetPhaseVersionListResponsePhase `json:"phase,required"` - // The unique ID of the ruleset. - ID string `json:"id"` - // An informative description of the ruleset. - Description string `json:"description"` - // The timestamp of when the ruleset was last modified. - LastUpdated time.Time `json:"last_updated" format:"date-time"` - // The version of the ruleset. - Version string `json:"version"` - JSON rulesetPhaseVersionListResponseJSON `json:"-"` -} - -// rulesetPhaseVersionListResponseJSON contains the JSON metadata for the struct -// [RulesetPhaseVersionListResponse] -type rulesetPhaseVersionListResponseJSON struct { - Kind apijson.Field - Name apijson.Field - Phase apijson.Field - ID apijson.Field - Description apijson.Field - LastUpdated apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionListResponseJSON) RawJSON() string { - return r.raw -} - -// The kind of the ruleset. -type RulesetPhaseVersionListResponseKind string - -const ( - RulesetPhaseVersionListResponseKindManaged RulesetPhaseVersionListResponseKind = "managed" - RulesetPhaseVersionListResponseKindCustom RulesetPhaseVersionListResponseKind = "custom" - RulesetPhaseVersionListResponseKindRoot RulesetPhaseVersionListResponseKind = "root" - RulesetPhaseVersionListResponseKindZone RulesetPhaseVersionListResponseKind = "zone" -) - -// The phase of the ruleset. -type RulesetPhaseVersionListResponsePhase string - -const ( - RulesetPhaseVersionListResponsePhaseDDOSL4 RulesetPhaseVersionListResponsePhase = "ddos_l4" - RulesetPhaseVersionListResponsePhaseDDOSL7 RulesetPhaseVersionListResponsePhase = "ddos_l7" - RulesetPhaseVersionListResponsePhaseHTTPConfigSettings RulesetPhaseVersionListResponsePhase = "http_config_settings" - RulesetPhaseVersionListResponsePhaseHTTPCustomErrors RulesetPhaseVersionListResponsePhase = "http_custom_errors" - RulesetPhaseVersionListResponsePhaseHTTPLogCustomFields RulesetPhaseVersionListResponsePhase = "http_log_custom_fields" - RulesetPhaseVersionListResponsePhaseHTTPRatelimit RulesetPhaseVersionListResponsePhase = "http_ratelimit" - RulesetPhaseVersionListResponsePhaseHTTPRequestCacheSettings RulesetPhaseVersionListResponsePhase = "http_request_cache_settings" - RulesetPhaseVersionListResponsePhaseHTTPRequestDynamicRedirect RulesetPhaseVersionListResponsePhase = "http_request_dynamic_redirect" - RulesetPhaseVersionListResponsePhaseHTTPRequestFirewallCustom RulesetPhaseVersionListResponsePhase = "http_request_firewall_custom" - RulesetPhaseVersionListResponsePhaseHTTPRequestFirewallManaged RulesetPhaseVersionListResponsePhase = "http_request_firewall_managed" - RulesetPhaseVersionListResponsePhaseHTTPRequestLateTransform RulesetPhaseVersionListResponsePhase = "http_request_late_transform" - RulesetPhaseVersionListResponsePhaseHTTPRequestOrigin RulesetPhaseVersionListResponsePhase = "http_request_origin" - RulesetPhaseVersionListResponsePhaseHTTPRequestRedirect RulesetPhaseVersionListResponsePhase = "http_request_redirect" - RulesetPhaseVersionListResponsePhaseHTTPRequestSanitize RulesetPhaseVersionListResponsePhase = "http_request_sanitize" - RulesetPhaseVersionListResponsePhaseHTTPRequestSbfm RulesetPhaseVersionListResponsePhase = "http_request_sbfm" - RulesetPhaseVersionListResponsePhaseHTTPRequestSelectConfiguration RulesetPhaseVersionListResponsePhase = "http_request_select_configuration" - RulesetPhaseVersionListResponsePhaseHTTPRequestTransform RulesetPhaseVersionListResponsePhase = "http_request_transform" - RulesetPhaseVersionListResponsePhaseHTTPResponseCompression RulesetPhaseVersionListResponsePhase = "http_response_compression" - RulesetPhaseVersionListResponsePhaseHTTPResponseFirewallManaged RulesetPhaseVersionListResponsePhase = "http_response_firewall_managed" - RulesetPhaseVersionListResponsePhaseHTTPResponseHeadersTransform RulesetPhaseVersionListResponsePhase = "http_response_headers_transform" - RulesetPhaseVersionListResponsePhaseMagicTransit RulesetPhaseVersionListResponsePhase = "magic_transit" - RulesetPhaseVersionListResponsePhaseMagicTransitIDsManaged RulesetPhaseVersionListResponsePhase = "magic_transit_ids_managed" - RulesetPhaseVersionListResponsePhaseMagicTransitManaged RulesetPhaseVersionListResponsePhase = "magic_transit_managed" -) - -// A result. -type RulesetPhaseVersionGetResponse struct { - // The unique ID of the ruleset. - ID string `json:"id,required"` - // The kind of the ruleset. - Kind RulesetPhaseVersionGetResponseKind `json:"kind,required"` - // The timestamp of when the ruleset was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The human-readable name of the ruleset. - Name string `json:"name,required"` - // The phase of the ruleset. - Phase RulesetPhaseVersionGetResponsePhase `json:"phase,required"` - // The list of rules in the ruleset. - Rules []RulesetPhaseVersionGetResponseRule `json:"rules,required"` - // The version of the ruleset. - Version string `json:"version,required"` - // An informative description of the ruleset. - Description string `json:"description"` - JSON rulesetPhaseVersionGetResponseJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseJSON contains the JSON metadata for the struct -// [RulesetPhaseVersionGetResponse] -type rulesetPhaseVersionGetResponseJSON struct { - ID apijson.Field - Kind apijson.Field - LastUpdated apijson.Field - Name apijson.Field - Phase apijson.Field - Rules apijson.Field - Version apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseJSON) RawJSON() string { - return r.raw -} - -// The kind of the ruleset. -type RulesetPhaseVersionGetResponseKind string - -const ( - RulesetPhaseVersionGetResponseKindManaged RulesetPhaseVersionGetResponseKind = "managed" - RulesetPhaseVersionGetResponseKindCustom RulesetPhaseVersionGetResponseKind = "custom" - RulesetPhaseVersionGetResponseKindRoot RulesetPhaseVersionGetResponseKind = "root" - RulesetPhaseVersionGetResponseKindZone RulesetPhaseVersionGetResponseKind = "zone" -) - -// The phase of the ruleset. -type RulesetPhaseVersionGetResponsePhase string - -const ( - RulesetPhaseVersionGetResponsePhaseDDOSL4 RulesetPhaseVersionGetResponsePhase = "ddos_l4" - RulesetPhaseVersionGetResponsePhaseDDOSL7 RulesetPhaseVersionGetResponsePhase = "ddos_l7" - RulesetPhaseVersionGetResponsePhaseHTTPConfigSettings RulesetPhaseVersionGetResponsePhase = "http_config_settings" - RulesetPhaseVersionGetResponsePhaseHTTPCustomErrors RulesetPhaseVersionGetResponsePhase = "http_custom_errors" - RulesetPhaseVersionGetResponsePhaseHTTPLogCustomFields RulesetPhaseVersionGetResponsePhase = "http_log_custom_fields" - RulesetPhaseVersionGetResponsePhaseHTTPRatelimit RulesetPhaseVersionGetResponsePhase = "http_ratelimit" - RulesetPhaseVersionGetResponsePhaseHTTPRequestCacheSettings RulesetPhaseVersionGetResponsePhase = "http_request_cache_settings" - RulesetPhaseVersionGetResponsePhaseHTTPRequestDynamicRedirect RulesetPhaseVersionGetResponsePhase = "http_request_dynamic_redirect" - RulesetPhaseVersionGetResponsePhaseHTTPRequestFirewallCustom RulesetPhaseVersionGetResponsePhase = "http_request_firewall_custom" - RulesetPhaseVersionGetResponsePhaseHTTPRequestFirewallManaged RulesetPhaseVersionGetResponsePhase = "http_request_firewall_managed" - RulesetPhaseVersionGetResponsePhaseHTTPRequestLateTransform RulesetPhaseVersionGetResponsePhase = "http_request_late_transform" - RulesetPhaseVersionGetResponsePhaseHTTPRequestOrigin RulesetPhaseVersionGetResponsePhase = "http_request_origin" - RulesetPhaseVersionGetResponsePhaseHTTPRequestRedirect RulesetPhaseVersionGetResponsePhase = "http_request_redirect" - RulesetPhaseVersionGetResponsePhaseHTTPRequestSanitize RulesetPhaseVersionGetResponsePhase = "http_request_sanitize" - RulesetPhaseVersionGetResponsePhaseHTTPRequestSbfm RulesetPhaseVersionGetResponsePhase = "http_request_sbfm" - RulesetPhaseVersionGetResponsePhaseHTTPRequestSelectConfiguration RulesetPhaseVersionGetResponsePhase = "http_request_select_configuration" - RulesetPhaseVersionGetResponsePhaseHTTPRequestTransform RulesetPhaseVersionGetResponsePhase = "http_request_transform" - RulesetPhaseVersionGetResponsePhaseHTTPResponseCompression RulesetPhaseVersionGetResponsePhase = "http_response_compression" - RulesetPhaseVersionGetResponsePhaseHTTPResponseFirewallManaged RulesetPhaseVersionGetResponsePhase = "http_response_firewall_managed" - RulesetPhaseVersionGetResponsePhaseHTTPResponseHeadersTransform RulesetPhaseVersionGetResponsePhase = "http_response_headers_transform" - RulesetPhaseVersionGetResponsePhaseMagicTransit RulesetPhaseVersionGetResponsePhase = "magic_transit" - RulesetPhaseVersionGetResponsePhaseMagicTransitIDsManaged RulesetPhaseVersionGetResponsePhase = "magic_transit_ids_managed" - RulesetPhaseVersionGetResponsePhaseMagicTransitManaged RulesetPhaseVersionGetResponsePhase = "magic_transit_managed" -) - -// Union satisfied by [RulesetPhaseVersionGetResponseRulesRulesetsBlockRule], -// [RulesetPhaseVersionGetResponseRulesRulesetsExecuteRule], -// [RulesetPhaseVersionGetResponseRulesRulesetsLogRule] or -// [RulesetPhaseVersionGetResponseRulesRulesetsSkipRule]. -type RulesetPhaseVersionGetResponseRule interface { - implementsRulesetPhaseVersionGetResponseRule() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*RulesetPhaseVersionGetResponseRule)(nil)).Elem(), - "action", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetPhaseVersionGetResponseRulesRulesetsBlockRule{}), - DiscriminatorValue: "block", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetPhaseVersionGetResponseRulesRulesetsExecuteRule{}), - DiscriminatorValue: "execute", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetPhaseVersionGetResponseRulesRulesetsLogRule{}), - DiscriminatorValue: "log", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetPhaseVersionGetResponseRulesRulesetsSkipRule{}), - DiscriminatorValue: "skip", - }, - ) -} - -type RulesetPhaseVersionGetResponseRulesRulesetsBlockRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetPhaseVersionGetResponseRulesRulesetsBlockRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetPhaseVersionGetResponseRulesRulesetsBlockRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetPhaseVersionGetResponseRulesRulesetsBlockRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetPhaseVersionGetResponseRulesRulesetsBlockRuleJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseRulesRulesetsBlockRuleJSON contains the JSON -// metadata for the struct [RulesetPhaseVersionGetResponseRulesRulesetsBlockRule] -type rulesetPhaseVersionGetResponseRulesRulesetsBlockRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseRulesRulesetsBlockRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseRulesRulesetsBlockRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetPhaseVersionGetResponseRulesRulesetsBlockRule) implementsRulesetPhaseVersionGetResponseRule() { -} - -// The action to perform when the rule matches. -type RulesetPhaseVersionGetResponseRulesRulesetsBlockRuleAction string - -const ( - RulesetPhaseVersionGetResponseRulesRulesetsBlockRuleActionBlock RulesetPhaseVersionGetResponseRulesRulesetsBlockRuleAction = "block" -) - -// The parameters configuring the rule's action. -type RulesetPhaseVersionGetResponseRulesRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response RulesetPhaseVersionGetResponseRulesRulesetsBlockRuleActionParametersResponse `json:"response"` - JSON rulesetPhaseVersionGetResponseRulesRulesetsBlockRuleActionParametersJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseRulesRulesetsBlockRuleActionParametersJSON -// contains the JSON metadata for the struct -// [RulesetPhaseVersionGetResponseRulesRulesetsBlockRuleActionParameters] -type rulesetPhaseVersionGetResponseRulesRulesetsBlockRuleActionParametersJSON struct { - Response apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseRulesRulesetsBlockRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseRulesRulesetsBlockRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The response to show when the block is applied. -type RulesetPhaseVersionGetResponseRulesRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content string `json:"content,required"` - // The type of the content to return. - ContentType string `json:"content_type,required"` - // The status code to return. - StatusCode int64 `json:"status_code,required"` - JSON rulesetPhaseVersionGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON -// contains the JSON metadata for the struct -// [RulesetPhaseVersionGetResponseRulesRulesetsBlockRuleActionParametersResponse] -type rulesetPhaseVersionGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON struct { - Content apijson.Field - ContentType apijson.Field - StatusCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseRulesRulesetsBlockRuleActionParametersResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON) RawJSON() string { - return r.raw -} - -// An object configuring the rule's logging behavior. -type RulesetPhaseVersionGetResponseRulesRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetPhaseVersionGetResponseRulesRulesetsBlockRuleLoggingJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseRulesRulesetsBlockRuleLoggingJSON contains the -// JSON metadata for the struct -// [RulesetPhaseVersionGetResponseRulesRulesetsBlockRuleLogging] -type rulesetPhaseVersionGetResponseRulesRulesetsBlockRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseRulesRulesetsBlockRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseRulesRulesetsBlockRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetPhaseVersionGetResponseRulesRulesetsExecuteRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleJSON contains the JSON -// metadata for the struct [RulesetPhaseVersionGetResponseRulesRulesetsExecuteRule] -type rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseRulesRulesetsExecuteRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetPhaseVersionGetResponseRulesRulesetsExecuteRule) implementsRulesetPhaseVersionGetResponseRule() { -} - -// The action to perform when the rule matches. -type RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleAction string - -const ( - RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionExecute RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleAction = "execute" -) - -// The parameters configuring the rule's action. -type RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID string `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverrides `json:"overrides"` - JSON rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersJSON -// contains the JSON metadata for the struct -// [RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParameters] -type rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersJSON struct { - ID apijson.Field - MatchedData apijson.Field - Overrides apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The configuration to use for matched data logging. -type RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey string `json:"public_key,required"` - JSON rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON -// contains the JSON metadata for the struct -// [RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData] -type rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON struct { - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON) RawJSON() string { - return r.raw -} - -// A set of overrides to apply to the target ruleset. -type RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action string `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories []RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled bool `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules []RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON -// contains the JSON metadata for the struct -// [RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverrides] -type rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON struct { - Action apijson.Field - Categories apijson.Field - Enabled apijson.Field - Rules apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverrides) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON) RawJSON() string { - return r.raw -} - -// A category-level override -type RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category string `json:"category,required"` - // The action to override rules in the category with. - Action string `json:"action"` - // Whether to enable execution of rules in the category. - Enabled bool `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON -// contains the JSON metadata for the struct -// [RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory] -type rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON struct { - Category apijson.Field - Action apijson.Field - Enabled apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for rules in the category. -type RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string - -const ( - RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" -) - -// A rule-level override -type RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID string `json:"id,required"` - // The action to override the rule with. - Action string `json:"action"` - // Whether to enable execution of the rule. - Enabled bool `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold int64 `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON -// contains the JSON metadata for the struct -// [RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule] -type rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON struct { - ID apijson.Field - Action apijson.Field - Enabled apijson.Field - ScoreThreshold apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for the rule. -type RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string - -const ( - RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" -) - -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string - -const ( - RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" -) - -// An object configuring the rule's logging behavior. -type RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleLoggingJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleLoggingJSON contains the -// JSON metadata for the struct -// [RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleLogging] -type rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseRulesRulesetsExecuteRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetPhaseVersionGetResponseRulesRulesetsLogRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetPhaseVersionGetResponseRulesRulesetsLogRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters interface{} `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetPhaseVersionGetResponseRulesRulesetsLogRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetPhaseVersionGetResponseRulesRulesetsLogRuleJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseRulesRulesetsLogRuleJSON contains the JSON -// metadata for the struct [RulesetPhaseVersionGetResponseRulesRulesetsLogRule] -type rulesetPhaseVersionGetResponseRulesRulesetsLogRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseRulesRulesetsLogRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseRulesRulesetsLogRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetPhaseVersionGetResponseRulesRulesetsLogRule) implementsRulesetPhaseVersionGetResponseRule() { -} - -// The action to perform when the rule matches. -type RulesetPhaseVersionGetResponseRulesRulesetsLogRuleAction string - -const ( - RulesetPhaseVersionGetResponseRulesRulesetsLogRuleActionLog RulesetPhaseVersionGetResponseRulesRulesetsLogRuleAction = "log" -) - -// An object configuring the rule's logging behavior. -type RulesetPhaseVersionGetResponseRulesRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetPhaseVersionGetResponseRulesRulesetsLogRuleLoggingJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseRulesRulesetsLogRuleLoggingJSON contains the JSON -// metadata for the struct -// [RulesetPhaseVersionGetResponseRulesRulesetsLogRuleLogging] -type rulesetPhaseVersionGetResponseRulesRulesetsLogRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseRulesRulesetsLogRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseRulesRulesetsLogRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetPhaseVersionGetResponseRulesRulesetsSkipRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetPhaseVersionGetResponseRulesRulesetsSkipRuleJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseRulesRulesetsSkipRuleJSON contains the JSON -// metadata for the struct [RulesetPhaseVersionGetResponseRulesRulesetsSkipRule] -type rulesetPhaseVersionGetResponseRulesRulesetsSkipRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseRulesRulesetsSkipRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseRulesRulesetsSkipRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetPhaseVersionGetResponseRulesRulesetsSkipRule) implementsRulesetPhaseVersionGetResponseRule() { -} - -// The action to perform when the rule matches. -type RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleAction string - -const ( - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionSkip RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleAction = "skip" -) - -// The parameters configuring the rule's action. -type RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases []RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase `json:"phases"` - // A list of legacy security products to skip the execution of. - Products []RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersProduct `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules map[string][]string `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersRuleset `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets []string `json:"rulesets"` - JSON rulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersJSON contains -// the JSON metadata for the struct -// [RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParameters] -type rulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersJSON struct { - Phases apijson.Field - Products apijson.Field - Rules apijson.Field - Ruleset apijson.Field - Rulesets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// A phase to skip the execution of. -type RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase string - -const ( - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL4 RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL7 RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -// The name of a legacy security product to skip the execution of. -type RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersProduct string - -const ( - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersProductBic RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersProduct = "bic" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersProductHot RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersProduct = "hot" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersProductUABlock RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersProductWAF RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersProduct = "waf" - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) - -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersRuleset string - -const ( - RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleActionParametersRuleset = "current" -) - -// An object configuring the rule's logging behavior. -type RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetPhaseVersionGetResponseRulesRulesetsSkipRuleLoggingJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseRulesRulesetsSkipRuleLoggingJSON contains the JSON -// metadata for the struct -// [RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleLogging] -type rulesetPhaseVersionGetResponseRulesRulesetsSkipRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseRulesRulesetsSkipRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseRulesRulesetsSkipRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetPhaseVersionListParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -// The phase of the ruleset. -type RulesetPhaseVersionListParamsRulesetPhase string - -const ( - RulesetPhaseVersionListParamsRulesetPhaseDDOSL4 RulesetPhaseVersionListParamsRulesetPhase = "ddos_l4" - RulesetPhaseVersionListParamsRulesetPhaseDDOSL7 RulesetPhaseVersionListParamsRulesetPhase = "ddos_l7" - RulesetPhaseVersionListParamsRulesetPhaseHTTPConfigSettings RulesetPhaseVersionListParamsRulesetPhase = "http_config_settings" - RulesetPhaseVersionListParamsRulesetPhaseHTTPCustomErrors RulesetPhaseVersionListParamsRulesetPhase = "http_custom_errors" - RulesetPhaseVersionListParamsRulesetPhaseHTTPLogCustomFields RulesetPhaseVersionListParamsRulesetPhase = "http_log_custom_fields" - RulesetPhaseVersionListParamsRulesetPhaseHTTPRatelimit RulesetPhaseVersionListParamsRulesetPhase = "http_ratelimit" - RulesetPhaseVersionListParamsRulesetPhaseHTTPRequestCacheSettings RulesetPhaseVersionListParamsRulesetPhase = "http_request_cache_settings" - RulesetPhaseVersionListParamsRulesetPhaseHTTPRequestDynamicRedirect RulesetPhaseVersionListParamsRulesetPhase = "http_request_dynamic_redirect" - RulesetPhaseVersionListParamsRulesetPhaseHTTPRequestFirewallCustom RulesetPhaseVersionListParamsRulesetPhase = "http_request_firewall_custom" - RulesetPhaseVersionListParamsRulesetPhaseHTTPRequestFirewallManaged RulesetPhaseVersionListParamsRulesetPhase = "http_request_firewall_managed" - RulesetPhaseVersionListParamsRulesetPhaseHTTPRequestLateTransform RulesetPhaseVersionListParamsRulesetPhase = "http_request_late_transform" - RulesetPhaseVersionListParamsRulesetPhaseHTTPRequestOrigin RulesetPhaseVersionListParamsRulesetPhase = "http_request_origin" - RulesetPhaseVersionListParamsRulesetPhaseHTTPRequestRedirect RulesetPhaseVersionListParamsRulesetPhase = "http_request_redirect" - RulesetPhaseVersionListParamsRulesetPhaseHTTPRequestSanitize RulesetPhaseVersionListParamsRulesetPhase = "http_request_sanitize" - RulesetPhaseVersionListParamsRulesetPhaseHTTPRequestSbfm RulesetPhaseVersionListParamsRulesetPhase = "http_request_sbfm" - RulesetPhaseVersionListParamsRulesetPhaseHTTPRequestSelectConfiguration RulesetPhaseVersionListParamsRulesetPhase = "http_request_select_configuration" - RulesetPhaseVersionListParamsRulesetPhaseHTTPRequestTransform RulesetPhaseVersionListParamsRulesetPhase = "http_request_transform" - RulesetPhaseVersionListParamsRulesetPhaseHTTPResponseCompression RulesetPhaseVersionListParamsRulesetPhase = "http_response_compression" - RulesetPhaseVersionListParamsRulesetPhaseHTTPResponseFirewallManaged RulesetPhaseVersionListParamsRulesetPhase = "http_response_firewall_managed" - RulesetPhaseVersionListParamsRulesetPhaseHTTPResponseHeadersTransform RulesetPhaseVersionListParamsRulesetPhase = "http_response_headers_transform" - RulesetPhaseVersionListParamsRulesetPhaseMagicTransit RulesetPhaseVersionListParamsRulesetPhase = "magic_transit" - RulesetPhaseVersionListParamsRulesetPhaseMagicTransitIDsManaged RulesetPhaseVersionListParamsRulesetPhase = "magic_transit_ids_managed" - RulesetPhaseVersionListParamsRulesetPhaseMagicTransitManaged RulesetPhaseVersionListParamsRulesetPhase = "magic_transit_managed" -) - -// A response object. -type RulesetPhaseVersionListResponseEnvelope struct { - // A list of error messages. - Errors []RulesetPhaseVersionListResponseEnvelopeErrors `json:"errors,required"` - // A list of warning messages. - Messages []RulesetPhaseVersionListResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result []RulesetPhaseVersionListResponse `json:"result,required"` - // Whether the API call was successful. - Success RulesetPhaseVersionListResponseEnvelopeSuccess `json:"success,required"` - JSON rulesetPhaseVersionListResponseEnvelopeJSON `json:"-"` -} - -// rulesetPhaseVersionListResponseEnvelopeJSON contains the JSON metadata for the -// struct [RulesetPhaseVersionListResponseEnvelope] -type rulesetPhaseVersionListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetPhaseVersionListResponseEnvelopeErrors struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetPhaseVersionListResponseEnvelopeErrorsSource `json:"source"` - JSON rulesetPhaseVersionListResponseEnvelopeErrorsJSON `json:"-"` -} - -// rulesetPhaseVersionListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [RulesetPhaseVersionListResponseEnvelopeErrors] -type rulesetPhaseVersionListResponseEnvelopeErrorsJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetPhaseVersionListResponseEnvelopeErrorsSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetPhaseVersionListResponseEnvelopeErrorsSourceJSON `json:"-"` -} - -// rulesetPhaseVersionListResponseEnvelopeErrorsSourceJSON contains the JSON -// metadata for the struct [RulesetPhaseVersionListResponseEnvelopeErrorsSource] -type rulesetPhaseVersionListResponseEnvelopeErrorsSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionListResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionListResponseEnvelopeErrorsSourceJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetPhaseVersionListResponseEnvelopeMessages struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetPhaseVersionListResponseEnvelopeMessagesSource `json:"source"` - JSON rulesetPhaseVersionListResponseEnvelopeMessagesJSON `json:"-"` -} - -// rulesetPhaseVersionListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [RulesetPhaseVersionListResponseEnvelopeMessages] -type rulesetPhaseVersionListResponseEnvelopeMessagesJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetPhaseVersionListResponseEnvelopeMessagesSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetPhaseVersionListResponseEnvelopeMessagesSourceJSON `json:"-"` -} - -// rulesetPhaseVersionListResponseEnvelopeMessagesSourceJSON contains the JSON -// metadata for the struct [RulesetPhaseVersionListResponseEnvelopeMessagesSource] -type rulesetPhaseVersionListResponseEnvelopeMessagesSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionListResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionListResponseEnvelopeMessagesSourceJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type RulesetPhaseVersionListResponseEnvelopeSuccess bool - -const ( - RulesetPhaseVersionListResponseEnvelopeSuccessTrue RulesetPhaseVersionListResponseEnvelopeSuccess = true -) - -type RulesetPhaseVersionGetParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -// The phase of the ruleset. -type RulesetPhaseVersionGetParamsRulesetPhase string - -const ( - RulesetPhaseVersionGetParamsRulesetPhaseDDOSL4 RulesetPhaseVersionGetParamsRulesetPhase = "ddos_l4" - RulesetPhaseVersionGetParamsRulesetPhaseDDOSL7 RulesetPhaseVersionGetParamsRulesetPhase = "ddos_l7" - RulesetPhaseVersionGetParamsRulesetPhaseHTTPConfigSettings RulesetPhaseVersionGetParamsRulesetPhase = "http_config_settings" - RulesetPhaseVersionGetParamsRulesetPhaseHTTPCustomErrors RulesetPhaseVersionGetParamsRulesetPhase = "http_custom_errors" - RulesetPhaseVersionGetParamsRulesetPhaseHTTPLogCustomFields RulesetPhaseVersionGetParamsRulesetPhase = "http_log_custom_fields" - RulesetPhaseVersionGetParamsRulesetPhaseHTTPRatelimit RulesetPhaseVersionGetParamsRulesetPhase = "http_ratelimit" - RulesetPhaseVersionGetParamsRulesetPhaseHTTPRequestCacheSettings RulesetPhaseVersionGetParamsRulesetPhase = "http_request_cache_settings" - RulesetPhaseVersionGetParamsRulesetPhaseHTTPRequestDynamicRedirect RulesetPhaseVersionGetParamsRulesetPhase = "http_request_dynamic_redirect" - RulesetPhaseVersionGetParamsRulesetPhaseHTTPRequestFirewallCustom RulesetPhaseVersionGetParamsRulesetPhase = "http_request_firewall_custom" - RulesetPhaseVersionGetParamsRulesetPhaseHTTPRequestFirewallManaged RulesetPhaseVersionGetParamsRulesetPhase = "http_request_firewall_managed" - RulesetPhaseVersionGetParamsRulesetPhaseHTTPRequestLateTransform RulesetPhaseVersionGetParamsRulesetPhase = "http_request_late_transform" - RulesetPhaseVersionGetParamsRulesetPhaseHTTPRequestOrigin RulesetPhaseVersionGetParamsRulesetPhase = "http_request_origin" - RulesetPhaseVersionGetParamsRulesetPhaseHTTPRequestRedirect RulesetPhaseVersionGetParamsRulesetPhase = "http_request_redirect" - RulesetPhaseVersionGetParamsRulesetPhaseHTTPRequestSanitize RulesetPhaseVersionGetParamsRulesetPhase = "http_request_sanitize" - RulesetPhaseVersionGetParamsRulesetPhaseHTTPRequestSbfm RulesetPhaseVersionGetParamsRulesetPhase = "http_request_sbfm" - RulesetPhaseVersionGetParamsRulesetPhaseHTTPRequestSelectConfiguration RulesetPhaseVersionGetParamsRulesetPhase = "http_request_select_configuration" - RulesetPhaseVersionGetParamsRulesetPhaseHTTPRequestTransform RulesetPhaseVersionGetParamsRulesetPhase = "http_request_transform" - RulesetPhaseVersionGetParamsRulesetPhaseHTTPResponseCompression RulesetPhaseVersionGetParamsRulesetPhase = "http_response_compression" - RulesetPhaseVersionGetParamsRulesetPhaseHTTPResponseFirewallManaged RulesetPhaseVersionGetParamsRulesetPhase = "http_response_firewall_managed" - RulesetPhaseVersionGetParamsRulesetPhaseHTTPResponseHeadersTransform RulesetPhaseVersionGetParamsRulesetPhase = "http_response_headers_transform" - RulesetPhaseVersionGetParamsRulesetPhaseMagicTransit RulesetPhaseVersionGetParamsRulesetPhase = "magic_transit" - RulesetPhaseVersionGetParamsRulesetPhaseMagicTransitIDsManaged RulesetPhaseVersionGetParamsRulesetPhase = "magic_transit_ids_managed" - RulesetPhaseVersionGetParamsRulesetPhaseMagicTransitManaged RulesetPhaseVersionGetParamsRulesetPhase = "magic_transit_managed" -) - -// A response object. -type RulesetPhaseVersionGetResponseEnvelope struct { - // A list of error messages. - Errors []RulesetPhaseVersionGetResponseEnvelopeErrors `json:"errors,required"` - // A list of warning messages. - Messages []RulesetPhaseVersionGetResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result RulesetPhaseVersionGetResponse `json:"result,required"` - // Whether the API call was successful. - Success RulesetPhaseVersionGetResponseEnvelopeSuccess `json:"success,required"` - JSON rulesetPhaseVersionGetResponseEnvelopeJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [RulesetPhaseVersionGetResponseEnvelope] -type rulesetPhaseVersionGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetPhaseVersionGetResponseEnvelopeErrors struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetPhaseVersionGetResponseEnvelopeErrorsSource `json:"source"` - JSON rulesetPhaseVersionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [RulesetPhaseVersionGetResponseEnvelopeErrors] -type rulesetPhaseVersionGetResponseEnvelopeErrorsJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetPhaseVersionGetResponseEnvelopeErrorsSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetPhaseVersionGetResponseEnvelopeErrorsSourceJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseEnvelopeErrorsSourceJSON contains the JSON -// metadata for the struct [RulesetPhaseVersionGetResponseEnvelopeErrorsSource] -type rulesetPhaseVersionGetResponseEnvelopeErrorsSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseEnvelopeErrorsSourceJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetPhaseVersionGetResponseEnvelopeMessages struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetPhaseVersionGetResponseEnvelopeMessagesSource `json:"source"` - JSON rulesetPhaseVersionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [RulesetPhaseVersionGetResponseEnvelopeMessages] -type rulesetPhaseVersionGetResponseEnvelopeMessagesJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetPhaseVersionGetResponseEnvelopeMessagesSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetPhaseVersionGetResponseEnvelopeMessagesSourceJSON `json:"-"` -} - -// rulesetPhaseVersionGetResponseEnvelopeMessagesSourceJSON contains the JSON -// metadata for the struct [RulesetPhaseVersionGetResponseEnvelopeMessagesSource] -type rulesetPhaseVersionGetResponseEnvelopeMessagesSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetPhaseVersionGetResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetPhaseVersionGetResponseEnvelopeMessagesSourceJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type RulesetPhaseVersionGetResponseEnvelopeSuccess bool - -const ( - RulesetPhaseVersionGetResponseEnvelopeSuccessTrue RulesetPhaseVersionGetResponseEnvelopeSuccess = true -) diff --git a/rulesetphaseversion_test.go b/rulesetphaseversion_test.go deleted file mode 100644 index 353dd93908e..00000000000 --- a/rulesetphaseversion_test.go +++ /dev/null @@ -1,77 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRulesetPhaseVersionListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Rulesets.Phases.Versions.List( - context.TODO(), - cloudflare.RulesetPhaseVersionListParamsRulesetPhaseHTTPRequestFirewallCustom, - cloudflare.RulesetPhaseVersionListParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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 TestRulesetPhaseVersionGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Rulesets.Phases.Versions.Get( - context.TODO(), - cloudflare.RulesetPhaseVersionGetParamsRulesetPhaseHTTPRequestFirewallCustom, - "1", - cloudflare.RulesetPhaseVersionGetParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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/rulesetrule.go b/rulesetrule.go deleted file mode 100644 index 5c3249bd1ed..00000000000 --- a/rulesetrule.go +++ /dev/null @@ -1,3036 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// RulesetRuleService 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 [NewRulesetRuleService] method -// instead. -type RulesetRuleService struct { - Options []option.RequestOption -} - -// NewRulesetRuleService 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 NewRulesetRuleService(opts ...option.RequestOption) (r *RulesetRuleService) { - r = &RulesetRuleService{} - r.Options = opts - return -} - -// Adds a new rule to an account or zone ruleset. The rule will be added to the end -// of the existing list of rules in the ruleset by default. -func (r *RulesetRuleService) New(ctx context.Context, rulesetID string, params RulesetRuleNewParams, opts ...option.RequestOption) (res *RulesetRuleNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env RulesetRuleNewResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/rulesets/%s/rules", accountOrZone, accountOrZoneID, rulesetID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes an existing rule from an account or zone ruleset. -func (r *RulesetRuleService) Delete(ctx context.Context, rulesetID string, ruleID string, body RulesetRuleDeleteParams, opts ...option.RequestOption) (res *RulesetRuleDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env RulesetRuleDeleteResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if body.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = body.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = body.ZoneID - } - path := fmt.Sprintf("%s/%s/rulesets/%s/rules/%s", accountOrZone, accountOrZoneID, rulesetID, ruleID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates an existing rule in an account ruleset. -func (r *RulesetRuleService) Edit(ctx context.Context, rulesetID string, ruleID string, params RulesetRuleEditParams, opts ...option.RequestOption) (res *RulesetRuleEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env RulesetRuleEditResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/rulesets/%s/rules/%s", accountOrZone, accountOrZoneID, rulesetID, ruleID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// A result. -type RulesetRuleNewResponse struct { - // The unique ID of the ruleset. - ID string `json:"id,required"` - // The kind of the ruleset. - Kind RulesetRuleNewResponseKind `json:"kind,required"` - // The timestamp of when the ruleset was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The human-readable name of the ruleset. - Name string `json:"name,required"` - // The phase of the ruleset. - Phase RulesetRuleNewResponsePhase `json:"phase,required"` - // The list of rules in the ruleset. - Rules []RulesetRuleNewResponseRule `json:"rules,required"` - // The version of the ruleset. - Version string `json:"version,required"` - // An informative description of the ruleset. - Description string `json:"description"` - JSON rulesetRuleNewResponseJSON `json:"-"` -} - -// rulesetRuleNewResponseJSON contains the JSON metadata for the struct -// [RulesetRuleNewResponse] -type rulesetRuleNewResponseJSON struct { - ID apijson.Field - Kind apijson.Field - LastUpdated apijson.Field - Name apijson.Field - Phase apijson.Field - Rules apijson.Field - Version apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseJSON) RawJSON() string { - return r.raw -} - -// The kind of the ruleset. -type RulesetRuleNewResponseKind string - -const ( - RulesetRuleNewResponseKindManaged RulesetRuleNewResponseKind = "managed" - RulesetRuleNewResponseKindCustom RulesetRuleNewResponseKind = "custom" - RulesetRuleNewResponseKindRoot RulesetRuleNewResponseKind = "root" - RulesetRuleNewResponseKindZone RulesetRuleNewResponseKind = "zone" -) - -// The phase of the ruleset. -type RulesetRuleNewResponsePhase string - -const ( - RulesetRuleNewResponsePhaseDDOSL4 RulesetRuleNewResponsePhase = "ddos_l4" - RulesetRuleNewResponsePhaseDDOSL7 RulesetRuleNewResponsePhase = "ddos_l7" - RulesetRuleNewResponsePhaseHTTPConfigSettings RulesetRuleNewResponsePhase = "http_config_settings" - RulesetRuleNewResponsePhaseHTTPCustomErrors RulesetRuleNewResponsePhase = "http_custom_errors" - RulesetRuleNewResponsePhaseHTTPLogCustomFields RulesetRuleNewResponsePhase = "http_log_custom_fields" - RulesetRuleNewResponsePhaseHTTPRatelimit RulesetRuleNewResponsePhase = "http_ratelimit" - RulesetRuleNewResponsePhaseHTTPRequestCacheSettings RulesetRuleNewResponsePhase = "http_request_cache_settings" - RulesetRuleNewResponsePhaseHTTPRequestDynamicRedirect RulesetRuleNewResponsePhase = "http_request_dynamic_redirect" - RulesetRuleNewResponsePhaseHTTPRequestFirewallCustom RulesetRuleNewResponsePhase = "http_request_firewall_custom" - RulesetRuleNewResponsePhaseHTTPRequestFirewallManaged RulesetRuleNewResponsePhase = "http_request_firewall_managed" - RulesetRuleNewResponsePhaseHTTPRequestLateTransform RulesetRuleNewResponsePhase = "http_request_late_transform" - RulesetRuleNewResponsePhaseHTTPRequestOrigin RulesetRuleNewResponsePhase = "http_request_origin" - RulesetRuleNewResponsePhaseHTTPRequestRedirect RulesetRuleNewResponsePhase = "http_request_redirect" - RulesetRuleNewResponsePhaseHTTPRequestSanitize RulesetRuleNewResponsePhase = "http_request_sanitize" - RulesetRuleNewResponsePhaseHTTPRequestSbfm RulesetRuleNewResponsePhase = "http_request_sbfm" - RulesetRuleNewResponsePhaseHTTPRequestSelectConfiguration RulesetRuleNewResponsePhase = "http_request_select_configuration" - RulesetRuleNewResponsePhaseHTTPRequestTransform RulesetRuleNewResponsePhase = "http_request_transform" - RulesetRuleNewResponsePhaseHTTPResponseCompression RulesetRuleNewResponsePhase = "http_response_compression" - RulesetRuleNewResponsePhaseHTTPResponseFirewallManaged RulesetRuleNewResponsePhase = "http_response_firewall_managed" - RulesetRuleNewResponsePhaseHTTPResponseHeadersTransform RulesetRuleNewResponsePhase = "http_response_headers_transform" - RulesetRuleNewResponsePhaseMagicTransit RulesetRuleNewResponsePhase = "magic_transit" - RulesetRuleNewResponsePhaseMagicTransitIDsManaged RulesetRuleNewResponsePhase = "magic_transit_ids_managed" - RulesetRuleNewResponsePhaseMagicTransitManaged RulesetRuleNewResponsePhase = "magic_transit_managed" -) - -// Union satisfied by [RulesetRuleNewResponseRulesRulesetsBlockRule], -// [RulesetRuleNewResponseRulesRulesetsExecuteRule], -// [RulesetRuleNewResponseRulesRulesetsLogRule] or -// [RulesetRuleNewResponseRulesRulesetsSkipRule]. -type RulesetRuleNewResponseRule interface { - implementsRulesetRuleNewResponseRule() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*RulesetRuleNewResponseRule)(nil)).Elem(), - "action", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetRuleNewResponseRulesRulesetsBlockRule{}), - DiscriminatorValue: "block", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetRuleNewResponseRulesRulesetsExecuteRule{}), - DiscriminatorValue: "execute", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetRuleNewResponseRulesRulesetsLogRule{}), - DiscriminatorValue: "log", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetRuleNewResponseRulesRulesetsSkipRule{}), - DiscriminatorValue: "skip", - }, - ) -} - -type RulesetRuleNewResponseRulesRulesetsBlockRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetRuleNewResponseRulesRulesetsBlockRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetRuleNewResponseRulesRulesetsBlockRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetRuleNewResponseRulesRulesetsBlockRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetRuleNewResponseRulesRulesetsBlockRuleJSON `json:"-"` -} - -// rulesetRuleNewResponseRulesRulesetsBlockRuleJSON contains the JSON metadata for -// the struct [RulesetRuleNewResponseRulesRulesetsBlockRule] -type rulesetRuleNewResponseRulesRulesetsBlockRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseRulesRulesetsBlockRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseRulesRulesetsBlockRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetRuleNewResponseRulesRulesetsBlockRule) implementsRulesetRuleNewResponseRule() {} - -// The action to perform when the rule matches. -type RulesetRuleNewResponseRulesRulesetsBlockRuleAction string - -const ( - RulesetRuleNewResponseRulesRulesetsBlockRuleActionBlock RulesetRuleNewResponseRulesRulesetsBlockRuleAction = "block" -) - -// The parameters configuring the rule's action. -type RulesetRuleNewResponseRulesRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response RulesetRuleNewResponseRulesRulesetsBlockRuleActionParametersResponse `json:"response"` - JSON rulesetRuleNewResponseRulesRulesetsBlockRuleActionParametersJSON `json:"-"` -} - -// rulesetRuleNewResponseRulesRulesetsBlockRuleActionParametersJSON contains the -// JSON metadata for the struct -// [RulesetRuleNewResponseRulesRulesetsBlockRuleActionParameters] -type rulesetRuleNewResponseRulesRulesetsBlockRuleActionParametersJSON struct { - Response apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseRulesRulesetsBlockRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseRulesRulesetsBlockRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The response to show when the block is applied. -type RulesetRuleNewResponseRulesRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content string `json:"content,required"` - // The type of the content to return. - ContentType string `json:"content_type,required"` - // The status code to return. - StatusCode int64 `json:"status_code,required"` - JSON rulesetRuleNewResponseRulesRulesetsBlockRuleActionParametersResponseJSON `json:"-"` -} - -// rulesetRuleNewResponseRulesRulesetsBlockRuleActionParametersResponseJSON -// contains the JSON metadata for the struct -// [RulesetRuleNewResponseRulesRulesetsBlockRuleActionParametersResponse] -type rulesetRuleNewResponseRulesRulesetsBlockRuleActionParametersResponseJSON struct { - Content apijson.Field - ContentType apijson.Field - StatusCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseRulesRulesetsBlockRuleActionParametersResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseRulesRulesetsBlockRuleActionParametersResponseJSON) RawJSON() string { - return r.raw -} - -// An object configuring the rule's logging behavior. -type RulesetRuleNewResponseRulesRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetRuleNewResponseRulesRulesetsBlockRuleLoggingJSON `json:"-"` -} - -// rulesetRuleNewResponseRulesRulesetsBlockRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetRuleNewResponseRulesRulesetsBlockRuleLogging] -type rulesetRuleNewResponseRulesRulesetsBlockRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseRulesRulesetsBlockRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseRulesRulesetsBlockRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetRuleNewResponseRulesRulesetsExecuteRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetRuleNewResponseRulesRulesetsExecuteRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetRuleNewResponseRulesRulesetsExecuteRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetRuleNewResponseRulesRulesetsExecuteRuleJSON `json:"-"` -} - -// rulesetRuleNewResponseRulesRulesetsExecuteRuleJSON contains the JSON metadata -// for the struct [RulesetRuleNewResponseRulesRulesetsExecuteRule] -type rulesetRuleNewResponseRulesRulesetsExecuteRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseRulesRulesetsExecuteRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseRulesRulesetsExecuteRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetRuleNewResponseRulesRulesetsExecuteRule) implementsRulesetRuleNewResponseRule() {} - -// The action to perform when the rule matches. -type RulesetRuleNewResponseRulesRulesetsExecuteRuleAction string - -const ( - RulesetRuleNewResponseRulesRulesetsExecuteRuleActionExecute RulesetRuleNewResponseRulesRulesetsExecuteRuleAction = "execute" -) - -// The parameters configuring the rule's action. -type RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID string `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersMatchedData `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverrides `json:"overrides"` - JSON rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersJSON `json:"-"` -} - -// rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersJSON contains the -// JSON metadata for the struct -// [RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParameters] -type rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersJSON struct { - ID apijson.Field - MatchedData apijson.Field - Overrides apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The configuration to use for matched data logging. -type RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey string `json:"public_key,required"` - JSON rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON `json:"-"` -} - -// rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON -// contains the JSON metadata for the struct -// [RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersMatchedData] -type rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON struct { - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersMatchedData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON) RawJSON() string { - return r.raw -} - -// A set of overrides to apply to the target ruleset. -type RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action string `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories []RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled bool `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules []RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRule `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON `json:"-"` -} - -// rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON -// contains the JSON metadata for the struct -// [RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverrides] -type rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON struct { - Action apijson.Field - Categories apijson.Field - Enabled apijson.Field - Rules apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverrides) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON) RawJSON() string { - return r.raw -} - -// A category-level override -type RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category string `json:"category,required"` - // The action to override rules in the category with. - Action string `json:"action"` - // Whether to enable execution of rules in the category. - Enabled bool `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON `json:"-"` -} - -// rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON -// contains the JSON metadata for the struct -// [RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory] -type rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON struct { - Category apijson.Field - Action apijson.Field - Enabled apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for rules in the category. -type RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string - -const ( - RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" -) - -// A rule-level override -type RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID string `json:"id,required"` - // The action to override the rule with. - Action string `json:"action"` - // Whether to enable execution of the rule. - Enabled bool `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold int64 `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON `json:"-"` -} - -// rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON -// contains the JSON metadata for the struct -// [RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRule] -type rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON struct { - ID apijson.Field - Action apijson.Field - Enabled apijson.Field - ScoreThreshold apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for the rule. -type RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string - -const ( - RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" -) - -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string - -const ( - RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetRuleNewResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" -) - -// An object configuring the rule's logging behavior. -type RulesetRuleNewResponseRulesRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetRuleNewResponseRulesRulesetsExecuteRuleLoggingJSON `json:"-"` -} - -// rulesetRuleNewResponseRulesRulesetsExecuteRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetRuleNewResponseRulesRulesetsExecuteRuleLogging] -type rulesetRuleNewResponseRulesRulesetsExecuteRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseRulesRulesetsExecuteRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseRulesRulesetsExecuteRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetRuleNewResponseRulesRulesetsLogRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetRuleNewResponseRulesRulesetsLogRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters interface{} `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetRuleNewResponseRulesRulesetsLogRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetRuleNewResponseRulesRulesetsLogRuleJSON `json:"-"` -} - -// rulesetRuleNewResponseRulesRulesetsLogRuleJSON contains the JSON metadata for -// the struct [RulesetRuleNewResponseRulesRulesetsLogRule] -type rulesetRuleNewResponseRulesRulesetsLogRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseRulesRulesetsLogRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseRulesRulesetsLogRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetRuleNewResponseRulesRulesetsLogRule) implementsRulesetRuleNewResponseRule() {} - -// The action to perform when the rule matches. -type RulesetRuleNewResponseRulesRulesetsLogRuleAction string - -const ( - RulesetRuleNewResponseRulesRulesetsLogRuleActionLog RulesetRuleNewResponseRulesRulesetsLogRuleAction = "log" -) - -// An object configuring the rule's logging behavior. -type RulesetRuleNewResponseRulesRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetRuleNewResponseRulesRulesetsLogRuleLoggingJSON `json:"-"` -} - -// rulesetRuleNewResponseRulesRulesetsLogRuleLoggingJSON contains the JSON metadata -// for the struct [RulesetRuleNewResponseRulesRulesetsLogRuleLogging] -type rulesetRuleNewResponseRulesRulesetsLogRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseRulesRulesetsLogRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseRulesRulesetsLogRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetRuleNewResponseRulesRulesetsSkipRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetRuleNewResponseRulesRulesetsSkipRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetRuleNewResponseRulesRulesetsSkipRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetRuleNewResponseRulesRulesetsSkipRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetRuleNewResponseRulesRulesetsSkipRuleJSON `json:"-"` -} - -// rulesetRuleNewResponseRulesRulesetsSkipRuleJSON contains the JSON metadata for -// the struct [RulesetRuleNewResponseRulesRulesetsSkipRule] -type rulesetRuleNewResponseRulesRulesetsSkipRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseRulesRulesetsSkipRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseRulesRulesetsSkipRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetRuleNewResponseRulesRulesetsSkipRule) implementsRulesetRuleNewResponseRule() {} - -// The action to perform when the rule matches. -type RulesetRuleNewResponseRulesRulesetsSkipRuleAction string - -const ( - RulesetRuleNewResponseRulesRulesetsSkipRuleActionSkip RulesetRuleNewResponseRulesRulesetsSkipRuleAction = "skip" -) - -// The parameters configuring the rule's action. -type RulesetRuleNewResponseRulesRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases []RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase `json:"phases"` - // A list of legacy security products to skip the execution of. - Products []RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersProduct `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules map[string][]string `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersRuleset `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets []string `json:"rulesets"` - JSON rulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersJSON `json:"-"` -} - -// rulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersJSON contains the -// JSON metadata for the struct -// [RulesetRuleNewResponseRulesRulesetsSkipRuleActionParameters] -type rulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersJSON struct { - Phases apijson.Field - Products apijson.Field - Rules apijson.Field - Ruleset apijson.Field - Rulesets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseRulesRulesetsSkipRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// A phase to skip the execution of. -type RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase string - -const ( - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL4 RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL7 RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -// The name of a legacy security product to skip the execution of. -type RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersProduct string - -const ( - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersProductBic RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersProduct = "bic" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersProductHot RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersProduct = "hot" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersProductUABlock RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersProductWAF RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersProduct = "waf" - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) - -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersRuleset string - -const ( - RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetRuleNewResponseRulesRulesetsSkipRuleActionParametersRuleset = "current" -) - -// An object configuring the rule's logging behavior. -type RulesetRuleNewResponseRulesRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetRuleNewResponseRulesRulesetsSkipRuleLoggingJSON `json:"-"` -} - -// rulesetRuleNewResponseRulesRulesetsSkipRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetRuleNewResponseRulesRulesetsSkipRuleLogging] -type rulesetRuleNewResponseRulesRulesetsSkipRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseRulesRulesetsSkipRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseRulesRulesetsSkipRuleLoggingJSON) RawJSON() string { - return r.raw -} - -// A result. -type RulesetRuleDeleteResponse struct { - // The unique ID of the ruleset. - ID string `json:"id,required"` - // The kind of the ruleset. - Kind RulesetRuleDeleteResponseKind `json:"kind,required"` - // The timestamp of when the ruleset was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The human-readable name of the ruleset. - Name string `json:"name,required"` - // The phase of the ruleset. - Phase RulesetRuleDeleteResponsePhase `json:"phase,required"` - // The list of rules in the ruleset. - Rules []RulesetRuleDeleteResponseRule `json:"rules,required"` - // The version of the ruleset. - Version string `json:"version,required"` - // An informative description of the ruleset. - Description string `json:"description"` - JSON rulesetRuleDeleteResponseJSON `json:"-"` -} - -// rulesetRuleDeleteResponseJSON contains the JSON metadata for the struct -// [RulesetRuleDeleteResponse] -type rulesetRuleDeleteResponseJSON struct { - ID apijson.Field - Kind apijson.Field - LastUpdated apijson.Field - Name apijson.Field - Phase apijson.Field - Rules apijson.Field - Version apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// The kind of the ruleset. -type RulesetRuleDeleteResponseKind string - -const ( - RulesetRuleDeleteResponseKindManaged RulesetRuleDeleteResponseKind = "managed" - RulesetRuleDeleteResponseKindCustom RulesetRuleDeleteResponseKind = "custom" - RulesetRuleDeleteResponseKindRoot RulesetRuleDeleteResponseKind = "root" - RulesetRuleDeleteResponseKindZone RulesetRuleDeleteResponseKind = "zone" -) - -// The phase of the ruleset. -type RulesetRuleDeleteResponsePhase string - -const ( - RulesetRuleDeleteResponsePhaseDDOSL4 RulesetRuleDeleteResponsePhase = "ddos_l4" - RulesetRuleDeleteResponsePhaseDDOSL7 RulesetRuleDeleteResponsePhase = "ddos_l7" - RulesetRuleDeleteResponsePhaseHTTPConfigSettings RulesetRuleDeleteResponsePhase = "http_config_settings" - RulesetRuleDeleteResponsePhaseHTTPCustomErrors RulesetRuleDeleteResponsePhase = "http_custom_errors" - RulesetRuleDeleteResponsePhaseHTTPLogCustomFields RulesetRuleDeleteResponsePhase = "http_log_custom_fields" - RulesetRuleDeleteResponsePhaseHTTPRatelimit RulesetRuleDeleteResponsePhase = "http_ratelimit" - RulesetRuleDeleteResponsePhaseHTTPRequestCacheSettings RulesetRuleDeleteResponsePhase = "http_request_cache_settings" - RulesetRuleDeleteResponsePhaseHTTPRequestDynamicRedirect RulesetRuleDeleteResponsePhase = "http_request_dynamic_redirect" - RulesetRuleDeleteResponsePhaseHTTPRequestFirewallCustom RulesetRuleDeleteResponsePhase = "http_request_firewall_custom" - RulesetRuleDeleteResponsePhaseHTTPRequestFirewallManaged RulesetRuleDeleteResponsePhase = "http_request_firewall_managed" - RulesetRuleDeleteResponsePhaseHTTPRequestLateTransform RulesetRuleDeleteResponsePhase = "http_request_late_transform" - RulesetRuleDeleteResponsePhaseHTTPRequestOrigin RulesetRuleDeleteResponsePhase = "http_request_origin" - RulesetRuleDeleteResponsePhaseHTTPRequestRedirect RulesetRuleDeleteResponsePhase = "http_request_redirect" - RulesetRuleDeleteResponsePhaseHTTPRequestSanitize RulesetRuleDeleteResponsePhase = "http_request_sanitize" - RulesetRuleDeleteResponsePhaseHTTPRequestSbfm RulesetRuleDeleteResponsePhase = "http_request_sbfm" - RulesetRuleDeleteResponsePhaseHTTPRequestSelectConfiguration RulesetRuleDeleteResponsePhase = "http_request_select_configuration" - RulesetRuleDeleteResponsePhaseHTTPRequestTransform RulesetRuleDeleteResponsePhase = "http_request_transform" - RulesetRuleDeleteResponsePhaseHTTPResponseCompression RulesetRuleDeleteResponsePhase = "http_response_compression" - RulesetRuleDeleteResponsePhaseHTTPResponseFirewallManaged RulesetRuleDeleteResponsePhase = "http_response_firewall_managed" - RulesetRuleDeleteResponsePhaseHTTPResponseHeadersTransform RulesetRuleDeleteResponsePhase = "http_response_headers_transform" - RulesetRuleDeleteResponsePhaseMagicTransit RulesetRuleDeleteResponsePhase = "magic_transit" - RulesetRuleDeleteResponsePhaseMagicTransitIDsManaged RulesetRuleDeleteResponsePhase = "magic_transit_ids_managed" - RulesetRuleDeleteResponsePhaseMagicTransitManaged RulesetRuleDeleteResponsePhase = "magic_transit_managed" -) - -// Union satisfied by [RulesetRuleDeleteResponseRulesRulesetsBlockRule], -// [RulesetRuleDeleteResponseRulesRulesetsExecuteRule], -// [RulesetRuleDeleteResponseRulesRulesetsLogRule] or -// [RulesetRuleDeleteResponseRulesRulesetsSkipRule]. -type RulesetRuleDeleteResponseRule interface { - implementsRulesetRuleDeleteResponseRule() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*RulesetRuleDeleteResponseRule)(nil)).Elem(), - "action", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetRuleDeleteResponseRulesRulesetsBlockRule{}), - DiscriminatorValue: "block", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetRuleDeleteResponseRulesRulesetsExecuteRule{}), - DiscriminatorValue: "execute", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetRuleDeleteResponseRulesRulesetsLogRule{}), - DiscriminatorValue: "log", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetRuleDeleteResponseRulesRulesetsSkipRule{}), - DiscriminatorValue: "skip", - }, - ) -} - -type RulesetRuleDeleteResponseRulesRulesetsBlockRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetRuleDeleteResponseRulesRulesetsBlockRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetRuleDeleteResponseRulesRulesetsBlockRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetRuleDeleteResponseRulesRulesetsBlockRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetRuleDeleteResponseRulesRulesetsBlockRuleJSON `json:"-"` -} - -// rulesetRuleDeleteResponseRulesRulesetsBlockRuleJSON contains the JSON metadata -// for the struct [RulesetRuleDeleteResponseRulesRulesetsBlockRule] -type rulesetRuleDeleteResponseRulesRulesetsBlockRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseRulesRulesetsBlockRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseRulesRulesetsBlockRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetRuleDeleteResponseRulesRulesetsBlockRule) implementsRulesetRuleDeleteResponseRule() {} - -// The action to perform when the rule matches. -type RulesetRuleDeleteResponseRulesRulesetsBlockRuleAction string - -const ( - RulesetRuleDeleteResponseRulesRulesetsBlockRuleActionBlock RulesetRuleDeleteResponseRulesRulesetsBlockRuleAction = "block" -) - -// The parameters configuring the rule's action. -type RulesetRuleDeleteResponseRulesRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response RulesetRuleDeleteResponseRulesRulesetsBlockRuleActionParametersResponse `json:"response"` - JSON rulesetRuleDeleteResponseRulesRulesetsBlockRuleActionParametersJSON `json:"-"` -} - -// rulesetRuleDeleteResponseRulesRulesetsBlockRuleActionParametersJSON contains the -// JSON metadata for the struct -// [RulesetRuleDeleteResponseRulesRulesetsBlockRuleActionParameters] -type rulesetRuleDeleteResponseRulesRulesetsBlockRuleActionParametersJSON struct { - Response apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseRulesRulesetsBlockRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseRulesRulesetsBlockRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The response to show when the block is applied. -type RulesetRuleDeleteResponseRulesRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content string `json:"content,required"` - // The type of the content to return. - ContentType string `json:"content_type,required"` - // The status code to return. - StatusCode int64 `json:"status_code,required"` - JSON rulesetRuleDeleteResponseRulesRulesetsBlockRuleActionParametersResponseJSON `json:"-"` -} - -// rulesetRuleDeleteResponseRulesRulesetsBlockRuleActionParametersResponseJSON -// contains the JSON metadata for the struct -// [RulesetRuleDeleteResponseRulesRulesetsBlockRuleActionParametersResponse] -type rulesetRuleDeleteResponseRulesRulesetsBlockRuleActionParametersResponseJSON struct { - Content apijson.Field - ContentType apijson.Field - StatusCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseRulesRulesetsBlockRuleActionParametersResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseRulesRulesetsBlockRuleActionParametersResponseJSON) RawJSON() string { - return r.raw -} - -// An object configuring the rule's logging behavior. -type RulesetRuleDeleteResponseRulesRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetRuleDeleteResponseRulesRulesetsBlockRuleLoggingJSON `json:"-"` -} - -// rulesetRuleDeleteResponseRulesRulesetsBlockRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetRuleDeleteResponseRulesRulesetsBlockRuleLogging] -type rulesetRuleDeleteResponseRulesRulesetsBlockRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseRulesRulesetsBlockRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseRulesRulesetsBlockRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetRuleDeleteResponseRulesRulesetsExecuteRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetRuleDeleteResponseRulesRulesetsExecuteRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetRuleDeleteResponseRulesRulesetsExecuteRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetRuleDeleteResponseRulesRulesetsExecuteRuleJSON `json:"-"` -} - -// rulesetRuleDeleteResponseRulesRulesetsExecuteRuleJSON contains the JSON metadata -// for the struct [RulesetRuleDeleteResponseRulesRulesetsExecuteRule] -type rulesetRuleDeleteResponseRulesRulesetsExecuteRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseRulesRulesetsExecuteRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseRulesRulesetsExecuteRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetRuleDeleteResponseRulesRulesetsExecuteRule) implementsRulesetRuleDeleteResponseRule() { -} - -// The action to perform when the rule matches. -type RulesetRuleDeleteResponseRulesRulesetsExecuteRuleAction string - -const ( - RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionExecute RulesetRuleDeleteResponseRulesRulesetsExecuteRuleAction = "execute" -) - -// The parameters configuring the rule's action. -type RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID string `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersMatchedData `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverrides `json:"overrides"` - JSON rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersJSON `json:"-"` -} - -// rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersJSON contains -// the JSON metadata for the struct -// [RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParameters] -type rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersJSON struct { - ID apijson.Field - MatchedData apijson.Field - Overrides apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The configuration to use for matched data logging. -type RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey string `json:"public_key,required"` - JSON rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON `json:"-"` -} - -// rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON -// contains the JSON metadata for the struct -// [RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersMatchedData] -type rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON struct { - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersMatchedData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON) RawJSON() string { - return r.raw -} - -// A set of overrides to apply to the target ruleset. -type RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action string `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories []RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled bool `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules []RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesRule `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON `json:"-"` -} - -// rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON -// contains the JSON metadata for the struct -// [RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverrides] -type rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON struct { - Action apijson.Field - Categories apijson.Field - Enabled apijson.Field - Rules apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverrides) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON) RawJSON() string { - return r.raw -} - -// A category-level override -type RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category string `json:"category,required"` - // The action to override rules in the category with. - Action string `json:"action"` - // Whether to enable execution of rules in the category. - Enabled bool `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON `json:"-"` -} - -// rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON -// contains the JSON metadata for the struct -// [RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory] -type rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON struct { - Category apijson.Field - Action apijson.Field - Enabled apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for rules in the category. -type RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string - -const ( - RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" -) - -// A rule-level override -type RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID string `json:"id,required"` - // The action to override the rule with. - Action string `json:"action"` - // Whether to enable execution of the rule. - Enabled bool `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold int64 `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON `json:"-"` -} - -// rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON -// contains the JSON metadata for the struct -// [RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesRule] -type rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON struct { - ID apijson.Field - Action apijson.Field - Enabled apijson.Field - ScoreThreshold apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for the rule. -type RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string - -const ( - RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" -) - -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string - -const ( - RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetRuleDeleteResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" -) - -// An object configuring the rule's logging behavior. -type RulesetRuleDeleteResponseRulesRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetRuleDeleteResponseRulesRulesetsExecuteRuleLoggingJSON `json:"-"` -} - -// rulesetRuleDeleteResponseRulesRulesetsExecuteRuleLoggingJSON contains the JSON -// metadata for the struct -// [RulesetRuleDeleteResponseRulesRulesetsExecuteRuleLogging] -type rulesetRuleDeleteResponseRulesRulesetsExecuteRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseRulesRulesetsExecuteRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseRulesRulesetsExecuteRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetRuleDeleteResponseRulesRulesetsLogRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetRuleDeleteResponseRulesRulesetsLogRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters interface{} `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetRuleDeleteResponseRulesRulesetsLogRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetRuleDeleteResponseRulesRulesetsLogRuleJSON `json:"-"` -} - -// rulesetRuleDeleteResponseRulesRulesetsLogRuleJSON contains the JSON metadata for -// the struct [RulesetRuleDeleteResponseRulesRulesetsLogRule] -type rulesetRuleDeleteResponseRulesRulesetsLogRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseRulesRulesetsLogRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseRulesRulesetsLogRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetRuleDeleteResponseRulesRulesetsLogRule) implementsRulesetRuleDeleteResponseRule() {} - -// The action to perform when the rule matches. -type RulesetRuleDeleteResponseRulesRulesetsLogRuleAction string - -const ( - RulesetRuleDeleteResponseRulesRulesetsLogRuleActionLog RulesetRuleDeleteResponseRulesRulesetsLogRuleAction = "log" -) - -// An object configuring the rule's logging behavior. -type RulesetRuleDeleteResponseRulesRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetRuleDeleteResponseRulesRulesetsLogRuleLoggingJSON `json:"-"` -} - -// rulesetRuleDeleteResponseRulesRulesetsLogRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetRuleDeleteResponseRulesRulesetsLogRuleLogging] -type rulesetRuleDeleteResponseRulesRulesetsLogRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseRulesRulesetsLogRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseRulesRulesetsLogRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetRuleDeleteResponseRulesRulesetsSkipRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetRuleDeleteResponseRulesRulesetsSkipRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetRuleDeleteResponseRulesRulesetsSkipRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetRuleDeleteResponseRulesRulesetsSkipRuleJSON `json:"-"` -} - -// rulesetRuleDeleteResponseRulesRulesetsSkipRuleJSON contains the JSON metadata -// for the struct [RulesetRuleDeleteResponseRulesRulesetsSkipRule] -type rulesetRuleDeleteResponseRulesRulesetsSkipRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseRulesRulesetsSkipRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseRulesRulesetsSkipRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetRuleDeleteResponseRulesRulesetsSkipRule) implementsRulesetRuleDeleteResponseRule() {} - -// The action to perform when the rule matches. -type RulesetRuleDeleteResponseRulesRulesetsSkipRuleAction string - -const ( - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionSkip RulesetRuleDeleteResponseRulesRulesetsSkipRuleAction = "skip" -) - -// The parameters configuring the rule's action. -type RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases []RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase `json:"phases"` - // A list of legacy security products to skip the execution of. - Products []RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersProduct `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules map[string][]string `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersRuleset `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets []string `json:"rulesets"` - JSON rulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersJSON `json:"-"` -} - -// rulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersJSON contains the -// JSON metadata for the struct -// [RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParameters] -type rulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersJSON struct { - Phases apijson.Field - Products apijson.Field - Rules apijson.Field - Ruleset apijson.Field - Rulesets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// A phase to skip the execution of. -type RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase string - -const ( - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL4 RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL7 RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -// The name of a legacy security product to skip the execution of. -type RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersProduct string - -const ( - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersProductBic RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersProduct = "bic" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersProductHot RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersProduct = "hot" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersProductUABlock RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersProductWAF RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersProduct = "waf" - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) - -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersRuleset string - -const ( - RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetRuleDeleteResponseRulesRulesetsSkipRuleActionParametersRuleset = "current" -) - -// An object configuring the rule's logging behavior. -type RulesetRuleDeleteResponseRulesRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetRuleDeleteResponseRulesRulesetsSkipRuleLoggingJSON `json:"-"` -} - -// rulesetRuleDeleteResponseRulesRulesetsSkipRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetRuleDeleteResponseRulesRulesetsSkipRuleLogging] -type rulesetRuleDeleteResponseRulesRulesetsSkipRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseRulesRulesetsSkipRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseRulesRulesetsSkipRuleLoggingJSON) RawJSON() string { - return r.raw -} - -// A result. -type RulesetRuleEditResponse struct { - // The unique ID of the ruleset. - ID string `json:"id,required"` - // The kind of the ruleset. - Kind RulesetRuleEditResponseKind `json:"kind,required"` - // The timestamp of when the ruleset was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The human-readable name of the ruleset. - Name string `json:"name,required"` - // The phase of the ruleset. - Phase RulesetRuleEditResponsePhase `json:"phase,required"` - // The list of rules in the ruleset. - Rules []RulesetRuleEditResponseRule `json:"rules,required"` - // The version of the ruleset. - Version string `json:"version,required"` - // An informative description of the ruleset. - Description string `json:"description"` - JSON rulesetRuleEditResponseJSON `json:"-"` -} - -// rulesetRuleEditResponseJSON contains the JSON metadata for the struct -// [RulesetRuleEditResponse] -type rulesetRuleEditResponseJSON struct { - ID apijson.Field - Kind apijson.Field - LastUpdated apijson.Field - Name apijson.Field - Phase apijson.Field - Rules apijson.Field - Version apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseJSON) RawJSON() string { - return r.raw -} - -// The kind of the ruleset. -type RulesetRuleEditResponseKind string - -const ( - RulesetRuleEditResponseKindManaged RulesetRuleEditResponseKind = "managed" - RulesetRuleEditResponseKindCustom RulesetRuleEditResponseKind = "custom" - RulesetRuleEditResponseKindRoot RulesetRuleEditResponseKind = "root" - RulesetRuleEditResponseKindZone RulesetRuleEditResponseKind = "zone" -) - -// The phase of the ruleset. -type RulesetRuleEditResponsePhase string - -const ( - RulesetRuleEditResponsePhaseDDOSL4 RulesetRuleEditResponsePhase = "ddos_l4" - RulesetRuleEditResponsePhaseDDOSL7 RulesetRuleEditResponsePhase = "ddos_l7" - RulesetRuleEditResponsePhaseHTTPConfigSettings RulesetRuleEditResponsePhase = "http_config_settings" - RulesetRuleEditResponsePhaseHTTPCustomErrors RulesetRuleEditResponsePhase = "http_custom_errors" - RulesetRuleEditResponsePhaseHTTPLogCustomFields RulesetRuleEditResponsePhase = "http_log_custom_fields" - RulesetRuleEditResponsePhaseHTTPRatelimit RulesetRuleEditResponsePhase = "http_ratelimit" - RulesetRuleEditResponsePhaseHTTPRequestCacheSettings RulesetRuleEditResponsePhase = "http_request_cache_settings" - RulesetRuleEditResponsePhaseHTTPRequestDynamicRedirect RulesetRuleEditResponsePhase = "http_request_dynamic_redirect" - RulesetRuleEditResponsePhaseHTTPRequestFirewallCustom RulesetRuleEditResponsePhase = "http_request_firewall_custom" - RulesetRuleEditResponsePhaseHTTPRequestFirewallManaged RulesetRuleEditResponsePhase = "http_request_firewall_managed" - RulesetRuleEditResponsePhaseHTTPRequestLateTransform RulesetRuleEditResponsePhase = "http_request_late_transform" - RulesetRuleEditResponsePhaseHTTPRequestOrigin RulesetRuleEditResponsePhase = "http_request_origin" - RulesetRuleEditResponsePhaseHTTPRequestRedirect RulesetRuleEditResponsePhase = "http_request_redirect" - RulesetRuleEditResponsePhaseHTTPRequestSanitize RulesetRuleEditResponsePhase = "http_request_sanitize" - RulesetRuleEditResponsePhaseHTTPRequestSbfm RulesetRuleEditResponsePhase = "http_request_sbfm" - RulesetRuleEditResponsePhaseHTTPRequestSelectConfiguration RulesetRuleEditResponsePhase = "http_request_select_configuration" - RulesetRuleEditResponsePhaseHTTPRequestTransform RulesetRuleEditResponsePhase = "http_request_transform" - RulesetRuleEditResponsePhaseHTTPResponseCompression RulesetRuleEditResponsePhase = "http_response_compression" - RulesetRuleEditResponsePhaseHTTPResponseFirewallManaged RulesetRuleEditResponsePhase = "http_response_firewall_managed" - RulesetRuleEditResponsePhaseHTTPResponseHeadersTransform RulesetRuleEditResponsePhase = "http_response_headers_transform" - RulesetRuleEditResponsePhaseMagicTransit RulesetRuleEditResponsePhase = "magic_transit" - RulesetRuleEditResponsePhaseMagicTransitIDsManaged RulesetRuleEditResponsePhase = "magic_transit_ids_managed" - RulesetRuleEditResponsePhaseMagicTransitManaged RulesetRuleEditResponsePhase = "magic_transit_managed" -) - -// Union satisfied by [RulesetRuleEditResponseRulesRulesetsBlockRule], -// [RulesetRuleEditResponseRulesRulesetsExecuteRule], -// [RulesetRuleEditResponseRulesRulesetsLogRule] or -// [RulesetRuleEditResponseRulesRulesetsSkipRule]. -type RulesetRuleEditResponseRule interface { - implementsRulesetRuleEditResponseRule() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*RulesetRuleEditResponseRule)(nil)).Elem(), - "action", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetRuleEditResponseRulesRulesetsBlockRule{}), - DiscriminatorValue: "block", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetRuleEditResponseRulesRulesetsExecuteRule{}), - DiscriminatorValue: "execute", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetRuleEditResponseRulesRulesetsLogRule{}), - DiscriminatorValue: "log", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetRuleEditResponseRulesRulesetsSkipRule{}), - DiscriminatorValue: "skip", - }, - ) -} - -type RulesetRuleEditResponseRulesRulesetsBlockRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetRuleEditResponseRulesRulesetsBlockRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetRuleEditResponseRulesRulesetsBlockRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetRuleEditResponseRulesRulesetsBlockRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetRuleEditResponseRulesRulesetsBlockRuleJSON `json:"-"` -} - -// rulesetRuleEditResponseRulesRulesetsBlockRuleJSON contains the JSON metadata for -// the struct [RulesetRuleEditResponseRulesRulesetsBlockRule] -type rulesetRuleEditResponseRulesRulesetsBlockRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseRulesRulesetsBlockRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseRulesRulesetsBlockRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetRuleEditResponseRulesRulesetsBlockRule) implementsRulesetRuleEditResponseRule() {} - -// The action to perform when the rule matches. -type RulesetRuleEditResponseRulesRulesetsBlockRuleAction string - -const ( - RulesetRuleEditResponseRulesRulesetsBlockRuleActionBlock RulesetRuleEditResponseRulesRulesetsBlockRuleAction = "block" -) - -// The parameters configuring the rule's action. -type RulesetRuleEditResponseRulesRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response RulesetRuleEditResponseRulesRulesetsBlockRuleActionParametersResponse `json:"response"` - JSON rulesetRuleEditResponseRulesRulesetsBlockRuleActionParametersJSON `json:"-"` -} - -// rulesetRuleEditResponseRulesRulesetsBlockRuleActionParametersJSON contains the -// JSON metadata for the struct -// [RulesetRuleEditResponseRulesRulesetsBlockRuleActionParameters] -type rulesetRuleEditResponseRulesRulesetsBlockRuleActionParametersJSON struct { - Response apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseRulesRulesetsBlockRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseRulesRulesetsBlockRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The response to show when the block is applied. -type RulesetRuleEditResponseRulesRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content string `json:"content,required"` - // The type of the content to return. - ContentType string `json:"content_type,required"` - // The status code to return. - StatusCode int64 `json:"status_code,required"` - JSON rulesetRuleEditResponseRulesRulesetsBlockRuleActionParametersResponseJSON `json:"-"` -} - -// rulesetRuleEditResponseRulesRulesetsBlockRuleActionParametersResponseJSON -// contains the JSON metadata for the struct -// [RulesetRuleEditResponseRulesRulesetsBlockRuleActionParametersResponse] -type rulesetRuleEditResponseRulesRulesetsBlockRuleActionParametersResponseJSON struct { - Content apijson.Field - ContentType apijson.Field - StatusCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseRulesRulesetsBlockRuleActionParametersResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseRulesRulesetsBlockRuleActionParametersResponseJSON) RawJSON() string { - return r.raw -} - -// An object configuring the rule's logging behavior. -type RulesetRuleEditResponseRulesRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetRuleEditResponseRulesRulesetsBlockRuleLoggingJSON `json:"-"` -} - -// rulesetRuleEditResponseRulesRulesetsBlockRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetRuleEditResponseRulesRulesetsBlockRuleLogging] -type rulesetRuleEditResponseRulesRulesetsBlockRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseRulesRulesetsBlockRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseRulesRulesetsBlockRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetRuleEditResponseRulesRulesetsExecuteRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetRuleEditResponseRulesRulesetsExecuteRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetRuleEditResponseRulesRulesetsExecuteRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetRuleEditResponseRulesRulesetsExecuteRuleJSON `json:"-"` -} - -// rulesetRuleEditResponseRulesRulesetsExecuteRuleJSON contains the JSON metadata -// for the struct [RulesetRuleEditResponseRulesRulesetsExecuteRule] -type rulesetRuleEditResponseRulesRulesetsExecuteRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseRulesRulesetsExecuteRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseRulesRulesetsExecuteRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetRuleEditResponseRulesRulesetsExecuteRule) implementsRulesetRuleEditResponseRule() {} - -// The action to perform when the rule matches. -type RulesetRuleEditResponseRulesRulesetsExecuteRuleAction string - -const ( - RulesetRuleEditResponseRulesRulesetsExecuteRuleActionExecute RulesetRuleEditResponseRulesRulesetsExecuteRuleAction = "execute" -) - -// The parameters configuring the rule's action. -type RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID string `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersMatchedData `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverrides `json:"overrides"` - JSON rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersJSON `json:"-"` -} - -// rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersJSON contains the -// JSON metadata for the struct -// [RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParameters] -type rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersJSON struct { - ID apijson.Field - MatchedData apijson.Field - Overrides apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The configuration to use for matched data logging. -type RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey string `json:"public_key,required"` - JSON rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON `json:"-"` -} - -// rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON -// contains the JSON metadata for the struct -// [RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersMatchedData] -type rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON struct { - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersMatchedData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON) RawJSON() string { - return r.raw -} - -// A set of overrides to apply to the target ruleset. -type RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action string `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories []RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled bool `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules []RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesRule `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON `json:"-"` -} - -// rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON -// contains the JSON metadata for the struct -// [RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverrides] -type rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON struct { - Action apijson.Field - Categories apijson.Field - Enabled apijson.Field - Rules apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverrides) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON) RawJSON() string { - return r.raw -} - -// A category-level override -type RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category string `json:"category,required"` - // The action to override rules in the category with. - Action string `json:"action"` - // Whether to enable execution of rules in the category. - Enabled bool `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON `json:"-"` -} - -// rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON -// contains the JSON metadata for the struct -// [RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory] -type rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON struct { - Category apijson.Field - Action apijson.Field - Enabled apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for rules in the category. -type RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string - -const ( - RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" -) - -// A rule-level override -type RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID string `json:"id,required"` - // The action to override the rule with. - Action string `json:"action"` - // Whether to enable execution of the rule. - Enabled bool `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold int64 `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON `json:"-"` -} - -// rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON -// contains the JSON metadata for the struct -// [RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesRule] -type rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON struct { - ID apijson.Field - Action apijson.Field - Enabled apijson.Field - ScoreThreshold apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for the rule. -type RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string - -const ( - RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" -) - -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string - -const ( - RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetRuleEditResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" -) - -// An object configuring the rule's logging behavior. -type RulesetRuleEditResponseRulesRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetRuleEditResponseRulesRulesetsExecuteRuleLoggingJSON `json:"-"` -} - -// rulesetRuleEditResponseRulesRulesetsExecuteRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetRuleEditResponseRulesRulesetsExecuteRuleLogging] -type rulesetRuleEditResponseRulesRulesetsExecuteRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseRulesRulesetsExecuteRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseRulesRulesetsExecuteRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetRuleEditResponseRulesRulesetsLogRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetRuleEditResponseRulesRulesetsLogRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters interface{} `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetRuleEditResponseRulesRulesetsLogRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetRuleEditResponseRulesRulesetsLogRuleJSON `json:"-"` -} - -// rulesetRuleEditResponseRulesRulesetsLogRuleJSON contains the JSON metadata for -// the struct [RulesetRuleEditResponseRulesRulesetsLogRule] -type rulesetRuleEditResponseRulesRulesetsLogRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseRulesRulesetsLogRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseRulesRulesetsLogRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetRuleEditResponseRulesRulesetsLogRule) implementsRulesetRuleEditResponseRule() {} - -// The action to perform when the rule matches. -type RulesetRuleEditResponseRulesRulesetsLogRuleAction string - -const ( - RulesetRuleEditResponseRulesRulesetsLogRuleActionLog RulesetRuleEditResponseRulesRulesetsLogRuleAction = "log" -) - -// An object configuring the rule's logging behavior. -type RulesetRuleEditResponseRulesRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetRuleEditResponseRulesRulesetsLogRuleLoggingJSON `json:"-"` -} - -// rulesetRuleEditResponseRulesRulesetsLogRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetRuleEditResponseRulesRulesetsLogRuleLogging] -type rulesetRuleEditResponseRulesRulesetsLogRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseRulesRulesetsLogRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseRulesRulesetsLogRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetRuleEditResponseRulesRulesetsSkipRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetRuleEditResponseRulesRulesetsSkipRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetRuleEditResponseRulesRulesetsSkipRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetRuleEditResponseRulesRulesetsSkipRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetRuleEditResponseRulesRulesetsSkipRuleJSON `json:"-"` -} - -// rulesetRuleEditResponseRulesRulesetsSkipRuleJSON contains the JSON metadata for -// the struct [RulesetRuleEditResponseRulesRulesetsSkipRule] -type rulesetRuleEditResponseRulesRulesetsSkipRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseRulesRulesetsSkipRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseRulesRulesetsSkipRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetRuleEditResponseRulesRulesetsSkipRule) implementsRulesetRuleEditResponseRule() {} - -// The action to perform when the rule matches. -type RulesetRuleEditResponseRulesRulesetsSkipRuleAction string - -const ( - RulesetRuleEditResponseRulesRulesetsSkipRuleActionSkip RulesetRuleEditResponseRulesRulesetsSkipRuleAction = "skip" -) - -// The parameters configuring the rule's action. -type RulesetRuleEditResponseRulesRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases []RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase `json:"phases"` - // A list of legacy security products to skip the execution of. - Products []RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersProduct `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules map[string][]string `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersRuleset `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets []string `json:"rulesets"` - JSON rulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersJSON `json:"-"` -} - -// rulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersJSON contains the -// JSON metadata for the struct -// [RulesetRuleEditResponseRulesRulesetsSkipRuleActionParameters] -type rulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersJSON struct { - Phases apijson.Field - Products apijson.Field - Rules apijson.Field - Ruleset apijson.Field - Rulesets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseRulesRulesetsSkipRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// A phase to skip the execution of. -type RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase string - -const ( - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL4 RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL7 RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -// The name of a legacy security product to skip the execution of. -type RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersProduct string - -const ( - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersProductBic RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersProduct = "bic" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersProductHot RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersProduct = "hot" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersProductUABlock RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersProductWAF RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersProduct = "waf" - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) - -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersRuleset string - -const ( - RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetRuleEditResponseRulesRulesetsSkipRuleActionParametersRuleset = "current" -) - -// An object configuring the rule's logging behavior. -type RulesetRuleEditResponseRulesRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetRuleEditResponseRulesRulesetsSkipRuleLoggingJSON `json:"-"` -} - -// rulesetRuleEditResponseRulesRulesetsSkipRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetRuleEditResponseRulesRulesetsSkipRuleLogging] -type rulesetRuleEditResponseRulesRulesetsSkipRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseRulesRulesetsSkipRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseRulesRulesetsSkipRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetRuleNewParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // An object configuring where the rule will be placed. - Position param.Field[RulesetRuleNewParamsPosition] `json:"position"` -} - -func (r RulesetRuleNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// An object configuring where the rule will be placed. -// -// Satisfied by [RulesetRuleNewParamsPositionBeforePosition], -// [RulesetRuleNewParamsPositionAfterPosition], -// [RulesetRuleNewParamsPositionIndexPosition]. -type RulesetRuleNewParamsPosition interface { - implementsRulesetRuleNewParamsPosition() -} - -// An object configuring where the rule will be placed. -type RulesetRuleNewParamsPositionBeforePosition struct { - // The ID of another rule to place the rule before. An empty value causes the rule - // to be placed at the top. - Before param.Field[string] `json:"before"` -} - -func (r RulesetRuleNewParamsPositionBeforePosition) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetRuleNewParamsPositionBeforePosition) implementsRulesetRuleNewParamsPosition() {} - -// An object configuring where the rule will be placed. -type RulesetRuleNewParamsPositionAfterPosition struct { - // The ID of another rule to place the rule after. An empty value causes the rule - // to be placed at the bottom. - After param.Field[string] `json:"after"` -} - -func (r RulesetRuleNewParamsPositionAfterPosition) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetRuleNewParamsPositionAfterPosition) implementsRulesetRuleNewParamsPosition() {} - -// An object configuring where the rule will be placed. -type RulesetRuleNewParamsPositionIndexPosition struct { - // An index at which to place the rule, where index 1 is the first rule. - Index param.Field[float64] `json:"index"` -} - -func (r RulesetRuleNewParamsPositionIndexPosition) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetRuleNewParamsPositionIndexPosition) implementsRulesetRuleNewParamsPosition() {} - -// A response object. -type RulesetRuleNewResponseEnvelope struct { - // A list of error messages. - Errors []RulesetRuleNewResponseEnvelopeErrors `json:"errors,required"` - // A list of warning messages. - Messages []RulesetRuleNewResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result RulesetRuleNewResponse `json:"result,required"` - // Whether the API call was successful. - Success RulesetRuleNewResponseEnvelopeSuccess `json:"success,required"` - JSON rulesetRuleNewResponseEnvelopeJSON `json:"-"` -} - -// rulesetRuleNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [RulesetRuleNewResponseEnvelope] -type rulesetRuleNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetRuleNewResponseEnvelopeErrors struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetRuleNewResponseEnvelopeErrorsSource `json:"source"` - JSON rulesetRuleNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// rulesetRuleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RulesetRuleNewResponseEnvelopeErrors] -type rulesetRuleNewResponseEnvelopeErrorsJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetRuleNewResponseEnvelopeErrorsSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetRuleNewResponseEnvelopeErrorsSourceJSON `json:"-"` -} - -// rulesetRuleNewResponseEnvelopeErrorsSourceJSON contains the JSON metadata for -// the struct [RulesetRuleNewResponseEnvelopeErrorsSource] -type rulesetRuleNewResponseEnvelopeErrorsSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseEnvelopeErrorsSourceJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetRuleNewResponseEnvelopeMessages struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetRuleNewResponseEnvelopeMessagesSource `json:"source"` - JSON rulesetRuleNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// rulesetRuleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RulesetRuleNewResponseEnvelopeMessages] -type rulesetRuleNewResponseEnvelopeMessagesJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetRuleNewResponseEnvelopeMessagesSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetRuleNewResponseEnvelopeMessagesSourceJSON `json:"-"` -} - -// rulesetRuleNewResponseEnvelopeMessagesSourceJSON contains the JSON metadata for -// the struct [RulesetRuleNewResponseEnvelopeMessagesSource] -type rulesetRuleNewResponseEnvelopeMessagesSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleNewResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleNewResponseEnvelopeMessagesSourceJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type RulesetRuleNewResponseEnvelopeSuccess bool - -const ( - RulesetRuleNewResponseEnvelopeSuccessTrue RulesetRuleNewResponseEnvelopeSuccess = true -) - -type RulesetRuleDeleteParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -// A response object. -type RulesetRuleDeleteResponseEnvelope struct { - // A list of error messages. - Errors []RulesetRuleDeleteResponseEnvelopeErrors `json:"errors,required"` - // A list of warning messages. - Messages []RulesetRuleDeleteResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result RulesetRuleDeleteResponse `json:"result,required"` - // Whether the API call was successful. - Success RulesetRuleDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON rulesetRuleDeleteResponseEnvelopeJSON `json:"-"` -} - -// rulesetRuleDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [RulesetRuleDeleteResponseEnvelope] -type rulesetRuleDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetRuleDeleteResponseEnvelopeErrors struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetRuleDeleteResponseEnvelopeErrorsSource `json:"source"` - JSON rulesetRuleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// rulesetRuleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RulesetRuleDeleteResponseEnvelopeErrors] -type rulesetRuleDeleteResponseEnvelopeErrorsJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetRuleDeleteResponseEnvelopeErrorsSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetRuleDeleteResponseEnvelopeErrorsSourceJSON `json:"-"` -} - -// rulesetRuleDeleteResponseEnvelopeErrorsSourceJSON contains the JSON metadata for -// the struct [RulesetRuleDeleteResponseEnvelopeErrorsSource] -type rulesetRuleDeleteResponseEnvelopeErrorsSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseEnvelopeErrorsSourceJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetRuleDeleteResponseEnvelopeMessages struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetRuleDeleteResponseEnvelopeMessagesSource `json:"source"` - JSON rulesetRuleDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// rulesetRuleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RulesetRuleDeleteResponseEnvelopeMessages] -type rulesetRuleDeleteResponseEnvelopeMessagesJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetRuleDeleteResponseEnvelopeMessagesSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetRuleDeleteResponseEnvelopeMessagesSourceJSON `json:"-"` -} - -// rulesetRuleDeleteResponseEnvelopeMessagesSourceJSON contains the JSON metadata -// for the struct [RulesetRuleDeleteResponseEnvelopeMessagesSource] -type rulesetRuleDeleteResponseEnvelopeMessagesSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleDeleteResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleDeleteResponseEnvelopeMessagesSourceJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type RulesetRuleDeleteResponseEnvelopeSuccess bool - -const ( - RulesetRuleDeleteResponseEnvelopeSuccessTrue RulesetRuleDeleteResponseEnvelopeSuccess = true -) - -type RulesetRuleEditParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // An object configuring where the rule will be placed. - Position param.Field[RulesetRuleEditParamsPosition] `json:"position"` -} - -func (r RulesetRuleEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// An object configuring where the rule will be placed. -// -// Satisfied by [RulesetRuleEditParamsPositionBeforePosition], -// [RulesetRuleEditParamsPositionAfterPosition], -// [RulesetRuleEditParamsPositionIndexPosition]. -type RulesetRuleEditParamsPosition interface { - implementsRulesetRuleEditParamsPosition() -} - -// An object configuring where the rule will be placed. -type RulesetRuleEditParamsPositionBeforePosition struct { - // The ID of another rule to place the rule before. An empty value causes the rule - // to be placed at the top. - Before param.Field[string] `json:"before"` -} - -func (r RulesetRuleEditParamsPositionBeforePosition) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetRuleEditParamsPositionBeforePosition) implementsRulesetRuleEditParamsPosition() {} - -// An object configuring where the rule will be placed. -type RulesetRuleEditParamsPositionAfterPosition struct { - // The ID of another rule to place the rule after. An empty value causes the rule - // to be placed at the bottom. - After param.Field[string] `json:"after"` -} - -func (r RulesetRuleEditParamsPositionAfterPosition) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetRuleEditParamsPositionAfterPosition) implementsRulesetRuleEditParamsPosition() {} - -// An object configuring where the rule will be placed. -type RulesetRuleEditParamsPositionIndexPosition struct { - // An index at which to place the rule, where index 1 is the first rule. - Index param.Field[float64] `json:"index"` -} - -func (r RulesetRuleEditParamsPositionIndexPosition) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r RulesetRuleEditParamsPositionIndexPosition) implementsRulesetRuleEditParamsPosition() {} - -// A response object. -type RulesetRuleEditResponseEnvelope struct { - // A list of error messages. - Errors []RulesetRuleEditResponseEnvelopeErrors `json:"errors,required"` - // A list of warning messages. - Messages []RulesetRuleEditResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result RulesetRuleEditResponse `json:"result,required"` - // Whether the API call was successful. - Success RulesetRuleEditResponseEnvelopeSuccess `json:"success,required"` - JSON rulesetRuleEditResponseEnvelopeJSON `json:"-"` -} - -// rulesetRuleEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [RulesetRuleEditResponseEnvelope] -type rulesetRuleEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetRuleEditResponseEnvelopeErrors struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetRuleEditResponseEnvelopeErrorsSource `json:"source"` - JSON rulesetRuleEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// rulesetRuleEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RulesetRuleEditResponseEnvelopeErrors] -type rulesetRuleEditResponseEnvelopeErrorsJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetRuleEditResponseEnvelopeErrorsSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetRuleEditResponseEnvelopeErrorsSourceJSON `json:"-"` -} - -// rulesetRuleEditResponseEnvelopeErrorsSourceJSON contains the JSON metadata for -// the struct [RulesetRuleEditResponseEnvelopeErrorsSource] -type rulesetRuleEditResponseEnvelopeErrorsSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseEnvelopeErrorsSourceJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetRuleEditResponseEnvelopeMessages struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetRuleEditResponseEnvelopeMessagesSource `json:"source"` - JSON rulesetRuleEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// rulesetRuleEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RulesetRuleEditResponseEnvelopeMessages] -type rulesetRuleEditResponseEnvelopeMessagesJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetRuleEditResponseEnvelopeMessagesSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetRuleEditResponseEnvelopeMessagesSourceJSON `json:"-"` -} - -// rulesetRuleEditResponseEnvelopeMessagesSourceJSON contains the JSON metadata for -// the struct [RulesetRuleEditResponseEnvelopeMessagesSource] -type rulesetRuleEditResponseEnvelopeMessagesSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetRuleEditResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetRuleEditResponseEnvelopeMessagesSourceJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type RulesetRuleEditResponseEnvelopeSuccess bool - -const ( - RulesetRuleEditResponseEnvelopeSuccessTrue RulesetRuleEditResponseEnvelopeSuccess = true -) diff --git a/rulesetrule_test.go b/rulesetrule_test.go deleted file mode 100644 index a6e400ced2a..00000000000 --- a/rulesetrule_test.go +++ /dev/null @@ -1,115 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRulesetRuleNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Rulesets.Rules.New( - context.TODO(), - "2f2feab2026849078ba485f918791bdc", - cloudflare.RulesetRuleNewParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - Position: cloudflare.F[cloudflare.RulesetRuleNewParamsPosition](cloudflare.RulesetRuleNewParamsPositionBeforePosition(cloudflare.RulesetRuleNewParamsPositionBeforePosition{ - Before: cloudflare.F("da5e8e506c8e7877fe06cdf4c41add54"), - })), - }, - ) - 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 TestRulesetRuleDeleteWithOptionalParams(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("user@example.com"), - ) - _, err := client.Rulesets.Rules.Delete( - context.TODO(), - "2f2feab2026849078ba485f918791bdc", - "3a03d665bac047339bb530ecb439a90d", - cloudflare.RulesetRuleDeleteParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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 TestRulesetRuleEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Rulesets.Rules.Edit( - context.TODO(), - "2f2feab2026849078ba485f918791bdc", - "3a03d665bac047339bb530ecb439a90d", - cloudflare.RulesetRuleEditParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - Position: cloudflare.F[cloudflare.RulesetRuleEditParamsPosition](cloudflare.RulesetRuleEditParamsPositionBeforePosition(cloudflare.RulesetRuleEditParamsPositionBeforePosition{ - Before: cloudflare.F("da5e8e506c8e7877fe06cdf4c41add54"), - })), - }, - ) - 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/rulesets/aliases.go b/rulesets/aliases.go new file mode 100644 index 00000000000..dd97fee1c1b --- /dev/null +++ b/rulesets/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package rulesets + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/rulesets/phase.go b/rulesets/phase.go new file mode 100644 index 00000000000..a9bb9f77825 --- /dev/null +++ b/rulesets/phase.go @@ -0,0 +1,874 @@ +// File generated from our OpenAPI spec by Stainless. + +package rulesets + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// PhaseService 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 [NewPhaseService] method instead. +type PhaseService struct { + Options []option.RequestOption + Versions *PhaseVersionService +} + +// NewPhaseService 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 NewPhaseService(opts ...option.RequestOption) (r *PhaseService) { + r = &PhaseService{} + r.Options = opts + r.Versions = NewPhaseVersionService(opts...) + return +} + +// Updates an account or zone entry point ruleset, creating a new version. +func (r *PhaseService) Update(ctx context.Context, rulesetPhase PhaseUpdateParamsRulesetPhase, params PhaseUpdateParams, opts ...option.RequestOption) (res *RulesetsRulesetResponse, err error) { + opts = append(r.Options[:], opts...) + var env PhaseUpdateResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/rulesets/phases/%v/entrypoint", accountOrZone, accountOrZoneID, rulesetPhase) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the latest version of the account or zone entry point ruleset for a +// given phase. +func (r *PhaseService) Get(ctx context.Context, rulesetPhase PhaseGetParamsRulesetPhase, query PhaseGetParams, opts ...option.RequestOption) (res *RulesetsRulesetResponse, err error) { + opts = append(r.Options[:], opts...) + var env PhaseGetResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/rulesets/phases/%v/entrypoint", accountOrZone, accountOrZoneID, rulesetPhase) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type PhaseUpdateParams struct { + // The unique ID of the ruleset. + ID param.Field[string] `json:"id,required"` + // The list of rules in the ruleset. + Rules param.Field[[]PhaseUpdateParamsRule] `json:"rules,required"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // An informative description of the ruleset. + Description param.Field[string] `json:"description"` + // The kind of the ruleset. + Kind param.Field[PhaseUpdateParamsKind] `json:"kind"` + // The human-readable name of the ruleset. + Name param.Field[string] `json:"name"` + // The phase of the ruleset. + Phase param.Field[PhaseUpdateParamsPhase] `json:"phase"` +} + +func (r PhaseUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The phase of the ruleset. +type PhaseUpdateParamsRulesetPhase string + +const ( + PhaseUpdateParamsRulesetPhaseDDOSL4 PhaseUpdateParamsRulesetPhase = "ddos_l4" + PhaseUpdateParamsRulesetPhaseDDOSL7 PhaseUpdateParamsRulesetPhase = "ddos_l7" + PhaseUpdateParamsRulesetPhaseHTTPConfigSettings PhaseUpdateParamsRulesetPhase = "http_config_settings" + PhaseUpdateParamsRulesetPhaseHTTPCustomErrors PhaseUpdateParamsRulesetPhase = "http_custom_errors" + PhaseUpdateParamsRulesetPhaseHTTPLogCustomFields PhaseUpdateParamsRulesetPhase = "http_log_custom_fields" + PhaseUpdateParamsRulesetPhaseHTTPRatelimit PhaseUpdateParamsRulesetPhase = "http_ratelimit" + PhaseUpdateParamsRulesetPhaseHTTPRequestCacheSettings PhaseUpdateParamsRulesetPhase = "http_request_cache_settings" + PhaseUpdateParamsRulesetPhaseHTTPRequestDynamicRedirect PhaseUpdateParamsRulesetPhase = "http_request_dynamic_redirect" + PhaseUpdateParamsRulesetPhaseHTTPRequestFirewallCustom PhaseUpdateParamsRulesetPhase = "http_request_firewall_custom" + PhaseUpdateParamsRulesetPhaseHTTPRequestFirewallManaged PhaseUpdateParamsRulesetPhase = "http_request_firewall_managed" + PhaseUpdateParamsRulesetPhaseHTTPRequestLateTransform PhaseUpdateParamsRulesetPhase = "http_request_late_transform" + PhaseUpdateParamsRulesetPhaseHTTPRequestOrigin PhaseUpdateParamsRulesetPhase = "http_request_origin" + PhaseUpdateParamsRulesetPhaseHTTPRequestRedirect PhaseUpdateParamsRulesetPhase = "http_request_redirect" + PhaseUpdateParamsRulesetPhaseHTTPRequestSanitize PhaseUpdateParamsRulesetPhase = "http_request_sanitize" + PhaseUpdateParamsRulesetPhaseHTTPRequestSbfm PhaseUpdateParamsRulesetPhase = "http_request_sbfm" + PhaseUpdateParamsRulesetPhaseHTTPRequestSelectConfiguration PhaseUpdateParamsRulesetPhase = "http_request_select_configuration" + PhaseUpdateParamsRulesetPhaseHTTPRequestTransform PhaseUpdateParamsRulesetPhase = "http_request_transform" + PhaseUpdateParamsRulesetPhaseHTTPResponseCompression PhaseUpdateParamsRulesetPhase = "http_response_compression" + PhaseUpdateParamsRulesetPhaseHTTPResponseFirewallManaged PhaseUpdateParamsRulesetPhase = "http_response_firewall_managed" + PhaseUpdateParamsRulesetPhaseHTTPResponseHeadersTransform PhaseUpdateParamsRulesetPhase = "http_response_headers_transform" + PhaseUpdateParamsRulesetPhaseMagicTransit PhaseUpdateParamsRulesetPhase = "magic_transit" + PhaseUpdateParamsRulesetPhaseMagicTransitIDsManaged PhaseUpdateParamsRulesetPhase = "magic_transit_ids_managed" + PhaseUpdateParamsRulesetPhaseMagicTransitManaged PhaseUpdateParamsRulesetPhase = "magic_transit_managed" +) + +// Satisfied by [rulesets.PhaseUpdateParamsRulesRulesetsBlockRule], +// [rulesets.PhaseUpdateParamsRulesRulesetsExecuteRule], +// [rulesets.PhaseUpdateParamsRulesRulesetsLogRule], +// [rulesets.PhaseUpdateParamsRulesRulesetsSkipRule]. +type PhaseUpdateParamsRule interface { + implementsRulesetsPhaseUpdateParamsRule() +} + +type PhaseUpdateParamsRulesRulesetsBlockRule struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[PhaseUpdateParamsRulesRulesetsBlockRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[PhaseUpdateParamsRulesRulesetsBlockRuleActionParameters] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[PhaseUpdateParamsRulesRulesetsBlockRuleLogging] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r PhaseUpdateParamsRulesRulesetsBlockRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r PhaseUpdateParamsRulesRulesetsBlockRule) implementsRulesetsPhaseUpdateParamsRule() {} + +// The action to perform when the rule matches. +type PhaseUpdateParamsRulesRulesetsBlockRuleAction string + +const ( + PhaseUpdateParamsRulesRulesetsBlockRuleActionBlock PhaseUpdateParamsRulesRulesetsBlockRuleAction = "block" +) + +// The parameters configuring the rule's action. +type PhaseUpdateParamsRulesRulesetsBlockRuleActionParameters struct { + // The response to show when the block is applied. + Response param.Field[PhaseUpdateParamsRulesRulesetsBlockRuleActionParametersResponse] `json:"response"` +} + +func (r PhaseUpdateParamsRulesRulesetsBlockRuleActionParameters) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The response to show when the block is applied. +type PhaseUpdateParamsRulesRulesetsBlockRuleActionParametersResponse struct { + // The content to return. + Content param.Field[string] `json:"content,required"` + // The type of the content to return. + ContentType param.Field[string] `json:"content_type,required"` + // The status code to return. + StatusCode param.Field[int64] `json:"status_code,required"` +} + +func (r PhaseUpdateParamsRulesRulesetsBlockRuleActionParametersResponse) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// An object configuring the rule's logging behavior. +type PhaseUpdateParamsRulesRulesetsBlockRuleLogging struct { + // Whether to generate a log when the rule matches. + Enabled param.Field[bool] `json:"enabled,required"` +} + +func (r PhaseUpdateParamsRulesRulesetsBlockRuleLogging) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type PhaseUpdateParamsRulesRulesetsExecuteRule struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[PhaseUpdateParamsRulesRulesetsExecuteRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[PhaseUpdateParamsRulesRulesetsExecuteRuleActionParameters] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[PhaseUpdateParamsRulesRulesetsExecuteRuleLogging] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r PhaseUpdateParamsRulesRulesetsExecuteRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r PhaseUpdateParamsRulesRulesetsExecuteRule) implementsRulesetsPhaseUpdateParamsRule() {} + +// The action to perform when the rule matches. +type PhaseUpdateParamsRulesRulesetsExecuteRuleAction string + +const ( + PhaseUpdateParamsRulesRulesetsExecuteRuleActionExecute PhaseUpdateParamsRulesRulesetsExecuteRuleAction = "execute" +) + +// The parameters configuring the rule's action. +type PhaseUpdateParamsRulesRulesetsExecuteRuleActionParameters struct { + // The ID of the ruleset to execute. + ID param.Field[string] `json:"id,required"` + // The configuration to use for matched data logging. + MatchedData param.Field[PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersMatchedData] `json:"matched_data"` + // A set of overrides to apply to the target ruleset. + Overrides param.Field[PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverrides] `json:"overrides"` +} + +func (r PhaseUpdateParamsRulesRulesetsExecuteRuleActionParameters) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The configuration to use for matched data logging. +type PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersMatchedData struct { + // The public key to encrypt matched data logs with. + PublicKey param.Field[string] `json:"public_key,required"` +} + +func (r PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersMatchedData) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A set of overrides to apply to the target ruleset. +type PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverrides struct { + // An action to override all rules with. This option has lower precedence than rule + // and category overrides. + Action param.Field[string] `json:"action"` + // A list of category-level overrides. This option has the second-highest + // precedence after rule-level overrides. + Categories param.Field[[]PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory] `json:"categories"` + // Whether to enable execution of all rules. This option has lower precedence than + // rule and category overrides. + Enabled param.Field[bool] `json:"enabled"` + // A list of rule-level overrides. This option has the highest precedence. + Rules param.Field[[]PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRule] `json:"rules"` + // A sensitivity level to set for all rules. This option has lower precedence than + // rule and category overrides and is only applicable for DDoS phases. + SensitivityLevel param.Field[PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel] `json:"sensitivity_level"` +} + +func (r PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverrides) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A category-level override +type PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { + // The name of the category to override. + Category param.Field[string] `json:"category,required"` + // The action to override rules in the category with. + Action param.Field[string] `json:"action"` + // Whether to enable execution of rules in the category. + Enabled param.Field[bool] `json:"enabled"` + // The sensitivity level to use for rules in the category. + SensitivityLevel param.Field[PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel] `json:"sensitivity_level"` +} + +func (r PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The sensitivity level to use for rules in the category. +type PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string + +const ( + PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" + PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" + PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" + PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" +) + +// A rule-level override +type PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRule struct { + // The ID of the rule to override. + ID param.Field[string] `json:"id,required"` + // The action to override the rule with. + Action param.Field[string] `json:"action"` + // Whether to enable execution of the rule. + Enabled param.Field[bool] `json:"enabled"` + // The score threshold to use for the rule. + ScoreThreshold param.Field[int64] `json:"score_threshold"` + // The sensitivity level to use for the rule. + SensitivityLevel param.Field[PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel] `json:"sensitivity_level"` +} + +func (r PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The sensitivity level to use for the rule. +type PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string + +const ( + PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" + PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" + PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" + PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" +) + +// A sensitivity level to set for all rules. This option has lower precedence than +// rule and category overrides and is only applicable for DDoS phases. +type PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string + +const ( + PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" + PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" + PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" + PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff PhaseUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" +) + +// An object configuring the rule's logging behavior. +type PhaseUpdateParamsRulesRulesetsExecuteRuleLogging struct { + // Whether to generate a log when the rule matches. + Enabled param.Field[bool] `json:"enabled,required"` +} + +func (r PhaseUpdateParamsRulesRulesetsExecuteRuleLogging) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type PhaseUpdateParamsRulesRulesetsLogRule struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[PhaseUpdateParamsRulesRulesetsLogRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[interface{}] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[PhaseUpdateParamsRulesRulesetsLogRuleLogging] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r PhaseUpdateParamsRulesRulesetsLogRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r PhaseUpdateParamsRulesRulesetsLogRule) implementsRulesetsPhaseUpdateParamsRule() {} + +// The action to perform when the rule matches. +type PhaseUpdateParamsRulesRulesetsLogRuleAction string + +const ( + PhaseUpdateParamsRulesRulesetsLogRuleActionLog PhaseUpdateParamsRulesRulesetsLogRuleAction = "log" +) + +// An object configuring the rule's logging behavior. +type PhaseUpdateParamsRulesRulesetsLogRuleLogging struct { + // Whether to generate a log when the rule matches. + Enabled param.Field[bool] `json:"enabled,required"` +} + +func (r PhaseUpdateParamsRulesRulesetsLogRuleLogging) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type PhaseUpdateParamsRulesRulesetsSkipRule struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[PhaseUpdateParamsRulesRulesetsSkipRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[PhaseUpdateParamsRulesRulesetsSkipRuleActionParameters] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[PhaseUpdateParamsRulesRulesetsSkipRuleLogging] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r PhaseUpdateParamsRulesRulesetsSkipRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r PhaseUpdateParamsRulesRulesetsSkipRule) implementsRulesetsPhaseUpdateParamsRule() {} + +// The action to perform when the rule matches. +type PhaseUpdateParamsRulesRulesetsSkipRuleAction string + +const ( + PhaseUpdateParamsRulesRulesetsSkipRuleActionSkip PhaseUpdateParamsRulesRulesetsSkipRuleAction = "skip" +) + +// The parameters configuring the rule's action. +type PhaseUpdateParamsRulesRulesetsSkipRuleActionParameters struct { + // A list of phases to skip the execution of. This option is incompatible with the + // ruleset and rulesets options. + Phases param.Field[[]PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase] `json:"phases"` + // A list of legacy security products to skip the execution of. + Products param.Field[[]PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct] `json:"products"` + // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the + // execution of. This option is incompatible with the ruleset option. + Rules param.Field[map[string][]string] `json:"rules"` + // A ruleset to skip the execution of. This option is incompatible with the + // rulesets, rules and phases options. + Ruleset param.Field[PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset] `json:"ruleset"` + // A list of ruleset IDs to skip the execution of. This option is incompatible with + // the ruleset and phases options. + Rulesets param.Field[[]string] `json:"rulesets"` +} + +func (r PhaseUpdateParamsRulesRulesetsSkipRuleActionParameters) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A phase to skip the execution of. +type PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase string + +const ( + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseDDOSL4 PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseDDOSL7 PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransit PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" +) + +// The name of a legacy security product to skip the execution of. +type PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct string + +const ( + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductBic PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "bic" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductHot PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "hot" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductRateLimit PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductSecurityLevel PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductUABlock PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductWAF PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "waf" + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProductZoneLockdown PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" +) + +// A ruleset to skip the execution of. This option is incompatible with the +// rulesets, rules and phases options. +type PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset string + +const ( + PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersRulesetCurrent PhaseUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset = "current" +) + +// An object configuring the rule's logging behavior. +type PhaseUpdateParamsRulesRulesetsSkipRuleLogging struct { + // Whether to generate a log when the rule matches. + Enabled param.Field[bool] `json:"enabled,required"` +} + +func (r PhaseUpdateParamsRulesRulesetsSkipRuleLogging) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The kind of the ruleset. +type PhaseUpdateParamsKind string + +const ( + PhaseUpdateParamsKindManaged PhaseUpdateParamsKind = "managed" + PhaseUpdateParamsKindCustom PhaseUpdateParamsKind = "custom" + PhaseUpdateParamsKindRoot PhaseUpdateParamsKind = "root" + PhaseUpdateParamsKindZone PhaseUpdateParamsKind = "zone" +) + +// The phase of the ruleset. +type PhaseUpdateParamsPhase string + +const ( + PhaseUpdateParamsPhaseDDOSL4 PhaseUpdateParamsPhase = "ddos_l4" + PhaseUpdateParamsPhaseDDOSL7 PhaseUpdateParamsPhase = "ddos_l7" + PhaseUpdateParamsPhaseHTTPConfigSettings PhaseUpdateParamsPhase = "http_config_settings" + PhaseUpdateParamsPhaseHTTPCustomErrors PhaseUpdateParamsPhase = "http_custom_errors" + PhaseUpdateParamsPhaseHTTPLogCustomFields PhaseUpdateParamsPhase = "http_log_custom_fields" + PhaseUpdateParamsPhaseHTTPRatelimit PhaseUpdateParamsPhase = "http_ratelimit" + PhaseUpdateParamsPhaseHTTPRequestCacheSettings PhaseUpdateParamsPhase = "http_request_cache_settings" + PhaseUpdateParamsPhaseHTTPRequestDynamicRedirect PhaseUpdateParamsPhase = "http_request_dynamic_redirect" + PhaseUpdateParamsPhaseHTTPRequestFirewallCustom PhaseUpdateParamsPhase = "http_request_firewall_custom" + PhaseUpdateParamsPhaseHTTPRequestFirewallManaged PhaseUpdateParamsPhase = "http_request_firewall_managed" + PhaseUpdateParamsPhaseHTTPRequestLateTransform PhaseUpdateParamsPhase = "http_request_late_transform" + PhaseUpdateParamsPhaseHTTPRequestOrigin PhaseUpdateParamsPhase = "http_request_origin" + PhaseUpdateParamsPhaseHTTPRequestRedirect PhaseUpdateParamsPhase = "http_request_redirect" + PhaseUpdateParamsPhaseHTTPRequestSanitize PhaseUpdateParamsPhase = "http_request_sanitize" + PhaseUpdateParamsPhaseHTTPRequestSbfm PhaseUpdateParamsPhase = "http_request_sbfm" + PhaseUpdateParamsPhaseHTTPRequestSelectConfiguration PhaseUpdateParamsPhase = "http_request_select_configuration" + PhaseUpdateParamsPhaseHTTPRequestTransform PhaseUpdateParamsPhase = "http_request_transform" + PhaseUpdateParamsPhaseHTTPResponseCompression PhaseUpdateParamsPhase = "http_response_compression" + PhaseUpdateParamsPhaseHTTPResponseFirewallManaged PhaseUpdateParamsPhase = "http_response_firewall_managed" + PhaseUpdateParamsPhaseHTTPResponseHeadersTransform PhaseUpdateParamsPhase = "http_response_headers_transform" + PhaseUpdateParamsPhaseMagicTransit PhaseUpdateParamsPhase = "magic_transit" + PhaseUpdateParamsPhaseMagicTransitIDsManaged PhaseUpdateParamsPhase = "magic_transit_ids_managed" + PhaseUpdateParamsPhaseMagicTransitManaged PhaseUpdateParamsPhase = "magic_transit_managed" +) + +// A response object. +type PhaseUpdateResponseEnvelope struct { + // A list of error messages. + Errors []PhaseUpdateResponseEnvelopeErrors `json:"errors,required"` + // A list of warning messages. + Messages []PhaseUpdateResponseEnvelopeMessages `json:"messages,required"` + // A result. + Result RulesetsRulesetResponse `json:"result,required"` + // Whether the API call was successful. + Success PhaseUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON phaseUpdateResponseEnvelopeJSON `json:"-"` +} + +// phaseUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [PhaseUpdateResponseEnvelope] +type phaseUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// A message. +type PhaseUpdateResponseEnvelopeErrors struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source PhaseUpdateResponseEnvelopeErrorsSource `json:"source"` + JSON phaseUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// phaseUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PhaseUpdateResponseEnvelopeErrors] +type phaseUpdateResponseEnvelopeErrorsJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type PhaseUpdateResponseEnvelopeErrorsSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON phaseUpdateResponseEnvelopeErrorsSourceJSON `json:"-"` +} + +// phaseUpdateResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the +// struct [PhaseUpdateResponseEnvelopeErrorsSource] +type phaseUpdateResponseEnvelopeErrorsSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseUpdateResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseUpdateResponseEnvelopeErrorsSourceJSON) RawJSON() string { + return r.raw +} + +// A message. +type PhaseUpdateResponseEnvelopeMessages struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source PhaseUpdateResponseEnvelopeMessagesSource `json:"source"` + JSON phaseUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// phaseUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [PhaseUpdateResponseEnvelopeMessages] +type phaseUpdateResponseEnvelopeMessagesJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type PhaseUpdateResponseEnvelopeMessagesSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON phaseUpdateResponseEnvelopeMessagesSourceJSON `json:"-"` +} + +// phaseUpdateResponseEnvelopeMessagesSourceJSON contains the JSON metadata for the +// struct [PhaseUpdateResponseEnvelopeMessagesSource] +type phaseUpdateResponseEnvelopeMessagesSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseUpdateResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseUpdateResponseEnvelopeMessagesSourceJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type PhaseUpdateResponseEnvelopeSuccess bool + +const ( + PhaseUpdateResponseEnvelopeSuccessTrue PhaseUpdateResponseEnvelopeSuccess = true +) + +type PhaseGetParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +// The phase of the ruleset. +type PhaseGetParamsRulesetPhase string + +const ( + PhaseGetParamsRulesetPhaseDDOSL4 PhaseGetParamsRulesetPhase = "ddos_l4" + PhaseGetParamsRulesetPhaseDDOSL7 PhaseGetParamsRulesetPhase = "ddos_l7" + PhaseGetParamsRulesetPhaseHTTPConfigSettings PhaseGetParamsRulesetPhase = "http_config_settings" + PhaseGetParamsRulesetPhaseHTTPCustomErrors PhaseGetParamsRulesetPhase = "http_custom_errors" + PhaseGetParamsRulesetPhaseHTTPLogCustomFields PhaseGetParamsRulesetPhase = "http_log_custom_fields" + PhaseGetParamsRulesetPhaseHTTPRatelimit PhaseGetParamsRulesetPhase = "http_ratelimit" + PhaseGetParamsRulesetPhaseHTTPRequestCacheSettings PhaseGetParamsRulesetPhase = "http_request_cache_settings" + PhaseGetParamsRulesetPhaseHTTPRequestDynamicRedirect PhaseGetParamsRulesetPhase = "http_request_dynamic_redirect" + PhaseGetParamsRulesetPhaseHTTPRequestFirewallCustom PhaseGetParamsRulesetPhase = "http_request_firewall_custom" + PhaseGetParamsRulesetPhaseHTTPRequestFirewallManaged PhaseGetParamsRulesetPhase = "http_request_firewall_managed" + PhaseGetParamsRulesetPhaseHTTPRequestLateTransform PhaseGetParamsRulesetPhase = "http_request_late_transform" + PhaseGetParamsRulesetPhaseHTTPRequestOrigin PhaseGetParamsRulesetPhase = "http_request_origin" + PhaseGetParamsRulesetPhaseHTTPRequestRedirect PhaseGetParamsRulesetPhase = "http_request_redirect" + PhaseGetParamsRulesetPhaseHTTPRequestSanitize PhaseGetParamsRulesetPhase = "http_request_sanitize" + PhaseGetParamsRulesetPhaseHTTPRequestSbfm PhaseGetParamsRulesetPhase = "http_request_sbfm" + PhaseGetParamsRulesetPhaseHTTPRequestSelectConfiguration PhaseGetParamsRulesetPhase = "http_request_select_configuration" + PhaseGetParamsRulesetPhaseHTTPRequestTransform PhaseGetParamsRulesetPhase = "http_request_transform" + PhaseGetParamsRulesetPhaseHTTPResponseCompression PhaseGetParamsRulesetPhase = "http_response_compression" + PhaseGetParamsRulesetPhaseHTTPResponseFirewallManaged PhaseGetParamsRulesetPhase = "http_response_firewall_managed" + PhaseGetParamsRulesetPhaseHTTPResponseHeadersTransform PhaseGetParamsRulesetPhase = "http_response_headers_transform" + PhaseGetParamsRulesetPhaseMagicTransit PhaseGetParamsRulesetPhase = "magic_transit" + PhaseGetParamsRulesetPhaseMagicTransitIDsManaged PhaseGetParamsRulesetPhase = "magic_transit_ids_managed" + PhaseGetParamsRulesetPhaseMagicTransitManaged PhaseGetParamsRulesetPhase = "magic_transit_managed" +) + +// A response object. +type PhaseGetResponseEnvelope struct { + // A list of error messages. + Errors []PhaseGetResponseEnvelopeErrors `json:"errors,required"` + // A list of warning messages. + Messages []PhaseGetResponseEnvelopeMessages `json:"messages,required"` + // A result. + Result RulesetsRulesetResponse `json:"result,required"` + // Whether the API call was successful. + Success PhaseGetResponseEnvelopeSuccess `json:"success,required"` + JSON phaseGetResponseEnvelopeJSON `json:"-"` +} + +// phaseGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [PhaseGetResponseEnvelope] +type phaseGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// A message. +type PhaseGetResponseEnvelopeErrors struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source PhaseGetResponseEnvelopeErrorsSource `json:"source"` + JSON phaseGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// phaseGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PhaseGetResponseEnvelopeErrors] +type phaseGetResponseEnvelopeErrorsJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type PhaseGetResponseEnvelopeErrorsSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON phaseGetResponseEnvelopeErrorsSourceJSON `json:"-"` +} + +// phaseGetResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the +// struct [PhaseGetResponseEnvelopeErrorsSource] +type phaseGetResponseEnvelopeErrorsSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseGetResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseGetResponseEnvelopeErrorsSourceJSON) RawJSON() string { + return r.raw +} + +// A message. +type PhaseGetResponseEnvelopeMessages struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source PhaseGetResponseEnvelopeMessagesSource `json:"source"` + JSON phaseGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// phaseGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PhaseGetResponseEnvelopeMessages] +type phaseGetResponseEnvelopeMessagesJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type PhaseGetResponseEnvelopeMessagesSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON phaseGetResponseEnvelopeMessagesSourceJSON `json:"-"` +} + +// phaseGetResponseEnvelopeMessagesSourceJSON contains the JSON metadata for the +// struct [PhaseGetResponseEnvelopeMessagesSource] +type phaseGetResponseEnvelopeMessagesSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseGetResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseGetResponseEnvelopeMessagesSourceJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type PhaseGetResponseEnvelopeSuccess bool + +const ( + PhaseGetResponseEnvelopeSuccessTrue PhaseGetResponseEnvelopeSuccess = true +) diff --git a/rulesets/phase_test.go b/rulesets/phase_test.go new file mode 100644 index 00000000000..049983acc09 --- /dev/null +++ b/rulesets/phase_test.go @@ -0,0 +1,134 @@ +// File generated from our OpenAPI spec by Stainless. + +package rulesets_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/rulesets" +) + +func TestPhaseUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Rulesets.Phases.Update( + context.TODO(), + rulesets.PhaseUpdateParamsRulesetPhaseHTTPRequestFirewallCustom, + rulesets.PhaseUpdateParams{ + ID: cloudflare.F("2f2feab2026849078ba485f918791bdc"), + Rules: cloudflare.F([]rulesets.PhaseUpdateParamsRule{rulesets.PhaseUpdateParamsRulesRulesetsBlockRule(rulesets.PhaseUpdateParamsRulesRulesetsBlockRule{ + Action: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleActionBlock), + ActionParameters: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleActionParameters{ + Response: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleActionParametersResponse{ + Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), + ContentType: cloudflare.F("application/json"), + StatusCode: cloudflare.F(int64(400)), + }), + }), + Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), + Enabled: cloudflare.F(true), + Expression: cloudflare.F("ip.src ne 1.1.1.1"), + ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), + Logging: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleLogging{ + Enabled: cloudflare.F(true), + }), + Ref: cloudflare.F("my_ref"), + }), rulesets.PhaseUpdateParamsRulesRulesetsBlockRule(rulesets.PhaseUpdateParamsRulesRulesetsBlockRule{ + Action: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleActionBlock), + ActionParameters: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleActionParameters{ + Response: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleActionParametersResponse{ + Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), + ContentType: cloudflare.F("application/json"), + StatusCode: cloudflare.F(int64(400)), + }), + }), + Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), + Enabled: cloudflare.F(true), + Expression: cloudflare.F("ip.src ne 1.1.1.1"), + ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), + Logging: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleLogging{ + Enabled: cloudflare.F(true), + }), + Ref: cloudflare.F("my_ref"), + }), rulesets.PhaseUpdateParamsRulesRulesetsBlockRule(rulesets.PhaseUpdateParamsRulesRulesetsBlockRule{ + Action: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleActionBlock), + ActionParameters: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleActionParameters{ + Response: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleActionParametersResponse{ + Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), + ContentType: cloudflare.F("application/json"), + StatusCode: cloudflare.F(int64(400)), + }), + }), + Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), + Enabled: cloudflare.F(true), + Expression: cloudflare.F("ip.src ne 1.1.1.1"), + ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), + Logging: cloudflare.F(rulesets.PhaseUpdateParamsRulesRulesetsBlockRuleLogging{ + Enabled: cloudflare.F(true), + }), + Ref: cloudflare.F("my_ref"), + })}), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + Description: cloudflare.F("My ruleset to execute managed rulesets"), + Kind: cloudflare.F(rulesets.PhaseUpdateParamsKindRoot), + Name: cloudflare.F("My ruleset"), + Phase: cloudflare.F(rulesets.PhaseUpdateParamsPhaseHTTPRequestFirewallCustom), + }, + ) + 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 TestPhaseGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Rulesets.Phases.Get( + context.TODO(), + rulesets.PhaseGetParamsRulesetPhaseHTTPRequestFirewallCustom, + rulesets.PhaseGetParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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/rulesets/phaseversion.go b/rulesets/phaseversion.go new file mode 100644 index 00000000000..352a3c62d26 --- /dev/null +++ b/rulesets/phaseversion.go @@ -0,0 +1,515 @@ +// File generated from our OpenAPI spec by Stainless. + +package rulesets + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// PhaseVersionService 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 [NewPhaseVersionService] method +// instead. +type PhaseVersionService struct { + Options []option.RequestOption +} + +// NewPhaseVersionService 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 NewPhaseVersionService(opts ...option.RequestOption) (r *PhaseVersionService) { + r = &PhaseVersionService{} + r.Options = opts + return +} + +// Fetches the versions of an account or zone entry point ruleset. +func (r *PhaseVersionService) List(ctx context.Context, rulesetPhase PhaseVersionListParamsRulesetPhase, query PhaseVersionListParams, opts ...option.RequestOption) (res *RulesetsRulesetsResponse, err error) { + opts = append(r.Options[:], opts...) + var env PhaseVersionListResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/rulesets/phases/%v/entrypoint/versions", accountOrZone, accountOrZoneID, rulesetPhase) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a specific version of an account or zone entry point ruleset. +func (r *PhaseVersionService) Get(ctx context.Context, rulesetPhase PhaseVersionGetParamsRulesetPhase, rulesetVersion string, query PhaseVersionGetParams, opts ...option.RequestOption) (res *RulesetsRulesetResponse, err error) { + opts = append(r.Options[:], opts...) + var env PhaseVersionGetResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/rulesets/phases/%v/entrypoint/versions/%s", accountOrZone, accountOrZoneID, rulesetPhase, rulesetVersion) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// A ruleset object. +type PhaseVersionListResponse struct { + // The kind of the ruleset. + Kind PhaseVersionListResponseKind `json:"kind,required"` + // The human-readable name of the ruleset. + Name string `json:"name,required"` + // The phase of the ruleset. + Phase PhaseVersionListResponsePhase `json:"phase,required"` + // The unique ID of the ruleset. + ID string `json:"id"` + // An informative description of the ruleset. + Description string `json:"description"` + // The timestamp of when the ruleset was last modified. + LastUpdated time.Time `json:"last_updated" format:"date-time"` + // The version of the ruleset. + Version string `json:"version"` + JSON phaseVersionListResponseJSON `json:"-"` +} + +// phaseVersionListResponseJSON contains the JSON metadata for the struct +// [PhaseVersionListResponse] +type phaseVersionListResponseJSON struct { + Kind apijson.Field + Name apijson.Field + Phase apijson.Field + ID apijson.Field + Description apijson.Field + LastUpdated apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseVersionListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseVersionListResponseJSON) RawJSON() string { + return r.raw +} + +// The kind of the ruleset. +type PhaseVersionListResponseKind string + +const ( + PhaseVersionListResponseKindManaged PhaseVersionListResponseKind = "managed" + PhaseVersionListResponseKindCustom PhaseVersionListResponseKind = "custom" + PhaseVersionListResponseKindRoot PhaseVersionListResponseKind = "root" + PhaseVersionListResponseKindZone PhaseVersionListResponseKind = "zone" +) + +// The phase of the ruleset. +type PhaseVersionListResponsePhase string + +const ( + PhaseVersionListResponsePhaseDDOSL4 PhaseVersionListResponsePhase = "ddos_l4" + PhaseVersionListResponsePhaseDDOSL7 PhaseVersionListResponsePhase = "ddos_l7" + PhaseVersionListResponsePhaseHTTPConfigSettings PhaseVersionListResponsePhase = "http_config_settings" + PhaseVersionListResponsePhaseHTTPCustomErrors PhaseVersionListResponsePhase = "http_custom_errors" + PhaseVersionListResponsePhaseHTTPLogCustomFields PhaseVersionListResponsePhase = "http_log_custom_fields" + PhaseVersionListResponsePhaseHTTPRatelimit PhaseVersionListResponsePhase = "http_ratelimit" + PhaseVersionListResponsePhaseHTTPRequestCacheSettings PhaseVersionListResponsePhase = "http_request_cache_settings" + PhaseVersionListResponsePhaseHTTPRequestDynamicRedirect PhaseVersionListResponsePhase = "http_request_dynamic_redirect" + PhaseVersionListResponsePhaseHTTPRequestFirewallCustom PhaseVersionListResponsePhase = "http_request_firewall_custom" + PhaseVersionListResponsePhaseHTTPRequestFirewallManaged PhaseVersionListResponsePhase = "http_request_firewall_managed" + PhaseVersionListResponsePhaseHTTPRequestLateTransform PhaseVersionListResponsePhase = "http_request_late_transform" + PhaseVersionListResponsePhaseHTTPRequestOrigin PhaseVersionListResponsePhase = "http_request_origin" + PhaseVersionListResponsePhaseHTTPRequestRedirect PhaseVersionListResponsePhase = "http_request_redirect" + PhaseVersionListResponsePhaseHTTPRequestSanitize PhaseVersionListResponsePhase = "http_request_sanitize" + PhaseVersionListResponsePhaseHTTPRequestSbfm PhaseVersionListResponsePhase = "http_request_sbfm" + PhaseVersionListResponsePhaseHTTPRequestSelectConfiguration PhaseVersionListResponsePhase = "http_request_select_configuration" + PhaseVersionListResponsePhaseHTTPRequestTransform PhaseVersionListResponsePhase = "http_request_transform" + PhaseVersionListResponsePhaseHTTPResponseCompression PhaseVersionListResponsePhase = "http_response_compression" + PhaseVersionListResponsePhaseHTTPResponseFirewallManaged PhaseVersionListResponsePhase = "http_response_firewall_managed" + PhaseVersionListResponsePhaseHTTPResponseHeadersTransform PhaseVersionListResponsePhase = "http_response_headers_transform" + PhaseVersionListResponsePhaseMagicTransit PhaseVersionListResponsePhase = "magic_transit" + PhaseVersionListResponsePhaseMagicTransitIDsManaged PhaseVersionListResponsePhase = "magic_transit_ids_managed" + PhaseVersionListResponsePhaseMagicTransitManaged PhaseVersionListResponsePhase = "magic_transit_managed" +) + +type PhaseVersionListParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +// The phase of the ruleset. +type PhaseVersionListParamsRulesetPhase string + +const ( + PhaseVersionListParamsRulesetPhaseDDOSL4 PhaseVersionListParamsRulesetPhase = "ddos_l4" + PhaseVersionListParamsRulesetPhaseDDOSL7 PhaseVersionListParamsRulesetPhase = "ddos_l7" + PhaseVersionListParamsRulesetPhaseHTTPConfigSettings PhaseVersionListParamsRulesetPhase = "http_config_settings" + PhaseVersionListParamsRulesetPhaseHTTPCustomErrors PhaseVersionListParamsRulesetPhase = "http_custom_errors" + PhaseVersionListParamsRulesetPhaseHTTPLogCustomFields PhaseVersionListParamsRulesetPhase = "http_log_custom_fields" + PhaseVersionListParamsRulesetPhaseHTTPRatelimit PhaseVersionListParamsRulesetPhase = "http_ratelimit" + PhaseVersionListParamsRulesetPhaseHTTPRequestCacheSettings PhaseVersionListParamsRulesetPhase = "http_request_cache_settings" + PhaseVersionListParamsRulesetPhaseHTTPRequestDynamicRedirect PhaseVersionListParamsRulesetPhase = "http_request_dynamic_redirect" + PhaseVersionListParamsRulesetPhaseHTTPRequestFirewallCustom PhaseVersionListParamsRulesetPhase = "http_request_firewall_custom" + PhaseVersionListParamsRulesetPhaseHTTPRequestFirewallManaged PhaseVersionListParamsRulesetPhase = "http_request_firewall_managed" + PhaseVersionListParamsRulesetPhaseHTTPRequestLateTransform PhaseVersionListParamsRulesetPhase = "http_request_late_transform" + PhaseVersionListParamsRulesetPhaseHTTPRequestOrigin PhaseVersionListParamsRulesetPhase = "http_request_origin" + PhaseVersionListParamsRulesetPhaseHTTPRequestRedirect PhaseVersionListParamsRulesetPhase = "http_request_redirect" + PhaseVersionListParamsRulesetPhaseHTTPRequestSanitize PhaseVersionListParamsRulesetPhase = "http_request_sanitize" + PhaseVersionListParamsRulesetPhaseHTTPRequestSbfm PhaseVersionListParamsRulesetPhase = "http_request_sbfm" + PhaseVersionListParamsRulesetPhaseHTTPRequestSelectConfiguration PhaseVersionListParamsRulesetPhase = "http_request_select_configuration" + PhaseVersionListParamsRulesetPhaseHTTPRequestTransform PhaseVersionListParamsRulesetPhase = "http_request_transform" + PhaseVersionListParamsRulesetPhaseHTTPResponseCompression PhaseVersionListParamsRulesetPhase = "http_response_compression" + PhaseVersionListParamsRulesetPhaseHTTPResponseFirewallManaged PhaseVersionListParamsRulesetPhase = "http_response_firewall_managed" + PhaseVersionListParamsRulesetPhaseHTTPResponseHeadersTransform PhaseVersionListParamsRulesetPhase = "http_response_headers_transform" + PhaseVersionListParamsRulesetPhaseMagicTransit PhaseVersionListParamsRulesetPhase = "magic_transit" + PhaseVersionListParamsRulesetPhaseMagicTransitIDsManaged PhaseVersionListParamsRulesetPhase = "magic_transit_ids_managed" + PhaseVersionListParamsRulesetPhaseMagicTransitManaged PhaseVersionListParamsRulesetPhase = "magic_transit_managed" +) + +// A response object. +type PhaseVersionListResponseEnvelope struct { + // A list of error messages. + Errors []PhaseVersionListResponseEnvelopeErrors `json:"errors,required"` + // A list of warning messages. + Messages []PhaseVersionListResponseEnvelopeMessages `json:"messages,required"` + // A result. + Result RulesetsRulesetsResponse `json:"result,required"` + // Whether the API call was successful. + Success PhaseVersionListResponseEnvelopeSuccess `json:"success,required"` + JSON phaseVersionListResponseEnvelopeJSON `json:"-"` +} + +// phaseVersionListResponseEnvelopeJSON contains the JSON metadata for the struct +// [PhaseVersionListResponseEnvelope] +type phaseVersionListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseVersionListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseVersionListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// A message. +type PhaseVersionListResponseEnvelopeErrors struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source PhaseVersionListResponseEnvelopeErrorsSource `json:"source"` + JSON phaseVersionListResponseEnvelopeErrorsJSON `json:"-"` +} + +// phaseVersionListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [PhaseVersionListResponseEnvelopeErrors] +type phaseVersionListResponseEnvelopeErrorsJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseVersionListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseVersionListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type PhaseVersionListResponseEnvelopeErrorsSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON phaseVersionListResponseEnvelopeErrorsSourceJSON `json:"-"` +} + +// phaseVersionListResponseEnvelopeErrorsSourceJSON contains the JSON metadata for +// the struct [PhaseVersionListResponseEnvelopeErrorsSource] +type phaseVersionListResponseEnvelopeErrorsSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseVersionListResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseVersionListResponseEnvelopeErrorsSourceJSON) RawJSON() string { + return r.raw +} + +// A message. +type PhaseVersionListResponseEnvelopeMessages struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source PhaseVersionListResponseEnvelopeMessagesSource `json:"source"` + JSON phaseVersionListResponseEnvelopeMessagesJSON `json:"-"` +} + +// phaseVersionListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [PhaseVersionListResponseEnvelopeMessages] +type phaseVersionListResponseEnvelopeMessagesJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseVersionListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseVersionListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type PhaseVersionListResponseEnvelopeMessagesSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON phaseVersionListResponseEnvelopeMessagesSourceJSON `json:"-"` +} + +// phaseVersionListResponseEnvelopeMessagesSourceJSON contains the JSON metadata +// for the struct [PhaseVersionListResponseEnvelopeMessagesSource] +type phaseVersionListResponseEnvelopeMessagesSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseVersionListResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseVersionListResponseEnvelopeMessagesSourceJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type PhaseVersionListResponseEnvelopeSuccess bool + +const ( + PhaseVersionListResponseEnvelopeSuccessTrue PhaseVersionListResponseEnvelopeSuccess = true +) + +type PhaseVersionGetParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +// The phase of the ruleset. +type PhaseVersionGetParamsRulesetPhase string + +const ( + PhaseVersionGetParamsRulesetPhaseDDOSL4 PhaseVersionGetParamsRulesetPhase = "ddos_l4" + PhaseVersionGetParamsRulesetPhaseDDOSL7 PhaseVersionGetParamsRulesetPhase = "ddos_l7" + PhaseVersionGetParamsRulesetPhaseHTTPConfigSettings PhaseVersionGetParamsRulesetPhase = "http_config_settings" + PhaseVersionGetParamsRulesetPhaseHTTPCustomErrors PhaseVersionGetParamsRulesetPhase = "http_custom_errors" + PhaseVersionGetParamsRulesetPhaseHTTPLogCustomFields PhaseVersionGetParamsRulesetPhase = "http_log_custom_fields" + PhaseVersionGetParamsRulesetPhaseHTTPRatelimit PhaseVersionGetParamsRulesetPhase = "http_ratelimit" + PhaseVersionGetParamsRulesetPhaseHTTPRequestCacheSettings PhaseVersionGetParamsRulesetPhase = "http_request_cache_settings" + PhaseVersionGetParamsRulesetPhaseHTTPRequestDynamicRedirect PhaseVersionGetParamsRulesetPhase = "http_request_dynamic_redirect" + PhaseVersionGetParamsRulesetPhaseHTTPRequestFirewallCustom PhaseVersionGetParamsRulesetPhase = "http_request_firewall_custom" + PhaseVersionGetParamsRulesetPhaseHTTPRequestFirewallManaged PhaseVersionGetParamsRulesetPhase = "http_request_firewall_managed" + PhaseVersionGetParamsRulesetPhaseHTTPRequestLateTransform PhaseVersionGetParamsRulesetPhase = "http_request_late_transform" + PhaseVersionGetParamsRulesetPhaseHTTPRequestOrigin PhaseVersionGetParamsRulesetPhase = "http_request_origin" + PhaseVersionGetParamsRulesetPhaseHTTPRequestRedirect PhaseVersionGetParamsRulesetPhase = "http_request_redirect" + PhaseVersionGetParamsRulesetPhaseHTTPRequestSanitize PhaseVersionGetParamsRulesetPhase = "http_request_sanitize" + PhaseVersionGetParamsRulesetPhaseHTTPRequestSbfm PhaseVersionGetParamsRulesetPhase = "http_request_sbfm" + PhaseVersionGetParamsRulesetPhaseHTTPRequestSelectConfiguration PhaseVersionGetParamsRulesetPhase = "http_request_select_configuration" + PhaseVersionGetParamsRulesetPhaseHTTPRequestTransform PhaseVersionGetParamsRulesetPhase = "http_request_transform" + PhaseVersionGetParamsRulesetPhaseHTTPResponseCompression PhaseVersionGetParamsRulesetPhase = "http_response_compression" + PhaseVersionGetParamsRulesetPhaseHTTPResponseFirewallManaged PhaseVersionGetParamsRulesetPhase = "http_response_firewall_managed" + PhaseVersionGetParamsRulesetPhaseHTTPResponseHeadersTransform PhaseVersionGetParamsRulesetPhase = "http_response_headers_transform" + PhaseVersionGetParamsRulesetPhaseMagicTransit PhaseVersionGetParamsRulesetPhase = "magic_transit" + PhaseVersionGetParamsRulesetPhaseMagicTransitIDsManaged PhaseVersionGetParamsRulesetPhase = "magic_transit_ids_managed" + PhaseVersionGetParamsRulesetPhaseMagicTransitManaged PhaseVersionGetParamsRulesetPhase = "magic_transit_managed" +) + +// A response object. +type PhaseVersionGetResponseEnvelope struct { + // A list of error messages. + Errors []PhaseVersionGetResponseEnvelopeErrors `json:"errors,required"` + // A list of warning messages. + Messages []PhaseVersionGetResponseEnvelopeMessages `json:"messages,required"` + // A result. + Result RulesetsRulesetResponse `json:"result,required"` + // Whether the API call was successful. + Success PhaseVersionGetResponseEnvelopeSuccess `json:"success,required"` + JSON phaseVersionGetResponseEnvelopeJSON `json:"-"` +} + +// phaseVersionGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [PhaseVersionGetResponseEnvelope] +type phaseVersionGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseVersionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseVersionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// A message. +type PhaseVersionGetResponseEnvelopeErrors struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source PhaseVersionGetResponseEnvelopeErrorsSource `json:"source"` + JSON phaseVersionGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// phaseVersionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [PhaseVersionGetResponseEnvelopeErrors] +type phaseVersionGetResponseEnvelopeErrorsJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseVersionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseVersionGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type PhaseVersionGetResponseEnvelopeErrorsSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON phaseVersionGetResponseEnvelopeErrorsSourceJSON `json:"-"` +} + +// phaseVersionGetResponseEnvelopeErrorsSourceJSON contains the JSON metadata for +// the struct [PhaseVersionGetResponseEnvelopeErrorsSource] +type phaseVersionGetResponseEnvelopeErrorsSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseVersionGetResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseVersionGetResponseEnvelopeErrorsSourceJSON) RawJSON() string { + return r.raw +} + +// A message. +type PhaseVersionGetResponseEnvelopeMessages struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source PhaseVersionGetResponseEnvelopeMessagesSource `json:"source"` + JSON phaseVersionGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// phaseVersionGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [PhaseVersionGetResponseEnvelopeMessages] +type phaseVersionGetResponseEnvelopeMessagesJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseVersionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseVersionGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type PhaseVersionGetResponseEnvelopeMessagesSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON phaseVersionGetResponseEnvelopeMessagesSourceJSON `json:"-"` +} + +// phaseVersionGetResponseEnvelopeMessagesSourceJSON contains the JSON metadata for +// the struct [PhaseVersionGetResponseEnvelopeMessagesSource] +type phaseVersionGetResponseEnvelopeMessagesSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PhaseVersionGetResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r phaseVersionGetResponseEnvelopeMessagesSourceJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type PhaseVersionGetResponseEnvelopeSuccess bool + +const ( + PhaseVersionGetResponseEnvelopeSuccessTrue PhaseVersionGetResponseEnvelopeSuccess = true +) diff --git a/rulesets/phaseversion_test.go b/rulesets/phaseversion_test.go new file mode 100644 index 00000000000..c6f6a3edac2 --- /dev/null +++ b/rulesets/phaseversion_test.go @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package rulesets_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/rulesets" +) + +func TestPhaseVersionListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Rulesets.Phases.Versions.List( + context.TODO(), + rulesets.PhaseVersionListParamsRulesetPhaseHTTPRequestFirewallCustom, + rulesets.PhaseVersionListParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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 TestPhaseVersionGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Rulesets.Phases.Versions.Get( + context.TODO(), + rulesets.PhaseVersionGetParamsRulesetPhaseHTTPRequestFirewallCustom, + "1", + rulesets.PhaseVersionGetParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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/rulesets/rule.go b/rulesets/rule.go new file mode 100644 index 00000000000..5aafc47ad3b --- /dev/null +++ b/rulesets/rule.go @@ -0,0 +1,654 @@ +// File generated from our OpenAPI spec by Stainless. + +package rulesets + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-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 +} + +// 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 + return +} + +// Adds a new rule to an account or zone ruleset. The rule will be added to the end +// of the existing list of rules in the ruleset by default. +func (r *RuleService) New(ctx context.Context, rulesetID string, params RuleNewParams, opts ...option.RequestOption) (res *RulesetsRulesetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RuleNewResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/rulesets/%s/rules", accountOrZone, accountOrZoneID, rulesetID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes an existing rule from an account or zone ruleset. +func (r *RuleService) Delete(ctx context.Context, rulesetID string, ruleID string, body RuleDeleteParams, opts ...option.RequestOption) (res *RulesetsRulesetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RuleDeleteResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if body.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = body.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = body.ZoneID + } + path := fmt.Sprintf("%s/%s/rulesets/%s/rules/%s", accountOrZone, accountOrZoneID, rulesetID, ruleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates an existing rule in an account ruleset. +func (r *RuleService) Edit(ctx context.Context, rulesetID string, ruleID string, params RuleEditParams, opts ...option.RequestOption) (res *RulesetsRulesetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RuleEditResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/rulesets/%s/rules/%s", accountOrZone, accountOrZoneID, rulesetID, ruleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type RuleNewParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // An object configuring where the rule will be placed. + Position param.Field[RuleNewParamsPosition] `json:"position"` +} + +func (r RuleNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// An object configuring where the rule will be placed. +// +// Satisfied by [rulesets.RuleNewParamsPositionBeforePosition], +// [rulesets.RuleNewParamsPositionAfterPosition], +// [rulesets.RuleNewParamsPositionIndexPosition]. +type RuleNewParamsPosition interface { + implementsRulesetsRuleNewParamsPosition() +} + +// An object configuring where the rule will be placed. +type RuleNewParamsPositionBeforePosition struct { + // The ID of another rule to place the rule before. An empty value causes the rule + // to be placed at the top. + Before param.Field[string] `json:"before"` +} + +func (r RuleNewParamsPositionBeforePosition) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RuleNewParamsPositionBeforePosition) implementsRulesetsRuleNewParamsPosition() {} + +// An object configuring where the rule will be placed. +type RuleNewParamsPositionAfterPosition struct { + // The ID of another rule to place the rule after. An empty value causes the rule + // to be placed at the bottom. + After param.Field[string] `json:"after"` +} + +func (r RuleNewParamsPositionAfterPosition) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RuleNewParamsPositionAfterPosition) implementsRulesetsRuleNewParamsPosition() {} + +// An object configuring where the rule will be placed. +type RuleNewParamsPositionIndexPosition struct { + // An index at which to place the rule, where index 1 is the first rule. + Index param.Field[float64] `json:"index"` +} + +func (r RuleNewParamsPositionIndexPosition) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RuleNewParamsPositionIndexPosition) implementsRulesetsRuleNewParamsPosition() {} + +// A response object. +type RuleNewResponseEnvelope struct { + // A list of error messages. + Errors []RuleNewResponseEnvelopeErrors `json:"errors,required"` + // A list of warning messages. + Messages []RuleNewResponseEnvelopeMessages `json:"messages,required"` + // A result. + Result RulesetsRulesetResponse `json:"result,required"` + // Whether the API call was successful. + Success RuleNewResponseEnvelopeSuccess `json:"success,required"` + JSON ruleNewResponseEnvelopeJSON `json:"-"` +} + +// ruleNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleNewResponseEnvelope] +type ruleNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// A message. +type RuleNewResponseEnvelopeErrors struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source RuleNewResponseEnvelopeErrorsSource `json:"source"` + JSON ruleNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleNewResponseEnvelopeErrors] +type ruleNewResponseEnvelopeErrorsJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type RuleNewResponseEnvelopeErrorsSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON ruleNewResponseEnvelopeErrorsSourceJSON `json:"-"` +} + +// ruleNewResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the +// struct [RuleNewResponseEnvelopeErrorsSource] +type ruleNewResponseEnvelopeErrorsSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleNewResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleNewResponseEnvelopeErrorsSourceJSON) RawJSON() string { + return r.raw +} + +// A message. +type RuleNewResponseEnvelopeMessages struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source RuleNewResponseEnvelopeMessagesSource `json:"source"` + JSON ruleNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleNewResponseEnvelopeMessages] +type ruleNewResponseEnvelopeMessagesJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type RuleNewResponseEnvelopeMessagesSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON ruleNewResponseEnvelopeMessagesSourceJSON `json:"-"` +} + +// ruleNewResponseEnvelopeMessagesSourceJSON contains the JSON metadata for the +// struct [RuleNewResponseEnvelopeMessagesSource] +type ruleNewResponseEnvelopeMessagesSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleNewResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleNewResponseEnvelopeMessagesSourceJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type RuleNewResponseEnvelopeSuccess bool + +const ( + RuleNewResponseEnvelopeSuccessTrue RuleNewResponseEnvelopeSuccess = true +) + +type RuleDeleteParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +// A response object. +type RuleDeleteResponseEnvelope struct { + // A list of error messages. + Errors []RuleDeleteResponseEnvelopeErrors `json:"errors,required"` + // A list of warning messages. + Messages []RuleDeleteResponseEnvelopeMessages `json:"messages,required"` + // A result. + Result RulesetsRulesetResponse `json:"result,required"` + // Whether the API call was successful. + Success RuleDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON ruleDeleteResponseEnvelopeJSON `json:"-"` +} + +// ruleDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleDeleteResponseEnvelope] +type ruleDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// A message. +type RuleDeleteResponseEnvelopeErrors struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source RuleDeleteResponseEnvelopeErrorsSource `json:"source"` + JSON ruleDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleDeleteResponseEnvelopeErrors] +type ruleDeleteResponseEnvelopeErrorsJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type RuleDeleteResponseEnvelopeErrorsSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON ruleDeleteResponseEnvelopeErrorsSourceJSON `json:"-"` +} + +// ruleDeleteResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the +// struct [RuleDeleteResponseEnvelopeErrorsSource] +type ruleDeleteResponseEnvelopeErrorsSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleDeleteResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleDeleteResponseEnvelopeErrorsSourceJSON) RawJSON() string { + return r.raw +} + +// A message. +type RuleDeleteResponseEnvelopeMessages struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source RuleDeleteResponseEnvelopeMessagesSource `json:"source"` + JSON ruleDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleDeleteResponseEnvelopeMessages] +type ruleDeleteResponseEnvelopeMessagesJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type RuleDeleteResponseEnvelopeMessagesSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON ruleDeleteResponseEnvelopeMessagesSourceJSON `json:"-"` +} + +// ruleDeleteResponseEnvelopeMessagesSourceJSON contains the JSON metadata for the +// struct [RuleDeleteResponseEnvelopeMessagesSource] +type ruleDeleteResponseEnvelopeMessagesSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleDeleteResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleDeleteResponseEnvelopeMessagesSourceJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type RuleDeleteResponseEnvelopeSuccess bool + +const ( + RuleDeleteResponseEnvelopeSuccessTrue RuleDeleteResponseEnvelopeSuccess = true +) + +type RuleEditParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // An object configuring where the rule will be placed. + Position param.Field[RuleEditParamsPosition] `json:"position"` +} + +func (r RuleEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// An object configuring where the rule will be placed. +// +// Satisfied by [rulesets.RuleEditParamsPositionBeforePosition], +// [rulesets.RuleEditParamsPositionAfterPosition], +// [rulesets.RuleEditParamsPositionIndexPosition]. +type RuleEditParamsPosition interface { + implementsRulesetsRuleEditParamsPosition() +} + +// An object configuring where the rule will be placed. +type RuleEditParamsPositionBeforePosition struct { + // The ID of another rule to place the rule before. An empty value causes the rule + // to be placed at the top. + Before param.Field[string] `json:"before"` +} + +func (r RuleEditParamsPositionBeforePosition) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RuleEditParamsPositionBeforePosition) implementsRulesetsRuleEditParamsPosition() {} + +// An object configuring where the rule will be placed. +type RuleEditParamsPositionAfterPosition struct { + // The ID of another rule to place the rule after. An empty value causes the rule + // to be placed at the bottom. + After param.Field[string] `json:"after"` +} + +func (r RuleEditParamsPositionAfterPosition) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RuleEditParamsPositionAfterPosition) implementsRulesetsRuleEditParamsPosition() {} + +// An object configuring where the rule will be placed. +type RuleEditParamsPositionIndexPosition struct { + // An index at which to place the rule, where index 1 is the first rule. + Index param.Field[float64] `json:"index"` +} + +func (r RuleEditParamsPositionIndexPosition) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RuleEditParamsPositionIndexPosition) implementsRulesetsRuleEditParamsPosition() {} + +// A response object. +type RuleEditResponseEnvelope struct { + // A list of error messages. + Errors []RuleEditResponseEnvelopeErrors `json:"errors,required"` + // A list of warning messages. + Messages []RuleEditResponseEnvelopeMessages `json:"messages,required"` + // A result. + Result RulesetsRulesetResponse `json:"result,required"` + // Whether the API call was successful. + Success RuleEditResponseEnvelopeSuccess `json:"success,required"` + JSON ruleEditResponseEnvelopeJSON `json:"-"` +} + +// ruleEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleEditResponseEnvelope] +type ruleEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// A message. +type RuleEditResponseEnvelopeErrors struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source RuleEditResponseEnvelopeErrorsSource `json:"source"` + JSON ruleEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleEditResponseEnvelopeErrors] +type ruleEditResponseEnvelopeErrorsJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type RuleEditResponseEnvelopeErrorsSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON ruleEditResponseEnvelopeErrorsSourceJSON `json:"-"` +} + +// ruleEditResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the +// struct [RuleEditResponseEnvelopeErrorsSource] +type ruleEditResponseEnvelopeErrorsSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleEditResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleEditResponseEnvelopeErrorsSourceJSON) RawJSON() string { + return r.raw +} + +// A message. +type RuleEditResponseEnvelopeMessages struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source RuleEditResponseEnvelopeMessagesSource `json:"source"` + JSON ruleEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleEditResponseEnvelopeMessages] +type ruleEditResponseEnvelopeMessagesJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type RuleEditResponseEnvelopeMessagesSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON ruleEditResponseEnvelopeMessagesSourceJSON `json:"-"` +} + +// ruleEditResponseEnvelopeMessagesSourceJSON contains the JSON metadata for the +// struct [RuleEditResponseEnvelopeMessagesSource] +type ruleEditResponseEnvelopeMessagesSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleEditResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleEditResponseEnvelopeMessagesSourceJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type RuleEditResponseEnvelopeSuccess bool + +const ( + RuleEditResponseEnvelopeSuccessTrue RuleEditResponseEnvelopeSuccess = true +) diff --git a/rulesets/rule_test.go b/rulesets/rule_test.go new file mode 100644 index 00000000000..ce85a188cd2 --- /dev/null +++ b/rulesets/rule_test.go @@ -0,0 +1,116 @@ +// File generated from our OpenAPI spec by Stainless. + +package rulesets_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/rulesets" +) + +func TestRuleNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Rulesets.Rules.New( + context.TODO(), + "2f2feab2026849078ba485f918791bdc", + rulesets.RuleNewParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + Position: cloudflare.F[rulesets.RuleNewParamsPosition](rulesets.RuleNewParamsPositionBeforePosition(rulesets.RuleNewParamsPositionBeforePosition{ + Before: cloudflare.F("da5e8e506c8e7877fe06cdf4c41add54"), + })), + }, + ) + 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 TestRuleDeleteWithOptionalParams(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("user@example.com"), + ) + _, err := client.Rulesets.Rules.Delete( + context.TODO(), + "2f2feab2026849078ba485f918791bdc", + "3a03d665bac047339bb530ecb439a90d", + rulesets.RuleDeleteParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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 TestRuleEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Rulesets.Rules.Edit( + context.TODO(), + "2f2feab2026849078ba485f918791bdc", + "3a03d665bac047339bb530ecb439a90d", + rulesets.RuleEditParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + Position: cloudflare.F[rulesets.RuleEditParamsPosition](rulesets.RuleEditParamsPositionBeforePosition(rulesets.RuleEditParamsPositionBeforePosition{ + Before: cloudflare.F("da5e8e506c8e7877fe06cdf4c41add54"), + })), + }, + ) + 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/rulesets/ruleset.go b/rulesets/ruleset.go new file mode 100644 index 00000000000..a68b3ec3c43 --- /dev/null +++ b/rulesets/ruleset.go @@ -0,0 +1,2505 @@ +// File generated from our OpenAPI spec by Stainless. + +package rulesets + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// RulesetService 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 [NewRulesetService] method instead. +type RulesetService struct { + Options []option.RequestOption + Phases *PhaseService + Rules *RuleService + Versions *VersionService +} + +// NewRulesetService 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 NewRulesetService(opts ...option.RequestOption) (r *RulesetService) { + r = &RulesetService{} + r.Options = opts + r.Phases = NewPhaseService(opts...) + r.Rules = NewRuleService(opts...) + r.Versions = NewVersionService(opts...) + return +} + +// Creates a ruleset. +func (r *RulesetService) New(ctx context.Context, params RulesetNewParams, opts ...option.RequestOption) (res *RulesetsRulesetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RulesetNewResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/rulesets", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates an account or zone ruleset, creating a new version. +func (r *RulesetService) Update(ctx context.Context, rulesetID string, params RulesetUpdateParams, opts ...option.RequestOption) (res *RulesetsRulesetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RulesetUpdateResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/rulesets/%s", accountOrZone, accountOrZoneID, rulesetID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches all rulesets. +func (r *RulesetService) List(ctx context.Context, query RulesetListParams, opts ...option.RequestOption) (res *RulesetsRulesetsResponse, err error) { + opts = append(r.Options[:], opts...) + var env RulesetListResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/rulesets", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes all versions of an existing account or zone ruleset. +func (r *RulesetService) Delete(ctx context.Context, rulesetID string, body RulesetDeleteParams, opts ...option.RequestOption) (err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + var accountOrZone string + var accountOrZoneID param.Field[string] + if body.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = body.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = body.ZoneID + } + path := fmt.Sprintf("%s/%s/rulesets/%s", accountOrZone, accountOrZoneID, rulesetID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) + return +} + +// Fetches the latest version of an account or zone ruleset. +func (r *RulesetService) Get(ctx context.Context, rulesetID string, query RulesetGetParams, opts ...option.RequestOption) (res *RulesetsRulesetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RulesetGetResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/rulesets/%s", accountOrZone, accountOrZoneID, rulesetID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// A ruleset object. +type RulesetsRulesetResponse struct { + // The unique ID of the ruleset. + ID string `json:"id,required"` + // The kind of the ruleset. + Kind RulesetsRulesetResponseKind `json:"kind,required"` + // The timestamp of when the ruleset was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The human-readable name of the ruleset. + Name string `json:"name,required"` + // The phase of the ruleset. + Phase RulesetsRulesetResponsePhase `json:"phase,required"` + // The list of rules in the ruleset. + Rules []RulesetsRulesetResponseRule `json:"rules,required"` + // The version of the ruleset. + Version string `json:"version,required"` + // An informative description of the ruleset. + Description string `json:"description"` + JSON rulesetsRulesetResponseJSON `json:"-"` +} + +// rulesetsRulesetResponseJSON contains the JSON metadata for the struct +// [RulesetsRulesetResponse] +type rulesetsRulesetResponseJSON struct { + ID apijson.Field + Kind apijson.Field + LastUpdated apijson.Field + Name apijson.Field + Phase apijson.Field + Rules apijson.Field + Version apijson.Field + Description apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetsRulesetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetsRulesetResponseJSON) RawJSON() string { + return r.raw +} + +// The kind of the ruleset. +type RulesetsRulesetResponseKind string + +const ( + RulesetsRulesetResponseKindManaged RulesetsRulesetResponseKind = "managed" + RulesetsRulesetResponseKindCustom RulesetsRulesetResponseKind = "custom" + RulesetsRulesetResponseKindRoot RulesetsRulesetResponseKind = "root" + RulesetsRulesetResponseKindZone RulesetsRulesetResponseKind = "zone" +) + +// The phase of the ruleset. +type RulesetsRulesetResponsePhase string + +const ( + RulesetsRulesetResponsePhaseDDOSL4 RulesetsRulesetResponsePhase = "ddos_l4" + RulesetsRulesetResponsePhaseDDOSL7 RulesetsRulesetResponsePhase = "ddos_l7" + RulesetsRulesetResponsePhaseHTTPConfigSettings RulesetsRulesetResponsePhase = "http_config_settings" + RulesetsRulesetResponsePhaseHTTPCustomErrors RulesetsRulesetResponsePhase = "http_custom_errors" + RulesetsRulesetResponsePhaseHTTPLogCustomFields RulesetsRulesetResponsePhase = "http_log_custom_fields" + RulesetsRulesetResponsePhaseHTTPRatelimit RulesetsRulesetResponsePhase = "http_ratelimit" + RulesetsRulesetResponsePhaseHTTPRequestCacheSettings RulesetsRulesetResponsePhase = "http_request_cache_settings" + RulesetsRulesetResponsePhaseHTTPRequestDynamicRedirect RulesetsRulesetResponsePhase = "http_request_dynamic_redirect" + RulesetsRulesetResponsePhaseHTTPRequestFirewallCustom RulesetsRulesetResponsePhase = "http_request_firewall_custom" + RulesetsRulesetResponsePhaseHTTPRequestFirewallManaged RulesetsRulesetResponsePhase = "http_request_firewall_managed" + RulesetsRulesetResponsePhaseHTTPRequestLateTransform RulesetsRulesetResponsePhase = "http_request_late_transform" + RulesetsRulesetResponsePhaseHTTPRequestOrigin RulesetsRulesetResponsePhase = "http_request_origin" + RulesetsRulesetResponsePhaseHTTPRequestRedirect RulesetsRulesetResponsePhase = "http_request_redirect" + RulesetsRulesetResponsePhaseHTTPRequestSanitize RulesetsRulesetResponsePhase = "http_request_sanitize" + RulesetsRulesetResponsePhaseHTTPRequestSbfm RulesetsRulesetResponsePhase = "http_request_sbfm" + RulesetsRulesetResponsePhaseHTTPRequestSelectConfiguration RulesetsRulesetResponsePhase = "http_request_select_configuration" + RulesetsRulesetResponsePhaseHTTPRequestTransform RulesetsRulesetResponsePhase = "http_request_transform" + RulesetsRulesetResponsePhaseHTTPResponseCompression RulesetsRulesetResponsePhase = "http_response_compression" + RulesetsRulesetResponsePhaseHTTPResponseFirewallManaged RulesetsRulesetResponsePhase = "http_response_firewall_managed" + RulesetsRulesetResponsePhaseHTTPResponseHeadersTransform RulesetsRulesetResponsePhase = "http_response_headers_transform" + RulesetsRulesetResponsePhaseMagicTransit RulesetsRulesetResponsePhase = "magic_transit" + RulesetsRulesetResponsePhaseMagicTransitIDsManaged RulesetsRulesetResponsePhase = "magic_transit_ids_managed" + RulesetsRulesetResponsePhaseMagicTransitManaged RulesetsRulesetResponsePhase = "magic_transit_managed" +) + +// Union satisfied by [rulesets.RulesetsRulesetResponseRulesRulesetsBlockRule], +// [rulesets.RulesetsRulesetResponseRulesRulesetsExecuteRule], +// [rulesets.RulesetsRulesetResponseRulesRulesetsLogRule] or +// [rulesets.RulesetsRulesetResponseRulesRulesetsSkipRule]. +type RulesetsRulesetResponseRule interface { + implementsRulesetsRulesetsRulesetResponseRule() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RulesetsRulesetResponseRule)(nil)).Elem(), + "action", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RulesetsRulesetResponseRulesRulesetsBlockRule{}), + DiscriminatorValue: "block", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RulesetsRulesetResponseRulesRulesetsExecuteRule{}), + DiscriminatorValue: "execute", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RulesetsRulesetResponseRulesRulesetsLogRule{}), + DiscriminatorValue: "log", + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RulesetsRulesetResponseRulesRulesetsSkipRule{}), + DiscriminatorValue: "skip", + }, + ) +} + +type RulesetsRulesetResponseRulesRulesetsBlockRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` + // The unique ID of the rule. + ID string `json:"id"` + // The action to perform when the rule matches. + Action RulesetsRulesetResponseRulesRulesetsBlockRuleAction `json:"action"` + // The parameters configuring the rule's action. + ActionParameters RulesetsRulesetResponseRulesRulesetsBlockRuleActionParameters `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // An object configuring the rule's logging behavior. + Logging RulesetsRulesetResponseRulesRulesetsBlockRuleLogging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + JSON rulesetsRulesetResponseRulesRulesetsBlockRuleJSON `json:"-"` +} + +// rulesetsRulesetResponseRulesRulesetsBlockRuleJSON contains the JSON metadata for +// the struct [RulesetsRulesetResponseRulesRulesetsBlockRule] +type rulesetsRulesetResponseRulesRulesetsBlockRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetsRulesetResponseRulesRulesetsBlockRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetsRulesetResponseRulesRulesetsBlockRuleJSON) RawJSON() string { + return r.raw +} + +func (r RulesetsRulesetResponseRulesRulesetsBlockRule) implementsRulesetsRulesetsRulesetResponseRule() { +} + +// The action to perform when the rule matches. +type RulesetsRulesetResponseRulesRulesetsBlockRuleAction string + +const ( + RulesetsRulesetResponseRulesRulesetsBlockRuleActionBlock RulesetsRulesetResponseRulesRulesetsBlockRuleAction = "block" +) + +// The parameters configuring the rule's action. +type RulesetsRulesetResponseRulesRulesetsBlockRuleActionParameters struct { + // The response to show when the block is applied. + Response RulesetsRulesetResponseRulesRulesetsBlockRuleActionParametersResponse `json:"response"` + JSON rulesetsRulesetResponseRulesRulesetsBlockRuleActionParametersJSON `json:"-"` +} + +// rulesetsRulesetResponseRulesRulesetsBlockRuleActionParametersJSON contains the +// JSON metadata for the struct +// [RulesetsRulesetResponseRulesRulesetsBlockRuleActionParameters] +type rulesetsRulesetResponseRulesRulesetsBlockRuleActionParametersJSON struct { + Response apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetsRulesetResponseRulesRulesetsBlockRuleActionParameters) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetsRulesetResponseRulesRulesetsBlockRuleActionParametersJSON) RawJSON() string { + return r.raw +} + +// The response to show when the block is applied. +type RulesetsRulesetResponseRulesRulesetsBlockRuleActionParametersResponse struct { + // The content to return. + Content string `json:"content,required"` + // The type of the content to return. + ContentType string `json:"content_type,required"` + // The status code to return. + StatusCode int64 `json:"status_code,required"` + JSON rulesetsRulesetResponseRulesRulesetsBlockRuleActionParametersResponseJSON `json:"-"` +} + +// rulesetsRulesetResponseRulesRulesetsBlockRuleActionParametersResponseJSON +// contains the JSON metadata for the struct +// [RulesetsRulesetResponseRulesRulesetsBlockRuleActionParametersResponse] +type rulesetsRulesetResponseRulesRulesetsBlockRuleActionParametersResponseJSON struct { + Content apijson.Field + ContentType apijson.Field + StatusCode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetsRulesetResponseRulesRulesetsBlockRuleActionParametersResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetsRulesetResponseRulesRulesetsBlockRuleActionParametersResponseJSON) RawJSON() string { + return r.raw +} + +// An object configuring the rule's logging behavior. +type RulesetsRulesetResponseRulesRulesetsBlockRuleLogging struct { + // Whether to generate a log when the rule matches. + Enabled bool `json:"enabled,required"` + JSON rulesetsRulesetResponseRulesRulesetsBlockRuleLoggingJSON `json:"-"` +} + +// rulesetsRulesetResponseRulesRulesetsBlockRuleLoggingJSON contains the JSON +// metadata for the struct [RulesetsRulesetResponseRulesRulesetsBlockRuleLogging] +type rulesetsRulesetResponseRulesRulesetsBlockRuleLoggingJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetsRulesetResponseRulesRulesetsBlockRuleLogging) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetsRulesetResponseRulesRulesetsBlockRuleLoggingJSON) RawJSON() string { + return r.raw +} + +type RulesetsRulesetResponseRulesRulesetsExecuteRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` + // The unique ID of the rule. + ID string `json:"id"` + // The action to perform when the rule matches. + Action RulesetsRulesetResponseRulesRulesetsExecuteRuleAction `json:"action"` + // The parameters configuring the rule's action. + ActionParameters RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParameters `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // An object configuring the rule's logging behavior. + Logging RulesetsRulesetResponseRulesRulesetsExecuteRuleLogging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + JSON rulesetsRulesetResponseRulesRulesetsExecuteRuleJSON `json:"-"` +} + +// rulesetsRulesetResponseRulesRulesetsExecuteRuleJSON contains the JSON metadata +// for the struct [RulesetsRulesetResponseRulesRulesetsExecuteRule] +type rulesetsRulesetResponseRulesRulesetsExecuteRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetsRulesetResponseRulesRulesetsExecuteRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetsRulesetResponseRulesRulesetsExecuteRuleJSON) RawJSON() string { + return r.raw +} + +func (r RulesetsRulesetResponseRulesRulesetsExecuteRule) implementsRulesetsRulesetsRulesetResponseRule() { +} + +// The action to perform when the rule matches. +type RulesetsRulesetResponseRulesRulesetsExecuteRuleAction string + +const ( + RulesetsRulesetResponseRulesRulesetsExecuteRuleActionExecute RulesetsRulesetResponseRulesRulesetsExecuteRuleAction = "execute" +) + +// The parameters configuring the rule's action. +type RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParameters struct { + // The ID of the ruleset to execute. + ID string `json:"id,required"` + // The configuration to use for matched data logging. + MatchedData RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersMatchedData `json:"matched_data"` + // A set of overrides to apply to the target ruleset. + Overrides RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverrides `json:"overrides"` + JSON rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersJSON `json:"-"` +} + +// rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersJSON contains the +// JSON metadata for the struct +// [RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParameters] +type rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersJSON struct { + ID apijson.Field + MatchedData apijson.Field + Overrides apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParameters) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersJSON) RawJSON() string { + return r.raw +} + +// The configuration to use for matched data logging. +type RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersMatchedData struct { + // The public key to encrypt matched data logs with. + PublicKey string `json:"public_key,required"` + JSON rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON `json:"-"` +} + +// rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON +// contains the JSON metadata for the struct +// [RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersMatchedData] +type rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON struct { + PublicKey apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersMatchedData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON) RawJSON() string { + return r.raw +} + +// A set of overrides to apply to the target ruleset. +type RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverrides struct { + // An action to override all rules with. This option has lower precedence than rule + // and category overrides. + Action string `json:"action"` + // A list of category-level overrides. This option has the second-highest + // precedence after rule-level overrides. + Categories []RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory `json:"categories"` + // Whether to enable execution of all rules. This option has lower precedence than + // rule and category overrides. + Enabled bool `json:"enabled"` + // A list of rule-level overrides. This option has the highest precedence. + Rules []RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule `json:"rules"` + // A sensitivity level to set for all rules. This option has lower precedence than + // rule and category overrides and is only applicable for DDoS phases. + SensitivityLevel RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel `json:"sensitivity_level"` + JSON rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON `json:"-"` +} + +// rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON +// contains the JSON metadata for the struct +// [RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverrides] +type rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON struct { + Action apijson.Field + Categories apijson.Field + Enabled apijson.Field + Rules apijson.Field + SensitivityLevel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverrides) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON) RawJSON() string { + return r.raw +} + +// A category-level override +type RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { + // The name of the category to override. + Category string `json:"category,required"` + // The action to override rules in the category with. + Action string `json:"action"` + // Whether to enable execution of rules in the category. + Enabled bool `json:"enabled"` + // The sensitivity level to use for rules in the category. + SensitivityLevel RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel `json:"sensitivity_level"` + JSON rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON `json:"-"` +} + +// rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON +// contains the JSON metadata for the struct +// [RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory] +type rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON struct { + Category apijson.Field + Action apijson.Field + Enabled apijson.Field + SensitivityLevel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON) RawJSON() string { + return r.raw +} + +// The sensitivity level to use for rules in the category. +type RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string + +const ( + RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" + RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" + RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" + RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" +) + +// A rule-level override +type RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule struct { + // The ID of the rule to override. + ID string `json:"id,required"` + // The action to override the rule with. + Action string `json:"action"` + // Whether to enable execution of the rule. + Enabled bool `json:"enabled"` + // The score threshold to use for the rule. + ScoreThreshold int64 `json:"score_threshold"` + // The sensitivity level to use for the rule. + SensitivityLevel RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel `json:"sensitivity_level"` + JSON rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON `json:"-"` +} + +// rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON +// contains the JSON metadata for the struct +// [RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule] +type rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON struct { + ID apijson.Field + Action apijson.Field + Enabled apijson.Field + ScoreThreshold apijson.Field + SensitivityLevel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON) RawJSON() string { + return r.raw +} + +// The sensitivity level to use for the rule. +type RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string + +const ( + RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" + RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" + RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" + RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" +) + +// A sensitivity level to set for all rules. This option has lower precedence than +// rule and category overrides and is only applicable for DDoS phases. +type RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string + +const ( + RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" + RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" + RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" + RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetsRulesetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" +) + +// An object configuring the rule's logging behavior. +type RulesetsRulesetResponseRulesRulesetsExecuteRuleLogging struct { + // Whether to generate a log when the rule matches. + Enabled bool `json:"enabled,required"` + JSON rulesetsRulesetResponseRulesRulesetsExecuteRuleLoggingJSON `json:"-"` +} + +// rulesetsRulesetResponseRulesRulesetsExecuteRuleLoggingJSON contains the JSON +// metadata for the struct [RulesetsRulesetResponseRulesRulesetsExecuteRuleLogging] +type rulesetsRulesetResponseRulesRulesetsExecuteRuleLoggingJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetsRulesetResponseRulesRulesetsExecuteRuleLogging) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetsRulesetResponseRulesRulesetsExecuteRuleLoggingJSON) RawJSON() string { + return r.raw +} + +type RulesetsRulesetResponseRulesRulesetsLogRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` + // The unique ID of the rule. + ID string `json:"id"` + // The action to perform when the rule matches. + Action RulesetsRulesetResponseRulesRulesetsLogRuleAction `json:"action"` + // The parameters configuring the rule's action. + ActionParameters interface{} `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // An object configuring the rule's logging behavior. + Logging RulesetsRulesetResponseRulesRulesetsLogRuleLogging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + JSON rulesetsRulesetResponseRulesRulesetsLogRuleJSON `json:"-"` +} + +// rulesetsRulesetResponseRulesRulesetsLogRuleJSON contains the JSON metadata for +// the struct [RulesetsRulesetResponseRulesRulesetsLogRule] +type rulesetsRulesetResponseRulesRulesetsLogRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetsRulesetResponseRulesRulesetsLogRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetsRulesetResponseRulesRulesetsLogRuleJSON) RawJSON() string { + return r.raw +} + +func (r RulesetsRulesetResponseRulesRulesetsLogRule) implementsRulesetsRulesetsRulesetResponseRule() { +} + +// The action to perform when the rule matches. +type RulesetsRulesetResponseRulesRulesetsLogRuleAction string + +const ( + RulesetsRulesetResponseRulesRulesetsLogRuleActionLog RulesetsRulesetResponseRulesRulesetsLogRuleAction = "log" +) + +// An object configuring the rule's logging behavior. +type RulesetsRulesetResponseRulesRulesetsLogRuleLogging struct { + // Whether to generate a log when the rule matches. + Enabled bool `json:"enabled,required"` + JSON rulesetsRulesetResponseRulesRulesetsLogRuleLoggingJSON `json:"-"` +} + +// rulesetsRulesetResponseRulesRulesetsLogRuleLoggingJSON contains the JSON +// metadata for the struct [RulesetsRulesetResponseRulesRulesetsLogRuleLogging] +type rulesetsRulesetResponseRulesRulesetsLogRuleLoggingJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetsRulesetResponseRulesRulesetsLogRuleLogging) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetsRulesetResponseRulesRulesetsLogRuleLoggingJSON) RawJSON() string { + return r.raw +} + +type RulesetsRulesetResponseRulesRulesetsSkipRule struct { + // The timestamp of when the rule was last modified. + LastUpdated time.Time `json:"last_updated,required" format:"date-time"` + // The version of the rule. + Version string `json:"version,required"` + // The unique ID of the rule. + ID string `json:"id"` + // The action to perform when the rule matches. + Action RulesetsRulesetResponseRulesRulesetsSkipRuleAction `json:"action"` + // The parameters configuring the rule's action. + ActionParameters RulesetsRulesetResponseRulesRulesetsSkipRuleActionParameters `json:"action_parameters"` + // The categories of the rule. + Categories []string `json:"categories"` + // An informative description of the rule. + Description string `json:"description"` + // Whether the rule should be executed. + Enabled bool `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression string `json:"expression"` + // An object configuring the rule's logging behavior. + Logging RulesetsRulesetResponseRulesRulesetsSkipRuleLogging `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref string `json:"ref"` + JSON rulesetsRulesetResponseRulesRulesetsSkipRuleJSON `json:"-"` +} + +// rulesetsRulesetResponseRulesRulesetsSkipRuleJSON contains the JSON metadata for +// the struct [RulesetsRulesetResponseRulesRulesetsSkipRule] +type rulesetsRulesetResponseRulesRulesetsSkipRuleJSON struct { + LastUpdated apijson.Field + Version apijson.Field + ID apijson.Field + Action apijson.Field + ActionParameters apijson.Field + Categories apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + Logging apijson.Field + Ref apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetsRulesetResponseRulesRulesetsSkipRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetsRulesetResponseRulesRulesetsSkipRuleJSON) RawJSON() string { + return r.raw +} + +func (r RulesetsRulesetResponseRulesRulesetsSkipRule) implementsRulesetsRulesetsRulesetResponseRule() { +} + +// The action to perform when the rule matches. +type RulesetsRulesetResponseRulesRulesetsSkipRuleAction string + +const ( + RulesetsRulesetResponseRulesRulesetsSkipRuleActionSkip RulesetsRulesetResponseRulesRulesetsSkipRuleAction = "skip" +) + +// The parameters configuring the rule's action. +type RulesetsRulesetResponseRulesRulesetsSkipRuleActionParameters struct { + // A list of phases to skip the execution of. This option is incompatible with the + // ruleset and rulesets options. + Phases []RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase `json:"phases"` + // A list of legacy security products to skip the execution of. + Products []RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersProduct `json:"products"` + // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the + // execution of. This option is incompatible with the ruleset option. + Rules map[string][]string `json:"rules"` + // A ruleset to skip the execution of. This option is incompatible with the + // rulesets, rules and phases options. + Ruleset RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersRuleset `json:"ruleset"` + // A list of ruleset IDs to skip the execution of. This option is incompatible with + // the ruleset and phases options. + Rulesets []string `json:"rulesets"` + JSON rulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersJSON `json:"-"` +} + +// rulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersJSON contains the +// JSON metadata for the struct +// [RulesetsRulesetResponseRulesRulesetsSkipRuleActionParameters] +type rulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersJSON struct { + Phases apijson.Field + Products apijson.Field + Rules apijson.Field + Ruleset apijson.Field + Rulesets apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetsRulesetResponseRulesRulesetsSkipRuleActionParameters) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersJSON) RawJSON() string { + return r.raw +} + +// A phase to skip the execution of. +type RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase string + +const ( + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL4 RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL7 RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" +) + +// The name of a legacy security product to skip the execution of. +type RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersProduct string + +const ( + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersProductBic RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersProduct = "bic" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersProductHot RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersProduct = "hot" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersProductUABlock RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersProductWAF RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersProduct = "waf" + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" +) + +// A ruleset to skip the execution of. This option is incompatible with the +// rulesets, rules and phases options. +type RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersRuleset string + +const ( + RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetsRulesetResponseRulesRulesetsSkipRuleActionParametersRuleset = "current" +) + +// An object configuring the rule's logging behavior. +type RulesetsRulesetResponseRulesRulesetsSkipRuleLogging struct { + // Whether to generate a log when the rule matches. + Enabled bool `json:"enabled,required"` + JSON rulesetsRulesetResponseRulesRulesetsSkipRuleLoggingJSON `json:"-"` +} + +// rulesetsRulesetResponseRulesRulesetsSkipRuleLoggingJSON contains the JSON +// metadata for the struct [RulesetsRulesetResponseRulesRulesetsSkipRuleLogging] +type rulesetsRulesetResponseRulesRulesetsSkipRuleLoggingJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetsRulesetResponseRulesRulesetsSkipRuleLogging) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetsRulesetResponseRulesRulesetsSkipRuleLoggingJSON) RawJSON() string { + return r.raw +} + +type RulesetsRulesetsResponse []RulesetsRulesetsResponse + +// A ruleset object. +type RulesetListResponse struct { + // The kind of the ruleset. + Kind RulesetListResponseKind `json:"kind,required"` + // The human-readable name of the ruleset. + Name string `json:"name,required"` + // The phase of the ruleset. + Phase RulesetListResponsePhase `json:"phase,required"` + // The unique ID of the ruleset. + ID string `json:"id"` + // An informative description of the ruleset. + Description string `json:"description"` + // The timestamp of when the ruleset was last modified. + LastUpdated time.Time `json:"last_updated" format:"date-time"` + // The version of the ruleset. + Version string `json:"version"` + JSON rulesetListResponseJSON `json:"-"` +} + +// rulesetListResponseJSON contains the JSON metadata for the struct +// [RulesetListResponse] +type rulesetListResponseJSON struct { + Kind apijson.Field + Name apijson.Field + Phase apijson.Field + ID apijson.Field + Description apijson.Field + LastUpdated apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetListResponseJSON) RawJSON() string { + return r.raw +} + +// The kind of the ruleset. +type RulesetListResponseKind string + +const ( + RulesetListResponseKindManaged RulesetListResponseKind = "managed" + RulesetListResponseKindCustom RulesetListResponseKind = "custom" + RulesetListResponseKindRoot RulesetListResponseKind = "root" + RulesetListResponseKindZone RulesetListResponseKind = "zone" +) + +// The phase of the ruleset. +type RulesetListResponsePhase string + +const ( + RulesetListResponsePhaseDDOSL4 RulesetListResponsePhase = "ddos_l4" + RulesetListResponsePhaseDDOSL7 RulesetListResponsePhase = "ddos_l7" + RulesetListResponsePhaseHTTPConfigSettings RulesetListResponsePhase = "http_config_settings" + RulesetListResponsePhaseHTTPCustomErrors RulesetListResponsePhase = "http_custom_errors" + RulesetListResponsePhaseHTTPLogCustomFields RulesetListResponsePhase = "http_log_custom_fields" + RulesetListResponsePhaseHTTPRatelimit RulesetListResponsePhase = "http_ratelimit" + RulesetListResponsePhaseHTTPRequestCacheSettings RulesetListResponsePhase = "http_request_cache_settings" + RulesetListResponsePhaseHTTPRequestDynamicRedirect RulesetListResponsePhase = "http_request_dynamic_redirect" + RulesetListResponsePhaseHTTPRequestFirewallCustom RulesetListResponsePhase = "http_request_firewall_custom" + RulesetListResponsePhaseHTTPRequestFirewallManaged RulesetListResponsePhase = "http_request_firewall_managed" + RulesetListResponsePhaseHTTPRequestLateTransform RulesetListResponsePhase = "http_request_late_transform" + RulesetListResponsePhaseHTTPRequestOrigin RulesetListResponsePhase = "http_request_origin" + RulesetListResponsePhaseHTTPRequestRedirect RulesetListResponsePhase = "http_request_redirect" + RulesetListResponsePhaseHTTPRequestSanitize RulesetListResponsePhase = "http_request_sanitize" + RulesetListResponsePhaseHTTPRequestSbfm RulesetListResponsePhase = "http_request_sbfm" + RulesetListResponsePhaseHTTPRequestSelectConfiguration RulesetListResponsePhase = "http_request_select_configuration" + RulesetListResponsePhaseHTTPRequestTransform RulesetListResponsePhase = "http_request_transform" + RulesetListResponsePhaseHTTPResponseCompression RulesetListResponsePhase = "http_response_compression" + RulesetListResponsePhaseHTTPResponseFirewallManaged RulesetListResponsePhase = "http_response_firewall_managed" + RulesetListResponsePhaseHTTPResponseHeadersTransform RulesetListResponsePhase = "http_response_headers_transform" + RulesetListResponsePhaseMagicTransit RulesetListResponsePhase = "magic_transit" + RulesetListResponsePhaseMagicTransitIDsManaged RulesetListResponsePhase = "magic_transit_ids_managed" + RulesetListResponsePhaseMagicTransitManaged RulesetListResponsePhase = "magic_transit_managed" +) + +type RulesetNewParams struct { + // The kind of the ruleset. + Kind param.Field[RulesetNewParamsKind] `json:"kind,required"` + // The human-readable name of the ruleset. + Name param.Field[string] `json:"name,required"` + // The phase of the ruleset. + Phase param.Field[RulesetNewParamsPhase] `json:"phase,required"` + // The list of rules in the ruleset. + Rules param.Field[[]RulesetNewParamsRule] `json:"rules,required"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // An informative description of the ruleset. + Description param.Field[string] `json:"description"` +} + +func (r RulesetNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The kind of the ruleset. +type RulesetNewParamsKind string + +const ( + RulesetNewParamsKindManaged RulesetNewParamsKind = "managed" + RulesetNewParamsKindCustom RulesetNewParamsKind = "custom" + RulesetNewParamsKindRoot RulesetNewParamsKind = "root" + RulesetNewParamsKindZone RulesetNewParamsKind = "zone" +) + +// The phase of the ruleset. +type RulesetNewParamsPhase string + +const ( + RulesetNewParamsPhaseDDOSL4 RulesetNewParamsPhase = "ddos_l4" + RulesetNewParamsPhaseDDOSL7 RulesetNewParamsPhase = "ddos_l7" + RulesetNewParamsPhaseHTTPConfigSettings RulesetNewParamsPhase = "http_config_settings" + RulesetNewParamsPhaseHTTPCustomErrors RulesetNewParamsPhase = "http_custom_errors" + RulesetNewParamsPhaseHTTPLogCustomFields RulesetNewParamsPhase = "http_log_custom_fields" + RulesetNewParamsPhaseHTTPRatelimit RulesetNewParamsPhase = "http_ratelimit" + RulesetNewParamsPhaseHTTPRequestCacheSettings RulesetNewParamsPhase = "http_request_cache_settings" + RulesetNewParamsPhaseHTTPRequestDynamicRedirect RulesetNewParamsPhase = "http_request_dynamic_redirect" + RulesetNewParamsPhaseHTTPRequestFirewallCustom RulesetNewParamsPhase = "http_request_firewall_custom" + RulesetNewParamsPhaseHTTPRequestFirewallManaged RulesetNewParamsPhase = "http_request_firewall_managed" + RulesetNewParamsPhaseHTTPRequestLateTransform RulesetNewParamsPhase = "http_request_late_transform" + RulesetNewParamsPhaseHTTPRequestOrigin RulesetNewParamsPhase = "http_request_origin" + RulesetNewParamsPhaseHTTPRequestRedirect RulesetNewParamsPhase = "http_request_redirect" + RulesetNewParamsPhaseHTTPRequestSanitize RulesetNewParamsPhase = "http_request_sanitize" + RulesetNewParamsPhaseHTTPRequestSbfm RulesetNewParamsPhase = "http_request_sbfm" + RulesetNewParamsPhaseHTTPRequestSelectConfiguration RulesetNewParamsPhase = "http_request_select_configuration" + RulesetNewParamsPhaseHTTPRequestTransform RulesetNewParamsPhase = "http_request_transform" + RulesetNewParamsPhaseHTTPResponseCompression RulesetNewParamsPhase = "http_response_compression" + RulesetNewParamsPhaseHTTPResponseFirewallManaged RulesetNewParamsPhase = "http_response_firewall_managed" + RulesetNewParamsPhaseHTTPResponseHeadersTransform RulesetNewParamsPhase = "http_response_headers_transform" + RulesetNewParamsPhaseMagicTransit RulesetNewParamsPhase = "magic_transit" + RulesetNewParamsPhaseMagicTransitIDsManaged RulesetNewParamsPhase = "magic_transit_ids_managed" + RulesetNewParamsPhaseMagicTransitManaged RulesetNewParamsPhase = "magic_transit_managed" +) + +// Satisfied by [rulesets.RulesetNewParamsRulesRulesetsBlockRule], +// [rulesets.RulesetNewParamsRulesRulesetsExecuteRule], +// [rulesets.RulesetNewParamsRulesRulesetsLogRule], +// [rulesets.RulesetNewParamsRulesRulesetsSkipRule]. +type RulesetNewParamsRule interface { + implementsRulesetsRulesetNewParamsRule() +} + +type RulesetNewParamsRulesRulesetsBlockRule struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[RulesetNewParamsRulesRulesetsBlockRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[RulesetNewParamsRulesRulesetsBlockRuleActionParameters] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[RulesetNewParamsRulesRulesetsBlockRuleLogging] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r RulesetNewParamsRulesRulesetsBlockRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RulesetNewParamsRulesRulesetsBlockRule) implementsRulesetsRulesetNewParamsRule() {} + +// The action to perform when the rule matches. +type RulesetNewParamsRulesRulesetsBlockRuleAction string + +const ( + RulesetNewParamsRulesRulesetsBlockRuleActionBlock RulesetNewParamsRulesRulesetsBlockRuleAction = "block" +) + +// The parameters configuring the rule's action. +type RulesetNewParamsRulesRulesetsBlockRuleActionParameters struct { + // The response to show when the block is applied. + Response param.Field[RulesetNewParamsRulesRulesetsBlockRuleActionParametersResponse] `json:"response"` +} + +func (r RulesetNewParamsRulesRulesetsBlockRuleActionParameters) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The response to show when the block is applied. +type RulesetNewParamsRulesRulesetsBlockRuleActionParametersResponse struct { + // The content to return. + Content param.Field[string] `json:"content,required"` + // The type of the content to return. + ContentType param.Field[string] `json:"content_type,required"` + // The status code to return. + StatusCode param.Field[int64] `json:"status_code,required"` +} + +func (r RulesetNewParamsRulesRulesetsBlockRuleActionParametersResponse) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// An object configuring the rule's logging behavior. +type RulesetNewParamsRulesRulesetsBlockRuleLogging struct { + // Whether to generate a log when the rule matches. + Enabled param.Field[bool] `json:"enabled,required"` +} + +func (r RulesetNewParamsRulesRulesetsBlockRuleLogging) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RulesetNewParamsRulesRulesetsExecuteRule struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[RulesetNewParamsRulesRulesetsExecuteRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[RulesetNewParamsRulesRulesetsExecuteRuleActionParameters] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[RulesetNewParamsRulesRulesetsExecuteRuleLogging] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r RulesetNewParamsRulesRulesetsExecuteRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RulesetNewParamsRulesRulesetsExecuteRule) implementsRulesetsRulesetNewParamsRule() {} + +// The action to perform when the rule matches. +type RulesetNewParamsRulesRulesetsExecuteRuleAction string + +const ( + RulesetNewParamsRulesRulesetsExecuteRuleActionExecute RulesetNewParamsRulesRulesetsExecuteRuleAction = "execute" +) + +// The parameters configuring the rule's action. +type RulesetNewParamsRulesRulesetsExecuteRuleActionParameters struct { + // The ID of the ruleset to execute. + ID param.Field[string] `json:"id,required"` + // The configuration to use for matched data logging. + MatchedData param.Field[RulesetNewParamsRulesRulesetsExecuteRuleActionParametersMatchedData] `json:"matched_data"` + // A set of overrides to apply to the target ruleset. + Overrides param.Field[RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverrides] `json:"overrides"` +} + +func (r RulesetNewParamsRulesRulesetsExecuteRuleActionParameters) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The configuration to use for matched data logging. +type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersMatchedData struct { + // The public key to encrypt matched data logs with. + PublicKey param.Field[string] `json:"public_key,required"` +} + +func (r RulesetNewParamsRulesRulesetsExecuteRuleActionParametersMatchedData) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A set of overrides to apply to the target ruleset. +type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverrides struct { + // An action to override all rules with. This option has lower precedence than rule + // and category overrides. + Action param.Field[string] `json:"action"` + // A list of category-level overrides. This option has the second-highest + // precedence after rule-level overrides. + Categories param.Field[[]RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory] `json:"categories"` + // Whether to enable execution of all rules. This option has lower precedence than + // rule and category overrides. + Enabled param.Field[bool] `json:"enabled"` + // A list of rule-level overrides. This option has the highest precedence. + Rules param.Field[[]RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRule] `json:"rules"` + // A sensitivity level to set for all rules. This option has lower precedence than + // rule and category overrides and is only applicable for DDoS phases. + SensitivityLevel param.Field[RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel] `json:"sensitivity_level"` +} + +func (r RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverrides) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A category-level override +type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { + // The name of the category to override. + Category param.Field[string] `json:"category,required"` + // The action to override rules in the category with. + Action param.Field[string] `json:"action"` + // Whether to enable execution of rules in the category. + Enabled param.Field[bool] `json:"enabled"` + // The sensitivity level to use for rules in the category. + SensitivityLevel param.Field[RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel] `json:"sensitivity_level"` +} + +func (r RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The sensitivity level to use for rules in the category. +type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string + +const ( + RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" + RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" + RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" + RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" +) + +// A rule-level override +type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRule struct { + // The ID of the rule to override. + ID param.Field[string] `json:"id,required"` + // The action to override the rule with. + Action param.Field[string] `json:"action"` + // Whether to enable execution of the rule. + Enabled param.Field[bool] `json:"enabled"` + // The score threshold to use for the rule. + ScoreThreshold param.Field[int64] `json:"score_threshold"` + // The sensitivity level to use for the rule. + SensitivityLevel param.Field[RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel] `json:"sensitivity_level"` +} + +func (r RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The sensitivity level to use for the rule. +type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string + +const ( + RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" + RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" + RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" + RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" +) + +// A sensitivity level to set for all rules. This option has lower precedence than +// rule and category overrides and is only applicable for DDoS phases. +type RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string + +const ( + RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" + RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" + RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" + RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetNewParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" +) + +// An object configuring the rule's logging behavior. +type RulesetNewParamsRulesRulesetsExecuteRuleLogging struct { + // Whether to generate a log when the rule matches. + Enabled param.Field[bool] `json:"enabled,required"` +} + +func (r RulesetNewParamsRulesRulesetsExecuteRuleLogging) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RulesetNewParamsRulesRulesetsLogRule struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[RulesetNewParamsRulesRulesetsLogRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[interface{}] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[RulesetNewParamsRulesRulesetsLogRuleLogging] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r RulesetNewParamsRulesRulesetsLogRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RulesetNewParamsRulesRulesetsLogRule) implementsRulesetsRulesetNewParamsRule() {} + +// The action to perform when the rule matches. +type RulesetNewParamsRulesRulesetsLogRuleAction string + +const ( + RulesetNewParamsRulesRulesetsLogRuleActionLog RulesetNewParamsRulesRulesetsLogRuleAction = "log" +) + +// An object configuring the rule's logging behavior. +type RulesetNewParamsRulesRulesetsLogRuleLogging struct { + // Whether to generate a log when the rule matches. + Enabled param.Field[bool] `json:"enabled,required"` +} + +func (r RulesetNewParamsRulesRulesetsLogRuleLogging) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RulesetNewParamsRulesRulesetsSkipRule struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[RulesetNewParamsRulesRulesetsSkipRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[RulesetNewParamsRulesRulesetsSkipRuleActionParameters] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[RulesetNewParamsRulesRulesetsSkipRuleLogging] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r RulesetNewParamsRulesRulesetsSkipRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RulesetNewParamsRulesRulesetsSkipRule) implementsRulesetsRulesetNewParamsRule() {} + +// The action to perform when the rule matches. +type RulesetNewParamsRulesRulesetsSkipRuleAction string + +const ( + RulesetNewParamsRulesRulesetsSkipRuleActionSkip RulesetNewParamsRulesRulesetsSkipRuleAction = "skip" +) + +// The parameters configuring the rule's action. +type RulesetNewParamsRulesRulesetsSkipRuleActionParameters struct { + // A list of phases to skip the execution of. This option is incompatible with the + // ruleset and rulesets options. + Phases param.Field[[]RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase] `json:"phases"` + // A list of legacy security products to skip the execution of. + Products param.Field[[]RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct] `json:"products"` + // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the + // execution of. This option is incompatible with the ruleset option. + Rules param.Field[map[string][]string] `json:"rules"` + // A ruleset to skip the execution of. This option is incompatible with the + // rulesets, rules and phases options. + Ruleset param.Field[RulesetNewParamsRulesRulesetsSkipRuleActionParametersRuleset] `json:"ruleset"` + // A list of ruleset IDs to skip the execution of. This option is incompatible with + // the ruleset and phases options. + Rulesets param.Field[[]string] `json:"rulesets"` +} + +func (r RulesetNewParamsRulesRulesetsSkipRuleActionParameters) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A phase to skip the execution of. +type RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase string + +const ( + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseDDOSL4 RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseDDOSL7 RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetNewParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" +) + +// The name of a legacy security product to skip the execution of. +type RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct string + +const ( + RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductBic RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "bic" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductHot RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "hot" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductUABlock RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductWAF RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "waf" + RulesetNewParamsRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetNewParamsRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" +) + +// A ruleset to skip the execution of. This option is incompatible with the +// rulesets, rules and phases options. +type RulesetNewParamsRulesRulesetsSkipRuleActionParametersRuleset string + +const ( + RulesetNewParamsRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetNewParamsRulesRulesetsSkipRuleActionParametersRuleset = "current" +) + +// An object configuring the rule's logging behavior. +type RulesetNewParamsRulesRulesetsSkipRuleLogging struct { + // Whether to generate a log when the rule matches. + Enabled param.Field[bool] `json:"enabled,required"` +} + +func (r RulesetNewParamsRulesRulesetsSkipRuleLogging) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A response object. +type RulesetNewResponseEnvelope struct { + // A list of error messages. + Errors []RulesetNewResponseEnvelopeErrors `json:"errors,required"` + // A list of warning messages. + Messages []RulesetNewResponseEnvelopeMessages `json:"messages,required"` + // A result. + Result RulesetsRulesetResponse `json:"result,required"` + // Whether the API call was successful. + Success RulesetNewResponseEnvelopeSuccess `json:"success,required"` + JSON rulesetNewResponseEnvelopeJSON `json:"-"` +} + +// rulesetNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [RulesetNewResponseEnvelope] +type rulesetNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// A message. +type RulesetNewResponseEnvelopeErrors struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source RulesetNewResponseEnvelopeErrorsSource `json:"source"` + JSON rulesetNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// rulesetNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RulesetNewResponseEnvelopeErrors] +type rulesetNewResponseEnvelopeErrorsJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type RulesetNewResponseEnvelopeErrorsSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON rulesetNewResponseEnvelopeErrorsSourceJSON `json:"-"` +} + +// rulesetNewResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the +// struct [RulesetNewResponseEnvelopeErrorsSource] +type rulesetNewResponseEnvelopeErrorsSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetNewResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetNewResponseEnvelopeErrorsSourceJSON) RawJSON() string { + return r.raw +} + +// A message. +type RulesetNewResponseEnvelopeMessages struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source RulesetNewResponseEnvelopeMessagesSource `json:"source"` + JSON rulesetNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// rulesetNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RulesetNewResponseEnvelopeMessages] +type rulesetNewResponseEnvelopeMessagesJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type RulesetNewResponseEnvelopeMessagesSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON rulesetNewResponseEnvelopeMessagesSourceJSON `json:"-"` +} + +// rulesetNewResponseEnvelopeMessagesSourceJSON contains the JSON metadata for the +// struct [RulesetNewResponseEnvelopeMessagesSource] +type rulesetNewResponseEnvelopeMessagesSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetNewResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetNewResponseEnvelopeMessagesSourceJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type RulesetNewResponseEnvelopeSuccess bool + +const ( + RulesetNewResponseEnvelopeSuccessTrue RulesetNewResponseEnvelopeSuccess = true +) + +type RulesetUpdateParams struct { + // The unique ID of the ruleset. + ID param.Field[string] `json:"id,required"` + // The list of rules in the ruleset. + Rules param.Field[[]RulesetUpdateParamsRule] `json:"rules,required"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // An informative description of the ruleset. + Description param.Field[string] `json:"description"` + // The kind of the ruleset. + Kind param.Field[RulesetUpdateParamsKind] `json:"kind"` + // The human-readable name of the ruleset. + Name param.Field[string] `json:"name"` + // The phase of the ruleset. + Phase param.Field[RulesetUpdateParamsPhase] `json:"phase"` +} + +func (r RulesetUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Satisfied by [rulesets.RulesetUpdateParamsRulesRulesetsBlockRule], +// [rulesets.RulesetUpdateParamsRulesRulesetsExecuteRule], +// [rulesets.RulesetUpdateParamsRulesRulesetsLogRule], +// [rulesets.RulesetUpdateParamsRulesRulesetsSkipRule]. +type RulesetUpdateParamsRule interface { + implementsRulesetsRulesetUpdateParamsRule() +} + +type RulesetUpdateParamsRulesRulesetsBlockRule struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[RulesetUpdateParamsRulesRulesetsBlockRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[RulesetUpdateParamsRulesRulesetsBlockRuleActionParameters] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[RulesetUpdateParamsRulesRulesetsBlockRuleLogging] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r RulesetUpdateParamsRulesRulesetsBlockRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RulesetUpdateParamsRulesRulesetsBlockRule) implementsRulesetsRulesetUpdateParamsRule() {} + +// The action to perform when the rule matches. +type RulesetUpdateParamsRulesRulesetsBlockRuleAction string + +const ( + RulesetUpdateParamsRulesRulesetsBlockRuleActionBlock RulesetUpdateParamsRulesRulesetsBlockRuleAction = "block" +) + +// The parameters configuring the rule's action. +type RulesetUpdateParamsRulesRulesetsBlockRuleActionParameters struct { + // The response to show when the block is applied. + Response param.Field[RulesetUpdateParamsRulesRulesetsBlockRuleActionParametersResponse] `json:"response"` +} + +func (r RulesetUpdateParamsRulesRulesetsBlockRuleActionParameters) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The response to show when the block is applied. +type RulesetUpdateParamsRulesRulesetsBlockRuleActionParametersResponse struct { + // The content to return. + Content param.Field[string] `json:"content,required"` + // The type of the content to return. + ContentType param.Field[string] `json:"content_type,required"` + // The status code to return. + StatusCode param.Field[int64] `json:"status_code,required"` +} + +func (r RulesetUpdateParamsRulesRulesetsBlockRuleActionParametersResponse) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// An object configuring the rule's logging behavior. +type RulesetUpdateParamsRulesRulesetsBlockRuleLogging struct { + // Whether to generate a log when the rule matches. + Enabled param.Field[bool] `json:"enabled,required"` +} + +func (r RulesetUpdateParamsRulesRulesetsBlockRuleLogging) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RulesetUpdateParamsRulesRulesetsExecuteRule struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleActionParameters] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleLogging] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r RulesetUpdateParamsRulesRulesetsExecuteRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RulesetUpdateParamsRulesRulesetsExecuteRule) implementsRulesetsRulesetUpdateParamsRule() {} + +// The action to perform when the rule matches. +type RulesetUpdateParamsRulesRulesetsExecuteRuleAction string + +const ( + RulesetUpdateParamsRulesRulesetsExecuteRuleActionExecute RulesetUpdateParamsRulesRulesetsExecuteRuleAction = "execute" +) + +// The parameters configuring the rule's action. +type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParameters struct { + // The ID of the ruleset to execute. + ID param.Field[string] `json:"id,required"` + // The configuration to use for matched data logging. + MatchedData param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersMatchedData] `json:"matched_data"` + // A set of overrides to apply to the target ruleset. + Overrides param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverrides] `json:"overrides"` +} + +func (r RulesetUpdateParamsRulesRulesetsExecuteRuleActionParameters) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The configuration to use for matched data logging. +type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersMatchedData struct { + // The public key to encrypt matched data logs with. + PublicKey param.Field[string] `json:"public_key,required"` +} + +func (r RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersMatchedData) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A set of overrides to apply to the target ruleset. +type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverrides struct { + // An action to override all rules with. This option has lower precedence than rule + // and category overrides. + Action param.Field[string] `json:"action"` + // A list of category-level overrides. This option has the second-highest + // precedence after rule-level overrides. + Categories param.Field[[]RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory] `json:"categories"` + // Whether to enable execution of all rules. This option has lower precedence than + // rule and category overrides. + Enabled param.Field[bool] `json:"enabled"` + // A list of rule-level overrides. This option has the highest precedence. + Rules param.Field[[]RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRule] `json:"rules"` + // A sensitivity level to set for all rules. This option has lower precedence than + // rule and category overrides and is only applicable for DDoS phases. + SensitivityLevel param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel] `json:"sensitivity_level"` +} + +func (r RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverrides) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A category-level override +type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { + // The name of the category to override. + Category param.Field[string] `json:"category,required"` + // The action to override rules in the category with. + Action param.Field[string] `json:"action"` + // Whether to enable execution of rules in the category. + Enabled param.Field[bool] `json:"enabled"` + // The sensitivity level to use for rules in the category. + SensitivityLevel param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel] `json:"sensitivity_level"` +} + +func (r RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategory) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The sensitivity level to use for rules in the category. +type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string + +const ( + RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" + RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" + RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" + RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" +) + +// A rule-level override +type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRule struct { + // The ID of the rule to override. + ID param.Field[string] `json:"id,required"` + // The action to override the rule with. + Action param.Field[string] `json:"action"` + // Whether to enable execution of the rule. + Enabled param.Field[bool] `json:"enabled"` + // The score threshold to use for the rule. + ScoreThreshold param.Field[int64] `json:"score_threshold"` + // The sensitivity level to use for the rule. + SensitivityLevel param.Field[RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel] `json:"sensitivity_level"` +} + +func (r RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The sensitivity level to use for the rule. +type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string + +const ( + RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" + RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" + RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" + RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" +) + +// A sensitivity level to set for all rules. This option has lower precedence than +// rule and category overrides and is only applicable for DDoS phases. +type RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string + +const ( + RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" + RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" + RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" + RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetUpdateParamsRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" +) + +// An object configuring the rule's logging behavior. +type RulesetUpdateParamsRulesRulesetsExecuteRuleLogging struct { + // Whether to generate a log when the rule matches. + Enabled param.Field[bool] `json:"enabled,required"` +} + +func (r RulesetUpdateParamsRulesRulesetsExecuteRuleLogging) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RulesetUpdateParamsRulesRulesetsLogRule struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[RulesetUpdateParamsRulesRulesetsLogRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[interface{}] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[RulesetUpdateParamsRulesRulesetsLogRuleLogging] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r RulesetUpdateParamsRulesRulesetsLogRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RulesetUpdateParamsRulesRulesetsLogRule) implementsRulesetsRulesetUpdateParamsRule() {} + +// The action to perform when the rule matches. +type RulesetUpdateParamsRulesRulesetsLogRuleAction string + +const ( + RulesetUpdateParamsRulesRulesetsLogRuleActionLog RulesetUpdateParamsRulesRulesetsLogRuleAction = "log" +) + +// An object configuring the rule's logging behavior. +type RulesetUpdateParamsRulesRulesetsLogRuleLogging struct { + // Whether to generate a log when the rule matches. + Enabled param.Field[bool] `json:"enabled,required"` +} + +func (r RulesetUpdateParamsRulesRulesetsLogRuleLogging) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RulesetUpdateParamsRulesRulesetsSkipRule struct { + // The unique ID of the rule. + ID param.Field[string] `json:"id"` + // The action to perform when the rule matches. + Action param.Field[RulesetUpdateParamsRulesRulesetsSkipRuleAction] `json:"action"` + // The parameters configuring the rule's action. + ActionParameters param.Field[RulesetUpdateParamsRulesRulesetsSkipRuleActionParameters] `json:"action_parameters"` + // An informative description of the rule. + Description param.Field[string] `json:"description"` + // Whether the rule should be executed. + Enabled param.Field[bool] `json:"enabled"` + // The expression defining which traffic will match the rule. + Expression param.Field[string] `json:"expression"` + // An object configuring the rule's logging behavior. + Logging param.Field[RulesetUpdateParamsRulesRulesetsSkipRuleLogging] `json:"logging"` + // The reference of the rule (the rule ID by default). + Ref param.Field[string] `json:"ref"` +} + +func (r RulesetUpdateParamsRulesRulesetsSkipRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RulesetUpdateParamsRulesRulesetsSkipRule) implementsRulesetsRulesetUpdateParamsRule() {} + +// The action to perform when the rule matches. +type RulesetUpdateParamsRulesRulesetsSkipRuleAction string + +const ( + RulesetUpdateParamsRulesRulesetsSkipRuleActionSkip RulesetUpdateParamsRulesRulesetsSkipRuleAction = "skip" +) + +// The parameters configuring the rule's action. +type RulesetUpdateParamsRulesRulesetsSkipRuleActionParameters struct { + // A list of phases to skip the execution of. This option is incompatible with the + // ruleset and rulesets options. + Phases param.Field[[]RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase] `json:"phases"` + // A list of legacy security products to skip the execution of. + Products param.Field[[]RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct] `json:"products"` + // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the + // execution of. This option is incompatible with the ruleset option. + Rules param.Field[map[string][]string] `json:"rules"` + // A ruleset to skip the execution of. This option is incompatible with the + // rulesets, rules and phases options. + Ruleset param.Field[RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset] `json:"ruleset"` + // A list of ruleset IDs to skip the execution of. This option is incompatible with + // the ruleset and phases options. + Rulesets param.Field[[]string] `json:"rulesets"` +} + +func (r RulesetUpdateParamsRulesRulesetsSkipRuleActionParameters) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A phase to skip the execution of. +type RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase string + +const ( + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseDDOSL4 RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseDDOSL7 RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" +) + +// The name of a legacy security product to skip the execution of. +type RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct string + +const ( + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductBic RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "bic" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductHot RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "hot" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductUABlock RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductWAF RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "waf" + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" +) + +// A ruleset to skip the execution of. This option is incompatible with the +// rulesets, rules and phases options. +type RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset string + +const ( + RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetUpdateParamsRulesRulesetsSkipRuleActionParametersRuleset = "current" +) + +// An object configuring the rule's logging behavior. +type RulesetUpdateParamsRulesRulesetsSkipRuleLogging struct { + // Whether to generate a log when the rule matches. + Enabled param.Field[bool] `json:"enabled,required"` +} + +func (r RulesetUpdateParamsRulesRulesetsSkipRuleLogging) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The kind of the ruleset. +type RulesetUpdateParamsKind string + +const ( + RulesetUpdateParamsKindManaged RulesetUpdateParamsKind = "managed" + RulesetUpdateParamsKindCustom RulesetUpdateParamsKind = "custom" + RulesetUpdateParamsKindRoot RulesetUpdateParamsKind = "root" + RulesetUpdateParamsKindZone RulesetUpdateParamsKind = "zone" +) + +// The phase of the ruleset. +type RulesetUpdateParamsPhase string + +const ( + RulesetUpdateParamsPhaseDDOSL4 RulesetUpdateParamsPhase = "ddos_l4" + RulesetUpdateParamsPhaseDDOSL7 RulesetUpdateParamsPhase = "ddos_l7" + RulesetUpdateParamsPhaseHTTPConfigSettings RulesetUpdateParamsPhase = "http_config_settings" + RulesetUpdateParamsPhaseHTTPCustomErrors RulesetUpdateParamsPhase = "http_custom_errors" + RulesetUpdateParamsPhaseHTTPLogCustomFields RulesetUpdateParamsPhase = "http_log_custom_fields" + RulesetUpdateParamsPhaseHTTPRatelimit RulesetUpdateParamsPhase = "http_ratelimit" + RulesetUpdateParamsPhaseHTTPRequestCacheSettings RulesetUpdateParamsPhase = "http_request_cache_settings" + RulesetUpdateParamsPhaseHTTPRequestDynamicRedirect RulesetUpdateParamsPhase = "http_request_dynamic_redirect" + RulesetUpdateParamsPhaseHTTPRequestFirewallCustom RulesetUpdateParamsPhase = "http_request_firewall_custom" + RulesetUpdateParamsPhaseHTTPRequestFirewallManaged RulesetUpdateParamsPhase = "http_request_firewall_managed" + RulesetUpdateParamsPhaseHTTPRequestLateTransform RulesetUpdateParamsPhase = "http_request_late_transform" + RulesetUpdateParamsPhaseHTTPRequestOrigin RulesetUpdateParamsPhase = "http_request_origin" + RulesetUpdateParamsPhaseHTTPRequestRedirect RulesetUpdateParamsPhase = "http_request_redirect" + RulesetUpdateParamsPhaseHTTPRequestSanitize RulesetUpdateParamsPhase = "http_request_sanitize" + RulesetUpdateParamsPhaseHTTPRequestSbfm RulesetUpdateParamsPhase = "http_request_sbfm" + RulesetUpdateParamsPhaseHTTPRequestSelectConfiguration RulesetUpdateParamsPhase = "http_request_select_configuration" + RulesetUpdateParamsPhaseHTTPRequestTransform RulesetUpdateParamsPhase = "http_request_transform" + RulesetUpdateParamsPhaseHTTPResponseCompression RulesetUpdateParamsPhase = "http_response_compression" + RulesetUpdateParamsPhaseHTTPResponseFirewallManaged RulesetUpdateParamsPhase = "http_response_firewall_managed" + RulesetUpdateParamsPhaseHTTPResponseHeadersTransform RulesetUpdateParamsPhase = "http_response_headers_transform" + RulesetUpdateParamsPhaseMagicTransit RulesetUpdateParamsPhase = "magic_transit" + RulesetUpdateParamsPhaseMagicTransitIDsManaged RulesetUpdateParamsPhase = "magic_transit_ids_managed" + RulesetUpdateParamsPhaseMagicTransitManaged RulesetUpdateParamsPhase = "magic_transit_managed" +) + +// A response object. +type RulesetUpdateResponseEnvelope struct { + // A list of error messages. + Errors []RulesetUpdateResponseEnvelopeErrors `json:"errors,required"` + // A list of warning messages. + Messages []RulesetUpdateResponseEnvelopeMessages `json:"messages,required"` + // A result. + Result RulesetsRulesetResponse `json:"result,required"` + // Whether the API call was successful. + Success RulesetUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON rulesetUpdateResponseEnvelopeJSON `json:"-"` +} + +// rulesetUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [RulesetUpdateResponseEnvelope] +type rulesetUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// A message. +type RulesetUpdateResponseEnvelopeErrors struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source RulesetUpdateResponseEnvelopeErrorsSource `json:"source"` + JSON rulesetUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// rulesetUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RulesetUpdateResponseEnvelopeErrors] +type rulesetUpdateResponseEnvelopeErrorsJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type RulesetUpdateResponseEnvelopeErrorsSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON rulesetUpdateResponseEnvelopeErrorsSourceJSON `json:"-"` +} + +// rulesetUpdateResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the +// struct [RulesetUpdateResponseEnvelopeErrorsSource] +type rulesetUpdateResponseEnvelopeErrorsSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetUpdateResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetUpdateResponseEnvelopeErrorsSourceJSON) RawJSON() string { + return r.raw +} + +// A message. +type RulesetUpdateResponseEnvelopeMessages struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source RulesetUpdateResponseEnvelopeMessagesSource `json:"source"` + JSON rulesetUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// rulesetUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RulesetUpdateResponseEnvelopeMessages] +type rulesetUpdateResponseEnvelopeMessagesJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type RulesetUpdateResponseEnvelopeMessagesSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON rulesetUpdateResponseEnvelopeMessagesSourceJSON `json:"-"` +} + +// rulesetUpdateResponseEnvelopeMessagesSourceJSON contains the JSON metadata for +// the struct [RulesetUpdateResponseEnvelopeMessagesSource] +type rulesetUpdateResponseEnvelopeMessagesSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetUpdateResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetUpdateResponseEnvelopeMessagesSourceJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type RulesetUpdateResponseEnvelopeSuccess bool + +const ( + RulesetUpdateResponseEnvelopeSuccessTrue RulesetUpdateResponseEnvelopeSuccess = true +) + +type RulesetListParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +// A response object. +type RulesetListResponseEnvelope struct { + // A list of error messages. + Errors []RulesetListResponseEnvelopeErrors `json:"errors,required"` + // A list of warning messages. + Messages []RulesetListResponseEnvelopeMessages `json:"messages,required"` + // A result. + Result RulesetsRulesetsResponse `json:"result,required"` + // Whether the API call was successful. + Success RulesetListResponseEnvelopeSuccess `json:"success,required"` + JSON rulesetListResponseEnvelopeJSON `json:"-"` +} + +// rulesetListResponseEnvelopeJSON contains the JSON metadata for the struct +// [RulesetListResponseEnvelope] +type rulesetListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// A message. +type RulesetListResponseEnvelopeErrors struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source RulesetListResponseEnvelopeErrorsSource `json:"source"` + JSON rulesetListResponseEnvelopeErrorsJSON `json:"-"` +} + +// rulesetListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RulesetListResponseEnvelopeErrors] +type rulesetListResponseEnvelopeErrorsJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type RulesetListResponseEnvelopeErrorsSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON rulesetListResponseEnvelopeErrorsSourceJSON `json:"-"` +} + +// rulesetListResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the +// struct [RulesetListResponseEnvelopeErrorsSource] +type rulesetListResponseEnvelopeErrorsSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetListResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetListResponseEnvelopeErrorsSourceJSON) RawJSON() string { + return r.raw +} + +// A message. +type RulesetListResponseEnvelopeMessages struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source RulesetListResponseEnvelopeMessagesSource `json:"source"` + JSON rulesetListResponseEnvelopeMessagesJSON `json:"-"` +} + +// rulesetListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RulesetListResponseEnvelopeMessages] +type rulesetListResponseEnvelopeMessagesJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type RulesetListResponseEnvelopeMessagesSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON rulesetListResponseEnvelopeMessagesSourceJSON `json:"-"` +} + +// rulesetListResponseEnvelopeMessagesSourceJSON contains the JSON metadata for the +// struct [RulesetListResponseEnvelopeMessagesSource] +type rulesetListResponseEnvelopeMessagesSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetListResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetListResponseEnvelopeMessagesSourceJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type RulesetListResponseEnvelopeSuccess bool + +const ( + RulesetListResponseEnvelopeSuccessTrue RulesetListResponseEnvelopeSuccess = true +) + +type RulesetDeleteParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type RulesetGetParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +// A response object. +type RulesetGetResponseEnvelope struct { + // A list of error messages. + Errors []RulesetGetResponseEnvelopeErrors `json:"errors,required"` + // A list of warning messages. + Messages []RulesetGetResponseEnvelopeMessages `json:"messages,required"` + // A result. + Result RulesetsRulesetResponse `json:"result,required"` + // Whether the API call was successful. + Success RulesetGetResponseEnvelopeSuccess `json:"success,required"` + JSON rulesetGetResponseEnvelopeJSON `json:"-"` +} + +// rulesetGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RulesetGetResponseEnvelope] +type rulesetGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// A message. +type RulesetGetResponseEnvelopeErrors struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source RulesetGetResponseEnvelopeErrorsSource `json:"source"` + JSON rulesetGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// rulesetGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RulesetGetResponseEnvelopeErrors] +type rulesetGetResponseEnvelopeErrorsJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type RulesetGetResponseEnvelopeErrorsSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON rulesetGetResponseEnvelopeErrorsSourceJSON `json:"-"` +} + +// rulesetGetResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the +// struct [RulesetGetResponseEnvelopeErrorsSource] +type rulesetGetResponseEnvelopeErrorsSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetGetResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetGetResponseEnvelopeErrorsSourceJSON) RawJSON() string { + return r.raw +} + +// A message. +type RulesetGetResponseEnvelopeMessages struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source RulesetGetResponseEnvelopeMessagesSource `json:"source"` + JSON rulesetGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// rulesetGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RulesetGetResponseEnvelopeMessages] +type rulesetGetResponseEnvelopeMessagesJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type RulesetGetResponseEnvelopeMessagesSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON rulesetGetResponseEnvelopeMessagesSourceJSON `json:"-"` +} + +// rulesetGetResponseEnvelopeMessagesSourceJSON contains the JSON metadata for the +// struct [RulesetGetResponseEnvelopeMessagesSource] +type rulesetGetResponseEnvelopeMessagesSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RulesetGetResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rulesetGetResponseEnvelopeMessagesSourceJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type RulesetGetResponseEnvelopeSuccess bool + +const ( + RulesetGetResponseEnvelopeSuccessTrue RulesetGetResponseEnvelopeSuccess = true +) diff --git a/rulesets/ruleset_test.go b/rulesets/ruleset_test.go new file mode 100644 index 00000000000..48c579a73ff --- /dev/null +++ b/rulesets/ruleset_test.go @@ -0,0 +1,275 @@ +// File generated from our OpenAPI spec by Stainless. + +package rulesets_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/rulesets" +) + +func TestRulesetNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Rulesets.New(context.TODO(), rulesets.RulesetNewParams{ + Kind: cloudflare.F(rulesets.RulesetNewParamsKindRoot), + Name: cloudflare.F("My ruleset"), + Phase: cloudflare.F(rulesets.RulesetNewParamsPhaseHTTPRequestFirewallCustom), + Rules: cloudflare.F([]rulesets.RulesetNewParamsRule{rulesets.RulesetNewParamsRulesRulesetsBlockRule(rulesets.RulesetNewParamsRulesRulesetsBlockRule{ + Action: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleActionBlock), + ActionParameters: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleActionParameters{ + Response: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleActionParametersResponse{ + Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), + ContentType: cloudflare.F("application/json"), + StatusCode: cloudflare.F(int64(400)), + }), + }), + Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), + Enabled: cloudflare.F(true), + Expression: cloudflare.F("ip.src ne 1.1.1.1"), + ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), + Logging: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleLogging{ + Enabled: cloudflare.F(true), + }), + Ref: cloudflare.F("my_ref"), + }), rulesets.RulesetNewParamsRulesRulesetsBlockRule(rulesets.RulesetNewParamsRulesRulesetsBlockRule{ + Action: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleActionBlock), + ActionParameters: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleActionParameters{ + Response: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleActionParametersResponse{ + Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), + ContentType: cloudflare.F("application/json"), + StatusCode: cloudflare.F(int64(400)), + }), + }), + Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), + Enabled: cloudflare.F(true), + Expression: cloudflare.F("ip.src ne 1.1.1.1"), + ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), + Logging: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleLogging{ + Enabled: cloudflare.F(true), + }), + Ref: cloudflare.F("my_ref"), + }), rulesets.RulesetNewParamsRulesRulesetsBlockRule(rulesets.RulesetNewParamsRulesRulesetsBlockRule{ + Action: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleActionBlock), + ActionParameters: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleActionParameters{ + Response: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleActionParametersResponse{ + Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), + ContentType: cloudflare.F("application/json"), + StatusCode: cloudflare.F(int64(400)), + }), + }), + Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), + Enabled: cloudflare.F(true), + Expression: cloudflare.F("ip.src ne 1.1.1.1"), + ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), + Logging: cloudflare.F(rulesets.RulesetNewParamsRulesRulesetsBlockRuleLogging{ + Enabled: cloudflare.F(true), + }), + Ref: cloudflare.F("my_ref"), + })}), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + Description: cloudflare.F("My ruleset to execute managed rulesets"), + }) + 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 TestRulesetUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Rulesets.Update( + context.TODO(), + "2f2feab2026849078ba485f918791bdc", + rulesets.RulesetUpdateParams{ + ID: cloudflare.F("2f2feab2026849078ba485f918791bdc"), + Rules: cloudflare.F([]rulesets.RulesetUpdateParamsRule{rulesets.RulesetUpdateParamsRulesRulesetsBlockRule(rulesets.RulesetUpdateParamsRulesRulesetsBlockRule{ + Action: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleActionBlock), + ActionParameters: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleActionParameters{ + Response: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleActionParametersResponse{ + Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), + ContentType: cloudflare.F("application/json"), + StatusCode: cloudflare.F(int64(400)), + }), + }), + Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), + Enabled: cloudflare.F(true), + Expression: cloudflare.F("ip.src ne 1.1.1.1"), + ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), + Logging: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleLogging{ + Enabled: cloudflare.F(true), + }), + Ref: cloudflare.F("my_ref"), + }), rulesets.RulesetUpdateParamsRulesRulesetsBlockRule(rulesets.RulesetUpdateParamsRulesRulesetsBlockRule{ + Action: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleActionBlock), + ActionParameters: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleActionParameters{ + Response: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleActionParametersResponse{ + Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), + ContentType: cloudflare.F("application/json"), + StatusCode: cloudflare.F(int64(400)), + }), + }), + Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), + Enabled: cloudflare.F(true), + Expression: cloudflare.F("ip.src ne 1.1.1.1"), + ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), + Logging: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleLogging{ + Enabled: cloudflare.F(true), + }), + Ref: cloudflare.F("my_ref"), + }), rulesets.RulesetUpdateParamsRulesRulesetsBlockRule(rulesets.RulesetUpdateParamsRulesRulesetsBlockRule{ + Action: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleActionBlock), + ActionParameters: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleActionParameters{ + Response: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleActionParametersResponse{ + Content: cloudflare.F("{\n \"success\": false,\n \"error\": \"you have been blocked\"\n}"), + ContentType: cloudflare.F("application/json"), + StatusCode: cloudflare.F(int64(400)), + }), + }), + Description: cloudflare.F("Block when the IP address is not 1.1.1.1"), + Enabled: cloudflare.F(true), + Expression: cloudflare.F("ip.src ne 1.1.1.1"), + ID: cloudflare.F("3a03d665bac047339bb530ecb439a90d"), + Logging: cloudflare.F(rulesets.RulesetUpdateParamsRulesRulesetsBlockRuleLogging{ + Enabled: cloudflare.F(true), + }), + Ref: cloudflare.F("my_ref"), + })}), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + Description: cloudflare.F("My ruleset to execute managed rulesets"), + Kind: cloudflare.F(rulesets.RulesetUpdateParamsKindRoot), + Name: cloudflare.F("My ruleset"), + Phase: cloudflare.F(rulesets.RulesetUpdateParamsPhaseHTTPRequestFirewallCustom), + }, + ) + 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 TestRulesetListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Rulesets.List(context.TODO(), rulesets.RulesetListParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }) + 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 TestRulesetDeleteWithOptionalParams(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("user@example.com"), + ) + err := client.Rulesets.Delete( + context.TODO(), + "2f2feab2026849078ba485f918791bdc", + rulesets.RulesetDeleteParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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 TestRulesetGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Rulesets.Get( + context.TODO(), + "2f2feab2026849078ba485f918791bdc", + rulesets.RulesetGetParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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/rulesets/version.go b/rulesets/version.go new file mode 100644 index 00000000000..b9318d0c4eb --- /dev/null +++ b/rulesets/version.go @@ -0,0 +1,483 @@ +// File generated from our OpenAPI spec by Stainless. + +package rulesets + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// VersionService 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 [NewVersionService] method instead. +type VersionService struct { + Options []option.RequestOption + ByTags *VersionByTagService +} + +// NewVersionService 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 NewVersionService(opts ...option.RequestOption) (r *VersionService) { + r = &VersionService{} + r.Options = opts + r.ByTags = NewVersionByTagService(opts...) + return +} + +// Fetches the versions of an account or zone ruleset. +func (r *VersionService) List(ctx context.Context, rulesetID string, query VersionListParams, opts ...option.RequestOption) (res *RulesetsRulesetsResponse, err error) { + opts = append(r.Options[:], opts...) + var env VersionListResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/rulesets/%s/versions", accountOrZone, accountOrZoneID, rulesetID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes an existing version of an account or zone ruleset. +func (r *VersionService) Delete(ctx context.Context, rulesetID string, rulesetVersion string, body VersionDeleteParams, opts ...option.RequestOption) (err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + var accountOrZone string + var accountOrZoneID param.Field[string] + if body.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = body.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = body.ZoneID + } + path := fmt.Sprintf("%s/%s/rulesets/%s/versions/%s", accountOrZone, accountOrZoneID, rulesetID, rulesetVersion) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) + return +} + +// Fetches a specific version of an account or zone ruleset. +func (r *VersionService) Get(ctx context.Context, rulesetID string, rulesetVersion string, query VersionGetParams, opts ...option.RequestOption) (res *RulesetsRulesetResponse, err error) { + opts = append(r.Options[:], opts...) + var env VersionGetResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/rulesets/%s/versions/%s", accountOrZone, accountOrZoneID, rulesetID, rulesetVersion) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// A ruleset object. +type VersionListResponse struct { + // The kind of the ruleset. + Kind VersionListResponseKind `json:"kind,required"` + // The human-readable name of the ruleset. + Name string `json:"name,required"` + // The phase of the ruleset. + Phase VersionListResponsePhase `json:"phase,required"` + // The unique ID of the ruleset. + ID string `json:"id"` + // An informative description of the ruleset. + Description string `json:"description"` + // The timestamp of when the ruleset was last modified. + LastUpdated time.Time `json:"last_updated" format:"date-time"` + // The version of the ruleset. + Version string `json:"version"` + JSON versionListResponseJSON `json:"-"` +} + +// versionListResponseJSON contains the JSON metadata for the struct +// [VersionListResponse] +type versionListResponseJSON struct { + Kind apijson.Field + Name apijson.Field + Phase apijson.Field + ID apijson.Field + Description apijson.Field + LastUpdated apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VersionListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r versionListResponseJSON) RawJSON() string { + return r.raw +} + +// The kind of the ruleset. +type VersionListResponseKind string + +const ( + VersionListResponseKindManaged VersionListResponseKind = "managed" + VersionListResponseKindCustom VersionListResponseKind = "custom" + VersionListResponseKindRoot VersionListResponseKind = "root" + VersionListResponseKindZone VersionListResponseKind = "zone" +) + +// The phase of the ruleset. +type VersionListResponsePhase string + +const ( + VersionListResponsePhaseDDOSL4 VersionListResponsePhase = "ddos_l4" + VersionListResponsePhaseDDOSL7 VersionListResponsePhase = "ddos_l7" + VersionListResponsePhaseHTTPConfigSettings VersionListResponsePhase = "http_config_settings" + VersionListResponsePhaseHTTPCustomErrors VersionListResponsePhase = "http_custom_errors" + VersionListResponsePhaseHTTPLogCustomFields VersionListResponsePhase = "http_log_custom_fields" + VersionListResponsePhaseHTTPRatelimit VersionListResponsePhase = "http_ratelimit" + VersionListResponsePhaseHTTPRequestCacheSettings VersionListResponsePhase = "http_request_cache_settings" + VersionListResponsePhaseHTTPRequestDynamicRedirect VersionListResponsePhase = "http_request_dynamic_redirect" + VersionListResponsePhaseHTTPRequestFirewallCustom VersionListResponsePhase = "http_request_firewall_custom" + VersionListResponsePhaseHTTPRequestFirewallManaged VersionListResponsePhase = "http_request_firewall_managed" + VersionListResponsePhaseHTTPRequestLateTransform VersionListResponsePhase = "http_request_late_transform" + VersionListResponsePhaseHTTPRequestOrigin VersionListResponsePhase = "http_request_origin" + VersionListResponsePhaseHTTPRequestRedirect VersionListResponsePhase = "http_request_redirect" + VersionListResponsePhaseHTTPRequestSanitize VersionListResponsePhase = "http_request_sanitize" + VersionListResponsePhaseHTTPRequestSbfm VersionListResponsePhase = "http_request_sbfm" + VersionListResponsePhaseHTTPRequestSelectConfiguration VersionListResponsePhase = "http_request_select_configuration" + VersionListResponsePhaseHTTPRequestTransform VersionListResponsePhase = "http_request_transform" + VersionListResponsePhaseHTTPResponseCompression VersionListResponsePhase = "http_response_compression" + VersionListResponsePhaseHTTPResponseFirewallManaged VersionListResponsePhase = "http_response_firewall_managed" + VersionListResponsePhaseHTTPResponseHeadersTransform VersionListResponsePhase = "http_response_headers_transform" + VersionListResponsePhaseMagicTransit VersionListResponsePhase = "magic_transit" + VersionListResponsePhaseMagicTransitIDsManaged VersionListResponsePhase = "magic_transit_ids_managed" + VersionListResponsePhaseMagicTransitManaged VersionListResponsePhase = "magic_transit_managed" +) + +type VersionListParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +// A response object. +type VersionListResponseEnvelope struct { + // A list of error messages. + Errors []VersionListResponseEnvelopeErrors `json:"errors,required"` + // A list of warning messages. + Messages []VersionListResponseEnvelopeMessages `json:"messages,required"` + // A result. + Result RulesetsRulesetsResponse `json:"result,required"` + // Whether the API call was successful. + Success VersionListResponseEnvelopeSuccess `json:"success,required"` + JSON versionListResponseEnvelopeJSON `json:"-"` +} + +// versionListResponseEnvelopeJSON contains the JSON metadata for the struct +// [VersionListResponseEnvelope] +type versionListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VersionListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r versionListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// A message. +type VersionListResponseEnvelopeErrors struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source VersionListResponseEnvelopeErrorsSource `json:"source"` + JSON versionListResponseEnvelopeErrorsJSON `json:"-"` +} + +// versionListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [VersionListResponseEnvelopeErrors] +type versionListResponseEnvelopeErrorsJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VersionListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r versionListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type VersionListResponseEnvelopeErrorsSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON versionListResponseEnvelopeErrorsSourceJSON `json:"-"` +} + +// versionListResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the +// struct [VersionListResponseEnvelopeErrorsSource] +type versionListResponseEnvelopeErrorsSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VersionListResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r versionListResponseEnvelopeErrorsSourceJSON) RawJSON() string { + return r.raw +} + +// A message. +type VersionListResponseEnvelopeMessages struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source VersionListResponseEnvelopeMessagesSource `json:"source"` + JSON versionListResponseEnvelopeMessagesJSON `json:"-"` +} + +// versionListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [VersionListResponseEnvelopeMessages] +type versionListResponseEnvelopeMessagesJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VersionListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r versionListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type VersionListResponseEnvelopeMessagesSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON versionListResponseEnvelopeMessagesSourceJSON `json:"-"` +} + +// versionListResponseEnvelopeMessagesSourceJSON contains the JSON metadata for the +// struct [VersionListResponseEnvelopeMessagesSource] +type versionListResponseEnvelopeMessagesSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VersionListResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r versionListResponseEnvelopeMessagesSourceJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type VersionListResponseEnvelopeSuccess bool + +const ( + VersionListResponseEnvelopeSuccessTrue VersionListResponseEnvelopeSuccess = true +) + +type VersionDeleteParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type VersionGetParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +// A response object. +type VersionGetResponseEnvelope struct { + // A list of error messages. + Errors []VersionGetResponseEnvelopeErrors `json:"errors,required"` + // A list of warning messages. + Messages []VersionGetResponseEnvelopeMessages `json:"messages,required"` + // A result. + Result RulesetsRulesetResponse `json:"result,required"` + // Whether the API call was successful. + Success VersionGetResponseEnvelopeSuccess `json:"success,required"` + JSON versionGetResponseEnvelopeJSON `json:"-"` +} + +// versionGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [VersionGetResponseEnvelope] +type versionGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VersionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r versionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// A message. +type VersionGetResponseEnvelopeErrors struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source VersionGetResponseEnvelopeErrorsSource `json:"source"` + JSON versionGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// versionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [VersionGetResponseEnvelopeErrors] +type versionGetResponseEnvelopeErrorsJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VersionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r versionGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type VersionGetResponseEnvelopeErrorsSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON versionGetResponseEnvelopeErrorsSourceJSON `json:"-"` +} + +// versionGetResponseEnvelopeErrorsSourceJSON contains the JSON metadata for the +// struct [VersionGetResponseEnvelopeErrorsSource] +type versionGetResponseEnvelopeErrorsSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VersionGetResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r versionGetResponseEnvelopeErrorsSourceJSON) RawJSON() string { + return r.raw +} + +// A message. +type VersionGetResponseEnvelopeMessages struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source VersionGetResponseEnvelopeMessagesSource `json:"source"` + JSON versionGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// versionGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [VersionGetResponseEnvelopeMessages] +type versionGetResponseEnvelopeMessagesJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VersionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r versionGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type VersionGetResponseEnvelopeMessagesSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON versionGetResponseEnvelopeMessagesSourceJSON `json:"-"` +} + +// versionGetResponseEnvelopeMessagesSourceJSON contains the JSON metadata for the +// struct [VersionGetResponseEnvelopeMessagesSource] +type versionGetResponseEnvelopeMessagesSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VersionGetResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r versionGetResponseEnvelopeMessagesSourceJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type VersionGetResponseEnvelopeSuccess bool + +const ( + VersionGetResponseEnvelopeSuccessTrue VersionGetResponseEnvelopeSuccess = true +) diff --git a/rulesets/version_test.go b/rulesets/version_test.go new file mode 100644 index 00000000000..0de008b4ec0 --- /dev/null +++ b/rulesets/version_test.go @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package rulesets_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/rulesets" +) + +func TestVersionListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Rulesets.Versions.List( + context.TODO(), + "2f2feab2026849078ba485f918791bdc", + rulesets.VersionListParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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 TestVersionDeleteWithOptionalParams(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("user@example.com"), + ) + err := client.Rulesets.Versions.Delete( + context.TODO(), + "2f2feab2026849078ba485f918791bdc", + "1", + rulesets.VersionDeleteParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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 TestVersionGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Rulesets.Versions.Get( + context.TODO(), + "2f2feab2026849078ba485f918791bdc", + "1", + rulesets.VersionGetParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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/rulesets/versionbytag.go b/rulesets/versionbytag.go new file mode 100644 index 00000000000..a56ce9d6e10 --- /dev/null +++ b/rulesets/versionbytag.go @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package rulesets + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// VersionByTagService 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 [NewVersionByTagService] method +// instead. +type VersionByTagService struct { + Options []option.RequestOption +} + +// NewVersionByTagService 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 NewVersionByTagService(opts ...option.RequestOption) (r *VersionByTagService) { + r = &VersionByTagService{} + r.Options = opts + return +} + +// Fetches the rules of a managed account ruleset version for a given tag. +func (r *VersionByTagService) Get(ctx context.Context, rulesetID string, rulesetVersion string, ruleTag string, query VersionByTagGetParams, opts ...option.RequestOption) (res *RulesetsRulesetResponse, err error) { + opts = append(r.Options[:], opts...) + var env VersionByTagGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/rulesets/%s/versions/%s/by_tag/%s", query.AccountID, rulesetID, rulesetVersion, ruleTag) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type VersionByTagGetParams struct { + // The unique ID of the account. + AccountID param.Field[string] `path:"account_id,required"` +} + +// A response object. +type VersionByTagGetResponseEnvelope struct { + // A list of error messages. + Errors []VersionByTagGetResponseEnvelopeErrors `json:"errors,required"` + // A list of warning messages. + Messages []VersionByTagGetResponseEnvelopeMessages `json:"messages,required"` + // A result. + Result RulesetsRulesetResponse `json:"result,required"` + // Whether the API call was successful. + Success VersionByTagGetResponseEnvelopeSuccess `json:"success,required"` + JSON versionByTagGetResponseEnvelopeJSON `json:"-"` +} + +// versionByTagGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [VersionByTagGetResponseEnvelope] +type versionByTagGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VersionByTagGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r versionByTagGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// A message. +type VersionByTagGetResponseEnvelopeErrors struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source VersionByTagGetResponseEnvelopeErrorsSource `json:"source"` + JSON versionByTagGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// versionByTagGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [VersionByTagGetResponseEnvelopeErrors] +type versionByTagGetResponseEnvelopeErrorsJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VersionByTagGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r versionByTagGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type VersionByTagGetResponseEnvelopeErrorsSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON versionByTagGetResponseEnvelopeErrorsSourceJSON `json:"-"` +} + +// versionByTagGetResponseEnvelopeErrorsSourceJSON contains the JSON metadata for +// the struct [VersionByTagGetResponseEnvelopeErrorsSource] +type versionByTagGetResponseEnvelopeErrorsSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VersionByTagGetResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r versionByTagGetResponseEnvelopeErrorsSourceJSON) RawJSON() string { + return r.raw +} + +// A message. +type VersionByTagGetResponseEnvelopeMessages struct { + // A text description of this message. + Message string `json:"message,required"` + // A unique code for this message. + Code int64 `json:"code"` + // The source of this message. + Source VersionByTagGetResponseEnvelopeMessagesSource `json:"source"` + JSON versionByTagGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// versionByTagGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [VersionByTagGetResponseEnvelopeMessages] +type versionByTagGetResponseEnvelopeMessagesJSON struct { + Message apijson.Field + Code apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VersionByTagGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r versionByTagGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// The source of this message. +type VersionByTagGetResponseEnvelopeMessagesSource struct { + // A JSON pointer to the field that is the source of the message. + Pointer string `json:"pointer,required"` + JSON versionByTagGetResponseEnvelopeMessagesSourceJSON `json:"-"` +} + +// versionByTagGetResponseEnvelopeMessagesSourceJSON contains the JSON metadata for +// the struct [VersionByTagGetResponseEnvelopeMessagesSource] +type versionByTagGetResponseEnvelopeMessagesSourceJSON struct { + Pointer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VersionByTagGetResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r versionByTagGetResponseEnvelopeMessagesSourceJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type VersionByTagGetResponseEnvelopeSuccess bool + +const ( + VersionByTagGetResponseEnvelopeSuccessTrue VersionByTagGetResponseEnvelopeSuccess = true +) diff --git a/rulesets/versionbytag_test.go b/rulesets/versionbytag_test.go new file mode 100644 index 00000000000..b0ac57a9538 --- /dev/null +++ b/rulesets/versionbytag_test.go @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package rulesets_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/rulesets" +) + +func TestVersionByTagGet(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("user@example.com"), + ) + _, err := client.Rulesets.Versions.ByTags.Get( + context.TODO(), + "2f2feab2026849078ba485f918791bdc", + "1", + "directory-traversal", + rulesets.VersionByTagGetParams{ + AccountID: cloudflare.F("abf9b32d38c5f572afde3336ec0ce302"), + }, + ) + 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/rulesetversion.go b/rulesetversion.go deleted file mode 100644 index 0205917cde1..00000000000 --- a/rulesetversion.go +++ /dev/null @@ -1,1280 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// RulesetVersionService 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 [NewRulesetVersionService] method -// instead. -type RulesetVersionService struct { - Options []option.RequestOption - ByTags *RulesetVersionByTagService -} - -// NewRulesetVersionService 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 NewRulesetVersionService(opts ...option.RequestOption) (r *RulesetVersionService) { - r = &RulesetVersionService{} - r.Options = opts - r.ByTags = NewRulesetVersionByTagService(opts...) - return -} - -// Fetches the versions of an account or zone ruleset. -func (r *RulesetVersionService) List(ctx context.Context, rulesetID string, query RulesetVersionListParams, opts ...option.RequestOption) (res *[]RulesetVersionListResponse, err error) { - opts = append(r.Options[:], opts...) - var env RulesetVersionListResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/rulesets/%s/versions", accountOrZone, accountOrZoneID, rulesetID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes an existing version of an account or zone ruleset. -func (r *RulesetVersionService) Delete(ctx context.Context, rulesetID string, rulesetVersion string, body RulesetVersionDeleteParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - var accountOrZone string - var accountOrZoneID param.Field[string] - if body.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = body.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = body.ZoneID - } - path := fmt.Sprintf("%s/%s/rulesets/%s/versions/%s", accountOrZone, accountOrZoneID, rulesetID, rulesetVersion) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) - return -} - -// Fetches a specific version of an account or zone ruleset. -func (r *RulesetVersionService) Get(ctx context.Context, rulesetID string, rulesetVersion string, query RulesetVersionGetParams, opts ...option.RequestOption) (res *RulesetVersionGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RulesetVersionGetResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/rulesets/%s/versions/%s", accountOrZone, accountOrZoneID, rulesetID, rulesetVersion) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// A ruleset object. -type RulesetVersionListResponse struct { - // The kind of the ruleset. - Kind RulesetVersionListResponseKind `json:"kind,required"` - // The human-readable name of the ruleset. - Name string `json:"name,required"` - // The phase of the ruleset. - Phase RulesetVersionListResponsePhase `json:"phase,required"` - // The unique ID of the ruleset. - ID string `json:"id"` - // An informative description of the ruleset. - Description string `json:"description"` - // The timestamp of when the ruleset was last modified. - LastUpdated time.Time `json:"last_updated" format:"date-time"` - // The version of the ruleset. - Version string `json:"version"` - JSON rulesetVersionListResponseJSON `json:"-"` -} - -// rulesetVersionListResponseJSON contains the JSON metadata for the struct -// [RulesetVersionListResponse] -type rulesetVersionListResponseJSON struct { - Kind apijson.Field - Name apijson.Field - Phase apijson.Field - ID apijson.Field - Description apijson.Field - LastUpdated apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionListResponseJSON) RawJSON() string { - return r.raw -} - -// The kind of the ruleset. -type RulesetVersionListResponseKind string - -const ( - RulesetVersionListResponseKindManaged RulesetVersionListResponseKind = "managed" - RulesetVersionListResponseKindCustom RulesetVersionListResponseKind = "custom" - RulesetVersionListResponseKindRoot RulesetVersionListResponseKind = "root" - RulesetVersionListResponseKindZone RulesetVersionListResponseKind = "zone" -) - -// The phase of the ruleset. -type RulesetVersionListResponsePhase string - -const ( - RulesetVersionListResponsePhaseDDOSL4 RulesetVersionListResponsePhase = "ddos_l4" - RulesetVersionListResponsePhaseDDOSL7 RulesetVersionListResponsePhase = "ddos_l7" - RulesetVersionListResponsePhaseHTTPConfigSettings RulesetVersionListResponsePhase = "http_config_settings" - RulesetVersionListResponsePhaseHTTPCustomErrors RulesetVersionListResponsePhase = "http_custom_errors" - RulesetVersionListResponsePhaseHTTPLogCustomFields RulesetVersionListResponsePhase = "http_log_custom_fields" - RulesetVersionListResponsePhaseHTTPRatelimit RulesetVersionListResponsePhase = "http_ratelimit" - RulesetVersionListResponsePhaseHTTPRequestCacheSettings RulesetVersionListResponsePhase = "http_request_cache_settings" - RulesetVersionListResponsePhaseHTTPRequestDynamicRedirect RulesetVersionListResponsePhase = "http_request_dynamic_redirect" - RulesetVersionListResponsePhaseHTTPRequestFirewallCustom RulesetVersionListResponsePhase = "http_request_firewall_custom" - RulesetVersionListResponsePhaseHTTPRequestFirewallManaged RulesetVersionListResponsePhase = "http_request_firewall_managed" - RulesetVersionListResponsePhaseHTTPRequestLateTransform RulesetVersionListResponsePhase = "http_request_late_transform" - RulesetVersionListResponsePhaseHTTPRequestOrigin RulesetVersionListResponsePhase = "http_request_origin" - RulesetVersionListResponsePhaseHTTPRequestRedirect RulesetVersionListResponsePhase = "http_request_redirect" - RulesetVersionListResponsePhaseHTTPRequestSanitize RulesetVersionListResponsePhase = "http_request_sanitize" - RulesetVersionListResponsePhaseHTTPRequestSbfm RulesetVersionListResponsePhase = "http_request_sbfm" - RulesetVersionListResponsePhaseHTTPRequestSelectConfiguration RulesetVersionListResponsePhase = "http_request_select_configuration" - RulesetVersionListResponsePhaseHTTPRequestTransform RulesetVersionListResponsePhase = "http_request_transform" - RulesetVersionListResponsePhaseHTTPResponseCompression RulesetVersionListResponsePhase = "http_response_compression" - RulesetVersionListResponsePhaseHTTPResponseFirewallManaged RulesetVersionListResponsePhase = "http_response_firewall_managed" - RulesetVersionListResponsePhaseHTTPResponseHeadersTransform RulesetVersionListResponsePhase = "http_response_headers_transform" - RulesetVersionListResponsePhaseMagicTransit RulesetVersionListResponsePhase = "magic_transit" - RulesetVersionListResponsePhaseMagicTransitIDsManaged RulesetVersionListResponsePhase = "magic_transit_ids_managed" - RulesetVersionListResponsePhaseMagicTransitManaged RulesetVersionListResponsePhase = "magic_transit_managed" -) - -// A result. -type RulesetVersionGetResponse struct { - // The unique ID of the ruleset. - ID string `json:"id,required"` - // The kind of the ruleset. - Kind RulesetVersionGetResponseKind `json:"kind,required"` - // The timestamp of when the ruleset was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The human-readable name of the ruleset. - Name string `json:"name,required"` - // The phase of the ruleset. - Phase RulesetVersionGetResponsePhase `json:"phase,required"` - // The list of rules in the ruleset. - Rules []RulesetVersionGetResponseRule `json:"rules,required"` - // The version of the ruleset. - Version string `json:"version,required"` - // An informative description of the ruleset. - Description string `json:"description"` - JSON rulesetVersionGetResponseJSON `json:"-"` -} - -// rulesetVersionGetResponseJSON contains the JSON metadata for the struct -// [RulesetVersionGetResponse] -type rulesetVersionGetResponseJSON struct { - ID apijson.Field - Kind apijson.Field - LastUpdated apijson.Field - Name apijson.Field - Phase apijson.Field - Rules apijson.Field - Version apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseJSON) RawJSON() string { - return r.raw -} - -// The kind of the ruleset. -type RulesetVersionGetResponseKind string - -const ( - RulesetVersionGetResponseKindManaged RulesetVersionGetResponseKind = "managed" - RulesetVersionGetResponseKindCustom RulesetVersionGetResponseKind = "custom" - RulesetVersionGetResponseKindRoot RulesetVersionGetResponseKind = "root" - RulesetVersionGetResponseKindZone RulesetVersionGetResponseKind = "zone" -) - -// The phase of the ruleset. -type RulesetVersionGetResponsePhase string - -const ( - RulesetVersionGetResponsePhaseDDOSL4 RulesetVersionGetResponsePhase = "ddos_l4" - RulesetVersionGetResponsePhaseDDOSL7 RulesetVersionGetResponsePhase = "ddos_l7" - RulesetVersionGetResponsePhaseHTTPConfigSettings RulesetVersionGetResponsePhase = "http_config_settings" - RulesetVersionGetResponsePhaseHTTPCustomErrors RulesetVersionGetResponsePhase = "http_custom_errors" - RulesetVersionGetResponsePhaseHTTPLogCustomFields RulesetVersionGetResponsePhase = "http_log_custom_fields" - RulesetVersionGetResponsePhaseHTTPRatelimit RulesetVersionGetResponsePhase = "http_ratelimit" - RulesetVersionGetResponsePhaseHTTPRequestCacheSettings RulesetVersionGetResponsePhase = "http_request_cache_settings" - RulesetVersionGetResponsePhaseHTTPRequestDynamicRedirect RulesetVersionGetResponsePhase = "http_request_dynamic_redirect" - RulesetVersionGetResponsePhaseHTTPRequestFirewallCustom RulesetVersionGetResponsePhase = "http_request_firewall_custom" - RulesetVersionGetResponsePhaseHTTPRequestFirewallManaged RulesetVersionGetResponsePhase = "http_request_firewall_managed" - RulesetVersionGetResponsePhaseHTTPRequestLateTransform RulesetVersionGetResponsePhase = "http_request_late_transform" - RulesetVersionGetResponsePhaseHTTPRequestOrigin RulesetVersionGetResponsePhase = "http_request_origin" - RulesetVersionGetResponsePhaseHTTPRequestRedirect RulesetVersionGetResponsePhase = "http_request_redirect" - RulesetVersionGetResponsePhaseHTTPRequestSanitize RulesetVersionGetResponsePhase = "http_request_sanitize" - RulesetVersionGetResponsePhaseHTTPRequestSbfm RulesetVersionGetResponsePhase = "http_request_sbfm" - RulesetVersionGetResponsePhaseHTTPRequestSelectConfiguration RulesetVersionGetResponsePhase = "http_request_select_configuration" - RulesetVersionGetResponsePhaseHTTPRequestTransform RulesetVersionGetResponsePhase = "http_request_transform" - RulesetVersionGetResponsePhaseHTTPResponseCompression RulesetVersionGetResponsePhase = "http_response_compression" - RulesetVersionGetResponsePhaseHTTPResponseFirewallManaged RulesetVersionGetResponsePhase = "http_response_firewall_managed" - RulesetVersionGetResponsePhaseHTTPResponseHeadersTransform RulesetVersionGetResponsePhase = "http_response_headers_transform" - RulesetVersionGetResponsePhaseMagicTransit RulesetVersionGetResponsePhase = "magic_transit" - RulesetVersionGetResponsePhaseMagicTransitIDsManaged RulesetVersionGetResponsePhase = "magic_transit_ids_managed" - RulesetVersionGetResponsePhaseMagicTransitManaged RulesetVersionGetResponsePhase = "magic_transit_managed" -) - -// Union satisfied by [RulesetVersionGetResponseRulesRulesetsBlockRule], -// [RulesetVersionGetResponseRulesRulesetsExecuteRule], -// [RulesetVersionGetResponseRulesRulesetsLogRule] or -// [RulesetVersionGetResponseRulesRulesetsSkipRule]. -type RulesetVersionGetResponseRule interface { - implementsRulesetVersionGetResponseRule() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*RulesetVersionGetResponseRule)(nil)).Elem(), - "action", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetVersionGetResponseRulesRulesetsBlockRule{}), - DiscriminatorValue: "block", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetVersionGetResponseRulesRulesetsExecuteRule{}), - DiscriminatorValue: "execute", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetVersionGetResponseRulesRulesetsLogRule{}), - DiscriminatorValue: "log", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetVersionGetResponseRulesRulesetsSkipRule{}), - DiscriminatorValue: "skip", - }, - ) -} - -type RulesetVersionGetResponseRulesRulesetsBlockRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetVersionGetResponseRulesRulesetsBlockRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetVersionGetResponseRulesRulesetsBlockRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetVersionGetResponseRulesRulesetsBlockRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetVersionGetResponseRulesRulesetsBlockRuleJSON `json:"-"` -} - -// rulesetVersionGetResponseRulesRulesetsBlockRuleJSON contains the JSON metadata -// for the struct [RulesetVersionGetResponseRulesRulesetsBlockRule] -type rulesetVersionGetResponseRulesRulesetsBlockRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseRulesRulesetsBlockRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseRulesRulesetsBlockRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetVersionGetResponseRulesRulesetsBlockRule) implementsRulesetVersionGetResponseRule() {} - -// The action to perform when the rule matches. -type RulesetVersionGetResponseRulesRulesetsBlockRuleAction string - -const ( - RulesetVersionGetResponseRulesRulesetsBlockRuleActionBlock RulesetVersionGetResponseRulesRulesetsBlockRuleAction = "block" -) - -// The parameters configuring the rule's action. -type RulesetVersionGetResponseRulesRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response RulesetVersionGetResponseRulesRulesetsBlockRuleActionParametersResponse `json:"response"` - JSON rulesetVersionGetResponseRulesRulesetsBlockRuleActionParametersJSON `json:"-"` -} - -// rulesetVersionGetResponseRulesRulesetsBlockRuleActionParametersJSON contains the -// JSON metadata for the struct -// [RulesetVersionGetResponseRulesRulesetsBlockRuleActionParameters] -type rulesetVersionGetResponseRulesRulesetsBlockRuleActionParametersJSON struct { - Response apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseRulesRulesetsBlockRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseRulesRulesetsBlockRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The response to show when the block is applied. -type RulesetVersionGetResponseRulesRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content string `json:"content,required"` - // The type of the content to return. - ContentType string `json:"content_type,required"` - // The status code to return. - StatusCode int64 `json:"status_code,required"` - JSON rulesetVersionGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON `json:"-"` -} - -// rulesetVersionGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON -// contains the JSON metadata for the struct -// [RulesetVersionGetResponseRulesRulesetsBlockRuleActionParametersResponse] -type rulesetVersionGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON struct { - Content apijson.Field - ContentType apijson.Field - StatusCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseRulesRulesetsBlockRuleActionParametersResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON) RawJSON() string { - return r.raw -} - -// An object configuring the rule's logging behavior. -type RulesetVersionGetResponseRulesRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetVersionGetResponseRulesRulesetsBlockRuleLoggingJSON `json:"-"` -} - -// rulesetVersionGetResponseRulesRulesetsBlockRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetVersionGetResponseRulesRulesetsBlockRuleLogging] -type rulesetVersionGetResponseRulesRulesetsBlockRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseRulesRulesetsBlockRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseRulesRulesetsBlockRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetVersionGetResponseRulesRulesetsExecuteRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetVersionGetResponseRulesRulesetsExecuteRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetVersionGetResponseRulesRulesetsExecuteRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetVersionGetResponseRulesRulesetsExecuteRuleJSON `json:"-"` -} - -// rulesetVersionGetResponseRulesRulesetsExecuteRuleJSON contains the JSON metadata -// for the struct [RulesetVersionGetResponseRulesRulesetsExecuteRule] -type rulesetVersionGetResponseRulesRulesetsExecuteRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseRulesRulesetsExecuteRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseRulesRulesetsExecuteRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetVersionGetResponseRulesRulesetsExecuteRule) implementsRulesetVersionGetResponseRule() { -} - -// The action to perform when the rule matches. -type RulesetVersionGetResponseRulesRulesetsExecuteRuleAction string - -const ( - RulesetVersionGetResponseRulesRulesetsExecuteRuleActionExecute RulesetVersionGetResponseRulesRulesetsExecuteRuleAction = "execute" -) - -// The parameters configuring the rule's action. -type RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID string `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverrides `json:"overrides"` - JSON rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersJSON `json:"-"` -} - -// rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersJSON contains -// the JSON metadata for the struct -// [RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParameters] -type rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersJSON struct { - ID apijson.Field - MatchedData apijson.Field - Overrides apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The configuration to use for matched data logging. -type RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey string `json:"public_key,required"` - JSON rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON `json:"-"` -} - -// rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON -// contains the JSON metadata for the struct -// [RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData] -type rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON struct { - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON) RawJSON() string { - return r.raw -} - -// A set of overrides to apply to the target ruleset. -type RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action string `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories []RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled bool `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules []RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON `json:"-"` -} - -// rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON -// contains the JSON metadata for the struct -// [RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverrides] -type rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON struct { - Action apijson.Field - Categories apijson.Field - Enabled apijson.Field - Rules apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverrides) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON) RawJSON() string { - return r.raw -} - -// A category-level override -type RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category string `json:"category,required"` - // The action to override rules in the category with. - Action string `json:"action"` - // Whether to enable execution of rules in the category. - Enabled bool `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON `json:"-"` -} - -// rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON -// contains the JSON metadata for the struct -// [RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory] -type rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON struct { - Category apijson.Field - Action apijson.Field - Enabled apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for rules in the category. -type RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string - -const ( - RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" -) - -// A rule-level override -type RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID string `json:"id,required"` - // The action to override the rule with. - Action string `json:"action"` - // Whether to enable execution of the rule. - Enabled bool `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold int64 `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON `json:"-"` -} - -// rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON -// contains the JSON metadata for the struct -// [RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule] -type rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON struct { - ID apijson.Field - Action apijson.Field - Enabled apijson.Field - ScoreThreshold apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for the rule. -type RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string - -const ( - RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" -) - -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string - -const ( - RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetVersionGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" -) - -// An object configuring the rule's logging behavior. -type RulesetVersionGetResponseRulesRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetVersionGetResponseRulesRulesetsExecuteRuleLoggingJSON `json:"-"` -} - -// rulesetVersionGetResponseRulesRulesetsExecuteRuleLoggingJSON contains the JSON -// metadata for the struct -// [RulesetVersionGetResponseRulesRulesetsExecuteRuleLogging] -type rulesetVersionGetResponseRulesRulesetsExecuteRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseRulesRulesetsExecuteRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseRulesRulesetsExecuteRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetVersionGetResponseRulesRulesetsLogRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetVersionGetResponseRulesRulesetsLogRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters interface{} `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetVersionGetResponseRulesRulesetsLogRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetVersionGetResponseRulesRulesetsLogRuleJSON `json:"-"` -} - -// rulesetVersionGetResponseRulesRulesetsLogRuleJSON contains the JSON metadata for -// the struct [RulesetVersionGetResponseRulesRulesetsLogRule] -type rulesetVersionGetResponseRulesRulesetsLogRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseRulesRulesetsLogRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseRulesRulesetsLogRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetVersionGetResponseRulesRulesetsLogRule) implementsRulesetVersionGetResponseRule() {} - -// The action to perform when the rule matches. -type RulesetVersionGetResponseRulesRulesetsLogRuleAction string - -const ( - RulesetVersionGetResponseRulesRulesetsLogRuleActionLog RulesetVersionGetResponseRulesRulesetsLogRuleAction = "log" -) - -// An object configuring the rule's logging behavior. -type RulesetVersionGetResponseRulesRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetVersionGetResponseRulesRulesetsLogRuleLoggingJSON `json:"-"` -} - -// rulesetVersionGetResponseRulesRulesetsLogRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetVersionGetResponseRulesRulesetsLogRuleLogging] -type rulesetVersionGetResponseRulesRulesetsLogRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseRulesRulesetsLogRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseRulesRulesetsLogRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetVersionGetResponseRulesRulesetsSkipRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetVersionGetResponseRulesRulesetsSkipRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetVersionGetResponseRulesRulesetsSkipRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetVersionGetResponseRulesRulesetsSkipRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetVersionGetResponseRulesRulesetsSkipRuleJSON `json:"-"` -} - -// rulesetVersionGetResponseRulesRulesetsSkipRuleJSON contains the JSON metadata -// for the struct [RulesetVersionGetResponseRulesRulesetsSkipRule] -type rulesetVersionGetResponseRulesRulesetsSkipRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseRulesRulesetsSkipRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseRulesRulesetsSkipRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetVersionGetResponseRulesRulesetsSkipRule) implementsRulesetVersionGetResponseRule() {} - -// The action to perform when the rule matches. -type RulesetVersionGetResponseRulesRulesetsSkipRuleAction string - -const ( - RulesetVersionGetResponseRulesRulesetsSkipRuleActionSkip RulesetVersionGetResponseRulesRulesetsSkipRuleAction = "skip" -) - -// The parameters configuring the rule's action. -type RulesetVersionGetResponseRulesRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases []RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase `json:"phases"` - // A list of legacy security products to skip the execution of. - Products []RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersProduct `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules map[string][]string `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersRuleset `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets []string `json:"rulesets"` - JSON rulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersJSON `json:"-"` -} - -// rulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersJSON contains the -// JSON metadata for the struct -// [RulesetVersionGetResponseRulesRulesetsSkipRuleActionParameters] -type rulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersJSON struct { - Phases apijson.Field - Products apijson.Field - Rules apijson.Field - Ruleset apijson.Field - Rulesets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseRulesRulesetsSkipRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// A phase to skip the execution of. -type RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase string - -const ( - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL4 RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL7 RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -// The name of a legacy security product to skip the execution of. -type RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersProduct string - -const ( - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersProductBic RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersProduct = "bic" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersProductHot RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersProduct = "hot" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersProductUABlock RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersProductWAF RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersProduct = "waf" - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) - -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersRuleset string - -const ( - RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetVersionGetResponseRulesRulesetsSkipRuleActionParametersRuleset = "current" -) - -// An object configuring the rule's logging behavior. -type RulesetVersionGetResponseRulesRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetVersionGetResponseRulesRulesetsSkipRuleLoggingJSON `json:"-"` -} - -// rulesetVersionGetResponseRulesRulesetsSkipRuleLoggingJSON contains the JSON -// metadata for the struct [RulesetVersionGetResponseRulesRulesetsSkipRuleLogging] -type rulesetVersionGetResponseRulesRulesetsSkipRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseRulesRulesetsSkipRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseRulesRulesetsSkipRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetVersionListParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -// A response object. -type RulesetVersionListResponseEnvelope struct { - // A list of error messages. - Errors []RulesetVersionListResponseEnvelopeErrors `json:"errors,required"` - // A list of warning messages. - Messages []RulesetVersionListResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result []RulesetVersionListResponse `json:"result,required"` - // Whether the API call was successful. - Success RulesetVersionListResponseEnvelopeSuccess `json:"success,required"` - JSON rulesetVersionListResponseEnvelopeJSON `json:"-"` -} - -// rulesetVersionListResponseEnvelopeJSON contains the JSON metadata for the struct -// [RulesetVersionListResponseEnvelope] -type rulesetVersionListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetVersionListResponseEnvelopeErrors struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetVersionListResponseEnvelopeErrorsSource `json:"source"` - JSON rulesetVersionListResponseEnvelopeErrorsJSON `json:"-"` -} - -// rulesetVersionListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RulesetVersionListResponseEnvelopeErrors] -type rulesetVersionListResponseEnvelopeErrorsJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetVersionListResponseEnvelopeErrorsSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetVersionListResponseEnvelopeErrorsSourceJSON `json:"-"` -} - -// rulesetVersionListResponseEnvelopeErrorsSourceJSON contains the JSON metadata -// for the struct [RulesetVersionListResponseEnvelopeErrorsSource] -type rulesetVersionListResponseEnvelopeErrorsSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionListResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionListResponseEnvelopeErrorsSourceJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetVersionListResponseEnvelopeMessages struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetVersionListResponseEnvelopeMessagesSource `json:"source"` - JSON rulesetVersionListResponseEnvelopeMessagesJSON `json:"-"` -} - -// rulesetVersionListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [RulesetVersionListResponseEnvelopeMessages] -type rulesetVersionListResponseEnvelopeMessagesJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetVersionListResponseEnvelopeMessagesSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetVersionListResponseEnvelopeMessagesSourceJSON `json:"-"` -} - -// rulesetVersionListResponseEnvelopeMessagesSourceJSON contains the JSON metadata -// for the struct [RulesetVersionListResponseEnvelopeMessagesSource] -type rulesetVersionListResponseEnvelopeMessagesSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionListResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionListResponseEnvelopeMessagesSourceJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type RulesetVersionListResponseEnvelopeSuccess bool - -const ( - RulesetVersionListResponseEnvelopeSuccessTrue RulesetVersionListResponseEnvelopeSuccess = true -) - -type RulesetVersionDeleteParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type RulesetVersionGetParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -// A response object. -type RulesetVersionGetResponseEnvelope struct { - // A list of error messages. - Errors []RulesetVersionGetResponseEnvelopeErrors `json:"errors,required"` - // A list of warning messages. - Messages []RulesetVersionGetResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result RulesetVersionGetResponse `json:"result,required"` - // Whether the API call was successful. - Success RulesetVersionGetResponseEnvelopeSuccess `json:"success,required"` - JSON rulesetVersionGetResponseEnvelopeJSON `json:"-"` -} - -// rulesetVersionGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [RulesetVersionGetResponseEnvelope] -type rulesetVersionGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetVersionGetResponseEnvelopeErrors struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetVersionGetResponseEnvelopeErrorsSource `json:"source"` - JSON rulesetVersionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// rulesetVersionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [RulesetVersionGetResponseEnvelopeErrors] -type rulesetVersionGetResponseEnvelopeErrorsJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetVersionGetResponseEnvelopeErrorsSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetVersionGetResponseEnvelopeErrorsSourceJSON `json:"-"` -} - -// rulesetVersionGetResponseEnvelopeErrorsSourceJSON contains the JSON metadata for -// the struct [RulesetVersionGetResponseEnvelopeErrorsSource] -type rulesetVersionGetResponseEnvelopeErrorsSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseEnvelopeErrorsSourceJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetVersionGetResponseEnvelopeMessages struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetVersionGetResponseEnvelopeMessagesSource `json:"source"` - JSON rulesetVersionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// rulesetVersionGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [RulesetVersionGetResponseEnvelopeMessages] -type rulesetVersionGetResponseEnvelopeMessagesJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetVersionGetResponseEnvelopeMessagesSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetVersionGetResponseEnvelopeMessagesSourceJSON `json:"-"` -} - -// rulesetVersionGetResponseEnvelopeMessagesSourceJSON contains the JSON metadata -// for the struct [RulesetVersionGetResponseEnvelopeMessagesSource] -type rulesetVersionGetResponseEnvelopeMessagesSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionGetResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionGetResponseEnvelopeMessagesSourceJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type RulesetVersionGetResponseEnvelopeSuccess bool - -const ( - RulesetVersionGetResponseEnvelopeSuccessTrue RulesetVersionGetResponseEnvelopeSuccess = true -) diff --git a/rulesetversion_test.go b/rulesetversion_test.go deleted file mode 100644 index f0bb38079d8..00000000000 --- a/rulesetversion_test.go +++ /dev/null @@ -1,109 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRulesetVersionListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Rulesets.Versions.List( - context.TODO(), - "2f2feab2026849078ba485f918791bdc", - cloudflare.RulesetVersionListParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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 TestRulesetVersionDeleteWithOptionalParams(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("user@example.com"), - ) - err := client.Rulesets.Versions.Delete( - context.TODO(), - "2f2feab2026849078ba485f918791bdc", - "1", - cloudflare.RulesetVersionDeleteParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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 TestRulesetVersionGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Rulesets.Versions.Get( - context.TODO(), - "2f2feab2026849078ba485f918791bdc", - "1", - cloudflare.RulesetVersionGetParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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/rulesetversionbytag.go b/rulesetversionbytag.go deleted file mode 100644 index 7f725456289..00000000000 --- a/rulesetversionbytag.go +++ /dev/null @@ -1,996 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// RulesetVersionByTagService 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 [NewRulesetVersionByTagService] -// method instead. -type RulesetVersionByTagService struct { - Options []option.RequestOption -} - -// NewRulesetVersionByTagService 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 NewRulesetVersionByTagService(opts ...option.RequestOption) (r *RulesetVersionByTagService) { - r = &RulesetVersionByTagService{} - r.Options = opts - return -} - -// Fetches the rules of a managed account ruleset version for a given tag. -func (r *RulesetVersionByTagService) Get(ctx context.Context, rulesetID string, rulesetVersion string, ruleTag string, query RulesetVersionByTagGetParams, opts ...option.RequestOption) (res *RulesetVersionByTagGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RulesetVersionByTagGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/rulesets/%s/versions/%s/by_tag/%s", query.AccountID, rulesetID, rulesetVersion, ruleTag) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// A result. -type RulesetVersionByTagGetResponse struct { - // The unique ID of the ruleset. - ID string `json:"id,required"` - // The kind of the ruleset. - Kind RulesetVersionByTagGetResponseKind `json:"kind,required"` - // The timestamp of when the ruleset was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The human-readable name of the ruleset. - Name string `json:"name,required"` - // The phase of the ruleset. - Phase RulesetVersionByTagGetResponsePhase `json:"phase,required"` - // The list of rules in the ruleset. - Rules []RulesetVersionByTagGetResponseRule `json:"rules,required"` - // The version of the ruleset. - Version string `json:"version,required"` - // An informative description of the ruleset. - Description string `json:"description"` - JSON rulesetVersionByTagGetResponseJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseJSON contains the JSON metadata for the struct -// [RulesetVersionByTagGetResponse] -type rulesetVersionByTagGetResponseJSON struct { - ID apijson.Field - Kind apijson.Field - LastUpdated apijson.Field - Name apijson.Field - Phase apijson.Field - Rules apijson.Field - Version apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseJSON) RawJSON() string { - return r.raw -} - -// The kind of the ruleset. -type RulesetVersionByTagGetResponseKind string - -const ( - RulesetVersionByTagGetResponseKindManaged RulesetVersionByTagGetResponseKind = "managed" - RulesetVersionByTagGetResponseKindCustom RulesetVersionByTagGetResponseKind = "custom" - RulesetVersionByTagGetResponseKindRoot RulesetVersionByTagGetResponseKind = "root" - RulesetVersionByTagGetResponseKindZone RulesetVersionByTagGetResponseKind = "zone" -) - -// The phase of the ruleset. -type RulesetVersionByTagGetResponsePhase string - -const ( - RulesetVersionByTagGetResponsePhaseDDOSL4 RulesetVersionByTagGetResponsePhase = "ddos_l4" - RulesetVersionByTagGetResponsePhaseDDOSL7 RulesetVersionByTagGetResponsePhase = "ddos_l7" - RulesetVersionByTagGetResponsePhaseHTTPConfigSettings RulesetVersionByTagGetResponsePhase = "http_config_settings" - RulesetVersionByTagGetResponsePhaseHTTPCustomErrors RulesetVersionByTagGetResponsePhase = "http_custom_errors" - RulesetVersionByTagGetResponsePhaseHTTPLogCustomFields RulesetVersionByTagGetResponsePhase = "http_log_custom_fields" - RulesetVersionByTagGetResponsePhaseHTTPRatelimit RulesetVersionByTagGetResponsePhase = "http_ratelimit" - RulesetVersionByTagGetResponsePhaseHTTPRequestCacheSettings RulesetVersionByTagGetResponsePhase = "http_request_cache_settings" - RulesetVersionByTagGetResponsePhaseHTTPRequestDynamicRedirect RulesetVersionByTagGetResponsePhase = "http_request_dynamic_redirect" - RulesetVersionByTagGetResponsePhaseHTTPRequestFirewallCustom RulesetVersionByTagGetResponsePhase = "http_request_firewall_custom" - RulesetVersionByTagGetResponsePhaseHTTPRequestFirewallManaged RulesetVersionByTagGetResponsePhase = "http_request_firewall_managed" - RulesetVersionByTagGetResponsePhaseHTTPRequestLateTransform RulesetVersionByTagGetResponsePhase = "http_request_late_transform" - RulesetVersionByTagGetResponsePhaseHTTPRequestOrigin RulesetVersionByTagGetResponsePhase = "http_request_origin" - RulesetVersionByTagGetResponsePhaseHTTPRequestRedirect RulesetVersionByTagGetResponsePhase = "http_request_redirect" - RulesetVersionByTagGetResponsePhaseHTTPRequestSanitize RulesetVersionByTagGetResponsePhase = "http_request_sanitize" - RulesetVersionByTagGetResponsePhaseHTTPRequestSbfm RulesetVersionByTagGetResponsePhase = "http_request_sbfm" - RulesetVersionByTagGetResponsePhaseHTTPRequestSelectConfiguration RulesetVersionByTagGetResponsePhase = "http_request_select_configuration" - RulesetVersionByTagGetResponsePhaseHTTPRequestTransform RulesetVersionByTagGetResponsePhase = "http_request_transform" - RulesetVersionByTagGetResponsePhaseHTTPResponseCompression RulesetVersionByTagGetResponsePhase = "http_response_compression" - RulesetVersionByTagGetResponsePhaseHTTPResponseFirewallManaged RulesetVersionByTagGetResponsePhase = "http_response_firewall_managed" - RulesetVersionByTagGetResponsePhaseHTTPResponseHeadersTransform RulesetVersionByTagGetResponsePhase = "http_response_headers_transform" - RulesetVersionByTagGetResponsePhaseMagicTransit RulesetVersionByTagGetResponsePhase = "magic_transit" - RulesetVersionByTagGetResponsePhaseMagicTransitIDsManaged RulesetVersionByTagGetResponsePhase = "magic_transit_ids_managed" - RulesetVersionByTagGetResponsePhaseMagicTransitManaged RulesetVersionByTagGetResponsePhase = "magic_transit_managed" -) - -// Union satisfied by [RulesetVersionByTagGetResponseRulesRulesetsBlockRule], -// [RulesetVersionByTagGetResponseRulesRulesetsExecuteRule], -// [RulesetVersionByTagGetResponseRulesRulesetsLogRule] or -// [RulesetVersionByTagGetResponseRulesRulesetsSkipRule]. -type RulesetVersionByTagGetResponseRule interface { - implementsRulesetVersionByTagGetResponseRule() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*RulesetVersionByTagGetResponseRule)(nil)).Elem(), - "action", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetVersionByTagGetResponseRulesRulesetsBlockRule{}), - DiscriminatorValue: "block", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetVersionByTagGetResponseRulesRulesetsExecuteRule{}), - DiscriminatorValue: "execute", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetVersionByTagGetResponseRulesRulesetsLogRule{}), - DiscriminatorValue: "log", - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(RulesetVersionByTagGetResponseRulesRulesetsSkipRule{}), - DiscriminatorValue: "skip", - }, - ) -} - -type RulesetVersionByTagGetResponseRulesRulesetsBlockRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetVersionByTagGetResponseRulesRulesetsBlockRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetVersionByTagGetResponseRulesRulesetsBlockRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetVersionByTagGetResponseRulesRulesetsBlockRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetVersionByTagGetResponseRulesRulesetsBlockRuleJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseRulesRulesetsBlockRuleJSON contains the JSON -// metadata for the struct [RulesetVersionByTagGetResponseRulesRulesetsBlockRule] -type rulesetVersionByTagGetResponseRulesRulesetsBlockRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseRulesRulesetsBlockRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseRulesRulesetsBlockRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetVersionByTagGetResponseRulesRulesetsBlockRule) implementsRulesetVersionByTagGetResponseRule() { -} - -// The action to perform when the rule matches. -type RulesetVersionByTagGetResponseRulesRulesetsBlockRuleAction string - -const ( - RulesetVersionByTagGetResponseRulesRulesetsBlockRuleActionBlock RulesetVersionByTagGetResponseRulesRulesetsBlockRuleAction = "block" -) - -// The parameters configuring the rule's action. -type RulesetVersionByTagGetResponseRulesRulesetsBlockRuleActionParameters struct { - // The response to show when the block is applied. - Response RulesetVersionByTagGetResponseRulesRulesetsBlockRuleActionParametersResponse `json:"response"` - JSON rulesetVersionByTagGetResponseRulesRulesetsBlockRuleActionParametersJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseRulesRulesetsBlockRuleActionParametersJSON -// contains the JSON metadata for the struct -// [RulesetVersionByTagGetResponseRulesRulesetsBlockRuleActionParameters] -type rulesetVersionByTagGetResponseRulesRulesetsBlockRuleActionParametersJSON struct { - Response apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseRulesRulesetsBlockRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseRulesRulesetsBlockRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The response to show when the block is applied. -type RulesetVersionByTagGetResponseRulesRulesetsBlockRuleActionParametersResponse struct { - // The content to return. - Content string `json:"content,required"` - // The type of the content to return. - ContentType string `json:"content_type,required"` - // The status code to return. - StatusCode int64 `json:"status_code,required"` - JSON rulesetVersionByTagGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON -// contains the JSON metadata for the struct -// [RulesetVersionByTagGetResponseRulesRulesetsBlockRuleActionParametersResponse] -type rulesetVersionByTagGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON struct { - Content apijson.Field - ContentType apijson.Field - StatusCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseRulesRulesetsBlockRuleActionParametersResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseRulesRulesetsBlockRuleActionParametersResponseJSON) RawJSON() string { - return r.raw -} - -// An object configuring the rule's logging behavior. -type RulesetVersionByTagGetResponseRulesRulesetsBlockRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetVersionByTagGetResponseRulesRulesetsBlockRuleLoggingJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseRulesRulesetsBlockRuleLoggingJSON contains the -// JSON metadata for the struct -// [RulesetVersionByTagGetResponseRulesRulesetsBlockRuleLogging] -type rulesetVersionByTagGetResponseRulesRulesetsBlockRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseRulesRulesetsBlockRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseRulesRulesetsBlockRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetVersionByTagGetResponseRulesRulesetsExecuteRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleJSON contains the JSON -// metadata for the struct [RulesetVersionByTagGetResponseRulesRulesetsExecuteRule] -type rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseRulesRulesetsExecuteRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetVersionByTagGetResponseRulesRulesetsExecuteRule) implementsRulesetVersionByTagGetResponseRule() { -} - -// The action to perform when the rule matches. -type RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleAction string - -const ( - RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionExecute RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleAction = "execute" -) - -// The parameters configuring the rule's action. -type RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParameters struct { - // The ID of the ruleset to execute. - ID string `json:"id,required"` - // The configuration to use for matched data logging. - MatchedData RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData `json:"matched_data"` - // A set of overrides to apply to the target ruleset. - Overrides RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverrides `json:"overrides"` - JSON rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersJSON -// contains the JSON metadata for the struct -// [RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParameters] -type rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersJSON struct { - ID apijson.Field - MatchedData apijson.Field - Overrides apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// The configuration to use for matched data logging. -type RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData struct { - // The public key to encrypt matched data logs with. - PublicKey string `json:"public_key,required"` - JSON rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON -// contains the JSON metadata for the struct -// [RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData] -type rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON struct { - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersMatchedData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersMatchedDataJSON) RawJSON() string { - return r.raw -} - -// A set of overrides to apply to the target ruleset. -type RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverrides struct { - // An action to override all rules with. This option has lower precedence than rule - // and category overrides. - Action string `json:"action"` - // A list of category-level overrides. This option has the second-highest - // precedence after rule-level overrides. - Categories []RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory `json:"categories"` - // Whether to enable execution of all rules. This option has lower precedence than - // rule and category overrides. - Enabled bool `json:"enabled"` - // A list of rule-level overrides. This option has the highest precedence. - Rules []RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule `json:"rules"` - // A sensitivity level to set for all rules. This option has lower precedence than - // rule and category overrides and is only applicable for DDoS phases. - SensitivityLevel RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON -// contains the JSON metadata for the struct -// [RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverrides] -type rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON struct { - Action apijson.Field - Categories apijson.Field - Enabled apijson.Field - Rules apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverrides) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesJSON) RawJSON() string { - return r.raw -} - -// A category-level override -type RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory struct { - // The name of the category to override. - Category string `json:"category,required"` - // The action to override rules in the category with. - Action string `json:"action"` - // Whether to enable execution of rules in the category. - Enabled bool `json:"enabled"` - // The sensitivity level to use for rules in the category. - SensitivityLevel RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON -// contains the JSON metadata for the struct -// [RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory] -type rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON struct { - Category apijson.Field - Action apijson.Field - Enabled apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoryJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for rules in the category. -type RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel string - -const ( - RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelDefault RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "default" - RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelMedium RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "medium" - RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelLow RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "low" - RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevelEoff RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesCategoriesSensitivityLevel = "eoff" -) - -// A rule-level override -type RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule struct { - // The ID of the rule to override. - ID string `json:"id,required"` - // The action to override the rule with. - Action string `json:"action"` - // Whether to enable execution of the rule. - Enabled bool `json:"enabled"` - // The score threshold to use for the rule. - ScoreThreshold int64 `json:"score_threshold"` - // The sensitivity level to use for the rule. - SensitivityLevel RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel `json:"sensitivity_level"` - JSON rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON -// contains the JSON metadata for the struct -// [RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule] -type rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON struct { - ID apijson.Field - Action apijson.Field - Enabled apijson.Field - ScoreThreshold apijson.Field - SensitivityLevel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRuleJSON) RawJSON() string { - return r.raw -} - -// The sensitivity level to use for the rule. -type RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel string - -const ( - RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelDefault RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "default" - RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelMedium RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "medium" - RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelLow RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "low" - RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevelEoff RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesRulesSensitivityLevel = "eoff" -) - -// A sensitivity level to set for all rules. This option has lower precedence than -// rule and category overrides and is only applicable for DDoS phases. -type RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel string - -const ( - RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelDefault RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "default" - RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelMedium RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "medium" - RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelLow RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "low" - RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevelEoff RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleActionParametersOverridesSensitivityLevel = "eoff" -) - -// An object configuring the rule's logging behavior. -type RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleLoggingJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleLoggingJSON contains the -// JSON metadata for the struct -// [RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleLogging] -type rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseRulesRulesetsExecuteRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseRulesRulesetsExecuteRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetVersionByTagGetResponseRulesRulesetsLogRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetVersionByTagGetResponseRulesRulesetsLogRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters interface{} `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetVersionByTagGetResponseRulesRulesetsLogRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetVersionByTagGetResponseRulesRulesetsLogRuleJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseRulesRulesetsLogRuleJSON contains the JSON -// metadata for the struct [RulesetVersionByTagGetResponseRulesRulesetsLogRule] -type rulesetVersionByTagGetResponseRulesRulesetsLogRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseRulesRulesetsLogRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseRulesRulesetsLogRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetVersionByTagGetResponseRulesRulesetsLogRule) implementsRulesetVersionByTagGetResponseRule() { -} - -// The action to perform when the rule matches. -type RulesetVersionByTagGetResponseRulesRulesetsLogRuleAction string - -const ( - RulesetVersionByTagGetResponseRulesRulesetsLogRuleActionLog RulesetVersionByTagGetResponseRulesRulesetsLogRuleAction = "log" -) - -// An object configuring the rule's logging behavior. -type RulesetVersionByTagGetResponseRulesRulesetsLogRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetVersionByTagGetResponseRulesRulesetsLogRuleLoggingJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseRulesRulesetsLogRuleLoggingJSON contains the JSON -// metadata for the struct -// [RulesetVersionByTagGetResponseRulesRulesetsLogRuleLogging] -type rulesetVersionByTagGetResponseRulesRulesetsLogRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseRulesRulesetsLogRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseRulesRulesetsLogRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetVersionByTagGetResponseRulesRulesetsSkipRule struct { - // The timestamp of when the rule was last modified. - LastUpdated time.Time `json:"last_updated,required" format:"date-time"` - // The version of the rule. - Version string `json:"version,required"` - // The unique ID of the rule. - ID string `json:"id"` - // The action to perform when the rule matches. - Action RulesetVersionByTagGetResponseRulesRulesetsSkipRuleAction `json:"action"` - // The parameters configuring the rule's action. - ActionParameters RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParameters `json:"action_parameters"` - // The categories of the rule. - Categories []string `json:"categories"` - // An informative description of the rule. - Description string `json:"description"` - // Whether the rule should be executed. - Enabled bool `json:"enabled"` - // The expression defining which traffic will match the rule. - Expression string `json:"expression"` - // An object configuring the rule's logging behavior. - Logging RulesetVersionByTagGetResponseRulesRulesetsSkipRuleLogging `json:"logging"` - // The reference of the rule (the rule ID by default). - Ref string `json:"ref"` - JSON rulesetVersionByTagGetResponseRulesRulesetsSkipRuleJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseRulesRulesetsSkipRuleJSON contains the JSON -// metadata for the struct [RulesetVersionByTagGetResponseRulesRulesetsSkipRule] -type rulesetVersionByTagGetResponseRulesRulesetsSkipRuleJSON struct { - LastUpdated apijson.Field - Version apijson.Field - ID apijson.Field - Action apijson.Field - ActionParameters apijson.Field - Categories apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - Logging apijson.Field - Ref apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseRulesRulesetsSkipRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseRulesRulesetsSkipRuleJSON) RawJSON() string { - return r.raw -} - -func (r RulesetVersionByTagGetResponseRulesRulesetsSkipRule) implementsRulesetVersionByTagGetResponseRule() { -} - -// The action to perform when the rule matches. -type RulesetVersionByTagGetResponseRulesRulesetsSkipRuleAction string - -const ( - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionSkip RulesetVersionByTagGetResponseRulesRulesetsSkipRuleAction = "skip" -) - -// The parameters configuring the rule's action. -type RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParameters struct { - // A list of phases to skip the execution of. This option is incompatible with the - // ruleset and rulesets options. - Phases []RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase `json:"phases"` - // A list of legacy security products to skip the execution of. - Products []RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersProduct `json:"products"` - // A mapping of ruleset IDs to a list of rule IDs in that ruleset to skip the - // execution of. This option is incompatible with the ruleset option. - Rules map[string][]string `json:"rules"` - // A ruleset to skip the execution of. This option is incompatible with the - // rulesets, rules and phases options. - Ruleset RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersRuleset `json:"ruleset"` - // A list of ruleset IDs to skip the execution of. This option is incompatible with - // the ruleset and phases options. - Rulesets []string `json:"rulesets"` - JSON rulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersJSON contains -// the JSON metadata for the struct -// [RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParameters] -type rulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersJSON struct { - Phases apijson.Field - Products apijson.Field - Rules apijson.Field - Ruleset apijson.Field - Rulesets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParameters) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersJSON) RawJSON() string { - return r.raw -} - -// A phase to skip the execution of. -type RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase string - -const ( - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL4 RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l4" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseDDOSL7 RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "ddos_l7" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPConfigSettings RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_config_settings" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPCustomErrors RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_custom_errors" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPLogCustomFields RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_log_custom_fields" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRatelimit RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_ratelimit" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestCacheSettings RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_cache_settings" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestDynamicRedirect RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_dynamic_redirect" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallCustom RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_custom" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestFirewallManaged RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_firewall_managed" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestLateTransform RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_late_transform" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestOrigin RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_origin" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestRedirect RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_redirect" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSanitize RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sanitize" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSbfm RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_sbfm" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestSelectConfiguration RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_select_configuration" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPRequestTransform RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_request_transform" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseCompression RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_compression" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseFirewallManaged RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_firewall_managed" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseHTTPResponseHeadersTransform RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "http_response_headers_transform" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransit RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitIDsManaged RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_ids_managed" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhaseMagicTransitManaged RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersPhase = "magic_transit_managed" -) - -// The name of a legacy security product to skip the execution of. -type RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersProduct string - -const ( - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersProductBic RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersProduct = "bic" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersProductHot RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersProduct = "hot" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersProductRateLimit RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersProduct = "rateLimit" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersProductSecurityLevel RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersProduct = "securityLevel" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersProductUABlock RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersProduct = "uaBlock" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersProductWAF RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersProduct = "waf" - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersProductZoneLockdown RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersProduct = "zoneLockdown" -) - -// A ruleset to skip the execution of. This option is incompatible with the -// rulesets, rules and phases options. -type RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersRuleset string - -const ( - RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersRulesetCurrent RulesetVersionByTagGetResponseRulesRulesetsSkipRuleActionParametersRuleset = "current" -) - -// An object configuring the rule's logging behavior. -type RulesetVersionByTagGetResponseRulesRulesetsSkipRuleLogging struct { - // Whether to generate a log when the rule matches. - Enabled bool `json:"enabled,required"` - JSON rulesetVersionByTagGetResponseRulesRulesetsSkipRuleLoggingJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseRulesRulesetsSkipRuleLoggingJSON contains the JSON -// metadata for the struct -// [RulesetVersionByTagGetResponseRulesRulesetsSkipRuleLogging] -type rulesetVersionByTagGetResponseRulesRulesetsSkipRuleLoggingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseRulesRulesetsSkipRuleLogging) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseRulesRulesetsSkipRuleLoggingJSON) RawJSON() string { - return r.raw -} - -type RulesetVersionByTagGetParams struct { - // The unique ID of the account. - AccountID param.Field[string] `path:"account_id,required"` -} - -// A response object. -type RulesetVersionByTagGetResponseEnvelope struct { - // A list of error messages. - Errors []RulesetVersionByTagGetResponseEnvelopeErrors `json:"errors,required"` - // A list of warning messages. - Messages []RulesetVersionByTagGetResponseEnvelopeMessages `json:"messages,required"` - // A result. - Result RulesetVersionByTagGetResponse `json:"result,required"` - // Whether the API call was successful. - Success RulesetVersionByTagGetResponseEnvelopeSuccess `json:"success,required"` - JSON rulesetVersionByTagGetResponseEnvelopeJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [RulesetVersionByTagGetResponseEnvelope] -type rulesetVersionByTagGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetVersionByTagGetResponseEnvelopeErrors struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetVersionByTagGetResponseEnvelopeErrorsSource `json:"source"` - JSON rulesetVersionByTagGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [RulesetVersionByTagGetResponseEnvelopeErrors] -type rulesetVersionByTagGetResponseEnvelopeErrorsJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetVersionByTagGetResponseEnvelopeErrorsSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetVersionByTagGetResponseEnvelopeErrorsSourceJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseEnvelopeErrorsSourceJSON contains the JSON -// metadata for the struct [RulesetVersionByTagGetResponseEnvelopeErrorsSource] -type rulesetVersionByTagGetResponseEnvelopeErrorsSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseEnvelopeErrorsSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseEnvelopeErrorsSourceJSON) RawJSON() string { - return r.raw -} - -// A message. -type RulesetVersionByTagGetResponseEnvelopeMessages struct { - // A text description of this message. - Message string `json:"message,required"` - // A unique code for this message. - Code int64 `json:"code"` - // The source of this message. - Source RulesetVersionByTagGetResponseEnvelopeMessagesSource `json:"source"` - JSON rulesetVersionByTagGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [RulesetVersionByTagGetResponseEnvelopeMessages] -type rulesetVersionByTagGetResponseEnvelopeMessagesJSON struct { - Message apijson.Field - Code apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// The source of this message. -type RulesetVersionByTagGetResponseEnvelopeMessagesSource struct { - // A JSON pointer to the field that is the source of the message. - Pointer string `json:"pointer,required"` - JSON rulesetVersionByTagGetResponseEnvelopeMessagesSourceJSON `json:"-"` -} - -// rulesetVersionByTagGetResponseEnvelopeMessagesSourceJSON contains the JSON -// metadata for the struct [RulesetVersionByTagGetResponseEnvelopeMessagesSource] -type rulesetVersionByTagGetResponseEnvelopeMessagesSourceJSON struct { - Pointer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RulesetVersionByTagGetResponseEnvelopeMessagesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rulesetVersionByTagGetResponseEnvelopeMessagesSourceJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type RulesetVersionByTagGetResponseEnvelopeSuccess bool - -const ( - RulesetVersionByTagGetResponseEnvelopeSuccessTrue RulesetVersionByTagGetResponseEnvelopeSuccess = true -) diff --git a/rulesetversionbytag_test.go b/rulesetversionbytag_test.go deleted file mode 100644 index 3752792bab9..00000000000 --- a/rulesetversionbytag_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRulesetVersionByTagGet(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("user@example.com"), - ) - _, err := client.Rulesets.Versions.ByTags.Get( - context.TODO(), - "2f2feab2026849078ba485f918791bdc", - "1", - "directory-traversal", - cloudflare.RulesetVersionByTagGetParams{ - AccountID: cloudflare.F("abf9b32d38c5f572afde3336ec0ce302"), - }, - ) - 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/rum/aliases.go b/rum/aliases.go new file mode 100644 index 00000000000..1abe3af2916 --- /dev/null +++ b/rum/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package rum + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/rum/rule.go b/rum/rule.go new file mode 100644 index 00000000000..0928b1c6bc9 --- /dev/null +++ b/rum/rule.go @@ -0,0 +1,321 @@ +// File generated from our OpenAPI spec by Stainless. + +package rum + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-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 +} + +// 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 + return +} + +// Creates a new rule in a Web Analytics ruleset. +func (r *RuleService) New(ctx context.Context, rulesetID string, params RuleNewParams, opts ...option.RequestOption) (res *RUMRule, err error) { + opts = append(r.Options[:], opts...) + var env RuleNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/rum/v2/%s/rule", params.AccountID, rulesetID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a rule in a Web Analytics ruleset. +func (r *RuleService) Update(ctx context.Context, rulesetID string, ruleID string, params RuleUpdateParams, opts ...option.RequestOption) (res *RUMRule, err error) { + opts = append(r.Options[:], opts...) + var env RuleUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/rum/v2/%s/rule/%s", params.AccountID, rulesetID, ruleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists all the rules in a Web Analytics ruleset. +func (r *RuleService) List(ctx context.Context, rulesetID string, query RuleListParams, opts ...option.RequestOption) (res *RuleListResponse, err error) { + opts = append(r.Options[:], opts...) + var env RuleListResponseEnvelope + path := fmt.Sprintf("accounts/%s/rum/v2/%s/rules", query.AccountID, rulesetID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes an existing rule from a Web Analytics ruleset. +func (r *RuleService) Delete(ctx context.Context, rulesetID string, ruleID string, body RuleDeleteParams, opts ...option.RequestOption) (res *RuleDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env RuleDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/rum/v2/%s/rule/%s", body.AccountID, rulesetID, ruleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type RUMRule struct { + // The Web Analytics rule identifier. + ID string `json:"id"` + Created time.Time `json:"created" format:"date-time"` + // The hostname the rule will be applied to. + Host string `json:"host"` + // Whether the rule includes or excludes traffic from being measured. + Inclusive bool `json:"inclusive"` + // Whether the rule is paused or not. + IsPaused bool `json:"is_paused"` + // The paths the rule will be applied to. + Paths []string `json:"paths"` + Priority float64 `json:"priority"` + JSON rumRuleJSON `json:"-"` +} + +// rumRuleJSON contains the JSON metadata for the struct [RUMRule] +type rumRuleJSON struct { + ID apijson.Field + Created apijson.Field + Host apijson.Field + Inclusive apijson.Field + IsPaused apijson.Field + Paths apijson.Field + Priority apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RUMRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rumRuleJSON) RawJSON() string { + return r.raw +} + +type RuleListResponse struct { + // A list of rules. + Rules []RUMRule `json:"rules"` + Ruleset RuleListResponseRuleset `json:"ruleset"` + JSON ruleListResponseJSON `json:"-"` +} + +// ruleListResponseJSON contains the JSON metadata for the struct +// [RuleListResponse] +type ruleListResponseJSON struct { + Rules apijson.Field + Ruleset apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleListResponseJSON) RawJSON() string { + return r.raw +} + +type RuleListResponseRuleset struct { + // The Web Analytics ruleset identifier. + ID string `json:"id"` + // Whether the ruleset is enabled. + Enabled bool `json:"enabled"` + ZoneName string `json:"zone_name"` + // The zone identifier. + ZoneTag string `json:"zone_tag"` + JSON ruleListResponseRulesetJSON `json:"-"` +} + +// ruleListResponseRulesetJSON contains the JSON metadata for the struct +// [RuleListResponseRuleset] +type ruleListResponseRulesetJSON struct { + ID apijson.Field + Enabled apijson.Field + ZoneName apijson.Field + ZoneTag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListResponseRuleset) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleListResponseRulesetJSON) RawJSON() string { + return r.raw +} + +type RuleDeleteResponse struct { + // The Web Analytics rule identifier. + ID string `json:"id"` + JSON ruleDeleteResponseJSON `json:"-"` +} + +// ruleDeleteResponseJSON contains the JSON metadata for the struct +// [RuleDeleteResponse] +type ruleDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type RuleNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Host param.Field[string] `json:"host"` + // Whether the rule includes or excludes traffic from being measured. + Inclusive param.Field[bool] `json:"inclusive"` + // Whether the rule is paused or not. + IsPaused param.Field[bool] `json:"is_paused"` + Paths param.Field[[]string] `json:"paths"` +} + +func (r RuleNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RuleNewResponseEnvelope struct { + Result RUMRule `json:"result"` + JSON ruleNewResponseEnvelopeJSON `json:"-"` +} + +// ruleNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleNewResponseEnvelope] +type ruleNewResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Host param.Field[string] `json:"host"` + // Whether the rule includes or excludes traffic from being measured. + Inclusive param.Field[bool] `json:"inclusive"` + // Whether the rule is paused or not. + IsPaused param.Field[bool] `json:"is_paused"` + Paths param.Field[[]string] `json:"paths"` +} + +func (r RuleUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RuleUpdateResponseEnvelope struct { + Result RUMRule `json:"result"` + JSON ruleUpdateResponseEnvelopeJSON `json:"-"` +} + +// ruleUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleUpdateResponseEnvelope] +type ruleUpdateResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type RuleListResponseEnvelope struct { + Result RuleListResponse `json:"result"` + JSON ruleListResponseEnvelopeJSON `json:"-"` +} + +// ruleListResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleListResponseEnvelope] +type ruleListResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type RuleDeleteResponseEnvelope struct { + Result RuleDeleteResponse `json:"result"` + JSON ruleDeleteResponseEnvelopeJSON `json:"-"` +} + +// ruleDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleDeleteResponseEnvelope] +type ruleDeleteResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/rum/rule_test.go b/rum/rule_test.go new file mode 100644 index 00000000000..daba261be46 --- /dev/null +++ b/rum/rule_test.go @@ -0,0 +1,145 @@ +// File generated from our OpenAPI spec by Stainless. + +package rum_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/rum" +) + +func TestRuleNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.RUM.Rules.New( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + rum.RuleNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Host: cloudflare.F("example.com"), + Inclusive: cloudflare.F(true), + IsPaused: cloudflare.F(false), + Paths: cloudflare.F([]string{"*"}), + }, + ) + 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 TestRuleUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.RUM.Rules.Update( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + rum.RuleUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Host: cloudflare.F("example.com"), + Inclusive: cloudflare.F(true), + IsPaused: cloudflare.F(false), + Paths: cloudflare.F([]string{"*"}), + }, + ) + 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 TestRuleList(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("user@example.com"), + ) + _, err := client.RUM.Rules.List( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + rum.RuleListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestRuleDelete(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("user@example.com"), + ) + _, err := client.RUM.Rules.Delete( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + rum.RuleDeleteParams{ + AccountID: cloudflare.F("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/rum.go b/rum/rum.go similarity index 83% rename from rum.go rename to rum/rum.go index da7e91f75ce..ff7e53eae1b 100644 --- a/rum.go +++ b/rum/rum.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package rum import ( "github.com/cloudflare/cloudflare-go/option" @@ -12,8 +12,8 @@ import ( // directly, and instead use the [NewRUMService] method instead. type RUMService struct { Options []option.RequestOption - SiteInfos *RUMSiteInfoService - Rules *RUMRuleService + SiteInfos *SiteInfoService + Rules *RuleService } // NewRUMService generates a new service that applies the given options to each @@ -22,7 +22,7 @@ type RUMService struct { func NewRUMService(opts ...option.RequestOption) (r *RUMService) { r = &RUMService{} r.Options = opts - r.SiteInfos = NewRUMSiteInfoService(opts...) - r.Rules = NewRUMRuleService(opts...) + r.SiteInfos = NewSiteInfoService(opts...) + r.Rules = NewRuleService(opts...) return } diff --git a/rum/siteinfo.go b/rum/siteinfo.go new file mode 100644 index 00000000000..b0ce8d46111 --- /dev/null +++ b/rum/siteinfo.go @@ -0,0 +1,352 @@ +// File generated from our OpenAPI spec by Stainless. + +package rum + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" +) + +// SiteInfoService 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 [NewSiteInfoService] method instead. +type SiteInfoService struct { + Options []option.RequestOption +} + +// NewSiteInfoService 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 NewSiteInfoService(opts ...option.RequestOption) (r *SiteInfoService) { + r = &SiteInfoService{} + r.Options = opts + return +} + +// Creates a new Web Analytics site. +func (r *SiteInfoService) New(ctx context.Context, params SiteInfoNewParams, opts ...option.RequestOption) (res *RUMSite, err error) { + opts = append(r.Options[:], opts...) + var env SiteInfoNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/rum/site_info", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates an existing Web Analytics site. +func (r *SiteInfoService) Update(ctx context.Context, siteID string, params SiteInfoUpdateParams, opts ...option.RequestOption) (res *RUMSite, err error) { + opts = append(r.Options[:], opts...) + var env SiteInfoUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/rum/site_info/%s", params.AccountID, siteID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists all Web Analytics sites of an account. +func (r *SiteInfoService) List(ctx context.Context, params SiteInfoListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[RUMSite], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("accounts/%s/rum/site_info/list", params.AccountID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists all Web Analytics sites of an account. +func (r *SiteInfoService) ListAutoPaging(ctx context.Context, params SiteInfoListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[RUMSite] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) +} + +// Deletes an existing Web Analytics site. +func (r *SiteInfoService) Delete(ctx context.Context, siteID string, body SiteInfoDeleteParams, opts ...option.RequestOption) (res *SiteInfoDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env SiteInfoDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/rum/site_info/%s", body.AccountID, siteID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Retrieves a Web Analytics site. +func (r *SiteInfoService) Get(ctx context.Context, siteID string, query SiteInfoGetParams, opts ...option.RequestOption) (res *RUMSite, err error) { + opts = append(r.Options[:], opts...) + var env SiteInfoGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/rum/site_info/%s", query.AccountID, siteID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type RUMSite struct { + // If enabled, the JavaScript snippet is automatically injected for orange-clouded + // sites. + AutoInstall bool `json:"auto_install"` + Created time.Time `json:"created" format:"date-time"` + // A list of rules. + Rules []RUMRule `json:"rules"` + Ruleset RUMSiteRuleset `json:"ruleset"` + // The Web Analytics site identifier. + SiteTag string `json:"site_tag"` + // The Web Analytics site token. + SiteToken string `json:"site_token"` + // Encoded JavaScript snippet. + Snippet string `json:"snippet"` + JSON rumSiteJSON `json:"-"` +} + +// rumSiteJSON contains the JSON metadata for the struct [RUMSite] +type rumSiteJSON struct { + AutoInstall apijson.Field + Created apijson.Field + Rules apijson.Field + Ruleset apijson.Field + SiteTag apijson.Field + SiteToken apijson.Field + Snippet apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RUMSite) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rumSiteJSON) RawJSON() string { + return r.raw +} + +type RUMSiteRuleset struct { + // The Web Analytics ruleset identifier. + ID string `json:"id"` + // Whether the ruleset is enabled. + Enabled bool `json:"enabled"` + ZoneName string `json:"zone_name"` + // The zone identifier. + ZoneTag string `json:"zone_tag"` + JSON rumSiteRulesetJSON `json:"-"` +} + +// rumSiteRulesetJSON contains the JSON metadata for the struct [RUMSiteRuleset] +type rumSiteRulesetJSON struct { + ID apijson.Field + Enabled apijson.Field + ZoneName apijson.Field + ZoneTag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RUMSiteRuleset) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r rumSiteRulesetJSON) RawJSON() string { + return r.raw +} + +type SiteInfoDeleteResponse struct { + // The Web Analytics site identifier. + SiteTag string `json:"site_tag"` + JSON siteInfoDeleteResponseJSON `json:"-"` +} + +// siteInfoDeleteResponseJSON contains the JSON metadata for the struct +// [SiteInfoDeleteResponse] +type siteInfoDeleteResponseJSON struct { + SiteTag apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SiteInfoDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r siteInfoDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type SiteInfoNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // If enabled, the JavaScript snippet is automatically injected for orange-clouded + // sites. + AutoInstall param.Field[bool] `json:"auto_install"` + // The hostname to use for gray-clouded sites. + Host param.Field[string] `json:"host"` + // The zone identifier. + ZoneTag param.Field[string] `json:"zone_tag"` +} + +func (r SiteInfoNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SiteInfoNewResponseEnvelope struct { + Result RUMSite `json:"result"` + JSON siteInfoNewResponseEnvelopeJSON `json:"-"` +} + +// siteInfoNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [SiteInfoNewResponseEnvelope] +type siteInfoNewResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SiteInfoNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r siteInfoNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SiteInfoUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // If enabled, the JavaScript snippet is automatically injected for orange-clouded + // sites. + AutoInstall param.Field[bool] `json:"auto_install"` + // The hostname to use for gray-clouded sites. + Host param.Field[string] `json:"host"` + // The zone identifier. + ZoneTag param.Field[string] `json:"zone_tag"` +} + +func (r SiteInfoUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SiteInfoUpdateResponseEnvelope struct { + Result RUMSite `json:"result"` + JSON siteInfoUpdateResponseEnvelopeJSON `json:"-"` +} + +// siteInfoUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [SiteInfoUpdateResponseEnvelope] +type siteInfoUpdateResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SiteInfoUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r siteInfoUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SiteInfoListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The property used to sort the list of results. + OrderBy param.Field[SiteInfoListParamsOrderBy] `query:"order_by"` + // Current page within the paginated list of results. + Page param.Field[float64] `query:"page"` + // Number of items to return per page of results. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [SiteInfoListParams]'s query parameters as `url.Values`. +func (r SiteInfoListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// The property used to sort the list of results. +type SiteInfoListParamsOrderBy string + +const ( + SiteInfoListParamsOrderByHost SiteInfoListParamsOrderBy = "host" + SiteInfoListParamsOrderByCreated SiteInfoListParamsOrderBy = "created" +) + +type SiteInfoDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type SiteInfoDeleteResponseEnvelope struct { + Result SiteInfoDeleteResponse `json:"result"` + JSON siteInfoDeleteResponseEnvelopeJSON `json:"-"` +} + +// siteInfoDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [SiteInfoDeleteResponseEnvelope] +type siteInfoDeleteResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SiteInfoDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r siteInfoDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SiteInfoGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type SiteInfoGetResponseEnvelope struct { + Result RUMSite `json:"result"` + JSON siteInfoGetResponseEnvelopeJSON `json:"-"` +} + +// siteInfoGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SiteInfoGetResponseEnvelope] +type siteInfoGetResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SiteInfoGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r siteInfoGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/rum/siteinfo_test.go b/rum/siteinfo_test.go new file mode 100644 index 00000000000..2ebddcf8318 --- /dev/null +++ b/rum/siteinfo_test.go @@ -0,0 +1,166 @@ +// File generated from our OpenAPI spec by Stainless. + +package rum_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/rum" +) + +func TestSiteInfoNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.RUM.SiteInfos.New(context.TODO(), rum.SiteInfoNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + AutoInstall: cloudflare.F(true), + Host: cloudflare.F("example.com"), + ZoneTag: cloudflare.F("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()) + } +} + +func TestSiteInfoUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.RUM.SiteInfos.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + rum.SiteInfoUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + AutoInstall: cloudflare.F(true), + Host: cloudflare.F("example.com"), + ZoneTag: cloudflare.F("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()) + } +} + +func TestSiteInfoListWithOptionalParams(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("user@example.com"), + ) + _, err := client.RUM.SiteInfos.List(context.TODO(), rum.SiteInfoListParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + OrderBy: cloudflare.F(rum.SiteInfoListParamsOrderByHost), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(10.000000), + }) + 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 TestSiteInfoDelete(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("user@example.com"), + ) + _, err := client.RUM.SiteInfos.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + rum.SiteInfoDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestSiteInfoGet(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("user@example.com"), + ) + _, err := client.RUM.SiteInfos.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + rum.SiteInfoGetParams{ + AccountID: cloudflare.F("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/rumrule.go b/rumrule.go deleted file mode 100644 index 3ab7e7c6872..00000000000 --- a/rumrule.go +++ /dev/null @@ -1,398 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// RUMRuleService 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 [NewRUMRuleService] method instead. -type RUMRuleService struct { - Options []option.RequestOption -} - -// NewRUMRuleService 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 NewRUMRuleService(opts ...option.RequestOption) (r *RUMRuleService) { - r = &RUMRuleService{} - r.Options = opts - return -} - -// Creates a new rule in a Web Analytics ruleset. -func (r *RUMRuleService) New(ctx context.Context, rulesetID string, params RUMRuleNewParams, opts ...option.RequestOption) (res *RUMRuleNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env RUMRuleNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/rum/v2/%s/rule", params.AccountID, rulesetID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a rule in a Web Analytics ruleset. -func (r *RUMRuleService) Update(ctx context.Context, rulesetID string, ruleID string, params RUMRuleUpdateParams, opts ...option.RequestOption) (res *RUMRuleUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env RUMRuleUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/rum/v2/%s/rule/%s", params.AccountID, rulesetID, ruleID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists all the rules in a Web Analytics ruleset. -func (r *RUMRuleService) List(ctx context.Context, rulesetID string, query RUMRuleListParams, opts ...option.RequestOption) (res *RUMRuleListResponse, err error) { - opts = append(r.Options[:], opts...) - var env RUMRuleListResponseEnvelope - path := fmt.Sprintf("accounts/%s/rum/v2/%s/rules", query.AccountID, rulesetID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes an existing rule from a Web Analytics ruleset. -func (r *RUMRuleService) Delete(ctx context.Context, rulesetID string, ruleID string, body RUMRuleDeleteParams, opts ...option.RequestOption) (res *RUMRuleDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env RUMRuleDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/rum/v2/%s/rule/%s", body.AccountID, rulesetID, ruleID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RUMRuleNewResponse struct { - // The Web Analytics rule identifier. - ID string `json:"id"` - Created time.Time `json:"created" format:"date-time"` - // The hostname the rule will be applied to. - Host string `json:"host"` - // Whether the rule includes or excludes traffic from being measured. - Inclusive bool `json:"inclusive"` - // Whether the rule is paused or not. - IsPaused bool `json:"is_paused"` - // The paths the rule will be applied to. - Paths []string `json:"paths"` - Priority float64 `json:"priority"` - JSON rumRuleNewResponseJSON `json:"-"` -} - -// rumRuleNewResponseJSON contains the JSON metadata for the struct -// [RUMRuleNewResponse] -type rumRuleNewResponseJSON struct { - ID apijson.Field - Created apijson.Field - Host apijson.Field - Inclusive apijson.Field - IsPaused apijson.Field - Paths apijson.Field - Priority apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMRuleNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumRuleNewResponseJSON) RawJSON() string { - return r.raw -} - -type RUMRuleUpdateResponse struct { - // The Web Analytics rule identifier. - ID string `json:"id"` - Created time.Time `json:"created" format:"date-time"` - // The hostname the rule will be applied to. - Host string `json:"host"` - // Whether the rule includes or excludes traffic from being measured. - Inclusive bool `json:"inclusive"` - // Whether the rule is paused or not. - IsPaused bool `json:"is_paused"` - // The paths the rule will be applied to. - Paths []string `json:"paths"` - Priority float64 `json:"priority"` - JSON rumRuleUpdateResponseJSON `json:"-"` -} - -// rumRuleUpdateResponseJSON contains the JSON metadata for the struct -// [RUMRuleUpdateResponse] -type rumRuleUpdateResponseJSON struct { - ID apijson.Field - Created apijson.Field - Host apijson.Field - Inclusive apijson.Field - IsPaused apijson.Field - Paths apijson.Field - Priority apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMRuleUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumRuleUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type RUMRuleListResponse struct { - // A list of rules. - Rules []RUMRuleListResponseRule `json:"rules"` - Ruleset RUMRuleListResponseRuleset `json:"ruleset"` - JSON rumRuleListResponseJSON `json:"-"` -} - -// rumRuleListResponseJSON contains the JSON metadata for the struct -// [RUMRuleListResponse] -type rumRuleListResponseJSON struct { - Rules apijson.Field - Ruleset apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMRuleListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumRuleListResponseJSON) RawJSON() string { - return r.raw -} - -type RUMRuleListResponseRule struct { - // The Web Analytics rule identifier. - ID string `json:"id"` - Created time.Time `json:"created" format:"date-time"` - // The hostname the rule will be applied to. - Host string `json:"host"` - // Whether the rule includes or excludes traffic from being measured. - Inclusive bool `json:"inclusive"` - // Whether the rule is paused or not. - IsPaused bool `json:"is_paused"` - // The paths the rule will be applied to. - Paths []string `json:"paths"` - Priority float64 `json:"priority"` - JSON rumRuleListResponseRuleJSON `json:"-"` -} - -// rumRuleListResponseRuleJSON contains the JSON metadata for the struct -// [RUMRuleListResponseRule] -type rumRuleListResponseRuleJSON struct { - ID apijson.Field - Created apijson.Field - Host apijson.Field - Inclusive apijson.Field - IsPaused apijson.Field - Paths apijson.Field - Priority apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMRuleListResponseRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumRuleListResponseRuleJSON) RawJSON() string { - return r.raw -} - -type RUMRuleListResponseRuleset struct { - // The Web Analytics ruleset identifier. - ID string `json:"id"` - // Whether the ruleset is enabled. - Enabled bool `json:"enabled"` - ZoneName string `json:"zone_name"` - // The zone identifier. - ZoneTag string `json:"zone_tag"` - JSON rumRuleListResponseRulesetJSON `json:"-"` -} - -// rumRuleListResponseRulesetJSON contains the JSON metadata for the struct -// [RUMRuleListResponseRuleset] -type rumRuleListResponseRulesetJSON struct { - ID apijson.Field - Enabled apijson.Field - ZoneName apijson.Field - ZoneTag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMRuleListResponseRuleset) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumRuleListResponseRulesetJSON) RawJSON() string { - return r.raw -} - -type RUMRuleDeleteResponse struct { - // The Web Analytics rule identifier. - ID string `json:"id"` - JSON rumRuleDeleteResponseJSON `json:"-"` -} - -// rumRuleDeleteResponseJSON contains the JSON metadata for the struct -// [RUMRuleDeleteResponse] -type rumRuleDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMRuleDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumRuleDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type RUMRuleNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Host param.Field[string] `json:"host"` - // Whether the rule includes or excludes traffic from being measured. - Inclusive param.Field[bool] `json:"inclusive"` - // Whether the rule is paused or not. - IsPaused param.Field[bool] `json:"is_paused"` - Paths param.Field[[]string] `json:"paths"` -} - -func (r RUMRuleNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RUMRuleNewResponseEnvelope struct { - Result RUMRuleNewResponse `json:"result"` - JSON rumRuleNewResponseEnvelopeJSON `json:"-"` -} - -// rumRuleNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [RUMRuleNewResponseEnvelope] -type rumRuleNewResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMRuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumRuleNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RUMRuleUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Host param.Field[string] `json:"host"` - // Whether the rule includes or excludes traffic from being measured. - Inclusive param.Field[bool] `json:"inclusive"` - // Whether the rule is paused or not. - IsPaused param.Field[bool] `json:"is_paused"` - Paths param.Field[[]string] `json:"paths"` -} - -func (r RUMRuleUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RUMRuleUpdateResponseEnvelope struct { - Result RUMRuleUpdateResponse `json:"result"` - JSON rumRuleUpdateResponseEnvelopeJSON `json:"-"` -} - -// rumRuleUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [RUMRuleUpdateResponseEnvelope] -type rumRuleUpdateResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMRuleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumRuleUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RUMRuleListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type RUMRuleListResponseEnvelope struct { - Result RUMRuleListResponse `json:"result"` - JSON rumRuleListResponseEnvelopeJSON `json:"-"` -} - -// rumRuleListResponseEnvelopeJSON contains the JSON metadata for the struct -// [RUMRuleListResponseEnvelope] -type rumRuleListResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMRuleListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumRuleListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RUMRuleDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type RUMRuleDeleteResponseEnvelope struct { - Result RUMRuleDeleteResponse `json:"result"` - JSON rumRuleDeleteResponseEnvelopeJSON `json:"-"` -} - -// rumRuleDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [RUMRuleDeleteResponseEnvelope] -type rumRuleDeleteResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMRuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumRuleDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/rumrule_test.go b/rumrule_test.go deleted file mode 100644 index 77f1a6ee7d0..00000000000 --- a/rumrule_test.go +++ /dev/null @@ -1,144 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRUMRuleNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.RUM.Rules.New( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.RUMRuleNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Host: cloudflare.F("example.com"), - Inclusive: cloudflare.F(true), - IsPaused: cloudflare.F(false), - Paths: cloudflare.F([]string{"*"}), - }, - ) - 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 TestRUMRuleUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.RUM.Rules.Update( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.RUMRuleUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Host: cloudflare.F("example.com"), - Inclusive: cloudflare.F(true), - IsPaused: cloudflare.F(false), - Paths: cloudflare.F([]string{"*"}), - }, - ) - 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 TestRUMRuleList(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("user@example.com"), - ) - _, err := client.RUM.Rules.List( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.RUMRuleListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestRUMRuleDelete(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("user@example.com"), - ) - _, err := client.RUM.Rules.Delete( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.RUMRuleDeleteParams{ - AccountID: cloudflare.F("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/rumsiteinfo.go b/rumsiteinfo.go deleted file mode 100644 index 94cb99dc330..00000000000 --- a/rumsiteinfo.go +++ /dev/null @@ -1,714 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" -) - -// RUMSiteInfoService 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 [NewRUMSiteInfoService] method -// instead. -type RUMSiteInfoService struct { - Options []option.RequestOption -} - -// NewRUMSiteInfoService 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 NewRUMSiteInfoService(opts ...option.RequestOption) (r *RUMSiteInfoService) { - r = &RUMSiteInfoService{} - r.Options = opts - return -} - -// Creates a new Web Analytics site. -func (r *RUMSiteInfoService) New(ctx context.Context, params RUMSiteInfoNewParams, opts ...option.RequestOption) (res *RUMSiteInfoNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env RUMSiteInfoNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/rum/site_info", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates an existing Web Analytics site. -func (r *RUMSiteInfoService) Update(ctx context.Context, siteID string, params RUMSiteInfoUpdateParams, opts ...option.RequestOption) (res *RUMSiteInfoUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env RUMSiteInfoUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/rum/site_info/%s", params.AccountID, siteID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists all Web Analytics sites of an account. -func (r *RUMSiteInfoService) List(ctx context.Context, params RUMSiteInfoListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[RUMSiteInfoListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("accounts/%s/rum/site_info/list", params.AccountID) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Lists all Web Analytics sites of an account. -func (r *RUMSiteInfoService) ListAutoPaging(ctx context.Context, params RUMSiteInfoListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[RUMSiteInfoListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) -} - -// Deletes an existing Web Analytics site. -func (r *RUMSiteInfoService) Delete(ctx context.Context, siteID string, body RUMSiteInfoDeleteParams, opts ...option.RequestOption) (res *RUMSiteInfoDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env RUMSiteInfoDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/rum/site_info/%s", body.AccountID, siteID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Retrieves a Web Analytics site. -func (r *RUMSiteInfoService) Get(ctx context.Context, siteID string, query RUMSiteInfoGetParams, opts ...option.RequestOption) (res *RUMSiteInfoGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env RUMSiteInfoGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/rum/site_info/%s", query.AccountID, siteID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type RUMSiteInfoNewResponse struct { - // If enabled, the JavaScript snippet is automatically injected for orange-clouded - // sites. - AutoInstall bool `json:"auto_install"` - Created time.Time `json:"created" format:"date-time"` - // A list of rules. - Rules []RUMSiteInfoNewResponseRule `json:"rules"` - Ruleset RUMSiteInfoNewResponseRuleset `json:"ruleset"` - // The Web Analytics site identifier. - SiteTag string `json:"site_tag"` - // The Web Analytics site token. - SiteToken string `json:"site_token"` - // Encoded JavaScript snippet. - Snippet string `json:"snippet"` - JSON rumSiteInfoNewResponseJSON `json:"-"` -} - -// rumSiteInfoNewResponseJSON contains the JSON metadata for the struct -// [RUMSiteInfoNewResponse] -type rumSiteInfoNewResponseJSON struct { - AutoInstall apijson.Field - Created apijson.Field - Rules apijson.Field - Ruleset apijson.Field - SiteTag apijson.Field - SiteToken apijson.Field - Snippet apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMSiteInfoNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumSiteInfoNewResponseJSON) RawJSON() string { - return r.raw -} - -type RUMSiteInfoNewResponseRule struct { - // The Web Analytics rule identifier. - ID string `json:"id"` - Created time.Time `json:"created" format:"date-time"` - // The hostname the rule will be applied to. - Host string `json:"host"` - // Whether the rule includes or excludes traffic from being measured. - Inclusive bool `json:"inclusive"` - // Whether the rule is paused or not. - IsPaused bool `json:"is_paused"` - // The paths the rule will be applied to. - Paths []string `json:"paths"` - Priority float64 `json:"priority"` - JSON rumSiteInfoNewResponseRuleJSON `json:"-"` -} - -// rumSiteInfoNewResponseRuleJSON contains the JSON metadata for the struct -// [RUMSiteInfoNewResponseRule] -type rumSiteInfoNewResponseRuleJSON struct { - ID apijson.Field - Created apijson.Field - Host apijson.Field - Inclusive apijson.Field - IsPaused apijson.Field - Paths apijson.Field - Priority apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMSiteInfoNewResponseRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumSiteInfoNewResponseRuleJSON) RawJSON() string { - return r.raw -} - -type RUMSiteInfoNewResponseRuleset struct { - // The Web Analytics ruleset identifier. - ID string `json:"id"` - // Whether the ruleset is enabled. - Enabled bool `json:"enabled"` - ZoneName string `json:"zone_name"` - // The zone identifier. - ZoneTag string `json:"zone_tag"` - JSON rumSiteInfoNewResponseRulesetJSON `json:"-"` -} - -// rumSiteInfoNewResponseRulesetJSON contains the JSON metadata for the struct -// [RUMSiteInfoNewResponseRuleset] -type rumSiteInfoNewResponseRulesetJSON struct { - ID apijson.Field - Enabled apijson.Field - ZoneName apijson.Field - ZoneTag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMSiteInfoNewResponseRuleset) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumSiteInfoNewResponseRulesetJSON) RawJSON() string { - return r.raw -} - -type RUMSiteInfoUpdateResponse struct { - // If enabled, the JavaScript snippet is automatically injected for orange-clouded - // sites. - AutoInstall bool `json:"auto_install"` - Created time.Time `json:"created" format:"date-time"` - // A list of rules. - Rules []RUMSiteInfoUpdateResponseRule `json:"rules"` - Ruleset RUMSiteInfoUpdateResponseRuleset `json:"ruleset"` - // The Web Analytics site identifier. - SiteTag string `json:"site_tag"` - // The Web Analytics site token. - SiteToken string `json:"site_token"` - // Encoded JavaScript snippet. - Snippet string `json:"snippet"` - JSON rumSiteInfoUpdateResponseJSON `json:"-"` -} - -// rumSiteInfoUpdateResponseJSON contains the JSON metadata for the struct -// [RUMSiteInfoUpdateResponse] -type rumSiteInfoUpdateResponseJSON struct { - AutoInstall apijson.Field - Created apijson.Field - Rules apijson.Field - Ruleset apijson.Field - SiteTag apijson.Field - SiteToken apijson.Field - Snippet apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMSiteInfoUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumSiteInfoUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type RUMSiteInfoUpdateResponseRule struct { - // The Web Analytics rule identifier. - ID string `json:"id"` - Created time.Time `json:"created" format:"date-time"` - // The hostname the rule will be applied to. - Host string `json:"host"` - // Whether the rule includes or excludes traffic from being measured. - Inclusive bool `json:"inclusive"` - // Whether the rule is paused or not. - IsPaused bool `json:"is_paused"` - // The paths the rule will be applied to. - Paths []string `json:"paths"` - Priority float64 `json:"priority"` - JSON rumSiteInfoUpdateResponseRuleJSON `json:"-"` -} - -// rumSiteInfoUpdateResponseRuleJSON contains the JSON metadata for the struct -// [RUMSiteInfoUpdateResponseRule] -type rumSiteInfoUpdateResponseRuleJSON struct { - ID apijson.Field - Created apijson.Field - Host apijson.Field - Inclusive apijson.Field - IsPaused apijson.Field - Paths apijson.Field - Priority apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMSiteInfoUpdateResponseRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumSiteInfoUpdateResponseRuleJSON) RawJSON() string { - return r.raw -} - -type RUMSiteInfoUpdateResponseRuleset struct { - // The Web Analytics ruleset identifier. - ID string `json:"id"` - // Whether the ruleset is enabled. - Enabled bool `json:"enabled"` - ZoneName string `json:"zone_name"` - // The zone identifier. - ZoneTag string `json:"zone_tag"` - JSON rumSiteInfoUpdateResponseRulesetJSON `json:"-"` -} - -// rumSiteInfoUpdateResponseRulesetJSON contains the JSON metadata for the struct -// [RUMSiteInfoUpdateResponseRuleset] -type rumSiteInfoUpdateResponseRulesetJSON struct { - ID apijson.Field - Enabled apijson.Field - ZoneName apijson.Field - ZoneTag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMSiteInfoUpdateResponseRuleset) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumSiteInfoUpdateResponseRulesetJSON) RawJSON() string { - return r.raw -} - -type RUMSiteInfoListResponse struct { - // If enabled, the JavaScript snippet is automatically injected for orange-clouded - // sites. - AutoInstall bool `json:"auto_install"` - Created time.Time `json:"created" format:"date-time"` - // A list of rules. - Rules []RUMSiteInfoListResponseRule `json:"rules"` - Ruleset RUMSiteInfoListResponseRuleset `json:"ruleset"` - // The Web Analytics site identifier. - SiteTag string `json:"site_tag"` - // The Web Analytics site token. - SiteToken string `json:"site_token"` - // Encoded JavaScript snippet. - Snippet string `json:"snippet"` - JSON rumSiteInfoListResponseJSON `json:"-"` -} - -// rumSiteInfoListResponseJSON contains the JSON metadata for the struct -// [RUMSiteInfoListResponse] -type rumSiteInfoListResponseJSON struct { - AutoInstall apijson.Field - Created apijson.Field - Rules apijson.Field - Ruleset apijson.Field - SiteTag apijson.Field - SiteToken apijson.Field - Snippet apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMSiteInfoListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumSiteInfoListResponseJSON) RawJSON() string { - return r.raw -} - -type RUMSiteInfoListResponseRule struct { - // The Web Analytics rule identifier. - ID string `json:"id"` - Created time.Time `json:"created" format:"date-time"` - // The hostname the rule will be applied to. - Host string `json:"host"` - // Whether the rule includes or excludes traffic from being measured. - Inclusive bool `json:"inclusive"` - // Whether the rule is paused or not. - IsPaused bool `json:"is_paused"` - // The paths the rule will be applied to. - Paths []string `json:"paths"` - Priority float64 `json:"priority"` - JSON rumSiteInfoListResponseRuleJSON `json:"-"` -} - -// rumSiteInfoListResponseRuleJSON contains the JSON metadata for the struct -// [RUMSiteInfoListResponseRule] -type rumSiteInfoListResponseRuleJSON struct { - ID apijson.Field - Created apijson.Field - Host apijson.Field - Inclusive apijson.Field - IsPaused apijson.Field - Paths apijson.Field - Priority apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMSiteInfoListResponseRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumSiteInfoListResponseRuleJSON) RawJSON() string { - return r.raw -} - -type RUMSiteInfoListResponseRuleset struct { - // The Web Analytics ruleset identifier. - ID string `json:"id"` - // Whether the ruleset is enabled. - Enabled bool `json:"enabled"` - ZoneName string `json:"zone_name"` - // The zone identifier. - ZoneTag string `json:"zone_tag"` - JSON rumSiteInfoListResponseRulesetJSON `json:"-"` -} - -// rumSiteInfoListResponseRulesetJSON contains the JSON metadata for the struct -// [RUMSiteInfoListResponseRuleset] -type rumSiteInfoListResponseRulesetJSON struct { - ID apijson.Field - Enabled apijson.Field - ZoneName apijson.Field - ZoneTag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMSiteInfoListResponseRuleset) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumSiteInfoListResponseRulesetJSON) RawJSON() string { - return r.raw -} - -type RUMSiteInfoDeleteResponse struct { - // The Web Analytics site identifier. - SiteTag string `json:"site_tag"` - JSON rumSiteInfoDeleteResponseJSON `json:"-"` -} - -// rumSiteInfoDeleteResponseJSON contains the JSON metadata for the struct -// [RUMSiteInfoDeleteResponse] -type rumSiteInfoDeleteResponseJSON struct { - SiteTag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMSiteInfoDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumSiteInfoDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type RUMSiteInfoGetResponse struct { - // If enabled, the JavaScript snippet is automatically injected for orange-clouded - // sites. - AutoInstall bool `json:"auto_install"` - Created time.Time `json:"created" format:"date-time"` - // A list of rules. - Rules []RUMSiteInfoGetResponseRule `json:"rules"` - Ruleset RUMSiteInfoGetResponseRuleset `json:"ruleset"` - // The Web Analytics site identifier. - SiteTag string `json:"site_tag"` - // The Web Analytics site token. - SiteToken string `json:"site_token"` - // Encoded JavaScript snippet. - Snippet string `json:"snippet"` - JSON rumSiteInfoGetResponseJSON `json:"-"` -} - -// rumSiteInfoGetResponseJSON contains the JSON metadata for the struct -// [RUMSiteInfoGetResponse] -type rumSiteInfoGetResponseJSON struct { - AutoInstall apijson.Field - Created apijson.Field - Rules apijson.Field - Ruleset apijson.Field - SiteTag apijson.Field - SiteToken apijson.Field - Snippet apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMSiteInfoGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumSiteInfoGetResponseJSON) RawJSON() string { - return r.raw -} - -type RUMSiteInfoGetResponseRule struct { - // The Web Analytics rule identifier. - ID string `json:"id"` - Created time.Time `json:"created" format:"date-time"` - // The hostname the rule will be applied to. - Host string `json:"host"` - // Whether the rule includes or excludes traffic from being measured. - Inclusive bool `json:"inclusive"` - // Whether the rule is paused or not. - IsPaused bool `json:"is_paused"` - // The paths the rule will be applied to. - Paths []string `json:"paths"` - Priority float64 `json:"priority"` - JSON rumSiteInfoGetResponseRuleJSON `json:"-"` -} - -// rumSiteInfoGetResponseRuleJSON contains the JSON metadata for the struct -// [RUMSiteInfoGetResponseRule] -type rumSiteInfoGetResponseRuleJSON struct { - ID apijson.Field - Created apijson.Field - Host apijson.Field - Inclusive apijson.Field - IsPaused apijson.Field - Paths apijson.Field - Priority apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMSiteInfoGetResponseRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumSiteInfoGetResponseRuleJSON) RawJSON() string { - return r.raw -} - -type RUMSiteInfoGetResponseRuleset struct { - // The Web Analytics ruleset identifier. - ID string `json:"id"` - // Whether the ruleset is enabled. - Enabled bool `json:"enabled"` - ZoneName string `json:"zone_name"` - // The zone identifier. - ZoneTag string `json:"zone_tag"` - JSON rumSiteInfoGetResponseRulesetJSON `json:"-"` -} - -// rumSiteInfoGetResponseRulesetJSON contains the JSON metadata for the struct -// [RUMSiteInfoGetResponseRuleset] -type rumSiteInfoGetResponseRulesetJSON struct { - ID apijson.Field - Enabled apijson.Field - ZoneName apijson.Field - ZoneTag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMSiteInfoGetResponseRuleset) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumSiteInfoGetResponseRulesetJSON) RawJSON() string { - return r.raw -} - -type RUMSiteInfoNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // If enabled, the JavaScript snippet is automatically injected for orange-clouded - // sites. - AutoInstall param.Field[bool] `json:"auto_install"` - // The hostname to use for gray-clouded sites. - Host param.Field[string] `json:"host"` - // The zone identifier. - ZoneTag param.Field[string] `json:"zone_tag"` -} - -func (r RUMSiteInfoNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RUMSiteInfoNewResponseEnvelope struct { - Result RUMSiteInfoNewResponse `json:"result"` - JSON rumSiteInfoNewResponseEnvelopeJSON `json:"-"` -} - -// rumSiteInfoNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [RUMSiteInfoNewResponseEnvelope] -type rumSiteInfoNewResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMSiteInfoNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumSiteInfoNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RUMSiteInfoUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // If enabled, the JavaScript snippet is automatically injected for orange-clouded - // sites. - AutoInstall param.Field[bool] `json:"auto_install"` - // The hostname to use for gray-clouded sites. - Host param.Field[string] `json:"host"` - // The zone identifier. - ZoneTag param.Field[string] `json:"zone_tag"` -} - -func (r RUMSiteInfoUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RUMSiteInfoUpdateResponseEnvelope struct { - Result RUMSiteInfoUpdateResponse `json:"result"` - JSON rumSiteInfoUpdateResponseEnvelopeJSON `json:"-"` -} - -// rumSiteInfoUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [RUMSiteInfoUpdateResponseEnvelope] -type rumSiteInfoUpdateResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMSiteInfoUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumSiteInfoUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RUMSiteInfoListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The property used to sort the list of results. - OrderBy param.Field[RUMSiteInfoListParamsOrderBy] `query:"order_by"` - // Current page within the paginated list of results. - Page param.Field[float64] `query:"page"` - // Number of items to return per page of results. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [RUMSiteInfoListParams]'s query parameters as `url.Values`. -func (r RUMSiteInfoListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// The property used to sort the list of results. -type RUMSiteInfoListParamsOrderBy string - -const ( - RUMSiteInfoListParamsOrderByHost RUMSiteInfoListParamsOrderBy = "host" - RUMSiteInfoListParamsOrderByCreated RUMSiteInfoListParamsOrderBy = "created" -) - -type RUMSiteInfoDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type RUMSiteInfoDeleteResponseEnvelope struct { - Result RUMSiteInfoDeleteResponse `json:"result"` - JSON rumSiteInfoDeleteResponseEnvelopeJSON `json:"-"` -} - -// rumSiteInfoDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [RUMSiteInfoDeleteResponseEnvelope] -type rumSiteInfoDeleteResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMSiteInfoDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumSiteInfoDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type RUMSiteInfoGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type RUMSiteInfoGetResponseEnvelope struct { - Result RUMSiteInfoGetResponse `json:"result"` - JSON rumSiteInfoGetResponseEnvelopeJSON `json:"-"` -} - -// rumSiteInfoGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [RUMSiteInfoGetResponseEnvelope] -type rumSiteInfoGetResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RUMSiteInfoGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r rumSiteInfoGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/rumsiteinfo_test.go b/rumsiteinfo_test.go deleted file mode 100644 index 29c013c97c7..00000000000 --- a/rumsiteinfo_test.go +++ /dev/null @@ -1,165 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestRUMSiteInfoNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.RUM.SiteInfos.New(context.TODO(), cloudflare.RUMSiteInfoNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - AutoInstall: cloudflare.F(true), - Host: cloudflare.F("example.com"), - ZoneTag: cloudflare.F("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()) - } -} - -func TestRUMSiteInfoUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.RUM.SiteInfos.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.RUMSiteInfoUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - AutoInstall: cloudflare.F(true), - Host: cloudflare.F("example.com"), - ZoneTag: cloudflare.F("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()) - } -} - -func TestRUMSiteInfoListWithOptionalParams(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("user@example.com"), - ) - _, err := client.RUM.SiteInfos.List(context.TODO(), cloudflare.RUMSiteInfoListParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - OrderBy: cloudflare.F(cloudflare.RUMSiteInfoListParamsOrderByHost), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(10.000000), - }) - 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 TestRUMSiteInfoDelete(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("user@example.com"), - ) - _, err := client.RUM.SiteInfos.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.RUMSiteInfoDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestRUMSiteInfoGet(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("user@example.com"), - ) - _, err := client.RUM.SiteInfos.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.RUMSiteInfoGetParams{ - AccountID: cloudflare.F("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/secondary_dns/acl.go b/secondary_dns/acl.go new file mode 100644 index 00000000000..fe3420b89a6 --- /dev/null +++ b/secondary_dns/acl.go @@ -0,0 +1,622 @@ +// File generated from our OpenAPI spec by Stainless. + +package secondary_dns + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ACLService 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 [NewACLService] method instead. +type ACLService struct { + Options []option.RequestOption +} + +// NewACLService 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 NewACLService(opts ...option.RequestOption) (r *ACLService) { + r = &ACLService{} + r.Options = opts + return +} + +// Create ACL. +func (r *ACLService) New(ctx context.Context, params ACLNewParams, opts ...option.RequestOption) (res *SecondaryDNSACL, err error) { + opts = append(r.Options[:], opts...) + var env ACLNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/secondary_dns/acls", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Modify ACL. +func (r *ACLService) Update(ctx context.Context, aclID interface{}, params ACLUpdateParams, opts ...option.RequestOption) (res *SecondaryDNSACL, err error) { + opts = append(r.Options[:], opts...) + var env ACLUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/secondary_dns/acls/%v", params.AccountID, aclID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List ACLs. +func (r *ACLService) List(ctx context.Context, query ACLListParams, opts ...option.RequestOption) (res *[]SecondaryDNSACL, err error) { + opts = append(r.Options[:], opts...) + var env ACLListResponseEnvelope + path := fmt.Sprintf("accounts/%v/secondary_dns/acls", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete ACL. +func (r *ACLService) Delete(ctx context.Context, aclID interface{}, body ACLDeleteParams, opts ...option.RequestOption) (res *ACLDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env ACLDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%v/secondary_dns/acls/%v", body.AccountID, aclID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get ACL. +func (r *ACLService) Get(ctx context.Context, aclID interface{}, query ACLGetParams, opts ...option.RequestOption) (res *SecondaryDNSACL, err error) { + opts = append(r.Options[:], opts...) + var env ACLGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/secondary_dns/acls/%v", query.AccountID, aclID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type SecondaryDNSACL struct { + ID interface{} `json:"id,required"` + // Allowed IPv4/IPv6 address range of primary or secondary nameservers. This will + // be applied for the entire account. The IP range is used to allow additional + // NOTIFY IPs for secondary zones and IPs Cloudflare allows AXFR/IXFR requests from + // for primary zones. CIDRs are limited to a maximum of /24 for IPv4 and /64 for + // IPv6 respectively. + IPRange string `json:"ip_range,required"` + // The name of the acl. + Name string `json:"name,required"` + JSON secondaryDnsaclJSON `json:"-"` +} + +// secondaryDnsaclJSON contains the JSON metadata for the struct [SecondaryDNSACL] +type secondaryDnsaclJSON struct { + ID apijson.Field + IPRange apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SecondaryDNSACL) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r secondaryDnsaclJSON) RawJSON() string { + return r.raw +} + +type ACLDeleteResponse struct { + ID interface{} `json:"id"` + JSON aclDeleteResponseJSON `json:"-"` +} + +// aclDeleteResponseJSON contains the JSON metadata for the struct +// [ACLDeleteResponse] +type aclDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ACLDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aclDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type ACLNewParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + Body param.Field[interface{}] `json:"body,required"` +} + +func (r ACLNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type ACLNewResponseEnvelope struct { + Errors []ACLNewResponseEnvelopeErrors `json:"errors,required"` + Messages []ACLNewResponseEnvelopeMessages `json:"messages,required"` + Result SecondaryDNSACL `json:"result,required"` + // Whether the API call was successful + Success ACLNewResponseEnvelopeSuccess `json:"success,required"` + JSON aclNewResponseEnvelopeJSON `json:"-"` +} + +// aclNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [ACLNewResponseEnvelope] +type aclNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ACLNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aclNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ACLNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON aclNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// aclNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ACLNewResponseEnvelopeErrors] +type aclNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ACLNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aclNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ACLNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON aclNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// aclNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ACLNewResponseEnvelopeMessages] +type aclNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ACLNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aclNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ACLNewResponseEnvelopeSuccess bool + +const ( + ACLNewResponseEnvelopeSuccessTrue ACLNewResponseEnvelopeSuccess = true +) + +type ACLUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // Allowed IPv4/IPv6 address range of primary or secondary nameservers. This will + // be applied for the entire account. The IP range is used to allow additional + // NOTIFY IPs for secondary zones and IPs Cloudflare allows AXFR/IXFR requests from + // for primary zones. CIDRs are limited to a maximum of /24 for IPv4 and /64 for + // IPv6 respectively. + IPRange param.Field[string] `json:"ip_range,required"` + // The name of the acl. + Name param.Field[string] `json:"name,required"` +} + +func (r ACLUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ACLUpdateResponseEnvelope struct { + Errors []ACLUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []ACLUpdateResponseEnvelopeMessages `json:"messages,required"` + Result SecondaryDNSACL `json:"result,required"` + // Whether the API call was successful + Success ACLUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON aclUpdateResponseEnvelopeJSON `json:"-"` +} + +// aclUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [ACLUpdateResponseEnvelope] +type aclUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ACLUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aclUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ACLUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON aclUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// aclUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ACLUpdateResponseEnvelopeErrors] +type aclUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ACLUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aclUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ACLUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON aclUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// aclUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ACLUpdateResponseEnvelopeMessages] +type aclUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ACLUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aclUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ACLUpdateResponseEnvelopeSuccess bool + +const ( + ACLUpdateResponseEnvelopeSuccessTrue ACLUpdateResponseEnvelopeSuccess = true +) + +type ACLListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type ACLListResponseEnvelope struct { + Errors []ACLListResponseEnvelopeErrors `json:"errors,required"` + Messages []ACLListResponseEnvelopeMessages `json:"messages,required"` + Result []SecondaryDNSACL `json:"result,required,nullable"` + // Whether the API call was successful + Success ACLListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo ACLListResponseEnvelopeResultInfo `json:"result_info"` + JSON aclListResponseEnvelopeJSON `json:"-"` +} + +// aclListResponseEnvelopeJSON contains the JSON metadata for the struct +// [ACLListResponseEnvelope] +type aclListResponseEnvelopeJSON 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 *ACLListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aclListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ACLListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON aclListResponseEnvelopeErrorsJSON `json:"-"` +} + +// aclListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ACLListResponseEnvelopeErrors] +type aclListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ACLListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aclListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ACLListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON aclListResponseEnvelopeMessagesJSON `json:"-"` +} + +// aclListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ACLListResponseEnvelopeMessages] +type aclListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ACLListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aclListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ACLListResponseEnvelopeSuccess bool + +const ( + ACLListResponseEnvelopeSuccessTrue ACLListResponseEnvelopeSuccess = true +) + +type ACLListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON aclListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// aclListResponseEnvelopeResultInfoJSON contains the JSON metadata for the struct +// [ACLListResponseEnvelopeResultInfo] +type aclListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ACLListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aclListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type ACLDeleteParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type ACLDeleteResponseEnvelope struct { + Errors []ACLDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []ACLDeleteResponseEnvelopeMessages `json:"messages,required"` + Result ACLDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success ACLDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON aclDeleteResponseEnvelopeJSON `json:"-"` +} + +// aclDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [ACLDeleteResponseEnvelope] +type aclDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ACLDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aclDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ACLDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON aclDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// aclDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ACLDeleteResponseEnvelopeErrors] +type aclDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ACLDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aclDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ACLDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON aclDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// aclDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ACLDeleteResponseEnvelopeMessages] +type aclDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ACLDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aclDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ACLDeleteResponseEnvelopeSuccess bool + +const ( + ACLDeleteResponseEnvelopeSuccessTrue ACLDeleteResponseEnvelopeSuccess = true +) + +type ACLGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type ACLGetResponseEnvelope struct { + Errors []ACLGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ACLGetResponseEnvelopeMessages `json:"messages,required"` + Result SecondaryDNSACL `json:"result,required"` + // Whether the API call was successful + Success ACLGetResponseEnvelopeSuccess `json:"success,required"` + JSON aclGetResponseEnvelopeJSON `json:"-"` +} + +// aclGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [ACLGetResponseEnvelope] +type aclGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ACLGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aclGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ACLGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON aclGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// aclGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ACLGetResponseEnvelopeErrors] +type aclGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ACLGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aclGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ACLGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON aclGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// aclGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ACLGetResponseEnvelopeMessages] +type aclGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ACLGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aclGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ACLGetResponseEnvelopeSuccess bool + +const ( + ACLGetResponseEnvelopeSuccessTrue ACLGetResponseEnvelopeSuccess = true +) diff --git a/secondary_dns/acl_test.go b/secondary_dns/acl_test.go new file mode 100644 index 00000000000..ed5cb3485f5 --- /dev/null +++ b/secondary_dns/acl_test.go @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package secondary_dns_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/secondary_dns" +) + +func TestACLNew(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("user@example.com"), + ) + _, err := client.SecondaryDNS.ACLs.New(context.TODO(), secondary_dns.ACLNewParams{ + AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), + Body: cloudflare.F[any](map[string]interface{}{}), + }) + 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 TestACLUpdate(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("user@example.com"), + ) + _, err := client.SecondaryDNS.ACLs.Update( + context.TODO(), + "23ff594956f20c2a721606e94745a8aa", + secondary_dns.ACLUpdateParams{ + AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), + IPRange: cloudflare.F("192.0.2.53/28"), + Name: cloudflare.F("my-acl-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 TestACLList(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("user@example.com"), + ) + _, err := client.SecondaryDNS.ACLs.List(context.TODO(), secondary_dns.ACLListParams{ + AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), + }) + 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 TestACLDelete(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("user@example.com"), + ) + _, err := client.SecondaryDNS.ACLs.Delete( + context.TODO(), + "23ff594956f20c2a721606e94745a8aa", + secondary_dns.ACLDeleteParams{ + AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), + }, + ) + 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 TestACLGet(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("user@example.com"), + ) + _, err := client.SecondaryDNS.ACLs.Get( + context.TODO(), + "23ff594956f20c2a721606e94745a8aa", + secondary_dns.ACLGetParams{ + AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), + }, + ) + 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/secondary_dns/aliases.go b/secondary_dns/aliases.go new file mode 100644 index 00000000000..2b90c548da4 --- /dev/null +++ b/secondary_dns/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package secondary_dns + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/secondary_dns/forceaxfr.go b/secondary_dns/forceaxfr.go new file mode 100644 index 00000000000..983670ff3c3 --- /dev/null +++ b/secondary_dns/forceaxfr.go @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. + +package secondary_dns + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ForceAxfrService 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 [NewForceAxfrService] method instead. +type ForceAxfrService struct { + Options []option.RequestOption +} + +// NewForceAxfrService 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 NewForceAxfrService(opts ...option.RequestOption) (r *ForceAxfrService) { + r = &ForceAxfrService{} + r.Options = opts + return +} + +// Sends AXFR zone transfer request to primary nameserver(s). +func (r *ForceAxfrService) New(ctx context.Context, body ForceAxfrNewParams, opts ...option.RequestOption) (res *SecondaryDNSForceResult, err error) { + opts = append(r.Options[:], opts...) + var env ForceAxfrNewResponseEnvelope + path := fmt.Sprintf("zones/%v/secondary_dns/force_axfr", body.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type SecondaryDNSForceResult = string + +type ForceAxfrNewParams struct { + ZoneID param.Field[interface{}] `path:"zone_id,required"` +} + +type ForceAxfrNewResponseEnvelope struct { + Errors []ForceAxfrNewResponseEnvelopeErrors `json:"errors,required"` + Messages []ForceAxfrNewResponseEnvelopeMessages `json:"messages,required"` + // When force_axfr query parameter is set to true, the response is a simple string + Result SecondaryDNSForceResult `json:"result,required"` + // Whether the API call was successful + Success ForceAxfrNewResponseEnvelopeSuccess `json:"success,required"` + JSON forceAxfrNewResponseEnvelopeJSON `json:"-"` +} + +// forceAxfrNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [ForceAxfrNewResponseEnvelope] +type forceAxfrNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ForceAxfrNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r forceAxfrNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ForceAxfrNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON forceAxfrNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// forceAxfrNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ForceAxfrNewResponseEnvelopeErrors] +type forceAxfrNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ForceAxfrNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r forceAxfrNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ForceAxfrNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON forceAxfrNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// forceAxfrNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ForceAxfrNewResponseEnvelopeMessages] +type forceAxfrNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ForceAxfrNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r forceAxfrNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ForceAxfrNewResponseEnvelopeSuccess bool + +const ( + ForceAxfrNewResponseEnvelopeSuccessTrue ForceAxfrNewResponseEnvelopeSuccess = true +) diff --git a/secondary_dns/forceaxfr_test.go b/secondary_dns/forceaxfr_test.go new file mode 100644 index 00000000000..5c41b076f9b --- /dev/null +++ b/secondary_dns/forceaxfr_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package secondary_dns_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/secondary_dns" +) + +func TestForceAxfrNew(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("user@example.com"), + ) + _, err := client.SecondaryDNS.ForceAxfrs.New(context.TODO(), secondary_dns.ForceAxfrNewParams{ + ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), + }) + 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/secondary_dns/incoming.go b/secondary_dns/incoming.go new file mode 100644 index 00000000000..d46e00ff7db --- /dev/null +++ b/secondary_dns/incoming.go @@ -0,0 +1,595 @@ +// File generated from our OpenAPI spec by Stainless. + +package secondary_dns + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// IncomingService 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 [NewIncomingService] method instead. +type IncomingService struct { + Options []option.RequestOption +} + +// NewIncomingService 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 NewIncomingService(opts ...option.RequestOption) (r *IncomingService) { + r = &IncomingService{} + r.Options = opts + return +} + +// Create secondary zone configuration for incoming zone transfers. +func (r *IncomingService) New(ctx context.Context, params IncomingNewParams, opts ...option.RequestOption) (res *IncomingNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env IncomingNewResponseEnvelope + path := fmt.Sprintf("zones/%v/secondary_dns/incoming", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update secondary zone configuration for incoming zone transfers. +func (r *IncomingService) Update(ctx context.Context, params IncomingUpdateParams, opts ...option.RequestOption) (res *IncomingUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env IncomingUpdateResponseEnvelope + path := fmt.Sprintf("zones/%v/secondary_dns/incoming", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete secondary zone configuration for incoming zone transfers. +func (r *IncomingService) Delete(ctx context.Context, body IncomingDeleteParams, opts ...option.RequestOption) (res *IncomingDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env IncomingDeleteResponseEnvelope + path := fmt.Sprintf("zones/%v/secondary_dns/incoming", body.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get secondary zone configuration for incoming zone transfers. +func (r *IncomingService) Get(ctx context.Context, query IncomingGetParams, opts ...option.RequestOption) (res *IncomingGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env IncomingGetResponseEnvelope + path := fmt.Sprintf("zones/%v/secondary_dns/incoming", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type IncomingNewResponse struct { + ID interface{} `json:"id"` + // How often should a secondary zone auto refresh regardless of DNS NOTIFY. Not + // applicable for primary zones. + AutoRefreshSeconds float64 `json:"auto_refresh_seconds"` + // The time for a specific event. + CheckedTime string `json:"checked_time"` + // The time for a specific event. + CreatedTime string `json:"created_time"` + // The time for a specific event. + ModifiedTime string `json:"modified_time"` + // Zone name. + Name string `json:"name"` + // A list of peer tags. + Peers []interface{} `json:"peers"` + // The serial number of the SOA for the given zone. + SoaSerial float64 `json:"soa_serial"` + JSON incomingNewResponseJSON `json:"-"` +} + +// incomingNewResponseJSON contains the JSON metadata for the struct +// [IncomingNewResponse] +type incomingNewResponseJSON struct { + ID apijson.Field + AutoRefreshSeconds apijson.Field + CheckedTime apijson.Field + CreatedTime apijson.Field + ModifiedTime apijson.Field + Name apijson.Field + Peers apijson.Field + SoaSerial apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IncomingNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r incomingNewResponseJSON) RawJSON() string { + return r.raw +} + +type IncomingUpdateResponse struct { + ID interface{} `json:"id"` + // How often should a secondary zone auto refresh regardless of DNS NOTIFY. Not + // applicable for primary zones. + AutoRefreshSeconds float64 `json:"auto_refresh_seconds"` + // The time for a specific event. + CheckedTime string `json:"checked_time"` + // The time for a specific event. + CreatedTime string `json:"created_time"` + // The time for a specific event. + ModifiedTime string `json:"modified_time"` + // Zone name. + Name string `json:"name"` + // A list of peer tags. + Peers []interface{} `json:"peers"` + // The serial number of the SOA for the given zone. + SoaSerial float64 `json:"soa_serial"` + JSON incomingUpdateResponseJSON `json:"-"` +} + +// incomingUpdateResponseJSON contains the JSON metadata for the struct +// [IncomingUpdateResponse] +type incomingUpdateResponseJSON struct { + ID apijson.Field + AutoRefreshSeconds apijson.Field + CheckedTime apijson.Field + CreatedTime apijson.Field + ModifiedTime apijson.Field + Name apijson.Field + Peers apijson.Field + SoaSerial apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IncomingUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r incomingUpdateResponseJSON) RawJSON() string { + return r.raw +} + +type IncomingDeleteResponse struct { + ID interface{} `json:"id"` + JSON incomingDeleteResponseJSON `json:"-"` +} + +// incomingDeleteResponseJSON contains the JSON metadata for the struct +// [IncomingDeleteResponse] +type incomingDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IncomingDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r incomingDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type IncomingGetResponse struct { + ID interface{} `json:"id"` + // How often should a secondary zone auto refresh regardless of DNS NOTIFY. Not + // applicable for primary zones. + AutoRefreshSeconds float64 `json:"auto_refresh_seconds"` + // The time for a specific event. + CheckedTime string `json:"checked_time"` + // The time for a specific event. + CreatedTime string `json:"created_time"` + // The time for a specific event. + ModifiedTime string `json:"modified_time"` + // Zone name. + Name string `json:"name"` + // A list of peer tags. + Peers []interface{} `json:"peers"` + // The serial number of the SOA for the given zone. + SoaSerial float64 `json:"soa_serial"` + JSON incomingGetResponseJSON `json:"-"` +} + +// incomingGetResponseJSON contains the JSON metadata for the struct +// [IncomingGetResponse] +type incomingGetResponseJSON struct { + ID apijson.Field + AutoRefreshSeconds apijson.Field + CheckedTime apijson.Field + CreatedTime apijson.Field + ModifiedTime apijson.Field + Name apijson.Field + Peers apijson.Field + SoaSerial apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IncomingGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r incomingGetResponseJSON) RawJSON() string { + return r.raw +} + +type IncomingNewParams struct { + ZoneID param.Field[interface{}] `path:"zone_id,required"` + // How often should a secondary zone auto refresh regardless of DNS NOTIFY. Not + // applicable for primary zones. + AutoRefreshSeconds param.Field[float64] `json:"auto_refresh_seconds,required"` + // Zone name. + Name param.Field[string] `json:"name,required"` + // A list of peer tags. + Peers param.Field[[]interface{}] `json:"peers,required"` +} + +func (r IncomingNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IncomingNewResponseEnvelope struct { + Errors []IncomingNewResponseEnvelopeErrors `json:"errors,required"` + Messages []IncomingNewResponseEnvelopeMessages `json:"messages,required"` + Result IncomingNewResponse `json:"result,required"` + // Whether the API call was successful + Success IncomingNewResponseEnvelopeSuccess `json:"success,required"` + JSON incomingNewResponseEnvelopeJSON `json:"-"` +} + +// incomingNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [IncomingNewResponseEnvelope] +type incomingNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IncomingNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r incomingNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IncomingNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON incomingNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// incomingNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [IncomingNewResponseEnvelopeErrors] +type incomingNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IncomingNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r incomingNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IncomingNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON incomingNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// incomingNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [IncomingNewResponseEnvelopeMessages] +type incomingNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IncomingNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r incomingNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IncomingNewResponseEnvelopeSuccess bool + +const ( + IncomingNewResponseEnvelopeSuccessTrue IncomingNewResponseEnvelopeSuccess = true +) + +type IncomingUpdateParams struct { + ZoneID param.Field[interface{}] `path:"zone_id,required"` + // How often should a secondary zone auto refresh regardless of DNS NOTIFY. Not + // applicable for primary zones. + AutoRefreshSeconds param.Field[float64] `json:"auto_refresh_seconds,required"` + // Zone name. + Name param.Field[string] `json:"name,required"` + // A list of peer tags. + Peers param.Field[[]interface{}] `json:"peers,required"` +} + +func (r IncomingUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IncomingUpdateResponseEnvelope struct { + Errors []IncomingUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []IncomingUpdateResponseEnvelopeMessages `json:"messages,required"` + Result IncomingUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success IncomingUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON incomingUpdateResponseEnvelopeJSON `json:"-"` +} + +// incomingUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [IncomingUpdateResponseEnvelope] +type incomingUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IncomingUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r incomingUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IncomingUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON incomingUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// incomingUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [IncomingUpdateResponseEnvelopeErrors] +type incomingUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IncomingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r incomingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IncomingUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON incomingUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// incomingUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [IncomingUpdateResponseEnvelopeMessages] +type incomingUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IncomingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r incomingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IncomingUpdateResponseEnvelopeSuccess bool + +const ( + IncomingUpdateResponseEnvelopeSuccessTrue IncomingUpdateResponseEnvelopeSuccess = true +) + +type IncomingDeleteParams struct { + ZoneID param.Field[interface{}] `path:"zone_id,required"` +} + +type IncomingDeleteResponseEnvelope struct { + Errors []IncomingDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []IncomingDeleteResponseEnvelopeMessages `json:"messages,required"` + Result IncomingDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success IncomingDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON incomingDeleteResponseEnvelopeJSON `json:"-"` +} + +// incomingDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [IncomingDeleteResponseEnvelope] +type incomingDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IncomingDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r incomingDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IncomingDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON incomingDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// incomingDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [IncomingDeleteResponseEnvelopeErrors] +type incomingDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IncomingDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r incomingDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IncomingDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON incomingDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// incomingDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [IncomingDeleteResponseEnvelopeMessages] +type incomingDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IncomingDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r incomingDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IncomingDeleteResponseEnvelopeSuccess bool + +const ( + IncomingDeleteResponseEnvelopeSuccessTrue IncomingDeleteResponseEnvelopeSuccess = true +) + +type IncomingGetParams struct { + ZoneID param.Field[interface{}] `path:"zone_id,required"` +} + +type IncomingGetResponseEnvelope struct { + Errors []IncomingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []IncomingGetResponseEnvelopeMessages `json:"messages,required"` + Result IncomingGetResponse `json:"result,required"` + // Whether the API call was successful + Success IncomingGetResponseEnvelopeSuccess `json:"success,required"` + JSON incomingGetResponseEnvelopeJSON `json:"-"` +} + +// incomingGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [IncomingGetResponseEnvelope] +type incomingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IncomingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r incomingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IncomingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON incomingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// incomingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [IncomingGetResponseEnvelopeErrors] +type incomingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IncomingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r incomingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IncomingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON incomingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// incomingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [IncomingGetResponseEnvelopeMessages] +type incomingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IncomingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r incomingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IncomingGetResponseEnvelopeSuccess bool + +const ( + IncomingGetResponseEnvelopeSuccessTrue IncomingGetResponseEnvelopeSuccess = true +) diff --git a/secondary_dns/incoming_test.go b/secondary_dns/incoming_test.go new file mode 100644 index 00000000000..a8b80f28066 --- /dev/null +++ b/secondary_dns/incoming_test.go @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. + +package secondary_dns_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/secondary_dns" +) + +func TestIncomingNew(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("user@example.com"), + ) + _, err := client.SecondaryDNS.Incoming.New(context.TODO(), secondary_dns.IncomingNewParams{ + ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), + AutoRefreshSeconds: cloudflare.F(86400.000000), + Name: cloudflare.F("www.example.com."), + Peers: cloudflare.F([]interface{}{"23ff594956f20c2a721606e94745a8aa", "00920f38ce07c2e2f4df50b1f61d4194"}), + }) + 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 TestIncomingUpdate(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("user@example.com"), + ) + _, err := client.SecondaryDNS.Incoming.Update(context.TODO(), secondary_dns.IncomingUpdateParams{ + ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), + AutoRefreshSeconds: cloudflare.F(86400.000000), + Name: cloudflare.F("www.example.com."), + Peers: cloudflare.F([]interface{}{"23ff594956f20c2a721606e94745a8aa", "00920f38ce07c2e2f4df50b1f61d4194"}), + }) + 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 TestIncomingDelete(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("user@example.com"), + ) + _, err := client.SecondaryDNS.Incoming.Delete(context.TODO(), secondary_dns.IncomingDeleteParams{ + ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), + }) + 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 TestIncomingGet(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("user@example.com"), + ) + _, err := client.SecondaryDNS.Incoming.Get(context.TODO(), secondary_dns.IncomingGetParams{ + ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), + }) + 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/secondary_dns/outgoing.go b/secondary_dns/outgoing.go new file mode 100644 index 00000000000..84a835b6c8a --- /dev/null +++ b/secondary_dns/outgoing.go @@ -0,0 +1,884 @@ +// File generated from our OpenAPI spec by Stainless. + +package secondary_dns + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// OutgoingService 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 [NewOutgoingService] method instead. +type OutgoingService struct { + Options []option.RequestOption + Status *OutgoingStatusService +} + +// NewOutgoingService 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 NewOutgoingService(opts ...option.RequestOption) (r *OutgoingService) { + r = &OutgoingService{} + r.Options = opts + r.Status = NewOutgoingStatusService(opts...) + return +} + +// Create primary zone configuration for outgoing zone transfers. +func (r *OutgoingService) New(ctx context.Context, params OutgoingNewParams, opts ...option.RequestOption) (res *OutgoingNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env OutgoingNewResponseEnvelope + path := fmt.Sprintf("zones/%v/secondary_dns/outgoing", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update primary zone configuration for outgoing zone transfers. +func (r *OutgoingService) Update(ctx context.Context, params OutgoingUpdateParams, opts ...option.RequestOption) (res *OutgoingUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env OutgoingUpdateResponseEnvelope + path := fmt.Sprintf("zones/%v/secondary_dns/outgoing", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete primary zone configuration for outgoing zone transfers. +func (r *OutgoingService) Delete(ctx context.Context, body OutgoingDeleteParams, opts ...option.RequestOption) (res *OutgoingDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env OutgoingDeleteResponseEnvelope + path := fmt.Sprintf("zones/%v/secondary_dns/outgoing", body.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Disable outgoing zone transfers for primary zone and clears IXFR backlog of +// primary zone. +func (r *OutgoingService) Disable(ctx context.Context, body OutgoingDisableParams, opts ...option.RequestOption) (res *SecondaryDNSDisableTransferResult, err error) { + opts = append(r.Options[:], opts...) + var env OutgoingDisableResponseEnvelope + path := fmt.Sprintf("zones/%v/secondary_dns/outgoing/disable", body.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Enable outgoing zone transfers for primary zone. +func (r *OutgoingService) Enable(ctx context.Context, body OutgoingEnableParams, opts ...option.RequestOption) (res *SecondaryDNSEnableTransferResult, err error) { + opts = append(r.Options[:], opts...) + var env OutgoingEnableResponseEnvelope + path := fmt.Sprintf("zones/%v/secondary_dns/outgoing/enable", body.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Notifies the secondary nameserver(s) and clears IXFR backlog of primary zone. +func (r *OutgoingService) ForceNotify(ctx context.Context, body OutgoingForceNotifyParams, opts ...option.RequestOption) (res *SecondaryDNSSchemasForceResult, err error) { + opts = append(r.Options[:], opts...) + var env OutgoingForceNotifyResponseEnvelope + path := fmt.Sprintf("zones/%v/secondary_dns/outgoing/force_notify", body.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get primary zone configuration for outgoing zone transfers. +func (r *OutgoingService) Get(ctx context.Context, query OutgoingGetParams, opts ...option.RequestOption) (res *OutgoingGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env OutgoingGetResponseEnvelope + path := fmt.Sprintf("zones/%v/secondary_dns/outgoing", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type SecondaryDNSDisableTransferResult = string + +type SecondaryDNSEnableTransferResult = string + +type SecondaryDNSSchemasForceResult = string + +type OutgoingNewResponse struct { + ID interface{} `json:"id"` + // The time for a specific event. + CheckedTime string `json:"checked_time"` + // The time for a specific event. + CreatedTime string `json:"created_time"` + // The time for a specific event. + LastTransferredTime string `json:"last_transferred_time"` + // Zone name. + Name string `json:"name"` + // A list of peer tags. + Peers []interface{} `json:"peers"` + // The serial number of the SOA for the given zone. + SoaSerial float64 `json:"soa_serial"` + JSON outgoingNewResponseJSON `json:"-"` +} + +// outgoingNewResponseJSON contains the JSON metadata for the struct +// [OutgoingNewResponse] +type outgoingNewResponseJSON struct { + ID apijson.Field + CheckedTime apijson.Field + CreatedTime apijson.Field + LastTransferredTime apijson.Field + Name apijson.Field + Peers apijson.Field + SoaSerial apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingNewResponseJSON) RawJSON() string { + return r.raw +} + +type OutgoingUpdateResponse struct { + ID interface{} `json:"id"` + // The time for a specific event. + CheckedTime string `json:"checked_time"` + // The time for a specific event. + CreatedTime string `json:"created_time"` + // The time for a specific event. + LastTransferredTime string `json:"last_transferred_time"` + // Zone name. + Name string `json:"name"` + // A list of peer tags. + Peers []interface{} `json:"peers"` + // The serial number of the SOA for the given zone. + SoaSerial float64 `json:"soa_serial"` + JSON outgoingUpdateResponseJSON `json:"-"` +} + +// outgoingUpdateResponseJSON contains the JSON metadata for the struct +// [OutgoingUpdateResponse] +type outgoingUpdateResponseJSON struct { + ID apijson.Field + CheckedTime apijson.Field + CreatedTime apijson.Field + LastTransferredTime apijson.Field + Name apijson.Field + Peers apijson.Field + SoaSerial apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingUpdateResponseJSON) RawJSON() string { + return r.raw +} + +type OutgoingDeleteResponse struct { + ID interface{} `json:"id"` + JSON outgoingDeleteResponseJSON `json:"-"` +} + +// outgoingDeleteResponseJSON contains the JSON metadata for the struct +// [OutgoingDeleteResponse] +type outgoingDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type OutgoingGetResponse struct { + ID interface{} `json:"id"` + // The time for a specific event. + CheckedTime string `json:"checked_time"` + // The time for a specific event. + CreatedTime string `json:"created_time"` + // The time for a specific event. + LastTransferredTime string `json:"last_transferred_time"` + // Zone name. + Name string `json:"name"` + // A list of peer tags. + Peers []interface{} `json:"peers"` + // The serial number of the SOA for the given zone. + SoaSerial float64 `json:"soa_serial"` + JSON outgoingGetResponseJSON `json:"-"` +} + +// outgoingGetResponseJSON contains the JSON metadata for the struct +// [OutgoingGetResponse] +type outgoingGetResponseJSON struct { + ID apijson.Field + CheckedTime apijson.Field + CreatedTime apijson.Field + LastTransferredTime apijson.Field + Name apijson.Field + Peers apijson.Field + SoaSerial apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingGetResponseJSON) RawJSON() string { + return r.raw +} + +type OutgoingNewParams struct { + ZoneID param.Field[interface{}] `path:"zone_id,required"` + // Zone name. + Name param.Field[string] `json:"name,required"` + // A list of peer tags. + Peers param.Field[[]interface{}] `json:"peers,required"` +} + +func (r OutgoingNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type OutgoingNewResponseEnvelope struct { + Errors []OutgoingNewResponseEnvelopeErrors `json:"errors,required"` + Messages []OutgoingNewResponseEnvelopeMessages `json:"messages,required"` + Result OutgoingNewResponse `json:"result,required"` + // Whether the API call was successful + Success OutgoingNewResponseEnvelopeSuccess `json:"success,required"` + JSON outgoingNewResponseEnvelopeJSON `json:"-"` +} + +// outgoingNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [OutgoingNewResponseEnvelope] +type outgoingNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type OutgoingNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON outgoingNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// outgoingNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [OutgoingNewResponseEnvelopeErrors] +type outgoingNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type OutgoingNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON outgoingNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// outgoingNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [OutgoingNewResponseEnvelopeMessages] +type outgoingNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type OutgoingNewResponseEnvelopeSuccess bool + +const ( + OutgoingNewResponseEnvelopeSuccessTrue OutgoingNewResponseEnvelopeSuccess = true +) + +type OutgoingUpdateParams struct { + ZoneID param.Field[interface{}] `path:"zone_id,required"` + // Zone name. + Name param.Field[string] `json:"name,required"` + // A list of peer tags. + Peers param.Field[[]interface{}] `json:"peers,required"` +} + +func (r OutgoingUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type OutgoingUpdateResponseEnvelope struct { + Errors []OutgoingUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []OutgoingUpdateResponseEnvelopeMessages `json:"messages,required"` + Result OutgoingUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success OutgoingUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON outgoingUpdateResponseEnvelopeJSON `json:"-"` +} + +// outgoingUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [OutgoingUpdateResponseEnvelope] +type outgoingUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type OutgoingUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON outgoingUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// outgoingUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [OutgoingUpdateResponseEnvelopeErrors] +type outgoingUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type OutgoingUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON outgoingUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// outgoingUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [OutgoingUpdateResponseEnvelopeMessages] +type outgoingUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type OutgoingUpdateResponseEnvelopeSuccess bool + +const ( + OutgoingUpdateResponseEnvelopeSuccessTrue OutgoingUpdateResponseEnvelopeSuccess = true +) + +type OutgoingDeleteParams struct { + ZoneID param.Field[interface{}] `path:"zone_id,required"` +} + +type OutgoingDeleteResponseEnvelope struct { + Errors []OutgoingDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []OutgoingDeleteResponseEnvelopeMessages `json:"messages,required"` + Result OutgoingDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success OutgoingDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON outgoingDeleteResponseEnvelopeJSON `json:"-"` +} + +// outgoingDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [OutgoingDeleteResponseEnvelope] +type outgoingDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type OutgoingDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON outgoingDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// outgoingDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [OutgoingDeleteResponseEnvelopeErrors] +type outgoingDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type OutgoingDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON outgoingDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// outgoingDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [OutgoingDeleteResponseEnvelopeMessages] +type outgoingDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type OutgoingDeleteResponseEnvelopeSuccess bool + +const ( + OutgoingDeleteResponseEnvelopeSuccessTrue OutgoingDeleteResponseEnvelopeSuccess = true +) + +type OutgoingDisableParams struct { + ZoneID param.Field[interface{}] `path:"zone_id,required"` +} + +type OutgoingDisableResponseEnvelope struct { + Errors []OutgoingDisableResponseEnvelopeErrors `json:"errors,required"` + Messages []OutgoingDisableResponseEnvelopeMessages `json:"messages,required"` + // The zone transfer status of a primary zone + Result SecondaryDNSDisableTransferResult `json:"result,required"` + // Whether the API call was successful + Success OutgoingDisableResponseEnvelopeSuccess `json:"success,required"` + JSON outgoingDisableResponseEnvelopeJSON `json:"-"` +} + +// outgoingDisableResponseEnvelopeJSON contains the JSON metadata for the struct +// [OutgoingDisableResponseEnvelope] +type outgoingDisableResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingDisableResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingDisableResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type OutgoingDisableResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON outgoingDisableResponseEnvelopeErrorsJSON `json:"-"` +} + +// outgoingDisableResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [OutgoingDisableResponseEnvelopeErrors] +type outgoingDisableResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingDisableResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingDisableResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type OutgoingDisableResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON outgoingDisableResponseEnvelopeMessagesJSON `json:"-"` +} + +// outgoingDisableResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [OutgoingDisableResponseEnvelopeMessages] +type outgoingDisableResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingDisableResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingDisableResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type OutgoingDisableResponseEnvelopeSuccess bool + +const ( + OutgoingDisableResponseEnvelopeSuccessTrue OutgoingDisableResponseEnvelopeSuccess = true +) + +type OutgoingEnableParams struct { + ZoneID param.Field[interface{}] `path:"zone_id,required"` +} + +type OutgoingEnableResponseEnvelope struct { + Errors []OutgoingEnableResponseEnvelopeErrors `json:"errors,required"` + Messages []OutgoingEnableResponseEnvelopeMessages `json:"messages,required"` + // The zone transfer status of a primary zone + Result SecondaryDNSEnableTransferResult `json:"result,required"` + // Whether the API call was successful + Success OutgoingEnableResponseEnvelopeSuccess `json:"success,required"` + JSON outgoingEnableResponseEnvelopeJSON `json:"-"` +} + +// outgoingEnableResponseEnvelopeJSON contains the JSON metadata for the struct +// [OutgoingEnableResponseEnvelope] +type outgoingEnableResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingEnableResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingEnableResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type OutgoingEnableResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON outgoingEnableResponseEnvelopeErrorsJSON `json:"-"` +} + +// outgoingEnableResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [OutgoingEnableResponseEnvelopeErrors] +type outgoingEnableResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingEnableResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingEnableResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type OutgoingEnableResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON outgoingEnableResponseEnvelopeMessagesJSON `json:"-"` +} + +// outgoingEnableResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [OutgoingEnableResponseEnvelopeMessages] +type outgoingEnableResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingEnableResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingEnableResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type OutgoingEnableResponseEnvelopeSuccess bool + +const ( + OutgoingEnableResponseEnvelopeSuccessTrue OutgoingEnableResponseEnvelopeSuccess = true +) + +type OutgoingForceNotifyParams struct { + ZoneID param.Field[interface{}] `path:"zone_id,required"` +} + +type OutgoingForceNotifyResponseEnvelope struct { + Errors []OutgoingForceNotifyResponseEnvelopeErrors `json:"errors,required"` + Messages []OutgoingForceNotifyResponseEnvelopeMessages `json:"messages,required"` + // When force_notify query parameter is set to true, the response is a simple + // string + Result SecondaryDNSSchemasForceResult `json:"result,required"` + // Whether the API call was successful + Success OutgoingForceNotifyResponseEnvelopeSuccess `json:"success,required"` + JSON outgoingForceNotifyResponseEnvelopeJSON `json:"-"` +} + +// outgoingForceNotifyResponseEnvelopeJSON contains the JSON metadata for the +// struct [OutgoingForceNotifyResponseEnvelope] +type outgoingForceNotifyResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingForceNotifyResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingForceNotifyResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type OutgoingForceNotifyResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON outgoingForceNotifyResponseEnvelopeErrorsJSON `json:"-"` +} + +// outgoingForceNotifyResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [OutgoingForceNotifyResponseEnvelopeErrors] +type outgoingForceNotifyResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingForceNotifyResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingForceNotifyResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type OutgoingForceNotifyResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON outgoingForceNotifyResponseEnvelopeMessagesJSON `json:"-"` +} + +// outgoingForceNotifyResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [OutgoingForceNotifyResponseEnvelopeMessages] +type outgoingForceNotifyResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingForceNotifyResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingForceNotifyResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type OutgoingForceNotifyResponseEnvelopeSuccess bool + +const ( + OutgoingForceNotifyResponseEnvelopeSuccessTrue OutgoingForceNotifyResponseEnvelopeSuccess = true +) + +type OutgoingGetParams struct { + ZoneID param.Field[interface{}] `path:"zone_id,required"` +} + +type OutgoingGetResponseEnvelope struct { + Errors []OutgoingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []OutgoingGetResponseEnvelopeMessages `json:"messages,required"` + Result OutgoingGetResponse `json:"result,required"` + // Whether the API call was successful + Success OutgoingGetResponseEnvelopeSuccess `json:"success,required"` + JSON outgoingGetResponseEnvelopeJSON `json:"-"` +} + +// outgoingGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [OutgoingGetResponseEnvelope] +type outgoingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type OutgoingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON outgoingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// outgoingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [OutgoingGetResponseEnvelopeErrors] +type outgoingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type OutgoingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON outgoingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// outgoingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [OutgoingGetResponseEnvelopeMessages] +type outgoingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type OutgoingGetResponseEnvelopeSuccess bool + +const ( + OutgoingGetResponseEnvelopeSuccessTrue OutgoingGetResponseEnvelopeSuccess = true +) diff --git a/secondary_dns/outgoing_test.go b/secondary_dns/outgoing_test.go new file mode 100644 index 00000000000..9b5c5e54f72 --- /dev/null +++ b/secondary_dns/outgoing_test.go @@ -0,0 +1,201 @@ +// File generated from our OpenAPI spec by Stainless. + +package secondary_dns_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/secondary_dns" +) + +func TestOutgoingNew(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("user@example.com"), + ) + _, err := client.SecondaryDNS.Outgoing.New(context.TODO(), secondary_dns.OutgoingNewParams{ + ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), + Name: cloudflare.F("www.example.com."), + Peers: cloudflare.F([]interface{}{"23ff594956f20c2a721606e94745a8aa", "00920f38ce07c2e2f4df50b1f61d4194"}), + }) + 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 TestOutgoingUpdate(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("user@example.com"), + ) + _, err := client.SecondaryDNS.Outgoing.Update(context.TODO(), secondary_dns.OutgoingUpdateParams{ + ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), + Name: cloudflare.F("www.example.com."), + Peers: cloudflare.F([]interface{}{"23ff594956f20c2a721606e94745a8aa", "00920f38ce07c2e2f4df50b1f61d4194"}), + }) + 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 TestOutgoingDelete(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("user@example.com"), + ) + _, err := client.SecondaryDNS.Outgoing.Delete(context.TODO(), secondary_dns.OutgoingDeleteParams{ + ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), + }) + 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 TestOutgoingDisable(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("user@example.com"), + ) + _, err := client.SecondaryDNS.Outgoing.Disable(context.TODO(), secondary_dns.OutgoingDisableParams{ + ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), + }) + 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 TestOutgoingEnable(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("user@example.com"), + ) + _, err := client.SecondaryDNS.Outgoing.Enable(context.TODO(), secondary_dns.OutgoingEnableParams{ + ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), + }) + 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 TestOutgoingForceNotify(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("user@example.com"), + ) + _, err := client.SecondaryDNS.Outgoing.ForceNotify(context.TODO(), secondary_dns.OutgoingForceNotifyParams{ + ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), + }) + 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 TestOutgoingGet(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("user@example.com"), + ) + _, err := client.SecondaryDNS.Outgoing.Get(context.TODO(), secondary_dns.OutgoingGetParams{ + ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), + }) + 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/secondary_dns/outgoingstatus.go b/secondary_dns/outgoingstatus.go new file mode 100644 index 00000000000..322157d5e78 --- /dev/null +++ b/secondary_dns/outgoingstatus.go @@ -0,0 +1,131 @@ +// File generated from our OpenAPI spec by Stainless. + +package secondary_dns + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// OutgoingStatusService 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 [NewOutgoingStatusService] method +// instead. +type OutgoingStatusService struct { + Options []option.RequestOption +} + +// NewOutgoingStatusService 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 NewOutgoingStatusService(opts ...option.RequestOption) (r *OutgoingStatusService) { + r = &OutgoingStatusService{} + r.Options = opts + return +} + +// Get primary zone transfer status. +func (r *OutgoingStatusService) Get(ctx context.Context, query OutgoingStatusGetParams, opts ...option.RequestOption) (res *SecondaryDNSEnableTransferResult, err error) { + opts = append(r.Options[:], opts...) + var env OutgoingStatusGetResponseEnvelope + path := fmt.Sprintf("zones/%v/secondary_dns/outgoing/status", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type OutgoingStatusGetParams struct { + ZoneID param.Field[interface{}] `path:"zone_id,required"` +} + +type OutgoingStatusGetResponseEnvelope struct { + Errors []OutgoingStatusGetResponseEnvelopeErrors `json:"errors,required"` + Messages []OutgoingStatusGetResponseEnvelopeMessages `json:"messages,required"` + // The zone transfer status of a primary zone + Result SecondaryDNSEnableTransferResult `json:"result,required"` + // Whether the API call was successful + Success OutgoingStatusGetResponseEnvelopeSuccess `json:"success,required"` + JSON outgoingStatusGetResponseEnvelopeJSON `json:"-"` +} + +// outgoingStatusGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [OutgoingStatusGetResponseEnvelope] +type outgoingStatusGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingStatusGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingStatusGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type OutgoingStatusGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON outgoingStatusGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// outgoingStatusGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [OutgoingStatusGetResponseEnvelopeErrors] +type outgoingStatusGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingStatusGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingStatusGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type OutgoingStatusGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON outgoingStatusGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// outgoingStatusGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [OutgoingStatusGetResponseEnvelopeMessages] +type outgoingStatusGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OutgoingStatusGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r outgoingStatusGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type OutgoingStatusGetResponseEnvelopeSuccess bool + +const ( + OutgoingStatusGetResponseEnvelopeSuccessTrue OutgoingStatusGetResponseEnvelopeSuccess = true +) diff --git a/secondary_dns/outgoingstatus_test.go b/secondary_dns/outgoingstatus_test.go new file mode 100644 index 00000000000..a7a19ecabf7 --- /dev/null +++ b/secondary_dns/outgoingstatus_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package secondary_dns_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/secondary_dns" +) + +func TestOutgoingStatusGet(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("user@example.com"), + ) + _, err := client.SecondaryDNS.Outgoing.Status.Get(context.TODO(), secondary_dns.OutgoingStatusGetParams{ + ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), + }) + 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/secondary_dns/peer.go b/secondary_dns/peer.go new file mode 100644 index 00000000000..d78e533ba28 --- /dev/null +++ b/secondary_dns/peer.go @@ -0,0 +1,642 @@ +// File generated from our OpenAPI spec by Stainless. + +package secondary_dns + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// PeerService 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 [NewPeerService] method instead. +type PeerService struct { + Options []option.RequestOption +} + +// NewPeerService 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 NewPeerService(opts ...option.RequestOption) (r *PeerService) { + r = &PeerService{} + r.Options = opts + return +} + +// Create Peer. +func (r *PeerService) New(ctx context.Context, params PeerNewParams, opts ...option.RequestOption) (res *SecondaryDNSPeer, err error) { + opts = append(r.Options[:], opts...) + var env PeerNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/secondary_dns/peers", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Modify Peer. +func (r *PeerService) Update(ctx context.Context, peerID interface{}, params PeerUpdateParams, opts ...option.RequestOption) (res *SecondaryDNSPeer, err error) { + opts = append(r.Options[:], opts...) + var env PeerUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/secondary_dns/peers/%v", params.AccountID, peerID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List Peers. +func (r *PeerService) List(ctx context.Context, query PeerListParams, opts ...option.RequestOption) (res *[]SecondaryDNSPeer, err error) { + opts = append(r.Options[:], opts...) + var env PeerListResponseEnvelope + path := fmt.Sprintf("accounts/%v/secondary_dns/peers", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete Peer. +func (r *PeerService) Delete(ctx context.Context, peerID interface{}, body PeerDeleteParams, opts ...option.RequestOption) (res *PeerDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env PeerDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%v/secondary_dns/peers/%v", body.AccountID, peerID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get Peer. +func (r *PeerService) Get(ctx context.Context, peerID interface{}, query PeerGetParams, opts ...option.RequestOption) (res *SecondaryDNSPeer, err error) { + opts = append(r.Options[:], opts...) + var env PeerGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/secondary_dns/peers/%v", query.AccountID, peerID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type SecondaryDNSPeer struct { + ID interface{} `json:"id,required"` + // The name of the peer. + Name string `json:"name,required"` + // IPv4/IPv6 address of primary or secondary nameserver, depending on what zone + // this peer is linked to. For primary zones this IP defines the IP of the + // secondary nameserver Cloudflare will NOTIFY upon zone changes. For secondary + // zones this IP defines the IP of the primary nameserver Cloudflare will send + // AXFR/IXFR requests to. + IP string `json:"ip"` + // Enable IXFR transfer protocol, default is AXFR. Only applicable to secondary + // zones. + IxfrEnable bool `json:"ixfr_enable"` + // DNS port of primary or secondary nameserver, depending on what zone this peer is + // linked to. + Port float64 `json:"port"` + // TSIG authentication will be used for zone transfer if configured. + TSIGID string `json:"tsig_id"` + JSON secondaryDNSPeerJSON `json:"-"` +} + +// secondaryDNSPeerJSON contains the JSON metadata for the struct +// [SecondaryDNSPeer] +type secondaryDNSPeerJSON struct { + ID apijson.Field + Name apijson.Field + IP apijson.Field + IxfrEnable apijson.Field + Port apijson.Field + TSIGID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SecondaryDNSPeer) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r secondaryDNSPeerJSON) RawJSON() string { + return r.raw +} + +type PeerDeleteResponse struct { + ID interface{} `json:"id"` + JSON peerDeleteResponseJSON `json:"-"` +} + +// peerDeleteResponseJSON contains the JSON metadata for the struct +// [PeerDeleteResponse] +type peerDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PeerDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r peerDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type PeerNewParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + Body param.Field[interface{}] `json:"body,required"` +} + +func (r PeerNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type PeerNewResponseEnvelope struct { + Errors []PeerNewResponseEnvelopeErrors `json:"errors,required"` + Messages []PeerNewResponseEnvelopeMessages `json:"messages,required"` + Result SecondaryDNSPeer `json:"result,required"` + // Whether the API call was successful + Success PeerNewResponseEnvelopeSuccess `json:"success,required"` + JSON peerNewResponseEnvelopeJSON `json:"-"` +} + +// peerNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [PeerNewResponseEnvelope] +type peerNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PeerNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r peerNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PeerNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON peerNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// peerNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PeerNewResponseEnvelopeErrors] +type peerNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PeerNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r peerNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PeerNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON peerNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// peerNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PeerNewResponseEnvelopeMessages] +type peerNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PeerNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r peerNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PeerNewResponseEnvelopeSuccess bool + +const ( + PeerNewResponseEnvelopeSuccessTrue PeerNewResponseEnvelopeSuccess = true +) + +type PeerUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // The name of the peer. + Name param.Field[string] `json:"name,required"` + // IPv4/IPv6 address of primary or secondary nameserver, depending on what zone + // this peer is linked to. For primary zones this IP defines the IP of the + // secondary nameserver Cloudflare will NOTIFY upon zone changes. For secondary + // zones this IP defines the IP of the primary nameserver Cloudflare will send + // AXFR/IXFR requests to. + IP param.Field[string] `json:"ip"` + // Enable IXFR transfer protocol, default is AXFR. Only applicable to secondary + // zones. + IxfrEnable param.Field[bool] `json:"ixfr_enable"` + // DNS port of primary or secondary nameserver, depending on what zone this peer is + // linked to. + Port param.Field[float64] `json:"port"` + // TSIG authentication will be used for zone transfer if configured. + TSIGID param.Field[string] `json:"tsig_id"` +} + +func (r PeerUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type PeerUpdateResponseEnvelope struct { + Errors []PeerUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []PeerUpdateResponseEnvelopeMessages `json:"messages,required"` + Result SecondaryDNSPeer `json:"result,required"` + // Whether the API call was successful + Success PeerUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON peerUpdateResponseEnvelopeJSON `json:"-"` +} + +// peerUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [PeerUpdateResponseEnvelope] +type peerUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PeerUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r peerUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PeerUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON peerUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// peerUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PeerUpdateResponseEnvelopeErrors] +type peerUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PeerUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r peerUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PeerUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON peerUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// peerUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PeerUpdateResponseEnvelopeMessages] +type peerUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PeerUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r peerUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PeerUpdateResponseEnvelopeSuccess bool + +const ( + PeerUpdateResponseEnvelopeSuccessTrue PeerUpdateResponseEnvelopeSuccess = true +) + +type PeerListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type PeerListResponseEnvelope struct { + Errors []PeerListResponseEnvelopeErrors `json:"errors,required"` + Messages []PeerListResponseEnvelopeMessages `json:"messages,required"` + Result []SecondaryDNSPeer `json:"result,required,nullable"` + // Whether the API call was successful + Success PeerListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo PeerListResponseEnvelopeResultInfo `json:"result_info"` + JSON peerListResponseEnvelopeJSON `json:"-"` +} + +// peerListResponseEnvelopeJSON contains the JSON metadata for the struct +// [PeerListResponseEnvelope] +type peerListResponseEnvelopeJSON 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 *PeerListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r peerListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PeerListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON peerListResponseEnvelopeErrorsJSON `json:"-"` +} + +// peerListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PeerListResponseEnvelopeErrors] +type peerListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PeerListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r peerListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PeerListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON peerListResponseEnvelopeMessagesJSON `json:"-"` +} + +// peerListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PeerListResponseEnvelopeMessages] +type peerListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PeerListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r peerListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PeerListResponseEnvelopeSuccess bool + +const ( + PeerListResponseEnvelopeSuccessTrue PeerListResponseEnvelopeSuccess = true +) + +type PeerListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON peerListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// peerListResponseEnvelopeResultInfoJSON contains the JSON metadata for the struct +// [PeerListResponseEnvelopeResultInfo] +type peerListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PeerListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r peerListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type PeerDeleteParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type PeerDeleteResponseEnvelope struct { + Errors []PeerDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []PeerDeleteResponseEnvelopeMessages `json:"messages,required"` + Result PeerDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success PeerDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON peerDeleteResponseEnvelopeJSON `json:"-"` +} + +// peerDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [PeerDeleteResponseEnvelope] +type peerDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PeerDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r peerDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PeerDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON peerDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// peerDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PeerDeleteResponseEnvelopeErrors] +type peerDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PeerDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r peerDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PeerDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON peerDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// peerDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PeerDeleteResponseEnvelopeMessages] +type peerDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PeerDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r peerDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PeerDeleteResponseEnvelopeSuccess bool + +const ( + PeerDeleteResponseEnvelopeSuccessTrue PeerDeleteResponseEnvelopeSuccess = true +) + +type PeerGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type PeerGetResponseEnvelope struct { + Errors []PeerGetResponseEnvelopeErrors `json:"errors,required"` + Messages []PeerGetResponseEnvelopeMessages `json:"messages,required"` + Result SecondaryDNSPeer `json:"result,required"` + // Whether the API call was successful + Success PeerGetResponseEnvelopeSuccess `json:"success,required"` + JSON peerGetResponseEnvelopeJSON `json:"-"` +} + +// peerGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [PeerGetResponseEnvelope] +type peerGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PeerGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r peerGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type PeerGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON peerGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// peerGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [PeerGetResponseEnvelopeErrors] +type peerGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PeerGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r peerGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type PeerGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON peerGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// peerGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [PeerGetResponseEnvelopeMessages] +type peerGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PeerGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r peerGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type PeerGetResponseEnvelopeSuccess bool + +const ( + PeerGetResponseEnvelopeSuccessTrue PeerGetResponseEnvelopeSuccess = true +) diff --git a/secondary_dns/peer_test.go b/secondary_dns/peer_test.go new file mode 100644 index 00000000000..7db35393bcb --- /dev/null +++ b/secondary_dns/peer_test.go @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package secondary_dns_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/secondary_dns" +) + +func TestPeerNew(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("user@example.com"), + ) + _, err := client.SecondaryDNS.Peers.New(context.TODO(), secondary_dns.PeerNewParams{ + AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), + Body: cloudflare.F[any](map[string]interface{}{}), + }) + 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 TestPeerUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.SecondaryDNS.Peers.Update( + context.TODO(), + "23ff594956f20c2a721606e94745a8aa", + secondary_dns.PeerUpdateParams{ + AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), + Name: cloudflare.F("my-peer-1"), + IP: cloudflare.F("192.0.2.53"), + IxfrEnable: cloudflare.F(false), + Port: cloudflare.F(53.000000), + TSIGID: cloudflare.F("69cd1e104af3e6ed3cb344f263fd0d5a"), + }, + ) + 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 TestPeerList(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("user@example.com"), + ) + _, err := client.SecondaryDNS.Peers.List(context.TODO(), secondary_dns.PeerListParams{ + AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), + }) + 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 TestPeerDelete(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("user@example.com"), + ) + _, err := client.SecondaryDNS.Peers.Delete( + context.TODO(), + "23ff594956f20c2a721606e94745a8aa", + secondary_dns.PeerDeleteParams{ + AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), + }, + ) + 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 TestPeerGet(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("user@example.com"), + ) + _, err := client.SecondaryDNS.Peers.Get( + context.TODO(), + "23ff594956f20c2a721606e94745a8aa", + secondary_dns.PeerGetParams{ + AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), + }, + ) + 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/secondary_dns/secondarydns.go b/secondary_dns/secondarydns.go new file mode 100644 index 00000000000..10b4b357120 --- /dev/null +++ b/secondary_dns/secondarydns.go @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package secondary_dns + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// SecondaryDNSService 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 [NewSecondaryDNSService] method +// instead. +type SecondaryDNSService struct { + Options []option.RequestOption + ForceAxfrs *ForceAxfrService + Incoming *IncomingService + Outgoing *OutgoingService + ACLs *ACLService + Peers *PeerService + TSIGs *TSIGService +} + +// NewSecondaryDNSService 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 NewSecondaryDNSService(opts ...option.RequestOption) (r *SecondaryDNSService) { + r = &SecondaryDNSService{} + r.Options = opts + r.ForceAxfrs = NewForceAxfrService(opts...) + r.Incoming = NewIncomingService(opts...) + r.Outgoing = NewOutgoingService(opts...) + r.ACLs = NewACLService(opts...) + r.Peers = NewPeerService(opts...) + r.TSIGs = NewTSIGService(opts...) + return +} diff --git a/secondary_dns/tsig.go b/secondary_dns/tsig.go new file mode 100644 index 00000000000..7efe88b5051 --- /dev/null +++ b/secondary_dns/tsig.go @@ -0,0 +1,625 @@ +// File generated from our OpenAPI spec by Stainless. + +package secondary_dns + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// TSIGService 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 [NewTSIGService] method instead. +type TSIGService struct { + Options []option.RequestOption +} + +// NewTSIGService 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 NewTSIGService(opts ...option.RequestOption) (r *TSIGService) { + r = &TSIGService{} + r.Options = opts + return +} + +// Create TSIG. +func (r *TSIGService) New(ctx context.Context, params TSIGNewParams, opts ...option.RequestOption) (res *SecondaryDNSTSIG, err error) { + opts = append(r.Options[:], opts...) + var env TSIGNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/secondary_dns/tsigs", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Modify TSIG. +func (r *TSIGService) Update(ctx context.Context, tsigID interface{}, params TSIGUpdateParams, opts ...option.RequestOption) (res *SecondaryDNSTSIG, err error) { + opts = append(r.Options[:], opts...) + var env TSIGUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/secondary_dns/tsigs/%v", params.AccountID, tsigID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List TSIGs. +func (r *TSIGService) List(ctx context.Context, query TSIGListParams, opts ...option.RequestOption) (res *[]SecondaryDNSTSIG, err error) { + opts = append(r.Options[:], opts...) + var env TSIGListResponseEnvelope + path := fmt.Sprintf("accounts/%v/secondary_dns/tsigs", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete TSIG. +func (r *TSIGService) Delete(ctx context.Context, tsigID interface{}, body TSIGDeleteParams, opts ...option.RequestOption) (res *TSIGDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env TSIGDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%v/secondary_dns/tsigs/%v", body.AccountID, tsigID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get TSIG. +func (r *TSIGService) Get(ctx context.Context, tsigID interface{}, query TSIGGetParams, opts ...option.RequestOption) (res *SecondaryDNSTSIG, err error) { + opts = append(r.Options[:], opts...) + var env TSIGGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/secondary_dns/tsigs/%v", query.AccountID, tsigID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type SecondaryDNSTSIG struct { + ID interface{} `json:"id,required"` + // TSIG algorithm. + Algo string `json:"algo,required"` + // TSIG key name. + Name string `json:"name,required"` + // TSIG secret. + Secret string `json:"secret,required"` + JSON secondaryDnstsigJSON `json:"-"` +} + +// secondaryDnstsigJSON contains the JSON metadata for the struct +// [SecondaryDNSTSIG] +type secondaryDnstsigJSON struct { + ID apijson.Field + Algo apijson.Field + Name apijson.Field + Secret apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SecondaryDNSTSIG) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r secondaryDnstsigJSON) RawJSON() string { + return r.raw +} + +type TSIGDeleteResponse struct { + ID interface{} `json:"id"` + JSON tsigDeleteResponseJSON `json:"-"` +} + +// tsigDeleteResponseJSON contains the JSON metadata for the struct +// [TSIGDeleteResponse] +type tsigDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TSIGDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tsigDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type TSIGNewParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // TSIG algorithm. + Algo param.Field[string] `json:"algo,required"` + // TSIG key name. + Name param.Field[string] `json:"name,required"` + // TSIG secret. + Secret param.Field[string] `json:"secret,required"` +} + +func (r TSIGNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type TSIGNewResponseEnvelope struct { + Errors []TSIGNewResponseEnvelopeErrors `json:"errors,required"` + Messages []TSIGNewResponseEnvelopeMessages `json:"messages,required"` + Result SecondaryDNSTSIG `json:"result,required"` + // Whether the API call was successful + Success TSIGNewResponseEnvelopeSuccess `json:"success,required"` + JSON tsigNewResponseEnvelopeJSON `json:"-"` +} + +// tsigNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [TSIGNewResponseEnvelope] +type tsigNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TSIGNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tsigNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TSIGNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tsigNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// tsigNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [TSIGNewResponseEnvelopeErrors] +type tsigNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TSIGNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tsigNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TSIGNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tsigNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// tsigNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [TSIGNewResponseEnvelopeMessages] +type tsigNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TSIGNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tsigNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TSIGNewResponseEnvelopeSuccess bool + +const ( + TSIGNewResponseEnvelopeSuccessTrue TSIGNewResponseEnvelopeSuccess = true +) + +type TSIGUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // TSIG algorithm. + Algo param.Field[string] `json:"algo,required"` + // TSIG key name. + Name param.Field[string] `json:"name,required"` + // TSIG secret. + Secret param.Field[string] `json:"secret,required"` +} + +func (r TSIGUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type TSIGUpdateResponseEnvelope struct { + Errors []TSIGUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []TSIGUpdateResponseEnvelopeMessages `json:"messages,required"` + Result SecondaryDNSTSIG `json:"result,required"` + // Whether the API call was successful + Success TSIGUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON tsigUpdateResponseEnvelopeJSON `json:"-"` +} + +// tsigUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [TSIGUpdateResponseEnvelope] +type tsigUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TSIGUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tsigUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TSIGUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tsigUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// tsigUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [TSIGUpdateResponseEnvelopeErrors] +type tsigUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TSIGUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tsigUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TSIGUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tsigUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// tsigUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [TSIGUpdateResponseEnvelopeMessages] +type tsigUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TSIGUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tsigUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TSIGUpdateResponseEnvelopeSuccess bool + +const ( + TSIGUpdateResponseEnvelopeSuccessTrue TSIGUpdateResponseEnvelopeSuccess = true +) + +type TSIGListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type TSIGListResponseEnvelope struct { + Errors []TSIGListResponseEnvelopeErrors `json:"errors,required"` + Messages []TSIGListResponseEnvelopeMessages `json:"messages,required"` + Result []SecondaryDNSTSIG `json:"result,required,nullable"` + // Whether the API call was successful + Success TSIGListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo TSIGListResponseEnvelopeResultInfo `json:"result_info"` + JSON tsigListResponseEnvelopeJSON `json:"-"` +} + +// tsigListResponseEnvelopeJSON contains the JSON metadata for the struct +// [TSIGListResponseEnvelope] +type tsigListResponseEnvelopeJSON 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 *TSIGListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tsigListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TSIGListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tsigListResponseEnvelopeErrorsJSON `json:"-"` +} + +// tsigListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [TSIGListResponseEnvelopeErrors] +type tsigListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TSIGListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tsigListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TSIGListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tsigListResponseEnvelopeMessagesJSON `json:"-"` +} + +// tsigListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [TSIGListResponseEnvelopeMessages] +type tsigListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TSIGListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tsigListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TSIGListResponseEnvelopeSuccess bool + +const ( + TSIGListResponseEnvelopeSuccessTrue TSIGListResponseEnvelopeSuccess = true +) + +type TSIGListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON tsigListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// tsigListResponseEnvelopeResultInfoJSON contains the JSON metadata for the struct +// [TSIGListResponseEnvelopeResultInfo] +type tsigListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TSIGListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tsigListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type TSIGDeleteParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type TSIGDeleteResponseEnvelope struct { + Errors []TSIGDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []TSIGDeleteResponseEnvelopeMessages `json:"messages,required"` + Result TSIGDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success TSIGDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON tsigDeleteResponseEnvelopeJSON `json:"-"` +} + +// tsigDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [TSIGDeleteResponseEnvelope] +type tsigDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TSIGDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tsigDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TSIGDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tsigDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// tsigDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [TSIGDeleteResponseEnvelopeErrors] +type tsigDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TSIGDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tsigDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TSIGDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tsigDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// tsigDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [TSIGDeleteResponseEnvelopeMessages] +type tsigDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TSIGDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tsigDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TSIGDeleteResponseEnvelopeSuccess bool + +const ( + TSIGDeleteResponseEnvelopeSuccessTrue TSIGDeleteResponseEnvelopeSuccess = true +) + +type TSIGGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type TSIGGetResponseEnvelope struct { + Errors []TSIGGetResponseEnvelopeErrors `json:"errors,required"` + Messages []TSIGGetResponseEnvelopeMessages `json:"messages,required"` + Result SecondaryDNSTSIG `json:"result,required"` + // Whether the API call was successful + Success TSIGGetResponseEnvelopeSuccess `json:"success,required"` + JSON tsigGetResponseEnvelopeJSON `json:"-"` +} + +// tsigGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [TSIGGetResponseEnvelope] +type tsigGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TSIGGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tsigGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TSIGGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tsigGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// tsigGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [TSIGGetResponseEnvelopeErrors] +type tsigGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TSIGGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tsigGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TSIGGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tsigGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// tsigGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [TSIGGetResponseEnvelopeMessages] +type tsigGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TSIGGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tsigGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TSIGGetResponseEnvelopeSuccess bool + +const ( + TSIGGetResponseEnvelopeSuccessTrue TSIGGetResponseEnvelopeSuccess = true +) diff --git a/secondary_dns/tsig_test.go b/secondary_dns/tsig_test.go new file mode 100644 index 00000000000..c410881d5c7 --- /dev/null +++ b/secondary_dns/tsig_test.go @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package secondary_dns_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/secondary_dns" +) + +func TestTSIGNew(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("user@example.com"), + ) + _, err := client.SecondaryDNS.TSIGs.New(context.TODO(), secondary_dns.TSIGNewParams{ + AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), + Algo: cloudflare.F("hmac-sha512."), + Name: cloudflare.F("tsig.customer.cf."), + Secret: cloudflare.F("caf79a7804b04337c9c66ccd7bef9190a1e1679b5dd03d8aa10f7ad45e1a9dab92b417896c15d4d007c7c14194538d2a5d0feffdecc5a7f0e1c570cfa700837c"), + }) + 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 TestTSIGUpdate(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("user@example.com"), + ) + _, err := client.SecondaryDNS.TSIGs.Update( + context.TODO(), + "69cd1e104af3e6ed3cb344f263fd0d5a", + secondary_dns.TSIGUpdateParams{ + AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), + Algo: cloudflare.F("hmac-sha512."), + Name: cloudflare.F("tsig.customer.cf."), + Secret: cloudflare.F("caf79a7804b04337c9c66ccd7bef9190a1e1679b5dd03d8aa10f7ad45e1a9dab92b417896c15d4d007c7c14194538d2a5d0feffdecc5a7f0e1c570cfa700837c"), + }, + ) + 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 TestTSIGList(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("user@example.com"), + ) + _, err := client.SecondaryDNS.TSIGs.List(context.TODO(), secondary_dns.TSIGListParams{ + AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), + }) + 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 TestTSIGDelete(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("user@example.com"), + ) + _, err := client.SecondaryDNS.TSIGs.Delete( + context.TODO(), + "69cd1e104af3e6ed3cb344f263fd0d5a", + secondary_dns.TSIGDeleteParams{ + AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), + }, + ) + 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 TestTSIGGet(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("user@example.com"), + ) + _, err := client.SecondaryDNS.TSIGs.Get( + context.TODO(), + "69cd1e104af3e6ed3cb344f263fd0d5a", + secondary_dns.TSIGGetParams{ + AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), + }, + ) + 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/secondarydns.go b/secondarydns.go deleted file mode 100644 index 11b793c2f7d..00000000000 --- a/secondarydns.go +++ /dev/null @@ -1,37 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// SecondaryDNSService 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 [NewSecondaryDNSService] method -// instead. -type SecondaryDNSService struct { - Options []option.RequestOption - ForceAxfrs *SecondaryDNSForceAxfrService - Incoming *SecondaryDNSIncomingService - Outgoing *SecondaryDNSOutgoingService - ACLs *SecondaryDNSACLService - Peers *SecondaryDNSPeerService - TSIGs *SecondaryDNSTSIGService -} - -// NewSecondaryDNSService 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 NewSecondaryDNSService(opts ...option.RequestOption) (r *SecondaryDNSService) { - r = &SecondaryDNSService{} - r.Options = opts - r.ForceAxfrs = NewSecondaryDNSForceAxfrService(opts...) - r.Incoming = NewSecondaryDNSIncomingService(opts...) - r.Outgoing = NewSecondaryDNSOutgoingService(opts...) - r.ACLs = NewSecondaryDNSACLService(opts...) - r.Peers = NewSecondaryDNSPeerService(opts...) - r.TSIGs = NewSecondaryDNSTSIGService(opts...) - return -} diff --git a/secondarydnsacl.go b/secondarydnsacl.go deleted file mode 100644 index ea99847a580..00000000000 --- a/secondarydnsacl.go +++ /dev/null @@ -1,717 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SecondaryDNSACLService 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 [NewSecondaryDNSACLService] method -// instead. -type SecondaryDNSACLService struct { - Options []option.RequestOption -} - -// NewSecondaryDNSACLService 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 NewSecondaryDNSACLService(opts ...option.RequestOption) (r *SecondaryDNSACLService) { - r = &SecondaryDNSACLService{} - r.Options = opts - return -} - -// Create ACL. -func (r *SecondaryDNSACLService) New(ctx context.Context, params SecondaryDNSACLNewParams, opts ...option.RequestOption) (res *SecondaryDnsaclNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDnsaclNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/secondary_dns/acls", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Modify ACL. -func (r *SecondaryDNSACLService) Update(ctx context.Context, aclID interface{}, params SecondaryDNSACLUpdateParams, opts ...option.RequestOption) (res *SecondaryDnsaclUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDnsaclUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/secondary_dns/acls/%v", params.AccountID, aclID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List ACLs. -func (r *SecondaryDNSACLService) List(ctx context.Context, query SecondaryDNSACLListParams, opts ...option.RequestOption) (res *[]SecondaryDnsaclListResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDnsaclListResponseEnvelope - path := fmt.Sprintf("accounts/%v/secondary_dns/acls", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete ACL. -func (r *SecondaryDNSACLService) Delete(ctx context.Context, aclID interface{}, body SecondaryDNSACLDeleteParams, opts ...option.RequestOption) (res *SecondaryDnsaclDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDnsaclDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%v/secondary_dns/acls/%v", body.AccountID, aclID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get ACL. -func (r *SecondaryDNSACLService) Get(ctx context.Context, aclID interface{}, query SecondaryDNSACLGetParams, opts ...option.RequestOption) (res *SecondaryDnsaclGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDnsaclGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/secondary_dns/acls/%v", query.AccountID, aclID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SecondaryDnsaclNewResponse struct { - ID interface{} `json:"id,required"` - // Allowed IPv4/IPv6 address range of primary or secondary nameservers. This will - // be applied for the entire account. The IP range is used to allow additional - // NOTIFY IPs for secondary zones and IPs Cloudflare allows AXFR/IXFR requests from - // for primary zones. CIDRs are limited to a maximum of /24 for IPv4 and /64 for - // IPv6 respectively. - IPRange string `json:"ip_range,required"` - // The name of the acl. - Name string `json:"name,required"` - JSON secondaryDnsaclNewResponseJSON `json:"-"` -} - -// secondaryDnsaclNewResponseJSON contains the JSON metadata for the struct -// [SecondaryDnsaclNewResponse] -type secondaryDnsaclNewResponseJSON struct { - ID apijson.Field - IPRange apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclNewResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnsaclUpdateResponse struct { - ID interface{} `json:"id,required"` - // Allowed IPv4/IPv6 address range of primary or secondary nameservers. This will - // be applied for the entire account. The IP range is used to allow additional - // NOTIFY IPs for secondary zones and IPs Cloudflare allows AXFR/IXFR requests from - // for primary zones. CIDRs are limited to a maximum of /24 for IPv4 and /64 for - // IPv6 respectively. - IPRange string `json:"ip_range,required"` - // The name of the acl. - Name string `json:"name,required"` - JSON secondaryDnsaclUpdateResponseJSON `json:"-"` -} - -// secondaryDnsaclUpdateResponseJSON contains the JSON metadata for the struct -// [SecondaryDnsaclUpdateResponse] -type secondaryDnsaclUpdateResponseJSON struct { - ID apijson.Field - IPRange apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnsaclListResponse struct { - ID interface{} `json:"id,required"` - // Allowed IPv4/IPv6 address range of primary or secondary nameservers. This will - // be applied for the entire account. The IP range is used to allow additional - // NOTIFY IPs for secondary zones and IPs Cloudflare allows AXFR/IXFR requests from - // for primary zones. CIDRs are limited to a maximum of /24 for IPv4 and /64 for - // IPv6 respectively. - IPRange string `json:"ip_range,required"` - // The name of the acl. - Name string `json:"name,required"` - JSON secondaryDnsaclListResponseJSON `json:"-"` -} - -// secondaryDnsaclListResponseJSON contains the JSON metadata for the struct -// [SecondaryDnsaclListResponse] -type secondaryDnsaclListResponseJSON struct { - ID apijson.Field - IPRange apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclListResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnsaclDeleteResponse struct { - ID interface{} `json:"id"` - JSON secondaryDnsaclDeleteResponseJSON `json:"-"` -} - -// secondaryDnsaclDeleteResponseJSON contains the JSON metadata for the struct -// [SecondaryDnsaclDeleteResponse] -type secondaryDnsaclDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnsaclGetResponse struct { - ID interface{} `json:"id,required"` - // Allowed IPv4/IPv6 address range of primary or secondary nameservers. This will - // be applied for the entire account. The IP range is used to allow additional - // NOTIFY IPs for secondary zones and IPs Cloudflare allows AXFR/IXFR requests from - // for primary zones. CIDRs are limited to a maximum of /24 for IPv4 and /64 for - // IPv6 respectively. - IPRange string `json:"ip_range,required"` - // The name of the acl. - Name string `json:"name,required"` - JSON secondaryDnsaclGetResponseJSON `json:"-"` -} - -// secondaryDnsaclGetResponseJSON contains the JSON metadata for the struct -// [SecondaryDnsaclGetResponse] -type secondaryDnsaclGetResponseJSON struct { - ID apijson.Field - IPRange apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclGetResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSACLNewParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` -} - -func (r SecondaryDNSACLNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type SecondaryDnsaclNewResponseEnvelope struct { - Errors []SecondaryDnsaclNewResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDnsaclNewResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDnsaclNewResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDnsaclNewResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDnsaclNewResponseEnvelopeJSON `json:"-"` -} - -// secondaryDnsaclNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [SecondaryDnsaclNewResponseEnvelope] -type secondaryDnsaclNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnsaclNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnsaclNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDnsaclNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SecondaryDnsaclNewResponseEnvelopeErrors] -type secondaryDnsaclNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnsaclNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnsaclNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDnsaclNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SecondaryDnsaclNewResponseEnvelopeMessages] -type secondaryDnsaclNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDnsaclNewResponseEnvelopeSuccess bool - -const ( - SecondaryDnsaclNewResponseEnvelopeSuccessTrue SecondaryDnsaclNewResponseEnvelopeSuccess = true -) - -type SecondaryDNSACLUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // Allowed IPv4/IPv6 address range of primary or secondary nameservers. This will - // be applied for the entire account. The IP range is used to allow additional - // NOTIFY IPs for secondary zones and IPs Cloudflare allows AXFR/IXFR requests from - // for primary zones. CIDRs are limited to a maximum of /24 for IPv4 and /64 for - // IPv6 respectively. - IPRange param.Field[string] `json:"ip_range,required"` - // The name of the acl. - Name param.Field[string] `json:"name,required"` -} - -func (r SecondaryDNSACLUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SecondaryDnsaclUpdateResponseEnvelope struct { - Errors []SecondaryDnsaclUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDnsaclUpdateResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDnsaclUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDnsaclUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDnsaclUpdateResponseEnvelopeJSON `json:"-"` -} - -// secondaryDnsaclUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [SecondaryDnsaclUpdateResponseEnvelope] -type secondaryDnsaclUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnsaclUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnsaclUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDnsaclUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SecondaryDnsaclUpdateResponseEnvelopeErrors] -type secondaryDnsaclUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnsaclUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnsaclUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDnsaclUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SecondaryDnsaclUpdateResponseEnvelopeMessages] -type secondaryDnsaclUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDnsaclUpdateResponseEnvelopeSuccess bool - -const ( - SecondaryDnsaclUpdateResponseEnvelopeSuccessTrue SecondaryDnsaclUpdateResponseEnvelopeSuccess = true -) - -type SecondaryDNSACLListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type SecondaryDnsaclListResponseEnvelope struct { - Errors []SecondaryDnsaclListResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDnsaclListResponseEnvelopeMessages `json:"messages,required"` - Result []SecondaryDnsaclListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success SecondaryDnsaclListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo SecondaryDnsaclListResponseEnvelopeResultInfo `json:"result_info"` - JSON secondaryDnsaclListResponseEnvelopeJSON `json:"-"` -} - -// secondaryDnsaclListResponseEnvelopeJSON contains the JSON metadata for the -// struct [SecondaryDnsaclListResponseEnvelope] -type secondaryDnsaclListResponseEnvelopeJSON 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 *SecondaryDnsaclListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnsaclListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnsaclListResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDnsaclListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SecondaryDnsaclListResponseEnvelopeErrors] -type secondaryDnsaclListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnsaclListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnsaclListResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDnsaclListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SecondaryDnsaclListResponseEnvelopeMessages] -type secondaryDnsaclListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDnsaclListResponseEnvelopeSuccess bool - -const ( - SecondaryDnsaclListResponseEnvelopeSuccessTrue SecondaryDnsaclListResponseEnvelopeSuccess = true -) - -type SecondaryDnsaclListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON secondaryDnsaclListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// secondaryDnsaclListResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [SecondaryDnsaclListResponseEnvelopeResultInfo] -type secondaryDnsaclListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSACLDeleteParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type SecondaryDnsaclDeleteResponseEnvelope struct { - Errors []SecondaryDnsaclDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDnsaclDeleteResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDnsaclDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDnsaclDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDnsaclDeleteResponseEnvelopeJSON `json:"-"` -} - -// secondaryDnsaclDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [SecondaryDnsaclDeleteResponseEnvelope] -type secondaryDnsaclDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnsaclDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnsaclDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDnsaclDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SecondaryDnsaclDeleteResponseEnvelopeErrors] -type secondaryDnsaclDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnsaclDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnsaclDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDnsaclDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SecondaryDnsaclDeleteResponseEnvelopeMessages] -type secondaryDnsaclDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDnsaclDeleteResponseEnvelopeSuccess bool - -const ( - SecondaryDnsaclDeleteResponseEnvelopeSuccessTrue SecondaryDnsaclDeleteResponseEnvelopeSuccess = true -) - -type SecondaryDNSACLGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type SecondaryDnsaclGetResponseEnvelope struct { - Errors []SecondaryDnsaclGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDnsaclGetResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDnsaclGetResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDnsaclGetResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDnsaclGetResponseEnvelopeJSON `json:"-"` -} - -// secondaryDnsaclGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [SecondaryDnsaclGetResponseEnvelope] -type secondaryDnsaclGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnsaclGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnsaclGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDnsaclGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SecondaryDnsaclGetResponseEnvelopeErrors] -type secondaryDnsaclGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnsaclGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnsaclGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDnsaclGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SecondaryDnsaclGetResponseEnvelopeMessages] -type secondaryDnsaclGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnsaclGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnsaclGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDnsaclGetResponseEnvelopeSuccess bool - -const ( - SecondaryDnsaclGetResponseEnvelopeSuccessTrue SecondaryDnsaclGetResponseEnvelopeSuccess = true -) diff --git a/secondarydnsacl_test.go b/secondarydnsacl_test.go deleted file mode 100644 index 87acef30548..00000000000 --- a/secondarydnsacl_test.go +++ /dev/null @@ -1,159 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSecondaryDNSACLNew(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("user@example.com"), - ) - _, err := client.SecondaryDNS.ACLs.New(context.TODO(), cloudflare.SecondaryDNSACLNewParams{ - AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), - Body: cloudflare.F[any](map[string]interface{}{}), - }) - 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 TestSecondaryDNSACLUpdate(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("user@example.com"), - ) - _, err := client.SecondaryDNS.ACLs.Update( - context.TODO(), - "23ff594956f20c2a721606e94745a8aa", - cloudflare.SecondaryDNSACLUpdateParams{ - AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), - IPRange: cloudflare.F("192.0.2.53/28"), - Name: cloudflare.F("my-acl-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 TestSecondaryDNSACLList(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("user@example.com"), - ) - _, err := client.SecondaryDNS.ACLs.List(context.TODO(), cloudflare.SecondaryDNSACLListParams{ - AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), - }) - 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 TestSecondaryDNSACLDelete(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("user@example.com"), - ) - _, err := client.SecondaryDNS.ACLs.Delete( - context.TODO(), - "23ff594956f20c2a721606e94745a8aa", - cloudflare.SecondaryDNSACLDeleteParams{ - AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), - }, - ) - 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 TestSecondaryDNSACLGet(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("user@example.com"), - ) - _, err := client.SecondaryDNS.ACLs.Get( - context.TODO(), - "23ff594956f20c2a721606e94745a8aa", - cloudflare.SecondaryDNSACLGetParams{ - AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), - }, - ) - 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/secondarydnsforceaxfr.go b/secondarydnsforceaxfr.go deleted file mode 100644 index 419073e7793..00000000000 --- a/secondarydnsforceaxfr.go +++ /dev/null @@ -1,131 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SecondaryDNSForceAxfrService 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 [NewSecondaryDNSForceAxfrService] -// method instead. -type SecondaryDNSForceAxfrService struct { - Options []option.RequestOption -} - -// NewSecondaryDNSForceAxfrService 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 NewSecondaryDNSForceAxfrService(opts ...option.RequestOption) (r *SecondaryDNSForceAxfrService) { - r = &SecondaryDNSForceAxfrService{} - r.Options = opts - return -} - -// Sends AXFR zone transfer request to primary nameserver(s). -func (r *SecondaryDNSForceAxfrService) New(ctx context.Context, body SecondaryDNSForceAxfrNewParams, opts ...option.RequestOption) (res *string, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDNSForceAxfrNewResponseEnvelope - path := fmt.Sprintf("zones/%v/secondary_dns/force_axfr", body.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SecondaryDNSForceAxfrNewParams struct { - ZoneID param.Field[interface{}] `path:"zone_id,required"` -} - -type SecondaryDNSForceAxfrNewResponseEnvelope struct { - Errors []SecondaryDNSForceAxfrNewResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDNSForceAxfrNewResponseEnvelopeMessages `json:"messages,required"` - // When force_axfr query parameter is set to true, the response is a simple string - Result string `json:"result,required"` - // Whether the API call was successful - Success SecondaryDNSForceAxfrNewResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDNSForceAxfrNewResponseEnvelopeJSON `json:"-"` -} - -// secondaryDNSForceAxfrNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [SecondaryDNSForceAxfrNewResponseEnvelope] -type secondaryDNSForceAxfrNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSForceAxfrNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSForceAxfrNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSForceAxfrNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSForceAxfrNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDNSForceAxfrNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SecondaryDNSForceAxfrNewResponseEnvelopeErrors] -type secondaryDNSForceAxfrNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSForceAxfrNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSForceAxfrNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSForceAxfrNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSForceAxfrNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDNSForceAxfrNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SecondaryDNSForceAxfrNewResponseEnvelopeMessages] -type secondaryDNSForceAxfrNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSForceAxfrNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSForceAxfrNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDNSForceAxfrNewResponseEnvelopeSuccess bool - -const ( - SecondaryDNSForceAxfrNewResponseEnvelopeSuccessTrue SecondaryDNSForceAxfrNewResponseEnvelopeSuccess = true -) diff --git a/secondarydnsforceaxfr_test.go b/secondarydnsforceaxfr_test.go deleted file mode 100644 index b3068420781..00000000000 --- a/secondarydnsforceaxfr_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSecondaryDNSForceAxfrNew(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("user@example.com"), - ) - _, err := client.SecondaryDNS.ForceAxfrs.New(context.TODO(), cloudflare.SecondaryDNSForceAxfrNewParams{ - ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), - }) - 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/secondarydnsincoming.go b/secondarydnsincoming.go deleted file mode 100644 index 449a2a5d366..00000000000 --- a/secondarydnsincoming.go +++ /dev/null @@ -1,596 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SecondaryDNSIncomingService 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 [NewSecondaryDNSIncomingService] -// method instead. -type SecondaryDNSIncomingService struct { - Options []option.RequestOption -} - -// NewSecondaryDNSIncomingService 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 NewSecondaryDNSIncomingService(opts ...option.RequestOption) (r *SecondaryDNSIncomingService) { - r = &SecondaryDNSIncomingService{} - r.Options = opts - return -} - -// Create secondary zone configuration for incoming zone transfers. -func (r *SecondaryDNSIncomingService) New(ctx context.Context, params SecondaryDNSIncomingNewParams, opts ...option.RequestOption) (res *SecondaryDNSIncomingNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDNSIncomingNewResponseEnvelope - path := fmt.Sprintf("zones/%v/secondary_dns/incoming", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update secondary zone configuration for incoming zone transfers. -func (r *SecondaryDNSIncomingService) Update(ctx context.Context, params SecondaryDNSIncomingUpdateParams, opts ...option.RequestOption) (res *SecondaryDNSIncomingUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDNSIncomingUpdateResponseEnvelope - path := fmt.Sprintf("zones/%v/secondary_dns/incoming", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete secondary zone configuration for incoming zone transfers. -func (r *SecondaryDNSIncomingService) Delete(ctx context.Context, body SecondaryDNSIncomingDeleteParams, opts ...option.RequestOption) (res *SecondaryDNSIncomingDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDNSIncomingDeleteResponseEnvelope - path := fmt.Sprintf("zones/%v/secondary_dns/incoming", body.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get secondary zone configuration for incoming zone transfers. -func (r *SecondaryDNSIncomingService) Get(ctx context.Context, query SecondaryDNSIncomingGetParams, opts ...option.RequestOption) (res *SecondaryDNSIncomingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDNSIncomingGetResponseEnvelope - path := fmt.Sprintf("zones/%v/secondary_dns/incoming", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SecondaryDNSIncomingNewResponse struct { - ID interface{} `json:"id"` - // How often should a secondary zone auto refresh regardless of DNS NOTIFY. Not - // applicable for primary zones. - AutoRefreshSeconds float64 `json:"auto_refresh_seconds"` - // The time for a specific event. - CheckedTime string `json:"checked_time"` - // The time for a specific event. - CreatedTime string `json:"created_time"` - // The time for a specific event. - ModifiedTime string `json:"modified_time"` - // Zone name. - Name string `json:"name"` - // A list of peer tags. - Peers []interface{} `json:"peers"` - // The serial number of the SOA for the given zone. - SoaSerial float64 `json:"soa_serial"` - JSON secondaryDNSIncomingNewResponseJSON `json:"-"` -} - -// secondaryDNSIncomingNewResponseJSON contains the JSON metadata for the struct -// [SecondaryDNSIncomingNewResponse] -type secondaryDNSIncomingNewResponseJSON struct { - ID apijson.Field - AutoRefreshSeconds apijson.Field - CheckedTime apijson.Field - CreatedTime apijson.Field - ModifiedTime apijson.Field - Name apijson.Field - Peers apijson.Field - SoaSerial apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSIncomingNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSIncomingNewResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSIncomingUpdateResponse struct { - ID interface{} `json:"id"` - // How often should a secondary zone auto refresh regardless of DNS NOTIFY. Not - // applicable for primary zones. - AutoRefreshSeconds float64 `json:"auto_refresh_seconds"` - // The time for a specific event. - CheckedTime string `json:"checked_time"` - // The time for a specific event. - CreatedTime string `json:"created_time"` - // The time for a specific event. - ModifiedTime string `json:"modified_time"` - // Zone name. - Name string `json:"name"` - // A list of peer tags. - Peers []interface{} `json:"peers"` - // The serial number of the SOA for the given zone. - SoaSerial float64 `json:"soa_serial"` - JSON secondaryDNSIncomingUpdateResponseJSON `json:"-"` -} - -// secondaryDNSIncomingUpdateResponseJSON contains the JSON metadata for the struct -// [SecondaryDNSIncomingUpdateResponse] -type secondaryDNSIncomingUpdateResponseJSON struct { - ID apijson.Field - AutoRefreshSeconds apijson.Field - CheckedTime apijson.Field - CreatedTime apijson.Field - ModifiedTime apijson.Field - Name apijson.Field - Peers apijson.Field - SoaSerial apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSIncomingUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSIncomingUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSIncomingDeleteResponse struct { - ID interface{} `json:"id"` - JSON secondaryDNSIncomingDeleteResponseJSON `json:"-"` -} - -// secondaryDNSIncomingDeleteResponseJSON contains the JSON metadata for the struct -// [SecondaryDNSIncomingDeleteResponse] -type secondaryDNSIncomingDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSIncomingDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSIncomingDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSIncomingGetResponse struct { - ID interface{} `json:"id"` - // How often should a secondary zone auto refresh regardless of DNS NOTIFY. Not - // applicable for primary zones. - AutoRefreshSeconds float64 `json:"auto_refresh_seconds"` - // The time for a specific event. - CheckedTime string `json:"checked_time"` - // The time for a specific event. - CreatedTime string `json:"created_time"` - // The time for a specific event. - ModifiedTime string `json:"modified_time"` - // Zone name. - Name string `json:"name"` - // A list of peer tags. - Peers []interface{} `json:"peers"` - // The serial number of the SOA for the given zone. - SoaSerial float64 `json:"soa_serial"` - JSON secondaryDNSIncomingGetResponseJSON `json:"-"` -} - -// secondaryDNSIncomingGetResponseJSON contains the JSON metadata for the struct -// [SecondaryDNSIncomingGetResponse] -type secondaryDNSIncomingGetResponseJSON struct { - ID apijson.Field - AutoRefreshSeconds apijson.Field - CheckedTime apijson.Field - CreatedTime apijson.Field - ModifiedTime apijson.Field - Name apijson.Field - Peers apijson.Field - SoaSerial apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSIncomingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSIncomingGetResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSIncomingNewParams struct { - ZoneID param.Field[interface{}] `path:"zone_id,required"` - // How often should a secondary zone auto refresh regardless of DNS NOTIFY. Not - // applicable for primary zones. - AutoRefreshSeconds param.Field[float64] `json:"auto_refresh_seconds,required"` - // Zone name. - Name param.Field[string] `json:"name,required"` - // A list of peer tags. - Peers param.Field[[]interface{}] `json:"peers,required"` -} - -func (r SecondaryDNSIncomingNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SecondaryDNSIncomingNewResponseEnvelope struct { - Errors []SecondaryDNSIncomingNewResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDNSIncomingNewResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSIncomingNewResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDNSIncomingNewResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDNSIncomingNewResponseEnvelopeJSON `json:"-"` -} - -// secondaryDNSIncomingNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [SecondaryDNSIncomingNewResponseEnvelope] -type secondaryDNSIncomingNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSIncomingNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSIncomingNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSIncomingNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSIncomingNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDNSIncomingNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SecondaryDNSIncomingNewResponseEnvelopeErrors] -type secondaryDNSIncomingNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSIncomingNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSIncomingNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSIncomingNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSIncomingNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDNSIncomingNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SecondaryDNSIncomingNewResponseEnvelopeMessages] -type secondaryDNSIncomingNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSIncomingNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSIncomingNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDNSIncomingNewResponseEnvelopeSuccess bool - -const ( - SecondaryDNSIncomingNewResponseEnvelopeSuccessTrue SecondaryDNSIncomingNewResponseEnvelopeSuccess = true -) - -type SecondaryDNSIncomingUpdateParams struct { - ZoneID param.Field[interface{}] `path:"zone_id,required"` - // How often should a secondary zone auto refresh regardless of DNS NOTIFY. Not - // applicable for primary zones. - AutoRefreshSeconds param.Field[float64] `json:"auto_refresh_seconds,required"` - // Zone name. - Name param.Field[string] `json:"name,required"` - // A list of peer tags. - Peers param.Field[[]interface{}] `json:"peers,required"` -} - -func (r SecondaryDNSIncomingUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SecondaryDNSIncomingUpdateResponseEnvelope struct { - Errors []SecondaryDNSIncomingUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDNSIncomingUpdateResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSIncomingUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDNSIncomingUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDNSIncomingUpdateResponseEnvelopeJSON `json:"-"` -} - -// secondaryDNSIncomingUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [SecondaryDNSIncomingUpdateResponseEnvelope] -type secondaryDNSIncomingUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSIncomingUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSIncomingUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSIncomingUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSIncomingUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDNSIncomingUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SecondaryDNSIncomingUpdateResponseEnvelopeErrors] -type secondaryDNSIncomingUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSIncomingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSIncomingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSIncomingUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSIncomingUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDNSIncomingUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SecondaryDNSIncomingUpdateResponseEnvelopeMessages] -type secondaryDNSIncomingUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSIncomingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSIncomingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDNSIncomingUpdateResponseEnvelopeSuccess bool - -const ( - SecondaryDNSIncomingUpdateResponseEnvelopeSuccessTrue SecondaryDNSIncomingUpdateResponseEnvelopeSuccess = true -) - -type SecondaryDNSIncomingDeleteParams struct { - ZoneID param.Field[interface{}] `path:"zone_id,required"` -} - -type SecondaryDNSIncomingDeleteResponseEnvelope struct { - Errors []SecondaryDNSIncomingDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDNSIncomingDeleteResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSIncomingDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDNSIncomingDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDNSIncomingDeleteResponseEnvelopeJSON `json:"-"` -} - -// secondaryDNSIncomingDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [SecondaryDNSIncomingDeleteResponseEnvelope] -type secondaryDNSIncomingDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSIncomingDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSIncomingDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSIncomingDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSIncomingDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDNSIncomingDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SecondaryDNSIncomingDeleteResponseEnvelopeErrors] -type secondaryDNSIncomingDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSIncomingDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSIncomingDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSIncomingDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSIncomingDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDNSIncomingDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SecondaryDNSIncomingDeleteResponseEnvelopeMessages] -type secondaryDNSIncomingDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSIncomingDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSIncomingDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDNSIncomingDeleteResponseEnvelopeSuccess bool - -const ( - SecondaryDNSIncomingDeleteResponseEnvelopeSuccessTrue SecondaryDNSIncomingDeleteResponseEnvelopeSuccess = true -) - -type SecondaryDNSIncomingGetParams struct { - ZoneID param.Field[interface{}] `path:"zone_id,required"` -} - -type SecondaryDNSIncomingGetResponseEnvelope struct { - Errors []SecondaryDNSIncomingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDNSIncomingGetResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSIncomingGetResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDNSIncomingGetResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDNSIncomingGetResponseEnvelopeJSON `json:"-"` -} - -// secondaryDNSIncomingGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [SecondaryDNSIncomingGetResponseEnvelope] -type secondaryDNSIncomingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSIncomingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSIncomingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSIncomingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSIncomingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDNSIncomingGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SecondaryDNSIncomingGetResponseEnvelopeErrors] -type secondaryDNSIncomingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSIncomingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSIncomingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSIncomingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSIncomingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDNSIncomingGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SecondaryDNSIncomingGetResponseEnvelopeMessages] -type secondaryDNSIncomingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSIncomingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSIncomingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDNSIncomingGetResponseEnvelopeSuccess bool - -const ( - SecondaryDNSIncomingGetResponseEnvelopeSuccessTrue SecondaryDNSIncomingGetResponseEnvelopeSuccess = true -) diff --git a/secondarydnsincoming_test.go b/secondarydnsincoming_test.go deleted file mode 100644 index 154a89376c6..00000000000 --- a/secondarydnsincoming_test.go +++ /dev/null @@ -1,124 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSecondaryDNSIncomingNew(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("user@example.com"), - ) - _, err := client.SecondaryDNS.Incoming.New(context.TODO(), cloudflare.SecondaryDNSIncomingNewParams{ - ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), - AutoRefreshSeconds: cloudflare.F(86400.000000), - Name: cloudflare.F("www.example.com."), - Peers: cloudflare.F([]interface{}{"23ff594956f20c2a721606e94745a8aa", "00920f38ce07c2e2f4df50b1f61d4194"}), - }) - 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 TestSecondaryDNSIncomingUpdate(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("user@example.com"), - ) - _, err := client.SecondaryDNS.Incoming.Update(context.TODO(), cloudflare.SecondaryDNSIncomingUpdateParams{ - ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), - AutoRefreshSeconds: cloudflare.F(86400.000000), - Name: cloudflare.F("www.example.com."), - Peers: cloudflare.F([]interface{}{"23ff594956f20c2a721606e94745a8aa", "00920f38ce07c2e2f4df50b1f61d4194"}), - }) - 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 TestSecondaryDNSIncomingDelete(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("user@example.com"), - ) - _, err := client.SecondaryDNS.Incoming.Delete(context.TODO(), cloudflare.SecondaryDNSIncomingDeleteParams{ - ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), - }) - 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 TestSecondaryDNSIncomingGet(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("user@example.com"), - ) - _, err := client.SecondaryDNS.Incoming.Get(context.TODO(), cloudflare.SecondaryDNSIncomingGetParams{ - ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), - }) - 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/secondarydnsoutgoing.go b/secondarydnsoutgoing.go deleted file mode 100644 index e21f7a6628a..00000000000 --- a/secondarydnsoutgoing.go +++ /dev/null @@ -1,880 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SecondaryDNSOutgoingService 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 [NewSecondaryDNSOutgoingService] -// method instead. -type SecondaryDNSOutgoingService struct { - Options []option.RequestOption - Status *SecondaryDNSOutgoingStatusService -} - -// NewSecondaryDNSOutgoingService 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 NewSecondaryDNSOutgoingService(opts ...option.RequestOption) (r *SecondaryDNSOutgoingService) { - r = &SecondaryDNSOutgoingService{} - r.Options = opts - r.Status = NewSecondaryDNSOutgoingStatusService(opts...) - return -} - -// Create primary zone configuration for outgoing zone transfers. -func (r *SecondaryDNSOutgoingService) New(ctx context.Context, params SecondaryDNSOutgoingNewParams, opts ...option.RequestOption) (res *SecondaryDNSOutgoingNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDNSOutgoingNewResponseEnvelope - path := fmt.Sprintf("zones/%v/secondary_dns/outgoing", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update primary zone configuration for outgoing zone transfers. -func (r *SecondaryDNSOutgoingService) Update(ctx context.Context, params SecondaryDNSOutgoingUpdateParams, opts ...option.RequestOption) (res *SecondaryDNSOutgoingUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDNSOutgoingUpdateResponseEnvelope - path := fmt.Sprintf("zones/%v/secondary_dns/outgoing", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete primary zone configuration for outgoing zone transfers. -func (r *SecondaryDNSOutgoingService) Delete(ctx context.Context, body SecondaryDNSOutgoingDeleteParams, opts ...option.RequestOption) (res *SecondaryDNSOutgoingDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDNSOutgoingDeleteResponseEnvelope - path := fmt.Sprintf("zones/%v/secondary_dns/outgoing", body.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Disable outgoing zone transfers for primary zone and clears IXFR backlog of -// primary zone. -func (r *SecondaryDNSOutgoingService) Disable(ctx context.Context, body SecondaryDNSOutgoingDisableParams, opts ...option.RequestOption) (res *string, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDNSOutgoingDisableResponseEnvelope - path := fmt.Sprintf("zones/%v/secondary_dns/outgoing/disable", body.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Enable outgoing zone transfers for primary zone. -func (r *SecondaryDNSOutgoingService) Enable(ctx context.Context, body SecondaryDNSOutgoingEnableParams, opts ...option.RequestOption) (res *string, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDNSOutgoingEnableResponseEnvelope - path := fmt.Sprintf("zones/%v/secondary_dns/outgoing/enable", body.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Notifies the secondary nameserver(s) and clears IXFR backlog of primary zone. -func (r *SecondaryDNSOutgoingService) ForceNotify(ctx context.Context, body SecondaryDNSOutgoingForceNotifyParams, opts ...option.RequestOption) (res *string, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDNSOutgoingForceNotifyResponseEnvelope - path := fmt.Sprintf("zones/%v/secondary_dns/outgoing/force_notify", body.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get primary zone configuration for outgoing zone transfers. -func (r *SecondaryDNSOutgoingService) Get(ctx context.Context, query SecondaryDNSOutgoingGetParams, opts ...option.RequestOption) (res *SecondaryDNSOutgoingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDNSOutgoingGetResponseEnvelope - path := fmt.Sprintf("zones/%v/secondary_dns/outgoing", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SecondaryDNSOutgoingNewResponse struct { - ID interface{} `json:"id"` - // The time for a specific event. - CheckedTime string `json:"checked_time"` - // The time for a specific event. - CreatedTime string `json:"created_time"` - // The time for a specific event. - LastTransferredTime string `json:"last_transferred_time"` - // Zone name. - Name string `json:"name"` - // A list of peer tags. - Peers []interface{} `json:"peers"` - // The serial number of the SOA for the given zone. - SoaSerial float64 `json:"soa_serial"` - JSON secondaryDNSOutgoingNewResponseJSON `json:"-"` -} - -// secondaryDNSOutgoingNewResponseJSON contains the JSON metadata for the struct -// [SecondaryDNSOutgoingNewResponse] -type secondaryDNSOutgoingNewResponseJSON struct { - ID apijson.Field - CheckedTime apijson.Field - CreatedTime apijson.Field - LastTransferredTime apijson.Field - Name apijson.Field - Peers apijson.Field - SoaSerial apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingNewResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingUpdateResponse struct { - ID interface{} `json:"id"` - // The time for a specific event. - CheckedTime string `json:"checked_time"` - // The time for a specific event. - CreatedTime string `json:"created_time"` - // The time for a specific event. - LastTransferredTime string `json:"last_transferred_time"` - // Zone name. - Name string `json:"name"` - // A list of peer tags. - Peers []interface{} `json:"peers"` - // The serial number of the SOA for the given zone. - SoaSerial float64 `json:"soa_serial"` - JSON secondaryDNSOutgoingUpdateResponseJSON `json:"-"` -} - -// secondaryDNSOutgoingUpdateResponseJSON contains the JSON metadata for the struct -// [SecondaryDNSOutgoingUpdateResponse] -type secondaryDNSOutgoingUpdateResponseJSON struct { - ID apijson.Field - CheckedTime apijson.Field - CreatedTime apijson.Field - LastTransferredTime apijson.Field - Name apijson.Field - Peers apijson.Field - SoaSerial apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingDeleteResponse struct { - ID interface{} `json:"id"` - JSON secondaryDNSOutgoingDeleteResponseJSON `json:"-"` -} - -// secondaryDNSOutgoingDeleteResponseJSON contains the JSON metadata for the struct -// [SecondaryDNSOutgoingDeleteResponse] -type secondaryDNSOutgoingDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingGetResponse struct { - ID interface{} `json:"id"` - // The time for a specific event. - CheckedTime string `json:"checked_time"` - // The time for a specific event. - CreatedTime string `json:"created_time"` - // The time for a specific event. - LastTransferredTime string `json:"last_transferred_time"` - // Zone name. - Name string `json:"name"` - // A list of peer tags. - Peers []interface{} `json:"peers"` - // The serial number of the SOA for the given zone. - SoaSerial float64 `json:"soa_serial"` - JSON secondaryDNSOutgoingGetResponseJSON `json:"-"` -} - -// secondaryDNSOutgoingGetResponseJSON contains the JSON metadata for the struct -// [SecondaryDNSOutgoingGetResponse] -type secondaryDNSOutgoingGetResponseJSON struct { - ID apijson.Field - CheckedTime apijson.Field - CreatedTime apijson.Field - LastTransferredTime apijson.Field - Name apijson.Field - Peers apijson.Field - SoaSerial apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingGetResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingNewParams struct { - ZoneID param.Field[interface{}] `path:"zone_id,required"` - // Zone name. - Name param.Field[string] `json:"name,required"` - // A list of peer tags. - Peers param.Field[[]interface{}] `json:"peers,required"` -} - -func (r SecondaryDNSOutgoingNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SecondaryDNSOutgoingNewResponseEnvelope struct { - Errors []SecondaryDNSOutgoingNewResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDNSOutgoingNewResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSOutgoingNewResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDNSOutgoingNewResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDNSOutgoingNewResponseEnvelopeJSON `json:"-"` -} - -// secondaryDNSOutgoingNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [SecondaryDNSOutgoingNewResponseEnvelope] -type secondaryDNSOutgoingNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSOutgoingNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDNSOutgoingNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SecondaryDNSOutgoingNewResponseEnvelopeErrors] -type secondaryDNSOutgoingNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSOutgoingNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDNSOutgoingNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SecondaryDNSOutgoingNewResponseEnvelopeMessages] -type secondaryDNSOutgoingNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDNSOutgoingNewResponseEnvelopeSuccess bool - -const ( - SecondaryDNSOutgoingNewResponseEnvelopeSuccessTrue SecondaryDNSOutgoingNewResponseEnvelopeSuccess = true -) - -type SecondaryDNSOutgoingUpdateParams struct { - ZoneID param.Field[interface{}] `path:"zone_id,required"` - // Zone name. - Name param.Field[string] `json:"name,required"` - // A list of peer tags. - Peers param.Field[[]interface{}] `json:"peers,required"` -} - -func (r SecondaryDNSOutgoingUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SecondaryDNSOutgoingUpdateResponseEnvelope struct { - Errors []SecondaryDNSOutgoingUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDNSOutgoingUpdateResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSOutgoingUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDNSOutgoingUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDNSOutgoingUpdateResponseEnvelopeJSON `json:"-"` -} - -// secondaryDNSOutgoingUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [SecondaryDNSOutgoingUpdateResponseEnvelope] -type secondaryDNSOutgoingUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSOutgoingUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDNSOutgoingUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SecondaryDNSOutgoingUpdateResponseEnvelopeErrors] -type secondaryDNSOutgoingUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSOutgoingUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDNSOutgoingUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SecondaryDNSOutgoingUpdateResponseEnvelopeMessages] -type secondaryDNSOutgoingUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDNSOutgoingUpdateResponseEnvelopeSuccess bool - -const ( - SecondaryDNSOutgoingUpdateResponseEnvelopeSuccessTrue SecondaryDNSOutgoingUpdateResponseEnvelopeSuccess = true -) - -type SecondaryDNSOutgoingDeleteParams struct { - ZoneID param.Field[interface{}] `path:"zone_id,required"` -} - -type SecondaryDNSOutgoingDeleteResponseEnvelope struct { - Errors []SecondaryDNSOutgoingDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDNSOutgoingDeleteResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSOutgoingDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDNSOutgoingDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDNSOutgoingDeleteResponseEnvelopeJSON `json:"-"` -} - -// secondaryDNSOutgoingDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [SecondaryDNSOutgoingDeleteResponseEnvelope] -type secondaryDNSOutgoingDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSOutgoingDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDNSOutgoingDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SecondaryDNSOutgoingDeleteResponseEnvelopeErrors] -type secondaryDNSOutgoingDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSOutgoingDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDNSOutgoingDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SecondaryDNSOutgoingDeleteResponseEnvelopeMessages] -type secondaryDNSOutgoingDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDNSOutgoingDeleteResponseEnvelopeSuccess bool - -const ( - SecondaryDNSOutgoingDeleteResponseEnvelopeSuccessTrue SecondaryDNSOutgoingDeleteResponseEnvelopeSuccess = true -) - -type SecondaryDNSOutgoingDisableParams struct { - ZoneID param.Field[interface{}] `path:"zone_id,required"` -} - -type SecondaryDNSOutgoingDisableResponseEnvelope struct { - Errors []SecondaryDNSOutgoingDisableResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDNSOutgoingDisableResponseEnvelopeMessages `json:"messages,required"` - // The zone transfer status of a primary zone - Result string `json:"result,required"` - // Whether the API call was successful - Success SecondaryDNSOutgoingDisableResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDNSOutgoingDisableResponseEnvelopeJSON `json:"-"` -} - -// secondaryDNSOutgoingDisableResponseEnvelopeJSON contains the JSON metadata for -// the struct [SecondaryDNSOutgoingDisableResponseEnvelope] -type secondaryDNSOutgoingDisableResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingDisableResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingDisableResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingDisableResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSOutgoingDisableResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDNSOutgoingDisableResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SecondaryDNSOutgoingDisableResponseEnvelopeErrors] -type secondaryDNSOutgoingDisableResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingDisableResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingDisableResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingDisableResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSOutgoingDisableResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDNSOutgoingDisableResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SecondaryDNSOutgoingDisableResponseEnvelopeMessages] -type secondaryDNSOutgoingDisableResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingDisableResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingDisableResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDNSOutgoingDisableResponseEnvelopeSuccess bool - -const ( - SecondaryDNSOutgoingDisableResponseEnvelopeSuccessTrue SecondaryDNSOutgoingDisableResponseEnvelopeSuccess = true -) - -type SecondaryDNSOutgoingEnableParams struct { - ZoneID param.Field[interface{}] `path:"zone_id,required"` -} - -type SecondaryDNSOutgoingEnableResponseEnvelope struct { - Errors []SecondaryDNSOutgoingEnableResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDNSOutgoingEnableResponseEnvelopeMessages `json:"messages,required"` - // The zone transfer status of a primary zone - Result string `json:"result,required"` - // Whether the API call was successful - Success SecondaryDNSOutgoingEnableResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDNSOutgoingEnableResponseEnvelopeJSON `json:"-"` -} - -// secondaryDNSOutgoingEnableResponseEnvelopeJSON contains the JSON metadata for -// the struct [SecondaryDNSOutgoingEnableResponseEnvelope] -type secondaryDNSOutgoingEnableResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingEnableResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingEnableResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingEnableResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSOutgoingEnableResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDNSOutgoingEnableResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SecondaryDNSOutgoingEnableResponseEnvelopeErrors] -type secondaryDNSOutgoingEnableResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingEnableResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingEnableResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingEnableResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSOutgoingEnableResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDNSOutgoingEnableResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SecondaryDNSOutgoingEnableResponseEnvelopeMessages] -type secondaryDNSOutgoingEnableResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingEnableResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingEnableResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDNSOutgoingEnableResponseEnvelopeSuccess bool - -const ( - SecondaryDNSOutgoingEnableResponseEnvelopeSuccessTrue SecondaryDNSOutgoingEnableResponseEnvelopeSuccess = true -) - -type SecondaryDNSOutgoingForceNotifyParams struct { - ZoneID param.Field[interface{}] `path:"zone_id,required"` -} - -type SecondaryDNSOutgoingForceNotifyResponseEnvelope struct { - Errors []SecondaryDNSOutgoingForceNotifyResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDNSOutgoingForceNotifyResponseEnvelopeMessages `json:"messages,required"` - // When force_notify query parameter is set to true, the response is a simple - // string - Result string `json:"result,required"` - // Whether the API call was successful - Success SecondaryDNSOutgoingForceNotifyResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDNSOutgoingForceNotifyResponseEnvelopeJSON `json:"-"` -} - -// secondaryDNSOutgoingForceNotifyResponseEnvelopeJSON contains the JSON metadata -// for the struct [SecondaryDNSOutgoingForceNotifyResponseEnvelope] -type secondaryDNSOutgoingForceNotifyResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingForceNotifyResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingForceNotifyResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingForceNotifyResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSOutgoingForceNotifyResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDNSOutgoingForceNotifyResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [SecondaryDNSOutgoingForceNotifyResponseEnvelopeErrors] -type secondaryDNSOutgoingForceNotifyResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingForceNotifyResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingForceNotifyResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingForceNotifyResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSOutgoingForceNotifyResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDNSOutgoingForceNotifyResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [SecondaryDNSOutgoingForceNotifyResponseEnvelopeMessages] -type secondaryDNSOutgoingForceNotifyResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingForceNotifyResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingForceNotifyResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDNSOutgoingForceNotifyResponseEnvelopeSuccess bool - -const ( - SecondaryDNSOutgoingForceNotifyResponseEnvelopeSuccessTrue SecondaryDNSOutgoingForceNotifyResponseEnvelopeSuccess = true -) - -type SecondaryDNSOutgoingGetParams struct { - ZoneID param.Field[interface{}] `path:"zone_id,required"` -} - -type SecondaryDNSOutgoingGetResponseEnvelope struct { - Errors []SecondaryDNSOutgoingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDNSOutgoingGetResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSOutgoingGetResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDNSOutgoingGetResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDNSOutgoingGetResponseEnvelopeJSON `json:"-"` -} - -// secondaryDNSOutgoingGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [SecondaryDNSOutgoingGetResponseEnvelope] -type secondaryDNSOutgoingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSOutgoingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDNSOutgoingGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SecondaryDNSOutgoingGetResponseEnvelopeErrors] -type secondaryDNSOutgoingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSOutgoingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDNSOutgoingGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SecondaryDNSOutgoingGetResponseEnvelopeMessages] -type secondaryDNSOutgoingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDNSOutgoingGetResponseEnvelopeSuccess bool - -const ( - SecondaryDNSOutgoingGetResponseEnvelopeSuccessTrue SecondaryDNSOutgoingGetResponseEnvelopeSuccess = true -) diff --git a/secondarydnsoutgoing_test.go b/secondarydnsoutgoing_test.go deleted file mode 100644 index 726aa121a33..00000000000 --- a/secondarydnsoutgoing_test.go +++ /dev/null @@ -1,200 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSecondaryDNSOutgoingNew(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("user@example.com"), - ) - _, err := client.SecondaryDNS.Outgoing.New(context.TODO(), cloudflare.SecondaryDNSOutgoingNewParams{ - ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), - Name: cloudflare.F("www.example.com."), - Peers: cloudflare.F([]interface{}{"23ff594956f20c2a721606e94745a8aa", "00920f38ce07c2e2f4df50b1f61d4194"}), - }) - 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 TestSecondaryDNSOutgoingUpdate(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("user@example.com"), - ) - _, err := client.SecondaryDNS.Outgoing.Update(context.TODO(), cloudflare.SecondaryDNSOutgoingUpdateParams{ - ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), - Name: cloudflare.F("www.example.com."), - Peers: cloudflare.F([]interface{}{"23ff594956f20c2a721606e94745a8aa", "00920f38ce07c2e2f4df50b1f61d4194"}), - }) - 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 TestSecondaryDNSOutgoingDelete(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("user@example.com"), - ) - _, err := client.SecondaryDNS.Outgoing.Delete(context.TODO(), cloudflare.SecondaryDNSOutgoingDeleteParams{ - ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), - }) - 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 TestSecondaryDNSOutgoingDisable(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("user@example.com"), - ) - _, err := client.SecondaryDNS.Outgoing.Disable(context.TODO(), cloudflare.SecondaryDNSOutgoingDisableParams{ - ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), - }) - 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 TestSecondaryDNSOutgoingEnable(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("user@example.com"), - ) - _, err := client.SecondaryDNS.Outgoing.Enable(context.TODO(), cloudflare.SecondaryDNSOutgoingEnableParams{ - ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), - }) - 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 TestSecondaryDNSOutgoingForceNotify(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("user@example.com"), - ) - _, err := client.SecondaryDNS.Outgoing.ForceNotify(context.TODO(), cloudflare.SecondaryDNSOutgoingForceNotifyParams{ - ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), - }) - 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 TestSecondaryDNSOutgoingGet(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("user@example.com"), - ) - _, err := client.SecondaryDNS.Outgoing.Get(context.TODO(), cloudflare.SecondaryDNSOutgoingGetParams{ - ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), - }) - 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/secondarydnsoutgoingstatus.go b/secondarydnsoutgoingstatus.go deleted file mode 100644 index fad0d6624a7..00000000000 --- a/secondarydnsoutgoingstatus.go +++ /dev/null @@ -1,131 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SecondaryDNSOutgoingStatusService 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 -// [NewSecondaryDNSOutgoingStatusService] method instead. -type SecondaryDNSOutgoingStatusService struct { - Options []option.RequestOption -} - -// NewSecondaryDNSOutgoingStatusService 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 NewSecondaryDNSOutgoingStatusService(opts ...option.RequestOption) (r *SecondaryDNSOutgoingStatusService) { - r = &SecondaryDNSOutgoingStatusService{} - r.Options = opts - return -} - -// Get primary zone transfer status. -func (r *SecondaryDNSOutgoingStatusService) Get(ctx context.Context, query SecondaryDNSOutgoingStatusGetParams, opts ...option.RequestOption) (res *string, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDNSOutgoingStatusGetResponseEnvelope - path := fmt.Sprintf("zones/%v/secondary_dns/outgoing/status", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SecondaryDNSOutgoingStatusGetParams struct { - ZoneID param.Field[interface{}] `path:"zone_id,required"` -} - -type SecondaryDNSOutgoingStatusGetResponseEnvelope struct { - Errors []SecondaryDNSOutgoingStatusGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDNSOutgoingStatusGetResponseEnvelopeMessages `json:"messages,required"` - // The zone transfer status of a primary zone - Result string `json:"result,required"` - // Whether the API call was successful - Success SecondaryDNSOutgoingStatusGetResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDNSOutgoingStatusGetResponseEnvelopeJSON `json:"-"` -} - -// secondaryDNSOutgoingStatusGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [SecondaryDNSOutgoingStatusGetResponseEnvelope] -type secondaryDNSOutgoingStatusGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingStatusGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingStatusGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingStatusGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSOutgoingStatusGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDNSOutgoingStatusGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [SecondaryDNSOutgoingStatusGetResponseEnvelopeErrors] -type secondaryDNSOutgoingStatusGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingStatusGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingStatusGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSOutgoingStatusGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSOutgoingStatusGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDNSOutgoingStatusGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SecondaryDNSOutgoingStatusGetResponseEnvelopeMessages] -type secondaryDNSOutgoingStatusGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSOutgoingStatusGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSOutgoingStatusGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDNSOutgoingStatusGetResponseEnvelopeSuccess bool - -const ( - SecondaryDNSOutgoingStatusGetResponseEnvelopeSuccessTrue SecondaryDNSOutgoingStatusGetResponseEnvelopeSuccess = true -) diff --git a/secondarydnsoutgoingstatus_test.go b/secondarydnsoutgoingstatus_test.go deleted file mode 100644 index 0a115ff8d3e..00000000000 --- a/secondarydnsoutgoingstatus_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSecondaryDNSOutgoingStatusGet(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("user@example.com"), - ) - _, err := client.SecondaryDNS.Outgoing.Status.Get(context.TODO(), cloudflare.SecondaryDNSOutgoingStatusGetParams{ - ZoneID: cloudflare.F[any]("269d8f4853475ca241c4e730be286b20"), - }) - 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/secondarydnspeer.go b/secondarydnspeer.go deleted file mode 100644 index ada4f3dac10..00000000000 --- a/secondarydnspeer.go +++ /dev/null @@ -1,769 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SecondaryDNSPeerService 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 [NewSecondaryDNSPeerService] method -// instead. -type SecondaryDNSPeerService struct { - Options []option.RequestOption -} - -// NewSecondaryDNSPeerService 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 NewSecondaryDNSPeerService(opts ...option.RequestOption) (r *SecondaryDNSPeerService) { - r = &SecondaryDNSPeerService{} - r.Options = opts - return -} - -// Create Peer. -func (r *SecondaryDNSPeerService) New(ctx context.Context, params SecondaryDNSPeerNewParams, opts ...option.RequestOption) (res *SecondaryDNSPeerNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDNSPeerNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/secondary_dns/peers", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Modify Peer. -func (r *SecondaryDNSPeerService) Update(ctx context.Context, peerID interface{}, params SecondaryDNSPeerUpdateParams, opts ...option.RequestOption) (res *SecondaryDNSPeerUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDNSPeerUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/secondary_dns/peers/%v", params.AccountID, peerID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List Peers. -func (r *SecondaryDNSPeerService) List(ctx context.Context, query SecondaryDNSPeerListParams, opts ...option.RequestOption) (res *[]SecondaryDNSPeerListResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDNSPeerListResponseEnvelope - path := fmt.Sprintf("accounts/%v/secondary_dns/peers", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete Peer. -func (r *SecondaryDNSPeerService) Delete(ctx context.Context, peerID interface{}, body SecondaryDNSPeerDeleteParams, opts ...option.RequestOption) (res *SecondaryDNSPeerDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDNSPeerDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%v/secondary_dns/peers/%v", body.AccountID, peerID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get Peer. -func (r *SecondaryDNSPeerService) Get(ctx context.Context, peerID interface{}, query SecondaryDNSPeerGetParams, opts ...option.RequestOption) (res *SecondaryDNSPeerGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDNSPeerGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/secondary_dns/peers/%v", query.AccountID, peerID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SecondaryDNSPeerNewResponse struct { - ID interface{} `json:"id,required"` - // The name of the peer. - Name string `json:"name,required"` - // IPv4/IPv6 address of primary or secondary nameserver, depending on what zone - // this peer is linked to. For primary zones this IP defines the IP of the - // secondary nameserver Cloudflare will NOTIFY upon zone changes. For secondary - // zones this IP defines the IP of the primary nameserver Cloudflare will send - // AXFR/IXFR requests to. - IP string `json:"ip"` - // Enable IXFR transfer protocol, default is AXFR. Only applicable to secondary - // zones. - IxfrEnable bool `json:"ixfr_enable"` - // DNS port of primary or secondary nameserver, depending on what zone this peer is - // linked to. - Port float64 `json:"port"` - // TSIG authentication will be used for zone transfer if configured. - TSIGID string `json:"tsig_id"` - JSON secondaryDNSPeerNewResponseJSON `json:"-"` -} - -// secondaryDNSPeerNewResponseJSON contains the JSON metadata for the struct -// [SecondaryDNSPeerNewResponse] -type secondaryDNSPeerNewResponseJSON struct { - ID apijson.Field - Name apijson.Field - IP apijson.Field - IxfrEnable apijson.Field - Port apijson.Field - TSIGID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerNewResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSPeerUpdateResponse struct { - ID interface{} `json:"id,required"` - // The name of the peer. - Name string `json:"name,required"` - // IPv4/IPv6 address of primary or secondary nameserver, depending on what zone - // this peer is linked to. For primary zones this IP defines the IP of the - // secondary nameserver Cloudflare will NOTIFY upon zone changes. For secondary - // zones this IP defines the IP of the primary nameserver Cloudflare will send - // AXFR/IXFR requests to. - IP string `json:"ip"` - // Enable IXFR transfer protocol, default is AXFR. Only applicable to secondary - // zones. - IxfrEnable bool `json:"ixfr_enable"` - // DNS port of primary or secondary nameserver, depending on what zone this peer is - // linked to. - Port float64 `json:"port"` - // TSIG authentication will be used for zone transfer if configured. - TSIGID string `json:"tsig_id"` - JSON secondaryDNSPeerUpdateResponseJSON `json:"-"` -} - -// secondaryDNSPeerUpdateResponseJSON contains the JSON metadata for the struct -// [SecondaryDNSPeerUpdateResponse] -type secondaryDNSPeerUpdateResponseJSON struct { - ID apijson.Field - Name apijson.Field - IP apijson.Field - IxfrEnable apijson.Field - Port apijson.Field - TSIGID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSPeerListResponse struct { - ID interface{} `json:"id,required"` - // The name of the peer. - Name string `json:"name,required"` - // IPv4/IPv6 address of primary or secondary nameserver, depending on what zone - // this peer is linked to. For primary zones this IP defines the IP of the - // secondary nameserver Cloudflare will NOTIFY upon zone changes. For secondary - // zones this IP defines the IP of the primary nameserver Cloudflare will send - // AXFR/IXFR requests to. - IP string `json:"ip"` - // Enable IXFR transfer protocol, default is AXFR. Only applicable to secondary - // zones. - IxfrEnable bool `json:"ixfr_enable"` - // DNS port of primary or secondary nameserver, depending on what zone this peer is - // linked to. - Port float64 `json:"port"` - // TSIG authentication will be used for zone transfer if configured. - TSIGID string `json:"tsig_id"` - JSON secondaryDNSPeerListResponseJSON `json:"-"` -} - -// secondaryDNSPeerListResponseJSON contains the JSON metadata for the struct -// [SecondaryDNSPeerListResponse] -type secondaryDNSPeerListResponseJSON struct { - ID apijson.Field - Name apijson.Field - IP apijson.Field - IxfrEnable apijson.Field - Port apijson.Field - TSIGID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerListResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSPeerDeleteResponse struct { - ID interface{} `json:"id"` - JSON secondaryDNSPeerDeleteResponseJSON `json:"-"` -} - -// secondaryDNSPeerDeleteResponseJSON contains the JSON metadata for the struct -// [SecondaryDNSPeerDeleteResponse] -type secondaryDNSPeerDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSPeerGetResponse struct { - ID interface{} `json:"id,required"` - // The name of the peer. - Name string `json:"name,required"` - // IPv4/IPv6 address of primary or secondary nameserver, depending on what zone - // this peer is linked to. For primary zones this IP defines the IP of the - // secondary nameserver Cloudflare will NOTIFY upon zone changes. For secondary - // zones this IP defines the IP of the primary nameserver Cloudflare will send - // AXFR/IXFR requests to. - IP string `json:"ip"` - // Enable IXFR transfer protocol, default is AXFR. Only applicable to secondary - // zones. - IxfrEnable bool `json:"ixfr_enable"` - // DNS port of primary or secondary nameserver, depending on what zone this peer is - // linked to. - Port float64 `json:"port"` - // TSIG authentication will be used for zone transfer if configured. - TSIGID string `json:"tsig_id"` - JSON secondaryDNSPeerGetResponseJSON `json:"-"` -} - -// secondaryDNSPeerGetResponseJSON contains the JSON metadata for the struct -// [SecondaryDNSPeerGetResponse] -type secondaryDNSPeerGetResponseJSON struct { - ID apijson.Field - Name apijson.Field - IP apijson.Field - IxfrEnable apijson.Field - Port apijson.Field - TSIGID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerGetResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSPeerNewParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` -} - -func (r SecondaryDNSPeerNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type SecondaryDNSPeerNewResponseEnvelope struct { - Errors []SecondaryDNSPeerNewResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDNSPeerNewResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSPeerNewResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDNSPeerNewResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDNSPeerNewResponseEnvelopeJSON `json:"-"` -} - -// secondaryDNSPeerNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [SecondaryDNSPeerNewResponseEnvelope] -type secondaryDNSPeerNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSPeerNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSPeerNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDNSPeerNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SecondaryDNSPeerNewResponseEnvelopeErrors] -type secondaryDNSPeerNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSPeerNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSPeerNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDNSPeerNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SecondaryDNSPeerNewResponseEnvelopeMessages] -type secondaryDNSPeerNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDNSPeerNewResponseEnvelopeSuccess bool - -const ( - SecondaryDNSPeerNewResponseEnvelopeSuccessTrue SecondaryDNSPeerNewResponseEnvelopeSuccess = true -) - -type SecondaryDNSPeerUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // The name of the peer. - Name param.Field[string] `json:"name,required"` - // IPv4/IPv6 address of primary or secondary nameserver, depending on what zone - // this peer is linked to. For primary zones this IP defines the IP of the - // secondary nameserver Cloudflare will NOTIFY upon zone changes. For secondary - // zones this IP defines the IP of the primary nameserver Cloudflare will send - // AXFR/IXFR requests to. - IP param.Field[string] `json:"ip"` - // Enable IXFR transfer protocol, default is AXFR. Only applicable to secondary - // zones. - IxfrEnable param.Field[bool] `json:"ixfr_enable"` - // DNS port of primary or secondary nameserver, depending on what zone this peer is - // linked to. - Port param.Field[float64] `json:"port"` - // TSIG authentication will be used for zone transfer if configured. - TSIGID param.Field[string] `json:"tsig_id"` -} - -func (r SecondaryDNSPeerUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SecondaryDNSPeerUpdateResponseEnvelope struct { - Errors []SecondaryDNSPeerUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDNSPeerUpdateResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSPeerUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDNSPeerUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDNSPeerUpdateResponseEnvelopeJSON `json:"-"` -} - -// secondaryDNSPeerUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [SecondaryDNSPeerUpdateResponseEnvelope] -type secondaryDNSPeerUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSPeerUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSPeerUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDNSPeerUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SecondaryDNSPeerUpdateResponseEnvelopeErrors] -type secondaryDNSPeerUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSPeerUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSPeerUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDNSPeerUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SecondaryDNSPeerUpdateResponseEnvelopeMessages] -type secondaryDNSPeerUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDNSPeerUpdateResponseEnvelopeSuccess bool - -const ( - SecondaryDNSPeerUpdateResponseEnvelopeSuccessTrue SecondaryDNSPeerUpdateResponseEnvelopeSuccess = true -) - -type SecondaryDNSPeerListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type SecondaryDNSPeerListResponseEnvelope struct { - Errors []SecondaryDNSPeerListResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDNSPeerListResponseEnvelopeMessages `json:"messages,required"` - Result []SecondaryDNSPeerListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success SecondaryDNSPeerListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo SecondaryDNSPeerListResponseEnvelopeResultInfo `json:"result_info"` - JSON secondaryDNSPeerListResponseEnvelopeJSON `json:"-"` -} - -// secondaryDNSPeerListResponseEnvelopeJSON contains the JSON metadata for the -// struct [SecondaryDNSPeerListResponseEnvelope] -type secondaryDNSPeerListResponseEnvelopeJSON 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 *SecondaryDNSPeerListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSPeerListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSPeerListResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDNSPeerListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SecondaryDNSPeerListResponseEnvelopeErrors] -type secondaryDNSPeerListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSPeerListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSPeerListResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDNSPeerListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SecondaryDNSPeerListResponseEnvelopeMessages] -type secondaryDNSPeerListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDNSPeerListResponseEnvelopeSuccess bool - -const ( - SecondaryDNSPeerListResponseEnvelopeSuccessTrue SecondaryDNSPeerListResponseEnvelopeSuccess = true -) - -type SecondaryDNSPeerListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON secondaryDNSPeerListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// secondaryDNSPeerListResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [SecondaryDNSPeerListResponseEnvelopeResultInfo] -type secondaryDNSPeerListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSPeerDeleteParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type SecondaryDNSPeerDeleteResponseEnvelope struct { - Errors []SecondaryDNSPeerDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDNSPeerDeleteResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSPeerDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDNSPeerDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDNSPeerDeleteResponseEnvelopeJSON `json:"-"` -} - -// secondaryDNSPeerDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [SecondaryDNSPeerDeleteResponseEnvelope] -type secondaryDNSPeerDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSPeerDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSPeerDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDNSPeerDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SecondaryDNSPeerDeleteResponseEnvelopeErrors] -type secondaryDNSPeerDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSPeerDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSPeerDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDNSPeerDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SecondaryDNSPeerDeleteResponseEnvelopeMessages] -type secondaryDNSPeerDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDNSPeerDeleteResponseEnvelopeSuccess bool - -const ( - SecondaryDNSPeerDeleteResponseEnvelopeSuccessTrue SecondaryDNSPeerDeleteResponseEnvelopeSuccess = true -) - -type SecondaryDNSPeerGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type SecondaryDNSPeerGetResponseEnvelope struct { - Errors []SecondaryDNSPeerGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDNSPeerGetResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDNSPeerGetResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDNSPeerGetResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDNSPeerGetResponseEnvelopeJSON `json:"-"` -} - -// secondaryDNSPeerGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [SecondaryDNSPeerGetResponseEnvelope] -type secondaryDNSPeerGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSPeerGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSPeerGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDNSPeerGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SecondaryDNSPeerGetResponseEnvelopeErrors] -type secondaryDNSPeerGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSPeerGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDNSPeerGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDNSPeerGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SecondaryDNSPeerGetResponseEnvelopeMessages] -type secondaryDNSPeerGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDNSPeerGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDNSPeerGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDNSPeerGetResponseEnvelopeSuccess bool - -const ( - SecondaryDNSPeerGetResponseEnvelopeSuccessTrue SecondaryDNSPeerGetResponseEnvelopeSuccess = true -) diff --git a/secondarydnspeer_test.go b/secondarydnspeer_test.go deleted file mode 100644 index 21bceae83f5..00000000000 --- a/secondarydnspeer_test.go +++ /dev/null @@ -1,162 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSecondaryDNSPeerNew(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("user@example.com"), - ) - _, err := client.SecondaryDNS.Peers.New(context.TODO(), cloudflare.SecondaryDNSPeerNewParams{ - AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), - Body: cloudflare.F[any](map[string]interface{}{}), - }) - 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 TestSecondaryDNSPeerUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.SecondaryDNS.Peers.Update( - context.TODO(), - "23ff594956f20c2a721606e94745a8aa", - cloudflare.SecondaryDNSPeerUpdateParams{ - AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), - Name: cloudflare.F("my-peer-1"), - IP: cloudflare.F("192.0.2.53"), - IxfrEnable: cloudflare.F(false), - Port: cloudflare.F(53.000000), - TSIGID: cloudflare.F("69cd1e104af3e6ed3cb344f263fd0d5a"), - }, - ) - 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 TestSecondaryDNSPeerList(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("user@example.com"), - ) - _, err := client.SecondaryDNS.Peers.List(context.TODO(), cloudflare.SecondaryDNSPeerListParams{ - AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), - }) - 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 TestSecondaryDNSPeerDelete(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("user@example.com"), - ) - _, err := client.SecondaryDNS.Peers.Delete( - context.TODO(), - "23ff594956f20c2a721606e94745a8aa", - cloudflare.SecondaryDNSPeerDeleteParams{ - AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), - }, - ) - 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 TestSecondaryDNSPeerGet(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("user@example.com"), - ) - _, err := client.SecondaryDNS.Peers.Get( - context.TODO(), - "23ff594956f20c2a721606e94745a8aa", - cloudflare.SecondaryDNSPeerGetParams{ - AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), - }, - ) - 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/secondarydnstsig.go b/secondarydnstsig.go deleted file mode 100644 index 13205e13abb..00000000000 --- a/secondarydnstsig.go +++ /dev/null @@ -1,716 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SecondaryDNSTSIGService 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 [NewSecondaryDNSTSIGService] method -// instead. -type SecondaryDNSTSIGService struct { - Options []option.RequestOption -} - -// NewSecondaryDNSTSIGService 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 NewSecondaryDNSTSIGService(opts ...option.RequestOption) (r *SecondaryDNSTSIGService) { - r = &SecondaryDNSTSIGService{} - r.Options = opts - return -} - -// Create TSIG. -func (r *SecondaryDNSTSIGService) New(ctx context.Context, params SecondaryDNSTSIGNewParams, opts ...option.RequestOption) (res *SecondaryDnstsigNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDnstsigNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/secondary_dns/tsigs", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Modify TSIG. -func (r *SecondaryDNSTSIGService) Update(ctx context.Context, tsigID interface{}, params SecondaryDNSTSIGUpdateParams, opts ...option.RequestOption) (res *SecondaryDnstsigUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDnstsigUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/secondary_dns/tsigs/%v", params.AccountID, tsigID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List TSIGs. -func (r *SecondaryDNSTSIGService) List(ctx context.Context, query SecondaryDNSTSIGListParams, opts ...option.RequestOption) (res *[]SecondaryDnstsigListResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDnstsigListResponseEnvelope - path := fmt.Sprintf("accounts/%v/secondary_dns/tsigs", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete TSIG. -func (r *SecondaryDNSTSIGService) Delete(ctx context.Context, tsigID interface{}, body SecondaryDNSTSIGDeleteParams, opts ...option.RequestOption) (res *SecondaryDnstsigDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDnstsigDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%v/secondary_dns/tsigs/%v", body.AccountID, tsigID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get TSIG. -func (r *SecondaryDNSTSIGService) Get(ctx context.Context, tsigID interface{}, query SecondaryDNSTSIGGetParams, opts ...option.RequestOption) (res *SecondaryDnstsigGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env SecondaryDnstsigGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/secondary_dns/tsigs/%v", query.AccountID, tsigID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SecondaryDnstsigNewResponse struct { - ID interface{} `json:"id,required"` - // TSIG algorithm. - Algo string `json:"algo,required"` - // TSIG key name. - Name string `json:"name,required"` - // TSIG secret. - Secret string `json:"secret,required"` - JSON secondaryDnstsigNewResponseJSON `json:"-"` -} - -// secondaryDnstsigNewResponseJSON contains the JSON metadata for the struct -// [SecondaryDnstsigNewResponse] -type secondaryDnstsigNewResponseJSON struct { - ID apijson.Field - Algo apijson.Field - Name apijson.Field - Secret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigNewResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnstsigUpdateResponse struct { - ID interface{} `json:"id,required"` - // TSIG algorithm. - Algo string `json:"algo,required"` - // TSIG key name. - Name string `json:"name,required"` - // TSIG secret. - Secret string `json:"secret,required"` - JSON secondaryDnstsigUpdateResponseJSON `json:"-"` -} - -// secondaryDnstsigUpdateResponseJSON contains the JSON metadata for the struct -// [SecondaryDnstsigUpdateResponse] -type secondaryDnstsigUpdateResponseJSON struct { - ID apijson.Field - Algo apijson.Field - Name apijson.Field - Secret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnstsigListResponse struct { - ID interface{} `json:"id,required"` - // TSIG algorithm. - Algo string `json:"algo,required"` - // TSIG key name. - Name string `json:"name,required"` - // TSIG secret. - Secret string `json:"secret,required"` - JSON secondaryDnstsigListResponseJSON `json:"-"` -} - -// secondaryDnstsigListResponseJSON contains the JSON metadata for the struct -// [SecondaryDnstsigListResponse] -type secondaryDnstsigListResponseJSON struct { - ID apijson.Field - Algo apijson.Field - Name apijson.Field - Secret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigListResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnstsigDeleteResponse struct { - ID interface{} `json:"id"` - JSON secondaryDnstsigDeleteResponseJSON `json:"-"` -} - -// secondaryDnstsigDeleteResponseJSON contains the JSON metadata for the struct -// [SecondaryDnstsigDeleteResponse] -type secondaryDnstsigDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnstsigGetResponse struct { - ID interface{} `json:"id,required"` - // TSIG algorithm. - Algo string `json:"algo,required"` - // TSIG key name. - Name string `json:"name,required"` - // TSIG secret. - Secret string `json:"secret,required"` - JSON secondaryDnstsigGetResponseJSON `json:"-"` -} - -// secondaryDnstsigGetResponseJSON contains the JSON metadata for the struct -// [SecondaryDnstsigGetResponse] -type secondaryDnstsigGetResponseJSON struct { - ID apijson.Field - Algo apijson.Field - Name apijson.Field - Secret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigGetResponseJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSTSIGNewParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // TSIG algorithm. - Algo param.Field[string] `json:"algo,required"` - // TSIG key name. - Name param.Field[string] `json:"name,required"` - // TSIG secret. - Secret param.Field[string] `json:"secret,required"` -} - -func (r SecondaryDNSTSIGNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SecondaryDnstsigNewResponseEnvelope struct { - Errors []SecondaryDnstsigNewResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDnstsigNewResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDnstsigNewResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDnstsigNewResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDnstsigNewResponseEnvelopeJSON `json:"-"` -} - -// secondaryDnstsigNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [SecondaryDnstsigNewResponseEnvelope] -type secondaryDnstsigNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnstsigNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnstsigNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDnstsigNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SecondaryDnstsigNewResponseEnvelopeErrors] -type secondaryDnstsigNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnstsigNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnstsigNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDnstsigNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SecondaryDnstsigNewResponseEnvelopeMessages] -type secondaryDnstsigNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDnstsigNewResponseEnvelopeSuccess bool - -const ( - SecondaryDnstsigNewResponseEnvelopeSuccessTrue SecondaryDnstsigNewResponseEnvelopeSuccess = true -) - -type SecondaryDNSTSIGUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // TSIG algorithm. - Algo param.Field[string] `json:"algo,required"` - // TSIG key name. - Name param.Field[string] `json:"name,required"` - // TSIG secret. - Secret param.Field[string] `json:"secret,required"` -} - -func (r SecondaryDNSTSIGUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SecondaryDnstsigUpdateResponseEnvelope struct { - Errors []SecondaryDnstsigUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDnstsigUpdateResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDnstsigUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDnstsigUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDnstsigUpdateResponseEnvelopeJSON `json:"-"` -} - -// secondaryDnstsigUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [SecondaryDnstsigUpdateResponseEnvelope] -type secondaryDnstsigUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnstsigUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnstsigUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDnstsigUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SecondaryDnstsigUpdateResponseEnvelopeErrors] -type secondaryDnstsigUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnstsigUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnstsigUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDnstsigUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SecondaryDnstsigUpdateResponseEnvelopeMessages] -type secondaryDnstsigUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDnstsigUpdateResponseEnvelopeSuccess bool - -const ( - SecondaryDnstsigUpdateResponseEnvelopeSuccessTrue SecondaryDnstsigUpdateResponseEnvelopeSuccess = true -) - -type SecondaryDNSTSIGListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type SecondaryDnstsigListResponseEnvelope struct { - Errors []SecondaryDnstsigListResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDnstsigListResponseEnvelopeMessages `json:"messages,required"` - Result []SecondaryDnstsigListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success SecondaryDnstsigListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo SecondaryDnstsigListResponseEnvelopeResultInfo `json:"result_info"` - JSON secondaryDnstsigListResponseEnvelopeJSON `json:"-"` -} - -// secondaryDnstsigListResponseEnvelopeJSON contains the JSON metadata for the -// struct [SecondaryDnstsigListResponseEnvelope] -type secondaryDnstsigListResponseEnvelopeJSON 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 *SecondaryDnstsigListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnstsigListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnstsigListResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDnstsigListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SecondaryDnstsigListResponseEnvelopeErrors] -type secondaryDnstsigListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnstsigListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnstsigListResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDnstsigListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SecondaryDnstsigListResponseEnvelopeMessages] -type secondaryDnstsigListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDnstsigListResponseEnvelopeSuccess bool - -const ( - SecondaryDnstsigListResponseEnvelopeSuccessTrue SecondaryDnstsigListResponseEnvelopeSuccess = true -) - -type SecondaryDnstsigListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON secondaryDnstsigListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// secondaryDnstsigListResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [SecondaryDnstsigListResponseEnvelopeResultInfo] -type secondaryDnstsigListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type SecondaryDNSTSIGDeleteParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type SecondaryDnstsigDeleteResponseEnvelope struct { - Errors []SecondaryDnstsigDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDnstsigDeleteResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDnstsigDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDnstsigDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDnstsigDeleteResponseEnvelopeJSON `json:"-"` -} - -// secondaryDnstsigDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [SecondaryDnstsigDeleteResponseEnvelope] -type secondaryDnstsigDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnstsigDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnstsigDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDnstsigDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SecondaryDnstsigDeleteResponseEnvelopeErrors] -type secondaryDnstsigDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnstsigDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnstsigDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDnstsigDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SecondaryDnstsigDeleteResponseEnvelopeMessages] -type secondaryDnstsigDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDnstsigDeleteResponseEnvelopeSuccess bool - -const ( - SecondaryDnstsigDeleteResponseEnvelopeSuccessTrue SecondaryDnstsigDeleteResponseEnvelopeSuccess = true -) - -type SecondaryDNSTSIGGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type SecondaryDnstsigGetResponseEnvelope struct { - Errors []SecondaryDnstsigGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SecondaryDnstsigGetResponseEnvelopeMessages `json:"messages,required"` - Result SecondaryDnstsigGetResponse `json:"result,required"` - // Whether the API call was successful - Success SecondaryDnstsigGetResponseEnvelopeSuccess `json:"success,required"` - JSON secondaryDnstsigGetResponseEnvelopeJSON `json:"-"` -} - -// secondaryDnstsigGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [SecondaryDnstsigGetResponseEnvelope] -type secondaryDnstsigGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnstsigGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnstsigGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// secondaryDnstsigGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SecondaryDnstsigGetResponseEnvelopeErrors] -type secondaryDnstsigGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SecondaryDnstsigGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON secondaryDnstsigGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// secondaryDnstsigGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SecondaryDnstsigGetResponseEnvelopeMessages] -type secondaryDnstsigGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SecondaryDnstsigGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r secondaryDnstsigGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SecondaryDnstsigGetResponseEnvelopeSuccess bool - -const ( - SecondaryDnstsigGetResponseEnvelopeSuccessTrue SecondaryDnstsigGetResponseEnvelopeSuccess = true -) diff --git a/secondarydnstsig_test.go b/secondarydnstsig_test.go deleted file mode 100644 index 2d3b8c0492d..00000000000 --- a/secondarydnstsig_test.go +++ /dev/null @@ -1,162 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSecondaryDNSTSIGNew(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("user@example.com"), - ) - _, err := client.SecondaryDNS.TSIGs.New(context.TODO(), cloudflare.SecondaryDNSTSIGNewParams{ - AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), - Algo: cloudflare.F("hmac-sha512."), - Name: cloudflare.F("tsig.customer.cf."), - Secret: cloudflare.F("caf79a7804b04337c9c66ccd7bef9190a1e1679b5dd03d8aa10f7ad45e1a9dab92b417896c15d4d007c7c14194538d2a5d0feffdecc5a7f0e1c570cfa700837c"), - }) - 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 TestSecondaryDNSTSIGUpdate(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("user@example.com"), - ) - _, err := client.SecondaryDNS.TSIGs.Update( - context.TODO(), - "69cd1e104af3e6ed3cb344f263fd0d5a", - cloudflare.SecondaryDNSTSIGUpdateParams{ - AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), - Algo: cloudflare.F("hmac-sha512."), - Name: cloudflare.F("tsig.customer.cf."), - Secret: cloudflare.F("caf79a7804b04337c9c66ccd7bef9190a1e1679b5dd03d8aa10f7ad45e1a9dab92b417896c15d4d007c7c14194538d2a5d0feffdecc5a7f0e1c570cfa700837c"), - }, - ) - 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 TestSecondaryDNSTSIGList(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("user@example.com"), - ) - _, err := client.SecondaryDNS.TSIGs.List(context.TODO(), cloudflare.SecondaryDNSTSIGListParams{ - AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), - }) - 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 TestSecondaryDNSTSIGDelete(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("user@example.com"), - ) - _, err := client.SecondaryDNS.TSIGs.Delete( - context.TODO(), - "69cd1e104af3e6ed3cb344f263fd0d5a", - cloudflare.SecondaryDNSTSIGDeleteParams{ - AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), - }, - ) - 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 TestSecondaryDNSTSIGGet(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("user@example.com"), - ) - _, err := client.SecondaryDNS.TSIGs.Get( - context.TODO(), - "69cd1e104af3e6ed3cb344f263fd0d5a", - cloudflare.SecondaryDNSTSIGGetParams{ - AccountID: cloudflare.F[any]("01a7362d577a6c3019a474fd6f485823"), - }, - ) - 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/snippetcontent.go b/snippetcontent.go deleted file mode 100644 index f5c49e900cd..00000000000 --- a/snippetcontent.go +++ /dev/null @@ -1,39 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SnippetContentService 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 [NewSnippetContentService] method -// instead. -type SnippetContentService struct { - Options []option.RequestOption -} - -// NewSnippetContentService 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 NewSnippetContentService(opts ...option.RequestOption) (r *SnippetContentService) { - r = &SnippetContentService{} - r.Options = opts - return -} - -// Snippet Content -func (r *SnippetContentService) Get(ctx context.Context, zoneIdentifier string, snippetName string, opts ...option.RequestOption) (res *http.Response, err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "multipart/form-data")}, opts...) - path := fmt.Sprintf("zones/%s/snippets/%s/content", zoneIdentifier, snippetName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) - return -} diff --git a/snippetcontent_test.go b/snippetcontent_test.go deleted file mode 100644 index cf9fd4f7634..00000000000 --- a/snippetcontent_test.go +++ /dev/null @@ -1,56 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "bytes" - "context" - "errors" - "io" - "net/http" - "net/http/httptest" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSnippetContentGet(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - w.Write([]byte("abc")) - })) - defer server.Close() - baseURL := server.URL - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - resp, err := client.Snippets.Content.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "snippet_name_01", - ) - 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()) - } - defer resp.Body.Close() - - b, err := io.ReadAll(resp.Body) - 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()) - } - if !bytes.Equal(b, []byte("abc")) { - t.Fatalf("return value not %s: %s", "abc", b) - } -} diff --git a/snippetrule.go b/snippetrule.go deleted file mode 100644 index c7f9c35d324..00000000000 --- a/snippetrule.go +++ /dev/null @@ -1,299 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SnippetRuleService 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 [NewSnippetRuleService] method -// instead. -type SnippetRuleService struct { - Options []option.RequestOption -} - -// NewSnippetRuleService 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 NewSnippetRuleService(opts ...option.RequestOption) (r *SnippetRuleService) { - r = &SnippetRuleService{} - r.Options = opts - return -} - -// Put Rules -func (r *SnippetRuleService) Update(ctx context.Context, zoneIdentifier string, body SnippetRuleUpdateParams, opts ...option.RequestOption) (res *[]SnippetRuleUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env SnippetRuleUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/snippets/snippet_rules", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Rules -func (r *SnippetRuleService) List(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *[]SnippetRuleListResponse, err error) { - opts = append(r.Options[:], opts...) - var env SnippetRuleListResponseEnvelope - path := fmt.Sprintf("zones/%s/snippets/snippet_rules", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SnippetRuleUpdateResponse struct { - Description string `json:"description"` - Enabled bool `json:"enabled"` - Expression string `json:"expression"` - // Snippet identifying name - SnippetName string `json:"snippet_name"` - JSON snippetRuleUpdateResponseJSON `json:"-"` -} - -// snippetRuleUpdateResponseJSON contains the JSON metadata for the struct -// [SnippetRuleUpdateResponse] -type snippetRuleUpdateResponseJSON struct { - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - SnippetName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SnippetRuleUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r snippetRuleUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type SnippetRuleListResponse struct { - Description string `json:"description"` - Enabled bool `json:"enabled"` - Expression string `json:"expression"` - // Snippet identifying name - SnippetName string `json:"snippet_name"` - JSON snippetRuleListResponseJSON `json:"-"` -} - -// snippetRuleListResponseJSON contains the JSON metadata for the struct -// [SnippetRuleListResponse] -type snippetRuleListResponseJSON struct { - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - SnippetName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SnippetRuleListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r snippetRuleListResponseJSON) RawJSON() string { - return r.raw -} - -type SnippetRuleUpdateParams struct { - // List of snippet rules - Rules param.Field[[]SnippetRuleUpdateParamsRule] `json:"rules"` -} - -func (r SnippetRuleUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SnippetRuleUpdateParamsRule struct { - Description param.Field[string] `json:"description"` - Enabled param.Field[bool] `json:"enabled"` - Expression param.Field[string] `json:"expression"` - // Snippet identifying name - SnippetName param.Field[string] `json:"snippet_name"` -} - -func (r SnippetRuleUpdateParamsRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SnippetRuleUpdateResponseEnvelope struct { - Errors []SnippetRuleUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []SnippetRuleUpdateResponseEnvelopeMessages `json:"messages,required"` - // List of snippet rules - Result []SnippetRuleUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success SnippetRuleUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON snippetRuleUpdateResponseEnvelopeJSON `json:"-"` -} - -// snippetRuleUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [SnippetRuleUpdateResponseEnvelope] -type snippetRuleUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SnippetRuleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r snippetRuleUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SnippetRuleUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON snippetRuleUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// snippetRuleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SnippetRuleUpdateResponseEnvelopeErrors] -type snippetRuleUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SnippetRuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r snippetRuleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SnippetRuleUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON snippetRuleUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// snippetRuleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SnippetRuleUpdateResponseEnvelopeMessages] -type snippetRuleUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SnippetRuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r snippetRuleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SnippetRuleUpdateResponseEnvelopeSuccess bool - -const ( - SnippetRuleUpdateResponseEnvelopeSuccessTrue SnippetRuleUpdateResponseEnvelopeSuccess = true -) - -type SnippetRuleListResponseEnvelope struct { - Errors []SnippetRuleListResponseEnvelopeErrors `json:"errors,required"` - Messages []SnippetRuleListResponseEnvelopeMessages `json:"messages,required"` - // List of snippet rules - Result []SnippetRuleListResponse `json:"result,required"` - // Whether the API call was successful - Success SnippetRuleListResponseEnvelopeSuccess `json:"success,required"` - JSON snippetRuleListResponseEnvelopeJSON `json:"-"` -} - -// snippetRuleListResponseEnvelopeJSON contains the JSON metadata for the struct -// [SnippetRuleListResponseEnvelope] -type snippetRuleListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SnippetRuleListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r snippetRuleListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SnippetRuleListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON snippetRuleListResponseEnvelopeErrorsJSON `json:"-"` -} - -// snippetRuleListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SnippetRuleListResponseEnvelopeErrors] -type snippetRuleListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SnippetRuleListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r snippetRuleListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SnippetRuleListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON snippetRuleListResponseEnvelopeMessagesJSON `json:"-"` -} - -// snippetRuleListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SnippetRuleListResponseEnvelopeMessages] -type snippetRuleListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SnippetRuleListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r snippetRuleListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SnippetRuleListResponseEnvelopeSuccess bool - -const ( - SnippetRuleListResponseEnvelopeSuccessTrue SnippetRuleListResponseEnvelopeSuccess = true -) diff --git a/snippetrule_test.go b/snippetrule_test.go deleted file mode 100644 index 23a872950d9..00000000000 --- a/snippetrule_test.go +++ /dev/null @@ -1,83 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSnippetRuleUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Snippets.Rules.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.SnippetRuleUpdateParams{ - Rules: cloudflare.F([]cloudflare.SnippetRuleUpdateParamsRule{{ - Description: cloudflare.F("Rule description"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("http.cookie eq \"a=b\""), - SnippetName: cloudflare.F("snippet_name_01"), - }, { - Description: cloudflare.F("Rule description"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("http.cookie eq \"a=b\""), - SnippetName: cloudflare.F("snippet_name_01"), - }, { - Description: cloudflare.F("Rule description"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("http.cookie eq \"a=b\""), - SnippetName: cloudflare.F("snippet_name_01"), - }}), - }, - ) - 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 TestSnippetRuleList(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("user@example.com"), - ) - _, err := client.Snippets.Rules.List(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/snippets/aliases.go b/snippets/aliases.go new file mode 100644 index 00000000000..4400ffac293 --- /dev/null +++ b/snippets/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package snippets + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/snippets/content.go b/snippets/content.go new file mode 100644 index 00000000000..4fee13ce077 --- /dev/null +++ b/snippets/content.go @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package snippets + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ContentService 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 [NewContentService] method instead. +type ContentService struct { + Options []option.RequestOption +} + +// NewContentService 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 NewContentService(opts ...option.RequestOption) (r *ContentService) { + r = &ContentService{} + r.Options = opts + return +} + +// Snippet Content +func (r *ContentService) Get(ctx context.Context, zoneIdentifier string, snippetName string, opts ...option.RequestOption) (res *http.Response, err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "multipart/form-data")}, opts...) + path := fmt.Sprintf("zones/%s/snippets/%s/content", zoneIdentifier, snippetName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return +} diff --git a/snippets/content_test.go b/snippets/content_test.go new file mode 100644 index 00000000000..d5c01d19636 --- /dev/null +++ b/snippets/content_test.go @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package snippets_test + +import ( + "bytes" + "context" + "errors" + "io" + "net/http" + "net/http/httptest" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestContentGet(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + w.Write([]byte("abc")) + })) + defer server.Close() + baseURL := server.URL + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("user@example.com"), + ) + resp, err := client.Snippets.Content.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "snippet_name_01", + ) + 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()) + } + defer resp.Body.Close() + + b, err := io.ReadAll(resp.Body) + 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()) + } + if !bytes.Equal(b, []byte("abc")) { + t.Fatalf("return value not %s: %s", "abc", b) + } +} diff --git a/snippets/rule.go b/snippets/rule.go new file mode 100644 index 00000000000..ab29db079fe --- /dev/null +++ b/snippets/rule.go @@ -0,0 +1,298 @@ +// File generated from our OpenAPI spec by Stainless. + +package snippets + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-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 +} + +// 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 + return +} + +// Put Rules +func (r *RuleService) Update(ctx context.Context, zoneIdentifier string, body RuleUpdateParams, opts ...option.RequestOption) (res *[]RuleUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env RuleUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/snippets/snippet_rules", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Rules +func (r *RuleService) List(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *[]RuleListResponse, err error) { + opts = append(r.Options[:], opts...) + var env RuleListResponseEnvelope + path := fmt.Sprintf("zones/%s/snippets/snippet_rules", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type RuleUpdateResponse struct { + Description string `json:"description"` + Enabled bool `json:"enabled"` + Expression string `json:"expression"` + // Snippet identifying name + SnippetName string `json:"snippet_name"` + JSON ruleUpdateResponseJSON `json:"-"` +} + +// ruleUpdateResponseJSON contains the JSON metadata for the struct +// [RuleUpdateResponse] +type ruleUpdateResponseJSON struct { + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + SnippetName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleUpdateResponseJSON) RawJSON() string { + return r.raw +} + +type RuleListResponse struct { + Description string `json:"description"` + Enabled bool `json:"enabled"` + Expression string `json:"expression"` + // Snippet identifying name + SnippetName string `json:"snippet_name"` + JSON ruleListResponseJSON `json:"-"` +} + +// ruleListResponseJSON contains the JSON metadata for the struct +// [RuleListResponse] +type ruleListResponseJSON struct { + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + SnippetName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleListResponseJSON) RawJSON() string { + return r.raw +} + +type RuleUpdateParams struct { + // List of snippet rules + Rules param.Field[[]RuleUpdateParamsRule] `json:"rules"` +} + +func (r RuleUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RuleUpdateParamsRule struct { + Description param.Field[string] `json:"description"` + Enabled param.Field[bool] `json:"enabled"` + Expression param.Field[string] `json:"expression"` + // Snippet identifying name + SnippetName param.Field[string] `json:"snippet_name"` +} + +func (r RuleUpdateParamsRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RuleUpdateResponseEnvelope struct { + Errors []RuleUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleUpdateResponseEnvelopeMessages `json:"messages,required"` + // List of snippet rules + Result []RuleUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success RuleUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON ruleUpdateResponseEnvelopeJSON `json:"-"` +} + +// ruleUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleUpdateResponseEnvelope] +type ruleUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleUpdateResponseEnvelopeErrors] +type ruleUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleUpdateResponseEnvelopeMessages] +type ruleUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleUpdateResponseEnvelopeSuccess bool + +const ( + RuleUpdateResponseEnvelopeSuccessTrue RuleUpdateResponseEnvelopeSuccess = true +) + +type RuleListResponseEnvelope struct { + Errors []RuleListResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleListResponseEnvelopeMessages `json:"messages,required"` + // List of snippet rules + Result []RuleListResponse `json:"result,required"` + // Whether the API call was successful + Success RuleListResponseEnvelopeSuccess `json:"success,required"` + JSON ruleListResponseEnvelopeJSON `json:"-"` +} + +// ruleListResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleListResponseEnvelope] +type ruleListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleListResponseEnvelopeErrors] +type ruleListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleListResponseEnvelopeMessages] +type ruleListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleListResponseEnvelopeSuccess bool + +const ( + RuleListResponseEnvelopeSuccessTrue RuleListResponseEnvelopeSuccess = true +) diff --git a/snippets/rule_test.go b/snippets/rule_test.go new file mode 100644 index 00000000000..7cc78fd6d25 --- /dev/null +++ b/snippets/rule_test.go @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package snippets_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/snippets" +) + +func TestRuleUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Snippets.Rules.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + snippets.RuleUpdateParams{ + Rules: cloudflare.F([]snippets.RuleUpdateParamsRule{{ + Description: cloudflare.F("Rule description"), + Enabled: cloudflare.F(true), + Expression: cloudflare.F("http.cookie eq \"a=b\""), + SnippetName: cloudflare.F("snippet_name_01"), + }, { + Description: cloudflare.F("Rule description"), + Enabled: cloudflare.F(true), + Expression: cloudflare.F("http.cookie eq \"a=b\""), + SnippetName: cloudflare.F("snippet_name_01"), + }, { + Description: cloudflare.F("Rule description"), + Enabled: cloudflare.F(true), + Expression: cloudflare.F("http.cookie eq \"a=b\""), + SnippetName: cloudflare.F("snippet_name_01"), + }}), + }, + ) + 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 TestRuleList(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("user@example.com"), + ) + _, err := client.Snippets.Rules.List(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/snippet.go b/snippets/snippet.go similarity index 84% rename from snippet.go rename to snippets/snippet.go index 4e60b9b01d1..906a82b34e7 100644 --- a/snippet.go +++ b/snippets/snippet.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package snippets import ( "context" @@ -22,8 +22,8 @@ import ( // service directly, and instead use the [NewSnippetService] method instead. type SnippetService struct { Options []option.RequestOption - Content *SnippetContentService - Rules *SnippetRuleService + Content *ContentService + Rules *RuleService } // NewSnippetService generates a new service that applies the given options to each @@ -32,13 +32,13 @@ type SnippetService struct { func NewSnippetService(opts ...option.RequestOption) (r *SnippetService) { r = &SnippetService{} r.Options = opts - r.Content = NewSnippetContentService(opts...) - r.Rules = NewSnippetRuleService(opts...) + r.Content = NewContentService(opts...) + r.Rules = NewRuleService(opts...) return } // Put Snippet -func (r *SnippetService) Update(ctx context.Context, zoneIdentifier string, snippetName string, body SnippetUpdateParams, opts ...option.RequestOption) (res *SnippetUpdateResponse, err error) { +func (r *SnippetService) Update(ctx context.Context, zoneIdentifier string, snippetName string, body SnippetUpdateParams, opts ...option.RequestOption) (res *Snippet, err error) { opts = append(r.Options[:], opts...) var env SnippetUpdateResponseEnvelope path := fmt.Sprintf("zones/%s/snippets/%s", zoneIdentifier, snippetName) @@ -51,7 +51,7 @@ func (r *SnippetService) Update(ctx context.Context, zoneIdentifier string, snip } // All Snippets -func (r *SnippetService) List(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *[]SnippetListResponse, err error) { +func (r *SnippetService) List(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *[]Snippet, err error) { opts = append(r.Options[:], opts...) var env SnippetListResponseEnvelope path := fmt.Sprintf("zones/%s/snippets", zoneIdentifier) @@ -77,7 +77,7 @@ func (r *SnippetService) Delete(ctx context.Context, zoneIdentifier string, snip } // Snippet -func (r *SnippetService) Get(ctx context.Context, zoneIdentifier string, snippetName string, opts ...option.RequestOption) (res *SnippetGetResponse, err error) { +func (r *SnippetService) Get(ctx context.Context, zoneIdentifier string, snippetName string, opts ...option.RequestOption) (res *Snippet, err error) { opts = append(r.Options[:], opts...) var env SnippetGetResponseEnvelope path := fmt.Sprintf("zones/%s/snippets/%s", zoneIdentifier, snippetName) @@ -90,19 +90,18 @@ func (r *SnippetService) Get(ctx context.Context, zoneIdentifier string, snippet } // Snippet Information -type SnippetUpdateResponse struct { +type Snippet struct { // Creation time of the snippet CreatedOn string `json:"created_on"` // Modification time of the snippet ModifiedOn string `json:"modified_on"` // Snippet identifying name - SnippetName string `json:"snippet_name"` - JSON snippetUpdateResponseJSON `json:"-"` + SnippetName string `json:"snippet_name"` + JSON snippetJSON `json:"-"` } -// snippetUpdateResponseJSON contains the JSON metadata for the struct -// [SnippetUpdateResponse] -type snippetUpdateResponseJSON struct { +// snippetJSON contains the JSON metadata for the struct [Snippet] +type snippetJSON struct { CreatedOn apijson.Field ModifiedOn apijson.Field SnippetName apijson.Field @@ -110,47 +109,18 @@ type snippetUpdateResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *SnippetUpdateResponse) UnmarshalJSON(data []byte) (err error) { +func (r *Snippet) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r snippetUpdateResponseJSON) RawJSON() string { +func (r snippetJSON) RawJSON() string { return r.raw } -// Snippet Information -type SnippetListResponse struct { - // Creation time of the snippet - CreatedOn string `json:"created_on"` - // Modification time of the snippet - ModifiedOn string `json:"modified_on"` - // Snippet identifying name - SnippetName string `json:"snippet_name"` - JSON snippetListResponseJSON `json:"-"` -} - -// snippetListResponseJSON contains the JSON metadata for the struct -// [SnippetListResponse] -type snippetListResponseJSON struct { - CreatedOn apijson.Field - ModifiedOn apijson.Field - SnippetName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SnippetListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r snippetListResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [SnippetDeleteResponseUnknown], [SnippetDeleteResponseArray] -// or [shared.UnionString]. +// Union satisfied by [snippets.SnippetDeleteResponseUnknown], +// [snippets.SnippetDeleteResponseArray] or [shared.UnionString]. type SnippetDeleteResponse interface { - ImplementsSnippetDeleteResponse() + ImplementsSnippetsSnippetDeleteResponse() } func init() { @@ -170,36 +140,7 @@ func init() { type SnippetDeleteResponseArray []interface{} -func (r SnippetDeleteResponseArray) ImplementsSnippetDeleteResponse() {} - -// Snippet Information -type SnippetGetResponse struct { - // Creation time of the snippet - CreatedOn string `json:"created_on"` - // Modification time of the snippet - ModifiedOn string `json:"modified_on"` - // Snippet identifying name - SnippetName string `json:"snippet_name"` - JSON snippetGetResponseJSON `json:"-"` -} - -// snippetGetResponseJSON contains the JSON metadata for the struct -// [SnippetGetResponse] -type snippetGetResponseJSON struct { - CreatedOn apijson.Field - ModifiedOn apijson.Field - SnippetName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SnippetGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r snippetGetResponseJSON) RawJSON() string { - return r.raw -} +func (r SnippetDeleteResponseArray) ImplementsSnippetsSnippetDeleteResponse() {} type SnippetUpdateParams struct { // Content files of uploaded snippet @@ -224,7 +165,7 @@ type SnippetUpdateResponseEnvelope struct { Errors []SnippetUpdateResponseEnvelopeErrors `json:"errors,required"` Messages []SnippetUpdateResponseEnvelopeMessages `json:"messages,required"` // Snippet Information - Result SnippetUpdateResponse `json:"result,required"` + Result Snippet `json:"result,required"` // Whether the API call was successful Success SnippetUpdateResponseEnvelopeSuccess `json:"success,required"` JSON snippetUpdateResponseEnvelopeJSON `json:"-"` @@ -306,7 +247,7 @@ type SnippetListResponseEnvelope struct { Errors []SnippetListResponseEnvelopeErrors `json:"errors,required"` Messages []SnippetListResponseEnvelopeMessages `json:"messages,required"` // List of all zone snippets - Result []SnippetListResponse `json:"result,required"` + Result []Snippet `json:"result,required"` // Whether the API call was successful Success SnippetListResponseEnvelopeSuccess `json:"success,required"` JSON snippetListResponseEnvelopeJSON `json:"-"` @@ -469,7 +410,7 @@ type SnippetGetResponseEnvelope struct { Errors []SnippetGetResponseEnvelopeErrors `json:"errors,required"` Messages []SnippetGetResponseEnvelopeMessages `json:"messages,required"` // Snippet Information - Result SnippetGetResponse `json:"result,required"` + Result Snippet `json:"result,required"` // Whether the API call was successful Success SnippetGetResponseEnvelopeSuccess `json:"success,required"` JSON snippetGetResponseEnvelopeJSON `json:"-"` diff --git a/snippet_test.go b/snippets/snippet_test.go similarity index 95% rename from snippet_test.go rename to snippets/snippet_test.go index f53a6835681..fcbecb9ed54 100644 --- a/snippet_test.go +++ b/snippets/snippet_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package snippets_test import ( "context" @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/snippets" ) func TestSnippetUpdateWithOptionalParams(t *testing.T) { @@ -31,9 +32,9 @@ func TestSnippetUpdateWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "snippet_name_01", - cloudflare.SnippetUpdateParams{ + snippets.SnippetUpdateParams{ Files: cloudflare.F("export { async function fetch(request, env) {return new Response('some_response') } }"), - Metadata: cloudflare.F(cloudflare.SnippetUpdateParamsMetadata{ + Metadata: cloudflare.F(snippets.SnippetUpdateParamsMetadata{ MainModule: cloudflare.F("main.js"), }), }, diff --git a/spectrum/aliases.go b/spectrum/aliases.go new file mode 100644 index 00000000000..6ad4914a7af --- /dev/null +++ b/spectrum/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package spectrum + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/spectrum/analytics.go b/spectrum/analytics.go new file mode 100644 index 00000000000..f760e846bdc --- /dev/null +++ b/spectrum/analytics.go @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package spectrum + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// AnalyticsService 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 [NewAnalyticsService] method instead. +type AnalyticsService struct { + Options []option.RequestOption + Aggregates *AnalyticsAggregateService + Events *AnalyticsEventService +} + +// NewAnalyticsService 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 NewAnalyticsService(opts ...option.RequestOption) (r *AnalyticsService) { + r = &AnalyticsService{} + r.Options = opts + r.Aggregates = NewAnalyticsAggregateService(opts...) + r.Events = NewAnalyticsEventService(opts...) + return +} diff --git a/spectrum/analyticsaggregate.go b/spectrum/analyticsaggregate.go new file mode 100644 index 00000000000..6412cea7e74 --- /dev/null +++ b/spectrum/analyticsaggregate.go @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package spectrum + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// AnalyticsAggregateService 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 [NewAnalyticsAggregateService] method +// instead. +type AnalyticsAggregateService struct { + Options []option.RequestOption + Currents *AnalyticsAggregateCurrentService +} + +// NewAnalyticsAggregateService 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 NewAnalyticsAggregateService(opts ...option.RequestOption) (r *AnalyticsAggregateService) { + r = &AnalyticsAggregateService{} + r.Options = opts + r.Currents = NewAnalyticsAggregateCurrentService(opts...) + return +} diff --git a/spectrum/analyticsaggregatecurrent.go b/spectrum/analyticsaggregatecurrent.go new file mode 100644 index 00000000000..b631f3d11db --- /dev/null +++ b/spectrum/analyticsaggregatecurrent.go @@ -0,0 +1,151 @@ +// File generated from our OpenAPI spec by Stainless. + +package spectrum + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AnalyticsAggregateCurrentService 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 +// [NewAnalyticsAggregateCurrentService] method instead. +type AnalyticsAggregateCurrentService struct { + Options []option.RequestOption +} + +// NewAnalyticsAggregateCurrentService 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 NewAnalyticsAggregateCurrentService(opts ...option.RequestOption) (r *AnalyticsAggregateCurrentService) { + r = &AnalyticsAggregateCurrentService{} + r.Options = opts + return +} + +// Retrieves analytics aggregated from the last minute of usage on Spectrum +// applications underneath a given zone. +func (r *AnalyticsAggregateCurrentService) Get(ctx context.Context, zone string, query AnalyticsAggregateCurrentGetParams, opts ...option.RequestOption) (res *[]AnalyticsAggregateCurrentGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env AnalyticsAggregateCurrentGetResponseEnvelope + path := fmt.Sprintf("zones/%s/spectrum/analytics/aggregate/current", zone) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AnalyticsAggregateCurrentGetResponse = interface{} + +type AnalyticsAggregateCurrentGetParams struct { + // Comma-delimited list of Spectrum Application Id(s). If provided, the response + // will be limited to Spectrum Application Id(s) that match. + AppIDParam param.Field[string] `query:"app_id_param"` + // Comma-delimited list of Spectrum Application Id(s). If provided, the response + // will be limited to Spectrum Application Id(s) that match. + AppID param.Field[string] `query:"appID"` + // Co-location identifier. + ColoName param.Field[string] `query:"colo_name"` +} + +// URLQuery serializes [AnalyticsAggregateCurrentGetParams]'s query parameters as +// `url.Values`. +func (r AnalyticsAggregateCurrentGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AnalyticsAggregateCurrentGetResponseEnvelope struct { + Errors []AnalyticsAggregateCurrentGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AnalyticsAggregateCurrentGetResponseEnvelopeMessages `json:"messages,required"` + Result []AnalyticsAggregateCurrentGetResponse `json:"result,required"` + // Whether the API call was successful + Success AnalyticsAggregateCurrentGetResponseEnvelopeSuccess `json:"success,required"` + JSON analyticsAggregateCurrentGetResponseEnvelopeJSON `json:"-"` +} + +// analyticsAggregateCurrentGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [AnalyticsAggregateCurrentGetResponseEnvelope] +type analyticsAggregateCurrentGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsAggregateCurrentGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsAggregateCurrentGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AnalyticsAggregateCurrentGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON analyticsAggregateCurrentGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// analyticsAggregateCurrentGetResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [AnalyticsAggregateCurrentGetResponseEnvelopeErrors] +type analyticsAggregateCurrentGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsAggregateCurrentGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsAggregateCurrentGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AnalyticsAggregateCurrentGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON analyticsAggregateCurrentGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// analyticsAggregateCurrentGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [AnalyticsAggregateCurrentGetResponseEnvelopeMessages] +type analyticsAggregateCurrentGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsAggregateCurrentGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsAggregateCurrentGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AnalyticsAggregateCurrentGetResponseEnvelopeSuccess bool + +const ( + AnalyticsAggregateCurrentGetResponseEnvelopeSuccessTrue AnalyticsAggregateCurrentGetResponseEnvelopeSuccess = true +) diff --git a/spectrum/analyticsaggregatecurrent_test.go b/spectrum/analyticsaggregatecurrent_test.go new file mode 100644 index 00000000000..624e7373497 --- /dev/null +++ b/spectrum/analyticsaggregatecurrent_test.go @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package spectrum_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/spectrum" +) + +func TestAnalyticsAggregateCurrentGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Spectrum.Analytics.Aggregates.Currents.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + spectrum.AnalyticsAggregateCurrentGetParams{ + AppIDParam: cloudflare.F("ea95132c15732412d22c1476fa83f27a,d122c5f4bb71e25cc9e86ab43b142e2f"), + AppID: cloudflare.F("ea95132c15732412d22c1476fa83f27a,d122c5f4bb71e25cc9e86ab43b142e2f"), + ColoName: cloudflare.F("PDX"), + }, + ) + 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/spectrum/analyticsevent.go b/spectrum/analyticsevent.go new file mode 100644 index 00000000000..6ab98029fc5 --- /dev/null +++ b/spectrum/analyticsevent.go @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package spectrum + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// AnalyticsEventService 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 [NewAnalyticsEventService] method +// instead. +type AnalyticsEventService struct { + Options []option.RequestOption + Bytimes *AnalyticsEventBytimeService + Summaries *AnalyticsEventSummaryService +} + +// NewAnalyticsEventService 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 NewAnalyticsEventService(opts ...option.RequestOption) (r *AnalyticsEventService) { + r = &AnalyticsEventService{} + r.Options = opts + r.Bytimes = NewAnalyticsEventBytimeService(opts...) + r.Summaries = NewAnalyticsEventSummaryService(opts...) + return +} diff --git a/spectrum/analyticseventbytime.go b/spectrum/analyticseventbytime.go new file mode 100644 index 00000000000..ceb1a40a104 --- /dev/null +++ b/spectrum/analyticseventbytime.go @@ -0,0 +1,244 @@ +// File generated from our OpenAPI spec by Stainless. + +package spectrum + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// AnalyticsEventBytimeService 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 [NewAnalyticsEventBytimeService] +// method instead. +type AnalyticsEventBytimeService struct { + Options []option.RequestOption +} + +// NewAnalyticsEventBytimeService 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 NewAnalyticsEventBytimeService(opts ...option.RequestOption) (r *AnalyticsEventBytimeService) { + r = &AnalyticsEventBytimeService{} + r.Options = opts + return +} + +// Retrieves a list of aggregate metrics grouped by time interval. +func (r *AnalyticsEventBytimeService) Get(ctx context.Context, zone string, query AnalyticsEventBytimeGetParams, opts ...option.RequestOption) (res *AnalyticsEventBytimeGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env AnalyticsEventBytimeGetResponseEnvelope + path := fmt.Sprintf("zones/%s/spectrum/analytics/events/bytime", zone) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [spectrum.AnalyticsEventBytimeGetResponseUnknown] or +// [shared.UnionString]. +type AnalyticsEventBytimeGetResponse interface { + ImplementsSpectrumAnalyticsEventBytimeGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AnalyticsEventBytimeGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type AnalyticsEventBytimeGetParams struct { + // Can be used to break down the data by given attributes. Options are: + // + // | Dimension | Name | Example | + // | --------- | ----------------------------- | ---------------------------------------------------------- | + // | event | Connection Event | connect, progress, disconnect, originError, clientFiltered | + // | appID | Application ID | 40d67c87c6cd4b889a4fd57805225e85 | + // | coloName | Colo Name | SFO | + // | ipVersion | IP version used by the client | 4, 6. | + Dimensions param.Field[[]AnalyticsEventBytimeGetParamsDimension] `query:"dimensions"` + // Used to filter rows by one or more dimensions. Filters can be combined using OR + // and AND boolean logic. AND takes precedence over OR in all the expressions. The + // OR operator is defined using a comma (,) or OR keyword surrounded by whitespace. + // The AND operator is defined using a semicolon (;) or AND keyword surrounded by + // whitespace. Note that the semicolon is a reserved character in URLs (rfc1738) + // and needs to be percent-encoded as %3B. Comparison options are: + // + // | Operator | Name | URL Encoded | + // | -------- | ------------------------ | ----------- | + // | == | Equals | %3D%3D | + // | != | Does not equals | !%3D | + // | > | Greater Than | %3E | + // | < | Less Than | %3C | + // | >= | Greater than or equal to | %3E%3D | + // | <= | Less than or equal to | %3C%3D . | + Filters param.Field[string] `query:"filters"` + // One or more metrics to compute. Options are: + // + // | Metric | Name | Example | Unit | + // | -------------- | ----------------------------------- | ------- | --------------------- | + // | count | Count of total events | 1000 | Count | + // | bytesIngress | Sum of ingress bytes | 1000 | Sum | + // | bytesEgress | Sum of egress bytes | 1000 | Sum | + // | durationAvg | Average connection duration | 1.0 | Time in milliseconds | + // | durationMedian | Median connection duration | 1.0 | Time in milliseconds | + // | duration90th | 90th percentile connection duration | 1.0 | Time in milliseconds | + // | duration99th | 99th percentile connection duration | 1.0 | Time in milliseconds. | + Metrics param.Field[[]AnalyticsEventBytimeGetParamsMetric] `query:"metrics"` + // Start of time interval to query, defaults to `until` - 6 hours. Timestamp must + // be in RFC3339 format and uses UTC unless otherwise specified. + Since param.Field[time.Time] `query:"since" format:"date-time"` + // The sort order for the result set; sort fields must be included in `metrics` or + // `dimensions`. + Sort param.Field[[]interface{}] `query:"sort"` + // Used to select time series resolution. + TimeDelta param.Field[AnalyticsEventBytimeGetParamsTimeDelta] `query:"time_delta"` + // End of time interval to query, defaults to current time. Timestamp must be in + // RFC3339 format and uses UTC unless otherwise specified. + Until param.Field[time.Time] `query:"until" format:"date-time"` +} + +// URLQuery serializes [AnalyticsEventBytimeGetParams]'s query parameters as +// `url.Values`. +func (r AnalyticsEventBytimeGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AnalyticsEventBytimeGetParamsDimension string + +const ( + AnalyticsEventBytimeGetParamsDimensionEvent AnalyticsEventBytimeGetParamsDimension = "event" + AnalyticsEventBytimeGetParamsDimensionAppID AnalyticsEventBytimeGetParamsDimension = "appID" + AnalyticsEventBytimeGetParamsDimensionColoName AnalyticsEventBytimeGetParamsDimension = "coloName" + AnalyticsEventBytimeGetParamsDimensionIPVersion AnalyticsEventBytimeGetParamsDimension = "ipVersion" +) + +type AnalyticsEventBytimeGetParamsMetric string + +const ( + AnalyticsEventBytimeGetParamsMetricCount AnalyticsEventBytimeGetParamsMetric = "count" + AnalyticsEventBytimeGetParamsMetricBytesIngress AnalyticsEventBytimeGetParamsMetric = "bytesIngress" + AnalyticsEventBytimeGetParamsMetricBytesEgress AnalyticsEventBytimeGetParamsMetric = "bytesEgress" + AnalyticsEventBytimeGetParamsMetricDurationAvg AnalyticsEventBytimeGetParamsMetric = "durationAvg" + AnalyticsEventBytimeGetParamsMetricDurationMedian AnalyticsEventBytimeGetParamsMetric = "durationMedian" + AnalyticsEventBytimeGetParamsMetricDuration90th AnalyticsEventBytimeGetParamsMetric = "duration90th" + AnalyticsEventBytimeGetParamsMetricDuration99th AnalyticsEventBytimeGetParamsMetric = "duration99th" +) + +// Used to select time series resolution. +type AnalyticsEventBytimeGetParamsTimeDelta string + +const ( + AnalyticsEventBytimeGetParamsTimeDeltaYear AnalyticsEventBytimeGetParamsTimeDelta = "year" + AnalyticsEventBytimeGetParamsTimeDeltaQuarter AnalyticsEventBytimeGetParamsTimeDelta = "quarter" + AnalyticsEventBytimeGetParamsTimeDeltaMonth AnalyticsEventBytimeGetParamsTimeDelta = "month" + AnalyticsEventBytimeGetParamsTimeDeltaWeek AnalyticsEventBytimeGetParamsTimeDelta = "week" + AnalyticsEventBytimeGetParamsTimeDeltaDay AnalyticsEventBytimeGetParamsTimeDelta = "day" + AnalyticsEventBytimeGetParamsTimeDeltaHour AnalyticsEventBytimeGetParamsTimeDelta = "hour" + AnalyticsEventBytimeGetParamsTimeDeltaDekaminute AnalyticsEventBytimeGetParamsTimeDelta = "dekaminute" + AnalyticsEventBytimeGetParamsTimeDeltaMinute AnalyticsEventBytimeGetParamsTimeDelta = "minute" +) + +type AnalyticsEventBytimeGetResponseEnvelope struct { + Errors []AnalyticsEventBytimeGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AnalyticsEventBytimeGetResponseEnvelopeMessages `json:"messages,required"` + Result AnalyticsEventBytimeGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AnalyticsEventBytimeGetResponseEnvelopeSuccess `json:"success,required"` + JSON analyticsEventBytimeGetResponseEnvelopeJSON `json:"-"` +} + +// analyticsEventBytimeGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [AnalyticsEventBytimeGetResponseEnvelope] +type analyticsEventBytimeGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsEventBytimeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsEventBytimeGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AnalyticsEventBytimeGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON analyticsEventBytimeGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// analyticsEventBytimeGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AnalyticsEventBytimeGetResponseEnvelopeErrors] +type analyticsEventBytimeGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsEventBytimeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsEventBytimeGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AnalyticsEventBytimeGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON analyticsEventBytimeGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// analyticsEventBytimeGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AnalyticsEventBytimeGetResponseEnvelopeMessages] +type analyticsEventBytimeGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsEventBytimeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsEventBytimeGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AnalyticsEventBytimeGetResponseEnvelopeSuccess bool + +const ( + AnalyticsEventBytimeGetResponseEnvelopeSuccessTrue AnalyticsEventBytimeGetResponseEnvelopeSuccess = true +) diff --git a/spectrum/analyticseventbytime_test.go b/spectrum/analyticseventbytime_test.go new file mode 100644 index 00000000000..074e0ba83e2 --- /dev/null +++ b/spectrum/analyticseventbytime_test.go @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package spectrum_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/spectrum" +) + +func TestAnalyticsEventBytimeGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Spectrum.Analytics.Events.Bytimes.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + spectrum.AnalyticsEventBytimeGetParams{ + Dimensions: cloudflare.F([]spectrum.AnalyticsEventBytimeGetParamsDimension{spectrum.AnalyticsEventBytimeGetParamsDimensionEvent, spectrum.AnalyticsEventBytimeGetParamsDimensionAppID}), + Filters: cloudflare.F("event==disconnect%20AND%20coloName!=SFO"), + Metrics: cloudflare.F([]spectrum.AnalyticsEventBytimeGetParamsMetric{spectrum.AnalyticsEventBytimeGetParamsMetricCount, spectrum.AnalyticsEventBytimeGetParamsMetricBytesIngress}), + Since: cloudflare.F(time.Now()), + Sort: cloudflare.F([]interface{}{"+count", "-bytesIngress"}), + TimeDelta: cloudflare.F(spectrum.AnalyticsEventBytimeGetParamsTimeDeltaMinute), + Until: cloudflare.F(time.Now()), + }, + ) + 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/spectrum/analyticseventsummary.go b/spectrum/analyticseventsummary.go new file mode 100644 index 00000000000..91f57492407 --- /dev/null +++ b/spectrum/analyticseventsummary.go @@ -0,0 +1,228 @@ +// File generated from our OpenAPI spec by Stainless. + +package spectrum + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// AnalyticsEventSummaryService 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 [NewAnalyticsEventSummaryService] +// method instead. +type AnalyticsEventSummaryService struct { + Options []option.RequestOption +} + +// NewAnalyticsEventSummaryService 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 NewAnalyticsEventSummaryService(opts ...option.RequestOption) (r *AnalyticsEventSummaryService) { + r = &AnalyticsEventSummaryService{} + r.Options = opts + return +} + +// Retrieves a list of summarised aggregate metrics over a given time period. +func (r *AnalyticsEventSummaryService) Get(ctx context.Context, zone string, query AnalyticsEventSummaryGetParams, opts ...option.RequestOption) (res *AnalyticsEventSummaryGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env AnalyticsEventSummaryGetResponseEnvelope + path := fmt.Sprintf("zones/%s/spectrum/analytics/events/summary", zone) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [spectrum.AnalyticsEventSummaryGetResponseUnknown] or +// [shared.UnionString]. +type AnalyticsEventSummaryGetResponse interface { + ImplementsSpectrumAnalyticsEventSummaryGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AnalyticsEventSummaryGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type AnalyticsEventSummaryGetParams struct { + // Can be used to break down the data by given attributes. Options are: + // + // | Dimension | Name | Example | + // | --------- | ----------------------------- | ---------------------------------------------------------- | + // | event | Connection Event | connect, progress, disconnect, originError, clientFiltered | + // | appID | Application ID | 40d67c87c6cd4b889a4fd57805225e85 | + // | coloName | Colo Name | SFO | + // | ipVersion | IP version used by the client | 4, 6. | + Dimensions param.Field[[]AnalyticsEventSummaryGetParamsDimension] `query:"dimensions"` + // Used to filter rows by one or more dimensions. Filters can be combined using OR + // and AND boolean logic. AND takes precedence over OR in all the expressions. The + // OR operator is defined using a comma (,) or OR keyword surrounded by whitespace. + // The AND operator is defined using a semicolon (;) or AND keyword surrounded by + // whitespace. Note that the semicolon is a reserved character in URLs (rfc1738) + // and needs to be percent-encoded as %3B. Comparison options are: + // + // | Operator | Name | URL Encoded | + // | -------- | ------------------------ | ----------- | + // | == | Equals | %3D%3D | + // | != | Does not equals | !%3D | + // | > | Greater Than | %3E | + // | < | Less Than | %3C | + // | >= | Greater than or equal to | %3E%3D | + // | <= | Less than or equal to | %3C%3D . | + Filters param.Field[string] `query:"filters"` + // One or more metrics to compute. Options are: + // + // | Metric | Name | Example | Unit | + // | -------------- | ----------------------------------- | ------- | --------------------- | + // | count | Count of total events | 1000 | Count | + // | bytesIngress | Sum of ingress bytes | 1000 | Sum | + // | bytesEgress | Sum of egress bytes | 1000 | Sum | + // | durationAvg | Average connection duration | 1.0 | Time in milliseconds | + // | durationMedian | Median connection duration | 1.0 | Time in milliseconds | + // | duration90th | 90th percentile connection duration | 1.0 | Time in milliseconds | + // | duration99th | 99th percentile connection duration | 1.0 | Time in milliseconds. | + Metrics param.Field[[]AnalyticsEventSummaryGetParamsMetric] `query:"metrics"` + // Start of time interval to query, defaults to `until` - 6 hours. Timestamp must + // be in RFC3339 format and uses UTC unless otherwise specified. + Since param.Field[time.Time] `query:"since" format:"date-time"` + // The sort order for the result set; sort fields must be included in `metrics` or + // `dimensions`. + Sort param.Field[[]interface{}] `query:"sort"` + // End of time interval to query, defaults to current time. Timestamp must be in + // RFC3339 format and uses UTC unless otherwise specified. + Until param.Field[time.Time] `query:"until" format:"date-time"` +} + +// URLQuery serializes [AnalyticsEventSummaryGetParams]'s query parameters as +// `url.Values`. +func (r AnalyticsEventSummaryGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AnalyticsEventSummaryGetParamsDimension string + +const ( + AnalyticsEventSummaryGetParamsDimensionEvent AnalyticsEventSummaryGetParamsDimension = "event" + AnalyticsEventSummaryGetParamsDimensionAppID AnalyticsEventSummaryGetParamsDimension = "appID" + AnalyticsEventSummaryGetParamsDimensionColoName AnalyticsEventSummaryGetParamsDimension = "coloName" + AnalyticsEventSummaryGetParamsDimensionIPVersion AnalyticsEventSummaryGetParamsDimension = "ipVersion" +) + +type AnalyticsEventSummaryGetParamsMetric string + +const ( + AnalyticsEventSummaryGetParamsMetricCount AnalyticsEventSummaryGetParamsMetric = "count" + AnalyticsEventSummaryGetParamsMetricBytesIngress AnalyticsEventSummaryGetParamsMetric = "bytesIngress" + AnalyticsEventSummaryGetParamsMetricBytesEgress AnalyticsEventSummaryGetParamsMetric = "bytesEgress" + AnalyticsEventSummaryGetParamsMetricDurationAvg AnalyticsEventSummaryGetParamsMetric = "durationAvg" + AnalyticsEventSummaryGetParamsMetricDurationMedian AnalyticsEventSummaryGetParamsMetric = "durationMedian" + AnalyticsEventSummaryGetParamsMetricDuration90th AnalyticsEventSummaryGetParamsMetric = "duration90th" + AnalyticsEventSummaryGetParamsMetricDuration99th AnalyticsEventSummaryGetParamsMetric = "duration99th" +) + +type AnalyticsEventSummaryGetResponseEnvelope struct { + Errors []AnalyticsEventSummaryGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AnalyticsEventSummaryGetResponseEnvelopeMessages `json:"messages,required"` + Result AnalyticsEventSummaryGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AnalyticsEventSummaryGetResponseEnvelopeSuccess `json:"success,required"` + JSON analyticsEventSummaryGetResponseEnvelopeJSON `json:"-"` +} + +// analyticsEventSummaryGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [AnalyticsEventSummaryGetResponseEnvelope] +type analyticsEventSummaryGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsEventSummaryGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsEventSummaryGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AnalyticsEventSummaryGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON analyticsEventSummaryGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// analyticsEventSummaryGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [AnalyticsEventSummaryGetResponseEnvelopeErrors] +type analyticsEventSummaryGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsEventSummaryGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsEventSummaryGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AnalyticsEventSummaryGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON analyticsEventSummaryGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// analyticsEventSummaryGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AnalyticsEventSummaryGetResponseEnvelopeMessages] +type analyticsEventSummaryGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsEventSummaryGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsEventSummaryGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AnalyticsEventSummaryGetResponseEnvelopeSuccess bool + +const ( + AnalyticsEventSummaryGetResponseEnvelopeSuccessTrue AnalyticsEventSummaryGetResponseEnvelopeSuccess = true +) diff --git a/spectrum/analyticseventsummary_test.go b/spectrum/analyticseventsummary_test.go new file mode 100644 index 00000000000..f5df4cf71ce --- /dev/null +++ b/spectrum/analyticseventsummary_test.go @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package spectrum_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/spectrum" +) + +func TestAnalyticsEventSummaryGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.Spectrum.Analytics.Events.Summaries.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + spectrum.AnalyticsEventSummaryGetParams{ + Dimensions: cloudflare.F([]spectrum.AnalyticsEventSummaryGetParamsDimension{spectrum.AnalyticsEventSummaryGetParamsDimensionEvent, spectrum.AnalyticsEventSummaryGetParamsDimensionAppID}), + Filters: cloudflare.F("event==disconnect%20AND%20coloName!=SFO"), + Metrics: cloudflare.F([]spectrum.AnalyticsEventSummaryGetParamsMetric{spectrum.AnalyticsEventSummaryGetParamsMetricCount, spectrum.AnalyticsEventSummaryGetParamsMetricBytesIngress}), + Since: cloudflare.F(time.Now()), + Sort: cloudflare.F([]interface{}{"+count", "-bytesIngress"}), + Until: cloudflare.F(time.Now()), + }, + ) + 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/spectrum/app.go b/spectrum/app.go new file mode 100644 index 00000000000..5fe86e4d102 --- /dev/null +++ b/spectrum/app.go @@ -0,0 +1,1566 @@ +// File generated from our OpenAPI spec by Stainless. + +package spectrum + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// AppService 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 [NewAppService] method instead. +type AppService struct { + Options []option.RequestOption +} + +// NewAppService 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 NewAppService(opts ...option.RequestOption) (r *AppService) { + r = &AppService{} + r.Options = opts + return +} + +// Creates a new Spectrum application from a configuration using a name for the +// origin. +func (r *AppService) New(ctx context.Context, zone string, body AppNewParams, opts ...option.RequestOption) (res *AppNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env AppNewResponseEnvelope + path := fmt.Sprintf("zones/%s/spectrum/apps", zone) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a previously existing application's configuration that uses a name for +// the origin. +func (r *AppService) Update(ctx context.Context, zone string, appID string, body AppUpdateParams, opts ...option.RequestOption) (res *AppUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env AppUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/spectrum/apps/%s", zone, appID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Retrieves a list of currently existing Spectrum applications inside a zone. +func (r *AppService) List(ctx context.Context, zone string, query AppListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[AppListResponse], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("zones/%s/spectrum/apps", zone) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Retrieves a list of currently existing Spectrum applications inside a zone. +func (r *AppService) ListAutoPaging(ctx context.Context, zone string, query AppListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[AppListResponse] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, zone, query, opts...)) +} + +// Deletes a previously existing application. +func (r *AppService) Delete(ctx context.Context, zone string, appID string, opts ...option.RequestOption) (res *AppDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env AppDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/spectrum/apps/%s", zone, appID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets the application configuration of a specific application inside a zone. +func (r *AppService) Get(ctx context.Context, zone string, appID string, opts ...option.RequestOption) (res *AppGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env AppGetResponseEnvelope + path := fmt.Sprintf("zones/%s/spectrum/apps/%s", zone, appID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AppNewResponse struct { + // Application identifier. + ID string `json:"id"` + // Enables Argo Smart Routing for this application. Notes: Only available for TCP + // applications with traffic_type set to "direct". + ArgoSmartRouting bool `json:"argo_smart_routing"` + // When the Application was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // The name and type of DNS record for the Spectrum application. + DNS AppNewResponseDNS `json:"dns"` + // The anycast edge IP configuration for the hostname of this application. + EdgeIPs AppNewResponseEdgeIPs `json:"edge_ips"` + // Enables IP Access Rules for this application. Notes: Only available for TCP + // applications. + IPFirewall bool `json:"ip_firewall"` + // When the Application was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // The name and type of DNS record for the Spectrum application. + OriginDNS AppNewResponseOriginDNS `json:"origin_dns"` + // The destination port at the origin. Only specified in conjunction with + // origin_dns. May use an integer to specify a single origin port, for example + // `1000`, or a string to specify a range of origin ports, for example + // `"1000-2000"`. Notes: If specifying a port range, the number of ports in the + // range must match the number of ports specified in the "protocol" field. + OriginPort AppNewResponseOriginPort `json:"origin_port"` + // The port configuration at Cloudflare’s edge. May specify a single port, for + // example `"tcp/1000"`, or a range of ports, for example `"tcp/1000-2000"`. + Protocol string `json:"protocol"` + // Enables Proxy Protocol to the origin. Refer to + // [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) + // for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple + // Proxy Protocol. + ProxyProtocol AppNewResponseProxyProtocol `json:"proxy_protocol"` + // The type of TLS termination associated with the application. + TLS AppNewResponseTLS `json:"tls"` + // Determines how data travels from the edge to your origin. When set to "direct", + // Spectrum will send traffic directly to your origin, and the application's type + // is derived from the `protocol`. When set to "http" or "https", Spectrum will + // apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and + // the application type matches this property exactly. + TrafficType AppNewResponseTrafficType `json:"traffic_type"` + JSON appNewResponseJSON `json:"-"` +} + +// appNewResponseJSON contains the JSON metadata for the struct [AppNewResponse] +type appNewResponseJSON struct { + ID apijson.Field + ArgoSmartRouting apijson.Field + CreatedOn apijson.Field + DNS apijson.Field + EdgeIPs apijson.Field + IPFirewall apijson.Field + ModifiedOn apijson.Field + OriginDNS apijson.Field + OriginPort apijson.Field + Protocol apijson.Field + ProxyProtocol apijson.Field + TLS apijson.Field + TrafficType apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appNewResponseJSON) RawJSON() string { + return r.raw +} + +// The name and type of DNS record for the Spectrum application. +type AppNewResponseDNS struct { + // The name of the DNS record associated with the application. + Name string `json:"name" format:"hostname"` + // The type of DNS record associated with the application. + Type AppNewResponseDNSType `json:"type"` + JSON appNewResponseDNSJSON `json:"-"` +} + +// appNewResponseDNSJSON contains the JSON metadata for the struct +// [AppNewResponseDNS] +type appNewResponseDNSJSON struct { + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppNewResponseDNS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appNewResponseDNSJSON) RawJSON() string { + return r.raw +} + +// The type of DNS record associated with the application. +type AppNewResponseDNSType string + +const ( + AppNewResponseDNSTypeCNAME AppNewResponseDNSType = "CNAME" + AppNewResponseDNSTypeAddress AppNewResponseDNSType = "ADDRESS" +) + +// The anycast edge IP configuration for the hostname of this application. +// +// Union satisfied by +// [spectrum.AppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable] or +// [spectrum.AppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable]. +type AppNewResponseEdgeIPs interface { + implementsSpectrumAppNewResponseEdgeIPs() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AppNewResponseEdgeIPs)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable{}), + }, + ) +} + +type AppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable struct { + // The IP versions supported for inbound connections on Spectrum anycast IPs. + Connectivity AppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity `json:"connectivity"` + // The type of edge IP configuration specified. Dynamically allocated edge IPs use + // Spectrum anycast IPs in accordance with the connectivity you specify. Only valid + // with CNAME DNS names. + Type AppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableType `json:"type"` + JSON appNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableJSON `json:"-"` +} + +// appNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableJSON contains the JSON +// metadata for the struct [AppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable] +type appNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableJSON struct { + Connectivity apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableJSON) RawJSON() string { + return r.raw +} + +func (r AppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable) implementsSpectrumAppNewResponseEdgeIPs() { +} + +// The IP versions supported for inbound connections on Spectrum anycast IPs. +type AppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity string + +const ( + AppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityAll AppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "all" + AppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityIPV4 AppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "ipv4" + AppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityIPV6 AppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "ipv6" +) + +// The type of edge IP configuration specified. Dynamically allocated edge IPs use +// Spectrum anycast IPs in accordance with the connectivity you specify. Only valid +// with CNAME DNS names. +type AppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableType string + +const ( + AppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableTypeDynamic AppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableType = "dynamic" +) + +type AppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable struct { + // The array of customer owned IPs we broadcast via anycast for this hostname and + // application. + IPs []string `json:"ips"` + // The type of edge IP configuration specified. Statically allocated edge IPs use + // customer IPs in accordance with the ips array you specify. Only valid with + // ADDRESS DNS names. + Type AppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType `json:"type"` + JSON appNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableJSON `json:"-"` +} + +// appNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableJSON contains the +// JSON metadata for the struct +// [AppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable] +type appNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableJSON struct { + IPs apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableJSON) RawJSON() string { + return r.raw +} + +func (r AppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable) implementsSpectrumAppNewResponseEdgeIPs() { +} + +// The type of edge IP configuration specified. Statically allocated edge IPs use +// customer IPs in accordance with the ips array you specify. Only valid with +// ADDRESS DNS names. +type AppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType string + +const ( + AppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableTypeStatic AppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType = "static" +) + +// The name and type of DNS record for the Spectrum application. +type AppNewResponseOriginDNS struct { + // The name of the DNS record associated with the origin. + Name string `json:"name" format:"hostname"` + // The TTL of our resolution of your DNS record in seconds. + TTL int64 `json:"ttl"` + // The type of DNS record associated with the origin. "" is used to specify a + // combination of A/AAAA records. + Type AppNewResponseOriginDNSType `json:"type"` + JSON appNewResponseOriginDNSJSON `json:"-"` +} + +// appNewResponseOriginDNSJSON contains the JSON metadata for the struct +// [AppNewResponseOriginDNS] +type appNewResponseOriginDNSJSON struct { + Name apijson.Field + TTL apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppNewResponseOriginDNS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appNewResponseOriginDNSJSON) RawJSON() string { + return r.raw +} + +// The type of DNS record associated with the origin. "" is used to specify a +// combination of A/AAAA records. +type AppNewResponseOriginDNSType string + +const ( + AppNewResponseOriginDNSTypeEmpty AppNewResponseOriginDNSType = "" + AppNewResponseOriginDNSTypeA AppNewResponseOriginDNSType = "A" + AppNewResponseOriginDNSTypeAAAA AppNewResponseOriginDNSType = "AAAA" + AppNewResponseOriginDNSTypeSRV AppNewResponseOriginDNSType = "SRV" +) + +// The destination port at the origin. Only specified in conjunction with +// origin_dns. May use an integer to specify a single origin port, for example +// `1000`, or a string to specify a range of origin ports, for example +// `"1000-2000"`. Notes: If specifying a port range, the number of ports in the +// range must match the number of ports specified in the "protocol" field. +// +// Union satisfied by [shared.UnionInt] or [shared.UnionString]. +type AppNewResponseOriginPort interface { + ImplementsSpectrumAppNewResponseOriginPort() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AppNewResponseOriginPort)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionInt(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Enables Proxy Protocol to the origin. Refer to +// [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) +// for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple +// Proxy Protocol. +type AppNewResponseProxyProtocol string + +const ( + AppNewResponseProxyProtocolOff AppNewResponseProxyProtocol = "off" + AppNewResponseProxyProtocolV1 AppNewResponseProxyProtocol = "v1" + AppNewResponseProxyProtocolV2 AppNewResponseProxyProtocol = "v2" + AppNewResponseProxyProtocolSimple AppNewResponseProxyProtocol = "simple" +) + +// The type of TLS termination associated with the application. +type AppNewResponseTLS string + +const ( + AppNewResponseTLSOff AppNewResponseTLS = "off" + AppNewResponseTLSFlexible AppNewResponseTLS = "flexible" + AppNewResponseTLSFull AppNewResponseTLS = "full" + AppNewResponseTLSStrict AppNewResponseTLS = "strict" +) + +// Determines how data travels from the edge to your origin. When set to "direct", +// Spectrum will send traffic directly to your origin, and the application's type +// is derived from the `protocol`. When set to "http" or "https", Spectrum will +// apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and +// the application type matches this property exactly. +type AppNewResponseTrafficType string + +const ( + AppNewResponseTrafficTypeDirect AppNewResponseTrafficType = "direct" + AppNewResponseTrafficTypeHTTP AppNewResponseTrafficType = "http" + AppNewResponseTrafficTypeHTTPS AppNewResponseTrafficType = "https" +) + +type AppUpdateResponse struct { + // Application identifier. + ID string `json:"id"` + // Enables Argo Smart Routing for this application. Notes: Only available for TCP + // applications with traffic_type set to "direct". + ArgoSmartRouting bool `json:"argo_smart_routing"` + // When the Application was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // The name and type of DNS record for the Spectrum application. + DNS AppUpdateResponseDNS `json:"dns"` + // The anycast edge IP configuration for the hostname of this application. + EdgeIPs AppUpdateResponseEdgeIPs `json:"edge_ips"` + // Enables IP Access Rules for this application. Notes: Only available for TCP + // applications. + IPFirewall bool `json:"ip_firewall"` + // When the Application was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // The name and type of DNS record for the Spectrum application. + OriginDNS AppUpdateResponseOriginDNS `json:"origin_dns"` + // The destination port at the origin. Only specified in conjunction with + // origin_dns. May use an integer to specify a single origin port, for example + // `1000`, or a string to specify a range of origin ports, for example + // `"1000-2000"`. Notes: If specifying a port range, the number of ports in the + // range must match the number of ports specified in the "protocol" field. + OriginPort AppUpdateResponseOriginPort `json:"origin_port"` + // The port configuration at Cloudflare’s edge. May specify a single port, for + // example `"tcp/1000"`, or a range of ports, for example `"tcp/1000-2000"`. + Protocol string `json:"protocol"` + // Enables Proxy Protocol to the origin. Refer to + // [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) + // for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple + // Proxy Protocol. + ProxyProtocol AppUpdateResponseProxyProtocol `json:"proxy_protocol"` + // The type of TLS termination associated with the application. + TLS AppUpdateResponseTLS `json:"tls"` + // Determines how data travels from the edge to your origin. When set to "direct", + // Spectrum will send traffic directly to your origin, and the application's type + // is derived from the `protocol`. When set to "http" or "https", Spectrum will + // apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and + // the application type matches this property exactly. + TrafficType AppUpdateResponseTrafficType `json:"traffic_type"` + JSON appUpdateResponseJSON `json:"-"` +} + +// appUpdateResponseJSON contains the JSON metadata for the struct +// [AppUpdateResponse] +type appUpdateResponseJSON struct { + ID apijson.Field + ArgoSmartRouting apijson.Field + CreatedOn apijson.Field + DNS apijson.Field + EdgeIPs apijson.Field + IPFirewall apijson.Field + ModifiedOn apijson.Field + OriginDNS apijson.Field + OriginPort apijson.Field + Protocol apijson.Field + ProxyProtocol apijson.Field + TLS apijson.Field + TrafficType apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appUpdateResponseJSON) RawJSON() string { + return r.raw +} + +// The name and type of DNS record for the Spectrum application. +type AppUpdateResponseDNS struct { + // The name of the DNS record associated with the application. + Name string `json:"name" format:"hostname"` + // The type of DNS record associated with the application. + Type AppUpdateResponseDNSType `json:"type"` + JSON appUpdateResponseDNSJSON `json:"-"` +} + +// appUpdateResponseDNSJSON contains the JSON metadata for the struct +// [AppUpdateResponseDNS] +type appUpdateResponseDNSJSON struct { + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppUpdateResponseDNS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appUpdateResponseDNSJSON) RawJSON() string { + return r.raw +} + +// The type of DNS record associated with the application. +type AppUpdateResponseDNSType string + +const ( + AppUpdateResponseDNSTypeCNAME AppUpdateResponseDNSType = "CNAME" + AppUpdateResponseDNSTypeAddress AppUpdateResponseDNSType = "ADDRESS" +) + +// The anycast edge IP configuration for the hostname of this application. +// +// Union satisfied by +// [spectrum.AppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable] or +// [spectrum.AppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable]. +type AppUpdateResponseEdgeIPs interface { + implementsSpectrumAppUpdateResponseEdgeIPs() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AppUpdateResponseEdgeIPs)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable{}), + }, + ) +} + +type AppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable struct { + // The IP versions supported for inbound connections on Spectrum anycast IPs. + Connectivity AppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity `json:"connectivity"` + // The type of edge IP configuration specified. Dynamically allocated edge IPs use + // Spectrum anycast IPs in accordance with the connectivity you specify. Only valid + // with CNAME DNS names. + Type AppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableType `json:"type"` + JSON appUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableJSON `json:"-"` +} + +// appUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableJSON contains the JSON +// metadata for the struct +// [AppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable] +type appUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableJSON struct { + Connectivity apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableJSON) RawJSON() string { + return r.raw +} + +func (r AppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable) implementsSpectrumAppUpdateResponseEdgeIPs() { +} + +// The IP versions supported for inbound connections on Spectrum anycast IPs. +type AppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity string + +const ( + AppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityAll AppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "all" + AppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityIPV4 AppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "ipv4" + AppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityIPV6 AppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "ipv6" +) + +// The type of edge IP configuration specified. Dynamically allocated edge IPs use +// Spectrum anycast IPs in accordance with the connectivity you specify. Only valid +// with CNAME DNS names. +type AppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableType string + +const ( + AppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableTypeDynamic AppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableType = "dynamic" +) + +type AppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable struct { + // The array of customer owned IPs we broadcast via anycast for this hostname and + // application. + IPs []string `json:"ips"` + // The type of edge IP configuration specified. Statically allocated edge IPs use + // customer IPs in accordance with the ips array you specify. Only valid with + // ADDRESS DNS names. + Type AppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType `json:"type"` + JSON appUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableJSON `json:"-"` +} + +// appUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableJSON contains the +// JSON metadata for the struct +// [AppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable] +type appUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableJSON struct { + IPs apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableJSON) RawJSON() string { + return r.raw +} + +func (r AppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable) implementsSpectrumAppUpdateResponseEdgeIPs() { +} + +// The type of edge IP configuration specified. Statically allocated edge IPs use +// customer IPs in accordance with the ips array you specify. Only valid with +// ADDRESS DNS names. +type AppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType string + +const ( + AppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableTypeStatic AppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType = "static" +) + +// The name and type of DNS record for the Spectrum application. +type AppUpdateResponseOriginDNS struct { + // The name of the DNS record associated with the origin. + Name string `json:"name" format:"hostname"` + // The TTL of our resolution of your DNS record in seconds. + TTL int64 `json:"ttl"` + // The type of DNS record associated with the origin. "" is used to specify a + // combination of A/AAAA records. + Type AppUpdateResponseOriginDNSType `json:"type"` + JSON appUpdateResponseOriginDNSJSON `json:"-"` +} + +// appUpdateResponseOriginDNSJSON contains the JSON metadata for the struct +// [AppUpdateResponseOriginDNS] +type appUpdateResponseOriginDNSJSON struct { + Name apijson.Field + TTL apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppUpdateResponseOriginDNS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appUpdateResponseOriginDNSJSON) RawJSON() string { + return r.raw +} + +// The type of DNS record associated with the origin. "" is used to specify a +// combination of A/AAAA records. +type AppUpdateResponseOriginDNSType string + +const ( + AppUpdateResponseOriginDNSTypeEmpty AppUpdateResponseOriginDNSType = "" + AppUpdateResponseOriginDNSTypeA AppUpdateResponseOriginDNSType = "A" + AppUpdateResponseOriginDNSTypeAAAA AppUpdateResponseOriginDNSType = "AAAA" + AppUpdateResponseOriginDNSTypeSRV AppUpdateResponseOriginDNSType = "SRV" +) + +// The destination port at the origin. Only specified in conjunction with +// origin_dns. May use an integer to specify a single origin port, for example +// `1000`, or a string to specify a range of origin ports, for example +// `"1000-2000"`. Notes: If specifying a port range, the number of ports in the +// range must match the number of ports specified in the "protocol" field. +// +// Union satisfied by [shared.UnionInt] or [shared.UnionString]. +type AppUpdateResponseOriginPort interface { + ImplementsSpectrumAppUpdateResponseOriginPort() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AppUpdateResponseOriginPort)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionInt(0)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Enables Proxy Protocol to the origin. Refer to +// [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) +// for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple +// Proxy Protocol. +type AppUpdateResponseProxyProtocol string + +const ( + AppUpdateResponseProxyProtocolOff AppUpdateResponseProxyProtocol = "off" + AppUpdateResponseProxyProtocolV1 AppUpdateResponseProxyProtocol = "v1" + AppUpdateResponseProxyProtocolV2 AppUpdateResponseProxyProtocol = "v2" + AppUpdateResponseProxyProtocolSimple AppUpdateResponseProxyProtocol = "simple" +) + +// The type of TLS termination associated with the application. +type AppUpdateResponseTLS string + +const ( + AppUpdateResponseTLSOff AppUpdateResponseTLS = "off" + AppUpdateResponseTLSFlexible AppUpdateResponseTLS = "flexible" + AppUpdateResponseTLSFull AppUpdateResponseTLS = "full" + AppUpdateResponseTLSStrict AppUpdateResponseTLS = "strict" +) + +// Determines how data travels from the edge to your origin. When set to "direct", +// Spectrum will send traffic directly to your origin, and the application's type +// is derived from the `protocol`. When set to "http" or "https", Spectrum will +// apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and +// the application type matches this property exactly. +type AppUpdateResponseTrafficType string + +const ( + AppUpdateResponseTrafficTypeDirect AppUpdateResponseTrafficType = "direct" + AppUpdateResponseTrafficTypeHTTP AppUpdateResponseTrafficType = "http" + AppUpdateResponseTrafficTypeHTTPS AppUpdateResponseTrafficType = "https" +) + +type AppListResponse = interface{} + +type AppDeleteResponse struct { + // Application identifier. + ID string `json:"id"` + JSON appDeleteResponseJSON `json:"-"` +} + +// appDeleteResponseJSON contains the JSON metadata for the struct +// [AppDeleteResponse] +type appDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appDeleteResponseJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [spectrum.AppGetResponseUnknown] or [shared.UnionString]. +type AppGetResponse interface { + ImplementsSpectrumAppGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AppGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type AppNewParams struct { + // The name and type of DNS record for the Spectrum application. + DNS param.Field[AppNewParamsDNS] `json:"dns,required"` + // The name and type of DNS record for the Spectrum application. + OriginDNS param.Field[AppNewParamsOriginDNS] `json:"origin_dns,required"` + // The destination port at the origin. Only specified in conjunction with + // origin_dns. May use an integer to specify a single origin port, for example + // `1000`, or a string to specify a range of origin ports, for example + // `"1000-2000"`. Notes: If specifying a port range, the number of ports in the + // range must match the number of ports specified in the "protocol" field. + OriginPort param.Field[AppNewParamsOriginPort] `json:"origin_port,required"` + // The port configuration at Cloudflare’s edge. May specify a single port, for + // example `"tcp/1000"`, or a range of ports, for example `"tcp/1000-2000"`. + Protocol param.Field[string] `json:"protocol,required"` + // Enables Argo Smart Routing for this application. Notes: Only available for TCP + // applications with traffic_type set to "direct". + ArgoSmartRouting param.Field[bool] `json:"argo_smart_routing"` + // The anycast edge IP configuration for the hostname of this application. + EdgeIPs param.Field[AppNewParamsEdgeIPs] `json:"edge_ips"` + // Enables IP Access Rules for this application. Notes: Only available for TCP + // applications. + IPFirewall param.Field[bool] `json:"ip_firewall"` + // Enables Proxy Protocol to the origin. Refer to + // [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) + // for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple + // Proxy Protocol. + ProxyProtocol param.Field[AppNewParamsProxyProtocol] `json:"proxy_protocol"` + // The type of TLS termination associated with the application. + TLS param.Field[AppNewParamsTLS] `json:"tls"` + // Determines how data travels from the edge to your origin. When set to "direct", + // Spectrum will send traffic directly to your origin, and the application's type + // is derived from the `protocol`. When set to "http" or "https", Spectrum will + // apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and + // the application type matches this property exactly. + TrafficType param.Field[AppNewParamsTrafficType] `json:"traffic_type"` +} + +func (r AppNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The name and type of DNS record for the Spectrum application. +type AppNewParamsDNS struct { + // The name of the DNS record associated with the application. + Name param.Field[string] `json:"name" format:"hostname"` + // The type of DNS record associated with the application. + Type param.Field[AppNewParamsDNSType] `json:"type"` +} + +func (r AppNewParamsDNS) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of DNS record associated with the application. +type AppNewParamsDNSType string + +const ( + AppNewParamsDNSTypeCNAME AppNewParamsDNSType = "CNAME" + AppNewParamsDNSTypeAddress AppNewParamsDNSType = "ADDRESS" +) + +// The name and type of DNS record for the Spectrum application. +type AppNewParamsOriginDNS struct { + // The name of the DNS record associated with the origin. + Name param.Field[string] `json:"name" format:"hostname"` + // The TTL of our resolution of your DNS record in seconds. + TTL param.Field[int64] `json:"ttl"` + // The type of DNS record associated with the origin. "" is used to specify a + // combination of A/AAAA records. + Type param.Field[AppNewParamsOriginDNSType] `json:"type"` +} + +func (r AppNewParamsOriginDNS) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of DNS record associated with the origin. "" is used to specify a +// combination of A/AAAA records. +type AppNewParamsOriginDNSType string + +const ( + AppNewParamsOriginDNSTypeEmpty AppNewParamsOriginDNSType = "" + AppNewParamsOriginDNSTypeA AppNewParamsOriginDNSType = "A" + AppNewParamsOriginDNSTypeAAAA AppNewParamsOriginDNSType = "AAAA" + AppNewParamsOriginDNSTypeSRV AppNewParamsOriginDNSType = "SRV" +) + +// The destination port at the origin. Only specified in conjunction with +// origin_dns. May use an integer to specify a single origin port, for example +// `1000`, or a string to specify a range of origin ports, for example +// `"1000-2000"`. Notes: If specifying a port range, the number of ports in the +// range must match the number of ports specified in the "protocol" field. +// +// Satisfied by [shared.UnionInt], [shared.UnionString]. +type AppNewParamsOriginPort interface { + ImplementsSpectrumAppNewParamsOriginPort() +} + +// The anycast edge IP configuration for the hostname of this application. +// +// Satisfied by [spectrum.AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable], +// [spectrum.AppNewParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable]. +type AppNewParamsEdgeIPs interface { + implementsSpectrumAppNewParamsEdgeIPs() +} + +type AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable struct { + // The IP versions supported for inbound connections on Spectrum anycast IPs. + Connectivity param.Field[AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity] `json:"connectivity"` + // The type of edge IP configuration specified. Dynamically allocated edge IPs use + // Spectrum anycast IPs in accordance with the connectivity you specify. Only valid + // with CNAME DNS names. + Type param.Field[AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableType] `json:"type"` +} + +func (r AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable) implementsSpectrumAppNewParamsEdgeIPs() { +} + +// The IP versions supported for inbound connections on Spectrum anycast IPs. +type AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity string + +const ( + AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityAll AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "all" + AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityIPV4 AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "ipv4" + AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityIPV6 AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "ipv6" +) + +// The type of edge IP configuration specified. Dynamically allocated edge IPs use +// Spectrum anycast IPs in accordance with the connectivity you specify. Only valid +// with CNAME DNS names. +type AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableType string + +const ( + AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableTypeDynamic AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableType = "dynamic" +) + +type AppNewParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable struct { + // The array of customer owned IPs we broadcast via anycast for this hostname and + // application. + IPs param.Field[[]string] `json:"ips"` + // The type of edge IP configuration specified. Statically allocated edge IPs use + // customer IPs in accordance with the ips array you specify. Only valid with + // ADDRESS DNS names. + Type param.Field[AppNewParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType] `json:"type"` +} + +func (r AppNewParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AppNewParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable) implementsSpectrumAppNewParamsEdgeIPs() { +} + +// The type of edge IP configuration specified. Statically allocated edge IPs use +// customer IPs in accordance with the ips array you specify. Only valid with +// ADDRESS DNS names. +type AppNewParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType string + +const ( + AppNewParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableTypeStatic AppNewParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType = "static" +) + +// Enables Proxy Protocol to the origin. Refer to +// [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) +// for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple +// Proxy Protocol. +type AppNewParamsProxyProtocol string + +const ( + AppNewParamsProxyProtocolOff AppNewParamsProxyProtocol = "off" + AppNewParamsProxyProtocolV1 AppNewParamsProxyProtocol = "v1" + AppNewParamsProxyProtocolV2 AppNewParamsProxyProtocol = "v2" + AppNewParamsProxyProtocolSimple AppNewParamsProxyProtocol = "simple" +) + +// The type of TLS termination associated with the application. +type AppNewParamsTLS string + +const ( + AppNewParamsTLSOff AppNewParamsTLS = "off" + AppNewParamsTLSFlexible AppNewParamsTLS = "flexible" + AppNewParamsTLSFull AppNewParamsTLS = "full" + AppNewParamsTLSStrict AppNewParamsTLS = "strict" +) + +// Determines how data travels from the edge to your origin. When set to "direct", +// Spectrum will send traffic directly to your origin, and the application's type +// is derived from the `protocol`. When set to "http" or "https", Spectrum will +// apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and +// the application type matches this property exactly. +type AppNewParamsTrafficType string + +const ( + AppNewParamsTrafficTypeDirect AppNewParamsTrafficType = "direct" + AppNewParamsTrafficTypeHTTP AppNewParamsTrafficType = "http" + AppNewParamsTrafficTypeHTTPS AppNewParamsTrafficType = "https" +) + +type AppNewResponseEnvelope struct { + Errors []AppNewResponseEnvelopeErrors `json:"errors,required"` + Messages []AppNewResponseEnvelopeMessages `json:"messages,required"` + Result AppNewResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AppNewResponseEnvelopeSuccess `json:"success,required"` + JSON appNewResponseEnvelopeJSON `json:"-"` +} + +// appNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [AppNewResponseEnvelope] +type appNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AppNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON appNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// appNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [AppNewResponseEnvelopeErrors] +type appNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AppNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON appNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// appNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [AppNewResponseEnvelopeMessages] +type appNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AppNewResponseEnvelopeSuccess bool + +const ( + AppNewResponseEnvelopeSuccessTrue AppNewResponseEnvelopeSuccess = true +) + +type AppUpdateParams struct { + // The name and type of DNS record for the Spectrum application. + DNS param.Field[AppUpdateParamsDNS] `json:"dns,required"` + // The name and type of DNS record for the Spectrum application. + OriginDNS param.Field[AppUpdateParamsOriginDNS] `json:"origin_dns,required"` + // The destination port at the origin. Only specified in conjunction with + // origin_dns. May use an integer to specify a single origin port, for example + // `1000`, or a string to specify a range of origin ports, for example + // `"1000-2000"`. Notes: If specifying a port range, the number of ports in the + // range must match the number of ports specified in the "protocol" field. + OriginPort param.Field[AppUpdateParamsOriginPort] `json:"origin_port,required"` + // The port configuration at Cloudflare’s edge. May specify a single port, for + // example `"tcp/1000"`, or a range of ports, for example `"tcp/1000-2000"`. + Protocol param.Field[string] `json:"protocol,required"` + // Enables Argo Smart Routing for this application. Notes: Only available for TCP + // applications with traffic_type set to "direct". + ArgoSmartRouting param.Field[bool] `json:"argo_smart_routing"` + // The anycast edge IP configuration for the hostname of this application. + EdgeIPs param.Field[AppUpdateParamsEdgeIPs] `json:"edge_ips"` + // Enables IP Access Rules for this application. Notes: Only available for TCP + // applications. + IPFirewall param.Field[bool] `json:"ip_firewall"` + // Enables Proxy Protocol to the origin. Refer to + // [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) + // for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple + // Proxy Protocol. + ProxyProtocol param.Field[AppUpdateParamsProxyProtocol] `json:"proxy_protocol"` + // The type of TLS termination associated with the application. + TLS param.Field[AppUpdateParamsTLS] `json:"tls"` + // Determines how data travels from the edge to your origin. When set to "direct", + // Spectrum will send traffic directly to your origin, and the application's type + // is derived from the `protocol`. When set to "http" or "https", Spectrum will + // apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and + // the application type matches this property exactly. + TrafficType param.Field[AppUpdateParamsTrafficType] `json:"traffic_type"` +} + +func (r AppUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The name and type of DNS record for the Spectrum application. +type AppUpdateParamsDNS struct { + // The name of the DNS record associated with the application. + Name param.Field[string] `json:"name" format:"hostname"` + // The type of DNS record associated with the application. + Type param.Field[AppUpdateParamsDNSType] `json:"type"` +} + +func (r AppUpdateParamsDNS) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of DNS record associated with the application. +type AppUpdateParamsDNSType string + +const ( + AppUpdateParamsDNSTypeCNAME AppUpdateParamsDNSType = "CNAME" + AppUpdateParamsDNSTypeAddress AppUpdateParamsDNSType = "ADDRESS" +) + +// The name and type of DNS record for the Spectrum application. +type AppUpdateParamsOriginDNS struct { + // The name of the DNS record associated with the origin. + Name param.Field[string] `json:"name" format:"hostname"` + // The TTL of our resolution of your DNS record in seconds. + TTL param.Field[int64] `json:"ttl"` + // The type of DNS record associated with the origin. "" is used to specify a + // combination of A/AAAA records. + Type param.Field[AppUpdateParamsOriginDNSType] `json:"type"` +} + +func (r AppUpdateParamsOriginDNS) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of DNS record associated with the origin. "" is used to specify a +// combination of A/AAAA records. +type AppUpdateParamsOriginDNSType string + +const ( + AppUpdateParamsOriginDNSTypeEmpty AppUpdateParamsOriginDNSType = "" + AppUpdateParamsOriginDNSTypeA AppUpdateParamsOriginDNSType = "A" + AppUpdateParamsOriginDNSTypeAAAA AppUpdateParamsOriginDNSType = "AAAA" + AppUpdateParamsOriginDNSTypeSRV AppUpdateParamsOriginDNSType = "SRV" +) + +// The destination port at the origin. Only specified in conjunction with +// origin_dns. May use an integer to specify a single origin port, for example +// `1000`, or a string to specify a range of origin ports, for example +// `"1000-2000"`. Notes: If specifying a port range, the number of ports in the +// range must match the number of ports specified in the "protocol" field. +// +// Satisfied by [shared.UnionInt], [shared.UnionString]. +type AppUpdateParamsOriginPort interface { + ImplementsSpectrumAppUpdateParamsOriginPort() +} + +// The anycast edge IP configuration for the hostname of this application. +// +// Satisfied by [spectrum.AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable], +// [spectrum.AppUpdateParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable]. +type AppUpdateParamsEdgeIPs interface { + implementsSpectrumAppUpdateParamsEdgeIPs() +} + +type AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable struct { + // The IP versions supported for inbound connections on Spectrum anycast IPs. + Connectivity param.Field[AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity] `json:"connectivity"` + // The type of edge IP configuration specified. Dynamically allocated edge IPs use + // Spectrum anycast IPs in accordance with the connectivity you specify. Only valid + // with CNAME DNS names. + Type param.Field[AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableType] `json:"type"` +} + +func (r AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable) implementsSpectrumAppUpdateParamsEdgeIPs() { +} + +// The IP versions supported for inbound connections on Spectrum anycast IPs. +type AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity string + +const ( + AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityAll AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "all" + AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityIPV4 AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "ipv4" + AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityIPV6 AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "ipv6" +) + +// The type of edge IP configuration specified. Dynamically allocated edge IPs use +// Spectrum anycast IPs in accordance with the connectivity you specify. Only valid +// with CNAME DNS names. +type AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableType string + +const ( + AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableTypeDynamic AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableType = "dynamic" +) + +type AppUpdateParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable struct { + // The array of customer owned IPs we broadcast via anycast for this hostname and + // application. + IPs param.Field[[]string] `json:"ips"` + // The type of edge IP configuration specified. Statically allocated edge IPs use + // customer IPs in accordance with the ips array you specify. Only valid with + // ADDRESS DNS names. + Type param.Field[AppUpdateParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType] `json:"type"` +} + +func (r AppUpdateParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AppUpdateParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable) implementsSpectrumAppUpdateParamsEdgeIPs() { +} + +// The type of edge IP configuration specified. Statically allocated edge IPs use +// customer IPs in accordance with the ips array you specify. Only valid with +// ADDRESS DNS names. +type AppUpdateParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType string + +const ( + AppUpdateParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableTypeStatic AppUpdateParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType = "static" +) + +// Enables Proxy Protocol to the origin. Refer to +// [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) +// for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple +// Proxy Protocol. +type AppUpdateParamsProxyProtocol string + +const ( + AppUpdateParamsProxyProtocolOff AppUpdateParamsProxyProtocol = "off" + AppUpdateParamsProxyProtocolV1 AppUpdateParamsProxyProtocol = "v1" + AppUpdateParamsProxyProtocolV2 AppUpdateParamsProxyProtocol = "v2" + AppUpdateParamsProxyProtocolSimple AppUpdateParamsProxyProtocol = "simple" +) + +// The type of TLS termination associated with the application. +type AppUpdateParamsTLS string + +const ( + AppUpdateParamsTLSOff AppUpdateParamsTLS = "off" + AppUpdateParamsTLSFlexible AppUpdateParamsTLS = "flexible" + AppUpdateParamsTLSFull AppUpdateParamsTLS = "full" + AppUpdateParamsTLSStrict AppUpdateParamsTLS = "strict" +) + +// Determines how data travels from the edge to your origin. When set to "direct", +// Spectrum will send traffic directly to your origin, and the application's type +// is derived from the `protocol`. When set to "http" or "https", Spectrum will +// apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and +// the application type matches this property exactly. +type AppUpdateParamsTrafficType string + +const ( + AppUpdateParamsTrafficTypeDirect AppUpdateParamsTrafficType = "direct" + AppUpdateParamsTrafficTypeHTTP AppUpdateParamsTrafficType = "http" + AppUpdateParamsTrafficTypeHTTPS AppUpdateParamsTrafficType = "https" +) + +type AppUpdateResponseEnvelope struct { + Errors []AppUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []AppUpdateResponseEnvelopeMessages `json:"messages,required"` + Result AppUpdateResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AppUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON appUpdateResponseEnvelopeJSON `json:"-"` +} + +// appUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [AppUpdateResponseEnvelope] +type appUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AppUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON appUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// appUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [AppUpdateResponseEnvelopeErrors] +type appUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AppUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON appUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// appUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [AppUpdateResponseEnvelopeMessages] +type appUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AppUpdateResponseEnvelopeSuccess bool + +const ( + AppUpdateResponseEnvelopeSuccessTrue AppUpdateResponseEnvelopeSuccess = true +) + +type AppListParams struct { + // Sets the direction by which results are ordered. + Direction param.Field[AppListParamsDirection] `query:"direction"` + // Application field by which results are ordered. + Order param.Field[AppListParamsOrder] `query:"order"` + // Page number of paginated results. This parameter is required in order to use + // other pagination parameters. If included in the query, `result_info` will be + // present in the response. + Page param.Field[float64] `query:"page"` + // Sets the maximum number of results per page. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [AppListParams]'s query parameters as `url.Values`. +func (r AppListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Sets the direction by which results are ordered. +type AppListParamsDirection string + +const ( + AppListParamsDirectionAsc AppListParamsDirection = "asc" + AppListParamsDirectionDesc AppListParamsDirection = "desc" +) + +// Application field by which results are ordered. +type AppListParamsOrder string + +const ( + AppListParamsOrderProtocol AppListParamsOrder = "protocol" + AppListParamsOrderAppID AppListParamsOrder = "app_id" + AppListParamsOrderCreatedOn AppListParamsOrder = "created_on" + AppListParamsOrderModifiedOn AppListParamsOrder = "modified_on" + AppListParamsOrderDNS AppListParamsOrder = "dns" +) + +type AppDeleteResponseEnvelope struct { + Errors []AppDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []AppDeleteResponseEnvelopeMessages `json:"messages,required"` + Result AppDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AppDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON appDeleteResponseEnvelopeJSON `json:"-"` +} + +// appDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [AppDeleteResponseEnvelope] +type appDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AppDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON appDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// appDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [AppDeleteResponseEnvelopeErrors] +type appDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AppDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON appDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// appDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [AppDeleteResponseEnvelopeMessages] +type appDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AppDeleteResponseEnvelopeSuccess bool + +const ( + AppDeleteResponseEnvelopeSuccessTrue AppDeleteResponseEnvelopeSuccess = true +) + +type AppGetResponseEnvelope struct { + Errors []AppGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AppGetResponseEnvelopeMessages `json:"messages,required"` + Result AppGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AppGetResponseEnvelopeSuccess `json:"success,required"` + JSON appGetResponseEnvelopeJSON `json:"-"` +} + +// appGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [AppGetResponseEnvelope] +type appGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AppGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON appGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// appGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [AppGetResponseEnvelopeErrors] +type appGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AppGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON appGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// appGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [AppGetResponseEnvelopeMessages] +type appGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AppGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r appGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AppGetResponseEnvelopeSuccess bool + +const ( + AppGetResponseEnvelopeSuccessTrue AppGetResponseEnvelopeSuccess = true +) diff --git a/spectrum/app_test.go b/spectrum/app_test.go new file mode 100644 index 00000000000..43dec4fc3d8 --- /dev/null +++ b/spectrum/app_test.go @@ -0,0 +1,204 @@ +// File generated from our OpenAPI spec by Stainless. + +package spectrum_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/spectrum" +) + +func TestAppNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Spectrum.Apps.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + spectrum.AppNewParams{ + DNS: cloudflare.F(spectrum.AppNewParamsDNS{ + Name: cloudflare.F("ssh.example.com"), + Type: cloudflare.F(spectrum.AppNewParamsDNSTypeCNAME), + }), + OriginDNS: cloudflare.F(spectrum.AppNewParamsOriginDNS{ + Name: cloudflare.F("origin.example.com"), + TTL: cloudflare.F(int64(600)), + Type: cloudflare.F(spectrum.AppNewParamsOriginDNSTypeEmpty), + }), + OriginPort: cloudflare.F[spectrum.AppNewParamsOriginPort](shared.UnionInt(int64(22))), + Protocol: cloudflare.F("tcp/22"), + ArgoSmartRouting: cloudflare.F(true), + EdgeIPs: cloudflare.F[spectrum.AppNewParamsEdgeIPs](spectrum.AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable(spectrum.AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable{ + Connectivity: cloudflare.F(spectrum.AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityAll), + Type: cloudflare.F(spectrum.AppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableTypeDynamic), + })), + IPFirewall: cloudflare.F(true), + ProxyProtocol: cloudflare.F(spectrum.AppNewParamsProxyProtocolOff), + TLS: cloudflare.F(spectrum.AppNewParamsTLSFull), + TrafficType: cloudflare.F(spectrum.AppNewParamsTrafficTypeDirect), + }, + ) + 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 TestAppUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Spectrum.Apps.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "ea95132c15732412d22c1476fa83f27a", + spectrum.AppUpdateParams{ + DNS: cloudflare.F(spectrum.AppUpdateParamsDNS{ + Name: cloudflare.F("ssh.example.com"), + Type: cloudflare.F(spectrum.AppUpdateParamsDNSTypeCNAME), + }), + OriginDNS: cloudflare.F(spectrum.AppUpdateParamsOriginDNS{ + Name: cloudflare.F("origin.example.com"), + TTL: cloudflare.F(int64(600)), + Type: cloudflare.F(spectrum.AppUpdateParamsOriginDNSTypeEmpty), + }), + OriginPort: cloudflare.F[spectrum.AppUpdateParamsOriginPort](shared.UnionInt(int64(22))), + Protocol: cloudflare.F("tcp/22"), + ArgoSmartRouting: cloudflare.F(true), + EdgeIPs: cloudflare.F[spectrum.AppUpdateParamsEdgeIPs](spectrum.AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable(spectrum.AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable{ + Connectivity: cloudflare.F(spectrum.AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityAll), + Type: cloudflare.F(spectrum.AppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableTypeDynamic), + })), + IPFirewall: cloudflare.F(true), + ProxyProtocol: cloudflare.F(spectrum.AppUpdateParamsProxyProtocolOff), + TLS: cloudflare.F(spectrum.AppUpdateParamsTLSFull), + TrafficType: cloudflare.F(spectrum.AppUpdateParamsTrafficTypeDirect), + }, + ) + 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 TestAppListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Spectrum.Apps.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + spectrum.AppListParams{ + Direction: cloudflare.F(spectrum.AppListParamsDirectionDesc), + Order: cloudflare.F(spectrum.AppListParamsOrderProtocol), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(1.000000), + }, + ) + 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 TestAppDelete(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("user@example.com"), + ) + _, err := client.Spectrum.Apps.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "ea95132c15732412d22c1476fa83f27a", + ) + 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 TestAppGet(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("user@example.com"), + ) + _, err := client.Spectrum.Apps.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "ea95132c15732412d22c1476fa83f27a", + ) + 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/spectrum.go b/spectrum/spectrum.go similarity index 82% rename from spectrum.go rename to spectrum/spectrum.go index ac0995065ca..66a6ca5a8be 100644 --- a/spectrum.go +++ b/spectrum/spectrum.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package spectrum import ( "github.com/cloudflare/cloudflare-go/option" @@ -12,8 +12,8 @@ import ( // service directly, and instead use the [NewSpectrumService] method instead. type SpectrumService struct { Options []option.RequestOption - Analytics *SpectrumAnalyticsService - Apps *SpectrumAppService + Analytics *AnalyticsService + Apps *AppService } // NewSpectrumService generates a new service that applies the given options to @@ -22,7 +22,7 @@ type SpectrumService struct { func NewSpectrumService(opts ...option.RequestOption) (r *SpectrumService) { r = &SpectrumService{} r.Options = opts - r.Analytics = NewSpectrumAnalyticsService(opts...) - r.Apps = NewSpectrumAppService(opts...) + r.Analytics = NewAnalyticsService(opts...) + r.Apps = NewAppService(opts...) return } diff --git a/spectrumanalytics.go b/spectrumanalytics.go deleted file mode 100644 index f1267a5443d..00000000000 --- a/spectrumanalytics.go +++ /dev/null @@ -1,29 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// SpectrumAnalyticsService 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 [NewSpectrumAnalyticsService] method -// instead. -type SpectrumAnalyticsService struct { - Options []option.RequestOption - Aggregates *SpectrumAnalyticsAggregateService - Events *SpectrumAnalyticsEventService -} - -// NewSpectrumAnalyticsService 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 NewSpectrumAnalyticsService(opts ...option.RequestOption) (r *SpectrumAnalyticsService) { - r = &SpectrumAnalyticsService{} - r.Options = opts - r.Aggregates = NewSpectrumAnalyticsAggregateService(opts...) - r.Events = NewSpectrumAnalyticsEventService(opts...) - return -} diff --git a/spectrumanalyticsaggregate.go b/spectrumanalyticsaggregate.go deleted file mode 100644 index 6e98aa2873c..00000000000 --- a/spectrumanalyticsaggregate.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// SpectrumAnalyticsAggregateService 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 -// [NewSpectrumAnalyticsAggregateService] method instead. -type SpectrumAnalyticsAggregateService struct { - Options []option.RequestOption - Currents *SpectrumAnalyticsAggregateCurrentService -} - -// NewSpectrumAnalyticsAggregateService 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 NewSpectrumAnalyticsAggregateService(opts ...option.RequestOption) (r *SpectrumAnalyticsAggregateService) { - r = &SpectrumAnalyticsAggregateService{} - r.Options = opts - r.Currents = NewSpectrumAnalyticsAggregateCurrentService(opts...) - return -} diff --git a/spectrumanalyticsaggregatecurrent.go b/spectrumanalyticsaggregatecurrent.go deleted file mode 100644 index 51e15b26785..00000000000 --- a/spectrumanalyticsaggregatecurrent.go +++ /dev/null @@ -1,153 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SpectrumAnalyticsAggregateCurrentService 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 -// [NewSpectrumAnalyticsAggregateCurrentService] method instead. -type SpectrumAnalyticsAggregateCurrentService struct { - Options []option.RequestOption -} - -// NewSpectrumAnalyticsAggregateCurrentService 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 NewSpectrumAnalyticsAggregateCurrentService(opts ...option.RequestOption) (r *SpectrumAnalyticsAggregateCurrentService) { - r = &SpectrumAnalyticsAggregateCurrentService{} - r.Options = opts - return -} - -// Retrieves analytics aggregated from the last minute of usage on Spectrum -// applications underneath a given zone. -func (r *SpectrumAnalyticsAggregateCurrentService) Get(ctx context.Context, zone string, query SpectrumAnalyticsAggregateCurrentGetParams, opts ...option.RequestOption) (res *[]SpectrumAnalyticsAggregateCurrentGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env SpectrumAnalyticsAggregateCurrentGetResponseEnvelope - path := fmt.Sprintf("zones/%s/spectrum/analytics/aggregate/current", zone) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SpectrumAnalyticsAggregateCurrentGetResponse = interface{} - -type SpectrumAnalyticsAggregateCurrentGetParams struct { - // Comma-delimited list of Spectrum Application Id(s). If provided, the response - // will be limited to Spectrum Application Id(s) that match. - AppIDParam param.Field[string] `query:"app_id_param"` - // Comma-delimited list of Spectrum Application Id(s). If provided, the response - // will be limited to Spectrum Application Id(s) that match. - AppID param.Field[string] `query:"appID"` - // Co-location identifier. - ColoName param.Field[string] `query:"colo_name"` -} - -// URLQuery serializes [SpectrumAnalyticsAggregateCurrentGetParams]'s query -// parameters as `url.Values`. -func (r SpectrumAnalyticsAggregateCurrentGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type SpectrumAnalyticsAggregateCurrentGetResponseEnvelope struct { - Errors []SpectrumAnalyticsAggregateCurrentGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SpectrumAnalyticsAggregateCurrentGetResponseEnvelopeMessages `json:"messages,required"` - Result []SpectrumAnalyticsAggregateCurrentGetResponse `json:"result,required"` - // Whether the API call was successful - Success SpectrumAnalyticsAggregateCurrentGetResponseEnvelopeSuccess `json:"success,required"` - JSON spectrumAnalyticsAggregateCurrentGetResponseEnvelopeJSON `json:"-"` -} - -// spectrumAnalyticsAggregateCurrentGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [SpectrumAnalyticsAggregateCurrentGetResponseEnvelope] -type spectrumAnalyticsAggregateCurrentGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAnalyticsAggregateCurrentGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAnalyticsAggregateCurrentGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SpectrumAnalyticsAggregateCurrentGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON spectrumAnalyticsAggregateCurrentGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// spectrumAnalyticsAggregateCurrentGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [SpectrumAnalyticsAggregateCurrentGetResponseEnvelopeErrors] -type spectrumAnalyticsAggregateCurrentGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAnalyticsAggregateCurrentGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAnalyticsAggregateCurrentGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SpectrumAnalyticsAggregateCurrentGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON spectrumAnalyticsAggregateCurrentGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// spectrumAnalyticsAggregateCurrentGetResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [SpectrumAnalyticsAggregateCurrentGetResponseEnvelopeMessages] -type spectrumAnalyticsAggregateCurrentGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAnalyticsAggregateCurrentGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAnalyticsAggregateCurrentGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SpectrumAnalyticsAggregateCurrentGetResponseEnvelopeSuccess bool - -const ( - SpectrumAnalyticsAggregateCurrentGetResponseEnvelopeSuccessTrue SpectrumAnalyticsAggregateCurrentGetResponseEnvelopeSuccess = true -) diff --git a/spectrumanalyticsaggregatecurrent_test.go b/spectrumanalyticsaggregatecurrent_test.go deleted file mode 100644 index 40b2c6516a8..00000000000 --- a/spectrumanalyticsaggregatecurrent_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSpectrumAnalyticsAggregateCurrentGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Spectrum.Analytics.Aggregates.Currents.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.SpectrumAnalyticsAggregateCurrentGetParams{ - AppIDParam: cloudflare.F("ea95132c15732412d22c1476fa83f27a,d122c5f4bb71e25cc9e86ab43b142e2f"), - AppID: cloudflare.F("ea95132c15732412d22c1476fa83f27a,d122c5f4bb71e25cc9e86ab43b142e2f"), - ColoName: cloudflare.F("PDX"), - }, - ) - 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/spectrumanalyticsevent.go b/spectrumanalyticsevent.go deleted file mode 100644 index 66118d55dc6..00000000000 --- a/spectrumanalyticsevent.go +++ /dev/null @@ -1,29 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// SpectrumAnalyticsEventService 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 [NewSpectrumAnalyticsEventService] -// method instead. -type SpectrumAnalyticsEventService struct { - Options []option.RequestOption - Bytimes *SpectrumAnalyticsEventBytimeService - Summaries *SpectrumAnalyticsEventSummaryService -} - -// NewSpectrumAnalyticsEventService 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 NewSpectrumAnalyticsEventService(opts ...option.RequestOption) (r *SpectrumAnalyticsEventService) { - r = &SpectrumAnalyticsEventService{} - r.Options = opts - r.Bytimes = NewSpectrumAnalyticsEventBytimeService(opts...) - r.Summaries = NewSpectrumAnalyticsEventSummaryService(opts...) - return -} diff --git a/spectrumanalyticseventbytime.go b/spectrumanalyticseventbytime.go deleted file mode 100644 index e3ebcce6eed..00000000000 --- a/spectrumanalyticseventbytime.go +++ /dev/null @@ -1,245 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// SpectrumAnalyticsEventBytimeService 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 -// [NewSpectrumAnalyticsEventBytimeService] method instead. -type SpectrumAnalyticsEventBytimeService struct { - Options []option.RequestOption -} - -// NewSpectrumAnalyticsEventBytimeService 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 NewSpectrumAnalyticsEventBytimeService(opts ...option.RequestOption) (r *SpectrumAnalyticsEventBytimeService) { - r = &SpectrumAnalyticsEventBytimeService{} - r.Options = opts - return -} - -// Retrieves a list of aggregate metrics grouped by time interval. -func (r *SpectrumAnalyticsEventBytimeService) Get(ctx context.Context, zone string, query SpectrumAnalyticsEventBytimeGetParams, opts ...option.RequestOption) (res *SpectrumAnalyticsEventBytimeGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env SpectrumAnalyticsEventBytimeGetResponseEnvelope - path := fmt.Sprintf("zones/%s/spectrum/analytics/events/bytime", zone) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [SpectrumAnalyticsEventBytimeGetResponseUnknown] or -// [shared.UnionString]. -type SpectrumAnalyticsEventBytimeGetResponse interface { - ImplementsSpectrumAnalyticsEventBytimeGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SpectrumAnalyticsEventBytimeGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type SpectrumAnalyticsEventBytimeGetParams struct { - // Can be used to break down the data by given attributes. Options are: - // - // | Dimension | Name | Example | - // | --------- | ----------------------------- | ---------------------------------------------------------- | - // | event | Connection Event | connect, progress, disconnect, originError, clientFiltered | - // | appID | Application ID | 40d67c87c6cd4b889a4fd57805225e85 | - // | coloName | Colo Name | SFO | - // | ipVersion | IP version used by the client | 4, 6. | - Dimensions param.Field[[]SpectrumAnalyticsEventBytimeGetParamsDimension] `query:"dimensions"` - // Used to filter rows by one or more dimensions. Filters can be combined using OR - // and AND boolean logic. AND takes precedence over OR in all the expressions. The - // OR operator is defined using a comma (,) or OR keyword surrounded by whitespace. - // The AND operator is defined using a semicolon (;) or AND keyword surrounded by - // whitespace. Note that the semicolon is a reserved character in URLs (rfc1738) - // and needs to be percent-encoded as %3B. Comparison options are: - // - // | Operator | Name | URL Encoded | - // | -------- | ------------------------ | ----------- | - // | == | Equals | %3D%3D | - // | != | Does not equals | !%3D | - // | > | Greater Than | %3E | - // | < | Less Than | %3C | - // | >= | Greater than or equal to | %3E%3D | - // | <= | Less than or equal to | %3C%3D . | - Filters param.Field[string] `query:"filters"` - // One or more metrics to compute. Options are: - // - // | Metric | Name | Example | Unit | - // | -------------- | ----------------------------------- | ------- | --------------------- | - // | count | Count of total events | 1000 | Count | - // | bytesIngress | Sum of ingress bytes | 1000 | Sum | - // | bytesEgress | Sum of egress bytes | 1000 | Sum | - // | durationAvg | Average connection duration | 1.0 | Time in milliseconds | - // | durationMedian | Median connection duration | 1.0 | Time in milliseconds | - // | duration90th | 90th percentile connection duration | 1.0 | Time in milliseconds | - // | duration99th | 99th percentile connection duration | 1.0 | Time in milliseconds. | - Metrics param.Field[[]SpectrumAnalyticsEventBytimeGetParamsMetric] `query:"metrics"` - // Start of time interval to query, defaults to `until` - 6 hours. Timestamp must - // be in RFC3339 format and uses UTC unless otherwise specified. - Since param.Field[time.Time] `query:"since" format:"date-time"` - // The sort order for the result set; sort fields must be included in `metrics` or - // `dimensions`. - Sort param.Field[[]interface{}] `query:"sort"` - // Used to select time series resolution. - TimeDelta param.Field[SpectrumAnalyticsEventBytimeGetParamsTimeDelta] `query:"time_delta"` - // End of time interval to query, defaults to current time. Timestamp must be in - // RFC3339 format and uses UTC unless otherwise specified. - Until param.Field[time.Time] `query:"until" format:"date-time"` -} - -// URLQuery serializes [SpectrumAnalyticsEventBytimeGetParams]'s query parameters -// as `url.Values`. -func (r SpectrumAnalyticsEventBytimeGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type SpectrumAnalyticsEventBytimeGetParamsDimension string - -const ( - SpectrumAnalyticsEventBytimeGetParamsDimensionEvent SpectrumAnalyticsEventBytimeGetParamsDimension = "event" - SpectrumAnalyticsEventBytimeGetParamsDimensionAppID SpectrumAnalyticsEventBytimeGetParamsDimension = "appID" - SpectrumAnalyticsEventBytimeGetParamsDimensionColoName SpectrumAnalyticsEventBytimeGetParamsDimension = "coloName" - SpectrumAnalyticsEventBytimeGetParamsDimensionIPVersion SpectrumAnalyticsEventBytimeGetParamsDimension = "ipVersion" -) - -type SpectrumAnalyticsEventBytimeGetParamsMetric string - -const ( - SpectrumAnalyticsEventBytimeGetParamsMetricCount SpectrumAnalyticsEventBytimeGetParamsMetric = "count" - SpectrumAnalyticsEventBytimeGetParamsMetricBytesIngress SpectrumAnalyticsEventBytimeGetParamsMetric = "bytesIngress" - SpectrumAnalyticsEventBytimeGetParamsMetricBytesEgress SpectrumAnalyticsEventBytimeGetParamsMetric = "bytesEgress" - SpectrumAnalyticsEventBytimeGetParamsMetricDurationAvg SpectrumAnalyticsEventBytimeGetParamsMetric = "durationAvg" - SpectrumAnalyticsEventBytimeGetParamsMetricDurationMedian SpectrumAnalyticsEventBytimeGetParamsMetric = "durationMedian" - SpectrumAnalyticsEventBytimeGetParamsMetricDuration90th SpectrumAnalyticsEventBytimeGetParamsMetric = "duration90th" - SpectrumAnalyticsEventBytimeGetParamsMetricDuration99th SpectrumAnalyticsEventBytimeGetParamsMetric = "duration99th" -) - -// Used to select time series resolution. -type SpectrumAnalyticsEventBytimeGetParamsTimeDelta string - -const ( - SpectrumAnalyticsEventBytimeGetParamsTimeDeltaYear SpectrumAnalyticsEventBytimeGetParamsTimeDelta = "year" - SpectrumAnalyticsEventBytimeGetParamsTimeDeltaQuarter SpectrumAnalyticsEventBytimeGetParamsTimeDelta = "quarter" - SpectrumAnalyticsEventBytimeGetParamsTimeDeltaMonth SpectrumAnalyticsEventBytimeGetParamsTimeDelta = "month" - SpectrumAnalyticsEventBytimeGetParamsTimeDeltaWeek SpectrumAnalyticsEventBytimeGetParamsTimeDelta = "week" - SpectrumAnalyticsEventBytimeGetParamsTimeDeltaDay SpectrumAnalyticsEventBytimeGetParamsTimeDelta = "day" - SpectrumAnalyticsEventBytimeGetParamsTimeDeltaHour SpectrumAnalyticsEventBytimeGetParamsTimeDelta = "hour" - SpectrumAnalyticsEventBytimeGetParamsTimeDeltaDekaminute SpectrumAnalyticsEventBytimeGetParamsTimeDelta = "dekaminute" - SpectrumAnalyticsEventBytimeGetParamsTimeDeltaMinute SpectrumAnalyticsEventBytimeGetParamsTimeDelta = "minute" -) - -type SpectrumAnalyticsEventBytimeGetResponseEnvelope struct { - Errors []SpectrumAnalyticsEventBytimeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SpectrumAnalyticsEventBytimeGetResponseEnvelopeMessages `json:"messages,required"` - Result SpectrumAnalyticsEventBytimeGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success SpectrumAnalyticsEventBytimeGetResponseEnvelopeSuccess `json:"success,required"` - JSON spectrumAnalyticsEventBytimeGetResponseEnvelopeJSON `json:"-"` -} - -// spectrumAnalyticsEventBytimeGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [SpectrumAnalyticsEventBytimeGetResponseEnvelope] -type spectrumAnalyticsEventBytimeGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAnalyticsEventBytimeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAnalyticsEventBytimeGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SpectrumAnalyticsEventBytimeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON spectrumAnalyticsEventBytimeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// spectrumAnalyticsEventBytimeGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [SpectrumAnalyticsEventBytimeGetResponseEnvelopeErrors] -type spectrumAnalyticsEventBytimeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAnalyticsEventBytimeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAnalyticsEventBytimeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SpectrumAnalyticsEventBytimeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON spectrumAnalyticsEventBytimeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// spectrumAnalyticsEventBytimeGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [SpectrumAnalyticsEventBytimeGetResponseEnvelopeMessages] -type spectrumAnalyticsEventBytimeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAnalyticsEventBytimeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAnalyticsEventBytimeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SpectrumAnalyticsEventBytimeGetResponseEnvelopeSuccess bool - -const ( - SpectrumAnalyticsEventBytimeGetResponseEnvelopeSuccessTrue SpectrumAnalyticsEventBytimeGetResponseEnvelopeSuccess = true -) diff --git a/spectrumanalyticseventbytime_test.go b/spectrumanalyticseventbytime_test.go deleted file mode 100644 index c876748d3fd..00000000000 --- a/spectrumanalyticseventbytime_test.go +++ /dev/null @@ -1,51 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSpectrumAnalyticsEventBytimeGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Spectrum.Analytics.Events.Bytimes.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.SpectrumAnalyticsEventBytimeGetParams{ - Dimensions: cloudflare.F([]cloudflare.SpectrumAnalyticsEventBytimeGetParamsDimension{cloudflare.SpectrumAnalyticsEventBytimeGetParamsDimensionEvent, cloudflare.SpectrumAnalyticsEventBytimeGetParamsDimensionAppID}), - Filters: cloudflare.F("event==disconnect%20AND%20coloName!=SFO"), - Metrics: cloudflare.F([]cloudflare.SpectrumAnalyticsEventBytimeGetParamsMetric{cloudflare.SpectrumAnalyticsEventBytimeGetParamsMetricCount, cloudflare.SpectrumAnalyticsEventBytimeGetParamsMetricBytesIngress}), - Since: cloudflare.F(time.Now()), - Sort: cloudflare.F([]interface{}{"+count", "-bytesIngress"}), - TimeDelta: cloudflare.F(cloudflare.SpectrumAnalyticsEventBytimeGetParamsTimeDeltaMinute), - Until: cloudflare.F(time.Now()), - }, - ) - 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/spectrumanalyticseventsummary.go b/spectrumanalyticseventsummary.go deleted file mode 100644 index bdc0fe5f0c3..00000000000 --- a/spectrumanalyticseventsummary.go +++ /dev/null @@ -1,229 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// SpectrumAnalyticsEventSummaryService 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 -// [NewSpectrumAnalyticsEventSummaryService] method instead. -type SpectrumAnalyticsEventSummaryService struct { - Options []option.RequestOption -} - -// NewSpectrumAnalyticsEventSummaryService 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 NewSpectrumAnalyticsEventSummaryService(opts ...option.RequestOption) (r *SpectrumAnalyticsEventSummaryService) { - r = &SpectrumAnalyticsEventSummaryService{} - r.Options = opts - return -} - -// Retrieves a list of summarised aggregate metrics over a given time period. -func (r *SpectrumAnalyticsEventSummaryService) Get(ctx context.Context, zone string, query SpectrumAnalyticsEventSummaryGetParams, opts ...option.RequestOption) (res *SpectrumAnalyticsEventSummaryGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env SpectrumAnalyticsEventSummaryGetResponseEnvelope - path := fmt.Sprintf("zones/%s/spectrum/analytics/events/summary", zone) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [SpectrumAnalyticsEventSummaryGetResponseUnknown] or -// [shared.UnionString]. -type SpectrumAnalyticsEventSummaryGetResponse interface { - ImplementsSpectrumAnalyticsEventSummaryGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SpectrumAnalyticsEventSummaryGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type SpectrumAnalyticsEventSummaryGetParams struct { - // Can be used to break down the data by given attributes. Options are: - // - // | Dimension | Name | Example | - // | --------- | ----------------------------- | ---------------------------------------------------------- | - // | event | Connection Event | connect, progress, disconnect, originError, clientFiltered | - // | appID | Application ID | 40d67c87c6cd4b889a4fd57805225e85 | - // | coloName | Colo Name | SFO | - // | ipVersion | IP version used by the client | 4, 6. | - Dimensions param.Field[[]SpectrumAnalyticsEventSummaryGetParamsDimension] `query:"dimensions"` - // Used to filter rows by one or more dimensions. Filters can be combined using OR - // and AND boolean logic. AND takes precedence over OR in all the expressions. The - // OR operator is defined using a comma (,) or OR keyword surrounded by whitespace. - // The AND operator is defined using a semicolon (;) or AND keyword surrounded by - // whitespace. Note that the semicolon is a reserved character in URLs (rfc1738) - // and needs to be percent-encoded as %3B. Comparison options are: - // - // | Operator | Name | URL Encoded | - // | -------- | ------------------------ | ----------- | - // | == | Equals | %3D%3D | - // | != | Does not equals | !%3D | - // | > | Greater Than | %3E | - // | < | Less Than | %3C | - // | >= | Greater than or equal to | %3E%3D | - // | <= | Less than or equal to | %3C%3D . | - Filters param.Field[string] `query:"filters"` - // One or more metrics to compute. Options are: - // - // | Metric | Name | Example | Unit | - // | -------------- | ----------------------------------- | ------- | --------------------- | - // | count | Count of total events | 1000 | Count | - // | bytesIngress | Sum of ingress bytes | 1000 | Sum | - // | bytesEgress | Sum of egress bytes | 1000 | Sum | - // | durationAvg | Average connection duration | 1.0 | Time in milliseconds | - // | durationMedian | Median connection duration | 1.0 | Time in milliseconds | - // | duration90th | 90th percentile connection duration | 1.0 | Time in milliseconds | - // | duration99th | 99th percentile connection duration | 1.0 | Time in milliseconds. | - Metrics param.Field[[]SpectrumAnalyticsEventSummaryGetParamsMetric] `query:"metrics"` - // Start of time interval to query, defaults to `until` - 6 hours. Timestamp must - // be in RFC3339 format and uses UTC unless otherwise specified. - Since param.Field[time.Time] `query:"since" format:"date-time"` - // The sort order for the result set; sort fields must be included in `metrics` or - // `dimensions`. - Sort param.Field[[]interface{}] `query:"sort"` - // End of time interval to query, defaults to current time. Timestamp must be in - // RFC3339 format and uses UTC unless otherwise specified. - Until param.Field[time.Time] `query:"until" format:"date-time"` -} - -// URLQuery serializes [SpectrumAnalyticsEventSummaryGetParams]'s query parameters -// as `url.Values`. -func (r SpectrumAnalyticsEventSummaryGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type SpectrumAnalyticsEventSummaryGetParamsDimension string - -const ( - SpectrumAnalyticsEventSummaryGetParamsDimensionEvent SpectrumAnalyticsEventSummaryGetParamsDimension = "event" - SpectrumAnalyticsEventSummaryGetParamsDimensionAppID SpectrumAnalyticsEventSummaryGetParamsDimension = "appID" - SpectrumAnalyticsEventSummaryGetParamsDimensionColoName SpectrumAnalyticsEventSummaryGetParamsDimension = "coloName" - SpectrumAnalyticsEventSummaryGetParamsDimensionIPVersion SpectrumAnalyticsEventSummaryGetParamsDimension = "ipVersion" -) - -type SpectrumAnalyticsEventSummaryGetParamsMetric string - -const ( - SpectrumAnalyticsEventSummaryGetParamsMetricCount SpectrumAnalyticsEventSummaryGetParamsMetric = "count" - SpectrumAnalyticsEventSummaryGetParamsMetricBytesIngress SpectrumAnalyticsEventSummaryGetParamsMetric = "bytesIngress" - SpectrumAnalyticsEventSummaryGetParamsMetricBytesEgress SpectrumAnalyticsEventSummaryGetParamsMetric = "bytesEgress" - SpectrumAnalyticsEventSummaryGetParamsMetricDurationAvg SpectrumAnalyticsEventSummaryGetParamsMetric = "durationAvg" - SpectrumAnalyticsEventSummaryGetParamsMetricDurationMedian SpectrumAnalyticsEventSummaryGetParamsMetric = "durationMedian" - SpectrumAnalyticsEventSummaryGetParamsMetricDuration90th SpectrumAnalyticsEventSummaryGetParamsMetric = "duration90th" - SpectrumAnalyticsEventSummaryGetParamsMetricDuration99th SpectrumAnalyticsEventSummaryGetParamsMetric = "duration99th" -) - -type SpectrumAnalyticsEventSummaryGetResponseEnvelope struct { - Errors []SpectrumAnalyticsEventSummaryGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SpectrumAnalyticsEventSummaryGetResponseEnvelopeMessages `json:"messages,required"` - Result SpectrumAnalyticsEventSummaryGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success SpectrumAnalyticsEventSummaryGetResponseEnvelopeSuccess `json:"success,required"` - JSON spectrumAnalyticsEventSummaryGetResponseEnvelopeJSON `json:"-"` -} - -// spectrumAnalyticsEventSummaryGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [SpectrumAnalyticsEventSummaryGetResponseEnvelope] -type spectrumAnalyticsEventSummaryGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAnalyticsEventSummaryGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAnalyticsEventSummaryGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SpectrumAnalyticsEventSummaryGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON spectrumAnalyticsEventSummaryGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// spectrumAnalyticsEventSummaryGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [SpectrumAnalyticsEventSummaryGetResponseEnvelopeErrors] -type spectrumAnalyticsEventSummaryGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAnalyticsEventSummaryGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAnalyticsEventSummaryGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SpectrumAnalyticsEventSummaryGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON spectrumAnalyticsEventSummaryGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// spectrumAnalyticsEventSummaryGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [SpectrumAnalyticsEventSummaryGetResponseEnvelopeMessages] -type spectrumAnalyticsEventSummaryGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAnalyticsEventSummaryGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAnalyticsEventSummaryGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SpectrumAnalyticsEventSummaryGetResponseEnvelopeSuccess bool - -const ( - SpectrumAnalyticsEventSummaryGetResponseEnvelopeSuccessTrue SpectrumAnalyticsEventSummaryGetResponseEnvelopeSuccess = true -) diff --git a/spectrumanalyticseventsummary_test.go b/spectrumanalyticseventsummary_test.go deleted file mode 100644 index f414a8a550e..00000000000 --- a/spectrumanalyticseventsummary_test.go +++ /dev/null @@ -1,50 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSpectrumAnalyticsEventSummaryGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.Spectrum.Analytics.Events.Summaries.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.SpectrumAnalyticsEventSummaryGetParams{ - Dimensions: cloudflare.F([]cloudflare.SpectrumAnalyticsEventSummaryGetParamsDimension{cloudflare.SpectrumAnalyticsEventSummaryGetParamsDimensionEvent, cloudflare.SpectrumAnalyticsEventSummaryGetParamsDimensionAppID}), - Filters: cloudflare.F("event==disconnect%20AND%20coloName!=SFO"), - Metrics: cloudflare.F([]cloudflare.SpectrumAnalyticsEventSummaryGetParamsMetric{cloudflare.SpectrumAnalyticsEventSummaryGetParamsMetricCount, cloudflare.SpectrumAnalyticsEventSummaryGetParamsMetricBytesIngress}), - Since: cloudflare.F(time.Now()), - Sort: cloudflare.F([]interface{}{"+count", "-bytesIngress"}), - Until: cloudflare.F(time.Now()), - }, - ) - 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/spectrumapp.go b/spectrumapp.go deleted file mode 100644 index 89d5440642d..00000000000 --- a/spectrumapp.go +++ /dev/null @@ -1,1569 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// SpectrumAppService 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 [NewSpectrumAppService] method -// instead. -type SpectrumAppService struct { - Options []option.RequestOption -} - -// NewSpectrumAppService 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 NewSpectrumAppService(opts ...option.RequestOption) (r *SpectrumAppService) { - r = &SpectrumAppService{} - r.Options = opts - return -} - -// Creates a new Spectrum application from a configuration using a name for the -// origin. -func (r *SpectrumAppService) New(ctx context.Context, zone string, body SpectrumAppNewParams, opts ...option.RequestOption) (res *SpectrumAppNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env SpectrumAppNewResponseEnvelope - path := fmt.Sprintf("zones/%s/spectrum/apps", zone) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a previously existing application's configuration that uses a name for -// the origin. -func (r *SpectrumAppService) Update(ctx context.Context, zone string, appID string, body SpectrumAppUpdateParams, opts ...option.RequestOption) (res *SpectrumAppUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env SpectrumAppUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/spectrum/apps/%s", zone, appID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Retrieves a list of currently existing Spectrum applications inside a zone. -func (r *SpectrumAppService) List(ctx context.Context, zone string, query SpectrumAppListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[SpectrumAppListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("zones/%s/spectrum/apps", zone) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Retrieves a list of currently existing Spectrum applications inside a zone. -func (r *SpectrumAppService) ListAutoPaging(ctx context.Context, zone string, query SpectrumAppListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[SpectrumAppListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, zone, query, opts...)) -} - -// Deletes a previously existing application. -func (r *SpectrumAppService) Delete(ctx context.Context, zone string, appID string, opts ...option.RequestOption) (res *SpectrumAppDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env SpectrumAppDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/spectrum/apps/%s", zone, appID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets the application configuration of a specific application inside a zone. -func (r *SpectrumAppService) Get(ctx context.Context, zone string, appID string, opts ...option.RequestOption) (res *SpectrumAppGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env SpectrumAppGetResponseEnvelope - path := fmt.Sprintf("zones/%s/spectrum/apps/%s", zone, appID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SpectrumAppNewResponse struct { - // Application identifier. - ID string `json:"id"` - // Enables Argo Smart Routing for this application. Notes: Only available for TCP - // applications with traffic_type set to "direct". - ArgoSmartRouting bool `json:"argo_smart_routing"` - // When the Application was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // The name and type of DNS record for the Spectrum application. - DNS SpectrumAppNewResponseDNS `json:"dns"` - // The anycast edge IP configuration for the hostname of this application. - EdgeIPs SpectrumAppNewResponseEdgeIPs `json:"edge_ips"` - // Enables IP Access Rules for this application. Notes: Only available for TCP - // applications. - IPFirewall bool `json:"ip_firewall"` - // When the Application was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The name and type of DNS record for the Spectrum application. - OriginDNS SpectrumAppNewResponseOriginDNS `json:"origin_dns"` - // The destination port at the origin. Only specified in conjunction with - // origin_dns. May use an integer to specify a single origin port, for example - // `1000`, or a string to specify a range of origin ports, for example - // `"1000-2000"`. Notes: If specifying a port range, the number of ports in the - // range must match the number of ports specified in the "protocol" field. - OriginPort SpectrumAppNewResponseOriginPort `json:"origin_port"` - // The port configuration at Cloudflare’s edge. May specify a single port, for - // example `"tcp/1000"`, or a range of ports, for example `"tcp/1000-2000"`. - Protocol string `json:"protocol"` - // Enables Proxy Protocol to the origin. Refer to - // [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) - // for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple - // Proxy Protocol. - ProxyProtocol SpectrumAppNewResponseProxyProtocol `json:"proxy_protocol"` - // The type of TLS termination associated with the application. - TLS SpectrumAppNewResponseTLS `json:"tls"` - // Determines how data travels from the edge to your origin. When set to "direct", - // Spectrum will send traffic directly to your origin, and the application's type - // is derived from the `protocol`. When set to "http" or "https", Spectrum will - // apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and - // the application type matches this property exactly. - TrafficType SpectrumAppNewResponseTrafficType `json:"traffic_type"` - JSON spectrumAppNewResponseJSON `json:"-"` -} - -// spectrumAppNewResponseJSON contains the JSON metadata for the struct -// [SpectrumAppNewResponse] -type spectrumAppNewResponseJSON struct { - ID apijson.Field - ArgoSmartRouting apijson.Field - CreatedOn apijson.Field - DNS apijson.Field - EdgeIPs apijson.Field - IPFirewall apijson.Field - ModifiedOn apijson.Field - OriginDNS apijson.Field - OriginPort apijson.Field - Protocol apijson.Field - ProxyProtocol apijson.Field - TLS apijson.Field - TrafficType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppNewResponseJSON) RawJSON() string { - return r.raw -} - -// The name and type of DNS record for the Spectrum application. -type SpectrumAppNewResponseDNS struct { - // The name of the DNS record associated with the application. - Name string `json:"name" format:"hostname"` - // The type of DNS record associated with the application. - Type SpectrumAppNewResponseDNSType `json:"type"` - JSON spectrumAppNewResponseDNSJSON `json:"-"` -} - -// spectrumAppNewResponseDNSJSON contains the JSON metadata for the struct -// [SpectrumAppNewResponseDNS] -type spectrumAppNewResponseDNSJSON struct { - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppNewResponseDNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppNewResponseDNSJSON) RawJSON() string { - return r.raw -} - -// The type of DNS record associated with the application. -type SpectrumAppNewResponseDNSType string - -const ( - SpectrumAppNewResponseDNSTypeCNAME SpectrumAppNewResponseDNSType = "CNAME" - SpectrumAppNewResponseDNSTypeAddress SpectrumAppNewResponseDNSType = "ADDRESS" -) - -// The anycast edge IP configuration for the hostname of this application. -// -// Union satisfied by -// [SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable] or -// [SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable]. -type SpectrumAppNewResponseEdgeIPs interface { - implementsSpectrumAppNewResponseEdgeIPs() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SpectrumAppNewResponseEdgeIPs)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable{}), - }, - ) -} - -type SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable struct { - // The IP versions supported for inbound connections on Spectrum anycast IPs. - Connectivity SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity `json:"connectivity"` - // The type of edge IP configuration specified. Dynamically allocated edge IPs use - // Spectrum anycast IPs in accordance with the connectivity you specify. Only valid - // with CNAME DNS names. - Type SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableType `json:"type"` - JSON spectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableJSON `json:"-"` -} - -// spectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableJSON contains the -// JSON metadata for the struct -// [SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable] -type spectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableJSON struct { - Connectivity apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableJSON) RawJSON() string { - return r.raw -} - -func (r SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable) implementsSpectrumAppNewResponseEdgeIPs() { -} - -// The IP versions supported for inbound connections on Spectrum anycast IPs. -type SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity string - -const ( - SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityAll SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "all" - SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityIPV4 SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "ipv4" - SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityIPV6 SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "ipv6" -) - -// The type of edge IP configuration specified. Dynamically allocated edge IPs use -// Spectrum anycast IPs in accordance with the connectivity you specify. Only valid -// with CNAME DNS names. -type SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableType string - -const ( - SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableTypeDynamic SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableType = "dynamic" -) - -type SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable struct { - // The array of customer owned IPs we broadcast via anycast for this hostname and - // application. - IPs []string `json:"ips"` - // The type of edge IP configuration specified. Statically allocated edge IPs use - // customer IPs in accordance with the ips array you specify. Only valid with - // ADDRESS DNS names. - Type SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType `json:"type"` - JSON spectrumAppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableJSON `json:"-"` -} - -// spectrumAppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableJSON contains -// the JSON metadata for the struct -// [SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable] -type spectrumAppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableJSON struct { - IPs apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableJSON) RawJSON() string { - return r.raw -} - -func (r SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable) implementsSpectrumAppNewResponseEdgeIPs() { -} - -// The type of edge IP configuration specified. Statically allocated edge IPs use -// customer IPs in accordance with the ips array you specify. Only valid with -// ADDRESS DNS names. -type SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType string - -const ( - SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableTypeStatic SpectrumAppNewResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType = "static" -) - -// The name and type of DNS record for the Spectrum application. -type SpectrumAppNewResponseOriginDNS struct { - // The name of the DNS record associated with the origin. - Name string `json:"name" format:"hostname"` - // The TTL of our resolution of your DNS record in seconds. - TTL int64 `json:"ttl"` - // The type of DNS record associated with the origin. "" is used to specify a - // combination of A/AAAA records. - Type SpectrumAppNewResponseOriginDNSType `json:"type"` - JSON spectrumAppNewResponseOriginDNSJSON `json:"-"` -} - -// spectrumAppNewResponseOriginDNSJSON contains the JSON metadata for the struct -// [SpectrumAppNewResponseOriginDNS] -type spectrumAppNewResponseOriginDNSJSON struct { - Name apijson.Field - TTL apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppNewResponseOriginDNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppNewResponseOriginDNSJSON) RawJSON() string { - return r.raw -} - -// The type of DNS record associated with the origin. "" is used to specify a -// combination of A/AAAA records. -type SpectrumAppNewResponseOriginDNSType string - -const ( - SpectrumAppNewResponseOriginDNSTypeEmpty SpectrumAppNewResponseOriginDNSType = "" - SpectrumAppNewResponseOriginDNSTypeA SpectrumAppNewResponseOriginDNSType = "A" - SpectrumAppNewResponseOriginDNSTypeAAAA SpectrumAppNewResponseOriginDNSType = "AAAA" - SpectrumAppNewResponseOriginDNSTypeSRV SpectrumAppNewResponseOriginDNSType = "SRV" -) - -// The destination port at the origin. Only specified in conjunction with -// origin_dns. May use an integer to specify a single origin port, for example -// `1000`, or a string to specify a range of origin ports, for example -// `"1000-2000"`. Notes: If specifying a port range, the number of ports in the -// range must match the number of ports specified in the "protocol" field. -// -// Union satisfied by [shared.UnionInt] or [shared.UnionString]. -type SpectrumAppNewResponseOriginPort interface { - ImplementsSpectrumAppNewResponseOriginPort() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SpectrumAppNewResponseOriginPort)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionInt(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Enables Proxy Protocol to the origin. Refer to -// [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) -// for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple -// Proxy Protocol. -type SpectrumAppNewResponseProxyProtocol string - -const ( - SpectrumAppNewResponseProxyProtocolOff SpectrumAppNewResponseProxyProtocol = "off" - SpectrumAppNewResponseProxyProtocolV1 SpectrumAppNewResponseProxyProtocol = "v1" - SpectrumAppNewResponseProxyProtocolV2 SpectrumAppNewResponseProxyProtocol = "v2" - SpectrumAppNewResponseProxyProtocolSimple SpectrumAppNewResponseProxyProtocol = "simple" -) - -// The type of TLS termination associated with the application. -type SpectrumAppNewResponseTLS string - -const ( - SpectrumAppNewResponseTLSOff SpectrumAppNewResponseTLS = "off" - SpectrumAppNewResponseTLSFlexible SpectrumAppNewResponseTLS = "flexible" - SpectrumAppNewResponseTLSFull SpectrumAppNewResponseTLS = "full" - SpectrumAppNewResponseTLSStrict SpectrumAppNewResponseTLS = "strict" -) - -// Determines how data travels from the edge to your origin. When set to "direct", -// Spectrum will send traffic directly to your origin, and the application's type -// is derived from the `protocol`. When set to "http" or "https", Spectrum will -// apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and -// the application type matches this property exactly. -type SpectrumAppNewResponseTrafficType string - -const ( - SpectrumAppNewResponseTrafficTypeDirect SpectrumAppNewResponseTrafficType = "direct" - SpectrumAppNewResponseTrafficTypeHTTP SpectrumAppNewResponseTrafficType = "http" - SpectrumAppNewResponseTrafficTypeHTTPS SpectrumAppNewResponseTrafficType = "https" -) - -type SpectrumAppUpdateResponse struct { - // Application identifier. - ID string `json:"id"` - // Enables Argo Smart Routing for this application. Notes: Only available for TCP - // applications with traffic_type set to "direct". - ArgoSmartRouting bool `json:"argo_smart_routing"` - // When the Application was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // The name and type of DNS record for the Spectrum application. - DNS SpectrumAppUpdateResponseDNS `json:"dns"` - // The anycast edge IP configuration for the hostname of this application. - EdgeIPs SpectrumAppUpdateResponseEdgeIPs `json:"edge_ips"` - // Enables IP Access Rules for this application. Notes: Only available for TCP - // applications. - IPFirewall bool `json:"ip_firewall"` - // When the Application was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The name and type of DNS record for the Spectrum application. - OriginDNS SpectrumAppUpdateResponseOriginDNS `json:"origin_dns"` - // The destination port at the origin. Only specified in conjunction with - // origin_dns. May use an integer to specify a single origin port, for example - // `1000`, or a string to specify a range of origin ports, for example - // `"1000-2000"`. Notes: If specifying a port range, the number of ports in the - // range must match the number of ports specified in the "protocol" field. - OriginPort SpectrumAppUpdateResponseOriginPort `json:"origin_port"` - // The port configuration at Cloudflare’s edge. May specify a single port, for - // example `"tcp/1000"`, or a range of ports, for example `"tcp/1000-2000"`. - Protocol string `json:"protocol"` - // Enables Proxy Protocol to the origin. Refer to - // [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) - // for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple - // Proxy Protocol. - ProxyProtocol SpectrumAppUpdateResponseProxyProtocol `json:"proxy_protocol"` - // The type of TLS termination associated with the application. - TLS SpectrumAppUpdateResponseTLS `json:"tls"` - // Determines how data travels from the edge to your origin. When set to "direct", - // Spectrum will send traffic directly to your origin, and the application's type - // is derived from the `protocol`. When set to "http" or "https", Spectrum will - // apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and - // the application type matches this property exactly. - TrafficType SpectrumAppUpdateResponseTrafficType `json:"traffic_type"` - JSON spectrumAppUpdateResponseJSON `json:"-"` -} - -// spectrumAppUpdateResponseJSON contains the JSON metadata for the struct -// [SpectrumAppUpdateResponse] -type spectrumAppUpdateResponseJSON struct { - ID apijson.Field - ArgoSmartRouting apijson.Field - CreatedOn apijson.Field - DNS apijson.Field - EdgeIPs apijson.Field - IPFirewall apijson.Field - ModifiedOn apijson.Field - OriginDNS apijson.Field - OriginPort apijson.Field - Protocol apijson.Field - ProxyProtocol apijson.Field - TLS apijson.Field - TrafficType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// The name and type of DNS record for the Spectrum application. -type SpectrumAppUpdateResponseDNS struct { - // The name of the DNS record associated with the application. - Name string `json:"name" format:"hostname"` - // The type of DNS record associated with the application. - Type SpectrumAppUpdateResponseDNSType `json:"type"` - JSON spectrumAppUpdateResponseDNSJSON `json:"-"` -} - -// spectrumAppUpdateResponseDNSJSON contains the JSON metadata for the struct -// [SpectrumAppUpdateResponseDNS] -type spectrumAppUpdateResponseDNSJSON struct { - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppUpdateResponseDNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppUpdateResponseDNSJSON) RawJSON() string { - return r.raw -} - -// The type of DNS record associated with the application. -type SpectrumAppUpdateResponseDNSType string - -const ( - SpectrumAppUpdateResponseDNSTypeCNAME SpectrumAppUpdateResponseDNSType = "CNAME" - SpectrumAppUpdateResponseDNSTypeAddress SpectrumAppUpdateResponseDNSType = "ADDRESS" -) - -// The anycast edge IP configuration for the hostname of this application. -// -// Union satisfied by -// [SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable] or -// [SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable]. -type SpectrumAppUpdateResponseEdgeIPs interface { - implementsSpectrumAppUpdateResponseEdgeIPs() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SpectrumAppUpdateResponseEdgeIPs)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable{}), - }, - ) -} - -type SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable struct { - // The IP versions supported for inbound connections on Spectrum anycast IPs. - Connectivity SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity `json:"connectivity"` - // The type of edge IP configuration specified. Dynamically allocated edge IPs use - // Spectrum anycast IPs in accordance with the connectivity you specify. Only valid - // with CNAME DNS names. - Type SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableType `json:"type"` - JSON spectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableJSON `json:"-"` -} - -// spectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableJSON contains -// the JSON metadata for the struct -// [SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable] -type spectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableJSON struct { - Connectivity apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableJSON) RawJSON() string { - return r.raw -} - -func (r SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariable) implementsSpectrumAppUpdateResponseEdgeIPs() { -} - -// The IP versions supported for inbound connections on Spectrum anycast IPs. -type SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity string - -const ( - SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityAll SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "all" - SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityIPV4 SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "ipv4" - SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityIPV6 SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "ipv6" -) - -// The type of edge IP configuration specified. Dynamically allocated edge IPs use -// Spectrum anycast IPs in accordance with the connectivity you specify. Only valid -// with CNAME DNS names. -type SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableType string - -const ( - SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableTypeDynamic SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPEyeballIPsVariableType = "dynamic" -) - -type SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable struct { - // The array of customer owned IPs we broadcast via anycast for this hostname and - // application. - IPs []string `json:"ips"` - // The type of edge IP configuration specified. Statically allocated edge IPs use - // customer IPs in accordance with the ips array you specify. Only valid with - // ADDRESS DNS names. - Type SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType `json:"type"` - JSON spectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableJSON `json:"-"` -} - -// spectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableJSON -// contains the JSON metadata for the struct -// [SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable] -type spectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableJSON struct { - IPs apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableJSON) RawJSON() string { - return r.raw -} - -func (r SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable) implementsSpectrumAppUpdateResponseEdgeIPs() { -} - -// The type of edge IP configuration specified. Statically allocated edge IPs use -// customer IPs in accordance with the ips array you specify. Only valid with -// ADDRESS DNS names. -type SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType string - -const ( - SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableTypeStatic SpectrumAppUpdateResponseEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType = "static" -) - -// The name and type of DNS record for the Spectrum application. -type SpectrumAppUpdateResponseOriginDNS struct { - // The name of the DNS record associated with the origin. - Name string `json:"name" format:"hostname"` - // The TTL of our resolution of your DNS record in seconds. - TTL int64 `json:"ttl"` - // The type of DNS record associated with the origin. "" is used to specify a - // combination of A/AAAA records. - Type SpectrumAppUpdateResponseOriginDNSType `json:"type"` - JSON spectrumAppUpdateResponseOriginDNSJSON `json:"-"` -} - -// spectrumAppUpdateResponseOriginDNSJSON contains the JSON metadata for the struct -// [SpectrumAppUpdateResponseOriginDNS] -type spectrumAppUpdateResponseOriginDNSJSON struct { - Name apijson.Field - TTL apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppUpdateResponseOriginDNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppUpdateResponseOriginDNSJSON) RawJSON() string { - return r.raw -} - -// The type of DNS record associated with the origin. "" is used to specify a -// combination of A/AAAA records. -type SpectrumAppUpdateResponseOriginDNSType string - -const ( - SpectrumAppUpdateResponseOriginDNSTypeEmpty SpectrumAppUpdateResponseOriginDNSType = "" - SpectrumAppUpdateResponseOriginDNSTypeA SpectrumAppUpdateResponseOriginDNSType = "A" - SpectrumAppUpdateResponseOriginDNSTypeAAAA SpectrumAppUpdateResponseOriginDNSType = "AAAA" - SpectrumAppUpdateResponseOriginDNSTypeSRV SpectrumAppUpdateResponseOriginDNSType = "SRV" -) - -// The destination port at the origin. Only specified in conjunction with -// origin_dns. May use an integer to specify a single origin port, for example -// `1000`, or a string to specify a range of origin ports, for example -// `"1000-2000"`. Notes: If specifying a port range, the number of ports in the -// range must match the number of ports specified in the "protocol" field. -// -// Union satisfied by [shared.UnionInt] or [shared.UnionString]. -type SpectrumAppUpdateResponseOriginPort interface { - ImplementsSpectrumAppUpdateResponseOriginPort() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SpectrumAppUpdateResponseOriginPort)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.Number, - Type: reflect.TypeOf(shared.UnionInt(0)), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Enables Proxy Protocol to the origin. Refer to -// [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) -// for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple -// Proxy Protocol. -type SpectrumAppUpdateResponseProxyProtocol string - -const ( - SpectrumAppUpdateResponseProxyProtocolOff SpectrumAppUpdateResponseProxyProtocol = "off" - SpectrumAppUpdateResponseProxyProtocolV1 SpectrumAppUpdateResponseProxyProtocol = "v1" - SpectrumAppUpdateResponseProxyProtocolV2 SpectrumAppUpdateResponseProxyProtocol = "v2" - SpectrumAppUpdateResponseProxyProtocolSimple SpectrumAppUpdateResponseProxyProtocol = "simple" -) - -// The type of TLS termination associated with the application. -type SpectrumAppUpdateResponseTLS string - -const ( - SpectrumAppUpdateResponseTLSOff SpectrumAppUpdateResponseTLS = "off" - SpectrumAppUpdateResponseTLSFlexible SpectrumAppUpdateResponseTLS = "flexible" - SpectrumAppUpdateResponseTLSFull SpectrumAppUpdateResponseTLS = "full" - SpectrumAppUpdateResponseTLSStrict SpectrumAppUpdateResponseTLS = "strict" -) - -// Determines how data travels from the edge to your origin. When set to "direct", -// Spectrum will send traffic directly to your origin, and the application's type -// is derived from the `protocol`. When set to "http" or "https", Spectrum will -// apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and -// the application type matches this property exactly. -type SpectrumAppUpdateResponseTrafficType string - -const ( - SpectrumAppUpdateResponseTrafficTypeDirect SpectrumAppUpdateResponseTrafficType = "direct" - SpectrumAppUpdateResponseTrafficTypeHTTP SpectrumAppUpdateResponseTrafficType = "http" - SpectrumAppUpdateResponseTrafficTypeHTTPS SpectrumAppUpdateResponseTrafficType = "https" -) - -type SpectrumAppListResponse = interface{} - -type SpectrumAppDeleteResponse struct { - // Application identifier. - ID string `json:"id"` - JSON spectrumAppDeleteResponseJSON `json:"-"` -} - -// spectrumAppDeleteResponseJSON contains the JSON metadata for the struct -// [SpectrumAppDeleteResponse] -type spectrumAppDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [SpectrumAppGetResponseUnknown] or [shared.UnionString]. -type SpectrumAppGetResponse interface { - ImplementsSpectrumAppGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SpectrumAppGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type SpectrumAppNewParams struct { - // The name and type of DNS record for the Spectrum application. - DNS param.Field[SpectrumAppNewParamsDNS] `json:"dns,required"` - // The name and type of DNS record for the Spectrum application. - OriginDNS param.Field[SpectrumAppNewParamsOriginDNS] `json:"origin_dns,required"` - // The destination port at the origin. Only specified in conjunction with - // origin_dns. May use an integer to specify a single origin port, for example - // `1000`, or a string to specify a range of origin ports, for example - // `"1000-2000"`. Notes: If specifying a port range, the number of ports in the - // range must match the number of ports specified in the "protocol" field. - OriginPort param.Field[SpectrumAppNewParamsOriginPort] `json:"origin_port,required"` - // The port configuration at Cloudflare’s edge. May specify a single port, for - // example `"tcp/1000"`, or a range of ports, for example `"tcp/1000-2000"`. - Protocol param.Field[string] `json:"protocol,required"` - // Enables Argo Smart Routing for this application. Notes: Only available for TCP - // applications with traffic_type set to "direct". - ArgoSmartRouting param.Field[bool] `json:"argo_smart_routing"` - // The anycast edge IP configuration for the hostname of this application. - EdgeIPs param.Field[SpectrumAppNewParamsEdgeIPs] `json:"edge_ips"` - // Enables IP Access Rules for this application. Notes: Only available for TCP - // applications. - IPFirewall param.Field[bool] `json:"ip_firewall"` - // Enables Proxy Protocol to the origin. Refer to - // [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) - // for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple - // Proxy Protocol. - ProxyProtocol param.Field[SpectrumAppNewParamsProxyProtocol] `json:"proxy_protocol"` - // The type of TLS termination associated with the application. - TLS param.Field[SpectrumAppNewParamsTLS] `json:"tls"` - // Determines how data travels from the edge to your origin. When set to "direct", - // Spectrum will send traffic directly to your origin, and the application's type - // is derived from the `protocol`. When set to "http" or "https", Spectrum will - // apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and - // the application type matches this property exactly. - TrafficType param.Field[SpectrumAppNewParamsTrafficType] `json:"traffic_type"` -} - -func (r SpectrumAppNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The name and type of DNS record for the Spectrum application. -type SpectrumAppNewParamsDNS struct { - // The name of the DNS record associated with the application. - Name param.Field[string] `json:"name" format:"hostname"` - // The type of DNS record associated with the application. - Type param.Field[SpectrumAppNewParamsDNSType] `json:"type"` -} - -func (r SpectrumAppNewParamsDNS) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of DNS record associated with the application. -type SpectrumAppNewParamsDNSType string - -const ( - SpectrumAppNewParamsDNSTypeCNAME SpectrumAppNewParamsDNSType = "CNAME" - SpectrumAppNewParamsDNSTypeAddress SpectrumAppNewParamsDNSType = "ADDRESS" -) - -// The name and type of DNS record for the Spectrum application. -type SpectrumAppNewParamsOriginDNS struct { - // The name of the DNS record associated with the origin. - Name param.Field[string] `json:"name" format:"hostname"` - // The TTL of our resolution of your DNS record in seconds. - TTL param.Field[int64] `json:"ttl"` - // The type of DNS record associated with the origin. "" is used to specify a - // combination of A/AAAA records. - Type param.Field[SpectrumAppNewParamsOriginDNSType] `json:"type"` -} - -func (r SpectrumAppNewParamsOriginDNS) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of DNS record associated with the origin. "" is used to specify a -// combination of A/AAAA records. -type SpectrumAppNewParamsOriginDNSType string - -const ( - SpectrumAppNewParamsOriginDNSTypeEmpty SpectrumAppNewParamsOriginDNSType = "" - SpectrumAppNewParamsOriginDNSTypeA SpectrumAppNewParamsOriginDNSType = "A" - SpectrumAppNewParamsOriginDNSTypeAAAA SpectrumAppNewParamsOriginDNSType = "AAAA" - SpectrumAppNewParamsOriginDNSTypeSRV SpectrumAppNewParamsOriginDNSType = "SRV" -) - -// The destination port at the origin. Only specified in conjunction with -// origin_dns. May use an integer to specify a single origin port, for example -// `1000`, or a string to specify a range of origin ports, for example -// `"1000-2000"`. Notes: If specifying a port range, the number of ports in the -// range must match the number of ports specified in the "protocol" field. -// -// Satisfied by [shared.UnionInt], [shared.UnionString]. -type SpectrumAppNewParamsOriginPort interface { - ImplementsSpectrumAppNewParamsOriginPort() -} - -// The anycast edge IP configuration for the hostname of this application. -// -// Satisfied by [SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable], -// [SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable]. -type SpectrumAppNewParamsEdgeIPs interface { - implementsSpectrumAppNewParamsEdgeIPs() -} - -type SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable struct { - // The IP versions supported for inbound connections on Spectrum anycast IPs. - Connectivity param.Field[SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity] `json:"connectivity"` - // The type of edge IP configuration specified. Dynamically allocated edge IPs use - // Spectrum anycast IPs in accordance with the connectivity you specify. Only valid - // with CNAME DNS names. - Type param.Field[SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableType] `json:"type"` -} - -func (r SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable) implementsSpectrumAppNewParamsEdgeIPs() { -} - -// The IP versions supported for inbound connections on Spectrum anycast IPs. -type SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity string - -const ( - SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityAll SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "all" - SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityIPV4 SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "ipv4" - SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityIPV6 SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "ipv6" -) - -// The type of edge IP configuration specified. Dynamically allocated edge IPs use -// Spectrum anycast IPs in accordance with the connectivity you specify. Only valid -// with CNAME DNS names. -type SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableType string - -const ( - SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableTypeDynamic SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableType = "dynamic" -) - -type SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable struct { - // The array of customer owned IPs we broadcast via anycast for this hostname and - // application. - IPs param.Field[[]string] `json:"ips"` - // The type of edge IP configuration specified. Statically allocated edge IPs use - // customer IPs in accordance with the ips array you specify. Only valid with - // ADDRESS DNS names. - Type param.Field[SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType] `json:"type"` -} - -func (r SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable) implementsSpectrumAppNewParamsEdgeIPs() { -} - -// The type of edge IP configuration specified. Statically allocated edge IPs use -// customer IPs in accordance with the ips array you specify. Only valid with -// ADDRESS DNS names. -type SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType string - -const ( - SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableTypeStatic SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType = "static" -) - -// Enables Proxy Protocol to the origin. Refer to -// [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) -// for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple -// Proxy Protocol. -type SpectrumAppNewParamsProxyProtocol string - -const ( - SpectrumAppNewParamsProxyProtocolOff SpectrumAppNewParamsProxyProtocol = "off" - SpectrumAppNewParamsProxyProtocolV1 SpectrumAppNewParamsProxyProtocol = "v1" - SpectrumAppNewParamsProxyProtocolV2 SpectrumAppNewParamsProxyProtocol = "v2" - SpectrumAppNewParamsProxyProtocolSimple SpectrumAppNewParamsProxyProtocol = "simple" -) - -// The type of TLS termination associated with the application. -type SpectrumAppNewParamsTLS string - -const ( - SpectrumAppNewParamsTLSOff SpectrumAppNewParamsTLS = "off" - SpectrumAppNewParamsTLSFlexible SpectrumAppNewParamsTLS = "flexible" - SpectrumAppNewParamsTLSFull SpectrumAppNewParamsTLS = "full" - SpectrumAppNewParamsTLSStrict SpectrumAppNewParamsTLS = "strict" -) - -// Determines how data travels from the edge to your origin. When set to "direct", -// Spectrum will send traffic directly to your origin, and the application's type -// is derived from the `protocol`. When set to "http" or "https", Spectrum will -// apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and -// the application type matches this property exactly. -type SpectrumAppNewParamsTrafficType string - -const ( - SpectrumAppNewParamsTrafficTypeDirect SpectrumAppNewParamsTrafficType = "direct" - SpectrumAppNewParamsTrafficTypeHTTP SpectrumAppNewParamsTrafficType = "http" - SpectrumAppNewParamsTrafficTypeHTTPS SpectrumAppNewParamsTrafficType = "https" -) - -type SpectrumAppNewResponseEnvelope struct { - Errors []SpectrumAppNewResponseEnvelopeErrors `json:"errors,required"` - Messages []SpectrumAppNewResponseEnvelopeMessages `json:"messages,required"` - Result SpectrumAppNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success SpectrumAppNewResponseEnvelopeSuccess `json:"success,required"` - JSON spectrumAppNewResponseEnvelopeJSON `json:"-"` -} - -// spectrumAppNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [SpectrumAppNewResponseEnvelope] -type spectrumAppNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SpectrumAppNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON spectrumAppNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// spectrumAppNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SpectrumAppNewResponseEnvelopeErrors] -type spectrumAppNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SpectrumAppNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON spectrumAppNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// spectrumAppNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SpectrumAppNewResponseEnvelopeMessages] -type spectrumAppNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SpectrumAppNewResponseEnvelopeSuccess bool - -const ( - SpectrumAppNewResponseEnvelopeSuccessTrue SpectrumAppNewResponseEnvelopeSuccess = true -) - -type SpectrumAppUpdateParams struct { - // The name and type of DNS record for the Spectrum application. - DNS param.Field[SpectrumAppUpdateParamsDNS] `json:"dns,required"` - // The name and type of DNS record for the Spectrum application. - OriginDNS param.Field[SpectrumAppUpdateParamsOriginDNS] `json:"origin_dns,required"` - // The destination port at the origin. Only specified in conjunction with - // origin_dns. May use an integer to specify a single origin port, for example - // `1000`, or a string to specify a range of origin ports, for example - // `"1000-2000"`. Notes: If specifying a port range, the number of ports in the - // range must match the number of ports specified in the "protocol" field. - OriginPort param.Field[SpectrumAppUpdateParamsOriginPort] `json:"origin_port,required"` - // The port configuration at Cloudflare’s edge. May specify a single port, for - // example `"tcp/1000"`, or a range of ports, for example `"tcp/1000-2000"`. - Protocol param.Field[string] `json:"protocol,required"` - // Enables Argo Smart Routing for this application. Notes: Only available for TCP - // applications with traffic_type set to "direct". - ArgoSmartRouting param.Field[bool] `json:"argo_smart_routing"` - // The anycast edge IP configuration for the hostname of this application. - EdgeIPs param.Field[SpectrumAppUpdateParamsEdgeIPs] `json:"edge_ips"` - // Enables IP Access Rules for this application. Notes: Only available for TCP - // applications. - IPFirewall param.Field[bool] `json:"ip_firewall"` - // Enables Proxy Protocol to the origin. Refer to - // [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) - // for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple - // Proxy Protocol. - ProxyProtocol param.Field[SpectrumAppUpdateParamsProxyProtocol] `json:"proxy_protocol"` - // The type of TLS termination associated with the application. - TLS param.Field[SpectrumAppUpdateParamsTLS] `json:"tls"` - // Determines how data travels from the edge to your origin. When set to "direct", - // Spectrum will send traffic directly to your origin, and the application's type - // is derived from the `protocol`. When set to "http" or "https", Spectrum will - // apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and - // the application type matches this property exactly. - TrafficType param.Field[SpectrumAppUpdateParamsTrafficType] `json:"traffic_type"` -} - -func (r SpectrumAppUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The name and type of DNS record for the Spectrum application. -type SpectrumAppUpdateParamsDNS struct { - // The name of the DNS record associated with the application. - Name param.Field[string] `json:"name" format:"hostname"` - // The type of DNS record associated with the application. - Type param.Field[SpectrumAppUpdateParamsDNSType] `json:"type"` -} - -func (r SpectrumAppUpdateParamsDNS) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of DNS record associated with the application. -type SpectrumAppUpdateParamsDNSType string - -const ( - SpectrumAppUpdateParamsDNSTypeCNAME SpectrumAppUpdateParamsDNSType = "CNAME" - SpectrumAppUpdateParamsDNSTypeAddress SpectrumAppUpdateParamsDNSType = "ADDRESS" -) - -// The name and type of DNS record for the Spectrum application. -type SpectrumAppUpdateParamsOriginDNS struct { - // The name of the DNS record associated with the origin. - Name param.Field[string] `json:"name" format:"hostname"` - // The TTL of our resolution of your DNS record in seconds. - TTL param.Field[int64] `json:"ttl"` - // The type of DNS record associated with the origin. "" is used to specify a - // combination of A/AAAA records. - Type param.Field[SpectrumAppUpdateParamsOriginDNSType] `json:"type"` -} - -func (r SpectrumAppUpdateParamsOriginDNS) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of DNS record associated with the origin. "" is used to specify a -// combination of A/AAAA records. -type SpectrumAppUpdateParamsOriginDNSType string - -const ( - SpectrumAppUpdateParamsOriginDNSTypeEmpty SpectrumAppUpdateParamsOriginDNSType = "" - SpectrumAppUpdateParamsOriginDNSTypeA SpectrumAppUpdateParamsOriginDNSType = "A" - SpectrumAppUpdateParamsOriginDNSTypeAAAA SpectrumAppUpdateParamsOriginDNSType = "AAAA" - SpectrumAppUpdateParamsOriginDNSTypeSRV SpectrumAppUpdateParamsOriginDNSType = "SRV" -) - -// The destination port at the origin. Only specified in conjunction with -// origin_dns. May use an integer to specify a single origin port, for example -// `1000`, or a string to specify a range of origin ports, for example -// `"1000-2000"`. Notes: If specifying a port range, the number of ports in the -// range must match the number of ports specified in the "protocol" field. -// -// Satisfied by [shared.UnionInt], [shared.UnionString]. -type SpectrumAppUpdateParamsOriginPort interface { - ImplementsSpectrumAppUpdateParamsOriginPort() -} - -// The anycast edge IP configuration for the hostname of this application. -// -// Satisfied by [SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable], -// [SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable]. -type SpectrumAppUpdateParamsEdgeIPs interface { - implementsSpectrumAppUpdateParamsEdgeIPs() -} - -type SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable struct { - // The IP versions supported for inbound connections on Spectrum anycast IPs. - Connectivity param.Field[SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity] `json:"connectivity"` - // The type of edge IP configuration specified. Dynamically allocated edge IPs use - // Spectrum anycast IPs in accordance with the connectivity you specify. Only valid - // with CNAME DNS names. - Type param.Field[SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableType] `json:"type"` -} - -func (r SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable) implementsSpectrumAppUpdateParamsEdgeIPs() { -} - -// The IP versions supported for inbound connections on Spectrum anycast IPs. -type SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity string - -const ( - SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityAll SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "all" - SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityIPV4 SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "ipv4" - SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityIPV6 SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivity = "ipv6" -) - -// The type of edge IP configuration specified. Dynamically allocated edge IPs use -// Spectrum anycast IPs in accordance with the connectivity you specify. Only valid -// with CNAME DNS names. -type SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableType string - -const ( - SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableTypeDynamic SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableType = "dynamic" -) - -type SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable struct { - // The array of customer owned IPs we broadcast via anycast for this hostname and - // application. - IPs param.Field[[]string] `json:"ips"` - // The type of edge IP configuration specified. Statically allocated edge IPs use - // customer IPs in accordance with the ips array you specify. Only valid with - // ADDRESS DNS names. - Type param.Field[SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType] `json:"type"` -} - -func (r SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariable) implementsSpectrumAppUpdateParamsEdgeIPs() { -} - -// The type of edge IP configuration specified. Statically allocated edge IPs use -// customer IPs in accordance with the ips array you specify. Only valid with -// ADDRESS DNS names. -type SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType string - -const ( - SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableTypeStatic SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPCustomerOwnedIPsVariableType = "static" -) - -// Enables Proxy Protocol to the origin. Refer to -// [Enable Proxy protocol](https://developers.cloudflare.com/spectrum/getting-started/proxy-protocol/) -// for implementation details on PROXY Protocol V1, PROXY Protocol V2, and Simple -// Proxy Protocol. -type SpectrumAppUpdateParamsProxyProtocol string - -const ( - SpectrumAppUpdateParamsProxyProtocolOff SpectrumAppUpdateParamsProxyProtocol = "off" - SpectrumAppUpdateParamsProxyProtocolV1 SpectrumAppUpdateParamsProxyProtocol = "v1" - SpectrumAppUpdateParamsProxyProtocolV2 SpectrumAppUpdateParamsProxyProtocol = "v2" - SpectrumAppUpdateParamsProxyProtocolSimple SpectrumAppUpdateParamsProxyProtocol = "simple" -) - -// The type of TLS termination associated with the application. -type SpectrumAppUpdateParamsTLS string - -const ( - SpectrumAppUpdateParamsTLSOff SpectrumAppUpdateParamsTLS = "off" - SpectrumAppUpdateParamsTLSFlexible SpectrumAppUpdateParamsTLS = "flexible" - SpectrumAppUpdateParamsTLSFull SpectrumAppUpdateParamsTLS = "full" - SpectrumAppUpdateParamsTLSStrict SpectrumAppUpdateParamsTLS = "strict" -) - -// Determines how data travels from the edge to your origin. When set to "direct", -// Spectrum will send traffic directly to your origin, and the application's type -// is derived from the `protocol`. When set to "http" or "https", Spectrum will -// apply Cloudflare's HTTP/HTTPS features as it sends traffic to your origin, and -// the application type matches this property exactly. -type SpectrumAppUpdateParamsTrafficType string - -const ( - SpectrumAppUpdateParamsTrafficTypeDirect SpectrumAppUpdateParamsTrafficType = "direct" - SpectrumAppUpdateParamsTrafficTypeHTTP SpectrumAppUpdateParamsTrafficType = "http" - SpectrumAppUpdateParamsTrafficTypeHTTPS SpectrumAppUpdateParamsTrafficType = "https" -) - -type SpectrumAppUpdateResponseEnvelope struct { - Errors []SpectrumAppUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []SpectrumAppUpdateResponseEnvelopeMessages `json:"messages,required"` - Result SpectrumAppUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success SpectrumAppUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON spectrumAppUpdateResponseEnvelopeJSON `json:"-"` -} - -// spectrumAppUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [SpectrumAppUpdateResponseEnvelope] -type spectrumAppUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SpectrumAppUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON spectrumAppUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// spectrumAppUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SpectrumAppUpdateResponseEnvelopeErrors] -type spectrumAppUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SpectrumAppUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON spectrumAppUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// spectrumAppUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SpectrumAppUpdateResponseEnvelopeMessages] -type spectrumAppUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SpectrumAppUpdateResponseEnvelopeSuccess bool - -const ( - SpectrumAppUpdateResponseEnvelopeSuccessTrue SpectrumAppUpdateResponseEnvelopeSuccess = true -) - -type SpectrumAppListParams struct { - // Sets the direction by which results are ordered. - Direction param.Field[SpectrumAppListParamsDirection] `query:"direction"` - // Application field by which results are ordered. - Order param.Field[SpectrumAppListParamsOrder] `query:"order"` - // Page number of paginated results. This parameter is required in order to use - // other pagination parameters. If included in the query, `result_info` will be - // present in the response. - Page param.Field[float64] `query:"page"` - // Sets the maximum number of results per page. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [SpectrumAppListParams]'s query parameters as `url.Values`. -func (r SpectrumAppListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Sets the direction by which results are ordered. -type SpectrumAppListParamsDirection string - -const ( - SpectrumAppListParamsDirectionAsc SpectrumAppListParamsDirection = "asc" - SpectrumAppListParamsDirectionDesc SpectrumAppListParamsDirection = "desc" -) - -// Application field by which results are ordered. -type SpectrumAppListParamsOrder string - -const ( - SpectrumAppListParamsOrderProtocol SpectrumAppListParamsOrder = "protocol" - SpectrumAppListParamsOrderAppID SpectrumAppListParamsOrder = "app_id" - SpectrumAppListParamsOrderCreatedOn SpectrumAppListParamsOrder = "created_on" - SpectrumAppListParamsOrderModifiedOn SpectrumAppListParamsOrder = "modified_on" - SpectrumAppListParamsOrderDNS SpectrumAppListParamsOrder = "dns" -) - -type SpectrumAppDeleteResponseEnvelope struct { - Errors []SpectrumAppDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []SpectrumAppDeleteResponseEnvelopeMessages `json:"messages,required"` - Result SpectrumAppDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success SpectrumAppDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON spectrumAppDeleteResponseEnvelopeJSON `json:"-"` -} - -// spectrumAppDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [SpectrumAppDeleteResponseEnvelope] -type spectrumAppDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SpectrumAppDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON spectrumAppDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// spectrumAppDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SpectrumAppDeleteResponseEnvelopeErrors] -type spectrumAppDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SpectrumAppDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON spectrumAppDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// spectrumAppDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SpectrumAppDeleteResponseEnvelopeMessages] -type spectrumAppDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SpectrumAppDeleteResponseEnvelopeSuccess bool - -const ( - SpectrumAppDeleteResponseEnvelopeSuccessTrue SpectrumAppDeleteResponseEnvelopeSuccess = true -) - -type SpectrumAppGetResponseEnvelope struct { - Errors []SpectrumAppGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SpectrumAppGetResponseEnvelopeMessages `json:"messages,required"` - Result SpectrumAppGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success SpectrumAppGetResponseEnvelopeSuccess `json:"success,required"` - JSON spectrumAppGetResponseEnvelopeJSON `json:"-"` -} - -// spectrumAppGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [SpectrumAppGetResponseEnvelope] -type spectrumAppGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SpectrumAppGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON spectrumAppGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// spectrumAppGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SpectrumAppGetResponseEnvelopeErrors] -type spectrumAppGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SpectrumAppGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON spectrumAppGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// spectrumAppGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SpectrumAppGetResponseEnvelopeMessages] -type spectrumAppGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpectrumAppGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r spectrumAppGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SpectrumAppGetResponseEnvelopeSuccess bool - -const ( - SpectrumAppGetResponseEnvelopeSuccessTrue SpectrumAppGetResponseEnvelopeSuccess = true -) diff --git a/spectrumapp_test.go b/spectrumapp_test.go deleted file mode 100644 index 9705bc3ae9f..00000000000 --- a/spectrumapp_test.go +++ /dev/null @@ -1,203 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSpectrumAppNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Spectrum.Apps.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.SpectrumAppNewParams{ - DNS: cloudflare.F(cloudflare.SpectrumAppNewParamsDNS{ - Name: cloudflare.F("ssh.example.com"), - Type: cloudflare.F(cloudflare.SpectrumAppNewParamsDNSTypeCNAME), - }), - OriginDNS: cloudflare.F(cloudflare.SpectrumAppNewParamsOriginDNS{ - Name: cloudflare.F("origin.example.com"), - TTL: cloudflare.F(int64(600)), - Type: cloudflare.F(cloudflare.SpectrumAppNewParamsOriginDNSTypeEmpty), - }), - OriginPort: cloudflare.F[cloudflare.SpectrumAppNewParamsOriginPort](shared.UnionInt(int64(22))), - Protocol: cloudflare.F("tcp/22"), - ArgoSmartRouting: cloudflare.F(true), - EdgeIPs: cloudflare.F[cloudflare.SpectrumAppNewParamsEdgeIPs](cloudflare.SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable(cloudflare.SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable{ - Connectivity: cloudflare.F(cloudflare.SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityAll), - Type: cloudflare.F(cloudflare.SpectrumAppNewParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableTypeDynamic), - })), - IPFirewall: cloudflare.F(true), - ProxyProtocol: cloudflare.F(cloudflare.SpectrumAppNewParamsProxyProtocolOff), - TLS: cloudflare.F(cloudflare.SpectrumAppNewParamsTLSFull), - TrafficType: cloudflare.F(cloudflare.SpectrumAppNewParamsTrafficTypeDirect), - }, - ) - 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 TestSpectrumAppUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Spectrum.Apps.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "ea95132c15732412d22c1476fa83f27a", - cloudflare.SpectrumAppUpdateParams{ - DNS: cloudflare.F(cloudflare.SpectrumAppUpdateParamsDNS{ - Name: cloudflare.F("ssh.example.com"), - Type: cloudflare.F(cloudflare.SpectrumAppUpdateParamsDNSTypeCNAME), - }), - OriginDNS: cloudflare.F(cloudflare.SpectrumAppUpdateParamsOriginDNS{ - Name: cloudflare.F("origin.example.com"), - TTL: cloudflare.F(int64(600)), - Type: cloudflare.F(cloudflare.SpectrumAppUpdateParamsOriginDNSTypeEmpty), - }), - OriginPort: cloudflare.F[cloudflare.SpectrumAppUpdateParamsOriginPort](shared.UnionInt(int64(22))), - Protocol: cloudflare.F("tcp/22"), - ArgoSmartRouting: cloudflare.F(true), - EdgeIPs: cloudflare.F[cloudflare.SpectrumAppUpdateParamsEdgeIPs](cloudflare.SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable(cloudflare.SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariable{ - Connectivity: cloudflare.F(cloudflare.SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableConnectivityAll), - Type: cloudflare.F(cloudflare.SpectrumAppUpdateParamsEdgeIPsSpectrumEdgeIPEyeballIPsVariableTypeDynamic), - })), - IPFirewall: cloudflare.F(true), - ProxyProtocol: cloudflare.F(cloudflare.SpectrumAppUpdateParamsProxyProtocolOff), - TLS: cloudflare.F(cloudflare.SpectrumAppUpdateParamsTLSFull), - TrafficType: cloudflare.F(cloudflare.SpectrumAppUpdateParamsTrafficTypeDirect), - }, - ) - 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 TestSpectrumAppListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Spectrum.Apps.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.SpectrumAppListParams{ - Direction: cloudflare.F(cloudflare.SpectrumAppListParamsDirectionDesc), - Order: cloudflare.F(cloudflare.SpectrumAppListParamsOrderProtocol), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(1.000000), - }, - ) - 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 TestSpectrumAppDelete(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("user@example.com"), - ) - _, err := client.Spectrum.Apps.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "ea95132c15732412d22c1476fa83f27a", - ) - 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 TestSpectrumAppGet(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("user@example.com"), - ) - _, err := client.Spectrum.Apps.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "ea95132c15732412d22c1476fa83f27a", - ) - 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/speed/aliases.go b/speed/aliases.go new file mode 100644 index 00000000000..ff4c7d8dc02 --- /dev/null +++ b/speed/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package speed + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/speed/availability.go b/speed/availability.go new file mode 100644 index 00000000000..7e21cb3e063 --- /dev/null +++ b/speed/availability.go @@ -0,0 +1,182 @@ +// File generated from our OpenAPI spec by Stainless. + +package speed + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AvailabilityService 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 [NewAvailabilityService] method +// instead. +type AvailabilityService struct { + Options []option.RequestOption +} + +// NewAvailabilityService 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 NewAvailabilityService(opts ...option.RequestOption) (r *AvailabilityService) { + r = &AvailabilityService{} + r.Options = opts + return +} + +// Retrieves quota for all plans, as well as the current zone quota. +func (r *AvailabilityService) List(ctx context.Context, query AvailabilityListParams, opts ...option.RequestOption) (res *ObservatoryAvailabilities, err error) { + opts = append(r.Options[:], opts...) + var env AvailabilityListResponseEnvelope + path := fmt.Sprintf("zones/%s/speed_api/availabilities", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ObservatoryAvailabilities struct { + Quota ObservatoryAvailabilitiesQuota `json:"quota"` + Regions []ObservatoryAvailabilitiesRegion `json:"regions"` + RegionsPerPlan interface{} `json:"regionsPerPlan"` + JSON observatoryAvailabilitiesJSON `json:"-"` +} + +// observatoryAvailabilitiesJSON contains the JSON metadata for the struct +// [ObservatoryAvailabilities] +type observatoryAvailabilitiesJSON struct { + Quota apijson.Field + Regions apijson.Field + RegionsPerPlan apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ObservatoryAvailabilities) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r observatoryAvailabilitiesJSON) RawJSON() string { + return r.raw +} + +type ObservatoryAvailabilitiesQuota struct { + // Cloudflare plan. + Plan string `json:"plan"` + // The number of tests available per plan. + QuotasPerPlan map[string]float64 `json:"quotasPerPlan"` + // The number of remaining schedules available. + RemainingSchedules float64 `json:"remainingSchedules"` + // The number of remaining tests available. + RemainingTests float64 `json:"remainingTests"` + // The number of schedules available per plan. + ScheduleQuotasPerPlan map[string]float64 `json:"scheduleQuotasPerPlan"` + JSON observatoryAvailabilitiesQuotaJSON `json:"-"` +} + +// observatoryAvailabilitiesQuotaJSON contains the JSON metadata for the struct +// [ObservatoryAvailabilitiesQuota] +type observatoryAvailabilitiesQuotaJSON struct { + Plan apijson.Field + QuotasPerPlan apijson.Field + RemainingSchedules apijson.Field + RemainingTests apijson.Field + ScheduleQuotasPerPlan apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ObservatoryAvailabilitiesQuota) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r observatoryAvailabilitiesQuotaJSON) RawJSON() string { + return r.raw +} + +// A test region with a label. +type ObservatoryAvailabilitiesRegion struct { + Label string `json:"label"` + // A test region. + Value ObservatoryAvailabilitiesRegionsValue `json:"value"` + JSON observatoryAvailabilitiesRegionJSON `json:"-"` +} + +// observatoryAvailabilitiesRegionJSON contains the JSON metadata for the struct +// [ObservatoryAvailabilitiesRegion] +type observatoryAvailabilitiesRegionJSON struct { + Label apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ObservatoryAvailabilitiesRegion) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r observatoryAvailabilitiesRegionJSON) RawJSON() string { + return r.raw +} + +// A test region. +type ObservatoryAvailabilitiesRegionsValue string + +const ( + ObservatoryAvailabilitiesRegionsValueAsiaEast1 ObservatoryAvailabilitiesRegionsValue = "asia-east1" + ObservatoryAvailabilitiesRegionsValueAsiaNortheast1 ObservatoryAvailabilitiesRegionsValue = "asia-northeast1" + ObservatoryAvailabilitiesRegionsValueAsiaNortheast2 ObservatoryAvailabilitiesRegionsValue = "asia-northeast2" + ObservatoryAvailabilitiesRegionsValueAsiaSouth1 ObservatoryAvailabilitiesRegionsValue = "asia-south1" + ObservatoryAvailabilitiesRegionsValueAsiaSoutheast1 ObservatoryAvailabilitiesRegionsValue = "asia-southeast1" + ObservatoryAvailabilitiesRegionsValueAustraliaSoutheast1 ObservatoryAvailabilitiesRegionsValue = "australia-southeast1" + ObservatoryAvailabilitiesRegionsValueEuropeNorth1 ObservatoryAvailabilitiesRegionsValue = "europe-north1" + ObservatoryAvailabilitiesRegionsValueEuropeSouthwest1 ObservatoryAvailabilitiesRegionsValue = "europe-southwest1" + ObservatoryAvailabilitiesRegionsValueEuropeWest1 ObservatoryAvailabilitiesRegionsValue = "europe-west1" + ObservatoryAvailabilitiesRegionsValueEuropeWest2 ObservatoryAvailabilitiesRegionsValue = "europe-west2" + ObservatoryAvailabilitiesRegionsValueEuropeWest3 ObservatoryAvailabilitiesRegionsValue = "europe-west3" + ObservatoryAvailabilitiesRegionsValueEuropeWest4 ObservatoryAvailabilitiesRegionsValue = "europe-west4" + ObservatoryAvailabilitiesRegionsValueEuropeWest8 ObservatoryAvailabilitiesRegionsValue = "europe-west8" + ObservatoryAvailabilitiesRegionsValueEuropeWest9 ObservatoryAvailabilitiesRegionsValue = "europe-west9" + ObservatoryAvailabilitiesRegionsValueMeWest1 ObservatoryAvailabilitiesRegionsValue = "me-west1" + ObservatoryAvailabilitiesRegionsValueSouthamericaEast1 ObservatoryAvailabilitiesRegionsValue = "southamerica-east1" + ObservatoryAvailabilitiesRegionsValueUsCentral1 ObservatoryAvailabilitiesRegionsValue = "us-central1" + ObservatoryAvailabilitiesRegionsValueUsEast1 ObservatoryAvailabilitiesRegionsValue = "us-east1" + ObservatoryAvailabilitiesRegionsValueUsEast4 ObservatoryAvailabilitiesRegionsValue = "us-east4" + ObservatoryAvailabilitiesRegionsValueUsSouth1 ObservatoryAvailabilitiesRegionsValue = "us-south1" + ObservatoryAvailabilitiesRegionsValueUsWest1 ObservatoryAvailabilitiesRegionsValue = "us-west1" +) + +type AvailabilityListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type AvailabilityListResponseEnvelope struct { + Result ObservatoryAvailabilities `json:"result"` + JSON availabilityListResponseEnvelopeJSON `json:"-"` +} + +// availabilityListResponseEnvelopeJSON contains the JSON metadata for the struct +// [AvailabilityListResponseEnvelope] +type availabilityListResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AvailabilityListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r availabilityListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/speed/availability_test.go b/speed/availability_test.go new file mode 100644 index 00000000000..6ad28da98a0 --- /dev/null +++ b/speed/availability_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package speed_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/speed" +) + +func TestAvailabilityList(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("user@example.com"), + ) + _, err := client.Speed.Availabilities.List(context.TODO(), speed.AvailabilityListParams{ + ZoneID: cloudflare.F("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/speed/page.go b/speed/page.go new file mode 100644 index 00000000000..8083ce45e46 --- /dev/null +++ b/speed/page.go @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package speed + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// PageService 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 [NewPageService] method instead. +type PageService struct { + Options []option.RequestOption +} + +// NewPageService 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 NewPageService(opts ...option.RequestOption) (r *PageService) { + r = &PageService{} + r.Options = opts + return +} + +// Lists all webpages which have been tested. +func (r *PageService) List(ctx context.Context, query PageListParams, opts ...option.RequestOption) (res *[]PageListResponse, err error) { + opts = append(r.Options[:], opts...) + var env PageListResponseEnvelope + path := fmt.Sprintf("zones/%s/speed_api/pages", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type PageListResponse struct { + // A test region with a label. + Region PageListResponseRegion `json:"region"` + // The frequency of the test. + ScheduleFrequency PageListResponseScheduleFrequency `json:"scheduleFrequency"` + Tests []ObservatoryPageTest `json:"tests"` + // A URL. + URL string `json:"url"` + JSON pageListResponseJSON `json:"-"` +} + +// pageListResponseJSON contains the JSON metadata for the struct +// [PageListResponse] +type pageListResponseJSON struct { + Region apijson.Field + ScheduleFrequency apijson.Field + Tests apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PageListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pageListResponseJSON) RawJSON() string { + return r.raw +} + +// A test region with a label. +type PageListResponseRegion struct { + Label string `json:"label"` + // A test region. + Value PageListResponseRegionValue `json:"value"` + JSON pageListResponseRegionJSON `json:"-"` +} + +// pageListResponseRegionJSON contains the JSON metadata for the struct +// [PageListResponseRegion] +type pageListResponseRegionJSON struct { + Label apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PageListResponseRegion) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pageListResponseRegionJSON) RawJSON() string { + return r.raw +} + +// A test region. +type PageListResponseRegionValue string + +const ( + PageListResponseRegionValueAsiaEast1 PageListResponseRegionValue = "asia-east1" + PageListResponseRegionValueAsiaNortheast1 PageListResponseRegionValue = "asia-northeast1" + PageListResponseRegionValueAsiaNortheast2 PageListResponseRegionValue = "asia-northeast2" + PageListResponseRegionValueAsiaSouth1 PageListResponseRegionValue = "asia-south1" + PageListResponseRegionValueAsiaSoutheast1 PageListResponseRegionValue = "asia-southeast1" + PageListResponseRegionValueAustraliaSoutheast1 PageListResponseRegionValue = "australia-southeast1" + PageListResponseRegionValueEuropeNorth1 PageListResponseRegionValue = "europe-north1" + PageListResponseRegionValueEuropeSouthwest1 PageListResponseRegionValue = "europe-southwest1" + PageListResponseRegionValueEuropeWest1 PageListResponseRegionValue = "europe-west1" + PageListResponseRegionValueEuropeWest2 PageListResponseRegionValue = "europe-west2" + PageListResponseRegionValueEuropeWest3 PageListResponseRegionValue = "europe-west3" + PageListResponseRegionValueEuropeWest4 PageListResponseRegionValue = "europe-west4" + PageListResponseRegionValueEuropeWest8 PageListResponseRegionValue = "europe-west8" + PageListResponseRegionValueEuropeWest9 PageListResponseRegionValue = "europe-west9" + PageListResponseRegionValueMeWest1 PageListResponseRegionValue = "me-west1" + PageListResponseRegionValueSouthamericaEast1 PageListResponseRegionValue = "southamerica-east1" + PageListResponseRegionValueUsCentral1 PageListResponseRegionValue = "us-central1" + PageListResponseRegionValueUsEast1 PageListResponseRegionValue = "us-east1" + PageListResponseRegionValueUsEast4 PageListResponseRegionValue = "us-east4" + PageListResponseRegionValueUsSouth1 PageListResponseRegionValue = "us-south1" + PageListResponseRegionValueUsWest1 PageListResponseRegionValue = "us-west1" +) + +// The frequency of the test. +type PageListResponseScheduleFrequency string + +const ( + PageListResponseScheduleFrequencyDaily PageListResponseScheduleFrequency = "DAILY" + PageListResponseScheduleFrequencyWeekly PageListResponseScheduleFrequency = "WEEKLY" +) + +type PageListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type PageListResponseEnvelope struct { + Result []PageListResponse `json:"result"` + JSON pageListResponseEnvelopeJSON `json:"-"` +} + +// pageListResponseEnvelopeJSON contains the JSON metadata for the struct +// [PageListResponseEnvelope] +type pageListResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *PageListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r pageListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/speed/page_test.go b/speed/page_test.go new file mode 100644 index 00000000000..3df98159b9a --- /dev/null +++ b/speed/page_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package speed_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/speed" +) + +func TestPageList(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("user@example.com"), + ) + _, err := client.Speed.Pages.List(context.TODO(), speed.PageListParams{ + ZoneID: cloudflare.F("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/speed/schedule.go b/speed/schedule.go new file mode 100644 index 00000000000..364fe7872db --- /dev/null +++ b/speed/schedule.go @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package speed + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ScheduleService 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 [NewScheduleService] method instead. +type ScheduleService struct { + Options []option.RequestOption +} + +// NewScheduleService 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 NewScheduleService(opts ...option.RequestOption) (r *ScheduleService) { + r = &ScheduleService{} + r.Options = opts + return +} + +// Creates a scheduled test for a page. +func (r *ScheduleService) New(ctx context.Context, url string, params ScheduleNewParams, opts ...option.RequestOption) (res *ScheduleNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env ScheduleNewResponseEnvelope + path := fmt.Sprintf("zones/%s/speed_api/schedule/%s", params.ZoneID, url) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ScheduleNewResponse struct { + // The test schedule. + Schedule ObservatorySchedule `json:"schedule"` + Test ObservatoryPageTest `json:"test"` + JSON scheduleNewResponseJSON `json:"-"` +} + +// scheduleNewResponseJSON contains the JSON metadata for the struct +// [ScheduleNewResponse] +type scheduleNewResponseJSON struct { + Schedule apijson.Field + Test apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScheduleNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scheduleNewResponseJSON) RawJSON() string { + return r.raw +} + +type ScheduleNewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // A test region. + Region param.Field[ScheduleNewParamsRegion] `query:"region"` +} + +// URLQuery serializes [ScheduleNewParams]'s query parameters as `url.Values`. +func (r ScheduleNewParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// A test region. +type ScheduleNewParamsRegion string + +const ( + ScheduleNewParamsRegionAsiaEast1 ScheduleNewParamsRegion = "asia-east1" + ScheduleNewParamsRegionAsiaNortheast1 ScheduleNewParamsRegion = "asia-northeast1" + ScheduleNewParamsRegionAsiaNortheast2 ScheduleNewParamsRegion = "asia-northeast2" + ScheduleNewParamsRegionAsiaSouth1 ScheduleNewParamsRegion = "asia-south1" + ScheduleNewParamsRegionAsiaSoutheast1 ScheduleNewParamsRegion = "asia-southeast1" + ScheduleNewParamsRegionAustraliaSoutheast1 ScheduleNewParamsRegion = "australia-southeast1" + ScheduleNewParamsRegionEuropeNorth1 ScheduleNewParamsRegion = "europe-north1" + ScheduleNewParamsRegionEuropeSouthwest1 ScheduleNewParamsRegion = "europe-southwest1" + ScheduleNewParamsRegionEuropeWest1 ScheduleNewParamsRegion = "europe-west1" + ScheduleNewParamsRegionEuropeWest2 ScheduleNewParamsRegion = "europe-west2" + ScheduleNewParamsRegionEuropeWest3 ScheduleNewParamsRegion = "europe-west3" + ScheduleNewParamsRegionEuropeWest4 ScheduleNewParamsRegion = "europe-west4" + ScheduleNewParamsRegionEuropeWest8 ScheduleNewParamsRegion = "europe-west8" + ScheduleNewParamsRegionEuropeWest9 ScheduleNewParamsRegion = "europe-west9" + ScheduleNewParamsRegionMeWest1 ScheduleNewParamsRegion = "me-west1" + ScheduleNewParamsRegionSouthamericaEast1 ScheduleNewParamsRegion = "southamerica-east1" + ScheduleNewParamsRegionUsCentral1 ScheduleNewParamsRegion = "us-central1" + ScheduleNewParamsRegionUsEast1 ScheduleNewParamsRegion = "us-east1" + ScheduleNewParamsRegionUsEast4 ScheduleNewParamsRegion = "us-east4" + ScheduleNewParamsRegionUsSouth1 ScheduleNewParamsRegion = "us-south1" + ScheduleNewParamsRegionUsWest1 ScheduleNewParamsRegion = "us-west1" +) + +type ScheduleNewResponseEnvelope struct { + Result ScheduleNewResponse `json:"result"` + JSON scheduleNewResponseEnvelopeJSON `json:"-"` +} + +// scheduleNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [ScheduleNewResponseEnvelope] +type scheduleNewResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScheduleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scheduleNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/speed/schedule_test.go b/speed/schedule_test.go new file mode 100644 index 00000000000..bb2e720fad3 --- /dev/null +++ b/speed/schedule_test.go @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package speed_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/speed" +) + +func TestScheduleNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Speed.Schedule.New( + context.TODO(), + "example.com", + speed.ScheduleNewParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Region: cloudflare.F(speed.ScheduleNewParamsRegionUsCentral1), + }, + ) + 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/speed.go b/speed/speed.go similarity index 78% rename from speed.go rename to speed/speed.go index c1b09504850..6235606c635 100644 --- a/speed.go +++ b/speed/speed.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package speed import ( "context" @@ -21,10 +21,10 @@ import ( // directly, and instead use the [NewSpeedService] method instead. type SpeedService struct { Options []option.RequestOption - Tests *SpeedTestService - Schedule *SpeedScheduleService - Availabilities *SpeedAvailabilityService - Pages *SpeedPageService + Tests *TestService + Schedule *ScheduleService + Availabilities *AvailabilityService + Pages *PageService } // NewSpeedService generates a new service that applies the given options to each @@ -33,10 +33,10 @@ type SpeedService struct { func NewSpeedService(opts ...option.RequestOption) (r *SpeedService) { r = &SpeedService{} r.Options = opts - r.Tests = NewSpeedTestService(opts...) - r.Schedule = NewSpeedScheduleService(opts...) - r.Availabilities = NewSpeedAvailabilityService(opts...) - r.Pages = NewSpeedPageService(opts...) + r.Tests = NewTestService(opts...) + r.Schedule = NewScheduleService(opts...) + r.Availabilities = NewAvailabilityService(opts...) + r.Pages = NewPageService(opts...) return } @@ -54,7 +54,7 @@ func (r *SpeedService) Delete(ctx context.Context, url string, params SpeedDelet } // Retrieves the test schedule for a page in a specific region. -func (r *SpeedService) ScheduleGet(ctx context.Context, url string, params SpeedScheduleGetParams, opts ...option.RequestOption) (res *SpeedScheduleGetResponse, err error) { +func (r *SpeedService) ScheduleGet(ctx context.Context, url string, params SpeedScheduleGetParams, opts ...option.RequestOption) (res *ObservatorySchedule, err error) { opts = append(r.Options[:], opts...) var env SpeedScheduleGetResponseEnvelope path := fmt.Sprintf("zones/%s/speed_api/schedule/%s", params.ZoneID, url) @@ -67,7 +67,7 @@ func (r *SpeedService) ScheduleGet(ctx context.Context, url string, params Speed } // Lists the core web vital metrics trend over time for a specific page. -func (r *SpeedService) TrendsList(ctx context.Context, url string, params SpeedTrendsListParams, opts ...option.RequestOption) (res *SpeedTrendsListResponse, err error) { +func (r *SpeedService) TrendsList(ctx context.Context, url string, params SpeedTrendsListParams, opts ...option.RequestOption) (res *ObservatoryTrend, err error) { opts = append(r.Options[:], opts...) var env SpeedTrendsListResponseEnvelope path := fmt.Sprintf("zones/%s/speed_api/pages/%s/trend", params.ZoneID, url) @@ -79,42 +79,20 @@ func (r *SpeedService) TrendsList(ctx context.Context, url string, params SpeedT return } -type SpeedDeleteResponse struct { - // Number of items affected. - Count float64 `json:"count"` - JSON speedDeleteResponseJSON `json:"-"` -} - -// speedDeleteResponseJSON contains the JSON metadata for the struct -// [SpeedDeleteResponse] -type speedDeleteResponseJSON struct { - Count apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedDeleteResponseJSON) RawJSON() string { - return r.raw -} - // The test schedule. -type SpeedScheduleGetResponse struct { +type ObservatorySchedule struct { // The frequency of the test. - Frequency SpeedScheduleGetResponseFrequency `json:"frequency"` + Frequency ObservatoryScheduleFrequency `json:"frequency"` // A test region. - Region SpeedScheduleGetResponseRegion `json:"region"` + Region ObservatoryScheduleRegion `json:"region"` // A URL. - URL string `json:"url"` - JSON speedScheduleGetResponseJSON `json:"-"` + URL string `json:"url"` + JSON observatoryScheduleJSON `json:"-"` } -// speedScheduleGetResponseJSON contains the JSON metadata for the struct -// [SpeedScheduleGetResponse] -type speedScheduleGetResponseJSON struct { +// observatoryScheduleJSON contains the JSON metadata for the struct +// [ObservatorySchedule] +type observatoryScheduleJSON struct { Frequency apijson.Field Region apijson.Field URL apijson.Field @@ -122,50 +100,50 @@ type speedScheduleGetResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *SpeedScheduleGetResponse) UnmarshalJSON(data []byte) (err error) { +func (r *ObservatorySchedule) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r speedScheduleGetResponseJSON) RawJSON() string { +func (r observatoryScheduleJSON) RawJSON() string { return r.raw } // The frequency of the test. -type SpeedScheduleGetResponseFrequency string +type ObservatoryScheduleFrequency string const ( - SpeedScheduleGetResponseFrequencyDaily SpeedScheduleGetResponseFrequency = "DAILY" - SpeedScheduleGetResponseFrequencyWeekly SpeedScheduleGetResponseFrequency = "WEEKLY" + ObservatoryScheduleFrequencyDaily ObservatoryScheduleFrequency = "DAILY" + ObservatoryScheduleFrequencyWeekly ObservatoryScheduleFrequency = "WEEKLY" ) // A test region. -type SpeedScheduleGetResponseRegion string +type ObservatoryScheduleRegion string const ( - SpeedScheduleGetResponseRegionAsiaEast1 SpeedScheduleGetResponseRegion = "asia-east1" - SpeedScheduleGetResponseRegionAsiaNortheast1 SpeedScheduleGetResponseRegion = "asia-northeast1" - SpeedScheduleGetResponseRegionAsiaNortheast2 SpeedScheduleGetResponseRegion = "asia-northeast2" - SpeedScheduleGetResponseRegionAsiaSouth1 SpeedScheduleGetResponseRegion = "asia-south1" - SpeedScheduleGetResponseRegionAsiaSoutheast1 SpeedScheduleGetResponseRegion = "asia-southeast1" - SpeedScheduleGetResponseRegionAustraliaSoutheast1 SpeedScheduleGetResponseRegion = "australia-southeast1" - SpeedScheduleGetResponseRegionEuropeNorth1 SpeedScheduleGetResponseRegion = "europe-north1" - SpeedScheduleGetResponseRegionEuropeSouthwest1 SpeedScheduleGetResponseRegion = "europe-southwest1" - SpeedScheduleGetResponseRegionEuropeWest1 SpeedScheduleGetResponseRegion = "europe-west1" - SpeedScheduleGetResponseRegionEuropeWest2 SpeedScheduleGetResponseRegion = "europe-west2" - SpeedScheduleGetResponseRegionEuropeWest3 SpeedScheduleGetResponseRegion = "europe-west3" - SpeedScheduleGetResponseRegionEuropeWest4 SpeedScheduleGetResponseRegion = "europe-west4" - SpeedScheduleGetResponseRegionEuropeWest8 SpeedScheduleGetResponseRegion = "europe-west8" - SpeedScheduleGetResponseRegionEuropeWest9 SpeedScheduleGetResponseRegion = "europe-west9" - SpeedScheduleGetResponseRegionMeWest1 SpeedScheduleGetResponseRegion = "me-west1" - SpeedScheduleGetResponseRegionSouthamericaEast1 SpeedScheduleGetResponseRegion = "southamerica-east1" - SpeedScheduleGetResponseRegionUsCentral1 SpeedScheduleGetResponseRegion = "us-central1" - SpeedScheduleGetResponseRegionUsEast1 SpeedScheduleGetResponseRegion = "us-east1" - SpeedScheduleGetResponseRegionUsEast4 SpeedScheduleGetResponseRegion = "us-east4" - SpeedScheduleGetResponseRegionUsSouth1 SpeedScheduleGetResponseRegion = "us-south1" - SpeedScheduleGetResponseRegionUsWest1 SpeedScheduleGetResponseRegion = "us-west1" + ObservatoryScheduleRegionAsiaEast1 ObservatoryScheduleRegion = "asia-east1" + ObservatoryScheduleRegionAsiaNortheast1 ObservatoryScheduleRegion = "asia-northeast1" + ObservatoryScheduleRegionAsiaNortheast2 ObservatoryScheduleRegion = "asia-northeast2" + ObservatoryScheduleRegionAsiaSouth1 ObservatoryScheduleRegion = "asia-south1" + ObservatoryScheduleRegionAsiaSoutheast1 ObservatoryScheduleRegion = "asia-southeast1" + ObservatoryScheduleRegionAustraliaSoutheast1 ObservatoryScheduleRegion = "australia-southeast1" + ObservatoryScheduleRegionEuropeNorth1 ObservatoryScheduleRegion = "europe-north1" + ObservatoryScheduleRegionEuropeSouthwest1 ObservatoryScheduleRegion = "europe-southwest1" + ObservatoryScheduleRegionEuropeWest1 ObservatoryScheduleRegion = "europe-west1" + ObservatoryScheduleRegionEuropeWest2 ObservatoryScheduleRegion = "europe-west2" + ObservatoryScheduleRegionEuropeWest3 ObservatoryScheduleRegion = "europe-west3" + ObservatoryScheduleRegionEuropeWest4 ObservatoryScheduleRegion = "europe-west4" + ObservatoryScheduleRegionEuropeWest8 ObservatoryScheduleRegion = "europe-west8" + ObservatoryScheduleRegionEuropeWest9 ObservatoryScheduleRegion = "europe-west9" + ObservatoryScheduleRegionMeWest1 ObservatoryScheduleRegion = "me-west1" + ObservatoryScheduleRegionSouthamericaEast1 ObservatoryScheduleRegion = "southamerica-east1" + ObservatoryScheduleRegionUsCentral1 ObservatoryScheduleRegion = "us-central1" + ObservatoryScheduleRegionUsEast1 ObservatoryScheduleRegion = "us-east1" + ObservatoryScheduleRegionUsEast4 ObservatoryScheduleRegion = "us-east4" + ObservatoryScheduleRegionUsSouth1 ObservatoryScheduleRegion = "us-south1" + ObservatoryScheduleRegionUsWest1 ObservatoryScheduleRegion = "us-west1" ) -type SpeedTrendsListResponse struct { +type ObservatoryTrend struct { // Cumulative Layout Shift trend. Cls []float64 `json:"cls"` // First Contentful Paint trend. @@ -181,13 +159,13 @@ type SpeedTrendsListResponse struct { // Time To First Byte trend. Ttfb []float64 `json:"ttfb"` // Time To Interactive trend. - Tti []float64 `json:"tti"` - JSON speedTrendsListResponseJSON `json:"-"` + Tti []float64 `json:"tti"` + JSON observatoryTrendJSON `json:"-"` } -// speedTrendsListResponseJSON contains the JSON metadata for the struct -// [SpeedTrendsListResponse] -type speedTrendsListResponseJSON struct { +// observatoryTrendJSON contains the JSON metadata for the struct +// [ObservatoryTrend] +type observatoryTrendJSON struct { Cls apijson.Field Fcp apijson.Field Lcp apijson.Field @@ -200,11 +178,33 @@ type speedTrendsListResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *SpeedTrendsListResponse) UnmarshalJSON(data []byte) (err error) { +func (r *ObservatoryTrend) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r speedTrendsListResponseJSON) RawJSON() string { +func (r observatoryTrendJSON) RawJSON() string { + return r.raw +} + +type SpeedDeleteResponse struct { + // Number of items affected. + Count float64 `json:"count"` + JSON speedDeleteResponseJSON `json:"-"` +} + +// speedDeleteResponseJSON contains the JSON metadata for the struct +// [SpeedDeleteResponse] +type speedDeleteResponseJSON struct { + Count apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SpeedDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r speedDeleteResponseJSON) RawJSON() string { return r.raw } @@ -315,7 +315,7 @@ const ( type SpeedScheduleGetResponseEnvelope struct { // The test schedule. - Result SpeedScheduleGetResponse `json:"result"` + Result ObservatorySchedule `json:"result"` JSON speedScheduleGetResponseEnvelopeJSON `json:"-"` } @@ -392,7 +392,7 @@ const ( ) type SpeedTrendsListResponseEnvelope struct { - Result SpeedTrendsListResponse `json:"result"` + Result ObservatoryTrend `json:"result"` JSON speedTrendsListResponseEnvelopeJSON `json:"-"` } diff --git a/speed_test.go b/speed/speed_test.go similarity index 86% rename from speed_test.go rename to speed/speed_test.go index 95cd8bc8edf..252c1757b21 100644 --- a/speed_test.go +++ b/speed/speed_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package speed_test import ( "context" @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/speed" ) func TestSpeedDeleteWithOptionalParams(t *testing.T) { @@ -30,9 +31,9 @@ func TestSpeedDeleteWithOptionalParams(t *testing.T) { _, err := client.Speed.Delete( context.TODO(), "example.com", - cloudflare.SpeedDeleteParams{ + speed.SpeedDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Region: cloudflare.F(cloudflare.SpeedDeleteParamsRegionUsCentral1), + Region: cloudflare.F(speed.SpeedDeleteParamsRegionUsCentral1), }, ) if err != nil { @@ -61,9 +62,9 @@ func TestSpeedScheduleGetWithOptionalParams(t *testing.T) { _, err := client.Speed.ScheduleGet( context.TODO(), "example.com", - cloudflare.SpeedScheduleGetParams{ + speed.SpeedScheduleGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Region: cloudflare.F(cloudflare.SpeedScheduleGetParamsRegionUsCentral1), + Region: cloudflare.F(speed.SpeedScheduleGetParamsRegionUsCentral1), }, ) if err != nil { @@ -92,11 +93,11 @@ func TestSpeedTrendsList(t *testing.T) { _, err := client.Speed.TrendsList( context.TODO(), "example.com", - cloudflare.SpeedTrendsListParams{ + speed.SpeedTrendsListParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - DeviceType: cloudflare.F(cloudflare.SpeedTrendsListParamsDeviceTypeDesktop), + DeviceType: cloudflare.F(speed.SpeedTrendsListParamsDeviceTypeDesktop), Metrics: cloudflare.F("performanceScore,ttfb,fcp,si,lcp,tti,tbt,cls"), - Region: cloudflare.F(cloudflare.SpeedTrendsListParamsRegionUsCentral1), + Region: cloudflare.F(speed.SpeedTrendsListParamsRegionUsCentral1), Tz: cloudflare.F("string"), }, ) diff --git a/speed/test.go b/speed/test.go new file mode 100644 index 00000000000..cff613b8736 --- /dev/null +++ b/speed/test.go @@ -0,0 +1,718 @@ +// File generated from our OpenAPI spec by Stainless. + +package speed + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// TestService 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 [NewTestService] method instead. +type TestService struct { + Options []option.RequestOption +} + +// NewTestService 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 NewTestService(opts ...option.RequestOption) (r *TestService) { + r = &TestService{} + r.Options = opts + return +} + +// Starts a test for a specific webpage, in a specific region. +func (r *TestService) New(ctx context.Context, url string, params TestNewParams, opts ...option.RequestOption) (res *ObservatoryPageTest, err error) { + opts = append(r.Options[:], opts...) + var env TestNewResponseEnvelope + path := fmt.Sprintf("zones/%s/speed_api/pages/%s/tests", params.ZoneID, url) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Test history (list of tests) for a specific webpage. +func (r *TestService) List(ctx context.Context, url string, params TestListParams, opts ...option.RequestOption) (res *TestListResponse, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("zones/%s/speed_api/pages/%s/tests", params.ZoneID, url) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &res, opts...) + return +} + +// Deletes all tests for a specific webpage from a specific region. Deleted tests +// are still counted as part of the quota. +func (r *TestService) Delete(ctx context.Context, url string, params TestDeleteParams, opts ...option.RequestOption) (res *TestDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env TestDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/speed_api/pages/%s/tests", params.ZoneID, url) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Retrieves the result of a specific test. +func (r *TestService) Get(ctx context.Context, url string, testID string, query TestGetParams, opts ...option.RequestOption) (res *ObservatoryPageTest, err error) { + opts = append(r.Options[:], opts...) + var env TestGetResponseEnvelope + path := fmt.Sprintf("zones/%s/speed_api/pages/%s/tests/%s", query.ZoneID, url, testID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ObservatoryPageTest struct { + // UUID + ID string `json:"id"` + Date time.Time `json:"date" format:"date-time"` + // The Lighthouse report. + DesktopReport ObservatoryPageTestDesktopReport `json:"desktopReport"` + // The Lighthouse report. + MobileReport ObservatoryPageTestMobileReport `json:"mobileReport"` + // A test region with a label. + Region ObservatoryPageTestRegion `json:"region"` + // The frequency of the test. + ScheduleFrequency ObservatoryPageTestScheduleFrequency `json:"scheduleFrequency"` + // A URL. + URL string `json:"url"` + JSON observatoryPageTestJSON `json:"-"` +} + +// observatoryPageTestJSON contains the JSON metadata for the struct +// [ObservatoryPageTest] +type observatoryPageTestJSON struct { + ID apijson.Field + Date apijson.Field + DesktopReport apijson.Field + MobileReport apijson.Field + Region apijson.Field + ScheduleFrequency apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ObservatoryPageTest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r observatoryPageTestJSON) RawJSON() string { + return r.raw +} + +// The Lighthouse report. +type ObservatoryPageTestDesktopReport struct { + // Cumulative Layout Shift. + Cls float64 `json:"cls"` + // The type of device. + DeviceType ObservatoryPageTestDesktopReportDeviceType `json:"deviceType"` + Error ObservatoryPageTestDesktopReportError `json:"error"` + // First Contentful Paint. + Fcp float64 `json:"fcp"` + // The URL to the full Lighthouse JSON report. + JsonReportURL string `json:"jsonReportUrl"` + // Largest Contentful Paint. + Lcp float64 `json:"lcp"` + // The Lighthouse performance score. + PerformanceScore float64 `json:"performanceScore"` + // Speed Index. + Si float64 `json:"si"` + // The state of the Lighthouse report. + State ObservatoryPageTestDesktopReportState `json:"state"` + // Total Blocking Time. + Tbt float64 `json:"tbt"` + // Time To First Byte. + Ttfb float64 `json:"ttfb"` + // Time To Interactive. + Tti float64 `json:"tti"` + JSON observatoryPageTestDesktopReportJSON `json:"-"` +} + +// observatoryPageTestDesktopReportJSON contains the JSON metadata for the struct +// [ObservatoryPageTestDesktopReport] +type observatoryPageTestDesktopReportJSON struct { + Cls apijson.Field + DeviceType apijson.Field + Error apijson.Field + Fcp apijson.Field + JsonReportURL apijson.Field + Lcp apijson.Field + PerformanceScore apijson.Field + Si apijson.Field + State apijson.Field + Tbt apijson.Field + Ttfb apijson.Field + Tti apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ObservatoryPageTestDesktopReport) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r observatoryPageTestDesktopReportJSON) RawJSON() string { + return r.raw +} + +// The type of device. +type ObservatoryPageTestDesktopReportDeviceType string + +const ( + ObservatoryPageTestDesktopReportDeviceTypeDesktop ObservatoryPageTestDesktopReportDeviceType = "DESKTOP" + ObservatoryPageTestDesktopReportDeviceTypeMobile ObservatoryPageTestDesktopReportDeviceType = "MOBILE" +) + +type ObservatoryPageTestDesktopReportError struct { + // The error code of the Lighthouse result. + Code ObservatoryPageTestDesktopReportErrorCode `json:"code"` + // Detailed error message. + Detail string `json:"detail"` + // The final URL displayed to the user. + FinalDisplayedURL string `json:"finalDisplayedUrl"` + JSON observatoryPageTestDesktopReportErrorJSON `json:"-"` +} + +// observatoryPageTestDesktopReportErrorJSON contains the JSON metadata for the +// struct [ObservatoryPageTestDesktopReportError] +type observatoryPageTestDesktopReportErrorJSON struct { + Code apijson.Field + Detail apijson.Field + FinalDisplayedURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ObservatoryPageTestDesktopReportError) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r observatoryPageTestDesktopReportErrorJSON) RawJSON() string { + return r.raw +} + +// The error code of the Lighthouse result. +type ObservatoryPageTestDesktopReportErrorCode string + +const ( + ObservatoryPageTestDesktopReportErrorCodeNotReachable ObservatoryPageTestDesktopReportErrorCode = "NOT_REACHABLE" + ObservatoryPageTestDesktopReportErrorCodeDNSFailure ObservatoryPageTestDesktopReportErrorCode = "DNS_FAILURE" + ObservatoryPageTestDesktopReportErrorCodeNotHTML ObservatoryPageTestDesktopReportErrorCode = "NOT_HTML" + ObservatoryPageTestDesktopReportErrorCodeLighthouseTimeout ObservatoryPageTestDesktopReportErrorCode = "LIGHTHOUSE_TIMEOUT" + ObservatoryPageTestDesktopReportErrorCodeUnknown ObservatoryPageTestDesktopReportErrorCode = "UNKNOWN" +) + +// The state of the Lighthouse report. +type ObservatoryPageTestDesktopReportState string + +const ( + ObservatoryPageTestDesktopReportStateRunning ObservatoryPageTestDesktopReportState = "RUNNING" + ObservatoryPageTestDesktopReportStateComplete ObservatoryPageTestDesktopReportState = "COMPLETE" + ObservatoryPageTestDesktopReportStateFailed ObservatoryPageTestDesktopReportState = "FAILED" +) + +// The Lighthouse report. +type ObservatoryPageTestMobileReport struct { + // Cumulative Layout Shift. + Cls float64 `json:"cls"` + // The type of device. + DeviceType ObservatoryPageTestMobileReportDeviceType `json:"deviceType"` + Error ObservatoryPageTestMobileReportError `json:"error"` + // First Contentful Paint. + Fcp float64 `json:"fcp"` + // The URL to the full Lighthouse JSON report. + JsonReportURL string `json:"jsonReportUrl"` + // Largest Contentful Paint. + Lcp float64 `json:"lcp"` + // The Lighthouse performance score. + PerformanceScore float64 `json:"performanceScore"` + // Speed Index. + Si float64 `json:"si"` + // The state of the Lighthouse report. + State ObservatoryPageTestMobileReportState `json:"state"` + // Total Blocking Time. + Tbt float64 `json:"tbt"` + // Time To First Byte. + Ttfb float64 `json:"ttfb"` + // Time To Interactive. + Tti float64 `json:"tti"` + JSON observatoryPageTestMobileReportJSON `json:"-"` +} + +// observatoryPageTestMobileReportJSON contains the JSON metadata for the struct +// [ObservatoryPageTestMobileReport] +type observatoryPageTestMobileReportJSON struct { + Cls apijson.Field + DeviceType apijson.Field + Error apijson.Field + Fcp apijson.Field + JsonReportURL apijson.Field + Lcp apijson.Field + PerformanceScore apijson.Field + Si apijson.Field + State apijson.Field + Tbt apijson.Field + Ttfb apijson.Field + Tti apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ObservatoryPageTestMobileReport) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r observatoryPageTestMobileReportJSON) RawJSON() string { + return r.raw +} + +// The type of device. +type ObservatoryPageTestMobileReportDeviceType string + +const ( + ObservatoryPageTestMobileReportDeviceTypeDesktop ObservatoryPageTestMobileReportDeviceType = "DESKTOP" + ObservatoryPageTestMobileReportDeviceTypeMobile ObservatoryPageTestMobileReportDeviceType = "MOBILE" +) + +type ObservatoryPageTestMobileReportError struct { + // The error code of the Lighthouse result. + Code ObservatoryPageTestMobileReportErrorCode `json:"code"` + // Detailed error message. + Detail string `json:"detail"` + // The final URL displayed to the user. + FinalDisplayedURL string `json:"finalDisplayedUrl"` + JSON observatoryPageTestMobileReportErrorJSON `json:"-"` +} + +// observatoryPageTestMobileReportErrorJSON contains the JSON metadata for the +// struct [ObservatoryPageTestMobileReportError] +type observatoryPageTestMobileReportErrorJSON struct { + Code apijson.Field + Detail apijson.Field + FinalDisplayedURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ObservatoryPageTestMobileReportError) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r observatoryPageTestMobileReportErrorJSON) RawJSON() string { + return r.raw +} + +// The error code of the Lighthouse result. +type ObservatoryPageTestMobileReportErrorCode string + +const ( + ObservatoryPageTestMobileReportErrorCodeNotReachable ObservatoryPageTestMobileReportErrorCode = "NOT_REACHABLE" + ObservatoryPageTestMobileReportErrorCodeDNSFailure ObservatoryPageTestMobileReportErrorCode = "DNS_FAILURE" + ObservatoryPageTestMobileReportErrorCodeNotHTML ObservatoryPageTestMobileReportErrorCode = "NOT_HTML" + ObservatoryPageTestMobileReportErrorCodeLighthouseTimeout ObservatoryPageTestMobileReportErrorCode = "LIGHTHOUSE_TIMEOUT" + ObservatoryPageTestMobileReportErrorCodeUnknown ObservatoryPageTestMobileReportErrorCode = "UNKNOWN" +) + +// The state of the Lighthouse report. +type ObservatoryPageTestMobileReportState string + +const ( + ObservatoryPageTestMobileReportStateRunning ObservatoryPageTestMobileReportState = "RUNNING" + ObservatoryPageTestMobileReportStateComplete ObservatoryPageTestMobileReportState = "COMPLETE" + ObservatoryPageTestMobileReportStateFailed ObservatoryPageTestMobileReportState = "FAILED" +) + +// A test region with a label. +type ObservatoryPageTestRegion struct { + Label string `json:"label"` + // A test region. + Value ObservatoryPageTestRegionValue `json:"value"` + JSON observatoryPageTestRegionJSON `json:"-"` +} + +// observatoryPageTestRegionJSON contains the JSON metadata for the struct +// [ObservatoryPageTestRegion] +type observatoryPageTestRegionJSON struct { + Label apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ObservatoryPageTestRegion) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r observatoryPageTestRegionJSON) RawJSON() string { + return r.raw +} + +// A test region. +type ObservatoryPageTestRegionValue string + +const ( + ObservatoryPageTestRegionValueAsiaEast1 ObservatoryPageTestRegionValue = "asia-east1" + ObservatoryPageTestRegionValueAsiaNortheast1 ObservatoryPageTestRegionValue = "asia-northeast1" + ObservatoryPageTestRegionValueAsiaNortheast2 ObservatoryPageTestRegionValue = "asia-northeast2" + ObservatoryPageTestRegionValueAsiaSouth1 ObservatoryPageTestRegionValue = "asia-south1" + ObservatoryPageTestRegionValueAsiaSoutheast1 ObservatoryPageTestRegionValue = "asia-southeast1" + ObservatoryPageTestRegionValueAustraliaSoutheast1 ObservatoryPageTestRegionValue = "australia-southeast1" + ObservatoryPageTestRegionValueEuropeNorth1 ObservatoryPageTestRegionValue = "europe-north1" + ObservatoryPageTestRegionValueEuropeSouthwest1 ObservatoryPageTestRegionValue = "europe-southwest1" + ObservatoryPageTestRegionValueEuropeWest1 ObservatoryPageTestRegionValue = "europe-west1" + ObservatoryPageTestRegionValueEuropeWest2 ObservatoryPageTestRegionValue = "europe-west2" + ObservatoryPageTestRegionValueEuropeWest3 ObservatoryPageTestRegionValue = "europe-west3" + ObservatoryPageTestRegionValueEuropeWest4 ObservatoryPageTestRegionValue = "europe-west4" + ObservatoryPageTestRegionValueEuropeWest8 ObservatoryPageTestRegionValue = "europe-west8" + ObservatoryPageTestRegionValueEuropeWest9 ObservatoryPageTestRegionValue = "europe-west9" + ObservatoryPageTestRegionValueMeWest1 ObservatoryPageTestRegionValue = "me-west1" + ObservatoryPageTestRegionValueSouthamericaEast1 ObservatoryPageTestRegionValue = "southamerica-east1" + ObservatoryPageTestRegionValueUsCentral1 ObservatoryPageTestRegionValue = "us-central1" + ObservatoryPageTestRegionValueUsEast1 ObservatoryPageTestRegionValue = "us-east1" + ObservatoryPageTestRegionValueUsEast4 ObservatoryPageTestRegionValue = "us-east4" + ObservatoryPageTestRegionValueUsSouth1 ObservatoryPageTestRegionValue = "us-south1" + ObservatoryPageTestRegionValueUsWest1 ObservatoryPageTestRegionValue = "us-west1" +) + +// The frequency of the test. +type ObservatoryPageTestScheduleFrequency string + +const ( + ObservatoryPageTestScheduleFrequencyDaily ObservatoryPageTestScheduleFrequency = "DAILY" + ObservatoryPageTestScheduleFrequencyWeekly ObservatoryPageTestScheduleFrequency = "WEEKLY" +) + +type TestListResponse struct { + Errors []TestListResponseError `json:"errors,required"` + Messages []TestListResponseMessage `json:"messages,required"` + // Whether the API call was successful. + Success bool `json:"success,required"` + ResultInfo TestListResponseResultInfo `json:"result_info"` + JSON testListResponseJSON `json:"-"` +} + +// testListResponseJSON contains the JSON metadata for the struct +// [TestListResponse] +type testListResponseJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + ResultInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TestListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r testListResponseJSON) RawJSON() string { + return r.raw +} + +type TestListResponseError struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON testListResponseErrorJSON `json:"-"` +} + +// testListResponseErrorJSON contains the JSON metadata for the struct +// [TestListResponseError] +type testListResponseErrorJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TestListResponseError) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r testListResponseErrorJSON) RawJSON() string { + return r.raw +} + +type TestListResponseMessage struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON testListResponseMessageJSON `json:"-"` +} + +// testListResponseMessageJSON contains the JSON metadata for the struct +// [TestListResponseMessage] +type testListResponseMessageJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TestListResponseMessage) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r testListResponseMessageJSON) RawJSON() string { + return r.raw +} + +type TestListResponseResultInfo struct { + Count int64 `json:"count"` + Page int64 `json:"page"` + PerPage int64 `json:"per_page"` + TotalCount int64 `json:"total_count"` + JSON testListResponseResultInfoJSON `json:"-"` +} + +// testListResponseResultInfoJSON contains the JSON metadata for the struct +// [TestListResponseResultInfo] +type testListResponseResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TestListResponseResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r testListResponseResultInfoJSON) RawJSON() string { + return r.raw +} + +type TestDeleteResponse struct { + // Number of items affected. + Count float64 `json:"count"` + JSON testDeleteResponseJSON `json:"-"` +} + +// testDeleteResponseJSON contains the JSON metadata for the struct +// [TestDeleteResponse] +type testDeleteResponseJSON struct { + Count apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TestDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r testDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type TestNewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // A test region. + Region param.Field[TestNewParamsRegion] `json:"region"` +} + +func (r TestNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A test region. +type TestNewParamsRegion string + +const ( + TestNewParamsRegionAsiaEast1 TestNewParamsRegion = "asia-east1" + TestNewParamsRegionAsiaNortheast1 TestNewParamsRegion = "asia-northeast1" + TestNewParamsRegionAsiaNortheast2 TestNewParamsRegion = "asia-northeast2" + TestNewParamsRegionAsiaSouth1 TestNewParamsRegion = "asia-south1" + TestNewParamsRegionAsiaSoutheast1 TestNewParamsRegion = "asia-southeast1" + TestNewParamsRegionAustraliaSoutheast1 TestNewParamsRegion = "australia-southeast1" + TestNewParamsRegionEuropeNorth1 TestNewParamsRegion = "europe-north1" + TestNewParamsRegionEuropeSouthwest1 TestNewParamsRegion = "europe-southwest1" + TestNewParamsRegionEuropeWest1 TestNewParamsRegion = "europe-west1" + TestNewParamsRegionEuropeWest2 TestNewParamsRegion = "europe-west2" + TestNewParamsRegionEuropeWest3 TestNewParamsRegion = "europe-west3" + TestNewParamsRegionEuropeWest4 TestNewParamsRegion = "europe-west4" + TestNewParamsRegionEuropeWest8 TestNewParamsRegion = "europe-west8" + TestNewParamsRegionEuropeWest9 TestNewParamsRegion = "europe-west9" + TestNewParamsRegionMeWest1 TestNewParamsRegion = "me-west1" + TestNewParamsRegionSouthamericaEast1 TestNewParamsRegion = "southamerica-east1" + TestNewParamsRegionUsCentral1 TestNewParamsRegion = "us-central1" + TestNewParamsRegionUsEast1 TestNewParamsRegion = "us-east1" + TestNewParamsRegionUsEast4 TestNewParamsRegion = "us-east4" + TestNewParamsRegionUsSouth1 TestNewParamsRegion = "us-south1" + TestNewParamsRegionUsWest1 TestNewParamsRegion = "us-west1" +) + +type TestNewResponseEnvelope struct { + Result ObservatoryPageTest `json:"result"` + JSON testNewResponseEnvelopeJSON `json:"-"` +} + +// testNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [TestNewResponseEnvelope] +type testNewResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TestNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r testNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TestListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Page param.Field[int64] `query:"page"` + PerPage param.Field[int64] `query:"per_page"` + // A test region. + Region param.Field[TestListParamsRegion] `query:"region"` +} + +// URLQuery serializes [TestListParams]'s query parameters as `url.Values`. +func (r TestListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// A test region. +type TestListParamsRegion string + +const ( + TestListParamsRegionAsiaEast1 TestListParamsRegion = "asia-east1" + TestListParamsRegionAsiaNortheast1 TestListParamsRegion = "asia-northeast1" + TestListParamsRegionAsiaNortheast2 TestListParamsRegion = "asia-northeast2" + TestListParamsRegionAsiaSouth1 TestListParamsRegion = "asia-south1" + TestListParamsRegionAsiaSoutheast1 TestListParamsRegion = "asia-southeast1" + TestListParamsRegionAustraliaSoutheast1 TestListParamsRegion = "australia-southeast1" + TestListParamsRegionEuropeNorth1 TestListParamsRegion = "europe-north1" + TestListParamsRegionEuropeSouthwest1 TestListParamsRegion = "europe-southwest1" + TestListParamsRegionEuropeWest1 TestListParamsRegion = "europe-west1" + TestListParamsRegionEuropeWest2 TestListParamsRegion = "europe-west2" + TestListParamsRegionEuropeWest3 TestListParamsRegion = "europe-west3" + TestListParamsRegionEuropeWest4 TestListParamsRegion = "europe-west4" + TestListParamsRegionEuropeWest8 TestListParamsRegion = "europe-west8" + TestListParamsRegionEuropeWest9 TestListParamsRegion = "europe-west9" + TestListParamsRegionMeWest1 TestListParamsRegion = "me-west1" + TestListParamsRegionSouthamericaEast1 TestListParamsRegion = "southamerica-east1" + TestListParamsRegionUsCentral1 TestListParamsRegion = "us-central1" + TestListParamsRegionUsEast1 TestListParamsRegion = "us-east1" + TestListParamsRegionUsEast4 TestListParamsRegion = "us-east4" + TestListParamsRegionUsSouth1 TestListParamsRegion = "us-south1" + TestListParamsRegionUsWest1 TestListParamsRegion = "us-west1" +) + +type TestDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // A test region. + Region param.Field[TestDeleteParamsRegion] `query:"region"` +} + +// URLQuery serializes [TestDeleteParams]'s query parameters as `url.Values`. +func (r TestDeleteParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// A test region. +type TestDeleteParamsRegion string + +const ( + TestDeleteParamsRegionAsiaEast1 TestDeleteParamsRegion = "asia-east1" + TestDeleteParamsRegionAsiaNortheast1 TestDeleteParamsRegion = "asia-northeast1" + TestDeleteParamsRegionAsiaNortheast2 TestDeleteParamsRegion = "asia-northeast2" + TestDeleteParamsRegionAsiaSouth1 TestDeleteParamsRegion = "asia-south1" + TestDeleteParamsRegionAsiaSoutheast1 TestDeleteParamsRegion = "asia-southeast1" + TestDeleteParamsRegionAustraliaSoutheast1 TestDeleteParamsRegion = "australia-southeast1" + TestDeleteParamsRegionEuropeNorth1 TestDeleteParamsRegion = "europe-north1" + TestDeleteParamsRegionEuropeSouthwest1 TestDeleteParamsRegion = "europe-southwest1" + TestDeleteParamsRegionEuropeWest1 TestDeleteParamsRegion = "europe-west1" + TestDeleteParamsRegionEuropeWest2 TestDeleteParamsRegion = "europe-west2" + TestDeleteParamsRegionEuropeWest3 TestDeleteParamsRegion = "europe-west3" + TestDeleteParamsRegionEuropeWest4 TestDeleteParamsRegion = "europe-west4" + TestDeleteParamsRegionEuropeWest8 TestDeleteParamsRegion = "europe-west8" + TestDeleteParamsRegionEuropeWest9 TestDeleteParamsRegion = "europe-west9" + TestDeleteParamsRegionMeWest1 TestDeleteParamsRegion = "me-west1" + TestDeleteParamsRegionSouthamericaEast1 TestDeleteParamsRegion = "southamerica-east1" + TestDeleteParamsRegionUsCentral1 TestDeleteParamsRegion = "us-central1" + TestDeleteParamsRegionUsEast1 TestDeleteParamsRegion = "us-east1" + TestDeleteParamsRegionUsEast4 TestDeleteParamsRegion = "us-east4" + TestDeleteParamsRegionUsSouth1 TestDeleteParamsRegion = "us-south1" + TestDeleteParamsRegionUsWest1 TestDeleteParamsRegion = "us-west1" +) + +type TestDeleteResponseEnvelope struct { + Result TestDeleteResponse `json:"result"` + JSON testDeleteResponseEnvelopeJSON `json:"-"` +} + +// testDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [TestDeleteResponseEnvelope] +type testDeleteResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TestDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r testDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TestGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type TestGetResponseEnvelope struct { + Result ObservatoryPageTest `json:"result"` + JSON testGetResponseEnvelopeJSON `json:"-"` +} + +// testGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [TestGetResponseEnvelope] +type testGetResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TestGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r testGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/speed/test_test.go b/speed/test_test.go new file mode 100644 index 00000000000..1b5683e4f20 --- /dev/null +++ b/speed/test_test.go @@ -0,0 +1,141 @@ +// File generated from our OpenAPI spec by Stainless. + +package speed_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/speed" +) + +func TestTestNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Speed.Tests.New( + context.TODO(), + "example.com", + speed.TestNewParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Region: cloudflare.F(speed.TestNewParamsRegionUsCentral1), + }, + ) + 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 TestTestListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Speed.Tests.List( + context.TODO(), + "example.com", + speed.TestListParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Page: cloudflare.F(int64(1)), + PerPage: cloudflare.F(int64(20)), + Region: cloudflare.F(speed.TestListParamsRegionUsCentral1), + }, + ) + 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 TestTestDeleteWithOptionalParams(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("user@example.com"), + ) + _, err := client.Speed.Tests.Delete( + context.TODO(), + "example.com", + speed.TestDeleteParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Region: cloudflare.F(speed.TestDeleteParamsRegionUsCentral1), + }, + ) + 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 TestTestGet(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("user@example.com"), + ) + _, err := client.Speed.Tests.Get( + context.TODO(), + "example.com", + "string", + speed.TestGetParams{ + ZoneID: cloudflare.F("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/speedavailability.go b/speedavailability.go deleted file mode 100644 index bdaf8767e29..00000000000 --- a/speedavailability.go +++ /dev/null @@ -1,182 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SpeedAvailabilityService 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 [NewSpeedAvailabilityService] method -// instead. -type SpeedAvailabilityService struct { - Options []option.RequestOption -} - -// NewSpeedAvailabilityService 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 NewSpeedAvailabilityService(opts ...option.RequestOption) (r *SpeedAvailabilityService) { - r = &SpeedAvailabilityService{} - r.Options = opts - return -} - -// Retrieves quota for all plans, as well as the current zone quota. -func (r *SpeedAvailabilityService) List(ctx context.Context, query SpeedAvailabilityListParams, opts ...option.RequestOption) (res *SpeedAvailabilityListResponse, err error) { - opts = append(r.Options[:], opts...) - var env SpeedAvailabilityListResponseEnvelope - path := fmt.Sprintf("zones/%s/speed_api/availabilities", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SpeedAvailabilityListResponse struct { - Quota SpeedAvailabilityListResponseQuota `json:"quota"` - Regions []SpeedAvailabilityListResponseRegion `json:"regions"` - RegionsPerPlan interface{} `json:"regionsPerPlan"` - JSON speedAvailabilityListResponseJSON `json:"-"` -} - -// speedAvailabilityListResponseJSON contains the JSON metadata for the struct -// [SpeedAvailabilityListResponse] -type speedAvailabilityListResponseJSON struct { - Quota apijson.Field - Regions apijson.Field - RegionsPerPlan apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedAvailabilityListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedAvailabilityListResponseJSON) RawJSON() string { - return r.raw -} - -type SpeedAvailabilityListResponseQuota struct { - // Cloudflare plan. - Plan string `json:"plan"` - // The number of tests available per plan. - QuotasPerPlan map[string]float64 `json:"quotasPerPlan"` - // The number of remaining schedules available. - RemainingSchedules float64 `json:"remainingSchedules"` - // The number of remaining tests available. - RemainingTests float64 `json:"remainingTests"` - // The number of schedules available per plan. - ScheduleQuotasPerPlan map[string]float64 `json:"scheduleQuotasPerPlan"` - JSON speedAvailabilityListResponseQuotaJSON `json:"-"` -} - -// speedAvailabilityListResponseQuotaJSON contains the JSON metadata for the struct -// [SpeedAvailabilityListResponseQuota] -type speedAvailabilityListResponseQuotaJSON struct { - Plan apijson.Field - QuotasPerPlan apijson.Field - RemainingSchedules apijson.Field - RemainingTests apijson.Field - ScheduleQuotasPerPlan apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedAvailabilityListResponseQuota) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedAvailabilityListResponseQuotaJSON) RawJSON() string { - return r.raw -} - -// A test region with a label. -type SpeedAvailabilityListResponseRegion struct { - Label string `json:"label"` - // A test region. - Value SpeedAvailabilityListResponseRegionsValue `json:"value"` - JSON speedAvailabilityListResponseRegionJSON `json:"-"` -} - -// speedAvailabilityListResponseRegionJSON contains the JSON metadata for the -// struct [SpeedAvailabilityListResponseRegion] -type speedAvailabilityListResponseRegionJSON struct { - Label apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedAvailabilityListResponseRegion) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedAvailabilityListResponseRegionJSON) RawJSON() string { - return r.raw -} - -// A test region. -type SpeedAvailabilityListResponseRegionsValue string - -const ( - SpeedAvailabilityListResponseRegionsValueAsiaEast1 SpeedAvailabilityListResponseRegionsValue = "asia-east1" - SpeedAvailabilityListResponseRegionsValueAsiaNortheast1 SpeedAvailabilityListResponseRegionsValue = "asia-northeast1" - SpeedAvailabilityListResponseRegionsValueAsiaNortheast2 SpeedAvailabilityListResponseRegionsValue = "asia-northeast2" - SpeedAvailabilityListResponseRegionsValueAsiaSouth1 SpeedAvailabilityListResponseRegionsValue = "asia-south1" - SpeedAvailabilityListResponseRegionsValueAsiaSoutheast1 SpeedAvailabilityListResponseRegionsValue = "asia-southeast1" - SpeedAvailabilityListResponseRegionsValueAustraliaSoutheast1 SpeedAvailabilityListResponseRegionsValue = "australia-southeast1" - SpeedAvailabilityListResponseRegionsValueEuropeNorth1 SpeedAvailabilityListResponseRegionsValue = "europe-north1" - SpeedAvailabilityListResponseRegionsValueEuropeSouthwest1 SpeedAvailabilityListResponseRegionsValue = "europe-southwest1" - SpeedAvailabilityListResponseRegionsValueEuropeWest1 SpeedAvailabilityListResponseRegionsValue = "europe-west1" - SpeedAvailabilityListResponseRegionsValueEuropeWest2 SpeedAvailabilityListResponseRegionsValue = "europe-west2" - SpeedAvailabilityListResponseRegionsValueEuropeWest3 SpeedAvailabilityListResponseRegionsValue = "europe-west3" - SpeedAvailabilityListResponseRegionsValueEuropeWest4 SpeedAvailabilityListResponseRegionsValue = "europe-west4" - SpeedAvailabilityListResponseRegionsValueEuropeWest8 SpeedAvailabilityListResponseRegionsValue = "europe-west8" - SpeedAvailabilityListResponseRegionsValueEuropeWest9 SpeedAvailabilityListResponseRegionsValue = "europe-west9" - SpeedAvailabilityListResponseRegionsValueMeWest1 SpeedAvailabilityListResponseRegionsValue = "me-west1" - SpeedAvailabilityListResponseRegionsValueSouthamericaEast1 SpeedAvailabilityListResponseRegionsValue = "southamerica-east1" - SpeedAvailabilityListResponseRegionsValueUsCentral1 SpeedAvailabilityListResponseRegionsValue = "us-central1" - SpeedAvailabilityListResponseRegionsValueUsEast1 SpeedAvailabilityListResponseRegionsValue = "us-east1" - SpeedAvailabilityListResponseRegionsValueUsEast4 SpeedAvailabilityListResponseRegionsValue = "us-east4" - SpeedAvailabilityListResponseRegionsValueUsSouth1 SpeedAvailabilityListResponseRegionsValue = "us-south1" - SpeedAvailabilityListResponseRegionsValueUsWest1 SpeedAvailabilityListResponseRegionsValue = "us-west1" -) - -type SpeedAvailabilityListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type SpeedAvailabilityListResponseEnvelope struct { - Result SpeedAvailabilityListResponse `json:"result"` - JSON speedAvailabilityListResponseEnvelopeJSON `json:"-"` -} - -// speedAvailabilityListResponseEnvelopeJSON contains the JSON metadata for the -// struct [SpeedAvailabilityListResponseEnvelope] -type speedAvailabilityListResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedAvailabilityListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedAvailabilityListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/speedavailability_test.go b/speedavailability_test.go deleted file mode 100644 index 9ec0733db97..00000000000 --- a/speedavailability_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSpeedAvailabilityList(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("user@example.com"), - ) - _, err := client.Speed.Availabilities.List(context.TODO(), cloudflare.SpeedAvailabilityListParams{ - ZoneID: cloudflare.F("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/speedpage.go b/speedpage.go deleted file mode 100644 index 9133ea8c6c5..00000000000 --- a/speedpage.go +++ /dev/null @@ -1,482 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SpeedPageService 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 [NewSpeedPageService] method instead. -type SpeedPageService struct { - Options []option.RequestOption -} - -// NewSpeedPageService 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 NewSpeedPageService(opts ...option.RequestOption) (r *SpeedPageService) { - r = &SpeedPageService{} - r.Options = opts - return -} - -// Lists all webpages which have been tested. -func (r *SpeedPageService) List(ctx context.Context, query SpeedPageListParams, opts ...option.RequestOption) (res *[]SpeedPageListResponse, err error) { - opts = append(r.Options[:], opts...) - var env SpeedPageListResponseEnvelope - path := fmt.Sprintf("zones/%s/speed_api/pages", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SpeedPageListResponse struct { - // A test region with a label. - Region SpeedPageListResponseRegion `json:"region"` - // The frequency of the test. - ScheduleFrequency SpeedPageListResponseScheduleFrequency `json:"scheduleFrequency"` - Tests []SpeedPageListResponseTest `json:"tests"` - // A URL. - URL string `json:"url"` - JSON speedPageListResponseJSON `json:"-"` -} - -// speedPageListResponseJSON contains the JSON metadata for the struct -// [SpeedPageListResponse] -type speedPageListResponseJSON struct { - Region apijson.Field - ScheduleFrequency apijson.Field - Tests apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedPageListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedPageListResponseJSON) RawJSON() string { - return r.raw -} - -// A test region with a label. -type SpeedPageListResponseRegion struct { - Label string `json:"label"` - // A test region. - Value SpeedPageListResponseRegionValue `json:"value"` - JSON speedPageListResponseRegionJSON `json:"-"` -} - -// speedPageListResponseRegionJSON contains the JSON metadata for the struct -// [SpeedPageListResponseRegion] -type speedPageListResponseRegionJSON struct { - Label apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedPageListResponseRegion) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedPageListResponseRegionJSON) RawJSON() string { - return r.raw -} - -// A test region. -type SpeedPageListResponseRegionValue string - -const ( - SpeedPageListResponseRegionValueAsiaEast1 SpeedPageListResponseRegionValue = "asia-east1" - SpeedPageListResponseRegionValueAsiaNortheast1 SpeedPageListResponseRegionValue = "asia-northeast1" - SpeedPageListResponseRegionValueAsiaNortheast2 SpeedPageListResponseRegionValue = "asia-northeast2" - SpeedPageListResponseRegionValueAsiaSouth1 SpeedPageListResponseRegionValue = "asia-south1" - SpeedPageListResponseRegionValueAsiaSoutheast1 SpeedPageListResponseRegionValue = "asia-southeast1" - SpeedPageListResponseRegionValueAustraliaSoutheast1 SpeedPageListResponseRegionValue = "australia-southeast1" - SpeedPageListResponseRegionValueEuropeNorth1 SpeedPageListResponseRegionValue = "europe-north1" - SpeedPageListResponseRegionValueEuropeSouthwest1 SpeedPageListResponseRegionValue = "europe-southwest1" - SpeedPageListResponseRegionValueEuropeWest1 SpeedPageListResponseRegionValue = "europe-west1" - SpeedPageListResponseRegionValueEuropeWest2 SpeedPageListResponseRegionValue = "europe-west2" - SpeedPageListResponseRegionValueEuropeWest3 SpeedPageListResponseRegionValue = "europe-west3" - SpeedPageListResponseRegionValueEuropeWest4 SpeedPageListResponseRegionValue = "europe-west4" - SpeedPageListResponseRegionValueEuropeWest8 SpeedPageListResponseRegionValue = "europe-west8" - SpeedPageListResponseRegionValueEuropeWest9 SpeedPageListResponseRegionValue = "europe-west9" - SpeedPageListResponseRegionValueMeWest1 SpeedPageListResponseRegionValue = "me-west1" - SpeedPageListResponseRegionValueSouthamericaEast1 SpeedPageListResponseRegionValue = "southamerica-east1" - SpeedPageListResponseRegionValueUsCentral1 SpeedPageListResponseRegionValue = "us-central1" - SpeedPageListResponseRegionValueUsEast1 SpeedPageListResponseRegionValue = "us-east1" - SpeedPageListResponseRegionValueUsEast4 SpeedPageListResponseRegionValue = "us-east4" - SpeedPageListResponseRegionValueUsSouth1 SpeedPageListResponseRegionValue = "us-south1" - SpeedPageListResponseRegionValueUsWest1 SpeedPageListResponseRegionValue = "us-west1" -) - -// The frequency of the test. -type SpeedPageListResponseScheduleFrequency string - -const ( - SpeedPageListResponseScheduleFrequencyDaily SpeedPageListResponseScheduleFrequency = "DAILY" - SpeedPageListResponseScheduleFrequencyWeekly SpeedPageListResponseScheduleFrequency = "WEEKLY" -) - -type SpeedPageListResponseTest struct { - // UUID - ID string `json:"id"` - Date time.Time `json:"date" format:"date-time"` - // The Lighthouse report. - DesktopReport SpeedPageListResponseTestsDesktopReport `json:"desktopReport"` - // The Lighthouse report. - MobileReport SpeedPageListResponseTestsMobileReport `json:"mobileReport"` - // A test region with a label. - Region SpeedPageListResponseTestsRegion `json:"region"` - // The frequency of the test. - ScheduleFrequency SpeedPageListResponseTestsScheduleFrequency `json:"scheduleFrequency"` - // A URL. - URL string `json:"url"` - JSON speedPageListResponseTestJSON `json:"-"` -} - -// speedPageListResponseTestJSON contains the JSON metadata for the struct -// [SpeedPageListResponseTest] -type speedPageListResponseTestJSON struct { - ID apijson.Field - Date apijson.Field - DesktopReport apijson.Field - MobileReport apijson.Field - Region apijson.Field - ScheduleFrequency apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedPageListResponseTest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedPageListResponseTestJSON) RawJSON() string { - return r.raw -} - -// The Lighthouse report. -type SpeedPageListResponseTestsDesktopReport struct { - // Cumulative Layout Shift. - Cls float64 `json:"cls"` - // The type of device. - DeviceType SpeedPageListResponseTestsDesktopReportDeviceType `json:"deviceType"` - Error SpeedPageListResponseTestsDesktopReportError `json:"error"` - // First Contentful Paint. - Fcp float64 `json:"fcp"` - // The URL to the full Lighthouse JSON report. - JsonReportURL string `json:"jsonReportUrl"` - // Largest Contentful Paint. - Lcp float64 `json:"lcp"` - // The Lighthouse performance score. - PerformanceScore float64 `json:"performanceScore"` - // Speed Index. - Si float64 `json:"si"` - // The state of the Lighthouse report. - State SpeedPageListResponseTestsDesktopReportState `json:"state"` - // Total Blocking Time. - Tbt float64 `json:"tbt"` - // Time To First Byte. - Ttfb float64 `json:"ttfb"` - // Time To Interactive. - Tti float64 `json:"tti"` - JSON speedPageListResponseTestsDesktopReportJSON `json:"-"` -} - -// speedPageListResponseTestsDesktopReportJSON contains the JSON metadata for the -// struct [SpeedPageListResponseTestsDesktopReport] -type speedPageListResponseTestsDesktopReportJSON struct { - Cls apijson.Field - DeviceType apijson.Field - Error apijson.Field - Fcp apijson.Field - JsonReportURL apijson.Field - Lcp apijson.Field - PerformanceScore apijson.Field - Si apijson.Field - State apijson.Field - Tbt apijson.Field - Ttfb apijson.Field - Tti apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedPageListResponseTestsDesktopReport) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedPageListResponseTestsDesktopReportJSON) RawJSON() string { - return r.raw -} - -// The type of device. -type SpeedPageListResponseTestsDesktopReportDeviceType string - -const ( - SpeedPageListResponseTestsDesktopReportDeviceTypeDesktop SpeedPageListResponseTestsDesktopReportDeviceType = "DESKTOP" - SpeedPageListResponseTestsDesktopReportDeviceTypeMobile SpeedPageListResponseTestsDesktopReportDeviceType = "MOBILE" -) - -type SpeedPageListResponseTestsDesktopReportError struct { - // The error code of the Lighthouse result. - Code SpeedPageListResponseTestsDesktopReportErrorCode `json:"code"` - // Detailed error message. - Detail string `json:"detail"` - // The final URL displayed to the user. - FinalDisplayedURL string `json:"finalDisplayedUrl"` - JSON speedPageListResponseTestsDesktopReportErrorJSON `json:"-"` -} - -// speedPageListResponseTestsDesktopReportErrorJSON contains the JSON metadata for -// the struct [SpeedPageListResponseTestsDesktopReportError] -type speedPageListResponseTestsDesktopReportErrorJSON struct { - Code apijson.Field - Detail apijson.Field - FinalDisplayedURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedPageListResponseTestsDesktopReportError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedPageListResponseTestsDesktopReportErrorJSON) RawJSON() string { - return r.raw -} - -// The error code of the Lighthouse result. -type SpeedPageListResponseTestsDesktopReportErrorCode string - -const ( - SpeedPageListResponseTestsDesktopReportErrorCodeNotReachable SpeedPageListResponseTestsDesktopReportErrorCode = "NOT_REACHABLE" - SpeedPageListResponseTestsDesktopReportErrorCodeDNSFailure SpeedPageListResponseTestsDesktopReportErrorCode = "DNS_FAILURE" - SpeedPageListResponseTestsDesktopReportErrorCodeNotHTML SpeedPageListResponseTestsDesktopReportErrorCode = "NOT_HTML" - SpeedPageListResponseTestsDesktopReportErrorCodeLighthouseTimeout SpeedPageListResponseTestsDesktopReportErrorCode = "LIGHTHOUSE_TIMEOUT" - SpeedPageListResponseTestsDesktopReportErrorCodeUnknown SpeedPageListResponseTestsDesktopReportErrorCode = "UNKNOWN" -) - -// The state of the Lighthouse report. -type SpeedPageListResponseTestsDesktopReportState string - -const ( - SpeedPageListResponseTestsDesktopReportStateRunning SpeedPageListResponseTestsDesktopReportState = "RUNNING" - SpeedPageListResponseTestsDesktopReportStateComplete SpeedPageListResponseTestsDesktopReportState = "COMPLETE" - SpeedPageListResponseTestsDesktopReportStateFailed SpeedPageListResponseTestsDesktopReportState = "FAILED" -) - -// The Lighthouse report. -type SpeedPageListResponseTestsMobileReport struct { - // Cumulative Layout Shift. - Cls float64 `json:"cls"` - // The type of device. - DeviceType SpeedPageListResponseTestsMobileReportDeviceType `json:"deviceType"` - Error SpeedPageListResponseTestsMobileReportError `json:"error"` - // First Contentful Paint. - Fcp float64 `json:"fcp"` - // The URL to the full Lighthouse JSON report. - JsonReportURL string `json:"jsonReportUrl"` - // Largest Contentful Paint. - Lcp float64 `json:"lcp"` - // The Lighthouse performance score. - PerformanceScore float64 `json:"performanceScore"` - // Speed Index. - Si float64 `json:"si"` - // The state of the Lighthouse report. - State SpeedPageListResponseTestsMobileReportState `json:"state"` - // Total Blocking Time. - Tbt float64 `json:"tbt"` - // Time To First Byte. - Ttfb float64 `json:"ttfb"` - // Time To Interactive. - Tti float64 `json:"tti"` - JSON speedPageListResponseTestsMobileReportJSON `json:"-"` -} - -// speedPageListResponseTestsMobileReportJSON contains the JSON metadata for the -// struct [SpeedPageListResponseTestsMobileReport] -type speedPageListResponseTestsMobileReportJSON struct { - Cls apijson.Field - DeviceType apijson.Field - Error apijson.Field - Fcp apijson.Field - JsonReportURL apijson.Field - Lcp apijson.Field - PerformanceScore apijson.Field - Si apijson.Field - State apijson.Field - Tbt apijson.Field - Ttfb apijson.Field - Tti apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedPageListResponseTestsMobileReport) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedPageListResponseTestsMobileReportJSON) RawJSON() string { - return r.raw -} - -// The type of device. -type SpeedPageListResponseTestsMobileReportDeviceType string - -const ( - SpeedPageListResponseTestsMobileReportDeviceTypeDesktop SpeedPageListResponseTestsMobileReportDeviceType = "DESKTOP" - SpeedPageListResponseTestsMobileReportDeviceTypeMobile SpeedPageListResponseTestsMobileReportDeviceType = "MOBILE" -) - -type SpeedPageListResponseTestsMobileReportError struct { - // The error code of the Lighthouse result. - Code SpeedPageListResponseTestsMobileReportErrorCode `json:"code"` - // Detailed error message. - Detail string `json:"detail"` - // The final URL displayed to the user. - FinalDisplayedURL string `json:"finalDisplayedUrl"` - JSON speedPageListResponseTestsMobileReportErrorJSON `json:"-"` -} - -// speedPageListResponseTestsMobileReportErrorJSON contains the JSON metadata for -// the struct [SpeedPageListResponseTestsMobileReportError] -type speedPageListResponseTestsMobileReportErrorJSON struct { - Code apijson.Field - Detail apijson.Field - FinalDisplayedURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedPageListResponseTestsMobileReportError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedPageListResponseTestsMobileReportErrorJSON) RawJSON() string { - return r.raw -} - -// The error code of the Lighthouse result. -type SpeedPageListResponseTestsMobileReportErrorCode string - -const ( - SpeedPageListResponseTestsMobileReportErrorCodeNotReachable SpeedPageListResponseTestsMobileReportErrorCode = "NOT_REACHABLE" - SpeedPageListResponseTestsMobileReportErrorCodeDNSFailure SpeedPageListResponseTestsMobileReportErrorCode = "DNS_FAILURE" - SpeedPageListResponseTestsMobileReportErrorCodeNotHTML SpeedPageListResponseTestsMobileReportErrorCode = "NOT_HTML" - SpeedPageListResponseTestsMobileReportErrorCodeLighthouseTimeout SpeedPageListResponseTestsMobileReportErrorCode = "LIGHTHOUSE_TIMEOUT" - SpeedPageListResponseTestsMobileReportErrorCodeUnknown SpeedPageListResponseTestsMobileReportErrorCode = "UNKNOWN" -) - -// The state of the Lighthouse report. -type SpeedPageListResponseTestsMobileReportState string - -const ( - SpeedPageListResponseTestsMobileReportStateRunning SpeedPageListResponseTestsMobileReportState = "RUNNING" - SpeedPageListResponseTestsMobileReportStateComplete SpeedPageListResponseTestsMobileReportState = "COMPLETE" - SpeedPageListResponseTestsMobileReportStateFailed SpeedPageListResponseTestsMobileReportState = "FAILED" -) - -// A test region with a label. -type SpeedPageListResponseTestsRegion struct { - Label string `json:"label"` - // A test region. - Value SpeedPageListResponseTestsRegionValue `json:"value"` - JSON speedPageListResponseTestsRegionJSON `json:"-"` -} - -// speedPageListResponseTestsRegionJSON contains the JSON metadata for the struct -// [SpeedPageListResponseTestsRegion] -type speedPageListResponseTestsRegionJSON struct { - Label apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedPageListResponseTestsRegion) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedPageListResponseTestsRegionJSON) RawJSON() string { - return r.raw -} - -// A test region. -type SpeedPageListResponseTestsRegionValue string - -const ( - SpeedPageListResponseTestsRegionValueAsiaEast1 SpeedPageListResponseTestsRegionValue = "asia-east1" - SpeedPageListResponseTestsRegionValueAsiaNortheast1 SpeedPageListResponseTestsRegionValue = "asia-northeast1" - SpeedPageListResponseTestsRegionValueAsiaNortheast2 SpeedPageListResponseTestsRegionValue = "asia-northeast2" - SpeedPageListResponseTestsRegionValueAsiaSouth1 SpeedPageListResponseTestsRegionValue = "asia-south1" - SpeedPageListResponseTestsRegionValueAsiaSoutheast1 SpeedPageListResponseTestsRegionValue = "asia-southeast1" - SpeedPageListResponseTestsRegionValueAustraliaSoutheast1 SpeedPageListResponseTestsRegionValue = "australia-southeast1" - SpeedPageListResponseTestsRegionValueEuropeNorth1 SpeedPageListResponseTestsRegionValue = "europe-north1" - SpeedPageListResponseTestsRegionValueEuropeSouthwest1 SpeedPageListResponseTestsRegionValue = "europe-southwest1" - SpeedPageListResponseTestsRegionValueEuropeWest1 SpeedPageListResponseTestsRegionValue = "europe-west1" - SpeedPageListResponseTestsRegionValueEuropeWest2 SpeedPageListResponseTestsRegionValue = "europe-west2" - SpeedPageListResponseTestsRegionValueEuropeWest3 SpeedPageListResponseTestsRegionValue = "europe-west3" - SpeedPageListResponseTestsRegionValueEuropeWest4 SpeedPageListResponseTestsRegionValue = "europe-west4" - SpeedPageListResponseTestsRegionValueEuropeWest8 SpeedPageListResponseTestsRegionValue = "europe-west8" - SpeedPageListResponseTestsRegionValueEuropeWest9 SpeedPageListResponseTestsRegionValue = "europe-west9" - SpeedPageListResponseTestsRegionValueMeWest1 SpeedPageListResponseTestsRegionValue = "me-west1" - SpeedPageListResponseTestsRegionValueSouthamericaEast1 SpeedPageListResponseTestsRegionValue = "southamerica-east1" - SpeedPageListResponseTestsRegionValueUsCentral1 SpeedPageListResponseTestsRegionValue = "us-central1" - SpeedPageListResponseTestsRegionValueUsEast1 SpeedPageListResponseTestsRegionValue = "us-east1" - SpeedPageListResponseTestsRegionValueUsEast4 SpeedPageListResponseTestsRegionValue = "us-east4" - SpeedPageListResponseTestsRegionValueUsSouth1 SpeedPageListResponseTestsRegionValue = "us-south1" - SpeedPageListResponseTestsRegionValueUsWest1 SpeedPageListResponseTestsRegionValue = "us-west1" -) - -// The frequency of the test. -type SpeedPageListResponseTestsScheduleFrequency string - -const ( - SpeedPageListResponseTestsScheduleFrequencyDaily SpeedPageListResponseTestsScheduleFrequency = "DAILY" - SpeedPageListResponseTestsScheduleFrequencyWeekly SpeedPageListResponseTestsScheduleFrequency = "WEEKLY" -) - -type SpeedPageListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type SpeedPageListResponseEnvelope struct { - Result []SpeedPageListResponse `json:"result"` - JSON speedPageListResponseEnvelopeJSON `json:"-"` -} - -// speedPageListResponseEnvelopeJSON contains the JSON metadata for the struct -// [SpeedPageListResponseEnvelope] -type speedPageListResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedPageListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedPageListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/speedpage_test.go b/speedpage_test.go deleted file mode 100644 index e3a6f4385ed..00000000000 --- a/speedpage_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSpeedPageList(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("user@example.com"), - ) - _, err := client.Speed.Pages.List(context.TODO(), cloudflare.SpeedPageListParams{ - ZoneID: cloudflare.F("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/speedschedule.go b/speedschedule.go deleted file mode 100644 index 2925367b264..00000000000 --- a/speedschedule.go +++ /dev/null @@ -1,520 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SpeedScheduleService 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 [NewSpeedScheduleService] method -// instead. -type SpeedScheduleService struct { - Options []option.RequestOption -} - -// NewSpeedScheduleService 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 NewSpeedScheduleService(opts ...option.RequestOption) (r *SpeedScheduleService) { - r = &SpeedScheduleService{} - r.Options = opts - return -} - -// Creates a scheduled test for a page. -func (r *SpeedScheduleService) New(ctx context.Context, url string, params SpeedScheduleNewParams, opts ...option.RequestOption) (res *SpeedScheduleNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env SpeedScheduleNewResponseEnvelope - path := fmt.Sprintf("zones/%s/speed_api/schedule/%s", params.ZoneID, url) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SpeedScheduleNewResponse struct { - // The test schedule. - Schedule SpeedScheduleNewResponseSchedule `json:"schedule"` - Test SpeedScheduleNewResponseTest `json:"test"` - JSON speedScheduleNewResponseJSON `json:"-"` -} - -// speedScheduleNewResponseJSON contains the JSON metadata for the struct -// [SpeedScheduleNewResponse] -type speedScheduleNewResponseJSON struct { - Schedule apijson.Field - Test apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedScheduleNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedScheduleNewResponseJSON) RawJSON() string { - return r.raw -} - -// The test schedule. -type SpeedScheduleNewResponseSchedule struct { - // The frequency of the test. - Frequency SpeedScheduleNewResponseScheduleFrequency `json:"frequency"` - // A test region. - Region SpeedScheduleNewResponseScheduleRegion `json:"region"` - // A URL. - URL string `json:"url"` - JSON speedScheduleNewResponseScheduleJSON `json:"-"` -} - -// speedScheduleNewResponseScheduleJSON contains the JSON metadata for the struct -// [SpeedScheduleNewResponseSchedule] -type speedScheduleNewResponseScheduleJSON struct { - Frequency apijson.Field - Region apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedScheduleNewResponseSchedule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedScheduleNewResponseScheduleJSON) RawJSON() string { - return r.raw -} - -// The frequency of the test. -type SpeedScheduleNewResponseScheduleFrequency string - -const ( - SpeedScheduleNewResponseScheduleFrequencyDaily SpeedScheduleNewResponseScheduleFrequency = "DAILY" - SpeedScheduleNewResponseScheduleFrequencyWeekly SpeedScheduleNewResponseScheduleFrequency = "WEEKLY" -) - -// A test region. -type SpeedScheduleNewResponseScheduleRegion string - -const ( - SpeedScheduleNewResponseScheduleRegionAsiaEast1 SpeedScheduleNewResponseScheduleRegion = "asia-east1" - SpeedScheduleNewResponseScheduleRegionAsiaNortheast1 SpeedScheduleNewResponseScheduleRegion = "asia-northeast1" - SpeedScheduleNewResponseScheduleRegionAsiaNortheast2 SpeedScheduleNewResponseScheduleRegion = "asia-northeast2" - SpeedScheduleNewResponseScheduleRegionAsiaSouth1 SpeedScheduleNewResponseScheduleRegion = "asia-south1" - SpeedScheduleNewResponseScheduleRegionAsiaSoutheast1 SpeedScheduleNewResponseScheduleRegion = "asia-southeast1" - SpeedScheduleNewResponseScheduleRegionAustraliaSoutheast1 SpeedScheduleNewResponseScheduleRegion = "australia-southeast1" - SpeedScheduleNewResponseScheduleRegionEuropeNorth1 SpeedScheduleNewResponseScheduleRegion = "europe-north1" - SpeedScheduleNewResponseScheduleRegionEuropeSouthwest1 SpeedScheduleNewResponseScheduleRegion = "europe-southwest1" - SpeedScheduleNewResponseScheduleRegionEuropeWest1 SpeedScheduleNewResponseScheduleRegion = "europe-west1" - SpeedScheduleNewResponseScheduleRegionEuropeWest2 SpeedScheduleNewResponseScheduleRegion = "europe-west2" - SpeedScheduleNewResponseScheduleRegionEuropeWest3 SpeedScheduleNewResponseScheduleRegion = "europe-west3" - SpeedScheduleNewResponseScheduleRegionEuropeWest4 SpeedScheduleNewResponseScheduleRegion = "europe-west4" - SpeedScheduleNewResponseScheduleRegionEuropeWest8 SpeedScheduleNewResponseScheduleRegion = "europe-west8" - SpeedScheduleNewResponseScheduleRegionEuropeWest9 SpeedScheduleNewResponseScheduleRegion = "europe-west9" - SpeedScheduleNewResponseScheduleRegionMeWest1 SpeedScheduleNewResponseScheduleRegion = "me-west1" - SpeedScheduleNewResponseScheduleRegionSouthamericaEast1 SpeedScheduleNewResponseScheduleRegion = "southamerica-east1" - SpeedScheduleNewResponseScheduleRegionUsCentral1 SpeedScheduleNewResponseScheduleRegion = "us-central1" - SpeedScheduleNewResponseScheduleRegionUsEast1 SpeedScheduleNewResponseScheduleRegion = "us-east1" - SpeedScheduleNewResponseScheduleRegionUsEast4 SpeedScheduleNewResponseScheduleRegion = "us-east4" - SpeedScheduleNewResponseScheduleRegionUsSouth1 SpeedScheduleNewResponseScheduleRegion = "us-south1" - SpeedScheduleNewResponseScheduleRegionUsWest1 SpeedScheduleNewResponseScheduleRegion = "us-west1" -) - -type SpeedScheduleNewResponseTest struct { - // UUID - ID string `json:"id"` - Date time.Time `json:"date" format:"date-time"` - // The Lighthouse report. - DesktopReport SpeedScheduleNewResponseTestDesktopReport `json:"desktopReport"` - // The Lighthouse report. - MobileReport SpeedScheduleNewResponseTestMobileReport `json:"mobileReport"` - // A test region with a label. - Region SpeedScheduleNewResponseTestRegion `json:"region"` - // The frequency of the test. - ScheduleFrequency SpeedScheduleNewResponseTestScheduleFrequency `json:"scheduleFrequency"` - // A URL. - URL string `json:"url"` - JSON speedScheduleNewResponseTestJSON `json:"-"` -} - -// speedScheduleNewResponseTestJSON contains the JSON metadata for the struct -// [SpeedScheduleNewResponseTest] -type speedScheduleNewResponseTestJSON struct { - ID apijson.Field - Date apijson.Field - DesktopReport apijson.Field - MobileReport apijson.Field - Region apijson.Field - ScheduleFrequency apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedScheduleNewResponseTest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedScheduleNewResponseTestJSON) RawJSON() string { - return r.raw -} - -// The Lighthouse report. -type SpeedScheduleNewResponseTestDesktopReport struct { - // Cumulative Layout Shift. - Cls float64 `json:"cls"` - // The type of device. - DeviceType SpeedScheduleNewResponseTestDesktopReportDeviceType `json:"deviceType"` - Error SpeedScheduleNewResponseTestDesktopReportError `json:"error"` - // First Contentful Paint. - Fcp float64 `json:"fcp"` - // The URL to the full Lighthouse JSON report. - JsonReportURL string `json:"jsonReportUrl"` - // Largest Contentful Paint. - Lcp float64 `json:"lcp"` - // The Lighthouse performance score. - PerformanceScore float64 `json:"performanceScore"` - // Speed Index. - Si float64 `json:"si"` - // The state of the Lighthouse report. - State SpeedScheduleNewResponseTestDesktopReportState `json:"state"` - // Total Blocking Time. - Tbt float64 `json:"tbt"` - // Time To First Byte. - Ttfb float64 `json:"ttfb"` - // Time To Interactive. - Tti float64 `json:"tti"` - JSON speedScheduleNewResponseTestDesktopReportJSON `json:"-"` -} - -// speedScheduleNewResponseTestDesktopReportJSON contains the JSON metadata for the -// struct [SpeedScheduleNewResponseTestDesktopReport] -type speedScheduleNewResponseTestDesktopReportJSON struct { - Cls apijson.Field - DeviceType apijson.Field - Error apijson.Field - Fcp apijson.Field - JsonReportURL apijson.Field - Lcp apijson.Field - PerformanceScore apijson.Field - Si apijson.Field - State apijson.Field - Tbt apijson.Field - Ttfb apijson.Field - Tti apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedScheduleNewResponseTestDesktopReport) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedScheduleNewResponseTestDesktopReportJSON) RawJSON() string { - return r.raw -} - -// The type of device. -type SpeedScheduleNewResponseTestDesktopReportDeviceType string - -const ( - SpeedScheduleNewResponseTestDesktopReportDeviceTypeDesktop SpeedScheduleNewResponseTestDesktopReportDeviceType = "DESKTOP" - SpeedScheduleNewResponseTestDesktopReportDeviceTypeMobile SpeedScheduleNewResponseTestDesktopReportDeviceType = "MOBILE" -) - -type SpeedScheduleNewResponseTestDesktopReportError struct { - // The error code of the Lighthouse result. - Code SpeedScheduleNewResponseTestDesktopReportErrorCode `json:"code"` - // Detailed error message. - Detail string `json:"detail"` - // The final URL displayed to the user. - FinalDisplayedURL string `json:"finalDisplayedUrl"` - JSON speedScheduleNewResponseTestDesktopReportErrorJSON `json:"-"` -} - -// speedScheduleNewResponseTestDesktopReportErrorJSON contains the JSON metadata -// for the struct [SpeedScheduleNewResponseTestDesktopReportError] -type speedScheduleNewResponseTestDesktopReportErrorJSON struct { - Code apijson.Field - Detail apijson.Field - FinalDisplayedURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedScheduleNewResponseTestDesktopReportError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedScheduleNewResponseTestDesktopReportErrorJSON) RawJSON() string { - return r.raw -} - -// The error code of the Lighthouse result. -type SpeedScheduleNewResponseTestDesktopReportErrorCode string - -const ( - SpeedScheduleNewResponseTestDesktopReportErrorCodeNotReachable SpeedScheduleNewResponseTestDesktopReportErrorCode = "NOT_REACHABLE" - SpeedScheduleNewResponseTestDesktopReportErrorCodeDNSFailure SpeedScheduleNewResponseTestDesktopReportErrorCode = "DNS_FAILURE" - SpeedScheduleNewResponseTestDesktopReportErrorCodeNotHTML SpeedScheduleNewResponseTestDesktopReportErrorCode = "NOT_HTML" - SpeedScheduleNewResponseTestDesktopReportErrorCodeLighthouseTimeout SpeedScheduleNewResponseTestDesktopReportErrorCode = "LIGHTHOUSE_TIMEOUT" - SpeedScheduleNewResponseTestDesktopReportErrorCodeUnknown SpeedScheduleNewResponseTestDesktopReportErrorCode = "UNKNOWN" -) - -// The state of the Lighthouse report. -type SpeedScheduleNewResponseTestDesktopReportState string - -const ( - SpeedScheduleNewResponseTestDesktopReportStateRunning SpeedScheduleNewResponseTestDesktopReportState = "RUNNING" - SpeedScheduleNewResponseTestDesktopReportStateComplete SpeedScheduleNewResponseTestDesktopReportState = "COMPLETE" - SpeedScheduleNewResponseTestDesktopReportStateFailed SpeedScheduleNewResponseTestDesktopReportState = "FAILED" -) - -// The Lighthouse report. -type SpeedScheduleNewResponseTestMobileReport struct { - // Cumulative Layout Shift. - Cls float64 `json:"cls"` - // The type of device. - DeviceType SpeedScheduleNewResponseTestMobileReportDeviceType `json:"deviceType"` - Error SpeedScheduleNewResponseTestMobileReportError `json:"error"` - // First Contentful Paint. - Fcp float64 `json:"fcp"` - // The URL to the full Lighthouse JSON report. - JsonReportURL string `json:"jsonReportUrl"` - // Largest Contentful Paint. - Lcp float64 `json:"lcp"` - // The Lighthouse performance score. - PerformanceScore float64 `json:"performanceScore"` - // Speed Index. - Si float64 `json:"si"` - // The state of the Lighthouse report. - State SpeedScheduleNewResponseTestMobileReportState `json:"state"` - // Total Blocking Time. - Tbt float64 `json:"tbt"` - // Time To First Byte. - Ttfb float64 `json:"ttfb"` - // Time To Interactive. - Tti float64 `json:"tti"` - JSON speedScheduleNewResponseTestMobileReportJSON `json:"-"` -} - -// speedScheduleNewResponseTestMobileReportJSON contains the JSON metadata for the -// struct [SpeedScheduleNewResponseTestMobileReport] -type speedScheduleNewResponseTestMobileReportJSON struct { - Cls apijson.Field - DeviceType apijson.Field - Error apijson.Field - Fcp apijson.Field - JsonReportURL apijson.Field - Lcp apijson.Field - PerformanceScore apijson.Field - Si apijson.Field - State apijson.Field - Tbt apijson.Field - Ttfb apijson.Field - Tti apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedScheduleNewResponseTestMobileReport) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedScheduleNewResponseTestMobileReportJSON) RawJSON() string { - return r.raw -} - -// The type of device. -type SpeedScheduleNewResponseTestMobileReportDeviceType string - -const ( - SpeedScheduleNewResponseTestMobileReportDeviceTypeDesktop SpeedScheduleNewResponseTestMobileReportDeviceType = "DESKTOP" - SpeedScheduleNewResponseTestMobileReportDeviceTypeMobile SpeedScheduleNewResponseTestMobileReportDeviceType = "MOBILE" -) - -type SpeedScheduleNewResponseTestMobileReportError struct { - // The error code of the Lighthouse result. - Code SpeedScheduleNewResponseTestMobileReportErrorCode `json:"code"` - // Detailed error message. - Detail string `json:"detail"` - // The final URL displayed to the user. - FinalDisplayedURL string `json:"finalDisplayedUrl"` - JSON speedScheduleNewResponseTestMobileReportErrorJSON `json:"-"` -} - -// speedScheduleNewResponseTestMobileReportErrorJSON contains the JSON metadata for -// the struct [SpeedScheduleNewResponseTestMobileReportError] -type speedScheduleNewResponseTestMobileReportErrorJSON struct { - Code apijson.Field - Detail apijson.Field - FinalDisplayedURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedScheduleNewResponseTestMobileReportError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedScheduleNewResponseTestMobileReportErrorJSON) RawJSON() string { - return r.raw -} - -// The error code of the Lighthouse result. -type SpeedScheduleNewResponseTestMobileReportErrorCode string - -const ( - SpeedScheduleNewResponseTestMobileReportErrorCodeNotReachable SpeedScheduleNewResponseTestMobileReportErrorCode = "NOT_REACHABLE" - SpeedScheduleNewResponseTestMobileReportErrorCodeDNSFailure SpeedScheduleNewResponseTestMobileReportErrorCode = "DNS_FAILURE" - SpeedScheduleNewResponseTestMobileReportErrorCodeNotHTML SpeedScheduleNewResponseTestMobileReportErrorCode = "NOT_HTML" - SpeedScheduleNewResponseTestMobileReportErrorCodeLighthouseTimeout SpeedScheduleNewResponseTestMobileReportErrorCode = "LIGHTHOUSE_TIMEOUT" - SpeedScheduleNewResponseTestMobileReportErrorCodeUnknown SpeedScheduleNewResponseTestMobileReportErrorCode = "UNKNOWN" -) - -// The state of the Lighthouse report. -type SpeedScheduleNewResponseTestMobileReportState string - -const ( - SpeedScheduleNewResponseTestMobileReportStateRunning SpeedScheduleNewResponseTestMobileReportState = "RUNNING" - SpeedScheduleNewResponseTestMobileReportStateComplete SpeedScheduleNewResponseTestMobileReportState = "COMPLETE" - SpeedScheduleNewResponseTestMobileReportStateFailed SpeedScheduleNewResponseTestMobileReportState = "FAILED" -) - -// A test region with a label. -type SpeedScheduleNewResponseTestRegion struct { - Label string `json:"label"` - // A test region. - Value SpeedScheduleNewResponseTestRegionValue `json:"value"` - JSON speedScheduleNewResponseTestRegionJSON `json:"-"` -} - -// speedScheduleNewResponseTestRegionJSON contains the JSON metadata for the struct -// [SpeedScheduleNewResponseTestRegion] -type speedScheduleNewResponseTestRegionJSON struct { - Label apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedScheduleNewResponseTestRegion) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedScheduleNewResponseTestRegionJSON) RawJSON() string { - return r.raw -} - -// A test region. -type SpeedScheduleNewResponseTestRegionValue string - -const ( - SpeedScheduleNewResponseTestRegionValueAsiaEast1 SpeedScheduleNewResponseTestRegionValue = "asia-east1" - SpeedScheduleNewResponseTestRegionValueAsiaNortheast1 SpeedScheduleNewResponseTestRegionValue = "asia-northeast1" - SpeedScheduleNewResponseTestRegionValueAsiaNortheast2 SpeedScheduleNewResponseTestRegionValue = "asia-northeast2" - SpeedScheduleNewResponseTestRegionValueAsiaSouth1 SpeedScheduleNewResponseTestRegionValue = "asia-south1" - SpeedScheduleNewResponseTestRegionValueAsiaSoutheast1 SpeedScheduleNewResponseTestRegionValue = "asia-southeast1" - SpeedScheduleNewResponseTestRegionValueAustraliaSoutheast1 SpeedScheduleNewResponseTestRegionValue = "australia-southeast1" - SpeedScheduleNewResponseTestRegionValueEuropeNorth1 SpeedScheduleNewResponseTestRegionValue = "europe-north1" - SpeedScheduleNewResponseTestRegionValueEuropeSouthwest1 SpeedScheduleNewResponseTestRegionValue = "europe-southwest1" - SpeedScheduleNewResponseTestRegionValueEuropeWest1 SpeedScheduleNewResponseTestRegionValue = "europe-west1" - SpeedScheduleNewResponseTestRegionValueEuropeWest2 SpeedScheduleNewResponseTestRegionValue = "europe-west2" - SpeedScheduleNewResponseTestRegionValueEuropeWest3 SpeedScheduleNewResponseTestRegionValue = "europe-west3" - SpeedScheduleNewResponseTestRegionValueEuropeWest4 SpeedScheduleNewResponseTestRegionValue = "europe-west4" - SpeedScheduleNewResponseTestRegionValueEuropeWest8 SpeedScheduleNewResponseTestRegionValue = "europe-west8" - SpeedScheduleNewResponseTestRegionValueEuropeWest9 SpeedScheduleNewResponseTestRegionValue = "europe-west9" - SpeedScheduleNewResponseTestRegionValueMeWest1 SpeedScheduleNewResponseTestRegionValue = "me-west1" - SpeedScheduleNewResponseTestRegionValueSouthamericaEast1 SpeedScheduleNewResponseTestRegionValue = "southamerica-east1" - SpeedScheduleNewResponseTestRegionValueUsCentral1 SpeedScheduleNewResponseTestRegionValue = "us-central1" - SpeedScheduleNewResponseTestRegionValueUsEast1 SpeedScheduleNewResponseTestRegionValue = "us-east1" - SpeedScheduleNewResponseTestRegionValueUsEast4 SpeedScheduleNewResponseTestRegionValue = "us-east4" - SpeedScheduleNewResponseTestRegionValueUsSouth1 SpeedScheduleNewResponseTestRegionValue = "us-south1" - SpeedScheduleNewResponseTestRegionValueUsWest1 SpeedScheduleNewResponseTestRegionValue = "us-west1" -) - -// The frequency of the test. -type SpeedScheduleNewResponseTestScheduleFrequency string - -const ( - SpeedScheduleNewResponseTestScheduleFrequencyDaily SpeedScheduleNewResponseTestScheduleFrequency = "DAILY" - SpeedScheduleNewResponseTestScheduleFrequencyWeekly SpeedScheduleNewResponseTestScheduleFrequency = "WEEKLY" -) - -type SpeedScheduleNewParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // A test region. - Region param.Field[SpeedScheduleNewParamsRegion] `query:"region"` -} - -// URLQuery serializes [SpeedScheduleNewParams]'s query parameters as `url.Values`. -func (r SpeedScheduleNewParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// A test region. -type SpeedScheduleNewParamsRegion string - -const ( - SpeedScheduleNewParamsRegionAsiaEast1 SpeedScheduleNewParamsRegion = "asia-east1" - SpeedScheduleNewParamsRegionAsiaNortheast1 SpeedScheduleNewParamsRegion = "asia-northeast1" - SpeedScheduleNewParamsRegionAsiaNortheast2 SpeedScheduleNewParamsRegion = "asia-northeast2" - SpeedScheduleNewParamsRegionAsiaSouth1 SpeedScheduleNewParamsRegion = "asia-south1" - SpeedScheduleNewParamsRegionAsiaSoutheast1 SpeedScheduleNewParamsRegion = "asia-southeast1" - SpeedScheduleNewParamsRegionAustraliaSoutheast1 SpeedScheduleNewParamsRegion = "australia-southeast1" - SpeedScheduleNewParamsRegionEuropeNorth1 SpeedScheduleNewParamsRegion = "europe-north1" - SpeedScheduleNewParamsRegionEuropeSouthwest1 SpeedScheduleNewParamsRegion = "europe-southwest1" - SpeedScheduleNewParamsRegionEuropeWest1 SpeedScheduleNewParamsRegion = "europe-west1" - SpeedScheduleNewParamsRegionEuropeWest2 SpeedScheduleNewParamsRegion = "europe-west2" - SpeedScheduleNewParamsRegionEuropeWest3 SpeedScheduleNewParamsRegion = "europe-west3" - SpeedScheduleNewParamsRegionEuropeWest4 SpeedScheduleNewParamsRegion = "europe-west4" - SpeedScheduleNewParamsRegionEuropeWest8 SpeedScheduleNewParamsRegion = "europe-west8" - SpeedScheduleNewParamsRegionEuropeWest9 SpeedScheduleNewParamsRegion = "europe-west9" - SpeedScheduleNewParamsRegionMeWest1 SpeedScheduleNewParamsRegion = "me-west1" - SpeedScheduleNewParamsRegionSouthamericaEast1 SpeedScheduleNewParamsRegion = "southamerica-east1" - SpeedScheduleNewParamsRegionUsCentral1 SpeedScheduleNewParamsRegion = "us-central1" - SpeedScheduleNewParamsRegionUsEast1 SpeedScheduleNewParamsRegion = "us-east1" - SpeedScheduleNewParamsRegionUsEast4 SpeedScheduleNewParamsRegion = "us-east4" - SpeedScheduleNewParamsRegionUsSouth1 SpeedScheduleNewParamsRegion = "us-south1" - SpeedScheduleNewParamsRegionUsWest1 SpeedScheduleNewParamsRegion = "us-west1" -) - -type SpeedScheduleNewResponseEnvelope struct { - Result SpeedScheduleNewResponse `json:"result"` - JSON speedScheduleNewResponseEnvelopeJSON `json:"-"` -} - -// speedScheduleNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [SpeedScheduleNewResponseEnvelope] -type speedScheduleNewResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedScheduleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedScheduleNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/speedschedule_test.go b/speedschedule_test.go deleted file mode 100644 index 3fb8955b6ec..00000000000 --- a/speedschedule_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSpeedScheduleNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Speed.Schedule.New( - context.TODO(), - "example.com", - cloudflare.SpeedScheduleNewParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Region: cloudflare.F(cloudflare.SpeedScheduleNewParamsRegionUsCentral1), - }, - ) - 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/speedtest.go b/speedtest.go deleted file mode 100644 index 7a9663b114f..00000000000 --- a/speedtest.go +++ /dev/null @@ -1,1039 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SpeedTestService 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 [NewSpeedTestService] method instead. -type SpeedTestService struct { - Options []option.RequestOption -} - -// NewSpeedTestService 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 NewSpeedTestService(opts ...option.RequestOption) (r *SpeedTestService) { - r = &SpeedTestService{} - r.Options = opts - return -} - -// Starts a test for a specific webpage, in a specific region. -func (r *SpeedTestService) New(ctx context.Context, url string, params SpeedTestNewParams, opts ...option.RequestOption) (res *SpeedTestNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env SpeedTestNewResponseEnvelope - path := fmt.Sprintf("zones/%s/speed_api/pages/%s/tests", params.ZoneID, url) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Test history (list of tests) for a specific webpage. -func (r *SpeedTestService) List(ctx context.Context, url string, params SpeedTestListParams, opts ...option.RequestOption) (res *SpeedTestListResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("zones/%s/speed_api/pages/%s/tests", params.ZoneID, url) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &res, opts...) - return -} - -// Deletes all tests for a specific webpage from a specific region. Deleted tests -// are still counted as part of the quota. -func (r *SpeedTestService) Delete(ctx context.Context, url string, params SpeedTestDeleteParams, opts ...option.RequestOption) (res *SpeedTestDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env SpeedTestDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/speed_api/pages/%s/tests", params.ZoneID, url) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Retrieves the result of a specific test. -func (r *SpeedTestService) Get(ctx context.Context, url string, testID string, query SpeedTestGetParams, opts ...option.RequestOption) (res *SpeedTestGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env SpeedTestGetResponseEnvelope - path := fmt.Sprintf("zones/%s/speed_api/pages/%s/tests/%s", query.ZoneID, url, testID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SpeedTestNewResponse struct { - // UUID - ID string `json:"id"` - Date time.Time `json:"date" format:"date-time"` - // The Lighthouse report. - DesktopReport SpeedTestNewResponseDesktopReport `json:"desktopReport"` - // The Lighthouse report. - MobileReport SpeedTestNewResponseMobileReport `json:"mobileReport"` - // A test region with a label. - Region SpeedTestNewResponseRegion `json:"region"` - // The frequency of the test. - ScheduleFrequency SpeedTestNewResponseScheduleFrequency `json:"scheduleFrequency"` - // A URL. - URL string `json:"url"` - JSON speedTestNewResponseJSON `json:"-"` -} - -// speedTestNewResponseJSON contains the JSON metadata for the struct -// [SpeedTestNewResponse] -type speedTestNewResponseJSON struct { - ID apijson.Field - Date apijson.Field - DesktopReport apijson.Field - MobileReport apijson.Field - Region apijson.Field - ScheduleFrequency apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestNewResponseJSON) RawJSON() string { - return r.raw -} - -// The Lighthouse report. -type SpeedTestNewResponseDesktopReport struct { - // Cumulative Layout Shift. - Cls float64 `json:"cls"` - // The type of device. - DeviceType SpeedTestNewResponseDesktopReportDeviceType `json:"deviceType"` - Error SpeedTestNewResponseDesktopReportError `json:"error"` - // First Contentful Paint. - Fcp float64 `json:"fcp"` - // The URL to the full Lighthouse JSON report. - JsonReportURL string `json:"jsonReportUrl"` - // Largest Contentful Paint. - Lcp float64 `json:"lcp"` - // The Lighthouse performance score. - PerformanceScore float64 `json:"performanceScore"` - // Speed Index. - Si float64 `json:"si"` - // The state of the Lighthouse report. - State SpeedTestNewResponseDesktopReportState `json:"state"` - // Total Blocking Time. - Tbt float64 `json:"tbt"` - // Time To First Byte. - Ttfb float64 `json:"ttfb"` - // Time To Interactive. - Tti float64 `json:"tti"` - JSON speedTestNewResponseDesktopReportJSON `json:"-"` -} - -// speedTestNewResponseDesktopReportJSON contains the JSON metadata for the struct -// [SpeedTestNewResponseDesktopReport] -type speedTestNewResponseDesktopReportJSON struct { - Cls apijson.Field - DeviceType apijson.Field - Error apijson.Field - Fcp apijson.Field - JsonReportURL apijson.Field - Lcp apijson.Field - PerformanceScore apijson.Field - Si apijson.Field - State apijson.Field - Tbt apijson.Field - Ttfb apijson.Field - Tti apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestNewResponseDesktopReport) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestNewResponseDesktopReportJSON) RawJSON() string { - return r.raw -} - -// The type of device. -type SpeedTestNewResponseDesktopReportDeviceType string - -const ( - SpeedTestNewResponseDesktopReportDeviceTypeDesktop SpeedTestNewResponseDesktopReportDeviceType = "DESKTOP" - SpeedTestNewResponseDesktopReportDeviceTypeMobile SpeedTestNewResponseDesktopReportDeviceType = "MOBILE" -) - -type SpeedTestNewResponseDesktopReportError struct { - // The error code of the Lighthouse result. - Code SpeedTestNewResponseDesktopReportErrorCode `json:"code"` - // Detailed error message. - Detail string `json:"detail"` - // The final URL displayed to the user. - FinalDisplayedURL string `json:"finalDisplayedUrl"` - JSON speedTestNewResponseDesktopReportErrorJSON `json:"-"` -} - -// speedTestNewResponseDesktopReportErrorJSON contains the JSON metadata for the -// struct [SpeedTestNewResponseDesktopReportError] -type speedTestNewResponseDesktopReportErrorJSON struct { - Code apijson.Field - Detail apijson.Field - FinalDisplayedURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestNewResponseDesktopReportError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestNewResponseDesktopReportErrorJSON) RawJSON() string { - return r.raw -} - -// The error code of the Lighthouse result. -type SpeedTestNewResponseDesktopReportErrorCode string - -const ( - SpeedTestNewResponseDesktopReportErrorCodeNotReachable SpeedTestNewResponseDesktopReportErrorCode = "NOT_REACHABLE" - SpeedTestNewResponseDesktopReportErrorCodeDNSFailure SpeedTestNewResponseDesktopReportErrorCode = "DNS_FAILURE" - SpeedTestNewResponseDesktopReportErrorCodeNotHTML SpeedTestNewResponseDesktopReportErrorCode = "NOT_HTML" - SpeedTestNewResponseDesktopReportErrorCodeLighthouseTimeout SpeedTestNewResponseDesktopReportErrorCode = "LIGHTHOUSE_TIMEOUT" - SpeedTestNewResponseDesktopReportErrorCodeUnknown SpeedTestNewResponseDesktopReportErrorCode = "UNKNOWN" -) - -// The state of the Lighthouse report. -type SpeedTestNewResponseDesktopReportState string - -const ( - SpeedTestNewResponseDesktopReportStateRunning SpeedTestNewResponseDesktopReportState = "RUNNING" - SpeedTestNewResponseDesktopReportStateComplete SpeedTestNewResponseDesktopReportState = "COMPLETE" - SpeedTestNewResponseDesktopReportStateFailed SpeedTestNewResponseDesktopReportState = "FAILED" -) - -// The Lighthouse report. -type SpeedTestNewResponseMobileReport struct { - // Cumulative Layout Shift. - Cls float64 `json:"cls"` - // The type of device. - DeviceType SpeedTestNewResponseMobileReportDeviceType `json:"deviceType"` - Error SpeedTestNewResponseMobileReportError `json:"error"` - // First Contentful Paint. - Fcp float64 `json:"fcp"` - // The URL to the full Lighthouse JSON report. - JsonReportURL string `json:"jsonReportUrl"` - // Largest Contentful Paint. - Lcp float64 `json:"lcp"` - // The Lighthouse performance score. - PerformanceScore float64 `json:"performanceScore"` - // Speed Index. - Si float64 `json:"si"` - // The state of the Lighthouse report. - State SpeedTestNewResponseMobileReportState `json:"state"` - // Total Blocking Time. - Tbt float64 `json:"tbt"` - // Time To First Byte. - Ttfb float64 `json:"ttfb"` - // Time To Interactive. - Tti float64 `json:"tti"` - JSON speedTestNewResponseMobileReportJSON `json:"-"` -} - -// speedTestNewResponseMobileReportJSON contains the JSON metadata for the struct -// [SpeedTestNewResponseMobileReport] -type speedTestNewResponseMobileReportJSON struct { - Cls apijson.Field - DeviceType apijson.Field - Error apijson.Field - Fcp apijson.Field - JsonReportURL apijson.Field - Lcp apijson.Field - PerformanceScore apijson.Field - Si apijson.Field - State apijson.Field - Tbt apijson.Field - Ttfb apijson.Field - Tti apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestNewResponseMobileReport) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestNewResponseMobileReportJSON) RawJSON() string { - return r.raw -} - -// The type of device. -type SpeedTestNewResponseMobileReportDeviceType string - -const ( - SpeedTestNewResponseMobileReportDeviceTypeDesktop SpeedTestNewResponseMobileReportDeviceType = "DESKTOP" - SpeedTestNewResponseMobileReportDeviceTypeMobile SpeedTestNewResponseMobileReportDeviceType = "MOBILE" -) - -type SpeedTestNewResponseMobileReportError struct { - // The error code of the Lighthouse result. - Code SpeedTestNewResponseMobileReportErrorCode `json:"code"` - // Detailed error message. - Detail string `json:"detail"` - // The final URL displayed to the user. - FinalDisplayedURL string `json:"finalDisplayedUrl"` - JSON speedTestNewResponseMobileReportErrorJSON `json:"-"` -} - -// speedTestNewResponseMobileReportErrorJSON contains the JSON metadata for the -// struct [SpeedTestNewResponseMobileReportError] -type speedTestNewResponseMobileReportErrorJSON struct { - Code apijson.Field - Detail apijson.Field - FinalDisplayedURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestNewResponseMobileReportError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestNewResponseMobileReportErrorJSON) RawJSON() string { - return r.raw -} - -// The error code of the Lighthouse result. -type SpeedTestNewResponseMobileReportErrorCode string - -const ( - SpeedTestNewResponseMobileReportErrorCodeNotReachable SpeedTestNewResponseMobileReportErrorCode = "NOT_REACHABLE" - SpeedTestNewResponseMobileReportErrorCodeDNSFailure SpeedTestNewResponseMobileReportErrorCode = "DNS_FAILURE" - SpeedTestNewResponseMobileReportErrorCodeNotHTML SpeedTestNewResponseMobileReportErrorCode = "NOT_HTML" - SpeedTestNewResponseMobileReportErrorCodeLighthouseTimeout SpeedTestNewResponseMobileReportErrorCode = "LIGHTHOUSE_TIMEOUT" - SpeedTestNewResponseMobileReportErrorCodeUnknown SpeedTestNewResponseMobileReportErrorCode = "UNKNOWN" -) - -// The state of the Lighthouse report. -type SpeedTestNewResponseMobileReportState string - -const ( - SpeedTestNewResponseMobileReportStateRunning SpeedTestNewResponseMobileReportState = "RUNNING" - SpeedTestNewResponseMobileReportStateComplete SpeedTestNewResponseMobileReportState = "COMPLETE" - SpeedTestNewResponseMobileReportStateFailed SpeedTestNewResponseMobileReportState = "FAILED" -) - -// A test region with a label. -type SpeedTestNewResponseRegion struct { - Label string `json:"label"` - // A test region. - Value SpeedTestNewResponseRegionValue `json:"value"` - JSON speedTestNewResponseRegionJSON `json:"-"` -} - -// speedTestNewResponseRegionJSON contains the JSON metadata for the struct -// [SpeedTestNewResponseRegion] -type speedTestNewResponseRegionJSON struct { - Label apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestNewResponseRegion) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestNewResponseRegionJSON) RawJSON() string { - return r.raw -} - -// A test region. -type SpeedTestNewResponseRegionValue string - -const ( - SpeedTestNewResponseRegionValueAsiaEast1 SpeedTestNewResponseRegionValue = "asia-east1" - SpeedTestNewResponseRegionValueAsiaNortheast1 SpeedTestNewResponseRegionValue = "asia-northeast1" - SpeedTestNewResponseRegionValueAsiaNortheast2 SpeedTestNewResponseRegionValue = "asia-northeast2" - SpeedTestNewResponseRegionValueAsiaSouth1 SpeedTestNewResponseRegionValue = "asia-south1" - SpeedTestNewResponseRegionValueAsiaSoutheast1 SpeedTestNewResponseRegionValue = "asia-southeast1" - SpeedTestNewResponseRegionValueAustraliaSoutheast1 SpeedTestNewResponseRegionValue = "australia-southeast1" - SpeedTestNewResponseRegionValueEuropeNorth1 SpeedTestNewResponseRegionValue = "europe-north1" - SpeedTestNewResponseRegionValueEuropeSouthwest1 SpeedTestNewResponseRegionValue = "europe-southwest1" - SpeedTestNewResponseRegionValueEuropeWest1 SpeedTestNewResponseRegionValue = "europe-west1" - SpeedTestNewResponseRegionValueEuropeWest2 SpeedTestNewResponseRegionValue = "europe-west2" - SpeedTestNewResponseRegionValueEuropeWest3 SpeedTestNewResponseRegionValue = "europe-west3" - SpeedTestNewResponseRegionValueEuropeWest4 SpeedTestNewResponseRegionValue = "europe-west4" - SpeedTestNewResponseRegionValueEuropeWest8 SpeedTestNewResponseRegionValue = "europe-west8" - SpeedTestNewResponseRegionValueEuropeWest9 SpeedTestNewResponseRegionValue = "europe-west9" - SpeedTestNewResponseRegionValueMeWest1 SpeedTestNewResponseRegionValue = "me-west1" - SpeedTestNewResponseRegionValueSouthamericaEast1 SpeedTestNewResponseRegionValue = "southamerica-east1" - SpeedTestNewResponseRegionValueUsCentral1 SpeedTestNewResponseRegionValue = "us-central1" - SpeedTestNewResponseRegionValueUsEast1 SpeedTestNewResponseRegionValue = "us-east1" - SpeedTestNewResponseRegionValueUsEast4 SpeedTestNewResponseRegionValue = "us-east4" - SpeedTestNewResponseRegionValueUsSouth1 SpeedTestNewResponseRegionValue = "us-south1" - SpeedTestNewResponseRegionValueUsWest1 SpeedTestNewResponseRegionValue = "us-west1" -) - -// The frequency of the test. -type SpeedTestNewResponseScheduleFrequency string - -const ( - SpeedTestNewResponseScheduleFrequencyDaily SpeedTestNewResponseScheduleFrequency = "DAILY" - SpeedTestNewResponseScheduleFrequencyWeekly SpeedTestNewResponseScheduleFrequency = "WEEKLY" -) - -type SpeedTestListResponse struct { - Errors []SpeedTestListResponseError `json:"errors,required"` - Messages []SpeedTestListResponseMessage `json:"messages,required"` - // Whether the API call was successful. - Success bool `json:"success,required"` - ResultInfo SpeedTestListResponseResultInfo `json:"result_info"` - JSON speedTestListResponseJSON `json:"-"` -} - -// speedTestListResponseJSON contains the JSON metadata for the struct -// [SpeedTestListResponse] -type speedTestListResponseJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - ResultInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestListResponseJSON) RawJSON() string { - return r.raw -} - -type SpeedTestListResponseError struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON speedTestListResponseErrorJSON `json:"-"` -} - -// speedTestListResponseErrorJSON contains the JSON metadata for the struct -// [SpeedTestListResponseError] -type speedTestListResponseErrorJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestListResponseError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestListResponseErrorJSON) RawJSON() string { - return r.raw -} - -type SpeedTestListResponseMessage struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON speedTestListResponseMessageJSON `json:"-"` -} - -// speedTestListResponseMessageJSON contains the JSON metadata for the struct -// [SpeedTestListResponseMessage] -type speedTestListResponseMessageJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestListResponseMessage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestListResponseMessageJSON) RawJSON() string { - return r.raw -} - -type SpeedTestListResponseResultInfo struct { - Count int64 `json:"count"` - Page int64 `json:"page"` - PerPage int64 `json:"per_page"` - TotalCount int64 `json:"total_count"` - JSON speedTestListResponseResultInfoJSON `json:"-"` -} - -// speedTestListResponseResultInfoJSON contains the JSON metadata for the struct -// [SpeedTestListResponseResultInfo] -type speedTestListResponseResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestListResponseResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestListResponseResultInfoJSON) RawJSON() string { - return r.raw -} - -type SpeedTestDeleteResponse struct { - // Number of items affected. - Count float64 `json:"count"` - JSON speedTestDeleteResponseJSON `json:"-"` -} - -// speedTestDeleteResponseJSON contains the JSON metadata for the struct -// [SpeedTestDeleteResponse] -type speedTestDeleteResponseJSON struct { - Count apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type SpeedTestGetResponse struct { - // UUID - ID string `json:"id"` - Date time.Time `json:"date" format:"date-time"` - // The Lighthouse report. - DesktopReport SpeedTestGetResponseDesktopReport `json:"desktopReport"` - // The Lighthouse report. - MobileReport SpeedTestGetResponseMobileReport `json:"mobileReport"` - // A test region with a label. - Region SpeedTestGetResponseRegion `json:"region"` - // The frequency of the test. - ScheduleFrequency SpeedTestGetResponseScheduleFrequency `json:"scheduleFrequency"` - // A URL. - URL string `json:"url"` - JSON speedTestGetResponseJSON `json:"-"` -} - -// speedTestGetResponseJSON contains the JSON metadata for the struct -// [SpeedTestGetResponse] -type speedTestGetResponseJSON struct { - ID apijson.Field - Date apijson.Field - DesktopReport apijson.Field - MobileReport apijson.Field - Region apijson.Field - ScheduleFrequency apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestGetResponseJSON) RawJSON() string { - return r.raw -} - -// The Lighthouse report. -type SpeedTestGetResponseDesktopReport struct { - // Cumulative Layout Shift. - Cls float64 `json:"cls"` - // The type of device. - DeviceType SpeedTestGetResponseDesktopReportDeviceType `json:"deviceType"` - Error SpeedTestGetResponseDesktopReportError `json:"error"` - // First Contentful Paint. - Fcp float64 `json:"fcp"` - // The URL to the full Lighthouse JSON report. - JsonReportURL string `json:"jsonReportUrl"` - // Largest Contentful Paint. - Lcp float64 `json:"lcp"` - // The Lighthouse performance score. - PerformanceScore float64 `json:"performanceScore"` - // Speed Index. - Si float64 `json:"si"` - // The state of the Lighthouse report. - State SpeedTestGetResponseDesktopReportState `json:"state"` - // Total Blocking Time. - Tbt float64 `json:"tbt"` - // Time To First Byte. - Ttfb float64 `json:"ttfb"` - // Time To Interactive. - Tti float64 `json:"tti"` - JSON speedTestGetResponseDesktopReportJSON `json:"-"` -} - -// speedTestGetResponseDesktopReportJSON contains the JSON metadata for the struct -// [SpeedTestGetResponseDesktopReport] -type speedTestGetResponseDesktopReportJSON struct { - Cls apijson.Field - DeviceType apijson.Field - Error apijson.Field - Fcp apijson.Field - JsonReportURL apijson.Field - Lcp apijson.Field - PerformanceScore apijson.Field - Si apijson.Field - State apijson.Field - Tbt apijson.Field - Ttfb apijson.Field - Tti apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestGetResponseDesktopReport) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestGetResponseDesktopReportJSON) RawJSON() string { - return r.raw -} - -// The type of device. -type SpeedTestGetResponseDesktopReportDeviceType string - -const ( - SpeedTestGetResponseDesktopReportDeviceTypeDesktop SpeedTestGetResponseDesktopReportDeviceType = "DESKTOP" - SpeedTestGetResponseDesktopReportDeviceTypeMobile SpeedTestGetResponseDesktopReportDeviceType = "MOBILE" -) - -type SpeedTestGetResponseDesktopReportError struct { - // The error code of the Lighthouse result. - Code SpeedTestGetResponseDesktopReportErrorCode `json:"code"` - // Detailed error message. - Detail string `json:"detail"` - // The final URL displayed to the user. - FinalDisplayedURL string `json:"finalDisplayedUrl"` - JSON speedTestGetResponseDesktopReportErrorJSON `json:"-"` -} - -// speedTestGetResponseDesktopReportErrorJSON contains the JSON metadata for the -// struct [SpeedTestGetResponseDesktopReportError] -type speedTestGetResponseDesktopReportErrorJSON struct { - Code apijson.Field - Detail apijson.Field - FinalDisplayedURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestGetResponseDesktopReportError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestGetResponseDesktopReportErrorJSON) RawJSON() string { - return r.raw -} - -// The error code of the Lighthouse result. -type SpeedTestGetResponseDesktopReportErrorCode string - -const ( - SpeedTestGetResponseDesktopReportErrorCodeNotReachable SpeedTestGetResponseDesktopReportErrorCode = "NOT_REACHABLE" - SpeedTestGetResponseDesktopReportErrorCodeDNSFailure SpeedTestGetResponseDesktopReportErrorCode = "DNS_FAILURE" - SpeedTestGetResponseDesktopReportErrorCodeNotHTML SpeedTestGetResponseDesktopReportErrorCode = "NOT_HTML" - SpeedTestGetResponseDesktopReportErrorCodeLighthouseTimeout SpeedTestGetResponseDesktopReportErrorCode = "LIGHTHOUSE_TIMEOUT" - SpeedTestGetResponseDesktopReportErrorCodeUnknown SpeedTestGetResponseDesktopReportErrorCode = "UNKNOWN" -) - -// The state of the Lighthouse report. -type SpeedTestGetResponseDesktopReportState string - -const ( - SpeedTestGetResponseDesktopReportStateRunning SpeedTestGetResponseDesktopReportState = "RUNNING" - SpeedTestGetResponseDesktopReportStateComplete SpeedTestGetResponseDesktopReportState = "COMPLETE" - SpeedTestGetResponseDesktopReportStateFailed SpeedTestGetResponseDesktopReportState = "FAILED" -) - -// The Lighthouse report. -type SpeedTestGetResponseMobileReport struct { - // Cumulative Layout Shift. - Cls float64 `json:"cls"` - // The type of device. - DeviceType SpeedTestGetResponseMobileReportDeviceType `json:"deviceType"` - Error SpeedTestGetResponseMobileReportError `json:"error"` - // First Contentful Paint. - Fcp float64 `json:"fcp"` - // The URL to the full Lighthouse JSON report. - JsonReportURL string `json:"jsonReportUrl"` - // Largest Contentful Paint. - Lcp float64 `json:"lcp"` - // The Lighthouse performance score. - PerformanceScore float64 `json:"performanceScore"` - // Speed Index. - Si float64 `json:"si"` - // The state of the Lighthouse report. - State SpeedTestGetResponseMobileReportState `json:"state"` - // Total Blocking Time. - Tbt float64 `json:"tbt"` - // Time To First Byte. - Ttfb float64 `json:"ttfb"` - // Time To Interactive. - Tti float64 `json:"tti"` - JSON speedTestGetResponseMobileReportJSON `json:"-"` -} - -// speedTestGetResponseMobileReportJSON contains the JSON metadata for the struct -// [SpeedTestGetResponseMobileReport] -type speedTestGetResponseMobileReportJSON struct { - Cls apijson.Field - DeviceType apijson.Field - Error apijson.Field - Fcp apijson.Field - JsonReportURL apijson.Field - Lcp apijson.Field - PerformanceScore apijson.Field - Si apijson.Field - State apijson.Field - Tbt apijson.Field - Ttfb apijson.Field - Tti apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestGetResponseMobileReport) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestGetResponseMobileReportJSON) RawJSON() string { - return r.raw -} - -// The type of device. -type SpeedTestGetResponseMobileReportDeviceType string - -const ( - SpeedTestGetResponseMobileReportDeviceTypeDesktop SpeedTestGetResponseMobileReportDeviceType = "DESKTOP" - SpeedTestGetResponseMobileReportDeviceTypeMobile SpeedTestGetResponseMobileReportDeviceType = "MOBILE" -) - -type SpeedTestGetResponseMobileReportError struct { - // The error code of the Lighthouse result. - Code SpeedTestGetResponseMobileReportErrorCode `json:"code"` - // Detailed error message. - Detail string `json:"detail"` - // The final URL displayed to the user. - FinalDisplayedURL string `json:"finalDisplayedUrl"` - JSON speedTestGetResponseMobileReportErrorJSON `json:"-"` -} - -// speedTestGetResponseMobileReportErrorJSON contains the JSON metadata for the -// struct [SpeedTestGetResponseMobileReportError] -type speedTestGetResponseMobileReportErrorJSON struct { - Code apijson.Field - Detail apijson.Field - FinalDisplayedURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestGetResponseMobileReportError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestGetResponseMobileReportErrorJSON) RawJSON() string { - return r.raw -} - -// The error code of the Lighthouse result. -type SpeedTestGetResponseMobileReportErrorCode string - -const ( - SpeedTestGetResponseMobileReportErrorCodeNotReachable SpeedTestGetResponseMobileReportErrorCode = "NOT_REACHABLE" - SpeedTestGetResponseMobileReportErrorCodeDNSFailure SpeedTestGetResponseMobileReportErrorCode = "DNS_FAILURE" - SpeedTestGetResponseMobileReportErrorCodeNotHTML SpeedTestGetResponseMobileReportErrorCode = "NOT_HTML" - SpeedTestGetResponseMobileReportErrorCodeLighthouseTimeout SpeedTestGetResponseMobileReportErrorCode = "LIGHTHOUSE_TIMEOUT" - SpeedTestGetResponseMobileReportErrorCodeUnknown SpeedTestGetResponseMobileReportErrorCode = "UNKNOWN" -) - -// The state of the Lighthouse report. -type SpeedTestGetResponseMobileReportState string - -const ( - SpeedTestGetResponseMobileReportStateRunning SpeedTestGetResponseMobileReportState = "RUNNING" - SpeedTestGetResponseMobileReportStateComplete SpeedTestGetResponseMobileReportState = "COMPLETE" - SpeedTestGetResponseMobileReportStateFailed SpeedTestGetResponseMobileReportState = "FAILED" -) - -// A test region with a label. -type SpeedTestGetResponseRegion struct { - Label string `json:"label"` - // A test region. - Value SpeedTestGetResponseRegionValue `json:"value"` - JSON speedTestGetResponseRegionJSON `json:"-"` -} - -// speedTestGetResponseRegionJSON contains the JSON metadata for the struct -// [SpeedTestGetResponseRegion] -type speedTestGetResponseRegionJSON struct { - Label apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestGetResponseRegion) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestGetResponseRegionJSON) RawJSON() string { - return r.raw -} - -// A test region. -type SpeedTestGetResponseRegionValue string - -const ( - SpeedTestGetResponseRegionValueAsiaEast1 SpeedTestGetResponseRegionValue = "asia-east1" - SpeedTestGetResponseRegionValueAsiaNortheast1 SpeedTestGetResponseRegionValue = "asia-northeast1" - SpeedTestGetResponseRegionValueAsiaNortheast2 SpeedTestGetResponseRegionValue = "asia-northeast2" - SpeedTestGetResponseRegionValueAsiaSouth1 SpeedTestGetResponseRegionValue = "asia-south1" - SpeedTestGetResponseRegionValueAsiaSoutheast1 SpeedTestGetResponseRegionValue = "asia-southeast1" - SpeedTestGetResponseRegionValueAustraliaSoutheast1 SpeedTestGetResponseRegionValue = "australia-southeast1" - SpeedTestGetResponseRegionValueEuropeNorth1 SpeedTestGetResponseRegionValue = "europe-north1" - SpeedTestGetResponseRegionValueEuropeSouthwest1 SpeedTestGetResponseRegionValue = "europe-southwest1" - SpeedTestGetResponseRegionValueEuropeWest1 SpeedTestGetResponseRegionValue = "europe-west1" - SpeedTestGetResponseRegionValueEuropeWest2 SpeedTestGetResponseRegionValue = "europe-west2" - SpeedTestGetResponseRegionValueEuropeWest3 SpeedTestGetResponseRegionValue = "europe-west3" - SpeedTestGetResponseRegionValueEuropeWest4 SpeedTestGetResponseRegionValue = "europe-west4" - SpeedTestGetResponseRegionValueEuropeWest8 SpeedTestGetResponseRegionValue = "europe-west8" - SpeedTestGetResponseRegionValueEuropeWest9 SpeedTestGetResponseRegionValue = "europe-west9" - SpeedTestGetResponseRegionValueMeWest1 SpeedTestGetResponseRegionValue = "me-west1" - SpeedTestGetResponseRegionValueSouthamericaEast1 SpeedTestGetResponseRegionValue = "southamerica-east1" - SpeedTestGetResponseRegionValueUsCentral1 SpeedTestGetResponseRegionValue = "us-central1" - SpeedTestGetResponseRegionValueUsEast1 SpeedTestGetResponseRegionValue = "us-east1" - SpeedTestGetResponseRegionValueUsEast4 SpeedTestGetResponseRegionValue = "us-east4" - SpeedTestGetResponseRegionValueUsSouth1 SpeedTestGetResponseRegionValue = "us-south1" - SpeedTestGetResponseRegionValueUsWest1 SpeedTestGetResponseRegionValue = "us-west1" -) - -// The frequency of the test. -type SpeedTestGetResponseScheduleFrequency string - -const ( - SpeedTestGetResponseScheduleFrequencyDaily SpeedTestGetResponseScheduleFrequency = "DAILY" - SpeedTestGetResponseScheduleFrequencyWeekly SpeedTestGetResponseScheduleFrequency = "WEEKLY" -) - -type SpeedTestNewParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // A test region. - Region param.Field[SpeedTestNewParamsRegion] `json:"region"` -} - -func (r SpeedTestNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A test region. -type SpeedTestNewParamsRegion string - -const ( - SpeedTestNewParamsRegionAsiaEast1 SpeedTestNewParamsRegion = "asia-east1" - SpeedTestNewParamsRegionAsiaNortheast1 SpeedTestNewParamsRegion = "asia-northeast1" - SpeedTestNewParamsRegionAsiaNortheast2 SpeedTestNewParamsRegion = "asia-northeast2" - SpeedTestNewParamsRegionAsiaSouth1 SpeedTestNewParamsRegion = "asia-south1" - SpeedTestNewParamsRegionAsiaSoutheast1 SpeedTestNewParamsRegion = "asia-southeast1" - SpeedTestNewParamsRegionAustraliaSoutheast1 SpeedTestNewParamsRegion = "australia-southeast1" - SpeedTestNewParamsRegionEuropeNorth1 SpeedTestNewParamsRegion = "europe-north1" - SpeedTestNewParamsRegionEuropeSouthwest1 SpeedTestNewParamsRegion = "europe-southwest1" - SpeedTestNewParamsRegionEuropeWest1 SpeedTestNewParamsRegion = "europe-west1" - SpeedTestNewParamsRegionEuropeWest2 SpeedTestNewParamsRegion = "europe-west2" - SpeedTestNewParamsRegionEuropeWest3 SpeedTestNewParamsRegion = "europe-west3" - SpeedTestNewParamsRegionEuropeWest4 SpeedTestNewParamsRegion = "europe-west4" - SpeedTestNewParamsRegionEuropeWest8 SpeedTestNewParamsRegion = "europe-west8" - SpeedTestNewParamsRegionEuropeWest9 SpeedTestNewParamsRegion = "europe-west9" - SpeedTestNewParamsRegionMeWest1 SpeedTestNewParamsRegion = "me-west1" - SpeedTestNewParamsRegionSouthamericaEast1 SpeedTestNewParamsRegion = "southamerica-east1" - SpeedTestNewParamsRegionUsCentral1 SpeedTestNewParamsRegion = "us-central1" - SpeedTestNewParamsRegionUsEast1 SpeedTestNewParamsRegion = "us-east1" - SpeedTestNewParamsRegionUsEast4 SpeedTestNewParamsRegion = "us-east4" - SpeedTestNewParamsRegionUsSouth1 SpeedTestNewParamsRegion = "us-south1" - SpeedTestNewParamsRegionUsWest1 SpeedTestNewParamsRegion = "us-west1" -) - -type SpeedTestNewResponseEnvelope struct { - Result SpeedTestNewResponse `json:"result"` - JSON speedTestNewResponseEnvelopeJSON `json:"-"` -} - -// speedTestNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [SpeedTestNewResponseEnvelope] -type speedTestNewResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SpeedTestListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Page param.Field[int64] `query:"page"` - PerPage param.Field[int64] `query:"per_page"` - // A test region. - Region param.Field[SpeedTestListParamsRegion] `query:"region"` -} - -// URLQuery serializes [SpeedTestListParams]'s query parameters as `url.Values`. -func (r SpeedTestListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// A test region. -type SpeedTestListParamsRegion string - -const ( - SpeedTestListParamsRegionAsiaEast1 SpeedTestListParamsRegion = "asia-east1" - SpeedTestListParamsRegionAsiaNortheast1 SpeedTestListParamsRegion = "asia-northeast1" - SpeedTestListParamsRegionAsiaNortheast2 SpeedTestListParamsRegion = "asia-northeast2" - SpeedTestListParamsRegionAsiaSouth1 SpeedTestListParamsRegion = "asia-south1" - SpeedTestListParamsRegionAsiaSoutheast1 SpeedTestListParamsRegion = "asia-southeast1" - SpeedTestListParamsRegionAustraliaSoutheast1 SpeedTestListParamsRegion = "australia-southeast1" - SpeedTestListParamsRegionEuropeNorth1 SpeedTestListParamsRegion = "europe-north1" - SpeedTestListParamsRegionEuropeSouthwest1 SpeedTestListParamsRegion = "europe-southwest1" - SpeedTestListParamsRegionEuropeWest1 SpeedTestListParamsRegion = "europe-west1" - SpeedTestListParamsRegionEuropeWest2 SpeedTestListParamsRegion = "europe-west2" - SpeedTestListParamsRegionEuropeWest3 SpeedTestListParamsRegion = "europe-west3" - SpeedTestListParamsRegionEuropeWest4 SpeedTestListParamsRegion = "europe-west4" - SpeedTestListParamsRegionEuropeWest8 SpeedTestListParamsRegion = "europe-west8" - SpeedTestListParamsRegionEuropeWest9 SpeedTestListParamsRegion = "europe-west9" - SpeedTestListParamsRegionMeWest1 SpeedTestListParamsRegion = "me-west1" - SpeedTestListParamsRegionSouthamericaEast1 SpeedTestListParamsRegion = "southamerica-east1" - SpeedTestListParamsRegionUsCentral1 SpeedTestListParamsRegion = "us-central1" - SpeedTestListParamsRegionUsEast1 SpeedTestListParamsRegion = "us-east1" - SpeedTestListParamsRegionUsEast4 SpeedTestListParamsRegion = "us-east4" - SpeedTestListParamsRegionUsSouth1 SpeedTestListParamsRegion = "us-south1" - SpeedTestListParamsRegionUsWest1 SpeedTestListParamsRegion = "us-west1" -) - -type SpeedTestDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // A test region. - Region param.Field[SpeedTestDeleteParamsRegion] `query:"region"` -} - -// URLQuery serializes [SpeedTestDeleteParams]'s query parameters as `url.Values`. -func (r SpeedTestDeleteParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// A test region. -type SpeedTestDeleteParamsRegion string - -const ( - SpeedTestDeleteParamsRegionAsiaEast1 SpeedTestDeleteParamsRegion = "asia-east1" - SpeedTestDeleteParamsRegionAsiaNortheast1 SpeedTestDeleteParamsRegion = "asia-northeast1" - SpeedTestDeleteParamsRegionAsiaNortheast2 SpeedTestDeleteParamsRegion = "asia-northeast2" - SpeedTestDeleteParamsRegionAsiaSouth1 SpeedTestDeleteParamsRegion = "asia-south1" - SpeedTestDeleteParamsRegionAsiaSoutheast1 SpeedTestDeleteParamsRegion = "asia-southeast1" - SpeedTestDeleteParamsRegionAustraliaSoutheast1 SpeedTestDeleteParamsRegion = "australia-southeast1" - SpeedTestDeleteParamsRegionEuropeNorth1 SpeedTestDeleteParamsRegion = "europe-north1" - SpeedTestDeleteParamsRegionEuropeSouthwest1 SpeedTestDeleteParamsRegion = "europe-southwest1" - SpeedTestDeleteParamsRegionEuropeWest1 SpeedTestDeleteParamsRegion = "europe-west1" - SpeedTestDeleteParamsRegionEuropeWest2 SpeedTestDeleteParamsRegion = "europe-west2" - SpeedTestDeleteParamsRegionEuropeWest3 SpeedTestDeleteParamsRegion = "europe-west3" - SpeedTestDeleteParamsRegionEuropeWest4 SpeedTestDeleteParamsRegion = "europe-west4" - SpeedTestDeleteParamsRegionEuropeWest8 SpeedTestDeleteParamsRegion = "europe-west8" - SpeedTestDeleteParamsRegionEuropeWest9 SpeedTestDeleteParamsRegion = "europe-west9" - SpeedTestDeleteParamsRegionMeWest1 SpeedTestDeleteParamsRegion = "me-west1" - SpeedTestDeleteParamsRegionSouthamericaEast1 SpeedTestDeleteParamsRegion = "southamerica-east1" - SpeedTestDeleteParamsRegionUsCentral1 SpeedTestDeleteParamsRegion = "us-central1" - SpeedTestDeleteParamsRegionUsEast1 SpeedTestDeleteParamsRegion = "us-east1" - SpeedTestDeleteParamsRegionUsEast4 SpeedTestDeleteParamsRegion = "us-east4" - SpeedTestDeleteParamsRegionUsSouth1 SpeedTestDeleteParamsRegion = "us-south1" - SpeedTestDeleteParamsRegionUsWest1 SpeedTestDeleteParamsRegion = "us-west1" -) - -type SpeedTestDeleteResponseEnvelope struct { - Result SpeedTestDeleteResponse `json:"result"` - JSON speedTestDeleteResponseEnvelopeJSON `json:"-"` -} - -// speedTestDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [SpeedTestDeleteResponseEnvelope] -type speedTestDeleteResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SpeedTestGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type SpeedTestGetResponseEnvelope struct { - Result SpeedTestGetResponse `json:"result"` - JSON speedTestGetResponseEnvelopeJSON `json:"-"` -} - -// speedTestGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [SpeedTestGetResponseEnvelope] -type speedTestGetResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SpeedTestGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r speedTestGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/speedtest_test.go b/speedtest_test.go deleted file mode 100644 index 45c2a829e22..00000000000 --- a/speedtest_test.go +++ /dev/null @@ -1,140 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSpeedTestNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Speed.Tests.New( - context.TODO(), - "example.com", - cloudflare.SpeedTestNewParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Region: cloudflare.F(cloudflare.SpeedTestNewParamsRegionUsCentral1), - }, - ) - 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 TestSpeedTestListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Speed.Tests.List( - context.TODO(), - "example.com", - cloudflare.SpeedTestListParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Page: cloudflare.F(int64(1)), - PerPage: cloudflare.F(int64(20)), - Region: cloudflare.F(cloudflare.SpeedTestListParamsRegionUsCentral1), - }, - ) - 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 TestSpeedTestDeleteWithOptionalParams(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("user@example.com"), - ) - _, err := client.Speed.Tests.Delete( - context.TODO(), - "example.com", - cloudflare.SpeedTestDeleteParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Region: cloudflare.F(cloudflare.SpeedTestDeleteParamsRegionUsCentral1), - }, - ) - 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 TestSpeedTestGet(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("user@example.com"), - ) - _, err := client.Speed.Tests.Get( - context.TODO(), - "example.com", - "string", - cloudflare.SpeedTestGetParams{ - ZoneID: cloudflare.F("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/ssl.go b/ssl.go deleted file mode 100644 index 15cef97e5b6..00000000000 --- a/ssl.go +++ /dev/null @@ -1,34 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// SSLService 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 [NewSSLService] method instead. -type SSLService struct { - Options []option.RequestOption - Analyze *SSLAnalyzeService - CertificatePacks *SSLCertificatePackService - Recommendations *SSLRecommendationService - Universal *SSLUniversalService - Verification *SSLVerificationService -} - -// NewSSLService 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 NewSSLService(opts ...option.RequestOption) (r *SSLService) { - r = &SSLService{} - r.Options = opts - r.Analyze = NewSSLAnalyzeService(opts...) - r.CertificatePacks = NewSSLCertificatePackService(opts...) - r.Recommendations = NewSSLRecommendationService(opts...) - r.Universal = NewSSLUniversalService(opts...) - r.Verification = NewSSLVerificationService(opts...) - return -} diff --git a/ssl/aliases.go b/ssl/aliases.go new file mode 100644 index 00000000000..93392ba99ac --- /dev/null +++ b/ssl/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package ssl + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/ssl/analyze.go b/ssl/analyze.go new file mode 100644 index 00000000000..c5752d14772 --- /dev/null +++ b/ssl/analyze.go @@ -0,0 +1,173 @@ +// File generated from our OpenAPI spec by Stainless. + +package ssl + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// AnalyzeService 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 [NewAnalyzeService] method instead. +type AnalyzeService struct { + Options []option.RequestOption +} + +// NewAnalyzeService 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 NewAnalyzeService(opts ...option.RequestOption) (r *AnalyzeService) { + r = &AnalyzeService{} + r.Options = opts + return +} + +// Returns the set of hostnames, the signature algorithm, and the expiration date +// of the certificate. +func (r *AnalyzeService) New(ctx context.Context, params AnalyzeNewParams, opts ...option.RequestOption) (res *AnalyzeNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env AnalyzeNewResponseEnvelope + path := fmt.Sprintf("zones/%s/ssl/analyze", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [ssl.AnalyzeNewResponseUnknown] or [shared.UnionString]. +type AnalyzeNewResponse interface { + ImplementsSSLAnalyzeNewResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AnalyzeNewResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type AnalyzeNewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // A ubiquitous bundle has the highest probability of being verified everywhere, + // even by clients using outdated or unusual trust stores. An optimal bundle uses + // the shortest chain and newest intermediates. And the force bundle verifies the + // chain, but does not otherwise modify it. + BundleMethod param.Field[AnalyzeNewParamsBundleMethod] `json:"bundle_method"` + // The zone's SSL certificate or certificate and the intermediate(s). + Certificate param.Field[string] `json:"certificate"` +} + +func (r AnalyzeNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A ubiquitous bundle has the highest probability of being verified everywhere, +// even by clients using outdated or unusual trust stores. An optimal bundle uses +// the shortest chain and newest intermediates. And the force bundle verifies the +// chain, but does not otherwise modify it. +type AnalyzeNewParamsBundleMethod string + +const ( + AnalyzeNewParamsBundleMethodUbiquitous AnalyzeNewParamsBundleMethod = "ubiquitous" + AnalyzeNewParamsBundleMethodOptimal AnalyzeNewParamsBundleMethod = "optimal" + AnalyzeNewParamsBundleMethodForce AnalyzeNewParamsBundleMethod = "force" +) + +type AnalyzeNewResponseEnvelope struct { + Errors []AnalyzeNewResponseEnvelopeErrors `json:"errors,required"` + Messages []AnalyzeNewResponseEnvelopeMessages `json:"messages,required"` + Result AnalyzeNewResponse `json:"result,required"` + // Whether the API call was successful + Success AnalyzeNewResponseEnvelopeSuccess `json:"success,required"` + JSON analyzeNewResponseEnvelopeJSON `json:"-"` +} + +// analyzeNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [AnalyzeNewResponseEnvelope] +type analyzeNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyzeNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyzeNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AnalyzeNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON analyzeNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// analyzeNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [AnalyzeNewResponseEnvelopeErrors] +type analyzeNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyzeNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyzeNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AnalyzeNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON analyzeNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// analyzeNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [AnalyzeNewResponseEnvelopeMessages] +type analyzeNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyzeNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyzeNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AnalyzeNewResponseEnvelopeSuccess bool + +const ( + AnalyzeNewResponseEnvelopeSuccessTrue AnalyzeNewResponseEnvelopeSuccess = true +) diff --git a/ssl/analyze_test.go b/ssl/analyze_test.go new file mode 100644 index 00000000000..abd0a4f7c6b --- /dev/null +++ b/ssl/analyze_test.go @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package ssl_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/ssl" +) + +func TestAnalyzeNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.SSL.Analyze.New(context.TODO(), ssl.AnalyzeNewParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + BundleMethod: cloudflare.F(ssl.AnalyzeNewParamsBundleMethodUbiquitous), + Certificate: cloudflare.F("-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIJAMHAwfXZ5/PWMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\nBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX\naWRnaXRzIFB0eSBMdGQwHhcNMTYwODI0MTY0MzAxWhcNMTYxMTIyMTY0MzAxWjBF\nMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50\nZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\nCgKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmGdtcGbg/1\nCGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKnabIRuGvB\nKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpidtnKX/a+5\n0GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+pyFxIXjbEI\ndZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pEewooaeO2\nizNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABo4GnMIGkMB0GA1UdDgQWBBT/LbE4\n9rWf288N6sJA5BRb6FJIGDB1BgNVHSMEbjBsgBT/LbE49rWf288N6sJA5BRb6FJI\nGKFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNV\nBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAMHAwfXZ5/PWMAwGA1UdEwQF\nMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAHHFwl0tH0quUYZYO0dZYt4R7SJ0pCm2\n2satiyzHl4OnXcHDpekAo7/a09c6Lz6AU83cKy/+x3/djYHXWba7HpEu0dR3ugQP\nMlr4zrhd9xKZ0KZKiYmtJH+ak4OM4L3FbT0owUZPyjLSlhMtJVcoRp5CJsjAMBUG\nSvD8RX+T01wzox/Qb+lnnNnOlaWpqu8eoOenybxKp1a9ULzIVvN/LAcc+14vioFq\n2swRWtmocBAs8QR9n4uvbpiYvS8eYueDCWMM4fvFfBhaDZ3N9IbtySh3SpFdQDhw\nYbjM2rxXiyLGxB4Bol7QTv4zHif7Zt89FReT/NBy4rzaskDJY5L6xmY=\n-----END CERTIFICATE-----\n"), + }) + 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/ssl/certificatepack.go b/ssl/certificatepack.go new file mode 100644 index 00000000000..56132d48bf3 --- /dev/null +++ b/ssl/certificatepack.go @@ -0,0 +1,641 @@ +// File generated from our OpenAPI spec by Stainless. + +package ssl + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// CertificatePackService 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 [NewCertificatePackService] method +// instead. +type CertificatePackService struct { + Options []option.RequestOption + Order *CertificatePackOrderService + Quota *CertificatePackQuotaService +} + +// NewCertificatePackService 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 NewCertificatePackService(opts ...option.RequestOption) (r *CertificatePackService) { + r = &CertificatePackService{} + r.Options = opts + r.Order = NewCertificatePackOrderService(opts...) + r.Quota = NewCertificatePackQuotaService(opts...) + return +} + +// For a given zone, list all active certificate packs. +func (r *CertificatePackService) List(ctx context.Context, params CertificatePackListParams, opts ...option.RequestOption) (res *[]CertificatePackListResponse, err error) { + opts = append(r.Options[:], opts...) + var env CertificatePackListResponseEnvelope + path := fmt.Sprintf("zones/%s/ssl/certificate_packs", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// For a given zone, delete an advanced certificate pack. +func (r *CertificatePackService) Delete(ctx context.Context, certificatePackID string, body CertificatePackDeleteParams, opts ...option.RequestOption) (res *CertificatePackDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env CertificatePackDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/ssl/certificate_packs/%s", body.ZoneID, certificatePackID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// For a given zone, restart validation for an advanced certificate pack. This is +// only a validation operation for a Certificate Pack in a validation_timed_out +// status. +func (r *CertificatePackService) Edit(ctx context.Context, certificatePackID string, body CertificatePackEditParams, opts ...option.RequestOption) (res *CertificatePackEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env CertificatePackEditResponseEnvelope + path := fmt.Sprintf("zones/%s/ssl/certificate_packs/%s", body.ZoneID, certificatePackID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// For a given zone, get a certificate pack. +func (r *CertificatePackService) Get(ctx context.Context, certificatePackID string, query CertificatePackGetParams, opts ...option.RequestOption) (res *CertificatePackGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env CertificatePackGetResponseEnvelope + path := fmt.Sprintf("zones/%s/ssl/certificate_packs/%s", query.ZoneID, certificatePackID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type CertificatePackListResponse = interface{} + +type CertificatePackDeleteResponse struct { + // Identifier + ID string `json:"id"` + JSON certificatePackDeleteResponseJSON `json:"-"` +} + +// certificatePackDeleteResponseJSON contains the JSON metadata for the struct +// [CertificatePackDeleteResponse] +type certificatePackDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type CertificatePackEditResponse struct { + // Identifier + ID string `json:"id"` + // Certificate Authority selected for the order. For information on any certificate + // authority specific details or restrictions + // [see this page for more details.](https://developers.cloudflare.com/ssl/reference/certificate-authorities) + CertificateAuthority CertificatePackEditResponseCertificateAuthority `json:"certificate_authority"` + // Whether or not to add Cloudflare Branding for the order. This will add + // sni.cloudflaressl.com as the Common Name if set true. + CloudflareBranding bool `json:"cloudflare_branding"` + // Comma separated list of valid host names for the certificate packs. Must contain + // the zone apex, may not contain more than 50 hosts, and may not be empty. + Hosts []string `json:"hosts"` + // Status of certificate pack. + Status CertificatePackEditResponseStatus `json:"status"` + // Type of certificate pack. + Type CertificatePackEditResponseType `json:"type"` + // Validation Method selected for the order. + ValidationMethod CertificatePackEditResponseValidationMethod `json:"validation_method"` + // Validity Days selected for the order. + ValidityDays CertificatePackEditResponseValidityDays `json:"validity_days"` + JSON certificatePackEditResponseJSON `json:"-"` +} + +// certificatePackEditResponseJSON contains the JSON metadata for the struct +// [CertificatePackEditResponse] +type certificatePackEditResponseJSON struct { + ID apijson.Field + CertificateAuthority apijson.Field + CloudflareBranding apijson.Field + Hosts apijson.Field + Status apijson.Field + Type apijson.Field + ValidationMethod apijson.Field + ValidityDays apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackEditResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackEditResponseJSON) RawJSON() string { + return r.raw +} + +// Certificate Authority selected for the order. For information on any certificate +// authority specific details or restrictions +// [see this page for more details.](https://developers.cloudflare.com/ssl/reference/certificate-authorities) +type CertificatePackEditResponseCertificateAuthority string + +const ( + CertificatePackEditResponseCertificateAuthorityGoogle CertificatePackEditResponseCertificateAuthority = "google" + CertificatePackEditResponseCertificateAuthorityLetsEncrypt CertificatePackEditResponseCertificateAuthority = "lets_encrypt" +) + +// Status of certificate pack. +type CertificatePackEditResponseStatus string + +const ( + CertificatePackEditResponseStatusInitializing CertificatePackEditResponseStatus = "initializing" + CertificatePackEditResponseStatusPendingValidation CertificatePackEditResponseStatus = "pending_validation" + CertificatePackEditResponseStatusDeleted CertificatePackEditResponseStatus = "deleted" + CertificatePackEditResponseStatusPendingIssuance CertificatePackEditResponseStatus = "pending_issuance" + CertificatePackEditResponseStatusPendingDeployment CertificatePackEditResponseStatus = "pending_deployment" + CertificatePackEditResponseStatusPendingDeletion CertificatePackEditResponseStatus = "pending_deletion" + CertificatePackEditResponseStatusPendingExpiration CertificatePackEditResponseStatus = "pending_expiration" + CertificatePackEditResponseStatusExpired CertificatePackEditResponseStatus = "expired" + CertificatePackEditResponseStatusActive CertificatePackEditResponseStatus = "active" + CertificatePackEditResponseStatusInitializingTimedOut CertificatePackEditResponseStatus = "initializing_timed_out" + CertificatePackEditResponseStatusValidationTimedOut CertificatePackEditResponseStatus = "validation_timed_out" + CertificatePackEditResponseStatusIssuanceTimedOut CertificatePackEditResponseStatus = "issuance_timed_out" + CertificatePackEditResponseStatusDeploymentTimedOut CertificatePackEditResponseStatus = "deployment_timed_out" + CertificatePackEditResponseStatusDeletionTimedOut CertificatePackEditResponseStatus = "deletion_timed_out" + CertificatePackEditResponseStatusPendingCleanup CertificatePackEditResponseStatus = "pending_cleanup" + CertificatePackEditResponseStatusStagingDeployment CertificatePackEditResponseStatus = "staging_deployment" + CertificatePackEditResponseStatusStagingActive CertificatePackEditResponseStatus = "staging_active" + CertificatePackEditResponseStatusDeactivating CertificatePackEditResponseStatus = "deactivating" + CertificatePackEditResponseStatusInactive CertificatePackEditResponseStatus = "inactive" + CertificatePackEditResponseStatusBackupIssued CertificatePackEditResponseStatus = "backup_issued" + CertificatePackEditResponseStatusHoldingDeployment CertificatePackEditResponseStatus = "holding_deployment" +) + +// Type of certificate pack. +type CertificatePackEditResponseType string + +const ( + CertificatePackEditResponseTypeAdvanced CertificatePackEditResponseType = "advanced" +) + +// Validation Method selected for the order. +type CertificatePackEditResponseValidationMethod string + +const ( + CertificatePackEditResponseValidationMethodTXT CertificatePackEditResponseValidationMethod = "txt" + CertificatePackEditResponseValidationMethodHTTP CertificatePackEditResponseValidationMethod = "http" + CertificatePackEditResponseValidationMethodEmail CertificatePackEditResponseValidationMethod = "email" +) + +// Validity Days selected for the order. +type CertificatePackEditResponseValidityDays int64 + +const ( + CertificatePackEditResponseValidityDays14 CertificatePackEditResponseValidityDays = 14 + CertificatePackEditResponseValidityDays30 CertificatePackEditResponseValidityDays = 30 + CertificatePackEditResponseValidityDays90 CertificatePackEditResponseValidityDays = 90 + CertificatePackEditResponseValidityDays365 CertificatePackEditResponseValidityDays = 365 +) + +// Union satisfied by [ssl.CertificatePackGetResponseUnknown] or +// [shared.UnionString]. +type CertificatePackGetResponse interface { + ImplementsSSLCertificatePackGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*CertificatePackGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type CertificatePackListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Include Certificate Packs of all statuses, not just active ones. + Status param.Field[CertificatePackListParamsStatus] `query:"status"` +} + +// URLQuery serializes [CertificatePackListParams]'s query parameters as +// `url.Values`. +func (r CertificatePackListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Include Certificate Packs of all statuses, not just active ones. +type CertificatePackListParamsStatus string + +const ( + CertificatePackListParamsStatusAll CertificatePackListParamsStatus = "all" +) + +type CertificatePackListResponseEnvelope struct { + Errors []CertificatePackListResponseEnvelopeErrors `json:"errors,required"` + Messages []CertificatePackListResponseEnvelopeMessages `json:"messages,required"` + Result []CertificatePackListResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success CertificatePackListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo CertificatePackListResponseEnvelopeResultInfo `json:"result_info"` + JSON certificatePackListResponseEnvelopeJSON `json:"-"` +} + +// certificatePackListResponseEnvelopeJSON contains the JSON metadata for the +// struct [CertificatePackListResponseEnvelope] +type certificatePackListResponseEnvelopeJSON 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 *CertificatePackListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CertificatePackListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON certificatePackListResponseEnvelopeErrorsJSON `json:"-"` +} + +// certificatePackListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [CertificatePackListResponseEnvelopeErrors] +type certificatePackListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CertificatePackListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON certificatePackListResponseEnvelopeMessagesJSON `json:"-"` +} + +// certificatePackListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [CertificatePackListResponseEnvelopeMessages] +type certificatePackListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CertificatePackListResponseEnvelopeSuccess bool + +const ( + CertificatePackListResponseEnvelopeSuccessTrue CertificatePackListResponseEnvelopeSuccess = true +) + +type CertificatePackListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON certificatePackListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// certificatePackListResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [CertificatePackListResponseEnvelopeResultInfo] +type certificatePackListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type CertificatePackDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type CertificatePackDeleteResponseEnvelope struct { + Errors []CertificatePackDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []CertificatePackDeleteResponseEnvelopeMessages `json:"messages,required"` + Result CertificatePackDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success CertificatePackDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON certificatePackDeleteResponseEnvelopeJSON `json:"-"` +} + +// certificatePackDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [CertificatePackDeleteResponseEnvelope] +type certificatePackDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CertificatePackDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON certificatePackDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// certificatePackDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [CertificatePackDeleteResponseEnvelopeErrors] +type certificatePackDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CertificatePackDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON certificatePackDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// certificatePackDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [CertificatePackDeleteResponseEnvelopeMessages] +type certificatePackDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CertificatePackDeleteResponseEnvelopeSuccess bool + +const ( + CertificatePackDeleteResponseEnvelopeSuccessTrue CertificatePackDeleteResponseEnvelopeSuccess = true +) + +type CertificatePackEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type CertificatePackEditResponseEnvelope struct { + Errors []CertificatePackEditResponseEnvelopeErrors `json:"errors,required"` + Messages []CertificatePackEditResponseEnvelopeMessages `json:"messages,required"` + Result CertificatePackEditResponse `json:"result,required"` + // Whether the API call was successful + Success CertificatePackEditResponseEnvelopeSuccess `json:"success,required"` + JSON certificatePackEditResponseEnvelopeJSON `json:"-"` +} + +// certificatePackEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [CertificatePackEditResponseEnvelope] +type certificatePackEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CertificatePackEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON certificatePackEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// certificatePackEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [CertificatePackEditResponseEnvelopeErrors] +type certificatePackEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CertificatePackEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON certificatePackEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// certificatePackEditResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [CertificatePackEditResponseEnvelopeMessages] +type certificatePackEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CertificatePackEditResponseEnvelopeSuccess bool + +const ( + CertificatePackEditResponseEnvelopeSuccessTrue CertificatePackEditResponseEnvelopeSuccess = true +) + +type CertificatePackGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type CertificatePackGetResponseEnvelope struct { + Errors []CertificatePackGetResponseEnvelopeErrors `json:"errors,required"` + Messages []CertificatePackGetResponseEnvelopeMessages `json:"messages,required"` + Result CertificatePackGetResponse `json:"result,required"` + // Whether the API call was successful + Success CertificatePackGetResponseEnvelopeSuccess `json:"success,required"` + JSON certificatePackGetResponseEnvelopeJSON `json:"-"` +} + +// certificatePackGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [CertificatePackGetResponseEnvelope] +type certificatePackGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CertificatePackGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON certificatePackGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// certificatePackGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [CertificatePackGetResponseEnvelopeErrors] +type certificatePackGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CertificatePackGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON certificatePackGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// certificatePackGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [CertificatePackGetResponseEnvelopeMessages] +type certificatePackGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CertificatePackGetResponseEnvelopeSuccess bool + +const ( + CertificatePackGetResponseEnvelopeSuccessTrue CertificatePackGetResponseEnvelopeSuccess = true +) diff --git a/ssl/certificatepack_test.go b/ssl/certificatepack_test.go new file mode 100644 index 00000000000..296485763c8 --- /dev/null +++ b/ssl/certificatepack_test.go @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. + +package ssl_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/ssl" +) + +func TestCertificatePackListWithOptionalParams(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("user@example.com"), + ) + _, err := client.SSL.CertificatePacks.List(context.TODO(), ssl.CertificatePackListParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Status: cloudflare.F(ssl.CertificatePackListParamsStatusAll), + }) + 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 TestCertificatePackDelete(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("user@example.com"), + ) + _, err := client.SSL.CertificatePacks.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + ssl.CertificatePackDeleteParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestCertificatePackEdit(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("user@example.com"), + ) + _, err := client.SSL.CertificatePacks.Edit( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + ssl.CertificatePackEditParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestCertificatePackGet(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("user@example.com"), + ) + _, err := client.SSL.CertificatePacks.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + ssl.CertificatePackGetParams{ + ZoneID: cloudflare.F("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/ssl/certificatepackorder.go b/ssl/certificatepackorder.go new file mode 100644 index 00000000000..fadefd9024a --- /dev/null +++ b/ssl/certificatepackorder.go @@ -0,0 +1,297 @@ +// File generated from our OpenAPI spec by Stainless. + +package ssl + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// CertificatePackOrderService 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 [NewCertificatePackOrderService] +// method instead. +type CertificatePackOrderService struct { + Options []option.RequestOption +} + +// NewCertificatePackOrderService 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 NewCertificatePackOrderService(opts ...option.RequestOption) (r *CertificatePackOrderService) { + r = &CertificatePackOrderService{} + r.Options = opts + return +} + +// For a given zone, order an advanced certificate pack. +func (r *CertificatePackOrderService) New(ctx context.Context, params CertificatePackOrderNewParams, opts ...option.RequestOption) (res *CertificatePackOrderNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env CertificatePackOrderNewResponseEnvelope + path := fmt.Sprintf("zones/%s/ssl/certificate_packs/order", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type CertificatePackOrderNewResponse struct { + // Identifier + ID string `json:"id"` + // Certificate Authority selected for the order. For information on any certificate + // authority specific details or restrictions + // [see this page for more details.](https://developers.cloudflare.com/ssl/reference/certificate-authorities) + CertificateAuthority CertificatePackOrderNewResponseCertificateAuthority `json:"certificate_authority"` + // Whether or not to add Cloudflare Branding for the order. This will add + // sni.cloudflaressl.com as the Common Name if set true. + CloudflareBranding bool `json:"cloudflare_branding"` + // Comma separated list of valid host names for the certificate packs. Must contain + // the zone apex, may not contain more than 50 hosts, and may not be empty. + Hosts []string `json:"hosts"` + // Status of certificate pack. + Status CertificatePackOrderNewResponseStatus `json:"status"` + // Type of certificate pack. + Type CertificatePackOrderNewResponseType `json:"type"` + // Validation Method selected for the order. + ValidationMethod CertificatePackOrderNewResponseValidationMethod `json:"validation_method"` + // Validity Days selected for the order. + ValidityDays CertificatePackOrderNewResponseValidityDays `json:"validity_days"` + JSON certificatePackOrderNewResponseJSON `json:"-"` +} + +// certificatePackOrderNewResponseJSON contains the JSON metadata for the struct +// [CertificatePackOrderNewResponse] +type certificatePackOrderNewResponseJSON struct { + ID apijson.Field + CertificateAuthority apijson.Field + CloudflareBranding apijson.Field + Hosts apijson.Field + Status apijson.Field + Type apijson.Field + ValidationMethod apijson.Field + ValidityDays apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackOrderNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackOrderNewResponseJSON) RawJSON() string { + return r.raw +} + +// Certificate Authority selected for the order. For information on any certificate +// authority specific details or restrictions +// [see this page for more details.](https://developers.cloudflare.com/ssl/reference/certificate-authorities) +type CertificatePackOrderNewResponseCertificateAuthority string + +const ( + CertificatePackOrderNewResponseCertificateAuthorityGoogle CertificatePackOrderNewResponseCertificateAuthority = "google" + CertificatePackOrderNewResponseCertificateAuthorityLetsEncrypt CertificatePackOrderNewResponseCertificateAuthority = "lets_encrypt" +) + +// Status of certificate pack. +type CertificatePackOrderNewResponseStatus string + +const ( + CertificatePackOrderNewResponseStatusInitializing CertificatePackOrderNewResponseStatus = "initializing" + CertificatePackOrderNewResponseStatusPendingValidation CertificatePackOrderNewResponseStatus = "pending_validation" + CertificatePackOrderNewResponseStatusDeleted CertificatePackOrderNewResponseStatus = "deleted" + CertificatePackOrderNewResponseStatusPendingIssuance CertificatePackOrderNewResponseStatus = "pending_issuance" + CertificatePackOrderNewResponseStatusPendingDeployment CertificatePackOrderNewResponseStatus = "pending_deployment" + CertificatePackOrderNewResponseStatusPendingDeletion CertificatePackOrderNewResponseStatus = "pending_deletion" + CertificatePackOrderNewResponseStatusPendingExpiration CertificatePackOrderNewResponseStatus = "pending_expiration" + CertificatePackOrderNewResponseStatusExpired CertificatePackOrderNewResponseStatus = "expired" + CertificatePackOrderNewResponseStatusActive CertificatePackOrderNewResponseStatus = "active" + CertificatePackOrderNewResponseStatusInitializingTimedOut CertificatePackOrderNewResponseStatus = "initializing_timed_out" + CertificatePackOrderNewResponseStatusValidationTimedOut CertificatePackOrderNewResponseStatus = "validation_timed_out" + CertificatePackOrderNewResponseStatusIssuanceTimedOut CertificatePackOrderNewResponseStatus = "issuance_timed_out" + CertificatePackOrderNewResponseStatusDeploymentTimedOut CertificatePackOrderNewResponseStatus = "deployment_timed_out" + CertificatePackOrderNewResponseStatusDeletionTimedOut CertificatePackOrderNewResponseStatus = "deletion_timed_out" + CertificatePackOrderNewResponseStatusPendingCleanup CertificatePackOrderNewResponseStatus = "pending_cleanup" + CertificatePackOrderNewResponseStatusStagingDeployment CertificatePackOrderNewResponseStatus = "staging_deployment" + CertificatePackOrderNewResponseStatusStagingActive CertificatePackOrderNewResponseStatus = "staging_active" + CertificatePackOrderNewResponseStatusDeactivating CertificatePackOrderNewResponseStatus = "deactivating" + CertificatePackOrderNewResponseStatusInactive CertificatePackOrderNewResponseStatus = "inactive" + CertificatePackOrderNewResponseStatusBackupIssued CertificatePackOrderNewResponseStatus = "backup_issued" + CertificatePackOrderNewResponseStatusHoldingDeployment CertificatePackOrderNewResponseStatus = "holding_deployment" +) + +// Type of certificate pack. +type CertificatePackOrderNewResponseType string + +const ( + CertificatePackOrderNewResponseTypeAdvanced CertificatePackOrderNewResponseType = "advanced" +) + +// Validation Method selected for the order. +type CertificatePackOrderNewResponseValidationMethod string + +const ( + CertificatePackOrderNewResponseValidationMethodTXT CertificatePackOrderNewResponseValidationMethod = "txt" + CertificatePackOrderNewResponseValidationMethodHTTP CertificatePackOrderNewResponseValidationMethod = "http" + CertificatePackOrderNewResponseValidationMethodEmail CertificatePackOrderNewResponseValidationMethod = "email" +) + +// Validity Days selected for the order. +type CertificatePackOrderNewResponseValidityDays int64 + +const ( + CertificatePackOrderNewResponseValidityDays14 CertificatePackOrderNewResponseValidityDays = 14 + CertificatePackOrderNewResponseValidityDays30 CertificatePackOrderNewResponseValidityDays = 30 + CertificatePackOrderNewResponseValidityDays90 CertificatePackOrderNewResponseValidityDays = 90 + CertificatePackOrderNewResponseValidityDays365 CertificatePackOrderNewResponseValidityDays = 365 +) + +type CertificatePackOrderNewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Certificate Authority selected for the order. For information on any certificate + // authority specific details or restrictions + // [see this page for more details.](https://developers.cloudflare.com/ssl/reference/certificate-authorities) + CertificateAuthority param.Field[CertificatePackOrderNewParamsCertificateAuthority] `json:"certificate_authority,required"` + // Comma separated list of valid host names for the certificate packs. Must contain + // the zone apex, may not contain more than 50 hosts, and may not be empty. + Hosts param.Field[[]string] `json:"hosts,required"` + // Type of certificate pack. + Type param.Field[CertificatePackOrderNewParamsType] `json:"type,required"` + // Validation Method selected for the order. + ValidationMethod param.Field[CertificatePackOrderNewParamsValidationMethod] `json:"validation_method,required"` + // Validity Days selected for the order. + ValidityDays param.Field[CertificatePackOrderNewParamsValidityDays] `json:"validity_days,required"` + // Whether or not to add Cloudflare Branding for the order. This will add + // sni.cloudflaressl.com as the Common Name if set true. + CloudflareBranding param.Field[bool] `json:"cloudflare_branding"` +} + +func (r CertificatePackOrderNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Certificate Authority selected for the order. For information on any certificate +// authority specific details or restrictions +// [see this page for more details.](https://developers.cloudflare.com/ssl/reference/certificate-authorities) +type CertificatePackOrderNewParamsCertificateAuthority string + +const ( + CertificatePackOrderNewParamsCertificateAuthorityGoogle CertificatePackOrderNewParamsCertificateAuthority = "google" + CertificatePackOrderNewParamsCertificateAuthorityLetsEncrypt CertificatePackOrderNewParamsCertificateAuthority = "lets_encrypt" +) + +// Type of certificate pack. +type CertificatePackOrderNewParamsType string + +const ( + CertificatePackOrderNewParamsTypeAdvanced CertificatePackOrderNewParamsType = "advanced" +) + +// Validation Method selected for the order. +type CertificatePackOrderNewParamsValidationMethod string + +const ( + CertificatePackOrderNewParamsValidationMethodTXT CertificatePackOrderNewParamsValidationMethod = "txt" + CertificatePackOrderNewParamsValidationMethodHTTP CertificatePackOrderNewParamsValidationMethod = "http" + CertificatePackOrderNewParamsValidationMethodEmail CertificatePackOrderNewParamsValidationMethod = "email" +) + +// Validity Days selected for the order. +type CertificatePackOrderNewParamsValidityDays int64 + +const ( + CertificatePackOrderNewParamsValidityDays14 CertificatePackOrderNewParamsValidityDays = 14 + CertificatePackOrderNewParamsValidityDays30 CertificatePackOrderNewParamsValidityDays = 30 + CertificatePackOrderNewParamsValidityDays90 CertificatePackOrderNewParamsValidityDays = 90 + CertificatePackOrderNewParamsValidityDays365 CertificatePackOrderNewParamsValidityDays = 365 +) + +type CertificatePackOrderNewResponseEnvelope struct { + Errors []CertificatePackOrderNewResponseEnvelopeErrors `json:"errors,required"` + Messages []CertificatePackOrderNewResponseEnvelopeMessages `json:"messages,required"` + Result CertificatePackOrderNewResponse `json:"result,required"` + // Whether the API call was successful + Success CertificatePackOrderNewResponseEnvelopeSuccess `json:"success,required"` + JSON certificatePackOrderNewResponseEnvelopeJSON `json:"-"` +} + +// certificatePackOrderNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [CertificatePackOrderNewResponseEnvelope] +type certificatePackOrderNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackOrderNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackOrderNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CertificatePackOrderNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON certificatePackOrderNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// certificatePackOrderNewResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [CertificatePackOrderNewResponseEnvelopeErrors] +type certificatePackOrderNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackOrderNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackOrderNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CertificatePackOrderNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON certificatePackOrderNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// certificatePackOrderNewResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [CertificatePackOrderNewResponseEnvelopeMessages] +type certificatePackOrderNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackOrderNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackOrderNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CertificatePackOrderNewResponseEnvelopeSuccess bool + +const ( + CertificatePackOrderNewResponseEnvelopeSuccessTrue CertificatePackOrderNewResponseEnvelopeSuccess = true +) diff --git a/ssl/certificatepackorder_test.go b/ssl/certificatepackorder_test.go new file mode 100644 index 00000000000..f37b6b3c791 --- /dev/null +++ b/ssl/certificatepackorder_test.go @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package ssl_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/ssl" +) + +func TestCertificatePackOrderNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.SSL.CertificatePacks.Order.New(context.TODO(), ssl.CertificatePackOrderNewParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + CertificateAuthority: cloudflare.F(ssl.CertificatePackOrderNewParamsCertificateAuthorityLetsEncrypt), + Hosts: cloudflare.F([]string{"example.com", "*.example.com", "www.example.com"}), + Type: cloudflare.F(ssl.CertificatePackOrderNewParamsTypeAdvanced), + ValidationMethod: cloudflare.F(ssl.CertificatePackOrderNewParamsValidationMethodTXT), + ValidityDays: cloudflare.F(ssl.CertificatePackOrderNewParamsValidityDays14), + CloudflareBranding: cloudflare.F(false), + }) + 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/ssl/certificatepackquota.go b/ssl/certificatepackquota.go new file mode 100644 index 00000000000..1f8d1529885 --- /dev/null +++ b/ssl/certificatepackquota.go @@ -0,0 +1,177 @@ +// File generated from our OpenAPI spec by Stainless. + +package ssl + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// CertificatePackQuotaService 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 [NewCertificatePackQuotaService] +// method instead. +type CertificatePackQuotaService struct { + Options []option.RequestOption +} + +// NewCertificatePackQuotaService 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 NewCertificatePackQuotaService(opts ...option.RequestOption) (r *CertificatePackQuotaService) { + r = &CertificatePackQuotaService{} + r.Options = opts + return +} + +// For a given zone, list certificate pack quotas. +func (r *CertificatePackQuotaService) Get(ctx context.Context, query CertificatePackQuotaGetParams, opts ...option.RequestOption) (res *CertificatePackQuotaGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env CertificatePackQuotaGetResponseEnvelope + path := fmt.Sprintf("zones/%s/ssl/certificate_packs/quota", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type CertificatePackQuotaGetResponse struct { + Advanced CertificatePackQuotaGetResponseAdvanced `json:"advanced"` + JSON certificatePackQuotaGetResponseJSON `json:"-"` +} + +// certificatePackQuotaGetResponseJSON contains the JSON metadata for the struct +// [CertificatePackQuotaGetResponse] +type certificatePackQuotaGetResponseJSON struct { + Advanced apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackQuotaGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackQuotaGetResponseJSON) RawJSON() string { + return r.raw +} + +type CertificatePackQuotaGetResponseAdvanced struct { + // Quantity Allocated. + Allocated int64 `json:"allocated"` + // Quantity Used. + Used int64 `json:"used"` + JSON certificatePackQuotaGetResponseAdvancedJSON `json:"-"` +} + +// certificatePackQuotaGetResponseAdvancedJSON contains the JSON metadata for the +// struct [CertificatePackQuotaGetResponseAdvanced] +type certificatePackQuotaGetResponseAdvancedJSON struct { + Allocated apijson.Field + Used apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackQuotaGetResponseAdvanced) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackQuotaGetResponseAdvancedJSON) RawJSON() string { + return r.raw +} + +type CertificatePackQuotaGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type CertificatePackQuotaGetResponseEnvelope struct { + Errors []CertificatePackQuotaGetResponseEnvelopeErrors `json:"errors,required"` + Messages []CertificatePackQuotaGetResponseEnvelopeMessages `json:"messages,required"` + Result CertificatePackQuotaGetResponse `json:"result,required"` + // Whether the API call was successful + Success CertificatePackQuotaGetResponseEnvelopeSuccess `json:"success,required"` + JSON certificatePackQuotaGetResponseEnvelopeJSON `json:"-"` +} + +// certificatePackQuotaGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [CertificatePackQuotaGetResponseEnvelope] +type certificatePackQuotaGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackQuotaGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackQuotaGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CertificatePackQuotaGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON certificatePackQuotaGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// certificatePackQuotaGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [CertificatePackQuotaGetResponseEnvelopeErrors] +type certificatePackQuotaGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackQuotaGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackQuotaGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CertificatePackQuotaGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON certificatePackQuotaGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// certificatePackQuotaGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [CertificatePackQuotaGetResponseEnvelopeMessages] +type certificatePackQuotaGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CertificatePackQuotaGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r certificatePackQuotaGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CertificatePackQuotaGetResponseEnvelopeSuccess bool + +const ( + CertificatePackQuotaGetResponseEnvelopeSuccessTrue CertificatePackQuotaGetResponseEnvelopeSuccess = true +) diff --git a/ssl/certificatepackquota_test.go b/ssl/certificatepackquota_test.go new file mode 100644 index 00000000000..69134f451a3 --- /dev/null +++ b/ssl/certificatepackquota_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package ssl_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/ssl" +) + +func TestCertificatePackQuotaGet(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("user@example.com"), + ) + _, err := client.SSL.CertificatePacks.Quota.Get(context.TODO(), ssl.CertificatePackQuotaGetParams{ + ZoneID: cloudflare.F("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/ssl/recommendation.go b/ssl/recommendation.go new file mode 100644 index 00000000000..669efd1b86d --- /dev/null +++ b/ssl/recommendation.go @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package ssl + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// RecommendationService 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 [NewRecommendationService] method +// instead. +type RecommendationService struct { + Options []option.RequestOption +} + +// NewRecommendationService 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 NewRecommendationService(opts ...option.RequestOption) (r *RecommendationService) { + r = &RecommendationService{} + r.Options = opts + return +} + +// Retrieve the SSL/TLS Recommender's recommendation for a zone. +func (r *RecommendationService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *RecommendationGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env RecommendationGetResponseEnvelope + path := fmt.Sprintf("zones/%s/ssl/recommendation", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type RecommendationGetResponse struct { + // Identifier of a recommedation result. + ID string `json:"id"` + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + Value RecommendationGetResponseValue `json:"value"` + JSON recommendationGetResponseJSON `json:"-"` +} + +// recommendationGetResponseJSON contains the JSON metadata for the struct +// [RecommendationGetResponse] +type recommendationGetResponseJSON struct { + ID apijson.Field + ModifiedOn apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecommendationGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recommendationGetResponseJSON) RawJSON() string { + return r.raw +} + +type RecommendationGetResponseValue string + +const ( + RecommendationGetResponseValueFlexible RecommendationGetResponseValue = "flexible" + RecommendationGetResponseValueFull RecommendationGetResponseValue = "full" + RecommendationGetResponseValueStrict RecommendationGetResponseValue = "strict" +) + +type RecommendationGetResponseEnvelope struct { + Errors []RecommendationGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RecommendationGetResponseEnvelopeMessages `json:"messages,required"` + Result RecommendationGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success RecommendationGetResponseEnvelopeSuccess `json:"success,required"` + JSON recommendationGetResponseEnvelopeJSON `json:"-"` +} + +// recommendationGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RecommendationGetResponseEnvelope] +type recommendationGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecommendationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recommendationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RecommendationGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON recommendationGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// recommendationGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [RecommendationGetResponseEnvelopeErrors] +type recommendationGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecommendationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recommendationGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RecommendationGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON recommendationGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// recommendationGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RecommendationGetResponseEnvelopeMessages] +type recommendationGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RecommendationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r recommendationGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RecommendationGetResponseEnvelopeSuccess bool + +const ( + RecommendationGetResponseEnvelopeSuccessTrue RecommendationGetResponseEnvelopeSuccess = true +) diff --git a/ssl/recommendation_test.go b/ssl/recommendation_test.go new file mode 100644 index 00000000000..3e89996282f --- /dev/null +++ b/ssl/recommendation_test.go @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package ssl_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestRecommendationGet(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("user@example.com"), + ) + _, err := client.SSL.Recommendations.Get(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/ssl/ssl.go b/ssl/ssl.go new file mode 100644 index 00000000000..4cdb95c4f2b --- /dev/null +++ b/ssl/ssl.go @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package ssl + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// SSLService 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 [NewSSLService] method instead. +type SSLService struct { + Options []option.RequestOption + Analyze *AnalyzeService + CertificatePacks *CertificatePackService + Recommendations *RecommendationService + Universal *UniversalService + Verification *VerificationService +} + +// NewSSLService 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 NewSSLService(opts ...option.RequestOption) (r *SSLService) { + r = &SSLService{} + r.Options = opts + r.Analyze = NewAnalyzeService(opts...) + r.CertificatePacks = NewCertificatePackService(opts...) + r.Recommendations = NewRecommendationService(opts...) + r.Universal = NewUniversalService(opts...) + r.Verification = NewVerificationService(opts...) + return +} diff --git a/ssl/universal.go b/ssl/universal.go new file mode 100644 index 00000000000..b5356c845c9 --- /dev/null +++ b/ssl/universal.go @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package ssl + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// UniversalService 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 [NewUniversalService] method instead. +type UniversalService struct { + Options []option.RequestOption + Settings *UniversalSettingService +} + +// NewUniversalService 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 NewUniversalService(opts ...option.RequestOption) (r *UniversalService) { + r = &UniversalService{} + r.Options = opts + r.Settings = NewUniversalSettingService(opts...) + return +} diff --git a/ssl/universalsetting.go b/ssl/universalsetting.go new file mode 100644 index 00000000000..adc41bfcf84 --- /dev/null +++ b/ssl/universalsetting.go @@ -0,0 +1,306 @@ +// File generated from our OpenAPI spec by Stainless. + +package ssl + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// UniversalSettingService 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 [NewUniversalSettingService] method +// instead. +type UniversalSettingService struct { + Options []option.RequestOption +} + +// NewUniversalSettingService 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 NewUniversalSettingService(opts ...option.RequestOption) (r *UniversalSettingService) { + r = &UniversalSettingService{} + r.Options = opts + return +} + +// Patch Universal SSL Settings for a Zone. +func (r *UniversalSettingService) Edit(ctx context.Context, params UniversalSettingEditParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesUniversal, err error) { + opts = append(r.Options[:], opts...) + var env UniversalSettingEditResponseEnvelope + path := fmt.Sprintf("zones/%s/ssl/universal/settings", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get Universal SSL Settings for a Zone. +func (r *UniversalSettingService) Get(ctx context.Context, query UniversalSettingGetParams, opts ...option.RequestOption) (res *TLSCertificatesAndHostnamesUniversal, err error) { + opts = append(r.Options[:], opts...) + var env UniversalSettingGetResponseEnvelope + path := fmt.Sprintf("zones/%s/ssl/universal/settings", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TLSCertificatesAndHostnamesUniversal struct { + // Disabling Universal SSL removes any currently active Universal SSL certificates + // for your zone from the edge and prevents any future Universal SSL certificates + // from being ordered. If there are no advanced certificates or custom certificates + // uploaded for the domain, visitors will be unable to access the domain over + // HTTPS. + // + // By disabling Universal SSL, you understand that the following Cloudflare + // settings and preferences will result in visitors being unable to visit your + // domain unless you have uploaded a custom certificate or purchased an advanced + // certificate. + // + // - HSTS + // - Always Use HTTPS + // - Opportunistic Encryption + // - Onion Routing + // - Any Page Rules redirecting traffic to HTTPS + // + // Similarly, any HTTP redirect to HTTPS at the origin while the Cloudflare proxy + // is enabled will result in users being unable to visit your site without a valid + // certificate at Cloudflare's edge. + // + // If you do not have a valid custom or advanced certificate at Cloudflare's edge + // and are unsure if any of the above Cloudflare settings are enabled, or if any + // HTTP redirects exist at your origin, we advise leaving Universal SSL enabled for + // your domain. + Enabled bool `json:"enabled"` + JSON tlsCertificatesAndHostnamesUniversalJSON `json:"-"` +} + +// tlsCertificatesAndHostnamesUniversalJSON contains the JSON metadata for the +// struct [TLSCertificatesAndHostnamesUniversal] +type tlsCertificatesAndHostnamesUniversalJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TLSCertificatesAndHostnamesUniversal) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tlsCertificatesAndHostnamesUniversalJSON) RawJSON() string { + return r.raw +} + +type UniversalSettingEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Disabling Universal SSL removes any currently active Universal SSL certificates + // for your zone from the edge and prevents any future Universal SSL certificates + // from being ordered. If there are no advanced certificates or custom certificates + // uploaded for the domain, visitors will be unable to access the domain over + // HTTPS. + // + // By disabling Universal SSL, you understand that the following Cloudflare + // settings and preferences will result in visitors being unable to visit your + // domain unless you have uploaded a custom certificate or purchased an advanced + // certificate. + // + // - HSTS + // - Always Use HTTPS + // - Opportunistic Encryption + // - Onion Routing + // - Any Page Rules redirecting traffic to HTTPS + // + // Similarly, any HTTP redirect to HTTPS at the origin while the Cloudflare proxy + // is enabled will result in users being unable to visit your site without a valid + // certificate at Cloudflare's edge. + // + // If you do not have a valid custom or advanced certificate at Cloudflare's edge + // and are unsure if any of the above Cloudflare settings are enabled, or if any + // HTTP redirects exist at your origin, we advise leaving Universal SSL enabled for + // your domain. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r UniversalSettingEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type UniversalSettingEditResponseEnvelope struct { + Errors []UniversalSettingEditResponseEnvelopeErrors `json:"errors,required"` + Messages []UniversalSettingEditResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesUniversal `json:"result,required"` + // Whether the API call was successful + Success UniversalSettingEditResponseEnvelopeSuccess `json:"success,required"` + JSON universalSettingEditResponseEnvelopeJSON `json:"-"` +} + +// universalSettingEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [UniversalSettingEditResponseEnvelope] +type universalSettingEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UniversalSettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r universalSettingEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type UniversalSettingEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON universalSettingEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// universalSettingEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [UniversalSettingEditResponseEnvelopeErrors] +type universalSettingEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UniversalSettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r universalSettingEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type UniversalSettingEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON universalSettingEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// universalSettingEditResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [UniversalSettingEditResponseEnvelopeMessages] +type universalSettingEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UniversalSettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r universalSettingEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type UniversalSettingEditResponseEnvelopeSuccess bool + +const ( + UniversalSettingEditResponseEnvelopeSuccessTrue UniversalSettingEditResponseEnvelopeSuccess = true +) + +type UniversalSettingGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type UniversalSettingGetResponseEnvelope struct { + Errors []UniversalSettingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []UniversalSettingGetResponseEnvelopeMessages `json:"messages,required"` + Result TLSCertificatesAndHostnamesUniversal `json:"result,required"` + // Whether the API call was successful + Success UniversalSettingGetResponseEnvelopeSuccess `json:"success,required"` + JSON universalSettingGetResponseEnvelopeJSON `json:"-"` +} + +// universalSettingGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [UniversalSettingGetResponseEnvelope] +type universalSettingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UniversalSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r universalSettingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type UniversalSettingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON universalSettingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// universalSettingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [UniversalSettingGetResponseEnvelopeErrors] +type universalSettingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UniversalSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r universalSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type UniversalSettingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON universalSettingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// universalSettingGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [UniversalSettingGetResponseEnvelopeMessages] +type universalSettingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *UniversalSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r universalSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type UniversalSettingGetResponseEnvelopeSuccess bool + +const ( + UniversalSettingGetResponseEnvelopeSuccessTrue UniversalSettingGetResponseEnvelopeSuccess = true +) diff --git a/ssl/universalsetting_test.go b/ssl/universalsetting_test.go new file mode 100644 index 00000000000..0e662ca452c --- /dev/null +++ b/ssl/universalsetting_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package ssl_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/ssl" +) + +func TestUniversalSettingEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.SSL.Universal.Settings.Edit(context.TODO(), ssl.UniversalSettingEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Enabled: cloudflare.F(true), + }) + 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 TestUniversalSettingGet(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("user@example.com"), + ) + _, err := client.SSL.Universal.Settings.Get(context.TODO(), ssl.UniversalSettingGetParams{ + ZoneID: cloudflare.F("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/ssl/verification.go b/ssl/verification.go new file mode 100644 index 00000000000..794316573b7 --- /dev/null +++ b/ssl/verification.go @@ -0,0 +1,373 @@ +// File generated from our OpenAPI spec by Stainless. + +package ssl + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// VerificationService 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 [NewVerificationService] method +// instead. +type VerificationService struct { + Options []option.RequestOption +} + +// NewVerificationService 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 NewVerificationService(opts ...option.RequestOption) (r *VerificationService) { + r = &VerificationService{} + r.Options = opts + return +} + +// Edit SSL validation method for a certificate pack. A PATCH request will request +// an immediate validation check on any certificate, and return the updated status. +// If a validation method is provided, the validation will be immediately attempted +// using that method. +func (r *VerificationService) Edit(ctx context.Context, certificatePackID string, params VerificationEditParams, opts ...option.RequestOption) (res *VerificationEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env VerificationEditResponseEnvelope + path := fmt.Sprintf("zones/%s/ssl/verification/%s", params.ZoneID, certificatePackID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get SSL Verification Info for a Zone. +func (r *VerificationService) Get(ctx context.Context, params VerificationGetParams, opts ...option.RequestOption) (res *[]TLSCertificatesAndHostnamesVerification, err error) { + opts = append(r.Options[:], opts...) + var env VerificationGetResponseEnvelope + path := fmt.Sprintf("zones/%s/ssl/verification", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TLSCertificatesAndHostnamesVerification struct { + // Current status of certificate. + CertificateStatus TLSCertificatesAndHostnamesVerificationCertificateStatus `json:"certificate_status,required"` + // Certificate Authority is manually reviewing the order. + BrandCheck bool `json:"brand_check"` + // Certificate Pack UUID. + CertPackUUID string `json:"cert_pack_uuid"` + // Certificate's signature algorithm. + Signature TLSCertificatesAndHostnamesVerificationSignature `json:"signature"` + // Validation method in use for a certificate pack order. + ValidationMethod TLSCertificatesAndHostnamesVerificationValidationMethod `json:"validation_method"` + // Certificate's required verification information. + VerificationInfo TLSCertificatesAndHostnamesVerificationVerificationInfo `json:"verification_info"` + // Status of the required verification information, omitted if verification status + // is unknown. + VerificationStatus bool `json:"verification_status"` + // Method of verification. + VerificationType TLSCertificatesAndHostnamesVerificationVerificationType `json:"verification_type"` + JSON tlsCertificatesAndHostnamesVerificationJSON `json:"-"` +} + +// tlsCertificatesAndHostnamesVerificationJSON contains the JSON metadata for the +// struct [TLSCertificatesAndHostnamesVerification] +type tlsCertificatesAndHostnamesVerificationJSON struct { + CertificateStatus apijson.Field + BrandCheck apijson.Field + CertPackUUID apijson.Field + Signature apijson.Field + ValidationMethod apijson.Field + VerificationInfo apijson.Field + VerificationStatus apijson.Field + VerificationType apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TLSCertificatesAndHostnamesVerification) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tlsCertificatesAndHostnamesVerificationJSON) RawJSON() string { + return r.raw +} + +// Current status of certificate. +type TLSCertificatesAndHostnamesVerificationCertificateStatus string + +const ( + TLSCertificatesAndHostnamesVerificationCertificateStatusInitializing TLSCertificatesAndHostnamesVerificationCertificateStatus = "initializing" + TLSCertificatesAndHostnamesVerificationCertificateStatusAuthorizing TLSCertificatesAndHostnamesVerificationCertificateStatus = "authorizing" + TLSCertificatesAndHostnamesVerificationCertificateStatusActive TLSCertificatesAndHostnamesVerificationCertificateStatus = "active" + TLSCertificatesAndHostnamesVerificationCertificateStatusExpired TLSCertificatesAndHostnamesVerificationCertificateStatus = "expired" + TLSCertificatesAndHostnamesVerificationCertificateStatusIssuing TLSCertificatesAndHostnamesVerificationCertificateStatus = "issuing" + TLSCertificatesAndHostnamesVerificationCertificateStatusTimingOut TLSCertificatesAndHostnamesVerificationCertificateStatus = "timing_out" + TLSCertificatesAndHostnamesVerificationCertificateStatusPendingDeployment TLSCertificatesAndHostnamesVerificationCertificateStatus = "pending_deployment" +) + +// Certificate's signature algorithm. +type TLSCertificatesAndHostnamesVerificationSignature string + +const ( + TLSCertificatesAndHostnamesVerificationSignatureEcdsaWithSha256 TLSCertificatesAndHostnamesVerificationSignature = "ECDSAWithSHA256" + TLSCertificatesAndHostnamesVerificationSignatureSha1WithRsa TLSCertificatesAndHostnamesVerificationSignature = "SHA1WithRSA" + TLSCertificatesAndHostnamesVerificationSignatureSha256WithRsa TLSCertificatesAndHostnamesVerificationSignature = "SHA256WithRSA" +) + +// Validation method in use for a certificate pack order. +type TLSCertificatesAndHostnamesVerificationValidationMethod string + +const ( + TLSCertificatesAndHostnamesVerificationValidationMethodHTTP TLSCertificatesAndHostnamesVerificationValidationMethod = "http" + TLSCertificatesAndHostnamesVerificationValidationMethodCNAME TLSCertificatesAndHostnamesVerificationValidationMethod = "cname" + TLSCertificatesAndHostnamesVerificationValidationMethodTXT TLSCertificatesAndHostnamesVerificationValidationMethod = "txt" +) + +// Certificate's required verification information. +type TLSCertificatesAndHostnamesVerificationVerificationInfo struct { + // Name of CNAME record. + RecordName TLSCertificatesAndHostnamesVerificationVerificationInfoRecordName `json:"record_name"` + // Target of CNAME record. + RecordTarget TLSCertificatesAndHostnamesVerificationVerificationInfoRecordTarget `json:"record_target"` + JSON tlsCertificatesAndHostnamesVerificationVerificationInfoJSON `json:"-"` +} + +// tlsCertificatesAndHostnamesVerificationVerificationInfoJSON contains the JSON +// metadata for the struct +// [TLSCertificatesAndHostnamesVerificationVerificationInfo] +type tlsCertificatesAndHostnamesVerificationVerificationInfoJSON struct { + RecordName apijson.Field + RecordTarget apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TLSCertificatesAndHostnamesVerificationVerificationInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tlsCertificatesAndHostnamesVerificationVerificationInfoJSON) RawJSON() string { + return r.raw +} + +// Name of CNAME record. +type TLSCertificatesAndHostnamesVerificationVerificationInfoRecordName string + +const ( + TLSCertificatesAndHostnamesVerificationVerificationInfoRecordNameRecordName TLSCertificatesAndHostnamesVerificationVerificationInfoRecordName = "record_name" + TLSCertificatesAndHostnamesVerificationVerificationInfoRecordNameHTTPURL TLSCertificatesAndHostnamesVerificationVerificationInfoRecordName = "http_url" + TLSCertificatesAndHostnamesVerificationVerificationInfoRecordNameCNAME TLSCertificatesAndHostnamesVerificationVerificationInfoRecordName = "cname" + TLSCertificatesAndHostnamesVerificationVerificationInfoRecordNameTXTName TLSCertificatesAndHostnamesVerificationVerificationInfoRecordName = "txt_name" +) + +// Target of CNAME record. +type TLSCertificatesAndHostnamesVerificationVerificationInfoRecordTarget string + +const ( + TLSCertificatesAndHostnamesVerificationVerificationInfoRecordTargetRecordValue TLSCertificatesAndHostnamesVerificationVerificationInfoRecordTarget = "record_value" + TLSCertificatesAndHostnamesVerificationVerificationInfoRecordTargetHTTPBody TLSCertificatesAndHostnamesVerificationVerificationInfoRecordTarget = "http_body" + TLSCertificatesAndHostnamesVerificationVerificationInfoRecordTargetCNAMETarget TLSCertificatesAndHostnamesVerificationVerificationInfoRecordTarget = "cname_target" + TLSCertificatesAndHostnamesVerificationVerificationInfoRecordTargetTXTValue TLSCertificatesAndHostnamesVerificationVerificationInfoRecordTarget = "txt_value" +) + +// Method of verification. +type TLSCertificatesAndHostnamesVerificationVerificationType string + +const ( + TLSCertificatesAndHostnamesVerificationVerificationTypeCNAME TLSCertificatesAndHostnamesVerificationVerificationType = "cname" + TLSCertificatesAndHostnamesVerificationVerificationTypeMetaTag TLSCertificatesAndHostnamesVerificationVerificationType = "meta tag" +) + +type VerificationEditResponse struct { + // Result status. + Status string `json:"status"` + // Desired validation method. + ValidationMethod VerificationEditResponseValidationMethod `json:"validation_method"` + JSON verificationEditResponseJSON `json:"-"` +} + +// verificationEditResponseJSON contains the JSON metadata for the struct +// [VerificationEditResponse] +type verificationEditResponseJSON struct { + Status apijson.Field + ValidationMethod apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerificationEditResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verificationEditResponseJSON) RawJSON() string { + return r.raw +} + +// Desired validation method. +type VerificationEditResponseValidationMethod string + +const ( + VerificationEditResponseValidationMethodHTTP VerificationEditResponseValidationMethod = "http" + VerificationEditResponseValidationMethodCNAME VerificationEditResponseValidationMethod = "cname" + VerificationEditResponseValidationMethodTXT VerificationEditResponseValidationMethod = "txt" + VerificationEditResponseValidationMethodEmail VerificationEditResponseValidationMethod = "email" +) + +type VerificationEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Desired validation method. + ValidationMethod param.Field[VerificationEditParamsValidationMethod] `json:"validation_method,required"` +} + +func (r VerificationEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Desired validation method. +type VerificationEditParamsValidationMethod string + +const ( + VerificationEditParamsValidationMethodHTTP VerificationEditParamsValidationMethod = "http" + VerificationEditParamsValidationMethodCNAME VerificationEditParamsValidationMethod = "cname" + VerificationEditParamsValidationMethodTXT VerificationEditParamsValidationMethod = "txt" + VerificationEditParamsValidationMethodEmail VerificationEditParamsValidationMethod = "email" +) + +type VerificationEditResponseEnvelope struct { + Errors []VerificationEditResponseEnvelopeErrors `json:"errors,required"` + Messages []VerificationEditResponseEnvelopeMessages `json:"messages,required"` + Result VerificationEditResponse `json:"result,required"` + // Whether the API call was successful + Success VerificationEditResponseEnvelopeSuccess `json:"success,required"` + JSON verificationEditResponseEnvelopeJSON `json:"-"` +} + +// verificationEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [VerificationEditResponseEnvelope] +type verificationEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerificationEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verificationEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type VerificationEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON verificationEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// verificationEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [VerificationEditResponseEnvelopeErrors] +type verificationEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerificationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verificationEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type VerificationEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON verificationEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// verificationEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [VerificationEditResponseEnvelopeMessages] +type verificationEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerificationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verificationEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type VerificationEditResponseEnvelopeSuccess bool + +const ( + VerificationEditResponseEnvelopeSuccessTrue VerificationEditResponseEnvelopeSuccess = true +) + +type VerificationGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Immediately retry SSL Verification. + Retry param.Field[VerificationGetParamsRetry] `query:"retry"` +} + +// URLQuery serializes [VerificationGetParams]'s query parameters as `url.Values`. +func (r VerificationGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Immediately retry SSL Verification. +type VerificationGetParamsRetry bool + +const ( + VerificationGetParamsRetryTrue VerificationGetParamsRetry = true +) + +type VerificationGetResponseEnvelope struct { + Result []TLSCertificatesAndHostnamesVerification `json:"result"` + JSON verificationGetResponseEnvelopeJSON `json:"-"` +} + +// verificationGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [VerificationGetResponseEnvelope] +type verificationGetResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VerificationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r verificationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/ssl/verification_test.go b/ssl/verification_test.go new file mode 100644 index 00000000000..975210580dd --- /dev/null +++ b/ssl/verification_test.go @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package ssl_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/ssl" +) + +func TestVerificationEdit(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("user@example.com"), + ) + _, err := client.SSL.Verification.Edit( + context.TODO(), + "a77f8bd7-3b47-46b4-a6f1-75cf98109948", + ssl.VerificationEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + ValidationMethod: cloudflare.F(ssl.VerificationEditParamsValidationMethodTXT), + }, + ) + 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 TestVerificationGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.SSL.Verification.Get(context.TODO(), ssl.VerificationGetParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Retry: cloudflare.F(ssl.VerificationGetParamsRetryTrue), + }) + 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/sslanalyze.go b/sslanalyze.go deleted file mode 100644 index 0f0195afbd7..00000000000 --- a/sslanalyze.go +++ /dev/null @@ -1,173 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// SSLAnalyzeService 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 [NewSSLAnalyzeService] method instead. -type SSLAnalyzeService struct { - Options []option.RequestOption -} - -// NewSSLAnalyzeService 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 NewSSLAnalyzeService(opts ...option.RequestOption) (r *SSLAnalyzeService) { - r = &SSLAnalyzeService{} - r.Options = opts - return -} - -// Returns the set of hostnames, the signature algorithm, and the expiration date -// of the certificate. -func (r *SSLAnalyzeService) New(ctx context.Context, params SSLAnalyzeNewParams, opts ...option.RequestOption) (res *SSLAnalyzeNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env SSLAnalyzeNewResponseEnvelope - path := fmt.Sprintf("zones/%s/ssl/analyze", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [SSLAnalyzeNewResponseUnknown] or [shared.UnionString]. -type SSLAnalyzeNewResponse interface { - ImplementsSSLAnalyzeNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SSLAnalyzeNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type SSLAnalyzeNewParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // A ubiquitous bundle has the highest probability of being verified everywhere, - // even by clients using outdated or unusual trust stores. An optimal bundle uses - // the shortest chain and newest intermediates. And the force bundle verifies the - // chain, but does not otherwise modify it. - BundleMethod param.Field[SSLAnalyzeNewParamsBundleMethod] `json:"bundle_method"` - // The zone's SSL certificate or certificate and the intermediate(s). - Certificate param.Field[string] `json:"certificate"` -} - -func (r SSLAnalyzeNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A ubiquitous bundle has the highest probability of being verified everywhere, -// even by clients using outdated or unusual trust stores. An optimal bundle uses -// the shortest chain and newest intermediates. And the force bundle verifies the -// chain, but does not otherwise modify it. -type SSLAnalyzeNewParamsBundleMethod string - -const ( - SSLAnalyzeNewParamsBundleMethodUbiquitous SSLAnalyzeNewParamsBundleMethod = "ubiquitous" - SSLAnalyzeNewParamsBundleMethodOptimal SSLAnalyzeNewParamsBundleMethod = "optimal" - SSLAnalyzeNewParamsBundleMethodForce SSLAnalyzeNewParamsBundleMethod = "force" -) - -type SSLAnalyzeNewResponseEnvelope struct { - Errors []SSLAnalyzeNewResponseEnvelopeErrors `json:"errors,required"` - Messages []SSLAnalyzeNewResponseEnvelopeMessages `json:"messages,required"` - Result SSLAnalyzeNewResponse `json:"result,required"` - // Whether the API call was successful - Success SSLAnalyzeNewResponseEnvelopeSuccess `json:"success,required"` - JSON sslAnalyzeNewResponseEnvelopeJSON `json:"-"` -} - -// sslAnalyzeNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [SSLAnalyzeNewResponseEnvelope] -type sslAnalyzeNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLAnalyzeNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslAnalyzeNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SSLAnalyzeNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslAnalyzeNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// sslAnalyzeNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SSLAnalyzeNewResponseEnvelopeErrors] -type sslAnalyzeNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLAnalyzeNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslAnalyzeNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SSLAnalyzeNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslAnalyzeNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// sslAnalyzeNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SSLAnalyzeNewResponseEnvelopeMessages] -type sslAnalyzeNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLAnalyzeNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslAnalyzeNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SSLAnalyzeNewResponseEnvelopeSuccess bool - -const ( - SSLAnalyzeNewResponseEnvelopeSuccessTrue SSLAnalyzeNewResponseEnvelopeSuccess = true -) diff --git a/sslanalyze_test.go b/sslanalyze_test.go deleted file mode 100644 index 9887d5411ff..00000000000 --- a/sslanalyze_test.go +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSSLAnalyzeNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.SSL.Analyze.New(context.TODO(), cloudflare.SSLAnalyzeNewParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - BundleMethod: cloudflare.F(cloudflare.SSLAnalyzeNewParamsBundleMethodUbiquitous), - Certificate: cloudflare.F("-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIJAMHAwfXZ5/PWMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\nBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX\naWRnaXRzIFB0eSBMdGQwHhcNMTYwODI0MTY0MzAxWhcNMTYxMTIyMTY0MzAxWjBF\nMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50\nZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\nCgKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmGdtcGbg/1\nCGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKnabIRuGvB\nKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpidtnKX/a+5\n0GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+pyFxIXjbEI\ndZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pEewooaeO2\nizNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABo4GnMIGkMB0GA1UdDgQWBBT/LbE4\n9rWf288N6sJA5BRb6FJIGDB1BgNVHSMEbjBsgBT/LbE49rWf288N6sJA5BRb6FJI\nGKFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNV\nBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAMHAwfXZ5/PWMAwGA1UdEwQF\nMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAHHFwl0tH0quUYZYO0dZYt4R7SJ0pCm2\n2satiyzHl4OnXcHDpekAo7/a09c6Lz6AU83cKy/+x3/djYHXWba7HpEu0dR3ugQP\nMlr4zrhd9xKZ0KZKiYmtJH+ak4OM4L3FbT0owUZPyjLSlhMtJVcoRp5CJsjAMBUG\nSvD8RX+T01wzox/Qb+lnnNnOlaWpqu8eoOenybxKp1a9ULzIVvN/LAcc+14vioFq\n2swRWtmocBAs8QR9n4uvbpiYvS8eYueDCWMM4fvFfBhaDZ3N9IbtySh3SpFdQDhw\nYbjM2rxXiyLGxB4Bol7QTv4zHif7Zt89FReT/NBy4rzaskDJY5L6xmY=\n-----END CERTIFICATE-----\n"), - }) - 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/sslcertificatepack.go b/sslcertificatepack.go deleted file mode 100644 index a5d2a2e3538..00000000000 --- a/sslcertificatepack.go +++ /dev/null @@ -1,641 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// SSLCertificatePackService 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 [NewSSLCertificatePackService] method -// instead. -type SSLCertificatePackService struct { - Options []option.RequestOption - Order *SSLCertificatePackOrderService - Quota *SSLCertificatePackQuotaService -} - -// NewSSLCertificatePackService 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 NewSSLCertificatePackService(opts ...option.RequestOption) (r *SSLCertificatePackService) { - r = &SSLCertificatePackService{} - r.Options = opts - r.Order = NewSSLCertificatePackOrderService(opts...) - r.Quota = NewSSLCertificatePackQuotaService(opts...) - return -} - -// For a given zone, list all active certificate packs. -func (r *SSLCertificatePackService) List(ctx context.Context, params SSLCertificatePackListParams, opts ...option.RequestOption) (res *[]SSLCertificatePackListResponse, err error) { - opts = append(r.Options[:], opts...) - var env SSLCertificatePackListResponseEnvelope - path := fmt.Sprintf("zones/%s/ssl/certificate_packs", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// For a given zone, delete an advanced certificate pack. -func (r *SSLCertificatePackService) Delete(ctx context.Context, certificatePackID string, body SSLCertificatePackDeleteParams, opts ...option.RequestOption) (res *SSLCertificatePackDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env SSLCertificatePackDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/ssl/certificate_packs/%s", body.ZoneID, certificatePackID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// For a given zone, restart validation for an advanced certificate pack. This is -// only a validation operation for a Certificate Pack in a validation_timed_out -// status. -func (r *SSLCertificatePackService) Edit(ctx context.Context, certificatePackID string, body SSLCertificatePackEditParams, opts ...option.RequestOption) (res *SSLCertificatePackEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env SSLCertificatePackEditResponseEnvelope - path := fmt.Sprintf("zones/%s/ssl/certificate_packs/%s", body.ZoneID, certificatePackID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// For a given zone, get a certificate pack. -func (r *SSLCertificatePackService) Get(ctx context.Context, certificatePackID string, query SSLCertificatePackGetParams, opts ...option.RequestOption) (res *SSLCertificatePackGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env SSLCertificatePackGetResponseEnvelope - path := fmt.Sprintf("zones/%s/ssl/certificate_packs/%s", query.ZoneID, certificatePackID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SSLCertificatePackListResponse = interface{} - -type SSLCertificatePackDeleteResponse struct { - // Identifier - ID string `json:"id"` - JSON sslCertificatePackDeleteResponseJSON `json:"-"` -} - -// sslCertificatePackDeleteResponseJSON contains the JSON metadata for the struct -// [SSLCertificatePackDeleteResponse] -type sslCertificatePackDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type SSLCertificatePackEditResponse struct { - // Identifier - ID string `json:"id"` - // Certificate Authority selected for the order. For information on any certificate - // authority specific details or restrictions - // [see this page for more details.](https://developers.cloudflare.com/ssl/reference/certificate-authorities) - CertificateAuthority SSLCertificatePackEditResponseCertificateAuthority `json:"certificate_authority"` - // Whether or not to add Cloudflare Branding for the order. This will add - // sni.cloudflaressl.com as the Common Name if set true. - CloudflareBranding bool `json:"cloudflare_branding"` - // Comma separated list of valid host names for the certificate packs. Must contain - // the zone apex, may not contain more than 50 hosts, and may not be empty. - Hosts []string `json:"hosts"` - // Status of certificate pack. - Status SSLCertificatePackEditResponseStatus `json:"status"` - // Type of certificate pack. - Type SSLCertificatePackEditResponseType `json:"type"` - // Validation Method selected for the order. - ValidationMethod SSLCertificatePackEditResponseValidationMethod `json:"validation_method"` - // Validity Days selected for the order. - ValidityDays SSLCertificatePackEditResponseValidityDays `json:"validity_days"` - JSON sslCertificatePackEditResponseJSON `json:"-"` -} - -// sslCertificatePackEditResponseJSON contains the JSON metadata for the struct -// [SSLCertificatePackEditResponse] -type sslCertificatePackEditResponseJSON struct { - ID apijson.Field - CertificateAuthority apijson.Field - CloudflareBranding apijson.Field - Hosts apijson.Field - Status apijson.Field - Type apijson.Field - ValidationMethod apijson.Field - ValidityDays apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackEditResponseJSON) RawJSON() string { - return r.raw -} - -// Certificate Authority selected for the order. For information on any certificate -// authority specific details or restrictions -// [see this page for more details.](https://developers.cloudflare.com/ssl/reference/certificate-authorities) -type SSLCertificatePackEditResponseCertificateAuthority string - -const ( - SSLCertificatePackEditResponseCertificateAuthorityGoogle SSLCertificatePackEditResponseCertificateAuthority = "google" - SSLCertificatePackEditResponseCertificateAuthorityLetsEncrypt SSLCertificatePackEditResponseCertificateAuthority = "lets_encrypt" -) - -// Status of certificate pack. -type SSLCertificatePackEditResponseStatus string - -const ( - SSLCertificatePackEditResponseStatusInitializing SSLCertificatePackEditResponseStatus = "initializing" - SSLCertificatePackEditResponseStatusPendingValidation SSLCertificatePackEditResponseStatus = "pending_validation" - SSLCertificatePackEditResponseStatusDeleted SSLCertificatePackEditResponseStatus = "deleted" - SSLCertificatePackEditResponseStatusPendingIssuance SSLCertificatePackEditResponseStatus = "pending_issuance" - SSLCertificatePackEditResponseStatusPendingDeployment SSLCertificatePackEditResponseStatus = "pending_deployment" - SSLCertificatePackEditResponseStatusPendingDeletion SSLCertificatePackEditResponseStatus = "pending_deletion" - SSLCertificatePackEditResponseStatusPendingExpiration SSLCertificatePackEditResponseStatus = "pending_expiration" - SSLCertificatePackEditResponseStatusExpired SSLCertificatePackEditResponseStatus = "expired" - SSLCertificatePackEditResponseStatusActive SSLCertificatePackEditResponseStatus = "active" - SSLCertificatePackEditResponseStatusInitializingTimedOut SSLCertificatePackEditResponseStatus = "initializing_timed_out" - SSLCertificatePackEditResponseStatusValidationTimedOut SSLCertificatePackEditResponseStatus = "validation_timed_out" - SSLCertificatePackEditResponseStatusIssuanceTimedOut SSLCertificatePackEditResponseStatus = "issuance_timed_out" - SSLCertificatePackEditResponseStatusDeploymentTimedOut SSLCertificatePackEditResponseStatus = "deployment_timed_out" - SSLCertificatePackEditResponseStatusDeletionTimedOut SSLCertificatePackEditResponseStatus = "deletion_timed_out" - SSLCertificatePackEditResponseStatusPendingCleanup SSLCertificatePackEditResponseStatus = "pending_cleanup" - SSLCertificatePackEditResponseStatusStagingDeployment SSLCertificatePackEditResponseStatus = "staging_deployment" - SSLCertificatePackEditResponseStatusStagingActive SSLCertificatePackEditResponseStatus = "staging_active" - SSLCertificatePackEditResponseStatusDeactivating SSLCertificatePackEditResponseStatus = "deactivating" - SSLCertificatePackEditResponseStatusInactive SSLCertificatePackEditResponseStatus = "inactive" - SSLCertificatePackEditResponseStatusBackupIssued SSLCertificatePackEditResponseStatus = "backup_issued" - SSLCertificatePackEditResponseStatusHoldingDeployment SSLCertificatePackEditResponseStatus = "holding_deployment" -) - -// Type of certificate pack. -type SSLCertificatePackEditResponseType string - -const ( - SSLCertificatePackEditResponseTypeAdvanced SSLCertificatePackEditResponseType = "advanced" -) - -// Validation Method selected for the order. -type SSLCertificatePackEditResponseValidationMethod string - -const ( - SSLCertificatePackEditResponseValidationMethodTXT SSLCertificatePackEditResponseValidationMethod = "txt" - SSLCertificatePackEditResponseValidationMethodHTTP SSLCertificatePackEditResponseValidationMethod = "http" - SSLCertificatePackEditResponseValidationMethodEmail SSLCertificatePackEditResponseValidationMethod = "email" -) - -// Validity Days selected for the order. -type SSLCertificatePackEditResponseValidityDays int64 - -const ( - SSLCertificatePackEditResponseValidityDays14 SSLCertificatePackEditResponseValidityDays = 14 - SSLCertificatePackEditResponseValidityDays30 SSLCertificatePackEditResponseValidityDays = 30 - SSLCertificatePackEditResponseValidityDays90 SSLCertificatePackEditResponseValidityDays = 90 - SSLCertificatePackEditResponseValidityDays365 SSLCertificatePackEditResponseValidityDays = 365 -) - -// Union satisfied by [SSLCertificatePackGetResponseUnknown] or -// [shared.UnionString]. -type SSLCertificatePackGetResponse interface { - ImplementsSSLCertificatePackGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SSLCertificatePackGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type SSLCertificatePackListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Include Certificate Packs of all statuses, not just active ones. - Status param.Field[SSLCertificatePackListParamsStatus] `query:"status"` -} - -// URLQuery serializes [SSLCertificatePackListParams]'s query parameters as -// `url.Values`. -func (r SSLCertificatePackListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Include Certificate Packs of all statuses, not just active ones. -type SSLCertificatePackListParamsStatus string - -const ( - SSLCertificatePackListParamsStatusAll SSLCertificatePackListParamsStatus = "all" -) - -type SSLCertificatePackListResponseEnvelope struct { - Errors []SSLCertificatePackListResponseEnvelopeErrors `json:"errors,required"` - Messages []SSLCertificatePackListResponseEnvelopeMessages `json:"messages,required"` - Result []SSLCertificatePackListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success SSLCertificatePackListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo SSLCertificatePackListResponseEnvelopeResultInfo `json:"result_info"` - JSON sslCertificatePackListResponseEnvelopeJSON `json:"-"` -} - -// sslCertificatePackListResponseEnvelopeJSON contains the JSON metadata for the -// struct [SSLCertificatePackListResponseEnvelope] -type sslCertificatePackListResponseEnvelopeJSON 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 *SSLCertificatePackListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SSLCertificatePackListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslCertificatePackListResponseEnvelopeErrorsJSON `json:"-"` -} - -// sslCertificatePackListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SSLCertificatePackListResponseEnvelopeErrors] -type sslCertificatePackListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SSLCertificatePackListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslCertificatePackListResponseEnvelopeMessagesJSON `json:"-"` -} - -// sslCertificatePackListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SSLCertificatePackListResponseEnvelopeMessages] -type sslCertificatePackListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SSLCertificatePackListResponseEnvelopeSuccess bool - -const ( - SSLCertificatePackListResponseEnvelopeSuccessTrue SSLCertificatePackListResponseEnvelopeSuccess = true -) - -type SSLCertificatePackListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON sslCertificatePackListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// sslCertificatePackListResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [SSLCertificatePackListResponseEnvelopeResultInfo] -type sslCertificatePackListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type SSLCertificatePackDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type SSLCertificatePackDeleteResponseEnvelope struct { - Errors []SSLCertificatePackDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []SSLCertificatePackDeleteResponseEnvelopeMessages `json:"messages,required"` - Result SSLCertificatePackDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success SSLCertificatePackDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON sslCertificatePackDeleteResponseEnvelopeJSON `json:"-"` -} - -// sslCertificatePackDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [SSLCertificatePackDeleteResponseEnvelope] -type sslCertificatePackDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SSLCertificatePackDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslCertificatePackDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// sslCertificatePackDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SSLCertificatePackDeleteResponseEnvelopeErrors] -type sslCertificatePackDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SSLCertificatePackDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslCertificatePackDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// sslCertificatePackDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SSLCertificatePackDeleteResponseEnvelopeMessages] -type sslCertificatePackDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SSLCertificatePackDeleteResponseEnvelopeSuccess bool - -const ( - SSLCertificatePackDeleteResponseEnvelopeSuccessTrue SSLCertificatePackDeleteResponseEnvelopeSuccess = true -) - -type SSLCertificatePackEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type SSLCertificatePackEditResponseEnvelope struct { - Errors []SSLCertificatePackEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SSLCertificatePackEditResponseEnvelopeMessages `json:"messages,required"` - Result SSLCertificatePackEditResponse `json:"result,required"` - // Whether the API call was successful - Success SSLCertificatePackEditResponseEnvelopeSuccess `json:"success,required"` - JSON sslCertificatePackEditResponseEnvelopeJSON `json:"-"` -} - -// sslCertificatePackEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [SSLCertificatePackEditResponseEnvelope] -type sslCertificatePackEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SSLCertificatePackEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslCertificatePackEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// sslCertificatePackEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SSLCertificatePackEditResponseEnvelopeErrors] -type sslCertificatePackEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SSLCertificatePackEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslCertificatePackEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// sslCertificatePackEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SSLCertificatePackEditResponseEnvelopeMessages] -type sslCertificatePackEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SSLCertificatePackEditResponseEnvelopeSuccess bool - -const ( - SSLCertificatePackEditResponseEnvelopeSuccessTrue SSLCertificatePackEditResponseEnvelopeSuccess = true -) - -type SSLCertificatePackGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type SSLCertificatePackGetResponseEnvelope struct { - Errors []SSLCertificatePackGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SSLCertificatePackGetResponseEnvelopeMessages `json:"messages,required"` - Result SSLCertificatePackGetResponse `json:"result,required"` - // Whether the API call was successful - Success SSLCertificatePackGetResponseEnvelopeSuccess `json:"success,required"` - JSON sslCertificatePackGetResponseEnvelopeJSON `json:"-"` -} - -// sslCertificatePackGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [SSLCertificatePackGetResponseEnvelope] -type sslCertificatePackGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SSLCertificatePackGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslCertificatePackGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// sslCertificatePackGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SSLCertificatePackGetResponseEnvelopeErrors] -type sslCertificatePackGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SSLCertificatePackGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslCertificatePackGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// sslCertificatePackGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SSLCertificatePackGetResponseEnvelopeMessages] -type sslCertificatePackGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SSLCertificatePackGetResponseEnvelopeSuccess bool - -const ( - SSLCertificatePackGetResponseEnvelopeSuccessTrue SSLCertificatePackGetResponseEnvelopeSuccess = true -) diff --git a/sslcertificatepack_test.go b/sslcertificatepack_test.go deleted file mode 100644 index e4fafbded8c..00000000000 --- a/sslcertificatepack_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSSLCertificatePackListWithOptionalParams(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("user@example.com"), - ) - _, err := client.SSL.CertificatePacks.List(context.TODO(), cloudflare.SSLCertificatePackListParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Status: cloudflare.F(cloudflare.SSLCertificatePackListParamsStatusAll), - }) - 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 TestSSLCertificatePackDelete(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("user@example.com"), - ) - _, err := client.SSL.CertificatePacks.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.SSLCertificatePackDeleteParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestSSLCertificatePackEdit(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("user@example.com"), - ) - _, err := client.SSL.CertificatePacks.Edit( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.SSLCertificatePackEditParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestSSLCertificatePackGet(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("user@example.com"), - ) - _, err := client.SSL.CertificatePacks.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.SSLCertificatePackGetParams{ - ZoneID: cloudflare.F("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/sslcertificatepackorder.go b/sslcertificatepackorder.go deleted file mode 100644 index 4a553dd9f7c..00000000000 --- a/sslcertificatepackorder.go +++ /dev/null @@ -1,297 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SSLCertificatePackOrderService 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 -// [NewSSLCertificatePackOrderService] method instead. -type SSLCertificatePackOrderService struct { - Options []option.RequestOption -} - -// NewSSLCertificatePackOrderService 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 NewSSLCertificatePackOrderService(opts ...option.RequestOption) (r *SSLCertificatePackOrderService) { - r = &SSLCertificatePackOrderService{} - r.Options = opts - return -} - -// For a given zone, order an advanced certificate pack. -func (r *SSLCertificatePackOrderService) New(ctx context.Context, params SSLCertificatePackOrderNewParams, opts ...option.RequestOption) (res *SSLCertificatePackOrderNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env SSLCertificatePackOrderNewResponseEnvelope - path := fmt.Sprintf("zones/%s/ssl/certificate_packs/order", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SSLCertificatePackOrderNewResponse struct { - // Identifier - ID string `json:"id"` - // Certificate Authority selected for the order. For information on any certificate - // authority specific details or restrictions - // [see this page for more details.](https://developers.cloudflare.com/ssl/reference/certificate-authorities) - CertificateAuthority SSLCertificatePackOrderNewResponseCertificateAuthority `json:"certificate_authority"` - // Whether or not to add Cloudflare Branding for the order. This will add - // sni.cloudflaressl.com as the Common Name if set true. - CloudflareBranding bool `json:"cloudflare_branding"` - // Comma separated list of valid host names for the certificate packs. Must contain - // the zone apex, may not contain more than 50 hosts, and may not be empty. - Hosts []string `json:"hosts"` - // Status of certificate pack. - Status SSLCertificatePackOrderNewResponseStatus `json:"status"` - // Type of certificate pack. - Type SSLCertificatePackOrderNewResponseType `json:"type"` - // Validation Method selected for the order. - ValidationMethod SSLCertificatePackOrderNewResponseValidationMethod `json:"validation_method"` - // Validity Days selected for the order. - ValidityDays SSLCertificatePackOrderNewResponseValidityDays `json:"validity_days"` - JSON sslCertificatePackOrderNewResponseJSON `json:"-"` -} - -// sslCertificatePackOrderNewResponseJSON contains the JSON metadata for the struct -// [SSLCertificatePackOrderNewResponse] -type sslCertificatePackOrderNewResponseJSON struct { - ID apijson.Field - CertificateAuthority apijson.Field - CloudflareBranding apijson.Field - Hosts apijson.Field - Status apijson.Field - Type apijson.Field - ValidationMethod apijson.Field - ValidityDays apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackOrderNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackOrderNewResponseJSON) RawJSON() string { - return r.raw -} - -// Certificate Authority selected for the order. For information on any certificate -// authority specific details or restrictions -// [see this page for more details.](https://developers.cloudflare.com/ssl/reference/certificate-authorities) -type SSLCertificatePackOrderNewResponseCertificateAuthority string - -const ( - SSLCertificatePackOrderNewResponseCertificateAuthorityGoogle SSLCertificatePackOrderNewResponseCertificateAuthority = "google" - SSLCertificatePackOrderNewResponseCertificateAuthorityLetsEncrypt SSLCertificatePackOrderNewResponseCertificateAuthority = "lets_encrypt" -) - -// Status of certificate pack. -type SSLCertificatePackOrderNewResponseStatus string - -const ( - SSLCertificatePackOrderNewResponseStatusInitializing SSLCertificatePackOrderNewResponseStatus = "initializing" - SSLCertificatePackOrderNewResponseStatusPendingValidation SSLCertificatePackOrderNewResponseStatus = "pending_validation" - SSLCertificatePackOrderNewResponseStatusDeleted SSLCertificatePackOrderNewResponseStatus = "deleted" - SSLCertificatePackOrderNewResponseStatusPendingIssuance SSLCertificatePackOrderNewResponseStatus = "pending_issuance" - SSLCertificatePackOrderNewResponseStatusPendingDeployment SSLCertificatePackOrderNewResponseStatus = "pending_deployment" - SSLCertificatePackOrderNewResponseStatusPendingDeletion SSLCertificatePackOrderNewResponseStatus = "pending_deletion" - SSLCertificatePackOrderNewResponseStatusPendingExpiration SSLCertificatePackOrderNewResponseStatus = "pending_expiration" - SSLCertificatePackOrderNewResponseStatusExpired SSLCertificatePackOrderNewResponseStatus = "expired" - SSLCertificatePackOrderNewResponseStatusActive SSLCertificatePackOrderNewResponseStatus = "active" - SSLCertificatePackOrderNewResponseStatusInitializingTimedOut SSLCertificatePackOrderNewResponseStatus = "initializing_timed_out" - SSLCertificatePackOrderNewResponseStatusValidationTimedOut SSLCertificatePackOrderNewResponseStatus = "validation_timed_out" - SSLCertificatePackOrderNewResponseStatusIssuanceTimedOut SSLCertificatePackOrderNewResponseStatus = "issuance_timed_out" - SSLCertificatePackOrderNewResponseStatusDeploymentTimedOut SSLCertificatePackOrderNewResponseStatus = "deployment_timed_out" - SSLCertificatePackOrderNewResponseStatusDeletionTimedOut SSLCertificatePackOrderNewResponseStatus = "deletion_timed_out" - SSLCertificatePackOrderNewResponseStatusPendingCleanup SSLCertificatePackOrderNewResponseStatus = "pending_cleanup" - SSLCertificatePackOrderNewResponseStatusStagingDeployment SSLCertificatePackOrderNewResponseStatus = "staging_deployment" - SSLCertificatePackOrderNewResponseStatusStagingActive SSLCertificatePackOrderNewResponseStatus = "staging_active" - SSLCertificatePackOrderNewResponseStatusDeactivating SSLCertificatePackOrderNewResponseStatus = "deactivating" - SSLCertificatePackOrderNewResponseStatusInactive SSLCertificatePackOrderNewResponseStatus = "inactive" - SSLCertificatePackOrderNewResponseStatusBackupIssued SSLCertificatePackOrderNewResponseStatus = "backup_issued" - SSLCertificatePackOrderNewResponseStatusHoldingDeployment SSLCertificatePackOrderNewResponseStatus = "holding_deployment" -) - -// Type of certificate pack. -type SSLCertificatePackOrderNewResponseType string - -const ( - SSLCertificatePackOrderNewResponseTypeAdvanced SSLCertificatePackOrderNewResponseType = "advanced" -) - -// Validation Method selected for the order. -type SSLCertificatePackOrderNewResponseValidationMethod string - -const ( - SSLCertificatePackOrderNewResponseValidationMethodTXT SSLCertificatePackOrderNewResponseValidationMethod = "txt" - SSLCertificatePackOrderNewResponseValidationMethodHTTP SSLCertificatePackOrderNewResponseValidationMethod = "http" - SSLCertificatePackOrderNewResponseValidationMethodEmail SSLCertificatePackOrderNewResponseValidationMethod = "email" -) - -// Validity Days selected for the order. -type SSLCertificatePackOrderNewResponseValidityDays int64 - -const ( - SSLCertificatePackOrderNewResponseValidityDays14 SSLCertificatePackOrderNewResponseValidityDays = 14 - SSLCertificatePackOrderNewResponseValidityDays30 SSLCertificatePackOrderNewResponseValidityDays = 30 - SSLCertificatePackOrderNewResponseValidityDays90 SSLCertificatePackOrderNewResponseValidityDays = 90 - SSLCertificatePackOrderNewResponseValidityDays365 SSLCertificatePackOrderNewResponseValidityDays = 365 -) - -type SSLCertificatePackOrderNewParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Certificate Authority selected for the order. For information on any certificate - // authority specific details or restrictions - // [see this page for more details.](https://developers.cloudflare.com/ssl/reference/certificate-authorities) - CertificateAuthority param.Field[SSLCertificatePackOrderNewParamsCertificateAuthority] `json:"certificate_authority,required"` - // Comma separated list of valid host names for the certificate packs. Must contain - // the zone apex, may not contain more than 50 hosts, and may not be empty. - Hosts param.Field[[]string] `json:"hosts,required"` - // Type of certificate pack. - Type param.Field[SSLCertificatePackOrderNewParamsType] `json:"type,required"` - // Validation Method selected for the order. - ValidationMethod param.Field[SSLCertificatePackOrderNewParamsValidationMethod] `json:"validation_method,required"` - // Validity Days selected for the order. - ValidityDays param.Field[SSLCertificatePackOrderNewParamsValidityDays] `json:"validity_days,required"` - // Whether or not to add Cloudflare Branding for the order. This will add - // sni.cloudflaressl.com as the Common Name if set true. - CloudflareBranding param.Field[bool] `json:"cloudflare_branding"` -} - -func (r SSLCertificatePackOrderNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Certificate Authority selected for the order. For information on any certificate -// authority specific details or restrictions -// [see this page for more details.](https://developers.cloudflare.com/ssl/reference/certificate-authorities) -type SSLCertificatePackOrderNewParamsCertificateAuthority string - -const ( - SSLCertificatePackOrderNewParamsCertificateAuthorityGoogle SSLCertificatePackOrderNewParamsCertificateAuthority = "google" - SSLCertificatePackOrderNewParamsCertificateAuthorityLetsEncrypt SSLCertificatePackOrderNewParamsCertificateAuthority = "lets_encrypt" -) - -// Type of certificate pack. -type SSLCertificatePackOrderNewParamsType string - -const ( - SSLCertificatePackOrderNewParamsTypeAdvanced SSLCertificatePackOrderNewParamsType = "advanced" -) - -// Validation Method selected for the order. -type SSLCertificatePackOrderNewParamsValidationMethod string - -const ( - SSLCertificatePackOrderNewParamsValidationMethodTXT SSLCertificatePackOrderNewParamsValidationMethod = "txt" - SSLCertificatePackOrderNewParamsValidationMethodHTTP SSLCertificatePackOrderNewParamsValidationMethod = "http" - SSLCertificatePackOrderNewParamsValidationMethodEmail SSLCertificatePackOrderNewParamsValidationMethod = "email" -) - -// Validity Days selected for the order. -type SSLCertificatePackOrderNewParamsValidityDays int64 - -const ( - SSLCertificatePackOrderNewParamsValidityDays14 SSLCertificatePackOrderNewParamsValidityDays = 14 - SSLCertificatePackOrderNewParamsValidityDays30 SSLCertificatePackOrderNewParamsValidityDays = 30 - SSLCertificatePackOrderNewParamsValidityDays90 SSLCertificatePackOrderNewParamsValidityDays = 90 - SSLCertificatePackOrderNewParamsValidityDays365 SSLCertificatePackOrderNewParamsValidityDays = 365 -) - -type SSLCertificatePackOrderNewResponseEnvelope struct { - Errors []SSLCertificatePackOrderNewResponseEnvelopeErrors `json:"errors,required"` - Messages []SSLCertificatePackOrderNewResponseEnvelopeMessages `json:"messages,required"` - Result SSLCertificatePackOrderNewResponse `json:"result,required"` - // Whether the API call was successful - Success SSLCertificatePackOrderNewResponseEnvelopeSuccess `json:"success,required"` - JSON sslCertificatePackOrderNewResponseEnvelopeJSON `json:"-"` -} - -// sslCertificatePackOrderNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [SSLCertificatePackOrderNewResponseEnvelope] -type sslCertificatePackOrderNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackOrderNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackOrderNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SSLCertificatePackOrderNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslCertificatePackOrderNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// sslCertificatePackOrderNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SSLCertificatePackOrderNewResponseEnvelopeErrors] -type sslCertificatePackOrderNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackOrderNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackOrderNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SSLCertificatePackOrderNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslCertificatePackOrderNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// sslCertificatePackOrderNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SSLCertificatePackOrderNewResponseEnvelopeMessages] -type sslCertificatePackOrderNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackOrderNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackOrderNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SSLCertificatePackOrderNewResponseEnvelopeSuccess bool - -const ( - SSLCertificatePackOrderNewResponseEnvelopeSuccessTrue SSLCertificatePackOrderNewResponseEnvelopeSuccess = true -) diff --git a/sslcertificatepackorder_test.go b/sslcertificatepackorder_test.go deleted file mode 100644 index fe81cb35f56..00000000000 --- a/sslcertificatepackorder_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSSLCertificatePackOrderNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.SSL.CertificatePacks.Order.New(context.TODO(), cloudflare.SSLCertificatePackOrderNewParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - CertificateAuthority: cloudflare.F(cloudflare.SSLCertificatePackOrderNewParamsCertificateAuthorityLetsEncrypt), - Hosts: cloudflare.F([]string{"example.com", "*.example.com", "www.example.com"}), - Type: cloudflare.F(cloudflare.SSLCertificatePackOrderNewParamsTypeAdvanced), - ValidationMethod: cloudflare.F(cloudflare.SSLCertificatePackOrderNewParamsValidationMethodTXT), - ValidityDays: cloudflare.F(cloudflare.SSLCertificatePackOrderNewParamsValidityDays14), - CloudflareBranding: cloudflare.F(false), - }) - 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/sslcertificatepackquota.go b/sslcertificatepackquota.go deleted file mode 100644 index dd4b3e34133..00000000000 --- a/sslcertificatepackquota.go +++ /dev/null @@ -1,177 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SSLCertificatePackQuotaService 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 -// [NewSSLCertificatePackQuotaService] method instead. -type SSLCertificatePackQuotaService struct { - Options []option.RequestOption -} - -// NewSSLCertificatePackQuotaService 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 NewSSLCertificatePackQuotaService(opts ...option.RequestOption) (r *SSLCertificatePackQuotaService) { - r = &SSLCertificatePackQuotaService{} - r.Options = opts - return -} - -// For a given zone, list certificate pack quotas. -func (r *SSLCertificatePackQuotaService) Get(ctx context.Context, query SSLCertificatePackQuotaGetParams, opts ...option.RequestOption) (res *SSLCertificatePackQuotaGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env SSLCertificatePackQuotaGetResponseEnvelope - path := fmt.Sprintf("zones/%s/ssl/certificate_packs/quota", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SSLCertificatePackQuotaGetResponse struct { - Advanced SSLCertificatePackQuotaGetResponseAdvanced `json:"advanced"` - JSON sslCertificatePackQuotaGetResponseJSON `json:"-"` -} - -// sslCertificatePackQuotaGetResponseJSON contains the JSON metadata for the struct -// [SSLCertificatePackQuotaGetResponse] -type sslCertificatePackQuotaGetResponseJSON struct { - Advanced apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackQuotaGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackQuotaGetResponseJSON) RawJSON() string { - return r.raw -} - -type SSLCertificatePackQuotaGetResponseAdvanced struct { - // Quantity Allocated. - Allocated int64 `json:"allocated"` - // Quantity Used. - Used int64 `json:"used"` - JSON sslCertificatePackQuotaGetResponseAdvancedJSON `json:"-"` -} - -// sslCertificatePackQuotaGetResponseAdvancedJSON contains the JSON metadata for -// the struct [SSLCertificatePackQuotaGetResponseAdvanced] -type sslCertificatePackQuotaGetResponseAdvancedJSON struct { - Allocated apijson.Field - Used apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackQuotaGetResponseAdvanced) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackQuotaGetResponseAdvancedJSON) RawJSON() string { - return r.raw -} - -type SSLCertificatePackQuotaGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type SSLCertificatePackQuotaGetResponseEnvelope struct { - Errors []SSLCertificatePackQuotaGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SSLCertificatePackQuotaGetResponseEnvelopeMessages `json:"messages,required"` - Result SSLCertificatePackQuotaGetResponse `json:"result,required"` - // Whether the API call was successful - Success SSLCertificatePackQuotaGetResponseEnvelopeSuccess `json:"success,required"` - JSON sslCertificatePackQuotaGetResponseEnvelopeJSON `json:"-"` -} - -// sslCertificatePackQuotaGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [SSLCertificatePackQuotaGetResponseEnvelope] -type sslCertificatePackQuotaGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackQuotaGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackQuotaGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SSLCertificatePackQuotaGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslCertificatePackQuotaGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// sslCertificatePackQuotaGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [SSLCertificatePackQuotaGetResponseEnvelopeErrors] -type sslCertificatePackQuotaGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackQuotaGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackQuotaGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SSLCertificatePackQuotaGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslCertificatePackQuotaGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// sslCertificatePackQuotaGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [SSLCertificatePackQuotaGetResponseEnvelopeMessages] -type sslCertificatePackQuotaGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLCertificatePackQuotaGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslCertificatePackQuotaGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SSLCertificatePackQuotaGetResponseEnvelopeSuccess bool - -const ( - SSLCertificatePackQuotaGetResponseEnvelopeSuccessTrue SSLCertificatePackQuotaGetResponseEnvelopeSuccess = true -) diff --git a/sslcertificatepackquota_test.go b/sslcertificatepackquota_test.go deleted file mode 100644 index 11991d9ac3d..00000000000 --- a/sslcertificatepackquota_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSSLCertificatePackQuotaGet(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("user@example.com"), - ) - _, err := client.SSL.CertificatePacks.Quota.Get(context.TODO(), cloudflare.SSLCertificatePackQuotaGetParams{ - ZoneID: cloudflare.F("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/sslrecommendation.go b/sslrecommendation.go deleted file mode 100644 index f6414d51ca9..00000000000 --- a/sslrecommendation.go +++ /dev/null @@ -1,160 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SSLRecommendationService 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 [NewSSLRecommendationService] method -// instead. -type SSLRecommendationService struct { - Options []option.RequestOption -} - -// NewSSLRecommendationService 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 NewSSLRecommendationService(opts ...option.RequestOption) (r *SSLRecommendationService) { - r = &SSLRecommendationService{} - r.Options = opts - return -} - -// Retrieve the SSL/TLS Recommender's recommendation for a zone. -func (r *SSLRecommendationService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *SSLRecommendationGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env SSLRecommendationGetResponseEnvelope - path := fmt.Sprintf("zones/%s/ssl/recommendation", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SSLRecommendationGetResponse struct { - // Identifier of a recommedation result. - ID string `json:"id"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - Value SSLRecommendationGetResponseValue `json:"value"` - JSON sslRecommendationGetResponseJSON `json:"-"` -} - -// sslRecommendationGetResponseJSON contains the JSON metadata for the struct -// [SSLRecommendationGetResponse] -type sslRecommendationGetResponseJSON struct { - ID apijson.Field - ModifiedOn apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLRecommendationGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslRecommendationGetResponseJSON) RawJSON() string { - return r.raw -} - -type SSLRecommendationGetResponseValue string - -const ( - SSLRecommendationGetResponseValueFlexible SSLRecommendationGetResponseValue = "flexible" - SSLRecommendationGetResponseValueFull SSLRecommendationGetResponseValue = "full" - SSLRecommendationGetResponseValueStrict SSLRecommendationGetResponseValue = "strict" -) - -type SSLRecommendationGetResponseEnvelope struct { - Errors []SSLRecommendationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SSLRecommendationGetResponseEnvelopeMessages `json:"messages,required"` - Result SSLRecommendationGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success SSLRecommendationGetResponseEnvelopeSuccess `json:"success,required"` - JSON sslRecommendationGetResponseEnvelopeJSON `json:"-"` -} - -// sslRecommendationGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [SSLRecommendationGetResponseEnvelope] -type sslRecommendationGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLRecommendationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslRecommendationGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SSLRecommendationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslRecommendationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// sslRecommendationGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SSLRecommendationGetResponseEnvelopeErrors] -type sslRecommendationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLRecommendationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslRecommendationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SSLRecommendationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslRecommendationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// sslRecommendationGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SSLRecommendationGetResponseEnvelopeMessages] -type sslRecommendationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLRecommendationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslRecommendationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SSLRecommendationGetResponseEnvelopeSuccess bool - -const ( - SSLRecommendationGetResponseEnvelopeSuccessTrue SSLRecommendationGetResponseEnvelopeSuccess = true -) diff --git a/sslrecommendation_test.go b/sslrecommendation_test.go deleted file mode 100644 index a96797cd7bf..00000000000 --- a/sslrecommendation_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSSLRecommendationGet(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("user@example.com"), - ) - _, err := client.SSL.Recommendations.Get(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/ssluniversal.go b/ssluniversal.go deleted file mode 100644 index bdcc94eba05..00000000000 --- a/ssluniversal.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// SSLUniversalService 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 [NewSSLUniversalService] method -// instead. -type SSLUniversalService struct { - Options []option.RequestOption - Settings *SSLUniversalSettingService -} - -// NewSSLUniversalService 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 NewSSLUniversalService(opts ...option.RequestOption) (r *SSLUniversalService) { - r = &SSLUniversalService{} - r.Options = opts - r.Settings = NewSSLUniversalSettingService(opts...) - return -} diff --git a/ssluniversalsetting.go b/ssluniversalsetting.go deleted file mode 100644 index f8cc386ef20..00000000000 --- a/ssluniversalsetting.go +++ /dev/null @@ -1,352 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SSLUniversalSettingService 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 [NewSSLUniversalSettingService] -// method instead. -type SSLUniversalSettingService struct { - Options []option.RequestOption -} - -// NewSSLUniversalSettingService 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 NewSSLUniversalSettingService(opts ...option.RequestOption) (r *SSLUniversalSettingService) { - r = &SSLUniversalSettingService{} - r.Options = opts - return -} - -// Patch Universal SSL Settings for a Zone. -func (r *SSLUniversalSettingService) Edit(ctx context.Context, params SSLUniversalSettingEditParams, opts ...option.RequestOption) (res *SSLUniversalSettingEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env SSLUniversalSettingEditResponseEnvelope - path := fmt.Sprintf("zones/%s/ssl/universal/settings", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get Universal SSL Settings for a Zone. -func (r *SSLUniversalSettingService) Get(ctx context.Context, query SSLUniversalSettingGetParams, opts ...option.RequestOption) (res *SSLUniversalSettingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env SSLUniversalSettingGetResponseEnvelope - path := fmt.Sprintf("zones/%s/ssl/universal/settings", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SSLUniversalSettingEditResponse struct { - // Disabling Universal SSL removes any currently active Universal SSL certificates - // for your zone from the edge and prevents any future Universal SSL certificates - // from being ordered. If there are no advanced certificates or custom certificates - // uploaded for the domain, visitors will be unable to access the domain over - // HTTPS. - // - // By disabling Universal SSL, you understand that the following Cloudflare - // settings and preferences will result in visitors being unable to visit your - // domain unless you have uploaded a custom certificate or purchased an advanced - // certificate. - // - // - HSTS - // - Always Use HTTPS - // - Opportunistic Encryption - // - Onion Routing - // - Any Page Rules redirecting traffic to HTTPS - // - // Similarly, any HTTP redirect to HTTPS at the origin while the Cloudflare proxy - // is enabled will result in users being unable to visit your site without a valid - // certificate at Cloudflare's edge. - // - // If you do not have a valid custom or advanced certificate at Cloudflare's edge - // and are unsure if any of the above Cloudflare settings are enabled, or if any - // HTTP redirects exist at your origin, we advise leaving Universal SSL enabled for - // your domain. - Enabled bool `json:"enabled"` - JSON sslUniversalSettingEditResponseJSON `json:"-"` -} - -// sslUniversalSettingEditResponseJSON contains the JSON metadata for the struct -// [SSLUniversalSettingEditResponse] -type sslUniversalSettingEditResponseJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLUniversalSettingEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslUniversalSettingEditResponseJSON) RawJSON() string { - return r.raw -} - -type SSLUniversalSettingGetResponse struct { - // Disabling Universal SSL removes any currently active Universal SSL certificates - // for your zone from the edge and prevents any future Universal SSL certificates - // from being ordered. If there are no advanced certificates or custom certificates - // uploaded for the domain, visitors will be unable to access the domain over - // HTTPS. - // - // By disabling Universal SSL, you understand that the following Cloudflare - // settings and preferences will result in visitors being unable to visit your - // domain unless you have uploaded a custom certificate or purchased an advanced - // certificate. - // - // - HSTS - // - Always Use HTTPS - // - Opportunistic Encryption - // - Onion Routing - // - Any Page Rules redirecting traffic to HTTPS - // - // Similarly, any HTTP redirect to HTTPS at the origin while the Cloudflare proxy - // is enabled will result in users being unable to visit your site without a valid - // certificate at Cloudflare's edge. - // - // If you do not have a valid custom or advanced certificate at Cloudflare's edge - // and are unsure if any of the above Cloudflare settings are enabled, or if any - // HTTP redirects exist at your origin, we advise leaving Universal SSL enabled for - // your domain. - Enabled bool `json:"enabled"` - JSON sslUniversalSettingGetResponseJSON `json:"-"` -} - -// sslUniversalSettingGetResponseJSON contains the JSON metadata for the struct -// [SSLUniversalSettingGetResponse] -type sslUniversalSettingGetResponseJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLUniversalSettingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslUniversalSettingGetResponseJSON) RawJSON() string { - return r.raw -} - -type SSLUniversalSettingEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Disabling Universal SSL removes any currently active Universal SSL certificates - // for your zone from the edge and prevents any future Universal SSL certificates - // from being ordered. If there are no advanced certificates or custom certificates - // uploaded for the domain, visitors will be unable to access the domain over - // HTTPS. - // - // By disabling Universal SSL, you understand that the following Cloudflare - // settings and preferences will result in visitors being unable to visit your - // domain unless you have uploaded a custom certificate or purchased an advanced - // certificate. - // - // - HSTS - // - Always Use HTTPS - // - Opportunistic Encryption - // - Onion Routing - // - Any Page Rules redirecting traffic to HTTPS - // - // Similarly, any HTTP redirect to HTTPS at the origin while the Cloudflare proxy - // is enabled will result in users being unable to visit your site without a valid - // certificate at Cloudflare's edge. - // - // If you do not have a valid custom or advanced certificate at Cloudflare's edge - // and are unsure if any of the above Cloudflare settings are enabled, or if any - // HTTP redirects exist at your origin, we advise leaving Universal SSL enabled for - // your domain. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r SSLUniversalSettingEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SSLUniversalSettingEditResponseEnvelope struct { - Errors []SSLUniversalSettingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SSLUniversalSettingEditResponseEnvelopeMessages `json:"messages,required"` - Result SSLUniversalSettingEditResponse `json:"result,required"` - // Whether the API call was successful - Success SSLUniversalSettingEditResponseEnvelopeSuccess `json:"success,required"` - JSON sslUniversalSettingEditResponseEnvelopeJSON `json:"-"` -} - -// sslUniversalSettingEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [SSLUniversalSettingEditResponseEnvelope] -type sslUniversalSettingEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLUniversalSettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslUniversalSettingEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SSLUniversalSettingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslUniversalSettingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// sslUniversalSettingEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SSLUniversalSettingEditResponseEnvelopeErrors] -type sslUniversalSettingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLUniversalSettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslUniversalSettingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SSLUniversalSettingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslUniversalSettingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// sslUniversalSettingEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SSLUniversalSettingEditResponseEnvelopeMessages] -type sslUniversalSettingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLUniversalSettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslUniversalSettingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SSLUniversalSettingEditResponseEnvelopeSuccess bool - -const ( - SSLUniversalSettingEditResponseEnvelopeSuccessTrue SSLUniversalSettingEditResponseEnvelopeSuccess = true -) - -type SSLUniversalSettingGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type SSLUniversalSettingGetResponseEnvelope struct { - Errors []SSLUniversalSettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SSLUniversalSettingGetResponseEnvelopeMessages `json:"messages,required"` - Result SSLUniversalSettingGetResponse `json:"result,required"` - // Whether the API call was successful - Success SSLUniversalSettingGetResponseEnvelopeSuccess `json:"success,required"` - JSON sslUniversalSettingGetResponseEnvelopeJSON `json:"-"` -} - -// sslUniversalSettingGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [SSLUniversalSettingGetResponseEnvelope] -type sslUniversalSettingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLUniversalSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslUniversalSettingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SSLUniversalSettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslUniversalSettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// sslUniversalSettingGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [SSLUniversalSettingGetResponseEnvelopeErrors] -type sslUniversalSettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLUniversalSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslUniversalSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SSLUniversalSettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslUniversalSettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// sslUniversalSettingGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [SSLUniversalSettingGetResponseEnvelopeMessages] -type sslUniversalSettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLUniversalSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslUniversalSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SSLUniversalSettingGetResponseEnvelopeSuccess bool - -const ( - SSLUniversalSettingGetResponseEnvelopeSuccessTrue SSLUniversalSettingGetResponseEnvelopeSuccess = true -) diff --git a/ssluniversalsetting_test.go b/ssluniversalsetting_test.go deleted file mode 100644 index 101e7acd282..00000000000 --- a/ssluniversalsetting_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSSLUniversalSettingEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.SSL.Universal.Settings.Edit(context.TODO(), cloudflare.SSLUniversalSettingEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Enabled: cloudflare.F(true), - }) - 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 TestSSLUniversalSettingGet(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("user@example.com"), - ) - _, err := client.SSL.Universal.Settings.Get(context.TODO(), cloudflare.SSLUniversalSettingGetParams{ - ZoneID: cloudflare.F("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/sslverification.go b/sslverification.go deleted file mode 100644 index ac55a7202fe..00000000000 --- a/sslverification.go +++ /dev/null @@ -1,373 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// SSLVerificationService 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 [NewSSLVerificationService] method -// instead. -type SSLVerificationService struct { - Options []option.RequestOption -} - -// NewSSLVerificationService 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 NewSSLVerificationService(opts ...option.RequestOption) (r *SSLVerificationService) { - r = &SSLVerificationService{} - r.Options = opts - return -} - -// Edit SSL validation method for a certificate pack. A PATCH request will request -// an immediate validation check on any certificate, and return the updated status. -// If a validation method is provided, the validation will be immediately attempted -// using that method. -func (r *SSLVerificationService) Edit(ctx context.Context, certificatePackID string, params SSLVerificationEditParams, opts ...option.RequestOption) (res *SSLVerificationEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env SSLVerificationEditResponseEnvelope - path := fmt.Sprintf("zones/%s/ssl/verification/%s", params.ZoneID, certificatePackID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get SSL Verification Info for a Zone. -func (r *SSLVerificationService) Get(ctx context.Context, params SSLVerificationGetParams, opts ...option.RequestOption) (res *[]SSLVerificationGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env SSLVerificationGetResponseEnvelope - path := fmt.Sprintf("zones/%s/ssl/verification", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type SSLVerificationEditResponse struct { - // Result status. - Status string `json:"status"` - // Desired validation method. - ValidationMethod SSLVerificationEditResponseValidationMethod `json:"validation_method"` - JSON sslVerificationEditResponseJSON `json:"-"` -} - -// sslVerificationEditResponseJSON contains the JSON metadata for the struct -// [SSLVerificationEditResponse] -type sslVerificationEditResponseJSON struct { - Status apijson.Field - ValidationMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLVerificationEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslVerificationEditResponseJSON) RawJSON() string { - return r.raw -} - -// Desired validation method. -type SSLVerificationEditResponseValidationMethod string - -const ( - SSLVerificationEditResponseValidationMethodHTTP SSLVerificationEditResponseValidationMethod = "http" - SSLVerificationEditResponseValidationMethodCNAME SSLVerificationEditResponseValidationMethod = "cname" - SSLVerificationEditResponseValidationMethodTXT SSLVerificationEditResponseValidationMethod = "txt" - SSLVerificationEditResponseValidationMethodEmail SSLVerificationEditResponseValidationMethod = "email" -) - -type SSLVerificationGetResponse struct { - // Current status of certificate. - CertificateStatus SSLVerificationGetResponseCertificateStatus `json:"certificate_status,required"` - // Certificate Authority is manually reviewing the order. - BrandCheck bool `json:"brand_check"` - // Certificate Pack UUID. - CertPackUUID string `json:"cert_pack_uuid"` - // Certificate's signature algorithm. - Signature SSLVerificationGetResponseSignature `json:"signature"` - // Validation method in use for a certificate pack order. - ValidationMethod SSLVerificationGetResponseValidationMethod `json:"validation_method"` - // Certificate's required verification information. - VerificationInfo SSLVerificationGetResponseVerificationInfo `json:"verification_info"` - // Status of the required verification information, omitted if verification status - // is unknown. - VerificationStatus bool `json:"verification_status"` - // Method of verification. - VerificationType SSLVerificationGetResponseVerificationType `json:"verification_type"` - JSON sslVerificationGetResponseJSON `json:"-"` -} - -// sslVerificationGetResponseJSON contains the JSON metadata for the struct -// [SSLVerificationGetResponse] -type sslVerificationGetResponseJSON struct { - CertificateStatus apijson.Field - BrandCheck apijson.Field - CertPackUUID apijson.Field - Signature apijson.Field - ValidationMethod apijson.Field - VerificationInfo apijson.Field - VerificationStatus apijson.Field - VerificationType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLVerificationGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslVerificationGetResponseJSON) RawJSON() string { - return r.raw -} - -// Current status of certificate. -type SSLVerificationGetResponseCertificateStatus string - -const ( - SSLVerificationGetResponseCertificateStatusInitializing SSLVerificationGetResponseCertificateStatus = "initializing" - SSLVerificationGetResponseCertificateStatusAuthorizing SSLVerificationGetResponseCertificateStatus = "authorizing" - SSLVerificationGetResponseCertificateStatusActive SSLVerificationGetResponseCertificateStatus = "active" - SSLVerificationGetResponseCertificateStatusExpired SSLVerificationGetResponseCertificateStatus = "expired" - SSLVerificationGetResponseCertificateStatusIssuing SSLVerificationGetResponseCertificateStatus = "issuing" - SSLVerificationGetResponseCertificateStatusTimingOut SSLVerificationGetResponseCertificateStatus = "timing_out" - SSLVerificationGetResponseCertificateStatusPendingDeployment SSLVerificationGetResponseCertificateStatus = "pending_deployment" -) - -// Certificate's signature algorithm. -type SSLVerificationGetResponseSignature string - -const ( - SSLVerificationGetResponseSignatureEcdsaWithSha256 SSLVerificationGetResponseSignature = "ECDSAWithSHA256" - SSLVerificationGetResponseSignatureSha1WithRsa SSLVerificationGetResponseSignature = "SHA1WithRSA" - SSLVerificationGetResponseSignatureSha256WithRsa SSLVerificationGetResponseSignature = "SHA256WithRSA" -) - -// Validation method in use for a certificate pack order. -type SSLVerificationGetResponseValidationMethod string - -const ( - SSLVerificationGetResponseValidationMethodHTTP SSLVerificationGetResponseValidationMethod = "http" - SSLVerificationGetResponseValidationMethodCNAME SSLVerificationGetResponseValidationMethod = "cname" - SSLVerificationGetResponseValidationMethodTXT SSLVerificationGetResponseValidationMethod = "txt" -) - -// Certificate's required verification information. -type SSLVerificationGetResponseVerificationInfo struct { - // Name of CNAME record. - RecordName SSLVerificationGetResponseVerificationInfoRecordName `json:"record_name"` - // Target of CNAME record. - RecordTarget SSLVerificationGetResponseVerificationInfoRecordTarget `json:"record_target"` - JSON sslVerificationGetResponseVerificationInfoJSON `json:"-"` -} - -// sslVerificationGetResponseVerificationInfoJSON contains the JSON metadata for -// the struct [SSLVerificationGetResponseVerificationInfo] -type sslVerificationGetResponseVerificationInfoJSON struct { - RecordName apijson.Field - RecordTarget apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLVerificationGetResponseVerificationInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslVerificationGetResponseVerificationInfoJSON) RawJSON() string { - return r.raw -} - -// Name of CNAME record. -type SSLVerificationGetResponseVerificationInfoRecordName string - -const ( - SSLVerificationGetResponseVerificationInfoRecordNameRecordName SSLVerificationGetResponseVerificationInfoRecordName = "record_name" - SSLVerificationGetResponseVerificationInfoRecordNameHTTPURL SSLVerificationGetResponseVerificationInfoRecordName = "http_url" - SSLVerificationGetResponseVerificationInfoRecordNameCNAME SSLVerificationGetResponseVerificationInfoRecordName = "cname" - SSLVerificationGetResponseVerificationInfoRecordNameTXTName SSLVerificationGetResponseVerificationInfoRecordName = "txt_name" -) - -// Target of CNAME record. -type SSLVerificationGetResponseVerificationInfoRecordTarget string - -const ( - SSLVerificationGetResponseVerificationInfoRecordTargetRecordValue SSLVerificationGetResponseVerificationInfoRecordTarget = "record_value" - SSLVerificationGetResponseVerificationInfoRecordTargetHTTPBody SSLVerificationGetResponseVerificationInfoRecordTarget = "http_body" - SSLVerificationGetResponseVerificationInfoRecordTargetCNAMETarget SSLVerificationGetResponseVerificationInfoRecordTarget = "cname_target" - SSLVerificationGetResponseVerificationInfoRecordTargetTXTValue SSLVerificationGetResponseVerificationInfoRecordTarget = "txt_value" -) - -// Method of verification. -type SSLVerificationGetResponseVerificationType string - -const ( - SSLVerificationGetResponseVerificationTypeCNAME SSLVerificationGetResponseVerificationType = "cname" - SSLVerificationGetResponseVerificationTypeMetaTag SSLVerificationGetResponseVerificationType = "meta tag" -) - -type SSLVerificationEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Desired validation method. - ValidationMethod param.Field[SSLVerificationEditParamsValidationMethod] `json:"validation_method,required"` -} - -func (r SSLVerificationEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Desired validation method. -type SSLVerificationEditParamsValidationMethod string - -const ( - SSLVerificationEditParamsValidationMethodHTTP SSLVerificationEditParamsValidationMethod = "http" - SSLVerificationEditParamsValidationMethodCNAME SSLVerificationEditParamsValidationMethod = "cname" - SSLVerificationEditParamsValidationMethodTXT SSLVerificationEditParamsValidationMethod = "txt" - SSLVerificationEditParamsValidationMethodEmail SSLVerificationEditParamsValidationMethod = "email" -) - -type SSLVerificationEditResponseEnvelope struct { - Errors []SSLVerificationEditResponseEnvelopeErrors `json:"errors,required"` - Messages []SSLVerificationEditResponseEnvelopeMessages `json:"messages,required"` - Result SSLVerificationEditResponse `json:"result,required"` - // Whether the API call was successful - Success SSLVerificationEditResponseEnvelopeSuccess `json:"success,required"` - JSON sslVerificationEditResponseEnvelopeJSON `json:"-"` -} - -// sslVerificationEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [SSLVerificationEditResponseEnvelope] -type sslVerificationEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLVerificationEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslVerificationEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SSLVerificationEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslVerificationEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// sslVerificationEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SSLVerificationEditResponseEnvelopeErrors] -type sslVerificationEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLVerificationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslVerificationEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SSLVerificationEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON sslVerificationEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// sslVerificationEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SSLVerificationEditResponseEnvelopeMessages] -type sslVerificationEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLVerificationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslVerificationEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SSLVerificationEditResponseEnvelopeSuccess bool - -const ( - SSLVerificationEditResponseEnvelopeSuccessTrue SSLVerificationEditResponseEnvelopeSuccess = true -) - -type SSLVerificationGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Immediately retry SSL Verification. - Retry param.Field[SSLVerificationGetParamsRetry] `query:"retry"` -} - -// URLQuery serializes [SSLVerificationGetParams]'s query parameters as -// `url.Values`. -func (r SSLVerificationGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Immediately retry SSL Verification. -type SSLVerificationGetParamsRetry bool - -const ( - SSLVerificationGetParamsRetryTrue SSLVerificationGetParamsRetry = true -) - -type SSLVerificationGetResponseEnvelope struct { - Result []SSLVerificationGetResponse `json:"result"` - JSON sslVerificationGetResponseEnvelopeJSON `json:"-"` -} - -// sslVerificationGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [SSLVerificationGetResponseEnvelope] -type sslVerificationGetResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SSLVerificationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r sslVerificationGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/sslverification_test.go b/sslverification_test.go deleted file mode 100644 index bf069b18b3f..00000000000 --- a/sslverification_test.go +++ /dev/null @@ -1,72 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSSLVerificationEdit(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("user@example.com"), - ) - _, err := client.SSL.Verification.Edit( - context.TODO(), - "a77f8bd7-3b47-46b4-a6f1-75cf98109948", - cloudflare.SSLVerificationEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - ValidationMethod: cloudflare.F(cloudflare.SSLVerificationEditParamsValidationMethodTXT), - }, - ) - 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 TestSSLVerificationGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.SSL.Verification.Get(context.TODO(), cloudflare.SSLVerificationGetParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Retry: cloudflare.F(cloudflare.SSLVerificationGetParamsRetryTrue), - }) - 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/storage/aliases.go b/storage/aliases.go new file mode 100644 index 00000000000..95a4b7db028 --- /dev/null +++ b/storage/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package storage + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/storage/analytics.go b/storage/analytics.go new file mode 100644 index 00000000000..257d5ced87a --- /dev/null +++ b/storage/analytics.go @@ -0,0 +1,609 @@ +// File generated from our OpenAPI spec by Stainless. + +package storage + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AnalyticsService 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 [NewAnalyticsService] method instead. +type AnalyticsService struct { + Options []option.RequestOption +} + +// NewAnalyticsService 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 NewAnalyticsService(opts ...option.RequestOption) (r *AnalyticsService) { + r = &AnalyticsService{} + r.Options = opts + return +} + +// Retrieves Workers KV request metrics for the given account. +func (r *AnalyticsService) List(ctx context.Context, params AnalyticsListParams, opts ...option.RequestOption) (res *WorkersKVSchemasResult, err error) { + opts = append(r.Options[:], opts...) + var env AnalyticsListResponseEnvelope + path := fmt.Sprintf("accounts/%s/storage/analytics", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Retrieves Workers KV stored data metrics for the given account. +func (r *AnalyticsService) Stored(ctx context.Context, params AnalyticsStoredParams, opts ...option.RequestOption) (res *WorkersKVComponentsSchemasResult, err error) { + opts = append(r.Options[:], opts...) + var env AnalyticsStoredResponseEnvelope + path := fmt.Sprintf("accounts/%s/storage/analytics/stored", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Metrics on Workers KV requests. +type WorkersKVComponentsSchemasResult struct { + Data []WorkersKVComponentsSchemasResultData `json:"data,required,nullable"` + // Number of seconds between current time and last processed event, i.e. how many + // seconds of data could be missing. + DataLag float64 `json:"data_lag,required"` + // Maximum results for each metric. + Max interface{} `json:"max,required"` + // Minimum results for each metric. + Min interface{} `json:"min,required"` + // For specifying result metrics. + Query WorkersKVComponentsSchemasResultQuery `json:"query,required"` + // Total number of rows in the result. + Rows float64 `json:"rows,required"` + // Total results for metrics across all data. + Totals interface{} `json:"totals,required"` + JSON workersKVComponentsSchemasResultJSON `json:"-"` +} + +// workersKVComponentsSchemasResultJSON contains the JSON metadata for the struct +// [WorkersKVComponentsSchemasResult] +type workersKVComponentsSchemasResultJSON struct { + Data apijson.Field + DataLag apijson.Field + Max apijson.Field + Min apijson.Field + Query apijson.Field + Rows apijson.Field + Totals apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersKVComponentsSchemasResult) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersKVComponentsSchemasResultJSON) RawJSON() string { + return r.raw +} + +type WorkersKVComponentsSchemasResultData struct { + // List of metrics returned by the query. + Metrics []interface{} `json:"metrics,required"` + JSON workersKVComponentsSchemasResultDataJSON `json:"-"` +} + +// workersKVComponentsSchemasResultDataJSON contains the JSON metadata for the +// struct [WorkersKVComponentsSchemasResultData] +type workersKVComponentsSchemasResultDataJSON struct { + Metrics apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersKVComponentsSchemasResultData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersKVComponentsSchemasResultDataJSON) RawJSON() string { + return r.raw +} + +// For specifying result metrics. +type WorkersKVComponentsSchemasResultQuery struct { + // Can be used to break down the data by given attributes. + Dimensions []string `json:"dimensions"` + // Used to filter rows by one or more dimensions. Filters can be combined using OR + // and AND boolean logic. AND takes precedence over OR in all the expressions. The + // OR operator is defined using a comma (,) or OR keyword surrounded by whitespace. + // The AND operator is defined using a semicolon (;) or AND keyword surrounded by + // whitespace. Note that the semicolon is a reserved character in URLs (rfc1738) + // and needs to be percent-encoded as %3B. Comparison options are: + // + // | Operator | Name | URL Encoded | + // | -------- | ------------------------ | ----------- | + // | == | Equals | %3D%3D | + // | != | Does not equals | !%3D | + // | > | Greater Than | %3E | + // | < | Less Than | %3C | + // | >= | Greater than or equal to | %3E%3D | + // | <= | Less than or equal to | %3C%3D . | + Filters string `json:"filters"` + // Limit number of returned metrics. + Limit int64 `json:"limit"` + // One or more metrics to compute. + Metrics []string `json:"metrics"` + // Start of time interval to query, defaults to 6 hours before request received. + Since time.Time `json:"since" format:"date-time"` + // Array of dimensions or metrics to sort by, each dimension/metric may be prefixed + // by - (descending) or + (ascending). + Sort []interface{} `json:"sort"` + // End of time interval to query, defaults to current time. + Until time.Time `json:"until" format:"date-time"` + JSON workersKVComponentsSchemasResultQueryJSON `json:"-"` +} + +// workersKVComponentsSchemasResultQueryJSON contains the JSON metadata for the +// struct [WorkersKVComponentsSchemasResultQuery] +type workersKVComponentsSchemasResultQueryJSON struct { + Dimensions apijson.Field + Filters apijson.Field + Limit apijson.Field + Metrics apijson.Field + Since apijson.Field + Sort apijson.Field + Until apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersKVComponentsSchemasResultQuery) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersKVComponentsSchemasResultQueryJSON) RawJSON() string { + return r.raw +} + +// Metrics on Workers KV requests. +type WorkersKVSchemasResult struct { + Data []WorkersKVSchemasResultData `json:"data,required,nullable"` + // Number of seconds between current time and last processed event, i.e. how many + // seconds of data could be missing. + DataLag float64 `json:"data_lag,required"` + // Maximum results for each metric. + Max interface{} `json:"max,required"` + // Minimum results for each metric. + Min interface{} `json:"min,required"` + // For specifying result metrics. + Query WorkersKVSchemasResultQuery `json:"query,required"` + // Total number of rows in the result. + Rows float64 `json:"rows,required"` + // Total results for metrics across all data. + Totals interface{} `json:"totals,required"` + JSON workersKVSchemasResultJSON `json:"-"` +} + +// workersKVSchemasResultJSON contains the JSON metadata for the struct +// [WorkersKVSchemasResult] +type workersKVSchemasResultJSON struct { + Data apijson.Field + DataLag apijson.Field + Max apijson.Field + Min apijson.Field + Query apijson.Field + Rows apijson.Field + Totals apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersKVSchemasResult) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersKVSchemasResultJSON) RawJSON() string { + return r.raw +} + +type WorkersKVSchemasResultData struct { + // List of metrics returned by the query. + Metrics []interface{} `json:"metrics,required"` + JSON workersKVSchemasResultDataJSON `json:"-"` +} + +// workersKVSchemasResultDataJSON contains the JSON metadata for the struct +// [WorkersKVSchemasResultData] +type workersKVSchemasResultDataJSON struct { + Metrics apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersKVSchemasResultData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersKVSchemasResultDataJSON) RawJSON() string { + return r.raw +} + +// For specifying result metrics. +type WorkersKVSchemasResultQuery struct { + // Can be used to break down the data by given attributes. + Dimensions []string `json:"dimensions"` + // Used to filter rows by one or more dimensions. Filters can be combined using OR + // and AND boolean logic. AND takes precedence over OR in all the expressions. The + // OR operator is defined using a comma (,) or OR keyword surrounded by whitespace. + // The AND operator is defined using a semicolon (;) or AND keyword surrounded by + // whitespace. Note that the semicolon is a reserved character in URLs (rfc1738) + // and needs to be percent-encoded as %3B. Comparison options are: + // + // | Operator | Name | URL Encoded | + // | -------- | ------------------------ | ----------- | + // | == | Equals | %3D%3D | + // | != | Does not equals | !%3D | + // | > | Greater Than | %3E | + // | < | Less Than | %3C | + // | >= | Greater than or equal to | %3E%3D | + // | <= | Less than or equal to | %3C%3D . | + Filters string `json:"filters"` + // Limit number of returned metrics. + Limit int64 `json:"limit"` + // One or more metrics to compute. + Metrics []string `json:"metrics"` + // Start of time interval to query, defaults to 6 hours before request received. + Since time.Time `json:"since" format:"date-time"` + // Array of dimensions or metrics to sort by, each dimension/metric may be prefixed + // by - (descending) or + (ascending). + Sort []interface{} `json:"sort"` + // End of time interval to query, defaults to current time. + Until time.Time `json:"until" format:"date-time"` + JSON workersKVSchemasResultQueryJSON `json:"-"` +} + +// workersKVSchemasResultQueryJSON contains the JSON metadata for the struct +// [WorkersKVSchemasResultQuery] +type workersKVSchemasResultQueryJSON struct { + Dimensions apijson.Field + Filters apijson.Field + Limit apijson.Field + Metrics apijson.Field + Since apijson.Field + Sort apijson.Field + Until apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersKVSchemasResultQuery) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersKVSchemasResultQueryJSON) RawJSON() string { + return r.raw +} + +type AnalyticsListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // For specifying result metrics. + Query param.Field[AnalyticsListParamsQuery] `query:"query"` +} + +// URLQuery serializes [AnalyticsListParams]'s query parameters as `url.Values`. +func (r AnalyticsListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// For specifying result metrics. +type AnalyticsListParamsQuery struct { + // Can be used to break down the data by given attributes. + Dimensions param.Field[[]AnalyticsListParamsQueryDimension] `query:"dimensions"` + // Used to filter rows by one or more dimensions. Filters can be combined using OR + // and AND boolean logic. AND takes precedence over OR in all the expressions. The + // OR operator is defined using a comma (,) or OR keyword surrounded by whitespace. + // The AND operator is defined using a semicolon (;) or AND keyword surrounded by + // whitespace. Note that the semicolon is a reserved character in URLs (rfc1738) + // and needs to be percent-encoded as %3B. Comparison options are: + // + // | Operator | Name | URL Encoded | + // | -------- | ------------------------ | ----------- | + // | == | Equals | %3D%3D | + // | != | Does not equals | !%3D | + // | > | Greater Than | %3E | + // | < | Less Than | %3C | + // | >= | Greater than or equal to | %3E%3D | + // | <= | Less than or equal to | %3C%3D . | + Filters param.Field[string] `query:"filters"` + // Limit number of returned metrics. + Limit param.Field[int64] `query:"limit"` + // One or more metrics to compute. + Metrics param.Field[[]AnalyticsListParamsQueryMetric] `query:"metrics"` + // Start of time interval to query, defaults to 6 hours before request received. + Since param.Field[time.Time] `query:"since" format:"date-time"` + // Array of dimensions or metrics to sort by, each dimension/metric may be prefixed + // by - (descending) or + (ascending). + Sort param.Field[[]interface{}] `query:"sort"` + // End of time interval to query, defaults to current time. + Until param.Field[time.Time] `query:"until" format:"date-time"` +} + +// URLQuery serializes [AnalyticsListParamsQuery]'s query parameters as +// `url.Values`. +func (r AnalyticsListParamsQuery) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// For drilling down on metrics. +type AnalyticsListParamsQueryDimension string + +const ( + AnalyticsListParamsQueryDimensionAccountID AnalyticsListParamsQueryDimension = "accountId" + AnalyticsListParamsQueryDimensionResponseCode AnalyticsListParamsQueryDimension = "responseCode" + AnalyticsListParamsQueryDimensionRequestType AnalyticsListParamsQueryDimension = "requestType" +) + +// A quantitative measurement of KV usage. +type AnalyticsListParamsQueryMetric string + +const ( + AnalyticsListParamsQueryMetricRequests AnalyticsListParamsQueryMetric = "requests" + AnalyticsListParamsQueryMetricWriteKiB AnalyticsListParamsQueryMetric = "writeKiB" + AnalyticsListParamsQueryMetricReadKiB AnalyticsListParamsQueryMetric = "readKiB" +) + +type AnalyticsListResponseEnvelope struct { + Errors []AnalyticsListResponseEnvelopeErrors `json:"errors,required"` + Messages []AnalyticsListResponseEnvelopeMessages `json:"messages,required"` + // Metrics on Workers KV requests. + Result WorkersKVSchemasResult `json:"result,required"` + // Whether the API call was successful + Success AnalyticsListResponseEnvelopeSuccess `json:"success,required"` + JSON analyticsListResponseEnvelopeJSON `json:"-"` +} + +// analyticsListResponseEnvelopeJSON contains the JSON metadata for the struct +// [AnalyticsListResponseEnvelope] +type analyticsListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AnalyticsListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON analyticsListResponseEnvelopeErrorsJSON `json:"-"` +} + +// analyticsListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AnalyticsListResponseEnvelopeErrors] +type analyticsListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AnalyticsListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON analyticsListResponseEnvelopeMessagesJSON `json:"-"` +} + +// analyticsListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AnalyticsListResponseEnvelopeMessages] +type analyticsListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AnalyticsListResponseEnvelopeSuccess bool + +const ( + AnalyticsListResponseEnvelopeSuccessTrue AnalyticsListResponseEnvelopeSuccess = true +) + +type AnalyticsStoredParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // For specifying result metrics. + Query param.Field[AnalyticsStoredParamsQuery] `query:"query"` +} + +// URLQuery serializes [AnalyticsStoredParams]'s query parameters as `url.Values`. +func (r AnalyticsStoredParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// For specifying result metrics. +type AnalyticsStoredParamsQuery struct { + // Can be used to break down the data by given attributes. + Dimensions param.Field[[]AnalyticsStoredParamsQueryDimension] `query:"dimensions"` + // Used to filter rows by one or more dimensions. Filters can be combined using OR + // and AND boolean logic. AND takes precedence over OR in all the expressions. The + // OR operator is defined using a comma (,) or OR keyword surrounded by whitespace. + // The AND operator is defined using a semicolon (;) or AND keyword surrounded by + // whitespace. Note that the semicolon is a reserved character in URLs (rfc1738) + // and needs to be percent-encoded as %3B. Comparison options are: + // + // | Operator | Name | URL Encoded | + // | -------- | ------------------------ | ----------- | + // | == | Equals | %3D%3D | + // | != | Does not equals | !%3D | + // | > | Greater Than | %3E | + // | < | Less Than | %3C | + // | >= | Greater than or equal to | %3E%3D | + // | <= | Less than or equal to | %3C%3D . | + Filters param.Field[string] `query:"filters"` + // Limit number of returned metrics. + Limit param.Field[int64] `query:"limit"` + // One or more metrics to compute. + Metrics param.Field[[]AnalyticsStoredParamsQueryMetric] `query:"metrics"` + // Start of time interval to query, defaults to 6 hours before request received. + Since param.Field[time.Time] `query:"since" format:"date-time"` + // Array of dimensions or metrics to sort by, each dimension/metric may be prefixed + // by - (descending) or + (ascending). + Sort param.Field[[]interface{}] `query:"sort"` + // End of time interval to query, defaults to current time. + Until param.Field[time.Time] `query:"until" format:"date-time"` +} + +// URLQuery serializes [AnalyticsStoredParamsQuery]'s query parameters as +// `url.Values`. +func (r AnalyticsStoredParamsQuery) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// For drilling down on metrics. +type AnalyticsStoredParamsQueryDimension string + +const ( + AnalyticsStoredParamsQueryDimensionNamespaceID AnalyticsStoredParamsQueryDimension = "namespaceId" +) + +// A quantitative measurement of KV usage. +type AnalyticsStoredParamsQueryMetric string + +const ( + AnalyticsStoredParamsQueryMetricStoredBytes AnalyticsStoredParamsQueryMetric = "storedBytes" + AnalyticsStoredParamsQueryMetricStoredKeys AnalyticsStoredParamsQueryMetric = "storedKeys" +) + +type AnalyticsStoredResponseEnvelope struct { + Errors []AnalyticsStoredResponseEnvelopeErrors `json:"errors,required"` + Messages []AnalyticsStoredResponseEnvelopeMessages `json:"messages,required"` + // Metrics on Workers KV requests. + Result WorkersKVComponentsSchemasResult `json:"result,required"` + // Whether the API call was successful + Success AnalyticsStoredResponseEnvelopeSuccess `json:"success,required"` + JSON analyticsStoredResponseEnvelopeJSON `json:"-"` +} + +// analyticsStoredResponseEnvelopeJSON contains the JSON metadata for the struct +// [AnalyticsStoredResponseEnvelope] +type analyticsStoredResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsStoredResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsStoredResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AnalyticsStoredResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON analyticsStoredResponseEnvelopeErrorsJSON `json:"-"` +} + +// analyticsStoredResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AnalyticsStoredResponseEnvelopeErrors] +type analyticsStoredResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsStoredResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsStoredResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AnalyticsStoredResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON analyticsStoredResponseEnvelopeMessagesJSON `json:"-"` +} + +// analyticsStoredResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AnalyticsStoredResponseEnvelopeMessages] +type analyticsStoredResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AnalyticsStoredResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r analyticsStoredResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AnalyticsStoredResponseEnvelopeSuccess bool + +const ( + AnalyticsStoredResponseEnvelopeSuccessTrue AnalyticsStoredResponseEnvelopeSuccess = true +) diff --git a/storage/analytics_test.go b/storage/analytics_test.go new file mode 100644 index 00000000000..b80bf1445ed --- /dev/null +++ b/storage/analytics_test.go @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package storage_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/storage" +) + +func TestAnalyticsListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Storage.Analytics.List(context.TODO(), storage.AnalyticsListParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Query: cloudflare.F(storage.AnalyticsListParamsQuery{ + Dimensions: cloudflare.F([]storage.AnalyticsListParamsQueryDimension{storage.AnalyticsListParamsQueryDimensionAccountID, storage.AnalyticsListParamsQueryDimensionResponseCode, storage.AnalyticsListParamsQueryDimensionRequestType}), + Filters: cloudflare.F("requestType==read AND responseCode!=200"), + Limit: cloudflare.F(int64(0)), + Metrics: cloudflare.F([]storage.AnalyticsListParamsQueryMetric{storage.AnalyticsListParamsQueryMetricRequests, storage.AnalyticsListParamsQueryMetricWriteKiB, storage.AnalyticsListParamsQueryMetricReadKiB}), + Since: cloudflare.F(time.Now()), + Sort: cloudflare.F([]interface{}{"+requests", "-responseCode"}), + Until: cloudflare.F(time.Now()), + }), + }) + 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 TestAnalyticsStoredWithOptionalParams(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("user@example.com"), + ) + _, err := client.Storage.Analytics.Stored(context.TODO(), storage.AnalyticsStoredParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Query: cloudflare.F(storage.AnalyticsStoredParamsQuery{ + Dimensions: cloudflare.F([]storage.AnalyticsStoredParamsQueryDimension{storage.AnalyticsStoredParamsQueryDimensionNamespaceID}), + Filters: cloudflare.F("namespaceId==a4e8cbb7-1b58-4990-925e-e026d40c4c64"), + Limit: cloudflare.F(int64(0)), + Metrics: cloudflare.F([]storage.AnalyticsStoredParamsQueryMetric{storage.AnalyticsStoredParamsQueryMetricStoredBytes, storage.AnalyticsStoredParamsQueryMetricStoredKeys}), + Since: cloudflare.F(time.Now()), + Sort: cloudflare.F([]interface{}{"+storedBytes", "-namespaceId"}), + Until: cloudflare.F(time.Now()), + }), + }) + 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/storage.go b/storage/storage.go similarity index 88% rename from storage.go rename to storage/storage.go index 50a558c3103..c0f063081c4 100644 --- a/storage.go +++ b/storage/storage.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package storage import ( "github.com/cloudflare/cloudflare-go/option" @@ -12,7 +12,7 @@ import ( // service directly, and instead use the [NewStorageService] method instead. type StorageService struct { Options []option.RequestOption - Analytics *StorageAnalyticsService + Analytics *AnalyticsService } // NewStorageService generates a new service that applies the given options to each @@ -21,6 +21,6 @@ type StorageService struct { func NewStorageService(opts ...option.RequestOption) (r *StorageService) { r = &StorageService{} r.Options = opts - r.Analytics = NewStorageAnalyticsService(opts...) + r.Analytics = NewAnalyticsService(opts...) return } diff --git a/storageanalytics.go b/storageanalytics.go deleted file mode 100644 index 6db766a75b8..00000000000 --- a/storageanalytics.go +++ /dev/null @@ -1,612 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// StorageAnalyticsService 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 [NewStorageAnalyticsService] method -// instead. -type StorageAnalyticsService struct { - Options []option.RequestOption -} - -// NewStorageAnalyticsService 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 NewStorageAnalyticsService(opts ...option.RequestOption) (r *StorageAnalyticsService) { - r = &StorageAnalyticsService{} - r.Options = opts - return -} - -// Retrieves Workers KV request metrics for the given account. -func (r *StorageAnalyticsService) List(ctx context.Context, params StorageAnalyticsListParams, opts ...option.RequestOption) (res *StorageAnalyticsListResponse, err error) { - opts = append(r.Options[:], opts...) - var env StorageAnalyticsListResponseEnvelope - path := fmt.Sprintf("accounts/%s/storage/analytics", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Retrieves Workers KV stored data metrics for the given account. -func (r *StorageAnalyticsService) Stored(ctx context.Context, params StorageAnalyticsStoredParams, opts ...option.RequestOption) (res *StorageAnalyticsStoredResponse, err error) { - opts = append(r.Options[:], opts...) - var env StorageAnalyticsStoredResponseEnvelope - path := fmt.Sprintf("accounts/%s/storage/analytics/stored", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Metrics on Workers KV requests. -type StorageAnalyticsListResponse struct { - Data []StorageAnalyticsListResponseData `json:"data,required,nullable"` - // Number of seconds between current time and last processed event, i.e. how many - // seconds of data could be missing. - DataLag float64 `json:"data_lag,required"` - // Maximum results for each metric. - Max interface{} `json:"max,required"` - // Minimum results for each metric. - Min interface{} `json:"min,required"` - // For specifying result metrics. - Query StorageAnalyticsListResponseQuery `json:"query,required"` - // Total number of rows in the result. - Rows float64 `json:"rows,required"` - // Total results for metrics across all data. - Totals interface{} `json:"totals,required"` - JSON storageAnalyticsListResponseJSON `json:"-"` -} - -// storageAnalyticsListResponseJSON contains the JSON metadata for the struct -// [StorageAnalyticsListResponse] -type storageAnalyticsListResponseJSON struct { - Data apijson.Field - DataLag apijson.Field - Max apijson.Field - Min apijson.Field - Query apijson.Field - Rows apijson.Field - Totals apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StorageAnalyticsListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r storageAnalyticsListResponseJSON) RawJSON() string { - return r.raw -} - -type StorageAnalyticsListResponseData struct { - // List of metrics returned by the query. - Metrics []interface{} `json:"metrics,required"` - JSON storageAnalyticsListResponseDataJSON `json:"-"` -} - -// storageAnalyticsListResponseDataJSON contains the JSON metadata for the struct -// [StorageAnalyticsListResponseData] -type storageAnalyticsListResponseDataJSON struct { - Metrics apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StorageAnalyticsListResponseData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r storageAnalyticsListResponseDataJSON) RawJSON() string { - return r.raw -} - -// For specifying result metrics. -type StorageAnalyticsListResponseQuery struct { - // Can be used to break down the data by given attributes. - Dimensions []string `json:"dimensions"` - // Used to filter rows by one or more dimensions. Filters can be combined using OR - // and AND boolean logic. AND takes precedence over OR in all the expressions. The - // OR operator is defined using a comma (,) or OR keyword surrounded by whitespace. - // The AND operator is defined using a semicolon (;) or AND keyword surrounded by - // whitespace. Note that the semicolon is a reserved character in URLs (rfc1738) - // and needs to be percent-encoded as %3B. Comparison options are: - // - // | Operator | Name | URL Encoded | - // | -------- | ------------------------ | ----------- | - // | == | Equals | %3D%3D | - // | != | Does not equals | !%3D | - // | > | Greater Than | %3E | - // | < | Less Than | %3C | - // | >= | Greater than or equal to | %3E%3D | - // | <= | Less than or equal to | %3C%3D . | - Filters string `json:"filters"` - // Limit number of returned metrics. - Limit int64 `json:"limit"` - // One or more metrics to compute. - Metrics []string `json:"metrics"` - // Start of time interval to query, defaults to 6 hours before request received. - Since time.Time `json:"since" format:"date-time"` - // Array of dimensions or metrics to sort by, each dimension/metric may be prefixed - // by - (descending) or + (ascending). - Sort []interface{} `json:"sort"` - // End of time interval to query, defaults to current time. - Until time.Time `json:"until" format:"date-time"` - JSON storageAnalyticsListResponseQueryJSON `json:"-"` -} - -// storageAnalyticsListResponseQueryJSON contains the JSON metadata for the struct -// [StorageAnalyticsListResponseQuery] -type storageAnalyticsListResponseQueryJSON struct { - Dimensions apijson.Field - Filters apijson.Field - Limit apijson.Field - Metrics apijson.Field - Since apijson.Field - Sort apijson.Field - Until apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StorageAnalyticsListResponseQuery) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r storageAnalyticsListResponseQueryJSON) RawJSON() string { - return r.raw -} - -// Metrics on Workers KV requests. -type StorageAnalyticsStoredResponse struct { - Data []StorageAnalyticsStoredResponseData `json:"data,required,nullable"` - // Number of seconds between current time and last processed event, i.e. how many - // seconds of data could be missing. - DataLag float64 `json:"data_lag,required"` - // Maximum results for each metric. - Max interface{} `json:"max,required"` - // Minimum results for each metric. - Min interface{} `json:"min,required"` - // For specifying result metrics. - Query StorageAnalyticsStoredResponseQuery `json:"query,required"` - // Total number of rows in the result. - Rows float64 `json:"rows,required"` - // Total results for metrics across all data. - Totals interface{} `json:"totals,required"` - JSON storageAnalyticsStoredResponseJSON `json:"-"` -} - -// storageAnalyticsStoredResponseJSON contains the JSON metadata for the struct -// [StorageAnalyticsStoredResponse] -type storageAnalyticsStoredResponseJSON struct { - Data apijson.Field - DataLag apijson.Field - Max apijson.Field - Min apijson.Field - Query apijson.Field - Rows apijson.Field - Totals apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StorageAnalyticsStoredResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r storageAnalyticsStoredResponseJSON) RawJSON() string { - return r.raw -} - -type StorageAnalyticsStoredResponseData struct { - // List of metrics returned by the query. - Metrics []interface{} `json:"metrics,required"` - JSON storageAnalyticsStoredResponseDataJSON `json:"-"` -} - -// storageAnalyticsStoredResponseDataJSON contains the JSON metadata for the struct -// [StorageAnalyticsStoredResponseData] -type storageAnalyticsStoredResponseDataJSON struct { - Metrics apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StorageAnalyticsStoredResponseData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r storageAnalyticsStoredResponseDataJSON) RawJSON() string { - return r.raw -} - -// For specifying result metrics. -type StorageAnalyticsStoredResponseQuery struct { - // Can be used to break down the data by given attributes. - Dimensions []string `json:"dimensions"` - // Used to filter rows by one or more dimensions. Filters can be combined using OR - // and AND boolean logic. AND takes precedence over OR in all the expressions. The - // OR operator is defined using a comma (,) or OR keyword surrounded by whitespace. - // The AND operator is defined using a semicolon (;) or AND keyword surrounded by - // whitespace. Note that the semicolon is a reserved character in URLs (rfc1738) - // and needs to be percent-encoded as %3B. Comparison options are: - // - // | Operator | Name | URL Encoded | - // | -------- | ------------------------ | ----------- | - // | == | Equals | %3D%3D | - // | != | Does not equals | !%3D | - // | > | Greater Than | %3E | - // | < | Less Than | %3C | - // | >= | Greater than or equal to | %3E%3D | - // | <= | Less than or equal to | %3C%3D . | - Filters string `json:"filters"` - // Limit number of returned metrics. - Limit int64 `json:"limit"` - // One or more metrics to compute. - Metrics []string `json:"metrics"` - // Start of time interval to query, defaults to 6 hours before request received. - Since time.Time `json:"since" format:"date-time"` - // Array of dimensions or metrics to sort by, each dimension/metric may be prefixed - // by - (descending) or + (ascending). - Sort []interface{} `json:"sort"` - // End of time interval to query, defaults to current time. - Until time.Time `json:"until" format:"date-time"` - JSON storageAnalyticsStoredResponseQueryJSON `json:"-"` -} - -// storageAnalyticsStoredResponseQueryJSON contains the JSON metadata for the -// struct [StorageAnalyticsStoredResponseQuery] -type storageAnalyticsStoredResponseQueryJSON struct { - Dimensions apijson.Field - Filters apijson.Field - Limit apijson.Field - Metrics apijson.Field - Since apijson.Field - Sort apijson.Field - Until apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StorageAnalyticsStoredResponseQuery) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r storageAnalyticsStoredResponseQueryJSON) RawJSON() string { - return r.raw -} - -type StorageAnalyticsListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // For specifying result metrics. - Query param.Field[StorageAnalyticsListParamsQuery] `query:"query"` -} - -// URLQuery serializes [StorageAnalyticsListParams]'s query parameters as -// `url.Values`. -func (r StorageAnalyticsListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// For specifying result metrics. -type StorageAnalyticsListParamsQuery struct { - // Can be used to break down the data by given attributes. - Dimensions param.Field[[]StorageAnalyticsListParamsQueryDimension] `query:"dimensions"` - // Used to filter rows by one or more dimensions. Filters can be combined using OR - // and AND boolean logic. AND takes precedence over OR in all the expressions. The - // OR operator is defined using a comma (,) or OR keyword surrounded by whitespace. - // The AND operator is defined using a semicolon (;) or AND keyword surrounded by - // whitespace. Note that the semicolon is a reserved character in URLs (rfc1738) - // and needs to be percent-encoded as %3B. Comparison options are: - // - // | Operator | Name | URL Encoded | - // | -------- | ------------------------ | ----------- | - // | == | Equals | %3D%3D | - // | != | Does not equals | !%3D | - // | > | Greater Than | %3E | - // | < | Less Than | %3C | - // | >= | Greater than or equal to | %3E%3D | - // | <= | Less than or equal to | %3C%3D . | - Filters param.Field[string] `query:"filters"` - // Limit number of returned metrics. - Limit param.Field[int64] `query:"limit"` - // One or more metrics to compute. - Metrics param.Field[[]StorageAnalyticsListParamsQueryMetric] `query:"metrics"` - // Start of time interval to query, defaults to 6 hours before request received. - Since param.Field[time.Time] `query:"since" format:"date-time"` - // Array of dimensions or metrics to sort by, each dimension/metric may be prefixed - // by - (descending) or + (ascending). - Sort param.Field[[]interface{}] `query:"sort"` - // End of time interval to query, defaults to current time. - Until param.Field[time.Time] `query:"until" format:"date-time"` -} - -// URLQuery serializes [StorageAnalyticsListParamsQuery]'s query parameters as -// `url.Values`. -func (r StorageAnalyticsListParamsQuery) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// For drilling down on metrics. -type StorageAnalyticsListParamsQueryDimension string - -const ( - StorageAnalyticsListParamsQueryDimensionAccountID StorageAnalyticsListParamsQueryDimension = "accountId" - StorageAnalyticsListParamsQueryDimensionResponseCode StorageAnalyticsListParamsQueryDimension = "responseCode" - StorageAnalyticsListParamsQueryDimensionRequestType StorageAnalyticsListParamsQueryDimension = "requestType" -) - -// A quantitative measurement of KV usage. -type StorageAnalyticsListParamsQueryMetric string - -const ( - StorageAnalyticsListParamsQueryMetricRequests StorageAnalyticsListParamsQueryMetric = "requests" - StorageAnalyticsListParamsQueryMetricWriteKiB StorageAnalyticsListParamsQueryMetric = "writeKiB" - StorageAnalyticsListParamsQueryMetricReadKiB StorageAnalyticsListParamsQueryMetric = "readKiB" -) - -type StorageAnalyticsListResponseEnvelope struct { - Errors []StorageAnalyticsListResponseEnvelopeErrors `json:"errors,required"` - Messages []StorageAnalyticsListResponseEnvelopeMessages `json:"messages,required"` - // Metrics on Workers KV requests. - Result StorageAnalyticsListResponse `json:"result,required"` - // Whether the API call was successful - Success StorageAnalyticsListResponseEnvelopeSuccess `json:"success,required"` - JSON storageAnalyticsListResponseEnvelopeJSON `json:"-"` -} - -// storageAnalyticsListResponseEnvelopeJSON contains the JSON metadata for the -// struct [StorageAnalyticsListResponseEnvelope] -type storageAnalyticsListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StorageAnalyticsListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r storageAnalyticsListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StorageAnalyticsListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON storageAnalyticsListResponseEnvelopeErrorsJSON `json:"-"` -} - -// storageAnalyticsListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [StorageAnalyticsListResponseEnvelopeErrors] -type storageAnalyticsListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StorageAnalyticsListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r storageAnalyticsListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StorageAnalyticsListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON storageAnalyticsListResponseEnvelopeMessagesJSON `json:"-"` -} - -// storageAnalyticsListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [StorageAnalyticsListResponseEnvelopeMessages] -type storageAnalyticsListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StorageAnalyticsListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r storageAnalyticsListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StorageAnalyticsListResponseEnvelopeSuccess bool - -const ( - StorageAnalyticsListResponseEnvelopeSuccessTrue StorageAnalyticsListResponseEnvelopeSuccess = true -) - -type StorageAnalyticsStoredParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // For specifying result metrics. - Query param.Field[StorageAnalyticsStoredParamsQuery] `query:"query"` -} - -// URLQuery serializes [StorageAnalyticsStoredParams]'s query parameters as -// `url.Values`. -func (r StorageAnalyticsStoredParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// For specifying result metrics. -type StorageAnalyticsStoredParamsQuery struct { - // Can be used to break down the data by given attributes. - Dimensions param.Field[[]StorageAnalyticsStoredParamsQueryDimension] `query:"dimensions"` - // Used to filter rows by one or more dimensions. Filters can be combined using OR - // and AND boolean logic. AND takes precedence over OR in all the expressions. The - // OR operator is defined using a comma (,) or OR keyword surrounded by whitespace. - // The AND operator is defined using a semicolon (;) or AND keyword surrounded by - // whitespace. Note that the semicolon is a reserved character in URLs (rfc1738) - // and needs to be percent-encoded as %3B. Comparison options are: - // - // | Operator | Name | URL Encoded | - // | -------- | ------------------------ | ----------- | - // | == | Equals | %3D%3D | - // | != | Does not equals | !%3D | - // | > | Greater Than | %3E | - // | < | Less Than | %3C | - // | >= | Greater than or equal to | %3E%3D | - // | <= | Less than or equal to | %3C%3D . | - Filters param.Field[string] `query:"filters"` - // Limit number of returned metrics. - Limit param.Field[int64] `query:"limit"` - // One or more metrics to compute. - Metrics param.Field[[]StorageAnalyticsStoredParamsQueryMetric] `query:"metrics"` - // Start of time interval to query, defaults to 6 hours before request received. - Since param.Field[time.Time] `query:"since" format:"date-time"` - // Array of dimensions or metrics to sort by, each dimension/metric may be prefixed - // by - (descending) or + (ascending). - Sort param.Field[[]interface{}] `query:"sort"` - // End of time interval to query, defaults to current time. - Until param.Field[time.Time] `query:"until" format:"date-time"` -} - -// URLQuery serializes [StorageAnalyticsStoredParamsQuery]'s query parameters as -// `url.Values`. -func (r StorageAnalyticsStoredParamsQuery) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// For drilling down on metrics. -type StorageAnalyticsStoredParamsQueryDimension string - -const ( - StorageAnalyticsStoredParamsQueryDimensionNamespaceID StorageAnalyticsStoredParamsQueryDimension = "namespaceId" -) - -// A quantitative measurement of KV usage. -type StorageAnalyticsStoredParamsQueryMetric string - -const ( - StorageAnalyticsStoredParamsQueryMetricStoredBytes StorageAnalyticsStoredParamsQueryMetric = "storedBytes" - StorageAnalyticsStoredParamsQueryMetricStoredKeys StorageAnalyticsStoredParamsQueryMetric = "storedKeys" -) - -type StorageAnalyticsStoredResponseEnvelope struct { - Errors []StorageAnalyticsStoredResponseEnvelopeErrors `json:"errors,required"` - Messages []StorageAnalyticsStoredResponseEnvelopeMessages `json:"messages,required"` - // Metrics on Workers KV requests. - Result StorageAnalyticsStoredResponse `json:"result,required"` - // Whether the API call was successful - Success StorageAnalyticsStoredResponseEnvelopeSuccess `json:"success,required"` - JSON storageAnalyticsStoredResponseEnvelopeJSON `json:"-"` -} - -// storageAnalyticsStoredResponseEnvelopeJSON contains the JSON metadata for the -// struct [StorageAnalyticsStoredResponseEnvelope] -type storageAnalyticsStoredResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StorageAnalyticsStoredResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r storageAnalyticsStoredResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StorageAnalyticsStoredResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON storageAnalyticsStoredResponseEnvelopeErrorsJSON `json:"-"` -} - -// storageAnalyticsStoredResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [StorageAnalyticsStoredResponseEnvelopeErrors] -type storageAnalyticsStoredResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StorageAnalyticsStoredResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r storageAnalyticsStoredResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StorageAnalyticsStoredResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON storageAnalyticsStoredResponseEnvelopeMessagesJSON `json:"-"` -} - -// storageAnalyticsStoredResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [StorageAnalyticsStoredResponseEnvelopeMessages] -type storageAnalyticsStoredResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StorageAnalyticsStoredResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r storageAnalyticsStoredResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StorageAnalyticsStoredResponseEnvelopeSuccess bool - -const ( - StorageAnalyticsStoredResponseEnvelopeSuccessTrue StorageAnalyticsStoredResponseEnvelopeSuccess = true -) diff --git a/storageanalytics_test.go b/storageanalytics_test.go deleted file mode 100644 index c4abf2111a4..00000000000 --- a/storageanalytics_test.go +++ /dev/null @@ -1,85 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestStorageAnalyticsListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Storage.Analytics.List(context.TODO(), cloudflare.StorageAnalyticsListParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Query: cloudflare.F(cloudflare.StorageAnalyticsListParamsQuery{ - Dimensions: cloudflare.F([]cloudflare.StorageAnalyticsListParamsQueryDimension{cloudflare.StorageAnalyticsListParamsQueryDimensionAccountID, cloudflare.StorageAnalyticsListParamsQueryDimensionResponseCode, cloudflare.StorageAnalyticsListParamsQueryDimensionRequestType}), - Filters: cloudflare.F("requestType==read AND responseCode!=200"), - Limit: cloudflare.F(int64(0)), - Metrics: cloudflare.F([]cloudflare.StorageAnalyticsListParamsQueryMetric{cloudflare.StorageAnalyticsListParamsQueryMetricRequests, cloudflare.StorageAnalyticsListParamsQueryMetricWriteKiB, cloudflare.StorageAnalyticsListParamsQueryMetricReadKiB}), - Since: cloudflare.F(time.Now()), - Sort: cloudflare.F([]interface{}{"+requests", "-responseCode"}), - Until: cloudflare.F(time.Now()), - }), - }) - 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 TestStorageAnalyticsStoredWithOptionalParams(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("user@example.com"), - ) - _, err := client.Storage.Analytics.Stored(context.TODO(), cloudflare.StorageAnalyticsStoredParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Query: cloudflare.F(cloudflare.StorageAnalyticsStoredParamsQuery{ - Dimensions: cloudflare.F([]cloudflare.StorageAnalyticsStoredParamsQueryDimension{cloudflare.StorageAnalyticsStoredParamsQueryDimensionNamespaceID}), - Filters: cloudflare.F("namespaceId==a4e8cbb7-1b58-4990-925e-e026d40c4c64"), - Limit: cloudflare.F(int64(0)), - Metrics: cloudflare.F([]cloudflare.StorageAnalyticsStoredParamsQueryMetric{cloudflare.StorageAnalyticsStoredParamsQueryMetricStoredBytes, cloudflare.StorageAnalyticsStoredParamsQueryMetricStoredKeys}), - Since: cloudflare.F(time.Now()), - Sort: cloudflare.F([]interface{}{"+storedBytes", "-namespaceId"}), - Until: cloudflare.F(time.Now()), - }), - }) - 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/stream.go b/stream.go deleted file mode 100644 index 0d847db6a0c..00000000000 --- a/stream.go +++ /dev/null @@ -1,898 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// StreamService 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 [NewStreamService] method instead. -type StreamService struct { - Options []option.RequestOption - AudioTracks *StreamAudioTrackService - Videos *StreamVideoService - Clips *StreamClipService - Copies *StreamCopyService - DirectUploads *StreamDirectUploadService - Keys *StreamKeyService - LiveInputs *StreamLiveInputService - Watermarks *StreamWatermarkService - Webhooks *StreamWebhookService - Captions *StreamCaptionService - Downloads *StreamDownloadService - Embeds *StreamEmbedService - Tokens *StreamTokenService -} - -// NewStreamService 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 NewStreamService(opts ...option.RequestOption) (r *StreamService) { - r = &StreamService{} - r.Options = opts - r.AudioTracks = NewStreamAudioTrackService(opts...) - r.Videos = NewStreamVideoService(opts...) - r.Clips = NewStreamClipService(opts...) - r.Copies = NewStreamCopyService(opts...) - r.DirectUploads = NewStreamDirectUploadService(opts...) - r.Keys = NewStreamKeyService(opts...) - r.LiveInputs = NewStreamLiveInputService(opts...) - r.Watermarks = NewStreamWatermarkService(opts...) - r.Webhooks = NewStreamWebhookService(opts...) - r.Captions = NewStreamCaptionService(opts...) - r.Downloads = NewStreamDownloadService(opts...) - r.Embeds = NewStreamEmbedService(opts...) - r.Tokens = NewStreamTokenService(opts...) - return -} - -// Initiates a video upload using the TUS protocol. On success, the server responds -// with a status code 201 (created) and includes a `location` header to indicate -// where the content should be uploaded. Refer to https://tus.io for protocol -// details. -func (r *StreamService) New(ctx context.Context, params StreamNewParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := fmt.Sprintf("accounts/%s/stream", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, nil, opts...) - return -} - -// Lists up to 1000 videos from a single request. For a specific range, refer to -// the optional parameters. -func (r *StreamService) List(ctx context.Context, params StreamListParams, opts ...option.RequestOption) (res *[]StreamListResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamListResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a video and its copies from Cloudflare Stream. -func (r *StreamService) Delete(ctx context.Context, identifier string, body StreamDeleteParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := fmt.Sprintf("accounts/%s/stream/%s", body.AccountID, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) - return -} - -// Fetches details for a single video. -func (r *StreamService) Get(ctx context.Context, identifier string, query StreamGetParams, opts ...option.RequestOption) (res *StreamGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/%s", query.AccountID, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type StreamListResponse struct { - // Lists the origins allowed to display the video. Enter allowed origin domains in - // an array and use `*` for wildcard subdomains. Empty arrays allow the video to be - // viewed on any origin. - AllowedOrigins []string `json:"allowedOrigins"` - // The date and time the media item was created. - Created time.Time `json:"created" format:"date-time"` - // A user-defined identifier for the media creator. - Creator string `json:"creator"` - // The duration of the video in seconds. A value of `-1` means the duration is - // unknown. The duration becomes available after the upload and before the video is - // ready. - Duration float64 `json:"duration"` - Input StreamListResponseInput `json:"input"` - // The live input ID used to upload a video with Stream Live. - LiveInput string `json:"liveInput"` - // The maximum duration in seconds for a video upload. Can be set for a video that - // is not yet uploaded to limit its duration. Uploads that exceed the specified - // duration will fail during processing. A value of `-1` means the value is - // unknown. - MaxDurationSeconds int64 `json:"maxDurationSeconds"` - // A user modifiable key-value store used to reference other systems of record for - // managing videos. - Meta interface{} `json:"meta"` - // The date and time the media item was last modified. - Modified time.Time `json:"modified" format:"date-time"` - Playback StreamListResponsePlayback `json:"playback"` - // The video's preview page URI. This field is omitted until encoding is complete. - Preview string `json:"preview" format:"uri"` - // Indicates whether the video is playable. The field is empty if the video is not - // ready for viewing or the live stream is still in progress. - ReadyToStream bool `json:"readyToStream"` - // Indicates the time at which the video became playable. The field is empty if the - // video is not ready for viewing or the live stream is still in progress. - ReadyToStreamAt time.Time `json:"readyToStreamAt" format:"date-time"` - // Indicates whether the video can be a accessed using the UID. When set to `true`, - // a signed token must be generated with a signing key to view the video. - RequireSignedURLs bool `json:"requireSignedURLs"` - // Indicates the date and time at which the video will be deleted. Omit the field - // to indicate no change, or include with a `null` value to remove an existing - // scheduled deletion. If specified, must be at least 30 days from upload time. - ScheduledDeletion time.Time `json:"scheduledDeletion" format:"date-time"` - // The size of the media item in bytes. - Size float64 `json:"size"` - // Specifies a detailed status for a video. If the `state` is `inprogress` or - // `error`, the `step` field returns `encoding` or `manifest`. If the `state` is - // `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the - // approximate percent of completion. If the `state` is `error`, `errorReasonCode` - // and `errorReasonText` provide additional details. - Status StreamListResponseStatus `json:"status"` - // The media item's thumbnail URI. This field is omitted until encoding is - // complete. - Thumbnail string `json:"thumbnail" format:"uri"` - // The timestamp for a thumbnail image calculated as a percentage value of the - // video's duration. To convert from a second-wise timestamp to a percentage, - // divide the desired timestamp by the total duration of the video. If this value - // is not set, the default thumbnail image is taken from 0s of the video. - ThumbnailTimestampPct float64 `json:"thumbnailTimestampPct"` - // A Cloudflare-generated unique identifier for a media item. - Uid string `json:"uid"` - // The date and time the media item was uploaded. - Uploaded time.Time `json:"uploaded" format:"date-time"` - // The date and time when the video upload URL is no longer valid for direct user - // uploads. - UploadExpiry time.Time `json:"uploadExpiry" format:"date-time"` - Watermark StreamListResponseWatermark `json:"watermark"` - JSON streamListResponseJSON `json:"-"` -} - -// streamListResponseJSON contains the JSON metadata for the struct -// [StreamListResponse] -type streamListResponseJSON struct { - AllowedOrigins apijson.Field - Created apijson.Field - Creator apijson.Field - Duration apijson.Field - Input apijson.Field - LiveInput apijson.Field - MaxDurationSeconds apijson.Field - Meta apijson.Field - Modified apijson.Field - Playback apijson.Field - Preview apijson.Field - ReadyToStream apijson.Field - ReadyToStreamAt apijson.Field - RequireSignedURLs apijson.Field - ScheduledDeletion apijson.Field - Size apijson.Field - Status apijson.Field - Thumbnail apijson.Field - ThumbnailTimestampPct apijson.Field - Uid apijson.Field - Uploaded apijson.Field - UploadExpiry apijson.Field - Watermark apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamListResponseJSON) RawJSON() string { - return r.raw -} - -type StreamListResponseInput struct { - // The video height in pixels. A value of `-1` means the height is unknown. The - // value becomes available after the upload and before the video is ready. - Height int64 `json:"height"` - // The video width in pixels. A value of `-1` means the width is unknown. The value - // becomes available after the upload and before the video is ready. - Width int64 `json:"width"` - JSON streamListResponseInputJSON `json:"-"` -} - -// streamListResponseInputJSON contains the JSON metadata for the struct -// [StreamListResponseInput] -type streamListResponseInputJSON struct { - Height apijson.Field - Width apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamListResponseInput) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamListResponseInputJSON) RawJSON() string { - return r.raw -} - -type StreamListResponsePlayback struct { - // DASH Media Presentation Description for the video. - Dash string `json:"dash"` - // The HLS manifest for the video. - Hls string `json:"hls"` - JSON streamListResponsePlaybackJSON `json:"-"` -} - -// streamListResponsePlaybackJSON contains the JSON metadata for the struct -// [StreamListResponsePlayback] -type streamListResponsePlaybackJSON struct { - Dash apijson.Field - Hls apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamListResponsePlayback) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamListResponsePlaybackJSON) RawJSON() string { - return r.raw -} - -// Specifies a detailed status for a video. If the `state` is `inprogress` or -// `error`, the `step` field returns `encoding` or `manifest`. If the `state` is -// `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the -// approximate percent of completion. If the `state` is `error`, `errorReasonCode` -// and `errorReasonText` provide additional details. -type StreamListResponseStatus struct { - // Specifies why the video failed to encode. This field is empty if the video is - // not in an `error` state. Preferred for programmatic use. - ErrorReasonCode string `json:"errorReasonCode"` - // Specifies why the video failed to encode using a human readable error message in - // English. This field is empty if the video is not in an `error` state. - ErrorReasonText string `json:"errorReasonText"` - // Indicates the size of the entire upload in bytes. The value must be a - // non-negative integer. - PctComplete string `json:"pctComplete"` - // Specifies the processing status for all quality levels for a video. - State StreamListResponseStatusState `json:"state"` - JSON streamListResponseStatusJSON `json:"-"` -} - -// streamListResponseStatusJSON contains the JSON metadata for the struct -// [StreamListResponseStatus] -type streamListResponseStatusJSON struct { - ErrorReasonCode apijson.Field - ErrorReasonText apijson.Field - PctComplete apijson.Field - State apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamListResponseStatus) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamListResponseStatusJSON) RawJSON() string { - return r.raw -} - -// Specifies the processing status for all quality levels for a video. -type StreamListResponseStatusState string - -const ( - StreamListResponseStatusStatePendingupload StreamListResponseStatusState = "pendingupload" - StreamListResponseStatusStateDownloading StreamListResponseStatusState = "downloading" - StreamListResponseStatusStateQueued StreamListResponseStatusState = "queued" - StreamListResponseStatusStateInprogress StreamListResponseStatusState = "inprogress" - StreamListResponseStatusStateReady StreamListResponseStatusState = "ready" - StreamListResponseStatusStateError StreamListResponseStatusState = "error" -) - -type StreamListResponseWatermark struct { - // The date and a time a watermark profile was created. - Created time.Time `json:"created" format:"date-time"` - // The source URL for a downloaded image. If the watermark profile was created via - // direct upload, this field is null. - DownloadedFrom string `json:"downloadedFrom"` - // The height of the image in pixels. - Height int64 `json:"height"` - // A short description of the watermark profile. - Name string `json:"name"` - // The translucency of the image. A value of `0.0` makes the image completely - // transparent, and `1.0` makes the image completely opaque. Note that if the image - // is already semi-transparent, setting this to `1.0` will not make the image - // completely opaque. - Opacity float64 `json:"opacity"` - // The whitespace between the adjacent edges (determined by position) of the video - // and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded - // video width or length, as determined by the algorithm. - Padding float64 `json:"padding"` - // The location of the image. Valid positions are: `upperRight`, `upperLeft`, - // `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the - // `padding` parameter. - Position string `json:"position"` - // The size of the image relative to the overall size of the video. This parameter - // will adapt to horizontal and vertical videos automatically. `0.0` indicates no - // scaling (use the size of the image as-is), and `1.0 `fills the entire video. - Scale float64 `json:"scale"` - // The size of the image in bytes. - Size float64 `json:"size"` - // The unique identifier for a watermark profile. - Uid string `json:"uid"` - // The width of the image in pixels. - Width int64 `json:"width"` - JSON streamListResponseWatermarkJSON `json:"-"` -} - -// streamListResponseWatermarkJSON contains the JSON metadata for the struct -// [StreamListResponseWatermark] -type streamListResponseWatermarkJSON struct { - Created apijson.Field - DownloadedFrom apijson.Field - Height apijson.Field - Name apijson.Field - Opacity apijson.Field - Padding apijson.Field - Position apijson.Field - Scale apijson.Field - Size apijson.Field - Uid apijson.Field - Width apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamListResponseWatermark) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamListResponseWatermarkJSON) RawJSON() string { - return r.raw -} - -type StreamGetResponse struct { - // Lists the origins allowed to display the video. Enter allowed origin domains in - // an array and use `*` for wildcard subdomains. Empty arrays allow the video to be - // viewed on any origin. - AllowedOrigins []string `json:"allowedOrigins"` - // The date and time the media item was created. - Created time.Time `json:"created" format:"date-time"` - // A user-defined identifier for the media creator. - Creator string `json:"creator"` - // The duration of the video in seconds. A value of `-1` means the duration is - // unknown. The duration becomes available after the upload and before the video is - // ready. - Duration float64 `json:"duration"` - Input StreamGetResponseInput `json:"input"` - // The live input ID used to upload a video with Stream Live. - LiveInput string `json:"liveInput"` - // The maximum duration in seconds for a video upload. Can be set for a video that - // is not yet uploaded to limit its duration. Uploads that exceed the specified - // duration will fail during processing. A value of `-1` means the value is - // unknown. - MaxDurationSeconds int64 `json:"maxDurationSeconds"` - // A user modifiable key-value store used to reference other systems of record for - // managing videos. - Meta interface{} `json:"meta"` - // The date and time the media item was last modified. - Modified time.Time `json:"modified" format:"date-time"` - Playback StreamGetResponsePlayback `json:"playback"` - // The video's preview page URI. This field is omitted until encoding is complete. - Preview string `json:"preview" format:"uri"` - // Indicates whether the video is playable. The field is empty if the video is not - // ready for viewing or the live stream is still in progress. - ReadyToStream bool `json:"readyToStream"` - // Indicates the time at which the video became playable. The field is empty if the - // video is not ready for viewing or the live stream is still in progress. - ReadyToStreamAt time.Time `json:"readyToStreamAt" format:"date-time"` - // Indicates whether the video can be a accessed using the UID. When set to `true`, - // a signed token must be generated with a signing key to view the video. - RequireSignedURLs bool `json:"requireSignedURLs"` - // Indicates the date and time at which the video will be deleted. Omit the field - // to indicate no change, or include with a `null` value to remove an existing - // scheduled deletion. If specified, must be at least 30 days from upload time. - ScheduledDeletion time.Time `json:"scheduledDeletion" format:"date-time"` - // The size of the media item in bytes. - Size float64 `json:"size"` - // Specifies a detailed status for a video. If the `state` is `inprogress` or - // `error`, the `step` field returns `encoding` or `manifest`. If the `state` is - // `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the - // approximate percent of completion. If the `state` is `error`, `errorReasonCode` - // and `errorReasonText` provide additional details. - Status StreamGetResponseStatus `json:"status"` - // The media item's thumbnail URI. This field is omitted until encoding is - // complete. - Thumbnail string `json:"thumbnail" format:"uri"` - // The timestamp for a thumbnail image calculated as a percentage value of the - // video's duration. To convert from a second-wise timestamp to a percentage, - // divide the desired timestamp by the total duration of the video. If this value - // is not set, the default thumbnail image is taken from 0s of the video. - ThumbnailTimestampPct float64 `json:"thumbnailTimestampPct"` - // A Cloudflare-generated unique identifier for a media item. - Uid string `json:"uid"` - // The date and time the media item was uploaded. - Uploaded time.Time `json:"uploaded" format:"date-time"` - // The date and time when the video upload URL is no longer valid for direct user - // uploads. - UploadExpiry time.Time `json:"uploadExpiry" format:"date-time"` - Watermark StreamGetResponseWatermark `json:"watermark"` - JSON streamGetResponseJSON `json:"-"` -} - -// streamGetResponseJSON contains the JSON metadata for the struct -// [StreamGetResponse] -type streamGetResponseJSON struct { - AllowedOrigins apijson.Field - Created apijson.Field - Creator apijson.Field - Duration apijson.Field - Input apijson.Field - LiveInput apijson.Field - MaxDurationSeconds apijson.Field - Meta apijson.Field - Modified apijson.Field - Playback apijson.Field - Preview apijson.Field - ReadyToStream apijson.Field - ReadyToStreamAt apijson.Field - RequireSignedURLs apijson.Field - ScheduledDeletion apijson.Field - Size apijson.Field - Status apijson.Field - Thumbnail apijson.Field - ThumbnailTimestampPct apijson.Field - Uid apijson.Field - Uploaded apijson.Field - UploadExpiry apijson.Field - Watermark apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamGetResponseJSON) RawJSON() string { - return r.raw -} - -type StreamGetResponseInput struct { - // The video height in pixels. A value of `-1` means the height is unknown. The - // value becomes available after the upload and before the video is ready. - Height int64 `json:"height"` - // The video width in pixels. A value of `-1` means the width is unknown. The value - // becomes available after the upload and before the video is ready. - Width int64 `json:"width"` - JSON streamGetResponseInputJSON `json:"-"` -} - -// streamGetResponseInputJSON contains the JSON metadata for the struct -// [StreamGetResponseInput] -type streamGetResponseInputJSON struct { - Height apijson.Field - Width apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamGetResponseInput) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamGetResponseInputJSON) RawJSON() string { - return r.raw -} - -type StreamGetResponsePlayback struct { - // DASH Media Presentation Description for the video. - Dash string `json:"dash"` - // The HLS manifest for the video. - Hls string `json:"hls"` - JSON streamGetResponsePlaybackJSON `json:"-"` -} - -// streamGetResponsePlaybackJSON contains the JSON metadata for the struct -// [StreamGetResponsePlayback] -type streamGetResponsePlaybackJSON struct { - Dash apijson.Field - Hls apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamGetResponsePlayback) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamGetResponsePlaybackJSON) RawJSON() string { - return r.raw -} - -// Specifies a detailed status for a video. If the `state` is `inprogress` or -// `error`, the `step` field returns `encoding` or `manifest`. If the `state` is -// `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the -// approximate percent of completion. If the `state` is `error`, `errorReasonCode` -// and `errorReasonText` provide additional details. -type StreamGetResponseStatus struct { - // Specifies why the video failed to encode. This field is empty if the video is - // not in an `error` state. Preferred for programmatic use. - ErrorReasonCode string `json:"errorReasonCode"` - // Specifies why the video failed to encode using a human readable error message in - // English. This field is empty if the video is not in an `error` state. - ErrorReasonText string `json:"errorReasonText"` - // Indicates the size of the entire upload in bytes. The value must be a - // non-negative integer. - PctComplete string `json:"pctComplete"` - // Specifies the processing status for all quality levels for a video. - State StreamGetResponseStatusState `json:"state"` - JSON streamGetResponseStatusJSON `json:"-"` -} - -// streamGetResponseStatusJSON contains the JSON metadata for the struct -// [StreamGetResponseStatus] -type streamGetResponseStatusJSON struct { - ErrorReasonCode apijson.Field - ErrorReasonText apijson.Field - PctComplete apijson.Field - State apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamGetResponseStatus) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamGetResponseStatusJSON) RawJSON() string { - return r.raw -} - -// Specifies the processing status for all quality levels for a video. -type StreamGetResponseStatusState string - -const ( - StreamGetResponseStatusStatePendingupload StreamGetResponseStatusState = "pendingupload" - StreamGetResponseStatusStateDownloading StreamGetResponseStatusState = "downloading" - StreamGetResponseStatusStateQueued StreamGetResponseStatusState = "queued" - StreamGetResponseStatusStateInprogress StreamGetResponseStatusState = "inprogress" - StreamGetResponseStatusStateReady StreamGetResponseStatusState = "ready" - StreamGetResponseStatusStateError StreamGetResponseStatusState = "error" -) - -type StreamGetResponseWatermark struct { - // The date and a time a watermark profile was created. - Created time.Time `json:"created" format:"date-time"` - // The source URL for a downloaded image. If the watermark profile was created via - // direct upload, this field is null. - DownloadedFrom string `json:"downloadedFrom"` - // The height of the image in pixels. - Height int64 `json:"height"` - // A short description of the watermark profile. - Name string `json:"name"` - // The translucency of the image. A value of `0.0` makes the image completely - // transparent, and `1.0` makes the image completely opaque. Note that if the image - // is already semi-transparent, setting this to `1.0` will not make the image - // completely opaque. - Opacity float64 `json:"opacity"` - // The whitespace between the adjacent edges (determined by position) of the video - // and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded - // video width or length, as determined by the algorithm. - Padding float64 `json:"padding"` - // The location of the image. Valid positions are: `upperRight`, `upperLeft`, - // `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the - // `padding` parameter. - Position string `json:"position"` - // The size of the image relative to the overall size of the video. This parameter - // will adapt to horizontal and vertical videos automatically. `0.0` indicates no - // scaling (use the size of the image as-is), and `1.0 `fills the entire video. - Scale float64 `json:"scale"` - // The size of the image in bytes. - Size float64 `json:"size"` - // The unique identifier for a watermark profile. - Uid string `json:"uid"` - // The width of the image in pixels. - Width int64 `json:"width"` - JSON streamGetResponseWatermarkJSON `json:"-"` -} - -// streamGetResponseWatermarkJSON contains the JSON metadata for the struct -// [StreamGetResponseWatermark] -type streamGetResponseWatermarkJSON struct { - Created apijson.Field - DownloadedFrom apijson.Field - Height apijson.Field - Name apijson.Field - Opacity apijson.Field - Padding apijson.Field - Position apijson.Field - Scale apijson.Field - Size apijson.Field - Uid apijson.Field - Width apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamGetResponseWatermark) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamGetResponseWatermarkJSON) RawJSON() string { - return r.raw -} - -type StreamNewParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // Specifies the TUS protocol version. This value must be included in every upload - // request. Notes: The only supported version of TUS protocol is 1.0.0. - TusResumable param.Field[StreamNewParamsTusResumable] `header:"Tus-Resumable,required"` - // Indicates the size of the entire upload in bytes. The value must be a - // non-negative integer. - UploadLength param.Field[int64] `header:"Upload-Length,required"` - // A user-defined identifier for the media creator. - UploadCreator param.Field[string] `header:"Upload-Creator"` - // Comma-separated key-value pairs following the TUS protocol specification. Values - // are Base-64 encoded. Supported keys: `name`, `requiresignedurls`, - // `allowedorigins`, `thumbnailtimestamppct`, `watermark`, `scheduleddeletion`. - UploadMetadata param.Field[string] `header:"Upload-Metadata"` -} - -// Specifies the TUS protocol version. This value must be included in every upload -// request. Notes: The only supported version of TUS protocol is 1.0.0. -type StreamNewParamsTusResumable string - -const ( - StreamNewParamsTusResumable1_0_0 StreamNewParamsTusResumable = "1.0.0" -) - -type StreamListParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // Lists videos in ascending order of creation. - Asc param.Field[bool] `query:"asc"` - // A user-defined identifier for the media creator. - Creator param.Field[string] `query:"creator"` - // Lists videos created before the specified date. - End param.Field[time.Time] `query:"end" format:"date-time"` - // Includes the total number of videos associated with the submitted query - // parameters. - IncludeCounts param.Field[bool] `query:"include_counts"` - // Searches over the `name` key in the `meta` field. This field can be set with or - // after the upload request. - Search param.Field[string] `query:"search"` - // Lists videos created after the specified date. - Start param.Field[time.Time] `query:"start" format:"date-time"` - // Specifies the processing status for all quality levels for a video. - Status param.Field[StreamListParamsStatus] `query:"status"` - // Specifies whether the video is `vod` or `live`. - Type param.Field[string] `query:"type"` -} - -// URLQuery serializes [StreamListParams]'s query parameters as `url.Values`. -func (r StreamListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Specifies the processing status for all quality levels for a video. -type StreamListParamsStatus string - -const ( - StreamListParamsStatusPendingupload StreamListParamsStatus = "pendingupload" - StreamListParamsStatusDownloading StreamListParamsStatus = "downloading" - StreamListParamsStatusQueued StreamListParamsStatus = "queued" - StreamListParamsStatusInprogress StreamListParamsStatus = "inprogress" - StreamListParamsStatusReady StreamListParamsStatus = "ready" - StreamListParamsStatusError StreamListParamsStatus = "error" -) - -type StreamListResponseEnvelope struct { - Errors []StreamListResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamListResponseEnvelopeMessages `json:"messages,required"` - Result []StreamListResponse `json:"result,required"` - // Whether the API call was successful - Success StreamListResponseEnvelopeSuccess `json:"success,required"` - // The total number of remaining videos based on cursor position. - Range int64 `json:"range"` - // The total number of videos that match the provided filters. - Total int64 `json:"total"` - JSON streamListResponseEnvelopeJSON `json:"-"` -} - -// streamListResponseEnvelopeJSON contains the JSON metadata for the struct -// [StreamListResponseEnvelope] -type streamListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - Range apijson.Field - Total apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamListResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [StreamListResponseEnvelopeErrors] -type streamListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamListResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [StreamListResponseEnvelopeMessages] -type streamListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamListResponseEnvelopeSuccess bool - -const ( - StreamListResponseEnvelopeSuccessTrue StreamListResponseEnvelopeSuccess = true -) - -type StreamDeleteParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamGetParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamGetResponseEnvelope struct { - Errors []StreamGetResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamGetResponseEnvelopeMessages `json:"messages,required"` - Result StreamGetResponse `json:"result,required"` - // Whether the API call was successful - Success StreamGetResponseEnvelopeSuccess `json:"success,required"` - JSON streamGetResponseEnvelopeJSON `json:"-"` -} - -// streamGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [StreamGetResponseEnvelope] -type streamGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [StreamGetResponseEnvelopeErrors] -type streamGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct -// [StreamGetResponseEnvelopeMessages] -type streamGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamGetResponseEnvelopeSuccess bool - -const ( - StreamGetResponseEnvelopeSuccessTrue StreamGetResponseEnvelopeSuccess = true -) diff --git a/stream/aliases.go b/stream/aliases.go new file mode 100644 index 00000000000..7d81e0f847d --- /dev/null +++ b/stream/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/stream/audiotrack.go b/stream/audiotrack.go new file mode 100644 index 00000000000..796887d6c8a --- /dev/null +++ b/stream/audiotrack.go @@ -0,0 +1,512 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// AudioTrackService 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 [NewAudioTrackService] method instead. +type AudioTrackService struct { + Options []option.RequestOption +} + +// NewAudioTrackService 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 NewAudioTrackService(opts ...option.RequestOption) (r *AudioTrackService) { + r = &AudioTrackService{} + r.Options = opts + return +} + +// Deletes additional audio tracks on a video. Deleting a default audio track is +// not allowed. You must assign another audio track as default prior to deletion. +func (r *AudioTrackService) Delete(ctx context.Context, identifier string, audioIdentifier string, body AudioTrackDeleteParams, opts ...option.RequestOption) (res *AudioTrackDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env AudioTrackDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/%s/audio/%s", body.AccountID, identifier, audioIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Adds an additional audio track to a video using the provided audio track URL. +func (r *AudioTrackService) Copy(ctx context.Context, identifier string, params AudioTrackCopyParams, opts ...option.RequestOption) (res *StreamAdditionalAudio, err error) { + opts = append(r.Options[:], opts...) + var env AudioTrackCopyResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/%s/audio/copy", params.AccountID, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Edits additional audio tracks on a video. Editing the default status of an audio +// track to `true` will mark all other audio tracks on the video default status to +// `false`. +func (r *AudioTrackService) Edit(ctx context.Context, identifier string, audioIdentifier string, params AudioTrackEditParams, opts ...option.RequestOption) (res *StreamAdditionalAudio, err error) { + opts = append(r.Options[:], opts...) + var env AudioTrackEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/%s/audio/%s", params.AccountID, identifier, audioIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists additional audio tracks on a video. Note this API will not return +// information for audio attached to the video upload. +func (r *AudioTrackService) Get(ctx context.Context, identifier string, query AudioTrackGetParams, opts ...option.RequestOption) (res *[]StreamAdditionalAudio, err error) { + opts = append(r.Options[:], opts...) + var env AudioTrackGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/%s/audio", query.AccountID, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type StreamAdditionalAudio struct { + // Denotes whether the audio track will be played by default in a player. + Default bool `json:"default"` + // A string to uniquely identify the track amongst other audio track labels for the + // specified video. + Label string `json:"label"` + // Specifies the processing status of the video. + Status StreamAdditionalAudioStatus `json:"status"` + // A Cloudflare-generated unique identifier for a media item. + Uid string `json:"uid"` + JSON streamAdditionalAudioJSON `json:"-"` +} + +// streamAdditionalAudioJSON contains the JSON metadata for the struct +// [StreamAdditionalAudio] +type streamAdditionalAudioJSON struct { + Default apijson.Field + Label apijson.Field + Status apijson.Field + Uid apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamAdditionalAudio) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamAdditionalAudioJSON) RawJSON() string { + return r.raw +} + +// Specifies the processing status of the video. +type StreamAdditionalAudioStatus string + +const ( + StreamAdditionalAudioStatusQueued StreamAdditionalAudioStatus = "queued" + StreamAdditionalAudioStatusReady StreamAdditionalAudioStatus = "ready" + StreamAdditionalAudioStatusError StreamAdditionalAudioStatus = "error" +) + +// Union satisfied by [stream.AudioTrackDeleteResponseUnknown] or +// [shared.UnionString]. +type AudioTrackDeleteResponse interface { + ImplementsStreamAudioTrackDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AudioTrackDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type AudioTrackDeleteParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type AudioTrackDeleteResponseEnvelope struct { + Errors []AudioTrackDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []AudioTrackDeleteResponseEnvelopeMessages `json:"messages,required"` + Result AudioTrackDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success AudioTrackDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON audioTrackDeleteResponseEnvelopeJSON `json:"-"` +} + +// audioTrackDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [AudioTrackDeleteResponseEnvelope] +type audioTrackDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AudioTrackDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r audioTrackDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AudioTrackDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON audioTrackDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// audioTrackDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AudioTrackDeleteResponseEnvelopeErrors] +type audioTrackDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AudioTrackDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r audioTrackDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AudioTrackDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON audioTrackDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// audioTrackDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AudioTrackDeleteResponseEnvelopeMessages] +type audioTrackDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AudioTrackDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r audioTrackDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AudioTrackDeleteResponseEnvelopeSuccess bool + +const ( + AudioTrackDeleteResponseEnvelopeSuccessTrue AudioTrackDeleteResponseEnvelopeSuccess = true +) + +type AudioTrackCopyParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + // A string to uniquely identify the track amongst other audio track labels for the + // specified video. + Label param.Field[string] `json:"label,required"` + // An audio track URL. The server must be publicly routable and support `HTTP HEAD` + // requests and `HTTP GET` range requests. The server should respond to `HTTP HEAD` + // requests with a `content-range` header that includes the size of the file. + URL param.Field[string] `json:"url" format:"uri"` +} + +func (r AudioTrackCopyParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AudioTrackCopyResponseEnvelope struct { + Errors []AudioTrackCopyResponseEnvelopeErrors `json:"errors,required"` + Messages []AudioTrackCopyResponseEnvelopeMessages `json:"messages,required"` + Result StreamAdditionalAudio `json:"result,required"` + // Whether the API call was successful + Success AudioTrackCopyResponseEnvelopeSuccess `json:"success,required"` + JSON audioTrackCopyResponseEnvelopeJSON `json:"-"` +} + +// audioTrackCopyResponseEnvelopeJSON contains the JSON metadata for the struct +// [AudioTrackCopyResponseEnvelope] +type audioTrackCopyResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AudioTrackCopyResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r audioTrackCopyResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AudioTrackCopyResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON audioTrackCopyResponseEnvelopeErrorsJSON `json:"-"` +} + +// audioTrackCopyResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AudioTrackCopyResponseEnvelopeErrors] +type audioTrackCopyResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AudioTrackCopyResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r audioTrackCopyResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AudioTrackCopyResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON audioTrackCopyResponseEnvelopeMessagesJSON `json:"-"` +} + +// audioTrackCopyResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AudioTrackCopyResponseEnvelopeMessages] +type audioTrackCopyResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AudioTrackCopyResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r audioTrackCopyResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AudioTrackCopyResponseEnvelopeSuccess bool + +const ( + AudioTrackCopyResponseEnvelopeSuccessTrue AudioTrackCopyResponseEnvelopeSuccess = true +) + +type AudioTrackEditParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + // Denotes whether the audio track will be played by default in a player. + Default param.Field[bool] `json:"default"` + // A string to uniquely identify the track amongst other audio track labels for the + // specified video. + Label param.Field[string] `json:"label"` +} + +func (r AudioTrackEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AudioTrackEditResponseEnvelope struct { + Errors []AudioTrackEditResponseEnvelopeErrors `json:"errors,required"` + Messages []AudioTrackEditResponseEnvelopeMessages `json:"messages,required"` + Result StreamAdditionalAudio `json:"result,required"` + // Whether the API call was successful + Success AudioTrackEditResponseEnvelopeSuccess `json:"success,required"` + JSON audioTrackEditResponseEnvelopeJSON `json:"-"` +} + +// audioTrackEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [AudioTrackEditResponseEnvelope] +type audioTrackEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AudioTrackEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r audioTrackEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AudioTrackEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON audioTrackEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// audioTrackEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AudioTrackEditResponseEnvelopeErrors] +type audioTrackEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AudioTrackEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r audioTrackEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AudioTrackEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON audioTrackEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// audioTrackEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AudioTrackEditResponseEnvelopeMessages] +type audioTrackEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AudioTrackEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r audioTrackEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AudioTrackEditResponseEnvelopeSuccess bool + +const ( + AudioTrackEditResponseEnvelopeSuccessTrue AudioTrackEditResponseEnvelopeSuccess = true +) + +type AudioTrackGetParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type AudioTrackGetResponseEnvelope struct { + Errors []AudioTrackGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AudioTrackGetResponseEnvelopeMessages `json:"messages,required"` + Result []StreamAdditionalAudio `json:"result,required"` + // Whether the API call was successful + Success AudioTrackGetResponseEnvelopeSuccess `json:"success,required"` + JSON audioTrackGetResponseEnvelopeJSON `json:"-"` +} + +// audioTrackGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [AudioTrackGetResponseEnvelope] +type audioTrackGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AudioTrackGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r audioTrackGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AudioTrackGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON audioTrackGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// audioTrackGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AudioTrackGetResponseEnvelopeErrors] +type audioTrackGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AudioTrackGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r audioTrackGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AudioTrackGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON audioTrackGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// audioTrackGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AudioTrackGetResponseEnvelopeMessages] +type audioTrackGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AudioTrackGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r audioTrackGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AudioTrackGetResponseEnvelopeSuccess bool + +const ( + AudioTrackGetResponseEnvelopeSuccessTrue AudioTrackGetResponseEnvelopeSuccess = true +) diff --git a/stream/audiotrack_test.go b/stream/audiotrack_test.go new file mode 100644 index 00000000000..cbf664cf088 --- /dev/null +++ b/stream/audiotrack_test.go @@ -0,0 +1,141 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/stream" +) + +func TestAudioTrackDelete(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("user@example.com"), + ) + _, err := client.Stream.AudioTracks.Delete( + context.TODO(), + "ea95132c15732412d22c1476fa83f27a", + "ea95132c15732412d22c1476fa83f27a", + stream.AudioTrackDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestAudioTrackCopyWithOptionalParams(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("user@example.com"), + ) + _, err := client.Stream.AudioTracks.Copy( + context.TODO(), + "ea95132c15732412d22c1476fa83f27a", + stream.AudioTrackCopyParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Label: cloudflare.F("director commentary"), + URL: cloudflare.F("https://www.examplestorage.com/audio_file.mp3"), + }, + ) + 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 TestAudioTrackEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Stream.AudioTracks.Edit( + context.TODO(), + "ea95132c15732412d22c1476fa83f27a", + "ea95132c15732412d22c1476fa83f27a", + stream.AudioTrackEditParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Default: cloudflare.F(true), + Label: cloudflare.F("director commentary"), + }, + ) + 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 TestAudioTrackGet(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("user@example.com"), + ) + _, err := client.Stream.AudioTracks.Get( + context.TODO(), + "ea95132c15732412d22c1476fa83f27a", + stream.AudioTrackGetParams{ + AccountID: cloudflare.F("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/stream/caption.go b/stream/caption.go new file mode 100644 index 00000000000..96a8242e98c --- /dev/null +++ b/stream/caption.go @@ -0,0 +1,404 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// CaptionService 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 [NewCaptionService] method instead. +type CaptionService struct { + Options []option.RequestOption +} + +// NewCaptionService 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 NewCaptionService(opts ...option.RequestOption) (r *CaptionService) { + r = &CaptionService{} + r.Options = opts + return +} + +// Uploads the caption or subtitle file to the endpoint for a specific BCP47 +// language. One caption or subtitle file per language is allowed. +func (r *CaptionService) Update(ctx context.Context, identifier string, language string, params CaptionUpdateParams, opts ...option.RequestOption) (res *CaptionUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env CaptionUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/%s/captions/%s", params.AccountID, identifier, language) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Removes the captions or subtitles from a video. +func (r *CaptionService) Delete(ctx context.Context, identifier string, language string, body CaptionDeleteParams, opts ...option.RequestOption) (res *CaptionDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env CaptionDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/%s/captions/%s", body.AccountID, identifier, language) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists the available captions or subtitles for a specific video. +func (r *CaptionService) Get(ctx context.Context, identifier string, query CaptionGetParams, opts ...option.RequestOption) (res *[]StreamCaptions, err error) { + opts = append(r.Options[:], opts...) + var env CaptionGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/%s/captions", query.AccountID, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type StreamCaptions struct { + // The language label displayed in the native language to users. + Label string `json:"label"` + // The language tag in BCP 47 format. + Language string `json:"language"` + JSON streamCaptionsJSON `json:"-"` +} + +// streamCaptionsJSON contains the JSON metadata for the struct [StreamCaptions] +type streamCaptionsJSON struct { + Label apijson.Field + Language apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamCaptions) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamCaptionsJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [stream.CaptionUpdateResponseUnknown] or +// [shared.UnionString]. +type CaptionUpdateResponse interface { + ImplementsStreamCaptionUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*CaptionUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [stream.CaptionDeleteResponseUnknown], +// [stream.CaptionDeleteResponseArray] or [shared.UnionString]. +type CaptionDeleteResponse interface { + ImplementsStreamCaptionDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*CaptionDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CaptionDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type CaptionDeleteResponseArray []interface{} + +func (r CaptionDeleteResponseArray) ImplementsStreamCaptionDeleteResponse() {} + +type CaptionUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The WebVTT file containing the caption or subtitle content. + File param.Field[string] `json:"file,required"` +} + +func (r CaptionUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type CaptionUpdateResponseEnvelope struct { + Errors []CaptionUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []CaptionUpdateResponseEnvelopeMessages `json:"messages,required"` + Result CaptionUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success CaptionUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON captionUpdateResponseEnvelopeJSON `json:"-"` +} + +// captionUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [CaptionUpdateResponseEnvelope] +type captionUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CaptionUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r captionUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CaptionUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON captionUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// captionUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [CaptionUpdateResponseEnvelopeErrors] +type captionUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CaptionUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r captionUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CaptionUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON captionUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// captionUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [CaptionUpdateResponseEnvelopeMessages] +type captionUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CaptionUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r captionUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CaptionUpdateResponseEnvelopeSuccess bool + +const ( + CaptionUpdateResponseEnvelopeSuccessTrue CaptionUpdateResponseEnvelopeSuccess = true +) + +type CaptionDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type CaptionDeleteResponseEnvelope struct { + Errors []CaptionDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []CaptionDeleteResponseEnvelopeMessages `json:"messages,required"` + Result CaptionDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success CaptionDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON captionDeleteResponseEnvelopeJSON `json:"-"` +} + +// captionDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [CaptionDeleteResponseEnvelope] +type captionDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CaptionDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r captionDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CaptionDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON captionDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// captionDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [CaptionDeleteResponseEnvelopeErrors] +type captionDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CaptionDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r captionDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CaptionDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON captionDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// captionDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [CaptionDeleteResponseEnvelopeMessages] +type captionDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CaptionDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r captionDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CaptionDeleteResponseEnvelopeSuccess bool + +const ( + CaptionDeleteResponseEnvelopeSuccessTrue CaptionDeleteResponseEnvelopeSuccess = true +) + +type CaptionGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type CaptionGetResponseEnvelope struct { + Errors []CaptionGetResponseEnvelopeErrors `json:"errors,required"` + Messages []CaptionGetResponseEnvelopeMessages `json:"messages,required"` + Result []StreamCaptions `json:"result,required"` + // Whether the API call was successful + Success CaptionGetResponseEnvelopeSuccess `json:"success,required"` + JSON captionGetResponseEnvelopeJSON `json:"-"` +} + +// captionGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [CaptionGetResponseEnvelope] +type captionGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CaptionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r captionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CaptionGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON captionGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// captionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [CaptionGetResponseEnvelopeErrors] +type captionGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CaptionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r captionGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CaptionGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON captionGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// captionGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [CaptionGetResponseEnvelopeMessages] +type captionGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CaptionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r captionGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CaptionGetResponseEnvelopeSuccess bool + +const ( + CaptionGetResponseEnvelopeSuccessTrue CaptionGetResponseEnvelopeSuccess = true +) diff --git a/stream/caption_test.go b/stream/caption_test.go new file mode 100644 index 00000000000..999722422cd --- /dev/null +++ b/stream/caption_test.go @@ -0,0 +1,108 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/stream" +) + +func TestCaptionUpdate(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("user@example.com"), + ) + _, err := client.Stream.Captions.Update( + context.TODO(), + "ea95132c15732412d22c1476fa83f27a", + "tr", + stream.CaptionUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + File: cloudflare.F("@/Users/kyle/Desktop/tr.vtt"), + }, + ) + 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 TestCaptionDelete(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("user@example.com"), + ) + _, err := client.Stream.Captions.Delete( + context.TODO(), + "ea95132c15732412d22c1476fa83f27a", + "tr", + stream.CaptionDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestCaptionGet(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("user@example.com"), + ) + _, err := client.Stream.Captions.Get( + context.TODO(), + "ea95132c15732412d22c1476fa83f27a", + stream.CaptionGetParams{ + AccountID: cloudflare.F("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/stream/clip.go b/stream/clip.go new file mode 100644 index 00000000000..5b4dabf1ec2 --- /dev/null +++ b/stream/clip.go @@ -0,0 +1,300 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ClipService 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 [NewClipService] method instead. +type ClipService struct { + Options []option.RequestOption +} + +// NewClipService 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 NewClipService(opts ...option.RequestOption) (r *ClipService) { + r = &ClipService{} + r.Options = opts + return +} + +// Clips a video based on the specified start and end times provided in seconds. +func (r *ClipService) New(ctx context.Context, params ClipNewParams, opts ...option.RequestOption) (res *StreamClipping, err error) { + opts = append(r.Options[:], opts...) + var env ClipNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/clip", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type StreamClipping struct { + // Lists the origins allowed to display the video. Enter allowed origin domains in + // an array and use `*` for wildcard subdomains. Empty arrays allow the video to be + // viewed on any origin. + AllowedOrigins []string `json:"allowedOrigins"` + // The unique video identifier (UID). + ClippedFromVideoUid string `json:"clippedFromVideoUID"` + // The date and time the clip was created. + Created time.Time `json:"created" format:"date-time"` + // A user-defined identifier for the media creator. + Creator string `json:"creator"` + // Specifies the end time for the video clip in seconds. + EndTimeSeconds int64 `json:"endTimeSeconds"` + // The maximum duration in seconds for a video upload. Can be set for a video that + // is not yet uploaded to limit its duration. Uploads that exceed the specified + // duration will fail during processing. A value of `-1` means the value is + // unknown. + MaxDurationSeconds int64 `json:"maxDurationSeconds"` + // A user modifiable key-value store used to reference other systems of record for + // managing videos. + Meta interface{} `json:"meta"` + // The date and time the live input was last modified. + Modified time.Time `json:"modified" format:"date-time"` + Playback StreamClippingPlayback `json:"playback"` + // The video's preview page URI. This field is omitted until encoding is complete. + Preview string `json:"preview" format:"uri"` + // Indicates whether the video can be a accessed using the UID. When set to `true`, + // a signed token must be generated with a signing key to view the video. + RequireSignedURLs bool `json:"requireSignedURLs"` + // Specifies the start time for the video clip in seconds. + StartTimeSeconds int64 `json:"startTimeSeconds"` + // Specifies the processing status for all quality levels for a video. + Status StreamClippingStatus `json:"status"` + // The timestamp for a thumbnail image calculated as a percentage value of the + // video's duration. To convert from a second-wise timestamp to a percentage, + // divide the desired timestamp by the total duration of the video. If this value + // is not set, the default thumbnail image is taken from 0s of the video. + ThumbnailTimestampPct float64 `json:"thumbnailTimestampPct"` + Watermark StreamClippingWatermark `json:"watermark"` + JSON streamClippingJSON `json:"-"` +} + +// streamClippingJSON contains the JSON metadata for the struct [StreamClipping] +type streamClippingJSON struct { + AllowedOrigins apijson.Field + ClippedFromVideoUid apijson.Field + Created apijson.Field + Creator apijson.Field + EndTimeSeconds apijson.Field + MaxDurationSeconds apijson.Field + Meta apijson.Field + Modified apijson.Field + Playback apijson.Field + Preview apijson.Field + RequireSignedURLs apijson.Field + StartTimeSeconds apijson.Field + Status apijson.Field + ThumbnailTimestampPct apijson.Field + Watermark apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamClipping) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamClippingJSON) RawJSON() string { + return r.raw +} + +type StreamClippingPlayback struct { + // DASH Media Presentation Description for the video. + Dash string `json:"dash"` + // The HLS manifest for the video. + Hls string `json:"hls"` + JSON streamClippingPlaybackJSON `json:"-"` +} + +// streamClippingPlaybackJSON contains the JSON metadata for the struct +// [StreamClippingPlayback] +type streamClippingPlaybackJSON struct { + Dash apijson.Field + Hls apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamClippingPlayback) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamClippingPlaybackJSON) RawJSON() string { + return r.raw +} + +// Specifies the processing status for all quality levels for a video. +type StreamClippingStatus string + +const ( + StreamClippingStatusPendingupload StreamClippingStatus = "pendingupload" + StreamClippingStatusDownloading StreamClippingStatus = "downloading" + StreamClippingStatusQueued StreamClippingStatus = "queued" + StreamClippingStatusInprogress StreamClippingStatus = "inprogress" + StreamClippingStatusReady StreamClippingStatus = "ready" + StreamClippingStatusError StreamClippingStatus = "error" +) + +type StreamClippingWatermark struct { + // The unique identifier for the watermark profile. + Uid string `json:"uid"` + JSON streamClippingWatermarkJSON `json:"-"` +} + +// streamClippingWatermarkJSON contains the JSON metadata for the struct +// [StreamClippingWatermark] +type streamClippingWatermarkJSON struct { + Uid apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamClippingWatermark) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamClippingWatermarkJSON) RawJSON() string { + return r.raw +} + +type ClipNewParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + // The unique video identifier (UID). + ClippedFromVideoUid param.Field[string] `json:"clippedFromVideoUID,required"` + // Specifies the end time for the video clip in seconds. + EndTimeSeconds param.Field[int64] `json:"endTimeSeconds,required"` + // Specifies the start time for the video clip in seconds. + StartTimeSeconds param.Field[int64] `json:"startTimeSeconds,required"` + // Lists the origins allowed to display the video. Enter allowed origin domains in + // an array and use `*` for wildcard subdomains. Empty arrays allow the video to be + // viewed on any origin. + AllowedOrigins param.Field[[]string] `json:"allowedOrigins"` + // A user-defined identifier for the media creator. + Creator param.Field[string] `json:"creator"` + // The maximum duration in seconds for a video upload. Can be set for a video that + // is not yet uploaded to limit its duration. Uploads that exceed the specified + // duration will fail during processing. A value of `-1` means the value is + // unknown. + MaxDurationSeconds param.Field[int64] `json:"maxDurationSeconds"` + // Indicates whether the video can be a accessed using the UID. When set to `true`, + // a signed token must be generated with a signing key to view the video. + RequireSignedURLs param.Field[bool] `json:"requireSignedURLs"` + // The timestamp for a thumbnail image calculated as a percentage value of the + // video's duration. To convert from a second-wise timestamp to a percentage, + // divide the desired timestamp by the total duration of the video. If this value + // is not set, the default thumbnail image is taken from 0s of the video. + ThumbnailTimestampPct param.Field[float64] `json:"thumbnailTimestampPct"` + Watermark param.Field[ClipNewParamsWatermark] `json:"watermark"` +} + +func (r ClipNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ClipNewParamsWatermark struct { + // The unique identifier for the watermark profile. + Uid param.Field[string] `json:"uid"` +} + +func (r ClipNewParamsWatermark) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ClipNewResponseEnvelope struct { + Errors []ClipNewResponseEnvelopeErrors `json:"errors,required"` + Messages []ClipNewResponseEnvelopeMessages `json:"messages,required"` + Result StreamClipping `json:"result,required"` + // Whether the API call was successful + Success ClipNewResponseEnvelopeSuccess `json:"success,required"` + JSON clipNewResponseEnvelopeJSON `json:"-"` +} + +// clipNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [ClipNewResponseEnvelope] +type clipNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ClipNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r clipNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ClipNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON clipNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// clipNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ClipNewResponseEnvelopeErrors] +type clipNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ClipNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r clipNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ClipNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON clipNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// clipNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ClipNewResponseEnvelopeMessages] +type clipNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ClipNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r clipNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ClipNewResponseEnvelopeSuccess bool + +const ( + ClipNewResponseEnvelopeSuccessTrue ClipNewResponseEnvelopeSuccess = true +) diff --git a/stream/clip_test.go b/stream/clip_test.go new file mode 100644 index 00000000000..a62f51ddc86 --- /dev/null +++ b/stream/clip_test.go @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/stream" +) + +func TestClipNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Stream.Clips.New(context.TODO(), stream.ClipNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + ClippedFromVideoUid: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + EndTimeSeconds: cloudflare.F(int64(0)), + StartTimeSeconds: cloudflare.F(int64(0)), + AllowedOrigins: cloudflare.F([]string{"example.com"}), + Creator: cloudflare.F("creator-id_abcde12345"), + MaxDurationSeconds: cloudflare.F(int64(1)), + RequireSignedURLs: cloudflare.F(true), + ThumbnailTimestampPct: cloudflare.F(0.529241), + Watermark: cloudflare.F(stream.ClipNewParamsWatermark{ + Uid: cloudflare.F("ea95132c15732412d22c1476fa83f27a"), + }), + }) + 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/stream/copy.go b/stream/copy.go new file mode 100644 index 00000000000..f19cba44850 --- /dev/null +++ b/stream/copy.go @@ -0,0 +1,176 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// CopyService 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 [NewCopyService] method instead. +type CopyService struct { + Options []option.RequestOption +} + +// NewCopyService 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 NewCopyService(opts ...option.RequestOption) (r *CopyService) { + r = &CopyService{} + r.Options = opts + return +} + +// Uploads a video to Stream from a provided URL. +func (r *CopyService) New(ctx context.Context, params CopyNewParams, opts ...option.RequestOption) (res *StreamVideos, err error) { + opts = append(r.Options[:], opts...) + var env CopyNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/copy", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type CopyNewParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + // A video's URL. The server must be publicly routable and support `HTTP HEAD` + // requests and `HTTP GET` range requests. The server should respond to `HTTP HEAD` + // requests with a `content-range` header that includes the size of the file. + URL param.Field[string] `json:"url,required" format:"uri"` + // Lists the origins allowed to display the video. Enter allowed origin domains in + // an array and use `*` for wildcard subdomains. Empty arrays allow the video to be + // viewed on any origin. + AllowedOrigins param.Field[[]string] `json:"allowedOrigins"` + // A user-defined identifier for the media creator. + Creator param.Field[string] `json:"creator"` + // A user modifiable key-value store used to reference other systems of record for + // managing videos. + Meta param.Field[interface{}] `json:"meta"` + // Indicates whether the video can be a accessed using the UID. When set to `true`, + // a signed token must be generated with a signing key to view the video. + RequireSignedURLs param.Field[bool] `json:"requireSignedURLs"` + // Indicates the date and time at which the video will be deleted. Omit the field + // to indicate no change, or include with a `null` value to remove an existing + // scheduled deletion. If specified, must be at least 30 days from upload time. + ScheduledDeletion param.Field[time.Time] `json:"scheduledDeletion" format:"date-time"` + // The timestamp for a thumbnail image calculated as a percentage value of the + // video's duration. To convert from a second-wise timestamp to a percentage, + // divide the desired timestamp by the total duration of the video. If this value + // is not set, the default thumbnail image is taken from 0s of the video. + ThumbnailTimestampPct param.Field[float64] `json:"thumbnailTimestampPct"` + Watermark param.Field[CopyNewParamsWatermark] `json:"watermark"` + // A user-defined identifier for the media creator. + UploadCreator param.Field[string] `header:"Upload-Creator"` + // Comma-separated key-value pairs following the TUS protocol specification. Values + // are Base-64 encoded. Supported keys: `name`, `requiresignedurls`, + // `allowedorigins`, `thumbnailtimestamppct`, `watermark`, `scheduleddeletion`. + UploadMetadata param.Field[string] `header:"Upload-Metadata"` +} + +func (r CopyNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type CopyNewParamsWatermark struct { + // The unique identifier for the watermark profile. + Uid param.Field[string] `json:"uid"` +} + +func (r CopyNewParamsWatermark) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type CopyNewResponseEnvelope struct { + Errors []CopyNewResponseEnvelopeErrors `json:"errors,required"` + Messages []CopyNewResponseEnvelopeMessages `json:"messages,required"` + Result StreamVideos `json:"result,required"` + // Whether the API call was successful + Success CopyNewResponseEnvelopeSuccess `json:"success,required"` + JSON copyNewResponseEnvelopeJSON `json:"-"` +} + +// copyNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [CopyNewResponseEnvelope] +type copyNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CopyNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r copyNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CopyNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON copyNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// copyNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [CopyNewResponseEnvelopeErrors] +type copyNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CopyNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r copyNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CopyNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON copyNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// copyNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [CopyNewResponseEnvelopeMessages] +type copyNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CopyNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r copyNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CopyNewResponseEnvelopeSuccess bool + +const ( + CopyNewResponseEnvelopeSuccessTrue CopyNewResponseEnvelopeSuccess = true +) diff --git a/stream/copy_test.go b/stream/copy_test.go new file mode 100644 index 00000000000..afa0acf060d --- /dev/null +++ b/stream/copy_test.go @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/stream" +) + +func TestCopyNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Stream.Copies.New(context.TODO(), stream.CopyNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + URL: cloudflare.F("https://example.com/myvideo.mp4"), + AllowedOrigins: cloudflare.F([]string{"example.com"}), + Creator: cloudflare.F("creator-id_abcde12345"), + Meta: cloudflare.F[any](map[string]interface{}{ + "name": "video12345.mp4", + }), + RequireSignedURLs: cloudflare.F(true), + ScheduledDeletion: cloudflare.F(time.Now()), + ThumbnailTimestampPct: cloudflare.F(0.529241), + Watermark: cloudflare.F(stream.CopyNewParamsWatermark{ + Uid: cloudflare.F("ea95132c15732412d22c1476fa83f27a"), + }), + UploadCreator: cloudflare.F("creator-id_abcde12345"), + UploadMetadata: cloudflare.F("name aGVsbG8gd29ybGQ=, requiresignedurls, allowedorigins ZXhhbXBsZS5jb20sdGVzdC5jb20="), + }) + 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/stream/directupload.go b/stream/directupload.go new file mode 100644 index 00000000000..19b5eee0821 --- /dev/null +++ b/stream/directupload.go @@ -0,0 +1,209 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DirectUploadService 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 [NewDirectUploadService] method +// instead. +type DirectUploadService struct { + Options []option.RequestOption +} + +// NewDirectUploadService 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 NewDirectUploadService(opts ...option.RequestOption) (r *DirectUploadService) { + r = &DirectUploadService{} + r.Options = opts + return +} + +// Creates a direct upload that allows video uploads without an API key. +func (r *DirectUploadService) New(ctx context.Context, params DirectUploadNewParams, opts ...option.RequestOption) (res *DirectUploadNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env DirectUploadNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/direct_upload", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DirectUploadNewResponse struct { + // Indicates the date and time at which the video will be deleted. Omit the field + // to indicate no change, or include with a `null` value to remove an existing + // scheduled deletion. If specified, must be at least 30 days from upload time. + ScheduledDeletion time.Time `json:"scheduledDeletion" format:"date-time"` + // A Cloudflare-generated unique identifier for a media item. + Uid string `json:"uid"` + // The URL an unauthenticated upload can use for a single + // `HTTP POST multipart/form-data` request. + UploadURL string `json:"uploadURL"` + Watermark StreamWatermarks `json:"watermark"` + JSON directUploadNewResponseJSON `json:"-"` +} + +// directUploadNewResponseJSON contains the JSON metadata for the struct +// [DirectUploadNewResponse] +type directUploadNewResponseJSON struct { + ScheduledDeletion apijson.Field + Uid apijson.Field + UploadURL apijson.Field + Watermark apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DirectUploadNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r directUploadNewResponseJSON) RawJSON() string { + return r.raw +} + +type DirectUploadNewParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + // The maximum duration in seconds for a video upload. Can be set for a video that + // is not yet uploaded to limit its duration. Uploads that exceed the specified + // duration will fail during processing. A value of `-1` means the value is + // unknown. + MaxDurationSeconds param.Field[int64] `json:"maxDurationSeconds,required"` + // Lists the origins allowed to display the video. Enter allowed origin domains in + // an array and use `*` for wildcard subdomains. Empty arrays allow the video to be + // viewed on any origin. + AllowedOrigins param.Field[[]string] `json:"allowedOrigins"` + // A user-defined identifier for the media creator. + Creator param.Field[string] `json:"creator"` + // The date and time after upload when videos will not be accepted. + Expiry param.Field[time.Time] `json:"expiry" format:"date-time"` + // A user modifiable key-value store used to reference other systems of record for + // managing videos. + Meta param.Field[interface{}] `json:"meta"` + // Indicates whether the video can be a accessed using the UID. When set to `true`, + // a signed token must be generated with a signing key to view the video. + RequireSignedURLs param.Field[bool] `json:"requireSignedURLs"` + // Indicates the date and time at which the video will be deleted. Omit the field + // to indicate no change, or include with a `null` value to remove an existing + // scheduled deletion. If specified, must be at least 30 days from upload time. + ScheduledDeletion param.Field[time.Time] `json:"scheduledDeletion" format:"date-time"` + // The timestamp for a thumbnail image calculated as a percentage value of the + // video's duration. To convert from a second-wise timestamp to a percentage, + // divide the desired timestamp by the total duration of the video. If this value + // is not set, the default thumbnail image is taken from 0s of the video. + ThumbnailTimestampPct param.Field[float64] `json:"thumbnailTimestampPct"` + Watermark param.Field[DirectUploadNewParamsWatermark] `json:"watermark"` + // A user-defined identifier for the media creator. + UploadCreator param.Field[string] `header:"Upload-Creator"` +} + +func (r DirectUploadNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DirectUploadNewParamsWatermark struct { + // The unique identifier for the watermark profile. + Uid param.Field[string] `json:"uid"` +} + +func (r DirectUploadNewParamsWatermark) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DirectUploadNewResponseEnvelope struct { + Errors []DirectUploadNewResponseEnvelopeErrors `json:"errors,required"` + Messages []DirectUploadNewResponseEnvelopeMessages `json:"messages,required"` + Result DirectUploadNewResponse `json:"result,required"` + // Whether the API call was successful + Success DirectUploadNewResponseEnvelopeSuccess `json:"success,required"` + JSON directUploadNewResponseEnvelopeJSON `json:"-"` +} + +// directUploadNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [DirectUploadNewResponseEnvelope] +type directUploadNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DirectUploadNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r directUploadNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DirectUploadNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON directUploadNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// directUploadNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DirectUploadNewResponseEnvelopeErrors] +type directUploadNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DirectUploadNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r directUploadNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DirectUploadNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON directUploadNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// directUploadNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DirectUploadNewResponseEnvelopeMessages] +type directUploadNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DirectUploadNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r directUploadNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DirectUploadNewResponseEnvelopeSuccess bool + +const ( + DirectUploadNewResponseEnvelopeSuccessTrue DirectUploadNewResponseEnvelopeSuccess = true +) diff --git a/stream/directupload_test.go b/stream/directupload_test.go new file mode 100644 index 00000000000..8670b1d3dc3 --- /dev/null +++ b/stream/directupload_test.go @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/stream" +) + +func TestDirectUploadNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Stream.DirectUploads.New(context.TODO(), stream.DirectUploadNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + MaxDurationSeconds: cloudflare.F(int64(1)), + AllowedOrigins: cloudflare.F([]string{"example.com"}), + Creator: cloudflare.F("creator-id_abcde12345"), + Expiry: cloudflare.F(time.Now()), + Meta: cloudflare.F[any](map[string]interface{}{ + "name": "video12345.mp4", + }), + RequireSignedURLs: cloudflare.F(true), + ScheduledDeletion: cloudflare.F(time.Now()), + ThumbnailTimestampPct: cloudflare.F(0.529241), + Watermark: cloudflare.F(stream.DirectUploadNewParamsWatermark{ + Uid: cloudflare.F("ea95132c15732412d22c1476fa83f27a"), + }), + UploadCreator: cloudflare.F("creator-id_abcde12345"), + }) + 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/stream/download.go b/stream/download.go new file mode 100644 index 00000000000..6a5cb006adb --- /dev/null +++ b/stream/download.go @@ -0,0 +1,380 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// DownloadService 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 [NewDownloadService] method instead. +type DownloadService struct { + Options []option.RequestOption +} + +// NewDownloadService 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 NewDownloadService(opts ...option.RequestOption) (r *DownloadService) { + r = &DownloadService{} + r.Options = opts + return +} + +// Creates a download for a video when a video is ready to view. +func (r *DownloadService) New(ctx context.Context, identifier string, body DownloadNewParams, opts ...option.RequestOption) (res *DownloadNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env DownloadNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/%s/downloads", body.AccountID, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete the downloads for a video. +func (r *DownloadService) Delete(ctx context.Context, identifier string, body DownloadDeleteParams, opts ...option.RequestOption) (res *DownloadDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env DownloadDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/%s/downloads", body.AccountID, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists the downloads created for a video. +func (r *DownloadService) Get(ctx context.Context, identifier string, query DownloadGetParams, opts ...option.RequestOption) (res *DownloadGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env DownloadGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/%s/downloads", query.AccountID, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [stream.DownloadNewResponseUnknown] or [shared.UnionString]. +type DownloadNewResponse interface { + ImplementsStreamDownloadNewResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DownloadNewResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [stream.DownloadDeleteResponseUnknown] or +// [shared.UnionString]. +type DownloadDeleteResponse interface { + ImplementsStreamDownloadDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DownloadDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [stream.DownloadGetResponseUnknown] or [shared.UnionString]. +type DownloadGetResponse interface { + ImplementsStreamDownloadGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DownloadGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type DownloadNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type DownloadNewResponseEnvelope struct { + Errors []DownloadNewResponseEnvelopeErrors `json:"errors,required"` + Messages []DownloadNewResponseEnvelopeMessages `json:"messages,required"` + Result DownloadNewResponse `json:"result,required"` + // Whether the API call was successful + Success DownloadNewResponseEnvelopeSuccess `json:"success,required"` + JSON downloadNewResponseEnvelopeJSON `json:"-"` +} + +// downloadNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [DownloadNewResponseEnvelope] +type downloadNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DownloadNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r downloadNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DownloadNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON downloadNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// downloadNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [DownloadNewResponseEnvelopeErrors] +type downloadNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DownloadNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r downloadNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DownloadNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON downloadNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// downloadNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DownloadNewResponseEnvelopeMessages] +type downloadNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DownloadNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r downloadNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DownloadNewResponseEnvelopeSuccess bool + +const ( + DownloadNewResponseEnvelopeSuccessTrue DownloadNewResponseEnvelopeSuccess = true +) + +type DownloadDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type DownloadDeleteResponseEnvelope struct { + Errors []DownloadDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []DownloadDeleteResponseEnvelopeMessages `json:"messages,required"` + Result DownloadDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success DownloadDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON downloadDeleteResponseEnvelopeJSON `json:"-"` +} + +// downloadDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [DownloadDeleteResponseEnvelope] +type downloadDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DownloadDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r downloadDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DownloadDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON downloadDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// downloadDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DownloadDeleteResponseEnvelopeErrors] +type downloadDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DownloadDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r downloadDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DownloadDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON downloadDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// downloadDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DownloadDeleteResponseEnvelopeMessages] +type downloadDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DownloadDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r downloadDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DownloadDeleteResponseEnvelopeSuccess bool + +const ( + DownloadDeleteResponseEnvelopeSuccessTrue DownloadDeleteResponseEnvelopeSuccess = true +) + +type DownloadGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type DownloadGetResponseEnvelope struct { + Errors []DownloadGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DownloadGetResponseEnvelopeMessages `json:"messages,required"` + Result DownloadGetResponse `json:"result,required"` + // Whether the API call was successful + Success DownloadGetResponseEnvelopeSuccess `json:"success,required"` + JSON downloadGetResponseEnvelopeJSON `json:"-"` +} + +// downloadGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DownloadGetResponseEnvelope] +type downloadGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DownloadGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r downloadGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DownloadGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON downloadGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// downloadGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [DownloadGetResponseEnvelopeErrors] +type downloadGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DownloadGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r downloadGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DownloadGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON downloadGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// downloadGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DownloadGetResponseEnvelopeMessages] +type downloadGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DownloadGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r downloadGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DownloadGetResponseEnvelopeSuccess bool + +const ( + DownloadGetResponseEnvelopeSuccessTrue DownloadGetResponseEnvelopeSuccess = true +) diff --git a/stream/download_test.go b/stream/download_test.go new file mode 100644 index 00000000000..77f9909763d --- /dev/null +++ b/stream/download_test.go @@ -0,0 +1,105 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/stream" +) + +func TestDownloadNew(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("user@example.com"), + ) + _, err := client.Stream.Downloads.New( + context.TODO(), + "ea95132c15732412d22c1476fa83f27a", + stream.DownloadNewParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestDownloadDelete(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("user@example.com"), + ) + _, err := client.Stream.Downloads.Delete( + context.TODO(), + "ea95132c15732412d22c1476fa83f27a", + stream.DownloadDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestDownloadGet(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("user@example.com"), + ) + _, err := client.Stream.Downloads.Get( + context.TODO(), + "ea95132c15732412d22c1476fa83f27a", + stream.DownloadGetParams{ + AccountID: cloudflare.F("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/stream/embed.go b/stream/embed.go new file mode 100644 index 00000000000..ce2544d4cc4 --- /dev/null +++ b/stream/embed.go @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// EmbedService 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 [NewEmbedService] method instead. +type EmbedService struct { + Options []option.RequestOption +} + +// NewEmbedService 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 NewEmbedService(opts ...option.RequestOption) (r *EmbedService) { + r = &EmbedService{} + r.Options = opts + return +} + +// Fetches an HTML code snippet to embed a video in a web page delivered through +// Cloudflare. On success, returns an HTML fragment for use on web pages to display +// a video. On failure, returns a JSON response body. +func (r *EmbedService) Get(ctx context.Context, identifier string, query EmbedGetParams, opts ...option.RequestOption) (res *EmbedGetResponse, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("accounts/%s/stream/%s/embed", query.AccountID, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +type EmbedGetResponse = interface{} + +type EmbedGetParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} diff --git a/stream/embed_test.go b/stream/embed_test.go new file mode 100644 index 00000000000..987ad84fb58 --- /dev/null +++ b/stream/embed_test.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/stream" +) + +func TestEmbedGet(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("user@example.com"), + ) + _, err := client.Stream.Embeds.Get( + context.TODO(), + "ea95132c15732412d22c1476fa83f27a", + stream.EmbedGetParams{ + AccountID: cloudflare.F("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/stream/key.go b/stream/key.go new file mode 100644 index 00000000000..ad02153bca4 --- /dev/null +++ b/stream/key.go @@ -0,0 +1,404 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// KeyService 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 [NewKeyService] method instead. +type KeyService struct { + Options []option.RequestOption +} + +// NewKeyService 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 NewKeyService(opts ...option.RequestOption) (r *KeyService) { + r = &KeyService{} + r.Options = opts + return +} + +// Creates an RSA private key in PEM and JWK formats. Key files are only displayed +// once after creation. Keys are created, used, and deleted independently of +// videos, and every key can sign any video. +func (r *KeyService) New(ctx context.Context, body KeyNewParams, opts ...option.RequestOption) (res *StreamKeys, err error) { + opts = append(r.Options[:], opts...) + var env KeyNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/keys", body.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes signing keys and revokes all signed URLs generated with the key. +func (r *KeyService) Delete(ctx context.Context, identifier string, body KeyDeleteParams, opts ...option.RequestOption) (res *KeyDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env KeyDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/keys/%s", body.AccountID, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists the video ID and creation date and time when a signing key was created. +func (r *KeyService) Get(ctx context.Context, query KeyGetParams, opts ...option.RequestOption) (res *[]KeyGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env KeyGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/keys", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type StreamKeys struct { + // Identifier + ID string `json:"id"` + // The date and time a signing key was created. + Created time.Time `json:"created" format:"date-time"` + // The signing key in JWK format. + Jwk string `json:"jwk"` + // The signing key in PEM format. + Pem string `json:"pem"` + JSON streamKeysJSON `json:"-"` +} + +// streamKeysJSON contains the JSON metadata for the struct [StreamKeys] +type streamKeysJSON struct { + ID apijson.Field + Created apijson.Field + Jwk apijson.Field + Pem apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamKeys) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamKeysJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [stream.KeyDeleteResponseUnknown] or [shared.UnionString]. +type KeyDeleteResponse interface { + ImplementsStreamKeyDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*KeyDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type KeyGetResponse struct { + // Identifier + ID string `json:"id"` + // The date and time a signing key was created. + Created time.Time `json:"created" format:"date-time"` + JSON keyGetResponseJSON `json:"-"` +} + +// keyGetResponseJSON contains the JSON metadata for the struct [KeyGetResponse] +type keyGetResponseJSON struct { + ID apijson.Field + Created apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeyGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keyGetResponseJSON) RawJSON() string { + return r.raw +} + +type KeyNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type KeyNewResponseEnvelope struct { + Errors []KeyNewResponseEnvelopeErrors `json:"errors,required"` + Messages []KeyNewResponseEnvelopeMessages `json:"messages,required"` + Result StreamKeys `json:"result,required"` + // Whether the API call was successful + Success KeyNewResponseEnvelopeSuccess `json:"success,required"` + JSON keyNewResponseEnvelopeJSON `json:"-"` +} + +// keyNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [KeyNewResponseEnvelope] +type keyNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeyNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keyNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type KeyNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON keyNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// keyNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [KeyNewResponseEnvelopeErrors] +type keyNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeyNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keyNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type KeyNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON keyNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// keyNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [KeyNewResponseEnvelopeMessages] +type keyNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeyNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keyNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type KeyNewResponseEnvelopeSuccess bool + +const ( + KeyNewResponseEnvelopeSuccessTrue KeyNewResponseEnvelopeSuccess = true +) + +type KeyDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type KeyDeleteResponseEnvelope struct { + Errors []KeyDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []KeyDeleteResponseEnvelopeMessages `json:"messages,required"` + Result KeyDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success KeyDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON keyDeleteResponseEnvelopeJSON `json:"-"` +} + +// keyDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [KeyDeleteResponseEnvelope] +type keyDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeyDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keyDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type KeyDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON keyDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// keyDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [KeyDeleteResponseEnvelopeErrors] +type keyDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type KeyDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON keyDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// keyDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [KeyDeleteResponseEnvelopeMessages] +type keyDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeyDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keyDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type KeyDeleteResponseEnvelopeSuccess bool + +const ( + KeyDeleteResponseEnvelopeSuccessTrue KeyDeleteResponseEnvelopeSuccess = true +) + +type KeyGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type KeyGetResponseEnvelope struct { + Errors []KeyGetResponseEnvelopeErrors `json:"errors,required"` + Messages []KeyGetResponseEnvelopeMessages `json:"messages,required"` + Result []KeyGetResponse `json:"result,required"` + // Whether the API call was successful + Success KeyGetResponseEnvelopeSuccess `json:"success,required"` + JSON keyGetResponseEnvelopeJSON `json:"-"` +} + +// keyGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [KeyGetResponseEnvelope] +type keyGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keyGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type KeyGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON keyGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// keyGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [KeyGetResponseEnvelopeErrors] +type keyGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keyGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type KeyGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON keyGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// keyGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [KeyGetResponseEnvelopeMessages] +type keyGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *KeyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r keyGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type KeyGetResponseEnvelopeSuccess bool + +const ( + KeyGetResponseEnvelopeSuccessTrue KeyGetResponseEnvelopeSuccess = true +) diff --git a/stream/key_test.go b/stream/key_test.go new file mode 100644 index 00000000000..a0d61120009 --- /dev/null +++ b/stream/key_test.go @@ -0,0 +1,97 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/stream" +) + +func TestKeyNew(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("user@example.com"), + ) + _, err := client.Stream.Keys.New(context.TODO(), stream.KeyNewParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestKeyDelete(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("user@example.com"), + ) + _, err := client.Stream.Keys.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + stream.KeyDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestKeyGet(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("user@example.com"), + ) + _, err := client.Stream.Keys.Get(context.TODO(), stream.KeyGetParams{ + AccountID: cloudflare.F("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/stream/liveinput.go b/stream/liveinput.go new file mode 100644 index 00000000000..5dcf4288554 --- /dev/null +++ b/stream/liveinput.go @@ -0,0 +1,926 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// LiveInputService 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 [NewLiveInputService] method instead. +type LiveInputService struct { + Options []option.RequestOption + Outputs *LiveInputOutputService +} + +// NewLiveInputService 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 NewLiveInputService(opts ...option.RequestOption) (r *LiveInputService) { + r = &LiveInputService{} + r.Options = opts + r.Outputs = NewLiveInputOutputService(opts...) + return +} + +// Creates a live input, and returns credentials that you or your users can use to +// stream live video to Cloudflare Stream. +func (r *LiveInputService) New(ctx context.Context, params LiveInputNewParams, opts ...option.RequestOption) (res *StreamLiveInput, err error) { + opts = append(r.Options[:], opts...) + var env LiveInputNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/live_inputs", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a specified live input. +func (r *LiveInputService) Update(ctx context.Context, liveInputIdentifier string, params LiveInputUpdateParams, opts ...option.RequestOption) (res *StreamLiveInput, err error) { + opts = append(r.Options[:], opts...) + var env LiveInputUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s", params.AccountID, liveInputIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists the live inputs created for an account. To get the credentials needed to +// stream to a specific live input, request a single live input. +func (r *LiveInputService) List(ctx context.Context, params LiveInputListParams, opts ...option.RequestOption) (res *LiveInputListResponse, err error) { + opts = append(r.Options[:], opts...) + var env LiveInputListResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/live_inputs", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Prevents a live input from being streamed to and makes the live input +// inaccessible to any future API calls. +func (r *LiveInputService) Delete(ctx context.Context, liveInputIdentifier string, body LiveInputDeleteParams, opts ...option.RequestOption) (err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s", body.AccountID, liveInputIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) + return +} + +// Retrieves details of an existing live input. +func (r *LiveInputService) Get(ctx context.Context, liveInputIdentifier string, query LiveInputGetParams, opts ...option.RequestOption) (res *StreamLiveInput, err error) { + opts = append(r.Options[:], opts...) + var env LiveInputGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s", query.AccountID, liveInputIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Details about a live input. +type StreamLiveInput struct { + // The date and time the live input was created. + Created time.Time `json:"created" format:"date-time"` + // Indicates the number of days after which the live inputs recordings will be + // deleted. When a stream completes and the recording is ready, the value is used + // to calculate a scheduled deletion date for that recording. Omit the field to + // indicate no change, or include with a `null` value to remove an existing + // scheduled deletion. + DeleteRecordingAfterDays float64 `json:"deleteRecordingAfterDays"` + // A user modifiable key-value store used to reference other systems of record for + // managing live inputs. + Meta interface{} `json:"meta"` + // The date and time the live input was last modified. + Modified time.Time `json:"modified" format:"date-time"` + // Records the input to a Cloudflare Stream video. Behavior depends on the mode. In + // most cases, the video will initially be viewable as a live video and transition + // to on-demand after a condition is satisfied. + Recording StreamLiveInputRecording `json:"recording"` + // Details for streaming to an live input using RTMPS. + Rtmps StreamLiveInputRtmps `json:"rtmps"` + // Details for playback from an live input using RTMPS. + RtmpsPlayback StreamLiveInputRtmpsPlayback `json:"rtmpsPlayback"` + // Details for streaming to a live input using SRT. + Srt StreamLiveInputSrt `json:"srt"` + // Details for playback from an live input using SRT. + SrtPlayback StreamLiveInputSrtPlayback `json:"srtPlayback"` + // The connection status of a live input. + Status StreamLiveInputStatus `json:"status,nullable"` + // A unique identifier for a live input. + Uid string `json:"uid"` + // Details for streaming to a live input using WebRTC. + WebRtc StreamLiveInputWebRtc `json:"webRTC"` + // Details for playback from a live input using WebRTC. + WebRtcPlayback StreamLiveInputWebRtcPlayback `json:"webRTCPlayback"` + JSON streamLiveInputJSON `json:"-"` +} + +// streamLiveInputJSON contains the JSON metadata for the struct [StreamLiveInput] +type streamLiveInputJSON struct { + Created apijson.Field + DeleteRecordingAfterDays apijson.Field + Meta apijson.Field + Modified apijson.Field + Recording apijson.Field + Rtmps apijson.Field + RtmpsPlayback apijson.Field + Srt apijson.Field + SrtPlayback apijson.Field + Status apijson.Field + Uid apijson.Field + WebRtc apijson.Field + WebRtcPlayback apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamLiveInput) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamLiveInputJSON) RawJSON() string { + return r.raw +} + +// Records the input to a Cloudflare Stream video. Behavior depends on the mode. In +// most cases, the video will initially be viewable as a live video and transition +// to on-demand after a condition is satisfied. +type StreamLiveInputRecording struct { + // Lists the origins allowed to display videos created with this input. Enter + // allowed origin domains in an array and use `*` for wildcard subdomains. An empty + // array allows videos to be viewed on any origin. + AllowedOrigins []string `json:"allowedOrigins"` + // Specifies the recording behavior for the live input. Set this value to `off` to + // prevent a recording. Set the value to `automatic` to begin a recording and + // transition to on-demand after Stream Live stops receiving input. + Mode StreamLiveInputRecordingMode `json:"mode"` + // Indicates if a video using the live input has the `requireSignedURLs` property + // set. Also enforces access controls on any video recording of the livestream with + // the live input. + RequireSignedURLs bool `json:"requireSignedURLs"` + // Determines the amount of time a live input configured in `automatic` mode should + // wait before a recording transitions from live to on-demand. `0` is recommended + // for most use cases and indicates the platform default should be used. + TimeoutSeconds int64 `json:"timeoutSeconds"` + JSON streamLiveInputRecordingJSON `json:"-"` +} + +// streamLiveInputRecordingJSON contains the JSON metadata for the struct +// [StreamLiveInputRecording] +type streamLiveInputRecordingJSON struct { + AllowedOrigins apijson.Field + Mode apijson.Field + RequireSignedURLs apijson.Field + TimeoutSeconds apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamLiveInputRecording) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamLiveInputRecordingJSON) RawJSON() string { + return r.raw +} + +// Specifies the recording behavior for the live input. Set this value to `off` to +// prevent a recording. Set the value to `automatic` to begin a recording and +// transition to on-demand after Stream Live stops receiving input. +type StreamLiveInputRecordingMode string + +const ( + StreamLiveInputRecordingModeOff StreamLiveInputRecordingMode = "off" + StreamLiveInputRecordingModeAutomatic StreamLiveInputRecordingMode = "automatic" +) + +// Details for streaming to an live input using RTMPS. +type StreamLiveInputRtmps struct { + // The secret key to use when streaming via RTMPS to a live input. + StreamKey string `json:"streamKey"` + // The RTMPS URL you provide to the broadcaster, which they stream live video to. + URL string `json:"url"` + JSON streamLiveInputRtmpsJSON `json:"-"` +} + +// streamLiveInputRtmpsJSON contains the JSON metadata for the struct +// [StreamLiveInputRtmps] +type streamLiveInputRtmpsJSON struct { + StreamKey apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamLiveInputRtmps) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamLiveInputRtmpsJSON) RawJSON() string { + return r.raw +} + +// Details for playback from an live input using RTMPS. +type StreamLiveInputRtmpsPlayback struct { + // The secret key to use for playback via RTMPS. + StreamKey string `json:"streamKey"` + // The URL used to play live video over RTMPS. + URL string `json:"url"` + JSON streamLiveInputRtmpsPlaybackJSON `json:"-"` +} + +// streamLiveInputRtmpsPlaybackJSON contains the JSON metadata for the struct +// [StreamLiveInputRtmpsPlayback] +type streamLiveInputRtmpsPlaybackJSON struct { + StreamKey apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamLiveInputRtmpsPlayback) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamLiveInputRtmpsPlaybackJSON) RawJSON() string { + return r.raw +} + +// Details for streaming to a live input using SRT. +type StreamLiveInputSrt struct { + // The secret key to use when streaming via SRT to a live input. + Passphrase string `json:"passphrase"` + // The identifier of the live input to use when streaming via SRT. + StreamID string `json:"streamId"` + // The SRT URL you provide to the broadcaster, which they stream live video to. + URL string `json:"url"` + JSON streamLiveInputSrtJSON `json:"-"` +} + +// streamLiveInputSrtJSON contains the JSON metadata for the struct +// [StreamLiveInputSrt] +type streamLiveInputSrtJSON struct { + Passphrase apijson.Field + StreamID apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamLiveInputSrt) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamLiveInputSrtJSON) RawJSON() string { + return r.raw +} + +// Details for playback from an live input using SRT. +type StreamLiveInputSrtPlayback struct { + // The secret key to use for playback via SRT. + Passphrase string `json:"passphrase"` + // The identifier of the live input to use for playback via SRT. + StreamID string `json:"streamId"` + // The URL used to play live video over SRT. + URL string `json:"url"` + JSON streamLiveInputSrtPlaybackJSON `json:"-"` +} + +// streamLiveInputSrtPlaybackJSON contains the JSON metadata for the struct +// [StreamLiveInputSrtPlayback] +type streamLiveInputSrtPlaybackJSON struct { + Passphrase apijson.Field + StreamID apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamLiveInputSrtPlayback) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamLiveInputSrtPlaybackJSON) RawJSON() string { + return r.raw +} + +// The connection status of a live input. +type StreamLiveInputStatus string + +const ( + StreamLiveInputStatusConnected StreamLiveInputStatus = "connected" + StreamLiveInputStatusReconnected StreamLiveInputStatus = "reconnected" + StreamLiveInputStatusReconnecting StreamLiveInputStatus = "reconnecting" + StreamLiveInputStatusClientDisconnect StreamLiveInputStatus = "client_disconnect" + StreamLiveInputStatusTTLExceeded StreamLiveInputStatus = "ttl_exceeded" + StreamLiveInputStatusFailedToConnect StreamLiveInputStatus = "failed_to_connect" + StreamLiveInputStatusFailedToReconnect StreamLiveInputStatus = "failed_to_reconnect" + StreamLiveInputStatusNewConfigurationAccepted StreamLiveInputStatus = "new_configuration_accepted" +) + +// Details for streaming to a live input using WebRTC. +type StreamLiveInputWebRtc struct { + // The WebRTC URL you provide to the broadcaster, which they stream live video to. + URL string `json:"url"` + JSON streamLiveInputWebRtcJSON `json:"-"` +} + +// streamLiveInputWebRtcJSON contains the JSON metadata for the struct +// [StreamLiveInputWebRtc] +type streamLiveInputWebRtcJSON struct { + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamLiveInputWebRtc) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamLiveInputWebRtcJSON) RawJSON() string { + return r.raw +} + +// Details for playback from a live input using WebRTC. +type StreamLiveInputWebRtcPlayback struct { + // The URL used to play live video over WebRTC. + URL string `json:"url"` + JSON streamLiveInputWebRtcPlaybackJSON `json:"-"` +} + +// streamLiveInputWebRtcPlaybackJSON contains the JSON metadata for the struct +// [StreamLiveInputWebRtcPlayback] +type streamLiveInputWebRtcPlaybackJSON struct { + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamLiveInputWebRtcPlayback) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamLiveInputWebRtcPlaybackJSON) RawJSON() string { + return r.raw +} + +type LiveInputListResponse struct { + LiveInputs []LiveInputListResponseLiveInput `json:"liveInputs"` + // The total number of remaining live inputs based on cursor position. + Range int64 `json:"range"` + // The total number of live inputs that match the provided filters. + Total int64 `json:"total"` + JSON liveInputListResponseJSON `json:"-"` +} + +// liveInputListResponseJSON contains the JSON metadata for the struct +// [LiveInputListResponse] +type liveInputListResponseJSON struct { + LiveInputs apijson.Field + Range apijson.Field + Total apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputListResponseJSON) RawJSON() string { + return r.raw +} + +type LiveInputListResponseLiveInput struct { + // The date and time the live input was created. + Created time.Time `json:"created" format:"date-time"` + // Indicates the number of days after which the live inputs recordings will be + // deleted. When a stream completes and the recording is ready, the value is used + // to calculate a scheduled deletion date for that recording. Omit the field to + // indicate no change, or include with a `null` value to remove an existing + // scheduled deletion. + DeleteRecordingAfterDays float64 `json:"deleteRecordingAfterDays"` + // A user modifiable key-value store used to reference other systems of record for + // managing live inputs. + Meta interface{} `json:"meta"` + // The date and time the live input was last modified. + Modified time.Time `json:"modified" format:"date-time"` + // A unique identifier for a live input. + Uid string `json:"uid"` + JSON liveInputListResponseLiveInputJSON `json:"-"` +} + +// liveInputListResponseLiveInputJSON contains the JSON metadata for the struct +// [LiveInputListResponseLiveInput] +type liveInputListResponseLiveInputJSON struct { + Created apijson.Field + DeleteRecordingAfterDays apijson.Field + Meta apijson.Field + Modified apijson.Field + Uid apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputListResponseLiveInput) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputListResponseLiveInputJSON) RawJSON() string { + return r.raw +} + +type LiveInputNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Sets the creator ID asssociated with this live input. + DefaultCreator param.Field[string] `json:"defaultCreator"` + // Indicates the number of days after which the live inputs recordings will be + // deleted. When a stream completes and the recording is ready, the value is used + // to calculate a scheduled deletion date for that recording. Omit the field to + // indicate no change, or include with a `null` value to remove an existing + // scheduled deletion. + DeleteRecordingAfterDays param.Field[float64] `json:"deleteRecordingAfterDays"` + // A user modifiable key-value store used to reference other systems of record for + // managing live inputs. + Meta param.Field[interface{}] `json:"meta"` + // Records the input to a Cloudflare Stream video. Behavior depends on the mode. In + // most cases, the video will initially be viewable as a live video and transition + // to on-demand after a condition is satisfied. + Recording param.Field[LiveInputNewParamsRecording] `json:"recording"` +} + +func (r LiveInputNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Records the input to a Cloudflare Stream video. Behavior depends on the mode. In +// most cases, the video will initially be viewable as a live video and transition +// to on-demand after a condition is satisfied. +type LiveInputNewParamsRecording struct { + // Lists the origins allowed to display videos created with this input. Enter + // allowed origin domains in an array and use `*` for wildcard subdomains. An empty + // array allows videos to be viewed on any origin. + AllowedOrigins param.Field[[]string] `json:"allowedOrigins"` + // Specifies the recording behavior for the live input. Set this value to `off` to + // prevent a recording. Set the value to `automatic` to begin a recording and + // transition to on-demand after Stream Live stops receiving input. + Mode param.Field[LiveInputNewParamsRecordingMode] `json:"mode"` + // Indicates if a video using the live input has the `requireSignedURLs` property + // set. Also enforces access controls on any video recording of the livestream with + // the live input. + RequireSignedURLs param.Field[bool] `json:"requireSignedURLs"` + // Determines the amount of time a live input configured in `automatic` mode should + // wait before a recording transitions from live to on-demand. `0` is recommended + // for most use cases and indicates the platform default should be used. + TimeoutSeconds param.Field[int64] `json:"timeoutSeconds"` +} + +func (r LiveInputNewParamsRecording) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Specifies the recording behavior for the live input. Set this value to `off` to +// prevent a recording. Set the value to `automatic` to begin a recording and +// transition to on-demand after Stream Live stops receiving input. +type LiveInputNewParamsRecordingMode string + +const ( + LiveInputNewParamsRecordingModeOff LiveInputNewParamsRecordingMode = "off" + LiveInputNewParamsRecordingModeAutomatic LiveInputNewParamsRecordingMode = "automatic" +) + +type LiveInputNewResponseEnvelope struct { + Errors []LiveInputNewResponseEnvelopeErrors `json:"errors,required"` + Messages []LiveInputNewResponseEnvelopeMessages `json:"messages,required"` + // Details about a live input. + Result StreamLiveInput `json:"result,required"` + // Whether the API call was successful + Success LiveInputNewResponseEnvelopeSuccess `json:"success,required"` + JSON liveInputNewResponseEnvelopeJSON `json:"-"` +} + +// liveInputNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [LiveInputNewResponseEnvelope] +type liveInputNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LiveInputNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON liveInputNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// liveInputNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [LiveInputNewResponseEnvelopeErrors] +type liveInputNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LiveInputNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON liveInputNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// liveInputNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [LiveInputNewResponseEnvelopeMessages] +type liveInputNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LiveInputNewResponseEnvelopeSuccess bool + +const ( + LiveInputNewResponseEnvelopeSuccessTrue LiveInputNewResponseEnvelopeSuccess = true +) + +type LiveInputUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Sets the creator ID asssociated with this live input. + DefaultCreator param.Field[string] `json:"defaultCreator"` + // Indicates the number of days after which the live inputs recordings will be + // deleted. When a stream completes and the recording is ready, the value is used + // to calculate a scheduled deletion date for that recording. Omit the field to + // indicate no change, or include with a `null` value to remove an existing + // scheduled deletion. + DeleteRecordingAfterDays param.Field[float64] `json:"deleteRecordingAfterDays"` + // A user modifiable key-value store used to reference other systems of record for + // managing live inputs. + Meta param.Field[interface{}] `json:"meta"` + // Records the input to a Cloudflare Stream video. Behavior depends on the mode. In + // most cases, the video will initially be viewable as a live video and transition + // to on-demand after a condition is satisfied. + Recording param.Field[LiveInputUpdateParamsRecording] `json:"recording"` +} + +func (r LiveInputUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Records the input to a Cloudflare Stream video. Behavior depends on the mode. In +// most cases, the video will initially be viewable as a live video and transition +// to on-demand after a condition is satisfied. +type LiveInputUpdateParamsRecording struct { + // Lists the origins allowed to display videos created with this input. Enter + // allowed origin domains in an array and use `*` for wildcard subdomains. An empty + // array allows videos to be viewed on any origin. + AllowedOrigins param.Field[[]string] `json:"allowedOrigins"` + // Specifies the recording behavior for the live input. Set this value to `off` to + // prevent a recording. Set the value to `automatic` to begin a recording and + // transition to on-demand after Stream Live stops receiving input. + Mode param.Field[LiveInputUpdateParamsRecordingMode] `json:"mode"` + // Indicates if a video using the live input has the `requireSignedURLs` property + // set. Also enforces access controls on any video recording of the livestream with + // the live input. + RequireSignedURLs param.Field[bool] `json:"requireSignedURLs"` + // Determines the amount of time a live input configured in `automatic` mode should + // wait before a recording transitions from live to on-demand. `0` is recommended + // for most use cases and indicates the platform default should be used. + TimeoutSeconds param.Field[int64] `json:"timeoutSeconds"` +} + +func (r LiveInputUpdateParamsRecording) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Specifies the recording behavior for the live input. Set this value to `off` to +// prevent a recording. Set the value to `automatic` to begin a recording and +// transition to on-demand after Stream Live stops receiving input. +type LiveInputUpdateParamsRecordingMode string + +const ( + LiveInputUpdateParamsRecordingModeOff LiveInputUpdateParamsRecordingMode = "off" + LiveInputUpdateParamsRecordingModeAutomatic LiveInputUpdateParamsRecordingMode = "automatic" +) + +type LiveInputUpdateResponseEnvelope struct { + Errors []LiveInputUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []LiveInputUpdateResponseEnvelopeMessages `json:"messages,required"` + // Details about a live input. + Result StreamLiveInput `json:"result,required"` + // Whether the API call was successful + Success LiveInputUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON liveInputUpdateResponseEnvelopeJSON `json:"-"` +} + +// liveInputUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [LiveInputUpdateResponseEnvelope] +type liveInputUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LiveInputUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON liveInputUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// liveInputUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [LiveInputUpdateResponseEnvelopeErrors] +type liveInputUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LiveInputUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON liveInputUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// liveInputUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [LiveInputUpdateResponseEnvelopeMessages] +type liveInputUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LiveInputUpdateResponseEnvelopeSuccess bool + +const ( + LiveInputUpdateResponseEnvelopeSuccessTrue LiveInputUpdateResponseEnvelopeSuccess = true +) + +type LiveInputListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Includes the total number of videos associated with the submitted query + // parameters. + IncludeCounts param.Field[bool] `query:"include_counts"` +} + +// URLQuery serializes [LiveInputListParams]'s query parameters as `url.Values`. +func (r LiveInputListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type LiveInputListResponseEnvelope struct { + Errors []LiveInputListResponseEnvelopeErrors `json:"errors,required"` + Messages []LiveInputListResponseEnvelopeMessages `json:"messages,required"` + Result LiveInputListResponse `json:"result,required"` + // Whether the API call was successful + Success LiveInputListResponseEnvelopeSuccess `json:"success,required"` + JSON liveInputListResponseEnvelopeJSON `json:"-"` +} + +// liveInputListResponseEnvelopeJSON contains the JSON metadata for the struct +// [LiveInputListResponseEnvelope] +type liveInputListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LiveInputListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON liveInputListResponseEnvelopeErrorsJSON `json:"-"` +} + +// liveInputListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [LiveInputListResponseEnvelopeErrors] +type liveInputListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LiveInputListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON liveInputListResponseEnvelopeMessagesJSON `json:"-"` +} + +// liveInputListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [LiveInputListResponseEnvelopeMessages] +type liveInputListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LiveInputListResponseEnvelopeSuccess bool + +const ( + LiveInputListResponseEnvelopeSuccessTrue LiveInputListResponseEnvelopeSuccess = true +) + +type LiveInputDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type LiveInputGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type LiveInputGetResponseEnvelope struct { + Errors []LiveInputGetResponseEnvelopeErrors `json:"errors,required"` + Messages []LiveInputGetResponseEnvelopeMessages `json:"messages,required"` + // Details about a live input. + Result StreamLiveInput `json:"result,required"` + // Whether the API call was successful + Success LiveInputGetResponseEnvelopeSuccess `json:"success,required"` + JSON liveInputGetResponseEnvelopeJSON `json:"-"` +} + +// liveInputGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [LiveInputGetResponseEnvelope] +type liveInputGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LiveInputGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON liveInputGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// liveInputGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [LiveInputGetResponseEnvelopeErrors] +type liveInputGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LiveInputGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON liveInputGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// liveInputGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [LiveInputGetResponseEnvelopeMessages] +type liveInputGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LiveInputGetResponseEnvelopeSuccess bool + +const ( + LiveInputGetResponseEnvelopeSuccessTrue LiveInputGetResponseEnvelopeSuccess = true +) diff --git a/stream/liveinput_test.go b/stream/liveinput_test.go new file mode 100644 index 00000000000..a1eb60ec81f --- /dev/null +++ b/stream/liveinput_test.go @@ -0,0 +1,180 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/stream" +) + +func TestLiveInputNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Stream.LiveInputs.New(context.TODO(), stream.LiveInputNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + DefaultCreator: cloudflare.F("string"), + DeleteRecordingAfterDays: cloudflare.F(45.000000), + Meta: cloudflare.F[any](map[string]interface{}{ + "name": "test stream 1", + }), + Recording: cloudflare.F(stream.LiveInputNewParamsRecording{ + AllowedOrigins: cloudflare.F([]string{"example.com"}), + Mode: cloudflare.F(stream.LiveInputNewParamsRecordingModeOff), + RequireSignedURLs: cloudflare.F(false), + TimeoutSeconds: cloudflare.F(int64(0)), + }), + }) + 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 TestLiveInputUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Stream.LiveInputs.Update( + context.TODO(), + "66be4bf738797e01e1fca35a7bdecdcd", + stream.LiveInputUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + DefaultCreator: cloudflare.F("string"), + DeleteRecordingAfterDays: cloudflare.F(45.000000), + Meta: cloudflare.F[any](map[string]interface{}{ + "name": "test stream 1", + }), + Recording: cloudflare.F(stream.LiveInputUpdateParamsRecording{ + AllowedOrigins: cloudflare.F([]string{"example.com"}), + Mode: cloudflare.F(stream.LiveInputUpdateParamsRecordingModeOff), + RequireSignedURLs: cloudflare.F(false), + TimeoutSeconds: cloudflare.F(int64(0)), + }), + }, + ) + 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 TestLiveInputListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Stream.LiveInputs.List(context.TODO(), stream.LiveInputListParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + IncludeCounts: cloudflare.F(true), + }) + 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 TestLiveInputDelete(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("user@example.com"), + ) + err := client.Stream.LiveInputs.Delete( + context.TODO(), + "66be4bf738797e01e1fca35a7bdecdcd", + stream.LiveInputDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestLiveInputGet(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("user@example.com"), + ) + _, err := client.Stream.LiveInputs.Get( + context.TODO(), + "66be4bf738797e01e1fca35a7bdecdcd", + stream.LiveInputGetParams{ + AccountID: cloudflare.F("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/stream/liveinputoutput.go b/stream/liveinputoutput.go new file mode 100644 index 00000000000..409d4cbac6b --- /dev/null +++ b/stream/liveinputoutput.go @@ -0,0 +1,403 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// LiveInputOutputService 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 [NewLiveInputOutputService] method +// instead. +type LiveInputOutputService struct { + Options []option.RequestOption +} + +// NewLiveInputOutputService 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 NewLiveInputOutputService(opts ...option.RequestOption) (r *LiveInputOutputService) { + r = &LiveInputOutputService{} + r.Options = opts + return +} + +// Creates a new output that can be used to simulcast or restream live video to +// other RTMP or SRT destinations. Outputs are always linked to a specific live +// input — one live input can have many outputs. +func (r *LiveInputOutputService) New(ctx context.Context, liveInputIdentifier string, params LiveInputOutputNewParams, opts ...option.RequestOption) (res *StreamOutput, err error) { + opts = append(r.Options[:], opts...) + var env LiveInputOutputNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s/outputs", params.AccountID, liveInputIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates the state of an output. +func (r *LiveInputOutputService) Update(ctx context.Context, liveInputIdentifier string, outputIdentifier string, params LiveInputOutputUpdateParams, opts ...option.RequestOption) (res *StreamOutput, err error) { + opts = append(r.Options[:], opts...) + var env LiveInputOutputUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s/outputs/%s", params.AccountID, liveInputIdentifier, outputIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Retrieves all outputs associated with a specified live input. +func (r *LiveInputOutputService) List(ctx context.Context, liveInputIdentifier string, query LiveInputOutputListParams, opts ...option.RequestOption) (res *[]StreamOutput, err error) { + opts = append(r.Options[:], opts...) + var env LiveInputOutputListResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s/outputs", query.AccountID, liveInputIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes an output and removes it from the associated live input. +func (r *LiveInputOutputService) Delete(ctx context.Context, liveInputIdentifier string, outputIdentifier string, body LiveInputOutputDeleteParams, opts ...option.RequestOption) (err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s/outputs/%s", body.AccountID, liveInputIdentifier, outputIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) + return +} + +type StreamOutput struct { + // When enabled, live video streamed to the associated live input will be sent to + // the output URL. When disabled, live video will not be sent to the output URL, + // even when streaming to the associated live input. Use this to control precisely + // when you start and stop simulcasting to specific destinations like YouTube and + // Twitch. + Enabled bool `json:"enabled"` + // The streamKey used to authenticate against an output's target. + StreamKey string `json:"streamKey"` + // A unique identifier for the output. + Uid string `json:"uid"` + // The URL an output uses to restream. + URL string `json:"url"` + JSON streamOutputJSON `json:"-"` +} + +// streamOutputJSON contains the JSON metadata for the struct [StreamOutput] +type streamOutputJSON struct { + Enabled apijson.Field + StreamKey apijson.Field + Uid apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamOutput) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamOutputJSON) RawJSON() string { + return r.raw +} + +type LiveInputOutputNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The streamKey used to authenticate against an output's target. + StreamKey param.Field[string] `json:"streamKey,required"` + // The URL an output uses to restream. + URL param.Field[string] `json:"url,required"` + // When enabled, live video streamed to the associated live input will be sent to + // the output URL. When disabled, live video will not be sent to the output URL, + // even when streaming to the associated live input. Use this to control precisely + // when you start and stop simulcasting to specific destinations like YouTube and + // Twitch. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r LiveInputOutputNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type LiveInputOutputNewResponseEnvelope struct { + Errors []LiveInputOutputNewResponseEnvelopeErrors `json:"errors,required"` + Messages []LiveInputOutputNewResponseEnvelopeMessages `json:"messages,required"` + Result StreamOutput `json:"result,required"` + // Whether the API call was successful + Success LiveInputOutputNewResponseEnvelopeSuccess `json:"success,required"` + JSON liveInputOutputNewResponseEnvelopeJSON `json:"-"` +} + +// liveInputOutputNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [LiveInputOutputNewResponseEnvelope] +type liveInputOutputNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputOutputNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputOutputNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LiveInputOutputNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON liveInputOutputNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// liveInputOutputNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [LiveInputOutputNewResponseEnvelopeErrors] +type liveInputOutputNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputOutputNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputOutputNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LiveInputOutputNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON liveInputOutputNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// liveInputOutputNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [LiveInputOutputNewResponseEnvelopeMessages] +type liveInputOutputNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputOutputNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputOutputNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LiveInputOutputNewResponseEnvelopeSuccess bool + +const ( + LiveInputOutputNewResponseEnvelopeSuccessTrue LiveInputOutputNewResponseEnvelopeSuccess = true +) + +type LiveInputOutputUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // When enabled, live video streamed to the associated live input will be sent to + // the output URL. When disabled, live video will not be sent to the output URL, + // even when streaming to the associated live input. Use this to control precisely + // when you start and stop simulcasting to specific destinations like YouTube and + // Twitch. + Enabled param.Field[bool] `json:"enabled,required"` +} + +func (r LiveInputOutputUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type LiveInputOutputUpdateResponseEnvelope struct { + Errors []LiveInputOutputUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []LiveInputOutputUpdateResponseEnvelopeMessages `json:"messages,required"` + Result StreamOutput `json:"result,required"` + // Whether the API call was successful + Success LiveInputOutputUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON liveInputOutputUpdateResponseEnvelopeJSON `json:"-"` +} + +// liveInputOutputUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [LiveInputOutputUpdateResponseEnvelope] +type liveInputOutputUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputOutputUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputOutputUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LiveInputOutputUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON liveInputOutputUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// liveInputOutputUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [LiveInputOutputUpdateResponseEnvelopeErrors] +type liveInputOutputUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputOutputUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputOutputUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LiveInputOutputUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON liveInputOutputUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// liveInputOutputUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [LiveInputOutputUpdateResponseEnvelopeMessages] +type liveInputOutputUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputOutputUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputOutputUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LiveInputOutputUpdateResponseEnvelopeSuccess bool + +const ( + LiveInputOutputUpdateResponseEnvelopeSuccessTrue LiveInputOutputUpdateResponseEnvelopeSuccess = true +) + +type LiveInputOutputListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type LiveInputOutputListResponseEnvelope struct { + Errors []LiveInputOutputListResponseEnvelopeErrors `json:"errors,required"` + Messages []LiveInputOutputListResponseEnvelopeMessages `json:"messages,required"` + Result []StreamOutput `json:"result,required"` + // Whether the API call was successful + Success LiveInputOutputListResponseEnvelopeSuccess `json:"success,required"` + JSON liveInputOutputListResponseEnvelopeJSON `json:"-"` +} + +// liveInputOutputListResponseEnvelopeJSON contains the JSON metadata for the +// struct [LiveInputOutputListResponseEnvelope] +type liveInputOutputListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputOutputListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputOutputListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LiveInputOutputListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON liveInputOutputListResponseEnvelopeErrorsJSON `json:"-"` +} + +// liveInputOutputListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [LiveInputOutputListResponseEnvelopeErrors] +type liveInputOutputListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputOutputListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputOutputListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LiveInputOutputListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON liveInputOutputListResponseEnvelopeMessagesJSON `json:"-"` +} + +// liveInputOutputListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [LiveInputOutputListResponseEnvelopeMessages] +type liveInputOutputListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LiveInputOutputListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r liveInputOutputListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LiveInputOutputListResponseEnvelopeSuccess bool + +const ( + LiveInputOutputListResponseEnvelopeSuccessTrue LiveInputOutputListResponseEnvelopeSuccess = true +) + +type LiveInputOutputDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} diff --git a/stream/liveinputoutput_test.go b/stream/liveinputoutput_test.go new file mode 100644 index 00000000000..af81560f398 --- /dev/null +++ b/stream/liveinputoutput_test.go @@ -0,0 +1,141 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/stream" +) + +func TestLiveInputOutputNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Stream.LiveInputs.Outputs.New( + context.TODO(), + "66be4bf738797e01e1fca35a7bdecdcd", + stream.LiveInputOutputNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + StreamKey: cloudflare.F("uzya-f19y-g2g9-a2ee-51j2"), + URL: cloudflare.F("rtmp://a.rtmp.youtube.com/live2"), + Enabled: cloudflare.F(true), + }, + ) + 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 TestLiveInputOutputUpdate(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("user@example.com"), + ) + _, err := client.Stream.LiveInputs.Outputs.Update( + context.TODO(), + "66be4bf738797e01e1fca35a7bdecdcd", + "baea4d9c515887b80289d5c33cf01145", + stream.LiveInputOutputUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Enabled: cloudflare.F(true), + }, + ) + 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 TestLiveInputOutputList(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("user@example.com"), + ) + _, err := client.Stream.LiveInputs.Outputs.List( + context.TODO(), + "66be4bf738797e01e1fca35a7bdecdcd", + stream.LiveInputOutputListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestLiveInputOutputDelete(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("user@example.com"), + ) + err := client.Stream.LiveInputs.Outputs.Delete( + context.TODO(), + "66be4bf738797e01e1fca35a7bdecdcd", + "baea4d9c515887b80289d5c33cf01145", + stream.LiveInputOutputDeleteParams{ + AccountID: cloudflare.F("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/stream/stream.go b/stream/stream.go new file mode 100644 index 00000000000..64a8119c4e8 --- /dev/null +++ b/stream/stream.go @@ -0,0 +1,563 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// StreamService 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 [NewStreamService] method instead. +type StreamService struct { + Options []option.RequestOption + AudioTracks *AudioTrackService + Videos *VideoService + Clips *ClipService + Copies *CopyService + DirectUploads *DirectUploadService + Keys *KeyService + LiveInputs *LiveInputService + Watermarks *WatermarkService + Webhooks *WebhookService + Captions *CaptionService + Downloads *DownloadService + Embeds *EmbedService + Tokens *TokenService +} + +// NewStreamService 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 NewStreamService(opts ...option.RequestOption) (r *StreamService) { + r = &StreamService{} + r.Options = opts + r.AudioTracks = NewAudioTrackService(opts...) + r.Videos = NewVideoService(opts...) + r.Clips = NewClipService(opts...) + r.Copies = NewCopyService(opts...) + r.DirectUploads = NewDirectUploadService(opts...) + r.Keys = NewKeyService(opts...) + r.LiveInputs = NewLiveInputService(opts...) + r.Watermarks = NewWatermarkService(opts...) + r.Webhooks = NewWebhookService(opts...) + r.Captions = NewCaptionService(opts...) + r.Downloads = NewDownloadService(opts...) + r.Embeds = NewEmbedService(opts...) + r.Tokens = NewTokenService(opts...) + return +} + +// Initiates a video upload using the TUS protocol. On success, the server responds +// with a status code 201 (created) and includes a `location` header to indicate +// where the content should be uploaded. Refer to https://tus.io for protocol +// details. +func (r *StreamService) New(ctx context.Context, params StreamNewParams, opts ...option.RequestOption) (err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + path := fmt.Sprintf("accounts/%s/stream", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, nil, opts...) + return +} + +// Lists up to 1000 videos from a single request. For a specific range, refer to +// the optional parameters. +func (r *StreamService) List(ctx context.Context, params StreamListParams, opts ...option.RequestOption) (res *[]StreamVideos, err error) { + opts = append(r.Options[:], opts...) + var env StreamListResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a video and its copies from Cloudflare Stream. +func (r *StreamService) Delete(ctx context.Context, identifier string, body StreamDeleteParams, opts ...option.RequestOption) (err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + path := fmt.Sprintf("accounts/%s/stream/%s", body.AccountID, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) + return +} + +// Fetches details for a single video. +func (r *StreamService) Get(ctx context.Context, identifier string, query StreamGetParams, opts ...option.RequestOption) (res *StreamVideos, err error) { + opts = append(r.Options[:], opts...) + var env StreamGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/%s", query.AccountID, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type StreamVideos struct { + // Lists the origins allowed to display the video. Enter allowed origin domains in + // an array and use `*` for wildcard subdomains. Empty arrays allow the video to be + // viewed on any origin. + AllowedOrigins []string `json:"allowedOrigins"` + // The date and time the media item was created. + Created time.Time `json:"created" format:"date-time"` + // A user-defined identifier for the media creator. + Creator string `json:"creator"` + // The duration of the video in seconds. A value of `-1` means the duration is + // unknown. The duration becomes available after the upload and before the video is + // ready. + Duration float64 `json:"duration"` + Input StreamVideosInput `json:"input"` + // The live input ID used to upload a video with Stream Live. + LiveInput string `json:"liveInput"` + // The maximum duration in seconds for a video upload. Can be set for a video that + // is not yet uploaded to limit its duration. Uploads that exceed the specified + // duration will fail during processing. A value of `-1` means the value is + // unknown. + MaxDurationSeconds int64 `json:"maxDurationSeconds"` + // A user modifiable key-value store used to reference other systems of record for + // managing videos. + Meta interface{} `json:"meta"` + // The date and time the media item was last modified. + Modified time.Time `json:"modified" format:"date-time"` + Playback StreamVideosPlayback `json:"playback"` + // The video's preview page URI. This field is omitted until encoding is complete. + Preview string `json:"preview" format:"uri"` + // Indicates whether the video is playable. The field is empty if the video is not + // ready for viewing or the live stream is still in progress. + ReadyToStream bool `json:"readyToStream"` + // Indicates the time at which the video became playable. The field is empty if the + // video is not ready for viewing or the live stream is still in progress. + ReadyToStreamAt time.Time `json:"readyToStreamAt" format:"date-time"` + // Indicates whether the video can be a accessed using the UID. When set to `true`, + // a signed token must be generated with a signing key to view the video. + RequireSignedURLs bool `json:"requireSignedURLs"` + // Indicates the date and time at which the video will be deleted. Omit the field + // to indicate no change, or include with a `null` value to remove an existing + // scheduled deletion. If specified, must be at least 30 days from upload time. + ScheduledDeletion time.Time `json:"scheduledDeletion" format:"date-time"` + // The size of the media item in bytes. + Size float64 `json:"size"` + // Specifies a detailed status for a video. If the `state` is `inprogress` or + // `error`, the `step` field returns `encoding` or `manifest`. If the `state` is + // `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the + // approximate percent of completion. If the `state` is `error`, `errorReasonCode` + // and `errorReasonText` provide additional details. + Status StreamVideosStatus `json:"status"` + // The media item's thumbnail URI. This field is omitted until encoding is + // complete. + Thumbnail string `json:"thumbnail" format:"uri"` + // The timestamp for a thumbnail image calculated as a percentage value of the + // video's duration. To convert from a second-wise timestamp to a percentage, + // divide the desired timestamp by the total duration of the video. If this value + // is not set, the default thumbnail image is taken from 0s of the video. + ThumbnailTimestampPct float64 `json:"thumbnailTimestampPct"` + // A Cloudflare-generated unique identifier for a media item. + Uid string `json:"uid"` + // The date and time the media item was uploaded. + Uploaded time.Time `json:"uploaded" format:"date-time"` + // The date and time when the video upload URL is no longer valid for direct user + // uploads. + UploadExpiry time.Time `json:"uploadExpiry" format:"date-time"` + Watermark StreamWatermarks `json:"watermark"` + JSON streamVideosJSON `json:"-"` +} + +// streamVideosJSON contains the JSON metadata for the struct [StreamVideos] +type streamVideosJSON struct { + AllowedOrigins apijson.Field + Created apijson.Field + Creator apijson.Field + Duration apijson.Field + Input apijson.Field + LiveInput apijson.Field + MaxDurationSeconds apijson.Field + Meta apijson.Field + Modified apijson.Field + Playback apijson.Field + Preview apijson.Field + ReadyToStream apijson.Field + ReadyToStreamAt apijson.Field + RequireSignedURLs apijson.Field + ScheduledDeletion apijson.Field + Size apijson.Field + Status apijson.Field + Thumbnail apijson.Field + ThumbnailTimestampPct apijson.Field + Uid apijson.Field + Uploaded apijson.Field + UploadExpiry apijson.Field + Watermark apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamVideos) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamVideosJSON) RawJSON() string { + return r.raw +} + +type StreamVideosInput struct { + // The video height in pixels. A value of `-1` means the height is unknown. The + // value becomes available after the upload and before the video is ready. + Height int64 `json:"height"` + // The video width in pixels. A value of `-1` means the width is unknown. The value + // becomes available after the upload and before the video is ready. + Width int64 `json:"width"` + JSON streamVideosInputJSON `json:"-"` +} + +// streamVideosInputJSON contains the JSON metadata for the struct +// [StreamVideosInput] +type streamVideosInputJSON struct { + Height apijson.Field + Width apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamVideosInput) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamVideosInputJSON) RawJSON() string { + return r.raw +} + +type StreamVideosPlayback struct { + // DASH Media Presentation Description for the video. + Dash string `json:"dash"` + // The HLS manifest for the video. + Hls string `json:"hls"` + JSON streamVideosPlaybackJSON `json:"-"` +} + +// streamVideosPlaybackJSON contains the JSON metadata for the struct +// [StreamVideosPlayback] +type streamVideosPlaybackJSON struct { + Dash apijson.Field + Hls apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamVideosPlayback) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamVideosPlaybackJSON) RawJSON() string { + return r.raw +} + +// Specifies a detailed status for a video. If the `state` is `inprogress` or +// `error`, the `step` field returns `encoding` or `manifest`. If the `state` is +// `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the +// approximate percent of completion. If the `state` is `error`, `errorReasonCode` +// and `errorReasonText` provide additional details. +type StreamVideosStatus struct { + // Specifies why the video failed to encode. This field is empty if the video is + // not in an `error` state. Preferred for programmatic use. + ErrorReasonCode string `json:"errorReasonCode"` + // Specifies why the video failed to encode using a human readable error message in + // English. This field is empty if the video is not in an `error` state. + ErrorReasonText string `json:"errorReasonText"` + // Indicates the size of the entire upload in bytes. The value must be a + // non-negative integer. + PctComplete string `json:"pctComplete"` + // Specifies the processing status for all quality levels for a video. + State StreamVideosStatusState `json:"state"` + JSON streamVideosStatusJSON `json:"-"` +} + +// streamVideosStatusJSON contains the JSON metadata for the struct +// [StreamVideosStatus] +type streamVideosStatusJSON struct { + ErrorReasonCode apijson.Field + ErrorReasonText apijson.Field + PctComplete apijson.Field + State apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamVideosStatus) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamVideosStatusJSON) RawJSON() string { + return r.raw +} + +// Specifies the processing status for all quality levels for a video. +type StreamVideosStatusState string + +const ( + StreamVideosStatusStatePendingupload StreamVideosStatusState = "pendingupload" + StreamVideosStatusStateDownloading StreamVideosStatusState = "downloading" + StreamVideosStatusStateQueued StreamVideosStatusState = "queued" + StreamVideosStatusStateInprogress StreamVideosStatusState = "inprogress" + StreamVideosStatusStateReady StreamVideosStatusState = "ready" + StreamVideosStatusStateError StreamVideosStatusState = "error" +) + +type StreamNewParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + // Specifies the TUS protocol version. This value must be included in every upload + // request. Notes: The only supported version of TUS protocol is 1.0.0. + TusResumable param.Field[StreamNewParamsTusResumable] `header:"Tus-Resumable,required"` + // Indicates the size of the entire upload in bytes. The value must be a + // non-negative integer. + UploadLength param.Field[int64] `header:"Upload-Length,required"` + // A user-defined identifier for the media creator. + UploadCreator param.Field[string] `header:"Upload-Creator"` + // Comma-separated key-value pairs following the TUS protocol specification. Values + // are Base-64 encoded. Supported keys: `name`, `requiresignedurls`, + // `allowedorigins`, `thumbnailtimestamppct`, `watermark`, `scheduleddeletion`. + UploadMetadata param.Field[string] `header:"Upload-Metadata"` +} + +// Specifies the TUS protocol version. This value must be included in every upload +// request. Notes: The only supported version of TUS protocol is 1.0.0. +type StreamNewParamsTusResumable string + +const ( + StreamNewParamsTusResumable1_0_0 StreamNewParamsTusResumable = "1.0.0" +) + +type StreamListParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + // Lists videos in ascending order of creation. + Asc param.Field[bool] `query:"asc"` + // A user-defined identifier for the media creator. + Creator param.Field[string] `query:"creator"` + // Lists videos created before the specified date. + End param.Field[time.Time] `query:"end" format:"date-time"` + // Includes the total number of videos associated with the submitted query + // parameters. + IncludeCounts param.Field[bool] `query:"include_counts"` + // Searches over the `name` key in the `meta` field. This field can be set with or + // after the upload request. + Search param.Field[string] `query:"search"` + // Lists videos created after the specified date. + Start param.Field[time.Time] `query:"start" format:"date-time"` + // Specifies the processing status for all quality levels for a video. + Status param.Field[StreamListParamsStatus] `query:"status"` + // Specifies whether the video is `vod` or `live`. + Type param.Field[string] `query:"type"` +} + +// URLQuery serializes [StreamListParams]'s query parameters as `url.Values`. +func (r StreamListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Specifies the processing status for all quality levels for a video. +type StreamListParamsStatus string + +const ( + StreamListParamsStatusPendingupload StreamListParamsStatus = "pendingupload" + StreamListParamsStatusDownloading StreamListParamsStatus = "downloading" + StreamListParamsStatusQueued StreamListParamsStatus = "queued" + StreamListParamsStatusInprogress StreamListParamsStatus = "inprogress" + StreamListParamsStatusReady StreamListParamsStatus = "ready" + StreamListParamsStatusError StreamListParamsStatus = "error" +) + +type StreamListResponseEnvelope struct { + Errors []StreamListResponseEnvelopeErrors `json:"errors,required"` + Messages []StreamListResponseEnvelopeMessages `json:"messages,required"` + Result []StreamVideos `json:"result,required"` + // Whether the API call was successful + Success StreamListResponseEnvelopeSuccess `json:"success,required"` + // The total number of remaining videos based on cursor position. + Range int64 `json:"range"` + // The total number of videos that match the provided filters. + Total int64 `json:"total"` + JSON streamListResponseEnvelopeJSON `json:"-"` +} + +// streamListResponseEnvelopeJSON contains the JSON metadata for the struct +// [StreamListResponseEnvelope] +type streamListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + Range apijson.Field + Total apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type StreamListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON streamListResponseEnvelopeErrorsJSON `json:"-"` +} + +// streamListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [StreamListResponseEnvelopeErrors] +type streamListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type StreamListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON streamListResponseEnvelopeMessagesJSON `json:"-"` +} + +// streamListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [StreamListResponseEnvelopeMessages] +type streamListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type StreamListResponseEnvelopeSuccess bool + +const ( + StreamListResponseEnvelopeSuccessTrue StreamListResponseEnvelopeSuccess = true +) + +type StreamDeleteParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type StreamGetParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type StreamGetResponseEnvelope struct { + Errors []StreamGetResponseEnvelopeErrors `json:"errors,required"` + Messages []StreamGetResponseEnvelopeMessages `json:"messages,required"` + Result StreamVideos `json:"result,required"` + // Whether the API call was successful + Success StreamGetResponseEnvelopeSuccess `json:"success,required"` + JSON streamGetResponseEnvelopeJSON `json:"-"` +} + +// streamGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [StreamGetResponseEnvelope] +type streamGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type StreamGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON streamGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// streamGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [StreamGetResponseEnvelopeErrors] +type streamGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type StreamGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON streamGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// streamGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [StreamGetResponseEnvelopeMessages] +type streamGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type StreamGetResponseEnvelopeSuccess bool + +const ( + StreamGetResponseEnvelopeSuccessTrue StreamGetResponseEnvelopeSuccess = true +) diff --git a/stream_test.go b/stream/stream_test.go similarity index 90% rename from stream_test.go rename to stream/stream_test.go index e33919d31f5..8224cae829d 100644 --- a/stream_test.go +++ b/stream/stream_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package stream_test import ( "context" @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/stream" ) func TestStreamNewWithOptionalParams(t *testing.T) { @@ -28,9 +29,9 @@ func TestStreamNewWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - err := client.Stream.New(context.TODO(), cloudflare.StreamNewParams{ + err := client.Stream.New(context.TODO(), stream.StreamNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - TusResumable: cloudflare.F(cloudflare.StreamNewParamsTusResumable1_0_0), + TusResumable: cloudflare.F(stream.StreamNewParamsTusResumable1_0_0), UploadLength: cloudflare.F(int64(0)), UploadCreator: cloudflare.F("creator-id_abcde12345"), UploadMetadata: cloudflare.F("name aGVsbG8gd29ybGQ=, requiresignedurls, allowedorigins ZXhhbXBsZS5jb20sdGVzdC5jb20="), @@ -58,7 +59,7 @@ func TestStreamListWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Stream.List(context.TODO(), cloudflare.StreamListParams{ + _, err := client.Stream.List(context.TODO(), stream.StreamListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Asc: cloudflare.F(true), Creator: cloudflare.F("creator-id_abcde12345"), @@ -66,7 +67,7 @@ func TestStreamListWithOptionalParams(t *testing.T) { IncludeCounts: cloudflare.F(true), Search: cloudflare.F("puppy.mp4"), Start: cloudflare.F(time.Now()), - Status: cloudflare.F(cloudflare.StreamListParamsStatusInprogress), + Status: cloudflare.F(stream.StreamListParamsStatusInprogress), Type: cloudflare.F("live"), }) if err != nil { @@ -95,7 +96,7 @@ func TestStreamDelete(t *testing.T) { err := client.Stream.Delete( context.TODO(), "ea95132c15732412d22c1476fa83f27a", - cloudflare.StreamDeleteParams{ + stream.StreamDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) @@ -125,7 +126,7 @@ func TestStreamGet(t *testing.T) { _, err := client.Stream.Get( context.TODO(), "ea95132c15732412d22c1476fa83f27a", - cloudflare.StreamGetParams{ + stream.StreamGetParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) diff --git a/stream/token.go b/stream/token.go new file mode 100644 index 00000000000..ab56b85a964 --- /dev/null +++ b/stream/token.go @@ -0,0 +1,221 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// TokenService 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 [NewTokenService] method instead. +type TokenService struct { + Options []option.RequestOption +} + +// NewTokenService 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 NewTokenService(opts ...option.RequestOption) (r *TokenService) { + r = &TokenService{} + r.Options = opts + return +} + +// Creates a signed URL token for a video. If a body is not provided in the +// request, a token is created with default values. +func (r *TokenService) New(ctx context.Context, identifier string, params TokenNewParams, opts ...option.RequestOption) (res *TokenNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env TokenNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/%s/token", params.AccountID, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TokenNewResponse struct { + // The signed token used with the signed URLs feature. + Token string `json:"token"` + JSON tokenNewResponseJSON `json:"-"` +} + +// tokenNewResponseJSON contains the JSON metadata for the struct +// [TokenNewResponse] +type tokenNewResponseJSON struct { + Token apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenNewResponseJSON) RawJSON() string { + return r.raw +} + +type TokenNewParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + // The optional ID of a Stream signing key. If present, the `pem` field is also + // required. + ID param.Field[string] `json:"id"` + // The optional list of access rule constraints on the token. Access can be blocked + // or allowed based on an IP, IP range, or by country. Access rules are evaluated + // from first to last. If a rule matches, the associated action is applied and no + // further rules are evaluated. + AccessRules param.Field[[]TokenNewParamsAccessRule] `json:"accessRules"` + // The optional boolean value that enables using signed tokens to access MP4 + // download links for a video. + Downloadable param.Field[bool] `json:"downloadable"` + // The optional unix epoch timestamp that specficies the time after a token is not + // accepted. The maximum time specification is 24 hours from issuing time. If this + // field is not set, the default is one hour after issuing. + Exp param.Field[int64] `json:"exp"` + // The optional unix epoch timestamp that specifies the time before a the token is + // not accepted. If this field is not set, the default is one hour before issuing. + Nbf param.Field[int64] `json:"nbf"` + // The optional base64 encoded private key in PEM format associated with a Stream + // signing key. If present, the `id` field is also required. + Pem param.Field[string] `json:"pem"` +} + +func (r TokenNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Defines rules for fine-grained control over content than signed URL tokens +// alone. Access rules primarily make tokens conditionally valid based on user +// information. Access Rules are specified on token payloads as the `accessRules` +// property containing an array of Rule objects. +type TokenNewParamsAccessRule struct { + // The action to take when a request matches a rule. If the action is `block`, the + // signed token blocks views for viewers matching the rule. + Action param.Field[TokenNewParamsAccessRulesAction] `json:"action"` + // An array of 2-letter country codes in ISO 3166-1 Alpha-2 format used to match + // requests. + Country param.Field[[]string] `json:"country"` + // An array of IPv4 or IPV6 addresses or CIDRs used to match requests. + IP param.Field[[]string] `json:"ip"` + // Lists available rule types to match for requests. An `any` type matches all + // requests and can be used as a wildcard to apply default actions after other + // rules. + Type param.Field[TokenNewParamsAccessRulesType] `json:"type"` +} + +func (r TokenNewParamsAccessRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The action to take when a request matches a rule. If the action is `block`, the +// signed token blocks views for viewers matching the rule. +type TokenNewParamsAccessRulesAction string + +const ( + TokenNewParamsAccessRulesActionAllow TokenNewParamsAccessRulesAction = "allow" + TokenNewParamsAccessRulesActionBlock TokenNewParamsAccessRulesAction = "block" +) + +// Lists available rule types to match for requests. An `any` type matches all +// requests and can be used as a wildcard to apply default actions after other +// rules. +type TokenNewParamsAccessRulesType string + +const ( + TokenNewParamsAccessRulesTypeAny TokenNewParamsAccessRulesType = "any" + TokenNewParamsAccessRulesTypeIPSrc TokenNewParamsAccessRulesType = "ip.src" + TokenNewParamsAccessRulesTypeIPGeoipCountry TokenNewParamsAccessRulesType = "ip.geoip.country" +) + +type TokenNewResponseEnvelope struct { + Errors []TokenNewResponseEnvelopeErrors `json:"errors,required"` + Messages []TokenNewResponseEnvelopeMessages `json:"messages,required"` + Result TokenNewResponse `json:"result,required"` + // Whether the API call was successful + Success TokenNewResponseEnvelopeSuccess `json:"success,required"` + JSON tokenNewResponseEnvelopeJSON `json:"-"` +} + +// tokenNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [TokenNewResponseEnvelope] +type tokenNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TokenNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tokenNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// tokenNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [TokenNewResponseEnvelopeErrors] +type tokenNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TokenNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tokenNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// tokenNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [TokenNewResponseEnvelopeMessages] +type tokenNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TokenNewResponseEnvelopeSuccess bool + +const ( + TokenNewResponseEnvelopeSuccessTrue TokenNewResponseEnvelopeSuccess = true +) diff --git a/stream/token_test.go b/stream/token_test.go new file mode 100644 index 00000000000..c6288fbb747 --- /dev/null +++ b/stream/token_test.go @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/stream" +) + +func TestTokenNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Stream.Tokens.New( + context.TODO(), + "ea95132c15732412d22c1476fa83f27a", + stream.TokenNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + ID: cloudflare.F("ab0d4ef71g4425f8dcba9041231813000"), + AccessRules: cloudflare.F([]stream.TokenNewParamsAccessRule{{ + Action: cloudflare.F(stream.TokenNewParamsAccessRulesActionBlock), + Country: cloudflare.F([]string{"US", "MX"}), + IP: cloudflare.F([]string{"string", "string", "string"}), + Type: cloudflare.F(stream.TokenNewParamsAccessRulesTypeIPGeoipCountry), + }, { + Action: cloudflare.F(stream.TokenNewParamsAccessRulesActionAllow), + Country: cloudflare.F([]string{"string", "string", "string"}), + IP: cloudflare.F([]string{"93.184.216.0/24", "2400:cb00::/32"}), + Type: cloudflare.F(stream.TokenNewParamsAccessRulesTypeIPSrc), + }, { + Action: cloudflare.F(stream.TokenNewParamsAccessRulesActionBlock), + Country: cloudflare.F([]string{"string", "string", "string"}), + IP: cloudflare.F([]string{"string", "string", "string"}), + Type: cloudflare.F(stream.TokenNewParamsAccessRulesTypeAny), + }}), + Downloadable: cloudflare.F(true), + Exp: cloudflare.F(int64(0)), + Nbf: cloudflare.F(int64(0)), + Pem: cloudflare.F("LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcEFJQkFBS0NBUUVBc284dnBvOFpEWXRkOUgzbWlPaW1qYXAzVXlVM0oyZ3kwTUYvN1R4blJuRnkwRHpDCkxqUk9naFZsQ0hPQmxsd3NVaE9GU0lyYnN4K05tUTdBeS90TFpXSGxuVGF3UWJ5WGZGOStJeDhVSnNlSHBGV1oKNVF5Z1JYd2liSjh1MVVsZ2xlcmZHMkpueldjVXpZTzEySktZN3doSkw1ajROMWgxZFJNUXQ5Q1pkZFlCQWRzOQpCdk02cjRFMDcxQkhQekhWeDMrUTI1VWtubGdUNXIwS3FiM1E1Y0dlTlBXY1JreW1ybkJEWWR0OXR4eFFMb1dPCllzNXdsMnVYWFVYL0VGcDMwajU0Nmp6czllWExLYlNDbjJjTDZFVE96Y2x3aG9DRGx2a2VQT05rUE9LMDVKNUMKTm1TdFdhMG9hV1VGRzM0MFl3cVVrWGt4OU9tNndXd1JldU1uU1FJREFRQUJBb0lCQUFJOHo1ck5kOEdtOGJBMgo1S3pxQjI1R2lOVENwbUNJeW53NXRJWHZTQmNHcEdydUcvdlN2WG9kVlFVSVY0TWdHQkVXUEFrVzdsNWVBcHI4CnA1ZFd5SkRXYTNkdklFSE9vSEpYU3dBYksxZzZEMTNVa2NkZ1EyRGpoNVhuWDhHZCtBY2c2SmRTQWgxOWtYSHEKMk54RUtBVDB6Ri83a1g2MkRkREFBcWxmQkpGSXJodVIvZUdEVWh4L2piTTRhQ2JCcFdiM0pnRE9OYm5tS1ZoMwpxS2ZwZmRZZENZU1lzWUxrNTlxRDF2VFNwUVFUQ0VadW9VKzNzRVNhdkJzaUs1bU0vTzY5ZkRMRXNURG1MeTVQCmhEK3BMQXI0SlhNNjFwRGVBS0l3cUVqWWJybXlDRHRXTUdJNnZzZ0E1eXQzUUJaME9vV2w5QUkwdWxoZ3p4dXQKZ2ZFNTRRRUNnWUVBN0F3a0lhVEEzYmQ4Nk9jSVZnNFlrWGk1cm5aNDdsM1k4V24zcjIzUmVISXhLdkllRUtSbgp5bUlFNDFtRVBBSmlGWFpLK1VPTXdkeS9EcnFJUithT1JiT2NiV01jWUg2QzgvbG1wdVJFaXE3SW1Ub3VWcnA4CnlnUkprMWprVDA4cTIvNmg4eTBEdjJqMitsaHFXNzRNOUt0cmwxcTRlWmZRUFREL01tR1NnTWtDZ1lFQXdhY04KaSttN1p6dnJtL3NuekF2VlZ5SEtwZHVUUjNERk1naC9maC9tZ0ZHZ1RwZWtUOVV5b3FleGNYQXdwMVlhL01iQQoyNTVJVDZRbXZZTm5yNXp6Wmxic2tMV0hsYllvbWhmWnVXTHhXR3hRaEFORWdaMFVVdUVTRGMvbWx2UXZHbEtSCkZoaGhBUWlVSmdDamhPaHk1SlBiNGFldGRKd0UxK09lVWRFaE1vRUNnWUVBNG8yZ25CM1o4ck5xa3NzemlBek4KYmNuMlJVbDJOaW9pejBwS3JMaDFaT29NNE5BekpQdjJsaHRQMzdtS0htS1hLMHczRjFqTEgwSTBxZmxFVmVZbQpSU1huakdHazJjUnpBYUVzOGgrQzNheDE0Z01pZUtGU3BqNUpNOEFNbVVZOXQ1cUVhN2FYc3o0V1ZoOUlMYmVTCkRiNzlhKzVwd21LQVBrcnBsTHhyZFdrQ2dZQlNNSHVBWVdBbmJYZ1BDS2FZWklGVWJNUWNacmY0ZnpWQ2lmYksKYWZHampvRlNPZXdEOGdGK3BWdWJRTGwxbkFieU44ek1xVDRaaHhybUhpcFlqMjJDaHV2NmN3RXJtbGRiSnpwQwpBMnRaVXdkTk1ESFlMUG5lUHlZeGRJWnlsUXFVeW14SGkydElUQUxNcWtLOGV3ZWdXZHpkeGhQSlJScU5JazhrCmZIVHhnUUtCZ1FEUFc2UXIxY3F3QjNUdnVWdWR4WGRqUTdIcDFodXhrNEVWaEFJZllKNFhSTW1NUE5YS28wdHUKdUt6LzE0QW14R0dvSWJxYVc1bDMzeFNteUxhem84clNUN0tSTjVKME9JSHcrZkR5SFgxdHpVSjZCTldDcEFTcwpjbWdNK0htSzVON0w2bkNaZFJQY2IwU1hGaVRQUGhCUG1PVWFDUnpER0ZMK2JYM1VwajJKbWc9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo="), + }, + ) + 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/stream/video.go b/stream/video.go new file mode 100644 index 00000000000..ebec270f8a5 --- /dev/null +++ b/stream/video.go @@ -0,0 +1,174 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// VideoService 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 [NewVideoService] method instead. +type VideoService struct { + Options []option.RequestOption +} + +// NewVideoService 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 NewVideoService(opts ...option.RequestOption) (r *VideoService) { + r = &VideoService{} + r.Options = opts + return +} + +// Returns information about an account's storage use. +func (r *VideoService) StorageUsage(ctx context.Context, params VideoStorageUsageParams, opts ...option.RequestOption) (res *VideoStorageUsageResponse, err error) { + opts = append(r.Options[:], opts...) + var env VideoStorageUsageResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/storage-usage", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type VideoStorageUsageResponse struct { + // A user-defined identifier for the media creator. + Creator string `json:"creator"` + // The total minutes of video content stored in the account. + TotalStorageMinutes int64 `json:"totalStorageMinutes"` + // The storage capacity alloted for the account. + TotalStorageMinutesLimit int64 `json:"totalStorageMinutesLimit"` + // The total count of videos associated with the account. + VideoCount int64 `json:"videoCount"` + JSON videoStorageUsageResponseJSON `json:"-"` +} + +// videoStorageUsageResponseJSON contains the JSON metadata for the struct +// [VideoStorageUsageResponse] +type videoStorageUsageResponseJSON struct { + Creator apijson.Field + TotalStorageMinutes apijson.Field + TotalStorageMinutesLimit apijson.Field + VideoCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VideoStorageUsageResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r videoStorageUsageResponseJSON) RawJSON() string { + return r.raw +} + +type VideoStorageUsageParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + // A user-defined identifier for the media creator. + Creator param.Field[string] `query:"creator"` +} + +// URLQuery serializes [VideoStorageUsageParams]'s query parameters as +// `url.Values`. +func (r VideoStorageUsageParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type VideoStorageUsageResponseEnvelope struct { + Errors []VideoStorageUsageResponseEnvelopeErrors `json:"errors,required"` + Messages []VideoStorageUsageResponseEnvelopeMessages `json:"messages,required"` + Result VideoStorageUsageResponse `json:"result,required"` + // Whether the API call was successful + Success VideoStorageUsageResponseEnvelopeSuccess `json:"success,required"` + JSON videoStorageUsageResponseEnvelopeJSON `json:"-"` +} + +// videoStorageUsageResponseEnvelopeJSON contains the JSON metadata for the struct +// [VideoStorageUsageResponseEnvelope] +type videoStorageUsageResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VideoStorageUsageResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r videoStorageUsageResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type VideoStorageUsageResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON videoStorageUsageResponseEnvelopeErrorsJSON `json:"-"` +} + +// videoStorageUsageResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [VideoStorageUsageResponseEnvelopeErrors] +type videoStorageUsageResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VideoStorageUsageResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r videoStorageUsageResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type VideoStorageUsageResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON videoStorageUsageResponseEnvelopeMessagesJSON `json:"-"` +} + +// videoStorageUsageResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [VideoStorageUsageResponseEnvelopeMessages] +type videoStorageUsageResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VideoStorageUsageResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r videoStorageUsageResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type VideoStorageUsageResponseEnvelopeSuccess bool + +const ( + VideoStorageUsageResponseEnvelopeSuccessTrue VideoStorageUsageResponseEnvelopeSuccess = true +) diff --git a/stream/video_test.go b/stream/video_test.go new file mode 100644 index 00000000000..fa8d69b8844 --- /dev/null +++ b/stream/video_test.go @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/stream" +) + +func TestVideoStorageUsageWithOptionalParams(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("user@example.com"), + ) + _, err := client.Stream.Videos.StorageUsage(context.TODO(), stream.VideoStorageUsageParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Creator: cloudflare.F("creator-id_abcde12345"), + }) + 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/stream/watermark.go b/stream/watermark.go new file mode 100644 index 00000000000..d9e92584a71 --- /dev/null +++ b/stream/watermark.go @@ -0,0 +1,568 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// WatermarkService 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 [NewWatermarkService] method instead. +type WatermarkService struct { + Options []option.RequestOption +} + +// NewWatermarkService 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 NewWatermarkService(opts ...option.RequestOption) (r *WatermarkService) { + r = &WatermarkService{} + r.Options = opts + return +} + +// Creates watermark profiles using a single `HTTP POST multipart/form-data` +// request. +func (r *WatermarkService) New(ctx context.Context, params WatermarkNewParams, opts ...option.RequestOption) (res *WatermarkNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env WatermarkNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/watermarks", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists all watermark profiles for an account. +func (r *WatermarkService) List(ctx context.Context, query WatermarkListParams, opts ...option.RequestOption) (res *[]StreamWatermarks, err error) { + opts = append(r.Options[:], opts...) + var env WatermarkListResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/watermarks", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a watermark profile. +func (r *WatermarkService) Delete(ctx context.Context, identifier string, body WatermarkDeleteParams, opts ...option.RequestOption) (res *WatermarkDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env WatermarkDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/watermarks/%s", body.AccountID, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Retrieves details for a single watermark profile. +func (r *WatermarkService) Get(ctx context.Context, identifier string, query WatermarkGetParams, opts ...option.RequestOption) (res *WatermarkGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env WatermarkGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/watermarks/%s", query.AccountID, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type StreamWatermarks struct { + // The date and a time a watermark profile was created. + Created time.Time `json:"created" format:"date-time"` + // The source URL for a downloaded image. If the watermark profile was created via + // direct upload, this field is null. + DownloadedFrom string `json:"downloadedFrom"` + // The height of the image in pixels. + Height int64 `json:"height"` + // A short description of the watermark profile. + Name string `json:"name"` + // The translucency of the image. A value of `0.0` makes the image completely + // transparent, and `1.0` makes the image completely opaque. Note that if the image + // is already semi-transparent, setting this to `1.0` will not make the image + // completely opaque. + Opacity float64 `json:"opacity"` + // The whitespace between the adjacent edges (determined by position) of the video + // and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded + // video width or length, as determined by the algorithm. + Padding float64 `json:"padding"` + // The location of the image. Valid positions are: `upperRight`, `upperLeft`, + // `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the + // `padding` parameter. + Position string `json:"position"` + // The size of the image relative to the overall size of the video. This parameter + // will adapt to horizontal and vertical videos automatically. `0.0` indicates no + // scaling (use the size of the image as-is), and `1.0 `fills the entire video. + Scale float64 `json:"scale"` + // The size of the image in bytes. + Size float64 `json:"size"` + // The unique identifier for a watermark profile. + Uid string `json:"uid"` + // The width of the image in pixels. + Width int64 `json:"width"` + JSON streamWatermarksJSON `json:"-"` +} + +// streamWatermarksJSON contains the JSON metadata for the struct +// [StreamWatermarks] +type streamWatermarksJSON struct { + Created apijson.Field + DownloadedFrom apijson.Field + Height apijson.Field + Name apijson.Field + Opacity apijson.Field + Padding apijson.Field + Position apijson.Field + Scale apijson.Field + Size apijson.Field + Uid apijson.Field + Width apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StreamWatermarks) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r streamWatermarksJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [stream.WatermarkNewResponseUnknown] or [shared.UnionString]. +type WatermarkNewResponse interface { + ImplementsStreamWatermarkNewResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WatermarkNewResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [stream.WatermarkDeleteResponseUnknown] or +// [shared.UnionString]. +type WatermarkDeleteResponse interface { + ImplementsStreamWatermarkDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WatermarkDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [stream.WatermarkGetResponseUnknown] or [shared.UnionString]. +type WatermarkGetResponse interface { + ImplementsStreamWatermarkGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WatermarkGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type WatermarkNewParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + // The image file to upload. + File param.Field[string] `json:"file,required"` + // A short description of the watermark profile. + Name param.Field[string] `json:"name"` + // The translucency of the image. A value of `0.0` makes the image completely + // transparent, and `1.0` makes the image completely opaque. Note that if the image + // is already semi-transparent, setting this to `1.0` will not make the image + // completely opaque. + Opacity param.Field[float64] `json:"opacity"` + // The whitespace between the adjacent edges (determined by position) of the video + // and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded + // video width or length, as determined by the algorithm. + Padding param.Field[float64] `json:"padding"` + // The location of the image. Valid positions are: `upperRight`, `upperLeft`, + // `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the + // `padding` parameter. + Position param.Field[string] `json:"position"` + // The size of the image relative to the overall size of the video. This parameter + // will adapt to horizontal and vertical videos automatically. `0.0` indicates no + // scaling (use the size of the image as-is), and `1.0 `fills the entire video. + Scale param.Field[float64] `json:"scale"` +} + +func (r WatermarkNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type WatermarkNewResponseEnvelope struct { + Errors []WatermarkNewResponseEnvelopeErrors `json:"errors,required"` + Messages []WatermarkNewResponseEnvelopeMessages `json:"messages,required"` + Result WatermarkNewResponse `json:"result,required"` + // Whether the API call was successful + Success WatermarkNewResponseEnvelopeSuccess `json:"success,required"` + JSON watermarkNewResponseEnvelopeJSON `json:"-"` +} + +// watermarkNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [WatermarkNewResponseEnvelope] +type watermarkNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WatermarkNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r watermarkNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WatermarkNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON watermarkNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// watermarkNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [WatermarkNewResponseEnvelopeErrors] +type watermarkNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WatermarkNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r watermarkNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WatermarkNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON watermarkNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// watermarkNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [WatermarkNewResponseEnvelopeMessages] +type watermarkNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WatermarkNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r watermarkNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type WatermarkNewResponseEnvelopeSuccess bool + +const ( + WatermarkNewResponseEnvelopeSuccessTrue WatermarkNewResponseEnvelopeSuccess = true +) + +type WatermarkListParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type WatermarkListResponseEnvelope struct { + Errors []WatermarkListResponseEnvelopeErrors `json:"errors,required"` + Messages []WatermarkListResponseEnvelopeMessages `json:"messages,required"` + Result []StreamWatermarks `json:"result,required"` + // Whether the API call was successful + Success WatermarkListResponseEnvelopeSuccess `json:"success,required"` + JSON watermarkListResponseEnvelopeJSON `json:"-"` +} + +// watermarkListResponseEnvelopeJSON contains the JSON metadata for the struct +// [WatermarkListResponseEnvelope] +type watermarkListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WatermarkListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r watermarkListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WatermarkListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON watermarkListResponseEnvelopeErrorsJSON `json:"-"` +} + +// watermarkListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [WatermarkListResponseEnvelopeErrors] +type watermarkListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WatermarkListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r watermarkListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WatermarkListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON watermarkListResponseEnvelopeMessagesJSON `json:"-"` +} + +// watermarkListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [WatermarkListResponseEnvelopeMessages] +type watermarkListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WatermarkListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r watermarkListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type WatermarkListResponseEnvelopeSuccess bool + +const ( + WatermarkListResponseEnvelopeSuccessTrue WatermarkListResponseEnvelopeSuccess = true +) + +type WatermarkDeleteParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type WatermarkDeleteResponseEnvelope struct { + Errors []WatermarkDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []WatermarkDeleteResponseEnvelopeMessages `json:"messages,required"` + Result WatermarkDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success WatermarkDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON watermarkDeleteResponseEnvelopeJSON `json:"-"` +} + +// watermarkDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [WatermarkDeleteResponseEnvelope] +type watermarkDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WatermarkDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r watermarkDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WatermarkDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON watermarkDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// watermarkDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [WatermarkDeleteResponseEnvelopeErrors] +type watermarkDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WatermarkDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r watermarkDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WatermarkDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON watermarkDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// watermarkDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [WatermarkDeleteResponseEnvelopeMessages] +type watermarkDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WatermarkDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r watermarkDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type WatermarkDeleteResponseEnvelopeSuccess bool + +const ( + WatermarkDeleteResponseEnvelopeSuccessTrue WatermarkDeleteResponseEnvelopeSuccess = true +) + +type WatermarkGetParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type WatermarkGetResponseEnvelope struct { + Errors []WatermarkGetResponseEnvelopeErrors `json:"errors,required"` + Messages []WatermarkGetResponseEnvelopeMessages `json:"messages,required"` + Result WatermarkGetResponse `json:"result,required"` + // Whether the API call was successful + Success WatermarkGetResponseEnvelopeSuccess `json:"success,required"` + JSON watermarkGetResponseEnvelopeJSON `json:"-"` +} + +// watermarkGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [WatermarkGetResponseEnvelope] +type watermarkGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WatermarkGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r watermarkGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WatermarkGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON watermarkGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// watermarkGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [WatermarkGetResponseEnvelopeErrors] +type watermarkGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WatermarkGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r watermarkGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WatermarkGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON watermarkGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// watermarkGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [WatermarkGetResponseEnvelopeMessages] +type watermarkGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WatermarkGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r watermarkGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type WatermarkGetResponseEnvelopeSuccess bool + +const ( + WatermarkGetResponseEnvelopeSuccessTrue WatermarkGetResponseEnvelopeSuccess = true +) diff --git a/stream/watermark_test.go b/stream/watermark_test.go new file mode 100644 index 00000000000..56d74ae12a9 --- /dev/null +++ b/stream/watermark_test.go @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/stream" +) + +func TestWatermarkNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Stream.Watermarks.New(context.TODO(), stream.WatermarkNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + File: cloudflare.F("@/Users/rchen/Downloads/watermark.png"), + Name: cloudflare.F("Marketing Videos"), + Opacity: cloudflare.F(0.750000), + Padding: cloudflare.F(0.100000), + Position: cloudflare.F("center"), + Scale: cloudflare.F(0.100000), + }) + 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 TestWatermarkList(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("user@example.com"), + ) + _, err := client.Stream.Watermarks.List(context.TODO(), stream.WatermarkListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestWatermarkDelete(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("user@example.com"), + ) + _, err := client.Stream.Watermarks.Delete( + context.TODO(), + "ea95132c15732412d22c1476fa83f27a", + stream.WatermarkDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestWatermarkGet(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("user@example.com"), + ) + _, err := client.Stream.Watermarks.Get( + context.TODO(), + "ea95132c15732412d22c1476fa83f27a", + stream.WatermarkGetParams{ + AccountID: cloudflare.F("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/stream/webhook.go b/stream/webhook.go new file mode 100644 index 00000000000..4d739d34eb4 --- /dev/null +++ b/stream/webhook.go @@ -0,0 +1,387 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// WebhookService 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 [NewWebhookService] method instead. +type WebhookService struct { + Options []option.RequestOption +} + +// NewWebhookService 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 NewWebhookService(opts ...option.RequestOption) (r *WebhookService) { + r = &WebhookService{} + r.Options = opts + return +} + +// Creates a webhook notification. +func (r *WebhookService) Update(ctx context.Context, params WebhookUpdateParams, opts ...option.RequestOption) (res *WebhookUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env WebhookUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/webhook", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a webhook. +func (r *WebhookService) Delete(ctx context.Context, body WebhookDeleteParams, opts ...option.RequestOption) (res *WebhookDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env WebhookDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/webhook", body.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Retrieves a list of webhooks. +func (r *WebhookService) Get(ctx context.Context, query WebhookGetParams, opts ...option.RequestOption) (res *WebhookGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env WebhookGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/stream/webhook", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [stream.WebhookUpdateResponseUnknown] or +// [shared.UnionString]. +type WebhookUpdateResponse interface { + ImplementsStreamWebhookUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WebhookUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [stream.WebhookDeleteResponseUnknown] or +// [shared.UnionString]. +type WebhookDeleteResponse interface { + ImplementsStreamWebhookDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WebhookDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [stream.WebhookGetResponseUnknown] or [shared.UnionString]. +type WebhookGetResponse interface { + ImplementsStreamWebhookGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WebhookGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type WebhookUpdateParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` + // The URL where webhooks will be sent. + NotificationURL param.Field[string] `json:"notificationUrl,required" format:"uri"` +} + +func (r WebhookUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type WebhookUpdateResponseEnvelope struct { + Errors []WebhookUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []WebhookUpdateResponseEnvelopeMessages `json:"messages,required"` + Result WebhookUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success WebhookUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON webhookUpdateResponseEnvelopeJSON `json:"-"` +} + +// webhookUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [WebhookUpdateResponseEnvelope] +type webhookUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WebhookUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r webhookUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WebhookUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON webhookUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// webhookUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [WebhookUpdateResponseEnvelopeErrors] +type webhookUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WebhookUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r webhookUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WebhookUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON webhookUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// webhookUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [WebhookUpdateResponseEnvelopeMessages] +type webhookUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WebhookUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r webhookUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type WebhookUpdateResponseEnvelopeSuccess bool + +const ( + WebhookUpdateResponseEnvelopeSuccessTrue WebhookUpdateResponseEnvelopeSuccess = true +) + +type WebhookDeleteParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type WebhookDeleteResponseEnvelope struct { + Errors []WebhookDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []WebhookDeleteResponseEnvelopeMessages `json:"messages,required"` + Result WebhookDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success WebhookDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON webhookDeleteResponseEnvelopeJSON `json:"-"` +} + +// webhookDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [WebhookDeleteResponseEnvelope] +type webhookDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WebhookDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r webhookDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WebhookDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON webhookDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// webhookDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [WebhookDeleteResponseEnvelopeErrors] +type webhookDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WebhookDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r webhookDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WebhookDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON webhookDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// webhookDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [WebhookDeleteResponseEnvelopeMessages] +type webhookDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WebhookDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r webhookDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type WebhookDeleteResponseEnvelopeSuccess bool + +const ( + WebhookDeleteResponseEnvelopeSuccessTrue WebhookDeleteResponseEnvelopeSuccess = true +) + +type WebhookGetParams struct { + // The account identifier tag. + AccountID param.Field[string] `path:"account_id,required"` +} + +type WebhookGetResponseEnvelope struct { + Errors []WebhookGetResponseEnvelopeErrors `json:"errors,required"` + Messages []WebhookGetResponseEnvelopeMessages `json:"messages,required"` + Result WebhookGetResponse `json:"result,required"` + // Whether the API call was successful + Success WebhookGetResponseEnvelopeSuccess `json:"success,required"` + JSON webhookGetResponseEnvelopeJSON `json:"-"` +} + +// webhookGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [WebhookGetResponseEnvelope] +type webhookGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WebhookGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r webhookGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WebhookGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON webhookGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// webhookGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [WebhookGetResponseEnvelopeErrors] +type webhookGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WebhookGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r webhookGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WebhookGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON webhookGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// webhookGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [WebhookGetResponseEnvelopeMessages] +type webhookGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WebhookGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r webhookGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type WebhookGetResponseEnvelopeSuccess bool + +const ( + WebhookGetResponseEnvelopeSuccessTrue WebhookGetResponseEnvelopeSuccess = true +) diff --git a/stream/webhook_test.go b/stream/webhook_test.go new file mode 100644 index 00000000000..483000b86a2 --- /dev/null +++ b/stream/webhook_test.go @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package stream_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/stream" +) + +func TestWebhookUpdate(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("user@example.com"), + ) + _, err := client.Stream.Webhooks.Update(context.TODO(), stream.WebhookUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + NotificationURL: cloudflare.F("https://example.com"), + }) + 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 TestWebhookDelete(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("user@example.com"), + ) + _, err := client.Stream.Webhooks.Delete(context.TODO(), stream.WebhookDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestWebhookGet(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("user@example.com"), + ) + _, err := client.Stream.Webhooks.Get(context.TODO(), stream.WebhookGetParams{ + AccountID: cloudflare.F("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/streamaudiotrack.go b/streamaudiotrack.go deleted file mode 100644 index 3953d238028..00000000000 --- a/streamaudiotrack.go +++ /dev/null @@ -1,595 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// StreamAudioTrackService 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 [NewStreamAudioTrackService] method -// instead. -type StreamAudioTrackService struct { - Options []option.RequestOption -} - -// NewStreamAudioTrackService 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 NewStreamAudioTrackService(opts ...option.RequestOption) (r *StreamAudioTrackService) { - r = &StreamAudioTrackService{} - r.Options = opts - return -} - -// Deletes additional audio tracks on a video. Deleting a default audio track is -// not allowed. You must assign another audio track as default prior to deletion. -func (r *StreamAudioTrackService) Delete(ctx context.Context, identifier string, audioIdentifier string, body StreamAudioTrackDeleteParams, opts ...option.RequestOption) (res *StreamAudioTrackDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamAudioTrackDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/%s/audio/%s", body.AccountID, identifier, audioIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Adds an additional audio track to a video using the provided audio track URL. -func (r *StreamAudioTrackService) Copy(ctx context.Context, identifier string, params StreamAudioTrackCopyParams, opts ...option.RequestOption) (res *StreamAudioTrackCopyResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamAudioTrackCopyResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/%s/audio/copy", params.AccountID, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Edits additional audio tracks on a video. Editing the default status of an audio -// track to `true` will mark all other audio tracks on the video default status to -// `false`. -func (r *StreamAudioTrackService) Edit(ctx context.Context, identifier string, audioIdentifier string, params StreamAudioTrackEditParams, opts ...option.RequestOption) (res *StreamAudioTrackEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamAudioTrackEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/%s/audio/%s", params.AccountID, identifier, audioIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists additional audio tracks on a video. Note this API will not return -// information for audio attached to the video upload. -func (r *StreamAudioTrackService) Get(ctx context.Context, identifier string, query StreamAudioTrackGetParams, opts ...option.RequestOption) (res *[]StreamAudioTrackGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamAudioTrackGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/%s/audio", query.AccountID, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [StreamAudioTrackDeleteResponseUnknown] or -// [shared.UnionString]. -type StreamAudioTrackDeleteResponse interface { - ImplementsStreamAudioTrackDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*StreamAudioTrackDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type StreamAudioTrackCopyResponse struct { - // Denotes whether the audio track will be played by default in a player. - Default bool `json:"default"` - // A string to uniquely identify the track amongst other audio track labels for the - // specified video. - Label string `json:"label"` - // Specifies the processing status of the video. - Status StreamAudioTrackCopyResponseStatus `json:"status"` - // A Cloudflare-generated unique identifier for a media item. - Uid string `json:"uid"` - JSON streamAudioTrackCopyResponseJSON `json:"-"` -} - -// streamAudioTrackCopyResponseJSON contains the JSON metadata for the struct -// [StreamAudioTrackCopyResponse] -type streamAudioTrackCopyResponseJSON struct { - Default apijson.Field - Label apijson.Field - Status apijson.Field - Uid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamAudioTrackCopyResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamAudioTrackCopyResponseJSON) RawJSON() string { - return r.raw -} - -// Specifies the processing status of the video. -type StreamAudioTrackCopyResponseStatus string - -const ( - StreamAudioTrackCopyResponseStatusQueued StreamAudioTrackCopyResponseStatus = "queued" - StreamAudioTrackCopyResponseStatusReady StreamAudioTrackCopyResponseStatus = "ready" - StreamAudioTrackCopyResponseStatusError StreamAudioTrackCopyResponseStatus = "error" -) - -type StreamAudioTrackEditResponse struct { - // Denotes whether the audio track will be played by default in a player. - Default bool `json:"default"` - // A string to uniquely identify the track amongst other audio track labels for the - // specified video. - Label string `json:"label"` - // Specifies the processing status of the video. - Status StreamAudioTrackEditResponseStatus `json:"status"` - // A Cloudflare-generated unique identifier for a media item. - Uid string `json:"uid"` - JSON streamAudioTrackEditResponseJSON `json:"-"` -} - -// streamAudioTrackEditResponseJSON contains the JSON metadata for the struct -// [StreamAudioTrackEditResponse] -type streamAudioTrackEditResponseJSON struct { - Default apijson.Field - Label apijson.Field - Status apijson.Field - Uid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamAudioTrackEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamAudioTrackEditResponseJSON) RawJSON() string { - return r.raw -} - -// Specifies the processing status of the video. -type StreamAudioTrackEditResponseStatus string - -const ( - StreamAudioTrackEditResponseStatusQueued StreamAudioTrackEditResponseStatus = "queued" - StreamAudioTrackEditResponseStatusReady StreamAudioTrackEditResponseStatus = "ready" - StreamAudioTrackEditResponseStatusError StreamAudioTrackEditResponseStatus = "error" -) - -type StreamAudioTrackGetResponse struct { - // Denotes whether the audio track will be played by default in a player. - Default bool `json:"default"` - // A string to uniquely identify the track amongst other audio track labels for the - // specified video. - Label string `json:"label"` - // Specifies the processing status of the video. - Status StreamAudioTrackGetResponseStatus `json:"status"` - // A Cloudflare-generated unique identifier for a media item. - Uid string `json:"uid"` - JSON streamAudioTrackGetResponseJSON `json:"-"` -} - -// streamAudioTrackGetResponseJSON contains the JSON metadata for the struct -// [StreamAudioTrackGetResponse] -type streamAudioTrackGetResponseJSON struct { - Default apijson.Field - Label apijson.Field - Status apijson.Field - Uid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamAudioTrackGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamAudioTrackGetResponseJSON) RawJSON() string { - return r.raw -} - -// Specifies the processing status of the video. -type StreamAudioTrackGetResponseStatus string - -const ( - StreamAudioTrackGetResponseStatusQueued StreamAudioTrackGetResponseStatus = "queued" - StreamAudioTrackGetResponseStatusReady StreamAudioTrackGetResponseStatus = "ready" - StreamAudioTrackGetResponseStatusError StreamAudioTrackGetResponseStatus = "error" -) - -type StreamAudioTrackDeleteParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamAudioTrackDeleteResponseEnvelope struct { - Errors []StreamAudioTrackDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamAudioTrackDeleteResponseEnvelopeMessages `json:"messages,required"` - Result StreamAudioTrackDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success StreamAudioTrackDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON streamAudioTrackDeleteResponseEnvelopeJSON `json:"-"` -} - -// streamAudioTrackDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [StreamAudioTrackDeleteResponseEnvelope] -type streamAudioTrackDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamAudioTrackDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamAudioTrackDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamAudioTrackDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamAudioTrackDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamAudioTrackDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [StreamAudioTrackDeleteResponseEnvelopeErrors] -type streamAudioTrackDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamAudioTrackDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamAudioTrackDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamAudioTrackDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamAudioTrackDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamAudioTrackDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [StreamAudioTrackDeleteResponseEnvelopeMessages] -type streamAudioTrackDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamAudioTrackDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamAudioTrackDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamAudioTrackDeleteResponseEnvelopeSuccess bool - -const ( - StreamAudioTrackDeleteResponseEnvelopeSuccessTrue StreamAudioTrackDeleteResponseEnvelopeSuccess = true -) - -type StreamAudioTrackCopyParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // A string to uniquely identify the track amongst other audio track labels for the - // specified video. - Label param.Field[string] `json:"label,required"` - // An audio track URL. The server must be publicly routable and support `HTTP HEAD` - // requests and `HTTP GET` range requests. The server should respond to `HTTP HEAD` - // requests with a `content-range` header that includes the size of the file. - URL param.Field[string] `json:"url" format:"uri"` -} - -func (r StreamAudioTrackCopyParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type StreamAudioTrackCopyResponseEnvelope struct { - Errors []StreamAudioTrackCopyResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamAudioTrackCopyResponseEnvelopeMessages `json:"messages,required"` - Result StreamAudioTrackCopyResponse `json:"result,required"` - // Whether the API call was successful - Success StreamAudioTrackCopyResponseEnvelopeSuccess `json:"success,required"` - JSON streamAudioTrackCopyResponseEnvelopeJSON `json:"-"` -} - -// streamAudioTrackCopyResponseEnvelopeJSON contains the JSON metadata for the -// struct [StreamAudioTrackCopyResponseEnvelope] -type streamAudioTrackCopyResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamAudioTrackCopyResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamAudioTrackCopyResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamAudioTrackCopyResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamAudioTrackCopyResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamAudioTrackCopyResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [StreamAudioTrackCopyResponseEnvelopeErrors] -type streamAudioTrackCopyResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamAudioTrackCopyResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamAudioTrackCopyResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamAudioTrackCopyResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamAudioTrackCopyResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamAudioTrackCopyResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [StreamAudioTrackCopyResponseEnvelopeMessages] -type streamAudioTrackCopyResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamAudioTrackCopyResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamAudioTrackCopyResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamAudioTrackCopyResponseEnvelopeSuccess bool - -const ( - StreamAudioTrackCopyResponseEnvelopeSuccessTrue StreamAudioTrackCopyResponseEnvelopeSuccess = true -) - -type StreamAudioTrackEditParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // Denotes whether the audio track will be played by default in a player. - Default param.Field[bool] `json:"default"` - // A string to uniquely identify the track amongst other audio track labels for the - // specified video. - Label param.Field[string] `json:"label"` -} - -func (r StreamAudioTrackEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type StreamAudioTrackEditResponseEnvelope struct { - Errors []StreamAudioTrackEditResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamAudioTrackEditResponseEnvelopeMessages `json:"messages,required"` - Result StreamAudioTrackEditResponse `json:"result,required"` - // Whether the API call was successful - Success StreamAudioTrackEditResponseEnvelopeSuccess `json:"success,required"` - JSON streamAudioTrackEditResponseEnvelopeJSON `json:"-"` -} - -// streamAudioTrackEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [StreamAudioTrackEditResponseEnvelope] -type streamAudioTrackEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamAudioTrackEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamAudioTrackEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamAudioTrackEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamAudioTrackEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamAudioTrackEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [StreamAudioTrackEditResponseEnvelopeErrors] -type streamAudioTrackEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamAudioTrackEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamAudioTrackEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamAudioTrackEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamAudioTrackEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamAudioTrackEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [StreamAudioTrackEditResponseEnvelopeMessages] -type streamAudioTrackEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamAudioTrackEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamAudioTrackEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamAudioTrackEditResponseEnvelopeSuccess bool - -const ( - StreamAudioTrackEditResponseEnvelopeSuccessTrue StreamAudioTrackEditResponseEnvelopeSuccess = true -) - -type StreamAudioTrackGetParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamAudioTrackGetResponseEnvelope struct { - Errors []StreamAudioTrackGetResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamAudioTrackGetResponseEnvelopeMessages `json:"messages,required"` - Result []StreamAudioTrackGetResponse `json:"result,required"` - // Whether the API call was successful - Success StreamAudioTrackGetResponseEnvelopeSuccess `json:"success,required"` - JSON streamAudioTrackGetResponseEnvelopeJSON `json:"-"` -} - -// streamAudioTrackGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [StreamAudioTrackGetResponseEnvelope] -type streamAudioTrackGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamAudioTrackGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamAudioTrackGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamAudioTrackGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamAudioTrackGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamAudioTrackGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamAudioTrackGetResponseEnvelopeErrors] -type streamAudioTrackGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamAudioTrackGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamAudioTrackGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamAudioTrackGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamAudioTrackGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamAudioTrackGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [StreamAudioTrackGetResponseEnvelopeMessages] -type streamAudioTrackGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamAudioTrackGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamAudioTrackGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamAudioTrackGetResponseEnvelopeSuccess bool - -const ( - StreamAudioTrackGetResponseEnvelopeSuccessTrue StreamAudioTrackGetResponseEnvelopeSuccess = true -) diff --git a/streamaudiotrack_test.go b/streamaudiotrack_test.go deleted file mode 100644 index d034294e4d1..00000000000 --- a/streamaudiotrack_test.go +++ /dev/null @@ -1,140 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestStreamAudioTrackDelete(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("user@example.com"), - ) - _, err := client.Stream.AudioTracks.Delete( - context.TODO(), - "ea95132c15732412d22c1476fa83f27a", - "ea95132c15732412d22c1476fa83f27a", - cloudflare.StreamAudioTrackDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestStreamAudioTrackCopyWithOptionalParams(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("user@example.com"), - ) - _, err := client.Stream.AudioTracks.Copy( - context.TODO(), - "ea95132c15732412d22c1476fa83f27a", - cloudflare.StreamAudioTrackCopyParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Label: cloudflare.F("director commentary"), - URL: cloudflare.F("https://www.examplestorage.com/audio_file.mp3"), - }, - ) - 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 TestStreamAudioTrackEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Stream.AudioTracks.Edit( - context.TODO(), - "ea95132c15732412d22c1476fa83f27a", - "ea95132c15732412d22c1476fa83f27a", - cloudflare.StreamAudioTrackEditParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Default: cloudflare.F(true), - Label: cloudflare.F("director commentary"), - }, - ) - 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 TestStreamAudioTrackGet(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("user@example.com"), - ) - _, err := client.Stream.AudioTracks.Get( - context.TODO(), - "ea95132c15732412d22c1476fa83f27a", - cloudflare.StreamAudioTrackGetParams{ - AccountID: cloudflare.F("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/streamcaption.go b/streamcaption.go deleted file mode 100644 index e417ca45875..00000000000 --- a/streamcaption.go +++ /dev/null @@ -1,405 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// StreamCaptionService 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 [NewStreamCaptionService] method -// instead. -type StreamCaptionService struct { - Options []option.RequestOption -} - -// NewStreamCaptionService 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 NewStreamCaptionService(opts ...option.RequestOption) (r *StreamCaptionService) { - r = &StreamCaptionService{} - r.Options = opts - return -} - -// Uploads the caption or subtitle file to the endpoint for a specific BCP47 -// language. One caption or subtitle file per language is allowed. -func (r *StreamCaptionService) Update(ctx context.Context, identifier string, language string, params StreamCaptionUpdateParams, opts ...option.RequestOption) (res *StreamCaptionUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamCaptionUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/%s/captions/%s", params.AccountID, identifier, language) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Removes the captions or subtitles from a video. -func (r *StreamCaptionService) Delete(ctx context.Context, identifier string, language string, body StreamCaptionDeleteParams, opts ...option.RequestOption) (res *StreamCaptionDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamCaptionDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/%s/captions/%s", body.AccountID, identifier, language) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists the available captions or subtitles for a specific video. -func (r *StreamCaptionService) Get(ctx context.Context, identifier string, query StreamCaptionGetParams, opts ...option.RequestOption) (res *[]StreamCaptionGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamCaptionGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/%s/captions", query.AccountID, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [StreamCaptionUpdateResponseUnknown] or [shared.UnionString]. -type StreamCaptionUpdateResponse interface { - ImplementsStreamCaptionUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*StreamCaptionUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [StreamCaptionDeleteResponseUnknown], -// [StreamCaptionDeleteResponseArray] or [shared.UnionString]. -type StreamCaptionDeleteResponse interface { - ImplementsStreamCaptionDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*StreamCaptionDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(StreamCaptionDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type StreamCaptionDeleteResponseArray []interface{} - -func (r StreamCaptionDeleteResponseArray) ImplementsStreamCaptionDeleteResponse() {} - -type StreamCaptionGetResponse struct { - // The language label displayed in the native language to users. - Label string `json:"label"` - // The language tag in BCP 47 format. - Language string `json:"language"` - JSON streamCaptionGetResponseJSON `json:"-"` -} - -// streamCaptionGetResponseJSON contains the JSON metadata for the struct -// [StreamCaptionGetResponse] -type streamCaptionGetResponseJSON struct { - Label apijson.Field - Language apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamCaptionGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamCaptionGetResponseJSON) RawJSON() string { - return r.raw -} - -type StreamCaptionUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The WebVTT file containing the caption or subtitle content. - File param.Field[string] `json:"file,required"` -} - -func (r StreamCaptionUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type StreamCaptionUpdateResponseEnvelope struct { - Errors []StreamCaptionUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamCaptionUpdateResponseEnvelopeMessages `json:"messages,required"` - Result StreamCaptionUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success StreamCaptionUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON streamCaptionUpdateResponseEnvelopeJSON `json:"-"` -} - -// streamCaptionUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [StreamCaptionUpdateResponseEnvelope] -type streamCaptionUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamCaptionUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamCaptionUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamCaptionUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamCaptionUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamCaptionUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamCaptionUpdateResponseEnvelopeErrors] -type streamCaptionUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamCaptionUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamCaptionUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamCaptionUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamCaptionUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamCaptionUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [StreamCaptionUpdateResponseEnvelopeMessages] -type streamCaptionUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamCaptionUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamCaptionUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamCaptionUpdateResponseEnvelopeSuccess bool - -const ( - StreamCaptionUpdateResponseEnvelopeSuccessTrue StreamCaptionUpdateResponseEnvelopeSuccess = true -) - -type StreamCaptionDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamCaptionDeleteResponseEnvelope struct { - Errors []StreamCaptionDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamCaptionDeleteResponseEnvelopeMessages `json:"messages,required"` - Result StreamCaptionDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success StreamCaptionDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON streamCaptionDeleteResponseEnvelopeJSON `json:"-"` -} - -// streamCaptionDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [StreamCaptionDeleteResponseEnvelope] -type streamCaptionDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamCaptionDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamCaptionDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamCaptionDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamCaptionDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamCaptionDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamCaptionDeleteResponseEnvelopeErrors] -type streamCaptionDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamCaptionDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamCaptionDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamCaptionDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamCaptionDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamCaptionDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [StreamCaptionDeleteResponseEnvelopeMessages] -type streamCaptionDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamCaptionDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamCaptionDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamCaptionDeleteResponseEnvelopeSuccess bool - -const ( - StreamCaptionDeleteResponseEnvelopeSuccessTrue StreamCaptionDeleteResponseEnvelopeSuccess = true -) - -type StreamCaptionGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamCaptionGetResponseEnvelope struct { - Errors []StreamCaptionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamCaptionGetResponseEnvelopeMessages `json:"messages,required"` - Result []StreamCaptionGetResponse `json:"result,required"` - // Whether the API call was successful - Success StreamCaptionGetResponseEnvelopeSuccess `json:"success,required"` - JSON streamCaptionGetResponseEnvelopeJSON `json:"-"` -} - -// streamCaptionGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [StreamCaptionGetResponseEnvelope] -type streamCaptionGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamCaptionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamCaptionGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamCaptionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamCaptionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamCaptionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamCaptionGetResponseEnvelopeErrors] -type streamCaptionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamCaptionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamCaptionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamCaptionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamCaptionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamCaptionGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [StreamCaptionGetResponseEnvelopeMessages] -type streamCaptionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamCaptionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamCaptionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamCaptionGetResponseEnvelopeSuccess bool - -const ( - StreamCaptionGetResponseEnvelopeSuccessTrue StreamCaptionGetResponseEnvelopeSuccess = true -) diff --git a/streamcaption_test.go b/streamcaption_test.go deleted file mode 100644 index fc105d52938..00000000000 --- a/streamcaption_test.go +++ /dev/null @@ -1,107 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestStreamCaptionUpdate(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("user@example.com"), - ) - _, err := client.Stream.Captions.Update( - context.TODO(), - "ea95132c15732412d22c1476fa83f27a", - "tr", - cloudflare.StreamCaptionUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - File: cloudflare.F("@/Users/kyle/Desktop/tr.vtt"), - }, - ) - 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 TestStreamCaptionDelete(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("user@example.com"), - ) - _, err := client.Stream.Captions.Delete( - context.TODO(), - "ea95132c15732412d22c1476fa83f27a", - "tr", - cloudflare.StreamCaptionDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestStreamCaptionGet(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("user@example.com"), - ) - _, err := client.Stream.Captions.Get( - context.TODO(), - "ea95132c15732412d22c1476fa83f27a", - cloudflare.StreamCaptionGetParams{ - AccountID: cloudflare.F("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/streamclip.go b/streamclip.go deleted file mode 100644 index b80792a94de..00000000000 --- a/streamclip.go +++ /dev/null @@ -1,301 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// StreamClipService 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 [NewStreamClipService] method instead. -type StreamClipService struct { - Options []option.RequestOption -} - -// NewStreamClipService 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 NewStreamClipService(opts ...option.RequestOption) (r *StreamClipService) { - r = &StreamClipService{} - r.Options = opts - return -} - -// Clips a video based on the specified start and end times provided in seconds. -func (r *StreamClipService) New(ctx context.Context, params StreamClipNewParams, opts ...option.RequestOption) (res *StreamClipNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamClipNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/clip", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type StreamClipNewResponse struct { - // Lists the origins allowed to display the video. Enter allowed origin domains in - // an array and use `*` for wildcard subdomains. Empty arrays allow the video to be - // viewed on any origin. - AllowedOrigins []string `json:"allowedOrigins"` - // The unique video identifier (UID). - ClippedFromVideoUid string `json:"clippedFromVideoUID"` - // The date and time the clip was created. - Created time.Time `json:"created" format:"date-time"` - // A user-defined identifier for the media creator. - Creator string `json:"creator"` - // Specifies the end time for the video clip in seconds. - EndTimeSeconds int64 `json:"endTimeSeconds"` - // The maximum duration in seconds for a video upload. Can be set for a video that - // is not yet uploaded to limit its duration. Uploads that exceed the specified - // duration will fail during processing. A value of `-1` means the value is - // unknown. - MaxDurationSeconds int64 `json:"maxDurationSeconds"` - // A user modifiable key-value store used to reference other systems of record for - // managing videos. - Meta interface{} `json:"meta"` - // The date and time the live input was last modified. - Modified time.Time `json:"modified" format:"date-time"` - Playback StreamClipNewResponsePlayback `json:"playback"` - // The video's preview page URI. This field is omitted until encoding is complete. - Preview string `json:"preview" format:"uri"` - // Indicates whether the video can be a accessed using the UID. When set to `true`, - // a signed token must be generated with a signing key to view the video. - RequireSignedURLs bool `json:"requireSignedURLs"` - // Specifies the start time for the video clip in seconds. - StartTimeSeconds int64 `json:"startTimeSeconds"` - // Specifies the processing status for all quality levels for a video. - Status StreamClipNewResponseStatus `json:"status"` - // The timestamp for a thumbnail image calculated as a percentage value of the - // video's duration. To convert from a second-wise timestamp to a percentage, - // divide the desired timestamp by the total duration of the video. If this value - // is not set, the default thumbnail image is taken from 0s of the video. - ThumbnailTimestampPct float64 `json:"thumbnailTimestampPct"` - Watermark StreamClipNewResponseWatermark `json:"watermark"` - JSON streamClipNewResponseJSON `json:"-"` -} - -// streamClipNewResponseJSON contains the JSON metadata for the struct -// [StreamClipNewResponse] -type streamClipNewResponseJSON struct { - AllowedOrigins apijson.Field - ClippedFromVideoUid apijson.Field - Created apijson.Field - Creator apijson.Field - EndTimeSeconds apijson.Field - MaxDurationSeconds apijson.Field - Meta apijson.Field - Modified apijson.Field - Playback apijson.Field - Preview apijson.Field - RequireSignedURLs apijson.Field - StartTimeSeconds apijson.Field - Status apijson.Field - ThumbnailTimestampPct apijson.Field - Watermark apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamClipNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamClipNewResponseJSON) RawJSON() string { - return r.raw -} - -type StreamClipNewResponsePlayback struct { - // DASH Media Presentation Description for the video. - Dash string `json:"dash"` - // The HLS manifest for the video. - Hls string `json:"hls"` - JSON streamClipNewResponsePlaybackJSON `json:"-"` -} - -// streamClipNewResponsePlaybackJSON contains the JSON metadata for the struct -// [StreamClipNewResponsePlayback] -type streamClipNewResponsePlaybackJSON struct { - Dash apijson.Field - Hls apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamClipNewResponsePlayback) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamClipNewResponsePlaybackJSON) RawJSON() string { - return r.raw -} - -// Specifies the processing status for all quality levels for a video. -type StreamClipNewResponseStatus string - -const ( - StreamClipNewResponseStatusPendingupload StreamClipNewResponseStatus = "pendingupload" - StreamClipNewResponseStatusDownloading StreamClipNewResponseStatus = "downloading" - StreamClipNewResponseStatusQueued StreamClipNewResponseStatus = "queued" - StreamClipNewResponseStatusInprogress StreamClipNewResponseStatus = "inprogress" - StreamClipNewResponseStatusReady StreamClipNewResponseStatus = "ready" - StreamClipNewResponseStatusError StreamClipNewResponseStatus = "error" -) - -type StreamClipNewResponseWatermark struct { - // The unique identifier for the watermark profile. - Uid string `json:"uid"` - JSON streamClipNewResponseWatermarkJSON `json:"-"` -} - -// streamClipNewResponseWatermarkJSON contains the JSON metadata for the struct -// [StreamClipNewResponseWatermark] -type streamClipNewResponseWatermarkJSON struct { - Uid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamClipNewResponseWatermark) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamClipNewResponseWatermarkJSON) RawJSON() string { - return r.raw -} - -type StreamClipNewParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // The unique video identifier (UID). - ClippedFromVideoUid param.Field[string] `json:"clippedFromVideoUID,required"` - // Specifies the end time for the video clip in seconds. - EndTimeSeconds param.Field[int64] `json:"endTimeSeconds,required"` - // Specifies the start time for the video clip in seconds. - StartTimeSeconds param.Field[int64] `json:"startTimeSeconds,required"` - // Lists the origins allowed to display the video. Enter allowed origin domains in - // an array and use `*` for wildcard subdomains. Empty arrays allow the video to be - // viewed on any origin. - AllowedOrigins param.Field[[]string] `json:"allowedOrigins"` - // A user-defined identifier for the media creator. - Creator param.Field[string] `json:"creator"` - // The maximum duration in seconds for a video upload. Can be set for a video that - // is not yet uploaded to limit its duration. Uploads that exceed the specified - // duration will fail during processing. A value of `-1` means the value is - // unknown. - MaxDurationSeconds param.Field[int64] `json:"maxDurationSeconds"` - // Indicates whether the video can be a accessed using the UID. When set to `true`, - // a signed token must be generated with a signing key to view the video. - RequireSignedURLs param.Field[bool] `json:"requireSignedURLs"` - // The timestamp for a thumbnail image calculated as a percentage value of the - // video's duration. To convert from a second-wise timestamp to a percentage, - // divide the desired timestamp by the total duration of the video. If this value - // is not set, the default thumbnail image is taken from 0s of the video. - ThumbnailTimestampPct param.Field[float64] `json:"thumbnailTimestampPct"` - Watermark param.Field[StreamClipNewParamsWatermark] `json:"watermark"` -} - -func (r StreamClipNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type StreamClipNewParamsWatermark struct { - // The unique identifier for the watermark profile. - Uid param.Field[string] `json:"uid"` -} - -func (r StreamClipNewParamsWatermark) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type StreamClipNewResponseEnvelope struct { - Errors []StreamClipNewResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamClipNewResponseEnvelopeMessages `json:"messages,required"` - Result StreamClipNewResponse `json:"result,required"` - // Whether the API call was successful - Success StreamClipNewResponseEnvelopeSuccess `json:"success,required"` - JSON streamClipNewResponseEnvelopeJSON `json:"-"` -} - -// streamClipNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [StreamClipNewResponseEnvelope] -type streamClipNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamClipNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamClipNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamClipNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamClipNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamClipNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamClipNewResponseEnvelopeErrors] -type streamClipNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamClipNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamClipNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamClipNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamClipNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamClipNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [StreamClipNewResponseEnvelopeMessages] -type streamClipNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamClipNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamClipNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamClipNewResponseEnvelopeSuccess bool - -const ( - StreamClipNewResponseEnvelopeSuccessTrue StreamClipNewResponseEnvelopeSuccess = true -) diff --git a/streamclip_test.go b/streamclip_test.go deleted file mode 100644 index 504bc548c39..00000000000 --- a/streamclip_test.go +++ /dev/null @@ -1,51 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestStreamClipNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Stream.Clips.New(context.TODO(), cloudflare.StreamClipNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - ClippedFromVideoUid: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - EndTimeSeconds: cloudflare.F(int64(0)), - StartTimeSeconds: cloudflare.F(int64(0)), - AllowedOrigins: cloudflare.F([]string{"example.com"}), - Creator: cloudflare.F("creator-id_abcde12345"), - MaxDurationSeconds: cloudflare.F(int64(1)), - RequireSignedURLs: cloudflare.F(true), - ThumbnailTimestampPct: cloudflare.F(0.529241), - Watermark: cloudflare.F(cloudflare.StreamClipNewParamsWatermark{ - Uid: cloudflare.F("ea95132c15732412d22c1476fa83f27a"), - }), - }) - 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/streamcopy.go b/streamcopy.go deleted file mode 100644 index 6f28e9b30af..00000000000 --- a/streamcopy.go +++ /dev/null @@ -1,448 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// StreamCopyService 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 [NewStreamCopyService] method instead. -type StreamCopyService struct { - Options []option.RequestOption -} - -// NewStreamCopyService 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 NewStreamCopyService(opts ...option.RequestOption) (r *StreamCopyService) { - r = &StreamCopyService{} - r.Options = opts - return -} - -// Uploads a video to Stream from a provided URL. -func (r *StreamCopyService) New(ctx context.Context, params StreamCopyNewParams, opts ...option.RequestOption) (res *StreamCopyNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamCopyNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/copy", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type StreamCopyNewResponse struct { - // Lists the origins allowed to display the video. Enter allowed origin domains in - // an array and use `*` for wildcard subdomains. Empty arrays allow the video to be - // viewed on any origin. - AllowedOrigins []string `json:"allowedOrigins"` - // The date and time the media item was created. - Created time.Time `json:"created" format:"date-time"` - // A user-defined identifier for the media creator. - Creator string `json:"creator"` - // The duration of the video in seconds. A value of `-1` means the duration is - // unknown. The duration becomes available after the upload and before the video is - // ready. - Duration float64 `json:"duration"` - Input StreamCopyNewResponseInput `json:"input"` - // The live input ID used to upload a video with Stream Live. - LiveInput string `json:"liveInput"` - // The maximum duration in seconds for a video upload. Can be set for a video that - // is not yet uploaded to limit its duration. Uploads that exceed the specified - // duration will fail during processing. A value of `-1` means the value is - // unknown. - MaxDurationSeconds int64 `json:"maxDurationSeconds"` - // A user modifiable key-value store used to reference other systems of record for - // managing videos. - Meta interface{} `json:"meta"` - // The date and time the media item was last modified. - Modified time.Time `json:"modified" format:"date-time"` - Playback StreamCopyNewResponsePlayback `json:"playback"` - // The video's preview page URI. This field is omitted until encoding is complete. - Preview string `json:"preview" format:"uri"` - // Indicates whether the video is playable. The field is empty if the video is not - // ready for viewing or the live stream is still in progress. - ReadyToStream bool `json:"readyToStream"` - // Indicates the time at which the video became playable. The field is empty if the - // video is not ready for viewing or the live stream is still in progress. - ReadyToStreamAt time.Time `json:"readyToStreamAt" format:"date-time"` - // Indicates whether the video can be a accessed using the UID. When set to `true`, - // a signed token must be generated with a signing key to view the video. - RequireSignedURLs bool `json:"requireSignedURLs"` - // Indicates the date and time at which the video will be deleted. Omit the field - // to indicate no change, or include with a `null` value to remove an existing - // scheduled deletion. If specified, must be at least 30 days from upload time. - ScheduledDeletion time.Time `json:"scheduledDeletion" format:"date-time"` - // The size of the media item in bytes. - Size float64 `json:"size"` - // Specifies a detailed status for a video. If the `state` is `inprogress` or - // `error`, the `step` field returns `encoding` or `manifest`. If the `state` is - // `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the - // approximate percent of completion. If the `state` is `error`, `errorReasonCode` - // and `errorReasonText` provide additional details. - Status StreamCopyNewResponseStatus `json:"status"` - // The media item's thumbnail URI. This field is omitted until encoding is - // complete. - Thumbnail string `json:"thumbnail" format:"uri"` - // The timestamp for a thumbnail image calculated as a percentage value of the - // video's duration. To convert from a second-wise timestamp to a percentage, - // divide the desired timestamp by the total duration of the video. If this value - // is not set, the default thumbnail image is taken from 0s of the video. - ThumbnailTimestampPct float64 `json:"thumbnailTimestampPct"` - // A Cloudflare-generated unique identifier for a media item. - Uid string `json:"uid"` - // The date and time the media item was uploaded. - Uploaded time.Time `json:"uploaded" format:"date-time"` - // The date and time when the video upload URL is no longer valid for direct user - // uploads. - UploadExpiry time.Time `json:"uploadExpiry" format:"date-time"` - Watermark StreamCopyNewResponseWatermark `json:"watermark"` - JSON streamCopyNewResponseJSON `json:"-"` -} - -// streamCopyNewResponseJSON contains the JSON metadata for the struct -// [StreamCopyNewResponse] -type streamCopyNewResponseJSON struct { - AllowedOrigins apijson.Field - Created apijson.Field - Creator apijson.Field - Duration apijson.Field - Input apijson.Field - LiveInput apijson.Field - MaxDurationSeconds apijson.Field - Meta apijson.Field - Modified apijson.Field - Playback apijson.Field - Preview apijson.Field - ReadyToStream apijson.Field - ReadyToStreamAt apijson.Field - RequireSignedURLs apijson.Field - ScheduledDeletion apijson.Field - Size apijson.Field - Status apijson.Field - Thumbnail apijson.Field - ThumbnailTimestampPct apijson.Field - Uid apijson.Field - Uploaded apijson.Field - UploadExpiry apijson.Field - Watermark apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamCopyNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamCopyNewResponseJSON) RawJSON() string { - return r.raw -} - -type StreamCopyNewResponseInput struct { - // The video height in pixels. A value of `-1` means the height is unknown. The - // value becomes available after the upload and before the video is ready. - Height int64 `json:"height"` - // The video width in pixels. A value of `-1` means the width is unknown. The value - // becomes available after the upload and before the video is ready. - Width int64 `json:"width"` - JSON streamCopyNewResponseInputJSON `json:"-"` -} - -// streamCopyNewResponseInputJSON contains the JSON metadata for the struct -// [StreamCopyNewResponseInput] -type streamCopyNewResponseInputJSON struct { - Height apijson.Field - Width apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamCopyNewResponseInput) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamCopyNewResponseInputJSON) RawJSON() string { - return r.raw -} - -type StreamCopyNewResponsePlayback struct { - // DASH Media Presentation Description for the video. - Dash string `json:"dash"` - // The HLS manifest for the video. - Hls string `json:"hls"` - JSON streamCopyNewResponsePlaybackJSON `json:"-"` -} - -// streamCopyNewResponsePlaybackJSON contains the JSON metadata for the struct -// [StreamCopyNewResponsePlayback] -type streamCopyNewResponsePlaybackJSON struct { - Dash apijson.Field - Hls apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamCopyNewResponsePlayback) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamCopyNewResponsePlaybackJSON) RawJSON() string { - return r.raw -} - -// Specifies a detailed status for a video. If the `state` is `inprogress` or -// `error`, the `step` field returns `encoding` or `manifest`. If the `state` is -// `inprogress`, `pctComplete` returns a number between 0 and 100 to indicate the -// approximate percent of completion. If the `state` is `error`, `errorReasonCode` -// and `errorReasonText` provide additional details. -type StreamCopyNewResponseStatus struct { - // Specifies why the video failed to encode. This field is empty if the video is - // not in an `error` state. Preferred for programmatic use. - ErrorReasonCode string `json:"errorReasonCode"` - // Specifies why the video failed to encode using a human readable error message in - // English. This field is empty if the video is not in an `error` state. - ErrorReasonText string `json:"errorReasonText"` - // Indicates the size of the entire upload in bytes. The value must be a - // non-negative integer. - PctComplete string `json:"pctComplete"` - // Specifies the processing status for all quality levels for a video. - State StreamCopyNewResponseStatusState `json:"state"` - JSON streamCopyNewResponseStatusJSON `json:"-"` -} - -// streamCopyNewResponseStatusJSON contains the JSON metadata for the struct -// [StreamCopyNewResponseStatus] -type streamCopyNewResponseStatusJSON struct { - ErrorReasonCode apijson.Field - ErrorReasonText apijson.Field - PctComplete apijson.Field - State apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamCopyNewResponseStatus) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamCopyNewResponseStatusJSON) RawJSON() string { - return r.raw -} - -// Specifies the processing status for all quality levels for a video. -type StreamCopyNewResponseStatusState string - -const ( - StreamCopyNewResponseStatusStatePendingupload StreamCopyNewResponseStatusState = "pendingupload" - StreamCopyNewResponseStatusStateDownloading StreamCopyNewResponseStatusState = "downloading" - StreamCopyNewResponseStatusStateQueued StreamCopyNewResponseStatusState = "queued" - StreamCopyNewResponseStatusStateInprogress StreamCopyNewResponseStatusState = "inprogress" - StreamCopyNewResponseStatusStateReady StreamCopyNewResponseStatusState = "ready" - StreamCopyNewResponseStatusStateError StreamCopyNewResponseStatusState = "error" -) - -type StreamCopyNewResponseWatermark struct { - // The date and a time a watermark profile was created. - Created time.Time `json:"created" format:"date-time"` - // The source URL for a downloaded image. If the watermark profile was created via - // direct upload, this field is null. - DownloadedFrom string `json:"downloadedFrom"` - // The height of the image in pixels. - Height int64 `json:"height"` - // A short description of the watermark profile. - Name string `json:"name"` - // The translucency of the image. A value of `0.0` makes the image completely - // transparent, and `1.0` makes the image completely opaque. Note that if the image - // is already semi-transparent, setting this to `1.0` will not make the image - // completely opaque. - Opacity float64 `json:"opacity"` - // The whitespace between the adjacent edges (determined by position) of the video - // and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded - // video width or length, as determined by the algorithm. - Padding float64 `json:"padding"` - // The location of the image. Valid positions are: `upperRight`, `upperLeft`, - // `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the - // `padding` parameter. - Position string `json:"position"` - // The size of the image relative to the overall size of the video. This parameter - // will adapt to horizontal and vertical videos automatically. `0.0` indicates no - // scaling (use the size of the image as-is), and `1.0 `fills the entire video. - Scale float64 `json:"scale"` - // The size of the image in bytes. - Size float64 `json:"size"` - // The unique identifier for a watermark profile. - Uid string `json:"uid"` - // The width of the image in pixels. - Width int64 `json:"width"` - JSON streamCopyNewResponseWatermarkJSON `json:"-"` -} - -// streamCopyNewResponseWatermarkJSON contains the JSON metadata for the struct -// [StreamCopyNewResponseWatermark] -type streamCopyNewResponseWatermarkJSON struct { - Created apijson.Field - DownloadedFrom apijson.Field - Height apijson.Field - Name apijson.Field - Opacity apijson.Field - Padding apijson.Field - Position apijson.Field - Scale apijson.Field - Size apijson.Field - Uid apijson.Field - Width apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamCopyNewResponseWatermark) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamCopyNewResponseWatermarkJSON) RawJSON() string { - return r.raw -} - -type StreamCopyNewParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // A video's URL. The server must be publicly routable and support `HTTP HEAD` - // requests and `HTTP GET` range requests. The server should respond to `HTTP HEAD` - // requests with a `content-range` header that includes the size of the file. - URL param.Field[string] `json:"url,required" format:"uri"` - // Lists the origins allowed to display the video. Enter allowed origin domains in - // an array and use `*` for wildcard subdomains. Empty arrays allow the video to be - // viewed on any origin. - AllowedOrigins param.Field[[]string] `json:"allowedOrigins"` - // A user-defined identifier for the media creator. - Creator param.Field[string] `json:"creator"` - // A user modifiable key-value store used to reference other systems of record for - // managing videos. - Meta param.Field[interface{}] `json:"meta"` - // Indicates whether the video can be a accessed using the UID. When set to `true`, - // a signed token must be generated with a signing key to view the video. - RequireSignedURLs param.Field[bool] `json:"requireSignedURLs"` - // Indicates the date and time at which the video will be deleted. Omit the field - // to indicate no change, or include with a `null` value to remove an existing - // scheduled deletion. If specified, must be at least 30 days from upload time. - ScheduledDeletion param.Field[time.Time] `json:"scheduledDeletion" format:"date-time"` - // The timestamp for a thumbnail image calculated as a percentage value of the - // video's duration. To convert from a second-wise timestamp to a percentage, - // divide the desired timestamp by the total duration of the video. If this value - // is not set, the default thumbnail image is taken from 0s of the video. - ThumbnailTimestampPct param.Field[float64] `json:"thumbnailTimestampPct"` - Watermark param.Field[StreamCopyNewParamsWatermark] `json:"watermark"` - // A user-defined identifier for the media creator. - UploadCreator param.Field[string] `header:"Upload-Creator"` - // Comma-separated key-value pairs following the TUS protocol specification. Values - // are Base-64 encoded. Supported keys: `name`, `requiresignedurls`, - // `allowedorigins`, `thumbnailtimestamppct`, `watermark`, `scheduleddeletion`. - UploadMetadata param.Field[string] `header:"Upload-Metadata"` -} - -func (r StreamCopyNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type StreamCopyNewParamsWatermark struct { - // The unique identifier for the watermark profile. - Uid param.Field[string] `json:"uid"` -} - -func (r StreamCopyNewParamsWatermark) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type StreamCopyNewResponseEnvelope struct { - Errors []StreamCopyNewResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamCopyNewResponseEnvelopeMessages `json:"messages,required"` - Result StreamCopyNewResponse `json:"result,required"` - // Whether the API call was successful - Success StreamCopyNewResponseEnvelopeSuccess `json:"success,required"` - JSON streamCopyNewResponseEnvelopeJSON `json:"-"` -} - -// streamCopyNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [StreamCopyNewResponseEnvelope] -type streamCopyNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamCopyNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamCopyNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamCopyNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamCopyNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamCopyNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamCopyNewResponseEnvelopeErrors] -type streamCopyNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamCopyNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamCopyNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamCopyNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamCopyNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamCopyNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [StreamCopyNewResponseEnvelopeMessages] -type streamCopyNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamCopyNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamCopyNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamCopyNewResponseEnvelopeSuccess bool - -const ( - StreamCopyNewResponseEnvelopeSuccessTrue StreamCopyNewResponseEnvelopeSuccess = true -) diff --git a/streamcopy_test.go b/streamcopy_test.go deleted file mode 100644 index c73e729262c..00000000000 --- a/streamcopy_test.go +++ /dev/null @@ -1,55 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestStreamCopyNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Stream.Copies.New(context.TODO(), cloudflare.StreamCopyNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - URL: cloudflare.F("https://example.com/myvideo.mp4"), - AllowedOrigins: cloudflare.F([]string{"example.com"}), - Creator: cloudflare.F("creator-id_abcde12345"), - Meta: cloudflare.F[any](map[string]interface{}{ - "name": "video12345.mp4", - }), - RequireSignedURLs: cloudflare.F(true), - ScheduledDeletion: cloudflare.F(time.Now()), - ThumbnailTimestampPct: cloudflare.F(0.529241), - Watermark: cloudflare.F(cloudflare.StreamCopyNewParamsWatermark{ - Uid: cloudflare.F("ea95132c15732412d22c1476fa83f27a"), - }), - UploadCreator: cloudflare.F("creator-id_abcde12345"), - UploadMetadata: cloudflare.F("name aGVsbG8gd29ybGQ=, requiresignedurls, allowedorigins ZXhhbXBsZS5jb20sdGVzdC5jb20="), - }) - 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/streamdirectupload.go b/streamdirectupload.go deleted file mode 100644 index 7521d5a9bad..00000000000 --- a/streamdirectupload.go +++ /dev/null @@ -1,271 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// StreamDirectUploadService 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 [NewStreamDirectUploadService] method -// instead. -type StreamDirectUploadService struct { - Options []option.RequestOption -} - -// NewStreamDirectUploadService 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 NewStreamDirectUploadService(opts ...option.RequestOption) (r *StreamDirectUploadService) { - r = &StreamDirectUploadService{} - r.Options = opts - return -} - -// Creates a direct upload that allows video uploads without an API key. -func (r *StreamDirectUploadService) New(ctx context.Context, params StreamDirectUploadNewParams, opts ...option.RequestOption) (res *StreamDirectUploadNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamDirectUploadNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/direct_upload", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type StreamDirectUploadNewResponse struct { - // Indicates the date and time at which the video will be deleted. Omit the field - // to indicate no change, or include with a `null` value to remove an existing - // scheduled deletion. If specified, must be at least 30 days from upload time. - ScheduledDeletion time.Time `json:"scheduledDeletion" format:"date-time"` - // A Cloudflare-generated unique identifier for a media item. - Uid string `json:"uid"` - // The URL an unauthenticated upload can use for a single - // `HTTP POST multipart/form-data` request. - UploadURL string `json:"uploadURL"` - Watermark StreamDirectUploadNewResponseWatermark `json:"watermark"` - JSON streamDirectUploadNewResponseJSON `json:"-"` -} - -// streamDirectUploadNewResponseJSON contains the JSON metadata for the struct -// [StreamDirectUploadNewResponse] -type streamDirectUploadNewResponseJSON struct { - ScheduledDeletion apijson.Field - Uid apijson.Field - UploadURL apijson.Field - Watermark apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamDirectUploadNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamDirectUploadNewResponseJSON) RawJSON() string { - return r.raw -} - -type StreamDirectUploadNewResponseWatermark struct { - // The date and a time a watermark profile was created. - Created time.Time `json:"created" format:"date-time"` - // The source URL for a downloaded image. If the watermark profile was created via - // direct upload, this field is null. - DownloadedFrom string `json:"downloadedFrom"` - // The height of the image in pixels. - Height int64 `json:"height"` - // A short description of the watermark profile. - Name string `json:"name"` - // The translucency of the image. A value of `0.0` makes the image completely - // transparent, and `1.0` makes the image completely opaque. Note that if the image - // is already semi-transparent, setting this to `1.0` will not make the image - // completely opaque. - Opacity float64 `json:"opacity"` - // The whitespace between the adjacent edges (determined by position) of the video - // and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded - // video width or length, as determined by the algorithm. - Padding float64 `json:"padding"` - // The location of the image. Valid positions are: `upperRight`, `upperLeft`, - // `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the - // `padding` parameter. - Position string `json:"position"` - // The size of the image relative to the overall size of the video. This parameter - // will adapt to horizontal and vertical videos automatically. `0.0` indicates no - // scaling (use the size of the image as-is), and `1.0 `fills the entire video. - Scale float64 `json:"scale"` - // The size of the image in bytes. - Size float64 `json:"size"` - // The unique identifier for a watermark profile. - Uid string `json:"uid"` - // The width of the image in pixels. - Width int64 `json:"width"` - JSON streamDirectUploadNewResponseWatermarkJSON `json:"-"` -} - -// streamDirectUploadNewResponseWatermarkJSON contains the JSON metadata for the -// struct [StreamDirectUploadNewResponseWatermark] -type streamDirectUploadNewResponseWatermarkJSON struct { - Created apijson.Field - DownloadedFrom apijson.Field - Height apijson.Field - Name apijson.Field - Opacity apijson.Field - Padding apijson.Field - Position apijson.Field - Scale apijson.Field - Size apijson.Field - Uid apijson.Field - Width apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamDirectUploadNewResponseWatermark) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamDirectUploadNewResponseWatermarkJSON) RawJSON() string { - return r.raw -} - -type StreamDirectUploadNewParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // The maximum duration in seconds for a video upload. Can be set for a video that - // is not yet uploaded to limit its duration. Uploads that exceed the specified - // duration will fail during processing. A value of `-1` means the value is - // unknown. - MaxDurationSeconds param.Field[int64] `json:"maxDurationSeconds,required"` - // Lists the origins allowed to display the video. Enter allowed origin domains in - // an array and use `*` for wildcard subdomains. Empty arrays allow the video to be - // viewed on any origin. - AllowedOrigins param.Field[[]string] `json:"allowedOrigins"` - // A user-defined identifier for the media creator. - Creator param.Field[string] `json:"creator"` - // The date and time after upload when videos will not be accepted. - Expiry param.Field[time.Time] `json:"expiry" format:"date-time"` - // A user modifiable key-value store used to reference other systems of record for - // managing videos. - Meta param.Field[interface{}] `json:"meta"` - // Indicates whether the video can be a accessed using the UID. When set to `true`, - // a signed token must be generated with a signing key to view the video. - RequireSignedURLs param.Field[bool] `json:"requireSignedURLs"` - // Indicates the date and time at which the video will be deleted. Omit the field - // to indicate no change, or include with a `null` value to remove an existing - // scheduled deletion. If specified, must be at least 30 days from upload time. - ScheduledDeletion param.Field[time.Time] `json:"scheduledDeletion" format:"date-time"` - // The timestamp for a thumbnail image calculated as a percentage value of the - // video's duration. To convert from a second-wise timestamp to a percentage, - // divide the desired timestamp by the total duration of the video. If this value - // is not set, the default thumbnail image is taken from 0s of the video. - ThumbnailTimestampPct param.Field[float64] `json:"thumbnailTimestampPct"` - Watermark param.Field[StreamDirectUploadNewParamsWatermark] `json:"watermark"` - // A user-defined identifier for the media creator. - UploadCreator param.Field[string] `header:"Upload-Creator"` -} - -func (r StreamDirectUploadNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type StreamDirectUploadNewParamsWatermark struct { - // The unique identifier for the watermark profile. - Uid param.Field[string] `json:"uid"` -} - -func (r StreamDirectUploadNewParamsWatermark) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type StreamDirectUploadNewResponseEnvelope struct { - Errors []StreamDirectUploadNewResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamDirectUploadNewResponseEnvelopeMessages `json:"messages,required"` - Result StreamDirectUploadNewResponse `json:"result,required"` - // Whether the API call was successful - Success StreamDirectUploadNewResponseEnvelopeSuccess `json:"success,required"` - JSON streamDirectUploadNewResponseEnvelopeJSON `json:"-"` -} - -// streamDirectUploadNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [StreamDirectUploadNewResponseEnvelope] -type streamDirectUploadNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamDirectUploadNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamDirectUploadNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamDirectUploadNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamDirectUploadNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamDirectUploadNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [StreamDirectUploadNewResponseEnvelopeErrors] -type streamDirectUploadNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamDirectUploadNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamDirectUploadNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamDirectUploadNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamDirectUploadNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamDirectUploadNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [StreamDirectUploadNewResponseEnvelopeMessages] -type streamDirectUploadNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamDirectUploadNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamDirectUploadNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamDirectUploadNewResponseEnvelopeSuccess bool - -const ( - StreamDirectUploadNewResponseEnvelopeSuccessTrue StreamDirectUploadNewResponseEnvelopeSuccess = true -) diff --git a/streamdirectupload_test.go b/streamdirectupload_test.go deleted file mode 100644 index e803b051732..00000000000 --- a/streamdirectupload_test.go +++ /dev/null @@ -1,55 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestStreamDirectUploadNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Stream.DirectUploads.New(context.TODO(), cloudflare.StreamDirectUploadNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - MaxDurationSeconds: cloudflare.F(int64(1)), - AllowedOrigins: cloudflare.F([]string{"example.com"}), - Creator: cloudflare.F("creator-id_abcde12345"), - Expiry: cloudflare.F(time.Now()), - Meta: cloudflare.F[any](map[string]interface{}{ - "name": "video12345.mp4", - }), - RequireSignedURLs: cloudflare.F(true), - ScheduledDeletion: cloudflare.F(time.Now()), - ThumbnailTimestampPct: cloudflare.F(0.529241), - Watermark: cloudflare.F(cloudflare.StreamDirectUploadNewParamsWatermark{ - Uid: cloudflare.F("ea95132c15732412d22c1476fa83f27a"), - }), - UploadCreator: cloudflare.F("creator-id_abcde12345"), - }) - 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/streamdownload.go b/streamdownload.go deleted file mode 100644 index 0494ce232c0..00000000000 --- a/streamdownload.go +++ /dev/null @@ -1,381 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// StreamDownloadService 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 [NewStreamDownloadService] method -// instead. -type StreamDownloadService struct { - Options []option.RequestOption -} - -// NewStreamDownloadService 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 NewStreamDownloadService(opts ...option.RequestOption) (r *StreamDownloadService) { - r = &StreamDownloadService{} - r.Options = opts - return -} - -// Creates a download for a video when a video is ready to view. -func (r *StreamDownloadService) New(ctx context.Context, identifier string, body StreamDownloadNewParams, opts ...option.RequestOption) (res *StreamDownloadNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamDownloadNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/%s/downloads", body.AccountID, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete the downloads for a video. -func (r *StreamDownloadService) Delete(ctx context.Context, identifier string, body StreamDownloadDeleteParams, opts ...option.RequestOption) (res *StreamDownloadDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamDownloadDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/%s/downloads", body.AccountID, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists the downloads created for a video. -func (r *StreamDownloadService) Get(ctx context.Context, identifier string, query StreamDownloadGetParams, opts ...option.RequestOption) (res *StreamDownloadGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamDownloadGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/%s/downloads", query.AccountID, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [StreamDownloadNewResponseUnknown] or [shared.UnionString]. -type StreamDownloadNewResponse interface { - ImplementsStreamDownloadNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*StreamDownloadNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [StreamDownloadDeleteResponseUnknown] or -// [shared.UnionString]. -type StreamDownloadDeleteResponse interface { - ImplementsStreamDownloadDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*StreamDownloadDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [StreamDownloadGetResponseUnknown] or [shared.UnionString]. -type StreamDownloadGetResponse interface { - ImplementsStreamDownloadGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*StreamDownloadGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type StreamDownloadNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamDownloadNewResponseEnvelope struct { - Errors []StreamDownloadNewResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamDownloadNewResponseEnvelopeMessages `json:"messages,required"` - Result StreamDownloadNewResponse `json:"result,required"` - // Whether the API call was successful - Success StreamDownloadNewResponseEnvelopeSuccess `json:"success,required"` - JSON streamDownloadNewResponseEnvelopeJSON `json:"-"` -} - -// streamDownloadNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [StreamDownloadNewResponseEnvelope] -type streamDownloadNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamDownloadNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamDownloadNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamDownloadNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamDownloadNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamDownloadNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamDownloadNewResponseEnvelopeErrors] -type streamDownloadNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamDownloadNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamDownloadNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamDownloadNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamDownloadNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamDownloadNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [StreamDownloadNewResponseEnvelopeMessages] -type streamDownloadNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamDownloadNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamDownloadNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamDownloadNewResponseEnvelopeSuccess bool - -const ( - StreamDownloadNewResponseEnvelopeSuccessTrue StreamDownloadNewResponseEnvelopeSuccess = true -) - -type StreamDownloadDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamDownloadDeleteResponseEnvelope struct { - Errors []StreamDownloadDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamDownloadDeleteResponseEnvelopeMessages `json:"messages,required"` - Result StreamDownloadDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success StreamDownloadDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON streamDownloadDeleteResponseEnvelopeJSON `json:"-"` -} - -// streamDownloadDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [StreamDownloadDeleteResponseEnvelope] -type streamDownloadDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamDownloadDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamDownloadDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamDownloadDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamDownloadDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamDownloadDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [StreamDownloadDeleteResponseEnvelopeErrors] -type streamDownloadDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamDownloadDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamDownloadDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamDownloadDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamDownloadDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamDownloadDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [StreamDownloadDeleteResponseEnvelopeMessages] -type streamDownloadDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamDownloadDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamDownloadDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamDownloadDeleteResponseEnvelopeSuccess bool - -const ( - StreamDownloadDeleteResponseEnvelopeSuccessTrue StreamDownloadDeleteResponseEnvelopeSuccess = true -) - -type StreamDownloadGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamDownloadGetResponseEnvelope struct { - Errors []StreamDownloadGetResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamDownloadGetResponseEnvelopeMessages `json:"messages,required"` - Result StreamDownloadGetResponse `json:"result,required"` - // Whether the API call was successful - Success StreamDownloadGetResponseEnvelopeSuccess `json:"success,required"` - JSON streamDownloadGetResponseEnvelopeJSON `json:"-"` -} - -// streamDownloadGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [StreamDownloadGetResponseEnvelope] -type streamDownloadGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamDownloadGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamDownloadGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamDownloadGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamDownloadGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamDownloadGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamDownloadGetResponseEnvelopeErrors] -type streamDownloadGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamDownloadGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamDownloadGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamDownloadGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamDownloadGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamDownloadGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [StreamDownloadGetResponseEnvelopeMessages] -type streamDownloadGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamDownloadGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamDownloadGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamDownloadGetResponseEnvelopeSuccess bool - -const ( - StreamDownloadGetResponseEnvelopeSuccessTrue StreamDownloadGetResponseEnvelopeSuccess = true -) diff --git a/streamdownload_test.go b/streamdownload_test.go deleted file mode 100644 index 66ea07e3b49..00000000000 --- a/streamdownload_test.go +++ /dev/null @@ -1,104 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestStreamDownloadNew(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("user@example.com"), - ) - _, err := client.Stream.Downloads.New( - context.TODO(), - "ea95132c15732412d22c1476fa83f27a", - cloudflare.StreamDownloadNewParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestStreamDownloadDelete(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("user@example.com"), - ) - _, err := client.Stream.Downloads.Delete( - context.TODO(), - "ea95132c15732412d22c1476fa83f27a", - cloudflare.StreamDownloadDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestStreamDownloadGet(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("user@example.com"), - ) - _, err := client.Stream.Downloads.Get( - context.TODO(), - "ea95132c15732412d22c1476fa83f27a", - cloudflare.StreamDownloadGetParams{ - AccountID: cloudflare.F("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/streamembed.go b/streamembed.go deleted file mode 100644 index f1a5a95d2ed..00000000000 --- a/streamembed.go +++ /dev/null @@ -1,48 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// StreamEmbedService 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 [NewStreamEmbedService] method -// instead. -type StreamEmbedService struct { - Options []option.RequestOption -} - -// NewStreamEmbedService 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 NewStreamEmbedService(opts ...option.RequestOption) (r *StreamEmbedService) { - r = &StreamEmbedService{} - r.Options = opts - return -} - -// Fetches an HTML code snippet to embed a video in a web page delivered through -// Cloudflare. On success, returns an HTML fragment for use on web pages to display -// a video. On failure, returns a JSON response body. -func (r *StreamEmbedService) Get(ctx context.Context, identifier string, query StreamEmbedGetParams, opts ...option.RequestOption) (res *StreamEmbedGetResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("accounts/%s/stream/%s/embed", query.AccountID, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -type StreamEmbedGetResponse = interface{} - -type StreamEmbedGetParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} diff --git a/streamembed_test.go b/streamembed_test.go deleted file mode 100644 index ad26a50ec63..00000000000 --- a/streamembed_test.go +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestStreamEmbedGet(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("user@example.com"), - ) - _, err := client.Stream.Embeds.Get( - context.TODO(), - "ea95132c15732412d22c1476fa83f27a", - cloudflare.StreamEmbedGetParams{ - AccountID: cloudflare.F("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/streamkey.go b/streamkey.go deleted file mode 100644 index 34cda238242..00000000000 --- a/streamkey.go +++ /dev/null @@ -1,406 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// StreamKeyService 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 [NewStreamKeyService] method instead. -type StreamKeyService struct { - Options []option.RequestOption -} - -// NewStreamKeyService 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 NewStreamKeyService(opts ...option.RequestOption) (r *StreamKeyService) { - r = &StreamKeyService{} - r.Options = opts - return -} - -// Creates an RSA private key in PEM and JWK formats. Key files are only displayed -// once after creation. Keys are created, used, and deleted independently of -// videos, and every key can sign any video. -func (r *StreamKeyService) New(ctx context.Context, body StreamKeyNewParams, opts ...option.RequestOption) (res *StreamKeyNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamKeyNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/keys", body.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes signing keys and revokes all signed URLs generated with the key. -func (r *StreamKeyService) Delete(ctx context.Context, identifier string, body StreamKeyDeleteParams, opts ...option.RequestOption) (res *StreamKeyDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamKeyDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/keys/%s", body.AccountID, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists the video ID and creation date and time when a signing key was created. -func (r *StreamKeyService) Get(ctx context.Context, query StreamKeyGetParams, opts ...option.RequestOption) (res *[]StreamKeyGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamKeyGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/keys", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type StreamKeyNewResponse struct { - // Identifier - ID string `json:"id"` - // The date and time a signing key was created. - Created time.Time `json:"created" format:"date-time"` - // The signing key in JWK format. - Jwk string `json:"jwk"` - // The signing key in PEM format. - Pem string `json:"pem"` - JSON streamKeyNewResponseJSON `json:"-"` -} - -// streamKeyNewResponseJSON contains the JSON metadata for the struct -// [StreamKeyNewResponse] -type streamKeyNewResponseJSON struct { - ID apijson.Field - Created apijson.Field - Jwk apijson.Field - Pem apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamKeyNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamKeyNewResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [StreamKeyDeleteResponseUnknown] or [shared.UnionString]. -type StreamKeyDeleteResponse interface { - ImplementsStreamKeyDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*StreamKeyDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type StreamKeyGetResponse struct { - // Identifier - ID string `json:"id"` - // The date and time a signing key was created. - Created time.Time `json:"created" format:"date-time"` - JSON streamKeyGetResponseJSON `json:"-"` -} - -// streamKeyGetResponseJSON contains the JSON metadata for the struct -// [StreamKeyGetResponse] -type streamKeyGetResponseJSON struct { - ID apijson.Field - Created apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamKeyGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamKeyGetResponseJSON) RawJSON() string { - return r.raw -} - -type StreamKeyNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamKeyNewResponseEnvelope struct { - Errors []StreamKeyNewResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamKeyNewResponseEnvelopeMessages `json:"messages,required"` - Result StreamKeyNewResponse `json:"result,required"` - // Whether the API call was successful - Success StreamKeyNewResponseEnvelopeSuccess `json:"success,required"` - JSON streamKeyNewResponseEnvelopeJSON `json:"-"` -} - -// streamKeyNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [StreamKeyNewResponseEnvelope] -type streamKeyNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamKeyNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamKeyNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamKeyNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamKeyNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamKeyNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [StreamKeyNewResponseEnvelopeErrors] -type streamKeyNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamKeyNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamKeyNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamKeyNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamKeyNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamKeyNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [StreamKeyNewResponseEnvelopeMessages] -type streamKeyNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamKeyNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamKeyNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamKeyNewResponseEnvelopeSuccess bool - -const ( - StreamKeyNewResponseEnvelopeSuccessTrue StreamKeyNewResponseEnvelopeSuccess = true -) - -type StreamKeyDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamKeyDeleteResponseEnvelope struct { - Errors []StreamKeyDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamKeyDeleteResponseEnvelopeMessages `json:"messages,required"` - Result StreamKeyDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success StreamKeyDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON streamKeyDeleteResponseEnvelopeJSON `json:"-"` -} - -// streamKeyDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [StreamKeyDeleteResponseEnvelope] -type streamKeyDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamKeyDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamKeyDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamKeyDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamKeyDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamKeyDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamKeyDeleteResponseEnvelopeErrors] -type streamKeyDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamKeyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamKeyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamKeyDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamKeyDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamKeyDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [StreamKeyDeleteResponseEnvelopeMessages] -type streamKeyDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamKeyDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamKeyDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamKeyDeleteResponseEnvelopeSuccess bool - -const ( - StreamKeyDeleteResponseEnvelopeSuccessTrue StreamKeyDeleteResponseEnvelopeSuccess = true -) - -type StreamKeyGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamKeyGetResponseEnvelope struct { - Errors []StreamKeyGetResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamKeyGetResponseEnvelopeMessages `json:"messages,required"` - Result []StreamKeyGetResponse `json:"result,required"` - // Whether the API call was successful - Success StreamKeyGetResponseEnvelopeSuccess `json:"success,required"` - JSON streamKeyGetResponseEnvelopeJSON `json:"-"` -} - -// streamKeyGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [StreamKeyGetResponseEnvelope] -type streamKeyGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamKeyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamKeyGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamKeyGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamKeyGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamKeyGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [StreamKeyGetResponseEnvelopeErrors] -type streamKeyGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamKeyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamKeyGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamKeyGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamKeyGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamKeyGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [StreamKeyGetResponseEnvelopeMessages] -type streamKeyGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamKeyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamKeyGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamKeyGetResponseEnvelopeSuccess bool - -const ( - StreamKeyGetResponseEnvelopeSuccessTrue StreamKeyGetResponseEnvelopeSuccess = true -) diff --git a/streamkey_test.go b/streamkey_test.go deleted file mode 100644 index c858a03869c..00000000000 --- a/streamkey_test.go +++ /dev/null @@ -1,96 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestStreamKeyNew(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("user@example.com"), - ) - _, err := client.Stream.Keys.New(context.TODO(), cloudflare.StreamKeyNewParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestStreamKeyDelete(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("user@example.com"), - ) - _, err := client.Stream.Keys.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.StreamKeyDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestStreamKeyGet(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("user@example.com"), - ) - _, err := client.Stream.Keys.Get(context.TODO(), cloudflare.StreamKeyGetParams{ - AccountID: cloudflare.F("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/streamliveinput.go b/streamliveinput.go deleted file mode 100644 index c49f0d89a14..00000000000 --- a/streamliveinput.go +++ /dev/null @@ -1,1505 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// StreamLiveInputService 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 [NewStreamLiveInputService] method -// instead. -type StreamLiveInputService struct { - Options []option.RequestOption - Outputs *StreamLiveInputOutputService -} - -// NewStreamLiveInputService 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 NewStreamLiveInputService(opts ...option.RequestOption) (r *StreamLiveInputService) { - r = &StreamLiveInputService{} - r.Options = opts - r.Outputs = NewStreamLiveInputOutputService(opts...) - return -} - -// Creates a live input, and returns credentials that you or your users can use to -// stream live video to Cloudflare Stream. -func (r *StreamLiveInputService) New(ctx context.Context, params StreamLiveInputNewParams, opts ...option.RequestOption) (res *StreamLiveInputNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamLiveInputNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/live_inputs", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a specified live input. -func (r *StreamLiveInputService) Update(ctx context.Context, liveInputIdentifier string, params StreamLiveInputUpdateParams, opts ...option.RequestOption) (res *StreamLiveInputUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamLiveInputUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s", params.AccountID, liveInputIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists the live inputs created for an account. To get the credentials needed to -// stream to a specific live input, request a single live input. -func (r *StreamLiveInputService) List(ctx context.Context, params StreamLiveInputListParams, opts ...option.RequestOption) (res *StreamLiveInputListResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamLiveInputListResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/live_inputs", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Prevents a live input from being streamed to and makes the live input -// inaccessible to any future API calls. -func (r *StreamLiveInputService) Delete(ctx context.Context, liveInputIdentifier string, body StreamLiveInputDeleteParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s", body.AccountID, liveInputIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) - return -} - -// Retrieves details of an existing live input. -func (r *StreamLiveInputService) Get(ctx context.Context, liveInputIdentifier string, query StreamLiveInputGetParams, opts ...option.RequestOption) (res *StreamLiveInputGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamLiveInputGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s", query.AccountID, liveInputIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Details about a live input. -type StreamLiveInputNewResponse struct { - // The date and time the live input was created. - Created time.Time `json:"created" format:"date-time"` - // Indicates the number of days after which the live inputs recordings will be - // deleted. When a stream completes and the recording is ready, the value is used - // to calculate a scheduled deletion date for that recording. Omit the field to - // indicate no change, or include with a `null` value to remove an existing - // scheduled deletion. - DeleteRecordingAfterDays float64 `json:"deleteRecordingAfterDays"` - // A user modifiable key-value store used to reference other systems of record for - // managing live inputs. - Meta interface{} `json:"meta"` - // The date and time the live input was last modified. - Modified time.Time `json:"modified" format:"date-time"` - // Records the input to a Cloudflare Stream video. Behavior depends on the mode. In - // most cases, the video will initially be viewable as a live video and transition - // to on-demand after a condition is satisfied. - Recording StreamLiveInputNewResponseRecording `json:"recording"` - // Details for streaming to an live input using RTMPS. - Rtmps StreamLiveInputNewResponseRtmps `json:"rtmps"` - // Details for playback from an live input using RTMPS. - RtmpsPlayback StreamLiveInputNewResponseRtmpsPlayback `json:"rtmpsPlayback"` - // Details for streaming to a live input using SRT. - Srt StreamLiveInputNewResponseSrt `json:"srt"` - // Details for playback from an live input using SRT. - SrtPlayback StreamLiveInputNewResponseSrtPlayback `json:"srtPlayback"` - // The connection status of a live input. - Status StreamLiveInputNewResponseStatus `json:"status,nullable"` - // A unique identifier for a live input. - Uid string `json:"uid"` - // Details for streaming to a live input using WebRTC. - WebRtc StreamLiveInputNewResponseWebRtc `json:"webRTC"` - // Details for playback from a live input using WebRTC. - WebRtcPlayback StreamLiveInputNewResponseWebRtcPlayback `json:"webRTCPlayback"` - JSON streamLiveInputNewResponseJSON `json:"-"` -} - -// streamLiveInputNewResponseJSON contains the JSON metadata for the struct -// [StreamLiveInputNewResponse] -type streamLiveInputNewResponseJSON struct { - Created apijson.Field - DeleteRecordingAfterDays apijson.Field - Meta apijson.Field - Modified apijson.Field - Recording apijson.Field - Rtmps apijson.Field - RtmpsPlayback apijson.Field - Srt apijson.Field - SrtPlayback apijson.Field - Status apijson.Field - Uid apijson.Field - WebRtc apijson.Field - WebRtcPlayback apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputNewResponseJSON) RawJSON() string { - return r.raw -} - -// Records the input to a Cloudflare Stream video. Behavior depends on the mode. In -// most cases, the video will initially be viewable as a live video and transition -// to on-demand after a condition is satisfied. -type StreamLiveInputNewResponseRecording struct { - // Lists the origins allowed to display videos created with this input. Enter - // allowed origin domains in an array and use `*` for wildcard subdomains. An empty - // array allows videos to be viewed on any origin. - AllowedOrigins []string `json:"allowedOrigins"` - // Specifies the recording behavior for the live input. Set this value to `off` to - // prevent a recording. Set the value to `automatic` to begin a recording and - // transition to on-demand after Stream Live stops receiving input. - Mode StreamLiveInputNewResponseRecordingMode `json:"mode"` - // Indicates if a video using the live input has the `requireSignedURLs` property - // set. Also enforces access controls on any video recording of the livestream with - // the live input. - RequireSignedURLs bool `json:"requireSignedURLs"` - // Determines the amount of time a live input configured in `automatic` mode should - // wait before a recording transitions from live to on-demand. `0` is recommended - // for most use cases and indicates the platform default should be used. - TimeoutSeconds int64 `json:"timeoutSeconds"` - JSON streamLiveInputNewResponseRecordingJSON `json:"-"` -} - -// streamLiveInputNewResponseRecordingJSON contains the JSON metadata for the -// struct [StreamLiveInputNewResponseRecording] -type streamLiveInputNewResponseRecordingJSON struct { - AllowedOrigins apijson.Field - Mode apijson.Field - RequireSignedURLs apijson.Field - TimeoutSeconds apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputNewResponseRecording) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputNewResponseRecordingJSON) RawJSON() string { - return r.raw -} - -// Specifies the recording behavior for the live input. Set this value to `off` to -// prevent a recording. Set the value to `automatic` to begin a recording and -// transition to on-demand after Stream Live stops receiving input. -type StreamLiveInputNewResponseRecordingMode string - -const ( - StreamLiveInputNewResponseRecordingModeOff StreamLiveInputNewResponseRecordingMode = "off" - StreamLiveInputNewResponseRecordingModeAutomatic StreamLiveInputNewResponseRecordingMode = "automatic" -) - -// Details for streaming to an live input using RTMPS. -type StreamLiveInputNewResponseRtmps struct { - // The secret key to use when streaming via RTMPS to a live input. - StreamKey string `json:"streamKey"` - // The RTMPS URL you provide to the broadcaster, which they stream live video to. - URL string `json:"url"` - JSON streamLiveInputNewResponseRtmpsJSON `json:"-"` -} - -// streamLiveInputNewResponseRtmpsJSON contains the JSON metadata for the struct -// [StreamLiveInputNewResponseRtmps] -type streamLiveInputNewResponseRtmpsJSON struct { - StreamKey apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputNewResponseRtmps) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputNewResponseRtmpsJSON) RawJSON() string { - return r.raw -} - -// Details for playback from an live input using RTMPS. -type StreamLiveInputNewResponseRtmpsPlayback struct { - // The secret key to use for playback via RTMPS. - StreamKey string `json:"streamKey"` - // The URL used to play live video over RTMPS. - URL string `json:"url"` - JSON streamLiveInputNewResponseRtmpsPlaybackJSON `json:"-"` -} - -// streamLiveInputNewResponseRtmpsPlaybackJSON contains the JSON metadata for the -// struct [StreamLiveInputNewResponseRtmpsPlayback] -type streamLiveInputNewResponseRtmpsPlaybackJSON struct { - StreamKey apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputNewResponseRtmpsPlayback) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputNewResponseRtmpsPlaybackJSON) RawJSON() string { - return r.raw -} - -// Details for streaming to a live input using SRT. -type StreamLiveInputNewResponseSrt struct { - // The secret key to use when streaming via SRT to a live input. - Passphrase string `json:"passphrase"` - // The identifier of the live input to use when streaming via SRT. - StreamID string `json:"streamId"` - // The SRT URL you provide to the broadcaster, which they stream live video to. - URL string `json:"url"` - JSON streamLiveInputNewResponseSrtJSON `json:"-"` -} - -// streamLiveInputNewResponseSrtJSON contains the JSON metadata for the struct -// [StreamLiveInputNewResponseSrt] -type streamLiveInputNewResponseSrtJSON struct { - Passphrase apijson.Field - StreamID apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputNewResponseSrt) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputNewResponseSrtJSON) RawJSON() string { - return r.raw -} - -// Details for playback from an live input using SRT. -type StreamLiveInputNewResponseSrtPlayback struct { - // The secret key to use for playback via SRT. - Passphrase string `json:"passphrase"` - // The identifier of the live input to use for playback via SRT. - StreamID string `json:"streamId"` - // The URL used to play live video over SRT. - URL string `json:"url"` - JSON streamLiveInputNewResponseSrtPlaybackJSON `json:"-"` -} - -// streamLiveInputNewResponseSrtPlaybackJSON contains the JSON metadata for the -// struct [StreamLiveInputNewResponseSrtPlayback] -type streamLiveInputNewResponseSrtPlaybackJSON struct { - Passphrase apijson.Field - StreamID apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputNewResponseSrtPlayback) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputNewResponseSrtPlaybackJSON) RawJSON() string { - return r.raw -} - -// The connection status of a live input. -type StreamLiveInputNewResponseStatus string - -const ( - StreamLiveInputNewResponseStatusConnected StreamLiveInputNewResponseStatus = "connected" - StreamLiveInputNewResponseStatusReconnected StreamLiveInputNewResponseStatus = "reconnected" - StreamLiveInputNewResponseStatusReconnecting StreamLiveInputNewResponseStatus = "reconnecting" - StreamLiveInputNewResponseStatusClientDisconnect StreamLiveInputNewResponseStatus = "client_disconnect" - StreamLiveInputNewResponseStatusTTLExceeded StreamLiveInputNewResponseStatus = "ttl_exceeded" - StreamLiveInputNewResponseStatusFailedToConnect StreamLiveInputNewResponseStatus = "failed_to_connect" - StreamLiveInputNewResponseStatusFailedToReconnect StreamLiveInputNewResponseStatus = "failed_to_reconnect" - StreamLiveInputNewResponseStatusNewConfigurationAccepted StreamLiveInputNewResponseStatus = "new_configuration_accepted" -) - -// Details for streaming to a live input using WebRTC. -type StreamLiveInputNewResponseWebRtc struct { - // The WebRTC URL you provide to the broadcaster, which they stream live video to. - URL string `json:"url"` - JSON streamLiveInputNewResponseWebRtcJSON `json:"-"` -} - -// streamLiveInputNewResponseWebRtcJSON contains the JSON metadata for the struct -// [StreamLiveInputNewResponseWebRtc] -type streamLiveInputNewResponseWebRtcJSON struct { - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputNewResponseWebRtc) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputNewResponseWebRtcJSON) RawJSON() string { - return r.raw -} - -// Details for playback from a live input using WebRTC. -type StreamLiveInputNewResponseWebRtcPlayback struct { - // The URL used to play live video over WebRTC. - URL string `json:"url"` - JSON streamLiveInputNewResponseWebRtcPlaybackJSON `json:"-"` -} - -// streamLiveInputNewResponseWebRtcPlaybackJSON contains the JSON metadata for the -// struct [StreamLiveInputNewResponseWebRtcPlayback] -type streamLiveInputNewResponseWebRtcPlaybackJSON struct { - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputNewResponseWebRtcPlayback) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputNewResponseWebRtcPlaybackJSON) RawJSON() string { - return r.raw -} - -// Details about a live input. -type StreamLiveInputUpdateResponse struct { - // The date and time the live input was created. - Created time.Time `json:"created" format:"date-time"` - // Indicates the number of days after which the live inputs recordings will be - // deleted. When a stream completes and the recording is ready, the value is used - // to calculate a scheduled deletion date for that recording. Omit the field to - // indicate no change, or include with a `null` value to remove an existing - // scheduled deletion. - DeleteRecordingAfterDays float64 `json:"deleteRecordingAfterDays"` - // A user modifiable key-value store used to reference other systems of record for - // managing live inputs. - Meta interface{} `json:"meta"` - // The date and time the live input was last modified. - Modified time.Time `json:"modified" format:"date-time"` - // Records the input to a Cloudflare Stream video. Behavior depends on the mode. In - // most cases, the video will initially be viewable as a live video and transition - // to on-demand after a condition is satisfied. - Recording StreamLiveInputUpdateResponseRecording `json:"recording"` - // Details for streaming to an live input using RTMPS. - Rtmps StreamLiveInputUpdateResponseRtmps `json:"rtmps"` - // Details for playback from an live input using RTMPS. - RtmpsPlayback StreamLiveInputUpdateResponseRtmpsPlayback `json:"rtmpsPlayback"` - // Details for streaming to a live input using SRT. - Srt StreamLiveInputUpdateResponseSrt `json:"srt"` - // Details for playback from an live input using SRT. - SrtPlayback StreamLiveInputUpdateResponseSrtPlayback `json:"srtPlayback"` - // The connection status of a live input. - Status StreamLiveInputUpdateResponseStatus `json:"status,nullable"` - // A unique identifier for a live input. - Uid string `json:"uid"` - // Details for streaming to a live input using WebRTC. - WebRtc StreamLiveInputUpdateResponseWebRtc `json:"webRTC"` - // Details for playback from a live input using WebRTC. - WebRtcPlayback StreamLiveInputUpdateResponseWebRtcPlayback `json:"webRTCPlayback"` - JSON streamLiveInputUpdateResponseJSON `json:"-"` -} - -// streamLiveInputUpdateResponseJSON contains the JSON metadata for the struct -// [StreamLiveInputUpdateResponse] -type streamLiveInputUpdateResponseJSON struct { - Created apijson.Field - DeleteRecordingAfterDays apijson.Field - Meta apijson.Field - Modified apijson.Field - Recording apijson.Field - Rtmps apijson.Field - RtmpsPlayback apijson.Field - Srt apijson.Field - SrtPlayback apijson.Field - Status apijson.Field - Uid apijson.Field - WebRtc apijson.Field - WebRtcPlayback apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// Records the input to a Cloudflare Stream video. Behavior depends on the mode. In -// most cases, the video will initially be viewable as a live video and transition -// to on-demand after a condition is satisfied. -type StreamLiveInputUpdateResponseRecording struct { - // Lists the origins allowed to display videos created with this input. Enter - // allowed origin domains in an array and use `*` for wildcard subdomains. An empty - // array allows videos to be viewed on any origin. - AllowedOrigins []string `json:"allowedOrigins"` - // Specifies the recording behavior for the live input. Set this value to `off` to - // prevent a recording. Set the value to `automatic` to begin a recording and - // transition to on-demand after Stream Live stops receiving input. - Mode StreamLiveInputUpdateResponseRecordingMode `json:"mode"` - // Indicates if a video using the live input has the `requireSignedURLs` property - // set. Also enforces access controls on any video recording of the livestream with - // the live input. - RequireSignedURLs bool `json:"requireSignedURLs"` - // Determines the amount of time a live input configured in `automatic` mode should - // wait before a recording transitions from live to on-demand. `0` is recommended - // for most use cases and indicates the platform default should be used. - TimeoutSeconds int64 `json:"timeoutSeconds"` - JSON streamLiveInputUpdateResponseRecordingJSON `json:"-"` -} - -// streamLiveInputUpdateResponseRecordingJSON contains the JSON metadata for the -// struct [StreamLiveInputUpdateResponseRecording] -type streamLiveInputUpdateResponseRecordingJSON struct { - AllowedOrigins apijson.Field - Mode apijson.Field - RequireSignedURLs apijson.Field - TimeoutSeconds apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputUpdateResponseRecording) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputUpdateResponseRecordingJSON) RawJSON() string { - return r.raw -} - -// Specifies the recording behavior for the live input. Set this value to `off` to -// prevent a recording. Set the value to `automatic` to begin a recording and -// transition to on-demand after Stream Live stops receiving input. -type StreamLiveInputUpdateResponseRecordingMode string - -const ( - StreamLiveInputUpdateResponseRecordingModeOff StreamLiveInputUpdateResponseRecordingMode = "off" - StreamLiveInputUpdateResponseRecordingModeAutomatic StreamLiveInputUpdateResponseRecordingMode = "automatic" -) - -// Details for streaming to an live input using RTMPS. -type StreamLiveInputUpdateResponseRtmps struct { - // The secret key to use when streaming via RTMPS to a live input. - StreamKey string `json:"streamKey"` - // The RTMPS URL you provide to the broadcaster, which they stream live video to. - URL string `json:"url"` - JSON streamLiveInputUpdateResponseRtmpsJSON `json:"-"` -} - -// streamLiveInputUpdateResponseRtmpsJSON contains the JSON metadata for the struct -// [StreamLiveInputUpdateResponseRtmps] -type streamLiveInputUpdateResponseRtmpsJSON struct { - StreamKey apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputUpdateResponseRtmps) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputUpdateResponseRtmpsJSON) RawJSON() string { - return r.raw -} - -// Details for playback from an live input using RTMPS. -type StreamLiveInputUpdateResponseRtmpsPlayback struct { - // The secret key to use for playback via RTMPS. - StreamKey string `json:"streamKey"` - // The URL used to play live video over RTMPS. - URL string `json:"url"` - JSON streamLiveInputUpdateResponseRtmpsPlaybackJSON `json:"-"` -} - -// streamLiveInputUpdateResponseRtmpsPlaybackJSON contains the JSON metadata for -// the struct [StreamLiveInputUpdateResponseRtmpsPlayback] -type streamLiveInputUpdateResponseRtmpsPlaybackJSON struct { - StreamKey apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputUpdateResponseRtmpsPlayback) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputUpdateResponseRtmpsPlaybackJSON) RawJSON() string { - return r.raw -} - -// Details for streaming to a live input using SRT. -type StreamLiveInputUpdateResponseSrt struct { - // The secret key to use when streaming via SRT to a live input. - Passphrase string `json:"passphrase"` - // The identifier of the live input to use when streaming via SRT. - StreamID string `json:"streamId"` - // The SRT URL you provide to the broadcaster, which they stream live video to. - URL string `json:"url"` - JSON streamLiveInputUpdateResponseSrtJSON `json:"-"` -} - -// streamLiveInputUpdateResponseSrtJSON contains the JSON metadata for the struct -// [StreamLiveInputUpdateResponseSrt] -type streamLiveInputUpdateResponseSrtJSON struct { - Passphrase apijson.Field - StreamID apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputUpdateResponseSrt) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputUpdateResponseSrtJSON) RawJSON() string { - return r.raw -} - -// Details for playback from an live input using SRT. -type StreamLiveInputUpdateResponseSrtPlayback struct { - // The secret key to use for playback via SRT. - Passphrase string `json:"passphrase"` - // The identifier of the live input to use for playback via SRT. - StreamID string `json:"streamId"` - // The URL used to play live video over SRT. - URL string `json:"url"` - JSON streamLiveInputUpdateResponseSrtPlaybackJSON `json:"-"` -} - -// streamLiveInputUpdateResponseSrtPlaybackJSON contains the JSON metadata for the -// struct [StreamLiveInputUpdateResponseSrtPlayback] -type streamLiveInputUpdateResponseSrtPlaybackJSON struct { - Passphrase apijson.Field - StreamID apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputUpdateResponseSrtPlayback) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputUpdateResponseSrtPlaybackJSON) RawJSON() string { - return r.raw -} - -// The connection status of a live input. -type StreamLiveInputUpdateResponseStatus string - -const ( - StreamLiveInputUpdateResponseStatusConnected StreamLiveInputUpdateResponseStatus = "connected" - StreamLiveInputUpdateResponseStatusReconnected StreamLiveInputUpdateResponseStatus = "reconnected" - StreamLiveInputUpdateResponseStatusReconnecting StreamLiveInputUpdateResponseStatus = "reconnecting" - StreamLiveInputUpdateResponseStatusClientDisconnect StreamLiveInputUpdateResponseStatus = "client_disconnect" - StreamLiveInputUpdateResponseStatusTTLExceeded StreamLiveInputUpdateResponseStatus = "ttl_exceeded" - StreamLiveInputUpdateResponseStatusFailedToConnect StreamLiveInputUpdateResponseStatus = "failed_to_connect" - StreamLiveInputUpdateResponseStatusFailedToReconnect StreamLiveInputUpdateResponseStatus = "failed_to_reconnect" - StreamLiveInputUpdateResponseStatusNewConfigurationAccepted StreamLiveInputUpdateResponseStatus = "new_configuration_accepted" -) - -// Details for streaming to a live input using WebRTC. -type StreamLiveInputUpdateResponseWebRtc struct { - // The WebRTC URL you provide to the broadcaster, which they stream live video to. - URL string `json:"url"` - JSON streamLiveInputUpdateResponseWebRtcJSON `json:"-"` -} - -// streamLiveInputUpdateResponseWebRtcJSON contains the JSON metadata for the -// struct [StreamLiveInputUpdateResponseWebRtc] -type streamLiveInputUpdateResponseWebRtcJSON struct { - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputUpdateResponseWebRtc) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputUpdateResponseWebRtcJSON) RawJSON() string { - return r.raw -} - -// Details for playback from a live input using WebRTC. -type StreamLiveInputUpdateResponseWebRtcPlayback struct { - // The URL used to play live video over WebRTC. - URL string `json:"url"` - JSON streamLiveInputUpdateResponseWebRtcPlaybackJSON `json:"-"` -} - -// streamLiveInputUpdateResponseWebRtcPlaybackJSON contains the JSON metadata for -// the struct [StreamLiveInputUpdateResponseWebRtcPlayback] -type streamLiveInputUpdateResponseWebRtcPlaybackJSON struct { - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputUpdateResponseWebRtcPlayback) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputUpdateResponseWebRtcPlaybackJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputListResponse struct { - LiveInputs []StreamLiveInputListResponseLiveInput `json:"liveInputs"` - // The total number of remaining live inputs based on cursor position. - Range int64 `json:"range"` - // The total number of live inputs that match the provided filters. - Total int64 `json:"total"` - JSON streamLiveInputListResponseJSON `json:"-"` -} - -// streamLiveInputListResponseJSON contains the JSON metadata for the struct -// [StreamLiveInputListResponse] -type streamLiveInputListResponseJSON struct { - LiveInputs apijson.Field - Range apijson.Field - Total apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputListResponseJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputListResponseLiveInput struct { - // The date and time the live input was created. - Created time.Time `json:"created" format:"date-time"` - // Indicates the number of days after which the live inputs recordings will be - // deleted. When a stream completes and the recording is ready, the value is used - // to calculate a scheduled deletion date for that recording. Omit the field to - // indicate no change, or include with a `null` value to remove an existing - // scheduled deletion. - DeleteRecordingAfterDays float64 `json:"deleteRecordingAfterDays"` - // A user modifiable key-value store used to reference other systems of record for - // managing live inputs. - Meta interface{} `json:"meta"` - // The date and time the live input was last modified. - Modified time.Time `json:"modified" format:"date-time"` - // A unique identifier for a live input. - Uid string `json:"uid"` - JSON streamLiveInputListResponseLiveInputJSON `json:"-"` -} - -// streamLiveInputListResponseLiveInputJSON contains the JSON metadata for the -// struct [StreamLiveInputListResponseLiveInput] -type streamLiveInputListResponseLiveInputJSON struct { - Created apijson.Field - DeleteRecordingAfterDays apijson.Field - Meta apijson.Field - Modified apijson.Field - Uid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputListResponseLiveInput) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputListResponseLiveInputJSON) RawJSON() string { - return r.raw -} - -// Details about a live input. -type StreamLiveInputGetResponse struct { - // The date and time the live input was created. - Created time.Time `json:"created" format:"date-time"` - // Indicates the number of days after which the live inputs recordings will be - // deleted. When a stream completes and the recording is ready, the value is used - // to calculate a scheduled deletion date for that recording. Omit the field to - // indicate no change, or include with a `null` value to remove an existing - // scheduled deletion. - DeleteRecordingAfterDays float64 `json:"deleteRecordingAfterDays"` - // A user modifiable key-value store used to reference other systems of record for - // managing live inputs. - Meta interface{} `json:"meta"` - // The date and time the live input was last modified. - Modified time.Time `json:"modified" format:"date-time"` - // Records the input to a Cloudflare Stream video. Behavior depends on the mode. In - // most cases, the video will initially be viewable as a live video and transition - // to on-demand after a condition is satisfied. - Recording StreamLiveInputGetResponseRecording `json:"recording"` - // Details for streaming to an live input using RTMPS. - Rtmps StreamLiveInputGetResponseRtmps `json:"rtmps"` - // Details for playback from an live input using RTMPS. - RtmpsPlayback StreamLiveInputGetResponseRtmpsPlayback `json:"rtmpsPlayback"` - // Details for streaming to a live input using SRT. - Srt StreamLiveInputGetResponseSrt `json:"srt"` - // Details for playback from an live input using SRT. - SrtPlayback StreamLiveInputGetResponseSrtPlayback `json:"srtPlayback"` - // The connection status of a live input. - Status StreamLiveInputGetResponseStatus `json:"status,nullable"` - // A unique identifier for a live input. - Uid string `json:"uid"` - // Details for streaming to a live input using WebRTC. - WebRtc StreamLiveInputGetResponseWebRtc `json:"webRTC"` - // Details for playback from a live input using WebRTC. - WebRtcPlayback StreamLiveInputGetResponseWebRtcPlayback `json:"webRTCPlayback"` - JSON streamLiveInputGetResponseJSON `json:"-"` -} - -// streamLiveInputGetResponseJSON contains the JSON metadata for the struct -// [StreamLiveInputGetResponse] -type streamLiveInputGetResponseJSON struct { - Created apijson.Field - DeleteRecordingAfterDays apijson.Field - Meta apijson.Field - Modified apijson.Field - Recording apijson.Field - Rtmps apijson.Field - RtmpsPlayback apijson.Field - Srt apijson.Field - SrtPlayback apijson.Field - Status apijson.Field - Uid apijson.Field - WebRtc apijson.Field - WebRtcPlayback apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputGetResponseJSON) RawJSON() string { - return r.raw -} - -// Records the input to a Cloudflare Stream video. Behavior depends on the mode. In -// most cases, the video will initially be viewable as a live video and transition -// to on-demand after a condition is satisfied. -type StreamLiveInputGetResponseRecording struct { - // Lists the origins allowed to display videos created with this input. Enter - // allowed origin domains in an array and use `*` for wildcard subdomains. An empty - // array allows videos to be viewed on any origin. - AllowedOrigins []string `json:"allowedOrigins"` - // Specifies the recording behavior for the live input. Set this value to `off` to - // prevent a recording. Set the value to `automatic` to begin a recording and - // transition to on-demand after Stream Live stops receiving input. - Mode StreamLiveInputGetResponseRecordingMode `json:"mode"` - // Indicates if a video using the live input has the `requireSignedURLs` property - // set. Also enforces access controls on any video recording of the livestream with - // the live input. - RequireSignedURLs bool `json:"requireSignedURLs"` - // Determines the amount of time a live input configured in `automatic` mode should - // wait before a recording transitions from live to on-demand. `0` is recommended - // for most use cases and indicates the platform default should be used. - TimeoutSeconds int64 `json:"timeoutSeconds"` - JSON streamLiveInputGetResponseRecordingJSON `json:"-"` -} - -// streamLiveInputGetResponseRecordingJSON contains the JSON metadata for the -// struct [StreamLiveInputGetResponseRecording] -type streamLiveInputGetResponseRecordingJSON struct { - AllowedOrigins apijson.Field - Mode apijson.Field - RequireSignedURLs apijson.Field - TimeoutSeconds apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputGetResponseRecording) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputGetResponseRecordingJSON) RawJSON() string { - return r.raw -} - -// Specifies the recording behavior for the live input. Set this value to `off` to -// prevent a recording. Set the value to `automatic` to begin a recording and -// transition to on-demand after Stream Live stops receiving input. -type StreamLiveInputGetResponseRecordingMode string - -const ( - StreamLiveInputGetResponseRecordingModeOff StreamLiveInputGetResponseRecordingMode = "off" - StreamLiveInputGetResponseRecordingModeAutomatic StreamLiveInputGetResponseRecordingMode = "automatic" -) - -// Details for streaming to an live input using RTMPS. -type StreamLiveInputGetResponseRtmps struct { - // The secret key to use when streaming via RTMPS to a live input. - StreamKey string `json:"streamKey"` - // The RTMPS URL you provide to the broadcaster, which they stream live video to. - URL string `json:"url"` - JSON streamLiveInputGetResponseRtmpsJSON `json:"-"` -} - -// streamLiveInputGetResponseRtmpsJSON contains the JSON metadata for the struct -// [StreamLiveInputGetResponseRtmps] -type streamLiveInputGetResponseRtmpsJSON struct { - StreamKey apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputGetResponseRtmps) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputGetResponseRtmpsJSON) RawJSON() string { - return r.raw -} - -// Details for playback from an live input using RTMPS. -type StreamLiveInputGetResponseRtmpsPlayback struct { - // The secret key to use for playback via RTMPS. - StreamKey string `json:"streamKey"` - // The URL used to play live video over RTMPS. - URL string `json:"url"` - JSON streamLiveInputGetResponseRtmpsPlaybackJSON `json:"-"` -} - -// streamLiveInputGetResponseRtmpsPlaybackJSON contains the JSON metadata for the -// struct [StreamLiveInputGetResponseRtmpsPlayback] -type streamLiveInputGetResponseRtmpsPlaybackJSON struct { - StreamKey apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputGetResponseRtmpsPlayback) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputGetResponseRtmpsPlaybackJSON) RawJSON() string { - return r.raw -} - -// Details for streaming to a live input using SRT. -type StreamLiveInputGetResponseSrt struct { - // The secret key to use when streaming via SRT to a live input. - Passphrase string `json:"passphrase"` - // The identifier of the live input to use when streaming via SRT. - StreamID string `json:"streamId"` - // The SRT URL you provide to the broadcaster, which they stream live video to. - URL string `json:"url"` - JSON streamLiveInputGetResponseSrtJSON `json:"-"` -} - -// streamLiveInputGetResponseSrtJSON contains the JSON metadata for the struct -// [StreamLiveInputGetResponseSrt] -type streamLiveInputGetResponseSrtJSON struct { - Passphrase apijson.Field - StreamID apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputGetResponseSrt) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputGetResponseSrtJSON) RawJSON() string { - return r.raw -} - -// Details for playback from an live input using SRT. -type StreamLiveInputGetResponseSrtPlayback struct { - // The secret key to use for playback via SRT. - Passphrase string `json:"passphrase"` - // The identifier of the live input to use for playback via SRT. - StreamID string `json:"streamId"` - // The URL used to play live video over SRT. - URL string `json:"url"` - JSON streamLiveInputGetResponseSrtPlaybackJSON `json:"-"` -} - -// streamLiveInputGetResponseSrtPlaybackJSON contains the JSON metadata for the -// struct [StreamLiveInputGetResponseSrtPlayback] -type streamLiveInputGetResponseSrtPlaybackJSON struct { - Passphrase apijson.Field - StreamID apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputGetResponseSrtPlayback) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputGetResponseSrtPlaybackJSON) RawJSON() string { - return r.raw -} - -// The connection status of a live input. -type StreamLiveInputGetResponseStatus string - -const ( - StreamLiveInputGetResponseStatusConnected StreamLiveInputGetResponseStatus = "connected" - StreamLiveInputGetResponseStatusReconnected StreamLiveInputGetResponseStatus = "reconnected" - StreamLiveInputGetResponseStatusReconnecting StreamLiveInputGetResponseStatus = "reconnecting" - StreamLiveInputGetResponseStatusClientDisconnect StreamLiveInputGetResponseStatus = "client_disconnect" - StreamLiveInputGetResponseStatusTTLExceeded StreamLiveInputGetResponseStatus = "ttl_exceeded" - StreamLiveInputGetResponseStatusFailedToConnect StreamLiveInputGetResponseStatus = "failed_to_connect" - StreamLiveInputGetResponseStatusFailedToReconnect StreamLiveInputGetResponseStatus = "failed_to_reconnect" - StreamLiveInputGetResponseStatusNewConfigurationAccepted StreamLiveInputGetResponseStatus = "new_configuration_accepted" -) - -// Details for streaming to a live input using WebRTC. -type StreamLiveInputGetResponseWebRtc struct { - // The WebRTC URL you provide to the broadcaster, which they stream live video to. - URL string `json:"url"` - JSON streamLiveInputGetResponseWebRtcJSON `json:"-"` -} - -// streamLiveInputGetResponseWebRtcJSON contains the JSON metadata for the struct -// [StreamLiveInputGetResponseWebRtc] -type streamLiveInputGetResponseWebRtcJSON struct { - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputGetResponseWebRtc) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputGetResponseWebRtcJSON) RawJSON() string { - return r.raw -} - -// Details for playback from a live input using WebRTC. -type StreamLiveInputGetResponseWebRtcPlayback struct { - // The URL used to play live video over WebRTC. - URL string `json:"url"` - JSON streamLiveInputGetResponseWebRtcPlaybackJSON `json:"-"` -} - -// streamLiveInputGetResponseWebRtcPlaybackJSON contains the JSON metadata for the -// struct [StreamLiveInputGetResponseWebRtcPlayback] -type streamLiveInputGetResponseWebRtcPlaybackJSON struct { - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputGetResponseWebRtcPlayback) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputGetResponseWebRtcPlaybackJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Sets the creator ID asssociated with this live input. - DefaultCreator param.Field[string] `json:"defaultCreator"` - // Indicates the number of days after which the live inputs recordings will be - // deleted. When a stream completes and the recording is ready, the value is used - // to calculate a scheduled deletion date for that recording. Omit the field to - // indicate no change, or include with a `null` value to remove an existing - // scheduled deletion. - DeleteRecordingAfterDays param.Field[float64] `json:"deleteRecordingAfterDays"` - // A user modifiable key-value store used to reference other systems of record for - // managing live inputs. - Meta param.Field[interface{}] `json:"meta"` - // Records the input to a Cloudflare Stream video. Behavior depends on the mode. In - // most cases, the video will initially be viewable as a live video and transition - // to on-demand after a condition is satisfied. - Recording param.Field[StreamLiveInputNewParamsRecording] `json:"recording"` -} - -func (r StreamLiveInputNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Records the input to a Cloudflare Stream video. Behavior depends on the mode. In -// most cases, the video will initially be viewable as a live video and transition -// to on-demand after a condition is satisfied. -type StreamLiveInputNewParamsRecording struct { - // Lists the origins allowed to display videos created with this input. Enter - // allowed origin domains in an array and use `*` for wildcard subdomains. An empty - // array allows videos to be viewed on any origin. - AllowedOrigins param.Field[[]string] `json:"allowedOrigins"` - // Specifies the recording behavior for the live input. Set this value to `off` to - // prevent a recording. Set the value to `automatic` to begin a recording and - // transition to on-demand after Stream Live stops receiving input. - Mode param.Field[StreamLiveInputNewParamsRecordingMode] `json:"mode"` - // Indicates if a video using the live input has the `requireSignedURLs` property - // set. Also enforces access controls on any video recording of the livestream with - // the live input. - RequireSignedURLs param.Field[bool] `json:"requireSignedURLs"` - // Determines the amount of time a live input configured in `automatic` mode should - // wait before a recording transitions from live to on-demand. `0` is recommended - // for most use cases and indicates the platform default should be used. - TimeoutSeconds param.Field[int64] `json:"timeoutSeconds"` -} - -func (r StreamLiveInputNewParamsRecording) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Specifies the recording behavior for the live input. Set this value to `off` to -// prevent a recording. Set the value to `automatic` to begin a recording and -// transition to on-demand after Stream Live stops receiving input. -type StreamLiveInputNewParamsRecordingMode string - -const ( - StreamLiveInputNewParamsRecordingModeOff StreamLiveInputNewParamsRecordingMode = "off" - StreamLiveInputNewParamsRecordingModeAutomatic StreamLiveInputNewParamsRecordingMode = "automatic" -) - -type StreamLiveInputNewResponseEnvelope struct { - Errors []StreamLiveInputNewResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamLiveInputNewResponseEnvelopeMessages `json:"messages,required"` - // Details about a live input. - Result StreamLiveInputNewResponse `json:"result,required"` - // Whether the API call was successful - Success StreamLiveInputNewResponseEnvelopeSuccess `json:"success,required"` - JSON streamLiveInputNewResponseEnvelopeJSON `json:"-"` -} - -// streamLiveInputNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [StreamLiveInputNewResponseEnvelope] -type streamLiveInputNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamLiveInputNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamLiveInputNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamLiveInputNewResponseEnvelopeErrors] -type streamLiveInputNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamLiveInputNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamLiveInputNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [StreamLiveInputNewResponseEnvelopeMessages] -type streamLiveInputNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamLiveInputNewResponseEnvelopeSuccess bool - -const ( - StreamLiveInputNewResponseEnvelopeSuccessTrue StreamLiveInputNewResponseEnvelopeSuccess = true -) - -type StreamLiveInputUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Sets the creator ID asssociated with this live input. - DefaultCreator param.Field[string] `json:"defaultCreator"` - // Indicates the number of days after which the live inputs recordings will be - // deleted. When a stream completes and the recording is ready, the value is used - // to calculate a scheduled deletion date for that recording. Omit the field to - // indicate no change, or include with a `null` value to remove an existing - // scheduled deletion. - DeleteRecordingAfterDays param.Field[float64] `json:"deleteRecordingAfterDays"` - // A user modifiable key-value store used to reference other systems of record for - // managing live inputs. - Meta param.Field[interface{}] `json:"meta"` - // Records the input to a Cloudflare Stream video. Behavior depends on the mode. In - // most cases, the video will initially be viewable as a live video and transition - // to on-demand after a condition is satisfied. - Recording param.Field[StreamLiveInputUpdateParamsRecording] `json:"recording"` -} - -func (r StreamLiveInputUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Records the input to a Cloudflare Stream video. Behavior depends on the mode. In -// most cases, the video will initially be viewable as a live video and transition -// to on-demand after a condition is satisfied. -type StreamLiveInputUpdateParamsRecording struct { - // Lists the origins allowed to display videos created with this input. Enter - // allowed origin domains in an array and use `*` for wildcard subdomains. An empty - // array allows videos to be viewed on any origin. - AllowedOrigins param.Field[[]string] `json:"allowedOrigins"` - // Specifies the recording behavior for the live input. Set this value to `off` to - // prevent a recording. Set the value to `automatic` to begin a recording and - // transition to on-demand after Stream Live stops receiving input. - Mode param.Field[StreamLiveInputUpdateParamsRecordingMode] `json:"mode"` - // Indicates if a video using the live input has the `requireSignedURLs` property - // set. Also enforces access controls on any video recording of the livestream with - // the live input. - RequireSignedURLs param.Field[bool] `json:"requireSignedURLs"` - // Determines the amount of time a live input configured in `automatic` mode should - // wait before a recording transitions from live to on-demand. `0` is recommended - // for most use cases and indicates the platform default should be used. - TimeoutSeconds param.Field[int64] `json:"timeoutSeconds"` -} - -func (r StreamLiveInputUpdateParamsRecording) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Specifies the recording behavior for the live input. Set this value to `off` to -// prevent a recording. Set the value to `automatic` to begin a recording and -// transition to on-demand after Stream Live stops receiving input. -type StreamLiveInputUpdateParamsRecordingMode string - -const ( - StreamLiveInputUpdateParamsRecordingModeOff StreamLiveInputUpdateParamsRecordingMode = "off" - StreamLiveInputUpdateParamsRecordingModeAutomatic StreamLiveInputUpdateParamsRecordingMode = "automatic" -) - -type StreamLiveInputUpdateResponseEnvelope struct { - Errors []StreamLiveInputUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamLiveInputUpdateResponseEnvelopeMessages `json:"messages,required"` - // Details about a live input. - Result StreamLiveInputUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success StreamLiveInputUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON streamLiveInputUpdateResponseEnvelopeJSON `json:"-"` -} - -// streamLiveInputUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [StreamLiveInputUpdateResponseEnvelope] -type streamLiveInputUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamLiveInputUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamLiveInputUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [StreamLiveInputUpdateResponseEnvelopeErrors] -type streamLiveInputUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamLiveInputUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamLiveInputUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [StreamLiveInputUpdateResponseEnvelopeMessages] -type streamLiveInputUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamLiveInputUpdateResponseEnvelopeSuccess bool - -const ( - StreamLiveInputUpdateResponseEnvelopeSuccessTrue StreamLiveInputUpdateResponseEnvelopeSuccess = true -) - -type StreamLiveInputListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Includes the total number of videos associated with the submitted query - // parameters. - IncludeCounts param.Field[bool] `query:"include_counts"` -} - -// URLQuery serializes [StreamLiveInputListParams]'s query parameters as -// `url.Values`. -func (r StreamLiveInputListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type StreamLiveInputListResponseEnvelope struct { - Errors []StreamLiveInputListResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamLiveInputListResponseEnvelopeMessages `json:"messages,required"` - Result StreamLiveInputListResponse `json:"result,required"` - // Whether the API call was successful - Success StreamLiveInputListResponseEnvelopeSuccess `json:"success,required"` - JSON streamLiveInputListResponseEnvelopeJSON `json:"-"` -} - -// streamLiveInputListResponseEnvelopeJSON contains the JSON metadata for the -// struct [StreamLiveInputListResponseEnvelope] -type streamLiveInputListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamLiveInputListResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamLiveInputListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamLiveInputListResponseEnvelopeErrors] -type streamLiveInputListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamLiveInputListResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamLiveInputListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [StreamLiveInputListResponseEnvelopeMessages] -type streamLiveInputListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamLiveInputListResponseEnvelopeSuccess bool - -const ( - StreamLiveInputListResponseEnvelopeSuccessTrue StreamLiveInputListResponseEnvelopeSuccess = true -) - -type StreamLiveInputDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamLiveInputGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamLiveInputGetResponseEnvelope struct { - Errors []StreamLiveInputGetResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamLiveInputGetResponseEnvelopeMessages `json:"messages,required"` - // Details about a live input. - Result StreamLiveInputGetResponse `json:"result,required"` - // Whether the API call was successful - Success StreamLiveInputGetResponseEnvelopeSuccess `json:"success,required"` - JSON streamLiveInputGetResponseEnvelopeJSON `json:"-"` -} - -// streamLiveInputGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [StreamLiveInputGetResponseEnvelope] -type streamLiveInputGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamLiveInputGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamLiveInputGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamLiveInputGetResponseEnvelopeErrors] -type streamLiveInputGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamLiveInputGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamLiveInputGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [StreamLiveInputGetResponseEnvelopeMessages] -type streamLiveInputGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamLiveInputGetResponseEnvelopeSuccess bool - -const ( - StreamLiveInputGetResponseEnvelopeSuccessTrue StreamLiveInputGetResponseEnvelopeSuccess = true -) diff --git a/streamliveinput_test.go b/streamliveinput_test.go deleted file mode 100644 index 72b9673d942..00000000000 --- a/streamliveinput_test.go +++ /dev/null @@ -1,179 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestStreamLiveInputNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Stream.LiveInputs.New(context.TODO(), cloudflare.StreamLiveInputNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - DefaultCreator: cloudflare.F("string"), - DeleteRecordingAfterDays: cloudflare.F(45.000000), - Meta: cloudflare.F[any](map[string]interface{}{ - "name": "test stream 1", - }), - Recording: cloudflare.F(cloudflare.StreamLiveInputNewParamsRecording{ - AllowedOrigins: cloudflare.F([]string{"example.com"}), - Mode: cloudflare.F(cloudflare.StreamLiveInputNewParamsRecordingModeOff), - RequireSignedURLs: cloudflare.F(false), - TimeoutSeconds: cloudflare.F(int64(0)), - }), - }) - 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 TestStreamLiveInputUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Stream.LiveInputs.Update( - context.TODO(), - "66be4bf738797e01e1fca35a7bdecdcd", - cloudflare.StreamLiveInputUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - DefaultCreator: cloudflare.F("string"), - DeleteRecordingAfterDays: cloudflare.F(45.000000), - Meta: cloudflare.F[any](map[string]interface{}{ - "name": "test stream 1", - }), - Recording: cloudflare.F(cloudflare.StreamLiveInputUpdateParamsRecording{ - AllowedOrigins: cloudflare.F([]string{"example.com"}), - Mode: cloudflare.F(cloudflare.StreamLiveInputUpdateParamsRecordingModeOff), - RequireSignedURLs: cloudflare.F(false), - TimeoutSeconds: cloudflare.F(int64(0)), - }), - }, - ) - 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 TestStreamLiveInputListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Stream.LiveInputs.List(context.TODO(), cloudflare.StreamLiveInputListParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - IncludeCounts: cloudflare.F(true), - }) - 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 TestStreamLiveInputDelete(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("user@example.com"), - ) - err := client.Stream.LiveInputs.Delete( - context.TODO(), - "66be4bf738797e01e1fca35a7bdecdcd", - cloudflare.StreamLiveInputDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestStreamLiveInputGet(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("user@example.com"), - ) - _, err := client.Stream.LiveInputs.Get( - context.TODO(), - "66be4bf738797e01e1fca35a7bdecdcd", - cloudflare.StreamLiveInputGetParams{ - AccountID: cloudflare.F("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/streamliveinputoutput.go b/streamliveinputoutput.go deleted file mode 100644 index 2d2d6750286..00000000000 --- a/streamliveinputoutput.go +++ /dev/null @@ -1,474 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// StreamLiveInputOutputService 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 [NewStreamLiveInputOutputService] -// method instead. -type StreamLiveInputOutputService struct { - Options []option.RequestOption -} - -// NewStreamLiveInputOutputService 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 NewStreamLiveInputOutputService(opts ...option.RequestOption) (r *StreamLiveInputOutputService) { - r = &StreamLiveInputOutputService{} - r.Options = opts - return -} - -// Creates a new output that can be used to simulcast or restream live video to -// other RTMP or SRT destinations. Outputs are always linked to a specific live -// input — one live input can have many outputs. -func (r *StreamLiveInputOutputService) New(ctx context.Context, liveInputIdentifier string, params StreamLiveInputOutputNewParams, opts ...option.RequestOption) (res *StreamLiveInputOutputNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamLiveInputOutputNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s/outputs", params.AccountID, liveInputIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates the state of an output. -func (r *StreamLiveInputOutputService) Update(ctx context.Context, liveInputIdentifier string, outputIdentifier string, params StreamLiveInputOutputUpdateParams, opts ...option.RequestOption) (res *StreamLiveInputOutputUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamLiveInputOutputUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s/outputs/%s", params.AccountID, liveInputIdentifier, outputIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Retrieves all outputs associated with a specified live input. -func (r *StreamLiveInputOutputService) List(ctx context.Context, liveInputIdentifier string, query StreamLiveInputOutputListParams, opts ...option.RequestOption) (res *[]StreamLiveInputOutputListResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamLiveInputOutputListResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s/outputs", query.AccountID, liveInputIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes an output and removes it from the associated live input. -func (r *StreamLiveInputOutputService) Delete(ctx context.Context, liveInputIdentifier string, outputIdentifier string, body StreamLiveInputOutputDeleteParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := fmt.Sprintf("accounts/%s/stream/live_inputs/%s/outputs/%s", body.AccountID, liveInputIdentifier, outputIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) - return -} - -type StreamLiveInputOutputNewResponse struct { - // When enabled, live video streamed to the associated live input will be sent to - // the output URL. When disabled, live video will not be sent to the output URL, - // even when streaming to the associated live input. Use this to control precisely - // when you start and stop simulcasting to specific destinations like YouTube and - // Twitch. - Enabled bool `json:"enabled"` - // The streamKey used to authenticate against an output's target. - StreamKey string `json:"streamKey"` - // A unique identifier for the output. - Uid string `json:"uid"` - // The URL an output uses to restream. - URL string `json:"url"` - JSON streamLiveInputOutputNewResponseJSON `json:"-"` -} - -// streamLiveInputOutputNewResponseJSON contains the JSON metadata for the struct -// [StreamLiveInputOutputNewResponse] -type streamLiveInputOutputNewResponseJSON struct { - Enabled apijson.Field - StreamKey apijson.Field - Uid apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputOutputNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputOutputNewResponseJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputOutputUpdateResponse struct { - // When enabled, live video streamed to the associated live input will be sent to - // the output URL. When disabled, live video will not be sent to the output URL, - // even when streaming to the associated live input. Use this to control precisely - // when you start and stop simulcasting to specific destinations like YouTube and - // Twitch. - Enabled bool `json:"enabled"` - // The streamKey used to authenticate against an output's target. - StreamKey string `json:"streamKey"` - // A unique identifier for the output. - Uid string `json:"uid"` - // The URL an output uses to restream. - URL string `json:"url"` - JSON streamLiveInputOutputUpdateResponseJSON `json:"-"` -} - -// streamLiveInputOutputUpdateResponseJSON contains the JSON metadata for the -// struct [StreamLiveInputOutputUpdateResponse] -type streamLiveInputOutputUpdateResponseJSON struct { - Enabled apijson.Field - StreamKey apijson.Field - Uid apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputOutputUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputOutputUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputOutputListResponse struct { - // When enabled, live video streamed to the associated live input will be sent to - // the output URL. When disabled, live video will not be sent to the output URL, - // even when streaming to the associated live input. Use this to control precisely - // when you start and stop simulcasting to specific destinations like YouTube and - // Twitch. - Enabled bool `json:"enabled"` - // The streamKey used to authenticate against an output's target. - StreamKey string `json:"streamKey"` - // A unique identifier for the output. - Uid string `json:"uid"` - // The URL an output uses to restream. - URL string `json:"url"` - JSON streamLiveInputOutputListResponseJSON `json:"-"` -} - -// streamLiveInputOutputListResponseJSON contains the JSON metadata for the struct -// [StreamLiveInputOutputListResponse] -type streamLiveInputOutputListResponseJSON struct { - Enabled apijson.Field - StreamKey apijson.Field - Uid apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputOutputListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputOutputListResponseJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputOutputNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The streamKey used to authenticate against an output's target. - StreamKey param.Field[string] `json:"streamKey,required"` - // The URL an output uses to restream. - URL param.Field[string] `json:"url,required"` - // When enabled, live video streamed to the associated live input will be sent to - // the output URL. When disabled, live video will not be sent to the output URL, - // even when streaming to the associated live input. Use this to control precisely - // when you start and stop simulcasting to specific destinations like YouTube and - // Twitch. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r StreamLiveInputOutputNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type StreamLiveInputOutputNewResponseEnvelope struct { - Errors []StreamLiveInputOutputNewResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamLiveInputOutputNewResponseEnvelopeMessages `json:"messages,required"` - Result StreamLiveInputOutputNewResponse `json:"result,required"` - // Whether the API call was successful - Success StreamLiveInputOutputNewResponseEnvelopeSuccess `json:"success,required"` - JSON streamLiveInputOutputNewResponseEnvelopeJSON `json:"-"` -} - -// streamLiveInputOutputNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [StreamLiveInputOutputNewResponseEnvelope] -type streamLiveInputOutputNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputOutputNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputOutputNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputOutputNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamLiveInputOutputNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamLiveInputOutputNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [StreamLiveInputOutputNewResponseEnvelopeErrors] -type streamLiveInputOutputNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputOutputNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputOutputNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputOutputNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamLiveInputOutputNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamLiveInputOutputNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [StreamLiveInputOutputNewResponseEnvelopeMessages] -type streamLiveInputOutputNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputOutputNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputOutputNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamLiveInputOutputNewResponseEnvelopeSuccess bool - -const ( - StreamLiveInputOutputNewResponseEnvelopeSuccessTrue StreamLiveInputOutputNewResponseEnvelopeSuccess = true -) - -type StreamLiveInputOutputUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // When enabled, live video streamed to the associated live input will be sent to - // the output URL. When disabled, live video will not be sent to the output URL, - // even when streaming to the associated live input. Use this to control precisely - // when you start and stop simulcasting to specific destinations like YouTube and - // Twitch. - Enabled param.Field[bool] `json:"enabled,required"` -} - -func (r StreamLiveInputOutputUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type StreamLiveInputOutputUpdateResponseEnvelope struct { - Errors []StreamLiveInputOutputUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamLiveInputOutputUpdateResponseEnvelopeMessages `json:"messages,required"` - Result StreamLiveInputOutputUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success StreamLiveInputOutputUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON streamLiveInputOutputUpdateResponseEnvelopeJSON `json:"-"` -} - -// streamLiveInputOutputUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [StreamLiveInputOutputUpdateResponseEnvelope] -type streamLiveInputOutputUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputOutputUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputOutputUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputOutputUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamLiveInputOutputUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamLiveInputOutputUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [StreamLiveInputOutputUpdateResponseEnvelopeErrors] -type streamLiveInputOutputUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputOutputUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputOutputUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputOutputUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamLiveInputOutputUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamLiveInputOutputUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [StreamLiveInputOutputUpdateResponseEnvelopeMessages] -type streamLiveInputOutputUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputOutputUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputOutputUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamLiveInputOutputUpdateResponseEnvelopeSuccess bool - -const ( - StreamLiveInputOutputUpdateResponseEnvelopeSuccessTrue StreamLiveInputOutputUpdateResponseEnvelopeSuccess = true -) - -type StreamLiveInputOutputListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamLiveInputOutputListResponseEnvelope struct { - Errors []StreamLiveInputOutputListResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamLiveInputOutputListResponseEnvelopeMessages `json:"messages,required"` - Result []StreamLiveInputOutputListResponse `json:"result,required"` - // Whether the API call was successful - Success StreamLiveInputOutputListResponseEnvelopeSuccess `json:"success,required"` - JSON streamLiveInputOutputListResponseEnvelopeJSON `json:"-"` -} - -// streamLiveInputOutputListResponseEnvelopeJSON contains the JSON metadata for the -// struct [StreamLiveInputOutputListResponseEnvelope] -type streamLiveInputOutputListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputOutputListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputOutputListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputOutputListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamLiveInputOutputListResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamLiveInputOutputListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [StreamLiveInputOutputListResponseEnvelopeErrors] -type streamLiveInputOutputListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputOutputListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputOutputListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamLiveInputOutputListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamLiveInputOutputListResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamLiveInputOutputListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [StreamLiveInputOutputListResponseEnvelopeMessages] -type streamLiveInputOutputListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamLiveInputOutputListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamLiveInputOutputListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamLiveInputOutputListResponseEnvelopeSuccess bool - -const ( - StreamLiveInputOutputListResponseEnvelopeSuccessTrue StreamLiveInputOutputListResponseEnvelopeSuccess = true -) - -type StreamLiveInputOutputDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} diff --git a/streamliveinputoutput_test.go b/streamliveinputoutput_test.go deleted file mode 100644 index 49b4964a840..00000000000 --- a/streamliveinputoutput_test.go +++ /dev/null @@ -1,140 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestStreamLiveInputOutputNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Stream.LiveInputs.Outputs.New( - context.TODO(), - "66be4bf738797e01e1fca35a7bdecdcd", - cloudflare.StreamLiveInputOutputNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - StreamKey: cloudflare.F("uzya-f19y-g2g9-a2ee-51j2"), - URL: cloudflare.F("rtmp://a.rtmp.youtube.com/live2"), - Enabled: cloudflare.F(true), - }, - ) - 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 TestStreamLiveInputOutputUpdate(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("user@example.com"), - ) - _, err := client.Stream.LiveInputs.Outputs.Update( - context.TODO(), - "66be4bf738797e01e1fca35a7bdecdcd", - "baea4d9c515887b80289d5c33cf01145", - cloudflare.StreamLiveInputOutputUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Enabled: cloudflare.F(true), - }, - ) - 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 TestStreamLiveInputOutputList(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("user@example.com"), - ) - _, err := client.Stream.LiveInputs.Outputs.List( - context.TODO(), - "66be4bf738797e01e1fca35a7bdecdcd", - cloudflare.StreamLiveInputOutputListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestStreamLiveInputOutputDelete(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("user@example.com"), - ) - err := client.Stream.LiveInputs.Outputs.Delete( - context.TODO(), - "66be4bf738797e01e1fca35a7bdecdcd", - "baea4d9c515887b80289d5c33cf01145", - cloudflare.StreamLiveInputOutputDeleteParams{ - AccountID: cloudflare.F("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/streamtoken.go b/streamtoken.go deleted file mode 100644 index 82ace9d60d6..00000000000 --- a/streamtoken.go +++ /dev/null @@ -1,222 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// StreamTokenService 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 [NewStreamTokenService] method -// instead. -type StreamTokenService struct { - Options []option.RequestOption -} - -// NewStreamTokenService 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 NewStreamTokenService(opts ...option.RequestOption) (r *StreamTokenService) { - r = &StreamTokenService{} - r.Options = opts - return -} - -// Creates a signed URL token for a video. If a body is not provided in the -// request, a token is created with default values. -func (r *StreamTokenService) New(ctx context.Context, identifier string, params StreamTokenNewParams, opts ...option.RequestOption) (res *StreamTokenNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamTokenNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/%s/token", params.AccountID, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type StreamTokenNewResponse struct { - // The signed token used with the signed URLs feature. - Token string `json:"token"` - JSON streamTokenNewResponseJSON `json:"-"` -} - -// streamTokenNewResponseJSON contains the JSON metadata for the struct -// [StreamTokenNewResponse] -type streamTokenNewResponseJSON struct { - Token apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamTokenNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamTokenNewResponseJSON) RawJSON() string { - return r.raw -} - -type StreamTokenNewParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // The optional ID of a Stream signing key. If present, the `pem` field is also - // required. - ID param.Field[string] `json:"id"` - // The optional list of access rule constraints on the token. Access can be blocked - // or allowed based on an IP, IP range, or by country. Access rules are evaluated - // from first to last. If a rule matches, the associated action is applied and no - // further rules are evaluated. - AccessRules param.Field[[]StreamTokenNewParamsAccessRule] `json:"accessRules"` - // The optional boolean value that enables using signed tokens to access MP4 - // download links for a video. - Downloadable param.Field[bool] `json:"downloadable"` - // The optional unix epoch timestamp that specficies the time after a token is not - // accepted. The maximum time specification is 24 hours from issuing time. If this - // field is not set, the default is one hour after issuing. - Exp param.Field[int64] `json:"exp"` - // The optional unix epoch timestamp that specifies the time before a the token is - // not accepted. If this field is not set, the default is one hour before issuing. - Nbf param.Field[int64] `json:"nbf"` - // The optional base64 encoded private key in PEM format associated with a Stream - // signing key. If present, the `id` field is also required. - Pem param.Field[string] `json:"pem"` -} - -func (r StreamTokenNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Defines rules for fine-grained control over content than signed URL tokens -// alone. Access rules primarily make tokens conditionally valid based on user -// information. Access Rules are specified on token payloads as the `accessRules` -// property containing an array of Rule objects. -type StreamTokenNewParamsAccessRule struct { - // The action to take when a request matches a rule. If the action is `block`, the - // signed token blocks views for viewers matching the rule. - Action param.Field[StreamTokenNewParamsAccessRulesAction] `json:"action"` - // An array of 2-letter country codes in ISO 3166-1 Alpha-2 format used to match - // requests. - Country param.Field[[]string] `json:"country"` - // An array of IPv4 or IPV6 addresses or CIDRs used to match requests. - IP param.Field[[]string] `json:"ip"` - // Lists available rule types to match for requests. An `any` type matches all - // requests and can be used as a wildcard to apply default actions after other - // rules. - Type param.Field[StreamTokenNewParamsAccessRulesType] `json:"type"` -} - -func (r StreamTokenNewParamsAccessRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The action to take when a request matches a rule. If the action is `block`, the -// signed token blocks views for viewers matching the rule. -type StreamTokenNewParamsAccessRulesAction string - -const ( - StreamTokenNewParamsAccessRulesActionAllow StreamTokenNewParamsAccessRulesAction = "allow" - StreamTokenNewParamsAccessRulesActionBlock StreamTokenNewParamsAccessRulesAction = "block" -) - -// Lists available rule types to match for requests. An `any` type matches all -// requests and can be used as a wildcard to apply default actions after other -// rules. -type StreamTokenNewParamsAccessRulesType string - -const ( - StreamTokenNewParamsAccessRulesTypeAny StreamTokenNewParamsAccessRulesType = "any" - StreamTokenNewParamsAccessRulesTypeIPSrc StreamTokenNewParamsAccessRulesType = "ip.src" - StreamTokenNewParamsAccessRulesTypeIPGeoipCountry StreamTokenNewParamsAccessRulesType = "ip.geoip.country" -) - -type StreamTokenNewResponseEnvelope struct { - Errors []StreamTokenNewResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamTokenNewResponseEnvelopeMessages `json:"messages,required"` - Result StreamTokenNewResponse `json:"result,required"` - // Whether the API call was successful - Success StreamTokenNewResponseEnvelopeSuccess `json:"success,required"` - JSON streamTokenNewResponseEnvelopeJSON `json:"-"` -} - -// streamTokenNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [StreamTokenNewResponseEnvelope] -type streamTokenNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamTokenNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamTokenNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamTokenNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamTokenNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamTokenNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamTokenNewResponseEnvelopeErrors] -type streamTokenNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamTokenNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamTokenNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamTokenNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamTokenNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamTokenNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [StreamTokenNewResponseEnvelopeMessages] -type streamTokenNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamTokenNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamTokenNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamTokenNewResponseEnvelopeSuccess bool - -const ( - StreamTokenNewResponseEnvelopeSuccessTrue StreamTokenNewResponseEnvelopeSuccess = true -) diff --git a/streamtoken_test.go b/streamtoken_test.go deleted file mode 100644 index ea03158a066..00000000000 --- a/streamtoken_test.go +++ /dev/null @@ -1,65 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestStreamTokenNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Stream.Tokens.New( - context.TODO(), - "ea95132c15732412d22c1476fa83f27a", - cloudflare.StreamTokenNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - ID: cloudflare.F("ab0d4ef71g4425f8dcba9041231813000"), - AccessRules: cloudflare.F([]cloudflare.StreamTokenNewParamsAccessRule{{ - Action: cloudflare.F(cloudflare.StreamTokenNewParamsAccessRulesActionBlock), - Country: cloudflare.F([]string{"US", "MX"}), - IP: cloudflare.F([]string{"string", "string", "string"}), - Type: cloudflare.F(cloudflare.StreamTokenNewParamsAccessRulesTypeIPGeoipCountry), - }, { - Action: cloudflare.F(cloudflare.StreamTokenNewParamsAccessRulesActionAllow), - Country: cloudflare.F([]string{"string", "string", "string"}), - IP: cloudflare.F([]string{"93.184.216.0/24", "2400:cb00::/32"}), - Type: cloudflare.F(cloudflare.StreamTokenNewParamsAccessRulesTypeIPSrc), - }, { - Action: cloudflare.F(cloudflare.StreamTokenNewParamsAccessRulesActionBlock), - Country: cloudflare.F([]string{"string", "string", "string"}), - IP: cloudflare.F([]string{"string", "string", "string"}), - Type: cloudflare.F(cloudflare.StreamTokenNewParamsAccessRulesTypeAny), - }}), - Downloadable: cloudflare.F(true), - Exp: cloudflare.F(int64(0)), - Nbf: cloudflare.F(int64(0)), - Pem: cloudflare.F("LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlFcEFJQkFBS0NBUUVBc284dnBvOFpEWXRkOUgzbWlPaW1qYXAzVXlVM0oyZ3kwTUYvN1R4blJuRnkwRHpDCkxqUk9naFZsQ0hPQmxsd3NVaE9GU0lyYnN4K05tUTdBeS90TFpXSGxuVGF3UWJ5WGZGOStJeDhVSnNlSHBGV1oKNVF5Z1JYd2liSjh1MVVsZ2xlcmZHMkpueldjVXpZTzEySktZN3doSkw1ajROMWgxZFJNUXQ5Q1pkZFlCQWRzOQpCdk02cjRFMDcxQkhQekhWeDMrUTI1VWtubGdUNXIwS3FiM1E1Y0dlTlBXY1JreW1ybkJEWWR0OXR4eFFMb1dPCllzNXdsMnVYWFVYL0VGcDMwajU0Nmp6czllWExLYlNDbjJjTDZFVE96Y2x3aG9DRGx2a2VQT05rUE9LMDVKNUMKTm1TdFdhMG9hV1VGRzM0MFl3cVVrWGt4OU9tNndXd1JldU1uU1FJREFRQUJBb0lCQUFJOHo1ck5kOEdtOGJBMgo1S3pxQjI1R2lOVENwbUNJeW53NXRJWHZTQmNHcEdydUcvdlN2WG9kVlFVSVY0TWdHQkVXUEFrVzdsNWVBcHI4CnA1ZFd5SkRXYTNkdklFSE9vSEpYU3dBYksxZzZEMTNVa2NkZ1EyRGpoNVhuWDhHZCtBY2c2SmRTQWgxOWtYSHEKMk54RUtBVDB6Ri83a1g2MkRkREFBcWxmQkpGSXJodVIvZUdEVWh4L2piTTRhQ2JCcFdiM0pnRE9OYm5tS1ZoMwpxS2ZwZmRZZENZU1lzWUxrNTlxRDF2VFNwUVFUQ0VadW9VKzNzRVNhdkJzaUs1bU0vTzY5ZkRMRXNURG1MeTVQCmhEK3BMQXI0SlhNNjFwRGVBS0l3cUVqWWJybXlDRHRXTUdJNnZzZ0E1eXQzUUJaME9vV2w5QUkwdWxoZ3p4dXQKZ2ZFNTRRRUNnWUVBN0F3a0lhVEEzYmQ4Nk9jSVZnNFlrWGk1cm5aNDdsM1k4V24zcjIzUmVISXhLdkllRUtSbgp5bUlFNDFtRVBBSmlGWFpLK1VPTXdkeS9EcnFJUithT1JiT2NiV01jWUg2QzgvbG1wdVJFaXE3SW1Ub3VWcnA4CnlnUkprMWprVDA4cTIvNmg4eTBEdjJqMitsaHFXNzRNOUt0cmwxcTRlWmZRUFREL01tR1NnTWtDZ1lFQXdhY04KaSttN1p6dnJtL3NuekF2VlZ5SEtwZHVUUjNERk1naC9maC9tZ0ZHZ1RwZWtUOVV5b3FleGNYQXdwMVlhL01iQQoyNTVJVDZRbXZZTm5yNXp6Wmxic2tMV0hsYllvbWhmWnVXTHhXR3hRaEFORWdaMFVVdUVTRGMvbWx2UXZHbEtSCkZoaGhBUWlVSmdDamhPaHk1SlBiNGFldGRKd0UxK09lVWRFaE1vRUNnWUVBNG8yZ25CM1o4ck5xa3NzemlBek4KYmNuMlJVbDJOaW9pejBwS3JMaDFaT29NNE5BekpQdjJsaHRQMzdtS0htS1hLMHczRjFqTEgwSTBxZmxFVmVZbQpSU1huakdHazJjUnpBYUVzOGgrQzNheDE0Z01pZUtGU3BqNUpNOEFNbVVZOXQ1cUVhN2FYc3o0V1ZoOUlMYmVTCkRiNzlhKzVwd21LQVBrcnBsTHhyZFdrQ2dZQlNNSHVBWVdBbmJYZ1BDS2FZWklGVWJNUWNacmY0ZnpWQ2lmYksKYWZHampvRlNPZXdEOGdGK3BWdWJRTGwxbkFieU44ek1xVDRaaHhybUhpcFlqMjJDaHV2NmN3RXJtbGRiSnpwQwpBMnRaVXdkTk1ESFlMUG5lUHlZeGRJWnlsUXFVeW14SGkydElUQUxNcWtLOGV3ZWdXZHpkeGhQSlJScU5JazhrCmZIVHhnUUtCZ1FEUFc2UXIxY3F3QjNUdnVWdWR4WGRqUTdIcDFodXhrNEVWaEFJZllKNFhSTW1NUE5YS28wdHUKdUt6LzE0QW14R0dvSWJxYVc1bDMzeFNteUxhem84clNUN0tSTjVKME9JSHcrZkR5SFgxdHpVSjZCTldDcEFTcwpjbWdNK0htSzVON0w2bkNaZFJQY2IwU1hGaVRQUGhCUG1PVWFDUnpER0ZMK2JYM1VwajJKbWc9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo="), - }, - ) - 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/streamvideo.go b/streamvideo.go deleted file mode 100644 index 65f3dd0ec5a..00000000000 --- a/streamvideo.go +++ /dev/null @@ -1,175 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// StreamVideoService 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 [NewStreamVideoService] method -// instead. -type StreamVideoService struct { - Options []option.RequestOption -} - -// NewStreamVideoService 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 NewStreamVideoService(opts ...option.RequestOption) (r *StreamVideoService) { - r = &StreamVideoService{} - r.Options = opts - return -} - -// Returns information about an account's storage use. -func (r *StreamVideoService) StorageUsage(ctx context.Context, params StreamVideoStorageUsageParams, opts ...option.RequestOption) (res *StreamVideoStorageUsageResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamVideoStorageUsageResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/storage-usage", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type StreamVideoStorageUsageResponse struct { - // A user-defined identifier for the media creator. - Creator string `json:"creator"` - // The total minutes of video content stored in the account. - TotalStorageMinutes int64 `json:"totalStorageMinutes"` - // The storage capacity alloted for the account. - TotalStorageMinutesLimit int64 `json:"totalStorageMinutesLimit"` - // The total count of videos associated with the account. - VideoCount int64 `json:"videoCount"` - JSON streamVideoStorageUsageResponseJSON `json:"-"` -} - -// streamVideoStorageUsageResponseJSON contains the JSON metadata for the struct -// [StreamVideoStorageUsageResponse] -type streamVideoStorageUsageResponseJSON struct { - Creator apijson.Field - TotalStorageMinutes apijson.Field - TotalStorageMinutesLimit apijson.Field - VideoCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamVideoStorageUsageResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamVideoStorageUsageResponseJSON) RawJSON() string { - return r.raw -} - -type StreamVideoStorageUsageParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // A user-defined identifier for the media creator. - Creator param.Field[string] `query:"creator"` -} - -// URLQuery serializes [StreamVideoStorageUsageParams]'s query parameters as -// `url.Values`. -func (r StreamVideoStorageUsageParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type StreamVideoStorageUsageResponseEnvelope struct { - Errors []StreamVideoStorageUsageResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamVideoStorageUsageResponseEnvelopeMessages `json:"messages,required"` - Result StreamVideoStorageUsageResponse `json:"result,required"` - // Whether the API call was successful - Success StreamVideoStorageUsageResponseEnvelopeSuccess `json:"success,required"` - JSON streamVideoStorageUsageResponseEnvelopeJSON `json:"-"` -} - -// streamVideoStorageUsageResponseEnvelopeJSON contains the JSON metadata for the -// struct [StreamVideoStorageUsageResponseEnvelope] -type streamVideoStorageUsageResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamVideoStorageUsageResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamVideoStorageUsageResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamVideoStorageUsageResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamVideoStorageUsageResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamVideoStorageUsageResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [StreamVideoStorageUsageResponseEnvelopeErrors] -type streamVideoStorageUsageResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamVideoStorageUsageResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamVideoStorageUsageResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamVideoStorageUsageResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamVideoStorageUsageResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamVideoStorageUsageResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [StreamVideoStorageUsageResponseEnvelopeMessages] -type streamVideoStorageUsageResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamVideoStorageUsageResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamVideoStorageUsageResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamVideoStorageUsageResponseEnvelopeSuccess bool - -const ( - StreamVideoStorageUsageResponseEnvelopeSuccessTrue StreamVideoStorageUsageResponseEnvelopeSuccess = true -) diff --git a/streamvideo_test.go b/streamvideo_test.go deleted file mode 100644 index 1fd299b7640..00000000000 --- a/streamvideo_test.go +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestStreamVideoStorageUsageWithOptionalParams(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("user@example.com"), - ) - _, err := client.Stream.Videos.StorageUsage(context.TODO(), cloudflare.StreamVideoStorageUsageParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Creator: cloudflare.F("creator-id_abcde12345"), - }) - 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/streamwatermark.go b/streamwatermark.go deleted file mode 100644 index 343c17373a0..00000000000 --- a/streamwatermark.go +++ /dev/null @@ -1,569 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// StreamWatermarkService 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 [NewStreamWatermarkService] method -// instead. -type StreamWatermarkService struct { - Options []option.RequestOption -} - -// NewStreamWatermarkService 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 NewStreamWatermarkService(opts ...option.RequestOption) (r *StreamWatermarkService) { - r = &StreamWatermarkService{} - r.Options = opts - return -} - -// Creates watermark profiles using a single `HTTP POST multipart/form-data` -// request. -func (r *StreamWatermarkService) New(ctx context.Context, params StreamWatermarkNewParams, opts ...option.RequestOption) (res *StreamWatermarkNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamWatermarkNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/watermarks", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists all watermark profiles for an account. -func (r *StreamWatermarkService) List(ctx context.Context, query StreamWatermarkListParams, opts ...option.RequestOption) (res *[]StreamWatermarkListResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamWatermarkListResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/watermarks", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a watermark profile. -func (r *StreamWatermarkService) Delete(ctx context.Context, identifier string, body StreamWatermarkDeleteParams, opts ...option.RequestOption) (res *StreamWatermarkDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamWatermarkDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/watermarks/%s", body.AccountID, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Retrieves details for a single watermark profile. -func (r *StreamWatermarkService) Get(ctx context.Context, identifier string, query StreamWatermarkGetParams, opts ...option.RequestOption) (res *StreamWatermarkGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamWatermarkGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/watermarks/%s", query.AccountID, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [StreamWatermarkNewResponseUnknown] or [shared.UnionString]. -type StreamWatermarkNewResponse interface { - ImplementsStreamWatermarkNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*StreamWatermarkNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type StreamWatermarkListResponse struct { - // The date and a time a watermark profile was created. - Created time.Time `json:"created" format:"date-time"` - // The source URL for a downloaded image. If the watermark profile was created via - // direct upload, this field is null. - DownloadedFrom string `json:"downloadedFrom"` - // The height of the image in pixels. - Height int64 `json:"height"` - // A short description of the watermark profile. - Name string `json:"name"` - // The translucency of the image. A value of `0.0` makes the image completely - // transparent, and `1.0` makes the image completely opaque. Note that if the image - // is already semi-transparent, setting this to `1.0` will not make the image - // completely opaque. - Opacity float64 `json:"opacity"` - // The whitespace between the adjacent edges (determined by position) of the video - // and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded - // video width or length, as determined by the algorithm. - Padding float64 `json:"padding"` - // The location of the image. Valid positions are: `upperRight`, `upperLeft`, - // `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the - // `padding` parameter. - Position string `json:"position"` - // The size of the image relative to the overall size of the video. This parameter - // will adapt to horizontal and vertical videos automatically. `0.0` indicates no - // scaling (use the size of the image as-is), and `1.0 `fills the entire video. - Scale float64 `json:"scale"` - // The size of the image in bytes. - Size float64 `json:"size"` - // The unique identifier for a watermark profile. - Uid string `json:"uid"` - // The width of the image in pixels. - Width int64 `json:"width"` - JSON streamWatermarkListResponseJSON `json:"-"` -} - -// streamWatermarkListResponseJSON contains the JSON metadata for the struct -// [StreamWatermarkListResponse] -type streamWatermarkListResponseJSON struct { - Created apijson.Field - DownloadedFrom apijson.Field - Height apijson.Field - Name apijson.Field - Opacity apijson.Field - Padding apijson.Field - Position apijson.Field - Scale apijson.Field - Size apijson.Field - Uid apijson.Field - Width apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWatermarkListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWatermarkListResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [StreamWatermarkDeleteResponseUnknown] or -// [shared.UnionString]. -type StreamWatermarkDeleteResponse interface { - ImplementsStreamWatermarkDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*StreamWatermarkDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [StreamWatermarkGetResponseUnknown] or [shared.UnionString]. -type StreamWatermarkGetResponse interface { - ImplementsStreamWatermarkGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*StreamWatermarkGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type StreamWatermarkNewParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // The image file to upload. - File param.Field[string] `json:"file,required"` - // A short description of the watermark profile. - Name param.Field[string] `json:"name"` - // The translucency of the image. A value of `0.0` makes the image completely - // transparent, and `1.0` makes the image completely opaque. Note that if the image - // is already semi-transparent, setting this to `1.0` will not make the image - // completely opaque. - Opacity param.Field[float64] `json:"opacity"` - // The whitespace between the adjacent edges (determined by position) of the video - // and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded - // video width or length, as determined by the algorithm. - Padding param.Field[float64] `json:"padding"` - // The location of the image. Valid positions are: `upperRight`, `upperLeft`, - // `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the - // `padding` parameter. - Position param.Field[string] `json:"position"` - // The size of the image relative to the overall size of the video. This parameter - // will adapt to horizontal and vertical videos automatically. `0.0` indicates no - // scaling (use the size of the image as-is), and `1.0 `fills the entire video. - Scale param.Field[float64] `json:"scale"` -} - -func (r StreamWatermarkNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type StreamWatermarkNewResponseEnvelope struct { - Errors []StreamWatermarkNewResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamWatermarkNewResponseEnvelopeMessages `json:"messages,required"` - Result StreamWatermarkNewResponse `json:"result,required"` - // Whether the API call was successful - Success StreamWatermarkNewResponseEnvelopeSuccess `json:"success,required"` - JSON streamWatermarkNewResponseEnvelopeJSON `json:"-"` -} - -// streamWatermarkNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [StreamWatermarkNewResponseEnvelope] -type streamWatermarkNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWatermarkNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWatermarkNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamWatermarkNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamWatermarkNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamWatermarkNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamWatermarkNewResponseEnvelopeErrors] -type streamWatermarkNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWatermarkNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWatermarkNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamWatermarkNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamWatermarkNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamWatermarkNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [StreamWatermarkNewResponseEnvelopeMessages] -type streamWatermarkNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWatermarkNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWatermarkNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamWatermarkNewResponseEnvelopeSuccess bool - -const ( - StreamWatermarkNewResponseEnvelopeSuccessTrue StreamWatermarkNewResponseEnvelopeSuccess = true -) - -type StreamWatermarkListParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamWatermarkListResponseEnvelope struct { - Errors []StreamWatermarkListResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamWatermarkListResponseEnvelopeMessages `json:"messages,required"` - Result []StreamWatermarkListResponse `json:"result,required"` - // Whether the API call was successful - Success StreamWatermarkListResponseEnvelopeSuccess `json:"success,required"` - JSON streamWatermarkListResponseEnvelopeJSON `json:"-"` -} - -// streamWatermarkListResponseEnvelopeJSON contains the JSON metadata for the -// struct [StreamWatermarkListResponseEnvelope] -type streamWatermarkListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWatermarkListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWatermarkListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamWatermarkListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamWatermarkListResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamWatermarkListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamWatermarkListResponseEnvelopeErrors] -type streamWatermarkListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWatermarkListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWatermarkListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamWatermarkListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamWatermarkListResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamWatermarkListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [StreamWatermarkListResponseEnvelopeMessages] -type streamWatermarkListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWatermarkListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWatermarkListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamWatermarkListResponseEnvelopeSuccess bool - -const ( - StreamWatermarkListResponseEnvelopeSuccessTrue StreamWatermarkListResponseEnvelopeSuccess = true -) - -type StreamWatermarkDeleteParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamWatermarkDeleteResponseEnvelope struct { - Errors []StreamWatermarkDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamWatermarkDeleteResponseEnvelopeMessages `json:"messages,required"` - Result StreamWatermarkDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success StreamWatermarkDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON streamWatermarkDeleteResponseEnvelopeJSON `json:"-"` -} - -// streamWatermarkDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [StreamWatermarkDeleteResponseEnvelope] -type streamWatermarkDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWatermarkDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWatermarkDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamWatermarkDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamWatermarkDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamWatermarkDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [StreamWatermarkDeleteResponseEnvelopeErrors] -type streamWatermarkDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWatermarkDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWatermarkDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamWatermarkDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamWatermarkDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamWatermarkDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [StreamWatermarkDeleteResponseEnvelopeMessages] -type streamWatermarkDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWatermarkDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWatermarkDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamWatermarkDeleteResponseEnvelopeSuccess bool - -const ( - StreamWatermarkDeleteResponseEnvelopeSuccessTrue StreamWatermarkDeleteResponseEnvelopeSuccess = true -) - -type StreamWatermarkGetParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamWatermarkGetResponseEnvelope struct { - Errors []StreamWatermarkGetResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamWatermarkGetResponseEnvelopeMessages `json:"messages,required"` - Result StreamWatermarkGetResponse `json:"result,required"` - // Whether the API call was successful - Success StreamWatermarkGetResponseEnvelopeSuccess `json:"success,required"` - JSON streamWatermarkGetResponseEnvelopeJSON `json:"-"` -} - -// streamWatermarkGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [StreamWatermarkGetResponseEnvelope] -type streamWatermarkGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWatermarkGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWatermarkGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamWatermarkGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamWatermarkGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamWatermarkGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamWatermarkGetResponseEnvelopeErrors] -type streamWatermarkGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWatermarkGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWatermarkGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamWatermarkGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamWatermarkGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamWatermarkGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [StreamWatermarkGetResponseEnvelopeMessages] -type streamWatermarkGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWatermarkGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWatermarkGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamWatermarkGetResponseEnvelopeSuccess bool - -const ( - StreamWatermarkGetResponseEnvelopeSuccessTrue StreamWatermarkGetResponseEnvelopeSuccess = true -) diff --git a/streamwatermark_test.go b/streamwatermark_test.go deleted file mode 100644 index c0a3bf4aee7..00000000000 --- a/streamwatermark_test.go +++ /dev/null @@ -1,132 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestStreamWatermarkNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Stream.Watermarks.New(context.TODO(), cloudflare.StreamWatermarkNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - File: cloudflare.F("@/Users/rchen/Downloads/watermark.png"), - Name: cloudflare.F("Marketing Videos"), - Opacity: cloudflare.F(0.750000), - Padding: cloudflare.F(0.100000), - Position: cloudflare.F("center"), - Scale: cloudflare.F(0.100000), - }) - 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 TestStreamWatermarkList(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("user@example.com"), - ) - _, err := client.Stream.Watermarks.List(context.TODO(), cloudflare.StreamWatermarkListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestStreamWatermarkDelete(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("user@example.com"), - ) - _, err := client.Stream.Watermarks.Delete( - context.TODO(), - "ea95132c15732412d22c1476fa83f27a", - cloudflare.StreamWatermarkDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestStreamWatermarkGet(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("user@example.com"), - ) - _, err := client.Stream.Watermarks.Get( - context.TODO(), - "ea95132c15732412d22c1476fa83f27a", - cloudflare.StreamWatermarkGetParams{ - AccountID: cloudflare.F("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/streamwebhook.go b/streamwebhook.go deleted file mode 100644 index ff2aa9f773b..00000000000 --- a/streamwebhook.go +++ /dev/null @@ -1,386 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// StreamWebhookService 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 [NewStreamWebhookService] method -// instead. -type StreamWebhookService struct { - Options []option.RequestOption -} - -// NewStreamWebhookService 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 NewStreamWebhookService(opts ...option.RequestOption) (r *StreamWebhookService) { - r = &StreamWebhookService{} - r.Options = opts - return -} - -// Creates a webhook notification. -func (r *StreamWebhookService) Update(ctx context.Context, params StreamWebhookUpdateParams, opts ...option.RequestOption) (res *StreamWebhookUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamWebhookUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/webhook", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a webhook. -func (r *StreamWebhookService) Delete(ctx context.Context, body StreamWebhookDeleteParams, opts ...option.RequestOption) (res *StreamWebhookDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamWebhookDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/webhook", body.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Retrieves a list of webhooks. -func (r *StreamWebhookService) Get(ctx context.Context, query StreamWebhookGetParams, opts ...option.RequestOption) (res *StreamWebhookGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env StreamWebhookGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/stream/webhook", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [StreamWebhookUpdateResponseUnknown] or [shared.UnionString]. -type StreamWebhookUpdateResponse interface { - ImplementsStreamWebhookUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*StreamWebhookUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [StreamWebhookDeleteResponseUnknown] or [shared.UnionString]. -type StreamWebhookDeleteResponse interface { - ImplementsStreamWebhookDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*StreamWebhookDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [StreamWebhookGetResponseUnknown] or [shared.UnionString]. -type StreamWebhookGetResponse interface { - ImplementsStreamWebhookGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*StreamWebhookGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type StreamWebhookUpdateParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` - // The URL where webhooks will be sent. - NotificationURL param.Field[string] `json:"notificationUrl,required" format:"uri"` -} - -func (r StreamWebhookUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type StreamWebhookUpdateResponseEnvelope struct { - Errors []StreamWebhookUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamWebhookUpdateResponseEnvelopeMessages `json:"messages,required"` - Result StreamWebhookUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success StreamWebhookUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON streamWebhookUpdateResponseEnvelopeJSON `json:"-"` -} - -// streamWebhookUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [StreamWebhookUpdateResponseEnvelope] -type streamWebhookUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWebhookUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWebhookUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamWebhookUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamWebhookUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamWebhookUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamWebhookUpdateResponseEnvelopeErrors] -type streamWebhookUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWebhookUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWebhookUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamWebhookUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamWebhookUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamWebhookUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [StreamWebhookUpdateResponseEnvelopeMessages] -type streamWebhookUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWebhookUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWebhookUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamWebhookUpdateResponseEnvelopeSuccess bool - -const ( - StreamWebhookUpdateResponseEnvelopeSuccessTrue StreamWebhookUpdateResponseEnvelopeSuccess = true -) - -type StreamWebhookDeleteParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamWebhookDeleteResponseEnvelope struct { - Errors []StreamWebhookDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamWebhookDeleteResponseEnvelopeMessages `json:"messages,required"` - Result StreamWebhookDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success StreamWebhookDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON streamWebhookDeleteResponseEnvelopeJSON `json:"-"` -} - -// streamWebhookDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [StreamWebhookDeleteResponseEnvelope] -type streamWebhookDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWebhookDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWebhookDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamWebhookDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamWebhookDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamWebhookDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamWebhookDeleteResponseEnvelopeErrors] -type streamWebhookDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWebhookDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWebhookDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamWebhookDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamWebhookDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamWebhookDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [StreamWebhookDeleteResponseEnvelopeMessages] -type streamWebhookDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWebhookDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWebhookDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamWebhookDeleteResponseEnvelopeSuccess bool - -const ( - StreamWebhookDeleteResponseEnvelopeSuccessTrue StreamWebhookDeleteResponseEnvelopeSuccess = true -) - -type StreamWebhookGetParams struct { - // The account identifier tag. - AccountID param.Field[string] `path:"account_id,required"` -} - -type StreamWebhookGetResponseEnvelope struct { - Errors []StreamWebhookGetResponseEnvelopeErrors `json:"errors,required"` - Messages []StreamWebhookGetResponseEnvelopeMessages `json:"messages,required"` - Result StreamWebhookGetResponse `json:"result,required"` - // Whether the API call was successful - Success StreamWebhookGetResponseEnvelopeSuccess `json:"success,required"` - JSON streamWebhookGetResponseEnvelopeJSON `json:"-"` -} - -// streamWebhookGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [StreamWebhookGetResponseEnvelope] -type streamWebhookGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWebhookGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWebhookGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type StreamWebhookGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamWebhookGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// streamWebhookGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [StreamWebhookGetResponseEnvelopeErrors] -type streamWebhookGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWebhookGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWebhookGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type StreamWebhookGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON streamWebhookGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// streamWebhookGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [StreamWebhookGetResponseEnvelopeMessages] -type streamWebhookGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *StreamWebhookGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r streamWebhookGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type StreamWebhookGetResponseEnvelopeSuccess bool - -const ( - StreamWebhookGetResponseEnvelopeSuccessTrue StreamWebhookGetResponseEnvelopeSuccess = true -) diff --git a/streamwebhook_test.go b/streamwebhook_test.go deleted file mode 100644 index cc446b5c646..00000000000 --- a/streamwebhook_test.go +++ /dev/null @@ -1,93 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestStreamWebhookUpdate(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("user@example.com"), - ) - _, err := client.Stream.Webhooks.Update(context.TODO(), cloudflare.StreamWebhookUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - NotificationURL: cloudflare.F("https://example.com"), - }) - 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 TestStreamWebhookDelete(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("user@example.com"), - ) - _, err := client.Stream.Webhooks.Delete(context.TODO(), cloudflare.StreamWebhookDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestStreamWebhookGet(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("user@example.com"), - ) - _, err := client.Stream.Webhooks.Get(context.TODO(), cloudflare.StreamWebhookGetParams{ - AccountID: cloudflare.F("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/subscription.go b/subscription.go deleted file mode 100644 index 4a49a656a23..00000000000 --- a/subscription.go +++ /dev/null @@ -1,967 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// SubscriptionService 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 [NewSubscriptionService] method -// instead. -type SubscriptionService struct { - Options []option.RequestOption -} - -// NewSubscriptionService 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 NewSubscriptionService(opts ...option.RequestOption) (r *SubscriptionService) { - r = &SubscriptionService{} - r.Options = opts - return -} - -// Create a zone subscription, either plan or add-ons. -func (r *SubscriptionService) New(ctx context.Context, identifier string, body SubscriptionNewParams, opts ...option.RequestOption) (res *SubscriptionNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env SubscriptionNewResponseEnvelope - path := fmt.Sprintf("zones/%s/subscription", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates an account subscription. -func (r *SubscriptionService) Update(ctx context.Context, accountIdentifier string, subscriptionIdentifier string, body SubscriptionUpdateParams, opts ...option.RequestOption) (res *SubscriptionUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env SubscriptionUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/subscriptions/%s", accountIdentifier, subscriptionIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists all of an account's subscriptions. -func (r *SubscriptionService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *[]SubscriptionListResponse, err error) { - opts = append(r.Options[:], opts...) - var env SubscriptionListResponseEnvelope - path := fmt.Sprintf("accounts/%s/subscriptions", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes an account's subscription. -func (r *SubscriptionService) Delete(ctx context.Context, accountIdentifier string, subscriptionIdentifier string, opts ...option.RequestOption) (res *SubscriptionDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env SubscriptionDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/subscriptions/%s", accountIdentifier, subscriptionIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists zone subscription details. -func (r *SubscriptionService) Get(ctx context.Context, identifier string, opts ...option.RequestOption) (res *SubscriptionGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env SubscriptionGetResponseEnvelope - path := fmt.Sprintf("zones/%s/subscription", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [SubscriptionNewResponseUnknown] or [shared.UnionString]. -type SubscriptionNewResponse interface { - ImplementsSubscriptionNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SubscriptionNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [SubscriptionUpdateResponseUnknown] or [shared.UnionString]. -type SubscriptionUpdateResponse interface { - ImplementsSubscriptionUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SubscriptionUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type SubscriptionListResponse struct { - // Subscription identifier tag. - ID string `json:"id"` - App SubscriptionListResponseApp `json:"app"` - // The list of add-ons subscribed to. - ComponentValues []SubscriptionListResponseComponentValue `json:"component_values"` - // The monetary unit in which pricing information is displayed. - Currency string `json:"currency"` - // The end of the current period and also when the next billing is due. - CurrentPeriodEnd time.Time `json:"current_period_end" format:"date-time"` - // When the current billing period started. May match initial_period_start if this - // is the first period. - CurrentPeriodStart time.Time `json:"current_period_start" format:"date-time"` - // How often the subscription is renewed automatically. - Frequency SubscriptionListResponseFrequency `json:"frequency"` - // The price of the subscription that will be billed, in US dollars. - Price float64 `json:"price"` - // The rate plan applied to the subscription. - RatePlan SubscriptionListResponseRatePlan `json:"rate_plan"` - // The state that the subscription is in. - State SubscriptionListResponseState `json:"state"` - // A simple zone object. May have null properties if not a zone subscription. - Zone SubscriptionListResponseZone `json:"zone"` - JSON subscriptionListResponseJSON `json:"-"` -} - -// subscriptionListResponseJSON contains the JSON metadata for the struct -// [SubscriptionListResponse] -type subscriptionListResponseJSON struct { - ID apijson.Field - App apijson.Field - ComponentValues apijson.Field - Currency apijson.Field - CurrentPeriodEnd apijson.Field - CurrentPeriodStart apijson.Field - Frequency apijson.Field - Price apijson.Field - RatePlan apijson.Field - State apijson.Field - Zone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseJSON) RawJSON() string { - return r.raw -} - -type SubscriptionListResponseApp struct { - // app install id. - InstallID string `json:"install_id"` - JSON subscriptionListResponseAppJSON `json:"-"` -} - -// subscriptionListResponseAppJSON contains the JSON metadata for the struct -// [SubscriptionListResponseApp] -type subscriptionListResponseAppJSON struct { - InstallID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionListResponseApp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseAppJSON) RawJSON() string { - return r.raw -} - -// A component value for a subscription. -type SubscriptionListResponseComponentValue struct { - // The default amount assigned. - Default float64 `json:"default"` - // The name of the component value. - Name string `json:"name"` - // The unit price for the component value. - Price float64 `json:"price"` - // The amount of the component value assigned. - Value float64 `json:"value"` - JSON subscriptionListResponseComponentValueJSON `json:"-"` -} - -// subscriptionListResponseComponentValueJSON contains the JSON metadata for the -// struct [SubscriptionListResponseComponentValue] -type subscriptionListResponseComponentValueJSON struct { - Default apijson.Field - Name apijson.Field - Price apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionListResponseComponentValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseComponentValueJSON) RawJSON() string { - return r.raw -} - -// How often the subscription is renewed automatically. -type SubscriptionListResponseFrequency string - -const ( - SubscriptionListResponseFrequencyWeekly SubscriptionListResponseFrequency = "weekly" - SubscriptionListResponseFrequencyMonthly SubscriptionListResponseFrequency = "monthly" - SubscriptionListResponseFrequencyQuarterly SubscriptionListResponseFrequency = "quarterly" - SubscriptionListResponseFrequencyYearly SubscriptionListResponseFrequency = "yearly" -) - -// The rate plan applied to the subscription. -type SubscriptionListResponseRatePlan struct { - // The ID of the rate plan. - ID interface{} `json:"id"` - // The currency applied to the rate plan subscription. - Currency string `json:"currency"` - // Whether this rate plan is managed externally from Cloudflare. - ExternallyManaged bool `json:"externally_managed"` - // Whether a rate plan is enterprise-based (or newly adopted term contract). - IsContract bool `json:"is_contract"` - // The full name of the rate plan. - PublicName string `json:"public_name"` - // The scope that this rate plan applies to. - Scope string `json:"scope"` - // The list of sets this rate plan applies to. - Sets []string `json:"sets"` - JSON subscriptionListResponseRatePlanJSON `json:"-"` -} - -// subscriptionListResponseRatePlanJSON contains the JSON metadata for the struct -// [SubscriptionListResponseRatePlan] -type subscriptionListResponseRatePlanJSON struct { - ID apijson.Field - Currency apijson.Field - ExternallyManaged apijson.Field - IsContract apijson.Field - PublicName apijson.Field - Scope apijson.Field - Sets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionListResponseRatePlan) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseRatePlanJSON) RawJSON() string { - return r.raw -} - -// The state that the subscription is in. -type SubscriptionListResponseState string - -const ( - SubscriptionListResponseStateTrial SubscriptionListResponseState = "Trial" - SubscriptionListResponseStateProvisioned SubscriptionListResponseState = "Provisioned" - SubscriptionListResponseStatePaid SubscriptionListResponseState = "Paid" - SubscriptionListResponseStateAwaitingPayment SubscriptionListResponseState = "AwaitingPayment" - SubscriptionListResponseStateCancelled SubscriptionListResponseState = "Cancelled" - SubscriptionListResponseStateFailed SubscriptionListResponseState = "Failed" - SubscriptionListResponseStateExpired SubscriptionListResponseState = "Expired" -) - -// A simple zone object. May have null properties if not a zone subscription. -type SubscriptionListResponseZone struct { - // Identifier - ID string `json:"id"` - // The domain name - Name string `json:"name"` - JSON subscriptionListResponseZoneJSON `json:"-"` -} - -// subscriptionListResponseZoneJSON contains the JSON metadata for the struct -// [SubscriptionListResponseZone] -type subscriptionListResponseZoneJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionListResponseZone) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseZoneJSON) RawJSON() string { - return r.raw -} - -type SubscriptionDeleteResponse struct { - // Subscription identifier tag. - SubscriptionID string `json:"subscription_id"` - JSON subscriptionDeleteResponseJSON `json:"-"` -} - -// subscriptionDeleteResponseJSON contains the JSON metadata for the struct -// [SubscriptionDeleteResponse] -type subscriptionDeleteResponseJSON struct { - SubscriptionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [SubscriptionGetResponseUnknown] or [shared.UnionString]. -type SubscriptionGetResponse interface { - ImplementsSubscriptionGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*SubscriptionGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type SubscriptionNewParams struct { - App param.Field[SubscriptionNewParamsApp] `json:"app"` - // The list of add-ons subscribed to. - ComponentValues param.Field[[]SubscriptionNewParamsComponentValue] `json:"component_values"` - // How often the subscription is renewed automatically. - Frequency param.Field[SubscriptionNewParamsFrequency] `json:"frequency"` - // The rate plan applied to the subscription. - RatePlan param.Field[SubscriptionNewParamsRatePlan] `json:"rate_plan"` - // A simple zone object. May have null properties if not a zone subscription. - Zone param.Field[SubscriptionNewParamsZone] `json:"zone"` -} - -func (r SubscriptionNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SubscriptionNewParamsApp struct { - // app install id. - InstallID param.Field[string] `json:"install_id"` -} - -func (r SubscriptionNewParamsApp) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A component value for a subscription. -type SubscriptionNewParamsComponentValue struct { - // The default amount assigned. - Default param.Field[float64] `json:"default"` - // The name of the component value. - Name param.Field[string] `json:"name"` - // The unit price for the component value. - Price param.Field[float64] `json:"price"` - // The amount of the component value assigned. - Value param.Field[float64] `json:"value"` -} - -func (r SubscriptionNewParamsComponentValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// How often the subscription is renewed automatically. -type SubscriptionNewParamsFrequency string - -const ( - SubscriptionNewParamsFrequencyWeekly SubscriptionNewParamsFrequency = "weekly" - SubscriptionNewParamsFrequencyMonthly SubscriptionNewParamsFrequency = "monthly" - SubscriptionNewParamsFrequencyQuarterly SubscriptionNewParamsFrequency = "quarterly" - SubscriptionNewParamsFrequencyYearly SubscriptionNewParamsFrequency = "yearly" -) - -// The rate plan applied to the subscription. -type SubscriptionNewParamsRatePlan struct { - // The ID of the rate plan. - ID param.Field[interface{}] `json:"id"` - // The currency applied to the rate plan subscription. - Currency param.Field[string] `json:"currency"` - // Whether this rate plan is managed externally from Cloudflare. - ExternallyManaged param.Field[bool] `json:"externally_managed"` - // Whether a rate plan is enterprise-based (or newly adopted term contract). - IsContract param.Field[bool] `json:"is_contract"` - // The full name of the rate plan. - PublicName param.Field[string] `json:"public_name"` - // The scope that this rate plan applies to. - Scope param.Field[string] `json:"scope"` - // The list of sets this rate plan applies to. - Sets param.Field[[]string] `json:"sets"` -} - -func (r SubscriptionNewParamsRatePlan) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A simple zone object. May have null properties if not a zone subscription. -type SubscriptionNewParamsZone struct { -} - -func (r SubscriptionNewParamsZone) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SubscriptionNewResponseEnvelope struct { - Errors []SubscriptionNewResponseEnvelopeErrors `json:"errors,required"` - Messages []SubscriptionNewResponseEnvelopeMessages `json:"messages,required"` - Result SubscriptionNewResponse `json:"result,required"` - // Whether the API call was successful - Success SubscriptionNewResponseEnvelopeSuccess `json:"success,required"` - JSON subscriptionNewResponseEnvelopeJSON `json:"-"` -} - -// subscriptionNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [SubscriptionNewResponseEnvelope] -type subscriptionNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SubscriptionNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// subscriptionNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SubscriptionNewResponseEnvelopeErrors] -type subscriptionNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SubscriptionNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// subscriptionNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SubscriptionNewResponseEnvelopeMessages] -type subscriptionNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SubscriptionNewResponseEnvelopeSuccess bool - -const ( - SubscriptionNewResponseEnvelopeSuccessTrue SubscriptionNewResponseEnvelopeSuccess = true -) - -type SubscriptionUpdateParams struct { - App param.Field[SubscriptionUpdateParamsApp] `json:"app"` - // The list of add-ons subscribed to. - ComponentValues param.Field[[]SubscriptionUpdateParamsComponentValue] `json:"component_values"` - // How often the subscription is renewed automatically. - Frequency param.Field[SubscriptionUpdateParamsFrequency] `json:"frequency"` - // The rate plan applied to the subscription. - RatePlan param.Field[SubscriptionUpdateParamsRatePlan] `json:"rate_plan"` - // A simple zone object. May have null properties if not a zone subscription. - Zone param.Field[SubscriptionUpdateParamsZone] `json:"zone"` -} - -func (r SubscriptionUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SubscriptionUpdateParamsApp struct { - // app install id. - InstallID param.Field[string] `json:"install_id"` -} - -func (r SubscriptionUpdateParamsApp) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A component value for a subscription. -type SubscriptionUpdateParamsComponentValue struct { - // The default amount assigned. - Default param.Field[float64] `json:"default"` - // The name of the component value. - Name param.Field[string] `json:"name"` - // The unit price for the component value. - Price param.Field[float64] `json:"price"` - // The amount of the component value assigned. - Value param.Field[float64] `json:"value"` -} - -func (r SubscriptionUpdateParamsComponentValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// How often the subscription is renewed automatically. -type SubscriptionUpdateParamsFrequency string - -const ( - SubscriptionUpdateParamsFrequencyWeekly SubscriptionUpdateParamsFrequency = "weekly" - SubscriptionUpdateParamsFrequencyMonthly SubscriptionUpdateParamsFrequency = "monthly" - SubscriptionUpdateParamsFrequencyQuarterly SubscriptionUpdateParamsFrequency = "quarterly" - SubscriptionUpdateParamsFrequencyYearly SubscriptionUpdateParamsFrequency = "yearly" -) - -// The rate plan applied to the subscription. -type SubscriptionUpdateParamsRatePlan struct { - // The ID of the rate plan. - ID param.Field[interface{}] `json:"id"` - // The currency applied to the rate plan subscription. - Currency param.Field[string] `json:"currency"` - // Whether this rate plan is managed externally from Cloudflare. - ExternallyManaged param.Field[bool] `json:"externally_managed"` - // Whether a rate plan is enterprise-based (or newly adopted term contract). - IsContract param.Field[bool] `json:"is_contract"` - // The full name of the rate plan. - PublicName param.Field[string] `json:"public_name"` - // The scope that this rate plan applies to. - Scope param.Field[string] `json:"scope"` - // The list of sets this rate plan applies to. - Sets param.Field[[]string] `json:"sets"` -} - -func (r SubscriptionUpdateParamsRatePlan) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A simple zone object. May have null properties if not a zone subscription. -type SubscriptionUpdateParamsZone struct { -} - -func (r SubscriptionUpdateParamsZone) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type SubscriptionUpdateResponseEnvelope struct { - Errors []SubscriptionUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []SubscriptionUpdateResponseEnvelopeMessages `json:"messages,required"` - Result SubscriptionUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success SubscriptionUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON subscriptionUpdateResponseEnvelopeJSON `json:"-"` -} - -// subscriptionUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [SubscriptionUpdateResponseEnvelope] -type subscriptionUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SubscriptionUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// subscriptionUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SubscriptionUpdateResponseEnvelopeErrors] -type subscriptionUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SubscriptionUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// subscriptionUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SubscriptionUpdateResponseEnvelopeMessages] -type subscriptionUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SubscriptionUpdateResponseEnvelopeSuccess bool - -const ( - SubscriptionUpdateResponseEnvelopeSuccessTrue SubscriptionUpdateResponseEnvelopeSuccess = true -) - -type SubscriptionListResponseEnvelope struct { - Errors []SubscriptionListResponseEnvelopeErrors `json:"errors,required"` - Messages []SubscriptionListResponseEnvelopeMessages `json:"messages,required"` - Result []SubscriptionListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success SubscriptionListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo SubscriptionListResponseEnvelopeResultInfo `json:"result_info"` - JSON subscriptionListResponseEnvelopeJSON `json:"-"` -} - -// subscriptionListResponseEnvelopeJSON contains the JSON metadata for the struct -// [SubscriptionListResponseEnvelope] -type subscriptionListResponseEnvelopeJSON 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 *SubscriptionListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SubscriptionListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionListResponseEnvelopeErrorsJSON `json:"-"` -} - -// subscriptionListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SubscriptionListResponseEnvelopeErrors] -type subscriptionListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SubscriptionListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionListResponseEnvelopeMessagesJSON `json:"-"` -} - -// subscriptionListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SubscriptionListResponseEnvelopeMessages] -type subscriptionListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SubscriptionListResponseEnvelopeSuccess bool - -const ( - SubscriptionListResponseEnvelopeSuccessTrue SubscriptionListResponseEnvelopeSuccess = true -) - -type SubscriptionListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON subscriptionListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// subscriptionListResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [SubscriptionListResponseEnvelopeResultInfo] -type subscriptionListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type SubscriptionDeleteResponseEnvelope struct { - Errors []SubscriptionDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []SubscriptionDeleteResponseEnvelopeMessages `json:"messages,required"` - Result SubscriptionDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success SubscriptionDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON subscriptionDeleteResponseEnvelopeJSON `json:"-"` -} - -// subscriptionDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [SubscriptionDeleteResponseEnvelope] -type subscriptionDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SubscriptionDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// subscriptionDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SubscriptionDeleteResponseEnvelopeErrors] -type subscriptionDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SubscriptionDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// subscriptionDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [SubscriptionDeleteResponseEnvelopeMessages] -type subscriptionDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SubscriptionDeleteResponseEnvelopeSuccess bool - -const ( - SubscriptionDeleteResponseEnvelopeSuccessTrue SubscriptionDeleteResponseEnvelopeSuccess = true -) - -type SubscriptionGetResponseEnvelope struct { - Errors []SubscriptionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []SubscriptionGetResponseEnvelopeMessages `json:"messages,required"` - Result SubscriptionGetResponse `json:"result,required"` - // Whether the API call was successful - Success SubscriptionGetResponseEnvelopeSuccess `json:"success,required"` - JSON subscriptionGetResponseEnvelopeJSON `json:"-"` -} - -// subscriptionGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [SubscriptionGetResponseEnvelope] -type subscriptionGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type SubscriptionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// subscriptionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [SubscriptionGetResponseEnvelopeErrors] -type subscriptionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type SubscriptionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON subscriptionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// subscriptionGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [SubscriptionGetResponseEnvelopeMessages] -type subscriptionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *SubscriptionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r subscriptionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type SubscriptionGetResponseEnvelopeSuccess bool - -const ( - SubscriptionGetResponseEnvelopeSuccessTrue SubscriptionGetResponseEnvelopeSuccess = true -) diff --git a/subscription_test.go b/subscription_test.go deleted file mode 100644 index 2a1d4110ff7..00000000000 --- a/subscription_test.go +++ /dev/null @@ -1,209 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestSubscriptionNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Subscriptions.New( - context.TODO(), - "506e3185e9c882d175a2d0cb0093d9f2", - cloudflare.SubscriptionNewParams{ - App: cloudflare.F(cloudflare.SubscriptionNewParamsApp{ - InstallID: cloudflare.F("string"), - }), - ComponentValues: cloudflare.F([]cloudflare.SubscriptionNewParamsComponentValue{{ - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }}), - Frequency: cloudflare.F(cloudflare.SubscriptionNewParamsFrequencyMonthly), - RatePlan: cloudflare.F(cloudflare.SubscriptionNewParamsRatePlan{ - Currency: cloudflare.F("USD"), - ExternallyManaged: cloudflare.F(false), - ID: cloudflare.F[any]("free"), - IsContract: cloudflare.F(false), - PublicName: cloudflare.F("Business Plan"), - Scope: cloudflare.F("zone"), - Sets: cloudflare.F([]string{"string", "string", "string"}), - }), - Zone: cloudflare.F(cloudflare.SubscriptionNewParamsZone{}), - }, - ) - 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 TestSubscriptionUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Subscriptions.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "506e3185e9c882d175a2d0cb0093d9f2", - cloudflare.SubscriptionUpdateParams{ - App: cloudflare.F(cloudflare.SubscriptionUpdateParamsApp{ - InstallID: cloudflare.F("string"), - }), - ComponentValues: cloudflare.F([]cloudflare.SubscriptionUpdateParamsComponentValue{{ - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }}), - Frequency: cloudflare.F(cloudflare.SubscriptionUpdateParamsFrequencyMonthly), - RatePlan: cloudflare.F(cloudflare.SubscriptionUpdateParamsRatePlan{ - Currency: cloudflare.F("USD"), - ExternallyManaged: cloudflare.F(false), - ID: cloudflare.F[any]("free"), - IsContract: cloudflare.F(false), - PublicName: cloudflare.F("Business Plan"), - Scope: cloudflare.F("zone"), - Sets: cloudflare.F([]string{"string", "string", "string"}), - }), - Zone: cloudflare.F(cloudflare.SubscriptionUpdateParamsZone{}), - }, - ) - 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 TestSubscriptionList(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("user@example.com"), - ) - _, err := client.Subscriptions.List(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()) - } -} - -func TestSubscriptionDelete(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("user@example.com"), - ) - _, err := client.Subscriptions.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "506e3185e9c882d175a2d0cb0093d9f2", - ) - 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 TestSubscriptionGet(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("user@example.com"), - ) - _, err := client.Subscriptions.Get(context.TODO(), "506e3185e9c882d175a2d0cb0093d9f2") - 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/subscriptions/aliases.go b/subscriptions/aliases.go new file mode 100644 index 00000000000..bb0e313e52f --- /dev/null +++ b/subscriptions/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package subscriptions + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/subscriptions/subscription.go b/subscriptions/subscription.go new file mode 100644 index 00000000000..97beb5526b3 --- /dev/null +++ b/subscriptions/subscription.go @@ -0,0 +1,970 @@ +// File generated from our OpenAPI spec by Stainless. + +package subscriptions + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// SubscriptionService 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 [NewSubscriptionService] method +// instead. +type SubscriptionService struct { + Options []option.RequestOption +} + +// NewSubscriptionService 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 NewSubscriptionService(opts ...option.RequestOption) (r *SubscriptionService) { + r = &SubscriptionService{} + r.Options = opts + return +} + +// Create a zone subscription, either plan or add-ons. +func (r *SubscriptionService) New(ctx context.Context, identifier string, body SubscriptionNewParams, opts ...option.RequestOption) (res *SubscriptionNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env SubscriptionNewResponseEnvelope + path := fmt.Sprintf("zones/%s/subscription", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates an account subscription. +func (r *SubscriptionService) Update(ctx context.Context, accountIdentifier string, subscriptionIdentifier string, body SubscriptionUpdateParams, opts ...option.RequestOption) (res *SubscriptionUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env SubscriptionUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/subscriptions/%s", accountIdentifier, subscriptionIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists all of an account's subscriptions. +func (r *SubscriptionService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *[]SubscriptionListResponse, err error) { + opts = append(r.Options[:], opts...) + var env SubscriptionListResponseEnvelope + path := fmt.Sprintf("accounts/%s/subscriptions", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes an account's subscription. +func (r *SubscriptionService) Delete(ctx context.Context, accountIdentifier string, subscriptionIdentifier string, opts ...option.RequestOption) (res *SubscriptionDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env SubscriptionDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/subscriptions/%s", accountIdentifier, subscriptionIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists zone subscription details. +func (r *SubscriptionService) Get(ctx context.Context, identifier string, opts ...option.RequestOption) (res *SubscriptionGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env SubscriptionGetResponseEnvelope + path := fmt.Sprintf("zones/%s/subscription", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [subscriptions.SubscriptionNewResponseUnknown] or +// [shared.UnionString]. +type SubscriptionNewResponse interface { + ImplementsSubscriptionsSubscriptionNewResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*SubscriptionNewResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [subscriptions.SubscriptionUpdateResponseUnknown] or +// [shared.UnionString]. +type SubscriptionUpdateResponse interface { + ImplementsSubscriptionsSubscriptionUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*SubscriptionUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type SubscriptionListResponse struct { + // Subscription identifier tag. + ID string `json:"id"` + App SubscriptionListResponseApp `json:"app"` + // The list of add-ons subscribed to. + ComponentValues []SubscriptionListResponseComponentValue `json:"component_values"` + // The monetary unit in which pricing information is displayed. + Currency string `json:"currency"` + // The end of the current period and also when the next billing is due. + CurrentPeriodEnd time.Time `json:"current_period_end" format:"date-time"` + // When the current billing period started. May match initial_period_start if this + // is the first period. + CurrentPeriodStart time.Time `json:"current_period_start" format:"date-time"` + // How often the subscription is renewed automatically. + Frequency SubscriptionListResponseFrequency `json:"frequency"` + // The price of the subscription that will be billed, in US dollars. + Price float64 `json:"price"` + // The rate plan applied to the subscription. + RatePlan SubscriptionListResponseRatePlan `json:"rate_plan"` + // The state that the subscription is in. + State SubscriptionListResponseState `json:"state"` + // A simple zone object. May have null properties if not a zone subscription. + Zone SubscriptionListResponseZone `json:"zone"` + JSON subscriptionListResponseJSON `json:"-"` +} + +// subscriptionListResponseJSON contains the JSON metadata for the struct +// [SubscriptionListResponse] +type subscriptionListResponseJSON struct { + ID apijson.Field + App apijson.Field + ComponentValues apijson.Field + Currency apijson.Field + CurrentPeriodEnd apijson.Field + CurrentPeriodStart apijson.Field + Frequency apijson.Field + Price apijson.Field + RatePlan apijson.Field + State apijson.Field + Zone apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionListResponseJSON) RawJSON() string { + return r.raw +} + +type SubscriptionListResponseApp struct { + // app install id. + InstallID string `json:"install_id"` + JSON subscriptionListResponseAppJSON `json:"-"` +} + +// subscriptionListResponseAppJSON contains the JSON metadata for the struct +// [SubscriptionListResponseApp] +type subscriptionListResponseAppJSON struct { + InstallID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionListResponseApp) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionListResponseAppJSON) RawJSON() string { + return r.raw +} + +// A component value for a subscription. +type SubscriptionListResponseComponentValue struct { + // The default amount assigned. + Default float64 `json:"default"` + // The name of the component value. + Name string `json:"name"` + // The unit price for the component value. + Price float64 `json:"price"` + // The amount of the component value assigned. + Value float64 `json:"value"` + JSON subscriptionListResponseComponentValueJSON `json:"-"` +} + +// subscriptionListResponseComponentValueJSON contains the JSON metadata for the +// struct [SubscriptionListResponseComponentValue] +type subscriptionListResponseComponentValueJSON struct { + Default apijson.Field + Name apijson.Field + Price apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionListResponseComponentValue) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionListResponseComponentValueJSON) RawJSON() string { + return r.raw +} + +// How often the subscription is renewed automatically. +type SubscriptionListResponseFrequency string + +const ( + SubscriptionListResponseFrequencyWeekly SubscriptionListResponseFrequency = "weekly" + SubscriptionListResponseFrequencyMonthly SubscriptionListResponseFrequency = "monthly" + SubscriptionListResponseFrequencyQuarterly SubscriptionListResponseFrequency = "quarterly" + SubscriptionListResponseFrequencyYearly SubscriptionListResponseFrequency = "yearly" +) + +// The rate plan applied to the subscription. +type SubscriptionListResponseRatePlan struct { + // The ID of the rate plan. + ID interface{} `json:"id"` + // The currency applied to the rate plan subscription. + Currency string `json:"currency"` + // Whether this rate plan is managed externally from Cloudflare. + ExternallyManaged bool `json:"externally_managed"` + // Whether a rate plan is enterprise-based (or newly adopted term contract). + IsContract bool `json:"is_contract"` + // The full name of the rate plan. + PublicName string `json:"public_name"` + // The scope that this rate plan applies to. + Scope string `json:"scope"` + // The list of sets this rate plan applies to. + Sets []string `json:"sets"` + JSON subscriptionListResponseRatePlanJSON `json:"-"` +} + +// subscriptionListResponseRatePlanJSON contains the JSON metadata for the struct +// [SubscriptionListResponseRatePlan] +type subscriptionListResponseRatePlanJSON struct { + ID apijson.Field + Currency apijson.Field + ExternallyManaged apijson.Field + IsContract apijson.Field + PublicName apijson.Field + Scope apijson.Field + Sets apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionListResponseRatePlan) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionListResponseRatePlanJSON) RawJSON() string { + return r.raw +} + +// The state that the subscription is in. +type SubscriptionListResponseState string + +const ( + SubscriptionListResponseStateTrial SubscriptionListResponseState = "Trial" + SubscriptionListResponseStateProvisioned SubscriptionListResponseState = "Provisioned" + SubscriptionListResponseStatePaid SubscriptionListResponseState = "Paid" + SubscriptionListResponseStateAwaitingPayment SubscriptionListResponseState = "AwaitingPayment" + SubscriptionListResponseStateCancelled SubscriptionListResponseState = "Cancelled" + SubscriptionListResponseStateFailed SubscriptionListResponseState = "Failed" + SubscriptionListResponseStateExpired SubscriptionListResponseState = "Expired" +) + +// A simple zone object. May have null properties if not a zone subscription. +type SubscriptionListResponseZone struct { + // Identifier + ID string `json:"id"` + // The domain name + Name string `json:"name"` + JSON subscriptionListResponseZoneJSON `json:"-"` +} + +// subscriptionListResponseZoneJSON contains the JSON metadata for the struct +// [SubscriptionListResponseZone] +type subscriptionListResponseZoneJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionListResponseZone) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionListResponseZoneJSON) RawJSON() string { + return r.raw +} + +type SubscriptionDeleteResponse struct { + // Subscription identifier tag. + SubscriptionID string `json:"subscription_id"` + JSON subscriptionDeleteResponseJSON `json:"-"` +} + +// subscriptionDeleteResponseJSON contains the JSON metadata for the struct +// [SubscriptionDeleteResponse] +type subscriptionDeleteResponseJSON struct { + SubscriptionID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionDeleteResponseJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [subscriptions.SubscriptionGetResponseUnknown] or +// [shared.UnionString]. +type SubscriptionGetResponse interface { + ImplementsSubscriptionsSubscriptionGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*SubscriptionGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type SubscriptionNewParams struct { + App param.Field[SubscriptionNewParamsApp] `json:"app"` + // The list of add-ons subscribed to. + ComponentValues param.Field[[]SubscriptionNewParamsComponentValue] `json:"component_values"` + // How often the subscription is renewed automatically. + Frequency param.Field[SubscriptionNewParamsFrequency] `json:"frequency"` + // The rate plan applied to the subscription. + RatePlan param.Field[SubscriptionNewParamsRatePlan] `json:"rate_plan"` + // A simple zone object. May have null properties if not a zone subscription. + Zone param.Field[SubscriptionNewParamsZone] `json:"zone"` +} + +func (r SubscriptionNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SubscriptionNewParamsApp struct { + // app install id. + InstallID param.Field[string] `json:"install_id"` +} + +func (r SubscriptionNewParamsApp) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A component value for a subscription. +type SubscriptionNewParamsComponentValue struct { + // The default amount assigned. + Default param.Field[float64] `json:"default"` + // The name of the component value. + Name param.Field[string] `json:"name"` + // The unit price for the component value. + Price param.Field[float64] `json:"price"` + // The amount of the component value assigned. + Value param.Field[float64] `json:"value"` +} + +func (r SubscriptionNewParamsComponentValue) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// How often the subscription is renewed automatically. +type SubscriptionNewParamsFrequency string + +const ( + SubscriptionNewParamsFrequencyWeekly SubscriptionNewParamsFrequency = "weekly" + SubscriptionNewParamsFrequencyMonthly SubscriptionNewParamsFrequency = "monthly" + SubscriptionNewParamsFrequencyQuarterly SubscriptionNewParamsFrequency = "quarterly" + SubscriptionNewParamsFrequencyYearly SubscriptionNewParamsFrequency = "yearly" +) + +// The rate plan applied to the subscription. +type SubscriptionNewParamsRatePlan struct { + // The ID of the rate plan. + ID param.Field[interface{}] `json:"id"` + // The currency applied to the rate plan subscription. + Currency param.Field[string] `json:"currency"` + // Whether this rate plan is managed externally from Cloudflare. + ExternallyManaged param.Field[bool] `json:"externally_managed"` + // Whether a rate plan is enterprise-based (or newly adopted term contract). + IsContract param.Field[bool] `json:"is_contract"` + // The full name of the rate plan. + PublicName param.Field[string] `json:"public_name"` + // The scope that this rate plan applies to. + Scope param.Field[string] `json:"scope"` + // The list of sets this rate plan applies to. + Sets param.Field[[]string] `json:"sets"` +} + +func (r SubscriptionNewParamsRatePlan) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A simple zone object. May have null properties if not a zone subscription. +type SubscriptionNewParamsZone struct { +} + +func (r SubscriptionNewParamsZone) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SubscriptionNewResponseEnvelope struct { + Errors []SubscriptionNewResponseEnvelopeErrors `json:"errors,required"` + Messages []SubscriptionNewResponseEnvelopeMessages `json:"messages,required"` + Result SubscriptionNewResponse `json:"result,required"` + // Whether the API call was successful + Success SubscriptionNewResponseEnvelopeSuccess `json:"success,required"` + JSON subscriptionNewResponseEnvelopeJSON `json:"-"` +} + +// subscriptionNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [SubscriptionNewResponseEnvelope] +type subscriptionNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SubscriptionNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// subscriptionNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SubscriptionNewResponseEnvelopeErrors] +type subscriptionNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SubscriptionNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// subscriptionNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SubscriptionNewResponseEnvelopeMessages] +type subscriptionNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SubscriptionNewResponseEnvelopeSuccess bool + +const ( + SubscriptionNewResponseEnvelopeSuccessTrue SubscriptionNewResponseEnvelopeSuccess = true +) + +type SubscriptionUpdateParams struct { + App param.Field[SubscriptionUpdateParamsApp] `json:"app"` + // The list of add-ons subscribed to. + ComponentValues param.Field[[]SubscriptionUpdateParamsComponentValue] `json:"component_values"` + // How often the subscription is renewed automatically. + Frequency param.Field[SubscriptionUpdateParamsFrequency] `json:"frequency"` + // The rate plan applied to the subscription. + RatePlan param.Field[SubscriptionUpdateParamsRatePlan] `json:"rate_plan"` + // A simple zone object. May have null properties if not a zone subscription. + Zone param.Field[SubscriptionUpdateParamsZone] `json:"zone"` +} + +func (r SubscriptionUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SubscriptionUpdateParamsApp struct { + // app install id. + InstallID param.Field[string] `json:"install_id"` +} + +func (r SubscriptionUpdateParamsApp) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A component value for a subscription. +type SubscriptionUpdateParamsComponentValue struct { + // The default amount assigned. + Default param.Field[float64] `json:"default"` + // The name of the component value. + Name param.Field[string] `json:"name"` + // The unit price for the component value. + Price param.Field[float64] `json:"price"` + // The amount of the component value assigned. + Value param.Field[float64] `json:"value"` +} + +func (r SubscriptionUpdateParamsComponentValue) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// How often the subscription is renewed automatically. +type SubscriptionUpdateParamsFrequency string + +const ( + SubscriptionUpdateParamsFrequencyWeekly SubscriptionUpdateParamsFrequency = "weekly" + SubscriptionUpdateParamsFrequencyMonthly SubscriptionUpdateParamsFrequency = "monthly" + SubscriptionUpdateParamsFrequencyQuarterly SubscriptionUpdateParamsFrequency = "quarterly" + SubscriptionUpdateParamsFrequencyYearly SubscriptionUpdateParamsFrequency = "yearly" +) + +// The rate plan applied to the subscription. +type SubscriptionUpdateParamsRatePlan struct { + // The ID of the rate plan. + ID param.Field[interface{}] `json:"id"` + // The currency applied to the rate plan subscription. + Currency param.Field[string] `json:"currency"` + // Whether this rate plan is managed externally from Cloudflare. + ExternallyManaged param.Field[bool] `json:"externally_managed"` + // Whether a rate plan is enterprise-based (or newly adopted term contract). + IsContract param.Field[bool] `json:"is_contract"` + // The full name of the rate plan. + PublicName param.Field[string] `json:"public_name"` + // The scope that this rate plan applies to. + Scope param.Field[string] `json:"scope"` + // The list of sets this rate plan applies to. + Sets param.Field[[]string] `json:"sets"` +} + +func (r SubscriptionUpdateParamsRatePlan) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A simple zone object. May have null properties if not a zone subscription. +type SubscriptionUpdateParamsZone struct { +} + +func (r SubscriptionUpdateParamsZone) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SubscriptionUpdateResponseEnvelope struct { + Errors []SubscriptionUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []SubscriptionUpdateResponseEnvelopeMessages `json:"messages,required"` + Result SubscriptionUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success SubscriptionUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON subscriptionUpdateResponseEnvelopeJSON `json:"-"` +} + +// subscriptionUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [SubscriptionUpdateResponseEnvelope] +type subscriptionUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SubscriptionUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// subscriptionUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SubscriptionUpdateResponseEnvelopeErrors] +type subscriptionUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SubscriptionUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// subscriptionUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [SubscriptionUpdateResponseEnvelopeMessages] +type subscriptionUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SubscriptionUpdateResponseEnvelopeSuccess bool + +const ( + SubscriptionUpdateResponseEnvelopeSuccessTrue SubscriptionUpdateResponseEnvelopeSuccess = true +) + +type SubscriptionListResponseEnvelope struct { + Errors []SubscriptionListResponseEnvelopeErrors `json:"errors,required"` + Messages []SubscriptionListResponseEnvelopeMessages `json:"messages,required"` + Result []SubscriptionListResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success SubscriptionListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo SubscriptionListResponseEnvelopeResultInfo `json:"result_info"` + JSON subscriptionListResponseEnvelopeJSON `json:"-"` +} + +// subscriptionListResponseEnvelopeJSON contains the JSON metadata for the struct +// [SubscriptionListResponseEnvelope] +type subscriptionListResponseEnvelopeJSON 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 *SubscriptionListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SubscriptionListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionListResponseEnvelopeErrorsJSON `json:"-"` +} + +// subscriptionListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SubscriptionListResponseEnvelopeErrors] +type subscriptionListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SubscriptionListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionListResponseEnvelopeMessagesJSON `json:"-"` +} + +// subscriptionListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SubscriptionListResponseEnvelopeMessages] +type subscriptionListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SubscriptionListResponseEnvelopeSuccess bool + +const ( + SubscriptionListResponseEnvelopeSuccessTrue SubscriptionListResponseEnvelopeSuccess = true +) + +type SubscriptionListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON subscriptionListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// subscriptionListResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [SubscriptionListResponseEnvelopeResultInfo] +type subscriptionListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type SubscriptionDeleteResponseEnvelope struct { + Errors []SubscriptionDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []SubscriptionDeleteResponseEnvelopeMessages `json:"messages,required"` + Result SubscriptionDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success SubscriptionDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON subscriptionDeleteResponseEnvelopeJSON `json:"-"` +} + +// subscriptionDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [SubscriptionDeleteResponseEnvelope] +type subscriptionDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SubscriptionDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// subscriptionDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SubscriptionDeleteResponseEnvelopeErrors] +type subscriptionDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SubscriptionDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// subscriptionDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [SubscriptionDeleteResponseEnvelopeMessages] +type subscriptionDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SubscriptionDeleteResponseEnvelopeSuccess bool + +const ( + SubscriptionDeleteResponseEnvelopeSuccessTrue SubscriptionDeleteResponseEnvelopeSuccess = true +) + +type SubscriptionGetResponseEnvelope struct { + Errors []SubscriptionGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SubscriptionGetResponseEnvelopeMessages `json:"messages,required"` + Result SubscriptionGetResponse `json:"result,required"` + // Whether the API call was successful + Success SubscriptionGetResponseEnvelopeSuccess `json:"success,required"` + JSON subscriptionGetResponseEnvelopeJSON `json:"-"` +} + +// subscriptionGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SubscriptionGetResponseEnvelope] +type subscriptionGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SubscriptionGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// subscriptionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SubscriptionGetResponseEnvelopeErrors] +type subscriptionGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SubscriptionGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// subscriptionGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SubscriptionGetResponseEnvelopeMessages] +type subscriptionGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SubscriptionGetResponseEnvelopeSuccess bool + +const ( + SubscriptionGetResponseEnvelopeSuccessTrue SubscriptionGetResponseEnvelopeSuccess = true +) diff --git a/subscriptions/subscription_test.go b/subscriptions/subscription_test.go new file mode 100644 index 00000000000..9e2bf77d36f --- /dev/null +++ b/subscriptions/subscription_test.go @@ -0,0 +1,210 @@ +// File generated from our OpenAPI spec by Stainless. + +package subscriptions_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/subscriptions" +) + +func TestSubscriptionNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Subscriptions.New( + context.TODO(), + "506e3185e9c882d175a2d0cb0093d9f2", + subscriptions.SubscriptionNewParams{ + App: cloudflare.F(subscriptions.SubscriptionNewParamsApp{ + InstallID: cloudflare.F("string"), + }), + ComponentValues: cloudflare.F([]subscriptions.SubscriptionNewParamsComponentValue{{ + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }}), + Frequency: cloudflare.F(subscriptions.SubscriptionNewParamsFrequencyMonthly), + RatePlan: cloudflare.F(subscriptions.SubscriptionNewParamsRatePlan{ + Currency: cloudflare.F("USD"), + ExternallyManaged: cloudflare.F(false), + ID: cloudflare.F[any]("free"), + IsContract: cloudflare.F(false), + PublicName: cloudflare.F("Business Plan"), + Scope: cloudflare.F("zone"), + Sets: cloudflare.F([]string{"string", "string", "string"}), + }), + Zone: cloudflare.F(subscriptions.SubscriptionNewParamsZone{}), + }, + ) + 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 TestSubscriptionUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Subscriptions.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "506e3185e9c882d175a2d0cb0093d9f2", + subscriptions.SubscriptionUpdateParams{ + App: cloudflare.F(subscriptions.SubscriptionUpdateParamsApp{ + InstallID: cloudflare.F("string"), + }), + ComponentValues: cloudflare.F([]subscriptions.SubscriptionUpdateParamsComponentValue{{ + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }}), + Frequency: cloudflare.F(subscriptions.SubscriptionUpdateParamsFrequencyMonthly), + RatePlan: cloudflare.F(subscriptions.SubscriptionUpdateParamsRatePlan{ + Currency: cloudflare.F("USD"), + ExternallyManaged: cloudflare.F(false), + ID: cloudflare.F[any]("free"), + IsContract: cloudflare.F(false), + PublicName: cloudflare.F("Business Plan"), + Scope: cloudflare.F("zone"), + Sets: cloudflare.F([]string{"string", "string", "string"}), + }), + Zone: cloudflare.F(subscriptions.SubscriptionUpdateParamsZone{}), + }, + ) + 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 TestSubscriptionList(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("user@example.com"), + ) + _, err := client.Subscriptions.List(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()) + } +} + +func TestSubscriptionDelete(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("user@example.com"), + ) + _, err := client.Subscriptions.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "506e3185e9c882d175a2d0cb0093d9f2", + ) + 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 TestSubscriptionGet(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("user@example.com"), + ) + _, err := client.Subscriptions.Get(context.TODO(), "506e3185e9c882d175a2d0cb0093d9f2") + 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/url_normalization/aliases.go b/url_normalization/aliases.go new file mode 100644 index 00000000000..aaed74eb442 --- /dev/null +++ b/url_normalization/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package url_normalization + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/urlnormalization.go b/url_normalization/urlnormalization.go similarity index 99% rename from urlnormalization.go rename to url_normalization/urlnormalization.go index 66b84f2e5fd..030819d5401 100644 --- a/urlnormalization.go +++ b/url_normalization/urlnormalization.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package url_normalization import ( "context" diff --git a/urlnormalization_test.go b/url_normalization/urlnormalization_test.go similarity index 85% rename from urlnormalization_test.go rename to url_normalization/urlnormalization_test.go index 8c81d90e54f..6cc45f44e67 100644 --- a/urlnormalization_test.go +++ b/url_normalization/urlnormalization_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package url_normalization_test import ( "context" @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/url_normalization" ) func TestURLNormalizationUpdateWithOptionalParams(t *testing.T) { @@ -27,7 +28,7 @@ func TestURLNormalizationUpdateWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.URLNormalization.Update(context.TODO(), cloudflare.URLNormalizationUpdateParams{ + _, err := client.URLNormalization.Update(context.TODO(), url_normalization.URLNormalizationUpdateParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Scope: cloudflare.F("incoming"), Type: cloudflare.F("cloudflare"), @@ -55,7 +56,7 @@ func TestURLNormalizationGet(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.URLNormalization.Get(context.TODO(), cloudflare.URLNormalizationGetParams{ + _, err := client.URLNormalization.Get(context.TODO(), url_normalization.URLNormalizationGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { diff --git a/url_scanner/aliases.go b/url_scanner/aliases.go new file mode 100644 index 00000000000..29d6b2f9729 --- /dev/null +++ b/url_scanner/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package url_scanner + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/url_scanner/scan.go b/url_scanner/scan.go new file mode 100644 index 00000000000..2c2f7cded84 --- /dev/null +++ b/url_scanner/scan.go @@ -0,0 +1,2009 @@ +// File generated from our OpenAPI spec by Stainless. + +package url_scanner + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ScanService 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 [NewScanService] method instead. +type ScanService struct { + Options []option.RequestOption +} + +// NewScanService 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 NewScanService(opts ...option.RequestOption) (r *ScanService) { + r = &ScanService{} + r.Options = opts + return +} + +// Submit a URL to scan. You can also set some options, like the visibility level +// and custom headers. Accounts are limited to 1 new scan every 10 seconds and 8000 +// per month. If you need more, please reach out. +func (r *ScanService) New(ctx context.Context, accountID string, body ScanNewParams, opts ...option.RequestOption) (res *ScanNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env ScanNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/urlscanner/scan", accountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get URL scan by uuid +func (r *ScanService) Get(ctx context.Context, accountID string, scanID string, opts ...option.RequestOption) (res *ScanGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env ScanGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/urlscanner/scan/%s", accountID, scanID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a URL scan's HAR file. See HAR spec at +// http://www.softwareishard.com/blog/har-12-spec/. +func (r *ScanService) Har(ctx context.Context, accountID string, scanID string, opts ...option.RequestOption) (res *ScanHarResponse, err error) { + opts = append(r.Options[:], opts...) + var env ScanHarResponseEnvelope + path := fmt.Sprintf("accounts/%s/urlscanner/scan/%s/har", accountID, scanID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get scan's screenshot by resolution (desktop/mobile/tablet). +func (r *ScanService) Screenshot(ctx context.Context, accountID string, scanID string, query ScanScreenshotParams, opts ...option.RequestOption) (res *http.Response, err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "image/png")}, opts...) + path := fmt.Sprintf("accounts/%s/urlscanner/scan/%s/screenshot", accountID, scanID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +type ScanNewResponse struct { + // Time when url was submitted for scanning. + Time time.Time `json:"time,required" format:"date-time"` + // Canonical form of submitted URL. Use this if you want to later search by URL. + URL string `json:"url,required"` + // Scan ID. + UUID string `json:"uuid,required" format:"uuid"` + // Submitted visibility status. + Visibility string `json:"visibility,required"` + JSON scanNewResponseJSON `json:"-"` +} + +// scanNewResponseJSON contains the JSON metadata for the struct [ScanNewResponse] +type scanNewResponseJSON struct { + Time apijson.Field + URL apijson.Field + UUID apijson.Field + Visibility apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanNewResponseJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponse struct { + Scan ScanGetResponseScan `json:"scan,required"` + JSON scanGetResponseJSON `json:"-"` +} + +// scanGetResponseJSON contains the JSON metadata for the struct [ScanGetResponse] +type scanGetResponseJSON struct { + Scan apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScan struct { + Certificates []ScanGetResponseScanCertificate `json:"certificates,required"` + Geo ScanGetResponseScanGeo `json:"geo,required"` + Meta ScanGetResponseScanMeta `json:"meta,required"` + Page ScanGetResponseScanPage `json:"page,required"` + Performance []ScanGetResponseScanPerformance `json:"performance,required"` + Task ScanGetResponseScanTask `json:"task,required"` + Verdicts ScanGetResponseScanVerdicts `json:"verdicts,required"` + // Dictionary of Autonomous System Numbers where ASN's are the keys + ASNs ScanGetResponseScanASNs `json:"asns"` + Domains ScanGetResponseScanDomains `json:"domains"` + IPs ScanGetResponseScanIPs `json:"ips"` + Links ScanGetResponseScanLinks `json:"links"` + JSON scanGetResponseScanJSON `json:"-"` +} + +// scanGetResponseScanJSON contains the JSON metadata for the struct +// [ScanGetResponseScan] +type scanGetResponseScanJSON struct { + Certificates apijson.Field + Geo apijson.Field + Meta apijson.Field + Page apijson.Field + Performance apijson.Field + Task apijson.Field + Verdicts apijson.Field + ASNs apijson.Field + Domains apijson.Field + IPs apijson.Field + Links apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScan) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanCertificate struct { + Issuer string `json:"issuer,required"` + SubjectName string `json:"subjectName,required"` + ValidFrom float64 `json:"validFrom,required"` + ValidTo float64 `json:"validTo,required"` + JSON scanGetResponseScanCertificateJSON `json:"-"` +} + +// scanGetResponseScanCertificateJSON contains the JSON metadata for the struct +// [ScanGetResponseScanCertificate] +type scanGetResponseScanCertificateJSON struct { + Issuer apijson.Field + SubjectName apijson.Field + ValidFrom apijson.Field + ValidTo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanCertificate) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanCertificateJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanGeo struct { + // GeoIP continent location + Continents []string `json:"continents,required"` + // GeoIP country location + Locations []string `json:"locations,required"` + JSON scanGetResponseScanGeoJSON `json:"-"` +} + +// scanGetResponseScanGeoJSON contains the JSON metadata for the struct +// [ScanGetResponseScanGeo] +type scanGetResponseScanGeoJSON struct { + Continents apijson.Field + Locations apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanGeo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanGeoJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanMeta struct { + Processors ScanGetResponseScanMetaProcessors `json:"processors,required"` + JSON scanGetResponseScanMetaJSON `json:"-"` +} + +// scanGetResponseScanMetaJSON contains the JSON metadata for the struct +// [ScanGetResponseScanMeta] +type scanGetResponseScanMetaJSON struct { + Processors apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanMeta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanMetaJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanMetaProcessors struct { + Categories ScanGetResponseScanMetaProcessorsCategories `json:"categories,required"` + Phishing []string `json:"phishing,required"` + Rank ScanGetResponseScanMetaProcessorsRank `json:"rank,required"` + Tech []ScanGetResponseScanMetaProcessorsTech `json:"tech,required"` + JSON scanGetResponseScanMetaProcessorsJSON `json:"-"` +} + +// scanGetResponseScanMetaProcessorsJSON contains the JSON metadata for the struct +// [ScanGetResponseScanMetaProcessors] +type scanGetResponseScanMetaProcessorsJSON struct { + Categories apijson.Field + Phishing apijson.Field + Rank apijson.Field + Tech apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanMetaProcessors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanMetaProcessorsJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanMetaProcessorsCategories struct { + Content []ScanGetResponseScanMetaProcessorsCategoriesContent `json:"content,required"` + Risks []ScanGetResponseScanMetaProcessorsCategoriesRisk `json:"risks,required"` + JSON scanGetResponseScanMetaProcessorsCategoriesJSON `json:"-"` +} + +// scanGetResponseScanMetaProcessorsCategoriesJSON contains the JSON metadata for +// the struct [ScanGetResponseScanMetaProcessorsCategories] +type scanGetResponseScanMetaProcessorsCategoriesJSON struct { + Content apijson.Field + Risks apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanMetaProcessorsCategories) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanMetaProcessorsCategoriesJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanMetaProcessorsCategoriesContent struct { + ID int64 `json:"id,required"` + Name string `json:"name,required"` + SuperCategoryID int64 `json:"super_category_id"` + JSON scanGetResponseScanMetaProcessorsCategoriesContentJSON `json:"-"` +} + +// scanGetResponseScanMetaProcessorsCategoriesContentJSON contains the JSON +// metadata for the struct [ScanGetResponseScanMetaProcessorsCategoriesContent] +type scanGetResponseScanMetaProcessorsCategoriesContentJSON struct { + ID apijson.Field + Name apijson.Field + SuperCategoryID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanMetaProcessorsCategoriesContent) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanMetaProcessorsCategoriesContentJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanMetaProcessorsCategoriesRisk struct { + ID int64 `json:"id,required"` + Name string `json:"name,required"` + SuperCategoryID int64 `json:"super_category_id,required"` + JSON scanGetResponseScanMetaProcessorsCategoriesRiskJSON `json:"-"` +} + +// scanGetResponseScanMetaProcessorsCategoriesRiskJSON contains the JSON metadata +// for the struct [ScanGetResponseScanMetaProcessorsCategoriesRisk] +type scanGetResponseScanMetaProcessorsCategoriesRiskJSON struct { + ID apijson.Field + Name apijson.Field + SuperCategoryID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanMetaProcessorsCategoriesRisk) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanMetaProcessorsCategoriesRiskJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanMetaProcessorsRank struct { + Bucket string `json:"bucket,required"` + Name string `json:"name,required"` + // Rank in the Global Radar Rank, if set. See more at + // https://blog.cloudflare.com/radar-domain-rankings/ + Rank int64 `json:"rank"` + JSON scanGetResponseScanMetaProcessorsRankJSON `json:"-"` +} + +// scanGetResponseScanMetaProcessorsRankJSON contains the JSON metadata for the +// struct [ScanGetResponseScanMetaProcessorsRank] +type scanGetResponseScanMetaProcessorsRankJSON struct { + Bucket apijson.Field + Name apijson.Field + Rank apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanMetaProcessorsRank) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanMetaProcessorsRankJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanMetaProcessorsTech struct { + Categories []ScanGetResponseScanMetaProcessorsTechCategory `json:"categories,required"` + Confidence int64 `json:"confidence,required"` + Evidence ScanGetResponseScanMetaProcessorsTechEvidence `json:"evidence,required"` + Icon string `json:"icon,required"` + Name string `json:"name,required"` + Slug string `json:"slug,required"` + Website string `json:"website,required"` + Description string `json:"description"` + JSON scanGetResponseScanMetaProcessorsTechJSON `json:"-"` +} + +// scanGetResponseScanMetaProcessorsTechJSON contains the JSON metadata for the +// struct [ScanGetResponseScanMetaProcessorsTech] +type scanGetResponseScanMetaProcessorsTechJSON struct { + Categories apijson.Field + Confidence apijson.Field + Evidence apijson.Field + Icon apijson.Field + Name apijson.Field + Slug apijson.Field + Website apijson.Field + Description apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanMetaProcessorsTech) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanMetaProcessorsTechJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanMetaProcessorsTechCategory struct { + ID int64 `json:"id,required"` + Groups []int64 `json:"groups,required"` + Name string `json:"name,required"` + Priority int64 `json:"priority,required"` + Slug string `json:"slug,required"` + JSON scanGetResponseScanMetaProcessorsTechCategoryJSON `json:"-"` +} + +// scanGetResponseScanMetaProcessorsTechCategoryJSON contains the JSON metadata for +// the struct [ScanGetResponseScanMetaProcessorsTechCategory] +type scanGetResponseScanMetaProcessorsTechCategoryJSON struct { + ID apijson.Field + Groups apijson.Field + Name apijson.Field + Priority apijson.Field + Slug apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanMetaProcessorsTechCategory) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanMetaProcessorsTechCategoryJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanMetaProcessorsTechEvidence struct { + ImpliedBy []string `json:"impliedBy,required"` + Patterns []ScanGetResponseScanMetaProcessorsTechEvidencePattern `json:"patterns,required"` + JSON scanGetResponseScanMetaProcessorsTechEvidenceJSON `json:"-"` +} + +// scanGetResponseScanMetaProcessorsTechEvidenceJSON contains the JSON metadata for +// the struct [ScanGetResponseScanMetaProcessorsTechEvidence] +type scanGetResponseScanMetaProcessorsTechEvidenceJSON struct { + ImpliedBy apijson.Field + Patterns apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanMetaProcessorsTechEvidence) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanMetaProcessorsTechEvidenceJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanMetaProcessorsTechEvidencePattern struct { + Confidence int64 `json:"confidence,required"` + Excludes []string `json:"excludes,required"` + Implies []string `json:"implies,required"` + Match string `json:"match,required"` + // Header or Cookie name when set + Name string `json:"name,required"` + Regex string `json:"regex,required"` + Type string `json:"type,required"` + Value string `json:"value,required"` + Version string `json:"version,required"` + JSON scanGetResponseScanMetaProcessorsTechEvidencePatternJSON `json:"-"` +} + +// scanGetResponseScanMetaProcessorsTechEvidencePatternJSON contains the JSON +// metadata for the struct [ScanGetResponseScanMetaProcessorsTechEvidencePattern] +type scanGetResponseScanMetaProcessorsTechEvidencePatternJSON struct { + Confidence apijson.Field + Excludes apijson.Field + Implies apijson.Field + Match apijson.Field + Name apijson.Field + Regex apijson.Field + Type apijson.Field + Value apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanMetaProcessorsTechEvidencePattern) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanMetaProcessorsTechEvidencePatternJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanPage struct { + ASN string `json:"asn,required"` + ASNLocationAlpha2 string `json:"asnLocationAlpha2,required"` + Asnname string `json:"asnname,required"` + Console []ScanGetResponseScanPageConsole `json:"console,required"` + Cookies []ScanGetResponseScanPageCooky `json:"cookies,required"` + Country string `json:"country,required"` + CountryLocationAlpha2 string `json:"countryLocationAlpha2,required"` + Domain string `json:"domain,required"` + Headers []ScanGetResponseScanPageHeader `json:"headers,required"` + IP string `json:"ip,required"` + Js ScanGetResponseScanPageJs `json:"js,required"` + SecurityViolations []ScanGetResponseScanPageSecurityViolation `json:"securityViolations,required"` + Status float64 `json:"status,required"` + Subdivision1Name string `json:"subdivision1Name,required"` + Subdivision2name string `json:"subdivision2name,required"` + URL string `json:"url,required"` + JSON scanGetResponseScanPageJSON `json:"-"` +} + +// scanGetResponseScanPageJSON contains the JSON metadata for the struct +// [ScanGetResponseScanPage] +type scanGetResponseScanPageJSON struct { + ASN apijson.Field + ASNLocationAlpha2 apijson.Field + Asnname apijson.Field + Console apijson.Field + Cookies apijson.Field + Country apijson.Field + CountryLocationAlpha2 apijson.Field + Domain apijson.Field + Headers apijson.Field + IP apijson.Field + Js apijson.Field + SecurityViolations apijson.Field + Status apijson.Field + Subdivision1Name apijson.Field + Subdivision2name apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanPage) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanPageJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanPageConsole struct { + Category string `json:"category,required"` + Text string `json:"text,required"` + Type string `json:"type,required"` + URL string `json:"url"` + JSON scanGetResponseScanPageConsoleJSON `json:"-"` +} + +// scanGetResponseScanPageConsoleJSON contains the JSON metadata for the struct +// [ScanGetResponseScanPageConsole] +type scanGetResponseScanPageConsoleJSON struct { + Category apijson.Field + Text apijson.Field + Type apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanPageConsole) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanPageConsoleJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanPageCooky struct { + Domain string `json:"domain,required"` + Expires float64 `json:"expires,required"` + HTTPOnly bool `json:"httpOnly,required"` + Name string `json:"name,required"` + Path string `json:"path,required"` + SameParty bool `json:"sameParty,required"` + Secure bool `json:"secure,required"` + Session bool `json:"session,required"` + Size float64 `json:"size,required"` + SourcePort float64 `json:"sourcePort,required"` + SourceScheme string `json:"sourceScheme,required"` + Value string `json:"value,required"` + Priority string `json:"priority"` + JSON scanGetResponseScanPageCookyJSON `json:"-"` +} + +// scanGetResponseScanPageCookyJSON contains the JSON metadata for the struct +// [ScanGetResponseScanPageCooky] +type scanGetResponseScanPageCookyJSON struct { + Domain apijson.Field + Expires apijson.Field + HTTPOnly apijson.Field + Name apijson.Field + Path apijson.Field + SameParty apijson.Field + Secure apijson.Field + Session apijson.Field + Size apijson.Field + SourcePort apijson.Field + SourceScheme apijson.Field + Value apijson.Field + Priority apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanPageCooky) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanPageCookyJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanPageHeader struct { + Name string `json:"name,required"` + Value string `json:"value,required"` + JSON scanGetResponseScanPageHeaderJSON `json:"-"` +} + +// scanGetResponseScanPageHeaderJSON contains the JSON metadata for the struct +// [ScanGetResponseScanPageHeader] +type scanGetResponseScanPageHeaderJSON struct { + Name apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanPageHeader) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanPageHeaderJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanPageJs struct { + Variables []ScanGetResponseScanPageJsVariable `json:"variables,required"` + JSON scanGetResponseScanPageJsJSON `json:"-"` +} + +// scanGetResponseScanPageJsJSON contains the JSON metadata for the struct +// [ScanGetResponseScanPageJs] +type scanGetResponseScanPageJsJSON struct { + Variables apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanPageJs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanPageJsJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanPageJsVariable struct { + Name string `json:"name,required"` + Type string `json:"type,required"` + JSON scanGetResponseScanPageJsVariableJSON `json:"-"` +} + +// scanGetResponseScanPageJsVariableJSON contains the JSON metadata for the struct +// [ScanGetResponseScanPageJsVariable] +type scanGetResponseScanPageJsVariableJSON struct { + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanPageJsVariable) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanPageJsVariableJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanPageSecurityViolation struct { + Category string `json:"category,required"` + Text string `json:"text,required"` + URL string `json:"url,required"` + JSON scanGetResponseScanPageSecurityViolationJSON `json:"-"` +} + +// scanGetResponseScanPageSecurityViolationJSON contains the JSON metadata for the +// struct [ScanGetResponseScanPageSecurityViolation] +type scanGetResponseScanPageSecurityViolationJSON struct { + Category apijson.Field + Text apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanPageSecurityViolation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanPageSecurityViolationJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanPerformance struct { + ConnectEnd float64 `json:"connectEnd,required"` + ConnectStart float64 `json:"connectStart,required"` + DecodedBodySize float64 `json:"decodedBodySize,required"` + DomainLookupEnd float64 `json:"domainLookupEnd,required"` + DomainLookupStart float64 `json:"domainLookupStart,required"` + DomComplete float64 `json:"domComplete,required"` + DomContentLoadedEventEnd float64 `json:"domContentLoadedEventEnd,required"` + DomContentLoadedEventStart float64 `json:"domContentLoadedEventStart,required"` + DomInteractive float64 `json:"domInteractive,required"` + Duration float64 `json:"duration,required"` + EncodedBodySize float64 `json:"encodedBodySize,required"` + EntryType string `json:"entryType,required"` + FetchStart float64 `json:"fetchStart,required"` + InitiatorType string `json:"initiatorType,required"` + LoadEventEnd float64 `json:"loadEventEnd,required"` + LoadEventStart float64 `json:"loadEventStart,required"` + Name string `json:"name,required"` + NextHopProtocol string `json:"nextHopProtocol,required"` + RedirectCount float64 `json:"redirectCount,required"` + RedirectEnd float64 `json:"redirectEnd,required"` + RedirectStart float64 `json:"redirectStart,required"` + RequestStart float64 `json:"requestStart,required"` + ResponseEnd float64 `json:"responseEnd,required"` + ResponseStart float64 `json:"responseStart,required"` + SecureConnectionStart float64 `json:"secureConnectionStart,required"` + StartTime float64 `json:"startTime,required"` + TransferSize float64 `json:"transferSize,required"` + Type string `json:"type,required"` + UnloadEventEnd float64 `json:"unloadEventEnd,required"` + UnloadEventStart float64 `json:"unloadEventStart,required"` + WorkerStart float64 `json:"workerStart,required"` + JSON scanGetResponseScanPerformanceJSON `json:"-"` +} + +// scanGetResponseScanPerformanceJSON contains the JSON metadata for the struct +// [ScanGetResponseScanPerformance] +type scanGetResponseScanPerformanceJSON struct { + ConnectEnd apijson.Field + ConnectStart apijson.Field + DecodedBodySize apijson.Field + DomainLookupEnd apijson.Field + DomainLookupStart apijson.Field + DomComplete apijson.Field + DomContentLoadedEventEnd apijson.Field + DomContentLoadedEventStart apijson.Field + DomInteractive apijson.Field + Duration apijson.Field + EncodedBodySize apijson.Field + EntryType apijson.Field + FetchStart apijson.Field + InitiatorType apijson.Field + LoadEventEnd apijson.Field + LoadEventStart apijson.Field + Name apijson.Field + NextHopProtocol apijson.Field + RedirectCount apijson.Field + RedirectEnd apijson.Field + RedirectStart apijson.Field + RequestStart apijson.Field + ResponseEnd apijson.Field + ResponseStart apijson.Field + SecureConnectionStart apijson.Field + StartTime apijson.Field + TransferSize apijson.Field + Type apijson.Field + UnloadEventEnd apijson.Field + UnloadEventStart apijson.Field + WorkerStart apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanPerformance) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanPerformanceJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanTask struct { + // Submitter location + ClientLocation string `json:"clientLocation,required"` + ClientType ScanGetResponseScanTaskClientType `json:"clientType,required"` + // URL of the primary request, after all HTTP redirects + EffectiveURL string `json:"effectiveUrl,required"` + Errors []ScanGetResponseScanTaskError `json:"errors,required"` + ScannedFrom ScanGetResponseScanTaskScannedFrom `json:"scannedFrom,required"` + Status ScanGetResponseScanTaskStatus `json:"status,required"` + Success bool `json:"success,required"` + Time string `json:"time,required"` + TimeEnd string `json:"timeEnd,required"` + // Submitted URL + URL string `json:"url,required"` + // Scan ID + UUID string `json:"uuid,required"` + Visibility ScanGetResponseScanTaskVisibility `json:"visibility,required"` + JSON scanGetResponseScanTaskJSON `json:"-"` +} + +// scanGetResponseScanTaskJSON contains the JSON metadata for the struct +// [ScanGetResponseScanTask] +type scanGetResponseScanTaskJSON struct { + ClientLocation apijson.Field + ClientType apijson.Field + EffectiveURL apijson.Field + Errors apijson.Field + ScannedFrom apijson.Field + Status apijson.Field + Success apijson.Field + Time apijson.Field + TimeEnd apijson.Field + URL apijson.Field + UUID apijson.Field + Visibility apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanTask) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanTaskJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanTaskClientType string + +const ( + ScanGetResponseScanTaskClientTypeSite ScanGetResponseScanTaskClientType = "Site" + ScanGetResponseScanTaskClientTypeAutomatic ScanGetResponseScanTaskClientType = "Automatic" + ScanGetResponseScanTaskClientTypeAPI ScanGetResponseScanTaskClientType = "Api" +) + +type ScanGetResponseScanTaskError struct { + Message string `json:"message,required"` + JSON scanGetResponseScanTaskErrorJSON `json:"-"` +} + +// scanGetResponseScanTaskErrorJSON contains the JSON metadata for the struct +// [ScanGetResponseScanTaskError] +type scanGetResponseScanTaskErrorJSON struct { + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanTaskError) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanTaskErrorJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanTaskScannedFrom struct { + // IATA code of Cloudflare datacenter + Colo string `json:"colo,required"` + JSON scanGetResponseScanTaskScannedFromJSON `json:"-"` +} + +// scanGetResponseScanTaskScannedFromJSON contains the JSON metadata for the struct +// [ScanGetResponseScanTaskScannedFrom] +type scanGetResponseScanTaskScannedFromJSON struct { + Colo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanTaskScannedFrom) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanTaskScannedFromJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanTaskStatus string + +const ( + ScanGetResponseScanTaskStatusQueued ScanGetResponseScanTaskStatus = "Queued" + ScanGetResponseScanTaskStatusInProgress ScanGetResponseScanTaskStatus = "InProgress" + ScanGetResponseScanTaskStatusInPostProcessing ScanGetResponseScanTaskStatus = "InPostProcessing" + ScanGetResponseScanTaskStatusFinished ScanGetResponseScanTaskStatus = "Finished" +) + +type ScanGetResponseScanTaskVisibility string + +const ( + ScanGetResponseScanTaskVisibilityPublic ScanGetResponseScanTaskVisibility = "Public" + ScanGetResponseScanTaskVisibilityUnlisted ScanGetResponseScanTaskVisibility = "Unlisted" +) + +type ScanGetResponseScanVerdicts struct { + Overall ScanGetResponseScanVerdictsOverall `json:"overall,required"` + JSON scanGetResponseScanVerdictsJSON `json:"-"` +} + +// scanGetResponseScanVerdictsJSON contains the JSON metadata for the struct +// [ScanGetResponseScanVerdicts] +type scanGetResponseScanVerdictsJSON struct { + Overall apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanVerdicts) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanVerdictsJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanVerdictsOverall struct { + Categories []ScanGetResponseScanVerdictsOverallCategory `json:"categories,required"` + // At least one of our subsystems marked the site as potentially malicious at the + // time of the scan. + Malicious bool `json:"malicious,required"` + Phishing []string `json:"phishing,required"` + JSON scanGetResponseScanVerdictsOverallJSON `json:"-"` +} + +// scanGetResponseScanVerdictsOverallJSON contains the JSON metadata for the struct +// [ScanGetResponseScanVerdictsOverall] +type scanGetResponseScanVerdictsOverallJSON struct { + Categories apijson.Field + Malicious apijson.Field + Phishing apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanVerdictsOverall) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanVerdictsOverallJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanVerdictsOverallCategory struct { + ID float64 `json:"id,required"` + Name string `json:"name,required"` + SuperCategoryID float64 `json:"super_category_id,required"` + JSON scanGetResponseScanVerdictsOverallCategoryJSON `json:"-"` +} + +// scanGetResponseScanVerdictsOverallCategoryJSON contains the JSON metadata for +// the struct [ScanGetResponseScanVerdictsOverallCategory] +type scanGetResponseScanVerdictsOverallCategoryJSON struct { + ID apijson.Field + Name apijson.Field + SuperCategoryID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanVerdictsOverallCategory) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanVerdictsOverallCategoryJSON) RawJSON() string { + return r.raw +} + +// Dictionary of Autonomous System Numbers where ASN's are the keys +type ScanGetResponseScanASNs struct { + // ASN's contacted + ASN ScanGetResponseScanASNsASN `json:"asn"` + JSON scanGetResponseScanASNsJSON `json:"-"` +} + +// scanGetResponseScanASNsJSON contains the JSON metadata for the struct +// [ScanGetResponseScanASNs] +type scanGetResponseScanASNsJSON struct { + ASN apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanASNs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanASNsJSON) RawJSON() string { + return r.raw +} + +// ASN's contacted +type ScanGetResponseScanASNsASN struct { + ASN string `json:"asn,required"` + Description string `json:"description,required"` + LocationAlpha2 string `json:"location_alpha2,required"` + Name string `json:"name,required"` + OrgName string `json:"org_name,required"` + JSON scanGetResponseScanASNsASNJSON `json:"-"` +} + +// scanGetResponseScanASNsASNJSON contains the JSON metadata for the struct +// [ScanGetResponseScanASNsASN] +type scanGetResponseScanASNsASNJSON struct { + ASN apijson.Field + Description apijson.Field + LocationAlpha2 apijson.Field + Name apijson.Field + OrgName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanASNsASN) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanASNsASNJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanDomains struct { + ExampleCom ScanGetResponseScanDomainsExampleCom `json:"example.com"` + JSON scanGetResponseScanDomainsJSON `json:"-"` +} + +// scanGetResponseScanDomainsJSON contains the JSON metadata for the struct +// [ScanGetResponseScanDomains] +type scanGetResponseScanDomainsJSON struct { + ExampleCom apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanDomains) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanDomainsJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanDomainsExampleCom struct { + Categories ScanGetResponseScanDomainsExampleComCategories `json:"categories,required"` + DNS []ScanGetResponseScanDomainsExampleComDNS `json:"dns,required"` + Name string `json:"name,required"` + Rank ScanGetResponseScanDomainsExampleComRank `json:"rank,required"` + Type string `json:"type,required"` + JSON scanGetResponseScanDomainsExampleComJSON `json:"-"` +} + +// scanGetResponseScanDomainsExampleComJSON contains the JSON metadata for the +// struct [ScanGetResponseScanDomainsExampleCom] +type scanGetResponseScanDomainsExampleComJSON struct { + Categories apijson.Field + DNS apijson.Field + Name apijson.Field + Rank apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanDomainsExampleCom) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanDomainsExampleComJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanDomainsExampleComCategories struct { + Inherited ScanGetResponseScanDomainsExampleComCategoriesInherited `json:"inherited,required"` + Content []ScanGetResponseScanDomainsExampleComCategoriesContent `json:"content"` + Risks []ScanGetResponseScanDomainsExampleComCategoriesRisk `json:"risks"` + JSON scanGetResponseScanDomainsExampleComCategoriesJSON `json:"-"` +} + +// scanGetResponseScanDomainsExampleComCategoriesJSON contains the JSON metadata +// for the struct [ScanGetResponseScanDomainsExampleComCategories] +type scanGetResponseScanDomainsExampleComCategoriesJSON struct { + Inherited apijson.Field + Content apijson.Field + Risks apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanDomainsExampleComCategories) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanDomainsExampleComCategoriesJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanDomainsExampleComCategoriesInherited struct { + Content []ScanGetResponseScanDomainsExampleComCategoriesInheritedContent `json:"content"` + From string `json:"from"` + Risks []ScanGetResponseScanDomainsExampleComCategoriesInheritedRisk `json:"risks"` + JSON scanGetResponseScanDomainsExampleComCategoriesInheritedJSON `json:"-"` +} + +// scanGetResponseScanDomainsExampleComCategoriesInheritedJSON contains the JSON +// metadata for the struct +// [ScanGetResponseScanDomainsExampleComCategoriesInherited] +type scanGetResponseScanDomainsExampleComCategoriesInheritedJSON struct { + Content apijson.Field + From apijson.Field + Risks apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanDomainsExampleComCategoriesInherited) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanDomainsExampleComCategoriesInheritedJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanDomainsExampleComCategoriesInheritedContent struct { + ID int64 `json:"id,required"` + Name string `json:"name,required"` + SuperCategoryID int64 `json:"super_category_id"` + JSON scanGetResponseScanDomainsExampleComCategoriesInheritedContentJSON `json:"-"` +} + +// scanGetResponseScanDomainsExampleComCategoriesInheritedContentJSON contains the +// JSON metadata for the struct +// [ScanGetResponseScanDomainsExampleComCategoriesInheritedContent] +type scanGetResponseScanDomainsExampleComCategoriesInheritedContentJSON struct { + ID apijson.Field + Name apijson.Field + SuperCategoryID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanDomainsExampleComCategoriesInheritedContent) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanDomainsExampleComCategoriesInheritedContentJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanDomainsExampleComCategoriesInheritedRisk struct { + ID int64 `json:"id,required"` + Name string `json:"name,required"` + SuperCategoryID int64 `json:"super_category_id"` + JSON scanGetResponseScanDomainsExampleComCategoriesInheritedRiskJSON `json:"-"` +} + +// scanGetResponseScanDomainsExampleComCategoriesInheritedRiskJSON contains the +// JSON metadata for the struct +// [ScanGetResponseScanDomainsExampleComCategoriesInheritedRisk] +type scanGetResponseScanDomainsExampleComCategoriesInheritedRiskJSON struct { + ID apijson.Field + Name apijson.Field + SuperCategoryID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanDomainsExampleComCategoriesInheritedRisk) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanDomainsExampleComCategoriesInheritedRiskJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanDomainsExampleComCategoriesContent struct { + ID int64 `json:"id,required"` + Name string `json:"name,required"` + SuperCategoryID int64 `json:"super_category_id"` + JSON scanGetResponseScanDomainsExampleComCategoriesContentJSON `json:"-"` +} + +// scanGetResponseScanDomainsExampleComCategoriesContentJSON contains the JSON +// metadata for the struct [ScanGetResponseScanDomainsExampleComCategoriesContent] +type scanGetResponseScanDomainsExampleComCategoriesContentJSON struct { + ID apijson.Field + Name apijson.Field + SuperCategoryID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanDomainsExampleComCategoriesContent) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanDomainsExampleComCategoriesContentJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanDomainsExampleComCategoriesRisk struct { + ID int64 `json:"id,required"` + Name string `json:"name,required"` + SuperCategoryID int64 `json:"super_category_id"` + JSON scanGetResponseScanDomainsExampleComCategoriesRiskJSON `json:"-"` +} + +// scanGetResponseScanDomainsExampleComCategoriesRiskJSON contains the JSON +// metadata for the struct [ScanGetResponseScanDomainsExampleComCategoriesRisk] +type scanGetResponseScanDomainsExampleComCategoriesRiskJSON struct { + ID apijson.Field + Name apijson.Field + SuperCategoryID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanDomainsExampleComCategoriesRisk) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanDomainsExampleComCategoriesRiskJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanDomainsExampleComDNS struct { + Address string `json:"address,required"` + DNSSECValid bool `json:"dnssec_valid,required"` + Name string `json:"name,required"` + Type string `json:"type,required"` + JSON scanGetResponseScanDomainsExampleComDNSJSON `json:"-"` +} + +// scanGetResponseScanDomainsExampleComDNSJSON contains the JSON metadata for the +// struct [ScanGetResponseScanDomainsExampleComDNS] +type scanGetResponseScanDomainsExampleComDNSJSON struct { + Address apijson.Field + DNSSECValid apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanDomainsExampleComDNS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanDomainsExampleComDNSJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanDomainsExampleComRank struct { + Bucket string `json:"bucket,required"` + Name string `json:"name,required"` + // Rank in the Global Radar Rank, if set. See more at + // https://blog.cloudflare.com/radar-domain-rankings/ + Rank int64 `json:"rank"` + JSON scanGetResponseScanDomainsExampleComRankJSON `json:"-"` +} + +// scanGetResponseScanDomainsExampleComRankJSON contains the JSON metadata for the +// struct [ScanGetResponseScanDomainsExampleComRank] +type scanGetResponseScanDomainsExampleComRankJSON struct { + Bucket apijson.Field + Name apijson.Field + Rank apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanDomainsExampleComRank) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanDomainsExampleComRankJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanIPs struct { + IP ScanGetResponseScanIPsIP `json:"ip"` + JSON scanGetResponseScanIPsJSON `json:"-"` +} + +// scanGetResponseScanIPsJSON contains the JSON metadata for the struct +// [ScanGetResponseScanIPs] +type scanGetResponseScanIPsJSON struct { + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanIPs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanIPsJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanIPsIP struct { + ASN string `json:"asn,required"` + ASNDescription string `json:"asnDescription,required"` + ASNLocationAlpha2 string `json:"asnLocationAlpha2,required"` + ASNName string `json:"asnName,required"` + ASNOrgName string `json:"asnOrgName,required"` + Continent string `json:"continent,required"` + GeonameID string `json:"geonameId,required"` + IP string `json:"ip,required"` + IPVersion string `json:"ipVersion,required"` + Latitude string `json:"latitude,required"` + LocationAlpha2 string `json:"locationAlpha2,required"` + LocationName string `json:"locationName,required"` + Longitude string `json:"longitude,required"` + Subdivision1Name string `json:"subdivision1Name,required"` + Subdivision2Name string `json:"subdivision2Name,required"` + JSON scanGetResponseScanIPsIPJSON `json:"-"` +} + +// scanGetResponseScanIPsIPJSON contains the JSON metadata for the struct +// [ScanGetResponseScanIPsIP] +type scanGetResponseScanIPsIPJSON struct { + ASN apijson.Field + ASNDescription apijson.Field + ASNLocationAlpha2 apijson.Field + ASNName apijson.Field + ASNOrgName apijson.Field + Continent apijson.Field + GeonameID apijson.Field + IP apijson.Field + IPVersion apijson.Field + Latitude apijson.Field + LocationAlpha2 apijson.Field + LocationName apijson.Field + Longitude apijson.Field + Subdivision1Name apijson.Field + Subdivision2Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanIPsIP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanIPsIPJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanLinks struct { + Link ScanGetResponseScanLinksLink `json:"link"` + JSON scanGetResponseScanLinksJSON `json:"-"` +} + +// scanGetResponseScanLinksJSON contains the JSON metadata for the struct +// [ScanGetResponseScanLinks] +type scanGetResponseScanLinksJSON struct { + Link apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanLinks) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanLinksJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseScanLinksLink struct { + // Outgoing link detected in the DOM + Href string `json:"href,required"` + Text string `json:"text,required"` + JSON scanGetResponseScanLinksLinkJSON `json:"-"` +} + +// scanGetResponseScanLinksLinkJSON contains the JSON metadata for the struct +// [ScanGetResponseScanLinksLink] +type scanGetResponseScanLinksLinkJSON struct { + Href apijson.Field + Text apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseScanLinksLink) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseScanLinksLinkJSON) RawJSON() string { + return r.raw +} + +type ScanHarResponse struct { + Har ScanHarResponseHar `json:"har,required"` + JSON scanHarResponseJSON `json:"-"` +} + +// scanHarResponseJSON contains the JSON metadata for the struct [ScanHarResponse] +type scanHarResponseJSON struct { + Har apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanHarResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanHarResponseJSON) RawJSON() string { + return r.raw +} + +type ScanHarResponseHar struct { + Log ScanHarResponseHarLog `json:"log,required"` + JSON scanHarResponseHarJSON `json:"-"` +} + +// scanHarResponseHarJSON contains the JSON metadata for the struct +// [ScanHarResponseHar] +type scanHarResponseHarJSON struct { + Log apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanHarResponseHar) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanHarResponseHarJSON) RawJSON() string { + return r.raw +} + +type ScanHarResponseHarLog struct { + Creator ScanHarResponseHarLogCreator `json:"creator,required"` + Entries []ScanHarResponseHarLogEntry `json:"entries,required"` + Pages []ScanHarResponseHarLogPage `json:"pages,required"` + Version string `json:"version,required"` + JSON scanHarResponseHarLogJSON `json:"-"` +} + +// scanHarResponseHarLogJSON contains the JSON metadata for the struct +// [ScanHarResponseHarLog] +type scanHarResponseHarLogJSON struct { + Creator apijson.Field + Entries apijson.Field + Pages apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanHarResponseHarLog) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanHarResponseHarLogJSON) RawJSON() string { + return r.raw +} + +type ScanHarResponseHarLogCreator struct { + Comment string `json:"comment,required"` + Name string `json:"name,required"` + Version string `json:"version,required"` + JSON scanHarResponseHarLogCreatorJSON `json:"-"` +} + +// scanHarResponseHarLogCreatorJSON contains the JSON metadata for the struct +// [ScanHarResponseHarLogCreator] +type scanHarResponseHarLogCreatorJSON struct { + Comment apijson.Field + Name apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanHarResponseHarLogCreator) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanHarResponseHarLogCreatorJSON) RawJSON() string { + return r.raw +} + +type ScanHarResponseHarLogEntry struct { + InitialPriority string `json:"_initialPriority,required"` + InitiatorType string `json:"_initiator_type,required"` + Priority string `json:"_priority,required"` + RequestID string `json:"_requestId,required"` + RequestTime float64 `json:"_requestTime,required"` + ResourceType string `json:"_resourceType,required"` + Cache interface{} `json:"cache,required"` + Connection string `json:"connection,required"` + Pageref string `json:"pageref,required"` + Request ScanHarResponseHarLogEntriesRequest `json:"request,required"` + Response ScanHarResponseHarLogEntriesResponse `json:"response,required"` + ServerIPAddress string `json:"serverIPAddress,required"` + StartedDateTime string `json:"startedDateTime,required"` + Time float64 `json:"time,required"` + JSON scanHarResponseHarLogEntryJSON `json:"-"` +} + +// scanHarResponseHarLogEntryJSON contains the JSON metadata for the struct +// [ScanHarResponseHarLogEntry] +type scanHarResponseHarLogEntryJSON struct { + InitialPriority apijson.Field + InitiatorType apijson.Field + Priority apijson.Field + RequestID apijson.Field + RequestTime apijson.Field + ResourceType apijson.Field + Cache apijson.Field + Connection apijson.Field + Pageref apijson.Field + Request apijson.Field + Response apijson.Field + ServerIPAddress apijson.Field + StartedDateTime apijson.Field + Time apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanHarResponseHarLogEntry) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanHarResponseHarLogEntryJSON) RawJSON() string { + return r.raw +} + +type ScanHarResponseHarLogEntriesRequest struct { + BodySize float64 `json:"bodySize,required"` + Headers []ScanHarResponseHarLogEntriesRequestHeader `json:"headers,required"` + HeadersSize float64 `json:"headersSize,required"` + HTTPVersion string `json:"httpVersion,required"` + Method string `json:"method,required"` + URL string `json:"url,required"` + JSON scanHarResponseHarLogEntriesRequestJSON `json:"-"` +} + +// scanHarResponseHarLogEntriesRequestJSON contains the JSON metadata for the +// struct [ScanHarResponseHarLogEntriesRequest] +type scanHarResponseHarLogEntriesRequestJSON struct { + BodySize apijson.Field + Headers apijson.Field + HeadersSize apijson.Field + HTTPVersion apijson.Field + Method apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanHarResponseHarLogEntriesRequest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanHarResponseHarLogEntriesRequestJSON) RawJSON() string { + return r.raw +} + +type ScanHarResponseHarLogEntriesRequestHeader struct { + Name string `json:"name,required"` + Value string `json:"value,required"` + JSON scanHarResponseHarLogEntriesRequestHeaderJSON `json:"-"` +} + +// scanHarResponseHarLogEntriesRequestHeaderJSON contains the JSON metadata for the +// struct [ScanHarResponseHarLogEntriesRequestHeader] +type scanHarResponseHarLogEntriesRequestHeaderJSON struct { + Name apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanHarResponseHarLogEntriesRequestHeader) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanHarResponseHarLogEntriesRequestHeaderJSON) RawJSON() string { + return r.raw +} + +type ScanHarResponseHarLogEntriesResponse struct { + TransferSize float64 `json:"_transferSize,required"` + BodySize float64 `json:"bodySize,required"` + Content ScanHarResponseHarLogEntriesResponseContent `json:"content,required"` + Headers []ScanHarResponseHarLogEntriesResponseHeader `json:"headers,required"` + HeadersSize float64 `json:"headersSize,required"` + HTTPVersion string `json:"httpVersion,required"` + RedirectURL string `json:"redirectURL,required"` + Status float64 `json:"status,required"` + StatusText string `json:"statusText,required"` + JSON scanHarResponseHarLogEntriesResponseJSON `json:"-"` +} + +// scanHarResponseHarLogEntriesResponseJSON contains the JSON metadata for the +// struct [ScanHarResponseHarLogEntriesResponse] +type scanHarResponseHarLogEntriesResponseJSON struct { + TransferSize apijson.Field + BodySize apijson.Field + Content apijson.Field + Headers apijson.Field + HeadersSize apijson.Field + HTTPVersion apijson.Field + RedirectURL apijson.Field + Status apijson.Field + StatusText apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanHarResponseHarLogEntriesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanHarResponseHarLogEntriesResponseJSON) RawJSON() string { + return r.raw +} + +type ScanHarResponseHarLogEntriesResponseContent struct { + MimeType string `json:"mimeType,required"` + Size float64 `json:"size,required"` + Compression int64 `json:"compression"` + JSON scanHarResponseHarLogEntriesResponseContentJSON `json:"-"` +} + +// scanHarResponseHarLogEntriesResponseContentJSON contains the JSON metadata for +// the struct [ScanHarResponseHarLogEntriesResponseContent] +type scanHarResponseHarLogEntriesResponseContentJSON struct { + MimeType apijson.Field + Size apijson.Field + Compression apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanHarResponseHarLogEntriesResponseContent) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanHarResponseHarLogEntriesResponseContentJSON) RawJSON() string { + return r.raw +} + +type ScanHarResponseHarLogEntriesResponseHeader struct { + Name string `json:"name,required"` + Value string `json:"value,required"` + JSON scanHarResponseHarLogEntriesResponseHeaderJSON `json:"-"` +} + +// scanHarResponseHarLogEntriesResponseHeaderJSON contains the JSON metadata for +// the struct [ScanHarResponseHarLogEntriesResponseHeader] +type scanHarResponseHarLogEntriesResponseHeaderJSON struct { + Name apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanHarResponseHarLogEntriesResponseHeader) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanHarResponseHarLogEntriesResponseHeaderJSON) RawJSON() string { + return r.raw +} + +type ScanHarResponseHarLogPage struct { + ID string `json:"id,required"` + PageTimings ScanHarResponseHarLogPagesPageTimings `json:"pageTimings,required"` + StartedDateTime string `json:"startedDateTime,required"` + Title string `json:"title,required"` + JSON scanHarResponseHarLogPageJSON `json:"-"` +} + +// scanHarResponseHarLogPageJSON contains the JSON metadata for the struct +// [ScanHarResponseHarLogPage] +type scanHarResponseHarLogPageJSON struct { + ID apijson.Field + PageTimings apijson.Field + StartedDateTime apijson.Field + Title apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanHarResponseHarLogPage) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanHarResponseHarLogPageJSON) RawJSON() string { + return r.raw +} + +type ScanHarResponseHarLogPagesPageTimings struct { + OnContentLoad float64 `json:"onContentLoad,required"` + OnLoad float64 `json:"onLoad,required"` + JSON scanHarResponseHarLogPagesPageTimingsJSON `json:"-"` +} + +// scanHarResponseHarLogPagesPageTimingsJSON contains the JSON metadata for the +// struct [ScanHarResponseHarLogPagesPageTimings] +type scanHarResponseHarLogPagesPageTimingsJSON struct { + OnContentLoad apijson.Field + OnLoad apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanHarResponseHarLogPagesPageTimings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanHarResponseHarLogPagesPageTimingsJSON) RawJSON() string { + return r.raw +} + +type ScanNewParams struct { + URL param.Field[string] `json:"url,required"` + // Set custom headers + CustomHeaders param.Field[map[string]string] `json:"customHeaders"` + // Take multiple screenshots targeting different device types + ScreenshotsResolutions param.Field[[]ScanNewParamsScreenshotsResolution] `json:"screenshotsResolutions"` + // The option `Public` means it will be included in listings like recent scans and + // search results. `Unlisted` means it will not be included in the aforementioned + // listings, users will need to have the scan's ID to access it. A a scan will be + // automatically marked as unlisted if it fails, if it contains potential PII or + // other sensitive material. + Visibility param.Field[ScanNewParamsVisibility] `json:"visibility"` +} + +func (r ScanNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Device resolutions. +type ScanNewParamsScreenshotsResolution string + +const ( + ScanNewParamsScreenshotsResolutionDesktop ScanNewParamsScreenshotsResolution = "desktop" + ScanNewParamsScreenshotsResolutionMobile ScanNewParamsScreenshotsResolution = "mobile" + ScanNewParamsScreenshotsResolutionTablet ScanNewParamsScreenshotsResolution = "tablet" +) + +// The option `Public` means it will be included in listings like recent scans and +// search results. `Unlisted` means it will not be included in the aforementioned +// listings, users will need to have the scan's ID to access it. A a scan will be +// automatically marked as unlisted if it fails, if it contains potential PII or +// other sensitive material. +type ScanNewParamsVisibility string + +const ( + ScanNewParamsVisibilityPublic ScanNewParamsVisibility = "Public" + ScanNewParamsVisibilityUnlisted ScanNewParamsVisibility = "Unlisted" +) + +type ScanNewResponseEnvelope struct { + Errors []ScanNewResponseEnvelopeErrors `json:"errors,required"` + Messages []ScanNewResponseEnvelopeMessages `json:"messages,required"` + Result ScanNewResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON scanNewResponseEnvelopeJSON `json:"-"` +} + +// scanNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [ScanNewResponseEnvelope] +type scanNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ScanNewResponseEnvelopeErrors struct { + Message string `json:"message,required"` + JSON scanNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// scanNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ScanNewResponseEnvelopeErrors] +type scanNewResponseEnvelopeErrorsJSON struct { + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ScanNewResponseEnvelopeMessages struct { + Message string `json:"message,required"` + JSON scanNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// scanNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ScanNewResponseEnvelopeMessages] +type scanNewResponseEnvelopeMessagesJSON struct { + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseEnvelope struct { + Errors []ScanGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ScanGetResponseEnvelopeMessages `json:"messages,required"` + Result ScanGetResponse `json:"result,required"` + // Whether request was successful or not + Success bool `json:"success,required"` + JSON scanGetResponseEnvelopeJSON `json:"-"` +} + +// scanGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [ScanGetResponseEnvelope] +type scanGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseEnvelopeErrors struct { + Message string `json:"message,required"` + JSON scanGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// scanGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ScanGetResponseEnvelopeErrors] +type scanGetResponseEnvelopeErrorsJSON struct { + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ScanGetResponseEnvelopeMessages struct { + Message string `json:"message,required"` + JSON scanGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// scanGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ScanGetResponseEnvelopeMessages] +type scanGetResponseEnvelopeMessagesJSON struct { + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type ScanHarResponseEnvelope struct { + Errors []ScanHarResponseEnvelopeErrors `json:"errors,required"` + Messages []ScanHarResponseEnvelopeMessages `json:"messages,required"` + Result ScanHarResponse `json:"result,required"` + // Whether search request was successful or not + Success bool `json:"success,required"` + JSON scanHarResponseEnvelopeJSON `json:"-"` +} + +// scanHarResponseEnvelopeJSON contains the JSON metadata for the struct +// [ScanHarResponseEnvelope] +type scanHarResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanHarResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanHarResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ScanHarResponseEnvelopeErrors struct { + Message string `json:"message,required"` + JSON scanHarResponseEnvelopeErrorsJSON `json:"-"` +} + +// scanHarResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ScanHarResponseEnvelopeErrors] +type scanHarResponseEnvelopeErrorsJSON struct { + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanHarResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanHarResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ScanHarResponseEnvelopeMessages struct { + Message string `json:"message,required"` + JSON scanHarResponseEnvelopeMessagesJSON `json:"-"` +} + +// scanHarResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ScanHarResponseEnvelopeMessages] +type scanHarResponseEnvelopeMessagesJSON struct { + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScanHarResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scanHarResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type ScanScreenshotParams struct { + // Target device type + Resolution param.Field[ScanScreenshotParamsResolution] `query:"resolution"` +} + +// URLQuery serializes [ScanScreenshotParams]'s query parameters as `url.Values`. +func (r ScanScreenshotParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Target device type +type ScanScreenshotParamsResolution string + +const ( + ScanScreenshotParamsResolutionDesktop ScanScreenshotParamsResolution = "desktop" + ScanScreenshotParamsResolutionMobile ScanScreenshotParamsResolution = "mobile" + ScanScreenshotParamsResolutionTablet ScanScreenshotParamsResolution = "tablet" +) diff --git a/url_scanner/scan_test.go b/url_scanner/scan_test.go new file mode 100644 index 00000000000..ce41a5c5504 --- /dev/null +++ b/url_scanner/scan_test.go @@ -0,0 +1,153 @@ +// File generated from our OpenAPI spec by Stainless. + +package url_scanner_test + +import ( + "bytes" + "context" + "errors" + "io" + "net/http" + "net/http/httptest" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/url_scanner" +) + +func TestScanNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.URLScanner.Scans.New( + context.TODO(), + "string", + url_scanner.ScanNewParams{ + URL: cloudflare.F("https://www.example.com"), + CustomHeaders: cloudflare.F(map[string]string{ + "foo": "string", + }), + ScreenshotsResolutions: cloudflare.F([]url_scanner.ScanNewParamsScreenshotsResolution{url_scanner.ScanNewParamsScreenshotsResolutionDesktop, url_scanner.ScanNewParamsScreenshotsResolutionMobile, url_scanner.ScanNewParamsScreenshotsResolutionTablet}), + Visibility: cloudflare.F(url_scanner.ScanNewParamsVisibilityPublic), + }, + ) + 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 TestScanGet(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("user@example.com"), + ) + _, err := client.URLScanner.Scans.Get( + context.TODO(), + "string", + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + 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 TestScanHar(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("user@example.com"), + ) + _, err := client.URLScanner.Scans.Har( + context.TODO(), + "string", + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + ) + 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 TestScanScreenshotWithOptionalParams(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + w.Write([]byte("abc")) + })) + defer server.Close() + baseURL := server.URL + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("user@example.com"), + ) + resp, err := client.URLScanner.Scans.Screenshot( + context.TODO(), + "string", + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + url_scanner.ScanScreenshotParams{ + Resolution: cloudflare.F(url_scanner.ScanScreenshotParamsResolutionDesktop), + }, + ) + 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()) + } + defer resp.Body.Close() + + b, err := io.ReadAll(resp.Body) + 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()) + } + if !bytes.Equal(b, []byte("abc")) { + t.Fatalf("return value not %s: %s", "abc", b) + } +} diff --git a/urlscanner.go b/url_scanner/urlscanner.go similarity index 98% rename from urlscanner.go rename to url_scanner/urlscanner.go index 9394854e242..e578907977c 100644 --- a/urlscanner.go +++ b/url_scanner/urlscanner.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package url_scanner import ( "context" @@ -22,7 +22,7 @@ import ( // service directly, and instead use the [NewURLScannerService] method instead. type URLScannerService struct { Options []option.RequestOption - Scans *URLScannerScanService + Scans *ScanService } // NewURLScannerService generates a new service that applies the given options to @@ -31,7 +31,7 @@ type URLScannerService struct { func NewURLScannerService(opts ...option.RequestOption) (r *URLScannerService) { r = &URLScannerService{} r.Options = opts - r.Scans = NewURLScannerScanService(opts...) + r.Scans = NewScanService(opts...) return } diff --git a/urlscanner_test.go b/url_scanner/urlscanner_test.go similarity index 93% rename from urlscanner_test.go rename to url_scanner/urlscanner_test.go index 7e6ef9ea688..cfdc64ec249 100644 --- a/urlscanner_test.go +++ b/url_scanner/urlscanner_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package url_scanner_test import ( "context" @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/url_scanner" ) func TestURLScannerScanWithOptionalParams(t *testing.T) { @@ -31,7 +32,7 @@ func TestURLScannerScanWithOptionalParams(t *testing.T) { _, err := client.URLScanner.Scan( context.TODO(), "string", - cloudflare.URLScannerScanParams{ + url_scanner.URLScannerScanParams{ AccountScans: cloudflare.F(true), DateEnd: cloudflare.F(time.Now()), DateStart: cloudflare.F(time.Now()), diff --git a/urlscannerscan.go b/urlscannerscan.go deleted file mode 100644 index da3eaa34c7f..00000000000 --- a/urlscannerscan.go +++ /dev/null @@ -1,2022 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// URLScannerScanService 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 [NewURLScannerScanService] method -// instead. -type URLScannerScanService struct { - Options []option.RequestOption -} - -// NewURLScannerScanService 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 NewURLScannerScanService(opts ...option.RequestOption) (r *URLScannerScanService) { - r = &URLScannerScanService{} - r.Options = opts - return -} - -// Submit a URL to scan. You can also set some options, like the visibility level -// and custom headers. Accounts are limited to 1 new scan every 10 seconds and 8000 -// per month. If you need more, please reach out. -func (r *URLScannerScanService) New(ctx context.Context, accountID string, body URLScannerScanNewParams, opts ...option.RequestOption) (res *URLScannerScanNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env URLScannerScanNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/urlscanner/scan", accountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get URL scan by uuid -func (r *URLScannerScanService) Get(ctx context.Context, accountID string, scanID string, opts ...option.RequestOption) (res *URLScannerScanGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env URLScannerScanGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/urlscanner/scan/%s", accountID, scanID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a URL scan's HAR file. See HAR spec at -// http://www.softwareishard.com/blog/har-12-spec/. -func (r *URLScannerScanService) Har(ctx context.Context, accountID string, scanID string, opts ...option.RequestOption) (res *URLScannerScanHarResponse, err error) { - opts = append(r.Options[:], opts...) - var env URLScannerScanHarResponseEnvelope - path := fmt.Sprintf("accounts/%s/urlscanner/scan/%s/har", accountID, scanID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get scan's screenshot by resolution (desktop/mobile/tablet). -func (r *URLScannerScanService) Screenshot(ctx context.Context, accountID string, scanID string, query URLScannerScanScreenshotParams, opts ...option.RequestOption) (res *http.Response, err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "image/png")}, opts...) - path := fmt.Sprintf("accounts/%s/urlscanner/scan/%s/screenshot", accountID, scanID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -type URLScannerScanNewResponse struct { - // Time when url was submitted for scanning. - Time time.Time `json:"time,required" format:"date-time"` - // Canonical form of submitted URL. Use this if you want to later search by URL. - URL string `json:"url,required"` - // Scan ID. - UUID string `json:"uuid,required" format:"uuid"` - // Submitted visibility status. - Visibility string `json:"visibility,required"` - JSON urlScannerScanNewResponseJSON `json:"-"` -} - -// urlScannerScanNewResponseJSON contains the JSON metadata for the struct -// [URLScannerScanNewResponse] -type urlScannerScanNewResponseJSON struct { - Time apijson.Field - URL apijson.Field - UUID apijson.Field - Visibility apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanNewResponseJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponse struct { - Scan URLScannerScanGetResponseScan `json:"scan,required"` - JSON urlScannerScanGetResponseJSON `json:"-"` -} - -// urlScannerScanGetResponseJSON contains the JSON metadata for the struct -// [URLScannerScanGetResponse] -type urlScannerScanGetResponseJSON struct { - Scan apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScan struct { - Certificates []URLScannerScanGetResponseScanCertificate `json:"certificates,required"` - Geo URLScannerScanGetResponseScanGeo `json:"geo,required"` - Meta URLScannerScanGetResponseScanMeta `json:"meta,required"` - Page URLScannerScanGetResponseScanPage `json:"page,required"` - Performance []URLScannerScanGetResponseScanPerformance `json:"performance,required"` - Task URLScannerScanGetResponseScanTask `json:"task,required"` - Verdicts URLScannerScanGetResponseScanVerdicts `json:"verdicts,required"` - // Dictionary of Autonomous System Numbers where ASN's are the keys - ASNs URLScannerScanGetResponseScanASNs `json:"asns"` - Domains URLScannerScanGetResponseScanDomains `json:"domains"` - IPs URLScannerScanGetResponseScanIPs `json:"ips"` - Links URLScannerScanGetResponseScanLinks `json:"links"` - JSON urlScannerScanGetResponseScanJSON `json:"-"` -} - -// urlScannerScanGetResponseScanJSON contains the JSON metadata for the struct -// [URLScannerScanGetResponseScan] -type urlScannerScanGetResponseScanJSON struct { - Certificates apijson.Field - Geo apijson.Field - Meta apijson.Field - Page apijson.Field - Performance apijson.Field - Task apijson.Field - Verdicts apijson.Field - ASNs apijson.Field - Domains apijson.Field - IPs apijson.Field - Links apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScan) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanCertificate struct { - Issuer string `json:"issuer,required"` - SubjectName string `json:"subjectName,required"` - ValidFrom float64 `json:"validFrom,required"` - ValidTo float64 `json:"validTo,required"` - JSON urlScannerScanGetResponseScanCertificateJSON `json:"-"` -} - -// urlScannerScanGetResponseScanCertificateJSON contains the JSON metadata for the -// struct [URLScannerScanGetResponseScanCertificate] -type urlScannerScanGetResponseScanCertificateJSON struct { - Issuer apijson.Field - SubjectName apijson.Field - ValidFrom apijson.Field - ValidTo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanCertificate) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanCertificateJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanGeo struct { - // GeoIP continent location - Continents []string `json:"continents,required"` - // GeoIP country location - Locations []string `json:"locations,required"` - JSON urlScannerScanGetResponseScanGeoJSON `json:"-"` -} - -// urlScannerScanGetResponseScanGeoJSON contains the JSON metadata for the struct -// [URLScannerScanGetResponseScanGeo] -type urlScannerScanGetResponseScanGeoJSON struct { - Continents apijson.Field - Locations apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanGeoJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanMeta struct { - Processors URLScannerScanGetResponseScanMetaProcessors `json:"processors,required"` - JSON urlScannerScanGetResponseScanMetaJSON `json:"-"` -} - -// urlScannerScanGetResponseScanMetaJSON contains the JSON metadata for the struct -// [URLScannerScanGetResponseScanMeta] -type urlScannerScanGetResponseScanMetaJSON struct { - Processors apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanMeta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanMetaJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanMetaProcessors struct { - Categories URLScannerScanGetResponseScanMetaProcessorsCategories `json:"categories,required"` - Phishing []string `json:"phishing,required"` - Rank URLScannerScanGetResponseScanMetaProcessorsRank `json:"rank,required"` - Tech []URLScannerScanGetResponseScanMetaProcessorsTech `json:"tech,required"` - JSON urlScannerScanGetResponseScanMetaProcessorsJSON `json:"-"` -} - -// urlScannerScanGetResponseScanMetaProcessorsJSON contains the JSON metadata for -// the struct [URLScannerScanGetResponseScanMetaProcessors] -type urlScannerScanGetResponseScanMetaProcessorsJSON struct { - Categories apijson.Field - Phishing apijson.Field - Rank apijson.Field - Tech apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanMetaProcessors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanMetaProcessorsJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanMetaProcessorsCategories struct { - Content []URLScannerScanGetResponseScanMetaProcessorsCategoriesContent `json:"content,required"` - Risks []URLScannerScanGetResponseScanMetaProcessorsCategoriesRisk `json:"risks,required"` - JSON urlScannerScanGetResponseScanMetaProcessorsCategoriesJSON `json:"-"` -} - -// urlScannerScanGetResponseScanMetaProcessorsCategoriesJSON contains the JSON -// metadata for the struct [URLScannerScanGetResponseScanMetaProcessorsCategories] -type urlScannerScanGetResponseScanMetaProcessorsCategoriesJSON struct { - Content apijson.Field - Risks apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanMetaProcessorsCategories) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanMetaProcessorsCategoriesJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanMetaProcessorsCategoriesContent struct { - ID int64 `json:"id,required"` - Name string `json:"name,required"` - SuperCategoryID int64 `json:"super_category_id"` - JSON urlScannerScanGetResponseScanMetaProcessorsCategoriesContentJSON `json:"-"` -} - -// urlScannerScanGetResponseScanMetaProcessorsCategoriesContentJSON contains the -// JSON metadata for the struct -// [URLScannerScanGetResponseScanMetaProcessorsCategoriesContent] -type urlScannerScanGetResponseScanMetaProcessorsCategoriesContentJSON struct { - ID apijson.Field - Name apijson.Field - SuperCategoryID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanMetaProcessorsCategoriesContent) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanMetaProcessorsCategoriesContentJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanMetaProcessorsCategoriesRisk struct { - ID int64 `json:"id,required"` - Name string `json:"name,required"` - SuperCategoryID int64 `json:"super_category_id,required"` - JSON urlScannerScanGetResponseScanMetaProcessorsCategoriesRiskJSON `json:"-"` -} - -// urlScannerScanGetResponseScanMetaProcessorsCategoriesRiskJSON contains the JSON -// metadata for the struct -// [URLScannerScanGetResponseScanMetaProcessorsCategoriesRisk] -type urlScannerScanGetResponseScanMetaProcessorsCategoriesRiskJSON struct { - ID apijson.Field - Name apijson.Field - SuperCategoryID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanMetaProcessorsCategoriesRisk) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanMetaProcessorsCategoriesRiskJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanMetaProcessorsRank struct { - Bucket string `json:"bucket,required"` - Name string `json:"name,required"` - // Rank in the Global Radar Rank, if set. See more at - // https://blog.cloudflare.com/radar-domain-rankings/ - Rank int64 `json:"rank"` - JSON urlScannerScanGetResponseScanMetaProcessorsRankJSON `json:"-"` -} - -// urlScannerScanGetResponseScanMetaProcessorsRankJSON contains the JSON metadata -// for the struct [URLScannerScanGetResponseScanMetaProcessorsRank] -type urlScannerScanGetResponseScanMetaProcessorsRankJSON struct { - Bucket apijson.Field - Name apijson.Field - Rank apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanMetaProcessorsRank) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanMetaProcessorsRankJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanMetaProcessorsTech struct { - Categories []URLScannerScanGetResponseScanMetaProcessorsTechCategory `json:"categories,required"` - Confidence int64 `json:"confidence,required"` - Evidence URLScannerScanGetResponseScanMetaProcessorsTechEvidence `json:"evidence,required"` - Icon string `json:"icon,required"` - Name string `json:"name,required"` - Slug string `json:"slug,required"` - Website string `json:"website,required"` - Description string `json:"description"` - JSON urlScannerScanGetResponseScanMetaProcessorsTechJSON `json:"-"` -} - -// urlScannerScanGetResponseScanMetaProcessorsTechJSON contains the JSON metadata -// for the struct [URLScannerScanGetResponseScanMetaProcessorsTech] -type urlScannerScanGetResponseScanMetaProcessorsTechJSON struct { - Categories apijson.Field - Confidence apijson.Field - Evidence apijson.Field - Icon apijson.Field - Name apijson.Field - Slug apijson.Field - Website apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanMetaProcessorsTech) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanMetaProcessorsTechJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanMetaProcessorsTechCategory struct { - ID int64 `json:"id,required"` - Groups []int64 `json:"groups,required"` - Name string `json:"name,required"` - Priority int64 `json:"priority,required"` - Slug string `json:"slug,required"` - JSON urlScannerScanGetResponseScanMetaProcessorsTechCategoryJSON `json:"-"` -} - -// urlScannerScanGetResponseScanMetaProcessorsTechCategoryJSON contains the JSON -// metadata for the struct -// [URLScannerScanGetResponseScanMetaProcessorsTechCategory] -type urlScannerScanGetResponseScanMetaProcessorsTechCategoryJSON struct { - ID apijson.Field - Groups apijson.Field - Name apijson.Field - Priority apijson.Field - Slug apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanMetaProcessorsTechCategory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanMetaProcessorsTechCategoryJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanMetaProcessorsTechEvidence struct { - ImpliedBy []string `json:"impliedBy,required"` - Patterns []URLScannerScanGetResponseScanMetaProcessorsTechEvidencePattern `json:"patterns,required"` - JSON urlScannerScanGetResponseScanMetaProcessorsTechEvidenceJSON `json:"-"` -} - -// urlScannerScanGetResponseScanMetaProcessorsTechEvidenceJSON contains the JSON -// metadata for the struct -// [URLScannerScanGetResponseScanMetaProcessorsTechEvidence] -type urlScannerScanGetResponseScanMetaProcessorsTechEvidenceJSON struct { - ImpliedBy apijson.Field - Patterns apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanMetaProcessorsTechEvidence) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanMetaProcessorsTechEvidenceJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanMetaProcessorsTechEvidencePattern struct { - Confidence int64 `json:"confidence,required"` - Excludes []string `json:"excludes,required"` - Implies []string `json:"implies,required"` - Match string `json:"match,required"` - // Header or Cookie name when set - Name string `json:"name,required"` - Regex string `json:"regex,required"` - Type string `json:"type,required"` - Value string `json:"value,required"` - Version string `json:"version,required"` - JSON urlScannerScanGetResponseScanMetaProcessorsTechEvidencePatternJSON `json:"-"` -} - -// urlScannerScanGetResponseScanMetaProcessorsTechEvidencePatternJSON contains the -// JSON metadata for the struct -// [URLScannerScanGetResponseScanMetaProcessorsTechEvidencePattern] -type urlScannerScanGetResponseScanMetaProcessorsTechEvidencePatternJSON struct { - Confidence apijson.Field - Excludes apijson.Field - Implies apijson.Field - Match apijson.Field - Name apijson.Field - Regex apijson.Field - Type apijson.Field - Value apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanMetaProcessorsTechEvidencePattern) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanMetaProcessorsTechEvidencePatternJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanPage struct { - ASN string `json:"asn,required"` - ASNLocationAlpha2 string `json:"asnLocationAlpha2,required"` - Asnname string `json:"asnname,required"` - Console []URLScannerScanGetResponseScanPageConsole `json:"console,required"` - Cookies []URLScannerScanGetResponseScanPageCooky `json:"cookies,required"` - Country string `json:"country,required"` - CountryLocationAlpha2 string `json:"countryLocationAlpha2,required"` - Domain string `json:"domain,required"` - Headers []URLScannerScanGetResponseScanPageHeader `json:"headers,required"` - IP string `json:"ip,required"` - Js URLScannerScanGetResponseScanPageJs `json:"js,required"` - SecurityViolations []URLScannerScanGetResponseScanPageSecurityViolation `json:"securityViolations,required"` - Status float64 `json:"status,required"` - Subdivision1Name string `json:"subdivision1Name,required"` - Subdivision2name string `json:"subdivision2name,required"` - URL string `json:"url,required"` - JSON urlScannerScanGetResponseScanPageJSON `json:"-"` -} - -// urlScannerScanGetResponseScanPageJSON contains the JSON metadata for the struct -// [URLScannerScanGetResponseScanPage] -type urlScannerScanGetResponseScanPageJSON struct { - ASN apijson.Field - ASNLocationAlpha2 apijson.Field - Asnname apijson.Field - Console apijson.Field - Cookies apijson.Field - Country apijson.Field - CountryLocationAlpha2 apijson.Field - Domain apijson.Field - Headers apijson.Field - IP apijson.Field - Js apijson.Field - SecurityViolations apijson.Field - Status apijson.Field - Subdivision1Name apijson.Field - Subdivision2name apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanPage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanPageJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanPageConsole struct { - Category string `json:"category,required"` - Text string `json:"text,required"` - Type string `json:"type,required"` - URL string `json:"url"` - JSON urlScannerScanGetResponseScanPageConsoleJSON `json:"-"` -} - -// urlScannerScanGetResponseScanPageConsoleJSON contains the JSON metadata for the -// struct [URLScannerScanGetResponseScanPageConsole] -type urlScannerScanGetResponseScanPageConsoleJSON struct { - Category apijson.Field - Text apijson.Field - Type apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanPageConsole) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanPageConsoleJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanPageCooky struct { - Domain string `json:"domain,required"` - Expires float64 `json:"expires,required"` - HTTPOnly bool `json:"httpOnly,required"` - Name string `json:"name,required"` - Path string `json:"path,required"` - SameParty bool `json:"sameParty,required"` - Secure bool `json:"secure,required"` - Session bool `json:"session,required"` - Size float64 `json:"size,required"` - SourcePort float64 `json:"sourcePort,required"` - SourceScheme string `json:"sourceScheme,required"` - Value string `json:"value,required"` - Priority string `json:"priority"` - JSON urlScannerScanGetResponseScanPageCookyJSON `json:"-"` -} - -// urlScannerScanGetResponseScanPageCookyJSON contains the JSON metadata for the -// struct [URLScannerScanGetResponseScanPageCooky] -type urlScannerScanGetResponseScanPageCookyJSON struct { - Domain apijson.Field - Expires apijson.Field - HTTPOnly apijson.Field - Name apijson.Field - Path apijson.Field - SameParty apijson.Field - Secure apijson.Field - Session apijson.Field - Size apijson.Field - SourcePort apijson.Field - SourceScheme apijson.Field - Value apijson.Field - Priority apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanPageCooky) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanPageCookyJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanPageHeader struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON urlScannerScanGetResponseScanPageHeaderJSON `json:"-"` -} - -// urlScannerScanGetResponseScanPageHeaderJSON contains the JSON metadata for the -// struct [URLScannerScanGetResponseScanPageHeader] -type urlScannerScanGetResponseScanPageHeaderJSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanPageHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanPageHeaderJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanPageJs struct { - Variables []URLScannerScanGetResponseScanPageJsVariable `json:"variables,required"` - JSON urlScannerScanGetResponseScanPageJsJSON `json:"-"` -} - -// urlScannerScanGetResponseScanPageJsJSON contains the JSON metadata for the -// struct [URLScannerScanGetResponseScanPageJs] -type urlScannerScanGetResponseScanPageJsJSON struct { - Variables apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanPageJs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanPageJsJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanPageJsVariable struct { - Name string `json:"name,required"` - Type string `json:"type,required"` - JSON urlScannerScanGetResponseScanPageJsVariableJSON `json:"-"` -} - -// urlScannerScanGetResponseScanPageJsVariableJSON contains the JSON metadata for -// the struct [URLScannerScanGetResponseScanPageJsVariable] -type urlScannerScanGetResponseScanPageJsVariableJSON struct { - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanPageJsVariable) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanPageJsVariableJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanPageSecurityViolation struct { - Category string `json:"category,required"` - Text string `json:"text,required"` - URL string `json:"url,required"` - JSON urlScannerScanGetResponseScanPageSecurityViolationJSON `json:"-"` -} - -// urlScannerScanGetResponseScanPageSecurityViolationJSON contains the JSON -// metadata for the struct [URLScannerScanGetResponseScanPageSecurityViolation] -type urlScannerScanGetResponseScanPageSecurityViolationJSON struct { - Category apijson.Field - Text apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanPageSecurityViolation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanPageSecurityViolationJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanPerformance struct { - ConnectEnd float64 `json:"connectEnd,required"` - ConnectStart float64 `json:"connectStart,required"` - DecodedBodySize float64 `json:"decodedBodySize,required"` - DomainLookupEnd float64 `json:"domainLookupEnd,required"` - DomainLookupStart float64 `json:"domainLookupStart,required"` - DomComplete float64 `json:"domComplete,required"` - DomContentLoadedEventEnd float64 `json:"domContentLoadedEventEnd,required"` - DomContentLoadedEventStart float64 `json:"domContentLoadedEventStart,required"` - DomInteractive float64 `json:"domInteractive,required"` - Duration float64 `json:"duration,required"` - EncodedBodySize float64 `json:"encodedBodySize,required"` - EntryType string `json:"entryType,required"` - FetchStart float64 `json:"fetchStart,required"` - InitiatorType string `json:"initiatorType,required"` - LoadEventEnd float64 `json:"loadEventEnd,required"` - LoadEventStart float64 `json:"loadEventStart,required"` - Name string `json:"name,required"` - NextHopProtocol string `json:"nextHopProtocol,required"` - RedirectCount float64 `json:"redirectCount,required"` - RedirectEnd float64 `json:"redirectEnd,required"` - RedirectStart float64 `json:"redirectStart,required"` - RequestStart float64 `json:"requestStart,required"` - ResponseEnd float64 `json:"responseEnd,required"` - ResponseStart float64 `json:"responseStart,required"` - SecureConnectionStart float64 `json:"secureConnectionStart,required"` - StartTime float64 `json:"startTime,required"` - TransferSize float64 `json:"transferSize,required"` - Type string `json:"type,required"` - UnloadEventEnd float64 `json:"unloadEventEnd,required"` - UnloadEventStart float64 `json:"unloadEventStart,required"` - WorkerStart float64 `json:"workerStart,required"` - JSON urlScannerScanGetResponseScanPerformanceJSON `json:"-"` -} - -// urlScannerScanGetResponseScanPerformanceJSON contains the JSON metadata for the -// struct [URLScannerScanGetResponseScanPerformance] -type urlScannerScanGetResponseScanPerformanceJSON struct { - ConnectEnd apijson.Field - ConnectStart apijson.Field - DecodedBodySize apijson.Field - DomainLookupEnd apijson.Field - DomainLookupStart apijson.Field - DomComplete apijson.Field - DomContentLoadedEventEnd apijson.Field - DomContentLoadedEventStart apijson.Field - DomInteractive apijson.Field - Duration apijson.Field - EncodedBodySize apijson.Field - EntryType apijson.Field - FetchStart apijson.Field - InitiatorType apijson.Field - LoadEventEnd apijson.Field - LoadEventStart apijson.Field - Name apijson.Field - NextHopProtocol apijson.Field - RedirectCount apijson.Field - RedirectEnd apijson.Field - RedirectStart apijson.Field - RequestStart apijson.Field - ResponseEnd apijson.Field - ResponseStart apijson.Field - SecureConnectionStart apijson.Field - StartTime apijson.Field - TransferSize apijson.Field - Type apijson.Field - UnloadEventEnd apijson.Field - UnloadEventStart apijson.Field - WorkerStart apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanPerformance) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanPerformanceJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanTask struct { - // Submitter location - ClientLocation string `json:"clientLocation,required"` - ClientType URLScannerScanGetResponseScanTaskClientType `json:"clientType,required"` - // URL of the primary request, after all HTTP redirects - EffectiveURL string `json:"effectiveUrl,required"` - Errors []URLScannerScanGetResponseScanTaskError `json:"errors,required"` - ScannedFrom URLScannerScanGetResponseScanTaskScannedFrom `json:"scannedFrom,required"` - Status URLScannerScanGetResponseScanTaskStatus `json:"status,required"` - Success bool `json:"success,required"` - Time string `json:"time,required"` - TimeEnd string `json:"timeEnd,required"` - // Submitted URL - URL string `json:"url,required"` - // Scan ID - UUID string `json:"uuid,required"` - Visibility URLScannerScanGetResponseScanTaskVisibility `json:"visibility,required"` - JSON urlScannerScanGetResponseScanTaskJSON `json:"-"` -} - -// urlScannerScanGetResponseScanTaskJSON contains the JSON metadata for the struct -// [URLScannerScanGetResponseScanTask] -type urlScannerScanGetResponseScanTaskJSON struct { - ClientLocation apijson.Field - ClientType apijson.Field - EffectiveURL apijson.Field - Errors apijson.Field - ScannedFrom apijson.Field - Status apijson.Field - Success apijson.Field - Time apijson.Field - TimeEnd apijson.Field - URL apijson.Field - UUID apijson.Field - Visibility apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanTask) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanTaskJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanTaskClientType string - -const ( - URLScannerScanGetResponseScanTaskClientTypeSite URLScannerScanGetResponseScanTaskClientType = "Site" - URLScannerScanGetResponseScanTaskClientTypeAutomatic URLScannerScanGetResponseScanTaskClientType = "Automatic" - URLScannerScanGetResponseScanTaskClientTypeAPI URLScannerScanGetResponseScanTaskClientType = "Api" -) - -type URLScannerScanGetResponseScanTaskError struct { - Message string `json:"message,required"` - JSON urlScannerScanGetResponseScanTaskErrorJSON `json:"-"` -} - -// urlScannerScanGetResponseScanTaskErrorJSON contains the JSON metadata for the -// struct [URLScannerScanGetResponseScanTaskError] -type urlScannerScanGetResponseScanTaskErrorJSON struct { - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanTaskError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanTaskErrorJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanTaskScannedFrom struct { - // IATA code of Cloudflare datacenter - Colo string `json:"colo,required"` - JSON urlScannerScanGetResponseScanTaskScannedFromJSON `json:"-"` -} - -// urlScannerScanGetResponseScanTaskScannedFromJSON contains the JSON metadata for -// the struct [URLScannerScanGetResponseScanTaskScannedFrom] -type urlScannerScanGetResponseScanTaskScannedFromJSON struct { - Colo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanTaskScannedFrom) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanTaskScannedFromJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanTaskStatus string - -const ( - URLScannerScanGetResponseScanTaskStatusQueued URLScannerScanGetResponseScanTaskStatus = "Queued" - URLScannerScanGetResponseScanTaskStatusInProgress URLScannerScanGetResponseScanTaskStatus = "InProgress" - URLScannerScanGetResponseScanTaskStatusInPostProcessing URLScannerScanGetResponseScanTaskStatus = "InPostProcessing" - URLScannerScanGetResponseScanTaskStatusFinished URLScannerScanGetResponseScanTaskStatus = "Finished" -) - -type URLScannerScanGetResponseScanTaskVisibility string - -const ( - URLScannerScanGetResponseScanTaskVisibilityPublic URLScannerScanGetResponseScanTaskVisibility = "Public" - URLScannerScanGetResponseScanTaskVisibilityUnlisted URLScannerScanGetResponseScanTaskVisibility = "Unlisted" -) - -type URLScannerScanGetResponseScanVerdicts struct { - Overall URLScannerScanGetResponseScanVerdictsOverall `json:"overall,required"` - JSON urlScannerScanGetResponseScanVerdictsJSON `json:"-"` -} - -// urlScannerScanGetResponseScanVerdictsJSON contains the JSON metadata for the -// struct [URLScannerScanGetResponseScanVerdicts] -type urlScannerScanGetResponseScanVerdictsJSON struct { - Overall apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanVerdicts) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanVerdictsJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanVerdictsOverall struct { - Categories []URLScannerScanGetResponseScanVerdictsOverallCategory `json:"categories,required"` - // At least one of our subsystems marked the site as potentially malicious at the - // time of the scan. - Malicious bool `json:"malicious,required"` - Phishing []string `json:"phishing,required"` - JSON urlScannerScanGetResponseScanVerdictsOverallJSON `json:"-"` -} - -// urlScannerScanGetResponseScanVerdictsOverallJSON contains the JSON metadata for -// the struct [URLScannerScanGetResponseScanVerdictsOverall] -type urlScannerScanGetResponseScanVerdictsOverallJSON struct { - Categories apijson.Field - Malicious apijson.Field - Phishing apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanVerdictsOverall) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanVerdictsOverallJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanVerdictsOverallCategory struct { - ID float64 `json:"id,required"` - Name string `json:"name,required"` - SuperCategoryID float64 `json:"super_category_id,required"` - JSON urlScannerScanGetResponseScanVerdictsOverallCategoryJSON `json:"-"` -} - -// urlScannerScanGetResponseScanVerdictsOverallCategoryJSON contains the JSON -// metadata for the struct [URLScannerScanGetResponseScanVerdictsOverallCategory] -type urlScannerScanGetResponseScanVerdictsOverallCategoryJSON struct { - ID apijson.Field - Name apijson.Field - SuperCategoryID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanVerdictsOverallCategory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanVerdictsOverallCategoryJSON) RawJSON() string { - return r.raw -} - -// Dictionary of Autonomous System Numbers where ASN's are the keys -type URLScannerScanGetResponseScanASNs struct { - // ASN's contacted - ASN URLScannerScanGetResponseScanASNsASN `json:"asn"` - JSON urlScannerScanGetResponseScanASNsJSON `json:"-"` -} - -// urlScannerScanGetResponseScanASNsJSON contains the JSON metadata for the struct -// [URLScannerScanGetResponseScanASNs] -type urlScannerScanGetResponseScanASNsJSON struct { - ASN apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanASNs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanASNsJSON) RawJSON() string { - return r.raw -} - -// ASN's contacted -type URLScannerScanGetResponseScanASNsASN struct { - ASN string `json:"asn,required"` - Description string `json:"description,required"` - LocationAlpha2 string `json:"location_alpha2,required"` - Name string `json:"name,required"` - OrgName string `json:"org_name,required"` - JSON urlScannerScanGetResponseScanASNsASNJSON `json:"-"` -} - -// urlScannerScanGetResponseScanASNsASNJSON contains the JSON metadata for the -// struct [URLScannerScanGetResponseScanASNsASN] -type urlScannerScanGetResponseScanASNsASNJSON struct { - ASN apijson.Field - Description apijson.Field - LocationAlpha2 apijson.Field - Name apijson.Field - OrgName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanASNsASN) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanASNsASNJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanDomains struct { - ExampleCom URLScannerScanGetResponseScanDomainsExampleCom `json:"example.com"` - JSON urlScannerScanGetResponseScanDomainsJSON `json:"-"` -} - -// urlScannerScanGetResponseScanDomainsJSON contains the JSON metadata for the -// struct [URLScannerScanGetResponseScanDomains] -type urlScannerScanGetResponseScanDomainsJSON struct { - ExampleCom apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanDomains) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanDomainsJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanDomainsExampleCom struct { - Categories URLScannerScanGetResponseScanDomainsExampleComCategories `json:"categories,required"` - DNS []URLScannerScanGetResponseScanDomainsExampleComDNS `json:"dns,required"` - Name string `json:"name,required"` - Rank URLScannerScanGetResponseScanDomainsExampleComRank `json:"rank,required"` - Type string `json:"type,required"` - JSON urlScannerScanGetResponseScanDomainsExampleComJSON `json:"-"` -} - -// urlScannerScanGetResponseScanDomainsExampleComJSON contains the JSON metadata -// for the struct [URLScannerScanGetResponseScanDomainsExampleCom] -type urlScannerScanGetResponseScanDomainsExampleComJSON struct { - Categories apijson.Field - DNS apijson.Field - Name apijson.Field - Rank apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanDomainsExampleCom) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanDomainsExampleComJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanDomainsExampleComCategories struct { - Inherited URLScannerScanGetResponseScanDomainsExampleComCategoriesInherited `json:"inherited,required"` - Content []URLScannerScanGetResponseScanDomainsExampleComCategoriesContent `json:"content"` - Risks []URLScannerScanGetResponseScanDomainsExampleComCategoriesRisk `json:"risks"` - JSON urlScannerScanGetResponseScanDomainsExampleComCategoriesJSON `json:"-"` -} - -// urlScannerScanGetResponseScanDomainsExampleComCategoriesJSON contains the JSON -// metadata for the struct -// [URLScannerScanGetResponseScanDomainsExampleComCategories] -type urlScannerScanGetResponseScanDomainsExampleComCategoriesJSON struct { - Inherited apijson.Field - Content apijson.Field - Risks apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanDomainsExampleComCategories) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanDomainsExampleComCategoriesJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanDomainsExampleComCategoriesInherited struct { - Content []URLScannerScanGetResponseScanDomainsExampleComCategoriesInheritedContent `json:"content"` - From string `json:"from"` - Risks []URLScannerScanGetResponseScanDomainsExampleComCategoriesInheritedRisk `json:"risks"` - JSON urlScannerScanGetResponseScanDomainsExampleComCategoriesInheritedJSON `json:"-"` -} - -// urlScannerScanGetResponseScanDomainsExampleComCategoriesInheritedJSON contains -// the JSON metadata for the struct -// [URLScannerScanGetResponseScanDomainsExampleComCategoriesInherited] -type urlScannerScanGetResponseScanDomainsExampleComCategoriesInheritedJSON struct { - Content apijson.Field - From apijson.Field - Risks apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanDomainsExampleComCategoriesInherited) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanDomainsExampleComCategoriesInheritedJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanDomainsExampleComCategoriesInheritedContent struct { - ID int64 `json:"id,required"` - Name string `json:"name,required"` - SuperCategoryID int64 `json:"super_category_id"` - JSON urlScannerScanGetResponseScanDomainsExampleComCategoriesInheritedContentJSON `json:"-"` -} - -// urlScannerScanGetResponseScanDomainsExampleComCategoriesInheritedContentJSON -// contains the JSON metadata for the struct -// [URLScannerScanGetResponseScanDomainsExampleComCategoriesInheritedContent] -type urlScannerScanGetResponseScanDomainsExampleComCategoriesInheritedContentJSON struct { - ID apijson.Field - Name apijson.Field - SuperCategoryID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanDomainsExampleComCategoriesInheritedContent) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanDomainsExampleComCategoriesInheritedContentJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanDomainsExampleComCategoriesInheritedRisk struct { - ID int64 `json:"id,required"` - Name string `json:"name,required"` - SuperCategoryID int64 `json:"super_category_id"` - JSON urlScannerScanGetResponseScanDomainsExampleComCategoriesInheritedRiskJSON `json:"-"` -} - -// urlScannerScanGetResponseScanDomainsExampleComCategoriesInheritedRiskJSON -// contains the JSON metadata for the struct -// [URLScannerScanGetResponseScanDomainsExampleComCategoriesInheritedRisk] -type urlScannerScanGetResponseScanDomainsExampleComCategoriesInheritedRiskJSON struct { - ID apijson.Field - Name apijson.Field - SuperCategoryID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanDomainsExampleComCategoriesInheritedRisk) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanDomainsExampleComCategoriesInheritedRiskJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanDomainsExampleComCategoriesContent struct { - ID int64 `json:"id,required"` - Name string `json:"name,required"` - SuperCategoryID int64 `json:"super_category_id"` - JSON urlScannerScanGetResponseScanDomainsExampleComCategoriesContentJSON `json:"-"` -} - -// urlScannerScanGetResponseScanDomainsExampleComCategoriesContentJSON contains the -// JSON metadata for the struct -// [URLScannerScanGetResponseScanDomainsExampleComCategoriesContent] -type urlScannerScanGetResponseScanDomainsExampleComCategoriesContentJSON struct { - ID apijson.Field - Name apijson.Field - SuperCategoryID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanDomainsExampleComCategoriesContent) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanDomainsExampleComCategoriesContentJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanDomainsExampleComCategoriesRisk struct { - ID int64 `json:"id,required"` - Name string `json:"name,required"` - SuperCategoryID int64 `json:"super_category_id"` - JSON urlScannerScanGetResponseScanDomainsExampleComCategoriesRiskJSON `json:"-"` -} - -// urlScannerScanGetResponseScanDomainsExampleComCategoriesRiskJSON contains the -// JSON metadata for the struct -// [URLScannerScanGetResponseScanDomainsExampleComCategoriesRisk] -type urlScannerScanGetResponseScanDomainsExampleComCategoriesRiskJSON struct { - ID apijson.Field - Name apijson.Field - SuperCategoryID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanDomainsExampleComCategoriesRisk) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanDomainsExampleComCategoriesRiskJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanDomainsExampleComDNS struct { - Address string `json:"address,required"` - DNSSECValid bool `json:"dnssec_valid,required"` - Name string `json:"name,required"` - Type string `json:"type,required"` - JSON urlScannerScanGetResponseScanDomainsExampleComDNSJSON `json:"-"` -} - -// urlScannerScanGetResponseScanDomainsExampleComDNSJSON contains the JSON metadata -// for the struct [URLScannerScanGetResponseScanDomainsExampleComDNS] -type urlScannerScanGetResponseScanDomainsExampleComDNSJSON struct { - Address apijson.Field - DNSSECValid apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanDomainsExampleComDNS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanDomainsExampleComDNSJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanDomainsExampleComRank struct { - Bucket string `json:"bucket,required"` - Name string `json:"name,required"` - // Rank in the Global Radar Rank, if set. See more at - // https://blog.cloudflare.com/radar-domain-rankings/ - Rank int64 `json:"rank"` - JSON urlScannerScanGetResponseScanDomainsExampleComRankJSON `json:"-"` -} - -// urlScannerScanGetResponseScanDomainsExampleComRankJSON contains the JSON -// metadata for the struct [URLScannerScanGetResponseScanDomainsExampleComRank] -type urlScannerScanGetResponseScanDomainsExampleComRankJSON struct { - Bucket apijson.Field - Name apijson.Field - Rank apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanDomainsExampleComRank) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanDomainsExampleComRankJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanIPs struct { - IP URLScannerScanGetResponseScanIPsIP `json:"ip"` - JSON urlScannerScanGetResponseScanIPsJSON `json:"-"` -} - -// urlScannerScanGetResponseScanIPsJSON contains the JSON metadata for the struct -// [URLScannerScanGetResponseScanIPs] -type urlScannerScanGetResponseScanIPsJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanIPs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanIPsJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanIPsIP struct { - ASN string `json:"asn,required"` - ASNDescription string `json:"asnDescription,required"` - ASNLocationAlpha2 string `json:"asnLocationAlpha2,required"` - ASNName string `json:"asnName,required"` - ASNOrgName string `json:"asnOrgName,required"` - Continent string `json:"continent,required"` - GeonameID string `json:"geonameId,required"` - IP string `json:"ip,required"` - IPVersion string `json:"ipVersion,required"` - Latitude string `json:"latitude,required"` - LocationAlpha2 string `json:"locationAlpha2,required"` - LocationName string `json:"locationName,required"` - Longitude string `json:"longitude,required"` - Subdivision1Name string `json:"subdivision1Name,required"` - Subdivision2Name string `json:"subdivision2Name,required"` - JSON urlScannerScanGetResponseScanIPsIPJSON `json:"-"` -} - -// urlScannerScanGetResponseScanIPsIPJSON contains the JSON metadata for the struct -// [URLScannerScanGetResponseScanIPsIP] -type urlScannerScanGetResponseScanIPsIPJSON struct { - ASN apijson.Field - ASNDescription apijson.Field - ASNLocationAlpha2 apijson.Field - ASNName apijson.Field - ASNOrgName apijson.Field - Continent apijson.Field - GeonameID apijson.Field - IP apijson.Field - IPVersion apijson.Field - Latitude apijson.Field - LocationAlpha2 apijson.Field - LocationName apijson.Field - Longitude apijson.Field - Subdivision1Name apijson.Field - Subdivision2Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanIPsIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanIPsIPJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanLinks struct { - Link URLScannerScanGetResponseScanLinksLink `json:"link"` - JSON urlScannerScanGetResponseScanLinksJSON `json:"-"` -} - -// urlScannerScanGetResponseScanLinksJSON contains the JSON metadata for the struct -// [URLScannerScanGetResponseScanLinks] -type urlScannerScanGetResponseScanLinksJSON struct { - Link apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanLinks) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanLinksJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseScanLinksLink struct { - // Outgoing link detected in the DOM - Href string `json:"href,required"` - Text string `json:"text,required"` - JSON urlScannerScanGetResponseScanLinksLinkJSON `json:"-"` -} - -// urlScannerScanGetResponseScanLinksLinkJSON contains the JSON metadata for the -// struct [URLScannerScanGetResponseScanLinksLink] -type urlScannerScanGetResponseScanLinksLinkJSON struct { - Href apijson.Field - Text apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseScanLinksLink) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseScanLinksLinkJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanHarResponse struct { - Har URLScannerScanHarResponseHar `json:"har,required"` - JSON urlScannerScanHarResponseJSON `json:"-"` -} - -// urlScannerScanHarResponseJSON contains the JSON metadata for the struct -// [URLScannerScanHarResponse] -type urlScannerScanHarResponseJSON struct { - Har apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanHarResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanHarResponseJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanHarResponseHar struct { - Log URLScannerScanHarResponseHarLog `json:"log,required"` - JSON urlScannerScanHarResponseHarJSON `json:"-"` -} - -// urlScannerScanHarResponseHarJSON contains the JSON metadata for the struct -// [URLScannerScanHarResponseHar] -type urlScannerScanHarResponseHarJSON struct { - Log apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanHarResponseHar) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanHarResponseHarJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanHarResponseHarLog struct { - Creator URLScannerScanHarResponseHarLogCreator `json:"creator,required"` - Entries []URLScannerScanHarResponseHarLogEntry `json:"entries,required"` - Pages []URLScannerScanHarResponseHarLogPage `json:"pages,required"` - Version string `json:"version,required"` - JSON urlScannerScanHarResponseHarLogJSON `json:"-"` -} - -// urlScannerScanHarResponseHarLogJSON contains the JSON metadata for the struct -// [URLScannerScanHarResponseHarLog] -type urlScannerScanHarResponseHarLogJSON struct { - Creator apijson.Field - Entries apijson.Field - Pages apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanHarResponseHarLog) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanHarResponseHarLogJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanHarResponseHarLogCreator struct { - Comment string `json:"comment,required"` - Name string `json:"name,required"` - Version string `json:"version,required"` - JSON urlScannerScanHarResponseHarLogCreatorJSON `json:"-"` -} - -// urlScannerScanHarResponseHarLogCreatorJSON contains the JSON metadata for the -// struct [URLScannerScanHarResponseHarLogCreator] -type urlScannerScanHarResponseHarLogCreatorJSON struct { - Comment apijson.Field - Name apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanHarResponseHarLogCreator) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanHarResponseHarLogCreatorJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanHarResponseHarLogEntry struct { - InitialPriority string `json:"_initialPriority,required"` - InitiatorType string `json:"_initiator_type,required"` - Priority string `json:"_priority,required"` - RequestID string `json:"_requestId,required"` - RequestTime float64 `json:"_requestTime,required"` - ResourceType string `json:"_resourceType,required"` - Cache interface{} `json:"cache,required"` - Connection string `json:"connection,required"` - Pageref string `json:"pageref,required"` - Request URLScannerScanHarResponseHarLogEntriesRequest `json:"request,required"` - Response URLScannerScanHarResponseHarLogEntriesResponse `json:"response,required"` - ServerIPAddress string `json:"serverIPAddress,required"` - StartedDateTime string `json:"startedDateTime,required"` - Time float64 `json:"time,required"` - JSON urlScannerScanHarResponseHarLogEntryJSON `json:"-"` -} - -// urlScannerScanHarResponseHarLogEntryJSON contains the JSON metadata for the -// struct [URLScannerScanHarResponseHarLogEntry] -type urlScannerScanHarResponseHarLogEntryJSON struct { - InitialPriority apijson.Field - InitiatorType apijson.Field - Priority apijson.Field - RequestID apijson.Field - RequestTime apijson.Field - ResourceType apijson.Field - Cache apijson.Field - Connection apijson.Field - Pageref apijson.Field - Request apijson.Field - Response apijson.Field - ServerIPAddress apijson.Field - StartedDateTime apijson.Field - Time apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanHarResponseHarLogEntry) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanHarResponseHarLogEntryJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanHarResponseHarLogEntriesRequest struct { - BodySize float64 `json:"bodySize,required"` - Headers []URLScannerScanHarResponseHarLogEntriesRequestHeader `json:"headers,required"` - HeadersSize float64 `json:"headersSize,required"` - HTTPVersion string `json:"httpVersion,required"` - Method string `json:"method,required"` - URL string `json:"url,required"` - JSON urlScannerScanHarResponseHarLogEntriesRequestJSON `json:"-"` -} - -// urlScannerScanHarResponseHarLogEntriesRequestJSON contains the JSON metadata for -// the struct [URLScannerScanHarResponseHarLogEntriesRequest] -type urlScannerScanHarResponseHarLogEntriesRequestJSON struct { - BodySize apijson.Field - Headers apijson.Field - HeadersSize apijson.Field - HTTPVersion apijson.Field - Method apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanHarResponseHarLogEntriesRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanHarResponseHarLogEntriesRequestJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanHarResponseHarLogEntriesRequestHeader struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON urlScannerScanHarResponseHarLogEntriesRequestHeaderJSON `json:"-"` -} - -// urlScannerScanHarResponseHarLogEntriesRequestHeaderJSON contains the JSON -// metadata for the struct [URLScannerScanHarResponseHarLogEntriesRequestHeader] -type urlScannerScanHarResponseHarLogEntriesRequestHeaderJSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanHarResponseHarLogEntriesRequestHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanHarResponseHarLogEntriesRequestHeaderJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanHarResponseHarLogEntriesResponse struct { - TransferSize float64 `json:"_transferSize,required"` - BodySize float64 `json:"bodySize,required"` - Content URLScannerScanHarResponseHarLogEntriesResponseContent `json:"content,required"` - Headers []URLScannerScanHarResponseHarLogEntriesResponseHeader `json:"headers,required"` - HeadersSize float64 `json:"headersSize,required"` - HTTPVersion string `json:"httpVersion,required"` - RedirectURL string `json:"redirectURL,required"` - Status float64 `json:"status,required"` - StatusText string `json:"statusText,required"` - JSON urlScannerScanHarResponseHarLogEntriesResponseJSON `json:"-"` -} - -// urlScannerScanHarResponseHarLogEntriesResponseJSON contains the JSON metadata -// for the struct [URLScannerScanHarResponseHarLogEntriesResponse] -type urlScannerScanHarResponseHarLogEntriesResponseJSON struct { - TransferSize apijson.Field - BodySize apijson.Field - Content apijson.Field - Headers apijson.Field - HeadersSize apijson.Field - HTTPVersion apijson.Field - RedirectURL apijson.Field - Status apijson.Field - StatusText apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanHarResponseHarLogEntriesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanHarResponseHarLogEntriesResponseJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanHarResponseHarLogEntriesResponseContent struct { - MimeType string `json:"mimeType,required"` - Size float64 `json:"size,required"` - Compression int64 `json:"compression"` - JSON urlScannerScanHarResponseHarLogEntriesResponseContentJSON `json:"-"` -} - -// urlScannerScanHarResponseHarLogEntriesResponseContentJSON contains the JSON -// metadata for the struct [URLScannerScanHarResponseHarLogEntriesResponseContent] -type urlScannerScanHarResponseHarLogEntriesResponseContentJSON struct { - MimeType apijson.Field - Size apijson.Field - Compression apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanHarResponseHarLogEntriesResponseContent) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanHarResponseHarLogEntriesResponseContentJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanHarResponseHarLogEntriesResponseHeader struct { - Name string `json:"name,required"` - Value string `json:"value,required"` - JSON urlScannerScanHarResponseHarLogEntriesResponseHeaderJSON `json:"-"` -} - -// urlScannerScanHarResponseHarLogEntriesResponseHeaderJSON contains the JSON -// metadata for the struct [URLScannerScanHarResponseHarLogEntriesResponseHeader] -type urlScannerScanHarResponseHarLogEntriesResponseHeaderJSON struct { - Name apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanHarResponseHarLogEntriesResponseHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanHarResponseHarLogEntriesResponseHeaderJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanHarResponseHarLogPage struct { - ID string `json:"id,required"` - PageTimings URLScannerScanHarResponseHarLogPagesPageTimings `json:"pageTimings,required"` - StartedDateTime string `json:"startedDateTime,required"` - Title string `json:"title,required"` - JSON urlScannerScanHarResponseHarLogPageJSON `json:"-"` -} - -// urlScannerScanHarResponseHarLogPageJSON contains the JSON metadata for the -// struct [URLScannerScanHarResponseHarLogPage] -type urlScannerScanHarResponseHarLogPageJSON struct { - ID apijson.Field - PageTimings apijson.Field - StartedDateTime apijson.Field - Title apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanHarResponseHarLogPage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanHarResponseHarLogPageJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanHarResponseHarLogPagesPageTimings struct { - OnContentLoad float64 `json:"onContentLoad,required"` - OnLoad float64 `json:"onLoad,required"` - JSON urlScannerScanHarResponseHarLogPagesPageTimingsJSON `json:"-"` -} - -// urlScannerScanHarResponseHarLogPagesPageTimingsJSON contains the JSON metadata -// for the struct [URLScannerScanHarResponseHarLogPagesPageTimings] -type urlScannerScanHarResponseHarLogPagesPageTimingsJSON struct { - OnContentLoad apijson.Field - OnLoad apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanHarResponseHarLogPagesPageTimings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanHarResponseHarLogPagesPageTimingsJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanNewParams struct { - URL param.Field[string] `json:"url,required"` - // Set custom headers - CustomHeaders param.Field[map[string]string] `json:"customHeaders"` - // Take multiple screenshots targeting different device types - ScreenshotsResolutions param.Field[[]URLScannerScanNewParamsScreenshotsResolution] `json:"screenshotsResolutions"` - // The option `Public` means it will be included in listings like recent scans and - // search results. `Unlisted` means it will not be included in the aforementioned - // listings, users will need to have the scan's ID to access it. A a scan will be - // automatically marked as unlisted if it fails, if it contains potential PII or - // other sensitive material. - Visibility param.Field[URLScannerScanNewParamsVisibility] `json:"visibility"` -} - -func (r URLScannerScanNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Device resolutions. -type URLScannerScanNewParamsScreenshotsResolution string - -const ( - URLScannerScanNewParamsScreenshotsResolutionDesktop URLScannerScanNewParamsScreenshotsResolution = "desktop" - URLScannerScanNewParamsScreenshotsResolutionMobile URLScannerScanNewParamsScreenshotsResolution = "mobile" - URLScannerScanNewParamsScreenshotsResolutionTablet URLScannerScanNewParamsScreenshotsResolution = "tablet" -) - -// The option `Public` means it will be included in listings like recent scans and -// search results. `Unlisted` means it will not be included in the aforementioned -// listings, users will need to have the scan's ID to access it. A a scan will be -// automatically marked as unlisted if it fails, if it contains potential PII or -// other sensitive material. -type URLScannerScanNewParamsVisibility string - -const ( - URLScannerScanNewParamsVisibilityPublic URLScannerScanNewParamsVisibility = "Public" - URLScannerScanNewParamsVisibilityUnlisted URLScannerScanNewParamsVisibility = "Unlisted" -) - -type URLScannerScanNewResponseEnvelope struct { - Errors []URLScannerScanNewResponseEnvelopeErrors `json:"errors,required"` - Messages []URLScannerScanNewResponseEnvelopeMessages `json:"messages,required"` - Result URLScannerScanNewResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON urlScannerScanNewResponseEnvelopeJSON `json:"-"` -} - -// urlScannerScanNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [URLScannerScanNewResponseEnvelope] -type urlScannerScanNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanNewResponseEnvelopeErrors struct { - Message string `json:"message,required"` - JSON urlScannerScanNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// urlScannerScanNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [URLScannerScanNewResponseEnvelopeErrors] -type urlScannerScanNewResponseEnvelopeErrorsJSON struct { - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanNewResponseEnvelopeMessages struct { - Message string `json:"message,required"` - JSON urlScannerScanNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// urlScannerScanNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [URLScannerScanNewResponseEnvelopeMessages] -type urlScannerScanNewResponseEnvelopeMessagesJSON struct { - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseEnvelope struct { - Errors []URLScannerScanGetResponseEnvelopeErrors `json:"errors,required"` - Messages []URLScannerScanGetResponseEnvelopeMessages `json:"messages,required"` - Result URLScannerScanGetResponse `json:"result,required"` - // Whether request was successful or not - Success bool `json:"success,required"` - JSON urlScannerScanGetResponseEnvelopeJSON `json:"-"` -} - -// urlScannerScanGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [URLScannerScanGetResponseEnvelope] -type urlScannerScanGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseEnvelopeErrors struct { - Message string `json:"message,required"` - JSON urlScannerScanGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// urlScannerScanGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [URLScannerScanGetResponseEnvelopeErrors] -type urlScannerScanGetResponseEnvelopeErrorsJSON struct { - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanGetResponseEnvelopeMessages struct { - Message string `json:"message,required"` - JSON urlScannerScanGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// urlScannerScanGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [URLScannerScanGetResponseEnvelopeMessages] -type urlScannerScanGetResponseEnvelopeMessagesJSON struct { - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanHarResponseEnvelope struct { - Errors []URLScannerScanHarResponseEnvelopeErrors `json:"errors,required"` - Messages []URLScannerScanHarResponseEnvelopeMessages `json:"messages,required"` - Result URLScannerScanHarResponse `json:"result,required"` - // Whether search request was successful or not - Success bool `json:"success,required"` - JSON urlScannerScanHarResponseEnvelopeJSON `json:"-"` -} - -// urlScannerScanHarResponseEnvelopeJSON contains the JSON metadata for the struct -// [URLScannerScanHarResponseEnvelope] -type urlScannerScanHarResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanHarResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanHarResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanHarResponseEnvelopeErrors struct { - Message string `json:"message,required"` - JSON urlScannerScanHarResponseEnvelopeErrorsJSON `json:"-"` -} - -// urlScannerScanHarResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [URLScannerScanHarResponseEnvelopeErrors] -type urlScannerScanHarResponseEnvelopeErrorsJSON struct { - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanHarResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanHarResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanHarResponseEnvelopeMessages struct { - Message string `json:"message,required"` - JSON urlScannerScanHarResponseEnvelopeMessagesJSON `json:"-"` -} - -// urlScannerScanHarResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [URLScannerScanHarResponseEnvelopeMessages] -type urlScannerScanHarResponseEnvelopeMessagesJSON struct { - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *URLScannerScanHarResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r urlScannerScanHarResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type URLScannerScanScreenshotParams struct { - // Target device type - Resolution param.Field[URLScannerScanScreenshotParamsResolution] `query:"resolution"` -} - -// URLQuery serializes [URLScannerScanScreenshotParams]'s query parameters as -// `url.Values`. -func (r URLScannerScanScreenshotParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Target device type -type URLScannerScanScreenshotParamsResolution string - -const ( - URLScannerScanScreenshotParamsResolutionDesktop URLScannerScanScreenshotParamsResolution = "desktop" - URLScannerScanScreenshotParamsResolutionMobile URLScannerScanScreenshotParamsResolution = "mobile" - URLScannerScanScreenshotParamsResolutionTablet URLScannerScanScreenshotParamsResolution = "tablet" -) diff --git a/urlscannerscan_test.go b/urlscannerscan_test.go deleted file mode 100644 index 6e7a93de9d4..00000000000 --- a/urlscannerscan_test.go +++ /dev/null @@ -1,152 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "bytes" - "context" - "errors" - "io" - "net/http" - "net/http/httptest" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestURLScannerScanNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.URLScanner.Scans.New( - context.TODO(), - "string", - cloudflare.URLScannerScanNewParams{ - URL: cloudflare.F("https://www.example.com"), - CustomHeaders: cloudflare.F(map[string]string{ - "foo": "string", - }), - ScreenshotsResolutions: cloudflare.F([]cloudflare.URLScannerScanNewParamsScreenshotsResolution{cloudflare.URLScannerScanNewParamsScreenshotsResolutionDesktop, cloudflare.URLScannerScanNewParamsScreenshotsResolutionMobile, cloudflare.URLScannerScanNewParamsScreenshotsResolutionTablet}), - Visibility: cloudflare.F(cloudflare.URLScannerScanNewParamsVisibilityPublic), - }, - ) - 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 TestURLScannerScanGet(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("user@example.com"), - ) - _, err := client.URLScanner.Scans.Get( - context.TODO(), - "string", - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - 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 TestURLScannerScanHar(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("user@example.com"), - ) - _, err := client.URLScanner.Scans.Har( - context.TODO(), - "string", - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - ) - 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 TestURLScannerScanScreenshotWithOptionalParams(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - w.Write([]byte("abc")) - })) - defer server.Close() - baseURL := server.URL - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - resp, err := client.URLScanner.Scans.Screenshot( - context.TODO(), - "string", - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - cloudflare.URLScannerScanScreenshotParams{ - Resolution: cloudflare.F(cloudflare.URLScannerScanScreenshotParamsResolutionDesktop), - }, - ) - 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()) - } - defer resp.Body.Close() - - b, err := io.ReadAll(resp.Body) - 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()) - } - if !bytes.Equal(b, []byte("abc")) { - t.Fatalf("return value not %s: %s", "abc", b) - } -} diff --git a/usage_test.go b/usage_test.go index f7cf4900121..cc40416c212 100644 --- a/usage_test.go +++ b/usage_test.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" ) func TestUsage(t *testing.T) { @@ -25,12 +26,12 @@ func TestUsage(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - zoneNewResponse, err := client.Zones.New(context.TODO(), cloudflare.ZoneNewParams{ - Account: cloudflare.F(cloudflare.ZoneNewParamsAccount{ + zoneNewResponse, err := client.Zones.New(context.TODO(), zones.ZoneNewParams{ + Account: cloudflare.F(zones.ZoneNewParamsAccount{ ID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }), Name: cloudflare.F("example.com"), - Type: cloudflare.F(cloudflare.ZoneNewParamsTypeFull), + Type: cloudflare.F(zones.ZoneNewParamsTypeFull), }) if err != nil { t.Error(err) diff --git a/user/aliases.go b/user/aliases.go new file mode 100644 index 00000000000..6f8afe5f7c3 --- /dev/null +++ b/user/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package user + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/user/auditlog.go b/user/auditlog.go new file mode 100644 index 00000000000..aab4e194bec --- /dev/null +++ b/user/auditlog.go @@ -0,0 +1,302 @@ +// File generated from our OpenAPI spec by Stainless. + +package user + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" +) + +// AuditLogService 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 [NewAuditLogService] method instead. +type AuditLogService struct { + Options []option.RequestOption +} + +// NewAuditLogService 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 NewAuditLogService(opts ...option.RequestOption) (r *AuditLogService) { + r = &AuditLogService{} + r.Options = opts + return +} + +// Gets a list of audit logs for a user account. Can be filtered by who made the +// change, on which zone, and the timeframe of the change. +func (r *AuditLogService) List(ctx context.Context, query AuditLogListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[AuditLogListResponse], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "user/audit_logs" + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Gets a list of audit logs for a user account. Can be filtered by who made the +// change, on which zone, and the timeframe of the change. +func (r *AuditLogService) ListAutoPaging(ctx context.Context, query AuditLogListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[AuditLogListResponse] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, query, opts...)) +} + +type AuditLogListResponse struct { + // A string that uniquely identifies the audit log. + ID string `json:"id"` + Action AuditLogListResponseAction `json:"action"` + Actor AuditLogListResponseActor `json:"actor"` + // The source of the event. + Interface string `json:"interface"` + // An object which can lend more context to the action being logged. This is a + // flexible value and varies between different actions. + Metadata interface{} `json:"metadata"` + // The new value of the resource that was modified. + NewValue string `json:"newValue"` + // The value of the resource before it was modified. + OldValue string `json:"oldValue"` + Owner AuditLogListResponseOwner `json:"owner"` + Resource AuditLogListResponseResource `json:"resource"` + // A UTC RFC3339 timestamp that specifies when the action being logged occured. + When time.Time `json:"when" format:"date-time"` + JSON auditLogListResponseJSON `json:"-"` +} + +// auditLogListResponseJSON contains the JSON metadata for the struct +// [AuditLogListResponse] +type auditLogListResponseJSON struct { + ID apijson.Field + Action apijson.Field + Actor apijson.Field + Interface apijson.Field + Metadata apijson.Field + NewValue apijson.Field + OldValue apijson.Field + Owner apijson.Field + Resource apijson.Field + When apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AuditLogListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r auditLogListResponseJSON) RawJSON() string { + return r.raw +} + +type AuditLogListResponseAction struct { + // A boolean that indicates if the action attempted was successful. + Result bool `json:"result"` + // A short string that describes the action that was performed. + Type string `json:"type"` + JSON auditLogListResponseActionJSON `json:"-"` +} + +// auditLogListResponseActionJSON contains the JSON metadata for the struct +// [AuditLogListResponseAction] +type auditLogListResponseActionJSON struct { + Result apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AuditLogListResponseAction) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r auditLogListResponseActionJSON) RawJSON() string { + return r.raw +} + +type AuditLogListResponseActor struct { + // The ID of the actor that performed the action. If a user performed the action, + // this will be their User ID. + ID string `json:"id"` + // The email of the user that performed the action. + Email string `json:"email" format:"email"` + // The IP address of the request that performed the action. + IP string `json:"ip"` + // The type of actor, whether a User, Cloudflare Admin, or an Automated System. + Type AuditLogListResponseActorType `json:"type"` + JSON auditLogListResponseActorJSON `json:"-"` +} + +// auditLogListResponseActorJSON contains the JSON metadata for the struct +// [AuditLogListResponseActor] +type auditLogListResponseActorJSON struct { + ID apijson.Field + Email apijson.Field + IP apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AuditLogListResponseActor) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r auditLogListResponseActorJSON) RawJSON() string { + return r.raw +} + +// The type of actor, whether a User, Cloudflare Admin, or an Automated System. +type AuditLogListResponseActorType string + +const ( + AuditLogListResponseActorTypeUser AuditLogListResponseActorType = "user" + AuditLogListResponseActorTypeAdmin AuditLogListResponseActorType = "admin" + AuditLogListResponseActorTypeCloudflare AuditLogListResponseActorType = "Cloudflare" +) + +type AuditLogListResponseOwner struct { + // Identifier + ID string `json:"id"` + JSON auditLogListResponseOwnerJSON `json:"-"` +} + +// auditLogListResponseOwnerJSON contains the JSON metadata for the struct +// [AuditLogListResponseOwner] +type auditLogListResponseOwnerJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AuditLogListResponseOwner) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r auditLogListResponseOwnerJSON) RawJSON() string { + return r.raw +} + +type AuditLogListResponseResource struct { + // An identifier for the resource that was affected by the action. + ID string `json:"id"` + // A short string that describes the resource that was affected by the action. + Type string `json:"type"` + JSON auditLogListResponseResourceJSON `json:"-"` +} + +// auditLogListResponseResourceJSON contains the JSON metadata for the struct +// [AuditLogListResponseResource] +type auditLogListResponseResourceJSON struct { + ID apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AuditLogListResponseResource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r auditLogListResponseResourceJSON) RawJSON() string { + return r.raw +} + +type AuditLogListParams struct { + // Finds a specific log by its ID. + ID param.Field[string] `query:"id"` + Action param.Field[AuditLogListParamsAction] `query:"action"` + Actor param.Field[AuditLogListParamsActor] `query:"actor"` + // Limits the returned results to logs older than the specified date. This can be a + // date string `2019-04-30` or an absolute timestamp that conforms to RFC3339. + Before param.Field[time.Time] `query:"before" format:"date-time"` + // Changes the direction of the chronological sorting. + Direction param.Field[AuditLogListParamsDirection] `query:"direction"` + // Indicates that this request is an export of logs in CSV format. + Export param.Field[bool] `query:"export"` + // Indicates whether or not to hide user level audit logs. + HideUserLogs param.Field[bool] `query:"hide_user_logs"` + // Defines which page of results to return. + Page param.Field[float64] `query:"page"` + // Sets the number of results to return per page. + PerPage param.Field[float64] `query:"per_page"` + // Limits the returned results to logs newer than the specified date. This can be a + // date string `2019-04-30` or an absolute timestamp that conforms to RFC3339. + Since param.Field[time.Time] `query:"since" format:"date-time"` + Zone param.Field[AuditLogListParamsZone] `query:"zone"` +} + +// URLQuery serializes [AuditLogListParams]'s query parameters as `url.Values`. +func (r AuditLogListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AuditLogListParamsAction struct { + // Filters by the action type. + Type param.Field[string] `query:"type"` +} + +// URLQuery serializes [AuditLogListParamsAction]'s query parameters as +// `url.Values`. +func (r AuditLogListParamsAction) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type AuditLogListParamsActor struct { + // Filters by the email address of the actor that made the change. + Email param.Field[string] `query:"email" format:"email"` + // Filters by the IP address of the request that made the change by specific IP + // address or valid CIDR Range. + IP param.Field[string] `query:"ip"` +} + +// URLQuery serializes [AuditLogListParamsActor]'s query parameters as +// `url.Values`. +func (r AuditLogListParamsActor) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Changes the direction of the chronological sorting. +type AuditLogListParamsDirection string + +const ( + AuditLogListParamsDirectionDesc AuditLogListParamsDirection = "desc" + AuditLogListParamsDirectionAsc AuditLogListParamsDirection = "asc" +) + +type AuditLogListParamsZone struct { + // Filters by the name of the zone associated to the change. + Name param.Field[string] `query:"name"` +} + +// URLQuery serializes [AuditLogListParamsZone]'s query parameters as `url.Values`. +func (r AuditLogListParamsZone) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/user/auditlog_test.go b/user/auditlog_test.go new file mode 100644 index 00000000000..920df77bd7a --- /dev/null +++ b/user/auditlog_test.go @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package user_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/user" +) + +func TestAuditLogListWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.AuditLogs.List(context.TODO(), user.AuditLogListParams{ + ID: cloudflare.F("f174be97-19b1-40d6-954d-70cd5fbd52db"), + Action: cloudflare.F(user.AuditLogListParamsAction{ + Type: cloudflare.F("add"), + }), + Actor: cloudflare.F(user.AuditLogListParamsActor{ + IP: cloudflare.F("17.168.228.63"), + Email: cloudflare.F("alice@example.com"), + }), + Before: cloudflare.F(time.Now()), + Direction: cloudflare.F(user.AuditLogListParamsDirectionDesc), + Export: cloudflare.F(true), + HideUserLogs: cloudflare.F(true), + Page: cloudflare.F(50.000000), + PerPage: cloudflare.F(25.000000), + Since: cloudflare.F(time.Now()), + Zone: cloudflare.F(user.AuditLogListParamsZone{ + Name: cloudflare.F("example.com"), + }), + }) + 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/user/billing.go b/user/billing.go new file mode 100644 index 00000000000..5c5a92bad1b --- /dev/null +++ b/user/billing.go @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package user + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// BillingService 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 [NewBillingService] method instead. +type BillingService struct { + Options []option.RequestOption + History *BillingHistoryService + Profiles *BillingProfileService +} + +// NewBillingService 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 NewBillingService(opts ...option.RequestOption) (r *BillingService) { + r = &BillingService{} + r.Options = opts + r.History = NewBillingHistoryService(opts...) + r.Profiles = NewBillingProfileService(opts...) + return +} diff --git a/user/billinghistory.go b/user/billinghistory.go new file mode 100644 index 00000000000..123220e5d66 --- /dev/null +++ b/user/billinghistory.go @@ -0,0 +1,251 @@ +// File generated from our OpenAPI spec by Stainless. + +package user + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// BillingHistoryService 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 [NewBillingHistoryService] method +// instead. +type BillingHistoryService struct { + Options []option.RequestOption +} + +// NewBillingHistoryService 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 NewBillingHistoryService(opts ...option.RequestOption) (r *BillingHistoryService) { + r = &BillingHistoryService{} + r.Options = opts + return +} + +// Accesses your billing history object. +func (r *BillingHistoryService) Get(ctx context.Context, query BillingHistoryGetParams, opts ...option.RequestOption) (res *[]BillSubsAPIBillingHistory, err error) { + opts = append(r.Options[:], opts...) + var env BillingHistoryGetResponseEnvelope + path := "user/billing/history" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type BillSubsAPIBillingHistory struct { + // Billing item identifier tag. + ID string `json:"id,required"` + // The billing item action. + Action string `json:"action,required"` + // The amount associated with this billing item. + Amount float64 `json:"amount,required"` + // The monetary unit in which pricing information is displayed. + Currency string `json:"currency,required"` + // The billing item description. + Description string `json:"description,required"` + // When the billing item was created. + OccurredAt time.Time `json:"occurred_at,required" format:"date-time"` + // The billing item type. + Type string `json:"type,required"` + Zone BillSubsAPIBillingHistoryZone `json:"zone,required"` + JSON billSubsAPIBillingHistoryJSON `json:"-"` +} + +// billSubsAPIBillingHistoryJSON contains the JSON metadata for the struct +// [BillSubsAPIBillingHistory] +type billSubsAPIBillingHistoryJSON struct { + ID apijson.Field + Action apijson.Field + Amount apijson.Field + Currency apijson.Field + Description apijson.Field + OccurredAt apijson.Field + Type apijson.Field + Zone apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BillSubsAPIBillingHistory) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r billSubsAPIBillingHistoryJSON) RawJSON() string { + return r.raw +} + +type BillSubsAPIBillingHistoryZone struct { + Name interface{} `json:"name"` + JSON billSubsAPIBillingHistoryZoneJSON `json:"-"` +} + +// billSubsAPIBillingHistoryZoneJSON contains the JSON metadata for the struct +// [BillSubsAPIBillingHistoryZone] +type billSubsAPIBillingHistoryZoneJSON struct { + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BillSubsAPIBillingHistoryZone) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r billSubsAPIBillingHistoryZoneJSON) RawJSON() string { + return r.raw +} + +type BillingHistoryGetParams struct { + // Field to order billing history by. + Order param.Field[BillingHistoryGetParamsOrder] `query:"order"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // Number of items per page. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [BillingHistoryGetParams]'s query parameters as +// `url.Values`. +func (r BillingHistoryGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Field to order billing history by. +type BillingHistoryGetParamsOrder string + +const ( + BillingHistoryGetParamsOrderType BillingHistoryGetParamsOrder = "type" + BillingHistoryGetParamsOrderOccuredAt BillingHistoryGetParamsOrder = "occured_at" + BillingHistoryGetParamsOrderAction BillingHistoryGetParamsOrder = "action" +) + +type BillingHistoryGetResponseEnvelope struct { + Errors []BillingHistoryGetResponseEnvelopeErrors `json:"errors,required"` + Messages []BillingHistoryGetResponseEnvelopeMessages `json:"messages,required"` + Result []BillSubsAPIBillingHistory `json:"result,required,nullable"` + // Whether the API call was successful + Success BillingHistoryGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo BillingHistoryGetResponseEnvelopeResultInfo `json:"result_info"` + JSON billingHistoryGetResponseEnvelopeJSON `json:"-"` +} + +// billingHistoryGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [BillingHistoryGetResponseEnvelope] +type billingHistoryGetResponseEnvelopeJSON 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 *BillingHistoryGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r billingHistoryGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type BillingHistoryGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON billingHistoryGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// billingHistoryGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [BillingHistoryGetResponseEnvelopeErrors] +type billingHistoryGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BillingHistoryGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r billingHistoryGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type BillingHistoryGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON billingHistoryGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// billingHistoryGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [BillingHistoryGetResponseEnvelopeMessages] +type billingHistoryGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BillingHistoryGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r billingHistoryGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type BillingHistoryGetResponseEnvelopeSuccess bool + +const ( + BillingHistoryGetResponseEnvelopeSuccessTrue BillingHistoryGetResponseEnvelopeSuccess = true +) + +type BillingHistoryGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON billingHistoryGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// billingHistoryGetResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [BillingHistoryGetResponseEnvelopeResultInfo] +type billingHistoryGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *BillingHistoryGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r billingHistoryGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/user/billinghistory_test.go b/user/billinghistory_test.go new file mode 100644 index 00000000000..9628ea17764 --- /dev/null +++ b/user/billinghistory_test.go @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package user_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/user" +) + +func TestBillingHistoryGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.Billing.History.Get(context.TODO(), user.BillingHistoryGetParams{ + Order: cloudflare.F(user.BillingHistoryGetParamsOrderOccuredAt), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(5.000000), + }) + 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/billingprofile.go b/user/billingprofile.go similarity index 91% rename from billingprofile.go rename to user/billingprofile.go index 9e8ec7e726b..aaaa3ca8fef 100644 --- a/billingprofile.go +++ b/user/billingprofile.go @@ -1,10 +1,9 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package user import ( "context" - "fmt" "net/http" "reflect" @@ -33,11 +32,11 @@ func NewBillingProfileService(opts ...option.RequestOption) (r *BillingProfileSe return } -// Gets the current billing profile for the account. -func (r *BillingProfileService) Get(ctx context.Context, accountIdentifier interface{}, opts ...option.RequestOption) (res *BillingProfileGetResponse, err error) { +// Accesses your billing profile object. +func (r *BillingProfileService) Get(ctx context.Context, opts ...option.RequestOption) (res *BillingProfileGetResponse, err error) { opts = append(r.Options[:], opts...) var env BillingProfileGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/billing/profile", accountIdentifier) + path := "user/billing/profile" err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) if err != nil { return @@ -46,9 +45,10 @@ func (r *BillingProfileService) Get(ctx context.Context, accountIdentifier inter return } -// Union satisfied by [BillingProfileGetResponseUnknown] or [shared.UnionString]. +// Union satisfied by [user.BillingProfileGetResponseUnknown] or +// [shared.UnionString]. type BillingProfileGetResponse interface { - ImplementsBillingProfileGetResponse() + ImplementsUserBillingProfileGetResponse() } func init() { diff --git a/billingprofile_test.go b/user/billingprofile_test.go similarity index 89% rename from billingprofile_test.go rename to user/billingprofile_test.go index 7076d7af109..4aedbb50668 100644 --- a/billingprofile_test.go +++ b/user/billingprofile_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package user_test import ( "context" @@ -27,7 +27,7 @@ func TestBillingProfileGet(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Billing.Profiles.Get(context.TODO(), map[string]interface{}{}) + _, err := client.User.Billing.Profiles.Get(context.TODO()) if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { diff --git a/user/firewall.go b/user/firewall.go new file mode 100644 index 00000000000..35a746d6074 --- /dev/null +++ b/user/firewall.go @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package user + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// FirewallService 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 [NewFirewallService] method instead. +type FirewallService struct { + Options []option.RequestOption + AccessRules *FirewallAccessRuleService +} + +// NewFirewallService 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 NewFirewallService(opts ...option.RequestOption) (r *FirewallService) { + r = &FirewallService{} + r.Options = opts + r.AccessRules = NewFirewallAccessRuleService(opts...) + return +} diff --git a/user/firewallaccessrule.go b/user/firewallaccessrule.go new file mode 100644 index 00000000000..23a4a5cee6d --- /dev/null +++ b/user/firewallaccessrule.go @@ -0,0 +1,964 @@ +// File generated from our OpenAPI spec by Stainless. + +package user + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// FirewallAccessRuleService 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 [NewFirewallAccessRuleService] method +// instead. +type FirewallAccessRuleService struct { + Options []option.RequestOption +} + +// NewFirewallAccessRuleService 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 NewFirewallAccessRuleService(opts ...option.RequestOption) (r *FirewallAccessRuleService) { + r = &FirewallAccessRuleService{} + r.Options = opts + return +} + +// Creates a new IP Access rule for all zones owned by the current user. +// +// Note: To create an IP Access rule that applies to a specific zone, refer to the +// [IP Access rules for a zone](#ip-access-rules-for-a-zone) endpoints. +func (r *FirewallAccessRuleService) New(ctx context.Context, body FirewallAccessRuleNewParams, opts ...option.RequestOption) (res *LegacyJhsRule, err error) { + opts = append(r.Options[:], opts...) + var env FirewallAccessRuleNewResponseEnvelope + path := "user/firewall/access_rules/rules" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches IP Access rules of the user. You can filter the results using several +// optional parameters. +func (r *FirewallAccessRuleService) List(ctx context.Context, query FirewallAccessRuleListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[LegacyJhsRule], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "user/firewall/access_rules/rules" + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Fetches IP Access rules of the user. You can filter the results using several +// optional parameters. +func (r *FirewallAccessRuleService) ListAutoPaging(ctx context.Context, query FirewallAccessRuleListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[LegacyJhsRule] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, query, opts...)) +} + +// Deletes an IP Access rule at the user level. +// +// Note: Deleting a user-level rule will affect all zones owned by the user. +func (r *FirewallAccessRuleService) Delete(ctx context.Context, identifier string, opts ...option.RequestOption) (res *FirewallAccessRuleDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env FirewallAccessRuleDeleteResponseEnvelope + path := fmt.Sprintf("user/firewall/access_rules/rules/%s", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates an IP Access rule defined at the user level. You can only update the +// rule action (`mode` parameter) and notes. +func (r *FirewallAccessRuleService) Edit(ctx context.Context, identifier string, body FirewallAccessRuleEditParams, opts ...option.RequestOption) (res *LegacyJhsRule, err error) { + opts = append(r.Options[:], opts...) + var env FirewallAccessRuleEditResponseEnvelope + path := fmt.Sprintf("user/firewall/access_rules/rules/%s", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type LegacyJhsRule struct { + // The unique identifier of the IP Access rule. + ID string `json:"id,required"` + // The available actions that a rule can apply to a matched request. + AllowedModes []LegacyJhsRuleAllowedMode `json:"allowed_modes,required"` + // The rule configuration. + Configuration LegacyJhsRuleConfiguration `json:"configuration,required"` + // The action to apply to a matched request. + Mode LegacyJhsRuleMode `json:"mode,required"` + // The timestamp of when the rule was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // The timestamp of when the rule was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // An informative summary of the rule, typically used as a reminder or explanation. + Notes string `json:"notes"` + JSON legacyJhsRuleJSON `json:"-"` +} + +// legacyJhsRuleJSON contains the JSON metadata for the struct [LegacyJhsRule] +type legacyJhsRuleJSON struct { + ID apijson.Field + AllowedModes apijson.Field + Configuration apijson.Field + Mode apijson.Field + CreatedOn apijson.Field + ModifiedOn apijson.Field + Notes apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LegacyJhsRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r legacyJhsRuleJSON) RawJSON() string { + return r.raw +} + +// The action to apply to a matched request. +type LegacyJhsRuleAllowedMode string + +const ( + LegacyJhsRuleAllowedModeBlock LegacyJhsRuleAllowedMode = "block" + LegacyJhsRuleAllowedModeChallenge LegacyJhsRuleAllowedMode = "challenge" + LegacyJhsRuleAllowedModeWhitelist LegacyJhsRuleAllowedMode = "whitelist" + LegacyJhsRuleAllowedModeJsChallenge LegacyJhsRuleAllowedMode = "js_challenge" + LegacyJhsRuleAllowedModeManagedChallenge LegacyJhsRuleAllowedMode = "managed_challenge" +) + +// The rule configuration. +// +// Union satisfied by [user.LegacyJhsRuleConfigurationLegacyJhsIPConfiguration], +// [user.LegacyJhsRuleConfigurationLegacyJhsIPV6Configuration], +// [user.LegacyJhsRuleConfigurationLegacyJhsCidrConfiguration], +// [user.LegacyJhsRuleConfigurationLegacyJhsASNConfiguration] or +// [user.LegacyJhsRuleConfigurationLegacyJhsCountryConfiguration]. +type LegacyJhsRuleConfiguration interface { + implementsUserLegacyJhsRuleConfiguration() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*LegacyJhsRuleConfiguration)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LegacyJhsRuleConfigurationLegacyJhsIPConfiguration{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LegacyJhsRuleConfigurationLegacyJhsIPV6Configuration{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LegacyJhsRuleConfigurationLegacyJhsCidrConfiguration{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LegacyJhsRuleConfigurationLegacyJhsASNConfiguration{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(LegacyJhsRuleConfigurationLegacyJhsCountryConfiguration{}), + }, + ) +} + +type LegacyJhsRuleConfigurationLegacyJhsIPConfiguration struct { + // The configuration target. You must set the target to `ip` when specifying an IP + // address in the rule. + Target LegacyJhsRuleConfigurationLegacyJhsIPConfigurationTarget `json:"target"` + // The IP address to match. This address will be compared to the IP address of + // incoming requests. + Value string `json:"value"` + JSON legacyJhsRuleConfigurationLegacyJhsIPConfigurationJSON `json:"-"` +} + +// legacyJhsRuleConfigurationLegacyJhsIPConfigurationJSON contains the JSON +// metadata for the struct [LegacyJhsRuleConfigurationLegacyJhsIPConfiguration] +type legacyJhsRuleConfigurationLegacyJhsIPConfigurationJSON struct { + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LegacyJhsRuleConfigurationLegacyJhsIPConfiguration) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r legacyJhsRuleConfigurationLegacyJhsIPConfigurationJSON) RawJSON() string { + return r.raw +} + +func (r LegacyJhsRuleConfigurationLegacyJhsIPConfiguration) implementsUserLegacyJhsRuleConfiguration() { +} + +// The configuration target. You must set the target to `ip` when specifying an IP +// address in the rule. +type LegacyJhsRuleConfigurationLegacyJhsIPConfigurationTarget string + +const ( + LegacyJhsRuleConfigurationLegacyJhsIPConfigurationTargetIP LegacyJhsRuleConfigurationLegacyJhsIPConfigurationTarget = "ip" +) + +type LegacyJhsRuleConfigurationLegacyJhsIPV6Configuration struct { + // The configuration target. You must set the target to `ip6` when specifying an + // IPv6 address in the rule. + Target LegacyJhsRuleConfigurationLegacyJhsIPV6ConfigurationTarget `json:"target"` + // The IPv6 address to match. + Value string `json:"value"` + JSON legacyJhsRuleConfigurationLegacyJhsIPV6ConfigurationJSON `json:"-"` +} + +// legacyJhsRuleConfigurationLegacyJhsIPV6ConfigurationJSON contains the JSON +// metadata for the struct [LegacyJhsRuleConfigurationLegacyJhsIPV6Configuration] +type legacyJhsRuleConfigurationLegacyJhsIPV6ConfigurationJSON struct { + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LegacyJhsRuleConfigurationLegacyJhsIPV6Configuration) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r legacyJhsRuleConfigurationLegacyJhsIPV6ConfigurationJSON) RawJSON() string { + return r.raw +} + +func (r LegacyJhsRuleConfigurationLegacyJhsIPV6Configuration) implementsUserLegacyJhsRuleConfiguration() { +} + +// The configuration target. You must set the target to `ip6` when specifying an +// IPv6 address in the rule. +type LegacyJhsRuleConfigurationLegacyJhsIPV6ConfigurationTarget string + +const ( + LegacyJhsRuleConfigurationLegacyJhsIPV6ConfigurationTargetIp6 LegacyJhsRuleConfigurationLegacyJhsIPV6ConfigurationTarget = "ip6" +) + +type LegacyJhsRuleConfigurationLegacyJhsCidrConfiguration struct { + // The configuration target. You must set the target to `ip_range` when specifying + // an IP address range in the rule. + Target LegacyJhsRuleConfigurationLegacyJhsCidrConfigurationTarget `json:"target"` + // The IP address range to match. You can only use prefix lengths `/16` and `/24` + // for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. + Value string `json:"value"` + JSON legacyJhsRuleConfigurationLegacyJhsCidrConfigurationJSON `json:"-"` +} + +// legacyJhsRuleConfigurationLegacyJhsCidrConfigurationJSON contains the JSON +// metadata for the struct [LegacyJhsRuleConfigurationLegacyJhsCidrConfiguration] +type legacyJhsRuleConfigurationLegacyJhsCidrConfigurationJSON struct { + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LegacyJhsRuleConfigurationLegacyJhsCidrConfiguration) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r legacyJhsRuleConfigurationLegacyJhsCidrConfigurationJSON) RawJSON() string { + return r.raw +} + +func (r LegacyJhsRuleConfigurationLegacyJhsCidrConfiguration) implementsUserLegacyJhsRuleConfiguration() { +} + +// The configuration target. You must set the target to `ip_range` when specifying +// an IP address range in the rule. +type LegacyJhsRuleConfigurationLegacyJhsCidrConfigurationTarget string + +const ( + LegacyJhsRuleConfigurationLegacyJhsCidrConfigurationTargetIPRange LegacyJhsRuleConfigurationLegacyJhsCidrConfigurationTarget = "ip_range" +) + +type LegacyJhsRuleConfigurationLegacyJhsASNConfiguration struct { + // The configuration target. You must set the target to `asn` when specifying an + // Autonomous System Number (ASN) in the rule. + Target LegacyJhsRuleConfigurationLegacyJhsASNConfigurationTarget `json:"target"` + // The AS number to match. + Value string `json:"value"` + JSON legacyJhsRuleConfigurationLegacyJhsASNConfigurationJSON `json:"-"` +} + +// legacyJhsRuleConfigurationLegacyJhsASNConfigurationJSON contains the JSON +// metadata for the struct [LegacyJhsRuleConfigurationLegacyJhsASNConfiguration] +type legacyJhsRuleConfigurationLegacyJhsASNConfigurationJSON struct { + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LegacyJhsRuleConfigurationLegacyJhsASNConfiguration) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r legacyJhsRuleConfigurationLegacyJhsASNConfigurationJSON) RawJSON() string { + return r.raw +} + +func (r LegacyJhsRuleConfigurationLegacyJhsASNConfiguration) implementsUserLegacyJhsRuleConfiguration() { +} + +// The configuration target. You must set the target to `asn` when specifying an +// Autonomous System Number (ASN) in the rule. +type LegacyJhsRuleConfigurationLegacyJhsASNConfigurationTarget string + +const ( + LegacyJhsRuleConfigurationLegacyJhsASNConfigurationTargetASN LegacyJhsRuleConfigurationLegacyJhsASNConfigurationTarget = "asn" +) + +type LegacyJhsRuleConfigurationLegacyJhsCountryConfiguration struct { + // The configuration target. You must set the target to `country` when specifying a + // country code in the rule. + Target LegacyJhsRuleConfigurationLegacyJhsCountryConfigurationTarget `json:"target"` + // The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to + // [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). + Value string `json:"value"` + JSON legacyJhsRuleConfigurationLegacyJhsCountryConfigurationJSON `json:"-"` +} + +// legacyJhsRuleConfigurationLegacyJhsCountryConfigurationJSON contains the JSON +// metadata for the struct +// [LegacyJhsRuleConfigurationLegacyJhsCountryConfiguration] +type legacyJhsRuleConfigurationLegacyJhsCountryConfigurationJSON struct { + Target apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LegacyJhsRuleConfigurationLegacyJhsCountryConfiguration) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r legacyJhsRuleConfigurationLegacyJhsCountryConfigurationJSON) RawJSON() string { + return r.raw +} + +func (r LegacyJhsRuleConfigurationLegacyJhsCountryConfiguration) implementsUserLegacyJhsRuleConfiguration() { +} + +// The configuration target. You must set the target to `country` when specifying a +// country code in the rule. +type LegacyJhsRuleConfigurationLegacyJhsCountryConfigurationTarget string + +const ( + LegacyJhsRuleConfigurationLegacyJhsCountryConfigurationTargetCountry LegacyJhsRuleConfigurationLegacyJhsCountryConfigurationTarget = "country" +) + +// The action to apply to a matched request. +type LegacyJhsRuleMode string + +const ( + LegacyJhsRuleModeBlock LegacyJhsRuleMode = "block" + LegacyJhsRuleModeChallenge LegacyJhsRuleMode = "challenge" + LegacyJhsRuleModeWhitelist LegacyJhsRuleMode = "whitelist" + LegacyJhsRuleModeJsChallenge LegacyJhsRuleMode = "js_challenge" + LegacyJhsRuleModeManagedChallenge LegacyJhsRuleMode = "managed_challenge" +) + +type FirewallAccessRuleDeleteResponse struct { + // The unique identifier of the IP Access rule. + ID string `json:"id"` + JSON firewallAccessRuleDeleteResponseJSON `json:"-"` +} + +// firewallAccessRuleDeleteResponseJSON contains the JSON metadata for the struct +// [FirewallAccessRuleDeleteResponse] +type firewallAccessRuleDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallAccessRuleDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallAccessRuleDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type FirewallAccessRuleNewParams struct { + // The rule configuration. + Configuration param.Field[FirewallAccessRuleNewParamsConfiguration] `json:"configuration,required"` + // The action to apply to a matched request. + Mode param.Field[FirewallAccessRuleNewParamsMode] `json:"mode,required"` + // An informative summary of the rule, typically used as a reminder or explanation. + Notes param.Field[string] `json:"notes"` +} + +func (r FirewallAccessRuleNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The rule configuration. +// +// Satisfied by +// [user.FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration], +// [user.FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration], +// [user.FirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfiguration], +// [user.FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfiguration], +// [user.FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration]. +type FirewallAccessRuleNewParamsConfiguration interface { + implementsUserFirewallAccessRuleNewParamsConfiguration() +} + +type FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration struct { + // The configuration target. You must set the target to `ip` when specifying an IP + // address in the rule. + Target param.Field[FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget] `json:"target"` + // The IP address to match. This address will be compared to the IP address of + // incoming requests. + Value param.Field[string] `json:"value"` +} + +func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration) implementsUserFirewallAccessRuleNewParamsConfiguration() { +} + +// The configuration target. You must set the target to `ip` when specifying an IP +// address in the rule. +type FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget string + +const ( + FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTargetIP FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget = "ip" +) + +type FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration struct { + // The configuration target. You must set the target to `ip6` when specifying an + // IPv6 address in the rule. + Target param.Field[FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget] `json:"target"` + // The IPv6 address to match. + Value param.Field[string] `json:"value"` +} + +func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration) implementsUserFirewallAccessRuleNewParamsConfiguration() { +} + +// The configuration target. You must set the target to `ip6` when specifying an +// IPv6 address in the rule. +type FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget string + +const ( + FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTargetIp6 FirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget = "ip6" +) + +type FirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfiguration struct { + // The configuration target. You must set the target to `ip_range` when specifying + // an IP address range in the rule. + Target param.Field[FirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfigurationTarget] `json:"target"` + // The IP address range to match. You can only use prefix lengths `/16` and `/24` + // for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. + Value param.Field[string] `json:"value"` +} + +func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfiguration) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfiguration) implementsUserFirewallAccessRuleNewParamsConfiguration() { +} + +// The configuration target. You must set the target to `ip_range` when specifying +// an IP address range in the rule. +type FirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfigurationTarget string + +const ( + FirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfigurationTargetIPRange FirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfigurationTarget = "ip_range" +) + +type FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfiguration struct { + // The configuration target. You must set the target to `asn` when specifying an + // Autonomous System Number (ASN) in the rule. + Target param.Field[FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget] `json:"target"` + // The AS number to match. + Value param.Field[string] `json:"value"` +} + +func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfiguration) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfiguration) implementsUserFirewallAccessRuleNewParamsConfiguration() { +} + +// The configuration target. You must set the target to `asn` when specifying an +// Autonomous System Number (ASN) in the rule. +type FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget string + +const ( + FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTargetASN FirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget = "asn" +) + +type FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration struct { + // The configuration target. You must set the target to `country` when specifying a + // country code in the rule. + Target param.Field[FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget] `json:"target"` + // The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to + // [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). + Value param.Field[string] `json:"value"` +} + +func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration) implementsUserFirewallAccessRuleNewParamsConfiguration() { +} + +// The configuration target. You must set the target to `country` when specifying a +// country code in the rule. +type FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget string + +const ( + FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTargetCountry FirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget = "country" +) + +// The action to apply to a matched request. +type FirewallAccessRuleNewParamsMode string + +const ( + FirewallAccessRuleNewParamsModeBlock FirewallAccessRuleNewParamsMode = "block" + FirewallAccessRuleNewParamsModeChallenge FirewallAccessRuleNewParamsMode = "challenge" + FirewallAccessRuleNewParamsModeWhitelist FirewallAccessRuleNewParamsMode = "whitelist" + FirewallAccessRuleNewParamsModeJsChallenge FirewallAccessRuleNewParamsMode = "js_challenge" + FirewallAccessRuleNewParamsModeManagedChallenge FirewallAccessRuleNewParamsMode = "managed_challenge" +) + +type FirewallAccessRuleNewResponseEnvelope struct { + Errors []FirewallAccessRuleNewResponseEnvelopeErrors `json:"errors,required"` + Messages []FirewallAccessRuleNewResponseEnvelopeMessages `json:"messages,required"` + Result LegacyJhsRule `json:"result,required,nullable"` + // Whether the API call was successful + Success FirewallAccessRuleNewResponseEnvelopeSuccess `json:"success,required"` + JSON firewallAccessRuleNewResponseEnvelopeJSON `json:"-"` +} + +// firewallAccessRuleNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [FirewallAccessRuleNewResponseEnvelope] +type firewallAccessRuleNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallAccessRuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallAccessRuleNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FirewallAccessRuleNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON firewallAccessRuleNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// firewallAccessRuleNewResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [FirewallAccessRuleNewResponseEnvelopeErrors] +type firewallAccessRuleNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallAccessRuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallAccessRuleNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FirewallAccessRuleNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON firewallAccessRuleNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// firewallAccessRuleNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [FirewallAccessRuleNewResponseEnvelopeMessages] +type firewallAccessRuleNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallAccessRuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallAccessRuleNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FirewallAccessRuleNewResponseEnvelopeSuccess bool + +const ( + FirewallAccessRuleNewResponseEnvelopeSuccessTrue FirewallAccessRuleNewResponseEnvelopeSuccess = true +) + +type FirewallAccessRuleListParams struct { + // The direction used to sort returned rules. + Direction param.Field[FirewallAccessRuleListParamsDirection] `query:"direction"` + EgsPagination param.Field[FirewallAccessRuleListParamsEgsPagination] `query:"egs-pagination"` + Filters param.Field[FirewallAccessRuleListParamsFilters] `query:"filters"` + // The field used to sort returned rules. + Order param.Field[FirewallAccessRuleListParamsOrder] `query:"order"` + // Requested page within paginated list of results. + Page param.Field[float64] `query:"page"` + // Maximum number of results requested. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [FirewallAccessRuleListParams]'s query parameters as +// `url.Values`. +func (r FirewallAccessRuleListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// The direction used to sort returned rules. +type FirewallAccessRuleListParamsDirection string + +const ( + FirewallAccessRuleListParamsDirectionAsc FirewallAccessRuleListParamsDirection = "asc" + FirewallAccessRuleListParamsDirectionDesc FirewallAccessRuleListParamsDirection = "desc" +) + +type FirewallAccessRuleListParamsEgsPagination struct { + Json param.Field[FirewallAccessRuleListParamsEgsPaginationJson] `query:"json"` +} + +// URLQuery serializes [FirewallAccessRuleListParamsEgsPagination]'s query +// parameters as `url.Values`. +func (r FirewallAccessRuleListParamsEgsPagination) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type FirewallAccessRuleListParamsEgsPaginationJson struct { + // The page number of paginated results. + Page param.Field[float64] `query:"page"` + // The maximum number of results per page. You can only set the value to `1` or to + // a multiple of 5 such as `5`, `10`, `15`, or `20`. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [FirewallAccessRuleListParamsEgsPaginationJson]'s query +// parameters as `url.Values`. +func (r FirewallAccessRuleListParamsEgsPaginationJson) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type FirewallAccessRuleListParamsFilters struct { + // The target to search in existing rules. + ConfigurationTarget param.Field[FirewallAccessRuleListParamsFiltersConfigurationTarget] `query:"configuration.target"` + // The target value to search for in existing rules: an IP address, an IP address + // range, or a country code, depending on the provided `configuration.target`. + // Notes: You can search for a single IPv4 address, an IP address range with a + // subnet of '/16' or '/24', or a two-letter ISO-3166-1 alpha-2 country code. + ConfigurationValue param.Field[string] `query:"configuration.value"` + // When set to `all`, all the search requirements must match. When set to `any`, + // only one of the search requirements has to match. + Match param.Field[FirewallAccessRuleListParamsFiltersMatch] `query:"match"` + // The action to apply to a matched request. + Mode param.Field[FirewallAccessRuleListParamsFiltersMode] `query:"mode"` + // The string to search for in the notes of existing IP Access rules. Notes: For + // example, the string 'attack' would match IP Access rules with notes 'Attack + // 26/02' and 'Attack 27/02'. The search is case insensitive. + Notes param.Field[string] `query:"notes"` +} + +// URLQuery serializes [FirewallAccessRuleListParamsFilters]'s query parameters as +// `url.Values`. +func (r FirewallAccessRuleListParamsFilters) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// The target to search in existing rules. +type FirewallAccessRuleListParamsFiltersConfigurationTarget string + +const ( + FirewallAccessRuleListParamsFiltersConfigurationTargetIP FirewallAccessRuleListParamsFiltersConfigurationTarget = "ip" + FirewallAccessRuleListParamsFiltersConfigurationTargetIPRange FirewallAccessRuleListParamsFiltersConfigurationTarget = "ip_range" + FirewallAccessRuleListParamsFiltersConfigurationTargetASN FirewallAccessRuleListParamsFiltersConfigurationTarget = "asn" + FirewallAccessRuleListParamsFiltersConfigurationTargetCountry FirewallAccessRuleListParamsFiltersConfigurationTarget = "country" +) + +// When set to `all`, all the search requirements must match. When set to `any`, +// only one of the search requirements has to match. +type FirewallAccessRuleListParamsFiltersMatch string + +const ( + FirewallAccessRuleListParamsFiltersMatchAny FirewallAccessRuleListParamsFiltersMatch = "any" + FirewallAccessRuleListParamsFiltersMatchAll FirewallAccessRuleListParamsFiltersMatch = "all" +) + +// The action to apply to a matched request. +type FirewallAccessRuleListParamsFiltersMode string + +const ( + FirewallAccessRuleListParamsFiltersModeBlock FirewallAccessRuleListParamsFiltersMode = "block" + FirewallAccessRuleListParamsFiltersModeChallenge FirewallAccessRuleListParamsFiltersMode = "challenge" + FirewallAccessRuleListParamsFiltersModeWhitelist FirewallAccessRuleListParamsFiltersMode = "whitelist" + FirewallAccessRuleListParamsFiltersModeJsChallenge FirewallAccessRuleListParamsFiltersMode = "js_challenge" + FirewallAccessRuleListParamsFiltersModeManagedChallenge FirewallAccessRuleListParamsFiltersMode = "managed_challenge" +) + +// The field used to sort returned rules. +type FirewallAccessRuleListParamsOrder string + +const ( + FirewallAccessRuleListParamsOrderConfigurationTarget FirewallAccessRuleListParamsOrder = "configuration.target" + FirewallAccessRuleListParamsOrderConfigurationValue FirewallAccessRuleListParamsOrder = "configuration.value" + FirewallAccessRuleListParamsOrderMode FirewallAccessRuleListParamsOrder = "mode" +) + +type FirewallAccessRuleDeleteResponseEnvelope struct { + Errors []FirewallAccessRuleDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []FirewallAccessRuleDeleteResponseEnvelopeMessages `json:"messages,required"` + Result FirewallAccessRuleDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success FirewallAccessRuleDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON firewallAccessRuleDeleteResponseEnvelopeJSON `json:"-"` +} + +// firewallAccessRuleDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [FirewallAccessRuleDeleteResponseEnvelope] +type firewallAccessRuleDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallAccessRuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallAccessRuleDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FirewallAccessRuleDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON firewallAccessRuleDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// firewallAccessRuleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [FirewallAccessRuleDeleteResponseEnvelopeErrors] +type firewallAccessRuleDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallAccessRuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallAccessRuleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FirewallAccessRuleDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON firewallAccessRuleDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// firewallAccessRuleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [FirewallAccessRuleDeleteResponseEnvelopeMessages] +type firewallAccessRuleDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallAccessRuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallAccessRuleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FirewallAccessRuleDeleteResponseEnvelopeSuccess bool + +const ( + FirewallAccessRuleDeleteResponseEnvelopeSuccessTrue FirewallAccessRuleDeleteResponseEnvelopeSuccess = true +) + +type FirewallAccessRuleEditParams struct { + // The action to apply to a matched request. + Mode param.Field[FirewallAccessRuleEditParamsMode] `json:"mode"` + // An informative summary of the rule, typically used as a reminder or explanation. + Notes param.Field[string] `json:"notes"` +} + +func (r FirewallAccessRuleEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The action to apply to a matched request. +type FirewallAccessRuleEditParamsMode string + +const ( + FirewallAccessRuleEditParamsModeBlock FirewallAccessRuleEditParamsMode = "block" + FirewallAccessRuleEditParamsModeChallenge FirewallAccessRuleEditParamsMode = "challenge" + FirewallAccessRuleEditParamsModeWhitelist FirewallAccessRuleEditParamsMode = "whitelist" + FirewallAccessRuleEditParamsModeJsChallenge FirewallAccessRuleEditParamsMode = "js_challenge" + FirewallAccessRuleEditParamsModeManagedChallenge FirewallAccessRuleEditParamsMode = "managed_challenge" +) + +type FirewallAccessRuleEditResponseEnvelope struct { + Errors []FirewallAccessRuleEditResponseEnvelopeErrors `json:"errors,required"` + Messages []FirewallAccessRuleEditResponseEnvelopeMessages `json:"messages,required"` + Result LegacyJhsRule `json:"result,required,nullable"` + // Whether the API call was successful + Success FirewallAccessRuleEditResponseEnvelopeSuccess `json:"success,required"` + JSON firewallAccessRuleEditResponseEnvelopeJSON `json:"-"` +} + +// firewallAccessRuleEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [FirewallAccessRuleEditResponseEnvelope] +type firewallAccessRuleEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallAccessRuleEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallAccessRuleEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FirewallAccessRuleEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON firewallAccessRuleEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// firewallAccessRuleEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [FirewallAccessRuleEditResponseEnvelopeErrors] +type firewallAccessRuleEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallAccessRuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallAccessRuleEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FirewallAccessRuleEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON firewallAccessRuleEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// firewallAccessRuleEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [FirewallAccessRuleEditResponseEnvelopeMessages] +type firewallAccessRuleEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FirewallAccessRuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r firewallAccessRuleEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FirewallAccessRuleEditResponseEnvelopeSuccess bool + +const ( + FirewallAccessRuleEditResponseEnvelopeSuccessTrue FirewallAccessRuleEditResponseEnvelopeSuccess = true +) diff --git a/user/firewallaccessrule_test.go b/user/firewallaccessrule_test.go new file mode 100644 index 00000000000..73d86bed1f5 --- /dev/null +++ b/user/firewallaccessrule_test.go @@ -0,0 +1,143 @@ +// File generated from our OpenAPI spec by Stainless. + +package user_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/user" +) + +func TestFirewallAccessRuleNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.Firewall.AccessRules.New(context.TODO(), user.FirewallAccessRuleNewParams{ + Configuration: cloudflare.F[user.FirewallAccessRuleNewParamsConfiguration](user.FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration(user.FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration{ + Target: cloudflare.F(user.FirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTargetIP), + Value: cloudflare.F("198.51.100.4"), + })), + Mode: cloudflare.F(user.FirewallAccessRuleNewParamsModeChallenge), + Notes: cloudflare.F("This rule is enabled because of an event that occurred on date X."), + }) + 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 TestFirewallAccessRuleListWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.Firewall.AccessRules.List(context.TODO(), user.FirewallAccessRuleListParams{ + Direction: cloudflare.F(user.FirewallAccessRuleListParamsDirectionDesc), + EgsPagination: cloudflare.F(user.FirewallAccessRuleListParamsEgsPagination{ + Json: cloudflare.F(user.FirewallAccessRuleListParamsEgsPaginationJson{ + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(1.000000), + }), + }), + Filters: cloudflare.F(user.FirewallAccessRuleListParamsFilters{ + ConfigurationTarget: cloudflare.F(user.FirewallAccessRuleListParamsFiltersConfigurationTargetIP), + ConfigurationValue: cloudflare.F("198.51.100.4"), + Match: cloudflare.F(user.FirewallAccessRuleListParamsFiltersMatchAny), + Mode: cloudflare.F(user.FirewallAccessRuleListParamsFiltersModeChallenge), + Notes: cloudflare.F("my note"), + }), + Order: cloudflare.F(user.FirewallAccessRuleListParamsOrderMode), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(20.000000), + }) + 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 TestFirewallAccessRuleDelete(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("user@example.com"), + ) + _, err := client.User.Firewall.AccessRules.Delete(context.TODO(), "92f17202ed8bd63d69a66b86a49a8f6b") + 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 TestFirewallAccessRuleEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.Firewall.AccessRules.Edit( + context.TODO(), + "92f17202ed8bd63d69a66b86a49a8f6b", + user.FirewallAccessRuleEditParams{ + Mode: cloudflare.F(user.FirewallAccessRuleEditParamsModeChallenge), + Notes: cloudflare.F("This rule is enabled because of an event that occurred on date X."), + }, + ) + 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/user/invite.go b/user/invite.go new file mode 100644 index 00000000000..c93b5e0aff7 --- /dev/null +++ b/user/invite.go @@ -0,0 +1,459 @@ +// File generated from our OpenAPI spec by Stainless. + +package user + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/accounts" + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// InviteService 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 [NewInviteService] method instead. +type InviteService struct { + Options []option.RequestOption +} + +// NewInviteService 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 NewInviteService(opts ...option.RequestOption) (r *InviteService) { + r = &InviteService{} + r.Options = opts + return +} + +// Lists all invitations associated with my user. +func (r *InviteService) List(ctx context.Context, opts ...option.RequestOption) (res *[]InviteListResponse, err error) { + opts = append(r.Options[:], opts...) + var env InviteListResponseEnvelope + path := "user/invites" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Responds to an invitation. +func (r *InviteService) Edit(ctx context.Context, inviteID string, body InviteEditParams, opts ...option.RequestOption) (res *InviteEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env InviteEditResponseEnvelope + path := fmt.Sprintf("user/invites/%s", inviteID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets the details of an invitation. +func (r *InviteService) Get(ctx context.Context, inviteID string, opts ...option.RequestOption) (res *InviteGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env InviteGetResponseEnvelope + path := fmt.Sprintf("user/invites/%s", inviteID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type InviteListResponse struct { + // ID of the user to add to the organization. + InvitedMemberID string `json:"invited_member_id,required,nullable"` + // ID of the organization the user will be added to. + OrganizationID string `json:"organization_id,required"` + // Invite identifier tag. + ID string `json:"id"` + // When the invite is no longer active. + ExpiresOn time.Time `json:"expires_on" format:"date-time"` + // The email address of the user who created the invite. + InvitedBy string `json:"invited_by"` + // Email address of the user to add to the organization. + InvitedMemberEmail string `json:"invited_member_email"` + // When the invite was sent. + InvitedOn time.Time `json:"invited_on" format:"date-time"` + // Organization name. + OrganizationName string `json:"organization_name"` + // Roles to be assigned to this user. + Roles []accounts.IamSchemasRole `json:"roles"` + // Current status of the invitation. + Status InviteListResponseStatus `json:"status"` + JSON inviteListResponseJSON `json:"-"` +} + +// inviteListResponseJSON contains the JSON metadata for the struct +// [InviteListResponse] +type inviteListResponseJSON struct { + InvitedMemberID apijson.Field + OrganizationID apijson.Field + ID apijson.Field + ExpiresOn apijson.Field + InvitedBy apijson.Field + InvitedMemberEmail apijson.Field + InvitedOn apijson.Field + OrganizationName apijson.Field + Roles apijson.Field + Status apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *InviteListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r inviteListResponseJSON) RawJSON() string { + return r.raw +} + +// Current status of the invitation. +type InviteListResponseStatus string + +const ( + InviteListResponseStatusPending InviteListResponseStatus = "pending" + InviteListResponseStatusAccepted InviteListResponseStatus = "accepted" + InviteListResponseStatusRejected InviteListResponseStatus = "rejected" + InviteListResponseStatusExpired InviteListResponseStatus = "expired" +) + +// Union satisfied by [user.InviteEditResponseUnknown] or [shared.UnionString]. +type InviteEditResponse interface { + ImplementsUserInviteEditResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*InviteEditResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [user.InviteGetResponseUnknown] or [shared.UnionString]. +type InviteGetResponse interface { + ImplementsUserInviteGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*InviteGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type InviteListResponseEnvelope struct { + Errors []InviteListResponseEnvelopeErrors `json:"errors,required"` + Messages []InviteListResponseEnvelopeMessages `json:"messages,required"` + Result []InviteListResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success InviteListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo InviteListResponseEnvelopeResultInfo `json:"result_info"` + JSON inviteListResponseEnvelopeJSON `json:"-"` +} + +// inviteListResponseEnvelopeJSON contains the JSON metadata for the struct +// [InviteListResponseEnvelope] +type inviteListResponseEnvelopeJSON 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 *InviteListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r inviteListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type InviteListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON inviteListResponseEnvelopeErrorsJSON `json:"-"` +} + +// inviteListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [InviteListResponseEnvelopeErrors] +type inviteListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *InviteListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r inviteListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type InviteListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON inviteListResponseEnvelopeMessagesJSON `json:"-"` +} + +// inviteListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [InviteListResponseEnvelopeMessages] +type inviteListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *InviteListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r inviteListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type InviteListResponseEnvelopeSuccess bool + +const ( + InviteListResponseEnvelopeSuccessTrue InviteListResponseEnvelopeSuccess = true +) + +type InviteListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON inviteListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// inviteListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [InviteListResponseEnvelopeResultInfo] +type inviteListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *InviteListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r inviteListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type InviteEditParams struct { + // Status of your response to the invitation (rejected or accepted). + Status param.Field[InviteEditParamsStatus] `json:"status,required"` +} + +func (r InviteEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Status of your response to the invitation (rejected or accepted). +type InviteEditParamsStatus string + +const ( + InviteEditParamsStatusAccepted InviteEditParamsStatus = "accepted" + InviteEditParamsStatusRejected InviteEditParamsStatus = "rejected" +) + +type InviteEditResponseEnvelope struct { + Errors []InviteEditResponseEnvelopeErrors `json:"errors,required"` + Messages []InviteEditResponseEnvelopeMessages `json:"messages,required"` + Result InviteEditResponse `json:"result,required"` + // Whether the API call was successful + Success InviteEditResponseEnvelopeSuccess `json:"success,required"` + JSON inviteEditResponseEnvelopeJSON `json:"-"` +} + +// inviteEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [InviteEditResponseEnvelope] +type inviteEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *InviteEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r inviteEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type InviteEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON inviteEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// inviteEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [InviteEditResponseEnvelopeErrors] +type inviteEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *InviteEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r inviteEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type InviteEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON inviteEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// inviteEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [InviteEditResponseEnvelopeMessages] +type inviteEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *InviteEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r inviteEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type InviteEditResponseEnvelopeSuccess bool + +const ( + InviteEditResponseEnvelopeSuccessTrue InviteEditResponseEnvelopeSuccess = true +) + +type InviteGetResponseEnvelope struct { + Errors []InviteGetResponseEnvelopeErrors `json:"errors,required"` + Messages []InviteGetResponseEnvelopeMessages `json:"messages,required"` + Result InviteGetResponse `json:"result,required"` + // Whether the API call was successful + Success InviteGetResponseEnvelopeSuccess `json:"success,required"` + JSON inviteGetResponseEnvelopeJSON `json:"-"` +} + +// inviteGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [InviteGetResponseEnvelope] +type inviteGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *InviteGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r inviteGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type InviteGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON inviteGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// inviteGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [InviteGetResponseEnvelopeErrors] +type inviteGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *InviteGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r inviteGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type InviteGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON inviteGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// inviteGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [InviteGetResponseEnvelopeMessages] +type inviteGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *InviteGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r inviteGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type InviteGetResponseEnvelopeSuccess bool + +const ( + InviteGetResponseEnvelopeSuccessTrue InviteGetResponseEnvelopeSuccess = true +) diff --git a/user/invite_test.go b/user/invite_test.go new file mode 100644 index 00000000000..0cbcb963e57 --- /dev/null +++ b/user/invite_test.go @@ -0,0 +1,93 @@ +// File generated from our OpenAPI spec by Stainless. + +package user_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/user" +) + +func TestInviteList(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("user@example.com"), + ) + _, err := client.User.Invites.List(context.TODO()) + 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 TestInviteEdit(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("user@example.com"), + ) + _, err := client.User.Invites.Edit( + context.TODO(), + "4f5f0c14a2a41d5063dd301b2f829f04", + user.InviteEditParams{ + Status: cloudflare.F(user.InviteEditParamsStatusAccepted), + }, + ) + 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 TestInviteGet(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("user@example.com"), + ) + _, err := client.User.Invites.Get(context.TODO(), "4f5f0c14a2a41d5063dd301b2f829f04") + 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/user/loadbalancer.go b/user/loadbalancer.go new file mode 100644 index 00000000000..17fdccd3f05 --- /dev/null +++ b/user/loadbalancer.go @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package user + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// LoadBalancerService 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 [NewLoadBalancerService] method +// instead. +type LoadBalancerService struct { + Options []option.RequestOption + Monitors *LoadBalancerMonitorService + Pools *LoadBalancerPoolService + Preview *LoadBalancerPreviewService + Analytics *LoadBalancerAnalyticsService +} + +// NewLoadBalancerService 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 NewLoadBalancerService(opts ...option.RequestOption) (r *LoadBalancerService) { + r = &LoadBalancerService{} + r.Options = opts + r.Monitors = NewLoadBalancerMonitorService(opts...) + r.Pools = NewLoadBalancerPoolService(opts...) + r.Preview = NewLoadBalancerPreviewService(opts...) + r.Analytics = NewLoadBalancerAnalyticsService(opts...) + return +} diff --git a/user/loadbalanceranalytics.go b/user/loadbalanceranalytics.go new file mode 100644 index 00000000000..795b4d1f6af --- /dev/null +++ b/user/loadbalanceranalytics.go @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package user + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// LoadBalancerAnalyticsService 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 [NewLoadBalancerAnalyticsService] +// method instead. +type LoadBalancerAnalyticsService struct { + Options []option.RequestOption + Events *LoadBalancerAnalyticsEventService +} + +// NewLoadBalancerAnalyticsService 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 NewLoadBalancerAnalyticsService(opts ...option.RequestOption) (r *LoadBalancerAnalyticsService) { + r = &LoadBalancerAnalyticsService{} + r.Options = opts + r.Events = NewLoadBalancerAnalyticsEventService(opts...) + return +} diff --git a/user/loadbalanceranalyticsevent.go b/user/loadbalanceranalyticsevent.go new file mode 100644 index 00000000000..947a91832e4 --- /dev/null +++ b/user/loadbalanceranalyticsevent.go @@ -0,0 +1,216 @@ +// File generated from our OpenAPI spec by Stainless. + +package user + +import ( + "context" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// LoadBalancerAnalyticsEventService 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 +// [NewLoadBalancerAnalyticsEventService] method instead. +type LoadBalancerAnalyticsEventService struct { + Options []option.RequestOption +} + +// NewLoadBalancerAnalyticsEventService 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 NewLoadBalancerAnalyticsEventService(opts ...option.RequestOption) (r *LoadBalancerAnalyticsEventService) { + r = &LoadBalancerAnalyticsEventService{} + r.Options = opts + return +} + +// List origin health changes. +func (r *LoadBalancerAnalyticsEventService) List(ctx context.Context, query LoadBalancerAnalyticsEventListParams, opts ...option.RequestOption) (res *[]LoadBalancingAnalytics, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerAnalyticsEventListResponseEnvelope + path := "user/load_balancing_analytics/events" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type LoadBalancingAnalytics struct { + ID int64 `json:"id"` + Origins []interface{} `json:"origins"` + Pool interface{} `json:"pool"` + Timestamp time.Time `json:"timestamp" format:"date-time"` + JSON loadBalancingAnalyticsJSON `json:"-"` +} + +// loadBalancingAnalyticsJSON contains the JSON metadata for the struct +// [LoadBalancingAnalytics] +type loadBalancingAnalyticsJSON struct { + ID apijson.Field + Origins apijson.Field + Pool apijson.Field + Timestamp apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancingAnalytics) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancingAnalyticsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerAnalyticsEventListParams struct { + // If true, filter events where the origin status is healthy. If false, filter + // events where the origin status is unhealthy. + OriginHealthy param.Field[bool] `query:"origin_healthy"` + // The name for the origin to filter. + OriginName param.Field[string] `query:"origin_name"` + // If true, filter events where the pool status is healthy. If false, filter events + // where the pool status is unhealthy. + PoolHealthy param.Field[bool] `query:"pool_healthy"` + PoolID param.Field[string] `query:"pool_id"` + // The name for the pool to filter. + PoolName param.Field[string] `query:"pool_name"` + // Start date and time of requesting data period in the ISO8601 format. + Since param.Field[time.Time] `query:"since" format:"date-time"` + // End date and time of requesting data period in the ISO8601 format. + Until param.Field[time.Time] `query:"until" format:"date-time"` +} + +// URLQuery serializes [LoadBalancerAnalyticsEventListParams]'s query parameters as +// `url.Values`. +func (r LoadBalancerAnalyticsEventListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type LoadBalancerAnalyticsEventListResponseEnvelope struct { + Errors []LoadBalancerAnalyticsEventListResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerAnalyticsEventListResponseEnvelopeMessages `json:"messages,required"` + Result []LoadBalancingAnalytics `json:"result,required,nullable"` + // Whether the API call was successful + Success LoadBalancerAnalyticsEventListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo LoadBalancerAnalyticsEventListResponseEnvelopeResultInfo `json:"result_info"` + JSON loadBalancerAnalyticsEventListResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerAnalyticsEventListResponseEnvelopeJSON contains the JSON metadata +// for the struct [LoadBalancerAnalyticsEventListResponseEnvelope] +type loadBalancerAnalyticsEventListResponseEnvelopeJSON 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 *LoadBalancerAnalyticsEventListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerAnalyticsEventListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerAnalyticsEventListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerAnalyticsEventListResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerAnalyticsEventListResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [LoadBalancerAnalyticsEventListResponseEnvelopeErrors] +type loadBalancerAnalyticsEventListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerAnalyticsEventListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerAnalyticsEventListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerAnalyticsEventListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerAnalyticsEventListResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerAnalyticsEventListResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [LoadBalancerAnalyticsEventListResponseEnvelopeMessages] +type loadBalancerAnalyticsEventListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerAnalyticsEventListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerAnalyticsEventListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerAnalyticsEventListResponseEnvelopeSuccess bool + +const ( + LoadBalancerAnalyticsEventListResponseEnvelopeSuccessTrue LoadBalancerAnalyticsEventListResponseEnvelopeSuccess = true +) + +type LoadBalancerAnalyticsEventListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON loadBalancerAnalyticsEventListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// loadBalancerAnalyticsEventListResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct +// [LoadBalancerAnalyticsEventListResponseEnvelopeResultInfo] +type loadBalancerAnalyticsEventListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerAnalyticsEventListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerAnalyticsEventListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/user/loadbalanceranalyticsevent_test.go b/user/loadbalanceranalyticsevent_test.go new file mode 100644 index 00000000000..3bf41e0069b --- /dev/null +++ b/user/loadbalanceranalyticsevent_test.go @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package user_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/user" +) + +func TestLoadBalancerAnalyticsEventListWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.LoadBalancers.Analytics.Events.List(context.TODO(), user.LoadBalancerAnalyticsEventListParams{ + OriginHealthy: cloudflare.F(true), + OriginName: cloudflare.F("primary-dc-1"), + PoolHealthy: cloudflare.F(true), + PoolID: cloudflare.F("17b5962d775c646f3f9725cbc7a53df4"), + PoolName: cloudflare.F("primary-dc"), + Since: cloudflare.F(time.Now()), + Until: cloudflare.F(time.Now()), + }) + 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/user/loadbalancermonitor.go b/user/loadbalancermonitor.go new file mode 100644 index 00000000000..8d46b6fe5c9 --- /dev/null +++ b/user/loadbalancermonitor.go @@ -0,0 +1,1313 @@ +// File generated from our OpenAPI spec by Stainless. + +package user + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// LoadBalancerMonitorService 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 [NewLoadBalancerMonitorService] +// method instead. +type LoadBalancerMonitorService struct { + Options []option.RequestOption +} + +// NewLoadBalancerMonitorService 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 NewLoadBalancerMonitorService(opts ...option.RequestOption) (r *LoadBalancerMonitorService) { + r = &LoadBalancerMonitorService{} + r.Options = opts + return +} + +// Create a configured monitor. +func (r *LoadBalancerMonitorService) New(ctx context.Context, body LoadBalancerMonitorNewParams, opts ...option.RequestOption) (res *LoadBalancingMonitor, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerMonitorNewResponseEnvelope + path := "user/load_balancers/monitors" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Modify a configured monitor. +func (r *LoadBalancerMonitorService) Update(ctx context.Context, monitorID string, body LoadBalancerMonitorUpdateParams, opts ...option.RequestOption) (res *LoadBalancingMonitor, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerMonitorUpdateResponseEnvelope + path := fmt.Sprintf("user/load_balancers/monitors/%s", monitorID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List configured monitors for a user. +func (r *LoadBalancerMonitorService) List(ctx context.Context, opts ...option.RequestOption) (res *[]LoadBalancingMonitor, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerMonitorListResponseEnvelope + path := "user/load_balancers/monitors" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a configured monitor. +func (r *LoadBalancerMonitorService) Delete(ctx context.Context, monitorID string, opts ...option.RequestOption) (res *LoadBalancerMonitorDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerMonitorDeleteResponseEnvelope + path := fmt.Sprintf("user/load_balancers/monitors/%s", monitorID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Apply changes to an existing monitor, overwriting the supplied properties. +func (r *LoadBalancerMonitorService) Edit(ctx context.Context, monitorID string, body LoadBalancerMonitorEditParams, opts ...option.RequestOption) (res *LoadBalancingMonitor, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerMonitorEditResponseEnvelope + path := fmt.Sprintf("user/load_balancers/monitors/%s", monitorID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List a single configured monitor for a user. +func (r *LoadBalancerMonitorService) Get(ctx context.Context, monitorID string, opts ...option.RequestOption) (res *LoadBalancingMonitor, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerMonitorGetResponseEnvelope + path := fmt.Sprintf("user/load_balancers/monitors/%s", monitorID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Preview pools using the specified monitor with provided monitor details. The +// returned preview_id can be used in the preview endpoint to retrieve the results. +func (r *LoadBalancerMonitorService) Preview(ctx context.Context, monitorID string, body LoadBalancerMonitorPreviewParams, opts ...option.RequestOption) (res *LoadBalancerMonitorPreviewResponse, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerMonitorPreviewResponseEnvelope + path := fmt.Sprintf("user/load_balancers/monitors/%s/preview", monitorID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the list of resources that reference the provided monitor. +func (r *LoadBalancerMonitorService) References(ctx context.Context, monitorID string, opts ...option.RequestOption) (res *[]LoadBalancerMonitorReferencesResponse, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerMonitorReferencesResponseEnvelope + path := fmt.Sprintf("user/load_balancers/monitors/%s/references", monitorID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type LoadBalancingMonitor struct { + ID string `json:"id"` + // Do not validate the certificate when monitor use HTTPS. This parameter is + // currently only valid for HTTP and HTTPS monitors. + AllowInsecure bool `json:"allow_insecure"` + // To be marked unhealthy the monitored origin must fail this healthcheck N + // consecutive times. + ConsecutiveDown int64 `json:"consecutive_down"` + // To be marked healthy the monitored origin must pass this healthcheck N + // consecutive times. + ConsecutiveUp int64 `json:"consecutive_up"` + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Object description. + Description string `json:"description"` + // A case-insensitive sub-string to look for in the response body. If this string + // is not found, the origin will be marked as unhealthy. This parameter is only + // valid for HTTP and HTTPS monitors. + ExpectedBody string `json:"expected_body"` + // The expected HTTP response code or code range of the health check. This + // parameter is only valid for HTTP and HTTPS monitors. + ExpectedCodes string `json:"expected_codes"` + // Follow redirects if returned by the origin. This parameter is only valid for + // HTTP and HTTPS monitors. + FollowRedirects bool `json:"follow_redirects"` + // The HTTP request headers to send in the health check. It is recommended you set + // a Host header by default. The User-Agent header cannot be overridden. This + // parameter is only valid for HTTP and HTTPS monitors. + Header interface{} `json:"header"` + // The interval between each health check. Shorter intervals may improve failover + // time, but will increase load on the origins as we check from multiple locations. + Interval int64 `json:"interval"` + // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS + // based checks and 'connection_established' for TCP based health checks. + Method string `json:"method"` + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // The endpoint path you want to conduct a health check against. This parameter is + // only valid for HTTP and HTTPS monitors. + Path string `json:"path"` + // The port number to connect to for the health check. Required for TCP, UDP, and + // SMTP checks. HTTP and HTTPS checks should only define the port when using a + // non-standard port (HTTP: default 80, HTTPS: default 443). + Port int64 `json:"port"` + // Assign this monitor to emulate the specified zone while probing. This parameter + // is only valid for HTTP and HTTPS monitors. + ProbeZone string `json:"probe_zone"` + // The number of retries to attempt in case of a timeout before marking the origin + // as unhealthy. Retries are attempted immediately. + Retries int64 `json:"retries"` + // The timeout (in seconds) before marking the health check as failed. + Timeout int64 `json:"timeout"` + // The protocol to use for the health check. Currently supported protocols are + // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. + Type LoadBalancingMonitorType `json:"type"` + JSON loadBalancingMonitorJSON `json:"-"` +} + +// loadBalancingMonitorJSON contains the JSON metadata for the struct +// [LoadBalancingMonitor] +type loadBalancingMonitorJSON struct { + ID apijson.Field + AllowInsecure apijson.Field + ConsecutiveDown apijson.Field + ConsecutiveUp apijson.Field + CreatedOn apijson.Field + Description apijson.Field + ExpectedBody apijson.Field + ExpectedCodes apijson.Field + FollowRedirects apijson.Field + Header apijson.Field + Interval apijson.Field + Method apijson.Field + ModifiedOn apijson.Field + Path apijson.Field + Port apijson.Field + ProbeZone apijson.Field + Retries apijson.Field + Timeout apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancingMonitor) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancingMonitorJSON) RawJSON() string { + return r.raw +} + +// The protocol to use for the health check. Currently supported protocols are +// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. +type LoadBalancingMonitorType string + +const ( + LoadBalancingMonitorTypeHTTP LoadBalancingMonitorType = "http" + LoadBalancingMonitorTypeHTTPS LoadBalancingMonitorType = "https" + LoadBalancingMonitorTypeTcp LoadBalancingMonitorType = "tcp" + LoadBalancingMonitorTypeUdpIcmp LoadBalancingMonitorType = "udp_icmp" + LoadBalancingMonitorTypeIcmpPing LoadBalancingMonitorType = "icmp_ping" + LoadBalancingMonitorTypeSmtp LoadBalancingMonitorType = "smtp" +) + +type LoadBalancerMonitorDeleteResponse struct { + ID string `json:"id"` + JSON loadBalancerMonitorDeleteResponseJSON `json:"-"` +} + +// loadBalancerMonitorDeleteResponseJSON contains the JSON metadata for the struct +// [LoadBalancerMonitorDeleteResponse] +type loadBalancerMonitorDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorPreviewResponse struct { + // Monitored pool IDs mapped to their respective names. + Pools map[string]string `json:"pools"` + PreviewID string `json:"preview_id"` + JSON loadBalancerMonitorPreviewResponseJSON `json:"-"` +} + +// loadBalancerMonitorPreviewResponseJSON contains the JSON metadata for the struct +// [LoadBalancerMonitorPreviewResponse] +type loadBalancerMonitorPreviewResponseJSON struct { + Pools apijson.Field + PreviewID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorPreviewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorPreviewResponseJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorReferencesResponse struct { + ReferenceType LoadBalancerMonitorReferencesResponseReferenceType `json:"reference_type"` + ResourceID string `json:"resource_id"` + ResourceName string `json:"resource_name"` + ResourceType string `json:"resource_type"` + JSON loadBalancerMonitorReferencesResponseJSON `json:"-"` +} + +// loadBalancerMonitorReferencesResponseJSON contains the JSON metadata for the +// struct [LoadBalancerMonitorReferencesResponse] +type loadBalancerMonitorReferencesResponseJSON struct { + ReferenceType apijson.Field + ResourceID apijson.Field + ResourceName apijson.Field + ResourceType apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorReferencesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorReferencesResponseJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorReferencesResponseReferenceType string + +const ( + LoadBalancerMonitorReferencesResponseReferenceTypeStar LoadBalancerMonitorReferencesResponseReferenceType = "*" + LoadBalancerMonitorReferencesResponseReferenceTypeReferral LoadBalancerMonitorReferencesResponseReferenceType = "referral" + LoadBalancerMonitorReferencesResponseReferenceTypeReferrer LoadBalancerMonitorReferencesResponseReferenceType = "referrer" +) + +type LoadBalancerMonitorNewParams struct { + // The expected HTTP response code or code range of the health check. This + // parameter is only valid for HTTP and HTTPS monitors. + ExpectedCodes param.Field[string] `json:"expected_codes,required"` + // Do not validate the certificate when monitor use HTTPS. This parameter is + // currently only valid for HTTP and HTTPS monitors. + AllowInsecure param.Field[bool] `json:"allow_insecure"` + // To be marked unhealthy the monitored origin must fail this healthcheck N + // consecutive times. + ConsecutiveDown param.Field[int64] `json:"consecutive_down"` + // To be marked healthy the monitored origin must pass this healthcheck N + // consecutive times. + ConsecutiveUp param.Field[int64] `json:"consecutive_up"` + // Object description. + Description param.Field[string] `json:"description"` + // A case-insensitive sub-string to look for in the response body. If this string + // is not found, the origin will be marked as unhealthy. This parameter is only + // valid for HTTP and HTTPS monitors. + ExpectedBody param.Field[string] `json:"expected_body"` + // Follow redirects if returned by the origin. This parameter is only valid for + // HTTP and HTTPS monitors. + FollowRedirects param.Field[bool] `json:"follow_redirects"` + // The HTTP request headers to send in the health check. It is recommended you set + // a Host header by default. The User-Agent header cannot be overridden. This + // parameter is only valid for HTTP and HTTPS monitors. + Header param.Field[interface{}] `json:"header"` + // The interval between each health check. Shorter intervals may improve failover + // time, but will increase load on the origins as we check from multiple locations. + Interval param.Field[int64] `json:"interval"` + // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS + // based checks and 'connection_established' for TCP based health checks. + Method param.Field[string] `json:"method"` + // The endpoint path you want to conduct a health check against. This parameter is + // only valid for HTTP and HTTPS monitors. + Path param.Field[string] `json:"path"` + // The port number to connect to for the health check. Required for TCP, UDP, and + // SMTP checks. HTTP and HTTPS checks should only define the port when using a + // non-standard port (HTTP: default 80, HTTPS: default 443). + Port param.Field[int64] `json:"port"` + // Assign this monitor to emulate the specified zone while probing. This parameter + // is only valid for HTTP and HTTPS monitors. + ProbeZone param.Field[string] `json:"probe_zone"` + // The number of retries to attempt in case of a timeout before marking the origin + // as unhealthy. Retries are attempted immediately. + Retries param.Field[int64] `json:"retries"` + // The timeout (in seconds) before marking the health check as failed. + Timeout param.Field[int64] `json:"timeout"` + // The protocol to use for the health check. Currently supported protocols are + // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. + Type param.Field[LoadBalancerMonitorNewParamsType] `json:"type"` +} + +func (r LoadBalancerMonitorNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The protocol to use for the health check. Currently supported protocols are +// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. +type LoadBalancerMonitorNewParamsType string + +const ( + LoadBalancerMonitorNewParamsTypeHTTP LoadBalancerMonitorNewParamsType = "http" + LoadBalancerMonitorNewParamsTypeHTTPS LoadBalancerMonitorNewParamsType = "https" + LoadBalancerMonitorNewParamsTypeTcp LoadBalancerMonitorNewParamsType = "tcp" + LoadBalancerMonitorNewParamsTypeUdpIcmp LoadBalancerMonitorNewParamsType = "udp_icmp" + LoadBalancerMonitorNewParamsTypeIcmpPing LoadBalancerMonitorNewParamsType = "icmp_ping" + LoadBalancerMonitorNewParamsTypeSmtp LoadBalancerMonitorNewParamsType = "smtp" +) + +type LoadBalancerMonitorNewResponseEnvelope struct { + Errors []LoadBalancerMonitorNewResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerMonitorNewResponseEnvelopeMessages `json:"messages,required"` + Result LoadBalancingMonitor `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerMonitorNewResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerMonitorNewResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerMonitorNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [LoadBalancerMonitorNewResponseEnvelope] +type loadBalancerMonitorNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerMonitorNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerMonitorNewResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [LoadBalancerMonitorNewResponseEnvelopeErrors] +type loadBalancerMonitorNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerMonitorNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerMonitorNewResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [LoadBalancerMonitorNewResponseEnvelopeMessages] +type loadBalancerMonitorNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerMonitorNewResponseEnvelopeSuccess bool + +const ( + LoadBalancerMonitorNewResponseEnvelopeSuccessTrue LoadBalancerMonitorNewResponseEnvelopeSuccess = true +) + +type LoadBalancerMonitorUpdateParams struct { + // The expected HTTP response code or code range of the health check. This + // parameter is only valid for HTTP and HTTPS monitors. + ExpectedCodes param.Field[string] `json:"expected_codes,required"` + // Do not validate the certificate when monitor use HTTPS. This parameter is + // currently only valid for HTTP and HTTPS monitors. + AllowInsecure param.Field[bool] `json:"allow_insecure"` + // To be marked unhealthy the monitored origin must fail this healthcheck N + // consecutive times. + ConsecutiveDown param.Field[int64] `json:"consecutive_down"` + // To be marked healthy the monitored origin must pass this healthcheck N + // consecutive times. + ConsecutiveUp param.Field[int64] `json:"consecutive_up"` + // Object description. + Description param.Field[string] `json:"description"` + // A case-insensitive sub-string to look for in the response body. If this string + // is not found, the origin will be marked as unhealthy. This parameter is only + // valid for HTTP and HTTPS monitors. + ExpectedBody param.Field[string] `json:"expected_body"` + // Follow redirects if returned by the origin. This parameter is only valid for + // HTTP and HTTPS monitors. + FollowRedirects param.Field[bool] `json:"follow_redirects"` + // The HTTP request headers to send in the health check. It is recommended you set + // a Host header by default. The User-Agent header cannot be overridden. This + // parameter is only valid for HTTP and HTTPS monitors. + Header param.Field[interface{}] `json:"header"` + // The interval between each health check. Shorter intervals may improve failover + // time, but will increase load on the origins as we check from multiple locations. + Interval param.Field[int64] `json:"interval"` + // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS + // based checks and 'connection_established' for TCP based health checks. + Method param.Field[string] `json:"method"` + // The endpoint path you want to conduct a health check against. This parameter is + // only valid for HTTP and HTTPS monitors. + Path param.Field[string] `json:"path"` + // The port number to connect to for the health check. Required for TCP, UDP, and + // SMTP checks. HTTP and HTTPS checks should only define the port when using a + // non-standard port (HTTP: default 80, HTTPS: default 443). + Port param.Field[int64] `json:"port"` + // Assign this monitor to emulate the specified zone while probing. This parameter + // is only valid for HTTP and HTTPS monitors. + ProbeZone param.Field[string] `json:"probe_zone"` + // The number of retries to attempt in case of a timeout before marking the origin + // as unhealthy. Retries are attempted immediately. + Retries param.Field[int64] `json:"retries"` + // The timeout (in seconds) before marking the health check as failed. + Timeout param.Field[int64] `json:"timeout"` + // The protocol to use for the health check. Currently supported protocols are + // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. + Type param.Field[LoadBalancerMonitorUpdateParamsType] `json:"type"` +} + +func (r LoadBalancerMonitorUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The protocol to use for the health check. Currently supported protocols are +// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. +type LoadBalancerMonitorUpdateParamsType string + +const ( + LoadBalancerMonitorUpdateParamsTypeHTTP LoadBalancerMonitorUpdateParamsType = "http" + LoadBalancerMonitorUpdateParamsTypeHTTPS LoadBalancerMonitorUpdateParamsType = "https" + LoadBalancerMonitorUpdateParamsTypeTcp LoadBalancerMonitorUpdateParamsType = "tcp" + LoadBalancerMonitorUpdateParamsTypeUdpIcmp LoadBalancerMonitorUpdateParamsType = "udp_icmp" + LoadBalancerMonitorUpdateParamsTypeIcmpPing LoadBalancerMonitorUpdateParamsType = "icmp_ping" + LoadBalancerMonitorUpdateParamsTypeSmtp LoadBalancerMonitorUpdateParamsType = "smtp" +) + +type LoadBalancerMonitorUpdateResponseEnvelope struct { + Errors []LoadBalancerMonitorUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerMonitorUpdateResponseEnvelopeMessages `json:"messages,required"` + Result LoadBalancingMonitor `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerMonitorUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerMonitorUpdateResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerMonitorUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [LoadBalancerMonitorUpdateResponseEnvelope] +type loadBalancerMonitorUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerMonitorUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerMonitorUpdateResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [LoadBalancerMonitorUpdateResponseEnvelopeErrors] +type loadBalancerMonitorUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerMonitorUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerMonitorUpdateResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [LoadBalancerMonitorUpdateResponseEnvelopeMessages] +type loadBalancerMonitorUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerMonitorUpdateResponseEnvelopeSuccess bool + +const ( + LoadBalancerMonitorUpdateResponseEnvelopeSuccessTrue LoadBalancerMonitorUpdateResponseEnvelopeSuccess = true +) + +type LoadBalancerMonitorListResponseEnvelope struct { + Errors []LoadBalancerMonitorListResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerMonitorListResponseEnvelopeMessages `json:"messages,required"` + Result []LoadBalancingMonitor `json:"result,required,nullable"` + // Whether the API call was successful + Success LoadBalancerMonitorListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo LoadBalancerMonitorListResponseEnvelopeResultInfo `json:"result_info"` + JSON loadBalancerMonitorListResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerMonitorListResponseEnvelopeJSON contains the JSON metadata for the +// struct [LoadBalancerMonitorListResponseEnvelope] +type loadBalancerMonitorListResponseEnvelopeJSON 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 *LoadBalancerMonitorListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerMonitorListResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerMonitorListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [LoadBalancerMonitorListResponseEnvelopeErrors] +type loadBalancerMonitorListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerMonitorListResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerMonitorListResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [LoadBalancerMonitorListResponseEnvelopeMessages] +type loadBalancerMonitorListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerMonitorListResponseEnvelopeSuccess bool + +const ( + LoadBalancerMonitorListResponseEnvelopeSuccessTrue LoadBalancerMonitorListResponseEnvelopeSuccess = true +) + +type LoadBalancerMonitorListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON loadBalancerMonitorListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// loadBalancerMonitorListResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [LoadBalancerMonitorListResponseEnvelopeResultInfo] +type loadBalancerMonitorListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorDeleteResponseEnvelope struct { + Errors []LoadBalancerMonitorDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerMonitorDeleteResponseEnvelopeMessages `json:"messages,required"` + Result LoadBalancerMonitorDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerMonitorDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerMonitorDeleteResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerMonitorDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [LoadBalancerMonitorDeleteResponseEnvelope] +type loadBalancerMonitorDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerMonitorDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerMonitorDeleteResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [LoadBalancerMonitorDeleteResponseEnvelopeErrors] +type loadBalancerMonitorDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerMonitorDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerMonitorDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [LoadBalancerMonitorDeleteResponseEnvelopeMessages] +type loadBalancerMonitorDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerMonitorDeleteResponseEnvelopeSuccess bool + +const ( + LoadBalancerMonitorDeleteResponseEnvelopeSuccessTrue LoadBalancerMonitorDeleteResponseEnvelopeSuccess = true +) + +type LoadBalancerMonitorEditParams struct { + // The expected HTTP response code or code range of the health check. This + // parameter is only valid for HTTP and HTTPS monitors. + ExpectedCodes param.Field[string] `json:"expected_codes,required"` + // Do not validate the certificate when monitor use HTTPS. This parameter is + // currently only valid for HTTP and HTTPS monitors. + AllowInsecure param.Field[bool] `json:"allow_insecure"` + // To be marked unhealthy the monitored origin must fail this healthcheck N + // consecutive times. + ConsecutiveDown param.Field[int64] `json:"consecutive_down"` + // To be marked healthy the monitored origin must pass this healthcheck N + // consecutive times. + ConsecutiveUp param.Field[int64] `json:"consecutive_up"` + // Object description. + Description param.Field[string] `json:"description"` + // A case-insensitive sub-string to look for in the response body. If this string + // is not found, the origin will be marked as unhealthy. This parameter is only + // valid for HTTP and HTTPS monitors. + ExpectedBody param.Field[string] `json:"expected_body"` + // Follow redirects if returned by the origin. This parameter is only valid for + // HTTP and HTTPS monitors. + FollowRedirects param.Field[bool] `json:"follow_redirects"` + // The HTTP request headers to send in the health check. It is recommended you set + // a Host header by default. The User-Agent header cannot be overridden. This + // parameter is only valid for HTTP and HTTPS monitors. + Header param.Field[interface{}] `json:"header"` + // The interval between each health check. Shorter intervals may improve failover + // time, but will increase load on the origins as we check from multiple locations. + Interval param.Field[int64] `json:"interval"` + // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS + // based checks and 'connection_established' for TCP based health checks. + Method param.Field[string] `json:"method"` + // The endpoint path you want to conduct a health check against. This parameter is + // only valid for HTTP and HTTPS monitors. + Path param.Field[string] `json:"path"` + // The port number to connect to for the health check. Required for TCP, UDP, and + // SMTP checks. HTTP and HTTPS checks should only define the port when using a + // non-standard port (HTTP: default 80, HTTPS: default 443). + Port param.Field[int64] `json:"port"` + // Assign this monitor to emulate the specified zone while probing. This parameter + // is only valid for HTTP and HTTPS monitors. + ProbeZone param.Field[string] `json:"probe_zone"` + // The number of retries to attempt in case of a timeout before marking the origin + // as unhealthy. Retries are attempted immediately. + Retries param.Field[int64] `json:"retries"` + // The timeout (in seconds) before marking the health check as failed. + Timeout param.Field[int64] `json:"timeout"` + // The protocol to use for the health check. Currently supported protocols are + // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. + Type param.Field[LoadBalancerMonitorEditParamsType] `json:"type"` +} + +func (r LoadBalancerMonitorEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The protocol to use for the health check. Currently supported protocols are +// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. +type LoadBalancerMonitorEditParamsType string + +const ( + LoadBalancerMonitorEditParamsTypeHTTP LoadBalancerMonitorEditParamsType = "http" + LoadBalancerMonitorEditParamsTypeHTTPS LoadBalancerMonitorEditParamsType = "https" + LoadBalancerMonitorEditParamsTypeTcp LoadBalancerMonitorEditParamsType = "tcp" + LoadBalancerMonitorEditParamsTypeUdpIcmp LoadBalancerMonitorEditParamsType = "udp_icmp" + LoadBalancerMonitorEditParamsTypeIcmpPing LoadBalancerMonitorEditParamsType = "icmp_ping" + LoadBalancerMonitorEditParamsTypeSmtp LoadBalancerMonitorEditParamsType = "smtp" +) + +type LoadBalancerMonitorEditResponseEnvelope struct { + Errors []LoadBalancerMonitorEditResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerMonitorEditResponseEnvelopeMessages `json:"messages,required"` + Result LoadBalancingMonitor `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerMonitorEditResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerMonitorEditResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerMonitorEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [LoadBalancerMonitorEditResponseEnvelope] +type loadBalancerMonitorEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerMonitorEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerMonitorEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [LoadBalancerMonitorEditResponseEnvelopeErrors] +type loadBalancerMonitorEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerMonitorEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerMonitorEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [LoadBalancerMonitorEditResponseEnvelopeMessages] +type loadBalancerMonitorEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerMonitorEditResponseEnvelopeSuccess bool + +const ( + LoadBalancerMonitorEditResponseEnvelopeSuccessTrue LoadBalancerMonitorEditResponseEnvelopeSuccess = true +) + +type LoadBalancerMonitorGetResponseEnvelope struct { + Errors []LoadBalancerMonitorGetResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerMonitorGetResponseEnvelopeMessages `json:"messages,required"` + Result LoadBalancingMonitor `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerMonitorGetResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerMonitorGetResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerMonitorGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [LoadBalancerMonitorGetResponseEnvelope] +type loadBalancerMonitorGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerMonitorGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerMonitorGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [LoadBalancerMonitorGetResponseEnvelopeErrors] +type loadBalancerMonitorGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerMonitorGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerMonitorGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [LoadBalancerMonitorGetResponseEnvelopeMessages] +type loadBalancerMonitorGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerMonitorGetResponseEnvelopeSuccess bool + +const ( + LoadBalancerMonitorGetResponseEnvelopeSuccessTrue LoadBalancerMonitorGetResponseEnvelopeSuccess = true +) + +type LoadBalancerMonitorPreviewParams struct { + // The expected HTTP response code or code range of the health check. This + // parameter is only valid for HTTP and HTTPS monitors. + ExpectedCodes param.Field[string] `json:"expected_codes,required"` + // Do not validate the certificate when monitor use HTTPS. This parameter is + // currently only valid for HTTP and HTTPS monitors. + AllowInsecure param.Field[bool] `json:"allow_insecure"` + // To be marked unhealthy the monitored origin must fail this healthcheck N + // consecutive times. + ConsecutiveDown param.Field[int64] `json:"consecutive_down"` + // To be marked healthy the monitored origin must pass this healthcheck N + // consecutive times. + ConsecutiveUp param.Field[int64] `json:"consecutive_up"` + // Object description. + Description param.Field[string] `json:"description"` + // A case-insensitive sub-string to look for in the response body. If this string + // is not found, the origin will be marked as unhealthy. This parameter is only + // valid for HTTP and HTTPS monitors. + ExpectedBody param.Field[string] `json:"expected_body"` + // Follow redirects if returned by the origin. This parameter is only valid for + // HTTP and HTTPS monitors. + FollowRedirects param.Field[bool] `json:"follow_redirects"` + // The HTTP request headers to send in the health check. It is recommended you set + // a Host header by default. The User-Agent header cannot be overridden. This + // parameter is only valid for HTTP and HTTPS monitors. + Header param.Field[interface{}] `json:"header"` + // The interval between each health check. Shorter intervals may improve failover + // time, but will increase load on the origins as we check from multiple locations. + Interval param.Field[int64] `json:"interval"` + // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS + // based checks and 'connection_established' for TCP based health checks. + Method param.Field[string] `json:"method"` + // The endpoint path you want to conduct a health check against. This parameter is + // only valid for HTTP and HTTPS monitors. + Path param.Field[string] `json:"path"` + // The port number to connect to for the health check. Required for TCP, UDP, and + // SMTP checks. HTTP and HTTPS checks should only define the port when using a + // non-standard port (HTTP: default 80, HTTPS: default 443). + Port param.Field[int64] `json:"port"` + // Assign this monitor to emulate the specified zone while probing. This parameter + // is only valid for HTTP and HTTPS monitors. + ProbeZone param.Field[string] `json:"probe_zone"` + // The number of retries to attempt in case of a timeout before marking the origin + // as unhealthy. Retries are attempted immediately. + Retries param.Field[int64] `json:"retries"` + // The timeout (in seconds) before marking the health check as failed. + Timeout param.Field[int64] `json:"timeout"` + // The protocol to use for the health check. Currently supported protocols are + // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. + Type param.Field[LoadBalancerMonitorPreviewParamsType] `json:"type"` +} + +func (r LoadBalancerMonitorPreviewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The protocol to use for the health check. Currently supported protocols are +// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. +type LoadBalancerMonitorPreviewParamsType string + +const ( + LoadBalancerMonitorPreviewParamsTypeHTTP LoadBalancerMonitorPreviewParamsType = "http" + LoadBalancerMonitorPreviewParamsTypeHTTPS LoadBalancerMonitorPreviewParamsType = "https" + LoadBalancerMonitorPreviewParamsTypeTcp LoadBalancerMonitorPreviewParamsType = "tcp" + LoadBalancerMonitorPreviewParamsTypeUdpIcmp LoadBalancerMonitorPreviewParamsType = "udp_icmp" + LoadBalancerMonitorPreviewParamsTypeIcmpPing LoadBalancerMonitorPreviewParamsType = "icmp_ping" + LoadBalancerMonitorPreviewParamsTypeSmtp LoadBalancerMonitorPreviewParamsType = "smtp" +) + +type LoadBalancerMonitorPreviewResponseEnvelope struct { + Errors []LoadBalancerMonitorPreviewResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerMonitorPreviewResponseEnvelopeMessages `json:"messages,required"` + Result LoadBalancerMonitorPreviewResponse `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerMonitorPreviewResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerMonitorPreviewResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerMonitorPreviewResponseEnvelopeJSON contains the JSON metadata for +// the struct [LoadBalancerMonitorPreviewResponseEnvelope] +type loadBalancerMonitorPreviewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorPreviewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorPreviewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorPreviewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerMonitorPreviewResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerMonitorPreviewResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [LoadBalancerMonitorPreviewResponseEnvelopeErrors] +type loadBalancerMonitorPreviewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorPreviewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorPreviewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorPreviewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerMonitorPreviewResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerMonitorPreviewResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [LoadBalancerMonitorPreviewResponseEnvelopeMessages] +type loadBalancerMonitorPreviewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorPreviewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorPreviewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerMonitorPreviewResponseEnvelopeSuccess bool + +const ( + LoadBalancerMonitorPreviewResponseEnvelopeSuccessTrue LoadBalancerMonitorPreviewResponseEnvelopeSuccess = true +) + +type LoadBalancerMonitorReferencesResponseEnvelope struct { + Errors []LoadBalancerMonitorReferencesResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerMonitorReferencesResponseEnvelopeMessages `json:"messages,required"` + // List of resources that reference a given monitor. + Result []LoadBalancerMonitorReferencesResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success LoadBalancerMonitorReferencesResponseEnvelopeSuccess `json:"success,required"` + ResultInfo LoadBalancerMonitorReferencesResponseEnvelopeResultInfo `json:"result_info"` + JSON loadBalancerMonitorReferencesResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerMonitorReferencesResponseEnvelopeJSON contains the JSON metadata for +// the struct [LoadBalancerMonitorReferencesResponseEnvelope] +type loadBalancerMonitorReferencesResponseEnvelopeJSON 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 *LoadBalancerMonitorReferencesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorReferencesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorReferencesResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerMonitorReferencesResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerMonitorReferencesResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [LoadBalancerMonitorReferencesResponseEnvelopeErrors] +type loadBalancerMonitorReferencesResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorReferencesResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorReferencesResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerMonitorReferencesResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerMonitorReferencesResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerMonitorReferencesResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [LoadBalancerMonitorReferencesResponseEnvelopeMessages] +type loadBalancerMonitorReferencesResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorReferencesResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorReferencesResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerMonitorReferencesResponseEnvelopeSuccess bool + +const ( + LoadBalancerMonitorReferencesResponseEnvelopeSuccessTrue LoadBalancerMonitorReferencesResponseEnvelopeSuccess = true +) + +type LoadBalancerMonitorReferencesResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON loadBalancerMonitorReferencesResponseEnvelopeResultInfoJSON `json:"-"` +} + +// loadBalancerMonitorReferencesResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct +// [LoadBalancerMonitorReferencesResponseEnvelopeResultInfo] +type loadBalancerMonitorReferencesResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerMonitorReferencesResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerMonitorReferencesResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/user/loadbalancermonitor_test.go b/user/loadbalancermonitor_test.go new file mode 100644 index 00000000000..fefa4ba9e00 --- /dev/null +++ b/user/loadbalancermonitor_test.go @@ -0,0 +1,315 @@ +// File generated from our OpenAPI spec by Stainless. + +package user_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/user" +) + +func TestLoadBalancerMonitorNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.LoadBalancers.Monitors.New(context.TODO(), user.LoadBalancerMonitorNewParams{ + ExpectedCodes: cloudflare.F("2xx"), + AllowInsecure: cloudflare.F(true), + ConsecutiveDown: cloudflare.F(int64(0)), + ConsecutiveUp: cloudflare.F(int64(0)), + Description: cloudflare.F("Login page monitor"), + ExpectedBody: cloudflare.F("alive"), + FollowRedirects: cloudflare.F(true), + Header: cloudflare.F[any](map[string]interface{}{ + "Host": map[string]interface{}{ + "0": "example.com", + }, + "X-App-ID": map[string]interface{}{ + "0": "abc123", + }, + }), + Interval: cloudflare.F(int64(0)), + Method: cloudflare.F("GET"), + Path: cloudflare.F("/health"), + Port: cloudflare.F(int64(0)), + ProbeZone: cloudflare.F("example.com"), + Retries: cloudflare.F(int64(0)), + Timeout: cloudflare.F(int64(0)), + Type: cloudflare.F(user.LoadBalancerMonitorNewParamsTypeHTTPS), + }) + 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 TestLoadBalancerMonitorUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.LoadBalancers.Monitors.Update( + context.TODO(), + "f1aba936b94213e5b8dca0c0dbf1f9cc", + user.LoadBalancerMonitorUpdateParams{ + ExpectedCodes: cloudflare.F("2xx"), + AllowInsecure: cloudflare.F(true), + ConsecutiveDown: cloudflare.F(int64(0)), + ConsecutiveUp: cloudflare.F(int64(0)), + Description: cloudflare.F("Login page monitor"), + ExpectedBody: cloudflare.F("alive"), + FollowRedirects: cloudflare.F(true), + Header: cloudflare.F[any](map[string]interface{}{ + "Host": map[string]interface{}{ + "0": "example.com", + }, + "X-App-ID": map[string]interface{}{ + "0": "abc123", + }, + }), + Interval: cloudflare.F(int64(0)), + Method: cloudflare.F("GET"), + Path: cloudflare.F("/health"), + Port: cloudflare.F(int64(0)), + ProbeZone: cloudflare.F("example.com"), + Retries: cloudflare.F(int64(0)), + Timeout: cloudflare.F(int64(0)), + Type: cloudflare.F(user.LoadBalancerMonitorUpdateParamsTypeHTTPS), + }, + ) + 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 TestLoadBalancerMonitorList(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("user@example.com"), + ) + _, err := client.User.LoadBalancers.Monitors.List(context.TODO()) + 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 TestLoadBalancerMonitorDelete(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("user@example.com"), + ) + _, err := client.User.LoadBalancers.Monitors.Delete(context.TODO(), "f1aba936b94213e5b8dca0c0dbf1f9cc") + 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 TestLoadBalancerMonitorEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.LoadBalancers.Monitors.Edit( + context.TODO(), + "f1aba936b94213e5b8dca0c0dbf1f9cc", + user.LoadBalancerMonitorEditParams{ + ExpectedCodes: cloudflare.F("2xx"), + AllowInsecure: cloudflare.F(true), + ConsecutiveDown: cloudflare.F(int64(0)), + ConsecutiveUp: cloudflare.F(int64(0)), + Description: cloudflare.F("Login page monitor"), + ExpectedBody: cloudflare.F("alive"), + FollowRedirects: cloudflare.F(true), + Header: cloudflare.F[any](map[string]interface{}{ + "Host": map[string]interface{}{ + "0": "example.com", + }, + "X-App-ID": map[string]interface{}{ + "0": "abc123", + }, + }), + Interval: cloudflare.F(int64(0)), + Method: cloudflare.F("GET"), + Path: cloudflare.F("/health"), + Port: cloudflare.F(int64(0)), + ProbeZone: cloudflare.F("example.com"), + Retries: cloudflare.F(int64(0)), + Timeout: cloudflare.F(int64(0)), + Type: cloudflare.F(user.LoadBalancerMonitorEditParamsTypeHTTPS), + }, + ) + 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 TestLoadBalancerMonitorGet(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("user@example.com"), + ) + _, err := client.User.LoadBalancers.Monitors.Get(context.TODO(), "f1aba936b94213e5b8dca0c0dbf1f9cc") + 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 TestLoadBalancerMonitorPreviewWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.LoadBalancers.Monitors.Preview( + context.TODO(), + "f1aba936b94213e5b8dca0c0dbf1f9cc", + user.LoadBalancerMonitorPreviewParams{ + ExpectedCodes: cloudflare.F("2xx"), + AllowInsecure: cloudflare.F(true), + ConsecutiveDown: cloudflare.F(int64(0)), + ConsecutiveUp: cloudflare.F(int64(0)), + Description: cloudflare.F("Login page monitor"), + ExpectedBody: cloudflare.F("alive"), + FollowRedirects: cloudflare.F(true), + Header: cloudflare.F[any](map[string]interface{}{ + "Host": map[string]interface{}{ + "0": "example.com", + }, + "X-App-ID": map[string]interface{}{ + "0": "abc123", + }, + }), + Interval: cloudflare.F(int64(0)), + Method: cloudflare.F("GET"), + Path: cloudflare.F("/health"), + Port: cloudflare.F(int64(0)), + ProbeZone: cloudflare.F("example.com"), + Retries: cloudflare.F(int64(0)), + Timeout: cloudflare.F(int64(0)), + Type: cloudflare.F(user.LoadBalancerMonitorPreviewParamsTypeHTTPS), + }, + ) + 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 TestLoadBalancerMonitorReferences(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("user@example.com"), + ) + _, err := client.User.LoadBalancers.Monitors.References(context.TODO(), "f1aba936b94213e5b8dca0c0dbf1f9cc") + 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/user/loadbalancerpool.go b/user/loadbalancerpool.go new file mode 100644 index 00000000000..1c740bf0484 --- /dev/null +++ b/user/loadbalancerpool.go @@ -0,0 +1,2267 @@ +// File generated from our OpenAPI spec by Stainless. + +package user + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// LoadBalancerPoolService 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 [NewLoadBalancerPoolService] method +// instead. +type LoadBalancerPoolService struct { + Options []option.RequestOption +} + +// NewLoadBalancerPoolService 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 NewLoadBalancerPoolService(opts ...option.RequestOption) (r *LoadBalancerPoolService) { + r = &LoadBalancerPoolService{} + r.Options = opts + return +} + +// Create a new pool. +func (r *LoadBalancerPoolService) New(ctx context.Context, body LoadBalancerPoolNewParams, opts ...option.RequestOption) (res *LoadBalancingPool, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerPoolNewResponseEnvelope + path := "user/load_balancers/pools" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Modify a configured pool. +func (r *LoadBalancerPoolService) Update(ctx context.Context, poolID string, body LoadBalancerPoolUpdateParams, opts ...option.RequestOption) (res *LoadBalancingPool, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerPoolUpdateResponseEnvelope + path := fmt.Sprintf("user/load_balancers/pools/%s", poolID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List configured pools. +func (r *LoadBalancerPoolService) List(ctx context.Context, query LoadBalancerPoolListParams, opts ...option.RequestOption) (res *[]LoadBalancingPool, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerPoolListResponseEnvelope + path := "user/load_balancers/pools" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a configured pool. +func (r *LoadBalancerPoolService) Delete(ctx context.Context, poolID string, opts ...option.RequestOption) (res *LoadBalancerPoolDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerPoolDeleteResponseEnvelope + path := fmt.Sprintf("user/load_balancers/pools/%s", poolID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Apply changes to an existing pool, overwriting the supplied properties. +func (r *LoadBalancerPoolService) Edit(ctx context.Context, poolID string, body LoadBalancerPoolEditParams, opts ...option.RequestOption) (res *LoadBalancingPool, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerPoolEditResponseEnvelope + path := fmt.Sprintf("user/load_balancers/pools/%s", poolID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch a single configured pool. +func (r *LoadBalancerPoolService) Get(ctx context.Context, poolID string, opts ...option.RequestOption) (res *LoadBalancingPool, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerPoolGetResponseEnvelope + path := fmt.Sprintf("user/load_balancers/pools/%s", poolID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch the latest pool health status for a single pool. +func (r *LoadBalancerPoolService) Health(ctx context.Context, poolID string, opts ...option.RequestOption) (res *LoadBalancerPoolHealthResponse, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerPoolHealthResponseEnvelope + path := fmt.Sprintf("user/load_balancers/pools/%s/health", poolID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Preview pool health using provided monitor details. The returned preview_id can +// be used in the preview endpoint to retrieve the results. +func (r *LoadBalancerPoolService) Preview(ctx context.Context, poolID string, body LoadBalancerPoolPreviewParams, opts ...option.RequestOption) (res *LoadBalancerPoolPreviewResponse, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerPoolPreviewResponseEnvelope + path := fmt.Sprintf("user/load_balancers/pools/%s/preview", poolID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get the list of resources that reference the provided pool. +func (r *LoadBalancerPoolService) References(ctx context.Context, poolID string, opts ...option.RequestOption) (res *[]LoadBalancerPoolReferencesResponse, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerPoolReferencesResponseEnvelope + path := fmt.Sprintf("user/load_balancers/pools/%s/references", poolID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type LoadBalancingPool struct { + ID string `json:"id"` + // A list of regions from which to run health checks. Null means every Cloudflare + // data center. + CheckRegions []LoadBalancingPoolCheckRegion `json:"check_regions,nullable"` + CreatedOn time.Time `json:"created_on" format:"date-time"` + // A human-readable description of the pool. + Description string `json:"description"` + // This field shows up only if the pool is disabled. This field is set with the + // time the pool was disabled at. + DisabledAt time.Time `json:"disabled_at" format:"date-time"` + // Whether to enable (the default) or disable this pool. Disabled pools will not + // receive traffic and are excluded from health checks. Disabling a pool will cause + // any load balancers using it to failover to the next pool (if any). + Enabled bool `json:"enabled"` + // The latitude of the data center containing the origins used in this pool in + // decimal degrees. If this is set, longitude must also be set. + Latitude float64 `json:"latitude"` + // Configures load shedding policies and percentages for the pool. + LoadShedding LoadBalancingPoolLoadShedding `json:"load_shedding"` + // The longitude of the data center containing the origins used in this pool in + // decimal degrees. If this is set, latitude must also be set. + Longitude float64 `json:"longitude"` + // The minimum number of origins that must be healthy for this pool to serve + // traffic. If the number of healthy origins falls below this number, the pool will + // be marked unhealthy and will failover to the next available pool. + MinimumOrigins int64 `json:"minimum_origins"` + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // The ID of the Monitor to use for checking the health of origins within this + // pool. + Monitor interface{} `json:"monitor"` + // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and + // underscores are allowed. + Name string `json:"name"` + // This field is now deprecated. It has been moved to Cloudflare's Centralized + // Notification service + // https://developers.cloudflare.com/fundamentals/notifications/. The email address + // to send health status notifications to. This can be an individual mailbox or a + // mailing list. Multiple emails can be supplied as a comma delimited list. + NotificationEmail string `json:"notification_email"` + // Filter pool and origin health notifications by resource type or health status. + // Use null to reset. + NotificationFilter LoadBalancingPoolNotificationFilter `json:"notification_filter,nullable"` + // Configures origin steering for the pool. Controls how origins are selected for + // new sessions and traffic without session affinity. + OriginSteering LoadBalancingPoolOriginSteering `json:"origin_steering"` + // The list of origins within this pool. Traffic directed at this pool is balanced + // across all currently healthy origins, provided the pool itself is healthy. + Origins []LoadBalancingPoolOrigin `json:"origins"` + JSON loadBalancingPoolJSON `json:"-"` +} + +// loadBalancingPoolJSON contains the JSON metadata for the struct +// [LoadBalancingPool] +type loadBalancingPoolJSON struct { + ID apijson.Field + CheckRegions apijson.Field + CreatedOn apijson.Field + Description apijson.Field + DisabledAt apijson.Field + Enabled apijson.Field + Latitude apijson.Field + LoadShedding apijson.Field + Longitude apijson.Field + MinimumOrigins apijson.Field + ModifiedOn apijson.Field + Monitor apijson.Field + Name apijson.Field + NotificationEmail apijson.Field + NotificationFilter apijson.Field + OriginSteering apijson.Field + Origins apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancingPool) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancingPoolJSON) RawJSON() string { + return r.raw +} + +// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, +// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, +// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: +// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all +// regions (ENTERPRISE customers only). +type LoadBalancingPoolCheckRegion string + +const ( + LoadBalancingPoolCheckRegionWnam LoadBalancingPoolCheckRegion = "WNAM" + LoadBalancingPoolCheckRegionEnam LoadBalancingPoolCheckRegion = "ENAM" + LoadBalancingPoolCheckRegionWeu LoadBalancingPoolCheckRegion = "WEU" + LoadBalancingPoolCheckRegionEeu LoadBalancingPoolCheckRegion = "EEU" + LoadBalancingPoolCheckRegionNsam LoadBalancingPoolCheckRegion = "NSAM" + LoadBalancingPoolCheckRegionSsam LoadBalancingPoolCheckRegion = "SSAM" + LoadBalancingPoolCheckRegionOc LoadBalancingPoolCheckRegion = "OC" + LoadBalancingPoolCheckRegionMe LoadBalancingPoolCheckRegion = "ME" + LoadBalancingPoolCheckRegionNaf LoadBalancingPoolCheckRegion = "NAF" + LoadBalancingPoolCheckRegionSaf LoadBalancingPoolCheckRegion = "SAF" + LoadBalancingPoolCheckRegionSas LoadBalancingPoolCheckRegion = "SAS" + LoadBalancingPoolCheckRegionSeas LoadBalancingPoolCheckRegion = "SEAS" + LoadBalancingPoolCheckRegionNeas LoadBalancingPoolCheckRegion = "NEAS" + LoadBalancingPoolCheckRegionAllRegions LoadBalancingPoolCheckRegion = "ALL_REGIONS" +) + +// Configures load shedding policies and percentages for the pool. +type LoadBalancingPoolLoadShedding struct { + // The percent of traffic to shed from the pool, according to the default policy. + // Applies to new sessions and traffic without session affinity. + DefaultPercent float64 `json:"default_percent"` + // The default policy to use when load shedding. A random policy randomly sheds a + // given percent of requests. A hash policy computes a hash over the + // CF-Connecting-IP address and sheds all requests originating from a percent of + // IPs. + DefaultPolicy LoadBalancingPoolLoadSheddingDefaultPolicy `json:"default_policy"` + // The percent of existing sessions to shed from the pool, according to the session + // policy. + SessionPercent float64 `json:"session_percent"` + // Only the hash policy is supported for existing sessions (to avoid exponential + // decay). + SessionPolicy LoadBalancingPoolLoadSheddingSessionPolicy `json:"session_policy"` + JSON loadBalancingPoolLoadSheddingJSON `json:"-"` +} + +// loadBalancingPoolLoadSheddingJSON contains the JSON metadata for the struct +// [LoadBalancingPoolLoadShedding] +type loadBalancingPoolLoadSheddingJSON struct { + DefaultPercent apijson.Field + DefaultPolicy apijson.Field + SessionPercent apijson.Field + SessionPolicy apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancingPoolLoadShedding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancingPoolLoadSheddingJSON) RawJSON() string { + return r.raw +} + +// The default policy to use when load shedding. A random policy randomly sheds a +// given percent of requests. A hash policy computes a hash over the +// CF-Connecting-IP address and sheds all requests originating from a percent of +// IPs. +type LoadBalancingPoolLoadSheddingDefaultPolicy string + +const ( + LoadBalancingPoolLoadSheddingDefaultPolicyRandom LoadBalancingPoolLoadSheddingDefaultPolicy = "random" + LoadBalancingPoolLoadSheddingDefaultPolicyHash LoadBalancingPoolLoadSheddingDefaultPolicy = "hash" +) + +// Only the hash policy is supported for existing sessions (to avoid exponential +// decay). +type LoadBalancingPoolLoadSheddingSessionPolicy string + +const ( + LoadBalancingPoolLoadSheddingSessionPolicyHash LoadBalancingPoolLoadSheddingSessionPolicy = "hash" +) + +// Filter pool and origin health notifications by resource type or health status. +// Use null to reset. +type LoadBalancingPoolNotificationFilter struct { + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Origin LoadBalancingPoolNotificationFilterOrigin `json:"origin,nullable"` + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Pool LoadBalancingPoolNotificationFilterPool `json:"pool,nullable"` + JSON loadBalancingPoolNotificationFilterJSON `json:"-"` +} + +// loadBalancingPoolNotificationFilterJSON contains the JSON metadata for the +// struct [LoadBalancingPoolNotificationFilter] +type loadBalancingPoolNotificationFilterJSON struct { + Origin apijson.Field + Pool apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancingPoolNotificationFilter) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancingPoolNotificationFilterJSON) RawJSON() string { + return r.raw +} + +// Filter options for a particular resource type (pool or origin). Use null to +// reset. +type LoadBalancingPoolNotificationFilterOrigin struct { + // If set true, disable notifications for this type of resource (pool or origin). + Disable bool `json:"disable"` + // If present, send notifications only for this health status (e.g. false for only + // DOWN events). Use null to reset (all events). + Healthy bool `json:"healthy,nullable"` + JSON loadBalancingPoolNotificationFilterOriginJSON `json:"-"` +} + +// loadBalancingPoolNotificationFilterOriginJSON contains the JSON metadata for the +// struct [LoadBalancingPoolNotificationFilterOrigin] +type loadBalancingPoolNotificationFilterOriginJSON struct { + Disable apijson.Field + Healthy apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancingPoolNotificationFilterOrigin) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancingPoolNotificationFilterOriginJSON) RawJSON() string { + return r.raw +} + +// Filter options for a particular resource type (pool or origin). Use null to +// reset. +type LoadBalancingPoolNotificationFilterPool struct { + // If set true, disable notifications for this type of resource (pool or origin). + Disable bool `json:"disable"` + // If present, send notifications only for this health status (e.g. false for only + // DOWN events). Use null to reset (all events). + Healthy bool `json:"healthy,nullable"` + JSON loadBalancingPoolNotificationFilterPoolJSON `json:"-"` +} + +// loadBalancingPoolNotificationFilterPoolJSON contains the JSON metadata for the +// struct [LoadBalancingPoolNotificationFilterPool] +type loadBalancingPoolNotificationFilterPoolJSON struct { + Disable apijson.Field + Healthy apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancingPoolNotificationFilterPool) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancingPoolNotificationFilterPoolJSON) RawJSON() string { + return r.raw +} + +// Configures origin steering for the pool. Controls how origins are selected for +// new sessions and traffic without session affinity. +type LoadBalancingPoolOriginSteering struct { + // The type of origin steering policy to use. + // + // - `"random"`: Select an origin randomly. + // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP + // address. + // - `"least_outstanding_requests"`: Select an origin by taking into consideration + // origin weights, as well as each origin's number of outstanding requests. + // Origins with more pending requests are weighted proportionately less relative + // to others. + // - `"least_connections"`: Select an origin by taking into consideration origin + // weights, as well as each origin's number of open connections. Origins with + // more open connections are weighted proportionately less relative to others. + // Supported for HTTP/1 and HTTP/2 connections. + Policy LoadBalancingPoolOriginSteeringPolicy `json:"policy"` + JSON loadBalancingPoolOriginSteeringJSON `json:"-"` +} + +// loadBalancingPoolOriginSteeringJSON contains the JSON metadata for the struct +// [LoadBalancingPoolOriginSteering] +type loadBalancingPoolOriginSteeringJSON struct { + Policy apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancingPoolOriginSteering) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancingPoolOriginSteeringJSON) RawJSON() string { + return r.raw +} + +// The type of origin steering policy to use. +// +// - `"random"`: Select an origin randomly. +// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP +// address. +// - `"least_outstanding_requests"`: Select an origin by taking into consideration +// origin weights, as well as each origin's number of outstanding requests. +// Origins with more pending requests are weighted proportionately less relative +// to others. +// - `"least_connections"`: Select an origin by taking into consideration origin +// weights, as well as each origin's number of open connections. Origins with +// more open connections are weighted proportionately less relative to others. +// Supported for HTTP/1 and HTTP/2 connections. +type LoadBalancingPoolOriginSteeringPolicy string + +const ( + LoadBalancingPoolOriginSteeringPolicyRandom LoadBalancingPoolOriginSteeringPolicy = "random" + LoadBalancingPoolOriginSteeringPolicyHash LoadBalancingPoolOriginSteeringPolicy = "hash" + LoadBalancingPoolOriginSteeringPolicyLeastOutstandingRequests LoadBalancingPoolOriginSteeringPolicy = "least_outstanding_requests" + LoadBalancingPoolOriginSteeringPolicyLeastConnections LoadBalancingPoolOriginSteeringPolicy = "least_connections" +) + +type LoadBalancingPoolOrigin struct { + // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable + // hostname. Hostnames entered here should resolve directly to the origin, and not + // be a hostname proxied by Cloudflare. To set an internal/reserved address, + // virtual_network_id must also be set. + Address string `json:"address"` + // This field shows up only if the origin is disabled. This field is set with the + // time the origin was disabled. + DisabledAt time.Time `json:"disabled_at" format:"date-time"` + // Whether to enable (the default) this origin within the pool. Disabled origins + // will not receive traffic and are excluded from health checks. The origin will + // only be disabled for the current pool. + Enabled bool `json:"enabled"` + // The request header is used to pass additional information with an HTTP request. + // Currently supported header is 'Host'. + Header LoadBalancingPoolOriginsHeader `json:"header"` + // A human-identifiable name for the origin. + Name string `json:"name"` + // The virtual network subnet ID the origin belongs in. Virtual network must also + // belong to the account. + VirtualNetworkID string `json:"virtual_network_id"` + // The weight of this origin relative to other origins in the pool. Based on the + // configured weight the total traffic is distributed among origins within the + // pool. + // + // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the + // origin's outstanding requests. + // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's + // open connections. + Weight float64 `json:"weight"` + JSON loadBalancingPoolOriginJSON `json:"-"` +} + +// loadBalancingPoolOriginJSON contains the JSON metadata for the struct +// [LoadBalancingPoolOrigin] +type loadBalancingPoolOriginJSON struct { + Address apijson.Field + DisabledAt apijson.Field + Enabled apijson.Field + Header apijson.Field + Name apijson.Field + VirtualNetworkID apijson.Field + Weight apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancingPoolOrigin) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancingPoolOriginJSON) RawJSON() string { + return r.raw +} + +// The request header is used to pass additional information with an HTTP request. +// Currently supported header is 'Host'. +type LoadBalancingPoolOriginsHeader struct { + // The 'Host' header allows to override the hostname set in the HTTP request. + // Current support is 1 'Host' header override per origin. + Host []string `json:"Host"` + JSON loadBalancingPoolOriginsHeaderJSON `json:"-"` +} + +// loadBalancingPoolOriginsHeaderJSON contains the JSON metadata for the struct +// [LoadBalancingPoolOriginsHeader] +type loadBalancingPoolOriginsHeaderJSON struct { + Host apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancingPoolOriginsHeader) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancingPoolOriginsHeaderJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolDeleteResponse struct { + ID string `json:"id"` + JSON loadBalancerPoolDeleteResponseJSON `json:"-"` +} + +// loadBalancerPoolDeleteResponseJSON contains the JSON metadata for the struct +// [LoadBalancerPoolDeleteResponse] +type loadBalancerPoolDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolDeleteResponseJSON) RawJSON() string { + return r.raw +} + +// A list of regions from which to run health checks. Null means every Cloudflare +// data center. +// +// Union satisfied by [user.LoadBalancerPoolHealthResponseUnknown] or +// [shared.UnionString]. +type LoadBalancerPoolHealthResponse interface { + ImplementsUserLoadBalancerPoolHealthResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*LoadBalancerPoolHealthResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type LoadBalancerPoolPreviewResponse struct { + // Monitored pool IDs mapped to their respective names. + Pools map[string]string `json:"pools"` + PreviewID string `json:"preview_id"` + JSON loadBalancerPoolPreviewResponseJSON `json:"-"` +} + +// loadBalancerPoolPreviewResponseJSON contains the JSON metadata for the struct +// [LoadBalancerPoolPreviewResponse] +type loadBalancerPoolPreviewResponseJSON struct { + Pools apijson.Field + PreviewID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolPreviewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolPreviewResponseJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolReferencesResponse struct { + ReferenceType LoadBalancerPoolReferencesResponseReferenceType `json:"reference_type"` + ResourceID string `json:"resource_id"` + ResourceName string `json:"resource_name"` + ResourceType string `json:"resource_type"` + JSON loadBalancerPoolReferencesResponseJSON `json:"-"` +} + +// loadBalancerPoolReferencesResponseJSON contains the JSON metadata for the struct +// [LoadBalancerPoolReferencesResponse] +type loadBalancerPoolReferencesResponseJSON struct { + ReferenceType apijson.Field + ResourceID apijson.Field + ResourceName apijson.Field + ResourceType apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolReferencesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolReferencesResponseJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolReferencesResponseReferenceType string + +const ( + LoadBalancerPoolReferencesResponseReferenceTypeStar LoadBalancerPoolReferencesResponseReferenceType = "*" + LoadBalancerPoolReferencesResponseReferenceTypeReferral LoadBalancerPoolReferencesResponseReferenceType = "referral" + LoadBalancerPoolReferencesResponseReferenceTypeReferrer LoadBalancerPoolReferencesResponseReferenceType = "referrer" +) + +type LoadBalancerPoolNewParams struct { + // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and + // underscores are allowed. + Name param.Field[string] `json:"name,required"` + // The list of origins within this pool. Traffic directed at this pool is balanced + // across all currently healthy origins, provided the pool itself is healthy. + Origins param.Field[[]LoadBalancerPoolNewParamsOrigin] `json:"origins,required"` + // A list of regions from which to run health checks. Null means every Cloudflare + // data center. + CheckRegions param.Field[[]LoadBalancerPoolNewParamsCheckRegion] `json:"check_regions"` + // A human-readable description of the pool. + Description param.Field[string] `json:"description"` + // Whether to enable (the default) or disable this pool. Disabled pools will not + // receive traffic and are excluded from health checks. Disabling a pool will cause + // any load balancers using it to failover to the next pool (if any). + Enabled param.Field[bool] `json:"enabled"` + // The latitude of the data center containing the origins used in this pool in + // decimal degrees. If this is set, longitude must also be set. + Latitude param.Field[float64] `json:"latitude"` + // Configures load shedding policies and percentages for the pool. + LoadShedding param.Field[LoadBalancerPoolNewParamsLoadShedding] `json:"load_shedding"` + // The longitude of the data center containing the origins used in this pool in + // decimal degrees. If this is set, latitude must also be set. + Longitude param.Field[float64] `json:"longitude"` + // The minimum number of origins that must be healthy for this pool to serve + // traffic. If the number of healthy origins falls below this number, the pool will + // be marked unhealthy and will failover to the next available pool. + MinimumOrigins param.Field[int64] `json:"minimum_origins"` + // The ID of the Monitor to use for checking the health of origins within this + // pool. + Monitor param.Field[interface{}] `json:"monitor"` + // This field is now deprecated. It has been moved to Cloudflare's Centralized + // Notification service + // https://developers.cloudflare.com/fundamentals/notifications/. The email address + // to send health status notifications to. This can be an individual mailbox or a + // mailing list. Multiple emails can be supplied as a comma delimited list. + NotificationEmail param.Field[string] `json:"notification_email"` + // Filter pool and origin health notifications by resource type or health status. + // Use null to reset. + NotificationFilter param.Field[LoadBalancerPoolNewParamsNotificationFilter] `json:"notification_filter"` + // Configures origin steering for the pool. Controls how origins are selected for + // new sessions and traffic without session affinity. + OriginSteering param.Field[LoadBalancerPoolNewParamsOriginSteering] `json:"origin_steering"` +} + +func (r LoadBalancerPoolNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type LoadBalancerPoolNewParamsOrigin struct { + // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable + // hostname. Hostnames entered here should resolve directly to the origin, and not + // be a hostname proxied by Cloudflare. To set an internal/reserved address, + // virtual_network_id must also be set. + Address param.Field[string] `json:"address"` + // Whether to enable (the default) this origin within the pool. Disabled origins + // will not receive traffic and are excluded from health checks. The origin will + // only be disabled for the current pool. + Enabled param.Field[bool] `json:"enabled"` + // The request header is used to pass additional information with an HTTP request. + // Currently supported header is 'Host'. + Header param.Field[LoadBalancerPoolNewParamsOriginsHeader] `json:"header"` + // A human-identifiable name for the origin. + Name param.Field[string] `json:"name"` + // The virtual network subnet ID the origin belongs in. Virtual network must also + // belong to the account. + VirtualNetworkID param.Field[string] `json:"virtual_network_id"` + // The weight of this origin relative to other origins in the pool. Based on the + // configured weight the total traffic is distributed among origins within the + // pool. + // + // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the + // origin's outstanding requests. + // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's + // open connections. + Weight param.Field[float64] `json:"weight"` +} + +func (r LoadBalancerPoolNewParamsOrigin) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The request header is used to pass additional information with an HTTP request. +// Currently supported header is 'Host'. +type LoadBalancerPoolNewParamsOriginsHeader struct { + // The 'Host' header allows to override the hostname set in the HTTP request. + // Current support is 1 'Host' header override per origin. + Host param.Field[[]string] `json:"Host"` +} + +func (r LoadBalancerPoolNewParamsOriginsHeader) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, +// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, +// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: +// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all +// regions (ENTERPRISE customers only). +type LoadBalancerPoolNewParamsCheckRegion string + +const ( + LoadBalancerPoolNewParamsCheckRegionWnam LoadBalancerPoolNewParamsCheckRegion = "WNAM" + LoadBalancerPoolNewParamsCheckRegionEnam LoadBalancerPoolNewParamsCheckRegion = "ENAM" + LoadBalancerPoolNewParamsCheckRegionWeu LoadBalancerPoolNewParamsCheckRegion = "WEU" + LoadBalancerPoolNewParamsCheckRegionEeu LoadBalancerPoolNewParamsCheckRegion = "EEU" + LoadBalancerPoolNewParamsCheckRegionNsam LoadBalancerPoolNewParamsCheckRegion = "NSAM" + LoadBalancerPoolNewParamsCheckRegionSsam LoadBalancerPoolNewParamsCheckRegion = "SSAM" + LoadBalancerPoolNewParamsCheckRegionOc LoadBalancerPoolNewParamsCheckRegion = "OC" + LoadBalancerPoolNewParamsCheckRegionMe LoadBalancerPoolNewParamsCheckRegion = "ME" + LoadBalancerPoolNewParamsCheckRegionNaf LoadBalancerPoolNewParamsCheckRegion = "NAF" + LoadBalancerPoolNewParamsCheckRegionSaf LoadBalancerPoolNewParamsCheckRegion = "SAF" + LoadBalancerPoolNewParamsCheckRegionSas LoadBalancerPoolNewParamsCheckRegion = "SAS" + LoadBalancerPoolNewParamsCheckRegionSeas LoadBalancerPoolNewParamsCheckRegion = "SEAS" + LoadBalancerPoolNewParamsCheckRegionNeas LoadBalancerPoolNewParamsCheckRegion = "NEAS" + LoadBalancerPoolNewParamsCheckRegionAllRegions LoadBalancerPoolNewParamsCheckRegion = "ALL_REGIONS" +) + +// Configures load shedding policies and percentages for the pool. +type LoadBalancerPoolNewParamsLoadShedding struct { + // The percent of traffic to shed from the pool, according to the default policy. + // Applies to new sessions and traffic without session affinity. + DefaultPercent param.Field[float64] `json:"default_percent"` + // The default policy to use when load shedding. A random policy randomly sheds a + // given percent of requests. A hash policy computes a hash over the + // CF-Connecting-IP address and sheds all requests originating from a percent of + // IPs. + DefaultPolicy param.Field[LoadBalancerPoolNewParamsLoadSheddingDefaultPolicy] `json:"default_policy"` + // The percent of existing sessions to shed from the pool, according to the session + // policy. + SessionPercent param.Field[float64] `json:"session_percent"` + // Only the hash policy is supported for existing sessions (to avoid exponential + // decay). + SessionPolicy param.Field[LoadBalancerPoolNewParamsLoadSheddingSessionPolicy] `json:"session_policy"` +} + +func (r LoadBalancerPoolNewParamsLoadShedding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The default policy to use when load shedding. A random policy randomly sheds a +// given percent of requests. A hash policy computes a hash over the +// CF-Connecting-IP address and sheds all requests originating from a percent of +// IPs. +type LoadBalancerPoolNewParamsLoadSheddingDefaultPolicy string + +const ( + LoadBalancerPoolNewParamsLoadSheddingDefaultPolicyRandom LoadBalancerPoolNewParamsLoadSheddingDefaultPolicy = "random" + LoadBalancerPoolNewParamsLoadSheddingDefaultPolicyHash LoadBalancerPoolNewParamsLoadSheddingDefaultPolicy = "hash" +) + +// Only the hash policy is supported for existing sessions (to avoid exponential +// decay). +type LoadBalancerPoolNewParamsLoadSheddingSessionPolicy string + +const ( + LoadBalancerPoolNewParamsLoadSheddingSessionPolicyHash LoadBalancerPoolNewParamsLoadSheddingSessionPolicy = "hash" +) + +// Filter pool and origin health notifications by resource type or health status. +// Use null to reset. +type LoadBalancerPoolNewParamsNotificationFilter struct { + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Origin param.Field[LoadBalancerPoolNewParamsNotificationFilterOrigin] `json:"origin"` + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Pool param.Field[LoadBalancerPoolNewParamsNotificationFilterPool] `json:"pool"` +} + +func (r LoadBalancerPoolNewParamsNotificationFilter) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Filter options for a particular resource type (pool or origin). Use null to +// reset. +type LoadBalancerPoolNewParamsNotificationFilterOrigin struct { + // If set true, disable notifications for this type of resource (pool or origin). + Disable param.Field[bool] `json:"disable"` + // If present, send notifications only for this health status (e.g. false for only + // DOWN events). Use null to reset (all events). + Healthy param.Field[bool] `json:"healthy"` +} + +func (r LoadBalancerPoolNewParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Filter options for a particular resource type (pool or origin). Use null to +// reset. +type LoadBalancerPoolNewParamsNotificationFilterPool struct { + // If set true, disable notifications for this type of resource (pool or origin). + Disable param.Field[bool] `json:"disable"` + // If present, send notifications only for this health status (e.g. false for only + // DOWN events). Use null to reset (all events). + Healthy param.Field[bool] `json:"healthy"` +} + +func (r LoadBalancerPoolNewParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures origin steering for the pool. Controls how origins are selected for +// new sessions and traffic without session affinity. +type LoadBalancerPoolNewParamsOriginSteering struct { + // The type of origin steering policy to use. + // + // - `"random"`: Select an origin randomly. + // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP + // address. + // - `"least_outstanding_requests"`: Select an origin by taking into consideration + // origin weights, as well as each origin's number of outstanding requests. + // Origins with more pending requests are weighted proportionately less relative + // to others. + // - `"least_connections"`: Select an origin by taking into consideration origin + // weights, as well as each origin's number of open connections. Origins with + // more open connections are weighted proportionately less relative to others. + // Supported for HTTP/1 and HTTP/2 connections. + Policy param.Field[LoadBalancerPoolNewParamsOriginSteeringPolicy] `json:"policy"` +} + +func (r LoadBalancerPoolNewParamsOriginSteering) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of origin steering policy to use. +// +// - `"random"`: Select an origin randomly. +// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP +// address. +// - `"least_outstanding_requests"`: Select an origin by taking into consideration +// origin weights, as well as each origin's number of outstanding requests. +// Origins with more pending requests are weighted proportionately less relative +// to others. +// - `"least_connections"`: Select an origin by taking into consideration origin +// weights, as well as each origin's number of open connections. Origins with +// more open connections are weighted proportionately less relative to others. +// Supported for HTTP/1 and HTTP/2 connections. +type LoadBalancerPoolNewParamsOriginSteeringPolicy string + +const ( + LoadBalancerPoolNewParamsOriginSteeringPolicyRandom LoadBalancerPoolNewParamsOriginSteeringPolicy = "random" + LoadBalancerPoolNewParamsOriginSteeringPolicyHash LoadBalancerPoolNewParamsOriginSteeringPolicy = "hash" + LoadBalancerPoolNewParamsOriginSteeringPolicyLeastOutstandingRequests LoadBalancerPoolNewParamsOriginSteeringPolicy = "least_outstanding_requests" + LoadBalancerPoolNewParamsOriginSteeringPolicyLeastConnections LoadBalancerPoolNewParamsOriginSteeringPolicy = "least_connections" +) + +type LoadBalancerPoolNewResponseEnvelope struct { + Errors []LoadBalancerPoolNewResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerPoolNewResponseEnvelopeMessages `json:"messages,required"` + Result LoadBalancingPool `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerPoolNewResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerPoolNewResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerPoolNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [LoadBalancerPoolNewResponseEnvelope] +type loadBalancerPoolNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPoolNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerPoolNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [LoadBalancerPoolNewResponseEnvelopeErrors] +type loadBalancerPoolNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPoolNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerPoolNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [LoadBalancerPoolNewResponseEnvelopeMessages] +type loadBalancerPoolNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerPoolNewResponseEnvelopeSuccess bool + +const ( + LoadBalancerPoolNewResponseEnvelopeSuccessTrue LoadBalancerPoolNewResponseEnvelopeSuccess = true +) + +type LoadBalancerPoolUpdateParams struct { + // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and + // underscores are allowed. + Name param.Field[string] `json:"name,required"` + // The list of origins within this pool. Traffic directed at this pool is balanced + // across all currently healthy origins, provided the pool itself is healthy. + Origins param.Field[[]LoadBalancerPoolUpdateParamsOrigin] `json:"origins,required"` + // A list of regions from which to run health checks. Null means every Cloudflare + // data center. + CheckRegions param.Field[[]LoadBalancerPoolUpdateParamsCheckRegion] `json:"check_regions"` + // A human-readable description of the pool. + Description param.Field[string] `json:"description"` + // Whether to enable (the default) or disable this pool. Disabled pools will not + // receive traffic and are excluded from health checks. Disabling a pool will cause + // any load balancers using it to failover to the next pool (if any). + Enabled param.Field[bool] `json:"enabled"` + // The latitude of the data center containing the origins used in this pool in + // decimal degrees. If this is set, longitude must also be set. + Latitude param.Field[float64] `json:"latitude"` + // Configures load shedding policies and percentages for the pool. + LoadShedding param.Field[LoadBalancerPoolUpdateParamsLoadShedding] `json:"load_shedding"` + // The longitude of the data center containing the origins used in this pool in + // decimal degrees. If this is set, latitude must also be set. + Longitude param.Field[float64] `json:"longitude"` + // The minimum number of origins that must be healthy for this pool to serve + // traffic. If the number of healthy origins falls below this number, the pool will + // be marked unhealthy and will failover to the next available pool. + MinimumOrigins param.Field[int64] `json:"minimum_origins"` + // The ID of the Monitor to use for checking the health of origins within this + // pool. + Monitor param.Field[interface{}] `json:"monitor"` + // This field is now deprecated. It has been moved to Cloudflare's Centralized + // Notification service + // https://developers.cloudflare.com/fundamentals/notifications/. The email address + // to send health status notifications to. This can be an individual mailbox or a + // mailing list. Multiple emails can be supplied as a comma delimited list. + NotificationEmail param.Field[string] `json:"notification_email"` + // Filter pool and origin health notifications by resource type or health status. + // Use null to reset. + NotificationFilter param.Field[LoadBalancerPoolUpdateParamsNotificationFilter] `json:"notification_filter"` + // Configures origin steering for the pool. Controls how origins are selected for + // new sessions and traffic without session affinity. + OriginSteering param.Field[LoadBalancerPoolUpdateParamsOriginSteering] `json:"origin_steering"` +} + +func (r LoadBalancerPoolUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type LoadBalancerPoolUpdateParamsOrigin struct { + // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable + // hostname. Hostnames entered here should resolve directly to the origin, and not + // be a hostname proxied by Cloudflare. To set an internal/reserved address, + // virtual_network_id must also be set. + Address param.Field[string] `json:"address"` + // Whether to enable (the default) this origin within the pool. Disabled origins + // will not receive traffic and are excluded from health checks. The origin will + // only be disabled for the current pool. + Enabled param.Field[bool] `json:"enabled"` + // The request header is used to pass additional information with an HTTP request. + // Currently supported header is 'Host'. + Header param.Field[LoadBalancerPoolUpdateParamsOriginsHeader] `json:"header"` + // A human-identifiable name for the origin. + Name param.Field[string] `json:"name"` + // The virtual network subnet ID the origin belongs in. Virtual network must also + // belong to the account. + VirtualNetworkID param.Field[string] `json:"virtual_network_id"` + // The weight of this origin relative to other origins in the pool. Based on the + // configured weight the total traffic is distributed among origins within the + // pool. + // + // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the + // origin's outstanding requests. + // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's + // open connections. + Weight param.Field[float64] `json:"weight"` +} + +func (r LoadBalancerPoolUpdateParamsOrigin) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The request header is used to pass additional information with an HTTP request. +// Currently supported header is 'Host'. +type LoadBalancerPoolUpdateParamsOriginsHeader struct { + // The 'Host' header allows to override the hostname set in the HTTP request. + // Current support is 1 'Host' header override per origin. + Host param.Field[[]string] `json:"Host"` +} + +func (r LoadBalancerPoolUpdateParamsOriginsHeader) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, +// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, +// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: +// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all +// regions (ENTERPRISE customers only). +type LoadBalancerPoolUpdateParamsCheckRegion string + +const ( + LoadBalancerPoolUpdateParamsCheckRegionWnam LoadBalancerPoolUpdateParamsCheckRegion = "WNAM" + LoadBalancerPoolUpdateParamsCheckRegionEnam LoadBalancerPoolUpdateParamsCheckRegion = "ENAM" + LoadBalancerPoolUpdateParamsCheckRegionWeu LoadBalancerPoolUpdateParamsCheckRegion = "WEU" + LoadBalancerPoolUpdateParamsCheckRegionEeu LoadBalancerPoolUpdateParamsCheckRegion = "EEU" + LoadBalancerPoolUpdateParamsCheckRegionNsam LoadBalancerPoolUpdateParamsCheckRegion = "NSAM" + LoadBalancerPoolUpdateParamsCheckRegionSsam LoadBalancerPoolUpdateParamsCheckRegion = "SSAM" + LoadBalancerPoolUpdateParamsCheckRegionOc LoadBalancerPoolUpdateParamsCheckRegion = "OC" + LoadBalancerPoolUpdateParamsCheckRegionMe LoadBalancerPoolUpdateParamsCheckRegion = "ME" + LoadBalancerPoolUpdateParamsCheckRegionNaf LoadBalancerPoolUpdateParamsCheckRegion = "NAF" + LoadBalancerPoolUpdateParamsCheckRegionSaf LoadBalancerPoolUpdateParamsCheckRegion = "SAF" + LoadBalancerPoolUpdateParamsCheckRegionSas LoadBalancerPoolUpdateParamsCheckRegion = "SAS" + LoadBalancerPoolUpdateParamsCheckRegionSeas LoadBalancerPoolUpdateParamsCheckRegion = "SEAS" + LoadBalancerPoolUpdateParamsCheckRegionNeas LoadBalancerPoolUpdateParamsCheckRegion = "NEAS" + LoadBalancerPoolUpdateParamsCheckRegionAllRegions LoadBalancerPoolUpdateParamsCheckRegion = "ALL_REGIONS" +) + +// Configures load shedding policies and percentages for the pool. +type LoadBalancerPoolUpdateParamsLoadShedding struct { + // The percent of traffic to shed from the pool, according to the default policy. + // Applies to new sessions and traffic without session affinity. + DefaultPercent param.Field[float64] `json:"default_percent"` + // The default policy to use when load shedding. A random policy randomly sheds a + // given percent of requests. A hash policy computes a hash over the + // CF-Connecting-IP address and sheds all requests originating from a percent of + // IPs. + DefaultPolicy param.Field[LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy] `json:"default_policy"` + // The percent of existing sessions to shed from the pool, according to the session + // policy. + SessionPercent param.Field[float64] `json:"session_percent"` + // Only the hash policy is supported for existing sessions (to avoid exponential + // decay). + SessionPolicy param.Field[LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicy] `json:"session_policy"` +} + +func (r LoadBalancerPoolUpdateParamsLoadShedding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The default policy to use when load shedding. A random policy randomly sheds a +// given percent of requests. A hash policy computes a hash over the +// CF-Connecting-IP address and sheds all requests originating from a percent of +// IPs. +type LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy string + +const ( + LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyRandom LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy = "random" + LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyHash LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy = "hash" +) + +// Only the hash policy is supported for existing sessions (to avoid exponential +// decay). +type LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicy string + +const ( + LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicyHash LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicy = "hash" +) + +// Filter pool and origin health notifications by resource type or health status. +// Use null to reset. +type LoadBalancerPoolUpdateParamsNotificationFilter struct { + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Origin param.Field[LoadBalancerPoolUpdateParamsNotificationFilterOrigin] `json:"origin"` + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Pool param.Field[LoadBalancerPoolUpdateParamsNotificationFilterPool] `json:"pool"` +} + +func (r LoadBalancerPoolUpdateParamsNotificationFilter) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Filter options for a particular resource type (pool or origin). Use null to +// reset. +type LoadBalancerPoolUpdateParamsNotificationFilterOrigin struct { + // If set true, disable notifications for this type of resource (pool or origin). + Disable param.Field[bool] `json:"disable"` + // If present, send notifications only for this health status (e.g. false for only + // DOWN events). Use null to reset (all events). + Healthy param.Field[bool] `json:"healthy"` +} + +func (r LoadBalancerPoolUpdateParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Filter options for a particular resource type (pool or origin). Use null to +// reset. +type LoadBalancerPoolUpdateParamsNotificationFilterPool struct { + // If set true, disable notifications for this type of resource (pool or origin). + Disable param.Field[bool] `json:"disable"` + // If present, send notifications only for this health status (e.g. false for only + // DOWN events). Use null to reset (all events). + Healthy param.Field[bool] `json:"healthy"` +} + +func (r LoadBalancerPoolUpdateParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures origin steering for the pool. Controls how origins are selected for +// new sessions and traffic without session affinity. +type LoadBalancerPoolUpdateParamsOriginSteering struct { + // The type of origin steering policy to use. + // + // - `"random"`: Select an origin randomly. + // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP + // address. + // - `"least_outstanding_requests"`: Select an origin by taking into consideration + // origin weights, as well as each origin's number of outstanding requests. + // Origins with more pending requests are weighted proportionately less relative + // to others. + // - `"least_connections"`: Select an origin by taking into consideration origin + // weights, as well as each origin's number of open connections. Origins with + // more open connections are weighted proportionately less relative to others. + // Supported for HTTP/1 and HTTP/2 connections. + Policy param.Field[LoadBalancerPoolUpdateParamsOriginSteeringPolicy] `json:"policy"` +} + +func (r LoadBalancerPoolUpdateParamsOriginSteering) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of origin steering policy to use. +// +// - `"random"`: Select an origin randomly. +// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP +// address. +// - `"least_outstanding_requests"`: Select an origin by taking into consideration +// origin weights, as well as each origin's number of outstanding requests. +// Origins with more pending requests are weighted proportionately less relative +// to others. +// - `"least_connections"`: Select an origin by taking into consideration origin +// weights, as well as each origin's number of open connections. Origins with +// more open connections are weighted proportionately less relative to others. +// Supported for HTTP/1 and HTTP/2 connections. +type LoadBalancerPoolUpdateParamsOriginSteeringPolicy string + +const ( + LoadBalancerPoolUpdateParamsOriginSteeringPolicyRandom LoadBalancerPoolUpdateParamsOriginSteeringPolicy = "random" + LoadBalancerPoolUpdateParamsOriginSteeringPolicyHash LoadBalancerPoolUpdateParamsOriginSteeringPolicy = "hash" + LoadBalancerPoolUpdateParamsOriginSteeringPolicyLeastOutstandingRequests LoadBalancerPoolUpdateParamsOriginSteeringPolicy = "least_outstanding_requests" + LoadBalancerPoolUpdateParamsOriginSteeringPolicyLeastConnections LoadBalancerPoolUpdateParamsOriginSteeringPolicy = "least_connections" +) + +type LoadBalancerPoolUpdateResponseEnvelope struct { + Errors []LoadBalancerPoolUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerPoolUpdateResponseEnvelopeMessages `json:"messages,required"` + Result LoadBalancingPool `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerPoolUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerPoolUpdateResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerPoolUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [LoadBalancerPoolUpdateResponseEnvelope] +type loadBalancerPoolUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPoolUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerPoolUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [LoadBalancerPoolUpdateResponseEnvelopeErrors] +type loadBalancerPoolUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPoolUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerPoolUpdateResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [LoadBalancerPoolUpdateResponseEnvelopeMessages] +type loadBalancerPoolUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerPoolUpdateResponseEnvelopeSuccess bool + +const ( + LoadBalancerPoolUpdateResponseEnvelopeSuccessTrue LoadBalancerPoolUpdateResponseEnvelopeSuccess = true +) + +type LoadBalancerPoolListParams struct { + // The ID of the Monitor to use for checking the health of origins within this + // pool. + Monitor param.Field[interface{}] `query:"monitor"` +} + +// URLQuery serializes [LoadBalancerPoolListParams]'s query parameters as +// `url.Values`. +func (r LoadBalancerPoolListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type LoadBalancerPoolListResponseEnvelope struct { + Errors []LoadBalancerPoolListResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerPoolListResponseEnvelopeMessages `json:"messages,required"` + Result []LoadBalancingPool `json:"result,required,nullable"` + // Whether the API call was successful + Success LoadBalancerPoolListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo LoadBalancerPoolListResponseEnvelopeResultInfo `json:"result_info"` + JSON loadBalancerPoolListResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerPoolListResponseEnvelopeJSON contains the JSON metadata for the +// struct [LoadBalancerPoolListResponseEnvelope] +type loadBalancerPoolListResponseEnvelopeJSON 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 *LoadBalancerPoolListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPoolListResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerPoolListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [LoadBalancerPoolListResponseEnvelopeErrors] +type loadBalancerPoolListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPoolListResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerPoolListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [LoadBalancerPoolListResponseEnvelopeMessages] +type loadBalancerPoolListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerPoolListResponseEnvelopeSuccess bool + +const ( + LoadBalancerPoolListResponseEnvelopeSuccessTrue LoadBalancerPoolListResponseEnvelopeSuccess = true +) + +type LoadBalancerPoolListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON loadBalancerPoolListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// loadBalancerPoolListResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [LoadBalancerPoolListResponseEnvelopeResultInfo] +type loadBalancerPoolListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolDeleteResponseEnvelope struct { + Errors []LoadBalancerPoolDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerPoolDeleteResponseEnvelopeMessages `json:"messages,required"` + Result LoadBalancerPoolDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerPoolDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerPoolDeleteResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerPoolDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [LoadBalancerPoolDeleteResponseEnvelope] +type loadBalancerPoolDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPoolDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerPoolDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [LoadBalancerPoolDeleteResponseEnvelopeErrors] +type loadBalancerPoolDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPoolDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerPoolDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [LoadBalancerPoolDeleteResponseEnvelopeMessages] +type loadBalancerPoolDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerPoolDeleteResponseEnvelopeSuccess bool + +const ( + LoadBalancerPoolDeleteResponseEnvelopeSuccessTrue LoadBalancerPoolDeleteResponseEnvelopeSuccess = true +) + +type LoadBalancerPoolEditParams struct { + // A list of regions from which to run health checks. Null means every Cloudflare + // data center. + CheckRegions param.Field[[]LoadBalancerPoolEditParamsCheckRegion] `json:"check_regions"` + // A human-readable description of the pool. + Description param.Field[string] `json:"description"` + // Whether to enable (the default) or disable this pool. Disabled pools will not + // receive traffic and are excluded from health checks. Disabling a pool will cause + // any load balancers using it to failover to the next pool (if any). + Enabled param.Field[bool] `json:"enabled"` + // The latitude of the data center containing the origins used in this pool in + // decimal degrees. If this is set, longitude must also be set. + Latitude param.Field[float64] `json:"latitude"` + // Configures load shedding policies and percentages for the pool. + LoadShedding param.Field[LoadBalancerPoolEditParamsLoadShedding] `json:"load_shedding"` + // The longitude of the data center containing the origins used in this pool in + // decimal degrees. If this is set, latitude must also be set. + Longitude param.Field[float64] `json:"longitude"` + // The minimum number of origins that must be healthy for this pool to serve + // traffic. If the number of healthy origins falls below this number, the pool will + // be marked unhealthy and will failover to the next available pool. + MinimumOrigins param.Field[int64] `json:"minimum_origins"` + // The ID of the Monitor to use for checking the health of origins within this + // pool. + Monitor param.Field[interface{}] `json:"monitor"` + // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and + // underscores are allowed. + Name param.Field[string] `json:"name"` + // This field is now deprecated. It has been moved to Cloudflare's Centralized + // Notification service + // https://developers.cloudflare.com/fundamentals/notifications/. The email address + // to send health status notifications to. This can be an individual mailbox or a + // mailing list. Multiple emails can be supplied as a comma delimited list. + NotificationEmail param.Field[string] `json:"notification_email"` + // Filter pool and origin health notifications by resource type or health status. + // Use null to reset. + NotificationFilter param.Field[LoadBalancerPoolEditParamsNotificationFilter] `json:"notification_filter"` + // Configures origin steering for the pool. Controls how origins are selected for + // new sessions and traffic without session affinity. + OriginSteering param.Field[LoadBalancerPoolEditParamsOriginSteering] `json:"origin_steering"` + // The list of origins within this pool. Traffic directed at this pool is balanced + // across all currently healthy origins, provided the pool itself is healthy. + Origins param.Field[[]LoadBalancerPoolEditParamsOrigin] `json:"origins"` +} + +func (r LoadBalancerPoolEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, +// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, +// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: +// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all +// regions (ENTERPRISE customers only). +type LoadBalancerPoolEditParamsCheckRegion string + +const ( + LoadBalancerPoolEditParamsCheckRegionWnam LoadBalancerPoolEditParamsCheckRegion = "WNAM" + LoadBalancerPoolEditParamsCheckRegionEnam LoadBalancerPoolEditParamsCheckRegion = "ENAM" + LoadBalancerPoolEditParamsCheckRegionWeu LoadBalancerPoolEditParamsCheckRegion = "WEU" + LoadBalancerPoolEditParamsCheckRegionEeu LoadBalancerPoolEditParamsCheckRegion = "EEU" + LoadBalancerPoolEditParamsCheckRegionNsam LoadBalancerPoolEditParamsCheckRegion = "NSAM" + LoadBalancerPoolEditParamsCheckRegionSsam LoadBalancerPoolEditParamsCheckRegion = "SSAM" + LoadBalancerPoolEditParamsCheckRegionOc LoadBalancerPoolEditParamsCheckRegion = "OC" + LoadBalancerPoolEditParamsCheckRegionMe LoadBalancerPoolEditParamsCheckRegion = "ME" + LoadBalancerPoolEditParamsCheckRegionNaf LoadBalancerPoolEditParamsCheckRegion = "NAF" + LoadBalancerPoolEditParamsCheckRegionSaf LoadBalancerPoolEditParamsCheckRegion = "SAF" + LoadBalancerPoolEditParamsCheckRegionSas LoadBalancerPoolEditParamsCheckRegion = "SAS" + LoadBalancerPoolEditParamsCheckRegionSeas LoadBalancerPoolEditParamsCheckRegion = "SEAS" + LoadBalancerPoolEditParamsCheckRegionNeas LoadBalancerPoolEditParamsCheckRegion = "NEAS" + LoadBalancerPoolEditParamsCheckRegionAllRegions LoadBalancerPoolEditParamsCheckRegion = "ALL_REGIONS" +) + +// Configures load shedding policies and percentages for the pool. +type LoadBalancerPoolEditParamsLoadShedding struct { + // The percent of traffic to shed from the pool, according to the default policy. + // Applies to new sessions and traffic without session affinity. + DefaultPercent param.Field[float64] `json:"default_percent"` + // The default policy to use when load shedding. A random policy randomly sheds a + // given percent of requests. A hash policy computes a hash over the + // CF-Connecting-IP address and sheds all requests originating from a percent of + // IPs. + DefaultPolicy param.Field[LoadBalancerPoolEditParamsLoadSheddingDefaultPolicy] `json:"default_policy"` + // The percent of existing sessions to shed from the pool, according to the session + // policy. + SessionPercent param.Field[float64] `json:"session_percent"` + // Only the hash policy is supported for existing sessions (to avoid exponential + // decay). + SessionPolicy param.Field[LoadBalancerPoolEditParamsLoadSheddingSessionPolicy] `json:"session_policy"` +} + +func (r LoadBalancerPoolEditParamsLoadShedding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The default policy to use when load shedding. A random policy randomly sheds a +// given percent of requests. A hash policy computes a hash over the +// CF-Connecting-IP address and sheds all requests originating from a percent of +// IPs. +type LoadBalancerPoolEditParamsLoadSheddingDefaultPolicy string + +const ( + LoadBalancerPoolEditParamsLoadSheddingDefaultPolicyRandom LoadBalancerPoolEditParamsLoadSheddingDefaultPolicy = "random" + LoadBalancerPoolEditParamsLoadSheddingDefaultPolicyHash LoadBalancerPoolEditParamsLoadSheddingDefaultPolicy = "hash" +) + +// Only the hash policy is supported for existing sessions (to avoid exponential +// decay). +type LoadBalancerPoolEditParamsLoadSheddingSessionPolicy string + +const ( + LoadBalancerPoolEditParamsLoadSheddingSessionPolicyHash LoadBalancerPoolEditParamsLoadSheddingSessionPolicy = "hash" +) + +// Filter pool and origin health notifications by resource type or health status. +// Use null to reset. +type LoadBalancerPoolEditParamsNotificationFilter struct { + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Origin param.Field[LoadBalancerPoolEditParamsNotificationFilterOrigin] `json:"origin"` + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Pool param.Field[LoadBalancerPoolEditParamsNotificationFilterPool] `json:"pool"` +} + +func (r LoadBalancerPoolEditParamsNotificationFilter) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Filter options for a particular resource type (pool or origin). Use null to +// reset. +type LoadBalancerPoolEditParamsNotificationFilterOrigin struct { + // If set true, disable notifications for this type of resource (pool or origin). + Disable param.Field[bool] `json:"disable"` + // If present, send notifications only for this health status (e.g. false for only + // DOWN events). Use null to reset (all events). + Healthy param.Field[bool] `json:"healthy"` +} + +func (r LoadBalancerPoolEditParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Filter options for a particular resource type (pool or origin). Use null to +// reset. +type LoadBalancerPoolEditParamsNotificationFilterPool struct { + // If set true, disable notifications for this type of resource (pool or origin). + Disable param.Field[bool] `json:"disable"` + // If present, send notifications only for this health status (e.g. false for only + // DOWN events). Use null to reset (all events). + Healthy param.Field[bool] `json:"healthy"` +} + +func (r LoadBalancerPoolEditParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures origin steering for the pool. Controls how origins are selected for +// new sessions and traffic without session affinity. +type LoadBalancerPoolEditParamsOriginSteering struct { + // The type of origin steering policy to use. + // + // - `"random"`: Select an origin randomly. + // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP + // address. + // - `"least_outstanding_requests"`: Select an origin by taking into consideration + // origin weights, as well as each origin's number of outstanding requests. + // Origins with more pending requests are weighted proportionately less relative + // to others. + // - `"least_connections"`: Select an origin by taking into consideration origin + // weights, as well as each origin's number of open connections. Origins with + // more open connections are weighted proportionately less relative to others. + // Supported for HTTP/1 and HTTP/2 connections. + Policy param.Field[LoadBalancerPoolEditParamsOriginSteeringPolicy] `json:"policy"` +} + +func (r LoadBalancerPoolEditParamsOriginSteering) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of origin steering policy to use. +// +// - `"random"`: Select an origin randomly. +// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP +// address. +// - `"least_outstanding_requests"`: Select an origin by taking into consideration +// origin weights, as well as each origin's number of outstanding requests. +// Origins with more pending requests are weighted proportionately less relative +// to others. +// - `"least_connections"`: Select an origin by taking into consideration origin +// weights, as well as each origin's number of open connections. Origins with +// more open connections are weighted proportionately less relative to others. +// Supported for HTTP/1 and HTTP/2 connections. +type LoadBalancerPoolEditParamsOriginSteeringPolicy string + +const ( + LoadBalancerPoolEditParamsOriginSteeringPolicyRandom LoadBalancerPoolEditParamsOriginSteeringPolicy = "random" + LoadBalancerPoolEditParamsOriginSteeringPolicyHash LoadBalancerPoolEditParamsOriginSteeringPolicy = "hash" + LoadBalancerPoolEditParamsOriginSteeringPolicyLeastOutstandingRequests LoadBalancerPoolEditParamsOriginSteeringPolicy = "least_outstanding_requests" + LoadBalancerPoolEditParamsOriginSteeringPolicyLeastConnections LoadBalancerPoolEditParamsOriginSteeringPolicy = "least_connections" +) + +type LoadBalancerPoolEditParamsOrigin struct { + // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable + // hostname. Hostnames entered here should resolve directly to the origin, and not + // be a hostname proxied by Cloudflare. To set an internal/reserved address, + // virtual_network_id must also be set. + Address param.Field[string] `json:"address"` + // Whether to enable (the default) this origin within the pool. Disabled origins + // will not receive traffic and are excluded from health checks. The origin will + // only be disabled for the current pool. + Enabled param.Field[bool] `json:"enabled"` + // The request header is used to pass additional information with an HTTP request. + // Currently supported header is 'Host'. + Header param.Field[LoadBalancerPoolEditParamsOriginsHeader] `json:"header"` + // A human-identifiable name for the origin. + Name param.Field[string] `json:"name"` + // The virtual network subnet ID the origin belongs in. Virtual network must also + // belong to the account. + VirtualNetworkID param.Field[string] `json:"virtual_network_id"` + // The weight of this origin relative to other origins in the pool. Based on the + // configured weight the total traffic is distributed among origins within the + // pool. + // + // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the + // origin's outstanding requests. + // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's + // open connections. + Weight param.Field[float64] `json:"weight"` +} + +func (r LoadBalancerPoolEditParamsOrigin) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The request header is used to pass additional information with an HTTP request. +// Currently supported header is 'Host'. +type LoadBalancerPoolEditParamsOriginsHeader struct { + // The 'Host' header allows to override the hostname set in the HTTP request. + // Current support is 1 'Host' header override per origin. + Host param.Field[[]string] `json:"Host"` +} + +func (r LoadBalancerPoolEditParamsOriginsHeader) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type LoadBalancerPoolEditResponseEnvelope struct { + Errors []LoadBalancerPoolEditResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerPoolEditResponseEnvelopeMessages `json:"messages,required"` + Result LoadBalancingPool `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerPoolEditResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerPoolEditResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerPoolEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [LoadBalancerPoolEditResponseEnvelope] +type loadBalancerPoolEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPoolEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerPoolEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [LoadBalancerPoolEditResponseEnvelopeErrors] +type loadBalancerPoolEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPoolEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerPoolEditResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [LoadBalancerPoolEditResponseEnvelopeMessages] +type loadBalancerPoolEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerPoolEditResponseEnvelopeSuccess bool + +const ( + LoadBalancerPoolEditResponseEnvelopeSuccessTrue LoadBalancerPoolEditResponseEnvelopeSuccess = true +) + +type LoadBalancerPoolGetResponseEnvelope struct { + Errors []LoadBalancerPoolGetResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerPoolGetResponseEnvelopeMessages `json:"messages,required"` + Result LoadBalancingPool `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerPoolGetResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerPoolGetResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerPoolGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [LoadBalancerPoolGetResponseEnvelope] +type loadBalancerPoolGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPoolGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerPoolGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [LoadBalancerPoolGetResponseEnvelopeErrors] +type loadBalancerPoolGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPoolGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerPoolGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [LoadBalancerPoolGetResponseEnvelopeMessages] +type loadBalancerPoolGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerPoolGetResponseEnvelopeSuccess bool + +const ( + LoadBalancerPoolGetResponseEnvelopeSuccessTrue LoadBalancerPoolGetResponseEnvelopeSuccess = true +) + +type LoadBalancerPoolHealthResponseEnvelope struct { + Errors []LoadBalancerPoolHealthResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerPoolHealthResponseEnvelopeMessages `json:"messages,required"` + // A list of regions from which to run health checks. Null means every Cloudflare + // data center. + Result LoadBalancerPoolHealthResponse `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerPoolHealthResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerPoolHealthResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerPoolHealthResponseEnvelopeJSON contains the JSON metadata for the +// struct [LoadBalancerPoolHealthResponseEnvelope] +type loadBalancerPoolHealthResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolHealthResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolHealthResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolHealthResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPoolHealthResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerPoolHealthResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [LoadBalancerPoolHealthResponseEnvelopeErrors] +type loadBalancerPoolHealthResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolHealthResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolHealthResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolHealthResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPoolHealthResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerPoolHealthResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [LoadBalancerPoolHealthResponseEnvelopeMessages] +type loadBalancerPoolHealthResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolHealthResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolHealthResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerPoolHealthResponseEnvelopeSuccess bool + +const ( + LoadBalancerPoolHealthResponseEnvelopeSuccessTrue LoadBalancerPoolHealthResponseEnvelopeSuccess = true +) + +type LoadBalancerPoolPreviewParams struct { + // The expected HTTP response code or code range of the health check. This + // parameter is only valid for HTTP and HTTPS monitors. + ExpectedCodes param.Field[string] `json:"expected_codes,required"` + // Do not validate the certificate when monitor use HTTPS. This parameter is + // currently only valid for HTTP and HTTPS monitors. + AllowInsecure param.Field[bool] `json:"allow_insecure"` + // To be marked unhealthy the monitored origin must fail this healthcheck N + // consecutive times. + ConsecutiveDown param.Field[int64] `json:"consecutive_down"` + // To be marked healthy the monitored origin must pass this healthcheck N + // consecutive times. + ConsecutiveUp param.Field[int64] `json:"consecutive_up"` + // Object description. + Description param.Field[string] `json:"description"` + // A case-insensitive sub-string to look for in the response body. If this string + // is not found, the origin will be marked as unhealthy. This parameter is only + // valid for HTTP and HTTPS monitors. + ExpectedBody param.Field[string] `json:"expected_body"` + // Follow redirects if returned by the origin. This parameter is only valid for + // HTTP and HTTPS monitors. + FollowRedirects param.Field[bool] `json:"follow_redirects"` + // The HTTP request headers to send in the health check. It is recommended you set + // a Host header by default. The User-Agent header cannot be overridden. This + // parameter is only valid for HTTP and HTTPS monitors. + Header param.Field[interface{}] `json:"header"` + // The interval between each health check. Shorter intervals may improve failover + // time, but will increase load on the origins as we check from multiple locations. + Interval param.Field[int64] `json:"interval"` + // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS + // based checks and 'connection_established' for TCP based health checks. + Method param.Field[string] `json:"method"` + // The endpoint path you want to conduct a health check against. This parameter is + // only valid for HTTP and HTTPS monitors. + Path param.Field[string] `json:"path"` + // The port number to connect to for the health check. Required for TCP, UDP, and + // SMTP checks. HTTP and HTTPS checks should only define the port when using a + // non-standard port (HTTP: default 80, HTTPS: default 443). + Port param.Field[int64] `json:"port"` + // Assign this monitor to emulate the specified zone while probing. This parameter + // is only valid for HTTP and HTTPS monitors. + ProbeZone param.Field[string] `json:"probe_zone"` + // The number of retries to attempt in case of a timeout before marking the origin + // as unhealthy. Retries are attempted immediately. + Retries param.Field[int64] `json:"retries"` + // The timeout (in seconds) before marking the health check as failed. + Timeout param.Field[int64] `json:"timeout"` + // The protocol to use for the health check. Currently supported protocols are + // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. + Type param.Field[LoadBalancerPoolPreviewParamsType] `json:"type"` +} + +func (r LoadBalancerPoolPreviewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The protocol to use for the health check. Currently supported protocols are +// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. +type LoadBalancerPoolPreviewParamsType string + +const ( + LoadBalancerPoolPreviewParamsTypeHTTP LoadBalancerPoolPreviewParamsType = "http" + LoadBalancerPoolPreviewParamsTypeHTTPS LoadBalancerPoolPreviewParamsType = "https" + LoadBalancerPoolPreviewParamsTypeTcp LoadBalancerPoolPreviewParamsType = "tcp" + LoadBalancerPoolPreviewParamsTypeUdpIcmp LoadBalancerPoolPreviewParamsType = "udp_icmp" + LoadBalancerPoolPreviewParamsTypeIcmpPing LoadBalancerPoolPreviewParamsType = "icmp_ping" + LoadBalancerPoolPreviewParamsTypeSmtp LoadBalancerPoolPreviewParamsType = "smtp" +) + +type LoadBalancerPoolPreviewResponseEnvelope struct { + Errors []LoadBalancerPoolPreviewResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerPoolPreviewResponseEnvelopeMessages `json:"messages,required"` + Result LoadBalancerPoolPreviewResponse `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerPoolPreviewResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerPoolPreviewResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerPoolPreviewResponseEnvelopeJSON contains the JSON metadata for the +// struct [LoadBalancerPoolPreviewResponseEnvelope] +type loadBalancerPoolPreviewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolPreviewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolPreviewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolPreviewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPoolPreviewResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerPoolPreviewResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [LoadBalancerPoolPreviewResponseEnvelopeErrors] +type loadBalancerPoolPreviewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolPreviewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolPreviewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolPreviewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPoolPreviewResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerPoolPreviewResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [LoadBalancerPoolPreviewResponseEnvelopeMessages] +type loadBalancerPoolPreviewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolPreviewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolPreviewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerPoolPreviewResponseEnvelopeSuccess bool + +const ( + LoadBalancerPoolPreviewResponseEnvelopeSuccessTrue LoadBalancerPoolPreviewResponseEnvelopeSuccess = true +) + +type LoadBalancerPoolReferencesResponseEnvelope struct { + Errors []LoadBalancerPoolReferencesResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerPoolReferencesResponseEnvelopeMessages `json:"messages,required"` + // List of resources that reference a given pool. + Result []LoadBalancerPoolReferencesResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success LoadBalancerPoolReferencesResponseEnvelopeSuccess `json:"success,required"` + ResultInfo LoadBalancerPoolReferencesResponseEnvelopeResultInfo `json:"result_info"` + JSON loadBalancerPoolReferencesResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerPoolReferencesResponseEnvelopeJSON contains the JSON metadata for +// the struct [LoadBalancerPoolReferencesResponseEnvelope] +type loadBalancerPoolReferencesResponseEnvelopeJSON 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 *LoadBalancerPoolReferencesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolReferencesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolReferencesResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPoolReferencesResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerPoolReferencesResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [LoadBalancerPoolReferencesResponseEnvelopeErrors] +type loadBalancerPoolReferencesResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolReferencesResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolReferencesResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPoolReferencesResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPoolReferencesResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerPoolReferencesResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [LoadBalancerPoolReferencesResponseEnvelopeMessages] +type loadBalancerPoolReferencesResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolReferencesResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolReferencesResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerPoolReferencesResponseEnvelopeSuccess bool + +const ( + LoadBalancerPoolReferencesResponseEnvelopeSuccessTrue LoadBalancerPoolReferencesResponseEnvelopeSuccess = true +) + +type LoadBalancerPoolReferencesResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON loadBalancerPoolReferencesResponseEnvelopeResultInfoJSON `json:"-"` +} + +// loadBalancerPoolReferencesResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [LoadBalancerPoolReferencesResponseEnvelopeResultInfo] +type loadBalancerPoolReferencesResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPoolReferencesResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPoolReferencesResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/user/loadbalancerpool_test.go b/user/loadbalancerpool_test.go new file mode 100644 index 00000000000..04dba05d6f2 --- /dev/null +++ b/user/loadbalancerpool_test.go @@ -0,0 +1,440 @@ +// File generated from our OpenAPI spec by Stainless. + +package user_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/user" +) + +func TestLoadBalancerPoolNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.LoadBalancers.Pools.New(context.TODO(), user.LoadBalancerPoolNewParams{ + Name: cloudflare.F("primary-dc-1"), + Origins: cloudflare.F([]user.LoadBalancerPoolNewParamsOrigin{{ + Address: cloudflare.F("0.0.0.0"), + Enabled: cloudflare.F(true), + Header: cloudflare.F(user.LoadBalancerPoolNewParamsOriginsHeader{ + Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + }), + Name: cloudflare.F("app-server-1"), + VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), + Weight: cloudflare.F(0.600000), + }, { + Address: cloudflare.F("0.0.0.0"), + Enabled: cloudflare.F(true), + Header: cloudflare.F(user.LoadBalancerPoolNewParamsOriginsHeader{ + Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + }), + Name: cloudflare.F("app-server-1"), + VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), + Weight: cloudflare.F(0.600000), + }, { + Address: cloudflare.F("0.0.0.0"), + Enabled: cloudflare.F(true), + Header: cloudflare.F(user.LoadBalancerPoolNewParamsOriginsHeader{ + Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + }), + Name: cloudflare.F("app-server-1"), + VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), + Weight: cloudflare.F(0.600000), + }}), + CheckRegions: cloudflare.F([]user.LoadBalancerPoolNewParamsCheckRegion{user.LoadBalancerPoolNewParamsCheckRegionWeu, user.LoadBalancerPoolNewParamsCheckRegionEnam}), + Description: cloudflare.F("Primary data center - Provider XYZ"), + Enabled: cloudflare.F(false), + Latitude: cloudflare.F(0.000000), + LoadShedding: cloudflare.F(user.LoadBalancerPoolNewParamsLoadShedding{ + DefaultPercent: cloudflare.F(0.000000), + DefaultPolicy: cloudflare.F(user.LoadBalancerPoolNewParamsLoadSheddingDefaultPolicyRandom), + SessionPercent: cloudflare.F(0.000000), + SessionPolicy: cloudflare.F(user.LoadBalancerPoolNewParamsLoadSheddingSessionPolicyHash), + }), + Longitude: cloudflare.F(0.000000), + MinimumOrigins: cloudflare.F(int64(0)), + Monitor: cloudflare.F[any](map[string]interface{}{}), + NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), + NotificationFilter: cloudflare.F(user.LoadBalancerPoolNewParamsNotificationFilter{ + Origin: cloudflare.F(user.LoadBalancerPoolNewParamsNotificationFilterOrigin{ + Disable: cloudflare.F(true), + Healthy: cloudflare.F(true), + }), + Pool: cloudflare.F(user.LoadBalancerPoolNewParamsNotificationFilterPool{ + Disable: cloudflare.F(true), + Healthy: cloudflare.F(false), + }), + }), + OriginSteering: cloudflare.F(user.LoadBalancerPoolNewParamsOriginSteering{ + Policy: cloudflare.F(user.LoadBalancerPoolNewParamsOriginSteeringPolicyRandom), + }), + }) + 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 TestLoadBalancerPoolUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.LoadBalancers.Pools.Update( + context.TODO(), + "17b5962d775c646f3f9725cbc7a53df4", + user.LoadBalancerPoolUpdateParams{ + Name: cloudflare.F("primary-dc-1"), + Origins: cloudflare.F([]user.LoadBalancerPoolUpdateParamsOrigin{{ + Address: cloudflare.F("0.0.0.0"), + Enabled: cloudflare.F(true), + Header: cloudflare.F(user.LoadBalancerPoolUpdateParamsOriginsHeader{ + Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + }), + Name: cloudflare.F("app-server-1"), + VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), + Weight: cloudflare.F(0.600000), + }, { + Address: cloudflare.F("0.0.0.0"), + Enabled: cloudflare.F(true), + Header: cloudflare.F(user.LoadBalancerPoolUpdateParamsOriginsHeader{ + Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + }), + Name: cloudflare.F("app-server-1"), + VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), + Weight: cloudflare.F(0.600000), + }, { + Address: cloudflare.F("0.0.0.0"), + Enabled: cloudflare.F(true), + Header: cloudflare.F(user.LoadBalancerPoolUpdateParamsOriginsHeader{ + Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + }), + Name: cloudflare.F("app-server-1"), + VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), + Weight: cloudflare.F(0.600000), + }}), + CheckRegions: cloudflare.F([]user.LoadBalancerPoolUpdateParamsCheckRegion{user.LoadBalancerPoolUpdateParamsCheckRegionWeu, user.LoadBalancerPoolUpdateParamsCheckRegionEnam}), + Description: cloudflare.F("Primary data center - Provider XYZ"), + Enabled: cloudflare.F(false), + Latitude: cloudflare.F(0.000000), + LoadShedding: cloudflare.F(user.LoadBalancerPoolUpdateParamsLoadShedding{ + DefaultPercent: cloudflare.F(0.000000), + DefaultPolicy: cloudflare.F(user.LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyRandom), + SessionPercent: cloudflare.F(0.000000), + SessionPolicy: cloudflare.F(user.LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicyHash), + }), + Longitude: cloudflare.F(0.000000), + MinimumOrigins: cloudflare.F(int64(0)), + Monitor: cloudflare.F[any](map[string]interface{}{}), + NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), + NotificationFilter: cloudflare.F(user.LoadBalancerPoolUpdateParamsNotificationFilter{ + Origin: cloudflare.F(user.LoadBalancerPoolUpdateParamsNotificationFilterOrigin{ + Disable: cloudflare.F(true), + Healthy: cloudflare.F(true), + }), + Pool: cloudflare.F(user.LoadBalancerPoolUpdateParamsNotificationFilterPool{ + Disable: cloudflare.F(true), + Healthy: cloudflare.F(false), + }), + }), + OriginSteering: cloudflare.F(user.LoadBalancerPoolUpdateParamsOriginSteering{ + Policy: cloudflare.F(user.LoadBalancerPoolUpdateParamsOriginSteeringPolicyRandom), + }), + }, + ) + 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 TestLoadBalancerPoolListWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.LoadBalancers.Pools.List(context.TODO(), user.LoadBalancerPoolListParams{ + Monitor: cloudflare.F[any](map[string]interface{}{}), + }) + 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 TestLoadBalancerPoolDelete(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("user@example.com"), + ) + _, err := client.User.LoadBalancers.Pools.Delete(context.TODO(), "17b5962d775c646f3f9725cbc7a53df4") + 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 TestLoadBalancerPoolEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.LoadBalancers.Pools.Edit( + context.TODO(), + "17b5962d775c646f3f9725cbc7a53df4", + user.LoadBalancerPoolEditParams{ + CheckRegions: cloudflare.F([]user.LoadBalancerPoolEditParamsCheckRegion{user.LoadBalancerPoolEditParamsCheckRegionWeu, user.LoadBalancerPoolEditParamsCheckRegionEnam}), + Description: cloudflare.F("Primary data center - Provider XYZ"), + Enabled: cloudflare.F(false), + Latitude: cloudflare.F(0.000000), + LoadShedding: cloudflare.F(user.LoadBalancerPoolEditParamsLoadShedding{ + DefaultPercent: cloudflare.F(0.000000), + DefaultPolicy: cloudflare.F(user.LoadBalancerPoolEditParamsLoadSheddingDefaultPolicyRandom), + SessionPercent: cloudflare.F(0.000000), + SessionPolicy: cloudflare.F(user.LoadBalancerPoolEditParamsLoadSheddingSessionPolicyHash), + }), + Longitude: cloudflare.F(0.000000), + MinimumOrigins: cloudflare.F(int64(0)), + Monitor: cloudflare.F[any](map[string]interface{}{}), + Name: cloudflare.F("primary-dc-1"), + NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), + NotificationFilter: cloudflare.F(user.LoadBalancerPoolEditParamsNotificationFilter{ + Origin: cloudflare.F(user.LoadBalancerPoolEditParamsNotificationFilterOrigin{ + Disable: cloudflare.F(true), + Healthy: cloudflare.F(true), + }), + Pool: cloudflare.F(user.LoadBalancerPoolEditParamsNotificationFilterPool{ + Disable: cloudflare.F(true), + Healthy: cloudflare.F(false), + }), + }), + OriginSteering: cloudflare.F(user.LoadBalancerPoolEditParamsOriginSteering{ + Policy: cloudflare.F(user.LoadBalancerPoolEditParamsOriginSteeringPolicyRandom), + }), + Origins: cloudflare.F([]user.LoadBalancerPoolEditParamsOrigin{{ + Address: cloudflare.F("0.0.0.0"), + Enabled: cloudflare.F(true), + Header: cloudflare.F(user.LoadBalancerPoolEditParamsOriginsHeader{ + Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + }), + Name: cloudflare.F("app-server-1"), + VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), + Weight: cloudflare.F(0.600000), + }, { + Address: cloudflare.F("0.0.0.0"), + Enabled: cloudflare.F(true), + Header: cloudflare.F(user.LoadBalancerPoolEditParamsOriginsHeader{ + Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + }), + Name: cloudflare.F("app-server-1"), + VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), + Weight: cloudflare.F(0.600000), + }, { + Address: cloudflare.F("0.0.0.0"), + Enabled: cloudflare.F(true), + Header: cloudflare.F(user.LoadBalancerPoolEditParamsOriginsHeader{ + Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + }), + Name: cloudflare.F("app-server-1"), + VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), + Weight: cloudflare.F(0.600000), + }}), + }, + ) + 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 TestLoadBalancerPoolGet(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("user@example.com"), + ) + _, err := client.User.LoadBalancers.Pools.Get(context.TODO(), "17b5962d775c646f3f9725cbc7a53df4") + 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 TestLoadBalancerPoolHealth(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("user@example.com"), + ) + _, err := client.User.LoadBalancers.Pools.Health(context.TODO(), "17b5962d775c646f3f9725cbc7a53df4") + 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 TestLoadBalancerPoolPreviewWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.LoadBalancers.Pools.Preview( + context.TODO(), + "17b5962d775c646f3f9725cbc7a53df4", + user.LoadBalancerPoolPreviewParams{ + ExpectedCodes: cloudflare.F("2xx"), + AllowInsecure: cloudflare.F(true), + ConsecutiveDown: cloudflare.F(int64(0)), + ConsecutiveUp: cloudflare.F(int64(0)), + Description: cloudflare.F("Login page monitor"), + ExpectedBody: cloudflare.F("alive"), + FollowRedirects: cloudflare.F(true), + Header: cloudflare.F[any](map[string]interface{}{ + "Host": map[string]interface{}{ + "0": "example.com", + }, + "X-App-ID": map[string]interface{}{ + "0": "abc123", + }, + }), + Interval: cloudflare.F(int64(0)), + Method: cloudflare.F("GET"), + Path: cloudflare.F("/health"), + Port: cloudflare.F(int64(0)), + ProbeZone: cloudflare.F("example.com"), + Retries: cloudflare.F(int64(0)), + Timeout: cloudflare.F(int64(0)), + Type: cloudflare.F(user.LoadBalancerPoolPreviewParamsTypeHTTPS), + }, + ) + 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 TestLoadBalancerPoolReferences(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("user@example.com"), + ) + _, err := client.User.LoadBalancers.Pools.References(context.TODO(), "17b5962d775c646f3f9725cbc7a53df4") + 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/user/loadbalancerpreview.go b/user/loadbalancerpreview.go new file mode 100644 index 00000000000..ae7c82f91a7 --- /dev/null +++ b/user/loadbalancerpreview.go @@ -0,0 +1,179 @@ +// File generated from our OpenAPI spec by Stainless. + +package user + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// LoadBalancerPreviewService 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 [NewLoadBalancerPreviewService] +// method instead. +type LoadBalancerPreviewService struct { + Options []option.RequestOption +} + +// NewLoadBalancerPreviewService 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 NewLoadBalancerPreviewService(opts ...option.RequestOption) (r *LoadBalancerPreviewService) { + r = &LoadBalancerPreviewService{} + r.Options = opts + return +} + +// Get the result of a previous preview operation using the provided preview_id. +func (r *LoadBalancerPreviewService) Get(ctx context.Context, previewID interface{}, opts ...option.RequestOption) (res *LoadBalancingPreviewResult, err error) { + opts = append(r.Options[:], opts...) + var env LoadBalancerPreviewGetResponseEnvelope + path := fmt.Sprintf("user/load_balancers/preview/%v", previewID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type LoadBalancingPreviewResult map[string]LoadBalancingPreviewResultItem + +type LoadBalancingPreviewResultItem struct { + Healthy bool `json:"healthy"` + Origins []map[string]LoadBalancingPreviewResultOrigin `json:"origins"` + JSON loadBalancingPreviewResultItemJSON `json:"-"` +} + +// loadBalancingPreviewResultItemJSON contains the JSON metadata for the struct +// [LoadBalancingPreviewResultItem] +type loadBalancingPreviewResultItemJSON struct { + Healthy apijson.Field + Origins apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancingPreviewResultItem) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancingPreviewResultItemJSON) RawJSON() string { + return r.raw +} + +// The origin ipv4/ipv6 address or domain name mapped to it's health data. +type LoadBalancingPreviewResultOrigin struct { + FailureReason string `json:"failure_reason"` + Healthy bool `json:"healthy"` + ResponseCode float64 `json:"response_code"` + RTT string `json:"rtt"` + JSON loadBalancingPreviewResultOriginJSON `json:"-"` +} + +// loadBalancingPreviewResultOriginJSON contains the JSON metadata for the struct +// [LoadBalancingPreviewResultOrigin] +type loadBalancingPreviewResultOriginJSON struct { + FailureReason apijson.Field + Healthy apijson.Field + ResponseCode apijson.Field + RTT apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancingPreviewResultOrigin) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancingPreviewResultOriginJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPreviewGetResponseEnvelope struct { + Errors []LoadBalancerPreviewGetResponseEnvelopeErrors `json:"errors,required"` + Messages []LoadBalancerPreviewGetResponseEnvelopeMessages `json:"messages,required"` + // Resulting health data from a preview operation. + Result LoadBalancingPreviewResult `json:"result,required"` + // Whether the API call was successful + Success LoadBalancerPreviewGetResponseEnvelopeSuccess `json:"success,required"` + JSON loadBalancerPreviewGetResponseEnvelopeJSON `json:"-"` +} + +// loadBalancerPreviewGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [LoadBalancerPreviewGetResponseEnvelope] +type loadBalancerPreviewGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPreviewGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPreviewGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPreviewGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPreviewGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// loadBalancerPreviewGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [LoadBalancerPreviewGetResponseEnvelopeErrors] +type loadBalancerPreviewGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPreviewGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPreviewGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type LoadBalancerPreviewGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON loadBalancerPreviewGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// loadBalancerPreviewGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [LoadBalancerPreviewGetResponseEnvelopeMessages] +type loadBalancerPreviewGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadBalancerPreviewGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadBalancerPreviewGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type LoadBalancerPreviewGetResponseEnvelopeSuccess bool + +const ( + LoadBalancerPreviewGetResponseEnvelopeSuccessTrue LoadBalancerPreviewGetResponseEnvelopeSuccess = true +) diff --git a/loadbalancerpreview_test.go b/user/loadbalancerpreview_test.go similarity index 78% rename from loadbalancerpreview_test.go rename to user/loadbalancerpreview_test.go index dc3f9ace203..d29d0010fe3 100644 --- a/loadbalancerpreview_test.go +++ b/user/loadbalancerpreview_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package user_test import ( "context" @@ -27,13 +27,7 @@ func TestLoadBalancerPreviewGet(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.LoadBalancers.Previews.Get( - context.TODO(), - "p1aba936b94213e5b8dca0c0dbf1f9cc", - cloudflare.LoadBalancerPreviewGetParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - }, - ) + _, err := client.User.LoadBalancers.Preview.Get(context.TODO(), "f1aba936b94213e5b8dca0c0dbf1f9cc") if err != nil { var apierr *cloudflare.Error if errors.As(err, &apierr) { diff --git a/user/organization.go b/user/organization.go new file mode 100644 index 00000000000..d1804e20e61 --- /dev/null +++ b/user/organization.go @@ -0,0 +1,300 @@ +// File generated from our OpenAPI spec by Stainless. + +package user + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// OrganizationService 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 [NewOrganizationService] method +// instead. +type OrganizationService struct { + Options []option.RequestOption +} + +// NewOrganizationService 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 NewOrganizationService(opts ...option.RequestOption) (r *OrganizationService) { + r = &OrganizationService{} + r.Options = opts + return +} + +// Lists organizations the user is associated with. +func (r *OrganizationService) List(ctx context.Context, query OrganizationListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[IamOrganization], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "user/organizations" + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists organizations the user is associated with. +func (r *OrganizationService) ListAutoPaging(ctx context.Context, query OrganizationListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[IamOrganization] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, query, opts...)) +} + +// Removes association to an organization. +func (r *OrganizationService) Delete(ctx context.Context, organizationID string, opts ...option.RequestOption) (res *OrganizationDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("user/organizations/%s", organizationID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return +} + +// Gets a specific organization the user is associated with. +func (r *OrganizationService) Get(ctx context.Context, organizationID string, opts ...option.RequestOption) (res *OrganizationGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env OrganizationGetResponseEnvelope + path := fmt.Sprintf("user/organizations/%s", organizationID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type IamOrganization struct { + // Identifier + ID string `json:"id"` + // Organization name. + Name string `json:"name"` + // Access permissions for this User. + Permissions []string `json:"permissions"` + // List of roles that a user has within an organization. + Roles []string `json:"roles"` + // Whether the user is a member of the organization or has an inivitation pending. + Status IamOrganizationStatus `json:"status"` + JSON iamOrganizationJSON `json:"-"` +} + +// iamOrganizationJSON contains the JSON metadata for the struct [IamOrganization] +type iamOrganizationJSON struct { + ID apijson.Field + Name apijson.Field + Permissions apijson.Field + Roles apijson.Field + Status apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IamOrganization) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r iamOrganizationJSON) RawJSON() string { + return r.raw +} + +// Whether the user is a member of the organization or has an inivitation pending. +type IamOrganizationStatus string + +const ( + IamOrganizationStatusMember IamOrganizationStatus = "member" + IamOrganizationStatusInvited IamOrganizationStatus = "invited" +) + +type OrganizationDeleteResponse struct { + // Identifier + ID string `json:"id"` + JSON organizationDeleteResponseJSON `json:"-"` +} + +// organizationDeleteResponseJSON contains the JSON metadata for the struct +// [OrganizationDeleteResponse] +type organizationDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OrganizationDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r organizationDeleteResponseJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [user.OrganizationGetResponseUnknown] or +// [shared.UnionString]. +type OrganizationGetResponse interface { + ImplementsUserOrganizationGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*OrganizationGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type OrganizationListParams struct { + // Direction to order organizations. + Direction param.Field[OrganizationListParamsDirection] `query:"direction"` + // Whether to match all search requirements or at least one (any). + Match param.Field[OrganizationListParamsMatch] `query:"match"` + // Organization name. + Name param.Field[string] `query:"name"` + // Field to order organizations by. + Order param.Field[OrganizationListParamsOrder] `query:"order"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // Number of organizations per page. + PerPage param.Field[float64] `query:"per_page"` + // Whether the user is a member of the organization or has an inivitation pending. + Status param.Field[OrganizationListParamsStatus] `query:"status"` +} + +// URLQuery serializes [OrganizationListParams]'s query parameters as `url.Values`. +func (r OrganizationListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Direction to order organizations. +type OrganizationListParamsDirection string + +const ( + OrganizationListParamsDirectionAsc OrganizationListParamsDirection = "asc" + OrganizationListParamsDirectionDesc OrganizationListParamsDirection = "desc" +) + +// Whether to match all search requirements or at least one (any). +type OrganizationListParamsMatch string + +const ( + OrganizationListParamsMatchAny OrganizationListParamsMatch = "any" + OrganizationListParamsMatchAll OrganizationListParamsMatch = "all" +) + +// Field to order organizations by. +type OrganizationListParamsOrder string + +const ( + OrganizationListParamsOrderID OrganizationListParamsOrder = "id" + OrganizationListParamsOrderName OrganizationListParamsOrder = "name" + OrganizationListParamsOrderStatus OrganizationListParamsOrder = "status" +) + +// Whether the user is a member of the organization or has an inivitation pending. +type OrganizationListParamsStatus string + +const ( + OrganizationListParamsStatusMember OrganizationListParamsStatus = "member" + OrganizationListParamsStatusInvited OrganizationListParamsStatus = "invited" +) + +type OrganizationGetResponseEnvelope struct { + Errors []OrganizationGetResponseEnvelopeErrors `json:"errors,required"` + Messages []OrganizationGetResponseEnvelopeMessages `json:"messages,required"` + Result OrganizationGetResponse `json:"result,required"` + // Whether the API call was successful + Success OrganizationGetResponseEnvelopeSuccess `json:"success,required"` + JSON organizationGetResponseEnvelopeJSON `json:"-"` +} + +// organizationGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [OrganizationGetResponseEnvelope] +type organizationGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OrganizationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r organizationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type OrganizationGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON organizationGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// organizationGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [OrganizationGetResponseEnvelopeErrors] +type organizationGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OrganizationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r organizationGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type OrganizationGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON organizationGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// organizationGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [OrganizationGetResponseEnvelopeMessages] +type organizationGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OrganizationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r organizationGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type OrganizationGetResponseEnvelopeSuccess bool + +const ( + OrganizationGetResponseEnvelopeSuccessTrue OrganizationGetResponseEnvelopeSuccess = true +) diff --git a/user/organization_test.go b/user/organization_test.go new file mode 100644 index 00000000000..0cabd791f52 --- /dev/null +++ b/user/organization_test.go @@ -0,0 +1,95 @@ +// File generated from our OpenAPI spec by Stainless. + +package user_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/user" +) + +func TestOrganizationListWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.Organizations.List(context.TODO(), user.OrganizationListParams{ + Direction: cloudflare.F(user.OrganizationListParamsDirectionDesc), + Match: cloudflare.F(user.OrganizationListParamsMatchAny), + Name: cloudflare.F("Cloudflare, Inc."), + Order: cloudflare.F(user.OrganizationListParamsOrderStatus), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(5.000000), + Status: cloudflare.F(user.OrganizationListParamsStatusMember), + }) + 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 TestOrganizationDelete(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("user@example.com"), + ) + _, err := client.User.Organizations.Delete(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()) + } +} + +func TestOrganizationGet(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("user@example.com"), + ) + _, err := client.User.Organizations.Get(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/user/subscription.go b/user/subscription.go new file mode 100644 index 00000000000..d37455540ea --- /dev/null +++ b/user/subscription.go @@ -0,0 +1,773 @@ +// File generated from our OpenAPI spec by Stainless. + +package user + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// SubscriptionService 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 [NewSubscriptionService] method +// instead. +type SubscriptionService struct { + Options []option.RequestOption +} + +// NewSubscriptionService 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 NewSubscriptionService(opts ...option.RequestOption) (r *SubscriptionService) { + r = &SubscriptionService{} + r.Options = opts + return +} + +// Updates a user's subscriptions. +func (r *SubscriptionService) Update(ctx context.Context, identifier string, body SubscriptionUpdateParams, opts ...option.RequestOption) (res *SubscriptionUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env SubscriptionUpdateResponseEnvelope + path := fmt.Sprintf("user/subscriptions/%s", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a user's subscription. +func (r *SubscriptionService) Delete(ctx context.Context, identifier string, opts ...option.RequestOption) (res *SubscriptionDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("user/subscriptions/%s", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + return +} + +// Updates zone subscriptions, either plan or add-ons. +func (r *SubscriptionService) Edit(ctx context.Context, identifier string, body SubscriptionEditParams, opts ...option.RequestOption) (res *SubscriptionEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env SubscriptionEditResponseEnvelope + path := fmt.Sprintf("zones/%s/subscription", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists all of a user's subscriptions. +func (r *SubscriptionService) Get(ctx context.Context, opts ...option.RequestOption) (res *[]SubscriptionGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env SubscriptionGetResponseEnvelope + path := "user/subscriptions" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [user.SubscriptionUpdateResponseUnknown] or +// [shared.UnionString]. +type SubscriptionUpdateResponse interface { + ImplementsUserSubscriptionUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*SubscriptionUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type SubscriptionDeleteResponse struct { + // Subscription identifier tag. + SubscriptionID string `json:"subscription_id"` + JSON subscriptionDeleteResponseJSON `json:"-"` +} + +// subscriptionDeleteResponseJSON contains the JSON metadata for the struct +// [SubscriptionDeleteResponse] +type subscriptionDeleteResponseJSON struct { + SubscriptionID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionDeleteResponseJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [user.SubscriptionEditResponseUnknown] or +// [shared.UnionString]. +type SubscriptionEditResponse interface { + ImplementsUserSubscriptionEditResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*SubscriptionEditResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type SubscriptionGetResponse struct { + // Subscription identifier tag. + ID string `json:"id"` + App SubscriptionGetResponseApp `json:"app"` + // The list of add-ons subscribed to. + ComponentValues []SubscriptionGetResponseComponentValue `json:"component_values"` + // The monetary unit in which pricing information is displayed. + Currency string `json:"currency"` + // The end of the current period and also when the next billing is due. + CurrentPeriodEnd time.Time `json:"current_period_end" format:"date-time"` + // When the current billing period started. May match initial_period_start if this + // is the first period. + CurrentPeriodStart time.Time `json:"current_period_start" format:"date-time"` + // How often the subscription is renewed automatically. + Frequency SubscriptionGetResponseFrequency `json:"frequency"` + // The price of the subscription that will be billed, in US dollars. + Price float64 `json:"price"` + // The rate plan applied to the subscription. + RatePlan SubscriptionGetResponseRatePlan `json:"rate_plan"` + // The state that the subscription is in. + State SubscriptionGetResponseState `json:"state"` + // A simple zone object. May have null properties if not a zone subscription. + Zone SubscriptionGetResponseZone `json:"zone"` + JSON subscriptionGetResponseJSON `json:"-"` +} + +// subscriptionGetResponseJSON contains the JSON metadata for the struct +// [SubscriptionGetResponse] +type subscriptionGetResponseJSON struct { + ID apijson.Field + App apijson.Field + ComponentValues apijson.Field + Currency apijson.Field + CurrentPeriodEnd apijson.Field + CurrentPeriodStart apijson.Field + Frequency apijson.Field + Price apijson.Field + RatePlan apijson.Field + State apijson.Field + Zone apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionGetResponseJSON) RawJSON() string { + return r.raw +} + +type SubscriptionGetResponseApp struct { + // app install id. + InstallID string `json:"install_id"` + JSON subscriptionGetResponseAppJSON `json:"-"` +} + +// subscriptionGetResponseAppJSON contains the JSON metadata for the struct +// [SubscriptionGetResponseApp] +type subscriptionGetResponseAppJSON struct { + InstallID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionGetResponseApp) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionGetResponseAppJSON) RawJSON() string { + return r.raw +} + +// A component value for a subscription. +type SubscriptionGetResponseComponentValue struct { + // The default amount assigned. + Default float64 `json:"default"` + // The name of the component value. + Name string `json:"name"` + // The unit price for the component value. + Price float64 `json:"price"` + // The amount of the component value assigned. + Value float64 `json:"value"` + JSON subscriptionGetResponseComponentValueJSON `json:"-"` +} + +// subscriptionGetResponseComponentValueJSON contains the JSON metadata for the +// struct [SubscriptionGetResponseComponentValue] +type subscriptionGetResponseComponentValueJSON struct { + Default apijson.Field + Name apijson.Field + Price apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionGetResponseComponentValue) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionGetResponseComponentValueJSON) RawJSON() string { + return r.raw +} + +// How often the subscription is renewed automatically. +type SubscriptionGetResponseFrequency string + +const ( + SubscriptionGetResponseFrequencyWeekly SubscriptionGetResponseFrequency = "weekly" + SubscriptionGetResponseFrequencyMonthly SubscriptionGetResponseFrequency = "monthly" + SubscriptionGetResponseFrequencyQuarterly SubscriptionGetResponseFrequency = "quarterly" + SubscriptionGetResponseFrequencyYearly SubscriptionGetResponseFrequency = "yearly" +) + +// The rate plan applied to the subscription. +type SubscriptionGetResponseRatePlan struct { + // The ID of the rate plan. + ID interface{} `json:"id"` + // The currency applied to the rate plan subscription. + Currency string `json:"currency"` + // Whether this rate plan is managed externally from Cloudflare. + ExternallyManaged bool `json:"externally_managed"` + // Whether a rate plan is enterprise-based (or newly adopted term contract). + IsContract bool `json:"is_contract"` + // The full name of the rate plan. + PublicName string `json:"public_name"` + // The scope that this rate plan applies to. + Scope string `json:"scope"` + // The list of sets this rate plan applies to. + Sets []string `json:"sets"` + JSON subscriptionGetResponseRatePlanJSON `json:"-"` +} + +// subscriptionGetResponseRatePlanJSON contains the JSON metadata for the struct +// [SubscriptionGetResponseRatePlan] +type subscriptionGetResponseRatePlanJSON struct { + ID apijson.Field + Currency apijson.Field + ExternallyManaged apijson.Field + IsContract apijson.Field + PublicName apijson.Field + Scope apijson.Field + Sets apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionGetResponseRatePlan) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionGetResponseRatePlanJSON) RawJSON() string { + return r.raw +} + +// The state that the subscription is in. +type SubscriptionGetResponseState string + +const ( + SubscriptionGetResponseStateTrial SubscriptionGetResponseState = "Trial" + SubscriptionGetResponseStateProvisioned SubscriptionGetResponseState = "Provisioned" + SubscriptionGetResponseStatePaid SubscriptionGetResponseState = "Paid" + SubscriptionGetResponseStateAwaitingPayment SubscriptionGetResponseState = "AwaitingPayment" + SubscriptionGetResponseStateCancelled SubscriptionGetResponseState = "Cancelled" + SubscriptionGetResponseStateFailed SubscriptionGetResponseState = "Failed" + SubscriptionGetResponseStateExpired SubscriptionGetResponseState = "Expired" +) + +// A simple zone object. May have null properties if not a zone subscription. +type SubscriptionGetResponseZone struct { + // Identifier + ID string `json:"id"` + // The domain name + Name string `json:"name"` + JSON subscriptionGetResponseZoneJSON `json:"-"` +} + +// subscriptionGetResponseZoneJSON contains the JSON metadata for the struct +// [SubscriptionGetResponseZone] +type subscriptionGetResponseZoneJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionGetResponseZone) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionGetResponseZoneJSON) RawJSON() string { + return r.raw +} + +type SubscriptionUpdateParams struct { + App param.Field[SubscriptionUpdateParamsApp] `json:"app"` + // The list of add-ons subscribed to. + ComponentValues param.Field[[]SubscriptionUpdateParamsComponentValue] `json:"component_values"` + // How often the subscription is renewed automatically. + Frequency param.Field[SubscriptionUpdateParamsFrequency] `json:"frequency"` + // The rate plan applied to the subscription. + RatePlan param.Field[SubscriptionUpdateParamsRatePlan] `json:"rate_plan"` + // A simple zone object. May have null properties if not a zone subscription. + Zone param.Field[SubscriptionUpdateParamsZone] `json:"zone"` +} + +func (r SubscriptionUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SubscriptionUpdateParamsApp struct { + // app install id. + InstallID param.Field[string] `json:"install_id"` +} + +func (r SubscriptionUpdateParamsApp) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A component value for a subscription. +type SubscriptionUpdateParamsComponentValue struct { + // The default amount assigned. + Default param.Field[float64] `json:"default"` + // The name of the component value. + Name param.Field[string] `json:"name"` + // The unit price for the component value. + Price param.Field[float64] `json:"price"` + // The amount of the component value assigned. + Value param.Field[float64] `json:"value"` +} + +func (r SubscriptionUpdateParamsComponentValue) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// How often the subscription is renewed automatically. +type SubscriptionUpdateParamsFrequency string + +const ( + SubscriptionUpdateParamsFrequencyWeekly SubscriptionUpdateParamsFrequency = "weekly" + SubscriptionUpdateParamsFrequencyMonthly SubscriptionUpdateParamsFrequency = "monthly" + SubscriptionUpdateParamsFrequencyQuarterly SubscriptionUpdateParamsFrequency = "quarterly" + SubscriptionUpdateParamsFrequencyYearly SubscriptionUpdateParamsFrequency = "yearly" +) + +// The rate plan applied to the subscription. +type SubscriptionUpdateParamsRatePlan struct { + // The ID of the rate plan. + ID param.Field[interface{}] `json:"id"` + // The currency applied to the rate plan subscription. + Currency param.Field[string] `json:"currency"` + // Whether this rate plan is managed externally from Cloudflare. + ExternallyManaged param.Field[bool] `json:"externally_managed"` + // Whether a rate plan is enterprise-based (or newly adopted term contract). + IsContract param.Field[bool] `json:"is_contract"` + // The full name of the rate plan. + PublicName param.Field[string] `json:"public_name"` + // The scope that this rate plan applies to. + Scope param.Field[string] `json:"scope"` + // The list of sets this rate plan applies to. + Sets param.Field[[]string] `json:"sets"` +} + +func (r SubscriptionUpdateParamsRatePlan) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A simple zone object. May have null properties if not a zone subscription. +type SubscriptionUpdateParamsZone struct { +} + +func (r SubscriptionUpdateParamsZone) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SubscriptionUpdateResponseEnvelope struct { + Errors []SubscriptionUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []SubscriptionUpdateResponseEnvelopeMessages `json:"messages,required"` + Result SubscriptionUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success SubscriptionUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON subscriptionUpdateResponseEnvelopeJSON `json:"-"` +} + +// subscriptionUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [SubscriptionUpdateResponseEnvelope] +type subscriptionUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SubscriptionUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// subscriptionUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SubscriptionUpdateResponseEnvelopeErrors] +type subscriptionUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SubscriptionUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// subscriptionUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [SubscriptionUpdateResponseEnvelopeMessages] +type subscriptionUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SubscriptionUpdateResponseEnvelopeSuccess bool + +const ( + SubscriptionUpdateResponseEnvelopeSuccessTrue SubscriptionUpdateResponseEnvelopeSuccess = true +) + +type SubscriptionEditParams struct { + App param.Field[SubscriptionEditParamsApp] `json:"app"` + // The list of add-ons subscribed to. + ComponentValues param.Field[[]SubscriptionEditParamsComponentValue] `json:"component_values"` + // How often the subscription is renewed automatically. + Frequency param.Field[SubscriptionEditParamsFrequency] `json:"frequency"` + // The rate plan applied to the subscription. + RatePlan param.Field[SubscriptionEditParamsRatePlan] `json:"rate_plan"` + // A simple zone object. May have null properties if not a zone subscription. + Zone param.Field[SubscriptionEditParamsZone] `json:"zone"` +} + +func (r SubscriptionEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SubscriptionEditParamsApp struct { + // app install id. + InstallID param.Field[string] `json:"install_id"` +} + +func (r SubscriptionEditParamsApp) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A component value for a subscription. +type SubscriptionEditParamsComponentValue struct { + // The default amount assigned. + Default param.Field[float64] `json:"default"` + // The name of the component value. + Name param.Field[string] `json:"name"` + // The unit price for the component value. + Price param.Field[float64] `json:"price"` + // The amount of the component value assigned. + Value param.Field[float64] `json:"value"` +} + +func (r SubscriptionEditParamsComponentValue) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// How often the subscription is renewed automatically. +type SubscriptionEditParamsFrequency string + +const ( + SubscriptionEditParamsFrequencyWeekly SubscriptionEditParamsFrequency = "weekly" + SubscriptionEditParamsFrequencyMonthly SubscriptionEditParamsFrequency = "monthly" + SubscriptionEditParamsFrequencyQuarterly SubscriptionEditParamsFrequency = "quarterly" + SubscriptionEditParamsFrequencyYearly SubscriptionEditParamsFrequency = "yearly" +) + +// The rate plan applied to the subscription. +type SubscriptionEditParamsRatePlan struct { + // The ID of the rate plan. + ID param.Field[interface{}] `json:"id"` + // The currency applied to the rate plan subscription. + Currency param.Field[string] `json:"currency"` + // Whether this rate plan is managed externally from Cloudflare. + ExternallyManaged param.Field[bool] `json:"externally_managed"` + // Whether a rate plan is enterprise-based (or newly adopted term contract). + IsContract param.Field[bool] `json:"is_contract"` + // The full name of the rate plan. + PublicName param.Field[string] `json:"public_name"` + // The scope that this rate plan applies to. + Scope param.Field[string] `json:"scope"` + // The list of sets this rate plan applies to. + Sets param.Field[[]string] `json:"sets"` +} + +func (r SubscriptionEditParamsRatePlan) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A simple zone object. May have null properties if not a zone subscription. +type SubscriptionEditParamsZone struct { +} + +func (r SubscriptionEditParamsZone) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SubscriptionEditResponseEnvelope struct { + Errors []SubscriptionEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SubscriptionEditResponseEnvelopeMessages `json:"messages,required"` + Result SubscriptionEditResponse `json:"result,required"` + // Whether the API call was successful + Success SubscriptionEditResponseEnvelopeSuccess `json:"success,required"` + JSON subscriptionEditResponseEnvelopeJSON `json:"-"` +} + +// subscriptionEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SubscriptionEditResponseEnvelope] +type subscriptionEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SubscriptionEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// subscriptionEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SubscriptionEditResponseEnvelopeErrors] +type subscriptionEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SubscriptionEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// subscriptionEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SubscriptionEditResponseEnvelopeMessages] +type subscriptionEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SubscriptionEditResponseEnvelopeSuccess bool + +const ( + SubscriptionEditResponseEnvelopeSuccessTrue SubscriptionEditResponseEnvelopeSuccess = true +) + +type SubscriptionGetResponseEnvelope struct { + Errors []SubscriptionGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SubscriptionGetResponseEnvelopeMessages `json:"messages,required"` + Result []SubscriptionGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success SubscriptionGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo SubscriptionGetResponseEnvelopeResultInfo `json:"result_info"` + JSON subscriptionGetResponseEnvelopeJSON `json:"-"` +} + +// subscriptionGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SubscriptionGetResponseEnvelope] +type subscriptionGetResponseEnvelopeJSON 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 *SubscriptionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SubscriptionGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// subscriptionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SubscriptionGetResponseEnvelopeErrors] +type subscriptionGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SubscriptionGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// subscriptionGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SubscriptionGetResponseEnvelopeMessages] +type subscriptionGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SubscriptionGetResponseEnvelopeSuccess bool + +const ( + SubscriptionGetResponseEnvelopeSuccessTrue SubscriptionGetResponseEnvelopeSuccess = true +) + +type SubscriptionGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON subscriptionGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// subscriptionGetResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [SubscriptionGetResponseEnvelopeResultInfo] +type subscriptionGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/user/subscription_test.go b/user/subscription_test.go new file mode 100644 index 00000000000..d64d5f32b64 --- /dev/null +++ b/user/subscription_test.go @@ -0,0 +1,181 @@ +// File generated from our OpenAPI spec by Stainless. + +package user_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/user" +) + +func TestSubscriptionUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.Subscriptions.Update( + context.TODO(), + "506e3185e9c882d175a2d0cb0093d9f2", + user.SubscriptionUpdateParams{ + App: cloudflare.F(user.SubscriptionUpdateParamsApp{ + InstallID: cloudflare.F("string"), + }), + ComponentValues: cloudflare.F([]user.SubscriptionUpdateParamsComponentValue{{ + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }}), + Frequency: cloudflare.F(user.SubscriptionUpdateParamsFrequencyMonthly), + RatePlan: cloudflare.F(user.SubscriptionUpdateParamsRatePlan{ + Currency: cloudflare.F("USD"), + ExternallyManaged: cloudflare.F(false), + ID: cloudflare.F[any]("free"), + IsContract: cloudflare.F(false), + PublicName: cloudflare.F("Business Plan"), + Scope: cloudflare.F("zone"), + Sets: cloudflare.F([]string{"string", "string", "string"}), + }), + Zone: cloudflare.F(user.SubscriptionUpdateParamsZone{}), + }, + ) + 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 TestSubscriptionDelete(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("user@example.com"), + ) + _, err := client.User.Subscriptions.Delete(context.TODO(), "506e3185e9c882d175a2d0cb0093d9f2") + 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 TestSubscriptionEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.Subscriptions.Edit( + context.TODO(), + "506e3185e9c882d175a2d0cb0093d9f2", + user.SubscriptionEditParams{ + App: cloudflare.F(user.SubscriptionEditParamsApp{ + InstallID: cloudflare.F("string"), + }), + ComponentValues: cloudflare.F([]user.SubscriptionEditParamsComponentValue{{ + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }}), + Frequency: cloudflare.F(user.SubscriptionEditParamsFrequencyMonthly), + RatePlan: cloudflare.F(user.SubscriptionEditParamsRatePlan{ + Currency: cloudflare.F("USD"), + ExternallyManaged: cloudflare.F(false), + ID: cloudflare.F[any]("free"), + IsContract: cloudflare.F(false), + PublicName: cloudflare.F("Business Plan"), + Scope: cloudflare.F("zone"), + Sets: cloudflare.F([]string{"string", "string", "string"}), + }), + Zone: cloudflare.F(user.SubscriptionEditParamsZone{}), + }, + ) + 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 TestSubscriptionGet(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("user@example.com"), + ) + _, err := client.User.Subscriptions.Get(context.TODO()) + 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/user/token.go b/user/token.go new file mode 100644 index 00000000000..8c3ff98fdf1 --- /dev/null +++ b/user/token.go @@ -0,0 +1,825 @@ +// File generated from our OpenAPI spec by Stainless. + +package user + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// TokenService 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 [NewTokenService] method instead. +type TokenService struct { + Options []option.RequestOption + PermissionGroups *TokenPermissionGroupService + Value *TokenValueService +} + +// NewTokenService 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 NewTokenService(opts ...option.RequestOption) (r *TokenService) { + r = &TokenService{} + r.Options = opts + r.PermissionGroups = NewTokenPermissionGroupService(opts...) + r.Value = NewTokenValueService(opts...) + return +} + +// Create a new access token. +func (r *TokenService) New(ctx context.Context, body TokenNewParams, opts ...option.RequestOption) (res *TokenNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env TokenNewResponseEnvelope + path := "user/tokens" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update an existing token. +func (r *TokenService) Update(ctx context.Context, tokenID interface{}, body TokenUpdateParams, opts ...option.RequestOption) (res *TokenUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env TokenUpdateResponseEnvelope + path := fmt.Sprintf("user/tokens/%v", tokenID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List all access tokens you created. +func (r *TokenService) List(ctx context.Context, query TokenListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[TokenListResponse], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := "user/tokens" + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// List all access tokens you created. +func (r *TokenService) ListAutoPaging(ctx context.Context, query TokenListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[TokenListResponse] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, query, opts...)) +} + +// Destroy a token. +func (r *TokenService) Delete(ctx context.Context, tokenID interface{}, opts ...option.RequestOption) (res *TokenDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env TokenDeleteResponseEnvelope + path := fmt.Sprintf("user/tokens/%v", tokenID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get information about a specific token. +func (r *TokenService) Get(ctx context.Context, tokenID interface{}, opts ...option.RequestOption) (res *TokenGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env TokenGetResponseEnvelope + path := fmt.Sprintf("user/tokens/%v", tokenID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Test whether a token works. +func (r *TokenService) Verify(ctx context.Context, opts ...option.RequestOption) (res *TokenVerifyResponse, err error) { + opts = append(r.Options[:], opts...) + var env TokenVerifyResponseEnvelope + path := "user/tokens/verify" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TokenNewResponse struct { + // The token value. + Value IamValue `json:"value"` + JSON tokenNewResponseJSON `json:"-"` +} + +// tokenNewResponseJSON contains the JSON metadata for the struct +// [TokenNewResponse] +type tokenNewResponseJSON struct { + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenNewResponseJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [user.TokenUpdateResponseUnknown] or [shared.UnionString]. +type TokenUpdateResponse interface { + ImplementsUserTokenUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*TokenUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type TokenListResponse = interface{} + +type TokenDeleteResponse struct { + // Identifier + ID string `json:"id,required"` + JSON tokenDeleteResponseJSON `json:"-"` +} + +// tokenDeleteResponseJSON contains the JSON metadata for the struct +// [TokenDeleteResponse] +type tokenDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenDeleteResponseJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [user.TokenGetResponseUnknown] or [shared.UnionString]. +type TokenGetResponse interface { + ImplementsUserTokenGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*TokenGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type TokenVerifyResponse struct { + // Token identifier tag. + ID string `json:"id,required"` + // Status of the token. + Status TokenVerifyResponseStatus `json:"status,required"` + // The expiration time on or after which the JWT MUST NOT be accepted for + // processing. + ExpiresOn time.Time `json:"expires_on" format:"date-time"` + // The time before which the token MUST NOT be accepted for processing. + NotBefore time.Time `json:"not_before" format:"date-time"` + JSON tokenVerifyResponseJSON `json:"-"` +} + +// tokenVerifyResponseJSON contains the JSON metadata for the struct +// [TokenVerifyResponse] +type tokenVerifyResponseJSON struct { + ID apijson.Field + Status apijson.Field + ExpiresOn apijson.Field + NotBefore apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenVerifyResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenVerifyResponseJSON) RawJSON() string { + return r.raw +} + +// Status of the token. +type TokenVerifyResponseStatus string + +const ( + TokenVerifyResponseStatusActive TokenVerifyResponseStatus = "active" + TokenVerifyResponseStatusDisabled TokenVerifyResponseStatus = "disabled" + TokenVerifyResponseStatusExpired TokenVerifyResponseStatus = "expired" +) + +type TokenNewParams struct { + // Token name. + Name param.Field[string] `json:"name,required"` + // List of access policies assigned to the token. + Policies param.Field[[]TokenNewParamsPolicy] `json:"policies,required"` + Condition param.Field[TokenNewParamsCondition] `json:"condition"` + // The expiration time on or after which the JWT MUST NOT be accepted for + // processing. + ExpiresOn param.Field[time.Time] `json:"expires_on" format:"date-time"` + // The time before which the token MUST NOT be accepted for processing. + NotBefore param.Field[time.Time] `json:"not_before" format:"date-time"` +} + +func (r TokenNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type TokenNewParamsPolicy struct { + // Allow or deny operations against the resources. + Effect param.Field[TokenNewParamsPoliciesEffect] `json:"effect,required"` + // A set of permission groups that are specified to the policy. + PermissionGroups param.Field[[]TokenNewParamsPoliciesPermissionGroup] `json:"permission_groups,required"` + // A list of resource names that the policy applies to. + Resources param.Field[interface{}] `json:"resources,required"` +} + +func (r TokenNewParamsPolicy) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Allow or deny operations against the resources. +type TokenNewParamsPoliciesEffect string + +const ( + TokenNewParamsPoliciesEffectAllow TokenNewParamsPoliciesEffect = "allow" + TokenNewParamsPoliciesEffectDeny TokenNewParamsPoliciesEffect = "deny" +) + +// A named group of permissions that map to a group of operations against +// resources. +type TokenNewParamsPoliciesPermissionGroup struct { +} + +func (r TokenNewParamsPoliciesPermissionGroup) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type TokenNewParamsCondition struct { + // Client IP restrictions. + RequestIP param.Field[TokenNewParamsConditionRequestIP] `json:"request_ip"` +} + +func (r TokenNewParamsCondition) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Client IP restrictions. +type TokenNewParamsConditionRequestIP struct { + // List of IPv4/IPv6 CIDR addresses. + In param.Field[[]string] `json:"in"` + // List of IPv4/IPv6 CIDR addresses. + NotIn param.Field[[]string] `json:"not_in"` +} + +func (r TokenNewParamsConditionRequestIP) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type TokenNewResponseEnvelope struct { + Errors []TokenNewResponseEnvelopeErrors `json:"errors,required"` + Messages []TokenNewResponseEnvelopeMessages `json:"messages,required"` + Result TokenNewResponse `json:"result,required"` + // Whether the API call was successful + Success TokenNewResponseEnvelopeSuccess `json:"success,required"` + JSON tokenNewResponseEnvelopeJSON `json:"-"` +} + +// tokenNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [TokenNewResponseEnvelope] +type tokenNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TokenNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tokenNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// tokenNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [TokenNewResponseEnvelopeErrors] +type tokenNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TokenNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tokenNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// tokenNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [TokenNewResponseEnvelopeMessages] +type tokenNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TokenNewResponseEnvelopeSuccess bool + +const ( + TokenNewResponseEnvelopeSuccessTrue TokenNewResponseEnvelopeSuccess = true +) + +type TokenUpdateParams struct { + // Token name. + Name param.Field[string] `json:"name,required"` + // List of access policies assigned to the token. + Policies param.Field[[]TokenUpdateParamsPolicy] `json:"policies,required"` + // Status of the token. + Status param.Field[TokenUpdateParamsStatus] `json:"status,required"` + Condition param.Field[TokenUpdateParamsCondition] `json:"condition"` + // The expiration time on or after which the JWT MUST NOT be accepted for + // processing. + ExpiresOn param.Field[time.Time] `json:"expires_on" format:"date-time"` + // The time before which the token MUST NOT be accepted for processing. + NotBefore param.Field[time.Time] `json:"not_before" format:"date-time"` +} + +func (r TokenUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type TokenUpdateParamsPolicy struct { + // Allow or deny operations against the resources. + Effect param.Field[TokenUpdateParamsPoliciesEffect] `json:"effect,required"` + // A set of permission groups that are specified to the policy. + PermissionGroups param.Field[[]TokenUpdateParamsPoliciesPermissionGroup] `json:"permission_groups,required"` + // A list of resource names that the policy applies to. + Resources param.Field[interface{}] `json:"resources,required"` +} + +func (r TokenUpdateParamsPolicy) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Allow or deny operations against the resources. +type TokenUpdateParamsPoliciesEffect string + +const ( + TokenUpdateParamsPoliciesEffectAllow TokenUpdateParamsPoliciesEffect = "allow" + TokenUpdateParamsPoliciesEffectDeny TokenUpdateParamsPoliciesEffect = "deny" +) + +// A named group of permissions that map to a group of operations against +// resources. +type TokenUpdateParamsPoliciesPermissionGroup struct { +} + +func (r TokenUpdateParamsPoliciesPermissionGroup) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Status of the token. +type TokenUpdateParamsStatus string + +const ( + TokenUpdateParamsStatusActive TokenUpdateParamsStatus = "active" + TokenUpdateParamsStatusDisabled TokenUpdateParamsStatus = "disabled" + TokenUpdateParamsStatusExpired TokenUpdateParamsStatus = "expired" +) + +type TokenUpdateParamsCondition struct { + // Client IP restrictions. + RequestIP param.Field[TokenUpdateParamsConditionRequestIP] `json:"request_ip"` +} + +func (r TokenUpdateParamsCondition) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Client IP restrictions. +type TokenUpdateParamsConditionRequestIP struct { + // List of IPv4/IPv6 CIDR addresses. + In param.Field[[]string] `json:"in"` + // List of IPv4/IPv6 CIDR addresses. + NotIn param.Field[[]string] `json:"not_in"` +} + +func (r TokenUpdateParamsConditionRequestIP) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type TokenUpdateResponseEnvelope struct { + Errors []TokenUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []TokenUpdateResponseEnvelopeMessages `json:"messages,required"` + Result TokenUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success TokenUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON tokenUpdateResponseEnvelopeJSON `json:"-"` +} + +// tokenUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [TokenUpdateResponseEnvelope] +type tokenUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TokenUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tokenUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// tokenUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [TokenUpdateResponseEnvelopeErrors] +type tokenUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TokenUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tokenUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// tokenUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [TokenUpdateResponseEnvelopeMessages] +type tokenUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TokenUpdateResponseEnvelopeSuccess bool + +const ( + TokenUpdateResponseEnvelopeSuccessTrue TokenUpdateResponseEnvelopeSuccess = true +) + +type TokenListParams struct { + // Direction to order results. + Direction param.Field[TokenListParamsDirection] `query:"direction"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // Maximum number of results per page. + PerPage param.Field[float64] `query:"per_page"` +} + +// URLQuery serializes [TokenListParams]'s query parameters as `url.Values`. +func (r TokenListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Direction to order results. +type TokenListParamsDirection string + +const ( + TokenListParamsDirectionAsc TokenListParamsDirection = "asc" + TokenListParamsDirectionDesc TokenListParamsDirection = "desc" +) + +type TokenDeleteResponseEnvelope struct { + Errors []TokenDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []TokenDeleteResponseEnvelopeMessages `json:"messages,required"` + Result TokenDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success TokenDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON tokenDeleteResponseEnvelopeJSON `json:"-"` +} + +// tokenDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [TokenDeleteResponseEnvelope] +type tokenDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TokenDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tokenDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// tokenDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [TokenDeleteResponseEnvelopeErrors] +type tokenDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TokenDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tokenDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// tokenDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [TokenDeleteResponseEnvelopeMessages] +type tokenDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TokenDeleteResponseEnvelopeSuccess bool + +const ( + TokenDeleteResponseEnvelopeSuccessTrue TokenDeleteResponseEnvelopeSuccess = true +) + +type TokenGetResponseEnvelope struct { + Errors []TokenGetResponseEnvelopeErrors `json:"errors,required"` + Messages []TokenGetResponseEnvelopeMessages `json:"messages,required"` + Result TokenGetResponse `json:"result,required"` + // Whether the API call was successful + Success TokenGetResponseEnvelopeSuccess `json:"success,required"` + JSON tokenGetResponseEnvelopeJSON `json:"-"` +} + +// tokenGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [TokenGetResponseEnvelope] +type tokenGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TokenGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tokenGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// tokenGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [TokenGetResponseEnvelopeErrors] +type tokenGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TokenGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tokenGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// tokenGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [TokenGetResponseEnvelopeMessages] +type tokenGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TokenGetResponseEnvelopeSuccess bool + +const ( + TokenGetResponseEnvelopeSuccessTrue TokenGetResponseEnvelopeSuccess = true +) + +type TokenVerifyResponseEnvelope struct { + Errors []TokenVerifyResponseEnvelopeErrors `json:"errors,required"` + Messages []TokenVerifyResponseEnvelopeMessages `json:"messages,required"` + Result TokenVerifyResponse `json:"result,required"` + // Whether the API call was successful + Success TokenVerifyResponseEnvelopeSuccess `json:"success,required"` + JSON tokenVerifyResponseEnvelopeJSON `json:"-"` +} + +// tokenVerifyResponseEnvelopeJSON contains the JSON metadata for the struct +// [TokenVerifyResponseEnvelope] +type tokenVerifyResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenVerifyResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenVerifyResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TokenVerifyResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tokenVerifyResponseEnvelopeErrorsJSON `json:"-"` +} + +// tokenVerifyResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [TokenVerifyResponseEnvelopeErrors] +type tokenVerifyResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenVerifyResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenVerifyResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TokenVerifyResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tokenVerifyResponseEnvelopeMessagesJSON `json:"-"` +} + +// tokenVerifyResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [TokenVerifyResponseEnvelopeMessages] +type tokenVerifyResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenVerifyResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenVerifyResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TokenVerifyResponseEnvelopeSuccess bool + +const ( + TokenVerifyResponseEnvelopeSuccessTrue TokenVerifyResponseEnvelopeSuccess = true +) diff --git a/user/token_test.go b/user/token_test.go new file mode 100644 index 00000000000..8441d8969b4 --- /dev/null +++ b/user/token_test.go @@ -0,0 +1,233 @@ +// File generated from our OpenAPI spec by Stainless. + +package user_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/user" +) + +func TestTokenNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.Tokens.New(context.TODO(), user.TokenNewParams{ + Name: cloudflare.F("readonly token"), + Policies: cloudflare.F([]user.TokenNewParamsPolicy{{ + Effect: cloudflare.F(user.TokenNewParamsPoliciesEffectAllow), + PermissionGroups: cloudflare.F([]user.TokenNewParamsPoliciesPermissionGroup{{}, {}}), + Resources: cloudflare.F[any](map[string]interface{}{ + "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", + "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", + }), + }, { + Effect: cloudflare.F(user.TokenNewParamsPoliciesEffectAllow), + PermissionGroups: cloudflare.F([]user.TokenNewParamsPoliciesPermissionGroup{{}, {}}), + Resources: cloudflare.F[any](map[string]interface{}{ + "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", + "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", + }), + }, { + Effect: cloudflare.F(user.TokenNewParamsPoliciesEffectAllow), + PermissionGroups: cloudflare.F([]user.TokenNewParamsPoliciesPermissionGroup{{}, {}}), + Resources: cloudflare.F[any](map[string]interface{}{ + "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", + "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", + }), + }}), + Condition: cloudflare.F(user.TokenNewParamsCondition{ + RequestIP: cloudflare.F(user.TokenNewParamsConditionRequestIP{ + In: cloudflare.F([]string{"123.123.123.0/24", "2606:4700::/32"}), + NotIn: cloudflare.F([]string{"123.123.123.100/24", "2606:4700:4700::/48"}), + }), + }), + ExpiresOn: cloudflare.F(time.Now()), + NotBefore: cloudflare.F(time.Now()), + }) + 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 TestTokenUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.Tokens.Update( + context.TODO(), + map[string]interface{}{}, + user.TokenUpdateParams{ + Name: cloudflare.F("readonly token"), + Policies: cloudflare.F([]user.TokenUpdateParamsPolicy{{ + Effect: cloudflare.F(user.TokenUpdateParamsPoliciesEffectAllow), + PermissionGroups: cloudflare.F([]user.TokenUpdateParamsPoliciesPermissionGroup{{}, {}}), + Resources: cloudflare.F[any](map[string]interface{}{ + "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", + "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", + }), + }, { + Effect: cloudflare.F(user.TokenUpdateParamsPoliciesEffectAllow), + PermissionGroups: cloudflare.F([]user.TokenUpdateParamsPoliciesPermissionGroup{{}, {}}), + Resources: cloudflare.F[any](map[string]interface{}{ + "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", + "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", + }), + }, { + Effect: cloudflare.F(user.TokenUpdateParamsPoliciesEffectAllow), + PermissionGroups: cloudflare.F([]user.TokenUpdateParamsPoliciesPermissionGroup{{}, {}}), + Resources: cloudflare.F[any](map[string]interface{}{ + "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", + "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", + }), + }}), + Status: cloudflare.F(user.TokenUpdateParamsStatusActive), + Condition: cloudflare.F(user.TokenUpdateParamsCondition{ + RequestIP: cloudflare.F(user.TokenUpdateParamsConditionRequestIP{ + In: cloudflare.F([]string{"123.123.123.0/24", "2606:4700::/32"}), + NotIn: cloudflare.F([]string{"123.123.123.100/24", "2606:4700:4700::/48"}), + }), + }), + ExpiresOn: cloudflare.F(time.Now()), + NotBefore: cloudflare.F(time.Now()), + }, + ) + 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 TestTokenListWithOptionalParams(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("user@example.com"), + ) + _, err := client.User.Tokens.List(context.TODO(), user.TokenListParams{ + Direction: cloudflare.F(user.TokenListParamsDirectionDesc), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(5.000000), + }) + 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 TestTokenDelete(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("user@example.com"), + ) + _, err := client.User.Tokens.Delete(context.TODO(), map[string]interface{}{}) + 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 TestTokenGet(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("user@example.com"), + ) + _, err := client.User.Tokens.Get(context.TODO(), map[string]interface{}{}) + 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 TestTokenVerify(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("user@example.com"), + ) + _, err := client.User.Tokens.Verify(context.TODO()) + 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/user/tokenpermissiongroup.go b/user/tokenpermissiongroup.go new file mode 100644 index 00000000000..f94b4ff4a22 --- /dev/null +++ b/user/tokenpermissiongroup.go @@ -0,0 +1,159 @@ +// File generated from our OpenAPI spec by Stainless. + +package user + +import ( + "context" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// TokenPermissionGroupService 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 [NewTokenPermissionGroupService] +// method instead. +type TokenPermissionGroupService struct { + Options []option.RequestOption +} + +// NewTokenPermissionGroupService 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 NewTokenPermissionGroupService(opts ...option.RequestOption) (r *TokenPermissionGroupService) { + r = &TokenPermissionGroupService{} + r.Options = opts + return +} + +// Find all available permission groups. +func (r *TokenPermissionGroupService) List(ctx context.Context, opts ...option.RequestOption) (res *[]TokenPermissionGroupListResponse, err error) { + opts = append(r.Options[:], opts...) + var env TokenPermissionGroupListResponseEnvelope + path := "user/tokens/permission_groups" + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TokenPermissionGroupListResponse = interface{} + +type TokenPermissionGroupListResponseEnvelope struct { + Errors []TokenPermissionGroupListResponseEnvelopeErrors `json:"errors,required"` + Messages []TokenPermissionGroupListResponseEnvelopeMessages `json:"messages,required"` + Result []TokenPermissionGroupListResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success TokenPermissionGroupListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo TokenPermissionGroupListResponseEnvelopeResultInfo `json:"result_info"` + JSON tokenPermissionGroupListResponseEnvelopeJSON `json:"-"` +} + +// tokenPermissionGroupListResponseEnvelopeJSON contains the JSON metadata for the +// struct [TokenPermissionGroupListResponseEnvelope] +type tokenPermissionGroupListResponseEnvelopeJSON 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 *TokenPermissionGroupListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenPermissionGroupListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TokenPermissionGroupListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tokenPermissionGroupListResponseEnvelopeErrorsJSON `json:"-"` +} + +// tokenPermissionGroupListResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [TokenPermissionGroupListResponseEnvelopeErrors] +type tokenPermissionGroupListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenPermissionGroupListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenPermissionGroupListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TokenPermissionGroupListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tokenPermissionGroupListResponseEnvelopeMessagesJSON `json:"-"` +} + +// tokenPermissionGroupListResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [TokenPermissionGroupListResponseEnvelopeMessages] +type tokenPermissionGroupListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenPermissionGroupListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenPermissionGroupListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TokenPermissionGroupListResponseEnvelopeSuccess bool + +const ( + TokenPermissionGroupListResponseEnvelopeSuccessTrue TokenPermissionGroupListResponseEnvelopeSuccess = true +) + +type TokenPermissionGroupListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON tokenPermissionGroupListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// tokenPermissionGroupListResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [TokenPermissionGroupListResponseEnvelopeResultInfo] +type tokenPermissionGroupListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenPermissionGroupListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenPermissionGroupListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/user/tokenpermissiongroup_test.go b/user/tokenpermissiongroup_test.go new file mode 100644 index 00000000000..050071d8d78 --- /dev/null +++ b/user/tokenpermissiongroup_test.go @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package user_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestTokenPermissionGroupList(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("user@example.com"), + ) + _, err := client.User.Tokens.PermissionGroups.List(context.TODO()) + 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/user/tokenvalue.go b/user/tokenvalue.go new file mode 100644 index 00000000000..2de17be7036 --- /dev/null +++ b/user/tokenvalue.go @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package user + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// TokenValueService 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 [NewTokenValueService] method instead. +type TokenValueService struct { + Options []option.RequestOption +} + +// NewTokenValueService 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 NewTokenValueService(opts ...option.RequestOption) (r *TokenValueService) { + r = &TokenValueService{} + r.Options = opts + return +} + +// Roll the token secret. +func (r *TokenValueService) Update(ctx context.Context, tokenID interface{}, body TokenValueUpdateParams, opts ...option.RequestOption) (res *IamValue, err error) { + opts = append(r.Options[:], opts...) + var env TokenValueUpdateResponseEnvelope + path := fmt.Sprintf("user/tokens/%v/value", tokenID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type IamValue = string + +type TokenValueUpdateParams struct { + Body param.Field[interface{}] `json:"body,required"` +} + +func (r TokenValueUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type TokenValueUpdateResponseEnvelope struct { + Errors []TokenValueUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []TokenValueUpdateResponseEnvelopeMessages `json:"messages,required"` + // The token value. + Result IamValue `json:"result,required"` + // Whether the API call was successful + Success TokenValueUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON tokenValueUpdateResponseEnvelopeJSON `json:"-"` +} + +// tokenValueUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [TokenValueUpdateResponseEnvelope] +type tokenValueUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenValueUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenValueUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TokenValueUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tokenValueUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// tokenValueUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [TokenValueUpdateResponseEnvelopeErrors] +type tokenValueUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenValueUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenValueUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TokenValueUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tokenValueUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// tokenValueUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [TokenValueUpdateResponseEnvelopeMessages] +type tokenValueUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TokenValueUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tokenValueUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TokenValueUpdateResponseEnvelopeSuccess bool + +const ( + TokenValueUpdateResponseEnvelopeSuccessTrue TokenValueUpdateResponseEnvelopeSuccess = true +) diff --git a/user/tokenvalue_test.go b/user/tokenvalue_test.go new file mode 100644 index 00000000000..8beb69a9d72 --- /dev/null +++ b/user/tokenvalue_test.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package user_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/user" +) + +func TestTokenValueUpdate(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("user@example.com"), + ) + _, err := client.User.Tokens.Value.Update( + context.TODO(), + map[string]interface{}{}, + user.TokenValueUpdateParams{ + Body: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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/user.go b/user/user.go similarity index 89% rename from user.go rename to user/user.go index 032f55ef648..1a8d917770f 100644 --- a/user.go +++ b/user/user.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package user import ( "context" @@ -21,14 +21,14 @@ import ( // directly, and instead use the [NewUserService] method instead. type UserService struct { Options []option.RequestOption - AuditLogs *UserAuditLogService - Billing *UserBillingService - Firewall *UserFirewallService - Invites *UserInviteService - LoadBalancers *UserLoadBalancerService - Organizations *UserOrganizationService - Subscriptions *UserSubscriptionService - Tokens *UserTokenService + AuditLogs *AuditLogService + Billing *BillingService + Firewall *FirewallService + Invites *InviteService + LoadBalancers *LoadBalancerService + Organizations *OrganizationService + Subscriptions *SubscriptionService + Tokens *TokenService } // NewUserService generates a new service that applies the given options to each @@ -37,14 +37,14 @@ type UserService struct { func NewUserService(opts ...option.RequestOption) (r *UserService) { r = &UserService{} r.Options = opts - r.AuditLogs = NewUserAuditLogService(opts...) - r.Billing = NewUserBillingService(opts...) - r.Firewall = NewUserFirewallService(opts...) - r.Invites = NewUserInviteService(opts...) - r.LoadBalancers = NewUserLoadBalancerService(opts...) - r.Organizations = NewUserOrganizationService(opts...) - r.Subscriptions = NewUserSubscriptionService(opts...) - r.Tokens = NewUserTokenService(opts...) + r.AuditLogs = NewAuditLogService(opts...) + r.Billing = NewBillingService(opts...) + r.Firewall = NewFirewallService(opts...) + r.Invites = NewInviteService(opts...) + r.LoadBalancers = NewLoadBalancerService(opts...) + r.Organizations = NewOrganizationService(opts...) + r.Subscriptions = NewSubscriptionService(opts...) + r.Tokens = NewTokenService(opts...) return } @@ -74,9 +74,9 @@ func (r *UserService) Get(ctx context.Context, opts ...option.RequestOption) (re return } -// Union satisfied by [UserEditResponseUnknown] or [shared.UnionString]. +// Union satisfied by [user.UserEditResponseUnknown] or [shared.UnionString]. type UserEditResponse interface { - ImplementsUserEditResponse() + ImplementsUserUserEditResponse() } func init() { @@ -90,9 +90,9 @@ func init() { ) } -// Union satisfied by [UserGetResponseUnknown] or [shared.UnionString]. +// Union satisfied by [user.UserGetResponseUnknown] or [shared.UnionString]. type UserGetResponse interface { - ImplementsUserGetResponse() + ImplementsUserUserGetResponse() } func init() { diff --git a/user_test.go b/user/user_test.go similarity index 93% rename from user_test.go rename to user/user_test.go index f125333642e..c2cdfd38b65 100644 --- a/user_test.go +++ b/user/user_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package user_test import ( "context" @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/user" ) func TestUserEditWithOptionalParams(t *testing.T) { @@ -27,7 +28,7 @@ func TestUserEditWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.User.Edit(context.TODO(), cloudflare.UserEditParams{ + _, err := client.User.Edit(context.TODO(), user.UserEditParams{ Country: cloudflare.F("US"), FirstName: cloudflare.F("John"), LastName: cloudflare.F("Appleseed"), diff --git a/userauditlog.go b/userauditlog.go deleted file mode 100644 index ade59d1245a..00000000000 --- a/userauditlog.go +++ /dev/null @@ -1,304 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" -) - -// UserAuditLogService 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 [NewUserAuditLogService] method -// instead. -type UserAuditLogService struct { - Options []option.RequestOption -} - -// NewUserAuditLogService 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 NewUserAuditLogService(opts ...option.RequestOption) (r *UserAuditLogService) { - r = &UserAuditLogService{} - r.Options = opts - return -} - -// Gets a list of audit logs for a user account. Can be filtered by who made the -// change, on which zone, and the timeframe of the change. -func (r *UserAuditLogService) List(ctx context.Context, query UserAuditLogListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[UserAuditLogListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := "user/audit_logs" - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Gets a list of audit logs for a user account. Can be filtered by who made the -// change, on which zone, and the timeframe of the change. -func (r *UserAuditLogService) ListAutoPaging(ctx context.Context, query UserAuditLogListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[UserAuditLogListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, query, opts...)) -} - -type UserAuditLogListResponse struct { - // A string that uniquely identifies the audit log. - ID string `json:"id"` - Action UserAuditLogListResponseAction `json:"action"` - Actor UserAuditLogListResponseActor `json:"actor"` - // The source of the event. - Interface string `json:"interface"` - // An object which can lend more context to the action being logged. This is a - // flexible value and varies between different actions. - Metadata interface{} `json:"metadata"` - // The new value of the resource that was modified. - NewValue string `json:"newValue"` - // The value of the resource before it was modified. - OldValue string `json:"oldValue"` - Owner UserAuditLogListResponseOwner `json:"owner"` - Resource UserAuditLogListResponseResource `json:"resource"` - // A UTC RFC3339 timestamp that specifies when the action being logged occured. - When time.Time `json:"when" format:"date-time"` - JSON userAuditLogListResponseJSON `json:"-"` -} - -// userAuditLogListResponseJSON contains the JSON metadata for the struct -// [UserAuditLogListResponse] -type userAuditLogListResponseJSON struct { - ID apijson.Field - Action apijson.Field - Actor apijson.Field - Interface apijson.Field - Metadata apijson.Field - NewValue apijson.Field - OldValue apijson.Field - Owner apijson.Field - Resource apijson.Field - When apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserAuditLogListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userAuditLogListResponseJSON) RawJSON() string { - return r.raw -} - -type UserAuditLogListResponseAction struct { - // A boolean that indicates if the action attempted was successful. - Result bool `json:"result"` - // A short string that describes the action that was performed. - Type string `json:"type"` - JSON userAuditLogListResponseActionJSON `json:"-"` -} - -// userAuditLogListResponseActionJSON contains the JSON metadata for the struct -// [UserAuditLogListResponseAction] -type userAuditLogListResponseActionJSON struct { - Result apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserAuditLogListResponseAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userAuditLogListResponseActionJSON) RawJSON() string { - return r.raw -} - -type UserAuditLogListResponseActor struct { - // The ID of the actor that performed the action. If a user performed the action, - // this will be their User ID. - ID string `json:"id"` - // The email of the user that performed the action. - Email string `json:"email" format:"email"` - // The IP address of the request that performed the action. - IP string `json:"ip"` - // The type of actor, whether a User, Cloudflare Admin, or an Automated System. - Type UserAuditLogListResponseActorType `json:"type"` - JSON userAuditLogListResponseActorJSON `json:"-"` -} - -// userAuditLogListResponseActorJSON contains the JSON metadata for the struct -// [UserAuditLogListResponseActor] -type userAuditLogListResponseActorJSON struct { - ID apijson.Field - Email apijson.Field - IP apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserAuditLogListResponseActor) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userAuditLogListResponseActorJSON) RawJSON() string { - return r.raw -} - -// The type of actor, whether a User, Cloudflare Admin, or an Automated System. -type UserAuditLogListResponseActorType string - -const ( - UserAuditLogListResponseActorTypeUser UserAuditLogListResponseActorType = "user" - UserAuditLogListResponseActorTypeAdmin UserAuditLogListResponseActorType = "admin" - UserAuditLogListResponseActorTypeCloudflare UserAuditLogListResponseActorType = "Cloudflare" -) - -type UserAuditLogListResponseOwner struct { - // Identifier - ID string `json:"id"` - JSON userAuditLogListResponseOwnerJSON `json:"-"` -} - -// userAuditLogListResponseOwnerJSON contains the JSON metadata for the struct -// [UserAuditLogListResponseOwner] -type userAuditLogListResponseOwnerJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserAuditLogListResponseOwner) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userAuditLogListResponseOwnerJSON) RawJSON() string { - return r.raw -} - -type UserAuditLogListResponseResource struct { - // An identifier for the resource that was affected by the action. - ID string `json:"id"` - // A short string that describes the resource that was affected by the action. - Type string `json:"type"` - JSON userAuditLogListResponseResourceJSON `json:"-"` -} - -// userAuditLogListResponseResourceJSON contains the JSON metadata for the struct -// [UserAuditLogListResponseResource] -type userAuditLogListResponseResourceJSON struct { - ID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserAuditLogListResponseResource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userAuditLogListResponseResourceJSON) RawJSON() string { - return r.raw -} - -type UserAuditLogListParams struct { - // Finds a specific log by its ID. - ID param.Field[string] `query:"id"` - Action param.Field[UserAuditLogListParamsAction] `query:"action"` - Actor param.Field[UserAuditLogListParamsActor] `query:"actor"` - // Limits the returned results to logs older than the specified date. This can be a - // date string `2019-04-30` or an absolute timestamp that conforms to RFC3339. - Before param.Field[time.Time] `query:"before" format:"date-time"` - // Changes the direction of the chronological sorting. - Direction param.Field[UserAuditLogListParamsDirection] `query:"direction"` - // Indicates that this request is an export of logs in CSV format. - Export param.Field[bool] `query:"export"` - // Indicates whether or not to hide user level audit logs. - HideUserLogs param.Field[bool] `query:"hide_user_logs"` - // Defines which page of results to return. - Page param.Field[float64] `query:"page"` - // Sets the number of results to return per page. - PerPage param.Field[float64] `query:"per_page"` - // Limits the returned results to logs newer than the specified date. This can be a - // date string `2019-04-30` or an absolute timestamp that conforms to RFC3339. - Since param.Field[time.Time] `query:"since" format:"date-time"` - Zone param.Field[UserAuditLogListParamsZone] `query:"zone"` -} - -// URLQuery serializes [UserAuditLogListParams]'s query parameters as `url.Values`. -func (r UserAuditLogListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type UserAuditLogListParamsAction struct { - // Filters by the action type. - Type param.Field[string] `query:"type"` -} - -// URLQuery serializes [UserAuditLogListParamsAction]'s query parameters as -// `url.Values`. -func (r UserAuditLogListParamsAction) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type UserAuditLogListParamsActor struct { - // Filters by the email address of the actor that made the change. - Email param.Field[string] `query:"email" format:"email"` - // Filters by the IP address of the request that made the change by specific IP - // address or valid CIDR Range. - IP param.Field[string] `query:"ip"` -} - -// URLQuery serializes [UserAuditLogListParamsActor]'s query parameters as -// `url.Values`. -func (r UserAuditLogListParamsActor) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Changes the direction of the chronological sorting. -type UserAuditLogListParamsDirection string - -const ( - UserAuditLogListParamsDirectionDesc UserAuditLogListParamsDirection = "desc" - UserAuditLogListParamsDirectionAsc UserAuditLogListParamsDirection = "asc" -) - -type UserAuditLogListParamsZone struct { - // Filters by the name of the zone associated to the change. - Name param.Field[string] `query:"name"` -} - -// URLQuery serializes [UserAuditLogListParamsZone]'s query parameters as -// `url.Values`. -func (r UserAuditLogListParamsZone) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} diff --git a/userauditlog_test.go b/userauditlog_test.go deleted file mode 100644 index 3e1fee156fa..00000000000 --- a/userauditlog_test.go +++ /dev/null @@ -1,58 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestUserAuditLogListWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.AuditLogs.List(context.TODO(), cloudflare.UserAuditLogListParams{ - ID: cloudflare.F("f174be97-19b1-40d6-954d-70cd5fbd52db"), - Action: cloudflare.F(cloudflare.UserAuditLogListParamsAction{ - Type: cloudflare.F("add"), - }), - Actor: cloudflare.F(cloudflare.UserAuditLogListParamsActor{ - IP: cloudflare.F("17.168.228.63"), - Email: cloudflare.F("alice@example.com"), - }), - Before: cloudflare.F(time.Now()), - Direction: cloudflare.F(cloudflare.UserAuditLogListParamsDirectionDesc), - Export: cloudflare.F(true), - HideUserLogs: cloudflare.F(true), - Page: cloudflare.F(50.000000), - PerPage: cloudflare.F(25.000000), - Since: cloudflare.F(time.Now()), - Zone: cloudflare.F(cloudflare.UserAuditLogListParamsZone{ - Name: cloudflare.F("example.com"), - }), - }) - 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/userbilling.go b/userbilling.go deleted file mode 100644 index 6cb93cdf7eb..00000000000 --- a/userbilling.go +++ /dev/null @@ -1,29 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// UserBillingService 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 [NewUserBillingService] method -// instead. -type UserBillingService struct { - Options []option.RequestOption - History *UserBillingHistoryService - Profiles *UserBillingProfileService -} - -// NewUserBillingService 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 NewUserBillingService(opts ...option.RequestOption) (r *UserBillingService) { - r = &UserBillingService{} - r.Options = opts - r.History = NewUserBillingHistoryService(opts...) - r.Profiles = NewUserBillingProfileService(opts...) - return -} diff --git a/userbillinghistory.go b/userbillinghistory.go deleted file mode 100644 index c2a4b68c2c8..00000000000 --- a/userbillinghistory.go +++ /dev/null @@ -1,251 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// UserBillingHistoryService 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 [NewUserBillingHistoryService] method -// instead. -type UserBillingHistoryService struct { - Options []option.RequestOption -} - -// NewUserBillingHistoryService 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 NewUserBillingHistoryService(opts ...option.RequestOption) (r *UserBillingHistoryService) { - r = &UserBillingHistoryService{} - r.Options = opts - return -} - -// Accesses your billing history object. -func (r *UserBillingHistoryService) Get(ctx context.Context, query UserBillingHistoryGetParams, opts ...option.RequestOption) (res *[]UserBillingHistoryGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserBillingHistoryGetResponseEnvelope - path := "user/billing/history" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type UserBillingHistoryGetResponse struct { - // Billing item identifier tag. - ID string `json:"id,required"` - // The billing item action. - Action string `json:"action,required"` - // The amount associated with this billing item. - Amount float64 `json:"amount,required"` - // The monetary unit in which pricing information is displayed. - Currency string `json:"currency,required"` - // The billing item description. - Description string `json:"description,required"` - // When the billing item was created. - OccurredAt time.Time `json:"occurred_at,required" format:"date-time"` - // The billing item type. - Type string `json:"type,required"` - Zone UserBillingHistoryGetResponseZone `json:"zone,required"` - JSON userBillingHistoryGetResponseJSON `json:"-"` -} - -// userBillingHistoryGetResponseJSON contains the JSON metadata for the struct -// [UserBillingHistoryGetResponse] -type userBillingHistoryGetResponseJSON struct { - ID apijson.Field - Action apijson.Field - Amount apijson.Field - Currency apijson.Field - Description apijson.Field - OccurredAt apijson.Field - Type apijson.Field - Zone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserBillingHistoryGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userBillingHistoryGetResponseJSON) RawJSON() string { - return r.raw -} - -type UserBillingHistoryGetResponseZone struct { - Name interface{} `json:"name"` - JSON userBillingHistoryGetResponseZoneJSON `json:"-"` -} - -// userBillingHistoryGetResponseZoneJSON contains the JSON metadata for the struct -// [UserBillingHistoryGetResponseZone] -type userBillingHistoryGetResponseZoneJSON struct { - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserBillingHistoryGetResponseZone) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userBillingHistoryGetResponseZoneJSON) RawJSON() string { - return r.raw -} - -type UserBillingHistoryGetParams struct { - // Field to order billing history by. - Order param.Field[UserBillingHistoryGetParamsOrder] `query:"order"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // Number of items per page. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [UserBillingHistoryGetParams]'s query parameters as -// `url.Values`. -func (r UserBillingHistoryGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Field to order billing history by. -type UserBillingHistoryGetParamsOrder string - -const ( - UserBillingHistoryGetParamsOrderType UserBillingHistoryGetParamsOrder = "type" - UserBillingHistoryGetParamsOrderOccuredAt UserBillingHistoryGetParamsOrder = "occured_at" - UserBillingHistoryGetParamsOrderAction UserBillingHistoryGetParamsOrder = "action" -) - -type UserBillingHistoryGetResponseEnvelope struct { - Errors []UserBillingHistoryGetResponseEnvelopeErrors `json:"errors,required"` - Messages []UserBillingHistoryGetResponseEnvelopeMessages `json:"messages,required"` - Result []UserBillingHistoryGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success UserBillingHistoryGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo UserBillingHistoryGetResponseEnvelopeResultInfo `json:"result_info"` - JSON userBillingHistoryGetResponseEnvelopeJSON `json:"-"` -} - -// userBillingHistoryGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [UserBillingHistoryGetResponseEnvelope] -type userBillingHistoryGetResponseEnvelopeJSON 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 *UserBillingHistoryGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userBillingHistoryGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserBillingHistoryGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userBillingHistoryGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// userBillingHistoryGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [UserBillingHistoryGetResponseEnvelopeErrors] -type userBillingHistoryGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserBillingHistoryGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userBillingHistoryGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserBillingHistoryGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userBillingHistoryGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// userBillingHistoryGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [UserBillingHistoryGetResponseEnvelopeMessages] -type userBillingHistoryGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserBillingHistoryGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userBillingHistoryGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserBillingHistoryGetResponseEnvelopeSuccess bool - -const ( - UserBillingHistoryGetResponseEnvelopeSuccessTrue UserBillingHistoryGetResponseEnvelopeSuccess = true -) - -type UserBillingHistoryGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON userBillingHistoryGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// userBillingHistoryGetResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [UserBillingHistoryGetResponseEnvelopeResultInfo] -type userBillingHistoryGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserBillingHistoryGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userBillingHistoryGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/userbillinghistory_test.go b/userbillinghistory_test.go deleted file mode 100644 index f0a79298c27..00000000000 --- a/userbillinghistory_test.go +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestUserBillingHistoryGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.Billing.History.Get(context.TODO(), cloudflare.UserBillingHistoryGetParams{ - Order: cloudflare.F(cloudflare.UserBillingHistoryGetParamsOrderOccuredAt), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(5.000000), - }) - 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/userbillingprofile.go b/userbillingprofile.go deleted file mode 100644 index d4b04af490d..00000000000 --- a/userbillingprofile.go +++ /dev/null @@ -1,144 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// UserBillingProfileService 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 [NewUserBillingProfileService] method -// instead. -type UserBillingProfileService struct { - Options []option.RequestOption -} - -// NewUserBillingProfileService 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 NewUserBillingProfileService(opts ...option.RequestOption) (r *UserBillingProfileService) { - r = &UserBillingProfileService{} - r.Options = opts - return -} - -// Accesses your billing profile object. -func (r *UserBillingProfileService) Get(ctx context.Context, opts ...option.RequestOption) (res *UserBillingProfileGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserBillingProfileGetResponseEnvelope - path := "user/billing/profile" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [UserBillingProfileGetResponseUnknown] or -// [shared.UnionString]. -type UserBillingProfileGetResponse interface { - ImplementsUserBillingProfileGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*UserBillingProfileGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type UserBillingProfileGetResponseEnvelope struct { - Errors []UserBillingProfileGetResponseEnvelopeErrors `json:"errors,required"` - Messages []UserBillingProfileGetResponseEnvelopeMessages `json:"messages,required"` - Result UserBillingProfileGetResponse `json:"result,required"` - // Whether the API call was successful - Success UserBillingProfileGetResponseEnvelopeSuccess `json:"success,required"` - JSON userBillingProfileGetResponseEnvelopeJSON `json:"-"` -} - -// userBillingProfileGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [UserBillingProfileGetResponseEnvelope] -type userBillingProfileGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserBillingProfileGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userBillingProfileGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserBillingProfileGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userBillingProfileGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// userBillingProfileGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [UserBillingProfileGetResponseEnvelopeErrors] -type userBillingProfileGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserBillingProfileGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userBillingProfileGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserBillingProfileGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userBillingProfileGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// userBillingProfileGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [UserBillingProfileGetResponseEnvelopeMessages] -type userBillingProfileGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserBillingProfileGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userBillingProfileGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserBillingProfileGetResponseEnvelopeSuccess bool - -const ( - UserBillingProfileGetResponseEnvelopeSuccessTrue UserBillingProfileGetResponseEnvelopeSuccess = true -) diff --git a/userbillingprofile_test.go b/userbillingprofile_test.go deleted file mode 100644 index 1d3f85cbaa2..00000000000 --- a/userbillingprofile_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestUserBillingProfileGet(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("user@example.com"), - ) - _, err := client.User.Billing.Profiles.Get(context.TODO()) - 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/userfirewall.go b/userfirewall.go deleted file mode 100644 index 3287e889d2a..00000000000 --- a/userfirewall.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// UserFirewallService 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 [NewUserFirewallService] method -// instead. -type UserFirewallService struct { - Options []option.RequestOption - AccessRules *UserFirewallAccessRuleService -} - -// NewUserFirewallService 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 NewUserFirewallService(opts ...option.RequestOption) (r *UserFirewallService) { - r = &UserFirewallService{} - r.Options = opts - r.AccessRules = NewUserFirewallAccessRuleService(opts...) - return -} diff --git a/userfirewallaccessrule.go b/userfirewallaccessrule.go deleted file mode 100644 index 685fd807b6b..00000000000 --- a/userfirewallaccessrule.go +++ /dev/null @@ -1,1558 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// UserFirewallAccessRuleService 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 [NewUserFirewallAccessRuleService] -// method instead. -type UserFirewallAccessRuleService struct { - Options []option.RequestOption -} - -// NewUserFirewallAccessRuleService 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 NewUserFirewallAccessRuleService(opts ...option.RequestOption) (r *UserFirewallAccessRuleService) { - r = &UserFirewallAccessRuleService{} - r.Options = opts - return -} - -// Creates a new IP Access rule for all zones owned by the current user. -// -// Note: To create an IP Access rule that applies to a specific zone, refer to the -// [IP Access rules for a zone](#ip-access-rules-for-a-zone) endpoints. -func (r *UserFirewallAccessRuleService) New(ctx context.Context, body UserFirewallAccessRuleNewParams, opts ...option.RequestOption) (res *UserFirewallAccessRuleNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserFirewallAccessRuleNewResponseEnvelope - path := "user/firewall/access_rules/rules" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches IP Access rules of the user. You can filter the results using several -// optional parameters. -func (r *UserFirewallAccessRuleService) List(ctx context.Context, query UserFirewallAccessRuleListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[UserFirewallAccessRuleListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := "user/firewall/access_rules/rules" - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Fetches IP Access rules of the user. You can filter the results using several -// optional parameters. -func (r *UserFirewallAccessRuleService) ListAutoPaging(ctx context.Context, query UserFirewallAccessRuleListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[UserFirewallAccessRuleListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, query, opts...)) -} - -// Deletes an IP Access rule at the user level. -// -// Note: Deleting a user-level rule will affect all zones owned by the user. -func (r *UserFirewallAccessRuleService) Delete(ctx context.Context, identifier string, opts ...option.RequestOption) (res *UserFirewallAccessRuleDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserFirewallAccessRuleDeleteResponseEnvelope - path := fmt.Sprintf("user/firewall/access_rules/rules/%s", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates an IP Access rule defined at the user level. You can only update the -// rule action (`mode` parameter) and notes. -func (r *UserFirewallAccessRuleService) Edit(ctx context.Context, identifier string, body UserFirewallAccessRuleEditParams, opts ...option.RequestOption) (res *UserFirewallAccessRuleEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserFirewallAccessRuleEditResponseEnvelope - path := fmt.Sprintf("user/firewall/access_rules/rules/%s", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type UserFirewallAccessRuleNewResponse struct { - // The unique identifier of the IP Access rule. - ID string `json:"id,required"` - // The available actions that a rule can apply to a matched request. - AllowedModes []UserFirewallAccessRuleNewResponseAllowedMode `json:"allowed_modes,required"` - // The rule configuration. - Configuration UserFirewallAccessRuleNewResponseConfiguration `json:"configuration,required"` - // The action to apply to a matched request. - Mode UserFirewallAccessRuleNewResponseMode `json:"mode,required"` - // The timestamp of when the rule was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // The timestamp of when the rule was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // An informative summary of the rule, typically used as a reminder or explanation. - Notes string `json:"notes"` - JSON userFirewallAccessRuleNewResponseJSON `json:"-"` -} - -// userFirewallAccessRuleNewResponseJSON contains the JSON metadata for the struct -// [UserFirewallAccessRuleNewResponse] -type userFirewallAccessRuleNewResponseJSON struct { - ID apijson.Field - AllowedModes apijson.Field - Configuration apijson.Field - Mode apijson.Field - CreatedOn apijson.Field - ModifiedOn apijson.Field - Notes apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleNewResponseJSON) RawJSON() string { - return r.raw -} - -// The action to apply to a matched request. -type UserFirewallAccessRuleNewResponseAllowedMode string - -const ( - UserFirewallAccessRuleNewResponseAllowedModeBlock UserFirewallAccessRuleNewResponseAllowedMode = "block" - UserFirewallAccessRuleNewResponseAllowedModeChallenge UserFirewallAccessRuleNewResponseAllowedMode = "challenge" - UserFirewallAccessRuleNewResponseAllowedModeWhitelist UserFirewallAccessRuleNewResponseAllowedMode = "whitelist" - UserFirewallAccessRuleNewResponseAllowedModeJsChallenge UserFirewallAccessRuleNewResponseAllowedMode = "js_challenge" - UserFirewallAccessRuleNewResponseAllowedModeManagedChallenge UserFirewallAccessRuleNewResponseAllowedMode = "managed_challenge" -) - -// The rule configuration. -// -// Union satisfied by -// [UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPConfiguration], -// [UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPV6Configuration], -// [UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCidrConfiguration], -// [UserFirewallAccessRuleNewResponseConfigurationLegacyJhsASNConfiguration] or -// [UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCountryConfiguration]. -type UserFirewallAccessRuleNewResponseConfiguration interface { - implementsUserFirewallAccessRuleNewResponseConfiguration() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*UserFirewallAccessRuleNewResponseConfiguration)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPV6Configuration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCidrConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(UserFirewallAccessRuleNewResponseConfigurationLegacyJhsASNConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCountryConfiguration{}), - }, - ) -} - -type UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPConfiguration struct { - // The configuration target. You must set the target to `ip` when specifying an IP - // address in the rule. - Target UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPConfigurationTarget `json:"target"` - // The IP address to match. This address will be compared to the IP address of - // incoming requests. - Value string `json:"value"` - JSON userFirewallAccessRuleNewResponseConfigurationLegacyJhsIPConfigurationJSON `json:"-"` -} - -// userFirewallAccessRuleNewResponseConfigurationLegacyJhsIPConfigurationJSON -// contains the JSON metadata for the struct -// [UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPConfiguration] -type userFirewallAccessRuleNewResponseConfigurationLegacyJhsIPConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleNewResponseConfigurationLegacyJhsIPConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPConfiguration) implementsUserFirewallAccessRuleNewResponseConfiguration() { -} - -// The configuration target. You must set the target to `ip` when specifying an IP -// address in the rule. -type UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPConfigurationTarget string - -const ( - UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPConfigurationTargetIP UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPConfigurationTarget = "ip" -) - -type UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPV6Configuration struct { - // The configuration target. You must set the target to `ip6` when specifying an - // IPv6 address in the rule. - Target UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPV6ConfigurationTarget `json:"target"` - // The IPv6 address to match. - Value string `json:"value"` - JSON userFirewallAccessRuleNewResponseConfigurationLegacyJhsIPV6ConfigurationJSON `json:"-"` -} - -// userFirewallAccessRuleNewResponseConfigurationLegacyJhsIPV6ConfigurationJSON -// contains the JSON metadata for the struct -// [UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPV6Configuration] -type userFirewallAccessRuleNewResponseConfigurationLegacyJhsIPV6ConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPV6Configuration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleNewResponseConfigurationLegacyJhsIPV6ConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPV6Configuration) implementsUserFirewallAccessRuleNewResponseConfiguration() { -} - -// The configuration target. You must set the target to `ip6` when specifying an -// IPv6 address in the rule. -type UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPV6ConfigurationTarget string - -const ( - UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPV6ConfigurationTargetIp6 UserFirewallAccessRuleNewResponseConfigurationLegacyJhsIPV6ConfigurationTarget = "ip6" -) - -type UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCidrConfiguration struct { - // The configuration target. You must set the target to `ip_range` when specifying - // an IP address range in the rule. - Target UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCidrConfigurationTarget `json:"target"` - // The IP address range to match. You can only use prefix lengths `/16` and `/24` - // for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. - Value string `json:"value"` - JSON userFirewallAccessRuleNewResponseConfigurationLegacyJhsCidrConfigurationJSON `json:"-"` -} - -// userFirewallAccessRuleNewResponseConfigurationLegacyJhsCidrConfigurationJSON -// contains the JSON metadata for the struct -// [UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCidrConfiguration] -type userFirewallAccessRuleNewResponseConfigurationLegacyJhsCidrConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCidrConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleNewResponseConfigurationLegacyJhsCidrConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCidrConfiguration) implementsUserFirewallAccessRuleNewResponseConfiguration() { -} - -// The configuration target. You must set the target to `ip_range` when specifying -// an IP address range in the rule. -type UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCidrConfigurationTarget string - -const ( - UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCidrConfigurationTargetIPRange UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCidrConfigurationTarget = "ip_range" -) - -type UserFirewallAccessRuleNewResponseConfigurationLegacyJhsASNConfiguration struct { - // The configuration target. You must set the target to `asn` when specifying an - // Autonomous System Number (ASN) in the rule. - Target UserFirewallAccessRuleNewResponseConfigurationLegacyJhsASNConfigurationTarget `json:"target"` - // The AS number to match. - Value string `json:"value"` - JSON userFirewallAccessRuleNewResponseConfigurationLegacyJhsASNConfigurationJSON `json:"-"` -} - -// userFirewallAccessRuleNewResponseConfigurationLegacyJhsASNConfigurationJSON -// contains the JSON metadata for the struct -// [UserFirewallAccessRuleNewResponseConfigurationLegacyJhsASNConfiguration] -type userFirewallAccessRuleNewResponseConfigurationLegacyJhsASNConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleNewResponseConfigurationLegacyJhsASNConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleNewResponseConfigurationLegacyJhsASNConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r UserFirewallAccessRuleNewResponseConfigurationLegacyJhsASNConfiguration) implementsUserFirewallAccessRuleNewResponseConfiguration() { -} - -// The configuration target. You must set the target to `asn` when specifying an -// Autonomous System Number (ASN) in the rule. -type UserFirewallAccessRuleNewResponseConfigurationLegacyJhsASNConfigurationTarget string - -const ( - UserFirewallAccessRuleNewResponseConfigurationLegacyJhsASNConfigurationTargetASN UserFirewallAccessRuleNewResponseConfigurationLegacyJhsASNConfigurationTarget = "asn" -) - -type UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCountryConfiguration struct { - // The configuration target. You must set the target to `country` when specifying a - // country code in the rule. - Target UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCountryConfigurationTarget `json:"target"` - // The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to - // [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). - Value string `json:"value"` - JSON userFirewallAccessRuleNewResponseConfigurationLegacyJhsCountryConfigurationJSON `json:"-"` -} - -// userFirewallAccessRuleNewResponseConfigurationLegacyJhsCountryConfigurationJSON -// contains the JSON metadata for the struct -// [UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCountryConfiguration] -type userFirewallAccessRuleNewResponseConfigurationLegacyJhsCountryConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCountryConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleNewResponseConfigurationLegacyJhsCountryConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCountryConfiguration) implementsUserFirewallAccessRuleNewResponseConfiguration() { -} - -// The configuration target. You must set the target to `country` when specifying a -// country code in the rule. -type UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCountryConfigurationTarget string - -const ( - UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCountryConfigurationTargetCountry UserFirewallAccessRuleNewResponseConfigurationLegacyJhsCountryConfigurationTarget = "country" -) - -// The action to apply to a matched request. -type UserFirewallAccessRuleNewResponseMode string - -const ( - UserFirewallAccessRuleNewResponseModeBlock UserFirewallAccessRuleNewResponseMode = "block" - UserFirewallAccessRuleNewResponseModeChallenge UserFirewallAccessRuleNewResponseMode = "challenge" - UserFirewallAccessRuleNewResponseModeWhitelist UserFirewallAccessRuleNewResponseMode = "whitelist" - UserFirewallAccessRuleNewResponseModeJsChallenge UserFirewallAccessRuleNewResponseMode = "js_challenge" - UserFirewallAccessRuleNewResponseModeManagedChallenge UserFirewallAccessRuleNewResponseMode = "managed_challenge" -) - -type UserFirewallAccessRuleListResponse struct { - // The unique identifier of the IP Access rule. - ID string `json:"id,required"` - // The available actions that a rule can apply to a matched request. - AllowedModes []UserFirewallAccessRuleListResponseAllowedMode `json:"allowed_modes,required"` - // The rule configuration. - Configuration UserFirewallAccessRuleListResponseConfiguration `json:"configuration,required"` - // The action to apply to a matched request. - Mode UserFirewallAccessRuleListResponseMode `json:"mode,required"` - // The timestamp of when the rule was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // The timestamp of when the rule was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // An informative summary of the rule, typically used as a reminder or explanation. - Notes string `json:"notes"` - JSON userFirewallAccessRuleListResponseJSON `json:"-"` -} - -// userFirewallAccessRuleListResponseJSON contains the JSON metadata for the struct -// [UserFirewallAccessRuleListResponse] -type userFirewallAccessRuleListResponseJSON struct { - ID apijson.Field - AllowedModes apijson.Field - Configuration apijson.Field - Mode apijson.Field - CreatedOn apijson.Field - ModifiedOn apijson.Field - Notes apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleListResponseJSON) RawJSON() string { - return r.raw -} - -// The action to apply to a matched request. -type UserFirewallAccessRuleListResponseAllowedMode string - -const ( - UserFirewallAccessRuleListResponseAllowedModeBlock UserFirewallAccessRuleListResponseAllowedMode = "block" - UserFirewallAccessRuleListResponseAllowedModeChallenge UserFirewallAccessRuleListResponseAllowedMode = "challenge" - UserFirewallAccessRuleListResponseAllowedModeWhitelist UserFirewallAccessRuleListResponseAllowedMode = "whitelist" - UserFirewallAccessRuleListResponseAllowedModeJsChallenge UserFirewallAccessRuleListResponseAllowedMode = "js_challenge" - UserFirewallAccessRuleListResponseAllowedModeManagedChallenge UserFirewallAccessRuleListResponseAllowedMode = "managed_challenge" -) - -// The rule configuration. -// -// Union satisfied by -// [UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPConfiguration], -// [UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPV6Configuration], -// [UserFirewallAccessRuleListResponseConfigurationLegacyJhsCidrConfiguration], -// [UserFirewallAccessRuleListResponseConfigurationLegacyJhsASNConfiguration] or -// [UserFirewallAccessRuleListResponseConfigurationLegacyJhsCountryConfiguration]. -type UserFirewallAccessRuleListResponseConfiguration interface { - implementsUserFirewallAccessRuleListResponseConfiguration() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*UserFirewallAccessRuleListResponseConfiguration)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPV6Configuration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(UserFirewallAccessRuleListResponseConfigurationLegacyJhsCidrConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(UserFirewallAccessRuleListResponseConfigurationLegacyJhsASNConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(UserFirewallAccessRuleListResponseConfigurationLegacyJhsCountryConfiguration{}), - }, - ) -} - -type UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPConfiguration struct { - // The configuration target. You must set the target to `ip` when specifying an IP - // address in the rule. - Target UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPConfigurationTarget `json:"target"` - // The IP address to match. This address will be compared to the IP address of - // incoming requests. - Value string `json:"value"` - JSON userFirewallAccessRuleListResponseConfigurationLegacyJhsIPConfigurationJSON `json:"-"` -} - -// userFirewallAccessRuleListResponseConfigurationLegacyJhsIPConfigurationJSON -// contains the JSON metadata for the struct -// [UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPConfiguration] -type userFirewallAccessRuleListResponseConfigurationLegacyJhsIPConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleListResponseConfigurationLegacyJhsIPConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPConfiguration) implementsUserFirewallAccessRuleListResponseConfiguration() { -} - -// The configuration target. You must set the target to `ip` when specifying an IP -// address in the rule. -type UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPConfigurationTarget string - -const ( - UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPConfigurationTargetIP UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPConfigurationTarget = "ip" -) - -type UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPV6Configuration struct { - // The configuration target. You must set the target to `ip6` when specifying an - // IPv6 address in the rule. - Target UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPV6ConfigurationTarget `json:"target"` - // The IPv6 address to match. - Value string `json:"value"` - JSON userFirewallAccessRuleListResponseConfigurationLegacyJhsIPV6ConfigurationJSON `json:"-"` -} - -// userFirewallAccessRuleListResponseConfigurationLegacyJhsIPV6ConfigurationJSON -// contains the JSON metadata for the struct -// [UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPV6Configuration] -type userFirewallAccessRuleListResponseConfigurationLegacyJhsIPV6ConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPV6Configuration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleListResponseConfigurationLegacyJhsIPV6ConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPV6Configuration) implementsUserFirewallAccessRuleListResponseConfiguration() { -} - -// The configuration target. You must set the target to `ip6` when specifying an -// IPv6 address in the rule. -type UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPV6ConfigurationTarget string - -const ( - UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPV6ConfigurationTargetIp6 UserFirewallAccessRuleListResponseConfigurationLegacyJhsIPV6ConfigurationTarget = "ip6" -) - -type UserFirewallAccessRuleListResponseConfigurationLegacyJhsCidrConfiguration struct { - // The configuration target. You must set the target to `ip_range` when specifying - // an IP address range in the rule. - Target UserFirewallAccessRuleListResponseConfigurationLegacyJhsCidrConfigurationTarget `json:"target"` - // The IP address range to match. You can only use prefix lengths `/16` and `/24` - // for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. - Value string `json:"value"` - JSON userFirewallAccessRuleListResponseConfigurationLegacyJhsCidrConfigurationJSON `json:"-"` -} - -// userFirewallAccessRuleListResponseConfigurationLegacyJhsCidrConfigurationJSON -// contains the JSON metadata for the struct -// [UserFirewallAccessRuleListResponseConfigurationLegacyJhsCidrConfiguration] -type userFirewallAccessRuleListResponseConfigurationLegacyJhsCidrConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleListResponseConfigurationLegacyJhsCidrConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleListResponseConfigurationLegacyJhsCidrConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r UserFirewallAccessRuleListResponseConfigurationLegacyJhsCidrConfiguration) implementsUserFirewallAccessRuleListResponseConfiguration() { -} - -// The configuration target. You must set the target to `ip_range` when specifying -// an IP address range in the rule. -type UserFirewallAccessRuleListResponseConfigurationLegacyJhsCidrConfigurationTarget string - -const ( - UserFirewallAccessRuleListResponseConfigurationLegacyJhsCidrConfigurationTargetIPRange UserFirewallAccessRuleListResponseConfigurationLegacyJhsCidrConfigurationTarget = "ip_range" -) - -type UserFirewallAccessRuleListResponseConfigurationLegacyJhsASNConfiguration struct { - // The configuration target. You must set the target to `asn` when specifying an - // Autonomous System Number (ASN) in the rule. - Target UserFirewallAccessRuleListResponseConfigurationLegacyJhsASNConfigurationTarget `json:"target"` - // The AS number to match. - Value string `json:"value"` - JSON userFirewallAccessRuleListResponseConfigurationLegacyJhsASNConfigurationJSON `json:"-"` -} - -// userFirewallAccessRuleListResponseConfigurationLegacyJhsASNConfigurationJSON -// contains the JSON metadata for the struct -// [UserFirewallAccessRuleListResponseConfigurationLegacyJhsASNConfiguration] -type userFirewallAccessRuleListResponseConfigurationLegacyJhsASNConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleListResponseConfigurationLegacyJhsASNConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleListResponseConfigurationLegacyJhsASNConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r UserFirewallAccessRuleListResponseConfigurationLegacyJhsASNConfiguration) implementsUserFirewallAccessRuleListResponseConfiguration() { -} - -// The configuration target. You must set the target to `asn` when specifying an -// Autonomous System Number (ASN) in the rule. -type UserFirewallAccessRuleListResponseConfigurationLegacyJhsASNConfigurationTarget string - -const ( - UserFirewallAccessRuleListResponseConfigurationLegacyJhsASNConfigurationTargetASN UserFirewallAccessRuleListResponseConfigurationLegacyJhsASNConfigurationTarget = "asn" -) - -type UserFirewallAccessRuleListResponseConfigurationLegacyJhsCountryConfiguration struct { - // The configuration target. You must set the target to `country` when specifying a - // country code in the rule. - Target UserFirewallAccessRuleListResponseConfigurationLegacyJhsCountryConfigurationTarget `json:"target"` - // The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to - // [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). - Value string `json:"value"` - JSON userFirewallAccessRuleListResponseConfigurationLegacyJhsCountryConfigurationJSON `json:"-"` -} - -// userFirewallAccessRuleListResponseConfigurationLegacyJhsCountryConfigurationJSON -// contains the JSON metadata for the struct -// [UserFirewallAccessRuleListResponseConfigurationLegacyJhsCountryConfiguration] -type userFirewallAccessRuleListResponseConfigurationLegacyJhsCountryConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleListResponseConfigurationLegacyJhsCountryConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleListResponseConfigurationLegacyJhsCountryConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r UserFirewallAccessRuleListResponseConfigurationLegacyJhsCountryConfiguration) implementsUserFirewallAccessRuleListResponseConfiguration() { -} - -// The configuration target. You must set the target to `country` when specifying a -// country code in the rule. -type UserFirewallAccessRuleListResponseConfigurationLegacyJhsCountryConfigurationTarget string - -const ( - UserFirewallAccessRuleListResponseConfigurationLegacyJhsCountryConfigurationTargetCountry UserFirewallAccessRuleListResponseConfigurationLegacyJhsCountryConfigurationTarget = "country" -) - -// The action to apply to a matched request. -type UserFirewallAccessRuleListResponseMode string - -const ( - UserFirewallAccessRuleListResponseModeBlock UserFirewallAccessRuleListResponseMode = "block" - UserFirewallAccessRuleListResponseModeChallenge UserFirewallAccessRuleListResponseMode = "challenge" - UserFirewallAccessRuleListResponseModeWhitelist UserFirewallAccessRuleListResponseMode = "whitelist" - UserFirewallAccessRuleListResponseModeJsChallenge UserFirewallAccessRuleListResponseMode = "js_challenge" - UserFirewallAccessRuleListResponseModeManagedChallenge UserFirewallAccessRuleListResponseMode = "managed_challenge" -) - -type UserFirewallAccessRuleDeleteResponse struct { - // The unique identifier of the IP Access rule. - ID string `json:"id"` - JSON userFirewallAccessRuleDeleteResponseJSON `json:"-"` -} - -// userFirewallAccessRuleDeleteResponseJSON contains the JSON metadata for the -// struct [UserFirewallAccessRuleDeleteResponse] -type userFirewallAccessRuleDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type UserFirewallAccessRuleEditResponse struct { - // The unique identifier of the IP Access rule. - ID string `json:"id,required"` - // The available actions that a rule can apply to a matched request. - AllowedModes []UserFirewallAccessRuleEditResponseAllowedMode `json:"allowed_modes,required"` - // The rule configuration. - Configuration UserFirewallAccessRuleEditResponseConfiguration `json:"configuration,required"` - // The action to apply to a matched request. - Mode UserFirewallAccessRuleEditResponseMode `json:"mode,required"` - // The timestamp of when the rule was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // The timestamp of when the rule was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // An informative summary of the rule, typically used as a reminder or explanation. - Notes string `json:"notes"` - JSON userFirewallAccessRuleEditResponseJSON `json:"-"` -} - -// userFirewallAccessRuleEditResponseJSON contains the JSON metadata for the struct -// [UserFirewallAccessRuleEditResponse] -type userFirewallAccessRuleEditResponseJSON struct { - ID apijson.Field - AllowedModes apijson.Field - Configuration apijson.Field - Mode apijson.Field - CreatedOn apijson.Field - ModifiedOn apijson.Field - Notes apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleEditResponseJSON) RawJSON() string { - return r.raw -} - -// The action to apply to a matched request. -type UserFirewallAccessRuleEditResponseAllowedMode string - -const ( - UserFirewallAccessRuleEditResponseAllowedModeBlock UserFirewallAccessRuleEditResponseAllowedMode = "block" - UserFirewallAccessRuleEditResponseAllowedModeChallenge UserFirewallAccessRuleEditResponseAllowedMode = "challenge" - UserFirewallAccessRuleEditResponseAllowedModeWhitelist UserFirewallAccessRuleEditResponseAllowedMode = "whitelist" - UserFirewallAccessRuleEditResponseAllowedModeJsChallenge UserFirewallAccessRuleEditResponseAllowedMode = "js_challenge" - UserFirewallAccessRuleEditResponseAllowedModeManagedChallenge UserFirewallAccessRuleEditResponseAllowedMode = "managed_challenge" -) - -// The rule configuration. -// -// Union satisfied by -// [UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPConfiguration], -// [UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPV6Configuration], -// [UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCidrConfiguration], -// [UserFirewallAccessRuleEditResponseConfigurationLegacyJhsASNConfiguration] or -// [UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCountryConfiguration]. -type UserFirewallAccessRuleEditResponseConfiguration interface { - implementsUserFirewallAccessRuleEditResponseConfiguration() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*UserFirewallAccessRuleEditResponseConfiguration)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPV6Configuration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCidrConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(UserFirewallAccessRuleEditResponseConfigurationLegacyJhsASNConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCountryConfiguration{}), - }, - ) -} - -type UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPConfiguration struct { - // The configuration target. You must set the target to `ip` when specifying an IP - // address in the rule. - Target UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPConfigurationTarget `json:"target"` - // The IP address to match. This address will be compared to the IP address of - // incoming requests. - Value string `json:"value"` - JSON userFirewallAccessRuleEditResponseConfigurationLegacyJhsIPConfigurationJSON `json:"-"` -} - -// userFirewallAccessRuleEditResponseConfigurationLegacyJhsIPConfigurationJSON -// contains the JSON metadata for the struct -// [UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPConfiguration] -type userFirewallAccessRuleEditResponseConfigurationLegacyJhsIPConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleEditResponseConfigurationLegacyJhsIPConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPConfiguration) implementsUserFirewallAccessRuleEditResponseConfiguration() { -} - -// The configuration target. You must set the target to `ip` when specifying an IP -// address in the rule. -type UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPConfigurationTarget string - -const ( - UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPConfigurationTargetIP UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPConfigurationTarget = "ip" -) - -type UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPV6Configuration struct { - // The configuration target. You must set the target to `ip6` when specifying an - // IPv6 address in the rule. - Target UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPV6ConfigurationTarget `json:"target"` - // The IPv6 address to match. - Value string `json:"value"` - JSON userFirewallAccessRuleEditResponseConfigurationLegacyJhsIPV6ConfigurationJSON `json:"-"` -} - -// userFirewallAccessRuleEditResponseConfigurationLegacyJhsIPV6ConfigurationJSON -// contains the JSON metadata for the struct -// [UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPV6Configuration] -type userFirewallAccessRuleEditResponseConfigurationLegacyJhsIPV6ConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPV6Configuration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleEditResponseConfigurationLegacyJhsIPV6ConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPV6Configuration) implementsUserFirewallAccessRuleEditResponseConfiguration() { -} - -// The configuration target. You must set the target to `ip6` when specifying an -// IPv6 address in the rule. -type UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPV6ConfigurationTarget string - -const ( - UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPV6ConfigurationTargetIp6 UserFirewallAccessRuleEditResponseConfigurationLegacyJhsIPV6ConfigurationTarget = "ip6" -) - -type UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCidrConfiguration struct { - // The configuration target. You must set the target to `ip_range` when specifying - // an IP address range in the rule. - Target UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCidrConfigurationTarget `json:"target"` - // The IP address range to match. You can only use prefix lengths `/16` and `/24` - // for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. - Value string `json:"value"` - JSON userFirewallAccessRuleEditResponseConfigurationLegacyJhsCidrConfigurationJSON `json:"-"` -} - -// userFirewallAccessRuleEditResponseConfigurationLegacyJhsCidrConfigurationJSON -// contains the JSON metadata for the struct -// [UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCidrConfiguration] -type userFirewallAccessRuleEditResponseConfigurationLegacyJhsCidrConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCidrConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleEditResponseConfigurationLegacyJhsCidrConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCidrConfiguration) implementsUserFirewallAccessRuleEditResponseConfiguration() { -} - -// The configuration target. You must set the target to `ip_range` when specifying -// an IP address range in the rule. -type UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCidrConfigurationTarget string - -const ( - UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCidrConfigurationTargetIPRange UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCidrConfigurationTarget = "ip_range" -) - -type UserFirewallAccessRuleEditResponseConfigurationLegacyJhsASNConfiguration struct { - // The configuration target. You must set the target to `asn` when specifying an - // Autonomous System Number (ASN) in the rule. - Target UserFirewallAccessRuleEditResponseConfigurationLegacyJhsASNConfigurationTarget `json:"target"` - // The AS number to match. - Value string `json:"value"` - JSON userFirewallAccessRuleEditResponseConfigurationLegacyJhsASNConfigurationJSON `json:"-"` -} - -// userFirewallAccessRuleEditResponseConfigurationLegacyJhsASNConfigurationJSON -// contains the JSON metadata for the struct -// [UserFirewallAccessRuleEditResponseConfigurationLegacyJhsASNConfiguration] -type userFirewallAccessRuleEditResponseConfigurationLegacyJhsASNConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleEditResponseConfigurationLegacyJhsASNConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleEditResponseConfigurationLegacyJhsASNConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r UserFirewallAccessRuleEditResponseConfigurationLegacyJhsASNConfiguration) implementsUserFirewallAccessRuleEditResponseConfiguration() { -} - -// The configuration target. You must set the target to `asn` when specifying an -// Autonomous System Number (ASN) in the rule. -type UserFirewallAccessRuleEditResponseConfigurationLegacyJhsASNConfigurationTarget string - -const ( - UserFirewallAccessRuleEditResponseConfigurationLegacyJhsASNConfigurationTargetASN UserFirewallAccessRuleEditResponseConfigurationLegacyJhsASNConfigurationTarget = "asn" -) - -type UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCountryConfiguration struct { - // The configuration target. You must set the target to `country` when specifying a - // country code in the rule. - Target UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCountryConfigurationTarget `json:"target"` - // The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to - // [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). - Value string `json:"value"` - JSON userFirewallAccessRuleEditResponseConfigurationLegacyJhsCountryConfigurationJSON `json:"-"` -} - -// userFirewallAccessRuleEditResponseConfigurationLegacyJhsCountryConfigurationJSON -// contains the JSON metadata for the struct -// [UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCountryConfiguration] -type userFirewallAccessRuleEditResponseConfigurationLegacyJhsCountryConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCountryConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleEditResponseConfigurationLegacyJhsCountryConfigurationJSON) RawJSON() string { - return r.raw -} - -func (r UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCountryConfiguration) implementsUserFirewallAccessRuleEditResponseConfiguration() { -} - -// The configuration target. You must set the target to `country` when specifying a -// country code in the rule. -type UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCountryConfigurationTarget string - -const ( - UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCountryConfigurationTargetCountry UserFirewallAccessRuleEditResponseConfigurationLegacyJhsCountryConfigurationTarget = "country" -) - -// The action to apply to a matched request. -type UserFirewallAccessRuleEditResponseMode string - -const ( - UserFirewallAccessRuleEditResponseModeBlock UserFirewallAccessRuleEditResponseMode = "block" - UserFirewallAccessRuleEditResponseModeChallenge UserFirewallAccessRuleEditResponseMode = "challenge" - UserFirewallAccessRuleEditResponseModeWhitelist UserFirewallAccessRuleEditResponseMode = "whitelist" - UserFirewallAccessRuleEditResponseModeJsChallenge UserFirewallAccessRuleEditResponseMode = "js_challenge" - UserFirewallAccessRuleEditResponseModeManagedChallenge UserFirewallAccessRuleEditResponseMode = "managed_challenge" -) - -type UserFirewallAccessRuleNewParams struct { - // The rule configuration. - Configuration param.Field[UserFirewallAccessRuleNewParamsConfiguration] `json:"configuration,required"` - // The action to apply to a matched request. - Mode param.Field[UserFirewallAccessRuleNewParamsMode] `json:"mode,required"` - // An informative summary of the rule, typically used as a reminder or explanation. - Notes param.Field[string] `json:"notes"` -} - -func (r UserFirewallAccessRuleNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The rule configuration. -// -// Satisfied by -// [UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration], -// [UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration], -// [UserFirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfiguration], -// [UserFirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfiguration], -// [UserFirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration]. -type UserFirewallAccessRuleNewParamsConfiguration interface { - implementsUserFirewallAccessRuleNewParamsConfiguration() -} - -type UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration struct { - // The configuration target. You must set the target to `ip` when specifying an IP - // address in the rule. - Target param.Field[UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget] `json:"target"` - // The IP address to match. This address will be compared to the IP address of - // incoming requests. - Value param.Field[string] `json:"value"` -} - -func (r UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration) implementsUserFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `ip` when specifying an IP -// address in the rule. -type UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget string - -const ( - UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTargetIP UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTarget = "ip" -) - -type UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration struct { - // The configuration target. You must set the target to `ip6` when specifying an - // IPv6 address in the rule. - Target param.Field[UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget] `json:"target"` - // The IPv6 address to match. - Value param.Field[string] `json:"value"` -} - -func (r UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6Configuration) implementsUserFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `ip6` when specifying an -// IPv6 address in the rule. -type UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget string - -const ( - UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTargetIp6 UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPV6ConfigurationTarget = "ip6" -) - -type UserFirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfiguration struct { - // The configuration target. You must set the target to `ip_range` when specifying - // an IP address range in the rule. - Target param.Field[UserFirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfigurationTarget] `json:"target"` - // The IP address range to match. You can only use prefix lengths `/16` and `/24` - // for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. - Value param.Field[string] `json:"value"` -} - -func (r UserFirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r UserFirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfiguration) implementsUserFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `ip_range` when specifying -// an IP address range in the rule. -type UserFirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfigurationTarget string - -const ( - UserFirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfigurationTargetIPRange UserFirewallAccessRuleNewParamsConfigurationLegacyJhsCidrConfigurationTarget = "ip_range" -) - -type UserFirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfiguration struct { - // The configuration target. You must set the target to `asn` when specifying an - // Autonomous System Number (ASN) in the rule. - Target param.Field[UserFirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget] `json:"target"` - // The AS number to match. - Value param.Field[string] `json:"value"` -} - -func (r UserFirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r UserFirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfiguration) implementsUserFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `asn` when specifying an -// Autonomous System Number (ASN) in the rule. -type UserFirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget string - -const ( - UserFirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTargetASN UserFirewallAccessRuleNewParamsConfigurationLegacyJhsASNConfigurationTarget = "asn" -) - -type UserFirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration struct { - // The configuration target. You must set the target to `country` when specifying a - // country code in the rule. - Target param.Field[UserFirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget] `json:"target"` - // The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to - // [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). - Value param.Field[string] `json:"value"` -} - -func (r UserFirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r UserFirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfiguration) implementsUserFirewallAccessRuleNewParamsConfiguration() { -} - -// The configuration target. You must set the target to `country` when specifying a -// country code in the rule. -type UserFirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget string - -const ( - UserFirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTargetCountry UserFirewallAccessRuleNewParamsConfigurationLegacyJhsCountryConfigurationTarget = "country" -) - -// The action to apply to a matched request. -type UserFirewallAccessRuleNewParamsMode string - -const ( - UserFirewallAccessRuleNewParamsModeBlock UserFirewallAccessRuleNewParamsMode = "block" - UserFirewallAccessRuleNewParamsModeChallenge UserFirewallAccessRuleNewParamsMode = "challenge" - UserFirewallAccessRuleNewParamsModeWhitelist UserFirewallAccessRuleNewParamsMode = "whitelist" - UserFirewallAccessRuleNewParamsModeJsChallenge UserFirewallAccessRuleNewParamsMode = "js_challenge" - UserFirewallAccessRuleNewParamsModeManagedChallenge UserFirewallAccessRuleNewParamsMode = "managed_challenge" -) - -type UserFirewallAccessRuleNewResponseEnvelope struct { - Errors []UserFirewallAccessRuleNewResponseEnvelopeErrors `json:"errors,required"` - Messages []UserFirewallAccessRuleNewResponseEnvelopeMessages `json:"messages,required"` - Result UserFirewallAccessRuleNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success UserFirewallAccessRuleNewResponseEnvelopeSuccess `json:"success,required"` - JSON userFirewallAccessRuleNewResponseEnvelopeJSON `json:"-"` -} - -// userFirewallAccessRuleNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [UserFirewallAccessRuleNewResponseEnvelope] -type userFirewallAccessRuleNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserFirewallAccessRuleNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userFirewallAccessRuleNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// userFirewallAccessRuleNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [UserFirewallAccessRuleNewResponseEnvelopeErrors] -type userFirewallAccessRuleNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserFirewallAccessRuleNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userFirewallAccessRuleNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// userFirewallAccessRuleNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [UserFirewallAccessRuleNewResponseEnvelopeMessages] -type userFirewallAccessRuleNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserFirewallAccessRuleNewResponseEnvelopeSuccess bool - -const ( - UserFirewallAccessRuleNewResponseEnvelopeSuccessTrue UserFirewallAccessRuleNewResponseEnvelopeSuccess = true -) - -type UserFirewallAccessRuleListParams struct { - // The direction used to sort returned rules. - Direction param.Field[UserFirewallAccessRuleListParamsDirection] `query:"direction"` - EgsPagination param.Field[UserFirewallAccessRuleListParamsEgsPagination] `query:"egs-pagination"` - Filters param.Field[UserFirewallAccessRuleListParamsFilters] `query:"filters"` - // The field used to sort returned rules. - Order param.Field[UserFirewallAccessRuleListParamsOrder] `query:"order"` - // Requested page within paginated list of results. - Page param.Field[float64] `query:"page"` - // Maximum number of results requested. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [UserFirewallAccessRuleListParams]'s query parameters as -// `url.Values`. -func (r UserFirewallAccessRuleListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// The direction used to sort returned rules. -type UserFirewallAccessRuleListParamsDirection string - -const ( - UserFirewallAccessRuleListParamsDirectionAsc UserFirewallAccessRuleListParamsDirection = "asc" - UserFirewallAccessRuleListParamsDirectionDesc UserFirewallAccessRuleListParamsDirection = "desc" -) - -type UserFirewallAccessRuleListParamsEgsPagination struct { - Json param.Field[UserFirewallAccessRuleListParamsEgsPaginationJson] `query:"json"` -} - -// URLQuery serializes [UserFirewallAccessRuleListParamsEgsPagination]'s query -// parameters as `url.Values`. -func (r UserFirewallAccessRuleListParamsEgsPagination) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type UserFirewallAccessRuleListParamsEgsPaginationJson struct { - // The page number of paginated results. - Page param.Field[float64] `query:"page"` - // The maximum number of results per page. You can only set the value to `1` or to - // a multiple of 5 such as `5`, `10`, `15`, or `20`. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [UserFirewallAccessRuleListParamsEgsPaginationJson]'s query -// parameters as `url.Values`. -func (r UserFirewallAccessRuleListParamsEgsPaginationJson) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type UserFirewallAccessRuleListParamsFilters struct { - // The target to search in existing rules. - ConfigurationTarget param.Field[UserFirewallAccessRuleListParamsFiltersConfigurationTarget] `query:"configuration.target"` - // The target value to search for in existing rules: an IP address, an IP address - // range, or a country code, depending on the provided `configuration.target`. - // Notes: You can search for a single IPv4 address, an IP address range with a - // subnet of '/16' or '/24', or a two-letter ISO-3166-1 alpha-2 country code. - ConfigurationValue param.Field[string] `query:"configuration.value"` - // When set to `all`, all the search requirements must match. When set to `any`, - // only one of the search requirements has to match. - Match param.Field[UserFirewallAccessRuleListParamsFiltersMatch] `query:"match"` - // The action to apply to a matched request. - Mode param.Field[UserFirewallAccessRuleListParamsFiltersMode] `query:"mode"` - // The string to search for in the notes of existing IP Access rules. Notes: For - // example, the string 'attack' would match IP Access rules with notes 'Attack - // 26/02' and 'Attack 27/02'. The search is case insensitive. - Notes param.Field[string] `query:"notes"` -} - -// URLQuery serializes [UserFirewallAccessRuleListParamsFilters]'s query parameters -// as `url.Values`. -func (r UserFirewallAccessRuleListParamsFilters) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// The target to search in existing rules. -type UserFirewallAccessRuleListParamsFiltersConfigurationTarget string - -const ( - UserFirewallAccessRuleListParamsFiltersConfigurationTargetIP UserFirewallAccessRuleListParamsFiltersConfigurationTarget = "ip" - UserFirewallAccessRuleListParamsFiltersConfigurationTargetIPRange UserFirewallAccessRuleListParamsFiltersConfigurationTarget = "ip_range" - UserFirewallAccessRuleListParamsFiltersConfigurationTargetASN UserFirewallAccessRuleListParamsFiltersConfigurationTarget = "asn" - UserFirewallAccessRuleListParamsFiltersConfigurationTargetCountry UserFirewallAccessRuleListParamsFiltersConfigurationTarget = "country" -) - -// When set to `all`, all the search requirements must match. When set to `any`, -// only one of the search requirements has to match. -type UserFirewallAccessRuleListParamsFiltersMatch string - -const ( - UserFirewallAccessRuleListParamsFiltersMatchAny UserFirewallAccessRuleListParamsFiltersMatch = "any" - UserFirewallAccessRuleListParamsFiltersMatchAll UserFirewallAccessRuleListParamsFiltersMatch = "all" -) - -// The action to apply to a matched request. -type UserFirewallAccessRuleListParamsFiltersMode string - -const ( - UserFirewallAccessRuleListParamsFiltersModeBlock UserFirewallAccessRuleListParamsFiltersMode = "block" - UserFirewallAccessRuleListParamsFiltersModeChallenge UserFirewallAccessRuleListParamsFiltersMode = "challenge" - UserFirewallAccessRuleListParamsFiltersModeWhitelist UserFirewallAccessRuleListParamsFiltersMode = "whitelist" - UserFirewallAccessRuleListParamsFiltersModeJsChallenge UserFirewallAccessRuleListParamsFiltersMode = "js_challenge" - UserFirewallAccessRuleListParamsFiltersModeManagedChallenge UserFirewallAccessRuleListParamsFiltersMode = "managed_challenge" -) - -// The field used to sort returned rules. -type UserFirewallAccessRuleListParamsOrder string - -const ( - UserFirewallAccessRuleListParamsOrderConfigurationTarget UserFirewallAccessRuleListParamsOrder = "configuration.target" - UserFirewallAccessRuleListParamsOrderConfigurationValue UserFirewallAccessRuleListParamsOrder = "configuration.value" - UserFirewallAccessRuleListParamsOrderMode UserFirewallAccessRuleListParamsOrder = "mode" -) - -type UserFirewallAccessRuleDeleteResponseEnvelope struct { - Errors []UserFirewallAccessRuleDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []UserFirewallAccessRuleDeleteResponseEnvelopeMessages `json:"messages,required"` - Result UserFirewallAccessRuleDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success UserFirewallAccessRuleDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON userFirewallAccessRuleDeleteResponseEnvelopeJSON `json:"-"` -} - -// userFirewallAccessRuleDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [UserFirewallAccessRuleDeleteResponseEnvelope] -type userFirewallAccessRuleDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserFirewallAccessRuleDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userFirewallAccessRuleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// userFirewallAccessRuleDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [UserFirewallAccessRuleDeleteResponseEnvelopeErrors] -type userFirewallAccessRuleDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserFirewallAccessRuleDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userFirewallAccessRuleDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// userFirewallAccessRuleDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [UserFirewallAccessRuleDeleteResponseEnvelopeMessages] -type userFirewallAccessRuleDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserFirewallAccessRuleDeleteResponseEnvelopeSuccess bool - -const ( - UserFirewallAccessRuleDeleteResponseEnvelopeSuccessTrue UserFirewallAccessRuleDeleteResponseEnvelopeSuccess = true -) - -type UserFirewallAccessRuleEditParams struct { - // The action to apply to a matched request. - Mode param.Field[UserFirewallAccessRuleEditParamsMode] `json:"mode"` - // An informative summary of the rule, typically used as a reminder or explanation. - Notes param.Field[string] `json:"notes"` -} - -func (r UserFirewallAccessRuleEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The action to apply to a matched request. -type UserFirewallAccessRuleEditParamsMode string - -const ( - UserFirewallAccessRuleEditParamsModeBlock UserFirewallAccessRuleEditParamsMode = "block" - UserFirewallAccessRuleEditParamsModeChallenge UserFirewallAccessRuleEditParamsMode = "challenge" - UserFirewallAccessRuleEditParamsModeWhitelist UserFirewallAccessRuleEditParamsMode = "whitelist" - UserFirewallAccessRuleEditParamsModeJsChallenge UserFirewallAccessRuleEditParamsMode = "js_challenge" - UserFirewallAccessRuleEditParamsModeManagedChallenge UserFirewallAccessRuleEditParamsMode = "managed_challenge" -) - -type UserFirewallAccessRuleEditResponseEnvelope struct { - Errors []UserFirewallAccessRuleEditResponseEnvelopeErrors `json:"errors,required"` - Messages []UserFirewallAccessRuleEditResponseEnvelopeMessages `json:"messages,required"` - Result UserFirewallAccessRuleEditResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success UserFirewallAccessRuleEditResponseEnvelopeSuccess `json:"success,required"` - JSON userFirewallAccessRuleEditResponseEnvelopeJSON `json:"-"` -} - -// userFirewallAccessRuleEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [UserFirewallAccessRuleEditResponseEnvelope] -type userFirewallAccessRuleEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserFirewallAccessRuleEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userFirewallAccessRuleEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// userFirewallAccessRuleEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [UserFirewallAccessRuleEditResponseEnvelopeErrors] -type userFirewallAccessRuleEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserFirewallAccessRuleEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userFirewallAccessRuleEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// userFirewallAccessRuleEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [UserFirewallAccessRuleEditResponseEnvelopeMessages] -type userFirewallAccessRuleEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserFirewallAccessRuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userFirewallAccessRuleEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserFirewallAccessRuleEditResponseEnvelopeSuccess bool - -const ( - UserFirewallAccessRuleEditResponseEnvelopeSuccessTrue UserFirewallAccessRuleEditResponseEnvelopeSuccess = true -) diff --git a/userfirewallaccessrule_test.go b/userfirewallaccessrule_test.go deleted file mode 100644 index ae89d8e95a4..00000000000 --- a/userfirewallaccessrule_test.go +++ /dev/null @@ -1,142 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestUserFirewallAccessRuleNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.Firewall.AccessRules.New(context.TODO(), cloudflare.UserFirewallAccessRuleNewParams{ - Configuration: cloudflare.F[cloudflare.UserFirewallAccessRuleNewParamsConfiguration](cloudflare.UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration(cloudflare.UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfiguration{ - Target: cloudflare.F(cloudflare.UserFirewallAccessRuleNewParamsConfigurationLegacyJhsIPConfigurationTargetIP), - Value: cloudflare.F("198.51.100.4"), - })), - Mode: cloudflare.F(cloudflare.UserFirewallAccessRuleNewParamsModeChallenge), - Notes: cloudflare.F("This rule is enabled because of an event that occurred on date X."), - }) - 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 TestUserFirewallAccessRuleListWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.Firewall.AccessRules.List(context.TODO(), cloudflare.UserFirewallAccessRuleListParams{ - Direction: cloudflare.F(cloudflare.UserFirewallAccessRuleListParamsDirectionDesc), - EgsPagination: cloudflare.F(cloudflare.UserFirewallAccessRuleListParamsEgsPagination{ - Json: cloudflare.F(cloudflare.UserFirewallAccessRuleListParamsEgsPaginationJson{ - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(1.000000), - }), - }), - Filters: cloudflare.F(cloudflare.UserFirewallAccessRuleListParamsFilters{ - ConfigurationTarget: cloudflare.F(cloudflare.UserFirewallAccessRuleListParamsFiltersConfigurationTargetIP), - ConfigurationValue: cloudflare.F("198.51.100.4"), - Match: cloudflare.F(cloudflare.UserFirewallAccessRuleListParamsFiltersMatchAny), - Mode: cloudflare.F(cloudflare.UserFirewallAccessRuleListParamsFiltersModeChallenge), - Notes: cloudflare.F("my note"), - }), - Order: cloudflare.F(cloudflare.UserFirewallAccessRuleListParamsOrderMode), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(20.000000), - }) - 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 TestUserFirewallAccessRuleDelete(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("user@example.com"), - ) - _, err := client.User.Firewall.AccessRules.Delete(context.TODO(), "92f17202ed8bd63d69a66b86a49a8f6b") - 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 TestUserFirewallAccessRuleEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.Firewall.AccessRules.Edit( - context.TODO(), - "92f17202ed8bd63d69a66b86a49a8f6b", - cloudflare.UserFirewallAccessRuleEditParams{ - Mode: cloudflare.F(cloudflare.UserFirewallAccessRuleEditParamsModeChallenge), - Notes: cloudflare.F("This rule is enabled because of an event that occurred on date X."), - }, - ) - 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/userinvite.go b/userinvite.go deleted file mode 100644 index 6a41ff8317f..00000000000 --- a/userinvite.go +++ /dev/null @@ -1,489 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// UserInviteService 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 [NewUserInviteService] method instead. -type UserInviteService struct { - Options []option.RequestOption -} - -// NewUserInviteService 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 NewUserInviteService(opts ...option.RequestOption) (r *UserInviteService) { - r = &UserInviteService{} - r.Options = opts - return -} - -// Lists all invitations associated with my user. -func (r *UserInviteService) List(ctx context.Context, opts ...option.RequestOption) (res *[]UserInviteListResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserInviteListResponseEnvelope - path := "user/invites" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Responds to an invitation. -func (r *UserInviteService) Edit(ctx context.Context, inviteID string, body UserInviteEditParams, opts ...option.RequestOption) (res *UserInviteEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserInviteEditResponseEnvelope - path := fmt.Sprintf("user/invites/%s", inviteID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets the details of an invitation. -func (r *UserInviteService) Get(ctx context.Context, inviteID string, opts ...option.RequestOption) (res *UserInviteGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserInviteGetResponseEnvelope - path := fmt.Sprintf("user/invites/%s", inviteID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type UserInviteListResponse struct { - // ID of the user to add to the organization. - InvitedMemberID string `json:"invited_member_id,required,nullable"` - // ID of the organization the user will be added to. - OrganizationID string `json:"organization_id,required"` - // Invite identifier tag. - ID string `json:"id"` - // When the invite is no longer active. - ExpiresOn time.Time `json:"expires_on" format:"date-time"` - // The email address of the user who created the invite. - InvitedBy string `json:"invited_by"` - // Email address of the user to add to the organization. - InvitedMemberEmail string `json:"invited_member_email"` - // When the invite was sent. - InvitedOn time.Time `json:"invited_on" format:"date-time"` - // Organization name. - OrganizationName string `json:"organization_name"` - // Roles to be assigned to this user. - Roles []UserInviteListResponseRole `json:"roles"` - // Current status of the invitation. - Status UserInviteListResponseStatus `json:"status"` - JSON userInviteListResponseJSON `json:"-"` -} - -// userInviteListResponseJSON contains the JSON metadata for the struct -// [UserInviteListResponse] -type userInviteListResponseJSON struct { - InvitedMemberID apijson.Field - OrganizationID apijson.Field - ID apijson.Field - ExpiresOn apijson.Field - InvitedBy apijson.Field - InvitedMemberEmail apijson.Field - InvitedOn apijson.Field - OrganizationName apijson.Field - Roles apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserInviteListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userInviteListResponseJSON) RawJSON() string { - return r.raw -} - -type UserInviteListResponseRole struct { - // Role identifier tag. - ID string `json:"id,required"` - // Description of role's permissions. - Description string `json:"description,required"` - // Role Name. - Name string `json:"name,required"` - // Access permissions for this User. - Permissions []string `json:"permissions,required"` - JSON userInviteListResponseRoleJSON `json:"-"` -} - -// userInviteListResponseRoleJSON contains the JSON metadata for the struct -// [UserInviteListResponseRole] -type userInviteListResponseRoleJSON struct { - ID apijson.Field - Description apijson.Field - Name apijson.Field - Permissions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserInviteListResponseRole) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userInviteListResponseRoleJSON) RawJSON() string { - return r.raw -} - -// Current status of the invitation. -type UserInviteListResponseStatus string - -const ( - UserInviteListResponseStatusPending UserInviteListResponseStatus = "pending" - UserInviteListResponseStatusAccepted UserInviteListResponseStatus = "accepted" - UserInviteListResponseStatusRejected UserInviteListResponseStatus = "rejected" - UserInviteListResponseStatusExpired UserInviteListResponseStatus = "expired" -) - -// Union satisfied by [UserInviteEditResponseUnknown] or [shared.UnionString]. -type UserInviteEditResponse interface { - ImplementsUserInviteEditResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*UserInviteEditResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [UserInviteGetResponseUnknown] or [shared.UnionString]. -type UserInviteGetResponse interface { - ImplementsUserInviteGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*UserInviteGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type UserInviteListResponseEnvelope struct { - Errors []UserInviteListResponseEnvelopeErrors `json:"errors,required"` - Messages []UserInviteListResponseEnvelopeMessages `json:"messages,required"` - Result []UserInviteListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success UserInviteListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo UserInviteListResponseEnvelopeResultInfo `json:"result_info"` - JSON userInviteListResponseEnvelopeJSON `json:"-"` -} - -// userInviteListResponseEnvelopeJSON contains the JSON metadata for the struct -// [UserInviteListResponseEnvelope] -type userInviteListResponseEnvelopeJSON 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 *UserInviteListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userInviteListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserInviteListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userInviteListResponseEnvelopeErrorsJSON `json:"-"` -} - -// userInviteListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [UserInviteListResponseEnvelopeErrors] -type userInviteListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserInviteListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userInviteListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserInviteListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userInviteListResponseEnvelopeMessagesJSON `json:"-"` -} - -// userInviteListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [UserInviteListResponseEnvelopeMessages] -type userInviteListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserInviteListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userInviteListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserInviteListResponseEnvelopeSuccess bool - -const ( - UserInviteListResponseEnvelopeSuccessTrue UserInviteListResponseEnvelopeSuccess = true -) - -type UserInviteListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON userInviteListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// userInviteListResponseEnvelopeResultInfoJSON contains the JSON metadata for the -// struct [UserInviteListResponseEnvelopeResultInfo] -type userInviteListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserInviteListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userInviteListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type UserInviteEditParams struct { - // Status of your response to the invitation (rejected or accepted). - Status param.Field[UserInviteEditParamsStatus] `json:"status,required"` -} - -func (r UserInviteEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Status of your response to the invitation (rejected or accepted). -type UserInviteEditParamsStatus string - -const ( - UserInviteEditParamsStatusAccepted UserInviteEditParamsStatus = "accepted" - UserInviteEditParamsStatusRejected UserInviteEditParamsStatus = "rejected" -) - -type UserInviteEditResponseEnvelope struct { - Errors []UserInviteEditResponseEnvelopeErrors `json:"errors,required"` - Messages []UserInviteEditResponseEnvelopeMessages `json:"messages,required"` - Result UserInviteEditResponse `json:"result,required"` - // Whether the API call was successful - Success UserInviteEditResponseEnvelopeSuccess `json:"success,required"` - JSON userInviteEditResponseEnvelopeJSON `json:"-"` -} - -// userInviteEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [UserInviteEditResponseEnvelope] -type userInviteEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserInviteEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userInviteEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserInviteEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userInviteEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// userInviteEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [UserInviteEditResponseEnvelopeErrors] -type userInviteEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserInviteEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userInviteEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserInviteEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userInviteEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// userInviteEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [UserInviteEditResponseEnvelopeMessages] -type userInviteEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserInviteEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userInviteEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserInviteEditResponseEnvelopeSuccess bool - -const ( - UserInviteEditResponseEnvelopeSuccessTrue UserInviteEditResponseEnvelopeSuccess = true -) - -type UserInviteGetResponseEnvelope struct { - Errors []UserInviteGetResponseEnvelopeErrors `json:"errors,required"` - Messages []UserInviteGetResponseEnvelopeMessages `json:"messages,required"` - Result UserInviteGetResponse `json:"result,required"` - // Whether the API call was successful - Success UserInviteGetResponseEnvelopeSuccess `json:"success,required"` - JSON userInviteGetResponseEnvelopeJSON `json:"-"` -} - -// userInviteGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [UserInviteGetResponseEnvelope] -type userInviteGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserInviteGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userInviteGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserInviteGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userInviteGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// userInviteGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [UserInviteGetResponseEnvelopeErrors] -type userInviteGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserInviteGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userInviteGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserInviteGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userInviteGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// userInviteGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [UserInviteGetResponseEnvelopeMessages] -type userInviteGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserInviteGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userInviteGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserInviteGetResponseEnvelopeSuccess bool - -const ( - UserInviteGetResponseEnvelopeSuccessTrue UserInviteGetResponseEnvelopeSuccess = true -) diff --git a/userinvite_test.go b/userinvite_test.go deleted file mode 100644 index ec1bf8666c7..00000000000 --- a/userinvite_test.go +++ /dev/null @@ -1,92 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestUserInviteList(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("user@example.com"), - ) - _, err := client.User.Invites.List(context.TODO()) - 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 TestUserInviteEdit(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("user@example.com"), - ) - _, err := client.User.Invites.Edit( - context.TODO(), - "4f5f0c14a2a41d5063dd301b2f829f04", - cloudflare.UserInviteEditParams{ - Status: cloudflare.F(cloudflare.UserInviteEditParamsStatusAccepted), - }, - ) - 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 TestUserInviteGet(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("user@example.com"), - ) - _, err := client.User.Invites.Get(context.TODO(), "4f5f0c14a2a41d5063dd301b2f829f04") - 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/userloadbalancer.go b/userloadbalancer.go deleted file mode 100644 index 4d11e2596a8..00000000000 --- a/userloadbalancer.go +++ /dev/null @@ -1,33 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// UserLoadBalancerService 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 [NewUserLoadBalancerService] method -// instead. -type UserLoadBalancerService struct { - Options []option.RequestOption - Monitors *UserLoadBalancerMonitorService - Pools *UserLoadBalancerPoolService - Preview *UserLoadBalancerPreviewService - Analytics *UserLoadBalancerAnalyticsService -} - -// NewUserLoadBalancerService 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 NewUserLoadBalancerService(opts ...option.RequestOption) (r *UserLoadBalancerService) { - r = &UserLoadBalancerService{} - r.Options = opts - r.Monitors = NewUserLoadBalancerMonitorService(opts...) - r.Pools = NewUserLoadBalancerPoolService(opts...) - r.Preview = NewUserLoadBalancerPreviewService(opts...) - r.Analytics = NewUserLoadBalancerAnalyticsService(opts...) - return -} diff --git a/userloadbalanceranalytics.go b/userloadbalanceranalytics.go deleted file mode 100644 index 2d0c0ae4db8..00000000000 --- a/userloadbalanceranalytics.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// UserLoadBalancerAnalyticsService 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 -// [NewUserLoadBalancerAnalyticsService] method instead. -type UserLoadBalancerAnalyticsService struct { - Options []option.RequestOption - Events *UserLoadBalancerAnalyticsEventService -} - -// NewUserLoadBalancerAnalyticsService 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 NewUserLoadBalancerAnalyticsService(opts ...option.RequestOption) (r *UserLoadBalancerAnalyticsService) { - r = &UserLoadBalancerAnalyticsService{} - r.Options = opts - r.Events = NewUserLoadBalancerAnalyticsEventService(opts...) - return -} diff --git a/userloadbalanceranalyticsevent.go b/userloadbalanceranalyticsevent.go deleted file mode 100644 index 42e4e154547..00000000000 --- a/userloadbalanceranalyticsevent.go +++ /dev/null @@ -1,218 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// UserLoadBalancerAnalyticsEventService 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 -// [NewUserLoadBalancerAnalyticsEventService] method instead. -type UserLoadBalancerAnalyticsEventService struct { - Options []option.RequestOption -} - -// NewUserLoadBalancerAnalyticsEventService 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 NewUserLoadBalancerAnalyticsEventService(opts ...option.RequestOption) (r *UserLoadBalancerAnalyticsEventService) { - r = &UserLoadBalancerAnalyticsEventService{} - r.Options = opts - return -} - -// List origin health changes. -func (r *UserLoadBalancerAnalyticsEventService) List(ctx context.Context, query UserLoadBalancerAnalyticsEventListParams, opts ...option.RequestOption) (res *[]UserLoadBalancerAnalyticsEventListResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerAnalyticsEventListResponseEnvelope - path := "user/load_balancing_analytics/events" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type UserLoadBalancerAnalyticsEventListResponse struct { - ID int64 `json:"id"` - Origins []interface{} `json:"origins"` - Pool interface{} `json:"pool"` - Timestamp time.Time `json:"timestamp" format:"date-time"` - JSON userLoadBalancerAnalyticsEventListResponseJSON `json:"-"` -} - -// userLoadBalancerAnalyticsEventListResponseJSON contains the JSON metadata for -// the struct [UserLoadBalancerAnalyticsEventListResponse] -type userLoadBalancerAnalyticsEventListResponseJSON struct { - ID apijson.Field - Origins apijson.Field - Pool apijson.Field - Timestamp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerAnalyticsEventListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerAnalyticsEventListResponseJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerAnalyticsEventListParams struct { - // If true, filter events where the origin status is healthy. If false, filter - // events where the origin status is unhealthy. - OriginHealthy param.Field[bool] `query:"origin_healthy"` - // The name for the origin to filter. - OriginName param.Field[string] `query:"origin_name"` - // If true, filter events where the pool status is healthy. If false, filter events - // where the pool status is unhealthy. - PoolHealthy param.Field[bool] `query:"pool_healthy"` - PoolID param.Field[string] `query:"pool_id"` - // The name for the pool to filter. - PoolName param.Field[string] `query:"pool_name"` - // Start date and time of requesting data period in the ISO8601 format. - Since param.Field[time.Time] `query:"since" format:"date-time"` - // End date and time of requesting data period in the ISO8601 format. - Until param.Field[time.Time] `query:"until" format:"date-time"` -} - -// URLQuery serializes [UserLoadBalancerAnalyticsEventListParams]'s query -// parameters as `url.Values`. -func (r UserLoadBalancerAnalyticsEventListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type UserLoadBalancerAnalyticsEventListResponseEnvelope struct { - Errors []UserLoadBalancerAnalyticsEventListResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerAnalyticsEventListResponseEnvelopeMessages `json:"messages,required"` - Result []UserLoadBalancerAnalyticsEventListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success UserLoadBalancerAnalyticsEventListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo UserLoadBalancerAnalyticsEventListResponseEnvelopeResultInfo `json:"result_info"` - JSON userLoadBalancerAnalyticsEventListResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerAnalyticsEventListResponseEnvelopeJSON contains the JSON -// metadata for the struct [UserLoadBalancerAnalyticsEventListResponseEnvelope] -type userLoadBalancerAnalyticsEventListResponseEnvelopeJSON 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 *UserLoadBalancerAnalyticsEventListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerAnalyticsEventListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerAnalyticsEventListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerAnalyticsEventListResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerAnalyticsEventListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [UserLoadBalancerAnalyticsEventListResponseEnvelopeErrors] -type userLoadBalancerAnalyticsEventListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerAnalyticsEventListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerAnalyticsEventListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerAnalyticsEventListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerAnalyticsEventListResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerAnalyticsEventListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [UserLoadBalancerAnalyticsEventListResponseEnvelopeMessages] -type userLoadBalancerAnalyticsEventListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerAnalyticsEventListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerAnalyticsEventListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerAnalyticsEventListResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerAnalyticsEventListResponseEnvelopeSuccessTrue UserLoadBalancerAnalyticsEventListResponseEnvelopeSuccess = true -) - -type UserLoadBalancerAnalyticsEventListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON userLoadBalancerAnalyticsEventListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// userLoadBalancerAnalyticsEventListResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [UserLoadBalancerAnalyticsEventListResponseEnvelopeResultInfo] -type userLoadBalancerAnalyticsEventListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerAnalyticsEventListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerAnalyticsEventListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/userloadbalanceranalyticsevent_test.go b/userloadbalanceranalyticsevent_test.go deleted file mode 100644 index fdbd71877c6..00000000000 --- a/userloadbalanceranalyticsevent_test.go +++ /dev/null @@ -1,47 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestUserLoadBalancerAnalyticsEventListWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Analytics.Events.List(context.TODO(), cloudflare.UserLoadBalancerAnalyticsEventListParams{ - OriginHealthy: cloudflare.F(true), - OriginName: cloudflare.F("primary-dc-1"), - PoolHealthy: cloudflare.F(true), - PoolID: cloudflare.F("17b5962d775c646f3f9725cbc7a53df4"), - PoolName: cloudflare.F("primary-dc"), - Since: cloudflare.F(time.Now()), - Until: cloudflare.F(time.Now()), - }) - 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/userloadbalancermonitor.go b/userloadbalancermonitor.go deleted file mode 100644 index 55aa0d9a86c..00000000000 --- a/userloadbalancermonitor.go +++ /dev/null @@ -1,1727 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// UserLoadBalancerMonitorService 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 -// [NewUserLoadBalancerMonitorService] method instead. -type UserLoadBalancerMonitorService struct { - Options []option.RequestOption -} - -// NewUserLoadBalancerMonitorService 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 NewUserLoadBalancerMonitorService(opts ...option.RequestOption) (r *UserLoadBalancerMonitorService) { - r = &UserLoadBalancerMonitorService{} - r.Options = opts - return -} - -// Create a configured monitor. -func (r *UserLoadBalancerMonitorService) New(ctx context.Context, body UserLoadBalancerMonitorNewParams, opts ...option.RequestOption) (res *UserLoadBalancerMonitorNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerMonitorNewResponseEnvelope - path := "user/load_balancers/monitors" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Modify a configured monitor. -func (r *UserLoadBalancerMonitorService) Update(ctx context.Context, monitorID string, body UserLoadBalancerMonitorUpdateParams, opts ...option.RequestOption) (res *UserLoadBalancerMonitorUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerMonitorUpdateResponseEnvelope - path := fmt.Sprintf("user/load_balancers/monitors/%s", monitorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List configured monitors for a user. -func (r *UserLoadBalancerMonitorService) List(ctx context.Context, opts ...option.RequestOption) (res *[]UserLoadBalancerMonitorListResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerMonitorListResponseEnvelope - path := "user/load_balancers/monitors" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a configured monitor. -func (r *UserLoadBalancerMonitorService) Delete(ctx context.Context, monitorID string, opts ...option.RequestOption) (res *UserLoadBalancerMonitorDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerMonitorDeleteResponseEnvelope - path := fmt.Sprintf("user/load_balancers/monitors/%s", monitorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Apply changes to an existing monitor, overwriting the supplied properties. -func (r *UserLoadBalancerMonitorService) Edit(ctx context.Context, monitorID string, body UserLoadBalancerMonitorEditParams, opts ...option.RequestOption) (res *UserLoadBalancerMonitorEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerMonitorEditResponseEnvelope - path := fmt.Sprintf("user/load_balancers/monitors/%s", monitorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List a single configured monitor for a user. -func (r *UserLoadBalancerMonitorService) Get(ctx context.Context, monitorID string, opts ...option.RequestOption) (res *UserLoadBalancerMonitorGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerMonitorGetResponseEnvelope - path := fmt.Sprintf("user/load_balancers/monitors/%s", monitorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Preview pools using the specified monitor with provided monitor details. The -// returned preview_id can be used in the preview endpoint to retrieve the results. -func (r *UserLoadBalancerMonitorService) Preview(ctx context.Context, monitorID string, body UserLoadBalancerMonitorPreviewParams, opts ...option.RequestOption) (res *UserLoadBalancerMonitorPreviewResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerMonitorPreviewResponseEnvelope - path := fmt.Sprintf("user/load_balancers/monitors/%s/preview", monitorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the list of resources that reference the provided monitor. -func (r *UserLoadBalancerMonitorService) References(ctx context.Context, monitorID string, opts ...option.RequestOption) (res *[]UserLoadBalancerMonitorReferencesResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerMonitorReferencesResponseEnvelope - path := fmt.Sprintf("user/load_balancers/monitors/%s/references", monitorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type UserLoadBalancerMonitorNewResponse struct { - ID string `json:"id"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure bool `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown int64 `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp int64 `json:"consecutive_up"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Object description. - Description string `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes string `json:"expected_codes"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header interface{} `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval int64 `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method string `json:"method"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path string `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port int64 `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone string `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type UserLoadBalancerMonitorNewResponseType `json:"type"` - JSON userLoadBalancerMonitorNewResponseJSON `json:"-"` -} - -// userLoadBalancerMonitorNewResponseJSON contains the JSON metadata for the struct -// [UserLoadBalancerMonitorNewResponse] -type userLoadBalancerMonitorNewResponseJSON struct { - ID apijson.Field - AllowInsecure apijson.Field - ConsecutiveDown apijson.Field - ConsecutiveUp apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Interval apijson.Field - Method apijson.Field - ModifiedOn apijson.Field - Path apijson.Field - Port apijson.Field - ProbeZone apijson.Field - Retries apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorNewResponseJSON) RawJSON() string { - return r.raw -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type UserLoadBalancerMonitorNewResponseType string - -const ( - UserLoadBalancerMonitorNewResponseTypeHTTP UserLoadBalancerMonitorNewResponseType = "http" - UserLoadBalancerMonitorNewResponseTypeHTTPS UserLoadBalancerMonitorNewResponseType = "https" - UserLoadBalancerMonitorNewResponseTypeTcp UserLoadBalancerMonitorNewResponseType = "tcp" - UserLoadBalancerMonitorNewResponseTypeUdpIcmp UserLoadBalancerMonitorNewResponseType = "udp_icmp" - UserLoadBalancerMonitorNewResponseTypeIcmpPing UserLoadBalancerMonitorNewResponseType = "icmp_ping" - UserLoadBalancerMonitorNewResponseTypeSmtp UserLoadBalancerMonitorNewResponseType = "smtp" -) - -type UserLoadBalancerMonitorUpdateResponse struct { - ID string `json:"id"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure bool `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown int64 `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp int64 `json:"consecutive_up"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Object description. - Description string `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes string `json:"expected_codes"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header interface{} `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval int64 `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method string `json:"method"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path string `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port int64 `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone string `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type UserLoadBalancerMonitorUpdateResponseType `json:"type"` - JSON userLoadBalancerMonitorUpdateResponseJSON `json:"-"` -} - -// userLoadBalancerMonitorUpdateResponseJSON contains the JSON metadata for the -// struct [UserLoadBalancerMonitorUpdateResponse] -type userLoadBalancerMonitorUpdateResponseJSON struct { - ID apijson.Field - AllowInsecure apijson.Field - ConsecutiveDown apijson.Field - ConsecutiveUp apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Interval apijson.Field - Method apijson.Field - ModifiedOn apijson.Field - Path apijson.Field - Port apijson.Field - ProbeZone apijson.Field - Retries apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type UserLoadBalancerMonitorUpdateResponseType string - -const ( - UserLoadBalancerMonitorUpdateResponseTypeHTTP UserLoadBalancerMonitorUpdateResponseType = "http" - UserLoadBalancerMonitorUpdateResponseTypeHTTPS UserLoadBalancerMonitorUpdateResponseType = "https" - UserLoadBalancerMonitorUpdateResponseTypeTcp UserLoadBalancerMonitorUpdateResponseType = "tcp" - UserLoadBalancerMonitorUpdateResponseTypeUdpIcmp UserLoadBalancerMonitorUpdateResponseType = "udp_icmp" - UserLoadBalancerMonitorUpdateResponseTypeIcmpPing UserLoadBalancerMonitorUpdateResponseType = "icmp_ping" - UserLoadBalancerMonitorUpdateResponseTypeSmtp UserLoadBalancerMonitorUpdateResponseType = "smtp" -) - -type UserLoadBalancerMonitorListResponse struct { - ID string `json:"id"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure bool `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown int64 `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp int64 `json:"consecutive_up"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Object description. - Description string `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes string `json:"expected_codes"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header interface{} `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval int64 `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method string `json:"method"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path string `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port int64 `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone string `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type UserLoadBalancerMonitorListResponseType `json:"type"` - JSON userLoadBalancerMonitorListResponseJSON `json:"-"` -} - -// userLoadBalancerMonitorListResponseJSON contains the JSON metadata for the -// struct [UserLoadBalancerMonitorListResponse] -type userLoadBalancerMonitorListResponseJSON struct { - ID apijson.Field - AllowInsecure apijson.Field - ConsecutiveDown apijson.Field - ConsecutiveUp apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Interval apijson.Field - Method apijson.Field - ModifiedOn apijson.Field - Path apijson.Field - Port apijson.Field - ProbeZone apijson.Field - Retries apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorListResponseJSON) RawJSON() string { - return r.raw -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type UserLoadBalancerMonitorListResponseType string - -const ( - UserLoadBalancerMonitorListResponseTypeHTTP UserLoadBalancerMonitorListResponseType = "http" - UserLoadBalancerMonitorListResponseTypeHTTPS UserLoadBalancerMonitorListResponseType = "https" - UserLoadBalancerMonitorListResponseTypeTcp UserLoadBalancerMonitorListResponseType = "tcp" - UserLoadBalancerMonitorListResponseTypeUdpIcmp UserLoadBalancerMonitorListResponseType = "udp_icmp" - UserLoadBalancerMonitorListResponseTypeIcmpPing UserLoadBalancerMonitorListResponseType = "icmp_ping" - UserLoadBalancerMonitorListResponseTypeSmtp UserLoadBalancerMonitorListResponseType = "smtp" -) - -type UserLoadBalancerMonitorDeleteResponse struct { - ID string `json:"id"` - JSON userLoadBalancerMonitorDeleteResponseJSON `json:"-"` -} - -// userLoadBalancerMonitorDeleteResponseJSON contains the JSON metadata for the -// struct [UserLoadBalancerMonitorDeleteResponse] -type userLoadBalancerMonitorDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorEditResponse struct { - ID string `json:"id"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure bool `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown int64 `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp int64 `json:"consecutive_up"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Object description. - Description string `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes string `json:"expected_codes"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header interface{} `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval int64 `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method string `json:"method"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path string `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port int64 `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone string `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type UserLoadBalancerMonitorEditResponseType `json:"type"` - JSON userLoadBalancerMonitorEditResponseJSON `json:"-"` -} - -// userLoadBalancerMonitorEditResponseJSON contains the JSON metadata for the -// struct [UserLoadBalancerMonitorEditResponse] -type userLoadBalancerMonitorEditResponseJSON struct { - ID apijson.Field - AllowInsecure apijson.Field - ConsecutiveDown apijson.Field - ConsecutiveUp apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Interval apijson.Field - Method apijson.Field - ModifiedOn apijson.Field - Path apijson.Field - Port apijson.Field - ProbeZone apijson.Field - Retries apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorEditResponseJSON) RawJSON() string { - return r.raw -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type UserLoadBalancerMonitorEditResponseType string - -const ( - UserLoadBalancerMonitorEditResponseTypeHTTP UserLoadBalancerMonitorEditResponseType = "http" - UserLoadBalancerMonitorEditResponseTypeHTTPS UserLoadBalancerMonitorEditResponseType = "https" - UserLoadBalancerMonitorEditResponseTypeTcp UserLoadBalancerMonitorEditResponseType = "tcp" - UserLoadBalancerMonitorEditResponseTypeUdpIcmp UserLoadBalancerMonitorEditResponseType = "udp_icmp" - UserLoadBalancerMonitorEditResponseTypeIcmpPing UserLoadBalancerMonitorEditResponseType = "icmp_ping" - UserLoadBalancerMonitorEditResponseTypeSmtp UserLoadBalancerMonitorEditResponseType = "smtp" -) - -type UserLoadBalancerMonitorGetResponse struct { - ID string `json:"id"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure bool `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown int64 `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp int64 `json:"consecutive_up"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Object description. - Description string `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes string `json:"expected_codes"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header interface{} `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval int64 `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method string `json:"method"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path string `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port int64 `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone string `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type UserLoadBalancerMonitorGetResponseType `json:"type"` - JSON userLoadBalancerMonitorGetResponseJSON `json:"-"` -} - -// userLoadBalancerMonitorGetResponseJSON contains the JSON metadata for the struct -// [UserLoadBalancerMonitorGetResponse] -type userLoadBalancerMonitorGetResponseJSON struct { - ID apijson.Field - AllowInsecure apijson.Field - ConsecutiveDown apijson.Field - ConsecutiveUp apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Interval apijson.Field - Method apijson.Field - ModifiedOn apijson.Field - Path apijson.Field - Port apijson.Field - ProbeZone apijson.Field - Retries apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorGetResponseJSON) RawJSON() string { - return r.raw -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type UserLoadBalancerMonitorGetResponseType string - -const ( - UserLoadBalancerMonitorGetResponseTypeHTTP UserLoadBalancerMonitorGetResponseType = "http" - UserLoadBalancerMonitorGetResponseTypeHTTPS UserLoadBalancerMonitorGetResponseType = "https" - UserLoadBalancerMonitorGetResponseTypeTcp UserLoadBalancerMonitorGetResponseType = "tcp" - UserLoadBalancerMonitorGetResponseTypeUdpIcmp UserLoadBalancerMonitorGetResponseType = "udp_icmp" - UserLoadBalancerMonitorGetResponseTypeIcmpPing UserLoadBalancerMonitorGetResponseType = "icmp_ping" - UserLoadBalancerMonitorGetResponseTypeSmtp UserLoadBalancerMonitorGetResponseType = "smtp" -) - -type UserLoadBalancerMonitorPreviewResponse struct { - // Monitored pool IDs mapped to their respective names. - Pools map[string]string `json:"pools"` - PreviewID string `json:"preview_id"` - JSON userLoadBalancerMonitorPreviewResponseJSON `json:"-"` -} - -// userLoadBalancerMonitorPreviewResponseJSON contains the JSON metadata for the -// struct [UserLoadBalancerMonitorPreviewResponse] -type userLoadBalancerMonitorPreviewResponseJSON struct { - Pools apijson.Field - PreviewID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorPreviewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorPreviewResponseJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorReferencesResponse struct { - ReferenceType UserLoadBalancerMonitorReferencesResponseReferenceType `json:"reference_type"` - ResourceID string `json:"resource_id"` - ResourceName string `json:"resource_name"` - ResourceType string `json:"resource_type"` - JSON userLoadBalancerMonitorReferencesResponseJSON `json:"-"` -} - -// userLoadBalancerMonitorReferencesResponseJSON contains the JSON metadata for the -// struct [UserLoadBalancerMonitorReferencesResponse] -type userLoadBalancerMonitorReferencesResponseJSON struct { - ReferenceType apijson.Field - ResourceID apijson.Field - ResourceName apijson.Field - ResourceType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorReferencesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorReferencesResponseJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorReferencesResponseReferenceType string - -const ( - UserLoadBalancerMonitorReferencesResponseReferenceTypeStar UserLoadBalancerMonitorReferencesResponseReferenceType = "*" - UserLoadBalancerMonitorReferencesResponseReferenceTypeReferral UserLoadBalancerMonitorReferencesResponseReferenceType = "referral" - UserLoadBalancerMonitorReferencesResponseReferenceTypeReferrer UserLoadBalancerMonitorReferencesResponseReferenceType = "referrer" -) - -type UserLoadBalancerMonitorNewParams struct { - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes param.Field[string] `json:"expected_codes,required"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown param.Field[int64] `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp param.Field[int64] `json:"consecutive_up"` - // Object description. - Description param.Field[string] `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody param.Field[string] `json:"expected_body"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header param.Field[interface{}] `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method param.Field[string] `json:"method"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path param.Field[string] `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port param.Field[int64] `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone param.Field[string] `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type param.Field[UserLoadBalancerMonitorNewParamsType] `json:"type"` -} - -func (r UserLoadBalancerMonitorNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type UserLoadBalancerMonitorNewParamsType string - -const ( - UserLoadBalancerMonitorNewParamsTypeHTTP UserLoadBalancerMonitorNewParamsType = "http" - UserLoadBalancerMonitorNewParamsTypeHTTPS UserLoadBalancerMonitorNewParamsType = "https" - UserLoadBalancerMonitorNewParamsTypeTcp UserLoadBalancerMonitorNewParamsType = "tcp" - UserLoadBalancerMonitorNewParamsTypeUdpIcmp UserLoadBalancerMonitorNewParamsType = "udp_icmp" - UserLoadBalancerMonitorNewParamsTypeIcmpPing UserLoadBalancerMonitorNewParamsType = "icmp_ping" - UserLoadBalancerMonitorNewParamsTypeSmtp UserLoadBalancerMonitorNewParamsType = "smtp" -) - -type UserLoadBalancerMonitorNewResponseEnvelope struct { - Errors []UserLoadBalancerMonitorNewResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerMonitorNewResponseEnvelopeMessages `json:"messages,required"` - Result UserLoadBalancerMonitorNewResponse `json:"result,required"` - // Whether the API call was successful - Success UserLoadBalancerMonitorNewResponseEnvelopeSuccess `json:"success,required"` - JSON userLoadBalancerMonitorNewResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerMonitorNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [UserLoadBalancerMonitorNewResponseEnvelope] -type userLoadBalancerMonitorNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerMonitorNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerMonitorNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [UserLoadBalancerMonitorNewResponseEnvelopeErrors] -type userLoadBalancerMonitorNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerMonitorNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerMonitorNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [UserLoadBalancerMonitorNewResponseEnvelopeMessages] -type userLoadBalancerMonitorNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerMonitorNewResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerMonitorNewResponseEnvelopeSuccessTrue UserLoadBalancerMonitorNewResponseEnvelopeSuccess = true -) - -type UserLoadBalancerMonitorUpdateParams struct { - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes param.Field[string] `json:"expected_codes,required"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown param.Field[int64] `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp param.Field[int64] `json:"consecutive_up"` - // Object description. - Description param.Field[string] `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody param.Field[string] `json:"expected_body"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header param.Field[interface{}] `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method param.Field[string] `json:"method"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path param.Field[string] `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port param.Field[int64] `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone param.Field[string] `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type param.Field[UserLoadBalancerMonitorUpdateParamsType] `json:"type"` -} - -func (r UserLoadBalancerMonitorUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type UserLoadBalancerMonitorUpdateParamsType string - -const ( - UserLoadBalancerMonitorUpdateParamsTypeHTTP UserLoadBalancerMonitorUpdateParamsType = "http" - UserLoadBalancerMonitorUpdateParamsTypeHTTPS UserLoadBalancerMonitorUpdateParamsType = "https" - UserLoadBalancerMonitorUpdateParamsTypeTcp UserLoadBalancerMonitorUpdateParamsType = "tcp" - UserLoadBalancerMonitorUpdateParamsTypeUdpIcmp UserLoadBalancerMonitorUpdateParamsType = "udp_icmp" - UserLoadBalancerMonitorUpdateParamsTypeIcmpPing UserLoadBalancerMonitorUpdateParamsType = "icmp_ping" - UserLoadBalancerMonitorUpdateParamsTypeSmtp UserLoadBalancerMonitorUpdateParamsType = "smtp" -) - -type UserLoadBalancerMonitorUpdateResponseEnvelope struct { - Errors []UserLoadBalancerMonitorUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerMonitorUpdateResponseEnvelopeMessages `json:"messages,required"` - Result UserLoadBalancerMonitorUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success UserLoadBalancerMonitorUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON userLoadBalancerMonitorUpdateResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerMonitorUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [UserLoadBalancerMonitorUpdateResponseEnvelope] -type userLoadBalancerMonitorUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerMonitorUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerMonitorUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [UserLoadBalancerMonitorUpdateResponseEnvelopeErrors] -type userLoadBalancerMonitorUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerMonitorUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerMonitorUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [UserLoadBalancerMonitorUpdateResponseEnvelopeMessages] -type userLoadBalancerMonitorUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerMonitorUpdateResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerMonitorUpdateResponseEnvelopeSuccessTrue UserLoadBalancerMonitorUpdateResponseEnvelopeSuccess = true -) - -type UserLoadBalancerMonitorListResponseEnvelope struct { - Errors []UserLoadBalancerMonitorListResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerMonitorListResponseEnvelopeMessages `json:"messages,required"` - Result []UserLoadBalancerMonitorListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success UserLoadBalancerMonitorListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo UserLoadBalancerMonitorListResponseEnvelopeResultInfo `json:"result_info"` - JSON userLoadBalancerMonitorListResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerMonitorListResponseEnvelopeJSON contains the JSON metadata for -// the struct [UserLoadBalancerMonitorListResponseEnvelope] -type userLoadBalancerMonitorListResponseEnvelopeJSON 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 *UserLoadBalancerMonitorListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerMonitorListResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerMonitorListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [UserLoadBalancerMonitorListResponseEnvelopeErrors] -type userLoadBalancerMonitorListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerMonitorListResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerMonitorListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [UserLoadBalancerMonitorListResponseEnvelopeMessages] -type userLoadBalancerMonitorListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerMonitorListResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerMonitorListResponseEnvelopeSuccessTrue UserLoadBalancerMonitorListResponseEnvelopeSuccess = true -) - -type UserLoadBalancerMonitorListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON userLoadBalancerMonitorListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// userLoadBalancerMonitorListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [UserLoadBalancerMonitorListResponseEnvelopeResultInfo] -type userLoadBalancerMonitorListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorDeleteResponseEnvelope struct { - Errors []UserLoadBalancerMonitorDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerMonitorDeleteResponseEnvelopeMessages `json:"messages,required"` - Result UserLoadBalancerMonitorDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success UserLoadBalancerMonitorDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON userLoadBalancerMonitorDeleteResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerMonitorDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [UserLoadBalancerMonitorDeleteResponseEnvelope] -type userLoadBalancerMonitorDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerMonitorDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerMonitorDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [UserLoadBalancerMonitorDeleteResponseEnvelopeErrors] -type userLoadBalancerMonitorDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerMonitorDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerMonitorDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [UserLoadBalancerMonitorDeleteResponseEnvelopeMessages] -type userLoadBalancerMonitorDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerMonitorDeleteResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerMonitorDeleteResponseEnvelopeSuccessTrue UserLoadBalancerMonitorDeleteResponseEnvelopeSuccess = true -) - -type UserLoadBalancerMonitorEditParams struct { - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes param.Field[string] `json:"expected_codes,required"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown param.Field[int64] `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp param.Field[int64] `json:"consecutive_up"` - // Object description. - Description param.Field[string] `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody param.Field[string] `json:"expected_body"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header param.Field[interface{}] `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method param.Field[string] `json:"method"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path param.Field[string] `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port param.Field[int64] `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone param.Field[string] `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type param.Field[UserLoadBalancerMonitorEditParamsType] `json:"type"` -} - -func (r UserLoadBalancerMonitorEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type UserLoadBalancerMonitorEditParamsType string - -const ( - UserLoadBalancerMonitorEditParamsTypeHTTP UserLoadBalancerMonitorEditParamsType = "http" - UserLoadBalancerMonitorEditParamsTypeHTTPS UserLoadBalancerMonitorEditParamsType = "https" - UserLoadBalancerMonitorEditParamsTypeTcp UserLoadBalancerMonitorEditParamsType = "tcp" - UserLoadBalancerMonitorEditParamsTypeUdpIcmp UserLoadBalancerMonitorEditParamsType = "udp_icmp" - UserLoadBalancerMonitorEditParamsTypeIcmpPing UserLoadBalancerMonitorEditParamsType = "icmp_ping" - UserLoadBalancerMonitorEditParamsTypeSmtp UserLoadBalancerMonitorEditParamsType = "smtp" -) - -type UserLoadBalancerMonitorEditResponseEnvelope struct { - Errors []UserLoadBalancerMonitorEditResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerMonitorEditResponseEnvelopeMessages `json:"messages,required"` - Result UserLoadBalancerMonitorEditResponse `json:"result,required"` - // Whether the API call was successful - Success UserLoadBalancerMonitorEditResponseEnvelopeSuccess `json:"success,required"` - JSON userLoadBalancerMonitorEditResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerMonitorEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [UserLoadBalancerMonitorEditResponseEnvelope] -type userLoadBalancerMonitorEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerMonitorEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerMonitorEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [UserLoadBalancerMonitorEditResponseEnvelopeErrors] -type userLoadBalancerMonitorEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerMonitorEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerMonitorEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [UserLoadBalancerMonitorEditResponseEnvelopeMessages] -type userLoadBalancerMonitorEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerMonitorEditResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerMonitorEditResponseEnvelopeSuccessTrue UserLoadBalancerMonitorEditResponseEnvelopeSuccess = true -) - -type UserLoadBalancerMonitorGetResponseEnvelope struct { - Errors []UserLoadBalancerMonitorGetResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerMonitorGetResponseEnvelopeMessages `json:"messages,required"` - Result UserLoadBalancerMonitorGetResponse `json:"result,required"` - // Whether the API call was successful - Success UserLoadBalancerMonitorGetResponseEnvelopeSuccess `json:"success,required"` - JSON userLoadBalancerMonitorGetResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerMonitorGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [UserLoadBalancerMonitorGetResponseEnvelope] -type userLoadBalancerMonitorGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerMonitorGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerMonitorGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [UserLoadBalancerMonitorGetResponseEnvelopeErrors] -type userLoadBalancerMonitorGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerMonitorGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerMonitorGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [UserLoadBalancerMonitorGetResponseEnvelopeMessages] -type userLoadBalancerMonitorGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerMonitorGetResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerMonitorGetResponseEnvelopeSuccessTrue UserLoadBalancerMonitorGetResponseEnvelopeSuccess = true -) - -type UserLoadBalancerMonitorPreviewParams struct { - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes param.Field[string] `json:"expected_codes,required"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown param.Field[int64] `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp param.Field[int64] `json:"consecutive_up"` - // Object description. - Description param.Field[string] `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody param.Field[string] `json:"expected_body"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header param.Field[interface{}] `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method param.Field[string] `json:"method"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path param.Field[string] `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port param.Field[int64] `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone param.Field[string] `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type param.Field[UserLoadBalancerMonitorPreviewParamsType] `json:"type"` -} - -func (r UserLoadBalancerMonitorPreviewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type UserLoadBalancerMonitorPreviewParamsType string - -const ( - UserLoadBalancerMonitorPreviewParamsTypeHTTP UserLoadBalancerMonitorPreviewParamsType = "http" - UserLoadBalancerMonitorPreviewParamsTypeHTTPS UserLoadBalancerMonitorPreviewParamsType = "https" - UserLoadBalancerMonitorPreviewParamsTypeTcp UserLoadBalancerMonitorPreviewParamsType = "tcp" - UserLoadBalancerMonitorPreviewParamsTypeUdpIcmp UserLoadBalancerMonitorPreviewParamsType = "udp_icmp" - UserLoadBalancerMonitorPreviewParamsTypeIcmpPing UserLoadBalancerMonitorPreviewParamsType = "icmp_ping" - UserLoadBalancerMonitorPreviewParamsTypeSmtp UserLoadBalancerMonitorPreviewParamsType = "smtp" -) - -type UserLoadBalancerMonitorPreviewResponseEnvelope struct { - Errors []UserLoadBalancerMonitorPreviewResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerMonitorPreviewResponseEnvelopeMessages `json:"messages,required"` - Result UserLoadBalancerMonitorPreviewResponse `json:"result,required"` - // Whether the API call was successful - Success UserLoadBalancerMonitorPreviewResponseEnvelopeSuccess `json:"success,required"` - JSON userLoadBalancerMonitorPreviewResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerMonitorPreviewResponseEnvelopeJSON contains the JSON metadata -// for the struct [UserLoadBalancerMonitorPreviewResponseEnvelope] -type userLoadBalancerMonitorPreviewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorPreviewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorPreviewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorPreviewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerMonitorPreviewResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerMonitorPreviewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [UserLoadBalancerMonitorPreviewResponseEnvelopeErrors] -type userLoadBalancerMonitorPreviewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorPreviewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorPreviewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorPreviewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerMonitorPreviewResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerMonitorPreviewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [UserLoadBalancerMonitorPreviewResponseEnvelopeMessages] -type userLoadBalancerMonitorPreviewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorPreviewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorPreviewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerMonitorPreviewResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerMonitorPreviewResponseEnvelopeSuccessTrue UserLoadBalancerMonitorPreviewResponseEnvelopeSuccess = true -) - -type UserLoadBalancerMonitorReferencesResponseEnvelope struct { - Errors []UserLoadBalancerMonitorReferencesResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerMonitorReferencesResponseEnvelopeMessages `json:"messages,required"` - // List of resources that reference a given monitor. - Result []UserLoadBalancerMonitorReferencesResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success UserLoadBalancerMonitorReferencesResponseEnvelopeSuccess `json:"success,required"` - ResultInfo UserLoadBalancerMonitorReferencesResponseEnvelopeResultInfo `json:"result_info"` - JSON userLoadBalancerMonitorReferencesResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerMonitorReferencesResponseEnvelopeJSON contains the JSON metadata -// for the struct [UserLoadBalancerMonitorReferencesResponseEnvelope] -type userLoadBalancerMonitorReferencesResponseEnvelopeJSON 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 *UserLoadBalancerMonitorReferencesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorReferencesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorReferencesResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerMonitorReferencesResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerMonitorReferencesResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [UserLoadBalancerMonitorReferencesResponseEnvelopeErrors] -type userLoadBalancerMonitorReferencesResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorReferencesResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorReferencesResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerMonitorReferencesResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerMonitorReferencesResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerMonitorReferencesResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [UserLoadBalancerMonitorReferencesResponseEnvelopeMessages] -type userLoadBalancerMonitorReferencesResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorReferencesResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorReferencesResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerMonitorReferencesResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerMonitorReferencesResponseEnvelopeSuccessTrue UserLoadBalancerMonitorReferencesResponseEnvelopeSuccess = true -) - -type UserLoadBalancerMonitorReferencesResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON userLoadBalancerMonitorReferencesResponseEnvelopeResultInfoJSON `json:"-"` -} - -// userLoadBalancerMonitorReferencesResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [UserLoadBalancerMonitorReferencesResponseEnvelopeResultInfo] -type userLoadBalancerMonitorReferencesResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerMonitorReferencesResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerMonitorReferencesResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/userloadbalancermonitor_test.go b/userloadbalancermonitor_test.go deleted file mode 100644 index 53f5a090663..00000000000 --- a/userloadbalancermonitor_test.go +++ /dev/null @@ -1,314 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestUserLoadBalancerMonitorNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Monitors.New(context.TODO(), cloudflare.UserLoadBalancerMonitorNewParams{ - ExpectedCodes: cloudflare.F("2xx"), - AllowInsecure: cloudflare.F(true), - ConsecutiveDown: cloudflare.F(int64(0)), - ConsecutiveUp: cloudflare.F(int64(0)), - Description: cloudflare.F("Login page monitor"), - ExpectedBody: cloudflare.F("alive"), - FollowRedirects: cloudflare.F(true), - Header: cloudflare.F[any](map[string]interface{}{ - "Host": map[string]interface{}{ - "0": "example.com", - }, - "X-App-ID": map[string]interface{}{ - "0": "abc123", - }, - }), - Interval: cloudflare.F(int64(0)), - Method: cloudflare.F("GET"), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - ProbeZone: cloudflare.F("example.com"), - Retries: cloudflare.F(int64(0)), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F(cloudflare.UserLoadBalancerMonitorNewParamsTypeHTTPS), - }) - 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 TestUserLoadBalancerMonitorUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Monitors.Update( - context.TODO(), - "f1aba936b94213e5b8dca0c0dbf1f9cc", - cloudflare.UserLoadBalancerMonitorUpdateParams{ - ExpectedCodes: cloudflare.F("2xx"), - AllowInsecure: cloudflare.F(true), - ConsecutiveDown: cloudflare.F(int64(0)), - ConsecutiveUp: cloudflare.F(int64(0)), - Description: cloudflare.F("Login page monitor"), - ExpectedBody: cloudflare.F("alive"), - FollowRedirects: cloudflare.F(true), - Header: cloudflare.F[any](map[string]interface{}{ - "Host": map[string]interface{}{ - "0": "example.com", - }, - "X-App-ID": map[string]interface{}{ - "0": "abc123", - }, - }), - Interval: cloudflare.F(int64(0)), - Method: cloudflare.F("GET"), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - ProbeZone: cloudflare.F("example.com"), - Retries: cloudflare.F(int64(0)), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F(cloudflare.UserLoadBalancerMonitorUpdateParamsTypeHTTPS), - }, - ) - 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 TestUserLoadBalancerMonitorList(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Monitors.List(context.TODO()) - 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 TestUserLoadBalancerMonitorDelete(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Monitors.Delete(context.TODO(), "f1aba936b94213e5b8dca0c0dbf1f9cc") - 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 TestUserLoadBalancerMonitorEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Monitors.Edit( - context.TODO(), - "f1aba936b94213e5b8dca0c0dbf1f9cc", - cloudflare.UserLoadBalancerMonitorEditParams{ - ExpectedCodes: cloudflare.F("2xx"), - AllowInsecure: cloudflare.F(true), - ConsecutiveDown: cloudflare.F(int64(0)), - ConsecutiveUp: cloudflare.F(int64(0)), - Description: cloudflare.F("Login page monitor"), - ExpectedBody: cloudflare.F("alive"), - FollowRedirects: cloudflare.F(true), - Header: cloudflare.F[any](map[string]interface{}{ - "Host": map[string]interface{}{ - "0": "example.com", - }, - "X-App-ID": map[string]interface{}{ - "0": "abc123", - }, - }), - Interval: cloudflare.F(int64(0)), - Method: cloudflare.F("GET"), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - ProbeZone: cloudflare.F("example.com"), - Retries: cloudflare.F(int64(0)), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F(cloudflare.UserLoadBalancerMonitorEditParamsTypeHTTPS), - }, - ) - 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 TestUserLoadBalancerMonitorGet(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Monitors.Get(context.TODO(), "f1aba936b94213e5b8dca0c0dbf1f9cc") - 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 TestUserLoadBalancerMonitorPreviewWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Monitors.Preview( - context.TODO(), - "f1aba936b94213e5b8dca0c0dbf1f9cc", - cloudflare.UserLoadBalancerMonitorPreviewParams{ - ExpectedCodes: cloudflare.F("2xx"), - AllowInsecure: cloudflare.F(true), - ConsecutiveDown: cloudflare.F(int64(0)), - ConsecutiveUp: cloudflare.F(int64(0)), - Description: cloudflare.F("Login page monitor"), - ExpectedBody: cloudflare.F("alive"), - FollowRedirects: cloudflare.F(true), - Header: cloudflare.F[any](map[string]interface{}{ - "Host": map[string]interface{}{ - "0": "example.com", - }, - "X-App-ID": map[string]interface{}{ - "0": "abc123", - }, - }), - Interval: cloudflare.F(int64(0)), - Method: cloudflare.F("GET"), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - ProbeZone: cloudflare.F("example.com"), - Retries: cloudflare.F(int64(0)), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F(cloudflare.UserLoadBalancerMonitorPreviewParamsTypeHTTPS), - }, - ) - 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 TestUserLoadBalancerMonitorReferences(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Monitors.References(context.TODO(), "f1aba936b94213e5b8dca0c0dbf1f9cc") - 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/userloadbalancerpool.go b/userloadbalancerpool.go deleted file mode 100644 index 6534c3c4178..00000000000 --- a/userloadbalancerpool.go +++ /dev/null @@ -1,3826 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// UserLoadBalancerPoolService 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 [NewUserLoadBalancerPoolService] -// method instead. -type UserLoadBalancerPoolService struct { - Options []option.RequestOption -} - -// NewUserLoadBalancerPoolService 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 NewUserLoadBalancerPoolService(opts ...option.RequestOption) (r *UserLoadBalancerPoolService) { - r = &UserLoadBalancerPoolService{} - r.Options = opts - return -} - -// Create a new pool. -func (r *UserLoadBalancerPoolService) New(ctx context.Context, body UserLoadBalancerPoolNewParams, opts ...option.RequestOption) (res *UserLoadBalancerPoolNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerPoolNewResponseEnvelope - path := "user/load_balancers/pools" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Modify a configured pool. -func (r *UserLoadBalancerPoolService) Update(ctx context.Context, poolID string, body UserLoadBalancerPoolUpdateParams, opts ...option.RequestOption) (res *UserLoadBalancerPoolUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerPoolUpdateResponseEnvelope - path := fmt.Sprintf("user/load_balancers/pools/%s", poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List configured pools. -func (r *UserLoadBalancerPoolService) List(ctx context.Context, query UserLoadBalancerPoolListParams, opts ...option.RequestOption) (res *[]UserLoadBalancerPoolListResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerPoolListResponseEnvelope - path := "user/load_balancers/pools" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a configured pool. -func (r *UserLoadBalancerPoolService) Delete(ctx context.Context, poolID string, opts ...option.RequestOption) (res *UserLoadBalancerPoolDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerPoolDeleteResponseEnvelope - path := fmt.Sprintf("user/load_balancers/pools/%s", poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Apply changes to an existing pool, overwriting the supplied properties. -func (r *UserLoadBalancerPoolService) Edit(ctx context.Context, poolID string, body UserLoadBalancerPoolEditParams, opts ...option.RequestOption) (res *UserLoadBalancerPoolEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerPoolEditResponseEnvelope - path := fmt.Sprintf("user/load_balancers/pools/%s", poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch a single configured pool. -func (r *UserLoadBalancerPoolService) Get(ctx context.Context, poolID string, opts ...option.RequestOption) (res *UserLoadBalancerPoolGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerPoolGetResponseEnvelope - path := fmt.Sprintf("user/load_balancers/pools/%s", poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch the latest pool health status for a single pool. -func (r *UserLoadBalancerPoolService) Health(ctx context.Context, poolID string, opts ...option.RequestOption) (res *UserLoadBalancerPoolHealthResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerPoolHealthResponseEnvelope - path := fmt.Sprintf("user/load_balancers/pools/%s/health", poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Preview pool health using provided monitor details. The returned preview_id can -// be used in the preview endpoint to retrieve the results. -func (r *UserLoadBalancerPoolService) Preview(ctx context.Context, poolID string, body UserLoadBalancerPoolPreviewParams, opts ...option.RequestOption) (res *UserLoadBalancerPoolPreviewResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerPoolPreviewResponseEnvelope - path := fmt.Sprintf("user/load_balancers/pools/%s/preview", poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the list of resources that reference the provided pool. -func (r *UserLoadBalancerPoolService) References(ctx context.Context, poolID string, opts ...option.RequestOption) (res *[]UserLoadBalancerPoolReferencesResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerPoolReferencesResponseEnvelope - path := fmt.Sprintf("user/load_balancers/pools/%s/references", poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type UserLoadBalancerPoolNewResponse struct { - ID string `json:"id"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions []UserLoadBalancerPoolNewResponseCheckRegion `json:"check_regions,nullable"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A human-readable description of the pool. - Description string `json:"description"` - // This field shows up only if the pool is disabled. This field is set with the - // time the pool was disabled at. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) or disable this pool. Disabled pools will not - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled bool `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, longitude must also be set. - Latitude float64 `json:"latitude"` - // Configures load shedding policies and percentages for the pool. - LoadShedding UserLoadBalancerPoolNewResponseLoadShedding `json:"load_shedding"` - // The longitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, latitude must also be set. - Longitude float64 `json:"longitude"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins int64 `json:"minimum_origins"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor interface{} `json:"monitor"` - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - Name string `json:"name"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - NotificationEmail string `json:"notification_email"` - // Filter pool and origin health notifications by resource type or health status. - // Use null to reset. - NotificationFilter UserLoadBalancerPoolNewResponseNotificationFilter `json:"notification_filter,nullable"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering UserLoadBalancerPoolNewResponseOriginSteering `json:"origin_steering"` - // The list of origins within this pool. Traffic directed at this pool is balanced - // across all currently healthy origins, provided the pool itself is healthy. - Origins []UserLoadBalancerPoolNewResponseOrigin `json:"origins"` - JSON userLoadBalancerPoolNewResponseJSON `json:"-"` -} - -// userLoadBalancerPoolNewResponseJSON contains the JSON metadata for the struct -// [UserLoadBalancerPoolNewResponse] -type userLoadBalancerPoolNewResponseJSON struct { - ID apijson.Field - CheckRegions apijson.Field - CreatedOn apijson.Field - Description apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Latitude apijson.Field - LoadShedding apijson.Field - Longitude apijson.Field - MinimumOrigins apijson.Field - ModifiedOn apijson.Field - Monitor apijson.Field - Name apijson.Field - NotificationEmail apijson.Field - NotificationFilter apijson.Field - OriginSteering apijson.Field - Origins apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolNewResponseJSON) RawJSON() string { - return r.raw -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type UserLoadBalancerPoolNewResponseCheckRegion string - -const ( - UserLoadBalancerPoolNewResponseCheckRegionWnam UserLoadBalancerPoolNewResponseCheckRegion = "WNAM" - UserLoadBalancerPoolNewResponseCheckRegionEnam UserLoadBalancerPoolNewResponseCheckRegion = "ENAM" - UserLoadBalancerPoolNewResponseCheckRegionWeu UserLoadBalancerPoolNewResponseCheckRegion = "WEU" - UserLoadBalancerPoolNewResponseCheckRegionEeu UserLoadBalancerPoolNewResponseCheckRegion = "EEU" - UserLoadBalancerPoolNewResponseCheckRegionNsam UserLoadBalancerPoolNewResponseCheckRegion = "NSAM" - UserLoadBalancerPoolNewResponseCheckRegionSsam UserLoadBalancerPoolNewResponseCheckRegion = "SSAM" - UserLoadBalancerPoolNewResponseCheckRegionOc UserLoadBalancerPoolNewResponseCheckRegion = "OC" - UserLoadBalancerPoolNewResponseCheckRegionMe UserLoadBalancerPoolNewResponseCheckRegion = "ME" - UserLoadBalancerPoolNewResponseCheckRegionNaf UserLoadBalancerPoolNewResponseCheckRegion = "NAF" - UserLoadBalancerPoolNewResponseCheckRegionSaf UserLoadBalancerPoolNewResponseCheckRegion = "SAF" - UserLoadBalancerPoolNewResponseCheckRegionSas UserLoadBalancerPoolNewResponseCheckRegion = "SAS" - UserLoadBalancerPoolNewResponseCheckRegionSeas UserLoadBalancerPoolNewResponseCheckRegion = "SEAS" - UserLoadBalancerPoolNewResponseCheckRegionNeas UserLoadBalancerPoolNewResponseCheckRegion = "NEAS" - UserLoadBalancerPoolNewResponseCheckRegionAllRegions UserLoadBalancerPoolNewResponseCheckRegion = "ALL_REGIONS" -) - -// Configures load shedding policies and percentages for the pool. -type UserLoadBalancerPoolNewResponseLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent float64 `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy UserLoadBalancerPoolNewResponseLoadSheddingDefaultPolicy `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent float64 `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy UserLoadBalancerPoolNewResponseLoadSheddingSessionPolicy `json:"session_policy"` - JSON userLoadBalancerPoolNewResponseLoadSheddingJSON `json:"-"` -} - -// userLoadBalancerPoolNewResponseLoadSheddingJSON contains the JSON metadata for -// the struct [UserLoadBalancerPoolNewResponseLoadShedding] -type userLoadBalancerPoolNewResponseLoadSheddingJSON struct { - DefaultPercent apijson.Field - DefaultPolicy apijson.Field - SessionPercent apijson.Field - SessionPolicy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolNewResponseLoadShedding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolNewResponseLoadSheddingJSON) RawJSON() string { - return r.raw -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type UserLoadBalancerPoolNewResponseLoadSheddingDefaultPolicy string - -const ( - UserLoadBalancerPoolNewResponseLoadSheddingDefaultPolicyRandom UserLoadBalancerPoolNewResponseLoadSheddingDefaultPolicy = "random" - UserLoadBalancerPoolNewResponseLoadSheddingDefaultPolicyHash UserLoadBalancerPoolNewResponseLoadSheddingDefaultPolicy = "hash" -) - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type UserLoadBalancerPoolNewResponseLoadSheddingSessionPolicy string - -const ( - UserLoadBalancerPoolNewResponseLoadSheddingSessionPolicyHash UserLoadBalancerPoolNewResponseLoadSheddingSessionPolicy = "hash" -) - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type UserLoadBalancerPoolNewResponseNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin UserLoadBalancerPoolNewResponseNotificationFilterOrigin `json:"origin,nullable"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool UserLoadBalancerPoolNewResponseNotificationFilterPool `json:"pool,nullable"` - JSON userLoadBalancerPoolNewResponseNotificationFilterJSON `json:"-"` -} - -// userLoadBalancerPoolNewResponseNotificationFilterJSON contains the JSON metadata -// for the struct [UserLoadBalancerPoolNewResponseNotificationFilter] -type userLoadBalancerPoolNewResponseNotificationFilterJSON struct { - Origin apijson.Field - Pool apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolNewResponseNotificationFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolNewResponseNotificationFilterJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type UserLoadBalancerPoolNewResponseNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON userLoadBalancerPoolNewResponseNotificationFilterOriginJSON `json:"-"` -} - -// userLoadBalancerPoolNewResponseNotificationFilterOriginJSON contains the JSON -// metadata for the struct -// [UserLoadBalancerPoolNewResponseNotificationFilterOrigin] -type userLoadBalancerPoolNewResponseNotificationFilterOriginJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolNewResponseNotificationFilterOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolNewResponseNotificationFilterOriginJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type UserLoadBalancerPoolNewResponseNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON userLoadBalancerPoolNewResponseNotificationFilterPoolJSON `json:"-"` -} - -// userLoadBalancerPoolNewResponseNotificationFilterPoolJSON contains the JSON -// metadata for the struct [UserLoadBalancerPoolNewResponseNotificationFilterPool] -type userLoadBalancerPoolNewResponseNotificationFilterPoolJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolNewResponseNotificationFilterPool) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolNewResponseNotificationFilterPoolJSON) RawJSON() string { - return r.raw -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type UserLoadBalancerPoolNewResponseOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy UserLoadBalancerPoolNewResponseOriginSteeringPolicy `json:"policy"` - JSON userLoadBalancerPoolNewResponseOriginSteeringJSON `json:"-"` -} - -// userLoadBalancerPoolNewResponseOriginSteeringJSON contains the JSON metadata for -// the struct [UserLoadBalancerPoolNewResponseOriginSteering] -type userLoadBalancerPoolNewResponseOriginSteeringJSON struct { - Policy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolNewResponseOriginSteering) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolNewResponseOriginSteeringJSON) RawJSON() string { - return r.raw -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type UserLoadBalancerPoolNewResponseOriginSteeringPolicy string - -const ( - UserLoadBalancerPoolNewResponseOriginSteeringPolicyRandom UserLoadBalancerPoolNewResponseOriginSteeringPolicy = "random" - UserLoadBalancerPoolNewResponseOriginSteeringPolicyHash UserLoadBalancerPoolNewResponseOriginSteeringPolicy = "hash" - UserLoadBalancerPoolNewResponseOriginSteeringPolicyLeastOutstandingRequests UserLoadBalancerPoolNewResponseOriginSteeringPolicy = "least_outstanding_requests" - UserLoadBalancerPoolNewResponseOriginSteeringPolicyLeastConnections UserLoadBalancerPoolNewResponseOriginSteeringPolicy = "least_connections" -) - -type UserLoadBalancerPoolNewResponseOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address string `json:"address"` - // This field shows up only if the origin is disabled. This field is set with the - // time the origin was disabled. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled bool `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header UserLoadBalancerPoolNewResponseOriginsHeader `json:"header"` - // A human-identifiable name for the origin. - Name string `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID string `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight float64 `json:"weight"` - JSON userLoadBalancerPoolNewResponseOriginJSON `json:"-"` -} - -// userLoadBalancerPoolNewResponseOriginJSON contains the JSON metadata for the -// struct [UserLoadBalancerPoolNewResponseOrigin] -type userLoadBalancerPoolNewResponseOriginJSON struct { - Address apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Header apijson.Field - Name apijson.Field - VirtualNetworkID apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolNewResponseOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolNewResponseOriginJSON) RawJSON() string { - return r.raw -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type UserLoadBalancerPoolNewResponseOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host []string `json:"Host"` - JSON userLoadBalancerPoolNewResponseOriginsHeaderJSON `json:"-"` -} - -// userLoadBalancerPoolNewResponseOriginsHeaderJSON contains the JSON metadata for -// the struct [UserLoadBalancerPoolNewResponseOriginsHeader] -type userLoadBalancerPoolNewResponseOriginsHeaderJSON struct { - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolNewResponseOriginsHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolNewResponseOriginsHeaderJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolUpdateResponse struct { - ID string `json:"id"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions []UserLoadBalancerPoolUpdateResponseCheckRegion `json:"check_regions,nullable"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A human-readable description of the pool. - Description string `json:"description"` - // This field shows up only if the pool is disabled. This field is set with the - // time the pool was disabled at. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) or disable this pool. Disabled pools will not - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled bool `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, longitude must also be set. - Latitude float64 `json:"latitude"` - // Configures load shedding policies and percentages for the pool. - LoadShedding UserLoadBalancerPoolUpdateResponseLoadShedding `json:"load_shedding"` - // The longitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, latitude must also be set. - Longitude float64 `json:"longitude"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins int64 `json:"minimum_origins"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor interface{} `json:"monitor"` - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - Name string `json:"name"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - NotificationEmail string `json:"notification_email"` - // Filter pool and origin health notifications by resource type or health status. - // Use null to reset. - NotificationFilter UserLoadBalancerPoolUpdateResponseNotificationFilter `json:"notification_filter,nullable"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering UserLoadBalancerPoolUpdateResponseOriginSteering `json:"origin_steering"` - // The list of origins within this pool. Traffic directed at this pool is balanced - // across all currently healthy origins, provided the pool itself is healthy. - Origins []UserLoadBalancerPoolUpdateResponseOrigin `json:"origins"` - JSON userLoadBalancerPoolUpdateResponseJSON `json:"-"` -} - -// userLoadBalancerPoolUpdateResponseJSON contains the JSON metadata for the struct -// [UserLoadBalancerPoolUpdateResponse] -type userLoadBalancerPoolUpdateResponseJSON struct { - ID apijson.Field - CheckRegions apijson.Field - CreatedOn apijson.Field - Description apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Latitude apijson.Field - LoadShedding apijson.Field - Longitude apijson.Field - MinimumOrigins apijson.Field - ModifiedOn apijson.Field - Monitor apijson.Field - Name apijson.Field - NotificationEmail apijson.Field - NotificationFilter apijson.Field - OriginSteering apijson.Field - Origins apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type UserLoadBalancerPoolUpdateResponseCheckRegion string - -const ( - UserLoadBalancerPoolUpdateResponseCheckRegionWnam UserLoadBalancerPoolUpdateResponseCheckRegion = "WNAM" - UserLoadBalancerPoolUpdateResponseCheckRegionEnam UserLoadBalancerPoolUpdateResponseCheckRegion = "ENAM" - UserLoadBalancerPoolUpdateResponseCheckRegionWeu UserLoadBalancerPoolUpdateResponseCheckRegion = "WEU" - UserLoadBalancerPoolUpdateResponseCheckRegionEeu UserLoadBalancerPoolUpdateResponseCheckRegion = "EEU" - UserLoadBalancerPoolUpdateResponseCheckRegionNsam UserLoadBalancerPoolUpdateResponseCheckRegion = "NSAM" - UserLoadBalancerPoolUpdateResponseCheckRegionSsam UserLoadBalancerPoolUpdateResponseCheckRegion = "SSAM" - UserLoadBalancerPoolUpdateResponseCheckRegionOc UserLoadBalancerPoolUpdateResponseCheckRegion = "OC" - UserLoadBalancerPoolUpdateResponseCheckRegionMe UserLoadBalancerPoolUpdateResponseCheckRegion = "ME" - UserLoadBalancerPoolUpdateResponseCheckRegionNaf UserLoadBalancerPoolUpdateResponseCheckRegion = "NAF" - UserLoadBalancerPoolUpdateResponseCheckRegionSaf UserLoadBalancerPoolUpdateResponseCheckRegion = "SAF" - UserLoadBalancerPoolUpdateResponseCheckRegionSas UserLoadBalancerPoolUpdateResponseCheckRegion = "SAS" - UserLoadBalancerPoolUpdateResponseCheckRegionSeas UserLoadBalancerPoolUpdateResponseCheckRegion = "SEAS" - UserLoadBalancerPoolUpdateResponseCheckRegionNeas UserLoadBalancerPoolUpdateResponseCheckRegion = "NEAS" - UserLoadBalancerPoolUpdateResponseCheckRegionAllRegions UserLoadBalancerPoolUpdateResponseCheckRegion = "ALL_REGIONS" -) - -// Configures load shedding policies and percentages for the pool. -type UserLoadBalancerPoolUpdateResponseLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent float64 `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy UserLoadBalancerPoolUpdateResponseLoadSheddingDefaultPolicy `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent float64 `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy UserLoadBalancerPoolUpdateResponseLoadSheddingSessionPolicy `json:"session_policy"` - JSON userLoadBalancerPoolUpdateResponseLoadSheddingJSON `json:"-"` -} - -// userLoadBalancerPoolUpdateResponseLoadSheddingJSON contains the JSON metadata -// for the struct [UserLoadBalancerPoolUpdateResponseLoadShedding] -type userLoadBalancerPoolUpdateResponseLoadSheddingJSON struct { - DefaultPercent apijson.Field - DefaultPolicy apijson.Field - SessionPercent apijson.Field - SessionPolicy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolUpdateResponseLoadShedding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolUpdateResponseLoadSheddingJSON) RawJSON() string { - return r.raw -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type UserLoadBalancerPoolUpdateResponseLoadSheddingDefaultPolicy string - -const ( - UserLoadBalancerPoolUpdateResponseLoadSheddingDefaultPolicyRandom UserLoadBalancerPoolUpdateResponseLoadSheddingDefaultPolicy = "random" - UserLoadBalancerPoolUpdateResponseLoadSheddingDefaultPolicyHash UserLoadBalancerPoolUpdateResponseLoadSheddingDefaultPolicy = "hash" -) - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type UserLoadBalancerPoolUpdateResponseLoadSheddingSessionPolicy string - -const ( - UserLoadBalancerPoolUpdateResponseLoadSheddingSessionPolicyHash UserLoadBalancerPoolUpdateResponseLoadSheddingSessionPolicy = "hash" -) - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type UserLoadBalancerPoolUpdateResponseNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin UserLoadBalancerPoolUpdateResponseNotificationFilterOrigin `json:"origin,nullable"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool UserLoadBalancerPoolUpdateResponseNotificationFilterPool `json:"pool,nullable"` - JSON userLoadBalancerPoolUpdateResponseNotificationFilterJSON `json:"-"` -} - -// userLoadBalancerPoolUpdateResponseNotificationFilterJSON contains the JSON -// metadata for the struct [UserLoadBalancerPoolUpdateResponseNotificationFilter] -type userLoadBalancerPoolUpdateResponseNotificationFilterJSON struct { - Origin apijson.Field - Pool apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolUpdateResponseNotificationFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolUpdateResponseNotificationFilterJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type UserLoadBalancerPoolUpdateResponseNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON userLoadBalancerPoolUpdateResponseNotificationFilterOriginJSON `json:"-"` -} - -// userLoadBalancerPoolUpdateResponseNotificationFilterOriginJSON contains the JSON -// metadata for the struct -// [UserLoadBalancerPoolUpdateResponseNotificationFilterOrigin] -type userLoadBalancerPoolUpdateResponseNotificationFilterOriginJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolUpdateResponseNotificationFilterOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolUpdateResponseNotificationFilterOriginJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type UserLoadBalancerPoolUpdateResponseNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON userLoadBalancerPoolUpdateResponseNotificationFilterPoolJSON `json:"-"` -} - -// userLoadBalancerPoolUpdateResponseNotificationFilterPoolJSON contains the JSON -// metadata for the struct -// [UserLoadBalancerPoolUpdateResponseNotificationFilterPool] -type userLoadBalancerPoolUpdateResponseNotificationFilterPoolJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolUpdateResponseNotificationFilterPool) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolUpdateResponseNotificationFilterPoolJSON) RawJSON() string { - return r.raw -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type UserLoadBalancerPoolUpdateResponseOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy UserLoadBalancerPoolUpdateResponseOriginSteeringPolicy `json:"policy"` - JSON userLoadBalancerPoolUpdateResponseOriginSteeringJSON `json:"-"` -} - -// userLoadBalancerPoolUpdateResponseOriginSteeringJSON contains the JSON metadata -// for the struct [UserLoadBalancerPoolUpdateResponseOriginSteering] -type userLoadBalancerPoolUpdateResponseOriginSteeringJSON struct { - Policy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolUpdateResponseOriginSteering) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolUpdateResponseOriginSteeringJSON) RawJSON() string { - return r.raw -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type UserLoadBalancerPoolUpdateResponseOriginSteeringPolicy string - -const ( - UserLoadBalancerPoolUpdateResponseOriginSteeringPolicyRandom UserLoadBalancerPoolUpdateResponseOriginSteeringPolicy = "random" - UserLoadBalancerPoolUpdateResponseOriginSteeringPolicyHash UserLoadBalancerPoolUpdateResponseOriginSteeringPolicy = "hash" - UserLoadBalancerPoolUpdateResponseOriginSteeringPolicyLeastOutstandingRequests UserLoadBalancerPoolUpdateResponseOriginSteeringPolicy = "least_outstanding_requests" - UserLoadBalancerPoolUpdateResponseOriginSteeringPolicyLeastConnections UserLoadBalancerPoolUpdateResponseOriginSteeringPolicy = "least_connections" -) - -type UserLoadBalancerPoolUpdateResponseOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address string `json:"address"` - // This field shows up only if the origin is disabled. This field is set with the - // time the origin was disabled. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled bool `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header UserLoadBalancerPoolUpdateResponseOriginsHeader `json:"header"` - // A human-identifiable name for the origin. - Name string `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID string `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight float64 `json:"weight"` - JSON userLoadBalancerPoolUpdateResponseOriginJSON `json:"-"` -} - -// userLoadBalancerPoolUpdateResponseOriginJSON contains the JSON metadata for the -// struct [UserLoadBalancerPoolUpdateResponseOrigin] -type userLoadBalancerPoolUpdateResponseOriginJSON struct { - Address apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Header apijson.Field - Name apijson.Field - VirtualNetworkID apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolUpdateResponseOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolUpdateResponseOriginJSON) RawJSON() string { - return r.raw -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type UserLoadBalancerPoolUpdateResponseOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host []string `json:"Host"` - JSON userLoadBalancerPoolUpdateResponseOriginsHeaderJSON `json:"-"` -} - -// userLoadBalancerPoolUpdateResponseOriginsHeaderJSON contains the JSON metadata -// for the struct [UserLoadBalancerPoolUpdateResponseOriginsHeader] -type userLoadBalancerPoolUpdateResponseOriginsHeaderJSON struct { - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolUpdateResponseOriginsHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolUpdateResponseOriginsHeaderJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolListResponse struct { - ID string `json:"id"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions []UserLoadBalancerPoolListResponseCheckRegion `json:"check_regions,nullable"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A human-readable description of the pool. - Description string `json:"description"` - // This field shows up only if the pool is disabled. This field is set with the - // time the pool was disabled at. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) or disable this pool. Disabled pools will not - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled bool `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, longitude must also be set. - Latitude float64 `json:"latitude"` - // Configures load shedding policies and percentages for the pool. - LoadShedding UserLoadBalancerPoolListResponseLoadShedding `json:"load_shedding"` - // The longitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, latitude must also be set. - Longitude float64 `json:"longitude"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins int64 `json:"minimum_origins"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor interface{} `json:"monitor"` - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - Name string `json:"name"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - NotificationEmail string `json:"notification_email"` - // Filter pool and origin health notifications by resource type or health status. - // Use null to reset. - NotificationFilter UserLoadBalancerPoolListResponseNotificationFilter `json:"notification_filter,nullable"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering UserLoadBalancerPoolListResponseOriginSteering `json:"origin_steering"` - // The list of origins within this pool. Traffic directed at this pool is balanced - // across all currently healthy origins, provided the pool itself is healthy. - Origins []UserLoadBalancerPoolListResponseOrigin `json:"origins"` - JSON userLoadBalancerPoolListResponseJSON `json:"-"` -} - -// userLoadBalancerPoolListResponseJSON contains the JSON metadata for the struct -// [UserLoadBalancerPoolListResponse] -type userLoadBalancerPoolListResponseJSON struct { - ID apijson.Field - CheckRegions apijson.Field - CreatedOn apijson.Field - Description apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Latitude apijson.Field - LoadShedding apijson.Field - Longitude apijson.Field - MinimumOrigins apijson.Field - ModifiedOn apijson.Field - Monitor apijson.Field - Name apijson.Field - NotificationEmail apijson.Field - NotificationFilter apijson.Field - OriginSteering apijson.Field - Origins apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolListResponseJSON) RawJSON() string { - return r.raw -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type UserLoadBalancerPoolListResponseCheckRegion string - -const ( - UserLoadBalancerPoolListResponseCheckRegionWnam UserLoadBalancerPoolListResponseCheckRegion = "WNAM" - UserLoadBalancerPoolListResponseCheckRegionEnam UserLoadBalancerPoolListResponseCheckRegion = "ENAM" - UserLoadBalancerPoolListResponseCheckRegionWeu UserLoadBalancerPoolListResponseCheckRegion = "WEU" - UserLoadBalancerPoolListResponseCheckRegionEeu UserLoadBalancerPoolListResponseCheckRegion = "EEU" - UserLoadBalancerPoolListResponseCheckRegionNsam UserLoadBalancerPoolListResponseCheckRegion = "NSAM" - UserLoadBalancerPoolListResponseCheckRegionSsam UserLoadBalancerPoolListResponseCheckRegion = "SSAM" - UserLoadBalancerPoolListResponseCheckRegionOc UserLoadBalancerPoolListResponseCheckRegion = "OC" - UserLoadBalancerPoolListResponseCheckRegionMe UserLoadBalancerPoolListResponseCheckRegion = "ME" - UserLoadBalancerPoolListResponseCheckRegionNaf UserLoadBalancerPoolListResponseCheckRegion = "NAF" - UserLoadBalancerPoolListResponseCheckRegionSaf UserLoadBalancerPoolListResponseCheckRegion = "SAF" - UserLoadBalancerPoolListResponseCheckRegionSas UserLoadBalancerPoolListResponseCheckRegion = "SAS" - UserLoadBalancerPoolListResponseCheckRegionSeas UserLoadBalancerPoolListResponseCheckRegion = "SEAS" - UserLoadBalancerPoolListResponseCheckRegionNeas UserLoadBalancerPoolListResponseCheckRegion = "NEAS" - UserLoadBalancerPoolListResponseCheckRegionAllRegions UserLoadBalancerPoolListResponseCheckRegion = "ALL_REGIONS" -) - -// Configures load shedding policies and percentages for the pool. -type UserLoadBalancerPoolListResponseLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent float64 `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy UserLoadBalancerPoolListResponseLoadSheddingDefaultPolicy `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent float64 `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy UserLoadBalancerPoolListResponseLoadSheddingSessionPolicy `json:"session_policy"` - JSON userLoadBalancerPoolListResponseLoadSheddingJSON `json:"-"` -} - -// userLoadBalancerPoolListResponseLoadSheddingJSON contains the JSON metadata for -// the struct [UserLoadBalancerPoolListResponseLoadShedding] -type userLoadBalancerPoolListResponseLoadSheddingJSON struct { - DefaultPercent apijson.Field - DefaultPolicy apijson.Field - SessionPercent apijson.Field - SessionPolicy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolListResponseLoadShedding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolListResponseLoadSheddingJSON) RawJSON() string { - return r.raw -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type UserLoadBalancerPoolListResponseLoadSheddingDefaultPolicy string - -const ( - UserLoadBalancerPoolListResponseLoadSheddingDefaultPolicyRandom UserLoadBalancerPoolListResponseLoadSheddingDefaultPolicy = "random" - UserLoadBalancerPoolListResponseLoadSheddingDefaultPolicyHash UserLoadBalancerPoolListResponseLoadSheddingDefaultPolicy = "hash" -) - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type UserLoadBalancerPoolListResponseLoadSheddingSessionPolicy string - -const ( - UserLoadBalancerPoolListResponseLoadSheddingSessionPolicyHash UserLoadBalancerPoolListResponseLoadSheddingSessionPolicy = "hash" -) - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type UserLoadBalancerPoolListResponseNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin UserLoadBalancerPoolListResponseNotificationFilterOrigin `json:"origin,nullable"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool UserLoadBalancerPoolListResponseNotificationFilterPool `json:"pool,nullable"` - JSON userLoadBalancerPoolListResponseNotificationFilterJSON `json:"-"` -} - -// userLoadBalancerPoolListResponseNotificationFilterJSON contains the JSON -// metadata for the struct [UserLoadBalancerPoolListResponseNotificationFilter] -type userLoadBalancerPoolListResponseNotificationFilterJSON struct { - Origin apijson.Field - Pool apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolListResponseNotificationFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolListResponseNotificationFilterJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type UserLoadBalancerPoolListResponseNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON userLoadBalancerPoolListResponseNotificationFilterOriginJSON `json:"-"` -} - -// userLoadBalancerPoolListResponseNotificationFilterOriginJSON contains the JSON -// metadata for the struct -// [UserLoadBalancerPoolListResponseNotificationFilterOrigin] -type userLoadBalancerPoolListResponseNotificationFilterOriginJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolListResponseNotificationFilterOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolListResponseNotificationFilterOriginJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type UserLoadBalancerPoolListResponseNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON userLoadBalancerPoolListResponseNotificationFilterPoolJSON `json:"-"` -} - -// userLoadBalancerPoolListResponseNotificationFilterPoolJSON contains the JSON -// metadata for the struct [UserLoadBalancerPoolListResponseNotificationFilterPool] -type userLoadBalancerPoolListResponseNotificationFilterPoolJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolListResponseNotificationFilterPool) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolListResponseNotificationFilterPoolJSON) RawJSON() string { - return r.raw -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type UserLoadBalancerPoolListResponseOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy UserLoadBalancerPoolListResponseOriginSteeringPolicy `json:"policy"` - JSON userLoadBalancerPoolListResponseOriginSteeringJSON `json:"-"` -} - -// userLoadBalancerPoolListResponseOriginSteeringJSON contains the JSON metadata -// for the struct [UserLoadBalancerPoolListResponseOriginSteering] -type userLoadBalancerPoolListResponseOriginSteeringJSON struct { - Policy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolListResponseOriginSteering) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolListResponseOriginSteeringJSON) RawJSON() string { - return r.raw -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type UserLoadBalancerPoolListResponseOriginSteeringPolicy string - -const ( - UserLoadBalancerPoolListResponseOriginSteeringPolicyRandom UserLoadBalancerPoolListResponseOriginSteeringPolicy = "random" - UserLoadBalancerPoolListResponseOriginSteeringPolicyHash UserLoadBalancerPoolListResponseOriginSteeringPolicy = "hash" - UserLoadBalancerPoolListResponseOriginSteeringPolicyLeastOutstandingRequests UserLoadBalancerPoolListResponseOriginSteeringPolicy = "least_outstanding_requests" - UserLoadBalancerPoolListResponseOriginSteeringPolicyLeastConnections UserLoadBalancerPoolListResponseOriginSteeringPolicy = "least_connections" -) - -type UserLoadBalancerPoolListResponseOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address string `json:"address"` - // This field shows up only if the origin is disabled. This field is set with the - // time the origin was disabled. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled bool `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header UserLoadBalancerPoolListResponseOriginsHeader `json:"header"` - // A human-identifiable name for the origin. - Name string `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID string `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight float64 `json:"weight"` - JSON userLoadBalancerPoolListResponseOriginJSON `json:"-"` -} - -// userLoadBalancerPoolListResponseOriginJSON contains the JSON metadata for the -// struct [UserLoadBalancerPoolListResponseOrigin] -type userLoadBalancerPoolListResponseOriginJSON struct { - Address apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Header apijson.Field - Name apijson.Field - VirtualNetworkID apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolListResponseOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolListResponseOriginJSON) RawJSON() string { - return r.raw -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type UserLoadBalancerPoolListResponseOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host []string `json:"Host"` - JSON userLoadBalancerPoolListResponseOriginsHeaderJSON `json:"-"` -} - -// userLoadBalancerPoolListResponseOriginsHeaderJSON contains the JSON metadata for -// the struct [UserLoadBalancerPoolListResponseOriginsHeader] -type userLoadBalancerPoolListResponseOriginsHeaderJSON struct { - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolListResponseOriginsHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolListResponseOriginsHeaderJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolDeleteResponse struct { - ID string `json:"id"` - JSON userLoadBalancerPoolDeleteResponseJSON `json:"-"` -} - -// userLoadBalancerPoolDeleteResponseJSON contains the JSON metadata for the struct -// [UserLoadBalancerPoolDeleteResponse] -type userLoadBalancerPoolDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolEditResponse struct { - ID string `json:"id"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions []UserLoadBalancerPoolEditResponseCheckRegion `json:"check_regions,nullable"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A human-readable description of the pool. - Description string `json:"description"` - // This field shows up only if the pool is disabled. This field is set with the - // time the pool was disabled at. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) or disable this pool. Disabled pools will not - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled bool `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, longitude must also be set. - Latitude float64 `json:"latitude"` - // Configures load shedding policies and percentages for the pool. - LoadShedding UserLoadBalancerPoolEditResponseLoadShedding `json:"load_shedding"` - // The longitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, latitude must also be set. - Longitude float64 `json:"longitude"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins int64 `json:"minimum_origins"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor interface{} `json:"monitor"` - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - Name string `json:"name"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - NotificationEmail string `json:"notification_email"` - // Filter pool and origin health notifications by resource type or health status. - // Use null to reset. - NotificationFilter UserLoadBalancerPoolEditResponseNotificationFilter `json:"notification_filter,nullable"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering UserLoadBalancerPoolEditResponseOriginSteering `json:"origin_steering"` - // The list of origins within this pool. Traffic directed at this pool is balanced - // across all currently healthy origins, provided the pool itself is healthy. - Origins []UserLoadBalancerPoolEditResponseOrigin `json:"origins"` - JSON userLoadBalancerPoolEditResponseJSON `json:"-"` -} - -// userLoadBalancerPoolEditResponseJSON contains the JSON metadata for the struct -// [UserLoadBalancerPoolEditResponse] -type userLoadBalancerPoolEditResponseJSON struct { - ID apijson.Field - CheckRegions apijson.Field - CreatedOn apijson.Field - Description apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Latitude apijson.Field - LoadShedding apijson.Field - Longitude apijson.Field - MinimumOrigins apijson.Field - ModifiedOn apijson.Field - Monitor apijson.Field - Name apijson.Field - NotificationEmail apijson.Field - NotificationFilter apijson.Field - OriginSteering apijson.Field - Origins apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolEditResponseJSON) RawJSON() string { - return r.raw -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type UserLoadBalancerPoolEditResponseCheckRegion string - -const ( - UserLoadBalancerPoolEditResponseCheckRegionWnam UserLoadBalancerPoolEditResponseCheckRegion = "WNAM" - UserLoadBalancerPoolEditResponseCheckRegionEnam UserLoadBalancerPoolEditResponseCheckRegion = "ENAM" - UserLoadBalancerPoolEditResponseCheckRegionWeu UserLoadBalancerPoolEditResponseCheckRegion = "WEU" - UserLoadBalancerPoolEditResponseCheckRegionEeu UserLoadBalancerPoolEditResponseCheckRegion = "EEU" - UserLoadBalancerPoolEditResponseCheckRegionNsam UserLoadBalancerPoolEditResponseCheckRegion = "NSAM" - UserLoadBalancerPoolEditResponseCheckRegionSsam UserLoadBalancerPoolEditResponseCheckRegion = "SSAM" - UserLoadBalancerPoolEditResponseCheckRegionOc UserLoadBalancerPoolEditResponseCheckRegion = "OC" - UserLoadBalancerPoolEditResponseCheckRegionMe UserLoadBalancerPoolEditResponseCheckRegion = "ME" - UserLoadBalancerPoolEditResponseCheckRegionNaf UserLoadBalancerPoolEditResponseCheckRegion = "NAF" - UserLoadBalancerPoolEditResponseCheckRegionSaf UserLoadBalancerPoolEditResponseCheckRegion = "SAF" - UserLoadBalancerPoolEditResponseCheckRegionSas UserLoadBalancerPoolEditResponseCheckRegion = "SAS" - UserLoadBalancerPoolEditResponseCheckRegionSeas UserLoadBalancerPoolEditResponseCheckRegion = "SEAS" - UserLoadBalancerPoolEditResponseCheckRegionNeas UserLoadBalancerPoolEditResponseCheckRegion = "NEAS" - UserLoadBalancerPoolEditResponseCheckRegionAllRegions UserLoadBalancerPoolEditResponseCheckRegion = "ALL_REGIONS" -) - -// Configures load shedding policies and percentages for the pool. -type UserLoadBalancerPoolEditResponseLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent float64 `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy UserLoadBalancerPoolEditResponseLoadSheddingDefaultPolicy `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent float64 `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy UserLoadBalancerPoolEditResponseLoadSheddingSessionPolicy `json:"session_policy"` - JSON userLoadBalancerPoolEditResponseLoadSheddingJSON `json:"-"` -} - -// userLoadBalancerPoolEditResponseLoadSheddingJSON contains the JSON metadata for -// the struct [UserLoadBalancerPoolEditResponseLoadShedding] -type userLoadBalancerPoolEditResponseLoadSheddingJSON struct { - DefaultPercent apijson.Field - DefaultPolicy apijson.Field - SessionPercent apijson.Field - SessionPolicy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolEditResponseLoadShedding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolEditResponseLoadSheddingJSON) RawJSON() string { - return r.raw -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type UserLoadBalancerPoolEditResponseLoadSheddingDefaultPolicy string - -const ( - UserLoadBalancerPoolEditResponseLoadSheddingDefaultPolicyRandom UserLoadBalancerPoolEditResponseLoadSheddingDefaultPolicy = "random" - UserLoadBalancerPoolEditResponseLoadSheddingDefaultPolicyHash UserLoadBalancerPoolEditResponseLoadSheddingDefaultPolicy = "hash" -) - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type UserLoadBalancerPoolEditResponseLoadSheddingSessionPolicy string - -const ( - UserLoadBalancerPoolEditResponseLoadSheddingSessionPolicyHash UserLoadBalancerPoolEditResponseLoadSheddingSessionPolicy = "hash" -) - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type UserLoadBalancerPoolEditResponseNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin UserLoadBalancerPoolEditResponseNotificationFilterOrigin `json:"origin,nullable"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool UserLoadBalancerPoolEditResponseNotificationFilterPool `json:"pool,nullable"` - JSON userLoadBalancerPoolEditResponseNotificationFilterJSON `json:"-"` -} - -// userLoadBalancerPoolEditResponseNotificationFilterJSON contains the JSON -// metadata for the struct [UserLoadBalancerPoolEditResponseNotificationFilter] -type userLoadBalancerPoolEditResponseNotificationFilterJSON struct { - Origin apijson.Field - Pool apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolEditResponseNotificationFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolEditResponseNotificationFilterJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type UserLoadBalancerPoolEditResponseNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON userLoadBalancerPoolEditResponseNotificationFilterOriginJSON `json:"-"` -} - -// userLoadBalancerPoolEditResponseNotificationFilterOriginJSON contains the JSON -// metadata for the struct -// [UserLoadBalancerPoolEditResponseNotificationFilterOrigin] -type userLoadBalancerPoolEditResponseNotificationFilterOriginJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolEditResponseNotificationFilterOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolEditResponseNotificationFilterOriginJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type UserLoadBalancerPoolEditResponseNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON userLoadBalancerPoolEditResponseNotificationFilterPoolJSON `json:"-"` -} - -// userLoadBalancerPoolEditResponseNotificationFilterPoolJSON contains the JSON -// metadata for the struct [UserLoadBalancerPoolEditResponseNotificationFilterPool] -type userLoadBalancerPoolEditResponseNotificationFilterPoolJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolEditResponseNotificationFilterPool) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolEditResponseNotificationFilterPoolJSON) RawJSON() string { - return r.raw -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type UserLoadBalancerPoolEditResponseOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy UserLoadBalancerPoolEditResponseOriginSteeringPolicy `json:"policy"` - JSON userLoadBalancerPoolEditResponseOriginSteeringJSON `json:"-"` -} - -// userLoadBalancerPoolEditResponseOriginSteeringJSON contains the JSON metadata -// for the struct [UserLoadBalancerPoolEditResponseOriginSteering] -type userLoadBalancerPoolEditResponseOriginSteeringJSON struct { - Policy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolEditResponseOriginSteering) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolEditResponseOriginSteeringJSON) RawJSON() string { - return r.raw -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type UserLoadBalancerPoolEditResponseOriginSteeringPolicy string - -const ( - UserLoadBalancerPoolEditResponseOriginSteeringPolicyRandom UserLoadBalancerPoolEditResponseOriginSteeringPolicy = "random" - UserLoadBalancerPoolEditResponseOriginSteeringPolicyHash UserLoadBalancerPoolEditResponseOriginSteeringPolicy = "hash" - UserLoadBalancerPoolEditResponseOriginSteeringPolicyLeastOutstandingRequests UserLoadBalancerPoolEditResponseOriginSteeringPolicy = "least_outstanding_requests" - UserLoadBalancerPoolEditResponseOriginSteeringPolicyLeastConnections UserLoadBalancerPoolEditResponseOriginSteeringPolicy = "least_connections" -) - -type UserLoadBalancerPoolEditResponseOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address string `json:"address"` - // This field shows up only if the origin is disabled. This field is set with the - // time the origin was disabled. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled bool `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header UserLoadBalancerPoolEditResponseOriginsHeader `json:"header"` - // A human-identifiable name for the origin. - Name string `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID string `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight float64 `json:"weight"` - JSON userLoadBalancerPoolEditResponseOriginJSON `json:"-"` -} - -// userLoadBalancerPoolEditResponseOriginJSON contains the JSON metadata for the -// struct [UserLoadBalancerPoolEditResponseOrigin] -type userLoadBalancerPoolEditResponseOriginJSON struct { - Address apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Header apijson.Field - Name apijson.Field - VirtualNetworkID apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolEditResponseOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolEditResponseOriginJSON) RawJSON() string { - return r.raw -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type UserLoadBalancerPoolEditResponseOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host []string `json:"Host"` - JSON userLoadBalancerPoolEditResponseOriginsHeaderJSON `json:"-"` -} - -// userLoadBalancerPoolEditResponseOriginsHeaderJSON contains the JSON metadata for -// the struct [UserLoadBalancerPoolEditResponseOriginsHeader] -type userLoadBalancerPoolEditResponseOriginsHeaderJSON struct { - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolEditResponseOriginsHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolEditResponseOriginsHeaderJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolGetResponse struct { - ID string `json:"id"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions []UserLoadBalancerPoolGetResponseCheckRegion `json:"check_regions,nullable"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // A human-readable description of the pool. - Description string `json:"description"` - // This field shows up only if the pool is disabled. This field is set with the - // time the pool was disabled at. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) or disable this pool. Disabled pools will not - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled bool `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, longitude must also be set. - Latitude float64 `json:"latitude"` - // Configures load shedding policies and percentages for the pool. - LoadShedding UserLoadBalancerPoolGetResponseLoadShedding `json:"load_shedding"` - // The longitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, latitude must also be set. - Longitude float64 `json:"longitude"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins int64 `json:"minimum_origins"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor interface{} `json:"monitor"` - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - Name string `json:"name"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - NotificationEmail string `json:"notification_email"` - // Filter pool and origin health notifications by resource type or health status. - // Use null to reset. - NotificationFilter UserLoadBalancerPoolGetResponseNotificationFilter `json:"notification_filter,nullable"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering UserLoadBalancerPoolGetResponseOriginSteering `json:"origin_steering"` - // The list of origins within this pool. Traffic directed at this pool is balanced - // across all currently healthy origins, provided the pool itself is healthy. - Origins []UserLoadBalancerPoolGetResponseOrigin `json:"origins"` - JSON userLoadBalancerPoolGetResponseJSON `json:"-"` -} - -// userLoadBalancerPoolGetResponseJSON contains the JSON metadata for the struct -// [UserLoadBalancerPoolGetResponse] -type userLoadBalancerPoolGetResponseJSON struct { - ID apijson.Field - CheckRegions apijson.Field - CreatedOn apijson.Field - Description apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Latitude apijson.Field - LoadShedding apijson.Field - Longitude apijson.Field - MinimumOrigins apijson.Field - ModifiedOn apijson.Field - Monitor apijson.Field - Name apijson.Field - NotificationEmail apijson.Field - NotificationFilter apijson.Field - OriginSteering apijson.Field - Origins apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolGetResponseJSON) RawJSON() string { - return r.raw -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type UserLoadBalancerPoolGetResponseCheckRegion string - -const ( - UserLoadBalancerPoolGetResponseCheckRegionWnam UserLoadBalancerPoolGetResponseCheckRegion = "WNAM" - UserLoadBalancerPoolGetResponseCheckRegionEnam UserLoadBalancerPoolGetResponseCheckRegion = "ENAM" - UserLoadBalancerPoolGetResponseCheckRegionWeu UserLoadBalancerPoolGetResponseCheckRegion = "WEU" - UserLoadBalancerPoolGetResponseCheckRegionEeu UserLoadBalancerPoolGetResponseCheckRegion = "EEU" - UserLoadBalancerPoolGetResponseCheckRegionNsam UserLoadBalancerPoolGetResponseCheckRegion = "NSAM" - UserLoadBalancerPoolGetResponseCheckRegionSsam UserLoadBalancerPoolGetResponseCheckRegion = "SSAM" - UserLoadBalancerPoolGetResponseCheckRegionOc UserLoadBalancerPoolGetResponseCheckRegion = "OC" - UserLoadBalancerPoolGetResponseCheckRegionMe UserLoadBalancerPoolGetResponseCheckRegion = "ME" - UserLoadBalancerPoolGetResponseCheckRegionNaf UserLoadBalancerPoolGetResponseCheckRegion = "NAF" - UserLoadBalancerPoolGetResponseCheckRegionSaf UserLoadBalancerPoolGetResponseCheckRegion = "SAF" - UserLoadBalancerPoolGetResponseCheckRegionSas UserLoadBalancerPoolGetResponseCheckRegion = "SAS" - UserLoadBalancerPoolGetResponseCheckRegionSeas UserLoadBalancerPoolGetResponseCheckRegion = "SEAS" - UserLoadBalancerPoolGetResponseCheckRegionNeas UserLoadBalancerPoolGetResponseCheckRegion = "NEAS" - UserLoadBalancerPoolGetResponseCheckRegionAllRegions UserLoadBalancerPoolGetResponseCheckRegion = "ALL_REGIONS" -) - -// Configures load shedding policies and percentages for the pool. -type UserLoadBalancerPoolGetResponseLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent float64 `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy UserLoadBalancerPoolGetResponseLoadSheddingDefaultPolicy `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent float64 `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy UserLoadBalancerPoolGetResponseLoadSheddingSessionPolicy `json:"session_policy"` - JSON userLoadBalancerPoolGetResponseLoadSheddingJSON `json:"-"` -} - -// userLoadBalancerPoolGetResponseLoadSheddingJSON contains the JSON metadata for -// the struct [UserLoadBalancerPoolGetResponseLoadShedding] -type userLoadBalancerPoolGetResponseLoadSheddingJSON struct { - DefaultPercent apijson.Field - DefaultPolicy apijson.Field - SessionPercent apijson.Field - SessionPolicy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolGetResponseLoadShedding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolGetResponseLoadSheddingJSON) RawJSON() string { - return r.raw -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type UserLoadBalancerPoolGetResponseLoadSheddingDefaultPolicy string - -const ( - UserLoadBalancerPoolGetResponseLoadSheddingDefaultPolicyRandom UserLoadBalancerPoolGetResponseLoadSheddingDefaultPolicy = "random" - UserLoadBalancerPoolGetResponseLoadSheddingDefaultPolicyHash UserLoadBalancerPoolGetResponseLoadSheddingDefaultPolicy = "hash" -) - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type UserLoadBalancerPoolGetResponseLoadSheddingSessionPolicy string - -const ( - UserLoadBalancerPoolGetResponseLoadSheddingSessionPolicyHash UserLoadBalancerPoolGetResponseLoadSheddingSessionPolicy = "hash" -) - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type UserLoadBalancerPoolGetResponseNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin UserLoadBalancerPoolGetResponseNotificationFilterOrigin `json:"origin,nullable"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool UserLoadBalancerPoolGetResponseNotificationFilterPool `json:"pool,nullable"` - JSON userLoadBalancerPoolGetResponseNotificationFilterJSON `json:"-"` -} - -// userLoadBalancerPoolGetResponseNotificationFilterJSON contains the JSON metadata -// for the struct [UserLoadBalancerPoolGetResponseNotificationFilter] -type userLoadBalancerPoolGetResponseNotificationFilterJSON struct { - Origin apijson.Field - Pool apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolGetResponseNotificationFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolGetResponseNotificationFilterJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type UserLoadBalancerPoolGetResponseNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON userLoadBalancerPoolGetResponseNotificationFilterOriginJSON `json:"-"` -} - -// userLoadBalancerPoolGetResponseNotificationFilterOriginJSON contains the JSON -// metadata for the struct -// [UserLoadBalancerPoolGetResponseNotificationFilterOrigin] -type userLoadBalancerPoolGetResponseNotificationFilterOriginJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolGetResponseNotificationFilterOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolGetResponseNotificationFilterOriginJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type UserLoadBalancerPoolGetResponseNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON userLoadBalancerPoolGetResponseNotificationFilterPoolJSON `json:"-"` -} - -// userLoadBalancerPoolGetResponseNotificationFilterPoolJSON contains the JSON -// metadata for the struct [UserLoadBalancerPoolGetResponseNotificationFilterPool] -type userLoadBalancerPoolGetResponseNotificationFilterPoolJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolGetResponseNotificationFilterPool) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolGetResponseNotificationFilterPoolJSON) RawJSON() string { - return r.raw -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type UserLoadBalancerPoolGetResponseOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy UserLoadBalancerPoolGetResponseOriginSteeringPolicy `json:"policy"` - JSON userLoadBalancerPoolGetResponseOriginSteeringJSON `json:"-"` -} - -// userLoadBalancerPoolGetResponseOriginSteeringJSON contains the JSON metadata for -// the struct [UserLoadBalancerPoolGetResponseOriginSteering] -type userLoadBalancerPoolGetResponseOriginSteeringJSON struct { - Policy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolGetResponseOriginSteering) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolGetResponseOriginSteeringJSON) RawJSON() string { - return r.raw -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type UserLoadBalancerPoolGetResponseOriginSteeringPolicy string - -const ( - UserLoadBalancerPoolGetResponseOriginSteeringPolicyRandom UserLoadBalancerPoolGetResponseOriginSteeringPolicy = "random" - UserLoadBalancerPoolGetResponseOriginSteeringPolicyHash UserLoadBalancerPoolGetResponseOriginSteeringPolicy = "hash" - UserLoadBalancerPoolGetResponseOriginSteeringPolicyLeastOutstandingRequests UserLoadBalancerPoolGetResponseOriginSteeringPolicy = "least_outstanding_requests" - UserLoadBalancerPoolGetResponseOriginSteeringPolicyLeastConnections UserLoadBalancerPoolGetResponseOriginSteeringPolicy = "least_connections" -) - -type UserLoadBalancerPoolGetResponseOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address string `json:"address"` - // This field shows up only if the origin is disabled. This field is set with the - // time the origin was disabled. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled bool `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header UserLoadBalancerPoolGetResponseOriginsHeader `json:"header"` - // A human-identifiable name for the origin. - Name string `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID string `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight float64 `json:"weight"` - JSON userLoadBalancerPoolGetResponseOriginJSON `json:"-"` -} - -// userLoadBalancerPoolGetResponseOriginJSON contains the JSON metadata for the -// struct [UserLoadBalancerPoolGetResponseOrigin] -type userLoadBalancerPoolGetResponseOriginJSON struct { - Address apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Header apijson.Field - Name apijson.Field - VirtualNetworkID apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolGetResponseOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolGetResponseOriginJSON) RawJSON() string { - return r.raw -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type UserLoadBalancerPoolGetResponseOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host []string `json:"Host"` - JSON userLoadBalancerPoolGetResponseOriginsHeaderJSON `json:"-"` -} - -// userLoadBalancerPoolGetResponseOriginsHeaderJSON contains the JSON metadata for -// the struct [UserLoadBalancerPoolGetResponseOriginsHeader] -type userLoadBalancerPoolGetResponseOriginsHeaderJSON struct { - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolGetResponseOriginsHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolGetResponseOriginsHeaderJSON) RawJSON() string { - return r.raw -} - -// A list of regions from which to run health checks. Null means every Cloudflare -// data center. -// -// Union satisfied by [UserLoadBalancerPoolHealthResponseUnknown] or -// [shared.UnionString]. -type UserLoadBalancerPoolHealthResponse interface { - ImplementsUserLoadBalancerPoolHealthResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*UserLoadBalancerPoolHealthResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type UserLoadBalancerPoolPreviewResponse struct { - // Monitored pool IDs mapped to their respective names. - Pools map[string]string `json:"pools"` - PreviewID string `json:"preview_id"` - JSON userLoadBalancerPoolPreviewResponseJSON `json:"-"` -} - -// userLoadBalancerPoolPreviewResponseJSON contains the JSON metadata for the -// struct [UserLoadBalancerPoolPreviewResponse] -type userLoadBalancerPoolPreviewResponseJSON struct { - Pools apijson.Field - PreviewID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolPreviewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolPreviewResponseJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolReferencesResponse struct { - ReferenceType UserLoadBalancerPoolReferencesResponseReferenceType `json:"reference_type"` - ResourceID string `json:"resource_id"` - ResourceName string `json:"resource_name"` - ResourceType string `json:"resource_type"` - JSON userLoadBalancerPoolReferencesResponseJSON `json:"-"` -} - -// userLoadBalancerPoolReferencesResponseJSON contains the JSON metadata for the -// struct [UserLoadBalancerPoolReferencesResponse] -type userLoadBalancerPoolReferencesResponseJSON struct { - ReferenceType apijson.Field - ResourceID apijson.Field - ResourceName apijson.Field - ResourceType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolReferencesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolReferencesResponseJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolReferencesResponseReferenceType string - -const ( - UserLoadBalancerPoolReferencesResponseReferenceTypeStar UserLoadBalancerPoolReferencesResponseReferenceType = "*" - UserLoadBalancerPoolReferencesResponseReferenceTypeReferral UserLoadBalancerPoolReferencesResponseReferenceType = "referral" - UserLoadBalancerPoolReferencesResponseReferenceTypeReferrer UserLoadBalancerPoolReferencesResponseReferenceType = "referrer" -) - -type UserLoadBalancerPoolNewParams struct { - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - Name param.Field[string] `json:"name,required"` - // The list of origins within this pool. Traffic directed at this pool is balanced - // across all currently healthy origins, provided the pool itself is healthy. - Origins param.Field[[]UserLoadBalancerPoolNewParamsOrigin] `json:"origins,required"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions param.Field[[]UserLoadBalancerPoolNewParamsCheckRegion] `json:"check_regions"` - // A human-readable description of the pool. - Description param.Field[string] `json:"description"` - // Whether to enable (the default) or disable this pool. Disabled pools will not - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled param.Field[bool] `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, longitude must also be set. - Latitude param.Field[float64] `json:"latitude"` - // Configures load shedding policies and percentages for the pool. - LoadShedding param.Field[UserLoadBalancerPoolNewParamsLoadShedding] `json:"load_shedding"` - // The longitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, latitude must also be set. - Longitude param.Field[float64] `json:"longitude"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins param.Field[int64] `json:"minimum_origins"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor param.Field[interface{}] `json:"monitor"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - NotificationEmail param.Field[string] `json:"notification_email"` - // Filter pool and origin health notifications by resource type or health status. - // Use null to reset. - NotificationFilter param.Field[UserLoadBalancerPoolNewParamsNotificationFilter] `json:"notification_filter"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering param.Field[UserLoadBalancerPoolNewParamsOriginSteering] `json:"origin_steering"` -} - -func (r UserLoadBalancerPoolNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type UserLoadBalancerPoolNewParamsOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address param.Field[string] `json:"address"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled param.Field[bool] `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header param.Field[UserLoadBalancerPoolNewParamsOriginsHeader] `json:"header"` - // A human-identifiable name for the origin. - Name param.Field[string] `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID param.Field[string] `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight param.Field[float64] `json:"weight"` -} - -func (r UserLoadBalancerPoolNewParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type UserLoadBalancerPoolNewParamsOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host param.Field[[]string] `json:"Host"` -} - -func (r UserLoadBalancerPoolNewParamsOriginsHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type UserLoadBalancerPoolNewParamsCheckRegion string - -const ( - UserLoadBalancerPoolNewParamsCheckRegionWnam UserLoadBalancerPoolNewParamsCheckRegion = "WNAM" - UserLoadBalancerPoolNewParamsCheckRegionEnam UserLoadBalancerPoolNewParamsCheckRegion = "ENAM" - UserLoadBalancerPoolNewParamsCheckRegionWeu UserLoadBalancerPoolNewParamsCheckRegion = "WEU" - UserLoadBalancerPoolNewParamsCheckRegionEeu UserLoadBalancerPoolNewParamsCheckRegion = "EEU" - UserLoadBalancerPoolNewParamsCheckRegionNsam UserLoadBalancerPoolNewParamsCheckRegion = "NSAM" - UserLoadBalancerPoolNewParamsCheckRegionSsam UserLoadBalancerPoolNewParamsCheckRegion = "SSAM" - UserLoadBalancerPoolNewParamsCheckRegionOc UserLoadBalancerPoolNewParamsCheckRegion = "OC" - UserLoadBalancerPoolNewParamsCheckRegionMe UserLoadBalancerPoolNewParamsCheckRegion = "ME" - UserLoadBalancerPoolNewParamsCheckRegionNaf UserLoadBalancerPoolNewParamsCheckRegion = "NAF" - UserLoadBalancerPoolNewParamsCheckRegionSaf UserLoadBalancerPoolNewParamsCheckRegion = "SAF" - UserLoadBalancerPoolNewParamsCheckRegionSas UserLoadBalancerPoolNewParamsCheckRegion = "SAS" - UserLoadBalancerPoolNewParamsCheckRegionSeas UserLoadBalancerPoolNewParamsCheckRegion = "SEAS" - UserLoadBalancerPoolNewParamsCheckRegionNeas UserLoadBalancerPoolNewParamsCheckRegion = "NEAS" - UserLoadBalancerPoolNewParamsCheckRegionAllRegions UserLoadBalancerPoolNewParamsCheckRegion = "ALL_REGIONS" -) - -// Configures load shedding policies and percentages for the pool. -type UserLoadBalancerPoolNewParamsLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent param.Field[float64] `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy param.Field[UserLoadBalancerPoolNewParamsLoadSheddingDefaultPolicy] `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent param.Field[float64] `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy param.Field[UserLoadBalancerPoolNewParamsLoadSheddingSessionPolicy] `json:"session_policy"` -} - -func (r UserLoadBalancerPoolNewParamsLoadShedding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type UserLoadBalancerPoolNewParamsLoadSheddingDefaultPolicy string - -const ( - UserLoadBalancerPoolNewParamsLoadSheddingDefaultPolicyRandom UserLoadBalancerPoolNewParamsLoadSheddingDefaultPolicy = "random" - UserLoadBalancerPoolNewParamsLoadSheddingDefaultPolicyHash UserLoadBalancerPoolNewParamsLoadSheddingDefaultPolicy = "hash" -) - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type UserLoadBalancerPoolNewParamsLoadSheddingSessionPolicy string - -const ( - UserLoadBalancerPoolNewParamsLoadSheddingSessionPolicyHash UserLoadBalancerPoolNewParamsLoadSheddingSessionPolicy = "hash" -) - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type UserLoadBalancerPoolNewParamsNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin param.Field[UserLoadBalancerPoolNewParamsNotificationFilterOrigin] `json:"origin"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool param.Field[UserLoadBalancerPoolNewParamsNotificationFilterPool] `json:"pool"` -} - -func (r UserLoadBalancerPoolNewParamsNotificationFilter) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type UserLoadBalancerPoolNewParamsNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r UserLoadBalancerPoolNewParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type UserLoadBalancerPoolNewParamsNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r UserLoadBalancerPoolNewParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type UserLoadBalancerPoolNewParamsOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy param.Field[UserLoadBalancerPoolNewParamsOriginSteeringPolicy] `json:"policy"` -} - -func (r UserLoadBalancerPoolNewParamsOriginSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type UserLoadBalancerPoolNewParamsOriginSteeringPolicy string - -const ( - UserLoadBalancerPoolNewParamsOriginSteeringPolicyRandom UserLoadBalancerPoolNewParamsOriginSteeringPolicy = "random" - UserLoadBalancerPoolNewParamsOriginSteeringPolicyHash UserLoadBalancerPoolNewParamsOriginSteeringPolicy = "hash" - UserLoadBalancerPoolNewParamsOriginSteeringPolicyLeastOutstandingRequests UserLoadBalancerPoolNewParamsOriginSteeringPolicy = "least_outstanding_requests" - UserLoadBalancerPoolNewParamsOriginSteeringPolicyLeastConnections UserLoadBalancerPoolNewParamsOriginSteeringPolicy = "least_connections" -) - -type UserLoadBalancerPoolNewResponseEnvelope struct { - Errors []UserLoadBalancerPoolNewResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerPoolNewResponseEnvelopeMessages `json:"messages,required"` - Result UserLoadBalancerPoolNewResponse `json:"result,required"` - // Whether the API call was successful - Success UserLoadBalancerPoolNewResponseEnvelopeSuccess `json:"success,required"` - JSON userLoadBalancerPoolNewResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerPoolNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [UserLoadBalancerPoolNewResponseEnvelope] -type userLoadBalancerPoolNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPoolNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerPoolNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [UserLoadBalancerPoolNewResponseEnvelopeErrors] -type userLoadBalancerPoolNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPoolNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerPoolNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [UserLoadBalancerPoolNewResponseEnvelopeMessages] -type userLoadBalancerPoolNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerPoolNewResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerPoolNewResponseEnvelopeSuccessTrue UserLoadBalancerPoolNewResponseEnvelopeSuccess = true -) - -type UserLoadBalancerPoolUpdateParams struct { - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - Name param.Field[string] `json:"name,required"` - // The list of origins within this pool. Traffic directed at this pool is balanced - // across all currently healthy origins, provided the pool itself is healthy. - Origins param.Field[[]UserLoadBalancerPoolUpdateParamsOrigin] `json:"origins,required"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions param.Field[[]UserLoadBalancerPoolUpdateParamsCheckRegion] `json:"check_regions"` - // A human-readable description of the pool. - Description param.Field[string] `json:"description"` - // Whether to enable (the default) or disable this pool. Disabled pools will not - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled param.Field[bool] `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, longitude must also be set. - Latitude param.Field[float64] `json:"latitude"` - // Configures load shedding policies and percentages for the pool. - LoadShedding param.Field[UserLoadBalancerPoolUpdateParamsLoadShedding] `json:"load_shedding"` - // The longitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, latitude must also be set. - Longitude param.Field[float64] `json:"longitude"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins param.Field[int64] `json:"minimum_origins"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor param.Field[interface{}] `json:"monitor"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - NotificationEmail param.Field[string] `json:"notification_email"` - // Filter pool and origin health notifications by resource type or health status. - // Use null to reset. - NotificationFilter param.Field[UserLoadBalancerPoolUpdateParamsNotificationFilter] `json:"notification_filter"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering param.Field[UserLoadBalancerPoolUpdateParamsOriginSteering] `json:"origin_steering"` -} - -func (r UserLoadBalancerPoolUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type UserLoadBalancerPoolUpdateParamsOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address param.Field[string] `json:"address"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled param.Field[bool] `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header param.Field[UserLoadBalancerPoolUpdateParamsOriginsHeader] `json:"header"` - // A human-identifiable name for the origin. - Name param.Field[string] `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID param.Field[string] `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight param.Field[float64] `json:"weight"` -} - -func (r UserLoadBalancerPoolUpdateParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type UserLoadBalancerPoolUpdateParamsOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host param.Field[[]string] `json:"Host"` -} - -func (r UserLoadBalancerPoolUpdateParamsOriginsHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type UserLoadBalancerPoolUpdateParamsCheckRegion string - -const ( - UserLoadBalancerPoolUpdateParamsCheckRegionWnam UserLoadBalancerPoolUpdateParamsCheckRegion = "WNAM" - UserLoadBalancerPoolUpdateParamsCheckRegionEnam UserLoadBalancerPoolUpdateParamsCheckRegion = "ENAM" - UserLoadBalancerPoolUpdateParamsCheckRegionWeu UserLoadBalancerPoolUpdateParamsCheckRegion = "WEU" - UserLoadBalancerPoolUpdateParamsCheckRegionEeu UserLoadBalancerPoolUpdateParamsCheckRegion = "EEU" - UserLoadBalancerPoolUpdateParamsCheckRegionNsam UserLoadBalancerPoolUpdateParamsCheckRegion = "NSAM" - UserLoadBalancerPoolUpdateParamsCheckRegionSsam UserLoadBalancerPoolUpdateParamsCheckRegion = "SSAM" - UserLoadBalancerPoolUpdateParamsCheckRegionOc UserLoadBalancerPoolUpdateParamsCheckRegion = "OC" - UserLoadBalancerPoolUpdateParamsCheckRegionMe UserLoadBalancerPoolUpdateParamsCheckRegion = "ME" - UserLoadBalancerPoolUpdateParamsCheckRegionNaf UserLoadBalancerPoolUpdateParamsCheckRegion = "NAF" - UserLoadBalancerPoolUpdateParamsCheckRegionSaf UserLoadBalancerPoolUpdateParamsCheckRegion = "SAF" - UserLoadBalancerPoolUpdateParamsCheckRegionSas UserLoadBalancerPoolUpdateParamsCheckRegion = "SAS" - UserLoadBalancerPoolUpdateParamsCheckRegionSeas UserLoadBalancerPoolUpdateParamsCheckRegion = "SEAS" - UserLoadBalancerPoolUpdateParamsCheckRegionNeas UserLoadBalancerPoolUpdateParamsCheckRegion = "NEAS" - UserLoadBalancerPoolUpdateParamsCheckRegionAllRegions UserLoadBalancerPoolUpdateParamsCheckRegion = "ALL_REGIONS" -) - -// Configures load shedding policies and percentages for the pool. -type UserLoadBalancerPoolUpdateParamsLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent param.Field[float64] `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy param.Field[UserLoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy] `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent param.Field[float64] `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy param.Field[UserLoadBalancerPoolUpdateParamsLoadSheddingSessionPolicy] `json:"session_policy"` -} - -func (r UserLoadBalancerPoolUpdateParamsLoadShedding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type UserLoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy string - -const ( - UserLoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyRandom UserLoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy = "random" - UserLoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyHash UserLoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy = "hash" -) - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type UserLoadBalancerPoolUpdateParamsLoadSheddingSessionPolicy string - -const ( - UserLoadBalancerPoolUpdateParamsLoadSheddingSessionPolicyHash UserLoadBalancerPoolUpdateParamsLoadSheddingSessionPolicy = "hash" -) - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type UserLoadBalancerPoolUpdateParamsNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin param.Field[UserLoadBalancerPoolUpdateParamsNotificationFilterOrigin] `json:"origin"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool param.Field[UserLoadBalancerPoolUpdateParamsNotificationFilterPool] `json:"pool"` -} - -func (r UserLoadBalancerPoolUpdateParamsNotificationFilter) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type UserLoadBalancerPoolUpdateParamsNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r UserLoadBalancerPoolUpdateParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type UserLoadBalancerPoolUpdateParamsNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r UserLoadBalancerPoolUpdateParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type UserLoadBalancerPoolUpdateParamsOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy param.Field[UserLoadBalancerPoolUpdateParamsOriginSteeringPolicy] `json:"policy"` -} - -func (r UserLoadBalancerPoolUpdateParamsOriginSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type UserLoadBalancerPoolUpdateParamsOriginSteeringPolicy string - -const ( - UserLoadBalancerPoolUpdateParamsOriginSteeringPolicyRandom UserLoadBalancerPoolUpdateParamsOriginSteeringPolicy = "random" - UserLoadBalancerPoolUpdateParamsOriginSteeringPolicyHash UserLoadBalancerPoolUpdateParamsOriginSteeringPolicy = "hash" - UserLoadBalancerPoolUpdateParamsOriginSteeringPolicyLeastOutstandingRequests UserLoadBalancerPoolUpdateParamsOriginSteeringPolicy = "least_outstanding_requests" - UserLoadBalancerPoolUpdateParamsOriginSteeringPolicyLeastConnections UserLoadBalancerPoolUpdateParamsOriginSteeringPolicy = "least_connections" -) - -type UserLoadBalancerPoolUpdateResponseEnvelope struct { - Errors []UserLoadBalancerPoolUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerPoolUpdateResponseEnvelopeMessages `json:"messages,required"` - Result UserLoadBalancerPoolUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success UserLoadBalancerPoolUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON userLoadBalancerPoolUpdateResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerPoolUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [UserLoadBalancerPoolUpdateResponseEnvelope] -type userLoadBalancerPoolUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPoolUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerPoolUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [UserLoadBalancerPoolUpdateResponseEnvelopeErrors] -type userLoadBalancerPoolUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPoolUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerPoolUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [UserLoadBalancerPoolUpdateResponseEnvelopeMessages] -type userLoadBalancerPoolUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerPoolUpdateResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerPoolUpdateResponseEnvelopeSuccessTrue UserLoadBalancerPoolUpdateResponseEnvelopeSuccess = true -) - -type UserLoadBalancerPoolListParams struct { - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor param.Field[interface{}] `query:"monitor"` -} - -// URLQuery serializes [UserLoadBalancerPoolListParams]'s query parameters as -// `url.Values`. -func (r UserLoadBalancerPoolListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type UserLoadBalancerPoolListResponseEnvelope struct { - Errors []UserLoadBalancerPoolListResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerPoolListResponseEnvelopeMessages `json:"messages,required"` - Result []UserLoadBalancerPoolListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success UserLoadBalancerPoolListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo UserLoadBalancerPoolListResponseEnvelopeResultInfo `json:"result_info"` - JSON userLoadBalancerPoolListResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerPoolListResponseEnvelopeJSON contains the JSON metadata for the -// struct [UserLoadBalancerPoolListResponseEnvelope] -type userLoadBalancerPoolListResponseEnvelopeJSON 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 *UserLoadBalancerPoolListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPoolListResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerPoolListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [UserLoadBalancerPoolListResponseEnvelopeErrors] -type userLoadBalancerPoolListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPoolListResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerPoolListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [UserLoadBalancerPoolListResponseEnvelopeMessages] -type userLoadBalancerPoolListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerPoolListResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerPoolListResponseEnvelopeSuccessTrue UserLoadBalancerPoolListResponseEnvelopeSuccess = true -) - -type UserLoadBalancerPoolListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON userLoadBalancerPoolListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// userLoadBalancerPoolListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [UserLoadBalancerPoolListResponseEnvelopeResultInfo] -type userLoadBalancerPoolListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolDeleteResponseEnvelope struct { - Errors []UserLoadBalancerPoolDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerPoolDeleteResponseEnvelopeMessages `json:"messages,required"` - Result UserLoadBalancerPoolDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success UserLoadBalancerPoolDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON userLoadBalancerPoolDeleteResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerPoolDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [UserLoadBalancerPoolDeleteResponseEnvelope] -type userLoadBalancerPoolDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPoolDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerPoolDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [UserLoadBalancerPoolDeleteResponseEnvelopeErrors] -type userLoadBalancerPoolDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPoolDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerPoolDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [UserLoadBalancerPoolDeleteResponseEnvelopeMessages] -type userLoadBalancerPoolDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerPoolDeleteResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerPoolDeleteResponseEnvelopeSuccessTrue UserLoadBalancerPoolDeleteResponseEnvelopeSuccess = true -) - -type UserLoadBalancerPoolEditParams struct { - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions param.Field[[]UserLoadBalancerPoolEditParamsCheckRegion] `json:"check_regions"` - // A human-readable description of the pool. - Description param.Field[string] `json:"description"` - // Whether to enable (the default) or disable this pool. Disabled pools will not - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled param.Field[bool] `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, longitude must also be set. - Latitude param.Field[float64] `json:"latitude"` - // Configures load shedding policies and percentages for the pool. - LoadShedding param.Field[UserLoadBalancerPoolEditParamsLoadShedding] `json:"load_shedding"` - // The longitude of the data center containing the origins used in this pool in - // decimal degrees. If this is set, latitude must also be set. - Longitude param.Field[float64] `json:"longitude"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins param.Field[int64] `json:"minimum_origins"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor param.Field[interface{}] `json:"monitor"` - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - Name param.Field[string] `json:"name"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - NotificationEmail param.Field[string] `json:"notification_email"` - // Filter pool and origin health notifications by resource type or health status. - // Use null to reset. - NotificationFilter param.Field[UserLoadBalancerPoolEditParamsNotificationFilter] `json:"notification_filter"` - // Configures origin steering for the pool. Controls how origins are selected for - // new sessions and traffic without session affinity. - OriginSteering param.Field[UserLoadBalancerPoolEditParamsOriginSteering] `json:"origin_steering"` - // The list of origins within this pool. Traffic directed at this pool is balanced - // across all currently healthy origins, provided the pool itself is healthy. - Origins param.Field[[]UserLoadBalancerPoolEditParamsOrigin] `json:"origins"` -} - -func (r UserLoadBalancerPoolEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type UserLoadBalancerPoolEditParamsCheckRegion string - -const ( - UserLoadBalancerPoolEditParamsCheckRegionWnam UserLoadBalancerPoolEditParamsCheckRegion = "WNAM" - UserLoadBalancerPoolEditParamsCheckRegionEnam UserLoadBalancerPoolEditParamsCheckRegion = "ENAM" - UserLoadBalancerPoolEditParamsCheckRegionWeu UserLoadBalancerPoolEditParamsCheckRegion = "WEU" - UserLoadBalancerPoolEditParamsCheckRegionEeu UserLoadBalancerPoolEditParamsCheckRegion = "EEU" - UserLoadBalancerPoolEditParamsCheckRegionNsam UserLoadBalancerPoolEditParamsCheckRegion = "NSAM" - UserLoadBalancerPoolEditParamsCheckRegionSsam UserLoadBalancerPoolEditParamsCheckRegion = "SSAM" - UserLoadBalancerPoolEditParamsCheckRegionOc UserLoadBalancerPoolEditParamsCheckRegion = "OC" - UserLoadBalancerPoolEditParamsCheckRegionMe UserLoadBalancerPoolEditParamsCheckRegion = "ME" - UserLoadBalancerPoolEditParamsCheckRegionNaf UserLoadBalancerPoolEditParamsCheckRegion = "NAF" - UserLoadBalancerPoolEditParamsCheckRegionSaf UserLoadBalancerPoolEditParamsCheckRegion = "SAF" - UserLoadBalancerPoolEditParamsCheckRegionSas UserLoadBalancerPoolEditParamsCheckRegion = "SAS" - UserLoadBalancerPoolEditParamsCheckRegionSeas UserLoadBalancerPoolEditParamsCheckRegion = "SEAS" - UserLoadBalancerPoolEditParamsCheckRegionNeas UserLoadBalancerPoolEditParamsCheckRegion = "NEAS" - UserLoadBalancerPoolEditParamsCheckRegionAllRegions UserLoadBalancerPoolEditParamsCheckRegion = "ALL_REGIONS" -) - -// Configures load shedding policies and percentages for the pool. -type UserLoadBalancerPoolEditParamsLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent param.Field[float64] `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy param.Field[UserLoadBalancerPoolEditParamsLoadSheddingDefaultPolicy] `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent param.Field[float64] `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy param.Field[UserLoadBalancerPoolEditParamsLoadSheddingSessionPolicy] `json:"session_policy"` -} - -func (r UserLoadBalancerPoolEditParamsLoadShedding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type UserLoadBalancerPoolEditParamsLoadSheddingDefaultPolicy string - -const ( - UserLoadBalancerPoolEditParamsLoadSheddingDefaultPolicyRandom UserLoadBalancerPoolEditParamsLoadSheddingDefaultPolicy = "random" - UserLoadBalancerPoolEditParamsLoadSheddingDefaultPolicyHash UserLoadBalancerPoolEditParamsLoadSheddingDefaultPolicy = "hash" -) - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type UserLoadBalancerPoolEditParamsLoadSheddingSessionPolicy string - -const ( - UserLoadBalancerPoolEditParamsLoadSheddingSessionPolicyHash UserLoadBalancerPoolEditParamsLoadSheddingSessionPolicy = "hash" -) - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type UserLoadBalancerPoolEditParamsNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin param.Field[UserLoadBalancerPoolEditParamsNotificationFilterOrigin] `json:"origin"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool param.Field[UserLoadBalancerPoolEditParamsNotificationFilterPool] `json:"pool"` -} - -func (r UserLoadBalancerPoolEditParamsNotificationFilter) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type UserLoadBalancerPoolEditParamsNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r UserLoadBalancerPoolEditParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type UserLoadBalancerPoolEditParamsNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r UserLoadBalancerPoolEditParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type UserLoadBalancerPoolEditParamsOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy param.Field[UserLoadBalancerPoolEditParamsOriginSteeringPolicy] `json:"policy"` -} - -func (r UserLoadBalancerPoolEditParamsOriginSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type UserLoadBalancerPoolEditParamsOriginSteeringPolicy string - -const ( - UserLoadBalancerPoolEditParamsOriginSteeringPolicyRandom UserLoadBalancerPoolEditParamsOriginSteeringPolicy = "random" - UserLoadBalancerPoolEditParamsOriginSteeringPolicyHash UserLoadBalancerPoolEditParamsOriginSteeringPolicy = "hash" - UserLoadBalancerPoolEditParamsOriginSteeringPolicyLeastOutstandingRequests UserLoadBalancerPoolEditParamsOriginSteeringPolicy = "least_outstanding_requests" - UserLoadBalancerPoolEditParamsOriginSteeringPolicyLeastConnections UserLoadBalancerPoolEditParamsOriginSteeringPolicy = "least_connections" -) - -type UserLoadBalancerPoolEditParamsOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address param.Field[string] `json:"address"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled param.Field[bool] `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header param.Field[UserLoadBalancerPoolEditParamsOriginsHeader] `json:"header"` - // A human-identifiable name for the origin. - Name param.Field[string] `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID param.Field[string] `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight param.Field[float64] `json:"weight"` -} - -func (r UserLoadBalancerPoolEditParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type UserLoadBalancerPoolEditParamsOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host param.Field[[]string] `json:"Host"` -} - -func (r UserLoadBalancerPoolEditParamsOriginsHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type UserLoadBalancerPoolEditResponseEnvelope struct { - Errors []UserLoadBalancerPoolEditResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerPoolEditResponseEnvelopeMessages `json:"messages,required"` - Result UserLoadBalancerPoolEditResponse `json:"result,required"` - // Whether the API call was successful - Success UserLoadBalancerPoolEditResponseEnvelopeSuccess `json:"success,required"` - JSON userLoadBalancerPoolEditResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerPoolEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [UserLoadBalancerPoolEditResponseEnvelope] -type userLoadBalancerPoolEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPoolEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerPoolEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [UserLoadBalancerPoolEditResponseEnvelopeErrors] -type userLoadBalancerPoolEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPoolEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerPoolEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [UserLoadBalancerPoolEditResponseEnvelopeMessages] -type userLoadBalancerPoolEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerPoolEditResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerPoolEditResponseEnvelopeSuccessTrue UserLoadBalancerPoolEditResponseEnvelopeSuccess = true -) - -type UserLoadBalancerPoolGetResponseEnvelope struct { - Errors []UserLoadBalancerPoolGetResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerPoolGetResponseEnvelopeMessages `json:"messages,required"` - Result UserLoadBalancerPoolGetResponse `json:"result,required"` - // Whether the API call was successful - Success UserLoadBalancerPoolGetResponseEnvelopeSuccess `json:"success,required"` - JSON userLoadBalancerPoolGetResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerPoolGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [UserLoadBalancerPoolGetResponseEnvelope] -type userLoadBalancerPoolGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPoolGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerPoolGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [UserLoadBalancerPoolGetResponseEnvelopeErrors] -type userLoadBalancerPoolGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPoolGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerPoolGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [UserLoadBalancerPoolGetResponseEnvelopeMessages] -type userLoadBalancerPoolGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerPoolGetResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerPoolGetResponseEnvelopeSuccessTrue UserLoadBalancerPoolGetResponseEnvelopeSuccess = true -) - -type UserLoadBalancerPoolHealthResponseEnvelope struct { - Errors []UserLoadBalancerPoolHealthResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerPoolHealthResponseEnvelopeMessages `json:"messages,required"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - Result UserLoadBalancerPoolHealthResponse `json:"result,required"` - // Whether the API call was successful - Success UserLoadBalancerPoolHealthResponseEnvelopeSuccess `json:"success,required"` - JSON userLoadBalancerPoolHealthResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerPoolHealthResponseEnvelopeJSON contains the JSON metadata for -// the struct [UserLoadBalancerPoolHealthResponseEnvelope] -type userLoadBalancerPoolHealthResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolHealthResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolHealthResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolHealthResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPoolHealthResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerPoolHealthResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [UserLoadBalancerPoolHealthResponseEnvelopeErrors] -type userLoadBalancerPoolHealthResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolHealthResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolHealthResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolHealthResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPoolHealthResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerPoolHealthResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [UserLoadBalancerPoolHealthResponseEnvelopeMessages] -type userLoadBalancerPoolHealthResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolHealthResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolHealthResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerPoolHealthResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerPoolHealthResponseEnvelopeSuccessTrue UserLoadBalancerPoolHealthResponseEnvelopeSuccess = true -) - -type UserLoadBalancerPoolPreviewParams struct { - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes param.Field[string] `json:"expected_codes,required"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown param.Field[int64] `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp param.Field[int64] `json:"consecutive_up"` - // Object description. - Description param.Field[string] `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody param.Field[string] `json:"expected_body"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header param.Field[interface{}] `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method param.Field[string] `json:"method"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path param.Field[string] `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port param.Field[int64] `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone param.Field[string] `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type param.Field[UserLoadBalancerPoolPreviewParamsType] `json:"type"` -} - -func (r UserLoadBalancerPoolPreviewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type UserLoadBalancerPoolPreviewParamsType string - -const ( - UserLoadBalancerPoolPreviewParamsTypeHTTP UserLoadBalancerPoolPreviewParamsType = "http" - UserLoadBalancerPoolPreviewParamsTypeHTTPS UserLoadBalancerPoolPreviewParamsType = "https" - UserLoadBalancerPoolPreviewParamsTypeTcp UserLoadBalancerPoolPreviewParamsType = "tcp" - UserLoadBalancerPoolPreviewParamsTypeUdpIcmp UserLoadBalancerPoolPreviewParamsType = "udp_icmp" - UserLoadBalancerPoolPreviewParamsTypeIcmpPing UserLoadBalancerPoolPreviewParamsType = "icmp_ping" - UserLoadBalancerPoolPreviewParamsTypeSmtp UserLoadBalancerPoolPreviewParamsType = "smtp" -) - -type UserLoadBalancerPoolPreviewResponseEnvelope struct { - Errors []UserLoadBalancerPoolPreviewResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerPoolPreviewResponseEnvelopeMessages `json:"messages,required"` - Result UserLoadBalancerPoolPreviewResponse `json:"result,required"` - // Whether the API call was successful - Success UserLoadBalancerPoolPreviewResponseEnvelopeSuccess `json:"success,required"` - JSON userLoadBalancerPoolPreviewResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerPoolPreviewResponseEnvelopeJSON contains the JSON metadata for -// the struct [UserLoadBalancerPoolPreviewResponseEnvelope] -type userLoadBalancerPoolPreviewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolPreviewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolPreviewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolPreviewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPoolPreviewResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerPoolPreviewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [UserLoadBalancerPoolPreviewResponseEnvelopeErrors] -type userLoadBalancerPoolPreviewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolPreviewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolPreviewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolPreviewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPoolPreviewResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerPoolPreviewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [UserLoadBalancerPoolPreviewResponseEnvelopeMessages] -type userLoadBalancerPoolPreviewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolPreviewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolPreviewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerPoolPreviewResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerPoolPreviewResponseEnvelopeSuccessTrue UserLoadBalancerPoolPreviewResponseEnvelopeSuccess = true -) - -type UserLoadBalancerPoolReferencesResponseEnvelope struct { - Errors []UserLoadBalancerPoolReferencesResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerPoolReferencesResponseEnvelopeMessages `json:"messages,required"` - // List of resources that reference a given pool. - Result []UserLoadBalancerPoolReferencesResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success UserLoadBalancerPoolReferencesResponseEnvelopeSuccess `json:"success,required"` - ResultInfo UserLoadBalancerPoolReferencesResponseEnvelopeResultInfo `json:"result_info"` - JSON userLoadBalancerPoolReferencesResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerPoolReferencesResponseEnvelopeJSON contains the JSON metadata -// for the struct [UserLoadBalancerPoolReferencesResponseEnvelope] -type userLoadBalancerPoolReferencesResponseEnvelopeJSON 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 *UserLoadBalancerPoolReferencesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolReferencesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolReferencesResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPoolReferencesResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerPoolReferencesResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [UserLoadBalancerPoolReferencesResponseEnvelopeErrors] -type userLoadBalancerPoolReferencesResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolReferencesResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolReferencesResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPoolReferencesResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPoolReferencesResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerPoolReferencesResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [UserLoadBalancerPoolReferencesResponseEnvelopeMessages] -type userLoadBalancerPoolReferencesResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolReferencesResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolReferencesResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerPoolReferencesResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerPoolReferencesResponseEnvelopeSuccessTrue UserLoadBalancerPoolReferencesResponseEnvelopeSuccess = true -) - -type UserLoadBalancerPoolReferencesResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON userLoadBalancerPoolReferencesResponseEnvelopeResultInfoJSON `json:"-"` -} - -// userLoadBalancerPoolReferencesResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [UserLoadBalancerPoolReferencesResponseEnvelopeResultInfo] -type userLoadBalancerPoolReferencesResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPoolReferencesResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPoolReferencesResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/userloadbalancerpool_test.go b/userloadbalancerpool_test.go deleted file mode 100644 index 204104d2e48..00000000000 --- a/userloadbalancerpool_test.go +++ /dev/null @@ -1,439 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestUserLoadBalancerPoolNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Pools.New(context.TODO(), cloudflare.UserLoadBalancerPoolNewParams{ - Name: cloudflare.F("primary-dc-1"), - Origins: cloudflare.F([]cloudflare.UserLoadBalancerPoolNewParamsOrigin{{ - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(cloudflare.UserLoadBalancerPoolNewParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), - }), - Name: cloudflare.F("app-server-1"), - VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), - Weight: cloudflare.F(0.600000), - }, { - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(cloudflare.UserLoadBalancerPoolNewParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), - }), - Name: cloudflare.F("app-server-1"), - VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), - Weight: cloudflare.F(0.600000), - }, { - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(cloudflare.UserLoadBalancerPoolNewParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), - }), - Name: cloudflare.F("app-server-1"), - VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), - Weight: cloudflare.F(0.600000), - }}), - CheckRegions: cloudflare.F([]cloudflare.UserLoadBalancerPoolNewParamsCheckRegion{cloudflare.UserLoadBalancerPoolNewParamsCheckRegionWeu, cloudflare.UserLoadBalancerPoolNewParamsCheckRegionEnam}), - Description: cloudflare.F("Primary data center - Provider XYZ"), - Enabled: cloudflare.F(false), - Latitude: cloudflare.F(0.000000), - LoadShedding: cloudflare.F(cloudflare.UserLoadBalancerPoolNewParamsLoadShedding{ - DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(cloudflare.UserLoadBalancerPoolNewParamsLoadSheddingDefaultPolicyRandom), - SessionPercent: cloudflare.F(0.000000), - SessionPolicy: cloudflare.F(cloudflare.UserLoadBalancerPoolNewParamsLoadSheddingSessionPolicyHash), - }), - Longitude: cloudflare.F(0.000000), - MinimumOrigins: cloudflare.F(int64(0)), - Monitor: cloudflare.F[any](map[string]interface{}{}), - NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), - NotificationFilter: cloudflare.F(cloudflare.UserLoadBalancerPoolNewParamsNotificationFilter{ - Origin: cloudflare.F(cloudflare.UserLoadBalancerPoolNewParamsNotificationFilterOrigin{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(true), - }), - Pool: cloudflare.F(cloudflare.UserLoadBalancerPoolNewParamsNotificationFilterPool{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(false), - }), - }), - OriginSteering: cloudflare.F(cloudflare.UserLoadBalancerPoolNewParamsOriginSteering{ - Policy: cloudflare.F(cloudflare.UserLoadBalancerPoolNewParamsOriginSteeringPolicyRandom), - }), - }) - 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 TestUserLoadBalancerPoolUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Pools.Update( - context.TODO(), - "17b5962d775c646f3f9725cbc7a53df4", - cloudflare.UserLoadBalancerPoolUpdateParams{ - Name: cloudflare.F("primary-dc-1"), - Origins: cloudflare.F([]cloudflare.UserLoadBalancerPoolUpdateParamsOrigin{{ - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(cloudflare.UserLoadBalancerPoolUpdateParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), - }), - Name: cloudflare.F("app-server-1"), - VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), - Weight: cloudflare.F(0.600000), - }, { - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(cloudflare.UserLoadBalancerPoolUpdateParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), - }), - Name: cloudflare.F("app-server-1"), - VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), - Weight: cloudflare.F(0.600000), - }, { - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(cloudflare.UserLoadBalancerPoolUpdateParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), - }), - Name: cloudflare.F("app-server-1"), - VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), - Weight: cloudflare.F(0.600000), - }}), - CheckRegions: cloudflare.F([]cloudflare.UserLoadBalancerPoolUpdateParamsCheckRegion{cloudflare.UserLoadBalancerPoolUpdateParamsCheckRegionWeu, cloudflare.UserLoadBalancerPoolUpdateParamsCheckRegionEnam}), - Description: cloudflare.F("Primary data center - Provider XYZ"), - Enabled: cloudflare.F(false), - Latitude: cloudflare.F(0.000000), - LoadShedding: cloudflare.F(cloudflare.UserLoadBalancerPoolUpdateParamsLoadShedding{ - DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(cloudflare.UserLoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyRandom), - SessionPercent: cloudflare.F(0.000000), - SessionPolicy: cloudflare.F(cloudflare.UserLoadBalancerPoolUpdateParamsLoadSheddingSessionPolicyHash), - }), - Longitude: cloudflare.F(0.000000), - MinimumOrigins: cloudflare.F(int64(0)), - Monitor: cloudflare.F[any](map[string]interface{}{}), - NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), - NotificationFilter: cloudflare.F(cloudflare.UserLoadBalancerPoolUpdateParamsNotificationFilter{ - Origin: cloudflare.F(cloudflare.UserLoadBalancerPoolUpdateParamsNotificationFilterOrigin{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(true), - }), - Pool: cloudflare.F(cloudflare.UserLoadBalancerPoolUpdateParamsNotificationFilterPool{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(false), - }), - }), - OriginSteering: cloudflare.F(cloudflare.UserLoadBalancerPoolUpdateParamsOriginSteering{ - Policy: cloudflare.F(cloudflare.UserLoadBalancerPoolUpdateParamsOriginSteeringPolicyRandom), - }), - }, - ) - 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 TestUserLoadBalancerPoolListWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Pools.List(context.TODO(), cloudflare.UserLoadBalancerPoolListParams{ - Monitor: cloudflare.F[any](map[string]interface{}{}), - }) - 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 TestUserLoadBalancerPoolDelete(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Pools.Delete(context.TODO(), "17b5962d775c646f3f9725cbc7a53df4") - 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 TestUserLoadBalancerPoolEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Pools.Edit( - context.TODO(), - "17b5962d775c646f3f9725cbc7a53df4", - cloudflare.UserLoadBalancerPoolEditParams{ - CheckRegions: cloudflare.F([]cloudflare.UserLoadBalancerPoolEditParamsCheckRegion{cloudflare.UserLoadBalancerPoolEditParamsCheckRegionWeu, cloudflare.UserLoadBalancerPoolEditParamsCheckRegionEnam}), - Description: cloudflare.F("Primary data center - Provider XYZ"), - Enabled: cloudflare.F(false), - Latitude: cloudflare.F(0.000000), - LoadShedding: cloudflare.F(cloudflare.UserLoadBalancerPoolEditParamsLoadShedding{ - DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(cloudflare.UserLoadBalancerPoolEditParamsLoadSheddingDefaultPolicyRandom), - SessionPercent: cloudflare.F(0.000000), - SessionPolicy: cloudflare.F(cloudflare.UserLoadBalancerPoolEditParamsLoadSheddingSessionPolicyHash), - }), - Longitude: cloudflare.F(0.000000), - MinimumOrigins: cloudflare.F(int64(0)), - Monitor: cloudflare.F[any](map[string]interface{}{}), - Name: cloudflare.F("primary-dc-1"), - NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), - NotificationFilter: cloudflare.F(cloudflare.UserLoadBalancerPoolEditParamsNotificationFilter{ - Origin: cloudflare.F(cloudflare.UserLoadBalancerPoolEditParamsNotificationFilterOrigin{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(true), - }), - Pool: cloudflare.F(cloudflare.UserLoadBalancerPoolEditParamsNotificationFilterPool{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(false), - }), - }), - OriginSteering: cloudflare.F(cloudflare.UserLoadBalancerPoolEditParamsOriginSteering{ - Policy: cloudflare.F(cloudflare.UserLoadBalancerPoolEditParamsOriginSteeringPolicyRandom), - }), - Origins: cloudflare.F([]cloudflare.UserLoadBalancerPoolEditParamsOrigin{{ - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(cloudflare.UserLoadBalancerPoolEditParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), - }), - Name: cloudflare.F("app-server-1"), - VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), - Weight: cloudflare.F(0.600000), - }, { - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(cloudflare.UserLoadBalancerPoolEditParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), - }), - Name: cloudflare.F("app-server-1"), - VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), - Weight: cloudflare.F(0.600000), - }, { - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - Header: cloudflare.F(cloudflare.UserLoadBalancerPoolEditParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), - }), - Name: cloudflare.F("app-server-1"), - VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), - Weight: cloudflare.F(0.600000), - }}), - }, - ) - 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 TestUserLoadBalancerPoolGet(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Pools.Get(context.TODO(), "17b5962d775c646f3f9725cbc7a53df4") - 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 TestUserLoadBalancerPoolHealth(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Pools.Health(context.TODO(), "17b5962d775c646f3f9725cbc7a53df4") - 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 TestUserLoadBalancerPoolPreviewWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Pools.Preview( - context.TODO(), - "17b5962d775c646f3f9725cbc7a53df4", - cloudflare.UserLoadBalancerPoolPreviewParams{ - ExpectedCodes: cloudflare.F("2xx"), - AllowInsecure: cloudflare.F(true), - ConsecutiveDown: cloudflare.F(int64(0)), - ConsecutiveUp: cloudflare.F(int64(0)), - Description: cloudflare.F("Login page monitor"), - ExpectedBody: cloudflare.F("alive"), - FollowRedirects: cloudflare.F(true), - Header: cloudflare.F[any](map[string]interface{}{ - "Host": map[string]interface{}{ - "0": "example.com", - }, - "X-App-ID": map[string]interface{}{ - "0": "abc123", - }, - }), - Interval: cloudflare.F(int64(0)), - Method: cloudflare.F("GET"), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - ProbeZone: cloudflare.F("example.com"), - Retries: cloudflare.F(int64(0)), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F(cloudflare.UserLoadBalancerPoolPreviewParamsTypeHTTPS), - }, - ) - 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 TestUserLoadBalancerPoolReferences(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Pools.References(context.TODO(), "17b5962d775c646f3f9725cbc7a53df4") - 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/userloadbalancerpreview.go b/userloadbalancerpreview.go deleted file mode 100644 index 112b9ec8cf3..00000000000 --- a/userloadbalancerpreview.go +++ /dev/null @@ -1,128 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// UserLoadBalancerPreviewService 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 -// [NewUserLoadBalancerPreviewService] method instead. -type UserLoadBalancerPreviewService struct { - Options []option.RequestOption -} - -// NewUserLoadBalancerPreviewService 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 NewUserLoadBalancerPreviewService(opts ...option.RequestOption) (r *UserLoadBalancerPreviewService) { - r = &UserLoadBalancerPreviewService{} - r.Options = opts - return -} - -// Get the result of a previous preview operation using the provided preview_id. -func (r *UserLoadBalancerPreviewService) Get(ctx context.Context, previewID interface{}, opts ...option.RequestOption) (res *UserLoadBalancerPreviewGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserLoadBalancerPreviewGetResponseEnvelope - path := fmt.Sprintf("user/load_balancers/preview/%v", previewID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type UserLoadBalancerPreviewGetResponse map[string]UserLoadBalancerPreviewGetResponse - -type UserLoadBalancerPreviewGetResponseEnvelope struct { - Errors []UserLoadBalancerPreviewGetResponseEnvelopeErrors `json:"errors,required"` - Messages []UserLoadBalancerPreviewGetResponseEnvelopeMessages `json:"messages,required"` - // Resulting health data from a preview operation. - Result UserLoadBalancerPreviewGetResponse `json:"result,required"` - // Whether the API call was successful - Success UserLoadBalancerPreviewGetResponseEnvelopeSuccess `json:"success,required"` - JSON userLoadBalancerPreviewGetResponseEnvelopeJSON `json:"-"` -} - -// userLoadBalancerPreviewGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [UserLoadBalancerPreviewGetResponseEnvelope] -type userLoadBalancerPreviewGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPreviewGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPreviewGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPreviewGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPreviewGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// userLoadBalancerPreviewGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [UserLoadBalancerPreviewGetResponseEnvelopeErrors] -type userLoadBalancerPreviewGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPreviewGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPreviewGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserLoadBalancerPreviewGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userLoadBalancerPreviewGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// userLoadBalancerPreviewGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [UserLoadBalancerPreviewGetResponseEnvelopeMessages] -type userLoadBalancerPreviewGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserLoadBalancerPreviewGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userLoadBalancerPreviewGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserLoadBalancerPreviewGetResponseEnvelopeSuccess bool - -const ( - UserLoadBalancerPreviewGetResponseEnvelopeSuccessTrue UserLoadBalancerPreviewGetResponseEnvelopeSuccess = true -) diff --git a/userloadbalancerpreview_test.go b/userloadbalancerpreview_test.go deleted file mode 100644 index a2cb9fea64b..00000000000 --- a/userloadbalancerpreview_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestUserLoadBalancerPreviewGet(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("user@example.com"), - ) - _, err := client.User.LoadBalancers.Preview.Get(context.TODO(), "f1aba936b94213e5b8dca0c0dbf1f9cc") - 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/userorganization.go b/userorganization.go deleted file mode 100644 index f229d89b651..00000000000 --- a/userorganization.go +++ /dev/null @@ -1,301 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// UserOrganizationService 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 [NewUserOrganizationService] method -// instead. -type UserOrganizationService struct { - Options []option.RequestOption -} - -// NewUserOrganizationService 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 NewUserOrganizationService(opts ...option.RequestOption) (r *UserOrganizationService) { - r = &UserOrganizationService{} - r.Options = opts - return -} - -// Lists organizations the user is associated with. -func (r *UserOrganizationService) List(ctx context.Context, query UserOrganizationListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[UserOrganizationListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := "user/organizations" - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Lists organizations the user is associated with. -func (r *UserOrganizationService) ListAutoPaging(ctx context.Context, query UserOrganizationListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[UserOrganizationListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, query, opts...)) -} - -// Removes association to an organization. -func (r *UserOrganizationService) Delete(ctx context.Context, organizationID string, opts ...option.RequestOption) (res *UserOrganizationDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("user/organizations/%s", organizationID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) - return -} - -// Gets a specific organization the user is associated with. -func (r *UserOrganizationService) Get(ctx context.Context, organizationID string, opts ...option.RequestOption) (res *UserOrganizationGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserOrganizationGetResponseEnvelope - path := fmt.Sprintf("user/organizations/%s", organizationID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type UserOrganizationListResponse struct { - // Identifier - ID string `json:"id"` - // Organization name. - Name string `json:"name"` - // Access permissions for this User. - Permissions []string `json:"permissions"` - // List of roles that a user has within an organization. - Roles []string `json:"roles"` - // Whether the user is a member of the organization or has an inivitation pending. - Status UserOrganizationListResponseStatus `json:"status"` - JSON userOrganizationListResponseJSON `json:"-"` -} - -// userOrganizationListResponseJSON contains the JSON metadata for the struct -// [UserOrganizationListResponse] -type userOrganizationListResponseJSON struct { - ID apijson.Field - Name apijson.Field - Permissions apijson.Field - Roles apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserOrganizationListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userOrganizationListResponseJSON) RawJSON() string { - return r.raw -} - -// Whether the user is a member of the organization or has an inivitation pending. -type UserOrganizationListResponseStatus string - -const ( - UserOrganizationListResponseStatusMember UserOrganizationListResponseStatus = "member" - UserOrganizationListResponseStatusInvited UserOrganizationListResponseStatus = "invited" -) - -type UserOrganizationDeleteResponse struct { - // Identifier - ID string `json:"id"` - JSON userOrganizationDeleteResponseJSON `json:"-"` -} - -// userOrganizationDeleteResponseJSON contains the JSON metadata for the struct -// [UserOrganizationDeleteResponse] -type userOrganizationDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserOrganizationDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userOrganizationDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [UserOrganizationGetResponseUnknown] or [shared.UnionString]. -type UserOrganizationGetResponse interface { - ImplementsUserOrganizationGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*UserOrganizationGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type UserOrganizationListParams struct { - // Direction to order organizations. - Direction param.Field[UserOrganizationListParamsDirection] `query:"direction"` - // Whether to match all search requirements or at least one (any). - Match param.Field[UserOrganizationListParamsMatch] `query:"match"` - // Organization name. - Name param.Field[string] `query:"name"` - // Field to order organizations by. - Order param.Field[UserOrganizationListParamsOrder] `query:"order"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // Number of organizations per page. - PerPage param.Field[float64] `query:"per_page"` - // Whether the user is a member of the organization or has an inivitation pending. - Status param.Field[UserOrganizationListParamsStatus] `query:"status"` -} - -// URLQuery serializes [UserOrganizationListParams]'s query parameters as -// `url.Values`. -func (r UserOrganizationListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Direction to order organizations. -type UserOrganizationListParamsDirection string - -const ( - UserOrganizationListParamsDirectionAsc UserOrganizationListParamsDirection = "asc" - UserOrganizationListParamsDirectionDesc UserOrganizationListParamsDirection = "desc" -) - -// Whether to match all search requirements or at least one (any). -type UserOrganizationListParamsMatch string - -const ( - UserOrganizationListParamsMatchAny UserOrganizationListParamsMatch = "any" - UserOrganizationListParamsMatchAll UserOrganizationListParamsMatch = "all" -) - -// Field to order organizations by. -type UserOrganizationListParamsOrder string - -const ( - UserOrganizationListParamsOrderID UserOrganizationListParamsOrder = "id" - UserOrganizationListParamsOrderName UserOrganizationListParamsOrder = "name" - UserOrganizationListParamsOrderStatus UserOrganizationListParamsOrder = "status" -) - -// Whether the user is a member of the organization or has an inivitation pending. -type UserOrganizationListParamsStatus string - -const ( - UserOrganizationListParamsStatusMember UserOrganizationListParamsStatus = "member" - UserOrganizationListParamsStatusInvited UserOrganizationListParamsStatus = "invited" -) - -type UserOrganizationGetResponseEnvelope struct { - Errors []UserOrganizationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []UserOrganizationGetResponseEnvelopeMessages `json:"messages,required"` - Result UserOrganizationGetResponse `json:"result,required"` - // Whether the API call was successful - Success UserOrganizationGetResponseEnvelopeSuccess `json:"success,required"` - JSON userOrganizationGetResponseEnvelopeJSON `json:"-"` -} - -// userOrganizationGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [UserOrganizationGetResponseEnvelope] -type userOrganizationGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserOrganizationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userOrganizationGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserOrganizationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userOrganizationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// userOrganizationGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [UserOrganizationGetResponseEnvelopeErrors] -type userOrganizationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserOrganizationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userOrganizationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserOrganizationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userOrganizationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// userOrganizationGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [UserOrganizationGetResponseEnvelopeMessages] -type userOrganizationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserOrganizationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userOrganizationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserOrganizationGetResponseEnvelopeSuccess bool - -const ( - UserOrganizationGetResponseEnvelopeSuccessTrue UserOrganizationGetResponseEnvelopeSuccess = true -) diff --git a/userorganization_test.go b/userorganization_test.go deleted file mode 100644 index 45453861bac..00000000000 --- a/userorganization_test.go +++ /dev/null @@ -1,94 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestUserOrganizationListWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.Organizations.List(context.TODO(), cloudflare.UserOrganizationListParams{ - Direction: cloudflare.F(cloudflare.UserOrganizationListParamsDirectionDesc), - Match: cloudflare.F(cloudflare.UserOrganizationListParamsMatchAny), - Name: cloudflare.F("Cloudflare, Inc."), - Order: cloudflare.F(cloudflare.UserOrganizationListParamsOrderStatus), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(5.000000), - Status: cloudflare.F(cloudflare.UserOrganizationListParamsStatusMember), - }) - 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 TestUserOrganizationDelete(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("user@example.com"), - ) - _, err := client.User.Organizations.Delete(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()) - } -} - -func TestUserOrganizationGet(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("user@example.com"), - ) - _, err := client.User.Organizations.Get(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/usersubscription.go b/usersubscription.go deleted file mode 100644 index 01b7137f40b..00000000000 --- a/usersubscription.go +++ /dev/null @@ -1,773 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// UserSubscriptionService 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 [NewUserSubscriptionService] method -// instead. -type UserSubscriptionService struct { - Options []option.RequestOption -} - -// NewUserSubscriptionService 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 NewUserSubscriptionService(opts ...option.RequestOption) (r *UserSubscriptionService) { - r = &UserSubscriptionService{} - r.Options = opts - return -} - -// Updates a user's subscriptions. -func (r *UserSubscriptionService) Update(ctx context.Context, identifier string, body UserSubscriptionUpdateParams, opts ...option.RequestOption) (res *UserSubscriptionUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserSubscriptionUpdateResponseEnvelope - path := fmt.Sprintf("user/subscriptions/%s", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a user's subscription. -func (r *UserSubscriptionService) Delete(ctx context.Context, identifier string, opts ...option.RequestOption) (res *UserSubscriptionDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("user/subscriptions/%s", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) - return -} - -// Updates zone subscriptions, either plan or add-ons. -func (r *UserSubscriptionService) Edit(ctx context.Context, identifier string, body UserSubscriptionEditParams, opts ...option.RequestOption) (res *UserSubscriptionEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserSubscriptionEditResponseEnvelope - path := fmt.Sprintf("zones/%s/subscription", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists all of a user's subscriptions. -func (r *UserSubscriptionService) Get(ctx context.Context, opts ...option.RequestOption) (res *[]UserSubscriptionGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserSubscriptionGetResponseEnvelope - path := "user/subscriptions" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [UserSubscriptionUpdateResponseUnknown] or -// [shared.UnionString]. -type UserSubscriptionUpdateResponse interface { - ImplementsUserSubscriptionUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*UserSubscriptionUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type UserSubscriptionDeleteResponse struct { - // Subscription identifier tag. - SubscriptionID string `json:"subscription_id"` - JSON userSubscriptionDeleteResponseJSON `json:"-"` -} - -// userSubscriptionDeleteResponseJSON contains the JSON metadata for the struct -// [UserSubscriptionDeleteResponse] -type userSubscriptionDeleteResponseJSON struct { - SubscriptionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserSubscriptionDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userSubscriptionDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [UserSubscriptionEditResponseUnknown] or -// [shared.UnionString]. -type UserSubscriptionEditResponse interface { - ImplementsUserSubscriptionEditResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*UserSubscriptionEditResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type UserSubscriptionGetResponse struct { - // Subscription identifier tag. - ID string `json:"id"` - App UserSubscriptionGetResponseApp `json:"app"` - // The list of add-ons subscribed to. - ComponentValues []UserSubscriptionGetResponseComponentValue `json:"component_values"` - // The monetary unit in which pricing information is displayed. - Currency string `json:"currency"` - // The end of the current period and also when the next billing is due. - CurrentPeriodEnd time.Time `json:"current_period_end" format:"date-time"` - // When the current billing period started. May match initial_period_start if this - // is the first period. - CurrentPeriodStart time.Time `json:"current_period_start" format:"date-time"` - // How often the subscription is renewed automatically. - Frequency UserSubscriptionGetResponseFrequency `json:"frequency"` - // The price of the subscription that will be billed, in US dollars. - Price float64 `json:"price"` - // The rate plan applied to the subscription. - RatePlan UserSubscriptionGetResponseRatePlan `json:"rate_plan"` - // The state that the subscription is in. - State UserSubscriptionGetResponseState `json:"state"` - // A simple zone object. May have null properties if not a zone subscription. - Zone UserSubscriptionGetResponseZone `json:"zone"` - JSON userSubscriptionGetResponseJSON `json:"-"` -} - -// userSubscriptionGetResponseJSON contains the JSON metadata for the struct -// [UserSubscriptionGetResponse] -type userSubscriptionGetResponseJSON struct { - ID apijson.Field - App apijson.Field - ComponentValues apijson.Field - Currency apijson.Field - CurrentPeriodEnd apijson.Field - CurrentPeriodStart apijson.Field - Frequency apijson.Field - Price apijson.Field - RatePlan apijson.Field - State apijson.Field - Zone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserSubscriptionGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userSubscriptionGetResponseJSON) RawJSON() string { - return r.raw -} - -type UserSubscriptionGetResponseApp struct { - // app install id. - InstallID string `json:"install_id"` - JSON userSubscriptionGetResponseAppJSON `json:"-"` -} - -// userSubscriptionGetResponseAppJSON contains the JSON metadata for the struct -// [UserSubscriptionGetResponseApp] -type userSubscriptionGetResponseAppJSON struct { - InstallID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserSubscriptionGetResponseApp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userSubscriptionGetResponseAppJSON) RawJSON() string { - return r.raw -} - -// A component value for a subscription. -type UserSubscriptionGetResponseComponentValue struct { - // The default amount assigned. - Default float64 `json:"default"` - // The name of the component value. - Name string `json:"name"` - // The unit price for the component value. - Price float64 `json:"price"` - // The amount of the component value assigned. - Value float64 `json:"value"` - JSON userSubscriptionGetResponseComponentValueJSON `json:"-"` -} - -// userSubscriptionGetResponseComponentValueJSON contains the JSON metadata for the -// struct [UserSubscriptionGetResponseComponentValue] -type userSubscriptionGetResponseComponentValueJSON struct { - Default apijson.Field - Name apijson.Field - Price apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserSubscriptionGetResponseComponentValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userSubscriptionGetResponseComponentValueJSON) RawJSON() string { - return r.raw -} - -// How often the subscription is renewed automatically. -type UserSubscriptionGetResponseFrequency string - -const ( - UserSubscriptionGetResponseFrequencyWeekly UserSubscriptionGetResponseFrequency = "weekly" - UserSubscriptionGetResponseFrequencyMonthly UserSubscriptionGetResponseFrequency = "monthly" - UserSubscriptionGetResponseFrequencyQuarterly UserSubscriptionGetResponseFrequency = "quarterly" - UserSubscriptionGetResponseFrequencyYearly UserSubscriptionGetResponseFrequency = "yearly" -) - -// The rate plan applied to the subscription. -type UserSubscriptionGetResponseRatePlan struct { - // The ID of the rate plan. - ID interface{} `json:"id"` - // The currency applied to the rate plan subscription. - Currency string `json:"currency"` - // Whether this rate plan is managed externally from Cloudflare. - ExternallyManaged bool `json:"externally_managed"` - // Whether a rate plan is enterprise-based (or newly adopted term contract). - IsContract bool `json:"is_contract"` - // The full name of the rate plan. - PublicName string `json:"public_name"` - // The scope that this rate plan applies to. - Scope string `json:"scope"` - // The list of sets this rate plan applies to. - Sets []string `json:"sets"` - JSON userSubscriptionGetResponseRatePlanJSON `json:"-"` -} - -// userSubscriptionGetResponseRatePlanJSON contains the JSON metadata for the -// struct [UserSubscriptionGetResponseRatePlan] -type userSubscriptionGetResponseRatePlanJSON struct { - ID apijson.Field - Currency apijson.Field - ExternallyManaged apijson.Field - IsContract apijson.Field - PublicName apijson.Field - Scope apijson.Field - Sets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserSubscriptionGetResponseRatePlan) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userSubscriptionGetResponseRatePlanJSON) RawJSON() string { - return r.raw -} - -// The state that the subscription is in. -type UserSubscriptionGetResponseState string - -const ( - UserSubscriptionGetResponseStateTrial UserSubscriptionGetResponseState = "Trial" - UserSubscriptionGetResponseStateProvisioned UserSubscriptionGetResponseState = "Provisioned" - UserSubscriptionGetResponseStatePaid UserSubscriptionGetResponseState = "Paid" - UserSubscriptionGetResponseStateAwaitingPayment UserSubscriptionGetResponseState = "AwaitingPayment" - UserSubscriptionGetResponseStateCancelled UserSubscriptionGetResponseState = "Cancelled" - UserSubscriptionGetResponseStateFailed UserSubscriptionGetResponseState = "Failed" - UserSubscriptionGetResponseStateExpired UserSubscriptionGetResponseState = "Expired" -) - -// A simple zone object. May have null properties if not a zone subscription. -type UserSubscriptionGetResponseZone struct { - // Identifier - ID string `json:"id"` - // The domain name - Name string `json:"name"` - JSON userSubscriptionGetResponseZoneJSON `json:"-"` -} - -// userSubscriptionGetResponseZoneJSON contains the JSON metadata for the struct -// [UserSubscriptionGetResponseZone] -type userSubscriptionGetResponseZoneJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserSubscriptionGetResponseZone) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userSubscriptionGetResponseZoneJSON) RawJSON() string { - return r.raw -} - -type UserSubscriptionUpdateParams struct { - App param.Field[UserSubscriptionUpdateParamsApp] `json:"app"` - // The list of add-ons subscribed to. - ComponentValues param.Field[[]UserSubscriptionUpdateParamsComponentValue] `json:"component_values"` - // How often the subscription is renewed automatically. - Frequency param.Field[UserSubscriptionUpdateParamsFrequency] `json:"frequency"` - // The rate plan applied to the subscription. - RatePlan param.Field[UserSubscriptionUpdateParamsRatePlan] `json:"rate_plan"` - // A simple zone object. May have null properties if not a zone subscription. - Zone param.Field[UserSubscriptionUpdateParamsZone] `json:"zone"` -} - -func (r UserSubscriptionUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type UserSubscriptionUpdateParamsApp struct { - // app install id. - InstallID param.Field[string] `json:"install_id"` -} - -func (r UserSubscriptionUpdateParamsApp) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A component value for a subscription. -type UserSubscriptionUpdateParamsComponentValue struct { - // The default amount assigned. - Default param.Field[float64] `json:"default"` - // The name of the component value. - Name param.Field[string] `json:"name"` - // The unit price for the component value. - Price param.Field[float64] `json:"price"` - // The amount of the component value assigned. - Value param.Field[float64] `json:"value"` -} - -func (r UserSubscriptionUpdateParamsComponentValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// How often the subscription is renewed automatically. -type UserSubscriptionUpdateParamsFrequency string - -const ( - UserSubscriptionUpdateParamsFrequencyWeekly UserSubscriptionUpdateParamsFrequency = "weekly" - UserSubscriptionUpdateParamsFrequencyMonthly UserSubscriptionUpdateParamsFrequency = "monthly" - UserSubscriptionUpdateParamsFrequencyQuarterly UserSubscriptionUpdateParamsFrequency = "quarterly" - UserSubscriptionUpdateParamsFrequencyYearly UserSubscriptionUpdateParamsFrequency = "yearly" -) - -// The rate plan applied to the subscription. -type UserSubscriptionUpdateParamsRatePlan struct { - // The ID of the rate plan. - ID param.Field[interface{}] `json:"id"` - // The currency applied to the rate plan subscription. - Currency param.Field[string] `json:"currency"` - // Whether this rate plan is managed externally from Cloudflare. - ExternallyManaged param.Field[bool] `json:"externally_managed"` - // Whether a rate plan is enterprise-based (or newly adopted term contract). - IsContract param.Field[bool] `json:"is_contract"` - // The full name of the rate plan. - PublicName param.Field[string] `json:"public_name"` - // The scope that this rate plan applies to. - Scope param.Field[string] `json:"scope"` - // The list of sets this rate plan applies to. - Sets param.Field[[]string] `json:"sets"` -} - -func (r UserSubscriptionUpdateParamsRatePlan) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A simple zone object. May have null properties if not a zone subscription. -type UserSubscriptionUpdateParamsZone struct { -} - -func (r UserSubscriptionUpdateParamsZone) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type UserSubscriptionUpdateResponseEnvelope struct { - Errors []UserSubscriptionUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []UserSubscriptionUpdateResponseEnvelopeMessages `json:"messages,required"` - Result UserSubscriptionUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success UserSubscriptionUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON userSubscriptionUpdateResponseEnvelopeJSON `json:"-"` -} - -// userSubscriptionUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [UserSubscriptionUpdateResponseEnvelope] -type userSubscriptionUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserSubscriptionUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userSubscriptionUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserSubscriptionUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userSubscriptionUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// userSubscriptionUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [UserSubscriptionUpdateResponseEnvelopeErrors] -type userSubscriptionUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserSubscriptionUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userSubscriptionUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserSubscriptionUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userSubscriptionUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// userSubscriptionUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [UserSubscriptionUpdateResponseEnvelopeMessages] -type userSubscriptionUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserSubscriptionUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userSubscriptionUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserSubscriptionUpdateResponseEnvelopeSuccess bool - -const ( - UserSubscriptionUpdateResponseEnvelopeSuccessTrue UserSubscriptionUpdateResponseEnvelopeSuccess = true -) - -type UserSubscriptionEditParams struct { - App param.Field[UserSubscriptionEditParamsApp] `json:"app"` - // The list of add-ons subscribed to. - ComponentValues param.Field[[]UserSubscriptionEditParamsComponentValue] `json:"component_values"` - // How often the subscription is renewed automatically. - Frequency param.Field[UserSubscriptionEditParamsFrequency] `json:"frequency"` - // The rate plan applied to the subscription. - RatePlan param.Field[UserSubscriptionEditParamsRatePlan] `json:"rate_plan"` - // A simple zone object. May have null properties if not a zone subscription. - Zone param.Field[UserSubscriptionEditParamsZone] `json:"zone"` -} - -func (r UserSubscriptionEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type UserSubscriptionEditParamsApp struct { - // app install id. - InstallID param.Field[string] `json:"install_id"` -} - -func (r UserSubscriptionEditParamsApp) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A component value for a subscription. -type UserSubscriptionEditParamsComponentValue struct { - // The default amount assigned. - Default param.Field[float64] `json:"default"` - // The name of the component value. - Name param.Field[string] `json:"name"` - // The unit price for the component value. - Price param.Field[float64] `json:"price"` - // The amount of the component value assigned. - Value param.Field[float64] `json:"value"` -} - -func (r UserSubscriptionEditParamsComponentValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// How often the subscription is renewed automatically. -type UserSubscriptionEditParamsFrequency string - -const ( - UserSubscriptionEditParamsFrequencyWeekly UserSubscriptionEditParamsFrequency = "weekly" - UserSubscriptionEditParamsFrequencyMonthly UserSubscriptionEditParamsFrequency = "monthly" - UserSubscriptionEditParamsFrequencyQuarterly UserSubscriptionEditParamsFrequency = "quarterly" - UserSubscriptionEditParamsFrequencyYearly UserSubscriptionEditParamsFrequency = "yearly" -) - -// The rate plan applied to the subscription. -type UserSubscriptionEditParamsRatePlan struct { - // The ID of the rate plan. - ID param.Field[interface{}] `json:"id"` - // The currency applied to the rate plan subscription. - Currency param.Field[string] `json:"currency"` - // Whether this rate plan is managed externally from Cloudflare. - ExternallyManaged param.Field[bool] `json:"externally_managed"` - // Whether a rate plan is enterprise-based (or newly adopted term contract). - IsContract param.Field[bool] `json:"is_contract"` - // The full name of the rate plan. - PublicName param.Field[string] `json:"public_name"` - // The scope that this rate plan applies to. - Scope param.Field[string] `json:"scope"` - // The list of sets this rate plan applies to. - Sets param.Field[[]string] `json:"sets"` -} - -func (r UserSubscriptionEditParamsRatePlan) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A simple zone object. May have null properties if not a zone subscription. -type UserSubscriptionEditParamsZone struct { -} - -func (r UserSubscriptionEditParamsZone) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type UserSubscriptionEditResponseEnvelope struct { - Errors []UserSubscriptionEditResponseEnvelopeErrors `json:"errors,required"` - Messages []UserSubscriptionEditResponseEnvelopeMessages `json:"messages,required"` - Result UserSubscriptionEditResponse `json:"result,required"` - // Whether the API call was successful - Success UserSubscriptionEditResponseEnvelopeSuccess `json:"success,required"` - JSON userSubscriptionEditResponseEnvelopeJSON `json:"-"` -} - -// userSubscriptionEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [UserSubscriptionEditResponseEnvelope] -type userSubscriptionEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserSubscriptionEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userSubscriptionEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserSubscriptionEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userSubscriptionEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// userSubscriptionEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [UserSubscriptionEditResponseEnvelopeErrors] -type userSubscriptionEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserSubscriptionEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userSubscriptionEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserSubscriptionEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userSubscriptionEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// userSubscriptionEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [UserSubscriptionEditResponseEnvelopeMessages] -type userSubscriptionEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserSubscriptionEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userSubscriptionEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserSubscriptionEditResponseEnvelopeSuccess bool - -const ( - UserSubscriptionEditResponseEnvelopeSuccessTrue UserSubscriptionEditResponseEnvelopeSuccess = true -) - -type UserSubscriptionGetResponseEnvelope struct { - Errors []UserSubscriptionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []UserSubscriptionGetResponseEnvelopeMessages `json:"messages,required"` - Result []UserSubscriptionGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success UserSubscriptionGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo UserSubscriptionGetResponseEnvelopeResultInfo `json:"result_info"` - JSON userSubscriptionGetResponseEnvelopeJSON `json:"-"` -} - -// userSubscriptionGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [UserSubscriptionGetResponseEnvelope] -type userSubscriptionGetResponseEnvelopeJSON 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 *UserSubscriptionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userSubscriptionGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserSubscriptionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userSubscriptionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// userSubscriptionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [UserSubscriptionGetResponseEnvelopeErrors] -type userSubscriptionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserSubscriptionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userSubscriptionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserSubscriptionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userSubscriptionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// userSubscriptionGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [UserSubscriptionGetResponseEnvelopeMessages] -type userSubscriptionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserSubscriptionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userSubscriptionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserSubscriptionGetResponseEnvelopeSuccess bool - -const ( - UserSubscriptionGetResponseEnvelopeSuccessTrue UserSubscriptionGetResponseEnvelopeSuccess = true -) - -type UserSubscriptionGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON userSubscriptionGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// userSubscriptionGetResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [UserSubscriptionGetResponseEnvelopeResultInfo] -type userSubscriptionGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserSubscriptionGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userSubscriptionGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/usersubscription_test.go b/usersubscription_test.go deleted file mode 100644 index 77eeee6b963..00000000000 --- a/usersubscription_test.go +++ /dev/null @@ -1,180 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestUserSubscriptionUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.Subscriptions.Update( - context.TODO(), - "506e3185e9c882d175a2d0cb0093d9f2", - cloudflare.UserSubscriptionUpdateParams{ - App: cloudflare.F(cloudflare.UserSubscriptionUpdateParamsApp{ - InstallID: cloudflare.F("string"), - }), - ComponentValues: cloudflare.F([]cloudflare.UserSubscriptionUpdateParamsComponentValue{{ - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }}), - Frequency: cloudflare.F(cloudflare.UserSubscriptionUpdateParamsFrequencyMonthly), - RatePlan: cloudflare.F(cloudflare.UserSubscriptionUpdateParamsRatePlan{ - Currency: cloudflare.F("USD"), - ExternallyManaged: cloudflare.F(false), - ID: cloudflare.F[any]("free"), - IsContract: cloudflare.F(false), - PublicName: cloudflare.F("Business Plan"), - Scope: cloudflare.F("zone"), - Sets: cloudflare.F([]string{"string", "string", "string"}), - }), - Zone: cloudflare.F(cloudflare.UserSubscriptionUpdateParamsZone{}), - }, - ) - 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 TestUserSubscriptionDelete(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("user@example.com"), - ) - _, err := client.User.Subscriptions.Delete(context.TODO(), "506e3185e9c882d175a2d0cb0093d9f2") - 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 TestUserSubscriptionEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.Subscriptions.Edit( - context.TODO(), - "506e3185e9c882d175a2d0cb0093d9f2", - cloudflare.UserSubscriptionEditParams{ - App: cloudflare.F(cloudflare.UserSubscriptionEditParamsApp{ - InstallID: cloudflare.F("string"), - }), - ComponentValues: cloudflare.F([]cloudflare.UserSubscriptionEditParamsComponentValue{{ - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }}), - Frequency: cloudflare.F(cloudflare.UserSubscriptionEditParamsFrequencyMonthly), - RatePlan: cloudflare.F(cloudflare.UserSubscriptionEditParamsRatePlan{ - Currency: cloudflare.F("USD"), - ExternallyManaged: cloudflare.F(false), - ID: cloudflare.F[any]("free"), - IsContract: cloudflare.F(false), - PublicName: cloudflare.F("Business Plan"), - Scope: cloudflare.F("zone"), - Sets: cloudflare.F([]string{"string", "string", "string"}), - }), - Zone: cloudflare.F(cloudflare.UserSubscriptionEditParamsZone{}), - }, - ) - 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 TestUserSubscriptionGet(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("user@example.com"), - ) - _, err := client.User.Subscriptions.Get(context.TODO()) - 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/usertoken.go b/usertoken.go deleted file mode 100644 index 7bb38bbd658..00000000000 --- a/usertoken.go +++ /dev/null @@ -1,825 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// UserTokenService 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 [NewUserTokenService] method instead. -type UserTokenService struct { - Options []option.RequestOption - PermissionGroups *UserTokenPermissionGroupService - Value *UserTokenValueService -} - -// NewUserTokenService 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 NewUserTokenService(opts ...option.RequestOption) (r *UserTokenService) { - r = &UserTokenService{} - r.Options = opts - r.PermissionGroups = NewUserTokenPermissionGroupService(opts...) - r.Value = NewUserTokenValueService(opts...) - return -} - -// Create a new access token. -func (r *UserTokenService) New(ctx context.Context, body UserTokenNewParams, opts ...option.RequestOption) (res *UserTokenNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserTokenNewResponseEnvelope - path := "user/tokens" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update an existing token. -func (r *UserTokenService) Update(ctx context.Context, tokenID interface{}, body UserTokenUpdateParams, opts ...option.RequestOption) (res *UserTokenUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserTokenUpdateResponseEnvelope - path := fmt.Sprintf("user/tokens/%v", tokenID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List all access tokens you created. -func (r *UserTokenService) List(ctx context.Context, query UserTokenListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[UserTokenListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := "user/tokens" - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// List all access tokens you created. -func (r *UserTokenService) ListAutoPaging(ctx context.Context, query UserTokenListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[UserTokenListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, query, opts...)) -} - -// Destroy a token. -func (r *UserTokenService) Delete(ctx context.Context, tokenID interface{}, opts ...option.RequestOption) (res *UserTokenDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserTokenDeleteResponseEnvelope - path := fmt.Sprintf("user/tokens/%v", tokenID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get information about a specific token. -func (r *UserTokenService) Get(ctx context.Context, tokenID interface{}, opts ...option.RequestOption) (res *UserTokenGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserTokenGetResponseEnvelope - path := fmt.Sprintf("user/tokens/%v", tokenID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Test whether a token works. -func (r *UserTokenService) Verify(ctx context.Context, opts ...option.RequestOption) (res *UserTokenVerifyResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserTokenVerifyResponseEnvelope - path := "user/tokens/verify" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type UserTokenNewResponse struct { - // The token value. - Value string `json:"value"` - JSON userTokenNewResponseJSON `json:"-"` -} - -// userTokenNewResponseJSON contains the JSON metadata for the struct -// [UserTokenNewResponse] -type userTokenNewResponseJSON struct { - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenNewResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [UserTokenUpdateResponseUnknown] or [shared.UnionString]. -type UserTokenUpdateResponse interface { - ImplementsUserTokenUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*UserTokenUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type UserTokenListResponse = interface{} - -type UserTokenDeleteResponse struct { - // Identifier - ID string `json:"id,required"` - JSON userTokenDeleteResponseJSON `json:"-"` -} - -// userTokenDeleteResponseJSON contains the JSON metadata for the struct -// [UserTokenDeleteResponse] -type userTokenDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [UserTokenGetResponseUnknown] or [shared.UnionString]. -type UserTokenGetResponse interface { - ImplementsUserTokenGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*UserTokenGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type UserTokenVerifyResponse struct { - // Token identifier tag. - ID string `json:"id,required"` - // Status of the token. - Status UserTokenVerifyResponseStatus `json:"status,required"` - // The expiration time on or after which the JWT MUST NOT be accepted for - // processing. - ExpiresOn time.Time `json:"expires_on" format:"date-time"` - // The time before which the token MUST NOT be accepted for processing. - NotBefore time.Time `json:"not_before" format:"date-time"` - JSON userTokenVerifyResponseJSON `json:"-"` -} - -// userTokenVerifyResponseJSON contains the JSON metadata for the struct -// [UserTokenVerifyResponse] -type userTokenVerifyResponseJSON struct { - ID apijson.Field - Status apijson.Field - ExpiresOn apijson.Field - NotBefore apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenVerifyResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenVerifyResponseJSON) RawJSON() string { - return r.raw -} - -// Status of the token. -type UserTokenVerifyResponseStatus string - -const ( - UserTokenVerifyResponseStatusActive UserTokenVerifyResponseStatus = "active" - UserTokenVerifyResponseStatusDisabled UserTokenVerifyResponseStatus = "disabled" - UserTokenVerifyResponseStatusExpired UserTokenVerifyResponseStatus = "expired" -) - -type UserTokenNewParams struct { - // Token name. - Name param.Field[string] `json:"name,required"` - // List of access policies assigned to the token. - Policies param.Field[[]UserTokenNewParamsPolicy] `json:"policies,required"` - Condition param.Field[UserTokenNewParamsCondition] `json:"condition"` - // The expiration time on or after which the JWT MUST NOT be accepted for - // processing. - ExpiresOn param.Field[time.Time] `json:"expires_on" format:"date-time"` - // The time before which the token MUST NOT be accepted for processing. - NotBefore param.Field[time.Time] `json:"not_before" format:"date-time"` -} - -func (r UserTokenNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type UserTokenNewParamsPolicy struct { - // Allow or deny operations against the resources. - Effect param.Field[UserTokenNewParamsPoliciesEffect] `json:"effect,required"` - // A set of permission groups that are specified to the policy. - PermissionGroups param.Field[[]UserTokenNewParamsPoliciesPermissionGroup] `json:"permission_groups,required"` - // A list of resource names that the policy applies to. - Resources param.Field[interface{}] `json:"resources,required"` -} - -func (r UserTokenNewParamsPolicy) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Allow or deny operations against the resources. -type UserTokenNewParamsPoliciesEffect string - -const ( - UserTokenNewParamsPoliciesEffectAllow UserTokenNewParamsPoliciesEffect = "allow" - UserTokenNewParamsPoliciesEffectDeny UserTokenNewParamsPoliciesEffect = "deny" -) - -// A named group of permissions that map to a group of operations against -// resources. -type UserTokenNewParamsPoliciesPermissionGroup struct { -} - -func (r UserTokenNewParamsPoliciesPermissionGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type UserTokenNewParamsCondition struct { - // Client IP restrictions. - RequestIP param.Field[UserTokenNewParamsConditionRequestIP] `json:"request_ip"` -} - -func (r UserTokenNewParamsCondition) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Client IP restrictions. -type UserTokenNewParamsConditionRequestIP struct { - // List of IPv4/IPv6 CIDR addresses. - In param.Field[[]string] `json:"in"` - // List of IPv4/IPv6 CIDR addresses. - NotIn param.Field[[]string] `json:"not_in"` -} - -func (r UserTokenNewParamsConditionRequestIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type UserTokenNewResponseEnvelope struct { - Errors []UserTokenNewResponseEnvelopeErrors `json:"errors,required"` - Messages []UserTokenNewResponseEnvelopeMessages `json:"messages,required"` - Result UserTokenNewResponse `json:"result,required"` - // Whether the API call was successful - Success UserTokenNewResponseEnvelopeSuccess `json:"success,required"` - JSON userTokenNewResponseEnvelopeJSON `json:"-"` -} - -// userTokenNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [UserTokenNewResponseEnvelope] -type userTokenNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserTokenNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userTokenNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// userTokenNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [UserTokenNewResponseEnvelopeErrors] -type userTokenNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserTokenNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userTokenNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// userTokenNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [UserTokenNewResponseEnvelopeMessages] -type userTokenNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserTokenNewResponseEnvelopeSuccess bool - -const ( - UserTokenNewResponseEnvelopeSuccessTrue UserTokenNewResponseEnvelopeSuccess = true -) - -type UserTokenUpdateParams struct { - // Token name. - Name param.Field[string] `json:"name,required"` - // List of access policies assigned to the token. - Policies param.Field[[]UserTokenUpdateParamsPolicy] `json:"policies,required"` - // Status of the token. - Status param.Field[UserTokenUpdateParamsStatus] `json:"status,required"` - Condition param.Field[UserTokenUpdateParamsCondition] `json:"condition"` - // The expiration time on or after which the JWT MUST NOT be accepted for - // processing. - ExpiresOn param.Field[time.Time] `json:"expires_on" format:"date-time"` - // The time before which the token MUST NOT be accepted for processing. - NotBefore param.Field[time.Time] `json:"not_before" format:"date-time"` -} - -func (r UserTokenUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type UserTokenUpdateParamsPolicy struct { - // Allow or deny operations against the resources. - Effect param.Field[UserTokenUpdateParamsPoliciesEffect] `json:"effect,required"` - // A set of permission groups that are specified to the policy. - PermissionGroups param.Field[[]UserTokenUpdateParamsPoliciesPermissionGroup] `json:"permission_groups,required"` - // A list of resource names that the policy applies to. - Resources param.Field[interface{}] `json:"resources,required"` -} - -func (r UserTokenUpdateParamsPolicy) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Allow or deny operations against the resources. -type UserTokenUpdateParamsPoliciesEffect string - -const ( - UserTokenUpdateParamsPoliciesEffectAllow UserTokenUpdateParamsPoliciesEffect = "allow" - UserTokenUpdateParamsPoliciesEffectDeny UserTokenUpdateParamsPoliciesEffect = "deny" -) - -// A named group of permissions that map to a group of operations against -// resources. -type UserTokenUpdateParamsPoliciesPermissionGroup struct { -} - -func (r UserTokenUpdateParamsPoliciesPermissionGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Status of the token. -type UserTokenUpdateParamsStatus string - -const ( - UserTokenUpdateParamsStatusActive UserTokenUpdateParamsStatus = "active" - UserTokenUpdateParamsStatusDisabled UserTokenUpdateParamsStatus = "disabled" - UserTokenUpdateParamsStatusExpired UserTokenUpdateParamsStatus = "expired" -) - -type UserTokenUpdateParamsCondition struct { - // Client IP restrictions. - RequestIP param.Field[UserTokenUpdateParamsConditionRequestIP] `json:"request_ip"` -} - -func (r UserTokenUpdateParamsCondition) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Client IP restrictions. -type UserTokenUpdateParamsConditionRequestIP struct { - // List of IPv4/IPv6 CIDR addresses. - In param.Field[[]string] `json:"in"` - // List of IPv4/IPv6 CIDR addresses. - NotIn param.Field[[]string] `json:"not_in"` -} - -func (r UserTokenUpdateParamsConditionRequestIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type UserTokenUpdateResponseEnvelope struct { - Errors []UserTokenUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []UserTokenUpdateResponseEnvelopeMessages `json:"messages,required"` - Result UserTokenUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success UserTokenUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON userTokenUpdateResponseEnvelopeJSON `json:"-"` -} - -// userTokenUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [UserTokenUpdateResponseEnvelope] -type userTokenUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserTokenUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userTokenUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// userTokenUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [UserTokenUpdateResponseEnvelopeErrors] -type userTokenUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserTokenUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userTokenUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// userTokenUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [UserTokenUpdateResponseEnvelopeMessages] -type userTokenUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserTokenUpdateResponseEnvelopeSuccess bool - -const ( - UserTokenUpdateResponseEnvelopeSuccessTrue UserTokenUpdateResponseEnvelopeSuccess = true -) - -type UserTokenListParams struct { - // Direction to order results. - Direction param.Field[UserTokenListParamsDirection] `query:"direction"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // Maximum number of results per page. - PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [UserTokenListParams]'s query parameters as `url.Values`. -func (r UserTokenListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Direction to order results. -type UserTokenListParamsDirection string - -const ( - UserTokenListParamsDirectionAsc UserTokenListParamsDirection = "asc" - UserTokenListParamsDirectionDesc UserTokenListParamsDirection = "desc" -) - -type UserTokenDeleteResponseEnvelope struct { - Errors []UserTokenDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []UserTokenDeleteResponseEnvelopeMessages `json:"messages,required"` - Result UserTokenDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success UserTokenDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON userTokenDeleteResponseEnvelopeJSON `json:"-"` -} - -// userTokenDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [UserTokenDeleteResponseEnvelope] -type userTokenDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserTokenDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userTokenDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// userTokenDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [UserTokenDeleteResponseEnvelopeErrors] -type userTokenDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserTokenDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userTokenDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// userTokenDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [UserTokenDeleteResponseEnvelopeMessages] -type userTokenDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserTokenDeleteResponseEnvelopeSuccess bool - -const ( - UserTokenDeleteResponseEnvelopeSuccessTrue UserTokenDeleteResponseEnvelopeSuccess = true -) - -type UserTokenGetResponseEnvelope struct { - Errors []UserTokenGetResponseEnvelopeErrors `json:"errors,required"` - Messages []UserTokenGetResponseEnvelopeMessages `json:"messages,required"` - Result UserTokenGetResponse `json:"result,required"` - // Whether the API call was successful - Success UserTokenGetResponseEnvelopeSuccess `json:"success,required"` - JSON userTokenGetResponseEnvelopeJSON `json:"-"` -} - -// userTokenGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [UserTokenGetResponseEnvelope] -type userTokenGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserTokenGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userTokenGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// userTokenGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [UserTokenGetResponseEnvelopeErrors] -type userTokenGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserTokenGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userTokenGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// userTokenGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [UserTokenGetResponseEnvelopeMessages] -type userTokenGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserTokenGetResponseEnvelopeSuccess bool - -const ( - UserTokenGetResponseEnvelopeSuccessTrue UserTokenGetResponseEnvelopeSuccess = true -) - -type UserTokenVerifyResponseEnvelope struct { - Errors []UserTokenVerifyResponseEnvelopeErrors `json:"errors,required"` - Messages []UserTokenVerifyResponseEnvelopeMessages `json:"messages,required"` - Result UserTokenVerifyResponse `json:"result,required"` - // Whether the API call was successful - Success UserTokenVerifyResponseEnvelopeSuccess `json:"success,required"` - JSON userTokenVerifyResponseEnvelopeJSON `json:"-"` -} - -// userTokenVerifyResponseEnvelopeJSON contains the JSON metadata for the struct -// [UserTokenVerifyResponseEnvelope] -type userTokenVerifyResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenVerifyResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenVerifyResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserTokenVerifyResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userTokenVerifyResponseEnvelopeErrorsJSON `json:"-"` -} - -// userTokenVerifyResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [UserTokenVerifyResponseEnvelopeErrors] -type userTokenVerifyResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenVerifyResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenVerifyResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserTokenVerifyResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userTokenVerifyResponseEnvelopeMessagesJSON `json:"-"` -} - -// userTokenVerifyResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [UserTokenVerifyResponseEnvelopeMessages] -type userTokenVerifyResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenVerifyResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenVerifyResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserTokenVerifyResponseEnvelopeSuccess bool - -const ( - UserTokenVerifyResponseEnvelopeSuccessTrue UserTokenVerifyResponseEnvelopeSuccess = true -) diff --git a/usertoken_test.go b/usertoken_test.go deleted file mode 100644 index 0027a501098..00000000000 --- a/usertoken_test.go +++ /dev/null @@ -1,232 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestUserTokenNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.Tokens.New(context.TODO(), cloudflare.UserTokenNewParams{ - Name: cloudflare.F("readonly token"), - Policies: cloudflare.F([]cloudflare.UserTokenNewParamsPolicy{{ - Effect: cloudflare.F(cloudflare.UserTokenNewParamsPoliciesEffectAllow), - PermissionGroups: cloudflare.F([]cloudflare.UserTokenNewParamsPoliciesPermissionGroup{{}, {}}), - Resources: cloudflare.F[any](map[string]interface{}{ - "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", - "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", - }), - }, { - Effect: cloudflare.F(cloudflare.UserTokenNewParamsPoliciesEffectAllow), - PermissionGroups: cloudflare.F([]cloudflare.UserTokenNewParamsPoliciesPermissionGroup{{}, {}}), - Resources: cloudflare.F[any](map[string]interface{}{ - "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", - "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", - }), - }, { - Effect: cloudflare.F(cloudflare.UserTokenNewParamsPoliciesEffectAllow), - PermissionGroups: cloudflare.F([]cloudflare.UserTokenNewParamsPoliciesPermissionGroup{{}, {}}), - Resources: cloudflare.F[any](map[string]interface{}{ - "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", - "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", - }), - }}), - Condition: cloudflare.F(cloudflare.UserTokenNewParamsCondition{ - RequestIP: cloudflare.F(cloudflare.UserTokenNewParamsConditionRequestIP{ - In: cloudflare.F([]string{"123.123.123.0/24", "2606:4700::/32"}), - NotIn: cloudflare.F([]string{"123.123.123.100/24", "2606:4700:4700::/48"}), - }), - }), - ExpiresOn: cloudflare.F(time.Now()), - NotBefore: cloudflare.F(time.Now()), - }) - 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 TestUserTokenUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.Tokens.Update( - context.TODO(), - map[string]interface{}{}, - cloudflare.UserTokenUpdateParams{ - Name: cloudflare.F("readonly token"), - Policies: cloudflare.F([]cloudflare.UserTokenUpdateParamsPolicy{{ - Effect: cloudflare.F(cloudflare.UserTokenUpdateParamsPoliciesEffectAllow), - PermissionGroups: cloudflare.F([]cloudflare.UserTokenUpdateParamsPoliciesPermissionGroup{{}, {}}), - Resources: cloudflare.F[any](map[string]interface{}{ - "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", - "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", - }), - }, { - Effect: cloudflare.F(cloudflare.UserTokenUpdateParamsPoliciesEffectAllow), - PermissionGroups: cloudflare.F([]cloudflare.UserTokenUpdateParamsPoliciesPermissionGroup{{}, {}}), - Resources: cloudflare.F[any](map[string]interface{}{ - "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", - "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", - }), - }, { - Effect: cloudflare.F(cloudflare.UserTokenUpdateParamsPoliciesEffectAllow), - PermissionGroups: cloudflare.F([]cloudflare.UserTokenUpdateParamsPoliciesPermissionGroup{{}, {}}), - Resources: cloudflare.F[any](map[string]interface{}{ - "com.cloudflare.api.account.zone.22b1de5f1c0e4b3ea97bb1e963b06a43": "*", - "com.cloudflare.api.account.zone.eb78d65290b24279ba6f44721b3ea3c4": "*", - }), - }}), - Status: cloudflare.F(cloudflare.UserTokenUpdateParamsStatusActive), - Condition: cloudflare.F(cloudflare.UserTokenUpdateParamsCondition{ - RequestIP: cloudflare.F(cloudflare.UserTokenUpdateParamsConditionRequestIP{ - In: cloudflare.F([]string{"123.123.123.0/24", "2606:4700::/32"}), - NotIn: cloudflare.F([]string{"123.123.123.100/24", "2606:4700:4700::/48"}), - }), - }), - ExpiresOn: cloudflare.F(time.Now()), - NotBefore: cloudflare.F(time.Now()), - }, - ) - 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 TestUserTokenListWithOptionalParams(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("user@example.com"), - ) - _, err := client.User.Tokens.List(context.TODO(), cloudflare.UserTokenListParams{ - Direction: cloudflare.F(cloudflare.UserTokenListParamsDirectionDesc), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(5.000000), - }) - 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 TestUserTokenDelete(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("user@example.com"), - ) - _, err := client.User.Tokens.Delete(context.TODO(), map[string]interface{}{}) - 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 TestUserTokenGet(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("user@example.com"), - ) - _, err := client.User.Tokens.Get(context.TODO(), map[string]interface{}{}) - 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 TestUserTokenVerify(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("user@example.com"), - ) - _, err := client.User.Tokens.Verify(context.TODO()) - 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/usertokenpermissiongroup.go b/usertokenpermissiongroup.go deleted file mode 100644 index 6300b3c6e85..00000000000 --- a/usertokenpermissiongroup.go +++ /dev/null @@ -1,159 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// UserTokenPermissionGroupService 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 -// [NewUserTokenPermissionGroupService] method instead. -type UserTokenPermissionGroupService struct { - Options []option.RequestOption -} - -// NewUserTokenPermissionGroupService 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 NewUserTokenPermissionGroupService(opts ...option.RequestOption) (r *UserTokenPermissionGroupService) { - r = &UserTokenPermissionGroupService{} - r.Options = opts - return -} - -// Find all available permission groups. -func (r *UserTokenPermissionGroupService) List(ctx context.Context, opts ...option.RequestOption) (res *[]UserTokenPermissionGroupListResponse, err error) { - opts = append(r.Options[:], opts...) - var env UserTokenPermissionGroupListResponseEnvelope - path := "user/tokens/permission_groups" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type UserTokenPermissionGroupListResponse = interface{} - -type UserTokenPermissionGroupListResponseEnvelope struct { - Errors []UserTokenPermissionGroupListResponseEnvelopeErrors `json:"errors,required"` - Messages []UserTokenPermissionGroupListResponseEnvelopeMessages `json:"messages,required"` - Result []UserTokenPermissionGroupListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success UserTokenPermissionGroupListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo UserTokenPermissionGroupListResponseEnvelopeResultInfo `json:"result_info"` - JSON userTokenPermissionGroupListResponseEnvelopeJSON `json:"-"` -} - -// userTokenPermissionGroupListResponseEnvelopeJSON contains the JSON metadata for -// the struct [UserTokenPermissionGroupListResponseEnvelope] -type userTokenPermissionGroupListResponseEnvelopeJSON 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 *UserTokenPermissionGroupListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenPermissionGroupListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserTokenPermissionGroupListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userTokenPermissionGroupListResponseEnvelopeErrorsJSON `json:"-"` -} - -// userTokenPermissionGroupListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [UserTokenPermissionGroupListResponseEnvelopeErrors] -type userTokenPermissionGroupListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenPermissionGroupListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenPermissionGroupListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserTokenPermissionGroupListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userTokenPermissionGroupListResponseEnvelopeMessagesJSON `json:"-"` -} - -// userTokenPermissionGroupListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [UserTokenPermissionGroupListResponseEnvelopeMessages] -type userTokenPermissionGroupListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenPermissionGroupListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenPermissionGroupListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserTokenPermissionGroupListResponseEnvelopeSuccess bool - -const ( - UserTokenPermissionGroupListResponseEnvelopeSuccessTrue UserTokenPermissionGroupListResponseEnvelopeSuccess = true -) - -type UserTokenPermissionGroupListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON userTokenPermissionGroupListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// userTokenPermissionGroupListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [UserTokenPermissionGroupListResponseEnvelopeResultInfo] -type userTokenPermissionGroupListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenPermissionGroupListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenPermissionGroupListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/usertokenpermissiongroup_test.go b/usertokenpermissiongroup_test.go deleted file mode 100644 index 17afe9cf9f9..00000000000 --- a/usertokenpermissiongroup_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestUserTokenPermissionGroupList(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("user@example.com"), - ) - _, err := client.User.Tokens.PermissionGroups.List(context.TODO()) - 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/usertokenvalue.go b/usertokenvalue.go deleted file mode 100644 index eee302b7185..00000000000 --- a/usertokenvalue.go +++ /dev/null @@ -1,135 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// UserTokenValueService 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 [NewUserTokenValueService] method -// instead. -type UserTokenValueService struct { - Options []option.RequestOption -} - -// NewUserTokenValueService 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 NewUserTokenValueService(opts ...option.RequestOption) (r *UserTokenValueService) { - r = &UserTokenValueService{} - r.Options = opts - return -} - -// Roll the token secret. -func (r *UserTokenValueService) Update(ctx context.Context, tokenID interface{}, body UserTokenValueUpdateParams, opts ...option.RequestOption) (res *string, err error) { - opts = append(r.Options[:], opts...) - var env UserTokenValueUpdateResponseEnvelope - path := fmt.Sprintf("user/tokens/%v/value", tokenID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type UserTokenValueUpdateParams struct { - Body param.Field[interface{}] `json:"body,required"` -} - -func (r UserTokenValueUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type UserTokenValueUpdateResponseEnvelope struct { - Errors []UserTokenValueUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []UserTokenValueUpdateResponseEnvelopeMessages `json:"messages,required"` - // The token value. - Result string `json:"result,required"` - // Whether the API call was successful - Success UserTokenValueUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON userTokenValueUpdateResponseEnvelopeJSON `json:"-"` -} - -// userTokenValueUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [UserTokenValueUpdateResponseEnvelope] -type userTokenValueUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenValueUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenValueUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type UserTokenValueUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userTokenValueUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// userTokenValueUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [UserTokenValueUpdateResponseEnvelopeErrors] -type userTokenValueUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenValueUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenValueUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type UserTokenValueUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON userTokenValueUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// userTokenValueUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [UserTokenValueUpdateResponseEnvelopeMessages] -type userTokenValueUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *UserTokenValueUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r userTokenValueUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type UserTokenValueUpdateResponseEnvelopeSuccess bool - -const ( - UserTokenValueUpdateResponseEnvelopeSuccessTrue UserTokenValueUpdateResponseEnvelopeSuccess = true -) diff --git a/usertokenvalue_test.go b/usertokenvalue_test.go deleted file mode 100644 index 773b9260da8..00000000000 --- a/usertokenvalue_test.go +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestUserTokenValueUpdate(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("user@example.com"), - ) - _, err := client.User.Tokens.Value.Update( - context.TODO(), - map[string]interface{}{}, - cloudflare.UserTokenValueUpdateParams{ - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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/vectorize/aliases.go b/vectorize/aliases.go new file mode 100644 index 00000000000..76aecc5a22f --- /dev/null +++ b/vectorize/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package vectorize + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/vectorize/index.go b/vectorize/index.go new file mode 100644 index 00000000000..18fac8d9a58 --- /dev/null +++ b/vectorize/index.go @@ -0,0 +1,1300 @@ +// File generated from our OpenAPI spec by Stainless. + +package vectorize + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// IndexService 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 [NewIndexService] method instead. +type IndexService struct { + Options []option.RequestOption +} + +// NewIndexService 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 NewIndexService(opts ...option.RequestOption) (r *IndexService) { + r = &IndexService{} + r.Options = opts + return +} + +// Creates and returns a new Vectorize Index. +func (r *IndexService) New(ctx context.Context, accountIdentifier string, body IndexNewParams, opts ...option.RequestOption) (res *VectorizeCreateIndex, err error) { + opts = append(r.Options[:], opts...) + var env IndexNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/vectorize/indexes", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates and returns the specified Vectorize Index. +func (r *IndexService) Update(ctx context.Context, accountIdentifier string, indexName string, body IndexUpdateParams, opts ...option.RequestOption) (res *VectorizeCreateIndex, err error) { + opts = append(r.Options[:], opts...) + var env IndexUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s", accountIdentifier, indexName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Returns a list of Vectorize Indexes +func (r *IndexService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *[]VectorizeCreateIndex, err error) { + opts = append(r.Options[:], opts...) + var env IndexListResponseEnvelope + path := fmt.Sprintf("accounts/%s/vectorize/indexes", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes the specified Vectorize Index. +func (r *IndexService) Delete(ctx context.Context, accountIdentifier string, indexName string, opts ...option.RequestOption) (res *IndexDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env IndexDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s", accountIdentifier, indexName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a set of vectors from an index by their vector identifiers. +func (r *IndexService) DeleteByIDs(ctx context.Context, accountIdentifier string, indexName string, body IndexDeleteByIDsParams, opts ...option.RequestOption) (res *VectorizeIndexDeleteVectorsByID, err error) { + opts = append(r.Options[:], opts...) + var env IndexDeleteByIDsResponseEnvelope + path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s/delete-by-ids", accountIdentifier, indexName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Returns the specified Vectorize Index. +func (r *IndexService) Get(ctx context.Context, accountIdentifier string, indexName string, opts ...option.RequestOption) (res *VectorizeCreateIndex, err error) { + opts = append(r.Options[:], opts...) + var env IndexGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s", accountIdentifier, indexName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a set of vectors from an index by their vector identifiers. +func (r *IndexService) GetByIDs(ctx context.Context, accountIdentifier string, indexName string, body IndexGetByIDsParams, opts ...option.RequestOption) (res *IndexGetByIDsResponse, err error) { + opts = append(r.Options[:], opts...) + var env IndexGetByIDsResponseEnvelope + path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s/get-by-ids", accountIdentifier, indexName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Inserts vectors into the specified index and returns the count of the vectors +// successfully inserted. +func (r *IndexService) Insert(ctx context.Context, accountIdentifier string, indexName string, opts ...option.RequestOption) (res *VectorizeIndexInsert, err error) { + opts = append(r.Options[:], opts...) + var env IndexInsertResponseEnvelope + path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s/insert", accountIdentifier, indexName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Finds vectors closest to a given vector in an index. +func (r *IndexService) Query(ctx context.Context, accountIdentifier string, indexName string, body IndexQueryParams, opts ...option.RequestOption) (res *VectorizeIndexQuery, err error) { + opts = append(r.Options[:], opts...) + var env IndexQueryResponseEnvelope + path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s/query", accountIdentifier, indexName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Upserts vectors into the specified index, creating them if they do not exist and +// returns the count of values and ids successfully inserted. +func (r *IndexService) Upsert(ctx context.Context, accountIdentifier string, indexName string, opts ...option.RequestOption) (res *VectorizeIndexUpsert, err error) { + opts = append(r.Options[:], opts...) + var env IndexUpsertResponseEnvelope + path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s/upsert", accountIdentifier, indexName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type VectorizeCreateIndex struct { + Config VectorizeCreateIndexConfig `json:"config"` + // Specifies the timestamp the resource was created as an ISO8601 string. + CreatedOn interface{} `json:"created_on"` + // Specifies the description of the index. + Description string `json:"description"` + // Specifies the timestamp the resource was modified as an ISO8601 string. + ModifiedOn interface{} `json:"modified_on"` + Name string `json:"name"` + JSON vectorizeCreateIndexJSON `json:"-"` +} + +// vectorizeCreateIndexJSON contains the JSON metadata for the struct +// [VectorizeCreateIndex] +type vectorizeCreateIndexJSON struct { + Config apijson.Field + CreatedOn apijson.Field + Description apijson.Field + ModifiedOn apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VectorizeCreateIndex) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r vectorizeCreateIndexJSON) RawJSON() string { + return r.raw +} + +type VectorizeCreateIndexConfig struct { + // Specifies the number of dimensions for the index + Dimensions int64 `json:"dimensions,required"` + // Specifies the type of metric to use calculating distance. + Metric VectorizeCreateIndexConfigMetric `json:"metric,required"` + JSON vectorizeCreateIndexConfigJSON `json:"-"` +} + +// vectorizeCreateIndexConfigJSON contains the JSON metadata for the struct +// [VectorizeCreateIndexConfig] +type vectorizeCreateIndexConfigJSON struct { + Dimensions apijson.Field + Metric apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VectorizeCreateIndexConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r vectorizeCreateIndexConfigJSON) RawJSON() string { + return r.raw +} + +// Specifies the type of metric to use calculating distance. +type VectorizeCreateIndexConfigMetric string + +const ( + VectorizeCreateIndexConfigMetricCosine VectorizeCreateIndexConfigMetric = "cosine" + VectorizeCreateIndexConfigMetricEuclidean VectorizeCreateIndexConfigMetric = "euclidean" + VectorizeCreateIndexConfigMetricDotProduct VectorizeCreateIndexConfigMetric = "dot-product" +) + +type VectorizeIndexDeleteVectorsByID struct { + // The count of the vectors successfully deleted. + Count int64 `json:"count"` + // Array of vector identifiers of the vectors that were successfully processed for + // deletion. + IDs []string `json:"ids"` + JSON vectorizeIndexDeleteVectorsByIDJSON `json:"-"` +} + +// vectorizeIndexDeleteVectorsByIDJSON contains the JSON metadata for the struct +// [VectorizeIndexDeleteVectorsByID] +type vectorizeIndexDeleteVectorsByIDJSON struct { + Count apijson.Field + IDs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VectorizeIndexDeleteVectorsByID) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r vectorizeIndexDeleteVectorsByIDJSON) RawJSON() string { + return r.raw +} + +type VectorizeIndexInsert struct { + // Specifies the count of the vectors successfully inserted. + Count int64 `json:"count"` + // Array of vector identifiers of the vectors successfully inserted. + IDs []string `json:"ids"` + JSON vectorizeIndexInsertJSON `json:"-"` +} + +// vectorizeIndexInsertJSON contains the JSON metadata for the struct +// [VectorizeIndexInsert] +type vectorizeIndexInsertJSON struct { + Count apijson.Field + IDs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VectorizeIndexInsert) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r vectorizeIndexInsertJSON) RawJSON() string { + return r.raw +} + +type VectorizeIndexQuery struct { + // Specifies the count of vectors returned by the search + Count int64 `json:"count"` + // Array of vectors matched by the search + Matches []VectorizeIndexQueryMatch `json:"matches"` + JSON vectorizeIndexQueryJSON `json:"-"` +} + +// vectorizeIndexQueryJSON contains the JSON metadata for the struct +// [VectorizeIndexQuery] +type vectorizeIndexQueryJSON struct { + Count apijson.Field + Matches apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VectorizeIndexQuery) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r vectorizeIndexQueryJSON) RawJSON() string { + return r.raw +} + +type VectorizeIndexQueryMatch struct { + // Identifier + ID string `json:"id"` + Metadata interface{} `json:"metadata"` + // The score of the vector according to the index's distance metric + Score float64 `json:"score"` + Values []float64 `json:"values"` + JSON vectorizeIndexQueryMatchJSON `json:"-"` +} + +// vectorizeIndexQueryMatchJSON contains the JSON metadata for the struct +// [VectorizeIndexQueryMatch] +type vectorizeIndexQueryMatchJSON struct { + ID apijson.Field + Metadata apijson.Field + Score apijson.Field + Values apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VectorizeIndexQueryMatch) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r vectorizeIndexQueryMatchJSON) RawJSON() string { + return r.raw +} + +type VectorizeIndexUpsert struct { + // Specifies the count of the vectors successfully inserted. + Count int64 `json:"count"` + // Array of vector identifiers of the vectors successfully inserted. + IDs []string `json:"ids"` + JSON vectorizeIndexUpsertJSON `json:"-"` +} + +// vectorizeIndexUpsertJSON contains the JSON metadata for the struct +// [VectorizeIndexUpsert] +type vectorizeIndexUpsertJSON struct { + Count apijson.Field + IDs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *VectorizeIndexUpsert) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r vectorizeIndexUpsertJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [vectorize.IndexDeleteResponseUnknown] or +// [shared.UnionString]. +type IndexDeleteResponse interface { + ImplementsVectorizeIndexDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*IndexDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type IndexGetByIDsResponse = interface{} + +type IndexNewParams struct { + // Specifies the type of configuration to use for the index. + Config param.Field[IndexNewParamsConfig] `json:"config,required"` + Name param.Field[string] `json:"name,required"` + // Specifies the description of the index. + Description param.Field[string] `json:"description"` +} + +func (r IndexNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Specifies the type of configuration to use for the index. +// +// Satisfied by [vectorize.IndexNewParamsConfigVectorizeIndexPresetConfiguration], +// [vectorize.IndexNewParamsConfigVectorizeIndexDimensionConfiguration]. +type IndexNewParamsConfig interface { + implementsVectorizeIndexNewParamsConfig() +} + +type IndexNewParamsConfigVectorizeIndexPresetConfiguration struct { + // Specifies the preset to use for the index. + Preset param.Field[IndexNewParamsConfigVectorizeIndexPresetConfigurationPreset] `json:"preset,required"` +} + +func (r IndexNewParamsConfigVectorizeIndexPresetConfiguration) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r IndexNewParamsConfigVectorizeIndexPresetConfiguration) implementsVectorizeIndexNewParamsConfig() { +} + +// Specifies the preset to use for the index. +type IndexNewParamsConfigVectorizeIndexPresetConfigurationPreset string + +const ( + IndexNewParamsConfigVectorizeIndexPresetConfigurationPresetCfBaaiBgeSmallEnV1_5 IndexNewParamsConfigVectorizeIndexPresetConfigurationPreset = "@cf/baai/bge-small-en-v1.5" + IndexNewParamsConfigVectorizeIndexPresetConfigurationPresetCfBaaiBgeBaseEnV1_5 IndexNewParamsConfigVectorizeIndexPresetConfigurationPreset = "@cf/baai/bge-base-en-v1.5" + IndexNewParamsConfigVectorizeIndexPresetConfigurationPresetCfBaaiBgeLargeEnV1_5 IndexNewParamsConfigVectorizeIndexPresetConfigurationPreset = "@cf/baai/bge-large-en-v1.5" + IndexNewParamsConfigVectorizeIndexPresetConfigurationPresetOpenAITextEmbeddingAda002 IndexNewParamsConfigVectorizeIndexPresetConfigurationPreset = "openai/text-embedding-ada-002" + IndexNewParamsConfigVectorizeIndexPresetConfigurationPresetCohereEmbedMultilingualV2_0 IndexNewParamsConfigVectorizeIndexPresetConfigurationPreset = "cohere/embed-multilingual-v2.0" +) + +type IndexNewParamsConfigVectorizeIndexDimensionConfiguration struct { + // Specifies the number of dimensions for the index + Dimensions param.Field[int64] `json:"dimensions,required"` + // Specifies the type of metric to use calculating distance. + Metric param.Field[IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetric] `json:"metric,required"` +} + +func (r IndexNewParamsConfigVectorizeIndexDimensionConfiguration) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r IndexNewParamsConfigVectorizeIndexDimensionConfiguration) implementsVectorizeIndexNewParamsConfig() { +} + +// Specifies the type of metric to use calculating distance. +type IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetric string + +const ( + IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetricCosine IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetric = "cosine" + IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetricEuclidean IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetric = "euclidean" + IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetricDotProduct IndexNewParamsConfigVectorizeIndexDimensionConfigurationMetric = "dot-product" +) + +type IndexNewResponseEnvelope struct { + Errors []IndexNewResponseEnvelopeErrors `json:"errors,required"` + Messages []IndexNewResponseEnvelopeMessages `json:"messages,required"` + Result VectorizeCreateIndex `json:"result,required,nullable"` + // Whether the API call was successful + Success IndexNewResponseEnvelopeSuccess `json:"success,required"` + JSON indexNewResponseEnvelopeJSON `json:"-"` +} + +// indexNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [IndexNewResponseEnvelope] +type indexNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IndexNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// indexNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [IndexNewResponseEnvelopeErrors] +type indexNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IndexNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// indexNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [IndexNewResponseEnvelopeMessages] +type indexNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IndexNewResponseEnvelopeSuccess bool + +const ( + IndexNewResponseEnvelopeSuccessTrue IndexNewResponseEnvelopeSuccess = true +) + +type IndexUpdateParams struct { + // Specifies the description of the index. + Description param.Field[string] `json:"description,required"` +} + +func (r IndexUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IndexUpdateResponseEnvelope struct { + Errors []IndexUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []IndexUpdateResponseEnvelopeMessages `json:"messages,required"` + Result VectorizeCreateIndex `json:"result,required,nullable"` + // Whether the API call was successful + Success IndexUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON indexUpdateResponseEnvelopeJSON `json:"-"` +} + +// indexUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [IndexUpdateResponseEnvelope] +type indexUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IndexUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// indexUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [IndexUpdateResponseEnvelopeErrors] +type indexUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IndexUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// indexUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [IndexUpdateResponseEnvelopeMessages] +type indexUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IndexUpdateResponseEnvelopeSuccess bool + +const ( + IndexUpdateResponseEnvelopeSuccessTrue IndexUpdateResponseEnvelopeSuccess = true +) + +type IndexListResponseEnvelope struct { + Errors []IndexListResponseEnvelopeErrors `json:"errors,required"` + Messages []IndexListResponseEnvelopeMessages `json:"messages,required"` + Result []VectorizeCreateIndex `json:"result,required"` + // Whether the API call was successful + Success IndexListResponseEnvelopeSuccess `json:"success,required"` + JSON indexListResponseEnvelopeJSON `json:"-"` +} + +// indexListResponseEnvelopeJSON contains the JSON metadata for the struct +// [IndexListResponseEnvelope] +type indexListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IndexListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexListResponseEnvelopeErrorsJSON `json:"-"` +} + +// indexListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [IndexListResponseEnvelopeErrors] +type indexListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IndexListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexListResponseEnvelopeMessagesJSON `json:"-"` +} + +// indexListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [IndexListResponseEnvelopeMessages] +type indexListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IndexListResponseEnvelopeSuccess bool + +const ( + IndexListResponseEnvelopeSuccessTrue IndexListResponseEnvelopeSuccess = true +) + +type IndexDeleteResponseEnvelope struct { + Errors []IndexDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []IndexDeleteResponseEnvelopeMessages `json:"messages,required"` + Result IndexDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success IndexDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON indexDeleteResponseEnvelopeJSON `json:"-"` +} + +// indexDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [IndexDeleteResponseEnvelope] +type indexDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IndexDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// indexDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [IndexDeleteResponseEnvelopeErrors] +type indexDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IndexDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// indexDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [IndexDeleteResponseEnvelopeMessages] +type indexDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IndexDeleteResponseEnvelopeSuccess bool + +const ( + IndexDeleteResponseEnvelopeSuccessTrue IndexDeleteResponseEnvelopeSuccess = true +) + +type IndexDeleteByIDsParams struct { + // A list of vector identifiers to delete from the index indicated by the path. + IDs param.Field[[]string] `json:"ids"` +} + +func (r IndexDeleteByIDsParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IndexDeleteByIDsResponseEnvelope struct { + Errors []IndexDeleteByIDsResponseEnvelopeErrors `json:"errors,required"` + Messages []IndexDeleteByIDsResponseEnvelopeMessages `json:"messages,required"` + Result VectorizeIndexDeleteVectorsByID `json:"result,required,nullable"` + // Whether the API call was successful + Success IndexDeleteByIDsResponseEnvelopeSuccess `json:"success,required"` + JSON indexDeleteByIDsResponseEnvelopeJSON `json:"-"` +} + +// indexDeleteByIDsResponseEnvelopeJSON contains the JSON metadata for the struct +// [IndexDeleteByIDsResponseEnvelope] +type indexDeleteByIDsResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexDeleteByIDsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexDeleteByIDsResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IndexDeleteByIDsResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexDeleteByIDsResponseEnvelopeErrorsJSON `json:"-"` +} + +// indexDeleteByIDsResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [IndexDeleteByIDsResponseEnvelopeErrors] +type indexDeleteByIDsResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexDeleteByIDsResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexDeleteByIDsResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IndexDeleteByIDsResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexDeleteByIDsResponseEnvelopeMessagesJSON `json:"-"` +} + +// indexDeleteByIDsResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [IndexDeleteByIDsResponseEnvelopeMessages] +type indexDeleteByIDsResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexDeleteByIDsResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexDeleteByIDsResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IndexDeleteByIDsResponseEnvelopeSuccess bool + +const ( + IndexDeleteByIDsResponseEnvelopeSuccessTrue IndexDeleteByIDsResponseEnvelopeSuccess = true +) + +type IndexGetResponseEnvelope struct { + Errors []IndexGetResponseEnvelopeErrors `json:"errors,required"` + Messages []IndexGetResponseEnvelopeMessages `json:"messages,required"` + Result VectorizeCreateIndex `json:"result,required,nullable"` + // Whether the API call was successful + Success IndexGetResponseEnvelopeSuccess `json:"success,required"` + JSON indexGetResponseEnvelopeJSON `json:"-"` +} + +// indexGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [IndexGetResponseEnvelope] +type indexGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IndexGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// indexGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [IndexGetResponseEnvelopeErrors] +type indexGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IndexGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// indexGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [IndexGetResponseEnvelopeMessages] +type indexGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IndexGetResponseEnvelopeSuccess bool + +const ( + IndexGetResponseEnvelopeSuccessTrue IndexGetResponseEnvelopeSuccess = true +) + +type IndexGetByIDsParams struct { + // A list of vector identifiers to retrieve from the index indicated by the path. + IDs param.Field[[]string] `json:"ids"` +} + +func (r IndexGetByIDsParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IndexGetByIDsResponseEnvelope struct { + Errors []IndexGetByIDsResponseEnvelopeErrors `json:"errors,required"` + Messages []IndexGetByIDsResponseEnvelopeMessages `json:"messages,required"` + // Array of vectors with matching ids. + Result IndexGetByIDsResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success IndexGetByIDsResponseEnvelopeSuccess `json:"success,required"` + JSON indexGetByIDsResponseEnvelopeJSON `json:"-"` +} + +// indexGetByIDsResponseEnvelopeJSON contains the JSON metadata for the struct +// [IndexGetByIDsResponseEnvelope] +type indexGetByIDsResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexGetByIDsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexGetByIDsResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IndexGetByIDsResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexGetByIDsResponseEnvelopeErrorsJSON `json:"-"` +} + +// indexGetByIDsResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [IndexGetByIDsResponseEnvelopeErrors] +type indexGetByIDsResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexGetByIDsResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexGetByIDsResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IndexGetByIDsResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexGetByIDsResponseEnvelopeMessagesJSON `json:"-"` +} + +// indexGetByIDsResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [IndexGetByIDsResponseEnvelopeMessages] +type indexGetByIDsResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexGetByIDsResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexGetByIDsResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IndexGetByIDsResponseEnvelopeSuccess bool + +const ( + IndexGetByIDsResponseEnvelopeSuccessTrue IndexGetByIDsResponseEnvelopeSuccess = true +) + +type IndexInsertResponseEnvelope struct { + Errors []IndexInsertResponseEnvelopeErrors `json:"errors,required"` + Messages []IndexInsertResponseEnvelopeMessages `json:"messages,required"` + Result VectorizeIndexInsert `json:"result,required,nullable"` + // Whether the API call was successful + Success IndexInsertResponseEnvelopeSuccess `json:"success,required"` + JSON indexInsertResponseEnvelopeJSON `json:"-"` +} + +// indexInsertResponseEnvelopeJSON contains the JSON metadata for the struct +// [IndexInsertResponseEnvelope] +type indexInsertResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexInsertResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexInsertResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IndexInsertResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexInsertResponseEnvelopeErrorsJSON `json:"-"` +} + +// indexInsertResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [IndexInsertResponseEnvelopeErrors] +type indexInsertResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexInsertResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexInsertResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IndexInsertResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexInsertResponseEnvelopeMessagesJSON `json:"-"` +} + +// indexInsertResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [IndexInsertResponseEnvelopeMessages] +type indexInsertResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexInsertResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexInsertResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IndexInsertResponseEnvelopeSuccess bool + +const ( + IndexInsertResponseEnvelopeSuccessTrue IndexInsertResponseEnvelopeSuccess = true +) + +type IndexQueryParams struct { + // Whether to return the metadata associated with the closest vectors. + ReturnMetadata param.Field[bool] `json:"returnMetadata"` + // Whether to return the values associated with the closest vectors. + ReturnValues param.Field[bool] `json:"returnValues"` + // The number of nearest neighbors to find. + TopK param.Field[float64] `json:"topK"` + // The search vector that will be used to find the nearest neighbors. + Vector param.Field[[]float64] `json:"vector"` +} + +func (r IndexQueryParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IndexQueryResponseEnvelope struct { + Errors []IndexQueryResponseEnvelopeErrors `json:"errors,required"` + Messages []IndexQueryResponseEnvelopeMessages `json:"messages,required"` + Result VectorizeIndexQuery `json:"result,required,nullable"` + // Whether the API call was successful + Success IndexQueryResponseEnvelopeSuccess `json:"success,required"` + JSON indexQueryResponseEnvelopeJSON `json:"-"` +} + +// indexQueryResponseEnvelopeJSON contains the JSON metadata for the struct +// [IndexQueryResponseEnvelope] +type indexQueryResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexQueryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexQueryResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IndexQueryResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexQueryResponseEnvelopeErrorsJSON `json:"-"` +} + +// indexQueryResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [IndexQueryResponseEnvelopeErrors] +type indexQueryResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexQueryResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexQueryResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IndexQueryResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexQueryResponseEnvelopeMessagesJSON `json:"-"` +} + +// indexQueryResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [IndexQueryResponseEnvelopeMessages] +type indexQueryResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexQueryResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexQueryResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IndexQueryResponseEnvelopeSuccess bool + +const ( + IndexQueryResponseEnvelopeSuccessTrue IndexQueryResponseEnvelopeSuccess = true +) + +type IndexUpsertResponseEnvelope struct { + Errors []IndexUpsertResponseEnvelopeErrors `json:"errors,required"` + Messages []IndexUpsertResponseEnvelopeMessages `json:"messages,required"` + Result VectorizeIndexUpsert `json:"result,required,nullable"` + // Whether the API call was successful + Success IndexUpsertResponseEnvelopeSuccess `json:"success,required"` + JSON indexUpsertResponseEnvelopeJSON `json:"-"` +} + +// indexUpsertResponseEnvelopeJSON contains the JSON metadata for the struct +// [IndexUpsertResponseEnvelope] +type indexUpsertResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexUpsertResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexUpsertResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IndexUpsertResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexUpsertResponseEnvelopeErrorsJSON `json:"-"` +} + +// indexUpsertResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [IndexUpsertResponseEnvelopeErrors] +type indexUpsertResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexUpsertResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexUpsertResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IndexUpsertResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON indexUpsertResponseEnvelopeMessagesJSON `json:"-"` +} + +// indexUpsertResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [IndexUpsertResponseEnvelopeMessages] +type indexUpsertResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IndexUpsertResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r indexUpsertResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IndexUpsertResponseEnvelopeSuccess bool + +const ( + IndexUpsertResponseEnvelopeSuccessTrue IndexUpsertResponseEnvelopeSuccess = true +) diff --git a/vectorize/index_test.go b/vectorize/index_test.go new file mode 100644 index 00000000000..de91e230ed4 --- /dev/null +++ b/vectorize/index_test.go @@ -0,0 +1,312 @@ +// File generated from our OpenAPI spec by Stainless. + +package vectorize_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/vectorize" +) + +func TestIndexNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Vectorize.Indexes.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + vectorize.IndexNewParams{ + Config: cloudflare.F[vectorize.IndexNewParamsConfig](vectorize.IndexNewParamsConfigVectorizeIndexPresetConfiguration(vectorize.IndexNewParamsConfigVectorizeIndexPresetConfiguration{ + Preset: cloudflare.F(vectorize.IndexNewParamsConfigVectorizeIndexPresetConfigurationPresetCfBaaiBgeSmallEnV1_5), + })), + Name: cloudflare.F("example-index"), + Description: cloudflare.F("This is my example index."), + }, + ) + 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 TestIndexUpdate(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("user@example.com"), + ) + _, err := client.Vectorize.Indexes.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "example-index", + vectorize.IndexUpdateParams{ + Description: cloudflare.F("This is my example index."), + }, + ) + 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 TestIndexList(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("user@example.com"), + ) + _, err := client.Vectorize.Indexes.List(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()) + } +} + +func TestIndexDelete(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("user@example.com"), + ) + _, err := client.Vectorize.Indexes.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "example-index", + ) + 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 TestIndexDeleteByIDsWithOptionalParams(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("user@example.com"), + ) + _, err := client.Vectorize.Indexes.DeleteByIDs( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "example-index", + vectorize.IndexDeleteByIDsParams{ + IDs: cloudflare.F([]string{"5121db81354a40c6aedc3fe1ace51c59", "f90eb49c2107486abdfd78c67e853430"}), + }, + ) + 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 TestIndexGet(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("user@example.com"), + ) + _, err := client.Vectorize.Indexes.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "example-index", + ) + 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 TestIndexGetByIDsWithOptionalParams(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("user@example.com"), + ) + _, err := client.Vectorize.Indexes.GetByIDs( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "example-index", + vectorize.IndexGetByIDsParams{ + IDs: cloudflare.F([]string{"5121db81354a40c6aedc3fe1ace51c59", "f90eb49c2107486abdfd78c67e853430"}), + }, + ) + 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 TestIndexInsert(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("user@example.com"), + ) + _, err := client.Vectorize.Indexes.Insert( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "example-index", + ) + 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 TestIndexQueryWithOptionalParams(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("user@example.com"), + ) + _, err := client.Vectorize.Indexes.Query( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "example-index", + vectorize.IndexQueryParams{ + ReturnMetadata: cloudflare.F(true), + ReturnValues: cloudflare.F(true), + TopK: cloudflare.F(5.000000), + Vector: cloudflare.F([]float64{0.500000, 0.500000, 0.500000}), + }, + ) + 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 TestIndexUpsert(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("user@example.com"), + ) + _, err := client.Vectorize.Indexes.Upsert( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "example-index", + ) + 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/vectorize.go b/vectorize/vectorize.go similarity index 89% rename from vectorize.go rename to vectorize/vectorize.go index 9ba072e3f54..3344c1733cb 100644 --- a/vectorize.go +++ b/vectorize/vectorize.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package vectorize import ( "github.com/cloudflare/cloudflare-go/option" @@ -12,7 +12,7 @@ import ( // service directly, and instead use the [NewVectorizeService] method instead. type VectorizeService struct { Options []option.RequestOption - Indexes *VectorizeIndexService + Indexes *IndexService } // NewVectorizeService generates a new service that applies the given options to @@ -21,6 +21,6 @@ type VectorizeService struct { func NewVectorizeService(opts ...option.RequestOption) (r *VectorizeService) { r = &VectorizeService{} r.Options = opts - r.Indexes = NewVectorizeIndexService(opts...) + r.Indexes = NewIndexService(opts...) return } diff --git a/vectorizeindex.go b/vectorizeindex.go deleted file mode 100644 index bee27b83e9d..00000000000 --- a/vectorizeindex.go +++ /dev/null @@ -1,1499 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// VectorizeIndexService 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 [NewVectorizeIndexService] method -// instead. -type VectorizeIndexService struct { - Options []option.RequestOption -} - -// NewVectorizeIndexService 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 NewVectorizeIndexService(opts ...option.RequestOption) (r *VectorizeIndexService) { - r = &VectorizeIndexService{} - r.Options = opts - return -} - -// Creates and returns a new Vectorize Index. -func (r *VectorizeIndexService) New(ctx context.Context, accountIdentifier string, body VectorizeIndexNewParams, opts ...option.RequestOption) (res *VectorizeIndexNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env VectorizeIndexNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/vectorize/indexes", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates and returns the specified Vectorize Index. -func (r *VectorizeIndexService) Update(ctx context.Context, accountIdentifier string, indexName string, body VectorizeIndexUpdateParams, opts ...option.RequestOption) (res *VectorizeIndexUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env VectorizeIndexUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s", accountIdentifier, indexName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Returns a list of Vectorize Indexes -func (r *VectorizeIndexService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *[]VectorizeIndexListResponse, err error) { - opts = append(r.Options[:], opts...) - var env VectorizeIndexListResponseEnvelope - path := fmt.Sprintf("accounts/%s/vectorize/indexes", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes the specified Vectorize Index. -func (r *VectorizeIndexService) Delete(ctx context.Context, accountIdentifier string, indexName string, opts ...option.RequestOption) (res *VectorizeIndexDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env VectorizeIndexDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s", accountIdentifier, indexName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a set of vectors from an index by their vector identifiers. -func (r *VectorizeIndexService) DeleteByIDs(ctx context.Context, accountIdentifier string, indexName string, body VectorizeIndexDeleteByIDsParams, opts ...option.RequestOption) (res *VectorizeIndexDeleteByIDsResponse, err error) { - opts = append(r.Options[:], opts...) - var env VectorizeIndexDeleteByIDsResponseEnvelope - path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s/delete-by-ids", accountIdentifier, indexName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Returns the specified Vectorize Index. -func (r *VectorizeIndexService) Get(ctx context.Context, accountIdentifier string, indexName string, opts ...option.RequestOption) (res *VectorizeIndexGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env VectorizeIndexGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s", accountIdentifier, indexName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a set of vectors from an index by their vector identifiers. -func (r *VectorizeIndexService) GetByIDs(ctx context.Context, accountIdentifier string, indexName string, body VectorizeIndexGetByIDsParams, opts ...option.RequestOption) (res *VectorizeIndexGetByIDsResponse, err error) { - opts = append(r.Options[:], opts...) - var env VectorizeIndexGetByIDsResponseEnvelope - path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s/get-by-ids", accountIdentifier, indexName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Inserts vectors into the specified index and returns the count of the vectors -// successfully inserted. -func (r *VectorizeIndexService) Insert(ctx context.Context, accountIdentifier string, indexName string, opts ...option.RequestOption) (res *VectorizeIndexInsertResponse, err error) { - opts = append(r.Options[:], opts...) - var env VectorizeIndexInsertResponseEnvelope - path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s/insert", accountIdentifier, indexName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Finds vectors closest to a given vector in an index. -func (r *VectorizeIndexService) Query(ctx context.Context, accountIdentifier string, indexName string, body VectorizeIndexQueryParams, opts ...option.RequestOption) (res *VectorizeIndexQueryResponse, err error) { - opts = append(r.Options[:], opts...) - var env VectorizeIndexQueryResponseEnvelope - path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s/query", accountIdentifier, indexName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Upserts vectors into the specified index, creating them if they do not exist and -// returns the count of values and ids successfully inserted. -func (r *VectorizeIndexService) Upsert(ctx context.Context, accountIdentifier string, indexName string, opts ...option.RequestOption) (res *VectorizeIndexUpsertResponse, err error) { - opts = append(r.Options[:], opts...) - var env VectorizeIndexUpsertResponseEnvelope - path := fmt.Sprintf("accounts/%s/vectorize/indexes/%s/upsert", accountIdentifier, indexName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type VectorizeIndexNewResponse struct { - Config VectorizeIndexNewResponseConfig `json:"config"` - // Specifies the timestamp the resource was created as an ISO8601 string. - CreatedOn interface{} `json:"created_on"` - // Specifies the description of the index. - Description string `json:"description"` - // Specifies the timestamp the resource was modified as an ISO8601 string. - ModifiedOn interface{} `json:"modified_on"` - Name string `json:"name"` - JSON vectorizeIndexNewResponseJSON `json:"-"` -} - -// vectorizeIndexNewResponseJSON contains the JSON metadata for the struct -// [VectorizeIndexNewResponse] -type vectorizeIndexNewResponseJSON struct { - Config apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexNewResponseJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexNewResponseConfig struct { - // Specifies the number of dimensions for the index - Dimensions int64 `json:"dimensions,required"` - // Specifies the type of metric to use calculating distance. - Metric VectorizeIndexNewResponseConfigMetric `json:"metric,required"` - JSON vectorizeIndexNewResponseConfigJSON `json:"-"` -} - -// vectorizeIndexNewResponseConfigJSON contains the JSON metadata for the struct -// [VectorizeIndexNewResponseConfig] -type vectorizeIndexNewResponseConfigJSON struct { - Dimensions apijson.Field - Metric apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexNewResponseConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexNewResponseConfigJSON) RawJSON() string { - return r.raw -} - -// Specifies the type of metric to use calculating distance. -type VectorizeIndexNewResponseConfigMetric string - -const ( - VectorizeIndexNewResponseConfigMetricCosine VectorizeIndexNewResponseConfigMetric = "cosine" - VectorizeIndexNewResponseConfigMetricEuclidean VectorizeIndexNewResponseConfigMetric = "euclidean" - VectorizeIndexNewResponseConfigMetricDotProduct VectorizeIndexNewResponseConfigMetric = "dot-product" -) - -type VectorizeIndexUpdateResponse struct { - Config VectorizeIndexUpdateResponseConfig `json:"config"` - // Specifies the timestamp the resource was created as an ISO8601 string. - CreatedOn interface{} `json:"created_on"` - // Specifies the description of the index. - Description string `json:"description"` - // Specifies the timestamp the resource was modified as an ISO8601 string. - ModifiedOn interface{} `json:"modified_on"` - Name string `json:"name"` - JSON vectorizeIndexUpdateResponseJSON `json:"-"` -} - -// vectorizeIndexUpdateResponseJSON contains the JSON metadata for the struct -// [VectorizeIndexUpdateResponse] -type vectorizeIndexUpdateResponseJSON struct { - Config apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexUpdateResponseConfig struct { - // Specifies the number of dimensions for the index - Dimensions int64 `json:"dimensions,required"` - // Specifies the type of metric to use calculating distance. - Metric VectorizeIndexUpdateResponseConfigMetric `json:"metric,required"` - JSON vectorizeIndexUpdateResponseConfigJSON `json:"-"` -} - -// vectorizeIndexUpdateResponseConfigJSON contains the JSON metadata for the struct -// [VectorizeIndexUpdateResponseConfig] -type vectorizeIndexUpdateResponseConfigJSON struct { - Dimensions apijson.Field - Metric apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexUpdateResponseConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexUpdateResponseConfigJSON) RawJSON() string { - return r.raw -} - -// Specifies the type of metric to use calculating distance. -type VectorizeIndexUpdateResponseConfigMetric string - -const ( - VectorizeIndexUpdateResponseConfigMetricCosine VectorizeIndexUpdateResponseConfigMetric = "cosine" - VectorizeIndexUpdateResponseConfigMetricEuclidean VectorizeIndexUpdateResponseConfigMetric = "euclidean" - VectorizeIndexUpdateResponseConfigMetricDotProduct VectorizeIndexUpdateResponseConfigMetric = "dot-product" -) - -type VectorizeIndexListResponse struct { - Config VectorizeIndexListResponseConfig `json:"config"` - // Specifies the timestamp the resource was created as an ISO8601 string. - CreatedOn interface{} `json:"created_on"` - // Specifies the description of the index. - Description string `json:"description"` - // Specifies the timestamp the resource was modified as an ISO8601 string. - ModifiedOn interface{} `json:"modified_on"` - Name string `json:"name"` - JSON vectorizeIndexListResponseJSON `json:"-"` -} - -// vectorizeIndexListResponseJSON contains the JSON metadata for the struct -// [VectorizeIndexListResponse] -type vectorizeIndexListResponseJSON struct { - Config apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexListResponseJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexListResponseConfig struct { - // Specifies the number of dimensions for the index - Dimensions int64 `json:"dimensions,required"` - // Specifies the type of metric to use calculating distance. - Metric VectorizeIndexListResponseConfigMetric `json:"metric,required"` - JSON vectorizeIndexListResponseConfigJSON `json:"-"` -} - -// vectorizeIndexListResponseConfigJSON contains the JSON metadata for the struct -// [VectorizeIndexListResponseConfig] -type vectorizeIndexListResponseConfigJSON struct { - Dimensions apijson.Field - Metric apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexListResponseConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexListResponseConfigJSON) RawJSON() string { - return r.raw -} - -// Specifies the type of metric to use calculating distance. -type VectorizeIndexListResponseConfigMetric string - -const ( - VectorizeIndexListResponseConfigMetricCosine VectorizeIndexListResponseConfigMetric = "cosine" - VectorizeIndexListResponseConfigMetricEuclidean VectorizeIndexListResponseConfigMetric = "euclidean" - VectorizeIndexListResponseConfigMetricDotProduct VectorizeIndexListResponseConfigMetric = "dot-product" -) - -// Union satisfied by [VectorizeIndexDeleteResponseUnknown] or -// [shared.UnionString]. -type VectorizeIndexDeleteResponse interface { - ImplementsVectorizeIndexDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*VectorizeIndexDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type VectorizeIndexDeleteByIDsResponse struct { - // The count of the vectors successfully deleted. - Count int64 `json:"count"` - // Array of vector identifiers of the vectors that were successfully processed for - // deletion. - IDs []string `json:"ids"` - JSON vectorizeIndexDeleteByIDsResponseJSON `json:"-"` -} - -// vectorizeIndexDeleteByIDsResponseJSON contains the JSON metadata for the struct -// [VectorizeIndexDeleteByIDsResponse] -type vectorizeIndexDeleteByIDsResponseJSON struct { - Count apijson.Field - IDs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexDeleteByIDsResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexDeleteByIDsResponseJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexGetResponse struct { - Config VectorizeIndexGetResponseConfig `json:"config"` - // Specifies the timestamp the resource was created as an ISO8601 string. - CreatedOn interface{} `json:"created_on"` - // Specifies the description of the index. - Description string `json:"description"` - // Specifies the timestamp the resource was modified as an ISO8601 string. - ModifiedOn interface{} `json:"modified_on"` - Name string `json:"name"` - JSON vectorizeIndexGetResponseJSON `json:"-"` -} - -// vectorizeIndexGetResponseJSON contains the JSON metadata for the struct -// [VectorizeIndexGetResponse] -type vectorizeIndexGetResponseJSON struct { - Config apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexGetResponseJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexGetResponseConfig struct { - // Specifies the number of dimensions for the index - Dimensions int64 `json:"dimensions,required"` - // Specifies the type of metric to use calculating distance. - Metric VectorizeIndexGetResponseConfigMetric `json:"metric,required"` - JSON vectorizeIndexGetResponseConfigJSON `json:"-"` -} - -// vectorizeIndexGetResponseConfigJSON contains the JSON metadata for the struct -// [VectorizeIndexGetResponseConfig] -type vectorizeIndexGetResponseConfigJSON struct { - Dimensions apijson.Field - Metric apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexGetResponseConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexGetResponseConfigJSON) RawJSON() string { - return r.raw -} - -// Specifies the type of metric to use calculating distance. -type VectorizeIndexGetResponseConfigMetric string - -const ( - VectorizeIndexGetResponseConfigMetricCosine VectorizeIndexGetResponseConfigMetric = "cosine" - VectorizeIndexGetResponseConfigMetricEuclidean VectorizeIndexGetResponseConfigMetric = "euclidean" - VectorizeIndexGetResponseConfigMetricDotProduct VectorizeIndexGetResponseConfigMetric = "dot-product" -) - -type VectorizeIndexGetByIDsResponse = interface{} - -type VectorizeIndexInsertResponse struct { - // Specifies the count of the vectors successfully inserted. - Count int64 `json:"count"` - // Array of vector identifiers of the vectors successfully inserted. - IDs []string `json:"ids"` - JSON vectorizeIndexInsertResponseJSON `json:"-"` -} - -// vectorizeIndexInsertResponseJSON contains the JSON metadata for the struct -// [VectorizeIndexInsertResponse] -type vectorizeIndexInsertResponseJSON struct { - Count apijson.Field - IDs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexInsertResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexInsertResponseJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexQueryResponse struct { - // Specifies the count of vectors returned by the search - Count int64 `json:"count"` - // Array of vectors matched by the search - Matches []VectorizeIndexQueryResponseMatch `json:"matches"` - JSON vectorizeIndexQueryResponseJSON `json:"-"` -} - -// vectorizeIndexQueryResponseJSON contains the JSON metadata for the struct -// [VectorizeIndexQueryResponse] -type vectorizeIndexQueryResponseJSON struct { - Count apijson.Field - Matches apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexQueryResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexQueryResponseJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexQueryResponseMatch struct { - // Identifier - ID string `json:"id"` - Metadata interface{} `json:"metadata"` - // The score of the vector according to the index's distance metric - Score float64 `json:"score"` - Values []float64 `json:"values"` - JSON vectorizeIndexQueryResponseMatchJSON `json:"-"` -} - -// vectorizeIndexQueryResponseMatchJSON contains the JSON metadata for the struct -// [VectorizeIndexQueryResponseMatch] -type vectorizeIndexQueryResponseMatchJSON struct { - ID apijson.Field - Metadata apijson.Field - Score apijson.Field - Values apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexQueryResponseMatch) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexQueryResponseMatchJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexUpsertResponse struct { - // Specifies the count of the vectors successfully inserted. - Count int64 `json:"count"` - // Array of vector identifiers of the vectors successfully inserted. - IDs []string `json:"ids"` - JSON vectorizeIndexUpsertResponseJSON `json:"-"` -} - -// vectorizeIndexUpsertResponseJSON contains the JSON metadata for the struct -// [VectorizeIndexUpsertResponse] -type vectorizeIndexUpsertResponseJSON struct { - Count apijson.Field - IDs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexUpsertResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexUpsertResponseJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexNewParams struct { - // Specifies the type of configuration to use for the index. - Config param.Field[VectorizeIndexNewParamsConfig] `json:"config,required"` - Name param.Field[string] `json:"name,required"` - // Specifies the description of the index. - Description param.Field[string] `json:"description"` -} - -func (r VectorizeIndexNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Specifies the type of configuration to use for the index. -// -// Satisfied by [VectorizeIndexNewParamsConfigVectorizeIndexPresetConfiguration], -// [VectorizeIndexNewParamsConfigVectorizeIndexDimensionConfiguration]. -type VectorizeIndexNewParamsConfig interface { - implementsVectorizeIndexNewParamsConfig() -} - -type VectorizeIndexNewParamsConfigVectorizeIndexPresetConfiguration struct { - // Specifies the preset to use for the index. - Preset param.Field[VectorizeIndexNewParamsConfigVectorizeIndexPresetConfigurationPreset] `json:"preset,required"` -} - -func (r VectorizeIndexNewParamsConfigVectorizeIndexPresetConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r VectorizeIndexNewParamsConfigVectorizeIndexPresetConfiguration) implementsVectorizeIndexNewParamsConfig() { -} - -// Specifies the preset to use for the index. -type VectorizeIndexNewParamsConfigVectorizeIndexPresetConfigurationPreset string - -const ( - VectorizeIndexNewParamsConfigVectorizeIndexPresetConfigurationPresetCfBaaiBgeSmallEnV1_5 VectorizeIndexNewParamsConfigVectorizeIndexPresetConfigurationPreset = "@cf/baai/bge-small-en-v1.5" - VectorizeIndexNewParamsConfigVectorizeIndexPresetConfigurationPresetCfBaaiBgeBaseEnV1_5 VectorizeIndexNewParamsConfigVectorizeIndexPresetConfigurationPreset = "@cf/baai/bge-base-en-v1.5" - VectorizeIndexNewParamsConfigVectorizeIndexPresetConfigurationPresetCfBaaiBgeLargeEnV1_5 VectorizeIndexNewParamsConfigVectorizeIndexPresetConfigurationPreset = "@cf/baai/bge-large-en-v1.5" - VectorizeIndexNewParamsConfigVectorizeIndexPresetConfigurationPresetOpenAITextEmbeddingAda002 VectorizeIndexNewParamsConfigVectorizeIndexPresetConfigurationPreset = "openai/text-embedding-ada-002" - VectorizeIndexNewParamsConfigVectorizeIndexPresetConfigurationPresetCohereEmbedMultilingualV2_0 VectorizeIndexNewParamsConfigVectorizeIndexPresetConfigurationPreset = "cohere/embed-multilingual-v2.0" -) - -type VectorizeIndexNewParamsConfigVectorizeIndexDimensionConfiguration struct { - // Specifies the number of dimensions for the index - Dimensions param.Field[int64] `json:"dimensions,required"` - // Specifies the type of metric to use calculating distance. - Metric param.Field[VectorizeIndexNewParamsConfigVectorizeIndexDimensionConfigurationMetric] `json:"metric,required"` -} - -func (r VectorizeIndexNewParamsConfigVectorizeIndexDimensionConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r VectorizeIndexNewParamsConfigVectorizeIndexDimensionConfiguration) implementsVectorizeIndexNewParamsConfig() { -} - -// Specifies the type of metric to use calculating distance. -type VectorizeIndexNewParamsConfigVectorizeIndexDimensionConfigurationMetric string - -const ( - VectorizeIndexNewParamsConfigVectorizeIndexDimensionConfigurationMetricCosine VectorizeIndexNewParamsConfigVectorizeIndexDimensionConfigurationMetric = "cosine" - VectorizeIndexNewParamsConfigVectorizeIndexDimensionConfigurationMetricEuclidean VectorizeIndexNewParamsConfigVectorizeIndexDimensionConfigurationMetric = "euclidean" - VectorizeIndexNewParamsConfigVectorizeIndexDimensionConfigurationMetricDotProduct VectorizeIndexNewParamsConfigVectorizeIndexDimensionConfigurationMetric = "dot-product" -) - -type VectorizeIndexNewResponseEnvelope struct { - Errors []VectorizeIndexNewResponseEnvelopeErrors `json:"errors,required"` - Messages []VectorizeIndexNewResponseEnvelopeMessages `json:"messages,required"` - Result VectorizeIndexNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success VectorizeIndexNewResponseEnvelopeSuccess `json:"success,required"` - JSON vectorizeIndexNewResponseEnvelopeJSON `json:"-"` -} - -// vectorizeIndexNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [VectorizeIndexNewResponseEnvelope] -type vectorizeIndexNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// vectorizeIndexNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [VectorizeIndexNewResponseEnvelopeErrors] -type vectorizeIndexNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// vectorizeIndexNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [VectorizeIndexNewResponseEnvelopeMessages] -type vectorizeIndexNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type VectorizeIndexNewResponseEnvelopeSuccess bool - -const ( - VectorizeIndexNewResponseEnvelopeSuccessTrue VectorizeIndexNewResponseEnvelopeSuccess = true -) - -type VectorizeIndexUpdateParams struct { - // Specifies the description of the index. - Description param.Field[string] `json:"description,required"` -} - -func (r VectorizeIndexUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type VectorizeIndexUpdateResponseEnvelope struct { - Errors []VectorizeIndexUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []VectorizeIndexUpdateResponseEnvelopeMessages `json:"messages,required"` - Result VectorizeIndexUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success VectorizeIndexUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON vectorizeIndexUpdateResponseEnvelopeJSON `json:"-"` -} - -// vectorizeIndexUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [VectorizeIndexUpdateResponseEnvelope] -type vectorizeIndexUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// vectorizeIndexUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [VectorizeIndexUpdateResponseEnvelopeErrors] -type vectorizeIndexUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// vectorizeIndexUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [VectorizeIndexUpdateResponseEnvelopeMessages] -type vectorizeIndexUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type VectorizeIndexUpdateResponseEnvelopeSuccess bool - -const ( - VectorizeIndexUpdateResponseEnvelopeSuccessTrue VectorizeIndexUpdateResponseEnvelopeSuccess = true -) - -type VectorizeIndexListResponseEnvelope struct { - Errors []VectorizeIndexListResponseEnvelopeErrors `json:"errors,required"` - Messages []VectorizeIndexListResponseEnvelopeMessages `json:"messages,required"` - Result []VectorizeIndexListResponse `json:"result,required"` - // Whether the API call was successful - Success VectorizeIndexListResponseEnvelopeSuccess `json:"success,required"` - JSON vectorizeIndexListResponseEnvelopeJSON `json:"-"` -} - -// vectorizeIndexListResponseEnvelopeJSON contains the JSON metadata for the struct -// [VectorizeIndexListResponseEnvelope] -type vectorizeIndexListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexListResponseEnvelopeErrorsJSON `json:"-"` -} - -// vectorizeIndexListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [VectorizeIndexListResponseEnvelopeErrors] -type vectorizeIndexListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexListResponseEnvelopeMessagesJSON `json:"-"` -} - -// vectorizeIndexListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [VectorizeIndexListResponseEnvelopeMessages] -type vectorizeIndexListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type VectorizeIndexListResponseEnvelopeSuccess bool - -const ( - VectorizeIndexListResponseEnvelopeSuccessTrue VectorizeIndexListResponseEnvelopeSuccess = true -) - -type VectorizeIndexDeleteResponseEnvelope struct { - Errors []VectorizeIndexDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []VectorizeIndexDeleteResponseEnvelopeMessages `json:"messages,required"` - Result VectorizeIndexDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success VectorizeIndexDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON vectorizeIndexDeleteResponseEnvelopeJSON `json:"-"` -} - -// vectorizeIndexDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [VectorizeIndexDeleteResponseEnvelope] -type vectorizeIndexDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// vectorizeIndexDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [VectorizeIndexDeleteResponseEnvelopeErrors] -type vectorizeIndexDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// vectorizeIndexDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [VectorizeIndexDeleteResponseEnvelopeMessages] -type vectorizeIndexDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type VectorizeIndexDeleteResponseEnvelopeSuccess bool - -const ( - VectorizeIndexDeleteResponseEnvelopeSuccessTrue VectorizeIndexDeleteResponseEnvelopeSuccess = true -) - -type VectorizeIndexDeleteByIDsParams struct { - // A list of vector identifiers to delete from the index indicated by the path. - IDs param.Field[[]string] `json:"ids"` -} - -func (r VectorizeIndexDeleteByIDsParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type VectorizeIndexDeleteByIDsResponseEnvelope struct { - Errors []VectorizeIndexDeleteByIDsResponseEnvelopeErrors `json:"errors,required"` - Messages []VectorizeIndexDeleteByIDsResponseEnvelopeMessages `json:"messages,required"` - Result VectorizeIndexDeleteByIDsResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success VectorizeIndexDeleteByIDsResponseEnvelopeSuccess `json:"success,required"` - JSON vectorizeIndexDeleteByIDsResponseEnvelopeJSON `json:"-"` -} - -// vectorizeIndexDeleteByIDsResponseEnvelopeJSON contains the JSON metadata for the -// struct [VectorizeIndexDeleteByIDsResponseEnvelope] -type vectorizeIndexDeleteByIDsResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexDeleteByIDsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexDeleteByIDsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexDeleteByIDsResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexDeleteByIDsResponseEnvelopeErrorsJSON `json:"-"` -} - -// vectorizeIndexDeleteByIDsResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [VectorizeIndexDeleteByIDsResponseEnvelopeErrors] -type vectorizeIndexDeleteByIDsResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexDeleteByIDsResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexDeleteByIDsResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexDeleteByIDsResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexDeleteByIDsResponseEnvelopeMessagesJSON `json:"-"` -} - -// vectorizeIndexDeleteByIDsResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [VectorizeIndexDeleteByIDsResponseEnvelopeMessages] -type vectorizeIndexDeleteByIDsResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexDeleteByIDsResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexDeleteByIDsResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type VectorizeIndexDeleteByIDsResponseEnvelopeSuccess bool - -const ( - VectorizeIndexDeleteByIDsResponseEnvelopeSuccessTrue VectorizeIndexDeleteByIDsResponseEnvelopeSuccess = true -) - -type VectorizeIndexGetResponseEnvelope struct { - Errors []VectorizeIndexGetResponseEnvelopeErrors `json:"errors,required"` - Messages []VectorizeIndexGetResponseEnvelopeMessages `json:"messages,required"` - Result VectorizeIndexGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success VectorizeIndexGetResponseEnvelopeSuccess `json:"success,required"` - JSON vectorizeIndexGetResponseEnvelopeJSON `json:"-"` -} - -// vectorizeIndexGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [VectorizeIndexGetResponseEnvelope] -type vectorizeIndexGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// vectorizeIndexGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [VectorizeIndexGetResponseEnvelopeErrors] -type vectorizeIndexGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// vectorizeIndexGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [VectorizeIndexGetResponseEnvelopeMessages] -type vectorizeIndexGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type VectorizeIndexGetResponseEnvelopeSuccess bool - -const ( - VectorizeIndexGetResponseEnvelopeSuccessTrue VectorizeIndexGetResponseEnvelopeSuccess = true -) - -type VectorizeIndexGetByIDsParams struct { - // A list of vector identifiers to retrieve from the index indicated by the path. - IDs param.Field[[]string] `json:"ids"` -} - -func (r VectorizeIndexGetByIDsParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type VectorizeIndexGetByIDsResponseEnvelope struct { - Errors []VectorizeIndexGetByIDsResponseEnvelopeErrors `json:"errors,required"` - Messages []VectorizeIndexGetByIDsResponseEnvelopeMessages `json:"messages,required"` - // Array of vectors with matching ids. - Result VectorizeIndexGetByIDsResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success VectorizeIndexGetByIDsResponseEnvelopeSuccess `json:"success,required"` - JSON vectorizeIndexGetByIDsResponseEnvelopeJSON `json:"-"` -} - -// vectorizeIndexGetByIDsResponseEnvelopeJSON contains the JSON metadata for the -// struct [VectorizeIndexGetByIDsResponseEnvelope] -type vectorizeIndexGetByIDsResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexGetByIDsResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexGetByIDsResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexGetByIDsResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexGetByIDsResponseEnvelopeErrorsJSON `json:"-"` -} - -// vectorizeIndexGetByIDsResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [VectorizeIndexGetByIDsResponseEnvelopeErrors] -type vectorizeIndexGetByIDsResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexGetByIDsResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexGetByIDsResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexGetByIDsResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexGetByIDsResponseEnvelopeMessagesJSON `json:"-"` -} - -// vectorizeIndexGetByIDsResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [VectorizeIndexGetByIDsResponseEnvelopeMessages] -type vectorizeIndexGetByIDsResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexGetByIDsResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexGetByIDsResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type VectorizeIndexGetByIDsResponseEnvelopeSuccess bool - -const ( - VectorizeIndexGetByIDsResponseEnvelopeSuccessTrue VectorizeIndexGetByIDsResponseEnvelopeSuccess = true -) - -type VectorizeIndexInsertResponseEnvelope struct { - Errors []VectorizeIndexInsertResponseEnvelopeErrors `json:"errors,required"` - Messages []VectorizeIndexInsertResponseEnvelopeMessages `json:"messages,required"` - Result VectorizeIndexInsertResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success VectorizeIndexInsertResponseEnvelopeSuccess `json:"success,required"` - JSON vectorizeIndexInsertResponseEnvelopeJSON `json:"-"` -} - -// vectorizeIndexInsertResponseEnvelopeJSON contains the JSON metadata for the -// struct [VectorizeIndexInsertResponseEnvelope] -type vectorizeIndexInsertResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexInsertResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexInsertResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexInsertResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexInsertResponseEnvelopeErrorsJSON `json:"-"` -} - -// vectorizeIndexInsertResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [VectorizeIndexInsertResponseEnvelopeErrors] -type vectorizeIndexInsertResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexInsertResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexInsertResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexInsertResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexInsertResponseEnvelopeMessagesJSON `json:"-"` -} - -// vectorizeIndexInsertResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [VectorizeIndexInsertResponseEnvelopeMessages] -type vectorizeIndexInsertResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexInsertResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexInsertResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type VectorizeIndexInsertResponseEnvelopeSuccess bool - -const ( - VectorizeIndexInsertResponseEnvelopeSuccessTrue VectorizeIndexInsertResponseEnvelopeSuccess = true -) - -type VectorizeIndexQueryParams struct { - // Whether to return the metadata associated with the closest vectors. - ReturnMetadata param.Field[bool] `json:"returnMetadata"` - // Whether to return the values associated with the closest vectors. - ReturnValues param.Field[bool] `json:"returnValues"` - // The number of nearest neighbors to find. - TopK param.Field[float64] `json:"topK"` - // The search vector that will be used to find the nearest neighbors. - Vector param.Field[[]float64] `json:"vector"` -} - -func (r VectorizeIndexQueryParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type VectorizeIndexQueryResponseEnvelope struct { - Errors []VectorizeIndexQueryResponseEnvelopeErrors `json:"errors,required"` - Messages []VectorizeIndexQueryResponseEnvelopeMessages `json:"messages,required"` - Result VectorizeIndexQueryResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success VectorizeIndexQueryResponseEnvelopeSuccess `json:"success,required"` - JSON vectorizeIndexQueryResponseEnvelopeJSON `json:"-"` -} - -// vectorizeIndexQueryResponseEnvelopeJSON contains the JSON metadata for the -// struct [VectorizeIndexQueryResponseEnvelope] -type vectorizeIndexQueryResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexQueryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexQueryResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexQueryResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexQueryResponseEnvelopeErrorsJSON `json:"-"` -} - -// vectorizeIndexQueryResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [VectorizeIndexQueryResponseEnvelopeErrors] -type vectorizeIndexQueryResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexQueryResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexQueryResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexQueryResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexQueryResponseEnvelopeMessagesJSON `json:"-"` -} - -// vectorizeIndexQueryResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [VectorizeIndexQueryResponseEnvelopeMessages] -type vectorizeIndexQueryResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexQueryResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexQueryResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type VectorizeIndexQueryResponseEnvelopeSuccess bool - -const ( - VectorizeIndexQueryResponseEnvelopeSuccessTrue VectorizeIndexQueryResponseEnvelopeSuccess = true -) - -type VectorizeIndexUpsertResponseEnvelope struct { - Errors []VectorizeIndexUpsertResponseEnvelopeErrors `json:"errors,required"` - Messages []VectorizeIndexUpsertResponseEnvelopeMessages `json:"messages,required"` - Result VectorizeIndexUpsertResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success VectorizeIndexUpsertResponseEnvelopeSuccess `json:"success,required"` - JSON vectorizeIndexUpsertResponseEnvelopeJSON `json:"-"` -} - -// vectorizeIndexUpsertResponseEnvelopeJSON contains the JSON metadata for the -// struct [VectorizeIndexUpsertResponseEnvelope] -type vectorizeIndexUpsertResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexUpsertResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexUpsertResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexUpsertResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexUpsertResponseEnvelopeErrorsJSON `json:"-"` -} - -// vectorizeIndexUpsertResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [VectorizeIndexUpsertResponseEnvelopeErrors] -type vectorizeIndexUpsertResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexUpsertResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexUpsertResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type VectorizeIndexUpsertResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON vectorizeIndexUpsertResponseEnvelopeMessagesJSON `json:"-"` -} - -// vectorizeIndexUpsertResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [VectorizeIndexUpsertResponseEnvelopeMessages] -type vectorizeIndexUpsertResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *VectorizeIndexUpsertResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r vectorizeIndexUpsertResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type VectorizeIndexUpsertResponseEnvelopeSuccess bool - -const ( - VectorizeIndexUpsertResponseEnvelopeSuccessTrue VectorizeIndexUpsertResponseEnvelopeSuccess = true -) diff --git a/vectorizeindex_test.go b/vectorizeindex_test.go deleted file mode 100644 index 1d10b612b2e..00000000000 --- a/vectorizeindex_test.go +++ /dev/null @@ -1,311 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestVectorizeIndexNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Vectorize.Indexes.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.VectorizeIndexNewParams{ - Config: cloudflare.F[cloudflare.VectorizeIndexNewParamsConfig](cloudflare.VectorizeIndexNewParamsConfigVectorizeIndexPresetConfiguration(cloudflare.VectorizeIndexNewParamsConfigVectorizeIndexPresetConfiguration{ - Preset: cloudflare.F(cloudflare.VectorizeIndexNewParamsConfigVectorizeIndexPresetConfigurationPresetCfBaaiBgeSmallEnV1_5), - })), - Name: cloudflare.F("example-index"), - Description: cloudflare.F("This is my example index."), - }, - ) - 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 TestVectorizeIndexUpdate(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("user@example.com"), - ) - _, err := client.Vectorize.Indexes.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "example-index", - cloudflare.VectorizeIndexUpdateParams{ - Description: cloudflare.F("This is my example index."), - }, - ) - 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 TestVectorizeIndexList(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("user@example.com"), - ) - _, err := client.Vectorize.Indexes.List(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()) - } -} - -func TestVectorizeIndexDelete(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("user@example.com"), - ) - _, err := client.Vectorize.Indexes.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "example-index", - ) - 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 TestVectorizeIndexDeleteByIDsWithOptionalParams(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("user@example.com"), - ) - _, err := client.Vectorize.Indexes.DeleteByIDs( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "example-index", - cloudflare.VectorizeIndexDeleteByIDsParams{ - IDs: cloudflare.F([]string{"5121db81354a40c6aedc3fe1ace51c59", "f90eb49c2107486abdfd78c67e853430"}), - }, - ) - 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 TestVectorizeIndexGet(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("user@example.com"), - ) - _, err := client.Vectorize.Indexes.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "example-index", - ) - 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 TestVectorizeIndexGetByIDsWithOptionalParams(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("user@example.com"), - ) - _, err := client.Vectorize.Indexes.GetByIDs( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "example-index", - cloudflare.VectorizeIndexGetByIDsParams{ - IDs: cloudflare.F([]string{"5121db81354a40c6aedc3fe1ace51c59", "f90eb49c2107486abdfd78c67e853430"}), - }, - ) - 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 TestVectorizeIndexInsert(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("user@example.com"), - ) - _, err := client.Vectorize.Indexes.Insert( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "example-index", - ) - 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 TestVectorizeIndexQueryWithOptionalParams(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("user@example.com"), - ) - _, err := client.Vectorize.Indexes.Query( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "example-index", - cloudflare.VectorizeIndexQueryParams{ - ReturnMetadata: cloudflare.F(true), - ReturnValues: cloudflare.F(true), - TopK: cloudflare.F(5.000000), - Vector: cloudflare.F([]float64{0.500000, 0.500000, 0.500000}), - }, - ) - 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 TestVectorizeIndexUpsert(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("user@example.com"), - ) - _, err := client.Vectorize.Indexes.Upsert( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "example-index", - ) - 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/waiting_rooms/aliases.go b/waiting_rooms/aliases.go new file mode 100644 index 00000000000..003e9c89d6e --- /dev/null +++ b/waiting_rooms/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package waiting_rooms + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/waiting_rooms/event.go b/waiting_rooms/event.go new file mode 100644 index 00000000000..473dcb1ba88 --- /dev/null +++ b/waiting_rooms/event.go @@ -0,0 +1,596 @@ +// File generated from our OpenAPI spec by Stainless. + +package waiting_rooms + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// EventService 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 [NewEventService] method instead. +type EventService struct { + Options []option.RequestOption + Details *EventDetailService +} + +// NewEventService 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 NewEventService(opts ...option.RequestOption) (r *EventService) { + r = &EventService{} + r.Options = opts + r.Details = NewEventDetailService(opts...) + return +} + +// Only available for the Waiting Room Advanced subscription. Creates an event for +// a waiting room. An event takes place during a specified period of time, +// temporarily changing the behavior of a waiting room. While the event is active, +// some of the properties in the event's configuration may either override or +// inherit from the waiting room's configuration. Note that events cannot overlap +// with each other, so only one event can be active at a time. +func (r *EventService) New(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body EventNewParams, opts ...option.RequestOption) (res *WaitingroomEventResult, err error) { + opts = append(r.Options[:], opts...) + var env EventNewResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/%v/events", zoneIdentifier, waitingRoomID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a configured event for a waiting room. +func (r *EventService) Update(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}, body EventUpdateParams, opts ...option.RequestOption) (res *WaitingroomEventResult, err error) { + opts = append(r.Options[:], opts...) + var env EventUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/%v/events/%v", zoneIdentifier, waitingRoomID, eventID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists events for a waiting room. +func (r *EventService) List(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, opts ...option.RequestOption) (res *[]WaitingroomEventResult, err error) { + opts = append(r.Options[:], opts...) + var env EventListResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/%v/events", zoneIdentifier, waitingRoomID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes an event for a waiting room. +func (r *EventService) Delete(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}, opts ...option.RequestOption) (res *EventDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env EventDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/%v/events/%v", zoneIdentifier, waitingRoomID, eventID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Patches a configured event for a waiting room. +func (r *EventService) Edit(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}, body EventEditParams, opts ...option.RequestOption) (res *WaitingroomEventResult, err error) { + opts = append(r.Options[:], opts...) + var env EventEditResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/%v/events/%v", zoneIdentifier, waitingRoomID, eventID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a single configured event for a waiting room. +func (r *EventService) Get(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}, opts ...option.RequestOption) (res *WaitingroomEventResult, err error) { + opts = append(r.Options[:], opts...) + var env EventGetResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/%v/events/%v", zoneIdentifier, waitingRoomID, eventID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type WaitingroomEventResult struct { + ID interface{} `json:"id"` + CreatedOn time.Time `json:"created_on" format:"date-time"` + // If set, the event will override the waiting room's `custom_page_html` property + // while it is active. If null, the event will inherit it. + CustomPageHTML string `json:"custom_page_html,nullable"` + // A note that you can use to add more details about the event. + Description string `json:"description"` + // If set, the event will override the waiting room's `disable_session_renewal` + // property while it is active. If null, the event will inherit it. + DisableSessionRenewal bool `json:"disable_session_renewal,nullable"` + // An ISO 8601 timestamp that marks the end of the event. + EventEndTime string `json:"event_end_time"` + // An ISO 8601 timestamp that marks the start of the event. At this time, queued + // users will be processed with the event's configuration. The start time must be + // at least one minute before `event_end_time`. + EventStartTime string `json:"event_start_time"` + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // A unique name to identify the event. Only alphanumeric characters, hyphens and + // underscores are allowed. + Name string `json:"name"` + // If set, the event will override the waiting room's `new_users_per_minute` + // property while it is active. If null, the event will inherit it. This can only + // be set if the event's `total_active_users` property is also set. + NewUsersPerMinute int64 `json:"new_users_per_minute,nullable"` + // An ISO 8601 timestamp that marks when to begin queueing all users before the + // event starts. The prequeue must start at least five minutes before + // `event_start_time`. + PrequeueStartTime string `json:"prequeue_start_time,nullable"` + // If set, the event will override the waiting room's `queueing_method` property + // while it is active. If null, the event will inherit it. + QueueingMethod string `json:"queueing_method,nullable"` + // If set, the event will override the waiting room's `session_duration` property + // while it is active. If null, the event will inherit it. + SessionDuration int64 `json:"session_duration,nullable"` + // If enabled, users in the prequeue will be shuffled randomly at the + // `event_start_time`. Requires that `prequeue_start_time` is not null. This is + // useful for situations when many users will join the event prequeue at the same + // time and you want to shuffle them to ensure fairness. Naturally, it makes the + // most sense to enable this feature when the `queueing_method` during the event + // respects ordering such as **fifo**, or else the shuffling may be unnecessary. + ShuffleAtEventStart bool `json:"shuffle_at_event_start"` + // Suspends or allows an event. If set to `true`, the event is ignored and traffic + // will be handled based on the waiting room configuration. + Suspended bool `json:"suspended"` + // If set, the event will override the waiting room's `total_active_users` property + // while it is active. If null, the event will inherit it. This can only be set if + // the event's `new_users_per_minute` property is also set. + TotalActiveUsers int64 `json:"total_active_users,nullable"` + JSON waitingroomEventResultJSON `json:"-"` +} + +// waitingroomEventResultJSON contains the JSON metadata for the struct +// [WaitingroomEventResult] +type waitingroomEventResultJSON struct { + ID apijson.Field + CreatedOn apijson.Field + CustomPageHTML apijson.Field + Description apijson.Field + DisableSessionRenewal apijson.Field + EventEndTime apijson.Field + EventStartTime apijson.Field + ModifiedOn apijson.Field + Name apijson.Field + NewUsersPerMinute apijson.Field + PrequeueStartTime apijson.Field + QueueingMethod apijson.Field + SessionDuration apijson.Field + ShuffleAtEventStart apijson.Field + Suspended apijson.Field + TotalActiveUsers apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WaitingroomEventResult) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingroomEventResultJSON) RawJSON() string { + return r.raw +} + +type EventDeleteResponse struct { + ID interface{} `json:"id"` + JSON eventDeleteResponseJSON `json:"-"` +} + +// eventDeleteResponseJSON contains the JSON metadata for the struct +// [EventDeleteResponse] +type eventDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EventDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r eventDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type EventNewParams struct { + // An ISO 8601 timestamp that marks the end of the event. + EventEndTime param.Field[string] `json:"event_end_time,required"` + // An ISO 8601 timestamp that marks the start of the event. At this time, queued + // users will be processed with the event's configuration. The start time must be + // at least one minute before `event_end_time`. + EventStartTime param.Field[string] `json:"event_start_time,required"` + // A unique name to identify the event. Only alphanumeric characters, hyphens and + // underscores are allowed. + Name param.Field[string] `json:"name,required"` + // If set, the event will override the waiting room's `custom_page_html` property + // while it is active. If null, the event will inherit it. + CustomPageHTML param.Field[string] `json:"custom_page_html"` + // A note that you can use to add more details about the event. + Description param.Field[string] `json:"description"` + // If set, the event will override the waiting room's `disable_session_renewal` + // property while it is active. If null, the event will inherit it. + DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` + // If set, the event will override the waiting room's `new_users_per_minute` + // property while it is active. If null, the event will inherit it. This can only + // be set if the event's `total_active_users` property is also set. + NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute"` + // An ISO 8601 timestamp that marks when to begin queueing all users before the + // event starts. The prequeue must start at least five minutes before + // `event_start_time`. + PrequeueStartTime param.Field[string] `json:"prequeue_start_time"` + // If set, the event will override the waiting room's `queueing_method` property + // while it is active. If null, the event will inherit it. + QueueingMethod param.Field[string] `json:"queueing_method"` + // If set, the event will override the waiting room's `session_duration` property + // while it is active. If null, the event will inherit it. + SessionDuration param.Field[int64] `json:"session_duration"` + // If enabled, users in the prequeue will be shuffled randomly at the + // `event_start_time`. Requires that `prequeue_start_time` is not null. This is + // useful for situations when many users will join the event prequeue at the same + // time and you want to shuffle them to ensure fairness. Naturally, it makes the + // most sense to enable this feature when the `queueing_method` during the event + // respects ordering such as **fifo**, or else the shuffling may be unnecessary. + ShuffleAtEventStart param.Field[bool] `json:"shuffle_at_event_start"` + // Suspends or allows an event. If set to `true`, the event is ignored and traffic + // will be handled based on the waiting room configuration. + Suspended param.Field[bool] `json:"suspended"` + // If set, the event will override the waiting room's `total_active_users` property + // while it is active. If null, the event will inherit it. This can only be set if + // the event's `new_users_per_minute` property is also set. + TotalActiveUsers param.Field[int64] `json:"total_active_users"` +} + +func (r EventNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type EventNewResponseEnvelope struct { + Result WaitingroomEventResult `json:"result,required"` + JSON eventNewResponseEnvelopeJSON `json:"-"` +} + +// eventNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [EventNewResponseEnvelope] +type eventNewResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EventNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r eventNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EventUpdateParams struct { + // An ISO 8601 timestamp that marks the end of the event. + EventEndTime param.Field[string] `json:"event_end_time,required"` + // An ISO 8601 timestamp that marks the start of the event. At this time, queued + // users will be processed with the event's configuration. The start time must be + // at least one minute before `event_end_time`. + EventStartTime param.Field[string] `json:"event_start_time,required"` + // A unique name to identify the event. Only alphanumeric characters, hyphens and + // underscores are allowed. + Name param.Field[string] `json:"name,required"` + // If set, the event will override the waiting room's `custom_page_html` property + // while it is active. If null, the event will inherit it. + CustomPageHTML param.Field[string] `json:"custom_page_html"` + // A note that you can use to add more details about the event. + Description param.Field[string] `json:"description"` + // If set, the event will override the waiting room's `disable_session_renewal` + // property while it is active. If null, the event will inherit it. + DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` + // If set, the event will override the waiting room's `new_users_per_minute` + // property while it is active. If null, the event will inherit it. This can only + // be set if the event's `total_active_users` property is also set. + NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute"` + // An ISO 8601 timestamp that marks when to begin queueing all users before the + // event starts. The prequeue must start at least five minutes before + // `event_start_time`. + PrequeueStartTime param.Field[string] `json:"prequeue_start_time"` + // If set, the event will override the waiting room's `queueing_method` property + // while it is active. If null, the event will inherit it. + QueueingMethod param.Field[string] `json:"queueing_method"` + // If set, the event will override the waiting room's `session_duration` property + // while it is active. If null, the event will inherit it. + SessionDuration param.Field[int64] `json:"session_duration"` + // If enabled, users in the prequeue will be shuffled randomly at the + // `event_start_time`. Requires that `prequeue_start_time` is not null. This is + // useful for situations when many users will join the event prequeue at the same + // time and you want to shuffle them to ensure fairness. Naturally, it makes the + // most sense to enable this feature when the `queueing_method` during the event + // respects ordering such as **fifo**, or else the shuffling may be unnecessary. + ShuffleAtEventStart param.Field[bool] `json:"shuffle_at_event_start"` + // Suspends or allows an event. If set to `true`, the event is ignored and traffic + // will be handled based on the waiting room configuration. + Suspended param.Field[bool] `json:"suspended"` + // If set, the event will override the waiting room's `total_active_users` property + // while it is active. If null, the event will inherit it. This can only be set if + // the event's `new_users_per_minute` property is also set. + TotalActiveUsers param.Field[int64] `json:"total_active_users"` +} + +func (r EventUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type EventUpdateResponseEnvelope struct { + Result WaitingroomEventResult `json:"result,required"` + JSON eventUpdateResponseEnvelopeJSON `json:"-"` +} + +// eventUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [EventUpdateResponseEnvelope] +type eventUpdateResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EventUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r eventUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EventListResponseEnvelope struct { + Errors []EventListResponseEnvelopeErrors `json:"errors,required"` + Messages []EventListResponseEnvelopeMessages `json:"messages,required"` + Result []WaitingroomEventResult `json:"result,required,nullable"` + // Whether the API call was successful + Success EventListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo EventListResponseEnvelopeResultInfo `json:"result_info"` + JSON eventListResponseEnvelopeJSON `json:"-"` +} + +// eventListResponseEnvelopeJSON contains the JSON metadata for the struct +// [EventListResponseEnvelope] +type eventListResponseEnvelopeJSON 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 *EventListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r eventListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EventListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON eventListResponseEnvelopeErrorsJSON `json:"-"` +} + +// eventListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [EventListResponseEnvelopeErrors] +type eventListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EventListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r eventListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type EventListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON eventListResponseEnvelopeMessagesJSON `json:"-"` +} + +// eventListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [EventListResponseEnvelopeMessages] +type eventListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EventListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r eventListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type EventListResponseEnvelopeSuccess bool + +const ( + EventListResponseEnvelopeSuccessTrue EventListResponseEnvelopeSuccess = true +) + +type EventListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON eventListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// eventListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [EventListResponseEnvelopeResultInfo] +type eventListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EventListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r eventListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type EventDeleteResponseEnvelope struct { + Result EventDeleteResponse `json:"result,required"` + JSON eventDeleteResponseEnvelopeJSON `json:"-"` +} + +// eventDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [EventDeleteResponseEnvelope] +type eventDeleteResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EventDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r eventDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EventEditParams struct { + // An ISO 8601 timestamp that marks the end of the event. + EventEndTime param.Field[string] `json:"event_end_time,required"` + // An ISO 8601 timestamp that marks the start of the event. At this time, queued + // users will be processed with the event's configuration. The start time must be + // at least one minute before `event_end_time`. + EventStartTime param.Field[string] `json:"event_start_time,required"` + // A unique name to identify the event. Only alphanumeric characters, hyphens and + // underscores are allowed. + Name param.Field[string] `json:"name,required"` + // If set, the event will override the waiting room's `custom_page_html` property + // while it is active. If null, the event will inherit it. + CustomPageHTML param.Field[string] `json:"custom_page_html"` + // A note that you can use to add more details about the event. + Description param.Field[string] `json:"description"` + // If set, the event will override the waiting room's `disable_session_renewal` + // property while it is active. If null, the event will inherit it. + DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` + // If set, the event will override the waiting room's `new_users_per_minute` + // property while it is active. If null, the event will inherit it. This can only + // be set if the event's `total_active_users` property is also set. + NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute"` + // An ISO 8601 timestamp that marks when to begin queueing all users before the + // event starts. The prequeue must start at least five minutes before + // `event_start_time`. + PrequeueStartTime param.Field[string] `json:"prequeue_start_time"` + // If set, the event will override the waiting room's `queueing_method` property + // while it is active. If null, the event will inherit it. + QueueingMethod param.Field[string] `json:"queueing_method"` + // If set, the event will override the waiting room's `session_duration` property + // while it is active. If null, the event will inherit it. + SessionDuration param.Field[int64] `json:"session_duration"` + // If enabled, users in the prequeue will be shuffled randomly at the + // `event_start_time`. Requires that `prequeue_start_time` is not null. This is + // useful for situations when many users will join the event prequeue at the same + // time and you want to shuffle them to ensure fairness. Naturally, it makes the + // most sense to enable this feature when the `queueing_method` during the event + // respects ordering such as **fifo**, or else the shuffling may be unnecessary. + ShuffleAtEventStart param.Field[bool] `json:"shuffle_at_event_start"` + // Suspends or allows an event. If set to `true`, the event is ignored and traffic + // will be handled based on the waiting room configuration. + Suspended param.Field[bool] `json:"suspended"` + // If set, the event will override the waiting room's `total_active_users` property + // while it is active. If null, the event will inherit it. This can only be set if + // the event's `new_users_per_minute` property is also set. + TotalActiveUsers param.Field[int64] `json:"total_active_users"` +} + +func (r EventEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type EventEditResponseEnvelope struct { + Result WaitingroomEventResult `json:"result,required"` + JSON eventEditResponseEnvelopeJSON `json:"-"` +} + +// eventEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [EventEditResponseEnvelope] +type eventEditResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EventEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r eventEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type EventGetResponseEnvelope struct { + Result WaitingroomEventResult `json:"result,required"` + JSON eventGetResponseEnvelopeJSON `json:"-"` +} + +// eventGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [EventGetResponseEnvelope] +type eventGetResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EventGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r eventGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/waiting_rooms/event_test.go b/waiting_rooms/event_test.go new file mode 100644 index 00000000000..e1abc20aa90 --- /dev/null +++ b/waiting_rooms/event_test.go @@ -0,0 +1,232 @@ +// File generated from our OpenAPI spec by Stainless. + +package waiting_rooms_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/waiting_rooms" +) + +func TestEventNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.WaitingRooms.Events.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "699d98642c564d2e855e9661899b7252", + waiting_rooms.EventNewParams{ + EventEndTime: cloudflare.F("2021-09-28T17:00:00.000Z"), + EventStartTime: cloudflare.F("2021-09-28T15:30:00.000Z"), + Name: cloudflare.F("production_webinar_event"), + CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Event is prequeueing / Queue all enabled {{/waitTimeKnown}}"), + Description: cloudflare.F("Production event - DO NOT MODIFY"), + DisableSessionRenewal: cloudflare.F(true), + NewUsersPerMinute: cloudflare.F(int64(200)), + PrequeueStartTime: cloudflare.F("2021-09-28T15:00:00.000Z"), + QueueingMethod: cloudflare.F("random"), + SessionDuration: cloudflare.F(int64(1)), + ShuffleAtEventStart: cloudflare.F(true), + Suspended: cloudflare.F(true), + TotalActiveUsers: cloudflare.F(int64(200)), + }, + ) + 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 TestEventUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.WaitingRooms.Events.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "699d98642c564d2e855e9661899b7252", + "25756b2dfe6e378a06b033b670413757", + waiting_rooms.EventUpdateParams{ + EventEndTime: cloudflare.F("2021-09-28T17:00:00.000Z"), + EventStartTime: cloudflare.F("2021-09-28T15:30:00.000Z"), + Name: cloudflare.F("production_webinar_event"), + CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Event is prequeueing / Queue all enabled {{/waitTimeKnown}}"), + Description: cloudflare.F("Production event - DO NOT MODIFY"), + DisableSessionRenewal: cloudflare.F(true), + NewUsersPerMinute: cloudflare.F(int64(200)), + PrequeueStartTime: cloudflare.F("2021-09-28T15:00:00.000Z"), + QueueingMethod: cloudflare.F("random"), + SessionDuration: cloudflare.F(int64(1)), + ShuffleAtEventStart: cloudflare.F(true), + Suspended: cloudflare.F(true), + TotalActiveUsers: cloudflare.F(int64(200)), + }, + ) + 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 TestEventList(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("user@example.com"), + ) + _, err := client.WaitingRooms.Events.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "699d98642c564d2e855e9661899b7252", + ) + 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 TestEventDelete(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("user@example.com"), + ) + _, err := client.WaitingRooms.Events.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "699d98642c564d2e855e9661899b7252", + "25756b2dfe6e378a06b033b670413757", + ) + 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 TestEventEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.WaitingRooms.Events.Edit( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "699d98642c564d2e855e9661899b7252", + "25756b2dfe6e378a06b033b670413757", + waiting_rooms.EventEditParams{ + EventEndTime: cloudflare.F("2021-09-28T17:00:00.000Z"), + EventStartTime: cloudflare.F("2021-09-28T15:30:00.000Z"), + Name: cloudflare.F("production_webinar_event"), + CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Event is prequeueing / Queue all enabled {{/waitTimeKnown}}"), + Description: cloudflare.F("Production event - DO NOT MODIFY"), + DisableSessionRenewal: cloudflare.F(true), + NewUsersPerMinute: cloudflare.F(int64(200)), + PrequeueStartTime: cloudflare.F("2021-09-28T15:00:00.000Z"), + QueueingMethod: cloudflare.F("random"), + SessionDuration: cloudflare.F(int64(1)), + ShuffleAtEventStart: cloudflare.F(true), + Suspended: cloudflare.F(true), + TotalActiveUsers: cloudflare.F(int64(200)), + }, + ) + 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 TestEventGet(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("user@example.com"), + ) + _, err := client.WaitingRooms.Events.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "699d98642c564d2e855e9661899b7252", + "25756b2dfe6e378a06b033b670413757", + ) + 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/waiting_rooms/eventdetail.go b/waiting_rooms/eventdetail.go new file mode 100644 index 00000000000..b6ca6736eb2 --- /dev/null +++ b/waiting_rooms/eventdetail.go @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package waiting_rooms + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// EventDetailService 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 [NewEventDetailService] method +// instead. +type EventDetailService struct { + Options []option.RequestOption +} + +// NewEventDetailService 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 NewEventDetailService(opts ...option.RequestOption) (r *EventDetailService) { + r = &EventDetailService{} + r.Options = opts + return +} + +// Previews an event's configuration as if it was active. Inherited fields from the +// waiting room will be displayed with their current values. +func (r *EventDetailService) Get(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}, opts ...option.RequestOption) (res *WaitingroomEventDetailsResult, err error) { + opts = append(r.Options[:], opts...) + var env EventDetailGetResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/%v/events/%v/details", zoneIdentifier, waitingRoomID, eventID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type WaitingroomEventDetailsResult struct { + ID interface{} `json:"id"` + CreatedOn time.Time `json:"created_on" format:"date-time"` + CustomPageHTML string `json:"custom_page_html"` + // A note that you can use to add more details about the event. + Description string `json:"description"` + DisableSessionRenewal bool `json:"disable_session_renewal"` + // An ISO 8601 timestamp that marks the end of the event. + EventEndTime string `json:"event_end_time"` + // An ISO 8601 timestamp that marks the start of the event. At this time, queued + // users will be processed with the event's configuration. The start time must be + // at least one minute before `event_end_time`. + EventStartTime string `json:"event_start_time"` + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // A unique name to identify the event. Only alphanumeric characters, hyphens and + // underscores are allowed. + Name string `json:"name"` + NewUsersPerMinute int64 `json:"new_users_per_minute"` + // An ISO 8601 timestamp that marks when to begin queueing all users before the + // event starts. The prequeue must start at least five minutes before + // `event_start_time`. + PrequeueStartTime string `json:"prequeue_start_time,nullable"` + QueueingMethod string `json:"queueing_method"` + SessionDuration int64 `json:"session_duration"` + // If enabled, users in the prequeue will be shuffled randomly at the + // `event_start_time`. Requires that `prequeue_start_time` is not null. This is + // useful for situations when many users will join the event prequeue at the same + // time and you want to shuffle them to ensure fairness. Naturally, it makes the + // most sense to enable this feature when the `queueing_method` during the event + // respects ordering such as **fifo**, or else the shuffling may be unnecessary. + ShuffleAtEventStart bool `json:"shuffle_at_event_start"` + // Suspends or allows an event. If set to `true`, the event is ignored and traffic + // will be handled based on the waiting room configuration. + Suspended bool `json:"suspended"` + TotalActiveUsers int64 `json:"total_active_users"` + JSON waitingroomEventDetailsResultJSON `json:"-"` +} + +// waitingroomEventDetailsResultJSON contains the JSON metadata for the struct +// [WaitingroomEventDetailsResult] +type waitingroomEventDetailsResultJSON struct { + ID apijson.Field + CreatedOn apijson.Field + CustomPageHTML apijson.Field + Description apijson.Field + DisableSessionRenewal apijson.Field + EventEndTime apijson.Field + EventStartTime apijson.Field + ModifiedOn apijson.Field + Name apijson.Field + NewUsersPerMinute apijson.Field + PrequeueStartTime apijson.Field + QueueingMethod apijson.Field + SessionDuration apijson.Field + ShuffleAtEventStart apijson.Field + Suspended apijson.Field + TotalActiveUsers apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WaitingroomEventDetailsResult) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingroomEventDetailsResultJSON) RawJSON() string { + return r.raw +} + +type EventDetailGetResponseEnvelope struct { + Result WaitingroomEventDetailsResult `json:"result,required"` + JSON eventDetailGetResponseEnvelopeJSON `json:"-"` +} + +// eventDetailGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [EventDetailGetResponseEnvelope] +type eventDetailGetResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *EventDetailGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r eventDetailGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/waiting_rooms/eventdetail_test.go b/waiting_rooms/eventdetail_test.go new file mode 100644 index 00000000000..98d0dd53cae --- /dev/null +++ b/waiting_rooms/eventdetail_test.go @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package waiting_rooms_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestEventDetailGet(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("user@example.com"), + ) + _, err := client.WaitingRooms.Events.Details.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "699d98642c564d2e855e9661899b7252", + "25756b2dfe6e378a06b033b670413757", + ) + 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/waiting_rooms/rule.go b/waiting_rooms/rule.go new file mode 100644 index 00000000000..716da625e7a --- /dev/null +++ b/waiting_rooms/rule.go @@ -0,0 +1,814 @@ +// File generated from our OpenAPI spec by Stainless. + +package waiting_rooms + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-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 +} + +// 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 + return +} + +// Only available for the Waiting Room Advanced subscription. Creates a rule for a +// waiting room. +func (r *RuleService) New(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body RuleNewParams, opts ...option.RequestOption) (res *[]WaitingroomRuleResult, err error) { + opts = append(r.Options[:], opts...) + var env RuleNewResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/%v/rules", zoneIdentifier, waitingRoomID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Only available for the Waiting Room Advanced subscription. Replaces all rules +// for a waiting room. +func (r *RuleService) Update(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body RuleUpdateParams, opts ...option.RequestOption) (res *[]WaitingroomRuleResult, err error) { + opts = append(r.Options[:], opts...) + var env RuleUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/%v/rules", zoneIdentifier, waitingRoomID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists rules for a waiting room. +func (r *RuleService) List(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, opts ...option.RequestOption) (res *[]WaitingroomRuleResult, err error) { + opts = append(r.Options[:], opts...) + var env RuleListResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/%v/rules", zoneIdentifier, waitingRoomID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a rule for a waiting room. +func (r *RuleService) Delete(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, ruleID string, opts ...option.RequestOption) (res *[]WaitingroomRuleResult, err error) { + opts = append(r.Options[:], opts...) + var env RuleDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/%v/rules/%s", zoneIdentifier, waitingRoomID, ruleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Patches a rule for a waiting room. +func (r *RuleService) Edit(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, ruleID string, body RuleEditParams, opts ...option.RequestOption) (res *[]WaitingroomRuleResult, err error) { + opts = append(r.Options[:], opts...) + var env RuleEditResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/%v/rules/%s", zoneIdentifier, waitingRoomID, ruleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type WaitingroomRuleResult struct { + // The ID of the rule. + ID string `json:"id"` + // The action to take when the expression matches. + Action WaitingroomRuleResultAction `json:"action"` + // The description of the rule. + Description string `json:"description"` + // When set to true, the rule is enabled. + Enabled bool `json:"enabled"` + // Criteria defining when there is a match for the current rule. + Expression string `json:"expression"` + LastUpdated time.Time `json:"last_updated" format:"date-time"` + // The version of the rule. + Version string `json:"version"` + JSON waitingroomRuleResultJSON `json:"-"` +} + +// waitingroomRuleResultJSON contains the JSON metadata for the struct +// [WaitingroomRuleResult] +type waitingroomRuleResultJSON struct { + ID apijson.Field + Action apijson.Field + Description apijson.Field + Enabled apijson.Field + Expression apijson.Field + LastUpdated apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WaitingroomRuleResult) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingroomRuleResultJSON) RawJSON() string { + return r.raw +} + +// The action to take when the expression matches. +type WaitingroomRuleResultAction string + +const ( + WaitingroomRuleResultActionBypassWaitingRoom WaitingroomRuleResultAction = "bypass_waiting_room" +) + +type RuleNewParams struct { + // The action to take when the expression matches. + Action param.Field[RuleNewParamsAction] `json:"action,required"` + // Criteria defining when there is a match for the current rule. + Expression param.Field[string] `json:"expression,required"` + // The description of the rule. + Description param.Field[string] `json:"description"` + // When set to true, the rule is enabled. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r RuleNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The action to take when the expression matches. +type RuleNewParamsAction string + +const ( + RuleNewParamsActionBypassWaitingRoom RuleNewParamsAction = "bypass_waiting_room" +) + +type RuleNewResponseEnvelope struct { + Errors []RuleNewResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleNewResponseEnvelopeMessages `json:"messages,required"` + Result []WaitingroomRuleResult `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleNewResponseEnvelopeSuccess `json:"success,required"` + ResultInfo RuleNewResponseEnvelopeResultInfo `json:"result_info"` + JSON ruleNewResponseEnvelopeJSON `json:"-"` +} + +// ruleNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleNewResponseEnvelope] +type ruleNewResponseEnvelopeJSON 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 *RuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleNewResponseEnvelopeErrors] +type ruleNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleNewResponseEnvelopeMessages] +type ruleNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleNewResponseEnvelopeSuccess bool + +const ( + RuleNewResponseEnvelopeSuccessTrue RuleNewResponseEnvelopeSuccess = true +) + +type RuleNewResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON ruleNewResponseEnvelopeResultInfoJSON `json:"-"` +} + +// ruleNewResponseEnvelopeResultInfoJSON contains the JSON metadata for the struct +// [RuleNewResponseEnvelopeResultInfo] +type ruleNewResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleNewResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type RuleUpdateParams struct { + Body param.Field[[]RuleUpdateParamsBody] `json:"body,required"` +} + +func (r RuleUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type RuleUpdateParamsBody struct { + // The action to take when the expression matches. + Action param.Field[RuleUpdateParamsBodyAction] `json:"action,required"` + // Criteria defining when there is a match for the current rule. + Expression param.Field[string] `json:"expression,required"` + // The description of the rule. + Description param.Field[string] `json:"description"` + // When set to true, the rule is enabled. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r RuleUpdateParamsBody) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The action to take when the expression matches. +type RuleUpdateParamsBodyAction string + +const ( + RuleUpdateParamsBodyActionBypassWaitingRoom RuleUpdateParamsBodyAction = "bypass_waiting_room" +) + +type RuleUpdateResponseEnvelope struct { + Errors []RuleUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleUpdateResponseEnvelopeMessages `json:"messages,required"` + Result []WaitingroomRuleResult `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleUpdateResponseEnvelopeSuccess `json:"success,required"` + ResultInfo RuleUpdateResponseEnvelopeResultInfo `json:"result_info"` + JSON ruleUpdateResponseEnvelopeJSON `json:"-"` +} + +// ruleUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleUpdateResponseEnvelope] +type ruleUpdateResponseEnvelopeJSON 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 *RuleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleUpdateResponseEnvelopeErrors] +type ruleUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleUpdateResponseEnvelopeMessages] +type ruleUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleUpdateResponseEnvelopeSuccess bool + +const ( + RuleUpdateResponseEnvelopeSuccessTrue RuleUpdateResponseEnvelopeSuccess = true +) + +type RuleUpdateResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON ruleUpdateResponseEnvelopeResultInfoJSON `json:"-"` +} + +// ruleUpdateResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [RuleUpdateResponseEnvelopeResultInfo] +type ruleUpdateResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type RuleListResponseEnvelope struct { + Errors []RuleListResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleListResponseEnvelopeMessages `json:"messages,required"` + Result []WaitingroomRuleResult `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo RuleListResponseEnvelopeResultInfo `json:"result_info"` + JSON ruleListResponseEnvelopeJSON `json:"-"` +} + +// ruleListResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleListResponseEnvelope] +type ruleListResponseEnvelopeJSON 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 *RuleListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleListResponseEnvelopeErrors] +type ruleListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleListResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleListResponseEnvelopeMessages] +type ruleListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleListResponseEnvelopeSuccess bool + +const ( + RuleListResponseEnvelopeSuccessTrue RuleListResponseEnvelopeSuccess = true +) + +type RuleListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON ruleListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// ruleListResponseEnvelopeResultInfoJSON contains the JSON metadata for the struct +// [RuleListResponseEnvelopeResultInfo] +type ruleListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type RuleDeleteResponseEnvelope struct { + Errors []RuleDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleDeleteResponseEnvelopeMessages `json:"messages,required"` + Result []WaitingroomRuleResult `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleDeleteResponseEnvelopeSuccess `json:"success,required"` + ResultInfo RuleDeleteResponseEnvelopeResultInfo `json:"result_info"` + JSON ruleDeleteResponseEnvelopeJSON `json:"-"` +} + +// ruleDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleDeleteResponseEnvelope] +type ruleDeleteResponseEnvelopeJSON 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 *RuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleDeleteResponseEnvelopeErrors] +type ruleDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleDeleteResponseEnvelopeMessages] +type ruleDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleDeleteResponseEnvelopeSuccess bool + +const ( + RuleDeleteResponseEnvelopeSuccessTrue RuleDeleteResponseEnvelopeSuccess = true +) + +type RuleDeleteResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON ruleDeleteResponseEnvelopeResultInfoJSON `json:"-"` +} + +// ruleDeleteResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [RuleDeleteResponseEnvelopeResultInfo] +type ruleDeleteResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type RuleEditParams struct { + // The action to take when the expression matches. + Action param.Field[RuleEditParamsAction] `json:"action,required"` + // Criteria defining when there is a match for the current rule. + Expression param.Field[string] `json:"expression,required"` + // The description of the rule. + Description param.Field[string] `json:"description"` + // When set to true, the rule is enabled. + Enabled param.Field[bool] `json:"enabled"` + // Reorder the position of a rule + Position param.Field[RuleEditParamsPosition] `json:"position"` +} + +func (r RuleEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The action to take when the expression matches. +type RuleEditParamsAction string + +const ( + RuleEditParamsActionBypassWaitingRoom RuleEditParamsAction = "bypass_waiting_room" +) + +// Reorder the position of a rule +// +// Satisfied by [waiting_rooms.RuleEditParamsPositionObject], +// [waiting_rooms.RuleEditParamsPositionObject], +// [waiting_rooms.RuleEditParamsPositionObject]. +type RuleEditParamsPosition interface { + implementsWaitingRoomsRuleEditParamsPosition() +} + +type RuleEditParamsPositionObject struct { + // Places the rule in the exact position specified by the integer number + // . Position numbers start with 1. Existing rules in the ruleset + // from the specified position number onward are shifted one position (no rule is + // overwritten). + Index param.Field[int64] `json:"index"` +} + +func (r RuleEditParamsPositionObject) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r RuleEditParamsPositionObject) implementsWaitingRoomsRuleEditParamsPosition() {} + +type RuleEditResponseEnvelope struct { + Errors []RuleEditResponseEnvelopeErrors `json:"errors,required"` + Messages []RuleEditResponseEnvelopeMessages `json:"messages,required"` + Result []WaitingroomRuleResult `json:"result,required,nullable"` + // Whether the API call was successful + Success RuleEditResponseEnvelopeSuccess `json:"success,required"` + ResultInfo RuleEditResponseEnvelopeResultInfo `json:"result_info"` + JSON ruleEditResponseEnvelopeJSON `json:"-"` +} + +// ruleEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [RuleEditResponseEnvelope] +type ruleEditResponseEnvelopeJSON 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 *RuleEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RuleEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// ruleEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RuleEditResponseEnvelopeErrors] +type ruleEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RuleEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON ruleEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// ruleEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RuleEditResponseEnvelopeMessages] +type ruleEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RuleEditResponseEnvelopeSuccess bool + +const ( + RuleEditResponseEnvelopeSuccessTrue RuleEditResponseEnvelopeSuccess = true +) + +type RuleEditResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON ruleEditResponseEnvelopeResultInfoJSON `json:"-"` +} + +// ruleEditResponseEnvelopeResultInfoJSON contains the JSON metadata for the struct +// [RuleEditResponseEnvelopeResultInfo] +type ruleEditResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RuleEditResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r ruleEditResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/waiting_rooms/rule_test.go b/waiting_rooms/rule_test.go new file mode 100644 index 00000000000..62e4f4d94a1 --- /dev/null +++ b/waiting_rooms/rule_test.go @@ -0,0 +1,190 @@ +// File generated from our OpenAPI spec by Stainless. + +package waiting_rooms_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/waiting_rooms" +) + +func TestRuleNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.WaitingRooms.Rules.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "699d98642c564d2e855e9661899b7252", + waiting_rooms.RuleNewParams{ + Action: cloudflare.F(waiting_rooms.RuleNewParamsActionBypassWaitingRoom), + Expression: cloudflare.F("ip.src in {10.20.30.40}"), + Description: cloudflare.F("allow all traffic from 10.20.30.40"), + Enabled: cloudflare.F(true), + }, + ) + 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 TestRuleUpdate(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("user@example.com"), + ) + _, err := client.WaitingRooms.Rules.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "699d98642c564d2e855e9661899b7252", + waiting_rooms.RuleUpdateParams{ + Body: cloudflare.F([]waiting_rooms.RuleUpdateParamsBody{{ + Action: cloudflare.F(waiting_rooms.RuleUpdateParamsBodyActionBypassWaitingRoom), + Description: cloudflare.F("allow all traffic from 10.20.30.40"), + Enabled: cloudflare.F(true), + Expression: cloudflare.F("ip.src in {10.20.30.40}"), + }, { + Action: cloudflare.F(waiting_rooms.RuleUpdateParamsBodyActionBypassWaitingRoom), + Description: cloudflare.F("allow all traffic from 10.20.30.40"), + Enabled: cloudflare.F(true), + Expression: cloudflare.F("ip.src in {10.20.30.40}"), + }, { + Action: cloudflare.F(waiting_rooms.RuleUpdateParamsBodyActionBypassWaitingRoom), + Description: cloudflare.F("allow all traffic from 10.20.30.40"), + Enabled: cloudflare.F(true), + Expression: cloudflare.F("ip.src in {10.20.30.40}"), + }}), + }, + ) + 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 TestRuleList(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("user@example.com"), + ) + _, err := client.WaitingRooms.Rules.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "699d98642c564d2e855e9661899b7252", + ) + 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 TestRuleDelete(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("user@example.com"), + ) + _, err := client.WaitingRooms.Rules.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "699d98642c564d2e855e9661899b7252", + "25756b2dfe6e378a06b033b670413757", + ) + 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 TestRuleEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.WaitingRooms.Rules.Edit( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "699d98642c564d2e855e9661899b7252", + "25756b2dfe6e378a06b033b670413757", + waiting_rooms.RuleEditParams{ + Action: cloudflare.F(waiting_rooms.RuleEditParamsActionBypassWaitingRoom), + Expression: cloudflare.F("ip.src in {10.20.30.40}"), + Description: cloudflare.F("allow all traffic from 10.20.30.40"), + Enabled: cloudflare.F(true), + Position: cloudflare.F[waiting_rooms.RuleEditParamsPosition](waiting_rooms.RuleEditParamsPositionObject(waiting_rooms.RuleEditParamsPositionObject{ + Index: cloudflare.F(int64(0)), + })), + }, + ) + 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/waiting_rooms/setting.go b/waiting_rooms/setting.go new file mode 100644 index 00000000000..240f5eab420 --- /dev/null +++ b/waiting_rooms/setting.go @@ -0,0 +1,227 @@ +// File generated from our OpenAPI spec by Stainless. + +package waiting_rooms + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingService 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 [NewSettingService] method instead. +type SettingService struct { + Options []option.RequestOption +} + +// NewSettingService 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 NewSettingService(opts ...option.RequestOption) (r *SettingService) { + r = &SettingService{} + r.Options = opts + return +} + +// Update zone-level Waiting Room settings +func (r *SettingService) Update(ctx context.Context, zoneIdentifier string, body SettingUpdateParams, opts ...option.RequestOption) (res *SettingUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env SettingUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/settings", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Patch zone-level Waiting Room settings +func (r *SettingService) Edit(ctx context.Context, zoneIdentifier string, body SettingEditParams, opts ...option.RequestOption) (res *SettingEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env SettingEditResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/settings", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get zone-level Waiting Room settings +func (r *SettingService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *SettingGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env SettingGetResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/settings", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type SettingUpdateResponse struct { + // Whether to allow verified search engine crawlers to bypass all waiting rooms on + // this zone. Verified search engine crawlers will not be tracked or counted by the + // waiting room system, and will not appear in waiting room analytics. + SearchEngineCrawlerBypass bool `json:"search_engine_crawler_bypass,required"` + JSON settingUpdateResponseJSON `json:"-"` +} + +// settingUpdateResponseJSON contains the JSON metadata for the struct +// [SettingUpdateResponse] +type settingUpdateResponseJSON struct { + SearchEngineCrawlerBypass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingUpdateResponseJSON) RawJSON() string { + return r.raw +} + +type SettingEditResponse struct { + // Whether to allow verified search engine crawlers to bypass all waiting rooms on + // this zone. Verified search engine crawlers will not be tracked or counted by the + // waiting room system, and will not appear in waiting room analytics. + SearchEngineCrawlerBypass bool `json:"search_engine_crawler_bypass,required"` + JSON settingEditResponseJSON `json:"-"` +} + +// settingEditResponseJSON contains the JSON metadata for the struct +// [SettingEditResponse] +type settingEditResponseJSON struct { + SearchEngineCrawlerBypass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEditResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEditResponseJSON) RawJSON() string { + return r.raw +} + +type SettingGetResponse struct { + // Whether to allow verified search engine crawlers to bypass all waiting rooms on + // this zone. Verified search engine crawlers will not be tracked or counted by the + // waiting room system, and will not appear in waiting room analytics. + SearchEngineCrawlerBypass bool `json:"search_engine_crawler_bypass,required"` + JSON settingGetResponseJSON `json:"-"` +} + +// settingGetResponseJSON contains the JSON metadata for the struct +// [SettingGetResponse] +type settingGetResponseJSON struct { + SearchEngineCrawlerBypass apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingGetResponseJSON) RawJSON() string { + return r.raw +} + +type SettingUpdateParams struct { + // Whether to allow verified search engine crawlers to bypass all waiting rooms on + // this zone. Verified search engine crawlers will not be tracked or counted by the + // waiting room system, and will not appear in waiting room analytics. + SearchEngineCrawlerBypass param.Field[bool] `json:"search_engine_crawler_bypass"` +} + +func (r SettingUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingUpdateResponseEnvelope struct { + Result SettingUpdateResponse `json:"result,required"` + JSON settingUpdateResponseEnvelopeJSON `json:"-"` +} + +// settingUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingUpdateResponseEnvelope] +type settingUpdateResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingEditParams struct { + // Whether to allow verified search engine crawlers to bypass all waiting rooms on + // this zone. Verified search engine crawlers will not be tracked or counted by the + // waiting room system, and will not appear in waiting room analytics. + SearchEngineCrawlerBypass param.Field[bool] `json:"search_engine_crawler_bypass"` +} + +func (r SettingEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingEditResponseEnvelope struct { + Result SettingEditResponse `json:"result,required"` + JSON settingEditResponseEnvelopeJSON `json:"-"` +} + +// settingEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingEditResponseEnvelope] +type settingEditResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingGetResponseEnvelope struct { + Result SettingGetResponse `json:"result,required"` + JSON settingGetResponseEnvelopeJSON `json:"-"` +} + +// settingGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingGetResponseEnvelope] +type settingGetResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/waiting_rooms/setting_test.go b/waiting_rooms/setting_test.go new file mode 100644 index 00000000000..7c2b416bd92 --- /dev/null +++ b/waiting_rooms/setting_test.go @@ -0,0 +1,99 @@ +// File generated from our OpenAPI spec by Stainless. + +package waiting_rooms_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/waiting_rooms" +) + +func TestSettingUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.WaitingRooms.Settings.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + waiting_rooms.SettingUpdateParams{ + SearchEngineCrawlerBypass: cloudflare.F(true), + }, + ) + 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 TestSettingEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.WaitingRooms.Settings.Edit( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + waiting_rooms.SettingEditParams{ + SearchEngineCrawlerBypass: cloudflare.F(true), + }, + ) + 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 TestSettingGet(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("user@example.com"), + ) + _, err := client.WaitingRooms.Settings.Get(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/waiting_rooms/status.go b/waiting_rooms/status.go new file mode 100644 index 00000000000..da4a72e8afd --- /dev/null +++ b/waiting_rooms/status.go @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package waiting_rooms + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// StatusService 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 [NewStatusService] method instead. +type StatusService struct { + Options []option.RequestOption +} + +// NewStatusService 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 NewStatusService(opts ...option.RequestOption) (r *StatusService) { + r = &StatusService{} + r.Options = opts + return +} + +// Fetches the status of a configured waiting room. Response fields include: +// +// 1. `status`: String indicating the status of the waiting room. The possible +// status are: +// - **not_queueing** indicates that the configured thresholds have not been met +// and all users are going through to the origin. +// - **queueing** indicates that the thresholds have been met and some users are +// held in the waiting room. +// - **event_prequeueing** indicates that an event is active and is currently +// prequeueing users before it starts. +// 2. `event_id`: String of the current event's `id` if an event is active, +// otherwise an empty string. +// 3. `estimated_queued_users`: Integer of the estimated number of users currently +// waiting in the queue. +// 4. `estimated_total_active_users`: Integer of the estimated number of users +// currently active on the origin. +// 5. `max_estimated_time_minutes`: Integer of the maximum estimated time currently +// presented to the users. +func (r *StatusService) Get(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, opts ...option.RequestOption) (res *StatusGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env StatusGetResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/%v/status", zoneIdentifier, waitingRoomID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type StatusGetResponse struct { + EstimatedQueuedUsers int64 `json:"estimated_queued_users"` + EstimatedTotalActiveUsers int64 `json:"estimated_total_active_users"` + EventID string `json:"event_id"` + MaxEstimatedTimeMinutes int64 `json:"max_estimated_time_minutes"` + Status StatusGetResponseStatus `json:"status"` + JSON statusGetResponseJSON `json:"-"` +} + +// statusGetResponseJSON contains the JSON metadata for the struct +// [StatusGetResponse] +type statusGetResponseJSON struct { + EstimatedQueuedUsers apijson.Field + EstimatedTotalActiveUsers apijson.Field + EventID apijson.Field + MaxEstimatedTimeMinutes apijson.Field + Status apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StatusGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r statusGetResponseJSON) RawJSON() string { + return r.raw +} + +type StatusGetResponseStatus string + +const ( + StatusGetResponseStatusEventPrequeueing StatusGetResponseStatus = "event_prequeueing" + StatusGetResponseStatusNotQueueing StatusGetResponseStatus = "not_queueing" + StatusGetResponseStatusQueueing StatusGetResponseStatus = "queueing" +) + +type StatusGetResponseEnvelope struct { + Result StatusGetResponse `json:"result,required"` + JSON statusGetResponseEnvelopeJSON `json:"-"` +} + +// statusGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [StatusGetResponseEnvelope] +type statusGetResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *StatusGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r statusGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/waiting_rooms/status_test.go b/waiting_rooms/status_test.go new file mode 100644 index 00000000000..8f64513f8c0 --- /dev/null +++ b/waiting_rooms/status_test.go @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package waiting_rooms_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestStatusGet(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("user@example.com"), + ) + _, err := client.WaitingRooms.Statuses.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "699d98642c564d2e855e9661899b7252", + ) + 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/waiting_rooms/waitingroom.go b/waiting_rooms/waitingroom.go new file mode 100644 index 00000000000..b1fec185dff --- /dev/null +++ b/waiting_rooms/waitingroom.go @@ -0,0 +1,2117 @@ +// File generated from our OpenAPI spec by Stainless. + +package waiting_rooms + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// WaitingRoomService 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 [NewWaitingRoomService] method +// instead. +type WaitingRoomService struct { + Options []option.RequestOption + Events *EventService + Rules *RuleService + Statuses *StatusService + Settings *SettingService +} + +// NewWaitingRoomService 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 NewWaitingRoomService(opts ...option.RequestOption) (r *WaitingRoomService) { + r = &WaitingRoomService{} + r.Options = opts + r.Events = NewEventService(opts...) + r.Rules = NewRuleService(opts...) + r.Statuses = NewStatusService(opts...) + r.Settings = NewSettingService(opts...) + return +} + +// Creates a new waiting room. +func (r *WaitingRoomService) New(ctx context.Context, zoneIdentifier string, body WaitingRoomNewParams, opts ...option.RequestOption) (res *WaitingroomWaitingroom, err error) { + opts = append(r.Options[:], opts...) + var env WaitingRoomNewResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a configured waiting room. +func (r *WaitingRoomService) Update(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body WaitingRoomUpdateParams, opts ...option.RequestOption) (res *WaitingroomWaitingroom, err error) { + opts = append(r.Options[:], opts...) + var env WaitingRoomUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/%v", zoneIdentifier, waitingRoomID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists waiting rooms. +func (r *WaitingRoomService) List(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *[]WaitingroomWaitingroom, err error) { + opts = append(r.Options[:], opts...) + var env WaitingRoomListResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a waiting room. +func (r *WaitingRoomService) Delete(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, opts ...option.RequestOption) (res *WaitingRoomDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env WaitingRoomDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/%v", zoneIdentifier, waitingRoomID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Patches a configured waiting room. +func (r *WaitingRoomService) Edit(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body WaitingRoomEditParams, opts ...option.RequestOption) (res *WaitingroomWaitingroom, err error) { + opts = append(r.Options[:], opts...) + var env WaitingRoomEditResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/%v", zoneIdentifier, waitingRoomID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a single configured waiting room. +func (r *WaitingRoomService) Get(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, opts ...option.RequestOption) (res *WaitingroomWaitingroom, err error) { + opts = append(r.Options[:], opts...) + var env WaitingRoomGetResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/%v", zoneIdentifier, waitingRoomID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Creates a waiting room page preview. Upload a custom waiting room page for +// preview. You will receive a preview URL in the form +// `http://waitingrooms.dev/preview/`. You can use the following query +// parameters to change the state of the preview: +// +// 1. `force_queue`: Boolean indicating if all users will be queued in the waiting +// room and no one will be let into the origin website (also known as queueAll). +// 2. `queue_is_full`: Boolean indicating if the waiting room's queue is currently +// full and not accepting new users at the moment. +// 3. `queueing_method`: The queueing method currently used by the waiting room. +// - **fifo** indicates a FIFO queue. +// - **random** indicates a Random queue. +// - **passthrough** indicates a Passthrough queue. Keep in mind that the +// waiting room page will only be displayed if `force_queue=true` or +// `event=prequeueing` — for other cases the request will pass through to the +// origin. For our preview, this will be a fake origin website returning +// "Welcome". +// - **reject** indicates a Reject queue. +// 4. `event`: Used to preview a waiting room event. +// - **none** indicates no event is occurring. +// - **prequeueing** indicates that an event is prequeueing (between +// `prequeue_start_time` and `event_start_time`). +// - **started** indicates that an event has started (between `event_start_time` +// and `event_end_time`). +// 5. `shuffle_at_event_start`: Boolean indicating if the event will shuffle users +// in the prequeue when it starts. This can only be set to **true** if an event +// is active (`event` is not **none**). +// +// For example, you can make a request to +// `http://waitingrooms.dev/preview/?force_queue=false&queue_is_full=false&queueing_method=random&event=started&shuffle_at_event_start=true` 6. +// `waitTime`: Non-zero, positive integer indicating the estimated wait time in +// minutes. The default value is 10 minutes. +// +// For example, you can make a request to +// `http://waitingrooms.dev/preview/?waitTime=50` to configure the estimated +// wait time as 50 minutes. +func (r *WaitingRoomService) Preview(ctx context.Context, zoneIdentifier string, body WaitingRoomPreviewParams, opts ...option.RequestOption) (res *WaitingRoomPreviewResponse, err error) { + opts = append(r.Options[:], opts...) + var env WaitingRoomPreviewResponseEnvelope + path := fmt.Sprintf("zones/%s/waiting_rooms/preview", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type WaitingroomWaitingroom struct { + ID interface{} `json:"id"` + // Only available for the Waiting Room Advanced subscription. Additional hostname + // and path combinations to which this waiting room will be applied. There is an + // implied wildcard at the end of the path. The hostname and path combination must + // be unique to this and all other waiting rooms. + AdditionalRoutes []WaitingroomWaitingroomAdditionalRoute `json:"additional_routes"` + // Configures cookie attributes for the waiting room cookie. This encrypted cookie + // stores a user's status in the waiting room, such as queue position. + CookieAttributes WaitingroomWaitingroomCookieAttributes `json:"cookie_attributes"` + // Appends a '\_' + a custom suffix to the end of Cloudflare Waiting Room's cookie + // name(**cf_waitingroom). If `cookie_suffix` is "abcd", the cookie name will be + // `**cf_waitingroom_abcd`. This field is required if using `additional_routes`. + CookieSuffix string `json:"cookie_suffix"` + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Only available for the Waiting Room Advanced subscription. This is a template + // html file that will be rendered at the edge. If no custom_page_html is provided, + // the default waiting room will be used. The template is based on mustache ( + // https://mustache.github.io/ ). There are several variables that are evaluated by + // the Cloudflare edge: + // + // 1. {{`waitTimeKnown`}} Acts like a boolean value that indicates the behavior to + // take when wait time is not available, for instance when queue_all is + // **true**. + // 2. {{`waitTimeFormatted`}} Estimated wait time for the user. For example, five + // minutes. Alternatively, you can use: + // 3. {{`waitTime`}} Number of minutes of estimated wait for a user. + // 4. {{`waitTimeHours`}} Number of hours of estimated wait for a user + // (`Math.floor(waitTime/60)`). + // 5. {{`waitTimeHourMinutes`}} Number of minutes above the `waitTimeHours` value + // (`waitTime%60`). + // 6. {{`queueIsFull`}} Changes to **true** when no more people can be added to the + // queue. + // + // To view the full list of variables, look at the `cfWaitingRoom` object described + // under the `json_response_enabled` property in other Waiting Room API calls. + CustomPageHTML string `json:"custom_page_html"` + // The language of the default page template. If no default_template_language is + // provided, then `en-US` (English) will be used. + DefaultTemplateLanguage WaitingroomWaitingroomDefaultTemplateLanguage `json:"default_template_language"` + // A note that you can use to add more details about the waiting room. + Description string `json:"description"` + // Only available for the Waiting Room Advanced subscription. Disables automatic + // renewal of session cookies. If `true`, an accepted user will have + // session_duration minutes to browse the site. After that, they will have to go + // through the waiting room again. If `false`, a user's session cookie will be + // automatically renewed on every request. + DisableSessionRenewal bool `json:"disable_session_renewal"` + // The host name to which the waiting room will be applied (no wildcards). Please + // do not include the scheme (http:// or https://). The host and path combination + // must be unique. + Host string `json:"host"` + // Only available for the Waiting Room Advanced subscription. If `true`, requests + // to the waiting room with the header `Accept: application/json` will receive a + // JSON response object with information on the user's status in the waiting room + // as opposed to the configured static HTML page. This JSON response object has one + // property `cfWaitingRoom` which is an object containing the following fields: + // + // 1. `inWaitingRoom`: Boolean indicating if the user is in the waiting room + // (always **true**). + // 2. `waitTimeKnown`: Boolean indicating if the current estimated wait times are + // accurate. If **false**, they are not available. + // 3. `waitTime`: Valid only when `waitTimeKnown` is **true**. Integer indicating + // the current estimated time in minutes the user will wait in the waiting room. + // When `queueingMethod` is **random**, this is set to `waitTime50Percentile`. + // 4. `waitTime25Percentile`: Valid only when `queueingMethod` is **random** and + // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum + // wait time for the 25% of users that gain entry the fastest (25th percentile). + // 5. `waitTime50Percentile`: Valid only when `queueingMethod` is **random** and + // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum + // wait time for the 50% of users that gain entry the fastest (50th percentile). + // In other words, half of the queued users are expected to let into the origin + // website before `waitTime50Percentile` and half are expected to be let in + // after it. + // 6. `waitTime75Percentile`: Valid only when `queueingMethod` is **random** and + // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum + // wait time for the 75% of users that gain entry the fastest (75th percentile). + // 7. `waitTimeFormatted`: String displaying the `waitTime` formatted in English + // for users. If `waitTimeKnown` is **false**, `waitTimeFormatted` will display + // **unavailable**. + // 8. `queueIsFull`: Boolean indicating if the waiting room's queue is currently + // full and not accepting new users at the moment. + // 9. `queueAll`: Boolean indicating if all users will be queued in the waiting + // room and no one will be let into the origin website. + // 10. `lastUpdated`: String displaying the timestamp as an ISO 8601 string of the + // user's last attempt to leave the waiting room and be let into the origin + // website. The user is able to make another attempt after + // `refreshIntervalSeconds` past this time. If the user makes a request too + // soon, it will be ignored and `lastUpdated` will not change. + // 11. `refreshIntervalSeconds`: Integer indicating the number of seconds after + // `lastUpdated` until the user is able to make another attempt to leave the + // waiting room and be let into the origin website. When the `queueingMethod` + // is `reject`, there is no specified refresh time — it will always be + // **zero**. + // 12. `queueingMethod`: The queueing method currently used by the waiting room. It + // is either **fifo**, **random**, **passthrough**, or **reject**. + // 13. `isFIFOQueue`: Boolean indicating if the waiting room uses a FIFO + // (First-In-First-Out) queue. + // 14. `isRandomQueue`: Boolean indicating if the waiting room uses a Random queue + // where users gain access randomly. + // 15. `isPassthroughQueue`: Boolean indicating if the waiting room uses a + // passthrough queue. Keep in mind that when passthrough is enabled, this JSON + // response will only exist when `queueAll` is **true** or `isEventPrequeueing` + // is **true** because in all other cases requests will go directly to the + // origin. + // 16. `isRejectQueue`: Boolean indicating if the waiting room uses a reject queue. + // 17. `isEventActive`: Boolean indicating if an event is currently occurring. + // Events are able to change a waiting room's behavior during a specified + // period of time. For additional information, look at the event properties + // `prequeue_start_time`, `event_start_time`, and `event_end_time` in the + // documentation for creating waiting room events. Events are considered active + // between these start and end times, as well as during the prequeueing period + // if it exists. + // 18. `isEventPrequeueing`: Valid only when `isEventActive` is **true**. Boolean + // indicating if an event is currently prequeueing users before it starts. + // 19. `timeUntilEventStart`: Valid only when `isEventPrequeueing` is **true**. + // Integer indicating the number of minutes until the event starts. + // 20. `timeUntilEventStartFormatted`: String displaying the `timeUntilEventStart` + // formatted in English for users. If `isEventPrequeueing` is **false**, + // `timeUntilEventStartFormatted` will display **unavailable**. + // 21. `timeUntilEventEnd`: Valid only when `isEventActive` is **true**. Integer + // indicating the number of minutes until the event ends. + // 22. `timeUntilEventEndFormatted`: String displaying the `timeUntilEventEnd` + // formatted in English for users. If `isEventActive` is **false**, + // `timeUntilEventEndFormatted` will display **unavailable**. + // 23. `shuffleAtEventStart`: Valid only when `isEventActive` is **true**. Boolean + // indicating if the users in the prequeue are shuffled randomly when the event + // starts. + // + // An example cURL to a waiting room could be: + // + // curl -X GET "https://example.com/waitingroom" \ + // -H "Accept: application/json" + // + // If `json_response_enabled` is **true** and the request hits the waiting room, an + // example JSON response when `queueingMethod` is **fifo** and no event is active + // could be: + // + // { + // "cfWaitingRoom": { + // "inWaitingRoom": true, + // "waitTimeKnown": true, + // "waitTime": 10, + // "waitTime25Percentile": 0, + // "waitTime50Percentile": 0, + // "waitTime75Percentile": 0, + // "waitTimeFormatted": "10 minutes", + // "queueIsFull": false, + // "queueAll": false, + // "lastUpdated": "2020-08-03T23:46:00.000Z", + // "refreshIntervalSeconds": 20, + // "queueingMethod": "fifo", + // "isFIFOQueue": true, + // "isRandomQueue": false, + // "isPassthroughQueue": false, + // "isRejectQueue": false, + // "isEventActive": false, + // "isEventPrequeueing": false, + // "timeUntilEventStart": 0, + // "timeUntilEventStartFormatted": "unavailable", + // "timeUntilEventEnd": 0, + // "timeUntilEventEndFormatted": "unavailable", + // "shuffleAtEventStart": false + // } + // } + // + // If `json_response_enabled` is **true** and the request hits the waiting room, an + // example JSON response when `queueingMethod` is **random** and an event is active + // could be: + // + // { + // "cfWaitingRoom": { + // "inWaitingRoom": true, + // "waitTimeKnown": true, + // "waitTime": 10, + // "waitTime25Percentile": 5, + // "waitTime50Percentile": 10, + // "waitTime75Percentile": 15, + // "waitTimeFormatted": "5 minutes to 15 minutes", + // "queueIsFull": false, + // "queueAll": false, + // "lastUpdated": "2020-08-03T23:46:00.000Z", + // "refreshIntervalSeconds": 20, + // "queueingMethod": "random", + // "isFIFOQueue": false, + // "isRandomQueue": true, + // "isPassthroughQueue": false, + // "isRejectQueue": false, + // "isEventActive": true, + // "isEventPrequeueing": false, + // "timeUntilEventStart": 0, + // "timeUntilEventStartFormatted": "unavailable", + // "timeUntilEventEnd": 15, + // "timeUntilEventEndFormatted": "15 minutes", + // "shuffleAtEventStart": true + // } + // }. + JsonResponseEnabled bool `json:"json_response_enabled"` + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // A unique name to identify the waiting room. Only alphanumeric characters, + // hyphens and underscores are allowed. + Name string `json:"name"` + // Sets the number of new users that will be let into the route every minute. This + // value is used as baseline for the number of users that are let in per minute. So + // it is possible that there is a little more or little less traffic coming to the + // route based on the traffic patterns at that time around the world. + NewUsersPerMinute int64 `json:"new_users_per_minute"` + // An ISO 8601 timestamp that marks when the next event will begin queueing. + NextEventPrequeueStartTime string `json:"next_event_prequeue_start_time,nullable"` + // An ISO 8601 timestamp that marks when the next event will start. + NextEventStartTime string `json:"next_event_start_time,nullable"` + // Sets the path within the host to enable the waiting room on. The waiting room + // will be enabled for all subpaths as well. If there are two waiting rooms on the + // same subpath, the waiting room for the most specific path will be chosen. + // Wildcards and query parameters are not supported. + Path string `json:"path"` + // If queue_all is `true`, all the traffic that is coming to a route will be sent + // to the waiting room. No new traffic can get to the route once this field is set + // and estimated time will become unavailable. + QueueAll bool `json:"queue_all"` + // Sets the queueing method used by the waiting room. Changing this parameter from + // the **default** queueing method is only available for the Waiting Room Advanced + // subscription. Regardless of the queueing method, if `queue_all` is enabled or an + // event is prequeueing, users in the waiting room will not be accepted to the + // origin. These users will always see a waiting room page that refreshes + // automatically. The valid queueing methods are: + // + // 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in + // the order they arrived. + // 2. `random`: Random queue where customers gain access randomly, regardless of + // arrival time. + // 3. `passthrough`: Users will pass directly through the waiting room and into the + // origin website. As a result, any configured limits will not be respected + // while this is enabled. This method can be used as an alternative to disabling + // a waiting room (with `suspended`) so that analytics are still reported. This + // can be used if you wish to allow all traffic normally, but want to restrict + // traffic during a waiting room event, or vice versa. + // 4. `reject`: Users will be immediately rejected from the waiting room. As a + // result, no users will reach the origin website while this is enabled. This + // can be used if you wish to reject all traffic while performing maintenance, + // block traffic during a specified period of time (an event), or block traffic + // while events are not occurring. Consider a waiting room used for vaccine + // distribution that only allows traffic during sign-up events, and otherwise + // blocks all traffic. For this case, the waiting room uses `reject`, and its + // events override this with `fifo`, `random`, or `passthrough`. When this + // queueing method is enabled and neither `queueAll` is enabled nor an event is + // prequeueing, the waiting room page **will not refresh automatically**. + QueueingMethod WaitingroomWaitingroomQueueingMethod `json:"queueing_method"` + // HTTP status code returned to a user while in the queue. + QueueingStatusCode WaitingroomWaitingroomQueueingStatusCode `json:"queueing_status_code"` + // Lifetime of a cookie (in minutes) set by Cloudflare for users who get access to + // the route. If a user is not seen by Cloudflare again in that time period, they + // will be treated as a new user that visits the route. + SessionDuration int64 `json:"session_duration"` + // Suspends or allows traffic going to the waiting room. If set to `true`, the + // traffic will not go to the waiting room. + Suspended bool `json:"suspended"` + // Sets the total number of active user sessions on the route at a point in time. A + // route is a combination of host and path on which a waiting room is available. + // This value is used as a baseline for the total number of active user sessions on + // the route. It is possible to have a situation where there are more or less + // active users sessions on the route based on the traffic patterns at that time + // around the world. + TotalActiveUsers int64 `json:"total_active_users"` + JSON waitingroomWaitingroomJSON `json:"-"` +} + +// waitingroomWaitingroomJSON contains the JSON metadata for the struct +// [WaitingroomWaitingroom] +type waitingroomWaitingroomJSON struct { + ID apijson.Field + AdditionalRoutes apijson.Field + CookieAttributes apijson.Field + CookieSuffix apijson.Field + CreatedOn apijson.Field + CustomPageHTML apijson.Field + DefaultTemplateLanguage apijson.Field + Description apijson.Field + DisableSessionRenewal apijson.Field + Host apijson.Field + JsonResponseEnabled apijson.Field + ModifiedOn apijson.Field + Name apijson.Field + NewUsersPerMinute apijson.Field + NextEventPrequeueStartTime apijson.Field + NextEventStartTime apijson.Field + Path apijson.Field + QueueAll apijson.Field + QueueingMethod apijson.Field + QueueingStatusCode apijson.Field + SessionDuration apijson.Field + Suspended apijson.Field + TotalActiveUsers apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WaitingroomWaitingroom) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingroomWaitingroomJSON) RawJSON() string { + return r.raw +} + +type WaitingroomWaitingroomAdditionalRoute struct { + // The hostname to which this waiting room will be applied (no wildcards). The + // hostname must be the primary domain, subdomain, or custom hostname (if using SSL + // for SaaS) of this zone. Please do not include the scheme (http:// or https://). + Host string `json:"host"` + // Sets the path within the host to enable the waiting room on. The waiting room + // will be enabled for all subpaths as well. If there are two waiting rooms on the + // same subpath, the waiting room for the most specific path will be chosen. + // Wildcards and query parameters are not supported. + Path string `json:"path"` + JSON waitingroomWaitingroomAdditionalRouteJSON `json:"-"` +} + +// waitingroomWaitingroomAdditionalRouteJSON contains the JSON metadata for the +// struct [WaitingroomWaitingroomAdditionalRoute] +type waitingroomWaitingroomAdditionalRouteJSON struct { + Host apijson.Field + Path apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WaitingroomWaitingroomAdditionalRoute) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingroomWaitingroomAdditionalRouteJSON) RawJSON() string { + return r.raw +} + +// Configures cookie attributes for the waiting room cookie. This encrypted cookie +// stores a user's status in the waiting room, such as queue position. +type WaitingroomWaitingroomCookieAttributes struct { + // Configures the SameSite attribute on the waiting room cookie. Value `auto` will + // be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. + // Note that when using value `none`, the secure attribute cannot be set to + // `never`. + Samesite WaitingroomWaitingroomCookieAttributesSamesite `json:"samesite"` + // Configures the Secure attribute on the waiting room cookie. Value `always` + // indicates that the Secure attribute will be set in the Set-Cookie header, + // `never` indicates that the Secure attribute will not be set, and `auto` will set + // the Secure attribute depending if **Always Use HTTPS** is enabled. + Secure WaitingroomWaitingroomCookieAttributesSecure `json:"secure"` + JSON waitingroomWaitingroomCookieAttributesJSON `json:"-"` +} + +// waitingroomWaitingroomCookieAttributesJSON contains the JSON metadata for the +// struct [WaitingroomWaitingroomCookieAttributes] +type waitingroomWaitingroomCookieAttributesJSON struct { + Samesite apijson.Field + Secure apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WaitingroomWaitingroomCookieAttributes) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingroomWaitingroomCookieAttributesJSON) RawJSON() string { + return r.raw +} + +// Configures the SameSite attribute on the waiting room cookie. Value `auto` will +// be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. +// Note that when using value `none`, the secure attribute cannot be set to +// `never`. +type WaitingroomWaitingroomCookieAttributesSamesite string + +const ( + WaitingroomWaitingroomCookieAttributesSamesiteAuto WaitingroomWaitingroomCookieAttributesSamesite = "auto" + WaitingroomWaitingroomCookieAttributesSamesiteLax WaitingroomWaitingroomCookieAttributesSamesite = "lax" + WaitingroomWaitingroomCookieAttributesSamesiteNone WaitingroomWaitingroomCookieAttributesSamesite = "none" + WaitingroomWaitingroomCookieAttributesSamesiteStrict WaitingroomWaitingroomCookieAttributesSamesite = "strict" +) + +// Configures the Secure attribute on the waiting room cookie. Value `always` +// indicates that the Secure attribute will be set in the Set-Cookie header, +// `never` indicates that the Secure attribute will not be set, and `auto` will set +// the Secure attribute depending if **Always Use HTTPS** is enabled. +type WaitingroomWaitingroomCookieAttributesSecure string + +const ( + WaitingroomWaitingroomCookieAttributesSecureAuto WaitingroomWaitingroomCookieAttributesSecure = "auto" + WaitingroomWaitingroomCookieAttributesSecureAlways WaitingroomWaitingroomCookieAttributesSecure = "always" + WaitingroomWaitingroomCookieAttributesSecureNever WaitingroomWaitingroomCookieAttributesSecure = "never" +) + +// The language of the default page template. If no default_template_language is +// provided, then `en-US` (English) will be used. +type WaitingroomWaitingroomDefaultTemplateLanguage string + +const ( + WaitingroomWaitingroomDefaultTemplateLanguageEnUs WaitingroomWaitingroomDefaultTemplateLanguage = "en-US" + WaitingroomWaitingroomDefaultTemplateLanguageEsEs WaitingroomWaitingroomDefaultTemplateLanguage = "es-ES" + WaitingroomWaitingroomDefaultTemplateLanguageDeDe WaitingroomWaitingroomDefaultTemplateLanguage = "de-DE" + WaitingroomWaitingroomDefaultTemplateLanguageFrFr WaitingroomWaitingroomDefaultTemplateLanguage = "fr-FR" + WaitingroomWaitingroomDefaultTemplateLanguageItIt WaitingroomWaitingroomDefaultTemplateLanguage = "it-IT" + WaitingroomWaitingroomDefaultTemplateLanguageJaJp WaitingroomWaitingroomDefaultTemplateLanguage = "ja-JP" + WaitingroomWaitingroomDefaultTemplateLanguageKoKr WaitingroomWaitingroomDefaultTemplateLanguage = "ko-KR" + WaitingroomWaitingroomDefaultTemplateLanguagePtBr WaitingroomWaitingroomDefaultTemplateLanguage = "pt-BR" + WaitingroomWaitingroomDefaultTemplateLanguageZhCn WaitingroomWaitingroomDefaultTemplateLanguage = "zh-CN" + WaitingroomWaitingroomDefaultTemplateLanguageZhTw WaitingroomWaitingroomDefaultTemplateLanguage = "zh-TW" + WaitingroomWaitingroomDefaultTemplateLanguageNlNl WaitingroomWaitingroomDefaultTemplateLanguage = "nl-NL" + WaitingroomWaitingroomDefaultTemplateLanguagePlPl WaitingroomWaitingroomDefaultTemplateLanguage = "pl-PL" + WaitingroomWaitingroomDefaultTemplateLanguageIDID WaitingroomWaitingroomDefaultTemplateLanguage = "id-ID" + WaitingroomWaitingroomDefaultTemplateLanguageTrTr WaitingroomWaitingroomDefaultTemplateLanguage = "tr-TR" + WaitingroomWaitingroomDefaultTemplateLanguageArEg WaitingroomWaitingroomDefaultTemplateLanguage = "ar-EG" + WaitingroomWaitingroomDefaultTemplateLanguageRuRu WaitingroomWaitingroomDefaultTemplateLanguage = "ru-RU" + WaitingroomWaitingroomDefaultTemplateLanguageFaIr WaitingroomWaitingroomDefaultTemplateLanguage = "fa-IR" +) + +// Sets the queueing method used by the waiting room. Changing this parameter from +// the **default** queueing method is only available for the Waiting Room Advanced +// subscription. Regardless of the queueing method, if `queue_all` is enabled or an +// event is prequeueing, users in the waiting room will not be accepted to the +// origin. These users will always see a waiting room page that refreshes +// automatically. The valid queueing methods are: +// +// 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in +// the order they arrived. +// 2. `random`: Random queue where customers gain access randomly, regardless of +// arrival time. +// 3. `passthrough`: Users will pass directly through the waiting room and into the +// origin website. As a result, any configured limits will not be respected +// while this is enabled. This method can be used as an alternative to disabling +// a waiting room (with `suspended`) so that analytics are still reported. This +// can be used if you wish to allow all traffic normally, but want to restrict +// traffic during a waiting room event, or vice versa. +// 4. `reject`: Users will be immediately rejected from the waiting room. As a +// result, no users will reach the origin website while this is enabled. This +// can be used if you wish to reject all traffic while performing maintenance, +// block traffic during a specified period of time (an event), or block traffic +// while events are not occurring. Consider a waiting room used for vaccine +// distribution that only allows traffic during sign-up events, and otherwise +// blocks all traffic. For this case, the waiting room uses `reject`, and its +// events override this with `fifo`, `random`, or `passthrough`. When this +// queueing method is enabled and neither `queueAll` is enabled nor an event is +// prequeueing, the waiting room page **will not refresh automatically**. +type WaitingroomWaitingroomQueueingMethod string + +const ( + WaitingroomWaitingroomQueueingMethodFifo WaitingroomWaitingroomQueueingMethod = "fifo" + WaitingroomWaitingroomQueueingMethodRandom WaitingroomWaitingroomQueueingMethod = "random" + WaitingroomWaitingroomQueueingMethodPassthrough WaitingroomWaitingroomQueueingMethod = "passthrough" + WaitingroomWaitingroomQueueingMethodReject WaitingroomWaitingroomQueueingMethod = "reject" +) + +// HTTP status code returned to a user while in the queue. +type WaitingroomWaitingroomQueueingStatusCode int64 + +const ( + WaitingroomWaitingroomQueueingStatusCode200 WaitingroomWaitingroomQueueingStatusCode = 200 + WaitingroomWaitingroomQueueingStatusCode202 WaitingroomWaitingroomQueueingStatusCode = 202 + WaitingroomWaitingroomQueueingStatusCode429 WaitingroomWaitingroomQueueingStatusCode = 429 +) + +type WaitingRoomDeleteResponse struct { + ID interface{} `json:"id"` + JSON waitingRoomDeleteResponseJSON `json:"-"` +} + +// waitingRoomDeleteResponseJSON contains the JSON metadata for the struct +// [WaitingRoomDeleteResponse] +type waitingRoomDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WaitingRoomDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingRoomDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type WaitingRoomPreviewResponse struct { + // URL where the custom waiting room page can temporarily be previewed. + PreviewURL string `json:"preview_url"` + JSON waitingRoomPreviewResponseJSON `json:"-"` +} + +// waitingRoomPreviewResponseJSON contains the JSON metadata for the struct +// [WaitingRoomPreviewResponse] +type waitingRoomPreviewResponseJSON struct { + PreviewURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WaitingRoomPreviewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingRoomPreviewResponseJSON) RawJSON() string { + return r.raw +} + +type WaitingRoomNewParams struct { + // The host name to which the waiting room will be applied (no wildcards). Please + // do not include the scheme (http:// or https://). The host and path combination + // must be unique. + Host param.Field[string] `json:"host,required"` + // A unique name to identify the waiting room. Only alphanumeric characters, + // hyphens and underscores are allowed. + Name param.Field[string] `json:"name,required"` + // Sets the number of new users that will be let into the route every minute. This + // value is used as baseline for the number of users that are let in per minute. So + // it is possible that there is a little more or little less traffic coming to the + // route based on the traffic patterns at that time around the world. + NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute,required"` + // Sets the total number of active user sessions on the route at a point in time. A + // route is a combination of host and path on which a waiting room is available. + // This value is used as a baseline for the total number of active user sessions on + // the route. It is possible to have a situation where there are more or less + // active users sessions on the route based on the traffic patterns at that time + // around the world. + TotalActiveUsers param.Field[int64] `json:"total_active_users,required"` + // Only available for the Waiting Room Advanced subscription. Additional hostname + // and path combinations to which this waiting room will be applied. There is an + // implied wildcard at the end of the path. The hostname and path combination must + // be unique to this and all other waiting rooms. + AdditionalRoutes param.Field[[]WaitingRoomNewParamsAdditionalRoute] `json:"additional_routes"` + // Configures cookie attributes for the waiting room cookie. This encrypted cookie + // stores a user's status in the waiting room, such as queue position. + CookieAttributes param.Field[WaitingRoomNewParamsCookieAttributes] `json:"cookie_attributes"` + // Appends a '\_' + a custom suffix to the end of Cloudflare Waiting Room's cookie + // name(**cf_waitingroom). If `cookie_suffix` is "abcd", the cookie name will be + // `**cf_waitingroom_abcd`. This field is required if using `additional_routes`. + CookieSuffix param.Field[string] `json:"cookie_suffix"` + // Only available for the Waiting Room Advanced subscription. This is a template + // html file that will be rendered at the edge. If no custom_page_html is provided, + // the default waiting room will be used. The template is based on mustache ( + // https://mustache.github.io/ ). There are several variables that are evaluated by + // the Cloudflare edge: + // + // 1. {{`waitTimeKnown`}} Acts like a boolean value that indicates the behavior to + // take when wait time is not available, for instance when queue_all is + // **true**. + // 2. {{`waitTimeFormatted`}} Estimated wait time for the user. For example, five + // minutes. Alternatively, you can use: + // 3. {{`waitTime`}} Number of minutes of estimated wait for a user. + // 4. {{`waitTimeHours`}} Number of hours of estimated wait for a user + // (`Math.floor(waitTime/60)`). + // 5. {{`waitTimeHourMinutes`}} Number of minutes above the `waitTimeHours` value + // (`waitTime%60`). + // 6. {{`queueIsFull`}} Changes to **true** when no more people can be added to the + // queue. + // + // To view the full list of variables, look at the `cfWaitingRoom` object described + // under the `json_response_enabled` property in other Waiting Room API calls. + CustomPageHTML param.Field[string] `json:"custom_page_html"` + // The language of the default page template. If no default_template_language is + // provided, then `en-US` (English) will be used. + DefaultTemplateLanguage param.Field[WaitingRoomNewParamsDefaultTemplateLanguage] `json:"default_template_language"` + // A note that you can use to add more details about the waiting room. + Description param.Field[string] `json:"description"` + // Only available for the Waiting Room Advanced subscription. Disables automatic + // renewal of session cookies. If `true`, an accepted user will have + // session_duration minutes to browse the site. After that, they will have to go + // through the waiting room again. If `false`, a user's session cookie will be + // automatically renewed on every request. + DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` + // Only available for the Waiting Room Advanced subscription. If `true`, requests + // to the waiting room with the header `Accept: application/json` will receive a + // JSON response object with information on the user's status in the waiting room + // as opposed to the configured static HTML page. This JSON response object has one + // property `cfWaitingRoom` which is an object containing the following fields: + // + // 1. `inWaitingRoom`: Boolean indicating if the user is in the waiting room + // (always **true**). + // 2. `waitTimeKnown`: Boolean indicating if the current estimated wait times are + // accurate. If **false**, they are not available. + // 3. `waitTime`: Valid only when `waitTimeKnown` is **true**. Integer indicating + // the current estimated time in minutes the user will wait in the waiting room. + // When `queueingMethod` is **random**, this is set to `waitTime50Percentile`. + // 4. `waitTime25Percentile`: Valid only when `queueingMethod` is **random** and + // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum + // wait time for the 25% of users that gain entry the fastest (25th percentile). + // 5. `waitTime50Percentile`: Valid only when `queueingMethod` is **random** and + // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum + // wait time for the 50% of users that gain entry the fastest (50th percentile). + // In other words, half of the queued users are expected to let into the origin + // website before `waitTime50Percentile` and half are expected to be let in + // after it. + // 6. `waitTime75Percentile`: Valid only when `queueingMethod` is **random** and + // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum + // wait time for the 75% of users that gain entry the fastest (75th percentile). + // 7. `waitTimeFormatted`: String displaying the `waitTime` formatted in English + // for users. If `waitTimeKnown` is **false**, `waitTimeFormatted` will display + // **unavailable**. + // 8. `queueIsFull`: Boolean indicating if the waiting room's queue is currently + // full and not accepting new users at the moment. + // 9. `queueAll`: Boolean indicating if all users will be queued in the waiting + // room and no one will be let into the origin website. + // 10. `lastUpdated`: String displaying the timestamp as an ISO 8601 string of the + // user's last attempt to leave the waiting room and be let into the origin + // website. The user is able to make another attempt after + // `refreshIntervalSeconds` past this time. If the user makes a request too + // soon, it will be ignored and `lastUpdated` will not change. + // 11. `refreshIntervalSeconds`: Integer indicating the number of seconds after + // `lastUpdated` until the user is able to make another attempt to leave the + // waiting room and be let into the origin website. When the `queueingMethod` + // is `reject`, there is no specified refresh time — it will always be + // **zero**. + // 12. `queueingMethod`: The queueing method currently used by the waiting room. It + // is either **fifo**, **random**, **passthrough**, or **reject**. + // 13. `isFIFOQueue`: Boolean indicating if the waiting room uses a FIFO + // (First-In-First-Out) queue. + // 14. `isRandomQueue`: Boolean indicating if the waiting room uses a Random queue + // where users gain access randomly. + // 15. `isPassthroughQueue`: Boolean indicating if the waiting room uses a + // passthrough queue. Keep in mind that when passthrough is enabled, this JSON + // response will only exist when `queueAll` is **true** or `isEventPrequeueing` + // is **true** because in all other cases requests will go directly to the + // origin. + // 16. `isRejectQueue`: Boolean indicating if the waiting room uses a reject queue. + // 17. `isEventActive`: Boolean indicating if an event is currently occurring. + // Events are able to change a waiting room's behavior during a specified + // period of time. For additional information, look at the event properties + // `prequeue_start_time`, `event_start_time`, and `event_end_time` in the + // documentation for creating waiting room events. Events are considered active + // between these start and end times, as well as during the prequeueing period + // if it exists. + // 18. `isEventPrequeueing`: Valid only when `isEventActive` is **true**. Boolean + // indicating if an event is currently prequeueing users before it starts. + // 19. `timeUntilEventStart`: Valid only when `isEventPrequeueing` is **true**. + // Integer indicating the number of minutes until the event starts. + // 20. `timeUntilEventStartFormatted`: String displaying the `timeUntilEventStart` + // formatted in English for users. If `isEventPrequeueing` is **false**, + // `timeUntilEventStartFormatted` will display **unavailable**. + // 21. `timeUntilEventEnd`: Valid only when `isEventActive` is **true**. Integer + // indicating the number of minutes until the event ends. + // 22. `timeUntilEventEndFormatted`: String displaying the `timeUntilEventEnd` + // formatted in English for users. If `isEventActive` is **false**, + // `timeUntilEventEndFormatted` will display **unavailable**. + // 23. `shuffleAtEventStart`: Valid only when `isEventActive` is **true**. Boolean + // indicating if the users in the prequeue are shuffled randomly when the event + // starts. + // + // An example cURL to a waiting room could be: + // + // curl -X GET "https://example.com/waitingroom" \ + // -H "Accept: application/json" + // + // If `json_response_enabled` is **true** and the request hits the waiting room, an + // example JSON response when `queueingMethod` is **fifo** and no event is active + // could be: + // + // { + // "cfWaitingRoom": { + // "inWaitingRoom": true, + // "waitTimeKnown": true, + // "waitTime": 10, + // "waitTime25Percentile": 0, + // "waitTime50Percentile": 0, + // "waitTime75Percentile": 0, + // "waitTimeFormatted": "10 minutes", + // "queueIsFull": false, + // "queueAll": false, + // "lastUpdated": "2020-08-03T23:46:00.000Z", + // "refreshIntervalSeconds": 20, + // "queueingMethod": "fifo", + // "isFIFOQueue": true, + // "isRandomQueue": false, + // "isPassthroughQueue": false, + // "isRejectQueue": false, + // "isEventActive": false, + // "isEventPrequeueing": false, + // "timeUntilEventStart": 0, + // "timeUntilEventStartFormatted": "unavailable", + // "timeUntilEventEnd": 0, + // "timeUntilEventEndFormatted": "unavailable", + // "shuffleAtEventStart": false + // } + // } + // + // If `json_response_enabled` is **true** and the request hits the waiting room, an + // example JSON response when `queueingMethod` is **random** and an event is active + // could be: + // + // { + // "cfWaitingRoom": { + // "inWaitingRoom": true, + // "waitTimeKnown": true, + // "waitTime": 10, + // "waitTime25Percentile": 5, + // "waitTime50Percentile": 10, + // "waitTime75Percentile": 15, + // "waitTimeFormatted": "5 minutes to 15 minutes", + // "queueIsFull": false, + // "queueAll": false, + // "lastUpdated": "2020-08-03T23:46:00.000Z", + // "refreshIntervalSeconds": 20, + // "queueingMethod": "random", + // "isFIFOQueue": false, + // "isRandomQueue": true, + // "isPassthroughQueue": false, + // "isRejectQueue": false, + // "isEventActive": true, + // "isEventPrequeueing": false, + // "timeUntilEventStart": 0, + // "timeUntilEventStartFormatted": "unavailable", + // "timeUntilEventEnd": 15, + // "timeUntilEventEndFormatted": "15 minutes", + // "shuffleAtEventStart": true + // } + // }. + JsonResponseEnabled param.Field[bool] `json:"json_response_enabled"` + // Sets the path within the host to enable the waiting room on. The waiting room + // will be enabled for all subpaths as well. If there are two waiting rooms on the + // same subpath, the waiting room for the most specific path will be chosen. + // Wildcards and query parameters are not supported. + Path param.Field[string] `json:"path"` + // If queue_all is `true`, all the traffic that is coming to a route will be sent + // to the waiting room. No new traffic can get to the route once this field is set + // and estimated time will become unavailable. + QueueAll param.Field[bool] `json:"queue_all"` + // Sets the queueing method used by the waiting room. Changing this parameter from + // the **default** queueing method is only available for the Waiting Room Advanced + // subscription. Regardless of the queueing method, if `queue_all` is enabled or an + // event is prequeueing, users in the waiting room will not be accepted to the + // origin. These users will always see a waiting room page that refreshes + // automatically. The valid queueing methods are: + // + // 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in + // the order they arrived. + // 2. `random`: Random queue where customers gain access randomly, regardless of + // arrival time. + // 3. `passthrough`: Users will pass directly through the waiting room and into the + // origin website. As a result, any configured limits will not be respected + // while this is enabled. This method can be used as an alternative to disabling + // a waiting room (with `suspended`) so that analytics are still reported. This + // can be used if you wish to allow all traffic normally, but want to restrict + // traffic during a waiting room event, or vice versa. + // 4. `reject`: Users will be immediately rejected from the waiting room. As a + // result, no users will reach the origin website while this is enabled. This + // can be used if you wish to reject all traffic while performing maintenance, + // block traffic during a specified period of time (an event), or block traffic + // while events are not occurring. Consider a waiting room used for vaccine + // distribution that only allows traffic during sign-up events, and otherwise + // blocks all traffic. For this case, the waiting room uses `reject`, and its + // events override this with `fifo`, `random`, or `passthrough`. When this + // queueing method is enabled and neither `queueAll` is enabled nor an event is + // prequeueing, the waiting room page **will not refresh automatically**. + QueueingMethod param.Field[WaitingRoomNewParamsQueueingMethod] `json:"queueing_method"` + // HTTP status code returned to a user while in the queue. + QueueingStatusCode param.Field[WaitingRoomNewParamsQueueingStatusCode] `json:"queueing_status_code"` + // Lifetime of a cookie (in minutes) set by Cloudflare for users who get access to + // the route. If a user is not seen by Cloudflare again in that time period, they + // will be treated as a new user that visits the route. + SessionDuration param.Field[int64] `json:"session_duration"` + // Suspends or allows traffic going to the waiting room. If set to `true`, the + // traffic will not go to the waiting room. + Suspended param.Field[bool] `json:"suspended"` +} + +func (r WaitingRoomNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type WaitingRoomNewParamsAdditionalRoute struct { + // The hostname to which this waiting room will be applied (no wildcards). The + // hostname must be the primary domain, subdomain, or custom hostname (if using SSL + // for SaaS) of this zone. Please do not include the scheme (http:// or https://). + Host param.Field[string] `json:"host"` + // Sets the path within the host to enable the waiting room on. The waiting room + // will be enabled for all subpaths as well. If there are two waiting rooms on the + // same subpath, the waiting room for the most specific path will be chosen. + // Wildcards and query parameters are not supported. + Path param.Field[string] `json:"path"` +} + +func (r WaitingRoomNewParamsAdditionalRoute) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures cookie attributes for the waiting room cookie. This encrypted cookie +// stores a user's status in the waiting room, such as queue position. +type WaitingRoomNewParamsCookieAttributes struct { + // Configures the SameSite attribute on the waiting room cookie. Value `auto` will + // be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. + // Note that when using value `none`, the secure attribute cannot be set to + // `never`. + Samesite param.Field[WaitingRoomNewParamsCookieAttributesSamesite] `json:"samesite"` + // Configures the Secure attribute on the waiting room cookie. Value `always` + // indicates that the Secure attribute will be set in the Set-Cookie header, + // `never` indicates that the Secure attribute will not be set, and `auto` will set + // the Secure attribute depending if **Always Use HTTPS** is enabled. + Secure param.Field[WaitingRoomNewParamsCookieAttributesSecure] `json:"secure"` +} + +func (r WaitingRoomNewParamsCookieAttributes) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures the SameSite attribute on the waiting room cookie. Value `auto` will +// be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. +// Note that when using value `none`, the secure attribute cannot be set to +// `never`. +type WaitingRoomNewParamsCookieAttributesSamesite string + +const ( + WaitingRoomNewParamsCookieAttributesSamesiteAuto WaitingRoomNewParamsCookieAttributesSamesite = "auto" + WaitingRoomNewParamsCookieAttributesSamesiteLax WaitingRoomNewParamsCookieAttributesSamesite = "lax" + WaitingRoomNewParamsCookieAttributesSamesiteNone WaitingRoomNewParamsCookieAttributesSamesite = "none" + WaitingRoomNewParamsCookieAttributesSamesiteStrict WaitingRoomNewParamsCookieAttributesSamesite = "strict" +) + +// Configures the Secure attribute on the waiting room cookie. Value `always` +// indicates that the Secure attribute will be set in the Set-Cookie header, +// `never` indicates that the Secure attribute will not be set, and `auto` will set +// the Secure attribute depending if **Always Use HTTPS** is enabled. +type WaitingRoomNewParamsCookieAttributesSecure string + +const ( + WaitingRoomNewParamsCookieAttributesSecureAuto WaitingRoomNewParamsCookieAttributesSecure = "auto" + WaitingRoomNewParamsCookieAttributesSecureAlways WaitingRoomNewParamsCookieAttributesSecure = "always" + WaitingRoomNewParamsCookieAttributesSecureNever WaitingRoomNewParamsCookieAttributesSecure = "never" +) + +// The language of the default page template. If no default_template_language is +// provided, then `en-US` (English) will be used. +type WaitingRoomNewParamsDefaultTemplateLanguage string + +const ( + WaitingRoomNewParamsDefaultTemplateLanguageEnUs WaitingRoomNewParamsDefaultTemplateLanguage = "en-US" + WaitingRoomNewParamsDefaultTemplateLanguageEsEs WaitingRoomNewParamsDefaultTemplateLanguage = "es-ES" + WaitingRoomNewParamsDefaultTemplateLanguageDeDe WaitingRoomNewParamsDefaultTemplateLanguage = "de-DE" + WaitingRoomNewParamsDefaultTemplateLanguageFrFr WaitingRoomNewParamsDefaultTemplateLanguage = "fr-FR" + WaitingRoomNewParamsDefaultTemplateLanguageItIt WaitingRoomNewParamsDefaultTemplateLanguage = "it-IT" + WaitingRoomNewParamsDefaultTemplateLanguageJaJp WaitingRoomNewParamsDefaultTemplateLanguage = "ja-JP" + WaitingRoomNewParamsDefaultTemplateLanguageKoKr WaitingRoomNewParamsDefaultTemplateLanguage = "ko-KR" + WaitingRoomNewParamsDefaultTemplateLanguagePtBr WaitingRoomNewParamsDefaultTemplateLanguage = "pt-BR" + WaitingRoomNewParamsDefaultTemplateLanguageZhCn WaitingRoomNewParamsDefaultTemplateLanguage = "zh-CN" + WaitingRoomNewParamsDefaultTemplateLanguageZhTw WaitingRoomNewParamsDefaultTemplateLanguage = "zh-TW" + WaitingRoomNewParamsDefaultTemplateLanguageNlNl WaitingRoomNewParamsDefaultTemplateLanguage = "nl-NL" + WaitingRoomNewParamsDefaultTemplateLanguagePlPl WaitingRoomNewParamsDefaultTemplateLanguage = "pl-PL" + WaitingRoomNewParamsDefaultTemplateLanguageIDID WaitingRoomNewParamsDefaultTemplateLanguage = "id-ID" + WaitingRoomNewParamsDefaultTemplateLanguageTrTr WaitingRoomNewParamsDefaultTemplateLanguage = "tr-TR" + WaitingRoomNewParamsDefaultTemplateLanguageArEg WaitingRoomNewParamsDefaultTemplateLanguage = "ar-EG" + WaitingRoomNewParamsDefaultTemplateLanguageRuRu WaitingRoomNewParamsDefaultTemplateLanguage = "ru-RU" + WaitingRoomNewParamsDefaultTemplateLanguageFaIr WaitingRoomNewParamsDefaultTemplateLanguage = "fa-IR" +) + +// Sets the queueing method used by the waiting room. Changing this parameter from +// the **default** queueing method is only available for the Waiting Room Advanced +// subscription. Regardless of the queueing method, if `queue_all` is enabled or an +// event is prequeueing, users in the waiting room will not be accepted to the +// origin. These users will always see a waiting room page that refreshes +// automatically. The valid queueing methods are: +// +// 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in +// the order they arrived. +// 2. `random`: Random queue where customers gain access randomly, regardless of +// arrival time. +// 3. `passthrough`: Users will pass directly through the waiting room and into the +// origin website. As a result, any configured limits will not be respected +// while this is enabled. This method can be used as an alternative to disabling +// a waiting room (with `suspended`) so that analytics are still reported. This +// can be used if you wish to allow all traffic normally, but want to restrict +// traffic during a waiting room event, or vice versa. +// 4. `reject`: Users will be immediately rejected from the waiting room. As a +// result, no users will reach the origin website while this is enabled. This +// can be used if you wish to reject all traffic while performing maintenance, +// block traffic during a specified period of time (an event), or block traffic +// while events are not occurring. Consider a waiting room used for vaccine +// distribution that only allows traffic during sign-up events, and otherwise +// blocks all traffic. For this case, the waiting room uses `reject`, and its +// events override this with `fifo`, `random`, or `passthrough`. When this +// queueing method is enabled and neither `queueAll` is enabled nor an event is +// prequeueing, the waiting room page **will not refresh automatically**. +type WaitingRoomNewParamsQueueingMethod string + +const ( + WaitingRoomNewParamsQueueingMethodFifo WaitingRoomNewParamsQueueingMethod = "fifo" + WaitingRoomNewParamsQueueingMethodRandom WaitingRoomNewParamsQueueingMethod = "random" + WaitingRoomNewParamsQueueingMethodPassthrough WaitingRoomNewParamsQueueingMethod = "passthrough" + WaitingRoomNewParamsQueueingMethodReject WaitingRoomNewParamsQueueingMethod = "reject" +) + +// HTTP status code returned to a user while in the queue. +type WaitingRoomNewParamsQueueingStatusCode int64 + +const ( + WaitingRoomNewParamsQueueingStatusCode200 WaitingRoomNewParamsQueueingStatusCode = 200 + WaitingRoomNewParamsQueueingStatusCode202 WaitingRoomNewParamsQueueingStatusCode = 202 + WaitingRoomNewParamsQueueingStatusCode429 WaitingRoomNewParamsQueueingStatusCode = 429 +) + +type WaitingRoomNewResponseEnvelope struct { + Result WaitingroomWaitingroom `json:"result,required"` + JSON waitingRoomNewResponseEnvelopeJSON `json:"-"` +} + +// waitingRoomNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [WaitingRoomNewResponseEnvelope] +type waitingRoomNewResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WaitingRoomNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingRoomNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WaitingRoomUpdateParams struct { + // The host name to which the waiting room will be applied (no wildcards). Please + // do not include the scheme (http:// or https://). The host and path combination + // must be unique. + Host param.Field[string] `json:"host,required"` + // A unique name to identify the waiting room. Only alphanumeric characters, + // hyphens and underscores are allowed. + Name param.Field[string] `json:"name,required"` + // Sets the number of new users that will be let into the route every minute. This + // value is used as baseline for the number of users that are let in per minute. So + // it is possible that there is a little more or little less traffic coming to the + // route based on the traffic patterns at that time around the world. + NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute,required"` + // Sets the total number of active user sessions on the route at a point in time. A + // route is a combination of host and path on which a waiting room is available. + // This value is used as a baseline for the total number of active user sessions on + // the route. It is possible to have a situation where there are more or less + // active users sessions on the route based on the traffic patterns at that time + // around the world. + TotalActiveUsers param.Field[int64] `json:"total_active_users,required"` + // Only available for the Waiting Room Advanced subscription. Additional hostname + // and path combinations to which this waiting room will be applied. There is an + // implied wildcard at the end of the path. The hostname and path combination must + // be unique to this and all other waiting rooms. + AdditionalRoutes param.Field[[]WaitingRoomUpdateParamsAdditionalRoute] `json:"additional_routes"` + // Configures cookie attributes for the waiting room cookie. This encrypted cookie + // stores a user's status in the waiting room, such as queue position. + CookieAttributes param.Field[WaitingRoomUpdateParamsCookieAttributes] `json:"cookie_attributes"` + // Appends a '\_' + a custom suffix to the end of Cloudflare Waiting Room's cookie + // name(**cf_waitingroom). If `cookie_suffix` is "abcd", the cookie name will be + // `**cf_waitingroom_abcd`. This field is required if using `additional_routes`. + CookieSuffix param.Field[string] `json:"cookie_suffix"` + // Only available for the Waiting Room Advanced subscription. This is a template + // html file that will be rendered at the edge. If no custom_page_html is provided, + // the default waiting room will be used. The template is based on mustache ( + // https://mustache.github.io/ ). There are several variables that are evaluated by + // the Cloudflare edge: + // + // 1. {{`waitTimeKnown`}} Acts like a boolean value that indicates the behavior to + // take when wait time is not available, for instance when queue_all is + // **true**. + // 2. {{`waitTimeFormatted`}} Estimated wait time for the user. For example, five + // minutes. Alternatively, you can use: + // 3. {{`waitTime`}} Number of minutes of estimated wait for a user. + // 4. {{`waitTimeHours`}} Number of hours of estimated wait for a user + // (`Math.floor(waitTime/60)`). + // 5. {{`waitTimeHourMinutes`}} Number of minutes above the `waitTimeHours` value + // (`waitTime%60`). + // 6. {{`queueIsFull`}} Changes to **true** when no more people can be added to the + // queue. + // + // To view the full list of variables, look at the `cfWaitingRoom` object described + // under the `json_response_enabled` property in other Waiting Room API calls. + CustomPageHTML param.Field[string] `json:"custom_page_html"` + // The language of the default page template. If no default_template_language is + // provided, then `en-US` (English) will be used. + DefaultTemplateLanguage param.Field[WaitingRoomUpdateParamsDefaultTemplateLanguage] `json:"default_template_language"` + // A note that you can use to add more details about the waiting room. + Description param.Field[string] `json:"description"` + // Only available for the Waiting Room Advanced subscription. Disables automatic + // renewal of session cookies. If `true`, an accepted user will have + // session_duration minutes to browse the site. After that, they will have to go + // through the waiting room again. If `false`, a user's session cookie will be + // automatically renewed on every request. + DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` + // Only available for the Waiting Room Advanced subscription. If `true`, requests + // to the waiting room with the header `Accept: application/json` will receive a + // JSON response object with information on the user's status in the waiting room + // as opposed to the configured static HTML page. This JSON response object has one + // property `cfWaitingRoom` which is an object containing the following fields: + // + // 1. `inWaitingRoom`: Boolean indicating if the user is in the waiting room + // (always **true**). + // 2. `waitTimeKnown`: Boolean indicating if the current estimated wait times are + // accurate. If **false**, they are not available. + // 3. `waitTime`: Valid only when `waitTimeKnown` is **true**. Integer indicating + // the current estimated time in minutes the user will wait in the waiting room. + // When `queueingMethod` is **random**, this is set to `waitTime50Percentile`. + // 4. `waitTime25Percentile`: Valid only when `queueingMethod` is **random** and + // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum + // wait time for the 25% of users that gain entry the fastest (25th percentile). + // 5. `waitTime50Percentile`: Valid only when `queueingMethod` is **random** and + // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum + // wait time for the 50% of users that gain entry the fastest (50th percentile). + // In other words, half of the queued users are expected to let into the origin + // website before `waitTime50Percentile` and half are expected to be let in + // after it. + // 6. `waitTime75Percentile`: Valid only when `queueingMethod` is **random** and + // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum + // wait time for the 75% of users that gain entry the fastest (75th percentile). + // 7. `waitTimeFormatted`: String displaying the `waitTime` formatted in English + // for users. If `waitTimeKnown` is **false**, `waitTimeFormatted` will display + // **unavailable**. + // 8. `queueIsFull`: Boolean indicating if the waiting room's queue is currently + // full and not accepting new users at the moment. + // 9. `queueAll`: Boolean indicating if all users will be queued in the waiting + // room and no one will be let into the origin website. + // 10. `lastUpdated`: String displaying the timestamp as an ISO 8601 string of the + // user's last attempt to leave the waiting room and be let into the origin + // website. The user is able to make another attempt after + // `refreshIntervalSeconds` past this time. If the user makes a request too + // soon, it will be ignored and `lastUpdated` will not change. + // 11. `refreshIntervalSeconds`: Integer indicating the number of seconds after + // `lastUpdated` until the user is able to make another attempt to leave the + // waiting room and be let into the origin website. When the `queueingMethod` + // is `reject`, there is no specified refresh time — it will always be + // **zero**. + // 12. `queueingMethod`: The queueing method currently used by the waiting room. It + // is either **fifo**, **random**, **passthrough**, or **reject**. + // 13. `isFIFOQueue`: Boolean indicating if the waiting room uses a FIFO + // (First-In-First-Out) queue. + // 14. `isRandomQueue`: Boolean indicating if the waiting room uses a Random queue + // where users gain access randomly. + // 15. `isPassthroughQueue`: Boolean indicating if the waiting room uses a + // passthrough queue. Keep in mind that when passthrough is enabled, this JSON + // response will only exist when `queueAll` is **true** or `isEventPrequeueing` + // is **true** because in all other cases requests will go directly to the + // origin. + // 16. `isRejectQueue`: Boolean indicating if the waiting room uses a reject queue. + // 17. `isEventActive`: Boolean indicating if an event is currently occurring. + // Events are able to change a waiting room's behavior during a specified + // period of time. For additional information, look at the event properties + // `prequeue_start_time`, `event_start_time`, and `event_end_time` in the + // documentation for creating waiting room events. Events are considered active + // between these start and end times, as well as during the prequeueing period + // if it exists. + // 18. `isEventPrequeueing`: Valid only when `isEventActive` is **true**. Boolean + // indicating if an event is currently prequeueing users before it starts. + // 19. `timeUntilEventStart`: Valid only when `isEventPrequeueing` is **true**. + // Integer indicating the number of minutes until the event starts. + // 20. `timeUntilEventStartFormatted`: String displaying the `timeUntilEventStart` + // formatted in English for users. If `isEventPrequeueing` is **false**, + // `timeUntilEventStartFormatted` will display **unavailable**. + // 21. `timeUntilEventEnd`: Valid only when `isEventActive` is **true**. Integer + // indicating the number of minutes until the event ends. + // 22. `timeUntilEventEndFormatted`: String displaying the `timeUntilEventEnd` + // formatted in English for users. If `isEventActive` is **false**, + // `timeUntilEventEndFormatted` will display **unavailable**. + // 23. `shuffleAtEventStart`: Valid only when `isEventActive` is **true**. Boolean + // indicating if the users in the prequeue are shuffled randomly when the event + // starts. + // + // An example cURL to a waiting room could be: + // + // curl -X GET "https://example.com/waitingroom" \ + // -H "Accept: application/json" + // + // If `json_response_enabled` is **true** and the request hits the waiting room, an + // example JSON response when `queueingMethod` is **fifo** and no event is active + // could be: + // + // { + // "cfWaitingRoom": { + // "inWaitingRoom": true, + // "waitTimeKnown": true, + // "waitTime": 10, + // "waitTime25Percentile": 0, + // "waitTime50Percentile": 0, + // "waitTime75Percentile": 0, + // "waitTimeFormatted": "10 minutes", + // "queueIsFull": false, + // "queueAll": false, + // "lastUpdated": "2020-08-03T23:46:00.000Z", + // "refreshIntervalSeconds": 20, + // "queueingMethod": "fifo", + // "isFIFOQueue": true, + // "isRandomQueue": false, + // "isPassthroughQueue": false, + // "isRejectQueue": false, + // "isEventActive": false, + // "isEventPrequeueing": false, + // "timeUntilEventStart": 0, + // "timeUntilEventStartFormatted": "unavailable", + // "timeUntilEventEnd": 0, + // "timeUntilEventEndFormatted": "unavailable", + // "shuffleAtEventStart": false + // } + // } + // + // If `json_response_enabled` is **true** and the request hits the waiting room, an + // example JSON response when `queueingMethod` is **random** and an event is active + // could be: + // + // { + // "cfWaitingRoom": { + // "inWaitingRoom": true, + // "waitTimeKnown": true, + // "waitTime": 10, + // "waitTime25Percentile": 5, + // "waitTime50Percentile": 10, + // "waitTime75Percentile": 15, + // "waitTimeFormatted": "5 minutes to 15 minutes", + // "queueIsFull": false, + // "queueAll": false, + // "lastUpdated": "2020-08-03T23:46:00.000Z", + // "refreshIntervalSeconds": 20, + // "queueingMethod": "random", + // "isFIFOQueue": false, + // "isRandomQueue": true, + // "isPassthroughQueue": false, + // "isRejectQueue": false, + // "isEventActive": true, + // "isEventPrequeueing": false, + // "timeUntilEventStart": 0, + // "timeUntilEventStartFormatted": "unavailable", + // "timeUntilEventEnd": 15, + // "timeUntilEventEndFormatted": "15 minutes", + // "shuffleAtEventStart": true + // } + // }. + JsonResponseEnabled param.Field[bool] `json:"json_response_enabled"` + // Sets the path within the host to enable the waiting room on. The waiting room + // will be enabled for all subpaths as well. If there are two waiting rooms on the + // same subpath, the waiting room for the most specific path will be chosen. + // Wildcards and query parameters are not supported. + Path param.Field[string] `json:"path"` + // If queue_all is `true`, all the traffic that is coming to a route will be sent + // to the waiting room. No new traffic can get to the route once this field is set + // and estimated time will become unavailable. + QueueAll param.Field[bool] `json:"queue_all"` + // Sets the queueing method used by the waiting room. Changing this parameter from + // the **default** queueing method is only available for the Waiting Room Advanced + // subscription. Regardless of the queueing method, if `queue_all` is enabled or an + // event is prequeueing, users in the waiting room will not be accepted to the + // origin. These users will always see a waiting room page that refreshes + // automatically. The valid queueing methods are: + // + // 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in + // the order they arrived. + // 2. `random`: Random queue where customers gain access randomly, regardless of + // arrival time. + // 3. `passthrough`: Users will pass directly through the waiting room and into the + // origin website. As a result, any configured limits will not be respected + // while this is enabled. This method can be used as an alternative to disabling + // a waiting room (with `suspended`) so that analytics are still reported. This + // can be used if you wish to allow all traffic normally, but want to restrict + // traffic during a waiting room event, or vice versa. + // 4. `reject`: Users will be immediately rejected from the waiting room. As a + // result, no users will reach the origin website while this is enabled. This + // can be used if you wish to reject all traffic while performing maintenance, + // block traffic during a specified period of time (an event), or block traffic + // while events are not occurring. Consider a waiting room used for vaccine + // distribution that only allows traffic during sign-up events, and otherwise + // blocks all traffic. For this case, the waiting room uses `reject`, and its + // events override this with `fifo`, `random`, or `passthrough`. When this + // queueing method is enabled and neither `queueAll` is enabled nor an event is + // prequeueing, the waiting room page **will not refresh automatically**. + QueueingMethod param.Field[WaitingRoomUpdateParamsQueueingMethod] `json:"queueing_method"` + // HTTP status code returned to a user while in the queue. + QueueingStatusCode param.Field[WaitingRoomUpdateParamsQueueingStatusCode] `json:"queueing_status_code"` + // Lifetime of a cookie (in minutes) set by Cloudflare for users who get access to + // the route. If a user is not seen by Cloudflare again in that time period, they + // will be treated as a new user that visits the route. + SessionDuration param.Field[int64] `json:"session_duration"` + // Suspends or allows traffic going to the waiting room. If set to `true`, the + // traffic will not go to the waiting room. + Suspended param.Field[bool] `json:"suspended"` +} + +func (r WaitingRoomUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type WaitingRoomUpdateParamsAdditionalRoute struct { + // The hostname to which this waiting room will be applied (no wildcards). The + // hostname must be the primary domain, subdomain, or custom hostname (if using SSL + // for SaaS) of this zone. Please do not include the scheme (http:// or https://). + Host param.Field[string] `json:"host"` + // Sets the path within the host to enable the waiting room on. The waiting room + // will be enabled for all subpaths as well. If there are two waiting rooms on the + // same subpath, the waiting room for the most specific path will be chosen. + // Wildcards and query parameters are not supported. + Path param.Field[string] `json:"path"` +} + +func (r WaitingRoomUpdateParamsAdditionalRoute) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures cookie attributes for the waiting room cookie. This encrypted cookie +// stores a user's status in the waiting room, such as queue position. +type WaitingRoomUpdateParamsCookieAttributes struct { + // Configures the SameSite attribute on the waiting room cookie. Value `auto` will + // be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. + // Note that when using value `none`, the secure attribute cannot be set to + // `never`. + Samesite param.Field[WaitingRoomUpdateParamsCookieAttributesSamesite] `json:"samesite"` + // Configures the Secure attribute on the waiting room cookie. Value `always` + // indicates that the Secure attribute will be set in the Set-Cookie header, + // `never` indicates that the Secure attribute will not be set, and `auto` will set + // the Secure attribute depending if **Always Use HTTPS** is enabled. + Secure param.Field[WaitingRoomUpdateParamsCookieAttributesSecure] `json:"secure"` +} + +func (r WaitingRoomUpdateParamsCookieAttributes) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures the SameSite attribute on the waiting room cookie. Value `auto` will +// be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. +// Note that when using value `none`, the secure attribute cannot be set to +// `never`. +type WaitingRoomUpdateParamsCookieAttributesSamesite string + +const ( + WaitingRoomUpdateParamsCookieAttributesSamesiteAuto WaitingRoomUpdateParamsCookieAttributesSamesite = "auto" + WaitingRoomUpdateParamsCookieAttributesSamesiteLax WaitingRoomUpdateParamsCookieAttributesSamesite = "lax" + WaitingRoomUpdateParamsCookieAttributesSamesiteNone WaitingRoomUpdateParamsCookieAttributesSamesite = "none" + WaitingRoomUpdateParamsCookieAttributesSamesiteStrict WaitingRoomUpdateParamsCookieAttributesSamesite = "strict" +) + +// Configures the Secure attribute on the waiting room cookie. Value `always` +// indicates that the Secure attribute will be set in the Set-Cookie header, +// `never` indicates that the Secure attribute will not be set, and `auto` will set +// the Secure attribute depending if **Always Use HTTPS** is enabled. +type WaitingRoomUpdateParamsCookieAttributesSecure string + +const ( + WaitingRoomUpdateParamsCookieAttributesSecureAuto WaitingRoomUpdateParamsCookieAttributesSecure = "auto" + WaitingRoomUpdateParamsCookieAttributesSecureAlways WaitingRoomUpdateParamsCookieAttributesSecure = "always" + WaitingRoomUpdateParamsCookieAttributesSecureNever WaitingRoomUpdateParamsCookieAttributesSecure = "never" +) + +// The language of the default page template. If no default_template_language is +// provided, then `en-US` (English) will be used. +type WaitingRoomUpdateParamsDefaultTemplateLanguage string + +const ( + WaitingRoomUpdateParamsDefaultTemplateLanguageEnUs WaitingRoomUpdateParamsDefaultTemplateLanguage = "en-US" + WaitingRoomUpdateParamsDefaultTemplateLanguageEsEs WaitingRoomUpdateParamsDefaultTemplateLanguage = "es-ES" + WaitingRoomUpdateParamsDefaultTemplateLanguageDeDe WaitingRoomUpdateParamsDefaultTemplateLanguage = "de-DE" + WaitingRoomUpdateParamsDefaultTemplateLanguageFrFr WaitingRoomUpdateParamsDefaultTemplateLanguage = "fr-FR" + WaitingRoomUpdateParamsDefaultTemplateLanguageItIt WaitingRoomUpdateParamsDefaultTemplateLanguage = "it-IT" + WaitingRoomUpdateParamsDefaultTemplateLanguageJaJp WaitingRoomUpdateParamsDefaultTemplateLanguage = "ja-JP" + WaitingRoomUpdateParamsDefaultTemplateLanguageKoKr WaitingRoomUpdateParamsDefaultTemplateLanguage = "ko-KR" + WaitingRoomUpdateParamsDefaultTemplateLanguagePtBr WaitingRoomUpdateParamsDefaultTemplateLanguage = "pt-BR" + WaitingRoomUpdateParamsDefaultTemplateLanguageZhCn WaitingRoomUpdateParamsDefaultTemplateLanguage = "zh-CN" + WaitingRoomUpdateParamsDefaultTemplateLanguageZhTw WaitingRoomUpdateParamsDefaultTemplateLanguage = "zh-TW" + WaitingRoomUpdateParamsDefaultTemplateLanguageNlNl WaitingRoomUpdateParamsDefaultTemplateLanguage = "nl-NL" + WaitingRoomUpdateParamsDefaultTemplateLanguagePlPl WaitingRoomUpdateParamsDefaultTemplateLanguage = "pl-PL" + WaitingRoomUpdateParamsDefaultTemplateLanguageIDID WaitingRoomUpdateParamsDefaultTemplateLanguage = "id-ID" + WaitingRoomUpdateParamsDefaultTemplateLanguageTrTr WaitingRoomUpdateParamsDefaultTemplateLanguage = "tr-TR" + WaitingRoomUpdateParamsDefaultTemplateLanguageArEg WaitingRoomUpdateParamsDefaultTemplateLanguage = "ar-EG" + WaitingRoomUpdateParamsDefaultTemplateLanguageRuRu WaitingRoomUpdateParamsDefaultTemplateLanguage = "ru-RU" + WaitingRoomUpdateParamsDefaultTemplateLanguageFaIr WaitingRoomUpdateParamsDefaultTemplateLanguage = "fa-IR" +) + +// Sets the queueing method used by the waiting room. Changing this parameter from +// the **default** queueing method is only available for the Waiting Room Advanced +// subscription. Regardless of the queueing method, if `queue_all` is enabled or an +// event is prequeueing, users in the waiting room will not be accepted to the +// origin. These users will always see a waiting room page that refreshes +// automatically. The valid queueing methods are: +// +// 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in +// the order they arrived. +// 2. `random`: Random queue where customers gain access randomly, regardless of +// arrival time. +// 3. `passthrough`: Users will pass directly through the waiting room and into the +// origin website. As a result, any configured limits will not be respected +// while this is enabled. This method can be used as an alternative to disabling +// a waiting room (with `suspended`) so that analytics are still reported. This +// can be used if you wish to allow all traffic normally, but want to restrict +// traffic during a waiting room event, or vice versa. +// 4. `reject`: Users will be immediately rejected from the waiting room. As a +// result, no users will reach the origin website while this is enabled. This +// can be used if you wish to reject all traffic while performing maintenance, +// block traffic during a specified period of time (an event), or block traffic +// while events are not occurring. Consider a waiting room used for vaccine +// distribution that only allows traffic during sign-up events, and otherwise +// blocks all traffic. For this case, the waiting room uses `reject`, and its +// events override this with `fifo`, `random`, or `passthrough`. When this +// queueing method is enabled and neither `queueAll` is enabled nor an event is +// prequeueing, the waiting room page **will not refresh automatically**. +type WaitingRoomUpdateParamsQueueingMethod string + +const ( + WaitingRoomUpdateParamsQueueingMethodFifo WaitingRoomUpdateParamsQueueingMethod = "fifo" + WaitingRoomUpdateParamsQueueingMethodRandom WaitingRoomUpdateParamsQueueingMethod = "random" + WaitingRoomUpdateParamsQueueingMethodPassthrough WaitingRoomUpdateParamsQueueingMethod = "passthrough" + WaitingRoomUpdateParamsQueueingMethodReject WaitingRoomUpdateParamsQueueingMethod = "reject" +) + +// HTTP status code returned to a user while in the queue. +type WaitingRoomUpdateParamsQueueingStatusCode int64 + +const ( + WaitingRoomUpdateParamsQueueingStatusCode200 WaitingRoomUpdateParamsQueueingStatusCode = 200 + WaitingRoomUpdateParamsQueueingStatusCode202 WaitingRoomUpdateParamsQueueingStatusCode = 202 + WaitingRoomUpdateParamsQueueingStatusCode429 WaitingRoomUpdateParamsQueueingStatusCode = 429 +) + +type WaitingRoomUpdateResponseEnvelope struct { + Result WaitingroomWaitingroom `json:"result,required"` + JSON waitingRoomUpdateResponseEnvelopeJSON `json:"-"` +} + +// waitingRoomUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [WaitingRoomUpdateResponseEnvelope] +type waitingRoomUpdateResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WaitingRoomUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingRoomUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WaitingRoomListResponseEnvelope struct { + Errors []WaitingRoomListResponseEnvelopeErrors `json:"errors,required"` + Messages []WaitingRoomListResponseEnvelopeMessages `json:"messages,required"` + Result []WaitingroomWaitingroom `json:"result,required,nullable"` + // Whether the API call was successful + Success WaitingRoomListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo WaitingRoomListResponseEnvelopeResultInfo `json:"result_info"` + JSON waitingRoomListResponseEnvelopeJSON `json:"-"` +} + +// waitingRoomListResponseEnvelopeJSON contains the JSON metadata for the struct +// [WaitingRoomListResponseEnvelope] +type waitingRoomListResponseEnvelopeJSON 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 *WaitingRoomListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingRoomListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WaitingRoomListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON waitingRoomListResponseEnvelopeErrorsJSON `json:"-"` +} + +// waitingRoomListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [WaitingRoomListResponseEnvelopeErrors] +type waitingRoomListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WaitingRoomListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingRoomListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WaitingRoomListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON waitingRoomListResponseEnvelopeMessagesJSON `json:"-"` +} + +// waitingRoomListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [WaitingRoomListResponseEnvelopeMessages] +type waitingRoomListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WaitingRoomListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingRoomListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type WaitingRoomListResponseEnvelopeSuccess bool + +const ( + WaitingRoomListResponseEnvelopeSuccessTrue WaitingRoomListResponseEnvelopeSuccess = true +) + +type WaitingRoomListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON waitingRoomListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// waitingRoomListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [WaitingRoomListResponseEnvelopeResultInfo] +type waitingRoomListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WaitingRoomListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingRoomListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type WaitingRoomDeleteResponseEnvelope struct { + Result WaitingRoomDeleteResponse `json:"result,required"` + JSON waitingRoomDeleteResponseEnvelopeJSON `json:"-"` +} + +// waitingRoomDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [WaitingRoomDeleteResponseEnvelope] +type waitingRoomDeleteResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WaitingRoomDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingRoomDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WaitingRoomEditParams struct { + // The host name to which the waiting room will be applied (no wildcards). Please + // do not include the scheme (http:// or https://). The host and path combination + // must be unique. + Host param.Field[string] `json:"host,required"` + // A unique name to identify the waiting room. Only alphanumeric characters, + // hyphens and underscores are allowed. + Name param.Field[string] `json:"name,required"` + // Sets the number of new users that will be let into the route every minute. This + // value is used as baseline for the number of users that are let in per minute. So + // it is possible that there is a little more or little less traffic coming to the + // route based on the traffic patterns at that time around the world. + NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute,required"` + // Sets the total number of active user sessions on the route at a point in time. A + // route is a combination of host and path on which a waiting room is available. + // This value is used as a baseline for the total number of active user sessions on + // the route. It is possible to have a situation where there are more or less + // active users sessions on the route based on the traffic patterns at that time + // around the world. + TotalActiveUsers param.Field[int64] `json:"total_active_users,required"` + // Only available for the Waiting Room Advanced subscription. Additional hostname + // and path combinations to which this waiting room will be applied. There is an + // implied wildcard at the end of the path. The hostname and path combination must + // be unique to this and all other waiting rooms. + AdditionalRoutes param.Field[[]WaitingRoomEditParamsAdditionalRoute] `json:"additional_routes"` + // Configures cookie attributes for the waiting room cookie. This encrypted cookie + // stores a user's status in the waiting room, such as queue position. + CookieAttributes param.Field[WaitingRoomEditParamsCookieAttributes] `json:"cookie_attributes"` + // Appends a '\_' + a custom suffix to the end of Cloudflare Waiting Room's cookie + // name(**cf_waitingroom). If `cookie_suffix` is "abcd", the cookie name will be + // `**cf_waitingroom_abcd`. This field is required if using `additional_routes`. + CookieSuffix param.Field[string] `json:"cookie_suffix"` + // Only available for the Waiting Room Advanced subscription. This is a template + // html file that will be rendered at the edge. If no custom_page_html is provided, + // the default waiting room will be used. The template is based on mustache ( + // https://mustache.github.io/ ). There are several variables that are evaluated by + // the Cloudflare edge: + // + // 1. {{`waitTimeKnown`}} Acts like a boolean value that indicates the behavior to + // take when wait time is not available, for instance when queue_all is + // **true**. + // 2. {{`waitTimeFormatted`}} Estimated wait time for the user. For example, five + // minutes. Alternatively, you can use: + // 3. {{`waitTime`}} Number of minutes of estimated wait for a user. + // 4. {{`waitTimeHours`}} Number of hours of estimated wait for a user + // (`Math.floor(waitTime/60)`). + // 5. {{`waitTimeHourMinutes`}} Number of minutes above the `waitTimeHours` value + // (`waitTime%60`). + // 6. {{`queueIsFull`}} Changes to **true** when no more people can be added to the + // queue. + // + // To view the full list of variables, look at the `cfWaitingRoom` object described + // under the `json_response_enabled` property in other Waiting Room API calls. + CustomPageHTML param.Field[string] `json:"custom_page_html"` + // The language of the default page template. If no default_template_language is + // provided, then `en-US` (English) will be used. + DefaultTemplateLanguage param.Field[WaitingRoomEditParamsDefaultTemplateLanguage] `json:"default_template_language"` + // A note that you can use to add more details about the waiting room. + Description param.Field[string] `json:"description"` + // Only available for the Waiting Room Advanced subscription. Disables automatic + // renewal of session cookies. If `true`, an accepted user will have + // session_duration minutes to browse the site. After that, they will have to go + // through the waiting room again. If `false`, a user's session cookie will be + // automatically renewed on every request. + DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` + // Only available for the Waiting Room Advanced subscription. If `true`, requests + // to the waiting room with the header `Accept: application/json` will receive a + // JSON response object with information on the user's status in the waiting room + // as opposed to the configured static HTML page. This JSON response object has one + // property `cfWaitingRoom` which is an object containing the following fields: + // + // 1. `inWaitingRoom`: Boolean indicating if the user is in the waiting room + // (always **true**). + // 2. `waitTimeKnown`: Boolean indicating if the current estimated wait times are + // accurate. If **false**, they are not available. + // 3. `waitTime`: Valid only when `waitTimeKnown` is **true**. Integer indicating + // the current estimated time in minutes the user will wait in the waiting room. + // When `queueingMethod` is **random**, this is set to `waitTime50Percentile`. + // 4. `waitTime25Percentile`: Valid only when `queueingMethod` is **random** and + // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum + // wait time for the 25% of users that gain entry the fastest (25th percentile). + // 5. `waitTime50Percentile`: Valid only when `queueingMethod` is **random** and + // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum + // wait time for the 50% of users that gain entry the fastest (50th percentile). + // In other words, half of the queued users are expected to let into the origin + // website before `waitTime50Percentile` and half are expected to be let in + // after it. + // 6. `waitTime75Percentile`: Valid only when `queueingMethod` is **random** and + // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum + // wait time for the 75% of users that gain entry the fastest (75th percentile). + // 7. `waitTimeFormatted`: String displaying the `waitTime` formatted in English + // for users. If `waitTimeKnown` is **false**, `waitTimeFormatted` will display + // **unavailable**. + // 8. `queueIsFull`: Boolean indicating if the waiting room's queue is currently + // full and not accepting new users at the moment. + // 9. `queueAll`: Boolean indicating if all users will be queued in the waiting + // room and no one will be let into the origin website. + // 10. `lastUpdated`: String displaying the timestamp as an ISO 8601 string of the + // user's last attempt to leave the waiting room and be let into the origin + // website. The user is able to make another attempt after + // `refreshIntervalSeconds` past this time. If the user makes a request too + // soon, it will be ignored and `lastUpdated` will not change. + // 11. `refreshIntervalSeconds`: Integer indicating the number of seconds after + // `lastUpdated` until the user is able to make another attempt to leave the + // waiting room and be let into the origin website. When the `queueingMethod` + // is `reject`, there is no specified refresh time — it will always be + // **zero**. + // 12. `queueingMethod`: The queueing method currently used by the waiting room. It + // is either **fifo**, **random**, **passthrough**, or **reject**. + // 13. `isFIFOQueue`: Boolean indicating if the waiting room uses a FIFO + // (First-In-First-Out) queue. + // 14. `isRandomQueue`: Boolean indicating if the waiting room uses a Random queue + // where users gain access randomly. + // 15. `isPassthroughQueue`: Boolean indicating if the waiting room uses a + // passthrough queue. Keep in mind that when passthrough is enabled, this JSON + // response will only exist when `queueAll` is **true** or `isEventPrequeueing` + // is **true** because in all other cases requests will go directly to the + // origin. + // 16. `isRejectQueue`: Boolean indicating if the waiting room uses a reject queue. + // 17. `isEventActive`: Boolean indicating if an event is currently occurring. + // Events are able to change a waiting room's behavior during a specified + // period of time. For additional information, look at the event properties + // `prequeue_start_time`, `event_start_time`, and `event_end_time` in the + // documentation for creating waiting room events. Events are considered active + // between these start and end times, as well as during the prequeueing period + // if it exists. + // 18. `isEventPrequeueing`: Valid only when `isEventActive` is **true**. Boolean + // indicating if an event is currently prequeueing users before it starts. + // 19. `timeUntilEventStart`: Valid only when `isEventPrequeueing` is **true**. + // Integer indicating the number of minutes until the event starts. + // 20. `timeUntilEventStartFormatted`: String displaying the `timeUntilEventStart` + // formatted in English for users. If `isEventPrequeueing` is **false**, + // `timeUntilEventStartFormatted` will display **unavailable**. + // 21. `timeUntilEventEnd`: Valid only when `isEventActive` is **true**. Integer + // indicating the number of minutes until the event ends. + // 22. `timeUntilEventEndFormatted`: String displaying the `timeUntilEventEnd` + // formatted in English for users. If `isEventActive` is **false**, + // `timeUntilEventEndFormatted` will display **unavailable**. + // 23. `shuffleAtEventStart`: Valid only when `isEventActive` is **true**. Boolean + // indicating if the users in the prequeue are shuffled randomly when the event + // starts. + // + // An example cURL to a waiting room could be: + // + // curl -X GET "https://example.com/waitingroom" \ + // -H "Accept: application/json" + // + // If `json_response_enabled` is **true** and the request hits the waiting room, an + // example JSON response when `queueingMethod` is **fifo** and no event is active + // could be: + // + // { + // "cfWaitingRoom": { + // "inWaitingRoom": true, + // "waitTimeKnown": true, + // "waitTime": 10, + // "waitTime25Percentile": 0, + // "waitTime50Percentile": 0, + // "waitTime75Percentile": 0, + // "waitTimeFormatted": "10 minutes", + // "queueIsFull": false, + // "queueAll": false, + // "lastUpdated": "2020-08-03T23:46:00.000Z", + // "refreshIntervalSeconds": 20, + // "queueingMethod": "fifo", + // "isFIFOQueue": true, + // "isRandomQueue": false, + // "isPassthroughQueue": false, + // "isRejectQueue": false, + // "isEventActive": false, + // "isEventPrequeueing": false, + // "timeUntilEventStart": 0, + // "timeUntilEventStartFormatted": "unavailable", + // "timeUntilEventEnd": 0, + // "timeUntilEventEndFormatted": "unavailable", + // "shuffleAtEventStart": false + // } + // } + // + // If `json_response_enabled` is **true** and the request hits the waiting room, an + // example JSON response when `queueingMethod` is **random** and an event is active + // could be: + // + // { + // "cfWaitingRoom": { + // "inWaitingRoom": true, + // "waitTimeKnown": true, + // "waitTime": 10, + // "waitTime25Percentile": 5, + // "waitTime50Percentile": 10, + // "waitTime75Percentile": 15, + // "waitTimeFormatted": "5 minutes to 15 minutes", + // "queueIsFull": false, + // "queueAll": false, + // "lastUpdated": "2020-08-03T23:46:00.000Z", + // "refreshIntervalSeconds": 20, + // "queueingMethod": "random", + // "isFIFOQueue": false, + // "isRandomQueue": true, + // "isPassthroughQueue": false, + // "isRejectQueue": false, + // "isEventActive": true, + // "isEventPrequeueing": false, + // "timeUntilEventStart": 0, + // "timeUntilEventStartFormatted": "unavailable", + // "timeUntilEventEnd": 15, + // "timeUntilEventEndFormatted": "15 minutes", + // "shuffleAtEventStart": true + // } + // }. + JsonResponseEnabled param.Field[bool] `json:"json_response_enabled"` + // Sets the path within the host to enable the waiting room on. The waiting room + // will be enabled for all subpaths as well. If there are two waiting rooms on the + // same subpath, the waiting room for the most specific path will be chosen. + // Wildcards and query parameters are not supported. + Path param.Field[string] `json:"path"` + // If queue_all is `true`, all the traffic that is coming to a route will be sent + // to the waiting room. No new traffic can get to the route once this field is set + // and estimated time will become unavailable. + QueueAll param.Field[bool] `json:"queue_all"` + // Sets the queueing method used by the waiting room. Changing this parameter from + // the **default** queueing method is only available for the Waiting Room Advanced + // subscription. Regardless of the queueing method, if `queue_all` is enabled or an + // event is prequeueing, users in the waiting room will not be accepted to the + // origin. These users will always see a waiting room page that refreshes + // automatically. The valid queueing methods are: + // + // 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in + // the order they arrived. + // 2. `random`: Random queue where customers gain access randomly, regardless of + // arrival time. + // 3. `passthrough`: Users will pass directly through the waiting room and into the + // origin website. As a result, any configured limits will not be respected + // while this is enabled. This method can be used as an alternative to disabling + // a waiting room (with `suspended`) so that analytics are still reported. This + // can be used if you wish to allow all traffic normally, but want to restrict + // traffic during a waiting room event, or vice versa. + // 4. `reject`: Users will be immediately rejected from the waiting room. As a + // result, no users will reach the origin website while this is enabled. This + // can be used if you wish to reject all traffic while performing maintenance, + // block traffic during a specified period of time (an event), or block traffic + // while events are not occurring. Consider a waiting room used for vaccine + // distribution that only allows traffic during sign-up events, and otherwise + // blocks all traffic. For this case, the waiting room uses `reject`, and its + // events override this with `fifo`, `random`, or `passthrough`. When this + // queueing method is enabled and neither `queueAll` is enabled nor an event is + // prequeueing, the waiting room page **will not refresh automatically**. + QueueingMethod param.Field[WaitingRoomEditParamsQueueingMethod] `json:"queueing_method"` + // HTTP status code returned to a user while in the queue. + QueueingStatusCode param.Field[WaitingRoomEditParamsQueueingStatusCode] `json:"queueing_status_code"` + // Lifetime of a cookie (in minutes) set by Cloudflare for users who get access to + // the route. If a user is not seen by Cloudflare again in that time period, they + // will be treated as a new user that visits the route. + SessionDuration param.Field[int64] `json:"session_duration"` + // Suspends or allows traffic going to the waiting room. If set to `true`, the + // traffic will not go to the waiting room. + Suspended param.Field[bool] `json:"suspended"` +} + +func (r WaitingRoomEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type WaitingRoomEditParamsAdditionalRoute struct { + // The hostname to which this waiting room will be applied (no wildcards). The + // hostname must be the primary domain, subdomain, or custom hostname (if using SSL + // for SaaS) of this zone. Please do not include the scheme (http:// or https://). + Host param.Field[string] `json:"host"` + // Sets the path within the host to enable the waiting room on. The waiting room + // will be enabled for all subpaths as well. If there are two waiting rooms on the + // same subpath, the waiting room for the most specific path will be chosen. + // Wildcards and query parameters are not supported. + Path param.Field[string] `json:"path"` +} + +func (r WaitingRoomEditParamsAdditionalRoute) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures cookie attributes for the waiting room cookie. This encrypted cookie +// stores a user's status in the waiting room, such as queue position. +type WaitingRoomEditParamsCookieAttributes struct { + // Configures the SameSite attribute on the waiting room cookie. Value `auto` will + // be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. + // Note that when using value `none`, the secure attribute cannot be set to + // `never`. + Samesite param.Field[WaitingRoomEditParamsCookieAttributesSamesite] `json:"samesite"` + // Configures the Secure attribute on the waiting room cookie. Value `always` + // indicates that the Secure attribute will be set in the Set-Cookie header, + // `never` indicates that the Secure attribute will not be set, and `auto` will set + // the Secure attribute depending if **Always Use HTTPS** is enabled. + Secure param.Field[WaitingRoomEditParamsCookieAttributesSecure] `json:"secure"` +} + +func (r WaitingRoomEditParamsCookieAttributes) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures the SameSite attribute on the waiting room cookie. Value `auto` will +// be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. +// Note that when using value `none`, the secure attribute cannot be set to +// `never`. +type WaitingRoomEditParamsCookieAttributesSamesite string + +const ( + WaitingRoomEditParamsCookieAttributesSamesiteAuto WaitingRoomEditParamsCookieAttributesSamesite = "auto" + WaitingRoomEditParamsCookieAttributesSamesiteLax WaitingRoomEditParamsCookieAttributesSamesite = "lax" + WaitingRoomEditParamsCookieAttributesSamesiteNone WaitingRoomEditParamsCookieAttributesSamesite = "none" + WaitingRoomEditParamsCookieAttributesSamesiteStrict WaitingRoomEditParamsCookieAttributesSamesite = "strict" +) + +// Configures the Secure attribute on the waiting room cookie. Value `always` +// indicates that the Secure attribute will be set in the Set-Cookie header, +// `never` indicates that the Secure attribute will not be set, and `auto` will set +// the Secure attribute depending if **Always Use HTTPS** is enabled. +type WaitingRoomEditParamsCookieAttributesSecure string + +const ( + WaitingRoomEditParamsCookieAttributesSecureAuto WaitingRoomEditParamsCookieAttributesSecure = "auto" + WaitingRoomEditParamsCookieAttributesSecureAlways WaitingRoomEditParamsCookieAttributesSecure = "always" + WaitingRoomEditParamsCookieAttributesSecureNever WaitingRoomEditParamsCookieAttributesSecure = "never" +) + +// The language of the default page template. If no default_template_language is +// provided, then `en-US` (English) will be used. +type WaitingRoomEditParamsDefaultTemplateLanguage string + +const ( + WaitingRoomEditParamsDefaultTemplateLanguageEnUs WaitingRoomEditParamsDefaultTemplateLanguage = "en-US" + WaitingRoomEditParamsDefaultTemplateLanguageEsEs WaitingRoomEditParamsDefaultTemplateLanguage = "es-ES" + WaitingRoomEditParamsDefaultTemplateLanguageDeDe WaitingRoomEditParamsDefaultTemplateLanguage = "de-DE" + WaitingRoomEditParamsDefaultTemplateLanguageFrFr WaitingRoomEditParamsDefaultTemplateLanguage = "fr-FR" + WaitingRoomEditParamsDefaultTemplateLanguageItIt WaitingRoomEditParamsDefaultTemplateLanguage = "it-IT" + WaitingRoomEditParamsDefaultTemplateLanguageJaJp WaitingRoomEditParamsDefaultTemplateLanguage = "ja-JP" + WaitingRoomEditParamsDefaultTemplateLanguageKoKr WaitingRoomEditParamsDefaultTemplateLanguage = "ko-KR" + WaitingRoomEditParamsDefaultTemplateLanguagePtBr WaitingRoomEditParamsDefaultTemplateLanguage = "pt-BR" + WaitingRoomEditParamsDefaultTemplateLanguageZhCn WaitingRoomEditParamsDefaultTemplateLanguage = "zh-CN" + WaitingRoomEditParamsDefaultTemplateLanguageZhTw WaitingRoomEditParamsDefaultTemplateLanguage = "zh-TW" + WaitingRoomEditParamsDefaultTemplateLanguageNlNl WaitingRoomEditParamsDefaultTemplateLanguage = "nl-NL" + WaitingRoomEditParamsDefaultTemplateLanguagePlPl WaitingRoomEditParamsDefaultTemplateLanguage = "pl-PL" + WaitingRoomEditParamsDefaultTemplateLanguageIDID WaitingRoomEditParamsDefaultTemplateLanguage = "id-ID" + WaitingRoomEditParamsDefaultTemplateLanguageTrTr WaitingRoomEditParamsDefaultTemplateLanguage = "tr-TR" + WaitingRoomEditParamsDefaultTemplateLanguageArEg WaitingRoomEditParamsDefaultTemplateLanguage = "ar-EG" + WaitingRoomEditParamsDefaultTemplateLanguageRuRu WaitingRoomEditParamsDefaultTemplateLanguage = "ru-RU" + WaitingRoomEditParamsDefaultTemplateLanguageFaIr WaitingRoomEditParamsDefaultTemplateLanguage = "fa-IR" +) + +// Sets the queueing method used by the waiting room. Changing this parameter from +// the **default** queueing method is only available for the Waiting Room Advanced +// subscription. Regardless of the queueing method, if `queue_all` is enabled or an +// event is prequeueing, users in the waiting room will not be accepted to the +// origin. These users will always see a waiting room page that refreshes +// automatically. The valid queueing methods are: +// +// 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in +// the order they arrived. +// 2. `random`: Random queue where customers gain access randomly, regardless of +// arrival time. +// 3. `passthrough`: Users will pass directly through the waiting room and into the +// origin website. As a result, any configured limits will not be respected +// while this is enabled. This method can be used as an alternative to disabling +// a waiting room (with `suspended`) so that analytics are still reported. This +// can be used if you wish to allow all traffic normally, but want to restrict +// traffic during a waiting room event, or vice versa. +// 4. `reject`: Users will be immediately rejected from the waiting room. As a +// result, no users will reach the origin website while this is enabled. This +// can be used if you wish to reject all traffic while performing maintenance, +// block traffic during a specified period of time (an event), or block traffic +// while events are not occurring. Consider a waiting room used for vaccine +// distribution that only allows traffic during sign-up events, and otherwise +// blocks all traffic. For this case, the waiting room uses `reject`, and its +// events override this with `fifo`, `random`, or `passthrough`. When this +// queueing method is enabled and neither `queueAll` is enabled nor an event is +// prequeueing, the waiting room page **will not refresh automatically**. +type WaitingRoomEditParamsQueueingMethod string + +const ( + WaitingRoomEditParamsQueueingMethodFifo WaitingRoomEditParamsQueueingMethod = "fifo" + WaitingRoomEditParamsQueueingMethodRandom WaitingRoomEditParamsQueueingMethod = "random" + WaitingRoomEditParamsQueueingMethodPassthrough WaitingRoomEditParamsQueueingMethod = "passthrough" + WaitingRoomEditParamsQueueingMethodReject WaitingRoomEditParamsQueueingMethod = "reject" +) + +// HTTP status code returned to a user while in the queue. +type WaitingRoomEditParamsQueueingStatusCode int64 + +const ( + WaitingRoomEditParamsQueueingStatusCode200 WaitingRoomEditParamsQueueingStatusCode = 200 + WaitingRoomEditParamsQueueingStatusCode202 WaitingRoomEditParamsQueueingStatusCode = 202 + WaitingRoomEditParamsQueueingStatusCode429 WaitingRoomEditParamsQueueingStatusCode = 429 +) + +type WaitingRoomEditResponseEnvelope struct { + Result WaitingroomWaitingroom `json:"result,required"` + JSON waitingRoomEditResponseEnvelopeJSON `json:"-"` +} + +// waitingRoomEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [WaitingRoomEditResponseEnvelope] +type waitingRoomEditResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WaitingRoomEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingRoomEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WaitingRoomGetResponseEnvelope struct { + Result WaitingroomWaitingroom `json:"result,required"` + JSON waitingRoomGetResponseEnvelopeJSON `json:"-"` +} + +// waitingRoomGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [WaitingRoomGetResponseEnvelope] +type waitingRoomGetResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WaitingRoomGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingRoomGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WaitingRoomPreviewParams struct { + // Only available for the Waiting Room Advanced subscription. This is a template + // html file that will be rendered at the edge. If no custom_page_html is provided, + // the default waiting room will be used. The template is based on mustache ( + // https://mustache.github.io/ ). There are several variables that are evaluated by + // the Cloudflare edge: + // + // 1. {{`waitTimeKnown`}} Acts like a boolean value that indicates the behavior to + // take when wait time is not available, for instance when queue_all is + // **true**. + // 2. {{`waitTimeFormatted`}} Estimated wait time for the user. For example, five + // minutes. Alternatively, you can use: + // 3. {{`waitTime`}} Number of minutes of estimated wait for a user. + // 4. {{`waitTimeHours`}} Number of hours of estimated wait for a user + // (`Math.floor(waitTime/60)`). + // 5. {{`waitTimeHourMinutes`}} Number of minutes above the `waitTimeHours` value + // (`waitTime%60`). + // 6. {{`queueIsFull`}} Changes to **true** when no more people can be added to the + // queue. + // + // To view the full list of variables, look at the `cfWaitingRoom` object described + // under the `json_response_enabled` property in other Waiting Room API calls. + CustomHTML param.Field[string] `json:"custom_html,required"` +} + +func (r WaitingRoomPreviewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type WaitingRoomPreviewResponseEnvelope struct { + Result WaitingRoomPreviewResponse `json:"result,required"` + JSON waitingRoomPreviewResponseEnvelopeJSON `json:"-"` +} + +// waitingRoomPreviewResponseEnvelopeJSON contains the JSON metadata for the struct +// [WaitingRoomPreviewResponseEnvelope] +type waitingRoomPreviewResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WaitingRoomPreviewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r waitingRoomPreviewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} diff --git a/waitingroom_test.go b/waiting_rooms/waitingroom_test.go similarity index 80% rename from waitingroom_test.go rename to waiting_rooms/waitingroom_test.go index 9ba2d3a5c54..ba2d438d0fb 100644 --- a/waitingroom_test.go +++ b/waiting_rooms/waitingroom_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package waiting_rooms_test import ( "context" @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/waiting_rooms" ) func TestWaitingRoomNewWithOptionalParams(t *testing.T) { @@ -30,12 +31,12 @@ func TestWaitingRoomNewWithOptionalParams(t *testing.T) { _, err := client.WaitingRooms.New( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.WaitingRoomNewParams{ + waiting_rooms.WaitingRoomNewParams{ Host: cloudflare.F("shop.example.com"), Name: cloudflare.F("production_webinar"), NewUsersPerMinute: cloudflare.F(int64(200)), TotalActiveUsers: cloudflare.F(int64(200)), - AdditionalRoutes: cloudflare.F([]cloudflare.WaitingRoomNewParamsAdditionalRoute{{ + AdditionalRoutes: cloudflare.F([]waiting_rooms.WaitingRoomNewParamsAdditionalRoute{{ Host: cloudflare.F("shop2.example.com"), Path: cloudflare.F("/shop2/checkout"), }, { @@ -45,20 +46,20 @@ func TestWaitingRoomNewWithOptionalParams(t *testing.T) { Host: cloudflare.F("shop2.example.com"), Path: cloudflare.F("/shop2/checkout"), }}), - CookieAttributes: cloudflare.F(cloudflare.WaitingRoomNewParamsCookieAttributes{ - Samesite: cloudflare.F(cloudflare.WaitingRoomNewParamsCookieAttributesSamesiteAuto), - Secure: cloudflare.F(cloudflare.WaitingRoomNewParamsCookieAttributesSecureAuto), + CookieAttributes: cloudflare.F(waiting_rooms.WaitingRoomNewParamsCookieAttributes{ + Samesite: cloudflare.F(waiting_rooms.WaitingRoomNewParamsCookieAttributesSamesiteAuto), + Secure: cloudflare.F(waiting_rooms.WaitingRoomNewParamsCookieAttributesSecureAuto), }), CookieSuffix: cloudflare.F("abcd"), CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Queue all enabled {{/waitTimeKnown}}"), - DefaultTemplateLanguage: cloudflare.F(cloudflare.WaitingRoomNewParamsDefaultTemplateLanguageEsEs), + DefaultTemplateLanguage: cloudflare.F(waiting_rooms.WaitingRoomNewParamsDefaultTemplateLanguageEsEs), Description: cloudflare.F("Production - DO NOT MODIFY"), DisableSessionRenewal: cloudflare.F(false), JsonResponseEnabled: cloudflare.F(false), Path: cloudflare.F("/shop/checkout"), QueueAll: cloudflare.F(true), - QueueingMethod: cloudflare.F(cloudflare.WaitingRoomNewParamsQueueingMethodFifo), - QueueingStatusCode: cloudflare.F(cloudflare.WaitingRoomNewParamsQueueingStatusCode202), + QueueingMethod: cloudflare.F(waiting_rooms.WaitingRoomNewParamsQueueingMethodFifo), + QueueingStatusCode: cloudflare.F(waiting_rooms.WaitingRoomNewParamsQueueingStatusCode202), SessionDuration: cloudflare.F(int64(1)), Suspended: cloudflare.F(true), }, @@ -90,12 +91,12 @@ func TestWaitingRoomUpdateWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", - cloudflare.WaitingRoomUpdateParams{ + waiting_rooms.WaitingRoomUpdateParams{ Host: cloudflare.F("shop.example.com"), Name: cloudflare.F("production_webinar"), NewUsersPerMinute: cloudflare.F(int64(200)), TotalActiveUsers: cloudflare.F(int64(200)), - AdditionalRoutes: cloudflare.F([]cloudflare.WaitingRoomUpdateParamsAdditionalRoute{{ + AdditionalRoutes: cloudflare.F([]waiting_rooms.WaitingRoomUpdateParamsAdditionalRoute{{ Host: cloudflare.F("shop2.example.com"), Path: cloudflare.F("/shop2/checkout"), }, { @@ -105,20 +106,20 @@ func TestWaitingRoomUpdateWithOptionalParams(t *testing.T) { Host: cloudflare.F("shop2.example.com"), Path: cloudflare.F("/shop2/checkout"), }}), - CookieAttributes: cloudflare.F(cloudflare.WaitingRoomUpdateParamsCookieAttributes{ - Samesite: cloudflare.F(cloudflare.WaitingRoomUpdateParamsCookieAttributesSamesiteAuto), - Secure: cloudflare.F(cloudflare.WaitingRoomUpdateParamsCookieAttributesSecureAuto), + CookieAttributes: cloudflare.F(waiting_rooms.WaitingRoomUpdateParamsCookieAttributes{ + Samesite: cloudflare.F(waiting_rooms.WaitingRoomUpdateParamsCookieAttributesSamesiteAuto), + Secure: cloudflare.F(waiting_rooms.WaitingRoomUpdateParamsCookieAttributesSecureAuto), }), CookieSuffix: cloudflare.F("abcd"), CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Queue all enabled {{/waitTimeKnown}}"), - DefaultTemplateLanguage: cloudflare.F(cloudflare.WaitingRoomUpdateParamsDefaultTemplateLanguageEsEs), + DefaultTemplateLanguage: cloudflare.F(waiting_rooms.WaitingRoomUpdateParamsDefaultTemplateLanguageEsEs), Description: cloudflare.F("Production - DO NOT MODIFY"), DisableSessionRenewal: cloudflare.F(false), JsonResponseEnabled: cloudflare.F(false), Path: cloudflare.F("/shop/checkout"), QueueAll: cloudflare.F(true), - QueueingMethod: cloudflare.F(cloudflare.WaitingRoomUpdateParamsQueueingMethodFifo), - QueueingStatusCode: cloudflare.F(cloudflare.WaitingRoomUpdateParamsQueueingStatusCode202), + QueueingMethod: cloudflare.F(waiting_rooms.WaitingRoomUpdateParamsQueueingMethodFifo), + QueueingStatusCode: cloudflare.F(waiting_rooms.WaitingRoomUpdateParamsQueueingStatusCode202), SessionDuration: cloudflare.F(int64(1)), Suspended: cloudflare.F(true), }, @@ -202,12 +203,12 @@ func TestWaitingRoomEditWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", "699d98642c564d2e855e9661899b7252", - cloudflare.WaitingRoomEditParams{ + waiting_rooms.WaitingRoomEditParams{ Host: cloudflare.F("shop.example.com"), Name: cloudflare.F("production_webinar"), NewUsersPerMinute: cloudflare.F(int64(200)), TotalActiveUsers: cloudflare.F(int64(200)), - AdditionalRoutes: cloudflare.F([]cloudflare.WaitingRoomEditParamsAdditionalRoute{{ + AdditionalRoutes: cloudflare.F([]waiting_rooms.WaitingRoomEditParamsAdditionalRoute{{ Host: cloudflare.F("shop2.example.com"), Path: cloudflare.F("/shop2/checkout"), }, { @@ -217,20 +218,20 @@ func TestWaitingRoomEditWithOptionalParams(t *testing.T) { Host: cloudflare.F("shop2.example.com"), Path: cloudflare.F("/shop2/checkout"), }}), - CookieAttributes: cloudflare.F(cloudflare.WaitingRoomEditParamsCookieAttributes{ - Samesite: cloudflare.F(cloudflare.WaitingRoomEditParamsCookieAttributesSamesiteAuto), - Secure: cloudflare.F(cloudflare.WaitingRoomEditParamsCookieAttributesSecureAuto), + CookieAttributes: cloudflare.F(waiting_rooms.WaitingRoomEditParamsCookieAttributes{ + Samesite: cloudflare.F(waiting_rooms.WaitingRoomEditParamsCookieAttributesSamesiteAuto), + Secure: cloudflare.F(waiting_rooms.WaitingRoomEditParamsCookieAttributesSecureAuto), }), CookieSuffix: cloudflare.F("abcd"), CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Queue all enabled {{/waitTimeKnown}}"), - DefaultTemplateLanguage: cloudflare.F(cloudflare.WaitingRoomEditParamsDefaultTemplateLanguageEsEs), + DefaultTemplateLanguage: cloudflare.F(waiting_rooms.WaitingRoomEditParamsDefaultTemplateLanguageEsEs), Description: cloudflare.F("Production - DO NOT MODIFY"), DisableSessionRenewal: cloudflare.F(false), JsonResponseEnabled: cloudflare.F(false), Path: cloudflare.F("/shop/checkout"), QueueAll: cloudflare.F(true), - QueueingMethod: cloudflare.F(cloudflare.WaitingRoomEditParamsQueueingMethodFifo), - QueueingStatusCode: cloudflare.F(cloudflare.WaitingRoomEditParamsQueueingStatusCode202), + QueueingMethod: cloudflare.F(waiting_rooms.WaitingRoomEditParamsQueueingMethodFifo), + QueueingStatusCode: cloudflare.F(waiting_rooms.WaitingRoomEditParamsQueueingStatusCode202), SessionDuration: cloudflare.F(int64(1)), Suspended: cloudflare.F(true), }, @@ -289,7 +290,7 @@ func TestWaitingRoomPreview(t *testing.T) { _, err := client.WaitingRooms.Preview( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.WaitingRoomPreviewParams{ + waiting_rooms.WaitingRoomPreviewParams{ CustomHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Queue all enabled {{/waitTimeKnown}}"), }, ) diff --git a/waitingroom.go b/waitingroom.go deleted file mode 100644 index afcbb84fece..00000000000 --- a/waitingroom.go +++ /dev/null @@ -1,3965 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WaitingRoomService 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 [NewWaitingRoomService] method -// instead. -type WaitingRoomService struct { - Options []option.RequestOption - Events *WaitingRoomEventService - Rules *WaitingRoomRuleService - Statuses *WaitingRoomStatusService - Settings *WaitingRoomSettingService -} - -// NewWaitingRoomService 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 NewWaitingRoomService(opts ...option.RequestOption) (r *WaitingRoomService) { - r = &WaitingRoomService{} - r.Options = opts - r.Events = NewWaitingRoomEventService(opts...) - r.Rules = NewWaitingRoomRuleService(opts...) - r.Statuses = NewWaitingRoomStatusService(opts...) - r.Settings = NewWaitingRoomSettingService(opts...) - return -} - -// Creates a new waiting room. -func (r *WaitingRoomService) New(ctx context.Context, zoneIdentifier string, body WaitingRoomNewParams, opts ...option.RequestOption) (res *WaitingRoomNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomNewResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a configured waiting room. -func (r *WaitingRoomService) Update(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body WaitingRoomUpdateParams, opts ...option.RequestOption) (res *WaitingRoomUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%v", zoneIdentifier, waitingRoomID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists waiting rooms. -func (r *WaitingRoomService) List(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *[]WaitingRoomListResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomListResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a waiting room. -func (r *WaitingRoomService) Delete(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, opts ...option.RequestOption) (res *WaitingRoomDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%v", zoneIdentifier, waitingRoomID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Patches a configured waiting room. -func (r *WaitingRoomService) Edit(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body WaitingRoomEditParams, opts ...option.RequestOption) (res *WaitingRoomEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomEditResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%v", zoneIdentifier, waitingRoomID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a single configured waiting room. -func (r *WaitingRoomService) Get(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, opts ...option.RequestOption) (res *WaitingRoomGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomGetResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%v", zoneIdentifier, waitingRoomID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Creates a waiting room page preview. Upload a custom waiting room page for -// preview. You will receive a preview URL in the form -// `http://waitingrooms.dev/preview/`. You can use the following query -// parameters to change the state of the preview: -// -// 1. `force_queue`: Boolean indicating if all users will be queued in the waiting -// room and no one will be let into the origin website (also known as queueAll). -// 2. `queue_is_full`: Boolean indicating if the waiting room's queue is currently -// full and not accepting new users at the moment. -// 3. `queueing_method`: The queueing method currently used by the waiting room. -// - **fifo** indicates a FIFO queue. -// - **random** indicates a Random queue. -// - **passthrough** indicates a Passthrough queue. Keep in mind that the -// waiting room page will only be displayed if `force_queue=true` or -// `event=prequeueing` — for other cases the request will pass through to the -// origin. For our preview, this will be a fake origin website returning -// "Welcome". -// - **reject** indicates a Reject queue. -// 4. `event`: Used to preview a waiting room event. -// - **none** indicates no event is occurring. -// - **prequeueing** indicates that an event is prequeueing (between -// `prequeue_start_time` and `event_start_time`). -// - **started** indicates that an event has started (between `event_start_time` -// and `event_end_time`). -// 5. `shuffle_at_event_start`: Boolean indicating if the event will shuffle users -// in the prequeue when it starts. This can only be set to **true** if an event -// is active (`event` is not **none**). -// -// For example, you can make a request to -// `http://waitingrooms.dev/preview/?force_queue=false&queue_is_full=false&queueing_method=random&event=started&shuffle_at_event_start=true` 6. -// `waitTime`: Non-zero, positive integer indicating the estimated wait time in -// minutes. The default value is 10 minutes. -// -// For example, you can make a request to -// `http://waitingrooms.dev/preview/?waitTime=50` to configure the estimated -// wait time as 50 minutes. -func (r *WaitingRoomService) Preview(ctx context.Context, zoneIdentifier string, body WaitingRoomPreviewParams, opts ...option.RequestOption) (res *WaitingRoomPreviewResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomPreviewResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/preview", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WaitingRoomNewResponse struct { - ID interface{} `json:"id"` - // Only available for the Waiting Room Advanced subscription. Additional hostname - // and path combinations to which this waiting room will be applied. There is an - // implied wildcard at the end of the path. The hostname and path combination must - // be unique to this and all other waiting rooms. - AdditionalRoutes []WaitingRoomNewResponseAdditionalRoute `json:"additional_routes"` - // Configures cookie attributes for the waiting room cookie. This encrypted cookie - // stores a user's status in the waiting room, such as queue position. - CookieAttributes WaitingRoomNewResponseCookieAttributes `json:"cookie_attributes"` - // Appends a '\_' + a custom suffix to the end of Cloudflare Waiting Room's cookie - // name(**cf_waitingroom). If `cookie_suffix` is "abcd", the cookie name will be - // `**cf_waitingroom_abcd`. This field is required if using `additional_routes`. - CookieSuffix string `json:"cookie_suffix"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Only available for the Waiting Room Advanced subscription. This is a template - // html file that will be rendered at the edge. If no custom_page_html is provided, - // the default waiting room will be used. The template is based on mustache ( - // https://mustache.github.io/ ). There are several variables that are evaluated by - // the Cloudflare edge: - // - // 1. {{`waitTimeKnown`}} Acts like a boolean value that indicates the behavior to - // take when wait time is not available, for instance when queue_all is - // **true**. - // 2. {{`waitTimeFormatted`}} Estimated wait time for the user. For example, five - // minutes. Alternatively, you can use: - // 3. {{`waitTime`}} Number of minutes of estimated wait for a user. - // 4. {{`waitTimeHours`}} Number of hours of estimated wait for a user - // (`Math.floor(waitTime/60)`). - // 5. {{`waitTimeHourMinutes`}} Number of minutes above the `waitTimeHours` value - // (`waitTime%60`). - // 6. {{`queueIsFull`}} Changes to **true** when no more people can be added to the - // queue. - // - // To view the full list of variables, look at the `cfWaitingRoom` object described - // under the `json_response_enabled` property in other Waiting Room API calls. - CustomPageHTML string `json:"custom_page_html"` - // The language of the default page template. If no default_template_language is - // provided, then `en-US` (English) will be used. - DefaultTemplateLanguage WaitingRoomNewResponseDefaultTemplateLanguage `json:"default_template_language"` - // A note that you can use to add more details about the waiting room. - Description string `json:"description"` - // Only available for the Waiting Room Advanced subscription. Disables automatic - // renewal of session cookies. If `true`, an accepted user will have - // session_duration minutes to browse the site. After that, they will have to go - // through the waiting room again. If `false`, a user's session cookie will be - // automatically renewed on every request. - DisableSessionRenewal bool `json:"disable_session_renewal"` - // The host name to which the waiting room will be applied (no wildcards). Please - // do not include the scheme (http:// or https://). The host and path combination - // must be unique. - Host string `json:"host"` - // Only available for the Waiting Room Advanced subscription. If `true`, requests - // to the waiting room with the header `Accept: application/json` will receive a - // JSON response object with information on the user's status in the waiting room - // as opposed to the configured static HTML page. This JSON response object has one - // property `cfWaitingRoom` which is an object containing the following fields: - // - // 1. `inWaitingRoom`: Boolean indicating if the user is in the waiting room - // (always **true**). - // 2. `waitTimeKnown`: Boolean indicating if the current estimated wait times are - // accurate. If **false**, they are not available. - // 3. `waitTime`: Valid only when `waitTimeKnown` is **true**. Integer indicating - // the current estimated time in minutes the user will wait in the waiting room. - // When `queueingMethod` is **random**, this is set to `waitTime50Percentile`. - // 4. `waitTime25Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 25% of users that gain entry the fastest (25th percentile). - // 5. `waitTime50Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 50% of users that gain entry the fastest (50th percentile). - // In other words, half of the queued users are expected to let into the origin - // website before `waitTime50Percentile` and half are expected to be let in - // after it. - // 6. `waitTime75Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 75% of users that gain entry the fastest (75th percentile). - // 7. `waitTimeFormatted`: String displaying the `waitTime` formatted in English - // for users. If `waitTimeKnown` is **false**, `waitTimeFormatted` will display - // **unavailable**. - // 8. `queueIsFull`: Boolean indicating if the waiting room's queue is currently - // full and not accepting new users at the moment. - // 9. `queueAll`: Boolean indicating if all users will be queued in the waiting - // room and no one will be let into the origin website. - // 10. `lastUpdated`: String displaying the timestamp as an ISO 8601 string of the - // user's last attempt to leave the waiting room and be let into the origin - // website. The user is able to make another attempt after - // `refreshIntervalSeconds` past this time. If the user makes a request too - // soon, it will be ignored and `lastUpdated` will not change. - // 11. `refreshIntervalSeconds`: Integer indicating the number of seconds after - // `lastUpdated` until the user is able to make another attempt to leave the - // waiting room and be let into the origin website. When the `queueingMethod` - // is `reject`, there is no specified refresh time — it will always be - // **zero**. - // 12. `queueingMethod`: The queueing method currently used by the waiting room. It - // is either **fifo**, **random**, **passthrough**, or **reject**. - // 13. `isFIFOQueue`: Boolean indicating if the waiting room uses a FIFO - // (First-In-First-Out) queue. - // 14. `isRandomQueue`: Boolean indicating if the waiting room uses a Random queue - // where users gain access randomly. - // 15. `isPassthroughQueue`: Boolean indicating if the waiting room uses a - // passthrough queue. Keep in mind that when passthrough is enabled, this JSON - // response will only exist when `queueAll` is **true** or `isEventPrequeueing` - // is **true** because in all other cases requests will go directly to the - // origin. - // 16. `isRejectQueue`: Boolean indicating if the waiting room uses a reject queue. - // 17. `isEventActive`: Boolean indicating if an event is currently occurring. - // Events are able to change a waiting room's behavior during a specified - // period of time. For additional information, look at the event properties - // `prequeue_start_time`, `event_start_time`, and `event_end_time` in the - // documentation for creating waiting room events. Events are considered active - // between these start and end times, as well as during the prequeueing period - // if it exists. - // 18. `isEventPrequeueing`: Valid only when `isEventActive` is **true**. Boolean - // indicating if an event is currently prequeueing users before it starts. - // 19. `timeUntilEventStart`: Valid only when `isEventPrequeueing` is **true**. - // Integer indicating the number of minutes until the event starts. - // 20. `timeUntilEventStartFormatted`: String displaying the `timeUntilEventStart` - // formatted in English for users. If `isEventPrequeueing` is **false**, - // `timeUntilEventStartFormatted` will display **unavailable**. - // 21. `timeUntilEventEnd`: Valid only when `isEventActive` is **true**. Integer - // indicating the number of minutes until the event ends. - // 22. `timeUntilEventEndFormatted`: String displaying the `timeUntilEventEnd` - // formatted in English for users. If `isEventActive` is **false**, - // `timeUntilEventEndFormatted` will display **unavailable**. - // 23. `shuffleAtEventStart`: Valid only when `isEventActive` is **true**. Boolean - // indicating if the users in the prequeue are shuffled randomly when the event - // starts. - // - // An example cURL to a waiting room could be: - // - // curl -X GET "https://example.com/waitingroom" \ - // -H "Accept: application/json" - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **fifo** and no event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 0, - // "waitTime50Percentile": 0, - // "waitTime75Percentile": 0, - // "waitTimeFormatted": "10 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "fifo", - // "isFIFOQueue": true, - // "isRandomQueue": false, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": false, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 0, - // "timeUntilEventEndFormatted": "unavailable", - // "shuffleAtEventStart": false - // } - // } - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **random** and an event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 5, - // "waitTime50Percentile": 10, - // "waitTime75Percentile": 15, - // "waitTimeFormatted": "5 minutes to 15 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "random", - // "isFIFOQueue": false, - // "isRandomQueue": true, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": true, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 15, - // "timeUntilEventEndFormatted": "15 minutes", - // "shuffleAtEventStart": true - // } - // }. - JsonResponseEnabled bool `json:"json_response_enabled"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A unique name to identify the waiting room. Only alphanumeric characters, - // hyphens and underscores are allowed. - Name string `json:"name"` - // Sets the number of new users that will be let into the route every minute. This - // value is used as baseline for the number of users that are let in per minute. So - // it is possible that there is a little more or little less traffic coming to the - // route based on the traffic patterns at that time around the world. - NewUsersPerMinute int64 `json:"new_users_per_minute"` - // An ISO 8601 timestamp that marks when the next event will begin queueing. - NextEventPrequeueStartTime string `json:"next_event_prequeue_start_time,nullable"` - // An ISO 8601 timestamp that marks when the next event will start. - NextEventStartTime string `json:"next_event_start_time,nullable"` - // Sets the path within the host to enable the waiting room on. The waiting room - // will be enabled for all subpaths as well. If there are two waiting rooms on the - // same subpath, the waiting room for the most specific path will be chosen. - // Wildcards and query parameters are not supported. - Path string `json:"path"` - // If queue_all is `true`, all the traffic that is coming to a route will be sent - // to the waiting room. No new traffic can get to the route once this field is set - // and estimated time will become unavailable. - QueueAll bool `json:"queue_all"` - // Sets the queueing method used by the waiting room. Changing this parameter from - // the **default** queueing method is only available for the Waiting Room Advanced - // subscription. Regardless of the queueing method, if `queue_all` is enabled or an - // event is prequeueing, users in the waiting room will not be accepted to the - // origin. These users will always see a waiting room page that refreshes - // automatically. The valid queueing methods are: - // - // 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in - // the order they arrived. - // 2. `random`: Random queue where customers gain access randomly, regardless of - // arrival time. - // 3. `passthrough`: Users will pass directly through the waiting room and into the - // origin website. As a result, any configured limits will not be respected - // while this is enabled. This method can be used as an alternative to disabling - // a waiting room (with `suspended`) so that analytics are still reported. This - // can be used if you wish to allow all traffic normally, but want to restrict - // traffic during a waiting room event, or vice versa. - // 4. `reject`: Users will be immediately rejected from the waiting room. As a - // result, no users will reach the origin website while this is enabled. This - // can be used if you wish to reject all traffic while performing maintenance, - // block traffic during a specified period of time (an event), or block traffic - // while events are not occurring. Consider a waiting room used for vaccine - // distribution that only allows traffic during sign-up events, and otherwise - // blocks all traffic. For this case, the waiting room uses `reject`, and its - // events override this with `fifo`, `random`, or `passthrough`. When this - // queueing method is enabled and neither `queueAll` is enabled nor an event is - // prequeueing, the waiting room page **will not refresh automatically**. - QueueingMethod WaitingRoomNewResponseQueueingMethod `json:"queueing_method"` - // HTTP status code returned to a user while in the queue. - QueueingStatusCode WaitingRoomNewResponseQueueingStatusCode `json:"queueing_status_code"` - // Lifetime of a cookie (in minutes) set by Cloudflare for users who get access to - // the route. If a user is not seen by Cloudflare again in that time period, they - // will be treated as a new user that visits the route. - SessionDuration int64 `json:"session_duration"` - // Suspends or allows traffic going to the waiting room. If set to `true`, the - // traffic will not go to the waiting room. - Suspended bool `json:"suspended"` - // Sets the total number of active user sessions on the route at a point in time. A - // route is a combination of host and path on which a waiting room is available. - // This value is used as a baseline for the total number of active user sessions on - // the route. It is possible to have a situation where there are more or less - // active users sessions on the route based on the traffic patterns at that time - // around the world. - TotalActiveUsers int64 `json:"total_active_users"` - JSON waitingRoomNewResponseJSON `json:"-"` -} - -// waitingRoomNewResponseJSON contains the JSON metadata for the struct -// [WaitingRoomNewResponse] -type waitingRoomNewResponseJSON struct { - ID apijson.Field - AdditionalRoutes apijson.Field - CookieAttributes apijson.Field - CookieSuffix apijson.Field - CreatedOn apijson.Field - CustomPageHTML apijson.Field - DefaultTemplateLanguage apijson.Field - Description apijson.Field - DisableSessionRenewal apijson.Field - Host apijson.Field - JsonResponseEnabled apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - NewUsersPerMinute apijson.Field - NextEventPrequeueStartTime apijson.Field - NextEventStartTime apijson.Field - Path apijson.Field - QueueAll apijson.Field - QueueingMethod apijson.Field - QueueingStatusCode apijson.Field - SessionDuration apijson.Field - Suspended apijson.Field - TotalActiveUsers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomNewResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomNewResponseAdditionalRoute struct { - // The hostname to which this waiting room will be applied (no wildcards). The - // hostname must be the primary domain, subdomain, or custom hostname (if using SSL - // for SaaS) of this zone. Please do not include the scheme (http:// or https://). - Host string `json:"host"` - // Sets the path within the host to enable the waiting room on. The waiting room - // will be enabled for all subpaths as well. If there are two waiting rooms on the - // same subpath, the waiting room for the most specific path will be chosen. - // Wildcards and query parameters are not supported. - Path string `json:"path"` - JSON waitingRoomNewResponseAdditionalRouteJSON `json:"-"` -} - -// waitingRoomNewResponseAdditionalRouteJSON contains the JSON metadata for the -// struct [WaitingRoomNewResponseAdditionalRoute] -type waitingRoomNewResponseAdditionalRouteJSON struct { - Host apijson.Field - Path apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomNewResponseAdditionalRoute) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomNewResponseAdditionalRouteJSON) RawJSON() string { - return r.raw -} - -// Configures cookie attributes for the waiting room cookie. This encrypted cookie -// stores a user's status in the waiting room, such as queue position. -type WaitingRoomNewResponseCookieAttributes struct { - // Configures the SameSite attribute on the waiting room cookie. Value `auto` will - // be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. - // Note that when using value `none`, the secure attribute cannot be set to - // `never`. - Samesite WaitingRoomNewResponseCookieAttributesSamesite `json:"samesite"` - // Configures the Secure attribute on the waiting room cookie. Value `always` - // indicates that the Secure attribute will be set in the Set-Cookie header, - // `never` indicates that the Secure attribute will not be set, and `auto` will set - // the Secure attribute depending if **Always Use HTTPS** is enabled. - Secure WaitingRoomNewResponseCookieAttributesSecure `json:"secure"` - JSON waitingRoomNewResponseCookieAttributesJSON `json:"-"` -} - -// waitingRoomNewResponseCookieAttributesJSON contains the JSON metadata for the -// struct [WaitingRoomNewResponseCookieAttributes] -type waitingRoomNewResponseCookieAttributesJSON struct { - Samesite apijson.Field - Secure apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomNewResponseCookieAttributes) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomNewResponseCookieAttributesJSON) RawJSON() string { - return r.raw -} - -// Configures the SameSite attribute on the waiting room cookie. Value `auto` will -// be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. -// Note that when using value `none`, the secure attribute cannot be set to -// `never`. -type WaitingRoomNewResponseCookieAttributesSamesite string - -const ( - WaitingRoomNewResponseCookieAttributesSamesiteAuto WaitingRoomNewResponseCookieAttributesSamesite = "auto" - WaitingRoomNewResponseCookieAttributesSamesiteLax WaitingRoomNewResponseCookieAttributesSamesite = "lax" - WaitingRoomNewResponseCookieAttributesSamesiteNone WaitingRoomNewResponseCookieAttributesSamesite = "none" - WaitingRoomNewResponseCookieAttributesSamesiteStrict WaitingRoomNewResponseCookieAttributesSamesite = "strict" -) - -// Configures the Secure attribute on the waiting room cookie. Value `always` -// indicates that the Secure attribute will be set in the Set-Cookie header, -// `never` indicates that the Secure attribute will not be set, and `auto` will set -// the Secure attribute depending if **Always Use HTTPS** is enabled. -type WaitingRoomNewResponseCookieAttributesSecure string - -const ( - WaitingRoomNewResponseCookieAttributesSecureAuto WaitingRoomNewResponseCookieAttributesSecure = "auto" - WaitingRoomNewResponseCookieAttributesSecureAlways WaitingRoomNewResponseCookieAttributesSecure = "always" - WaitingRoomNewResponseCookieAttributesSecureNever WaitingRoomNewResponseCookieAttributesSecure = "never" -) - -// The language of the default page template. If no default_template_language is -// provided, then `en-US` (English) will be used. -type WaitingRoomNewResponseDefaultTemplateLanguage string - -const ( - WaitingRoomNewResponseDefaultTemplateLanguageEnUs WaitingRoomNewResponseDefaultTemplateLanguage = "en-US" - WaitingRoomNewResponseDefaultTemplateLanguageEsEs WaitingRoomNewResponseDefaultTemplateLanguage = "es-ES" - WaitingRoomNewResponseDefaultTemplateLanguageDeDe WaitingRoomNewResponseDefaultTemplateLanguage = "de-DE" - WaitingRoomNewResponseDefaultTemplateLanguageFrFr WaitingRoomNewResponseDefaultTemplateLanguage = "fr-FR" - WaitingRoomNewResponseDefaultTemplateLanguageItIt WaitingRoomNewResponseDefaultTemplateLanguage = "it-IT" - WaitingRoomNewResponseDefaultTemplateLanguageJaJp WaitingRoomNewResponseDefaultTemplateLanguage = "ja-JP" - WaitingRoomNewResponseDefaultTemplateLanguageKoKr WaitingRoomNewResponseDefaultTemplateLanguage = "ko-KR" - WaitingRoomNewResponseDefaultTemplateLanguagePtBr WaitingRoomNewResponseDefaultTemplateLanguage = "pt-BR" - WaitingRoomNewResponseDefaultTemplateLanguageZhCn WaitingRoomNewResponseDefaultTemplateLanguage = "zh-CN" - WaitingRoomNewResponseDefaultTemplateLanguageZhTw WaitingRoomNewResponseDefaultTemplateLanguage = "zh-TW" - WaitingRoomNewResponseDefaultTemplateLanguageNlNl WaitingRoomNewResponseDefaultTemplateLanguage = "nl-NL" - WaitingRoomNewResponseDefaultTemplateLanguagePlPl WaitingRoomNewResponseDefaultTemplateLanguage = "pl-PL" - WaitingRoomNewResponseDefaultTemplateLanguageIDID WaitingRoomNewResponseDefaultTemplateLanguage = "id-ID" - WaitingRoomNewResponseDefaultTemplateLanguageTrTr WaitingRoomNewResponseDefaultTemplateLanguage = "tr-TR" - WaitingRoomNewResponseDefaultTemplateLanguageArEg WaitingRoomNewResponseDefaultTemplateLanguage = "ar-EG" - WaitingRoomNewResponseDefaultTemplateLanguageRuRu WaitingRoomNewResponseDefaultTemplateLanguage = "ru-RU" - WaitingRoomNewResponseDefaultTemplateLanguageFaIr WaitingRoomNewResponseDefaultTemplateLanguage = "fa-IR" -) - -// Sets the queueing method used by the waiting room. Changing this parameter from -// the **default** queueing method is only available for the Waiting Room Advanced -// subscription. Regardless of the queueing method, if `queue_all` is enabled or an -// event is prequeueing, users in the waiting room will not be accepted to the -// origin. These users will always see a waiting room page that refreshes -// automatically. The valid queueing methods are: -// -// 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in -// the order they arrived. -// 2. `random`: Random queue where customers gain access randomly, regardless of -// arrival time. -// 3. `passthrough`: Users will pass directly through the waiting room and into the -// origin website. As a result, any configured limits will not be respected -// while this is enabled. This method can be used as an alternative to disabling -// a waiting room (with `suspended`) so that analytics are still reported. This -// can be used if you wish to allow all traffic normally, but want to restrict -// traffic during a waiting room event, or vice versa. -// 4. `reject`: Users will be immediately rejected from the waiting room. As a -// result, no users will reach the origin website while this is enabled. This -// can be used if you wish to reject all traffic while performing maintenance, -// block traffic during a specified period of time (an event), or block traffic -// while events are not occurring. Consider a waiting room used for vaccine -// distribution that only allows traffic during sign-up events, and otherwise -// blocks all traffic. For this case, the waiting room uses `reject`, and its -// events override this with `fifo`, `random`, or `passthrough`. When this -// queueing method is enabled and neither `queueAll` is enabled nor an event is -// prequeueing, the waiting room page **will not refresh automatically**. -type WaitingRoomNewResponseQueueingMethod string - -const ( - WaitingRoomNewResponseQueueingMethodFifo WaitingRoomNewResponseQueueingMethod = "fifo" - WaitingRoomNewResponseQueueingMethodRandom WaitingRoomNewResponseQueueingMethod = "random" - WaitingRoomNewResponseQueueingMethodPassthrough WaitingRoomNewResponseQueueingMethod = "passthrough" - WaitingRoomNewResponseQueueingMethodReject WaitingRoomNewResponseQueueingMethod = "reject" -) - -// HTTP status code returned to a user while in the queue. -type WaitingRoomNewResponseQueueingStatusCode int64 - -const ( - WaitingRoomNewResponseQueueingStatusCode200 WaitingRoomNewResponseQueueingStatusCode = 200 - WaitingRoomNewResponseQueueingStatusCode202 WaitingRoomNewResponseQueueingStatusCode = 202 - WaitingRoomNewResponseQueueingStatusCode429 WaitingRoomNewResponseQueueingStatusCode = 429 -) - -type WaitingRoomUpdateResponse struct { - ID interface{} `json:"id"` - // Only available for the Waiting Room Advanced subscription. Additional hostname - // and path combinations to which this waiting room will be applied. There is an - // implied wildcard at the end of the path. The hostname and path combination must - // be unique to this and all other waiting rooms. - AdditionalRoutes []WaitingRoomUpdateResponseAdditionalRoute `json:"additional_routes"` - // Configures cookie attributes for the waiting room cookie. This encrypted cookie - // stores a user's status in the waiting room, such as queue position. - CookieAttributes WaitingRoomUpdateResponseCookieAttributes `json:"cookie_attributes"` - // Appends a '\_' + a custom suffix to the end of Cloudflare Waiting Room's cookie - // name(**cf_waitingroom). If `cookie_suffix` is "abcd", the cookie name will be - // `**cf_waitingroom_abcd`. This field is required if using `additional_routes`. - CookieSuffix string `json:"cookie_suffix"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Only available for the Waiting Room Advanced subscription. This is a template - // html file that will be rendered at the edge. If no custom_page_html is provided, - // the default waiting room will be used. The template is based on mustache ( - // https://mustache.github.io/ ). There are several variables that are evaluated by - // the Cloudflare edge: - // - // 1. {{`waitTimeKnown`}} Acts like a boolean value that indicates the behavior to - // take when wait time is not available, for instance when queue_all is - // **true**. - // 2. {{`waitTimeFormatted`}} Estimated wait time for the user. For example, five - // minutes. Alternatively, you can use: - // 3. {{`waitTime`}} Number of minutes of estimated wait for a user. - // 4. {{`waitTimeHours`}} Number of hours of estimated wait for a user - // (`Math.floor(waitTime/60)`). - // 5. {{`waitTimeHourMinutes`}} Number of minutes above the `waitTimeHours` value - // (`waitTime%60`). - // 6. {{`queueIsFull`}} Changes to **true** when no more people can be added to the - // queue. - // - // To view the full list of variables, look at the `cfWaitingRoom` object described - // under the `json_response_enabled` property in other Waiting Room API calls. - CustomPageHTML string `json:"custom_page_html"` - // The language of the default page template. If no default_template_language is - // provided, then `en-US` (English) will be used. - DefaultTemplateLanguage WaitingRoomUpdateResponseDefaultTemplateLanguage `json:"default_template_language"` - // A note that you can use to add more details about the waiting room. - Description string `json:"description"` - // Only available for the Waiting Room Advanced subscription. Disables automatic - // renewal of session cookies. If `true`, an accepted user will have - // session_duration minutes to browse the site. After that, they will have to go - // through the waiting room again. If `false`, a user's session cookie will be - // automatically renewed on every request. - DisableSessionRenewal bool `json:"disable_session_renewal"` - // The host name to which the waiting room will be applied (no wildcards). Please - // do not include the scheme (http:// or https://). The host and path combination - // must be unique. - Host string `json:"host"` - // Only available for the Waiting Room Advanced subscription. If `true`, requests - // to the waiting room with the header `Accept: application/json` will receive a - // JSON response object with information on the user's status in the waiting room - // as opposed to the configured static HTML page. This JSON response object has one - // property `cfWaitingRoom` which is an object containing the following fields: - // - // 1. `inWaitingRoom`: Boolean indicating if the user is in the waiting room - // (always **true**). - // 2. `waitTimeKnown`: Boolean indicating if the current estimated wait times are - // accurate. If **false**, they are not available. - // 3. `waitTime`: Valid only when `waitTimeKnown` is **true**. Integer indicating - // the current estimated time in minutes the user will wait in the waiting room. - // When `queueingMethod` is **random**, this is set to `waitTime50Percentile`. - // 4. `waitTime25Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 25% of users that gain entry the fastest (25th percentile). - // 5. `waitTime50Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 50% of users that gain entry the fastest (50th percentile). - // In other words, half of the queued users are expected to let into the origin - // website before `waitTime50Percentile` and half are expected to be let in - // after it. - // 6. `waitTime75Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 75% of users that gain entry the fastest (75th percentile). - // 7. `waitTimeFormatted`: String displaying the `waitTime` formatted in English - // for users. If `waitTimeKnown` is **false**, `waitTimeFormatted` will display - // **unavailable**. - // 8. `queueIsFull`: Boolean indicating if the waiting room's queue is currently - // full and not accepting new users at the moment. - // 9. `queueAll`: Boolean indicating if all users will be queued in the waiting - // room and no one will be let into the origin website. - // 10. `lastUpdated`: String displaying the timestamp as an ISO 8601 string of the - // user's last attempt to leave the waiting room and be let into the origin - // website. The user is able to make another attempt after - // `refreshIntervalSeconds` past this time. If the user makes a request too - // soon, it will be ignored and `lastUpdated` will not change. - // 11. `refreshIntervalSeconds`: Integer indicating the number of seconds after - // `lastUpdated` until the user is able to make another attempt to leave the - // waiting room and be let into the origin website. When the `queueingMethod` - // is `reject`, there is no specified refresh time — it will always be - // **zero**. - // 12. `queueingMethod`: The queueing method currently used by the waiting room. It - // is either **fifo**, **random**, **passthrough**, or **reject**. - // 13. `isFIFOQueue`: Boolean indicating if the waiting room uses a FIFO - // (First-In-First-Out) queue. - // 14. `isRandomQueue`: Boolean indicating if the waiting room uses a Random queue - // where users gain access randomly. - // 15. `isPassthroughQueue`: Boolean indicating if the waiting room uses a - // passthrough queue. Keep in mind that when passthrough is enabled, this JSON - // response will only exist when `queueAll` is **true** or `isEventPrequeueing` - // is **true** because in all other cases requests will go directly to the - // origin. - // 16. `isRejectQueue`: Boolean indicating if the waiting room uses a reject queue. - // 17. `isEventActive`: Boolean indicating if an event is currently occurring. - // Events are able to change a waiting room's behavior during a specified - // period of time. For additional information, look at the event properties - // `prequeue_start_time`, `event_start_time`, and `event_end_time` in the - // documentation for creating waiting room events. Events are considered active - // between these start and end times, as well as during the prequeueing period - // if it exists. - // 18. `isEventPrequeueing`: Valid only when `isEventActive` is **true**. Boolean - // indicating if an event is currently prequeueing users before it starts. - // 19. `timeUntilEventStart`: Valid only when `isEventPrequeueing` is **true**. - // Integer indicating the number of minutes until the event starts. - // 20. `timeUntilEventStartFormatted`: String displaying the `timeUntilEventStart` - // formatted in English for users. If `isEventPrequeueing` is **false**, - // `timeUntilEventStartFormatted` will display **unavailable**. - // 21. `timeUntilEventEnd`: Valid only when `isEventActive` is **true**. Integer - // indicating the number of minutes until the event ends. - // 22. `timeUntilEventEndFormatted`: String displaying the `timeUntilEventEnd` - // formatted in English for users. If `isEventActive` is **false**, - // `timeUntilEventEndFormatted` will display **unavailable**. - // 23. `shuffleAtEventStart`: Valid only when `isEventActive` is **true**. Boolean - // indicating if the users in the prequeue are shuffled randomly when the event - // starts. - // - // An example cURL to a waiting room could be: - // - // curl -X GET "https://example.com/waitingroom" \ - // -H "Accept: application/json" - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **fifo** and no event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 0, - // "waitTime50Percentile": 0, - // "waitTime75Percentile": 0, - // "waitTimeFormatted": "10 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "fifo", - // "isFIFOQueue": true, - // "isRandomQueue": false, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": false, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 0, - // "timeUntilEventEndFormatted": "unavailable", - // "shuffleAtEventStart": false - // } - // } - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **random** and an event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 5, - // "waitTime50Percentile": 10, - // "waitTime75Percentile": 15, - // "waitTimeFormatted": "5 minutes to 15 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "random", - // "isFIFOQueue": false, - // "isRandomQueue": true, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": true, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 15, - // "timeUntilEventEndFormatted": "15 minutes", - // "shuffleAtEventStart": true - // } - // }. - JsonResponseEnabled bool `json:"json_response_enabled"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A unique name to identify the waiting room. Only alphanumeric characters, - // hyphens and underscores are allowed. - Name string `json:"name"` - // Sets the number of new users that will be let into the route every minute. This - // value is used as baseline for the number of users that are let in per minute. So - // it is possible that there is a little more or little less traffic coming to the - // route based on the traffic patterns at that time around the world. - NewUsersPerMinute int64 `json:"new_users_per_minute"` - // An ISO 8601 timestamp that marks when the next event will begin queueing. - NextEventPrequeueStartTime string `json:"next_event_prequeue_start_time,nullable"` - // An ISO 8601 timestamp that marks when the next event will start. - NextEventStartTime string `json:"next_event_start_time,nullable"` - // Sets the path within the host to enable the waiting room on. The waiting room - // will be enabled for all subpaths as well. If there are two waiting rooms on the - // same subpath, the waiting room for the most specific path will be chosen. - // Wildcards and query parameters are not supported. - Path string `json:"path"` - // If queue_all is `true`, all the traffic that is coming to a route will be sent - // to the waiting room. No new traffic can get to the route once this field is set - // and estimated time will become unavailable. - QueueAll bool `json:"queue_all"` - // Sets the queueing method used by the waiting room. Changing this parameter from - // the **default** queueing method is only available for the Waiting Room Advanced - // subscription. Regardless of the queueing method, if `queue_all` is enabled or an - // event is prequeueing, users in the waiting room will not be accepted to the - // origin. These users will always see a waiting room page that refreshes - // automatically. The valid queueing methods are: - // - // 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in - // the order they arrived. - // 2. `random`: Random queue where customers gain access randomly, regardless of - // arrival time. - // 3. `passthrough`: Users will pass directly through the waiting room and into the - // origin website. As a result, any configured limits will not be respected - // while this is enabled. This method can be used as an alternative to disabling - // a waiting room (with `suspended`) so that analytics are still reported. This - // can be used if you wish to allow all traffic normally, but want to restrict - // traffic during a waiting room event, or vice versa. - // 4. `reject`: Users will be immediately rejected from the waiting room. As a - // result, no users will reach the origin website while this is enabled. This - // can be used if you wish to reject all traffic while performing maintenance, - // block traffic during a specified period of time (an event), or block traffic - // while events are not occurring. Consider a waiting room used for vaccine - // distribution that only allows traffic during sign-up events, and otherwise - // blocks all traffic. For this case, the waiting room uses `reject`, and its - // events override this with `fifo`, `random`, or `passthrough`. When this - // queueing method is enabled and neither `queueAll` is enabled nor an event is - // prequeueing, the waiting room page **will not refresh automatically**. - QueueingMethod WaitingRoomUpdateResponseQueueingMethod `json:"queueing_method"` - // HTTP status code returned to a user while in the queue. - QueueingStatusCode WaitingRoomUpdateResponseQueueingStatusCode `json:"queueing_status_code"` - // Lifetime of a cookie (in minutes) set by Cloudflare for users who get access to - // the route. If a user is not seen by Cloudflare again in that time period, they - // will be treated as a new user that visits the route. - SessionDuration int64 `json:"session_duration"` - // Suspends or allows traffic going to the waiting room. If set to `true`, the - // traffic will not go to the waiting room. - Suspended bool `json:"suspended"` - // Sets the total number of active user sessions on the route at a point in time. A - // route is a combination of host and path on which a waiting room is available. - // This value is used as a baseline for the total number of active user sessions on - // the route. It is possible to have a situation where there are more or less - // active users sessions on the route based on the traffic patterns at that time - // around the world. - TotalActiveUsers int64 `json:"total_active_users"` - JSON waitingRoomUpdateResponseJSON `json:"-"` -} - -// waitingRoomUpdateResponseJSON contains the JSON metadata for the struct -// [WaitingRoomUpdateResponse] -type waitingRoomUpdateResponseJSON struct { - ID apijson.Field - AdditionalRoutes apijson.Field - CookieAttributes apijson.Field - CookieSuffix apijson.Field - CreatedOn apijson.Field - CustomPageHTML apijson.Field - DefaultTemplateLanguage apijson.Field - Description apijson.Field - DisableSessionRenewal apijson.Field - Host apijson.Field - JsonResponseEnabled apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - NewUsersPerMinute apijson.Field - NextEventPrequeueStartTime apijson.Field - NextEventStartTime apijson.Field - Path apijson.Field - QueueAll apijson.Field - QueueingMethod apijson.Field - QueueingStatusCode apijson.Field - SessionDuration apijson.Field - Suspended apijson.Field - TotalActiveUsers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomUpdateResponseAdditionalRoute struct { - // The hostname to which this waiting room will be applied (no wildcards). The - // hostname must be the primary domain, subdomain, or custom hostname (if using SSL - // for SaaS) of this zone. Please do not include the scheme (http:// or https://). - Host string `json:"host"` - // Sets the path within the host to enable the waiting room on. The waiting room - // will be enabled for all subpaths as well. If there are two waiting rooms on the - // same subpath, the waiting room for the most specific path will be chosen. - // Wildcards and query parameters are not supported. - Path string `json:"path"` - JSON waitingRoomUpdateResponseAdditionalRouteJSON `json:"-"` -} - -// waitingRoomUpdateResponseAdditionalRouteJSON contains the JSON metadata for the -// struct [WaitingRoomUpdateResponseAdditionalRoute] -type waitingRoomUpdateResponseAdditionalRouteJSON struct { - Host apijson.Field - Path apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomUpdateResponseAdditionalRoute) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomUpdateResponseAdditionalRouteJSON) RawJSON() string { - return r.raw -} - -// Configures cookie attributes for the waiting room cookie. This encrypted cookie -// stores a user's status in the waiting room, such as queue position. -type WaitingRoomUpdateResponseCookieAttributes struct { - // Configures the SameSite attribute on the waiting room cookie. Value `auto` will - // be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. - // Note that when using value `none`, the secure attribute cannot be set to - // `never`. - Samesite WaitingRoomUpdateResponseCookieAttributesSamesite `json:"samesite"` - // Configures the Secure attribute on the waiting room cookie. Value `always` - // indicates that the Secure attribute will be set in the Set-Cookie header, - // `never` indicates that the Secure attribute will not be set, and `auto` will set - // the Secure attribute depending if **Always Use HTTPS** is enabled. - Secure WaitingRoomUpdateResponseCookieAttributesSecure `json:"secure"` - JSON waitingRoomUpdateResponseCookieAttributesJSON `json:"-"` -} - -// waitingRoomUpdateResponseCookieAttributesJSON contains the JSON metadata for the -// struct [WaitingRoomUpdateResponseCookieAttributes] -type waitingRoomUpdateResponseCookieAttributesJSON struct { - Samesite apijson.Field - Secure apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomUpdateResponseCookieAttributes) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomUpdateResponseCookieAttributesJSON) RawJSON() string { - return r.raw -} - -// Configures the SameSite attribute on the waiting room cookie. Value `auto` will -// be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. -// Note that when using value `none`, the secure attribute cannot be set to -// `never`. -type WaitingRoomUpdateResponseCookieAttributesSamesite string - -const ( - WaitingRoomUpdateResponseCookieAttributesSamesiteAuto WaitingRoomUpdateResponseCookieAttributesSamesite = "auto" - WaitingRoomUpdateResponseCookieAttributesSamesiteLax WaitingRoomUpdateResponseCookieAttributesSamesite = "lax" - WaitingRoomUpdateResponseCookieAttributesSamesiteNone WaitingRoomUpdateResponseCookieAttributesSamesite = "none" - WaitingRoomUpdateResponseCookieAttributesSamesiteStrict WaitingRoomUpdateResponseCookieAttributesSamesite = "strict" -) - -// Configures the Secure attribute on the waiting room cookie. Value `always` -// indicates that the Secure attribute will be set in the Set-Cookie header, -// `never` indicates that the Secure attribute will not be set, and `auto` will set -// the Secure attribute depending if **Always Use HTTPS** is enabled. -type WaitingRoomUpdateResponseCookieAttributesSecure string - -const ( - WaitingRoomUpdateResponseCookieAttributesSecureAuto WaitingRoomUpdateResponseCookieAttributesSecure = "auto" - WaitingRoomUpdateResponseCookieAttributesSecureAlways WaitingRoomUpdateResponseCookieAttributesSecure = "always" - WaitingRoomUpdateResponseCookieAttributesSecureNever WaitingRoomUpdateResponseCookieAttributesSecure = "never" -) - -// The language of the default page template. If no default_template_language is -// provided, then `en-US` (English) will be used. -type WaitingRoomUpdateResponseDefaultTemplateLanguage string - -const ( - WaitingRoomUpdateResponseDefaultTemplateLanguageEnUs WaitingRoomUpdateResponseDefaultTemplateLanguage = "en-US" - WaitingRoomUpdateResponseDefaultTemplateLanguageEsEs WaitingRoomUpdateResponseDefaultTemplateLanguage = "es-ES" - WaitingRoomUpdateResponseDefaultTemplateLanguageDeDe WaitingRoomUpdateResponseDefaultTemplateLanguage = "de-DE" - WaitingRoomUpdateResponseDefaultTemplateLanguageFrFr WaitingRoomUpdateResponseDefaultTemplateLanguage = "fr-FR" - WaitingRoomUpdateResponseDefaultTemplateLanguageItIt WaitingRoomUpdateResponseDefaultTemplateLanguage = "it-IT" - WaitingRoomUpdateResponseDefaultTemplateLanguageJaJp WaitingRoomUpdateResponseDefaultTemplateLanguage = "ja-JP" - WaitingRoomUpdateResponseDefaultTemplateLanguageKoKr WaitingRoomUpdateResponseDefaultTemplateLanguage = "ko-KR" - WaitingRoomUpdateResponseDefaultTemplateLanguagePtBr WaitingRoomUpdateResponseDefaultTemplateLanguage = "pt-BR" - WaitingRoomUpdateResponseDefaultTemplateLanguageZhCn WaitingRoomUpdateResponseDefaultTemplateLanguage = "zh-CN" - WaitingRoomUpdateResponseDefaultTemplateLanguageZhTw WaitingRoomUpdateResponseDefaultTemplateLanguage = "zh-TW" - WaitingRoomUpdateResponseDefaultTemplateLanguageNlNl WaitingRoomUpdateResponseDefaultTemplateLanguage = "nl-NL" - WaitingRoomUpdateResponseDefaultTemplateLanguagePlPl WaitingRoomUpdateResponseDefaultTemplateLanguage = "pl-PL" - WaitingRoomUpdateResponseDefaultTemplateLanguageIDID WaitingRoomUpdateResponseDefaultTemplateLanguage = "id-ID" - WaitingRoomUpdateResponseDefaultTemplateLanguageTrTr WaitingRoomUpdateResponseDefaultTemplateLanguage = "tr-TR" - WaitingRoomUpdateResponseDefaultTemplateLanguageArEg WaitingRoomUpdateResponseDefaultTemplateLanguage = "ar-EG" - WaitingRoomUpdateResponseDefaultTemplateLanguageRuRu WaitingRoomUpdateResponseDefaultTemplateLanguage = "ru-RU" - WaitingRoomUpdateResponseDefaultTemplateLanguageFaIr WaitingRoomUpdateResponseDefaultTemplateLanguage = "fa-IR" -) - -// Sets the queueing method used by the waiting room. Changing this parameter from -// the **default** queueing method is only available for the Waiting Room Advanced -// subscription. Regardless of the queueing method, if `queue_all` is enabled or an -// event is prequeueing, users in the waiting room will not be accepted to the -// origin. These users will always see a waiting room page that refreshes -// automatically. The valid queueing methods are: -// -// 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in -// the order they arrived. -// 2. `random`: Random queue where customers gain access randomly, regardless of -// arrival time. -// 3. `passthrough`: Users will pass directly through the waiting room and into the -// origin website. As a result, any configured limits will not be respected -// while this is enabled. This method can be used as an alternative to disabling -// a waiting room (with `suspended`) so that analytics are still reported. This -// can be used if you wish to allow all traffic normally, but want to restrict -// traffic during a waiting room event, or vice versa. -// 4. `reject`: Users will be immediately rejected from the waiting room. As a -// result, no users will reach the origin website while this is enabled. This -// can be used if you wish to reject all traffic while performing maintenance, -// block traffic during a specified period of time (an event), or block traffic -// while events are not occurring. Consider a waiting room used for vaccine -// distribution that only allows traffic during sign-up events, and otherwise -// blocks all traffic. For this case, the waiting room uses `reject`, and its -// events override this with `fifo`, `random`, or `passthrough`. When this -// queueing method is enabled and neither `queueAll` is enabled nor an event is -// prequeueing, the waiting room page **will not refresh automatically**. -type WaitingRoomUpdateResponseQueueingMethod string - -const ( - WaitingRoomUpdateResponseQueueingMethodFifo WaitingRoomUpdateResponseQueueingMethod = "fifo" - WaitingRoomUpdateResponseQueueingMethodRandom WaitingRoomUpdateResponseQueueingMethod = "random" - WaitingRoomUpdateResponseQueueingMethodPassthrough WaitingRoomUpdateResponseQueueingMethod = "passthrough" - WaitingRoomUpdateResponseQueueingMethodReject WaitingRoomUpdateResponseQueueingMethod = "reject" -) - -// HTTP status code returned to a user while in the queue. -type WaitingRoomUpdateResponseQueueingStatusCode int64 - -const ( - WaitingRoomUpdateResponseQueueingStatusCode200 WaitingRoomUpdateResponseQueueingStatusCode = 200 - WaitingRoomUpdateResponseQueueingStatusCode202 WaitingRoomUpdateResponseQueueingStatusCode = 202 - WaitingRoomUpdateResponseQueueingStatusCode429 WaitingRoomUpdateResponseQueueingStatusCode = 429 -) - -type WaitingRoomListResponse struct { - ID interface{} `json:"id"` - // Only available for the Waiting Room Advanced subscription. Additional hostname - // and path combinations to which this waiting room will be applied. There is an - // implied wildcard at the end of the path. The hostname and path combination must - // be unique to this and all other waiting rooms. - AdditionalRoutes []WaitingRoomListResponseAdditionalRoute `json:"additional_routes"` - // Configures cookie attributes for the waiting room cookie. This encrypted cookie - // stores a user's status in the waiting room, such as queue position. - CookieAttributes WaitingRoomListResponseCookieAttributes `json:"cookie_attributes"` - // Appends a '\_' + a custom suffix to the end of Cloudflare Waiting Room's cookie - // name(**cf_waitingroom). If `cookie_suffix` is "abcd", the cookie name will be - // `**cf_waitingroom_abcd`. This field is required if using `additional_routes`. - CookieSuffix string `json:"cookie_suffix"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Only available for the Waiting Room Advanced subscription. This is a template - // html file that will be rendered at the edge. If no custom_page_html is provided, - // the default waiting room will be used. The template is based on mustache ( - // https://mustache.github.io/ ). There are several variables that are evaluated by - // the Cloudflare edge: - // - // 1. {{`waitTimeKnown`}} Acts like a boolean value that indicates the behavior to - // take when wait time is not available, for instance when queue_all is - // **true**. - // 2. {{`waitTimeFormatted`}} Estimated wait time for the user. For example, five - // minutes. Alternatively, you can use: - // 3. {{`waitTime`}} Number of minutes of estimated wait for a user. - // 4. {{`waitTimeHours`}} Number of hours of estimated wait for a user - // (`Math.floor(waitTime/60)`). - // 5. {{`waitTimeHourMinutes`}} Number of minutes above the `waitTimeHours` value - // (`waitTime%60`). - // 6. {{`queueIsFull`}} Changes to **true** when no more people can be added to the - // queue. - // - // To view the full list of variables, look at the `cfWaitingRoom` object described - // under the `json_response_enabled` property in other Waiting Room API calls. - CustomPageHTML string `json:"custom_page_html"` - // The language of the default page template. If no default_template_language is - // provided, then `en-US` (English) will be used. - DefaultTemplateLanguage WaitingRoomListResponseDefaultTemplateLanguage `json:"default_template_language"` - // A note that you can use to add more details about the waiting room. - Description string `json:"description"` - // Only available for the Waiting Room Advanced subscription. Disables automatic - // renewal of session cookies. If `true`, an accepted user will have - // session_duration minutes to browse the site. After that, they will have to go - // through the waiting room again. If `false`, a user's session cookie will be - // automatically renewed on every request. - DisableSessionRenewal bool `json:"disable_session_renewal"` - // The host name to which the waiting room will be applied (no wildcards). Please - // do not include the scheme (http:// or https://). The host and path combination - // must be unique. - Host string `json:"host"` - // Only available for the Waiting Room Advanced subscription. If `true`, requests - // to the waiting room with the header `Accept: application/json` will receive a - // JSON response object with information on the user's status in the waiting room - // as opposed to the configured static HTML page. This JSON response object has one - // property `cfWaitingRoom` which is an object containing the following fields: - // - // 1. `inWaitingRoom`: Boolean indicating if the user is in the waiting room - // (always **true**). - // 2. `waitTimeKnown`: Boolean indicating if the current estimated wait times are - // accurate. If **false**, they are not available. - // 3. `waitTime`: Valid only when `waitTimeKnown` is **true**. Integer indicating - // the current estimated time in minutes the user will wait in the waiting room. - // When `queueingMethod` is **random**, this is set to `waitTime50Percentile`. - // 4. `waitTime25Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 25% of users that gain entry the fastest (25th percentile). - // 5. `waitTime50Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 50% of users that gain entry the fastest (50th percentile). - // In other words, half of the queued users are expected to let into the origin - // website before `waitTime50Percentile` and half are expected to be let in - // after it. - // 6. `waitTime75Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 75% of users that gain entry the fastest (75th percentile). - // 7. `waitTimeFormatted`: String displaying the `waitTime` formatted in English - // for users. If `waitTimeKnown` is **false**, `waitTimeFormatted` will display - // **unavailable**. - // 8. `queueIsFull`: Boolean indicating if the waiting room's queue is currently - // full and not accepting new users at the moment. - // 9. `queueAll`: Boolean indicating if all users will be queued in the waiting - // room and no one will be let into the origin website. - // 10. `lastUpdated`: String displaying the timestamp as an ISO 8601 string of the - // user's last attempt to leave the waiting room and be let into the origin - // website. The user is able to make another attempt after - // `refreshIntervalSeconds` past this time. If the user makes a request too - // soon, it will be ignored and `lastUpdated` will not change. - // 11. `refreshIntervalSeconds`: Integer indicating the number of seconds after - // `lastUpdated` until the user is able to make another attempt to leave the - // waiting room and be let into the origin website. When the `queueingMethod` - // is `reject`, there is no specified refresh time — it will always be - // **zero**. - // 12. `queueingMethod`: The queueing method currently used by the waiting room. It - // is either **fifo**, **random**, **passthrough**, or **reject**. - // 13. `isFIFOQueue`: Boolean indicating if the waiting room uses a FIFO - // (First-In-First-Out) queue. - // 14. `isRandomQueue`: Boolean indicating if the waiting room uses a Random queue - // where users gain access randomly. - // 15. `isPassthroughQueue`: Boolean indicating if the waiting room uses a - // passthrough queue. Keep in mind that when passthrough is enabled, this JSON - // response will only exist when `queueAll` is **true** or `isEventPrequeueing` - // is **true** because in all other cases requests will go directly to the - // origin. - // 16. `isRejectQueue`: Boolean indicating if the waiting room uses a reject queue. - // 17. `isEventActive`: Boolean indicating if an event is currently occurring. - // Events are able to change a waiting room's behavior during a specified - // period of time. For additional information, look at the event properties - // `prequeue_start_time`, `event_start_time`, and `event_end_time` in the - // documentation for creating waiting room events. Events are considered active - // between these start and end times, as well as during the prequeueing period - // if it exists. - // 18. `isEventPrequeueing`: Valid only when `isEventActive` is **true**. Boolean - // indicating if an event is currently prequeueing users before it starts. - // 19. `timeUntilEventStart`: Valid only when `isEventPrequeueing` is **true**. - // Integer indicating the number of minutes until the event starts. - // 20. `timeUntilEventStartFormatted`: String displaying the `timeUntilEventStart` - // formatted in English for users. If `isEventPrequeueing` is **false**, - // `timeUntilEventStartFormatted` will display **unavailable**. - // 21. `timeUntilEventEnd`: Valid only when `isEventActive` is **true**. Integer - // indicating the number of minutes until the event ends. - // 22. `timeUntilEventEndFormatted`: String displaying the `timeUntilEventEnd` - // formatted in English for users. If `isEventActive` is **false**, - // `timeUntilEventEndFormatted` will display **unavailable**. - // 23. `shuffleAtEventStart`: Valid only when `isEventActive` is **true**. Boolean - // indicating if the users in the prequeue are shuffled randomly when the event - // starts. - // - // An example cURL to a waiting room could be: - // - // curl -X GET "https://example.com/waitingroom" \ - // -H "Accept: application/json" - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **fifo** and no event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 0, - // "waitTime50Percentile": 0, - // "waitTime75Percentile": 0, - // "waitTimeFormatted": "10 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "fifo", - // "isFIFOQueue": true, - // "isRandomQueue": false, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": false, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 0, - // "timeUntilEventEndFormatted": "unavailable", - // "shuffleAtEventStart": false - // } - // } - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **random** and an event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 5, - // "waitTime50Percentile": 10, - // "waitTime75Percentile": 15, - // "waitTimeFormatted": "5 minutes to 15 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "random", - // "isFIFOQueue": false, - // "isRandomQueue": true, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": true, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 15, - // "timeUntilEventEndFormatted": "15 minutes", - // "shuffleAtEventStart": true - // } - // }. - JsonResponseEnabled bool `json:"json_response_enabled"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A unique name to identify the waiting room. Only alphanumeric characters, - // hyphens and underscores are allowed. - Name string `json:"name"` - // Sets the number of new users that will be let into the route every minute. This - // value is used as baseline for the number of users that are let in per minute. So - // it is possible that there is a little more or little less traffic coming to the - // route based on the traffic patterns at that time around the world. - NewUsersPerMinute int64 `json:"new_users_per_minute"` - // An ISO 8601 timestamp that marks when the next event will begin queueing. - NextEventPrequeueStartTime string `json:"next_event_prequeue_start_time,nullable"` - // An ISO 8601 timestamp that marks when the next event will start. - NextEventStartTime string `json:"next_event_start_time,nullable"` - // Sets the path within the host to enable the waiting room on. The waiting room - // will be enabled for all subpaths as well. If there are two waiting rooms on the - // same subpath, the waiting room for the most specific path will be chosen. - // Wildcards and query parameters are not supported. - Path string `json:"path"` - // If queue_all is `true`, all the traffic that is coming to a route will be sent - // to the waiting room. No new traffic can get to the route once this field is set - // and estimated time will become unavailable. - QueueAll bool `json:"queue_all"` - // Sets the queueing method used by the waiting room. Changing this parameter from - // the **default** queueing method is only available for the Waiting Room Advanced - // subscription. Regardless of the queueing method, if `queue_all` is enabled or an - // event is prequeueing, users in the waiting room will not be accepted to the - // origin. These users will always see a waiting room page that refreshes - // automatically. The valid queueing methods are: - // - // 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in - // the order they arrived. - // 2. `random`: Random queue where customers gain access randomly, regardless of - // arrival time. - // 3. `passthrough`: Users will pass directly through the waiting room and into the - // origin website. As a result, any configured limits will not be respected - // while this is enabled. This method can be used as an alternative to disabling - // a waiting room (with `suspended`) so that analytics are still reported. This - // can be used if you wish to allow all traffic normally, but want to restrict - // traffic during a waiting room event, or vice versa. - // 4. `reject`: Users will be immediately rejected from the waiting room. As a - // result, no users will reach the origin website while this is enabled. This - // can be used if you wish to reject all traffic while performing maintenance, - // block traffic during a specified period of time (an event), or block traffic - // while events are not occurring. Consider a waiting room used for vaccine - // distribution that only allows traffic during sign-up events, and otherwise - // blocks all traffic. For this case, the waiting room uses `reject`, and its - // events override this with `fifo`, `random`, or `passthrough`. When this - // queueing method is enabled and neither `queueAll` is enabled nor an event is - // prequeueing, the waiting room page **will not refresh automatically**. - QueueingMethod WaitingRoomListResponseQueueingMethod `json:"queueing_method"` - // HTTP status code returned to a user while in the queue. - QueueingStatusCode WaitingRoomListResponseQueueingStatusCode `json:"queueing_status_code"` - // Lifetime of a cookie (in minutes) set by Cloudflare for users who get access to - // the route. If a user is not seen by Cloudflare again in that time period, they - // will be treated as a new user that visits the route. - SessionDuration int64 `json:"session_duration"` - // Suspends or allows traffic going to the waiting room. If set to `true`, the - // traffic will not go to the waiting room. - Suspended bool `json:"suspended"` - // Sets the total number of active user sessions on the route at a point in time. A - // route is a combination of host and path on which a waiting room is available. - // This value is used as a baseline for the total number of active user sessions on - // the route. It is possible to have a situation where there are more or less - // active users sessions on the route based on the traffic patterns at that time - // around the world. - TotalActiveUsers int64 `json:"total_active_users"` - JSON waitingRoomListResponseJSON `json:"-"` -} - -// waitingRoomListResponseJSON contains the JSON metadata for the struct -// [WaitingRoomListResponse] -type waitingRoomListResponseJSON struct { - ID apijson.Field - AdditionalRoutes apijson.Field - CookieAttributes apijson.Field - CookieSuffix apijson.Field - CreatedOn apijson.Field - CustomPageHTML apijson.Field - DefaultTemplateLanguage apijson.Field - Description apijson.Field - DisableSessionRenewal apijson.Field - Host apijson.Field - JsonResponseEnabled apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - NewUsersPerMinute apijson.Field - NextEventPrequeueStartTime apijson.Field - NextEventStartTime apijson.Field - Path apijson.Field - QueueAll apijson.Field - QueueingMethod apijson.Field - QueueingStatusCode apijson.Field - SessionDuration apijson.Field - Suspended apijson.Field - TotalActiveUsers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomListResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomListResponseAdditionalRoute struct { - // The hostname to which this waiting room will be applied (no wildcards). The - // hostname must be the primary domain, subdomain, or custom hostname (if using SSL - // for SaaS) of this zone. Please do not include the scheme (http:// or https://). - Host string `json:"host"` - // Sets the path within the host to enable the waiting room on. The waiting room - // will be enabled for all subpaths as well. If there are two waiting rooms on the - // same subpath, the waiting room for the most specific path will be chosen. - // Wildcards and query parameters are not supported. - Path string `json:"path"` - JSON waitingRoomListResponseAdditionalRouteJSON `json:"-"` -} - -// waitingRoomListResponseAdditionalRouteJSON contains the JSON metadata for the -// struct [WaitingRoomListResponseAdditionalRoute] -type waitingRoomListResponseAdditionalRouteJSON struct { - Host apijson.Field - Path apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomListResponseAdditionalRoute) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomListResponseAdditionalRouteJSON) RawJSON() string { - return r.raw -} - -// Configures cookie attributes for the waiting room cookie. This encrypted cookie -// stores a user's status in the waiting room, such as queue position. -type WaitingRoomListResponseCookieAttributes struct { - // Configures the SameSite attribute on the waiting room cookie. Value `auto` will - // be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. - // Note that when using value `none`, the secure attribute cannot be set to - // `never`. - Samesite WaitingRoomListResponseCookieAttributesSamesite `json:"samesite"` - // Configures the Secure attribute on the waiting room cookie. Value `always` - // indicates that the Secure attribute will be set in the Set-Cookie header, - // `never` indicates that the Secure attribute will not be set, and `auto` will set - // the Secure attribute depending if **Always Use HTTPS** is enabled. - Secure WaitingRoomListResponseCookieAttributesSecure `json:"secure"` - JSON waitingRoomListResponseCookieAttributesJSON `json:"-"` -} - -// waitingRoomListResponseCookieAttributesJSON contains the JSON metadata for the -// struct [WaitingRoomListResponseCookieAttributes] -type waitingRoomListResponseCookieAttributesJSON struct { - Samesite apijson.Field - Secure apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomListResponseCookieAttributes) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomListResponseCookieAttributesJSON) RawJSON() string { - return r.raw -} - -// Configures the SameSite attribute on the waiting room cookie. Value `auto` will -// be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. -// Note that when using value `none`, the secure attribute cannot be set to -// `never`. -type WaitingRoomListResponseCookieAttributesSamesite string - -const ( - WaitingRoomListResponseCookieAttributesSamesiteAuto WaitingRoomListResponseCookieAttributesSamesite = "auto" - WaitingRoomListResponseCookieAttributesSamesiteLax WaitingRoomListResponseCookieAttributesSamesite = "lax" - WaitingRoomListResponseCookieAttributesSamesiteNone WaitingRoomListResponseCookieAttributesSamesite = "none" - WaitingRoomListResponseCookieAttributesSamesiteStrict WaitingRoomListResponseCookieAttributesSamesite = "strict" -) - -// Configures the Secure attribute on the waiting room cookie. Value `always` -// indicates that the Secure attribute will be set in the Set-Cookie header, -// `never` indicates that the Secure attribute will not be set, and `auto` will set -// the Secure attribute depending if **Always Use HTTPS** is enabled. -type WaitingRoomListResponseCookieAttributesSecure string - -const ( - WaitingRoomListResponseCookieAttributesSecureAuto WaitingRoomListResponseCookieAttributesSecure = "auto" - WaitingRoomListResponseCookieAttributesSecureAlways WaitingRoomListResponseCookieAttributesSecure = "always" - WaitingRoomListResponseCookieAttributesSecureNever WaitingRoomListResponseCookieAttributesSecure = "never" -) - -// The language of the default page template. If no default_template_language is -// provided, then `en-US` (English) will be used. -type WaitingRoomListResponseDefaultTemplateLanguage string - -const ( - WaitingRoomListResponseDefaultTemplateLanguageEnUs WaitingRoomListResponseDefaultTemplateLanguage = "en-US" - WaitingRoomListResponseDefaultTemplateLanguageEsEs WaitingRoomListResponseDefaultTemplateLanguage = "es-ES" - WaitingRoomListResponseDefaultTemplateLanguageDeDe WaitingRoomListResponseDefaultTemplateLanguage = "de-DE" - WaitingRoomListResponseDefaultTemplateLanguageFrFr WaitingRoomListResponseDefaultTemplateLanguage = "fr-FR" - WaitingRoomListResponseDefaultTemplateLanguageItIt WaitingRoomListResponseDefaultTemplateLanguage = "it-IT" - WaitingRoomListResponseDefaultTemplateLanguageJaJp WaitingRoomListResponseDefaultTemplateLanguage = "ja-JP" - WaitingRoomListResponseDefaultTemplateLanguageKoKr WaitingRoomListResponseDefaultTemplateLanguage = "ko-KR" - WaitingRoomListResponseDefaultTemplateLanguagePtBr WaitingRoomListResponseDefaultTemplateLanguage = "pt-BR" - WaitingRoomListResponseDefaultTemplateLanguageZhCn WaitingRoomListResponseDefaultTemplateLanguage = "zh-CN" - WaitingRoomListResponseDefaultTemplateLanguageZhTw WaitingRoomListResponseDefaultTemplateLanguage = "zh-TW" - WaitingRoomListResponseDefaultTemplateLanguageNlNl WaitingRoomListResponseDefaultTemplateLanguage = "nl-NL" - WaitingRoomListResponseDefaultTemplateLanguagePlPl WaitingRoomListResponseDefaultTemplateLanguage = "pl-PL" - WaitingRoomListResponseDefaultTemplateLanguageIDID WaitingRoomListResponseDefaultTemplateLanguage = "id-ID" - WaitingRoomListResponseDefaultTemplateLanguageTrTr WaitingRoomListResponseDefaultTemplateLanguage = "tr-TR" - WaitingRoomListResponseDefaultTemplateLanguageArEg WaitingRoomListResponseDefaultTemplateLanguage = "ar-EG" - WaitingRoomListResponseDefaultTemplateLanguageRuRu WaitingRoomListResponseDefaultTemplateLanguage = "ru-RU" - WaitingRoomListResponseDefaultTemplateLanguageFaIr WaitingRoomListResponseDefaultTemplateLanguage = "fa-IR" -) - -// Sets the queueing method used by the waiting room. Changing this parameter from -// the **default** queueing method is only available for the Waiting Room Advanced -// subscription. Regardless of the queueing method, if `queue_all` is enabled or an -// event is prequeueing, users in the waiting room will not be accepted to the -// origin. These users will always see a waiting room page that refreshes -// automatically. The valid queueing methods are: -// -// 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in -// the order they arrived. -// 2. `random`: Random queue where customers gain access randomly, regardless of -// arrival time. -// 3. `passthrough`: Users will pass directly through the waiting room and into the -// origin website. As a result, any configured limits will not be respected -// while this is enabled. This method can be used as an alternative to disabling -// a waiting room (with `suspended`) so that analytics are still reported. This -// can be used if you wish to allow all traffic normally, but want to restrict -// traffic during a waiting room event, or vice versa. -// 4. `reject`: Users will be immediately rejected from the waiting room. As a -// result, no users will reach the origin website while this is enabled. This -// can be used if you wish to reject all traffic while performing maintenance, -// block traffic during a specified period of time (an event), or block traffic -// while events are not occurring. Consider a waiting room used for vaccine -// distribution that only allows traffic during sign-up events, and otherwise -// blocks all traffic. For this case, the waiting room uses `reject`, and its -// events override this with `fifo`, `random`, or `passthrough`. When this -// queueing method is enabled and neither `queueAll` is enabled nor an event is -// prequeueing, the waiting room page **will not refresh automatically**. -type WaitingRoomListResponseQueueingMethod string - -const ( - WaitingRoomListResponseQueueingMethodFifo WaitingRoomListResponseQueueingMethod = "fifo" - WaitingRoomListResponseQueueingMethodRandom WaitingRoomListResponseQueueingMethod = "random" - WaitingRoomListResponseQueueingMethodPassthrough WaitingRoomListResponseQueueingMethod = "passthrough" - WaitingRoomListResponseQueueingMethodReject WaitingRoomListResponseQueueingMethod = "reject" -) - -// HTTP status code returned to a user while in the queue. -type WaitingRoomListResponseQueueingStatusCode int64 - -const ( - WaitingRoomListResponseQueueingStatusCode200 WaitingRoomListResponseQueueingStatusCode = 200 - WaitingRoomListResponseQueueingStatusCode202 WaitingRoomListResponseQueueingStatusCode = 202 - WaitingRoomListResponseQueueingStatusCode429 WaitingRoomListResponseQueueingStatusCode = 429 -) - -type WaitingRoomDeleteResponse struct { - ID interface{} `json:"id"` - JSON waitingRoomDeleteResponseJSON `json:"-"` -} - -// waitingRoomDeleteResponseJSON contains the JSON metadata for the struct -// [WaitingRoomDeleteResponse] -type waitingRoomDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomEditResponse struct { - ID interface{} `json:"id"` - // Only available for the Waiting Room Advanced subscription. Additional hostname - // and path combinations to which this waiting room will be applied. There is an - // implied wildcard at the end of the path. The hostname and path combination must - // be unique to this and all other waiting rooms. - AdditionalRoutes []WaitingRoomEditResponseAdditionalRoute `json:"additional_routes"` - // Configures cookie attributes for the waiting room cookie. This encrypted cookie - // stores a user's status in the waiting room, such as queue position. - CookieAttributes WaitingRoomEditResponseCookieAttributes `json:"cookie_attributes"` - // Appends a '\_' + a custom suffix to the end of Cloudflare Waiting Room's cookie - // name(**cf_waitingroom). If `cookie_suffix` is "abcd", the cookie name will be - // `**cf_waitingroom_abcd`. This field is required if using `additional_routes`. - CookieSuffix string `json:"cookie_suffix"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Only available for the Waiting Room Advanced subscription. This is a template - // html file that will be rendered at the edge. If no custom_page_html is provided, - // the default waiting room will be used. The template is based on mustache ( - // https://mustache.github.io/ ). There are several variables that are evaluated by - // the Cloudflare edge: - // - // 1. {{`waitTimeKnown`}} Acts like a boolean value that indicates the behavior to - // take when wait time is not available, for instance when queue_all is - // **true**. - // 2. {{`waitTimeFormatted`}} Estimated wait time for the user. For example, five - // minutes. Alternatively, you can use: - // 3. {{`waitTime`}} Number of minutes of estimated wait for a user. - // 4. {{`waitTimeHours`}} Number of hours of estimated wait for a user - // (`Math.floor(waitTime/60)`). - // 5. {{`waitTimeHourMinutes`}} Number of minutes above the `waitTimeHours` value - // (`waitTime%60`). - // 6. {{`queueIsFull`}} Changes to **true** when no more people can be added to the - // queue. - // - // To view the full list of variables, look at the `cfWaitingRoom` object described - // under the `json_response_enabled` property in other Waiting Room API calls. - CustomPageHTML string `json:"custom_page_html"` - // The language of the default page template. If no default_template_language is - // provided, then `en-US` (English) will be used. - DefaultTemplateLanguage WaitingRoomEditResponseDefaultTemplateLanguage `json:"default_template_language"` - // A note that you can use to add more details about the waiting room. - Description string `json:"description"` - // Only available for the Waiting Room Advanced subscription. Disables automatic - // renewal of session cookies. If `true`, an accepted user will have - // session_duration minutes to browse the site. After that, they will have to go - // through the waiting room again. If `false`, a user's session cookie will be - // automatically renewed on every request. - DisableSessionRenewal bool `json:"disable_session_renewal"` - // The host name to which the waiting room will be applied (no wildcards). Please - // do not include the scheme (http:// or https://). The host and path combination - // must be unique. - Host string `json:"host"` - // Only available for the Waiting Room Advanced subscription. If `true`, requests - // to the waiting room with the header `Accept: application/json` will receive a - // JSON response object with information on the user's status in the waiting room - // as opposed to the configured static HTML page. This JSON response object has one - // property `cfWaitingRoom` which is an object containing the following fields: - // - // 1. `inWaitingRoom`: Boolean indicating if the user is in the waiting room - // (always **true**). - // 2. `waitTimeKnown`: Boolean indicating if the current estimated wait times are - // accurate. If **false**, they are not available. - // 3. `waitTime`: Valid only when `waitTimeKnown` is **true**. Integer indicating - // the current estimated time in minutes the user will wait in the waiting room. - // When `queueingMethod` is **random**, this is set to `waitTime50Percentile`. - // 4. `waitTime25Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 25% of users that gain entry the fastest (25th percentile). - // 5. `waitTime50Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 50% of users that gain entry the fastest (50th percentile). - // In other words, half of the queued users are expected to let into the origin - // website before `waitTime50Percentile` and half are expected to be let in - // after it. - // 6. `waitTime75Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 75% of users that gain entry the fastest (75th percentile). - // 7. `waitTimeFormatted`: String displaying the `waitTime` formatted in English - // for users. If `waitTimeKnown` is **false**, `waitTimeFormatted` will display - // **unavailable**. - // 8. `queueIsFull`: Boolean indicating if the waiting room's queue is currently - // full and not accepting new users at the moment. - // 9. `queueAll`: Boolean indicating if all users will be queued in the waiting - // room and no one will be let into the origin website. - // 10. `lastUpdated`: String displaying the timestamp as an ISO 8601 string of the - // user's last attempt to leave the waiting room and be let into the origin - // website. The user is able to make another attempt after - // `refreshIntervalSeconds` past this time. If the user makes a request too - // soon, it will be ignored and `lastUpdated` will not change. - // 11. `refreshIntervalSeconds`: Integer indicating the number of seconds after - // `lastUpdated` until the user is able to make another attempt to leave the - // waiting room and be let into the origin website. When the `queueingMethod` - // is `reject`, there is no specified refresh time — it will always be - // **zero**. - // 12. `queueingMethod`: The queueing method currently used by the waiting room. It - // is either **fifo**, **random**, **passthrough**, or **reject**. - // 13. `isFIFOQueue`: Boolean indicating if the waiting room uses a FIFO - // (First-In-First-Out) queue. - // 14. `isRandomQueue`: Boolean indicating if the waiting room uses a Random queue - // where users gain access randomly. - // 15. `isPassthroughQueue`: Boolean indicating if the waiting room uses a - // passthrough queue. Keep in mind that when passthrough is enabled, this JSON - // response will only exist when `queueAll` is **true** or `isEventPrequeueing` - // is **true** because in all other cases requests will go directly to the - // origin. - // 16. `isRejectQueue`: Boolean indicating if the waiting room uses a reject queue. - // 17. `isEventActive`: Boolean indicating if an event is currently occurring. - // Events are able to change a waiting room's behavior during a specified - // period of time. For additional information, look at the event properties - // `prequeue_start_time`, `event_start_time`, and `event_end_time` in the - // documentation for creating waiting room events. Events are considered active - // between these start and end times, as well as during the prequeueing period - // if it exists. - // 18. `isEventPrequeueing`: Valid only when `isEventActive` is **true**. Boolean - // indicating if an event is currently prequeueing users before it starts. - // 19. `timeUntilEventStart`: Valid only when `isEventPrequeueing` is **true**. - // Integer indicating the number of minutes until the event starts. - // 20. `timeUntilEventStartFormatted`: String displaying the `timeUntilEventStart` - // formatted in English for users. If `isEventPrequeueing` is **false**, - // `timeUntilEventStartFormatted` will display **unavailable**. - // 21. `timeUntilEventEnd`: Valid only when `isEventActive` is **true**. Integer - // indicating the number of minutes until the event ends. - // 22. `timeUntilEventEndFormatted`: String displaying the `timeUntilEventEnd` - // formatted in English for users. If `isEventActive` is **false**, - // `timeUntilEventEndFormatted` will display **unavailable**. - // 23. `shuffleAtEventStart`: Valid only when `isEventActive` is **true**. Boolean - // indicating if the users in the prequeue are shuffled randomly when the event - // starts. - // - // An example cURL to a waiting room could be: - // - // curl -X GET "https://example.com/waitingroom" \ - // -H "Accept: application/json" - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **fifo** and no event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 0, - // "waitTime50Percentile": 0, - // "waitTime75Percentile": 0, - // "waitTimeFormatted": "10 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "fifo", - // "isFIFOQueue": true, - // "isRandomQueue": false, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": false, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 0, - // "timeUntilEventEndFormatted": "unavailable", - // "shuffleAtEventStart": false - // } - // } - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **random** and an event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 5, - // "waitTime50Percentile": 10, - // "waitTime75Percentile": 15, - // "waitTimeFormatted": "5 minutes to 15 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "random", - // "isFIFOQueue": false, - // "isRandomQueue": true, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": true, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 15, - // "timeUntilEventEndFormatted": "15 minutes", - // "shuffleAtEventStart": true - // } - // }. - JsonResponseEnabled bool `json:"json_response_enabled"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A unique name to identify the waiting room. Only alphanumeric characters, - // hyphens and underscores are allowed. - Name string `json:"name"` - // Sets the number of new users that will be let into the route every minute. This - // value is used as baseline for the number of users that are let in per minute. So - // it is possible that there is a little more or little less traffic coming to the - // route based on the traffic patterns at that time around the world. - NewUsersPerMinute int64 `json:"new_users_per_minute"` - // An ISO 8601 timestamp that marks when the next event will begin queueing. - NextEventPrequeueStartTime string `json:"next_event_prequeue_start_time,nullable"` - // An ISO 8601 timestamp that marks when the next event will start. - NextEventStartTime string `json:"next_event_start_time,nullable"` - // Sets the path within the host to enable the waiting room on. The waiting room - // will be enabled for all subpaths as well. If there are two waiting rooms on the - // same subpath, the waiting room for the most specific path will be chosen. - // Wildcards and query parameters are not supported. - Path string `json:"path"` - // If queue_all is `true`, all the traffic that is coming to a route will be sent - // to the waiting room. No new traffic can get to the route once this field is set - // and estimated time will become unavailable. - QueueAll bool `json:"queue_all"` - // Sets the queueing method used by the waiting room. Changing this parameter from - // the **default** queueing method is only available for the Waiting Room Advanced - // subscription. Regardless of the queueing method, if `queue_all` is enabled or an - // event is prequeueing, users in the waiting room will not be accepted to the - // origin. These users will always see a waiting room page that refreshes - // automatically. The valid queueing methods are: - // - // 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in - // the order they arrived. - // 2. `random`: Random queue where customers gain access randomly, regardless of - // arrival time. - // 3. `passthrough`: Users will pass directly through the waiting room and into the - // origin website. As a result, any configured limits will not be respected - // while this is enabled. This method can be used as an alternative to disabling - // a waiting room (with `suspended`) so that analytics are still reported. This - // can be used if you wish to allow all traffic normally, but want to restrict - // traffic during a waiting room event, or vice versa. - // 4. `reject`: Users will be immediately rejected from the waiting room. As a - // result, no users will reach the origin website while this is enabled. This - // can be used if you wish to reject all traffic while performing maintenance, - // block traffic during a specified period of time (an event), or block traffic - // while events are not occurring. Consider a waiting room used for vaccine - // distribution that only allows traffic during sign-up events, and otherwise - // blocks all traffic. For this case, the waiting room uses `reject`, and its - // events override this with `fifo`, `random`, or `passthrough`. When this - // queueing method is enabled and neither `queueAll` is enabled nor an event is - // prequeueing, the waiting room page **will not refresh automatically**. - QueueingMethod WaitingRoomEditResponseQueueingMethod `json:"queueing_method"` - // HTTP status code returned to a user while in the queue. - QueueingStatusCode WaitingRoomEditResponseQueueingStatusCode `json:"queueing_status_code"` - // Lifetime of a cookie (in minutes) set by Cloudflare for users who get access to - // the route. If a user is not seen by Cloudflare again in that time period, they - // will be treated as a new user that visits the route. - SessionDuration int64 `json:"session_duration"` - // Suspends or allows traffic going to the waiting room. If set to `true`, the - // traffic will not go to the waiting room. - Suspended bool `json:"suspended"` - // Sets the total number of active user sessions on the route at a point in time. A - // route is a combination of host and path on which a waiting room is available. - // This value is used as a baseline for the total number of active user sessions on - // the route. It is possible to have a situation where there are more or less - // active users sessions on the route based on the traffic patterns at that time - // around the world. - TotalActiveUsers int64 `json:"total_active_users"` - JSON waitingRoomEditResponseJSON `json:"-"` -} - -// waitingRoomEditResponseJSON contains the JSON metadata for the struct -// [WaitingRoomEditResponse] -type waitingRoomEditResponseJSON struct { - ID apijson.Field - AdditionalRoutes apijson.Field - CookieAttributes apijson.Field - CookieSuffix apijson.Field - CreatedOn apijson.Field - CustomPageHTML apijson.Field - DefaultTemplateLanguage apijson.Field - Description apijson.Field - DisableSessionRenewal apijson.Field - Host apijson.Field - JsonResponseEnabled apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - NewUsersPerMinute apijson.Field - NextEventPrequeueStartTime apijson.Field - NextEventStartTime apijson.Field - Path apijson.Field - QueueAll apijson.Field - QueueingMethod apijson.Field - QueueingStatusCode apijson.Field - SessionDuration apijson.Field - Suspended apijson.Field - TotalActiveUsers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEditResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomEditResponseAdditionalRoute struct { - // The hostname to which this waiting room will be applied (no wildcards). The - // hostname must be the primary domain, subdomain, or custom hostname (if using SSL - // for SaaS) of this zone. Please do not include the scheme (http:// or https://). - Host string `json:"host"` - // Sets the path within the host to enable the waiting room on. The waiting room - // will be enabled for all subpaths as well. If there are two waiting rooms on the - // same subpath, the waiting room for the most specific path will be chosen. - // Wildcards and query parameters are not supported. - Path string `json:"path"` - JSON waitingRoomEditResponseAdditionalRouteJSON `json:"-"` -} - -// waitingRoomEditResponseAdditionalRouteJSON contains the JSON metadata for the -// struct [WaitingRoomEditResponseAdditionalRoute] -type waitingRoomEditResponseAdditionalRouteJSON struct { - Host apijson.Field - Path apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEditResponseAdditionalRoute) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEditResponseAdditionalRouteJSON) RawJSON() string { - return r.raw -} - -// Configures cookie attributes for the waiting room cookie. This encrypted cookie -// stores a user's status in the waiting room, such as queue position. -type WaitingRoomEditResponseCookieAttributes struct { - // Configures the SameSite attribute on the waiting room cookie. Value `auto` will - // be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. - // Note that when using value `none`, the secure attribute cannot be set to - // `never`. - Samesite WaitingRoomEditResponseCookieAttributesSamesite `json:"samesite"` - // Configures the Secure attribute on the waiting room cookie. Value `always` - // indicates that the Secure attribute will be set in the Set-Cookie header, - // `never` indicates that the Secure attribute will not be set, and `auto` will set - // the Secure attribute depending if **Always Use HTTPS** is enabled. - Secure WaitingRoomEditResponseCookieAttributesSecure `json:"secure"` - JSON waitingRoomEditResponseCookieAttributesJSON `json:"-"` -} - -// waitingRoomEditResponseCookieAttributesJSON contains the JSON metadata for the -// struct [WaitingRoomEditResponseCookieAttributes] -type waitingRoomEditResponseCookieAttributesJSON struct { - Samesite apijson.Field - Secure apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEditResponseCookieAttributes) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEditResponseCookieAttributesJSON) RawJSON() string { - return r.raw -} - -// Configures the SameSite attribute on the waiting room cookie. Value `auto` will -// be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. -// Note that when using value `none`, the secure attribute cannot be set to -// `never`. -type WaitingRoomEditResponseCookieAttributesSamesite string - -const ( - WaitingRoomEditResponseCookieAttributesSamesiteAuto WaitingRoomEditResponseCookieAttributesSamesite = "auto" - WaitingRoomEditResponseCookieAttributesSamesiteLax WaitingRoomEditResponseCookieAttributesSamesite = "lax" - WaitingRoomEditResponseCookieAttributesSamesiteNone WaitingRoomEditResponseCookieAttributesSamesite = "none" - WaitingRoomEditResponseCookieAttributesSamesiteStrict WaitingRoomEditResponseCookieAttributesSamesite = "strict" -) - -// Configures the Secure attribute on the waiting room cookie. Value `always` -// indicates that the Secure attribute will be set in the Set-Cookie header, -// `never` indicates that the Secure attribute will not be set, and `auto` will set -// the Secure attribute depending if **Always Use HTTPS** is enabled. -type WaitingRoomEditResponseCookieAttributesSecure string - -const ( - WaitingRoomEditResponseCookieAttributesSecureAuto WaitingRoomEditResponseCookieAttributesSecure = "auto" - WaitingRoomEditResponseCookieAttributesSecureAlways WaitingRoomEditResponseCookieAttributesSecure = "always" - WaitingRoomEditResponseCookieAttributesSecureNever WaitingRoomEditResponseCookieAttributesSecure = "never" -) - -// The language of the default page template. If no default_template_language is -// provided, then `en-US` (English) will be used. -type WaitingRoomEditResponseDefaultTemplateLanguage string - -const ( - WaitingRoomEditResponseDefaultTemplateLanguageEnUs WaitingRoomEditResponseDefaultTemplateLanguage = "en-US" - WaitingRoomEditResponseDefaultTemplateLanguageEsEs WaitingRoomEditResponseDefaultTemplateLanguage = "es-ES" - WaitingRoomEditResponseDefaultTemplateLanguageDeDe WaitingRoomEditResponseDefaultTemplateLanguage = "de-DE" - WaitingRoomEditResponseDefaultTemplateLanguageFrFr WaitingRoomEditResponseDefaultTemplateLanguage = "fr-FR" - WaitingRoomEditResponseDefaultTemplateLanguageItIt WaitingRoomEditResponseDefaultTemplateLanguage = "it-IT" - WaitingRoomEditResponseDefaultTemplateLanguageJaJp WaitingRoomEditResponseDefaultTemplateLanguage = "ja-JP" - WaitingRoomEditResponseDefaultTemplateLanguageKoKr WaitingRoomEditResponseDefaultTemplateLanguage = "ko-KR" - WaitingRoomEditResponseDefaultTemplateLanguagePtBr WaitingRoomEditResponseDefaultTemplateLanguage = "pt-BR" - WaitingRoomEditResponseDefaultTemplateLanguageZhCn WaitingRoomEditResponseDefaultTemplateLanguage = "zh-CN" - WaitingRoomEditResponseDefaultTemplateLanguageZhTw WaitingRoomEditResponseDefaultTemplateLanguage = "zh-TW" - WaitingRoomEditResponseDefaultTemplateLanguageNlNl WaitingRoomEditResponseDefaultTemplateLanguage = "nl-NL" - WaitingRoomEditResponseDefaultTemplateLanguagePlPl WaitingRoomEditResponseDefaultTemplateLanguage = "pl-PL" - WaitingRoomEditResponseDefaultTemplateLanguageIDID WaitingRoomEditResponseDefaultTemplateLanguage = "id-ID" - WaitingRoomEditResponseDefaultTemplateLanguageTrTr WaitingRoomEditResponseDefaultTemplateLanguage = "tr-TR" - WaitingRoomEditResponseDefaultTemplateLanguageArEg WaitingRoomEditResponseDefaultTemplateLanguage = "ar-EG" - WaitingRoomEditResponseDefaultTemplateLanguageRuRu WaitingRoomEditResponseDefaultTemplateLanguage = "ru-RU" - WaitingRoomEditResponseDefaultTemplateLanguageFaIr WaitingRoomEditResponseDefaultTemplateLanguage = "fa-IR" -) - -// Sets the queueing method used by the waiting room. Changing this parameter from -// the **default** queueing method is only available for the Waiting Room Advanced -// subscription. Regardless of the queueing method, if `queue_all` is enabled or an -// event is prequeueing, users in the waiting room will not be accepted to the -// origin. These users will always see a waiting room page that refreshes -// automatically. The valid queueing methods are: -// -// 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in -// the order they arrived. -// 2. `random`: Random queue where customers gain access randomly, regardless of -// arrival time. -// 3. `passthrough`: Users will pass directly through the waiting room and into the -// origin website. As a result, any configured limits will not be respected -// while this is enabled. This method can be used as an alternative to disabling -// a waiting room (with `suspended`) so that analytics are still reported. This -// can be used if you wish to allow all traffic normally, but want to restrict -// traffic during a waiting room event, or vice versa. -// 4. `reject`: Users will be immediately rejected from the waiting room. As a -// result, no users will reach the origin website while this is enabled. This -// can be used if you wish to reject all traffic while performing maintenance, -// block traffic during a specified period of time (an event), or block traffic -// while events are not occurring. Consider a waiting room used for vaccine -// distribution that only allows traffic during sign-up events, and otherwise -// blocks all traffic. For this case, the waiting room uses `reject`, and its -// events override this with `fifo`, `random`, or `passthrough`. When this -// queueing method is enabled and neither `queueAll` is enabled nor an event is -// prequeueing, the waiting room page **will not refresh automatically**. -type WaitingRoomEditResponseQueueingMethod string - -const ( - WaitingRoomEditResponseQueueingMethodFifo WaitingRoomEditResponseQueueingMethod = "fifo" - WaitingRoomEditResponseQueueingMethodRandom WaitingRoomEditResponseQueueingMethod = "random" - WaitingRoomEditResponseQueueingMethodPassthrough WaitingRoomEditResponseQueueingMethod = "passthrough" - WaitingRoomEditResponseQueueingMethodReject WaitingRoomEditResponseQueueingMethod = "reject" -) - -// HTTP status code returned to a user while in the queue. -type WaitingRoomEditResponseQueueingStatusCode int64 - -const ( - WaitingRoomEditResponseQueueingStatusCode200 WaitingRoomEditResponseQueueingStatusCode = 200 - WaitingRoomEditResponseQueueingStatusCode202 WaitingRoomEditResponseQueueingStatusCode = 202 - WaitingRoomEditResponseQueueingStatusCode429 WaitingRoomEditResponseQueueingStatusCode = 429 -) - -type WaitingRoomGetResponse struct { - ID interface{} `json:"id"` - // Only available for the Waiting Room Advanced subscription. Additional hostname - // and path combinations to which this waiting room will be applied. There is an - // implied wildcard at the end of the path. The hostname and path combination must - // be unique to this and all other waiting rooms. - AdditionalRoutes []WaitingRoomGetResponseAdditionalRoute `json:"additional_routes"` - // Configures cookie attributes for the waiting room cookie. This encrypted cookie - // stores a user's status in the waiting room, such as queue position. - CookieAttributes WaitingRoomGetResponseCookieAttributes `json:"cookie_attributes"` - // Appends a '\_' + a custom suffix to the end of Cloudflare Waiting Room's cookie - // name(**cf_waitingroom). If `cookie_suffix` is "abcd", the cookie name will be - // `**cf_waitingroom_abcd`. This field is required if using `additional_routes`. - CookieSuffix string `json:"cookie_suffix"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Only available for the Waiting Room Advanced subscription. This is a template - // html file that will be rendered at the edge. If no custom_page_html is provided, - // the default waiting room will be used. The template is based on mustache ( - // https://mustache.github.io/ ). There are several variables that are evaluated by - // the Cloudflare edge: - // - // 1. {{`waitTimeKnown`}} Acts like a boolean value that indicates the behavior to - // take when wait time is not available, for instance when queue_all is - // **true**. - // 2. {{`waitTimeFormatted`}} Estimated wait time for the user. For example, five - // minutes. Alternatively, you can use: - // 3. {{`waitTime`}} Number of minutes of estimated wait for a user. - // 4. {{`waitTimeHours`}} Number of hours of estimated wait for a user - // (`Math.floor(waitTime/60)`). - // 5. {{`waitTimeHourMinutes`}} Number of minutes above the `waitTimeHours` value - // (`waitTime%60`). - // 6. {{`queueIsFull`}} Changes to **true** when no more people can be added to the - // queue. - // - // To view the full list of variables, look at the `cfWaitingRoom` object described - // under the `json_response_enabled` property in other Waiting Room API calls. - CustomPageHTML string `json:"custom_page_html"` - // The language of the default page template. If no default_template_language is - // provided, then `en-US` (English) will be used. - DefaultTemplateLanguage WaitingRoomGetResponseDefaultTemplateLanguage `json:"default_template_language"` - // A note that you can use to add more details about the waiting room. - Description string `json:"description"` - // Only available for the Waiting Room Advanced subscription. Disables automatic - // renewal of session cookies. If `true`, an accepted user will have - // session_duration minutes to browse the site. After that, they will have to go - // through the waiting room again. If `false`, a user's session cookie will be - // automatically renewed on every request. - DisableSessionRenewal bool `json:"disable_session_renewal"` - // The host name to which the waiting room will be applied (no wildcards). Please - // do not include the scheme (http:// or https://). The host and path combination - // must be unique. - Host string `json:"host"` - // Only available for the Waiting Room Advanced subscription. If `true`, requests - // to the waiting room with the header `Accept: application/json` will receive a - // JSON response object with information on the user's status in the waiting room - // as opposed to the configured static HTML page. This JSON response object has one - // property `cfWaitingRoom` which is an object containing the following fields: - // - // 1. `inWaitingRoom`: Boolean indicating if the user is in the waiting room - // (always **true**). - // 2. `waitTimeKnown`: Boolean indicating if the current estimated wait times are - // accurate. If **false**, they are not available. - // 3. `waitTime`: Valid only when `waitTimeKnown` is **true**. Integer indicating - // the current estimated time in minutes the user will wait in the waiting room. - // When `queueingMethod` is **random**, this is set to `waitTime50Percentile`. - // 4. `waitTime25Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 25% of users that gain entry the fastest (25th percentile). - // 5. `waitTime50Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 50% of users that gain entry the fastest (50th percentile). - // In other words, half of the queued users are expected to let into the origin - // website before `waitTime50Percentile` and half are expected to be let in - // after it. - // 6. `waitTime75Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 75% of users that gain entry the fastest (75th percentile). - // 7. `waitTimeFormatted`: String displaying the `waitTime` formatted in English - // for users. If `waitTimeKnown` is **false**, `waitTimeFormatted` will display - // **unavailable**. - // 8. `queueIsFull`: Boolean indicating if the waiting room's queue is currently - // full and not accepting new users at the moment. - // 9. `queueAll`: Boolean indicating if all users will be queued in the waiting - // room and no one will be let into the origin website. - // 10. `lastUpdated`: String displaying the timestamp as an ISO 8601 string of the - // user's last attempt to leave the waiting room and be let into the origin - // website. The user is able to make another attempt after - // `refreshIntervalSeconds` past this time. If the user makes a request too - // soon, it will be ignored and `lastUpdated` will not change. - // 11. `refreshIntervalSeconds`: Integer indicating the number of seconds after - // `lastUpdated` until the user is able to make another attempt to leave the - // waiting room and be let into the origin website. When the `queueingMethod` - // is `reject`, there is no specified refresh time — it will always be - // **zero**. - // 12. `queueingMethod`: The queueing method currently used by the waiting room. It - // is either **fifo**, **random**, **passthrough**, or **reject**. - // 13. `isFIFOQueue`: Boolean indicating if the waiting room uses a FIFO - // (First-In-First-Out) queue. - // 14. `isRandomQueue`: Boolean indicating if the waiting room uses a Random queue - // where users gain access randomly. - // 15. `isPassthroughQueue`: Boolean indicating if the waiting room uses a - // passthrough queue. Keep in mind that when passthrough is enabled, this JSON - // response will only exist when `queueAll` is **true** or `isEventPrequeueing` - // is **true** because in all other cases requests will go directly to the - // origin. - // 16. `isRejectQueue`: Boolean indicating if the waiting room uses a reject queue. - // 17. `isEventActive`: Boolean indicating if an event is currently occurring. - // Events are able to change a waiting room's behavior during a specified - // period of time. For additional information, look at the event properties - // `prequeue_start_time`, `event_start_time`, and `event_end_time` in the - // documentation for creating waiting room events. Events are considered active - // between these start and end times, as well as during the prequeueing period - // if it exists. - // 18. `isEventPrequeueing`: Valid only when `isEventActive` is **true**. Boolean - // indicating if an event is currently prequeueing users before it starts. - // 19. `timeUntilEventStart`: Valid only when `isEventPrequeueing` is **true**. - // Integer indicating the number of minutes until the event starts. - // 20. `timeUntilEventStartFormatted`: String displaying the `timeUntilEventStart` - // formatted in English for users. If `isEventPrequeueing` is **false**, - // `timeUntilEventStartFormatted` will display **unavailable**. - // 21. `timeUntilEventEnd`: Valid only when `isEventActive` is **true**. Integer - // indicating the number of minutes until the event ends. - // 22. `timeUntilEventEndFormatted`: String displaying the `timeUntilEventEnd` - // formatted in English for users. If `isEventActive` is **false**, - // `timeUntilEventEndFormatted` will display **unavailable**. - // 23. `shuffleAtEventStart`: Valid only when `isEventActive` is **true**. Boolean - // indicating if the users in the prequeue are shuffled randomly when the event - // starts. - // - // An example cURL to a waiting room could be: - // - // curl -X GET "https://example.com/waitingroom" \ - // -H "Accept: application/json" - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **fifo** and no event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 0, - // "waitTime50Percentile": 0, - // "waitTime75Percentile": 0, - // "waitTimeFormatted": "10 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "fifo", - // "isFIFOQueue": true, - // "isRandomQueue": false, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": false, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 0, - // "timeUntilEventEndFormatted": "unavailable", - // "shuffleAtEventStart": false - // } - // } - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **random** and an event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 5, - // "waitTime50Percentile": 10, - // "waitTime75Percentile": 15, - // "waitTimeFormatted": "5 minutes to 15 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "random", - // "isFIFOQueue": false, - // "isRandomQueue": true, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": true, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 15, - // "timeUntilEventEndFormatted": "15 minutes", - // "shuffleAtEventStart": true - // } - // }. - JsonResponseEnabled bool `json:"json_response_enabled"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A unique name to identify the waiting room. Only alphanumeric characters, - // hyphens and underscores are allowed. - Name string `json:"name"` - // Sets the number of new users that will be let into the route every minute. This - // value is used as baseline for the number of users that are let in per minute. So - // it is possible that there is a little more or little less traffic coming to the - // route based on the traffic patterns at that time around the world. - NewUsersPerMinute int64 `json:"new_users_per_minute"` - // An ISO 8601 timestamp that marks when the next event will begin queueing. - NextEventPrequeueStartTime string `json:"next_event_prequeue_start_time,nullable"` - // An ISO 8601 timestamp that marks when the next event will start. - NextEventStartTime string `json:"next_event_start_time,nullable"` - // Sets the path within the host to enable the waiting room on. The waiting room - // will be enabled for all subpaths as well. If there are two waiting rooms on the - // same subpath, the waiting room for the most specific path will be chosen. - // Wildcards and query parameters are not supported. - Path string `json:"path"` - // If queue_all is `true`, all the traffic that is coming to a route will be sent - // to the waiting room. No new traffic can get to the route once this field is set - // and estimated time will become unavailable. - QueueAll bool `json:"queue_all"` - // Sets the queueing method used by the waiting room. Changing this parameter from - // the **default** queueing method is only available for the Waiting Room Advanced - // subscription. Regardless of the queueing method, if `queue_all` is enabled or an - // event is prequeueing, users in the waiting room will not be accepted to the - // origin. These users will always see a waiting room page that refreshes - // automatically. The valid queueing methods are: - // - // 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in - // the order they arrived. - // 2. `random`: Random queue where customers gain access randomly, regardless of - // arrival time. - // 3. `passthrough`: Users will pass directly through the waiting room and into the - // origin website. As a result, any configured limits will not be respected - // while this is enabled. This method can be used as an alternative to disabling - // a waiting room (with `suspended`) so that analytics are still reported. This - // can be used if you wish to allow all traffic normally, but want to restrict - // traffic during a waiting room event, or vice versa. - // 4. `reject`: Users will be immediately rejected from the waiting room. As a - // result, no users will reach the origin website while this is enabled. This - // can be used if you wish to reject all traffic while performing maintenance, - // block traffic during a specified period of time (an event), or block traffic - // while events are not occurring. Consider a waiting room used for vaccine - // distribution that only allows traffic during sign-up events, and otherwise - // blocks all traffic. For this case, the waiting room uses `reject`, and its - // events override this with `fifo`, `random`, or `passthrough`. When this - // queueing method is enabled and neither `queueAll` is enabled nor an event is - // prequeueing, the waiting room page **will not refresh automatically**. - QueueingMethod WaitingRoomGetResponseQueueingMethod `json:"queueing_method"` - // HTTP status code returned to a user while in the queue. - QueueingStatusCode WaitingRoomGetResponseQueueingStatusCode `json:"queueing_status_code"` - // Lifetime of a cookie (in minutes) set by Cloudflare for users who get access to - // the route. If a user is not seen by Cloudflare again in that time period, they - // will be treated as a new user that visits the route. - SessionDuration int64 `json:"session_duration"` - // Suspends or allows traffic going to the waiting room. If set to `true`, the - // traffic will not go to the waiting room. - Suspended bool `json:"suspended"` - // Sets the total number of active user sessions on the route at a point in time. A - // route is a combination of host and path on which a waiting room is available. - // This value is used as a baseline for the total number of active user sessions on - // the route. It is possible to have a situation where there are more or less - // active users sessions on the route based on the traffic patterns at that time - // around the world. - TotalActiveUsers int64 `json:"total_active_users"` - JSON waitingRoomGetResponseJSON `json:"-"` -} - -// waitingRoomGetResponseJSON contains the JSON metadata for the struct -// [WaitingRoomGetResponse] -type waitingRoomGetResponseJSON struct { - ID apijson.Field - AdditionalRoutes apijson.Field - CookieAttributes apijson.Field - CookieSuffix apijson.Field - CreatedOn apijson.Field - CustomPageHTML apijson.Field - DefaultTemplateLanguage apijson.Field - Description apijson.Field - DisableSessionRenewal apijson.Field - Host apijson.Field - JsonResponseEnabled apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - NewUsersPerMinute apijson.Field - NextEventPrequeueStartTime apijson.Field - NextEventStartTime apijson.Field - Path apijson.Field - QueueAll apijson.Field - QueueingMethod apijson.Field - QueueingStatusCode apijson.Field - SessionDuration apijson.Field - Suspended apijson.Field - TotalActiveUsers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomGetResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomGetResponseAdditionalRoute struct { - // The hostname to which this waiting room will be applied (no wildcards). The - // hostname must be the primary domain, subdomain, or custom hostname (if using SSL - // for SaaS) of this zone. Please do not include the scheme (http:// or https://). - Host string `json:"host"` - // Sets the path within the host to enable the waiting room on. The waiting room - // will be enabled for all subpaths as well. If there are two waiting rooms on the - // same subpath, the waiting room for the most specific path will be chosen. - // Wildcards and query parameters are not supported. - Path string `json:"path"` - JSON waitingRoomGetResponseAdditionalRouteJSON `json:"-"` -} - -// waitingRoomGetResponseAdditionalRouteJSON contains the JSON metadata for the -// struct [WaitingRoomGetResponseAdditionalRoute] -type waitingRoomGetResponseAdditionalRouteJSON struct { - Host apijson.Field - Path apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomGetResponseAdditionalRoute) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomGetResponseAdditionalRouteJSON) RawJSON() string { - return r.raw -} - -// Configures cookie attributes for the waiting room cookie. This encrypted cookie -// stores a user's status in the waiting room, such as queue position. -type WaitingRoomGetResponseCookieAttributes struct { - // Configures the SameSite attribute on the waiting room cookie. Value `auto` will - // be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. - // Note that when using value `none`, the secure attribute cannot be set to - // `never`. - Samesite WaitingRoomGetResponseCookieAttributesSamesite `json:"samesite"` - // Configures the Secure attribute on the waiting room cookie. Value `always` - // indicates that the Secure attribute will be set in the Set-Cookie header, - // `never` indicates that the Secure attribute will not be set, and `auto` will set - // the Secure attribute depending if **Always Use HTTPS** is enabled. - Secure WaitingRoomGetResponseCookieAttributesSecure `json:"secure"` - JSON waitingRoomGetResponseCookieAttributesJSON `json:"-"` -} - -// waitingRoomGetResponseCookieAttributesJSON contains the JSON metadata for the -// struct [WaitingRoomGetResponseCookieAttributes] -type waitingRoomGetResponseCookieAttributesJSON struct { - Samesite apijson.Field - Secure apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomGetResponseCookieAttributes) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomGetResponseCookieAttributesJSON) RawJSON() string { - return r.raw -} - -// Configures the SameSite attribute on the waiting room cookie. Value `auto` will -// be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. -// Note that when using value `none`, the secure attribute cannot be set to -// `never`. -type WaitingRoomGetResponseCookieAttributesSamesite string - -const ( - WaitingRoomGetResponseCookieAttributesSamesiteAuto WaitingRoomGetResponseCookieAttributesSamesite = "auto" - WaitingRoomGetResponseCookieAttributesSamesiteLax WaitingRoomGetResponseCookieAttributesSamesite = "lax" - WaitingRoomGetResponseCookieAttributesSamesiteNone WaitingRoomGetResponseCookieAttributesSamesite = "none" - WaitingRoomGetResponseCookieAttributesSamesiteStrict WaitingRoomGetResponseCookieAttributesSamesite = "strict" -) - -// Configures the Secure attribute on the waiting room cookie. Value `always` -// indicates that the Secure attribute will be set in the Set-Cookie header, -// `never` indicates that the Secure attribute will not be set, and `auto` will set -// the Secure attribute depending if **Always Use HTTPS** is enabled. -type WaitingRoomGetResponseCookieAttributesSecure string - -const ( - WaitingRoomGetResponseCookieAttributesSecureAuto WaitingRoomGetResponseCookieAttributesSecure = "auto" - WaitingRoomGetResponseCookieAttributesSecureAlways WaitingRoomGetResponseCookieAttributesSecure = "always" - WaitingRoomGetResponseCookieAttributesSecureNever WaitingRoomGetResponseCookieAttributesSecure = "never" -) - -// The language of the default page template. If no default_template_language is -// provided, then `en-US` (English) will be used. -type WaitingRoomGetResponseDefaultTemplateLanguage string - -const ( - WaitingRoomGetResponseDefaultTemplateLanguageEnUs WaitingRoomGetResponseDefaultTemplateLanguage = "en-US" - WaitingRoomGetResponseDefaultTemplateLanguageEsEs WaitingRoomGetResponseDefaultTemplateLanguage = "es-ES" - WaitingRoomGetResponseDefaultTemplateLanguageDeDe WaitingRoomGetResponseDefaultTemplateLanguage = "de-DE" - WaitingRoomGetResponseDefaultTemplateLanguageFrFr WaitingRoomGetResponseDefaultTemplateLanguage = "fr-FR" - WaitingRoomGetResponseDefaultTemplateLanguageItIt WaitingRoomGetResponseDefaultTemplateLanguage = "it-IT" - WaitingRoomGetResponseDefaultTemplateLanguageJaJp WaitingRoomGetResponseDefaultTemplateLanguage = "ja-JP" - WaitingRoomGetResponseDefaultTemplateLanguageKoKr WaitingRoomGetResponseDefaultTemplateLanguage = "ko-KR" - WaitingRoomGetResponseDefaultTemplateLanguagePtBr WaitingRoomGetResponseDefaultTemplateLanguage = "pt-BR" - WaitingRoomGetResponseDefaultTemplateLanguageZhCn WaitingRoomGetResponseDefaultTemplateLanguage = "zh-CN" - WaitingRoomGetResponseDefaultTemplateLanguageZhTw WaitingRoomGetResponseDefaultTemplateLanguage = "zh-TW" - WaitingRoomGetResponseDefaultTemplateLanguageNlNl WaitingRoomGetResponseDefaultTemplateLanguage = "nl-NL" - WaitingRoomGetResponseDefaultTemplateLanguagePlPl WaitingRoomGetResponseDefaultTemplateLanguage = "pl-PL" - WaitingRoomGetResponseDefaultTemplateLanguageIDID WaitingRoomGetResponseDefaultTemplateLanguage = "id-ID" - WaitingRoomGetResponseDefaultTemplateLanguageTrTr WaitingRoomGetResponseDefaultTemplateLanguage = "tr-TR" - WaitingRoomGetResponseDefaultTemplateLanguageArEg WaitingRoomGetResponseDefaultTemplateLanguage = "ar-EG" - WaitingRoomGetResponseDefaultTemplateLanguageRuRu WaitingRoomGetResponseDefaultTemplateLanguage = "ru-RU" - WaitingRoomGetResponseDefaultTemplateLanguageFaIr WaitingRoomGetResponseDefaultTemplateLanguage = "fa-IR" -) - -// Sets the queueing method used by the waiting room. Changing this parameter from -// the **default** queueing method is only available for the Waiting Room Advanced -// subscription. Regardless of the queueing method, if `queue_all` is enabled or an -// event is prequeueing, users in the waiting room will not be accepted to the -// origin. These users will always see a waiting room page that refreshes -// automatically. The valid queueing methods are: -// -// 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in -// the order they arrived. -// 2. `random`: Random queue where customers gain access randomly, regardless of -// arrival time. -// 3. `passthrough`: Users will pass directly through the waiting room and into the -// origin website. As a result, any configured limits will not be respected -// while this is enabled. This method can be used as an alternative to disabling -// a waiting room (with `suspended`) so that analytics are still reported. This -// can be used if you wish to allow all traffic normally, but want to restrict -// traffic during a waiting room event, or vice versa. -// 4. `reject`: Users will be immediately rejected from the waiting room. As a -// result, no users will reach the origin website while this is enabled. This -// can be used if you wish to reject all traffic while performing maintenance, -// block traffic during a specified period of time (an event), or block traffic -// while events are not occurring. Consider a waiting room used for vaccine -// distribution that only allows traffic during sign-up events, and otherwise -// blocks all traffic. For this case, the waiting room uses `reject`, and its -// events override this with `fifo`, `random`, or `passthrough`. When this -// queueing method is enabled and neither `queueAll` is enabled nor an event is -// prequeueing, the waiting room page **will not refresh automatically**. -type WaitingRoomGetResponseQueueingMethod string - -const ( - WaitingRoomGetResponseQueueingMethodFifo WaitingRoomGetResponseQueueingMethod = "fifo" - WaitingRoomGetResponseQueueingMethodRandom WaitingRoomGetResponseQueueingMethod = "random" - WaitingRoomGetResponseQueueingMethodPassthrough WaitingRoomGetResponseQueueingMethod = "passthrough" - WaitingRoomGetResponseQueueingMethodReject WaitingRoomGetResponseQueueingMethod = "reject" -) - -// HTTP status code returned to a user while in the queue. -type WaitingRoomGetResponseQueueingStatusCode int64 - -const ( - WaitingRoomGetResponseQueueingStatusCode200 WaitingRoomGetResponseQueueingStatusCode = 200 - WaitingRoomGetResponseQueueingStatusCode202 WaitingRoomGetResponseQueueingStatusCode = 202 - WaitingRoomGetResponseQueueingStatusCode429 WaitingRoomGetResponseQueueingStatusCode = 429 -) - -type WaitingRoomPreviewResponse struct { - // URL where the custom waiting room page can temporarily be previewed. - PreviewURL string `json:"preview_url"` - JSON waitingRoomPreviewResponseJSON `json:"-"` -} - -// waitingRoomPreviewResponseJSON contains the JSON metadata for the struct -// [WaitingRoomPreviewResponse] -type waitingRoomPreviewResponseJSON struct { - PreviewURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomPreviewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomPreviewResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomNewParams struct { - // The host name to which the waiting room will be applied (no wildcards). Please - // do not include the scheme (http:// or https://). The host and path combination - // must be unique. - Host param.Field[string] `json:"host,required"` - // A unique name to identify the waiting room. Only alphanumeric characters, - // hyphens and underscores are allowed. - Name param.Field[string] `json:"name,required"` - // Sets the number of new users that will be let into the route every minute. This - // value is used as baseline for the number of users that are let in per minute. So - // it is possible that there is a little more or little less traffic coming to the - // route based on the traffic patterns at that time around the world. - NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute,required"` - // Sets the total number of active user sessions on the route at a point in time. A - // route is a combination of host and path on which a waiting room is available. - // This value is used as a baseline for the total number of active user sessions on - // the route. It is possible to have a situation where there are more or less - // active users sessions on the route based on the traffic patterns at that time - // around the world. - TotalActiveUsers param.Field[int64] `json:"total_active_users,required"` - // Only available for the Waiting Room Advanced subscription. Additional hostname - // and path combinations to which this waiting room will be applied. There is an - // implied wildcard at the end of the path. The hostname and path combination must - // be unique to this and all other waiting rooms. - AdditionalRoutes param.Field[[]WaitingRoomNewParamsAdditionalRoute] `json:"additional_routes"` - // Configures cookie attributes for the waiting room cookie. This encrypted cookie - // stores a user's status in the waiting room, such as queue position. - CookieAttributes param.Field[WaitingRoomNewParamsCookieAttributes] `json:"cookie_attributes"` - // Appends a '\_' + a custom suffix to the end of Cloudflare Waiting Room's cookie - // name(**cf_waitingroom). If `cookie_suffix` is "abcd", the cookie name will be - // `**cf_waitingroom_abcd`. This field is required if using `additional_routes`. - CookieSuffix param.Field[string] `json:"cookie_suffix"` - // Only available for the Waiting Room Advanced subscription. This is a template - // html file that will be rendered at the edge. If no custom_page_html is provided, - // the default waiting room will be used. The template is based on mustache ( - // https://mustache.github.io/ ). There are several variables that are evaluated by - // the Cloudflare edge: - // - // 1. {{`waitTimeKnown`}} Acts like a boolean value that indicates the behavior to - // take when wait time is not available, for instance when queue_all is - // **true**. - // 2. {{`waitTimeFormatted`}} Estimated wait time for the user. For example, five - // minutes. Alternatively, you can use: - // 3. {{`waitTime`}} Number of minutes of estimated wait for a user. - // 4. {{`waitTimeHours`}} Number of hours of estimated wait for a user - // (`Math.floor(waitTime/60)`). - // 5. {{`waitTimeHourMinutes`}} Number of minutes above the `waitTimeHours` value - // (`waitTime%60`). - // 6. {{`queueIsFull`}} Changes to **true** when no more people can be added to the - // queue. - // - // To view the full list of variables, look at the `cfWaitingRoom` object described - // under the `json_response_enabled` property in other Waiting Room API calls. - CustomPageHTML param.Field[string] `json:"custom_page_html"` - // The language of the default page template. If no default_template_language is - // provided, then `en-US` (English) will be used. - DefaultTemplateLanguage param.Field[WaitingRoomNewParamsDefaultTemplateLanguage] `json:"default_template_language"` - // A note that you can use to add more details about the waiting room. - Description param.Field[string] `json:"description"` - // Only available for the Waiting Room Advanced subscription. Disables automatic - // renewal of session cookies. If `true`, an accepted user will have - // session_duration minutes to browse the site. After that, they will have to go - // through the waiting room again. If `false`, a user's session cookie will be - // automatically renewed on every request. - DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` - // Only available for the Waiting Room Advanced subscription. If `true`, requests - // to the waiting room with the header `Accept: application/json` will receive a - // JSON response object with information on the user's status in the waiting room - // as opposed to the configured static HTML page. This JSON response object has one - // property `cfWaitingRoom` which is an object containing the following fields: - // - // 1. `inWaitingRoom`: Boolean indicating if the user is in the waiting room - // (always **true**). - // 2. `waitTimeKnown`: Boolean indicating if the current estimated wait times are - // accurate. If **false**, they are not available. - // 3. `waitTime`: Valid only when `waitTimeKnown` is **true**. Integer indicating - // the current estimated time in minutes the user will wait in the waiting room. - // When `queueingMethod` is **random**, this is set to `waitTime50Percentile`. - // 4. `waitTime25Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 25% of users that gain entry the fastest (25th percentile). - // 5. `waitTime50Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 50% of users that gain entry the fastest (50th percentile). - // In other words, half of the queued users are expected to let into the origin - // website before `waitTime50Percentile` and half are expected to be let in - // after it. - // 6. `waitTime75Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 75% of users that gain entry the fastest (75th percentile). - // 7. `waitTimeFormatted`: String displaying the `waitTime` formatted in English - // for users. If `waitTimeKnown` is **false**, `waitTimeFormatted` will display - // **unavailable**. - // 8. `queueIsFull`: Boolean indicating if the waiting room's queue is currently - // full and not accepting new users at the moment. - // 9. `queueAll`: Boolean indicating if all users will be queued in the waiting - // room and no one will be let into the origin website. - // 10. `lastUpdated`: String displaying the timestamp as an ISO 8601 string of the - // user's last attempt to leave the waiting room and be let into the origin - // website. The user is able to make another attempt after - // `refreshIntervalSeconds` past this time. If the user makes a request too - // soon, it will be ignored and `lastUpdated` will not change. - // 11. `refreshIntervalSeconds`: Integer indicating the number of seconds after - // `lastUpdated` until the user is able to make another attempt to leave the - // waiting room and be let into the origin website. When the `queueingMethod` - // is `reject`, there is no specified refresh time — it will always be - // **zero**. - // 12. `queueingMethod`: The queueing method currently used by the waiting room. It - // is either **fifo**, **random**, **passthrough**, or **reject**. - // 13. `isFIFOQueue`: Boolean indicating if the waiting room uses a FIFO - // (First-In-First-Out) queue. - // 14. `isRandomQueue`: Boolean indicating if the waiting room uses a Random queue - // where users gain access randomly. - // 15. `isPassthroughQueue`: Boolean indicating if the waiting room uses a - // passthrough queue. Keep in mind that when passthrough is enabled, this JSON - // response will only exist when `queueAll` is **true** or `isEventPrequeueing` - // is **true** because in all other cases requests will go directly to the - // origin. - // 16. `isRejectQueue`: Boolean indicating if the waiting room uses a reject queue. - // 17. `isEventActive`: Boolean indicating if an event is currently occurring. - // Events are able to change a waiting room's behavior during a specified - // period of time. For additional information, look at the event properties - // `prequeue_start_time`, `event_start_time`, and `event_end_time` in the - // documentation for creating waiting room events. Events are considered active - // between these start and end times, as well as during the prequeueing period - // if it exists. - // 18. `isEventPrequeueing`: Valid only when `isEventActive` is **true**. Boolean - // indicating if an event is currently prequeueing users before it starts. - // 19. `timeUntilEventStart`: Valid only when `isEventPrequeueing` is **true**. - // Integer indicating the number of minutes until the event starts. - // 20. `timeUntilEventStartFormatted`: String displaying the `timeUntilEventStart` - // formatted in English for users. If `isEventPrequeueing` is **false**, - // `timeUntilEventStartFormatted` will display **unavailable**. - // 21. `timeUntilEventEnd`: Valid only when `isEventActive` is **true**. Integer - // indicating the number of minutes until the event ends. - // 22. `timeUntilEventEndFormatted`: String displaying the `timeUntilEventEnd` - // formatted in English for users. If `isEventActive` is **false**, - // `timeUntilEventEndFormatted` will display **unavailable**. - // 23. `shuffleAtEventStart`: Valid only when `isEventActive` is **true**. Boolean - // indicating if the users in the prequeue are shuffled randomly when the event - // starts. - // - // An example cURL to a waiting room could be: - // - // curl -X GET "https://example.com/waitingroom" \ - // -H "Accept: application/json" - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **fifo** and no event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 0, - // "waitTime50Percentile": 0, - // "waitTime75Percentile": 0, - // "waitTimeFormatted": "10 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "fifo", - // "isFIFOQueue": true, - // "isRandomQueue": false, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": false, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 0, - // "timeUntilEventEndFormatted": "unavailable", - // "shuffleAtEventStart": false - // } - // } - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **random** and an event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 5, - // "waitTime50Percentile": 10, - // "waitTime75Percentile": 15, - // "waitTimeFormatted": "5 minutes to 15 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "random", - // "isFIFOQueue": false, - // "isRandomQueue": true, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": true, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 15, - // "timeUntilEventEndFormatted": "15 minutes", - // "shuffleAtEventStart": true - // } - // }. - JsonResponseEnabled param.Field[bool] `json:"json_response_enabled"` - // Sets the path within the host to enable the waiting room on. The waiting room - // will be enabled for all subpaths as well. If there are two waiting rooms on the - // same subpath, the waiting room for the most specific path will be chosen. - // Wildcards and query parameters are not supported. - Path param.Field[string] `json:"path"` - // If queue_all is `true`, all the traffic that is coming to a route will be sent - // to the waiting room. No new traffic can get to the route once this field is set - // and estimated time will become unavailable. - QueueAll param.Field[bool] `json:"queue_all"` - // Sets the queueing method used by the waiting room. Changing this parameter from - // the **default** queueing method is only available for the Waiting Room Advanced - // subscription. Regardless of the queueing method, if `queue_all` is enabled or an - // event is prequeueing, users in the waiting room will not be accepted to the - // origin. These users will always see a waiting room page that refreshes - // automatically. The valid queueing methods are: - // - // 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in - // the order they arrived. - // 2. `random`: Random queue where customers gain access randomly, regardless of - // arrival time. - // 3. `passthrough`: Users will pass directly through the waiting room and into the - // origin website. As a result, any configured limits will not be respected - // while this is enabled. This method can be used as an alternative to disabling - // a waiting room (with `suspended`) so that analytics are still reported. This - // can be used if you wish to allow all traffic normally, but want to restrict - // traffic during a waiting room event, or vice versa. - // 4. `reject`: Users will be immediately rejected from the waiting room. As a - // result, no users will reach the origin website while this is enabled. This - // can be used if you wish to reject all traffic while performing maintenance, - // block traffic during a specified period of time (an event), or block traffic - // while events are not occurring. Consider a waiting room used for vaccine - // distribution that only allows traffic during sign-up events, and otherwise - // blocks all traffic. For this case, the waiting room uses `reject`, and its - // events override this with `fifo`, `random`, or `passthrough`. When this - // queueing method is enabled and neither `queueAll` is enabled nor an event is - // prequeueing, the waiting room page **will not refresh automatically**. - QueueingMethod param.Field[WaitingRoomNewParamsQueueingMethod] `json:"queueing_method"` - // HTTP status code returned to a user while in the queue. - QueueingStatusCode param.Field[WaitingRoomNewParamsQueueingStatusCode] `json:"queueing_status_code"` - // Lifetime of a cookie (in minutes) set by Cloudflare for users who get access to - // the route. If a user is not seen by Cloudflare again in that time period, they - // will be treated as a new user that visits the route. - SessionDuration param.Field[int64] `json:"session_duration"` - // Suspends or allows traffic going to the waiting room. If set to `true`, the - // traffic will not go to the waiting room. - Suspended param.Field[bool] `json:"suspended"` -} - -func (r WaitingRoomNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WaitingRoomNewParamsAdditionalRoute struct { - // The hostname to which this waiting room will be applied (no wildcards). The - // hostname must be the primary domain, subdomain, or custom hostname (if using SSL - // for SaaS) of this zone. Please do not include the scheme (http:// or https://). - Host param.Field[string] `json:"host"` - // Sets the path within the host to enable the waiting room on. The waiting room - // will be enabled for all subpaths as well. If there are two waiting rooms on the - // same subpath, the waiting room for the most specific path will be chosen. - // Wildcards and query parameters are not supported. - Path param.Field[string] `json:"path"` -} - -func (r WaitingRoomNewParamsAdditionalRoute) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures cookie attributes for the waiting room cookie. This encrypted cookie -// stores a user's status in the waiting room, such as queue position. -type WaitingRoomNewParamsCookieAttributes struct { - // Configures the SameSite attribute on the waiting room cookie. Value `auto` will - // be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. - // Note that when using value `none`, the secure attribute cannot be set to - // `never`. - Samesite param.Field[WaitingRoomNewParamsCookieAttributesSamesite] `json:"samesite"` - // Configures the Secure attribute on the waiting room cookie. Value `always` - // indicates that the Secure attribute will be set in the Set-Cookie header, - // `never` indicates that the Secure attribute will not be set, and `auto` will set - // the Secure attribute depending if **Always Use HTTPS** is enabled. - Secure param.Field[WaitingRoomNewParamsCookieAttributesSecure] `json:"secure"` -} - -func (r WaitingRoomNewParamsCookieAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures the SameSite attribute on the waiting room cookie. Value `auto` will -// be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. -// Note that when using value `none`, the secure attribute cannot be set to -// `never`. -type WaitingRoomNewParamsCookieAttributesSamesite string - -const ( - WaitingRoomNewParamsCookieAttributesSamesiteAuto WaitingRoomNewParamsCookieAttributesSamesite = "auto" - WaitingRoomNewParamsCookieAttributesSamesiteLax WaitingRoomNewParamsCookieAttributesSamesite = "lax" - WaitingRoomNewParamsCookieAttributesSamesiteNone WaitingRoomNewParamsCookieAttributesSamesite = "none" - WaitingRoomNewParamsCookieAttributesSamesiteStrict WaitingRoomNewParamsCookieAttributesSamesite = "strict" -) - -// Configures the Secure attribute on the waiting room cookie. Value `always` -// indicates that the Secure attribute will be set in the Set-Cookie header, -// `never` indicates that the Secure attribute will not be set, and `auto` will set -// the Secure attribute depending if **Always Use HTTPS** is enabled. -type WaitingRoomNewParamsCookieAttributesSecure string - -const ( - WaitingRoomNewParamsCookieAttributesSecureAuto WaitingRoomNewParamsCookieAttributesSecure = "auto" - WaitingRoomNewParamsCookieAttributesSecureAlways WaitingRoomNewParamsCookieAttributesSecure = "always" - WaitingRoomNewParamsCookieAttributesSecureNever WaitingRoomNewParamsCookieAttributesSecure = "never" -) - -// The language of the default page template. If no default_template_language is -// provided, then `en-US` (English) will be used. -type WaitingRoomNewParamsDefaultTemplateLanguage string - -const ( - WaitingRoomNewParamsDefaultTemplateLanguageEnUs WaitingRoomNewParamsDefaultTemplateLanguage = "en-US" - WaitingRoomNewParamsDefaultTemplateLanguageEsEs WaitingRoomNewParamsDefaultTemplateLanguage = "es-ES" - WaitingRoomNewParamsDefaultTemplateLanguageDeDe WaitingRoomNewParamsDefaultTemplateLanguage = "de-DE" - WaitingRoomNewParamsDefaultTemplateLanguageFrFr WaitingRoomNewParamsDefaultTemplateLanguage = "fr-FR" - WaitingRoomNewParamsDefaultTemplateLanguageItIt WaitingRoomNewParamsDefaultTemplateLanguage = "it-IT" - WaitingRoomNewParamsDefaultTemplateLanguageJaJp WaitingRoomNewParamsDefaultTemplateLanguage = "ja-JP" - WaitingRoomNewParamsDefaultTemplateLanguageKoKr WaitingRoomNewParamsDefaultTemplateLanguage = "ko-KR" - WaitingRoomNewParamsDefaultTemplateLanguagePtBr WaitingRoomNewParamsDefaultTemplateLanguage = "pt-BR" - WaitingRoomNewParamsDefaultTemplateLanguageZhCn WaitingRoomNewParamsDefaultTemplateLanguage = "zh-CN" - WaitingRoomNewParamsDefaultTemplateLanguageZhTw WaitingRoomNewParamsDefaultTemplateLanguage = "zh-TW" - WaitingRoomNewParamsDefaultTemplateLanguageNlNl WaitingRoomNewParamsDefaultTemplateLanguage = "nl-NL" - WaitingRoomNewParamsDefaultTemplateLanguagePlPl WaitingRoomNewParamsDefaultTemplateLanguage = "pl-PL" - WaitingRoomNewParamsDefaultTemplateLanguageIDID WaitingRoomNewParamsDefaultTemplateLanguage = "id-ID" - WaitingRoomNewParamsDefaultTemplateLanguageTrTr WaitingRoomNewParamsDefaultTemplateLanguage = "tr-TR" - WaitingRoomNewParamsDefaultTemplateLanguageArEg WaitingRoomNewParamsDefaultTemplateLanguage = "ar-EG" - WaitingRoomNewParamsDefaultTemplateLanguageRuRu WaitingRoomNewParamsDefaultTemplateLanguage = "ru-RU" - WaitingRoomNewParamsDefaultTemplateLanguageFaIr WaitingRoomNewParamsDefaultTemplateLanguage = "fa-IR" -) - -// Sets the queueing method used by the waiting room. Changing this parameter from -// the **default** queueing method is only available for the Waiting Room Advanced -// subscription. Regardless of the queueing method, if `queue_all` is enabled or an -// event is prequeueing, users in the waiting room will not be accepted to the -// origin. These users will always see a waiting room page that refreshes -// automatically. The valid queueing methods are: -// -// 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in -// the order they arrived. -// 2. `random`: Random queue where customers gain access randomly, regardless of -// arrival time. -// 3. `passthrough`: Users will pass directly through the waiting room and into the -// origin website. As a result, any configured limits will not be respected -// while this is enabled. This method can be used as an alternative to disabling -// a waiting room (with `suspended`) so that analytics are still reported. This -// can be used if you wish to allow all traffic normally, but want to restrict -// traffic during a waiting room event, or vice versa. -// 4. `reject`: Users will be immediately rejected from the waiting room. As a -// result, no users will reach the origin website while this is enabled. This -// can be used if you wish to reject all traffic while performing maintenance, -// block traffic during a specified period of time (an event), or block traffic -// while events are not occurring. Consider a waiting room used for vaccine -// distribution that only allows traffic during sign-up events, and otherwise -// blocks all traffic. For this case, the waiting room uses `reject`, and its -// events override this with `fifo`, `random`, or `passthrough`. When this -// queueing method is enabled and neither `queueAll` is enabled nor an event is -// prequeueing, the waiting room page **will not refresh automatically**. -type WaitingRoomNewParamsQueueingMethod string - -const ( - WaitingRoomNewParamsQueueingMethodFifo WaitingRoomNewParamsQueueingMethod = "fifo" - WaitingRoomNewParamsQueueingMethodRandom WaitingRoomNewParamsQueueingMethod = "random" - WaitingRoomNewParamsQueueingMethodPassthrough WaitingRoomNewParamsQueueingMethod = "passthrough" - WaitingRoomNewParamsQueueingMethodReject WaitingRoomNewParamsQueueingMethod = "reject" -) - -// HTTP status code returned to a user while in the queue. -type WaitingRoomNewParamsQueueingStatusCode int64 - -const ( - WaitingRoomNewParamsQueueingStatusCode200 WaitingRoomNewParamsQueueingStatusCode = 200 - WaitingRoomNewParamsQueueingStatusCode202 WaitingRoomNewParamsQueueingStatusCode = 202 - WaitingRoomNewParamsQueueingStatusCode429 WaitingRoomNewParamsQueueingStatusCode = 429 -) - -type WaitingRoomNewResponseEnvelope struct { - Result WaitingRoomNewResponse `json:"result,required"` - JSON waitingRoomNewResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [WaitingRoomNewResponseEnvelope] -type waitingRoomNewResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomUpdateParams struct { - // The host name to which the waiting room will be applied (no wildcards). Please - // do not include the scheme (http:// or https://). The host and path combination - // must be unique. - Host param.Field[string] `json:"host,required"` - // A unique name to identify the waiting room. Only alphanumeric characters, - // hyphens and underscores are allowed. - Name param.Field[string] `json:"name,required"` - // Sets the number of new users that will be let into the route every minute. This - // value is used as baseline for the number of users that are let in per minute. So - // it is possible that there is a little more or little less traffic coming to the - // route based on the traffic patterns at that time around the world. - NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute,required"` - // Sets the total number of active user sessions on the route at a point in time. A - // route is a combination of host and path on which a waiting room is available. - // This value is used as a baseline for the total number of active user sessions on - // the route. It is possible to have a situation where there are more or less - // active users sessions on the route based on the traffic patterns at that time - // around the world. - TotalActiveUsers param.Field[int64] `json:"total_active_users,required"` - // Only available for the Waiting Room Advanced subscription. Additional hostname - // and path combinations to which this waiting room will be applied. There is an - // implied wildcard at the end of the path. The hostname and path combination must - // be unique to this and all other waiting rooms. - AdditionalRoutes param.Field[[]WaitingRoomUpdateParamsAdditionalRoute] `json:"additional_routes"` - // Configures cookie attributes for the waiting room cookie. This encrypted cookie - // stores a user's status in the waiting room, such as queue position. - CookieAttributes param.Field[WaitingRoomUpdateParamsCookieAttributes] `json:"cookie_attributes"` - // Appends a '\_' + a custom suffix to the end of Cloudflare Waiting Room's cookie - // name(**cf_waitingroom). If `cookie_suffix` is "abcd", the cookie name will be - // `**cf_waitingroom_abcd`. This field is required if using `additional_routes`. - CookieSuffix param.Field[string] `json:"cookie_suffix"` - // Only available for the Waiting Room Advanced subscription. This is a template - // html file that will be rendered at the edge. If no custom_page_html is provided, - // the default waiting room will be used. The template is based on mustache ( - // https://mustache.github.io/ ). There are several variables that are evaluated by - // the Cloudflare edge: - // - // 1. {{`waitTimeKnown`}} Acts like a boolean value that indicates the behavior to - // take when wait time is not available, for instance when queue_all is - // **true**. - // 2. {{`waitTimeFormatted`}} Estimated wait time for the user. For example, five - // minutes. Alternatively, you can use: - // 3. {{`waitTime`}} Number of minutes of estimated wait for a user. - // 4. {{`waitTimeHours`}} Number of hours of estimated wait for a user - // (`Math.floor(waitTime/60)`). - // 5. {{`waitTimeHourMinutes`}} Number of minutes above the `waitTimeHours` value - // (`waitTime%60`). - // 6. {{`queueIsFull`}} Changes to **true** when no more people can be added to the - // queue. - // - // To view the full list of variables, look at the `cfWaitingRoom` object described - // under the `json_response_enabled` property in other Waiting Room API calls. - CustomPageHTML param.Field[string] `json:"custom_page_html"` - // The language of the default page template. If no default_template_language is - // provided, then `en-US` (English) will be used. - DefaultTemplateLanguage param.Field[WaitingRoomUpdateParamsDefaultTemplateLanguage] `json:"default_template_language"` - // A note that you can use to add more details about the waiting room. - Description param.Field[string] `json:"description"` - // Only available for the Waiting Room Advanced subscription. Disables automatic - // renewal of session cookies. If `true`, an accepted user will have - // session_duration minutes to browse the site. After that, they will have to go - // through the waiting room again. If `false`, a user's session cookie will be - // automatically renewed on every request. - DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` - // Only available for the Waiting Room Advanced subscription. If `true`, requests - // to the waiting room with the header `Accept: application/json` will receive a - // JSON response object with information on the user's status in the waiting room - // as opposed to the configured static HTML page. This JSON response object has one - // property `cfWaitingRoom` which is an object containing the following fields: - // - // 1. `inWaitingRoom`: Boolean indicating if the user is in the waiting room - // (always **true**). - // 2. `waitTimeKnown`: Boolean indicating if the current estimated wait times are - // accurate. If **false**, they are not available. - // 3. `waitTime`: Valid only when `waitTimeKnown` is **true**. Integer indicating - // the current estimated time in minutes the user will wait in the waiting room. - // When `queueingMethod` is **random**, this is set to `waitTime50Percentile`. - // 4. `waitTime25Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 25% of users that gain entry the fastest (25th percentile). - // 5. `waitTime50Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 50% of users that gain entry the fastest (50th percentile). - // In other words, half of the queued users are expected to let into the origin - // website before `waitTime50Percentile` and half are expected to be let in - // after it. - // 6. `waitTime75Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 75% of users that gain entry the fastest (75th percentile). - // 7. `waitTimeFormatted`: String displaying the `waitTime` formatted in English - // for users. If `waitTimeKnown` is **false**, `waitTimeFormatted` will display - // **unavailable**. - // 8. `queueIsFull`: Boolean indicating if the waiting room's queue is currently - // full and not accepting new users at the moment. - // 9. `queueAll`: Boolean indicating if all users will be queued in the waiting - // room and no one will be let into the origin website. - // 10. `lastUpdated`: String displaying the timestamp as an ISO 8601 string of the - // user's last attempt to leave the waiting room and be let into the origin - // website. The user is able to make another attempt after - // `refreshIntervalSeconds` past this time. If the user makes a request too - // soon, it will be ignored and `lastUpdated` will not change. - // 11. `refreshIntervalSeconds`: Integer indicating the number of seconds after - // `lastUpdated` until the user is able to make another attempt to leave the - // waiting room and be let into the origin website. When the `queueingMethod` - // is `reject`, there is no specified refresh time — it will always be - // **zero**. - // 12. `queueingMethod`: The queueing method currently used by the waiting room. It - // is either **fifo**, **random**, **passthrough**, or **reject**. - // 13. `isFIFOQueue`: Boolean indicating if the waiting room uses a FIFO - // (First-In-First-Out) queue. - // 14. `isRandomQueue`: Boolean indicating if the waiting room uses a Random queue - // where users gain access randomly. - // 15. `isPassthroughQueue`: Boolean indicating if the waiting room uses a - // passthrough queue. Keep in mind that when passthrough is enabled, this JSON - // response will only exist when `queueAll` is **true** or `isEventPrequeueing` - // is **true** because in all other cases requests will go directly to the - // origin. - // 16. `isRejectQueue`: Boolean indicating if the waiting room uses a reject queue. - // 17. `isEventActive`: Boolean indicating if an event is currently occurring. - // Events are able to change a waiting room's behavior during a specified - // period of time. For additional information, look at the event properties - // `prequeue_start_time`, `event_start_time`, and `event_end_time` in the - // documentation for creating waiting room events. Events are considered active - // between these start and end times, as well as during the prequeueing period - // if it exists. - // 18. `isEventPrequeueing`: Valid only when `isEventActive` is **true**. Boolean - // indicating if an event is currently prequeueing users before it starts. - // 19. `timeUntilEventStart`: Valid only when `isEventPrequeueing` is **true**. - // Integer indicating the number of minutes until the event starts. - // 20. `timeUntilEventStartFormatted`: String displaying the `timeUntilEventStart` - // formatted in English for users. If `isEventPrequeueing` is **false**, - // `timeUntilEventStartFormatted` will display **unavailable**. - // 21. `timeUntilEventEnd`: Valid only when `isEventActive` is **true**. Integer - // indicating the number of minutes until the event ends. - // 22. `timeUntilEventEndFormatted`: String displaying the `timeUntilEventEnd` - // formatted in English for users. If `isEventActive` is **false**, - // `timeUntilEventEndFormatted` will display **unavailable**. - // 23. `shuffleAtEventStart`: Valid only when `isEventActive` is **true**. Boolean - // indicating if the users in the prequeue are shuffled randomly when the event - // starts. - // - // An example cURL to a waiting room could be: - // - // curl -X GET "https://example.com/waitingroom" \ - // -H "Accept: application/json" - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **fifo** and no event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 0, - // "waitTime50Percentile": 0, - // "waitTime75Percentile": 0, - // "waitTimeFormatted": "10 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "fifo", - // "isFIFOQueue": true, - // "isRandomQueue": false, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": false, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 0, - // "timeUntilEventEndFormatted": "unavailable", - // "shuffleAtEventStart": false - // } - // } - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **random** and an event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 5, - // "waitTime50Percentile": 10, - // "waitTime75Percentile": 15, - // "waitTimeFormatted": "5 minutes to 15 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "random", - // "isFIFOQueue": false, - // "isRandomQueue": true, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": true, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 15, - // "timeUntilEventEndFormatted": "15 minutes", - // "shuffleAtEventStart": true - // } - // }. - JsonResponseEnabled param.Field[bool] `json:"json_response_enabled"` - // Sets the path within the host to enable the waiting room on. The waiting room - // will be enabled for all subpaths as well. If there are two waiting rooms on the - // same subpath, the waiting room for the most specific path will be chosen. - // Wildcards and query parameters are not supported. - Path param.Field[string] `json:"path"` - // If queue_all is `true`, all the traffic that is coming to a route will be sent - // to the waiting room. No new traffic can get to the route once this field is set - // and estimated time will become unavailable. - QueueAll param.Field[bool] `json:"queue_all"` - // Sets the queueing method used by the waiting room. Changing this parameter from - // the **default** queueing method is only available for the Waiting Room Advanced - // subscription. Regardless of the queueing method, if `queue_all` is enabled or an - // event is prequeueing, users in the waiting room will not be accepted to the - // origin. These users will always see a waiting room page that refreshes - // automatically. The valid queueing methods are: - // - // 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in - // the order they arrived. - // 2. `random`: Random queue where customers gain access randomly, regardless of - // arrival time. - // 3. `passthrough`: Users will pass directly through the waiting room and into the - // origin website. As a result, any configured limits will not be respected - // while this is enabled. This method can be used as an alternative to disabling - // a waiting room (with `suspended`) so that analytics are still reported. This - // can be used if you wish to allow all traffic normally, but want to restrict - // traffic during a waiting room event, or vice versa. - // 4. `reject`: Users will be immediately rejected from the waiting room. As a - // result, no users will reach the origin website while this is enabled. This - // can be used if you wish to reject all traffic while performing maintenance, - // block traffic during a specified period of time (an event), or block traffic - // while events are not occurring. Consider a waiting room used for vaccine - // distribution that only allows traffic during sign-up events, and otherwise - // blocks all traffic. For this case, the waiting room uses `reject`, and its - // events override this with `fifo`, `random`, or `passthrough`. When this - // queueing method is enabled and neither `queueAll` is enabled nor an event is - // prequeueing, the waiting room page **will not refresh automatically**. - QueueingMethod param.Field[WaitingRoomUpdateParamsQueueingMethod] `json:"queueing_method"` - // HTTP status code returned to a user while in the queue. - QueueingStatusCode param.Field[WaitingRoomUpdateParamsQueueingStatusCode] `json:"queueing_status_code"` - // Lifetime of a cookie (in minutes) set by Cloudflare for users who get access to - // the route. If a user is not seen by Cloudflare again in that time period, they - // will be treated as a new user that visits the route. - SessionDuration param.Field[int64] `json:"session_duration"` - // Suspends or allows traffic going to the waiting room. If set to `true`, the - // traffic will not go to the waiting room. - Suspended param.Field[bool] `json:"suspended"` -} - -func (r WaitingRoomUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WaitingRoomUpdateParamsAdditionalRoute struct { - // The hostname to which this waiting room will be applied (no wildcards). The - // hostname must be the primary domain, subdomain, or custom hostname (if using SSL - // for SaaS) of this zone. Please do not include the scheme (http:// or https://). - Host param.Field[string] `json:"host"` - // Sets the path within the host to enable the waiting room on. The waiting room - // will be enabled for all subpaths as well. If there are two waiting rooms on the - // same subpath, the waiting room for the most specific path will be chosen. - // Wildcards and query parameters are not supported. - Path param.Field[string] `json:"path"` -} - -func (r WaitingRoomUpdateParamsAdditionalRoute) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures cookie attributes for the waiting room cookie. This encrypted cookie -// stores a user's status in the waiting room, such as queue position. -type WaitingRoomUpdateParamsCookieAttributes struct { - // Configures the SameSite attribute on the waiting room cookie. Value `auto` will - // be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. - // Note that when using value `none`, the secure attribute cannot be set to - // `never`. - Samesite param.Field[WaitingRoomUpdateParamsCookieAttributesSamesite] `json:"samesite"` - // Configures the Secure attribute on the waiting room cookie. Value `always` - // indicates that the Secure attribute will be set in the Set-Cookie header, - // `never` indicates that the Secure attribute will not be set, and `auto` will set - // the Secure attribute depending if **Always Use HTTPS** is enabled. - Secure param.Field[WaitingRoomUpdateParamsCookieAttributesSecure] `json:"secure"` -} - -func (r WaitingRoomUpdateParamsCookieAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures the SameSite attribute on the waiting room cookie. Value `auto` will -// be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. -// Note that when using value `none`, the secure attribute cannot be set to -// `never`. -type WaitingRoomUpdateParamsCookieAttributesSamesite string - -const ( - WaitingRoomUpdateParamsCookieAttributesSamesiteAuto WaitingRoomUpdateParamsCookieAttributesSamesite = "auto" - WaitingRoomUpdateParamsCookieAttributesSamesiteLax WaitingRoomUpdateParamsCookieAttributesSamesite = "lax" - WaitingRoomUpdateParamsCookieAttributesSamesiteNone WaitingRoomUpdateParamsCookieAttributesSamesite = "none" - WaitingRoomUpdateParamsCookieAttributesSamesiteStrict WaitingRoomUpdateParamsCookieAttributesSamesite = "strict" -) - -// Configures the Secure attribute on the waiting room cookie. Value `always` -// indicates that the Secure attribute will be set in the Set-Cookie header, -// `never` indicates that the Secure attribute will not be set, and `auto` will set -// the Secure attribute depending if **Always Use HTTPS** is enabled. -type WaitingRoomUpdateParamsCookieAttributesSecure string - -const ( - WaitingRoomUpdateParamsCookieAttributesSecureAuto WaitingRoomUpdateParamsCookieAttributesSecure = "auto" - WaitingRoomUpdateParamsCookieAttributesSecureAlways WaitingRoomUpdateParamsCookieAttributesSecure = "always" - WaitingRoomUpdateParamsCookieAttributesSecureNever WaitingRoomUpdateParamsCookieAttributesSecure = "never" -) - -// The language of the default page template. If no default_template_language is -// provided, then `en-US` (English) will be used. -type WaitingRoomUpdateParamsDefaultTemplateLanguage string - -const ( - WaitingRoomUpdateParamsDefaultTemplateLanguageEnUs WaitingRoomUpdateParamsDefaultTemplateLanguage = "en-US" - WaitingRoomUpdateParamsDefaultTemplateLanguageEsEs WaitingRoomUpdateParamsDefaultTemplateLanguage = "es-ES" - WaitingRoomUpdateParamsDefaultTemplateLanguageDeDe WaitingRoomUpdateParamsDefaultTemplateLanguage = "de-DE" - WaitingRoomUpdateParamsDefaultTemplateLanguageFrFr WaitingRoomUpdateParamsDefaultTemplateLanguage = "fr-FR" - WaitingRoomUpdateParamsDefaultTemplateLanguageItIt WaitingRoomUpdateParamsDefaultTemplateLanguage = "it-IT" - WaitingRoomUpdateParamsDefaultTemplateLanguageJaJp WaitingRoomUpdateParamsDefaultTemplateLanguage = "ja-JP" - WaitingRoomUpdateParamsDefaultTemplateLanguageKoKr WaitingRoomUpdateParamsDefaultTemplateLanguage = "ko-KR" - WaitingRoomUpdateParamsDefaultTemplateLanguagePtBr WaitingRoomUpdateParamsDefaultTemplateLanguage = "pt-BR" - WaitingRoomUpdateParamsDefaultTemplateLanguageZhCn WaitingRoomUpdateParamsDefaultTemplateLanguage = "zh-CN" - WaitingRoomUpdateParamsDefaultTemplateLanguageZhTw WaitingRoomUpdateParamsDefaultTemplateLanguage = "zh-TW" - WaitingRoomUpdateParamsDefaultTemplateLanguageNlNl WaitingRoomUpdateParamsDefaultTemplateLanguage = "nl-NL" - WaitingRoomUpdateParamsDefaultTemplateLanguagePlPl WaitingRoomUpdateParamsDefaultTemplateLanguage = "pl-PL" - WaitingRoomUpdateParamsDefaultTemplateLanguageIDID WaitingRoomUpdateParamsDefaultTemplateLanguage = "id-ID" - WaitingRoomUpdateParamsDefaultTemplateLanguageTrTr WaitingRoomUpdateParamsDefaultTemplateLanguage = "tr-TR" - WaitingRoomUpdateParamsDefaultTemplateLanguageArEg WaitingRoomUpdateParamsDefaultTemplateLanguage = "ar-EG" - WaitingRoomUpdateParamsDefaultTemplateLanguageRuRu WaitingRoomUpdateParamsDefaultTemplateLanguage = "ru-RU" - WaitingRoomUpdateParamsDefaultTemplateLanguageFaIr WaitingRoomUpdateParamsDefaultTemplateLanguage = "fa-IR" -) - -// Sets the queueing method used by the waiting room. Changing this parameter from -// the **default** queueing method is only available for the Waiting Room Advanced -// subscription. Regardless of the queueing method, if `queue_all` is enabled or an -// event is prequeueing, users in the waiting room will not be accepted to the -// origin. These users will always see a waiting room page that refreshes -// automatically. The valid queueing methods are: -// -// 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in -// the order they arrived. -// 2. `random`: Random queue where customers gain access randomly, regardless of -// arrival time. -// 3. `passthrough`: Users will pass directly through the waiting room and into the -// origin website. As a result, any configured limits will not be respected -// while this is enabled. This method can be used as an alternative to disabling -// a waiting room (with `suspended`) so that analytics are still reported. This -// can be used if you wish to allow all traffic normally, but want to restrict -// traffic during a waiting room event, or vice versa. -// 4. `reject`: Users will be immediately rejected from the waiting room. As a -// result, no users will reach the origin website while this is enabled. This -// can be used if you wish to reject all traffic while performing maintenance, -// block traffic during a specified period of time (an event), or block traffic -// while events are not occurring. Consider a waiting room used for vaccine -// distribution that only allows traffic during sign-up events, and otherwise -// blocks all traffic. For this case, the waiting room uses `reject`, and its -// events override this with `fifo`, `random`, or `passthrough`. When this -// queueing method is enabled and neither `queueAll` is enabled nor an event is -// prequeueing, the waiting room page **will not refresh automatically**. -type WaitingRoomUpdateParamsQueueingMethod string - -const ( - WaitingRoomUpdateParamsQueueingMethodFifo WaitingRoomUpdateParamsQueueingMethod = "fifo" - WaitingRoomUpdateParamsQueueingMethodRandom WaitingRoomUpdateParamsQueueingMethod = "random" - WaitingRoomUpdateParamsQueueingMethodPassthrough WaitingRoomUpdateParamsQueueingMethod = "passthrough" - WaitingRoomUpdateParamsQueueingMethodReject WaitingRoomUpdateParamsQueueingMethod = "reject" -) - -// HTTP status code returned to a user while in the queue. -type WaitingRoomUpdateParamsQueueingStatusCode int64 - -const ( - WaitingRoomUpdateParamsQueueingStatusCode200 WaitingRoomUpdateParamsQueueingStatusCode = 200 - WaitingRoomUpdateParamsQueueingStatusCode202 WaitingRoomUpdateParamsQueueingStatusCode = 202 - WaitingRoomUpdateParamsQueueingStatusCode429 WaitingRoomUpdateParamsQueueingStatusCode = 429 -) - -type WaitingRoomUpdateResponseEnvelope struct { - Result WaitingRoomUpdateResponse `json:"result,required"` - JSON waitingRoomUpdateResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [WaitingRoomUpdateResponseEnvelope] -type waitingRoomUpdateResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomListResponseEnvelope struct { - Errors []WaitingRoomListResponseEnvelopeErrors `json:"errors,required"` - Messages []WaitingRoomListResponseEnvelopeMessages `json:"messages,required"` - Result []WaitingRoomListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success WaitingRoomListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo WaitingRoomListResponseEnvelopeResultInfo `json:"result_info"` - JSON waitingRoomListResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomListResponseEnvelopeJSON contains the JSON metadata for the struct -// [WaitingRoomListResponseEnvelope] -type waitingRoomListResponseEnvelopeJSON 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 *WaitingRoomListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON waitingRoomListResponseEnvelopeErrorsJSON `json:"-"` -} - -// waitingRoomListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WaitingRoomListResponseEnvelopeErrors] -type waitingRoomListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON waitingRoomListResponseEnvelopeMessagesJSON `json:"-"` -} - -// waitingRoomListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WaitingRoomListResponseEnvelopeMessages] -type waitingRoomListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WaitingRoomListResponseEnvelopeSuccess bool - -const ( - WaitingRoomListResponseEnvelopeSuccessTrue WaitingRoomListResponseEnvelopeSuccess = true -) - -type WaitingRoomListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON waitingRoomListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// waitingRoomListResponseEnvelopeResultInfoJSON contains the JSON metadata for the -// struct [WaitingRoomListResponseEnvelopeResultInfo] -type waitingRoomListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomDeleteResponseEnvelope struct { - Result WaitingRoomDeleteResponse `json:"result,required"` - JSON waitingRoomDeleteResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [WaitingRoomDeleteResponseEnvelope] -type waitingRoomDeleteResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomEditParams struct { - // The host name to which the waiting room will be applied (no wildcards). Please - // do not include the scheme (http:// or https://). The host and path combination - // must be unique. - Host param.Field[string] `json:"host,required"` - // A unique name to identify the waiting room. Only alphanumeric characters, - // hyphens and underscores are allowed. - Name param.Field[string] `json:"name,required"` - // Sets the number of new users that will be let into the route every minute. This - // value is used as baseline for the number of users that are let in per minute. So - // it is possible that there is a little more or little less traffic coming to the - // route based on the traffic patterns at that time around the world. - NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute,required"` - // Sets the total number of active user sessions on the route at a point in time. A - // route is a combination of host and path on which a waiting room is available. - // This value is used as a baseline for the total number of active user sessions on - // the route. It is possible to have a situation where there are more or less - // active users sessions on the route based on the traffic patterns at that time - // around the world. - TotalActiveUsers param.Field[int64] `json:"total_active_users,required"` - // Only available for the Waiting Room Advanced subscription. Additional hostname - // and path combinations to which this waiting room will be applied. There is an - // implied wildcard at the end of the path. The hostname and path combination must - // be unique to this and all other waiting rooms. - AdditionalRoutes param.Field[[]WaitingRoomEditParamsAdditionalRoute] `json:"additional_routes"` - // Configures cookie attributes for the waiting room cookie. This encrypted cookie - // stores a user's status in the waiting room, such as queue position. - CookieAttributes param.Field[WaitingRoomEditParamsCookieAttributes] `json:"cookie_attributes"` - // Appends a '\_' + a custom suffix to the end of Cloudflare Waiting Room's cookie - // name(**cf_waitingroom). If `cookie_suffix` is "abcd", the cookie name will be - // `**cf_waitingroom_abcd`. This field is required if using `additional_routes`. - CookieSuffix param.Field[string] `json:"cookie_suffix"` - // Only available for the Waiting Room Advanced subscription. This is a template - // html file that will be rendered at the edge. If no custom_page_html is provided, - // the default waiting room will be used. The template is based on mustache ( - // https://mustache.github.io/ ). There are several variables that are evaluated by - // the Cloudflare edge: - // - // 1. {{`waitTimeKnown`}} Acts like a boolean value that indicates the behavior to - // take when wait time is not available, for instance when queue_all is - // **true**. - // 2. {{`waitTimeFormatted`}} Estimated wait time for the user. For example, five - // minutes. Alternatively, you can use: - // 3. {{`waitTime`}} Number of minutes of estimated wait for a user. - // 4. {{`waitTimeHours`}} Number of hours of estimated wait for a user - // (`Math.floor(waitTime/60)`). - // 5. {{`waitTimeHourMinutes`}} Number of minutes above the `waitTimeHours` value - // (`waitTime%60`). - // 6. {{`queueIsFull`}} Changes to **true** when no more people can be added to the - // queue. - // - // To view the full list of variables, look at the `cfWaitingRoom` object described - // under the `json_response_enabled` property in other Waiting Room API calls. - CustomPageHTML param.Field[string] `json:"custom_page_html"` - // The language of the default page template. If no default_template_language is - // provided, then `en-US` (English) will be used. - DefaultTemplateLanguage param.Field[WaitingRoomEditParamsDefaultTemplateLanguage] `json:"default_template_language"` - // A note that you can use to add more details about the waiting room. - Description param.Field[string] `json:"description"` - // Only available for the Waiting Room Advanced subscription. Disables automatic - // renewal of session cookies. If `true`, an accepted user will have - // session_duration minutes to browse the site. After that, they will have to go - // through the waiting room again. If `false`, a user's session cookie will be - // automatically renewed on every request. - DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` - // Only available for the Waiting Room Advanced subscription. If `true`, requests - // to the waiting room with the header `Accept: application/json` will receive a - // JSON response object with information on the user's status in the waiting room - // as opposed to the configured static HTML page. This JSON response object has one - // property `cfWaitingRoom` which is an object containing the following fields: - // - // 1. `inWaitingRoom`: Boolean indicating if the user is in the waiting room - // (always **true**). - // 2. `waitTimeKnown`: Boolean indicating if the current estimated wait times are - // accurate. If **false**, they are not available. - // 3. `waitTime`: Valid only when `waitTimeKnown` is **true**. Integer indicating - // the current estimated time in minutes the user will wait in the waiting room. - // When `queueingMethod` is **random**, this is set to `waitTime50Percentile`. - // 4. `waitTime25Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 25% of users that gain entry the fastest (25th percentile). - // 5. `waitTime50Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 50% of users that gain entry the fastest (50th percentile). - // In other words, half of the queued users are expected to let into the origin - // website before `waitTime50Percentile` and half are expected to be let in - // after it. - // 6. `waitTime75Percentile`: Valid only when `queueingMethod` is **random** and - // `waitTimeKnown` is **true**. Integer indicating the current estimated maximum - // wait time for the 75% of users that gain entry the fastest (75th percentile). - // 7. `waitTimeFormatted`: String displaying the `waitTime` formatted in English - // for users. If `waitTimeKnown` is **false**, `waitTimeFormatted` will display - // **unavailable**. - // 8. `queueIsFull`: Boolean indicating if the waiting room's queue is currently - // full and not accepting new users at the moment. - // 9. `queueAll`: Boolean indicating if all users will be queued in the waiting - // room and no one will be let into the origin website. - // 10. `lastUpdated`: String displaying the timestamp as an ISO 8601 string of the - // user's last attempt to leave the waiting room and be let into the origin - // website. The user is able to make another attempt after - // `refreshIntervalSeconds` past this time. If the user makes a request too - // soon, it will be ignored and `lastUpdated` will not change. - // 11. `refreshIntervalSeconds`: Integer indicating the number of seconds after - // `lastUpdated` until the user is able to make another attempt to leave the - // waiting room and be let into the origin website. When the `queueingMethod` - // is `reject`, there is no specified refresh time — it will always be - // **zero**. - // 12. `queueingMethod`: The queueing method currently used by the waiting room. It - // is either **fifo**, **random**, **passthrough**, or **reject**. - // 13. `isFIFOQueue`: Boolean indicating if the waiting room uses a FIFO - // (First-In-First-Out) queue. - // 14. `isRandomQueue`: Boolean indicating if the waiting room uses a Random queue - // where users gain access randomly. - // 15. `isPassthroughQueue`: Boolean indicating if the waiting room uses a - // passthrough queue. Keep in mind that when passthrough is enabled, this JSON - // response will only exist when `queueAll` is **true** or `isEventPrequeueing` - // is **true** because in all other cases requests will go directly to the - // origin. - // 16. `isRejectQueue`: Boolean indicating if the waiting room uses a reject queue. - // 17. `isEventActive`: Boolean indicating if an event is currently occurring. - // Events are able to change a waiting room's behavior during a specified - // period of time. For additional information, look at the event properties - // `prequeue_start_time`, `event_start_time`, and `event_end_time` in the - // documentation for creating waiting room events. Events are considered active - // between these start and end times, as well as during the prequeueing period - // if it exists. - // 18. `isEventPrequeueing`: Valid only when `isEventActive` is **true**. Boolean - // indicating if an event is currently prequeueing users before it starts. - // 19. `timeUntilEventStart`: Valid only when `isEventPrequeueing` is **true**. - // Integer indicating the number of minutes until the event starts. - // 20. `timeUntilEventStartFormatted`: String displaying the `timeUntilEventStart` - // formatted in English for users. If `isEventPrequeueing` is **false**, - // `timeUntilEventStartFormatted` will display **unavailable**. - // 21. `timeUntilEventEnd`: Valid only when `isEventActive` is **true**. Integer - // indicating the number of minutes until the event ends. - // 22. `timeUntilEventEndFormatted`: String displaying the `timeUntilEventEnd` - // formatted in English for users. If `isEventActive` is **false**, - // `timeUntilEventEndFormatted` will display **unavailable**. - // 23. `shuffleAtEventStart`: Valid only when `isEventActive` is **true**. Boolean - // indicating if the users in the prequeue are shuffled randomly when the event - // starts. - // - // An example cURL to a waiting room could be: - // - // curl -X GET "https://example.com/waitingroom" \ - // -H "Accept: application/json" - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **fifo** and no event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 0, - // "waitTime50Percentile": 0, - // "waitTime75Percentile": 0, - // "waitTimeFormatted": "10 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "fifo", - // "isFIFOQueue": true, - // "isRandomQueue": false, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": false, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 0, - // "timeUntilEventEndFormatted": "unavailable", - // "shuffleAtEventStart": false - // } - // } - // - // If `json_response_enabled` is **true** and the request hits the waiting room, an - // example JSON response when `queueingMethod` is **random** and an event is active - // could be: - // - // { - // "cfWaitingRoom": { - // "inWaitingRoom": true, - // "waitTimeKnown": true, - // "waitTime": 10, - // "waitTime25Percentile": 5, - // "waitTime50Percentile": 10, - // "waitTime75Percentile": 15, - // "waitTimeFormatted": "5 minutes to 15 minutes", - // "queueIsFull": false, - // "queueAll": false, - // "lastUpdated": "2020-08-03T23:46:00.000Z", - // "refreshIntervalSeconds": 20, - // "queueingMethod": "random", - // "isFIFOQueue": false, - // "isRandomQueue": true, - // "isPassthroughQueue": false, - // "isRejectQueue": false, - // "isEventActive": true, - // "isEventPrequeueing": false, - // "timeUntilEventStart": 0, - // "timeUntilEventStartFormatted": "unavailable", - // "timeUntilEventEnd": 15, - // "timeUntilEventEndFormatted": "15 minutes", - // "shuffleAtEventStart": true - // } - // }. - JsonResponseEnabled param.Field[bool] `json:"json_response_enabled"` - // Sets the path within the host to enable the waiting room on. The waiting room - // will be enabled for all subpaths as well. If there are two waiting rooms on the - // same subpath, the waiting room for the most specific path will be chosen. - // Wildcards and query parameters are not supported. - Path param.Field[string] `json:"path"` - // If queue_all is `true`, all the traffic that is coming to a route will be sent - // to the waiting room. No new traffic can get to the route once this field is set - // and estimated time will become unavailable. - QueueAll param.Field[bool] `json:"queue_all"` - // Sets the queueing method used by the waiting room. Changing this parameter from - // the **default** queueing method is only available for the Waiting Room Advanced - // subscription. Regardless of the queueing method, if `queue_all` is enabled or an - // event is prequeueing, users in the waiting room will not be accepted to the - // origin. These users will always see a waiting room page that refreshes - // automatically. The valid queueing methods are: - // - // 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in - // the order they arrived. - // 2. `random`: Random queue where customers gain access randomly, regardless of - // arrival time. - // 3. `passthrough`: Users will pass directly through the waiting room and into the - // origin website. As a result, any configured limits will not be respected - // while this is enabled. This method can be used as an alternative to disabling - // a waiting room (with `suspended`) so that analytics are still reported. This - // can be used if you wish to allow all traffic normally, but want to restrict - // traffic during a waiting room event, or vice versa. - // 4. `reject`: Users will be immediately rejected from the waiting room. As a - // result, no users will reach the origin website while this is enabled. This - // can be used if you wish to reject all traffic while performing maintenance, - // block traffic during a specified period of time (an event), or block traffic - // while events are not occurring. Consider a waiting room used for vaccine - // distribution that only allows traffic during sign-up events, and otherwise - // blocks all traffic. For this case, the waiting room uses `reject`, and its - // events override this with `fifo`, `random`, or `passthrough`. When this - // queueing method is enabled and neither `queueAll` is enabled nor an event is - // prequeueing, the waiting room page **will not refresh automatically**. - QueueingMethod param.Field[WaitingRoomEditParamsQueueingMethod] `json:"queueing_method"` - // HTTP status code returned to a user while in the queue. - QueueingStatusCode param.Field[WaitingRoomEditParamsQueueingStatusCode] `json:"queueing_status_code"` - // Lifetime of a cookie (in minutes) set by Cloudflare for users who get access to - // the route. If a user is not seen by Cloudflare again in that time period, they - // will be treated as a new user that visits the route. - SessionDuration param.Field[int64] `json:"session_duration"` - // Suspends or allows traffic going to the waiting room. If set to `true`, the - // traffic will not go to the waiting room. - Suspended param.Field[bool] `json:"suspended"` -} - -func (r WaitingRoomEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WaitingRoomEditParamsAdditionalRoute struct { - // The hostname to which this waiting room will be applied (no wildcards). The - // hostname must be the primary domain, subdomain, or custom hostname (if using SSL - // for SaaS) of this zone. Please do not include the scheme (http:// or https://). - Host param.Field[string] `json:"host"` - // Sets the path within the host to enable the waiting room on. The waiting room - // will be enabled for all subpaths as well. If there are two waiting rooms on the - // same subpath, the waiting room for the most specific path will be chosen. - // Wildcards and query parameters are not supported. - Path param.Field[string] `json:"path"` -} - -func (r WaitingRoomEditParamsAdditionalRoute) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures cookie attributes for the waiting room cookie. This encrypted cookie -// stores a user's status in the waiting room, such as queue position. -type WaitingRoomEditParamsCookieAttributes struct { - // Configures the SameSite attribute on the waiting room cookie. Value `auto` will - // be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. - // Note that when using value `none`, the secure attribute cannot be set to - // `never`. - Samesite param.Field[WaitingRoomEditParamsCookieAttributesSamesite] `json:"samesite"` - // Configures the Secure attribute on the waiting room cookie. Value `always` - // indicates that the Secure attribute will be set in the Set-Cookie header, - // `never` indicates that the Secure attribute will not be set, and `auto` will set - // the Secure attribute depending if **Always Use HTTPS** is enabled. - Secure param.Field[WaitingRoomEditParamsCookieAttributesSecure] `json:"secure"` -} - -func (r WaitingRoomEditParamsCookieAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures the SameSite attribute on the waiting room cookie. Value `auto` will -// be translated to `lax` or `none` depending if **Always Use HTTPS** is enabled. -// Note that when using value `none`, the secure attribute cannot be set to -// `never`. -type WaitingRoomEditParamsCookieAttributesSamesite string - -const ( - WaitingRoomEditParamsCookieAttributesSamesiteAuto WaitingRoomEditParamsCookieAttributesSamesite = "auto" - WaitingRoomEditParamsCookieAttributesSamesiteLax WaitingRoomEditParamsCookieAttributesSamesite = "lax" - WaitingRoomEditParamsCookieAttributesSamesiteNone WaitingRoomEditParamsCookieAttributesSamesite = "none" - WaitingRoomEditParamsCookieAttributesSamesiteStrict WaitingRoomEditParamsCookieAttributesSamesite = "strict" -) - -// Configures the Secure attribute on the waiting room cookie. Value `always` -// indicates that the Secure attribute will be set in the Set-Cookie header, -// `never` indicates that the Secure attribute will not be set, and `auto` will set -// the Secure attribute depending if **Always Use HTTPS** is enabled. -type WaitingRoomEditParamsCookieAttributesSecure string - -const ( - WaitingRoomEditParamsCookieAttributesSecureAuto WaitingRoomEditParamsCookieAttributesSecure = "auto" - WaitingRoomEditParamsCookieAttributesSecureAlways WaitingRoomEditParamsCookieAttributesSecure = "always" - WaitingRoomEditParamsCookieAttributesSecureNever WaitingRoomEditParamsCookieAttributesSecure = "never" -) - -// The language of the default page template. If no default_template_language is -// provided, then `en-US` (English) will be used. -type WaitingRoomEditParamsDefaultTemplateLanguage string - -const ( - WaitingRoomEditParamsDefaultTemplateLanguageEnUs WaitingRoomEditParamsDefaultTemplateLanguage = "en-US" - WaitingRoomEditParamsDefaultTemplateLanguageEsEs WaitingRoomEditParamsDefaultTemplateLanguage = "es-ES" - WaitingRoomEditParamsDefaultTemplateLanguageDeDe WaitingRoomEditParamsDefaultTemplateLanguage = "de-DE" - WaitingRoomEditParamsDefaultTemplateLanguageFrFr WaitingRoomEditParamsDefaultTemplateLanguage = "fr-FR" - WaitingRoomEditParamsDefaultTemplateLanguageItIt WaitingRoomEditParamsDefaultTemplateLanguage = "it-IT" - WaitingRoomEditParamsDefaultTemplateLanguageJaJp WaitingRoomEditParamsDefaultTemplateLanguage = "ja-JP" - WaitingRoomEditParamsDefaultTemplateLanguageKoKr WaitingRoomEditParamsDefaultTemplateLanguage = "ko-KR" - WaitingRoomEditParamsDefaultTemplateLanguagePtBr WaitingRoomEditParamsDefaultTemplateLanguage = "pt-BR" - WaitingRoomEditParamsDefaultTemplateLanguageZhCn WaitingRoomEditParamsDefaultTemplateLanguage = "zh-CN" - WaitingRoomEditParamsDefaultTemplateLanguageZhTw WaitingRoomEditParamsDefaultTemplateLanguage = "zh-TW" - WaitingRoomEditParamsDefaultTemplateLanguageNlNl WaitingRoomEditParamsDefaultTemplateLanguage = "nl-NL" - WaitingRoomEditParamsDefaultTemplateLanguagePlPl WaitingRoomEditParamsDefaultTemplateLanguage = "pl-PL" - WaitingRoomEditParamsDefaultTemplateLanguageIDID WaitingRoomEditParamsDefaultTemplateLanguage = "id-ID" - WaitingRoomEditParamsDefaultTemplateLanguageTrTr WaitingRoomEditParamsDefaultTemplateLanguage = "tr-TR" - WaitingRoomEditParamsDefaultTemplateLanguageArEg WaitingRoomEditParamsDefaultTemplateLanguage = "ar-EG" - WaitingRoomEditParamsDefaultTemplateLanguageRuRu WaitingRoomEditParamsDefaultTemplateLanguage = "ru-RU" - WaitingRoomEditParamsDefaultTemplateLanguageFaIr WaitingRoomEditParamsDefaultTemplateLanguage = "fa-IR" -) - -// Sets the queueing method used by the waiting room. Changing this parameter from -// the **default** queueing method is only available for the Waiting Room Advanced -// subscription. Regardless of the queueing method, if `queue_all` is enabled or an -// event is prequeueing, users in the waiting room will not be accepted to the -// origin. These users will always see a waiting room page that refreshes -// automatically. The valid queueing methods are: -// -// 1. `fifo` **(default)**: First-In-First-Out queue where customers gain access in -// the order they arrived. -// 2. `random`: Random queue where customers gain access randomly, regardless of -// arrival time. -// 3. `passthrough`: Users will pass directly through the waiting room and into the -// origin website. As a result, any configured limits will not be respected -// while this is enabled. This method can be used as an alternative to disabling -// a waiting room (with `suspended`) so that analytics are still reported. This -// can be used if you wish to allow all traffic normally, but want to restrict -// traffic during a waiting room event, or vice versa. -// 4. `reject`: Users will be immediately rejected from the waiting room. As a -// result, no users will reach the origin website while this is enabled. This -// can be used if you wish to reject all traffic while performing maintenance, -// block traffic during a specified period of time (an event), or block traffic -// while events are not occurring. Consider a waiting room used for vaccine -// distribution that only allows traffic during sign-up events, and otherwise -// blocks all traffic. For this case, the waiting room uses `reject`, and its -// events override this with `fifo`, `random`, or `passthrough`. When this -// queueing method is enabled and neither `queueAll` is enabled nor an event is -// prequeueing, the waiting room page **will not refresh automatically**. -type WaitingRoomEditParamsQueueingMethod string - -const ( - WaitingRoomEditParamsQueueingMethodFifo WaitingRoomEditParamsQueueingMethod = "fifo" - WaitingRoomEditParamsQueueingMethodRandom WaitingRoomEditParamsQueueingMethod = "random" - WaitingRoomEditParamsQueueingMethodPassthrough WaitingRoomEditParamsQueueingMethod = "passthrough" - WaitingRoomEditParamsQueueingMethodReject WaitingRoomEditParamsQueueingMethod = "reject" -) - -// HTTP status code returned to a user while in the queue. -type WaitingRoomEditParamsQueueingStatusCode int64 - -const ( - WaitingRoomEditParamsQueueingStatusCode200 WaitingRoomEditParamsQueueingStatusCode = 200 - WaitingRoomEditParamsQueueingStatusCode202 WaitingRoomEditParamsQueueingStatusCode = 202 - WaitingRoomEditParamsQueueingStatusCode429 WaitingRoomEditParamsQueueingStatusCode = 429 -) - -type WaitingRoomEditResponseEnvelope struct { - Result WaitingRoomEditResponse `json:"result,required"` - JSON waitingRoomEditResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [WaitingRoomEditResponseEnvelope] -type waitingRoomEditResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomGetResponseEnvelope struct { - Result WaitingRoomGetResponse `json:"result,required"` - JSON waitingRoomGetResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [WaitingRoomGetResponseEnvelope] -type waitingRoomGetResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomPreviewParams struct { - // Only available for the Waiting Room Advanced subscription. This is a template - // html file that will be rendered at the edge. If no custom_page_html is provided, - // the default waiting room will be used. The template is based on mustache ( - // https://mustache.github.io/ ). There are several variables that are evaluated by - // the Cloudflare edge: - // - // 1. {{`waitTimeKnown`}} Acts like a boolean value that indicates the behavior to - // take when wait time is not available, for instance when queue_all is - // **true**. - // 2. {{`waitTimeFormatted`}} Estimated wait time for the user. For example, five - // minutes. Alternatively, you can use: - // 3. {{`waitTime`}} Number of minutes of estimated wait for a user. - // 4. {{`waitTimeHours`}} Number of hours of estimated wait for a user - // (`Math.floor(waitTime/60)`). - // 5. {{`waitTimeHourMinutes`}} Number of minutes above the `waitTimeHours` value - // (`waitTime%60`). - // 6. {{`queueIsFull`}} Changes to **true** when no more people can be added to the - // queue. - // - // To view the full list of variables, look at the `cfWaitingRoom` object described - // under the `json_response_enabled` property in other Waiting Room API calls. - CustomHTML param.Field[string] `json:"custom_html,required"` -} - -func (r WaitingRoomPreviewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WaitingRoomPreviewResponseEnvelope struct { - Result WaitingRoomPreviewResponse `json:"result,required"` - JSON waitingRoomPreviewResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomPreviewResponseEnvelopeJSON contains the JSON metadata for the struct -// [WaitingRoomPreviewResponseEnvelope] -type waitingRoomPreviewResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomPreviewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomPreviewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/waitingroomevent.go b/waitingroomevent.go deleted file mode 100644 index 401050258d9..00000000000 --- a/waitingroomevent.go +++ /dev/null @@ -1,929 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WaitingRoomEventService 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 [NewWaitingRoomEventService] method -// instead. -type WaitingRoomEventService struct { - Options []option.RequestOption - Details *WaitingRoomEventDetailService -} - -// NewWaitingRoomEventService 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 NewWaitingRoomEventService(opts ...option.RequestOption) (r *WaitingRoomEventService) { - r = &WaitingRoomEventService{} - r.Options = opts - r.Details = NewWaitingRoomEventDetailService(opts...) - return -} - -// Only available for the Waiting Room Advanced subscription. Creates an event for -// a waiting room. An event takes place during a specified period of time, -// temporarily changing the behavior of a waiting room. While the event is active, -// some of the properties in the event's configuration may either override or -// inherit from the waiting room's configuration. Note that events cannot overlap -// with each other, so only one event can be active at a time. -func (r *WaitingRoomEventService) New(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body WaitingRoomEventNewParams, opts ...option.RequestOption) (res *WaitingRoomEventNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomEventNewResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%v/events", zoneIdentifier, waitingRoomID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a configured event for a waiting room. -func (r *WaitingRoomEventService) Update(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}, body WaitingRoomEventUpdateParams, opts ...option.RequestOption) (res *WaitingRoomEventUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomEventUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%v/events/%v", zoneIdentifier, waitingRoomID, eventID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists events for a waiting room. -func (r *WaitingRoomEventService) List(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, opts ...option.RequestOption) (res *[]WaitingRoomEventListResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomEventListResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%v/events", zoneIdentifier, waitingRoomID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes an event for a waiting room. -func (r *WaitingRoomEventService) Delete(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}, opts ...option.RequestOption) (res *WaitingRoomEventDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomEventDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%v/events/%v", zoneIdentifier, waitingRoomID, eventID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Patches a configured event for a waiting room. -func (r *WaitingRoomEventService) Edit(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}, body WaitingRoomEventEditParams, opts ...option.RequestOption) (res *WaitingRoomEventEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomEventEditResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%v/events/%v", zoneIdentifier, waitingRoomID, eventID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a single configured event for a waiting room. -func (r *WaitingRoomEventService) Get(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}, opts ...option.RequestOption) (res *WaitingRoomEventGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomEventGetResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%v/events/%v", zoneIdentifier, waitingRoomID, eventID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WaitingRoomEventNewResponse struct { - ID interface{} `json:"id"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // If set, the event will override the waiting room's `custom_page_html` property - // while it is active. If null, the event will inherit it. - CustomPageHTML string `json:"custom_page_html,nullable"` - // A note that you can use to add more details about the event. - Description string `json:"description"` - // If set, the event will override the waiting room's `disable_session_renewal` - // property while it is active. If null, the event will inherit it. - DisableSessionRenewal bool `json:"disable_session_renewal,nullable"` - // An ISO 8601 timestamp that marks the end of the event. - EventEndTime string `json:"event_end_time"` - // An ISO 8601 timestamp that marks the start of the event. At this time, queued - // users will be processed with the event's configuration. The start time must be - // at least one minute before `event_end_time`. - EventStartTime string `json:"event_start_time"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A unique name to identify the event. Only alphanumeric characters, hyphens and - // underscores are allowed. - Name string `json:"name"` - // If set, the event will override the waiting room's `new_users_per_minute` - // property while it is active. If null, the event will inherit it. This can only - // be set if the event's `total_active_users` property is also set. - NewUsersPerMinute int64 `json:"new_users_per_minute,nullable"` - // An ISO 8601 timestamp that marks when to begin queueing all users before the - // event starts. The prequeue must start at least five minutes before - // `event_start_time`. - PrequeueStartTime string `json:"prequeue_start_time,nullable"` - // If set, the event will override the waiting room's `queueing_method` property - // while it is active. If null, the event will inherit it. - QueueingMethod string `json:"queueing_method,nullable"` - // If set, the event will override the waiting room's `session_duration` property - // while it is active. If null, the event will inherit it. - SessionDuration int64 `json:"session_duration,nullable"` - // If enabled, users in the prequeue will be shuffled randomly at the - // `event_start_time`. Requires that `prequeue_start_time` is not null. This is - // useful for situations when many users will join the event prequeue at the same - // time and you want to shuffle them to ensure fairness. Naturally, it makes the - // most sense to enable this feature when the `queueing_method` during the event - // respects ordering such as **fifo**, or else the shuffling may be unnecessary. - ShuffleAtEventStart bool `json:"shuffle_at_event_start"` - // Suspends or allows an event. If set to `true`, the event is ignored and traffic - // will be handled based on the waiting room configuration. - Suspended bool `json:"suspended"` - // If set, the event will override the waiting room's `total_active_users` property - // while it is active. If null, the event will inherit it. This can only be set if - // the event's `new_users_per_minute` property is also set. - TotalActiveUsers int64 `json:"total_active_users,nullable"` - JSON waitingRoomEventNewResponseJSON `json:"-"` -} - -// waitingRoomEventNewResponseJSON contains the JSON metadata for the struct -// [WaitingRoomEventNewResponse] -type waitingRoomEventNewResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - CustomPageHTML apijson.Field - Description apijson.Field - DisableSessionRenewal apijson.Field - EventEndTime apijson.Field - EventStartTime apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - NewUsersPerMinute apijson.Field - PrequeueStartTime apijson.Field - QueueingMethod apijson.Field - SessionDuration apijson.Field - ShuffleAtEventStart apijson.Field - Suspended apijson.Field - TotalActiveUsers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEventNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEventNewResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomEventUpdateResponse struct { - ID interface{} `json:"id"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // If set, the event will override the waiting room's `custom_page_html` property - // while it is active. If null, the event will inherit it. - CustomPageHTML string `json:"custom_page_html,nullable"` - // A note that you can use to add more details about the event. - Description string `json:"description"` - // If set, the event will override the waiting room's `disable_session_renewal` - // property while it is active. If null, the event will inherit it. - DisableSessionRenewal bool `json:"disable_session_renewal,nullable"` - // An ISO 8601 timestamp that marks the end of the event. - EventEndTime string `json:"event_end_time"` - // An ISO 8601 timestamp that marks the start of the event. At this time, queued - // users will be processed with the event's configuration. The start time must be - // at least one minute before `event_end_time`. - EventStartTime string `json:"event_start_time"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A unique name to identify the event. Only alphanumeric characters, hyphens and - // underscores are allowed. - Name string `json:"name"` - // If set, the event will override the waiting room's `new_users_per_minute` - // property while it is active. If null, the event will inherit it. This can only - // be set if the event's `total_active_users` property is also set. - NewUsersPerMinute int64 `json:"new_users_per_minute,nullable"` - // An ISO 8601 timestamp that marks when to begin queueing all users before the - // event starts. The prequeue must start at least five minutes before - // `event_start_time`. - PrequeueStartTime string `json:"prequeue_start_time,nullable"` - // If set, the event will override the waiting room's `queueing_method` property - // while it is active. If null, the event will inherit it. - QueueingMethod string `json:"queueing_method,nullable"` - // If set, the event will override the waiting room's `session_duration` property - // while it is active. If null, the event will inherit it. - SessionDuration int64 `json:"session_duration,nullable"` - // If enabled, users in the prequeue will be shuffled randomly at the - // `event_start_time`. Requires that `prequeue_start_time` is not null. This is - // useful for situations when many users will join the event prequeue at the same - // time and you want to shuffle them to ensure fairness. Naturally, it makes the - // most sense to enable this feature when the `queueing_method` during the event - // respects ordering such as **fifo**, or else the shuffling may be unnecessary. - ShuffleAtEventStart bool `json:"shuffle_at_event_start"` - // Suspends or allows an event. If set to `true`, the event is ignored and traffic - // will be handled based on the waiting room configuration. - Suspended bool `json:"suspended"` - // If set, the event will override the waiting room's `total_active_users` property - // while it is active. If null, the event will inherit it. This can only be set if - // the event's `new_users_per_minute` property is also set. - TotalActiveUsers int64 `json:"total_active_users,nullable"` - JSON waitingRoomEventUpdateResponseJSON `json:"-"` -} - -// waitingRoomEventUpdateResponseJSON contains the JSON metadata for the struct -// [WaitingRoomEventUpdateResponse] -type waitingRoomEventUpdateResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - CustomPageHTML apijson.Field - Description apijson.Field - DisableSessionRenewal apijson.Field - EventEndTime apijson.Field - EventStartTime apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - NewUsersPerMinute apijson.Field - PrequeueStartTime apijson.Field - QueueingMethod apijson.Field - SessionDuration apijson.Field - ShuffleAtEventStart apijson.Field - Suspended apijson.Field - TotalActiveUsers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEventUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEventUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomEventListResponse struct { - ID interface{} `json:"id"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // If set, the event will override the waiting room's `custom_page_html` property - // while it is active. If null, the event will inherit it. - CustomPageHTML string `json:"custom_page_html,nullable"` - // A note that you can use to add more details about the event. - Description string `json:"description"` - // If set, the event will override the waiting room's `disable_session_renewal` - // property while it is active. If null, the event will inherit it. - DisableSessionRenewal bool `json:"disable_session_renewal,nullable"` - // An ISO 8601 timestamp that marks the end of the event. - EventEndTime string `json:"event_end_time"` - // An ISO 8601 timestamp that marks the start of the event. At this time, queued - // users will be processed with the event's configuration. The start time must be - // at least one minute before `event_end_time`. - EventStartTime string `json:"event_start_time"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A unique name to identify the event. Only alphanumeric characters, hyphens and - // underscores are allowed. - Name string `json:"name"` - // If set, the event will override the waiting room's `new_users_per_minute` - // property while it is active. If null, the event will inherit it. This can only - // be set if the event's `total_active_users` property is also set. - NewUsersPerMinute int64 `json:"new_users_per_minute,nullable"` - // An ISO 8601 timestamp that marks when to begin queueing all users before the - // event starts. The prequeue must start at least five minutes before - // `event_start_time`. - PrequeueStartTime string `json:"prequeue_start_time,nullable"` - // If set, the event will override the waiting room's `queueing_method` property - // while it is active. If null, the event will inherit it. - QueueingMethod string `json:"queueing_method,nullable"` - // If set, the event will override the waiting room's `session_duration` property - // while it is active. If null, the event will inherit it. - SessionDuration int64 `json:"session_duration,nullable"` - // If enabled, users in the prequeue will be shuffled randomly at the - // `event_start_time`. Requires that `prequeue_start_time` is not null. This is - // useful for situations when many users will join the event prequeue at the same - // time and you want to shuffle them to ensure fairness. Naturally, it makes the - // most sense to enable this feature when the `queueing_method` during the event - // respects ordering such as **fifo**, or else the shuffling may be unnecessary. - ShuffleAtEventStart bool `json:"shuffle_at_event_start"` - // Suspends or allows an event. If set to `true`, the event is ignored and traffic - // will be handled based on the waiting room configuration. - Suspended bool `json:"suspended"` - // If set, the event will override the waiting room's `total_active_users` property - // while it is active. If null, the event will inherit it. This can only be set if - // the event's `new_users_per_minute` property is also set. - TotalActiveUsers int64 `json:"total_active_users,nullable"` - JSON waitingRoomEventListResponseJSON `json:"-"` -} - -// waitingRoomEventListResponseJSON contains the JSON metadata for the struct -// [WaitingRoomEventListResponse] -type waitingRoomEventListResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - CustomPageHTML apijson.Field - Description apijson.Field - DisableSessionRenewal apijson.Field - EventEndTime apijson.Field - EventStartTime apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - NewUsersPerMinute apijson.Field - PrequeueStartTime apijson.Field - QueueingMethod apijson.Field - SessionDuration apijson.Field - ShuffleAtEventStart apijson.Field - Suspended apijson.Field - TotalActiveUsers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEventListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEventListResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomEventDeleteResponse struct { - ID interface{} `json:"id"` - JSON waitingRoomEventDeleteResponseJSON `json:"-"` -} - -// waitingRoomEventDeleteResponseJSON contains the JSON metadata for the struct -// [WaitingRoomEventDeleteResponse] -type waitingRoomEventDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEventDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEventDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomEventEditResponse struct { - ID interface{} `json:"id"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // If set, the event will override the waiting room's `custom_page_html` property - // while it is active. If null, the event will inherit it. - CustomPageHTML string `json:"custom_page_html,nullable"` - // A note that you can use to add more details about the event. - Description string `json:"description"` - // If set, the event will override the waiting room's `disable_session_renewal` - // property while it is active. If null, the event will inherit it. - DisableSessionRenewal bool `json:"disable_session_renewal,nullable"` - // An ISO 8601 timestamp that marks the end of the event. - EventEndTime string `json:"event_end_time"` - // An ISO 8601 timestamp that marks the start of the event. At this time, queued - // users will be processed with the event's configuration. The start time must be - // at least one minute before `event_end_time`. - EventStartTime string `json:"event_start_time"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A unique name to identify the event. Only alphanumeric characters, hyphens and - // underscores are allowed. - Name string `json:"name"` - // If set, the event will override the waiting room's `new_users_per_minute` - // property while it is active. If null, the event will inherit it. This can only - // be set if the event's `total_active_users` property is also set. - NewUsersPerMinute int64 `json:"new_users_per_minute,nullable"` - // An ISO 8601 timestamp that marks when to begin queueing all users before the - // event starts. The prequeue must start at least five minutes before - // `event_start_time`. - PrequeueStartTime string `json:"prequeue_start_time,nullable"` - // If set, the event will override the waiting room's `queueing_method` property - // while it is active. If null, the event will inherit it. - QueueingMethod string `json:"queueing_method,nullable"` - // If set, the event will override the waiting room's `session_duration` property - // while it is active. If null, the event will inherit it. - SessionDuration int64 `json:"session_duration,nullable"` - // If enabled, users in the prequeue will be shuffled randomly at the - // `event_start_time`. Requires that `prequeue_start_time` is not null. This is - // useful for situations when many users will join the event prequeue at the same - // time and you want to shuffle them to ensure fairness. Naturally, it makes the - // most sense to enable this feature when the `queueing_method` during the event - // respects ordering such as **fifo**, or else the shuffling may be unnecessary. - ShuffleAtEventStart bool `json:"shuffle_at_event_start"` - // Suspends or allows an event. If set to `true`, the event is ignored and traffic - // will be handled based on the waiting room configuration. - Suspended bool `json:"suspended"` - // If set, the event will override the waiting room's `total_active_users` property - // while it is active. If null, the event will inherit it. This can only be set if - // the event's `new_users_per_minute` property is also set. - TotalActiveUsers int64 `json:"total_active_users,nullable"` - JSON waitingRoomEventEditResponseJSON `json:"-"` -} - -// waitingRoomEventEditResponseJSON contains the JSON metadata for the struct -// [WaitingRoomEventEditResponse] -type waitingRoomEventEditResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - CustomPageHTML apijson.Field - Description apijson.Field - DisableSessionRenewal apijson.Field - EventEndTime apijson.Field - EventStartTime apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - NewUsersPerMinute apijson.Field - PrequeueStartTime apijson.Field - QueueingMethod apijson.Field - SessionDuration apijson.Field - ShuffleAtEventStart apijson.Field - Suspended apijson.Field - TotalActiveUsers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEventEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEventEditResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomEventGetResponse struct { - ID interface{} `json:"id"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // If set, the event will override the waiting room's `custom_page_html` property - // while it is active. If null, the event will inherit it. - CustomPageHTML string `json:"custom_page_html,nullable"` - // A note that you can use to add more details about the event. - Description string `json:"description"` - // If set, the event will override the waiting room's `disable_session_renewal` - // property while it is active. If null, the event will inherit it. - DisableSessionRenewal bool `json:"disable_session_renewal,nullable"` - // An ISO 8601 timestamp that marks the end of the event. - EventEndTime string `json:"event_end_time"` - // An ISO 8601 timestamp that marks the start of the event. At this time, queued - // users will be processed with the event's configuration. The start time must be - // at least one minute before `event_end_time`. - EventStartTime string `json:"event_start_time"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A unique name to identify the event. Only alphanumeric characters, hyphens and - // underscores are allowed. - Name string `json:"name"` - // If set, the event will override the waiting room's `new_users_per_minute` - // property while it is active. If null, the event will inherit it. This can only - // be set if the event's `total_active_users` property is also set. - NewUsersPerMinute int64 `json:"new_users_per_minute,nullable"` - // An ISO 8601 timestamp that marks when to begin queueing all users before the - // event starts. The prequeue must start at least five minutes before - // `event_start_time`. - PrequeueStartTime string `json:"prequeue_start_time,nullable"` - // If set, the event will override the waiting room's `queueing_method` property - // while it is active. If null, the event will inherit it. - QueueingMethod string `json:"queueing_method,nullable"` - // If set, the event will override the waiting room's `session_duration` property - // while it is active. If null, the event will inherit it. - SessionDuration int64 `json:"session_duration,nullable"` - // If enabled, users in the prequeue will be shuffled randomly at the - // `event_start_time`. Requires that `prequeue_start_time` is not null. This is - // useful for situations when many users will join the event prequeue at the same - // time and you want to shuffle them to ensure fairness. Naturally, it makes the - // most sense to enable this feature when the `queueing_method` during the event - // respects ordering such as **fifo**, or else the shuffling may be unnecessary. - ShuffleAtEventStart bool `json:"shuffle_at_event_start"` - // Suspends or allows an event. If set to `true`, the event is ignored and traffic - // will be handled based on the waiting room configuration. - Suspended bool `json:"suspended"` - // If set, the event will override the waiting room's `total_active_users` property - // while it is active. If null, the event will inherit it. This can only be set if - // the event's `new_users_per_minute` property is also set. - TotalActiveUsers int64 `json:"total_active_users,nullable"` - JSON waitingRoomEventGetResponseJSON `json:"-"` -} - -// waitingRoomEventGetResponseJSON contains the JSON metadata for the struct -// [WaitingRoomEventGetResponse] -type waitingRoomEventGetResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - CustomPageHTML apijson.Field - Description apijson.Field - DisableSessionRenewal apijson.Field - EventEndTime apijson.Field - EventStartTime apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - NewUsersPerMinute apijson.Field - PrequeueStartTime apijson.Field - QueueingMethod apijson.Field - SessionDuration apijson.Field - ShuffleAtEventStart apijson.Field - Suspended apijson.Field - TotalActiveUsers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEventGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEventGetResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomEventNewParams struct { - // An ISO 8601 timestamp that marks the end of the event. - EventEndTime param.Field[string] `json:"event_end_time,required"` - // An ISO 8601 timestamp that marks the start of the event. At this time, queued - // users will be processed with the event's configuration. The start time must be - // at least one minute before `event_end_time`. - EventStartTime param.Field[string] `json:"event_start_time,required"` - // A unique name to identify the event. Only alphanumeric characters, hyphens and - // underscores are allowed. - Name param.Field[string] `json:"name,required"` - // If set, the event will override the waiting room's `custom_page_html` property - // while it is active. If null, the event will inherit it. - CustomPageHTML param.Field[string] `json:"custom_page_html"` - // A note that you can use to add more details about the event. - Description param.Field[string] `json:"description"` - // If set, the event will override the waiting room's `disable_session_renewal` - // property while it is active. If null, the event will inherit it. - DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` - // If set, the event will override the waiting room's `new_users_per_minute` - // property while it is active. If null, the event will inherit it. This can only - // be set if the event's `total_active_users` property is also set. - NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute"` - // An ISO 8601 timestamp that marks when to begin queueing all users before the - // event starts. The prequeue must start at least five minutes before - // `event_start_time`. - PrequeueStartTime param.Field[string] `json:"prequeue_start_time"` - // If set, the event will override the waiting room's `queueing_method` property - // while it is active. If null, the event will inherit it. - QueueingMethod param.Field[string] `json:"queueing_method"` - // If set, the event will override the waiting room's `session_duration` property - // while it is active. If null, the event will inherit it. - SessionDuration param.Field[int64] `json:"session_duration"` - // If enabled, users in the prequeue will be shuffled randomly at the - // `event_start_time`. Requires that `prequeue_start_time` is not null. This is - // useful for situations when many users will join the event prequeue at the same - // time and you want to shuffle them to ensure fairness. Naturally, it makes the - // most sense to enable this feature when the `queueing_method` during the event - // respects ordering such as **fifo**, or else the shuffling may be unnecessary. - ShuffleAtEventStart param.Field[bool] `json:"shuffle_at_event_start"` - // Suspends or allows an event. If set to `true`, the event is ignored and traffic - // will be handled based on the waiting room configuration. - Suspended param.Field[bool] `json:"suspended"` - // If set, the event will override the waiting room's `total_active_users` property - // while it is active. If null, the event will inherit it. This can only be set if - // the event's `new_users_per_minute` property is also set. - TotalActiveUsers param.Field[int64] `json:"total_active_users"` -} - -func (r WaitingRoomEventNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WaitingRoomEventNewResponseEnvelope struct { - Result WaitingRoomEventNewResponse `json:"result,required"` - JSON waitingRoomEventNewResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomEventNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [WaitingRoomEventNewResponseEnvelope] -type waitingRoomEventNewResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEventNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEventNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomEventUpdateParams struct { - // An ISO 8601 timestamp that marks the end of the event. - EventEndTime param.Field[string] `json:"event_end_time,required"` - // An ISO 8601 timestamp that marks the start of the event. At this time, queued - // users will be processed with the event's configuration. The start time must be - // at least one minute before `event_end_time`. - EventStartTime param.Field[string] `json:"event_start_time,required"` - // A unique name to identify the event. Only alphanumeric characters, hyphens and - // underscores are allowed. - Name param.Field[string] `json:"name,required"` - // If set, the event will override the waiting room's `custom_page_html` property - // while it is active. If null, the event will inherit it. - CustomPageHTML param.Field[string] `json:"custom_page_html"` - // A note that you can use to add more details about the event. - Description param.Field[string] `json:"description"` - // If set, the event will override the waiting room's `disable_session_renewal` - // property while it is active. If null, the event will inherit it. - DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` - // If set, the event will override the waiting room's `new_users_per_minute` - // property while it is active. If null, the event will inherit it. This can only - // be set if the event's `total_active_users` property is also set. - NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute"` - // An ISO 8601 timestamp that marks when to begin queueing all users before the - // event starts. The prequeue must start at least five minutes before - // `event_start_time`. - PrequeueStartTime param.Field[string] `json:"prequeue_start_time"` - // If set, the event will override the waiting room's `queueing_method` property - // while it is active. If null, the event will inherit it. - QueueingMethod param.Field[string] `json:"queueing_method"` - // If set, the event will override the waiting room's `session_duration` property - // while it is active. If null, the event will inherit it. - SessionDuration param.Field[int64] `json:"session_duration"` - // If enabled, users in the prequeue will be shuffled randomly at the - // `event_start_time`. Requires that `prequeue_start_time` is not null. This is - // useful for situations when many users will join the event prequeue at the same - // time and you want to shuffle them to ensure fairness. Naturally, it makes the - // most sense to enable this feature when the `queueing_method` during the event - // respects ordering such as **fifo**, or else the shuffling may be unnecessary. - ShuffleAtEventStart param.Field[bool] `json:"shuffle_at_event_start"` - // Suspends or allows an event. If set to `true`, the event is ignored and traffic - // will be handled based on the waiting room configuration. - Suspended param.Field[bool] `json:"suspended"` - // If set, the event will override the waiting room's `total_active_users` property - // while it is active. If null, the event will inherit it. This can only be set if - // the event's `new_users_per_minute` property is also set. - TotalActiveUsers param.Field[int64] `json:"total_active_users"` -} - -func (r WaitingRoomEventUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WaitingRoomEventUpdateResponseEnvelope struct { - Result WaitingRoomEventUpdateResponse `json:"result,required"` - JSON waitingRoomEventUpdateResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomEventUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [WaitingRoomEventUpdateResponseEnvelope] -type waitingRoomEventUpdateResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEventUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEventUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomEventListResponseEnvelope struct { - Errors []WaitingRoomEventListResponseEnvelopeErrors `json:"errors,required"` - Messages []WaitingRoomEventListResponseEnvelopeMessages `json:"messages,required"` - Result []WaitingRoomEventListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success WaitingRoomEventListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo WaitingRoomEventListResponseEnvelopeResultInfo `json:"result_info"` - JSON waitingRoomEventListResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomEventListResponseEnvelopeJSON contains the JSON metadata for the -// struct [WaitingRoomEventListResponseEnvelope] -type waitingRoomEventListResponseEnvelopeJSON 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 *WaitingRoomEventListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEventListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomEventListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON waitingRoomEventListResponseEnvelopeErrorsJSON `json:"-"` -} - -// waitingRoomEventListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [WaitingRoomEventListResponseEnvelopeErrors] -type waitingRoomEventListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEventListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEventListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomEventListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON waitingRoomEventListResponseEnvelopeMessagesJSON `json:"-"` -} - -// waitingRoomEventListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WaitingRoomEventListResponseEnvelopeMessages] -type waitingRoomEventListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEventListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEventListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WaitingRoomEventListResponseEnvelopeSuccess bool - -const ( - WaitingRoomEventListResponseEnvelopeSuccessTrue WaitingRoomEventListResponseEnvelopeSuccess = true -) - -type WaitingRoomEventListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON waitingRoomEventListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// waitingRoomEventListResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [WaitingRoomEventListResponseEnvelopeResultInfo] -type waitingRoomEventListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEventListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEventListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomEventDeleteResponseEnvelope struct { - Result WaitingRoomEventDeleteResponse `json:"result,required"` - JSON waitingRoomEventDeleteResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomEventDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [WaitingRoomEventDeleteResponseEnvelope] -type waitingRoomEventDeleteResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEventDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEventDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomEventEditParams struct { - // An ISO 8601 timestamp that marks the end of the event. - EventEndTime param.Field[string] `json:"event_end_time,required"` - // An ISO 8601 timestamp that marks the start of the event. At this time, queued - // users will be processed with the event's configuration. The start time must be - // at least one minute before `event_end_time`. - EventStartTime param.Field[string] `json:"event_start_time,required"` - // A unique name to identify the event. Only alphanumeric characters, hyphens and - // underscores are allowed. - Name param.Field[string] `json:"name,required"` - // If set, the event will override the waiting room's `custom_page_html` property - // while it is active. If null, the event will inherit it. - CustomPageHTML param.Field[string] `json:"custom_page_html"` - // A note that you can use to add more details about the event. - Description param.Field[string] `json:"description"` - // If set, the event will override the waiting room's `disable_session_renewal` - // property while it is active. If null, the event will inherit it. - DisableSessionRenewal param.Field[bool] `json:"disable_session_renewal"` - // If set, the event will override the waiting room's `new_users_per_minute` - // property while it is active. If null, the event will inherit it. This can only - // be set if the event's `total_active_users` property is also set. - NewUsersPerMinute param.Field[int64] `json:"new_users_per_minute"` - // An ISO 8601 timestamp that marks when to begin queueing all users before the - // event starts. The prequeue must start at least five minutes before - // `event_start_time`. - PrequeueStartTime param.Field[string] `json:"prequeue_start_time"` - // If set, the event will override the waiting room's `queueing_method` property - // while it is active. If null, the event will inherit it. - QueueingMethod param.Field[string] `json:"queueing_method"` - // If set, the event will override the waiting room's `session_duration` property - // while it is active. If null, the event will inherit it. - SessionDuration param.Field[int64] `json:"session_duration"` - // If enabled, users in the prequeue will be shuffled randomly at the - // `event_start_time`. Requires that `prequeue_start_time` is not null. This is - // useful for situations when many users will join the event prequeue at the same - // time and you want to shuffle them to ensure fairness. Naturally, it makes the - // most sense to enable this feature when the `queueing_method` during the event - // respects ordering such as **fifo**, or else the shuffling may be unnecessary. - ShuffleAtEventStart param.Field[bool] `json:"shuffle_at_event_start"` - // Suspends or allows an event. If set to `true`, the event is ignored and traffic - // will be handled based on the waiting room configuration. - Suspended param.Field[bool] `json:"suspended"` - // If set, the event will override the waiting room's `total_active_users` property - // while it is active. If null, the event will inherit it. This can only be set if - // the event's `new_users_per_minute` property is also set. - TotalActiveUsers param.Field[int64] `json:"total_active_users"` -} - -func (r WaitingRoomEventEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WaitingRoomEventEditResponseEnvelope struct { - Result WaitingRoomEventEditResponse `json:"result,required"` - JSON waitingRoomEventEditResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomEventEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [WaitingRoomEventEditResponseEnvelope] -type waitingRoomEventEditResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEventEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEventEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomEventGetResponseEnvelope struct { - Result WaitingRoomEventGetResponse `json:"result,required"` - JSON waitingRoomEventGetResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomEventGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [WaitingRoomEventGetResponseEnvelope] -type waitingRoomEventGetResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEventGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEventGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/waitingroomevent_test.go b/waitingroomevent_test.go deleted file mode 100644 index 6de46595e34..00000000000 --- a/waitingroomevent_test.go +++ /dev/null @@ -1,231 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWaitingRoomEventNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.WaitingRooms.Events.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "699d98642c564d2e855e9661899b7252", - cloudflare.WaitingRoomEventNewParams{ - EventEndTime: cloudflare.F("2021-09-28T17:00:00.000Z"), - EventStartTime: cloudflare.F("2021-09-28T15:30:00.000Z"), - Name: cloudflare.F("production_webinar_event"), - CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Event is prequeueing / Queue all enabled {{/waitTimeKnown}}"), - Description: cloudflare.F("Production event - DO NOT MODIFY"), - DisableSessionRenewal: cloudflare.F(true), - NewUsersPerMinute: cloudflare.F(int64(200)), - PrequeueStartTime: cloudflare.F("2021-09-28T15:00:00.000Z"), - QueueingMethod: cloudflare.F("random"), - SessionDuration: cloudflare.F(int64(1)), - ShuffleAtEventStart: cloudflare.F(true), - Suspended: cloudflare.F(true), - TotalActiveUsers: cloudflare.F(int64(200)), - }, - ) - 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 TestWaitingRoomEventUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.WaitingRooms.Events.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "699d98642c564d2e855e9661899b7252", - "25756b2dfe6e378a06b033b670413757", - cloudflare.WaitingRoomEventUpdateParams{ - EventEndTime: cloudflare.F("2021-09-28T17:00:00.000Z"), - EventStartTime: cloudflare.F("2021-09-28T15:30:00.000Z"), - Name: cloudflare.F("production_webinar_event"), - CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Event is prequeueing / Queue all enabled {{/waitTimeKnown}}"), - Description: cloudflare.F("Production event - DO NOT MODIFY"), - DisableSessionRenewal: cloudflare.F(true), - NewUsersPerMinute: cloudflare.F(int64(200)), - PrequeueStartTime: cloudflare.F("2021-09-28T15:00:00.000Z"), - QueueingMethod: cloudflare.F("random"), - SessionDuration: cloudflare.F(int64(1)), - ShuffleAtEventStart: cloudflare.F(true), - Suspended: cloudflare.F(true), - TotalActiveUsers: cloudflare.F(int64(200)), - }, - ) - 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 TestWaitingRoomEventList(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("user@example.com"), - ) - _, err := client.WaitingRooms.Events.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "699d98642c564d2e855e9661899b7252", - ) - 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 TestWaitingRoomEventDelete(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("user@example.com"), - ) - _, err := client.WaitingRooms.Events.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "699d98642c564d2e855e9661899b7252", - "25756b2dfe6e378a06b033b670413757", - ) - 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 TestWaitingRoomEventEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.WaitingRooms.Events.Edit( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "699d98642c564d2e855e9661899b7252", - "25756b2dfe6e378a06b033b670413757", - cloudflare.WaitingRoomEventEditParams{ - EventEndTime: cloudflare.F("2021-09-28T17:00:00.000Z"), - EventStartTime: cloudflare.F("2021-09-28T15:30:00.000Z"), - Name: cloudflare.F("production_webinar_event"), - CustomPageHTML: cloudflare.F("{{#waitTimeKnown}} {{waitTime}} mins {{/waitTimeKnown}} {{^waitTimeKnown}} Event is prequeueing / Queue all enabled {{/waitTimeKnown}}"), - Description: cloudflare.F("Production event - DO NOT MODIFY"), - DisableSessionRenewal: cloudflare.F(true), - NewUsersPerMinute: cloudflare.F(int64(200)), - PrequeueStartTime: cloudflare.F("2021-09-28T15:00:00.000Z"), - QueueingMethod: cloudflare.F("random"), - SessionDuration: cloudflare.F(int64(1)), - ShuffleAtEventStart: cloudflare.F(true), - Suspended: cloudflare.F(true), - TotalActiveUsers: cloudflare.F(int64(200)), - }, - ) - 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 TestWaitingRoomEventGet(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("user@example.com"), - ) - _, err := client.WaitingRooms.Events.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "699d98642c564d2e855e9661899b7252", - "25756b2dfe6e378a06b033b670413757", - ) - 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/waitingroomeventdetail.go b/waitingroomeventdetail.go deleted file mode 100644 index 4dc30924eba..00000000000 --- a/waitingroomeventdetail.go +++ /dev/null @@ -1,136 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WaitingRoomEventDetailService 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 [NewWaitingRoomEventDetailService] -// method instead. -type WaitingRoomEventDetailService struct { - Options []option.RequestOption -} - -// NewWaitingRoomEventDetailService 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 NewWaitingRoomEventDetailService(opts ...option.RequestOption) (r *WaitingRoomEventDetailService) { - r = &WaitingRoomEventDetailService{} - r.Options = opts - return -} - -// Previews an event's configuration as if it was active. Inherited fields from the -// waiting room will be displayed with their current values. -func (r *WaitingRoomEventDetailService) Get(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, eventID interface{}, opts ...option.RequestOption) (res *WaitingRoomEventDetailGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomEventDetailGetResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%v/events/%v/details", zoneIdentifier, waitingRoomID, eventID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WaitingRoomEventDetailGetResponse struct { - ID interface{} `json:"id"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - CustomPageHTML string `json:"custom_page_html"` - // A note that you can use to add more details about the event. - Description string `json:"description"` - DisableSessionRenewal bool `json:"disable_session_renewal"` - // An ISO 8601 timestamp that marks the end of the event. - EventEndTime string `json:"event_end_time"` - // An ISO 8601 timestamp that marks the start of the event. At this time, queued - // users will be processed with the event's configuration. The start time must be - // at least one minute before `event_end_time`. - EventStartTime string `json:"event_start_time"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // A unique name to identify the event. Only alphanumeric characters, hyphens and - // underscores are allowed. - Name string `json:"name"` - NewUsersPerMinute int64 `json:"new_users_per_minute"` - // An ISO 8601 timestamp that marks when to begin queueing all users before the - // event starts. The prequeue must start at least five minutes before - // `event_start_time`. - PrequeueStartTime string `json:"prequeue_start_time,nullable"` - QueueingMethod string `json:"queueing_method"` - SessionDuration int64 `json:"session_duration"` - // If enabled, users in the prequeue will be shuffled randomly at the - // `event_start_time`. Requires that `prequeue_start_time` is not null. This is - // useful for situations when many users will join the event prequeue at the same - // time and you want to shuffle them to ensure fairness. Naturally, it makes the - // most sense to enable this feature when the `queueing_method` during the event - // respects ordering such as **fifo**, or else the shuffling may be unnecessary. - ShuffleAtEventStart bool `json:"shuffle_at_event_start"` - // Suspends or allows an event. If set to `true`, the event is ignored and traffic - // will be handled based on the waiting room configuration. - Suspended bool `json:"suspended"` - TotalActiveUsers int64 `json:"total_active_users"` - JSON waitingRoomEventDetailGetResponseJSON `json:"-"` -} - -// waitingRoomEventDetailGetResponseJSON contains the JSON metadata for the struct -// [WaitingRoomEventDetailGetResponse] -type waitingRoomEventDetailGetResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - CustomPageHTML apijson.Field - Description apijson.Field - DisableSessionRenewal apijson.Field - EventEndTime apijson.Field - EventStartTime apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - NewUsersPerMinute apijson.Field - PrequeueStartTime apijson.Field - QueueingMethod apijson.Field - SessionDuration apijson.Field - ShuffleAtEventStart apijson.Field - Suspended apijson.Field - TotalActiveUsers apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEventDetailGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEventDetailGetResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomEventDetailGetResponseEnvelope struct { - Result WaitingRoomEventDetailGetResponse `json:"result,required"` - JSON waitingRoomEventDetailGetResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomEventDetailGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [WaitingRoomEventDetailGetResponseEnvelope] -type waitingRoomEventDetailGetResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomEventDetailGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomEventDetailGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/waitingroomeventdetail_test.go b/waitingroomeventdetail_test.go deleted file mode 100644 index adedccf2c13..00000000000 --- a/waitingroomeventdetail_test.go +++ /dev/null @@ -1,43 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWaitingRoomEventDetailGet(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("user@example.com"), - ) - _, err := client.WaitingRooms.Events.Details.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "699d98642c564d2e855e9661899b7252", - "25756b2dfe6e378a06b033b670413757", - ) - 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/waitingroomrule.go b/waitingroomrule.go deleted file mode 100644 index 95361a7bf2b..00000000000 --- a/waitingroomrule.go +++ /dev/null @@ -1,999 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WaitingRoomRuleService 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 [NewWaitingRoomRuleService] method -// instead. -type WaitingRoomRuleService struct { - Options []option.RequestOption -} - -// NewWaitingRoomRuleService 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 NewWaitingRoomRuleService(opts ...option.RequestOption) (r *WaitingRoomRuleService) { - r = &WaitingRoomRuleService{} - r.Options = opts - return -} - -// Only available for the Waiting Room Advanced subscription. Creates a rule for a -// waiting room. -func (r *WaitingRoomRuleService) New(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body WaitingRoomRuleNewParams, opts ...option.RequestOption) (res *[]WaitingRoomRuleNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomRuleNewResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%v/rules", zoneIdentifier, waitingRoomID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Only available for the Waiting Room Advanced subscription. Replaces all rules -// for a waiting room. -func (r *WaitingRoomRuleService) Update(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, body WaitingRoomRuleUpdateParams, opts ...option.RequestOption) (res *[]WaitingRoomRuleUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomRuleUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%v/rules", zoneIdentifier, waitingRoomID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists rules for a waiting room. -func (r *WaitingRoomRuleService) List(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, opts ...option.RequestOption) (res *[]WaitingRoomRuleListResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomRuleListResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%v/rules", zoneIdentifier, waitingRoomID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a rule for a waiting room. -func (r *WaitingRoomRuleService) Delete(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, ruleID string, opts ...option.RequestOption) (res *[]WaitingRoomRuleDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomRuleDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%v/rules/%s", zoneIdentifier, waitingRoomID, ruleID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Patches a rule for a waiting room. -func (r *WaitingRoomRuleService) Edit(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, ruleID string, body WaitingRoomRuleEditParams, opts ...option.RequestOption) (res *[]WaitingRoomRuleEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomRuleEditResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%v/rules/%s", zoneIdentifier, waitingRoomID, ruleID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WaitingRoomRuleNewResponse struct { - // The ID of the rule. - ID string `json:"id"` - // The action to take when the expression matches. - Action WaitingRoomRuleNewResponseAction `json:"action"` - // The description of the rule. - Description string `json:"description"` - // When set to true, the rule is enabled. - Enabled bool `json:"enabled"` - // Criteria defining when there is a match for the current rule. - Expression string `json:"expression"` - LastUpdated time.Time `json:"last_updated" format:"date-time"` - // The version of the rule. - Version string `json:"version"` - JSON waitingRoomRuleNewResponseJSON `json:"-"` -} - -// waitingRoomRuleNewResponseJSON contains the JSON metadata for the struct -// [WaitingRoomRuleNewResponse] -type waitingRoomRuleNewResponseJSON struct { - ID apijson.Field - Action apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - LastUpdated apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleNewResponseJSON) RawJSON() string { - return r.raw -} - -// The action to take when the expression matches. -type WaitingRoomRuleNewResponseAction string - -const ( - WaitingRoomRuleNewResponseActionBypassWaitingRoom WaitingRoomRuleNewResponseAction = "bypass_waiting_room" -) - -type WaitingRoomRuleUpdateResponse struct { - // The ID of the rule. - ID string `json:"id"` - // The action to take when the expression matches. - Action WaitingRoomRuleUpdateResponseAction `json:"action"` - // The description of the rule. - Description string `json:"description"` - // When set to true, the rule is enabled. - Enabled bool `json:"enabled"` - // Criteria defining when there is a match for the current rule. - Expression string `json:"expression"` - LastUpdated time.Time `json:"last_updated" format:"date-time"` - // The version of the rule. - Version string `json:"version"` - JSON waitingRoomRuleUpdateResponseJSON `json:"-"` -} - -// waitingRoomRuleUpdateResponseJSON contains the JSON metadata for the struct -// [WaitingRoomRuleUpdateResponse] -type waitingRoomRuleUpdateResponseJSON struct { - ID apijson.Field - Action apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - LastUpdated apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// The action to take when the expression matches. -type WaitingRoomRuleUpdateResponseAction string - -const ( - WaitingRoomRuleUpdateResponseActionBypassWaitingRoom WaitingRoomRuleUpdateResponseAction = "bypass_waiting_room" -) - -type WaitingRoomRuleListResponse struct { - // The ID of the rule. - ID string `json:"id"` - // The action to take when the expression matches. - Action WaitingRoomRuleListResponseAction `json:"action"` - // The description of the rule. - Description string `json:"description"` - // When set to true, the rule is enabled. - Enabled bool `json:"enabled"` - // Criteria defining when there is a match for the current rule. - Expression string `json:"expression"` - LastUpdated time.Time `json:"last_updated" format:"date-time"` - // The version of the rule. - Version string `json:"version"` - JSON waitingRoomRuleListResponseJSON `json:"-"` -} - -// waitingRoomRuleListResponseJSON contains the JSON metadata for the struct -// [WaitingRoomRuleListResponse] -type waitingRoomRuleListResponseJSON struct { - ID apijson.Field - Action apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - LastUpdated apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleListResponseJSON) RawJSON() string { - return r.raw -} - -// The action to take when the expression matches. -type WaitingRoomRuleListResponseAction string - -const ( - WaitingRoomRuleListResponseActionBypassWaitingRoom WaitingRoomRuleListResponseAction = "bypass_waiting_room" -) - -type WaitingRoomRuleDeleteResponse struct { - // The ID of the rule. - ID string `json:"id"` - // The action to take when the expression matches. - Action WaitingRoomRuleDeleteResponseAction `json:"action"` - // The description of the rule. - Description string `json:"description"` - // When set to true, the rule is enabled. - Enabled bool `json:"enabled"` - // Criteria defining when there is a match for the current rule. - Expression string `json:"expression"` - LastUpdated time.Time `json:"last_updated" format:"date-time"` - // The version of the rule. - Version string `json:"version"` - JSON waitingRoomRuleDeleteResponseJSON `json:"-"` -} - -// waitingRoomRuleDeleteResponseJSON contains the JSON metadata for the struct -// [WaitingRoomRuleDeleteResponse] -type waitingRoomRuleDeleteResponseJSON struct { - ID apijson.Field - Action apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - LastUpdated apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// The action to take when the expression matches. -type WaitingRoomRuleDeleteResponseAction string - -const ( - WaitingRoomRuleDeleteResponseActionBypassWaitingRoom WaitingRoomRuleDeleteResponseAction = "bypass_waiting_room" -) - -type WaitingRoomRuleEditResponse struct { - // The ID of the rule. - ID string `json:"id"` - // The action to take when the expression matches. - Action WaitingRoomRuleEditResponseAction `json:"action"` - // The description of the rule. - Description string `json:"description"` - // When set to true, the rule is enabled. - Enabled bool `json:"enabled"` - // Criteria defining when there is a match for the current rule. - Expression string `json:"expression"` - LastUpdated time.Time `json:"last_updated" format:"date-time"` - // The version of the rule. - Version string `json:"version"` - JSON waitingRoomRuleEditResponseJSON `json:"-"` -} - -// waitingRoomRuleEditResponseJSON contains the JSON metadata for the struct -// [WaitingRoomRuleEditResponse] -type waitingRoomRuleEditResponseJSON struct { - ID apijson.Field - Action apijson.Field - Description apijson.Field - Enabled apijson.Field - Expression apijson.Field - LastUpdated apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleEditResponseJSON) RawJSON() string { - return r.raw -} - -// The action to take when the expression matches. -type WaitingRoomRuleEditResponseAction string - -const ( - WaitingRoomRuleEditResponseActionBypassWaitingRoom WaitingRoomRuleEditResponseAction = "bypass_waiting_room" -) - -type WaitingRoomRuleNewParams struct { - // The action to take when the expression matches. - Action param.Field[WaitingRoomRuleNewParamsAction] `json:"action,required"` - // Criteria defining when there is a match for the current rule. - Expression param.Field[string] `json:"expression,required"` - // The description of the rule. - Description param.Field[string] `json:"description"` - // When set to true, the rule is enabled. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r WaitingRoomRuleNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The action to take when the expression matches. -type WaitingRoomRuleNewParamsAction string - -const ( - WaitingRoomRuleNewParamsActionBypassWaitingRoom WaitingRoomRuleNewParamsAction = "bypass_waiting_room" -) - -type WaitingRoomRuleNewResponseEnvelope struct { - Errors []WaitingRoomRuleNewResponseEnvelopeErrors `json:"errors,required"` - Messages []WaitingRoomRuleNewResponseEnvelopeMessages `json:"messages,required"` - Result []WaitingRoomRuleNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success WaitingRoomRuleNewResponseEnvelopeSuccess `json:"success,required"` - ResultInfo WaitingRoomRuleNewResponseEnvelopeResultInfo `json:"result_info"` - JSON waitingRoomRuleNewResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomRuleNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [WaitingRoomRuleNewResponseEnvelope] -type waitingRoomRuleNewResponseEnvelopeJSON 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 *WaitingRoomRuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomRuleNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON waitingRoomRuleNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// waitingRoomRuleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WaitingRoomRuleNewResponseEnvelopeErrors] -type waitingRoomRuleNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomRuleNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON waitingRoomRuleNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// waitingRoomRuleNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WaitingRoomRuleNewResponseEnvelopeMessages] -type waitingRoomRuleNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WaitingRoomRuleNewResponseEnvelopeSuccess bool - -const ( - WaitingRoomRuleNewResponseEnvelopeSuccessTrue WaitingRoomRuleNewResponseEnvelopeSuccess = true -) - -type WaitingRoomRuleNewResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON waitingRoomRuleNewResponseEnvelopeResultInfoJSON `json:"-"` -} - -// waitingRoomRuleNewResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [WaitingRoomRuleNewResponseEnvelopeResultInfo] -type waitingRoomRuleNewResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleNewResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomRuleUpdateParams struct { - Body param.Field[[]WaitingRoomRuleUpdateParamsBody] `json:"body,required"` -} - -func (r WaitingRoomRuleUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type WaitingRoomRuleUpdateParamsBody struct { - // The action to take when the expression matches. - Action param.Field[WaitingRoomRuleUpdateParamsBodyAction] `json:"action,required"` - // Criteria defining when there is a match for the current rule. - Expression param.Field[string] `json:"expression,required"` - // The description of the rule. - Description param.Field[string] `json:"description"` - // When set to true, the rule is enabled. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r WaitingRoomRuleUpdateParamsBody) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The action to take when the expression matches. -type WaitingRoomRuleUpdateParamsBodyAction string - -const ( - WaitingRoomRuleUpdateParamsBodyActionBypassWaitingRoom WaitingRoomRuleUpdateParamsBodyAction = "bypass_waiting_room" -) - -type WaitingRoomRuleUpdateResponseEnvelope struct { - Errors []WaitingRoomRuleUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []WaitingRoomRuleUpdateResponseEnvelopeMessages `json:"messages,required"` - Result []WaitingRoomRuleUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success WaitingRoomRuleUpdateResponseEnvelopeSuccess `json:"success,required"` - ResultInfo WaitingRoomRuleUpdateResponseEnvelopeResultInfo `json:"result_info"` - JSON waitingRoomRuleUpdateResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomRuleUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [WaitingRoomRuleUpdateResponseEnvelope] -type waitingRoomRuleUpdateResponseEnvelopeJSON 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 *WaitingRoomRuleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomRuleUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON waitingRoomRuleUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// waitingRoomRuleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [WaitingRoomRuleUpdateResponseEnvelopeErrors] -type waitingRoomRuleUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomRuleUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON waitingRoomRuleUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// waitingRoomRuleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WaitingRoomRuleUpdateResponseEnvelopeMessages] -type waitingRoomRuleUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WaitingRoomRuleUpdateResponseEnvelopeSuccess bool - -const ( - WaitingRoomRuleUpdateResponseEnvelopeSuccessTrue WaitingRoomRuleUpdateResponseEnvelopeSuccess = true -) - -type WaitingRoomRuleUpdateResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON waitingRoomRuleUpdateResponseEnvelopeResultInfoJSON `json:"-"` -} - -// waitingRoomRuleUpdateResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [WaitingRoomRuleUpdateResponseEnvelopeResultInfo] -type waitingRoomRuleUpdateResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomRuleListResponseEnvelope struct { - Errors []WaitingRoomRuleListResponseEnvelopeErrors `json:"errors,required"` - Messages []WaitingRoomRuleListResponseEnvelopeMessages `json:"messages,required"` - Result []WaitingRoomRuleListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success WaitingRoomRuleListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo WaitingRoomRuleListResponseEnvelopeResultInfo `json:"result_info"` - JSON waitingRoomRuleListResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomRuleListResponseEnvelopeJSON contains the JSON metadata for the -// struct [WaitingRoomRuleListResponseEnvelope] -type waitingRoomRuleListResponseEnvelopeJSON 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 *WaitingRoomRuleListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomRuleListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON waitingRoomRuleListResponseEnvelopeErrorsJSON `json:"-"` -} - -// waitingRoomRuleListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WaitingRoomRuleListResponseEnvelopeErrors] -type waitingRoomRuleListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomRuleListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON waitingRoomRuleListResponseEnvelopeMessagesJSON `json:"-"` -} - -// waitingRoomRuleListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WaitingRoomRuleListResponseEnvelopeMessages] -type waitingRoomRuleListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WaitingRoomRuleListResponseEnvelopeSuccess bool - -const ( - WaitingRoomRuleListResponseEnvelopeSuccessTrue WaitingRoomRuleListResponseEnvelopeSuccess = true -) - -type WaitingRoomRuleListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON waitingRoomRuleListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// waitingRoomRuleListResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [WaitingRoomRuleListResponseEnvelopeResultInfo] -type waitingRoomRuleListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomRuleDeleteResponseEnvelope struct { - Errors []WaitingRoomRuleDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []WaitingRoomRuleDeleteResponseEnvelopeMessages `json:"messages,required"` - Result []WaitingRoomRuleDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success WaitingRoomRuleDeleteResponseEnvelopeSuccess `json:"success,required"` - ResultInfo WaitingRoomRuleDeleteResponseEnvelopeResultInfo `json:"result_info"` - JSON waitingRoomRuleDeleteResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomRuleDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [WaitingRoomRuleDeleteResponseEnvelope] -type waitingRoomRuleDeleteResponseEnvelopeJSON 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 *WaitingRoomRuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomRuleDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON waitingRoomRuleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// waitingRoomRuleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [WaitingRoomRuleDeleteResponseEnvelopeErrors] -type waitingRoomRuleDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomRuleDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON waitingRoomRuleDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// waitingRoomRuleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WaitingRoomRuleDeleteResponseEnvelopeMessages] -type waitingRoomRuleDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WaitingRoomRuleDeleteResponseEnvelopeSuccess bool - -const ( - WaitingRoomRuleDeleteResponseEnvelopeSuccessTrue WaitingRoomRuleDeleteResponseEnvelopeSuccess = true -) - -type WaitingRoomRuleDeleteResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON waitingRoomRuleDeleteResponseEnvelopeResultInfoJSON `json:"-"` -} - -// waitingRoomRuleDeleteResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [WaitingRoomRuleDeleteResponseEnvelopeResultInfo] -type waitingRoomRuleDeleteResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomRuleEditParams struct { - // The action to take when the expression matches. - Action param.Field[WaitingRoomRuleEditParamsAction] `json:"action,required"` - // Criteria defining when there is a match for the current rule. - Expression param.Field[string] `json:"expression,required"` - // The description of the rule. - Description param.Field[string] `json:"description"` - // When set to true, the rule is enabled. - Enabled param.Field[bool] `json:"enabled"` - // Reorder the position of a rule - Position param.Field[WaitingRoomRuleEditParamsPosition] `json:"position"` -} - -func (r WaitingRoomRuleEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The action to take when the expression matches. -type WaitingRoomRuleEditParamsAction string - -const ( - WaitingRoomRuleEditParamsActionBypassWaitingRoom WaitingRoomRuleEditParamsAction = "bypass_waiting_room" -) - -// Reorder the position of a rule -// -// Satisfied by [WaitingRoomRuleEditParamsPositionObject], -// [WaitingRoomRuleEditParamsPositionObject], -// [WaitingRoomRuleEditParamsPositionObject]. -type WaitingRoomRuleEditParamsPosition interface { - implementsWaitingRoomRuleEditParamsPosition() -} - -type WaitingRoomRuleEditParamsPositionObject struct { - // Places the rule in the exact position specified by the integer number - // . Position numbers start with 1. Existing rules in the ruleset - // from the specified position number onward are shifted one position (no rule is - // overwritten). - Index param.Field[int64] `json:"index"` -} - -func (r WaitingRoomRuleEditParamsPositionObject) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WaitingRoomRuleEditParamsPositionObject) implementsWaitingRoomRuleEditParamsPosition() {} - -type WaitingRoomRuleEditResponseEnvelope struct { - Errors []WaitingRoomRuleEditResponseEnvelopeErrors `json:"errors,required"` - Messages []WaitingRoomRuleEditResponseEnvelopeMessages `json:"messages,required"` - Result []WaitingRoomRuleEditResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success WaitingRoomRuleEditResponseEnvelopeSuccess `json:"success,required"` - ResultInfo WaitingRoomRuleEditResponseEnvelopeResultInfo `json:"result_info"` - JSON waitingRoomRuleEditResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomRuleEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [WaitingRoomRuleEditResponseEnvelope] -type waitingRoomRuleEditResponseEnvelopeJSON 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 *WaitingRoomRuleEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomRuleEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON waitingRoomRuleEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// waitingRoomRuleEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WaitingRoomRuleEditResponseEnvelopeErrors] -type waitingRoomRuleEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomRuleEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON waitingRoomRuleEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// waitingRoomRuleEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WaitingRoomRuleEditResponseEnvelopeMessages] -type waitingRoomRuleEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WaitingRoomRuleEditResponseEnvelopeSuccess bool - -const ( - WaitingRoomRuleEditResponseEnvelopeSuccessTrue WaitingRoomRuleEditResponseEnvelopeSuccess = true -) - -type WaitingRoomRuleEditResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON waitingRoomRuleEditResponseEnvelopeResultInfoJSON `json:"-"` -} - -// waitingRoomRuleEditResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [WaitingRoomRuleEditResponseEnvelopeResultInfo] -type waitingRoomRuleEditResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomRuleEditResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomRuleEditResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/waitingroomrule_test.go b/waitingroomrule_test.go deleted file mode 100644 index 53e309e5e2c..00000000000 --- a/waitingroomrule_test.go +++ /dev/null @@ -1,189 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWaitingRoomRuleNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.WaitingRooms.Rules.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "699d98642c564d2e855e9661899b7252", - cloudflare.WaitingRoomRuleNewParams{ - Action: cloudflare.F(cloudflare.WaitingRoomRuleNewParamsActionBypassWaitingRoom), - Expression: cloudflare.F("ip.src in {10.20.30.40}"), - Description: cloudflare.F("allow all traffic from 10.20.30.40"), - Enabled: cloudflare.F(true), - }, - ) - 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 TestWaitingRoomRuleUpdate(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("user@example.com"), - ) - _, err := client.WaitingRooms.Rules.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "699d98642c564d2e855e9661899b7252", - cloudflare.WaitingRoomRuleUpdateParams{ - Body: cloudflare.F([]cloudflare.WaitingRoomRuleUpdateParamsBody{{ - Action: cloudflare.F(cloudflare.WaitingRoomRuleUpdateParamsBodyActionBypassWaitingRoom), - Description: cloudflare.F("allow all traffic from 10.20.30.40"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("ip.src in {10.20.30.40}"), - }, { - Action: cloudflare.F(cloudflare.WaitingRoomRuleUpdateParamsBodyActionBypassWaitingRoom), - Description: cloudflare.F("allow all traffic from 10.20.30.40"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("ip.src in {10.20.30.40}"), - }, { - Action: cloudflare.F(cloudflare.WaitingRoomRuleUpdateParamsBodyActionBypassWaitingRoom), - Description: cloudflare.F("allow all traffic from 10.20.30.40"), - Enabled: cloudflare.F(true), - Expression: cloudflare.F("ip.src in {10.20.30.40}"), - }}), - }, - ) - 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 TestWaitingRoomRuleList(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("user@example.com"), - ) - _, err := client.WaitingRooms.Rules.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "699d98642c564d2e855e9661899b7252", - ) - 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 TestWaitingRoomRuleDelete(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("user@example.com"), - ) - _, err := client.WaitingRooms.Rules.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "699d98642c564d2e855e9661899b7252", - "25756b2dfe6e378a06b033b670413757", - ) - 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 TestWaitingRoomRuleEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.WaitingRooms.Rules.Edit( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "699d98642c564d2e855e9661899b7252", - "25756b2dfe6e378a06b033b670413757", - cloudflare.WaitingRoomRuleEditParams{ - Action: cloudflare.F(cloudflare.WaitingRoomRuleEditParamsActionBypassWaitingRoom), - Expression: cloudflare.F("ip.src in {10.20.30.40}"), - Description: cloudflare.F("allow all traffic from 10.20.30.40"), - Enabled: cloudflare.F(true), - Position: cloudflare.F[cloudflare.WaitingRoomRuleEditParamsPosition](cloudflare.WaitingRoomRuleEditParamsPositionObject(cloudflare.WaitingRoomRuleEditParamsPositionObject{ - Index: cloudflare.F(int64(0)), - })), - }, - ) - 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/waitingroomsetting.go b/waitingroomsetting.go deleted file mode 100644 index 33b36701327..00000000000 --- a/waitingroomsetting.go +++ /dev/null @@ -1,228 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WaitingRoomSettingService 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 [NewWaitingRoomSettingService] method -// instead. -type WaitingRoomSettingService struct { - Options []option.RequestOption -} - -// NewWaitingRoomSettingService 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 NewWaitingRoomSettingService(opts ...option.RequestOption) (r *WaitingRoomSettingService) { - r = &WaitingRoomSettingService{} - r.Options = opts - return -} - -// Update zone-level Waiting Room settings -func (r *WaitingRoomSettingService) Update(ctx context.Context, zoneIdentifier string, body WaitingRoomSettingUpdateParams, opts ...option.RequestOption) (res *WaitingRoomSettingUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomSettingUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/settings", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Patch zone-level Waiting Room settings -func (r *WaitingRoomSettingService) Edit(ctx context.Context, zoneIdentifier string, body WaitingRoomSettingEditParams, opts ...option.RequestOption) (res *WaitingRoomSettingEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomSettingEditResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/settings", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get zone-level Waiting Room settings -func (r *WaitingRoomSettingService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *WaitingRoomSettingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomSettingGetResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/settings", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WaitingRoomSettingUpdateResponse struct { - // Whether to allow verified search engine crawlers to bypass all waiting rooms on - // this zone. Verified search engine crawlers will not be tracked or counted by the - // waiting room system, and will not appear in waiting room analytics. - SearchEngineCrawlerBypass bool `json:"search_engine_crawler_bypass,required"` - JSON waitingRoomSettingUpdateResponseJSON `json:"-"` -} - -// waitingRoomSettingUpdateResponseJSON contains the JSON metadata for the struct -// [WaitingRoomSettingUpdateResponse] -type waitingRoomSettingUpdateResponseJSON struct { - SearchEngineCrawlerBypass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomSettingUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomSettingUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomSettingEditResponse struct { - // Whether to allow verified search engine crawlers to bypass all waiting rooms on - // this zone. Verified search engine crawlers will not be tracked or counted by the - // waiting room system, and will not appear in waiting room analytics. - SearchEngineCrawlerBypass bool `json:"search_engine_crawler_bypass,required"` - JSON waitingRoomSettingEditResponseJSON `json:"-"` -} - -// waitingRoomSettingEditResponseJSON contains the JSON metadata for the struct -// [WaitingRoomSettingEditResponse] -type waitingRoomSettingEditResponseJSON struct { - SearchEngineCrawlerBypass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomSettingEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomSettingEditResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomSettingGetResponse struct { - // Whether to allow verified search engine crawlers to bypass all waiting rooms on - // this zone. Verified search engine crawlers will not be tracked or counted by the - // waiting room system, and will not appear in waiting room analytics. - SearchEngineCrawlerBypass bool `json:"search_engine_crawler_bypass,required"` - JSON waitingRoomSettingGetResponseJSON `json:"-"` -} - -// waitingRoomSettingGetResponseJSON contains the JSON metadata for the struct -// [WaitingRoomSettingGetResponse] -type waitingRoomSettingGetResponseJSON struct { - SearchEngineCrawlerBypass apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomSettingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomSettingGetResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomSettingUpdateParams struct { - // Whether to allow verified search engine crawlers to bypass all waiting rooms on - // this zone. Verified search engine crawlers will not be tracked or counted by the - // waiting room system, and will not appear in waiting room analytics. - SearchEngineCrawlerBypass param.Field[bool] `json:"search_engine_crawler_bypass"` -} - -func (r WaitingRoomSettingUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WaitingRoomSettingUpdateResponseEnvelope struct { - Result WaitingRoomSettingUpdateResponse `json:"result,required"` - JSON waitingRoomSettingUpdateResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomSettingUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [WaitingRoomSettingUpdateResponseEnvelope] -type waitingRoomSettingUpdateResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomSettingUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomSettingUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomSettingEditParams struct { - // Whether to allow verified search engine crawlers to bypass all waiting rooms on - // this zone. Verified search engine crawlers will not be tracked or counted by the - // waiting room system, and will not appear in waiting room analytics. - SearchEngineCrawlerBypass param.Field[bool] `json:"search_engine_crawler_bypass"` -} - -func (r WaitingRoomSettingEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WaitingRoomSettingEditResponseEnvelope struct { - Result WaitingRoomSettingEditResponse `json:"result,required"` - JSON waitingRoomSettingEditResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomSettingEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [WaitingRoomSettingEditResponseEnvelope] -type waitingRoomSettingEditResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomSettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomSettingEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomSettingGetResponseEnvelope struct { - Result WaitingRoomSettingGetResponse `json:"result,required"` - JSON waitingRoomSettingGetResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomSettingGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [WaitingRoomSettingGetResponseEnvelope] -type waitingRoomSettingGetResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomSettingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/waitingroomsetting_test.go b/waitingroomsetting_test.go deleted file mode 100644 index bab6db3c403..00000000000 --- a/waitingroomsetting_test.go +++ /dev/null @@ -1,98 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWaitingRoomSettingUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.WaitingRooms.Settings.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.WaitingRoomSettingUpdateParams{ - SearchEngineCrawlerBypass: cloudflare.F(true), - }, - ) - 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 TestWaitingRoomSettingEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.WaitingRooms.Settings.Edit( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.WaitingRoomSettingEditParams{ - SearchEngineCrawlerBypass: cloudflare.F(true), - }, - ) - 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 TestWaitingRoomSettingGet(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("user@example.com"), - ) - _, err := client.WaitingRooms.Settings.Get(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/waitingroomstatus.go b/waitingroomstatus.go deleted file mode 100644 index ac87685eb41..00000000000 --- a/waitingroomstatus.go +++ /dev/null @@ -1,119 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WaitingRoomStatusService 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 [NewWaitingRoomStatusService] method -// instead. -type WaitingRoomStatusService struct { - Options []option.RequestOption -} - -// NewWaitingRoomStatusService 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 NewWaitingRoomStatusService(opts ...option.RequestOption) (r *WaitingRoomStatusService) { - r = &WaitingRoomStatusService{} - r.Options = opts - return -} - -// Fetches the status of a configured waiting room. Response fields include: -// -// 1. `status`: String indicating the status of the waiting room. The possible -// status are: -// - **not_queueing** indicates that the configured thresholds have not been met -// and all users are going through to the origin. -// - **queueing** indicates that the thresholds have been met and some users are -// held in the waiting room. -// - **event_prequeueing** indicates that an event is active and is currently -// prequeueing users before it starts. -// 2. `event_id`: String of the current event's `id` if an event is active, -// otherwise an empty string. -// 3. `estimated_queued_users`: Integer of the estimated number of users currently -// waiting in the queue. -// 4. `estimated_total_active_users`: Integer of the estimated number of users -// currently active on the origin. -// 5. `max_estimated_time_minutes`: Integer of the maximum estimated time currently -// presented to the users. -func (r *WaitingRoomStatusService) Get(ctx context.Context, zoneIdentifier string, waitingRoomID interface{}, opts ...option.RequestOption) (res *WaitingRoomStatusGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WaitingRoomStatusGetResponseEnvelope - path := fmt.Sprintf("zones/%s/waiting_rooms/%v/status", zoneIdentifier, waitingRoomID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WaitingRoomStatusGetResponse struct { - EstimatedQueuedUsers int64 `json:"estimated_queued_users"` - EstimatedTotalActiveUsers int64 `json:"estimated_total_active_users"` - EventID string `json:"event_id"` - MaxEstimatedTimeMinutes int64 `json:"max_estimated_time_minutes"` - Status WaitingRoomStatusGetResponseStatus `json:"status"` - JSON waitingRoomStatusGetResponseJSON `json:"-"` -} - -// waitingRoomStatusGetResponseJSON contains the JSON metadata for the struct -// [WaitingRoomStatusGetResponse] -type waitingRoomStatusGetResponseJSON struct { - EstimatedQueuedUsers apijson.Field - EstimatedTotalActiveUsers apijson.Field - EventID apijson.Field - MaxEstimatedTimeMinutes apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomStatusGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomStatusGetResponseJSON) RawJSON() string { - return r.raw -} - -type WaitingRoomStatusGetResponseStatus string - -const ( - WaitingRoomStatusGetResponseStatusEventPrequeueing WaitingRoomStatusGetResponseStatus = "event_prequeueing" - WaitingRoomStatusGetResponseStatusNotQueueing WaitingRoomStatusGetResponseStatus = "not_queueing" - WaitingRoomStatusGetResponseStatusQueueing WaitingRoomStatusGetResponseStatus = "queueing" -) - -type WaitingRoomStatusGetResponseEnvelope struct { - Result WaitingRoomStatusGetResponse `json:"result,required"` - JSON waitingRoomStatusGetResponseEnvelopeJSON `json:"-"` -} - -// waitingRoomStatusGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [WaitingRoomStatusGetResponseEnvelope] -type waitingRoomStatusGetResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WaitingRoomStatusGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r waitingRoomStatusGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} diff --git a/waitingroomstatus_test.go b/waitingroomstatus_test.go deleted file mode 100644 index a74d94de52c..00000000000 --- a/waitingroomstatus_test.go +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWaitingRoomStatusGet(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("user@example.com"), - ) - _, err := client.WaitingRooms.Statuses.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "699d98642c564d2e855e9661899b7252", - ) - 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/warp_connector/aliases.go b/warp_connector/aliases.go new file mode 100644 index 00000000000..02aa95c5787 --- /dev/null +++ b/warp_connector/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package warp_connector + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/warpconnector.go b/warp_connector/warpconnector.go similarity index 97% rename from warpconnector.go rename to warp_connector/warpconnector.go index 947f62e42db..605eb794e6c 100644 --- a/warpconnector.go +++ b/warp_connector/warpconnector.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package warp_connector import ( "context" @@ -128,10 +128,10 @@ func (r *WARPConnectorService) Token(ctx context.Context, tunnelID string, query // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. // -// Union satisfied by [WARPConnectorNewResponseTunnelCfdTunnel] or -// [WARPConnectorNewResponseTunnelWARPConnectorTunnel]. +// Union satisfied by [warp_connector.WARPConnectorNewResponseTunnelCfdTunnel] or +// [warp_connector.WARPConnectorNewResponseTunnelWARPConnectorTunnel]. type WARPConnectorNewResponse interface { - implementsWARPConnectorNewResponse() + implementsWARPConnectorWARPConnectorNewResponse() } func init() { @@ -212,7 +212,7 @@ func (r warpConnectorNewResponseTunnelCfdTunnelJSON) RawJSON() string { return r.raw } -func (r WARPConnectorNewResponseTunnelCfdTunnel) implementsWARPConnectorNewResponse() {} +func (r WARPConnectorNewResponseTunnelCfdTunnel) implementsWARPConnectorWARPConnectorNewResponse() {} type WARPConnectorNewResponseTunnelCfdTunnelConnection struct { // UUID of the Cloudflare Tunnel connection. @@ -330,7 +330,8 @@ func (r warpConnectorNewResponseTunnelWARPConnectorTunnelJSON) RawJSON() string return r.raw } -func (r WARPConnectorNewResponseTunnelWARPConnectorTunnel) implementsWARPConnectorNewResponse() {} +func (r WARPConnectorNewResponseTunnelWARPConnectorTunnel) implementsWARPConnectorWARPConnectorNewResponse() { +} type WARPConnectorNewResponseTunnelWARPConnectorTunnelConnection struct { // UUID of the Cloudflare Tunnel connection. @@ -392,10 +393,10 @@ const ( // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. // -// Union satisfied by [WARPConnectorListResponseTunnelCfdTunnel] or -// [WARPConnectorListResponseTunnelWARPConnectorTunnel]. +// Union satisfied by [warp_connector.WARPConnectorListResponseTunnelCfdTunnel] or +// [warp_connector.WARPConnectorListResponseTunnelWARPConnectorTunnel]. type WARPConnectorListResponse interface { - implementsWARPConnectorListResponse() + implementsWARPConnectorWARPConnectorListResponse() } func init() { @@ -476,7 +477,8 @@ func (r warpConnectorListResponseTunnelCfdTunnelJSON) RawJSON() string { return r.raw } -func (r WARPConnectorListResponseTunnelCfdTunnel) implementsWARPConnectorListResponse() {} +func (r WARPConnectorListResponseTunnelCfdTunnel) implementsWARPConnectorWARPConnectorListResponse() { +} type WARPConnectorListResponseTunnelCfdTunnelConnection struct { // UUID of the Cloudflare Tunnel connection. @@ -594,7 +596,8 @@ func (r warpConnectorListResponseTunnelWARPConnectorTunnelJSON) RawJSON() string return r.raw } -func (r WARPConnectorListResponseTunnelWARPConnectorTunnel) implementsWARPConnectorListResponse() {} +func (r WARPConnectorListResponseTunnelWARPConnectorTunnel) implementsWARPConnectorWARPConnectorListResponse() { +} type WARPConnectorListResponseTunnelWARPConnectorTunnelConnection struct { // UUID of the Cloudflare Tunnel connection. @@ -656,10 +659,10 @@ const ( // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. // -// Union satisfied by [WARPConnectorDeleteResponseTunnelCfdTunnel] or -// [WARPConnectorDeleteResponseTunnelWARPConnectorTunnel]. +// Union satisfied by [warp_connector.WARPConnectorDeleteResponseTunnelCfdTunnel] +// or [warp_connector.WARPConnectorDeleteResponseTunnelWARPConnectorTunnel]. type WARPConnectorDeleteResponse interface { - implementsWARPConnectorDeleteResponse() + implementsWARPConnectorWARPConnectorDeleteResponse() } func init() { @@ -740,7 +743,8 @@ func (r warpConnectorDeleteResponseTunnelCfdTunnelJSON) RawJSON() string { return r.raw } -func (r WARPConnectorDeleteResponseTunnelCfdTunnel) implementsWARPConnectorDeleteResponse() {} +func (r WARPConnectorDeleteResponseTunnelCfdTunnel) implementsWARPConnectorWARPConnectorDeleteResponse() { +} type WARPConnectorDeleteResponseTunnelCfdTunnelConnection struct { // UUID of the Cloudflare Tunnel connection. @@ -858,7 +862,7 @@ func (r warpConnectorDeleteResponseTunnelWARPConnectorTunnelJSON) RawJSON() stri return r.raw } -func (r WARPConnectorDeleteResponseTunnelWARPConnectorTunnel) implementsWARPConnectorDeleteResponse() { +func (r WARPConnectorDeleteResponseTunnelWARPConnectorTunnel) implementsWARPConnectorWARPConnectorDeleteResponse() { } type WARPConnectorDeleteResponseTunnelWARPConnectorTunnelConnection struct { @@ -921,10 +925,10 @@ const ( // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. // -// Union satisfied by [WARPConnectorEditResponseTunnelCfdTunnel] or -// [WARPConnectorEditResponseTunnelWARPConnectorTunnel]. +// Union satisfied by [warp_connector.WARPConnectorEditResponseTunnelCfdTunnel] or +// [warp_connector.WARPConnectorEditResponseTunnelWARPConnectorTunnel]. type WARPConnectorEditResponse interface { - implementsWARPConnectorEditResponse() + implementsWARPConnectorWARPConnectorEditResponse() } func init() { @@ -1005,7 +1009,8 @@ func (r warpConnectorEditResponseTunnelCfdTunnelJSON) RawJSON() string { return r.raw } -func (r WARPConnectorEditResponseTunnelCfdTunnel) implementsWARPConnectorEditResponse() {} +func (r WARPConnectorEditResponseTunnelCfdTunnel) implementsWARPConnectorWARPConnectorEditResponse() { +} type WARPConnectorEditResponseTunnelCfdTunnelConnection struct { // UUID of the Cloudflare Tunnel connection. @@ -1123,7 +1128,8 @@ func (r warpConnectorEditResponseTunnelWARPConnectorTunnelJSON) RawJSON() string return r.raw } -func (r WARPConnectorEditResponseTunnelWARPConnectorTunnel) implementsWARPConnectorEditResponse() {} +func (r WARPConnectorEditResponseTunnelWARPConnectorTunnel) implementsWARPConnectorWARPConnectorEditResponse() { +} type WARPConnectorEditResponseTunnelWARPConnectorTunnelConnection struct { // UUID of the Cloudflare Tunnel connection. @@ -1185,10 +1191,10 @@ const ( // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. // -// Union satisfied by [WARPConnectorGetResponseTunnelCfdTunnel] or -// [WARPConnectorGetResponseTunnelWARPConnectorTunnel]. +// Union satisfied by [warp_connector.WARPConnectorGetResponseTunnelCfdTunnel] or +// [warp_connector.WARPConnectorGetResponseTunnelWARPConnectorTunnel]. type WARPConnectorGetResponse interface { - implementsWARPConnectorGetResponse() + implementsWARPConnectorWARPConnectorGetResponse() } func init() { @@ -1269,7 +1275,7 @@ func (r warpConnectorGetResponseTunnelCfdTunnelJSON) RawJSON() string { return r.raw } -func (r WARPConnectorGetResponseTunnelCfdTunnel) implementsWARPConnectorGetResponse() {} +func (r WARPConnectorGetResponseTunnelCfdTunnel) implementsWARPConnectorWARPConnectorGetResponse() {} type WARPConnectorGetResponseTunnelCfdTunnelConnection struct { // UUID of the Cloudflare Tunnel connection. @@ -1387,7 +1393,8 @@ func (r warpConnectorGetResponseTunnelWARPConnectorTunnelJSON) RawJSON() string return r.raw } -func (r WARPConnectorGetResponseTunnelWARPConnectorTunnel) implementsWARPConnectorGetResponse() {} +func (r WARPConnectorGetResponseTunnelWARPConnectorTunnel) implementsWARPConnectorWARPConnectorGetResponse() { +} type WARPConnectorGetResponseTunnelWARPConnectorTunnelConnection struct { // UUID of the Cloudflare Tunnel connection. @@ -1447,10 +1454,10 @@ const ( WARPConnectorGetResponseTunnelWARPConnectorTunnelTunTypeCni WARPConnectorGetResponseTunnelWARPConnectorTunnelTunType = "cni" ) -// Union satisfied by [WARPConnectorTokenResponseUnknown], -// [WARPConnectorTokenResponseArray] or [shared.UnionString]. +// Union satisfied by [warp_connector.WARPConnectorTokenResponseUnknown], +// [warp_connector.WARPConnectorTokenResponseArray] or [shared.UnionString]. type WARPConnectorTokenResponse interface { - ImplementsWARPConnectorTokenResponse() + ImplementsWARPConnectorWARPConnectorTokenResponse() } func init() { @@ -1470,7 +1477,7 @@ func init() { type WARPConnectorTokenResponseArray []interface{} -func (r WARPConnectorTokenResponseArray) ImplementsWARPConnectorTokenResponse() {} +func (r WARPConnectorTokenResponseArray) ImplementsWARPConnectorWARPConnectorTokenResponse() {} type WARPConnectorNewParams struct { // Cloudflare account ID diff --git a/warpconnector_test.go b/warp_connector/warpconnector_test.go similarity index 92% rename from warpconnector_test.go rename to warp_connector/warpconnector_test.go index a7127197880..f3f7a727e22 100644 --- a/warpconnector_test.go +++ b/warp_connector/warpconnector_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package warp_connector_test import ( "context" @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/warp_connector" ) func TestWARPConnectorNew(t *testing.T) { @@ -28,7 +29,7 @@ func TestWARPConnectorNew(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.WARPConnector.New(context.TODO(), cloudflare.WARPConnectorNewParams{ + _, err := client.WARPConnector.New(context.TODO(), warp_connector.WARPConnectorNewParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), Name: cloudflare.F("blog"), }) @@ -55,7 +56,7 @@ func TestWARPConnectorListWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.WARPConnector.List(context.TODO(), cloudflare.WARPConnectorListParams{ + _, err := client.WARPConnector.List(context.TODO(), warp_connector.WARPConnectorListParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), ExcludePrefix: cloudflare.F("vpc1-"), ExistedAt: cloudflare.F(time.Now()), @@ -93,7 +94,7 @@ func TestWARPConnectorDelete(t *testing.T) { _, err := client.WARPConnector.Delete( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", - cloudflare.WARPConnectorDeleteParams{ + warp_connector.WARPConnectorDeleteParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), Body: cloudflare.F[any](map[string]interface{}{}), }, @@ -124,7 +125,7 @@ func TestWARPConnectorEditWithOptionalParams(t *testing.T) { _, err := client.WARPConnector.Edit( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", - cloudflare.WARPConnectorEditParams{ + warp_connector.WARPConnectorEditParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), Name: cloudflare.F("blog"), TunnelSecret: cloudflare.F("AQIDBAUGBwgBAgMEBQYHCAECAwQFBgcIAQIDBAUGBwg="), @@ -156,7 +157,7 @@ func TestWARPConnectorGet(t *testing.T) { _, err := client.WARPConnector.Get( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", - cloudflare.WARPConnectorGetParams{ + warp_connector.WARPConnectorGetParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) @@ -186,7 +187,7 @@ func TestWARPConnectorToken(t *testing.T) { _, err := client.WARPConnector.Token( context.TODO(), "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", - cloudflare.WARPConnectorTokenParams{ + warp_connector.WARPConnectorTokenParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), }, ) diff --git a/web3/aliases.go b/web3/aliases.go new file mode 100644 index 00000000000..87c98f4f38e --- /dev/null +++ b/web3/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package web3 + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/web3/hostname.go b/web3/hostname.go new file mode 100644 index 00000000000..d65a624ad1c --- /dev/null +++ b/web3/hostname.go @@ -0,0 +1,652 @@ +// File generated from our OpenAPI spec by Stainless. + +package web3 + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HostnameService 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 [NewHostnameService] method instead. +type HostnameService struct { + Options []option.RequestOption + IPFSUniversalPaths *HostnameIPFSUniversalPathService +} + +// NewHostnameService 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 NewHostnameService(opts ...option.RequestOption) (r *HostnameService) { + r = &HostnameService{} + r.Options = opts + r.IPFSUniversalPaths = NewHostnameIPFSUniversalPathService(opts...) + return +} + +// Create Web3 Hostname +func (r *HostnameService) New(ctx context.Context, zoneIdentifier string, body HostnameNewParams, opts ...option.RequestOption) (res *DwebConfigWeb3Hostname, err error) { + opts = append(r.Options[:], opts...) + var env HostnameNewResponseEnvelope + path := fmt.Sprintf("zones/%s/web3/hostnames", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List Web3 Hostnames +func (r *HostnameService) List(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *[]DwebConfigWeb3Hostname, err error) { + opts = append(r.Options[:], opts...) + var env HostnameListResponseEnvelope + path := fmt.Sprintf("zones/%s/web3/hostnames", zoneIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete Web3 Hostname +func (r *HostnameService) Delete(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *HostnameDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env HostnameDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/web3/hostnames/%s", zoneIdentifier, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Edit Web3 Hostname +func (r *HostnameService) Edit(ctx context.Context, zoneIdentifier string, identifier string, body HostnameEditParams, opts ...option.RequestOption) (res *DwebConfigWeb3Hostname, err error) { + opts = append(r.Options[:], opts...) + var env HostnameEditResponseEnvelope + path := fmt.Sprintf("zones/%s/web3/hostnames/%s", zoneIdentifier, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Web3 Hostname Details +func (r *HostnameService) Get(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *DwebConfigWeb3Hostname, err error) { + opts = append(r.Options[:], opts...) + var env HostnameGetResponseEnvelope + path := fmt.Sprintf("zones/%s/web3/hostnames/%s", zoneIdentifier, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DwebConfigWeb3Hostname struct { + // Identifier + ID string `json:"id"` + CreatedOn time.Time `json:"created_on" format:"date-time"` + // An optional description of the hostname. + Description string `json:"description"` + // DNSLink value used if the target is ipfs. + Dnslink string `json:"dnslink"` + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // The hostname that will point to the target gateway via CNAME. + Name string `json:"name"` + // Status of the hostname's activation. + Status DwebConfigWeb3HostnameStatus `json:"status"` + // Target gateway of the hostname. + Target DwebConfigWeb3HostnameTarget `json:"target"` + JSON dwebConfigWeb3HostnameJSON `json:"-"` +} + +// dwebConfigWeb3HostnameJSON contains the JSON metadata for the struct +// [DwebConfigWeb3Hostname] +type dwebConfigWeb3HostnameJSON struct { + ID apijson.Field + CreatedOn apijson.Field + Description apijson.Field + Dnslink apijson.Field + ModifiedOn apijson.Field + Name apijson.Field + Status apijson.Field + Target apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DwebConfigWeb3Hostname) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dwebConfigWeb3HostnameJSON) RawJSON() string { + return r.raw +} + +// Status of the hostname's activation. +type DwebConfigWeb3HostnameStatus string + +const ( + DwebConfigWeb3HostnameStatusActive DwebConfigWeb3HostnameStatus = "active" + DwebConfigWeb3HostnameStatusPending DwebConfigWeb3HostnameStatus = "pending" + DwebConfigWeb3HostnameStatusDeleting DwebConfigWeb3HostnameStatus = "deleting" + DwebConfigWeb3HostnameStatusError DwebConfigWeb3HostnameStatus = "error" +) + +// Target gateway of the hostname. +type DwebConfigWeb3HostnameTarget string + +const ( + DwebConfigWeb3HostnameTargetEthereum DwebConfigWeb3HostnameTarget = "ethereum" + DwebConfigWeb3HostnameTargetIPFS DwebConfigWeb3HostnameTarget = "ipfs" + DwebConfigWeb3HostnameTargetIPFSUniversalPath DwebConfigWeb3HostnameTarget = "ipfs_universal_path" +) + +type HostnameDeleteResponse struct { + // Identifier + ID string `json:"id,required"` + JSON hostnameDeleteResponseJSON `json:"-"` +} + +// hostnameDeleteResponseJSON contains the JSON metadata for the struct +// [HostnameDeleteResponse] +type hostnameDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type HostnameNewParams struct { + // Target gateway of the hostname. + Target param.Field[HostnameNewParamsTarget] `json:"target,required"` + // An optional description of the hostname. + Description param.Field[string] `json:"description"` + // DNSLink value used if the target is ipfs. + Dnslink param.Field[string] `json:"dnslink"` +} + +func (r HostnameNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Target gateway of the hostname. +type HostnameNewParamsTarget string + +const ( + HostnameNewParamsTargetEthereum HostnameNewParamsTarget = "ethereum" + HostnameNewParamsTargetIPFS HostnameNewParamsTarget = "ipfs" + HostnameNewParamsTargetIPFSUniversalPath HostnameNewParamsTarget = "ipfs_universal_path" +) + +type HostnameNewResponseEnvelope struct { + Errors []HostnameNewResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameNewResponseEnvelopeMessages `json:"messages,required"` + Result DwebConfigWeb3Hostname `json:"result,required"` + // Whether the API call was successful + Success HostnameNewResponseEnvelopeSuccess `json:"success,required"` + JSON hostnameNewResponseEnvelopeJSON `json:"-"` +} + +// hostnameNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [HostnameNewResponseEnvelope] +type hostnameNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [HostnameNewResponseEnvelopeErrors] +type hostnameNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [HostnameNewResponseEnvelopeMessages] +type hostnameNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameNewResponseEnvelopeSuccess bool + +const ( + HostnameNewResponseEnvelopeSuccessTrue HostnameNewResponseEnvelopeSuccess = true +) + +type HostnameListResponseEnvelope struct { + Errors []HostnameListResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameListResponseEnvelopeMessages `json:"messages,required"` + Result []DwebConfigWeb3Hostname `json:"result,required,nullable"` + // Whether the API call was successful + Success HostnameListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo HostnameListResponseEnvelopeResultInfo `json:"result_info"` + JSON hostnameListResponseEnvelopeJSON `json:"-"` +} + +// hostnameListResponseEnvelopeJSON contains the JSON metadata for the struct +// [HostnameListResponseEnvelope] +type hostnameListResponseEnvelopeJSON 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 *HostnameListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameListResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [HostnameListResponseEnvelopeErrors] +type hostnameListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameListResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [HostnameListResponseEnvelopeMessages] +type hostnameListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameListResponseEnvelopeSuccess bool + +const ( + HostnameListResponseEnvelopeSuccessTrue HostnameListResponseEnvelopeSuccess = true +) + +type HostnameListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON hostnameListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// hostnameListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [HostnameListResponseEnvelopeResultInfo] +type hostnameListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type HostnameDeleteResponseEnvelope struct { + Errors []HostnameDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameDeleteResponseEnvelopeMessages `json:"messages,required"` + Result HostnameDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success HostnameDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON hostnameDeleteResponseEnvelopeJSON `json:"-"` +} + +// hostnameDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [HostnameDeleteResponseEnvelope] +type hostnameDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [HostnameDeleteResponseEnvelopeErrors] +type hostnameDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [HostnameDeleteResponseEnvelopeMessages] +type hostnameDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameDeleteResponseEnvelopeSuccess bool + +const ( + HostnameDeleteResponseEnvelopeSuccessTrue HostnameDeleteResponseEnvelopeSuccess = true +) + +type HostnameEditParams struct { + // An optional description of the hostname. + Description param.Field[string] `json:"description"` + // DNSLink value used if the target is ipfs. + Dnslink param.Field[string] `json:"dnslink"` +} + +func (r HostnameEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type HostnameEditResponseEnvelope struct { + Errors []HostnameEditResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameEditResponseEnvelopeMessages `json:"messages,required"` + Result DwebConfigWeb3Hostname `json:"result,required"` + // Whether the API call was successful + Success HostnameEditResponseEnvelopeSuccess `json:"success,required"` + JSON hostnameEditResponseEnvelopeJSON `json:"-"` +} + +// hostnameEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [HostnameEditResponseEnvelope] +type hostnameEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [HostnameEditResponseEnvelopeErrors] +type hostnameEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [HostnameEditResponseEnvelopeMessages] +type hostnameEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameEditResponseEnvelopeSuccess bool + +const ( + HostnameEditResponseEnvelopeSuccessTrue HostnameEditResponseEnvelopeSuccess = true +) + +type HostnameGetResponseEnvelope struct { + Errors []HostnameGetResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameGetResponseEnvelopeMessages `json:"messages,required"` + Result DwebConfigWeb3Hostname `json:"result,required"` + // Whether the API call was successful + Success HostnameGetResponseEnvelopeSuccess `json:"success,required"` + JSON hostnameGetResponseEnvelopeJSON `json:"-"` +} + +// hostnameGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [HostnameGetResponseEnvelope] +type hostnameGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [HostnameGetResponseEnvelopeErrors] +type hostnameGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [HostnameGetResponseEnvelopeMessages] +type hostnameGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameGetResponseEnvelopeSuccess bool + +const ( + HostnameGetResponseEnvelopeSuccessTrue HostnameGetResponseEnvelopeSuccess = true +) diff --git a/web3/hostname_test.go b/web3/hostname_test.go new file mode 100644 index 00000000000..a628f91b770 --- /dev/null +++ b/web3/hostname_test.go @@ -0,0 +1,159 @@ +// File generated from our OpenAPI spec by Stainless. + +package web3_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/web3" +) + +func TestHostnameNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Web3.Hostnames.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + web3.HostnameNewParams{ + Target: cloudflare.F(web3.HostnameNewParamsTargetIPFS), + Description: cloudflare.F("This is my IPFS gateway."), + Dnslink: cloudflare.F("/ipns/onboarding.ipfs.cloudflare.com"), + }, + ) + 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 TestHostnameList(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("user@example.com"), + ) + _, err := client.Web3.Hostnames.List(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()) + } +} + +func TestHostnameDelete(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("user@example.com"), + ) + _, err := client.Web3.Hostnames.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "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()) + } +} + +func TestHostnameEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Web3.Hostnames.Edit( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + web3.HostnameEditParams{ + Description: cloudflare.F("This is my IPFS gateway."), + Dnslink: cloudflare.F("/ipns/onboarding.ipfs.cloudflare.com"), + }, + ) + 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 TestHostnameGet(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("user@example.com"), + ) + _, err := client.Web3.Hostnames.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "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/web3/hostnameipfsuniversalpath.go b/web3/hostnameipfsuniversalpath.go new file mode 100644 index 00000000000..61f21b3c741 --- /dev/null +++ b/web3/hostnameipfsuniversalpath.go @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package web3 + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// HostnameIPFSUniversalPathService 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 +// [NewHostnameIPFSUniversalPathService] method instead. +type HostnameIPFSUniversalPathService struct { + Options []option.RequestOption + ContentLists *HostnameIPFSUniversalPathContentListService +} + +// NewHostnameIPFSUniversalPathService 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 NewHostnameIPFSUniversalPathService(opts ...option.RequestOption) (r *HostnameIPFSUniversalPathService) { + r = &HostnameIPFSUniversalPathService{} + r.Options = opts + r.ContentLists = NewHostnameIPFSUniversalPathContentListService(opts...) + return +} diff --git a/web3/hostnameipfsuniversalpathcontentlist.go b/web3/hostnameipfsuniversalpathcontentlist.go new file mode 100644 index 00000000000..5e8725cce5e --- /dev/null +++ b/web3/hostnameipfsuniversalpathcontentlist.go @@ -0,0 +1,276 @@ +// File generated from our OpenAPI spec by Stainless. + +package web3 + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HostnameIPFSUniversalPathContentListService 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 +// [NewHostnameIPFSUniversalPathContentListService] method instead. +type HostnameIPFSUniversalPathContentListService struct { + Options []option.RequestOption + Entries *HostnameIPFSUniversalPathContentListEntryService +} + +// NewHostnameIPFSUniversalPathContentListService 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 NewHostnameIPFSUniversalPathContentListService(opts ...option.RequestOption) (r *HostnameIPFSUniversalPathContentListService) { + r = &HostnameIPFSUniversalPathContentListService{} + r.Options = opts + r.Entries = NewHostnameIPFSUniversalPathContentListEntryService(opts...) + return +} + +// Update IPFS Universal Path Gateway Content List +func (r *HostnameIPFSUniversalPathContentListService) Update(ctx context.Context, zoneIdentifier string, identifier string, body HostnameIPFSUniversalPathContentListUpdateParams, opts ...option.RequestOption) (res *DwebConfigContentListDetails, err error) { + opts = append(r.Options[:], opts...) + var env HostnameIPFSUniversalPathContentListUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list", zoneIdentifier, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// IPFS Universal Path Gateway Content List Details +func (r *HostnameIPFSUniversalPathContentListService) Get(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *DwebConfigContentListDetails, err error) { + opts = append(r.Options[:], opts...) + var env HostnameIPFSUniversalPathContentListGetResponseEnvelope + path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list", zoneIdentifier, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DwebConfigContentListDetails struct { + // Behavior of the content list. + Action DwebConfigContentListDetailsAction `json:"action"` + JSON dwebConfigContentListDetailsJSON `json:"-"` +} + +// dwebConfigContentListDetailsJSON contains the JSON metadata for the struct +// [DwebConfigContentListDetails] +type dwebConfigContentListDetailsJSON struct { + Action apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DwebConfigContentListDetails) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dwebConfigContentListDetailsJSON) RawJSON() string { + return r.raw +} + +// Behavior of the content list. +type DwebConfigContentListDetailsAction string + +const ( + DwebConfigContentListDetailsActionBlock DwebConfigContentListDetailsAction = "block" +) + +type HostnameIPFSUniversalPathContentListUpdateParams struct { + // Behavior of the content list. + Action param.Field[HostnameIPFSUniversalPathContentListUpdateParamsAction] `json:"action,required"` + // Content list entries. + Entries param.Field[[]DwebConfigContentListEntryParam] `json:"entries,required"` +} + +func (r HostnameIPFSUniversalPathContentListUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Behavior of the content list. +type HostnameIPFSUniversalPathContentListUpdateParamsAction string + +const ( + HostnameIPFSUniversalPathContentListUpdateParamsActionBlock HostnameIPFSUniversalPathContentListUpdateParamsAction = "block" +) + +type HostnameIPFSUniversalPathContentListUpdateResponseEnvelope struct { + Errors []HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessages `json:"messages,required"` + Result DwebConfigContentListDetails `json:"result,required"` + // Whether the API call was successful + Success HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeJSON contains the JSON +// metadata for the struct +// [HostnameIPFSUniversalPathContentListUpdateResponseEnvelope] +type hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrorsJSON contains +// the JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrors] +type hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessagesJSON contains +// the JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessages] +type hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeSuccess bool + +const ( + HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeSuccessTrue HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeSuccess = true +) + +type HostnameIPFSUniversalPathContentListGetResponseEnvelope struct { + Errors []HostnameIPFSUniversalPathContentListGetResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameIPFSUniversalPathContentListGetResponseEnvelopeMessages `json:"messages,required"` + Result DwebConfigContentListDetails `json:"result,required"` + // Whether the API call was successful + Success HostnameIPFSUniversalPathContentListGetResponseEnvelopeSuccess `json:"success,required"` + JSON hostnameIPFSUniversalPathContentListGetResponseEnvelopeJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListGetResponseEnvelopeJSON contains the JSON +// metadata for the struct +// [HostnameIPFSUniversalPathContentListGetResponseEnvelope] +type hostnameIPFSUniversalPathContentListGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameIPFSUniversalPathContentListGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameIPFSUniversalPathContentListGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListGetResponseEnvelopeErrorsJSON contains the +// JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListGetResponseEnvelopeErrors] +type hostnameIPFSUniversalPathContentListGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameIPFSUniversalPathContentListGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameIPFSUniversalPathContentListGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListGetResponseEnvelopeMessagesJSON contains the +// JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListGetResponseEnvelopeMessages] +type hostnameIPFSUniversalPathContentListGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameIPFSUniversalPathContentListGetResponseEnvelopeSuccess bool + +const ( + HostnameIPFSUniversalPathContentListGetResponseEnvelopeSuccessTrue HostnameIPFSUniversalPathContentListGetResponseEnvelopeSuccess = true +) diff --git a/web3/hostnameipfsuniversalpathcontentlist_test.go b/web3/hostnameipfsuniversalpathcontentlist_test.go new file mode 100644 index 00000000000..07692afb7ed --- /dev/null +++ b/web3/hostnameipfsuniversalpathcontentlist_test.go @@ -0,0 +1,87 @@ +// File generated from our OpenAPI spec by Stainless. + +package web3_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/web3" +) + +func TestHostnameIPFSUniversalPathContentListUpdate(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("user@example.com"), + ) + _, err := client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + web3.HostnameIPFSUniversalPathContentListUpdateParams{ + Action: cloudflare.F(web3.HostnameIPFSUniversalPathContentListUpdateParamsActionBlock), + Entries: cloudflare.F([]web3.DwebConfigContentListEntryParam{{ + Content: cloudflare.F("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB"), + Description: cloudflare.F("this is my content list entry"), + Type: cloudflare.F(web3.DwebConfigContentListEntryTypeCid), + }, { + Content: cloudflare.F("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB"), + Description: cloudflare.F("this is my content list entry"), + Type: cloudflare.F(web3.DwebConfigContentListEntryTypeCid), + }, { + Content: cloudflare.F("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB"), + Description: cloudflare.F("this is my content list entry"), + Type: cloudflare.F(web3.DwebConfigContentListEntryTypeCid), + }}), + }, + ) + 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 TestHostnameIPFSUniversalPathContentListGet(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("user@example.com"), + ) + _, err := client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "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/web3/hostnameipfsuniversalpathcontentlistentry.go b/web3/hostnameipfsuniversalpathcontentlistentry.go new file mode 100644 index 00000000000..2e7bc2211c8 --- /dev/null +++ b/web3/hostnameipfsuniversalpathcontentlistentry.go @@ -0,0 +1,701 @@ +// File generated from our OpenAPI spec by Stainless. + +package web3 + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HostnameIPFSUniversalPathContentListEntryService 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 [NewHostnameIPFSUniversalPathContentListEntryService] method instead. +type HostnameIPFSUniversalPathContentListEntryService struct { + Options []option.RequestOption +} + +// NewHostnameIPFSUniversalPathContentListEntryService 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 NewHostnameIPFSUniversalPathContentListEntryService(opts ...option.RequestOption) (r *HostnameIPFSUniversalPathContentListEntryService) { + r = &HostnameIPFSUniversalPathContentListEntryService{} + r.Options = opts + return +} + +// Create IPFS Universal Path Gateway Content List Entry +func (r *HostnameIPFSUniversalPathContentListEntryService) New(ctx context.Context, zoneIdentifier string, identifier string, body HostnameIPFSUniversalPathContentListEntryNewParams, opts ...option.RequestOption) (res *DwebConfigContentListEntry, err error) { + opts = append(r.Options[:], opts...) + var env HostnameIPFSUniversalPathContentListEntryNewResponseEnvelope + path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list/entries", zoneIdentifier, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Edit IPFS Universal Path Gateway Content List Entry +func (r *HostnameIPFSUniversalPathContentListEntryService) Update(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, body HostnameIPFSUniversalPathContentListEntryUpdateParams, opts ...option.RequestOption) (res *DwebConfigContentListEntry, err error) { + opts = append(r.Options[:], opts...) + var env HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list/entries/%s", zoneIdentifier, identifier, contentListEntryIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List IPFS Universal Path Gateway Content List Entries +func (r *HostnameIPFSUniversalPathContentListEntryService) List(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *HostnameIPFSUniversalPathContentListEntryListResponse, err error) { + opts = append(r.Options[:], opts...) + var env HostnameIPFSUniversalPathContentListEntryListResponseEnvelope + path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list/entries", zoneIdentifier, identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete IPFS Universal Path Gateway Content List Entry +func (r *HostnameIPFSUniversalPathContentListEntryService) Delete(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, opts ...option.RequestOption) (res *HostnameIPFSUniversalPathContentListEntryDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list/entries/%s", zoneIdentifier, identifier, contentListEntryIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// IPFS Universal Path Gateway Content List Entry Details +func (r *HostnameIPFSUniversalPathContentListEntryService) Get(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, opts ...option.RequestOption) (res *DwebConfigContentListEntry, err error) { + opts = append(r.Options[:], opts...) + var env HostnameIPFSUniversalPathContentListEntryGetResponseEnvelope + path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list/entries/%s", zoneIdentifier, identifier, contentListEntryIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Content list entry to be blocked. +type DwebConfigContentListEntry struct { + // Identifier + ID string `json:"id"` + // CID or content path of content to block. + Content string `json:"content"` + CreatedOn time.Time `json:"created_on" format:"date-time"` + // An optional description of the content list entry. + Description string `json:"description"` + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Type of content list entry to block. + Type DwebConfigContentListEntryType `json:"type"` + JSON dwebConfigContentListEntryJSON `json:"-"` +} + +// dwebConfigContentListEntryJSON contains the JSON metadata for the struct +// [DwebConfigContentListEntry] +type dwebConfigContentListEntryJSON struct { + ID apijson.Field + Content apijson.Field + CreatedOn apijson.Field + Description apijson.Field + ModifiedOn apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DwebConfigContentListEntry) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dwebConfigContentListEntryJSON) RawJSON() string { + return r.raw +} + +// Type of content list entry to block. +type DwebConfigContentListEntryType string + +const ( + DwebConfigContentListEntryTypeCid DwebConfigContentListEntryType = "cid" + DwebConfigContentListEntryTypeContentPath DwebConfigContentListEntryType = "content_path" +) + +// Content list entry to be blocked. +type DwebConfigContentListEntryParam struct { + // CID or content path of content to block. + Content param.Field[string] `json:"content"` + // An optional description of the content list entry. + Description param.Field[string] `json:"description"` + // Type of content list entry to block. + Type param.Field[DwebConfigContentListEntryType] `json:"type"` +} + +func (r DwebConfigContentListEntryParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type HostnameIPFSUniversalPathContentListEntryListResponse struct { + // Content list entries. + Entries []DwebConfigContentListEntry `json:"entries"` + JSON hostnameIPFSUniversalPathContentListEntryListResponseJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryListResponseJSON contains the JSON +// metadata for the struct [HostnameIPFSUniversalPathContentListEntryListResponse] +type hostnameIPFSUniversalPathContentListEntryListResponseJSON struct { + Entries apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryListResponseJSON) RawJSON() string { + return r.raw +} + +type HostnameIPFSUniversalPathContentListEntryDeleteResponse struct { + // Identifier + ID string `json:"id,required"` + JSON hostnameIPFSUniversalPathContentListEntryDeleteResponseJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryDeleteResponseJSON contains the JSON +// metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryDeleteResponse] +type hostnameIPFSUniversalPathContentListEntryDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type HostnameIPFSUniversalPathContentListEntryNewParams struct { + // CID or content path of content to block. + Content param.Field[string] `json:"content,required"` + // Type of content list entry to block. + Type param.Field[HostnameIPFSUniversalPathContentListEntryNewParamsType] `json:"type,required"` + // An optional description of the content list entry. + Description param.Field[string] `json:"description"` +} + +func (r HostnameIPFSUniversalPathContentListEntryNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Type of content list entry to block. +type HostnameIPFSUniversalPathContentListEntryNewParamsType string + +const ( + HostnameIPFSUniversalPathContentListEntryNewParamsTypeCid HostnameIPFSUniversalPathContentListEntryNewParamsType = "cid" + HostnameIPFSUniversalPathContentListEntryNewParamsTypeContentPath HostnameIPFSUniversalPathContentListEntryNewParamsType = "content_path" +) + +type HostnameIPFSUniversalPathContentListEntryNewResponseEnvelope struct { + Errors []HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessages `json:"messages,required"` + // Content list entry to be blocked. + Result DwebConfigContentListEntry `json:"result,required"` + // Whether the API call was successful + Success HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeSuccess `json:"success,required"` + JSON hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeJSON contains the +// JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryNewResponseEnvelope] +type hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrorsJSON contains +// the JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrors] +type hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessagesJSON +// contains the JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessages] +type hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeSuccess bool + +const ( + HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeSuccessTrue HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeSuccess = true +) + +type HostnameIPFSUniversalPathContentListEntryUpdateParams struct { + // CID or content path of content to block. + Content param.Field[string] `json:"content,required"` + // Type of content list entry to block. + Type param.Field[HostnameIPFSUniversalPathContentListEntryUpdateParamsType] `json:"type,required"` + // An optional description of the content list entry. + Description param.Field[string] `json:"description"` +} + +func (r HostnameIPFSUniversalPathContentListEntryUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Type of content list entry to block. +type HostnameIPFSUniversalPathContentListEntryUpdateParamsType string + +const ( + HostnameIPFSUniversalPathContentListEntryUpdateParamsTypeCid HostnameIPFSUniversalPathContentListEntryUpdateParamsType = "cid" + HostnameIPFSUniversalPathContentListEntryUpdateParamsTypeContentPath HostnameIPFSUniversalPathContentListEntryUpdateParamsType = "content_path" +) + +type HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelope struct { + Errors []HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessages `json:"messages,required"` + // Content list entry to be blocked. + Result DwebConfigContentListEntry `json:"result,required"` + // Whether the API call was successful + Success HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeJSON contains the +// JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelope] +type hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrorsJSON +// contains the JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrors] +type hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessagesJSON +// contains the JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessages] +type hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeSuccess bool + +const ( + HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeSuccessTrue HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeSuccess = true +) + +type HostnameIPFSUniversalPathContentListEntryListResponseEnvelope struct { + Errors []HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessages `json:"messages,required"` + Result HostnameIPFSUniversalPathContentListEntryListResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeResultInfo `json:"result_info"` + JSON hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeJSON contains the +// JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryListResponseEnvelope] +type hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeJSON 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 *HostnameIPFSUniversalPathContentListEntryListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrorsJSON contains +// the JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrors] +type hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessagesJSON +// contains the JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessages] +type hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeSuccess bool + +const ( + HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeSuccessTrue HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeSuccess = true +) + +type HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeResultInfoJSON +// contains the JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeResultInfo] +type hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelope struct { + Errors []HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessages `json:"messages,required"` + Result HostnameIPFSUniversalPathContentListEntryDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeJSON contains the +// JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelope] +type hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrorsJSON +// contains the JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrors] +type hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessagesJSON +// contains the JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessages] +type hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeSuccess bool + +const ( + HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeSuccessTrue HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeSuccess = true +) + +type HostnameIPFSUniversalPathContentListEntryGetResponseEnvelope struct { + Errors []HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrors `json:"errors,required"` + Messages []HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessages `json:"messages,required"` + // Content list entry to be blocked. + Result DwebConfigContentListEntry `json:"result,required"` + // Whether the API call was successful + Success HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeSuccess `json:"success,required"` + JSON hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeJSON contains the +// JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryGetResponseEnvelope] +type hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrorsJSON contains +// the JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrors] +type hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessagesJSON +// contains the JSON metadata for the struct +// [HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessages] +type hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeSuccess bool + +const ( + HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeSuccessTrue HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeSuccess = true +) diff --git a/web3/hostnameipfsuniversalpathcontentlistentry_test.go b/web3/hostnameipfsuniversalpathcontentlistentry_test.go new file mode 100644 index 00000000000..5ab18469682 --- /dev/null +++ b/web3/hostnameipfsuniversalpathcontentlistentry_test.go @@ -0,0 +1,168 @@ +// File generated from our OpenAPI spec by Stainless. + +package web3_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/web3" +) + +func TestHostnameIPFSUniversalPathContentListEntryNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + web3.HostnameIPFSUniversalPathContentListEntryNewParams{ + Content: cloudflare.F("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB"), + Type: cloudflare.F(web3.HostnameIPFSUniversalPathContentListEntryNewParamsTypeCid), + Description: cloudflare.F("this is my content list entry"), + }, + ) + 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 TestHostnameIPFSUniversalPathContentListEntryUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + web3.HostnameIPFSUniversalPathContentListEntryUpdateParams{ + Content: cloudflare.F("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB"), + Type: cloudflare.F(web3.HostnameIPFSUniversalPathContentListEntryUpdateParamsTypeCid), + Description: cloudflare.F("this is my content list entry"), + }, + ) + 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 TestHostnameIPFSUniversalPathContentListEntryList(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("user@example.com"), + ) + _, err := client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "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()) + } +} + +func TestHostnameIPFSUniversalPathContentListEntryDelete(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("user@example.com"), + ) + _, err := client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + "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()) + } +} + +func TestHostnameIPFSUniversalPathContentListEntryGet(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("user@example.com"), + ) + _, err := client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "023e105f4ecef8ad9ca31a8372d0c353", + "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/web3.go b/web3/web3.go similarity index 89% rename from web3.go rename to web3/web3.go index 64c218a7fcb..2cde15ee07c 100644 --- a/web3.go +++ b/web3/web3.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package web3 import ( "github.com/cloudflare/cloudflare-go/option" @@ -12,7 +12,7 @@ import ( // directly, and instead use the [NewWeb3Service] method instead. type Web3Service struct { Options []option.RequestOption - Hostnames *Web3HostnameService + Hostnames *HostnameService } // NewWeb3Service generates a new service that applies the given options to each @@ -21,6 +21,6 @@ type Web3Service struct { func NewWeb3Service(opts ...option.RequestOption) (r *Web3Service) { r = &Web3Service{} r.Options = opts - r.Hostnames = NewWeb3HostnameService(opts...) + r.Hostnames = NewHostnameService(opts...) return } diff --git a/web3hostname.go b/web3hostname.go deleted file mode 100644 index 64e267a5f7c..00000000000 --- a/web3hostname.go +++ /dev/null @@ -1,833 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// Web3HostnameService 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 [NewWeb3HostnameService] method -// instead. -type Web3HostnameService struct { - Options []option.RequestOption - IPFSUniversalPaths *Web3HostnameIPFSUniversalPathService -} - -// NewWeb3HostnameService 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 NewWeb3HostnameService(opts ...option.RequestOption) (r *Web3HostnameService) { - r = &Web3HostnameService{} - r.Options = opts - r.IPFSUniversalPaths = NewWeb3HostnameIPFSUniversalPathService(opts...) - return -} - -// Create Web3 Hostname -func (r *Web3HostnameService) New(ctx context.Context, zoneIdentifier string, body Web3HostnameNewParams, opts ...option.RequestOption) (res *Web3HostnameNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env Web3HostnameNewResponseEnvelope - path := fmt.Sprintf("zones/%s/web3/hostnames", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List Web3 Hostnames -func (r *Web3HostnameService) List(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *[]Web3HostnameListResponse, err error) { - opts = append(r.Options[:], opts...) - var env Web3HostnameListResponseEnvelope - path := fmt.Sprintf("zones/%s/web3/hostnames", zoneIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete Web3 Hostname -func (r *Web3HostnameService) Delete(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *Web3HostnameDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env Web3HostnameDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/web3/hostnames/%s", zoneIdentifier, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Edit Web3 Hostname -func (r *Web3HostnameService) Edit(ctx context.Context, zoneIdentifier string, identifier string, body Web3HostnameEditParams, opts ...option.RequestOption) (res *Web3HostnameEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env Web3HostnameEditResponseEnvelope - path := fmt.Sprintf("zones/%s/web3/hostnames/%s", zoneIdentifier, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Web3 Hostname Details -func (r *Web3HostnameService) Get(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *Web3HostnameGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env Web3HostnameGetResponseEnvelope - path := fmt.Sprintf("zones/%s/web3/hostnames/%s", zoneIdentifier, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type Web3HostnameNewResponse struct { - // Identifier - ID string `json:"id"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // An optional description of the hostname. - Description string `json:"description"` - // DNSLink value used if the target is ipfs. - Dnslink string `json:"dnslink"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The hostname that will point to the target gateway via CNAME. - Name string `json:"name"` - // Status of the hostname's activation. - Status Web3HostnameNewResponseStatus `json:"status"` - // Target gateway of the hostname. - Target Web3HostnameNewResponseTarget `json:"target"` - JSON web3HostnameNewResponseJSON `json:"-"` -} - -// web3HostnameNewResponseJSON contains the JSON metadata for the struct -// [Web3HostnameNewResponse] -type web3HostnameNewResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Description apijson.Field - Dnslink apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Status apijson.Field - Target apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameNewResponseJSON) RawJSON() string { - return r.raw -} - -// Status of the hostname's activation. -type Web3HostnameNewResponseStatus string - -const ( - Web3HostnameNewResponseStatusActive Web3HostnameNewResponseStatus = "active" - Web3HostnameNewResponseStatusPending Web3HostnameNewResponseStatus = "pending" - Web3HostnameNewResponseStatusDeleting Web3HostnameNewResponseStatus = "deleting" - Web3HostnameNewResponseStatusError Web3HostnameNewResponseStatus = "error" -) - -// Target gateway of the hostname. -type Web3HostnameNewResponseTarget string - -const ( - Web3HostnameNewResponseTargetEthereum Web3HostnameNewResponseTarget = "ethereum" - Web3HostnameNewResponseTargetIPFS Web3HostnameNewResponseTarget = "ipfs" - Web3HostnameNewResponseTargetIPFSUniversalPath Web3HostnameNewResponseTarget = "ipfs_universal_path" -) - -type Web3HostnameListResponse struct { - // Identifier - ID string `json:"id"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // An optional description of the hostname. - Description string `json:"description"` - // DNSLink value used if the target is ipfs. - Dnslink string `json:"dnslink"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The hostname that will point to the target gateway via CNAME. - Name string `json:"name"` - // Status of the hostname's activation. - Status Web3HostnameListResponseStatus `json:"status"` - // Target gateway of the hostname. - Target Web3HostnameListResponseTarget `json:"target"` - JSON web3HostnameListResponseJSON `json:"-"` -} - -// web3HostnameListResponseJSON contains the JSON metadata for the struct -// [Web3HostnameListResponse] -type web3HostnameListResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Description apijson.Field - Dnslink apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Status apijson.Field - Target apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameListResponseJSON) RawJSON() string { - return r.raw -} - -// Status of the hostname's activation. -type Web3HostnameListResponseStatus string - -const ( - Web3HostnameListResponseStatusActive Web3HostnameListResponseStatus = "active" - Web3HostnameListResponseStatusPending Web3HostnameListResponseStatus = "pending" - Web3HostnameListResponseStatusDeleting Web3HostnameListResponseStatus = "deleting" - Web3HostnameListResponseStatusError Web3HostnameListResponseStatus = "error" -) - -// Target gateway of the hostname. -type Web3HostnameListResponseTarget string - -const ( - Web3HostnameListResponseTargetEthereum Web3HostnameListResponseTarget = "ethereum" - Web3HostnameListResponseTargetIPFS Web3HostnameListResponseTarget = "ipfs" - Web3HostnameListResponseTargetIPFSUniversalPath Web3HostnameListResponseTarget = "ipfs_universal_path" -) - -type Web3HostnameDeleteResponse struct { - // Identifier - ID string `json:"id,required"` - JSON web3HostnameDeleteResponseJSON `json:"-"` -} - -// web3HostnameDeleteResponseJSON contains the JSON metadata for the struct -// [Web3HostnameDeleteResponse] -type web3HostnameDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameEditResponse struct { - // Identifier - ID string `json:"id"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // An optional description of the hostname. - Description string `json:"description"` - // DNSLink value used if the target is ipfs. - Dnslink string `json:"dnslink"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The hostname that will point to the target gateway via CNAME. - Name string `json:"name"` - // Status of the hostname's activation. - Status Web3HostnameEditResponseStatus `json:"status"` - // Target gateway of the hostname. - Target Web3HostnameEditResponseTarget `json:"target"` - JSON web3HostnameEditResponseJSON `json:"-"` -} - -// web3HostnameEditResponseJSON contains the JSON metadata for the struct -// [Web3HostnameEditResponse] -type web3HostnameEditResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Description apijson.Field - Dnslink apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Status apijson.Field - Target apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameEditResponseJSON) RawJSON() string { - return r.raw -} - -// Status of the hostname's activation. -type Web3HostnameEditResponseStatus string - -const ( - Web3HostnameEditResponseStatusActive Web3HostnameEditResponseStatus = "active" - Web3HostnameEditResponseStatusPending Web3HostnameEditResponseStatus = "pending" - Web3HostnameEditResponseStatusDeleting Web3HostnameEditResponseStatus = "deleting" - Web3HostnameEditResponseStatusError Web3HostnameEditResponseStatus = "error" -) - -// Target gateway of the hostname. -type Web3HostnameEditResponseTarget string - -const ( - Web3HostnameEditResponseTargetEthereum Web3HostnameEditResponseTarget = "ethereum" - Web3HostnameEditResponseTargetIPFS Web3HostnameEditResponseTarget = "ipfs" - Web3HostnameEditResponseTargetIPFSUniversalPath Web3HostnameEditResponseTarget = "ipfs_universal_path" -) - -type Web3HostnameGetResponse struct { - // Identifier - ID string `json:"id"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // An optional description of the hostname. - Description string `json:"description"` - // DNSLink value used if the target is ipfs. - Dnslink string `json:"dnslink"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The hostname that will point to the target gateway via CNAME. - Name string `json:"name"` - // Status of the hostname's activation. - Status Web3HostnameGetResponseStatus `json:"status"` - // Target gateway of the hostname. - Target Web3HostnameGetResponseTarget `json:"target"` - JSON web3HostnameGetResponseJSON `json:"-"` -} - -// web3HostnameGetResponseJSON contains the JSON metadata for the struct -// [Web3HostnameGetResponse] -type web3HostnameGetResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Description apijson.Field - Dnslink apijson.Field - ModifiedOn apijson.Field - Name apijson.Field - Status apijson.Field - Target apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameGetResponseJSON) RawJSON() string { - return r.raw -} - -// Status of the hostname's activation. -type Web3HostnameGetResponseStatus string - -const ( - Web3HostnameGetResponseStatusActive Web3HostnameGetResponseStatus = "active" - Web3HostnameGetResponseStatusPending Web3HostnameGetResponseStatus = "pending" - Web3HostnameGetResponseStatusDeleting Web3HostnameGetResponseStatus = "deleting" - Web3HostnameGetResponseStatusError Web3HostnameGetResponseStatus = "error" -) - -// Target gateway of the hostname. -type Web3HostnameGetResponseTarget string - -const ( - Web3HostnameGetResponseTargetEthereum Web3HostnameGetResponseTarget = "ethereum" - Web3HostnameGetResponseTargetIPFS Web3HostnameGetResponseTarget = "ipfs" - Web3HostnameGetResponseTargetIPFSUniversalPath Web3HostnameGetResponseTarget = "ipfs_universal_path" -) - -type Web3HostnameNewParams struct { - // Target gateway of the hostname. - Target param.Field[Web3HostnameNewParamsTarget] `json:"target,required"` - // An optional description of the hostname. - Description param.Field[string] `json:"description"` - // DNSLink value used if the target is ipfs. - Dnslink param.Field[string] `json:"dnslink"` -} - -func (r Web3HostnameNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Target gateway of the hostname. -type Web3HostnameNewParamsTarget string - -const ( - Web3HostnameNewParamsTargetEthereum Web3HostnameNewParamsTarget = "ethereum" - Web3HostnameNewParamsTargetIPFS Web3HostnameNewParamsTarget = "ipfs" - Web3HostnameNewParamsTargetIPFSUniversalPath Web3HostnameNewParamsTarget = "ipfs_universal_path" -) - -type Web3HostnameNewResponseEnvelope struct { - Errors []Web3HostnameNewResponseEnvelopeErrors `json:"errors,required"` - Messages []Web3HostnameNewResponseEnvelopeMessages `json:"messages,required"` - Result Web3HostnameNewResponse `json:"result,required"` - // Whether the API call was successful - Success Web3HostnameNewResponseEnvelopeSuccess `json:"success,required"` - JSON web3HostnameNewResponseEnvelopeJSON `json:"-"` -} - -// web3HostnameNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [Web3HostnameNewResponseEnvelope] -type web3HostnameNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// web3HostnameNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [Web3HostnameNewResponseEnvelopeErrors] -type web3HostnameNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// web3HostnameNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [Web3HostnameNewResponseEnvelopeMessages] -type web3HostnameNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type Web3HostnameNewResponseEnvelopeSuccess bool - -const ( - Web3HostnameNewResponseEnvelopeSuccessTrue Web3HostnameNewResponseEnvelopeSuccess = true -) - -type Web3HostnameListResponseEnvelope struct { - Errors []Web3HostnameListResponseEnvelopeErrors `json:"errors,required"` - Messages []Web3HostnameListResponseEnvelopeMessages `json:"messages,required"` - Result []Web3HostnameListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success Web3HostnameListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo Web3HostnameListResponseEnvelopeResultInfo `json:"result_info"` - JSON web3HostnameListResponseEnvelopeJSON `json:"-"` -} - -// web3HostnameListResponseEnvelopeJSON contains the JSON metadata for the struct -// [Web3HostnameListResponseEnvelope] -type web3HostnameListResponseEnvelopeJSON 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 *Web3HostnameListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameListResponseEnvelopeErrorsJSON `json:"-"` -} - -// web3HostnameListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [Web3HostnameListResponseEnvelopeErrors] -type web3HostnameListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameListResponseEnvelopeMessagesJSON `json:"-"` -} - -// web3HostnameListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [Web3HostnameListResponseEnvelopeMessages] -type web3HostnameListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type Web3HostnameListResponseEnvelopeSuccess bool - -const ( - Web3HostnameListResponseEnvelopeSuccessTrue Web3HostnameListResponseEnvelopeSuccess = true -) - -type Web3HostnameListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON web3HostnameListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// web3HostnameListResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [Web3HostnameListResponseEnvelopeResultInfo] -type web3HostnameListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameDeleteResponseEnvelope struct { - Errors []Web3HostnameDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []Web3HostnameDeleteResponseEnvelopeMessages `json:"messages,required"` - Result Web3HostnameDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success Web3HostnameDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON web3HostnameDeleteResponseEnvelopeJSON `json:"-"` -} - -// web3HostnameDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [Web3HostnameDeleteResponseEnvelope] -type web3HostnameDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// web3HostnameDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [Web3HostnameDeleteResponseEnvelopeErrors] -type web3HostnameDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// web3HostnameDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [Web3HostnameDeleteResponseEnvelopeMessages] -type web3HostnameDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type Web3HostnameDeleteResponseEnvelopeSuccess bool - -const ( - Web3HostnameDeleteResponseEnvelopeSuccessTrue Web3HostnameDeleteResponseEnvelopeSuccess = true -) - -type Web3HostnameEditParams struct { - // An optional description of the hostname. - Description param.Field[string] `json:"description"` - // DNSLink value used if the target is ipfs. - Dnslink param.Field[string] `json:"dnslink"` -} - -func (r Web3HostnameEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type Web3HostnameEditResponseEnvelope struct { - Errors []Web3HostnameEditResponseEnvelopeErrors `json:"errors,required"` - Messages []Web3HostnameEditResponseEnvelopeMessages `json:"messages,required"` - Result Web3HostnameEditResponse `json:"result,required"` - // Whether the API call was successful - Success Web3HostnameEditResponseEnvelopeSuccess `json:"success,required"` - JSON web3HostnameEditResponseEnvelopeJSON `json:"-"` -} - -// web3HostnameEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [Web3HostnameEditResponseEnvelope] -type web3HostnameEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// web3HostnameEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [Web3HostnameEditResponseEnvelopeErrors] -type web3HostnameEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// web3HostnameEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [Web3HostnameEditResponseEnvelopeMessages] -type web3HostnameEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type Web3HostnameEditResponseEnvelopeSuccess bool - -const ( - Web3HostnameEditResponseEnvelopeSuccessTrue Web3HostnameEditResponseEnvelopeSuccess = true -) - -type Web3HostnameGetResponseEnvelope struct { - Errors []Web3HostnameGetResponseEnvelopeErrors `json:"errors,required"` - Messages []Web3HostnameGetResponseEnvelopeMessages `json:"messages,required"` - Result Web3HostnameGetResponse `json:"result,required"` - // Whether the API call was successful - Success Web3HostnameGetResponseEnvelopeSuccess `json:"success,required"` - JSON web3HostnameGetResponseEnvelopeJSON `json:"-"` -} - -// web3HostnameGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [Web3HostnameGetResponseEnvelope] -type web3HostnameGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// web3HostnameGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [Web3HostnameGetResponseEnvelopeErrors] -type web3HostnameGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// web3HostnameGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [Web3HostnameGetResponseEnvelopeMessages] -type web3HostnameGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type Web3HostnameGetResponseEnvelopeSuccess bool - -const ( - Web3HostnameGetResponseEnvelopeSuccessTrue Web3HostnameGetResponseEnvelopeSuccess = true -) diff --git a/web3hostname_test.go b/web3hostname_test.go deleted file mode 100644 index 80c5cb60acb..00000000000 --- a/web3hostname_test.go +++ /dev/null @@ -1,158 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWeb3HostnameNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Web3.Hostnames.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.Web3HostnameNewParams{ - Target: cloudflare.F(cloudflare.Web3HostnameNewParamsTargetIPFS), - Description: cloudflare.F("This is my IPFS gateway."), - Dnslink: cloudflare.F("/ipns/onboarding.ipfs.cloudflare.com"), - }, - ) - 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 TestWeb3HostnameList(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("user@example.com"), - ) - _, err := client.Web3.Hostnames.List(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()) - } -} - -func TestWeb3HostnameDelete(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("user@example.com"), - ) - _, err := client.Web3.Hostnames.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "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()) - } -} - -func TestWeb3HostnameEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Web3.Hostnames.Edit( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.Web3HostnameEditParams{ - Description: cloudflare.F("This is my IPFS gateway."), - Dnslink: cloudflare.F("/ipns/onboarding.ipfs.cloudflare.com"), - }, - ) - 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 TestWeb3HostnameGet(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("user@example.com"), - ) - _, err := client.Web3.Hostnames.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "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/web3hostnameipfsuniversalpath.go b/web3hostnameipfsuniversalpath.go deleted file mode 100644 index 899e410a45b..00000000000 --- a/web3hostnameipfsuniversalpath.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// Web3HostnameIPFSUniversalPathService 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 -// [NewWeb3HostnameIPFSUniversalPathService] method instead. -type Web3HostnameIPFSUniversalPathService struct { - Options []option.RequestOption - ContentLists *Web3HostnameIPFSUniversalPathContentListService -} - -// NewWeb3HostnameIPFSUniversalPathService 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 NewWeb3HostnameIPFSUniversalPathService(opts ...option.RequestOption) (r *Web3HostnameIPFSUniversalPathService) { - r = &Web3HostnameIPFSUniversalPathService{} - r.Options = opts - r.ContentLists = NewWeb3HostnameIPFSUniversalPathContentListService(opts...) - return -} diff --git a/web3hostnameipfsuniversalpathcontentlist.go b/web3hostnameipfsuniversalpathcontentlist.go deleted file mode 100644 index 30c3260fe58..00000000000 --- a/web3hostnameipfsuniversalpathcontentlist.go +++ /dev/null @@ -1,327 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// Web3HostnameIPFSUniversalPathContentListService 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 [NewWeb3HostnameIPFSUniversalPathContentListService] method instead. -type Web3HostnameIPFSUniversalPathContentListService struct { - Options []option.RequestOption - Entries *Web3HostnameIPFSUniversalPathContentListEntryService -} - -// NewWeb3HostnameIPFSUniversalPathContentListService 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 NewWeb3HostnameIPFSUniversalPathContentListService(opts ...option.RequestOption) (r *Web3HostnameIPFSUniversalPathContentListService) { - r = &Web3HostnameIPFSUniversalPathContentListService{} - r.Options = opts - r.Entries = NewWeb3HostnameIPFSUniversalPathContentListEntryService(opts...) - return -} - -// Update IPFS Universal Path Gateway Content List -func (r *Web3HostnameIPFSUniversalPathContentListService) Update(ctx context.Context, zoneIdentifier string, identifier string, body Web3HostnameIPFSUniversalPathContentListUpdateParams, opts ...option.RequestOption) (res *Web3HostnameIPFSUniversalPathContentListUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env Web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list", zoneIdentifier, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// IPFS Universal Path Gateway Content List Details -func (r *Web3HostnameIPFSUniversalPathContentListService) Get(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *Web3HostnameIPFSUniversalPathContentListGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env Web3HostnameIPFSUniversalPathContentListGetResponseEnvelope - path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list", zoneIdentifier, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type Web3HostnameIPFSUniversalPathContentListUpdateResponse struct { - // Behavior of the content list. - Action Web3HostnameIPFSUniversalPathContentListUpdateResponseAction `json:"action"` - JSON web3HostnameIPFSUniversalPathContentListUpdateResponseJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListUpdateResponseJSON contains the JSON -// metadata for the struct [Web3HostnameIPFSUniversalPathContentListUpdateResponse] -type web3HostnameIPFSUniversalPathContentListUpdateResponseJSON struct { - Action apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// Behavior of the content list. -type Web3HostnameIPFSUniversalPathContentListUpdateResponseAction string - -const ( - Web3HostnameIPFSUniversalPathContentListUpdateResponseActionBlock Web3HostnameIPFSUniversalPathContentListUpdateResponseAction = "block" -) - -type Web3HostnameIPFSUniversalPathContentListGetResponse struct { - // Behavior of the content list. - Action Web3HostnameIPFSUniversalPathContentListGetResponseAction `json:"action"` - JSON web3HostnameIPFSUniversalPathContentListGetResponseJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListGetResponseJSON contains the JSON -// metadata for the struct [Web3HostnameIPFSUniversalPathContentListGetResponse] -type web3HostnameIPFSUniversalPathContentListGetResponseJSON struct { - Action apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListGetResponseJSON) RawJSON() string { - return r.raw -} - -// Behavior of the content list. -type Web3HostnameIPFSUniversalPathContentListGetResponseAction string - -const ( - Web3HostnameIPFSUniversalPathContentListGetResponseActionBlock Web3HostnameIPFSUniversalPathContentListGetResponseAction = "block" -) - -type Web3HostnameIPFSUniversalPathContentListUpdateParams struct { - // Behavior of the content list. - Action param.Field[Web3HostnameIPFSUniversalPathContentListUpdateParamsAction] `json:"action,required"` - // Content list entries. - Entries param.Field[[]Web3HostnameIPFSUniversalPathContentListUpdateParamsEntry] `json:"entries,required"` -} - -func (r Web3HostnameIPFSUniversalPathContentListUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Behavior of the content list. -type Web3HostnameIPFSUniversalPathContentListUpdateParamsAction string - -const ( - Web3HostnameIPFSUniversalPathContentListUpdateParamsActionBlock Web3HostnameIPFSUniversalPathContentListUpdateParamsAction = "block" -) - -// Content list entry to be blocked. -type Web3HostnameIPFSUniversalPathContentListUpdateParamsEntry struct { - // CID or content path of content to block. - Content param.Field[string] `json:"content"` - // An optional description of the content list entry. - Description param.Field[string] `json:"description"` - // Type of content list entry to block. - Type param.Field[Web3HostnameIPFSUniversalPathContentListUpdateParamsEntriesType] `json:"type"` -} - -func (r Web3HostnameIPFSUniversalPathContentListUpdateParamsEntry) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Type of content list entry to block. -type Web3HostnameIPFSUniversalPathContentListUpdateParamsEntriesType string - -const ( - Web3HostnameIPFSUniversalPathContentListUpdateParamsEntriesTypeCid Web3HostnameIPFSUniversalPathContentListUpdateParamsEntriesType = "cid" - Web3HostnameIPFSUniversalPathContentListUpdateParamsEntriesTypeContentPath Web3HostnameIPFSUniversalPathContentListUpdateParamsEntriesType = "content_path" -) - -type Web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelope struct { - Errors []Web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []Web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessages `json:"messages,required"` - Result Web3HostnameIPFSUniversalPathContentListUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success Web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeJSON contains the -// JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelope] -type web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrorsJSON -// contains the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrors] -type web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessages] -type web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type Web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeSuccess bool - -const ( - Web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeSuccessTrue Web3HostnameIPFSUniversalPathContentListUpdateResponseEnvelopeSuccess = true -) - -type Web3HostnameIPFSUniversalPathContentListGetResponseEnvelope struct { - Errors []Web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeErrors `json:"errors,required"` - Messages []Web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeMessages `json:"messages,required"` - Result Web3HostnameIPFSUniversalPathContentListGetResponse `json:"result,required"` - // Whether the API call was successful - Success Web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeSuccess `json:"success,required"` - JSON web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeJSON contains the -// JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListGetResponseEnvelope] -type web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeErrorsJSON contains -// the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeErrors] -type web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeMessagesJSON contains -// the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeMessages] -type web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type Web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeSuccess bool - -const ( - Web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeSuccessTrue Web3HostnameIPFSUniversalPathContentListGetResponseEnvelopeSuccess = true -) diff --git a/web3hostnameipfsuniversalpathcontentlist_test.go b/web3hostnameipfsuniversalpathcontentlist_test.go deleted file mode 100644 index 0323fef68a0..00000000000 --- a/web3hostnameipfsuniversalpathcontentlist_test.go +++ /dev/null @@ -1,86 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWeb3HostnameIPFSUniversalPathContentListUpdate(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("user@example.com"), - ) - _, err := client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.Web3HostnameIPFSUniversalPathContentListUpdateParams{ - Action: cloudflare.F(cloudflare.Web3HostnameIPFSUniversalPathContentListUpdateParamsActionBlock), - Entries: cloudflare.F([]cloudflare.Web3HostnameIPFSUniversalPathContentListUpdateParamsEntry{{ - Content: cloudflare.F("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB"), - Description: cloudflare.F("this is my content list entry"), - Type: cloudflare.F(cloudflare.Web3HostnameIPFSUniversalPathContentListUpdateParamsEntriesTypeCid), - }, { - Content: cloudflare.F("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB"), - Description: cloudflare.F("this is my content list entry"), - Type: cloudflare.F(cloudflare.Web3HostnameIPFSUniversalPathContentListUpdateParamsEntriesTypeCid), - }, { - Content: cloudflare.F("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB"), - Description: cloudflare.F("this is my content list entry"), - Type: cloudflare.F(cloudflare.Web3HostnameIPFSUniversalPathContentListUpdateParamsEntriesTypeCid), - }}), - }, - ) - 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 TestWeb3HostnameIPFSUniversalPathContentListGet(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("user@example.com"), - ) - _, err := client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "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/web3hostnameipfsuniversalpathcontentlistentry.go b/web3hostnameipfsuniversalpathcontentlistentry.go deleted file mode 100644 index e2be95a68de..00000000000 --- a/web3hostnameipfsuniversalpathcontentlistentry.go +++ /dev/null @@ -1,824 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// Web3HostnameIPFSUniversalPathContentListEntryService 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 [NewWeb3HostnameIPFSUniversalPathContentListEntryService] method instead. -type Web3HostnameIPFSUniversalPathContentListEntryService struct { - Options []option.RequestOption -} - -// NewWeb3HostnameIPFSUniversalPathContentListEntryService 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 NewWeb3HostnameIPFSUniversalPathContentListEntryService(opts ...option.RequestOption) (r *Web3HostnameIPFSUniversalPathContentListEntryService) { - r = &Web3HostnameIPFSUniversalPathContentListEntryService{} - r.Options = opts - return -} - -// Create IPFS Universal Path Gateway Content List Entry -func (r *Web3HostnameIPFSUniversalPathContentListEntryService) New(ctx context.Context, zoneIdentifier string, identifier string, body Web3HostnameIPFSUniversalPathContentListEntryNewParams, opts ...option.RequestOption) (res *Web3HostnameIPFSUniversalPathContentListEntryNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env Web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelope - path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list/entries", zoneIdentifier, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Edit IPFS Universal Path Gateway Content List Entry -func (r *Web3HostnameIPFSUniversalPathContentListEntryService) Update(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, body Web3HostnameIPFSUniversalPathContentListEntryUpdateParams, opts ...option.RequestOption) (res *Web3HostnameIPFSUniversalPathContentListEntryUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list/entries/%s", zoneIdentifier, identifier, contentListEntryIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List IPFS Universal Path Gateway Content List Entries -func (r *Web3HostnameIPFSUniversalPathContentListEntryService) List(ctx context.Context, zoneIdentifier string, identifier string, opts ...option.RequestOption) (res *Web3HostnameIPFSUniversalPathContentListEntryListResponse, err error) { - opts = append(r.Options[:], opts...) - var env Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelope - path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list/entries", zoneIdentifier, identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete IPFS Universal Path Gateway Content List Entry -func (r *Web3HostnameIPFSUniversalPathContentListEntryService) Delete(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, opts ...option.RequestOption) (res *Web3HostnameIPFSUniversalPathContentListEntryDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env Web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list/entries/%s", zoneIdentifier, identifier, contentListEntryIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// IPFS Universal Path Gateway Content List Entry Details -func (r *Web3HostnameIPFSUniversalPathContentListEntryService) Get(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, opts ...option.RequestOption) (res *Web3HostnameIPFSUniversalPathContentListEntryGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env Web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelope - path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list/entries/%s", zoneIdentifier, identifier, contentListEntryIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Content list entry to be blocked. -type Web3HostnameIPFSUniversalPathContentListEntryNewResponse struct { - // Identifier - ID string `json:"id"` - // CID or content path of content to block. - Content string `json:"content"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // An optional description of the content list entry. - Description string `json:"description"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Type of content list entry to block. - Type Web3HostnameIPFSUniversalPathContentListEntryNewResponseType `json:"type"` - JSON web3HostnameIPFSUniversalPathContentListEntryNewResponseJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryNewResponseJSON contains the JSON -// metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryNewResponse] -type web3HostnameIPFSUniversalPathContentListEntryNewResponseJSON struct { - ID apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ModifiedOn apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryNewResponseJSON) RawJSON() string { - return r.raw -} - -// Type of content list entry to block. -type Web3HostnameIPFSUniversalPathContentListEntryNewResponseType string - -const ( - Web3HostnameIPFSUniversalPathContentListEntryNewResponseTypeCid Web3HostnameIPFSUniversalPathContentListEntryNewResponseType = "cid" - Web3HostnameIPFSUniversalPathContentListEntryNewResponseTypeContentPath Web3HostnameIPFSUniversalPathContentListEntryNewResponseType = "content_path" -) - -// Content list entry to be blocked. -type Web3HostnameIPFSUniversalPathContentListEntryUpdateResponse struct { - // Identifier - ID string `json:"id"` - // CID or content path of content to block. - Content string `json:"content"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // An optional description of the content list entry. - Description string `json:"description"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Type of content list entry to block. - Type Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseType `json:"type"` - JSON web3HostnameIPFSUniversalPathContentListEntryUpdateResponseJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryUpdateResponseJSON contains the -// JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryUpdateResponse] -type web3HostnameIPFSUniversalPathContentListEntryUpdateResponseJSON struct { - ID apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ModifiedOn apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// Type of content list entry to block. -type Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseType string - -const ( - Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseTypeCid Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseType = "cid" - Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseTypeContentPath Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseType = "content_path" -) - -type Web3HostnameIPFSUniversalPathContentListEntryListResponse struct { - // Content list entries. - Entries []Web3HostnameIPFSUniversalPathContentListEntryListResponseEntry `json:"entries"` - JSON web3HostnameIPFSUniversalPathContentListEntryListResponseJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryListResponseJSON contains the JSON -// metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryListResponse] -type web3HostnameIPFSUniversalPathContentListEntryListResponseJSON struct { - Entries apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryListResponseJSON) RawJSON() string { - return r.raw -} - -// Content list entry to be blocked. -type Web3HostnameIPFSUniversalPathContentListEntryListResponseEntry struct { - // Identifier - ID string `json:"id"` - // CID or content path of content to block. - Content string `json:"content"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // An optional description of the content list entry. - Description string `json:"description"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Type of content list entry to block. - Type Web3HostnameIPFSUniversalPathContentListEntryListResponseEntriesType `json:"type"` - JSON web3HostnameIPFSUniversalPathContentListEntryListResponseEntryJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryListResponseEntryJSON contains the -// JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryListResponseEntry] -type web3HostnameIPFSUniversalPathContentListEntryListResponseEntryJSON struct { - ID apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ModifiedOn apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryListResponseEntry) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryListResponseEntryJSON) RawJSON() string { - return r.raw -} - -// Type of content list entry to block. -type Web3HostnameIPFSUniversalPathContentListEntryListResponseEntriesType string - -const ( - Web3HostnameIPFSUniversalPathContentListEntryListResponseEntriesTypeCid Web3HostnameIPFSUniversalPathContentListEntryListResponseEntriesType = "cid" - Web3HostnameIPFSUniversalPathContentListEntryListResponseEntriesTypeContentPath Web3HostnameIPFSUniversalPathContentListEntryListResponseEntriesType = "content_path" -) - -type Web3HostnameIPFSUniversalPathContentListEntryDeleteResponse struct { - // Identifier - ID string `json:"id,required"` - JSON web3HostnameIPFSUniversalPathContentListEntryDeleteResponseJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryDeleteResponseJSON contains the -// JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryDeleteResponse] -type web3HostnameIPFSUniversalPathContentListEntryDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// Content list entry to be blocked. -type Web3HostnameIPFSUniversalPathContentListEntryGetResponse struct { - // Identifier - ID string `json:"id"` - // CID or content path of content to block. - Content string `json:"content"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // An optional description of the content list entry. - Description string `json:"description"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Type of content list entry to block. - Type Web3HostnameIPFSUniversalPathContentListEntryGetResponseType `json:"type"` - JSON web3HostnameIPFSUniversalPathContentListEntryGetResponseJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryGetResponseJSON contains the JSON -// metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryGetResponse] -type web3HostnameIPFSUniversalPathContentListEntryGetResponseJSON struct { - ID apijson.Field - Content apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ModifiedOn apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryGetResponseJSON) RawJSON() string { - return r.raw -} - -// Type of content list entry to block. -type Web3HostnameIPFSUniversalPathContentListEntryGetResponseType string - -const ( - Web3HostnameIPFSUniversalPathContentListEntryGetResponseTypeCid Web3HostnameIPFSUniversalPathContentListEntryGetResponseType = "cid" - Web3HostnameIPFSUniversalPathContentListEntryGetResponseTypeContentPath Web3HostnameIPFSUniversalPathContentListEntryGetResponseType = "content_path" -) - -type Web3HostnameIPFSUniversalPathContentListEntryNewParams struct { - // CID or content path of content to block. - Content param.Field[string] `json:"content,required"` - // Type of content list entry to block. - Type param.Field[Web3HostnameIPFSUniversalPathContentListEntryNewParamsType] `json:"type,required"` - // An optional description of the content list entry. - Description param.Field[string] `json:"description"` -} - -func (r Web3HostnameIPFSUniversalPathContentListEntryNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Type of content list entry to block. -type Web3HostnameIPFSUniversalPathContentListEntryNewParamsType string - -const ( - Web3HostnameIPFSUniversalPathContentListEntryNewParamsTypeCid Web3HostnameIPFSUniversalPathContentListEntryNewParamsType = "cid" - Web3HostnameIPFSUniversalPathContentListEntryNewParamsTypeContentPath Web3HostnameIPFSUniversalPathContentListEntryNewParamsType = "content_path" -) - -type Web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelope struct { - Errors []Web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrors `json:"errors,required"` - Messages []Web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessages `json:"messages,required"` - // Content list entry to be blocked. - Result Web3HostnameIPFSUniversalPathContentListEntryNewResponse `json:"result,required"` - // Whether the API call was successful - Success Web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeSuccess `json:"success,required"` - JSON web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeJSON contains -// the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelope] -type web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrorsJSON -// contains the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrors] -type web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessages] -type web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type Web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeSuccess bool - -const ( - Web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeSuccessTrue Web3HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeSuccess = true -) - -type Web3HostnameIPFSUniversalPathContentListEntryUpdateParams struct { - // CID or content path of content to block. - Content param.Field[string] `json:"content,required"` - // Type of content list entry to block. - Type param.Field[Web3HostnameIPFSUniversalPathContentListEntryUpdateParamsType] `json:"type,required"` - // An optional description of the content list entry. - Description param.Field[string] `json:"description"` -} - -func (r Web3HostnameIPFSUniversalPathContentListEntryUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Type of content list entry to block. -type Web3HostnameIPFSUniversalPathContentListEntryUpdateParamsType string - -const ( - Web3HostnameIPFSUniversalPathContentListEntryUpdateParamsTypeCid Web3HostnameIPFSUniversalPathContentListEntryUpdateParamsType = "cid" - Web3HostnameIPFSUniversalPathContentListEntryUpdateParamsTypeContentPath Web3HostnameIPFSUniversalPathContentListEntryUpdateParamsType = "content_path" -) - -type Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelope struct { - Errors []Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessages `json:"messages,required"` - // Content list entry to be blocked. - Result Web3HostnameIPFSUniversalPathContentListEntryUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeJSON contains -// the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelope] -type web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrorsJSON -// contains the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrors] -type web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessages] -type web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeSuccess bool - -const ( - Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeSuccessTrue Web3HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeSuccess = true -) - -type Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelope struct { - Errors []Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrors `json:"errors,required"` - Messages []Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessages `json:"messages,required"` - Result Web3HostnameIPFSUniversalPathContentListEntryListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeResultInfo `json:"result_info"` - JSON web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeJSON contains -// the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelope] -type web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeJSON 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 *Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrorsJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrorsJSON -// contains the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrors] -type web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessagesJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessages] -type web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeSuccess bool - -const ( - Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeSuccessTrue Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeSuccess = true -) - -type Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeResultInfoJSON -// contains the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeResultInfo] -type web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelope struct { - Errors []Web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []Web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessages `json:"messages,required"` - Result Web3HostnameIPFSUniversalPathContentListEntryDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success Web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeJSON contains -// the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelope] -type web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrorsJSON -// contains the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrors] -type web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessages] -type web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type Web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeSuccess bool - -const ( - Web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeSuccessTrue Web3HostnameIPFSUniversalPathContentListEntryDeleteResponseEnvelopeSuccess = true -) - -type Web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelope struct { - Errors []Web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrors `json:"errors,required"` - Messages []Web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessages `json:"messages,required"` - // Content list entry to be blocked. - Result Web3HostnameIPFSUniversalPathContentListEntryGetResponse `json:"result,required"` - // Whether the API call was successful - Success Web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeSuccess `json:"success,required"` - JSON web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeJSON contains -// the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelope] -type web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrorsJSON -// contains the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrors] -type web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type Web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [Web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessages] -type web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type Web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeSuccess bool - -const ( - Web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeSuccessTrue Web3HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeSuccess = true -) diff --git a/web3hostnameipfsuniversalpathcontentlistentry_test.go b/web3hostnameipfsuniversalpathcontentlistentry_test.go deleted file mode 100644 index cf5155a0dc5..00000000000 --- a/web3hostnameipfsuniversalpathcontentlistentry_test.go +++ /dev/null @@ -1,167 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWeb3HostnameIPFSUniversalPathContentListEntryNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.Web3HostnameIPFSUniversalPathContentListEntryNewParams{ - Content: cloudflare.F("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB"), - Type: cloudflare.F(cloudflare.Web3HostnameIPFSUniversalPathContentListEntryNewParamsTypeCid), - Description: cloudflare.F("this is my content list entry"), - }, - ) - 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 TestWeb3HostnameIPFSUniversalPathContentListEntryUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "023e105f4ecef8ad9ca31a8372d0c353", - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.Web3HostnameIPFSUniversalPathContentListEntryUpdateParams{ - Content: cloudflare.F("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB"), - Type: cloudflare.F(cloudflare.Web3HostnameIPFSUniversalPathContentListEntryUpdateParamsTypeCid), - Description: cloudflare.F("this is my content list entry"), - }, - ) - 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 TestWeb3HostnameIPFSUniversalPathContentListEntryList(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("user@example.com"), - ) - _, err := client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "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()) - } -} - -func TestWeb3HostnameIPFSUniversalPathContentListEntryDelete(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("user@example.com"), - ) - _, err := client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "023e105f4ecef8ad9ca31a8372d0c353", - "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()) - } -} - -func TestWeb3HostnameIPFSUniversalPathContentListEntryGet(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("user@example.com"), - ) - _, err := client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "023e105f4ecef8ad9ca31a8372d0c353", - "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/worker.go b/worker.go deleted file mode 100644 index 768e3eeb41c..00000000000 --- a/worker.go +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkerService 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 [NewWorkerService] method instead. -type WorkerService struct { - Options []option.RequestOption - AI *WorkerAIService - Scripts *WorkerScriptService - Filters *WorkerFilterService - Routes *WorkerRouteService - AccountSettings *WorkerAccountSettingService - Deployments *WorkerDeploymentService - Domains *WorkerDomainService - Subdomains *WorkerSubdomainService - Services *WorkerServiceService -} - -// NewWorkerService 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 NewWorkerService(opts ...option.RequestOption) (r *WorkerService) { - r = &WorkerService{} - r.Options = opts - r.AI = NewWorkerAIService(opts...) - r.Scripts = NewWorkerScriptService(opts...) - r.Filters = NewWorkerFilterService(opts...) - r.Routes = NewWorkerRouteService(opts...) - r.AccountSettings = NewWorkerAccountSettingService(opts...) - r.Deployments = NewWorkerDeploymentService(opts...) - r.Domains = NewWorkerDomainService(opts...) - r.Subdomains = NewWorkerSubdomainService(opts...) - r.Services = NewWorkerServiceService(opts...) - return -} diff --git a/workeraccountsetting.go b/workeraccountsetting.go deleted file mode 100644 index 3d7c407a6b0..00000000000 --- a/workeraccountsetting.go +++ /dev/null @@ -1,281 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkerAccountSettingService 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 [NewWorkerAccountSettingService] -// method instead. -type WorkerAccountSettingService struct { - Options []option.RequestOption -} - -// NewWorkerAccountSettingService 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 NewWorkerAccountSettingService(opts ...option.RequestOption) (r *WorkerAccountSettingService) { - r = &WorkerAccountSettingService{} - r.Options = opts - return -} - -// Creates Worker account settings for an account. -func (r *WorkerAccountSettingService) Update(ctx context.Context, params WorkerAccountSettingUpdateParams, opts ...option.RequestOption) (res *WorkerAccountSettingUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerAccountSettingUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/account-settings", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches Worker account settings for an account. -func (r *WorkerAccountSettingService) Get(ctx context.Context, query WorkerAccountSettingGetParams, opts ...option.RequestOption) (res *WorkerAccountSettingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerAccountSettingGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/account-settings", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WorkerAccountSettingUpdateResponse struct { - DefaultUsageModel interface{} `json:"default_usage_model"` - GreenCompute interface{} `json:"green_compute"` - JSON workerAccountSettingUpdateResponseJSON `json:"-"` -} - -// workerAccountSettingUpdateResponseJSON contains the JSON metadata for the struct -// [WorkerAccountSettingUpdateResponse] -type workerAccountSettingUpdateResponseJSON struct { - DefaultUsageModel apijson.Field - GreenCompute apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerAccountSettingUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerAccountSettingUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerAccountSettingGetResponse struct { - DefaultUsageModel interface{} `json:"default_usage_model"` - GreenCompute interface{} `json:"green_compute"` - JSON workerAccountSettingGetResponseJSON `json:"-"` -} - -// workerAccountSettingGetResponseJSON contains the JSON metadata for the struct -// [WorkerAccountSettingGetResponse] -type workerAccountSettingGetResponseJSON struct { - DefaultUsageModel apijson.Field - GreenCompute apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerAccountSettingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerAccountSettingGetResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerAccountSettingUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` -} - -func (r WorkerAccountSettingUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type WorkerAccountSettingUpdateResponseEnvelope struct { - Errors []WorkerAccountSettingUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerAccountSettingUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkerAccountSettingUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerAccountSettingUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON workerAccountSettingUpdateResponseEnvelopeJSON `json:"-"` -} - -// workerAccountSettingUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [WorkerAccountSettingUpdateResponseEnvelope] -type workerAccountSettingUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerAccountSettingUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerAccountSettingUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerAccountSettingUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerAccountSettingUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerAccountSettingUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [WorkerAccountSettingUpdateResponseEnvelopeErrors] -type workerAccountSettingUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerAccountSettingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerAccountSettingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerAccountSettingUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerAccountSettingUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerAccountSettingUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [WorkerAccountSettingUpdateResponseEnvelopeMessages] -type workerAccountSettingUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerAccountSettingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerAccountSettingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerAccountSettingUpdateResponseEnvelopeSuccess bool - -const ( - WorkerAccountSettingUpdateResponseEnvelopeSuccessTrue WorkerAccountSettingUpdateResponseEnvelopeSuccess = true -) - -type WorkerAccountSettingGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type WorkerAccountSettingGetResponseEnvelope struct { - Errors []WorkerAccountSettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerAccountSettingGetResponseEnvelopeMessages `json:"messages,required"` - Result WorkerAccountSettingGetResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerAccountSettingGetResponseEnvelopeSuccess `json:"success,required"` - JSON workerAccountSettingGetResponseEnvelopeJSON `json:"-"` -} - -// workerAccountSettingGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [WorkerAccountSettingGetResponseEnvelope] -type workerAccountSettingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerAccountSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerAccountSettingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerAccountSettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerAccountSettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerAccountSettingGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [WorkerAccountSettingGetResponseEnvelopeErrors] -type workerAccountSettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerAccountSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerAccountSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerAccountSettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerAccountSettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerAccountSettingGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [WorkerAccountSettingGetResponseEnvelopeMessages] -type workerAccountSettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerAccountSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerAccountSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerAccountSettingGetResponseEnvelopeSuccess bool - -const ( - WorkerAccountSettingGetResponseEnvelopeSuccessTrue WorkerAccountSettingGetResponseEnvelopeSuccess = true -) diff --git a/workeraccountsetting_test.go b/workeraccountsetting_test.go deleted file mode 100644 index 5ed34c41cce..00000000000 --- a/workeraccountsetting_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkerAccountSettingUpdate(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("user@example.com"), - ) - _, err := client.Workers.AccountSettings.Update(context.TODO(), cloudflare.WorkerAccountSettingUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F[any]("{'default_usage_model': 'unbound'}"), - }) - 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 TestWorkerAccountSettingGet(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("user@example.com"), - ) - _, err := client.Workers.AccountSettings.Get(context.TODO(), cloudflare.WorkerAccountSettingGetParams{ - AccountID: cloudflare.F("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/workerai.go b/workerai.go deleted file mode 100644 index de3478f91fa..00000000000 --- a/workerai.go +++ /dev/null @@ -1,108 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkerAIService 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 [NewWorkerAIService] method instead. -type WorkerAIService struct { - Options []option.RequestOption -} - -// NewWorkerAIService 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 NewWorkerAIService(opts ...option.RequestOption) (r *WorkerAIService) { - r = &WorkerAIService{} - r.Options = opts - return -} - -// This endpoint provides users with the capability to run specific AI models -// on-demand. -// -// By submitting the required input data, users can receive real-time predictions -// or results generated by the chosen AI model. The endpoint supports various AI -// model types, ensuring flexibility and adaptability for diverse use cases. -func (r *WorkerAIService) Run(ctx context.Context, modelName string, params WorkerAIRunParams, opts ...option.RequestOption) (res *WorkerAIRunResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerAIRunResponseEnvelope - path := fmt.Sprintf("accounts/%s/ai/run/%s", params.AccountID, modelName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WorkerAIRunResponse = interface{} - -type WorkerAIRunParams struct { - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` -} - -func (r WorkerAIRunParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type WorkerAIRunResponseEnvelope struct { - Errors []WorkerAIRunResponseEnvelopeErrors `json:"errors,required"` - Messages []string `json:"messages,required"` - Result WorkerAIRunResponse `json:"result,required"` - Success bool `json:"success,required"` - JSON workerAIRunResponseEnvelopeJSON `json:"-"` -} - -// workerAIRunResponseEnvelopeJSON contains the JSON metadata for the struct -// [WorkerAIRunResponseEnvelope] -type workerAIRunResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerAIRunResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerAIRunResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerAIRunResponseEnvelopeErrors struct { - Message string `json:"message,required"` - JSON workerAIRunResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerAIRunResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [WorkerAIRunResponseEnvelopeErrors] -type workerAIRunResponseEnvelopeErrorsJSON struct { - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerAIRunResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerAIRunResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} diff --git a/workerai_test.go b/workerai_test.go deleted file mode 100644 index 9336471a492..00000000000 --- a/workerai_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkerAIRun(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("user@example.com"), - ) - _, err := client.Workers.AI.Run( - context.TODO(), - "string", - cloudflare.WorkerAIRunParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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/workerdeployment.go b/workerdeployment.go deleted file mode 100644 index a4de482e380..00000000000 --- a/workerdeployment.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkerDeploymentService 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 [NewWorkerDeploymentService] method -// instead. -type WorkerDeploymentService struct { - Options []option.RequestOption - ByScripts *WorkerDeploymentByScriptService -} - -// NewWorkerDeploymentService 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 NewWorkerDeploymentService(opts ...option.RequestOption) (r *WorkerDeploymentService) { - r = &WorkerDeploymentService{} - r.Options = opts - r.ByScripts = NewWorkerDeploymentByScriptService(opts...) - return -} diff --git a/workerdeploymentbyscript.go b/workerdeploymentbyscript.go deleted file mode 100644 index f8944d70ec5..00000000000 --- a/workerdeploymentbyscript.go +++ /dev/null @@ -1,156 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkerDeploymentByScriptService 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 -// [NewWorkerDeploymentByScriptService] method instead. -type WorkerDeploymentByScriptService struct { - Options []option.RequestOption - Details *WorkerDeploymentByScriptDetailService -} - -// NewWorkerDeploymentByScriptService 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 NewWorkerDeploymentByScriptService(opts ...option.RequestOption) (r *WorkerDeploymentByScriptService) { - r = &WorkerDeploymentByScriptService{} - r.Options = opts - r.Details = NewWorkerDeploymentByScriptDetailService(opts...) - return -} - -// List Deployments -func (r *WorkerDeploymentByScriptService) Get(ctx context.Context, scriptID string, query WorkerDeploymentByScriptGetParams, opts ...option.RequestOption) (res *WorkerDeploymentByScriptGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerDeploymentByScriptGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/deployments/by-script/%s", query.AccountID, scriptID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WorkerDeploymentByScriptGetResponse struct { - Items []interface{} `json:"items"` - Latest interface{} `json:"latest"` - JSON workerDeploymentByScriptGetResponseJSON `json:"-"` -} - -// workerDeploymentByScriptGetResponseJSON contains the JSON metadata for the -// struct [WorkerDeploymentByScriptGetResponse] -type workerDeploymentByScriptGetResponseJSON struct { - Items apijson.Field - Latest apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDeploymentByScriptGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDeploymentByScriptGetResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerDeploymentByScriptGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type WorkerDeploymentByScriptGetResponseEnvelope struct { - Errors []WorkerDeploymentByScriptGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerDeploymentByScriptGetResponseEnvelopeMessages `json:"messages,required"` - Result WorkerDeploymentByScriptGetResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerDeploymentByScriptGetResponseEnvelopeSuccess `json:"success,required"` - JSON workerDeploymentByScriptGetResponseEnvelopeJSON `json:"-"` -} - -// workerDeploymentByScriptGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [WorkerDeploymentByScriptGetResponseEnvelope] -type workerDeploymentByScriptGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDeploymentByScriptGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDeploymentByScriptGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerDeploymentByScriptGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerDeploymentByScriptGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerDeploymentByScriptGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [WorkerDeploymentByScriptGetResponseEnvelopeErrors] -type workerDeploymentByScriptGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDeploymentByScriptGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDeploymentByScriptGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerDeploymentByScriptGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerDeploymentByScriptGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerDeploymentByScriptGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [WorkerDeploymentByScriptGetResponseEnvelopeMessages] -type workerDeploymentByScriptGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDeploymentByScriptGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDeploymentByScriptGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerDeploymentByScriptGetResponseEnvelopeSuccess bool - -const ( - WorkerDeploymentByScriptGetResponseEnvelopeSuccessTrue WorkerDeploymentByScriptGetResponseEnvelopeSuccess = true -) diff --git a/workerdeploymentbyscript_test.go b/workerdeploymentbyscript_test.go deleted file mode 100644 index 42eb0f9d33a..00000000000 --- a/workerdeploymentbyscript_test.go +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkerDeploymentByScriptGet(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("user@example.com"), - ) - _, err := client.Workers.Deployments.ByScripts.Get( - context.TODO(), - "8ee82b3a2c0f42928b8f14dae4a97121", - cloudflare.WorkerDeploymentByScriptGetParams{ - AccountID: cloudflare.F("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/workerdeploymentbyscriptdetail.go b/workerdeploymentbyscriptdetail.go deleted file mode 100644 index 4598a167ffc..00000000000 --- a/workerdeploymentbyscriptdetail.go +++ /dev/null @@ -1,160 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkerDeploymentByScriptDetailService 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 -// [NewWorkerDeploymentByScriptDetailService] method instead. -type WorkerDeploymentByScriptDetailService struct { - Options []option.RequestOption -} - -// NewWorkerDeploymentByScriptDetailService 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 NewWorkerDeploymentByScriptDetailService(opts ...option.RequestOption) (r *WorkerDeploymentByScriptDetailService) { - r = &WorkerDeploymentByScriptDetailService{} - r.Options = opts - return -} - -// Get Deployment Detail -func (r *WorkerDeploymentByScriptDetailService) Get(ctx context.Context, scriptID string, deploymentID string, query WorkerDeploymentByScriptDetailGetParams, opts ...option.RequestOption) (res *WorkerDeploymentByScriptDetailGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerDeploymentByScriptDetailGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/deployments/by-script/%s/detail/%s", query.AccountID, scriptID, deploymentID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WorkerDeploymentByScriptDetailGetResponse struct { - ID string `json:"id"` - Metadata interface{} `json:"metadata"` - Number float64 `json:"number"` - Resources interface{} `json:"resources"` - JSON workerDeploymentByScriptDetailGetResponseJSON `json:"-"` -} - -// workerDeploymentByScriptDetailGetResponseJSON contains the JSON metadata for the -// struct [WorkerDeploymentByScriptDetailGetResponse] -type workerDeploymentByScriptDetailGetResponseJSON struct { - ID apijson.Field - Metadata apijson.Field - Number apijson.Field - Resources apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDeploymentByScriptDetailGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDeploymentByScriptDetailGetResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerDeploymentByScriptDetailGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type WorkerDeploymentByScriptDetailGetResponseEnvelope struct { - Errors []WorkerDeploymentByScriptDetailGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerDeploymentByScriptDetailGetResponseEnvelopeMessages `json:"messages,required"` - Result WorkerDeploymentByScriptDetailGetResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerDeploymentByScriptDetailGetResponseEnvelopeSuccess `json:"success,required"` - JSON workerDeploymentByScriptDetailGetResponseEnvelopeJSON `json:"-"` -} - -// workerDeploymentByScriptDetailGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [WorkerDeploymentByScriptDetailGetResponseEnvelope] -type workerDeploymentByScriptDetailGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDeploymentByScriptDetailGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDeploymentByScriptDetailGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerDeploymentByScriptDetailGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerDeploymentByScriptDetailGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerDeploymentByScriptDetailGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [WorkerDeploymentByScriptDetailGetResponseEnvelopeErrors] -type workerDeploymentByScriptDetailGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDeploymentByScriptDetailGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDeploymentByScriptDetailGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerDeploymentByScriptDetailGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerDeploymentByScriptDetailGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerDeploymentByScriptDetailGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [WorkerDeploymentByScriptDetailGetResponseEnvelopeMessages] -type workerDeploymentByScriptDetailGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDeploymentByScriptDetailGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDeploymentByScriptDetailGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerDeploymentByScriptDetailGetResponseEnvelopeSuccess bool - -const ( - WorkerDeploymentByScriptDetailGetResponseEnvelopeSuccessTrue WorkerDeploymentByScriptDetailGetResponseEnvelopeSuccess = true -) diff --git a/workerdeploymentbyscriptdetail_test.go b/workerdeploymentbyscriptdetail_test.go deleted file mode 100644 index 3a53f3ee8f3..00000000000 --- a/workerdeploymentbyscriptdetail_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkerDeploymentByScriptDetailGet(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("user@example.com"), - ) - _, err := client.Workers.Deployments.ByScripts.Details.Get( - context.TODO(), - "8ee82b3a2c0f42928b8f14dae4a97121", - "bcf48806-b317-4351-9ee7-36e7d557d4de", - cloudflare.WorkerDeploymentByScriptDetailGetParams{ - AccountID: cloudflare.F("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/workerdomain.go b/workerdomain.go deleted file mode 100644 index fc83eea36a6..00000000000 --- a/workerdomain.go +++ /dev/null @@ -1,482 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkerDomainService 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 [NewWorkerDomainService] method -// instead. -type WorkerDomainService struct { - Options []option.RequestOption -} - -// NewWorkerDomainService 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 NewWorkerDomainService(opts ...option.RequestOption) (r *WorkerDomainService) { - r = &WorkerDomainService{} - r.Options = opts - return -} - -// Attaches a Worker to a zone and hostname. -func (r *WorkerDomainService) Update(ctx context.Context, params WorkerDomainUpdateParams, opts ...option.RequestOption) (res *WorkerDomainUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerDomainUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/workers/domains", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists all Worker Domains for an account. -func (r *WorkerDomainService) List(ctx context.Context, params WorkerDomainListParams, opts ...option.RequestOption) (res *[]WorkerDomainListResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerDomainListResponseEnvelope - path := fmt.Sprintf("accounts/%v/workers/domains", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Detaches a Worker from a zone and hostname. -func (r *WorkerDomainService) Delete(ctx context.Context, domainID interface{}, body WorkerDomainDeleteParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := fmt.Sprintf("accounts/%v/workers/domains/%v", body.AccountID, domainID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) - return -} - -// Gets a Worker domain. -func (r *WorkerDomainService) Get(ctx context.Context, domainID interface{}, query WorkerDomainGetParams, opts ...option.RequestOption) (res *WorkerDomainGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerDomainGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/workers/domains/%v", query.AccountID, domainID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WorkerDomainUpdateResponse struct { - // Identifer of the Worker Domain. - ID interface{} `json:"id"` - // Worker environment associated with the zone and hostname. - Environment string `json:"environment"` - // Hostname of the Worker Domain. - Hostname string `json:"hostname"` - // Worker service associated with the zone and hostname. - Service string `json:"service"` - // Identifier of the zone. - ZoneID interface{} `json:"zone_id"` - // Name of the zone. - ZoneName string `json:"zone_name"` - JSON workerDomainUpdateResponseJSON `json:"-"` -} - -// workerDomainUpdateResponseJSON contains the JSON metadata for the struct -// [WorkerDomainUpdateResponse] -type workerDomainUpdateResponseJSON struct { - ID apijson.Field - Environment apijson.Field - Hostname apijson.Field - Service apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDomainUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDomainUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerDomainListResponse struct { - // Identifer of the Worker Domain. - ID interface{} `json:"id"` - // Worker environment associated with the zone and hostname. - Environment string `json:"environment"` - // Hostname of the Worker Domain. - Hostname string `json:"hostname"` - // Worker service associated with the zone and hostname. - Service string `json:"service"` - // Identifier of the zone. - ZoneID interface{} `json:"zone_id"` - // Name of the zone. - ZoneName string `json:"zone_name"` - JSON workerDomainListResponseJSON `json:"-"` -} - -// workerDomainListResponseJSON contains the JSON metadata for the struct -// [WorkerDomainListResponse] -type workerDomainListResponseJSON struct { - ID apijson.Field - Environment apijson.Field - Hostname apijson.Field - Service apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDomainListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDomainListResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerDomainGetResponse struct { - // Identifer of the Worker Domain. - ID interface{} `json:"id"` - // Worker environment associated with the zone and hostname. - Environment string `json:"environment"` - // Hostname of the Worker Domain. - Hostname string `json:"hostname"` - // Worker service associated with the zone and hostname. - Service string `json:"service"` - // Identifier of the zone. - ZoneID interface{} `json:"zone_id"` - // Name of the zone. - ZoneName string `json:"zone_name"` - JSON workerDomainGetResponseJSON `json:"-"` -} - -// workerDomainGetResponseJSON contains the JSON metadata for the struct -// [WorkerDomainGetResponse] -type workerDomainGetResponseJSON struct { - ID apijson.Field - Environment apijson.Field - Hostname apijson.Field - Service apijson.Field - ZoneID apijson.Field - ZoneName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDomainGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDomainGetResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerDomainUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // Worker environment associated with the zone and hostname. - Environment param.Field[string] `json:"environment,required"` - // Hostname of the Worker Domain. - Hostname param.Field[string] `json:"hostname,required"` - // Worker service associated with the zone and hostname. - Service param.Field[string] `json:"service,required"` - // Identifier of the zone. - ZoneID param.Field[interface{}] `json:"zone_id,required"` -} - -func (r WorkerDomainUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerDomainUpdateResponseEnvelope struct { - Errors []WorkerDomainUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerDomainUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkerDomainUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerDomainUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON workerDomainUpdateResponseEnvelopeJSON `json:"-"` -} - -// workerDomainUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [WorkerDomainUpdateResponseEnvelope] -type workerDomainUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDomainUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDomainUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerDomainUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerDomainUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerDomainUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WorkerDomainUpdateResponseEnvelopeErrors] -type workerDomainUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDomainUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDomainUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerDomainUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerDomainUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerDomainUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WorkerDomainUpdateResponseEnvelopeMessages] -type workerDomainUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDomainUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDomainUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerDomainUpdateResponseEnvelopeSuccess bool - -const ( - WorkerDomainUpdateResponseEnvelopeSuccessTrue WorkerDomainUpdateResponseEnvelopeSuccess = true -) - -type WorkerDomainListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // Worker environment associated with the zone and hostname. - Environment param.Field[string] `query:"environment"` - // Hostname of the Worker Domain. - Hostname param.Field[string] `query:"hostname"` - // Worker service associated with the zone and hostname. - Service param.Field[string] `query:"service"` - // Identifier of the zone. - ZoneID param.Field[interface{}] `query:"zone_id"` - // Name of the zone. - ZoneName param.Field[string] `query:"zone_name"` -} - -// URLQuery serializes [WorkerDomainListParams]'s query parameters as `url.Values`. -func (r WorkerDomainListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type WorkerDomainListResponseEnvelope struct { - Errors []WorkerDomainListResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerDomainListResponseEnvelopeMessages `json:"messages,required"` - Result []WorkerDomainListResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerDomainListResponseEnvelopeSuccess `json:"success,required"` - JSON workerDomainListResponseEnvelopeJSON `json:"-"` -} - -// workerDomainListResponseEnvelopeJSON contains the JSON metadata for the struct -// [WorkerDomainListResponseEnvelope] -type workerDomainListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDomainListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDomainListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerDomainListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerDomainListResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerDomainListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WorkerDomainListResponseEnvelopeErrors] -type workerDomainListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDomainListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDomainListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerDomainListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerDomainListResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerDomainListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WorkerDomainListResponseEnvelopeMessages] -type workerDomainListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDomainListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDomainListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerDomainListResponseEnvelopeSuccess bool - -const ( - WorkerDomainListResponseEnvelopeSuccessTrue WorkerDomainListResponseEnvelopeSuccess = true -) - -type WorkerDomainDeleteParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type WorkerDomainGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type WorkerDomainGetResponseEnvelope struct { - Errors []WorkerDomainGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerDomainGetResponseEnvelopeMessages `json:"messages,required"` - Result WorkerDomainGetResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerDomainGetResponseEnvelopeSuccess `json:"success,required"` - JSON workerDomainGetResponseEnvelopeJSON `json:"-"` -} - -// workerDomainGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [WorkerDomainGetResponseEnvelope] -type workerDomainGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDomainGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDomainGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerDomainGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerDomainGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerDomainGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WorkerDomainGetResponseEnvelopeErrors] -type workerDomainGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDomainGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDomainGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerDomainGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerDomainGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerDomainGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WorkerDomainGetResponseEnvelopeMessages] -type workerDomainGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerDomainGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerDomainGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerDomainGetResponseEnvelopeSuccess bool - -const ( - WorkerDomainGetResponseEnvelopeSuccessTrue WorkerDomainGetResponseEnvelopeSuccess = true -) diff --git a/workerdomain_test.go b/workerdomain_test.go deleted file mode 100644 index 526e7bd9537..00000000000 --- a/workerdomain_test.go +++ /dev/null @@ -1,135 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkerDomainUpdate(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("user@example.com"), - ) - _, err := client.Workers.Domains.Update(context.TODO(), cloudflare.WorkerDomainUpdateParams{ - AccountID: cloudflare.F[any]("9a7806061c88ada191ed06f989cc3dac"), - Environment: cloudflare.F("production"), - Hostname: cloudflare.F("foo.example.com"), - Service: cloudflare.F("foo"), - ZoneID: cloudflare.F[any]("593c9c94de529bbbfaac7c53ced0447d"), - }) - 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 TestWorkerDomainListWithOptionalParams(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("user@example.com"), - ) - _, err := client.Workers.Domains.List(context.TODO(), cloudflare.WorkerDomainListParams{ - AccountID: cloudflare.F[any]("9a7806061c88ada191ed06f989cc3dac"), - Environment: cloudflare.F("production"), - Hostname: cloudflare.F("foo.example.com"), - Service: cloudflare.F("foo"), - ZoneID: cloudflare.F[any]("593c9c94de529bbbfaac7c53ced0447d"), - ZoneName: cloudflare.F("example.com"), - }) - 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 TestWorkerDomainDelete(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("user@example.com"), - ) - err := client.Workers.Domains.Delete( - context.TODO(), - "dbe10b4bc17c295377eabd600e1787fd", - cloudflare.WorkerDomainDeleteParams{ - AccountID: cloudflare.F[any]("9a7806061c88ada191ed06f989cc3dac"), - }, - ) - 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 TestWorkerDomainGet(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("user@example.com"), - ) - _, err := client.Workers.Domains.Get( - context.TODO(), - "dbe10b4bc17c295377eabd600e1787fd", - cloudflare.WorkerDomainGetParams{ - AccountID: cloudflare.F[any]("9a7806061c88ada191ed06f989cc3dac"), - }, - ) - 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/workerfilter.go b/workerfilter.go deleted file mode 100644 index f0dd91adc30..00000000000 --- a/workerfilter.go +++ /dev/null @@ -1,536 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkerFilterService 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 [NewWorkerFilterService] method -// instead. -type WorkerFilterService struct { - Options []option.RequestOption -} - -// NewWorkerFilterService 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 NewWorkerFilterService(opts ...option.RequestOption) (r *WorkerFilterService) { - r = &WorkerFilterService{} - r.Options = opts - return -} - -// Create Filter -func (r *WorkerFilterService) New(ctx context.Context, params WorkerFilterNewParams, opts ...option.RequestOption) (res *WorkerFilterNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerFilterNewResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/filters", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update Filter -func (r *WorkerFilterService) Update(ctx context.Context, filterID string, params WorkerFilterUpdateParams, opts ...option.RequestOption) (res *WorkerFilterUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerFilterUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/filters/%s", params.ZoneID, filterID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List Filters -func (r *WorkerFilterService) List(ctx context.Context, query WorkerFilterListParams, opts ...option.RequestOption) (res *[]WorkerFilterListResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerFilterListResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/filters", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete Filter -func (r *WorkerFilterService) Delete(ctx context.Context, filterID string, body WorkerFilterDeleteParams, opts ...option.RequestOption) (res *WorkerFilterDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerFilterDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/filters/%s", body.ZoneID, filterID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WorkerFilterNewResponse struct { - // Identifier - ID string `json:"id,required"` - JSON workerFilterNewResponseJSON `json:"-"` -} - -// workerFilterNewResponseJSON contains the JSON metadata for the struct -// [WorkerFilterNewResponse] -type workerFilterNewResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerFilterNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerFilterNewResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerFilterUpdateResponse struct { - // Identifier - ID string `json:"id,required"` - Enabled bool `json:"enabled,required"` - Pattern string `json:"pattern,required"` - JSON workerFilterUpdateResponseJSON `json:"-"` -} - -// workerFilterUpdateResponseJSON contains the JSON metadata for the struct -// [WorkerFilterUpdateResponse] -type workerFilterUpdateResponseJSON struct { - ID apijson.Field - Enabled apijson.Field - Pattern apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerFilterUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerFilterUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerFilterListResponse struct { - // Identifier - ID string `json:"id,required"` - Enabled bool `json:"enabled,required"` - Pattern string `json:"pattern,required"` - JSON workerFilterListResponseJSON `json:"-"` -} - -// workerFilterListResponseJSON contains the JSON metadata for the struct -// [WorkerFilterListResponse] -type workerFilterListResponseJSON struct { - ID apijson.Field - Enabled apijson.Field - Pattern apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerFilterListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerFilterListResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerFilterDeleteResponse struct { - // Identifier - ID string `json:"id,required"` - JSON workerFilterDeleteResponseJSON `json:"-"` -} - -// workerFilterDeleteResponseJSON contains the JSON metadata for the struct -// [WorkerFilterDeleteResponse] -type workerFilterDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerFilterDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerFilterDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerFilterNewParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Enabled param.Field[bool] `json:"enabled,required"` - Pattern param.Field[string] `json:"pattern,required"` -} - -func (r WorkerFilterNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerFilterNewResponseEnvelope struct { - Errors []WorkerFilterNewResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerFilterNewResponseEnvelopeMessages `json:"messages,required"` - Result WorkerFilterNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success WorkerFilterNewResponseEnvelopeSuccess `json:"success,required"` - JSON workerFilterNewResponseEnvelopeJSON `json:"-"` -} - -// workerFilterNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [WorkerFilterNewResponseEnvelope] -type workerFilterNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerFilterNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerFilterNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerFilterNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerFilterNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerFilterNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WorkerFilterNewResponseEnvelopeErrors] -type workerFilterNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerFilterNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerFilterNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerFilterNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerFilterNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerFilterNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WorkerFilterNewResponseEnvelopeMessages] -type workerFilterNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerFilterNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerFilterNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerFilterNewResponseEnvelopeSuccess bool - -const ( - WorkerFilterNewResponseEnvelopeSuccessTrue WorkerFilterNewResponseEnvelopeSuccess = true -) - -type WorkerFilterUpdateParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Enabled param.Field[bool] `json:"enabled,required"` - Pattern param.Field[string] `json:"pattern,required"` -} - -func (r WorkerFilterUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerFilterUpdateResponseEnvelope struct { - Errors []WorkerFilterUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerFilterUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkerFilterUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerFilterUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON workerFilterUpdateResponseEnvelopeJSON `json:"-"` -} - -// workerFilterUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [WorkerFilterUpdateResponseEnvelope] -type workerFilterUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerFilterUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerFilterUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerFilterUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerFilterUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerFilterUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WorkerFilterUpdateResponseEnvelopeErrors] -type workerFilterUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerFilterUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerFilterUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerFilterUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerFilterUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerFilterUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WorkerFilterUpdateResponseEnvelopeMessages] -type workerFilterUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerFilterUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerFilterUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerFilterUpdateResponseEnvelopeSuccess bool - -const ( - WorkerFilterUpdateResponseEnvelopeSuccessTrue WorkerFilterUpdateResponseEnvelopeSuccess = true -) - -type WorkerFilterListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type WorkerFilterListResponseEnvelope struct { - Errors []WorkerFilterListResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerFilterListResponseEnvelopeMessages `json:"messages,required"` - Result []WorkerFilterListResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerFilterListResponseEnvelopeSuccess `json:"success,required"` - JSON workerFilterListResponseEnvelopeJSON `json:"-"` -} - -// workerFilterListResponseEnvelopeJSON contains the JSON metadata for the struct -// [WorkerFilterListResponseEnvelope] -type workerFilterListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerFilterListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerFilterListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerFilterListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerFilterListResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerFilterListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WorkerFilterListResponseEnvelopeErrors] -type workerFilterListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerFilterListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerFilterListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerFilterListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerFilterListResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerFilterListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WorkerFilterListResponseEnvelopeMessages] -type workerFilterListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerFilterListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerFilterListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerFilterListResponseEnvelopeSuccess bool - -const ( - WorkerFilterListResponseEnvelopeSuccessTrue WorkerFilterListResponseEnvelopeSuccess = true -) - -type WorkerFilterDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type WorkerFilterDeleteResponseEnvelope struct { - Errors []WorkerFilterDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerFilterDeleteResponseEnvelopeMessages `json:"messages,required"` - Result WorkerFilterDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success WorkerFilterDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON workerFilterDeleteResponseEnvelopeJSON `json:"-"` -} - -// workerFilterDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [WorkerFilterDeleteResponseEnvelope] -type workerFilterDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerFilterDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerFilterDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerFilterDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerFilterDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerFilterDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WorkerFilterDeleteResponseEnvelopeErrors] -type workerFilterDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerFilterDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerFilterDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerFilterDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerFilterDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerFilterDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WorkerFilterDeleteResponseEnvelopeMessages] -type workerFilterDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerFilterDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerFilterDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerFilterDeleteResponseEnvelopeSuccess bool - -const ( - WorkerFilterDeleteResponseEnvelopeSuccessTrue WorkerFilterDeleteResponseEnvelopeSuccess = true -) diff --git a/workerfilter_test.go b/workerfilter_test.go deleted file mode 100644 index cc28c4df1fd..00000000000 --- a/workerfilter_test.go +++ /dev/null @@ -1,130 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkerFilterNew(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("user@example.com"), - ) - _, err := client.Workers.Filters.New(context.TODO(), cloudflare.WorkerFilterNewParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Enabled: cloudflare.F(true), - Pattern: cloudflare.F("example.net/*"), - }) - 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 TestWorkerFilterUpdate(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("user@example.com"), - ) - _, err := client.Workers.Filters.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.WorkerFilterUpdateParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Enabled: cloudflare.F(true), - Pattern: cloudflare.F("example.net/*"), - }, - ) - 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 TestWorkerFilterList(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("user@example.com"), - ) - _, err := client.Workers.Filters.List(context.TODO(), cloudflare.WorkerFilterListParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestWorkerFilterDelete(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("user@example.com"), - ) - _, err := client.Workers.Filters.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.WorkerFilterDeleteParams{ - ZoneID: cloudflare.F("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/workerroute.go b/workerroute.go deleted file mode 100644 index dbd61333305..00000000000 --- a/workerroute.go +++ /dev/null @@ -1,657 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// WorkerRouteService 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 [NewWorkerRouteService] method -// instead. -type WorkerRouteService struct { - Options []option.RequestOption -} - -// NewWorkerRouteService 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 NewWorkerRouteService(opts ...option.RequestOption) (r *WorkerRouteService) { - r = &WorkerRouteService{} - r.Options = opts - return -} - -// Creates a route that maps a URL pattern to a Worker. -func (r *WorkerRouteService) New(ctx context.Context, params WorkerRouteNewParams, opts ...option.RequestOption) (res *WorkerRouteNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerRouteNewResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/routes", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates the URL pattern or Worker associated with a route. -func (r *WorkerRouteService) Update(ctx context.Context, routeID string, params WorkerRouteUpdateParams, opts ...option.RequestOption) (res *WorkerRouteUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerRouteUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/routes/%s", params.ZoneID, routeID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Returns routes for a zone. -func (r *WorkerRouteService) List(ctx context.Context, query WorkerRouteListParams, opts ...option.RequestOption) (res *[]WorkerRouteListResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerRouteListResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/routes", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a route. -func (r *WorkerRouteService) Delete(ctx context.Context, routeID string, body WorkerRouteDeleteParams, opts ...option.RequestOption) (res *WorkerRouteDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerRouteDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/routes/%s", body.ZoneID, routeID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Returns information about a route, including URL pattern and Worker. -func (r *WorkerRouteService) Get(ctx context.Context, routeID string, query WorkerRouteGetParams, opts ...option.RequestOption) (res *WorkerRouteGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerRouteGetResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/routes/%s", query.ZoneID, routeID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [WorkerRouteNewResponseUnknown] or [shared.UnionString]. -type WorkerRouteNewResponse interface { - ImplementsWorkerRouteNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkerRouteNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type WorkerRouteUpdateResponse struct { - // Identifier - ID string `json:"id,required"` - Pattern string `json:"pattern,required"` - // Name of the script, used in URLs and route configuration. - Script string `json:"script,required"` - JSON workerRouteUpdateResponseJSON `json:"-"` -} - -// workerRouteUpdateResponseJSON contains the JSON metadata for the struct -// [WorkerRouteUpdateResponse] -type workerRouteUpdateResponseJSON struct { - ID apijson.Field - Pattern apijson.Field - Script apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerRouteUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerRouteUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerRouteListResponse struct { - // Identifier - ID string `json:"id,required"` - Pattern string `json:"pattern,required"` - // Name of the script, used in URLs and route configuration. - Script string `json:"script,required"` - JSON workerRouteListResponseJSON `json:"-"` -} - -// workerRouteListResponseJSON contains the JSON metadata for the struct -// [WorkerRouteListResponse] -type workerRouteListResponseJSON struct { - ID apijson.Field - Pattern apijson.Field - Script apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerRouteListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerRouteListResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [WorkerRouteDeleteResponseUnknown] or [shared.UnionString]. -type WorkerRouteDeleteResponse interface { - ImplementsWorkerRouteDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkerRouteDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type WorkerRouteGetResponse struct { - // Identifier - ID string `json:"id,required"` - Pattern string `json:"pattern,required"` - // Name of the script, used in URLs and route configuration. - Script string `json:"script,required"` - JSON workerRouteGetResponseJSON `json:"-"` -} - -// workerRouteGetResponseJSON contains the JSON metadata for the struct -// [WorkerRouteGetResponse] -type workerRouteGetResponseJSON struct { - ID apijson.Field - Pattern apijson.Field - Script apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerRouteGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerRouteGetResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerRouteNewParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Pattern param.Field[string] `json:"pattern,required"` - // Name of the script, used in URLs and route configuration. - Script param.Field[string] `json:"script"` -} - -func (r WorkerRouteNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerRouteNewResponseEnvelope struct { - Errors []WorkerRouteNewResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerRouteNewResponseEnvelopeMessages `json:"messages,required"` - Result WorkerRouteNewResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerRouteNewResponseEnvelopeSuccess `json:"success,required"` - JSON workerRouteNewResponseEnvelopeJSON `json:"-"` -} - -// workerRouteNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [WorkerRouteNewResponseEnvelope] -type workerRouteNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerRouteNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerRouteNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerRouteNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerRouteNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerRouteNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WorkerRouteNewResponseEnvelopeErrors] -type workerRouteNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerRouteNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerRouteNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerRouteNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerRouteNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerRouteNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WorkerRouteNewResponseEnvelopeMessages] -type workerRouteNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerRouteNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerRouteNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerRouteNewResponseEnvelopeSuccess bool - -const ( - WorkerRouteNewResponseEnvelopeSuccessTrue WorkerRouteNewResponseEnvelopeSuccess = true -) - -type WorkerRouteUpdateParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Pattern param.Field[string] `json:"pattern,required"` - // Name of the script, used in URLs and route configuration. - Script param.Field[string] `json:"script"` -} - -func (r WorkerRouteUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerRouteUpdateResponseEnvelope struct { - Errors []WorkerRouteUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerRouteUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkerRouteUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerRouteUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON workerRouteUpdateResponseEnvelopeJSON `json:"-"` -} - -// workerRouteUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [WorkerRouteUpdateResponseEnvelope] -type workerRouteUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerRouteUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerRouteUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerRouteUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerRouteUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerRouteUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WorkerRouteUpdateResponseEnvelopeErrors] -type workerRouteUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerRouteUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerRouteUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerRouteUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerRouteUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerRouteUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WorkerRouteUpdateResponseEnvelopeMessages] -type workerRouteUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerRouteUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerRouteUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerRouteUpdateResponseEnvelopeSuccess bool - -const ( - WorkerRouteUpdateResponseEnvelopeSuccessTrue WorkerRouteUpdateResponseEnvelopeSuccess = true -) - -type WorkerRouteListParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type WorkerRouteListResponseEnvelope struct { - Errors []WorkerRouteListResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerRouteListResponseEnvelopeMessages `json:"messages,required"` - Result []WorkerRouteListResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerRouteListResponseEnvelopeSuccess `json:"success,required"` - JSON workerRouteListResponseEnvelopeJSON `json:"-"` -} - -// workerRouteListResponseEnvelopeJSON contains the JSON metadata for the struct -// [WorkerRouteListResponseEnvelope] -type workerRouteListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerRouteListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerRouteListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerRouteListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerRouteListResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerRouteListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WorkerRouteListResponseEnvelopeErrors] -type workerRouteListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerRouteListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerRouteListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerRouteListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerRouteListResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerRouteListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WorkerRouteListResponseEnvelopeMessages] -type workerRouteListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerRouteListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerRouteListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerRouteListResponseEnvelopeSuccess bool - -const ( - WorkerRouteListResponseEnvelopeSuccessTrue WorkerRouteListResponseEnvelopeSuccess = true -) - -type WorkerRouteDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type WorkerRouteDeleteResponseEnvelope struct { - Errors []WorkerRouteDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerRouteDeleteResponseEnvelopeMessages `json:"messages,required"` - Result WorkerRouteDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerRouteDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON workerRouteDeleteResponseEnvelopeJSON `json:"-"` -} - -// workerRouteDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [WorkerRouteDeleteResponseEnvelope] -type workerRouteDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerRouteDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerRouteDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerRouteDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerRouteDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerRouteDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WorkerRouteDeleteResponseEnvelopeErrors] -type workerRouteDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerRouteDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerRouteDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerRouteDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerRouteDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerRouteDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WorkerRouteDeleteResponseEnvelopeMessages] -type workerRouteDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerRouteDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerRouteDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerRouteDeleteResponseEnvelopeSuccess bool - -const ( - WorkerRouteDeleteResponseEnvelopeSuccessTrue WorkerRouteDeleteResponseEnvelopeSuccess = true -) - -type WorkerRouteGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type WorkerRouteGetResponseEnvelope struct { - Errors []WorkerRouteGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerRouteGetResponseEnvelopeMessages `json:"messages,required"` - Result WorkerRouteGetResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerRouteGetResponseEnvelopeSuccess `json:"success,required"` - JSON workerRouteGetResponseEnvelopeJSON `json:"-"` -} - -// workerRouteGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [WorkerRouteGetResponseEnvelope] -type workerRouteGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerRouteGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerRouteGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerRouteGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerRouteGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerRouteGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WorkerRouteGetResponseEnvelopeErrors] -type workerRouteGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerRouteGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerRouteGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerRouteGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerRouteGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerRouteGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WorkerRouteGetResponseEnvelopeMessages] -type workerRouteGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerRouteGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerRouteGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerRouteGetResponseEnvelopeSuccess bool - -const ( - WorkerRouteGetResponseEnvelopeSuccessTrue WorkerRouteGetResponseEnvelopeSuccess = true -) diff --git a/workerroute_test.go b/workerroute_test.go deleted file mode 100644 index 8d23f6c2919..00000000000 --- a/workerroute_test.go +++ /dev/null @@ -1,160 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkerRouteNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Workers.Routes.New(context.TODO(), cloudflare.WorkerRouteNewParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Pattern: cloudflare.F("example.net/*"), - Script: cloudflare.F("this-is_my_script-01"), - }) - 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 TestWorkerRouteUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Workers.Routes.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.WorkerRouteUpdateParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Pattern: cloudflare.F("example.net/*"), - Script: cloudflare.F("this-is_my_script-01"), - }, - ) - 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 TestWorkerRouteList(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("user@example.com"), - ) - _, err := client.Workers.Routes.List(context.TODO(), cloudflare.WorkerRouteListParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestWorkerRouteDelete(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("user@example.com"), - ) - _, err := client.Workers.Routes.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.WorkerRouteDeleteParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestWorkerRouteGet(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("user@example.com"), - ) - _, err := client.Workers.Routes.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.WorkerRouteGetParams{ - ZoneID: cloudflare.F("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/workers/accountsetting.go b/workers/accountsetting.go new file mode 100644 index 00000000000..2ed259830ab --- /dev/null +++ b/workers/accountsetting.go @@ -0,0 +1,281 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AccountSettingService 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 [NewAccountSettingService] method +// instead. +type AccountSettingService struct { + Options []option.RequestOption +} + +// NewAccountSettingService 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 NewAccountSettingService(opts ...option.RequestOption) (r *AccountSettingService) { + r = &AccountSettingService{} + r.Options = opts + return +} + +// Creates Worker account settings for an account. +func (r *AccountSettingService) Update(ctx context.Context, params AccountSettingUpdateParams, opts ...option.RequestOption) (res *AccountSettingUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccountSettingUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/account-settings", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches Worker account settings for an account. +func (r *AccountSettingService) Get(ctx context.Context, query AccountSettingGetParams, opts ...option.RequestOption) (res *AccountSettingGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccountSettingGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/account-settings", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AccountSettingUpdateResponse struct { + DefaultUsageModel interface{} `json:"default_usage_model"` + GreenCompute interface{} `json:"green_compute"` + JSON accountSettingUpdateResponseJSON `json:"-"` +} + +// accountSettingUpdateResponseJSON contains the JSON metadata for the struct +// [AccountSettingUpdateResponse] +type accountSettingUpdateResponseJSON struct { + DefaultUsageModel apijson.Field + GreenCompute apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountSettingUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountSettingUpdateResponseJSON) RawJSON() string { + return r.raw +} + +type AccountSettingGetResponse struct { + DefaultUsageModel interface{} `json:"default_usage_model"` + GreenCompute interface{} `json:"green_compute"` + JSON accountSettingGetResponseJSON `json:"-"` +} + +// accountSettingGetResponseJSON contains the JSON metadata for the struct +// [AccountSettingGetResponse] +type accountSettingGetResponseJSON struct { + DefaultUsageModel apijson.Field + GreenCompute apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountSettingGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountSettingGetResponseJSON) RawJSON() string { + return r.raw +} + +type AccountSettingUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Body param.Field[interface{}] `json:"body,required"` +} + +func (r AccountSettingUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type AccountSettingUpdateResponseEnvelope struct { + Errors []AccountSettingUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []AccountSettingUpdateResponseEnvelopeMessages `json:"messages,required"` + Result AccountSettingUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success AccountSettingUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON accountSettingUpdateResponseEnvelopeJSON `json:"-"` +} + +// accountSettingUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccountSettingUpdateResponseEnvelope] +type accountSettingUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountSettingUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountSettingUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccountSettingUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accountSettingUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// accountSettingUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccountSettingUpdateResponseEnvelopeErrors] +type accountSettingUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountSettingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountSettingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccountSettingUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accountSettingUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// accountSettingUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AccountSettingUpdateResponseEnvelopeMessages] +type accountSettingUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountSettingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountSettingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccountSettingUpdateResponseEnvelopeSuccess bool + +const ( + AccountSettingUpdateResponseEnvelopeSuccessTrue AccountSettingUpdateResponseEnvelopeSuccess = true +) + +type AccountSettingGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type AccountSettingGetResponseEnvelope struct { + Errors []AccountSettingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AccountSettingGetResponseEnvelopeMessages `json:"messages,required"` + Result AccountSettingGetResponse `json:"result,required"` + // Whether the API call was successful + Success AccountSettingGetResponseEnvelopeSuccess `json:"success,required"` + JSON accountSettingGetResponseEnvelopeJSON `json:"-"` +} + +// accountSettingGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccountSettingGetResponseEnvelope] +type accountSettingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountSettingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccountSettingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accountSettingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// accountSettingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccountSettingGetResponseEnvelopeErrors] +type accountSettingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccountSettingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accountSettingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// accountSettingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccountSettingGetResponseEnvelopeMessages] +type accountSettingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccountSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accountSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccountSettingGetResponseEnvelopeSuccess bool + +const ( + AccountSettingGetResponseEnvelopeSuccessTrue AccountSettingGetResponseEnvelopeSuccess = true +) diff --git a/workers/accountsetting_test.go b/workers/accountsetting_test.go new file mode 100644 index 00000000000..e8788356d12 --- /dev/null +++ b/workers/accountsetting_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +func TestAccountSettingUpdate(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("user@example.com"), + ) + _, err := client.Workers.AccountSettings.Update(context.TODO(), workers.AccountSettingUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: cloudflare.F[any]("{'default_usage_model': 'unbound'}"), + }) + 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 TestAccountSettingGet(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("user@example.com"), + ) + _, err := client.Workers.AccountSettings.Get(context.TODO(), workers.AccountSettingGetParams{ + AccountID: cloudflare.F("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/workers/ai.go b/workers/ai.go new file mode 100644 index 00000000000..0f0be725488 --- /dev/null +++ b/workers/ai.go @@ -0,0 +1,111 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AIService 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 [NewAIService] method instead. +type AIService struct { + Options []option.RequestOption +} + +// NewAIService 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 NewAIService(opts ...option.RequestOption) (r *AIService) { + r = &AIService{} + r.Options = opts + return +} + +// This endpoint provides users with the capability to run specific AI models +// on-demand. +// +// By submitting the required input data, users can receive real-time predictions +// or results generated by the chosen AI model. The endpoint supports various AI +// model types, ensuring flexibility and adaptability for diverse use cases. +// +// Model specific inputs available in +// [Cloudflare Docs](https://developers.cloudflare.com/workers-ai/models/). +func (r *AIService) Run(ctx context.Context, modelName string, params AIRunParams, opts ...option.RequestOption) (res *AIRunResponse, err error) { + opts = append(r.Options[:], opts...) + var env AIRunResponseEnvelope + path := fmt.Sprintf("accounts/%s/ai/run/%s", params.AccountID, modelName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AIRunResponse = interface{} + +type AIRunParams struct { + AccountID param.Field[string] `path:"account_id,required"` + Body param.Field[interface{}] `json:"body,required"` +} + +func (r AIRunParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type AIRunResponseEnvelope struct { + Errors []AIRunResponseEnvelopeErrors `json:"errors,required"` + Messages []string `json:"messages,required"` + Result AIRunResponse `json:"result,required"` + Success bool `json:"success,required"` + JSON aiRunResponseEnvelopeJSON `json:"-"` +} + +// aiRunResponseEnvelopeJSON contains the JSON metadata for the struct +// [AIRunResponseEnvelope] +type aiRunResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AIRunResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aiRunResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AIRunResponseEnvelopeErrors struct { + Message string `json:"message,required"` + JSON aiRunResponseEnvelopeErrorsJSON `json:"-"` +} + +// aiRunResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [AIRunResponseEnvelopeErrors] +type aiRunResponseEnvelopeErrorsJSON struct { + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AIRunResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r aiRunResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} diff --git a/workers/ai_test.go b/workers/ai_test.go new file mode 100644 index 00000000000..f3eaa1673b8 --- /dev/null +++ b/workers/ai_test.go @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +func TestAIRun(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("user@example.com"), + ) + _, err := client.Workers.AI.Run( + context.TODO(), + "string", + workers.AIRunParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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/workers/aliases.go b/workers/aliases.go new file mode 100644 index 00000000000..6a901696ba2 --- /dev/null +++ b/workers/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/workers/deployment.go b/workers/deployment.go new file mode 100644 index 00000000000..23fe56d4166 --- /dev/null +++ b/workers/deployment.go @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// DeploymentService 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 [NewDeploymentService] method instead. +type DeploymentService struct { + Options []option.RequestOption + ByScripts *DeploymentByScriptService +} + +// NewDeploymentService 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 NewDeploymentService(opts ...option.RequestOption) (r *DeploymentService) { + r = &DeploymentService{} + r.Options = opts + r.ByScripts = NewDeploymentByScriptService(opts...) + return +} diff --git a/workers/deploymentbyscript.go b/workers/deploymentbyscript.go new file mode 100644 index 00000000000..ed1e184b096 --- /dev/null +++ b/workers/deploymentbyscript.go @@ -0,0 +1,156 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DeploymentByScriptService 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 [NewDeploymentByScriptService] method +// instead. +type DeploymentByScriptService struct { + Options []option.RequestOption + Details *DeploymentByScriptDetailService +} + +// NewDeploymentByScriptService 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 NewDeploymentByScriptService(opts ...option.RequestOption) (r *DeploymentByScriptService) { + r = &DeploymentByScriptService{} + r.Options = opts + r.Details = NewDeploymentByScriptDetailService(opts...) + return +} + +// List Deployments +func (r *DeploymentByScriptService) Get(ctx context.Context, scriptID string, query DeploymentByScriptGetParams, opts ...option.RequestOption) (res *DeploymentByScriptGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env DeploymentByScriptGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/deployments/by-script/%s", query.AccountID, scriptID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DeploymentByScriptGetResponse struct { + Items []interface{} `json:"items"` + Latest interface{} `json:"latest"` + JSON deploymentByScriptGetResponseJSON `json:"-"` +} + +// deploymentByScriptGetResponseJSON contains the JSON metadata for the struct +// [DeploymentByScriptGetResponse] +type deploymentByScriptGetResponseJSON struct { + Items apijson.Field + Latest apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeploymentByScriptGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deploymentByScriptGetResponseJSON) RawJSON() string { + return r.raw +} + +type DeploymentByScriptGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type DeploymentByScriptGetResponseEnvelope struct { + Errors []DeploymentByScriptGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DeploymentByScriptGetResponseEnvelopeMessages `json:"messages,required"` + Result DeploymentByScriptGetResponse `json:"result,required"` + // Whether the API call was successful + Success DeploymentByScriptGetResponseEnvelopeSuccess `json:"success,required"` + JSON deploymentByScriptGetResponseEnvelopeJSON `json:"-"` +} + +// deploymentByScriptGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [DeploymentByScriptGetResponseEnvelope] +type deploymentByScriptGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeploymentByScriptGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deploymentByScriptGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeploymentByScriptGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deploymentByScriptGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// deploymentByScriptGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [DeploymentByScriptGetResponseEnvelopeErrors] +type deploymentByScriptGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeploymentByScriptGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deploymentByScriptGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeploymentByScriptGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deploymentByScriptGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// deploymentByScriptGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [DeploymentByScriptGetResponseEnvelopeMessages] +type deploymentByScriptGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeploymentByScriptGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deploymentByScriptGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DeploymentByScriptGetResponseEnvelopeSuccess bool + +const ( + DeploymentByScriptGetResponseEnvelopeSuccessTrue DeploymentByScriptGetResponseEnvelopeSuccess = true +) diff --git a/workers/deploymentbyscript_test.go b/workers/deploymentbyscript_test.go new file mode 100644 index 00000000000..7b5695ed951 --- /dev/null +++ b/workers/deploymentbyscript_test.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +func TestDeploymentByScriptGet(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("user@example.com"), + ) + _, err := client.Workers.Deployments.ByScripts.Get( + context.TODO(), + "8ee82b3a2c0f42928b8f14dae4a97121", + workers.DeploymentByScriptGetParams{ + AccountID: cloudflare.F("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/workers/deploymentbyscriptdetail.go b/workers/deploymentbyscriptdetail.go new file mode 100644 index 00000000000..32f74bea8f2 --- /dev/null +++ b/workers/deploymentbyscriptdetail.go @@ -0,0 +1,158 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DeploymentByScriptDetailService 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 +// [NewDeploymentByScriptDetailService] method instead. +type DeploymentByScriptDetailService struct { + Options []option.RequestOption +} + +// NewDeploymentByScriptDetailService 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 NewDeploymentByScriptDetailService(opts ...option.RequestOption) (r *DeploymentByScriptDetailService) { + r = &DeploymentByScriptDetailService{} + r.Options = opts + return +} + +// Get Deployment Detail +func (r *DeploymentByScriptDetailService) Get(ctx context.Context, scriptID string, deploymentID string, query DeploymentByScriptDetailGetParams, opts ...option.RequestOption) (res *DeploymentByScriptDetailGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env DeploymentByScriptDetailGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/deployments/by-script/%s/detail/%s", query.AccountID, scriptID, deploymentID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DeploymentByScriptDetailGetResponse struct { + ID string `json:"id"` + Metadata interface{} `json:"metadata"` + Number float64 `json:"number"` + Resources interface{} `json:"resources"` + JSON deploymentByScriptDetailGetResponseJSON `json:"-"` +} + +// deploymentByScriptDetailGetResponseJSON contains the JSON metadata for the +// struct [DeploymentByScriptDetailGetResponse] +type deploymentByScriptDetailGetResponseJSON struct { + ID apijson.Field + Metadata apijson.Field + Number apijson.Field + Resources apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeploymentByScriptDetailGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deploymentByScriptDetailGetResponseJSON) RawJSON() string { + return r.raw +} + +type DeploymentByScriptDetailGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type DeploymentByScriptDetailGetResponseEnvelope struct { + Errors []DeploymentByScriptDetailGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DeploymentByScriptDetailGetResponseEnvelopeMessages `json:"messages,required"` + Result DeploymentByScriptDetailGetResponse `json:"result,required"` + // Whether the API call was successful + Success DeploymentByScriptDetailGetResponseEnvelopeSuccess `json:"success,required"` + JSON deploymentByScriptDetailGetResponseEnvelopeJSON `json:"-"` +} + +// deploymentByScriptDetailGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [DeploymentByScriptDetailGetResponseEnvelope] +type deploymentByScriptDetailGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeploymentByScriptDetailGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deploymentByScriptDetailGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeploymentByScriptDetailGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deploymentByScriptDetailGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// deploymentByScriptDetailGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [DeploymentByScriptDetailGetResponseEnvelopeErrors] +type deploymentByScriptDetailGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeploymentByScriptDetailGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deploymentByScriptDetailGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeploymentByScriptDetailGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deploymentByScriptDetailGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// deploymentByScriptDetailGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [DeploymentByScriptDetailGetResponseEnvelopeMessages] +type deploymentByScriptDetailGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeploymentByScriptDetailGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deploymentByScriptDetailGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DeploymentByScriptDetailGetResponseEnvelopeSuccess bool + +const ( + DeploymentByScriptDetailGetResponseEnvelopeSuccessTrue DeploymentByScriptDetailGetResponseEnvelopeSuccess = true +) diff --git a/workers/deploymentbyscriptdetail_test.go b/workers/deploymentbyscriptdetail_test.go new file mode 100644 index 00000000000..5556fdcca13 --- /dev/null +++ b/workers/deploymentbyscriptdetail_test.go @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +func TestDeploymentByScriptDetailGet(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("user@example.com"), + ) + _, err := client.Workers.Deployments.ByScripts.Details.Get( + context.TODO(), + "8ee82b3a2c0f42928b8f14dae4a97121", + "bcf48806-b317-4351-9ee7-36e7d557d4de", + workers.DeploymentByScriptDetailGetParams{ + AccountID: cloudflare.F("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/workers/domain.go b/workers/domain.go new file mode 100644 index 00000000000..6054e88e554 --- /dev/null +++ b/workers/domain.go @@ -0,0 +1,406 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DomainService 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 [NewDomainService] method instead. +type DomainService struct { + Options []option.RequestOption +} + +// NewDomainService 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 NewDomainService(opts ...option.RequestOption) (r *DomainService) { + r = &DomainService{} + r.Options = opts + return +} + +// Attaches a Worker to a zone and hostname. +func (r *DomainService) Update(ctx context.Context, params DomainUpdateParams, opts ...option.RequestOption) (res *WorkersDomain, err error) { + opts = append(r.Options[:], opts...) + var env DomainUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/workers/domains", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists all Worker Domains for an account. +func (r *DomainService) List(ctx context.Context, params DomainListParams, opts ...option.RequestOption) (res *[]WorkersDomain, err error) { + opts = append(r.Options[:], opts...) + var env DomainListResponseEnvelope + path := fmt.Sprintf("accounts/%v/workers/domains", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Detaches a Worker from a zone and hostname. +func (r *DomainService) Delete(ctx context.Context, domainID interface{}, body DomainDeleteParams, opts ...option.RequestOption) (err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + path := fmt.Sprintf("accounts/%v/workers/domains/%v", body.AccountID, domainID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) + return +} + +// Gets a Worker domain. +func (r *DomainService) Get(ctx context.Context, domainID interface{}, query DomainGetParams, opts ...option.RequestOption) (res *WorkersDomain, err error) { + opts = append(r.Options[:], opts...) + var env DomainGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/workers/domains/%v", query.AccountID, domainID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type WorkersDomain struct { + // Identifer of the Worker Domain. + ID interface{} `json:"id"` + // Worker environment associated with the zone and hostname. + Environment string `json:"environment"` + // Hostname of the Worker Domain. + Hostname string `json:"hostname"` + // Worker service associated with the zone and hostname. + Service string `json:"service"` + // Identifier of the zone. + ZoneID interface{} `json:"zone_id"` + // Name of the zone. + ZoneName string `json:"zone_name"` + JSON workersDomainJSON `json:"-"` +} + +// workersDomainJSON contains the JSON metadata for the struct [WorkersDomain] +type workersDomainJSON struct { + ID apijson.Field + Environment apijson.Field + Hostname apijson.Field + Service apijson.Field + ZoneID apijson.Field + ZoneName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersDomain) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersDomainJSON) RawJSON() string { + return r.raw +} + +type DomainUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // Worker environment associated with the zone and hostname. + Environment param.Field[string] `json:"environment,required"` + // Hostname of the Worker Domain. + Hostname param.Field[string] `json:"hostname,required"` + // Worker service associated with the zone and hostname. + Service param.Field[string] `json:"service,required"` + // Identifier of the zone. + ZoneID param.Field[interface{}] `json:"zone_id,required"` +} + +func (r DomainUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DomainUpdateResponseEnvelope struct { + Errors []DomainUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []DomainUpdateResponseEnvelopeMessages `json:"messages,required"` + Result WorkersDomain `json:"result,required"` + // Whether the API call was successful + Success DomainUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON domainUpdateResponseEnvelopeJSON `json:"-"` +} + +// domainUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [DomainUpdateResponseEnvelope] +type domainUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DomainUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON domainUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// domainUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [DomainUpdateResponseEnvelopeErrors] +type domainUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DomainUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON domainUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// domainUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DomainUpdateResponseEnvelopeMessages] +type domainUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DomainUpdateResponseEnvelopeSuccess bool + +const ( + DomainUpdateResponseEnvelopeSuccessTrue DomainUpdateResponseEnvelopeSuccess = true +) + +type DomainListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // Worker environment associated with the zone and hostname. + Environment param.Field[string] `query:"environment"` + // Hostname of the Worker Domain. + Hostname param.Field[string] `query:"hostname"` + // Worker service associated with the zone and hostname. + Service param.Field[string] `query:"service"` + // Identifier of the zone. + ZoneID param.Field[interface{}] `query:"zone_id"` + // Name of the zone. + ZoneName param.Field[string] `query:"zone_name"` +} + +// URLQuery serializes [DomainListParams]'s query parameters as `url.Values`. +func (r DomainListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type DomainListResponseEnvelope struct { + Errors []DomainListResponseEnvelopeErrors `json:"errors,required"` + Messages []DomainListResponseEnvelopeMessages `json:"messages,required"` + Result []WorkersDomain `json:"result,required"` + // Whether the API call was successful + Success DomainListResponseEnvelopeSuccess `json:"success,required"` + JSON domainListResponseEnvelopeJSON `json:"-"` +} + +// domainListResponseEnvelopeJSON contains the JSON metadata for the struct +// [DomainListResponseEnvelope] +type domainListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DomainListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON domainListResponseEnvelopeErrorsJSON `json:"-"` +} + +// domainListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [DomainListResponseEnvelopeErrors] +type domainListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DomainListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON domainListResponseEnvelopeMessagesJSON `json:"-"` +} + +// domainListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [DomainListResponseEnvelopeMessages] +type domainListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DomainListResponseEnvelopeSuccess bool + +const ( + DomainListResponseEnvelopeSuccessTrue DomainListResponseEnvelopeSuccess = true +) + +type DomainDeleteParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DomainGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DomainGetResponseEnvelope struct { + Errors []DomainGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DomainGetResponseEnvelopeMessages `json:"messages,required"` + Result WorkersDomain `json:"result,required"` + // Whether the API call was successful + Success DomainGetResponseEnvelopeSuccess `json:"success,required"` + JSON domainGetResponseEnvelopeJSON `json:"-"` +} + +// domainGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DomainGetResponseEnvelope] +type domainGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DomainGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON domainGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// domainGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [DomainGetResponseEnvelopeErrors] +type domainGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DomainGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON domainGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// domainGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [DomainGetResponseEnvelopeMessages] +type domainGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DomainGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r domainGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DomainGetResponseEnvelopeSuccess bool + +const ( + DomainGetResponseEnvelopeSuccessTrue DomainGetResponseEnvelopeSuccess = true +) diff --git a/workers/domain_test.go b/workers/domain_test.go new file mode 100644 index 00000000000..43a38d22d4d --- /dev/null +++ b/workers/domain_test.go @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +func TestDomainUpdate(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("user@example.com"), + ) + _, err := client.Workers.Domains.Update(context.TODO(), workers.DomainUpdateParams{ + AccountID: cloudflare.F[any]("9a7806061c88ada191ed06f989cc3dac"), + Environment: cloudflare.F("production"), + Hostname: cloudflare.F("foo.example.com"), + Service: cloudflare.F("foo"), + ZoneID: cloudflare.F[any]("593c9c94de529bbbfaac7c53ced0447d"), + }) + 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 TestDomainListWithOptionalParams(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("user@example.com"), + ) + _, err := client.Workers.Domains.List(context.TODO(), workers.DomainListParams{ + AccountID: cloudflare.F[any]("9a7806061c88ada191ed06f989cc3dac"), + Environment: cloudflare.F("production"), + Hostname: cloudflare.F("foo.example.com"), + Service: cloudflare.F("foo"), + ZoneID: cloudflare.F[any]("593c9c94de529bbbfaac7c53ced0447d"), + ZoneName: cloudflare.F("example.com"), + }) + 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 TestDomainDelete(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("user@example.com"), + ) + err := client.Workers.Domains.Delete( + context.TODO(), + "dbe10b4bc17c295377eabd600e1787fd", + workers.DomainDeleteParams{ + AccountID: cloudflare.F[any]("9a7806061c88ada191ed06f989cc3dac"), + }, + ) + 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 TestDomainGet(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("user@example.com"), + ) + _, err := client.Workers.Domains.Get( + context.TODO(), + "dbe10b4bc17c295377eabd600e1787fd", + workers.DomainGetParams{ + AccountID: cloudflare.F[any]("9a7806061c88ada191ed06f989cc3dac"), + }, + ) + 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/workers/filter.go b/workers/filter.go new file mode 100644 index 00000000000..f695458fdd5 --- /dev/null +++ b/workers/filter.go @@ -0,0 +1,508 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// FilterService 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 [NewFilterService] method instead. +type FilterService struct { + Options []option.RequestOption +} + +// NewFilterService 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 NewFilterService(opts ...option.RequestOption) (r *FilterService) { + r = &FilterService{} + r.Options = opts + return +} + +// Create Filter +func (r *FilterService) New(ctx context.Context, params FilterNewParams, opts ...option.RequestOption) (res *FilterNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env FilterNewResponseEnvelope + path := fmt.Sprintf("zones/%s/workers/filters", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update Filter +func (r *FilterService) Update(ctx context.Context, filterID string, params FilterUpdateParams, opts ...option.RequestOption) (res *WorkersFilters, err error) { + opts = append(r.Options[:], opts...) + var env FilterUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/workers/filters/%s", params.ZoneID, filterID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List Filters +func (r *FilterService) List(ctx context.Context, query FilterListParams, opts ...option.RequestOption) (res *[]WorkersFilters, err error) { + opts = append(r.Options[:], opts...) + var env FilterListResponseEnvelope + path := fmt.Sprintf("zones/%s/workers/filters", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete Filter +func (r *FilterService) Delete(ctx context.Context, filterID string, body FilterDeleteParams, opts ...option.RequestOption) (res *FilterDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env FilterDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/workers/filters/%s", body.ZoneID, filterID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type WorkersFilters struct { + // Identifier + ID string `json:"id,required"` + Enabled bool `json:"enabled,required"` + Pattern string `json:"pattern,required"` + JSON workersFiltersJSON `json:"-"` +} + +// workersFiltersJSON contains the JSON metadata for the struct [WorkersFilters] +type workersFiltersJSON struct { + ID apijson.Field + Enabled apijson.Field + Pattern apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersFilters) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersFiltersJSON) RawJSON() string { + return r.raw +} + +type FilterNewResponse struct { + // Identifier + ID string `json:"id,required"` + JSON filterNewResponseJSON `json:"-"` +} + +// filterNewResponseJSON contains the JSON metadata for the struct +// [FilterNewResponse] +type filterNewResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterNewResponseJSON) RawJSON() string { + return r.raw +} + +type FilterDeleteResponse struct { + // Identifier + ID string `json:"id,required"` + JSON filterDeleteResponseJSON `json:"-"` +} + +// filterDeleteResponseJSON contains the JSON metadata for the struct +// [FilterDeleteResponse] +type filterDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type FilterNewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Enabled param.Field[bool] `json:"enabled,required"` + Pattern param.Field[string] `json:"pattern,required"` +} + +func (r FilterNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type FilterNewResponseEnvelope struct { + Errors []FilterNewResponseEnvelopeErrors `json:"errors,required"` + Messages []FilterNewResponseEnvelopeMessages `json:"messages,required"` + Result FilterNewResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success FilterNewResponseEnvelopeSuccess `json:"success,required"` + JSON filterNewResponseEnvelopeJSON `json:"-"` +} + +// filterNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [FilterNewResponseEnvelope] +type filterNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FilterNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON filterNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// filterNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [FilterNewResponseEnvelopeErrors] +type filterNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FilterNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON filterNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// filterNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [FilterNewResponseEnvelopeMessages] +type filterNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FilterNewResponseEnvelopeSuccess bool + +const ( + FilterNewResponseEnvelopeSuccessTrue FilterNewResponseEnvelopeSuccess = true +) + +type FilterUpdateParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Enabled param.Field[bool] `json:"enabled,required"` + Pattern param.Field[string] `json:"pattern,required"` +} + +func (r FilterUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type FilterUpdateResponseEnvelope struct { + Errors []FilterUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []FilterUpdateResponseEnvelopeMessages `json:"messages,required"` + Result WorkersFilters `json:"result,required"` + // Whether the API call was successful + Success FilterUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON filterUpdateResponseEnvelopeJSON `json:"-"` +} + +// filterUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [FilterUpdateResponseEnvelope] +type filterUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FilterUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON filterUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// filterUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [FilterUpdateResponseEnvelopeErrors] +type filterUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FilterUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON filterUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// filterUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [FilterUpdateResponseEnvelopeMessages] +type filterUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FilterUpdateResponseEnvelopeSuccess bool + +const ( + FilterUpdateResponseEnvelopeSuccessTrue FilterUpdateResponseEnvelopeSuccess = true +) + +type FilterListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type FilterListResponseEnvelope struct { + Errors []FilterListResponseEnvelopeErrors `json:"errors,required"` + Messages []FilterListResponseEnvelopeMessages `json:"messages,required"` + Result []WorkersFilters `json:"result,required"` + // Whether the API call was successful + Success FilterListResponseEnvelopeSuccess `json:"success,required"` + JSON filterListResponseEnvelopeJSON `json:"-"` +} + +// filterListResponseEnvelopeJSON contains the JSON metadata for the struct +// [FilterListResponseEnvelope] +type filterListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FilterListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON filterListResponseEnvelopeErrorsJSON `json:"-"` +} + +// filterListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [FilterListResponseEnvelopeErrors] +type filterListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FilterListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON filterListResponseEnvelopeMessagesJSON `json:"-"` +} + +// filterListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [FilterListResponseEnvelopeMessages] +type filterListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FilterListResponseEnvelopeSuccess bool + +const ( + FilterListResponseEnvelopeSuccessTrue FilterListResponseEnvelopeSuccess = true +) + +type FilterDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type FilterDeleteResponseEnvelope struct { + Errors []FilterDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []FilterDeleteResponseEnvelopeMessages `json:"messages,required"` + Result FilterDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success FilterDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON filterDeleteResponseEnvelopeJSON `json:"-"` +} + +// filterDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [FilterDeleteResponseEnvelope] +type filterDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type FilterDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON filterDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// filterDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [FilterDeleteResponseEnvelopeErrors] +type filterDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type FilterDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON filterDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// filterDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [FilterDeleteResponseEnvelopeMessages] +type filterDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type FilterDeleteResponseEnvelopeSuccess bool + +const ( + FilterDeleteResponseEnvelopeSuccessTrue FilterDeleteResponseEnvelopeSuccess = true +) diff --git a/workers/filter_test.go b/workers/filter_test.go new file mode 100644 index 00000000000..a60cbe74e47 --- /dev/null +++ b/workers/filter_test.go @@ -0,0 +1,131 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +func TestFilterNew(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("user@example.com"), + ) + _, err := client.Workers.Filters.New(context.TODO(), workers.FilterNewParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Enabled: cloudflare.F(true), + Pattern: cloudflare.F("example.net/*"), + }) + 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 TestFilterUpdate(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("user@example.com"), + ) + _, err := client.Workers.Filters.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + workers.FilterUpdateParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Enabled: cloudflare.F(true), + Pattern: cloudflare.F("example.net/*"), + }, + ) + 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 TestFilterList(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("user@example.com"), + ) + _, err := client.Workers.Filters.List(context.TODO(), workers.FilterListParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestFilterDelete(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("user@example.com"), + ) + _, err := client.Workers.Filters.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + workers.FilterDeleteParams{ + ZoneID: cloudflare.F("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/workers/route.go b/workers/route.go new file mode 100644 index 00000000000..2fe9196d79d --- /dev/null +++ b/workers/route.go @@ -0,0 +1,601 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// RouteService 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 [NewRouteService] method instead. +type RouteService struct { + Options []option.RequestOption +} + +// NewRouteService 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 NewRouteService(opts ...option.RequestOption) (r *RouteService) { + r = &RouteService{} + r.Options = opts + return +} + +// Creates a route that maps a URL pattern to a Worker. +func (r *RouteService) New(ctx context.Context, params RouteNewParams, opts ...option.RequestOption) (res *RouteNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env RouteNewResponseEnvelope + path := fmt.Sprintf("zones/%s/workers/routes", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates the URL pattern or Worker associated with a route. +func (r *RouteService) Update(ctx context.Context, routeID string, params RouteUpdateParams, opts ...option.RequestOption) (res *WorkersRoutes, err error) { + opts = append(r.Options[:], opts...) + var env RouteUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/workers/routes/%s", params.ZoneID, routeID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Returns routes for a zone. +func (r *RouteService) List(ctx context.Context, query RouteListParams, opts ...option.RequestOption) (res *[]WorkersRoutes, err error) { + opts = append(r.Options[:], opts...) + var env RouteListResponseEnvelope + path := fmt.Sprintf("zones/%s/workers/routes", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a route. +func (r *RouteService) Delete(ctx context.Context, routeID string, body RouteDeleteParams, opts ...option.RequestOption) (res *RouteDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env RouteDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/workers/routes/%s", body.ZoneID, routeID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Returns information about a route, including URL pattern and Worker. +func (r *RouteService) Get(ctx context.Context, routeID string, query RouteGetParams, opts ...option.RequestOption) (res *WorkersRoutes, err error) { + opts = append(r.Options[:], opts...) + var env RouteGetResponseEnvelope + path := fmt.Sprintf("zones/%s/workers/routes/%s", query.ZoneID, routeID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type WorkersRoutes struct { + // Identifier + ID string `json:"id,required"` + Pattern string `json:"pattern,required"` + // Name of the script, used in URLs and route configuration. + Script string `json:"script,required"` + JSON workersRoutesJSON `json:"-"` +} + +// workersRoutesJSON contains the JSON metadata for the struct [WorkersRoutes] +type workersRoutesJSON struct { + ID apijson.Field + Pattern apijson.Field + Script apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersRoutes) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersRoutesJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [workers.RouteNewResponseUnknown] or [shared.UnionString]. +type RouteNewResponse interface { + ImplementsWorkersRouteNewResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RouteNewResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [workers.RouteDeleteResponseUnknown] or [shared.UnionString]. +type RouteDeleteResponse interface { + ImplementsWorkersRouteDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RouteDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type RouteNewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Pattern param.Field[string] `json:"pattern,required"` + // Name of the script, used in URLs and route configuration. + Script param.Field[string] `json:"script"` +} + +func (r RouteNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RouteNewResponseEnvelope struct { + Errors []RouteNewResponseEnvelopeErrors `json:"errors,required"` + Messages []RouteNewResponseEnvelopeMessages `json:"messages,required"` + Result RouteNewResponse `json:"result,required"` + // Whether the API call was successful + Success RouteNewResponseEnvelopeSuccess `json:"success,required"` + JSON routeNewResponseEnvelopeJSON `json:"-"` +} + +// routeNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [RouteNewResponseEnvelope] +type routeNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RouteNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// routeNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RouteNewResponseEnvelopeErrors] +type routeNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RouteNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// routeNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RouteNewResponseEnvelopeMessages] +type routeNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RouteNewResponseEnvelopeSuccess bool + +const ( + RouteNewResponseEnvelopeSuccessTrue RouteNewResponseEnvelopeSuccess = true +) + +type RouteUpdateParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Pattern param.Field[string] `json:"pattern,required"` + // Name of the script, used in URLs and route configuration. + Script param.Field[string] `json:"script"` +} + +func (r RouteUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type RouteUpdateResponseEnvelope struct { + Errors []RouteUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []RouteUpdateResponseEnvelopeMessages `json:"messages,required"` + Result WorkersRoutes `json:"result,required"` + // Whether the API call was successful + Success RouteUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON routeUpdateResponseEnvelopeJSON `json:"-"` +} + +// routeUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [RouteUpdateResponseEnvelope] +type routeUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RouteUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// routeUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RouteUpdateResponseEnvelopeErrors] +type routeUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RouteUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// routeUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RouteUpdateResponseEnvelopeMessages] +type routeUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RouteUpdateResponseEnvelopeSuccess bool + +const ( + RouteUpdateResponseEnvelopeSuccessTrue RouteUpdateResponseEnvelopeSuccess = true +) + +type RouteListParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type RouteListResponseEnvelope struct { + Errors []RouteListResponseEnvelopeErrors `json:"errors,required"` + Messages []RouteListResponseEnvelopeMessages `json:"messages,required"` + Result []WorkersRoutes `json:"result,required"` + // Whether the API call was successful + Success RouteListResponseEnvelopeSuccess `json:"success,required"` + JSON routeListResponseEnvelopeJSON `json:"-"` +} + +// routeListResponseEnvelopeJSON contains the JSON metadata for the struct +// [RouteListResponseEnvelope] +type routeListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RouteListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeListResponseEnvelopeErrorsJSON `json:"-"` +} + +// routeListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RouteListResponseEnvelopeErrors] +type routeListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RouteListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeListResponseEnvelopeMessagesJSON `json:"-"` +} + +// routeListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RouteListResponseEnvelopeMessages] +type routeListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RouteListResponseEnvelopeSuccess bool + +const ( + RouteListResponseEnvelopeSuccessTrue RouteListResponseEnvelopeSuccess = true +) + +type RouteDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type RouteDeleteResponseEnvelope struct { + Errors []RouteDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []RouteDeleteResponseEnvelopeMessages `json:"messages,required"` + Result RouteDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success RouteDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON routeDeleteResponseEnvelopeJSON `json:"-"` +} + +// routeDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [RouteDeleteResponseEnvelope] +type routeDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RouteDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// routeDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RouteDeleteResponseEnvelopeErrors] +type routeDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RouteDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// routeDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [RouteDeleteResponseEnvelopeMessages] +type routeDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RouteDeleteResponseEnvelopeSuccess bool + +const ( + RouteDeleteResponseEnvelopeSuccessTrue RouteDeleteResponseEnvelopeSuccess = true +) + +type RouteGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type RouteGetResponseEnvelope struct { + Errors []RouteGetResponseEnvelopeErrors `json:"errors,required"` + Messages []RouteGetResponseEnvelopeMessages `json:"messages,required"` + Result WorkersRoutes `json:"result,required"` + // Whether the API call was successful + Success RouteGetResponseEnvelopeSuccess `json:"success,required"` + JSON routeGetResponseEnvelopeJSON `json:"-"` +} + +// routeGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [RouteGetResponseEnvelope] +type routeGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type RouteGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// routeGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [RouteGetResponseEnvelopeErrors] +type routeGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type RouteGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON routeGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// routeGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [RouteGetResponseEnvelopeMessages] +type routeGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RouteGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r routeGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RouteGetResponseEnvelopeSuccess bool + +const ( + RouteGetResponseEnvelopeSuccessTrue RouteGetResponseEnvelopeSuccess = true +) diff --git a/workers/route_test.go b/workers/route_test.go new file mode 100644 index 00000000000..1c079ed831b --- /dev/null +++ b/workers/route_test.go @@ -0,0 +1,161 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +func TestRouteNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Workers.Routes.New(context.TODO(), workers.RouteNewParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Pattern: cloudflare.F("example.net/*"), + Script: cloudflare.F("this-is_my_script-01"), + }) + 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 TestRouteUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Workers.Routes.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + workers.RouteUpdateParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Pattern: cloudflare.F("example.net/*"), + Script: cloudflare.F("this-is_my_script-01"), + }, + ) + 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 TestRouteList(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("user@example.com"), + ) + _, err := client.Workers.Routes.List(context.TODO(), workers.RouteListParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestRouteDelete(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("user@example.com"), + ) + _, err := client.Workers.Routes.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + workers.RouteDeleteParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestRouteGet(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("user@example.com"), + ) + _, err := client.Workers.Routes.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + workers.RouteGetParams{ + ZoneID: cloudflare.F("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/workers/script.go b/workers/script.go new file mode 100644 index 00000000000..618892aea59 --- /dev/null +++ b/workers/script.go @@ -0,0 +1,587 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "bytes" + "context" + "fmt" + "io" + "mime/multipart" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apiform" + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ScriptService 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 [NewScriptService] method instead. +type ScriptService struct { + Options []option.RequestOption + Bindings *ScriptBindingService + Schedules *ScriptScheduleService + Tail *ScriptTailService + UsageModel *ScriptUsageModelService + Content *ScriptContentService + ContentV2 *ScriptContentV2Service + Settings *ScriptSettingService +} + +// NewScriptService 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 NewScriptService(opts ...option.RequestOption) (r *ScriptService) { + r = &ScriptService{} + r.Options = opts + r.Bindings = NewScriptBindingService(opts...) + r.Schedules = NewScriptScheduleService(opts...) + r.Tail = NewScriptTailService(opts...) + r.UsageModel = NewScriptUsageModelService(opts...) + r.Content = NewScriptContentService(opts...) + r.ContentV2 = NewScriptContentV2Service(opts...) + r.Settings = NewScriptSettingService(opts...) + return +} + +// Upload a worker module. +func (r *ScriptService) Update(ctx context.Context, scriptName string, params ScriptUpdateParams, opts ...option.RequestOption) (res *WorkersScript, err error) { + opts = append(r.Options[:], opts...) + var env ScriptUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/scripts/%s", params.AccountID, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch a list of uploaded workers. +func (r *ScriptService) List(ctx context.Context, query ScriptListParams, opts ...option.RequestOption) (res *[]WorkersScript, err error) { + opts = append(r.Options[:], opts...) + var env ScriptListResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/scripts", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete your worker. This call has no response body on a successful delete. +func (r *ScriptService) Delete(ctx context.Context, scriptName string, params ScriptDeleteParams, opts ...option.RequestOption) (err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + path := fmt.Sprintf("accounts/%s/workers/scripts/%s", params.AccountID, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, nil, opts...) + return +} + +// Fetch raw script content for your worker. Note this is the original script +// content, not JSON encoded. +func (r *ScriptService) Get(ctx context.Context, scriptName string, query ScriptGetParams, opts ...option.RequestOption) (res *http.Response, err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "undefined")}, opts...) + path := fmt.Sprintf("accounts/%s/workers/scripts/%s", query.AccountID, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +type WorkersScript struct { + // The id of the script in the Workers system. Usually the script name. + ID string `json:"id"` + // When the script was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Hashed script content, can be used in a If-None-Match header when updating. + Etag string `json:"etag"` + // Whether Logpush is turned on for the Worker. + Logpush bool `json:"logpush"` + // When the script was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + // Deprecated. Deployment metadata for internal usage. + PipelineHash string `json:"pipeline_hash"` + // Specifies the placement mode for the Worker (e.g. 'smart'). + PlacementMode string `json:"placement_mode"` + // List of Workers that will consume logs from the attached Worker. + TailConsumers []WorkersScriptTailConsumer `json:"tail_consumers"` + // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). + UsageModel string `json:"usage_model"` + JSON workersScriptJSON `json:"-"` +} + +// workersScriptJSON contains the JSON metadata for the struct [WorkersScript] +type workersScriptJSON struct { + ID apijson.Field + CreatedOn apijson.Field + Etag apijson.Field + Logpush apijson.Field + ModifiedOn apijson.Field + PipelineHash apijson.Field + PlacementMode apijson.Field + TailConsumers apijson.Field + UsageModel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersScript) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersScriptJSON) RawJSON() string { + return r.raw +} + +// A reference to a script that will consume logs from the attached Worker. +type WorkersScriptTailConsumer struct { + // Name of Worker that is to be the consumer. + Service string `json:"service,required"` + // Optional environment if the Worker utilizes one. + Environment string `json:"environment"` + // Optional dispatch namespace the script belongs to. + Namespace string `json:"namespace"` + JSON workersScriptTailConsumerJSON `json:"-"` +} + +// workersScriptTailConsumerJSON contains the JSON metadata for the struct +// [WorkersScriptTailConsumer] +type workersScriptTailConsumerJSON struct { + Service apijson.Field + Environment apijson.Field + Namespace apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersScriptTailConsumer) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersScriptTailConsumerJSON) RawJSON() string { + return r.raw +} + +type ScriptUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Rollback to provided deployment based on deployment ID. Request body will only + // parse a "message" part. You can learn more about deployments + // [here](https://developers.cloudflare.com/workers/platform/deployments/). + RollbackTo param.Field[string] `query:"rollback_to"` + // A module comprising a Worker script, often a javascript file. Multiple modules + // may be provided as separate named parts, but at least one module must be present + // and referenced in the metadata as `main_module` or `body_part` by part name. + AnyPartName param.Field[[]io.Reader] `json:"" format:"binary"` + // Rollback message to be associated with this deployment. Only parsed when query + // param `"rollback_to"` is present. + Message param.Field[string] `json:"message"` + // JSON encoded metadata about the uploaded parts and Worker configuration. + Metadata param.Field[ScriptUpdateParamsMetadata] `json:"metadata"` +} + +func (r ScriptUpdateParams) MarshalMultipart() (data []byte, contentType string, err error) { + buf := bytes.NewBuffer(nil) + writer := multipart.NewWriter(buf) + err = apiform.MarshalRoot(r, writer) + if err != nil { + writer.Close() + return nil, "", err + } + err = writer.Close() + if err != nil { + return nil, "", err + } + return buf.Bytes(), writer.FormDataContentType(), nil +} + +// URLQuery serializes [ScriptUpdateParams]'s query parameters as `url.Values`. +func (r ScriptUpdateParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// JSON encoded metadata about the uploaded parts and Worker configuration. +type ScriptUpdateParamsMetadata struct { + // List of bindings available to the worker. + Bindings param.Field[[]interface{}] `json:"bindings"` + // Name of the part in the multipart request that contains the script (e.g. the + // file adding a listener to the `fetch` event). Indicates a + // `service worker syntax` Worker. + BodyPart param.Field[string] `json:"body_part"` + // Date indicating targeted support in the Workers runtime. Backwards incompatible + // fixes to the runtime following this date will not affect this Worker. + CompatibilityDate param.Field[string] `json:"compatibility_date"` + // Flags that enable or disable certain features in the Workers runtime. Used to + // enable upcoming features or opt in or out of specific changes not included in a + // `compatibility_date`. + CompatibilityFlags param.Field[[]string] `json:"compatibility_flags"` + // List of binding types to keep from previous_upload. + KeepBindings param.Field[[]string] `json:"keep_bindings"` + // Whether Logpush is turned on for the Worker. + Logpush param.Field[bool] `json:"logpush"` + // Name of the part in the multipart request that contains the main module (e.g. + // the file exporting a `fetch` handler). Indicates a `module syntax` Worker. + MainModule param.Field[string] `json:"main_module"` + // Migrations to apply for Durable Objects associated with this Worker. + Migrations param.Field[ScriptUpdateParamsMetadataMigrations] `json:"migrations"` + Placement param.Field[ScriptUpdateParamsMetadataPlacement] `json:"placement"` + // List of strings to use as tags for this Worker + Tags param.Field[[]string] `json:"tags"` + // List of Workers that will consume logs from the attached Worker. + TailConsumers param.Field[[]ScriptUpdateParamsMetadataTailConsumer] `json:"tail_consumers"` + // Usage model to apply to invocations. + UsageModel param.Field[ScriptUpdateParamsMetadataUsageModel] `json:"usage_model"` + // Key-value pairs to use as tags for this version of this Worker + VersionTags param.Field[interface{}] `json:"version_tags"` +} + +func (r ScriptUpdateParamsMetadata) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Migrations to apply for Durable Objects associated with this Worker. +// +// Satisfied by +// [workers.ScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations], +// [workers.ScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrations]. +type ScriptUpdateParamsMetadataMigrations interface { + implementsWorkersScriptUpdateParamsMetadataMigrations() +} + +// A single set of migrations to apply. +type ScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses param.Field[[]string] `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses param.Field[[]string] `json:"new_classes"` + // Tag to set as the latest migration tag. + NewTag param.Field[string] `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag param.Field[string] `json:"old_tag"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses param.Field[[]ScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsRenamedClass] `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses param.Field[[]ScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsTransferredClass] `json:"transferred_classes"` +} + +func (r ScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations) implementsWorkersScriptUpdateParamsMetadataMigrations() { +} + +type ScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsRenamedClass struct { + From param.Field[string] `json:"from"` + To param.Field[string] `json:"to"` +} + +func (r ScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsRenamedClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsTransferredClass struct { + From param.Field[string] `json:"from"` + FromScript param.Field[string] `json:"from_script"` + To param.Field[string] `json:"to"` +} + +func (r ScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsTransferredClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrations struct { + // Tag to set as the latest migration tag. + NewTag param.Field[string] `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag param.Field[string] `json:"old_tag"` + // Migrations to apply in order. + Steps param.Field[[]ScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStep] `json:"steps"` +} + +func (r ScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrations) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrations) implementsWorkersScriptUpdateParamsMetadataMigrations() { +} + +type ScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStep struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses param.Field[[]string] `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses param.Field[[]string] `json:"new_classes"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses param.Field[[]ScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass] `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses param.Field[[]ScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass] `json:"transferred_classes"` +} + +func (r ScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStep) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { + From param.Field[string] `json:"from"` + To param.Field[string] `json:"to"` +} + +func (r ScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { + From param.Field[string] `json:"from"` + FromScript param.Field[string] `json:"from_script"` + To param.Field[string] `json:"to"` +} + +func (r ScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptUpdateParamsMetadataPlacement struct { + // Enables + // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + // Only `"smart"` is currently supported + Mode param.Field[ScriptUpdateParamsMetadataPlacementMode] `json:"mode"` +} + +func (r ScriptUpdateParamsMetadataPlacement) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enables +// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). +// Only `"smart"` is currently supported +type ScriptUpdateParamsMetadataPlacementMode string + +const ( + ScriptUpdateParamsMetadataPlacementModeSmart ScriptUpdateParamsMetadataPlacementMode = "smart" +) + +// A reference to a script that will consume logs from the attached Worker. +type ScriptUpdateParamsMetadataTailConsumer struct { + // Name of Worker that is to be the consumer. + Service param.Field[string] `json:"service,required"` + // Optional environment if the Worker utilizes one. + Environment param.Field[string] `json:"environment"` + // Optional dispatch namespace the script belongs to. + Namespace param.Field[string] `json:"namespace"` +} + +func (r ScriptUpdateParamsMetadataTailConsumer) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Usage model to apply to invocations. +type ScriptUpdateParamsMetadataUsageModel string + +const ( + ScriptUpdateParamsMetadataUsageModelBundled ScriptUpdateParamsMetadataUsageModel = "bundled" + ScriptUpdateParamsMetadataUsageModelUnbound ScriptUpdateParamsMetadataUsageModel = "unbound" +) + +type ScriptUpdateResponseEnvelope struct { + Errors []ScriptUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []ScriptUpdateResponseEnvelopeMessages `json:"messages,required"` + Result WorkersScript `json:"result,required"` + // Whether the API call was successful + Success ScriptUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON scriptUpdateResponseEnvelopeJSON `json:"-"` +} + +// scriptUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [ScriptUpdateResponseEnvelope] +type scriptUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ScriptUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// scriptUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ScriptUpdateResponseEnvelopeErrors] +type scriptUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ScriptUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// scriptUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ScriptUpdateResponseEnvelopeMessages] +type scriptUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptUpdateResponseEnvelopeSuccess bool + +const ( + ScriptUpdateResponseEnvelopeSuccessTrue ScriptUpdateResponseEnvelopeSuccess = true +) + +type ScriptListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ScriptListResponseEnvelope struct { + Errors []ScriptListResponseEnvelopeErrors `json:"errors,required"` + Messages []ScriptListResponseEnvelopeMessages `json:"messages,required"` + Result []WorkersScript `json:"result,required"` + // Whether the API call was successful + Success ScriptListResponseEnvelopeSuccess `json:"success,required"` + JSON scriptListResponseEnvelopeJSON `json:"-"` +} + +// scriptListResponseEnvelopeJSON contains the JSON metadata for the struct +// [ScriptListResponseEnvelope] +type scriptListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ScriptListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptListResponseEnvelopeErrorsJSON `json:"-"` +} + +// scriptListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [ScriptListResponseEnvelopeErrors] +type scriptListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ScriptListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptListResponseEnvelopeMessagesJSON `json:"-"` +} + +// scriptListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [ScriptListResponseEnvelopeMessages] +type scriptListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptListResponseEnvelopeSuccess bool + +const ( + ScriptListResponseEnvelopeSuccessTrue ScriptListResponseEnvelopeSuccess = true +) + +type ScriptDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // If set to true, delete will not be stopped by associated service binding, + // durable object, or other binding. Any of these associated bindings/durable + // objects will be deleted along with the script. + Force param.Field[bool] `query:"force"` +} + +// URLQuery serializes [ScriptDeleteParams]'s query parameters as `url.Values`. +func (r ScriptDeleteParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type ScriptGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} diff --git a/workers/script_test.go b/workers/script_test.go new file mode 100644 index 00000000000..cd076b444c2 --- /dev/null +++ b/workers/script_test.go @@ -0,0 +1,212 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_test + +import ( + "bytes" + "context" + "errors" + "io" + "net/http" + "net/http/httptest" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +func TestScriptUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Workers.Scripts.Update( + context.TODO(), + "this-is_my_script-01", + workers.ScriptUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + RollbackTo: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), + AnyPartName: cloudflare.F([]io.Reader{io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents")))}), + Message: cloudflare.F("string"), + Metadata: cloudflare.F(workers.ScriptUpdateParamsMetadata{ + Bindings: cloudflare.F([]interface{}{map[string]interface{}{ + "name": "MY_ENV_VAR", + "text": "my_data", + "type": "plain_text", + }}), + BodyPart: cloudflare.F("worker.js"), + CompatibilityDate: cloudflare.F("2023-07-25"), + CompatibilityFlags: cloudflare.F([]string{"string", "string", "string"}), + KeepBindings: cloudflare.F([]string{"string", "string", "string"}), + Logpush: cloudflare.F(false), + MainModule: cloudflare.F("worker.js"), + Migrations: cloudflare.F[workers.ScriptUpdateParamsMetadataMigrations](workers.ScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations(workers.ScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations{ + NewTag: cloudflare.F("v2"), + OldTag: cloudflare.F("v1"), + DeletedClasses: cloudflare.F([]string{"string", "string", "string"}), + NewClasses: cloudflare.F([]string{"string", "string", "string"}), + RenamedClasses: cloudflare.F([]workers.ScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsRenamedClass{{ + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }}), + TransferredClasses: cloudflare.F([]workers.ScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsTransferredClass{{ + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }}), + })), + Placement: cloudflare.F(workers.ScriptUpdateParamsMetadataPlacement{ + Mode: cloudflare.F(workers.ScriptUpdateParamsMetadataPlacementModeSmart), + }), + Tags: cloudflare.F([]string{"string", "string", "string"}), + TailConsumers: cloudflare.F([]workers.ScriptUpdateParamsMetadataTailConsumer{{ + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), + }, { + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), + }, { + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), + }}), + UsageModel: cloudflare.F(workers.ScriptUpdateParamsMetadataUsageModelBundled), + VersionTags: cloudflare.F[any](map[string]interface{}{}), + }), + }, + ) + 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 TestScriptList(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("user@example.com"), + ) + _, err := client.Workers.Scripts.List(context.TODO(), workers.ScriptListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestScriptDeleteWithOptionalParams(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("user@example.com"), + ) + err := client.Workers.Scripts.Delete( + context.TODO(), + "this-is_my_script-01", + workers.ScriptDeleteParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Force: cloudflare.F(true), + }, + ) + 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 TestScriptGet(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + w.Write([]byte("abc")) + })) + defer server.Close() + baseURL := server.URL + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("user@example.com"), + ) + resp, err := client.Workers.Scripts.Get( + context.TODO(), + "this-is_my_script-01", + workers.ScriptGetParams{ + AccountID: cloudflare.F("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()) + } + defer resp.Body.Close() + + b, err := io.ReadAll(resp.Body) + 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()) + } + if !bytes.Equal(b, []byte("abc")) { + t.Fatalf("return value not %s: %s", "abc", b) + } +} diff --git a/workers/scriptbinding.go b/workers/scriptbinding.go new file mode 100644 index 00000000000..c687605af5f --- /dev/null +++ b/workers/scriptbinding.go @@ -0,0 +1,225 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// ScriptBindingService 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 [NewScriptBindingService] method +// instead. +type ScriptBindingService struct { + Options []option.RequestOption +} + +// NewScriptBindingService 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 NewScriptBindingService(opts ...option.RequestOption) (r *ScriptBindingService) { + r = &ScriptBindingService{} + r.Options = opts + return +} + +// List the bindings for a Workers script. +func (r *ScriptBindingService) Get(ctx context.Context, query ScriptBindingGetParams, opts ...option.RequestOption) (res *[]WorkersSchemasBinding, err error) { + opts = append(r.Options[:], opts...) + var env ScriptBindingGetResponseEnvelope + path := fmt.Sprintf("zones/%s/workers/script/bindings", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [workers.WorkersSchemasBindingWorkersKVNamespaceBinding] or +// [workers.WorkersSchemasBindingWorkersWasmModuleBinding]. +type WorkersSchemasBinding interface { + implementsWorkersWorkersSchemasBinding() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WorkersSchemasBinding)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WorkersSchemasBindingWorkersKVNamespaceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(WorkersSchemasBindingWorkersWasmModuleBinding{}), + }, + ) +} + +type WorkersSchemasBindingWorkersKVNamespaceBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Namespace identifier tag. + NamespaceID string `json:"namespace_id,required"` + // The class of resource that the binding provides. + Type WorkersSchemasBindingWorkersKVNamespaceBindingType `json:"type,required"` + JSON workersSchemasBindingWorkersKVNamespaceBindingJSON `json:"-"` +} + +// workersSchemasBindingWorkersKVNamespaceBindingJSON contains the JSON metadata +// for the struct [WorkersSchemasBindingWorkersKVNamespaceBinding] +type workersSchemasBindingWorkersKVNamespaceBindingJSON struct { + Name apijson.Field + NamespaceID apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersSchemasBindingWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersSchemasBindingWorkersKVNamespaceBindingJSON) RawJSON() string { + return r.raw +} + +func (r WorkersSchemasBindingWorkersKVNamespaceBinding) implementsWorkersWorkersSchemasBinding() {} + +// The class of resource that the binding provides. +type WorkersSchemasBindingWorkersKVNamespaceBindingType string + +const ( + WorkersSchemasBindingWorkersKVNamespaceBindingTypeKVNamespace WorkersSchemasBindingWorkersKVNamespaceBindingType = "kv_namespace" +) + +type WorkersSchemasBindingWorkersWasmModuleBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type WorkersSchemasBindingWorkersWasmModuleBindingType `json:"type,required"` + JSON workersSchemasBindingWorkersWasmModuleBindingJSON `json:"-"` +} + +// workersSchemasBindingWorkersWasmModuleBindingJSON contains the JSON metadata for +// the struct [WorkersSchemasBindingWorkersWasmModuleBinding] +type workersSchemasBindingWorkersWasmModuleBindingJSON struct { + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersSchemasBindingWorkersWasmModuleBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersSchemasBindingWorkersWasmModuleBindingJSON) RawJSON() string { + return r.raw +} + +func (r WorkersSchemasBindingWorkersWasmModuleBinding) implementsWorkersWorkersSchemasBinding() {} + +// The class of resource that the binding provides. +type WorkersSchemasBindingWorkersWasmModuleBindingType string + +const ( + WorkersSchemasBindingWorkersWasmModuleBindingTypeWasmModule WorkersSchemasBindingWorkersWasmModuleBindingType = "wasm_module" +) + +type ScriptBindingGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type ScriptBindingGetResponseEnvelope struct { + Errors []ScriptBindingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ScriptBindingGetResponseEnvelopeMessages `json:"messages,required"` + Result []WorkersSchemasBinding `json:"result,required"` + // Whether the API call was successful + Success ScriptBindingGetResponseEnvelopeSuccess `json:"success,required"` + JSON scriptBindingGetResponseEnvelopeJSON `json:"-"` +} + +// scriptBindingGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [ScriptBindingGetResponseEnvelope] +type scriptBindingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptBindingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptBindingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ScriptBindingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptBindingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// scriptBindingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ScriptBindingGetResponseEnvelopeErrors] +type scriptBindingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptBindingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptBindingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ScriptBindingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptBindingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// scriptBindingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ScriptBindingGetResponseEnvelopeMessages] +type scriptBindingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptBindingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptBindingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptBindingGetResponseEnvelopeSuccess bool + +const ( + ScriptBindingGetResponseEnvelopeSuccessTrue ScriptBindingGetResponseEnvelopeSuccess = true +) diff --git a/workers/scriptbinding_test.go b/workers/scriptbinding_test.go new file mode 100644 index 00000000000..e295f66c4b3 --- /dev/null +++ b/workers/scriptbinding_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +func TestScriptBindingGet(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("user@example.com"), + ) + _, err := client.Workers.Scripts.Bindings.Get(context.TODO(), workers.ScriptBindingGetParams{ + ZoneID: cloudflare.F("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/workers/scriptcontent.go b/workers/scriptcontent.go new file mode 100644 index 00000000000..45b852579ab --- /dev/null +++ b/workers/scriptcontent.go @@ -0,0 +1,175 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "bytes" + "context" + "fmt" + "io" + "mime/multipart" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apiform" + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ScriptContentService 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 [NewScriptContentService] method +// instead. +type ScriptContentService struct { + Options []option.RequestOption +} + +// NewScriptContentService 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 NewScriptContentService(opts ...option.RequestOption) (r *ScriptContentService) { + r = &ScriptContentService{} + r.Options = opts + return +} + +// Put script content without touching config or metadata +func (r *ScriptContentService) Update(ctx context.Context, scriptName string, params ScriptContentUpdateParams, opts ...option.RequestOption) (res *WorkersScript, err error) { + opts = append(r.Options[:], opts...) + var env ScriptContentUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/content", params.AccountID, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ScriptContentUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // A module comprising a Worker script, often a javascript file. Multiple modules + // may be provided as separate named parts, but at least one module must be + // present. This should be referenced either in the metadata as `main_module` + // (esm)/`body_part` (service worker) or as a header `CF-WORKER-MAIN-MODULE-PART` + // (esm) /`CF-WORKER-BODY-PART` (service worker) by part name. + AnyPartName param.Field[[]io.Reader] `json:"" format:"binary"` + // JSON encoded metadata about the uploaded parts and Worker configuration. + Metadata param.Field[ScriptContentUpdateParamsMetadata] `json:"metadata"` + CfWorkerBodyPart param.Field[string] `header:"CF-WORKER-BODY-PART"` + CfWorkerMainModulePart param.Field[string] `header:"CF-WORKER-MAIN-MODULE-PART"` +} + +func (r ScriptContentUpdateParams) MarshalMultipart() (data []byte, contentType string, err error) { + buf := bytes.NewBuffer(nil) + writer := multipart.NewWriter(buf) + err = apiform.MarshalRoot(r, writer) + if err != nil { + writer.Close() + return nil, "", err + } + err = writer.Close() + if err != nil { + return nil, "", err + } + return buf.Bytes(), writer.FormDataContentType(), nil +} + +// JSON encoded metadata about the uploaded parts and Worker configuration. +type ScriptContentUpdateParamsMetadata struct { + // Name of the part in the multipart request that contains the script (e.g. the + // file adding a listener to the `fetch` event). Indicates a + // `service worker syntax` Worker. + BodyPart param.Field[string] `json:"body_part"` + // Name of the part in the multipart request that contains the main module (e.g. + // the file exporting a `fetch` handler). Indicates a `module syntax` Worker. + MainModule param.Field[string] `json:"main_module"` +} + +func (r ScriptContentUpdateParamsMetadata) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptContentUpdateResponseEnvelope struct { + Errors []ScriptContentUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []ScriptContentUpdateResponseEnvelopeMessages `json:"messages,required"` + Result WorkersScript `json:"result,required"` + // Whether the API call was successful + Success ScriptContentUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON scriptContentUpdateResponseEnvelopeJSON `json:"-"` +} + +// scriptContentUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [ScriptContentUpdateResponseEnvelope] +type scriptContentUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptContentUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptContentUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ScriptContentUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptContentUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// scriptContentUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ScriptContentUpdateResponseEnvelopeErrors] +type scriptContentUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptContentUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptContentUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ScriptContentUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptContentUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// scriptContentUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [ScriptContentUpdateResponseEnvelopeMessages] +type scriptContentUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptContentUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptContentUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptContentUpdateResponseEnvelopeSuccess bool + +const ( + ScriptContentUpdateResponseEnvelopeSuccessTrue ScriptContentUpdateResponseEnvelopeSuccess = true +) diff --git a/workers/scriptcontent_test.go b/workers/scriptcontent_test.go new file mode 100644 index 00000000000..5186a97d9bc --- /dev/null +++ b/workers/scriptcontent_test.go @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_test + +import ( + "bytes" + "context" + "errors" + "io" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +func TestScriptContentUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Workers.Scripts.Content.Update( + context.TODO(), + "this-is_my_script-01", + workers.ScriptContentUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + AnyPartName: cloudflare.F([]io.Reader{io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents")))}), + Metadata: cloudflare.F(workers.ScriptContentUpdateParamsMetadata{ + BodyPart: cloudflare.F("worker.js"), + MainModule: cloudflare.F("worker.js"), + }), + CfWorkerBodyPart: cloudflare.F("string"), + CfWorkerMainModulePart: cloudflare.F("string"), + }, + ) + 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/workers/scriptcontentv2.go b/workers/scriptcontentv2.go new file mode 100644 index 00000000000..50759de93d1 --- /dev/null +++ b/workers/scriptcontentv2.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ScriptContentV2Service 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 [NewScriptContentV2Service] method +// instead. +type ScriptContentV2Service struct { + Options []option.RequestOption +} + +// NewScriptContentV2Service 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 NewScriptContentV2Service(opts ...option.RequestOption) (r *ScriptContentV2Service) { + r = &ScriptContentV2Service{} + r.Options = opts + return +} + +// Fetch script content only +func (r *ScriptContentV2Service) Get(ctx context.Context, scriptName string, query ScriptContentV2GetParams, opts ...option.RequestOption) (res *http.Response, err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "string")}, opts...) + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/content/v2", query.AccountID, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +type ScriptContentV2GetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} diff --git a/workers/scriptcontentv2_test.go b/workers/scriptcontentv2_test.go new file mode 100644 index 00000000000..66fe1d5292b --- /dev/null +++ b/workers/scriptcontentv2_test.go @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_test + +import ( + "bytes" + "context" + "errors" + "io" + "net/http" + "net/http/httptest" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +func TestScriptContentV2Get(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + w.Write([]byte("abc")) + })) + defer server.Close() + baseURL := server.URL + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("user@example.com"), + ) + resp, err := client.Workers.Scripts.ContentV2.Get( + context.TODO(), + "this-is_my_script-01", + workers.ScriptContentV2GetParams{ + AccountID: cloudflare.F("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()) + } + defer resp.Body.Close() + + b, err := io.ReadAll(resp.Body) + 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()) + } + if !bytes.Equal(b, []byte("abc")) { + t.Fatalf("return value not %s: %s", "abc", b) + } +} diff --git a/workers/scriptschedule.go b/workers/scriptschedule.go new file mode 100644 index 00000000000..04f0b66b064 --- /dev/null +++ b/workers/scriptschedule.go @@ -0,0 +1,327 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ScriptScheduleService 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 [NewScriptScheduleService] method +// instead. +type ScriptScheduleService struct { + Options []option.RequestOption +} + +// NewScriptScheduleService 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 NewScriptScheduleService(opts ...option.RequestOption) (r *ScriptScheduleService) { + r = &ScriptScheduleService{} + r.Options = opts + return +} + +// Updates Cron Triggers for a Worker. +func (r *ScriptScheduleService) Update(ctx context.Context, scriptName string, params ScriptScheduleUpdateParams, opts ...option.RequestOption) (res *ScriptScheduleUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env ScriptScheduleUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/schedules", params.AccountID, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches Cron Triggers for a Worker. +func (r *ScriptScheduleService) Get(ctx context.Context, scriptName string, query ScriptScheduleGetParams, opts ...option.RequestOption) (res *ScriptScheduleGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env ScriptScheduleGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/schedules", query.AccountID, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ScriptScheduleUpdateResponse struct { + Schedules []ScriptScheduleUpdateResponseSchedule `json:"schedules"` + JSON scriptScheduleUpdateResponseJSON `json:"-"` +} + +// scriptScheduleUpdateResponseJSON contains the JSON metadata for the struct +// [ScriptScheduleUpdateResponse] +type scriptScheduleUpdateResponseJSON struct { + Schedules apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptScheduleUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptScheduleUpdateResponseJSON) RawJSON() string { + return r.raw +} + +type ScriptScheduleUpdateResponseSchedule struct { + CreatedOn interface{} `json:"created_on"` + Cron interface{} `json:"cron"` + ModifiedOn interface{} `json:"modified_on"` + JSON scriptScheduleUpdateResponseScheduleJSON `json:"-"` +} + +// scriptScheduleUpdateResponseScheduleJSON contains the JSON metadata for the +// struct [ScriptScheduleUpdateResponseSchedule] +type scriptScheduleUpdateResponseScheduleJSON struct { + CreatedOn apijson.Field + Cron apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptScheduleUpdateResponseSchedule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptScheduleUpdateResponseScheduleJSON) RawJSON() string { + return r.raw +} + +type ScriptScheduleGetResponse struct { + Schedules []ScriptScheduleGetResponseSchedule `json:"schedules"` + JSON scriptScheduleGetResponseJSON `json:"-"` +} + +// scriptScheduleGetResponseJSON contains the JSON metadata for the struct +// [ScriptScheduleGetResponse] +type scriptScheduleGetResponseJSON struct { + Schedules apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptScheduleGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptScheduleGetResponseJSON) RawJSON() string { + return r.raw +} + +type ScriptScheduleGetResponseSchedule struct { + CreatedOn interface{} `json:"created_on"` + Cron interface{} `json:"cron"` + ModifiedOn interface{} `json:"modified_on"` + JSON scriptScheduleGetResponseScheduleJSON `json:"-"` +} + +// scriptScheduleGetResponseScheduleJSON contains the JSON metadata for the struct +// [ScriptScheduleGetResponseSchedule] +type scriptScheduleGetResponseScheduleJSON struct { + CreatedOn apijson.Field + Cron apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptScheduleGetResponseSchedule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptScheduleGetResponseScheduleJSON) RawJSON() string { + return r.raw +} + +type ScriptScheduleUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Body param.Field[interface{}] `json:"body,required"` +} + +func (r ScriptScheduleUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type ScriptScheduleUpdateResponseEnvelope struct { + Errors []ScriptScheduleUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []ScriptScheduleUpdateResponseEnvelopeMessages `json:"messages,required"` + Result ScriptScheduleUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success ScriptScheduleUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON scriptScheduleUpdateResponseEnvelopeJSON `json:"-"` +} + +// scriptScheduleUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [ScriptScheduleUpdateResponseEnvelope] +type scriptScheduleUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptScheduleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptScheduleUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ScriptScheduleUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptScheduleUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// scriptScheduleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [ScriptScheduleUpdateResponseEnvelopeErrors] +type scriptScheduleUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptScheduleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptScheduleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ScriptScheduleUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptScheduleUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// scriptScheduleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [ScriptScheduleUpdateResponseEnvelopeMessages] +type scriptScheduleUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptScheduleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptScheduleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptScheduleUpdateResponseEnvelopeSuccess bool + +const ( + ScriptScheduleUpdateResponseEnvelopeSuccessTrue ScriptScheduleUpdateResponseEnvelopeSuccess = true +) + +type ScriptScheduleGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ScriptScheduleGetResponseEnvelope struct { + Errors []ScriptScheduleGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ScriptScheduleGetResponseEnvelopeMessages `json:"messages,required"` + Result ScriptScheduleGetResponse `json:"result,required"` + // Whether the API call was successful + Success ScriptScheduleGetResponseEnvelopeSuccess `json:"success,required"` + JSON scriptScheduleGetResponseEnvelopeJSON `json:"-"` +} + +// scriptScheduleGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [ScriptScheduleGetResponseEnvelope] +type scriptScheduleGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptScheduleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptScheduleGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ScriptScheduleGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptScheduleGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// scriptScheduleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ScriptScheduleGetResponseEnvelopeErrors] +type scriptScheduleGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptScheduleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptScheduleGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ScriptScheduleGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptScheduleGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// scriptScheduleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ScriptScheduleGetResponseEnvelopeMessages] +type scriptScheduleGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptScheduleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptScheduleGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptScheduleGetResponseEnvelopeSuccess bool + +const ( + ScriptScheduleGetResponseEnvelopeSuccessTrue ScriptScheduleGetResponseEnvelopeSuccess = true +) diff --git a/workers/scriptschedule_test.go b/workers/scriptschedule_test.go new file mode 100644 index 00000000000..072132ec30d --- /dev/null +++ b/workers/scriptschedule_test.go @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +func TestScriptScheduleUpdate(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("user@example.com"), + ) + _, err := client.Workers.Scripts.Schedules.Update( + context.TODO(), + "this-is_my_script-01", + workers.ScriptScheduleUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: cloudflare.F[any]("[{'cron': '*/30 * * * *'}]"), + }, + ) + 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 TestScriptScheduleGet(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("user@example.com"), + ) + _, err := client.Workers.Scripts.Schedules.Get( + context.TODO(), + "this-is_my_script-01", + workers.ScriptScheduleGetParams{ + AccountID: cloudflare.F("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/workers/scriptsetting.go b/workers/scriptsetting.go new file mode 100644 index 00000000000..cdbca8300eb --- /dev/null +++ b/workers/scriptsetting.go @@ -0,0 +1,2202 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// ScriptSettingService 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 [NewScriptSettingService] method +// instead. +type ScriptSettingService struct { + Options []option.RequestOption +} + +// NewScriptSettingService 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 NewScriptSettingService(opts ...option.RequestOption) (r *ScriptSettingService) { + r = &ScriptSettingService{} + r.Options = opts + return +} + +// Patch script metadata or config, such as bindings or usage model +func (r *ScriptSettingService) Edit(ctx context.Context, scriptName string, params ScriptSettingEditParams, opts ...option.RequestOption) (res *ScriptSettingEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env ScriptSettingEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/settings", params.AccountID, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get script metadata and config, such as bindings or usage model +func (r *ScriptSettingService) Get(ctx context.Context, scriptName string, query ScriptSettingGetParams, opts ...option.RequestOption) (res *ScriptSettingGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env ScriptSettingGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/settings", query.AccountID, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ScriptSettingEditResponse struct { + // List of bindings attached to this Worker + Bindings []ScriptSettingEditResponseBinding `json:"bindings"` + // Opt your Worker into changes after this date + CompatibilityDate string `json:"compatibility_date"` + // Opt your Worker into specific changes + CompatibilityFlags []string `json:"compatibility_flags"` + // Whether Logpush is turned on for the Worker. + Logpush bool `json:"logpush"` + // Migrations to apply for Durable Objects associated with this Worker. + Migrations ScriptSettingEditResponseMigrations `json:"migrations"` + Placement ScriptSettingEditResponsePlacement `json:"placement"` + // Tags to help you manage your Workers + Tags []string `json:"tags"` + // List of Workers that will consume logs from the attached Worker. + TailConsumers []ScriptSettingEditResponseTailConsumer `json:"tail_consumers"` + // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). + UsageModel string `json:"usage_model"` + JSON scriptSettingEditResponseJSON `json:"-"` +} + +// scriptSettingEditResponseJSON contains the JSON metadata for the struct +// [ScriptSettingEditResponse] +type scriptSettingEditResponseJSON struct { + Bindings apijson.Field + CompatibilityDate apijson.Field + CompatibilityFlags apijson.Field + Logpush apijson.Field + Migrations apijson.Field + Placement apijson.Field + Tags apijson.Field + TailConsumers apijson.Field + UsageModel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseJSON) RawJSON() string { + return r.raw +} + +// A binding to allow the Worker to communicate with resources +// +// Union satisfied by +// [workers.ScriptSettingEditResponseBindingsWorkersKVNamespaceBinding], +// [workers.ScriptSettingEditResponseBindingsWorkersServiceBinding], +// [workers.ScriptSettingEditResponseBindingsWorkersDoBinding], +// [workers.ScriptSettingEditResponseBindingsWorkersR2Binding], +// [workers.ScriptSettingEditResponseBindingsWorkersQueueBinding], +// [workers.ScriptSettingEditResponseBindingsWorkersD1Binding], +// [workers.ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding] or +// [workers.ScriptSettingEditResponseBindingsWorkersMTLSCertBinding]. +type ScriptSettingEditResponseBinding interface { + implementsWorkersScriptSettingEditResponseBinding() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ScriptSettingEditResponseBinding)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingEditResponseBindingsWorkersKVNamespaceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingEditResponseBindingsWorkersServiceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingEditResponseBindingsWorkersDoBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingEditResponseBindingsWorkersR2Binding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingEditResponseBindingsWorkersQueueBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingEditResponseBindingsWorkersD1Binding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingEditResponseBindingsWorkersMTLSCertBinding{}), + }, + ) +} + +type ScriptSettingEditResponseBindingsWorkersKVNamespaceBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Namespace identifier tag. + NamespaceID string `json:"namespace_id,required"` + // The class of resource that the binding provides. + Type ScriptSettingEditResponseBindingsWorkersKVNamespaceBindingType `json:"type,required"` + JSON scriptSettingEditResponseBindingsWorkersKVNamespaceBindingJSON `json:"-"` +} + +// scriptSettingEditResponseBindingsWorkersKVNamespaceBindingJSON contains the JSON +// metadata for the struct +// [ScriptSettingEditResponseBindingsWorkersKVNamespaceBinding] +type scriptSettingEditResponseBindingsWorkersKVNamespaceBindingJSON struct { + Name apijson.Field + NamespaceID apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseBindingsWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseBindingsWorkersKVNamespaceBindingJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingEditResponseBindingsWorkersKVNamespaceBinding) implementsWorkersScriptSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingEditResponseBindingsWorkersKVNamespaceBindingType string + +const ( + ScriptSettingEditResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace ScriptSettingEditResponseBindingsWorkersKVNamespaceBindingType = "kv_namespace" +) + +type ScriptSettingEditResponseBindingsWorkersServiceBinding struct { + // Optional environment if the Worker utilizes one. + Environment string `json:"environment,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Name of Worker to bind to + Service string `json:"service,required"` + // The class of resource that the binding provides. + Type ScriptSettingEditResponseBindingsWorkersServiceBindingType `json:"type,required"` + JSON scriptSettingEditResponseBindingsWorkersServiceBindingJSON `json:"-"` +} + +// scriptSettingEditResponseBindingsWorkersServiceBindingJSON contains the JSON +// metadata for the struct [ScriptSettingEditResponseBindingsWorkersServiceBinding] +type scriptSettingEditResponseBindingsWorkersServiceBindingJSON struct { + Environment apijson.Field + Name apijson.Field + Service apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseBindingsWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseBindingsWorkersServiceBindingJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingEditResponseBindingsWorkersServiceBinding) implementsWorkersScriptSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingEditResponseBindingsWorkersServiceBindingType string + +const ( + ScriptSettingEditResponseBindingsWorkersServiceBindingTypeService ScriptSettingEditResponseBindingsWorkersServiceBindingType = "service" +) + +type ScriptSettingEditResponseBindingsWorkersDoBinding struct { + // The exported class name of the Durable Object + ClassName string `json:"class_name,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type ScriptSettingEditResponseBindingsWorkersDoBindingType `json:"type,required"` + // The environment of the script_name to bind to + Environment string `json:"environment"` + // Namespace identifier tag. + NamespaceID string `json:"namespace_id"` + // The script where the Durable Object is defined, if it is external to this Worker + ScriptName string `json:"script_name"` + JSON scriptSettingEditResponseBindingsWorkersDoBindingJSON `json:"-"` +} + +// scriptSettingEditResponseBindingsWorkersDoBindingJSON contains the JSON metadata +// for the struct [ScriptSettingEditResponseBindingsWorkersDoBinding] +type scriptSettingEditResponseBindingsWorkersDoBindingJSON struct { + ClassName apijson.Field + Name apijson.Field + Type apijson.Field + Environment apijson.Field + NamespaceID apijson.Field + ScriptName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseBindingsWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseBindingsWorkersDoBindingJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingEditResponseBindingsWorkersDoBinding) implementsWorkersScriptSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingEditResponseBindingsWorkersDoBindingType string + +const ( + ScriptSettingEditResponseBindingsWorkersDoBindingTypeDurableObjectNamespace ScriptSettingEditResponseBindingsWorkersDoBindingType = "durable_object_namespace" +) + +type ScriptSettingEditResponseBindingsWorkersR2Binding struct { + // R2 bucket to bind to + BucketName string `json:"bucket_name,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type ScriptSettingEditResponseBindingsWorkersR2BindingType `json:"type,required"` + JSON scriptSettingEditResponseBindingsWorkersR2BindingJSON `json:"-"` +} + +// scriptSettingEditResponseBindingsWorkersR2BindingJSON contains the JSON metadata +// for the struct [ScriptSettingEditResponseBindingsWorkersR2Binding] +type scriptSettingEditResponseBindingsWorkersR2BindingJSON struct { + BucketName apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseBindingsWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseBindingsWorkersR2BindingJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingEditResponseBindingsWorkersR2Binding) implementsWorkersScriptSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingEditResponseBindingsWorkersR2BindingType string + +const ( + ScriptSettingEditResponseBindingsWorkersR2BindingTypeR2Bucket ScriptSettingEditResponseBindingsWorkersR2BindingType = "r2_bucket" +) + +type ScriptSettingEditResponseBindingsWorkersQueueBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Name of the Queue to bind to + QueueName string `json:"queue_name,required"` + // The class of resource that the binding provides. + Type ScriptSettingEditResponseBindingsWorkersQueueBindingType `json:"type,required"` + JSON scriptSettingEditResponseBindingsWorkersQueueBindingJSON `json:"-"` +} + +// scriptSettingEditResponseBindingsWorkersQueueBindingJSON contains the JSON +// metadata for the struct [ScriptSettingEditResponseBindingsWorkersQueueBinding] +type scriptSettingEditResponseBindingsWorkersQueueBindingJSON struct { + Name apijson.Field + QueueName apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseBindingsWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseBindingsWorkersQueueBindingJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingEditResponseBindingsWorkersQueueBinding) implementsWorkersScriptSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingEditResponseBindingsWorkersQueueBindingType string + +const ( + ScriptSettingEditResponseBindingsWorkersQueueBindingTypeQueue ScriptSettingEditResponseBindingsWorkersQueueBindingType = "queue" +) + +type ScriptSettingEditResponseBindingsWorkersD1Binding struct { + // ID of the D1 database to bind to + ID string `json:"id,required"` + // A JavaScript variable name for the binding. + Binding string `json:"binding,required"` + // The name of the D1 database associated with the 'id' provided. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type ScriptSettingEditResponseBindingsWorkersD1BindingType `json:"type,required"` + JSON scriptSettingEditResponseBindingsWorkersD1BindingJSON `json:"-"` +} + +// scriptSettingEditResponseBindingsWorkersD1BindingJSON contains the JSON metadata +// for the struct [ScriptSettingEditResponseBindingsWorkersD1Binding] +type scriptSettingEditResponseBindingsWorkersD1BindingJSON struct { + ID apijson.Field + Binding apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseBindingsWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseBindingsWorkersD1BindingJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingEditResponseBindingsWorkersD1Binding) implementsWorkersScriptSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingEditResponseBindingsWorkersD1BindingType string + +const ( + ScriptSettingEditResponseBindingsWorkersD1BindingTypeD1 ScriptSettingEditResponseBindingsWorkersD1BindingType = "d1" +) + +type ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Namespace to bind to + Namespace string `json:"namespace,required"` + // The class of resource that the binding provides. + Type ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingType `json:"type,required"` + // Outbound worker + Outbound ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound `json:"outbound"` + JSON scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON `json:"-"` +} + +// scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON contains +// the JSON metadata for the struct +// [ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding] +type scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON struct { + Name apijson.Field + Namespace apijson.Field + Type apijson.Field + Outbound apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding) implementsWorkersScriptSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingType string + +const ( + ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" +) + +// Outbound worker +type ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound struct { + // Pass information from the Dispatch Worker to the Outbound Worker through the + // parameters + Params []string `json:"params"` + // Outbound worker + Worker ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` + JSON scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` +} + +// scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON +// contains the JSON metadata for the struct +// [ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound] +type scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON struct { + Params apijson.Field + Worker apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { + return r.raw +} + +// Outbound worker +type ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { + // Environment of the outbound worker + Environment string `json:"environment"` + // Name of the outbound worker + Service string `json:"service"` + JSON scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` +} + +// scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON +// contains the JSON metadata for the struct +// [ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker] +type scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { + Environment apijson.Field + Service apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { + return r.raw +} + +type ScriptSettingEditResponseBindingsWorkersMTLSCertBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type ScriptSettingEditResponseBindingsWorkersMTLSCertBindingType `json:"type,required"` + // ID of the certificate to bind to + CertificateID string `json:"certificate_id"` + JSON scriptSettingEditResponseBindingsWorkersMTLSCertBindingJSON `json:"-"` +} + +// scriptSettingEditResponseBindingsWorkersMTLSCertBindingJSON contains the JSON +// metadata for the struct +// [ScriptSettingEditResponseBindingsWorkersMTLSCertBinding] +type scriptSettingEditResponseBindingsWorkersMTLSCertBindingJSON struct { + Name apijson.Field + Type apijson.Field + CertificateID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseBindingsWorkersMTLSCertBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseBindingsWorkersMTLSCertBindingJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingEditResponseBindingsWorkersMTLSCertBinding) implementsWorkersScriptSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingEditResponseBindingsWorkersMTLSCertBindingType string + +const ( + ScriptSettingEditResponseBindingsWorkersMTLSCertBindingTypeMTLSCertificate ScriptSettingEditResponseBindingsWorkersMTLSCertBindingType = "mtls_certificate" +) + +// Migrations to apply for Durable Objects associated with this Worker. +// +// Union satisfied by +// [workers.ScriptSettingEditResponseMigrationsWorkersSingleStepMigrations] or +// [workers.ScriptSettingEditResponseMigrationsWorkersSteppedMigrations]. +type ScriptSettingEditResponseMigrations interface { + implementsWorkersScriptSettingEditResponseMigrations() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ScriptSettingEditResponseMigrations)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingEditResponseMigrationsWorkersSingleStepMigrations{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingEditResponseMigrationsWorkersSteppedMigrations{}), + }, + ) +} + +// A single set of migrations to apply. +type ScriptSettingEditResponseMigrationsWorkersSingleStepMigrations struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses []string `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses []string `json:"new_classes"` + // Tag to set as the latest migration tag. + NewTag string `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag string `json:"old_tag"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses []ScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses []ScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass `json:"transferred_classes"` + JSON scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON `json:"-"` +} + +// scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON contains the +// JSON metadata for the struct +// [ScriptSettingEditResponseMigrationsWorkersSingleStepMigrations] +type scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON struct { + DeletedClasses apijson.Field + NewClasses apijson.Field + NewTag apijson.Field + OldTag apijson.Field + RenamedClasses apijson.Field + TransferredClasses apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseMigrationsWorkersSingleStepMigrations) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingEditResponseMigrationsWorkersSingleStepMigrations) implementsWorkersScriptSettingEditResponseMigrations() { +} + +type ScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass struct { + From string `json:"from"` + To string `json:"to"` + JSON scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON `json:"-"` +} + +// scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON +// contains the JSON metadata for the struct +// [ScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass] +type scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON struct { + From apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON) RawJSON() string { + return r.raw +} + +type ScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass struct { + From string `json:"from"` + FromScript string `json:"from_script"` + To string `json:"to"` + JSON scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON `json:"-"` +} + +// scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON +// contains the JSON metadata for the struct +// [ScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass] +type scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON struct { + From apijson.Field + FromScript apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON) RawJSON() string { + return r.raw +} + +type ScriptSettingEditResponseMigrationsWorkersSteppedMigrations struct { + // Tag to set as the latest migration tag. + NewTag string `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag string `json:"old_tag"` + // Migrations to apply in order. + Steps []ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStep `json:"steps"` + JSON scriptSettingEditResponseMigrationsWorkersSteppedMigrationsJSON `json:"-"` +} + +// scriptSettingEditResponseMigrationsWorkersSteppedMigrationsJSON contains the +// JSON metadata for the struct +// [ScriptSettingEditResponseMigrationsWorkersSteppedMigrations] +type scriptSettingEditResponseMigrationsWorkersSteppedMigrationsJSON struct { + NewTag apijson.Field + OldTag apijson.Field + Steps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseMigrationsWorkersSteppedMigrations) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseMigrationsWorkersSteppedMigrationsJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingEditResponseMigrationsWorkersSteppedMigrations) implementsWorkersScriptSettingEditResponseMigrations() { +} + +type ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStep struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses []string `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses []string `json:"new_classes"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses []ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses []ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass `json:"transferred_classes"` + JSON scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON `json:"-"` +} + +// scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON contains the +// JSON metadata for the struct +// [ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStep] +type scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON struct { + DeletedClasses apijson.Field + NewClasses apijson.Field + RenamedClasses apijson.Field + TransferredClasses apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStep) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON) RawJSON() string { + return r.raw +} + +type ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { + From string `json:"from"` + To string `json:"to"` + JSON scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON `json:"-"` +} + +// scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON +// contains the JSON metadata for the struct +// [ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass] +type scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON struct { + From apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON) RawJSON() string { + return r.raw +} + +type ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { + From string `json:"from"` + FromScript string `json:"from_script"` + To string `json:"to"` + JSON scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON `json:"-"` +} + +// scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON +// contains the JSON metadata for the struct +// [ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass] +type scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON struct { + From apijson.Field + FromScript apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON) RawJSON() string { + return r.raw +} + +type ScriptSettingEditResponsePlacement struct { + // Enables + // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + // Only `"smart"` is currently supported + Mode ScriptSettingEditResponsePlacementMode `json:"mode"` + JSON scriptSettingEditResponsePlacementJSON `json:"-"` +} + +// scriptSettingEditResponsePlacementJSON contains the JSON metadata for the struct +// [ScriptSettingEditResponsePlacement] +type scriptSettingEditResponsePlacementJSON struct { + Mode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponsePlacement) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponsePlacementJSON) RawJSON() string { + return r.raw +} + +// Enables +// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). +// Only `"smart"` is currently supported +type ScriptSettingEditResponsePlacementMode string + +const ( + ScriptSettingEditResponsePlacementModeSmart ScriptSettingEditResponsePlacementMode = "smart" +) + +// A reference to a script that will consume logs from the attached Worker. +type ScriptSettingEditResponseTailConsumer struct { + // Name of Worker that is to be the consumer. + Service string `json:"service,required"` + // Optional environment if the Worker utilizes one. + Environment string `json:"environment"` + // Optional dispatch namespace the script belongs to. + Namespace string `json:"namespace"` + JSON scriptSettingEditResponseTailConsumerJSON `json:"-"` +} + +// scriptSettingEditResponseTailConsumerJSON contains the JSON metadata for the +// struct [ScriptSettingEditResponseTailConsumer] +type scriptSettingEditResponseTailConsumerJSON struct { + Service apijson.Field + Environment apijson.Field + Namespace apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseTailConsumerJSON) RawJSON() string { + return r.raw +} + +type ScriptSettingGetResponse struct { + // List of bindings attached to this Worker + Bindings []ScriptSettingGetResponseBinding `json:"bindings"` + // Opt your Worker into changes after this date + CompatibilityDate string `json:"compatibility_date"` + // Opt your Worker into specific changes + CompatibilityFlags []string `json:"compatibility_flags"` + // Whether Logpush is turned on for the Worker. + Logpush bool `json:"logpush"` + // Migrations to apply for Durable Objects associated with this Worker. + Migrations ScriptSettingGetResponseMigrations `json:"migrations"` + Placement ScriptSettingGetResponsePlacement `json:"placement"` + // Tags to help you manage your Workers + Tags []string `json:"tags"` + // List of Workers that will consume logs from the attached Worker. + TailConsumers []ScriptSettingGetResponseTailConsumer `json:"tail_consumers"` + // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). + UsageModel string `json:"usage_model"` + JSON scriptSettingGetResponseJSON `json:"-"` +} + +// scriptSettingGetResponseJSON contains the JSON metadata for the struct +// [ScriptSettingGetResponse] +type scriptSettingGetResponseJSON struct { + Bindings apijson.Field + CompatibilityDate apijson.Field + CompatibilityFlags apijson.Field + Logpush apijson.Field + Migrations apijson.Field + Placement apijson.Field + Tags apijson.Field + TailConsumers apijson.Field + UsageModel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseJSON) RawJSON() string { + return r.raw +} + +// A binding to allow the Worker to communicate with resources +// +// Union satisfied by +// [workers.ScriptSettingGetResponseBindingsWorkersKVNamespaceBinding], +// [workers.ScriptSettingGetResponseBindingsWorkersServiceBinding], +// [workers.ScriptSettingGetResponseBindingsWorkersDoBinding], +// [workers.ScriptSettingGetResponseBindingsWorkersR2Binding], +// [workers.ScriptSettingGetResponseBindingsWorkersQueueBinding], +// [workers.ScriptSettingGetResponseBindingsWorkersD1Binding], +// [workers.ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding] or +// [workers.ScriptSettingGetResponseBindingsWorkersMTLSCertBinding]. +type ScriptSettingGetResponseBinding interface { + implementsWorkersScriptSettingGetResponseBinding() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ScriptSettingGetResponseBinding)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingGetResponseBindingsWorkersKVNamespaceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingGetResponseBindingsWorkersServiceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingGetResponseBindingsWorkersDoBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingGetResponseBindingsWorkersR2Binding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingGetResponseBindingsWorkersQueueBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingGetResponseBindingsWorkersD1Binding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingGetResponseBindingsWorkersMTLSCertBinding{}), + }, + ) +} + +type ScriptSettingGetResponseBindingsWorkersKVNamespaceBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Namespace identifier tag. + NamespaceID string `json:"namespace_id,required"` + // The class of resource that the binding provides. + Type ScriptSettingGetResponseBindingsWorkersKVNamespaceBindingType `json:"type,required"` + JSON scriptSettingGetResponseBindingsWorkersKVNamespaceBindingJSON `json:"-"` +} + +// scriptSettingGetResponseBindingsWorkersKVNamespaceBindingJSON contains the JSON +// metadata for the struct +// [ScriptSettingGetResponseBindingsWorkersKVNamespaceBinding] +type scriptSettingGetResponseBindingsWorkersKVNamespaceBindingJSON struct { + Name apijson.Field + NamespaceID apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseBindingsWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseBindingsWorkersKVNamespaceBindingJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingGetResponseBindingsWorkersKVNamespaceBinding) implementsWorkersScriptSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingGetResponseBindingsWorkersKVNamespaceBindingType string + +const ( + ScriptSettingGetResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace ScriptSettingGetResponseBindingsWorkersKVNamespaceBindingType = "kv_namespace" +) + +type ScriptSettingGetResponseBindingsWorkersServiceBinding struct { + // Optional environment if the Worker utilizes one. + Environment string `json:"environment,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Name of Worker to bind to + Service string `json:"service,required"` + // The class of resource that the binding provides. + Type ScriptSettingGetResponseBindingsWorkersServiceBindingType `json:"type,required"` + JSON scriptSettingGetResponseBindingsWorkersServiceBindingJSON `json:"-"` +} + +// scriptSettingGetResponseBindingsWorkersServiceBindingJSON contains the JSON +// metadata for the struct [ScriptSettingGetResponseBindingsWorkersServiceBinding] +type scriptSettingGetResponseBindingsWorkersServiceBindingJSON struct { + Environment apijson.Field + Name apijson.Field + Service apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseBindingsWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseBindingsWorkersServiceBindingJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingGetResponseBindingsWorkersServiceBinding) implementsWorkersScriptSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingGetResponseBindingsWorkersServiceBindingType string + +const ( + ScriptSettingGetResponseBindingsWorkersServiceBindingTypeService ScriptSettingGetResponseBindingsWorkersServiceBindingType = "service" +) + +type ScriptSettingGetResponseBindingsWorkersDoBinding struct { + // The exported class name of the Durable Object + ClassName string `json:"class_name,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type ScriptSettingGetResponseBindingsWorkersDoBindingType `json:"type,required"` + // The environment of the script_name to bind to + Environment string `json:"environment"` + // Namespace identifier tag. + NamespaceID string `json:"namespace_id"` + // The script where the Durable Object is defined, if it is external to this Worker + ScriptName string `json:"script_name"` + JSON scriptSettingGetResponseBindingsWorkersDoBindingJSON `json:"-"` +} + +// scriptSettingGetResponseBindingsWorkersDoBindingJSON contains the JSON metadata +// for the struct [ScriptSettingGetResponseBindingsWorkersDoBinding] +type scriptSettingGetResponseBindingsWorkersDoBindingJSON struct { + ClassName apijson.Field + Name apijson.Field + Type apijson.Field + Environment apijson.Field + NamespaceID apijson.Field + ScriptName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseBindingsWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseBindingsWorkersDoBindingJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingGetResponseBindingsWorkersDoBinding) implementsWorkersScriptSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingGetResponseBindingsWorkersDoBindingType string + +const ( + ScriptSettingGetResponseBindingsWorkersDoBindingTypeDurableObjectNamespace ScriptSettingGetResponseBindingsWorkersDoBindingType = "durable_object_namespace" +) + +type ScriptSettingGetResponseBindingsWorkersR2Binding struct { + // R2 bucket to bind to + BucketName string `json:"bucket_name,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type ScriptSettingGetResponseBindingsWorkersR2BindingType `json:"type,required"` + JSON scriptSettingGetResponseBindingsWorkersR2BindingJSON `json:"-"` +} + +// scriptSettingGetResponseBindingsWorkersR2BindingJSON contains the JSON metadata +// for the struct [ScriptSettingGetResponseBindingsWorkersR2Binding] +type scriptSettingGetResponseBindingsWorkersR2BindingJSON struct { + BucketName apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseBindingsWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseBindingsWorkersR2BindingJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingGetResponseBindingsWorkersR2Binding) implementsWorkersScriptSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingGetResponseBindingsWorkersR2BindingType string + +const ( + ScriptSettingGetResponseBindingsWorkersR2BindingTypeR2Bucket ScriptSettingGetResponseBindingsWorkersR2BindingType = "r2_bucket" +) + +type ScriptSettingGetResponseBindingsWorkersQueueBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Name of the Queue to bind to + QueueName string `json:"queue_name,required"` + // The class of resource that the binding provides. + Type ScriptSettingGetResponseBindingsWorkersQueueBindingType `json:"type,required"` + JSON scriptSettingGetResponseBindingsWorkersQueueBindingJSON `json:"-"` +} + +// scriptSettingGetResponseBindingsWorkersQueueBindingJSON contains the JSON +// metadata for the struct [ScriptSettingGetResponseBindingsWorkersQueueBinding] +type scriptSettingGetResponseBindingsWorkersQueueBindingJSON struct { + Name apijson.Field + QueueName apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseBindingsWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseBindingsWorkersQueueBindingJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingGetResponseBindingsWorkersQueueBinding) implementsWorkersScriptSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingGetResponseBindingsWorkersQueueBindingType string + +const ( + ScriptSettingGetResponseBindingsWorkersQueueBindingTypeQueue ScriptSettingGetResponseBindingsWorkersQueueBindingType = "queue" +) + +type ScriptSettingGetResponseBindingsWorkersD1Binding struct { + // ID of the D1 database to bind to + ID string `json:"id,required"` + // A JavaScript variable name for the binding. + Binding string `json:"binding,required"` + // The name of the D1 database associated with the 'id' provided. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type ScriptSettingGetResponseBindingsWorkersD1BindingType `json:"type,required"` + JSON scriptSettingGetResponseBindingsWorkersD1BindingJSON `json:"-"` +} + +// scriptSettingGetResponseBindingsWorkersD1BindingJSON contains the JSON metadata +// for the struct [ScriptSettingGetResponseBindingsWorkersD1Binding] +type scriptSettingGetResponseBindingsWorkersD1BindingJSON struct { + ID apijson.Field + Binding apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseBindingsWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseBindingsWorkersD1BindingJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingGetResponseBindingsWorkersD1Binding) implementsWorkersScriptSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingGetResponseBindingsWorkersD1BindingType string + +const ( + ScriptSettingGetResponseBindingsWorkersD1BindingTypeD1 ScriptSettingGetResponseBindingsWorkersD1BindingType = "d1" +) + +type ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Namespace to bind to + Namespace string `json:"namespace,required"` + // The class of resource that the binding provides. + Type ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingType `json:"type,required"` + // Outbound worker + Outbound ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound `json:"outbound"` + JSON scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON `json:"-"` +} + +// scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON contains the +// JSON metadata for the struct +// [ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding] +type scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON struct { + Name apijson.Field + Namespace apijson.Field + Type apijson.Field + Outbound apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding) implementsWorkersScriptSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingType string + +const ( + ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" +) + +// Outbound worker +type ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound struct { + // Pass information from the Dispatch Worker to the Outbound Worker through the + // parameters + Params []string `json:"params"` + // Outbound worker + Worker ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` + JSON scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` +} + +// scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON +// contains the JSON metadata for the struct +// [ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound] +type scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON struct { + Params apijson.Field + Worker apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { + return r.raw +} + +// Outbound worker +type ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { + // Environment of the outbound worker + Environment string `json:"environment"` + // Name of the outbound worker + Service string `json:"service"` + JSON scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` +} + +// scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON +// contains the JSON metadata for the struct +// [ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker] +type scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { + Environment apijson.Field + Service apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { + return r.raw +} + +type ScriptSettingGetResponseBindingsWorkersMTLSCertBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type ScriptSettingGetResponseBindingsWorkersMTLSCertBindingType `json:"type,required"` + // ID of the certificate to bind to + CertificateID string `json:"certificate_id"` + JSON scriptSettingGetResponseBindingsWorkersMTLSCertBindingJSON `json:"-"` +} + +// scriptSettingGetResponseBindingsWorkersMTLSCertBindingJSON contains the JSON +// metadata for the struct [ScriptSettingGetResponseBindingsWorkersMTLSCertBinding] +type scriptSettingGetResponseBindingsWorkersMTLSCertBindingJSON struct { + Name apijson.Field + Type apijson.Field + CertificateID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseBindingsWorkersMTLSCertBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseBindingsWorkersMTLSCertBindingJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingGetResponseBindingsWorkersMTLSCertBinding) implementsWorkersScriptSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingGetResponseBindingsWorkersMTLSCertBindingType string + +const ( + ScriptSettingGetResponseBindingsWorkersMTLSCertBindingTypeMTLSCertificate ScriptSettingGetResponseBindingsWorkersMTLSCertBindingType = "mtls_certificate" +) + +// Migrations to apply for Durable Objects associated with this Worker. +// +// Union satisfied by +// [workers.ScriptSettingGetResponseMigrationsWorkersSingleStepMigrations] or +// [workers.ScriptSettingGetResponseMigrationsWorkersSteppedMigrations]. +type ScriptSettingGetResponseMigrations interface { + implementsWorkersScriptSettingGetResponseMigrations() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ScriptSettingGetResponseMigrations)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingGetResponseMigrationsWorkersSingleStepMigrations{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptSettingGetResponseMigrationsWorkersSteppedMigrations{}), + }, + ) +} + +// A single set of migrations to apply. +type ScriptSettingGetResponseMigrationsWorkersSingleStepMigrations struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses []string `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses []string `json:"new_classes"` + // Tag to set as the latest migration tag. + NewTag string `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag string `json:"old_tag"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses []ScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses []ScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass `json:"transferred_classes"` + JSON scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON `json:"-"` +} + +// scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON contains the +// JSON metadata for the struct +// [ScriptSettingGetResponseMigrationsWorkersSingleStepMigrations] +type scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON struct { + DeletedClasses apijson.Field + NewClasses apijson.Field + NewTag apijson.Field + OldTag apijson.Field + RenamedClasses apijson.Field + TransferredClasses apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseMigrationsWorkersSingleStepMigrations) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingGetResponseMigrationsWorkersSingleStepMigrations) implementsWorkersScriptSettingGetResponseMigrations() { +} + +type ScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass struct { + From string `json:"from"` + To string `json:"to"` + JSON scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON `json:"-"` +} + +// scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON +// contains the JSON metadata for the struct +// [ScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass] +type scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON struct { + From apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON) RawJSON() string { + return r.raw +} + +type ScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass struct { + From string `json:"from"` + FromScript string `json:"from_script"` + To string `json:"to"` + JSON scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON `json:"-"` +} + +// scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON +// contains the JSON metadata for the struct +// [ScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass] +type scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON struct { + From apijson.Field + FromScript apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON) RawJSON() string { + return r.raw +} + +type ScriptSettingGetResponseMigrationsWorkersSteppedMigrations struct { + // Tag to set as the latest migration tag. + NewTag string `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag string `json:"old_tag"` + // Migrations to apply in order. + Steps []ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStep `json:"steps"` + JSON scriptSettingGetResponseMigrationsWorkersSteppedMigrationsJSON `json:"-"` +} + +// scriptSettingGetResponseMigrationsWorkersSteppedMigrationsJSON contains the JSON +// metadata for the struct +// [ScriptSettingGetResponseMigrationsWorkersSteppedMigrations] +type scriptSettingGetResponseMigrationsWorkersSteppedMigrationsJSON struct { + NewTag apijson.Field + OldTag apijson.Field + Steps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseMigrationsWorkersSteppedMigrations) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseMigrationsWorkersSteppedMigrationsJSON) RawJSON() string { + return r.raw +} + +func (r ScriptSettingGetResponseMigrationsWorkersSteppedMigrations) implementsWorkersScriptSettingGetResponseMigrations() { +} + +type ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStep struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses []string `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses []string `json:"new_classes"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses []ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses []ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass `json:"transferred_classes"` + JSON scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON `json:"-"` +} + +// scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON contains the +// JSON metadata for the struct +// [ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStep] +type scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON struct { + DeletedClasses apijson.Field + NewClasses apijson.Field + RenamedClasses apijson.Field + TransferredClasses apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStep) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON) RawJSON() string { + return r.raw +} + +type ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { + From string `json:"from"` + To string `json:"to"` + JSON scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON `json:"-"` +} + +// scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON +// contains the JSON metadata for the struct +// [ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass] +type scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON struct { + From apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON) RawJSON() string { + return r.raw +} + +type ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { + From string `json:"from"` + FromScript string `json:"from_script"` + To string `json:"to"` + JSON scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON `json:"-"` +} + +// scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON +// contains the JSON metadata for the struct +// [ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass] +type scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON struct { + From apijson.Field + FromScript apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON) RawJSON() string { + return r.raw +} + +type ScriptSettingGetResponsePlacement struct { + // Enables + // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + // Only `"smart"` is currently supported + Mode ScriptSettingGetResponsePlacementMode `json:"mode"` + JSON scriptSettingGetResponsePlacementJSON `json:"-"` +} + +// scriptSettingGetResponsePlacementJSON contains the JSON metadata for the struct +// [ScriptSettingGetResponsePlacement] +type scriptSettingGetResponsePlacementJSON struct { + Mode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponsePlacement) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponsePlacementJSON) RawJSON() string { + return r.raw +} + +// Enables +// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). +// Only `"smart"` is currently supported +type ScriptSettingGetResponsePlacementMode string + +const ( + ScriptSettingGetResponsePlacementModeSmart ScriptSettingGetResponsePlacementMode = "smart" +) + +// A reference to a script that will consume logs from the attached Worker. +type ScriptSettingGetResponseTailConsumer struct { + // Name of Worker that is to be the consumer. + Service string `json:"service,required"` + // Optional environment if the Worker utilizes one. + Environment string `json:"environment"` + // Optional dispatch namespace the script belongs to. + Namespace string `json:"namespace"` + JSON scriptSettingGetResponseTailConsumerJSON `json:"-"` +} + +// scriptSettingGetResponseTailConsumerJSON contains the JSON metadata for the +// struct [ScriptSettingGetResponseTailConsumer] +type scriptSettingGetResponseTailConsumerJSON struct { + Service apijson.Field + Environment apijson.Field + Namespace apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseTailConsumerJSON) RawJSON() string { + return r.raw +} + +type ScriptSettingEditParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Settings param.Field[ScriptSettingEditParamsSettings] `json:"settings"` +} + +func (r ScriptSettingEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptSettingEditParamsSettings struct { + Errors param.Field[[]ScriptSettingEditParamsSettingsError] `json:"errors,required"` + Messages param.Field[[]ScriptSettingEditParamsSettingsMessage] `json:"messages,required"` + Result param.Field[ScriptSettingEditParamsSettingsResult] `json:"result,required"` + // Whether the API call was successful + Success param.Field[ScriptSettingEditParamsSettingsSuccess] `json:"success,required"` +} + +func (r ScriptSettingEditParamsSettings) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptSettingEditParamsSettingsError struct { + Code param.Field[int64] `json:"code,required"` + Message param.Field[string] `json:"message,required"` +} + +func (r ScriptSettingEditParamsSettingsError) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptSettingEditParamsSettingsMessage struct { + Code param.Field[int64] `json:"code,required"` + Message param.Field[string] `json:"message,required"` +} + +func (r ScriptSettingEditParamsSettingsMessage) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptSettingEditParamsSettingsResult struct { + // List of bindings attached to this Worker + Bindings param.Field[[]ScriptSettingEditParamsSettingsResultBinding] `json:"bindings"` + // Opt your Worker into changes after this date + CompatibilityDate param.Field[string] `json:"compatibility_date"` + // Opt your Worker into specific changes + CompatibilityFlags param.Field[[]string] `json:"compatibility_flags"` + // Whether Logpush is turned on for the Worker. + Logpush param.Field[bool] `json:"logpush"` + // Migrations to apply for Durable Objects associated with this Worker. + Migrations param.Field[ScriptSettingEditParamsSettingsResultMigrations] `json:"migrations"` + Placement param.Field[ScriptSettingEditParamsSettingsResultPlacement] `json:"placement"` + // Tags to help you manage your Workers + Tags param.Field[[]string] `json:"tags"` + // List of Workers that will consume logs from the attached Worker. + TailConsumers param.Field[[]ScriptSettingEditParamsSettingsResultTailConsumer] `json:"tail_consumers"` + // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). + UsageModel param.Field[string] `json:"usage_model"` +} + +func (r ScriptSettingEditParamsSettingsResult) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A binding to allow the Worker to communicate with resources +// +// Satisfied by +// [workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding], +// [workers.ScriptSettingEditParamsSettingsResultBindingsWorkersServiceBinding], +// [workers.ScriptSettingEditParamsSettingsResultBindingsWorkersDoBinding], +// [workers.ScriptSettingEditParamsSettingsResultBindingsWorkersR2Binding], +// [workers.ScriptSettingEditParamsSettingsResultBindingsWorkersQueueBinding], +// [workers.ScriptSettingEditParamsSettingsResultBindingsWorkersD1Binding], +// [workers.ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBinding], +// [workers.ScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCertBinding]. +type ScriptSettingEditParamsSettingsResultBinding interface { + implementsWorkersScriptSettingEditParamsSettingsResultBinding() +} + +type ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding struct { + // The class of resource that the binding provides. + Type param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingType] `json:"type,required"` +} + +func (r ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding) implementsWorkersScriptSettingEditParamsSettingsResultBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingType string + +const ( + ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingType = "kv_namespace" +) + +type ScriptSettingEditParamsSettingsResultBindingsWorkersServiceBinding struct { + // Optional environment if the Worker utilizes one. + Environment param.Field[string] `json:"environment,required"` + // Name of Worker to bind to + Service param.Field[string] `json:"service,required"` + // The class of resource that the binding provides. + Type param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersServiceBindingType] `json:"type,required"` +} + +func (r ScriptSettingEditParamsSettingsResultBindingsWorkersServiceBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ScriptSettingEditParamsSettingsResultBindingsWorkersServiceBinding) implementsWorkersScriptSettingEditParamsSettingsResultBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingEditParamsSettingsResultBindingsWorkersServiceBindingType string + +const ( + ScriptSettingEditParamsSettingsResultBindingsWorkersServiceBindingTypeService ScriptSettingEditParamsSettingsResultBindingsWorkersServiceBindingType = "service" +) + +type ScriptSettingEditParamsSettingsResultBindingsWorkersDoBinding struct { + // The exported class name of the Durable Object + ClassName param.Field[string] `json:"class_name,required"` + // The class of resource that the binding provides. + Type param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersDoBindingType] `json:"type,required"` + // The environment of the script_name to bind to + Environment param.Field[string] `json:"environment"` + // The script where the Durable Object is defined, if it is external to this Worker + ScriptName param.Field[string] `json:"script_name"` +} + +func (r ScriptSettingEditParamsSettingsResultBindingsWorkersDoBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ScriptSettingEditParamsSettingsResultBindingsWorkersDoBinding) implementsWorkersScriptSettingEditParamsSettingsResultBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingEditParamsSettingsResultBindingsWorkersDoBindingType string + +const ( + ScriptSettingEditParamsSettingsResultBindingsWorkersDoBindingTypeDurableObjectNamespace ScriptSettingEditParamsSettingsResultBindingsWorkersDoBindingType = "durable_object_namespace" +) + +type ScriptSettingEditParamsSettingsResultBindingsWorkersR2Binding struct { + // R2 bucket to bind to + BucketName param.Field[string] `json:"bucket_name,required"` + // The class of resource that the binding provides. + Type param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersR2BindingType] `json:"type,required"` +} + +func (r ScriptSettingEditParamsSettingsResultBindingsWorkersR2Binding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ScriptSettingEditParamsSettingsResultBindingsWorkersR2Binding) implementsWorkersScriptSettingEditParamsSettingsResultBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingEditParamsSettingsResultBindingsWorkersR2BindingType string + +const ( + ScriptSettingEditParamsSettingsResultBindingsWorkersR2BindingTypeR2Bucket ScriptSettingEditParamsSettingsResultBindingsWorkersR2BindingType = "r2_bucket" +) + +type ScriptSettingEditParamsSettingsResultBindingsWorkersQueueBinding struct { + // Name of the Queue to bind to + QueueName param.Field[string] `json:"queue_name,required"` + // The class of resource that the binding provides. + Type param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersQueueBindingType] `json:"type,required"` +} + +func (r ScriptSettingEditParamsSettingsResultBindingsWorkersQueueBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ScriptSettingEditParamsSettingsResultBindingsWorkersQueueBinding) implementsWorkersScriptSettingEditParamsSettingsResultBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingEditParamsSettingsResultBindingsWorkersQueueBindingType string + +const ( + ScriptSettingEditParamsSettingsResultBindingsWorkersQueueBindingTypeQueue ScriptSettingEditParamsSettingsResultBindingsWorkersQueueBindingType = "queue" +) + +type ScriptSettingEditParamsSettingsResultBindingsWorkersD1Binding struct { + // ID of the D1 database to bind to + ID param.Field[string] `json:"id,required"` + // The name of the D1 database associated with the 'id' provided. + Name param.Field[string] `json:"name,required"` + // The class of resource that the binding provides. + Type param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersD1BindingType] `json:"type,required"` +} + +func (r ScriptSettingEditParamsSettingsResultBindingsWorkersD1Binding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ScriptSettingEditParamsSettingsResultBindingsWorkersD1Binding) implementsWorkersScriptSettingEditParamsSettingsResultBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingEditParamsSettingsResultBindingsWorkersD1BindingType string + +const ( + ScriptSettingEditParamsSettingsResultBindingsWorkersD1BindingTypeD1 ScriptSettingEditParamsSettingsResultBindingsWorkersD1BindingType = "d1" +) + +type ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBinding struct { + // Namespace to bind to + Namespace param.Field[string] `json:"namespace,required"` + // The class of resource that the binding provides. + Type param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingType] `json:"type,required"` + // Outbound worker + Outbound param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingOutbound] `json:"outbound"` +} + +func (r ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBinding) implementsWorkersScriptSettingEditParamsSettingsResultBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingType string + +const ( + ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" +) + +// Outbound worker +type ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingOutbound struct { + // Pass information from the Dispatch Worker to the Outbound Worker through the + // parameters + Params param.Field[[]string] `json:"params"` + // Outbound worker + Worker param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker] `json:"worker"` +} + +func (r ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingOutbound) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Outbound worker +type ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { + // Environment of the outbound worker + Environment param.Field[string] `json:"environment"` + // Name of the outbound worker + Service param.Field[string] `json:"service"` +} + +func (r ScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCertBinding struct { + // The class of resource that the binding provides. + Type param.Field[ScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCertBindingType] `json:"type,required"` + // ID of the certificate to bind to + CertificateID param.Field[string] `json:"certificate_id"` +} + +func (r ScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCertBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCertBinding) implementsWorkersScriptSettingEditParamsSettingsResultBinding() { +} + +// The class of resource that the binding provides. +type ScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCertBindingType string + +const ( + ScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCertBindingTypeMTLSCertificate ScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCertBindingType = "mtls_certificate" +) + +// Migrations to apply for Durable Objects associated with this Worker. +// +// Satisfied by +// [workers.ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrations], +// [workers.ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrations]. +type ScriptSettingEditParamsSettingsResultMigrations interface { + implementsWorkersScriptSettingEditParamsSettingsResultMigrations() +} + +// A single set of migrations to apply. +type ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrations struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses param.Field[[]string] `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses param.Field[[]string] `json:"new_classes"` + // Tag to set as the latest migration tag. + NewTag param.Field[string] `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag param.Field[string] `json:"old_tag"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses param.Field[[]ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsRenamedClass] `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses param.Field[[]ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsTransferredClass] `json:"transferred_classes"` +} + +func (r ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrations) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrations) implementsWorkersScriptSettingEditParamsSettingsResultMigrations() { +} + +type ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsRenamedClass struct { + From param.Field[string] `json:"from"` + To param.Field[string] `json:"to"` +} + +func (r ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsRenamedClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsTransferredClass struct { + From param.Field[string] `json:"from"` + FromScript param.Field[string] `json:"from_script"` + To param.Field[string] `json:"to"` +} + +func (r ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsTransferredClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrations struct { + // Tag to set as the latest migration tag. + NewTag param.Field[string] `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag param.Field[string] `json:"old_tag"` + // Migrations to apply in order. + Steps param.Field[[]ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStep] `json:"steps"` +} + +func (r ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrations) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrations) implementsWorkersScriptSettingEditParamsSettingsResultMigrations() { +} + +type ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStep struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses param.Field[[]string] `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses param.Field[[]string] `json:"new_classes"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses param.Field[[]ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass] `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses param.Field[[]ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass] `json:"transferred_classes"` +} + +func (r ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStep) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { + From param.Field[string] `json:"from"` + To param.Field[string] `json:"to"` +} + +func (r ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { + From param.Field[string] `json:"from"` + FromScript param.Field[string] `json:"from_script"` + To param.Field[string] `json:"to"` +} + +func (r ScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ScriptSettingEditParamsSettingsResultPlacement struct { + // Enables + // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + // Only `"smart"` is currently supported + Mode param.Field[ScriptSettingEditParamsSettingsResultPlacementMode] `json:"mode"` +} + +func (r ScriptSettingEditParamsSettingsResultPlacement) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enables +// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). +// Only `"smart"` is currently supported +type ScriptSettingEditParamsSettingsResultPlacementMode string + +const ( + ScriptSettingEditParamsSettingsResultPlacementModeSmart ScriptSettingEditParamsSettingsResultPlacementMode = "smart" +) + +// A reference to a script that will consume logs from the attached Worker. +type ScriptSettingEditParamsSettingsResultTailConsumer struct { + // Name of Worker that is to be the consumer. + Service param.Field[string] `json:"service,required"` + // Optional environment if the Worker utilizes one. + Environment param.Field[string] `json:"environment"` + // Optional dispatch namespace the script belongs to. + Namespace param.Field[string] `json:"namespace"` +} + +func (r ScriptSettingEditParamsSettingsResultTailConsumer) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Whether the API call was successful +type ScriptSettingEditParamsSettingsSuccess bool + +const ( + ScriptSettingEditParamsSettingsSuccessTrue ScriptSettingEditParamsSettingsSuccess = true +) + +type ScriptSettingEditResponseEnvelope struct { + Errors []ScriptSettingEditResponseEnvelopeErrors `json:"errors,required"` + Messages []ScriptSettingEditResponseEnvelopeMessages `json:"messages,required"` + Result ScriptSettingEditResponse `json:"result,required"` + // Whether the API call was successful + Success ScriptSettingEditResponseEnvelopeSuccess `json:"success,required"` + JSON scriptSettingEditResponseEnvelopeJSON `json:"-"` +} + +// scriptSettingEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [ScriptSettingEditResponseEnvelope] +type scriptSettingEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ScriptSettingEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptSettingEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// scriptSettingEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ScriptSettingEditResponseEnvelopeErrors] +type scriptSettingEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ScriptSettingEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptSettingEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// scriptSettingEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ScriptSettingEditResponseEnvelopeMessages] +type scriptSettingEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptSettingEditResponseEnvelopeSuccess bool + +const ( + ScriptSettingEditResponseEnvelopeSuccessTrue ScriptSettingEditResponseEnvelopeSuccess = true +) + +type ScriptSettingGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ScriptSettingGetResponseEnvelope struct { + Errors []ScriptSettingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ScriptSettingGetResponseEnvelopeMessages `json:"messages,required"` + Result ScriptSettingGetResponse `json:"result,required"` + // Whether the API call was successful + Success ScriptSettingGetResponseEnvelopeSuccess `json:"success,required"` + JSON scriptSettingGetResponseEnvelopeJSON `json:"-"` +} + +// scriptSettingGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [ScriptSettingGetResponseEnvelope] +type scriptSettingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ScriptSettingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptSettingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// scriptSettingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ScriptSettingGetResponseEnvelopeErrors] +type scriptSettingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ScriptSettingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptSettingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// scriptSettingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ScriptSettingGetResponseEnvelopeMessages] +type scriptSettingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptSettingGetResponseEnvelopeSuccess bool + +const ( + ScriptSettingGetResponseEnvelopeSuccessTrue ScriptSettingGetResponseEnvelopeSuccess = true +) diff --git a/workers/scriptsetting_test.go b/workers/scriptsetting_test.go new file mode 100644 index 00000000000..2850faeba54 --- /dev/null +++ b/workers/scriptsetting_test.go @@ -0,0 +1,157 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +func TestScriptSettingEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Workers.Scripts.Settings.Edit( + context.TODO(), + "this-is_my_script-01", + workers.ScriptSettingEditParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Settings: cloudflare.F(workers.ScriptSettingEditParamsSettings{ + Errors: cloudflare.F([]workers.ScriptSettingEditParamsSettingsError{{ + Code: cloudflare.F(int64(1000)), + Message: cloudflare.F("string"), + }, { + Code: cloudflare.F(int64(1000)), + Message: cloudflare.F("string"), + }, { + Code: cloudflare.F(int64(1000)), + Message: cloudflare.F("string"), + }}), + Messages: cloudflare.F([]workers.ScriptSettingEditParamsSettingsMessage{{ + Code: cloudflare.F(int64(1000)), + Message: cloudflare.F("string"), + }, { + Code: cloudflare.F(int64(1000)), + Message: cloudflare.F("string"), + }, { + Code: cloudflare.F(int64(1000)), + Message: cloudflare.F("string"), + }}), + Result: cloudflare.F(workers.ScriptSettingEditParamsSettingsResult{ + Bindings: cloudflare.F([]workers.ScriptSettingEditParamsSettingsResultBinding{workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding(workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding{ + Type: cloudflare.F(workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), + }), workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding(workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding{ + Type: cloudflare.F(workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), + }), workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding(workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding{ + Type: cloudflare.F(workers.ScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), + })}), + CompatibilityDate: cloudflare.F("2022-04-05"), + CompatibilityFlags: cloudflare.F([]string{"formdata_parser_supports_files", "formdata_parser_supports_files", "formdata_parser_supports_files"}), + Logpush: cloudflare.F(false), + Migrations: cloudflare.F[workers.ScriptSettingEditParamsSettingsResultMigrations](workers.ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrations(workers.ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrations{ + NewTag: cloudflare.F("v2"), + OldTag: cloudflare.F("v1"), + DeletedClasses: cloudflare.F([]string{"string", "string", "string"}), + NewClasses: cloudflare.F([]string{"string", "string", "string"}), + RenamedClasses: cloudflare.F([]workers.ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsRenamedClass{{ + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }}), + TransferredClasses: cloudflare.F([]workers.ScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsTransferredClass{{ + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }}), + })), + Placement: cloudflare.F(workers.ScriptSettingEditParamsSettingsResultPlacement{ + Mode: cloudflare.F(workers.ScriptSettingEditParamsSettingsResultPlacementModeSmart), + }), + Tags: cloudflare.F([]string{"my-tag", "my-tag", "my-tag"}), + TailConsumers: cloudflare.F([]workers.ScriptSettingEditParamsSettingsResultTailConsumer{{ + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), + }, { + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), + }, { + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), + }}), + UsageModel: cloudflare.F("unbound"), + }), + Success: cloudflare.F(workers.ScriptSettingEditParamsSettingsSuccessTrue), + }), + }, + ) + 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 TestScriptSettingGet(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("user@example.com"), + ) + _, err := client.Workers.Scripts.Settings.Get( + context.TODO(), + "this-is_my_script-01", + workers.ScriptSettingGetParams{ + AccountID: cloudflare.F("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/workers/scripttail.go b/workers/scripttail.go new file mode 100644 index 00000000000..247589bec84 --- /dev/null +++ b/workers/scripttail.go @@ -0,0 +1,406 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// ScriptTailService 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 [NewScriptTailService] method instead. +type ScriptTailService struct { + Options []option.RequestOption +} + +// NewScriptTailService 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 NewScriptTailService(opts ...option.RequestOption) (r *ScriptTailService) { + r = &ScriptTailService{} + r.Options = opts + return +} + +// Starts a tail that receives logs and exception from a Worker. +func (r *ScriptTailService) New(ctx context.Context, scriptName string, body ScriptTailNewParams, opts ...option.RequestOption) (res *ScriptTailNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env ScriptTailNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/tails", body.AccountID, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a tail from a Worker. +func (r *ScriptTailService) Delete(ctx context.Context, scriptName string, id string, body ScriptTailDeleteParams, opts ...option.RequestOption) (res *ScriptTailDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env ScriptTailDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/tails/%s", body.AccountID, scriptName, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get list of tails currently deployed on a Worker. +func (r *ScriptTailService) Get(ctx context.Context, scriptName string, query ScriptTailGetParams, opts ...option.RequestOption) (res *ScriptTailGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env ScriptTailGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/tails", query.AccountID, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ScriptTailNewResponse struct { + ID interface{} `json:"id"` + ExpiresAt interface{} `json:"expires_at"` + URL interface{} `json:"url"` + JSON scriptTailNewResponseJSON `json:"-"` +} + +// scriptTailNewResponseJSON contains the JSON metadata for the struct +// [ScriptTailNewResponse] +type scriptTailNewResponseJSON struct { + ID apijson.Field + ExpiresAt apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptTailNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptTailNewResponseJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [workers.ScriptTailDeleteResponseUnknown], +// [workers.ScriptTailDeleteResponseArray] or [shared.UnionString]. +type ScriptTailDeleteResponse interface { + ImplementsWorkersScriptTailDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ScriptTailDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ScriptTailDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type ScriptTailDeleteResponseArray []interface{} + +func (r ScriptTailDeleteResponseArray) ImplementsWorkersScriptTailDeleteResponse() {} + +type ScriptTailGetResponse struct { + ID interface{} `json:"id"` + ExpiresAt interface{} `json:"expires_at"` + URL interface{} `json:"url"` + JSON scriptTailGetResponseJSON `json:"-"` +} + +// scriptTailGetResponseJSON contains the JSON metadata for the struct +// [ScriptTailGetResponse] +type scriptTailGetResponseJSON struct { + ID apijson.Field + ExpiresAt apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptTailGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptTailGetResponseJSON) RawJSON() string { + return r.raw +} + +type ScriptTailNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ScriptTailNewResponseEnvelope struct { + Errors []ScriptTailNewResponseEnvelopeErrors `json:"errors,required"` + Messages []ScriptTailNewResponseEnvelopeMessages `json:"messages,required"` + Result ScriptTailNewResponse `json:"result,required"` + // Whether the API call was successful + Success ScriptTailNewResponseEnvelopeSuccess `json:"success,required"` + JSON scriptTailNewResponseEnvelopeJSON `json:"-"` +} + +// scriptTailNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [ScriptTailNewResponseEnvelope] +type scriptTailNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptTailNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptTailNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ScriptTailNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptTailNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// scriptTailNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ScriptTailNewResponseEnvelopeErrors] +type scriptTailNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptTailNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptTailNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ScriptTailNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptTailNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// scriptTailNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ScriptTailNewResponseEnvelopeMessages] +type scriptTailNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptTailNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptTailNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptTailNewResponseEnvelopeSuccess bool + +const ( + ScriptTailNewResponseEnvelopeSuccessTrue ScriptTailNewResponseEnvelopeSuccess = true +) + +type ScriptTailDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ScriptTailDeleteResponseEnvelope struct { + Errors []ScriptTailDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []ScriptTailDeleteResponseEnvelopeMessages `json:"messages,required"` + Result ScriptTailDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success ScriptTailDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON scriptTailDeleteResponseEnvelopeJSON `json:"-"` +} + +// scriptTailDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [ScriptTailDeleteResponseEnvelope] +type scriptTailDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptTailDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptTailDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ScriptTailDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptTailDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// scriptTailDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ScriptTailDeleteResponseEnvelopeErrors] +type scriptTailDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptTailDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptTailDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ScriptTailDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptTailDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// scriptTailDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ScriptTailDeleteResponseEnvelopeMessages] +type scriptTailDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptTailDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptTailDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptTailDeleteResponseEnvelopeSuccess bool + +const ( + ScriptTailDeleteResponseEnvelopeSuccessTrue ScriptTailDeleteResponseEnvelopeSuccess = true +) + +type ScriptTailGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ScriptTailGetResponseEnvelope struct { + Errors []ScriptTailGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ScriptTailGetResponseEnvelopeMessages `json:"messages,required"` + Result ScriptTailGetResponse `json:"result,required"` + // Whether the API call was successful + Success ScriptTailGetResponseEnvelopeSuccess `json:"success,required"` + JSON scriptTailGetResponseEnvelopeJSON `json:"-"` +} + +// scriptTailGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [ScriptTailGetResponseEnvelope] +type scriptTailGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptTailGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptTailGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ScriptTailGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptTailGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// scriptTailGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ScriptTailGetResponseEnvelopeErrors] +type scriptTailGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptTailGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptTailGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ScriptTailGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptTailGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// scriptTailGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [ScriptTailGetResponseEnvelopeMessages] +type scriptTailGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptTailGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptTailGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptTailGetResponseEnvelopeSuccess bool + +const ( + ScriptTailGetResponseEnvelopeSuccessTrue ScriptTailGetResponseEnvelopeSuccess = true +) diff --git a/workers/scripttail_test.go b/workers/scripttail_test.go new file mode 100644 index 00000000000..48c9f44490c --- /dev/null +++ b/workers/scripttail_test.go @@ -0,0 +1,106 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +func TestScriptTailNew(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("user@example.com"), + ) + _, err := client.Workers.Scripts.Tail.New( + context.TODO(), + "this-is_my_script-01", + workers.ScriptTailNewParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestScriptTailDelete(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("user@example.com"), + ) + _, err := client.Workers.Scripts.Tail.Delete( + context.TODO(), + "this-is_my_script-01", + "03dc9f77817b488fb26c5861ec18f791", + workers.ScriptTailDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestScriptTailGet(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("user@example.com"), + ) + _, err := client.Workers.Scripts.Tail.Get( + context.TODO(), + "this-is_my_script-01", + workers.ScriptTailGetParams{ + AccountID: cloudflare.F("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/workers/scriptusagemodel.go b/workers/scriptusagemodel.go new file mode 100644 index 00000000000..a35340beb03 --- /dev/null +++ b/workers/scriptusagemodel.go @@ -0,0 +1,278 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ScriptUsageModelService 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 [NewScriptUsageModelService] method +// instead. +type ScriptUsageModelService struct { + Options []option.RequestOption +} + +// NewScriptUsageModelService 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 NewScriptUsageModelService(opts ...option.RequestOption) (r *ScriptUsageModelService) { + r = &ScriptUsageModelService{} + r.Options = opts + return +} + +// Updates the Usage Model for a given Worker. Requires a Workers Paid +// subscription. +func (r *ScriptUsageModelService) Update(ctx context.Context, scriptName string, params ScriptUsageModelUpdateParams, opts ...option.RequestOption) (res *ScriptUsageModelUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env ScriptUsageModelUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/usage-model", params.AccountID, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the Usage Model for a given Worker. +func (r *ScriptUsageModelService) Get(ctx context.Context, scriptName string, query ScriptUsageModelGetParams, opts ...option.RequestOption) (res *ScriptUsageModelGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env ScriptUsageModelGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/scripts/%s/usage-model", query.AccountID, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ScriptUsageModelUpdateResponse struct { + UsageModel interface{} `json:"usage_model"` + JSON scriptUsageModelUpdateResponseJSON `json:"-"` +} + +// scriptUsageModelUpdateResponseJSON contains the JSON metadata for the struct +// [ScriptUsageModelUpdateResponse] +type scriptUsageModelUpdateResponseJSON struct { + UsageModel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptUsageModelUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptUsageModelUpdateResponseJSON) RawJSON() string { + return r.raw +} + +type ScriptUsageModelGetResponse struct { + UsageModel interface{} `json:"usage_model"` + JSON scriptUsageModelGetResponseJSON `json:"-"` +} + +// scriptUsageModelGetResponseJSON contains the JSON metadata for the struct +// [ScriptUsageModelGetResponse] +type scriptUsageModelGetResponseJSON struct { + UsageModel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptUsageModelGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptUsageModelGetResponseJSON) RawJSON() string { + return r.raw +} + +type ScriptUsageModelUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Body param.Field[interface{}] `json:"body,required"` +} + +func (r ScriptUsageModelUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type ScriptUsageModelUpdateResponseEnvelope struct { + Errors []ScriptUsageModelUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []ScriptUsageModelUpdateResponseEnvelopeMessages `json:"messages,required"` + Result ScriptUsageModelUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success ScriptUsageModelUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON scriptUsageModelUpdateResponseEnvelopeJSON `json:"-"` +} + +// scriptUsageModelUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [ScriptUsageModelUpdateResponseEnvelope] +type scriptUsageModelUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptUsageModelUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptUsageModelUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ScriptUsageModelUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptUsageModelUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// scriptUsageModelUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [ScriptUsageModelUpdateResponseEnvelopeErrors] +type scriptUsageModelUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptUsageModelUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptUsageModelUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ScriptUsageModelUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptUsageModelUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// scriptUsageModelUpdateResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [ScriptUsageModelUpdateResponseEnvelopeMessages] +type scriptUsageModelUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptUsageModelUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptUsageModelUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptUsageModelUpdateResponseEnvelopeSuccess bool + +const ( + ScriptUsageModelUpdateResponseEnvelopeSuccessTrue ScriptUsageModelUpdateResponseEnvelopeSuccess = true +) + +type ScriptUsageModelGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ScriptUsageModelGetResponseEnvelope struct { + Errors []ScriptUsageModelGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ScriptUsageModelGetResponseEnvelopeMessages `json:"messages,required"` + Result ScriptUsageModelGetResponse `json:"result,required"` + // Whether the API call was successful + Success ScriptUsageModelGetResponseEnvelopeSuccess `json:"success,required"` + JSON scriptUsageModelGetResponseEnvelopeJSON `json:"-"` +} + +// scriptUsageModelGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [ScriptUsageModelGetResponseEnvelope] +type scriptUsageModelGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptUsageModelGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptUsageModelGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ScriptUsageModelGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptUsageModelGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// scriptUsageModelGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [ScriptUsageModelGetResponseEnvelopeErrors] +type scriptUsageModelGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptUsageModelGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptUsageModelGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ScriptUsageModelGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON scriptUsageModelGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// scriptUsageModelGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [ScriptUsageModelGetResponseEnvelopeMessages] +type scriptUsageModelGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ScriptUsageModelGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r scriptUsageModelGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ScriptUsageModelGetResponseEnvelopeSuccess bool + +const ( + ScriptUsageModelGetResponseEnvelopeSuccessTrue ScriptUsageModelGetResponseEnvelopeSuccess = true +) diff --git a/workers/scriptusagemodel_test.go b/workers/scriptusagemodel_test.go new file mode 100644 index 00000000000..572ef5575f6 --- /dev/null +++ b/workers/scriptusagemodel_test.go @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +func TestScriptUsageModelUpdate(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("user@example.com"), + ) + _, err := client.Workers.Scripts.UsageModel.Update( + context.TODO(), + "this-is_my_script-01", + workers.ScriptUsageModelUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: cloudflare.F[any]("{'usage_model': 'unbound'}"), + }, + ) + 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 TestScriptUsageModelGet(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("user@example.com"), + ) + _, err := client.Workers.Scripts.UsageModel.Get( + context.TODO(), + "this-is_my_script-01", + workers.ScriptUsageModelGetParams{ + AccountID: cloudflare.F("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/workers/service.go b/workers/service.go new file mode 100644 index 00000000000..a803b2517d2 --- /dev/null +++ b/workers/service.go @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// ServiceService 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 [NewServiceService] method instead. +type ServiceService struct { + Options []option.RequestOption + Environments *ServiceEnvironmentService +} + +// NewServiceService 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 NewServiceService(opts ...option.RequestOption) (r *ServiceService) { + r = &ServiceService{} + r.Options = opts + r.Environments = NewServiceEnvironmentService(opts...) + return +} diff --git a/workers/serviceenvironment.go b/workers/serviceenvironment.go new file mode 100644 index 00000000000..713f20aa9b7 --- /dev/null +++ b/workers/serviceenvironment.go @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// ServiceEnvironmentService 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 [NewServiceEnvironmentService] method +// instead. +type ServiceEnvironmentService struct { + Options []option.RequestOption + Content *ServiceEnvironmentContentService + Settings *ServiceEnvironmentSettingService +} + +// NewServiceEnvironmentService 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 NewServiceEnvironmentService(opts ...option.RequestOption) (r *ServiceEnvironmentService) { + r = &ServiceEnvironmentService{} + r.Options = opts + r.Content = NewServiceEnvironmentContentService(opts...) + r.Settings = NewServiceEnvironmentSettingService(opts...) + return +} diff --git a/workers/serviceenvironmentcontent.go b/workers/serviceenvironmentcontent.go new file mode 100644 index 00000000000..0387ebc7f1f --- /dev/null +++ b/workers/serviceenvironmentcontent.go @@ -0,0 +1,190 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "bytes" + "context" + "fmt" + "io" + "mime/multipart" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apiform" + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ServiceEnvironmentContentService 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 +// [NewServiceEnvironmentContentService] method instead. +type ServiceEnvironmentContentService struct { + Options []option.RequestOption +} + +// NewServiceEnvironmentContentService 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 NewServiceEnvironmentContentService(opts ...option.RequestOption) (r *ServiceEnvironmentContentService) { + r = &ServiceEnvironmentContentService{} + r.Options = opts + return +} + +// Put script content from a worker with an environment +func (r *ServiceEnvironmentContentService) Update(ctx context.Context, serviceName string, environmentName string, params ServiceEnvironmentContentUpdateParams, opts ...option.RequestOption) (res *WorkersScript, err error) { + opts = append(r.Options[:], opts...) + var env ServiceEnvironmentContentUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/services/%s/environments/%s/content", params.AccountID, serviceName, environmentName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get script content from a worker with an environment +func (r *ServiceEnvironmentContentService) Get(ctx context.Context, serviceName string, environmentName string, query ServiceEnvironmentContentGetParams, opts ...option.RequestOption) (res *http.Response, err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "string")}, opts...) + path := fmt.Sprintf("accounts/%s/workers/services/%s/environments/%s/content", query.AccountID, serviceName, environmentName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +type ServiceEnvironmentContentUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // A module comprising a Worker script, often a javascript file. Multiple modules + // may be provided as separate named parts, but at least one module must be + // present. This should be referenced either in the metadata as `main_module` + // (esm)/`body_part` (service worker) or as a header `CF-WORKER-MAIN-MODULE-PART` + // (esm) /`CF-WORKER-BODY-PART` (service worker) by part name. + AnyPartName param.Field[[]io.Reader] `json:"" format:"binary"` + // JSON encoded metadata about the uploaded parts and Worker configuration. + Metadata param.Field[ServiceEnvironmentContentUpdateParamsMetadata] `json:"metadata"` + CfWorkerBodyPart param.Field[string] `header:"CF-WORKER-BODY-PART"` + CfWorkerMainModulePart param.Field[string] `header:"CF-WORKER-MAIN-MODULE-PART"` +} + +func (r ServiceEnvironmentContentUpdateParams) MarshalMultipart() (data []byte, contentType string, err error) { + buf := bytes.NewBuffer(nil) + writer := multipart.NewWriter(buf) + err = apiform.MarshalRoot(r, writer) + if err != nil { + writer.Close() + return nil, "", err + } + err = writer.Close() + if err != nil { + return nil, "", err + } + return buf.Bytes(), writer.FormDataContentType(), nil +} + +// JSON encoded metadata about the uploaded parts and Worker configuration. +type ServiceEnvironmentContentUpdateParamsMetadata struct { + // Name of the part in the multipart request that contains the script (e.g. the + // file adding a listener to the `fetch` event). Indicates a + // `service worker syntax` Worker. + BodyPart param.Field[string] `json:"body_part"` + // Name of the part in the multipart request that contains the main module (e.g. + // the file exporting a `fetch` handler). Indicates a `module syntax` Worker. + MainModule param.Field[string] `json:"main_module"` +} + +func (r ServiceEnvironmentContentUpdateParamsMetadata) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ServiceEnvironmentContentUpdateResponseEnvelope struct { + Errors []ServiceEnvironmentContentUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []ServiceEnvironmentContentUpdateResponseEnvelopeMessages `json:"messages,required"` + Result WorkersScript `json:"result,required"` + // Whether the API call was successful + Success ServiceEnvironmentContentUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON serviceEnvironmentContentUpdateResponseEnvelopeJSON `json:"-"` +} + +// serviceEnvironmentContentUpdateResponseEnvelopeJSON contains the JSON metadata +// for the struct [ServiceEnvironmentContentUpdateResponseEnvelope] +type serviceEnvironmentContentUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentContentUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentContentUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentContentUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON serviceEnvironmentContentUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// serviceEnvironmentContentUpdateResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [ServiceEnvironmentContentUpdateResponseEnvelopeErrors] +type serviceEnvironmentContentUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentContentUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentContentUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentContentUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON serviceEnvironmentContentUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// serviceEnvironmentContentUpdateResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct +// [ServiceEnvironmentContentUpdateResponseEnvelopeMessages] +type serviceEnvironmentContentUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentContentUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentContentUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ServiceEnvironmentContentUpdateResponseEnvelopeSuccess bool + +const ( + ServiceEnvironmentContentUpdateResponseEnvelopeSuccessTrue ServiceEnvironmentContentUpdateResponseEnvelopeSuccess = true +) + +type ServiceEnvironmentContentGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} diff --git a/workers/serviceenvironmentcontent_test.go b/workers/serviceenvironmentcontent_test.go new file mode 100644 index 00000000000..552ef1e100e --- /dev/null +++ b/workers/serviceenvironmentcontent_test.go @@ -0,0 +1,100 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_test + +import ( + "bytes" + "context" + "errors" + "io" + "net/http" + "net/http/httptest" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +func TestServiceEnvironmentContentUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Workers.Services.Environments.Content.Update( + context.TODO(), + "my-worker", + "production", + workers.ServiceEnvironmentContentUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + AnyPartName: cloudflare.F([]io.Reader{io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents")))}), + Metadata: cloudflare.F(workers.ServiceEnvironmentContentUpdateParamsMetadata{ + BodyPart: cloudflare.F("worker.js"), + MainModule: cloudflare.F("worker.js"), + }), + CfWorkerBodyPart: cloudflare.F("string"), + CfWorkerMainModulePart: cloudflare.F("string"), + }, + ) + 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 TestServiceEnvironmentContentGet(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + w.Write([]byte("abc")) + })) + defer server.Close() + baseURL := server.URL + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("user@example.com"), + ) + resp, err := client.Workers.Services.Environments.Content.Get( + context.TODO(), + "my-worker", + "production", + workers.ServiceEnvironmentContentGetParams{ + AccountID: cloudflare.F("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()) + } + defer resp.Body.Close() + + b, err := io.ReadAll(resp.Body) + 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()) + } + if !bytes.Equal(b, []byte("abc")) { + t.Fatalf("return value not %s: %s", "abc", b) + } +} diff --git a/workers/serviceenvironmentsetting.go b/workers/serviceenvironmentsetting.go new file mode 100644 index 00000000000..6fe4889da2f --- /dev/null +++ b/workers/serviceenvironmentsetting.go @@ -0,0 +1,2208 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// ServiceEnvironmentSettingService 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 +// [NewServiceEnvironmentSettingService] method instead. +type ServiceEnvironmentSettingService struct { + Options []option.RequestOption +} + +// NewServiceEnvironmentSettingService 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 NewServiceEnvironmentSettingService(opts ...option.RequestOption) (r *ServiceEnvironmentSettingService) { + r = &ServiceEnvironmentSettingService{} + r.Options = opts + return +} + +// Patch script metadata, such as bindings +func (r *ServiceEnvironmentSettingService) Edit(ctx context.Context, serviceName string, environmentName string, params ServiceEnvironmentSettingEditParams, opts ...option.RequestOption) (res *ServiceEnvironmentSettingEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env ServiceEnvironmentSettingEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/services/%s/environments/%s/settings", params.AccountID, serviceName, environmentName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get script settings from a worker with an environment +func (r *ServiceEnvironmentSettingService) Get(ctx context.Context, serviceName string, environmentName string, query ServiceEnvironmentSettingGetParams, opts ...option.RequestOption) (res *ServiceEnvironmentSettingGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env ServiceEnvironmentSettingGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/services/%s/environments/%s/settings", query.AccountID, serviceName, environmentName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ServiceEnvironmentSettingEditResponse struct { + // List of bindings attached to this Worker + Bindings []ServiceEnvironmentSettingEditResponseBinding `json:"bindings"` + // Opt your Worker into changes after this date + CompatibilityDate string `json:"compatibility_date"` + // Opt your Worker into specific changes + CompatibilityFlags []string `json:"compatibility_flags"` + // Whether Logpush is turned on for the Worker. + Logpush bool `json:"logpush"` + // Migrations to apply for Durable Objects associated with this Worker. + Migrations ServiceEnvironmentSettingEditResponseMigrations `json:"migrations"` + Placement ServiceEnvironmentSettingEditResponsePlacement `json:"placement"` + // Tags to help you manage your Workers + Tags []string `json:"tags"` + // List of Workers that will consume logs from the attached Worker. + TailConsumers []ServiceEnvironmentSettingEditResponseTailConsumer `json:"tail_consumers"` + // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). + UsageModel string `json:"usage_model"` + JSON serviceEnvironmentSettingEditResponseJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseJSON contains the JSON metadata for the +// struct [ServiceEnvironmentSettingEditResponse] +type serviceEnvironmentSettingEditResponseJSON struct { + Bindings apijson.Field + CompatibilityDate apijson.Field + CompatibilityFlags apijson.Field + Logpush apijson.Field + Migrations apijson.Field + Placement apijson.Field + Tags apijson.Field + TailConsumers apijson.Field + UsageModel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseJSON) RawJSON() string { + return r.raw +} + +// A binding to allow the Worker to communicate with resources +// +// Union satisfied by +// [workers.ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBinding], +// [workers.ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBinding], +// [workers.ServiceEnvironmentSettingEditResponseBindingsWorkersDoBinding], +// [workers.ServiceEnvironmentSettingEditResponseBindingsWorkersR2Binding], +// [workers.ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBinding], +// [workers.ServiceEnvironmentSettingEditResponseBindingsWorkersD1Binding], +// [workers.ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBinding] +// or +// [workers.ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBinding]. +type ServiceEnvironmentSettingEditResponseBinding interface { + implementsWorkersServiceEnvironmentSettingEditResponseBinding() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ServiceEnvironmentSettingEditResponseBinding)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseBindingsWorkersDoBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseBindingsWorkersR2Binding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseBindingsWorkersD1Binding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBinding{}), + }, + ) +} + +type ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Namespace identifier tag. + NamespaceID string `json:"namespace_id,required"` + // The class of resource that the binding provides. + Type ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingType `json:"type,required"` + JSON serviceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBinding] +type serviceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON struct { + Name apijson.Field + NamespaceID apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBinding) implementsWorkersServiceEnvironmentSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingType string + +const ( + ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace ServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingType = "kv_namespace" +) + +type ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBinding struct { + // Optional environment if the Worker utilizes one. + Environment string `json:"environment,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Name of Worker to bind to + Service string `json:"service,required"` + // The class of resource that the binding provides. + Type ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBindingType `json:"type,required"` + JSON serviceEnvironmentSettingEditResponseBindingsWorkersServiceBindingJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseBindingsWorkersServiceBindingJSON contains +// the JSON metadata for the struct +// [ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBinding] +type serviceEnvironmentSettingEditResponseBindingsWorkersServiceBindingJSON struct { + Environment apijson.Field + Name apijson.Field + Service apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseBindingsWorkersServiceBindingJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBinding) implementsWorkersServiceEnvironmentSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBindingType string + +const ( + ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBindingTypeService ServiceEnvironmentSettingEditResponseBindingsWorkersServiceBindingType = "service" +) + +type ServiceEnvironmentSettingEditResponseBindingsWorkersDoBinding struct { + // The exported class name of the Durable Object + ClassName string `json:"class_name,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type ServiceEnvironmentSettingEditResponseBindingsWorkersDoBindingType `json:"type,required"` + // The environment of the script_name to bind to + Environment string `json:"environment"` + // Namespace identifier tag. + NamespaceID string `json:"namespace_id"` + // The script where the Durable Object is defined, if it is external to this Worker + ScriptName string `json:"script_name"` + JSON serviceEnvironmentSettingEditResponseBindingsWorkersDoBindingJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseBindingsWorkersDoBindingJSON contains the +// JSON metadata for the struct +// [ServiceEnvironmentSettingEditResponseBindingsWorkersDoBinding] +type serviceEnvironmentSettingEditResponseBindingsWorkersDoBindingJSON struct { + ClassName apijson.Field + Name apijson.Field + Type apijson.Field + Environment apijson.Field + NamespaceID apijson.Field + ScriptName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseBindingsWorkersDoBindingJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingEditResponseBindingsWorkersDoBinding) implementsWorkersServiceEnvironmentSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingEditResponseBindingsWorkersDoBindingType string + +const ( + ServiceEnvironmentSettingEditResponseBindingsWorkersDoBindingTypeDurableObjectNamespace ServiceEnvironmentSettingEditResponseBindingsWorkersDoBindingType = "durable_object_namespace" +) + +type ServiceEnvironmentSettingEditResponseBindingsWorkersR2Binding struct { + // R2 bucket to bind to + BucketName string `json:"bucket_name,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type ServiceEnvironmentSettingEditResponseBindingsWorkersR2BindingType `json:"type,required"` + JSON serviceEnvironmentSettingEditResponseBindingsWorkersR2BindingJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseBindingsWorkersR2BindingJSON contains the +// JSON metadata for the struct +// [ServiceEnvironmentSettingEditResponseBindingsWorkersR2Binding] +type serviceEnvironmentSettingEditResponseBindingsWorkersR2BindingJSON struct { + BucketName apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseBindingsWorkersR2BindingJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingEditResponseBindingsWorkersR2Binding) implementsWorkersServiceEnvironmentSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingEditResponseBindingsWorkersR2BindingType string + +const ( + ServiceEnvironmentSettingEditResponseBindingsWorkersR2BindingTypeR2Bucket ServiceEnvironmentSettingEditResponseBindingsWorkersR2BindingType = "r2_bucket" +) + +type ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Name of the Queue to bind to + QueueName string `json:"queue_name,required"` + // The class of resource that the binding provides. + Type ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBindingType `json:"type,required"` + JSON serviceEnvironmentSettingEditResponseBindingsWorkersQueueBindingJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseBindingsWorkersQueueBindingJSON contains +// the JSON metadata for the struct +// [ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBinding] +type serviceEnvironmentSettingEditResponseBindingsWorkersQueueBindingJSON struct { + Name apijson.Field + QueueName apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseBindingsWorkersQueueBindingJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBinding) implementsWorkersServiceEnvironmentSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBindingType string + +const ( + ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBindingTypeQueue ServiceEnvironmentSettingEditResponseBindingsWorkersQueueBindingType = "queue" +) + +type ServiceEnvironmentSettingEditResponseBindingsWorkersD1Binding struct { + // ID of the D1 database to bind to + ID string `json:"id,required"` + // A JavaScript variable name for the binding. + Binding string `json:"binding,required"` + // The name of the D1 database associated with the 'id' provided. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type ServiceEnvironmentSettingEditResponseBindingsWorkersD1BindingType `json:"type,required"` + JSON serviceEnvironmentSettingEditResponseBindingsWorkersD1BindingJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseBindingsWorkersD1BindingJSON contains the +// JSON metadata for the struct +// [ServiceEnvironmentSettingEditResponseBindingsWorkersD1Binding] +type serviceEnvironmentSettingEditResponseBindingsWorkersD1BindingJSON struct { + ID apijson.Field + Binding apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseBindingsWorkersD1BindingJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingEditResponseBindingsWorkersD1Binding) implementsWorkersServiceEnvironmentSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingEditResponseBindingsWorkersD1BindingType string + +const ( + ServiceEnvironmentSettingEditResponseBindingsWorkersD1BindingTypeD1 ServiceEnvironmentSettingEditResponseBindingsWorkersD1BindingType = "d1" +) + +type ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Namespace to bind to + Namespace string `json:"namespace,required"` + // The class of resource that the binding provides. + Type ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingType `json:"type,required"` + // Outbound worker + Outbound ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound `json:"outbound"` + JSON serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBinding] +type serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON struct { + Name apijson.Field + Namespace apijson.Field + Type apijson.Field + Outbound apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBinding) implementsWorkersServiceEnvironmentSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingType string + +const ( + ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" +) + +// Outbound worker +type ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound struct { + // Pass information from the Dispatch Worker to the Outbound Worker through the + // parameters + Params []string `json:"params"` + // Outbound worker + Worker ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` + JSON serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound] +type serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON struct { + Params apijson.Field + Worker apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { + return r.raw +} + +// Outbound worker +type ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { + // Environment of the outbound worker + Environment string `json:"environment"` + // Name of the outbound worker + Service string `json:"service"` + JSON serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker] +type serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { + Environment apijson.Field + Service apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBindingType `json:"type,required"` + // ID of the certificate to bind to + CertificateID string `json:"certificate_id"` + JSON serviceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBindingJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBindingJSON contains +// the JSON metadata for the struct +// [ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBinding] +type serviceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBindingJSON struct { + Name apijson.Field + Type apijson.Field + CertificateID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBindingJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBinding) implementsWorkersServiceEnvironmentSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBindingType string + +const ( + ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBindingTypeMTLSCertificate ServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBindingType = "mtls_certificate" +) + +// Migrations to apply for Durable Objects associated with this Worker. +// +// Union satisfied by +// [workers.ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrations] +// or +// [workers.ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrations]. +type ServiceEnvironmentSettingEditResponseMigrations interface { + implementsWorkersServiceEnvironmentSettingEditResponseMigrations() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ServiceEnvironmentSettingEditResponseMigrations)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrations{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrations{}), + }, + ) +} + +// A single set of migrations to apply. +type ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrations struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses []string `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses []string `json:"new_classes"` + // Tag to set as the latest migration tag. + NewTag string `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag string `json:"old_tag"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses []ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses []ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass `json:"transferred_classes"` + JSON serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrations] +type serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON struct { + DeletedClasses apijson.Field + NewClasses apijson.Field + NewTag apijson.Field + OldTag apijson.Field + RenamedClasses apijson.Field + TransferredClasses apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrations) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrations) implementsWorkersServiceEnvironmentSettingEditResponseMigrations() { +} + +type ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass struct { + From string `json:"from"` + To string `json:"to"` + JSON serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass] +type serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON struct { + From apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass struct { + From string `json:"from"` + FromScript string `json:"from_script"` + To string `json:"to"` + JSON serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass] +type serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON struct { + From apijson.Field + FromScript apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrations struct { + // Tag to set as the latest migration tag. + NewTag string `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag string `json:"old_tag"` + // Migrations to apply in order. + Steps []ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStep `json:"steps"` + JSON serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrations] +type serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON struct { + NewTag apijson.Field + OldTag apijson.Field + Steps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrations) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrations) implementsWorkersServiceEnvironmentSettingEditResponseMigrations() { +} + +type ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStep struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses []string `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses []string `json:"new_classes"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses []ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses []ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass `json:"transferred_classes"` + JSON serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStep] +type serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON struct { + DeletedClasses apijson.Field + NewClasses apijson.Field + RenamedClasses apijson.Field + TransferredClasses apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStep) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { + From string `json:"from"` + To string `json:"to"` + JSON serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass] +type serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON struct { + From apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { + From string `json:"from"` + FromScript string `json:"from_script"` + To string `json:"to"` + JSON serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass] +type serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON struct { + From apijson.Field + FromScript apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentSettingEditResponsePlacement struct { + // Enables + // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + // Only `"smart"` is currently supported + Mode ServiceEnvironmentSettingEditResponsePlacementMode `json:"mode"` + JSON serviceEnvironmentSettingEditResponsePlacementJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponsePlacementJSON contains the JSON metadata +// for the struct [ServiceEnvironmentSettingEditResponsePlacement] +type serviceEnvironmentSettingEditResponsePlacementJSON struct { + Mode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponsePlacement) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponsePlacementJSON) RawJSON() string { + return r.raw +} + +// Enables +// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). +// Only `"smart"` is currently supported +type ServiceEnvironmentSettingEditResponsePlacementMode string + +const ( + ServiceEnvironmentSettingEditResponsePlacementModeSmart ServiceEnvironmentSettingEditResponsePlacementMode = "smart" +) + +// A reference to a script that will consume logs from the attached Worker. +type ServiceEnvironmentSettingEditResponseTailConsumer struct { + // Name of Worker that is to be the consumer. + Service string `json:"service,required"` + // Optional environment if the Worker utilizes one. + Environment string `json:"environment"` + // Optional dispatch namespace the script belongs to. + Namespace string `json:"namespace"` + JSON serviceEnvironmentSettingEditResponseTailConsumerJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseTailConsumerJSON contains the JSON metadata +// for the struct [ServiceEnvironmentSettingEditResponseTailConsumer] +type serviceEnvironmentSettingEditResponseTailConsumerJSON struct { + Service apijson.Field + Environment apijson.Field + Namespace apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseTailConsumerJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentSettingGetResponse struct { + // List of bindings attached to this Worker + Bindings []ServiceEnvironmentSettingGetResponseBinding `json:"bindings"` + // Opt your Worker into changes after this date + CompatibilityDate string `json:"compatibility_date"` + // Opt your Worker into specific changes + CompatibilityFlags []string `json:"compatibility_flags"` + // Whether Logpush is turned on for the Worker. + Logpush bool `json:"logpush"` + // Migrations to apply for Durable Objects associated with this Worker. + Migrations ServiceEnvironmentSettingGetResponseMigrations `json:"migrations"` + Placement ServiceEnvironmentSettingGetResponsePlacement `json:"placement"` + // Tags to help you manage your Workers + Tags []string `json:"tags"` + // List of Workers that will consume logs from the attached Worker. + TailConsumers []ServiceEnvironmentSettingGetResponseTailConsumer `json:"tail_consumers"` + // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). + UsageModel string `json:"usage_model"` + JSON serviceEnvironmentSettingGetResponseJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseJSON contains the JSON metadata for the +// struct [ServiceEnvironmentSettingGetResponse] +type serviceEnvironmentSettingGetResponseJSON struct { + Bindings apijson.Field + CompatibilityDate apijson.Field + CompatibilityFlags apijson.Field + Logpush apijson.Field + Migrations apijson.Field + Placement apijson.Field + Tags apijson.Field + TailConsumers apijson.Field + UsageModel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseJSON) RawJSON() string { + return r.raw +} + +// A binding to allow the Worker to communicate with resources +// +// Union satisfied by +// [workers.ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBinding], +// [workers.ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBinding], +// [workers.ServiceEnvironmentSettingGetResponseBindingsWorkersDoBinding], +// [workers.ServiceEnvironmentSettingGetResponseBindingsWorkersR2Binding], +// [workers.ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBinding], +// [workers.ServiceEnvironmentSettingGetResponseBindingsWorkersD1Binding], +// [workers.ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBinding] +// or [workers.ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBinding]. +type ServiceEnvironmentSettingGetResponseBinding interface { + implementsWorkersServiceEnvironmentSettingGetResponseBinding() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ServiceEnvironmentSettingGetResponseBinding)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseBindingsWorkersDoBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseBindingsWorkersR2Binding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseBindingsWorkersD1Binding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBinding{}), + }, + ) +} + +type ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Namespace identifier tag. + NamespaceID string `json:"namespace_id,required"` + // The class of resource that the binding provides. + Type ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingType `json:"type,required"` + JSON serviceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBinding] +type serviceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON struct { + Name apijson.Field + NamespaceID apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBinding) implementsWorkersServiceEnvironmentSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingType string + +const ( + ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace ServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingType = "kv_namespace" +) + +type ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBinding struct { + // Optional environment if the Worker utilizes one. + Environment string `json:"environment,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Name of Worker to bind to + Service string `json:"service,required"` + // The class of resource that the binding provides. + Type ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBindingType `json:"type,required"` + JSON serviceEnvironmentSettingGetResponseBindingsWorkersServiceBindingJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseBindingsWorkersServiceBindingJSON contains +// the JSON metadata for the struct +// [ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBinding] +type serviceEnvironmentSettingGetResponseBindingsWorkersServiceBindingJSON struct { + Environment apijson.Field + Name apijson.Field + Service apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseBindingsWorkersServiceBindingJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBinding) implementsWorkersServiceEnvironmentSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBindingType string + +const ( + ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBindingTypeService ServiceEnvironmentSettingGetResponseBindingsWorkersServiceBindingType = "service" +) + +type ServiceEnvironmentSettingGetResponseBindingsWorkersDoBinding struct { + // The exported class name of the Durable Object + ClassName string `json:"class_name,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type ServiceEnvironmentSettingGetResponseBindingsWorkersDoBindingType `json:"type,required"` + // The environment of the script_name to bind to + Environment string `json:"environment"` + // Namespace identifier tag. + NamespaceID string `json:"namespace_id"` + // The script where the Durable Object is defined, if it is external to this Worker + ScriptName string `json:"script_name"` + JSON serviceEnvironmentSettingGetResponseBindingsWorkersDoBindingJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseBindingsWorkersDoBindingJSON contains the +// JSON metadata for the struct +// [ServiceEnvironmentSettingGetResponseBindingsWorkersDoBinding] +type serviceEnvironmentSettingGetResponseBindingsWorkersDoBindingJSON struct { + ClassName apijson.Field + Name apijson.Field + Type apijson.Field + Environment apijson.Field + NamespaceID apijson.Field + ScriptName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseBindingsWorkersDoBindingJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingGetResponseBindingsWorkersDoBinding) implementsWorkersServiceEnvironmentSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingGetResponseBindingsWorkersDoBindingType string + +const ( + ServiceEnvironmentSettingGetResponseBindingsWorkersDoBindingTypeDurableObjectNamespace ServiceEnvironmentSettingGetResponseBindingsWorkersDoBindingType = "durable_object_namespace" +) + +type ServiceEnvironmentSettingGetResponseBindingsWorkersR2Binding struct { + // R2 bucket to bind to + BucketName string `json:"bucket_name,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type ServiceEnvironmentSettingGetResponseBindingsWorkersR2BindingType `json:"type,required"` + JSON serviceEnvironmentSettingGetResponseBindingsWorkersR2BindingJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseBindingsWorkersR2BindingJSON contains the +// JSON metadata for the struct +// [ServiceEnvironmentSettingGetResponseBindingsWorkersR2Binding] +type serviceEnvironmentSettingGetResponseBindingsWorkersR2BindingJSON struct { + BucketName apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseBindingsWorkersR2BindingJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingGetResponseBindingsWorkersR2Binding) implementsWorkersServiceEnvironmentSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingGetResponseBindingsWorkersR2BindingType string + +const ( + ServiceEnvironmentSettingGetResponseBindingsWorkersR2BindingTypeR2Bucket ServiceEnvironmentSettingGetResponseBindingsWorkersR2BindingType = "r2_bucket" +) + +type ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Name of the Queue to bind to + QueueName string `json:"queue_name,required"` + // The class of resource that the binding provides. + Type ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBindingType `json:"type,required"` + JSON serviceEnvironmentSettingGetResponseBindingsWorkersQueueBindingJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseBindingsWorkersQueueBindingJSON contains the +// JSON metadata for the struct +// [ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBinding] +type serviceEnvironmentSettingGetResponseBindingsWorkersQueueBindingJSON struct { + Name apijson.Field + QueueName apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseBindingsWorkersQueueBindingJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBinding) implementsWorkersServiceEnvironmentSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBindingType string + +const ( + ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBindingTypeQueue ServiceEnvironmentSettingGetResponseBindingsWorkersQueueBindingType = "queue" +) + +type ServiceEnvironmentSettingGetResponseBindingsWorkersD1Binding struct { + // ID of the D1 database to bind to + ID string `json:"id,required"` + // A JavaScript variable name for the binding. + Binding string `json:"binding,required"` + // The name of the D1 database associated with the 'id' provided. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type ServiceEnvironmentSettingGetResponseBindingsWorkersD1BindingType `json:"type,required"` + JSON serviceEnvironmentSettingGetResponseBindingsWorkersD1BindingJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseBindingsWorkersD1BindingJSON contains the +// JSON metadata for the struct +// [ServiceEnvironmentSettingGetResponseBindingsWorkersD1Binding] +type serviceEnvironmentSettingGetResponseBindingsWorkersD1BindingJSON struct { + ID apijson.Field + Binding apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseBindingsWorkersD1BindingJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingGetResponseBindingsWorkersD1Binding) implementsWorkersServiceEnvironmentSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingGetResponseBindingsWorkersD1BindingType string + +const ( + ServiceEnvironmentSettingGetResponseBindingsWorkersD1BindingTypeD1 ServiceEnvironmentSettingGetResponseBindingsWorkersD1BindingType = "d1" +) + +type ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Namespace to bind to + Namespace string `json:"namespace,required"` + // The class of resource that the binding provides. + Type ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingType `json:"type,required"` + // Outbound worker + Outbound ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound `json:"outbound"` + JSON serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBinding] +type serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON struct { + Name apijson.Field + Namespace apijson.Field + Type apijson.Field + Outbound apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBinding) implementsWorkersServiceEnvironmentSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingType string + +const ( + ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" +) + +// Outbound worker +type ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound struct { + // Pass information from the Dispatch Worker to the Outbound Worker through the + // parameters + Params []string `json:"params"` + // Outbound worker + Worker ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` + JSON serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound] +type serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON struct { + Params apijson.Field + Worker apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { + return r.raw +} + +// Outbound worker +type ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { + // Environment of the outbound worker + Environment string `json:"environment"` + // Name of the outbound worker + Service string `json:"service"` + JSON serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker] +type serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { + Environment apijson.Field + Service apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBindingType `json:"type,required"` + // ID of the certificate to bind to + CertificateID string `json:"certificate_id"` + JSON serviceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBindingJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBindingJSON contains +// the JSON metadata for the struct +// [ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBinding] +type serviceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBindingJSON struct { + Name apijson.Field + Type apijson.Field + CertificateID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBindingJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBinding) implementsWorkersServiceEnvironmentSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBindingType string + +const ( + ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBindingTypeMTLSCertificate ServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBindingType = "mtls_certificate" +) + +// Migrations to apply for Durable Objects associated with this Worker. +// +// Union satisfied by +// [workers.ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrations] +// or +// [workers.ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrations]. +type ServiceEnvironmentSettingGetResponseMigrations interface { + implementsWorkersServiceEnvironmentSettingGetResponseMigrations() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ServiceEnvironmentSettingGetResponseMigrations)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrations{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrations{}), + }, + ) +} + +// A single set of migrations to apply. +type ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrations struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses []string `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses []string `json:"new_classes"` + // Tag to set as the latest migration tag. + NewTag string `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag string `json:"old_tag"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses []ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses []ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass `json:"transferred_classes"` + JSON serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrations] +type serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON struct { + DeletedClasses apijson.Field + NewClasses apijson.Field + NewTag apijson.Field + OldTag apijson.Field + RenamedClasses apijson.Field + TransferredClasses apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrations) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrations) implementsWorkersServiceEnvironmentSettingGetResponseMigrations() { +} + +type ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass struct { + From string `json:"from"` + To string `json:"to"` + JSON serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass] +type serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON struct { + From apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass struct { + From string `json:"from"` + FromScript string `json:"from_script"` + To string `json:"to"` + JSON serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass] +type serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON struct { + From apijson.Field + FromScript apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrations struct { + // Tag to set as the latest migration tag. + NewTag string `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag string `json:"old_tag"` + // Migrations to apply in order. + Steps []ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStep `json:"steps"` + JSON serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrations] +type serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON struct { + NewTag apijson.Field + OldTag apijson.Field + Steps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrations) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON) RawJSON() string { + return r.raw +} + +func (r ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrations) implementsWorkersServiceEnvironmentSettingGetResponseMigrations() { +} + +type ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStep struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses []string `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses []string `json:"new_classes"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses []ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses []ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass `json:"transferred_classes"` + JSON serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStep] +type serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON struct { + DeletedClasses apijson.Field + NewClasses apijson.Field + RenamedClasses apijson.Field + TransferredClasses apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStep) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { + From string `json:"from"` + To string `json:"to"` + JSON serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass] +type serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON struct { + From apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { + From string `json:"from"` + FromScript string `json:"from_script"` + To string `json:"to"` + JSON serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON +// contains the JSON metadata for the struct +// [ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass] +type serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON struct { + From apijson.Field + FromScript apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentSettingGetResponsePlacement struct { + // Enables + // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + // Only `"smart"` is currently supported + Mode ServiceEnvironmentSettingGetResponsePlacementMode `json:"mode"` + JSON serviceEnvironmentSettingGetResponsePlacementJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponsePlacementJSON contains the JSON metadata for +// the struct [ServiceEnvironmentSettingGetResponsePlacement] +type serviceEnvironmentSettingGetResponsePlacementJSON struct { + Mode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponsePlacement) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponsePlacementJSON) RawJSON() string { + return r.raw +} + +// Enables +// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). +// Only `"smart"` is currently supported +type ServiceEnvironmentSettingGetResponsePlacementMode string + +const ( + ServiceEnvironmentSettingGetResponsePlacementModeSmart ServiceEnvironmentSettingGetResponsePlacementMode = "smart" +) + +// A reference to a script that will consume logs from the attached Worker. +type ServiceEnvironmentSettingGetResponseTailConsumer struct { + // Name of Worker that is to be the consumer. + Service string `json:"service,required"` + // Optional environment if the Worker utilizes one. + Environment string `json:"environment"` + // Optional dispatch namespace the script belongs to. + Namespace string `json:"namespace"` + JSON serviceEnvironmentSettingGetResponseTailConsumerJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseTailConsumerJSON contains the JSON metadata +// for the struct [ServiceEnvironmentSettingGetResponseTailConsumer] +type serviceEnvironmentSettingGetResponseTailConsumerJSON struct { + Service apijson.Field + Environment apijson.Field + Namespace apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseTailConsumerJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentSettingEditParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Errors param.Field[[]ServiceEnvironmentSettingEditParamsError] `json:"errors,required"` + Messages param.Field[[]ServiceEnvironmentSettingEditParamsMessage] `json:"messages,required"` + Result param.Field[ServiceEnvironmentSettingEditParamsResult] `json:"result,required"` + // Whether the API call was successful + Success param.Field[ServiceEnvironmentSettingEditParamsSuccess] `json:"success,required"` +} + +func (r ServiceEnvironmentSettingEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ServiceEnvironmentSettingEditParamsError struct { + Code param.Field[int64] `json:"code,required"` + Message param.Field[string] `json:"message,required"` +} + +func (r ServiceEnvironmentSettingEditParamsError) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ServiceEnvironmentSettingEditParamsMessage struct { + Code param.Field[int64] `json:"code,required"` + Message param.Field[string] `json:"message,required"` +} + +func (r ServiceEnvironmentSettingEditParamsMessage) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ServiceEnvironmentSettingEditParamsResult struct { + // List of bindings attached to this Worker + Bindings param.Field[[]ServiceEnvironmentSettingEditParamsResultBinding] `json:"bindings"` + // Opt your Worker into changes after this date + CompatibilityDate param.Field[string] `json:"compatibility_date"` + // Opt your Worker into specific changes + CompatibilityFlags param.Field[[]string] `json:"compatibility_flags"` + // Whether Logpush is turned on for the Worker. + Logpush param.Field[bool] `json:"logpush"` + // Migrations to apply for Durable Objects associated with this Worker. + Migrations param.Field[ServiceEnvironmentSettingEditParamsResultMigrations] `json:"migrations"` + Placement param.Field[ServiceEnvironmentSettingEditParamsResultPlacement] `json:"placement"` + // Tags to help you manage your Workers + Tags param.Field[[]string] `json:"tags"` + // List of Workers that will consume logs from the attached Worker. + TailConsumers param.Field[[]ServiceEnvironmentSettingEditParamsResultTailConsumer] `json:"tail_consumers"` + // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). + UsageModel param.Field[string] `json:"usage_model"` +} + +func (r ServiceEnvironmentSettingEditParamsResult) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A binding to allow the Worker to communicate with resources +// +// Satisfied by +// [workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding], +// [workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBinding], +// [workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBinding], +// [workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersR2Binding], +// [workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBinding], +// [workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersD1Binding], +// [workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding], +// [workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCertBinding]. +type ServiceEnvironmentSettingEditParamsResultBinding interface { + implementsWorkersServiceEnvironmentSettingEditParamsResultBinding() +} + +type ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding struct { + // The class of resource that the binding provides. + Type param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingType] `json:"type,required"` +} + +func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding) implementsWorkersServiceEnvironmentSettingEditParamsResultBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingType string + +const ( + ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingType = "kv_namespace" +) + +type ServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBinding struct { + // Optional environment if the Worker utilizes one. + Environment param.Field[string] `json:"environment,required"` + // Name of Worker to bind to + Service param.Field[string] `json:"service,required"` + // The class of resource that the binding provides. + Type param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBindingType] `json:"type,required"` +} + +func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBinding) implementsWorkersServiceEnvironmentSettingEditParamsResultBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBindingType string + +const ( + ServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBindingTypeService ServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBindingType = "service" +) + +type ServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBinding struct { + // The exported class name of the Durable Object + ClassName param.Field[string] `json:"class_name,required"` + // The class of resource that the binding provides. + Type param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBindingType] `json:"type,required"` + // The environment of the script_name to bind to + Environment param.Field[string] `json:"environment"` + // The script where the Durable Object is defined, if it is external to this Worker + ScriptName param.Field[string] `json:"script_name"` +} + +func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBinding) implementsWorkersServiceEnvironmentSettingEditParamsResultBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBindingType string + +const ( + ServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBindingTypeDurableObjectNamespace ServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBindingType = "durable_object_namespace" +) + +type ServiceEnvironmentSettingEditParamsResultBindingsWorkersR2Binding struct { + // R2 bucket to bind to + BucketName param.Field[string] `json:"bucket_name,required"` + // The class of resource that the binding provides. + Type param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersR2BindingType] `json:"type,required"` +} + +func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersR2Binding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersR2Binding) implementsWorkersServiceEnvironmentSettingEditParamsResultBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingEditParamsResultBindingsWorkersR2BindingType string + +const ( + ServiceEnvironmentSettingEditParamsResultBindingsWorkersR2BindingTypeR2Bucket ServiceEnvironmentSettingEditParamsResultBindingsWorkersR2BindingType = "r2_bucket" +) + +type ServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBinding struct { + // Name of the Queue to bind to + QueueName param.Field[string] `json:"queue_name,required"` + // The class of resource that the binding provides. + Type param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBindingType] `json:"type,required"` +} + +func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBinding) implementsWorkersServiceEnvironmentSettingEditParamsResultBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBindingType string + +const ( + ServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBindingTypeQueue ServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBindingType = "queue" +) + +type ServiceEnvironmentSettingEditParamsResultBindingsWorkersD1Binding struct { + // ID of the D1 database to bind to + ID param.Field[string] `json:"id,required"` + // The name of the D1 database associated with the 'id' provided. + Name param.Field[string] `json:"name,required"` + // The class of resource that the binding provides. + Type param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersD1BindingType] `json:"type,required"` +} + +func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersD1Binding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersD1Binding) implementsWorkersServiceEnvironmentSettingEditParamsResultBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingEditParamsResultBindingsWorkersD1BindingType string + +const ( + ServiceEnvironmentSettingEditParamsResultBindingsWorkersD1BindingTypeD1 ServiceEnvironmentSettingEditParamsResultBindingsWorkersD1BindingType = "d1" +) + +type ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding struct { + // Namespace to bind to + Namespace param.Field[string] `json:"namespace,required"` + // The class of resource that the binding provides. + Type param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType] `json:"type,required"` + // Outbound worker + Outbound param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutbound] `json:"outbound"` +} + +func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding) implementsWorkersServiceEnvironmentSettingEditParamsResultBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType string + +const ( + ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" +) + +// Outbound worker +type ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutbound struct { + // Pass information from the Dispatch Worker to the Outbound Worker through the + // parameters + Params param.Field[[]string] `json:"params"` + // Outbound worker + Worker param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker] `json:"worker"` +} + +func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutbound) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Outbound worker +type ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { + // Environment of the outbound worker + Environment param.Field[string] `json:"environment"` + // Name of the outbound worker + Service param.Field[string] `json:"service"` +} + +func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCertBinding struct { + // The class of resource that the binding provides. + Type param.Field[ServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCertBindingType] `json:"type,required"` + // ID of the certificate to bind to + CertificateID param.Field[string] `json:"certificate_id"` +} + +func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCertBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCertBinding) implementsWorkersServiceEnvironmentSettingEditParamsResultBinding() { +} + +// The class of resource that the binding provides. +type ServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCertBindingType string + +const ( + ServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCertBindingTypeMTLSCertificate ServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCertBindingType = "mtls_certificate" +) + +// Migrations to apply for Durable Objects associated with this Worker. +// +// Satisfied by +// [workers.ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrations], +// [workers.ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrations]. +type ServiceEnvironmentSettingEditParamsResultMigrations interface { + implementsWorkersServiceEnvironmentSettingEditParamsResultMigrations() +} + +// A single set of migrations to apply. +type ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrations struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses param.Field[[]string] `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses param.Field[[]string] `json:"new_classes"` + // Tag to set as the latest migration tag. + NewTag param.Field[string] `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag param.Field[string] `json:"old_tag"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses param.Field[[]ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass] `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses param.Field[[]ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass] `json:"transferred_classes"` +} + +func (r ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrations) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrations) implementsWorkersServiceEnvironmentSettingEditParamsResultMigrations() { +} + +type ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass struct { + From param.Field[string] `json:"from"` + To param.Field[string] `json:"to"` +} + +func (r ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass struct { + From param.Field[string] `json:"from"` + FromScript param.Field[string] `json:"from_script"` + To param.Field[string] `json:"to"` +} + +func (r ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrations struct { + // Tag to set as the latest migration tag. + NewTag param.Field[string] `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag param.Field[string] `json:"old_tag"` + // Migrations to apply in order. + Steps param.Field[[]ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStep] `json:"steps"` +} + +func (r ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrations) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrations) implementsWorkersServiceEnvironmentSettingEditParamsResultMigrations() { +} + +type ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStep struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses param.Field[[]string] `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses param.Field[[]string] `json:"new_classes"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses param.Field[[]ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass] `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses param.Field[[]ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass] `json:"transferred_classes"` +} + +func (r ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStep) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { + From param.Field[string] `json:"from"` + To param.Field[string] `json:"to"` +} + +func (r ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { + From param.Field[string] `json:"from"` + FromScript param.Field[string] `json:"from_script"` + To param.Field[string] `json:"to"` +} + +func (r ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ServiceEnvironmentSettingEditParamsResultPlacement struct { + // Enables + // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + // Only `"smart"` is currently supported + Mode param.Field[ServiceEnvironmentSettingEditParamsResultPlacementMode] `json:"mode"` +} + +func (r ServiceEnvironmentSettingEditParamsResultPlacement) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enables +// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). +// Only `"smart"` is currently supported +type ServiceEnvironmentSettingEditParamsResultPlacementMode string + +const ( + ServiceEnvironmentSettingEditParamsResultPlacementModeSmart ServiceEnvironmentSettingEditParamsResultPlacementMode = "smart" +) + +// A reference to a script that will consume logs from the attached Worker. +type ServiceEnvironmentSettingEditParamsResultTailConsumer struct { + // Name of Worker that is to be the consumer. + Service param.Field[string] `json:"service,required"` + // Optional environment if the Worker utilizes one. + Environment param.Field[string] `json:"environment"` + // Optional dispatch namespace the script belongs to. + Namespace param.Field[string] `json:"namespace"` +} + +func (r ServiceEnvironmentSettingEditParamsResultTailConsumer) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Whether the API call was successful +type ServiceEnvironmentSettingEditParamsSuccess bool + +const ( + ServiceEnvironmentSettingEditParamsSuccessTrue ServiceEnvironmentSettingEditParamsSuccess = true +) + +type ServiceEnvironmentSettingEditResponseEnvelope struct { + Errors []ServiceEnvironmentSettingEditResponseEnvelopeErrors `json:"errors,required"` + Messages []ServiceEnvironmentSettingEditResponseEnvelopeMessages `json:"messages,required"` + Result ServiceEnvironmentSettingEditResponse `json:"result,required"` + // Whether the API call was successful + Success ServiceEnvironmentSettingEditResponseEnvelopeSuccess `json:"success,required"` + JSON serviceEnvironmentSettingEditResponseEnvelopeJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseEnvelopeJSON contains the JSON metadata for +// the struct [ServiceEnvironmentSettingEditResponseEnvelope] +type serviceEnvironmentSettingEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentSettingEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON serviceEnvironmentSettingEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [ServiceEnvironmentSettingEditResponseEnvelopeErrors] +type serviceEnvironmentSettingEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentSettingEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON serviceEnvironmentSettingEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// serviceEnvironmentSettingEditResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [ServiceEnvironmentSettingEditResponseEnvelopeMessages] +type serviceEnvironmentSettingEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ServiceEnvironmentSettingEditResponseEnvelopeSuccess bool + +const ( + ServiceEnvironmentSettingEditResponseEnvelopeSuccessTrue ServiceEnvironmentSettingEditResponseEnvelopeSuccess = true +) + +type ServiceEnvironmentSettingGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type ServiceEnvironmentSettingGetResponseEnvelope struct { + Errors []ServiceEnvironmentSettingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ServiceEnvironmentSettingGetResponseEnvelopeMessages `json:"messages,required"` + Result ServiceEnvironmentSettingGetResponse `json:"result,required"` + // Whether the API call was successful + Success ServiceEnvironmentSettingGetResponseEnvelopeSuccess `json:"success,required"` + JSON serviceEnvironmentSettingGetResponseEnvelopeJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [ServiceEnvironmentSettingGetResponseEnvelope] +type serviceEnvironmentSettingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentSettingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON serviceEnvironmentSettingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [ServiceEnvironmentSettingGetResponseEnvelopeErrors] +type serviceEnvironmentSettingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ServiceEnvironmentSettingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON serviceEnvironmentSettingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// serviceEnvironmentSettingGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [ServiceEnvironmentSettingGetResponseEnvelopeMessages] +type serviceEnvironmentSettingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ServiceEnvironmentSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r serviceEnvironmentSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ServiceEnvironmentSettingGetResponseEnvelopeSuccess bool + +const ( + ServiceEnvironmentSettingGetResponseEnvelopeSuccessTrue ServiceEnvironmentSettingGetResponseEnvelopeSuccess = true +) diff --git a/workers/serviceenvironmentsetting_test.go b/workers/serviceenvironmentsetting_test.go new file mode 100644 index 00000000000..768ac8d9d3a --- /dev/null +++ b/workers/serviceenvironmentsetting_test.go @@ -0,0 +1,157 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +func TestServiceEnvironmentSettingEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Workers.Services.Environments.Settings.Edit( + context.TODO(), + "my-worker", + "production", + workers.ServiceEnvironmentSettingEditParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Errors: cloudflare.F([]workers.ServiceEnvironmentSettingEditParamsError{{ + Code: cloudflare.F(int64(1000)), + Message: cloudflare.F("string"), + }, { + Code: cloudflare.F(int64(1000)), + Message: cloudflare.F("string"), + }, { + Code: cloudflare.F(int64(1000)), + Message: cloudflare.F("string"), + }}), + Messages: cloudflare.F([]workers.ServiceEnvironmentSettingEditParamsMessage{{ + Code: cloudflare.F(int64(1000)), + Message: cloudflare.F("string"), + }, { + Code: cloudflare.F(int64(1000)), + Message: cloudflare.F("string"), + }, { + Code: cloudflare.F(int64(1000)), + Message: cloudflare.F("string"), + }}), + Result: cloudflare.F(workers.ServiceEnvironmentSettingEditParamsResult{ + Bindings: cloudflare.F([]workers.ServiceEnvironmentSettingEditParamsResultBinding{workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding(workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding{ + Type: cloudflare.F(workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), + }), workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding(workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding{ + Type: cloudflare.F(workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), + }), workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding(workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding{ + Type: cloudflare.F(workers.ServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), + })}), + CompatibilityDate: cloudflare.F("2022-04-05"), + CompatibilityFlags: cloudflare.F([]string{"formdata_parser_supports_files", "formdata_parser_supports_files", "formdata_parser_supports_files"}), + Logpush: cloudflare.F(false), + Migrations: cloudflare.F[workers.ServiceEnvironmentSettingEditParamsResultMigrations](workers.ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrations(workers.ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrations{ + NewTag: cloudflare.F("v2"), + OldTag: cloudflare.F("v1"), + DeletedClasses: cloudflare.F([]string{"string", "string", "string"}), + NewClasses: cloudflare.F([]string{"string", "string", "string"}), + RenamedClasses: cloudflare.F([]workers.ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass{{ + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }}), + TransferredClasses: cloudflare.F([]workers.ServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass{{ + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }}), + })), + Placement: cloudflare.F(workers.ServiceEnvironmentSettingEditParamsResultPlacement{ + Mode: cloudflare.F(workers.ServiceEnvironmentSettingEditParamsResultPlacementModeSmart), + }), + Tags: cloudflare.F([]string{"my-tag", "my-tag", "my-tag"}), + TailConsumers: cloudflare.F([]workers.ServiceEnvironmentSettingEditParamsResultTailConsumer{{ + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), + }, { + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), + }, { + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), + }}), + UsageModel: cloudflare.F("unbound"), + }), + Success: cloudflare.F(workers.ServiceEnvironmentSettingEditParamsSuccessTrue), + }, + ) + 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 TestServiceEnvironmentSettingGet(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("user@example.com"), + ) + _, err := client.Workers.Services.Environments.Settings.Get( + context.TODO(), + "my-worker", + "production", + workers.ServiceEnvironmentSettingGetParams{ + AccountID: cloudflare.F("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/workers/subdomain.go b/workers/subdomain.go new file mode 100644 index 00000000000..236595a9155 --- /dev/null +++ b/workers/subdomain.go @@ -0,0 +1,276 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SubdomainService 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 [NewSubdomainService] method instead. +type SubdomainService struct { + Options []option.RequestOption +} + +// NewSubdomainService 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 NewSubdomainService(opts ...option.RequestOption) (r *SubdomainService) { + r = &SubdomainService{} + r.Options = opts + return +} + +// Creates a Workers subdomain for an account. +func (r *SubdomainService) Update(ctx context.Context, params SubdomainUpdateParams, opts ...option.RequestOption) (res *SubdomainUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env SubdomainUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/subdomain", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Returns a Workers subdomain for an account. +func (r *SubdomainService) Get(ctx context.Context, query SubdomainGetParams, opts ...option.RequestOption) (res *SubdomainGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env SubdomainGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/subdomain", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type SubdomainUpdateResponse struct { + Name interface{} `json:"name"` + JSON subdomainUpdateResponseJSON `json:"-"` +} + +// subdomainUpdateResponseJSON contains the JSON metadata for the struct +// [SubdomainUpdateResponse] +type subdomainUpdateResponseJSON struct { + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubdomainUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subdomainUpdateResponseJSON) RawJSON() string { + return r.raw +} + +type SubdomainGetResponse struct { + Name interface{} `json:"name"` + JSON subdomainGetResponseJSON `json:"-"` +} + +// subdomainGetResponseJSON contains the JSON metadata for the struct +// [SubdomainGetResponse] +type subdomainGetResponseJSON struct { + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubdomainGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subdomainGetResponseJSON) RawJSON() string { + return r.raw +} + +type SubdomainUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Body param.Field[interface{}] `json:"body,required"` +} + +func (r SubdomainUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type SubdomainUpdateResponseEnvelope struct { + Errors []SubdomainUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []SubdomainUpdateResponseEnvelopeMessages `json:"messages,required"` + Result SubdomainUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success SubdomainUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON subdomainUpdateResponseEnvelopeJSON `json:"-"` +} + +// subdomainUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [SubdomainUpdateResponseEnvelope] +type subdomainUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubdomainUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subdomainUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SubdomainUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subdomainUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// subdomainUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SubdomainUpdateResponseEnvelopeErrors] +type subdomainUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubdomainUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subdomainUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SubdomainUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subdomainUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// subdomainUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SubdomainUpdateResponseEnvelopeMessages] +type subdomainUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubdomainUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subdomainUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SubdomainUpdateResponseEnvelopeSuccess bool + +const ( + SubdomainUpdateResponseEnvelopeSuccessTrue SubdomainUpdateResponseEnvelopeSuccess = true +) + +type SubdomainGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type SubdomainGetResponseEnvelope struct { + Errors []SubdomainGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SubdomainGetResponseEnvelopeMessages `json:"messages,required"` + Result SubdomainGetResponse `json:"result,required"` + // Whether the API call was successful + Success SubdomainGetResponseEnvelopeSuccess `json:"success,required"` + JSON subdomainGetResponseEnvelopeJSON `json:"-"` +} + +// subdomainGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SubdomainGetResponseEnvelope] +type subdomainGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubdomainGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subdomainGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SubdomainGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subdomainGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// subdomainGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [SubdomainGetResponseEnvelopeErrors] +type subdomainGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubdomainGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subdomainGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SubdomainGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subdomainGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// subdomainGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SubdomainGetResponseEnvelopeMessages] +type subdomainGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubdomainGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subdomainGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SubdomainGetResponseEnvelopeSuccess bool + +const ( + SubdomainGetResponseEnvelopeSuccessTrue SubdomainGetResponseEnvelopeSuccess = true +) diff --git a/workers/subdomain_test.go b/workers/subdomain_test.go new file mode 100644 index 00000000000..8620af606bf --- /dev/null +++ b/workers/subdomain_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +func TestSubdomainUpdate(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("user@example.com"), + ) + _, err := client.Workers.Subdomains.Update(context.TODO(), workers.SubdomainUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Body: cloudflare.F[any]("{'subdomain': 'example-subdomain'}"), + }) + 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 TestSubdomainGet(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("user@example.com"), + ) + _, err := client.Workers.Subdomains.Get(context.TODO(), workers.SubdomainGetParams{ + AccountID: cloudflare.F("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/workers/worker.go b/workers/worker.go new file mode 100644 index 00000000000..52891e4fe71 --- /dev/null +++ b/workers/worker.go @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// WorkerService 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 [NewWorkerService] method instead. +type WorkerService struct { + Options []option.RequestOption + AI *AIService + Scripts *ScriptService + Filters *FilterService + Routes *RouteService + AccountSettings *AccountSettingService + Deployments *DeploymentService + Domains *DomainService + Subdomains *SubdomainService + Services *ServiceService +} + +// NewWorkerService 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 NewWorkerService(opts ...option.RequestOption) (r *WorkerService) { + r = &WorkerService{} + r.Options = opts + r.AI = NewAIService(opts...) + r.Scripts = NewScriptService(opts...) + r.Filters = NewFilterService(opts...) + r.Routes = NewRouteService(opts...) + r.AccountSettings = NewAccountSettingService(opts...) + r.Deployments = NewDeploymentService(opts...) + r.Domains = NewDomainService(opts...) + r.Subdomains = NewSubdomainService(opts...) + r.Services = NewServiceService(opts...) + return +} diff --git a/workers_for_platforms/aliases.go b/workers_for_platforms/aliases.go new file mode 100644 index 00000000000..407ff73aa03 --- /dev/null +++ b/workers_for_platforms/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_for_platforms + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/workers_for_platforms/dispatch.go b/workers_for_platforms/dispatch.go new file mode 100644 index 00000000000..3cd65881bd5 --- /dev/null +++ b/workers_for_platforms/dispatch.go @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_for_platforms + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// DispatchService 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 [NewDispatchService] method instead. +type DispatchService struct { + Options []option.RequestOption + Namespaces *DispatchNamespaceService +} + +// NewDispatchService 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 NewDispatchService(opts ...option.RequestOption) (r *DispatchService) { + r = &DispatchService{} + r.Options = opts + r.Namespaces = NewDispatchNamespaceService(opts...) + return +} diff --git a/workers_for_platforms/dispatchnamespace.go b/workers_for_platforms/dispatchnamespace.go new file mode 100644 index 00000000000..bbc49157b78 --- /dev/null +++ b/workers_for_platforms/dispatchnamespace.go @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_for_platforms + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// DispatchNamespaceService 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 [NewDispatchNamespaceService] method +// instead. +type DispatchNamespaceService struct { + Options []option.RequestOption + Scripts *DispatchNamespaceScriptService +} + +// NewDispatchNamespaceService 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 NewDispatchNamespaceService(opts ...option.RequestOption) (r *DispatchNamespaceService) { + r = &DispatchNamespaceService{} + r.Options = opts + r.Scripts = NewDispatchNamespaceScriptService(opts...) + return +} diff --git a/workers_for_platforms/dispatchnamespacescript.go b/workers_for_platforms/dispatchnamespacescript.go new file mode 100644 index 00000000000..96f78814426 --- /dev/null +++ b/workers_for_platforms/dispatchnamespacescript.go @@ -0,0 +1,510 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_for_platforms + +import ( + "bytes" + "context" + "fmt" + "io" + "mime/multipart" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apiform" + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +// DispatchNamespaceScriptService 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 +// [NewDispatchNamespaceScriptService] method instead. +type DispatchNamespaceScriptService struct { + Options []option.RequestOption + Content *DispatchNamespaceScriptContentService +} + +// NewDispatchNamespaceScriptService 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 NewDispatchNamespaceScriptService(opts ...option.RequestOption) (r *DispatchNamespaceScriptService) { + r = &DispatchNamespaceScriptService{} + r.Options = opts + r.Content = NewDispatchNamespaceScriptContentService(opts...) + return +} + +// Upload a worker module to a Workers for Platforms namespace. +func (r *DispatchNamespaceScriptService) Update(ctx context.Context, dispatchNamespace string, scriptName string, params DispatchNamespaceScriptUpdateParams, opts ...option.RequestOption) (res *workers.WorkersScript, err error) { + opts = append(r.Options[:], opts...) + var env DispatchNamespaceScriptUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s", params.AccountID, dispatchNamespace, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a worker from a Workers for Platforms namespace. This call has no +// response body on a successful delete. +func (r *DispatchNamespaceScriptService) Delete(ctx context.Context, dispatchNamespace string, scriptName string, params DispatchNamespaceScriptDeleteParams, opts ...option.RequestOption) (err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s", params.AccountID, dispatchNamespace, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, nil, opts...) + return +} + +// Fetch information about a script uploaded to a Workers for Platforms namespace. +func (r *DispatchNamespaceScriptService) Get(ctx context.Context, dispatchNamespace string, scriptName string, query DispatchNamespaceScriptGetParams, opts ...option.RequestOption) (res *WorkersNamespaceScript, err error) { + opts = append(r.Options[:], opts...) + var env DispatchNamespaceScriptGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s", query.AccountID, dispatchNamespace, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Details about a worker uploaded to a Workers for Platforms namespace. +type WorkersNamespaceScript struct { + // When the script was created. + CreatedOn time.Time `json:"created_on" format:"date-time"` + // Name of the Workers for Platforms dispatch namespace. + DispatchNamespace string `json:"dispatch_namespace"` + // When the script was last modified. + ModifiedOn time.Time `json:"modified_on" format:"date-time"` + Script workers.WorkersScript `json:"script"` + JSON workersNamespaceScriptJSON `json:"-"` +} + +// workersNamespaceScriptJSON contains the JSON metadata for the struct +// [WorkersNamespaceScript] +type workersNamespaceScriptJSON struct { + CreatedOn apijson.Field + DispatchNamespace apijson.Field + ModifiedOn apijson.Field + Script apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkersNamespaceScript) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workersNamespaceScriptJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // A module comprising a Worker script, often a javascript file. Multiple modules + // may be provided as separate named parts, but at least one module must be present + // and referenced in the metadata as `main_module` or `body_part` by part name. + AnyPartName param.Field[[]io.Reader] `json:"" format:"binary"` + // Rollback message to be associated with this deployment. Only parsed when query + // param `"rollback_to"` is present. + Message param.Field[string] `json:"message"` + // JSON encoded metadata about the uploaded parts and Worker configuration. + Metadata param.Field[DispatchNamespaceScriptUpdateParamsMetadata] `json:"metadata"` +} + +func (r DispatchNamespaceScriptUpdateParams) MarshalMultipart() (data []byte, contentType string, err error) { + buf := bytes.NewBuffer(nil) + writer := multipart.NewWriter(buf) + err = apiform.MarshalRoot(r, writer) + if err != nil { + writer.Close() + return nil, "", err + } + err = writer.Close() + if err != nil { + return nil, "", err + } + return buf.Bytes(), writer.FormDataContentType(), nil +} + +// JSON encoded metadata about the uploaded parts and Worker configuration. +type DispatchNamespaceScriptUpdateParamsMetadata struct { + // List of bindings available to the worker. + Bindings param.Field[[]interface{}] `json:"bindings"` + // Name of the part in the multipart request that contains the script (e.g. the + // file adding a listener to the `fetch` event). Indicates a + // `service worker syntax` Worker. + BodyPart param.Field[string] `json:"body_part"` + // Date indicating targeted support in the Workers runtime. Backwards incompatible + // fixes to the runtime following this date will not affect this Worker. + CompatibilityDate param.Field[string] `json:"compatibility_date"` + // Flags that enable or disable certain features in the Workers runtime. Used to + // enable upcoming features or opt in or out of specific changes not included in a + // `compatibility_date`. + CompatibilityFlags param.Field[[]string] `json:"compatibility_flags"` + // List of binding types to keep from previous_upload. + KeepBindings param.Field[[]string] `json:"keep_bindings"` + // Whether Logpush is turned on for the Worker. + Logpush param.Field[bool] `json:"logpush"` + // Name of the part in the multipart request that contains the main module (e.g. + // the file exporting a `fetch` handler). Indicates a `module syntax` Worker. + MainModule param.Field[string] `json:"main_module"` + // Migrations to apply for Durable Objects associated with this Worker. + Migrations param.Field[DispatchNamespaceScriptUpdateParamsMetadataMigrations] `json:"migrations"` + Placement param.Field[DispatchNamespaceScriptUpdateParamsMetadataPlacement] `json:"placement"` + // List of strings to use as tags for this Worker + Tags param.Field[[]string] `json:"tags"` + // List of Workers that will consume logs from the attached Worker. + TailConsumers param.Field[[]DispatchNamespaceScriptUpdateParamsMetadataTailConsumer] `json:"tail_consumers"` + // Usage model to apply to invocations. + UsageModel param.Field[DispatchNamespaceScriptUpdateParamsMetadataUsageModel] `json:"usage_model"` + // Key-value pairs to use as tags for this version of this Worker + VersionTags param.Field[interface{}] `json:"version_tags"` +} + +func (r DispatchNamespaceScriptUpdateParamsMetadata) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Migrations to apply for Durable Objects associated with this Worker. +// +// Satisfied by +// [workers_for_platforms.DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations], +// [workers_for_platforms.DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrations]. +type DispatchNamespaceScriptUpdateParamsMetadataMigrations interface { + implementsWorkersForPlatformsDispatchNamespaceScriptUpdateParamsMetadataMigrations() +} + +// A single set of migrations to apply. +type DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses param.Field[[]string] `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses param.Field[[]string] `json:"new_classes"` + // Tag to set as the latest migration tag. + NewTag param.Field[string] `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag param.Field[string] `json:"old_tag"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses param.Field[[]DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsRenamedClass] `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses param.Field[[]DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsTransferredClass] `json:"transferred_classes"` +} + +func (r DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations) implementsWorkersForPlatformsDispatchNamespaceScriptUpdateParamsMetadataMigrations() { +} + +type DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsRenamedClass struct { + From param.Field[string] `json:"from"` + To param.Field[string] `json:"to"` +} + +func (r DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsRenamedClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsTransferredClass struct { + From param.Field[string] `json:"from"` + FromScript param.Field[string] `json:"from_script"` + To param.Field[string] `json:"to"` +} + +func (r DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsTransferredClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrations struct { + // Tag to set as the latest migration tag. + NewTag param.Field[string] `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag param.Field[string] `json:"old_tag"` + // Migrations to apply in order. + Steps param.Field[[]DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStep] `json:"steps"` +} + +func (r DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrations) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrations) implementsWorkersForPlatformsDispatchNamespaceScriptUpdateParamsMetadataMigrations() { +} + +type DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStep struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses param.Field[[]string] `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses param.Field[[]string] `json:"new_classes"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses param.Field[[]DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass] `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses param.Field[[]DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass] `json:"transferred_classes"` +} + +func (r DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStep) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { + From param.Field[string] `json:"from"` + To param.Field[string] `json:"to"` +} + +func (r DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { + From param.Field[string] `json:"from"` + FromScript param.Field[string] `json:"from_script"` + To param.Field[string] `json:"to"` +} + +func (r DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DispatchNamespaceScriptUpdateParamsMetadataPlacement struct { + // Enables + // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + // Only `"smart"` is currently supported + Mode param.Field[DispatchNamespaceScriptUpdateParamsMetadataPlacementMode] `json:"mode"` +} + +func (r DispatchNamespaceScriptUpdateParamsMetadataPlacement) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enables +// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). +// Only `"smart"` is currently supported +type DispatchNamespaceScriptUpdateParamsMetadataPlacementMode string + +const ( + DispatchNamespaceScriptUpdateParamsMetadataPlacementModeSmart DispatchNamespaceScriptUpdateParamsMetadataPlacementMode = "smart" +) + +// A reference to a script that will consume logs from the attached Worker. +type DispatchNamespaceScriptUpdateParamsMetadataTailConsumer struct { + // Name of Worker that is to be the consumer. + Service param.Field[string] `json:"service,required"` + // Optional environment if the Worker utilizes one. + Environment param.Field[string] `json:"environment"` + // Optional dispatch namespace the script belongs to. + Namespace param.Field[string] `json:"namespace"` +} + +func (r DispatchNamespaceScriptUpdateParamsMetadataTailConsumer) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Usage model to apply to invocations. +type DispatchNamespaceScriptUpdateParamsMetadataUsageModel string + +const ( + DispatchNamespaceScriptUpdateParamsMetadataUsageModelBundled DispatchNamespaceScriptUpdateParamsMetadataUsageModel = "bundled" + DispatchNamespaceScriptUpdateParamsMetadataUsageModelUnbound DispatchNamespaceScriptUpdateParamsMetadataUsageModel = "unbound" +) + +type DispatchNamespaceScriptUpdateResponseEnvelope struct { + Errors []DispatchNamespaceScriptUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []DispatchNamespaceScriptUpdateResponseEnvelopeMessages `json:"messages,required"` + Result workers.WorkersScript `json:"result,required"` + // Whether the API call was successful + Success DispatchNamespaceScriptUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON dispatchNamespaceScriptUpdateResponseEnvelopeJSON `json:"-"` +} + +// dispatchNamespaceScriptUpdateResponseEnvelopeJSON contains the JSON metadata for +// the struct [DispatchNamespaceScriptUpdateResponseEnvelope] +type dispatchNamespaceScriptUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dispatchNamespaceScriptUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// dispatchNamespaceScriptUpdateResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [DispatchNamespaceScriptUpdateResponseEnvelopeErrors] +type dispatchNamespaceScriptUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dispatchNamespaceScriptUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// dispatchNamespaceScriptUpdateResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [DispatchNamespaceScriptUpdateResponseEnvelopeMessages] +type dispatchNamespaceScriptUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DispatchNamespaceScriptUpdateResponseEnvelopeSuccess bool + +const ( + DispatchNamespaceScriptUpdateResponseEnvelopeSuccessTrue DispatchNamespaceScriptUpdateResponseEnvelopeSuccess = true +) + +type DispatchNamespaceScriptDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // If set to true, delete will not be stopped by associated service binding, + // durable object, or other binding. Any of these associated bindings/durable + // objects will be deleted along with the script. + Force param.Field[bool] `query:"force"` +} + +// URLQuery serializes [DispatchNamespaceScriptDeleteParams]'s query parameters as +// `url.Values`. +func (r DispatchNamespaceScriptDeleteParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type DispatchNamespaceScriptGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type DispatchNamespaceScriptGetResponseEnvelope struct { + Errors []DispatchNamespaceScriptGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DispatchNamespaceScriptGetResponseEnvelopeMessages `json:"messages,required"` + // Details about a worker uploaded to a Workers for Platforms namespace. + Result WorkersNamespaceScript `json:"result,required"` + // Whether the API call was successful + Success DispatchNamespaceScriptGetResponseEnvelopeSuccess `json:"success,required"` + JSON dispatchNamespaceScriptGetResponseEnvelopeJSON `json:"-"` +} + +// dispatchNamespaceScriptGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [DispatchNamespaceScriptGetResponseEnvelope] +type dispatchNamespaceScriptGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dispatchNamespaceScriptGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// dispatchNamespaceScriptGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [DispatchNamespaceScriptGetResponseEnvelopeErrors] +type dispatchNamespaceScriptGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dispatchNamespaceScriptGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// dispatchNamespaceScriptGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [DispatchNamespaceScriptGetResponseEnvelopeMessages] +type dispatchNamespaceScriptGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DispatchNamespaceScriptGetResponseEnvelopeSuccess bool + +const ( + DispatchNamespaceScriptGetResponseEnvelopeSuccessTrue DispatchNamespaceScriptGetResponseEnvelopeSuccess = true +) diff --git a/workers_for_platforms/dispatchnamespacescript_test.go b/workers_for_platforms/dispatchnamespacescript_test.go new file mode 100644 index 00000000000..9fe8fbf2b50 --- /dev/null +++ b/workers_for_platforms/dispatchnamespacescript_test.go @@ -0,0 +1,174 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_for_platforms_test + +import ( + "bytes" + "context" + "errors" + "io" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers_for_platforms" +) + +func TestDispatchNamespaceScriptUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Update( + context.TODO(), + "my-dispatch-namespace", + "this-is_my_script-01", + workers_for_platforms.DispatchNamespaceScriptUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + AnyPartName: cloudflare.F([]io.Reader{io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents")))}), + Message: cloudflare.F("string"), + Metadata: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptUpdateParamsMetadata{ + Bindings: cloudflare.F([]interface{}{map[string]interface{}{ + "name": "MY_ENV_VAR", + "text": "my_data", + "type": "plain_text", + }}), + BodyPart: cloudflare.F("worker.js"), + CompatibilityDate: cloudflare.F("2023-07-25"), + CompatibilityFlags: cloudflare.F([]string{"string", "string", "string"}), + KeepBindings: cloudflare.F([]string{"string", "string", "string"}), + Logpush: cloudflare.F(false), + MainModule: cloudflare.F("worker.js"), + Migrations: cloudflare.F[workers_for_platforms.DispatchNamespaceScriptUpdateParamsMetadataMigrations](workers_for_platforms.DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations(workers_for_platforms.DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations{ + NewTag: cloudflare.F("v2"), + OldTag: cloudflare.F("v1"), + DeletedClasses: cloudflare.F([]string{"string", "string", "string"}), + NewClasses: cloudflare.F([]string{"string", "string", "string"}), + RenamedClasses: cloudflare.F([]workers_for_platforms.DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsRenamedClass{{ + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }}), + TransferredClasses: cloudflare.F([]workers_for_platforms.DispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsTransferredClass{{ + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }}), + })), + Placement: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptUpdateParamsMetadataPlacement{ + Mode: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptUpdateParamsMetadataPlacementModeSmart), + }), + Tags: cloudflare.F([]string{"string", "string", "string"}), + TailConsumers: cloudflare.F([]workers_for_platforms.DispatchNamespaceScriptUpdateParamsMetadataTailConsumer{{ + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), + }, { + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), + }, { + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), + }}), + UsageModel: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptUpdateParamsMetadataUsageModelBundled), + VersionTags: cloudflare.F[any](map[string]interface{}{}), + }), + }, + ) + 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 TestDispatchNamespaceScriptDeleteWithOptionalParams(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("user@example.com"), + ) + err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Delete( + context.TODO(), + "my-dispatch-namespace", + "this-is_my_script-01", + workers_for_platforms.DispatchNamespaceScriptDeleteParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Force: cloudflare.F(true), + }, + ) + 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 TestDispatchNamespaceScriptGet(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("user@example.com"), + ) + _, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Get( + context.TODO(), + "my-dispatch-namespace", + "this-is_my_script-01", + workers_for_platforms.DispatchNamespaceScriptGetParams{ + AccountID: cloudflare.F("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/workers_for_platforms/dispatchnamespacescriptcontent.go b/workers_for_platforms/dispatchnamespacescriptcontent.go new file mode 100644 index 00000000000..f45dfa05231 --- /dev/null +++ b/workers_for_platforms/dispatchnamespacescriptcontent.go @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_for_platforms + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// DispatchNamespaceScriptContentService 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 +// [NewDispatchNamespaceScriptContentService] method instead. +type DispatchNamespaceScriptContentService struct { + Options []option.RequestOption + Scripts *DispatchNamespaceScriptContentScriptService + Settings *DispatchNamespaceScriptContentSettingService + Bindings *DispatchNamespaceScriptContentBindingService +} + +// NewDispatchNamespaceScriptContentService 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 NewDispatchNamespaceScriptContentService(opts ...option.RequestOption) (r *DispatchNamespaceScriptContentService) { + r = &DispatchNamespaceScriptContentService{} + r.Options = opts + r.Scripts = NewDispatchNamespaceScriptContentScriptService(opts...) + r.Settings = NewDispatchNamespaceScriptContentSettingService(opts...) + r.Bindings = NewDispatchNamespaceScriptContentBindingService(opts...) + return +} diff --git a/workers_for_platforms/dispatchnamespacescriptcontentbinding.go b/workers_for_platforms/dispatchnamespacescriptcontentbinding.go new file mode 100644 index 00000000000..120d9e490d6 --- /dev/null +++ b/workers_for_platforms/dispatchnamespacescriptcontentbinding.go @@ -0,0 +1,489 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_for_platforms + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// DispatchNamespaceScriptContentBindingService 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 +// [NewDispatchNamespaceScriptContentBindingService] method instead. +type DispatchNamespaceScriptContentBindingService struct { + Options []option.RequestOption +} + +// NewDispatchNamespaceScriptContentBindingService 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 NewDispatchNamespaceScriptContentBindingService(opts ...option.RequestOption) (r *DispatchNamespaceScriptContentBindingService) { + r = &DispatchNamespaceScriptContentBindingService{} + r.Options = opts + return +} + +// Fetch script bindings from a script uploaded to a Workers for Platforms +// namespace. +func (r *DispatchNamespaceScriptContentBindingService) Get(ctx context.Context, dispatchNamespace string, scriptName string, query DispatchNamespaceScriptContentBindingGetParams, opts ...option.RequestOption) (res *DispatchNamespaceScriptContentBindingGetResponse, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s/bindings", query.AccountID, dispatchNamespace, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +// A binding to allow the Worker to communicate with resources +// +// Union satisfied by +// [workers_for_platforms.DispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBinding], +// [workers_for_platforms.DispatchNamespaceScriptContentBindingGetResponseWorkersServiceBinding], +// [workers_for_platforms.DispatchNamespaceScriptContentBindingGetResponseWorkersDoBinding], +// [workers_for_platforms.DispatchNamespaceScriptContentBindingGetResponseWorkersR2Binding], +// [workers_for_platforms.DispatchNamespaceScriptContentBindingGetResponseWorkersQueueBinding], +// [workers_for_platforms.DispatchNamespaceScriptContentBindingGetResponseWorkersD1Binding], +// [workers_for_platforms.DispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBinding] +// or +// [workers_for_platforms.DispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBinding]. +type DispatchNamespaceScriptContentBindingGetResponse interface { + implementsWorkersForPlatformsDispatchNamespaceScriptContentBindingGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DispatchNamespaceScriptContentBindingGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentBindingGetResponseWorkersServiceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentBindingGetResponseWorkersDoBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentBindingGetResponseWorkersR2Binding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentBindingGetResponseWorkersQueueBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentBindingGetResponseWorkersD1Binding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBinding{}), + }, + ) +} + +type DispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Namespace identifier tag. + NamespaceID string `json:"namespace_id,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBindingType `json:"type,required"` + JSON dispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBinding] +type dispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBindingJSON struct { + Name apijson.Field + NamespaceID apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentBindingGetResponse() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBindingType string + +const ( + DispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBindingTypeKVNamespace DispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBindingType = "kv_namespace" +) + +type DispatchNamespaceScriptContentBindingGetResponseWorkersServiceBinding struct { + // Optional environment if the Worker utilizes one. + Environment string `json:"environment,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Name of Worker to bind to + Service string `json:"service,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentBindingGetResponseWorkersServiceBindingType `json:"type,required"` + JSON dispatchNamespaceScriptContentBindingGetResponseWorkersServiceBindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentBindingGetResponseWorkersServiceBindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentBindingGetResponseWorkersServiceBinding] +type dispatchNamespaceScriptContentBindingGetResponseWorkersServiceBindingJSON struct { + Environment apijson.Field + Name apijson.Field + Service apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentBindingGetResponseWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentBindingGetResponseWorkersServiceBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentBindingGetResponseWorkersServiceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentBindingGetResponse() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentBindingGetResponseWorkersServiceBindingType string + +const ( + DispatchNamespaceScriptContentBindingGetResponseWorkersServiceBindingTypeService DispatchNamespaceScriptContentBindingGetResponseWorkersServiceBindingType = "service" +) + +type DispatchNamespaceScriptContentBindingGetResponseWorkersDoBinding struct { + // The exported class name of the Durable Object + ClassName string `json:"class_name,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentBindingGetResponseWorkersDoBindingType `json:"type,required"` + // The environment of the script_name to bind to + Environment string `json:"environment"` + // Namespace identifier tag. + NamespaceID string `json:"namespace_id"` + // The script where the Durable Object is defined, if it is external to this Worker + ScriptName string `json:"script_name"` + JSON dispatchNamespaceScriptContentBindingGetResponseWorkersDoBindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentBindingGetResponseWorkersDoBindingJSON contains +// the JSON metadata for the struct +// [DispatchNamespaceScriptContentBindingGetResponseWorkersDoBinding] +type dispatchNamespaceScriptContentBindingGetResponseWorkersDoBindingJSON struct { + ClassName apijson.Field + Name apijson.Field + Type apijson.Field + Environment apijson.Field + NamespaceID apijson.Field + ScriptName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentBindingGetResponseWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentBindingGetResponseWorkersDoBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentBindingGetResponseWorkersDoBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentBindingGetResponse() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentBindingGetResponseWorkersDoBindingType string + +const ( + DispatchNamespaceScriptContentBindingGetResponseWorkersDoBindingTypeDurableObjectNamespace DispatchNamespaceScriptContentBindingGetResponseWorkersDoBindingType = "durable_object_namespace" +) + +type DispatchNamespaceScriptContentBindingGetResponseWorkersR2Binding struct { + // R2 bucket to bind to + BucketName string `json:"bucket_name,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentBindingGetResponseWorkersR2BindingType `json:"type,required"` + JSON dispatchNamespaceScriptContentBindingGetResponseWorkersR2BindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentBindingGetResponseWorkersR2BindingJSON contains +// the JSON metadata for the struct +// [DispatchNamespaceScriptContentBindingGetResponseWorkersR2Binding] +type dispatchNamespaceScriptContentBindingGetResponseWorkersR2BindingJSON struct { + BucketName apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentBindingGetResponseWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentBindingGetResponseWorkersR2BindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentBindingGetResponseWorkersR2Binding) implementsWorkersForPlatformsDispatchNamespaceScriptContentBindingGetResponse() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentBindingGetResponseWorkersR2BindingType string + +const ( + DispatchNamespaceScriptContentBindingGetResponseWorkersR2BindingTypeR2Bucket DispatchNamespaceScriptContentBindingGetResponseWorkersR2BindingType = "r2_bucket" +) + +type DispatchNamespaceScriptContentBindingGetResponseWorkersQueueBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Name of the Queue to bind to + QueueName string `json:"queue_name,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentBindingGetResponseWorkersQueueBindingType `json:"type,required"` + JSON dispatchNamespaceScriptContentBindingGetResponseWorkersQueueBindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentBindingGetResponseWorkersQueueBindingJSON contains +// the JSON metadata for the struct +// [DispatchNamespaceScriptContentBindingGetResponseWorkersQueueBinding] +type dispatchNamespaceScriptContentBindingGetResponseWorkersQueueBindingJSON struct { + Name apijson.Field + QueueName apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentBindingGetResponseWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentBindingGetResponseWorkersQueueBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentBindingGetResponseWorkersQueueBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentBindingGetResponse() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentBindingGetResponseWorkersQueueBindingType string + +const ( + DispatchNamespaceScriptContentBindingGetResponseWorkersQueueBindingTypeQueue DispatchNamespaceScriptContentBindingGetResponseWorkersQueueBindingType = "queue" +) + +type DispatchNamespaceScriptContentBindingGetResponseWorkersD1Binding struct { + // ID of the D1 database to bind to + ID string `json:"id,required"` + // A JavaScript variable name for the binding. + Binding string `json:"binding,required"` + // The name of the D1 database associated with the 'id' provided. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentBindingGetResponseWorkersD1BindingType `json:"type,required"` + JSON dispatchNamespaceScriptContentBindingGetResponseWorkersD1BindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentBindingGetResponseWorkersD1BindingJSON contains +// the JSON metadata for the struct +// [DispatchNamespaceScriptContentBindingGetResponseWorkersD1Binding] +type dispatchNamespaceScriptContentBindingGetResponseWorkersD1BindingJSON struct { + ID apijson.Field + Binding apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentBindingGetResponseWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentBindingGetResponseWorkersD1BindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentBindingGetResponseWorkersD1Binding) implementsWorkersForPlatformsDispatchNamespaceScriptContentBindingGetResponse() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentBindingGetResponseWorkersD1BindingType string + +const ( + DispatchNamespaceScriptContentBindingGetResponseWorkersD1BindingTypeD1 DispatchNamespaceScriptContentBindingGetResponseWorkersD1BindingType = "d1" +) + +type DispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Namespace to bind to + Namespace string `json:"namespace,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingType `json:"type,required"` + // Outbound worker + Outbound DispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutbound `json:"outbound"` + JSON dispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBinding] +type dispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingJSON struct { + Name apijson.Field + Namespace apijson.Field + Type apijson.Field + Outbound apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentBindingGetResponse() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingType string + +const ( + DispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingTypeDispatchNamespace DispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingType = "dispatch_namespace" +) + +// Outbound worker +type DispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutbound struct { + // Pass information from the Dispatch Worker to the Outbound Worker through the + // parameters + Params []string `json:"params"` + // Outbound worker + Worker DispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` + JSON dispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` +} + +// dispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutbound] +type dispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundJSON struct { + Params apijson.Field + Worker apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { + return r.raw +} + +// Outbound worker +type DispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorker struct { + // Environment of the outbound worker + Environment string `json:"environment"` + // Name of the outbound worker + Service string `json:"service"` + JSON dispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` +} + +// dispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorkerJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorker] +type dispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { + Environment apijson.Field + Service apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBindingType `json:"type,required"` + // ID of the certificate to bind to + CertificateID string `json:"certificate_id"` + JSON dispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBinding] +type dispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBindingJSON struct { + Name apijson.Field + Type apijson.Field + CertificateID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentBindingGetResponse() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBindingType string + +const ( + DispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBindingTypeMTLSCertificate DispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBindingType = "mtls_certificate" +) + +type DispatchNamespaceScriptContentBindingGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} diff --git a/workers_for_platforms/dispatchnamespacescriptcontentbinding_test.go b/workers_for_platforms/dispatchnamespacescriptcontentbinding_test.go new file mode 100644 index 00000000000..5ab80707309 --- /dev/null +++ b/workers_for_platforms/dispatchnamespacescriptcontentbinding_test.go @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_for_platforms_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers_for_platforms" +) + +func TestDispatchNamespaceScriptContentBindingGet(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("user@example.com"), + ) + _, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Bindings.Get( + context.TODO(), + "my-dispatch-namespace", + "this-is_my_script-01", + workers_for_platforms.DispatchNamespaceScriptContentBindingGetParams{ + AccountID: cloudflare.F("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/workers_for_platforms/dispatchnamespacescriptcontentscript.go b/workers_for_platforms/dispatchnamespacescriptcontentscript.go new file mode 100644 index 00000000000..68f0e37c774 --- /dev/null +++ b/workers_for_platforms/dispatchnamespacescriptcontentscript.go @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_for_platforms + +import ( + "bytes" + "context" + "fmt" + "io" + "mime/multipart" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apiform" + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers" +) + +// DispatchNamespaceScriptContentScriptService 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 +// [NewDispatchNamespaceScriptContentScriptService] method instead. +type DispatchNamespaceScriptContentScriptService struct { + Options []option.RequestOption +} + +// NewDispatchNamespaceScriptContentScriptService 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 NewDispatchNamespaceScriptContentScriptService(opts ...option.RequestOption) (r *DispatchNamespaceScriptContentScriptService) { + r = &DispatchNamespaceScriptContentScriptService{} + r.Options = opts + return +} + +// Put script content for a script uploaded to a Workers for Platforms namespace. +func (r *DispatchNamespaceScriptContentScriptService) Update(ctx context.Context, dispatchNamespace string, scriptName string, params DispatchNamespaceScriptContentScriptUpdateParams, opts ...option.RequestOption) (res *workers.WorkersScript, err error) { + opts = append(r.Options[:], opts...) + var env DispatchNamespaceScriptContentScriptUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s/content", params.AccountID, dispatchNamespace, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch script content from a script uploaded to a Workers for Platforms +// namespace. +func (r *DispatchNamespaceScriptContentScriptService) Get(ctx context.Context, dispatchNamespace string, scriptName string, query DispatchNamespaceScriptContentScriptGetParams, opts ...option.RequestOption) (res *http.Response, err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "string")}, opts...) + path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s/content", query.AccountID, dispatchNamespace, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +type DispatchNamespaceScriptContentScriptUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // A module comprising a Worker script, often a javascript file. Multiple modules + // may be provided as separate named parts, but at least one module must be + // present. This should be referenced either in the metadata as `main_module` + // (esm)/`body_part` (service worker) or as a header `CF-WORKER-MAIN-MODULE-PART` + // (esm) /`CF-WORKER-BODY-PART` (service worker) by part name. + AnyPartName param.Field[[]io.Reader] `json:"" format:"binary"` + // JSON encoded metadata about the uploaded parts and Worker configuration. + Metadata param.Field[DispatchNamespaceScriptContentScriptUpdateParamsMetadata] `json:"metadata"` + CfWorkerBodyPart param.Field[string] `header:"CF-WORKER-BODY-PART"` + CfWorkerMainModulePart param.Field[string] `header:"CF-WORKER-MAIN-MODULE-PART"` +} + +func (r DispatchNamespaceScriptContentScriptUpdateParams) MarshalMultipart() (data []byte, contentType string, err error) { + buf := bytes.NewBuffer(nil) + writer := multipart.NewWriter(buf) + err = apiform.MarshalRoot(r, writer) + if err != nil { + writer.Close() + return nil, "", err + } + err = writer.Close() + if err != nil { + return nil, "", err + } + return buf.Bytes(), writer.FormDataContentType(), nil +} + +// JSON encoded metadata about the uploaded parts and Worker configuration. +type DispatchNamespaceScriptContentScriptUpdateParamsMetadata struct { + // Name of the part in the multipart request that contains the script (e.g. the + // file adding a listener to the `fetch` event). Indicates a + // `service worker syntax` Worker. + BodyPart param.Field[string] `json:"body_part"` + // Name of the part in the multipart request that contains the main module (e.g. + // the file exporting a `fetch` handler). Indicates a `module syntax` Worker. + MainModule param.Field[string] `json:"main_module"` +} + +func (r DispatchNamespaceScriptContentScriptUpdateParamsMetadata) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DispatchNamespaceScriptContentScriptUpdateResponseEnvelope struct { + Errors []DispatchNamespaceScriptContentScriptUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []DispatchNamespaceScriptContentScriptUpdateResponseEnvelopeMessages `json:"messages,required"` + Result workers.WorkersScript `json:"result,required"` + // Whether the API call was successful + Success DispatchNamespaceScriptContentScriptUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON dispatchNamespaceScriptContentScriptUpdateResponseEnvelopeJSON `json:"-"` +} + +// dispatchNamespaceScriptContentScriptUpdateResponseEnvelopeJSON contains the JSON +// metadata for the struct +// [DispatchNamespaceScriptContentScriptUpdateResponseEnvelope] +type dispatchNamespaceScriptContentScriptUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentScriptUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentScriptUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentScriptUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dispatchNamespaceScriptContentScriptUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// dispatchNamespaceScriptContentScriptUpdateResponseEnvelopeErrorsJSON contains +// the JSON metadata for the struct +// [DispatchNamespaceScriptContentScriptUpdateResponseEnvelopeErrors] +type dispatchNamespaceScriptContentScriptUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentScriptUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentScriptUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentScriptUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dispatchNamespaceScriptContentScriptUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// dispatchNamespaceScriptContentScriptUpdateResponseEnvelopeMessagesJSON contains +// the JSON metadata for the struct +// [DispatchNamespaceScriptContentScriptUpdateResponseEnvelopeMessages] +type dispatchNamespaceScriptContentScriptUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentScriptUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentScriptUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DispatchNamespaceScriptContentScriptUpdateResponseEnvelopeSuccess bool + +const ( + DispatchNamespaceScriptContentScriptUpdateResponseEnvelopeSuccessTrue DispatchNamespaceScriptContentScriptUpdateResponseEnvelopeSuccess = true +) + +type DispatchNamespaceScriptContentScriptGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} diff --git a/workers_for_platforms/dispatchnamespacescriptcontentscript_test.go b/workers_for_platforms/dispatchnamespacescriptcontentscript_test.go new file mode 100644 index 00000000000..bd5cb8d936f --- /dev/null +++ b/workers_for_platforms/dispatchnamespacescriptcontentscript_test.go @@ -0,0 +1,100 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_for_platforms_test + +import ( + "bytes" + "context" + "errors" + "io" + "net/http" + "net/http/httptest" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers_for_platforms" +) + +func TestDispatchNamespaceScriptContentScriptUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Scripts.Update( + context.TODO(), + "my-dispatch-namespace", + "this-is_my_script-01", + workers_for_platforms.DispatchNamespaceScriptContentScriptUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + AnyPartName: cloudflare.F([]io.Reader{io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents")))}), + Metadata: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptContentScriptUpdateParamsMetadata{ + BodyPart: cloudflare.F("worker.js"), + MainModule: cloudflare.F("worker.js"), + }), + CfWorkerBodyPart: cloudflare.F("string"), + CfWorkerMainModulePart: cloudflare.F("string"), + }, + ) + 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 TestDispatchNamespaceScriptContentScriptGet(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + w.Write([]byte("abc")) + })) + defer server.Close() + baseURL := server.URL + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("user@example.com"), + ) + resp, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Scripts.Get( + context.TODO(), + "my-dispatch-namespace", + "this-is_my_script-01", + workers_for_platforms.DispatchNamespaceScriptContentScriptGetParams{ + AccountID: cloudflare.F("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()) + } + defer resp.Body.Close() + + b, err := io.ReadAll(resp.Body) + 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()) + } + if !bytes.Equal(b, []byte("abc")) { + t.Fatalf("return value not %s: %s", "abc", b) + } +} diff --git a/workers_for_platforms/dispatchnamespacescriptcontentsetting.go b/workers_for_platforms/dispatchnamespacescriptcontentsetting.go new file mode 100644 index 00000000000..f10446a7d64 --- /dev/null +++ b/workers_for_platforms/dispatchnamespacescriptcontentsetting.go @@ -0,0 +1,2220 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_for_platforms + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// DispatchNamespaceScriptContentSettingService 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 +// [NewDispatchNamespaceScriptContentSettingService] method instead. +type DispatchNamespaceScriptContentSettingService struct { + Options []option.RequestOption +} + +// NewDispatchNamespaceScriptContentSettingService 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 NewDispatchNamespaceScriptContentSettingService(opts ...option.RequestOption) (r *DispatchNamespaceScriptContentSettingService) { + r = &DispatchNamespaceScriptContentSettingService{} + r.Options = opts + return +} + +// Patch script metadata, such as bindings +func (r *DispatchNamespaceScriptContentSettingService) Edit(ctx context.Context, dispatchNamespace string, scriptName string, params DispatchNamespaceScriptContentSettingEditParams, opts ...option.RequestOption) (res *DispatchNamespaceScriptContentSettingEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env DispatchNamespaceScriptContentSettingEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s/settings", params.AccountID, dispatchNamespace, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get script settings from a script uploaded to a Workers for Platforms namespace. +func (r *DispatchNamespaceScriptContentSettingService) Get(ctx context.Context, dispatchNamespace string, scriptName string, query DispatchNamespaceScriptContentSettingGetParams, opts ...option.RequestOption) (res *DispatchNamespaceScriptContentSettingGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env DispatchNamespaceScriptContentSettingGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s/settings", query.AccountID, dispatchNamespace, scriptName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DispatchNamespaceScriptContentSettingEditResponse struct { + // List of bindings attached to this Worker + Bindings []DispatchNamespaceScriptContentSettingEditResponseBinding `json:"bindings"` + // Opt your Worker into changes after this date + CompatibilityDate string `json:"compatibility_date"` + // Opt your Worker into specific changes + CompatibilityFlags []string `json:"compatibility_flags"` + // Whether Logpush is turned on for the Worker. + Logpush bool `json:"logpush"` + // Migrations to apply for Durable Objects associated with this Worker. + Migrations DispatchNamespaceScriptContentSettingEditResponseMigrations `json:"migrations"` + Placement DispatchNamespaceScriptContentSettingEditResponsePlacement `json:"placement"` + // Tags to help you manage your Workers + Tags []string `json:"tags"` + // List of Workers that will consume logs from the attached Worker. + TailConsumers []DispatchNamespaceScriptContentSettingEditResponseTailConsumer `json:"tail_consumers"` + // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). + UsageModel string `json:"usage_model"` + JSON dispatchNamespaceScriptContentSettingEditResponseJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseJSON contains the JSON metadata +// for the struct [DispatchNamespaceScriptContentSettingEditResponse] +type dispatchNamespaceScriptContentSettingEditResponseJSON struct { + Bindings apijson.Field + CompatibilityDate apijson.Field + CompatibilityFlags apijson.Field + Logpush apijson.Field + Migrations apijson.Field + Placement apijson.Field + Tags apijson.Field + TailConsumers apijson.Field + UsageModel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseJSON) RawJSON() string { + return r.raw +} + +// A binding to allow the Worker to communicate with resources +// +// Union satisfied by +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBinding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBinding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBinding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2Binding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBinding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1Binding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBinding] +// or +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBinding]. +type DispatchNamespaceScriptContentSettingEditResponseBinding interface { + implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditResponseBinding() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DispatchNamespaceScriptContentSettingEditResponseBinding)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2Binding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1Binding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBinding{}), + }, + ) +} + +type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Namespace identifier tag. + NamespaceID string `json:"namespace_id,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBindingType `json:"type,required"` + JSON dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBinding] +type dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON struct { + Name apijson.Field + NamespaceID apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBindingType string + +const ( + DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBindingType = "kv_namespace" +) + +type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBinding struct { + // Optional environment if the Worker utilizes one. + Environment string `json:"environment,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Name of Worker to bind to + Service string `json:"service,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBindingType `json:"type,required"` + JSON dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBinding] +type dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBindingJSON struct { + Environment apijson.Field + Name apijson.Field + Service apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBindingType string + +const ( + DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBindingTypeService DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBindingType = "service" +) + +type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBinding struct { + // The exported class name of the Durable Object + ClassName string `json:"class_name,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBindingType `json:"type,required"` + // The environment of the script_name to bind to + Environment string `json:"environment"` + // Namespace identifier tag. + NamespaceID string `json:"namespace_id"` + // The script where the Durable Object is defined, if it is external to this Worker + ScriptName string `json:"script_name"` + JSON dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBinding] +type dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBindingJSON struct { + ClassName apijson.Field + Name apijson.Field + Type apijson.Field + Environment apijson.Field + NamespaceID apijson.Field + ScriptName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBindingType string + +const ( + DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBindingTypeDurableObjectNamespace DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBindingType = "durable_object_namespace" +) + +type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2Binding struct { + // R2 bucket to bind to + BucketName string `json:"bucket_name,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2BindingType `json:"type,required"` + JSON dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2BindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2BindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2Binding] +type dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2BindingJSON struct { + BucketName apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2BindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2Binding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2BindingType string + +const ( + DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2BindingTypeR2Bucket DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2BindingType = "r2_bucket" +) + +type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Name of the Queue to bind to + QueueName string `json:"queue_name,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBindingType `json:"type,required"` + JSON dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBinding] +type dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBindingJSON struct { + Name apijson.Field + QueueName apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBindingType string + +const ( + DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBindingTypeQueue DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBindingType = "queue" +) + +type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1Binding struct { + // ID of the D1 database to bind to + ID string `json:"id,required"` + // A JavaScript variable name for the binding. + Binding string `json:"binding,required"` + // The name of the D1 database associated with the 'id' provided. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1BindingType `json:"type,required"` + JSON dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1BindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1BindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1Binding] +type dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1BindingJSON struct { + ID apijson.Field + Binding apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1BindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1Binding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1BindingType string + +const ( + DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1BindingTypeD1 DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1BindingType = "d1" +) + +type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Namespace to bind to + Namespace string `json:"namespace,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingType `json:"type,required"` + // Outbound worker + Outbound DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound `json:"outbound"` + JSON dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBinding] +type dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON struct { + Name apijson.Field + Namespace apijson.Field + Type apijson.Field + Outbound apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingType string + +const ( + DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" +) + +// Outbound worker +type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound struct { + // Pass information from the Dispatch Worker to the Outbound Worker through the + // parameters + Params []string `json:"params"` + // Outbound worker + Worker DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` + JSON dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound] +type dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON struct { + Params apijson.Field + Worker apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { + return r.raw +} + +// Outbound worker +type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { + // Environment of the outbound worker + Environment string `json:"environment"` + // Name of the outbound worker + Service string `json:"service"` + JSON dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker] +type dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { + Environment apijson.Field + Service apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBindingType `json:"type,required"` + // ID of the certificate to bind to + CertificateID string `json:"certificate_id"` + JSON dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBinding] +type dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBindingJSON struct { + Name apijson.Field + Type apijson.Field + CertificateID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditResponseBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBindingType string + +const ( + DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBindingTypeMTLSCertificate DispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBindingType = "mtls_certificate" +) + +// Migrations to apply for Durable Objects associated with this Worker. +// +// Union satisfied by +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrations] +// or +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrations]. +type DispatchNamespaceScriptContentSettingEditResponseMigrations interface { + implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditResponseMigrations() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DispatchNamespaceScriptContentSettingEditResponseMigrations)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrations{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrations{}), + }, + ) +} + +// A single set of migrations to apply. +type DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrations struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses []string `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses []string `json:"new_classes"` + // Tag to set as the latest migration tag. + NewTag string `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag string `json:"old_tag"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses []DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses []DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass `json:"transferred_classes"` + JSON dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrations] +type dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON struct { + DeletedClasses apijson.Field + NewClasses apijson.Field + NewTag apijson.Field + OldTag apijson.Field + RenamedClasses apijson.Field + TransferredClasses apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrations) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrations) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditResponseMigrations() { +} + +type DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass struct { + From string `json:"from"` + To string `json:"to"` + JSON dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass] +type dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON struct { + From apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass struct { + From string `json:"from"` + FromScript string `json:"from_script"` + To string `json:"to"` + JSON dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass] +type dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON struct { + From apijson.Field + FromScript apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrations struct { + // Tag to set as the latest migration tag. + NewTag string `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag string `json:"old_tag"` + // Migrations to apply in order. + Steps []DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStep `json:"steps"` + JSON dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrations] +type dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON struct { + NewTag apijson.Field + OldTag apijson.Field + Steps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrations) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrations) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditResponseMigrations() { +} + +type DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStep struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses []string `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses []string `json:"new_classes"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses []DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses []DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass `json:"transferred_classes"` + JSON dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStep] +type dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON struct { + DeletedClasses apijson.Field + NewClasses apijson.Field + RenamedClasses apijson.Field + TransferredClasses apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStep) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { + From string `json:"from"` + To string `json:"to"` + JSON dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass] +type dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON struct { + From apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { + From string `json:"from"` + FromScript string `json:"from_script"` + To string `json:"to"` + JSON dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass] +type dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON struct { + From apijson.Field + FromScript apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentSettingEditResponsePlacement struct { + // Enables + // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + // Only `"smart"` is currently supported + Mode DispatchNamespaceScriptContentSettingEditResponsePlacementMode `json:"mode"` + JSON dispatchNamespaceScriptContentSettingEditResponsePlacementJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponsePlacementJSON contains the JSON +// metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponsePlacement] +type dispatchNamespaceScriptContentSettingEditResponsePlacementJSON struct { + Mode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponsePlacement) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponsePlacementJSON) RawJSON() string { + return r.raw +} + +// Enables +// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). +// Only `"smart"` is currently supported +type DispatchNamespaceScriptContentSettingEditResponsePlacementMode string + +const ( + DispatchNamespaceScriptContentSettingEditResponsePlacementModeSmart DispatchNamespaceScriptContentSettingEditResponsePlacementMode = "smart" +) + +// A reference to a script that will consume logs from the attached Worker. +type DispatchNamespaceScriptContentSettingEditResponseTailConsumer struct { + // Name of Worker that is to be the consumer. + Service string `json:"service,required"` + // Optional environment if the Worker utilizes one. + Environment string `json:"environment"` + // Optional dispatch namespace the script belongs to. + Namespace string `json:"namespace"` + JSON dispatchNamespaceScriptContentSettingEditResponseTailConsumerJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseTailConsumerJSON contains the +// JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseTailConsumer] +type dispatchNamespaceScriptContentSettingEditResponseTailConsumerJSON struct { + Service apijson.Field + Environment apijson.Field + Namespace apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseTailConsumerJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentSettingGetResponse struct { + // List of bindings attached to this Worker + Bindings []DispatchNamespaceScriptContentSettingGetResponseBinding `json:"bindings"` + // Opt your Worker into changes after this date + CompatibilityDate string `json:"compatibility_date"` + // Opt your Worker into specific changes + CompatibilityFlags []string `json:"compatibility_flags"` + // Whether Logpush is turned on for the Worker. + Logpush bool `json:"logpush"` + // Migrations to apply for Durable Objects associated with this Worker. + Migrations DispatchNamespaceScriptContentSettingGetResponseMigrations `json:"migrations"` + Placement DispatchNamespaceScriptContentSettingGetResponsePlacement `json:"placement"` + // Tags to help you manage your Workers + Tags []string `json:"tags"` + // List of Workers that will consume logs from the attached Worker. + TailConsumers []DispatchNamespaceScriptContentSettingGetResponseTailConsumer `json:"tail_consumers"` + // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). + UsageModel string `json:"usage_model"` + JSON dispatchNamespaceScriptContentSettingGetResponseJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseJSON contains the JSON metadata +// for the struct [DispatchNamespaceScriptContentSettingGetResponse] +type dispatchNamespaceScriptContentSettingGetResponseJSON struct { + Bindings apijson.Field + CompatibilityDate apijson.Field + CompatibilityFlags apijson.Field + Logpush apijson.Field + Migrations apijson.Field + Placement apijson.Field + Tags apijson.Field + TailConsumers apijson.Field + UsageModel apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseJSON) RawJSON() string { + return r.raw +} + +// A binding to allow the Worker to communicate with resources +// +// Union satisfied by +// [workers_for_platforms.DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBinding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBinding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBinding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2Binding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBinding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1Binding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBinding] +// or +// [workers_for_platforms.DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBinding]. +type DispatchNamespaceScriptContentSettingGetResponseBinding interface { + implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingGetResponseBinding() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DispatchNamespaceScriptContentSettingGetResponseBinding)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2Binding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1Binding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBinding{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBinding{}), + }, + ) +} + +type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Namespace identifier tag. + NamespaceID string `json:"namespace_id,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBindingType `json:"type,required"` + JSON dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBinding] +type dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON struct { + Name apijson.Field + NamespaceID apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBindingType string + +const ( + DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBindingType = "kv_namespace" +) + +type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBinding struct { + // Optional environment if the Worker utilizes one. + Environment string `json:"environment,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Name of Worker to bind to + Service string `json:"service,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBindingType `json:"type,required"` + JSON dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBinding] +type dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBindingJSON struct { + Environment apijson.Field + Name apijson.Field + Service apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBindingType string + +const ( + DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBindingTypeService DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBindingType = "service" +) + +type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBinding struct { + // The exported class name of the Durable Object + ClassName string `json:"class_name,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBindingType `json:"type,required"` + // The environment of the script_name to bind to + Environment string `json:"environment"` + // Namespace identifier tag. + NamespaceID string `json:"namespace_id"` + // The script where the Durable Object is defined, if it is external to this Worker + ScriptName string `json:"script_name"` + JSON dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBinding] +type dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBindingJSON struct { + ClassName apijson.Field + Name apijson.Field + Type apijson.Field + Environment apijson.Field + NamespaceID apijson.Field + ScriptName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBindingType string + +const ( + DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBindingTypeDurableObjectNamespace DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBindingType = "durable_object_namespace" +) + +type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2Binding struct { + // R2 bucket to bind to + BucketName string `json:"bucket_name,required"` + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2BindingType `json:"type,required"` + JSON dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2BindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2BindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2Binding] +type dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2BindingJSON struct { + BucketName apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2BindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2Binding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2BindingType string + +const ( + DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2BindingTypeR2Bucket DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2BindingType = "r2_bucket" +) + +type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Name of the Queue to bind to + QueueName string `json:"queue_name,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBindingType `json:"type,required"` + JSON dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBinding] +type dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBindingJSON struct { + Name apijson.Field + QueueName apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBindingType string + +const ( + DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBindingTypeQueue DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBindingType = "queue" +) + +type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1Binding struct { + // ID of the D1 database to bind to + ID string `json:"id,required"` + // A JavaScript variable name for the binding. + Binding string `json:"binding,required"` + // The name of the D1 database associated with the 'id' provided. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1BindingType `json:"type,required"` + JSON dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1BindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1BindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1Binding] +type dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1BindingJSON struct { + ID apijson.Field + Binding apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1BindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1Binding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1BindingType string + +const ( + DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1BindingTypeD1 DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1BindingType = "d1" +) + +type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // Namespace to bind to + Namespace string `json:"namespace,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingType `json:"type,required"` + // Outbound worker + Outbound DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound `json:"outbound"` + JSON dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBinding] +type dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON struct { + Name apijson.Field + Namespace apijson.Field + Type apijson.Field + Outbound apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingType string + +const ( + DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" +) + +// Outbound worker +type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound struct { + // Pass information from the Dispatch Worker to the Outbound Worker through the + // parameters + Params []string `json:"params"` + // Outbound worker + Worker DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` + JSON dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound] +type dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON struct { + Params apijson.Field + Worker apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { + return r.raw +} + +// Outbound worker +type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { + // Environment of the outbound worker + Environment string `json:"environment"` + // Name of the outbound worker + Service string `json:"service"` + JSON dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker] +type dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { + Environment apijson.Field + Service apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBinding struct { + // A JavaScript variable name for the binding. + Name string `json:"name,required"` + // The class of resource that the binding provides. + Type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBindingType `json:"type,required"` + // ID of the certificate to bind to + CertificateID string `json:"certificate_id"` + JSON dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBindingJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBindingJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBinding] +type dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBindingJSON struct { + Name apijson.Field + Type apijson.Field + CertificateID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBinding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBindingJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingGetResponseBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBindingType string + +const ( + DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBindingTypeMTLSCertificate DispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBindingType = "mtls_certificate" +) + +// Migrations to apply for Durable Objects associated with this Worker. +// +// Union satisfied by +// [workers_for_platforms.DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrations] +// or +// [workers_for_platforms.DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrations]. +type DispatchNamespaceScriptContentSettingGetResponseMigrations interface { + implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingGetResponseMigrations() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DispatchNamespaceScriptContentSettingGetResponseMigrations)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrations{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrations{}), + }, + ) +} + +// A single set of migrations to apply. +type DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrations struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses []string `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses []string `json:"new_classes"` + // Tag to set as the latest migration tag. + NewTag string `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag string `json:"old_tag"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses []DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses []DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass `json:"transferred_classes"` + JSON dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrations] +type dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON struct { + DeletedClasses apijson.Field + NewClasses apijson.Field + NewTag apijson.Field + OldTag apijson.Field + RenamedClasses apijson.Field + TransferredClasses apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrations) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrations) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingGetResponseMigrations() { +} + +type DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass struct { + From string `json:"from"` + To string `json:"to"` + JSON dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass] +type dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON struct { + From apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass struct { + From string `json:"from"` + FromScript string `json:"from_script"` + To string `json:"to"` + JSON dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass] +type dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON struct { + From apijson.Field + FromScript apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrations struct { + // Tag to set as the latest migration tag. + NewTag string `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag string `json:"old_tag"` + // Migrations to apply in order. + Steps []DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStep `json:"steps"` + JSON dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrations] +type dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON struct { + NewTag apijson.Field + OldTag apijson.Field + Steps apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrations) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON) RawJSON() string { + return r.raw +} + +func (r DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrations) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingGetResponseMigrations() { +} + +type DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStep struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses []string `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses []string `json:"new_classes"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses []DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses []DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass `json:"transferred_classes"` + JSON dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStep] +type dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON struct { + DeletedClasses apijson.Field + NewClasses apijson.Field + RenamedClasses apijson.Field + TransferredClasses apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStep) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { + From string `json:"from"` + To string `json:"to"` + JSON dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass] +type dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON struct { + From apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { + From string `json:"from"` + FromScript string `json:"from_script"` + To string `json:"to"` + JSON dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON +// contains the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass] +type dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON struct { + From apijson.Field + FromScript apijson.Field + To apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentSettingGetResponsePlacement struct { + // Enables + // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + // Only `"smart"` is currently supported + Mode DispatchNamespaceScriptContentSettingGetResponsePlacementMode `json:"mode"` + JSON dispatchNamespaceScriptContentSettingGetResponsePlacementJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponsePlacementJSON contains the JSON +// metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponsePlacement] +type dispatchNamespaceScriptContentSettingGetResponsePlacementJSON struct { + Mode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponsePlacement) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponsePlacementJSON) RawJSON() string { + return r.raw +} + +// Enables +// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). +// Only `"smart"` is currently supported +type DispatchNamespaceScriptContentSettingGetResponsePlacementMode string + +const ( + DispatchNamespaceScriptContentSettingGetResponsePlacementModeSmart DispatchNamespaceScriptContentSettingGetResponsePlacementMode = "smart" +) + +// A reference to a script that will consume logs from the attached Worker. +type DispatchNamespaceScriptContentSettingGetResponseTailConsumer struct { + // Name of Worker that is to be the consumer. + Service string `json:"service,required"` + // Optional environment if the Worker utilizes one. + Environment string `json:"environment"` + // Optional dispatch namespace the script belongs to. + Namespace string `json:"namespace"` + JSON dispatchNamespaceScriptContentSettingGetResponseTailConsumerJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseTailConsumerJSON contains the +// JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseTailConsumer] +type dispatchNamespaceScriptContentSettingGetResponseTailConsumerJSON struct { + Service apijson.Field + Environment apijson.Field + Namespace apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseTailConsumerJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentSettingEditParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Errors param.Field[[]DispatchNamespaceScriptContentSettingEditParamsError] `json:"errors,required"` + Messages param.Field[[]DispatchNamespaceScriptContentSettingEditParamsMessage] `json:"messages,required"` + Result param.Field[DispatchNamespaceScriptContentSettingEditParamsResult] `json:"result,required"` + // Whether the API call was successful + Success param.Field[DispatchNamespaceScriptContentSettingEditParamsSuccess] `json:"success,required"` +} + +func (r DispatchNamespaceScriptContentSettingEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DispatchNamespaceScriptContentSettingEditParamsError struct { + Code param.Field[int64] `json:"code,required"` + Message param.Field[string] `json:"message,required"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsError) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DispatchNamespaceScriptContentSettingEditParamsMessage struct { + Code param.Field[int64] `json:"code,required"` + Message param.Field[string] `json:"message,required"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsMessage) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DispatchNamespaceScriptContentSettingEditParamsResult struct { + // List of bindings attached to this Worker + Bindings param.Field[[]DispatchNamespaceScriptContentSettingEditParamsResultBinding] `json:"bindings"` + // Opt your Worker into changes after this date + CompatibilityDate param.Field[string] `json:"compatibility_date"` + // Opt your Worker into specific changes + CompatibilityFlags param.Field[[]string] `json:"compatibility_flags"` + // Whether Logpush is turned on for the Worker. + Logpush param.Field[bool] `json:"logpush"` + // Migrations to apply for Durable Objects associated with this Worker. + Migrations param.Field[DispatchNamespaceScriptContentSettingEditParamsResultMigrations] `json:"migrations"` + Placement param.Field[DispatchNamespaceScriptContentSettingEditParamsResultPlacement] `json:"placement"` + // Tags to help you manage your Workers + Tags param.Field[[]string] `json:"tags"` + // List of Workers that will consume logs from the attached Worker. + TailConsumers param.Field[[]DispatchNamespaceScriptContentSettingEditParamsResultTailConsumer] `json:"tail_consumers"` + // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). + UsageModel param.Field[string] `json:"usage_model"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResult) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A binding to allow the Worker to communicate with resources +// +// Satisfied by +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersServiceBinding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDoBinding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersR2Binding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersQueueBinding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersD1Binding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersMTLSCertBinding]. +type DispatchNamespaceScriptContentSettingEditParamsResultBinding interface { + implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditParamsResultBinding() +} + +type DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding struct { + // The class of resource that the binding provides. + Type param.Field[DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBindingType] `json:"type,required"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditParamsResultBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBindingType string + +const ( + DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBindingType = "kv_namespace" +) + +type DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersServiceBinding struct { + // Optional environment if the Worker utilizes one. + Environment param.Field[string] `json:"environment,required"` + // Name of Worker to bind to + Service param.Field[string] `json:"service,required"` + // The class of resource that the binding provides. + Type param.Field[DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersServiceBindingType] `json:"type,required"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersServiceBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersServiceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditParamsResultBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersServiceBindingType string + +const ( + DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersServiceBindingTypeService DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersServiceBindingType = "service" +) + +type DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDoBinding struct { + // The exported class name of the Durable Object + ClassName param.Field[string] `json:"class_name,required"` + // The class of resource that the binding provides. + Type param.Field[DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDoBindingType] `json:"type,required"` + // The environment of the script_name to bind to + Environment param.Field[string] `json:"environment"` + // The script where the Durable Object is defined, if it is external to this Worker + ScriptName param.Field[string] `json:"script_name"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDoBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDoBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditParamsResultBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDoBindingType string + +const ( + DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDoBindingTypeDurableObjectNamespace DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDoBindingType = "durable_object_namespace" +) + +type DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersR2Binding struct { + // R2 bucket to bind to + BucketName param.Field[string] `json:"bucket_name,required"` + // The class of resource that the binding provides. + Type param.Field[DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersR2BindingType] `json:"type,required"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersR2Binding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersR2Binding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditParamsResultBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersR2BindingType string + +const ( + DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersR2BindingTypeR2Bucket DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersR2BindingType = "r2_bucket" +) + +type DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersQueueBinding struct { + // Name of the Queue to bind to + QueueName param.Field[string] `json:"queue_name,required"` + // The class of resource that the binding provides. + Type param.Field[DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersQueueBindingType] `json:"type,required"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersQueueBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersQueueBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditParamsResultBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersQueueBindingType string + +const ( + DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersQueueBindingTypeQueue DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersQueueBindingType = "queue" +) + +type DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersD1Binding struct { + // ID of the D1 database to bind to + ID param.Field[string] `json:"id,required"` + // The name of the D1 database associated with the 'id' provided. + Name param.Field[string] `json:"name,required"` + // The class of resource that the binding provides. + Type param.Field[DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersD1BindingType] `json:"type,required"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersD1Binding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersD1Binding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditParamsResultBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersD1BindingType string + +const ( + DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersD1BindingTypeD1 DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersD1BindingType = "d1" +) + +type DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding struct { + // Namespace to bind to + Namespace param.Field[string] `json:"namespace,required"` + // The class of resource that the binding provides. + Type param.Field[DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType] `json:"type,required"` + // Outbound worker + Outbound param.Field[DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutbound] `json:"outbound"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditParamsResultBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType string + +const ( + DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" +) + +// Outbound worker +type DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutbound struct { + // Pass information from the Dispatch Worker to the Outbound Worker through the + // parameters + Params param.Field[[]string] `json:"params"` + // Outbound worker + Worker param.Field[DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker] `json:"worker"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutbound) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Outbound worker +type DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { + // Environment of the outbound worker + Environment param.Field[string] `json:"environment"` + // Name of the outbound worker + Service param.Field[string] `json:"service"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersMTLSCertBinding struct { + // The class of resource that the binding provides. + Type param.Field[DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersMTLSCertBindingType] `json:"type,required"` + // ID of the certificate to bind to + CertificateID param.Field[string] `json:"certificate_id"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersMTLSCertBinding) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersMTLSCertBinding) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditParamsResultBinding() { +} + +// The class of resource that the binding provides. +type DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersMTLSCertBindingType string + +const ( + DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersMTLSCertBindingTypeMTLSCertificate DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersMTLSCertBindingType = "mtls_certificate" +) + +// Migrations to apply for Durable Objects associated with this Worker. +// +// Satisfied by +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrations], +// [workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrations]. +type DispatchNamespaceScriptContentSettingEditParamsResultMigrations interface { + implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditParamsResultMigrations() +} + +// A single set of migrations to apply. +type DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrations struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses param.Field[[]string] `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses param.Field[[]string] `json:"new_classes"` + // Tag to set as the latest migration tag. + NewTag param.Field[string] `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag param.Field[string] `json:"old_tag"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses param.Field[[]DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass] `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses param.Field[[]DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass] `json:"transferred_classes"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrations) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrations) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditParamsResultMigrations() { +} + +type DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass struct { + From param.Field[string] `json:"from"` + To param.Field[string] `json:"to"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass struct { + From param.Field[string] `json:"from"` + FromScript param.Field[string] `json:"from_script"` + To param.Field[string] `json:"to"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrations struct { + // Tag to set as the latest migration tag. + NewTag param.Field[string] `json:"new_tag"` + // Tag used to verify against the latest migration tag for this Worker. If they + // don't match, the upload is rejected. + OldTag param.Field[string] `json:"old_tag"` + // Migrations to apply in order. + Steps param.Field[[]DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStep] `json:"steps"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrations) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrations) implementsWorkersForPlatformsDispatchNamespaceScriptContentSettingEditParamsResultMigrations() { +} + +type DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStep struct { + // A list of classes to delete Durable Object namespaces from. + DeletedClasses param.Field[[]string] `json:"deleted_classes"` + // A list of classes to create Durable Object namespaces from. + NewClasses param.Field[[]string] `json:"new_classes"` + // A list of classes with Durable Object namespaces that were renamed. + RenamedClasses param.Field[[]DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass] `json:"renamed_classes"` + // A list of transfers for Durable Object namespaces from a different Worker and + // class to a class defined in this Worker. + TransferredClasses param.Field[[]DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass] `json:"transferred_classes"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStep) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { + From param.Field[string] `json:"from"` + To param.Field[string] `json:"to"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { + From param.Field[string] `json:"from"` + FromScript param.Field[string] `json:"from_script"` + To param.Field[string] `json:"to"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DispatchNamespaceScriptContentSettingEditParamsResultPlacement struct { + // Enables + // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). + // Only `"smart"` is currently supported + Mode param.Field[DispatchNamespaceScriptContentSettingEditParamsResultPlacementMode] `json:"mode"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultPlacement) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enables +// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). +// Only `"smart"` is currently supported +type DispatchNamespaceScriptContentSettingEditParamsResultPlacementMode string + +const ( + DispatchNamespaceScriptContentSettingEditParamsResultPlacementModeSmart DispatchNamespaceScriptContentSettingEditParamsResultPlacementMode = "smart" +) + +// A reference to a script that will consume logs from the attached Worker. +type DispatchNamespaceScriptContentSettingEditParamsResultTailConsumer struct { + // Name of Worker that is to be the consumer. + Service param.Field[string] `json:"service,required"` + // Optional environment if the Worker utilizes one. + Environment param.Field[string] `json:"environment"` + // Optional dispatch namespace the script belongs to. + Namespace param.Field[string] `json:"namespace"` +} + +func (r DispatchNamespaceScriptContentSettingEditParamsResultTailConsumer) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Whether the API call was successful +type DispatchNamespaceScriptContentSettingEditParamsSuccess bool + +const ( + DispatchNamespaceScriptContentSettingEditParamsSuccessTrue DispatchNamespaceScriptContentSettingEditParamsSuccess = true +) + +type DispatchNamespaceScriptContentSettingEditResponseEnvelope struct { + Errors []DispatchNamespaceScriptContentSettingEditResponseEnvelopeErrors `json:"errors,required"` + Messages []DispatchNamespaceScriptContentSettingEditResponseEnvelopeMessages `json:"messages,required"` + Result DispatchNamespaceScriptContentSettingEditResponse `json:"result,required"` + // Whether the API call was successful + Success DispatchNamespaceScriptContentSettingEditResponseEnvelopeSuccess `json:"success,required"` + JSON dispatchNamespaceScriptContentSettingEditResponseEnvelopeJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseEnvelopeJSON contains the JSON +// metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseEnvelope] +type dispatchNamespaceScriptContentSettingEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentSettingEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dispatchNamespaceScriptContentSettingEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseEnvelopeErrorsJSON contains the +// JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseEnvelopeErrors] +type dispatchNamespaceScriptContentSettingEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentSettingEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dispatchNamespaceScriptContentSettingEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingEditResponseEnvelopeMessagesJSON contains +// the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingEditResponseEnvelopeMessages] +type dispatchNamespaceScriptContentSettingEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DispatchNamespaceScriptContentSettingEditResponseEnvelopeSuccess bool + +const ( + DispatchNamespaceScriptContentSettingEditResponseEnvelopeSuccessTrue DispatchNamespaceScriptContentSettingEditResponseEnvelopeSuccess = true +) + +type DispatchNamespaceScriptContentSettingGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type DispatchNamespaceScriptContentSettingGetResponseEnvelope struct { + Errors []DispatchNamespaceScriptContentSettingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DispatchNamespaceScriptContentSettingGetResponseEnvelopeMessages `json:"messages,required"` + Result DispatchNamespaceScriptContentSettingGetResponse `json:"result,required"` + // Whether the API call was successful + Success DispatchNamespaceScriptContentSettingGetResponseEnvelopeSuccess `json:"success,required"` + JSON dispatchNamespaceScriptContentSettingGetResponseEnvelopeJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseEnvelopeJSON contains the JSON +// metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseEnvelope] +type dispatchNamespaceScriptContentSettingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentSettingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dispatchNamespaceScriptContentSettingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseEnvelopeErrorsJSON contains the +// JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseEnvelopeErrors] +type dispatchNamespaceScriptContentSettingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DispatchNamespaceScriptContentSettingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dispatchNamespaceScriptContentSettingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// dispatchNamespaceScriptContentSettingGetResponseEnvelopeMessagesJSON contains +// the JSON metadata for the struct +// [DispatchNamespaceScriptContentSettingGetResponseEnvelopeMessages] +type dispatchNamespaceScriptContentSettingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DispatchNamespaceScriptContentSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dispatchNamespaceScriptContentSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DispatchNamespaceScriptContentSettingGetResponseEnvelopeSuccess bool + +const ( + DispatchNamespaceScriptContentSettingGetResponseEnvelopeSuccessTrue DispatchNamespaceScriptContentSettingGetResponseEnvelopeSuccess = true +) diff --git a/workers_for_platforms/dispatchnamespacescriptcontentsetting_test.go b/workers_for_platforms/dispatchnamespacescriptcontentsetting_test.go new file mode 100644 index 00000000000..dab7efea2c6 --- /dev/null +++ b/workers_for_platforms/dispatchnamespacescriptcontentsetting_test.go @@ -0,0 +1,157 @@ +// File generated from our OpenAPI spec by Stainless. + +package workers_for_platforms_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/workers_for_platforms" +) + +func TestDispatchNamespaceScriptContentSettingEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Settings.Edit( + context.TODO(), + "my-dispatch-namespace", + "this-is_my_script-01", + workers_for_platforms.DispatchNamespaceScriptContentSettingEditParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Errors: cloudflare.F([]workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsError{{ + Code: cloudflare.F(int64(1000)), + Message: cloudflare.F("string"), + }, { + Code: cloudflare.F(int64(1000)), + Message: cloudflare.F("string"), + }, { + Code: cloudflare.F(int64(1000)), + Message: cloudflare.F("string"), + }}), + Messages: cloudflare.F([]workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsMessage{{ + Code: cloudflare.F(int64(1000)), + Message: cloudflare.F("string"), + }, { + Code: cloudflare.F(int64(1000)), + Message: cloudflare.F("string"), + }, { + Code: cloudflare.F(int64(1000)), + Message: cloudflare.F("string"), + }}), + Result: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResult{ + Bindings: cloudflare.F([]workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultBinding{workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding(workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding{ + Type: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), + }), workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding(workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding{ + Type: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), + }), workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding(workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding{ + Type: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), + })}), + CompatibilityDate: cloudflare.F("2022-04-05"), + CompatibilityFlags: cloudflare.F([]string{"formdata_parser_supports_files", "formdata_parser_supports_files", "formdata_parser_supports_files"}), + Logpush: cloudflare.F(false), + Migrations: cloudflare.F[workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultMigrations](workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrations(workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrations{ + NewTag: cloudflare.F("v2"), + OldTag: cloudflare.F("v1"), + DeletedClasses: cloudflare.F([]string{"string", "string", "string"}), + NewClasses: cloudflare.F([]string{"string", "string", "string"}), + RenamedClasses: cloudflare.F([]workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass{{ + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + To: cloudflare.F("string"), + }}), + TransferredClasses: cloudflare.F([]workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass{{ + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }, { + From: cloudflare.F("string"), + FromScript: cloudflare.F("string"), + To: cloudflare.F("string"), + }}), + })), + Placement: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultPlacement{ + Mode: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultPlacementModeSmart), + }), + Tags: cloudflare.F([]string{"my-tag", "my-tag", "my-tag"}), + TailConsumers: cloudflare.F([]workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsResultTailConsumer{{ + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), + }, { + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), + }, { + Environment: cloudflare.F("production"), + Namespace: cloudflare.F("my-namespace"), + Service: cloudflare.F("my-log-consumer"), + }}), + UsageModel: cloudflare.F("unbound"), + }), + Success: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptContentSettingEditParamsSuccessTrue), + }, + ) + 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 TestDispatchNamespaceScriptContentSettingGet(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("user@example.com"), + ) + _, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Settings.Get( + context.TODO(), + "my-dispatch-namespace", + "this-is_my_script-01", + workers_for_platforms.DispatchNamespaceScriptContentSettingGetParams{ + AccountID: cloudflare.F("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/workersforplatform.go b/workers_for_platforms/workersforplatform.go similarity index 88% rename from workersforplatform.go rename to workers_for_platforms/workersforplatform.go index 61bb33a3d1d..ee129d4f922 100644 --- a/workersforplatform.go +++ b/workers_for_platforms/workersforplatform.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package workers_for_platforms import ( "github.com/cloudflare/cloudflare-go/option" @@ -13,7 +13,7 @@ import ( // instead. type WorkersForPlatformService struct { Options []option.RequestOption - Dispatch *WorkersForPlatformDispatchService + Dispatch *DispatchService } // NewWorkersForPlatformService generates a new service that applies the given @@ -22,6 +22,6 @@ type WorkersForPlatformService struct { func NewWorkersForPlatformService(opts ...option.RequestOption) (r *WorkersForPlatformService) { r = &WorkersForPlatformService{} r.Options = opts - r.Dispatch = NewWorkersForPlatformDispatchService(opts...) + r.Dispatch = NewDispatchService(opts...) return } diff --git a/workerscript.go b/workerscript.go deleted file mode 100644 index 96fe8b633a9..00000000000 --- a/workerscript.go +++ /dev/null @@ -1,666 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "bytes" - "context" - "fmt" - "io" - "mime/multipart" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apiform" - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkerScriptService 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 [NewWorkerScriptService] method -// instead. -type WorkerScriptService struct { - Options []option.RequestOption - Bindings *WorkerScriptBindingService - Schedules *WorkerScriptScheduleService - Tail *WorkerScriptTailService - UsageModel *WorkerScriptUsageModelService - Content *WorkerScriptContentService - ContentV2 *WorkerScriptContentV2Service - Settings *WorkerScriptSettingService -} - -// NewWorkerScriptService 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 NewWorkerScriptService(opts ...option.RequestOption) (r *WorkerScriptService) { - r = &WorkerScriptService{} - r.Options = opts - r.Bindings = NewWorkerScriptBindingService(opts...) - r.Schedules = NewWorkerScriptScheduleService(opts...) - r.Tail = NewWorkerScriptTailService(opts...) - r.UsageModel = NewWorkerScriptUsageModelService(opts...) - r.Content = NewWorkerScriptContentService(opts...) - r.ContentV2 = NewWorkerScriptContentV2Service(opts...) - r.Settings = NewWorkerScriptSettingService(opts...) - return -} - -// Upload a worker module. -func (r *WorkerScriptService) Update(ctx context.Context, scriptName string, params WorkerScriptUpdateParams, opts ...option.RequestOption) (res *WorkerScriptUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerScriptUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts/%s", params.AccountID, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch a list of uploaded workers. -func (r *WorkerScriptService) List(ctx context.Context, query WorkerScriptListParams, opts ...option.RequestOption) (res *[]WorkerScriptListResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerScriptListResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete your worker. This call has no response body on a successful delete. -func (r *WorkerScriptService) Delete(ctx context.Context, scriptName string, params WorkerScriptDeleteParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := fmt.Sprintf("accounts/%s/workers/scripts/%s", params.AccountID, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, nil, opts...) - return -} - -// Fetch raw script content for your worker. Note this is the original script -// content, not JSON encoded. -func (r *WorkerScriptService) Get(ctx context.Context, scriptName string, query WorkerScriptGetParams, opts ...option.RequestOption) (res *http.Response, err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "undefined")}, opts...) - path := fmt.Sprintf("accounts/%s/workers/scripts/%s", query.AccountID, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -type WorkerScriptUpdateResponse struct { - // The id of the script in the Workers system. Usually the script name. - ID string `json:"id"` - // When the script was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Hashed script content, can be used in a If-None-Match header when updating. - Etag string `json:"etag"` - // Whether Logpush is turned on for the Worker. - Logpush bool `json:"logpush"` - // When the script was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Deprecated. Deployment metadata for internal usage. - PipelineHash string `json:"pipeline_hash"` - // Specifies the placement mode for the Worker (e.g. 'smart'). - PlacementMode string `json:"placement_mode"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers []WorkerScriptUpdateResponseTailConsumer `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel string `json:"usage_model"` - JSON workerScriptUpdateResponseJSON `json:"-"` -} - -// workerScriptUpdateResponseJSON contains the JSON metadata for the struct -// [WorkerScriptUpdateResponse] -type workerScriptUpdateResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Etag apijson.Field - Logpush apijson.Field - ModifiedOn apijson.Field - PipelineHash apijson.Field - PlacementMode apijson.Field - TailConsumers apijson.Field - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// A reference to a script that will consume logs from the attached Worker. -type WorkerScriptUpdateResponseTailConsumer struct { - // Name of Worker that is to be the consumer. - Service string `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment string `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace string `json:"namespace"` - JSON workerScriptUpdateResponseTailConsumerJSON `json:"-"` -} - -// workerScriptUpdateResponseTailConsumerJSON contains the JSON metadata for the -// struct [WorkerScriptUpdateResponseTailConsumer] -type workerScriptUpdateResponseTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptUpdateResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptUpdateResponseTailConsumerJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptListResponse struct { - // The id of the script in the Workers system. Usually the script name. - ID string `json:"id"` - // When the script was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Hashed script content, can be used in a If-None-Match header when updating. - Etag string `json:"etag"` - // Whether Logpush is turned on for the Worker. - Logpush bool `json:"logpush"` - // When the script was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Deprecated. Deployment metadata for internal usage. - PipelineHash string `json:"pipeline_hash"` - // Specifies the placement mode for the Worker (e.g. 'smart'). - PlacementMode string `json:"placement_mode"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers []WorkerScriptListResponseTailConsumer `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel string `json:"usage_model"` - JSON workerScriptListResponseJSON `json:"-"` -} - -// workerScriptListResponseJSON contains the JSON metadata for the struct -// [WorkerScriptListResponse] -type workerScriptListResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Etag apijson.Field - Logpush apijson.Field - ModifiedOn apijson.Field - PipelineHash apijson.Field - PlacementMode apijson.Field - TailConsumers apijson.Field - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptListResponseJSON) RawJSON() string { - return r.raw -} - -// A reference to a script that will consume logs from the attached Worker. -type WorkerScriptListResponseTailConsumer struct { - // Name of Worker that is to be the consumer. - Service string `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment string `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace string `json:"namespace"` - JSON workerScriptListResponseTailConsumerJSON `json:"-"` -} - -// workerScriptListResponseTailConsumerJSON contains the JSON metadata for the -// struct [WorkerScriptListResponseTailConsumer] -type workerScriptListResponseTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptListResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptListResponseTailConsumerJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Rollback to provided deployment based on deployment ID. Request body will only - // parse a "message" part. You can learn more about deployments - // [here](https://developers.cloudflare.com/workers/platform/deployments/). - RollbackTo param.Field[string] `query:"rollback_to"` - // A module comprising a Worker script, often a javascript file. Multiple modules - // may be provided as separate named parts, but at least one module must be present - // and referenced in the metadata as `main_module` or `body_part` by part name. - AnyPartName param.Field[[]io.Reader] `json:"" format:"binary"` - // Rollback message to be associated with this deployment. Only parsed when query - // param `"rollback_to"` is present. - Message param.Field[string] `json:"message"` - // JSON encoded metadata about the uploaded parts and Worker configuration. - Metadata param.Field[WorkerScriptUpdateParamsMetadata] `json:"metadata"` -} - -func (r WorkerScriptUpdateParams) MarshalMultipart() (data []byte, contentType string, err error) { - buf := bytes.NewBuffer(nil) - writer := multipart.NewWriter(buf) - err = apiform.MarshalRoot(r, writer) - if err != nil { - writer.Close() - return nil, "", err - } - err = writer.Close() - if err != nil { - return nil, "", err - } - return buf.Bytes(), writer.FormDataContentType(), nil -} - -// URLQuery serializes [WorkerScriptUpdateParams]'s query parameters as -// `url.Values`. -func (r WorkerScriptUpdateParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// JSON encoded metadata about the uploaded parts and Worker configuration. -type WorkerScriptUpdateParamsMetadata struct { - // List of bindings available to the worker. - Bindings param.Field[[]interface{}] `json:"bindings"` - // Name of the part in the multipart request that contains the script (e.g. the - // file adding a listener to the `fetch` event). Indicates a - // `service worker syntax` Worker. - BodyPart param.Field[string] `json:"body_part"` - // Date indicating targeted support in the Workers runtime. Backwards incompatible - // fixes to the runtime following this date will not affect this Worker. - CompatibilityDate param.Field[string] `json:"compatibility_date"` - // Flags that enable or disable certain features in the Workers runtime. Used to - // enable upcoming features or opt in or out of specific changes not included in a - // `compatibility_date`. - CompatibilityFlags param.Field[[]string] `json:"compatibility_flags"` - // List of binding types to keep from previous_upload. - KeepBindings param.Field[[]string] `json:"keep_bindings"` - // Whether Logpush is turned on for the Worker. - Logpush param.Field[bool] `json:"logpush"` - // Name of the part in the multipart request that contains the main module (e.g. - // the file exporting a `fetch` handler). Indicates a `module syntax` Worker. - MainModule param.Field[string] `json:"main_module"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations param.Field[WorkerScriptUpdateParamsMetadataMigrations] `json:"migrations"` - Placement param.Field[WorkerScriptUpdateParamsMetadataPlacement] `json:"placement"` - // List of strings to use as tags for this Worker - Tags param.Field[[]string] `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers param.Field[[]WorkerScriptUpdateParamsMetadataTailConsumer] `json:"tail_consumers"` - // Usage model to apply to invocations. - UsageModel param.Field[WorkerScriptUpdateParamsMetadataUsageModel] `json:"usage_model"` - // Key-value pairs to use as tags for this version of this Worker - VersionTags param.Field[interface{}] `json:"version_tags"` -} - -func (r WorkerScriptUpdateParamsMetadata) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Satisfied by -// [WorkerScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations], -// [WorkerScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrations]. -type WorkerScriptUpdateParamsMetadataMigrations interface { - implementsWorkerScriptUpdateParamsMetadataMigrations() -} - -// A single set of migrations to apply. -type WorkerScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag param.Field[string] `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]WorkerScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]WorkerScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsTransferredClass] `json:"transferred_classes"` -} - -func (r WorkerScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations) implementsWorkerScriptUpdateParamsMetadataMigrations() { -} - -type WorkerScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` -} - -func (r WorkerScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsRenamedClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` -} - -func (r WorkerScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag param.Field[string] `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // Migrations to apply in order. - Steps param.Field[[]WorkerScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStep] `json:"steps"` -} - -func (r WorkerScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrations) implementsWorkerScriptUpdateParamsMetadataMigrations() { -} - -type WorkerScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]WorkerScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]WorkerScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass] `json:"transferred_classes"` -} - -func (r WorkerScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStep) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` -} - -func (r WorkerScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` -} - -func (r WorkerScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerScriptUpdateParamsMetadataPlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode param.Field[WorkerScriptUpdateParamsMetadataPlacementMode] `json:"mode"` -} - -func (r WorkerScriptUpdateParamsMetadataPlacement) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type WorkerScriptUpdateParamsMetadataPlacementMode string - -const ( - WorkerScriptUpdateParamsMetadataPlacementModeSmart WorkerScriptUpdateParamsMetadataPlacementMode = "smart" -) - -// A reference to a script that will consume logs from the attached Worker. -type WorkerScriptUpdateParamsMetadataTailConsumer struct { - // Name of Worker that is to be the consumer. - Service param.Field[string] `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment param.Field[string] `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace param.Field[string] `json:"namespace"` -} - -func (r WorkerScriptUpdateParamsMetadataTailConsumer) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Usage model to apply to invocations. -type WorkerScriptUpdateParamsMetadataUsageModel string - -const ( - WorkerScriptUpdateParamsMetadataUsageModelBundled WorkerScriptUpdateParamsMetadataUsageModel = "bundled" - WorkerScriptUpdateParamsMetadataUsageModelUnbound WorkerScriptUpdateParamsMetadataUsageModel = "unbound" -) - -type WorkerScriptUpdateResponseEnvelope struct { - Errors []WorkerScriptUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerScriptUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkerScriptUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerScriptUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON workerScriptUpdateResponseEnvelopeJSON `json:"-"` -} - -// workerScriptUpdateResponseEnvelopeJSON contains the JSON metadata for the struct -// [WorkerScriptUpdateResponseEnvelope] -type workerScriptUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerScriptUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WorkerScriptUpdateResponseEnvelopeErrors] -type workerScriptUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerScriptUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WorkerScriptUpdateResponseEnvelopeMessages] -type workerScriptUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerScriptUpdateResponseEnvelopeSuccess bool - -const ( - WorkerScriptUpdateResponseEnvelopeSuccessTrue WorkerScriptUpdateResponseEnvelopeSuccess = true -) - -type WorkerScriptListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type WorkerScriptListResponseEnvelope struct { - Errors []WorkerScriptListResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerScriptListResponseEnvelopeMessages `json:"messages,required"` - Result []WorkerScriptListResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerScriptListResponseEnvelopeSuccess `json:"success,required"` - JSON workerScriptListResponseEnvelopeJSON `json:"-"` -} - -// workerScriptListResponseEnvelopeJSON contains the JSON metadata for the struct -// [WorkerScriptListResponseEnvelope] -type workerScriptListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptListResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerScriptListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WorkerScriptListResponseEnvelopeErrors] -type workerScriptListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptListResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerScriptListResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [WorkerScriptListResponseEnvelopeMessages] -type workerScriptListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerScriptListResponseEnvelopeSuccess bool - -const ( - WorkerScriptListResponseEnvelopeSuccessTrue WorkerScriptListResponseEnvelopeSuccess = true -) - -type WorkerScriptDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // If set to true, delete will not be stopped by associated service binding, - // durable object, or other binding. Any of these associated bindings/durable - // objects will be deleted along with the script. - Force param.Field[bool] `query:"force"` -} - -// URLQuery serializes [WorkerScriptDeleteParams]'s query parameters as -// `url.Values`. -func (r WorkerScriptDeleteParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type WorkerScriptGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} diff --git a/workerscript_test.go b/workerscript_test.go deleted file mode 100644 index 9d723411c33..00000000000 --- a/workerscript_test.go +++ /dev/null @@ -1,211 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "bytes" - "context" - "errors" - "io" - "net/http" - "net/http/httptest" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkerScriptUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Workers.Scripts.Update( - context.TODO(), - "this-is_my_script-01", - cloudflare.WorkerScriptUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - RollbackTo: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), - AnyPartName: cloudflare.F([]io.Reader{io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents")))}), - Message: cloudflare.F("string"), - Metadata: cloudflare.F(cloudflare.WorkerScriptUpdateParamsMetadata{ - Bindings: cloudflare.F([]interface{}{map[string]interface{}{ - "name": "MY_ENV_VAR", - "text": "my_data", - "type": "plain_text", - }}), - BodyPart: cloudflare.F("worker.js"), - CompatibilityDate: cloudflare.F("2023-07-25"), - CompatibilityFlags: cloudflare.F([]string{"string", "string", "string"}), - KeepBindings: cloudflare.F([]string{"string", "string", "string"}), - Logpush: cloudflare.F(false), - MainModule: cloudflare.F("worker.js"), - Migrations: cloudflare.F[cloudflare.WorkerScriptUpdateParamsMetadataMigrations](cloudflare.WorkerScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations(cloudflare.WorkerScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations{ - NewTag: cloudflare.F("v2"), - OldTag: cloudflare.F("v1"), - DeletedClasses: cloudflare.F([]string{"string", "string", "string"}), - NewClasses: cloudflare.F([]string{"string", "string", "string"}), - RenamedClasses: cloudflare.F([]cloudflare.WorkerScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsRenamedClass{{ - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }}), - TransferredClasses: cloudflare.F([]cloudflare.WorkerScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsTransferredClass{{ - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }}), - })), - Placement: cloudflare.F(cloudflare.WorkerScriptUpdateParamsMetadataPlacement{ - Mode: cloudflare.F(cloudflare.WorkerScriptUpdateParamsMetadataPlacementModeSmart), - }), - Tags: cloudflare.F([]string{"string", "string", "string"}), - TailConsumers: cloudflare.F([]cloudflare.WorkerScriptUpdateParamsMetadataTailConsumer{{ - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }, { - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }, { - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }}), - UsageModel: cloudflare.F(cloudflare.WorkerScriptUpdateParamsMetadataUsageModelBundled), - VersionTags: cloudflare.F[any](map[string]interface{}{}), - }), - }, - ) - 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 TestWorkerScriptList(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("user@example.com"), - ) - _, err := client.Workers.Scripts.List(context.TODO(), cloudflare.WorkerScriptListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestWorkerScriptDeleteWithOptionalParams(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("user@example.com"), - ) - err := client.Workers.Scripts.Delete( - context.TODO(), - "this-is_my_script-01", - cloudflare.WorkerScriptDeleteParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Force: cloudflare.F(true), - }, - ) - 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 TestWorkerScriptGet(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - w.Write([]byte("abc")) - })) - defer server.Close() - baseURL := server.URL - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - resp, err := client.Workers.Scripts.Get( - context.TODO(), - "this-is_my_script-01", - cloudflare.WorkerScriptGetParams{ - AccountID: cloudflare.F("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()) - } - defer resp.Body.Close() - - b, err := io.ReadAll(resp.Body) - 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()) - } - if !bytes.Equal(b, []byte("abc")) { - t.Fatalf("return value not %s: %s", "abc", b) - } -} diff --git a/workerscriptbinding.go b/workerscriptbinding.go deleted file mode 100644 index f0b47176ccb..00000000000 --- a/workerscriptbinding.go +++ /dev/null @@ -1,228 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// WorkerScriptBindingService 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 [NewWorkerScriptBindingService] -// method instead. -type WorkerScriptBindingService struct { - Options []option.RequestOption -} - -// NewWorkerScriptBindingService 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 NewWorkerScriptBindingService(opts ...option.RequestOption) (r *WorkerScriptBindingService) { - r = &WorkerScriptBindingService{} - r.Options = opts - return -} - -// List the bindings for a Workers script. -func (r *WorkerScriptBindingService) Get(ctx context.Context, query WorkerScriptBindingGetParams, opts ...option.RequestOption) (res *[]WorkerScriptBindingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerScriptBindingGetResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/script/bindings", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [WorkerScriptBindingGetResponseWorkersKVNamespaceBinding] or -// [WorkerScriptBindingGetResponseWorkersWasmModuleBinding]. -type WorkerScriptBindingGetResponse interface { - implementsWorkerScriptBindingGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkerScriptBindingGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptBindingGetResponseWorkersKVNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptBindingGetResponseWorkersWasmModuleBinding{}), - }, - ) -} - -type WorkerScriptBindingGetResponseWorkersKVNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id,required"` - // The class of resource that the binding provides. - Type WorkerScriptBindingGetResponseWorkersKVNamespaceBindingType `json:"type,required"` - JSON workerScriptBindingGetResponseWorkersKVNamespaceBindingJSON `json:"-"` -} - -// workerScriptBindingGetResponseWorkersKVNamespaceBindingJSON contains the JSON -// metadata for the struct -// [WorkerScriptBindingGetResponseWorkersKVNamespaceBinding] -type workerScriptBindingGetResponseWorkersKVNamespaceBindingJSON struct { - Name apijson.Field - NamespaceID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptBindingGetResponseWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptBindingGetResponseWorkersKVNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptBindingGetResponseWorkersKVNamespaceBinding) implementsWorkerScriptBindingGetResponse() { -} - -// The class of resource that the binding provides. -type WorkerScriptBindingGetResponseWorkersKVNamespaceBindingType string - -const ( - WorkerScriptBindingGetResponseWorkersKVNamespaceBindingTypeKVNamespace WorkerScriptBindingGetResponseWorkersKVNamespaceBindingType = "kv_namespace" -) - -type WorkerScriptBindingGetResponseWorkersWasmModuleBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkerScriptBindingGetResponseWorkersWasmModuleBindingType `json:"type,required"` - JSON workerScriptBindingGetResponseWorkersWasmModuleBindingJSON `json:"-"` -} - -// workerScriptBindingGetResponseWorkersWasmModuleBindingJSON contains the JSON -// metadata for the struct [WorkerScriptBindingGetResponseWorkersWasmModuleBinding] -type workerScriptBindingGetResponseWorkersWasmModuleBindingJSON struct { - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptBindingGetResponseWorkersWasmModuleBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptBindingGetResponseWorkersWasmModuleBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptBindingGetResponseWorkersWasmModuleBinding) implementsWorkerScriptBindingGetResponse() { -} - -// The class of resource that the binding provides. -type WorkerScriptBindingGetResponseWorkersWasmModuleBindingType string - -const ( - WorkerScriptBindingGetResponseWorkersWasmModuleBindingTypeWasmModule WorkerScriptBindingGetResponseWorkersWasmModuleBindingType = "wasm_module" -) - -type WorkerScriptBindingGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type WorkerScriptBindingGetResponseEnvelope struct { - Errors []WorkerScriptBindingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerScriptBindingGetResponseEnvelopeMessages `json:"messages,required"` - Result []WorkerScriptBindingGetResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerScriptBindingGetResponseEnvelopeSuccess `json:"success,required"` - JSON workerScriptBindingGetResponseEnvelopeJSON `json:"-"` -} - -// workerScriptBindingGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [WorkerScriptBindingGetResponseEnvelope] -type workerScriptBindingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptBindingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptBindingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptBindingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptBindingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerScriptBindingGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [WorkerScriptBindingGetResponseEnvelopeErrors] -type workerScriptBindingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptBindingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptBindingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptBindingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptBindingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerScriptBindingGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [WorkerScriptBindingGetResponseEnvelopeMessages] -type workerScriptBindingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptBindingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptBindingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerScriptBindingGetResponseEnvelopeSuccess bool - -const ( - WorkerScriptBindingGetResponseEnvelopeSuccessTrue WorkerScriptBindingGetResponseEnvelopeSuccess = true -) diff --git a/workerscriptbinding_test.go b/workerscriptbinding_test.go deleted file mode 100644 index 559d1c3bea6..00000000000 --- a/workerscriptbinding_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkerScriptBindingGet(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("user@example.com"), - ) - _, err := client.Workers.Scripts.Bindings.Get(context.TODO(), cloudflare.WorkerScriptBindingGetParams{ - ZoneID: cloudflare.F("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/workerscriptcontent.go b/workerscriptcontent.go deleted file mode 100644 index 793dc3e23d6..00000000000 --- a/workerscriptcontent.go +++ /dev/null @@ -1,251 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "bytes" - "context" - "fmt" - "io" - "mime/multipart" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apiform" - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkerScriptContentService 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 [NewWorkerScriptContentService] -// method instead. -type WorkerScriptContentService struct { - Options []option.RequestOption -} - -// NewWorkerScriptContentService 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 NewWorkerScriptContentService(opts ...option.RequestOption) (r *WorkerScriptContentService) { - r = &WorkerScriptContentService{} - r.Options = opts - return -} - -// Put script content without touching config or metadata -func (r *WorkerScriptContentService) Update(ctx context.Context, scriptName string, params WorkerScriptContentUpdateParams, opts ...option.RequestOption) (res *WorkerScriptContentUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerScriptContentUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts/%s/content", params.AccountID, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WorkerScriptContentUpdateResponse struct { - // The id of the script in the Workers system. Usually the script name. - ID string `json:"id"` - // When the script was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Hashed script content, can be used in a If-None-Match header when updating. - Etag string `json:"etag"` - // Whether Logpush is turned on for the Worker. - Logpush bool `json:"logpush"` - // When the script was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Deprecated. Deployment metadata for internal usage. - PipelineHash string `json:"pipeline_hash"` - // Specifies the placement mode for the Worker (e.g. 'smart'). - PlacementMode string `json:"placement_mode"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers []WorkerScriptContentUpdateResponseTailConsumer `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel string `json:"usage_model"` - JSON workerScriptContentUpdateResponseJSON `json:"-"` -} - -// workerScriptContentUpdateResponseJSON contains the JSON metadata for the struct -// [WorkerScriptContentUpdateResponse] -type workerScriptContentUpdateResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Etag apijson.Field - Logpush apijson.Field - ModifiedOn apijson.Field - PipelineHash apijson.Field - PlacementMode apijson.Field - TailConsumers apijson.Field - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptContentUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptContentUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// A reference to a script that will consume logs from the attached Worker. -type WorkerScriptContentUpdateResponseTailConsumer struct { - // Name of Worker that is to be the consumer. - Service string `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment string `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace string `json:"namespace"` - JSON workerScriptContentUpdateResponseTailConsumerJSON `json:"-"` -} - -// workerScriptContentUpdateResponseTailConsumerJSON contains the JSON metadata for -// the struct [WorkerScriptContentUpdateResponseTailConsumer] -type workerScriptContentUpdateResponseTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptContentUpdateResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptContentUpdateResponseTailConsumerJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptContentUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // A module comprising a Worker script, often a javascript file. Multiple modules - // may be provided as separate named parts, but at least one module must be - // present. This should be referenced either in the metadata as `main_module` - // (esm)/`body_part` (service worker) or as a header `CF-WORKER-MAIN-MODULE-PART` - // (esm) /`CF-WORKER-BODY-PART` (service worker) by part name. - AnyPartName param.Field[[]io.Reader] `json:"" format:"binary"` - // JSON encoded metadata about the uploaded parts and Worker configuration. - Metadata param.Field[WorkerScriptContentUpdateParamsMetadata] `json:"metadata"` - CfWorkerBodyPart param.Field[string] `header:"CF-WORKER-BODY-PART"` - CfWorkerMainModulePart param.Field[string] `header:"CF-WORKER-MAIN-MODULE-PART"` -} - -func (r WorkerScriptContentUpdateParams) MarshalMultipart() (data []byte, contentType string, err error) { - buf := bytes.NewBuffer(nil) - writer := multipart.NewWriter(buf) - err = apiform.MarshalRoot(r, writer) - if err != nil { - writer.Close() - return nil, "", err - } - err = writer.Close() - if err != nil { - return nil, "", err - } - return buf.Bytes(), writer.FormDataContentType(), nil -} - -// JSON encoded metadata about the uploaded parts and Worker configuration. -type WorkerScriptContentUpdateParamsMetadata struct { - // Name of the part in the multipart request that contains the script (e.g. the - // file adding a listener to the `fetch` event). Indicates a - // `service worker syntax` Worker. - BodyPart param.Field[string] `json:"body_part"` - // Name of the part in the multipart request that contains the main module (e.g. - // the file exporting a `fetch` handler). Indicates a `module syntax` Worker. - MainModule param.Field[string] `json:"main_module"` -} - -func (r WorkerScriptContentUpdateParamsMetadata) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerScriptContentUpdateResponseEnvelope struct { - Errors []WorkerScriptContentUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerScriptContentUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkerScriptContentUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerScriptContentUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON workerScriptContentUpdateResponseEnvelopeJSON `json:"-"` -} - -// workerScriptContentUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [WorkerScriptContentUpdateResponseEnvelope] -type workerScriptContentUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptContentUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptContentUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptContentUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptContentUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerScriptContentUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [WorkerScriptContentUpdateResponseEnvelopeErrors] -type workerScriptContentUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptContentUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptContentUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptContentUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptContentUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerScriptContentUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [WorkerScriptContentUpdateResponseEnvelopeMessages] -type workerScriptContentUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptContentUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptContentUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerScriptContentUpdateResponseEnvelopeSuccess bool - -const ( - WorkerScriptContentUpdateResponseEnvelopeSuccessTrue WorkerScriptContentUpdateResponseEnvelopeSuccess = true -) diff --git a/workerscriptcontent_test.go b/workerscriptcontent_test.go deleted file mode 100644 index 5d7da8daecc..00000000000 --- a/workerscriptcontent_test.go +++ /dev/null @@ -1,53 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "bytes" - "context" - "errors" - "io" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkerScriptContentUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Workers.Scripts.Content.Update( - context.TODO(), - "this-is_my_script-01", - cloudflare.WorkerScriptContentUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - AnyPartName: cloudflare.F([]io.Reader{io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents")))}), - Metadata: cloudflare.F(cloudflare.WorkerScriptContentUpdateParamsMetadata{ - BodyPart: cloudflare.F("worker.js"), - MainModule: cloudflare.F("worker.js"), - }), - CfWorkerBodyPart: cloudflare.F("string"), - CfWorkerMainModulePart: cloudflare.F("string"), - }, - ) - 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/workerscriptcontentv2.go b/workerscriptcontentv2.go deleted file mode 100644 index 3c761fdbf71..00000000000 --- a/workerscriptcontentv2.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkerScriptContentV2Service 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 [NewWorkerScriptContentV2Service] -// method instead. -type WorkerScriptContentV2Service struct { - Options []option.RequestOption -} - -// NewWorkerScriptContentV2Service 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 NewWorkerScriptContentV2Service(opts ...option.RequestOption) (r *WorkerScriptContentV2Service) { - r = &WorkerScriptContentV2Service{} - r.Options = opts - return -} - -// Fetch script content only -func (r *WorkerScriptContentV2Service) Get(ctx context.Context, scriptName string, query WorkerScriptContentV2GetParams, opts ...option.RequestOption) (res *http.Response, err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "string")}, opts...) - path := fmt.Sprintf("accounts/%s/workers/scripts/%s/content/v2", query.AccountID, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -type WorkerScriptContentV2GetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} diff --git a/workerscriptcontentv2_test.go b/workerscriptcontentv2_test.go deleted file mode 100644 index 98c0faaffef..00000000000 --- a/workerscriptcontentv2_test.go +++ /dev/null @@ -1,58 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "bytes" - "context" - "errors" - "io" - "net/http" - "net/http/httptest" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkerScriptContentV2Get(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - w.Write([]byte("abc")) - })) - defer server.Close() - baseURL := server.URL - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - resp, err := client.Workers.Scripts.ContentV2.Get( - context.TODO(), - "this-is_my_script-01", - cloudflare.WorkerScriptContentV2GetParams{ - AccountID: cloudflare.F("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()) - } - defer resp.Body.Close() - - b, err := io.ReadAll(resp.Body) - 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()) - } - if !bytes.Equal(b, []byte("abc")) { - t.Fatalf("return value not %s: %s", "abc", b) - } -} diff --git a/workerscriptschedule.go b/workerscriptschedule.go deleted file mode 100644 index 5529e414230..00000000000 --- a/workerscriptschedule.go +++ /dev/null @@ -1,327 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkerScriptScheduleService 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 [NewWorkerScriptScheduleService] -// method instead. -type WorkerScriptScheduleService struct { - Options []option.RequestOption -} - -// NewWorkerScriptScheduleService 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 NewWorkerScriptScheduleService(opts ...option.RequestOption) (r *WorkerScriptScheduleService) { - r = &WorkerScriptScheduleService{} - r.Options = opts - return -} - -// Updates Cron Triggers for a Worker. -func (r *WorkerScriptScheduleService) Update(ctx context.Context, scriptName string, params WorkerScriptScheduleUpdateParams, opts ...option.RequestOption) (res *WorkerScriptScheduleUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerScriptScheduleUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts/%s/schedules", params.AccountID, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches Cron Triggers for a Worker. -func (r *WorkerScriptScheduleService) Get(ctx context.Context, scriptName string, query WorkerScriptScheduleGetParams, opts ...option.RequestOption) (res *WorkerScriptScheduleGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerScriptScheduleGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts/%s/schedules", query.AccountID, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WorkerScriptScheduleUpdateResponse struct { - Schedules []WorkerScriptScheduleUpdateResponseSchedule `json:"schedules"` - JSON workerScriptScheduleUpdateResponseJSON `json:"-"` -} - -// workerScriptScheduleUpdateResponseJSON contains the JSON metadata for the struct -// [WorkerScriptScheduleUpdateResponse] -type workerScriptScheduleUpdateResponseJSON struct { - Schedules apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptScheduleUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptScheduleUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptScheduleUpdateResponseSchedule struct { - CreatedOn interface{} `json:"created_on"` - Cron interface{} `json:"cron"` - ModifiedOn interface{} `json:"modified_on"` - JSON workerScriptScheduleUpdateResponseScheduleJSON `json:"-"` -} - -// workerScriptScheduleUpdateResponseScheduleJSON contains the JSON metadata for -// the struct [WorkerScriptScheduleUpdateResponseSchedule] -type workerScriptScheduleUpdateResponseScheduleJSON struct { - CreatedOn apijson.Field - Cron apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptScheduleUpdateResponseSchedule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptScheduleUpdateResponseScheduleJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptScheduleGetResponse struct { - Schedules []WorkerScriptScheduleGetResponseSchedule `json:"schedules"` - JSON workerScriptScheduleGetResponseJSON `json:"-"` -} - -// workerScriptScheduleGetResponseJSON contains the JSON metadata for the struct -// [WorkerScriptScheduleGetResponse] -type workerScriptScheduleGetResponseJSON struct { - Schedules apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptScheduleGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptScheduleGetResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptScheduleGetResponseSchedule struct { - CreatedOn interface{} `json:"created_on"` - Cron interface{} `json:"cron"` - ModifiedOn interface{} `json:"modified_on"` - JSON workerScriptScheduleGetResponseScheduleJSON `json:"-"` -} - -// workerScriptScheduleGetResponseScheduleJSON contains the JSON metadata for the -// struct [WorkerScriptScheduleGetResponseSchedule] -type workerScriptScheduleGetResponseScheduleJSON struct { - CreatedOn apijson.Field - Cron apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptScheduleGetResponseSchedule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptScheduleGetResponseScheduleJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptScheduleUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` -} - -func (r WorkerScriptScheduleUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type WorkerScriptScheduleUpdateResponseEnvelope struct { - Errors []WorkerScriptScheduleUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerScriptScheduleUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkerScriptScheduleUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerScriptScheduleUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON workerScriptScheduleUpdateResponseEnvelopeJSON `json:"-"` -} - -// workerScriptScheduleUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [WorkerScriptScheduleUpdateResponseEnvelope] -type workerScriptScheduleUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptScheduleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptScheduleUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptScheduleUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptScheduleUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerScriptScheduleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [WorkerScriptScheduleUpdateResponseEnvelopeErrors] -type workerScriptScheduleUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptScheduleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptScheduleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptScheduleUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptScheduleUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerScriptScheduleUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [WorkerScriptScheduleUpdateResponseEnvelopeMessages] -type workerScriptScheduleUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptScheduleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptScheduleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerScriptScheduleUpdateResponseEnvelopeSuccess bool - -const ( - WorkerScriptScheduleUpdateResponseEnvelopeSuccessTrue WorkerScriptScheduleUpdateResponseEnvelopeSuccess = true -) - -type WorkerScriptScheduleGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type WorkerScriptScheduleGetResponseEnvelope struct { - Errors []WorkerScriptScheduleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerScriptScheduleGetResponseEnvelopeMessages `json:"messages,required"` - Result WorkerScriptScheduleGetResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerScriptScheduleGetResponseEnvelopeSuccess `json:"success,required"` - JSON workerScriptScheduleGetResponseEnvelopeJSON `json:"-"` -} - -// workerScriptScheduleGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [WorkerScriptScheduleGetResponseEnvelope] -type workerScriptScheduleGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptScheduleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptScheduleGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptScheduleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptScheduleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerScriptScheduleGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [WorkerScriptScheduleGetResponseEnvelopeErrors] -type workerScriptScheduleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptScheduleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptScheduleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptScheduleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptScheduleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerScriptScheduleGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [WorkerScriptScheduleGetResponseEnvelopeMessages] -type workerScriptScheduleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptScheduleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptScheduleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerScriptScheduleGetResponseEnvelopeSuccess bool - -const ( - WorkerScriptScheduleGetResponseEnvelopeSuccessTrue WorkerScriptScheduleGetResponseEnvelopeSuccess = true -) diff --git a/workerscriptschedule_test.go b/workerscriptschedule_test.go deleted file mode 100644 index acb536be73f..00000000000 --- a/workerscriptschedule_test.go +++ /dev/null @@ -1,75 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkerScriptScheduleUpdate(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("user@example.com"), - ) - _, err := client.Workers.Scripts.Schedules.Update( - context.TODO(), - "this-is_my_script-01", - cloudflare.WorkerScriptScheduleUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F[any]("[{'cron': '*/30 * * * *'}]"), - }, - ) - 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 TestWorkerScriptScheduleGet(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("user@example.com"), - ) - _, err := client.Workers.Scripts.Schedules.Get( - context.TODO(), - "this-is_my_script-01", - cloudflare.WorkerScriptScheduleGetParams{ - AccountID: cloudflare.F("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/workerscriptsetting.go b/workerscriptsetting.go deleted file mode 100644 index 1cdafb577d6..00000000000 --- a/workerscriptsetting.go +++ /dev/null @@ -1,2210 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// WorkerScriptSettingService 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 [NewWorkerScriptSettingService] -// method instead. -type WorkerScriptSettingService struct { - Options []option.RequestOption -} - -// NewWorkerScriptSettingService 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 NewWorkerScriptSettingService(opts ...option.RequestOption) (r *WorkerScriptSettingService) { - r = &WorkerScriptSettingService{} - r.Options = opts - return -} - -// Patch script metadata or config, such as bindings or usage model -func (r *WorkerScriptSettingService) Edit(ctx context.Context, scriptName string, params WorkerScriptSettingEditParams, opts ...option.RequestOption) (res *WorkerScriptSettingEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerScriptSettingEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts/%s/settings", params.AccountID, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get script metadata and config, such as bindings or usage model -func (r *WorkerScriptSettingService) Get(ctx context.Context, scriptName string, query WorkerScriptSettingGetParams, opts ...option.RequestOption) (res *WorkerScriptSettingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerScriptSettingGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts/%s/settings", query.AccountID, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WorkerScriptSettingEditResponse struct { - // List of bindings attached to this Worker - Bindings []WorkerScriptSettingEditResponseBinding `json:"bindings"` - // Opt your Worker into changes after this date - CompatibilityDate string `json:"compatibility_date"` - // Opt your Worker into specific changes - CompatibilityFlags []string `json:"compatibility_flags"` - // Whether Logpush is turned on for the Worker. - Logpush bool `json:"logpush"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations WorkerScriptSettingEditResponseMigrations `json:"migrations"` - Placement WorkerScriptSettingEditResponsePlacement `json:"placement"` - // Tags to help you manage your Workers - Tags []string `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers []WorkerScriptSettingEditResponseTailConsumer `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel string `json:"usage_model"` - JSON workerScriptSettingEditResponseJSON `json:"-"` -} - -// workerScriptSettingEditResponseJSON contains the JSON metadata for the struct -// [WorkerScriptSettingEditResponse] -type workerScriptSettingEditResponseJSON struct { - Bindings apijson.Field - CompatibilityDate apijson.Field - CompatibilityFlags apijson.Field - Logpush apijson.Field - Migrations apijson.Field - Placement apijson.Field - Tags apijson.Field - TailConsumers apijson.Field - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseJSON) RawJSON() string { - return r.raw -} - -// A binding to allow the Worker to communicate with resources -// -// Union satisfied by -// [WorkerScriptSettingEditResponseBindingsWorkersKVNamespaceBinding], -// [WorkerScriptSettingEditResponseBindingsWorkersServiceBinding], -// [WorkerScriptSettingEditResponseBindingsWorkersDoBinding], -// [WorkerScriptSettingEditResponseBindingsWorkersR2Binding], -// [WorkerScriptSettingEditResponseBindingsWorkersQueueBinding], -// [WorkerScriptSettingEditResponseBindingsWorkersD1Binding], -// [WorkerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding] or -// [WorkerScriptSettingEditResponseBindingsWorkersMTLSCertBinding]. -type WorkerScriptSettingEditResponseBinding interface { - implementsWorkerScriptSettingEditResponseBinding() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkerScriptSettingEditResponseBinding)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingEditResponseBindingsWorkersKVNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingEditResponseBindingsWorkersServiceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingEditResponseBindingsWorkersDoBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingEditResponseBindingsWorkersR2Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingEditResponseBindingsWorkersQueueBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingEditResponseBindingsWorkersD1Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingEditResponseBindingsWorkersMTLSCertBinding{}), - }, - ) -} - -type WorkerScriptSettingEditResponseBindingsWorkersKVNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id,required"` - // The class of resource that the binding provides. - Type WorkerScriptSettingEditResponseBindingsWorkersKVNamespaceBindingType `json:"type,required"` - JSON workerScriptSettingEditResponseBindingsWorkersKVNamespaceBindingJSON `json:"-"` -} - -// workerScriptSettingEditResponseBindingsWorkersKVNamespaceBindingJSON contains -// the JSON metadata for the struct -// [WorkerScriptSettingEditResponseBindingsWorkersKVNamespaceBinding] -type workerScriptSettingEditResponseBindingsWorkersKVNamespaceBindingJSON struct { - Name apijson.Field - NamespaceID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseBindingsWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseBindingsWorkersKVNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingEditResponseBindingsWorkersKVNamespaceBinding) implementsWorkerScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingEditResponseBindingsWorkersKVNamespaceBindingType string - -const ( - WorkerScriptSettingEditResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace WorkerScriptSettingEditResponseBindingsWorkersKVNamespaceBindingType = "kv_namespace" -) - -type WorkerScriptSettingEditResponseBindingsWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment string `json:"environment,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of Worker to bind to - Service string `json:"service,required"` - // The class of resource that the binding provides. - Type WorkerScriptSettingEditResponseBindingsWorkersServiceBindingType `json:"type,required"` - JSON workerScriptSettingEditResponseBindingsWorkersServiceBindingJSON `json:"-"` -} - -// workerScriptSettingEditResponseBindingsWorkersServiceBindingJSON contains the -// JSON metadata for the struct -// [WorkerScriptSettingEditResponseBindingsWorkersServiceBinding] -type workerScriptSettingEditResponseBindingsWorkersServiceBindingJSON struct { - Environment apijson.Field - Name apijson.Field - Service apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseBindingsWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseBindingsWorkersServiceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingEditResponseBindingsWorkersServiceBinding) implementsWorkerScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingEditResponseBindingsWorkersServiceBindingType string - -const ( - WorkerScriptSettingEditResponseBindingsWorkersServiceBindingTypeService WorkerScriptSettingEditResponseBindingsWorkersServiceBindingType = "service" -) - -type WorkerScriptSettingEditResponseBindingsWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName string `json:"class_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkerScriptSettingEditResponseBindingsWorkersDoBindingType `json:"type,required"` - // The environment of the script_name to bind to - Environment string `json:"environment"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName string `json:"script_name"` - JSON workerScriptSettingEditResponseBindingsWorkersDoBindingJSON `json:"-"` -} - -// workerScriptSettingEditResponseBindingsWorkersDoBindingJSON contains the JSON -// metadata for the struct -// [WorkerScriptSettingEditResponseBindingsWorkersDoBinding] -type workerScriptSettingEditResponseBindingsWorkersDoBindingJSON struct { - ClassName apijson.Field - Name apijson.Field - Type apijson.Field - Environment apijson.Field - NamespaceID apijson.Field - ScriptName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseBindingsWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseBindingsWorkersDoBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingEditResponseBindingsWorkersDoBinding) implementsWorkerScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingEditResponseBindingsWorkersDoBindingType string - -const ( - WorkerScriptSettingEditResponseBindingsWorkersDoBindingTypeDurableObjectNamespace WorkerScriptSettingEditResponseBindingsWorkersDoBindingType = "durable_object_namespace" -) - -type WorkerScriptSettingEditResponseBindingsWorkersR2Binding struct { - // R2 bucket to bind to - BucketName string `json:"bucket_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkerScriptSettingEditResponseBindingsWorkersR2BindingType `json:"type,required"` - JSON workerScriptSettingEditResponseBindingsWorkersR2BindingJSON `json:"-"` -} - -// workerScriptSettingEditResponseBindingsWorkersR2BindingJSON contains the JSON -// metadata for the struct -// [WorkerScriptSettingEditResponseBindingsWorkersR2Binding] -type workerScriptSettingEditResponseBindingsWorkersR2BindingJSON struct { - BucketName apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseBindingsWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseBindingsWorkersR2BindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingEditResponseBindingsWorkersR2Binding) implementsWorkerScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingEditResponseBindingsWorkersR2BindingType string - -const ( - WorkerScriptSettingEditResponseBindingsWorkersR2BindingTypeR2Bucket WorkerScriptSettingEditResponseBindingsWorkersR2BindingType = "r2_bucket" -) - -type WorkerScriptSettingEditResponseBindingsWorkersQueueBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of the Queue to bind to - QueueName string `json:"queue_name,required"` - // The class of resource that the binding provides. - Type WorkerScriptSettingEditResponseBindingsWorkersQueueBindingType `json:"type,required"` - JSON workerScriptSettingEditResponseBindingsWorkersQueueBindingJSON `json:"-"` -} - -// workerScriptSettingEditResponseBindingsWorkersQueueBindingJSON contains the JSON -// metadata for the struct -// [WorkerScriptSettingEditResponseBindingsWorkersQueueBinding] -type workerScriptSettingEditResponseBindingsWorkersQueueBindingJSON struct { - Name apijson.Field - QueueName apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseBindingsWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseBindingsWorkersQueueBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingEditResponseBindingsWorkersQueueBinding) implementsWorkerScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingEditResponseBindingsWorkersQueueBindingType string - -const ( - WorkerScriptSettingEditResponseBindingsWorkersQueueBindingTypeQueue WorkerScriptSettingEditResponseBindingsWorkersQueueBindingType = "queue" -) - -type WorkerScriptSettingEditResponseBindingsWorkersD1Binding struct { - // ID of the D1 database to bind to - ID string `json:"id,required"` - // A JavaScript variable name for the binding. - Binding string `json:"binding,required"` - // The name of the D1 database associated with the 'id' provided. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkerScriptSettingEditResponseBindingsWorkersD1BindingType `json:"type,required"` - JSON workerScriptSettingEditResponseBindingsWorkersD1BindingJSON `json:"-"` -} - -// workerScriptSettingEditResponseBindingsWorkersD1BindingJSON contains the JSON -// metadata for the struct -// [WorkerScriptSettingEditResponseBindingsWorkersD1Binding] -type workerScriptSettingEditResponseBindingsWorkersD1BindingJSON struct { - ID apijson.Field - Binding apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseBindingsWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseBindingsWorkersD1BindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingEditResponseBindingsWorkersD1Binding) implementsWorkerScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingEditResponseBindingsWorkersD1BindingType string - -const ( - WorkerScriptSettingEditResponseBindingsWorkersD1BindingTypeD1 WorkerScriptSettingEditResponseBindingsWorkersD1BindingType = "d1" -) - -type WorkerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace to bind to - Namespace string `json:"namespace,required"` - // The class of resource that the binding provides. - Type WorkerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingType `json:"type,required"` - // Outbound worker - Outbound WorkerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound `json:"outbound"` - JSON workerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON `json:"-"` -} - -// workerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON -// contains the JSON metadata for the struct -// [WorkerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding] -type workerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON struct { - Name apijson.Field - Namespace apijson.Field - Type apijson.Field - Outbound apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBinding) implementsWorkerScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingType string - -const ( - WorkerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace WorkerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -// Outbound worker -type WorkerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params []string `json:"params"` - // Outbound worker - Worker WorkerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` - JSON workerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` -} - -// workerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON -// contains the JSON metadata for the struct -// [WorkerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound] -type workerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON struct { - Params apijson.Field - Worker apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { - return r.raw -} - -// Outbound worker -type WorkerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment string `json:"environment"` - // Name of the outbound worker - Service string `json:"service"` - JSON workerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` -} - -// workerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON -// contains the JSON metadata for the struct -// [WorkerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker] -type workerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { - Environment apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptSettingEditResponseBindingsWorkersMTLSCertBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkerScriptSettingEditResponseBindingsWorkersMTLSCertBindingType `json:"type,required"` - // ID of the certificate to bind to - CertificateID string `json:"certificate_id"` - JSON workerScriptSettingEditResponseBindingsWorkersMTLSCertBindingJSON `json:"-"` -} - -// workerScriptSettingEditResponseBindingsWorkersMTLSCertBindingJSON contains the -// JSON metadata for the struct -// [WorkerScriptSettingEditResponseBindingsWorkersMTLSCertBinding] -type workerScriptSettingEditResponseBindingsWorkersMTLSCertBindingJSON struct { - Name apijson.Field - Type apijson.Field - CertificateID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseBindingsWorkersMTLSCertBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseBindingsWorkersMTLSCertBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingEditResponseBindingsWorkersMTLSCertBinding) implementsWorkerScriptSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingEditResponseBindingsWorkersMTLSCertBindingType string - -const ( - WorkerScriptSettingEditResponseBindingsWorkersMTLSCertBindingTypeMTLSCertificate WorkerScriptSettingEditResponseBindingsWorkersMTLSCertBindingType = "mtls_certificate" -) - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Union satisfied by -// [WorkerScriptSettingEditResponseMigrationsWorkersSingleStepMigrations] or -// [WorkerScriptSettingEditResponseMigrationsWorkersSteppedMigrations]. -type WorkerScriptSettingEditResponseMigrations interface { - implementsWorkerScriptSettingEditResponseMigrations() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkerScriptSettingEditResponseMigrations)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingEditResponseMigrationsWorkersSingleStepMigrations{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingEditResponseMigrationsWorkersSteppedMigrations{}), - }, - ) -} - -// A single set of migrations to apply. -type WorkerScriptSettingEditResponseMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []WorkerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []WorkerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass `json:"transferred_classes"` - JSON workerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON `json:"-"` -} - -// workerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON -// contains the JSON metadata for the struct -// [WorkerScriptSettingEditResponseMigrationsWorkersSingleStepMigrations] -type workerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - NewTag apijson.Field - OldTag apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseMigrationsWorkersSingleStepMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingEditResponseMigrationsWorkersSingleStepMigrations) implementsWorkerScriptSettingEditResponseMigrations() { -} - -type WorkerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON workerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON `json:"-"` -} - -// workerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON -// contains the JSON metadata for the struct -// [WorkerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass] -type workerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON workerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON `json:"-"` -} - -// workerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON -// contains the JSON metadata for the struct -// [WorkerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass] -type workerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptSettingEditResponseMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // Migrations to apply in order. - Steps []WorkerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStep `json:"steps"` - JSON workerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsJSON `json:"-"` -} - -// workerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsJSON contains -// the JSON metadata for the struct -// [WorkerScriptSettingEditResponseMigrationsWorkersSteppedMigrations] -type workerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsJSON struct { - NewTag apijson.Field - OldTag apijson.Field - Steps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseMigrationsWorkersSteppedMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingEditResponseMigrationsWorkersSteppedMigrations) implementsWorkerScriptSettingEditResponseMigrations() { -} - -type WorkerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []WorkerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []WorkerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass `json:"transferred_classes"` - JSON workerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON `json:"-"` -} - -// workerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON -// contains the JSON metadata for the struct -// [WorkerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStep] -type workerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStep) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON workerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON `json:"-"` -} - -// workerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON -// contains the JSON metadata for the struct -// [WorkerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass] -type workerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON workerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON `json:"-"` -} - -// workerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON -// contains the JSON metadata for the struct -// [WorkerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass] -type workerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptSettingEditResponsePlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode WorkerScriptSettingEditResponsePlacementMode `json:"mode"` - JSON workerScriptSettingEditResponsePlacementJSON `json:"-"` -} - -// workerScriptSettingEditResponsePlacementJSON contains the JSON metadata for the -// struct [WorkerScriptSettingEditResponsePlacement] -type workerScriptSettingEditResponsePlacementJSON struct { - Mode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponsePlacement) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponsePlacementJSON) RawJSON() string { - return r.raw -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type WorkerScriptSettingEditResponsePlacementMode string - -const ( - WorkerScriptSettingEditResponsePlacementModeSmart WorkerScriptSettingEditResponsePlacementMode = "smart" -) - -// A reference to a script that will consume logs from the attached Worker. -type WorkerScriptSettingEditResponseTailConsumer struct { - // Name of Worker that is to be the consumer. - Service string `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment string `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace string `json:"namespace"` - JSON workerScriptSettingEditResponseTailConsumerJSON `json:"-"` -} - -// workerScriptSettingEditResponseTailConsumerJSON contains the JSON metadata for -// the struct [WorkerScriptSettingEditResponseTailConsumer] -type workerScriptSettingEditResponseTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseTailConsumerJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptSettingGetResponse struct { - // List of bindings attached to this Worker - Bindings []WorkerScriptSettingGetResponseBinding `json:"bindings"` - // Opt your Worker into changes after this date - CompatibilityDate string `json:"compatibility_date"` - // Opt your Worker into specific changes - CompatibilityFlags []string `json:"compatibility_flags"` - // Whether Logpush is turned on for the Worker. - Logpush bool `json:"logpush"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations WorkerScriptSettingGetResponseMigrations `json:"migrations"` - Placement WorkerScriptSettingGetResponsePlacement `json:"placement"` - // Tags to help you manage your Workers - Tags []string `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers []WorkerScriptSettingGetResponseTailConsumer `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel string `json:"usage_model"` - JSON workerScriptSettingGetResponseJSON `json:"-"` -} - -// workerScriptSettingGetResponseJSON contains the JSON metadata for the struct -// [WorkerScriptSettingGetResponse] -type workerScriptSettingGetResponseJSON struct { - Bindings apijson.Field - CompatibilityDate apijson.Field - CompatibilityFlags apijson.Field - Logpush apijson.Field - Migrations apijson.Field - Placement apijson.Field - Tags apijson.Field - TailConsumers apijson.Field - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseJSON) RawJSON() string { - return r.raw -} - -// A binding to allow the Worker to communicate with resources -// -// Union satisfied by -// [WorkerScriptSettingGetResponseBindingsWorkersKVNamespaceBinding], -// [WorkerScriptSettingGetResponseBindingsWorkersServiceBinding], -// [WorkerScriptSettingGetResponseBindingsWorkersDoBinding], -// [WorkerScriptSettingGetResponseBindingsWorkersR2Binding], -// [WorkerScriptSettingGetResponseBindingsWorkersQueueBinding], -// [WorkerScriptSettingGetResponseBindingsWorkersD1Binding], -// [WorkerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding] or -// [WorkerScriptSettingGetResponseBindingsWorkersMTLSCertBinding]. -type WorkerScriptSettingGetResponseBinding interface { - implementsWorkerScriptSettingGetResponseBinding() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkerScriptSettingGetResponseBinding)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingGetResponseBindingsWorkersKVNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingGetResponseBindingsWorkersServiceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingGetResponseBindingsWorkersDoBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingGetResponseBindingsWorkersR2Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingGetResponseBindingsWorkersQueueBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingGetResponseBindingsWorkersD1Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingGetResponseBindingsWorkersMTLSCertBinding{}), - }, - ) -} - -type WorkerScriptSettingGetResponseBindingsWorkersKVNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id,required"` - // The class of resource that the binding provides. - Type WorkerScriptSettingGetResponseBindingsWorkersKVNamespaceBindingType `json:"type,required"` - JSON workerScriptSettingGetResponseBindingsWorkersKVNamespaceBindingJSON `json:"-"` -} - -// workerScriptSettingGetResponseBindingsWorkersKVNamespaceBindingJSON contains the -// JSON metadata for the struct -// [WorkerScriptSettingGetResponseBindingsWorkersKVNamespaceBinding] -type workerScriptSettingGetResponseBindingsWorkersKVNamespaceBindingJSON struct { - Name apijson.Field - NamespaceID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseBindingsWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseBindingsWorkersKVNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingGetResponseBindingsWorkersKVNamespaceBinding) implementsWorkerScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingGetResponseBindingsWorkersKVNamespaceBindingType string - -const ( - WorkerScriptSettingGetResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace WorkerScriptSettingGetResponseBindingsWorkersKVNamespaceBindingType = "kv_namespace" -) - -type WorkerScriptSettingGetResponseBindingsWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment string `json:"environment,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of Worker to bind to - Service string `json:"service,required"` - // The class of resource that the binding provides. - Type WorkerScriptSettingGetResponseBindingsWorkersServiceBindingType `json:"type,required"` - JSON workerScriptSettingGetResponseBindingsWorkersServiceBindingJSON `json:"-"` -} - -// workerScriptSettingGetResponseBindingsWorkersServiceBindingJSON contains the -// JSON metadata for the struct -// [WorkerScriptSettingGetResponseBindingsWorkersServiceBinding] -type workerScriptSettingGetResponseBindingsWorkersServiceBindingJSON struct { - Environment apijson.Field - Name apijson.Field - Service apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseBindingsWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseBindingsWorkersServiceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingGetResponseBindingsWorkersServiceBinding) implementsWorkerScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingGetResponseBindingsWorkersServiceBindingType string - -const ( - WorkerScriptSettingGetResponseBindingsWorkersServiceBindingTypeService WorkerScriptSettingGetResponseBindingsWorkersServiceBindingType = "service" -) - -type WorkerScriptSettingGetResponseBindingsWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName string `json:"class_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkerScriptSettingGetResponseBindingsWorkersDoBindingType `json:"type,required"` - // The environment of the script_name to bind to - Environment string `json:"environment"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName string `json:"script_name"` - JSON workerScriptSettingGetResponseBindingsWorkersDoBindingJSON `json:"-"` -} - -// workerScriptSettingGetResponseBindingsWorkersDoBindingJSON contains the JSON -// metadata for the struct [WorkerScriptSettingGetResponseBindingsWorkersDoBinding] -type workerScriptSettingGetResponseBindingsWorkersDoBindingJSON struct { - ClassName apijson.Field - Name apijson.Field - Type apijson.Field - Environment apijson.Field - NamespaceID apijson.Field - ScriptName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseBindingsWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseBindingsWorkersDoBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingGetResponseBindingsWorkersDoBinding) implementsWorkerScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingGetResponseBindingsWorkersDoBindingType string - -const ( - WorkerScriptSettingGetResponseBindingsWorkersDoBindingTypeDurableObjectNamespace WorkerScriptSettingGetResponseBindingsWorkersDoBindingType = "durable_object_namespace" -) - -type WorkerScriptSettingGetResponseBindingsWorkersR2Binding struct { - // R2 bucket to bind to - BucketName string `json:"bucket_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkerScriptSettingGetResponseBindingsWorkersR2BindingType `json:"type,required"` - JSON workerScriptSettingGetResponseBindingsWorkersR2BindingJSON `json:"-"` -} - -// workerScriptSettingGetResponseBindingsWorkersR2BindingJSON contains the JSON -// metadata for the struct [WorkerScriptSettingGetResponseBindingsWorkersR2Binding] -type workerScriptSettingGetResponseBindingsWorkersR2BindingJSON struct { - BucketName apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseBindingsWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseBindingsWorkersR2BindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingGetResponseBindingsWorkersR2Binding) implementsWorkerScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingGetResponseBindingsWorkersR2BindingType string - -const ( - WorkerScriptSettingGetResponseBindingsWorkersR2BindingTypeR2Bucket WorkerScriptSettingGetResponseBindingsWorkersR2BindingType = "r2_bucket" -) - -type WorkerScriptSettingGetResponseBindingsWorkersQueueBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of the Queue to bind to - QueueName string `json:"queue_name,required"` - // The class of resource that the binding provides. - Type WorkerScriptSettingGetResponseBindingsWorkersQueueBindingType `json:"type,required"` - JSON workerScriptSettingGetResponseBindingsWorkersQueueBindingJSON `json:"-"` -} - -// workerScriptSettingGetResponseBindingsWorkersQueueBindingJSON contains the JSON -// metadata for the struct -// [WorkerScriptSettingGetResponseBindingsWorkersQueueBinding] -type workerScriptSettingGetResponseBindingsWorkersQueueBindingJSON struct { - Name apijson.Field - QueueName apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseBindingsWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseBindingsWorkersQueueBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingGetResponseBindingsWorkersQueueBinding) implementsWorkerScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingGetResponseBindingsWorkersQueueBindingType string - -const ( - WorkerScriptSettingGetResponseBindingsWorkersQueueBindingTypeQueue WorkerScriptSettingGetResponseBindingsWorkersQueueBindingType = "queue" -) - -type WorkerScriptSettingGetResponseBindingsWorkersD1Binding struct { - // ID of the D1 database to bind to - ID string `json:"id,required"` - // A JavaScript variable name for the binding. - Binding string `json:"binding,required"` - // The name of the D1 database associated with the 'id' provided. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkerScriptSettingGetResponseBindingsWorkersD1BindingType `json:"type,required"` - JSON workerScriptSettingGetResponseBindingsWorkersD1BindingJSON `json:"-"` -} - -// workerScriptSettingGetResponseBindingsWorkersD1BindingJSON contains the JSON -// metadata for the struct [WorkerScriptSettingGetResponseBindingsWorkersD1Binding] -type workerScriptSettingGetResponseBindingsWorkersD1BindingJSON struct { - ID apijson.Field - Binding apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseBindingsWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseBindingsWorkersD1BindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingGetResponseBindingsWorkersD1Binding) implementsWorkerScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingGetResponseBindingsWorkersD1BindingType string - -const ( - WorkerScriptSettingGetResponseBindingsWorkersD1BindingTypeD1 WorkerScriptSettingGetResponseBindingsWorkersD1BindingType = "d1" -) - -type WorkerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace to bind to - Namespace string `json:"namespace,required"` - // The class of resource that the binding provides. - Type WorkerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingType `json:"type,required"` - // Outbound worker - Outbound WorkerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound `json:"outbound"` - JSON workerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON `json:"-"` -} - -// workerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON -// contains the JSON metadata for the struct -// [WorkerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding] -type workerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON struct { - Name apijson.Field - Namespace apijson.Field - Type apijson.Field - Outbound apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBinding) implementsWorkerScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingType string - -const ( - WorkerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace WorkerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -// Outbound worker -type WorkerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params []string `json:"params"` - // Outbound worker - Worker WorkerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` - JSON workerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` -} - -// workerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON -// contains the JSON metadata for the struct -// [WorkerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound] -type workerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON struct { - Params apijson.Field - Worker apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { - return r.raw -} - -// Outbound worker -type WorkerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment string `json:"environment"` - // Name of the outbound worker - Service string `json:"service"` - JSON workerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` -} - -// workerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON -// contains the JSON metadata for the struct -// [WorkerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker] -type workerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { - Environment apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptSettingGetResponseBindingsWorkersMTLSCertBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkerScriptSettingGetResponseBindingsWorkersMTLSCertBindingType `json:"type,required"` - // ID of the certificate to bind to - CertificateID string `json:"certificate_id"` - JSON workerScriptSettingGetResponseBindingsWorkersMTLSCertBindingJSON `json:"-"` -} - -// workerScriptSettingGetResponseBindingsWorkersMTLSCertBindingJSON contains the -// JSON metadata for the struct -// [WorkerScriptSettingGetResponseBindingsWorkersMTLSCertBinding] -type workerScriptSettingGetResponseBindingsWorkersMTLSCertBindingJSON struct { - Name apijson.Field - Type apijson.Field - CertificateID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseBindingsWorkersMTLSCertBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseBindingsWorkersMTLSCertBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingGetResponseBindingsWorkersMTLSCertBinding) implementsWorkerScriptSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingGetResponseBindingsWorkersMTLSCertBindingType string - -const ( - WorkerScriptSettingGetResponseBindingsWorkersMTLSCertBindingTypeMTLSCertificate WorkerScriptSettingGetResponseBindingsWorkersMTLSCertBindingType = "mtls_certificate" -) - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Union satisfied by -// [WorkerScriptSettingGetResponseMigrationsWorkersSingleStepMigrations] or -// [WorkerScriptSettingGetResponseMigrationsWorkersSteppedMigrations]. -type WorkerScriptSettingGetResponseMigrations interface { - implementsWorkerScriptSettingGetResponseMigrations() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkerScriptSettingGetResponseMigrations)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingGetResponseMigrationsWorkersSingleStepMigrations{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptSettingGetResponseMigrationsWorkersSteppedMigrations{}), - }, - ) -} - -// A single set of migrations to apply. -type WorkerScriptSettingGetResponseMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []WorkerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []WorkerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass `json:"transferred_classes"` - JSON workerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON `json:"-"` -} - -// workerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON contains -// the JSON metadata for the struct -// [WorkerScriptSettingGetResponseMigrationsWorkersSingleStepMigrations] -type workerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - NewTag apijson.Field - OldTag apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseMigrationsWorkersSingleStepMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingGetResponseMigrationsWorkersSingleStepMigrations) implementsWorkerScriptSettingGetResponseMigrations() { -} - -type WorkerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON workerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON `json:"-"` -} - -// workerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON -// contains the JSON metadata for the struct -// [WorkerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass] -type workerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON workerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON `json:"-"` -} - -// workerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON -// contains the JSON metadata for the struct -// [WorkerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass] -type workerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptSettingGetResponseMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // Migrations to apply in order. - Steps []WorkerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStep `json:"steps"` - JSON workerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsJSON `json:"-"` -} - -// workerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsJSON contains -// the JSON metadata for the struct -// [WorkerScriptSettingGetResponseMigrationsWorkersSteppedMigrations] -type workerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsJSON struct { - NewTag apijson.Field - OldTag apijson.Field - Steps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseMigrationsWorkersSteppedMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r WorkerScriptSettingGetResponseMigrationsWorkersSteppedMigrations) implementsWorkerScriptSettingGetResponseMigrations() { -} - -type WorkerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []WorkerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []WorkerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass `json:"transferred_classes"` - JSON workerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON `json:"-"` -} - -// workerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON -// contains the JSON metadata for the struct -// [WorkerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStep] -type workerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStep) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON workerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON `json:"-"` -} - -// workerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON -// contains the JSON metadata for the struct -// [WorkerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass] -type workerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON workerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON `json:"-"` -} - -// workerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON -// contains the JSON metadata for the struct -// [WorkerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass] -type workerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptSettingGetResponsePlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode WorkerScriptSettingGetResponsePlacementMode `json:"mode"` - JSON workerScriptSettingGetResponsePlacementJSON `json:"-"` -} - -// workerScriptSettingGetResponsePlacementJSON contains the JSON metadata for the -// struct [WorkerScriptSettingGetResponsePlacement] -type workerScriptSettingGetResponsePlacementJSON struct { - Mode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponsePlacement) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponsePlacementJSON) RawJSON() string { - return r.raw -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type WorkerScriptSettingGetResponsePlacementMode string - -const ( - WorkerScriptSettingGetResponsePlacementModeSmart WorkerScriptSettingGetResponsePlacementMode = "smart" -) - -// A reference to a script that will consume logs from the attached Worker. -type WorkerScriptSettingGetResponseTailConsumer struct { - // Name of Worker that is to be the consumer. - Service string `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment string `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace string `json:"namespace"` - JSON workerScriptSettingGetResponseTailConsumerJSON `json:"-"` -} - -// workerScriptSettingGetResponseTailConsumerJSON contains the JSON metadata for -// the struct [WorkerScriptSettingGetResponseTailConsumer] -type workerScriptSettingGetResponseTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseTailConsumerJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptSettingEditParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Settings param.Field[WorkerScriptSettingEditParamsSettings] `json:"settings"` -} - -func (r WorkerScriptSettingEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerScriptSettingEditParamsSettings struct { - Errors param.Field[[]WorkerScriptSettingEditParamsSettingsError] `json:"errors,required"` - Messages param.Field[[]WorkerScriptSettingEditParamsSettingsMessage] `json:"messages,required"` - Result param.Field[WorkerScriptSettingEditParamsSettingsResult] `json:"result,required"` - // Whether the API call was successful - Success param.Field[WorkerScriptSettingEditParamsSettingsSuccess] `json:"success,required"` -} - -func (r WorkerScriptSettingEditParamsSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerScriptSettingEditParamsSettingsError struct { - Code param.Field[int64] `json:"code,required"` - Message param.Field[string] `json:"message,required"` -} - -func (r WorkerScriptSettingEditParamsSettingsError) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerScriptSettingEditParamsSettingsMessage struct { - Code param.Field[int64] `json:"code,required"` - Message param.Field[string] `json:"message,required"` -} - -func (r WorkerScriptSettingEditParamsSettingsMessage) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerScriptSettingEditParamsSettingsResult struct { - // List of bindings attached to this Worker - Bindings param.Field[[]WorkerScriptSettingEditParamsSettingsResultBinding] `json:"bindings"` - // Opt your Worker into changes after this date - CompatibilityDate param.Field[string] `json:"compatibility_date"` - // Opt your Worker into specific changes - CompatibilityFlags param.Field[[]string] `json:"compatibility_flags"` - // Whether Logpush is turned on for the Worker. - Logpush param.Field[bool] `json:"logpush"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations param.Field[WorkerScriptSettingEditParamsSettingsResultMigrations] `json:"migrations"` - Placement param.Field[WorkerScriptSettingEditParamsSettingsResultPlacement] `json:"placement"` - // Tags to help you manage your Workers - Tags param.Field[[]string] `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers param.Field[[]WorkerScriptSettingEditParamsSettingsResultTailConsumer] `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel param.Field[string] `json:"usage_model"` -} - -func (r WorkerScriptSettingEditParamsSettingsResult) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A binding to allow the Worker to communicate with resources -// -// Satisfied by -// [WorkerScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding], -// [WorkerScriptSettingEditParamsSettingsResultBindingsWorkersServiceBinding], -// [WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDoBinding], -// [WorkerScriptSettingEditParamsSettingsResultBindingsWorkersR2Binding], -// [WorkerScriptSettingEditParamsSettingsResultBindingsWorkersQueueBinding], -// [WorkerScriptSettingEditParamsSettingsResultBindingsWorkersD1Binding], -// [WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBinding], -// [WorkerScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCertBinding]. -type WorkerScriptSettingEditParamsSettingsResultBinding interface { - implementsWorkerScriptSettingEditParamsSettingsResultBinding() -} - -type WorkerScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding struct { - // The class of resource that the binding provides. - Type param.Field[WorkerScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingType] `json:"type,required"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding) implementsWorkerScriptSettingEditParamsSettingsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingType string - -const ( - WorkerScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace WorkerScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingType = "kv_namespace" -) - -type WorkerScriptSettingEditParamsSettingsResultBindingsWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment param.Field[string] `json:"environment,required"` - // Name of Worker to bind to - Service param.Field[string] `json:"service,required"` - // The class of resource that the binding provides. - Type param.Field[WorkerScriptSettingEditParamsSettingsResultBindingsWorkersServiceBindingType] `json:"type,required"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultBindingsWorkersServiceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerScriptSettingEditParamsSettingsResultBindingsWorkersServiceBinding) implementsWorkerScriptSettingEditParamsSettingsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingEditParamsSettingsResultBindingsWorkersServiceBindingType string - -const ( - WorkerScriptSettingEditParamsSettingsResultBindingsWorkersServiceBindingTypeService WorkerScriptSettingEditParamsSettingsResultBindingsWorkersServiceBindingType = "service" -) - -type WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName param.Field[string] `json:"class_name,required"` - // The class of resource that the binding provides. - Type param.Field[WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDoBindingType] `json:"type,required"` - // The environment of the script_name to bind to - Environment param.Field[string] `json:"environment"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName param.Field[string] `json:"script_name"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDoBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDoBinding) implementsWorkerScriptSettingEditParamsSettingsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDoBindingType string - -const ( - WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDoBindingTypeDurableObjectNamespace WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDoBindingType = "durable_object_namespace" -) - -type WorkerScriptSettingEditParamsSettingsResultBindingsWorkersR2Binding struct { - // R2 bucket to bind to - BucketName param.Field[string] `json:"bucket_name,required"` - // The class of resource that the binding provides. - Type param.Field[WorkerScriptSettingEditParamsSettingsResultBindingsWorkersR2BindingType] `json:"type,required"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultBindingsWorkersR2Binding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerScriptSettingEditParamsSettingsResultBindingsWorkersR2Binding) implementsWorkerScriptSettingEditParamsSettingsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingEditParamsSettingsResultBindingsWorkersR2BindingType string - -const ( - WorkerScriptSettingEditParamsSettingsResultBindingsWorkersR2BindingTypeR2Bucket WorkerScriptSettingEditParamsSettingsResultBindingsWorkersR2BindingType = "r2_bucket" -) - -type WorkerScriptSettingEditParamsSettingsResultBindingsWorkersQueueBinding struct { - // Name of the Queue to bind to - QueueName param.Field[string] `json:"queue_name,required"` - // The class of resource that the binding provides. - Type param.Field[WorkerScriptSettingEditParamsSettingsResultBindingsWorkersQueueBindingType] `json:"type,required"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultBindingsWorkersQueueBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerScriptSettingEditParamsSettingsResultBindingsWorkersQueueBinding) implementsWorkerScriptSettingEditParamsSettingsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingEditParamsSettingsResultBindingsWorkersQueueBindingType string - -const ( - WorkerScriptSettingEditParamsSettingsResultBindingsWorkersQueueBindingTypeQueue WorkerScriptSettingEditParamsSettingsResultBindingsWorkersQueueBindingType = "queue" -) - -type WorkerScriptSettingEditParamsSettingsResultBindingsWorkersD1Binding struct { - // ID of the D1 database to bind to - ID param.Field[string] `json:"id,required"` - // The name of the D1 database associated with the 'id' provided. - Name param.Field[string] `json:"name,required"` - // The class of resource that the binding provides. - Type param.Field[WorkerScriptSettingEditParamsSettingsResultBindingsWorkersD1BindingType] `json:"type,required"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultBindingsWorkersD1Binding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerScriptSettingEditParamsSettingsResultBindingsWorkersD1Binding) implementsWorkerScriptSettingEditParamsSettingsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingEditParamsSettingsResultBindingsWorkersD1BindingType string - -const ( - WorkerScriptSettingEditParamsSettingsResultBindingsWorkersD1BindingTypeD1 WorkerScriptSettingEditParamsSettingsResultBindingsWorkersD1BindingType = "d1" -) - -type WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBinding struct { - // Namespace to bind to - Namespace param.Field[string] `json:"namespace,required"` - // The class of resource that the binding provides. - Type param.Field[WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingType] `json:"type,required"` - // Outbound worker - Outbound param.Field[WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingOutbound] `json:"outbound"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBinding) implementsWorkerScriptSettingEditParamsSettingsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingType string - -const ( - WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -// Outbound worker -type WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params param.Field[[]string] `json:"params"` - // Outbound worker - Worker param.Field[WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker] `json:"worker"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingOutbound) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Outbound worker -type WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment param.Field[string] `json:"environment"` - // Name of the outbound worker - Service param.Field[string] `json:"service"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCertBinding struct { - // The class of resource that the binding provides. - Type param.Field[WorkerScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCertBindingType] `json:"type,required"` - // ID of the certificate to bind to - CertificateID param.Field[string] `json:"certificate_id"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCertBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCertBinding) implementsWorkerScriptSettingEditParamsSettingsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkerScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCertBindingType string - -const ( - WorkerScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCertBindingTypeMTLSCertificate WorkerScriptSettingEditParamsSettingsResultBindingsWorkersMTLSCertBindingType = "mtls_certificate" -) - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Satisfied by -// [WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrations], -// [WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrations]. -type WorkerScriptSettingEditParamsSettingsResultMigrations interface { - implementsWorkerScriptSettingEditParamsSettingsResultMigrations() -} - -// A single set of migrations to apply. -type WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag param.Field[string] `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsTransferredClass] `json:"transferred_classes"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrations) implementsWorkerScriptSettingEditParamsSettingsResultMigrations() { -} - -type WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsRenamedClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag param.Field[string] `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // Migrations to apply in order. - Steps param.Field[[]WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStep] `json:"steps"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrations) implementsWorkerScriptSettingEditParamsSettingsResultMigrations() { -} - -type WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass] `json:"transferred_classes"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStep) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerScriptSettingEditParamsSettingsResultPlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode param.Field[WorkerScriptSettingEditParamsSettingsResultPlacementMode] `json:"mode"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultPlacement) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type WorkerScriptSettingEditParamsSettingsResultPlacementMode string - -const ( - WorkerScriptSettingEditParamsSettingsResultPlacementModeSmart WorkerScriptSettingEditParamsSettingsResultPlacementMode = "smart" -) - -// A reference to a script that will consume logs from the attached Worker. -type WorkerScriptSettingEditParamsSettingsResultTailConsumer struct { - // Name of Worker that is to be the consumer. - Service param.Field[string] `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment param.Field[string] `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace param.Field[string] `json:"namespace"` -} - -func (r WorkerScriptSettingEditParamsSettingsResultTailConsumer) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Whether the API call was successful -type WorkerScriptSettingEditParamsSettingsSuccess bool - -const ( - WorkerScriptSettingEditParamsSettingsSuccessTrue WorkerScriptSettingEditParamsSettingsSuccess = true -) - -type WorkerScriptSettingEditResponseEnvelope struct { - Errors []WorkerScriptSettingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerScriptSettingEditResponseEnvelopeMessages `json:"messages,required"` - Result WorkerScriptSettingEditResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerScriptSettingEditResponseEnvelopeSuccess `json:"success,required"` - JSON workerScriptSettingEditResponseEnvelopeJSON `json:"-"` -} - -// workerScriptSettingEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [WorkerScriptSettingEditResponseEnvelope] -type workerScriptSettingEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptSettingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptSettingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerScriptSettingEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [WorkerScriptSettingEditResponseEnvelopeErrors] -type workerScriptSettingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptSettingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptSettingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerScriptSettingEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [WorkerScriptSettingEditResponseEnvelopeMessages] -type workerScriptSettingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerScriptSettingEditResponseEnvelopeSuccess bool - -const ( - WorkerScriptSettingEditResponseEnvelopeSuccessTrue WorkerScriptSettingEditResponseEnvelopeSuccess = true -) - -type WorkerScriptSettingGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type WorkerScriptSettingGetResponseEnvelope struct { - Errors []WorkerScriptSettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerScriptSettingGetResponseEnvelopeMessages `json:"messages,required"` - Result WorkerScriptSettingGetResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerScriptSettingGetResponseEnvelopeSuccess `json:"success,required"` - JSON workerScriptSettingGetResponseEnvelopeJSON `json:"-"` -} - -// workerScriptSettingGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [WorkerScriptSettingGetResponseEnvelope] -type workerScriptSettingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptSettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptSettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerScriptSettingGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [WorkerScriptSettingGetResponseEnvelopeErrors] -type workerScriptSettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptSettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptSettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerScriptSettingGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [WorkerScriptSettingGetResponseEnvelopeMessages] -type workerScriptSettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerScriptSettingGetResponseEnvelopeSuccess bool - -const ( - WorkerScriptSettingGetResponseEnvelopeSuccessTrue WorkerScriptSettingGetResponseEnvelopeSuccess = true -) diff --git a/workerscriptsetting_test.go b/workerscriptsetting_test.go deleted file mode 100644 index da7f59b94f8..00000000000 --- a/workerscriptsetting_test.go +++ /dev/null @@ -1,156 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkerScriptSettingEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Workers.Scripts.Settings.Edit( - context.TODO(), - "this-is_my_script-01", - cloudflare.WorkerScriptSettingEditParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Settings: cloudflare.F(cloudflare.WorkerScriptSettingEditParamsSettings{ - Errors: cloudflare.F([]cloudflare.WorkerScriptSettingEditParamsSettingsError{{ - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }}), - Messages: cloudflare.F([]cloudflare.WorkerScriptSettingEditParamsSettingsMessage{{ - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }}), - Result: cloudflare.F(cloudflare.WorkerScriptSettingEditParamsSettingsResult{ - Bindings: cloudflare.F([]cloudflare.WorkerScriptSettingEditParamsSettingsResultBinding{cloudflare.WorkerScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding(cloudflare.WorkerScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding{ - Type: cloudflare.F(cloudflare.WorkerScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), - }), cloudflare.WorkerScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding(cloudflare.WorkerScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding{ - Type: cloudflare.F(cloudflare.WorkerScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), - }), cloudflare.WorkerScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding(cloudflare.WorkerScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBinding{ - Type: cloudflare.F(cloudflare.WorkerScriptSettingEditParamsSettingsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), - })}), - CompatibilityDate: cloudflare.F("2022-04-05"), - CompatibilityFlags: cloudflare.F([]string{"formdata_parser_supports_files", "formdata_parser_supports_files", "formdata_parser_supports_files"}), - Logpush: cloudflare.F(false), - Migrations: cloudflare.F[cloudflare.WorkerScriptSettingEditParamsSettingsResultMigrations](cloudflare.WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrations(cloudflare.WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrations{ - NewTag: cloudflare.F("v2"), - OldTag: cloudflare.F("v1"), - DeletedClasses: cloudflare.F([]string{"string", "string", "string"}), - NewClasses: cloudflare.F([]string{"string", "string", "string"}), - RenamedClasses: cloudflare.F([]cloudflare.WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsRenamedClass{{ - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }}), - TransferredClasses: cloudflare.F([]cloudflare.WorkerScriptSettingEditParamsSettingsResultMigrationsWorkersSingleStepMigrationsTransferredClass{{ - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }}), - })), - Placement: cloudflare.F(cloudflare.WorkerScriptSettingEditParamsSettingsResultPlacement{ - Mode: cloudflare.F(cloudflare.WorkerScriptSettingEditParamsSettingsResultPlacementModeSmart), - }), - Tags: cloudflare.F([]string{"my-tag", "my-tag", "my-tag"}), - TailConsumers: cloudflare.F([]cloudflare.WorkerScriptSettingEditParamsSettingsResultTailConsumer{{ - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }, { - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }, { - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }}), - UsageModel: cloudflare.F("unbound"), - }), - Success: cloudflare.F(cloudflare.WorkerScriptSettingEditParamsSettingsSuccessTrue), - }), - }, - ) - 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 TestWorkerScriptSettingGet(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("user@example.com"), - ) - _, err := client.Workers.Scripts.Settings.Get( - context.TODO(), - "this-is_my_script-01", - cloudflare.WorkerScriptSettingGetParams{ - AccountID: cloudflare.F("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/workerscripttail.go b/workerscripttail.go deleted file mode 100644 index c92acf63efe..00000000000 --- a/workerscripttail.go +++ /dev/null @@ -1,407 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// WorkerScriptTailService 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 [NewWorkerScriptTailService] method -// instead. -type WorkerScriptTailService struct { - Options []option.RequestOption -} - -// NewWorkerScriptTailService 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 NewWorkerScriptTailService(opts ...option.RequestOption) (r *WorkerScriptTailService) { - r = &WorkerScriptTailService{} - r.Options = opts - return -} - -// Starts a tail that receives logs and exception from a Worker. -func (r *WorkerScriptTailService) New(ctx context.Context, scriptName string, body WorkerScriptTailNewParams, opts ...option.RequestOption) (res *WorkerScriptTailNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerScriptTailNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts/%s/tails", body.AccountID, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a tail from a Worker. -func (r *WorkerScriptTailService) Delete(ctx context.Context, scriptName string, id string, body WorkerScriptTailDeleteParams, opts ...option.RequestOption) (res *WorkerScriptTailDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerScriptTailDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts/%s/tails/%s", body.AccountID, scriptName, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get list of tails currently deployed on a Worker. -func (r *WorkerScriptTailService) Get(ctx context.Context, scriptName string, query WorkerScriptTailGetParams, opts ...option.RequestOption) (res *WorkerScriptTailGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerScriptTailGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts/%s/tails", query.AccountID, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WorkerScriptTailNewResponse struct { - ID interface{} `json:"id"` - ExpiresAt interface{} `json:"expires_at"` - URL interface{} `json:"url"` - JSON workerScriptTailNewResponseJSON `json:"-"` -} - -// workerScriptTailNewResponseJSON contains the JSON metadata for the struct -// [WorkerScriptTailNewResponse] -type workerScriptTailNewResponseJSON struct { - ID apijson.Field - ExpiresAt apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptTailNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptTailNewResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [WorkerScriptTailDeleteResponseUnknown], -// [WorkerScriptTailDeleteResponseArray] or [shared.UnionString]. -type WorkerScriptTailDeleteResponse interface { - ImplementsWorkerScriptTailDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkerScriptTailDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerScriptTailDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type WorkerScriptTailDeleteResponseArray []interface{} - -func (r WorkerScriptTailDeleteResponseArray) ImplementsWorkerScriptTailDeleteResponse() {} - -type WorkerScriptTailGetResponse struct { - ID interface{} `json:"id"` - ExpiresAt interface{} `json:"expires_at"` - URL interface{} `json:"url"` - JSON workerScriptTailGetResponseJSON `json:"-"` -} - -// workerScriptTailGetResponseJSON contains the JSON metadata for the struct -// [WorkerScriptTailGetResponse] -type workerScriptTailGetResponseJSON struct { - ID apijson.Field - ExpiresAt apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptTailGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptTailGetResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptTailNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type WorkerScriptTailNewResponseEnvelope struct { - Errors []WorkerScriptTailNewResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerScriptTailNewResponseEnvelopeMessages `json:"messages,required"` - Result WorkerScriptTailNewResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerScriptTailNewResponseEnvelopeSuccess `json:"success,required"` - JSON workerScriptTailNewResponseEnvelopeJSON `json:"-"` -} - -// workerScriptTailNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [WorkerScriptTailNewResponseEnvelope] -type workerScriptTailNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptTailNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptTailNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptTailNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptTailNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerScriptTailNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WorkerScriptTailNewResponseEnvelopeErrors] -type workerScriptTailNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptTailNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptTailNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptTailNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptTailNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerScriptTailNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WorkerScriptTailNewResponseEnvelopeMessages] -type workerScriptTailNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptTailNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptTailNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerScriptTailNewResponseEnvelopeSuccess bool - -const ( - WorkerScriptTailNewResponseEnvelopeSuccessTrue WorkerScriptTailNewResponseEnvelopeSuccess = true -) - -type WorkerScriptTailDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type WorkerScriptTailDeleteResponseEnvelope struct { - Errors []WorkerScriptTailDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerScriptTailDeleteResponseEnvelopeMessages `json:"messages,required"` - Result WorkerScriptTailDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerScriptTailDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON workerScriptTailDeleteResponseEnvelopeJSON `json:"-"` -} - -// workerScriptTailDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [WorkerScriptTailDeleteResponseEnvelope] -type workerScriptTailDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptTailDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptTailDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptTailDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptTailDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerScriptTailDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [WorkerScriptTailDeleteResponseEnvelopeErrors] -type workerScriptTailDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptTailDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptTailDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptTailDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptTailDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerScriptTailDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [WorkerScriptTailDeleteResponseEnvelopeMessages] -type workerScriptTailDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptTailDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptTailDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerScriptTailDeleteResponseEnvelopeSuccess bool - -const ( - WorkerScriptTailDeleteResponseEnvelopeSuccessTrue WorkerScriptTailDeleteResponseEnvelopeSuccess = true -) - -type WorkerScriptTailGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type WorkerScriptTailGetResponseEnvelope struct { - Errors []WorkerScriptTailGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerScriptTailGetResponseEnvelopeMessages `json:"messages,required"` - Result WorkerScriptTailGetResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerScriptTailGetResponseEnvelopeSuccess `json:"success,required"` - JSON workerScriptTailGetResponseEnvelopeJSON `json:"-"` -} - -// workerScriptTailGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [WorkerScriptTailGetResponseEnvelope] -type workerScriptTailGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptTailGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptTailGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptTailGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptTailGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerScriptTailGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WorkerScriptTailGetResponseEnvelopeErrors] -type workerScriptTailGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptTailGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptTailGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptTailGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptTailGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerScriptTailGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WorkerScriptTailGetResponseEnvelopeMessages] -type workerScriptTailGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptTailGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptTailGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerScriptTailGetResponseEnvelopeSuccess bool - -const ( - WorkerScriptTailGetResponseEnvelopeSuccessTrue WorkerScriptTailGetResponseEnvelopeSuccess = true -) diff --git a/workerscripttail_test.go b/workerscripttail_test.go deleted file mode 100644 index a3c61a0b8c3..00000000000 --- a/workerscripttail_test.go +++ /dev/null @@ -1,105 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkerScriptTailNew(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("user@example.com"), - ) - _, err := client.Workers.Scripts.Tail.New( - context.TODO(), - "this-is_my_script-01", - cloudflare.WorkerScriptTailNewParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestWorkerScriptTailDelete(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("user@example.com"), - ) - _, err := client.Workers.Scripts.Tail.Delete( - context.TODO(), - "this-is_my_script-01", - "03dc9f77817b488fb26c5861ec18f791", - cloudflare.WorkerScriptTailDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestWorkerScriptTailGet(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("user@example.com"), - ) - _, err := client.Workers.Scripts.Tail.Get( - context.TODO(), - "this-is_my_script-01", - cloudflare.WorkerScriptTailGetParams{ - AccountID: cloudflare.F("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/workerscriptusagemodel.go b/workerscriptusagemodel.go deleted file mode 100644 index 37809d7b69f..00000000000 --- a/workerscriptusagemodel.go +++ /dev/null @@ -1,278 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkerScriptUsageModelService 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 [NewWorkerScriptUsageModelService] -// method instead. -type WorkerScriptUsageModelService struct { - Options []option.RequestOption -} - -// NewWorkerScriptUsageModelService 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 NewWorkerScriptUsageModelService(opts ...option.RequestOption) (r *WorkerScriptUsageModelService) { - r = &WorkerScriptUsageModelService{} - r.Options = opts - return -} - -// Updates the Usage Model for a given Worker. Requires a Workers Paid -// subscription. -func (r *WorkerScriptUsageModelService) Update(ctx context.Context, scriptName string, params WorkerScriptUsageModelUpdateParams, opts ...option.RequestOption) (res *WorkerScriptUsageModelUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerScriptUsageModelUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts/%s/usage-model", params.AccountID, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the Usage Model for a given Worker. -func (r *WorkerScriptUsageModelService) Get(ctx context.Context, scriptName string, query WorkerScriptUsageModelGetParams, opts ...option.RequestOption) (res *WorkerScriptUsageModelGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerScriptUsageModelGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/scripts/%s/usage-model", query.AccountID, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WorkerScriptUsageModelUpdateResponse struct { - UsageModel interface{} `json:"usage_model"` - JSON workerScriptUsageModelUpdateResponseJSON `json:"-"` -} - -// workerScriptUsageModelUpdateResponseJSON contains the JSON metadata for the -// struct [WorkerScriptUsageModelUpdateResponse] -type workerScriptUsageModelUpdateResponseJSON struct { - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptUsageModelUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptUsageModelUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptUsageModelGetResponse struct { - UsageModel interface{} `json:"usage_model"` - JSON workerScriptUsageModelGetResponseJSON `json:"-"` -} - -// workerScriptUsageModelGetResponseJSON contains the JSON metadata for the struct -// [WorkerScriptUsageModelGetResponse] -type workerScriptUsageModelGetResponseJSON struct { - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptUsageModelGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptUsageModelGetResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptUsageModelUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` -} - -func (r WorkerScriptUsageModelUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type WorkerScriptUsageModelUpdateResponseEnvelope struct { - Errors []WorkerScriptUsageModelUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerScriptUsageModelUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkerScriptUsageModelUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerScriptUsageModelUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON workerScriptUsageModelUpdateResponseEnvelopeJSON `json:"-"` -} - -// workerScriptUsageModelUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [WorkerScriptUsageModelUpdateResponseEnvelope] -type workerScriptUsageModelUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptUsageModelUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptUsageModelUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptUsageModelUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptUsageModelUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerScriptUsageModelUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [WorkerScriptUsageModelUpdateResponseEnvelopeErrors] -type workerScriptUsageModelUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptUsageModelUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptUsageModelUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptUsageModelUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptUsageModelUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerScriptUsageModelUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [WorkerScriptUsageModelUpdateResponseEnvelopeMessages] -type workerScriptUsageModelUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptUsageModelUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptUsageModelUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerScriptUsageModelUpdateResponseEnvelopeSuccess bool - -const ( - WorkerScriptUsageModelUpdateResponseEnvelopeSuccessTrue WorkerScriptUsageModelUpdateResponseEnvelopeSuccess = true -) - -type WorkerScriptUsageModelGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type WorkerScriptUsageModelGetResponseEnvelope struct { - Errors []WorkerScriptUsageModelGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerScriptUsageModelGetResponseEnvelopeMessages `json:"messages,required"` - Result WorkerScriptUsageModelGetResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerScriptUsageModelGetResponseEnvelopeSuccess `json:"success,required"` - JSON workerScriptUsageModelGetResponseEnvelopeJSON `json:"-"` -} - -// workerScriptUsageModelGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [WorkerScriptUsageModelGetResponseEnvelope] -type workerScriptUsageModelGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptUsageModelGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptUsageModelGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptUsageModelGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptUsageModelGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerScriptUsageModelGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [WorkerScriptUsageModelGetResponseEnvelopeErrors] -type workerScriptUsageModelGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptUsageModelGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptUsageModelGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerScriptUsageModelGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerScriptUsageModelGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerScriptUsageModelGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [WorkerScriptUsageModelGetResponseEnvelopeMessages] -type workerScriptUsageModelGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerScriptUsageModelGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerScriptUsageModelGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerScriptUsageModelGetResponseEnvelopeSuccess bool - -const ( - WorkerScriptUsageModelGetResponseEnvelopeSuccessTrue WorkerScriptUsageModelGetResponseEnvelopeSuccess = true -) diff --git a/workerscriptusagemodel_test.go b/workerscriptusagemodel_test.go deleted file mode 100644 index c65ce971215..00000000000 --- a/workerscriptusagemodel_test.go +++ /dev/null @@ -1,75 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkerScriptUsageModelUpdate(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("user@example.com"), - ) - _, err := client.Workers.Scripts.UsageModel.Update( - context.TODO(), - "this-is_my_script-01", - cloudflare.WorkerScriptUsageModelUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F[any]("{'usage_model': 'unbound'}"), - }, - ) - 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 TestWorkerScriptUsageModelGet(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("user@example.com"), - ) - _, err := client.Workers.Scripts.UsageModel.Get( - context.TODO(), - "this-is_my_script-01", - cloudflare.WorkerScriptUsageModelGetParams{ - AccountID: cloudflare.F("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/workerservice.go b/workerservice.go deleted file mode 100644 index edbaaee81f0..00000000000 --- a/workerservice.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkerServiceService 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 [NewWorkerServiceService] method -// instead. -type WorkerServiceService struct { - Options []option.RequestOption - Environments *WorkerServiceEnvironmentService -} - -// NewWorkerServiceService 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 NewWorkerServiceService(opts ...option.RequestOption) (r *WorkerServiceService) { - r = &WorkerServiceService{} - r.Options = opts - r.Environments = NewWorkerServiceEnvironmentService(opts...) - return -} diff --git a/workerserviceenvironment.go b/workerserviceenvironment.go deleted file mode 100644 index be9ef407a92..00000000000 --- a/workerserviceenvironment.go +++ /dev/null @@ -1,29 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkerServiceEnvironmentService 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 -// [NewWorkerServiceEnvironmentService] method instead. -type WorkerServiceEnvironmentService struct { - Options []option.RequestOption - Content *WorkerServiceEnvironmentContentService - Settings *WorkerServiceEnvironmentSettingService -} - -// NewWorkerServiceEnvironmentService 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 NewWorkerServiceEnvironmentService(opts ...option.RequestOption) (r *WorkerServiceEnvironmentService) { - r = &WorkerServiceEnvironmentService{} - r.Options = opts - r.Content = NewWorkerServiceEnvironmentContentService(opts...) - r.Settings = NewWorkerServiceEnvironmentSettingService(opts...) - return -} diff --git a/workerserviceenvironmentcontent.go b/workerserviceenvironmentcontent.go deleted file mode 100644 index 941f4b1c387..00000000000 --- a/workerserviceenvironmentcontent.go +++ /dev/null @@ -1,268 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "bytes" - "context" - "fmt" - "io" - "mime/multipart" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apiform" - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkerServiceEnvironmentContentService 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 -// [NewWorkerServiceEnvironmentContentService] method instead. -type WorkerServiceEnvironmentContentService struct { - Options []option.RequestOption -} - -// NewWorkerServiceEnvironmentContentService 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 NewWorkerServiceEnvironmentContentService(opts ...option.RequestOption) (r *WorkerServiceEnvironmentContentService) { - r = &WorkerServiceEnvironmentContentService{} - r.Options = opts - return -} - -// Put script content from a worker with an environment -func (r *WorkerServiceEnvironmentContentService) Update(ctx context.Context, serviceName string, environmentName string, params WorkerServiceEnvironmentContentUpdateParams, opts ...option.RequestOption) (res *WorkerServiceEnvironmentContentUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerServiceEnvironmentContentUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/services/%s/environments/%s/content", params.AccountID, serviceName, environmentName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get script content from a worker with an environment -func (r *WorkerServiceEnvironmentContentService) Get(ctx context.Context, serviceName string, environmentName string, query WorkerServiceEnvironmentContentGetParams, opts ...option.RequestOption) (res *http.Response, err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "string")}, opts...) - path := fmt.Sprintf("accounts/%s/workers/services/%s/environments/%s/content", query.AccountID, serviceName, environmentName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -type WorkerServiceEnvironmentContentUpdateResponse struct { - // The id of the script in the Workers system. Usually the script name. - ID string `json:"id"` - // When the script was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Hashed script content, can be used in a If-None-Match header when updating. - Etag string `json:"etag"` - // Whether Logpush is turned on for the Worker. - Logpush bool `json:"logpush"` - // When the script was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Deprecated. Deployment metadata for internal usage. - PipelineHash string `json:"pipeline_hash"` - // Specifies the placement mode for the Worker (e.g. 'smart'). - PlacementMode string `json:"placement_mode"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers []WorkerServiceEnvironmentContentUpdateResponseTailConsumer `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel string `json:"usage_model"` - JSON workerServiceEnvironmentContentUpdateResponseJSON `json:"-"` -} - -// workerServiceEnvironmentContentUpdateResponseJSON contains the JSON metadata for -// the struct [WorkerServiceEnvironmentContentUpdateResponse] -type workerServiceEnvironmentContentUpdateResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Etag apijson.Field - Logpush apijson.Field - ModifiedOn apijson.Field - PipelineHash apijson.Field - PlacementMode apijson.Field - TailConsumers apijson.Field - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentContentUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentContentUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// A reference to a script that will consume logs from the attached Worker. -type WorkerServiceEnvironmentContentUpdateResponseTailConsumer struct { - // Name of Worker that is to be the consumer. - Service string `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment string `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace string `json:"namespace"` - JSON workerServiceEnvironmentContentUpdateResponseTailConsumerJSON `json:"-"` -} - -// workerServiceEnvironmentContentUpdateResponseTailConsumerJSON contains the JSON -// metadata for the struct -// [WorkerServiceEnvironmentContentUpdateResponseTailConsumer] -type workerServiceEnvironmentContentUpdateResponseTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentContentUpdateResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentContentUpdateResponseTailConsumerJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentContentUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // A module comprising a Worker script, often a javascript file. Multiple modules - // may be provided as separate named parts, but at least one module must be - // present. This should be referenced either in the metadata as `main_module` - // (esm)/`body_part` (service worker) or as a header `CF-WORKER-MAIN-MODULE-PART` - // (esm) /`CF-WORKER-BODY-PART` (service worker) by part name. - AnyPartName param.Field[[]io.Reader] `json:"" format:"binary"` - // JSON encoded metadata about the uploaded parts and Worker configuration. - Metadata param.Field[WorkerServiceEnvironmentContentUpdateParamsMetadata] `json:"metadata"` - CfWorkerBodyPart param.Field[string] `header:"CF-WORKER-BODY-PART"` - CfWorkerMainModulePart param.Field[string] `header:"CF-WORKER-MAIN-MODULE-PART"` -} - -func (r WorkerServiceEnvironmentContentUpdateParams) MarshalMultipart() (data []byte, contentType string, err error) { - buf := bytes.NewBuffer(nil) - writer := multipart.NewWriter(buf) - err = apiform.MarshalRoot(r, writer) - if err != nil { - writer.Close() - return nil, "", err - } - err = writer.Close() - if err != nil { - return nil, "", err - } - return buf.Bytes(), writer.FormDataContentType(), nil -} - -// JSON encoded metadata about the uploaded parts and Worker configuration. -type WorkerServiceEnvironmentContentUpdateParamsMetadata struct { - // Name of the part in the multipart request that contains the script (e.g. the - // file adding a listener to the `fetch` event). Indicates a - // `service worker syntax` Worker. - BodyPart param.Field[string] `json:"body_part"` - // Name of the part in the multipart request that contains the main module (e.g. - // the file exporting a `fetch` handler). Indicates a `module syntax` Worker. - MainModule param.Field[string] `json:"main_module"` -} - -func (r WorkerServiceEnvironmentContentUpdateParamsMetadata) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerServiceEnvironmentContentUpdateResponseEnvelope struct { - Errors []WorkerServiceEnvironmentContentUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerServiceEnvironmentContentUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkerServiceEnvironmentContentUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerServiceEnvironmentContentUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON workerServiceEnvironmentContentUpdateResponseEnvelopeJSON `json:"-"` -} - -// workerServiceEnvironmentContentUpdateResponseEnvelopeJSON contains the JSON -// metadata for the struct [WorkerServiceEnvironmentContentUpdateResponseEnvelope] -type workerServiceEnvironmentContentUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentContentUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentContentUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentContentUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerServiceEnvironmentContentUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerServiceEnvironmentContentUpdateResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [WorkerServiceEnvironmentContentUpdateResponseEnvelopeErrors] -type workerServiceEnvironmentContentUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentContentUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentContentUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentContentUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerServiceEnvironmentContentUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerServiceEnvironmentContentUpdateResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [WorkerServiceEnvironmentContentUpdateResponseEnvelopeMessages] -type workerServiceEnvironmentContentUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentContentUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentContentUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerServiceEnvironmentContentUpdateResponseEnvelopeSuccess bool - -const ( - WorkerServiceEnvironmentContentUpdateResponseEnvelopeSuccessTrue WorkerServiceEnvironmentContentUpdateResponseEnvelopeSuccess = true -) - -type WorkerServiceEnvironmentContentGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} diff --git a/workerserviceenvironmentcontent_test.go b/workerserviceenvironmentcontent_test.go deleted file mode 100644 index 94e196088e0..00000000000 --- a/workerserviceenvironmentcontent_test.go +++ /dev/null @@ -1,99 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "bytes" - "context" - "errors" - "io" - "net/http" - "net/http/httptest" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkerServiceEnvironmentContentUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Workers.Services.Environments.Content.Update( - context.TODO(), - "my-worker", - "production", - cloudflare.WorkerServiceEnvironmentContentUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - AnyPartName: cloudflare.F([]io.Reader{io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents")))}), - Metadata: cloudflare.F(cloudflare.WorkerServiceEnvironmentContentUpdateParamsMetadata{ - BodyPart: cloudflare.F("worker.js"), - MainModule: cloudflare.F("worker.js"), - }), - CfWorkerBodyPart: cloudflare.F("string"), - CfWorkerMainModulePart: cloudflare.F("string"), - }, - ) - 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 TestWorkerServiceEnvironmentContentGet(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - w.Write([]byte("abc")) - })) - defer server.Close() - baseURL := server.URL - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - resp, err := client.Workers.Services.Environments.Content.Get( - context.TODO(), - "my-worker", - "production", - cloudflare.WorkerServiceEnvironmentContentGetParams{ - AccountID: cloudflare.F("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()) - } - defer resp.Body.Close() - - b, err := io.ReadAll(resp.Body) - 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()) - } - if !bytes.Equal(b, []byte("abc")) { - t.Fatalf("return value not %s: %s", "abc", b) - } -} diff --git a/workerserviceenvironmentsetting.go b/workerserviceenvironmentsetting.go deleted file mode 100644 index 98728558eeb..00000000000 --- a/workerserviceenvironmentsetting.go +++ /dev/null @@ -1,2212 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// WorkerServiceEnvironmentSettingService 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 -// [NewWorkerServiceEnvironmentSettingService] method instead. -type WorkerServiceEnvironmentSettingService struct { - Options []option.RequestOption -} - -// NewWorkerServiceEnvironmentSettingService 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 NewWorkerServiceEnvironmentSettingService(opts ...option.RequestOption) (r *WorkerServiceEnvironmentSettingService) { - r = &WorkerServiceEnvironmentSettingService{} - r.Options = opts - return -} - -// Patch script metadata, such as bindings -func (r *WorkerServiceEnvironmentSettingService) Edit(ctx context.Context, serviceName string, environmentName string, params WorkerServiceEnvironmentSettingEditParams, opts ...option.RequestOption) (res *WorkerServiceEnvironmentSettingEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerServiceEnvironmentSettingEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/services/%s/environments/%s/settings", params.AccountID, serviceName, environmentName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get script settings from a worker with an environment -func (r *WorkerServiceEnvironmentSettingService) Get(ctx context.Context, serviceName string, environmentName string, query WorkerServiceEnvironmentSettingGetParams, opts ...option.RequestOption) (res *WorkerServiceEnvironmentSettingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerServiceEnvironmentSettingGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/services/%s/environments/%s/settings", query.AccountID, serviceName, environmentName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WorkerServiceEnvironmentSettingEditResponse struct { - // List of bindings attached to this Worker - Bindings []WorkerServiceEnvironmentSettingEditResponseBinding `json:"bindings"` - // Opt your Worker into changes after this date - CompatibilityDate string `json:"compatibility_date"` - // Opt your Worker into specific changes - CompatibilityFlags []string `json:"compatibility_flags"` - // Whether Logpush is turned on for the Worker. - Logpush bool `json:"logpush"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations WorkerServiceEnvironmentSettingEditResponseMigrations `json:"migrations"` - Placement WorkerServiceEnvironmentSettingEditResponsePlacement `json:"placement"` - // Tags to help you manage your Workers - Tags []string `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers []WorkerServiceEnvironmentSettingEditResponseTailConsumer `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel string `json:"usage_model"` - JSON workerServiceEnvironmentSettingEditResponseJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseJSON contains the JSON metadata for -// the struct [WorkerServiceEnvironmentSettingEditResponse] -type workerServiceEnvironmentSettingEditResponseJSON struct { - Bindings apijson.Field - CompatibilityDate apijson.Field - CompatibilityFlags apijson.Field - Logpush apijson.Field - Migrations apijson.Field - Placement apijson.Field - Tags apijson.Field - TailConsumers apijson.Field - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseJSON) RawJSON() string { - return r.raw -} - -// A binding to allow the Worker to communicate with resources -// -// Union satisfied by -// [WorkerServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBinding], -// [WorkerServiceEnvironmentSettingEditResponseBindingsWorkersServiceBinding], -// [WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDoBinding], -// [WorkerServiceEnvironmentSettingEditResponseBindingsWorkersR2Binding], -// [WorkerServiceEnvironmentSettingEditResponseBindingsWorkersQueueBinding], -// [WorkerServiceEnvironmentSettingEditResponseBindingsWorkersD1Binding], -// [WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBinding] -// or [WorkerServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBinding]. -type WorkerServiceEnvironmentSettingEditResponseBinding interface { - implementsWorkerServiceEnvironmentSettingEditResponseBinding() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkerServiceEnvironmentSettingEditResponseBinding)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingEditResponseBindingsWorkersServiceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDoBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingEditResponseBindingsWorkersR2Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingEditResponseBindingsWorkersQueueBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingEditResponseBindingsWorkersD1Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBinding{}), - }, - ) -} - -type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id,required"` - // The class of resource that the binding provides. - Type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingType `json:"type,required"` - JSON workerServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBinding] -type workerServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON struct { - Name apijson.Field - NamespaceID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBinding) implementsWorkerServiceEnvironmentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingType string - -const ( - WorkerServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace WorkerServiceEnvironmentSettingEditResponseBindingsWorkersKVNamespaceBindingType = "kv_namespace" -) - -type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment string `json:"environment,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of Worker to bind to - Service string `json:"service,required"` - // The class of resource that the binding provides. - Type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersServiceBindingType `json:"type,required"` - JSON workerServiceEnvironmentSettingEditResponseBindingsWorkersServiceBindingJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseBindingsWorkersServiceBindingJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseBindingsWorkersServiceBinding] -type workerServiceEnvironmentSettingEditResponseBindingsWorkersServiceBindingJSON struct { - Environment apijson.Field - Name apijson.Field - Service apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseBindingsWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseBindingsWorkersServiceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingEditResponseBindingsWorkersServiceBinding) implementsWorkerServiceEnvironmentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersServiceBindingType string - -const ( - WorkerServiceEnvironmentSettingEditResponseBindingsWorkersServiceBindingTypeService WorkerServiceEnvironmentSettingEditResponseBindingsWorkersServiceBindingType = "service" -) - -type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName string `json:"class_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDoBindingType `json:"type,required"` - // The environment of the script_name to bind to - Environment string `json:"environment"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName string `json:"script_name"` - JSON workerServiceEnvironmentSettingEditResponseBindingsWorkersDoBindingJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseBindingsWorkersDoBindingJSON contains -// the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDoBinding] -type workerServiceEnvironmentSettingEditResponseBindingsWorkersDoBindingJSON struct { - ClassName apijson.Field - Name apijson.Field - Type apijson.Field - Environment apijson.Field - NamespaceID apijson.Field - ScriptName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseBindingsWorkersDoBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDoBinding) implementsWorkerServiceEnvironmentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDoBindingType string - -const ( - WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDoBindingTypeDurableObjectNamespace WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDoBindingType = "durable_object_namespace" -) - -type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersR2Binding struct { - // R2 bucket to bind to - BucketName string `json:"bucket_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersR2BindingType `json:"type,required"` - JSON workerServiceEnvironmentSettingEditResponseBindingsWorkersR2BindingJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseBindingsWorkersR2BindingJSON contains -// the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseBindingsWorkersR2Binding] -type workerServiceEnvironmentSettingEditResponseBindingsWorkersR2BindingJSON struct { - BucketName apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseBindingsWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseBindingsWorkersR2BindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingEditResponseBindingsWorkersR2Binding) implementsWorkerServiceEnvironmentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersR2BindingType string - -const ( - WorkerServiceEnvironmentSettingEditResponseBindingsWorkersR2BindingTypeR2Bucket WorkerServiceEnvironmentSettingEditResponseBindingsWorkersR2BindingType = "r2_bucket" -) - -type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersQueueBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of the Queue to bind to - QueueName string `json:"queue_name,required"` - // The class of resource that the binding provides. - Type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersQueueBindingType `json:"type,required"` - JSON workerServiceEnvironmentSettingEditResponseBindingsWorkersQueueBindingJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseBindingsWorkersQueueBindingJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseBindingsWorkersQueueBinding] -type workerServiceEnvironmentSettingEditResponseBindingsWorkersQueueBindingJSON struct { - Name apijson.Field - QueueName apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseBindingsWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseBindingsWorkersQueueBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingEditResponseBindingsWorkersQueueBinding) implementsWorkerServiceEnvironmentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersQueueBindingType string - -const ( - WorkerServiceEnvironmentSettingEditResponseBindingsWorkersQueueBindingTypeQueue WorkerServiceEnvironmentSettingEditResponseBindingsWorkersQueueBindingType = "queue" -) - -type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersD1Binding struct { - // ID of the D1 database to bind to - ID string `json:"id,required"` - // A JavaScript variable name for the binding. - Binding string `json:"binding,required"` - // The name of the D1 database associated with the 'id' provided. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersD1BindingType `json:"type,required"` - JSON workerServiceEnvironmentSettingEditResponseBindingsWorkersD1BindingJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseBindingsWorkersD1BindingJSON contains -// the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseBindingsWorkersD1Binding] -type workerServiceEnvironmentSettingEditResponseBindingsWorkersD1BindingJSON struct { - ID apijson.Field - Binding apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseBindingsWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseBindingsWorkersD1BindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingEditResponseBindingsWorkersD1Binding) implementsWorkerServiceEnvironmentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersD1BindingType string - -const ( - WorkerServiceEnvironmentSettingEditResponseBindingsWorkersD1BindingTypeD1 WorkerServiceEnvironmentSettingEditResponseBindingsWorkersD1BindingType = "d1" -) - -type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace to bind to - Namespace string `json:"namespace,required"` - // The class of resource that the binding provides. - Type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingType `json:"type,required"` - // Outbound worker - Outbound WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound `json:"outbound"` - JSON workerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBinding] -type workerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON struct { - Name apijson.Field - Namespace apijson.Field - Type apijson.Field - Outbound apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBinding) implementsWorkerServiceEnvironmentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingType string - -const ( - WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -// Outbound worker -type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params []string `json:"params"` - // Outbound worker - Worker WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` - JSON workerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound] -type workerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON struct { - Params apijson.Field - Worker apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { - return r.raw -} - -// Outbound worker -type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment string `json:"environment"` - // Name of the outbound worker - Service string `json:"service"` - JSON workerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker] -type workerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { - Environment apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBindingType `json:"type,required"` - // ID of the certificate to bind to - CertificateID string `json:"certificate_id"` - JSON workerServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBindingJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBindingJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBinding] -type workerServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBindingJSON struct { - Name apijson.Field - Type apijson.Field - CertificateID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBinding) implementsWorkerServiceEnvironmentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBindingType string - -const ( - WorkerServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBindingTypeMTLSCertificate WorkerServiceEnvironmentSettingEditResponseBindingsWorkersMTLSCertBindingType = "mtls_certificate" -) - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Union satisfied by -// [WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrations] -// or -// [WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrations]. -type WorkerServiceEnvironmentSettingEditResponseMigrations interface { - implementsWorkerServiceEnvironmentSettingEditResponseMigrations() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkerServiceEnvironmentSettingEditResponseMigrations)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrations{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrations{}), - }, - ) -} - -// A single set of migrations to apply. -type WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass `json:"transferred_classes"` - JSON workerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrations] -type workerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - NewTag apijson.Field - OldTag apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrations) implementsWorkerServiceEnvironmentSettingEditResponseMigrations() { -} - -type WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON workerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass] -type workerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON workerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass] -type workerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // Migrations to apply in order. - Steps []WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStep `json:"steps"` - JSON workerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrations] -type workerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON struct { - NewTag apijson.Field - OldTag apijson.Field - Steps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrations) implementsWorkerServiceEnvironmentSettingEditResponseMigrations() { -} - -type WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass `json:"transferred_classes"` - JSON workerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStep] -type workerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStep) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON workerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass] -type workerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON workerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass] -type workerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentSettingEditResponsePlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode WorkerServiceEnvironmentSettingEditResponsePlacementMode `json:"mode"` - JSON workerServiceEnvironmentSettingEditResponsePlacementJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponsePlacementJSON contains the JSON -// metadata for the struct [WorkerServiceEnvironmentSettingEditResponsePlacement] -type workerServiceEnvironmentSettingEditResponsePlacementJSON struct { - Mode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponsePlacement) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponsePlacementJSON) RawJSON() string { - return r.raw -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type WorkerServiceEnvironmentSettingEditResponsePlacementMode string - -const ( - WorkerServiceEnvironmentSettingEditResponsePlacementModeSmart WorkerServiceEnvironmentSettingEditResponsePlacementMode = "smart" -) - -// A reference to a script that will consume logs from the attached Worker. -type WorkerServiceEnvironmentSettingEditResponseTailConsumer struct { - // Name of Worker that is to be the consumer. - Service string `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment string `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace string `json:"namespace"` - JSON workerServiceEnvironmentSettingEditResponseTailConsumerJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseTailConsumerJSON contains the JSON -// metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseTailConsumer] -type workerServiceEnvironmentSettingEditResponseTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseTailConsumerJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentSettingGetResponse struct { - // List of bindings attached to this Worker - Bindings []WorkerServiceEnvironmentSettingGetResponseBinding `json:"bindings"` - // Opt your Worker into changes after this date - CompatibilityDate string `json:"compatibility_date"` - // Opt your Worker into specific changes - CompatibilityFlags []string `json:"compatibility_flags"` - // Whether Logpush is turned on for the Worker. - Logpush bool `json:"logpush"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations WorkerServiceEnvironmentSettingGetResponseMigrations `json:"migrations"` - Placement WorkerServiceEnvironmentSettingGetResponsePlacement `json:"placement"` - // Tags to help you manage your Workers - Tags []string `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers []WorkerServiceEnvironmentSettingGetResponseTailConsumer `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel string `json:"usage_model"` - JSON workerServiceEnvironmentSettingGetResponseJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseJSON contains the JSON metadata for -// the struct [WorkerServiceEnvironmentSettingGetResponse] -type workerServiceEnvironmentSettingGetResponseJSON struct { - Bindings apijson.Field - CompatibilityDate apijson.Field - CompatibilityFlags apijson.Field - Logpush apijson.Field - Migrations apijson.Field - Placement apijson.Field - Tags apijson.Field - TailConsumers apijson.Field - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseJSON) RawJSON() string { - return r.raw -} - -// A binding to allow the Worker to communicate with resources -// -// Union satisfied by -// [WorkerServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBinding], -// [WorkerServiceEnvironmentSettingGetResponseBindingsWorkersServiceBinding], -// [WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDoBinding], -// [WorkerServiceEnvironmentSettingGetResponseBindingsWorkersR2Binding], -// [WorkerServiceEnvironmentSettingGetResponseBindingsWorkersQueueBinding], -// [WorkerServiceEnvironmentSettingGetResponseBindingsWorkersD1Binding], -// [WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBinding] -// or [WorkerServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBinding]. -type WorkerServiceEnvironmentSettingGetResponseBinding interface { - implementsWorkerServiceEnvironmentSettingGetResponseBinding() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkerServiceEnvironmentSettingGetResponseBinding)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingGetResponseBindingsWorkersServiceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDoBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingGetResponseBindingsWorkersR2Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingGetResponseBindingsWorkersQueueBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingGetResponseBindingsWorkersD1Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBinding{}), - }, - ) -} - -type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id,required"` - // The class of resource that the binding provides. - Type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingType `json:"type,required"` - JSON workerServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBinding] -type workerServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON struct { - Name apijson.Field - NamespaceID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBinding) implementsWorkerServiceEnvironmentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingType string - -const ( - WorkerServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace WorkerServiceEnvironmentSettingGetResponseBindingsWorkersKVNamespaceBindingType = "kv_namespace" -) - -type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment string `json:"environment,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of Worker to bind to - Service string `json:"service,required"` - // The class of resource that the binding provides. - Type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersServiceBindingType `json:"type,required"` - JSON workerServiceEnvironmentSettingGetResponseBindingsWorkersServiceBindingJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseBindingsWorkersServiceBindingJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseBindingsWorkersServiceBinding] -type workerServiceEnvironmentSettingGetResponseBindingsWorkersServiceBindingJSON struct { - Environment apijson.Field - Name apijson.Field - Service apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseBindingsWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseBindingsWorkersServiceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingGetResponseBindingsWorkersServiceBinding) implementsWorkerServiceEnvironmentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersServiceBindingType string - -const ( - WorkerServiceEnvironmentSettingGetResponseBindingsWorkersServiceBindingTypeService WorkerServiceEnvironmentSettingGetResponseBindingsWorkersServiceBindingType = "service" -) - -type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName string `json:"class_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDoBindingType `json:"type,required"` - // The environment of the script_name to bind to - Environment string `json:"environment"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName string `json:"script_name"` - JSON workerServiceEnvironmentSettingGetResponseBindingsWorkersDoBindingJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseBindingsWorkersDoBindingJSON contains -// the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDoBinding] -type workerServiceEnvironmentSettingGetResponseBindingsWorkersDoBindingJSON struct { - ClassName apijson.Field - Name apijson.Field - Type apijson.Field - Environment apijson.Field - NamespaceID apijson.Field - ScriptName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseBindingsWorkersDoBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDoBinding) implementsWorkerServiceEnvironmentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDoBindingType string - -const ( - WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDoBindingTypeDurableObjectNamespace WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDoBindingType = "durable_object_namespace" -) - -type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersR2Binding struct { - // R2 bucket to bind to - BucketName string `json:"bucket_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersR2BindingType `json:"type,required"` - JSON workerServiceEnvironmentSettingGetResponseBindingsWorkersR2BindingJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseBindingsWorkersR2BindingJSON contains -// the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseBindingsWorkersR2Binding] -type workerServiceEnvironmentSettingGetResponseBindingsWorkersR2BindingJSON struct { - BucketName apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseBindingsWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseBindingsWorkersR2BindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingGetResponseBindingsWorkersR2Binding) implementsWorkerServiceEnvironmentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersR2BindingType string - -const ( - WorkerServiceEnvironmentSettingGetResponseBindingsWorkersR2BindingTypeR2Bucket WorkerServiceEnvironmentSettingGetResponseBindingsWorkersR2BindingType = "r2_bucket" -) - -type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersQueueBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of the Queue to bind to - QueueName string `json:"queue_name,required"` - // The class of resource that the binding provides. - Type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersQueueBindingType `json:"type,required"` - JSON workerServiceEnvironmentSettingGetResponseBindingsWorkersQueueBindingJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseBindingsWorkersQueueBindingJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseBindingsWorkersQueueBinding] -type workerServiceEnvironmentSettingGetResponseBindingsWorkersQueueBindingJSON struct { - Name apijson.Field - QueueName apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseBindingsWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseBindingsWorkersQueueBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingGetResponseBindingsWorkersQueueBinding) implementsWorkerServiceEnvironmentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersQueueBindingType string - -const ( - WorkerServiceEnvironmentSettingGetResponseBindingsWorkersQueueBindingTypeQueue WorkerServiceEnvironmentSettingGetResponseBindingsWorkersQueueBindingType = "queue" -) - -type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersD1Binding struct { - // ID of the D1 database to bind to - ID string `json:"id,required"` - // A JavaScript variable name for the binding. - Binding string `json:"binding,required"` - // The name of the D1 database associated with the 'id' provided. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersD1BindingType `json:"type,required"` - JSON workerServiceEnvironmentSettingGetResponseBindingsWorkersD1BindingJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseBindingsWorkersD1BindingJSON contains -// the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseBindingsWorkersD1Binding] -type workerServiceEnvironmentSettingGetResponseBindingsWorkersD1BindingJSON struct { - ID apijson.Field - Binding apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseBindingsWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseBindingsWorkersD1BindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingGetResponseBindingsWorkersD1Binding) implementsWorkerServiceEnvironmentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersD1BindingType string - -const ( - WorkerServiceEnvironmentSettingGetResponseBindingsWorkersD1BindingTypeD1 WorkerServiceEnvironmentSettingGetResponseBindingsWorkersD1BindingType = "d1" -) - -type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace to bind to - Namespace string `json:"namespace,required"` - // The class of resource that the binding provides. - Type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingType `json:"type,required"` - // Outbound worker - Outbound WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound `json:"outbound"` - JSON workerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBinding] -type workerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON struct { - Name apijson.Field - Namespace apijson.Field - Type apijson.Field - Outbound apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBinding) implementsWorkerServiceEnvironmentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingType string - -const ( - WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -// Outbound worker -type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params []string `json:"params"` - // Outbound worker - Worker WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` - JSON workerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound] -type workerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON struct { - Params apijson.Field - Worker apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { - return r.raw -} - -// Outbound worker -type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment string `json:"environment"` - // Name of the outbound worker - Service string `json:"service"` - JSON workerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker] -type workerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { - Environment apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBindingType `json:"type,required"` - // ID of the certificate to bind to - CertificateID string `json:"certificate_id"` - JSON workerServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBindingJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBindingJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBinding] -type workerServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBindingJSON struct { - Name apijson.Field - Type apijson.Field - CertificateID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBinding) implementsWorkerServiceEnvironmentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBindingType string - -const ( - WorkerServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBindingTypeMTLSCertificate WorkerServiceEnvironmentSettingGetResponseBindingsWorkersMTLSCertBindingType = "mtls_certificate" -) - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Union satisfied by -// [WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrations] -// or -// [WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrations]. -type WorkerServiceEnvironmentSettingGetResponseMigrations interface { - implementsWorkerServiceEnvironmentSettingGetResponseMigrations() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkerServiceEnvironmentSettingGetResponseMigrations)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrations{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrations{}), - }, - ) -} - -// A single set of migrations to apply. -type WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass `json:"transferred_classes"` - JSON workerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrations] -type workerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - NewTag apijson.Field - OldTag apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrations) implementsWorkerServiceEnvironmentSettingGetResponseMigrations() { -} - -type WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON workerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass] -type workerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON workerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass] -type workerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // Migrations to apply in order. - Steps []WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStep `json:"steps"` - JSON workerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrations] -type workerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON struct { - NewTag apijson.Field - OldTag apijson.Field - Steps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrations) implementsWorkerServiceEnvironmentSettingGetResponseMigrations() { -} - -type WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass `json:"transferred_classes"` - JSON workerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStep] -type workerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStep) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON workerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass] -type workerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON workerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON -// contains the JSON metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass] -type workerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentSettingGetResponsePlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode WorkerServiceEnvironmentSettingGetResponsePlacementMode `json:"mode"` - JSON workerServiceEnvironmentSettingGetResponsePlacementJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponsePlacementJSON contains the JSON -// metadata for the struct [WorkerServiceEnvironmentSettingGetResponsePlacement] -type workerServiceEnvironmentSettingGetResponsePlacementJSON struct { - Mode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponsePlacement) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponsePlacementJSON) RawJSON() string { - return r.raw -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type WorkerServiceEnvironmentSettingGetResponsePlacementMode string - -const ( - WorkerServiceEnvironmentSettingGetResponsePlacementModeSmart WorkerServiceEnvironmentSettingGetResponsePlacementMode = "smart" -) - -// A reference to a script that will consume logs from the attached Worker. -type WorkerServiceEnvironmentSettingGetResponseTailConsumer struct { - // Name of Worker that is to be the consumer. - Service string `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment string `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace string `json:"namespace"` - JSON workerServiceEnvironmentSettingGetResponseTailConsumerJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseTailConsumerJSON contains the JSON -// metadata for the struct [WorkerServiceEnvironmentSettingGetResponseTailConsumer] -type workerServiceEnvironmentSettingGetResponseTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseTailConsumerJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentSettingEditParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Errors param.Field[[]WorkerServiceEnvironmentSettingEditParamsError] `json:"errors,required"` - Messages param.Field[[]WorkerServiceEnvironmentSettingEditParamsMessage] `json:"messages,required"` - Result param.Field[WorkerServiceEnvironmentSettingEditParamsResult] `json:"result,required"` - // Whether the API call was successful - Success param.Field[WorkerServiceEnvironmentSettingEditParamsSuccess] `json:"success,required"` -} - -func (r WorkerServiceEnvironmentSettingEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerServiceEnvironmentSettingEditParamsError struct { - Code param.Field[int64] `json:"code,required"` - Message param.Field[string] `json:"message,required"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsError) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerServiceEnvironmentSettingEditParamsMessage struct { - Code param.Field[int64] `json:"code,required"` - Message param.Field[string] `json:"message,required"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsMessage) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerServiceEnvironmentSettingEditParamsResult struct { - // List of bindings attached to this Worker - Bindings param.Field[[]WorkerServiceEnvironmentSettingEditParamsResultBinding] `json:"bindings"` - // Opt your Worker into changes after this date - CompatibilityDate param.Field[string] `json:"compatibility_date"` - // Opt your Worker into specific changes - CompatibilityFlags param.Field[[]string] `json:"compatibility_flags"` - // Whether Logpush is turned on for the Worker. - Logpush param.Field[bool] `json:"logpush"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations param.Field[WorkerServiceEnvironmentSettingEditParamsResultMigrations] `json:"migrations"` - Placement param.Field[WorkerServiceEnvironmentSettingEditParamsResultPlacement] `json:"placement"` - // Tags to help you manage your Workers - Tags param.Field[[]string] `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers param.Field[[]WorkerServiceEnvironmentSettingEditParamsResultTailConsumer] `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel param.Field[string] `json:"usage_model"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResult) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A binding to allow the Worker to communicate with resources -// -// Satisfied by -// [WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding], -// [WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBinding], -// [WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBinding], -// [WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersR2Binding], -// [WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBinding], -// [WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersD1Binding], -// [WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding], -// [WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCertBinding]. -type WorkerServiceEnvironmentSettingEditParamsResultBinding interface { - implementsWorkerServiceEnvironmentSettingEditParamsResultBinding() -} - -type WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding struct { - // The class of resource that the binding provides. - Type param.Field[WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingType] `json:"type,required"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding) implementsWorkerServiceEnvironmentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingType string - -const ( - WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingType = "kv_namespace" -) - -type WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment param.Field[string] `json:"environment,required"` - // Name of Worker to bind to - Service param.Field[string] `json:"service,required"` - // The class of resource that the binding provides. - Type param.Field[WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBindingType] `json:"type,required"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBinding) implementsWorkerServiceEnvironmentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBindingType string - -const ( - WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBindingTypeService WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersServiceBindingType = "service" -) - -type WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName param.Field[string] `json:"class_name,required"` - // The class of resource that the binding provides. - Type param.Field[WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBindingType] `json:"type,required"` - // The environment of the script_name to bind to - Environment param.Field[string] `json:"environment"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName param.Field[string] `json:"script_name"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBinding) implementsWorkerServiceEnvironmentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBindingType string - -const ( - WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBindingTypeDurableObjectNamespace WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDoBindingType = "durable_object_namespace" -) - -type WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersR2Binding struct { - // R2 bucket to bind to - BucketName param.Field[string] `json:"bucket_name,required"` - // The class of resource that the binding provides. - Type param.Field[WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersR2BindingType] `json:"type,required"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersR2Binding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersR2Binding) implementsWorkerServiceEnvironmentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersR2BindingType string - -const ( - WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersR2BindingTypeR2Bucket WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersR2BindingType = "r2_bucket" -) - -type WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBinding struct { - // Name of the Queue to bind to - QueueName param.Field[string] `json:"queue_name,required"` - // The class of resource that the binding provides. - Type param.Field[WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBindingType] `json:"type,required"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBinding) implementsWorkerServiceEnvironmentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBindingType string - -const ( - WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBindingTypeQueue WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersQueueBindingType = "queue" -) - -type WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersD1Binding struct { - // ID of the D1 database to bind to - ID param.Field[string] `json:"id,required"` - // The name of the D1 database associated with the 'id' provided. - Name param.Field[string] `json:"name,required"` - // The class of resource that the binding provides. - Type param.Field[WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersD1BindingType] `json:"type,required"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersD1Binding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersD1Binding) implementsWorkerServiceEnvironmentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersD1BindingType string - -const ( - WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersD1BindingTypeD1 WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersD1BindingType = "d1" -) - -type WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding struct { - // Namespace to bind to - Namespace param.Field[string] `json:"namespace,required"` - // The class of resource that the binding provides. - Type param.Field[WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType] `json:"type,required"` - // Outbound worker - Outbound param.Field[WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutbound] `json:"outbound"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding) implementsWorkerServiceEnvironmentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType string - -const ( - WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -// Outbound worker -type WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params param.Field[[]string] `json:"params"` - // Outbound worker - Worker param.Field[WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker] `json:"worker"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutbound) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Outbound worker -type WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment param.Field[string] `json:"environment"` - // Name of the outbound worker - Service param.Field[string] `json:"service"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCertBinding struct { - // The class of resource that the binding provides. - Type param.Field[WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCertBindingType] `json:"type,required"` - // ID of the certificate to bind to - CertificateID param.Field[string] `json:"certificate_id"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCertBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCertBinding) implementsWorkerServiceEnvironmentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCertBindingType string - -const ( - WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCertBindingTypeMTLSCertificate WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersMTLSCertBindingType = "mtls_certificate" -) - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Satisfied by -// [WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrations], -// [WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrations]. -type WorkerServiceEnvironmentSettingEditParamsResultMigrations interface { - implementsWorkerServiceEnvironmentSettingEditParamsResultMigrations() -} - -// A single set of migrations to apply. -type WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag param.Field[string] `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass] `json:"transferred_classes"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrations) implementsWorkerServiceEnvironmentSettingEditParamsResultMigrations() { -} - -type WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag param.Field[string] `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // Migrations to apply in order. - Steps param.Field[[]WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStep] `json:"steps"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrations) implementsWorkerServiceEnvironmentSettingEditParamsResultMigrations() { -} - -type WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass] `json:"transferred_classes"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStep) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkerServiceEnvironmentSettingEditParamsResultPlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode param.Field[WorkerServiceEnvironmentSettingEditParamsResultPlacementMode] `json:"mode"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultPlacement) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type WorkerServiceEnvironmentSettingEditParamsResultPlacementMode string - -const ( - WorkerServiceEnvironmentSettingEditParamsResultPlacementModeSmart WorkerServiceEnvironmentSettingEditParamsResultPlacementMode = "smart" -) - -// A reference to a script that will consume logs from the attached Worker. -type WorkerServiceEnvironmentSettingEditParamsResultTailConsumer struct { - // Name of Worker that is to be the consumer. - Service param.Field[string] `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment param.Field[string] `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace param.Field[string] `json:"namespace"` -} - -func (r WorkerServiceEnvironmentSettingEditParamsResultTailConsumer) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Whether the API call was successful -type WorkerServiceEnvironmentSettingEditParamsSuccess bool - -const ( - WorkerServiceEnvironmentSettingEditParamsSuccessTrue WorkerServiceEnvironmentSettingEditParamsSuccess = true -) - -type WorkerServiceEnvironmentSettingEditResponseEnvelope struct { - Errors []WorkerServiceEnvironmentSettingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerServiceEnvironmentSettingEditResponseEnvelopeMessages `json:"messages,required"` - Result WorkerServiceEnvironmentSettingEditResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerServiceEnvironmentSettingEditResponseEnvelopeSuccess `json:"success,required"` - JSON workerServiceEnvironmentSettingEditResponseEnvelopeJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseEnvelopeJSON contains the JSON -// metadata for the struct [WorkerServiceEnvironmentSettingEditResponseEnvelope] -type workerServiceEnvironmentSettingEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentSettingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerServiceEnvironmentSettingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseEnvelopeErrors] -type workerServiceEnvironmentSettingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentSettingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerServiceEnvironmentSettingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerServiceEnvironmentSettingEditResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [WorkerServiceEnvironmentSettingEditResponseEnvelopeMessages] -type workerServiceEnvironmentSettingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerServiceEnvironmentSettingEditResponseEnvelopeSuccess bool - -const ( - WorkerServiceEnvironmentSettingEditResponseEnvelopeSuccessTrue WorkerServiceEnvironmentSettingEditResponseEnvelopeSuccess = true -) - -type WorkerServiceEnvironmentSettingGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type WorkerServiceEnvironmentSettingGetResponseEnvelope struct { - Errors []WorkerServiceEnvironmentSettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerServiceEnvironmentSettingGetResponseEnvelopeMessages `json:"messages,required"` - Result WorkerServiceEnvironmentSettingGetResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerServiceEnvironmentSettingGetResponseEnvelopeSuccess `json:"success,required"` - JSON workerServiceEnvironmentSettingGetResponseEnvelopeJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [WorkerServiceEnvironmentSettingGetResponseEnvelope] -type workerServiceEnvironmentSettingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentSettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerServiceEnvironmentSettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseEnvelopeErrors] -type workerServiceEnvironmentSettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerServiceEnvironmentSettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerServiceEnvironmentSettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerServiceEnvironmentSettingGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [WorkerServiceEnvironmentSettingGetResponseEnvelopeMessages] -type workerServiceEnvironmentSettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerServiceEnvironmentSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerServiceEnvironmentSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerServiceEnvironmentSettingGetResponseEnvelopeSuccess bool - -const ( - WorkerServiceEnvironmentSettingGetResponseEnvelopeSuccessTrue WorkerServiceEnvironmentSettingGetResponseEnvelopeSuccess = true -) diff --git a/workerserviceenvironmentsetting_test.go b/workerserviceenvironmentsetting_test.go deleted file mode 100644 index 42400ce7c85..00000000000 --- a/workerserviceenvironmentsetting_test.go +++ /dev/null @@ -1,156 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkerServiceEnvironmentSettingEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Workers.Services.Environments.Settings.Edit( - context.TODO(), - "my-worker", - "production", - cloudflare.WorkerServiceEnvironmentSettingEditParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Errors: cloudflare.F([]cloudflare.WorkerServiceEnvironmentSettingEditParamsError{{ - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }}), - Messages: cloudflare.F([]cloudflare.WorkerServiceEnvironmentSettingEditParamsMessage{{ - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }}), - Result: cloudflare.F(cloudflare.WorkerServiceEnvironmentSettingEditParamsResult{ - Bindings: cloudflare.F([]cloudflare.WorkerServiceEnvironmentSettingEditParamsResultBinding{cloudflare.WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding(cloudflare.WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding{ - Type: cloudflare.F(cloudflare.WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), - }), cloudflare.WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding(cloudflare.WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding{ - Type: cloudflare.F(cloudflare.WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), - }), cloudflare.WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding(cloudflare.WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBinding{ - Type: cloudflare.F(cloudflare.WorkerServiceEnvironmentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), - })}), - CompatibilityDate: cloudflare.F("2022-04-05"), - CompatibilityFlags: cloudflare.F([]string{"formdata_parser_supports_files", "formdata_parser_supports_files", "formdata_parser_supports_files"}), - Logpush: cloudflare.F(false), - Migrations: cloudflare.F[cloudflare.WorkerServiceEnvironmentSettingEditParamsResultMigrations](cloudflare.WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrations(cloudflare.WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrations{ - NewTag: cloudflare.F("v2"), - OldTag: cloudflare.F("v1"), - DeletedClasses: cloudflare.F([]string{"string", "string", "string"}), - NewClasses: cloudflare.F([]string{"string", "string", "string"}), - RenamedClasses: cloudflare.F([]cloudflare.WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass{{ - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }}), - TransferredClasses: cloudflare.F([]cloudflare.WorkerServiceEnvironmentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass{{ - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }}), - })), - Placement: cloudflare.F(cloudflare.WorkerServiceEnvironmentSettingEditParamsResultPlacement{ - Mode: cloudflare.F(cloudflare.WorkerServiceEnvironmentSettingEditParamsResultPlacementModeSmart), - }), - Tags: cloudflare.F([]string{"my-tag", "my-tag", "my-tag"}), - TailConsumers: cloudflare.F([]cloudflare.WorkerServiceEnvironmentSettingEditParamsResultTailConsumer{{ - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }, { - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }, { - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }}), - UsageModel: cloudflare.F("unbound"), - }), - Success: cloudflare.F(cloudflare.WorkerServiceEnvironmentSettingEditParamsSuccessTrue), - }, - ) - 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 TestWorkerServiceEnvironmentSettingGet(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("user@example.com"), - ) - _, err := client.Workers.Services.Environments.Settings.Get( - context.TODO(), - "my-worker", - "production", - cloudflare.WorkerServiceEnvironmentSettingGetParams{ - AccountID: cloudflare.F("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/workersforplatformdispatch.go b/workersforplatformdispatch.go deleted file mode 100644 index 415c8152f80..00000000000 --- a/workersforplatformdispatch.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkersForPlatformDispatchService 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 -// [NewWorkersForPlatformDispatchService] method instead. -type WorkersForPlatformDispatchService struct { - Options []option.RequestOption - Namespaces *WorkersForPlatformDispatchNamespaceService -} - -// NewWorkersForPlatformDispatchService 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 NewWorkersForPlatformDispatchService(opts ...option.RequestOption) (r *WorkersForPlatformDispatchService) { - r = &WorkersForPlatformDispatchService{} - r.Options = opts - r.Namespaces = NewWorkersForPlatformDispatchNamespaceService(opts...) - return -} diff --git a/workersforplatformdispatchnamespace.go b/workersforplatformdispatchnamespace.go deleted file mode 100644 index d973fc18860..00000000000 --- a/workersforplatformdispatchnamespace.go +++ /dev/null @@ -1,28 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkersForPlatformDispatchNamespaceService 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 -// [NewWorkersForPlatformDispatchNamespaceService] method instead. -type WorkersForPlatformDispatchNamespaceService struct { - Options []option.RequestOption - Scripts *WorkersForPlatformDispatchNamespaceScriptService -} - -// NewWorkersForPlatformDispatchNamespaceService 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 NewWorkersForPlatformDispatchNamespaceService(opts ...option.RequestOption) (r *WorkersForPlatformDispatchNamespaceService) { - r = &WorkersForPlatformDispatchNamespaceService{} - r.Options = opts - r.Scripts = NewWorkersForPlatformDispatchNamespaceScriptService(opts...) - return -} diff --git a/workersforplatformdispatchnamespacescript.go b/workersforplatformdispatchnamespacescript.go deleted file mode 100644 index dcadf064479..00000000000 --- a/workersforplatformdispatchnamespacescript.go +++ /dev/null @@ -1,670 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "bytes" - "context" - "fmt" - "io" - "mime/multipart" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apiform" - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkersForPlatformDispatchNamespaceScriptService 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 [NewWorkersForPlatformDispatchNamespaceScriptService] method instead. -type WorkersForPlatformDispatchNamespaceScriptService struct { - Options []option.RequestOption - Content *WorkersForPlatformDispatchNamespaceScriptContentService -} - -// NewWorkersForPlatformDispatchNamespaceScriptService 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 NewWorkersForPlatformDispatchNamespaceScriptService(opts ...option.RequestOption) (r *WorkersForPlatformDispatchNamespaceScriptService) { - r = &WorkersForPlatformDispatchNamespaceScriptService{} - r.Options = opts - r.Content = NewWorkersForPlatformDispatchNamespaceScriptContentService(opts...) - return -} - -// Upload a worker module to a Workers for Platforms namespace. -func (r *WorkersForPlatformDispatchNamespaceScriptService) Update(ctx context.Context, dispatchNamespace string, scriptName string, params WorkersForPlatformDispatchNamespaceScriptUpdateParams, opts ...option.RequestOption) (res *WorkersForPlatformDispatchNamespaceScriptUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkersForPlatformDispatchNamespaceScriptUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s", params.AccountID, dispatchNamespace, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a worker from a Workers for Platforms namespace. This call has no -// response body on a successful delete. -func (r *WorkersForPlatformDispatchNamespaceScriptService) Delete(ctx context.Context, dispatchNamespace string, scriptName string, params WorkersForPlatformDispatchNamespaceScriptDeleteParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s", params.AccountID, dispatchNamespace, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, nil, opts...) - return -} - -// Fetch information about a script uploaded to a Workers for Platforms namespace. -func (r *WorkersForPlatformDispatchNamespaceScriptService) Get(ctx context.Context, dispatchNamespace string, scriptName string, query WorkersForPlatformDispatchNamespaceScriptGetParams, opts ...option.RequestOption) (res *WorkersForPlatformDispatchNamespaceScriptGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkersForPlatformDispatchNamespaceScriptGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s", query.AccountID, dispatchNamespace, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WorkersForPlatformDispatchNamespaceScriptUpdateResponse struct { - // The id of the script in the Workers system. Usually the script name. - ID string `json:"id"` - // When the script was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Hashed script content, can be used in a If-None-Match header when updating. - Etag string `json:"etag"` - // Whether Logpush is turned on for the Worker. - Logpush bool `json:"logpush"` - // When the script was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Deprecated. Deployment metadata for internal usage. - PipelineHash string `json:"pipeline_hash"` - // Specifies the placement mode for the Worker (e.g. 'smart'). - PlacementMode string `json:"placement_mode"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers []WorkersForPlatformDispatchNamespaceScriptUpdateResponseTailConsumer `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel string `json:"usage_model"` - JSON workersForPlatformDispatchNamespaceScriptUpdateResponseJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptUpdateResponseJSON contains the JSON -// metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptUpdateResponse] -type workersForPlatformDispatchNamespaceScriptUpdateResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Etag apijson.Field - Logpush apijson.Field - ModifiedOn apijson.Field - PipelineHash apijson.Field - PlacementMode apijson.Field - TailConsumers apijson.Field - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// A reference to a script that will consume logs from the attached Worker. -type WorkersForPlatformDispatchNamespaceScriptUpdateResponseTailConsumer struct { - // Name of Worker that is to be the consumer. - Service string `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment string `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace string `json:"namespace"` - JSON workersForPlatformDispatchNamespaceScriptUpdateResponseTailConsumerJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptUpdateResponseTailConsumerJSON contains -// the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptUpdateResponseTailConsumer] -type workersForPlatformDispatchNamespaceScriptUpdateResponseTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptUpdateResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptUpdateResponseTailConsumerJSON) RawJSON() string { - return r.raw -} - -// Details about a worker uploaded to a Workers for Platforms namespace. -type WorkersForPlatformDispatchNamespaceScriptGetResponse struct { - // When the script was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Name of the Workers for Platforms dispatch namespace. - DispatchNamespace string `json:"dispatch_namespace"` - // When the script was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - Script WorkersForPlatformDispatchNamespaceScriptGetResponseScript `json:"script"` - JSON workersForPlatformDispatchNamespaceScriptGetResponseJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptGetResponseJSON contains the JSON -// metadata for the struct [WorkersForPlatformDispatchNamespaceScriptGetResponse] -type workersForPlatformDispatchNamespaceScriptGetResponseJSON struct { - CreatedOn apijson.Field - DispatchNamespace apijson.Field - ModifiedOn apijson.Field - Script apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptGetResponseJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptGetResponseScript struct { - // The id of the script in the Workers system. Usually the script name. - ID string `json:"id"` - // When the script was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Hashed script content, can be used in a If-None-Match header when updating. - Etag string `json:"etag"` - // Whether Logpush is turned on for the Worker. - Logpush bool `json:"logpush"` - // When the script was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Deprecated. Deployment metadata for internal usage. - PipelineHash string `json:"pipeline_hash"` - // Specifies the placement mode for the Worker (e.g. 'smart'). - PlacementMode string `json:"placement_mode"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers []WorkersForPlatformDispatchNamespaceScriptGetResponseScriptTailConsumer `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel string `json:"usage_model"` - JSON workersForPlatformDispatchNamespaceScriptGetResponseScriptJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptGetResponseScriptJSON contains the JSON -// metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptGetResponseScript] -type workersForPlatformDispatchNamespaceScriptGetResponseScriptJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Etag apijson.Field - Logpush apijson.Field - ModifiedOn apijson.Field - PipelineHash apijson.Field - PlacementMode apijson.Field - TailConsumers apijson.Field - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptGetResponseScript) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptGetResponseScriptJSON) RawJSON() string { - return r.raw -} - -// A reference to a script that will consume logs from the attached Worker. -type WorkersForPlatformDispatchNamespaceScriptGetResponseScriptTailConsumer struct { - // Name of Worker that is to be the consumer. - Service string `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment string `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace string `json:"namespace"` - JSON workersForPlatformDispatchNamespaceScriptGetResponseScriptTailConsumerJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptGetResponseScriptTailConsumerJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptGetResponseScriptTailConsumer] -type workersForPlatformDispatchNamespaceScriptGetResponseScriptTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptGetResponseScriptTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptGetResponseScriptTailConsumerJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // A module comprising a Worker script, often a javascript file. Multiple modules - // may be provided as separate named parts, but at least one module must be present - // and referenced in the metadata as `main_module` or `body_part` by part name. - AnyPartName param.Field[[]io.Reader] `json:"" format:"binary"` - // Rollback message to be associated with this deployment. Only parsed when query - // param `"rollback_to"` is present. - Message param.Field[string] `json:"message"` - // JSON encoded metadata about the uploaded parts and Worker configuration. - Metadata param.Field[WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadata] `json:"metadata"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptUpdateParams) MarshalMultipart() (data []byte, contentType string, err error) { - buf := bytes.NewBuffer(nil) - writer := multipart.NewWriter(buf) - err = apiform.MarshalRoot(r, writer) - if err != nil { - writer.Close() - return nil, "", err - } - err = writer.Close() - if err != nil { - return nil, "", err - } - return buf.Bytes(), writer.FormDataContentType(), nil -} - -// JSON encoded metadata about the uploaded parts and Worker configuration. -type WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadata struct { - // List of bindings available to the worker. - Bindings param.Field[[]interface{}] `json:"bindings"` - // Name of the part in the multipart request that contains the script (e.g. the - // file adding a listener to the `fetch` event). Indicates a - // `service worker syntax` Worker. - BodyPart param.Field[string] `json:"body_part"` - // Date indicating targeted support in the Workers runtime. Backwards incompatible - // fixes to the runtime following this date will not affect this Worker. - CompatibilityDate param.Field[string] `json:"compatibility_date"` - // Flags that enable or disable certain features in the Workers runtime. Used to - // enable upcoming features or opt in or out of specific changes not included in a - // `compatibility_date`. - CompatibilityFlags param.Field[[]string] `json:"compatibility_flags"` - // List of binding types to keep from previous_upload. - KeepBindings param.Field[[]string] `json:"keep_bindings"` - // Whether Logpush is turned on for the Worker. - Logpush param.Field[bool] `json:"logpush"` - // Name of the part in the multipart request that contains the main module (e.g. - // the file exporting a `fetch` handler). Indicates a `module syntax` Worker. - MainModule param.Field[string] `json:"main_module"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations param.Field[WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrations] `json:"migrations"` - Placement param.Field[WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataPlacement] `json:"placement"` - // List of strings to use as tags for this Worker - Tags param.Field[[]string] `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers param.Field[[]WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataTailConsumer] `json:"tail_consumers"` - // Usage model to apply to invocations. - UsageModel param.Field[WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataUsageModel] `json:"usage_model"` - // Key-value pairs to use as tags for this version of this Worker - VersionTags param.Field[interface{}] `json:"version_tags"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadata) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Satisfied by -// [WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations], -// [WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrations]. -type WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrations interface { - implementsWorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrations() -} - -// A single set of migrations to apply. -type WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag param.Field[string] `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsTransferredClass] `json:"transferred_classes"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations) implementsWorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrations() { -} - -type WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsRenamedClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag param.Field[string] `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // Migrations to apply in order. - Steps param.Field[[]WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStep] `json:"steps"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrations) implementsWorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrations() { -} - -type WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass] `json:"transferred_classes"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStep) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsRenamedClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSteppedMigrationsStepsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataPlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode param.Field[WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataPlacementMode] `json:"mode"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataPlacement) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataPlacementMode string - -const ( - WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataPlacementModeSmart WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataPlacementMode = "smart" -) - -// A reference to a script that will consume logs from the attached Worker. -type WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataTailConsumer struct { - // Name of Worker that is to be the consumer. - Service param.Field[string] `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment param.Field[string] `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace param.Field[string] `json:"namespace"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataTailConsumer) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Usage model to apply to invocations. -type WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataUsageModel string - -const ( - WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataUsageModelBundled WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataUsageModel = "bundled" - WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataUsageModelUnbound WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataUsageModel = "unbound" -) - -type WorkersForPlatformDispatchNamespaceScriptUpdateResponseEnvelope struct { - Errors []WorkersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkersForPlatformDispatchNamespaceScriptUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success WorkersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON workersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeJSON contains the -// JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptUpdateResponseEnvelope] -type workersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeErrorsJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeErrors] -type workersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeMessages] -type workersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeSuccess bool - -const ( - WorkersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeSuccessTrue WorkersForPlatformDispatchNamespaceScriptUpdateResponseEnvelopeSuccess = true -) - -type WorkersForPlatformDispatchNamespaceScriptDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // If set to true, delete will not be stopped by associated service binding, - // durable object, or other binding. Any of these associated bindings/durable - // objects will be deleted along with the script. - Force param.Field[bool] `query:"force"` -} - -// URLQuery serializes [WorkersForPlatformDispatchNamespaceScriptDeleteParams]'s -// query parameters as `url.Values`. -func (r WorkersForPlatformDispatchNamespaceScriptDeleteParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type WorkersForPlatformDispatchNamespaceScriptGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type WorkersForPlatformDispatchNamespaceScriptGetResponseEnvelope struct { - Errors []WorkersForPlatformDispatchNamespaceScriptGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkersForPlatformDispatchNamespaceScriptGetResponseEnvelopeMessages `json:"messages,required"` - // Details about a worker uploaded to a Workers for Platforms namespace. - Result WorkersForPlatformDispatchNamespaceScriptGetResponse `json:"result,required"` - // Whether the API call was successful - Success WorkersForPlatformDispatchNamespaceScriptGetResponseEnvelopeSuccess `json:"success,required"` - JSON workersForPlatformDispatchNamespaceScriptGetResponseEnvelopeJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptGetResponseEnvelopeJSON contains the -// JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptGetResponseEnvelope] -type workersForPlatformDispatchNamespaceScriptGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workersForPlatformDispatchNamespaceScriptGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptGetResponseEnvelopeErrorsJSON contains -// the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptGetResponseEnvelopeErrors] -type workersForPlatformDispatchNamespaceScriptGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workersForPlatformDispatchNamespaceScriptGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptGetResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptGetResponseEnvelopeMessages] -type workersForPlatformDispatchNamespaceScriptGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkersForPlatformDispatchNamespaceScriptGetResponseEnvelopeSuccess bool - -const ( - WorkersForPlatformDispatchNamespaceScriptGetResponseEnvelopeSuccessTrue WorkersForPlatformDispatchNamespaceScriptGetResponseEnvelopeSuccess = true -) diff --git a/workersforplatformdispatchnamespacescript_test.go b/workersforplatformdispatchnamespacescript_test.go deleted file mode 100644 index d2d60db6a6c..00000000000 --- a/workersforplatformdispatchnamespacescript_test.go +++ /dev/null @@ -1,173 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "bytes" - "context" - "errors" - "io" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkersForPlatformDispatchNamespaceScriptUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Update( - context.TODO(), - "my-dispatch-namespace", - "this-is_my_script-01", - cloudflare.WorkersForPlatformDispatchNamespaceScriptUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - AnyPartName: cloudflare.F([]io.Reader{io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents")))}), - Message: cloudflare.F("string"), - Metadata: cloudflare.F(cloudflare.WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadata{ - Bindings: cloudflare.F([]interface{}{map[string]interface{}{ - "name": "MY_ENV_VAR", - "text": "my_data", - "type": "plain_text", - }}), - BodyPart: cloudflare.F("worker.js"), - CompatibilityDate: cloudflare.F("2023-07-25"), - CompatibilityFlags: cloudflare.F([]string{"string", "string", "string"}), - KeepBindings: cloudflare.F([]string{"string", "string", "string"}), - Logpush: cloudflare.F(false), - MainModule: cloudflare.F("worker.js"), - Migrations: cloudflare.F[cloudflare.WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrations](cloudflare.WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations(cloudflare.WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrations{ - NewTag: cloudflare.F("v2"), - OldTag: cloudflare.F("v1"), - DeletedClasses: cloudflare.F([]string{"string", "string", "string"}), - NewClasses: cloudflare.F([]string{"string", "string", "string"}), - RenamedClasses: cloudflare.F([]cloudflare.WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsRenamedClass{{ - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }}), - TransferredClasses: cloudflare.F([]cloudflare.WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataMigrationsWorkersSingleStepMigrationsTransferredClass{{ - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }}), - })), - Placement: cloudflare.F(cloudflare.WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataPlacement{ - Mode: cloudflare.F(cloudflare.WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataPlacementModeSmart), - }), - Tags: cloudflare.F([]string{"string", "string", "string"}), - TailConsumers: cloudflare.F([]cloudflare.WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataTailConsumer{{ - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }, { - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }, { - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }}), - UsageModel: cloudflare.F(cloudflare.WorkersForPlatformDispatchNamespaceScriptUpdateParamsMetadataUsageModelBundled), - VersionTags: cloudflare.F[any](map[string]interface{}{}), - }), - }, - ) - 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 TestWorkersForPlatformDispatchNamespaceScriptDeleteWithOptionalParams(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("user@example.com"), - ) - err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Delete( - context.TODO(), - "my-dispatch-namespace", - "this-is_my_script-01", - cloudflare.WorkersForPlatformDispatchNamespaceScriptDeleteParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Force: cloudflare.F(true), - }, - ) - 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 TestWorkersForPlatformDispatchNamespaceScriptGet(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("user@example.com"), - ) - _, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Get( - context.TODO(), - "my-dispatch-namespace", - "this-is_my_script-01", - cloudflare.WorkersForPlatformDispatchNamespaceScriptGetParams{ - AccountID: cloudflare.F("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/workersforplatformdispatchnamespacescriptcontent.go b/workersforplatformdispatchnamespacescriptcontent.go deleted file mode 100644 index b1fda39a1c7..00000000000 --- a/workersforplatformdispatchnamespacescriptcontent.go +++ /dev/null @@ -1,32 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkersForPlatformDispatchNamespaceScriptContentService 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 [NewWorkersForPlatformDispatchNamespaceScriptContentService] method instead. -type WorkersForPlatformDispatchNamespaceScriptContentService struct { - Options []option.RequestOption - Scripts *WorkersForPlatformDispatchNamespaceScriptContentScriptService - Settings *WorkersForPlatformDispatchNamespaceScriptContentSettingService - Bindings *WorkersForPlatformDispatchNamespaceScriptContentBindingService -} - -// NewWorkersForPlatformDispatchNamespaceScriptContentService 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 NewWorkersForPlatformDispatchNamespaceScriptContentService(opts ...option.RequestOption) (r *WorkersForPlatformDispatchNamespaceScriptContentService) { - r = &WorkersForPlatformDispatchNamespaceScriptContentService{} - r.Options = opts - r.Scripts = NewWorkersForPlatformDispatchNamespaceScriptContentScriptService(opts...) - r.Settings = NewWorkersForPlatformDispatchNamespaceScriptContentSettingService(opts...) - r.Bindings = NewWorkersForPlatformDispatchNamespaceScriptContentBindingService(opts...) - return -} diff --git a/workersforplatformdispatchnamespacescriptcontentbinding.go b/workersforplatformdispatchnamespacescriptcontentbinding.go deleted file mode 100644 index 608a9e20388..00000000000 --- a/workersforplatformdispatchnamespacescriptcontentbinding.go +++ /dev/null @@ -1,490 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// WorkersForPlatformDispatchNamespaceScriptContentBindingService 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 [NewWorkersForPlatformDispatchNamespaceScriptContentBindingService] method -// instead. -type WorkersForPlatformDispatchNamespaceScriptContentBindingService struct { - Options []option.RequestOption -} - -// NewWorkersForPlatformDispatchNamespaceScriptContentBindingService 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 NewWorkersForPlatformDispatchNamespaceScriptContentBindingService(opts ...option.RequestOption) (r *WorkersForPlatformDispatchNamespaceScriptContentBindingService) { - r = &WorkersForPlatformDispatchNamespaceScriptContentBindingService{} - r.Options = opts - return -} - -// Fetch script bindings from a script uploaded to a Workers for Platforms -// namespace. -func (r *WorkersForPlatformDispatchNamespaceScriptContentBindingService) Get(ctx context.Context, dispatchNamespace string, scriptName string, query WorkersForPlatformDispatchNamespaceScriptContentBindingGetParams, opts ...option.RequestOption) (res *WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s/bindings", query.AccountID, dispatchNamespace, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -// A binding to allow the Worker to communicate with resources -// -// Union satisfied by -// [WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBinding], -// [WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersServiceBinding], -// [WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDoBinding], -// [WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersR2Binding], -// [WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersQueueBinding], -// [WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersD1Binding], -// [WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBinding] -// or -// [WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBinding]. -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponse interface { - implementsWorkersForPlatformDispatchNamespaceScriptContentBindingGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersServiceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDoBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersR2Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersQueueBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersD1Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBinding{}), - }, - ) -} - -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBindingType `json:"type,required"` - JSON workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBinding] -type workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBindingJSON struct { - Name apijson.Field - NamespaceID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentBindingGetResponse() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBindingTypeKVNamespace WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersKVNamespaceBindingType = "kv_namespace" -) - -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment string `json:"environment,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of Worker to bind to - Service string `json:"service,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersServiceBindingType `json:"type,required"` - JSON workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersServiceBindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersServiceBindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersServiceBinding] -type workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersServiceBindingJSON struct { - Environment apijson.Field - Name apijson.Field - Service apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersServiceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersServiceBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentBindingGetResponse() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersServiceBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersServiceBindingTypeService WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersServiceBindingType = "service" -) - -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName string `json:"class_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDoBindingType `json:"type,required"` - // The environment of the script_name to bind to - Environment string `json:"environment"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName string `json:"script_name"` - JSON workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDoBindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDoBindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDoBinding] -type workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDoBindingJSON struct { - ClassName apijson.Field - Name apijson.Field - Type apijson.Field - Environment apijson.Field - NamespaceID apijson.Field - ScriptName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDoBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDoBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentBindingGetResponse() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDoBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDoBindingTypeDurableObjectNamespace WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDoBindingType = "durable_object_namespace" -) - -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersR2Binding struct { - // R2 bucket to bind to - BucketName string `json:"bucket_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersR2BindingType `json:"type,required"` - JSON workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersR2BindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersR2BindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersR2Binding] -type workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersR2BindingJSON struct { - BucketName apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersR2BindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersR2Binding) implementsWorkersForPlatformDispatchNamespaceScriptContentBindingGetResponse() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersR2BindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersR2BindingTypeR2Bucket WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersR2BindingType = "r2_bucket" -) - -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersQueueBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of the Queue to bind to - QueueName string `json:"queue_name,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersQueueBindingType `json:"type,required"` - JSON workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersQueueBindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersQueueBindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersQueueBinding] -type workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersQueueBindingJSON struct { - Name apijson.Field - QueueName apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersQueueBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersQueueBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentBindingGetResponse() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersQueueBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersQueueBindingTypeQueue WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersQueueBindingType = "queue" -) - -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersD1Binding struct { - // ID of the D1 database to bind to - ID string `json:"id,required"` - // A JavaScript variable name for the binding. - Binding string `json:"binding,required"` - // The name of the D1 database associated with the 'id' provided. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersD1BindingType `json:"type,required"` - JSON workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersD1BindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersD1BindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersD1Binding] -type workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersD1BindingJSON struct { - ID apijson.Field - Binding apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersD1BindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersD1Binding) implementsWorkersForPlatformDispatchNamespaceScriptContentBindingGetResponse() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersD1BindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersD1BindingTypeD1 WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersD1BindingType = "d1" -) - -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace to bind to - Namespace string `json:"namespace,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingType `json:"type,required"` - // Outbound worker - Outbound WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutbound `json:"outbound"` - JSON workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBinding] -type workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingJSON struct { - Name apijson.Field - Namespace apijson.Field - Type apijson.Field - Outbound apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentBindingGetResponse() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingTypeDispatchNamespace WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -// Outbound worker -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params []string `json:"params"` - // Outbound worker - Worker WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` - JSON workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutbound] -type workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundJSON struct { - Params apijson.Field - Worker apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { - return r.raw -} - -// Outbound worker -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment string `json:"environment"` - // Name of the outbound worker - Service string `json:"service"` - JSON workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorkerJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorker] -type workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { - Environment apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBindingType `json:"type,required"` - // ID of the certificate to bind to - CertificateID string `json:"certificate_id"` - JSON workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBinding] -type workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBindingJSON struct { - Name apijson.Field - Type apijson.Field - CertificateID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentBindingGetResponse() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBindingTypeMTLSCertificate WorkersForPlatformDispatchNamespaceScriptContentBindingGetResponseWorkersMTLSCertBindingType = "mtls_certificate" -) - -type WorkersForPlatformDispatchNamespaceScriptContentBindingGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} diff --git a/workersforplatformdispatchnamespacescriptcontentbinding_test.go b/workersforplatformdispatchnamespacescriptcontentbinding_test.go deleted file mode 100644 index d164c9399ce..00000000000 --- a/workersforplatformdispatchnamespacescriptcontentbinding_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkersForPlatformDispatchNamespaceScriptContentBindingGet(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("user@example.com"), - ) - _, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Bindings.Get( - context.TODO(), - "my-dispatch-namespace", - "this-is_my_script-01", - cloudflare.WorkersForPlatformDispatchNamespaceScriptContentBindingGetParams{ - AccountID: cloudflare.F("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/workersforplatformdispatchnamespacescriptcontentscript.go b/workersforplatformdispatchnamespacescriptcontentscript.go deleted file mode 100644 index cafd2f46cc4..00000000000 --- a/workersforplatformdispatchnamespacescriptcontentscript.go +++ /dev/null @@ -1,273 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "bytes" - "context" - "fmt" - "io" - "mime/multipart" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apiform" - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkersForPlatformDispatchNamespaceScriptContentScriptService 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 [NewWorkersForPlatformDispatchNamespaceScriptContentScriptService] method -// instead. -type WorkersForPlatformDispatchNamespaceScriptContentScriptService struct { - Options []option.RequestOption -} - -// NewWorkersForPlatformDispatchNamespaceScriptContentScriptService 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 NewWorkersForPlatformDispatchNamespaceScriptContentScriptService(opts ...option.RequestOption) (r *WorkersForPlatformDispatchNamespaceScriptContentScriptService) { - r = &WorkersForPlatformDispatchNamespaceScriptContentScriptService{} - r.Options = opts - return -} - -// Put script content for a script uploaded to a Workers for Platforms namespace. -func (r *WorkersForPlatformDispatchNamespaceScriptContentScriptService) Update(ctx context.Context, dispatchNamespace string, scriptName string, params WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateParams, opts ...option.RequestOption) (res *WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s/content", params.AccountID, dispatchNamespace, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch script content from a script uploaded to a Workers for Platforms -// namespace. -func (r *WorkersForPlatformDispatchNamespaceScriptContentScriptService) Get(ctx context.Context, dispatchNamespace string, scriptName string, query WorkersForPlatformDispatchNamespaceScriptContentScriptGetParams, opts ...option.RequestOption) (res *http.Response, err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "string")}, opts...) - path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s/content", query.AccountID, dispatchNamespace, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -type WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponse struct { - // The id of the script in the Workers system. Usually the script name. - ID string `json:"id"` - // When the script was created. - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Hashed script content, can be used in a If-None-Match header when updating. - Etag string `json:"etag"` - // Whether Logpush is turned on for the Worker. - Logpush bool `json:"logpush"` - // When the script was last modified. - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // Deprecated. Deployment metadata for internal usage. - PipelineHash string `json:"pipeline_hash"` - // Specifies the placement mode for the Worker (e.g. 'smart'). - PlacementMode string `json:"placement_mode"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers []WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseTailConsumer `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel string `json:"usage_model"` - JSON workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponse] -type workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseJSON struct { - ID apijson.Field - CreatedOn apijson.Field - Etag apijson.Field - Logpush apijson.Field - ModifiedOn apijson.Field - PipelineHash apijson.Field - PlacementMode apijson.Field - TailConsumers apijson.Field - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// A reference to a script that will consume logs from the attached Worker. -type WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseTailConsumer struct { - // Name of Worker that is to be the consumer. - Service string `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment string `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace string `json:"namespace"` - JSON workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseTailConsumerJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseTailConsumerJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseTailConsumer] -type workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseTailConsumerJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // A module comprising a Worker script, often a javascript file. Multiple modules - // may be provided as separate named parts, but at least one module must be - // present. This should be referenced either in the metadata as `main_module` - // (esm)/`body_part` (service worker) or as a header `CF-WORKER-MAIN-MODULE-PART` - // (esm) /`CF-WORKER-BODY-PART` (service worker) by part name. - AnyPartName param.Field[[]io.Reader] `json:"" format:"binary"` - // JSON encoded metadata about the uploaded parts and Worker configuration. - Metadata param.Field[WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateParamsMetadata] `json:"metadata"` - CfWorkerBodyPart param.Field[string] `header:"CF-WORKER-BODY-PART"` - CfWorkerMainModulePart param.Field[string] `header:"CF-WORKER-MAIN-MODULE-PART"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateParams) MarshalMultipart() (data []byte, contentType string, err error) { - buf := bytes.NewBuffer(nil) - writer := multipart.NewWriter(buf) - err = apiform.MarshalRoot(r, writer) - if err != nil { - writer.Close() - return nil, "", err - } - err = writer.Close() - if err != nil { - return nil, "", err - } - return buf.Bytes(), writer.FormDataContentType(), nil -} - -// JSON encoded metadata about the uploaded parts and Worker configuration. -type WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateParamsMetadata struct { - // Name of the part in the multipart request that contains the script (e.g. the - // file adding a listener to the `fetch` event). Indicates a - // `service worker syntax` Worker. - BodyPart param.Field[string] `json:"body_part"` - // Name of the part in the multipart request that contains the main module (e.g. - // the file exporting a `fetch` handler). Indicates a `module syntax` Worker. - MainModule param.Field[string] `json:"main_module"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateParamsMetadata) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelope struct { - Errors []WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelope] -type workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeErrorsJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeErrors] -type workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeMessages] -type workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeSuccess bool - -const ( - WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeSuccessTrue WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateResponseEnvelopeSuccess = true -) - -type WorkersForPlatformDispatchNamespaceScriptContentScriptGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} diff --git a/workersforplatformdispatchnamespacescriptcontentscript_test.go b/workersforplatformdispatchnamespacescriptcontentscript_test.go deleted file mode 100644 index f87d27690f0..00000000000 --- a/workersforplatformdispatchnamespacescriptcontentscript_test.go +++ /dev/null @@ -1,99 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "bytes" - "context" - "errors" - "io" - "net/http" - "net/http/httptest" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkersForPlatformDispatchNamespaceScriptContentScriptUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Scripts.Update( - context.TODO(), - "my-dispatch-namespace", - "this-is_my_script-01", - cloudflare.WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - AnyPartName: cloudflare.F([]io.Reader{io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents"))), io.Reader(bytes.NewBuffer([]byte("some file contents")))}), - Metadata: cloudflare.F(cloudflare.WorkersForPlatformDispatchNamespaceScriptContentScriptUpdateParamsMetadata{ - BodyPart: cloudflare.F("worker.js"), - MainModule: cloudflare.F("worker.js"), - }), - CfWorkerBodyPart: cloudflare.F("string"), - CfWorkerMainModulePart: cloudflare.F("string"), - }, - ) - 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 TestWorkersForPlatformDispatchNamespaceScriptContentScriptGet(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - w.Write([]byte("abc")) - })) - defer server.Close() - baseURL := server.URL - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - resp, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Scripts.Get( - context.TODO(), - "my-dispatch-namespace", - "this-is_my_script-01", - cloudflare.WorkersForPlatformDispatchNamespaceScriptContentScriptGetParams{ - AccountID: cloudflare.F("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()) - } - defer resp.Body.Close() - - b, err := io.ReadAll(resp.Body) - 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()) - } - if !bytes.Equal(b, []byte("abc")) { - t.Fatalf("return value not %s: %s", "abc", b) - } -} diff --git a/workersforplatformdispatchnamespacescriptcontentsetting.go b/workersforplatformdispatchnamespacescriptcontentsetting.go deleted file mode 100644 index 75c05bd3112..00000000000 --- a/workersforplatformdispatchnamespacescriptcontentsetting.go +++ /dev/null @@ -1,2223 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// WorkersForPlatformDispatchNamespaceScriptContentSettingService 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 [NewWorkersForPlatformDispatchNamespaceScriptContentSettingService] method -// instead. -type WorkersForPlatformDispatchNamespaceScriptContentSettingService struct { - Options []option.RequestOption -} - -// NewWorkersForPlatformDispatchNamespaceScriptContentSettingService 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 NewWorkersForPlatformDispatchNamespaceScriptContentSettingService(opts ...option.RequestOption) (r *WorkersForPlatformDispatchNamespaceScriptContentSettingService) { - r = &WorkersForPlatformDispatchNamespaceScriptContentSettingService{} - r.Options = opts - return -} - -// Patch script metadata, such as bindings -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingService) Edit(ctx context.Context, dispatchNamespace string, scriptName string, params WorkersForPlatformDispatchNamespaceScriptContentSettingEditParams, opts ...option.RequestOption) (res *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s/settings", params.AccountID, dispatchNamespace, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get script settings from a script uploaded to a Workers for Platforms namespace. -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingService) Get(ctx context.Context, dispatchNamespace string, scriptName string, query WorkersForPlatformDispatchNamespaceScriptContentSettingGetParams, opts ...option.RequestOption) (res *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/dispatch/namespaces/%s/scripts/%s/settings", query.AccountID, dispatchNamespace, scriptName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponse struct { - // List of bindings attached to this Worker - Bindings []WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBinding `json:"bindings"` - // Opt your Worker into changes after this date - CompatibilityDate string `json:"compatibility_date"` - // Opt your Worker into specific changes - CompatibilityFlags []string `json:"compatibility_flags"` - // Whether Logpush is turned on for the Worker. - Logpush bool `json:"logpush"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrations `json:"migrations"` - Placement WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponsePlacement `json:"placement"` - // Tags to help you manage your Workers - Tags []string `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers []WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseTailConsumer `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel string `json:"usage_model"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseJSON contains -// the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponse] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseJSON struct { - Bindings apijson.Field - CompatibilityDate apijson.Field - CompatibilityFlags apijson.Field - Logpush apijson.Field - Migrations apijson.Field - Placement apijson.Field - Tags apijson.Field - TailConsumers apijson.Field - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseJSON) RawJSON() string { - return r.raw -} - -// A binding to allow the Worker to communicate with resources -// -// Union satisfied by -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBinding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBinding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBinding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2Binding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBinding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1Binding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBinding] -// or -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBinding]. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBinding interface { - implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBinding() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBinding)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBinding{}), - }, - ) -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBindingType `json:"type,required"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBinding] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON struct { - Name apijson.Field - NamespaceID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersKVNamespaceBindingType = "kv_namespace" -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment string `json:"environment,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of Worker to bind to - Service string `json:"service,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBindingType `json:"type,required"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBinding] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBindingJSON struct { - Environment apijson.Field - Name apijson.Field - Service apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBindingTypeService WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersServiceBindingType = "service" -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName string `json:"class_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBindingType `json:"type,required"` - // The environment of the script_name to bind to - Environment string `json:"environment"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName string `json:"script_name"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBinding] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBindingJSON struct { - ClassName apijson.Field - Name apijson.Field - Type apijson.Field - Environment apijson.Field - NamespaceID apijson.Field - ScriptName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBindingTypeDurableObjectNamespace WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDoBindingType = "durable_object_namespace" -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2Binding struct { - // R2 bucket to bind to - BucketName string `json:"bucket_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2BindingType `json:"type,required"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2BindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2BindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2Binding] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2BindingJSON struct { - BucketName apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2BindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2Binding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2BindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2BindingTypeR2Bucket WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersR2BindingType = "r2_bucket" -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of the Queue to bind to - QueueName string `json:"queue_name,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBindingType `json:"type,required"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBinding] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBindingJSON struct { - Name apijson.Field - QueueName apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBindingTypeQueue WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersQueueBindingType = "queue" -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1Binding struct { - // ID of the D1 database to bind to - ID string `json:"id,required"` - // A JavaScript variable name for the binding. - Binding string `json:"binding,required"` - // The name of the D1 database associated with the 'id' provided. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1BindingType `json:"type,required"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1BindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1BindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1Binding] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1BindingJSON struct { - ID apijson.Field - Binding apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1BindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1Binding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1BindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1BindingTypeD1 WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersD1BindingType = "d1" -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace to bind to - Namespace string `json:"namespace,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingType `json:"type,required"` - // Outbound worker - Outbound WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound `json:"outbound"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBinding] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON struct { - Name apijson.Field - Namespace apijson.Field - Type apijson.Field - Outbound apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -// Outbound worker -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params []string `json:"params"` - // Outbound worker - Worker WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON struct { - Params apijson.Field - Worker apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { - return r.raw -} - -// Outbound worker -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment string `json:"environment"` - // Name of the outbound worker - Service string `json:"service"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { - Environment apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBindingType `json:"type,required"` - // ID of the certificate to bind to - CertificateID string `json:"certificate_id"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBinding] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBindingJSON struct { - Name apijson.Field - Type apijson.Field - CertificateID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBindingTypeMTLSCertificate WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseBindingsWorkersMTLSCertBindingType = "mtls_certificate" -) - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Union satisfied by -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrations] -// or -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrations]. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrations interface { - implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrations() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrations)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrations{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrations{}), - }, - ) -} - -// A single set of migrations to apply. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass `json:"transferred_classes"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrations] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - NewTag apijson.Field - OldTag apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrations) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrations() { -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // Migrations to apply in order. - Steps []WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStep `json:"steps"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrations] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON struct { - NewTag apijson.Field - OldTag apijson.Field - Steps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrations) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrations() { -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass `json:"transferred_classes"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStep] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStep) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponsePlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponsePlacementMode `json:"mode"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponsePlacementJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponsePlacementJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponsePlacement] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponsePlacementJSON struct { - Mode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponsePlacement) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponsePlacementJSON) RawJSON() string { - return r.raw -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponsePlacementMode string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponsePlacementModeSmart WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponsePlacementMode = "smart" -) - -// A reference to a script that will consume logs from the attached Worker. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseTailConsumer struct { - // Name of Worker that is to be the consumer. - Service string `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment string `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace string `json:"namespace"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseTailConsumerJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseTailConsumerJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseTailConsumer] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseTailConsumerJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponse struct { - // List of bindings attached to this Worker - Bindings []WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBinding `json:"bindings"` - // Opt your Worker into changes after this date - CompatibilityDate string `json:"compatibility_date"` - // Opt your Worker into specific changes - CompatibilityFlags []string `json:"compatibility_flags"` - // Whether Logpush is turned on for the Worker. - Logpush bool `json:"logpush"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrations `json:"migrations"` - Placement WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponsePlacement `json:"placement"` - // Tags to help you manage your Workers - Tags []string `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers []WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseTailConsumer `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel string `json:"usage_model"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseJSON contains -// the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponse] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseJSON struct { - Bindings apijson.Field - CompatibilityDate apijson.Field - CompatibilityFlags apijson.Field - Logpush apijson.Field - Migrations apijson.Field - Placement apijson.Field - Tags apijson.Field - TailConsumers apijson.Field - UsageModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseJSON) RawJSON() string { - return r.raw -} - -// A binding to allow the Worker to communicate with resources -// -// Union satisfied by -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBinding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBinding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBinding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2Binding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBinding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1Binding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBinding] -// or -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBinding]. -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBinding interface { - implementsWorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBinding() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBinding)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1Binding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBinding{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBinding{}), - }, - ) -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBindingType `json:"type,required"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBinding] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON struct { - Name apijson.Field - NamespaceID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBindingTypeKVNamespace WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersKVNamespaceBindingType = "kv_namespace" -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment string `json:"environment,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of Worker to bind to - Service string `json:"service,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBindingType `json:"type,required"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBinding] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBindingJSON struct { - Environment apijson.Field - Name apijson.Field - Service apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBindingTypeService WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersServiceBindingType = "service" -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName string `json:"class_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBindingType `json:"type,required"` - // The environment of the script_name to bind to - Environment string `json:"environment"` - // Namespace identifier tag. - NamespaceID string `json:"namespace_id"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName string `json:"script_name"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBinding] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBindingJSON struct { - ClassName apijson.Field - Name apijson.Field - Type apijson.Field - Environment apijson.Field - NamespaceID apijson.Field - ScriptName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBindingTypeDurableObjectNamespace WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDoBindingType = "durable_object_namespace" -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2Binding struct { - // R2 bucket to bind to - BucketName string `json:"bucket_name,required"` - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2BindingType `json:"type,required"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2BindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2BindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2Binding] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2BindingJSON struct { - BucketName apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2BindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2Binding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2BindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2BindingTypeR2Bucket WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersR2BindingType = "r2_bucket" -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Name of the Queue to bind to - QueueName string `json:"queue_name,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBindingType `json:"type,required"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBinding] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBindingJSON struct { - Name apijson.Field - QueueName apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBindingTypeQueue WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersQueueBindingType = "queue" -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1Binding struct { - // ID of the D1 database to bind to - ID string `json:"id,required"` - // A JavaScript variable name for the binding. - Binding string `json:"binding,required"` - // The name of the D1 database associated with the 'id' provided. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1BindingType `json:"type,required"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1BindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1BindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1Binding] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1BindingJSON struct { - ID apijson.Field - Binding apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1Binding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1BindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1Binding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1BindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1BindingTypeD1 WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersD1BindingType = "d1" -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // Namespace to bind to - Namespace string `json:"namespace,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingType `json:"type,required"` - // Outbound worker - Outbound WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound `json:"outbound"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBinding] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON struct { - Name apijson.Field - Namespace apijson.Field - Type apijson.Field - Outbound apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -// Outbound worker -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params []string `json:"params"` - // Outbound worker - Worker WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker `json:"worker"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON struct { - Params apijson.Field - Worker apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutbound) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundJSON) RawJSON() string { - return r.raw -} - -// Outbound worker -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment string `json:"environment"` - // Name of the outbound worker - Service string `json:"service"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON struct { - Environment apijson.Field - Service apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorker) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersDispatchNamespaceBindingOutboundWorkerJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBinding struct { - // A JavaScript variable name for the binding. - Name string `json:"name,required"` - // The class of resource that the binding provides. - Type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBindingType `json:"type,required"` - // ID of the certificate to bind to - CertificateID string `json:"certificate_id"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBindingJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBindingJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBinding] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBindingJSON struct { - Name apijson.Field - Type apijson.Field - CertificateID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBinding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBindingJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBindingTypeMTLSCertificate WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseBindingsWorkersMTLSCertBindingType = "mtls_certificate" -) - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Union satisfied by -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrations] -// or -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrations]. -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrations interface { - implementsWorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrations() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrations)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrations{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrations{}), - }, - ) -} - -// A single set of migrations to apply. -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass `json:"transferred_classes"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrations] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - NewTag apijson.Field - OldTag apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrations) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrations() { -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSingleStepMigrationsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag string `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag string `json:"old_tag"` - // Migrations to apply in order. - Steps []WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStep `json:"steps"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrations] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON struct { - NewTag apijson.Field - OldTag apijson.Field - Steps apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrations) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsJSON) RawJSON() string { - return r.raw -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrations) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrations() { -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses []string `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses []string `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses []WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses []WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass `json:"transferred_classes"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStep] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON struct { - DeletedClasses apijson.Field - NewClasses apijson.Field - RenamedClasses apijson.Field - TransferredClasses apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStep) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From string `json:"from"` - To string `json:"to"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON struct { - From apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsRenamedClassJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From string `json:"from"` - FromScript string `json:"from_script"` - To string `json:"to"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON struct { - From apijson.Field - FromScript apijson.Field - To apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClass) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseMigrationsWorkersSteppedMigrationsStepsTransferredClassJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponsePlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponsePlacementMode `json:"mode"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponsePlacementJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponsePlacementJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponsePlacement] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponsePlacementJSON struct { - Mode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponsePlacement) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponsePlacementJSON) RawJSON() string { - return r.raw -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponsePlacementMode string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponsePlacementModeSmart WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponsePlacementMode = "smart" -) - -// A reference to a script that will consume logs from the attached Worker. -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseTailConsumer struct { - // Name of Worker that is to be the consumer. - Service string `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment string `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace string `json:"namespace"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseTailConsumerJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseTailConsumerJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseTailConsumer] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseTailConsumerJSON struct { - Service apijson.Field - Environment apijson.Field - Namespace apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseTailConsumer) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseTailConsumerJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Errors param.Field[[]WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsError] `json:"errors,required"` - Messages param.Field[[]WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsMessage] `json:"messages,required"` - Result param.Field[WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResult] `json:"result,required"` - // Whether the API call was successful - Success param.Field[WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsSuccess] `json:"success,required"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsError struct { - Code param.Field[int64] `json:"code,required"` - Message param.Field[string] `json:"message,required"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsError) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsMessage struct { - Code param.Field[int64] `json:"code,required"` - Message param.Field[string] `json:"message,required"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsMessage) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResult struct { - // List of bindings attached to this Worker - Bindings param.Field[[]WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBinding] `json:"bindings"` - // Opt your Worker into changes after this date - CompatibilityDate param.Field[string] `json:"compatibility_date"` - // Opt your Worker into specific changes - CompatibilityFlags param.Field[[]string] `json:"compatibility_flags"` - // Whether Logpush is turned on for the Worker. - Logpush param.Field[bool] `json:"logpush"` - // Migrations to apply for Durable Objects associated with this Worker. - Migrations param.Field[WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrations] `json:"migrations"` - Placement param.Field[WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultPlacement] `json:"placement"` - // Tags to help you manage your Workers - Tags param.Field[[]string] `json:"tags"` - // List of Workers that will consume logs from the attached Worker. - TailConsumers param.Field[[]WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultTailConsumer] `json:"tail_consumers"` - // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). - UsageModel param.Field[string] `json:"usage_model"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResult) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A binding to allow the Worker to communicate with resources -// -// Satisfied by -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersServiceBinding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDoBinding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersR2Binding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersQueueBinding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersD1Binding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersMTLSCertBinding]. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBinding interface { - implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBinding() -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding struct { - // The class of resource that the binding provides. - Type param.Field[WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBindingType] `json:"type,required"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBindingType = "kv_namespace" -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersServiceBinding struct { - // Optional environment if the Worker utilizes one. - Environment param.Field[string] `json:"environment,required"` - // Name of Worker to bind to - Service param.Field[string] `json:"service,required"` - // The class of resource that the binding provides. - Type param.Field[WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersServiceBindingType] `json:"type,required"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersServiceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersServiceBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersServiceBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersServiceBindingTypeService WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersServiceBindingType = "service" -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDoBinding struct { - // The exported class name of the Durable Object - ClassName param.Field[string] `json:"class_name,required"` - // The class of resource that the binding provides. - Type param.Field[WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDoBindingType] `json:"type,required"` - // The environment of the script_name to bind to - Environment param.Field[string] `json:"environment"` - // The script where the Durable Object is defined, if it is external to this Worker - ScriptName param.Field[string] `json:"script_name"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDoBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDoBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDoBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDoBindingTypeDurableObjectNamespace WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDoBindingType = "durable_object_namespace" -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersR2Binding struct { - // R2 bucket to bind to - BucketName param.Field[string] `json:"bucket_name,required"` - // The class of resource that the binding provides. - Type param.Field[WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersR2BindingType] `json:"type,required"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersR2Binding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersR2Binding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersR2BindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersR2BindingTypeR2Bucket WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersR2BindingType = "r2_bucket" -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersQueueBinding struct { - // Name of the Queue to bind to - QueueName param.Field[string] `json:"queue_name,required"` - // The class of resource that the binding provides. - Type param.Field[WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersQueueBindingType] `json:"type,required"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersQueueBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersQueueBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersQueueBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersQueueBindingTypeQueue WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersQueueBindingType = "queue" -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersD1Binding struct { - // ID of the D1 database to bind to - ID param.Field[string] `json:"id,required"` - // The name of the D1 database associated with the 'id' provided. - Name param.Field[string] `json:"name,required"` - // The class of resource that the binding provides. - Type param.Field[WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersD1BindingType] `json:"type,required"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersD1Binding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersD1Binding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersD1BindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersD1BindingTypeD1 WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersD1BindingType = "d1" -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding struct { - // Namespace to bind to - Namespace param.Field[string] `json:"namespace,required"` - // The class of resource that the binding provides. - Type param.Field[WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType] `json:"type,required"` - // Outbound worker - Outbound param.Field[WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutbound] `json:"outbound"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingTypeDispatchNamespace WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingType = "dispatch_namespace" -) - -// Outbound worker -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutbound struct { - // Pass information from the Dispatch Worker to the Outbound Worker through the - // parameters - Params param.Field[[]string] `json:"params"` - // Outbound worker - Worker param.Field[WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker] `json:"worker"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutbound) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Outbound worker -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker struct { - // Environment of the outbound worker - Environment param.Field[string] `json:"environment"` - // Name of the outbound worker - Service param.Field[string] `json:"service"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersDispatchNamespaceBindingOutboundWorker) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersMTLSCertBinding struct { - // The class of resource that the binding provides. - Type param.Field[WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersMTLSCertBindingType] `json:"type,required"` - // ID of the certificate to bind to - CertificateID param.Field[string] `json:"certificate_id"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersMTLSCertBinding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersMTLSCertBinding) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBinding() { -} - -// The class of resource that the binding provides. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersMTLSCertBindingType string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersMTLSCertBindingTypeMTLSCertificate WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersMTLSCertBindingType = "mtls_certificate" -) - -// Migrations to apply for Durable Objects associated with this Worker. -// -// Satisfied by -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrations], -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrations]. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrations interface { - implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrations() -} - -// A single set of migrations to apply. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrations struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` - // Tag to set as the latest migration tag. - NewTag param.Field[string] `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass] `json:"transferred_classes"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrations) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrations() { -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrations struct { - // Tag to set as the latest migration tag. - NewTag param.Field[string] `json:"new_tag"` - // Tag used to verify against the latest migration tag for this Worker. If they - // don't match, the upload is rejected. - OldTag param.Field[string] `json:"old_tag"` - // Migrations to apply in order. - Steps param.Field[[]WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStep] `json:"steps"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrations) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrations) implementsWorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrations() { -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStep struct { - // A list of classes to delete Durable Object namespaces from. - DeletedClasses param.Field[[]string] `json:"deleted_classes"` - // A list of classes to create Durable Object namespaces from. - NewClasses param.Field[[]string] `json:"new_classes"` - // A list of classes with Durable Object namespaces that were renamed. - RenamedClasses param.Field[[]WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass] `json:"renamed_classes"` - // A list of transfers for Durable Object namespaces from a different Worker and - // class to a class defined in this Worker. - TransferredClasses param.Field[[]WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass] `json:"transferred_classes"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStep) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass struct { - From param.Field[string] `json:"from"` - To param.Field[string] `json:"to"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsRenamedClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass struct { - From param.Field[string] `json:"from"` - FromScript param.Field[string] `json:"from_script"` - To param.Field[string] `json:"to"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSteppedMigrationsStepsTransferredClass) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultPlacement struct { - // Enables - // [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). - // Only `"smart"` is currently supported - Mode param.Field[WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultPlacementMode] `json:"mode"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultPlacement) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enables -// [Smart Placement](https://developers.cloudflare.com/workers/configuration/smart-placement). -// Only `"smart"` is currently supported -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultPlacementMode string - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultPlacementModeSmart WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultPlacementMode = "smart" -) - -// A reference to a script that will consume logs from the attached Worker. -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultTailConsumer struct { - // Name of Worker that is to be the consumer. - Service param.Field[string] `json:"service,required"` - // Optional environment if the Worker utilizes one. - Environment param.Field[string] `json:"environment"` - // Optional dispatch namespace the script belongs to. - Namespace param.Field[string] `json:"namespace"` -} - -func (r WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultTailConsumer) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Whether the API call was successful -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsSuccess bool - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsSuccessTrue WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsSuccess = true -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelope struct { - Errors []WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeMessages `json:"messages,required"` - Result WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponse `json:"result,required"` - // Whether the API call was successful - Success WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeSuccess `json:"success,required"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelope] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeErrorsJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeErrors] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeMessages] -type workersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeSuccess bool - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeSuccessTrue WorkersForPlatformDispatchNamespaceScriptContentSettingEditResponseEnvelopeSuccess = true -) - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelope struct { - Errors []WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeMessages `json:"messages,required"` - Result WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponse `json:"result,required"` - // Whether the API call was successful - Success WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeSuccess `json:"success,required"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelope] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeErrorsJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeErrors] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// workersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeMessages] -type workersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeSuccess bool - -const ( - WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeSuccessTrue WorkersForPlatformDispatchNamespaceScriptContentSettingGetResponseEnvelopeSuccess = true -) diff --git a/workersforplatformdispatchnamespacescriptcontentsetting_test.go b/workersforplatformdispatchnamespacescriptcontentsetting_test.go deleted file mode 100644 index 5750488fd43..00000000000 --- a/workersforplatformdispatchnamespacescriptcontentsetting_test.go +++ /dev/null @@ -1,156 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkersForPlatformDispatchNamespaceScriptContentSettingEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Settings.Edit( - context.TODO(), - "my-dispatch-namespace", - "this-is_my_script-01", - cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Errors: cloudflare.F([]cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsError{{ - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }}), - Messages: cloudflare.F([]cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsMessage{{ - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }, { - Code: cloudflare.F(int64(1000)), - Message: cloudflare.F("string"), - }}), - Result: cloudflare.F(cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResult{ - Bindings: cloudflare.F([]cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBinding{cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding(cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding{ - Type: cloudflare.F(cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), - }), cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding(cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding{ - Type: cloudflare.F(cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), - }), cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding(cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBinding{ - Type: cloudflare.F(cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultBindingsWorkersKVNamespaceBindingTypeKVNamespace), - })}), - CompatibilityDate: cloudflare.F("2022-04-05"), - CompatibilityFlags: cloudflare.F([]string{"formdata_parser_supports_files", "formdata_parser_supports_files", "formdata_parser_supports_files"}), - Logpush: cloudflare.F(false), - Migrations: cloudflare.F[cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrations](cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrations(cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrations{ - NewTag: cloudflare.F("v2"), - OldTag: cloudflare.F("v1"), - DeletedClasses: cloudflare.F([]string{"string", "string", "string"}), - NewClasses: cloudflare.F([]string{"string", "string", "string"}), - RenamedClasses: cloudflare.F([]cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsRenamedClass{{ - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - To: cloudflare.F("string"), - }}), - TransferredClasses: cloudflare.F([]cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultMigrationsWorkersSingleStepMigrationsTransferredClass{{ - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }, { - From: cloudflare.F("string"), - FromScript: cloudflare.F("string"), - To: cloudflare.F("string"), - }}), - })), - Placement: cloudflare.F(cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultPlacement{ - Mode: cloudflare.F(cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultPlacementModeSmart), - }), - Tags: cloudflare.F([]string{"my-tag", "my-tag", "my-tag"}), - TailConsumers: cloudflare.F([]cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsResultTailConsumer{{ - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }, { - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }, { - Environment: cloudflare.F("production"), - Namespace: cloudflare.F("my-namespace"), - Service: cloudflare.F("my-log-consumer"), - }}), - UsageModel: cloudflare.F("unbound"), - }), - Success: cloudflare.F(cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingEditParamsSuccessTrue), - }, - ) - 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 TestWorkersForPlatformDispatchNamespaceScriptContentSettingGet(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("user@example.com"), - ) - _, err := client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Content.Settings.Get( - context.TODO(), - "my-dispatch-namespace", - "this-is_my_script-01", - cloudflare.WorkersForPlatformDispatchNamespaceScriptContentSettingGetParams{ - AccountID: cloudflare.F("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/workersubdomain.go b/workersubdomain.go deleted file mode 100644 index 9029dd54671..00000000000 --- a/workersubdomain.go +++ /dev/null @@ -1,277 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// WorkerSubdomainService 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 [NewWorkerSubdomainService] method -// instead. -type WorkerSubdomainService struct { - Options []option.RequestOption -} - -// NewWorkerSubdomainService 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 NewWorkerSubdomainService(opts ...option.RequestOption) (r *WorkerSubdomainService) { - r = &WorkerSubdomainService{} - r.Options = opts - return -} - -// Creates a Workers subdomain for an account. -func (r *WorkerSubdomainService) Update(ctx context.Context, params WorkerSubdomainUpdateParams, opts ...option.RequestOption) (res *WorkerSubdomainUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerSubdomainUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/subdomain", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Returns a Workers subdomain for an account. -func (r *WorkerSubdomainService) Get(ctx context.Context, query WorkerSubdomainGetParams, opts ...option.RequestOption) (res *WorkerSubdomainGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env WorkerSubdomainGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/workers/subdomain", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type WorkerSubdomainUpdateResponse struct { - Name interface{} `json:"name"` - JSON workerSubdomainUpdateResponseJSON `json:"-"` -} - -// workerSubdomainUpdateResponseJSON contains the JSON metadata for the struct -// [WorkerSubdomainUpdateResponse] -type workerSubdomainUpdateResponseJSON struct { - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerSubdomainUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerSubdomainUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerSubdomainGetResponse struct { - Name interface{} `json:"name"` - JSON workerSubdomainGetResponseJSON `json:"-"` -} - -// workerSubdomainGetResponseJSON contains the JSON metadata for the struct -// [WorkerSubdomainGetResponse] -type workerSubdomainGetResponseJSON struct { - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerSubdomainGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerSubdomainGetResponseJSON) RawJSON() string { - return r.raw -} - -type WorkerSubdomainUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` -} - -func (r WorkerSubdomainUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type WorkerSubdomainUpdateResponseEnvelope struct { - Errors []WorkerSubdomainUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerSubdomainUpdateResponseEnvelopeMessages `json:"messages,required"` - Result WorkerSubdomainUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerSubdomainUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON workerSubdomainUpdateResponseEnvelopeJSON `json:"-"` -} - -// workerSubdomainUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [WorkerSubdomainUpdateResponseEnvelope] -type workerSubdomainUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerSubdomainUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerSubdomainUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerSubdomainUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerSubdomainUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerSubdomainUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [WorkerSubdomainUpdateResponseEnvelopeErrors] -type workerSubdomainUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerSubdomainUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerSubdomainUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerSubdomainUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerSubdomainUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerSubdomainUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WorkerSubdomainUpdateResponseEnvelopeMessages] -type workerSubdomainUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerSubdomainUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerSubdomainUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerSubdomainUpdateResponseEnvelopeSuccess bool - -const ( - WorkerSubdomainUpdateResponseEnvelopeSuccessTrue WorkerSubdomainUpdateResponseEnvelopeSuccess = true -) - -type WorkerSubdomainGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type WorkerSubdomainGetResponseEnvelope struct { - Errors []WorkerSubdomainGetResponseEnvelopeErrors `json:"errors,required"` - Messages []WorkerSubdomainGetResponseEnvelopeMessages `json:"messages,required"` - Result WorkerSubdomainGetResponse `json:"result,required"` - // Whether the API call was successful - Success WorkerSubdomainGetResponseEnvelopeSuccess `json:"success,required"` - JSON workerSubdomainGetResponseEnvelopeJSON `json:"-"` -} - -// workerSubdomainGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [WorkerSubdomainGetResponseEnvelope] -type workerSubdomainGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerSubdomainGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerSubdomainGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type WorkerSubdomainGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerSubdomainGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// workerSubdomainGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [WorkerSubdomainGetResponseEnvelopeErrors] -type workerSubdomainGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerSubdomainGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerSubdomainGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type WorkerSubdomainGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON workerSubdomainGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// workerSubdomainGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [WorkerSubdomainGetResponseEnvelopeMessages] -type workerSubdomainGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *WorkerSubdomainGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r workerSubdomainGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type WorkerSubdomainGetResponseEnvelopeSuccess bool - -const ( - WorkerSubdomainGetResponseEnvelopeSuccessTrue WorkerSubdomainGetResponseEnvelopeSuccess = true -) diff --git a/workersubdomain_test.go b/workersubdomain_test.go deleted file mode 100644 index e81ecc7ebf3..00000000000 --- a/workersubdomain_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestWorkerSubdomainUpdate(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("user@example.com"), - ) - _, err := client.Workers.Subdomains.Update(context.TODO(), cloudflare.WorkerSubdomainUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Body: cloudflare.F[any]("{'subdomain': 'example-subdomain'}"), - }) - 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 TestWorkerSubdomainGet(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("user@example.com"), - ) - _, err := client.Workers.Subdomains.Get(context.TODO(), cloudflare.WorkerSubdomainGetParams{ - AccountID: cloudflare.F("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/zero_trust/access.go b/zero_trust/access.go new file mode 100644 index 00000000000..506ce30b247 --- /dev/null +++ b/zero_trust/access.go @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// AccessService 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 [NewAccessService] method instead. +type AccessService struct { + Options []option.RequestOption + Applications *AccessApplicationService + Certificates *AccessCertificateService + Groups *AccessGroupService + ServiceTokens *AccessServiceTokenService + Bookmarks *AccessBookmarkService + Keys *AccessKeyService + Logs *AccessLogService + Users *AccessUserService + CustomPages *AccessCustomPageService + Tags *AccessTagService +} + +// NewAccessService 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 NewAccessService(opts ...option.RequestOption) (r *AccessService) { + r = &AccessService{} + r.Options = opts + r.Applications = NewAccessApplicationService(opts...) + r.Certificates = NewAccessCertificateService(opts...) + r.Groups = NewAccessGroupService(opts...) + r.ServiceTokens = NewAccessServiceTokenService(opts...) + r.Bookmarks = NewAccessBookmarkService(opts...) + r.Keys = NewAccessKeyService(opts...) + r.Logs = NewAccessLogService(opts...) + r.Users = NewAccessUserService(opts...) + r.CustomPages = NewAccessCustomPageService(opts...) + r.Tags = NewAccessTagService(opts...) + return +} diff --git a/zero_trust/accessapplication.go b/zero_trust/accessapplication.go new file mode 100644 index 00000000000..f8c6c0d2572 --- /dev/null +++ b/zero_trust/accessapplication.go @@ -0,0 +1,2338 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// AccessApplicationService 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 [NewAccessApplicationService] method +// instead. +type AccessApplicationService struct { + Options []option.RequestOption + CAs *AccessApplicationCAService + UserPolicyChecks *AccessApplicationUserPolicyCheckService + Policies *AccessApplicationPolicyService +} + +// NewAccessApplicationService 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 NewAccessApplicationService(opts ...option.RequestOption) (r *AccessApplicationService) { + r = &AccessApplicationService{} + r.Options = opts + r.CAs = NewAccessApplicationCAService(opts...) + r.UserPolicyChecks = NewAccessApplicationUserPolicyCheckService(opts...) + r.Policies = NewAccessApplicationPolicyService(opts...) + return +} + +// Adds a new application to Access. +func (r *AccessApplicationService) New(ctx context.Context, params AccessApplicationNewParams, opts ...option.RequestOption) (res *AccessApps, err error) { + opts = append(r.Options[:], opts...) + var env AccessApplicationNewResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/access/apps", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates an Access application. +func (r *AccessApplicationService) Update(ctx context.Context, appID AccessApplicationUpdateParamsAppID, params AccessApplicationUpdateParams, opts ...option.RequestOption) (res *AccessApps, err error) { + opts = append(r.Options[:], opts...) + var env AccessApplicationUpdateResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/access/apps/%v", accountOrZone, accountOrZoneID, appID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists all Access applications in an account or zone. +func (r *AccessApplicationService) List(ctx context.Context, query AccessApplicationListParams, opts ...option.RequestOption) (res *[]AccessApps, err error) { + opts = append(r.Options[:], opts...) + var env AccessApplicationListResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/access/apps", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes an application from Access. +func (r *AccessApplicationService) Delete(ctx context.Context, appID AccessApplicationDeleteParamsAppID, body AccessApplicationDeleteParams, opts ...option.RequestOption) (res *AccessApplicationDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessApplicationDeleteResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if body.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = body.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = body.ZoneID + } + path := fmt.Sprintf("%s/%s/access/apps/%v", accountOrZone, accountOrZoneID, appID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches information about an Access application. +func (r *AccessApplicationService) Get(ctx context.Context, appID AccessApplicationGetParamsAppID, query AccessApplicationGetParams, opts ...option.RequestOption) (res *AccessApps, err error) { + opts = append(r.Options[:], opts...) + var env AccessApplicationGetResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/access/apps/%v", accountOrZone, accountOrZoneID, appID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Revokes all tokens issued for an application. +func (r *AccessApplicationService) RevokeTokens(ctx context.Context, appID AccessApplicationRevokeTokensParamsAppID, body AccessApplicationRevokeTokensParams, opts ...option.RequestOption) (res *AccessApplicationRevokeTokensResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessApplicationRevokeTokensResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if body.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = body.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = body.ZoneID + } + path := fmt.Sprintf("%s/%s/access/apps/%v/revoke_tokens", accountOrZone, accountOrZoneID, appID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [zero_trust.AccessAppsSelfHostedApplication], +// [zero_trust.AccessAppsSaaSApplication], +// [zero_trust.AccessAppsBrowserSSHApplication], +// [zero_trust.AccessAppsBrowserVncApplication], +// [zero_trust.AccessAppsAppLauncherApplication], +// [zero_trust.AccessAppsDeviceEnrollmentPermissionsApplication], +// [zero_trust.AccessAppsBrowserIsolationPermissionsApplication] or +// [zero_trust.AccessAppsBookmarkApplication]. +type AccessApps interface { + implementsZeroTrustAccessApps() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessApps)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessAppsSelfHostedApplication{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessAppsSaaSApplication{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessAppsBrowserSSHApplication{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessAppsBrowserVncApplication{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessAppsAppLauncherApplication{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessAppsDeviceEnrollmentPermissionsApplication{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessAppsBrowserIsolationPermissionsApplication{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessAppsBookmarkApplication{}), + }, + ) +} + +type AccessAppsSelfHostedApplication struct { + // The primary hostname and path that Access will secure. If the app is visible in + // the App Launcher dashboard, this is the domain that will be displayed. + Domain string `json:"domain,required"` + // The application type. + Type string `json:"type,required"` + // UUID + ID string `json:"id"` + // When set to true, users can authenticate to this application using their WARP + // session. When set to false this application will always require direct IdP + // authentication. This setting always overrides the organization setting for WARP + // authentication. + AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` + // The identity providers your users can select when connecting to this + // application. Defaults to all IdPs configured in your account. + AllowedIdps []string `json:"allowed_idps"` + // Displays the application in the App Launcher. + AppLauncherVisible bool `json:"app_launcher_visible"` + // Audience tag. + Aud string `json:"aud"` + // When set to `true`, users skip the identity provider selection step during + // login. You must specify only one identity provider in allowed_idps. + AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` + CorsHeaders AccessAppsSelfHostedApplicationCorsHeaders `json:"cors_headers"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The custom error message shown to a user when they are denied access to the + // application. + CustomDenyMessage string `json:"custom_deny_message"` + // The custom URL a user is redirected to when they are denied access to the + // application when failing identity-based rules. + CustomDenyURL string `json:"custom_deny_url"` + // The custom URL a user is redirected to when they are denied access to the + // application when failing non-identity rules. + CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` + // The custom pages that will be displayed when applicable for this application + CustomPages []string `json:"custom_pages"` + // Enables the binding cookie, which increases security against compromised + // authorization tokens and CSRF attacks. + EnableBindingCookie bool `json:"enable_binding_cookie"` + // Enables the HttpOnly cookie attribute, which increases security against XSS + // attacks. + HTTPOnlyCookieAttribute bool `json:"http_only_cookie_attribute"` + // The image URL for the logo shown in the App Launcher dashboard. + LogoURL string `json:"logo_url"` + // The name of the application. + Name string `json:"name"` + // Enables cookie paths to scope an application's JWT to the application path. If + // disabled, the JWT will scope to the hostname by default + PathCookieAttribute bool `json:"path_cookie_attribute"` + // Sets the SameSite cookie setting, which provides increased security against CSRF + // attacks. + SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` + // List of domains that Access will secure. + SelfHostedDomains []string `json:"self_hosted_domains"` + // Returns a 401 status code when the request is blocked by a Service Auth policy. + ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` + // The amount of time that tokens issued for this application will be valid. Must + // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, + // s, m, h. + SessionDuration string `json:"session_duration"` + // Enables automatic authentication through cloudflared. + SkipInterstitial bool `json:"skip_interstitial"` + // The tags you want assigned to an application. Tags are used to filter + // applications in the App Launcher dashboard. + Tags []string `json:"tags"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessAppsSelfHostedApplicationJSON `json:"-"` +} + +// accessAppsSelfHostedApplicationJSON contains the JSON metadata for the struct +// [AccessAppsSelfHostedApplication] +type accessAppsSelfHostedApplicationJSON struct { + Domain apijson.Field + Type apijson.Field + ID apijson.Field + AllowAuthenticateViaWARP apijson.Field + AllowedIdps apijson.Field + AppLauncherVisible apijson.Field + Aud apijson.Field + AutoRedirectToIdentity apijson.Field + CorsHeaders apijson.Field + CreatedAt apijson.Field + CustomDenyMessage apijson.Field + CustomDenyURL apijson.Field + CustomNonIdentityDenyURL apijson.Field + CustomPages apijson.Field + EnableBindingCookie apijson.Field + HTTPOnlyCookieAttribute apijson.Field + LogoURL apijson.Field + Name apijson.Field + PathCookieAttribute apijson.Field + SameSiteCookieAttribute apijson.Field + SelfHostedDomains apijson.Field + ServiceAuth401Redirect apijson.Field + SessionDuration apijson.Field + SkipInterstitial apijson.Field + Tags apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessAppsSelfHostedApplication) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessAppsSelfHostedApplicationJSON) RawJSON() string { + return r.raw +} + +func (r AccessAppsSelfHostedApplication) implementsZeroTrustAccessApps() {} + +type AccessAppsSelfHostedApplicationCorsHeaders struct { + // Allows all HTTP request headers. + AllowAllHeaders bool `json:"allow_all_headers"` + // Allows all HTTP request methods. + AllowAllMethods bool `json:"allow_all_methods"` + // Allows all origins. + AllowAllOrigins bool `json:"allow_all_origins"` + // When set to `true`, includes credentials (cookies, authorization headers, or TLS + // client certificates) with requests. + AllowCredentials bool `json:"allow_credentials"` + // Allowed HTTP request headers. + AllowedHeaders []interface{} `json:"allowed_headers"` + // Allowed HTTP request methods. + AllowedMethods []AccessAppsSelfHostedApplicationCorsHeadersAllowedMethod `json:"allowed_methods"` + // Allowed origins. + AllowedOrigins []interface{} `json:"allowed_origins"` + // The maximum number of seconds the results of a preflight request can be cached. + MaxAge float64 `json:"max_age"` + JSON accessAppsSelfHostedApplicationCorsHeadersJSON `json:"-"` +} + +// accessAppsSelfHostedApplicationCorsHeadersJSON contains the JSON metadata for +// the struct [AccessAppsSelfHostedApplicationCorsHeaders] +type accessAppsSelfHostedApplicationCorsHeadersJSON struct { + AllowAllHeaders apijson.Field + AllowAllMethods apijson.Field + AllowAllOrigins apijson.Field + AllowCredentials apijson.Field + AllowedHeaders apijson.Field + AllowedMethods apijson.Field + AllowedOrigins apijson.Field + MaxAge apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessAppsSelfHostedApplicationCorsHeaders) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessAppsSelfHostedApplicationCorsHeadersJSON) RawJSON() string { + return r.raw +} + +type AccessAppsSelfHostedApplicationCorsHeadersAllowedMethod string + +const ( + AccessAppsSelfHostedApplicationCorsHeadersAllowedMethodGet AccessAppsSelfHostedApplicationCorsHeadersAllowedMethod = "GET" + AccessAppsSelfHostedApplicationCorsHeadersAllowedMethodPost AccessAppsSelfHostedApplicationCorsHeadersAllowedMethod = "POST" + AccessAppsSelfHostedApplicationCorsHeadersAllowedMethodHead AccessAppsSelfHostedApplicationCorsHeadersAllowedMethod = "HEAD" + AccessAppsSelfHostedApplicationCorsHeadersAllowedMethodPut AccessAppsSelfHostedApplicationCorsHeadersAllowedMethod = "PUT" + AccessAppsSelfHostedApplicationCorsHeadersAllowedMethodDelete AccessAppsSelfHostedApplicationCorsHeadersAllowedMethod = "DELETE" + AccessAppsSelfHostedApplicationCorsHeadersAllowedMethodConnect AccessAppsSelfHostedApplicationCorsHeadersAllowedMethod = "CONNECT" + AccessAppsSelfHostedApplicationCorsHeadersAllowedMethodOptions AccessAppsSelfHostedApplicationCorsHeadersAllowedMethod = "OPTIONS" + AccessAppsSelfHostedApplicationCorsHeadersAllowedMethodTrace AccessAppsSelfHostedApplicationCorsHeadersAllowedMethod = "TRACE" + AccessAppsSelfHostedApplicationCorsHeadersAllowedMethodPatch AccessAppsSelfHostedApplicationCorsHeadersAllowedMethod = "PATCH" +) + +type AccessAppsSaaSApplication struct { + // UUID + ID string `json:"id"` + // The identity providers your users can select when connecting to this + // application. Defaults to all IdPs configured in your account. + AllowedIdps []string `json:"allowed_idps"` + // Displays the application in the App Launcher. + AppLauncherVisible bool `json:"app_launcher_visible"` + // Audience tag. + Aud string `json:"aud"` + // When set to `true`, users skip the identity provider selection step during + // login. You must specify only one identity provider in allowed_idps. + AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The custom pages that will be displayed when applicable for this application + CustomPages []string `json:"custom_pages"` + // The image URL for the logo shown in the App Launcher dashboard. + LogoURL string `json:"logo_url"` + // The name of the application. + Name string `json:"name"` + SaasApp AccessAppsSaaSApplicationSaasApp `json:"saas_app"` + // The tags you want assigned to an application. Tags are used to filter + // applications in the App Launcher dashboard. + Tags []string `json:"tags"` + // The application type. + Type string `json:"type"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessAppsSaaSApplicationJSON `json:"-"` +} + +// accessAppsSaaSApplicationJSON contains the JSON metadata for the struct +// [AccessAppsSaaSApplication] +type accessAppsSaaSApplicationJSON struct { + ID apijson.Field + AllowedIdps apijson.Field + AppLauncherVisible apijson.Field + Aud apijson.Field + AutoRedirectToIdentity apijson.Field + CreatedAt apijson.Field + CustomPages apijson.Field + LogoURL apijson.Field + Name apijson.Field + SaasApp apijson.Field + Tags apijson.Field + Type apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessAppsSaaSApplication) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessAppsSaaSApplicationJSON) RawJSON() string { + return r.raw +} + +func (r AccessAppsSaaSApplication) implementsZeroTrustAccessApps() {} + +// Union satisfied by +// [zero_trust.AccessAppsSaaSApplicationSaasAppAccessSamlSaasApp] or +// [zero_trust.AccessAppsSaaSApplicationSaasAppAccessOidcSaasApp]. +type AccessAppsSaaSApplicationSaasApp interface { + implementsZeroTrustAccessAppsSaaSApplicationSaasApp() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessAppsSaaSApplicationSaasApp)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessAppsSaaSApplicationSaasAppAccessSamlSaasApp{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessAppsSaaSApplicationSaasAppAccessOidcSaasApp{}), + }, + ) +} + +type AccessAppsSaaSApplicationSaasAppAccessSamlSaasApp struct { + // Optional identifier indicating the authentication protocol used for the saas + // app. Required for OIDC. Default if unset is "saml" + AuthType AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppAuthType `json:"auth_type"` + // The service provider's endpoint that is responsible for receiving and parsing a + // SAML assertion. + ConsumerServiceURL string `json:"consumer_service_url"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + CustomAttributes AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes `json:"custom_attributes"` + // The URL that the user will be redirected to after a successful login for IDP + // initiated logins. + DefaultRelayState string `json:"default_relay_state"` + // The unique identifier for your SaaS application. + IdpEntityID string `json:"idp_entity_id"` + // The format of the name identifier sent to the SaaS application. + NameIDFormat AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat `json:"name_id_format"` + // A [JSONata](https://jsonata.org/) expression that transforms an application's + // user identities into a NameID value for its SAML assertion. This expression + // should evaluate to a singular string. The output of this expression can override + // the `name_id_format` setting. + NameIDTransformJsonata string `json:"name_id_transform_jsonata"` + // The Access public certificate that will be used to verify your identity. + PublicKey string `json:"public_key"` + // A globally unique name for an identity or service provider. + SpEntityID string `json:"sp_entity_id"` + // The endpoint where your SaaS application will send login requests. + SSOEndpoint string `json:"sso_endpoint"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessAppsSaaSApplicationSaasAppAccessSamlSaasAppJSON `json:"-"` +} + +// accessAppsSaaSApplicationSaasAppAccessSamlSaasAppJSON contains the JSON metadata +// for the struct [AccessAppsSaaSApplicationSaasAppAccessSamlSaasApp] +type accessAppsSaaSApplicationSaasAppAccessSamlSaasAppJSON struct { + AuthType apijson.Field + ConsumerServiceURL apijson.Field + CreatedAt apijson.Field + CustomAttributes apijson.Field + DefaultRelayState apijson.Field + IdpEntityID apijson.Field + NameIDFormat apijson.Field + NameIDTransformJsonata apijson.Field + PublicKey apijson.Field + SpEntityID apijson.Field + SSOEndpoint apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessAppsSaaSApplicationSaasAppAccessSamlSaasApp) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessAppsSaaSApplicationSaasAppAccessSamlSaasAppJSON) RawJSON() string { + return r.raw +} + +func (r AccessAppsSaaSApplicationSaasAppAccessSamlSaasApp) implementsZeroTrustAccessAppsSaaSApplicationSaasApp() { +} + +// Optional identifier indicating the authentication protocol used for the saas +// app. Required for OIDC. Default if unset is "saml" +type AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppAuthType string + +const ( + AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeSaml AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppAuthType = "saml" + AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeOidc AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppAuthType = "oidc" +) + +type AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes struct { + // The name of the attribute. + Name string `json:"name"` + // A globally unique name for an identity or service provider. + NameFormat AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat `json:"name_format"` + Source AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource `json:"source"` + JSON accessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON `json:"-"` +} + +// accessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON contains +// the JSON metadata for the struct +// [AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes] +type accessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON struct { + Name apijson.Field + NameFormat apijson.Field + Source apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON) RawJSON() string { + return r.raw +} + +// A globally unique name for an identity or service provider. +type AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat string + +const ( + AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatUnspecified AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" + AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic" + AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatURI AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" +) + +type AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource struct { + // The name of the IdP attribute. + Name string `json:"name"` + JSON accessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON `json:"-"` +} + +// accessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON +// contains the JSON metadata for the struct +// [AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource] +type accessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON struct { + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessAppsSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON) RawJSON() string { + return r.raw +} + +// The format of the name identifier sent to the SaaS application. +type AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat string + +const ( + AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatID AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat = "id" + AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatEmail AccessAppsSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat = "email" +) + +type AccessAppsSaaSApplicationSaasAppAccessOidcSaasApp struct { + // The URL where this applications tile redirects users + AppLauncherURL string `json:"app_launcher_url"` + // Identifier of the authentication protocol used for the saas app. Required for + // OIDC. + AuthType AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppAuthType `json:"auth_type"` + // The application client id + ClientID string `json:"client_id"` + // The application client secret, only returned on POST request. + ClientSecret string `json:"client_secret"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The OIDC flows supported by this application + GrantTypes []AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppGrantType `json:"grant_types"` + // A regex to filter Cloudflare groups returned in ID token and userinfo endpoint + GroupFilterRegex string `json:"group_filter_regex"` + // The Access public certificate that will be used to verify your identity. + PublicKey string `json:"public_key"` + // The permitted URL's for Cloudflare to return Authorization codes and Access/ID + // tokens + RedirectURIs []string `json:"redirect_uris"` + // Define the user information shared with access + Scopes []AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppScope `json:"scopes"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessAppsSaaSApplicationSaasAppAccessOidcSaasAppJSON `json:"-"` +} + +// accessAppsSaaSApplicationSaasAppAccessOidcSaasAppJSON contains the JSON metadata +// for the struct [AccessAppsSaaSApplicationSaasAppAccessOidcSaasApp] +type accessAppsSaaSApplicationSaasAppAccessOidcSaasAppJSON struct { + AppLauncherURL apijson.Field + AuthType apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + CreatedAt apijson.Field + GrantTypes apijson.Field + GroupFilterRegex apijson.Field + PublicKey apijson.Field + RedirectURIs apijson.Field + Scopes apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessAppsSaaSApplicationSaasAppAccessOidcSaasApp) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessAppsSaaSApplicationSaasAppAccessOidcSaasAppJSON) RawJSON() string { + return r.raw +} + +func (r AccessAppsSaaSApplicationSaasAppAccessOidcSaasApp) implementsZeroTrustAccessAppsSaaSApplicationSaasApp() { +} + +// Identifier of the authentication protocol used for the saas app. Required for +// OIDC. +type AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppAuthType string + +const ( + AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeSaml AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppAuthType = "saml" + AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeOidc AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppAuthType = "oidc" +) + +type AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppGrantType string + +const ( + AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCode AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppGrantType = "authorization_code" + AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCodeWithPkce AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppGrantType = "authorization_code_with_pkce" +) + +type AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppScope string + +const ( + AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppScopeOpenid AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppScope = "openid" + AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppScopeGroups AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppScope = "groups" + AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppScopeEmail AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppScope = "email" + AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppScopeProfile AccessAppsSaaSApplicationSaasAppAccessOidcSaasAppScope = "profile" +) + +type AccessAppsBrowserSSHApplication struct { + // The primary hostname and path that Access will secure. If the app is visible in + // the App Launcher dashboard, this is the domain that will be displayed. + Domain string `json:"domain,required"` + // The application type. + Type string `json:"type,required"` + // UUID + ID string `json:"id"` + // When set to true, users can authenticate to this application using their WARP + // session. When set to false this application will always require direct IdP + // authentication. This setting always overrides the organization setting for WARP + // authentication. + AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` + // The identity providers your users can select when connecting to this + // application. Defaults to all IdPs configured in your account. + AllowedIdps []string `json:"allowed_idps"` + // Displays the application in the App Launcher. + AppLauncherVisible bool `json:"app_launcher_visible"` + // Audience tag. + Aud string `json:"aud"` + // When set to `true`, users skip the identity provider selection step during + // login. You must specify only one identity provider in allowed_idps. + AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` + CorsHeaders AccessAppsBrowserSSHApplicationCorsHeaders `json:"cors_headers"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The custom error message shown to a user when they are denied access to the + // application. + CustomDenyMessage string `json:"custom_deny_message"` + // The custom URL a user is redirected to when they are denied access to the + // application when failing identity-based rules. + CustomDenyURL string `json:"custom_deny_url"` + // The custom URL a user is redirected to when they are denied access to the + // application when failing non-identity rules. + CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` + // The custom pages that will be displayed when applicable for this application + CustomPages []string `json:"custom_pages"` + // Enables the binding cookie, which increases security against compromised + // authorization tokens and CSRF attacks. + EnableBindingCookie bool `json:"enable_binding_cookie"` + // Enables the HttpOnly cookie attribute, which increases security against XSS + // attacks. + HTTPOnlyCookieAttribute bool `json:"http_only_cookie_attribute"` + // The image URL for the logo shown in the App Launcher dashboard. + LogoURL string `json:"logo_url"` + // The name of the application. + Name string `json:"name"` + // Enables cookie paths to scope an application's JWT to the application path. If + // disabled, the JWT will scope to the hostname by default + PathCookieAttribute bool `json:"path_cookie_attribute"` + // Sets the SameSite cookie setting, which provides increased security against CSRF + // attacks. + SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` + // List of domains that Access will secure. + SelfHostedDomains []string `json:"self_hosted_domains"` + // Returns a 401 status code when the request is blocked by a Service Auth policy. + ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` + // The amount of time that tokens issued for this application will be valid. Must + // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, + // s, m, h. + SessionDuration string `json:"session_duration"` + // Enables automatic authentication through cloudflared. + SkipInterstitial bool `json:"skip_interstitial"` + // The tags you want assigned to an application. Tags are used to filter + // applications in the App Launcher dashboard. + Tags []string `json:"tags"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessAppsBrowserSSHApplicationJSON `json:"-"` +} + +// accessAppsBrowserSSHApplicationJSON contains the JSON metadata for the struct +// [AccessAppsBrowserSSHApplication] +type accessAppsBrowserSSHApplicationJSON struct { + Domain apijson.Field + Type apijson.Field + ID apijson.Field + AllowAuthenticateViaWARP apijson.Field + AllowedIdps apijson.Field + AppLauncherVisible apijson.Field + Aud apijson.Field + AutoRedirectToIdentity apijson.Field + CorsHeaders apijson.Field + CreatedAt apijson.Field + CustomDenyMessage apijson.Field + CustomDenyURL apijson.Field + CustomNonIdentityDenyURL apijson.Field + CustomPages apijson.Field + EnableBindingCookie apijson.Field + HTTPOnlyCookieAttribute apijson.Field + LogoURL apijson.Field + Name apijson.Field + PathCookieAttribute apijson.Field + SameSiteCookieAttribute apijson.Field + SelfHostedDomains apijson.Field + ServiceAuth401Redirect apijson.Field + SessionDuration apijson.Field + SkipInterstitial apijson.Field + Tags apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessAppsBrowserSSHApplication) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessAppsBrowserSSHApplicationJSON) RawJSON() string { + return r.raw +} + +func (r AccessAppsBrowserSSHApplication) implementsZeroTrustAccessApps() {} + +type AccessAppsBrowserSSHApplicationCorsHeaders struct { + // Allows all HTTP request headers. + AllowAllHeaders bool `json:"allow_all_headers"` + // Allows all HTTP request methods. + AllowAllMethods bool `json:"allow_all_methods"` + // Allows all origins. + AllowAllOrigins bool `json:"allow_all_origins"` + // When set to `true`, includes credentials (cookies, authorization headers, or TLS + // client certificates) with requests. + AllowCredentials bool `json:"allow_credentials"` + // Allowed HTTP request headers. + AllowedHeaders []interface{} `json:"allowed_headers"` + // Allowed HTTP request methods. + AllowedMethods []AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethod `json:"allowed_methods"` + // Allowed origins. + AllowedOrigins []interface{} `json:"allowed_origins"` + // The maximum number of seconds the results of a preflight request can be cached. + MaxAge float64 `json:"max_age"` + JSON accessAppsBrowserSSHApplicationCorsHeadersJSON `json:"-"` +} + +// accessAppsBrowserSSHApplicationCorsHeadersJSON contains the JSON metadata for +// the struct [AccessAppsBrowserSSHApplicationCorsHeaders] +type accessAppsBrowserSSHApplicationCorsHeadersJSON struct { + AllowAllHeaders apijson.Field + AllowAllMethods apijson.Field + AllowAllOrigins apijson.Field + AllowCredentials apijson.Field + AllowedHeaders apijson.Field + AllowedMethods apijson.Field + AllowedOrigins apijson.Field + MaxAge apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessAppsBrowserSSHApplicationCorsHeaders) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessAppsBrowserSSHApplicationCorsHeadersJSON) RawJSON() string { + return r.raw +} + +type AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethod string + +const ( + AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethodGet AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethod = "GET" + AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethodPost AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethod = "POST" + AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethodHead AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethod = "HEAD" + AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethodPut AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethod = "PUT" + AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethodDelete AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethod = "DELETE" + AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethodConnect AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethod = "CONNECT" + AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethodOptions AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethod = "OPTIONS" + AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethodTrace AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethod = "TRACE" + AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethodPatch AccessAppsBrowserSSHApplicationCorsHeadersAllowedMethod = "PATCH" +) + +type AccessAppsBrowserVncApplication struct { + // The primary hostname and path that Access will secure. If the app is visible in + // the App Launcher dashboard, this is the domain that will be displayed. + Domain string `json:"domain,required"` + // The application type. + Type string `json:"type,required"` + // UUID + ID string `json:"id"` + // When set to true, users can authenticate to this application using their WARP + // session. When set to false this application will always require direct IdP + // authentication. This setting always overrides the organization setting for WARP + // authentication. + AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` + // The identity providers your users can select when connecting to this + // application. Defaults to all IdPs configured in your account. + AllowedIdps []string `json:"allowed_idps"` + // Displays the application in the App Launcher. + AppLauncherVisible bool `json:"app_launcher_visible"` + // Audience tag. + Aud string `json:"aud"` + // When set to `true`, users skip the identity provider selection step during + // login. You must specify only one identity provider in allowed_idps. + AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` + CorsHeaders AccessAppsBrowserVncApplicationCorsHeaders `json:"cors_headers"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The custom error message shown to a user when they are denied access to the + // application. + CustomDenyMessage string `json:"custom_deny_message"` + // The custom URL a user is redirected to when they are denied access to the + // application when failing identity-based rules. + CustomDenyURL string `json:"custom_deny_url"` + // The custom URL a user is redirected to when they are denied access to the + // application when failing non-identity rules. + CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` + // The custom pages that will be displayed when applicable for this application + CustomPages []string `json:"custom_pages"` + // Enables the binding cookie, which increases security against compromised + // authorization tokens and CSRF attacks. + EnableBindingCookie bool `json:"enable_binding_cookie"` + // Enables the HttpOnly cookie attribute, which increases security against XSS + // attacks. + HTTPOnlyCookieAttribute bool `json:"http_only_cookie_attribute"` + // The image URL for the logo shown in the App Launcher dashboard. + LogoURL string `json:"logo_url"` + // The name of the application. + Name string `json:"name"` + // Enables cookie paths to scope an application's JWT to the application path. If + // disabled, the JWT will scope to the hostname by default + PathCookieAttribute bool `json:"path_cookie_attribute"` + // Sets the SameSite cookie setting, which provides increased security against CSRF + // attacks. + SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` + // List of domains that Access will secure. + SelfHostedDomains []string `json:"self_hosted_domains"` + // Returns a 401 status code when the request is blocked by a Service Auth policy. + ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` + // The amount of time that tokens issued for this application will be valid. Must + // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, + // s, m, h. + SessionDuration string `json:"session_duration"` + // Enables automatic authentication through cloudflared. + SkipInterstitial bool `json:"skip_interstitial"` + // The tags you want assigned to an application. Tags are used to filter + // applications in the App Launcher dashboard. + Tags []string `json:"tags"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessAppsBrowserVncApplicationJSON `json:"-"` +} + +// accessAppsBrowserVncApplicationJSON contains the JSON metadata for the struct +// [AccessAppsBrowserVncApplication] +type accessAppsBrowserVncApplicationJSON struct { + Domain apijson.Field + Type apijson.Field + ID apijson.Field + AllowAuthenticateViaWARP apijson.Field + AllowedIdps apijson.Field + AppLauncherVisible apijson.Field + Aud apijson.Field + AutoRedirectToIdentity apijson.Field + CorsHeaders apijson.Field + CreatedAt apijson.Field + CustomDenyMessage apijson.Field + CustomDenyURL apijson.Field + CustomNonIdentityDenyURL apijson.Field + CustomPages apijson.Field + EnableBindingCookie apijson.Field + HTTPOnlyCookieAttribute apijson.Field + LogoURL apijson.Field + Name apijson.Field + PathCookieAttribute apijson.Field + SameSiteCookieAttribute apijson.Field + SelfHostedDomains apijson.Field + ServiceAuth401Redirect apijson.Field + SessionDuration apijson.Field + SkipInterstitial apijson.Field + Tags apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessAppsBrowserVncApplication) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessAppsBrowserVncApplicationJSON) RawJSON() string { + return r.raw +} + +func (r AccessAppsBrowserVncApplication) implementsZeroTrustAccessApps() {} + +type AccessAppsBrowserVncApplicationCorsHeaders struct { + // Allows all HTTP request headers. + AllowAllHeaders bool `json:"allow_all_headers"` + // Allows all HTTP request methods. + AllowAllMethods bool `json:"allow_all_methods"` + // Allows all origins. + AllowAllOrigins bool `json:"allow_all_origins"` + // When set to `true`, includes credentials (cookies, authorization headers, or TLS + // client certificates) with requests. + AllowCredentials bool `json:"allow_credentials"` + // Allowed HTTP request headers. + AllowedHeaders []interface{} `json:"allowed_headers"` + // Allowed HTTP request methods. + AllowedMethods []AccessAppsBrowserVncApplicationCorsHeadersAllowedMethod `json:"allowed_methods"` + // Allowed origins. + AllowedOrigins []interface{} `json:"allowed_origins"` + // The maximum number of seconds the results of a preflight request can be cached. + MaxAge float64 `json:"max_age"` + JSON accessAppsBrowserVncApplicationCorsHeadersJSON `json:"-"` +} + +// accessAppsBrowserVncApplicationCorsHeadersJSON contains the JSON metadata for +// the struct [AccessAppsBrowserVncApplicationCorsHeaders] +type accessAppsBrowserVncApplicationCorsHeadersJSON struct { + AllowAllHeaders apijson.Field + AllowAllMethods apijson.Field + AllowAllOrigins apijson.Field + AllowCredentials apijson.Field + AllowedHeaders apijson.Field + AllowedMethods apijson.Field + AllowedOrigins apijson.Field + MaxAge apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessAppsBrowserVncApplicationCorsHeaders) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessAppsBrowserVncApplicationCorsHeadersJSON) RawJSON() string { + return r.raw +} + +type AccessAppsBrowserVncApplicationCorsHeadersAllowedMethod string + +const ( + AccessAppsBrowserVncApplicationCorsHeadersAllowedMethodGet AccessAppsBrowserVncApplicationCorsHeadersAllowedMethod = "GET" + AccessAppsBrowserVncApplicationCorsHeadersAllowedMethodPost AccessAppsBrowserVncApplicationCorsHeadersAllowedMethod = "POST" + AccessAppsBrowserVncApplicationCorsHeadersAllowedMethodHead AccessAppsBrowserVncApplicationCorsHeadersAllowedMethod = "HEAD" + AccessAppsBrowserVncApplicationCorsHeadersAllowedMethodPut AccessAppsBrowserVncApplicationCorsHeadersAllowedMethod = "PUT" + AccessAppsBrowserVncApplicationCorsHeadersAllowedMethodDelete AccessAppsBrowserVncApplicationCorsHeadersAllowedMethod = "DELETE" + AccessAppsBrowserVncApplicationCorsHeadersAllowedMethodConnect AccessAppsBrowserVncApplicationCorsHeadersAllowedMethod = "CONNECT" + AccessAppsBrowserVncApplicationCorsHeadersAllowedMethodOptions AccessAppsBrowserVncApplicationCorsHeadersAllowedMethod = "OPTIONS" + AccessAppsBrowserVncApplicationCorsHeadersAllowedMethodTrace AccessAppsBrowserVncApplicationCorsHeadersAllowedMethod = "TRACE" + AccessAppsBrowserVncApplicationCorsHeadersAllowedMethodPatch AccessAppsBrowserVncApplicationCorsHeadersAllowedMethod = "PATCH" +) + +type AccessAppsAppLauncherApplication struct { + // The application type. + Type AccessAppsAppLauncherApplicationType `json:"type,required"` + // UUID + ID string `json:"id"` + // The identity providers your users can select when connecting to this + // application. Defaults to all IdPs configured in your account. + AllowedIdps []string `json:"allowed_idps"` + // Audience tag. + Aud string `json:"aud"` + // When set to `true`, users skip the identity provider selection step during + // login. You must specify only one identity provider in allowed_idps. + AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The primary hostname and path that Access will secure. If the app is visible in + // the App Launcher dashboard, this is the domain that will be displayed. + Domain string `json:"domain"` + // The name of the application. + Name string `json:"name"` + // The amount of time that tokens issued for this application will be valid. Must + // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, + // s, m, h. + SessionDuration string `json:"session_duration"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessAppsAppLauncherApplicationJSON `json:"-"` +} + +// accessAppsAppLauncherApplicationJSON contains the JSON metadata for the struct +// [AccessAppsAppLauncherApplication] +type accessAppsAppLauncherApplicationJSON struct { + Type apijson.Field + ID apijson.Field + AllowedIdps apijson.Field + Aud apijson.Field + AutoRedirectToIdentity apijson.Field + CreatedAt apijson.Field + Domain apijson.Field + Name apijson.Field + SessionDuration apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessAppsAppLauncherApplication) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessAppsAppLauncherApplicationJSON) RawJSON() string { + return r.raw +} + +func (r AccessAppsAppLauncherApplication) implementsZeroTrustAccessApps() {} + +// The application type. +type AccessAppsAppLauncherApplicationType string + +const ( + AccessAppsAppLauncherApplicationTypeSelfHosted AccessAppsAppLauncherApplicationType = "self_hosted" + AccessAppsAppLauncherApplicationTypeSaas AccessAppsAppLauncherApplicationType = "saas" + AccessAppsAppLauncherApplicationTypeSSH AccessAppsAppLauncherApplicationType = "ssh" + AccessAppsAppLauncherApplicationTypeVnc AccessAppsAppLauncherApplicationType = "vnc" + AccessAppsAppLauncherApplicationTypeAppLauncher AccessAppsAppLauncherApplicationType = "app_launcher" + AccessAppsAppLauncherApplicationTypeWARP AccessAppsAppLauncherApplicationType = "warp" + AccessAppsAppLauncherApplicationTypeBiso AccessAppsAppLauncherApplicationType = "biso" + AccessAppsAppLauncherApplicationTypeBookmark AccessAppsAppLauncherApplicationType = "bookmark" + AccessAppsAppLauncherApplicationTypeDashSSO AccessAppsAppLauncherApplicationType = "dash_sso" +) + +type AccessAppsDeviceEnrollmentPermissionsApplication struct { + // The application type. + Type AccessAppsDeviceEnrollmentPermissionsApplicationType `json:"type,required"` + // UUID + ID string `json:"id"` + // The identity providers your users can select when connecting to this + // application. Defaults to all IdPs configured in your account. + AllowedIdps []string `json:"allowed_idps"` + // Audience tag. + Aud string `json:"aud"` + // When set to `true`, users skip the identity provider selection step during + // login. You must specify only one identity provider in allowed_idps. + AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The primary hostname and path that Access will secure. If the app is visible in + // the App Launcher dashboard, this is the domain that will be displayed. + Domain string `json:"domain"` + // The name of the application. + Name string `json:"name"` + // The amount of time that tokens issued for this application will be valid. Must + // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, + // s, m, h. + SessionDuration string `json:"session_duration"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessAppsDeviceEnrollmentPermissionsApplicationJSON `json:"-"` +} + +// accessAppsDeviceEnrollmentPermissionsApplicationJSON contains the JSON metadata +// for the struct [AccessAppsDeviceEnrollmentPermissionsApplication] +type accessAppsDeviceEnrollmentPermissionsApplicationJSON struct { + Type apijson.Field + ID apijson.Field + AllowedIdps apijson.Field + Aud apijson.Field + AutoRedirectToIdentity apijson.Field + CreatedAt apijson.Field + Domain apijson.Field + Name apijson.Field + SessionDuration apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessAppsDeviceEnrollmentPermissionsApplication) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessAppsDeviceEnrollmentPermissionsApplicationJSON) RawJSON() string { + return r.raw +} + +func (r AccessAppsDeviceEnrollmentPermissionsApplication) implementsZeroTrustAccessApps() {} + +// The application type. +type AccessAppsDeviceEnrollmentPermissionsApplicationType string + +const ( + AccessAppsDeviceEnrollmentPermissionsApplicationTypeSelfHosted AccessAppsDeviceEnrollmentPermissionsApplicationType = "self_hosted" + AccessAppsDeviceEnrollmentPermissionsApplicationTypeSaas AccessAppsDeviceEnrollmentPermissionsApplicationType = "saas" + AccessAppsDeviceEnrollmentPermissionsApplicationTypeSSH AccessAppsDeviceEnrollmentPermissionsApplicationType = "ssh" + AccessAppsDeviceEnrollmentPermissionsApplicationTypeVnc AccessAppsDeviceEnrollmentPermissionsApplicationType = "vnc" + AccessAppsDeviceEnrollmentPermissionsApplicationTypeAppLauncher AccessAppsDeviceEnrollmentPermissionsApplicationType = "app_launcher" + AccessAppsDeviceEnrollmentPermissionsApplicationTypeWARP AccessAppsDeviceEnrollmentPermissionsApplicationType = "warp" + AccessAppsDeviceEnrollmentPermissionsApplicationTypeBiso AccessAppsDeviceEnrollmentPermissionsApplicationType = "biso" + AccessAppsDeviceEnrollmentPermissionsApplicationTypeBookmark AccessAppsDeviceEnrollmentPermissionsApplicationType = "bookmark" + AccessAppsDeviceEnrollmentPermissionsApplicationTypeDashSSO AccessAppsDeviceEnrollmentPermissionsApplicationType = "dash_sso" +) + +type AccessAppsBrowserIsolationPermissionsApplication struct { + // The application type. + Type AccessAppsBrowserIsolationPermissionsApplicationType `json:"type,required"` + // UUID + ID string `json:"id"` + // The identity providers your users can select when connecting to this + // application. Defaults to all IdPs configured in your account. + AllowedIdps []string `json:"allowed_idps"` + // Audience tag. + Aud string `json:"aud"` + // When set to `true`, users skip the identity provider selection step during + // login. You must specify only one identity provider in allowed_idps. + AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The primary hostname and path that Access will secure. If the app is visible in + // the App Launcher dashboard, this is the domain that will be displayed. + Domain string `json:"domain"` + // The name of the application. + Name string `json:"name"` + // The amount of time that tokens issued for this application will be valid. Must + // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, + // s, m, h. + SessionDuration string `json:"session_duration"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessAppsBrowserIsolationPermissionsApplicationJSON `json:"-"` +} + +// accessAppsBrowserIsolationPermissionsApplicationJSON contains the JSON metadata +// for the struct [AccessAppsBrowserIsolationPermissionsApplication] +type accessAppsBrowserIsolationPermissionsApplicationJSON struct { + Type apijson.Field + ID apijson.Field + AllowedIdps apijson.Field + Aud apijson.Field + AutoRedirectToIdentity apijson.Field + CreatedAt apijson.Field + Domain apijson.Field + Name apijson.Field + SessionDuration apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessAppsBrowserIsolationPermissionsApplication) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessAppsBrowserIsolationPermissionsApplicationJSON) RawJSON() string { + return r.raw +} + +func (r AccessAppsBrowserIsolationPermissionsApplication) implementsZeroTrustAccessApps() {} + +// The application type. +type AccessAppsBrowserIsolationPermissionsApplicationType string + +const ( + AccessAppsBrowserIsolationPermissionsApplicationTypeSelfHosted AccessAppsBrowserIsolationPermissionsApplicationType = "self_hosted" + AccessAppsBrowserIsolationPermissionsApplicationTypeSaas AccessAppsBrowserIsolationPermissionsApplicationType = "saas" + AccessAppsBrowserIsolationPermissionsApplicationTypeSSH AccessAppsBrowserIsolationPermissionsApplicationType = "ssh" + AccessAppsBrowserIsolationPermissionsApplicationTypeVnc AccessAppsBrowserIsolationPermissionsApplicationType = "vnc" + AccessAppsBrowserIsolationPermissionsApplicationTypeAppLauncher AccessAppsBrowserIsolationPermissionsApplicationType = "app_launcher" + AccessAppsBrowserIsolationPermissionsApplicationTypeWARP AccessAppsBrowserIsolationPermissionsApplicationType = "warp" + AccessAppsBrowserIsolationPermissionsApplicationTypeBiso AccessAppsBrowserIsolationPermissionsApplicationType = "biso" + AccessAppsBrowserIsolationPermissionsApplicationTypeBookmark AccessAppsBrowserIsolationPermissionsApplicationType = "bookmark" + AccessAppsBrowserIsolationPermissionsApplicationTypeDashSSO AccessAppsBrowserIsolationPermissionsApplicationType = "dash_sso" +) + +type AccessAppsBookmarkApplication struct { + // UUID + ID string `json:"id"` + AppLauncherVisible interface{} `json:"app_launcher_visible"` + // Audience tag. + Aud string `json:"aud"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The URL or domain of the bookmark. + Domain interface{} `json:"domain"` + // The image URL for the logo shown in the App Launcher dashboard. + LogoURL string `json:"logo_url"` + // The name of the application. + Name string `json:"name"` + // The tags you want assigned to an application. Tags are used to filter + // applications in the App Launcher dashboard. + Tags []string `json:"tags"` + // The application type. + Type string `json:"type"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessAppsBookmarkApplicationJSON `json:"-"` +} + +// accessAppsBookmarkApplicationJSON contains the JSON metadata for the struct +// [AccessAppsBookmarkApplication] +type accessAppsBookmarkApplicationJSON struct { + ID apijson.Field + AppLauncherVisible apijson.Field + Aud apijson.Field + CreatedAt apijson.Field + Domain apijson.Field + LogoURL apijson.Field + Name apijson.Field + Tags apijson.Field + Type apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessAppsBookmarkApplication) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessAppsBookmarkApplicationJSON) RawJSON() string { + return r.raw +} + +func (r AccessAppsBookmarkApplication) implementsZeroTrustAccessApps() {} + +type AccessApplicationDeleteResponse struct { + // UUID + ID string `json:"id"` + JSON accessApplicationDeleteResponseJSON `json:"-"` +} + +// accessApplicationDeleteResponseJSON contains the JSON metadata for the struct +// [AccessApplicationDeleteResponse] +type accessApplicationDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationRevokeTokensResponse = interface{} + +type AccessApplicationNewParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // When set to true, users can authenticate to this application using their WARP + // session. When set to false this application will always require direct IdP + // authentication. This setting always overrides the organization setting for WARP + // authentication. + AllowAuthenticateViaWARP param.Field[bool] `json:"allow_authenticate_via_warp"` + // The identity providers your users can select when connecting to this + // application. Defaults to all IdPs configured in your account. + AllowedIdps param.Field[[]string] `json:"allowed_idps"` + AppLauncherVisible param.Field[interface{}] `json:"app_launcher_visible"` + // When set to `true`, users skip the identity provider selection step during + // login. You must specify only one identity provider in allowed_idps. + AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` + CorsHeaders param.Field[AccessApplicationNewParamsCorsHeaders] `json:"cors_headers"` + // The custom error message shown to a user when they are denied access to the + // application. + CustomDenyMessage param.Field[string] `json:"custom_deny_message"` + // The custom URL a user is redirected to when they are denied access to the + // application when failing identity-based rules. + CustomDenyURL param.Field[string] `json:"custom_deny_url"` + // The custom URL a user is redirected to when they are denied access to the + // application when failing non-identity rules. + CustomNonIdentityDenyURL param.Field[string] `json:"custom_non_identity_deny_url"` + // The custom pages that will be displayed when applicable for this application + CustomPages param.Field[[]string] `json:"custom_pages"` + // The URL or domain of the bookmark. + Domain param.Field[interface{}] `json:"domain"` + // Enables the binding cookie, which increases security against compromised + // authorization tokens and CSRF attacks. + EnableBindingCookie param.Field[bool] `json:"enable_binding_cookie"` + // Enables the HttpOnly cookie attribute, which increases security against XSS + // attacks. + HTTPOnlyCookieAttribute param.Field[bool] `json:"http_only_cookie_attribute"` + // The image URL for the logo shown in the App Launcher dashboard. + LogoURL param.Field[string] `json:"logo_url"` + // The name of the application. + Name param.Field[string] `json:"name"` + // Enables cookie paths to scope an application's JWT to the application path. If + // disabled, the JWT will scope to the hostname by default + PathCookieAttribute param.Field[bool] `json:"path_cookie_attribute"` + SaasApp param.Field[AccessApplicationNewParamsSaasApp] `json:"saas_app"` + // Sets the SameSite cookie setting, which provides increased security against CSRF + // attacks. + SameSiteCookieAttribute param.Field[string] `json:"same_site_cookie_attribute"` + // List of domains that Access will secure. + SelfHostedDomains param.Field[[]string] `json:"self_hosted_domains"` + // Returns a 401 status code when the request is blocked by a Service Auth policy. + ServiceAuth401Redirect param.Field[bool] `json:"service_auth_401_redirect"` + // The amount of time that tokens issued for this application will be valid. Must + // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, + // s, m, h. + SessionDuration param.Field[string] `json:"session_duration"` + // Enables automatic authentication through cloudflared. + SkipInterstitial param.Field[bool] `json:"skip_interstitial"` + // The tags you want assigned to an application. Tags are used to filter + // applications in the App Launcher dashboard. + Tags param.Field[[]string] `json:"tags"` + // The application type. + Type param.Field[string] `json:"type"` +} + +func (r AccessApplicationNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AccessApplicationNewParamsCorsHeaders struct { + // Allows all HTTP request headers. + AllowAllHeaders param.Field[bool] `json:"allow_all_headers"` + // Allows all HTTP request methods. + AllowAllMethods param.Field[bool] `json:"allow_all_methods"` + // Allows all origins. + AllowAllOrigins param.Field[bool] `json:"allow_all_origins"` + // When set to `true`, includes credentials (cookies, authorization headers, or TLS + // client certificates) with requests. + AllowCredentials param.Field[bool] `json:"allow_credentials"` + // Allowed HTTP request headers. + AllowedHeaders param.Field[[]interface{}] `json:"allowed_headers"` + // Allowed HTTP request methods. + AllowedMethods param.Field[[]AccessApplicationNewParamsCorsHeadersAllowedMethod] `json:"allowed_methods"` + // Allowed origins. + AllowedOrigins param.Field[[]interface{}] `json:"allowed_origins"` + // The maximum number of seconds the results of a preflight request can be cached. + MaxAge param.Field[float64] `json:"max_age"` +} + +func (r AccessApplicationNewParamsCorsHeaders) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AccessApplicationNewParamsCorsHeadersAllowedMethod string + +const ( + AccessApplicationNewParamsCorsHeadersAllowedMethodGet AccessApplicationNewParamsCorsHeadersAllowedMethod = "GET" + AccessApplicationNewParamsCorsHeadersAllowedMethodPost AccessApplicationNewParamsCorsHeadersAllowedMethod = "POST" + AccessApplicationNewParamsCorsHeadersAllowedMethodHead AccessApplicationNewParamsCorsHeadersAllowedMethod = "HEAD" + AccessApplicationNewParamsCorsHeadersAllowedMethodPut AccessApplicationNewParamsCorsHeadersAllowedMethod = "PUT" + AccessApplicationNewParamsCorsHeadersAllowedMethodDelete AccessApplicationNewParamsCorsHeadersAllowedMethod = "DELETE" + AccessApplicationNewParamsCorsHeadersAllowedMethodConnect AccessApplicationNewParamsCorsHeadersAllowedMethod = "CONNECT" + AccessApplicationNewParamsCorsHeadersAllowedMethodOptions AccessApplicationNewParamsCorsHeadersAllowedMethod = "OPTIONS" + AccessApplicationNewParamsCorsHeadersAllowedMethodTrace AccessApplicationNewParamsCorsHeadersAllowedMethod = "TRACE" + AccessApplicationNewParamsCorsHeadersAllowedMethodPatch AccessApplicationNewParamsCorsHeadersAllowedMethod = "PATCH" +) + +// Satisfied by [zero_trust.AccessApplicationNewParamsSaasAppAccessSamlSaasApp], +// [zero_trust.AccessApplicationNewParamsSaasAppAccessOidcSaasApp]. +type AccessApplicationNewParamsSaasApp interface { + implementsZeroTrustAccessApplicationNewParamsSaasApp() +} + +type AccessApplicationNewParamsSaasAppAccessSamlSaasApp struct { + // Optional identifier indicating the authentication protocol used for the saas + // app. Required for OIDC. Default if unset is "saml" + AuthType param.Field[AccessApplicationNewParamsSaasAppAccessSamlSaasAppAuthType] `json:"auth_type"` + // The service provider's endpoint that is responsible for receiving and parsing a + // SAML assertion. + ConsumerServiceURL param.Field[string] `json:"consumer_service_url"` + CustomAttributes param.Field[AccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributes] `json:"custom_attributes"` + // The URL that the user will be redirected to after a successful login for IDP + // initiated logins. + DefaultRelayState param.Field[string] `json:"default_relay_state"` + // The unique identifier for your SaaS application. + IdpEntityID param.Field[string] `json:"idp_entity_id"` + // The format of the name identifier sent to the SaaS application. + NameIDFormat param.Field[AccessApplicationNewParamsSaasAppAccessSamlSaasAppNameIDFormat] `json:"name_id_format"` + // A [JSONata](https://jsonata.org/) expression that transforms an application's + // user identities into a NameID value for its SAML assertion. This expression + // should evaluate to a singular string. The output of this expression can override + // the `name_id_format` setting. + NameIDTransformJsonata param.Field[string] `json:"name_id_transform_jsonata"` + // The Access public certificate that will be used to verify your identity. + PublicKey param.Field[string] `json:"public_key"` + // A globally unique name for an identity or service provider. + SpEntityID param.Field[string] `json:"sp_entity_id"` + // The endpoint where your SaaS application will send login requests. + SSOEndpoint param.Field[string] `json:"sso_endpoint"` +} + +func (r AccessApplicationNewParamsSaasAppAccessSamlSaasApp) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationNewParamsSaasAppAccessSamlSaasApp) implementsZeroTrustAccessApplicationNewParamsSaasApp() { +} + +// Optional identifier indicating the authentication protocol used for the saas +// app. Required for OIDC. Default if unset is "saml" +type AccessApplicationNewParamsSaasAppAccessSamlSaasAppAuthType string + +const ( + AccessApplicationNewParamsSaasAppAccessSamlSaasAppAuthTypeSaml AccessApplicationNewParamsSaasAppAccessSamlSaasAppAuthType = "saml" + AccessApplicationNewParamsSaasAppAccessSamlSaasAppAuthTypeOidc AccessApplicationNewParamsSaasAppAccessSamlSaasAppAuthType = "oidc" +) + +type AccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributes struct { + // The name of the attribute. + Name param.Field[string] `json:"name"` + // A globally unique name for an identity or service provider. + NameFormat param.Field[AccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat] `json:"name_format"` + Source param.Field[AccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesSource] `json:"source"` +} + +func (r AccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributes) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A globally unique name for an identity or service provider. +type AccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat string + +const ( + AccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatUnspecified AccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" + AccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic AccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic" + AccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatURI AccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" +) + +type AccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesSource struct { + // The name of the IdP attribute. + Name param.Field[string] `json:"name"` +} + +func (r AccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesSource) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The format of the name identifier sent to the SaaS application. +type AccessApplicationNewParamsSaasAppAccessSamlSaasAppNameIDFormat string + +const ( + AccessApplicationNewParamsSaasAppAccessSamlSaasAppNameIDFormatID AccessApplicationNewParamsSaasAppAccessSamlSaasAppNameIDFormat = "id" + AccessApplicationNewParamsSaasAppAccessSamlSaasAppNameIDFormatEmail AccessApplicationNewParamsSaasAppAccessSamlSaasAppNameIDFormat = "email" +) + +type AccessApplicationNewParamsSaasAppAccessOidcSaasApp struct { + // The URL where this applications tile redirects users + AppLauncherURL param.Field[string] `json:"app_launcher_url"` + // Identifier of the authentication protocol used for the saas app. Required for + // OIDC. + AuthType param.Field[AccessApplicationNewParamsSaasAppAccessOidcSaasAppAuthType] `json:"auth_type"` + // The application client id + ClientID param.Field[string] `json:"client_id"` + // The application client secret, only returned on POST request. + ClientSecret param.Field[string] `json:"client_secret"` + // The OIDC flows supported by this application + GrantTypes param.Field[[]AccessApplicationNewParamsSaasAppAccessOidcSaasAppGrantType] `json:"grant_types"` + // A regex to filter Cloudflare groups returned in ID token and userinfo endpoint + GroupFilterRegex param.Field[string] `json:"group_filter_regex"` + // The Access public certificate that will be used to verify your identity. + PublicKey param.Field[string] `json:"public_key"` + // The permitted URL's for Cloudflare to return Authorization codes and Access/ID + // tokens + RedirectURIs param.Field[[]string] `json:"redirect_uris"` + // Define the user information shared with access + Scopes param.Field[[]AccessApplicationNewParamsSaasAppAccessOidcSaasAppScope] `json:"scopes"` +} + +func (r AccessApplicationNewParamsSaasAppAccessOidcSaasApp) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationNewParamsSaasAppAccessOidcSaasApp) implementsZeroTrustAccessApplicationNewParamsSaasApp() { +} + +// Identifier of the authentication protocol used for the saas app. Required for +// OIDC. +type AccessApplicationNewParamsSaasAppAccessOidcSaasAppAuthType string + +const ( + AccessApplicationNewParamsSaasAppAccessOidcSaasAppAuthTypeSaml AccessApplicationNewParamsSaasAppAccessOidcSaasAppAuthType = "saml" + AccessApplicationNewParamsSaasAppAccessOidcSaasAppAuthTypeOidc AccessApplicationNewParamsSaasAppAccessOidcSaasAppAuthType = "oidc" +) + +type AccessApplicationNewParamsSaasAppAccessOidcSaasAppGrantType string + +const ( + AccessApplicationNewParamsSaasAppAccessOidcSaasAppGrantTypeAuthorizationCode AccessApplicationNewParamsSaasAppAccessOidcSaasAppGrantType = "authorization_code" + AccessApplicationNewParamsSaasAppAccessOidcSaasAppGrantTypeAuthorizationCodeWithPkce AccessApplicationNewParamsSaasAppAccessOidcSaasAppGrantType = "authorization_code_with_pkce" +) + +type AccessApplicationNewParamsSaasAppAccessOidcSaasAppScope string + +const ( + AccessApplicationNewParamsSaasAppAccessOidcSaasAppScopeOpenid AccessApplicationNewParamsSaasAppAccessOidcSaasAppScope = "openid" + AccessApplicationNewParamsSaasAppAccessOidcSaasAppScopeGroups AccessApplicationNewParamsSaasAppAccessOidcSaasAppScope = "groups" + AccessApplicationNewParamsSaasAppAccessOidcSaasAppScopeEmail AccessApplicationNewParamsSaasAppAccessOidcSaasAppScope = "email" + AccessApplicationNewParamsSaasAppAccessOidcSaasAppScopeProfile AccessApplicationNewParamsSaasAppAccessOidcSaasAppScope = "profile" +) + +type AccessApplicationNewResponseEnvelope struct { + Errors []AccessApplicationNewResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessApplicationNewResponseEnvelopeMessages `json:"messages,required"` + Result AccessApps `json:"result,required"` + // Whether the API call was successful + Success AccessApplicationNewResponseEnvelopeSuccess `json:"success,required"` + JSON accessApplicationNewResponseEnvelopeJSON `json:"-"` +} + +// accessApplicationNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessApplicationNewResponseEnvelope] +type accessApplicationNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessApplicationNewResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessApplicationNewResponseEnvelopeErrors] +type accessApplicationNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessApplicationNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AccessApplicationNewResponseEnvelopeMessages] +type accessApplicationNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessApplicationNewResponseEnvelopeSuccess bool + +const ( + AccessApplicationNewResponseEnvelopeSuccessTrue AccessApplicationNewResponseEnvelopeSuccess = true +) + +type AccessApplicationUpdateParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // When set to true, users can authenticate to this application using their WARP + // session. When set to false this application will always require direct IdP + // authentication. This setting always overrides the organization setting for WARP + // authentication. + AllowAuthenticateViaWARP param.Field[bool] `json:"allow_authenticate_via_warp"` + // The identity providers your users can select when connecting to this + // application. Defaults to all IdPs configured in your account. + AllowedIdps param.Field[[]string] `json:"allowed_idps"` + AppLauncherVisible param.Field[interface{}] `json:"app_launcher_visible"` + // When set to `true`, users skip the identity provider selection step during + // login. You must specify only one identity provider in allowed_idps. + AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` + CorsHeaders param.Field[AccessApplicationUpdateParamsCorsHeaders] `json:"cors_headers"` + // The custom error message shown to a user when they are denied access to the + // application. + CustomDenyMessage param.Field[string] `json:"custom_deny_message"` + // The custom URL a user is redirected to when they are denied access to the + // application when failing identity-based rules. + CustomDenyURL param.Field[string] `json:"custom_deny_url"` + // The custom URL a user is redirected to when they are denied access to the + // application when failing non-identity rules. + CustomNonIdentityDenyURL param.Field[string] `json:"custom_non_identity_deny_url"` + // The custom pages that will be displayed when applicable for this application + CustomPages param.Field[[]string] `json:"custom_pages"` + // The URL or domain of the bookmark. + Domain param.Field[interface{}] `json:"domain"` + // Enables the binding cookie, which increases security against compromised + // authorization tokens and CSRF attacks. + EnableBindingCookie param.Field[bool] `json:"enable_binding_cookie"` + // Enables the HttpOnly cookie attribute, which increases security against XSS + // attacks. + HTTPOnlyCookieAttribute param.Field[bool] `json:"http_only_cookie_attribute"` + // The image URL for the logo shown in the App Launcher dashboard. + LogoURL param.Field[string] `json:"logo_url"` + // The name of the application. + Name param.Field[string] `json:"name"` + // Enables cookie paths to scope an application's JWT to the application path. If + // disabled, the JWT will scope to the hostname by default + PathCookieAttribute param.Field[bool] `json:"path_cookie_attribute"` + SaasApp param.Field[AccessApplicationUpdateParamsSaasApp] `json:"saas_app"` + // Sets the SameSite cookie setting, which provides increased security against CSRF + // attacks. + SameSiteCookieAttribute param.Field[string] `json:"same_site_cookie_attribute"` + // List of domains that Access will secure. + SelfHostedDomains param.Field[[]string] `json:"self_hosted_domains"` + // Returns a 401 status code when the request is blocked by a Service Auth policy. + ServiceAuth401Redirect param.Field[bool] `json:"service_auth_401_redirect"` + // The amount of time that tokens issued for this application will be valid. Must + // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, + // s, m, h. + SessionDuration param.Field[string] `json:"session_duration"` + // Enables automatic authentication through cloudflared. + SkipInterstitial param.Field[bool] `json:"skip_interstitial"` + // The tags you want assigned to an application. Tags are used to filter + // applications in the App Launcher dashboard. + Tags param.Field[[]string] `json:"tags"` + // The application type. + Type param.Field[string] `json:"type"` +} + +func (r AccessApplicationUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Identifier +// +// Satisfied by [shared.UnionString], [shared.UnionString]. +type AccessApplicationUpdateParamsAppID interface { + ImplementsZeroTrustAccessApplicationUpdateParamsAppID() +} + +type AccessApplicationUpdateParamsCorsHeaders struct { + // Allows all HTTP request headers. + AllowAllHeaders param.Field[bool] `json:"allow_all_headers"` + // Allows all HTTP request methods. + AllowAllMethods param.Field[bool] `json:"allow_all_methods"` + // Allows all origins. + AllowAllOrigins param.Field[bool] `json:"allow_all_origins"` + // When set to `true`, includes credentials (cookies, authorization headers, or TLS + // client certificates) with requests. + AllowCredentials param.Field[bool] `json:"allow_credentials"` + // Allowed HTTP request headers. + AllowedHeaders param.Field[[]interface{}] `json:"allowed_headers"` + // Allowed HTTP request methods. + AllowedMethods param.Field[[]AccessApplicationUpdateParamsCorsHeadersAllowedMethod] `json:"allowed_methods"` + // Allowed origins. + AllowedOrigins param.Field[[]interface{}] `json:"allowed_origins"` + // The maximum number of seconds the results of a preflight request can be cached. + MaxAge param.Field[float64] `json:"max_age"` +} + +func (r AccessApplicationUpdateParamsCorsHeaders) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AccessApplicationUpdateParamsCorsHeadersAllowedMethod string + +const ( + AccessApplicationUpdateParamsCorsHeadersAllowedMethodGet AccessApplicationUpdateParamsCorsHeadersAllowedMethod = "GET" + AccessApplicationUpdateParamsCorsHeadersAllowedMethodPost AccessApplicationUpdateParamsCorsHeadersAllowedMethod = "POST" + AccessApplicationUpdateParamsCorsHeadersAllowedMethodHead AccessApplicationUpdateParamsCorsHeadersAllowedMethod = "HEAD" + AccessApplicationUpdateParamsCorsHeadersAllowedMethodPut AccessApplicationUpdateParamsCorsHeadersAllowedMethod = "PUT" + AccessApplicationUpdateParamsCorsHeadersAllowedMethodDelete AccessApplicationUpdateParamsCorsHeadersAllowedMethod = "DELETE" + AccessApplicationUpdateParamsCorsHeadersAllowedMethodConnect AccessApplicationUpdateParamsCorsHeadersAllowedMethod = "CONNECT" + AccessApplicationUpdateParamsCorsHeadersAllowedMethodOptions AccessApplicationUpdateParamsCorsHeadersAllowedMethod = "OPTIONS" + AccessApplicationUpdateParamsCorsHeadersAllowedMethodTrace AccessApplicationUpdateParamsCorsHeadersAllowedMethod = "TRACE" + AccessApplicationUpdateParamsCorsHeadersAllowedMethodPatch AccessApplicationUpdateParamsCorsHeadersAllowedMethod = "PATCH" +) + +// Satisfied by [zero_trust.AccessApplicationUpdateParamsSaasAppAccessSamlSaasApp], +// [zero_trust.AccessApplicationUpdateParamsSaasAppAccessOidcSaasApp]. +type AccessApplicationUpdateParamsSaasApp interface { + implementsZeroTrustAccessApplicationUpdateParamsSaasApp() +} + +type AccessApplicationUpdateParamsSaasAppAccessSamlSaasApp struct { + // Optional identifier indicating the authentication protocol used for the saas + // app. Required for OIDC. Default if unset is "saml" + AuthType param.Field[AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppAuthType] `json:"auth_type"` + // The service provider's endpoint that is responsible for receiving and parsing a + // SAML assertion. + ConsumerServiceURL param.Field[string] `json:"consumer_service_url"` + CustomAttributes param.Field[AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributes] `json:"custom_attributes"` + // The URL that the user will be redirected to after a successful login for IDP + // initiated logins. + DefaultRelayState param.Field[string] `json:"default_relay_state"` + // The unique identifier for your SaaS application. + IdpEntityID param.Field[string] `json:"idp_entity_id"` + // The format of the name identifier sent to the SaaS application. + NameIDFormat param.Field[AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppNameIDFormat] `json:"name_id_format"` + // A [JSONata](https://jsonata.org/) expression that transforms an application's + // user identities into a NameID value for its SAML assertion. This expression + // should evaluate to a singular string. The output of this expression can override + // the `name_id_format` setting. + NameIDTransformJsonata param.Field[string] `json:"name_id_transform_jsonata"` + // The Access public certificate that will be used to verify your identity. + PublicKey param.Field[string] `json:"public_key"` + // A globally unique name for an identity or service provider. + SpEntityID param.Field[string] `json:"sp_entity_id"` + // The endpoint where your SaaS application will send login requests. + SSOEndpoint param.Field[string] `json:"sso_endpoint"` +} + +func (r AccessApplicationUpdateParamsSaasAppAccessSamlSaasApp) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationUpdateParamsSaasAppAccessSamlSaasApp) implementsZeroTrustAccessApplicationUpdateParamsSaasApp() { +} + +// Optional identifier indicating the authentication protocol used for the saas +// app. Required for OIDC. Default if unset is "saml" +type AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppAuthType string + +const ( + AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppAuthTypeSaml AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppAuthType = "saml" + AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppAuthTypeOidc AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppAuthType = "oidc" +) + +type AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributes struct { + // The name of the attribute. + Name param.Field[string] `json:"name"` + // A globally unique name for an identity or service provider. + NameFormat param.Field[AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat] `json:"name_format"` + Source param.Field[AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesSource] `json:"source"` +} + +func (r AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributes) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A globally unique name for an identity or service provider. +type AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat string + +const ( + AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatUnspecified AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" + AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic" + AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatURI AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" +) + +type AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesSource struct { + // The name of the IdP attribute. + Name param.Field[string] `json:"name"` +} + +func (r AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesSource) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The format of the name identifier sent to the SaaS application. +type AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppNameIDFormat string + +const ( + AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppNameIDFormatID AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppNameIDFormat = "id" + AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppNameIDFormatEmail AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppNameIDFormat = "email" +) + +type AccessApplicationUpdateParamsSaasAppAccessOidcSaasApp struct { + // The URL where this applications tile redirects users + AppLauncherURL param.Field[string] `json:"app_launcher_url"` + // Identifier of the authentication protocol used for the saas app. Required for + // OIDC. + AuthType param.Field[AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppAuthType] `json:"auth_type"` + // The application client id + ClientID param.Field[string] `json:"client_id"` + // The application client secret, only returned on POST request. + ClientSecret param.Field[string] `json:"client_secret"` + // The OIDC flows supported by this application + GrantTypes param.Field[[]AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppGrantType] `json:"grant_types"` + // A regex to filter Cloudflare groups returned in ID token and userinfo endpoint + GroupFilterRegex param.Field[string] `json:"group_filter_regex"` + // The Access public certificate that will be used to verify your identity. + PublicKey param.Field[string] `json:"public_key"` + // The permitted URL's for Cloudflare to return Authorization codes and Access/ID + // tokens + RedirectURIs param.Field[[]string] `json:"redirect_uris"` + // Define the user information shared with access + Scopes param.Field[[]AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScope] `json:"scopes"` +} + +func (r AccessApplicationUpdateParamsSaasAppAccessOidcSaasApp) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationUpdateParamsSaasAppAccessOidcSaasApp) implementsZeroTrustAccessApplicationUpdateParamsSaasApp() { +} + +// Identifier of the authentication protocol used for the saas app. Required for +// OIDC. +type AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppAuthType string + +const ( + AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppAuthTypeSaml AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppAuthType = "saml" + AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppAuthTypeOidc AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppAuthType = "oidc" +) + +type AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppGrantType string + +const ( + AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppGrantTypeAuthorizationCode AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppGrantType = "authorization_code" + AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppGrantTypeAuthorizationCodeWithPkce AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppGrantType = "authorization_code_with_pkce" +) + +type AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScope string + +const ( + AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScopeOpenid AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScope = "openid" + AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScopeGroups AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScope = "groups" + AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScopeEmail AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScope = "email" + AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScopeProfile AccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScope = "profile" +) + +type AccessApplicationUpdateResponseEnvelope struct { + Errors []AccessApplicationUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessApplicationUpdateResponseEnvelopeMessages `json:"messages,required"` + Result AccessApps `json:"result,required"` + // Whether the API call was successful + Success AccessApplicationUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON accessApplicationUpdateResponseEnvelopeJSON `json:"-"` +} + +// accessApplicationUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessApplicationUpdateResponseEnvelope] +type accessApplicationUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessApplicationUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessApplicationUpdateResponseEnvelopeErrors] +type accessApplicationUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessApplicationUpdateResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AccessApplicationUpdateResponseEnvelopeMessages] +type accessApplicationUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessApplicationUpdateResponseEnvelopeSuccess bool + +const ( + AccessApplicationUpdateResponseEnvelopeSuccessTrue AccessApplicationUpdateResponseEnvelopeSuccess = true +) + +type AccessApplicationListParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessApplicationListResponseEnvelope struct { + Errors []AccessApplicationListResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessApplicationListResponseEnvelopeMessages `json:"messages,required"` + Result []AccessApps `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessApplicationListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AccessApplicationListResponseEnvelopeResultInfo `json:"result_info"` + JSON accessApplicationListResponseEnvelopeJSON `json:"-"` +} + +// accessApplicationListResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessApplicationListResponseEnvelope] +type accessApplicationListResponseEnvelopeJSON 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 *AccessApplicationListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationListResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessApplicationListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessApplicationListResponseEnvelopeErrors] +type accessApplicationListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationListResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessApplicationListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AccessApplicationListResponseEnvelopeMessages] +type accessApplicationListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessApplicationListResponseEnvelopeSuccess bool + +const ( + AccessApplicationListResponseEnvelopeSuccessTrue AccessApplicationListResponseEnvelopeSuccess = true +) + +type AccessApplicationListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON accessApplicationListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// accessApplicationListResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [AccessApplicationListResponseEnvelopeResultInfo] +type accessApplicationListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationDeleteParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +// Identifier +// +// Satisfied by [shared.UnionString], [shared.UnionString]. +type AccessApplicationDeleteParamsAppID interface { + ImplementsZeroTrustAccessApplicationDeleteParamsAppID() +} + +type AccessApplicationDeleteResponseEnvelope struct { + Errors []AccessApplicationDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessApplicationDeleteResponseEnvelopeMessages `json:"messages,required"` + Result AccessApplicationDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success AccessApplicationDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON accessApplicationDeleteResponseEnvelopeJSON `json:"-"` +} + +// accessApplicationDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessApplicationDeleteResponseEnvelope] +type accessApplicationDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessApplicationDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessApplicationDeleteResponseEnvelopeErrors] +type accessApplicationDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessApplicationDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AccessApplicationDeleteResponseEnvelopeMessages] +type accessApplicationDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessApplicationDeleteResponseEnvelopeSuccess bool + +const ( + AccessApplicationDeleteResponseEnvelopeSuccessTrue AccessApplicationDeleteResponseEnvelopeSuccess = true +) + +type AccessApplicationGetParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +// Identifier +// +// Satisfied by [shared.UnionString], [shared.UnionString]. +type AccessApplicationGetParamsAppID interface { + ImplementsZeroTrustAccessApplicationGetParamsAppID() +} + +type AccessApplicationGetResponseEnvelope struct { + Errors []AccessApplicationGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessApplicationGetResponseEnvelopeMessages `json:"messages,required"` + Result AccessApps `json:"result,required"` + // Whether the API call was successful + Success AccessApplicationGetResponseEnvelopeSuccess `json:"success,required"` + JSON accessApplicationGetResponseEnvelopeJSON `json:"-"` +} + +// accessApplicationGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessApplicationGetResponseEnvelope] +type accessApplicationGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessApplicationGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessApplicationGetResponseEnvelopeErrors] +type accessApplicationGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessApplicationGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AccessApplicationGetResponseEnvelopeMessages] +type accessApplicationGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessApplicationGetResponseEnvelopeSuccess bool + +const ( + AccessApplicationGetResponseEnvelopeSuccessTrue AccessApplicationGetResponseEnvelopeSuccess = true +) + +type AccessApplicationRevokeTokensParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +// Identifier +// +// Satisfied by [shared.UnionString], [shared.UnionString]. +type AccessApplicationRevokeTokensParamsAppID interface { + ImplementsZeroTrustAccessApplicationRevokeTokensParamsAppID() +} + +type AccessApplicationRevokeTokensResponseEnvelope struct { + Result AccessApplicationRevokeTokensResponse `json:"result,nullable"` + Success AccessApplicationRevokeTokensResponseEnvelopeSuccess `json:"success"` + JSON accessApplicationRevokeTokensResponseEnvelopeJSON `json:"-"` +} + +// accessApplicationRevokeTokensResponseEnvelopeJSON contains the JSON metadata for +// the struct [AccessApplicationRevokeTokensResponseEnvelope] +type accessApplicationRevokeTokensResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationRevokeTokensResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationRevokeTokensResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationRevokeTokensResponseEnvelopeSuccess bool + +const ( + AccessApplicationRevokeTokensResponseEnvelopeSuccessTrue AccessApplicationRevokeTokensResponseEnvelopeSuccess = true + AccessApplicationRevokeTokensResponseEnvelopeSuccessFalse AccessApplicationRevokeTokensResponseEnvelopeSuccess = false +) diff --git a/zero_trust/accessapplication_test.go b/zero_trust/accessapplication_test.go new file mode 100644 index 00000000000..ae4f520ff40 --- /dev/null +++ b/zero_trust/accessapplication_test.go @@ -0,0 +1,292 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestAccessApplicationNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Applications.New(context.TODO(), zero_trust.AccessApplicationNewParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + AllowAuthenticateViaWARP: cloudflare.F(true), + AllowedIdps: cloudflare.F([]string{"699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252"}), + AppLauncherVisible: cloudflare.F[any](map[string]interface{}{}), + AutoRedirectToIdentity: cloudflare.F(true), + CorsHeaders: cloudflare.F(zero_trust.AccessApplicationNewParamsCorsHeaders{ + AllowAllHeaders: cloudflare.F(true), + AllowAllMethods: cloudflare.F(true), + AllowAllOrigins: cloudflare.F(true), + AllowCredentials: cloudflare.F(true), + AllowedHeaders: cloudflare.F([]interface{}{map[string]interface{}{}, map[string]interface{}{}, map[string]interface{}{}}), + AllowedMethods: cloudflare.F([]zero_trust.AccessApplicationNewParamsCorsHeadersAllowedMethod{zero_trust.AccessApplicationNewParamsCorsHeadersAllowedMethodGet}), + AllowedOrigins: cloudflare.F([]interface{}{"https://example.com"}), + MaxAge: cloudflare.F(-1.000000), + }), + CustomDenyMessage: cloudflare.F("string"), + CustomDenyURL: cloudflare.F("string"), + CustomNonIdentityDenyURL: cloudflare.F("string"), + CustomPages: cloudflare.F([]string{"699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252"}), + Domain: cloudflare.F[any]("https://mybookmark.com"), + EnableBindingCookie: cloudflare.F(true), + HTTPOnlyCookieAttribute: cloudflare.F(true), + LogoURL: cloudflare.F("https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg"), + Name: cloudflare.F("Admin Site"), + PathCookieAttribute: cloudflare.F(true), + SaasApp: cloudflare.F[zero_trust.AccessApplicationNewParamsSaasApp](zero_trust.AccessApplicationNewParamsSaasAppAccessSamlSaasApp(zero_trust.AccessApplicationNewParamsSaasAppAccessSamlSaasApp{ + AuthType: cloudflare.F(zero_trust.AccessApplicationNewParamsSaasAppAccessSamlSaasAppAuthTypeSaml), + ConsumerServiceURL: cloudflare.F("https://example.com"), + CustomAttributes: cloudflare.F(zero_trust.AccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributes{ + Name: cloudflare.F("family_name"), + NameFormat: cloudflare.F(zero_trust.AccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic), + Source: cloudflare.F(zero_trust.AccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesSource{ + Name: cloudflare.F("last_name"), + }), + }), + DefaultRelayState: cloudflare.F("https://example.com"), + IdpEntityID: cloudflare.F("https://example.cloudflareaccess.com"), + NameIDFormat: cloudflare.F(zero_trust.AccessApplicationNewParamsSaasAppAccessSamlSaasAppNameIDFormatID), + NameIDTransformJsonata: cloudflare.F("$substringBefore(email, '@') & '+sandbox@' & $substringAfter(email, '@')"), + PublicKey: cloudflare.F("example unique name"), + SpEntityID: cloudflare.F("example unique name"), + SSOEndpoint: cloudflare.F("https://example.cloudflareaccess.com/cdn-cgi/access/sso/saml/b3f58a2b414e0b51d45c8c2af26fccca0e27c63763c426fa52f98dcf0b3b3bfd"), + })), + SameSiteCookieAttribute: cloudflare.F("strict"), + SelfHostedDomains: cloudflare.F([]string{"test.example.com/admin", "test.anotherexample.com/staff"}), + ServiceAuth401Redirect: cloudflare.F(true), + SessionDuration: cloudflare.F("24h"), + SkipInterstitial: cloudflare.F(true), + Tags: cloudflare.F([]string{"engineers", "engineers", "engineers"}), + Type: cloudflare.F("bookmark"), + }) + 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 TestAccessApplicationUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Applications.Update( + context.TODO(), + shared.UnionString("023e105f4ecef8ad9ca31a8372d0c353"), + zero_trust.AccessApplicationUpdateParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + AllowAuthenticateViaWARP: cloudflare.F(true), + AllowedIdps: cloudflare.F([]string{"699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252"}), + AppLauncherVisible: cloudflare.F[any](map[string]interface{}{}), + AutoRedirectToIdentity: cloudflare.F(true), + CorsHeaders: cloudflare.F(zero_trust.AccessApplicationUpdateParamsCorsHeaders{ + AllowAllHeaders: cloudflare.F(true), + AllowAllMethods: cloudflare.F(true), + AllowAllOrigins: cloudflare.F(true), + AllowCredentials: cloudflare.F(true), + AllowedHeaders: cloudflare.F([]interface{}{map[string]interface{}{}, map[string]interface{}{}, map[string]interface{}{}}), + AllowedMethods: cloudflare.F([]zero_trust.AccessApplicationUpdateParamsCorsHeadersAllowedMethod{zero_trust.AccessApplicationUpdateParamsCorsHeadersAllowedMethodGet}), + AllowedOrigins: cloudflare.F([]interface{}{"https://example.com"}), + MaxAge: cloudflare.F(-1.000000), + }), + CustomDenyMessage: cloudflare.F("string"), + CustomDenyURL: cloudflare.F("string"), + CustomNonIdentityDenyURL: cloudflare.F("string"), + CustomPages: cloudflare.F([]string{"699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252"}), + Domain: cloudflare.F[any]("https://mybookmark.com"), + EnableBindingCookie: cloudflare.F(true), + HTTPOnlyCookieAttribute: cloudflare.F(true), + LogoURL: cloudflare.F("https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg"), + Name: cloudflare.F("Admin Site"), + PathCookieAttribute: cloudflare.F(true), + SaasApp: cloudflare.F[zero_trust.AccessApplicationUpdateParamsSaasApp](zero_trust.AccessApplicationUpdateParamsSaasAppAccessSamlSaasApp(zero_trust.AccessApplicationUpdateParamsSaasAppAccessSamlSaasApp{ + AuthType: cloudflare.F(zero_trust.AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppAuthTypeSaml), + ConsumerServiceURL: cloudflare.F("https://example.com"), + CustomAttributes: cloudflare.F(zero_trust.AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributes{ + Name: cloudflare.F("family_name"), + NameFormat: cloudflare.F(zero_trust.AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic), + Source: cloudflare.F(zero_trust.AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesSource{ + Name: cloudflare.F("last_name"), + }), + }), + DefaultRelayState: cloudflare.F("https://example.com"), + IdpEntityID: cloudflare.F("https://example.cloudflareaccess.com"), + NameIDFormat: cloudflare.F(zero_trust.AccessApplicationUpdateParamsSaasAppAccessSamlSaasAppNameIDFormatID), + NameIDTransformJsonata: cloudflare.F("$substringBefore(email, '@') & '+sandbox@' & $substringAfter(email, '@')"), + PublicKey: cloudflare.F("example unique name"), + SpEntityID: cloudflare.F("example unique name"), + SSOEndpoint: cloudflare.F("https://example.cloudflareaccess.com/cdn-cgi/access/sso/saml/b3f58a2b414e0b51d45c8c2af26fccca0e27c63763c426fa52f98dcf0b3b3bfd"), + })), + SameSiteCookieAttribute: cloudflare.F("strict"), + SelfHostedDomains: cloudflare.F([]string{"test.example.com/admin", "test.anotherexample.com/staff"}), + ServiceAuth401Redirect: cloudflare.F(true), + SessionDuration: cloudflare.F("24h"), + SkipInterstitial: cloudflare.F(true), + Tags: cloudflare.F([]string{"engineers", "engineers", "engineers"}), + Type: cloudflare.F("bookmark"), + }, + ) + 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 TestAccessApplicationListWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Applications.List(context.TODO(), zero_trust.AccessApplicationListParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }) + 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 TestAccessApplicationDeleteWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Applications.Delete( + context.TODO(), + shared.UnionString("023e105f4ecef8ad9ca31a8372d0c353"), + zero_trust.AccessApplicationDeleteParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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 TestAccessApplicationGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Applications.Get( + context.TODO(), + shared.UnionString("023e105f4ecef8ad9ca31a8372d0c353"), + zero_trust.AccessApplicationGetParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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 TestAccessApplicationRevokeTokensWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Applications.RevokeTokens( + context.TODO(), + shared.UnionString("023e105f4ecef8ad9ca31a8372d0c353"), + zero_trust.AccessApplicationRevokeTokensParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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/zero_trust/accessapplicationca.go b/zero_trust/accessapplicationca.go new file mode 100644 index 00000000000..8f8107f11bf --- /dev/null +++ b/zero_trust/accessapplicationca.go @@ -0,0 +1,592 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// AccessApplicationCAService 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 [NewAccessApplicationCAService] +// method instead. +type AccessApplicationCAService struct { + Options []option.RequestOption +} + +// NewAccessApplicationCAService 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 NewAccessApplicationCAService(opts ...option.RequestOption) (r *AccessApplicationCAService) { + r = &AccessApplicationCAService{} + r.Options = opts + return +} + +// Generates a new short-lived certificate CA and public key. +func (r *AccessApplicationCAService) New(ctx context.Context, uuid string, body AccessApplicationCANewParams, opts ...option.RequestOption) (res *AccessApplicationCANewResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessApplicationCANewResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if body.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = body.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = body.ZoneID + } + path := fmt.Sprintf("%s/%s/access/apps/%s/ca", accountOrZone, accountOrZoneID, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists short-lived certificate CAs and their public keys. +func (r *AccessApplicationCAService) List(ctx context.Context, query AccessApplicationCAListParams, opts ...option.RequestOption) (res *[]AccessCA, err error) { + opts = append(r.Options[:], opts...) + var env AccessApplicationCAListResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/access/apps/ca", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a short-lived certificate CA. +func (r *AccessApplicationCAService) Delete(ctx context.Context, uuid string, body AccessApplicationCADeleteParams, opts ...option.RequestOption) (res *AccessApplicationCADeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessApplicationCADeleteResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if body.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = body.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = body.ZoneID + } + path := fmt.Sprintf("%s/%s/access/apps/%s/ca", accountOrZone, accountOrZoneID, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a short-lived certificate CA and its public key. +func (r *AccessApplicationCAService) Get(ctx context.Context, uuid string, query AccessApplicationCAGetParams, opts ...option.RequestOption) (res *AccessApplicationCAGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessApplicationCAGetResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/access/apps/%s/ca", accountOrZone, accountOrZoneID, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AccessCA struct { + // The ID of the CA. + ID string `json:"id"` + // The Application Audience (AUD) tag. Identifies the application associated with + // the CA. + Aud string `json:"aud"` + // The public key to add to your SSH server configuration. + PublicKey string `json:"public_key"` + JSON accessCAJSON `json:"-"` +} + +// accessCAJSON contains the JSON metadata for the struct [AccessCA] +type accessCAJSON struct { + ID apijson.Field + Aud apijson.Field + PublicKey apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCA) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCAJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [zero_trust.AccessApplicationCANewResponseUnknown] or +// [shared.UnionString]. +type AccessApplicationCANewResponse interface { + ImplementsZeroTrustAccessApplicationCANewResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessApplicationCANewResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type AccessApplicationCADeleteResponse struct { + // The ID of the CA. + ID string `json:"id"` + JSON accessApplicationCADeleteResponseJSON `json:"-"` +} + +// accessApplicationCADeleteResponseJSON contains the JSON metadata for the struct +// [AccessApplicationCADeleteResponse] +type accessApplicationCADeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationCADeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationCADeleteResponseJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [zero_trust.AccessApplicationCAGetResponseUnknown] or +// [shared.UnionString]. +type AccessApplicationCAGetResponse interface { + ImplementsZeroTrustAccessApplicationCAGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessApplicationCAGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type AccessApplicationCANewParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessApplicationCANewResponseEnvelope struct { + Errors []AccessApplicationCANewResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessApplicationCANewResponseEnvelopeMessages `json:"messages,required"` + Result AccessApplicationCANewResponse `json:"result,required"` + // Whether the API call was successful + Success AccessApplicationCANewResponseEnvelopeSuccess `json:"success,required"` + JSON accessApplicationCANewResponseEnvelopeJSON `json:"-"` +} + +// accessApplicationCANewResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessApplicationCANewResponseEnvelope] +type accessApplicationCANewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationCANewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationCANewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationCANewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationCANewResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessApplicationCANewResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessApplicationCANewResponseEnvelopeErrors] +type accessApplicationCANewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationCANewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationCANewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationCANewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationCANewResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessApplicationCANewResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AccessApplicationCANewResponseEnvelopeMessages] +type accessApplicationCANewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationCANewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationCANewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessApplicationCANewResponseEnvelopeSuccess bool + +const ( + AccessApplicationCANewResponseEnvelopeSuccessTrue AccessApplicationCANewResponseEnvelopeSuccess = true +) + +type AccessApplicationCAListParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessApplicationCAListResponseEnvelope struct { + Errors []AccessApplicationCAListResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessApplicationCAListResponseEnvelopeMessages `json:"messages,required"` + Result []AccessCA `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessApplicationCAListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AccessApplicationCAListResponseEnvelopeResultInfo `json:"result_info"` + JSON accessApplicationCAListResponseEnvelopeJSON `json:"-"` +} + +// accessApplicationCAListResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessApplicationCAListResponseEnvelope] +type accessApplicationCAListResponseEnvelopeJSON 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 *AccessApplicationCAListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationCAListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationCAListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationCAListResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessApplicationCAListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessApplicationCAListResponseEnvelopeErrors] +type accessApplicationCAListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationCAListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationCAListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationCAListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationCAListResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessApplicationCAListResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AccessApplicationCAListResponseEnvelopeMessages] +type accessApplicationCAListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationCAListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationCAListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessApplicationCAListResponseEnvelopeSuccess bool + +const ( + AccessApplicationCAListResponseEnvelopeSuccessTrue AccessApplicationCAListResponseEnvelopeSuccess = true +) + +type AccessApplicationCAListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON accessApplicationCAListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// accessApplicationCAListResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [AccessApplicationCAListResponseEnvelopeResultInfo] +type accessApplicationCAListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationCAListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationCAListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationCADeleteParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessApplicationCADeleteResponseEnvelope struct { + Errors []AccessApplicationCADeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessApplicationCADeleteResponseEnvelopeMessages `json:"messages,required"` + Result AccessApplicationCADeleteResponse `json:"result,required"` + // Whether the API call was successful + Success AccessApplicationCADeleteResponseEnvelopeSuccess `json:"success,required"` + JSON accessApplicationCADeleteResponseEnvelopeJSON `json:"-"` +} + +// accessApplicationCADeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessApplicationCADeleteResponseEnvelope] +type accessApplicationCADeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationCADeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationCADeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationCADeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationCADeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessApplicationCADeleteResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [AccessApplicationCADeleteResponseEnvelopeErrors] +type accessApplicationCADeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationCADeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationCADeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationCADeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationCADeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessApplicationCADeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AccessApplicationCADeleteResponseEnvelopeMessages] +type accessApplicationCADeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationCADeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationCADeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessApplicationCADeleteResponseEnvelopeSuccess bool + +const ( + AccessApplicationCADeleteResponseEnvelopeSuccessTrue AccessApplicationCADeleteResponseEnvelopeSuccess = true +) + +type AccessApplicationCAGetParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessApplicationCAGetResponseEnvelope struct { + Errors []AccessApplicationCAGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessApplicationCAGetResponseEnvelopeMessages `json:"messages,required"` + Result AccessApplicationCAGetResponse `json:"result,required"` + // Whether the API call was successful + Success AccessApplicationCAGetResponseEnvelopeSuccess `json:"success,required"` + JSON accessApplicationCAGetResponseEnvelopeJSON `json:"-"` +} + +// accessApplicationCAGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessApplicationCAGetResponseEnvelope] +type accessApplicationCAGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationCAGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationCAGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationCAGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationCAGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessApplicationCAGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessApplicationCAGetResponseEnvelopeErrors] +type accessApplicationCAGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationCAGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationCAGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationCAGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationCAGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessApplicationCAGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AccessApplicationCAGetResponseEnvelopeMessages] +type accessApplicationCAGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationCAGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationCAGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessApplicationCAGetResponseEnvelopeSuccess bool + +const ( + AccessApplicationCAGetResponseEnvelopeSuccessTrue AccessApplicationCAGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/accessapplicationca_test.go b/zero_trust/accessapplicationca_test.go new file mode 100644 index 00000000000..7ca70a5940c --- /dev/null +++ b/zero_trust/accessapplicationca_test.go @@ -0,0 +1,135 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestAccessApplicationCANewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Applications.CAs.New( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessApplicationCANewParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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 TestAccessApplicationCAListWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Applications.CAs.List(context.TODO(), zero_trust.AccessApplicationCAListParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }) + 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 TestAccessApplicationCADeleteWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Applications.CAs.Delete( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessApplicationCADeleteParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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 TestAccessApplicationCAGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Applications.CAs.Get( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessApplicationCAGetParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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/zero_trust/accessapplicationpolicy.go b/zero_trust/accessapplicationpolicy.go new file mode 100644 index 00000000000..e9fe17f0a81 --- /dev/null +++ b/zero_trust/accessapplicationpolicy.go @@ -0,0 +1,6193 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// AccessApplicationPolicyService 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 +// [NewAccessApplicationPolicyService] method instead. +type AccessApplicationPolicyService struct { + Options []option.RequestOption +} + +// NewAccessApplicationPolicyService 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 NewAccessApplicationPolicyService(opts ...option.RequestOption) (r *AccessApplicationPolicyService) { + r = &AccessApplicationPolicyService{} + r.Options = opts + return +} + +// Create a new Access policy for an application. +func (r *AccessApplicationPolicyService) New(ctx context.Context, uuid string, params AccessApplicationPolicyNewParams, opts ...option.RequestOption) (res *AccessPolicies, err error) { + opts = append(r.Options[:], opts...) + var env AccessApplicationPolicyNewResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/access/apps/%s/policies", accountOrZone, accountOrZoneID, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update a configured Access policy. +func (r *AccessApplicationPolicyService) Update(ctx context.Context, uuid1 string, uuid string, params AccessApplicationPolicyUpdateParams, opts ...option.RequestOption) (res *AccessPolicies, err error) { + opts = append(r.Options[:], opts...) + var env AccessApplicationPolicyUpdateResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/access/apps/%s/policies/%s", accountOrZone, accountOrZoneID, uuid1, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists Access policies configured for an application. +func (r *AccessApplicationPolicyService) List(ctx context.Context, uuid string, query AccessApplicationPolicyListParams, opts ...option.RequestOption) (res *[]AccessPolicies, err error) { + opts = append(r.Options[:], opts...) + var env AccessApplicationPolicyListResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/access/apps/%s/policies", accountOrZone, accountOrZoneID, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete an Access policy. +func (r *AccessApplicationPolicyService) Delete(ctx context.Context, uuid1 string, uuid string, body AccessApplicationPolicyDeleteParams, opts ...option.RequestOption) (res *AccessApplicationPolicyDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessApplicationPolicyDeleteResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if body.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = body.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = body.ZoneID + } + path := fmt.Sprintf("%s/%s/access/apps/%s/policies/%s", accountOrZone, accountOrZoneID, uuid1, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a single Access policy. +func (r *AccessApplicationPolicyService) Get(ctx context.Context, uuid1 string, uuid string, query AccessApplicationPolicyGetParams, opts ...option.RequestOption) (res *AccessPolicies, err error) { + opts = append(r.Options[:], opts...) + var env AccessApplicationPolicyGetResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/access/apps/%s/policies/%s", accountOrZone, accountOrZoneID, uuid1, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AccessPolicies struct { + // UUID + ID string `json:"id"` + // Administrators who can approve a temporary authentication request. + ApprovalGroups []AccessPoliciesApprovalGroup `json:"approval_groups"` + // Requires the user to request access from an administrator at the start of each + // session. + ApprovalRequired bool `json:"approval_required"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The action Access will take if a user matches this policy. + Decision AccessPoliciesDecision `json:"decision"` + // Rules evaluated with a NOT logical operator. To match the policy, a user cannot + // meet any of the Exclude rules. + Exclude []AccessPoliciesExclude `json:"exclude"` + // Rules evaluated with an OR logical operator. A user needs to meet only one of + // the Include rules. + Include []AccessPoliciesInclude `json:"include"` + // Require this application to be served in an isolated browser for users matching + // this policy. 'Client Web Isolation' must be on for the account in order to use + // this feature. + IsolationRequired bool `json:"isolation_required"` + // The name of the Access policy. + Name string `json:"name"` + // The order of execution for this policy. Must be unique for each policy. + Precedence int64 `json:"precedence"` + // A custom message that will appear on the purpose justification screen. + PurposeJustificationPrompt string `json:"purpose_justification_prompt"` + // Require users to enter a justification when they log in to the application. + PurposeJustificationRequired bool `json:"purpose_justification_required"` + // Rules evaluated with an AND logical operator. To match the policy, a user must + // meet all of the Require rules. + Require []AccessPoliciesRequire `json:"require"` + // The amount of time that tokens issued for the application will be valid. Must be + // in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, + // m, h. + SessionDuration string `json:"session_duration"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessPoliciesJSON `json:"-"` +} + +// accessPoliciesJSON contains the JSON metadata for the struct [AccessPolicies] +type accessPoliciesJSON struct { + ID apijson.Field + ApprovalGroups apijson.Field + ApprovalRequired apijson.Field + CreatedAt apijson.Field + Decision apijson.Field + Exclude apijson.Field + Include apijson.Field + IsolationRequired apijson.Field + Name apijson.Field + Precedence apijson.Field + PurposeJustificationPrompt apijson.Field + PurposeJustificationRequired apijson.Field + Require apijson.Field + SessionDuration apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPolicies) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesJSON) RawJSON() string { + return r.raw +} + +// A group of email addresses that can approve a temporary authentication request. +type AccessPoliciesApprovalGroup struct { + // The number of approvals needed to obtain access. + ApprovalsNeeded float64 `json:"approvals_needed,required"` + // A list of emails that can approve the access request. + EmailAddresses []interface{} `json:"email_addresses"` + // The UUID of an re-usable email list. + EmailListUUID string `json:"email_list_uuid"` + JSON accessPoliciesApprovalGroupJSON `json:"-"` +} + +// accessPoliciesApprovalGroupJSON contains the JSON metadata for the struct +// [AccessPoliciesApprovalGroup] +type accessPoliciesApprovalGroupJSON struct { + ApprovalsNeeded apijson.Field + EmailAddresses apijson.Field + EmailListUUID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesApprovalGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesApprovalGroupJSON) RawJSON() string { + return r.raw +} + +// The action Access will take if a user matches this policy. +type AccessPoliciesDecision string + +const ( + AccessPoliciesDecisionAllow AccessPoliciesDecision = "allow" + AccessPoliciesDecisionDeny AccessPoliciesDecision = "deny" + AccessPoliciesDecisionNonIdentity AccessPoliciesDecision = "non_identity" + AccessPoliciesDecisionBypass AccessPoliciesDecision = "bypass" +) + +// Matches a specific email. +// +// Union satisfied by [zero_trust.AccessPoliciesExcludeAccessEmailRule], +// [zero_trust.AccessPoliciesExcludeAccessEmailListRule], +// [zero_trust.AccessPoliciesExcludeAccessDomainRule], +// [zero_trust.AccessPoliciesExcludeAccessEveryoneRule], +// [zero_trust.AccessPoliciesExcludeAccessIPRule], +// [zero_trust.AccessPoliciesExcludeAccessIPListRule], +// [zero_trust.AccessPoliciesExcludeAccessCertificateRule], +// [zero_trust.AccessPoliciesExcludeAccessAccessGroupRule], +// [zero_trust.AccessPoliciesExcludeAccessAzureGroupRule], +// [zero_trust.AccessPoliciesExcludeAccessGitHubOrganizationRule], +// [zero_trust.AccessPoliciesExcludeAccessGsuiteGroupRule], +// [zero_trust.AccessPoliciesExcludeAccessOktaGroupRule], +// [zero_trust.AccessPoliciesExcludeAccessSamlGroupRule], +// [zero_trust.AccessPoliciesExcludeAccessServiceTokenRule], +// [zero_trust.AccessPoliciesExcludeAccessAnyValidServiceTokenRule], +// [zero_trust.AccessPoliciesExcludeAccessExternalEvaluationRule], +// [zero_trust.AccessPoliciesExcludeAccessCountryRule], +// [zero_trust.AccessPoliciesExcludeAccessAuthenticationMethodRule] or +// [zero_trust.AccessPoliciesExcludeAccessDevicePostureRule]. +type AccessPoliciesExclude interface { + implementsZeroTrustAccessPoliciesExclude() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessPoliciesExclude)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessEmailRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessEmailListRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessDomainRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessEveryoneRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessIPRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessIPListRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessCertificateRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessAccessGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessAzureGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessGitHubOrganizationRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessGsuiteGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessOktaGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessSamlGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessServiceTokenRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessAnyValidServiceTokenRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessExternalEvaluationRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessCountryRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessAuthenticationMethodRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesExcludeAccessDevicePostureRule{}), + }, + ) +} + +// Matches a specific email. +type AccessPoliciesExcludeAccessEmailRule struct { + Email AccessPoliciesExcludeAccessEmailRuleEmail `json:"email,required"` + JSON accessPoliciesExcludeAccessEmailRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessEmailRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesExcludeAccessEmailRule] +type accessPoliciesExcludeAccessEmailRuleJSON struct { + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessEmailRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessEmailRule) implementsZeroTrustAccessPoliciesExclude() {} + +type AccessPoliciesExcludeAccessEmailRuleEmail struct { + // The email of the user. + Email string `json:"email,required" format:"email"` + JSON accessPoliciesExcludeAccessEmailRuleEmailJSON `json:"-"` +} + +// accessPoliciesExcludeAccessEmailRuleEmailJSON contains the JSON metadata for the +// struct [AccessPoliciesExcludeAccessEmailRuleEmail] +type accessPoliciesExcludeAccessEmailRuleEmailJSON struct { + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessEmailRuleEmailJSON) RawJSON() string { + return r.raw +} + +// Matches an email address from a list. +type AccessPoliciesExcludeAccessEmailListRule struct { + EmailList AccessPoliciesExcludeAccessEmailListRuleEmailList `json:"email_list,required"` + JSON accessPoliciesExcludeAccessEmailListRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessEmailListRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesExcludeAccessEmailListRule] +type accessPoliciesExcludeAccessEmailListRuleJSON struct { + EmailList apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessEmailListRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessEmailListRule) implementsZeroTrustAccessPoliciesExclude() {} + +type AccessPoliciesExcludeAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID string `json:"id,required"` + JSON accessPoliciesExcludeAccessEmailListRuleEmailListJSON `json:"-"` +} + +// accessPoliciesExcludeAccessEmailListRuleEmailListJSON contains the JSON metadata +// for the struct [AccessPoliciesExcludeAccessEmailListRuleEmailList] +type accessPoliciesExcludeAccessEmailListRuleEmailListJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessEmailListRuleEmailListJSON) RawJSON() string { + return r.raw +} + +// Match an entire email domain. +type AccessPoliciesExcludeAccessDomainRule struct { + EmailDomain AccessPoliciesExcludeAccessDomainRuleEmailDomain `json:"email_domain,required"` + JSON accessPoliciesExcludeAccessDomainRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessDomainRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesExcludeAccessDomainRule] +type accessPoliciesExcludeAccessDomainRuleJSON struct { + EmailDomain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessDomainRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessDomainRule) implementsZeroTrustAccessPoliciesExclude() {} + +type AccessPoliciesExcludeAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain string `json:"domain,required"` + JSON accessPoliciesExcludeAccessDomainRuleEmailDomainJSON `json:"-"` +} + +// accessPoliciesExcludeAccessDomainRuleEmailDomainJSON contains the JSON metadata +// for the struct [AccessPoliciesExcludeAccessDomainRuleEmailDomain] +type accessPoliciesExcludeAccessDomainRuleEmailDomainJSON struct { + Domain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessDomainRuleEmailDomainJSON) RawJSON() string { + return r.raw +} + +// Matches everyone. +type AccessPoliciesExcludeAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone interface{} `json:"everyone,required"` + JSON accessPoliciesExcludeAccessEveryoneRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessEveryoneRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesExcludeAccessEveryoneRule] +type accessPoliciesExcludeAccessEveryoneRuleJSON struct { + Everyone apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessEveryoneRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessEveryoneRule) implementsZeroTrustAccessPoliciesExclude() {} + +// Matches an IP address block. +type AccessPoliciesExcludeAccessIPRule struct { + IP AccessPoliciesExcludeAccessIPRuleIP `json:"ip,required"` + JSON accessPoliciesExcludeAccessIPRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessIPRuleJSON contains the JSON metadata for the struct +// [AccessPoliciesExcludeAccessIPRule] +type accessPoliciesExcludeAccessIPRuleJSON struct { + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessIPRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessIPRule) implementsZeroTrustAccessPoliciesExclude() {} + +type AccessPoliciesExcludeAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP string `json:"ip,required"` + JSON accessPoliciesExcludeAccessIPRuleIPJSON `json:"-"` +} + +// accessPoliciesExcludeAccessIPRuleIPJSON contains the JSON metadata for the +// struct [AccessPoliciesExcludeAccessIPRuleIP] +type accessPoliciesExcludeAccessIPRuleIPJSON struct { + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessIPRuleIPJSON) RawJSON() string { + return r.raw +} + +// Matches an IP address from a list. +type AccessPoliciesExcludeAccessIPListRule struct { + IPList AccessPoliciesExcludeAccessIPListRuleIPList `json:"ip_list,required"` + JSON accessPoliciesExcludeAccessIPListRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessIPListRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesExcludeAccessIPListRule] +type accessPoliciesExcludeAccessIPListRuleJSON struct { + IPList apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessIPListRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessIPListRule) implementsZeroTrustAccessPoliciesExclude() {} + +type AccessPoliciesExcludeAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID string `json:"id,required"` + JSON accessPoliciesExcludeAccessIPListRuleIPListJSON `json:"-"` +} + +// accessPoliciesExcludeAccessIPListRuleIPListJSON contains the JSON metadata for +// the struct [AccessPoliciesExcludeAccessIPListRuleIPList] +type accessPoliciesExcludeAccessIPListRuleIPListJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessIPListRuleIPListJSON) RawJSON() string { + return r.raw +} + +// Matches any valid client certificate. +type AccessPoliciesExcludeAccessCertificateRule struct { + Certificate interface{} `json:"certificate,required"` + JSON accessPoliciesExcludeAccessCertificateRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessCertificateRuleJSON contains the JSON metadata for +// the struct [AccessPoliciesExcludeAccessCertificateRule] +type accessPoliciesExcludeAccessCertificateRuleJSON struct { + Certificate apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessCertificateRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessCertificateRule) implementsZeroTrustAccessPoliciesExclude() {} + +// Matches an Access group. +type AccessPoliciesExcludeAccessAccessGroupRule struct { + Group AccessPoliciesExcludeAccessAccessGroupRuleGroup `json:"group,required"` + JSON accessPoliciesExcludeAccessAccessGroupRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessAccessGroupRuleJSON contains the JSON metadata for +// the struct [AccessPoliciesExcludeAccessAccessGroupRule] +type accessPoliciesExcludeAccessAccessGroupRuleJSON struct { + Group apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessAccessGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessAccessGroupRule) implementsZeroTrustAccessPoliciesExclude() {} + +type AccessPoliciesExcludeAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID string `json:"id,required"` + JSON accessPoliciesExcludeAccessAccessGroupRuleGroupJSON `json:"-"` +} + +// accessPoliciesExcludeAccessAccessGroupRuleGroupJSON contains the JSON metadata +// for the struct [AccessPoliciesExcludeAccessAccessGroupRuleGroup] +type accessPoliciesExcludeAccessAccessGroupRuleGroupJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessAccessGroupRuleGroupJSON) RawJSON() string { + return r.raw +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessPoliciesExcludeAccessAzureGroupRule struct { + AzureAd AccessPoliciesExcludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` + JSON accessPoliciesExcludeAccessAzureGroupRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessAzureGroupRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesExcludeAccessAzureGroupRule] +type accessPoliciesExcludeAccessAzureGroupRuleJSON struct { + AzureAd apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessAzureGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessAzureGroupRule) implementsZeroTrustAccessPoliciesExclude() {} + +type AccessPoliciesExcludeAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID string `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID string `json:"connection_id,required"` + JSON accessPoliciesExcludeAccessAzureGroupRuleAzureAdJSON `json:"-"` +} + +// accessPoliciesExcludeAccessAzureGroupRuleAzureAdJSON contains the JSON metadata +// for the struct [AccessPoliciesExcludeAccessAzureGroupRuleAzureAd] +type accessPoliciesExcludeAccessAzureGroupRuleAzureAdJSON struct { + ID apijson.Field + ConnectionID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { + return r.raw +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessPoliciesExcludeAccessGitHubOrganizationRule struct { + GitHubOrganization AccessPoliciesExcludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` + JSON accessPoliciesExcludeAccessGitHubOrganizationRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessGitHubOrganizationRuleJSON contains the JSON metadata +// for the struct [AccessPoliciesExcludeAccessGitHubOrganizationRule] +type accessPoliciesExcludeAccessGitHubOrganizationRuleJSON struct { + GitHubOrganization apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessGitHubOrganizationRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessPoliciesExclude() { +} + +type AccessPoliciesExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID string `json:"connection_id,required"` + // The name of the organization. + Name string `json:"name,required"` + JSON accessPoliciesExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` +} + +// accessPoliciesExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON contains +// the JSON metadata for the struct +// [AccessPoliciesExcludeAccessGitHubOrganizationRuleGitHubOrganization] +type accessPoliciesExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { + ConnectionID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { + return r.raw +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessPoliciesExcludeAccessGsuiteGroupRule struct { + Gsuite AccessPoliciesExcludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` + JSON accessPoliciesExcludeAccessGsuiteGroupRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessGsuiteGroupRuleJSON contains the JSON metadata for +// the struct [AccessPoliciesExcludeAccessGsuiteGroupRule] +type accessPoliciesExcludeAccessGsuiteGroupRuleJSON struct { + Gsuite apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessGsuiteGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessPoliciesExclude() {} + +type AccessPoliciesExcludeAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID string `json:"connection_id,required"` + // The email of the Google Workspace group. + Email string `json:"email,required"` + JSON accessPoliciesExcludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` +} + +// accessPoliciesExcludeAccessGsuiteGroupRuleGsuiteJSON contains the JSON metadata +// for the struct [AccessPoliciesExcludeAccessGsuiteGroupRuleGsuite] +type accessPoliciesExcludeAccessGsuiteGroupRuleGsuiteJSON struct { + ConnectionID apijson.Field + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { + return r.raw +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessPoliciesExcludeAccessOktaGroupRule struct { + Okta AccessPoliciesExcludeAccessOktaGroupRuleOkta `json:"okta,required"` + JSON accessPoliciesExcludeAccessOktaGroupRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessOktaGroupRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesExcludeAccessOktaGroupRule] +type accessPoliciesExcludeAccessOktaGroupRuleJSON struct { + Okta apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessOktaGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessOktaGroupRule) implementsZeroTrustAccessPoliciesExclude() {} + +type AccessPoliciesExcludeAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID string `json:"connection_id,required"` + // The email of the Okta group. + Email string `json:"email,required"` + JSON accessPoliciesExcludeAccessOktaGroupRuleOktaJSON `json:"-"` +} + +// accessPoliciesExcludeAccessOktaGroupRuleOktaJSON contains the JSON metadata for +// the struct [AccessPoliciesExcludeAccessOktaGroupRuleOkta] +type accessPoliciesExcludeAccessOktaGroupRuleOktaJSON struct { + ConnectionID apijson.Field + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessOktaGroupRuleOktaJSON) RawJSON() string { + return r.raw +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessPoliciesExcludeAccessSamlGroupRule struct { + Saml AccessPoliciesExcludeAccessSamlGroupRuleSaml `json:"saml,required"` + JSON accessPoliciesExcludeAccessSamlGroupRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessSamlGroupRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesExcludeAccessSamlGroupRule] +type accessPoliciesExcludeAccessSamlGroupRuleJSON struct { + Saml apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessSamlGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessSamlGroupRule) implementsZeroTrustAccessPoliciesExclude() {} + +type AccessPoliciesExcludeAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName string `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue string `json:"attribute_value,required"` + JSON accessPoliciesExcludeAccessSamlGroupRuleSamlJSON `json:"-"` +} + +// accessPoliciesExcludeAccessSamlGroupRuleSamlJSON contains the JSON metadata for +// the struct [AccessPoliciesExcludeAccessSamlGroupRuleSaml] +type accessPoliciesExcludeAccessSamlGroupRuleSamlJSON struct { + AttributeName apijson.Field + AttributeValue apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessSamlGroupRuleSamlJSON) RawJSON() string { + return r.raw +} + +// Matches a specific Access Service Token +type AccessPoliciesExcludeAccessServiceTokenRule struct { + ServiceToken AccessPoliciesExcludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` + JSON accessPoliciesExcludeAccessServiceTokenRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessServiceTokenRuleJSON contains the JSON metadata for +// the struct [AccessPoliciesExcludeAccessServiceTokenRule] +type accessPoliciesExcludeAccessServiceTokenRuleJSON struct { + ServiceToken apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessServiceTokenRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessServiceTokenRule) implementsZeroTrustAccessPoliciesExclude() {} + +type AccessPoliciesExcludeAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID string `json:"token_id,required"` + JSON accessPoliciesExcludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` +} + +// accessPoliciesExcludeAccessServiceTokenRuleServiceTokenJSON contains the JSON +// metadata for the struct +// [AccessPoliciesExcludeAccessServiceTokenRuleServiceToken] +type accessPoliciesExcludeAccessServiceTokenRuleServiceTokenJSON struct { + TokenID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { + return r.raw +} + +// Matches any valid Access Service Token +type AccessPoliciesExcludeAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` + JSON accessPoliciesExcludeAccessAnyValidServiceTokenRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessAnyValidServiceTokenRuleJSON contains the JSON +// metadata for the struct [AccessPoliciesExcludeAccessAnyValidServiceTokenRule] +type accessPoliciesExcludeAccessAnyValidServiceTokenRuleJSON struct { + AnyValidServiceToken apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessPoliciesExclude() { +} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessPoliciesExcludeAccessExternalEvaluationRule struct { + ExternalEvaluation AccessPoliciesExcludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` + JSON accessPoliciesExcludeAccessExternalEvaluationRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessExternalEvaluationRuleJSON contains the JSON metadata +// for the struct [AccessPoliciesExcludeAccessExternalEvaluationRule] +type accessPoliciesExcludeAccessExternalEvaluationRuleJSON struct { + ExternalEvaluation apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessExternalEvaluationRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessPoliciesExclude() { +} + +type AccessPoliciesExcludeAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL string `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL string `json:"keys_url,required"` + JSON accessPoliciesExcludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` +} + +// accessPoliciesExcludeAccessExternalEvaluationRuleExternalEvaluationJSON contains +// the JSON metadata for the struct +// [AccessPoliciesExcludeAccessExternalEvaluationRuleExternalEvaluation] +type accessPoliciesExcludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { + EvaluateURL apijson.Field + KeysURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { + return r.raw +} + +// Matches a specific country +type AccessPoliciesExcludeAccessCountryRule struct { + Geo AccessPoliciesExcludeAccessCountryRuleGeo `json:"geo,required"` + JSON accessPoliciesExcludeAccessCountryRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessCountryRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesExcludeAccessCountryRule] +type accessPoliciesExcludeAccessCountryRuleJSON struct { + Geo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessCountryRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessCountryRule) implementsZeroTrustAccessPoliciesExclude() {} + +type AccessPoliciesExcludeAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode string `json:"country_code,required"` + JSON accessPoliciesExcludeAccessCountryRuleGeoJSON `json:"-"` +} + +// accessPoliciesExcludeAccessCountryRuleGeoJSON contains the JSON metadata for the +// struct [AccessPoliciesExcludeAccessCountryRuleGeo] +type accessPoliciesExcludeAccessCountryRuleGeoJSON struct { + CountryCode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessCountryRuleGeoJSON) RawJSON() string { + return r.raw +} + +// Enforce different MFA options +type AccessPoliciesExcludeAccessAuthenticationMethodRule struct { + AuthMethod AccessPoliciesExcludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` + JSON accessPoliciesExcludeAccessAuthenticationMethodRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessAuthenticationMethodRuleJSON contains the JSON +// metadata for the struct [AccessPoliciesExcludeAccessAuthenticationMethodRule] +type accessPoliciesExcludeAccessAuthenticationMethodRuleJSON struct { + AuthMethod apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessAuthenticationMethodRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessPoliciesExclude() { +} + +type AccessPoliciesExcludeAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod string `json:"auth_method,required"` + JSON accessPoliciesExcludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` +} + +// accessPoliciesExcludeAccessAuthenticationMethodRuleAuthMethodJSON contains the +// JSON metadata for the struct +// [AccessPoliciesExcludeAccessAuthenticationMethodRuleAuthMethod] +type accessPoliciesExcludeAccessAuthenticationMethodRuleAuthMethodJSON struct { + AuthMethod apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { + return r.raw +} + +// Enforces a device posture rule has run successfully +type AccessPoliciesExcludeAccessDevicePostureRule struct { + DevicePosture AccessPoliciesExcludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` + JSON accessPoliciesExcludeAccessDevicePostureRuleJSON `json:"-"` +} + +// accessPoliciesExcludeAccessDevicePostureRuleJSON contains the JSON metadata for +// the struct [AccessPoliciesExcludeAccessDevicePostureRule] +type accessPoliciesExcludeAccessDevicePostureRuleJSON struct { + DevicePosture apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessDevicePostureRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesExcludeAccessDevicePostureRule) implementsZeroTrustAccessPoliciesExclude() {} + +type AccessPoliciesExcludeAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid string `json:"integration_uid,required"` + JSON accessPoliciesExcludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` +} + +// accessPoliciesExcludeAccessDevicePostureRuleDevicePostureJSON contains the JSON +// metadata for the struct +// [AccessPoliciesExcludeAccessDevicePostureRuleDevicePosture] +type accessPoliciesExcludeAccessDevicePostureRuleDevicePostureJSON struct { + IntegrationUid apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesExcludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesExcludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { + return r.raw +} + +// Matches a specific email. +// +// Union satisfied by [zero_trust.AccessPoliciesIncludeAccessEmailRule], +// [zero_trust.AccessPoliciesIncludeAccessEmailListRule], +// [zero_trust.AccessPoliciesIncludeAccessDomainRule], +// [zero_trust.AccessPoliciesIncludeAccessEveryoneRule], +// [zero_trust.AccessPoliciesIncludeAccessIPRule], +// [zero_trust.AccessPoliciesIncludeAccessIPListRule], +// [zero_trust.AccessPoliciesIncludeAccessCertificateRule], +// [zero_trust.AccessPoliciesIncludeAccessAccessGroupRule], +// [zero_trust.AccessPoliciesIncludeAccessAzureGroupRule], +// [zero_trust.AccessPoliciesIncludeAccessGitHubOrganizationRule], +// [zero_trust.AccessPoliciesIncludeAccessGsuiteGroupRule], +// [zero_trust.AccessPoliciesIncludeAccessOktaGroupRule], +// [zero_trust.AccessPoliciesIncludeAccessSamlGroupRule], +// [zero_trust.AccessPoliciesIncludeAccessServiceTokenRule], +// [zero_trust.AccessPoliciesIncludeAccessAnyValidServiceTokenRule], +// [zero_trust.AccessPoliciesIncludeAccessExternalEvaluationRule], +// [zero_trust.AccessPoliciesIncludeAccessCountryRule], +// [zero_trust.AccessPoliciesIncludeAccessAuthenticationMethodRule] or +// [zero_trust.AccessPoliciesIncludeAccessDevicePostureRule]. +type AccessPoliciesInclude interface { + implementsZeroTrustAccessPoliciesInclude() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessPoliciesInclude)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessEmailRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessEmailListRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessDomainRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessEveryoneRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessIPRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessIPListRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessCertificateRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessAccessGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessAzureGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessGitHubOrganizationRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessGsuiteGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessOktaGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessSamlGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessServiceTokenRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessAnyValidServiceTokenRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessExternalEvaluationRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessCountryRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessAuthenticationMethodRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesIncludeAccessDevicePostureRule{}), + }, + ) +} + +// Matches a specific email. +type AccessPoliciesIncludeAccessEmailRule struct { + Email AccessPoliciesIncludeAccessEmailRuleEmail `json:"email,required"` + JSON accessPoliciesIncludeAccessEmailRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessEmailRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesIncludeAccessEmailRule] +type accessPoliciesIncludeAccessEmailRuleJSON struct { + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessEmailRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessEmailRule) implementsZeroTrustAccessPoliciesInclude() {} + +type AccessPoliciesIncludeAccessEmailRuleEmail struct { + // The email of the user. + Email string `json:"email,required" format:"email"` + JSON accessPoliciesIncludeAccessEmailRuleEmailJSON `json:"-"` +} + +// accessPoliciesIncludeAccessEmailRuleEmailJSON contains the JSON metadata for the +// struct [AccessPoliciesIncludeAccessEmailRuleEmail] +type accessPoliciesIncludeAccessEmailRuleEmailJSON struct { + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessEmailRuleEmailJSON) RawJSON() string { + return r.raw +} + +// Matches an email address from a list. +type AccessPoliciesIncludeAccessEmailListRule struct { + EmailList AccessPoliciesIncludeAccessEmailListRuleEmailList `json:"email_list,required"` + JSON accessPoliciesIncludeAccessEmailListRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessEmailListRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesIncludeAccessEmailListRule] +type accessPoliciesIncludeAccessEmailListRuleJSON struct { + EmailList apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessEmailListRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessEmailListRule) implementsZeroTrustAccessPoliciesInclude() {} + +type AccessPoliciesIncludeAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID string `json:"id,required"` + JSON accessPoliciesIncludeAccessEmailListRuleEmailListJSON `json:"-"` +} + +// accessPoliciesIncludeAccessEmailListRuleEmailListJSON contains the JSON metadata +// for the struct [AccessPoliciesIncludeAccessEmailListRuleEmailList] +type accessPoliciesIncludeAccessEmailListRuleEmailListJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessEmailListRuleEmailListJSON) RawJSON() string { + return r.raw +} + +// Match an entire email domain. +type AccessPoliciesIncludeAccessDomainRule struct { + EmailDomain AccessPoliciesIncludeAccessDomainRuleEmailDomain `json:"email_domain,required"` + JSON accessPoliciesIncludeAccessDomainRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessDomainRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesIncludeAccessDomainRule] +type accessPoliciesIncludeAccessDomainRuleJSON struct { + EmailDomain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessDomainRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessDomainRule) implementsZeroTrustAccessPoliciesInclude() {} + +type AccessPoliciesIncludeAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain string `json:"domain,required"` + JSON accessPoliciesIncludeAccessDomainRuleEmailDomainJSON `json:"-"` +} + +// accessPoliciesIncludeAccessDomainRuleEmailDomainJSON contains the JSON metadata +// for the struct [AccessPoliciesIncludeAccessDomainRuleEmailDomain] +type accessPoliciesIncludeAccessDomainRuleEmailDomainJSON struct { + Domain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessDomainRuleEmailDomainJSON) RawJSON() string { + return r.raw +} + +// Matches everyone. +type AccessPoliciesIncludeAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone interface{} `json:"everyone,required"` + JSON accessPoliciesIncludeAccessEveryoneRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessEveryoneRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesIncludeAccessEveryoneRule] +type accessPoliciesIncludeAccessEveryoneRuleJSON struct { + Everyone apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessEveryoneRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessEveryoneRule) implementsZeroTrustAccessPoliciesInclude() {} + +// Matches an IP address block. +type AccessPoliciesIncludeAccessIPRule struct { + IP AccessPoliciesIncludeAccessIPRuleIP `json:"ip,required"` + JSON accessPoliciesIncludeAccessIPRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessIPRuleJSON contains the JSON metadata for the struct +// [AccessPoliciesIncludeAccessIPRule] +type accessPoliciesIncludeAccessIPRuleJSON struct { + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessIPRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessIPRule) implementsZeroTrustAccessPoliciesInclude() {} + +type AccessPoliciesIncludeAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP string `json:"ip,required"` + JSON accessPoliciesIncludeAccessIPRuleIPJSON `json:"-"` +} + +// accessPoliciesIncludeAccessIPRuleIPJSON contains the JSON metadata for the +// struct [AccessPoliciesIncludeAccessIPRuleIP] +type accessPoliciesIncludeAccessIPRuleIPJSON struct { + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessIPRuleIPJSON) RawJSON() string { + return r.raw +} + +// Matches an IP address from a list. +type AccessPoliciesIncludeAccessIPListRule struct { + IPList AccessPoliciesIncludeAccessIPListRuleIPList `json:"ip_list,required"` + JSON accessPoliciesIncludeAccessIPListRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessIPListRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesIncludeAccessIPListRule] +type accessPoliciesIncludeAccessIPListRuleJSON struct { + IPList apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessIPListRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessIPListRule) implementsZeroTrustAccessPoliciesInclude() {} + +type AccessPoliciesIncludeAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID string `json:"id,required"` + JSON accessPoliciesIncludeAccessIPListRuleIPListJSON `json:"-"` +} + +// accessPoliciesIncludeAccessIPListRuleIPListJSON contains the JSON metadata for +// the struct [AccessPoliciesIncludeAccessIPListRuleIPList] +type accessPoliciesIncludeAccessIPListRuleIPListJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessIPListRuleIPListJSON) RawJSON() string { + return r.raw +} + +// Matches any valid client certificate. +type AccessPoliciesIncludeAccessCertificateRule struct { + Certificate interface{} `json:"certificate,required"` + JSON accessPoliciesIncludeAccessCertificateRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessCertificateRuleJSON contains the JSON metadata for +// the struct [AccessPoliciesIncludeAccessCertificateRule] +type accessPoliciesIncludeAccessCertificateRuleJSON struct { + Certificate apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessCertificateRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessCertificateRule) implementsZeroTrustAccessPoliciesInclude() {} + +// Matches an Access group. +type AccessPoliciesIncludeAccessAccessGroupRule struct { + Group AccessPoliciesIncludeAccessAccessGroupRuleGroup `json:"group,required"` + JSON accessPoliciesIncludeAccessAccessGroupRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessAccessGroupRuleJSON contains the JSON metadata for +// the struct [AccessPoliciesIncludeAccessAccessGroupRule] +type accessPoliciesIncludeAccessAccessGroupRuleJSON struct { + Group apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessAccessGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessAccessGroupRule) implementsZeroTrustAccessPoliciesInclude() {} + +type AccessPoliciesIncludeAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID string `json:"id,required"` + JSON accessPoliciesIncludeAccessAccessGroupRuleGroupJSON `json:"-"` +} + +// accessPoliciesIncludeAccessAccessGroupRuleGroupJSON contains the JSON metadata +// for the struct [AccessPoliciesIncludeAccessAccessGroupRuleGroup] +type accessPoliciesIncludeAccessAccessGroupRuleGroupJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessAccessGroupRuleGroupJSON) RawJSON() string { + return r.raw +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessPoliciesIncludeAccessAzureGroupRule struct { + AzureAd AccessPoliciesIncludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` + JSON accessPoliciesIncludeAccessAzureGroupRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessAzureGroupRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesIncludeAccessAzureGroupRule] +type accessPoliciesIncludeAccessAzureGroupRuleJSON struct { + AzureAd apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessAzureGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessAzureGroupRule) implementsZeroTrustAccessPoliciesInclude() {} + +type AccessPoliciesIncludeAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID string `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID string `json:"connection_id,required"` + JSON accessPoliciesIncludeAccessAzureGroupRuleAzureAdJSON `json:"-"` +} + +// accessPoliciesIncludeAccessAzureGroupRuleAzureAdJSON contains the JSON metadata +// for the struct [AccessPoliciesIncludeAccessAzureGroupRuleAzureAd] +type accessPoliciesIncludeAccessAzureGroupRuleAzureAdJSON struct { + ID apijson.Field + ConnectionID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { + return r.raw +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessPoliciesIncludeAccessGitHubOrganizationRule struct { + GitHubOrganization AccessPoliciesIncludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` + JSON accessPoliciesIncludeAccessGitHubOrganizationRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessGitHubOrganizationRuleJSON contains the JSON metadata +// for the struct [AccessPoliciesIncludeAccessGitHubOrganizationRule] +type accessPoliciesIncludeAccessGitHubOrganizationRuleJSON struct { + GitHubOrganization apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessGitHubOrganizationRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessPoliciesInclude() { +} + +type AccessPoliciesIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID string `json:"connection_id,required"` + // The name of the organization. + Name string `json:"name,required"` + JSON accessPoliciesIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` +} + +// accessPoliciesIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON contains +// the JSON metadata for the struct +// [AccessPoliciesIncludeAccessGitHubOrganizationRuleGitHubOrganization] +type accessPoliciesIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { + ConnectionID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { + return r.raw +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessPoliciesIncludeAccessGsuiteGroupRule struct { + Gsuite AccessPoliciesIncludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` + JSON accessPoliciesIncludeAccessGsuiteGroupRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessGsuiteGroupRuleJSON contains the JSON metadata for +// the struct [AccessPoliciesIncludeAccessGsuiteGroupRule] +type accessPoliciesIncludeAccessGsuiteGroupRuleJSON struct { + Gsuite apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessGsuiteGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessPoliciesInclude() {} + +type AccessPoliciesIncludeAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID string `json:"connection_id,required"` + // The email of the Google Workspace group. + Email string `json:"email,required"` + JSON accessPoliciesIncludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` +} + +// accessPoliciesIncludeAccessGsuiteGroupRuleGsuiteJSON contains the JSON metadata +// for the struct [AccessPoliciesIncludeAccessGsuiteGroupRuleGsuite] +type accessPoliciesIncludeAccessGsuiteGroupRuleGsuiteJSON struct { + ConnectionID apijson.Field + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { + return r.raw +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessPoliciesIncludeAccessOktaGroupRule struct { + Okta AccessPoliciesIncludeAccessOktaGroupRuleOkta `json:"okta,required"` + JSON accessPoliciesIncludeAccessOktaGroupRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessOktaGroupRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesIncludeAccessOktaGroupRule] +type accessPoliciesIncludeAccessOktaGroupRuleJSON struct { + Okta apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessOktaGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessOktaGroupRule) implementsZeroTrustAccessPoliciesInclude() {} + +type AccessPoliciesIncludeAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID string `json:"connection_id,required"` + // The email of the Okta group. + Email string `json:"email,required"` + JSON accessPoliciesIncludeAccessOktaGroupRuleOktaJSON `json:"-"` +} + +// accessPoliciesIncludeAccessOktaGroupRuleOktaJSON contains the JSON metadata for +// the struct [AccessPoliciesIncludeAccessOktaGroupRuleOkta] +type accessPoliciesIncludeAccessOktaGroupRuleOktaJSON struct { + ConnectionID apijson.Field + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessOktaGroupRuleOktaJSON) RawJSON() string { + return r.raw +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessPoliciesIncludeAccessSamlGroupRule struct { + Saml AccessPoliciesIncludeAccessSamlGroupRuleSaml `json:"saml,required"` + JSON accessPoliciesIncludeAccessSamlGroupRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessSamlGroupRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesIncludeAccessSamlGroupRule] +type accessPoliciesIncludeAccessSamlGroupRuleJSON struct { + Saml apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessSamlGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessSamlGroupRule) implementsZeroTrustAccessPoliciesInclude() {} + +type AccessPoliciesIncludeAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName string `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue string `json:"attribute_value,required"` + JSON accessPoliciesIncludeAccessSamlGroupRuleSamlJSON `json:"-"` +} + +// accessPoliciesIncludeAccessSamlGroupRuleSamlJSON contains the JSON metadata for +// the struct [AccessPoliciesIncludeAccessSamlGroupRuleSaml] +type accessPoliciesIncludeAccessSamlGroupRuleSamlJSON struct { + AttributeName apijson.Field + AttributeValue apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessSamlGroupRuleSamlJSON) RawJSON() string { + return r.raw +} + +// Matches a specific Access Service Token +type AccessPoliciesIncludeAccessServiceTokenRule struct { + ServiceToken AccessPoliciesIncludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` + JSON accessPoliciesIncludeAccessServiceTokenRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessServiceTokenRuleJSON contains the JSON metadata for +// the struct [AccessPoliciesIncludeAccessServiceTokenRule] +type accessPoliciesIncludeAccessServiceTokenRuleJSON struct { + ServiceToken apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessServiceTokenRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessServiceTokenRule) implementsZeroTrustAccessPoliciesInclude() {} + +type AccessPoliciesIncludeAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID string `json:"token_id,required"` + JSON accessPoliciesIncludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` +} + +// accessPoliciesIncludeAccessServiceTokenRuleServiceTokenJSON contains the JSON +// metadata for the struct +// [AccessPoliciesIncludeAccessServiceTokenRuleServiceToken] +type accessPoliciesIncludeAccessServiceTokenRuleServiceTokenJSON struct { + TokenID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { + return r.raw +} + +// Matches any valid Access Service Token +type AccessPoliciesIncludeAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` + JSON accessPoliciesIncludeAccessAnyValidServiceTokenRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessAnyValidServiceTokenRuleJSON contains the JSON +// metadata for the struct [AccessPoliciesIncludeAccessAnyValidServiceTokenRule] +type accessPoliciesIncludeAccessAnyValidServiceTokenRuleJSON struct { + AnyValidServiceToken apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessPoliciesInclude() { +} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessPoliciesIncludeAccessExternalEvaluationRule struct { + ExternalEvaluation AccessPoliciesIncludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` + JSON accessPoliciesIncludeAccessExternalEvaluationRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessExternalEvaluationRuleJSON contains the JSON metadata +// for the struct [AccessPoliciesIncludeAccessExternalEvaluationRule] +type accessPoliciesIncludeAccessExternalEvaluationRuleJSON struct { + ExternalEvaluation apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessExternalEvaluationRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessPoliciesInclude() { +} + +type AccessPoliciesIncludeAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL string `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL string `json:"keys_url,required"` + JSON accessPoliciesIncludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` +} + +// accessPoliciesIncludeAccessExternalEvaluationRuleExternalEvaluationJSON contains +// the JSON metadata for the struct +// [AccessPoliciesIncludeAccessExternalEvaluationRuleExternalEvaluation] +type accessPoliciesIncludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { + EvaluateURL apijson.Field + KeysURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { + return r.raw +} + +// Matches a specific country +type AccessPoliciesIncludeAccessCountryRule struct { + Geo AccessPoliciesIncludeAccessCountryRuleGeo `json:"geo,required"` + JSON accessPoliciesIncludeAccessCountryRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessCountryRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesIncludeAccessCountryRule] +type accessPoliciesIncludeAccessCountryRuleJSON struct { + Geo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessCountryRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessCountryRule) implementsZeroTrustAccessPoliciesInclude() {} + +type AccessPoliciesIncludeAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode string `json:"country_code,required"` + JSON accessPoliciesIncludeAccessCountryRuleGeoJSON `json:"-"` +} + +// accessPoliciesIncludeAccessCountryRuleGeoJSON contains the JSON metadata for the +// struct [AccessPoliciesIncludeAccessCountryRuleGeo] +type accessPoliciesIncludeAccessCountryRuleGeoJSON struct { + CountryCode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessCountryRuleGeoJSON) RawJSON() string { + return r.raw +} + +// Enforce different MFA options +type AccessPoliciesIncludeAccessAuthenticationMethodRule struct { + AuthMethod AccessPoliciesIncludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` + JSON accessPoliciesIncludeAccessAuthenticationMethodRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessAuthenticationMethodRuleJSON contains the JSON +// metadata for the struct [AccessPoliciesIncludeAccessAuthenticationMethodRule] +type accessPoliciesIncludeAccessAuthenticationMethodRuleJSON struct { + AuthMethod apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessAuthenticationMethodRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessPoliciesInclude() { +} + +type AccessPoliciesIncludeAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod string `json:"auth_method,required"` + JSON accessPoliciesIncludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` +} + +// accessPoliciesIncludeAccessAuthenticationMethodRuleAuthMethodJSON contains the +// JSON metadata for the struct +// [AccessPoliciesIncludeAccessAuthenticationMethodRuleAuthMethod] +type accessPoliciesIncludeAccessAuthenticationMethodRuleAuthMethodJSON struct { + AuthMethod apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { + return r.raw +} + +// Enforces a device posture rule has run successfully +type AccessPoliciesIncludeAccessDevicePostureRule struct { + DevicePosture AccessPoliciesIncludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` + JSON accessPoliciesIncludeAccessDevicePostureRuleJSON `json:"-"` +} + +// accessPoliciesIncludeAccessDevicePostureRuleJSON contains the JSON metadata for +// the struct [AccessPoliciesIncludeAccessDevicePostureRule] +type accessPoliciesIncludeAccessDevicePostureRuleJSON struct { + DevicePosture apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessDevicePostureRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesIncludeAccessDevicePostureRule) implementsZeroTrustAccessPoliciesInclude() {} + +type AccessPoliciesIncludeAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid string `json:"integration_uid,required"` + JSON accessPoliciesIncludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` +} + +// accessPoliciesIncludeAccessDevicePostureRuleDevicePostureJSON contains the JSON +// metadata for the struct +// [AccessPoliciesIncludeAccessDevicePostureRuleDevicePosture] +type accessPoliciesIncludeAccessDevicePostureRuleDevicePostureJSON struct { + IntegrationUid apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesIncludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesIncludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { + return r.raw +} + +// Matches a specific email. +// +// Union satisfied by [zero_trust.AccessPoliciesRequireAccessEmailRule], +// [zero_trust.AccessPoliciesRequireAccessEmailListRule], +// [zero_trust.AccessPoliciesRequireAccessDomainRule], +// [zero_trust.AccessPoliciesRequireAccessEveryoneRule], +// [zero_trust.AccessPoliciesRequireAccessIPRule], +// [zero_trust.AccessPoliciesRequireAccessIPListRule], +// [zero_trust.AccessPoliciesRequireAccessCertificateRule], +// [zero_trust.AccessPoliciesRequireAccessAccessGroupRule], +// [zero_trust.AccessPoliciesRequireAccessAzureGroupRule], +// [zero_trust.AccessPoliciesRequireAccessGitHubOrganizationRule], +// [zero_trust.AccessPoliciesRequireAccessGsuiteGroupRule], +// [zero_trust.AccessPoliciesRequireAccessOktaGroupRule], +// [zero_trust.AccessPoliciesRequireAccessSamlGroupRule], +// [zero_trust.AccessPoliciesRequireAccessServiceTokenRule], +// [zero_trust.AccessPoliciesRequireAccessAnyValidServiceTokenRule], +// [zero_trust.AccessPoliciesRequireAccessExternalEvaluationRule], +// [zero_trust.AccessPoliciesRequireAccessCountryRule], +// [zero_trust.AccessPoliciesRequireAccessAuthenticationMethodRule] or +// [zero_trust.AccessPoliciesRequireAccessDevicePostureRule]. +type AccessPoliciesRequire interface { + implementsZeroTrustAccessPoliciesRequire() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessPoliciesRequire)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessEmailRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessEmailListRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessDomainRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessEveryoneRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessIPRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessIPListRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessCertificateRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessAccessGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessAzureGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessGitHubOrganizationRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessGsuiteGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessOktaGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessSamlGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessServiceTokenRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessAnyValidServiceTokenRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessExternalEvaluationRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessCountryRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessAuthenticationMethodRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessPoliciesRequireAccessDevicePostureRule{}), + }, + ) +} + +// Matches a specific email. +type AccessPoliciesRequireAccessEmailRule struct { + Email AccessPoliciesRequireAccessEmailRuleEmail `json:"email,required"` + JSON accessPoliciesRequireAccessEmailRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessEmailRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesRequireAccessEmailRule] +type accessPoliciesRequireAccessEmailRuleJSON struct { + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessEmailRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessEmailRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessEmailRule) implementsZeroTrustAccessPoliciesRequire() {} + +type AccessPoliciesRequireAccessEmailRuleEmail struct { + // The email of the user. + Email string `json:"email,required" format:"email"` + JSON accessPoliciesRequireAccessEmailRuleEmailJSON `json:"-"` +} + +// accessPoliciesRequireAccessEmailRuleEmailJSON contains the JSON metadata for the +// struct [AccessPoliciesRequireAccessEmailRuleEmail] +type accessPoliciesRequireAccessEmailRuleEmailJSON struct { + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessEmailRuleEmailJSON) RawJSON() string { + return r.raw +} + +// Matches an email address from a list. +type AccessPoliciesRequireAccessEmailListRule struct { + EmailList AccessPoliciesRequireAccessEmailListRuleEmailList `json:"email_list,required"` + JSON accessPoliciesRequireAccessEmailListRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessEmailListRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesRequireAccessEmailListRule] +type accessPoliciesRequireAccessEmailListRuleJSON struct { + EmailList apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessEmailListRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessEmailListRule) implementsZeroTrustAccessPoliciesRequire() {} + +type AccessPoliciesRequireAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID string `json:"id,required"` + JSON accessPoliciesRequireAccessEmailListRuleEmailListJSON `json:"-"` +} + +// accessPoliciesRequireAccessEmailListRuleEmailListJSON contains the JSON metadata +// for the struct [AccessPoliciesRequireAccessEmailListRuleEmailList] +type accessPoliciesRequireAccessEmailListRuleEmailListJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessEmailListRuleEmailListJSON) RawJSON() string { + return r.raw +} + +// Match an entire email domain. +type AccessPoliciesRequireAccessDomainRule struct { + EmailDomain AccessPoliciesRequireAccessDomainRuleEmailDomain `json:"email_domain,required"` + JSON accessPoliciesRequireAccessDomainRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessDomainRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesRequireAccessDomainRule] +type accessPoliciesRequireAccessDomainRuleJSON struct { + EmailDomain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessDomainRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessDomainRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessDomainRule) implementsZeroTrustAccessPoliciesRequire() {} + +type AccessPoliciesRequireAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain string `json:"domain,required"` + JSON accessPoliciesRequireAccessDomainRuleEmailDomainJSON `json:"-"` +} + +// accessPoliciesRequireAccessDomainRuleEmailDomainJSON contains the JSON metadata +// for the struct [AccessPoliciesRequireAccessDomainRuleEmailDomain] +type accessPoliciesRequireAccessDomainRuleEmailDomainJSON struct { + Domain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessDomainRuleEmailDomainJSON) RawJSON() string { + return r.raw +} + +// Matches everyone. +type AccessPoliciesRequireAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone interface{} `json:"everyone,required"` + JSON accessPoliciesRequireAccessEveryoneRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessEveryoneRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesRequireAccessEveryoneRule] +type accessPoliciesRequireAccessEveryoneRuleJSON struct { + Everyone apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessEveryoneRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessEveryoneRule) implementsZeroTrustAccessPoliciesRequire() {} + +// Matches an IP address block. +type AccessPoliciesRequireAccessIPRule struct { + IP AccessPoliciesRequireAccessIPRuleIP `json:"ip,required"` + JSON accessPoliciesRequireAccessIPRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessIPRuleJSON contains the JSON metadata for the struct +// [AccessPoliciesRequireAccessIPRule] +type accessPoliciesRequireAccessIPRuleJSON struct { + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessIPRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessIPRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessIPRule) implementsZeroTrustAccessPoliciesRequire() {} + +type AccessPoliciesRequireAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP string `json:"ip,required"` + JSON accessPoliciesRequireAccessIPRuleIPJSON `json:"-"` +} + +// accessPoliciesRequireAccessIPRuleIPJSON contains the JSON metadata for the +// struct [AccessPoliciesRequireAccessIPRuleIP] +type accessPoliciesRequireAccessIPRuleIPJSON struct { + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessIPRuleIPJSON) RawJSON() string { + return r.raw +} + +// Matches an IP address from a list. +type AccessPoliciesRequireAccessIPListRule struct { + IPList AccessPoliciesRequireAccessIPListRuleIPList `json:"ip_list,required"` + JSON accessPoliciesRequireAccessIPListRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessIPListRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesRequireAccessIPListRule] +type accessPoliciesRequireAccessIPListRuleJSON struct { + IPList apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessIPListRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessIPListRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessIPListRule) implementsZeroTrustAccessPoliciesRequire() {} + +type AccessPoliciesRequireAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID string `json:"id,required"` + JSON accessPoliciesRequireAccessIPListRuleIPListJSON `json:"-"` +} + +// accessPoliciesRequireAccessIPListRuleIPListJSON contains the JSON metadata for +// the struct [AccessPoliciesRequireAccessIPListRuleIPList] +type accessPoliciesRequireAccessIPListRuleIPListJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessIPListRuleIPListJSON) RawJSON() string { + return r.raw +} + +// Matches any valid client certificate. +type AccessPoliciesRequireAccessCertificateRule struct { + Certificate interface{} `json:"certificate,required"` + JSON accessPoliciesRequireAccessCertificateRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessCertificateRuleJSON contains the JSON metadata for +// the struct [AccessPoliciesRequireAccessCertificateRule] +type accessPoliciesRequireAccessCertificateRuleJSON struct { + Certificate apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessCertificateRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessCertificateRule) implementsZeroTrustAccessPoliciesRequire() {} + +// Matches an Access group. +type AccessPoliciesRequireAccessAccessGroupRule struct { + Group AccessPoliciesRequireAccessAccessGroupRuleGroup `json:"group,required"` + JSON accessPoliciesRequireAccessAccessGroupRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessAccessGroupRuleJSON contains the JSON metadata for +// the struct [AccessPoliciesRequireAccessAccessGroupRule] +type accessPoliciesRequireAccessAccessGroupRuleJSON struct { + Group apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessAccessGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessAccessGroupRule) implementsZeroTrustAccessPoliciesRequire() {} + +type AccessPoliciesRequireAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID string `json:"id,required"` + JSON accessPoliciesRequireAccessAccessGroupRuleGroupJSON `json:"-"` +} + +// accessPoliciesRequireAccessAccessGroupRuleGroupJSON contains the JSON metadata +// for the struct [AccessPoliciesRequireAccessAccessGroupRuleGroup] +type accessPoliciesRequireAccessAccessGroupRuleGroupJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessAccessGroupRuleGroupJSON) RawJSON() string { + return r.raw +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessPoliciesRequireAccessAzureGroupRule struct { + AzureAd AccessPoliciesRequireAccessAzureGroupRuleAzureAd `json:"azureAD,required"` + JSON accessPoliciesRequireAccessAzureGroupRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessAzureGroupRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesRequireAccessAzureGroupRule] +type accessPoliciesRequireAccessAzureGroupRuleJSON struct { + AzureAd apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessAzureGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessAzureGroupRule) implementsZeroTrustAccessPoliciesRequire() {} + +type AccessPoliciesRequireAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID string `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID string `json:"connection_id,required"` + JSON accessPoliciesRequireAccessAzureGroupRuleAzureAdJSON `json:"-"` +} + +// accessPoliciesRequireAccessAzureGroupRuleAzureAdJSON contains the JSON metadata +// for the struct [AccessPoliciesRequireAccessAzureGroupRuleAzureAd] +type accessPoliciesRequireAccessAzureGroupRuleAzureAdJSON struct { + ID apijson.Field + ConnectionID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessAzureGroupRuleAzureAdJSON) RawJSON() string { + return r.raw +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessPoliciesRequireAccessGitHubOrganizationRule struct { + GitHubOrganization AccessPoliciesRequireAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` + JSON accessPoliciesRequireAccessGitHubOrganizationRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessGitHubOrganizationRuleJSON contains the JSON metadata +// for the struct [AccessPoliciesRequireAccessGitHubOrganizationRule] +type accessPoliciesRequireAccessGitHubOrganizationRuleJSON struct { + GitHubOrganization apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessGitHubOrganizationRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessPoliciesRequire() { +} + +type AccessPoliciesRequireAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID string `json:"connection_id,required"` + // The name of the organization. + Name string `json:"name,required"` + JSON accessPoliciesRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` +} + +// accessPoliciesRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON contains +// the JSON metadata for the struct +// [AccessPoliciesRequireAccessGitHubOrganizationRuleGitHubOrganization] +type accessPoliciesRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { + ConnectionID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { + return r.raw +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessPoliciesRequireAccessGsuiteGroupRule struct { + Gsuite AccessPoliciesRequireAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` + JSON accessPoliciesRequireAccessGsuiteGroupRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessGsuiteGroupRuleJSON contains the JSON metadata for +// the struct [AccessPoliciesRequireAccessGsuiteGroupRule] +type accessPoliciesRequireAccessGsuiteGroupRuleJSON struct { + Gsuite apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessGsuiteGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessGsuiteGroupRule) implementsZeroTrustAccessPoliciesRequire() {} + +type AccessPoliciesRequireAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID string `json:"connection_id,required"` + // The email of the Google Workspace group. + Email string `json:"email,required"` + JSON accessPoliciesRequireAccessGsuiteGroupRuleGsuiteJSON `json:"-"` +} + +// accessPoliciesRequireAccessGsuiteGroupRuleGsuiteJSON contains the JSON metadata +// for the struct [AccessPoliciesRequireAccessGsuiteGroupRuleGsuite] +type accessPoliciesRequireAccessGsuiteGroupRuleGsuiteJSON struct { + ConnectionID apijson.Field + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { + return r.raw +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessPoliciesRequireAccessOktaGroupRule struct { + Okta AccessPoliciesRequireAccessOktaGroupRuleOkta `json:"okta,required"` + JSON accessPoliciesRequireAccessOktaGroupRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessOktaGroupRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesRequireAccessOktaGroupRule] +type accessPoliciesRequireAccessOktaGroupRuleJSON struct { + Okta apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessOktaGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessOktaGroupRule) implementsZeroTrustAccessPoliciesRequire() {} + +type AccessPoliciesRequireAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID string `json:"connection_id,required"` + // The email of the Okta group. + Email string `json:"email,required"` + JSON accessPoliciesRequireAccessOktaGroupRuleOktaJSON `json:"-"` +} + +// accessPoliciesRequireAccessOktaGroupRuleOktaJSON contains the JSON metadata for +// the struct [AccessPoliciesRequireAccessOktaGroupRuleOkta] +type accessPoliciesRequireAccessOktaGroupRuleOktaJSON struct { + ConnectionID apijson.Field + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessOktaGroupRuleOktaJSON) RawJSON() string { + return r.raw +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessPoliciesRequireAccessSamlGroupRule struct { + Saml AccessPoliciesRequireAccessSamlGroupRuleSaml `json:"saml,required"` + JSON accessPoliciesRequireAccessSamlGroupRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessSamlGroupRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesRequireAccessSamlGroupRule] +type accessPoliciesRequireAccessSamlGroupRuleJSON struct { + Saml apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessSamlGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessSamlGroupRule) implementsZeroTrustAccessPoliciesRequire() {} + +type AccessPoliciesRequireAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName string `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue string `json:"attribute_value,required"` + JSON accessPoliciesRequireAccessSamlGroupRuleSamlJSON `json:"-"` +} + +// accessPoliciesRequireAccessSamlGroupRuleSamlJSON contains the JSON metadata for +// the struct [AccessPoliciesRequireAccessSamlGroupRuleSaml] +type accessPoliciesRequireAccessSamlGroupRuleSamlJSON struct { + AttributeName apijson.Field + AttributeValue apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessSamlGroupRuleSamlJSON) RawJSON() string { + return r.raw +} + +// Matches a specific Access Service Token +type AccessPoliciesRequireAccessServiceTokenRule struct { + ServiceToken AccessPoliciesRequireAccessServiceTokenRuleServiceToken `json:"service_token,required"` + JSON accessPoliciesRequireAccessServiceTokenRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessServiceTokenRuleJSON contains the JSON metadata for +// the struct [AccessPoliciesRequireAccessServiceTokenRule] +type accessPoliciesRequireAccessServiceTokenRuleJSON struct { + ServiceToken apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessServiceTokenRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessServiceTokenRule) implementsZeroTrustAccessPoliciesRequire() {} + +type AccessPoliciesRequireAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID string `json:"token_id,required"` + JSON accessPoliciesRequireAccessServiceTokenRuleServiceTokenJSON `json:"-"` +} + +// accessPoliciesRequireAccessServiceTokenRuleServiceTokenJSON contains the JSON +// metadata for the struct +// [AccessPoliciesRequireAccessServiceTokenRuleServiceToken] +type accessPoliciesRequireAccessServiceTokenRuleServiceTokenJSON struct { + TokenID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { + return r.raw +} + +// Matches any valid Access Service Token +type AccessPoliciesRequireAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` + JSON accessPoliciesRequireAccessAnyValidServiceTokenRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessAnyValidServiceTokenRuleJSON contains the JSON +// metadata for the struct [AccessPoliciesRequireAccessAnyValidServiceTokenRule] +type accessPoliciesRequireAccessAnyValidServiceTokenRuleJSON struct { + AnyValidServiceToken apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessAnyValidServiceTokenRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessPoliciesRequire() { +} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessPoliciesRequireAccessExternalEvaluationRule struct { + ExternalEvaluation AccessPoliciesRequireAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` + JSON accessPoliciesRequireAccessExternalEvaluationRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessExternalEvaluationRuleJSON contains the JSON metadata +// for the struct [AccessPoliciesRequireAccessExternalEvaluationRule] +type accessPoliciesRequireAccessExternalEvaluationRuleJSON struct { + ExternalEvaluation apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessExternalEvaluationRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessExternalEvaluationRule) implementsZeroTrustAccessPoliciesRequire() { +} + +type AccessPoliciesRequireAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL string `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL string `json:"keys_url,required"` + JSON accessPoliciesRequireAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` +} + +// accessPoliciesRequireAccessExternalEvaluationRuleExternalEvaluationJSON contains +// the JSON metadata for the struct +// [AccessPoliciesRequireAccessExternalEvaluationRuleExternalEvaluation] +type accessPoliciesRequireAccessExternalEvaluationRuleExternalEvaluationJSON struct { + EvaluateURL apijson.Field + KeysURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { + return r.raw +} + +// Matches a specific country +type AccessPoliciesRequireAccessCountryRule struct { + Geo AccessPoliciesRequireAccessCountryRuleGeo `json:"geo,required"` + JSON accessPoliciesRequireAccessCountryRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessCountryRuleJSON contains the JSON metadata for the +// struct [AccessPoliciesRequireAccessCountryRule] +type accessPoliciesRequireAccessCountryRuleJSON struct { + Geo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessCountryRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessCountryRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessCountryRule) implementsZeroTrustAccessPoliciesRequire() {} + +type AccessPoliciesRequireAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode string `json:"country_code,required"` + JSON accessPoliciesRequireAccessCountryRuleGeoJSON `json:"-"` +} + +// accessPoliciesRequireAccessCountryRuleGeoJSON contains the JSON metadata for the +// struct [AccessPoliciesRequireAccessCountryRuleGeo] +type accessPoliciesRequireAccessCountryRuleGeoJSON struct { + CountryCode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessCountryRuleGeoJSON) RawJSON() string { + return r.raw +} + +// Enforce different MFA options +type AccessPoliciesRequireAccessAuthenticationMethodRule struct { + AuthMethod AccessPoliciesRequireAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` + JSON accessPoliciesRequireAccessAuthenticationMethodRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessAuthenticationMethodRuleJSON contains the JSON +// metadata for the struct [AccessPoliciesRequireAccessAuthenticationMethodRule] +type accessPoliciesRequireAccessAuthenticationMethodRuleJSON struct { + AuthMethod apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessAuthenticationMethodRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessPoliciesRequire() { +} + +type AccessPoliciesRequireAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod string `json:"auth_method,required"` + JSON accessPoliciesRequireAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` +} + +// accessPoliciesRequireAccessAuthenticationMethodRuleAuthMethodJSON contains the +// JSON metadata for the struct +// [AccessPoliciesRequireAccessAuthenticationMethodRuleAuthMethod] +type accessPoliciesRequireAccessAuthenticationMethodRuleAuthMethodJSON struct { + AuthMethod apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { + return r.raw +} + +// Enforces a device posture rule has run successfully +type AccessPoliciesRequireAccessDevicePostureRule struct { + DevicePosture AccessPoliciesRequireAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` + JSON accessPoliciesRequireAccessDevicePostureRuleJSON `json:"-"` +} + +// accessPoliciesRequireAccessDevicePostureRuleJSON contains the JSON metadata for +// the struct [AccessPoliciesRequireAccessDevicePostureRule] +type accessPoliciesRequireAccessDevicePostureRuleJSON struct { + DevicePosture apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessDevicePostureRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessPoliciesRequireAccessDevicePostureRule) implementsZeroTrustAccessPoliciesRequire() {} + +type AccessPoliciesRequireAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid string `json:"integration_uid,required"` + JSON accessPoliciesRequireAccessDevicePostureRuleDevicePostureJSON `json:"-"` +} + +// accessPoliciesRequireAccessDevicePostureRuleDevicePostureJSON contains the JSON +// metadata for the struct +// [AccessPoliciesRequireAccessDevicePostureRuleDevicePosture] +type accessPoliciesRequireAccessDevicePostureRuleDevicePostureJSON struct { + IntegrationUid apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessPoliciesRequireAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessPoliciesRequireAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationPolicyDeleteResponse struct { + // UUID + ID string `json:"id"` + JSON accessApplicationPolicyDeleteResponseJSON `json:"-"` +} + +// accessApplicationPolicyDeleteResponseJSON contains the JSON metadata for the +// struct [AccessApplicationPolicyDeleteResponse] +type accessApplicationPolicyDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationPolicyDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationPolicyDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationPolicyNewParams struct { + // The action Access will take if a user matches this policy. + Decision param.Field[AccessApplicationPolicyNewParamsDecision] `json:"decision,required"` + // Rules evaluated with an OR logical operator. A user needs to meet only one of + // the Include rules. + Include param.Field[[]AccessApplicationPolicyNewParamsInclude] `json:"include,required"` + // The name of the Access policy. + Name param.Field[string] `json:"name,required"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // Administrators who can approve a temporary authentication request. + ApprovalGroups param.Field[[]AccessApplicationPolicyNewParamsApprovalGroup] `json:"approval_groups"` + // Requires the user to request access from an administrator at the start of each + // session. + ApprovalRequired param.Field[bool] `json:"approval_required"` + // Rules evaluated with a NOT logical operator. To match the policy, a user cannot + // meet any of the Exclude rules. + Exclude param.Field[[]AccessApplicationPolicyNewParamsExclude] `json:"exclude"` + // Require this application to be served in an isolated browser for users matching + // this policy. 'Client Web Isolation' must be on for the account in order to use + // this feature. + IsolationRequired param.Field[bool] `json:"isolation_required"` + // The order of execution for this policy. Must be unique for each policy. + Precedence param.Field[int64] `json:"precedence"` + // A custom message that will appear on the purpose justification screen. + PurposeJustificationPrompt param.Field[string] `json:"purpose_justification_prompt"` + // Require users to enter a justification when they log in to the application. + PurposeJustificationRequired param.Field[bool] `json:"purpose_justification_required"` + // Rules evaluated with an AND logical operator. To match the policy, a user must + // meet all of the Require rules. + Require param.Field[[]AccessApplicationPolicyNewParamsRequire] `json:"require"` + // The amount of time that tokens issued for the application will be valid. Must be + // in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, + // m, h. + SessionDuration param.Field[string] `json:"session_duration"` +} + +func (r AccessApplicationPolicyNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The action Access will take if a user matches this policy. +type AccessApplicationPolicyNewParamsDecision string + +const ( + AccessApplicationPolicyNewParamsDecisionAllow AccessApplicationPolicyNewParamsDecision = "allow" + AccessApplicationPolicyNewParamsDecisionDeny AccessApplicationPolicyNewParamsDecision = "deny" + AccessApplicationPolicyNewParamsDecisionNonIdentity AccessApplicationPolicyNewParamsDecision = "non_identity" + AccessApplicationPolicyNewParamsDecisionBypass AccessApplicationPolicyNewParamsDecision = "bypass" +) + +// Matches a specific email. +// +// Satisfied by +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRule], +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailListRule], +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessDomainRule], +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEveryoneRule], +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessIPRule], +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessIPListRule], +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessCertificateRule], +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessAccessGroupRule], +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessAzureGroupRule], +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRule], +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRule], +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessOktaGroupRule], +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessSamlGroupRule], +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessServiceTokenRule], +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessAnyValidServiceTokenRule], +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRule], +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessCountryRule], +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRule], +// [zero_trust.AccessApplicationPolicyNewParamsIncludeAccessDevicePostureRule]. +type AccessApplicationPolicyNewParamsInclude interface { + implementsZeroTrustAccessApplicationPolicyNewParamsInclude() +} + +// Matches a specific email. +type AccessApplicationPolicyNewParamsIncludeAccessEmailRule struct { + Email param.Field[AccessApplicationPolicyNewParamsIncludeAccessEmailRuleEmail] `json:"email,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessEmailRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +type AccessApplicationPolicyNewParamsIncludeAccessEmailRuleEmail struct { + // The email of the user. + Email param.Field[string] `json:"email,required" format:"email"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an email address from a list. +type AccessApplicationPolicyNewParamsIncludeAccessEmailListRule struct { + EmailList param.Field[AccessApplicationPolicyNewParamsIncludeAccessEmailListRuleEmailList] `json:"email_list,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +type AccessApplicationPolicyNewParamsIncludeAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Match an entire email domain. +type AccessApplicationPolicyNewParamsIncludeAccessDomainRule struct { + EmailDomain param.Field[AccessApplicationPolicyNewParamsIncludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessDomainRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +type AccessApplicationPolicyNewParamsIncludeAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain param.Field[string] `json:"domain,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches everyone. +type AccessApplicationPolicyNewParamsIncludeAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone param.Field[interface{}] `json:"everyone,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +// Matches an IP address block. +type AccessApplicationPolicyNewParamsIncludeAccessIPRule struct { + IP param.Field[AccessApplicationPolicyNewParamsIncludeAccessIPRuleIP] `json:"ip,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessIPRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +type AccessApplicationPolicyNewParamsIncludeAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP param.Field[string] `json:"ip,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an IP address from a list. +type AccessApplicationPolicyNewParamsIncludeAccessIPListRule struct { + IPList param.Field[AccessApplicationPolicyNewParamsIncludeAccessIPListRuleIPList] `json:"ip_list,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessIPListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +type AccessApplicationPolicyNewParamsIncludeAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid client certificate. +type AccessApplicationPolicyNewParamsIncludeAccessCertificateRule struct { + Certificate param.Field[interface{}] `json:"certificate,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +// Matches an Access group. +type AccessApplicationPolicyNewParamsIncludeAccessAccessGroupRule struct { + Group param.Field[AccessApplicationPolicyNewParamsIncludeAccessAccessGroupRuleGroup] `json:"group,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +type AccessApplicationPolicyNewParamsIncludeAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessApplicationPolicyNewParamsIncludeAccessAzureGroupRule struct { + AzureAd param.Field[AccessApplicationPolicyNewParamsIncludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +type AccessApplicationPolicyNewParamsIncludeAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID param.Field[string] `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRule struct { + GitHubOrganization param.Field[AccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +type AccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The name of the organization. + Name param.Field[string] `json:"name,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRule struct { + Gsuite param.Field[AccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +type AccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Google Workspace group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessApplicationPolicyNewParamsIncludeAccessOktaGroupRule struct { + Okta param.Field[AccessApplicationPolicyNewParamsIncludeAccessOktaGroupRuleOkta] `json:"okta,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +type AccessApplicationPolicyNewParamsIncludeAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Okta group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessApplicationPolicyNewParamsIncludeAccessSamlGroupRule struct { + Saml param.Field[AccessApplicationPolicyNewParamsIncludeAccessSamlGroupRuleSaml] `json:"saml,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +type AccessApplicationPolicyNewParamsIncludeAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName param.Field[string] `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue param.Field[string] `json:"attribute_value,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific Access Service Token +type AccessApplicationPolicyNewParamsIncludeAccessServiceTokenRule struct { + ServiceToken param.Field[AccessApplicationPolicyNewParamsIncludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +type AccessApplicationPolicyNewParamsIncludeAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID param.Field[string] `json:"token_id,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid Access Service Token +type AccessApplicationPolicyNewParamsIncludeAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRule struct { + ExternalEvaluation param.Field[AccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +type AccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL param.Field[string] `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL param.Field[string] `json:"keys_url,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific country +type AccessApplicationPolicyNewParamsIncludeAccessCountryRule struct { + Geo param.Field[AccessApplicationPolicyNewParamsIncludeAccessCountryRuleGeo] `json:"geo,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessCountryRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +type AccessApplicationPolicyNewParamsIncludeAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode param.Field[string] `json:"country_code,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforce different MFA options +type AccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRule struct { + AuthMethod param.Field[AccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +type AccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod param.Field[string] `json:"auth_method,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforces a device posture rule has run successfully +type AccessApplicationPolicyNewParamsIncludeAccessDevicePostureRule struct { + DevicePosture param.Field[AccessApplicationPolicyNewParamsIncludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { +} + +type AccessApplicationPolicyNewParamsIncludeAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid param.Field[string] `json:"integration_uid,required"` +} + +func (r AccessApplicationPolicyNewParamsIncludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A group of email addresses that can approve a temporary authentication request. +type AccessApplicationPolicyNewParamsApprovalGroup struct { + // The number of approvals needed to obtain access. + ApprovalsNeeded param.Field[float64] `json:"approvals_needed,required"` + // A list of emails that can approve the access request. + EmailAddresses param.Field[[]interface{}] `json:"email_addresses"` + // The UUID of an re-usable email list. + EmailListUUID param.Field[string] `json:"email_list_uuid"` +} + +func (r AccessApplicationPolicyNewParamsApprovalGroup) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific email. +// +// Satisfied by +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRule], +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailListRule], +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessDomainRule], +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEveryoneRule], +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessIPRule], +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessIPListRule], +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessCertificateRule], +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessAccessGroupRule], +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessAzureGroupRule], +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRule], +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRule], +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessOktaGroupRule], +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessSamlGroupRule], +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessServiceTokenRule], +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessAnyValidServiceTokenRule], +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRule], +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessCountryRule], +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRule], +// [zero_trust.AccessApplicationPolicyNewParamsExcludeAccessDevicePostureRule]. +type AccessApplicationPolicyNewParamsExclude interface { + implementsZeroTrustAccessApplicationPolicyNewParamsExclude() +} + +// Matches a specific email. +type AccessApplicationPolicyNewParamsExcludeAccessEmailRule struct { + Email param.Field[AccessApplicationPolicyNewParamsExcludeAccessEmailRuleEmail] `json:"email,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessEmailRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +type AccessApplicationPolicyNewParamsExcludeAccessEmailRuleEmail struct { + // The email of the user. + Email param.Field[string] `json:"email,required" format:"email"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an email address from a list. +type AccessApplicationPolicyNewParamsExcludeAccessEmailListRule struct { + EmailList param.Field[AccessApplicationPolicyNewParamsExcludeAccessEmailListRuleEmailList] `json:"email_list,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +type AccessApplicationPolicyNewParamsExcludeAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Match an entire email domain. +type AccessApplicationPolicyNewParamsExcludeAccessDomainRule struct { + EmailDomain param.Field[AccessApplicationPolicyNewParamsExcludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessDomainRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +type AccessApplicationPolicyNewParamsExcludeAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain param.Field[string] `json:"domain,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches everyone. +type AccessApplicationPolicyNewParamsExcludeAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone param.Field[interface{}] `json:"everyone,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +// Matches an IP address block. +type AccessApplicationPolicyNewParamsExcludeAccessIPRule struct { + IP param.Field[AccessApplicationPolicyNewParamsExcludeAccessIPRuleIP] `json:"ip,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessIPRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +type AccessApplicationPolicyNewParamsExcludeAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP param.Field[string] `json:"ip,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an IP address from a list. +type AccessApplicationPolicyNewParamsExcludeAccessIPListRule struct { + IPList param.Field[AccessApplicationPolicyNewParamsExcludeAccessIPListRuleIPList] `json:"ip_list,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessIPListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +type AccessApplicationPolicyNewParamsExcludeAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid client certificate. +type AccessApplicationPolicyNewParamsExcludeAccessCertificateRule struct { + Certificate param.Field[interface{}] `json:"certificate,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +// Matches an Access group. +type AccessApplicationPolicyNewParamsExcludeAccessAccessGroupRule struct { + Group param.Field[AccessApplicationPolicyNewParamsExcludeAccessAccessGroupRuleGroup] `json:"group,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +type AccessApplicationPolicyNewParamsExcludeAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessApplicationPolicyNewParamsExcludeAccessAzureGroupRule struct { + AzureAd param.Field[AccessApplicationPolicyNewParamsExcludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +type AccessApplicationPolicyNewParamsExcludeAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID param.Field[string] `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRule struct { + GitHubOrganization param.Field[AccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +type AccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The name of the organization. + Name param.Field[string] `json:"name,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRule struct { + Gsuite param.Field[AccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +type AccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Google Workspace group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessApplicationPolicyNewParamsExcludeAccessOktaGroupRule struct { + Okta param.Field[AccessApplicationPolicyNewParamsExcludeAccessOktaGroupRuleOkta] `json:"okta,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +type AccessApplicationPolicyNewParamsExcludeAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Okta group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessApplicationPolicyNewParamsExcludeAccessSamlGroupRule struct { + Saml param.Field[AccessApplicationPolicyNewParamsExcludeAccessSamlGroupRuleSaml] `json:"saml,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +type AccessApplicationPolicyNewParamsExcludeAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName param.Field[string] `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue param.Field[string] `json:"attribute_value,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific Access Service Token +type AccessApplicationPolicyNewParamsExcludeAccessServiceTokenRule struct { + ServiceToken param.Field[AccessApplicationPolicyNewParamsExcludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +type AccessApplicationPolicyNewParamsExcludeAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID param.Field[string] `json:"token_id,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid Access Service Token +type AccessApplicationPolicyNewParamsExcludeAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRule struct { + ExternalEvaluation param.Field[AccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +type AccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL param.Field[string] `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL param.Field[string] `json:"keys_url,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific country +type AccessApplicationPolicyNewParamsExcludeAccessCountryRule struct { + Geo param.Field[AccessApplicationPolicyNewParamsExcludeAccessCountryRuleGeo] `json:"geo,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessCountryRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +type AccessApplicationPolicyNewParamsExcludeAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode param.Field[string] `json:"country_code,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforce different MFA options +type AccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRule struct { + AuthMethod param.Field[AccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +type AccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod param.Field[string] `json:"auth_method,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforces a device posture rule has run successfully +type AccessApplicationPolicyNewParamsExcludeAccessDevicePostureRule struct { + DevicePosture param.Field[AccessApplicationPolicyNewParamsExcludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { +} + +type AccessApplicationPolicyNewParamsExcludeAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid param.Field[string] `json:"integration_uid,required"` +} + +func (r AccessApplicationPolicyNewParamsExcludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific email. +// +// Satisfied by +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRule], +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailListRule], +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessDomainRule], +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessEveryoneRule], +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessIPRule], +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessIPListRule], +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessCertificateRule], +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessAccessGroupRule], +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessAzureGroupRule], +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRule], +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRule], +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessOktaGroupRule], +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessSamlGroupRule], +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessServiceTokenRule], +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessAnyValidServiceTokenRule], +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRule], +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessCountryRule], +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRule], +// [zero_trust.AccessApplicationPolicyNewParamsRequireAccessDevicePostureRule]. +type AccessApplicationPolicyNewParamsRequire interface { + implementsZeroTrustAccessApplicationPolicyNewParamsRequire() +} + +// Matches a specific email. +type AccessApplicationPolicyNewParamsRequireAccessEmailRule struct { + Email param.Field[AccessApplicationPolicyNewParamsRequireAccessEmailRuleEmail] `json:"email,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessEmailRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessEmailRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +type AccessApplicationPolicyNewParamsRequireAccessEmailRuleEmail struct { + // The email of the user. + Email param.Field[string] `json:"email,required" format:"email"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an email address from a list. +type AccessApplicationPolicyNewParamsRequireAccessEmailListRule struct { + EmailList param.Field[AccessApplicationPolicyNewParamsRequireAccessEmailListRuleEmailList] `json:"email_list,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessEmailListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +type AccessApplicationPolicyNewParamsRequireAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Match an entire email domain. +type AccessApplicationPolicyNewParamsRequireAccessDomainRule struct { + EmailDomain param.Field[AccessApplicationPolicyNewParamsRequireAccessDomainRuleEmailDomain] `json:"email_domain,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessDomainRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessDomainRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +type AccessApplicationPolicyNewParamsRequireAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain param.Field[string] `json:"domain,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches everyone. +type AccessApplicationPolicyNewParamsRequireAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone param.Field[interface{}] `json:"everyone,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessEveryoneRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +// Matches an IP address block. +type AccessApplicationPolicyNewParamsRequireAccessIPRule struct { + IP param.Field[AccessApplicationPolicyNewParamsRequireAccessIPRuleIP] `json:"ip,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessIPRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessIPRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +type AccessApplicationPolicyNewParamsRequireAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP param.Field[string] `json:"ip,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessIPRuleIP) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an IP address from a list. +type AccessApplicationPolicyNewParamsRequireAccessIPListRule struct { + IPList param.Field[AccessApplicationPolicyNewParamsRequireAccessIPListRuleIPList] `json:"ip_list,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessIPListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessIPListRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +type AccessApplicationPolicyNewParamsRequireAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid client certificate. +type AccessApplicationPolicyNewParamsRequireAccessCertificateRule struct { + Certificate param.Field[interface{}] `json:"certificate,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessCertificateRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +// Matches an Access group. +type AccessApplicationPolicyNewParamsRequireAccessAccessGroupRule struct { + Group param.Field[AccessApplicationPolicyNewParamsRequireAccessAccessGroupRuleGroup] `json:"group,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +type AccessApplicationPolicyNewParamsRequireAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessApplicationPolicyNewParamsRequireAccessAzureGroupRule struct { + AzureAd param.Field[AccessApplicationPolicyNewParamsRequireAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +type AccessApplicationPolicyNewParamsRequireAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID param.Field[string] `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRule struct { + GitHubOrganization param.Field[AccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +type AccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The name of the organization. + Name param.Field[string] `json:"name,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRule struct { + Gsuite param.Field[AccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +type AccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Google Workspace group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessApplicationPolicyNewParamsRequireAccessOktaGroupRule struct { + Okta param.Field[AccessApplicationPolicyNewParamsRequireAccessOktaGroupRuleOkta] `json:"okta,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +type AccessApplicationPolicyNewParamsRequireAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Okta group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessApplicationPolicyNewParamsRequireAccessSamlGroupRule struct { + Saml param.Field[AccessApplicationPolicyNewParamsRequireAccessSamlGroupRuleSaml] `json:"saml,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +type AccessApplicationPolicyNewParamsRequireAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName param.Field[string] `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue param.Field[string] `json:"attribute_value,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific Access Service Token +type AccessApplicationPolicyNewParamsRequireAccessServiceTokenRule struct { + ServiceToken param.Field[AccessApplicationPolicyNewParamsRequireAccessServiceTokenRuleServiceToken] `json:"service_token,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +type AccessApplicationPolicyNewParamsRequireAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID param.Field[string] `json:"token_id,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid Access Service Token +type AccessApplicationPolicyNewParamsRequireAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRule struct { + ExternalEvaluation param.Field[AccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +type AccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL param.Field[string] `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL param.Field[string] `json:"keys_url,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific country +type AccessApplicationPolicyNewParamsRequireAccessCountryRule struct { + Geo param.Field[AccessApplicationPolicyNewParamsRequireAccessCountryRuleGeo] `json:"geo,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessCountryRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessCountryRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +type AccessApplicationPolicyNewParamsRequireAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode param.Field[string] `json:"country_code,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforce different MFA options +type AccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRule struct { + AuthMethod param.Field[AccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +type AccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod param.Field[string] `json:"auth_method,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforces a device posture rule has run successfully +type AccessApplicationPolicyNewParamsRequireAccessDevicePostureRule struct { + DevicePosture param.Field[AccessApplicationPolicyNewParamsRequireAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyNewParamsRequireAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { +} + +type AccessApplicationPolicyNewParamsRequireAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid param.Field[string] `json:"integration_uid,required"` +} + +func (r AccessApplicationPolicyNewParamsRequireAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AccessApplicationPolicyNewResponseEnvelope struct { + Errors []AccessApplicationPolicyNewResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessApplicationPolicyNewResponseEnvelopeMessages `json:"messages,required"` + Result AccessPolicies `json:"result,required"` + // Whether the API call was successful + Success AccessApplicationPolicyNewResponseEnvelopeSuccess `json:"success,required"` + JSON accessApplicationPolicyNewResponseEnvelopeJSON `json:"-"` +} + +// accessApplicationPolicyNewResponseEnvelopeJSON contains the JSON metadata for +// the struct [AccessApplicationPolicyNewResponseEnvelope] +type accessApplicationPolicyNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationPolicyNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationPolicyNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationPolicyNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationPolicyNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessApplicationPolicyNewResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [AccessApplicationPolicyNewResponseEnvelopeErrors] +type accessApplicationPolicyNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationPolicyNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationPolicyNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationPolicyNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationPolicyNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessApplicationPolicyNewResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [AccessApplicationPolicyNewResponseEnvelopeMessages] +type accessApplicationPolicyNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationPolicyNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationPolicyNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessApplicationPolicyNewResponseEnvelopeSuccess bool + +const ( + AccessApplicationPolicyNewResponseEnvelopeSuccessTrue AccessApplicationPolicyNewResponseEnvelopeSuccess = true +) + +type AccessApplicationPolicyUpdateParams struct { + // The action Access will take if a user matches this policy. + Decision param.Field[AccessApplicationPolicyUpdateParamsDecision] `json:"decision,required"` + // Rules evaluated with an OR logical operator. A user needs to meet only one of + // the Include rules. + Include param.Field[[]AccessApplicationPolicyUpdateParamsInclude] `json:"include,required"` + // The name of the Access policy. + Name param.Field[string] `json:"name,required"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // Administrators who can approve a temporary authentication request. + ApprovalGroups param.Field[[]AccessApplicationPolicyUpdateParamsApprovalGroup] `json:"approval_groups"` + // Requires the user to request access from an administrator at the start of each + // session. + ApprovalRequired param.Field[bool] `json:"approval_required"` + // Rules evaluated with a NOT logical operator. To match the policy, a user cannot + // meet any of the Exclude rules. + Exclude param.Field[[]AccessApplicationPolicyUpdateParamsExclude] `json:"exclude"` + // Require this application to be served in an isolated browser for users matching + // this policy. 'Client Web Isolation' must be on for the account in order to use + // this feature. + IsolationRequired param.Field[bool] `json:"isolation_required"` + // The order of execution for this policy. Must be unique for each policy. + Precedence param.Field[int64] `json:"precedence"` + // A custom message that will appear on the purpose justification screen. + PurposeJustificationPrompt param.Field[string] `json:"purpose_justification_prompt"` + // Require users to enter a justification when they log in to the application. + PurposeJustificationRequired param.Field[bool] `json:"purpose_justification_required"` + // Rules evaluated with an AND logical operator. To match the policy, a user must + // meet all of the Require rules. + Require param.Field[[]AccessApplicationPolicyUpdateParamsRequire] `json:"require"` + // The amount of time that tokens issued for the application will be valid. Must be + // in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, + // m, h. + SessionDuration param.Field[string] `json:"session_duration"` +} + +func (r AccessApplicationPolicyUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The action Access will take if a user matches this policy. +type AccessApplicationPolicyUpdateParamsDecision string + +const ( + AccessApplicationPolicyUpdateParamsDecisionAllow AccessApplicationPolicyUpdateParamsDecision = "allow" + AccessApplicationPolicyUpdateParamsDecisionDeny AccessApplicationPolicyUpdateParamsDecision = "deny" + AccessApplicationPolicyUpdateParamsDecisionNonIdentity AccessApplicationPolicyUpdateParamsDecision = "non_identity" + AccessApplicationPolicyUpdateParamsDecisionBypass AccessApplicationPolicyUpdateParamsDecision = "bypass" +) + +// Matches a specific email. +// +// Satisfied by +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailListRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessDomainRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEveryoneRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessIPRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessIPListRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessCertificateRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessAnyValidServiceTokenRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessCountryRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRule]. +type AccessApplicationPolicyUpdateParamsInclude interface { + implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() +} + +// Matches a specific email. +type AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule struct { + Email param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessEmailRuleEmail] `json:"email,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +type AccessApplicationPolicyUpdateParamsIncludeAccessEmailRuleEmail struct { + // The email of the user. + Email param.Field[string] `json:"email,required" format:"email"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an email address from a list. +type AccessApplicationPolicyUpdateParamsIncludeAccessEmailListRule struct { + EmailList param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessEmailListRuleEmailList] `json:"email_list,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +type AccessApplicationPolicyUpdateParamsIncludeAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Match an entire email domain. +type AccessApplicationPolicyUpdateParamsIncludeAccessDomainRule struct { + EmailDomain param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessDomainRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +type AccessApplicationPolicyUpdateParamsIncludeAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain param.Field[string] `json:"domain,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches everyone. +type AccessApplicationPolicyUpdateParamsIncludeAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone param.Field[interface{}] `json:"everyone,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +// Matches an IP address block. +type AccessApplicationPolicyUpdateParamsIncludeAccessIPRule struct { + IP param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessIPRuleIP] `json:"ip,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessIPRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +type AccessApplicationPolicyUpdateParamsIncludeAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP param.Field[string] `json:"ip,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an IP address from a list. +type AccessApplicationPolicyUpdateParamsIncludeAccessIPListRule struct { + IPList param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessIPListRuleIPList] `json:"ip_list,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessIPListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +type AccessApplicationPolicyUpdateParamsIncludeAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid client certificate. +type AccessApplicationPolicyUpdateParamsIncludeAccessCertificateRule struct { + Certificate param.Field[interface{}] `json:"certificate,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +// Matches an Access group. +type AccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRule struct { + Group param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRuleGroup] `json:"group,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +type AccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRule struct { + AzureAd param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +type AccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID param.Field[string] `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRule struct { + GitHubOrganization param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +type AccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The name of the organization. + Name param.Field[string] `json:"name,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRule struct { + Gsuite param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +type AccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Google Workspace group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRule struct { + Okta param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRuleOkta] `json:"okta,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +type AccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Okta group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRule struct { + Saml param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRuleSaml] `json:"saml,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +type AccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName param.Field[string] `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue param.Field[string] `json:"attribute_value,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific Access Service Token +type AccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRule struct { + ServiceToken param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +type AccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID param.Field[string] `json:"token_id,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid Access Service Token +type AccessApplicationPolicyUpdateParamsIncludeAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRule struct { + ExternalEvaluation param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +type AccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL param.Field[string] `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL param.Field[string] `json:"keys_url,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific country +type AccessApplicationPolicyUpdateParamsIncludeAccessCountryRule struct { + Geo param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessCountryRuleGeo] `json:"geo,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessCountryRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +type AccessApplicationPolicyUpdateParamsIncludeAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode param.Field[string] `json:"country_code,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforce different MFA options +type AccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRule struct { + AuthMethod param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +type AccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod param.Field[string] `json:"auth_method,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforces a device posture rule has run successfully +type AccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRule struct { + DevicePosture param.Field[AccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { +} + +type AccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid param.Field[string] `json:"integration_uid,required"` +} + +func (r AccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A group of email addresses that can approve a temporary authentication request. +type AccessApplicationPolicyUpdateParamsApprovalGroup struct { + // The number of approvals needed to obtain access. + ApprovalsNeeded param.Field[float64] `json:"approvals_needed,required"` + // A list of emails that can approve the access request. + EmailAddresses param.Field[[]interface{}] `json:"email_addresses"` + // The UUID of an re-usable email list. + EmailListUUID param.Field[string] `json:"email_list_uuid"` +} + +func (r AccessApplicationPolicyUpdateParamsApprovalGroup) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific email. +// +// Satisfied by +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailListRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessDomainRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEveryoneRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessIPRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessIPListRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessCertificateRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessAnyValidServiceTokenRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessCountryRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRule]. +type AccessApplicationPolicyUpdateParamsExclude interface { + implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() +} + +// Matches a specific email. +type AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule struct { + Email param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessEmailRuleEmail] `json:"email,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +type AccessApplicationPolicyUpdateParamsExcludeAccessEmailRuleEmail struct { + // The email of the user. + Email param.Field[string] `json:"email,required" format:"email"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an email address from a list. +type AccessApplicationPolicyUpdateParamsExcludeAccessEmailListRule struct { + EmailList param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessEmailListRuleEmailList] `json:"email_list,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +type AccessApplicationPolicyUpdateParamsExcludeAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Match an entire email domain. +type AccessApplicationPolicyUpdateParamsExcludeAccessDomainRule struct { + EmailDomain param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessDomainRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +type AccessApplicationPolicyUpdateParamsExcludeAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain param.Field[string] `json:"domain,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches everyone. +type AccessApplicationPolicyUpdateParamsExcludeAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone param.Field[interface{}] `json:"everyone,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +// Matches an IP address block. +type AccessApplicationPolicyUpdateParamsExcludeAccessIPRule struct { + IP param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessIPRuleIP] `json:"ip,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessIPRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +type AccessApplicationPolicyUpdateParamsExcludeAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP param.Field[string] `json:"ip,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an IP address from a list. +type AccessApplicationPolicyUpdateParamsExcludeAccessIPListRule struct { + IPList param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessIPListRuleIPList] `json:"ip_list,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessIPListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +type AccessApplicationPolicyUpdateParamsExcludeAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid client certificate. +type AccessApplicationPolicyUpdateParamsExcludeAccessCertificateRule struct { + Certificate param.Field[interface{}] `json:"certificate,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +// Matches an Access group. +type AccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRule struct { + Group param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRuleGroup] `json:"group,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +type AccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRule struct { + AzureAd param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +type AccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID param.Field[string] `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRule struct { + GitHubOrganization param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +type AccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The name of the organization. + Name param.Field[string] `json:"name,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRule struct { + Gsuite param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +type AccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Google Workspace group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRule struct { + Okta param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRuleOkta] `json:"okta,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +type AccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Okta group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRule struct { + Saml param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRuleSaml] `json:"saml,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +type AccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName param.Field[string] `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue param.Field[string] `json:"attribute_value,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific Access Service Token +type AccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRule struct { + ServiceToken param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +type AccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID param.Field[string] `json:"token_id,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid Access Service Token +type AccessApplicationPolicyUpdateParamsExcludeAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRule struct { + ExternalEvaluation param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +type AccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL param.Field[string] `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL param.Field[string] `json:"keys_url,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific country +type AccessApplicationPolicyUpdateParamsExcludeAccessCountryRule struct { + Geo param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessCountryRuleGeo] `json:"geo,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessCountryRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +type AccessApplicationPolicyUpdateParamsExcludeAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode param.Field[string] `json:"country_code,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforce different MFA options +type AccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRule struct { + AuthMethod param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +type AccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod param.Field[string] `json:"auth_method,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforces a device posture rule has run successfully +type AccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRule struct { + DevicePosture param.Field[AccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { +} + +type AccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid param.Field[string] `json:"integration_uid,required"` +} + +func (r AccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific email. +// +// Satisfied by +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailListRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessDomainRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEveryoneRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessIPRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessIPListRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessCertificateRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessAnyValidServiceTokenRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessCountryRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRule], +// [zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRule]. +type AccessApplicationPolicyUpdateParamsRequire interface { + implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() +} + +// Matches a specific email. +type AccessApplicationPolicyUpdateParamsRequireAccessEmailRule struct { + Email param.Field[AccessApplicationPolicyUpdateParamsRequireAccessEmailRuleEmail] `json:"email,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessEmailRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessEmailRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +type AccessApplicationPolicyUpdateParamsRequireAccessEmailRuleEmail struct { + // The email of the user. + Email param.Field[string] `json:"email,required" format:"email"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an email address from a list. +type AccessApplicationPolicyUpdateParamsRequireAccessEmailListRule struct { + EmailList param.Field[AccessApplicationPolicyUpdateParamsRequireAccessEmailListRuleEmailList] `json:"email_list,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessEmailListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +type AccessApplicationPolicyUpdateParamsRequireAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Match an entire email domain. +type AccessApplicationPolicyUpdateParamsRequireAccessDomainRule struct { + EmailDomain param.Field[AccessApplicationPolicyUpdateParamsRequireAccessDomainRuleEmailDomain] `json:"email_domain,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessDomainRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessDomainRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +type AccessApplicationPolicyUpdateParamsRequireAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain param.Field[string] `json:"domain,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches everyone. +type AccessApplicationPolicyUpdateParamsRequireAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone param.Field[interface{}] `json:"everyone,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessEveryoneRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +// Matches an IP address block. +type AccessApplicationPolicyUpdateParamsRequireAccessIPRule struct { + IP param.Field[AccessApplicationPolicyUpdateParamsRequireAccessIPRuleIP] `json:"ip,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessIPRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessIPRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +type AccessApplicationPolicyUpdateParamsRequireAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP param.Field[string] `json:"ip,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessIPRuleIP) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an IP address from a list. +type AccessApplicationPolicyUpdateParamsRequireAccessIPListRule struct { + IPList param.Field[AccessApplicationPolicyUpdateParamsRequireAccessIPListRuleIPList] `json:"ip_list,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessIPListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessIPListRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +type AccessApplicationPolicyUpdateParamsRequireAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid client certificate. +type AccessApplicationPolicyUpdateParamsRequireAccessCertificateRule struct { + Certificate param.Field[interface{}] `json:"certificate,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessCertificateRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +// Matches an Access group. +type AccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRule struct { + Group param.Field[AccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRuleGroup] `json:"group,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +type AccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRule struct { + AzureAd param.Field[AccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +type AccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID param.Field[string] `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRule struct { + GitHubOrganization param.Field[AccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +type AccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The name of the organization. + Name param.Field[string] `json:"name,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRule struct { + Gsuite param.Field[AccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +type AccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Google Workspace group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRule struct { + Okta param.Field[AccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRuleOkta] `json:"okta,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +type AccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Okta group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRule struct { + Saml param.Field[AccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRuleSaml] `json:"saml,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +type AccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName param.Field[string] `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue param.Field[string] `json:"attribute_value,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific Access Service Token +type AccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRule struct { + ServiceToken param.Field[AccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRuleServiceToken] `json:"service_token,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +type AccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID param.Field[string] `json:"token_id,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid Access Service Token +type AccessApplicationPolicyUpdateParamsRequireAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRule struct { + ExternalEvaluation param.Field[AccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +type AccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL param.Field[string] `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL param.Field[string] `json:"keys_url,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific country +type AccessApplicationPolicyUpdateParamsRequireAccessCountryRule struct { + Geo param.Field[AccessApplicationPolicyUpdateParamsRequireAccessCountryRuleGeo] `json:"geo,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessCountryRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessCountryRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +type AccessApplicationPolicyUpdateParamsRequireAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode param.Field[string] `json:"country_code,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforce different MFA options +type AccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRule struct { + AuthMethod param.Field[AccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +type AccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod param.Field[string] `json:"auth_method,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforces a device posture rule has run successfully +type AccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRule struct { + DevicePosture param.Field[AccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { +} + +type AccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid param.Field[string] `json:"integration_uid,required"` +} + +func (r AccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AccessApplicationPolicyUpdateResponseEnvelope struct { + Errors []AccessApplicationPolicyUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessApplicationPolicyUpdateResponseEnvelopeMessages `json:"messages,required"` + Result AccessPolicies `json:"result,required"` + // Whether the API call was successful + Success AccessApplicationPolicyUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON accessApplicationPolicyUpdateResponseEnvelopeJSON `json:"-"` +} + +// accessApplicationPolicyUpdateResponseEnvelopeJSON contains the JSON metadata for +// the struct [AccessApplicationPolicyUpdateResponseEnvelope] +type accessApplicationPolicyUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationPolicyUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationPolicyUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationPolicyUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationPolicyUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessApplicationPolicyUpdateResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [AccessApplicationPolicyUpdateResponseEnvelopeErrors] +type accessApplicationPolicyUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationPolicyUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationPolicyUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationPolicyUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationPolicyUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessApplicationPolicyUpdateResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [AccessApplicationPolicyUpdateResponseEnvelopeMessages] +type accessApplicationPolicyUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationPolicyUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationPolicyUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessApplicationPolicyUpdateResponseEnvelopeSuccess bool + +const ( + AccessApplicationPolicyUpdateResponseEnvelopeSuccessTrue AccessApplicationPolicyUpdateResponseEnvelopeSuccess = true +) + +type AccessApplicationPolicyListParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessApplicationPolicyListResponseEnvelope struct { + Errors []AccessApplicationPolicyListResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessApplicationPolicyListResponseEnvelopeMessages `json:"messages,required"` + Result []AccessPolicies `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessApplicationPolicyListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AccessApplicationPolicyListResponseEnvelopeResultInfo `json:"result_info"` + JSON accessApplicationPolicyListResponseEnvelopeJSON `json:"-"` +} + +// accessApplicationPolicyListResponseEnvelopeJSON contains the JSON metadata for +// the struct [AccessApplicationPolicyListResponseEnvelope] +type accessApplicationPolicyListResponseEnvelopeJSON 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 *AccessApplicationPolicyListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationPolicyListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationPolicyListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationPolicyListResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessApplicationPolicyListResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [AccessApplicationPolicyListResponseEnvelopeErrors] +type accessApplicationPolicyListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationPolicyListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationPolicyListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationPolicyListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationPolicyListResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessApplicationPolicyListResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [AccessApplicationPolicyListResponseEnvelopeMessages] +type accessApplicationPolicyListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationPolicyListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationPolicyListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessApplicationPolicyListResponseEnvelopeSuccess bool + +const ( + AccessApplicationPolicyListResponseEnvelopeSuccessTrue AccessApplicationPolicyListResponseEnvelopeSuccess = true +) + +type AccessApplicationPolicyListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON accessApplicationPolicyListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// accessApplicationPolicyListResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [AccessApplicationPolicyListResponseEnvelopeResultInfo] +type accessApplicationPolicyListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationPolicyListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationPolicyListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationPolicyDeleteParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessApplicationPolicyDeleteResponseEnvelope struct { + Errors []AccessApplicationPolicyDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessApplicationPolicyDeleteResponseEnvelopeMessages `json:"messages,required"` + Result AccessApplicationPolicyDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success AccessApplicationPolicyDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON accessApplicationPolicyDeleteResponseEnvelopeJSON `json:"-"` +} + +// accessApplicationPolicyDeleteResponseEnvelopeJSON contains the JSON metadata for +// the struct [AccessApplicationPolicyDeleteResponseEnvelope] +type accessApplicationPolicyDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationPolicyDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationPolicyDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationPolicyDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationPolicyDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessApplicationPolicyDeleteResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [AccessApplicationPolicyDeleteResponseEnvelopeErrors] +type accessApplicationPolicyDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationPolicyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationPolicyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationPolicyDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationPolicyDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessApplicationPolicyDeleteResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [AccessApplicationPolicyDeleteResponseEnvelopeMessages] +type accessApplicationPolicyDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationPolicyDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationPolicyDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessApplicationPolicyDeleteResponseEnvelopeSuccess bool + +const ( + AccessApplicationPolicyDeleteResponseEnvelopeSuccessTrue AccessApplicationPolicyDeleteResponseEnvelopeSuccess = true +) + +type AccessApplicationPolicyGetParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessApplicationPolicyGetResponseEnvelope struct { + Errors []AccessApplicationPolicyGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessApplicationPolicyGetResponseEnvelopeMessages `json:"messages,required"` + Result AccessPolicies `json:"result,required"` + // Whether the API call was successful + Success AccessApplicationPolicyGetResponseEnvelopeSuccess `json:"success,required"` + JSON accessApplicationPolicyGetResponseEnvelopeJSON `json:"-"` +} + +// accessApplicationPolicyGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [AccessApplicationPolicyGetResponseEnvelope] +type accessApplicationPolicyGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationPolicyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationPolicyGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationPolicyGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationPolicyGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessApplicationPolicyGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [AccessApplicationPolicyGetResponseEnvelopeErrors] +type accessApplicationPolicyGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationPolicyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationPolicyGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationPolicyGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationPolicyGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessApplicationPolicyGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [AccessApplicationPolicyGetResponseEnvelopeMessages] +type accessApplicationPolicyGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationPolicyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationPolicyGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessApplicationPolicyGetResponseEnvelopeSuccess bool + +const ( + AccessApplicationPolicyGetResponseEnvelopeSuccessTrue AccessApplicationPolicyGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/accessapplicationpolicy_test.go b/zero_trust/accessapplicationpolicy_test.go new file mode 100644 index 00000000000..8fe0e5ec648 --- /dev/null +++ b/zero_trust/accessapplicationpolicy_test.go @@ -0,0 +1,285 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestAccessApplicationPolicyNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Applications.Policies.New( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessApplicationPolicyNewParams{ + Decision: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsDecisionAllow), + Include: cloudflare.F([]zero_trust.AccessApplicationPolicyNewParamsInclude{zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRule(zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRule(zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRule(zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsIncludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + })}), + Name: cloudflare.F("Allow devs"), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + ApprovalGroups: cloudflare.F([]zero_trust.AccessApplicationPolicyNewParamsApprovalGroup{{ + ApprovalsNeeded: cloudflare.F(1.000000), + EmailAddresses: cloudflare.F([]interface{}{"test1@cloudflare.com", "test2@cloudflare.com"}), + EmailListUUID: cloudflare.F("string"), + }, { + ApprovalsNeeded: cloudflare.F(3.000000), + EmailAddresses: cloudflare.F([]interface{}{"test@cloudflare.com", "test2@cloudflare.com"}), + EmailListUUID: cloudflare.F("597147a1-976b-4ef2-9af0-81d5d007fc34"), + }}), + ApprovalRequired: cloudflare.F(true), + Exclude: cloudflare.F([]zero_trust.AccessApplicationPolicyNewParamsExclude{zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRule(zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRule(zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRule(zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsExcludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + })}), + IsolationRequired: cloudflare.F(false), + Precedence: cloudflare.F(int64(0)), + PurposeJustificationPrompt: cloudflare.F("Please enter a justification for entering this protected domain."), + PurposeJustificationRequired: cloudflare.F(true), + Require: cloudflare.F([]zero_trust.AccessApplicationPolicyNewParamsRequire{zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRule(zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRule(zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRule(zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessApplicationPolicyNewParamsRequireAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + })}), + SessionDuration: cloudflare.F("24h"), + }, + ) + 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 TestAccessApplicationPolicyUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Applications.Policies.Update( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessApplicationPolicyUpdateParams{ + Decision: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsDecisionAllow), + Include: cloudflare.F([]zero_trust.AccessApplicationPolicyUpdateParamsInclude{zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule(zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule(zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule(zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsIncludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + })}), + Name: cloudflare.F("Allow devs"), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + ApprovalGroups: cloudflare.F([]zero_trust.AccessApplicationPolicyUpdateParamsApprovalGroup{{ + ApprovalsNeeded: cloudflare.F(1.000000), + EmailAddresses: cloudflare.F([]interface{}{"test1@cloudflare.com", "test2@cloudflare.com"}), + EmailListUUID: cloudflare.F("string"), + }, { + ApprovalsNeeded: cloudflare.F(3.000000), + EmailAddresses: cloudflare.F([]interface{}{"test@cloudflare.com", "test2@cloudflare.com"}), + EmailListUUID: cloudflare.F("597147a1-976b-4ef2-9af0-81d5d007fc34"), + }}), + ApprovalRequired: cloudflare.F(true), + Exclude: cloudflare.F([]zero_trust.AccessApplicationPolicyUpdateParamsExclude{zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule(zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule(zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule(zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsExcludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + })}), + IsolationRequired: cloudflare.F(false), + Precedence: cloudflare.F(int64(0)), + PurposeJustificationPrompt: cloudflare.F("Please enter a justification for entering this protected domain."), + PurposeJustificationRequired: cloudflare.F(true), + Require: cloudflare.F([]zero_trust.AccessApplicationPolicyUpdateParamsRequire{zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRule(zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRule(zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRule(zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessApplicationPolicyUpdateParamsRequireAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + })}), + SessionDuration: cloudflare.F("24h"), + }, + ) + 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 TestAccessApplicationPolicyListWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Applications.Policies.List( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessApplicationPolicyListParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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 TestAccessApplicationPolicyDeleteWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Applications.Policies.Delete( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessApplicationPolicyDeleteParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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 TestAccessApplicationPolicyGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Applications.Policies.Get( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessApplicationPolicyGetParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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/zero_trust/accessapplicationuserpolicycheck.go b/zero_trust/accessapplicationuserpolicycheck.go new file mode 100644 index 00000000000..79d22be9179 --- /dev/null +++ b/zero_trust/accessapplicationuserpolicycheck.go @@ -0,0 +1,271 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AccessApplicationUserPolicyCheckService 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 +// [NewAccessApplicationUserPolicyCheckService] method instead. +type AccessApplicationUserPolicyCheckService struct { + Options []option.RequestOption +} + +// NewAccessApplicationUserPolicyCheckService 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 NewAccessApplicationUserPolicyCheckService(opts ...option.RequestOption) (r *AccessApplicationUserPolicyCheckService) { + r = &AccessApplicationUserPolicyCheckService{} + r.Options = opts + return +} + +// Tests if a specific user has permission to access an application. +func (r *AccessApplicationUserPolicyCheckService) List(ctx context.Context, appID AccessApplicationUserPolicyCheckListParamsAppID, query AccessApplicationUserPolicyCheckListParams, opts ...option.RequestOption) (res *AccessApplicationUserPolicyCheckListResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessApplicationUserPolicyCheckListResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/access/apps/%v/user_policy_checks", accountOrZone, accountOrZoneID, appID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AccessApplicationUserPolicyCheckListResponse struct { + AppState AccessApplicationUserPolicyCheckListResponseAppState `json:"app_state"` + UserIdentity AccessApplicationUserPolicyCheckListResponseUserIdentity `json:"user_identity"` + JSON accessApplicationUserPolicyCheckListResponseJSON `json:"-"` +} + +// accessApplicationUserPolicyCheckListResponseJSON contains the JSON metadata for +// the struct [AccessApplicationUserPolicyCheckListResponse] +type accessApplicationUserPolicyCheckListResponseJSON struct { + AppState apijson.Field + UserIdentity apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationUserPolicyCheckListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationUserPolicyCheckListResponseJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationUserPolicyCheckListResponseAppState struct { + // UUID + AppUid string `json:"app_uid"` + Aud string `json:"aud"` + Hostname string `json:"hostname"` + Name string `json:"name"` + Policies []interface{} `json:"policies"` + Status string `json:"status"` + JSON accessApplicationUserPolicyCheckListResponseAppStateJSON `json:"-"` +} + +// accessApplicationUserPolicyCheckListResponseAppStateJSON contains the JSON +// metadata for the struct [AccessApplicationUserPolicyCheckListResponseAppState] +type accessApplicationUserPolicyCheckListResponseAppStateJSON struct { + AppUid apijson.Field + Aud apijson.Field + Hostname apijson.Field + Name apijson.Field + Policies apijson.Field + Status apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationUserPolicyCheckListResponseAppState) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationUserPolicyCheckListResponseAppStateJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationUserPolicyCheckListResponseUserIdentity struct { + ID string `json:"id"` + AccountID string `json:"account_id"` + DeviceSessions interface{} `json:"device_sessions"` + Email string `json:"email"` + Geo AccessApplicationUserPolicyCheckListResponseUserIdentityGeo `json:"geo"` + Iat int64 `json:"iat"` + IsGateway bool `json:"is_gateway"` + IsWARP bool `json:"is_warp"` + Name string `json:"name"` + // UUID + UserUUID string `json:"user_uuid"` + Version int64 `json:"version"` + JSON accessApplicationUserPolicyCheckListResponseUserIdentityJSON `json:"-"` +} + +// accessApplicationUserPolicyCheckListResponseUserIdentityJSON contains the JSON +// metadata for the struct +// [AccessApplicationUserPolicyCheckListResponseUserIdentity] +type accessApplicationUserPolicyCheckListResponseUserIdentityJSON struct { + ID apijson.Field + AccountID apijson.Field + DeviceSessions apijson.Field + Email apijson.Field + Geo apijson.Field + Iat apijson.Field + IsGateway apijson.Field + IsWARP apijson.Field + Name apijson.Field + UserUUID apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationUserPolicyCheckListResponseUserIdentity) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationUserPolicyCheckListResponseUserIdentityJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationUserPolicyCheckListResponseUserIdentityGeo struct { + Country string `json:"country"` + JSON accessApplicationUserPolicyCheckListResponseUserIdentityGeoJSON `json:"-"` +} + +// accessApplicationUserPolicyCheckListResponseUserIdentityGeoJSON contains the +// JSON metadata for the struct +// [AccessApplicationUserPolicyCheckListResponseUserIdentityGeo] +type accessApplicationUserPolicyCheckListResponseUserIdentityGeoJSON struct { + Country apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationUserPolicyCheckListResponseUserIdentityGeo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationUserPolicyCheckListResponseUserIdentityGeoJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationUserPolicyCheckListParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +// Identifier +// +// Satisfied by [shared.UnionString], [shared.UnionString]. +type AccessApplicationUserPolicyCheckListParamsAppID interface { + ImplementsZeroTrustAccessApplicationUserPolicyCheckListParamsAppID() +} + +type AccessApplicationUserPolicyCheckListResponseEnvelope struct { + Errors []AccessApplicationUserPolicyCheckListResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessApplicationUserPolicyCheckListResponseEnvelopeMessages `json:"messages,required"` + Result AccessApplicationUserPolicyCheckListResponse `json:"result,required"` + // Whether the API call was successful + Success AccessApplicationUserPolicyCheckListResponseEnvelopeSuccess `json:"success,required"` + JSON accessApplicationUserPolicyCheckListResponseEnvelopeJSON `json:"-"` +} + +// accessApplicationUserPolicyCheckListResponseEnvelopeJSON contains the JSON +// metadata for the struct [AccessApplicationUserPolicyCheckListResponseEnvelope] +type accessApplicationUserPolicyCheckListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationUserPolicyCheckListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationUserPolicyCheckListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationUserPolicyCheckListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationUserPolicyCheckListResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessApplicationUserPolicyCheckListResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct +// [AccessApplicationUserPolicyCheckListResponseEnvelopeErrors] +type accessApplicationUserPolicyCheckListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationUserPolicyCheckListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationUserPolicyCheckListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessApplicationUserPolicyCheckListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessApplicationUserPolicyCheckListResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessApplicationUserPolicyCheckListResponseEnvelopeMessagesJSON contains the +// JSON metadata for the struct +// [AccessApplicationUserPolicyCheckListResponseEnvelopeMessages] +type accessApplicationUserPolicyCheckListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessApplicationUserPolicyCheckListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessApplicationUserPolicyCheckListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessApplicationUserPolicyCheckListResponseEnvelopeSuccess bool + +const ( + AccessApplicationUserPolicyCheckListResponseEnvelopeSuccessTrue AccessApplicationUserPolicyCheckListResponseEnvelopeSuccess = true +) diff --git a/zero_trust/accessapplicationuserpolicycheck_test.go b/zero_trust/accessapplicationuserpolicycheck_test.go new file mode 100644 index 00000000000..e1f0d5bf3cf --- /dev/null +++ b/zero_trust/accessapplicationuserpolicycheck_test.go @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestAccessApplicationUserPolicyCheckListWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Applications.UserPolicyChecks.List( + context.TODO(), + shared.UnionString("023e105f4ecef8ad9ca31a8372d0c353"), + zero_trust.AccessApplicationUserPolicyCheckListParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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/zero_trust/accessbookmark.go b/zero_trust/accessbookmark.go new file mode 100644 index 00000000000..4ee1d0272f4 --- /dev/null +++ b/zero_trust/accessbookmark.go @@ -0,0 +1,594 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AccessBookmarkService 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 [NewAccessBookmarkService] method +// instead. +type AccessBookmarkService struct { + Options []option.RequestOption +} + +// NewAccessBookmarkService 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 NewAccessBookmarkService(opts ...option.RequestOption) (r *AccessBookmarkService) { + r = &AccessBookmarkService{} + r.Options = opts + return +} + +// Create a new Bookmark application. +func (r *AccessBookmarkService) New(ctx context.Context, identifier interface{}, uuid string, opts ...option.RequestOption) (res *AccessBookmarks, err error) { + opts = append(r.Options[:], opts...) + var env AccessBookmarkNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/access/bookmarks/%s", identifier, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a configured Bookmark application. +func (r *AccessBookmarkService) Update(ctx context.Context, identifier interface{}, uuid string, opts ...option.RequestOption) (res *AccessBookmarks, err error) { + opts = append(r.Options[:], opts...) + var env AccessBookmarkUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/access/bookmarks/%s", identifier, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists Bookmark applications. +func (r *AccessBookmarkService) List(ctx context.Context, identifier interface{}, opts ...option.RequestOption) (res *[]AccessBookmarks, err error) { + opts = append(r.Options[:], opts...) + var env AccessBookmarkListResponseEnvelope + path := fmt.Sprintf("accounts/%v/access/bookmarks", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a Bookmark application. +func (r *AccessBookmarkService) Delete(ctx context.Context, identifier interface{}, uuid string, opts ...option.RequestOption) (res *AccessBookmarkDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessBookmarkDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%v/access/bookmarks/%s", identifier, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a single Bookmark application. +func (r *AccessBookmarkService) Get(ctx context.Context, identifier interface{}, uuid string, opts ...option.RequestOption) (res *AccessBookmarks, err error) { + opts = append(r.Options[:], opts...) + var env AccessBookmarkGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/access/bookmarks/%s", identifier, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AccessBookmarks struct { + // The unique identifier for the Bookmark application. + ID interface{} `json:"id"` + // Displays the application in the App Launcher. + AppLauncherVisible bool `json:"app_launcher_visible"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The domain of the Bookmark application. + Domain string `json:"domain"` + // The image URL for the logo shown in the App Launcher dashboard. + LogoURL string `json:"logo_url"` + // The name of the Bookmark application. + Name string `json:"name"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessBookmarksJSON `json:"-"` +} + +// accessBookmarksJSON contains the JSON metadata for the struct [AccessBookmarks] +type accessBookmarksJSON struct { + ID apijson.Field + AppLauncherVisible apijson.Field + CreatedAt apijson.Field + Domain apijson.Field + LogoURL apijson.Field + Name apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessBookmarks) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessBookmarksJSON) RawJSON() string { + return r.raw +} + +type AccessBookmarkDeleteResponse struct { + // UUID + ID string `json:"id"` + JSON accessBookmarkDeleteResponseJSON `json:"-"` +} + +// accessBookmarkDeleteResponseJSON contains the JSON metadata for the struct +// [AccessBookmarkDeleteResponse] +type accessBookmarkDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessBookmarkDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessBookmarkDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type AccessBookmarkNewResponseEnvelope struct { + Errors []AccessBookmarkNewResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessBookmarkNewResponseEnvelopeMessages `json:"messages,required"` + Result AccessBookmarks `json:"result,required"` + // Whether the API call was successful + Success AccessBookmarkNewResponseEnvelopeSuccess `json:"success,required"` + JSON accessBookmarkNewResponseEnvelopeJSON `json:"-"` +} + +// accessBookmarkNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessBookmarkNewResponseEnvelope] +type accessBookmarkNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessBookmarkNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessBookmarkNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessBookmarkNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessBookmarkNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessBookmarkNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessBookmarkNewResponseEnvelopeErrors] +type accessBookmarkNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessBookmarkNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessBookmarkNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessBookmarkNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessBookmarkNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessBookmarkNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessBookmarkNewResponseEnvelopeMessages] +type accessBookmarkNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessBookmarkNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessBookmarkNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessBookmarkNewResponseEnvelopeSuccess bool + +const ( + AccessBookmarkNewResponseEnvelopeSuccessTrue AccessBookmarkNewResponseEnvelopeSuccess = true +) + +type AccessBookmarkUpdateResponseEnvelope struct { + Errors []AccessBookmarkUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessBookmarkUpdateResponseEnvelopeMessages `json:"messages,required"` + Result AccessBookmarks `json:"result,required"` + // Whether the API call was successful + Success AccessBookmarkUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON accessBookmarkUpdateResponseEnvelopeJSON `json:"-"` +} + +// accessBookmarkUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessBookmarkUpdateResponseEnvelope] +type accessBookmarkUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessBookmarkUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessBookmarkUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessBookmarkUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessBookmarkUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessBookmarkUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessBookmarkUpdateResponseEnvelopeErrors] +type accessBookmarkUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessBookmarkUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessBookmarkUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessBookmarkUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessBookmarkUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessBookmarkUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AccessBookmarkUpdateResponseEnvelopeMessages] +type accessBookmarkUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessBookmarkUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessBookmarkUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessBookmarkUpdateResponseEnvelopeSuccess bool + +const ( + AccessBookmarkUpdateResponseEnvelopeSuccessTrue AccessBookmarkUpdateResponseEnvelopeSuccess = true +) + +type AccessBookmarkListResponseEnvelope struct { + Errors []AccessBookmarkListResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessBookmarkListResponseEnvelopeMessages `json:"messages,required"` + Result []AccessBookmarks `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessBookmarkListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AccessBookmarkListResponseEnvelopeResultInfo `json:"result_info"` + JSON accessBookmarkListResponseEnvelopeJSON `json:"-"` +} + +// accessBookmarkListResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessBookmarkListResponseEnvelope] +type accessBookmarkListResponseEnvelopeJSON 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 *AccessBookmarkListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessBookmarkListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessBookmarkListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessBookmarkListResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessBookmarkListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessBookmarkListResponseEnvelopeErrors] +type accessBookmarkListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessBookmarkListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessBookmarkListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessBookmarkListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessBookmarkListResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessBookmarkListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AccessBookmarkListResponseEnvelopeMessages] +type accessBookmarkListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessBookmarkListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessBookmarkListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessBookmarkListResponseEnvelopeSuccess bool + +const ( + AccessBookmarkListResponseEnvelopeSuccessTrue AccessBookmarkListResponseEnvelopeSuccess = true +) + +type AccessBookmarkListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON accessBookmarkListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// accessBookmarkListResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [AccessBookmarkListResponseEnvelopeResultInfo] +type accessBookmarkListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessBookmarkListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessBookmarkListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type AccessBookmarkDeleteResponseEnvelope struct { + Errors []AccessBookmarkDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessBookmarkDeleteResponseEnvelopeMessages `json:"messages,required"` + Result AccessBookmarkDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success AccessBookmarkDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON accessBookmarkDeleteResponseEnvelopeJSON `json:"-"` +} + +// accessBookmarkDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessBookmarkDeleteResponseEnvelope] +type accessBookmarkDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessBookmarkDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessBookmarkDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessBookmarkDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessBookmarkDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessBookmarkDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessBookmarkDeleteResponseEnvelopeErrors] +type accessBookmarkDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessBookmarkDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessBookmarkDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessBookmarkDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessBookmarkDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessBookmarkDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AccessBookmarkDeleteResponseEnvelopeMessages] +type accessBookmarkDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessBookmarkDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessBookmarkDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessBookmarkDeleteResponseEnvelopeSuccess bool + +const ( + AccessBookmarkDeleteResponseEnvelopeSuccessTrue AccessBookmarkDeleteResponseEnvelopeSuccess = true +) + +type AccessBookmarkGetResponseEnvelope struct { + Errors []AccessBookmarkGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessBookmarkGetResponseEnvelopeMessages `json:"messages,required"` + Result AccessBookmarks `json:"result,required"` + // Whether the API call was successful + Success AccessBookmarkGetResponseEnvelopeSuccess `json:"success,required"` + JSON accessBookmarkGetResponseEnvelopeJSON `json:"-"` +} + +// accessBookmarkGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessBookmarkGetResponseEnvelope] +type accessBookmarkGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessBookmarkGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessBookmarkGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessBookmarkGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessBookmarkGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessBookmarkGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessBookmarkGetResponseEnvelopeErrors] +type accessBookmarkGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessBookmarkGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessBookmarkGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessBookmarkGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessBookmarkGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessBookmarkGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessBookmarkGetResponseEnvelopeMessages] +type accessBookmarkGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessBookmarkGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessBookmarkGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessBookmarkGetResponseEnvelopeSuccess bool + +const ( + AccessBookmarkGetResponseEnvelopeSuccessTrue AccessBookmarkGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/accessbookmark_test.go b/zero_trust/accessbookmark_test.go new file mode 100644 index 00000000000..bd6637fb951 --- /dev/null +++ b/zero_trust/accessbookmark_test.go @@ -0,0 +1,150 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestAccessBookmarkNew(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Bookmarks.New( + context.TODO(), + "699d98642c564d2e855e9661899b7252", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + 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 TestAccessBookmarkUpdate(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Bookmarks.Update( + context.TODO(), + "699d98642c564d2e855e9661899b7252", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + 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 TestAccessBookmarkList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Bookmarks.List(context.TODO(), "699d98642c564d2e855e9661899b7252") + 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 TestAccessBookmarkDelete(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Bookmarks.Delete( + context.TODO(), + "699d98642c564d2e855e9661899b7252", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + 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 TestAccessBookmarkGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Bookmarks.Get( + context.TODO(), + "699d98642c564d2e855e9661899b7252", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + 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/zero_trust/accesscertificate.go b/zero_trust/accesscertificate.go new file mode 100644 index 00000000000..0ced57d596c --- /dev/null +++ b/zero_trust/accesscertificate.go @@ -0,0 +1,695 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AccessCertificateService 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 [NewAccessCertificateService] method +// instead. +type AccessCertificateService struct { + Options []option.RequestOption + Settings *AccessCertificateSettingService +} + +// NewAccessCertificateService 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 NewAccessCertificateService(opts ...option.RequestOption) (r *AccessCertificateService) { + r = &AccessCertificateService{} + r.Options = opts + r.Settings = NewAccessCertificateSettingService(opts...) + return +} + +// Adds a new mTLS root certificate to Access. +func (r *AccessCertificateService) New(ctx context.Context, params AccessCertificateNewParams, opts ...option.RequestOption) (res *AccessCertificates, err error) { + opts = append(r.Options[:], opts...) + var env AccessCertificateNewResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/access/certificates", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a configured mTLS certificate. +func (r *AccessCertificateService) Update(ctx context.Context, uuid string, params AccessCertificateUpdateParams, opts ...option.RequestOption) (res *AccessCertificates, err error) { + opts = append(r.Options[:], opts...) + var env AccessCertificateUpdateResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/access/certificates/%s", accountOrZone, accountOrZoneID, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists all mTLS root certificates. +func (r *AccessCertificateService) List(ctx context.Context, query AccessCertificateListParams, opts ...option.RequestOption) (res *[]AccessCertificates, err error) { + opts = append(r.Options[:], opts...) + var env AccessCertificateListResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/access/certificates", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes an mTLS certificate. +func (r *AccessCertificateService) Delete(ctx context.Context, uuid string, body AccessCertificateDeleteParams, opts ...option.RequestOption) (res *AccessCertificateDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessCertificateDeleteResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if body.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = body.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = body.ZoneID + } + path := fmt.Sprintf("%s/%s/access/certificates/%s", accountOrZone, accountOrZoneID, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a single mTLS certificate. +func (r *AccessCertificateService) Get(ctx context.Context, uuid string, query AccessCertificateGetParams, opts ...option.RequestOption) (res *AccessCertificates, err error) { + opts = append(r.Options[:], opts...) + var env AccessCertificateGetResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/access/certificates/%s", accountOrZone, accountOrZoneID, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AccessCertificates struct { + // The ID of the application that will use this certificate. + ID interface{} `json:"id"` + // The hostnames of the applications that will use this certificate. + AssociatedHostnames []string `json:"associated_hostnames"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + ExpiresOn time.Time `json:"expires_on" format:"date-time"` + // The MD5 fingerprint of the certificate. + Fingerprint string `json:"fingerprint"` + // The name of the certificate. + Name string `json:"name"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessCertificatesJSON `json:"-"` +} + +// accessCertificatesJSON contains the JSON metadata for the struct +// [AccessCertificates] +type accessCertificatesJSON struct { + ID apijson.Field + AssociatedHostnames apijson.Field + CreatedAt apijson.Field + ExpiresOn apijson.Field + Fingerprint apijson.Field + Name apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificates) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificatesJSON) RawJSON() string { + return r.raw +} + +type AccessCertificateDeleteResponse struct { + // UUID + ID string `json:"id"` + JSON accessCertificateDeleteResponseJSON `json:"-"` +} + +// accessCertificateDeleteResponseJSON contains the JSON metadata for the struct +// [AccessCertificateDeleteResponse] +type accessCertificateDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type AccessCertificateNewParams struct { + // The certificate content. + Certificate param.Field[string] `json:"certificate,required"` + // The name of the certificate. + Name param.Field[string] `json:"name,required"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // The hostnames of the applications that will use this certificate. + AssociatedHostnames param.Field[[]string] `json:"associated_hostnames"` +} + +func (r AccessCertificateNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AccessCertificateNewResponseEnvelope struct { + Errors []AccessCertificateNewResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessCertificateNewResponseEnvelopeMessages `json:"messages,required"` + Result AccessCertificates `json:"result,required"` + // Whether the API call was successful + Success AccessCertificateNewResponseEnvelopeSuccess `json:"success,required"` + JSON accessCertificateNewResponseEnvelopeJSON `json:"-"` +} + +// accessCertificateNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessCertificateNewResponseEnvelope] +type accessCertificateNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessCertificateNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCertificateNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessCertificateNewResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessCertificateNewResponseEnvelopeErrors] +type accessCertificateNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessCertificateNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCertificateNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessCertificateNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AccessCertificateNewResponseEnvelopeMessages] +type accessCertificateNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessCertificateNewResponseEnvelopeSuccess bool + +const ( + AccessCertificateNewResponseEnvelopeSuccessTrue AccessCertificateNewResponseEnvelopeSuccess = true +) + +type AccessCertificateUpdateParams struct { + // The hostnames of the applications that will use this certificate. + AssociatedHostnames param.Field[[]string] `json:"associated_hostnames,required"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // The name of the certificate. + Name param.Field[string] `json:"name"` +} + +func (r AccessCertificateUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AccessCertificateUpdateResponseEnvelope struct { + Errors []AccessCertificateUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessCertificateUpdateResponseEnvelopeMessages `json:"messages,required"` + Result AccessCertificates `json:"result,required"` + // Whether the API call was successful + Success AccessCertificateUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON accessCertificateUpdateResponseEnvelopeJSON `json:"-"` +} + +// accessCertificateUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessCertificateUpdateResponseEnvelope] +type accessCertificateUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessCertificateUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCertificateUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessCertificateUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessCertificateUpdateResponseEnvelopeErrors] +type accessCertificateUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessCertificateUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCertificateUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessCertificateUpdateResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AccessCertificateUpdateResponseEnvelopeMessages] +type accessCertificateUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessCertificateUpdateResponseEnvelopeSuccess bool + +const ( + AccessCertificateUpdateResponseEnvelopeSuccessTrue AccessCertificateUpdateResponseEnvelopeSuccess = true +) + +type AccessCertificateListParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessCertificateListResponseEnvelope struct { + Errors []AccessCertificateListResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessCertificateListResponseEnvelopeMessages `json:"messages,required"` + Result []AccessCertificates `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessCertificateListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AccessCertificateListResponseEnvelopeResultInfo `json:"result_info"` + JSON accessCertificateListResponseEnvelopeJSON `json:"-"` +} + +// accessCertificateListResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessCertificateListResponseEnvelope] +type accessCertificateListResponseEnvelopeJSON 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 *AccessCertificateListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessCertificateListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCertificateListResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessCertificateListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessCertificateListResponseEnvelopeErrors] +type accessCertificateListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessCertificateListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCertificateListResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessCertificateListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AccessCertificateListResponseEnvelopeMessages] +type accessCertificateListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessCertificateListResponseEnvelopeSuccess bool + +const ( + AccessCertificateListResponseEnvelopeSuccessTrue AccessCertificateListResponseEnvelopeSuccess = true +) + +type AccessCertificateListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON accessCertificateListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// accessCertificateListResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [AccessCertificateListResponseEnvelopeResultInfo] +type accessCertificateListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type AccessCertificateDeleteParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessCertificateDeleteResponseEnvelope struct { + Errors []AccessCertificateDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessCertificateDeleteResponseEnvelopeMessages `json:"messages,required"` + Result AccessCertificateDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success AccessCertificateDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON accessCertificateDeleteResponseEnvelopeJSON `json:"-"` +} + +// accessCertificateDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessCertificateDeleteResponseEnvelope] +type accessCertificateDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessCertificateDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCertificateDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessCertificateDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessCertificateDeleteResponseEnvelopeErrors] +type accessCertificateDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessCertificateDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCertificateDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessCertificateDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AccessCertificateDeleteResponseEnvelopeMessages] +type accessCertificateDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessCertificateDeleteResponseEnvelopeSuccess bool + +const ( + AccessCertificateDeleteResponseEnvelopeSuccessTrue AccessCertificateDeleteResponseEnvelopeSuccess = true +) + +type AccessCertificateGetParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessCertificateGetResponseEnvelope struct { + Errors []AccessCertificateGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessCertificateGetResponseEnvelopeMessages `json:"messages,required"` + Result AccessCertificates `json:"result,required"` + // Whether the API call was successful + Success AccessCertificateGetResponseEnvelopeSuccess `json:"success,required"` + JSON accessCertificateGetResponseEnvelopeJSON `json:"-"` +} + +// accessCertificateGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessCertificateGetResponseEnvelope] +type accessCertificateGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessCertificateGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCertificateGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessCertificateGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessCertificateGetResponseEnvelopeErrors] +type accessCertificateGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessCertificateGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCertificateGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessCertificateGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AccessCertificateGetResponseEnvelopeMessages] +type accessCertificateGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessCertificateGetResponseEnvelopeSuccess bool + +const ( + AccessCertificateGetResponseEnvelopeSuccessTrue AccessCertificateGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/accesscertificate_test.go b/zero_trust/accesscertificate_test.go new file mode 100644 index 00000000000..2be8a4cda44 --- /dev/null +++ b/zero_trust/accesscertificate_test.go @@ -0,0 +1,167 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestAccessCertificateNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Certificates.New(context.TODO(), zero_trust.AccessCertificateNewParams{ + Certificate: cloudflare.F("-----BEGIN CERTIFICATE-----\nMIIGAjCCA+qgAwIBAgIJAI7kymlF7CWT...N4RI7KKB7nikiuUf8vhULKy5IX10\nDrUtmu/B\n-----END CERTIFICATE-----"), + Name: cloudflare.F("Allow devs"), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + AssociatedHostnames: cloudflare.F([]string{"admin.example.com", "admin.example.com", "admin.example.com"}), + }) + 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 TestAccessCertificateUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Certificates.Update( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessCertificateUpdateParams{ + AssociatedHostnames: cloudflare.F([]string{"admin.example.com", "admin.example.com", "admin.example.com"}), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + Name: cloudflare.F("Allow devs"), + }, + ) + 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 TestAccessCertificateListWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Certificates.List(context.TODO(), zero_trust.AccessCertificateListParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }) + 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 TestAccessCertificateDeleteWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Certificates.Delete( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessCertificateDeleteParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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 TestAccessCertificateGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Certificates.Get( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessCertificateGetParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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/zero_trust/accesscertificatesetting.go b/zero_trust/accesscertificatesetting.go new file mode 100644 index 00000000000..283b2a93074 --- /dev/null +++ b/zero_trust/accesscertificatesetting.go @@ -0,0 +1,370 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AccessCertificateSettingService 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 +// [NewAccessCertificateSettingService] method instead. +type AccessCertificateSettingService struct { + Options []option.RequestOption +} + +// NewAccessCertificateSettingService 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 NewAccessCertificateSettingService(opts ...option.RequestOption) (r *AccessCertificateSettingService) { + r = &AccessCertificateSettingService{} + r.Options = opts + return +} + +// Updates an mTLS certificate's hostname settings. +func (r *AccessCertificateSettingService) Update(ctx context.Context, params AccessCertificateSettingUpdateParams, opts ...option.RequestOption) (res *[]AccessSettings, err error) { + opts = append(r.Options[:], opts...) + var env AccessCertificateSettingUpdateResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/access/certificates/settings", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List all mTLS hostname settings for this account or zone. +func (r *AccessCertificateSettingService) List(ctx context.Context, query AccessCertificateSettingListParams, opts ...option.RequestOption) (res *[]AccessSettings, err error) { + opts = append(r.Options[:], opts...) + var env AccessCertificateSettingListResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/access/certificates/settings", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AccessSettings struct { + // Request client certificates for this hostname in China. Can only be set to true + // if this zone is china network enabled. + ChinaNetwork bool `json:"china_network,required"` + // Client Certificate Forwarding is a feature that takes the client cert provided + // by the eyeball to the edge, and forwards it to the origin as a HTTP header to + // allow logging on the origin. + ClientCertificateForwarding bool `json:"client_certificate_forwarding,required"` + // The hostname that these settings apply to. + Hostname string `json:"hostname,required"` + JSON accessSettingsJSON `json:"-"` +} + +// accessSettingsJSON contains the JSON metadata for the struct [AccessSettings] +type accessSettingsJSON struct { + ChinaNetwork apijson.Field + ClientCertificateForwarding apijson.Field + Hostname apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessSettings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessSettingsJSON) RawJSON() string { + return r.raw +} + +type AccessSettingsParam struct { + // Request client certificates for this hostname in China. Can only be set to true + // if this zone is china network enabled. + ChinaNetwork param.Field[bool] `json:"china_network,required"` + // Client Certificate Forwarding is a feature that takes the client cert provided + // by the eyeball to the edge, and forwards it to the origin as a HTTP header to + // allow logging on the origin. + ClientCertificateForwarding param.Field[bool] `json:"client_certificate_forwarding,required"` + // The hostname that these settings apply to. + Hostname param.Field[string] `json:"hostname,required"` +} + +func (r AccessSettingsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AccessCertificateSettingUpdateParams struct { + Settings param.Field[[]AccessSettingsParam] `json:"settings,required"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +func (r AccessCertificateSettingUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AccessCertificateSettingUpdateResponseEnvelope struct { + Errors []AccessCertificateSettingUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessCertificateSettingUpdateResponseEnvelopeMessages `json:"messages,required"` + Result []AccessSettings `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessCertificateSettingUpdateResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AccessCertificateSettingUpdateResponseEnvelopeResultInfo `json:"result_info"` + JSON accessCertificateSettingUpdateResponseEnvelopeJSON `json:"-"` +} + +// accessCertificateSettingUpdateResponseEnvelopeJSON contains the JSON metadata +// for the struct [AccessCertificateSettingUpdateResponseEnvelope] +type accessCertificateSettingUpdateResponseEnvelopeJSON 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 *AccessCertificateSettingUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateSettingUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessCertificateSettingUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCertificateSettingUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessCertificateSettingUpdateResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [AccessCertificateSettingUpdateResponseEnvelopeErrors] +type accessCertificateSettingUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateSettingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateSettingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessCertificateSettingUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCertificateSettingUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessCertificateSettingUpdateResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [AccessCertificateSettingUpdateResponseEnvelopeMessages] +type accessCertificateSettingUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateSettingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateSettingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessCertificateSettingUpdateResponseEnvelopeSuccess bool + +const ( + AccessCertificateSettingUpdateResponseEnvelopeSuccessTrue AccessCertificateSettingUpdateResponseEnvelopeSuccess = true +) + +type AccessCertificateSettingUpdateResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON accessCertificateSettingUpdateResponseEnvelopeResultInfoJSON `json:"-"` +} + +// accessCertificateSettingUpdateResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct +// [AccessCertificateSettingUpdateResponseEnvelopeResultInfo] +type accessCertificateSettingUpdateResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateSettingUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateSettingUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type AccessCertificateSettingListParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessCertificateSettingListResponseEnvelope struct { + Errors []AccessCertificateSettingListResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessCertificateSettingListResponseEnvelopeMessages `json:"messages,required"` + Result []AccessSettings `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessCertificateSettingListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AccessCertificateSettingListResponseEnvelopeResultInfo `json:"result_info"` + JSON accessCertificateSettingListResponseEnvelopeJSON `json:"-"` +} + +// accessCertificateSettingListResponseEnvelopeJSON contains the JSON metadata for +// the struct [AccessCertificateSettingListResponseEnvelope] +type accessCertificateSettingListResponseEnvelopeJSON 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 *AccessCertificateSettingListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateSettingListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessCertificateSettingListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCertificateSettingListResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessCertificateSettingListResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [AccessCertificateSettingListResponseEnvelopeErrors] +type accessCertificateSettingListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateSettingListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateSettingListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessCertificateSettingListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCertificateSettingListResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessCertificateSettingListResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [AccessCertificateSettingListResponseEnvelopeMessages] +type accessCertificateSettingListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateSettingListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateSettingListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessCertificateSettingListResponseEnvelopeSuccess bool + +const ( + AccessCertificateSettingListResponseEnvelopeSuccessTrue AccessCertificateSettingListResponseEnvelopeSuccess = true +) + +type AccessCertificateSettingListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON accessCertificateSettingListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// accessCertificateSettingListResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [AccessCertificateSettingListResponseEnvelopeResultInfo] +type accessCertificateSettingListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCertificateSettingListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCertificateSettingListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/accesscertificatesetting_test.go b/zero_trust/accesscertificatesetting_test.go new file mode 100644 index 00000000000..c632a6b880c --- /dev/null +++ b/zero_trust/accesscertificatesetting_test.go @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestAccessCertificateSettingUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Certificates.Settings.Update(context.TODO(), zero_trust.AccessCertificateSettingUpdateParams{ + Settings: cloudflare.F([]zero_trust.AccessSettingsParam{{ + ChinaNetwork: cloudflare.F(false), + ClientCertificateForwarding: cloudflare.F(true), + Hostname: cloudflare.F("admin.example.com"), + }, { + ChinaNetwork: cloudflare.F(false), + ClientCertificateForwarding: cloudflare.F(true), + Hostname: cloudflare.F("admin.example.com"), + }, { + ChinaNetwork: cloudflare.F(false), + ClientCertificateForwarding: cloudflare.F(true), + Hostname: cloudflare.F("admin.example.com"), + }}), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }) + 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 TestAccessCertificateSettingListWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Certificates.Settings.List(context.TODO(), zero_trust.AccessCertificateSettingListParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }) + 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/zero_trust/accesscustompage.go b/zero_trust/accesscustompage.go new file mode 100644 index 00000000000..b0850012634 --- /dev/null +++ b/zero_trust/accesscustompage.go @@ -0,0 +1,693 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AccessCustomPageService 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 [NewAccessCustomPageService] method +// instead. +type AccessCustomPageService struct { + Options []option.RequestOption +} + +// NewAccessCustomPageService 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 NewAccessCustomPageService(opts ...option.RequestOption) (r *AccessCustomPageService) { + r = &AccessCustomPageService{} + r.Options = opts + return +} + +// Create a custom page +func (r *AccessCustomPageService) New(ctx context.Context, identifier string, body AccessCustomPageNewParams, opts ...option.RequestOption) (res *AccessCustomPageWithoutHTML, err error) { + opts = append(r.Options[:], opts...) + var env AccessCustomPageNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/custom_pages", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update a custom page +func (r *AccessCustomPageService) Update(ctx context.Context, identifier string, uuid string, body AccessCustomPageUpdateParams, opts ...option.RequestOption) (res *AccessCustomPageWithoutHTML, err error) { + opts = append(r.Options[:], opts...) + var env AccessCustomPageUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/custom_pages/%s", identifier, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List custom pages +func (r *AccessCustomPageService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *[]AccessCustomPageWithoutHTML, err error) { + opts = append(r.Options[:], opts...) + var env AccessCustomPageListResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/custom_pages", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a custom page +func (r *AccessCustomPageService) Delete(ctx context.Context, identifier string, uuid string, opts ...option.RequestOption) (res *AccessCustomPageDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessCustomPageDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/custom_pages/%s", identifier, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a custom page and also returns its HTML. +func (r *AccessCustomPageService) Get(ctx context.Context, identifier string, uuid string, opts ...option.RequestOption) (res *AccessCustomPage, err error) { + opts = append(r.Options[:], opts...) + var env AccessCustomPageGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/custom_pages/%s", identifier, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AccessCustomPage struct { + // Custom page HTML. + CustomHTML string `json:"custom_html,required"` + // Custom page name. + Name string `json:"name,required"` + // Custom page type. + Type AccessCustomPageType `json:"type,required"` + // Number of apps the custom page is assigned to. + AppCount int64 `json:"app_count"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // UUID + Uid string `json:"uid"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessCustomPageJSON `json:"-"` +} + +// accessCustomPageJSON contains the JSON metadata for the struct +// [AccessCustomPage] +type accessCustomPageJSON struct { + CustomHTML apijson.Field + Name apijson.Field + Type apijson.Field + AppCount apijson.Field + CreatedAt apijson.Field + Uid apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCustomPage) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageJSON) RawJSON() string { + return r.raw +} + +// Custom page type. +type AccessCustomPageType string + +const ( + AccessCustomPageTypeIdentityDenied AccessCustomPageType = "identity_denied" + AccessCustomPageTypeForbidden AccessCustomPageType = "forbidden" +) + +type AccessCustomPageWithoutHTML struct { + // Custom page name. + Name string `json:"name,required"` + // Custom page type. + Type AccessCustomPageWithoutHTMLType `json:"type,required"` + // Number of apps the custom page is assigned to. + AppCount int64 `json:"app_count"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // UUID + Uid string `json:"uid"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessCustomPageWithoutHTMLJSON `json:"-"` +} + +// accessCustomPageWithoutHTMLJSON contains the JSON metadata for the struct +// [AccessCustomPageWithoutHTML] +type accessCustomPageWithoutHTMLJSON struct { + Name apijson.Field + Type apijson.Field + AppCount apijson.Field + CreatedAt apijson.Field + Uid apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCustomPageWithoutHTML) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageWithoutHTMLJSON) RawJSON() string { + return r.raw +} + +// Custom page type. +type AccessCustomPageWithoutHTMLType string + +const ( + AccessCustomPageWithoutHTMLTypeIdentityDenied AccessCustomPageWithoutHTMLType = "identity_denied" + AccessCustomPageWithoutHTMLTypeForbidden AccessCustomPageWithoutHTMLType = "forbidden" +) + +type AccessCustomPageDeleteResponse struct { + // UUID + ID string `json:"id"` + JSON accessCustomPageDeleteResponseJSON `json:"-"` +} + +// accessCustomPageDeleteResponseJSON contains the JSON metadata for the struct +// [AccessCustomPageDeleteResponse] +type accessCustomPageDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCustomPageDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type AccessCustomPageNewParams struct { + // Custom page HTML. + CustomHTML param.Field[string] `json:"custom_html,required"` + // Custom page name. + Name param.Field[string] `json:"name,required"` + // Custom page type. + Type param.Field[AccessCustomPageNewParamsType] `json:"type,required"` + // Number of apps the custom page is assigned to. + AppCount param.Field[int64] `json:"app_count"` +} + +func (r AccessCustomPageNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Custom page type. +type AccessCustomPageNewParamsType string + +const ( + AccessCustomPageNewParamsTypeIdentityDenied AccessCustomPageNewParamsType = "identity_denied" + AccessCustomPageNewParamsTypeForbidden AccessCustomPageNewParamsType = "forbidden" +) + +type AccessCustomPageNewResponseEnvelope struct { + Errors []AccessCustomPageNewResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessCustomPageNewResponseEnvelopeMessages `json:"messages,required"` + Result AccessCustomPageWithoutHTML `json:"result,required"` + // Whether the API call was successful + Success AccessCustomPageNewResponseEnvelopeSuccess `json:"success,required"` + JSON accessCustomPageNewResponseEnvelopeJSON `json:"-"` +} + +// accessCustomPageNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessCustomPageNewResponseEnvelope] +type accessCustomPageNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCustomPageNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessCustomPageNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCustomPageNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessCustomPageNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessCustomPageNewResponseEnvelopeErrors] +type accessCustomPageNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCustomPageNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessCustomPageNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCustomPageNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessCustomPageNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AccessCustomPageNewResponseEnvelopeMessages] +type accessCustomPageNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCustomPageNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessCustomPageNewResponseEnvelopeSuccess bool + +const ( + AccessCustomPageNewResponseEnvelopeSuccessTrue AccessCustomPageNewResponseEnvelopeSuccess = true +) + +type AccessCustomPageUpdateParams struct { + // Custom page HTML. + CustomHTML param.Field[string] `json:"custom_html,required"` + // Custom page name. + Name param.Field[string] `json:"name,required"` + // Custom page type. + Type param.Field[AccessCustomPageUpdateParamsType] `json:"type,required"` + // Number of apps the custom page is assigned to. + AppCount param.Field[int64] `json:"app_count"` +} + +func (r AccessCustomPageUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Custom page type. +type AccessCustomPageUpdateParamsType string + +const ( + AccessCustomPageUpdateParamsTypeIdentityDenied AccessCustomPageUpdateParamsType = "identity_denied" + AccessCustomPageUpdateParamsTypeForbidden AccessCustomPageUpdateParamsType = "forbidden" +) + +type AccessCustomPageUpdateResponseEnvelope struct { + Errors []AccessCustomPageUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessCustomPageUpdateResponseEnvelopeMessages `json:"messages,required"` + Result AccessCustomPageWithoutHTML `json:"result,required"` + // Whether the API call was successful + Success AccessCustomPageUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON accessCustomPageUpdateResponseEnvelopeJSON `json:"-"` +} + +// accessCustomPageUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessCustomPageUpdateResponseEnvelope] +type accessCustomPageUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCustomPageUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessCustomPageUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCustomPageUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessCustomPageUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessCustomPageUpdateResponseEnvelopeErrors] +type accessCustomPageUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCustomPageUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessCustomPageUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCustomPageUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessCustomPageUpdateResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AccessCustomPageUpdateResponseEnvelopeMessages] +type accessCustomPageUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCustomPageUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessCustomPageUpdateResponseEnvelopeSuccess bool + +const ( + AccessCustomPageUpdateResponseEnvelopeSuccessTrue AccessCustomPageUpdateResponseEnvelopeSuccess = true +) + +type AccessCustomPageListResponseEnvelope struct { + Errors []AccessCustomPageListResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessCustomPageListResponseEnvelopeMessages `json:"messages,required"` + Result []AccessCustomPageWithoutHTML `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessCustomPageListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AccessCustomPageListResponseEnvelopeResultInfo `json:"result_info"` + JSON accessCustomPageListResponseEnvelopeJSON `json:"-"` +} + +// accessCustomPageListResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessCustomPageListResponseEnvelope] +type accessCustomPageListResponseEnvelopeJSON 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 *AccessCustomPageListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessCustomPageListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCustomPageListResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessCustomPageListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessCustomPageListResponseEnvelopeErrors] +type accessCustomPageListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCustomPageListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessCustomPageListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCustomPageListResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessCustomPageListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AccessCustomPageListResponseEnvelopeMessages] +type accessCustomPageListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCustomPageListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessCustomPageListResponseEnvelopeSuccess bool + +const ( + AccessCustomPageListResponseEnvelopeSuccessTrue AccessCustomPageListResponseEnvelopeSuccess = true +) + +type AccessCustomPageListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON accessCustomPageListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// accessCustomPageListResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [AccessCustomPageListResponseEnvelopeResultInfo] +type accessCustomPageListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCustomPageListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type AccessCustomPageDeleteResponseEnvelope struct { + Errors []AccessCustomPageDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessCustomPageDeleteResponseEnvelopeMessages `json:"messages,required"` + Result AccessCustomPageDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success AccessCustomPageDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON accessCustomPageDeleteResponseEnvelopeJSON `json:"-"` +} + +// accessCustomPageDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessCustomPageDeleteResponseEnvelope] +type accessCustomPageDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCustomPageDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessCustomPageDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCustomPageDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessCustomPageDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessCustomPageDeleteResponseEnvelopeErrors] +type accessCustomPageDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCustomPageDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessCustomPageDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCustomPageDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessCustomPageDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AccessCustomPageDeleteResponseEnvelopeMessages] +type accessCustomPageDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCustomPageDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessCustomPageDeleteResponseEnvelopeSuccess bool + +const ( + AccessCustomPageDeleteResponseEnvelopeSuccessTrue AccessCustomPageDeleteResponseEnvelopeSuccess = true +) + +type AccessCustomPageGetResponseEnvelope struct { + Errors []AccessCustomPageGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessCustomPageGetResponseEnvelopeMessages `json:"messages,required"` + Result AccessCustomPage `json:"result,required"` + // Whether the API call was successful + Success AccessCustomPageGetResponseEnvelopeSuccess `json:"success,required"` + JSON accessCustomPageGetResponseEnvelopeJSON `json:"-"` +} + +// accessCustomPageGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessCustomPageGetResponseEnvelope] +type accessCustomPageGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCustomPageGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessCustomPageGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCustomPageGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessCustomPageGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessCustomPageGetResponseEnvelopeErrors] +type accessCustomPageGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCustomPageGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessCustomPageGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessCustomPageGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessCustomPageGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AccessCustomPageGetResponseEnvelopeMessages] +type accessCustomPageGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessCustomPageGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessCustomPageGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessCustomPageGetResponseEnvelopeSuccess bool + +const ( + AccessCustomPageGetResponseEnvelopeSuccessTrue AccessCustomPageGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/accesscustompage_test.go b/zero_trust/accesscustompage_test.go new file mode 100644 index 00000000000..14e3480ddff --- /dev/null +++ b/zero_trust/accesscustompage_test.go @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestAccessCustomPageNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.CustomPages.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + zero_trust.AccessCustomPageNewParams{ + CustomHTML: cloudflare.F("

Access Denied

"), + Name: cloudflare.F("string"), + Type: cloudflare.F(zero_trust.AccessCustomPageNewParamsTypeIdentityDenied), + AppCount: cloudflare.F(int64(0)), + }, + ) + 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 TestAccessCustomPageUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.CustomPages.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessCustomPageUpdateParams{ + CustomHTML: cloudflare.F("

Access Denied

"), + Name: cloudflare.F("string"), + Type: cloudflare.F(zero_trust.AccessCustomPageUpdateParamsTypeIdentityDenied), + AppCount: cloudflare.F(int64(0)), + }, + ) + 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 TestAccessCustomPageList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.CustomPages.List(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()) + } +} + +func TestAccessCustomPageDelete(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.CustomPages.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + 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 TestAccessCustomPageGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.CustomPages.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + 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/zero_trust/accessgroup.go b/zero_trust/accessgroup.go new file mode 100644 index 00000000000..8cede6bee51 --- /dev/null +++ b/zero_trust/accessgroup.go @@ -0,0 +1,6966 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// AccessGroupService 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 [NewAccessGroupService] method +// instead. +type AccessGroupService struct { + Options []option.RequestOption +} + +// NewAccessGroupService 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 NewAccessGroupService(opts ...option.RequestOption) (r *AccessGroupService) { + r = &AccessGroupService{} + r.Options = opts + return +} + +// Creates a new Access group. +func (r *AccessGroupService) New(ctx context.Context, params AccessGroupNewParams, opts ...option.RequestOption) (res *AccessGroups, err error) { + opts = append(r.Options[:], opts...) + var env AccessGroupNewResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/access/groups", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a configured Access group. +func (r *AccessGroupService) Update(ctx context.Context, uuid string, params AccessGroupUpdateParams, opts ...option.RequestOption) (res *AccessGroups, err error) { + opts = append(r.Options[:], opts...) + var env AccessGroupUpdateResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/access/groups/%s", accountOrZone, accountOrZoneID, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists all Access groups. +func (r *AccessGroupService) List(ctx context.Context, query AccessGroupListParams, opts ...option.RequestOption) (res *[]AccessGroups, err error) { + opts = append(r.Options[:], opts...) + var env AccessGroupListResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/access/groups", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes an Access group. +func (r *AccessGroupService) Delete(ctx context.Context, uuid string, body AccessGroupDeleteParams, opts ...option.RequestOption) (res *AccessGroupDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessGroupDeleteResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if body.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = body.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = body.ZoneID + } + path := fmt.Sprintf("%s/%s/access/groups/%s", accountOrZone, accountOrZoneID, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a single Access group. +func (r *AccessGroupService) Get(ctx context.Context, uuid string, query AccessGroupGetParams, opts ...option.RequestOption) (res *AccessGroups, err error) { + opts = append(r.Options[:], opts...) + var env AccessGroupGetResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/access/groups/%s", accountOrZone, accountOrZoneID, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AccessGroups struct { + // UUID + ID string `json:"id"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // Rules evaluated with a NOT logical operator. To match a policy, a user cannot + // meet any of the Exclude rules. + Exclude []AccessGroupsExclude `json:"exclude"` + // Rules evaluated with an OR logical operator. A user needs to meet only one of + // the Include rules. + Include []AccessGroupsInclude `json:"include"` + // Rules evaluated with an AND logical operator. To match a policy, a user must + // meet all of the Require rules. + IsDefault []AccessGroupsIsDefault `json:"is_default"` + // The name of the Access group. + Name string `json:"name"` + // Rules evaluated with an AND logical operator. To match a policy, a user must + // meet all of the Require rules. + Require []AccessGroupsRequire `json:"require"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessGroupsJSON `json:"-"` +} + +// accessGroupsJSON contains the JSON metadata for the struct [AccessGroups] +type accessGroupsJSON struct { + ID apijson.Field + CreatedAt apijson.Field + Exclude apijson.Field + Include apijson.Field + IsDefault apijson.Field + Name apijson.Field + Require apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroups) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsJSON) RawJSON() string { + return r.raw +} + +// Matches a specific email. +// +// Union satisfied by [zero_trust.AccessGroupsExcludeAccessEmailRule], +// [zero_trust.AccessGroupsExcludeAccessEmailListRule], +// [zero_trust.AccessGroupsExcludeAccessDomainRule], +// [zero_trust.AccessGroupsExcludeAccessEveryoneRule], +// [zero_trust.AccessGroupsExcludeAccessIPRule], +// [zero_trust.AccessGroupsExcludeAccessIPListRule], +// [zero_trust.AccessGroupsExcludeAccessCertificateRule], +// [zero_trust.AccessGroupsExcludeAccessAccessGroupRule], +// [zero_trust.AccessGroupsExcludeAccessAzureGroupRule], +// [zero_trust.AccessGroupsExcludeAccessGitHubOrganizationRule], +// [zero_trust.AccessGroupsExcludeAccessGsuiteGroupRule], +// [zero_trust.AccessGroupsExcludeAccessOktaGroupRule], +// [zero_trust.AccessGroupsExcludeAccessSamlGroupRule], +// [zero_trust.AccessGroupsExcludeAccessServiceTokenRule], +// [zero_trust.AccessGroupsExcludeAccessAnyValidServiceTokenRule], +// [zero_trust.AccessGroupsExcludeAccessExternalEvaluationRule], +// [zero_trust.AccessGroupsExcludeAccessCountryRule], +// [zero_trust.AccessGroupsExcludeAccessAuthenticationMethodRule] or +// [zero_trust.AccessGroupsExcludeAccessDevicePostureRule]. +type AccessGroupsExclude interface { + implementsZeroTrustAccessGroupsExclude() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessGroupsExclude)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessEmailRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessEmailListRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessDomainRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessEveryoneRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessIPRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessIPListRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessCertificateRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessAccessGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessAzureGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessGitHubOrganizationRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessGsuiteGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessOktaGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessSamlGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessServiceTokenRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessAnyValidServiceTokenRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessExternalEvaluationRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessCountryRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessAuthenticationMethodRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsExcludeAccessDevicePostureRule{}), + }, + ) +} + +// Matches a specific email. +type AccessGroupsExcludeAccessEmailRule struct { + Email AccessGroupsExcludeAccessEmailRuleEmail `json:"email,required"` + JSON accessGroupsExcludeAccessEmailRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessEmailRuleJSON contains the JSON metadata for the struct +// [AccessGroupsExcludeAccessEmailRule] +type accessGroupsExcludeAccessEmailRuleJSON struct { + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessEmailRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessEmailRule) implementsZeroTrustAccessGroupsExclude() {} + +type AccessGroupsExcludeAccessEmailRuleEmail struct { + // The email of the user. + Email string `json:"email,required" format:"email"` + JSON accessGroupsExcludeAccessEmailRuleEmailJSON `json:"-"` +} + +// accessGroupsExcludeAccessEmailRuleEmailJSON contains the JSON metadata for the +// struct [AccessGroupsExcludeAccessEmailRuleEmail] +type accessGroupsExcludeAccessEmailRuleEmailJSON struct { + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessEmailRuleEmailJSON) RawJSON() string { + return r.raw +} + +// Matches an email address from a list. +type AccessGroupsExcludeAccessEmailListRule struct { + EmailList AccessGroupsExcludeAccessEmailListRuleEmailList `json:"email_list,required"` + JSON accessGroupsExcludeAccessEmailListRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessEmailListRuleJSON contains the JSON metadata for the +// struct [AccessGroupsExcludeAccessEmailListRule] +type accessGroupsExcludeAccessEmailListRuleJSON struct { + EmailList apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessEmailListRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessEmailListRule) implementsZeroTrustAccessGroupsExclude() {} + +type AccessGroupsExcludeAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID string `json:"id,required"` + JSON accessGroupsExcludeAccessEmailListRuleEmailListJSON `json:"-"` +} + +// accessGroupsExcludeAccessEmailListRuleEmailListJSON contains the JSON metadata +// for the struct [AccessGroupsExcludeAccessEmailListRuleEmailList] +type accessGroupsExcludeAccessEmailListRuleEmailListJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessEmailListRuleEmailListJSON) RawJSON() string { + return r.raw +} + +// Match an entire email domain. +type AccessGroupsExcludeAccessDomainRule struct { + EmailDomain AccessGroupsExcludeAccessDomainRuleEmailDomain `json:"email_domain,required"` + JSON accessGroupsExcludeAccessDomainRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessDomainRuleJSON contains the JSON metadata for the +// struct [AccessGroupsExcludeAccessDomainRule] +type accessGroupsExcludeAccessDomainRuleJSON struct { + EmailDomain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessDomainRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessDomainRule) implementsZeroTrustAccessGroupsExclude() {} + +type AccessGroupsExcludeAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain string `json:"domain,required"` + JSON accessGroupsExcludeAccessDomainRuleEmailDomainJSON `json:"-"` +} + +// accessGroupsExcludeAccessDomainRuleEmailDomainJSON contains the JSON metadata +// for the struct [AccessGroupsExcludeAccessDomainRuleEmailDomain] +type accessGroupsExcludeAccessDomainRuleEmailDomainJSON struct { + Domain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessDomainRuleEmailDomainJSON) RawJSON() string { + return r.raw +} + +// Matches everyone. +type AccessGroupsExcludeAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone interface{} `json:"everyone,required"` + JSON accessGroupsExcludeAccessEveryoneRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessEveryoneRuleJSON contains the JSON metadata for the +// struct [AccessGroupsExcludeAccessEveryoneRule] +type accessGroupsExcludeAccessEveryoneRuleJSON struct { + Everyone apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessEveryoneRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessEveryoneRule) implementsZeroTrustAccessGroupsExclude() {} + +// Matches an IP address block. +type AccessGroupsExcludeAccessIPRule struct { + IP AccessGroupsExcludeAccessIPRuleIP `json:"ip,required"` + JSON accessGroupsExcludeAccessIPRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessIPRuleJSON contains the JSON metadata for the struct +// [AccessGroupsExcludeAccessIPRule] +type accessGroupsExcludeAccessIPRuleJSON struct { + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessIPRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessIPRule) implementsZeroTrustAccessGroupsExclude() {} + +type AccessGroupsExcludeAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP string `json:"ip,required"` + JSON accessGroupsExcludeAccessIPRuleIPJSON `json:"-"` +} + +// accessGroupsExcludeAccessIPRuleIPJSON contains the JSON metadata for the struct +// [AccessGroupsExcludeAccessIPRuleIP] +type accessGroupsExcludeAccessIPRuleIPJSON struct { + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessIPRuleIPJSON) RawJSON() string { + return r.raw +} + +// Matches an IP address from a list. +type AccessGroupsExcludeAccessIPListRule struct { + IPList AccessGroupsExcludeAccessIPListRuleIPList `json:"ip_list,required"` + JSON accessGroupsExcludeAccessIPListRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessIPListRuleJSON contains the JSON metadata for the +// struct [AccessGroupsExcludeAccessIPListRule] +type accessGroupsExcludeAccessIPListRuleJSON struct { + IPList apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessIPListRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessIPListRule) implementsZeroTrustAccessGroupsExclude() {} + +type AccessGroupsExcludeAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID string `json:"id,required"` + JSON accessGroupsExcludeAccessIPListRuleIPListJSON `json:"-"` +} + +// accessGroupsExcludeAccessIPListRuleIPListJSON contains the JSON metadata for the +// struct [AccessGroupsExcludeAccessIPListRuleIPList] +type accessGroupsExcludeAccessIPListRuleIPListJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessIPListRuleIPListJSON) RawJSON() string { + return r.raw +} + +// Matches any valid client certificate. +type AccessGroupsExcludeAccessCertificateRule struct { + Certificate interface{} `json:"certificate,required"` + JSON accessGroupsExcludeAccessCertificateRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessCertificateRuleJSON contains the JSON metadata for the +// struct [AccessGroupsExcludeAccessCertificateRule] +type accessGroupsExcludeAccessCertificateRuleJSON struct { + Certificate apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessCertificateRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessCertificateRule) implementsZeroTrustAccessGroupsExclude() {} + +// Matches an Access group. +type AccessGroupsExcludeAccessAccessGroupRule struct { + Group AccessGroupsExcludeAccessAccessGroupRuleGroup `json:"group,required"` + JSON accessGroupsExcludeAccessAccessGroupRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessAccessGroupRuleJSON contains the JSON metadata for the +// struct [AccessGroupsExcludeAccessAccessGroupRule] +type accessGroupsExcludeAccessAccessGroupRuleJSON struct { + Group apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessAccessGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessAccessGroupRule) implementsZeroTrustAccessGroupsExclude() {} + +type AccessGroupsExcludeAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID string `json:"id,required"` + JSON accessGroupsExcludeAccessAccessGroupRuleGroupJSON `json:"-"` +} + +// accessGroupsExcludeAccessAccessGroupRuleGroupJSON contains the JSON metadata for +// the struct [AccessGroupsExcludeAccessAccessGroupRuleGroup] +type accessGroupsExcludeAccessAccessGroupRuleGroupJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessAccessGroupRuleGroupJSON) RawJSON() string { + return r.raw +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessGroupsExcludeAccessAzureGroupRule struct { + AzureAd AccessGroupsExcludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` + JSON accessGroupsExcludeAccessAzureGroupRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessAzureGroupRuleJSON contains the JSON metadata for the +// struct [AccessGroupsExcludeAccessAzureGroupRule] +type accessGroupsExcludeAccessAzureGroupRuleJSON struct { + AzureAd apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessAzureGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessAzureGroupRule) implementsZeroTrustAccessGroupsExclude() {} + +type AccessGroupsExcludeAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID string `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID string `json:"connection_id,required"` + JSON accessGroupsExcludeAccessAzureGroupRuleAzureAdJSON `json:"-"` +} + +// accessGroupsExcludeAccessAzureGroupRuleAzureAdJSON contains the JSON metadata +// for the struct [AccessGroupsExcludeAccessAzureGroupRuleAzureAd] +type accessGroupsExcludeAccessAzureGroupRuleAzureAdJSON struct { + ID apijson.Field + ConnectionID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { + return r.raw +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessGroupsExcludeAccessGitHubOrganizationRule struct { + GitHubOrganization AccessGroupsExcludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` + JSON accessGroupsExcludeAccessGitHubOrganizationRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessGitHubOrganizationRuleJSON contains the JSON metadata +// for the struct [AccessGroupsExcludeAccessGitHubOrganizationRule] +type accessGroupsExcludeAccessGitHubOrganizationRuleJSON struct { + GitHubOrganization apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessGitHubOrganizationRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupsExclude() {} + +type AccessGroupsExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID string `json:"connection_id,required"` + // The name of the organization. + Name string `json:"name,required"` + JSON accessGroupsExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` +} + +// accessGroupsExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON contains +// the JSON metadata for the struct +// [AccessGroupsExcludeAccessGitHubOrganizationRuleGitHubOrganization] +type accessGroupsExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { + ConnectionID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { + return r.raw +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessGroupsExcludeAccessGsuiteGroupRule struct { + Gsuite AccessGroupsExcludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` + JSON accessGroupsExcludeAccessGsuiteGroupRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessGsuiteGroupRuleJSON contains the JSON metadata for the +// struct [AccessGroupsExcludeAccessGsuiteGroupRule] +type accessGroupsExcludeAccessGsuiteGroupRuleJSON struct { + Gsuite apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessGsuiteGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupsExclude() {} + +type AccessGroupsExcludeAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID string `json:"connection_id,required"` + // The email of the Google Workspace group. + Email string `json:"email,required"` + JSON accessGroupsExcludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` +} + +// accessGroupsExcludeAccessGsuiteGroupRuleGsuiteJSON contains the JSON metadata +// for the struct [AccessGroupsExcludeAccessGsuiteGroupRuleGsuite] +type accessGroupsExcludeAccessGsuiteGroupRuleGsuiteJSON struct { + ConnectionID apijson.Field + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { + return r.raw +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessGroupsExcludeAccessOktaGroupRule struct { + Okta AccessGroupsExcludeAccessOktaGroupRuleOkta `json:"okta,required"` + JSON accessGroupsExcludeAccessOktaGroupRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessOktaGroupRuleJSON contains the JSON metadata for the +// struct [AccessGroupsExcludeAccessOktaGroupRule] +type accessGroupsExcludeAccessOktaGroupRuleJSON struct { + Okta apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessOktaGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessOktaGroupRule) implementsZeroTrustAccessGroupsExclude() {} + +type AccessGroupsExcludeAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID string `json:"connection_id,required"` + // The email of the Okta group. + Email string `json:"email,required"` + JSON accessGroupsExcludeAccessOktaGroupRuleOktaJSON `json:"-"` +} + +// accessGroupsExcludeAccessOktaGroupRuleOktaJSON contains the JSON metadata for +// the struct [AccessGroupsExcludeAccessOktaGroupRuleOkta] +type accessGroupsExcludeAccessOktaGroupRuleOktaJSON struct { + ConnectionID apijson.Field + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessOktaGroupRuleOktaJSON) RawJSON() string { + return r.raw +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessGroupsExcludeAccessSamlGroupRule struct { + Saml AccessGroupsExcludeAccessSamlGroupRuleSaml `json:"saml,required"` + JSON accessGroupsExcludeAccessSamlGroupRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessSamlGroupRuleJSON contains the JSON metadata for the +// struct [AccessGroupsExcludeAccessSamlGroupRule] +type accessGroupsExcludeAccessSamlGroupRuleJSON struct { + Saml apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessSamlGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessSamlGroupRule) implementsZeroTrustAccessGroupsExclude() {} + +type AccessGroupsExcludeAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName string `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue string `json:"attribute_value,required"` + JSON accessGroupsExcludeAccessSamlGroupRuleSamlJSON `json:"-"` +} + +// accessGroupsExcludeAccessSamlGroupRuleSamlJSON contains the JSON metadata for +// the struct [AccessGroupsExcludeAccessSamlGroupRuleSaml] +type accessGroupsExcludeAccessSamlGroupRuleSamlJSON struct { + AttributeName apijson.Field + AttributeValue apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessSamlGroupRuleSamlJSON) RawJSON() string { + return r.raw +} + +// Matches a specific Access Service Token +type AccessGroupsExcludeAccessServiceTokenRule struct { + ServiceToken AccessGroupsExcludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` + JSON accessGroupsExcludeAccessServiceTokenRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessServiceTokenRuleJSON contains the JSON metadata for the +// struct [AccessGroupsExcludeAccessServiceTokenRule] +type accessGroupsExcludeAccessServiceTokenRuleJSON struct { + ServiceToken apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessServiceTokenRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessServiceTokenRule) implementsZeroTrustAccessGroupsExclude() {} + +type AccessGroupsExcludeAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID string `json:"token_id,required"` + JSON accessGroupsExcludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` +} + +// accessGroupsExcludeAccessServiceTokenRuleServiceTokenJSON contains the JSON +// metadata for the struct [AccessGroupsExcludeAccessServiceTokenRuleServiceToken] +type accessGroupsExcludeAccessServiceTokenRuleServiceTokenJSON struct { + TokenID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { + return r.raw +} + +// Matches any valid Access Service Token +type AccessGroupsExcludeAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` + JSON accessGroupsExcludeAccessAnyValidServiceTokenRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessAnyValidServiceTokenRuleJSON contains the JSON metadata +// for the struct [AccessGroupsExcludeAccessAnyValidServiceTokenRule] +type accessGroupsExcludeAccessAnyValidServiceTokenRuleJSON struct { + AnyValidServiceToken apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupsExclude() {} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessGroupsExcludeAccessExternalEvaluationRule struct { + ExternalEvaluation AccessGroupsExcludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` + JSON accessGroupsExcludeAccessExternalEvaluationRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessExternalEvaluationRuleJSON contains the JSON metadata +// for the struct [AccessGroupsExcludeAccessExternalEvaluationRule] +type accessGroupsExcludeAccessExternalEvaluationRuleJSON struct { + ExternalEvaluation apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessExternalEvaluationRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupsExclude() {} + +type AccessGroupsExcludeAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL string `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL string `json:"keys_url,required"` + JSON accessGroupsExcludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` +} + +// accessGroupsExcludeAccessExternalEvaluationRuleExternalEvaluationJSON contains +// the JSON metadata for the struct +// [AccessGroupsExcludeAccessExternalEvaluationRuleExternalEvaluation] +type accessGroupsExcludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { + EvaluateURL apijson.Field + KeysURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { + return r.raw +} + +// Matches a specific country +type AccessGroupsExcludeAccessCountryRule struct { + Geo AccessGroupsExcludeAccessCountryRuleGeo `json:"geo,required"` + JSON accessGroupsExcludeAccessCountryRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessCountryRuleJSON contains the JSON metadata for the +// struct [AccessGroupsExcludeAccessCountryRule] +type accessGroupsExcludeAccessCountryRuleJSON struct { + Geo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessCountryRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessCountryRule) implementsZeroTrustAccessGroupsExclude() {} + +type AccessGroupsExcludeAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode string `json:"country_code,required"` + JSON accessGroupsExcludeAccessCountryRuleGeoJSON `json:"-"` +} + +// accessGroupsExcludeAccessCountryRuleGeoJSON contains the JSON metadata for the +// struct [AccessGroupsExcludeAccessCountryRuleGeo] +type accessGroupsExcludeAccessCountryRuleGeoJSON struct { + CountryCode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessCountryRuleGeoJSON) RawJSON() string { + return r.raw +} + +// Enforce different MFA options +type AccessGroupsExcludeAccessAuthenticationMethodRule struct { + AuthMethod AccessGroupsExcludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` + JSON accessGroupsExcludeAccessAuthenticationMethodRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessAuthenticationMethodRuleJSON contains the JSON metadata +// for the struct [AccessGroupsExcludeAccessAuthenticationMethodRule] +type accessGroupsExcludeAccessAuthenticationMethodRuleJSON struct { + AuthMethod apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessAuthenticationMethodRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupsExclude() {} + +type AccessGroupsExcludeAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod string `json:"auth_method,required"` + JSON accessGroupsExcludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` +} + +// accessGroupsExcludeAccessAuthenticationMethodRuleAuthMethodJSON contains the +// JSON metadata for the struct +// [AccessGroupsExcludeAccessAuthenticationMethodRuleAuthMethod] +type accessGroupsExcludeAccessAuthenticationMethodRuleAuthMethodJSON struct { + AuthMethod apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { + return r.raw +} + +// Enforces a device posture rule has run successfully +type AccessGroupsExcludeAccessDevicePostureRule struct { + DevicePosture AccessGroupsExcludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` + JSON accessGroupsExcludeAccessDevicePostureRuleJSON `json:"-"` +} + +// accessGroupsExcludeAccessDevicePostureRuleJSON contains the JSON metadata for +// the struct [AccessGroupsExcludeAccessDevicePostureRule] +type accessGroupsExcludeAccessDevicePostureRuleJSON struct { + DevicePosture apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessDevicePostureRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsExcludeAccessDevicePostureRule) implementsZeroTrustAccessGroupsExclude() {} + +type AccessGroupsExcludeAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid string `json:"integration_uid,required"` + JSON accessGroupsExcludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` +} + +// accessGroupsExcludeAccessDevicePostureRuleDevicePostureJSON contains the JSON +// metadata for the struct +// [AccessGroupsExcludeAccessDevicePostureRuleDevicePosture] +type accessGroupsExcludeAccessDevicePostureRuleDevicePostureJSON struct { + IntegrationUid apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsExcludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsExcludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { + return r.raw +} + +// Matches a specific email. +// +// Union satisfied by [zero_trust.AccessGroupsIncludeAccessEmailRule], +// [zero_trust.AccessGroupsIncludeAccessEmailListRule], +// [zero_trust.AccessGroupsIncludeAccessDomainRule], +// [zero_trust.AccessGroupsIncludeAccessEveryoneRule], +// [zero_trust.AccessGroupsIncludeAccessIPRule], +// [zero_trust.AccessGroupsIncludeAccessIPListRule], +// [zero_trust.AccessGroupsIncludeAccessCertificateRule], +// [zero_trust.AccessGroupsIncludeAccessAccessGroupRule], +// [zero_trust.AccessGroupsIncludeAccessAzureGroupRule], +// [zero_trust.AccessGroupsIncludeAccessGitHubOrganizationRule], +// [zero_trust.AccessGroupsIncludeAccessGsuiteGroupRule], +// [zero_trust.AccessGroupsIncludeAccessOktaGroupRule], +// [zero_trust.AccessGroupsIncludeAccessSamlGroupRule], +// [zero_trust.AccessGroupsIncludeAccessServiceTokenRule], +// [zero_trust.AccessGroupsIncludeAccessAnyValidServiceTokenRule], +// [zero_trust.AccessGroupsIncludeAccessExternalEvaluationRule], +// [zero_trust.AccessGroupsIncludeAccessCountryRule], +// [zero_trust.AccessGroupsIncludeAccessAuthenticationMethodRule] or +// [zero_trust.AccessGroupsIncludeAccessDevicePostureRule]. +type AccessGroupsInclude interface { + implementsZeroTrustAccessGroupsInclude() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessGroupsInclude)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessEmailRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessEmailListRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessDomainRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessEveryoneRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessIPRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessIPListRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessCertificateRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessAccessGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessAzureGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessGitHubOrganizationRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessGsuiteGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessOktaGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessSamlGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessServiceTokenRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessAnyValidServiceTokenRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessExternalEvaluationRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessCountryRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessAuthenticationMethodRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIncludeAccessDevicePostureRule{}), + }, + ) +} + +// Matches a specific email. +type AccessGroupsIncludeAccessEmailRule struct { + Email AccessGroupsIncludeAccessEmailRuleEmail `json:"email,required"` + JSON accessGroupsIncludeAccessEmailRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessEmailRuleJSON contains the JSON metadata for the struct +// [AccessGroupsIncludeAccessEmailRule] +type accessGroupsIncludeAccessEmailRuleJSON struct { + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessEmailRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessEmailRule) implementsZeroTrustAccessGroupsInclude() {} + +type AccessGroupsIncludeAccessEmailRuleEmail struct { + // The email of the user. + Email string `json:"email,required" format:"email"` + JSON accessGroupsIncludeAccessEmailRuleEmailJSON `json:"-"` +} + +// accessGroupsIncludeAccessEmailRuleEmailJSON contains the JSON metadata for the +// struct [AccessGroupsIncludeAccessEmailRuleEmail] +type accessGroupsIncludeAccessEmailRuleEmailJSON struct { + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessEmailRuleEmailJSON) RawJSON() string { + return r.raw +} + +// Matches an email address from a list. +type AccessGroupsIncludeAccessEmailListRule struct { + EmailList AccessGroupsIncludeAccessEmailListRuleEmailList `json:"email_list,required"` + JSON accessGroupsIncludeAccessEmailListRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessEmailListRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIncludeAccessEmailListRule] +type accessGroupsIncludeAccessEmailListRuleJSON struct { + EmailList apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessEmailListRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessEmailListRule) implementsZeroTrustAccessGroupsInclude() {} + +type AccessGroupsIncludeAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID string `json:"id,required"` + JSON accessGroupsIncludeAccessEmailListRuleEmailListJSON `json:"-"` +} + +// accessGroupsIncludeAccessEmailListRuleEmailListJSON contains the JSON metadata +// for the struct [AccessGroupsIncludeAccessEmailListRuleEmailList] +type accessGroupsIncludeAccessEmailListRuleEmailListJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessEmailListRuleEmailListJSON) RawJSON() string { + return r.raw +} + +// Match an entire email domain. +type AccessGroupsIncludeAccessDomainRule struct { + EmailDomain AccessGroupsIncludeAccessDomainRuleEmailDomain `json:"email_domain,required"` + JSON accessGroupsIncludeAccessDomainRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessDomainRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIncludeAccessDomainRule] +type accessGroupsIncludeAccessDomainRuleJSON struct { + EmailDomain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessDomainRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessDomainRule) implementsZeroTrustAccessGroupsInclude() {} + +type AccessGroupsIncludeAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain string `json:"domain,required"` + JSON accessGroupsIncludeAccessDomainRuleEmailDomainJSON `json:"-"` +} + +// accessGroupsIncludeAccessDomainRuleEmailDomainJSON contains the JSON metadata +// for the struct [AccessGroupsIncludeAccessDomainRuleEmailDomain] +type accessGroupsIncludeAccessDomainRuleEmailDomainJSON struct { + Domain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessDomainRuleEmailDomainJSON) RawJSON() string { + return r.raw +} + +// Matches everyone. +type AccessGroupsIncludeAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone interface{} `json:"everyone,required"` + JSON accessGroupsIncludeAccessEveryoneRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessEveryoneRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIncludeAccessEveryoneRule] +type accessGroupsIncludeAccessEveryoneRuleJSON struct { + Everyone apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessEveryoneRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessEveryoneRule) implementsZeroTrustAccessGroupsInclude() {} + +// Matches an IP address block. +type AccessGroupsIncludeAccessIPRule struct { + IP AccessGroupsIncludeAccessIPRuleIP `json:"ip,required"` + JSON accessGroupsIncludeAccessIPRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessIPRuleJSON contains the JSON metadata for the struct +// [AccessGroupsIncludeAccessIPRule] +type accessGroupsIncludeAccessIPRuleJSON struct { + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessIPRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessIPRule) implementsZeroTrustAccessGroupsInclude() {} + +type AccessGroupsIncludeAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP string `json:"ip,required"` + JSON accessGroupsIncludeAccessIPRuleIPJSON `json:"-"` +} + +// accessGroupsIncludeAccessIPRuleIPJSON contains the JSON metadata for the struct +// [AccessGroupsIncludeAccessIPRuleIP] +type accessGroupsIncludeAccessIPRuleIPJSON struct { + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessIPRuleIPJSON) RawJSON() string { + return r.raw +} + +// Matches an IP address from a list. +type AccessGroupsIncludeAccessIPListRule struct { + IPList AccessGroupsIncludeAccessIPListRuleIPList `json:"ip_list,required"` + JSON accessGroupsIncludeAccessIPListRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessIPListRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIncludeAccessIPListRule] +type accessGroupsIncludeAccessIPListRuleJSON struct { + IPList apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessIPListRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessIPListRule) implementsZeroTrustAccessGroupsInclude() {} + +type AccessGroupsIncludeAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID string `json:"id,required"` + JSON accessGroupsIncludeAccessIPListRuleIPListJSON `json:"-"` +} + +// accessGroupsIncludeAccessIPListRuleIPListJSON contains the JSON metadata for the +// struct [AccessGroupsIncludeAccessIPListRuleIPList] +type accessGroupsIncludeAccessIPListRuleIPListJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessIPListRuleIPListJSON) RawJSON() string { + return r.raw +} + +// Matches any valid client certificate. +type AccessGroupsIncludeAccessCertificateRule struct { + Certificate interface{} `json:"certificate,required"` + JSON accessGroupsIncludeAccessCertificateRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessCertificateRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIncludeAccessCertificateRule] +type accessGroupsIncludeAccessCertificateRuleJSON struct { + Certificate apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessCertificateRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessCertificateRule) implementsZeroTrustAccessGroupsInclude() {} + +// Matches an Access group. +type AccessGroupsIncludeAccessAccessGroupRule struct { + Group AccessGroupsIncludeAccessAccessGroupRuleGroup `json:"group,required"` + JSON accessGroupsIncludeAccessAccessGroupRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessAccessGroupRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIncludeAccessAccessGroupRule] +type accessGroupsIncludeAccessAccessGroupRuleJSON struct { + Group apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessAccessGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessAccessGroupRule) implementsZeroTrustAccessGroupsInclude() {} + +type AccessGroupsIncludeAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID string `json:"id,required"` + JSON accessGroupsIncludeAccessAccessGroupRuleGroupJSON `json:"-"` +} + +// accessGroupsIncludeAccessAccessGroupRuleGroupJSON contains the JSON metadata for +// the struct [AccessGroupsIncludeAccessAccessGroupRuleGroup] +type accessGroupsIncludeAccessAccessGroupRuleGroupJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessAccessGroupRuleGroupJSON) RawJSON() string { + return r.raw +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessGroupsIncludeAccessAzureGroupRule struct { + AzureAd AccessGroupsIncludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` + JSON accessGroupsIncludeAccessAzureGroupRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessAzureGroupRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIncludeAccessAzureGroupRule] +type accessGroupsIncludeAccessAzureGroupRuleJSON struct { + AzureAd apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessAzureGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessAzureGroupRule) implementsZeroTrustAccessGroupsInclude() {} + +type AccessGroupsIncludeAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID string `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID string `json:"connection_id,required"` + JSON accessGroupsIncludeAccessAzureGroupRuleAzureAdJSON `json:"-"` +} + +// accessGroupsIncludeAccessAzureGroupRuleAzureAdJSON contains the JSON metadata +// for the struct [AccessGroupsIncludeAccessAzureGroupRuleAzureAd] +type accessGroupsIncludeAccessAzureGroupRuleAzureAdJSON struct { + ID apijson.Field + ConnectionID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { + return r.raw +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessGroupsIncludeAccessGitHubOrganizationRule struct { + GitHubOrganization AccessGroupsIncludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` + JSON accessGroupsIncludeAccessGitHubOrganizationRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessGitHubOrganizationRuleJSON contains the JSON metadata +// for the struct [AccessGroupsIncludeAccessGitHubOrganizationRule] +type accessGroupsIncludeAccessGitHubOrganizationRuleJSON struct { + GitHubOrganization apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessGitHubOrganizationRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupsInclude() {} + +type AccessGroupsIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID string `json:"connection_id,required"` + // The name of the organization. + Name string `json:"name,required"` + JSON accessGroupsIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` +} + +// accessGroupsIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON contains +// the JSON metadata for the struct +// [AccessGroupsIncludeAccessGitHubOrganizationRuleGitHubOrganization] +type accessGroupsIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { + ConnectionID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { + return r.raw +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessGroupsIncludeAccessGsuiteGroupRule struct { + Gsuite AccessGroupsIncludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` + JSON accessGroupsIncludeAccessGsuiteGroupRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessGsuiteGroupRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIncludeAccessGsuiteGroupRule] +type accessGroupsIncludeAccessGsuiteGroupRuleJSON struct { + Gsuite apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessGsuiteGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupsInclude() {} + +type AccessGroupsIncludeAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID string `json:"connection_id,required"` + // The email of the Google Workspace group. + Email string `json:"email,required"` + JSON accessGroupsIncludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` +} + +// accessGroupsIncludeAccessGsuiteGroupRuleGsuiteJSON contains the JSON metadata +// for the struct [AccessGroupsIncludeAccessGsuiteGroupRuleGsuite] +type accessGroupsIncludeAccessGsuiteGroupRuleGsuiteJSON struct { + ConnectionID apijson.Field + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { + return r.raw +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessGroupsIncludeAccessOktaGroupRule struct { + Okta AccessGroupsIncludeAccessOktaGroupRuleOkta `json:"okta,required"` + JSON accessGroupsIncludeAccessOktaGroupRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessOktaGroupRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIncludeAccessOktaGroupRule] +type accessGroupsIncludeAccessOktaGroupRuleJSON struct { + Okta apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessOktaGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessOktaGroupRule) implementsZeroTrustAccessGroupsInclude() {} + +type AccessGroupsIncludeAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID string `json:"connection_id,required"` + // The email of the Okta group. + Email string `json:"email,required"` + JSON accessGroupsIncludeAccessOktaGroupRuleOktaJSON `json:"-"` +} + +// accessGroupsIncludeAccessOktaGroupRuleOktaJSON contains the JSON metadata for +// the struct [AccessGroupsIncludeAccessOktaGroupRuleOkta] +type accessGroupsIncludeAccessOktaGroupRuleOktaJSON struct { + ConnectionID apijson.Field + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessOktaGroupRuleOktaJSON) RawJSON() string { + return r.raw +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessGroupsIncludeAccessSamlGroupRule struct { + Saml AccessGroupsIncludeAccessSamlGroupRuleSaml `json:"saml,required"` + JSON accessGroupsIncludeAccessSamlGroupRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessSamlGroupRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIncludeAccessSamlGroupRule] +type accessGroupsIncludeAccessSamlGroupRuleJSON struct { + Saml apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessSamlGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessSamlGroupRule) implementsZeroTrustAccessGroupsInclude() {} + +type AccessGroupsIncludeAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName string `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue string `json:"attribute_value,required"` + JSON accessGroupsIncludeAccessSamlGroupRuleSamlJSON `json:"-"` +} + +// accessGroupsIncludeAccessSamlGroupRuleSamlJSON contains the JSON metadata for +// the struct [AccessGroupsIncludeAccessSamlGroupRuleSaml] +type accessGroupsIncludeAccessSamlGroupRuleSamlJSON struct { + AttributeName apijson.Field + AttributeValue apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessSamlGroupRuleSamlJSON) RawJSON() string { + return r.raw +} + +// Matches a specific Access Service Token +type AccessGroupsIncludeAccessServiceTokenRule struct { + ServiceToken AccessGroupsIncludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` + JSON accessGroupsIncludeAccessServiceTokenRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessServiceTokenRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIncludeAccessServiceTokenRule] +type accessGroupsIncludeAccessServiceTokenRuleJSON struct { + ServiceToken apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessServiceTokenRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessServiceTokenRule) implementsZeroTrustAccessGroupsInclude() {} + +type AccessGroupsIncludeAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID string `json:"token_id,required"` + JSON accessGroupsIncludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` +} + +// accessGroupsIncludeAccessServiceTokenRuleServiceTokenJSON contains the JSON +// metadata for the struct [AccessGroupsIncludeAccessServiceTokenRuleServiceToken] +type accessGroupsIncludeAccessServiceTokenRuleServiceTokenJSON struct { + TokenID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { + return r.raw +} + +// Matches any valid Access Service Token +type AccessGroupsIncludeAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` + JSON accessGroupsIncludeAccessAnyValidServiceTokenRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessAnyValidServiceTokenRuleJSON contains the JSON metadata +// for the struct [AccessGroupsIncludeAccessAnyValidServiceTokenRule] +type accessGroupsIncludeAccessAnyValidServiceTokenRuleJSON struct { + AnyValidServiceToken apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupsInclude() {} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessGroupsIncludeAccessExternalEvaluationRule struct { + ExternalEvaluation AccessGroupsIncludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` + JSON accessGroupsIncludeAccessExternalEvaluationRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessExternalEvaluationRuleJSON contains the JSON metadata +// for the struct [AccessGroupsIncludeAccessExternalEvaluationRule] +type accessGroupsIncludeAccessExternalEvaluationRuleJSON struct { + ExternalEvaluation apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessExternalEvaluationRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupsInclude() {} + +type AccessGroupsIncludeAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL string `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL string `json:"keys_url,required"` + JSON accessGroupsIncludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` +} + +// accessGroupsIncludeAccessExternalEvaluationRuleExternalEvaluationJSON contains +// the JSON metadata for the struct +// [AccessGroupsIncludeAccessExternalEvaluationRuleExternalEvaluation] +type accessGroupsIncludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { + EvaluateURL apijson.Field + KeysURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { + return r.raw +} + +// Matches a specific country +type AccessGroupsIncludeAccessCountryRule struct { + Geo AccessGroupsIncludeAccessCountryRuleGeo `json:"geo,required"` + JSON accessGroupsIncludeAccessCountryRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessCountryRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIncludeAccessCountryRule] +type accessGroupsIncludeAccessCountryRuleJSON struct { + Geo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessCountryRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessCountryRule) implementsZeroTrustAccessGroupsInclude() {} + +type AccessGroupsIncludeAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode string `json:"country_code,required"` + JSON accessGroupsIncludeAccessCountryRuleGeoJSON `json:"-"` +} + +// accessGroupsIncludeAccessCountryRuleGeoJSON contains the JSON metadata for the +// struct [AccessGroupsIncludeAccessCountryRuleGeo] +type accessGroupsIncludeAccessCountryRuleGeoJSON struct { + CountryCode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessCountryRuleGeoJSON) RawJSON() string { + return r.raw +} + +// Enforce different MFA options +type AccessGroupsIncludeAccessAuthenticationMethodRule struct { + AuthMethod AccessGroupsIncludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` + JSON accessGroupsIncludeAccessAuthenticationMethodRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessAuthenticationMethodRuleJSON contains the JSON metadata +// for the struct [AccessGroupsIncludeAccessAuthenticationMethodRule] +type accessGroupsIncludeAccessAuthenticationMethodRuleJSON struct { + AuthMethod apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessAuthenticationMethodRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupsInclude() {} + +type AccessGroupsIncludeAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod string `json:"auth_method,required"` + JSON accessGroupsIncludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` +} + +// accessGroupsIncludeAccessAuthenticationMethodRuleAuthMethodJSON contains the +// JSON metadata for the struct +// [AccessGroupsIncludeAccessAuthenticationMethodRuleAuthMethod] +type accessGroupsIncludeAccessAuthenticationMethodRuleAuthMethodJSON struct { + AuthMethod apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { + return r.raw +} + +// Enforces a device posture rule has run successfully +type AccessGroupsIncludeAccessDevicePostureRule struct { + DevicePosture AccessGroupsIncludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` + JSON accessGroupsIncludeAccessDevicePostureRuleJSON `json:"-"` +} + +// accessGroupsIncludeAccessDevicePostureRuleJSON contains the JSON metadata for +// the struct [AccessGroupsIncludeAccessDevicePostureRule] +type accessGroupsIncludeAccessDevicePostureRuleJSON struct { + DevicePosture apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessDevicePostureRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIncludeAccessDevicePostureRule) implementsZeroTrustAccessGroupsInclude() {} + +type AccessGroupsIncludeAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid string `json:"integration_uid,required"` + JSON accessGroupsIncludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` +} + +// accessGroupsIncludeAccessDevicePostureRuleDevicePostureJSON contains the JSON +// metadata for the struct +// [AccessGroupsIncludeAccessDevicePostureRuleDevicePosture] +type accessGroupsIncludeAccessDevicePostureRuleDevicePostureJSON struct { + IntegrationUid apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIncludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIncludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { + return r.raw +} + +// Matches a specific email. +// +// Union satisfied by [zero_trust.AccessGroupsIsDefaultAccessEmailRule], +// [zero_trust.AccessGroupsIsDefaultAccessEmailListRule], +// [zero_trust.AccessGroupsIsDefaultAccessDomainRule], +// [zero_trust.AccessGroupsIsDefaultAccessEveryoneRule], +// [zero_trust.AccessGroupsIsDefaultAccessIPRule], +// [zero_trust.AccessGroupsIsDefaultAccessIPListRule], +// [zero_trust.AccessGroupsIsDefaultAccessCertificateRule], +// [zero_trust.AccessGroupsIsDefaultAccessAccessGroupRule], +// [zero_trust.AccessGroupsIsDefaultAccessAzureGroupRule], +// [zero_trust.AccessGroupsIsDefaultAccessGitHubOrganizationRule], +// [zero_trust.AccessGroupsIsDefaultAccessGsuiteGroupRule], +// [zero_trust.AccessGroupsIsDefaultAccessOktaGroupRule], +// [zero_trust.AccessGroupsIsDefaultAccessSamlGroupRule], +// [zero_trust.AccessGroupsIsDefaultAccessServiceTokenRule], +// [zero_trust.AccessGroupsIsDefaultAccessAnyValidServiceTokenRule], +// [zero_trust.AccessGroupsIsDefaultAccessExternalEvaluationRule], +// [zero_trust.AccessGroupsIsDefaultAccessCountryRule], +// [zero_trust.AccessGroupsIsDefaultAccessAuthenticationMethodRule] or +// [zero_trust.AccessGroupsIsDefaultAccessDevicePostureRule]. +type AccessGroupsIsDefault interface { + implementsZeroTrustAccessGroupsIsDefault() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessGroupsIsDefault)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessEmailRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessEmailListRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessDomainRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessEveryoneRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessIPRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessIPListRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessCertificateRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessAccessGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessAzureGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessGitHubOrganizationRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessGsuiteGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessOktaGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessSamlGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessServiceTokenRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessAnyValidServiceTokenRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessExternalEvaluationRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessCountryRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessAuthenticationMethodRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsIsDefaultAccessDevicePostureRule{}), + }, + ) +} + +// Matches a specific email. +type AccessGroupsIsDefaultAccessEmailRule struct { + Email AccessGroupsIsDefaultAccessEmailRuleEmail `json:"email,required"` + JSON accessGroupsIsDefaultAccessEmailRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessEmailRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIsDefaultAccessEmailRule] +type accessGroupsIsDefaultAccessEmailRuleJSON struct { + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessEmailRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessEmailRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessEmailRule) implementsZeroTrustAccessGroupsIsDefault() {} + +type AccessGroupsIsDefaultAccessEmailRuleEmail struct { + // The email of the user. + Email string `json:"email,required" format:"email"` + JSON accessGroupsIsDefaultAccessEmailRuleEmailJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessEmailRuleEmailJSON contains the JSON metadata for the +// struct [AccessGroupsIsDefaultAccessEmailRuleEmail] +type accessGroupsIsDefaultAccessEmailRuleEmailJSON struct { + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessEmailRuleEmailJSON) RawJSON() string { + return r.raw +} + +// Matches an email address from a list. +type AccessGroupsIsDefaultAccessEmailListRule struct { + EmailList AccessGroupsIsDefaultAccessEmailListRuleEmailList `json:"email_list,required"` + JSON accessGroupsIsDefaultAccessEmailListRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessEmailListRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIsDefaultAccessEmailListRule] +type accessGroupsIsDefaultAccessEmailListRuleJSON struct { + EmailList apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessEmailListRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessEmailListRule) implementsZeroTrustAccessGroupsIsDefault() {} + +type AccessGroupsIsDefaultAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID string `json:"id,required"` + JSON accessGroupsIsDefaultAccessEmailListRuleEmailListJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessEmailListRuleEmailListJSON contains the JSON metadata +// for the struct [AccessGroupsIsDefaultAccessEmailListRuleEmailList] +type accessGroupsIsDefaultAccessEmailListRuleEmailListJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessEmailListRuleEmailListJSON) RawJSON() string { + return r.raw +} + +// Match an entire email domain. +type AccessGroupsIsDefaultAccessDomainRule struct { + EmailDomain AccessGroupsIsDefaultAccessDomainRuleEmailDomain `json:"email_domain,required"` + JSON accessGroupsIsDefaultAccessDomainRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessDomainRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIsDefaultAccessDomainRule] +type accessGroupsIsDefaultAccessDomainRuleJSON struct { + EmailDomain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessDomainRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessDomainRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessDomainRule) implementsZeroTrustAccessGroupsIsDefault() {} + +type AccessGroupsIsDefaultAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain string `json:"domain,required"` + JSON accessGroupsIsDefaultAccessDomainRuleEmailDomainJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessDomainRuleEmailDomainJSON contains the JSON metadata +// for the struct [AccessGroupsIsDefaultAccessDomainRuleEmailDomain] +type accessGroupsIsDefaultAccessDomainRuleEmailDomainJSON struct { + Domain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessDomainRuleEmailDomainJSON) RawJSON() string { + return r.raw +} + +// Matches everyone. +type AccessGroupsIsDefaultAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone interface{} `json:"everyone,required"` + JSON accessGroupsIsDefaultAccessEveryoneRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessEveryoneRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIsDefaultAccessEveryoneRule] +type accessGroupsIsDefaultAccessEveryoneRuleJSON struct { + Everyone apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessEveryoneRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessEveryoneRule) implementsZeroTrustAccessGroupsIsDefault() {} + +// Matches an IP address block. +type AccessGroupsIsDefaultAccessIPRule struct { + IP AccessGroupsIsDefaultAccessIPRuleIP `json:"ip,required"` + JSON accessGroupsIsDefaultAccessIPRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessIPRuleJSON contains the JSON metadata for the struct +// [AccessGroupsIsDefaultAccessIPRule] +type accessGroupsIsDefaultAccessIPRuleJSON struct { + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessIPRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessIPRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessIPRule) implementsZeroTrustAccessGroupsIsDefault() {} + +type AccessGroupsIsDefaultAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP string `json:"ip,required"` + JSON accessGroupsIsDefaultAccessIPRuleIPJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessIPRuleIPJSON contains the JSON metadata for the +// struct [AccessGroupsIsDefaultAccessIPRuleIP] +type accessGroupsIsDefaultAccessIPRuleIPJSON struct { + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessIPRuleIPJSON) RawJSON() string { + return r.raw +} + +// Matches an IP address from a list. +type AccessGroupsIsDefaultAccessIPListRule struct { + IPList AccessGroupsIsDefaultAccessIPListRuleIPList `json:"ip_list,required"` + JSON accessGroupsIsDefaultAccessIPListRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessIPListRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIsDefaultAccessIPListRule] +type accessGroupsIsDefaultAccessIPListRuleJSON struct { + IPList apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessIPListRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessIPListRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessIPListRule) implementsZeroTrustAccessGroupsIsDefault() {} + +type AccessGroupsIsDefaultAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID string `json:"id,required"` + JSON accessGroupsIsDefaultAccessIPListRuleIPListJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessIPListRuleIPListJSON contains the JSON metadata for +// the struct [AccessGroupsIsDefaultAccessIPListRuleIPList] +type accessGroupsIsDefaultAccessIPListRuleIPListJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessIPListRuleIPListJSON) RawJSON() string { + return r.raw +} + +// Matches any valid client certificate. +type AccessGroupsIsDefaultAccessCertificateRule struct { + Certificate interface{} `json:"certificate,required"` + JSON accessGroupsIsDefaultAccessCertificateRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessCertificateRuleJSON contains the JSON metadata for +// the struct [AccessGroupsIsDefaultAccessCertificateRule] +type accessGroupsIsDefaultAccessCertificateRuleJSON struct { + Certificate apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessCertificateRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessCertificateRule) implementsZeroTrustAccessGroupsIsDefault() {} + +// Matches an Access group. +type AccessGroupsIsDefaultAccessAccessGroupRule struct { + Group AccessGroupsIsDefaultAccessAccessGroupRuleGroup `json:"group,required"` + JSON accessGroupsIsDefaultAccessAccessGroupRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessAccessGroupRuleJSON contains the JSON metadata for +// the struct [AccessGroupsIsDefaultAccessAccessGroupRule] +type accessGroupsIsDefaultAccessAccessGroupRuleJSON struct { + Group apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessAccessGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessAccessGroupRule) implementsZeroTrustAccessGroupsIsDefault() {} + +type AccessGroupsIsDefaultAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID string `json:"id,required"` + JSON accessGroupsIsDefaultAccessAccessGroupRuleGroupJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessAccessGroupRuleGroupJSON contains the JSON metadata +// for the struct [AccessGroupsIsDefaultAccessAccessGroupRuleGroup] +type accessGroupsIsDefaultAccessAccessGroupRuleGroupJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessAccessGroupRuleGroupJSON) RawJSON() string { + return r.raw +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessGroupsIsDefaultAccessAzureGroupRule struct { + AzureAd AccessGroupsIsDefaultAccessAzureGroupRuleAzureAd `json:"azureAD,required"` + JSON accessGroupsIsDefaultAccessAzureGroupRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessAzureGroupRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIsDefaultAccessAzureGroupRule] +type accessGroupsIsDefaultAccessAzureGroupRuleJSON struct { + AzureAd apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessAzureGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessAzureGroupRule) implementsZeroTrustAccessGroupsIsDefault() {} + +type AccessGroupsIsDefaultAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID string `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID string `json:"connection_id,required"` + JSON accessGroupsIsDefaultAccessAzureGroupRuleAzureAdJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessAzureGroupRuleAzureAdJSON contains the JSON metadata +// for the struct [AccessGroupsIsDefaultAccessAzureGroupRuleAzureAd] +type accessGroupsIsDefaultAccessAzureGroupRuleAzureAdJSON struct { + ID apijson.Field + ConnectionID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessAzureGroupRuleAzureAdJSON) RawJSON() string { + return r.raw +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessGroupsIsDefaultAccessGitHubOrganizationRule struct { + GitHubOrganization AccessGroupsIsDefaultAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` + JSON accessGroupsIsDefaultAccessGitHubOrganizationRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessGitHubOrganizationRuleJSON contains the JSON metadata +// for the struct [AccessGroupsIsDefaultAccessGitHubOrganizationRule] +type accessGroupsIsDefaultAccessGitHubOrganizationRuleJSON struct { + GitHubOrganization apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessGitHubOrganizationRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupsIsDefault() { +} + +type AccessGroupsIsDefaultAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID string `json:"connection_id,required"` + // The name of the organization. + Name string `json:"name,required"` + JSON accessGroupsIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON contains +// the JSON metadata for the struct +// [AccessGroupsIsDefaultAccessGitHubOrganizationRuleGitHubOrganization] +type accessGroupsIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { + ConnectionID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { + return r.raw +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessGroupsIsDefaultAccessGsuiteGroupRule struct { + Gsuite AccessGroupsIsDefaultAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` + JSON accessGroupsIsDefaultAccessGsuiteGroupRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessGsuiteGroupRuleJSON contains the JSON metadata for +// the struct [AccessGroupsIsDefaultAccessGsuiteGroupRule] +type accessGroupsIsDefaultAccessGsuiteGroupRuleJSON struct { + Gsuite apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessGsuiteGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessGsuiteGroupRule) implementsZeroTrustAccessGroupsIsDefault() {} + +type AccessGroupsIsDefaultAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID string `json:"connection_id,required"` + // The email of the Google Workspace group. + Email string `json:"email,required"` + JSON accessGroupsIsDefaultAccessGsuiteGroupRuleGsuiteJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessGsuiteGroupRuleGsuiteJSON contains the JSON metadata +// for the struct [AccessGroupsIsDefaultAccessGsuiteGroupRuleGsuite] +type accessGroupsIsDefaultAccessGsuiteGroupRuleGsuiteJSON struct { + ConnectionID apijson.Field + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { + return r.raw +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessGroupsIsDefaultAccessOktaGroupRule struct { + Okta AccessGroupsIsDefaultAccessOktaGroupRuleOkta `json:"okta,required"` + JSON accessGroupsIsDefaultAccessOktaGroupRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessOktaGroupRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIsDefaultAccessOktaGroupRule] +type accessGroupsIsDefaultAccessOktaGroupRuleJSON struct { + Okta apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessOktaGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessOktaGroupRule) implementsZeroTrustAccessGroupsIsDefault() {} + +type AccessGroupsIsDefaultAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID string `json:"connection_id,required"` + // The email of the Okta group. + Email string `json:"email,required"` + JSON accessGroupsIsDefaultAccessOktaGroupRuleOktaJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessOktaGroupRuleOktaJSON contains the JSON metadata for +// the struct [AccessGroupsIsDefaultAccessOktaGroupRuleOkta] +type accessGroupsIsDefaultAccessOktaGroupRuleOktaJSON struct { + ConnectionID apijson.Field + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessOktaGroupRuleOktaJSON) RawJSON() string { + return r.raw +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessGroupsIsDefaultAccessSamlGroupRule struct { + Saml AccessGroupsIsDefaultAccessSamlGroupRuleSaml `json:"saml,required"` + JSON accessGroupsIsDefaultAccessSamlGroupRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessSamlGroupRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIsDefaultAccessSamlGroupRule] +type accessGroupsIsDefaultAccessSamlGroupRuleJSON struct { + Saml apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessSamlGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessSamlGroupRule) implementsZeroTrustAccessGroupsIsDefault() {} + +type AccessGroupsIsDefaultAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName string `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue string `json:"attribute_value,required"` + JSON accessGroupsIsDefaultAccessSamlGroupRuleSamlJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessSamlGroupRuleSamlJSON contains the JSON metadata for +// the struct [AccessGroupsIsDefaultAccessSamlGroupRuleSaml] +type accessGroupsIsDefaultAccessSamlGroupRuleSamlJSON struct { + AttributeName apijson.Field + AttributeValue apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessSamlGroupRuleSamlJSON) RawJSON() string { + return r.raw +} + +// Matches a specific Access Service Token +type AccessGroupsIsDefaultAccessServiceTokenRule struct { + ServiceToken AccessGroupsIsDefaultAccessServiceTokenRuleServiceToken `json:"service_token,required"` + JSON accessGroupsIsDefaultAccessServiceTokenRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessServiceTokenRuleJSON contains the JSON metadata for +// the struct [AccessGroupsIsDefaultAccessServiceTokenRule] +type accessGroupsIsDefaultAccessServiceTokenRuleJSON struct { + ServiceToken apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessServiceTokenRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessServiceTokenRule) implementsZeroTrustAccessGroupsIsDefault() {} + +type AccessGroupsIsDefaultAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID string `json:"token_id,required"` + JSON accessGroupsIsDefaultAccessServiceTokenRuleServiceTokenJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessServiceTokenRuleServiceTokenJSON contains the JSON +// metadata for the struct +// [AccessGroupsIsDefaultAccessServiceTokenRuleServiceToken] +type accessGroupsIsDefaultAccessServiceTokenRuleServiceTokenJSON struct { + TokenID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { + return r.raw +} + +// Matches any valid Access Service Token +type AccessGroupsIsDefaultAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` + JSON accessGroupsIsDefaultAccessAnyValidServiceTokenRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessAnyValidServiceTokenRuleJSON contains the JSON +// metadata for the struct [AccessGroupsIsDefaultAccessAnyValidServiceTokenRule] +type accessGroupsIsDefaultAccessAnyValidServiceTokenRuleJSON struct { + AnyValidServiceToken apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessAnyValidServiceTokenRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupsIsDefault() { +} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessGroupsIsDefaultAccessExternalEvaluationRule struct { + ExternalEvaluation AccessGroupsIsDefaultAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` + JSON accessGroupsIsDefaultAccessExternalEvaluationRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessExternalEvaluationRuleJSON contains the JSON metadata +// for the struct [AccessGroupsIsDefaultAccessExternalEvaluationRule] +type accessGroupsIsDefaultAccessExternalEvaluationRuleJSON struct { + ExternalEvaluation apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessExternalEvaluationRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessExternalEvaluationRule) implementsZeroTrustAccessGroupsIsDefault() { +} + +type AccessGroupsIsDefaultAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL string `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL string `json:"keys_url,required"` + JSON accessGroupsIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON contains +// the JSON metadata for the struct +// [AccessGroupsIsDefaultAccessExternalEvaluationRuleExternalEvaluation] +type accessGroupsIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON struct { + EvaluateURL apijson.Field + KeysURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { + return r.raw +} + +// Matches a specific country +type AccessGroupsIsDefaultAccessCountryRule struct { + Geo AccessGroupsIsDefaultAccessCountryRuleGeo `json:"geo,required"` + JSON accessGroupsIsDefaultAccessCountryRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessCountryRuleJSON contains the JSON metadata for the +// struct [AccessGroupsIsDefaultAccessCountryRule] +type accessGroupsIsDefaultAccessCountryRuleJSON struct { + Geo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessCountryRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessCountryRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessCountryRule) implementsZeroTrustAccessGroupsIsDefault() {} + +type AccessGroupsIsDefaultAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode string `json:"country_code,required"` + JSON accessGroupsIsDefaultAccessCountryRuleGeoJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessCountryRuleGeoJSON contains the JSON metadata for the +// struct [AccessGroupsIsDefaultAccessCountryRuleGeo] +type accessGroupsIsDefaultAccessCountryRuleGeoJSON struct { + CountryCode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessCountryRuleGeoJSON) RawJSON() string { + return r.raw +} + +// Enforce different MFA options +type AccessGroupsIsDefaultAccessAuthenticationMethodRule struct { + AuthMethod AccessGroupsIsDefaultAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` + JSON accessGroupsIsDefaultAccessAuthenticationMethodRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessAuthenticationMethodRuleJSON contains the JSON +// metadata for the struct [AccessGroupsIsDefaultAccessAuthenticationMethodRule] +type accessGroupsIsDefaultAccessAuthenticationMethodRuleJSON struct { + AuthMethod apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessAuthenticationMethodRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupsIsDefault() { +} + +type AccessGroupsIsDefaultAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod string `json:"auth_method,required"` + JSON accessGroupsIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON contains the +// JSON metadata for the struct +// [AccessGroupsIsDefaultAccessAuthenticationMethodRuleAuthMethod] +type accessGroupsIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON struct { + AuthMethod apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { + return r.raw +} + +// Enforces a device posture rule has run successfully +type AccessGroupsIsDefaultAccessDevicePostureRule struct { + DevicePosture AccessGroupsIsDefaultAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` + JSON accessGroupsIsDefaultAccessDevicePostureRuleJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessDevicePostureRuleJSON contains the JSON metadata for +// the struct [AccessGroupsIsDefaultAccessDevicePostureRule] +type accessGroupsIsDefaultAccessDevicePostureRuleJSON struct { + DevicePosture apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessDevicePostureRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsIsDefaultAccessDevicePostureRule) implementsZeroTrustAccessGroupsIsDefault() {} + +type AccessGroupsIsDefaultAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid string `json:"integration_uid,required"` + JSON accessGroupsIsDefaultAccessDevicePostureRuleDevicePostureJSON `json:"-"` +} + +// accessGroupsIsDefaultAccessDevicePostureRuleDevicePostureJSON contains the JSON +// metadata for the struct +// [AccessGroupsIsDefaultAccessDevicePostureRuleDevicePosture] +type accessGroupsIsDefaultAccessDevicePostureRuleDevicePostureJSON struct { + IntegrationUid apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsIsDefaultAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsIsDefaultAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { + return r.raw +} + +// Matches a specific email. +// +// Union satisfied by [zero_trust.AccessGroupsRequireAccessEmailRule], +// [zero_trust.AccessGroupsRequireAccessEmailListRule], +// [zero_trust.AccessGroupsRequireAccessDomainRule], +// [zero_trust.AccessGroupsRequireAccessEveryoneRule], +// [zero_trust.AccessGroupsRequireAccessIPRule], +// [zero_trust.AccessGroupsRequireAccessIPListRule], +// [zero_trust.AccessGroupsRequireAccessCertificateRule], +// [zero_trust.AccessGroupsRequireAccessAccessGroupRule], +// [zero_trust.AccessGroupsRequireAccessAzureGroupRule], +// [zero_trust.AccessGroupsRequireAccessGitHubOrganizationRule], +// [zero_trust.AccessGroupsRequireAccessGsuiteGroupRule], +// [zero_trust.AccessGroupsRequireAccessOktaGroupRule], +// [zero_trust.AccessGroupsRequireAccessSamlGroupRule], +// [zero_trust.AccessGroupsRequireAccessServiceTokenRule], +// [zero_trust.AccessGroupsRequireAccessAnyValidServiceTokenRule], +// [zero_trust.AccessGroupsRequireAccessExternalEvaluationRule], +// [zero_trust.AccessGroupsRequireAccessCountryRule], +// [zero_trust.AccessGroupsRequireAccessAuthenticationMethodRule] or +// [zero_trust.AccessGroupsRequireAccessDevicePostureRule]. +type AccessGroupsRequire interface { + implementsZeroTrustAccessGroupsRequire() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessGroupsRequire)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessEmailRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessEmailListRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessDomainRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessEveryoneRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessIPRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessIPListRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessCertificateRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessAccessGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessAzureGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessGitHubOrganizationRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessGsuiteGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessOktaGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessSamlGroupRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessServiceTokenRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessAnyValidServiceTokenRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessExternalEvaluationRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessCountryRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessAuthenticationMethodRule{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessGroupsRequireAccessDevicePostureRule{}), + }, + ) +} + +// Matches a specific email. +type AccessGroupsRequireAccessEmailRule struct { + Email AccessGroupsRequireAccessEmailRuleEmail `json:"email,required"` + JSON accessGroupsRequireAccessEmailRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessEmailRuleJSON contains the JSON metadata for the struct +// [AccessGroupsRequireAccessEmailRule] +type accessGroupsRequireAccessEmailRuleJSON struct { + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessEmailRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessEmailRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessEmailRule) implementsZeroTrustAccessGroupsRequire() {} + +type AccessGroupsRequireAccessEmailRuleEmail struct { + // The email of the user. + Email string `json:"email,required" format:"email"` + JSON accessGroupsRequireAccessEmailRuleEmailJSON `json:"-"` +} + +// accessGroupsRequireAccessEmailRuleEmailJSON contains the JSON metadata for the +// struct [AccessGroupsRequireAccessEmailRuleEmail] +type accessGroupsRequireAccessEmailRuleEmailJSON struct { + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessEmailRuleEmailJSON) RawJSON() string { + return r.raw +} + +// Matches an email address from a list. +type AccessGroupsRequireAccessEmailListRule struct { + EmailList AccessGroupsRequireAccessEmailListRuleEmailList `json:"email_list,required"` + JSON accessGroupsRequireAccessEmailListRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessEmailListRuleJSON contains the JSON metadata for the +// struct [AccessGroupsRequireAccessEmailListRule] +type accessGroupsRequireAccessEmailListRuleJSON struct { + EmailList apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessEmailListRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessEmailListRule) implementsZeroTrustAccessGroupsRequire() {} + +type AccessGroupsRequireAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID string `json:"id,required"` + JSON accessGroupsRequireAccessEmailListRuleEmailListJSON `json:"-"` +} + +// accessGroupsRequireAccessEmailListRuleEmailListJSON contains the JSON metadata +// for the struct [AccessGroupsRequireAccessEmailListRuleEmailList] +type accessGroupsRequireAccessEmailListRuleEmailListJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessEmailListRuleEmailListJSON) RawJSON() string { + return r.raw +} + +// Match an entire email domain. +type AccessGroupsRequireAccessDomainRule struct { + EmailDomain AccessGroupsRequireAccessDomainRuleEmailDomain `json:"email_domain,required"` + JSON accessGroupsRequireAccessDomainRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessDomainRuleJSON contains the JSON metadata for the +// struct [AccessGroupsRequireAccessDomainRule] +type accessGroupsRequireAccessDomainRuleJSON struct { + EmailDomain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessDomainRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessDomainRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessDomainRule) implementsZeroTrustAccessGroupsRequire() {} + +type AccessGroupsRequireAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain string `json:"domain,required"` + JSON accessGroupsRequireAccessDomainRuleEmailDomainJSON `json:"-"` +} + +// accessGroupsRequireAccessDomainRuleEmailDomainJSON contains the JSON metadata +// for the struct [AccessGroupsRequireAccessDomainRuleEmailDomain] +type accessGroupsRequireAccessDomainRuleEmailDomainJSON struct { + Domain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessDomainRuleEmailDomainJSON) RawJSON() string { + return r.raw +} + +// Matches everyone. +type AccessGroupsRequireAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone interface{} `json:"everyone,required"` + JSON accessGroupsRequireAccessEveryoneRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessEveryoneRuleJSON contains the JSON metadata for the +// struct [AccessGroupsRequireAccessEveryoneRule] +type accessGroupsRequireAccessEveryoneRuleJSON struct { + Everyone apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessEveryoneRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessEveryoneRule) implementsZeroTrustAccessGroupsRequire() {} + +// Matches an IP address block. +type AccessGroupsRequireAccessIPRule struct { + IP AccessGroupsRequireAccessIPRuleIP `json:"ip,required"` + JSON accessGroupsRequireAccessIPRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessIPRuleJSON contains the JSON metadata for the struct +// [AccessGroupsRequireAccessIPRule] +type accessGroupsRequireAccessIPRuleJSON struct { + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessIPRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessIPRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessIPRule) implementsZeroTrustAccessGroupsRequire() {} + +type AccessGroupsRequireAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP string `json:"ip,required"` + JSON accessGroupsRequireAccessIPRuleIPJSON `json:"-"` +} + +// accessGroupsRequireAccessIPRuleIPJSON contains the JSON metadata for the struct +// [AccessGroupsRequireAccessIPRuleIP] +type accessGroupsRequireAccessIPRuleIPJSON struct { + IP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessIPRuleIPJSON) RawJSON() string { + return r.raw +} + +// Matches an IP address from a list. +type AccessGroupsRequireAccessIPListRule struct { + IPList AccessGroupsRequireAccessIPListRuleIPList `json:"ip_list,required"` + JSON accessGroupsRequireAccessIPListRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessIPListRuleJSON contains the JSON metadata for the +// struct [AccessGroupsRequireAccessIPListRule] +type accessGroupsRequireAccessIPListRuleJSON struct { + IPList apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessIPListRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessIPListRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessIPListRule) implementsZeroTrustAccessGroupsRequire() {} + +type AccessGroupsRequireAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID string `json:"id,required"` + JSON accessGroupsRequireAccessIPListRuleIPListJSON `json:"-"` +} + +// accessGroupsRequireAccessIPListRuleIPListJSON contains the JSON metadata for the +// struct [AccessGroupsRequireAccessIPListRuleIPList] +type accessGroupsRequireAccessIPListRuleIPListJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessIPListRuleIPListJSON) RawJSON() string { + return r.raw +} + +// Matches any valid client certificate. +type AccessGroupsRequireAccessCertificateRule struct { + Certificate interface{} `json:"certificate,required"` + JSON accessGroupsRequireAccessCertificateRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessCertificateRuleJSON contains the JSON metadata for the +// struct [AccessGroupsRequireAccessCertificateRule] +type accessGroupsRequireAccessCertificateRuleJSON struct { + Certificate apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessCertificateRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessCertificateRule) implementsZeroTrustAccessGroupsRequire() {} + +// Matches an Access group. +type AccessGroupsRequireAccessAccessGroupRule struct { + Group AccessGroupsRequireAccessAccessGroupRuleGroup `json:"group,required"` + JSON accessGroupsRequireAccessAccessGroupRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessAccessGroupRuleJSON contains the JSON metadata for the +// struct [AccessGroupsRequireAccessAccessGroupRule] +type accessGroupsRequireAccessAccessGroupRuleJSON struct { + Group apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessAccessGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessAccessGroupRule) implementsZeroTrustAccessGroupsRequire() {} + +type AccessGroupsRequireAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID string `json:"id,required"` + JSON accessGroupsRequireAccessAccessGroupRuleGroupJSON `json:"-"` +} + +// accessGroupsRequireAccessAccessGroupRuleGroupJSON contains the JSON metadata for +// the struct [AccessGroupsRequireAccessAccessGroupRuleGroup] +type accessGroupsRequireAccessAccessGroupRuleGroupJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessAccessGroupRuleGroupJSON) RawJSON() string { + return r.raw +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessGroupsRequireAccessAzureGroupRule struct { + AzureAd AccessGroupsRequireAccessAzureGroupRuleAzureAd `json:"azureAD,required"` + JSON accessGroupsRequireAccessAzureGroupRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessAzureGroupRuleJSON contains the JSON metadata for the +// struct [AccessGroupsRequireAccessAzureGroupRule] +type accessGroupsRequireAccessAzureGroupRuleJSON struct { + AzureAd apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessAzureGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessAzureGroupRule) implementsZeroTrustAccessGroupsRequire() {} + +type AccessGroupsRequireAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID string `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID string `json:"connection_id,required"` + JSON accessGroupsRequireAccessAzureGroupRuleAzureAdJSON `json:"-"` +} + +// accessGroupsRequireAccessAzureGroupRuleAzureAdJSON contains the JSON metadata +// for the struct [AccessGroupsRequireAccessAzureGroupRuleAzureAd] +type accessGroupsRequireAccessAzureGroupRuleAzureAdJSON struct { + ID apijson.Field + ConnectionID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessAzureGroupRuleAzureAdJSON) RawJSON() string { + return r.raw +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessGroupsRequireAccessGitHubOrganizationRule struct { + GitHubOrganization AccessGroupsRequireAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` + JSON accessGroupsRequireAccessGitHubOrganizationRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessGitHubOrganizationRuleJSON contains the JSON metadata +// for the struct [AccessGroupsRequireAccessGitHubOrganizationRule] +type accessGroupsRequireAccessGitHubOrganizationRuleJSON struct { + GitHubOrganization apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessGitHubOrganizationRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupsRequire() {} + +type AccessGroupsRequireAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID string `json:"connection_id,required"` + // The name of the organization. + Name string `json:"name,required"` + JSON accessGroupsRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` +} + +// accessGroupsRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON contains +// the JSON metadata for the struct +// [AccessGroupsRequireAccessGitHubOrganizationRuleGitHubOrganization] +type accessGroupsRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { + ConnectionID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { + return r.raw +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessGroupsRequireAccessGsuiteGroupRule struct { + Gsuite AccessGroupsRequireAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` + JSON accessGroupsRequireAccessGsuiteGroupRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessGsuiteGroupRuleJSON contains the JSON metadata for the +// struct [AccessGroupsRequireAccessGsuiteGroupRule] +type accessGroupsRequireAccessGsuiteGroupRuleJSON struct { + Gsuite apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessGsuiteGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessGsuiteGroupRule) implementsZeroTrustAccessGroupsRequire() {} + +type AccessGroupsRequireAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID string `json:"connection_id,required"` + // The email of the Google Workspace group. + Email string `json:"email,required"` + JSON accessGroupsRequireAccessGsuiteGroupRuleGsuiteJSON `json:"-"` +} + +// accessGroupsRequireAccessGsuiteGroupRuleGsuiteJSON contains the JSON metadata +// for the struct [AccessGroupsRequireAccessGsuiteGroupRuleGsuite] +type accessGroupsRequireAccessGsuiteGroupRuleGsuiteJSON struct { + ConnectionID apijson.Field + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { + return r.raw +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessGroupsRequireAccessOktaGroupRule struct { + Okta AccessGroupsRequireAccessOktaGroupRuleOkta `json:"okta,required"` + JSON accessGroupsRequireAccessOktaGroupRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessOktaGroupRuleJSON contains the JSON metadata for the +// struct [AccessGroupsRequireAccessOktaGroupRule] +type accessGroupsRequireAccessOktaGroupRuleJSON struct { + Okta apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessOktaGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessOktaGroupRule) implementsZeroTrustAccessGroupsRequire() {} + +type AccessGroupsRequireAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID string `json:"connection_id,required"` + // The email of the Okta group. + Email string `json:"email,required"` + JSON accessGroupsRequireAccessOktaGroupRuleOktaJSON `json:"-"` +} + +// accessGroupsRequireAccessOktaGroupRuleOktaJSON contains the JSON metadata for +// the struct [AccessGroupsRequireAccessOktaGroupRuleOkta] +type accessGroupsRequireAccessOktaGroupRuleOktaJSON struct { + ConnectionID apijson.Field + Email apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessOktaGroupRuleOktaJSON) RawJSON() string { + return r.raw +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessGroupsRequireAccessSamlGroupRule struct { + Saml AccessGroupsRequireAccessSamlGroupRuleSaml `json:"saml,required"` + JSON accessGroupsRequireAccessSamlGroupRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessSamlGroupRuleJSON contains the JSON metadata for the +// struct [AccessGroupsRequireAccessSamlGroupRule] +type accessGroupsRequireAccessSamlGroupRuleJSON struct { + Saml apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessSamlGroupRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessSamlGroupRule) implementsZeroTrustAccessGroupsRequire() {} + +type AccessGroupsRequireAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName string `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue string `json:"attribute_value,required"` + JSON accessGroupsRequireAccessSamlGroupRuleSamlJSON `json:"-"` +} + +// accessGroupsRequireAccessSamlGroupRuleSamlJSON contains the JSON metadata for +// the struct [AccessGroupsRequireAccessSamlGroupRuleSaml] +type accessGroupsRequireAccessSamlGroupRuleSamlJSON struct { + AttributeName apijson.Field + AttributeValue apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessSamlGroupRuleSamlJSON) RawJSON() string { + return r.raw +} + +// Matches a specific Access Service Token +type AccessGroupsRequireAccessServiceTokenRule struct { + ServiceToken AccessGroupsRequireAccessServiceTokenRuleServiceToken `json:"service_token,required"` + JSON accessGroupsRequireAccessServiceTokenRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessServiceTokenRuleJSON contains the JSON metadata for the +// struct [AccessGroupsRequireAccessServiceTokenRule] +type accessGroupsRequireAccessServiceTokenRuleJSON struct { + ServiceToken apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessServiceTokenRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessServiceTokenRule) implementsZeroTrustAccessGroupsRequire() {} + +type AccessGroupsRequireAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID string `json:"token_id,required"` + JSON accessGroupsRequireAccessServiceTokenRuleServiceTokenJSON `json:"-"` +} + +// accessGroupsRequireAccessServiceTokenRuleServiceTokenJSON contains the JSON +// metadata for the struct [AccessGroupsRequireAccessServiceTokenRuleServiceToken] +type accessGroupsRequireAccessServiceTokenRuleServiceTokenJSON struct { + TokenID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { + return r.raw +} + +// Matches any valid Access Service Token +type AccessGroupsRequireAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` + JSON accessGroupsRequireAccessAnyValidServiceTokenRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessAnyValidServiceTokenRuleJSON contains the JSON metadata +// for the struct [AccessGroupsRequireAccessAnyValidServiceTokenRule] +type accessGroupsRequireAccessAnyValidServiceTokenRuleJSON struct { + AnyValidServiceToken apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessAnyValidServiceTokenRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupsRequire() {} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessGroupsRequireAccessExternalEvaluationRule struct { + ExternalEvaluation AccessGroupsRequireAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` + JSON accessGroupsRequireAccessExternalEvaluationRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessExternalEvaluationRuleJSON contains the JSON metadata +// for the struct [AccessGroupsRequireAccessExternalEvaluationRule] +type accessGroupsRequireAccessExternalEvaluationRuleJSON struct { + ExternalEvaluation apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessExternalEvaluationRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessExternalEvaluationRule) implementsZeroTrustAccessGroupsRequire() {} + +type AccessGroupsRequireAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL string `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL string `json:"keys_url,required"` + JSON accessGroupsRequireAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` +} + +// accessGroupsRequireAccessExternalEvaluationRuleExternalEvaluationJSON contains +// the JSON metadata for the struct +// [AccessGroupsRequireAccessExternalEvaluationRuleExternalEvaluation] +type accessGroupsRequireAccessExternalEvaluationRuleExternalEvaluationJSON struct { + EvaluateURL apijson.Field + KeysURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { + return r.raw +} + +// Matches a specific country +type AccessGroupsRequireAccessCountryRule struct { + Geo AccessGroupsRequireAccessCountryRuleGeo `json:"geo,required"` + JSON accessGroupsRequireAccessCountryRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessCountryRuleJSON contains the JSON metadata for the +// struct [AccessGroupsRequireAccessCountryRule] +type accessGroupsRequireAccessCountryRuleJSON struct { + Geo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessCountryRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessCountryRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessCountryRule) implementsZeroTrustAccessGroupsRequire() {} + +type AccessGroupsRequireAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode string `json:"country_code,required"` + JSON accessGroupsRequireAccessCountryRuleGeoJSON `json:"-"` +} + +// accessGroupsRequireAccessCountryRuleGeoJSON contains the JSON metadata for the +// struct [AccessGroupsRequireAccessCountryRuleGeo] +type accessGroupsRequireAccessCountryRuleGeoJSON struct { + CountryCode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessCountryRuleGeoJSON) RawJSON() string { + return r.raw +} + +// Enforce different MFA options +type AccessGroupsRequireAccessAuthenticationMethodRule struct { + AuthMethod AccessGroupsRequireAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` + JSON accessGroupsRequireAccessAuthenticationMethodRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessAuthenticationMethodRuleJSON contains the JSON metadata +// for the struct [AccessGroupsRequireAccessAuthenticationMethodRule] +type accessGroupsRequireAccessAuthenticationMethodRuleJSON struct { + AuthMethod apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessAuthenticationMethodRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupsRequire() {} + +type AccessGroupsRequireAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod string `json:"auth_method,required"` + JSON accessGroupsRequireAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` +} + +// accessGroupsRequireAccessAuthenticationMethodRuleAuthMethodJSON contains the +// JSON metadata for the struct +// [AccessGroupsRequireAccessAuthenticationMethodRuleAuthMethod] +type accessGroupsRequireAccessAuthenticationMethodRuleAuthMethodJSON struct { + AuthMethod apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { + return r.raw +} + +// Enforces a device posture rule has run successfully +type AccessGroupsRequireAccessDevicePostureRule struct { + DevicePosture AccessGroupsRequireAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` + JSON accessGroupsRequireAccessDevicePostureRuleJSON `json:"-"` +} + +// accessGroupsRequireAccessDevicePostureRuleJSON contains the JSON metadata for +// the struct [AccessGroupsRequireAccessDevicePostureRule] +type accessGroupsRequireAccessDevicePostureRuleJSON struct { + DevicePosture apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessDevicePostureRuleJSON) RawJSON() string { + return r.raw +} + +func (r AccessGroupsRequireAccessDevicePostureRule) implementsZeroTrustAccessGroupsRequire() {} + +type AccessGroupsRequireAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid string `json:"integration_uid,required"` + JSON accessGroupsRequireAccessDevicePostureRuleDevicePostureJSON `json:"-"` +} + +// accessGroupsRequireAccessDevicePostureRuleDevicePostureJSON contains the JSON +// metadata for the struct +// [AccessGroupsRequireAccessDevicePostureRuleDevicePosture] +type accessGroupsRequireAccessDevicePostureRuleDevicePostureJSON struct { + IntegrationUid apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupsRequireAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupsRequireAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { + return r.raw +} + +type AccessGroupDeleteResponse struct { + // UUID + ID string `json:"id"` + JSON accessGroupDeleteResponseJSON `json:"-"` +} + +// accessGroupDeleteResponseJSON contains the JSON metadata for the struct +// [AccessGroupDeleteResponse] +type accessGroupDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type AccessGroupNewParams struct { + // Rules evaluated with an OR logical operator. A user needs to meet only one of + // the Include rules. + Include param.Field[[]AccessGroupNewParamsInclude] `json:"include,required"` + // The name of the Access group. + Name param.Field[string] `json:"name,required"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // Rules evaluated with a NOT logical operator. To match a policy, a user cannot + // meet any of the Exclude rules. + Exclude param.Field[[]AccessGroupNewParamsExclude] `json:"exclude"` + // Whether this is the default group + IsDefault param.Field[bool] `json:"is_default"` + // Rules evaluated with an AND logical operator. To match a policy, a user must + // meet all of the Require rules. + Require param.Field[[]AccessGroupNewParamsRequire] `json:"require"` +} + +func (r AccessGroupNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific email. +// +// Satisfied by [zero_trust.AccessGroupNewParamsIncludeAccessEmailRule], +// [zero_trust.AccessGroupNewParamsIncludeAccessEmailListRule], +// [zero_trust.AccessGroupNewParamsIncludeAccessDomainRule], +// [zero_trust.AccessGroupNewParamsIncludeAccessEveryoneRule], +// [zero_trust.AccessGroupNewParamsIncludeAccessIPRule], +// [zero_trust.AccessGroupNewParamsIncludeAccessIPListRule], +// [zero_trust.AccessGroupNewParamsIncludeAccessCertificateRule], +// [zero_trust.AccessGroupNewParamsIncludeAccessAccessGroupRule], +// [zero_trust.AccessGroupNewParamsIncludeAccessAzureGroupRule], +// [zero_trust.AccessGroupNewParamsIncludeAccessGitHubOrganizationRule], +// [zero_trust.AccessGroupNewParamsIncludeAccessGsuiteGroupRule], +// [zero_trust.AccessGroupNewParamsIncludeAccessOktaGroupRule], +// [zero_trust.AccessGroupNewParamsIncludeAccessSamlGroupRule], +// [zero_trust.AccessGroupNewParamsIncludeAccessServiceTokenRule], +// [zero_trust.AccessGroupNewParamsIncludeAccessAnyValidServiceTokenRule], +// [zero_trust.AccessGroupNewParamsIncludeAccessExternalEvaluationRule], +// [zero_trust.AccessGroupNewParamsIncludeAccessCountryRule], +// [zero_trust.AccessGroupNewParamsIncludeAccessAuthenticationMethodRule], +// [zero_trust.AccessGroupNewParamsIncludeAccessDevicePostureRule]. +type AccessGroupNewParamsInclude interface { + implementsZeroTrustAccessGroupNewParamsInclude() +} + +// Matches a specific email. +type AccessGroupNewParamsIncludeAccessEmailRule struct { + Email param.Field[AccessGroupNewParamsIncludeAccessEmailRuleEmail] `json:"email,required"` +} + +func (r AccessGroupNewParamsIncludeAccessEmailRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessEmailRule) implementsZeroTrustAccessGroupNewParamsInclude() { +} + +type AccessGroupNewParamsIncludeAccessEmailRuleEmail struct { + // The email of the user. + Email param.Field[string] `json:"email,required" format:"email"` +} + +func (r AccessGroupNewParamsIncludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an email address from a list. +type AccessGroupNewParamsIncludeAccessEmailListRule struct { + EmailList param.Field[AccessGroupNewParamsIncludeAccessEmailListRuleEmailList] `json:"email_list,required"` +} + +func (r AccessGroupNewParamsIncludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessEmailListRule) implementsZeroTrustAccessGroupNewParamsInclude() { +} + +type AccessGroupNewParamsIncludeAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessGroupNewParamsIncludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Match an entire email domain. +type AccessGroupNewParamsIncludeAccessDomainRule struct { + EmailDomain param.Field[AccessGroupNewParamsIncludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` +} + +func (r AccessGroupNewParamsIncludeAccessDomainRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessDomainRule) implementsZeroTrustAccessGroupNewParamsInclude() { +} + +type AccessGroupNewParamsIncludeAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain param.Field[string] `json:"domain,required"` +} + +func (r AccessGroupNewParamsIncludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches everyone. +type AccessGroupNewParamsIncludeAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone param.Field[interface{}] `json:"everyone,required"` +} + +func (r AccessGroupNewParamsIncludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessEveryoneRule) implementsZeroTrustAccessGroupNewParamsInclude() { +} + +// Matches an IP address block. +type AccessGroupNewParamsIncludeAccessIPRule struct { + IP param.Field[AccessGroupNewParamsIncludeAccessIPRuleIP] `json:"ip,required"` +} + +func (r AccessGroupNewParamsIncludeAccessIPRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessIPRule) implementsZeroTrustAccessGroupNewParamsInclude() {} + +type AccessGroupNewParamsIncludeAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP param.Field[string] `json:"ip,required"` +} + +func (r AccessGroupNewParamsIncludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an IP address from a list. +type AccessGroupNewParamsIncludeAccessIPListRule struct { + IPList param.Field[AccessGroupNewParamsIncludeAccessIPListRuleIPList] `json:"ip_list,required"` +} + +func (r AccessGroupNewParamsIncludeAccessIPListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessIPListRule) implementsZeroTrustAccessGroupNewParamsInclude() { +} + +type AccessGroupNewParamsIncludeAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessGroupNewParamsIncludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid client certificate. +type AccessGroupNewParamsIncludeAccessCertificateRule struct { + Certificate param.Field[interface{}] `json:"certificate,required"` +} + +func (r AccessGroupNewParamsIncludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessCertificateRule) implementsZeroTrustAccessGroupNewParamsInclude() { +} + +// Matches an Access group. +type AccessGroupNewParamsIncludeAccessAccessGroupRule struct { + Group param.Field[AccessGroupNewParamsIncludeAccessAccessGroupRuleGroup] `json:"group,required"` +} + +func (r AccessGroupNewParamsIncludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessAccessGroupRule) implementsZeroTrustAccessGroupNewParamsInclude() { +} + +type AccessGroupNewParamsIncludeAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessGroupNewParamsIncludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessGroupNewParamsIncludeAccessAzureGroupRule struct { + AzureAd param.Field[AccessGroupNewParamsIncludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` +} + +func (r AccessGroupNewParamsIncludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessAzureGroupRule) implementsZeroTrustAccessGroupNewParamsInclude() { +} + +type AccessGroupNewParamsIncludeAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID param.Field[string] `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` +} + +func (r AccessGroupNewParamsIncludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessGroupNewParamsIncludeAccessGitHubOrganizationRule struct { + GitHubOrganization param.Field[AccessGroupNewParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` +} + +func (r AccessGroupNewParamsIncludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupNewParamsInclude() { +} + +type AccessGroupNewParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The name of the organization. + Name param.Field[string] `json:"name,required"` +} + +func (r AccessGroupNewParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessGroupNewParamsIncludeAccessGsuiteGroupRule struct { + Gsuite param.Field[AccessGroupNewParamsIncludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` +} + +func (r AccessGroupNewParamsIncludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupNewParamsInclude() { +} + +type AccessGroupNewParamsIncludeAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Google Workspace group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessGroupNewParamsIncludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessGroupNewParamsIncludeAccessOktaGroupRule struct { + Okta param.Field[AccessGroupNewParamsIncludeAccessOktaGroupRuleOkta] `json:"okta,required"` +} + +func (r AccessGroupNewParamsIncludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessOktaGroupRule) implementsZeroTrustAccessGroupNewParamsInclude() { +} + +type AccessGroupNewParamsIncludeAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Okta group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessGroupNewParamsIncludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessGroupNewParamsIncludeAccessSamlGroupRule struct { + Saml param.Field[AccessGroupNewParamsIncludeAccessSamlGroupRuleSaml] `json:"saml,required"` +} + +func (r AccessGroupNewParamsIncludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessSamlGroupRule) implementsZeroTrustAccessGroupNewParamsInclude() { +} + +type AccessGroupNewParamsIncludeAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName param.Field[string] `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue param.Field[string] `json:"attribute_value,required"` +} + +func (r AccessGroupNewParamsIncludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific Access Service Token +type AccessGroupNewParamsIncludeAccessServiceTokenRule struct { + ServiceToken param.Field[AccessGroupNewParamsIncludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` +} + +func (r AccessGroupNewParamsIncludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessServiceTokenRule) implementsZeroTrustAccessGroupNewParamsInclude() { +} + +type AccessGroupNewParamsIncludeAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID param.Field[string] `json:"token_id,required"` +} + +func (r AccessGroupNewParamsIncludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid Access Service Token +type AccessGroupNewParamsIncludeAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` +} + +func (r AccessGroupNewParamsIncludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupNewParamsInclude() { +} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessGroupNewParamsIncludeAccessExternalEvaluationRule struct { + ExternalEvaluation param.Field[AccessGroupNewParamsIncludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` +} + +func (r AccessGroupNewParamsIncludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupNewParamsInclude() { +} + +type AccessGroupNewParamsIncludeAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL param.Field[string] `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL param.Field[string] `json:"keys_url,required"` +} + +func (r AccessGroupNewParamsIncludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific country +type AccessGroupNewParamsIncludeAccessCountryRule struct { + Geo param.Field[AccessGroupNewParamsIncludeAccessCountryRuleGeo] `json:"geo,required"` +} + +func (r AccessGroupNewParamsIncludeAccessCountryRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessCountryRule) implementsZeroTrustAccessGroupNewParamsInclude() { +} + +type AccessGroupNewParamsIncludeAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode param.Field[string] `json:"country_code,required"` +} + +func (r AccessGroupNewParamsIncludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforce different MFA options +type AccessGroupNewParamsIncludeAccessAuthenticationMethodRule struct { + AuthMethod param.Field[AccessGroupNewParamsIncludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` +} + +func (r AccessGroupNewParamsIncludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupNewParamsInclude() { +} + +type AccessGroupNewParamsIncludeAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod param.Field[string] `json:"auth_method,required"` +} + +func (r AccessGroupNewParamsIncludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforces a device posture rule has run successfully +type AccessGroupNewParamsIncludeAccessDevicePostureRule struct { + DevicePosture param.Field[AccessGroupNewParamsIncludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` +} + +func (r AccessGroupNewParamsIncludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsIncludeAccessDevicePostureRule) implementsZeroTrustAccessGroupNewParamsInclude() { +} + +type AccessGroupNewParamsIncludeAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid param.Field[string] `json:"integration_uid,required"` +} + +func (r AccessGroupNewParamsIncludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific email. +// +// Satisfied by [zero_trust.AccessGroupNewParamsExcludeAccessEmailRule], +// [zero_trust.AccessGroupNewParamsExcludeAccessEmailListRule], +// [zero_trust.AccessGroupNewParamsExcludeAccessDomainRule], +// [zero_trust.AccessGroupNewParamsExcludeAccessEveryoneRule], +// [zero_trust.AccessGroupNewParamsExcludeAccessIPRule], +// [zero_trust.AccessGroupNewParamsExcludeAccessIPListRule], +// [zero_trust.AccessGroupNewParamsExcludeAccessCertificateRule], +// [zero_trust.AccessGroupNewParamsExcludeAccessAccessGroupRule], +// [zero_trust.AccessGroupNewParamsExcludeAccessAzureGroupRule], +// [zero_trust.AccessGroupNewParamsExcludeAccessGitHubOrganizationRule], +// [zero_trust.AccessGroupNewParamsExcludeAccessGsuiteGroupRule], +// [zero_trust.AccessGroupNewParamsExcludeAccessOktaGroupRule], +// [zero_trust.AccessGroupNewParamsExcludeAccessSamlGroupRule], +// [zero_trust.AccessGroupNewParamsExcludeAccessServiceTokenRule], +// [zero_trust.AccessGroupNewParamsExcludeAccessAnyValidServiceTokenRule], +// [zero_trust.AccessGroupNewParamsExcludeAccessExternalEvaluationRule], +// [zero_trust.AccessGroupNewParamsExcludeAccessCountryRule], +// [zero_trust.AccessGroupNewParamsExcludeAccessAuthenticationMethodRule], +// [zero_trust.AccessGroupNewParamsExcludeAccessDevicePostureRule]. +type AccessGroupNewParamsExclude interface { + implementsZeroTrustAccessGroupNewParamsExclude() +} + +// Matches a specific email. +type AccessGroupNewParamsExcludeAccessEmailRule struct { + Email param.Field[AccessGroupNewParamsExcludeAccessEmailRuleEmail] `json:"email,required"` +} + +func (r AccessGroupNewParamsExcludeAccessEmailRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessEmailRule) implementsZeroTrustAccessGroupNewParamsExclude() { +} + +type AccessGroupNewParamsExcludeAccessEmailRuleEmail struct { + // The email of the user. + Email param.Field[string] `json:"email,required" format:"email"` +} + +func (r AccessGroupNewParamsExcludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an email address from a list. +type AccessGroupNewParamsExcludeAccessEmailListRule struct { + EmailList param.Field[AccessGroupNewParamsExcludeAccessEmailListRuleEmailList] `json:"email_list,required"` +} + +func (r AccessGroupNewParamsExcludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessEmailListRule) implementsZeroTrustAccessGroupNewParamsExclude() { +} + +type AccessGroupNewParamsExcludeAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessGroupNewParamsExcludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Match an entire email domain. +type AccessGroupNewParamsExcludeAccessDomainRule struct { + EmailDomain param.Field[AccessGroupNewParamsExcludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` +} + +func (r AccessGroupNewParamsExcludeAccessDomainRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessDomainRule) implementsZeroTrustAccessGroupNewParamsExclude() { +} + +type AccessGroupNewParamsExcludeAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain param.Field[string] `json:"domain,required"` +} + +func (r AccessGroupNewParamsExcludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches everyone. +type AccessGroupNewParamsExcludeAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone param.Field[interface{}] `json:"everyone,required"` +} + +func (r AccessGroupNewParamsExcludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessEveryoneRule) implementsZeroTrustAccessGroupNewParamsExclude() { +} + +// Matches an IP address block. +type AccessGroupNewParamsExcludeAccessIPRule struct { + IP param.Field[AccessGroupNewParamsExcludeAccessIPRuleIP] `json:"ip,required"` +} + +func (r AccessGroupNewParamsExcludeAccessIPRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessIPRule) implementsZeroTrustAccessGroupNewParamsExclude() {} + +type AccessGroupNewParamsExcludeAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP param.Field[string] `json:"ip,required"` +} + +func (r AccessGroupNewParamsExcludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an IP address from a list. +type AccessGroupNewParamsExcludeAccessIPListRule struct { + IPList param.Field[AccessGroupNewParamsExcludeAccessIPListRuleIPList] `json:"ip_list,required"` +} + +func (r AccessGroupNewParamsExcludeAccessIPListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessIPListRule) implementsZeroTrustAccessGroupNewParamsExclude() { +} + +type AccessGroupNewParamsExcludeAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessGroupNewParamsExcludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid client certificate. +type AccessGroupNewParamsExcludeAccessCertificateRule struct { + Certificate param.Field[interface{}] `json:"certificate,required"` +} + +func (r AccessGroupNewParamsExcludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessCertificateRule) implementsZeroTrustAccessGroupNewParamsExclude() { +} + +// Matches an Access group. +type AccessGroupNewParamsExcludeAccessAccessGroupRule struct { + Group param.Field[AccessGroupNewParamsExcludeAccessAccessGroupRuleGroup] `json:"group,required"` +} + +func (r AccessGroupNewParamsExcludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessAccessGroupRule) implementsZeroTrustAccessGroupNewParamsExclude() { +} + +type AccessGroupNewParamsExcludeAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessGroupNewParamsExcludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessGroupNewParamsExcludeAccessAzureGroupRule struct { + AzureAd param.Field[AccessGroupNewParamsExcludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` +} + +func (r AccessGroupNewParamsExcludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessAzureGroupRule) implementsZeroTrustAccessGroupNewParamsExclude() { +} + +type AccessGroupNewParamsExcludeAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID param.Field[string] `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` +} + +func (r AccessGroupNewParamsExcludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessGroupNewParamsExcludeAccessGitHubOrganizationRule struct { + GitHubOrganization param.Field[AccessGroupNewParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` +} + +func (r AccessGroupNewParamsExcludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupNewParamsExclude() { +} + +type AccessGroupNewParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The name of the organization. + Name param.Field[string] `json:"name,required"` +} + +func (r AccessGroupNewParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessGroupNewParamsExcludeAccessGsuiteGroupRule struct { + Gsuite param.Field[AccessGroupNewParamsExcludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` +} + +func (r AccessGroupNewParamsExcludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupNewParamsExclude() { +} + +type AccessGroupNewParamsExcludeAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Google Workspace group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessGroupNewParamsExcludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessGroupNewParamsExcludeAccessOktaGroupRule struct { + Okta param.Field[AccessGroupNewParamsExcludeAccessOktaGroupRuleOkta] `json:"okta,required"` +} + +func (r AccessGroupNewParamsExcludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessOktaGroupRule) implementsZeroTrustAccessGroupNewParamsExclude() { +} + +type AccessGroupNewParamsExcludeAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Okta group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessGroupNewParamsExcludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessGroupNewParamsExcludeAccessSamlGroupRule struct { + Saml param.Field[AccessGroupNewParamsExcludeAccessSamlGroupRuleSaml] `json:"saml,required"` +} + +func (r AccessGroupNewParamsExcludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessSamlGroupRule) implementsZeroTrustAccessGroupNewParamsExclude() { +} + +type AccessGroupNewParamsExcludeAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName param.Field[string] `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue param.Field[string] `json:"attribute_value,required"` +} + +func (r AccessGroupNewParamsExcludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific Access Service Token +type AccessGroupNewParamsExcludeAccessServiceTokenRule struct { + ServiceToken param.Field[AccessGroupNewParamsExcludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` +} + +func (r AccessGroupNewParamsExcludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessServiceTokenRule) implementsZeroTrustAccessGroupNewParamsExclude() { +} + +type AccessGroupNewParamsExcludeAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID param.Field[string] `json:"token_id,required"` +} + +func (r AccessGroupNewParamsExcludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid Access Service Token +type AccessGroupNewParamsExcludeAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` +} + +func (r AccessGroupNewParamsExcludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupNewParamsExclude() { +} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessGroupNewParamsExcludeAccessExternalEvaluationRule struct { + ExternalEvaluation param.Field[AccessGroupNewParamsExcludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` +} + +func (r AccessGroupNewParamsExcludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupNewParamsExclude() { +} + +type AccessGroupNewParamsExcludeAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL param.Field[string] `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL param.Field[string] `json:"keys_url,required"` +} + +func (r AccessGroupNewParamsExcludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific country +type AccessGroupNewParamsExcludeAccessCountryRule struct { + Geo param.Field[AccessGroupNewParamsExcludeAccessCountryRuleGeo] `json:"geo,required"` +} + +func (r AccessGroupNewParamsExcludeAccessCountryRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessCountryRule) implementsZeroTrustAccessGroupNewParamsExclude() { +} + +type AccessGroupNewParamsExcludeAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode param.Field[string] `json:"country_code,required"` +} + +func (r AccessGroupNewParamsExcludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforce different MFA options +type AccessGroupNewParamsExcludeAccessAuthenticationMethodRule struct { + AuthMethod param.Field[AccessGroupNewParamsExcludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` +} + +func (r AccessGroupNewParamsExcludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupNewParamsExclude() { +} + +type AccessGroupNewParamsExcludeAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod param.Field[string] `json:"auth_method,required"` +} + +func (r AccessGroupNewParamsExcludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforces a device posture rule has run successfully +type AccessGroupNewParamsExcludeAccessDevicePostureRule struct { + DevicePosture param.Field[AccessGroupNewParamsExcludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` +} + +func (r AccessGroupNewParamsExcludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsExcludeAccessDevicePostureRule) implementsZeroTrustAccessGroupNewParamsExclude() { +} + +type AccessGroupNewParamsExcludeAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid param.Field[string] `json:"integration_uid,required"` +} + +func (r AccessGroupNewParamsExcludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific email. +// +// Satisfied by [zero_trust.AccessGroupNewParamsRequireAccessEmailRule], +// [zero_trust.AccessGroupNewParamsRequireAccessEmailListRule], +// [zero_trust.AccessGroupNewParamsRequireAccessDomainRule], +// [zero_trust.AccessGroupNewParamsRequireAccessEveryoneRule], +// [zero_trust.AccessGroupNewParamsRequireAccessIPRule], +// [zero_trust.AccessGroupNewParamsRequireAccessIPListRule], +// [zero_trust.AccessGroupNewParamsRequireAccessCertificateRule], +// [zero_trust.AccessGroupNewParamsRequireAccessAccessGroupRule], +// [zero_trust.AccessGroupNewParamsRequireAccessAzureGroupRule], +// [zero_trust.AccessGroupNewParamsRequireAccessGitHubOrganizationRule], +// [zero_trust.AccessGroupNewParamsRequireAccessGsuiteGroupRule], +// [zero_trust.AccessGroupNewParamsRequireAccessOktaGroupRule], +// [zero_trust.AccessGroupNewParamsRequireAccessSamlGroupRule], +// [zero_trust.AccessGroupNewParamsRequireAccessServiceTokenRule], +// [zero_trust.AccessGroupNewParamsRequireAccessAnyValidServiceTokenRule], +// [zero_trust.AccessGroupNewParamsRequireAccessExternalEvaluationRule], +// [zero_trust.AccessGroupNewParamsRequireAccessCountryRule], +// [zero_trust.AccessGroupNewParamsRequireAccessAuthenticationMethodRule], +// [zero_trust.AccessGroupNewParamsRequireAccessDevicePostureRule]. +type AccessGroupNewParamsRequire interface { + implementsZeroTrustAccessGroupNewParamsRequire() +} + +// Matches a specific email. +type AccessGroupNewParamsRequireAccessEmailRule struct { + Email param.Field[AccessGroupNewParamsRequireAccessEmailRuleEmail] `json:"email,required"` +} + +func (r AccessGroupNewParamsRequireAccessEmailRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessEmailRule) implementsZeroTrustAccessGroupNewParamsRequire() { +} + +type AccessGroupNewParamsRequireAccessEmailRuleEmail struct { + // The email of the user. + Email param.Field[string] `json:"email,required" format:"email"` +} + +func (r AccessGroupNewParamsRequireAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an email address from a list. +type AccessGroupNewParamsRequireAccessEmailListRule struct { + EmailList param.Field[AccessGroupNewParamsRequireAccessEmailListRuleEmailList] `json:"email_list,required"` +} + +func (r AccessGroupNewParamsRequireAccessEmailListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessEmailListRule) implementsZeroTrustAccessGroupNewParamsRequire() { +} + +type AccessGroupNewParamsRequireAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessGroupNewParamsRequireAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Match an entire email domain. +type AccessGroupNewParamsRequireAccessDomainRule struct { + EmailDomain param.Field[AccessGroupNewParamsRequireAccessDomainRuleEmailDomain] `json:"email_domain,required"` +} + +func (r AccessGroupNewParamsRequireAccessDomainRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessDomainRule) implementsZeroTrustAccessGroupNewParamsRequire() { +} + +type AccessGroupNewParamsRequireAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain param.Field[string] `json:"domain,required"` +} + +func (r AccessGroupNewParamsRequireAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches everyone. +type AccessGroupNewParamsRequireAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone param.Field[interface{}] `json:"everyone,required"` +} + +func (r AccessGroupNewParamsRequireAccessEveryoneRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessEveryoneRule) implementsZeroTrustAccessGroupNewParamsRequire() { +} + +// Matches an IP address block. +type AccessGroupNewParamsRequireAccessIPRule struct { + IP param.Field[AccessGroupNewParamsRequireAccessIPRuleIP] `json:"ip,required"` +} + +func (r AccessGroupNewParamsRequireAccessIPRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessIPRule) implementsZeroTrustAccessGroupNewParamsRequire() {} + +type AccessGroupNewParamsRequireAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP param.Field[string] `json:"ip,required"` +} + +func (r AccessGroupNewParamsRequireAccessIPRuleIP) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an IP address from a list. +type AccessGroupNewParamsRequireAccessIPListRule struct { + IPList param.Field[AccessGroupNewParamsRequireAccessIPListRuleIPList] `json:"ip_list,required"` +} + +func (r AccessGroupNewParamsRequireAccessIPListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessIPListRule) implementsZeroTrustAccessGroupNewParamsRequire() { +} + +type AccessGroupNewParamsRequireAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessGroupNewParamsRequireAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid client certificate. +type AccessGroupNewParamsRequireAccessCertificateRule struct { + Certificate param.Field[interface{}] `json:"certificate,required"` +} + +func (r AccessGroupNewParamsRequireAccessCertificateRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessCertificateRule) implementsZeroTrustAccessGroupNewParamsRequire() { +} + +// Matches an Access group. +type AccessGroupNewParamsRequireAccessAccessGroupRule struct { + Group param.Field[AccessGroupNewParamsRequireAccessAccessGroupRuleGroup] `json:"group,required"` +} + +func (r AccessGroupNewParamsRequireAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessAccessGroupRule) implementsZeroTrustAccessGroupNewParamsRequire() { +} + +type AccessGroupNewParamsRequireAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessGroupNewParamsRequireAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessGroupNewParamsRequireAccessAzureGroupRule struct { + AzureAd param.Field[AccessGroupNewParamsRequireAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` +} + +func (r AccessGroupNewParamsRequireAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessAzureGroupRule) implementsZeroTrustAccessGroupNewParamsRequire() { +} + +type AccessGroupNewParamsRequireAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID param.Field[string] `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` +} + +func (r AccessGroupNewParamsRequireAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessGroupNewParamsRequireAccessGitHubOrganizationRule struct { + GitHubOrganization param.Field[AccessGroupNewParamsRequireAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` +} + +func (r AccessGroupNewParamsRequireAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupNewParamsRequire() { +} + +type AccessGroupNewParamsRequireAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The name of the organization. + Name param.Field[string] `json:"name,required"` +} + +func (r AccessGroupNewParamsRequireAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessGroupNewParamsRequireAccessGsuiteGroupRule struct { + Gsuite param.Field[AccessGroupNewParamsRequireAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` +} + +func (r AccessGroupNewParamsRequireAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessGsuiteGroupRule) implementsZeroTrustAccessGroupNewParamsRequire() { +} + +type AccessGroupNewParamsRequireAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Google Workspace group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessGroupNewParamsRequireAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessGroupNewParamsRequireAccessOktaGroupRule struct { + Okta param.Field[AccessGroupNewParamsRequireAccessOktaGroupRuleOkta] `json:"okta,required"` +} + +func (r AccessGroupNewParamsRequireAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessOktaGroupRule) implementsZeroTrustAccessGroupNewParamsRequire() { +} + +type AccessGroupNewParamsRequireAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Okta group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessGroupNewParamsRequireAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessGroupNewParamsRequireAccessSamlGroupRule struct { + Saml param.Field[AccessGroupNewParamsRequireAccessSamlGroupRuleSaml] `json:"saml,required"` +} + +func (r AccessGroupNewParamsRequireAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessSamlGroupRule) implementsZeroTrustAccessGroupNewParamsRequire() { +} + +type AccessGroupNewParamsRequireAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName param.Field[string] `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue param.Field[string] `json:"attribute_value,required"` +} + +func (r AccessGroupNewParamsRequireAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific Access Service Token +type AccessGroupNewParamsRequireAccessServiceTokenRule struct { + ServiceToken param.Field[AccessGroupNewParamsRequireAccessServiceTokenRuleServiceToken] `json:"service_token,required"` +} + +func (r AccessGroupNewParamsRequireAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessServiceTokenRule) implementsZeroTrustAccessGroupNewParamsRequire() { +} + +type AccessGroupNewParamsRequireAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID param.Field[string] `json:"token_id,required"` +} + +func (r AccessGroupNewParamsRequireAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid Access Service Token +type AccessGroupNewParamsRequireAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` +} + +func (r AccessGroupNewParamsRequireAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupNewParamsRequire() { +} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessGroupNewParamsRequireAccessExternalEvaluationRule struct { + ExternalEvaluation param.Field[AccessGroupNewParamsRequireAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` +} + +func (r AccessGroupNewParamsRequireAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessExternalEvaluationRule) implementsZeroTrustAccessGroupNewParamsRequire() { +} + +type AccessGroupNewParamsRequireAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL param.Field[string] `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL param.Field[string] `json:"keys_url,required"` +} + +func (r AccessGroupNewParamsRequireAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific country +type AccessGroupNewParamsRequireAccessCountryRule struct { + Geo param.Field[AccessGroupNewParamsRequireAccessCountryRuleGeo] `json:"geo,required"` +} + +func (r AccessGroupNewParamsRequireAccessCountryRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessCountryRule) implementsZeroTrustAccessGroupNewParamsRequire() { +} + +type AccessGroupNewParamsRequireAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode param.Field[string] `json:"country_code,required"` +} + +func (r AccessGroupNewParamsRequireAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforce different MFA options +type AccessGroupNewParamsRequireAccessAuthenticationMethodRule struct { + AuthMethod param.Field[AccessGroupNewParamsRequireAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` +} + +func (r AccessGroupNewParamsRequireAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupNewParamsRequire() { +} + +type AccessGroupNewParamsRequireAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod param.Field[string] `json:"auth_method,required"` +} + +func (r AccessGroupNewParamsRequireAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforces a device posture rule has run successfully +type AccessGroupNewParamsRequireAccessDevicePostureRule struct { + DevicePosture param.Field[AccessGroupNewParamsRequireAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` +} + +func (r AccessGroupNewParamsRequireAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupNewParamsRequireAccessDevicePostureRule) implementsZeroTrustAccessGroupNewParamsRequire() { +} + +type AccessGroupNewParamsRequireAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid param.Field[string] `json:"integration_uid,required"` +} + +func (r AccessGroupNewParamsRequireAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AccessGroupNewResponseEnvelope struct { + Errors []AccessGroupNewResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessGroupNewResponseEnvelopeMessages `json:"messages,required"` + Result AccessGroups `json:"result,required"` + // Whether the API call was successful + Success AccessGroupNewResponseEnvelopeSuccess `json:"success,required"` + JSON accessGroupNewResponseEnvelopeJSON `json:"-"` +} + +// accessGroupNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessGroupNewResponseEnvelope] +type accessGroupNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessGroupNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessGroupNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessGroupNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessGroupNewResponseEnvelopeErrors] +type accessGroupNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessGroupNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessGroupNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessGroupNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessGroupNewResponseEnvelopeMessages] +type accessGroupNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessGroupNewResponseEnvelopeSuccess bool + +const ( + AccessGroupNewResponseEnvelopeSuccessTrue AccessGroupNewResponseEnvelopeSuccess = true +) + +type AccessGroupUpdateParams struct { + // Rules evaluated with an OR logical operator. A user needs to meet only one of + // the Include rules. + Include param.Field[[]AccessGroupUpdateParamsInclude] `json:"include,required"` + // The name of the Access group. + Name param.Field[string] `json:"name,required"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // Rules evaluated with a NOT logical operator. To match a policy, a user cannot + // meet any of the Exclude rules. + Exclude param.Field[[]AccessGroupUpdateParamsExclude] `json:"exclude"` + // Whether this is the default group + IsDefault param.Field[bool] `json:"is_default"` + // Rules evaluated with an AND logical operator. To match a policy, a user must + // meet all of the Require rules. + Require param.Field[[]AccessGroupUpdateParamsRequire] `json:"require"` +} + +func (r AccessGroupUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific email. +// +// Satisfied by [zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRule], +// [zero_trust.AccessGroupUpdateParamsIncludeAccessEmailListRule], +// [zero_trust.AccessGroupUpdateParamsIncludeAccessDomainRule], +// [zero_trust.AccessGroupUpdateParamsIncludeAccessEveryoneRule], +// [zero_trust.AccessGroupUpdateParamsIncludeAccessIPRule], +// [zero_trust.AccessGroupUpdateParamsIncludeAccessIPListRule], +// [zero_trust.AccessGroupUpdateParamsIncludeAccessCertificateRule], +// [zero_trust.AccessGroupUpdateParamsIncludeAccessAccessGroupRule], +// [zero_trust.AccessGroupUpdateParamsIncludeAccessAzureGroupRule], +// [zero_trust.AccessGroupUpdateParamsIncludeAccessGitHubOrganizationRule], +// [zero_trust.AccessGroupUpdateParamsIncludeAccessGsuiteGroupRule], +// [zero_trust.AccessGroupUpdateParamsIncludeAccessOktaGroupRule], +// [zero_trust.AccessGroupUpdateParamsIncludeAccessSamlGroupRule], +// [zero_trust.AccessGroupUpdateParamsIncludeAccessServiceTokenRule], +// [zero_trust.AccessGroupUpdateParamsIncludeAccessAnyValidServiceTokenRule], +// [zero_trust.AccessGroupUpdateParamsIncludeAccessExternalEvaluationRule], +// [zero_trust.AccessGroupUpdateParamsIncludeAccessCountryRule], +// [zero_trust.AccessGroupUpdateParamsIncludeAccessAuthenticationMethodRule], +// [zero_trust.AccessGroupUpdateParamsIncludeAccessDevicePostureRule]. +type AccessGroupUpdateParamsInclude interface { + implementsZeroTrustAccessGroupUpdateParamsInclude() +} + +// Matches a specific email. +type AccessGroupUpdateParamsIncludeAccessEmailRule struct { + Email param.Field[AccessGroupUpdateParamsIncludeAccessEmailRuleEmail] `json:"email,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessEmailRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessEmailRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +type AccessGroupUpdateParamsIncludeAccessEmailRuleEmail struct { + // The email of the user. + Email param.Field[string] `json:"email,required" format:"email"` +} + +func (r AccessGroupUpdateParamsIncludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an email address from a list. +type AccessGroupUpdateParamsIncludeAccessEmailListRule struct { + EmailList param.Field[AccessGroupUpdateParamsIncludeAccessEmailListRuleEmailList] `json:"email_list,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessEmailListRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +type AccessGroupUpdateParamsIncludeAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Match an entire email domain. +type AccessGroupUpdateParamsIncludeAccessDomainRule struct { + EmailDomain param.Field[AccessGroupUpdateParamsIncludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessDomainRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessDomainRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +type AccessGroupUpdateParamsIncludeAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain param.Field[string] `json:"domain,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches everyone. +type AccessGroupUpdateParamsIncludeAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone param.Field[interface{}] `json:"everyone,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessEveryoneRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +// Matches an IP address block. +type AccessGroupUpdateParamsIncludeAccessIPRule struct { + IP param.Field[AccessGroupUpdateParamsIncludeAccessIPRuleIP] `json:"ip,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessIPRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessIPRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +type AccessGroupUpdateParamsIncludeAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP param.Field[string] `json:"ip,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an IP address from a list. +type AccessGroupUpdateParamsIncludeAccessIPListRule struct { + IPList param.Field[AccessGroupUpdateParamsIncludeAccessIPListRuleIPList] `json:"ip_list,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessIPListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessIPListRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +type AccessGroupUpdateParamsIncludeAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid client certificate. +type AccessGroupUpdateParamsIncludeAccessCertificateRule struct { + Certificate param.Field[interface{}] `json:"certificate,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessCertificateRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +// Matches an Access group. +type AccessGroupUpdateParamsIncludeAccessAccessGroupRule struct { + Group param.Field[AccessGroupUpdateParamsIncludeAccessAccessGroupRuleGroup] `json:"group,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessAccessGroupRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +type AccessGroupUpdateParamsIncludeAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessGroupUpdateParamsIncludeAccessAzureGroupRule struct { + AzureAd param.Field[AccessGroupUpdateParamsIncludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessAzureGroupRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +type AccessGroupUpdateParamsIncludeAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID param.Field[string] `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessGroupUpdateParamsIncludeAccessGitHubOrganizationRule struct { + GitHubOrganization param.Field[AccessGroupUpdateParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +type AccessGroupUpdateParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The name of the organization. + Name param.Field[string] `json:"name,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessGroupUpdateParamsIncludeAccessGsuiteGroupRule struct { + Gsuite param.Field[AccessGroupUpdateParamsIncludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +type AccessGroupUpdateParamsIncludeAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Google Workspace group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessGroupUpdateParamsIncludeAccessOktaGroupRule struct { + Okta param.Field[AccessGroupUpdateParamsIncludeAccessOktaGroupRuleOkta] `json:"okta,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessOktaGroupRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +type AccessGroupUpdateParamsIncludeAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Okta group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessGroupUpdateParamsIncludeAccessSamlGroupRule struct { + Saml param.Field[AccessGroupUpdateParamsIncludeAccessSamlGroupRuleSaml] `json:"saml,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessSamlGroupRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +type AccessGroupUpdateParamsIncludeAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName param.Field[string] `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue param.Field[string] `json:"attribute_value,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific Access Service Token +type AccessGroupUpdateParamsIncludeAccessServiceTokenRule struct { + ServiceToken param.Field[AccessGroupUpdateParamsIncludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessServiceTokenRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +type AccessGroupUpdateParamsIncludeAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID param.Field[string] `json:"token_id,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid Access Service Token +type AccessGroupUpdateParamsIncludeAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessGroupUpdateParamsIncludeAccessExternalEvaluationRule struct { + ExternalEvaluation param.Field[AccessGroupUpdateParamsIncludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +type AccessGroupUpdateParamsIncludeAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL param.Field[string] `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL param.Field[string] `json:"keys_url,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific country +type AccessGroupUpdateParamsIncludeAccessCountryRule struct { + Geo param.Field[AccessGroupUpdateParamsIncludeAccessCountryRuleGeo] `json:"geo,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessCountryRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessCountryRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +type AccessGroupUpdateParamsIncludeAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode param.Field[string] `json:"country_code,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforce different MFA options +type AccessGroupUpdateParamsIncludeAccessAuthenticationMethodRule struct { + AuthMethod param.Field[AccessGroupUpdateParamsIncludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +type AccessGroupUpdateParamsIncludeAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod param.Field[string] `json:"auth_method,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforces a device posture rule has run successfully +type AccessGroupUpdateParamsIncludeAccessDevicePostureRule struct { + DevicePosture param.Field[AccessGroupUpdateParamsIncludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsIncludeAccessDevicePostureRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { +} + +type AccessGroupUpdateParamsIncludeAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid param.Field[string] `json:"integration_uid,required"` +} + +func (r AccessGroupUpdateParamsIncludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific email. +// +// Satisfied by [zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRule], +// [zero_trust.AccessGroupUpdateParamsExcludeAccessEmailListRule], +// [zero_trust.AccessGroupUpdateParamsExcludeAccessDomainRule], +// [zero_trust.AccessGroupUpdateParamsExcludeAccessEveryoneRule], +// [zero_trust.AccessGroupUpdateParamsExcludeAccessIPRule], +// [zero_trust.AccessGroupUpdateParamsExcludeAccessIPListRule], +// [zero_trust.AccessGroupUpdateParamsExcludeAccessCertificateRule], +// [zero_trust.AccessGroupUpdateParamsExcludeAccessAccessGroupRule], +// [zero_trust.AccessGroupUpdateParamsExcludeAccessAzureGroupRule], +// [zero_trust.AccessGroupUpdateParamsExcludeAccessGitHubOrganizationRule], +// [zero_trust.AccessGroupUpdateParamsExcludeAccessGsuiteGroupRule], +// [zero_trust.AccessGroupUpdateParamsExcludeAccessOktaGroupRule], +// [zero_trust.AccessGroupUpdateParamsExcludeAccessSamlGroupRule], +// [zero_trust.AccessGroupUpdateParamsExcludeAccessServiceTokenRule], +// [zero_trust.AccessGroupUpdateParamsExcludeAccessAnyValidServiceTokenRule], +// [zero_trust.AccessGroupUpdateParamsExcludeAccessExternalEvaluationRule], +// [zero_trust.AccessGroupUpdateParamsExcludeAccessCountryRule], +// [zero_trust.AccessGroupUpdateParamsExcludeAccessAuthenticationMethodRule], +// [zero_trust.AccessGroupUpdateParamsExcludeAccessDevicePostureRule]. +type AccessGroupUpdateParamsExclude interface { + implementsZeroTrustAccessGroupUpdateParamsExclude() +} + +// Matches a specific email. +type AccessGroupUpdateParamsExcludeAccessEmailRule struct { + Email param.Field[AccessGroupUpdateParamsExcludeAccessEmailRuleEmail] `json:"email,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessEmailRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessEmailRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +type AccessGroupUpdateParamsExcludeAccessEmailRuleEmail struct { + // The email of the user. + Email param.Field[string] `json:"email,required" format:"email"` +} + +func (r AccessGroupUpdateParamsExcludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an email address from a list. +type AccessGroupUpdateParamsExcludeAccessEmailListRule struct { + EmailList param.Field[AccessGroupUpdateParamsExcludeAccessEmailListRuleEmailList] `json:"email_list,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessEmailListRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +type AccessGroupUpdateParamsExcludeAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Match an entire email domain. +type AccessGroupUpdateParamsExcludeAccessDomainRule struct { + EmailDomain param.Field[AccessGroupUpdateParamsExcludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessDomainRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessDomainRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +type AccessGroupUpdateParamsExcludeAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain param.Field[string] `json:"domain,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches everyone. +type AccessGroupUpdateParamsExcludeAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone param.Field[interface{}] `json:"everyone,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessEveryoneRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +// Matches an IP address block. +type AccessGroupUpdateParamsExcludeAccessIPRule struct { + IP param.Field[AccessGroupUpdateParamsExcludeAccessIPRuleIP] `json:"ip,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessIPRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessIPRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +type AccessGroupUpdateParamsExcludeAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP param.Field[string] `json:"ip,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an IP address from a list. +type AccessGroupUpdateParamsExcludeAccessIPListRule struct { + IPList param.Field[AccessGroupUpdateParamsExcludeAccessIPListRuleIPList] `json:"ip_list,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessIPListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessIPListRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +type AccessGroupUpdateParamsExcludeAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid client certificate. +type AccessGroupUpdateParamsExcludeAccessCertificateRule struct { + Certificate param.Field[interface{}] `json:"certificate,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessCertificateRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +// Matches an Access group. +type AccessGroupUpdateParamsExcludeAccessAccessGroupRule struct { + Group param.Field[AccessGroupUpdateParamsExcludeAccessAccessGroupRuleGroup] `json:"group,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessAccessGroupRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +type AccessGroupUpdateParamsExcludeAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessGroupUpdateParamsExcludeAccessAzureGroupRule struct { + AzureAd param.Field[AccessGroupUpdateParamsExcludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessAzureGroupRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +type AccessGroupUpdateParamsExcludeAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID param.Field[string] `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessGroupUpdateParamsExcludeAccessGitHubOrganizationRule struct { + GitHubOrganization param.Field[AccessGroupUpdateParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +type AccessGroupUpdateParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The name of the organization. + Name param.Field[string] `json:"name,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessGroupUpdateParamsExcludeAccessGsuiteGroupRule struct { + Gsuite param.Field[AccessGroupUpdateParamsExcludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +type AccessGroupUpdateParamsExcludeAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Google Workspace group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessGroupUpdateParamsExcludeAccessOktaGroupRule struct { + Okta param.Field[AccessGroupUpdateParamsExcludeAccessOktaGroupRuleOkta] `json:"okta,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessOktaGroupRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +type AccessGroupUpdateParamsExcludeAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Okta group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessGroupUpdateParamsExcludeAccessSamlGroupRule struct { + Saml param.Field[AccessGroupUpdateParamsExcludeAccessSamlGroupRuleSaml] `json:"saml,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessSamlGroupRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +type AccessGroupUpdateParamsExcludeAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName param.Field[string] `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue param.Field[string] `json:"attribute_value,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific Access Service Token +type AccessGroupUpdateParamsExcludeAccessServiceTokenRule struct { + ServiceToken param.Field[AccessGroupUpdateParamsExcludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessServiceTokenRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +type AccessGroupUpdateParamsExcludeAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID param.Field[string] `json:"token_id,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid Access Service Token +type AccessGroupUpdateParamsExcludeAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessGroupUpdateParamsExcludeAccessExternalEvaluationRule struct { + ExternalEvaluation param.Field[AccessGroupUpdateParamsExcludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +type AccessGroupUpdateParamsExcludeAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL param.Field[string] `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL param.Field[string] `json:"keys_url,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific country +type AccessGroupUpdateParamsExcludeAccessCountryRule struct { + Geo param.Field[AccessGroupUpdateParamsExcludeAccessCountryRuleGeo] `json:"geo,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessCountryRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessCountryRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +type AccessGroupUpdateParamsExcludeAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode param.Field[string] `json:"country_code,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforce different MFA options +type AccessGroupUpdateParamsExcludeAccessAuthenticationMethodRule struct { + AuthMethod param.Field[AccessGroupUpdateParamsExcludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +type AccessGroupUpdateParamsExcludeAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod param.Field[string] `json:"auth_method,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforces a device posture rule has run successfully +type AccessGroupUpdateParamsExcludeAccessDevicePostureRule struct { + DevicePosture param.Field[AccessGroupUpdateParamsExcludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsExcludeAccessDevicePostureRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { +} + +type AccessGroupUpdateParamsExcludeAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid param.Field[string] `json:"integration_uid,required"` +} + +func (r AccessGroupUpdateParamsExcludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific email. +// +// Satisfied by [zero_trust.AccessGroupUpdateParamsRequireAccessEmailRule], +// [zero_trust.AccessGroupUpdateParamsRequireAccessEmailListRule], +// [zero_trust.AccessGroupUpdateParamsRequireAccessDomainRule], +// [zero_trust.AccessGroupUpdateParamsRequireAccessEveryoneRule], +// [zero_trust.AccessGroupUpdateParamsRequireAccessIPRule], +// [zero_trust.AccessGroupUpdateParamsRequireAccessIPListRule], +// [zero_trust.AccessGroupUpdateParamsRequireAccessCertificateRule], +// [zero_trust.AccessGroupUpdateParamsRequireAccessAccessGroupRule], +// [zero_trust.AccessGroupUpdateParamsRequireAccessAzureGroupRule], +// [zero_trust.AccessGroupUpdateParamsRequireAccessGitHubOrganizationRule], +// [zero_trust.AccessGroupUpdateParamsRequireAccessGsuiteGroupRule], +// [zero_trust.AccessGroupUpdateParamsRequireAccessOktaGroupRule], +// [zero_trust.AccessGroupUpdateParamsRequireAccessSamlGroupRule], +// [zero_trust.AccessGroupUpdateParamsRequireAccessServiceTokenRule], +// [zero_trust.AccessGroupUpdateParamsRequireAccessAnyValidServiceTokenRule], +// [zero_trust.AccessGroupUpdateParamsRequireAccessExternalEvaluationRule], +// [zero_trust.AccessGroupUpdateParamsRequireAccessCountryRule], +// [zero_trust.AccessGroupUpdateParamsRequireAccessAuthenticationMethodRule], +// [zero_trust.AccessGroupUpdateParamsRequireAccessDevicePostureRule]. +type AccessGroupUpdateParamsRequire interface { + implementsZeroTrustAccessGroupUpdateParamsRequire() +} + +// Matches a specific email. +type AccessGroupUpdateParamsRequireAccessEmailRule struct { + Email param.Field[AccessGroupUpdateParamsRequireAccessEmailRuleEmail] `json:"email,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessEmailRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessEmailRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +type AccessGroupUpdateParamsRequireAccessEmailRuleEmail struct { + // The email of the user. + Email param.Field[string] `json:"email,required" format:"email"` +} + +func (r AccessGroupUpdateParamsRequireAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an email address from a list. +type AccessGroupUpdateParamsRequireAccessEmailListRule struct { + EmailList param.Field[AccessGroupUpdateParamsRequireAccessEmailListRuleEmailList] `json:"email_list,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessEmailListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessEmailListRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +type AccessGroupUpdateParamsRequireAccessEmailListRuleEmailList struct { + // The ID of a previously created email list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Match an entire email domain. +type AccessGroupUpdateParamsRequireAccessDomainRule struct { + EmailDomain param.Field[AccessGroupUpdateParamsRequireAccessDomainRuleEmailDomain] `json:"email_domain,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessDomainRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessDomainRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +type AccessGroupUpdateParamsRequireAccessDomainRuleEmailDomain struct { + // The email domain to match. + Domain param.Field[string] `json:"domain,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches everyone. +type AccessGroupUpdateParamsRequireAccessEveryoneRule struct { + // An empty object which matches on all users. + Everyone param.Field[interface{}] `json:"everyone,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessEveryoneRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessEveryoneRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +// Matches an IP address block. +type AccessGroupUpdateParamsRequireAccessIPRule struct { + IP param.Field[AccessGroupUpdateParamsRequireAccessIPRuleIP] `json:"ip,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessIPRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessIPRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +type AccessGroupUpdateParamsRequireAccessIPRuleIP struct { + // An IPv4 or IPv6 CIDR block. + IP param.Field[string] `json:"ip,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessIPRuleIP) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an IP address from a list. +type AccessGroupUpdateParamsRequireAccessIPListRule struct { + IPList param.Field[AccessGroupUpdateParamsRequireAccessIPListRuleIPList] `json:"ip_list,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessIPListRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessIPListRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +type AccessGroupUpdateParamsRequireAccessIPListRuleIPList struct { + // The ID of a previously created IP list. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid client certificate. +type AccessGroupUpdateParamsRequireAccessCertificateRule struct { + Certificate param.Field[interface{}] `json:"certificate,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessCertificateRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessCertificateRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +// Matches an Access group. +type AccessGroupUpdateParamsRequireAccessAccessGroupRule struct { + Group param.Field[AccessGroupUpdateParamsRequireAccessAccessGroupRuleGroup] `json:"group,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessAccessGroupRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +type AccessGroupUpdateParamsRequireAccessAccessGroupRuleGroup struct { + // The ID of a previously created Access group. + ID param.Field[string] `json:"id,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Azure group. Requires an Azure identity provider. +type AccessGroupUpdateParamsRequireAccessAzureGroupRule struct { + AzureAd param.Field[AccessGroupUpdateParamsRequireAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessAzureGroupRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +type AccessGroupUpdateParamsRequireAccessAzureGroupRuleAzureAd struct { + // The ID of an Azure group. + ID param.Field[string] `json:"id,required"` + // The ID of your Azure identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a Github organization. Requires a Github identity provider. +type AccessGroupUpdateParamsRequireAccessGitHubOrganizationRule struct { + GitHubOrganization param.Field[AccessGroupUpdateParamsRequireAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +type AccessGroupUpdateParamsRequireAccessGitHubOrganizationRuleGitHubOrganization struct { + // The ID of your Github identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The name of the organization. + Name param.Field[string] `json:"name,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a group in Google Workspace. Requires a Google Workspace identity +// provider. +type AccessGroupUpdateParamsRequireAccessGsuiteGroupRule struct { + Gsuite param.Field[AccessGroupUpdateParamsRequireAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessGsuiteGroupRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +type AccessGroupUpdateParamsRequireAccessGsuiteGroupRuleGsuite struct { + // The ID of your Google Workspace identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Google Workspace group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches an Okta group. Requires an Okta identity provider. +type AccessGroupUpdateParamsRequireAccessOktaGroupRule struct { + Okta param.Field[AccessGroupUpdateParamsRequireAccessOktaGroupRuleOkta] `json:"okta,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessOktaGroupRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +type AccessGroupUpdateParamsRequireAccessOktaGroupRuleOkta struct { + // The ID of your Okta identity provider. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The email of the Okta group. + Email param.Field[string] `json:"email,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a SAML group. Requires a SAML identity provider. +type AccessGroupUpdateParamsRequireAccessSamlGroupRule struct { + Saml param.Field[AccessGroupUpdateParamsRequireAccessSamlGroupRuleSaml] `json:"saml,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessSamlGroupRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +type AccessGroupUpdateParamsRequireAccessSamlGroupRuleSaml struct { + // The name of the SAML attribute. + AttributeName param.Field[string] `json:"attribute_name,required"` + // The SAML attribute value to look for. + AttributeValue param.Field[string] `json:"attribute_value,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific Access Service Token +type AccessGroupUpdateParamsRequireAccessServiceTokenRule struct { + ServiceToken param.Field[AccessGroupUpdateParamsRequireAccessServiceTokenRuleServiceToken] `json:"service_token,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessServiceTokenRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +type AccessGroupUpdateParamsRequireAccessServiceTokenRuleServiceToken struct { + // The ID of a Service Token. + TokenID param.Field[string] `json:"token_id,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches any valid Access Service Token +type AccessGroupUpdateParamsRequireAccessAnyValidServiceTokenRule struct { + // An empty object which matches on all service tokens. + AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +// Create Allow or Block policies which evaluate the user based on custom criteria. +type AccessGroupUpdateParamsRequireAccessExternalEvaluationRule struct { + ExternalEvaluation param.Field[AccessGroupUpdateParamsRequireAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessExternalEvaluationRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +type AccessGroupUpdateParamsRequireAccessExternalEvaluationRuleExternalEvaluation struct { + // The API endpoint containing your business logic. + EvaluateURL param.Field[string] `json:"evaluate_url,required"` + // The API endpoint containing the key that Access uses to verify that the response + // came from your API. + KeysURL param.Field[string] `json:"keys_url,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Matches a specific country +type AccessGroupUpdateParamsRequireAccessCountryRule struct { + Geo param.Field[AccessGroupUpdateParamsRequireAccessCountryRuleGeo] `json:"geo,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessCountryRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessCountryRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +type AccessGroupUpdateParamsRequireAccessCountryRuleGeo struct { + // The country code that should be matched. + CountryCode param.Field[string] `json:"country_code,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforce different MFA options +type AccessGroupUpdateParamsRequireAccessAuthenticationMethodRule struct { + AuthMethod param.Field[AccessGroupUpdateParamsRequireAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +type AccessGroupUpdateParamsRequireAccessAuthenticationMethodRuleAuthMethod struct { + // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. + AuthMethod param.Field[string] `json:"auth_method,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enforces a device posture rule has run successfully +type AccessGroupUpdateParamsRequireAccessDevicePostureRule struct { + DevicePosture param.Field[AccessGroupUpdateParamsRequireAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessGroupUpdateParamsRequireAccessDevicePostureRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { +} + +type AccessGroupUpdateParamsRequireAccessDevicePostureRuleDevicePosture struct { + // The ID of a device posture integration. + IntegrationUid param.Field[string] `json:"integration_uid,required"` +} + +func (r AccessGroupUpdateParamsRequireAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AccessGroupUpdateResponseEnvelope struct { + Errors []AccessGroupUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessGroupUpdateResponseEnvelopeMessages `json:"messages,required"` + Result AccessGroups `json:"result,required"` + // Whether the API call was successful + Success AccessGroupUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON accessGroupUpdateResponseEnvelopeJSON `json:"-"` +} + +// accessGroupUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessGroupUpdateResponseEnvelope] +type accessGroupUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessGroupUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessGroupUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessGroupUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessGroupUpdateResponseEnvelopeErrors] +type accessGroupUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessGroupUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessGroupUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessGroupUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessGroupUpdateResponseEnvelopeMessages] +type accessGroupUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessGroupUpdateResponseEnvelopeSuccess bool + +const ( + AccessGroupUpdateResponseEnvelopeSuccessTrue AccessGroupUpdateResponseEnvelopeSuccess = true +) + +type AccessGroupListParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessGroupListResponseEnvelope struct { + Errors []AccessGroupListResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessGroupListResponseEnvelopeMessages `json:"messages,required"` + Result []AccessGroups `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessGroupListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AccessGroupListResponseEnvelopeResultInfo `json:"result_info"` + JSON accessGroupListResponseEnvelopeJSON `json:"-"` +} + +// accessGroupListResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessGroupListResponseEnvelope] +type accessGroupListResponseEnvelopeJSON 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 *AccessGroupListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessGroupListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessGroupListResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessGroupListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessGroupListResponseEnvelopeErrors] +type accessGroupListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessGroupListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessGroupListResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessGroupListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessGroupListResponseEnvelopeMessages] +type accessGroupListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessGroupListResponseEnvelopeSuccess bool + +const ( + AccessGroupListResponseEnvelopeSuccessTrue AccessGroupListResponseEnvelopeSuccess = true +) + +type AccessGroupListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON accessGroupListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// accessGroupListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [AccessGroupListResponseEnvelopeResultInfo] +type accessGroupListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type AccessGroupDeleteParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessGroupDeleteResponseEnvelope struct { + Errors []AccessGroupDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessGroupDeleteResponseEnvelopeMessages `json:"messages,required"` + Result AccessGroupDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success AccessGroupDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON accessGroupDeleteResponseEnvelopeJSON `json:"-"` +} + +// accessGroupDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessGroupDeleteResponseEnvelope] +type accessGroupDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessGroupDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessGroupDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessGroupDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessGroupDeleteResponseEnvelopeErrors] +type accessGroupDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessGroupDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessGroupDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessGroupDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessGroupDeleteResponseEnvelopeMessages] +type accessGroupDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessGroupDeleteResponseEnvelopeSuccess bool + +const ( + AccessGroupDeleteResponseEnvelopeSuccessTrue AccessGroupDeleteResponseEnvelopeSuccess = true +) + +type AccessGroupGetParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessGroupGetResponseEnvelope struct { + Errors []AccessGroupGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessGroupGetResponseEnvelopeMessages `json:"messages,required"` + Result AccessGroups `json:"result,required"` + // Whether the API call was successful + Success AccessGroupGetResponseEnvelopeSuccess `json:"success,required"` + JSON accessGroupGetResponseEnvelopeJSON `json:"-"` +} + +// accessGroupGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessGroupGetResponseEnvelope] +type accessGroupGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessGroupGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessGroupGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessGroupGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessGroupGetResponseEnvelopeErrors] +type accessGroupGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessGroupGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessGroupGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessGroupGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessGroupGetResponseEnvelopeMessages] +type accessGroupGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessGroupGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessGroupGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessGroupGetResponseEnvelopeSuccess bool + +const ( + AccessGroupGetResponseEnvelopeSuccessTrue AccessGroupGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/accessgroup_test.go b/zero_trust/accessgroup_test.go new file mode 100644 index 00000000000..ca8e4068d91 --- /dev/null +++ b/zero_trust/accessgroup_test.go @@ -0,0 +1,244 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestAccessGroupNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Groups.New(context.TODO(), zero_trust.AccessGroupNewParams{ + Include: cloudflare.F([]zero_trust.AccessGroupNewParamsInclude{zero_trust.AccessGroupNewParamsIncludeAccessEmailRule(zero_trust.AccessGroupNewParamsIncludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessGroupNewParamsIncludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessGroupNewParamsIncludeAccessEmailRule(zero_trust.AccessGroupNewParamsIncludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessGroupNewParamsIncludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessGroupNewParamsIncludeAccessEmailRule(zero_trust.AccessGroupNewParamsIncludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessGroupNewParamsIncludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + })}), + Name: cloudflare.F("Allow devs"), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + Exclude: cloudflare.F([]zero_trust.AccessGroupNewParamsExclude{zero_trust.AccessGroupNewParamsExcludeAccessEmailRule(zero_trust.AccessGroupNewParamsExcludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessGroupNewParamsExcludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessGroupNewParamsExcludeAccessEmailRule(zero_trust.AccessGroupNewParamsExcludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessGroupNewParamsExcludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessGroupNewParamsExcludeAccessEmailRule(zero_trust.AccessGroupNewParamsExcludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessGroupNewParamsExcludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + })}), + IsDefault: cloudflare.F(true), + Require: cloudflare.F([]zero_trust.AccessGroupNewParamsRequire{zero_trust.AccessGroupNewParamsRequireAccessEmailRule(zero_trust.AccessGroupNewParamsRequireAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessGroupNewParamsRequireAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessGroupNewParamsRequireAccessEmailRule(zero_trust.AccessGroupNewParamsRequireAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessGroupNewParamsRequireAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessGroupNewParamsRequireAccessEmailRule(zero_trust.AccessGroupNewParamsRequireAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessGroupNewParamsRequireAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + })}), + }) + 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 TestAccessGroupUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Groups.Update( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessGroupUpdateParams{ + Include: cloudflare.F([]zero_trust.AccessGroupUpdateParamsInclude{zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRule(zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRule(zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRule(zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessGroupUpdateParamsIncludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + })}), + Name: cloudflare.F("Allow devs"), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + Exclude: cloudflare.F([]zero_trust.AccessGroupUpdateParamsExclude{zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRule(zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRule(zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRule(zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessGroupUpdateParamsExcludeAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + })}), + IsDefault: cloudflare.F(true), + Require: cloudflare.F([]zero_trust.AccessGroupUpdateParamsRequire{zero_trust.AccessGroupUpdateParamsRequireAccessEmailRule(zero_trust.AccessGroupUpdateParamsRequireAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessGroupUpdateParamsRequireAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessGroupUpdateParamsRequireAccessEmailRule(zero_trust.AccessGroupUpdateParamsRequireAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessGroupUpdateParamsRequireAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + }), zero_trust.AccessGroupUpdateParamsRequireAccessEmailRule(zero_trust.AccessGroupUpdateParamsRequireAccessEmailRule{ + Email: cloudflare.F(zero_trust.AccessGroupUpdateParamsRequireAccessEmailRuleEmail{ + Email: cloudflare.F("test@example.com"), + }), + })}), + }, + ) + 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 TestAccessGroupListWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Groups.List(context.TODO(), zero_trust.AccessGroupListParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }) + 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 TestAccessGroupDeleteWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Groups.Delete( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessGroupDeleteParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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 TestAccessGroupGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Groups.Get( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessGroupGetParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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/zero_trust/accesskey.go b/zero_trust/accesskey.go new file mode 100644 index 00000000000..8dd2ea636ac --- /dev/null +++ b/zero_trust/accesskey.go @@ -0,0 +1,404 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// AccessKeyService 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 [NewAccessKeyService] method instead. +type AccessKeyService struct { + Options []option.RequestOption +} + +// NewAccessKeyService 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 NewAccessKeyService(opts ...option.RequestOption) (r *AccessKeyService) { + r = &AccessKeyService{} + r.Options = opts + return +} + +// Updates the Access key rotation settings for an account. +func (r *AccessKeyService) Update(ctx context.Context, identifier string, body AccessKeyUpdateParams, opts ...option.RequestOption) (res *AccessKeyUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessKeyUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/keys", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets the Access key rotation settings for an account. +func (r *AccessKeyService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *AccessKeyListResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessKeyListResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/keys", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Perfoms a key rotation for an account. +func (r *AccessKeyService) Rotate(ctx context.Context, identifier string, opts ...option.RequestOption) (res *AccessKeyRotateResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessKeyRotateResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/keys/rotate", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [zero_trust.AccessKeyUpdateResponseUnknown] or +// [shared.UnionString]. +type AccessKeyUpdateResponse interface { + ImplementsZeroTrustAccessKeyUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessKeyUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [zero_trust.AccessKeyListResponseUnknown] or +// [shared.UnionString]. +type AccessKeyListResponse interface { + ImplementsZeroTrustAccessKeyListResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessKeyListResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Union satisfied by [zero_trust.AccessKeyRotateResponseUnknown] or +// [shared.UnionString]. +type AccessKeyRotateResponse interface { + ImplementsZeroTrustAccessKeyRotateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessKeyRotateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type AccessKeyUpdateParams struct { + // The number of days between key rotations. + KeyRotationIntervalDays param.Field[float64] `json:"key_rotation_interval_days,required"` +} + +func (r AccessKeyUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AccessKeyUpdateResponseEnvelope struct { + Errors []AccessKeyUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessKeyUpdateResponseEnvelopeMessages `json:"messages,required"` + Result AccessKeyUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success AccessKeyUpdateResponseEnvelopeSuccess `json:"success,required"` + // The number of days until the next key rotation. + DaysUntilNextRotation float64 `json:"days_until_next_rotation"` + // The number of days between key rotations. + KeyRotationIntervalDays float64 `json:"key_rotation_interval_days"` + // The timestamp of the previous key rotation. + LastKeyRotationAt time.Time `json:"last_key_rotation_at" format:"date-time"` + JSON accessKeyUpdateResponseEnvelopeJSON `json:"-"` +} + +// accessKeyUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessKeyUpdateResponseEnvelope] +type accessKeyUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + DaysUntilNextRotation apijson.Field + KeyRotationIntervalDays apijson.Field + LastKeyRotationAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessKeyUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessKeyUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessKeyUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessKeyUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessKeyUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessKeyUpdateResponseEnvelopeErrors] +type accessKeyUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessKeyUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessKeyUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessKeyUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessKeyUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessKeyUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessKeyUpdateResponseEnvelopeMessages] +type accessKeyUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessKeyUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessKeyUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessKeyUpdateResponseEnvelopeSuccess bool + +const ( + AccessKeyUpdateResponseEnvelopeSuccessTrue AccessKeyUpdateResponseEnvelopeSuccess = true +) + +type AccessKeyListResponseEnvelope struct { + Errors []AccessKeyListResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessKeyListResponseEnvelopeMessages `json:"messages,required"` + Result AccessKeyListResponse `json:"result,required"` + // Whether the API call was successful + Success AccessKeyListResponseEnvelopeSuccess `json:"success,required"` + // The number of days until the next key rotation. + DaysUntilNextRotation float64 `json:"days_until_next_rotation"` + // The number of days between key rotations. + KeyRotationIntervalDays float64 `json:"key_rotation_interval_days"` + // The timestamp of the previous key rotation. + LastKeyRotationAt time.Time `json:"last_key_rotation_at" format:"date-time"` + JSON accessKeyListResponseEnvelopeJSON `json:"-"` +} + +// accessKeyListResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessKeyListResponseEnvelope] +type accessKeyListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + DaysUntilNextRotation apijson.Field + KeyRotationIntervalDays apijson.Field + LastKeyRotationAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessKeyListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessKeyListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessKeyListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessKeyListResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessKeyListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessKeyListResponseEnvelopeErrors] +type accessKeyListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessKeyListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessKeyListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessKeyListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessKeyListResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessKeyListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessKeyListResponseEnvelopeMessages] +type accessKeyListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessKeyListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessKeyListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessKeyListResponseEnvelopeSuccess bool + +const ( + AccessKeyListResponseEnvelopeSuccessTrue AccessKeyListResponseEnvelopeSuccess = true +) + +type AccessKeyRotateResponseEnvelope struct { + Errors []AccessKeyRotateResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessKeyRotateResponseEnvelopeMessages `json:"messages,required"` + Result AccessKeyRotateResponse `json:"result,required"` + // Whether the API call was successful + Success AccessKeyRotateResponseEnvelopeSuccess `json:"success,required"` + // The number of days until the next key rotation. + DaysUntilNextRotation float64 `json:"days_until_next_rotation"` + // The number of days between key rotations. + KeyRotationIntervalDays float64 `json:"key_rotation_interval_days"` + // The timestamp of the previous key rotation. + LastKeyRotationAt time.Time `json:"last_key_rotation_at" format:"date-time"` + JSON accessKeyRotateResponseEnvelopeJSON `json:"-"` +} + +// accessKeyRotateResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessKeyRotateResponseEnvelope] +type accessKeyRotateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + DaysUntilNextRotation apijson.Field + KeyRotationIntervalDays apijson.Field + LastKeyRotationAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessKeyRotateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessKeyRotateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessKeyRotateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessKeyRotateResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessKeyRotateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessKeyRotateResponseEnvelopeErrors] +type accessKeyRotateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessKeyRotateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessKeyRotateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessKeyRotateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessKeyRotateResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessKeyRotateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessKeyRotateResponseEnvelopeMessages] +type accessKeyRotateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessKeyRotateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessKeyRotateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessKeyRotateResponseEnvelopeSuccess bool + +const ( + AccessKeyRotateResponseEnvelopeSuccessTrue AccessKeyRotateResponseEnvelopeSuccess = true +) diff --git a/zero_trust/accesskey_test.go b/zero_trust/accesskey_test.go new file mode 100644 index 00000000000..da11af7ae14 --- /dev/null +++ b/zero_trust/accesskey_test.go @@ -0,0 +1,93 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestAccessKeyUpdate(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Keys.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + zero_trust.AccessKeyUpdateParams{ + KeyRotationIntervalDays: cloudflare.F(30.000000), + }, + ) + 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 TestAccessKeyList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Keys.List(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()) + } +} + +func TestAccessKeyRotate(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Keys.Rotate(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/zero_trust/accesslog.go b/zero_trust/accesslog.go new file mode 100644 index 00000000000..9990fd14d14 --- /dev/null +++ b/zero_trust/accesslog.go @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// AccessLogService 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 [NewAccessLogService] method instead. +type AccessLogService struct { + Options []option.RequestOption + AccessRequests *AccessLogAccessRequestService +} + +// NewAccessLogService 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 NewAccessLogService(opts ...option.RequestOption) (r *AccessLogService) { + r = &AccessLogService{} + r.Options = opts + r.AccessRequests = NewAccessLogAccessRequestService(opts...) + return +} diff --git a/zero_trust/accesslogaccessrequest.go b/zero_trust/accesslogaccessrequest.go new file mode 100644 index 00000000000..05edb352561 --- /dev/null +++ b/zero_trust/accesslogaccessrequest.go @@ -0,0 +1,204 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AccessLogAccessRequestService 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 [NewAccessLogAccessRequestService] +// method instead. +type AccessLogAccessRequestService struct { + Options []option.RequestOption +} + +// NewAccessLogAccessRequestService 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 NewAccessLogAccessRequestService(opts ...option.RequestOption) (r *AccessLogAccessRequestService) { + r = &AccessLogAccessRequestService{} + r.Options = opts + return +} + +// Gets a list of Access authentication audit logs for an account. +func (r *AccessLogAccessRequestService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *[]AccessAccessRequests, err error) { + opts = append(r.Options[:], opts...) + var env AccessLogAccessRequestListResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/logs/access_requests", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AccessAccessRequests struct { + // The event that occurred, such as a login attempt. + Action string `json:"action"` + // The result of the authentication event. + Allowed bool `json:"allowed"` + // The URL of the Access application. + AppDomain string `json:"app_domain"` + // The unique identifier for the Access application. + AppUid interface{} `json:"app_uid"` + // The IdP used to authenticate. + Connection string `json:"connection"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The IP address of the authenticating user. + IPAddress string `json:"ip_address"` + // The unique identifier for the request to Cloudflare. + RayID string `json:"ray_id"` + // The email address of the authenticating user. + UserEmail string `json:"user_email" format:"email"` + JSON accessAccessRequestsJSON `json:"-"` +} + +// accessAccessRequestsJSON contains the JSON metadata for the struct +// [AccessAccessRequests] +type accessAccessRequestsJSON struct { + Action apijson.Field + Allowed apijson.Field + AppDomain apijson.Field + AppUid apijson.Field + Connection apijson.Field + CreatedAt apijson.Field + IPAddress apijson.Field + RayID apijson.Field + UserEmail apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessAccessRequests) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessAccessRequestsJSON) RawJSON() string { + return r.raw +} + +type AccessLogAccessRequestListResponseEnvelope struct { + Errors []AccessLogAccessRequestListResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessLogAccessRequestListResponseEnvelopeMessages `json:"messages,required"` + Result []AccessAccessRequests `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessLogAccessRequestListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AccessLogAccessRequestListResponseEnvelopeResultInfo `json:"result_info"` + JSON accessLogAccessRequestListResponseEnvelopeJSON `json:"-"` +} + +// accessLogAccessRequestListResponseEnvelopeJSON contains the JSON metadata for +// the struct [AccessLogAccessRequestListResponseEnvelope] +type accessLogAccessRequestListResponseEnvelopeJSON 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 *AccessLogAccessRequestListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessLogAccessRequestListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessLogAccessRequestListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessLogAccessRequestListResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessLogAccessRequestListResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [AccessLogAccessRequestListResponseEnvelopeErrors] +type accessLogAccessRequestListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessLogAccessRequestListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessLogAccessRequestListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessLogAccessRequestListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessLogAccessRequestListResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessLogAccessRequestListResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [AccessLogAccessRequestListResponseEnvelopeMessages] +type accessLogAccessRequestListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessLogAccessRequestListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessLogAccessRequestListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessLogAccessRequestListResponseEnvelopeSuccess bool + +const ( + AccessLogAccessRequestListResponseEnvelopeSuccessTrue AccessLogAccessRequestListResponseEnvelopeSuccess = true +) + +type AccessLogAccessRequestListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON accessLogAccessRequestListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// accessLogAccessRequestListResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [AccessLogAccessRequestListResponseEnvelopeResultInfo] +type accessLogAccessRequestListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessLogAccessRequestListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessLogAccessRequestListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/accesslogaccessrequest_test.go b/zero_trust/accesslogaccessrequest_test.go new file mode 100644 index 00000000000..e18d9e7528e --- /dev/null +++ b/zero_trust/accesslogaccessrequest_test.go @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestAccessLogAccessRequestList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Logs.AccessRequests.List(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/zero_trust/accessservicetoken.go b/zero_trust/accessservicetoken.go new file mode 100644 index 00000000000..9b601e8983f --- /dev/null +++ b/zero_trust/accessservicetoken.go @@ -0,0 +1,838 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AccessServiceTokenService 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 [NewAccessServiceTokenService] method +// instead. +type AccessServiceTokenService struct { + Options []option.RequestOption +} + +// NewAccessServiceTokenService 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 NewAccessServiceTokenService(opts ...option.RequestOption) (r *AccessServiceTokenService) { + r = &AccessServiceTokenService{} + r.Options = opts + return +} + +// Generates a new service token. **Note:** This is the only time you can get the +// Client Secret. If you lose the Client Secret, you will have to rotate the Client +// Secret or create a new service token. +func (r *AccessServiceTokenService) New(ctx context.Context, params AccessServiceTokenNewParams, opts ...option.RequestOption) (res *AccessServiceTokenNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessServiceTokenNewResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/access/service_tokens", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a configured service token. +func (r *AccessServiceTokenService) Update(ctx context.Context, uuid string, params AccessServiceTokenUpdateParams, opts ...option.RequestOption) (res *AccessServiceTokens, err error) { + opts = append(r.Options[:], opts...) + var env AccessServiceTokenUpdateResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/access/service_tokens/%s", accountOrZone, accountOrZoneID, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists all service tokens. +func (r *AccessServiceTokenService) List(ctx context.Context, query AccessServiceTokenListParams, opts ...option.RequestOption) (res *[]AccessServiceTokens, err error) { + opts = append(r.Options[:], opts...) + var env AccessServiceTokenListResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/access/service_tokens", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a service token. +func (r *AccessServiceTokenService) Delete(ctx context.Context, uuid string, body AccessServiceTokenDeleteParams, opts ...option.RequestOption) (res *AccessServiceTokens, err error) { + opts = append(r.Options[:], opts...) + var env AccessServiceTokenDeleteResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if body.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = body.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = body.ZoneID + } + path := fmt.Sprintf("%s/%s/access/service_tokens/%s", accountOrZone, accountOrZoneID, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Refreshes the expiration of a service token. +func (r *AccessServiceTokenService) Refresh(ctx context.Context, identifier string, uuid string, opts ...option.RequestOption) (res *AccessServiceTokens, err error) { + opts = append(r.Options[:], opts...) + var env AccessServiceTokenRefreshResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/service_tokens/%s/refresh", identifier, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Generates a new Client Secret for a service token and revokes the old one. +func (r *AccessServiceTokenService) Rotate(ctx context.Context, identifier string, uuid string, opts ...option.RequestOption) (res *AccessServiceTokenRotateResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessServiceTokenRotateResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/service_tokens/%s/rotate", identifier, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AccessServiceTokens struct { + // The ID of the service token. + ID interface{} `json:"id"` + // The Client ID for the service token. Access will check for this value in the + // `CF-Access-Client-ID` request header. + ClientID string `json:"client_id"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The duration for how long the service token will be valid. Must be in the format + // `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. The + // default is 1 year in hours (8760h). + Duration string `json:"duration"` + // The name of the service token. + Name string `json:"name"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessServiceTokensJSON `json:"-"` +} + +// accessServiceTokensJSON contains the JSON metadata for the struct +// [AccessServiceTokens] +type accessServiceTokensJSON struct { + ID apijson.Field + ClientID apijson.Field + CreatedAt apijson.Field + Duration apijson.Field + Name apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokens) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokensJSON) RawJSON() string { + return r.raw +} + +type AccessServiceTokenNewResponse struct { + // The ID of the service token. + ID interface{} `json:"id"` + // The Client ID for the service token. Access will check for this value in the + // `CF-Access-Client-ID` request header. + ClientID string `json:"client_id"` + // The Client Secret for the service token. Access will check for this value in the + // `CF-Access-Client-Secret` request header. + ClientSecret string `json:"client_secret"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The duration for how long the service token will be valid. Must be in the format + // `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. The + // default is 1 year in hours (8760h). + Duration string `json:"duration"` + // The name of the service token. + Name string `json:"name"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessServiceTokenNewResponseJSON `json:"-"` +} + +// accessServiceTokenNewResponseJSON contains the JSON metadata for the struct +// [AccessServiceTokenNewResponse] +type accessServiceTokenNewResponseJSON struct { + ID apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + CreatedAt apijson.Field + Duration apijson.Field + Name apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenNewResponseJSON) RawJSON() string { + return r.raw +} + +type AccessServiceTokenRotateResponse struct { + // The ID of the service token. + ID interface{} `json:"id"` + // The Client ID for the service token. Access will check for this value in the + // `CF-Access-Client-ID` request header. + ClientID string `json:"client_id"` + // The Client Secret for the service token. Access will check for this value in the + // `CF-Access-Client-Secret` request header. + ClientSecret string `json:"client_secret"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The duration for how long the service token will be valid. Must be in the format + // `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. The + // default is 1 year in hours (8760h). + Duration string `json:"duration"` + // The name of the service token. + Name string `json:"name"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessServiceTokenRotateResponseJSON `json:"-"` +} + +// accessServiceTokenRotateResponseJSON contains the JSON metadata for the struct +// [AccessServiceTokenRotateResponse] +type accessServiceTokenRotateResponseJSON struct { + ID apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + CreatedAt apijson.Field + Duration apijson.Field + Name apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenRotateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenRotateResponseJSON) RawJSON() string { + return r.raw +} + +type AccessServiceTokenNewParams struct { + // The name of the service token. + Name param.Field[string] `json:"name,required"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // The duration for how long the service token will be valid. Must be in the format + // `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. The + // default is 1 year in hours (8760h). + Duration param.Field[string] `json:"duration"` +} + +func (r AccessServiceTokenNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AccessServiceTokenNewResponseEnvelope struct { + Errors []AccessServiceTokenNewResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessServiceTokenNewResponseEnvelopeMessages `json:"messages,required"` + Result AccessServiceTokenNewResponse `json:"result,required"` + // Whether the API call was successful + Success AccessServiceTokenNewResponseEnvelopeSuccess `json:"success,required"` + JSON accessServiceTokenNewResponseEnvelopeJSON `json:"-"` +} + +// accessServiceTokenNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessServiceTokenNewResponseEnvelope] +type accessServiceTokenNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessServiceTokenNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessServiceTokenNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessServiceTokenNewResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessServiceTokenNewResponseEnvelopeErrors] +type accessServiceTokenNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessServiceTokenNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessServiceTokenNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessServiceTokenNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [AccessServiceTokenNewResponseEnvelopeMessages] +type accessServiceTokenNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessServiceTokenNewResponseEnvelopeSuccess bool + +const ( + AccessServiceTokenNewResponseEnvelopeSuccessTrue AccessServiceTokenNewResponseEnvelopeSuccess = true +) + +type AccessServiceTokenUpdateParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // The duration for how long the service token will be valid. Must be in the format + // `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. The + // default is 1 year in hours (8760h). + Duration param.Field[string] `json:"duration"` + // The name of the service token. + Name param.Field[string] `json:"name"` +} + +func (r AccessServiceTokenUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AccessServiceTokenUpdateResponseEnvelope struct { + Errors []AccessServiceTokenUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessServiceTokenUpdateResponseEnvelopeMessages `json:"messages,required"` + Result AccessServiceTokens `json:"result,required"` + // Whether the API call was successful + Success AccessServiceTokenUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON accessServiceTokenUpdateResponseEnvelopeJSON `json:"-"` +} + +// accessServiceTokenUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessServiceTokenUpdateResponseEnvelope] +type accessServiceTokenUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessServiceTokenUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessServiceTokenUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessServiceTokenUpdateResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [AccessServiceTokenUpdateResponseEnvelopeErrors] +type accessServiceTokenUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessServiceTokenUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessServiceTokenUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessServiceTokenUpdateResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AccessServiceTokenUpdateResponseEnvelopeMessages] +type accessServiceTokenUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessServiceTokenUpdateResponseEnvelopeSuccess bool + +const ( + AccessServiceTokenUpdateResponseEnvelopeSuccessTrue AccessServiceTokenUpdateResponseEnvelopeSuccess = true +) + +type AccessServiceTokenListParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessServiceTokenListResponseEnvelope struct { + Errors []AccessServiceTokenListResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessServiceTokenListResponseEnvelopeMessages `json:"messages,required"` + Result []AccessServiceTokens `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessServiceTokenListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AccessServiceTokenListResponseEnvelopeResultInfo `json:"result_info"` + JSON accessServiceTokenListResponseEnvelopeJSON `json:"-"` +} + +// accessServiceTokenListResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessServiceTokenListResponseEnvelope] +type accessServiceTokenListResponseEnvelopeJSON 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 *AccessServiceTokenListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessServiceTokenListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessServiceTokenListResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessServiceTokenListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [AccessServiceTokenListResponseEnvelopeErrors] +type accessServiceTokenListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessServiceTokenListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessServiceTokenListResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessServiceTokenListResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AccessServiceTokenListResponseEnvelopeMessages] +type accessServiceTokenListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessServiceTokenListResponseEnvelopeSuccess bool + +const ( + AccessServiceTokenListResponseEnvelopeSuccessTrue AccessServiceTokenListResponseEnvelopeSuccess = true +) + +type AccessServiceTokenListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON accessServiceTokenListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// accessServiceTokenListResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [AccessServiceTokenListResponseEnvelopeResultInfo] +type accessServiceTokenListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type AccessServiceTokenDeleteParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type AccessServiceTokenDeleteResponseEnvelope struct { + Errors []AccessServiceTokenDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessServiceTokenDeleteResponseEnvelopeMessages `json:"messages,required"` + Result AccessServiceTokens `json:"result,required"` + // Whether the API call was successful + Success AccessServiceTokenDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON accessServiceTokenDeleteResponseEnvelopeJSON `json:"-"` +} + +// accessServiceTokenDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessServiceTokenDeleteResponseEnvelope] +type accessServiceTokenDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessServiceTokenDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessServiceTokenDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessServiceTokenDeleteResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [AccessServiceTokenDeleteResponseEnvelopeErrors] +type accessServiceTokenDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessServiceTokenDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessServiceTokenDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessServiceTokenDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AccessServiceTokenDeleteResponseEnvelopeMessages] +type accessServiceTokenDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessServiceTokenDeleteResponseEnvelopeSuccess bool + +const ( + AccessServiceTokenDeleteResponseEnvelopeSuccessTrue AccessServiceTokenDeleteResponseEnvelopeSuccess = true +) + +type AccessServiceTokenRefreshResponseEnvelope struct { + Errors []AccessServiceTokenRefreshResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessServiceTokenRefreshResponseEnvelopeMessages `json:"messages,required"` + Result AccessServiceTokens `json:"result,required"` + // Whether the API call was successful + Success AccessServiceTokenRefreshResponseEnvelopeSuccess `json:"success,required"` + JSON accessServiceTokenRefreshResponseEnvelopeJSON `json:"-"` +} + +// accessServiceTokenRefreshResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessServiceTokenRefreshResponseEnvelope] +type accessServiceTokenRefreshResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenRefreshResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenRefreshResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessServiceTokenRefreshResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessServiceTokenRefreshResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessServiceTokenRefreshResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [AccessServiceTokenRefreshResponseEnvelopeErrors] +type accessServiceTokenRefreshResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenRefreshResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenRefreshResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessServiceTokenRefreshResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessServiceTokenRefreshResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessServiceTokenRefreshResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AccessServiceTokenRefreshResponseEnvelopeMessages] +type accessServiceTokenRefreshResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenRefreshResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenRefreshResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessServiceTokenRefreshResponseEnvelopeSuccess bool + +const ( + AccessServiceTokenRefreshResponseEnvelopeSuccessTrue AccessServiceTokenRefreshResponseEnvelopeSuccess = true +) + +type AccessServiceTokenRotateResponseEnvelope struct { + Errors []AccessServiceTokenRotateResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessServiceTokenRotateResponseEnvelopeMessages `json:"messages,required"` + Result AccessServiceTokenRotateResponse `json:"result,required"` + // Whether the API call was successful + Success AccessServiceTokenRotateResponseEnvelopeSuccess `json:"success,required"` + JSON accessServiceTokenRotateResponseEnvelopeJSON `json:"-"` +} + +// accessServiceTokenRotateResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessServiceTokenRotateResponseEnvelope] +type accessServiceTokenRotateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenRotateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenRotateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessServiceTokenRotateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessServiceTokenRotateResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessServiceTokenRotateResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [AccessServiceTokenRotateResponseEnvelopeErrors] +type accessServiceTokenRotateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenRotateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenRotateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessServiceTokenRotateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessServiceTokenRotateResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessServiceTokenRotateResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AccessServiceTokenRotateResponseEnvelopeMessages] +type accessServiceTokenRotateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessServiceTokenRotateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessServiceTokenRotateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessServiceTokenRotateResponseEnvelopeSuccess bool + +const ( + AccessServiceTokenRotateResponseEnvelopeSuccessTrue AccessServiceTokenRotateResponseEnvelopeSuccess = true +) diff --git a/zero_trust/accessservicetoken_test.go b/zero_trust/accessservicetoken_test.go new file mode 100644 index 00000000000..2ddda02d67d --- /dev/null +++ b/zero_trust/accessservicetoken_test.go @@ -0,0 +1,191 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestAccessServiceTokenNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.ServiceTokens.New(context.TODO(), zero_trust.AccessServiceTokenNewParams{ + Name: cloudflare.F("CI/CD token"), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + Duration: cloudflare.F("60m"), + }) + 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 TestAccessServiceTokenUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.ServiceTokens.Update( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessServiceTokenUpdateParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + Duration: cloudflare.F("60m"), + Name: cloudflare.F("CI/CD token"), + }, + ) + 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 TestAccessServiceTokenListWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.ServiceTokens.List(context.TODO(), zero_trust.AccessServiceTokenListParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }) + 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 TestAccessServiceTokenDeleteWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.ServiceTokens.Delete( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.AccessServiceTokenDeleteParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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 TestAccessServiceTokenRefresh(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.ServiceTokens.Refresh( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + 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 TestAccessServiceTokenRotate(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.ServiceTokens.Rotate( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + 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/zero_trust/accesstag.go b/zero_trust/accesstag.go new file mode 100644 index 00000000000..b0e292b8ad0 --- /dev/null +++ b/zero_trust/accesstag.go @@ -0,0 +1,607 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AccessTagService 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 [NewAccessTagService] method instead. +type AccessTagService struct { + Options []option.RequestOption +} + +// NewAccessTagService 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 NewAccessTagService(opts ...option.RequestOption) (r *AccessTagService) { + r = &AccessTagService{} + r.Options = opts + return +} + +// Create a tag +func (r *AccessTagService) New(ctx context.Context, identifier string, body AccessTagNewParams, opts ...option.RequestOption) (res *AccessTag, err error) { + opts = append(r.Options[:], opts...) + var env AccessTagNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/tags", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update a tag +func (r *AccessTagService) Update(ctx context.Context, identifier string, tagName string, body AccessTagUpdateParams, opts ...option.RequestOption) (res *AccessTag, err error) { + opts = append(r.Options[:], opts...) + var env AccessTagUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/tags/%s", identifier, tagName) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// List tags +func (r *AccessTagService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *[]AccessTag, err error) { + opts = append(r.Options[:], opts...) + var env AccessTagListResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/tags", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a tag +func (r *AccessTagService) Delete(ctx context.Context, identifier string, name string, opts ...option.RequestOption) (res *AccessTagDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessTagDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/tags/%s", identifier, name) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a tag +func (r *AccessTagService) Get(ctx context.Context, identifier string, name string, opts ...option.RequestOption) (res *AccessTag, err error) { + opts = append(r.Options[:], opts...) + var env AccessTagGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/tags/%s", identifier, name) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// A tag +type AccessTag struct { + // The name of the tag + Name string `json:"name,required"` + // The number of applications that have this tag + AppCount int64 `json:"app_count"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessTagJSON `json:"-"` +} + +// accessTagJSON contains the JSON metadata for the struct [AccessTag] +type accessTagJSON struct { + Name apijson.Field + AppCount apijson.Field + CreatedAt apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessTag) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessTagJSON) RawJSON() string { + return r.raw +} + +type AccessTagDeleteResponse struct { + // The name of the tag + Name string `json:"name"` + JSON accessTagDeleteResponseJSON `json:"-"` +} + +// accessTagDeleteResponseJSON contains the JSON metadata for the struct +// [AccessTagDeleteResponse] +type accessTagDeleteResponseJSON struct { + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessTagDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessTagDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type AccessTagNewParams struct { + // The name of the tag + Name param.Field[string] `json:"name,required"` +} + +func (r AccessTagNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AccessTagNewResponseEnvelope struct { + Errors []AccessTagNewResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessTagNewResponseEnvelopeMessages `json:"messages,required"` + // A tag + Result AccessTag `json:"result,required"` + // Whether the API call was successful + Success AccessTagNewResponseEnvelopeSuccess `json:"success,required"` + JSON accessTagNewResponseEnvelopeJSON `json:"-"` +} + +// accessTagNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessTagNewResponseEnvelope] +type accessTagNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessTagNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessTagNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessTagNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessTagNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessTagNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [AccessTagNewResponseEnvelopeErrors] +type accessTagNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessTagNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessTagNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessTagNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessTagNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessTagNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessTagNewResponseEnvelopeMessages] +type accessTagNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessTagNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessTagNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessTagNewResponseEnvelopeSuccess bool + +const ( + AccessTagNewResponseEnvelopeSuccessTrue AccessTagNewResponseEnvelopeSuccess = true +) + +type AccessTagUpdateParams struct { + // The name of the tag + Name param.Field[string] `json:"name,required"` +} + +func (r AccessTagUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type AccessTagUpdateResponseEnvelope struct { + Errors []AccessTagUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessTagUpdateResponseEnvelopeMessages `json:"messages,required"` + // A tag + Result AccessTag `json:"result,required"` + // Whether the API call was successful + Success AccessTagUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON accessTagUpdateResponseEnvelopeJSON `json:"-"` +} + +// accessTagUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessTagUpdateResponseEnvelope] +type accessTagUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessTagUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessTagUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessTagUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessTagUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessTagUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessTagUpdateResponseEnvelopeErrors] +type accessTagUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessTagUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessTagUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessTagUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessTagUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessTagUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessTagUpdateResponseEnvelopeMessages] +type accessTagUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessTagUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessTagUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessTagUpdateResponseEnvelopeSuccess bool + +const ( + AccessTagUpdateResponseEnvelopeSuccessTrue AccessTagUpdateResponseEnvelopeSuccess = true +) + +type AccessTagListResponseEnvelope struct { + Errors []AccessTagListResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessTagListResponseEnvelopeMessages `json:"messages,required"` + Result []AccessTag `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessTagListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AccessTagListResponseEnvelopeResultInfo `json:"result_info"` + JSON accessTagListResponseEnvelopeJSON `json:"-"` +} + +// accessTagListResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessTagListResponseEnvelope] +type accessTagListResponseEnvelopeJSON 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 *AccessTagListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessTagListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessTagListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessTagListResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessTagListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessTagListResponseEnvelopeErrors] +type accessTagListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessTagListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessTagListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessTagListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessTagListResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessTagListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessTagListResponseEnvelopeMessages] +type accessTagListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessTagListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessTagListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessTagListResponseEnvelopeSuccess bool + +const ( + AccessTagListResponseEnvelopeSuccessTrue AccessTagListResponseEnvelopeSuccess = true +) + +type AccessTagListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON accessTagListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// accessTagListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [AccessTagListResponseEnvelopeResultInfo] +type accessTagListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessTagListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessTagListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type AccessTagDeleteResponseEnvelope struct { + Errors []AccessTagDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessTagDeleteResponseEnvelopeMessages `json:"messages,required"` + Result AccessTagDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success AccessTagDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON accessTagDeleteResponseEnvelopeJSON `json:"-"` +} + +// accessTagDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessTagDeleteResponseEnvelope] +type accessTagDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessTagDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessTagDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessTagDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessTagDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessTagDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessTagDeleteResponseEnvelopeErrors] +type accessTagDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessTagDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessTagDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessTagDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessTagDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessTagDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessTagDeleteResponseEnvelopeMessages] +type accessTagDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessTagDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessTagDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessTagDeleteResponseEnvelopeSuccess bool + +const ( + AccessTagDeleteResponseEnvelopeSuccessTrue AccessTagDeleteResponseEnvelopeSuccess = true +) + +type AccessTagGetResponseEnvelope struct { + Errors []AccessTagGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessTagGetResponseEnvelopeMessages `json:"messages,required"` + // A tag + Result AccessTag `json:"result,required"` + // Whether the API call was successful + Success AccessTagGetResponseEnvelopeSuccess `json:"success,required"` + JSON accessTagGetResponseEnvelopeJSON `json:"-"` +} + +// accessTagGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessTagGetResponseEnvelope] +type accessTagGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessTagGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessTagGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessTagGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessTagGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessTagGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [AccessTagGetResponseEnvelopeErrors] +type accessTagGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessTagGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessTagGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessTagGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessTagGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessTagGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessTagGetResponseEnvelopeMessages] +type accessTagGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessTagGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessTagGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessTagGetResponseEnvelopeSuccess bool + +const ( + AccessTagGetResponseEnvelopeSuccessTrue AccessTagGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/accesstag_test.go b/zero_trust/accesstag_test.go new file mode 100644 index 00000000000..833871bc8b1 --- /dev/null +++ b/zero_trust/accesstag_test.go @@ -0,0 +1,156 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestAccessTagNew(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Tags.New( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + zero_trust.AccessTagNewParams{ + Name: cloudflare.F("engineers"), + }, + ) + 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 TestAccessTagUpdate(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Tags.Update( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "engineers", + zero_trust.AccessTagUpdateParams{ + Name: cloudflare.F("engineers"), + }, + ) + 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 TestAccessTagList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Tags.List(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()) + } +} + +func TestAccessTagDelete(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Tags.Delete( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "engineers", + ) + 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 TestAccessTagGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Tags.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "engineers", + ) + 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/zero_trust/accessuser.go b/zero_trust/accessuser.go new file mode 100644 index 00000000000..4d36d1a7539 --- /dev/null +++ b/zero_trust/accessuser.go @@ -0,0 +1,213 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AccessUserService 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 [NewAccessUserService] method instead. +type AccessUserService struct { + Options []option.RequestOption + ActiveSessions *AccessUserActiveSessionService + LastSeenIdentity *AccessUserLastSeenIdentityService + FailedLogins *AccessUserFailedLoginService +} + +// NewAccessUserService 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 NewAccessUserService(opts ...option.RequestOption) (r *AccessUserService) { + r = &AccessUserService{} + r.Options = opts + r.ActiveSessions = NewAccessUserActiveSessionService(opts...) + r.LastSeenIdentity = NewAccessUserLastSeenIdentityService(opts...) + r.FailedLogins = NewAccessUserFailedLoginService(opts...) + return +} + +// Gets a list of users for an account. +func (r *AccessUserService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *[]AccessUsers, err error) { + opts = append(r.Options[:], opts...) + var env AccessUserListResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/users", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AccessUsers struct { + // UUID + ID string `json:"id"` + // True if the user has authenticated with Cloudflare Access. + AccessSeat bool `json:"access_seat"` + // The number of active devices registered to the user. + ActiveDeviceCount float64 `json:"active_device_count"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The email of the user. + Email string `json:"email" format:"email"` + // True if the user has logged into the WARP client. + GatewaySeat bool `json:"gateway_seat"` + // The time at which the user last successfully logged in. + LastSuccessfulLogin time.Time `json:"last_successful_login" format:"date-time"` + // The name of the user. + Name string `json:"name"` + // The unique API identifier for the Zero Trust seat. + SeatUid interface{} `json:"seat_uid"` + // The unique API identifier for the user. + Uid interface{} `json:"uid"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessUsersJSON `json:"-"` +} + +// accessUsersJSON contains the JSON metadata for the struct [AccessUsers] +type accessUsersJSON struct { + ID apijson.Field + AccessSeat apijson.Field + ActiveDeviceCount apijson.Field + CreatedAt apijson.Field + Email apijson.Field + GatewaySeat apijson.Field + LastSuccessfulLogin apijson.Field + Name apijson.Field + SeatUid apijson.Field + Uid apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUsers) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUsersJSON) RawJSON() string { + return r.raw +} + +type AccessUserListResponseEnvelope struct { + Errors []AccessUserListResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessUserListResponseEnvelopeMessages `json:"messages,required"` + Result []AccessUsers `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessUserListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AccessUserListResponseEnvelopeResultInfo `json:"result_info"` + JSON accessUserListResponseEnvelopeJSON `json:"-"` +} + +// accessUserListResponseEnvelopeJSON contains the JSON metadata for the struct +// [AccessUserListResponseEnvelope] +type accessUserListResponseEnvelopeJSON 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 *AccessUserListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessUserListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessUserListResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessUserListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [AccessUserListResponseEnvelopeErrors] +type accessUserListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessUserListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessUserListResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessUserListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [AccessUserListResponseEnvelopeMessages] +type accessUserListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessUserListResponseEnvelopeSuccess bool + +const ( + AccessUserListResponseEnvelopeSuccessTrue AccessUserListResponseEnvelopeSuccess = true +) + +type AccessUserListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON accessUserListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// accessUserListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [AccessUserListResponseEnvelopeResultInfo] +type accessUserListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/accessuser_test.go b/zero_trust/accessuser_test.go new file mode 100644 index 00000000000..7fedbb0ac49 --- /dev/null +++ b/zero_trust/accessuser_test.go @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestAccessUserList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Users.List(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/zero_trust/accessuseractivesession.go b/zero_trust/accessuseractivesession.go new file mode 100644 index 00000000000..cffa548c4f9 --- /dev/null +++ b/zero_trust/accessuseractivesession.go @@ -0,0 +1,544 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AccessUserActiveSessionService 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 +// [NewAccessUserActiveSessionService] method instead. +type AccessUserActiveSessionService struct { + Options []option.RequestOption +} + +// NewAccessUserActiveSessionService 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 NewAccessUserActiveSessionService(opts ...option.RequestOption) (r *AccessUserActiveSessionService) { + r = &AccessUserActiveSessionService{} + r.Options = opts + return +} + +// Get active sessions for a single user. +func (r *AccessUserActiveSessionService) List(ctx context.Context, identifier string, id string, opts ...option.RequestOption) (res *[]AccessUserActiveSessionListResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessUserActiveSessionListResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/users/%s/active_sessions", identifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get an active session for a single user. +func (r *AccessUserActiveSessionService) Get(ctx context.Context, identifier string, id string, nonce string, opts ...option.RequestOption) (res *AccessUserActiveSessionGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessUserActiveSessionGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/users/%s/active_sessions/%s", identifier, id, nonce) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AccessUserActiveSessionListResponse struct { + Expiration int64 `json:"expiration"` + Metadata AccessUserActiveSessionListResponseMetadata `json:"metadata"` + Name string `json:"name"` + JSON accessUserActiveSessionListResponseJSON `json:"-"` +} + +// accessUserActiveSessionListResponseJSON contains the JSON metadata for the +// struct [AccessUserActiveSessionListResponse] +type accessUserActiveSessionListResponseJSON struct { + Expiration apijson.Field + Metadata apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserActiveSessionListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserActiveSessionListResponseJSON) RawJSON() string { + return r.raw +} + +type AccessUserActiveSessionListResponseMetadata struct { + Apps map[string]AccessUserActiveSessionListResponseMetadataApp `json:"apps"` + Expires int64 `json:"expires"` + Iat int64 `json:"iat"` + Nonce string `json:"nonce"` + TTL int64 `json:"ttl"` + JSON accessUserActiveSessionListResponseMetadataJSON `json:"-"` +} + +// accessUserActiveSessionListResponseMetadataJSON contains the JSON metadata for +// the struct [AccessUserActiveSessionListResponseMetadata] +type accessUserActiveSessionListResponseMetadataJSON struct { + Apps apijson.Field + Expires apijson.Field + Iat apijson.Field + Nonce apijson.Field + TTL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserActiveSessionListResponseMetadata) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserActiveSessionListResponseMetadataJSON) RawJSON() string { + return r.raw +} + +type AccessUserActiveSessionListResponseMetadataApp struct { + Hostname string `json:"hostname"` + Name string `json:"name"` + Type string `json:"type"` + Uid string `json:"uid"` + JSON accessUserActiveSessionListResponseMetadataAppJSON `json:"-"` +} + +// accessUserActiveSessionListResponseMetadataAppJSON contains the JSON metadata +// for the struct [AccessUserActiveSessionListResponseMetadataApp] +type accessUserActiveSessionListResponseMetadataAppJSON struct { + Hostname apijson.Field + Name apijson.Field + Type apijson.Field + Uid apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserActiveSessionListResponseMetadataApp) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserActiveSessionListResponseMetadataAppJSON) RawJSON() string { + return r.raw +} + +type AccessUserActiveSessionGetResponse struct { + AccountID string `json:"account_id"` + AuthStatus string `json:"auth_status"` + CommonName string `json:"common_name"` + DeviceID string `json:"device_id"` + DeviceSessions map[string]AccessUserActiveSessionGetResponseDeviceSession `json:"device_sessions"` + DevicePosture map[string]AccessUserActiveSessionGetResponseDevicePosture `json:"devicePosture"` + Email string `json:"email"` + Geo AccessUserActiveSessionGetResponseGeo `json:"geo"` + Iat float64 `json:"iat"` + Idp AccessUserActiveSessionGetResponseIdp `json:"idp"` + IP string `json:"ip"` + IsGateway bool `json:"is_gateway"` + IsWARP bool `json:"is_warp"` + IsActive bool `json:"isActive"` + MTLSAuth AccessUserActiveSessionGetResponseMTLSAuth `json:"mtls_auth"` + ServiceTokenID string `json:"service_token_id"` + ServiceTokenStatus bool `json:"service_token_status"` + UserUUID string `json:"user_uuid"` + Version float64 `json:"version"` + JSON accessUserActiveSessionGetResponseJSON `json:"-"` +} + +// accessUserActiveSessionGetResponseJSON contains the JSON metadata for the struct +// [AccessUserActiveSessionGetResponse] +type accessUserActiveSessionGetResponseJSON struct { + AccountID apijson.Field + AuthStatus apijson.Field + CommonName apijson.Field + DeviceID apijson.Field + DeviceSessions apijson.Field + DevicePosture apijson.Field + Email apijson.Field + Geo apijson.Field + Iat apijson.Field + Idp apijson.Field + IP apijson.Field + IsGateway apijson.Field + IsWARP apijson.Field + IsActive apijson.Field + MTLSAuth apijson.Field + ServiceTokenID apijson.Field + ServiceTokenStatus apijson.Field + UserUUID apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserActiveSessionGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserActiveSessionGetResponseJSON) RawJSON() string { + return r.raw +} + +type AccessUserActiveSessionGetResponseDeviceSession struct { + LastAuthenticated float64 `json:"last_authenticated"` + JSON accessUserActiveSessionGetResponseDeviceSessionJSON `json:"-"` +} + +// accessUserActiveSessionGetResponseDeviceSessionJSON contains the JSON metadata +// for the struct [AccessUserActiveSessionGetResponseDeviceSession] +type accessUserActiveSessionGetResponseDeviceSessionJSON struct { + LastAuthenticated apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserActiveSessionGetResponseDeviceSession) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserActiveSessionGetResponseDeviceSessionJSON) RawJSON() string { + return r.raw +} + +type AccessUserActiveSessionGetResponseDevicePosture struct { + ID string `json:"id"` + Check AccessUserActiveSessionGetResponseDevicePostureCheck `json:"check"` + Data interface{} `json:"data"` + Description string `json:"description"` + Error string `json:"error"` + RuleName string `json:"rule_name"` + Success bool `json:"success"` + Timestamp string `json:"timestamp"` + Type string `json:"type"` + JSON accessUserActiveSessionGetResponseDevicePostureJSON `json:"-"` +} + +// accessUserActiveSessionGetResponseDevicePostureJSON contains the JSON metadata +// for the struct [AccessUserActiveSessionGetResponseDevicePosture] +type accessUserActiveSessionGetResponseDevicePostureJSON struct { + ID apijson.Field + Check apijson.Field + Data apijson.Field + Description apijson.Field + Error apijson.Field + RuleName apijson.Field + Success apijson.Field + Timestamp apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserActiveSessionGetResponseDevicePosture) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserActiveSessionGetResponseDevicePostureJSON) RawJSON() string { + return r.raw +} + +type AccessUserActiveSessionGetResponseDevicePostureCheck struct { + Exists bool `json:"exists"` + Path string `json:"path"` + JSON accessUserActiveSessionGetResponseDevicePostureCheckJSON `json:"-"` +} + +// accessUserActiveSessionGetResponseDevicePostureCheckJSON contains the JSON +// metadata for the struct [AccessUserActiveSessionGetResponseDevicePostureCheck] +type accessUserActiveSessionGetResponseDevicePostureCheckJSON struct { + Exists apijson.Field + Path apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserActiveSessionGetResponseDevicePostureCheck) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserActiveSessionGetResponseDevicePostureCheckJSON) RawJSON() string { + return r.raw +} + +type AccessUserActiveSessionGetResponseGeo struct { + Country string `json:"country"` + JSON accessUserActiveSessionGetResponseGeoJSON `json:"-"` +} + +// accessUserActiveSessionGetResponseGeoJSON contains the JSON metadata for the +// struct [AccessUserActiveSessionGetResponseGeo] +type accessUserActiveSessionGetResponseGeoJSON struct { + Country apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserActiveSessionGetResponseGeo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserActiveSessionGetResponseGeoJSON) RawJSON() string { + return r.raw +} + +type AccessUserActiveSessionGetResponseIdp struct { + ID string `json:"id"` + Type string `json:"type"` + JSON accessUserActiveSessionGetResponseIdpJSON `json:"-"` +} + +// accessUserActiveSessionGetResponseIdpJSON contains the JSON metadata for the +// struct [AccessUserActiveSessionGetResponseIdp] +type accessUserActiveSessionGetResponseIdpJSON struct { + ID apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserActiveSessionGetResponseIdp) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserActiveSessionGetResponseIdpJSON) RawJSON() string { + return r.raw +} + +type AccessUserActiveSessionGetResponseMTLSAuth struct { + AuthStatus string `json:"auth_status"` + CertIssuerDn string `json:"cert_issuer_dn"` + CertIssuerSki string `json:"cert_issuer_ski"` + CertPresented bool `json:"cert_presented"` + CertSerial string `json:"cert_serial"` + JSON accessUserActiveSessionGetResponseMTLSAuthJSON `json:"-"` +} + +// accessUserActiveSessionGetResponseMTLSAuthJSON contains the JSON metadata for +// the struct [AccessUserActiveSessionGetResponseMTLSAuth] +type accessUserActiveSessionGetResponseMTLSAuthJSON struct { + AuthStatus apijson.Field + CertIssuerDn apijson.Field + CertIssuerSki apijson.Field + CertPresented apijson.Field + CertSerial apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserActiveSessionGetResponseMTLSAuth) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserActiveSessionGetResponseMTLSAuthJSON) RawJSON() string { + return r.raw +} + +type AccessUserActiveSessionListResponseEnvelope struct { + Errors []AccessUserActiveSessionListResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessUserActiveSessionListResponseEnvelopeMessages `json:"messages,required"` + Result []AccessUserActiveSessionListResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessUserActiveSessionListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AccessUserActiveSessionListResponseEnvelopeResultInfo `json:"result_info"` + JSON accessUserActiveSessionListResponseEnvelopeJSON `json:"-"` +} + +// accessUserActiveSessionListResponseEnvelopeJSON contains the JSON metadata for +// the struct [AccessUserActiveSessionListResponseEnvelope] +type accessUserActiveSessionListResponseEnvelopeJSON 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 *AccessUserActiveSessionListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserActiveSessionListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessUserActiveSessionListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessUserActiveSessionListResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessUserActiveSessionListResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [AccessUserActiveSessionListResponseEnvelopeErrors] +type accessUserActiveSessionListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserActiveSessionListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserActiveSessionListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessUserActiveSessionListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessUserActiveSessionListResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessUserActiveSessionListResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [AccessUserActiveSessionListResponseEnvelopeMessages] +type accessUserActiveSessionListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserActiveSessionListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserActiveSessionListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessUserActiveSessionListResponseEnvelopeSuccess bool + +const ( + AccessUserActiveSessionListResponseEnvelopeSuccessTrue AccessUserActiveSessionListResponseEnvelopeSuccess = true +) + +type AccessUserActiveSessionListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON accessUserActiveSessionListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// accessUserActiveSessionListResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [AccessUserActiveSessionListResponseEnvelopeResultInfo] +type accessUserActiveSessionListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserActiveSessionListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserActiveSessionListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type AccessUserActiveSessionGetResponseEnvelope struct { + Errors []AccessUserActiveSessionGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessUserActiveSessionGetResponseEnvelopeMessages `json:"messages,required"` + Result AccessUserActiveSessionGetResponse `json:"result,required"` + // Whether the API call was successful + Success AccessUserActiveSessionGetResponseEnvelopeSuccess `json:"success,required"` + JSON accessUserActiveSessionGetResponseEnvelopeJSON `json:"-"` +} + +// accessUserActiveSessionGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [AccessUserActiveSessionGetResponseEnvelope] +type accessUserActiveSessionGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserActiveSessionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserActiveSessionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessUserActiveSessionGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessUserActiveSessionGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessUserActiveSessionGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [AccessUserActiveSessionGetResponseEnvelopeErrors] +type accessUserActiveSessionGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserActiveSessionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserActiveSessionGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessUserActiveSessionGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessUserActiveSessionGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessUserActiveSessionGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [AccessUserActiveSessionGetResponseEnvelopeMessages] +type accessUserActiveSessionGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserActiveSessionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserActiveSessionGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessUserActiveSessionGetResponseEnvelopeSuccess bool + +const ( + AccessUserActiveSessionGetResponseEnvelopeSuccessTrue AccessUserActiveSessionGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/accessuseractivesession_test.go b/zero_trust/accessuseractivesession_test.go new file mode 100644 index 00000000000..70e6a3e3038 --- /dev/null +++ b/zero_trust/accessuseractivesession_test.go @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestAccessUserActiveSessionList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Users.ActiveSessions.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + 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 TestAccessUserActiveSessionGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Users.ActiveSessions.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + "X1aXj1lFVcqqyoXF", + ) + 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/zero_trust/accessuserfailedlogin.go b/zero_trust/accessuserfailedlogin.go new file mode 100644 index 00000000000..365688e145a --- /dev/null +++ b/zero_trust/accessuserfailedlogin.go @@ -0,0 +1,181 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AccessUserFailedLoginService 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 [NewAccessUserFailedLoginService] +// method instead. +type AccessUserFailedLoginService struct { + Options []option.RequestOption +} + +// NewAccessUserFailedLoginService 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 NewAccessUserFailedLoginService(opts ...option.RequestOption) (r *AccessUserFailedLoginService) { + r = &AccessUserFailedLoginService{} + r.Options = opts + return +} + +// Get all failed login attempts for a single user. +func (r *AccessUserFailedLoginService) List(ctx context.Context, identifier string, id string, opts ...option.RequestOption) (res *[]AccessUserFailedLoginListResponse, err error) { + opts = append(r.Options[:], opts...) + var env AccessUserFailedLoginListResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/users/%s/failed_logins", identifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AccessUserFailedLoginListResponse struct { + Expiration int64 `json:"expiration"` + Metadata interface{} `json:"metadata"` + JSON accessUserFailedLoginListResponseJSON `json:"-"` +} + +// accessUserFailedLoginListResponseJSON contains the JSON metadata for the struct +// [AccessUserFailedLoginListResponse] +type accessUserFailedLoginListResponseJSON struct { + Expiration apijson.Field + Metadata apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserFailedLoginListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserFailedLoginListResponseJSON) RawJSON() string { + return r.raw +} + +type AccessUserFailedLoginListResponseEnvelope struct { + Errors []AccessUserFailedLoginListResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessUserFailedLoginListResponseEnvelopeMessages `json:"messages,required"` + Result []AccessUserFailedLoginListResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success AccessUserFailedLoginListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo AccessUserFailedLoginListResponseEnvelopeResultInfo `json:"result_info"` + JSON accessUserFailedLoginListResponseEnvelopeJSON `json:"-"` +} + +// accessUserFailedLoginListResponseEnvelopeJSON contains the JSON metadata for the +// struct [AccessUserFailedLoginListResponseEnvelope] +type accessUserFailedLoginListResponseEnvelopeJSON 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 *AccessUserFailedLoginListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserFailedLoginListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessUserFailedLoginListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessUserFailedLoginListResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessUserFailedLoginListResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [AccessUserFailedLoginListResponseEnvelopeErrors] +type accessUserFailedLoginListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserFailedLoginListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserFailedLoginListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessUserFailedLoginListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessUserFailedLoginListResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessUserFailedLoginListResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [AccessUserFailedLoginListResponseEnvelopeMessages] +type accessUserFailedLoginListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserFailedLoginListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserFailedLoginListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessUserFailedLoginListResponseEnvelopeSuccess bool + +const ( + AccessUserFailedLoginListResponseEnvelopeSuccessTrue AccessUserFailedLoginListResponseEnvelopeSuccess = true +) + +type AccessUserFailedLoginListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON accessUserFailedLoginListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// accessUserFailedLoginListResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [AccessUserFailedLoginListResponseEnvelopeResultInfo] +type accessUserFailedLoginListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserFailedLoginListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserFailedLoginListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/accessuserfailedlogin_test.go b/zero_trust/accessuserfailedlogin_test.go new file mode 100644 index 00000000000..9a841640dd6 --- /dev/null +++ b/zero_trust/accessuserfailedlogin_test.go @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestAccessUserFailedLoginList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Users.FailedLogins.List( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + 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/zero_trust/accessuserlastseenidentity.go b/zero_trust/accessuserlastseenidentity.go new file mode 100644 index 00000000000..6812a22a33a --- /dev/null +++ b/zero_trust/accessuserlastseenidentity.go @@ -0,0 +1,333 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// AccessUserLastSeenIdentityService 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 +// [NewAccessUserLastSeenIdentityService] method instead. +type AccessUserLastSeenIdentityService struct { + Options []option.RequestOption +} + +// NewAccessUserLastSeenIdentityService 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 NewAccessUserLastSeenIdentityService(opts ...option.RequestOption) (r *AccessUserLastSeenIdentityService) { + r = &AccessUserLastSeenIdentityService{} + r.Options = opts + return +} + +// Get last seen identity for a single user. +func (r *AccessUserLastSeenIdentityService) Get(ctx context.Context, identifier string, id string, opts ...option.RequestOption) (res *AccessIdentity, err error) { + opts = append(r.Options[:], opts...) + var env AccessUserLastSeenIdentityGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/users/%s/last_seen_identity", identifier, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AccessIdentity struct { + AccountID string `json:"account_id"` + AuthStatus string `json:"auth_status"` + CommonName string `json:"common_name"` + DeviceID string `json:"device_id"` + DeviceSessions map[string]AccessIdentityDeviceSession `json:"device_sessions"` + DevicePosture map[string]AccessIdentityDevicePosture `json:"devicePosture"` + Email string `json:"email"` + Geo AccessIdentityGeo `json:"geo"` + Iat float64 `json:"iat"` + Idp AccessIdentityIdp `json:"idp"` + IP string `json:"ip"` + IsGateway bool `json:"is_gateway"` + IsWARP bool `json:"is_warp"` + MTLSAuth AccessIdentityMTLSAuth `json:"mtls_auth"` + ServiceTokenID string `json:"service_token_id"` + ServiceTokenStatus bool `json:"service_token_status"` + UserUUID string `json:"user_uuid"` + Version float64 `json:"version"` + JSON accessIdentityJSON `json:"-"` +} + +// accessIdentityJSON contains the JSON metadata for the struct [AccessIdentity] +type accessIdentityJSON struct { + AccountID apijson.Field + AuthStatus apijson.Field + CommonName apijson.Field + DeviceID apijson.Field + DeviceSessions apijson.Field + DevicePosture apijson.Field + Email apijson.Field + Geo apijson.Field + Iat apijson.Field + Idp apijson.Field + IP apijson.Field + IsGateway apijson.Field + IsWARP apijson.Field + MTLSAuth apijson.Field + ServiceTokenID apijson.Field + ServiceTokenStatus apijson.Field + UserUUID apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentity) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityDeviceSession struct { + LastAuthenticated float64 `json:"last_authenticated"` + JSON accessIdentityDeviceSessionJSON `json:"-"` +} + +// accessIdentityDeviceSessionJSON contains the JSON metadata for the struct +// [AccessIdentityDeviceSession] +type accessIdentityDeviceSessionJSON struct { + LastAuthenticated apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityDeviceSession) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityDeviceSessionJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityDevicePosture struct { + ID string `json:"id"` + Check AccessIdentityDevicePostureCheck `json:"check"` + Data interface{} `json:"data"` + Description string `json:"description"` + Error string `json:"error"` + RuleName string `json:"rule_name"` + Success bool `json:"success"` + Timestamp string `json:"timestamp"` + Type string `json:"type"` + JSON accessIdentityDevicePostureJSON `json:"-"` +} + +// accessIdentityDevicePostureJSON contains the JSON metadata for the struct +// [AccessIdentityDevicePosture] +type accessIdentityDevicePostureJSON struct { + ID apijson.Field + Check apijson.Field + Data apijson.Field + Description apijson.Field + Error apijson.Field + RuleName apijson.Field + Success apijson.Field + Timestamp apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityDevicePosture) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityDevicePostureJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityDevicePostureCheck struct { + Exists bool `json:"exists"` + Path string `json:"path"` + JSON accessIdentityDevicePostureCheckJSON `json:"-"` +} + +// accessIdentityDevicePostureCheckJSON contains the JSON metadata for the struct +// [AccessIdentityDevicePostureCheck] +type accessIdentityDevicePostureCheckJSON struct { + Exists apijson.Field + Path apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityDevicePostureCheck) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityDevicePostureCheckJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityGeo struct { + Country string `json:"country"` + JSON accessIdentityGeoJSON `json:"-"` +} + +// accessIdentityGeoJSON contains the JSON metadata for the struct +// [AccessIdentityGeo] +type accessIdentityGeoJSON struct { + Country apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityGeo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityGeoJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityIdp struct { + ID string `json:"id"` + Type string `json:"type"` + JSON accessIdentityIdpJSON `json:"-"` +} + +// accessIdentityIdpJSON contains the JSON metadata for the struct +// [AccessIdentityIdp] +type accessIdentityIdpJSON struct { + ID apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityIdp) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityIdpJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityMTLSAuth struct { + AuthStatus string `json:"auth_status"` + CertIssuerDn string `json:"cert_issuer_dn"` + CertIssuerSki string `json:"cert_issuer_ski"` + CertPresented bool `json:"cert_presented"` + CertSerial string `json:"cert_serial"` + JSON accessIdentityMTLSAuthJSON `json:"-"` +} + +// accessIdentityMTLSAuthJSON contains the JSON metadata for the struct +// [AccessIdentityMTLSAuth] +type accessIdentityMTLSAuthJSON struct { + AuthStatus apijson.Field + CertIssuerDn apijson.Field + CertIssuerSki apijson.Field + CertPresented apijson.Field + CertSerial apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityMTLSAuth) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityMTLSAuthJSON) RawJSON() string { + return r.raw +} + +type AccessUserLastSeenIdentityGetResponseEnvelope struct { + Errors []AccessUserLastSeenIdentityGetResponseEnvelopeErrors `json:"errors,required"` + Messages []AccessUserLastSeenIdentityGetResponseEnvelopeMessages `json:"messages,required"` + Result AccessIdentity `json:"result,required"` + // Whether the API call was successful + Success AccessUserLastSeenIdentityGetResponseEnvelopeSuccess `json:"success,required"` + JSON accessUserLastSeenIdentityGetResponseEnvelopeJSON `json:"-"` +} + +// accessUserLastSeenIdentityGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [AccessUserLastSeenIdentityGetResponseEnvelope] +type accessUserLastSeenIdentityGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserLastSeenIdentityGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserLastSeenIdentityGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type AccessUserLastSeenIdentityGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessUserLastSeenIdentityGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// accessUserLastSeenIdentityGetResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [AccessUserLastSeenIdentityGetResponseEnvelopeErrors] +type accessUserLastSeenIdentityGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserLastSeenIdentityGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserLastSeenIdentityGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type AccessUserLastSeenIdentityGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON accessUserLastSeenIdentityGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// accessUserLastSeenIdentityGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [AccessUserLastSeenIdentityGetResponseEnvelopeMessages] +type accessUserLastSeenIdentityGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessUserLastSeenIdentityGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessUserLastSeenIdentityGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type AccessUserLastSeenIdentityGetResponseEnvelopeSuccess bool + +const ( + AccessUserLastSeenIdentityGetResponseEnvelopeSuccessTrue AccessUserLastSeenIdentityGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/accessuserlastseenidentity_test.go b/zero_trust/accessuserlastseenidentity_test.go new file mode 100644 index 00000000000..0947222df67 --- /dev/null +++ b/zero_trust/accessuserlastseenidentity_test.go @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" +) + +func TestAccessUserLastSeenIdentityGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Access.Users.LastSeenIdentity.Get( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + ) + 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/zero_trust/aliases.go b/zero_trust/aliases.go new file mode 100644 index 00000000000..a82bbb16215 --- /dev/null +++ b/zero_trust/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/zero_trust/connectivitysetting.go b/zero_trust/connectivitysetting.go new file mode 100644 index 00000000000..12a47762cfe --- /dev/null +++ b/zero_trust/connectivitysetting.go @@ -0,0 +1,288 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ConnectivitySettingService 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 [NewConnectivitySettingService] +// method instead. +type ConnectivitySettingService struct { + Options []option.RequestOption +} + +// NewConnectivitySettingService 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 NewConnectivitySettingService(opts ...option.RequestOption) (r *ConnectivitySettingService) { + r = &ConnectivitySettingService{} + r.Options = opts + return +} + +// Updates the Zero Trust Connectivity Settings for the given account. +func (r *ConnectivitySettingService) Edit(ctx context.Context, params ConnectivitySettingEditParams, opts ...option.RequestOption) (res *ConnectivitySettingEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env ConnectivitySettingEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/zerotrust/connectivity_settings", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets the Zero Trust Connectivity Settings for the given account. +func (r *ConnectivitySettingService) Get(ctx context.Context, query ConnectivitySettingGetParams, opts ...option.RequestOption) (res *ConnectivitySettingGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env ConnectivitySettingGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/zerotrust/connectivity_settings", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ConnectivitySettingEditResponse struct { + // A flag to enable the ICMP proxy for the account network. + IcmpProxyEnabled bool `json:"icmp_proxy_enabled"` + // A flag to enable WARP to WARP traffic. + OfframpWARPEnabled bool `json:"offramp_warp_enabled"` + JSON connectivitySettingEditResponseJSON `json:"-"` +} + +// connectivitySettingEditResponseJSON contains the JSON metadata for the struct +// [ConnectivitySettingEditResponse] +type connectivitySettingEditResponseJSON struct { + IcmpProxyEnabled apijson.Field + OfframpWARPEnabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectivitySettingEditResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectivitySettingEditResponseJSON) RawJSON() string { + return r.raw +} + +type ConnectivitySettingGetResponse struct { + // A flag to enable the ICMP proxy for the account network. + IcmpProxyEnabled bool `json:"icmp_proxy_enabled"` + // A flag to enable WARP to WARP traffic. + OfframpWARPEnabled bool `json:"offramp_warp_enabled"` + JSON connectivitySettingGetResponseJSON `json:"-"` +} + +// connectivitySettingGetResponseJSON contains the JSON metadata for the struct +// [ConnectivitySettingGetResponse] +type connectivitySettingGetResponseJSON struct { + IcmpProxyEnabled apijson.Field + OfframpWARPEnabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectivitySettingGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectivitySettingGetResponseJSON) RawJSON() string { + return r.raw +} + +type ConnectivitySettingEditParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` + // A flag to enable the ICMP proxy for the account network. + IcmpProxyEnabled param.Field[bool] `json:"icmp_proxy_enabled"` + // A flag to enable WARP to WARP traffic. + OfframpWARPEnabled param.Field[bool] `json:"offramp_warp_enabled"` +} + +func (r ConnectivitySettingEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type ConnectivitySettingEditResponseEnvelope struct { + Errors []ConnectivitySettingEditResponseEnvelopeErrors `json:"errors,required"` + Messages []ConnectivitySettingEditResponseEnvelopeMessages `json:"messages,required"` + Result ConnectivitySettingEditResponse `json:"result,required"` + // Whether the API call was successful + Success ConnectivitySettingEditResponseEnvelopeSuccess `json:"success,required"` + JSON connectivitySettingEditResponseEnvelopeJSON `json:"-"` +} + +// connectivitySettingEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [ConnectivitySettingEditResponseEnvelope] +type connectivitySettingEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectivitySettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectivitySettingEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConnectivitySettingEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON connectivitySettingEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// connectivitySettingEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [ConnectivitySettingEditResponseEnvelopeErrors] +type connectivitySettingEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectivitySettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectivitySettingEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ConnectivitySettingEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON connectivitySettingEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// connectivitySettingEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [ConnectivitySettingEditResponseEnvelopeMessages] +type connectivitySettingEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectivitySettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectivitySettingEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConnectivitySettingEditResponseEnvelopeSuccess bool + +const ( + ConnectivitySettingEditResponseEnvelopeSuccessTrue ConnectivitySettingEditResponseEnvelopeSuccess = true +) + +type ConnectivitySettingGetParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` +} + +type ConnectivitySettingGetResponseEnvelope struct { + Errors []ConnectivitySettingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []ConnectivitySettingGetResponseEnvelopeMessages `json:"messages,required"` + Result ConnectivitySettingGetResponse `json:"result,required"` + // Whether the API call was successful + Success ConnectivitySettingGetResponseEnvelopeSuccess `json:"success,required"` + JSON connectivitySettingGetResponseEnvelopeJSON `json:"-"` +} + +// connectivitySettingGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [ConnectivitySettingGetResponseEnvelope] +type connectivitySettingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectivitySettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectivitySettingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ConnectivitySettingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON connectivitySettingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// connectivitySettingGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [ConnectivitySettingGetResponseEnvelopeErrors] +type connectivitySettingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectivitySettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectivitySettingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ConnectivitySettingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON connectivitySettingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// connectivitySettingGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [ConnectivitySettingGetResponseEnvelopeMessages] +type connectivitySettingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ConnectivitySettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r connectivitySettingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ConnectivitySettingGetResponseEnvelopeSuccess bool + +const ( + ConnectivitySettingGetResponseEnvelopeSuccessTrue ConnectivitySettingGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/connectivitysetting_test.go b/zero_trust/connectivitysetting_test.go new file mode 100644 index 00000000000..7b466943563 --- /dev/null +++ b/zero_trust/connectivitysetting_test.go @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestConnectivitySettingEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.ConnectivitySettings.Edit(context.TODO(), zero_trust.ConnectivitySettingEditParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + IcmpProxyEnabled: cloudflare.F(true), + OfframpWARPEnabled: cloudflare.F(true), + }) + 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 TestConnectivitySettingGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.ConnectivitySettings.Get(context.TODO(), zero_trust.ConnectivitySettingGetParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + }) + 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/zero_trust/device.go b/zero_trust/device.go new file mode 100644 index 00000000000..b561d35b971 --- /dev/null +++ b/zero_trust/device.go @@ -0,0 +1,412 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// DeviceService 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 [NewDeviceService] method instead. +type DeviceService struct { + Options []option.RequestOption + DEXTests *DeviceDEXTestService + Networks *DeviceNetworkService + Policies *DevicePolicyService + Postures *DevicePostureService + Revokes *DeviceRevokeService + Settings *DeviceSettingService + Unrevokes *DeviceUnrevokeService + OverrideCodes *DeviceOverrideCodeService +} + +// NewDeviceService 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 NewDeviceService(opts ...option.RequestOption) (r *DeviceService) { + r = &DeviceService{} + r.Options = opts + r.DEXTests = NewDeviceDEXTestService(opts...) + r.Networks = NewDeviceNetworkService(opts...) + r.Policies = NewDevicePolicyService(opts...) + r.Postures = NewDevicePostureService(opts...) + r.Revokes = NewDeviceRevokeService(opts...) + r.Settings = NewDeviceSettingService(opts...) + r.Unrevokes = NewDeviceUnrevokeService(opts...) + r.OverrideCodes = NewDeviceOverrideCodeService(opts...) + return +} + +// Fetches a list of enrolled devices. +func (r *DeviceService) List(ctx context.Context, query DeviceListParams, opts ...option.RequestOption) (res *[]TeamsDevicesDevices, err error) { + opts = append(r.Options[:], opts...) + var env DeviceListResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches details for a single device. +func (r *DeviceService) Get(ctx context.Context, deviceID string, query DeviceGetParams, opts ...option.RequestOption) (res *DeviceGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env DeviceGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/%s", query.AccountID, deviceID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TeamsDevicesDevices struct { + // Device ID. + ID string `json:"id"` + // When the device was created. + Created time.Time `json:"created" format:"date-time"` + // True if the device was deleted. + Deleted bool `json:"deleted"` + DeviceType TeamsDevicesDevicesDeviceType `json:"device_type"` + // IPv4 or IPv6 address. + IP string `json:"ip"` + // The device's public key. + Key string `json:"key"` + // When the device last connected to Cloudflare services. + LastSeen time.Time `json:"last_seen" format:"date-time"` + // The device mac address. + MacAddress string `json:"mac_address"` + // The device manufacturer name. + Manufacturer string `json:"manufacturer"` + // The device model name. + Model string `json:"model"` + // The device name. + Name string `json:"name"` + // The Linux distro name. + OSDistroName string `json:"os_distro_name"` + // The Linux distro revision. + OSDistroRevision string `json:"os_distro_revision"` + // The operating system version. + OSVersion string `json:"os_version"` + // The operating system version extra parameter. + OSVersionExtra string `json:"os_version_extra"` + // When the device was revoked. + RevokedAt time.Time `json:"revoked_at" format:"date-time"` + // The device serial number. + SerialNumber string `json:"serial_number"` + // When the device was updated. + Updated time.Time `json:"updated" format:"date-time"` + User TeamsDevicesDevicesUser `json:"user"` + // The WARP client version. + Version string `json:"version"` + JSON teamsDevicesDevicesJSON `json:"-"` +} + +// teamsDevicesDevicesJSON contains the JSON metadata for the struct +// [TeamsDevicesDevices] +type teamsDevicesDevicesJSON struct { + ID apijson.Field + Created apijson.Field + Deleted apijson.Field + DeviceType apijson.Field + IP apijson.Field + Key apijson.Field + LastSeen apijson.Field + MacAddress apijson.Field + Manufacturer apijson.Field + Model apijson.Field + Name apijson.Field + OSDistroName apijson.Field + OSDistroRevision apijson.Field + OSVersion apijson.Field + OSVersionExtra apijson.Field + RevokedAt apijson.Field + SerialNumber apijson.Field + Updated apijson.Field + User apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevices) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicesJSON) RawJSON() string { + return r.raw +} + +type TeamsDevicesDevicesDeviceType string + +const ( + TeamsDevicesDevicesDeviceTypeWindows TeamsDevicesDevicesDeviceType = "windows" + TeamsDevicesDevicesDeviceTypeMac TeamsDevicesDevicesDeviceType = "mac" + TeamsDevicesDevicesDeviceTypeLinux TeamsDevicesDevicesDeviceType = "linux" + TeamsDevicesDevicesDeviceTypeAndroid TeamsDevicesDevicesDeviceType = "android" + TeamsDevicesDevicesDeviceTypeIos TeamsDevicesDevicesDeviceType = "ios" +) + +type TeamsDevicesDevicesUser struct { + // UUID + ID string `json:"id"` + // The contact email address of the user. + Email string `json:"email"` + // The enrolled device user's name. + Name string `json:"name"` + JSON teamsDevicesDevicesUserJSON `json:"-"` +} + +// teamsDevicesDevicesUserJSON contains the JSON metadata for the struct +// [TeamsDevicesDevicesUser] +type teamsDevicesDevicesUserJSON struct { + ID apijson.Field + Email apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicesUser) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicesUserJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [zero_trust.DeviceGetResponseUnknown] or +// [shared.UnionString]. +type DeviceGetResponse interface { + ImplementsZeroTrustDeviceGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DeviceGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type DeviceListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DeviceListResponseEnvelope struct { + Errors []DeviceListResponseEnvelopeErrors `json:"errors,required"` + Messages []DeviceListResponseEnvelopeMessages `json:"messages,required"` + Result []TeamsDevicesDevices `json:"result,required,nullable"` + // Whether the API call was successful. + Success DeviceListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DeviceListResponseEnvelopeResultInfo `json:"result_info"` + JSON deviceListResponseEnvelopeJSON `json:"-"` +} + +// deviceListResponseEnvelopeJSON contains the JSON metadata for the struct +// [DeviceListResponseEnvelope] +type deviceListResponseEnvelopeJSON 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 *DeviceListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeviceListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceListResponseEnvelopeErrorsJSON `json:"-"` +} + +// deviceListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [DeviceListResponseEnvelopeErrors] +type deviceListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeviceListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceListResponseEnvelopeMessagesJSON `json:"-"` +} + +// deviceListResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [DeviceListResponseEnvelopeMessages] +type deviceListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DeviceListResponseEnvelopeSuccess bool + +const ( + DeviceListResponseEnvelopeSuccessTrue DeviceListResponseEnvelopeSuccess = true +) + +type DeviceListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON deviceListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// deviceListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [DeviceListResponseEnvelopeResultInfo] +type deviceListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DeviceGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DeviceGetResponseEnvelope struct { + Errors []DeviceGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DeviceGetResponseEnvelopeMessages `json:"messages,required"` + Result DeviceGetResponse `json:"result,required,nullable"` + // Whether the API call was successful. + Success DeviceGetResponseEnvelopeSuccess `json:"success,required"` + JSON deviceGetResponseEnvelopeJSON `json:"-"` +} + +// deviceGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DeviceGetResponseEnvelope] +type deviceGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeviceGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// deviceGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [DeviceGetResponseEnvelopeErrors] +type deviceGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeviceGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// deviceGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [DeviceGetResponseEnvelopeMessages] +type deviceGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DeviceGetResponseEnvelopeSuccess bool + +const ( + DeviceGetResponseEnvelopeSuccessTrue DeviceGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/device_test.go b/zero_trust/device_test.go new file mode 100644 index 00000000000..ca418b8a6fd --- /dev/null +++ b/zero_trust/device_test.go @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDeviceList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.List(context.TODO(), zero_trust.DeviceListParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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 TestDeviceGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Get( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DeviceGetParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/devicedextest.go b/zero_trust/devicedextest.go new file mode 100644 index 00000000000..2adfd7a1f6b --- /dev/null +++ b/zero_trust/devicedextest.go @@ -0,0 +1,648 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DeviceDEXTestService 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 [NewDeviceDEXTestService] method +// instead. +type DeviceDEXTestService struct { + Options []option.RequestOption +} + +// NewDeviceDEXTestService 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 NewDeviceDEXTestService(opts ...option.RequestOption) (r *DeviceDEXTestService) { + r = &DeviceDEXTestService{} + r.Options = opts + return +} + +// Create a DEX test. +func (r *DeviceDEXTestService) New(ctx context.Context, params DeviceDEXTestNewParams, opts ...option.RequestOption) (res *TeamsDevicesDeviceDEXTestSchemasHTTP, err error) { + opts = append(r.Options[:], opts...) + var env DeviceDEXTestNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/dex_tests", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update a DEX test. +func (r *DeviceDEXTestService) Update(ctx context.Context, dexTestID string, params DeviceDEXTestUpdateParams, opts ...option.RequestOption) (res *TeamsDevicesDeviceDEXTestSchemasHTTP, err error) { + opts = append(r.Options[:], opts...) + var env DeviceDEXTestUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/dex_tests/%s", params.AccountID, dexTestID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch all DEX tests. +func (r *DeviceDEXTestService) List(ctx context.Context, query DeviceDEXTestListParams, opts ...option.RequestOption) (res *[]TeamsDevicesDeviceDEXTestSchemasHTTP, err error) { + opts = append(r.Options[:], opts...) + var env DeviceDEXTestListResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/dex_tests", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a Device DEX test. Returns the remaining device dex tests for the +// account. +func (r *DeviceDEXTestService) Delete(ctx context.Context, dexTestID string, body DeviceDEXTestDeleteParams, opts ...option.RequestOption) (res *[]TeamsDevicesDeviceDEXTestSchemasHTTP, err error) { + opts = append(r.Options[:], opts...) + var env DeviceDEXTestDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/dex_tests/%s", body.AccountID, dexTestID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch a single DEX test. +func (r *DeviceDEXTestService) Get(ctx context.Context, dexTestID string, query DeviceDEXTestGetParams, opts ...option.RequestOption) (res *TeamsDevicesDeviceDEXTestSchemasHTTP, err error) { + opts = append(r.Options[:], opts...) + var env DeviceDEXTestGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/dex_tests/%s", query.AccountID, dexTestID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TeamsDevicesDeviceDEXTestSchemasHTTP struct { + // The configuration object which contains the details for the WARP client to + // conduct the test. + Data TeamsDevicesDeviceDEXTestSchemasHTTPData `json:"data,required"` + // Determines whether or not the test is active. + Enabled bool `json:"enabled,required"` + // How often the test will run. + Interval string `json:"interval,required"` + // The name of the DEX test. Must be unique. + Name string `json:"name,required"` + // Additional details about the test. + Description string `json:"description"` + JSON teamsDevicesDeviceDEXTestSchemasHTTPJSON `json:"-"` +} + +// teamsDevicesDeviceDEXTestSchemasHTTPJSON contains the JSON metadata for the +// struct [TeamsDevicesDeviceDEXTestSchemasHTTP] +type teamsDevicesDeviceDEXTestSchemasHTTPJSON struct { + Data apijson.Field + Enabled apijson.Field + Interval apijson.Field + Name apijson.Field + Description apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDeviceDEXTestSchemasHTTP) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDeviceDEXTestSchemasHTTPJSON) RawJSON() string { + return r.raw +} + +// The configuration object which contains the details for the WARP client to +// conduct the test. +type TeamsDevicesDeviceDEXTestSchemasHTTPData struct { + // The desired endpoint to test. + Host string `json:"host"` + // The type of test. + Kind string `json:"kind"` + // The HTTP request method type. + Method string `json:"method"` + JSON teamsDevicesDeviceDEXTestSchemasHTTPDataJSON `json:"-"` +} + +// teamsDevicesDeviceDEXTestSchemasHTTPDataJSON contains the JSON metadata for the +// struct [TeamsDevicesDeviceDEXTestSchemasHTTPData] +type teamsDevicesDeviceDEXTestSchemasHTTPDataJSON struct { + Host apijson.Field + Kind apijson.Field + Method apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDeviceDEXTestSchemasHTTPData) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDeviceDEXTestSchemasHTTPDataJSON) RawJSON() string { + return r.raw +} + +type DeviceDEXTestNewParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // The configuration object which contains the details for the WARP client to + // conduct the test. + Data param.Field[DeviceDEXTestNewParamsData] `json:"data,required"` + // Determines whether or not the test is active. + Enabled param.Field[bool] `json:"enabled,required"` + // How often the test will run. + Interval param.Field[string] `json:"interval,required"` + // The name of the DEX test. Must be unique. + Name param.Field[string] `json:"name,required"` + // Additional details about the test. + Description param.Field[string] `json:"description"` +} + +func (r DeviceDEXTestNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The configuration object which contains the details for the WARP client to +// conduct the test. +type DeviceDEXTestNewParamsData struct { + // The desired endpoint to test. + Host param.Field[string] `json:"host"` + // The type of test. + Kind param.Field[string] `json:"kind"` + // The HTTP request method type. + Method param.Field[string] `json:"method"` +} + +func (r DeviceDEXTestNewParamsData) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DeviceDEXTestNewResponseEnvelope struct { + Errors []DeviceDEXTestNewResponseEnvelopeErrors `json:"errors,required"` + Messages []DeviceDEXTestNewResponseEnvelopeMessages `json:"messages,required"` + Result TeamsDevicesDeviceDEXTestSchemasHTTP `json:"result,required,nullable"` + // Whether the API call was successful. + Success DeviceDEXTestNewResponseEnvelopeSuccess `json:"success,required"` + JSON deviceDEXTestNewResponseEnvelopeJSON `json:"-"` +} + +// deviceDEXTestNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [DeviceDEXTestNewResponseEnvelope] +type deviceDEXTestNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceDEXTestNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceDEXTestNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeviceDEXTestNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceDEXTestNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// deviceDEXTestNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DeviceDEXTestNewResponseEnvelopeErrors] +type deviceDEXTestNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceDEXTestNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceDEXTestNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeviceDEXTestNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceDEXTestNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// deviceDEXTestNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DeviceDEXTestNewResponseEnvelopeMessages] +type deviceDEXTestNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceDEXTestNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceDEXTestNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DeviceDEXTestNewResponseEnvelopeSuccess bool + +const ( + DeviceDEXTestNewResponseEnvelopeSuccessTrue DeviceDEXTestNewResponseEnvelopeSuccess = true +) + +type DeviceDEXTestUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // The configuration object which contains the details for the WARP client to + // conduct the test. + Data param.Field[DeviceDEXTestUpdateParamsData] `json:"data,required"` + // Determines whether or not the test is active. + Enabled param.Field[bool] `json:"enabled,required"` + // How often the test will run. + Interval param.Field[string] `json:"interval,required"` + // The name of the DEX test. Must be unique. + Name param.Field[string] `json:"name,required"` + // Additional details about the test. + Description param.Field[string] `json:"description"` +} + +func (r DeviceDEXTestUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The configuration object which contains the details for the WARP client to +// conduct the test. +type DeviceDEXTestUpdateParamsData struct { + // The desired endpoint to test. + Host param.Field[string] `json:"host"` + // The type of test. + Kind param.Field[string] `json:"kind"` + // The HTTP request method type. + Method param.Field[string] `json:"method"` +} + +func (r DeviceDEXTestUpdateParamsData) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DeviceDEXTestUpdateResponseEnvelope struct { + Errors []DeviceDEXTestUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []DeviceDEXTestUpdateResponseEnvelopeMessages `json:"messages,required"` + Result TeamsDevicesDeviceDEXTestSchemasHTTP `json:"result,required,nullable"` + // Whether the API call was successful. + Success DeviceDEXTestUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON deviceDEXTestUpdateResponseEnvelopeJSON `json:"-"` +} + +// deviceDEXTestUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [DeviceDEXTestUpdateResponseEnvelope] +type deviceDEXTestUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceDEXTestUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceDEXTestUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeviceDEXTestUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceDEXTestUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// deviceDEXTestUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DeviceDEXTestUpdateResponseEnvelopeErrors] +type deviceDEXTestUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceDEXTestUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceDEXTestUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeviceDEXTestUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceDEXTestUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// deviceDEXTestUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [DeviceDEXTestUpdateResponseEnvelopeMessages] +type deviceDEXTestUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceDEXTestUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceDEXTestUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DeviceDEXTestUpdateResponseEnvelopeSuccess bool + +const ( + DeviceDEXTestUpdateResponseEnvelopeSuccessTrue DeviceDEXTestUpdateResponseEnvelopeSuccess = true +) + +type DeviceDEXTestListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DeviceDEXTestListResponseEnvelope struct { + Errors []DeviceDEXTestListResponseEnvelopeErrors `json:"errors,required"` + Messages []DeviceDEXTestListResponseEnvelopeMessages `json:"messages,required"` + Result []TeamsDevicesDeviceDEXTestSchemasHTTP `json:"result,required,nullable"` + // Whether the API call was successful. + Success DeviceDEXTestListResponseEnvelopeSuccess `json:"success,required"` + JSON deviceDEXTestListResponseEnvelopeJSON `json:"-"` +} + +// deviceDEXTestListResponseEnvelopeJSON contains the JSON metadata for the struct +// [DeviceDEXTestListResponseEnvelope] +type deviceDEXTestListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceDEXTestListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceDEXTestListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeviceDEXTestListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceDEXTestListResponseEnvelopeErrorsJSON `json:"-"` +} + +// deviceDEXTestListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DeviceDEXTestListResponseEnvelopeErrors] +type deviceDEXTestListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceDEXTestListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceDEXTestListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeviceDEXTestListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceDEXTestListResponseEnvelopeMessagesJSON `json:"-"` +} + +// deviceDEXTestListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DeviceDEXTestListResponseEnvelopeMessages] +type deviceDEXTestListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceDEXTestListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceDEXTestListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DeviceDEXTestListResponseEnvelopeSuccess bool + +const ( + DeviceDEXTestListResponseEnvelopeSuccessTrue DeviceDEXTestListResponseEnvelopeSuccess = true +) + +type DeviceDEXTestDeleteParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DeviceDEXTestDeleteResponseEnvelope struct { + Errors []DeviceDEXTestDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []DeviceDEXTestDeleteResponseEnvelopeMessages `json:"messages,required"` + Result []TeamsDevicesDeviceDEXTestSchemasHTTP `json:"result,required,nullable"` + // Whether the API call was successful. + Success DeviceDEXTestDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON deviceDEXTestDeleteResponseEnvelopeJSON `json:"-"` +} + +// deviceDEXTestDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [DeviceDEXTestDeleteResponseEnvelope] +type deviceDEXTestDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceDEXTestDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceDEXTestDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeviceDEXTestDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceDEXTestDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// deviceDEXTestDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DeviceDEXTestDeleteResponseEnvelopeErrors] +type deviceDEXTestDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceDEXTestDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceDEXTestDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeviceDEXTestDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceDEXTestDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// deviceDEXTestDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [DeviceDEXTestDeleteResponseEnvelopeMessages] +type deviceDEXTestDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceDEXTestDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceDEXTestDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DeviceDEXTestDeleteResponseEnvelopeSuccess bool + +const ( + DeviceDEXTestDeleteResponseEnvelopeSuccessTrue DeviceDEXTestDeleteResponseEnvelopeSuccess = true +) + +type DeviceDEXTestGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DeviceDEXTestGetResponseEnvelope struct { + Errors []DeviceDEXTestGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DeviceDEXTestGetResponseEnvelopeMessages `json:"messages,required"` + Result TeamsDevicesDeviceDEXTestSchemasHTTP `json:"result,required,nullable"` + // Whether the API call was successful. + Success DeviceDEXTestGetResponseEnvelopeSuccess `json:"success,required"` + JSON deviceDEXTestGetResponseEnvelopeJSON `json:"-"` +} + +// deviceDEXTestGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DeviceDEXTestGetResponseEnvelope] +type deviceDEXTestGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceDEXTestGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceDEXTestGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeviceDEXTestGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceDEXTestGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// deviceDEXTestGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DeviceDEXTestGetResponseEnvelopeErrors] +type deviceDEXTestGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceDEXTestGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceDEXTestGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeviceDEXTestGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceDEXTestGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// deviceDEXTestGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DeviceDEXTestGetResponseEnvelopeMessages] +type deviceDEXTestGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceDEXTestGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceDEXTestGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DeviceDEXTestGetResponseEnvelopeSuccess bool + +const ( + DeviceDEXTestGetResponseEnvelopeSuccessTrue DeviceDEXTestGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/devicedextest_test.go b/zero_trust/devicedextest_test.go new file mode 100644 index 00000000000..d7f1fe5100d --- /dev/null +++ b/zero_trust/devicedextest_test.go @@ -0,0 +1,175 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDeviceDEXTestNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.DEXTests.New(context.TODO(), zero_trust.DeviceDEXTestNewParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Data: cloudflare.F(zero_trust.DeviceDEXTestNewParamsData{ + Host: cloudflare.F("https://dash.cloudflare.com"), + Kind: cloudflare.F("http"), + Method: cloudflare.F("GET"), + }), + Enabled: cloudflare.F(true), + Interval: cloudflare.F("30m"), + Name: cloudflare.F("HTTP dash health check"), + Description: cloudflare.F("Checks the dash endpoint every 30 minutes"), + }) + 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 TestDeviceDEXTestUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.DEXTests.Update( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DeviceDEXTestUpdateParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Data: cloudflare.F(zero_trust.DeviceDEXTestUpdateParamsData{ + Host: cloudflare.F("https://dash.cloudflare.com"), + Kind: cloudflare.F("http"), + Method: cloudflare.F("GET"), + }), + Enabled: cloudflare.F(true), + Interval: cloudflare.F("30m"), + Name: cloudflare.F("HTTP dash health check"), + Description: cloudflare.F("Checks the dash endpoint every 30 minutes"), + }, + ) + 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 TestDeviceDEXTestList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.DEXTests.List(context.TODO(), zero_trust.DeviceDEXTestListParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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 TestDeviceDEXTestDelete(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.DEXTests.Delete( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DeviceDEXTestDeleteParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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 TestDeviceDEXTestGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.DEXTests.Get( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DeviceDEXTestGetParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/devicenetwork.go b/zero_trust/devicenetwork.go new file mode 100644 index 00000000000..afb9773350e --- /dev/null +++ b/zero_trust/devicenetwork.go @@ -0,0 +1,726 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DeviceNetworkService 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 [NewDeviceNetworkService] method +// instead. +type DeviceNetworkService struct { + Options []option.RequestOption +} + +// NewDeviceNetworkService 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 NewDeviceNetworkService(opts ...option.RequestOption) (r *DeviceNetworkService) { + r = &DeviceNetworkService{} + r.Options = opts + return +} + +// Creates a new device managed network. +func (r *DeviceNetworkService) New(ctx context.Context, params DeviceNetworkNewParams, opts ...option.RequestOption) (res *TeamsDevicesDeviceManagedNetworks, err error) { + opts = append(r.Options[:], opts...) + var env DeviceNetworkNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/networks", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a configured device managed network. +func (r *DeviceNetworkService) Update(ctx context.Context, networkID string, params DeviceNetworkUpdateParams, opts ...option.RequestOption) (res *TeamsDevicesDeviceManagedNetworks, err error) { + opts = append(r.Options[:], opts...) + var env DeviceNetworkUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/networks/%s", params.AccountID, networkID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a list of managed networks for an account. +func (r *DeviceNetworkService) List(ctx context.Context, query DeviceNetworkListParams, opts ...option.RequestOption) (res *[]TeamsDevicesDeviceManagedNetworks, err error) { + opts = append(r.Options[:], opts...) + var env DeviceNetworkListResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/networks", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a device managed network and fetches a list of the remaining device +// managed networks for an account. +func (r *DeviceNetworkService) Delete(ctx context.Context, networkID string, body DeviceNetworkDeleteParams, opts ...option.RequestOption) (res *[]TeamsDevicesDeviceManagedNetworks, err error) { + opts = append(r.Options[:], opts...) + var env DeviceNetworkDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/networks/%s", body.AccountID, networkID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches details for a single managed network. +func (r *DeviceNetworkService) Get(ctx context.Context, networkID string, query DeviceNetworkGetParams, opts ...option.RequestOption) (res *TeamsDevicesDeviceManagedNetworks, err error) { + opts = append(r.Options[:], opts...) + var env DeviceNetworkGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/networks/%s", query.AccountID, networkID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TeamsDevicesDeviceManagedNetworks struct { + // The configuration object containing information for the WARP client to detect + // the managed network. + Config TeamsDevicesDeviceManagedNetworksConfig `json:"config"` + // The name of the device managed network. This name must be unique. + Name string `json:"name"` + // API UUID. + NetworkID string `json:"network_id"` + // The type of device managed network. + Type TeamsDevicesDeviceManagedNetworksType `json:"type"` + JSON teamsDevicesDeviceManagedNetworksJSON `json:"-"` +} + +// teamsDevicesDeviceManagedNetworksJSON contains the JSON metadata for the struct +// [TeamsDevicesDeviceManagedNetworks] +type teamsDevicesDeviceManagedNetworksJSON struct { + Config apijson.Field + Name apijson.Field + NetworkID apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDeviceManagedNetworks) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDeviceManagedNetworksJSON) RawJSON() string { + return r.raw +} + +// The configuration object containing information for the WARP client to detect +// the managed network. +type TeamsDevicesDeviceManagedNetworksConfig struct { + // A network address of the form "host:port" that the WARP client will use to + // detect the presence of a TLS host. + TLSSockaddr string `json:"tls_sockaddr,required"` + // The SHA-256 hash of the TLS certificate presented by the host found at + // tls_sockaddr. If absent, regular certificate verification (trusted roots, valid + // timestamp, etc) will be used to validate the certificate. + Sha256 string `json:"sha256"` + JSON teamsDevicesDeviceManagedNetworksConfigJSON `json:"-"` +} + +// teamsDevicesDeviceManagedNetworksConfigJSON contains the JSON metadata for the +// struct [TeamsDevicesDeviceManagedNetworksConfig] +type teamsDevicesDeviceManagedNetworksConfigJSON struct { + TLSSockaddr apijson.Field + Sha256 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDeviceManagedNetworksConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDeviceManagedNetworksConfigJSON) RawJSON() string { + return r.raw +} + +// The type of device managed network. +type TeamsDevicesDeviceManagedNetworksType string + +const ( + TeamsDevicesDeviceManagedNetworksTypeTLS TeamsDevicesDeviceManagedNetworksType = "tls" +) + +type DeviceNetworkNewParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // The configuration object containing information for the WARP client to detect + // the managed network. + Config param.Field[DeviceNetworkNewParamsConfig] `json:"config,required"` + // The name of the device managed network. This name must be unique. + Name param.Field[string] `json:"name,required"` + // The type of device managed network. + Type param.Field[DeviceNetworkNewParamsType] `json:"type,required"` +} + +func (r DeviceNetworkNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The configuration object containing information for the WARP client to detect +// the managed network. +type DeviceNetworkNewParamsConfig struct { + // A network address of the form "host:port" that the WARP client will use to + // detect the presence of a TLS host. + TLSSockaddr param.Field[string] `json:"tls_sockaddr,required"` + // The SHA-256 hash of the TLS certificate presented by the host found at + // tls_sockaddr. If absent, regular certificate verification (trusted roots, valid + // timestamp, etc) will be used to validate the certificate. + Sha256 param.Field[string] `json:"sha256"` +} + +func (r DeviceNetworkNewParamsConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of device managed network. +type DeviceNetworkNewParamsType string + +const ( + DeviceNetworkNewParamsTypeTLS DeviceNetworkNewParamsType = "tls" +) + +type DeviceNetworkNewResponseEnvelope struct { + Errors []DeviceNetworkNewResponseEnvelopeErrors `json:"errors,required"` + Messages []DeviceNetworkNewResponseEnvelopeMessages `json:"messages,required"` + Result TeamsDevicesDeviceManagedNetworks `json:"result,required,nullable"` + // Whether the API call was successful. + Success DeviceNetworkNewResponseEnvelopeSuccess `json:"success,required"` + JSON deviceNetworkNewResponseEnvelopeJSON `json:"-"` +} + +// deviceNetworkNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [DeviceNetworkNewResponseEnvelope] +type deviceNetworkNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceNetworkNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceNetworkNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeviceNetworkNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceNetworkNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// deviceNetworkNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DeviceNetworkNewResponseEnvelopeErrors] +type deviceNetworkNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceNetworkNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceNetworkNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeviceNetworkNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceNetworkNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// deviceNetworkNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DeviceNetworkNewResponseEnvelopeMessages] +type deviceNetworkNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceNetworkNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceNetworkNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DeviceNetworkNewResponseEnvelopeSuccess bool + +const ( + DeviceNetworkNewResponseEnvelopeSuccessTrue DeviceNetworkNewResponseEnvelopeSuccess = true +) + +type DeviceNetworkUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // The configuration object containing information for the WARP client to detect + // the managed network. + Config param.Field[DeviceNetworkUpdateParamsConfig] `json:"config"` + // The name of the device managed network. This name must be unique. + Name param.Field[string] `json:"name"` + // The type of device managed network. + Type param.Field[DeviceNetworkUpdateParamsType] `json:"type"` +} + +func (r DeviceNetworkUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The configuration object containing information for the WARP client to detect +// the managed network. +type DeviceNetworkUpdateParamsConfig struct { + // A network address of the form "host:port" that the WARP client will use to + // detect the presence of a TLS host. + TLSSockaddr param.Field[string] `json:"tls_sockaddr,required"` + // The SHA-256 hash of the TLS certificate presented by the host found at + // tls_sockaddr. If absent, regular certificate verification (trusted roots, valid + // timestamp, etc) will be used to validate the certificate. + Sha256 param.Field[string] `json:"sha256"` +} + +func (r DeviceNetworkUpdateParamsConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of device managed network. +type DeviceNetworkUpdateParamsType string + +const ( + DeviceNetworkUpdateParamsTypeTLS DeviceNetworkUpdateParamsType = "tls" +) + +type DeviceNetworkUpdateResponseEnvelope struct { + Errors []DeviceNetworkUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []DeviceNetworkUpdateResponseEnvelopeMessages `json:"messages,required"` + Result TeamsDevicesDeviceManagedNetworks `json:"result,required,nullable"` + // Whether the API call was successful. + Success DeviceNetworkUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON deviceNetworkUpdateResponseEnvelopeJSON `json:"-"` +} + +// deviceNetworkUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [DeviceNetworkUpdateResponseEnvelope] +type deviceNetworkUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceNetworkUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceNetworkUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeviceNetworkUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceNetworkUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// deviceNetworkUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DeviceNetworkUpdateResponseEnvelopeErrors] +type deviceNetworkUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceNetworkUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceNetworkUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeviceNetworkUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceNetworkUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// deviceNetworkUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [DeviceNetworkUpdateResponseEnvelopeMessages] +type deviceNetworkUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceNetworkUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceNetworkUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DeviceNetworkUpdateResponseEnvelopeSuccess bool + +const ( + DeviceNetworkUpdateResponseEnvelopeSuccessTrue DeviceNetworkUpdateResponseEnvelopeSuccess = true +) + +type DeviceNetworkListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DeviceNetworkListResponseEnvelope struct { + Errors []DeviceNetworkListResponseEnvelopeErrors `json:"errors,required"` + Messages []DeviceNetworkListResponseEnvelopeMessages `json:"messages,required"` + Result []TeamsDevicesDeviceManagedNetworks `json:"result,required,nullable"` + // Whether the API call was successful. + Success DeviceNetworkListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DeviceNetworkListResponseEnvelopeResultInfo `json:"result_info"` + JSON deviceNetworkListResponseEnvelopeJSON `json:"-"` +} + +// deviceNetworkListResponseEnvelopeJSON contains the JSON metadata for the struct +// [DeviceNetworkListResponseEnvelope] +type deviceNetworkListResponseEnvelopeJSON 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 *DeviceNetworkListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceNetworkListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeviceNetworkListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceNetworkListResponseEnvelopeErrorsJSON `json:"-"` +} + +// deviceNetworkListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DeviceNetworkListResponseEnvelopeErrors] +type deviceNetworkListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceNetworkListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceNetworkListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeviceNetworkListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceNetworkListResponseEnvelopeMessagesJSON `json:"-"` +} + +// deviceNetworkListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DeviceNetworkListResponseEnvelopeMessages] +type deviceNetworkListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceNetworkListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceNetworkListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DeviceNetworkListResponseEnvelopeSuccess bool + +const ( + DeviceNetworkListResponseEnvelopeSuccessTrue DeviceNetworkListResponseEnvelopeSuccess = true +) + +type DeviceNetworkListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON deviceNetworkListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// deviceNetworkListResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [DeviceNetworkListResponseEnvelopeResultInfo] +type deviceNetworkListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceNetworkListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceNetworkListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DeviceNetworkDeleteParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DeviceNetworkDeleteResponseEnvelope struct { + Errors []DeviceNetworkDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []DeviceNetworkDeleteResponseEnvelopeMessages `json:"messages,required"` + Result []TeamsDevicesDeviceManagedNetworks `json:"result,required,nullable"` + // Whether the API call was successful. + Success DeviceNetworkDeleteResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DeviceNetworkDeleteResponseEnvelopeResultInfo `json:"result_info"` + JSON deviceNetworkDeleteResponseEnvelopeJSON `json:"-"` +} + +// deviceNetworkDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [DeviceNetworkDeleteResponseEnvelope] +type deviceNetworkDeleteResponseEnvelopeJSON 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 *DeviceNetworkDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceNetworkDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeviceNetworkDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceNetworkDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// deviceNetworkDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DeviceNetworkDeleteResponseEnvelopeErrors] +type deviceNetworkDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceNetworkDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceNetworkDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeviceNetworkDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceNetworkDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// deviceNetworkDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [DeviceNetworkDeleteResponseEnvelopeMessages] +type deviceNetworkDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceNetworkDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceNetworkDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DeviceNetworkDeleteResponseEnvelopeSuccess bool + +const ( + DeviceNetworkDeleteResponseEnvelopeSuccessTrue DeviceNetworkDeleteResponseEnvelopeSuccess = true +) + +type DeviceNetworkDeleteResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON deviceNetworkDeleteResponseEnvelopeResultInfoJSON `json:"-"` +} + +// deviceNetworkDeleteResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [DeviceNetworkDeleteResponseEnvelopeResultInfo] +type deviceNetworkDeleteResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceNetworkDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceNetworkDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DeviceNetworkGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DeviceNetworkGetResponseEnvelope struct { + Errors []DeviceNetworkGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DeviceNetworkGetResponseEnvelopeMessages `json:"messages,required"` + Result TeamsDevicesDeviceManagedNetworks `json:"result,required,nullable"` + // Whether the API call was successful. + Success DeviceNetworkGetResponseEnvelopeSuccess `json:"success,required"` + JSON deviceNetworkGetResponseEnvelopeJSON `json:"-"` +} + +// deviceNetworkGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DeviceNetworkGetResponseEnvelope] +type deviceNetworkGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceNetworkGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceNetworkGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeviceNetworkGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceNetworkGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// deviceNetworkGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DeviceNetworkGetResponseEnvelopeErrors] +type deviceNetworkGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceNetworkGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceNetworkGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeviceNetworkGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceNetworkGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// deviceNetworkGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DeviceNetworkGetResponseEnvelopeMessages] +type deviceNetworkGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceNetworkGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceNetworkGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DeviceNetworkGetResponseEnvelopeSuccess bool + +const ( + DeviceNetworkGetResponseEnvelopeSuccessTrue DeviceNetworkGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/devicenetwork_test.go b/zero_trust/devicenetwork_test.go new file mode 100644 index 00000000000..b2d8ef7a72c --- /dev/null +++ b/zero_trust/devicenetwork_test.go @@ -0,0 +1,169 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDeviceNetworkNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Networks.New(context.TODO(), zero_trust.DeviceNetworkNewParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Config: cloudflare.F(zero_trust.DeviceNetworkNewParamsConfig{ + Sha256: cloudflare.F("b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c"), + TLSSockaddr: cloudflare.F("foo.bar:1234"), + }), + Name: cloudflare.F("managed-network-1"), + Type: cloudflare.F(zero_trust.DeviceNetworkNewParamsTypeTLS), + }) + 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 TestDeviceNetworkUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Networks.Update( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DeviceNetworkUpdateParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Config: cloudflare.F(zero_trust.DeviceNetworkUpdateParamsConfig{ + Sha256: cloudflare.F("b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c"), + TLSSockaddr: cloudflare.F("foo.bar:1234"), + }), + Name: cloudflare.F("managed-network-1"), + Type: cloudflare.F(zero_trust.DeviceNetworkUpdateParamsTypeTLS), + }, + ) + 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 TestDeviceNetworkList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Networks.List(context.TODO(), zero_trust.DeviceNetworkListParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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 TestDeviceNetworkDelete(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Networks.Delete( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DeviceNetworkDeleteParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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 TestDeviceNetworkGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Networks.Get( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DeviceNetworkGetParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/deviceoverridecode.go b/zero_trust/deviceoverridecode.go new file mode 100644 index 00000000000..8a5223d637c --- /dev/null +++ b/zero_trust/deviceoverridecode.go @@ -0,0 +1,219 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DeviceOverrideCodeService 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 [NewDeviceOverrideCodeService] method +// instead. +type DeviceOverrideCodeService struct { + Options []option.RequestOption +} + +// NewDeviceOverrideCodeService 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 NewDeviceOverrideCodeService(opts ...option.RequestOption) (r *DeviceOverrideCodeService) { + r = &DeviceOverrideCodeService{} + r.Options = opts + return +} + +// Fetches a one-time use admin override code for a device. This relies on the +// **Admin Override** setting being enabled in your device configuration. +func (r *DeviceOverrideCodeService) List(ctx context.Context, deviceID string, query DeviceOverrideCodeListParams, opts ...option.RequestOption) (res *DeviceOverrideCodeListResponse, err error) { + opts = append(r.Options[:], opts...) + var env DeviceOverrideCodeListResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/%s/override_codes", query.AccountID, deviceID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DeviceOverrideCodeListResponse struct { + DisableForTime DeviceOverrideCodeListResponseDisableForTime `json:"disable_for_time"` + JSON deviceOverrideCodeListResponseJSON `json:"-"` +} + +// deviceOverrideCodeListResponseJSON contains the JSON metadata for the struct +// [DeviceOverrideCodeListResponse] +type deviceOverrideCodeListResponseJSON struct { + DisableForTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceOverrideCodeListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceOverrideCodeListResponseJSON) RawJSON() string { + return r.raw +} + +type DeviceOverrideCodeListResponseDisableForTime struct { + // Override code that is valid for 1 hour. + Number1 interface{} `json:"1"` + // Override code that is valid for 12 hour2. + Number12 interface{} `json:"12"` + // Override code that is valid for 24 hour.2. + Number24 interface{} `json:"24"` + // Override code that is valid for 3 hours. + Number3 interface{} `json:"3"` + // Override code that is valid for 6 hours. + Number6 interface{} `json:"6"` + JSON deviceOverrideCodeListResponseDisableForTimeJSON `json:"-"` +} + +// deviceOverrideCodeListResponseDisableForTimeJSON contains the JSON metadata for +// the struct [DeviceOverrideCodeListResponseDisableForTime] +type deviceOverrideCodeListResponseDisableForTimeJSON struct { + Number1 apijson.Field + Number12 apijson.Field + Number24 apijson.Field + Number3 apijson.Field + Number6 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceOverrideCodeListResponseDisableForTime) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceOverrideCodeListResponseDisableForTimeJSON) RawJSON() string { + return r.raw +} + +type DeviceOverrideCodeListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DeviceOverrideCodeListResponseEnvelope struct { + Errors []DeviceOverrideCodeListResponseEnvelopeErrors `json:"errors,required"` + Messages []DeviceOverrideCodeListResponseEnvelopeMessages `json:"messages,required"` + Result DeviceOverrideCodeListResponse `json:"result,required,nullable"` + // Whether the API call was successful. + Success DeviceOverrideCodeListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DeviceOverrideCodeListResponseEnvelopeResultInfo `json:"result_info"` + JSON deviceOverrideCodeListResponseEnvelopeJSON `json:"-"` +} + +// deviceOverrideCodeListResponseEnvelopeJSON contains the JSON metadata for the +// struct [DeviceOverrideCodeListResponseEnvelope] +type deviceOverrideCodeListResponseEnvelopeJSON 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 *DeviceOverrideCodeListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceOverrideCodeListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeviceOverrideCodeListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceOverrideCodeListResponseEnvelopeErrorsJSON `json:"-"` +} + +// deviceOverrideCodeListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [DeviceOverrideCodeListResponseEnvelopeErrors] +type deviceOverrideCodeListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceOverrideCodeListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceOverrideCodeListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeviceOverrideCodeListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceOverrideCodeListResponseEnvelopeMessagesJSON `json:"-"` +} + +// deviceOverrideCodeListResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [DeviceOverrideCodeListResponseEnvelopeMessages] +type deviceOverrideCodeListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceOverrideCodeListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceOverrideCodeListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DeviceOverrideCodeListResponseEnvelopeSuccess bool + +const ( + DeviceOverrideCodeListResponseEnvelopeSuccessTrue DeviceOverrideCodeListResponseEnvelopeSuccess = true +) + +type DeviceOverrideCodeListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON deviceOverrideCodeListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// deviceOverrideCodeListResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [DeviceOverrideCodeListResponseEnvelopeResultInfo] +type deviceOverrideCodeListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceOverrideCodeListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceOverrideCodeListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/deviceoverridecode_test.go b/zero_trust/deviceoverridecode_test.go new file mode 100644 index 00000000000..bcd5053e1dd --- /dev/null +++ b/zero_trust/deviceoverridecode_test.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDeviceOverrideCodeList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.OverrideCodes.List( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DeviceOverrideCodeListParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/devicepolicy.go b/zero_trust/devicepolicy.go new file mode 100644 index 00000000000..97b265b00aa --- /dev/null +++ b/zero_trust/devicepolicy.go @@ -0,0 +1,923 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DevicePolicyService 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 [NewDevicePolicyService] method +// instead. +type DevicePolicyService struct { + Options []option.RequestOption + DefaultPolicy *DevicePolicyDefaultPolicyService + Excludes *DevicePolicyExcludeService + FallbackDomains *DevicePolicyFallbackDomainService + Includes *DevicePolicyIncludeService +} + +// NewDevicePolicyService 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 NewDevicePolicyService(opts ...option.RequestOption) (r *DevicePolicyService) { + r = &DevicePolicyService{} + r.Options = opts + r.DefaultPolicy = NewDevicePolicyDefaultPolicyService(opts...) + r.Excludes = NewDevicePolicyExcludeService(opts...) + r.FallbackDomains = NewDevicePolicyFallbackDomainService(opts...) + r.Includes = NewDevicePolicyIncludeService(opts...) + return +} + +// Creates a device settings profile to be applied to certain devices matching the +// criteria. +func (r *DevicePolicyService) New(ctx context.Context, params DevicePolicyNewParams, opts ...option.RequestOption) (res *TeamsDevicesDeviceSettingsPolicy, err error) { + opts = append(r.Options[:], opts...) + var env DevicePolicyNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/policy", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a list of the device settings profiles for an account. +func (r *DevicePolicyService) List(ctx context.Context, query DevicePolicyListParams, opts ...option.RequestOption) (res *[]TeamsDevicesDeviceSettingsPolicy, err error) { + opts = append(r.Options[:], opts...) + var env DevicePolicyListResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/policies", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a device settings profile and fetches a list of the remaining profiles +// for an account. +func (r *DevicePolicyService) Delete(ctx context.Context, policyID string, body DevicePolicyDeleteParams, opts ...option.RequestOption) (res *[]TeamsDevicesDeviceSettingsPolicy, err error) { + opts = append(r.Options[:], opts...) + var env DevicePolicyDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/policy/%s", body.AccountID, policyID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a configured device settings profile. +func (r *DevicePolicyService) Edit(ctx context.Context, policyID string, params DevicePolicyEditParams, opts ...option.RequestOption) (res *TeamsDevicesDeviceSettingsPolicy, err error) { + opts = append(r.Options[:], opts...) + var env DevicePolicyEditResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/policy/%s", params.AccountID, policyID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a device settings profile by ID. +func (r *DevicePolicyService) Get(ctx context.Context, policyID string, query DevicePolicyGetParams, opts ...option.RequestOption) (res *TeamsDevicesDeviceSettingsPolicy, err error) { + opts = append(r.Options[:], opts...) + var env DevicePolicyGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/policy/%s", query.AccountID, policyID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TeamsDevicesDeviceSettingsPolicy struct { + // Whether to allow the user to switch WARP between modes. + AllowModeSwitch bool `json:"allow_mode_switch"` + // Whether to receive update notifications when a new version of the client is + // available. + AllowUpdates bool `json:"allow_updates"` + // Whether to allow devices to leave the organization. + AllowedToLeave bool `json:"allowed_to_leave"` + // The amount of time in minutes to reconnect after having been disabled. + AutoConnect float64 `json:"auto_connect"` + // Turn on the captive portal after the specified amount of time. + CaptivePortal float64 `json:"captive_portal"` + // Whether the policy is the default policy for an account. + Default bool `json:"default"` + // A description of the policy. + Description string `json:"description"` + // If the `dns_server` field of a fallback domain is not present, the client will + // fall back to a best guess of the default/system DNS resolvers unless this policy + // option is set to `true`. + DisableAutoFallback bool `json:"disable_auto_fallback"` + // Whether the policy will be applied to matching devices. + Enabled bool `json:"enabled"` + Exclude []TeamsDevicesSplitTunnel `json:"exclude"` + // Whether to add Microsoft IPs to Split Tunnel exclusions. + ExcludeOfficeIPs bool `json:"exclude_office_ips"` + FallbackDomains []TeamsDevicesFallbackDomain `json:"fallback_domains"` + GatewayUniqueID string `json:"gateway_unique_id"` + Include []TeamsDevicesSplitTunnelInclude `json:"include"` + // The amount of time in minutes a user is allowed access to their LAN. A value of + // 0 will allow LAN access until the next WARP reconnection, such as a reboot or a + // laptop waking from sleep. Note that this field is omitted from the response if + // null or unset. + LanAllowMinutes float64 `json:"lan_allow_minutes"` + // The size of the subnet for the local access network. Note that this field is + // omitted from the response if null or unset. + LanAllowSubnetSize float64 `json:"lan_allow_subnet_size"` + // The wirefilter expression to match devices. + Match string `json:"match"` + // The name of the device settings profile. + Name string `json:"name"` + // Device ID. + PolicyID string `json:"policy_id"` + // The precedence of the policy. Lower values indicate higher precedence. Policies + // will be evaluated in ascending order of this field. + Precedence float64 `json:"precedence"` + ServiceModeV2 TeamsDevicesDeviceSettingsPolicyServiceModeV2 `json:"service_mode_v2"` + // The URL to launch when the Send Feedback button is clicked. + SupportURL string `json:"support_url"` + // Whether to allow the user to turn off the WARP switch and disconnect the client. + SwitchLocked bool `json:"switch_locked"` + JSON teamsDevicesDeviceSettingsPolicyJSON `json:"-"` +} + +// teamsDevicesDeviceSettingsPolicyJSON contains the JSON metadata for the struct +// [TeamsDevicesDeviceSettingsPolicy] +type teamsDevicesDeviceSettingsPolicyJSON struct { + AllowModeSwitch apijson.Field + AllowUpdates apijson.Field + AllowedToLeave apijson.Field + AutoConnect apijson.Field + CaptivePortal apijson.Field + Default apijson.Field + Description apijson.Field + DisableAutoFallback apijson.Field + Enabled apijson.Field + Exclude apijson.Field + ExcludeOfficeIPs apijson.Field + FallbackDomains apijson.Field + GatewayUniqueID apijson.Field + Include apijson.Field + LanAllowMinutes apijson.Field + LanAllowSubnetSize apijson.Field + Match apijson.Field + Name apijson.Field + PolicyID apijson.Field + Precedence apijson.Field + ServiceModeV2 apijson.Field + SupportURL apijson.Field + SwitchLocked apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDeviceSettingsPolicy) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDeviceSettingsPolicyJSON) RawJSON() string { + return r.raw +} + +type TeamsDevicesDeviceSettingsPolicyServiceModeV2 struct { + // The mode to run the WARP client under. + Mode string `json:"mode"` + // The port number when used with proxy mode. + Port float64 `json:"port"` + JSON teamsDevicesDeviceSettingsPolicyServiceModeV2JSON `json:"-"` +} + +// teamsDevicesDeviceSettingsPolicyServiceModeV2JSON contains the JSON metadata for +// the struct [TeamsDevicesDeviceSettingsPolicyServiceModeV2] +type teamsDevicesDeviceSettingsPolicyServiceModeV2JSON struct { + Mode apijson.Field + Port apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDeviceSettingsPolicyServiceModeV2) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDeviceSettingsPolicyServiceModeV2JSON) RawJSON() string { + return r.raw +} + +type DevicePolicyNewResponse = interface{} + +type DevicePolicyEditResponse = interface{} + +type DevicePolicyGetResponse = interface{} + +type DevicePolicyNewParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // The wirefilter expression to match devices. + Match param.Field[string] `json:"match,required"` + // The name of the device settings profile. + Name param.Field[string] `json:"name,required"` + // The precedence of the policy. Lower values indicate higher precedence. Policies + // will be evaluated in ascending order of this field. + Precedence param.Field[float64] `json:"precedence,required"` + // Whether to allow the user to switch WARP between modes. + AllowModeSwitch param.Field[bool] `json:"allow_mode_switch"` + // Whether to receive update notifications when a new version of the client is + // available. + AllowUpdates param.Field[bool] `json:"allow_updates"` + // Whether to allow devices to leave the organization. + AllowedToLeave param.Field[bool] `json:"allowed_to_leave"` + // The amount of time in minutes to reconnect after having been disabled. + AutoConnect param.Field[float64] `json:"auto_connect"` + // Turn on the captive portal after the specified amount of time. + CaptivePortal param.Field[float64] `json:"captive_portal"` + // A description of the policy. + Description param.Field[string] `json:"description"` + // If the `dns_server` field of a fallback domain is not present, the client will + // fall back to a best guess of the default/system DNS resolvers unless this policy + // option is set to `true`. + DisableAutoFallback param.Field[bool] `json:"disable_auto_fallback"` + // Whether the policy will be applied to matching devices. + Enabled param.Field[bool] `json:"enabled"` + // Whether to add Microsoft IPs to Split Tunnel exclusions. + ExcludeOfficeIPs param.Field[bool] `json:"exclude_office_ips"` + // The amount of time in minutes a user is allowed access to their LAN. A value of + // 0 will allow LAN access until the next WARP reconnection, such as a reboot or a + // laptop waking from sleep. Note that this field is omitted from the response if + // null or unset. + LanAllowMinutes param.Field[float64] `json:"lan_allow_minutes"` + // The size of the subnet for the local access network. Note that this field is + // omitted from the response if null or unset. + LanAllowSubnetSize param.Field[float64] `json:"lan_allow_subnet_size"` + ServiceModeV2 param.Field[DevicePolicyNewParamsServiceModeV2] `json:"service_mode_v2"` + // The URL to launch when the Send Feedback button is clicked. + SupportURL param.Field[string] `json:"support_url"` + // Whether to allow the user to turn off the WARP switch and disconnect the client. + SwitchLocked param.Field[bool] `json:"switch_locked"` +} + +func (r DevicePolicyNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DevicePolicyNewParamsServiceModeV2 struct { + // The mode to run the WARP client under. + Mode param.Field[string] `json:"mode"` + // The port number when used with proxy mode. + Port param.Field[float64] `json:"port"` +} + +func (r DevicePolicyNewParamsServiceModeV2) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DevicePolicyNewResponseEnvelope struct { + Errors []DevicePolicyNewResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePolicyNewResponseEnvelopeMessages `json:"messages,required"` + Result TeamsDevicesDeviceSettingsPolicy `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePolicyNewResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DevicePolicyNewResponseEnvelopeResultInfo `json:"result_info"` + JSON devicePolicyNewResponseEnvelopeJSON `json:"-"` +} + +// devicePolicyNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [DevicePolicyNewResponseEnvelope] +type devicePolicyNewResponseEnvelopeJSON 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 *DevicePolicyNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePolicyNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DevicePolicyNewResponseEnvelopeErrors] +type devicePolicyNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePolicyNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DevicePolicyNewResponseEnvelopeMessages] +type devicePolicyNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePolicyNewResponseEnvelopeSuccess bool + +const ( + DevicePolicyNewResponseEnvelopeSuccessTrue DevicePolicyNewResponseEnvelopeSuccess = true +) + +type DevicePolicyNewResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON devicePolicyNewResponseEnvelopeResultInfoJSON `json:"-"` +} + +// devicePolicyNewResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [DevicePolicyNewResponseEnvelopeResultInfo] +type devicePolicyNewResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyNewResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DevicePolicyListResponseEnvelope struct { + Errors []DevicePolicyListResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePolicyListResponseEnvelopeMessages `json:"messages,required"` + Result []TeamsDevicesDeviceSettingsPolicy `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePolicyListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DevicePolicyListResponseEnvelopeResultInfo `json:"result_info"` + JSON devicePolicyListResponseEnvelopeJSON `json:"-"` +} + +// devicePolicyListResponseEnvelopeJSON contains the JSON metadata for the struct +// [DevicePolicyListResponseEnvelope] +type devicePolicyListResponseEnvelopeJSON 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 *DevicePolicyListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyListResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePolicyListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DevicePolicyListResponseEnvelopeErrors] +type devicePolicyListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyListResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePolicyListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DevicePolicyListResponseEnvelopeMessages] +type devicePolicyListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePolicyListResponseEnvelopeSuccess bool + +const ( + DevicePolicyListResponseEnvelopeSuccessTrue DevicePolicyListResponseEnvelopeSuccess = true +) + +type DevicePolicyListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON devicePolicyListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// devicePolicyListResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [DevicePolicyListResponseEnvelopeResultInfo] +type devicePolicyListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyDeleteParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DevicePolicyDeleteResponseEnvelope struct { + Errors []DevicePolicyDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePolicyDeleteResponseEnvelopeMessages `json:"messages,required"` + Result []TeamsDevicesDeviceSettingsPolicy `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePolicyDeleteResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DevicePolicyDeleteResponseEnvelopeResultInfo `json:"result_info"` + JSON devicePolicyDeleteResponseEnvelopeJSON `json:"-"` +} + +// devicePolicyDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [DevicePolicyDeleteResponseEnvelope] +type devicePolicyDeleteResponseEnvelopeJSON 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 *DevicePolicyDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePolicyDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DevicePolicyDeleteResponseEnvelopeErrors] +type devicePolicyDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePolicyDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [DevicePolicyDeleteResponseEnvelopeMessages] +type devicePolicyDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePolicyDeleteResponseEnvelopeSuccess bool + +const ( + DevicePolicyDeleteResponseEnvelopeSuccessTrue DevicePolicyDeleteResponseEnvelopeSuccess = true +) + +type DevicePolicyDeleteResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON devicePolicyDeleteResponseEnvelopeResultInfoJSON `json:"-"` +} + +// devicePolicyDeleteResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [DevicePolicyDeleteResponseEnvelopeResultInfo] +type devicePolicyDeleteResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyEditParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // Whether to allow the user to switch WARP between modes. + AllowModeSwitch param.Field[bool] `json:"allow_mode_switch"` + // Whether to receive update notifications when a new version of the client is + // available. + AllowUpdates param.Field[bool] `json:"allow_updates"` + // Whether to allow devices to leave the organization. + AllowedToLeave param.Field[bool] `json:"allowed_to_leave"` + // The amount of time in minutes to reconnect after having been disabled. + AutoConnect param.Field[float64] `json:"auto_connect"` + // Turn on the captive portal after the specified amount of time. + CaptivePortal param.Field[float64] `json:"captive_portal"` + // A description of the policy. + Description param.Field[string] `json:"description"` + // If the `dns_server` field of a fallback domain is not present, the client will + // fall back to a best guess of the default/system DNS resolvers unless this policy + // option is set to `true`. + DisableAutoFallback param.Field[bool] `json:"disable_auto_fallback"` + // Whether the policy will be applied to matching devices. + Enabled param.Field[bool] `json:"enabled"` + // Whether to add Microsoft IPs to Split Tunnel exclusions. + ExcludeOfficeIPs param.Field[bool] `json:"exclude_office_ips"` + // The wirefilter expression to match devices. + Match param.Field[string] `json:"match"` + // The name of the device settings profile. + Name param.Field[string] `json:"name"` + // The precedence of the policy. Lower values indicate higher precedence. Policies + // will be evaluated in ascending order of this field. + Precedence param.Field[float64] `json:"precedence"` + ServiceModeV2 param.Field[DevicePolicyEditParamsServiceModeV2] `json:"service_mode_v2"` + // The URL to launch when the Send Feedback button is clicked. + SupportURL param.Field[string] `json:"support_url"` + // Whether to allow the user to turn off the WARP switch and disconnect the client. + SwitchLocked param.Field[bool] `json:"switch_locked"` +} + +func (r DevicePolicyEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DevicePolicyEditParamsServiceModeV2 struct { + // The mode to run the WARP client under. + Mode param.Field[string] `json:"mode"` + // The port number when used with proxy mode. + Port param.Field[float64] `json:"port"` +} + +func (r DevicePolicyEditParamsServiceModeV2) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DevicePolicyEditResponseEnvelope struct { + Errors []DevicePolicyEditResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePolicyEditResponseEnvelopeMessages `json:"messages,required"` + Result TeamsDevicesDeviceSettingsPolicy `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePolicyEditResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DevicePolicyEditResponseEnvelopeResultInfo `json:"result_info"` + JSON devicePolicyEditResponseEnvelopeJSON `json:"-"` +} + +// devicePolicyEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [DevicePolicyEditResponseEnvelope] +type devicePolicyEditResponseEnvelopeJSON 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 *DevicePolicyEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePolicyEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DevicePolicyEditResponseEnvelopeErrors] +type devicePolicyEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePolicyEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DevicePolicyEditResponseEnvelopeMessages] +type devicePolicyEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePolicyEditResponseEnvelopeSuccess bool + +const ( + DevicePolicyEditResponseEnvelopeSuccessTrue DevicePolicyEditResponseEnvelopeSuccess = true +) + +type DevicePolicyEditResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON devicePolicyEditResponseEnvelopeResultInfoJSON `json:"-"` +} + +// devicePolicyEditResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [DevicePolicyEditResponseEnvelopeResultInfo] +type devicePolicyEditResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyEditResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyEditResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DevicePolicyGetResponseEnvelope struct { + Errors []DevicePolicyGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePolicyGetResponseEnvelopeMessages `json:"messages,required"` + Result TeamsDevicesDeviceSettingsPolicy `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePolicyGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DevicePolicyGetResponseEnvelopeResultInfo `json:"result_info"` + JSON devicePolicyGetResponseEnvelopeJSON `json:"-"` +} + +// devicePolicyGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DevicePolicyGetResponseEnvelope] +type devicePolicyGetResponseEnvelopeJSON 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 *DevicePolicyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePolicyGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DevicePolicyGetResponseEnvelopeErrors] +type devicePolicyGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePolicyGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DevicePolicyGetResponseEnvelopeMessages] +type devicePolicyGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePolicyGetResponseEnvelopeSuccess bool + +const ( + DevicePolicyGetResponseEnvelopeSuccessTrue DevicePolicyGetResponseEnvelopeSuccess = true +) + +type DevicePolicyGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON devicePolicyGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// devicePolicyGetResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [DevicePolicyGetResponseEnvelopeResultInfo] +type devicePolicyGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/devicepolicy_test.go b/zero_trust/devicepolicy_test.go new file mode 100644 index 00000000000..90266216ed1 --- /dev/null +++ b/zero_trust/devicepolicy_test.go @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDevicePolicyNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Policies.New(context.TODO(), zero_trust.DevicePolicyNewParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Match: cloudflare.F("user.identity == \"test@cloudflare.com\""), + Name: cloudflare.F("Allow Developers"), + Precedence: cloudflare.F(100.000000), + AllowModeSwitch: cloudflare.F(true), + AllowUpdates: cloudflare.F(true), + AllowedToLeave: cloudflare.F(true), + AutoConnect: cloudflare.F(0.000000), + CaptivePortal: cloudflare.F(180.000000), + Description: cloudflare.F("Policy for test teams."), + DisableAutoFallback: cloudflare.F(true), + Enabled: cloudflare.F(true), + ExcludeOfficeIPs: cloudflare.F(true), + LanAllowMinutes: cloudflare.F(30.000000), + LanAllowSubnetSize: cloudflare.F(24.000000), + ServiceModeV2: cloudflare.F(zero_trust.DevicePolicyNewParamsServiceModeV2{ + Mode: cloudflare.F("proxy"), + Port: cloudflare.F(3000.000000), + }), + SupportURL: cloudflare.F("https://1.1.1.1/help"), + SwitchLocked: cloudflare.F(true), + }) + 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 TestDevicePolicyList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Policies.List(context.TODO(), zero_trust.DevicePolicyListParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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 TestDevicePolicyDelete(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Policies.Delete( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DevicePolicyDeleteParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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 TestDevicePolicyEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Policies.Edit( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DevicePolicyEditParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + AllowModeSwitch: cloudflare.F(true), + AllowUpdates: cloudflare.F(true), + AllowedToLeave: cloudflare.F(true), + AutoConnect: cloudflare.F(0.000000), + CaptivePortal: cloudflare.F(180.000000), + Description: cloudflare.F("Policy for test teams."), + DisableAutoFallback: cloudflare.F(true), + Enabled: cloudflare.F(true), + ExcludeOfficeIPs: cloudflare.F(true), + Match: cloudflare.F("user.identity == \"test@cloudflare.com\""), + Name: cloudflare.F("Allow Developers"), + Precedence: cloudflare.F(100.000000), + ServiceModeV2: cloudflare.F(zero_trust.DevicePolicyEditParamsServiceModeV2{ + Mode: cloudflare.F("proxy"), + Port: cloudflare.F(3000.000000), + }), + SupportURL: cloudflare.F("https://1.1.1.1/help"), + SwitchLocked: cloudflare.F(true), + }, + ) + 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 TestDevicePolicyGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Policies.Get( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DevicePolicyGetParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/devicepolicydefaultpolicy.go b/zero_trust/devicepolicydefaultpolicy.go new file mode 100644 index 00000000000..d0c73dae670 --- /dev/null +++ b/zero_trust/devicepolicydefaultpolicy.go @@ -0,0 +1,165 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DevicePolicyDefaultPolicyService 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 +// [NewDevicePolicyDefaultPolicyService] method instead. +type DevicePolicyDefaultPolicyService struct { + Options []option.RequestOption +} + +// NewDevicePolicyDefaultPolicyService 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 NewDevicePolicyDefaultPolicyService(opts ...option.RequestOption) (r *DevicePolicyDefaultPolicyService) { + r = &DevicePolicyDefaultPolicyService{} + r.Options = opts + return +} + +// Fetches the default device settings profile for an account. +func (r *DevicePolicyDefaultPolicyService) Get(ctx context.Context, query DevicePolicyDefaultPolicyGetParams, opts ...option.RequestOption) (res *[]DevicePolicyDefaultPolicyGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env DevicePolicyDefaultPolicyGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/policy", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DevicePolicyDefaultPolicyGetResponse = interface{} + +type DevicePolicyDefaultPolicyGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DevicePolicyDefaultPolicyGetResponseEnvelope struct { + Errors []DevicePolicyDefaultPolicyGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePolicyDefaultPolicyGetResponseEnvelopeMessages `json:"messages,required"` + Result []DevicePolicyDefaultPolicyGetResponse `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePolicyDefaultPolicyGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DevicePolicyDefaultPolicyGetResponseEnvelopeResultInfo `json:"result_info"` + JSON devicePolicyDefaultPolicyGetResponseEnvelopeJSON `json:"-"` +} + +// devicePolicyDefaultPolicyGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [DevicePolicyDefaultPolicyGetResponseEnvelope] +type devicePolicyDefaultPolicyGetResponseEnvelopeJSON 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 *DevicePolicyDefaultPolicyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyDefaultPolicyGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyDefaultPolicyGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyDefaultPolicyGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePolicyDefaultPolicyGetResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [DevicePolicyDefaultPolicyGetResponseEnvelopeErrors] +type devicePolicyDefaultPolicyGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyDefaultPolicyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyDefaultPolicyGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyDefaultPolicyGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyDefaultPolicyGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePolicyDefaultPolicyGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [DevicePolicyDefaultPolicyGetResponseEnvelopeMessages] +type devicePolicyDefaultPolicyGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyDefaultPolicyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyDefaultPolicyGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePolicyDefaultPolicyGetResponseEnvelopeSuccess bool + +const ( + DevicePolicyDefaultPolicyGetResponseEnvelopeSuccessTrue DevicePolicyDefaultPolicyGetResponseEnvelopeSuccess = true +) + +type DevicePolicyDefaultPolicyGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON devicePolicyDefaultPolicyGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// devicePolicyDefaultPolicyGetResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [DevicePolicyDefaultPolicyGetResponseEnvelopeResultInfo] +type devicePolicyDefaultPolicyGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyDefaultPolicyGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyDefaultPolicyGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/devicepolicydefaultpolicy_test.go b/zero_trust/devicepolicydefaultpolicy_test.go new file mode 100644 index 00000000000..6a0fc78c861 --- /dev/null +++ b/zero_trust/devicepolicydefaultpolicy_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDevicePolicyDefaultPolicyGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Policies.DefaultPolicy.Get(context.TODO(), zero_trust.DevicePolicyDefaultPolicyGetParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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/zero_trust/devicepolicyexclude.go b/zero_trust/devicepolicyexclude.go new file mode 100644 index 00000000000..2f3169f4984 --- /dev/null +++ b/zero_trust/devicepolicyexclude.go @@ -0,0 +1,476 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DevicePolicyExcludeService 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 [NewDevicePolicyExcludeService] +// method instead. +type DevicePolicyExcludeService struct { + Options []option.RequestOption +} + +// NewDevicePolicyExcludeService 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 NewDevicePolicyExcludeService(opts ...option.RequestOption) (r *DevicePolicyExcludeService) { + r = &DevicePolicyExcludeService{} + r.Options = opts + return +} + +// Sets the list of routes excluded from the WARP client's tunnel. +func (r *DevicePolicyExcludeService) Update(ctx context.Context, params DevicePolicyExcludeUpdateParams, opts ...option.RequestOption) (res *[]TeamsDevicesSplitTunnel, err error) { + opts = append(r.Options[:], opts...) + var env DevicePolicyExcludeUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/policy/exclude", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the list of routes excluded from the WARP client's tunnel. +func (r *DevicePolicyExcludeService) List(ctx context.Context, query DevicePolicyExcludeListParams, opts ...option.RequestOption) (res *[]TeamsDevicesSplitTunnel, err error) { + opts = append(r.Options[:], opts...) + var env DevicePolicyExcludeListResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/policy/exclude", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the list of routes excluded from the WARP client's tunnel for a specific +// device settings profile. +func (r *DevicePolicyExcludeService) Get(ctx context.Context, policyID string, query DevicePolicyExcludeGetParams, opts ...option.RequestOption) (res *[]TeamsDevicesSplitTunnel, err error) { + opts = append(r.Options[:], opts...) + var env DevicePolicyExcludeGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/policy/%s/exclude", query.AccountID, policyID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TeamsDevicesSplitTunnel struct { + // The address in CIDR format to exclude from the tunnel. If `address` is present, + // `host` must not be present. + Address string `json:"address,required"` + // A description of the Split Tunnel item, displayed in the client UI. + Description string `json:"description,required"` + // The domain name to exclude from the tunnel. If `host` is present, `address` must + // not be present. + Host string `json:"host"` + JSON teamsDevicesSplitTunnelJSON `json:"-"` +} + +// teamsDevicesSplitTunnelJSON contains the JSON metadata for the struct +// [TeamsDevicesSplitTunnel] +type teamsDevicesSplitTunnelJSON struct { + Address apijson.Field + Description apijson.Field + Host apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesSplitTunnel) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesSplitTunnelJSON) RawJSON() string { + return r.raw +} + +type TeamsDevicesSplitTunnelParam struct { + // The address in CIDR format to exclude from the tunnel. If `address` is present, + // `host` must not be present. + Address param.Field[string] `json:"address,required"` + // A description of the Split Tunnel item, displayed in the client UI. + Description param.Field[string] `json:"description,required"` + // The domain name to exclude from the tunnel. If `host` is present, `address` must + // not be present. + Host param.Field[string] `json:"host"` +} + +func (r TeamsDevicesSplitTunnelParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DevicePolicyExcludeUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + Body param.Field[[]TeamsDevicesSplitTunnelParam] `json:"body,required"` +} + +func (r DevicePolicyExcludeUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type DevicePolicyExcludeUpdateResponseEnvelope struct { + Errors []DevicePolicyExcludeUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePolicyExcludeUpdateResponseEnvelopeMessages `json:"messages,required"` + Result []TeamsDevicesSplitTunnel `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePolicyExcludeUpdateResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DevicePolicyExcludeUpdateResponseEnvelopeResultInfo `json:"result_info"` + JSON devicePolicyExcludeUpdateResponseEnvelopeJSON `json:"-"` +} + +// devicePolicyExcludeUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [DevicePolicyExcludeUpdateResponseEnvelope] +type devicePolicyExcludeUpdateResponseEnvelopeJSON 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 *DevicePolicyExcludeUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyExcludeUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyExcludeUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyExcludeUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePolicyExcludeUpdateResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [DevicePolicyExcludeUpdateResponseEnvelopeErrors] +type devicePolicyExcludeUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyExcludeUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyExcludeUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyExcludeUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyExcludeUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePolicyExcludeUpdateResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [DevicePolicyExcludeUpdateResponseEnvelopeMessages] +type devicePolicyExcludeUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyExcludeUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyExcludeUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePolicyExcludeUpdateResponseEnvelopeSuccess bool + +const ( + DevicePolicyExcludeUpdateResponseEnvelopeSuccessTrue DevicePolicyExcludeUpdateResponseEnvelopeSuccess = true +) + +type DevicePolicyExcludeUpdateResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON devicePolicyExcludeUpdateResponseEnvelopeResultInfoJSON `json:"-"` +} + +// devicePolicyExcludeUpdateResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [DevicePolicyExcludeUpdateResponseEnvelopeResultInfo] +type devicePolicyExcludeUpdateResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyExcludeUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyExcludeUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyExcludeListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DevicePolicyExcludeListResponseEnvelope struct { + Errors []DevicePolicyExcludeListResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePolicyExcludeListResponseEnvelopeMessages `json:"messages,required"` + Result []TeamsDevicesSplitTunnel `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePolicyExcludeListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DevicePolicyExcludeListResponseEnvelopeResultInfo `json:"result_info"` + JSON devicePolicyExcludeListResponseEnvelopeJSON `json:"-"` +} + +// devicePolicyExcludeListResponseEnvelopeJSON contains the JSON metadata for the +// struct [DevicePolicyExcludeListResponseEnvelope] +type devicePolicyExcludeListResponseEnvelopeJSON 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 *DevicePolicyExcludeListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyExcludeListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyExcludeListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyExcludeListResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePolicyExcludeListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [DevicePolicyExcludeListResponseEnvelopeErrors] +type devicePolicyExcludeListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyExcludeListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyExcludeListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyExcludeListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyExcludeListResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePolicyExcludeListResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [DevicePolicyExcludeListResponseEnvelopeMessages] +type devicePolicyExcludeListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyExcludeListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyExcludeListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePolicyExcludeListResponseEnvelopeSuccess bool + +const ( + DevicePolicyExcludeListResponseEnvelopeSuccessTrue DevicePolicyExcludeListResponseEnvelopeSuccess = true +) + +type DevicePolicyExcludeListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON devicePolicyExcludeListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// devicePolicyExcludeListResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [DevicePolicyExcludeListResponseEnvelopeResultInfo] +type devicePolicyExcludeListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyExcludeListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyExcludeListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyExcludeGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DevicePolicyExcludeGetResponseEnvelope struct { + Errors []DevicePolicyExcludeGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePolicyExcludeGetResponseEnvelopeMessages `json:"messages,required"` + Result []TeamsDevicesSplitTunnel `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePolicyExcludeGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DevicePolicyExcludeGetResponseEnvelopeResultInfo `json:"result_info"` + JSON devicePolicyExcludeGetResponseEnvelopeJSON `json:"-"` +} + +// devicePolicyExcludeGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [DevicePolicyExcludeGetResponseEnvelope] +type devicePolicyExcludeGetResponseEnvelopeJSON 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 *DevicePolicyExcludeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyExcludeGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyExcludeGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyExcludeGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePolicyExcludeGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [DevicePolicyExcludeGetResponseEnvelopeErrors] +type devicePolicyExcludeGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyExcludeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyExcludeGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyExcludeGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyExcludeGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePolicyExcludeGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [DevicePolicyExcludeGetResponseEnvelopeMessages] +type devicePolicyExcludeGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyExcludeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyExcludeGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePolicyExcludeGetResponseEnvelopeSuccess bool + +const ( + DevicePolicyExcludeGetResponseEnvelopeSuccessTrue DevicePolicyExcludeGetResponseEnvelopeSuccess = true +) + +type DevicePolicyExcludeGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON devicePolicyExcludeGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// devicePolicyExcludeGetResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [DevicePolicyExcludeGetResponseEnvelopeResultInfo] +type devicePolicyExcludeGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyExcludeGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyExcludeGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/devicepolicyexclude_test.go b/zero_trust/devicepolicyexclude_test.go new file mode 100644 index 00000000000..afae01cf29b --- /dev/null +++ b/zero_trust/devicepolicyexclude_test.go @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDevicePolicyExcludeUpdate(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Policies.Excludes.Update(context.TODO(), zero_trust.DevicePolicyExcludeUpdateParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Body: cloudflare.F([]zero_trust.TeamsDevicesSplitTunnelParam{{ + Address: cloudflare.F("192.0.2.0/24"), + Description: cloudflare.F("Exclude testing domains from the tunnel"), + Host: cloudflare.F("*.example.com"), + }, { + Address: cloudflare.F("192.0.2.0/24"), + Description: cloudflare.F("Exclude testing domains from the tunnel"), + Host: cloudflare.F("*.example.com"), + }, { + Address: cloudflare.F("192.0.2.0/24"), + Description: cloudflare.F("Exclude testing domains from the tunnel"), + Host: cloudflare.F("*.example.com"), + }}), + }) + 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 TestDevicePolicyExcludeList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Policies.Excludes.List(context.TODO(), zero_trust.DevicePolicyExcludeListParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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 TestDevicePolicyExcludeGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Policies.Excludes.Get( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DevicePolicyExcludeGetParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/devicepolicyfallbackdomain.go b/zero_trust/devicepolicyfallbackdomain.go new file mode 100644 index 00000000000..e79603267f8 --- /dev/null +++ b/zero_trust/devicepolicyfallbackdomain.go @@ -0,0 +1,480 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DevicePolicyFallbackDomainService 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 +// [NewDevicePolicyFallbackDomainService] method instead. +type DevicePolicyFallbackDomainService struct { + Options []option.RequestOption +} + +// NewDevicePolicyFallbackDomainService 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 NewDevicePolicyFallbackDomainService(opts ...option.RequestOption) (r *DevicePolicyFallbackDomainService) { + r = &DevicePolicyFallbackDomainService{} + r.Options = opts + return +} + +// Sets the list of domains to bypass Gateway DNS resolution. These domains will +// use the specified local DNS resolver instead. This will only apply to the +// specified device settings profile. +func (r *DevicePolicyFallbackDomainService) Update(ctx context.Context, policyID string, params DevicePolicyFallbackDomainUpdateParams, opts ...option.RequestOption) (res *[]TeamsDevicesFallbackDomain, err error) { + opts = append(r.Options[:], opts...) + var env DevicePolicyFallbackDomainUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/policy/%s/fallback_domains", params.AccountID, policyID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a list of domains to bypass Gateway DNS resolution. These domains will +// use the specified local DNS resolver instead. +func (r *DevicePolicyFallbackDomainService) List(ctx context.Context, query DevicePolicyFallbackDomainListParams, opts ...option.RequestOption) (res *[]TeamsDevicesFallbackDomain, err error) { + opts = append(r.Options[:], opts...) + var env DevicePolicyFallbackDomainListResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/policy/fallback_domains", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the list of domains to bypass Gateway DNS resolution from a specified +// device settings profile. These domains will use the specified local DNS resolver +// instead. +func (r *DevicePolicyFallbackDomainService) Get(ctx context.Context, policyID string, query DevicePolicyFallbackDomainGetParams, opts ...option.RequestOption) (res *[]TeamsDevicesFallbackDomain, err error) { + opts = append(r.Options[:], opts...) + var env DevicePolicyFallbackDomainGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/policy/%s/fallback_domains", query.AccountID, policyID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TeamsDevicesFallbackDomain struct { + // The domain suffix to match when resolving locally. + Suffix string `json:"suffix,required"` + // A description of the fallback domain, displayed in the client UI. + Description string `json:"description"` + // A list of IP addresses to handle domain resolution. + DNSServer []interface{} `json:"dns_server"` + JSON teamsDevicesFallbackDomainJSON `json:"-"` +} + +// teamsDevicesFallbackDomainJSON contains the JSON metadata for the struct +// [TeamsDevicesFallbackDomain] +type teamsDevicesFallbackDomainJSON struct { + Suffix apijson.Field + Description apijson.Field + DNSServer apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesFallbackDomain) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesFallbackDomainJSON) RawJSON() string { + return r.raw +} + +type TeamsDevicesFallbackDomainParam struct { + // The domain suffix to match when resolving locally. + Suffix param.Field[string] `json:"suffix,required"` + // A description of the fallback domain, displayed in the client UI. + Description param.Field[string] `json:"description"` + // A list of IP addresses to handle domain resolution. + DNSServer param.Field[[]interface{}] `json:"dns_server"` +} + +func (r TeamsDevicesFallbackDomainParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DevicePolicyFallbackDomainUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + Body param.Field[[]TeamsDevicesFallbackDomainParam] `json:"body,required"` +} + +func (r DevicePolicyFallbackDomainUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type DevicePolicyFallbackDomainUpdateResponseEnvelope struct { + Errors []DevicePolicyFallbackDomainUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePolicyFallbackDomainUpdateResponseEnvelopeMessages `json:"messages,required"` + Result []TeamsDevicesFallbackDomain `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePolicyFallbackDomainUpdateResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DevicePolicyFallbackDomainUpdateResponseEnvelopeResultInfo `json:"result_info"` + JSON devicePolicyFallbackDomainUpdateResponseEnvelopeJSON `json:"-"` +} + +// devicePolicyFallbackDomainUpdateResponseEnvelopeJSON contains the JSON metadata +// for the struct [DevicePolicyFallbackDomainUpdateResponseEnvelope] +type devicePolicyFallbackDomainUpdateResponseEnvelopeJSON 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 *DevicePolicyFallbackDomainUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyFallbackDomainUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyFallbackDomainUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyFallbackDomainUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePolicyFallbackDomainUpdateResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [DevicePolicyFallbackDomainUpdateResponseEnvelopeErrors] +type devicePolicyFallbackDomainUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyFallbackDomainUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyFallbackDomainUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyFallbackDomainUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyFallbackDomainUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePolicyFallbackDomainUpdateResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct +// [DevicePolicyFallbackDomainUpdateResponseEnvelopeMessages] +type devicePolicyFallbackDomainUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyFallbackDomainUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyFallbackDomainUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePolicyFallbackDomainUpdateResponseEnvelopeSuccess bool + +const ( + DevicePolicyFallbackDomainUpdateResponseEnvelopeSuccessTrue DevicePolicyFallbackDomainUpdateResponseEnvelopeSuccess = true +) + +type DevicePolicyFallbackDomainUpdateResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON devicePolicyFallbackDomainUpdateResponseEnvelopeResultInfoJSON `json:"-"` +} + +// devicePolicyFallbackDomainUpdateResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct +// [DevicePolicyFallbackDomainUpdateResponseEnvelopeResultInfo] +type devicePolicyFallbackDomainUpdateResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyFallbackDomainUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyFallbackDomainUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyFallbackDomainListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DevicePolicyFallbackDomainListResponseEnvelope struct { + Errors []DevicePolicyFallbackDomainListResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePolicyFallbackDomainListResponseEnvelopeMessages `json:"messages,required"` + Result []TeamsDevicesFallbackDomain `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePolicyFallbackDomainListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DevicePolicyFallbackDomainListResponseEnvelopeResultInfo `json:"result_info"` + JSON devicePolicyFallbackDomainListResponseEnvelopeJSON `json:"-"` +} + +// devicePolicyFallbackDomainListResponseEnvelopeJSON contains the JSON metadata +// for the struct [DevicePolicyFallbackDomainListResponseEnvelope] +type devicePolicyFallbackDomainListResponseEnvelopeJSON 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 *DevicePolicyFallbackDomainListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyFallbackDomainListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyFallbackDomainListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyFallbackDomainListResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePolicyFallbackDomainListResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [DevicePolicyFallbackDomainListResponseEnvelopeErrors] +type devicePolicyFallbackDomainListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyFallbackDomainListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyFallbackDomainListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyFallbackDomainListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyFallbackDomainListResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePolicyFallbackDomainListResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [DevicePolicyFallbackDomainListResponseEnvelopeMessages] +type devicePolicyFallbackDomainListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyFallbackDomainListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyFallbackDomainListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePolicyFallbackDomainListResponseEnvelopeSuccess bool + +const ( + DevicePolicyFallbackDomainListResponseEnvelopeSuccessTrue DevicePolicyFallbackDomainListResponseEnvelopeSuccess = true +) + +type DevicePolicyFallbackDomainListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON devicePolicyFallbackDomainListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// devicePolicyFallbackDomainListResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct +// [DevicePolicyFallbackDomainListResponseEnvelopeResultInfo] +type devicePolicyFallbackDomainListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyFallbackDomainListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyFallbackDomainListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyFallbackDomainGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DevicePolicyFallbackDomainGetResponseEnvelope struct { + Errors []DevicePolicyFallbackDomainGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePolicyFallbackDomainGetResponseEnvelopeMessages `json:"messages,required"` + Result []TeamsDevicesFallbackDomain `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePolicyFallbackDomainGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DevicePolicyFallbackDomainGetResponseEnvelopeResultInfo `json:"result_info"` + JSON devicePolicyFallbackDomainGetResponseEnvelopeJSON `json:"-"` +} + +// devicePolicyFallbackDomainGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [DevicePolicyFallbackDomainGetResponseEnvelope] +type devicePolicyFallbackDomainGetResponseEnvelopeJSON 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 *DevicePolicyFallbackDomainGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyFallbackDomainGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyFallbackDomainGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyFallbackDomainGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePolicyFallbackDomainGetResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [DevicePolicyFallbackDomainGetResponseEnvelopeErrors] +type devicePolicyFallbackDomainGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyFallbackDomainGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyFallbackDomainGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyFallbackDomainGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyFallbackDomainGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePolicyFallbackDomainGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [DevicePolicyFallbackDomainGetResponseEnvelopeMessages] +type devicePolicyFallbackDomainGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyFallbackDomainGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyFallbackDomainGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePolicyFallbackDomainGetResponseEnvelopeSuccess bool + +const ( + DevicePolicyFallbackDomainGetResponseEnvelopeSuccessTrue DevicePolicyFallbackDomainGetResponseEnvelopeSuccess = true +) + +type DevicePolicyFallbackDomainGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON devicePolicyFallbackDomainGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// devicePolicyFallbackDomainGetResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct +// [DevicePolicyFallbackDomainGetResponseEnvelopeResultInfo] +type devicePolicyFallbackDomainGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyFallbackDomainGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyFallbackDomainGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/devicepolicyfallbackdomain_test.go b/zero_trust/devicepolicyfallbackdomain_test.go new file mode 100644 index 00000000000..5d094e15806 --- /dev/null +++ b/zero_trust/devicepolicyfallbackdomain_test.go @@ -0,0 +1,114 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDevicePolicyFallbackDomainUpdate(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Policies.FallbackDomains.Update( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DevicePolicyFallbackDomainUpdateParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Body: cloudflare.F([]zero_trust.TeamsDevicesFallbackDomainParam{{ + Description: cloudflare.F("Domain bypass for local development"), + DNSServer: cloudflare.F([]interface{}{map[string]interface{}{}, map[string]interface{}{}, map[string]interface{}{}}), + Suffix: cloudflare.F("example.com"), + }, { + Description: cloudflare.F("Domain bypass for local development"), + DNSServer: cloudflare.F([]interface{}{map[string]interface{}{}, map[string]interface{}{}, map[string]interface{}{}}), + Suffix: cloudflare.F("example.com"), + }, { + Description: cloudflare.F("Domain bypass for local development"), + DNSServer: cloudflare.F([]interface{}{map[string]interface{}{}, map[string]interface{}{}, map[string]interface{}{}}), + Suffix: cloudflare.F("example.com"), + }}), + }, + ) + 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 TestDevicePolicyFallbackDomainList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Policies.FallbackDomains.List(context.TODO(), zero_trust.DevicePolicyFallbackDomainListParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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 TestDevicePolicyFallbackDomainGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Policies.FallbackDomains.Get( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DevicePolicyFallbackDomainGetParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/devicepolicyinclude.go b/zero_trust/devicepolicyinclude.go new file mode 100644 index 00000000000..3f28b5e0ec3 --- /dev/null +++ b/zero_trust/devicepolicyinclude.go @@ -0,0 +1,476 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DevicePolicyIncludeService 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 [NewDevicePolicyIncludeService] +// method instead. +type DevicePolicyIncludeService struct { + Options []option.RequestOption +} + +// NewDevicePolicyIncludeService 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 NewDevicePolicyIncludeService(opts ...option.RequestOption) (r *DevicePolicyIncludeService) { + r = &DevicePolicyIncludeService{} + r.Options = opts + return +} + +// Sets the list of routes included in the WARP client's tunnel. +func (r *DevicePolicyIncludeService) Update(ctx context.Context, params DevicePolicyIncludeUpdateParams, opts ...option.RequestOption) (res *[]TeamsDevicesSplitTunnelInclude, err error) { + opts = append(r.Options[:], opts...) + var env DevicePolicyIncludeUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/policy/include", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the list of routes included in the WARP client's tunnel. +func (r *DevicePolicyIncludeService) List(ctx context.Context, query DevicePolicyIncludeListParams, opts ...option.RequestOption) (res *[]TeamsDevicesSplitTunnelInclude, err error) { + opts = append(r.Options[:], opts...) + var env DevicePolicyIncludeListResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/policy/include", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the list of routes included in the WARP client's tunnel for a specific +// device settings profile. +func (r *DevicePolicyIncludeService) Get(ctx context.Context, policyID string, query DevicePolicyIncludeGetParams, opts ...option.RequestOption) (res *[]TeamsDevicesSplitTunnelInclude, err error) { + opts = append(r.Options[:], opts...) + var env DevicePolicyIncludeGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/policy/%s/include", query.AccountID, policyID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TeamsDevicesSplitTunnelInclude struct { + // The address in CIDR format to include in the tunnel. If address is present, host + // must not be present. + Address string `json:"address,required"` + // A description of the split tunnel item, displayed in the client UI. + Description string `json:"description,required"` + // The domain name to include in the tunnel. If host is present, address must not + // be present. + Host string `json:"host"` + JSON teamsDevicesSplitTunnelIncludeJSON `json:"-"` +} + +// teamsDevicesSplitTunnelIncludeJSON contains the JSON metadata for the struct +// [TeamsDevicesSplitTunnelInclude] +type teamsDevicesSplitTunnelIncludeJSON struct { + Address apijson.Field + Description apijson.Field + Host apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesSplitTunnelInclude) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesSplitTunnelIncludeJSON) RawJSON() string { + return r.raw +} + +type TeamsDevicesSplitTunnelIncludeParam struct { + // The address in CIDR format to include in the tunnel. If address is present, host + // must not be present. + Address param.Field[string] `json:"address,required"` + // A description of the split tunnel item, displayed in the client UI. + Description param.Field[string] `json:"description,required"` + // The domain name to include in the tunnel. If host is present, address must not + // be present. + Host param.Field[string] `json:"host"` +} + +func (r TeamsDevicesSplitTunnelIncludeParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DevicePolicyIncludeUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + Body param.Field[[]TeamsDevicesSplitTunnelIncludeParam] `json:"body,required"` +} + +func (r DevicePolicyIncludeUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type DevicePolicyIncludeUpdateResponseEnvelope struct { + Errors []DevicePolicyIncludeUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePolicyIncludeUpdateResponseEnvelopeMessages `json:"messages,required"` + Result []TeamsDevicesSplitTunnelInclude `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePolicyIncludeUpdateResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DevicePolicyIncludeUpdateResponseEnvelopeResultInfo `json:"result_info"` + JSON devicePolicyIncludeUpdateResponseEnvelopeJSON `json:"-"` +} + +// devicePolicyIncludeUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [DevicePolicyIncludeUpdateResponseEnvelope] +type devicePolicyIncludeUpdateResponseEnvelopeJSON 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 *DevicePolicyIncludeUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyIncludeUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyIncludeUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyIncludeUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePolicyIncludeUpdateResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [DevicePolicyIncludeUpdateResponseEnvelopeErrors] +type devicePolicyIncludeUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyIncludeUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyIncludeUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyIncludeUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyIncludeUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePolicyIncludeUpdateResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [DevicePolicyIncludeUpdateResponseEnvelopeMessages] +type devicePolicyIncludeUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyIncludeUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyIncludeUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePolicyIncludeUpdateResponseEnvelopeSuccess bool + +const ( + DevicePolicyIncludeUpdateResponseEnvelopeSuccessTrue DevicePolicyIncludeUpdateResponseEnvelopeSuccess = true +) + +type DevicePolicyIncludeUpdateResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON devicePolicyIncludeUpdateResponseEnvelopeResultInfoJSON `json:"-"` +} + +// devicePolicyIncludeUpdateResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [DevicePolicyIncludeUpdateResponseEnvelopeResultInfo] +type devicePolicyIncludeUpdateResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyIncludeUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyIncludeUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyIncludeListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DevicePolicyIncludeListResponseEnvelope struct { + Errors []DevicePolicyIncludeListResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePolicyIncludeListResponseEnvelopeMessages `json:"messages,required"` + Result []TeamsDevicesSplitTunnelInclude `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePolicyIncludeListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DevicePolicyIncludeListResponseEnvelopeResultInfo `json:"result_info"` + JSON devicePolicyIncludeListResponseEnvelopeJSON `json:"-"` +} + +// devicePolicyIncludeListResponseEnvelopeJSON contains the JSON metadata for the +// struct [DevicePolicyIncludeListResponseEnvelope] +type devicePolicyIncludeListResponseEnvelopeJSON 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 *DevicePolicyIncludeListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyIncludeListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyIncludeListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyIncludeListResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePolicyIncludeListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [DevicePolicyIncludeListResponseEnvelopeErrors] +type devicePolicyIncludeListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyIncludeListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyIncludeListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyIncludeListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyIncludeListResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePolicyIncludeListResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [DevicePolicyIncludeListResponseEnvelopeMessages] +type devicePolicyIncludeListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyIncludeListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyIncludeListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePolicyIncludeListResponseEnvelopeSuccess bool + +const ( + DevicePolicyIncludeListResponseEnvelopeSuccessTrue DevicePolicyIncludeListResponseEnvelopeSuccess = true +) + +type DevicePolicyIncludeListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON devicePolicyIncludeListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// devicePolicyIncludeListResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [DevicePolicyIncludeListResponseEnvelopeResultInfo] +type devicePolicyIncludeListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyIncludeListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyIncludeListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyIncludeGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DevicePolicyIncludeGetResponseEnvelope struct { + Errors []DevicePolicyIncludeGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePolicyIncludeGetResponseEnvelopeMessages `json:"messages,required"` + Result []TeamsDevicesSplitTunnelInclude `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePolicyIncludeGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DevicePolicyIncludeGetResponseEnvelopeResultInfo `json:"result_info"` + JSON devicePolicyIncludeGetResponseEnvelopeJSON `json:"-"` +} + +// devicePolicyIncludeGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [DevicePolicyIncludeGetResponseEnvelope] +type devicePolicyIncludeGetResponseEnvelopeJSON 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 *DevicePolicyIncludeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyIncludeGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyIncludeGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyIncludeGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePolicyIncludeGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [DevicePolicyIncludeGetResponseEnvelopeErrors] +type devicePolicyIncludeGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyIncludeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyIncludeGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePolicyIncludeGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePolicyIncludeGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePolicyIncludeGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [DevicePolicyIncludeGetResponseEnvelopeMessages] +type devicePolicyIncludeGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyIncludeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyIncludeGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePolicyIncludeGetResponseEnvelopeSuccess bool + +const ( + DevicePolicyIncludeGetResponseEnvelopeSuccessTrue DevicePolicyIncludeGetResponseEnvelopeSuccess = true +) + +type DevicePolicyIncludeGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON devicePolicyIncludeGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// devicePolicyIncludeGetResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [DevicePolicyIncludeGetResponseEnvelopeResultInfo] +type devicePolicyIncludeGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePolicyIncludeGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePolicyIncludeGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/devicepolicyinclude_test.go b/zero_trust/devicepolicyinclude_test.go new file mode 100644 index 00000000000..1ea8a659710 --- /dev/null +++ b/zero_trust/devicepolicyinclude_test.go @@ -0,0 +1,110 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDevicePolicyIncludeUpdate(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Policies.Includes.Update(context.TODO(), zero_trust.DevicePolicyIncludeUpdateParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Body: cloudflare.F([]zero_trust.TeamsDevicesSplitTunnelIncludeParam{{ + Address: cloudflare.F("192.0.2.0/24"), + Description: cloudflare.F("Include testing domains from the tunnel"), + Host: cloudflare.F("*.example.com"), + }, { + Address: cloudflare.F("192.0.2.0/24"), + Description: cloudflare.F("Include testing domains from the tunnel"), + Host: cloudflare.F("*.example.com"), + }, { + Address: cloudflare.F("192.0.2.0/24"), + Description: cloudflare.F("Include testing domains from the tunnel"), + Host: cloudflare.F("*.example.com"), + }}), + }) + 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 TestDevicePolicyIncludeList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Policies.Includes.List(context.TODO(), zero_trust.DevicePolicyIncludeListParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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 TestDevicePolicyIncludeGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Policies.Includes.Get( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DevicePolicyIncludeGetParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/deviceposture.go b/zero_trust/deviceposture.go new file mode 100644 index 00000000000..cb378022fdc --- /dev/null +++ b/zero_trust/deviceposture.go @@ -0,0 +1,2649 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// DevicePostureService 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 [NewDevicePostureService] method +// instead. +type DevicePostureService struct { + Options []option.RequestOption + Integrations *DevicePostureIntegrationService +} + +// NewDevicePostureService 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 NewDevicePostureService(opts ...option.RequestOption) (r *DevicePostureService) { + r = &DevicePostureService{} + r.Options = opts + r.Integrations = NewDevicePostureIntegrationService(opts...) + return +} + +// Creates a new device posture rule. +func (r *DevicePostureService) New(ctx context.Context, params DevicePostureNewParams, opts ...option.RequestOption) (res *TeamsDevicesDevicePostureRules, err error) { + opts = append(r.Options[:], opts...) + var env DevicePostureNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/posture", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a device posture rule. +func (r *DevicePostureService) Update(ctx context.Context, ruleID string, params DevicePostureUpdateParams, opts ...option.RequestOption) (res *TeamsDevicesDevicePostureRules, err error) { + opts = append(r.Options[:], opts...) + var env DevicePostureUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/posture/%s", params.AccountID, ruleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches device posture rules for a Zero Trust account. +func (r *DevicePostureService) List(ctx context.Context, query DevicePostureListParams, opts ...option.RequestOption) (res *[]TeamsDevicesDevicePostureRules, err error) { + opts = append(r.Options[:], opts...) + var env DevicePostureListResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/posture", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a device posture rule. +func (r *DevicePostureService) Delete(ctx context.Context, ruleID string, body DevicePostureDeleteParams, opts ...option.RequestOption) (res *DevicePostureDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env DevicePostureDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/posture/%s", body.AccountID, ruleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a single device posture rule. +func (r *DevicePostureService) Get(ctx context.Context, ruleID string, query DevicePostureGetParams, opts ...option.RequestOption) (res *TeamsDevicesDevicePostureRules, err error) { + opts = append(r.Options[:], opts...) + var env DevicePostureGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/posture/%s", query.AccountID, ruleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TeamsDevicesDevicePostureRules struct { + // API UUID. + ID string `json:"id"` + // The description of the device posture rule. + Description string `json:"description"` + // Sets the expiration time for a posture check result. If empty, the result + // remains valid until it is overwritten by new data from the WARP client. + Expiration string `json:"expiration"` + // The value to be checked against. + Input TeamsDevicesDevicePostureRulesInput `json:"input"` + // The conditions that the client must match to run the rule. + Match []TeamsDevicesDevicePostureRulesMatch `json:"match"` + // The name of the device posture rule. + Name string `json:"name"` + // Polling frequency for the WARP client posture check. Default: `5m` (poll every + // five minutes). Minimum: `1m`. + Schedule string `json:"schedule"` + // The type of device posture rule. + Type TeamsDevicesDevicePostureRulesType `json:"type"` + JSON teamsDevicesDevicePostureRulesJSON `json:"-"` +} + +// teamsDevicesDevicePostureRulesJSON contains the JSON metadata for the struct +// [TeamsDevicesDevicePostureRules] +type teamsDevicesDevicePostureRulesJSON struct { + ID apijson.Field + Description apijson.Field + Expiration apijson.Field + Input apijson.Field + Match apijson.Field + Name apijson.Field + Schedule apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureRules) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureRulesJSON) RawJSON() string { + return r.raw +} + +// The value to be checked against. +// +// Union satisfied by +// [zero_trust.TeamsDevicesDevicePostureRulesInputTeamsDevicesFileInputRequest], +// [zero_trust.TeamsDevicesDevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequest], +// [zero_trust.TeamsDevicesDevicePostureRulesInputTeamsDevicesDomainJoinedInputRequest], +// [zero_trust.TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequest], +// [zero_trust.TeamsDevicesDevicePostureRulesInputTeamsDevicesFirewallInputRequest], +// [zero_trust.TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneInputRequest], +// [zero_trust.TeamsDevicesDevicePostureRulesInputTeamsDevicesCarbonblackInputRequest], +// [zero_trust.TeamsDevicesDevicePostureRulesInputTeamsDevicesDiskEncryptionInputRequest], +// [zero_trust.TeamsDevicesDevicePostureRulesInputTeamsDevicesApplicationInputRequest], +// [zero_trust.TeamsDevicesDevicePostureRulesInputTeamsDevicesClientCertificateInputRequest], +// [zero_trust.TeamsDevicesDevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequest], +// [zero_trust.TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequest], +// [zero_trust.TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequest], +// [zero_trust.TeamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequest], +// [zero_trust.TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequest] +// or +// [zero_trust.TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequest]. +type TeamsDevicesDevicePostureRulesInput interface { + implementsZeroTrustTeamsDevicesDevicePostureRulesInput() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*TeamsDevicesDevicePostureRulesInput)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TeamsDevicesDevicePostureRulesInputTeamsDevicesFileInputRequest{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TeamsDevicesDevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequest{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TeamsDevicesDevicePostureRulesInputTeamsDevicesDomainJoinedInputRequest{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequest{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TeamsDevicesDevicePostureRulesInputTeamsDevicesFirewallInputRequest{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneInputRequest{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TeamsDevicesDevicePostureRulesInputTeamsDevicesCarbonblackInputRequest{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TeamsDevicesDevicePostureRulesInputTeamsDevicesDiskEncryptionInputRequest{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TeamsDevicesDevicePostureRulesInputTeamsDevicesApplicationInputRequest{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TeamsDevicesDevicePostureRulesInputTeamsDevicesClientCertificateInputRequest{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TeamsDevicesDevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequest{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequest{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequest{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TeamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequest{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequest{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequest{}), + }, + ) +} + +type TeamsDevicesDevicePostureRulesInputTeamsDevicesFileInputRequest struct { + // Operating system + OperatingSystem TeamsDevicesDevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystem `json:"operating_system,required"` + // File path. + Path string `json:"path,required"` + // Whether or not file exists + Exists bool `json:"exists"` + // SHA-256. + Sha256 string `json:"sha256"` + // Signing certificate thumbprint. + Thumbprint string `json:"thumbprint"` + JSON teamsDevicesDevicePostureRulesInputTeamsDevicesFileInputRequestJSON `json:"-"` +} + +// teamsDevicesDevicePostureRulesInputTeamsDevicesFileInputRequestJSON contains the +// JSON metadata for the struct +// [TeamsDevicesDevicePostureRulesInputTeamsDevicesFileInputRequest] +type teamsDevicesDevicePostureRulesInputTeamsDevicesFileInputRequestJSON struct { + OperatingSystem apijson.Field + Path apijson.Field + Exists apijson.Field + Sha256 apijson.Field + Thumbprint apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureRulesInputTeamsDevicesFileInputRequest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureRulesInputTeamsDevicesFileInputRequestJSON) RawJSON() string { + return r.raw +} + +func (r TeamsDevicesDevicePostureRulesInputTeamsDevicesFileInputRequest) implementsZeroTrustTeamsDevicesDevicePostureRulesInput() { +} + +// Operating system +type TeamsDevicesDevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystem string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystemWindows TeamsDevicesDevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystem = "windows" + TeamsDevicesDevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystemLinux TeamsDevicesDevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystem = "linux" + TeamsDevicesDevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystemMac TeamsDevicesDevicePostureRulesInputTeamsDevicesFileInputRequestOperatingSystem = "mac" +) + +type TeamsDevicesDevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequest struct { + // List ID. + ID string `json:"id,required"` + // Operating System + OperatingSystem TeamsDevicesDevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem `json:"operating_system,required"` + JSON teamsDevicesDevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestJSON `json:"-"` +} + +// teamsDevicesDevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestJSON +// contains the JSON metadata for the struct +// [TeamsDevicesDevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequest] +type teamsDevicesDevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestJSON struct { + ID apijson.Field + OperatingSystem apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestJSON) RawJSON() string { + return r.raw +} + +func (r TeamsDevicesDevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequest) implementsZeroTrustTeamsDevicesDevicePostureRulesInput() { +} + +// Operating System +type TeamsDevicesDevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemAndroid TeamsDevicesDevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "android" + TeamsDevicesDevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemIos TeamsDevicesDevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "ios" + TeamsDevicesDevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemChromeos TeamsDevicesDevicePostureRulesInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "chromeos" +) + +type TeamsDevicesDevicePostureRulesInputTeamsDevicesDomainJoinedInputRequest struct { + // Operating System + OperatingSystem TeamsDevicesDevicePostureRulesInputTeamsDevicesDomainJoinedInputRequestOperatingSystem `json:"operating_system,required"` + // Domain + Domain string `json:"domain"` + JSON teamsDevicesDevicePostureRulesInputTeamsDevicesDomainJoinedInputRequestJSON `json:"-"` +} + +// teamsDevicesDevicePostureRulesInputTeamsDevicesDomainJoinedInputRequestJSON +// contains the JSON metadata for the struct +// [TeamsDevicesDevicePostureRulesInputTeamsDevicesDomainJoinedInputRequest] +type teamsDevicesDevicePostureRulesInputTeamsDevicesDomainJoinedInputRequestJSON struct { + OperatingSystem apijson.Field + Domain apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureRulesInputTeamsDevicesDomainJoinedInputRequest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureRulesInputTeamsDevicesDomainJoinedInputRequestJSON) RawJSON() string { + return r.raw +} + +func (r TeamsDevicesDevicePostureRulesInputTeamsDevicesDomainJoinedInputRequest) implementsZeroTrustTeamsDevicesDevicePostureRulesInput() { +} + +// Operating System +type TeamsDevicesDevicePostureRulesInputTeamsDevicesDomainJoinedInputRequestOperatingSystem string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesDomainJoinedInputRequestOperatingSystemWindows TeamsDevicesDevicePostureRulesInputTeamsDevicesDomainJoinedInputRequestOperatingSystem = "windows" +) + +type TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequest struct { + // Operating System + OperatingSystem TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatingSystem `json:"operating_system,required"` + // Operator + Operator TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperator `json:"operator,required"` + // Version of OS + Version string `json:"version,required"` + // Operating System Distribution Name (linux only) + OSDistroName string `json:"os_distro_name"` + // Version of OS Distribution (linux only) + OSDistroRevision string `json:"os_distro_revision"` + // Additional version data. For Mac or iOS, the Product Verison Extra. For Linux, + // the kernel release version. (Mac, iOS, and Linux only) + OSVersionExtra string `json:"os_version_extra"` + JSON teamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestJSON `json:"-"` +} + +// teamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestJSON +// contains the JSON metadata for the struct +// [TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequest] +type teamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestJSON struct { + OperatingSystem apijson.Field + Operator apijson.Field + Version apijson.Field + OSDistroName apijson.Field + OSDistroRevision apijson.Field + OSVersionExtra apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestJSON) RawJSON() string { + return r.raw +} + +func (r TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequest) implementsZeroTrustTeamsDevicesDevicePostureRulesInput() { +} + +// Operating System +type TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatingSystem string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatingSystemWindows TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatingSystem = "windows" +) + +// Operator +type TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperator string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatorUnknown5 TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperator = "<" + TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatorUnknown6 TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperator = "<=" + TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatorUnknown7 TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperator = ">" + TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatorUnknown8 TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperator = ">=" + TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperatorUnknown9 TeamsDevicesDevicePostureRulesInputTeamsDevicesOSVersionInputRequestOperator = "==" +) + +type TeamsDevicesDevicePostureRulesInputTeamsDevicesFirewallInputRequest struct { + // Enabled + Enabled bool `json:"enabled,required"` + // Operating System + OperatingSystem TeamsDevicesDevicePostureRulesInputTeamsDevicesFirewallInputRequestOperatingSystem `json:"operating_system,required"` + JSON teamsDevicesDevicePostureRulesInputTeamsDevicesFirewallInputRequestJSON `json:"-"` +} + +// teamsDevicesDevicePostureRulesInputTeamsDevicesFirewallInputRequestJSON contains +// the JSON metadata for the struct +// [TeamsDevicesDevicePostureRulesInputTeamsDevicesFirewallInputRequest] +type teamsDevicesDevicePostureRulesInputTeamsDevicesFirewallInputRequestJSON struct { + Enabled apijson.Field + OperatingSystem apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureRulesInputTeamsDevicesFirewallInputRequest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureRulesInputTeamsDevicesFirewallInputRequestJSON) RawJSON() string { + return r.raw +} + +func (r TeamsDevicesDevicePostureRulesInputTeamsDevicesFirewallInputRequest) implementsZeroTrustTeamsDevicesDevicePostureRulesInput() { +} + +// Operating System +type TeamsDevicesDevicePostureRulesInputTeamsDevicesFirewallInputRequestOperatingSystem string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesFirewallInputRequestOperatingSystemWindows TeamsDevicesDevicePostureRulesInputTeamsDevicesFirewallInputRequestOperatingSystem = "windows" + TeamsDevicesDevicePostureRulesInputTeamsDevicesFirewallInputRequestOperatingSystemMac TeamsDevicesDevicePostureRulesInputTeamsDevicesFirewallInputRequestOperatingSystem = "mac" +) + +type TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneInputRequest struct { + // Operating system + OperatingSystem TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystem `json:"operating_system,required"` + // File path. + Path string `json:"path,required"` + // SHA-256. + Sha256 string `json:"sha256"` + // Signing certificate thumbprint. + Thumbprint string `json:"thumbprint"` + JSON teamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneInputRequestJSON `json:"-"` +} + +// teamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneInputRequestJSON +// contains the JSON metadata for the struct +// [TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneInputRequest] +type teamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneInputRequestJSON struct { + OperatingSystem apijson.Field + Path apijson.Field + Sha256 apijson.Field + Thumbprint apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneInputRequest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneInputRequestJSON) RawJSON() string { + return r.raw +} + +func (r TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneInputRequest) implementsZeroTrustTeamsDevicesDevicePostureRulesInput() { +} + +// Operating system +type TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystem string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystemWindows TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystem = "windows" + TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystemLinux TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystem = "linux" + TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystemMac TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneInputRequestOperatingSystem = "mac" +) + +type TeamsDevicesDevicePostureRulesInputTeamsDevicesCarbonblackInputRequest struct { + // Operating system + OperatingSystem TeamsDevicesDevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystem `json:"operating_system,required"` + // File path. + Path string `json:"path,required"` + // SHA-256. + Sha256 string `json:"sha256"` + // Signing certificate thumbprint. + Thumbprint string `json:"thumbprint"` + JSON teamsDevicesDevicePostureRulesInputTeamsDevicesCarbonblackInputRequestJSON `json:"-"` +} + +// teamsDevicesDevicePostureRulesInputTeamsDevicesCarbonblackInputRequestJSON +// contains the JSON metadata for the struct +// [TeamsDevicesDevicePostureRulesInputTeamsDevicesCarbonblackInputRequest] +type teamsDevicesDevicePostureRulesInputTeamsDevicesCarbonblackInputRequestJSON struct { + OperatingSystem apijson.Field + Path apijson.Field + Sha256 apijson.Field + Thumbprint apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureRulesInputTeamsDevicesCarbonblackInputRequest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureRulesInputTeamsDevicesCarbonblackInputRequestJSON) RawJSON() string { + return r.raw +} + +func (r TeamsDevicesDevicePostureRulesInputTeamsDevicesCarbonblackInputRequest) implementsZeroTrustTeamsDevicesDevicePostureRulesInput() { +} + +// Operating system +type TeamsDevicesDevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystem string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystemWindows TeamsDevicesDevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "windows" + TeamsDevicesDevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystemLinux TeamsDevicesDevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "linux" + TeamsDevicesDevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystemMac TeamsDevicesDevicePostureRulesInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "mac" +) + +type TeamsDevicesDevicePostureRulesInputTeamsDevicesDiskEncryptionInputRequest struct { + // List of volume names to be checked for encryption. + CheckDisks []string `json:"checkDisks"` + // Whether to check all disks for encryption. + RequireAll bool `json:"requireAll"` + JSON teamsDevicesDevicePostureRulesInputTeamsDevicesDiskEncryptionInputRequestJSON `json:"-"` +} + +// teamsDevicesDevicePostureRulesInputTeamsDevicesDiskEncryptionInputRequestJSON +// contains the JSON metadata for the struct +// [TeamsDevicesDevicePostureRulesInputTeamsDevicesDiskEncryptionInputRequest] +type teamsDevicesDevicePostureRulesInputTeamsDevicesDiskEncryptionInputRequestJSON struct { + CheckDisks apijson.Field + RequireAll apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureRulesInputTeamsDevicesDiskEncryptionInputRequest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureRulesInputTeamsDevicesDiskEncryptionInputRequestJSON) RawJSON() string { + return r.raw +} + +func (r TeamsDevicesDevicePostureRulesInputTeamsDevicesDiskEncryptionInputRequest) implementsZeroTrustTeamsDevicesDevicePostureRulesInput() { +} + +type TeamsDevicesDevicePostureRulesInputTeamsDevicesApplicationInputRequest struct { + // Operating system + OperatingSystem TeamsDevicesDevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystem `json:"operating_system,required"` + // Path for the application. + Path string `json:"path,required"` + // SHA-256. + Sha256 string `json:"sha256"` + // Signing certificate thumbprint. + Thumbprint string `json:"thumbprint"` + JSON teamsDevicesDevicePostureRulesInputTeamsDevicesApplicationInputRequestJSON `json:"-"` +} + +// teamsDevicesDevicePostureRulesInputTeamsDevicesApplicationInputRequestJSON +// contains the JSON metadata for the struct +// [TeamsDevicesDevicePostureRulesInputTeamsDevicesApplicationInputRequest] +type teamsDevicesDevicePostureRulesInputTeamsDevicesApplicationInputRequestJSON struct { + OperatingSystem apijson.Field + Path apijson.Field + Sha256 apijson.Field + Thumbprint apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureRulesInputTeamsDevicesApplicationInputRequest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureRulesInputTeamsDevicesApplicationInputRequestJSON) RawJSON() string { + return r.raw +} + +func (r TeamsDevicesDevicePostureRulesInputTeamsDevicesApplicationInputRequest) implementsZeroTrustTeamsDevicesDevicePostureRulesInput() { +} + +// Operating system +type TeamsDevicesDevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystem string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystemWindows TeamsDevicesDevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystem = "windows" + TeamsDevicesDevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystemLinux TeamsDevicesDevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystem = "linux" + TeamsDevicesDevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystemMac TeamsDevicesDevicePostureRulesInputTeamsDevicesApplicationInputRequestOperatingSystem = "mac" +) + +type TeamsDevicesDevicePostureRulesInputTeamsDevicesClientCertificateInputRequest struct { + // UUID of Cloudflare managed certificate. + CertificateID string `json:"certificate_id,required"` + // Common Name that is protected by the certificate + Cn string `json:"cn,required"` + JSON teamsDevicesDevicePostureRulesInputTeamsDevicesClientCertificateInputRequestJSON `json:"-"` +} + +// teamsDevicesDevicePostureRulesInputTeamsDevicesClientCertificateInputRequestJSON +// contains the JSON metadata for the struct +// [TeamsDevicesDevicePostureRulesInputTeamsDevicesClientCertificateInputRequest] +type teamsDevicesDevicePostureRulesInputTeamsDevicesClientCertificateInputRequestJSON struct { + CertificateID apijson.Field + Cn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureRulesInputTeamsDevicesClientCertificateInputRequest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureRulesInputTeamsDevicesClientCertificateInputRequestJSON) RawJSON() string { + return r.raw +} + +func (r TeamsDevicesDevicePostureRulesInputTeamsDevicesClientCertificateInputRequest) implementsZeroTrustTeamsDevicesDevicePostureRulesInput() { +} + +type TeamsDevicesDevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequest struct { + // Compliance Status + ComplianceStatus TeamsDevicesDevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus `json:"compliance_status,required"` + // Posture Integration ID. + ConnectionID string `json:"connection_id,required"` + JSON teamsDevicesDevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestJSON `json:"-"` +} + +// teamsDevicesDevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestJSON +// contains the JSON metadata for the struct +// [TeamsDevicesDevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequest] +type teamsDevicesDevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestJSON struct { + ComplianceStatus apijson.Field + ConnectionID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestJSON) RawJSON() string { + return r.raw +} + +func (r TeamsDevicesDevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequest) implementsZeroTrustTeamsDevicesDevicePostureRulesInput() { +} + +// Compliance Status +type TeamsDevicesDevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusCompliant TeamsDevicesDevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "compliant" + TeamsDevicesDevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusNoncompliant TeamsDevicesDevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "noncompliant" + TeamsDevicesDevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusUnknown TeamsDevicesDevicePostureRulesInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "unknown" +) + +type TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequest struct { + // Posture Integration ID. + ConnectionID string `json:"connection_id,required"` + // For more details on last seen, please refer to the Crowdstrike documentation. + LastSeen string `json:"last_seen"` + // Operator + Operator TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperator `json:"operator"` + // Os Version + OS string `json:"os"` + // overall + Overall string `json:"overall"` + // SensorConfig + SensorConfig string `json:"sensor_config"` + // For more details on state, please refer to the Crowdstrike documentation. + State TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestState `json:"state"` + // Version + Version string `json:"version"` + // Version Operator + VersionOperator TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperator `json:"versionOperator"` + JSON teamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestJSON `json:"-"` +} + +// teamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestJSON +// contains the JSON metadata for the struct +// [TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequest] +type teamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestJSON struct { + ConnectionID apijson.Field + LastSeen apijson.Field + Operator apijson.Field + OS apijson.Field + Overall apijson.Field + SensorConfig apijson.Field + State apijson.Field + Version apijson.Field + VersionOperator apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestJSON) RawJSON() string { + return r.raw +} + +func (r TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequest) implementsZeroTrustTeamsDevicesDevicePostureRulesInput() { +} + +// Operator +type TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperator string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown15 TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperator = "<" + TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown16 TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperator = "<=" + TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown17 TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperator = ">" + TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown18 TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperator = ">=" + TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown19 TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestOperator = "==" +) + +// For more details on state, please refer to the Crowdstrike documentation. +type TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestState string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestStateOnline TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestState = "online" + TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestStateOffline TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestState = "offline" + TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestStateUnknown TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestState = "unknown" +) + +// Version Operator +type TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperator string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown25 TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<" + TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown26 TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<=" + TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown27 TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">" + TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown28 TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">=" + TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown29 TeamsDevicesDevicePostureRulesInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "==" +) + +type TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequest struct { + // Compliance Status + ComplianceStatus TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatus `json:"compliance_status,required"` + // Posture Integration ID. + ConnectionID string `json:"connection_id,required"` + JSON teamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequestJSON `json:"-"` +} + +// teamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequestJSON contains +// the JSON metadata for the struct +// [TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequest] +type teamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequestJSON struct { + ComplianceStatus apijson.Field + ConnectionID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequestJSON) RawJSON() string { + return r.raw +} + +func (r TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequest) implementsZeroTrustTeamsDevicesDevicePostureRulesInput() { +} + +// Compliance Status +type TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatus string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatusCompliant TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatus = "compliant" + TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatusNoncompliant TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatus = "noncompliant" + TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatusUnknown TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatus = "unknown" + TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatusNotapplicable TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatus = "notapplicable" + TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatusIngraceperiod TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatus = "ingraceperiod" + TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatusError TeamsDevicesDevicePostureRulesInputTeamsDevicesIntuneInputRequestComplianceStatus = "error" +) + +type TeamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequest struct { + // Posture Integration ID. + ConnectionID string `json:"connection_id,required"` + // Count Operator + CountOperator TeamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperator `json:"countOperator,required"` + // The Number of Issues. + IssueCount string `json:"issue_count,required"` + JSON teamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequestJSON `json:"-"` +} + +// teamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequestJSON contains +// the JSON metadata for the struct +// [TeamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequest] +type teamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequestJSON struct { + ConnectionID apijson.Field + CountOperator apijson.Field + IssueCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequestJSON) RawJSON() string { + return r.raw +} + +func (r TeamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequest) implementsZeroTrustTeamsDevicesDevicePostureRulesInput() { +} + +// Count Operator +type TeamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperator string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperatorUnknown35 TeamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperator = "<" + TeamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperatorUnknown36 TeamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperator = "<=" + TeamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperatorUnknown37 TeamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperator = ">" + TeamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperatorUnknown38 TeamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperator = ">=" + TeamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperatorUnknown39 TeamsDevicesDevicePostureRulesInputTeamsDevicesKolideInputRequestCountOperator = "==" +) + +type TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequest struct { + // Posture Integration ID. + ConnectionID string `json:"connection_id,required"` + // For more details on eid last seen, refer to the Tanium documentation. + EidLastSeen string `json:"eid_last_seen"` + // Operator to evaluate risk_level or eid_last_seen. + Operator TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestOperator `json:"operator"` + // For more details on risk level, refer to the Tanium documentation. + RiskLevel TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevel `json:"risk_level"` + // Score Operator + ScoreOperator TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperator `json:"scoreOperator"` + // For more details on total score, refer to the Tanium documentation. + TotalScore float64 `json:"total_score"` + JSON teamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestJSON `json:"-"` +} + +// teamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestJSON contains +// the JSON metadata for the struct +// [TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequest] +type teamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestJSON struct { + ConnectionID apijson.Field + EidLastSeen apijson.Field + Operator apijson.Field + RiskLevel apijson.Field + ScoreOperator apijson.Field + TotalScore apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestJSON) RawJSON() string { + return r.raw +} + +func (r TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequest) implementsZeroTrustTeamsDevicesDevicePostureRulesInput() { +} + +// Operator to evaluate risk_level or eid_last_seen. +type TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestOperator string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestOperatorUnknown45 TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestOperator = "<" + TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestOperatorUnknown46 TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestOperator = "<=" + TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestOperatorUnknown47 TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestOperator = ">" + TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestOperatorUnknown48 TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestOperator = ">=" + TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestOperatorUnknown49 TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestOperator = "==" +) + +// For more details on risk level, refer to the Tanium documentation. +type TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevel string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevelLow TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevel = "low" + TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevelMedium TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevel = "medium" + TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevelHigh TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevel = "high" + TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevelCritical TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestRiskLevel = "critical" +) + +// Score Operator +type TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperator string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown55 TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperator = "<" + TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown56 TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperator = "<=" + TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown57 TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperator = ">" + TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown58 TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperator = ">=" + TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown59 TeamsDevicesDevicePostureRulesInputTeamsDevicesTaniumInputRequestScoreOperator = "==" +) + +type TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequest struct { + // Posture Integration ID. + ConnectionID string `json:"connection_id,required"` + // The Number of active threats. + ActiveThreats float64 `json:"active_threats"` + // Whether device is infected. + Infected bool `json:"infected"` + // Whether device is active. + IsActive bool `json:"is_active"` + // Network status of device. + NetworkStatus TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus `json:"network_status"` + // operator + Operator TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperator `json:"operator"` + JSON teamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestJSON `json:"-"` +} + +// teamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestJSON +// contains the JSON metadata for the struct +// [TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequest] +type teamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestJSON struct { + ConnectionID apijson.Field + ActiveThreats apijson.Field + Infected apijson.Field + IsActive apijson.Field + NetworkStatus apijson.Field + Operator apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestJSON) RawJSON() string { + return r.raw +} + +func (r TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequest) implementsZeroTrustTeamsDevicesDevicePostureRulesInput() { +} + +// Network status of device. +type TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnected TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connected" + TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnected TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnected" + TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnecting TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnecting" + TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnecting TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connecting" +) + +// operator +type TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperator string + +const ( + TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown65 TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperator = "<" + TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown66 TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperator = "<=" + TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown67 TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperator = ">" + TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown68 TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperator = ">=" + TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown69 TeamsDevicesDevicePostureRulesInputTeamsDevicesSentineloneS2sInputRequestOperator = "==" +) + +type TeamsDevicesDevicePostureRulesMatch struct { + Platform TeamsDevicesDevicePostureRulesMatchPlatform `json:"platform"` + JSON teamsDevicesDevicePostureRulesMatchJSON `json:"-"` +} + +// teamsDevicesDevicePostureRulesMatchJSON contains the JSON metadata for the +// struct [TeamsDevicesDevicePostureRulesMatch] +type teamsDevicesDevicePostureRulesMatchJSON struct { + Platform apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureRulesMatch) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureRulesMatchJSON) RawJSON() string { + return r.raw +} + +type TeamsDevicesDevicePostureRulesMatchPlatform string + +const ( + TeamsDevicesDevicePostureRulesMatchPlatformWindows TeamsDevicesDevicePostureRulesMatchPlatform = "windows" + TeamsDevicesDevicePostureRulesMatchPlatformMac TeamsDevicesDevicePostureRulesMatchPlatform = "mac" + TeamsDevicesDevicePostureRulesMatchPlatformLinux TeamsDevicesDevicePostureRulesMatchPlatform = "linux" + TeamsDevicesDevicePostureRulesMatchPlatformAndroid TeamsDevicesDevicePostureRulesMatchPlatform = "android" + TeamsDevicesDevicePostureRulesMatchPlatformIos TeamsDevicesDevicePostureRulesMatchPlatform = "ios" +) + +// The type of device posture rule. +type TeamsDevicesDevicePostureRulesType string + +const ( + TeamsDevicesDevicePostureRulesTypeFile TeamsDevicesDevicePostureRulesType = "file" + TeamsDevicesDevicePostureRulesTypeApplication TeamsDevicesDevicePostureRulesType = "application" + TeamsDevicesDevicePostureRulesTypeTanium TeamsDevicesDevicePostureRulesType = "tanium" + TeamsDevicesDevicePostureRulesTypeGateway TeamsDevicesDevicePostureRulesType = "gateway" + TeamsDevicesDevicePostureRulesTypeWARP TeamsDevicesDevicePostureRulesType = "warp" + TeamsDevicesDevicePostureRulesTypeDiskEncryption TeamsDevicesDevicePostureRulesType = "disk_encryption" + TeamsDevicesDevicePostureRulesTypeSentinelone TeamsDevicesDevicePostureRulesType = "sentinelone" + TeamsDevicesDevicePostureRulesTypeCarbonblack TeamsDevicesDevicePostureRulesType = "carbonblack" + TeamsDevicesDevicePostureRulesTypeFirewall TeamsDevicesDevicePostureRulesType = "firewall" + TeamsDevicesDevicePostureRulesTypeOSVersion TeamsDevicesDevicePostureRulesType = "os_version" + TeamsDevicesDevicePostureRulesTypeDomainJoined TeamsDevicesDevicePostureRulesType = "domain_joined" + TeamsDevicesDevicePostureRulesTypeClientCertificate TeamsDevicesDevicePostureRulesType = "client_certificate" + TeamsDevicesDevicePostureRulesTypeUniqueClientID TeamsDevicesDevicePostureRulesType = "unique_client_id" + TeamsDevicesDevicePostureRulesTypeKolide TeamsDevicesDevicePostureRulesType = "kolide" + TeamsDevicesDevicePostureRulesTypeTaniumS2s TeamsDevicesDevicePostureRulesType = "tanium_s2s" + TeamsDevicesDevicePostureRulesTypeCrowdstrikeS2s TeamsDevicesDevicePostureRulesType = "crowdstrike_s2s" + TeamsDevicesDevicePostureRulesTypeIntune TeamsDevicesDevicePostureRulesType = "intune" + TeamsDevicesDevicePostureRulesTypeWorkspaceOne TeamsDevicesDevicePostureRulesType = "workspace_one" + TeamsDevicesDevicePostureRulesTypeSentineloneS2s TeamsDevicesDevicePostureRulesType = "sentinelone_s2s" +) + +type DevicePostureDeleteResponse struct { + // API UUID. + ID string `json:"id"` + JSON devicePostureDeleteResponseJSON `json:"-"` +} + +// devicePostureDeleteResponseJSON contains the JSON metadata for the struct +// [DevicePostureDeleteResponse] +type devicePostureDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type DevicePostureNewParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // The name of the device posture rule. + Name param.Field[string] `json:"name,required"` + // The type of device posture rule. + Type param.Field[DevicePostureNewParamsType] `json:"type,required"` + // The description of the device posture rule. + Description param.Field[string] `json:"description"` + // Sets the expiration time for a posture check result. If empty, the result + // remains valid until it is overwritten by new data from the WARP client. + Expiration param.Field[string] `json:"expiration"` + // The value to be checked against. + Input param.Field[DevicePostureNewParamsInput] `json:"input"` + // The conditions that the client must match to run the rule. + Match param.Field[[]DevicePostureNewParamsMatch] `json:"match"` + // Polling frequency for the WARP client posture check. Default: `5m` (poll every + // five minutes). Minimum: `1m`. + Schedule param.Field[string] `json:"schedule"` +} + +func (r DevicePostureNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of device posture rule. +type DevicePostureNewParamsType string + +const ( + DevicePostureNewParamsTypeFile DevicePostureNewParamsType = "file" + DevicePostureNewParamsTypeApplication DevicePostureNewParamsType = "application" + DevicePostureNewParamsTypeTanium DevicePostureNewParamsType = "tanium" + DevicePostureNewParamsTypeGateway DevicePostureNewParamsType = "gateway" + DevicePostureNewParamsTypeWARP DevicePostureNewParamsType = "warp" + DevicePostureNewParamsTypeDiskEncryption DevicePostureNewParamsType = "disk_encryption" + DevicePostureNewParamsTypeSentinelone DevicePostureNewParamsType = "sentinelone" + DevicePostureNewParamsTypeCarbonblack DevicePostureNewParamsType = "carbonblack" + DevicePostureNewParamsTypeFirewall DevicePostureNewParamsType = "firewall" + DevicePostureNewParamsTypeOSVersion DevicePostureNewParamsType = "os_version" + DevicePostureNewParamsTypeDomainJoined DevicePostureNewParamsType = "domain_joined" + DevicePostureNewParamsTypeClientCertificate DevicePostureNewParamsType = "client_certificate" + DevicePostureNewParamsTypeUniqueClientID DevicePostureNewParamsType = "unique_client_id" + DevicePostureNewParamsTypeKolide DevicePostureNewParamsType = "kolide" + DevicePostureNewParamsTypeTaniumS2s DevicePostureNewParamsType = "tanium_s2s" + DevicePostureNewParamsTypeCrowdstrikeS2s DevicePostureNewParamsType = "crowdstrike_s2s" + DevicePostureNewParamsTypeIntune DevicePostureNewParamsType = "intune" + DevicePostureNewParamsTypeWorkspaceOne DevicePostureNewParamsType = "workspace_one" + DevicePostureNewParamsTypeSentineloneS2s DevicePostureNewParamsType = "sentinelone_s2s" +) + +// The value to be checked against. +// +// Satisfied by +// [zero_trust.DevicePostureNewParamsInputTeamsDevicesFileInputRequest], +// [zero_trust.DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequest], +// [zero_trust.DevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequest], +// [zero_trust.DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequest], +// [zero_trust.DevicePostureNewParamsInputTeamsDevicesFirewallInputRequest], +// [zero_trust.DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequest], +// [zero_trust.DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequest], +// [zero_trust.DevicePostureNewParamsInputTeamsDevicesDiskEncryptionInputRequest], +// [zero_trust.DevicePostureNewParamsInputTeamsDevicesApplicationInputRequest], +// [zero_trust.DevicePostureNewParamsInputTeamsDevicesClientCertificateInputRequest], +// [zero_trust.DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequest], +// [zero_trust.DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequest], +// [zero_trust.DevicePostureNewParamsInputTeamsDevicesIntuneInputRequest], +// [zero_trust.DevicePostureNewParamsInputTeamsDevicesKolideInputRequest], +// [zero_trust.DevicePostureNewParamsInputTeamsDevicesTaniumInputRequest], +// [zero_trust.DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequest]. +type DevicePostureNewParamsInput interface { + implementsZeroTrustDevicePostureNewParamsInput() +} + +type DevicePostureNewParamsInputTeamsDevicesFileInputRequest struct { + // Operating system + OperatingSystem param.Field[DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystem] `json:"operating_system,required"` + // File path. + Path param.Field[string] `json:"path,required"` + // Whether or not file exists + Exists param.Field[bool] `json:"exists"` + // SHA-256. + Sha256 param.Field[string] `json:"sha256"` + // Signing certificate thumbprint. + Thumbprint param.Field[string] `json:"thumbprint"` +} + +func (r DevicePostureNewParamsInputTeamsDevicesFileInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureNewParamsInputTeamsDevicesFileInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { +} + +// Operating system +type DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystem string + +const ( + DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystemWindows DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystem = "windows" + DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystemLinux DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystem = "linux" + DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystemMac DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystem = "mac" +) + +type DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequest struct { + // List ID. + ID param.Field[string] `json:"id,required"` + // Operating System + OperatingSystem param.Field[DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem] `json:"operating_system,required"` +} + +func (r DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { +} + +// Operating System +type DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem string + +const ( + DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemAndroid DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "android" + DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemIos DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "ios" + DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemChromeos DevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "chromeos" +) + +type DevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequest struct { + // Operating System + OperatingSystem param.Field[DevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem] `json:"operating_system,required"` + // Domain + Domain param.Field[string] `json:"domain"` +} + +func (r DevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { +} + +// Operating System +type DevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem string + +const ( + DevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystemWindows DevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem = "windows" +) + +type DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequest struct { + // Operating System + OperatingSystem param.Field[DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem] `json:"operating_system,required"` + // Operator + Operator param.Field[DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator] `json:"operator,required"` + // Version of OS + Version param.Field[string] `json:"version,required"` + // Operating System Distribution Name (linux only) + OSDistroName param.Field[string] `json:"os_distro_name"` + // Version of OS Distribution (linux only) + OSDistroRevision param.Field[string] `json:"os_distro_revision"` + // Additional version data. For Mac or iOS, the Product Verison Extra. For Linux, + // the kernel release version. (Mac, iOS, and Linux only) + OSVersionExtra param.Field[string] `json:"os_version_extra"` +} + +func (r DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { +} + +// Operating System +type DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem string + +const ( + DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatingSystemWindows DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem = "windows" +) + +// Operator +type DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator string + +const ( + DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown75 DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator = "<" + DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown76 DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator = "<=" + DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown77 DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator = ">" + DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown78 DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator = ">=" + DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown79 DevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator = "==" +) + +type DevicePostureNewParamsInputTeamsDevicesFirewallInputRequest struct { + // Enabled + Enabled param.Field[bool] `json:"enabled,required"` + // Operating System + OperatingSystem param.Field[DevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystem] `json:"operating_system,required"` +} + +func (r DevicePostureNewParamsInputTeamsDevicesFirewallInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureNewParamsInputTeamsDevicesFirewallInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { +} + +// Operating System +type DevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystem string + +const ( + DevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystemWindows DevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystem = "windows" + DevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystemMac DevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystem = "mac" +) + +type DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequest struct { + // Operating system + OperatingSystem param.Field[DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem] `json:"operating_system,required"` + // File path. + Path param.Field[string] `json:"path,required"` + // SHA-256. + Sha256 param.Field[string] `json:"sha256"` + // Signing certificate thumbprint. + Thumbprint param.Field[string] `json:"thumbprint"` +} + +func (r DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { +} + +// Operating system +type DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem string + +const ( + DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemWindows DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem = "windows" + DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemLinux DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem = "linux" + DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemMac DevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem = "mac" +) + +type DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequest struct { + // Operating system + OperatingSystem param.Field[DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem] `json:"operating_system,required"` + // File path. + Path param.Field[string] `json:"path,required"` + // SHA-256. + Sha256 param.Field[string] `json:"sha256"` + // Signing certificate thumbprint. + Thumbprint param.Field[string] `json:"thumbprint"` +} + +func (r DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { +} + +// Operating system +type DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem string + +const ( + DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemWindows DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "windows" + DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemLinux DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "linux" + DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemMac DevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "mac" +) + +type DevicePostureNewParamsInputTeamsDevicesDiskEncryptionInputRequest struct { + // List of volume names to be checked for encryption. + CheckDisks param.Field[[]string] `json:"checkDisks"` + // Whether to check all disks for encryption. + RequireAll param.Field[bool] `json:"requireAll"` +} + +func (r DevicePostureNewParamsInputTeamsDevicesDiskEncryptionInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureNewParamsInputTeamsDevicesDiskEncryptionInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { +} + +type DevicePostureNewParamsInputTeamsDevicesApplicationInputRequest struct { + // Operating system + OperatingSystem param.Field[DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystem] `json:"operating_system,required"` + // Path for the application. + Path param.Field[string] `json:"path,required"` + // SHA-256. + Sha256 param.Field[string] `json:"sha256"` + // Signing certificate thumbprint. + Thumbprint param.Field[string] `json:"thumbprint"` +} + +func (r DevicePostureNewParamsInputTeamsDevicesApplicationInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureNewParamsInputTeamsDevicesApplicationInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { +} + +// Operating system +type DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystem string + +const ( + DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystemWindows DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystem = "windows" + DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystemLinux DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystem = "linux" + DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystemMac DevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystem = "mac" +) + +type DevicePostureNewParamsInputTeamsDevicesClientCertificateInputRequest struct { + // UUID of Cloudflare managed certificate. + CertificateID param.Field[string] `json:"certificate_id,required"` + // Common Name that is protected by the certificate + Cn param.Field[string] `json:"cn,required"` +} + +func (r DevicePostureNewParamsInputTeamsDevicesClientCertificateInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureNewParamsInputTeamsDevicesClientCertificateInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { +} + +type DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequest struct { + // Compliance Status + ComplianceStatus param.Field[DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus] `json:"compliance_status,required"` + // Posture Integration ID. + ConnectionID param.Field[string] `json:"connection_id,required"` +} + +func (r DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { +} + +// Compliance Status +type DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus string + +const ( + DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusCompliant DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "compliant" + DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusNoncompliant DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "noncompliant" + DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusUnknown DevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "unknown" +) + +type DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequest struct { + // Posture Integration ID. + ConnectionID param.Field[string] `json:"connection_id,required"` + // For more details on last seen, please refer to the Crowdstrike documentation. + LastSeen param.Field[string] `json:"last_seen"` + // Operator + Operator param.Field[DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator] `json:"operator"` + // Os Version + OS param.Field[string] `json:"os"` + // overall + Overall param.Field[string] `json:"overall"` + // SensorConfig + SensorConfig param.Field[string] `json:"sensor_config"` + // For more details on state, please refer to the Crowdstrike documentation. + State param.Field[DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestState] `json:"state"` + // Version + Version param.Field[string] `json:"version"` + // Version Operator + VersionOperator param.Field[DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator] `json:"versionOperator"` +} + +func (r DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { +} + +// Operator +type DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator string + +const ( + DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown85 DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = "<" + DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown86 DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = "<=" + DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown87 DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = ">" + DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown88 DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = ">=" + DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown89 DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = "==" +) + +// For more details on state, please refer to the Crowdstrike documentation. +type DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestState string + +const ( + DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestStateOnline DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestState = "online" + DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestStateOffline DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestState = "offline" + DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestStateUnknown DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestState = "unknown" +) + +// Version Operator +type DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator string + +const ( + DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown95 DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<" + DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown96 DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<=" + DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown97 DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">" + DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown98 DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">=" + DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown99 DevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "==" +) + +type DevicePostureNewParamsInputTeamsDevicesIntuneInputRequest struct { + // Compliance Status + ComplianceStatus param.Field[DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus] `json:"compliance_status,required"` + // Posture Integration ID. + ConnectionID param.Field[string] `json:"connection_id,required"` +} + +func (r DevicePostureNewParamsInputTeamsDevicesIntuneInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureNewParamsInputTeamsDevicesIntuneInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { +} + +// Compliance Status +type DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus string + +const ( + DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusCompliant DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "compliant" + DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusNoncompliant DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "noncompliant" + DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusUnknown DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "unknown" + DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusNotapplicable DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "notapplicable" + DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusIngraceperiod DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "ingraceperiod" + DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusError DevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "error" +) + +type DevicePostureNewParamsInputTeamsDevicesKolideInputRequest struct { + // Posture Integration ID. + ConnectionID param.Field[string] `json:"connection_id,required"` + // Count Operator + CountOperator param.Field[DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator] `json:"countOperator,required"` + // The Number of Issues. + IssueCount param.Field[string] `json:"issue_count,required"` +} + +func (r DevicePostureNewParamsInputTeamsDevicesKolideInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureNewParamsInputTeamsDevicesKolideInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { +} + +// Count Operator +type DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator string + +const ( + DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown105 DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator = "<" + DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown106 DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator = "<=" + DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown107 DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator = ">" + DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown108 DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator = ">=" + DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown109 DevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator = "==" +) + +type DevicePostureNewParamsInputTeamsDevicesTaniumInputRequest struct { + // Posture Integration ID. + ConnectionID param.Field[string] `json:"connection_id,required"` + // For more details on eid last seen, refer to the Tanium documentation. + EidLastSeen param.Field[string] `json:"eid_last_seen"` + // Operator to evaluate risk_level or eid_last_seen. + Operator param.Field[DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator] `json:"operator"` + // For more details on risk level, refer to the Tanium documentation. + RiskLevel param.Field[DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel] `json:"risk_level"` + // Score Operator + ScoreOperator param.Field[DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator] `json:"scoreOperator"` + // For more details on total score, refer to the Tanium documentation. + TotalScore param.Field[float64] `json:"total_score"` +} + +func (r DevicePostureNewParamsInputTeamsDevicesTaniumInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureNewParamsInputTeamsDevicesTaniumInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { +} + +// Operator to evaluate risk_level or eid_last_seen. +type DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator string + +const ( + DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown115 DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator = "<" + DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown116 DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator = "<=" + DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown117 DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator = ">" + DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown118 DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator = ">=" + DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown119 DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator = "==" +) + +// For more details on risk level, refer to the Tanium documentation. +type DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel string + +const ( + DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevelLow DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "low" + DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevelMedium DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "medium" + DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevelHigh DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "high" + DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevelCritical DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "critical" +) + +// Score Operator +type DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator string + +const ( + DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown125 DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator = "<" + DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown126 DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator = "<=" + DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown127 DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator = ">" + DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown128 DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator = ">=" + DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown129 DevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator = "==" +) + +type DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequest struct { + // Posture Integration ID. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The Number of active threats. + ActiveThreats param.Field[float64] `json:"active_threats"` + // Whether device is infected. + Infected param.Field[bool] `json:"infected"` + // Whether device is active. + IsActive param.Field[bool] `json:"is_active"` + // Network status of device. + NetworkStatus param.Field[DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus] `json:"network_status"` + // operator + Operator param.Field[DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator] `json:"operator"` +} + +func (r DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { +} + +// Network status of device. +type DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus string + +const ( + DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnected DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connected" + DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnected DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnected" + DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnecting DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnecting" + DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnecting DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connecting" +) + +// operator +type DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator string + +const ( + DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown135 DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = "<" + DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown136 DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = "<=" + DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown137 DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = ">" + DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown138 DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = ">=" + DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown139 DevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = "==" +) + +type DevicePostureNewParamsMatch struct { + Platform param.Field[DevicePostureNewParamsMatchPlatform] `json:"platform"` +} + +func (r DevicePostureNewParamsMatch) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DevicePostureNewParamsMatchPlatform string + +const ( + DevicePostureNewParamsMatchPlatformWindows DevicePostureNewParamsMatchPlatform = "windows" + DevicePostureNewParamsMatchPlatformMac DevicePostureNewParamsMatchPlatform = "mac" + DevicePostureNewParamsMatchPlatformLinux DevicePostureNewParamsMatchPlatform = "linux" + DevicePostureNewParamsMatchPlatformAndroid DevicePostureNewParamsMatchPlatform = "android" + DevicePostureNewParamsMatchPlatformIos DevicePostureNewParamsMatchPlatform = "ios" +) + +type DevicePostureNewResponseEnvelope struct { + Errors []DevicePostureNewResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePostureNewResponseEnvelopeMessages `json:"messages,required"` + Result TeamsDevicesDevicePostureRules `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePostureNewResponseEnvelopeSuccess `json:"success,required"` + JSON devicePostureNewResponseEnvelopeJSON `json:"-"` +} + +// devicePostureNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [DevicePostureNewResponseEnvelope] +type devicePostureNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePostureNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePostureNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DevicePostureNewResponseEnvelopeErrors] +type devicePostureNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePostureNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePostureNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DevicePostureNewResponseEnvelopeMessages] +type devicePostureNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePostureNewResponseEnvelopeSuccess bool + +const ( + DevicePostureNewResponseEnvelopeSuccessTrue DevicePostureNewResponseEnvelopeSuccess = true +) + +type DevicePostureUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // The name of the device posture rule. + Name param.Field[string] `json:"name,required"` + // The type of device posture rule. + Type param.Field[DevicePostureUpdateParamsType] `json:"type,required"` + // The description of the device posture rule. + Description param.Field[string] `json:"description"` + // Sets the expiration time for a posture check result. If empty, the result + // remains valid until it is overwritten by new data from the WARP client. + Expiration param.Field[string] `json:"expiration"` + // The value to be checked against. + Input param.Field[DevicePostureUpdateParamsInput] `json:"input"` + // The conditions that the client must match to run the rule. + Match param.Field[[]DevicePostureUpdateParamsMatch] `json:"match"` + // Polling frequency for the WARP client posture check. Default: `5m` (poll every + // five minutes). Minimum: `1m`. + Schedule param.Field[string] `json:"schedule"` +} + +func (r DevicePostureUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of device posture rule. +type DevicePostureUpdateParamsType string + +const ( + DevicePostureUpdateParamsTypeFile DevicePostureUpdateParamsType = "file" + DevicePostureUpdateParamsTypeApplication DevicePostureUpdateParamsType = "application" + DevicePostureUpdateParamsTypeTanium DevicePostureUpdateParamsType = "tanium" + DevicePostureUpdateParamsTypeGateway DevicePostureUpdateParamsType = "gateway" + DevicePostureUpdateParamsTypeWARP DevicePostureUpdateParamsType = "warp" + DevicePostureUpdateParamsTypeDiskEncryption DevicePostureUpdateParamsType = "disk_encryption" + DevicePostureUpdateParamsTypeSentinelone DevicePostureUpdateParamsType = "sentinelone" + DevicePostureUpdateParamsTypeCarbonblack DevicePostureUpdateParamsType = "carbonblack" + DevicePostureUpdateParamsTypeFirewall DevicePostureUpdateParamsType = "firewall" + DevicePostureUpdateParamsTypeOSVersion DevicePostureUpdateParamsType = "os_version" + DevicePostureUpdateParamsTypeDomainJoined DevicePostureUpdateParamsType = "domain_joined" + DevicePostureUpdateParamsTypeClientCertificate DevicePostureUpdateParamsType = "client_certificate" + DevicePostureUpdateParamsTypeUniqueClientID DevicePostureUpdateParamsType = "unique_client_id" + DevicePostureUpdateParamsTypeKolide DevicePostureUpdateParamsType = "kolide" + DevicePostureUpdateParamsTypeTaniumS2s DevicePostureUpdateParamsType = "tanium_s2s" + DevicePostureUpdateParamsTypeCrowdstrikeS2s DevicePostureUpdateParamsType = "crowdstrike_s2s" + DevicePostureUpdateParamsTypeIntune DevicePostureUpdateParamsType = "intune" + DevicePostureUpdateParamsTypeWorkspaceOne DevicePostureUpdateParamsType = "workspace_one" + DevicePostureUpdateParamsTypeSentineloneS2s DevicePostureUpdateParamsType = "sentinelone_s2s" +) + +// The value to be checked against. +// +// Satisfied by +// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesFileInputRequest], +// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequest], +// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequest], +// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequest], +// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequest], +// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequest], +// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequest], +// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesDiskEncryptionInputRequest], +// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequest], +// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesClientCertificateInputRequest], +// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequest], +// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequest], +// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequest], +// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequest], +// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequest], +// [zero_trust.DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequest]. +type DevicePostureUpdateParamsInput interface { + implementsZeroTrustDevicePostureUpdateParamsInput() +} + +type DevicePostureUpdateParamsInputTeamsDevicesFileInputRequest struct { + // Operating system + OperatingSystem param.Field[DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystem] `json:"operating_system,required"` + // File path. + Path param.Field[string] `json:"path,required"` + // Whether or not file exists + Exists param.Field[bool] `json:"exists"` + // SHA-256. + Sha256 param.Field[string] `json:"sha256"` + // Signing certificate thumbprint. + Thumbprint param.Field[string] `json:"thumbprint"` +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesFileInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesFileInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +} + +// Operating system +type DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystem string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystemWindows DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystem = "windows" + DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystemLinux DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystem = "linux" + DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystemMac DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystem = "mac" +) + +type DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequest struct { + // List ID. + ID param.Field[string] `json:"id,required"` + // Operating System + OperatingSystem param.Field[DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem] `json:"operating_system,required"` +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +} + +// Operating System +type DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemAndroid DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "android" + DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemIos DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "ios" + DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemChromeos DevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "chromeos" +) + +type DevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequest struct { + // Operating System + OperatingSystem param.Field[DevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem] `json:"operating_system,required"` + // Domain + Domain param.Field[string] `json:"domain"` +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +} + +// Operating System +type DevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystemWindows DevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem = "windows" +) + +type DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequest struct { + // Operating System + OperatingSystem param.Field[DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem] `json:"operating_system,required"` + // Operator + Operator param.Field[DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator] `json:"operator,required"` + // Version of OS + Version param.Field[string] `json:"version,required"` + // Operating System Distribution Name (linux only) + OSDistroName param.Field[string] `json:"os_distro_name"` + // Version of OS Distribution (linux only) + OSDistroRevision param.Field[string] `json:"os_distro_revision"` + // Additional version data. For Mac or iOS, the Product Verison Extra. For Linux, + // the kernel release version. (Mac, iOS, and Linux only) + OSVersionExtra param.Field[string] `json:"os_version_extra"` +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +} + +// Operating System +type DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatingSystemWindows DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem = "windows" +) + +// Operator +type DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown145 DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator = "<" + DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown146 DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator = "<=" + DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown147 DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator = ">" + DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown148 DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator = ">=" + DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown149 DevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator = "==" +) + +type DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequest struct { + // Enabled + Enabled param.Field[bool] `json:"enabled,required"` + // Operating System + OperatingSystem param.Field[DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystem] `json:"operating_system,required"` +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +} + +// Operating System +type DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystem string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystemWindows DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystem = "windows" + DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystemMac DevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystem = "mac" +) + +type DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequest struct { + // Operating system + OperatingSystem param.Field[DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem] `json:"operating_system,required"` + // File path. + Path param.Field[string] `json:"path,required"` + // SHA-256. + Sha256 param.Field[string] `json:"sha256"` + // Signing certificate thumbprint. + Thumbprint param.Field[string] `json:"thumbprint"` +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +} + +// Operating system +type DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemWindows DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem = "windows" + DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemLinux DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem = "linux" + DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemMac DevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem = "mac" +) + +type DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequest struct { + // Operating system + OperatingSystem param.Field[DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem] `json:"operating_system,required"` + // File path. + Path param.Field[string] `json:"path,required"` + // SHA-256. + Sha256 param.Field[string] `json:"sha256"` + // Signing certificate thumbprint. + Thumbprint param.Field[string] `json:"thumbprint"` +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +} + +// Operating system +type DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemWindows DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "windows" + DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemLinux DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "linux" + DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemMac DevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "mac" +) + +type DevicePostureUpdateParamsInputTeamsDevicesDiskEncryptionInputRequest struct { + // List of volume names to be checked for encryption. + CheckDisks param.Field[[]string] `json:"checkDisks"` + // Whether to check all disks for encryption. + RequireAll param.Field[bool] `json:"requireAll"` +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesDiskEncryptionInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesDiskEncryptionInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +} + +type DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequest struct { + // Operating system + OperatingSystem param.Field[DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystem] `json:"operating_system,required"` + // Path for the application. + Path param.Field[string] `json:"path,required"` + // SHA-256. + Sha256 param.Field[string] `json:"sha256"` + // Signing certificate thumbprint. + Thumbprint param.Field[string] `json:"thumbprint"` +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +} + +// Operating system +type DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystem string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystemWindows DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystem = "windows" + DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystemLinux DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystem = "linux" + DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystemMac DevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystem = "mac" +) + +type DevicePostureUpdateParamsInputTeamsDevicesClientCertificateInputRequest struct { + // UUID of Cloudflare managed certificate. + CertificateID param.Field[string] `json:"certificate_id,required"` + // Common Name that is protected by the certificate + Cn param.Field[string] `json:"cn,required"` +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesClientCertificateInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesClientCertificateInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +} + +type DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequest struct { + // Compliance Status + ComplianceStatus param.Field[DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus] `json:"compliance_status,required"` + // Posture Integration ID. + ConnectionID param.Field[string] `json:"connection_id,required"` +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +} + +// Compliance Status +type DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusCompliant DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "compliant" + DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusNoncompliant DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "noncompliant" + DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusUnknown DevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "unknown" +) + +type DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequest struct { + // Posture Integration ID. + ConnectionID param.Field[string] `json:"connection_id,required"` + // For more details on last seen, please refer to the Crowdstrike documentation. + LastSeen param.Field[string] `json:"last_seen"` + // Operator + Operator param.Field[DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator] `json:"operator"` + // Os Version + OS param.Field[string] `json:"os"` + // overall + Overall param.Field[string] `json:"overall"` + // SensorConfig + SensorConfig param.Field[string] `json:"sensor_config"` + // For more details on state, please refer to the Crowdstrike documentation. + State param.Field[DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestState] `json:"state"` + // Version + Version param.Field[string] `json:"version"` + // Version Operator + VersionOperator param.Field[DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator] `json:"versionOperator"` +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +} + +// Operator +type DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown155 DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = "<" + DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown156 DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = "<=" + DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown157 DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = ">" + DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown158 DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = ">=" + DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown159 DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = "==" +) + +// For more details on state, please refer to the Crowdstrike documentation. +type DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestState string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestStateOnline DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestState = "online" + DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestStateOffline DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestState = "offline" + DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestStateUnknown DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestState = "unknown" +) + +// Version Operator +type DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown165 DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<" + DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown166 DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<=" + DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown167 DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">" + DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown168 DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">=" + DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown169 DevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "==" +) + +type DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequest struct { + // Compliance Status + ComplianceStatus param.Field[DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus] `json:"compliance_status,required"` + // Posture Integration ID. + ConnectionID param.Field[string] `json:"connection_id,required"` +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +} + +// Compliance Status +type DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusCompliant DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "compliant" + DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusNoncompliant DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "noncompliant" + DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusUnknown DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "unknown" + DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusNotapplicable DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "notapplicable" + DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusIngraceperiod DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "ingraceperiod" + DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusError DevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "error" +) + +type DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequest struct { + // Posture Integration ID. + ConnectionID param.Field[string] `json:"connection_id,required"` + // Count Operator + CountOperator param.Field[DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator] `json:"countOperator,required"` + // The Number of Issues. + IssueCount param.Field[string] `json:"issue_count,required"` +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +} + +// Count Operator +type DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown175 DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator = "<" + DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown176 DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator = "<=" + DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown177 DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator = ">" + DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown178 DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator = ">=" + DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown179 DevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator = "==" +) + +type DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequest struct { + // Posture Integration ID. + ConnectionID param.Field[string] `json:"connection_id,required"` + // For more details on eid last seen, refer to the Tanium documentation. + EidLastSeen param.Field[string] `json:"eid_last_seen"` + // Operator to evaluate risk_level or eid_last_seen. + Operator param.Field[DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator] `json:"operator"` + // For more details on risk level, refer to the Tanium documentation. + RiskLevel param.Field[DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel] `json:"risk_level"` + // Score Operator + ScoreOperator param.Field[DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator] `json:"scoreOperator"` + // For more details on total score, refer to the Tanium documentation. + TotalScore param.Field[float64] `json:"total_score"` +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +} + +// Operator to evaluate risk_level or eid_last_seen. +type DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown185 DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator = "<" + DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown186 DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator = "<=" + DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown187 DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator = ">" + DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown188 DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator = ">=" + DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown189 DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator = "==" +) + +// For more details on risk level, refer to the Tanium documentation. +type DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevelLow DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "low" + DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevelMedium DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "medium" + DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevelHigh DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "high" + DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevelCritical DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "critical" +) + +// Score Operator +type DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown195 DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator = "<" + DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown196 DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator = "<=" + DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown197 DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator = ">" + DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown198 DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator = ">=" + DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown199 DevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator = "==" +) + +type DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequest struct { + // Posture Integration ID. + ConnectionID param.Field[string] `json:"connection_id,required"` + // The Number of active threats. + ActiveThreats param.Field[float64] `json:"active_threats"` + // Whether device is infected. + Infected param.Field[bool] `json:"infected"` + // Whether device is active. + IsActive param.Field[bool] `json:"is_active"` + // Network status of device. + NetworkStatus param.Field[DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus] `json:"network_status"` + // operator + Operator param.Field[DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator] `json:"operator"` +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { +} + +// Network status of device. +type DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnected DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connected" + DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnected DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnected" + DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnecting DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnecting" + DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnecting DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connecting" +) + +// operator +type DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator string + +const ( + DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown205 DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = "<" + DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown206 DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = "<=" + DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown207 DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = ">" + DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown208 DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = ">=" + DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown209 DevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = "==" +) + +type DevicePostureUpdateParamsMatch struct { + Platform param.Field[DevicePostureUpdateParamsMatchPlatform] `json:"platform"` +} + +func (r DevicePostureUpdateParamsMatch) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DevicePostureUpdateParamsMatchPlatform string + +const ( + DevicePostureUpdateParamsMatchPlatformWindows DevicePostureUpdateParamsMatchPlatform = "windows" + DevicePostureUpdateParamsMatchPlatformMac DevicePostureUpdateParamsMatchPlatform = "mac" + DevicePostureUpdateParamsMatchPlatformLinux DevicePostureUpdateParamsMatchPlatform = "linux" + DevicePostureUpdateParamsMatchPlatformAndroid DevicePostureUpdateParamsMatchPlatform = "android" + DevicePostureUpdateParamsMatchPlatformIos DevicePostureUpdateParamsMatchPlatform = "ios" +) + +type DevicePostureUpdateResponseEnvelope struct { + Errors []DevicePostureUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePostureUpdateResponseEnvelopeMessages `json:"messages,required"` + Result TeamsDevicesDevicePostureRules `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePostureUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON devicePostureUpdateResponseEnvelopeJSON `json:"-"` +} + +// devicePostureUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [DevicePostureUpdateResponseEnvelope] +type devicePostureUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePostureUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePostureUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DevicePostureUpdateResponseEnvelopeErrors] +type devicePostureUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePostureUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePostureUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [DevicePostureUpdateResponseEnvelopeMessages] +type devicePostureUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePostureUpdateResponseEnvelopeSuccess bool + +const ( + DevicePostureUpdateResponseEnvelopeSuccessTrue DevicePostureUpdateResponseEnvelopeSuccess = true +) + +type DevicePostureListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DevicePostureListResponseEnvelope struct { + Errors []DevicePostureListResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePostureListResponseEnvelopeMessages `json:"messages,required"` + Result []TeamsDevicesDevicePostureRules `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePostureListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DevicePostureListResponseEnvelopeResultInfo `json:"result_info"` + JSON devicePostureListResponseEnvelopeJSON `json:"-"` +} + +// devicePostureListResponseEnvelopeJSON contains the JSON metadata for the struct +// [DevicePostureListResponseEnvelope] +type devicePostureListResponseEnvelopeJSON 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 *DevicePostureListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePostureListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureListResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePostureListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DevicePostureListResponseEnvelopeErrors] +type devicePostureListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePostureListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureListResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePostureListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DevicePostureListResponseEnvelopeMessages] +type devicePostureListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePostureListResponseEnvelopeSuccess bool + +const ( + DevicePostureListResponseEnvelopeSuccessTrue DevicePostureListResponseEnvelopeSuccess = true +) + +type DevicePostureListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON devicePostureListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// devicePostureListResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [DevicePostureListResponseEnvelopeResultInfo] +type devicePostureListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DevicePostureDeleteParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DevicePostureDeleteResponseEnvelope struct { + Errors []DevicePostureDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePostureDeleteResponseEnvelopeMessages `json:"messages,required"` + Result DevicePostureDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePostureDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON devicePostureDeleteResponseEnvelopeJSON `json:"-"` +} + +// devicePostureDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [DevicePostureDeleteResponseEnvelope] +type devicePostureDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePostureDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePostureDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DevicePostureDeleteResponseEnvelopeErrors] +type devicePostureDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePostureDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePostureDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [DevicePostureDeleteResponseEnvelopeMessages] +type devicePostureDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePostureDeleteResponseEnvelopeSuccess bool + +const ( + DevicePostureDeleteResponseEnvelopeSuccessTrue DevicePostureDeleteResponseEnvelopeSuccess = true +) + +type DevicePostureGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DevicePostureGetResponseEnvelope struct { + Errors []DevicePostureGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePostureGetResponseEnvelopeMessages `json:"messages,required"` + Result TeamsDevicesDevicePostureRules `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePostureGetResponseEnvelopeSuccess `json:"success,required"` + JSON devicePostureGetResponseEnvelopeJSON `json:"-"` +} + +// devicePostureGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DevicePostureGetResponseEnvelope] +type devicePostureGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePostureGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePostureGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DevicePostureGetResponseEnvelopeErrors] +type devicePostureGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePostureGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePostureGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DevicePostureGetResponseEnvelopeMessages] +type devicePostureGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePostureGetResponseEnvelopeSuccess bool + +const ( + DevicePostureGetResponseEnvelopeSuccessTrue DevicePostureGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/deviceposture_test.go b/zero_trust/deviceposture_test.go new file mode 100644 index 00000000000..1bc975fb43f --- /dev/null +++ b/zero_trust/deviceposture_test.go @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDevicePostureNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Postures.New(context.TODO(), zero_trust.DevicePostureNewParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Name: cloudflare.F("Admin Serial Numbers"), + Type: cloudflare.F(zero_trust.DevicePostureNewParamsTypeFile), + Description: cloudflare.F("The rule for admin serial numbers"), + Expiration: cloudflare.F("1h"), + Input: cloudflare.F[zero_trust.DevicePostureNewParamsInput](zero_trust.DevicePostureNewParamsInputTeamsDevicesFileInputRequest(zero_trust.DevicePostureNewParamsInputTeamsDevicesFileInputRequest{ + Exists: cloudflare.F(true), + OperatingSystem: cloudflare.F(zero_trust.DevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystemLinux), + Path: cloudflare.F("/bin/cat"), + Sha256: cloudflare.F("https://api.us-2.crowdstrike.com"), + Thumbprint: cloudflare.F("0aabab210bdb998e9cf45da2c9ce352977ab531c681b74cf1e487be1bbe9fe6e"), + })), + Match: cloudflare.F([]zero_trust.DevicePostureNewParamsMatch{{ + Platform: cloudflare.F(zero_trust.DevicePostureNewParamsMatchPlatformWindows), + }, { + Platform: cloudflare.F(zero_trust.DevicePostureNewParamsMatchPlatformWindows), + }, { + Platform: cloudflare.F(zero_trust.DevicePostureNewParamsMatchPlatformWindows), + }}), + Schedule: cloudflare.F("1h"), + }) + 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 TestDevicePostureUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Postures.Update( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DevicePostureUpdateParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Name: cloudflare.F("Admin Serial Numbers"), + Type: cloudflare.F(zero_trust.DevicePostureUpdateParamsTypeFile), + Description: cloudflare.F("The rule for admin serial numbers"), + Expiration: cloudflare.F("1h"), + Input: cloudflare.F[zero_trust.DevicePostureUpdateParamsInput](zero_trust.DevicePostureUpdateParamsInputTeamsDevicesFileInputRequest(zero_trust.DevicePostureUpdateParamsInputTeamsDevicesFileInputRequest{ + Exists: cloudflare.F(true), + OperatingSystem: cloudflare.F(zero_trust.DevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystemLinux), + Path: cloudflare.F("/bin/cat"), + Sha256: cloudflare.F("https://api.us-2.crowdstrike.com"), + Thumbprint: cloudflare.F("0aabab210bdb998e9cf45da2c9ce352977ab531c681b74cf1e487be1bbe9fe6e"), + })), + Match: cloudflare.F([]zero_trust.DevicePostureUpdateParamsMatch{{ + Platform: cloudflare.F(zero_trust.DevicePostureUpdateParamsMatchPlatformWindows), + }, { + Platform: cloudflare.F(zero_trust.DevicePostureUpdateParamsMatchPlatformWindows), + }, { + Platform: cloudflare.F(zero_trust.DevicePostureUpdateParamsMatchPlatformWindows), + }}), + Schedule: cloudflare.F("1h"), + }, + ) + 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 TestDevicePostureList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Postures.List(context.TODO(), zero_trust.DevicePostureListParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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 TestDevicePostureDelete(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Postures.Delete( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DevicePostureDeleteParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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 TestDevicePostureGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Postures.Get( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DevicePostureGetParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/devicepostureintegration.go b/zero_trust/devicepostureintegration.go new file mode 100644 index 00000000000..f270cd538e2 --- /dev/null +++ b/zero_trust/devicepostureintegration.go @@ -0,0 +1,968 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// DevicePostureIntegrationService 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 +// [NewDevicePostureIntegrationService] method instead. +type DevicePostureIntegrationService struct { + Options []option.RequestOption +} + +// NewDevicePostureIntegrationService 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 NewDevicePostureIntegrationService(opts ...option.RequestOption) (r *DevicePostureIntegrationService) { + r = &DevicePostureIntegrationService{} + r.Options = opts + return +} + +// Create a new device posture integration. +func (r *DevicePostureIntegrationService) New(ctx context.Context, params DevicePostureIntegrationNewParams, opts ...option.RequestOption) (res *TeamsDevicesDevicePostureIntegrations, err error) { + opts = append(r.Options[:], opts...) + var env DevicePostureIntegrationNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/posture/integration", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the list of device posture integrations for an account. +func (r *DevicePostureIntegrationService) List(ctx context.Context, query DevicePostureIntegrationListParams, opts ...option.RequestOption) (res *[]TeamsDevicesDevicePostureIntegrations, err error) { + opts = append(r.Options[:], opts...) + var env DevicePostureIntegrationListResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/posture/integration", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a configured device posture integration. +func (r *DevicePostureIntegrationService) Delete(ctx context.Context, integrationID string, body DevicePostureIntegrationDeleteParams, opts ...option.RequestOption) (res *DevicePostureIntegrationDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env DevicePostureIntegrationDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/posture/integration/%s", body.AccountID, integrationID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a configured device posture integration. +func (r *DevicePostureIntegrationService) Edit(ctx context.Context, integrationID string, params DevicePostureIntegrationEditParams, opts ...option.RequestOption) (res *TeamsDevicesDevicePostureIntegrations, err error) { + opts = append(r.Options[:], opts...) + var env DevicePostureIntegrationEditResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/posture/integration/%s", params.AccountID, integrationID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches details for a single device posture integration. +func (r *DevicePostureIntegrationService) Get(ctx context.Context, integrationID string, query DevicePostureIntegrationGetParams, opts ...option.RequestOption) (res *TeamsDevicesDevicePostureIntegrations, err error) { + opts = append(r.Options[:], opts...) + var env DevicePostureIntegrationGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/posture/integration/%s", query.AccountID, integrationID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TeamsDevicesDevicePostureIntegrations struct { + // API UUID. + ID string `json:"id"` + // The configuration object containing third-party integration information. + Config TeamsDevicesDevicePostureIntegrationsConfig `json:"config"` + // The interval between each posture check with the third-party API. Use `m` for + // minutes (e.g. `5m`) and `h` for hours (e.g. `12h`). + Interval string `json:"interval"` + // The name of the device posture integration. + Name string `json:"name"` + // The type of device posture integration. + Type TeamsDevicesDevicePostureIntegrationsType `json:"type"` + JSON teamsDevicesDevicePostureIntegrationsJSON `json:"-"` +} + +// teamsDevicesDevicePostureIntegrationsJSON contains the JSON metadata for the +// struct [TeamsDevicesDevicePostureIntegrations] +type teamsDevicesDevicePostureIntegrationsJSON struct { + ID apijson.Field + Config apijson.Field + Interval apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureIntegrations) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureIntegrationsJSON) RawJSON() string { + return r.raw +} + +// The configuration object containing third-party integration information. +type TeamsDevicesDevicePostureIntegrationsConfig struct { + // The Workspace One API URL provided in the Workspace One Admin Dashboard. + APIURL string `json:"api_url,required"` + // The Workspace One Authorization URL depending on your region. + AuthURL string `json:"auth_url,required"` + // The Workspace One client ID provided in the Workspace One Admin Dashboard. + ClientID string `json:"client_id,required"` + JSON teamsDevicesDevicePostureIntegrationsConfigJSON `json:"-"` +} + +// teamsDevicesDevicePostureIntegrationsConfigJSON contains the JSON metadata for +// the struct [TeamsDevicesDevicePostureIntegrationsConfig] +type teamsDevicesDevicePostureIntegrationsConfigJSON struct { + APIURL apijson.Field + AuthURL apijson.Field + ClientID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesDevicePostureIntegrationsConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesDevicePostureIntegrationsConfigJSON) RawJSON() string { + return r.raw +} + +// The type of device posture integration. +type TeamsDevicesDevicePostureIntegrationsType string + +const ( + TeamsDevicesDevicePostureIntegrationsTypeWorkspaceOne TeamsDevicesDevicePostureIntegrationsType = "workspace_one" + TeamsDevicesDevicePostureIntegrationsTypeCrowdstrikeS2s TeamsDevicesDevicePostureIntegrationsType = "crowdstrike_s2s" + TeamsDevicesDevicePostureIntegrationsTypeUptycs TeamsDevicesDevicePostureIntegrationsType = "uptycs" + TeamsDevicesDevicePostureIntegrationsTypeIntune TeamsDevicesDevicePostureIntegrationsType = "intune" + TeamsDevicesDevicePostureIntegrationsTypeKolide TeamsDevicesDevicePostureIntegrationsType = "kolide" + TeamsDevicesDevicePostureIntegrationsTypeTanium TeamsDevicesDevicePostureIntegrationsType = "tanium" + TeamsDevicesDevicePostureIntegrationsTypeSentineloneS2s TeamsDevicesDevicePostureIntegrationsType = "sentinelone_s2s" +) + +// Union satisfied by [zero_trust.DevicePostureIntegrationDeleteResponseUnknown] or +// [shared.UnionString]. +type DevicePostureIntegrationDeleteResponse interface { + ImplementsZeroTrustDevicePostureIntegrationDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DevicePostureIntegrationDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type DevicePostureIntegrationNewParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // The configuration object containing third-party integration information. + Config param.Field[DevicePostureIntegrationNewParamsConfig] `json:"config,required"` + // The interval between each posture check with the third-party API. Use `m` for + // minutes (e.g. `5m`) and `h` for hours (e.g. `12h`). + Interval param.Field[string] `json:"interval,required"` + // The name of the device posture integration. + Name param.Field[string] `json:"name,required"` + // The type of device posture integration. + Type param.Field[DevicePostureIntegrationNewParamsType] `json:"type,required"` +} + +func (r DevicePostureIntegrationNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The configuration object containing third-party integration information. +// +// Satisfied by +// [zero_trust.DevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigRequest], +// [zero_trust.DevicePostureIntegrationNewParamsConfigTeamsDevicesCrowdstrikeConfigRequest], +// [zero_trust.DevicePostureIntegrationNewParamsConfigTeamsDevicesUptycsConfigRequest], +// [zero_trust.DevicePostureIntegrationNewParamsConfigTeamsDevicesIntuneConfigRequest], +// [zero_trust.DevicePostureIntegrationNewParamsConfigTeamsDevicesKolideConfigRequest], +// [zero_trust.DevicePostureIntegrationNewParamsConfigTeamsDevicesTaniumConfigRequest], +// [zero_trust.DevicePostureIntegrationNewParamsConfigTeamsDevicesSentineloneS2sConfigRequest]. +type DevicePostureIntegrationNewParamsConfig interface { + implementsZeroTrustDevicePostureIntegrationNewParamsConfig() +} + +type DevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigRequest struct { + // The Workspace One API URL provided in the Workspace One Admin Dashboard. + APIURL param.Field[string] `json:"api_url,required"` + // The Workspace One Authorization URL depending on your region. + AuthURL param.Field[string] `json:"auth_url,required"` + // The Workspace One client ID provided in the Workspace One Admin Dashboard. + ClientID param.Field[string] `json:"client_id,required"` + // The Workspace One client secret provided in the Workspace One Admin Dashboard. + ClientSecret param.Field[string] `json:"client_secret,required"` +} + +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { +} + +type DevicePostureIntegrationNewParamsConfigTeamsDevicesCrowdstrikeConfigRequest struct { + // The Crowdstrike API URL. + APIURL param.Field[string] `json:"api_url,required"` + // The Crowdstrike client ID. + ClientID param.Field[string] `json:"client_id,required"` + // The Crowdstrike client secret. + ClientSecret param.Field[string] `json:"client_secret,required"` + // The Crowdstrike customer ID. + CustomerID param.Field[string] `json:"customer_id,required"` +} + +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesCrowdstrikeConfigRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesCrowdstrikeConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { +} + +type DevicePostureIntegrationNewParamsConfigTeamsDevicesUptycsConfigRequest struct { + // The Uptycs API URL. + APIURL param.Field[string] `json:"api_url,required"` + // The Uptycs client secret. + ClientKey param.Field[string] `json:"client_key,required"` + // The Uptycs client secret. + ClientSecret param.Field[string] `json:"client_secret,required"` + // The Uptycs customer ID. + CustomerID param.Field[string] `json:"customer_id,required"` +} + +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesUptycsConfigRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesUptycsConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { +} + +type DevicePostureIntegrationNewParamsConfigTeamsDevicesIntuneConfigRequest struct { + // The Intune client ID. + ClientID param.Field[string] `json:"client_id,required"` + // The Intune client secret. + ClientSecret param.Field[string] `json:"client_secret,required"` + // The Intune customer ID. + CustomerID param.Field[string] `json:"customer_id,required"` +} + +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesIntuneConfigRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesIntuneConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { +} + +type DevicePostureIntegrationNewParamsConfigTeamsDevicesKolideConfigRequest struct { + // The Kolide client ID. + ClientID param.Field[string] `json:"client_id,required"` + // The Kolide client secret. + ClientSecret param.Field[string] `json:"client_secret,required"` +} + +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesKolideConfigRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesKolideConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { +} + +type DevicePostureIntegrationNewParamsConfigTeamsDevicesTaniumConfigRequest struct { + // The Tanium API URL. + APIURL param.Field[string] `json:"api_url,required"` + // The Tanium client secret. + ClientSecret param.Field[string] `json:"client_secret,required"` + // If present, this id will be passed in the `CF-Access-Client-ID` header when + // hitting the `api_url` + AccessClientID param.Field[string] `json:"access_client_id"` + // If present, this secret will be passed in the `CF-Access-Client-Secret` header + // when hitting the `api_url` + AccessClientSecret param.Field[string] `json:"access_client_secret"` +} + +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesTaniumConfigRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesTaniumConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { +} + +type DevicePostureIntegrationNewParamsConfigTeamsDevicesSentineloneS2sConfigRequest struct { + // The SentinelOne S2S API URL. + APIURL param.Field[string] `json:"api_url,required"` + // The SentinelOne S2S client secret. + ClientSecret param.Field[string] `json:"client_secret,required"` +} + +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesSentineloneS2sConfigRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureIntegrationNewParamsConfigTeamsDevicesSentineloneS2sConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { +} + +// The type of device posture integration. +type DevicePostureIntegrationNewParamsType string + +const ( + DevicePostureIntegrationNewParamsTypeWorkspaceOne DevicePostureIntegrationNewParamsType = "workspace_one" + DevicePostureIntegrationNewParamsTypeCrowdstrikeS2s DevicePostureIntegrationNewParamsType = "crowdstrike_s2s" + DevicePostureIntegrationNewParamsTypeUptycs DevicePostureIntegrationNewParamsType = "uptycs" + DevicePostureIntegrationNewParamsTypeIntune DevicePostureIntegrationNewParamsType = "intune" + DevicePostureIntegrationNewParamsTypeKolide DevicePostureIntegrationNewParamsType = "kolide" + DevicePostureIntegrationNewParamsTypeTanium DevicePostureIntegrationNewParamsType = "tanium" + DevicePostureIntegrationNewParamsTypeSentineloneS2s DevicePostureIntegrationNewParamsType = "sentinelone_s2s" +) + +type DevicePostureIntegrationNewResponseEnvelope struct { + Errors []DevicePostureIntegrationNewResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePostureIntegrationNewResponseEnvelopeMessages `json:"messages,required"` + Result TeamsDevicesDevicePostureIntegrations `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePostureIntegrationNewResponseEnvelopeSuccess `json:"success,required"` + JSON devicePostureIntegrationNewResponseEnvelopeJSON `json:"-"` +} + +// devicePostureIntegrationNewResponseEnvelopeJSON contains the JSON metadata for +// the struct [DevicePostureIntegrationNewResponseEnvelope] +type devicePostureIntegrationNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureIntegrationNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureIntegrationNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePostureIntegrationNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureIntegrationNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePostureIntegrationNewResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [DevicePostureIntegrationNewResponseEnvelopeErrors] +type devicePostureIntegrationNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureIntegrationNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureIntegrationNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePostureIntegrationNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureIntegrationNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePostureIntegrationNewResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [DevicePostureIntegrationNewResponseEnvelopeMessages] +type devicePostureIntegrationNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureIntegrationNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureIntegrationNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePostureIntegrationNewResponseEnvelopeSuccess bool + +const ( + DevicePostureIntegrationNewResponseEnvelopeSuccessTrue DevicePostureIntegrationNewResponseEnvelopeSuccess = true +) + +type DevicePostureIntegrationListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DevicePostureIntegrationListResponseEnvelope struct { + Errors []DevicePostureIntegrationListResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePostureIntegrationListResponseEnvelopeMessages `json:"messages,required"` + Result []TeamsDevicesDevicePostureIntegrations `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePostureIntegrationListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DevicePostureIntegrationListResponseEnvelopeResultInfo `json:"result_info"` + JSON devicePostureIntegrationListResponseEnvelopeJSON `json:"-"` +} + +// devicePostureIntegrationListResponseEnvelopeJSON contains the JSON metadata for +// the struct [DevicePostureIntegrationListResponseEnvelope] +type devicePostureIntegrationListResponseEnvelopeJSON 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 *DevicePostureIntegrationListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureIntegrationListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePostureIntegrationListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureIntegrationListResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePostureIntegrationListResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [DevicePostureIntegrationListResponseEnvelopeErrors] +type devicePostureIntegrationListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureIntegrationListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureIntegrationListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePostureIntegrationListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureIntegrationListResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePostureIntegrationListResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [DevicePostureIntegrationListResponseEnvelopeMessages] +type devicePostureIntegrationListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureIntegrationListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureIntegrationListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePostureIntegrationListResponseEnvelopeSuccess bool + +const ( + DevicePostureIntegrationListResponseEnvelopeSuccessTrue DevicePostureIntegrationListResponseEnvelopeSuccess = true +) + +type DevicePostureIntegrationListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON devicePostureIntegrationListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// devicePostureIntegrationListResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [DevicePostureIntegrationListResponseEnvelopeResultInfo] +type devicePostureIntegrationListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureIntegrationListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureIntegrationListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DevicePostureIntegrationDeleteParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DevicePostureIntegrationDeleteResponseEnvelope struct { + Errors []DevicePostureIntegrationDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePostureIntegrationDeleteResponseEnvelopeMessages `json:"messages,required"` + Result DevicePostureIntegrationDeleteResponse `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePostureIntegrationDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON devicePostureIntegrationDeleteResponseEnvelopeJSON `json:"-"` +} + +// devicePostureIntegrationDeleteResponseEnvelopeJSON contains the JSON metadata +// for the struct [DevicePostureIntegrationDeleteResponseEnvelope] +type devicePostureIntegrationDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureIntegrationDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureIntegrationDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePostureIntegrationDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureIntegrationDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePostureIntegrationDeleteResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [DevicePostureIntegrationDeleteResponseEnvelopeErrors] +type devicePostureIntegrationDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureIntegrationDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureIntegrationDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePostureIntegrationDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureIntegrationDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePostureIntegrationDeleteResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [DevicePostureIntegrationDeleteResponseEnvelopeMessages] +type devicePostureIntegrationDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureIntegrationDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureIntegrationDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePostureIntegrationDeleteResponseEnvelopeSuccess bool + +const ( + DevicePostureIntegrationDeleteResponseEnvelopeSuccessTrue DevicePostureIntegrationDeleteResponseEnvelopeSuccess = true +) + +type DevicePostureIntegrationEditParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // The configuration object containing third-party integration information. + Config param.Field[DevicePostureIntegrationEditParamsConfig] `json:"config"` + // The interval between each posture check with the third-party API. Use `m` for + // minutes (e.g. `5m`) and `h` for hours (e.g. `12h`). + Interval param.Field[string] `json:"interval"` + // The name of the device posture integration. + Name param.Field[string] `json:"name"` + // The type of device posture integration. + Type param.Field[DevicePostureIntegrationEditParamsType] `json:"type"` +} + +func (r DevicePostureIntegrationEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The configuration object containing third-party integration information. +// +// Satisfied by +// [zero_trust.DevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRequest], +// [zero_trust.DevicePostureIntegrationEditParamsConfigTeamsDevicesCrowdstrikeConfigRequest], +// [zero_trust.DevicePostureIntegrationEditParamsConfigTeamsDevicesUptycsConfigRequest], +// [zero_trust.DevicePostureIntegrationEditParamsConfigTeamsDevicesIntuneConfigRequest], +// [zero_trust.DevicePostureIntegrationEditParamsConfigTeamsDevicesKolideConfigRequest], +// [zero_trust.DevicePostureIntegrationEditParamsConfigTeamsDevicesTaniumConfigRequest], +// [zero_trust.DevicePostureIntegrationEditParamsConfigTeamsDevicesSentineloneS2sConfigRequest]. +type DevicePostureIntegrationEditParamsConfig interface { + implementsZeroTrustDevicePostureIntegrationEditParamsConfig() +} + +type DevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRequest struct { + // The Workspace One API URL provided in the Workspace One Admin Dashboard. + APIURL param.Field[string] `json:"api_url,required"` + // The Workspace One Authorization URL depending on your region. + AuthURL param.Field[string] `json:"auth_url,required"` + // The Workspace One client ID provided in the Workspace One Admin Dashboard. + ClientID param.Field[string] `json:"client_id,required"` + // The Workspace One client secret provided in the Workspace One Admin Dashboard. + ClientSecret param.Field[string] `json:"client_secret,required"` +} + +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { +} + +type DevicePostureIntegrationEditParamsConfigTeamsDevicesCrowdstrikeConfigRequest struct { + // The Crowdstrike API URL. + APIURL param.Field[string] `json:"api_url,required"` + // The Crowdstrike client ID. + ClientID param.Field[string] `json:"client_id,required"` + // The Crowdstrike client secret. + ClientSecret param.Field[string] `json:"client_secret,required"` + // The Crowdstrike customer ID. + CustomerID param.Field[string] `json:"customer_id,required"` +} + +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesCrowdstrikeConfigRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesCrowdstrikeConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { +} + +type DevicePostureIntegrationEditParamsConfigTeamsDevicesUptycsConfigRequest struct { + // The Uptycs API URL. + APIURL param.Field[string] `json:"api_url,required"` + // The Uptycs client secret. + ClientKey param.Field[string] `json:"client_key,required"` + // The Uptycs client secret. + ClientSecret param.Field[string] `json:"client_secret,required"` + // The Uptycs customer ID. + CustomerID param.Field[string] `json:"customer_id,required"` +} + +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesUptycsConfigRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesUptycsConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { +} + +type DevicePostureIntegrationEditParamsConfigTeamsDevicesIntuneConfigRequest struct { + // The Intune client ID. + ClientID param.Field[string] `json:"client_id,required"` + // The Intune client secret. + ClientSecret param.Field[string] `json:"client_secret,required"` + // The Intune customer ID. + CustomerID param.Field[string] `json:"customer_id,required"` +} + +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesIntuneConfigRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesIntuneConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { +} + +type DevicePostureIntegrationEditParamsConfigTeamsDevicesKolideConfigRequest struct { + // The Kolide client ID. + ClientID param.Field[string] `json:"client_id,required"` + // The Kolide client secret. + ClientSecret param.Field[string] `json:"client_secret,required"` +} + +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesKolideConfigRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesKolideConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { +} + +type DevicePostureIntegrationEditParamsConfigTeamsDevicesTaniumConfigRequest struct { + // The Tanium API URL. + APIURL param.Field[string] `json:"api_url,required"` + // The Tanium client secret. + ClientSecret param.Field[string] `json:"client_secret,required"` + // If present, this id will be passed in the `CF-Access-Client-ID` header when + // hitting the `api_url` + AccessClientID param.Field[string] `json:"access_client_id"` + // If present, this secret will be passed in the `CF-Access-Client-Secret` header + // when hitting the `api_url` + AccessClientSecret param.Field[string] `json:"access_client_secret"` +} + +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesTaniumConfigRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesTaniumConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { +} + +type DevicePostureIntegrationEditParamsConfigTeamsDevicesSentineloneS2sConfigRequest struct { + // The SentinelOne S2S API URL. + APIURL param.Field[string] `json:"api_url,required"` + // The SentinelOne S2S client secret. + ClientSecret param.Field[string] `json:"client_secret,required"` +} + +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesSentineloneS2sConfigRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DevicePostureIntegrationEditParamsConfigTeamsDevicesSentineloneS2sConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { +} + +// The type of device posture integration. +type DevicePostureIntegrationEditParamsType string + +const ( + DevicePostureIntegrationEditParamsTypeWorkspaceOne DevicePostureIntegrationEditParamsType = "workspace_one" + DevicePostureIntegrationEditParamsTypeCrowdstrikeS2s DevicePostureIntegrationEditParamsType = "crowdstrike_s2s" + DevicePostureIntegrationEditParamsTypeUptycs DevicePostureIntegrationEditParamsType = "uptycs" + DevicePostureIntegrationEditParamsTypeIntune DevicePostureIntegrationEditParamsType = "intune" + DevicePostureIntegrationEditParamsTypeKolide DevicePostureIntegrationEditParamsType = "kolide" + DevicePostureIntegrationEditParamsTypeTanium DevicePostureIntegrationEditParamsType = "tanium" + DevicePostureIntegrationEditParamsTypeSentineloneS2s DevicePostureIntegrationEditParamsType = "sentinelone_s2s" +) + +type DevicePostureIntegrationEditResponseEnvelope struct { + Errors []DevicePostureIntegrationEditResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePostureIntegrationEditResponseEnvelopeMessages `json:"messages,required"` + Result TeamsDevicesDevicePostureIntegrations `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePostureIntegrationEditResponseEnvelopeSuccess `json:"success,required"` + JSON devicePostureIntegrationEditResponseEnvelopeJSON `json:"-"` +} + +// devicePostureIntegrationEditResponseEnvelopeJSON contains the JSON metadata for +// the struct [DevicePostureIntegrationEditResponseEnvelope] +type devicePostureIntegrationEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureIntegrationEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureIntegrationEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePostureIntegrationEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureIntegrationEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePostureIntegrationEditResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [DevicePostureIntegrationEditResponseEnvelopeErrors] +type devicePostureIntegrationEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureIntegrationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureIntegrationEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePostureIntegrationEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureIntegrationEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePostureIntegrationEditResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [DevicePostureIntegrationEditResponseEnvelopeMessages] +type devicePostureIntegrationEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureIntegrationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureIntegrationEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePostureIntegrationEditResponseEnvelopeSuccess bool + +const ( + DevicePostureIntegrationEditResponseEnvelopeSuccessTrue DevicePostureIntegrationEditResponseEnvelopeSuccess = true +) + +type DevicePostureIntegrationGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DevicePostureIntegrationGetResponseEnvelope struct { + Errors []DevicePostureIntegrationGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DevicePostureIntegrationGetResponseEnvelopeMessages `json:"messages,required"` + Result TeamsDevicesDevicePostureIntegrations `json:"result,required,nullable"` + // Whether the API call was successful. + Success DevicePostureIntegrationGetResponseEnvelopeSuccess `json:"success,required"` + JSON devicePostureIntegrationGetResponseEnvelopeJSON `json:"-"` +} + +// devicePostureIntegrationGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [DevicePostureIntegrationGetResponseEnvelope] +type devicePostureIntegrationGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureIntegrationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureIntegrationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DevicePostureIntegrationGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureIntegrationGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// devicePostureIntegrationGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [DevicePostureIntegrationGetResponseEnvelopeErrors] +type devicePostureIntegrationGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureIntegrationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureIntegrationGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DevicePostureIntegrationGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON devicePostureIntegrationGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// devicePostureIntegrationGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [DevicePostureIntegrationGetResponseEnvelopeMessages] +type devicePostureIntegrationGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DevicePostureIntegrationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r devicePostureIntegrationGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DevicePostureIntegrationGetResponseEnvelopeSuccess bool + +const ( + DevicePostureIntegrationGetResponseEnvelopeSuccessTrue DevicePostureIntegrationGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/devicepostureintegration_test.go b/zero_trust/devicepostureintegration_test.go new file mode 100644 index 00000000000..a704fa70942 --- /dev/null +++ b/zero_trust/devicepostureintegration_test.go @@ -0,0 +1,175 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDevicePostureIntegrationNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Postures.Integrations.New(context.TODO(), zero_trust.DevicePostureIntegrationNewParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Config: cloudflare.F[zero_trust.DevicePostureIntegrationNewParamsConfig](zero_trust.DevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigRequest(zero_trust.DevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigRequest{ + APIURL: cloudflare.F("https://as123.awmdm.com/API"), + AuthURL: cloudflare.F("https://na.uemauth.vmwservices.com/connect/token"), + ClientID: cloudflare.F("example client id"), + ClientSecret: cloudflare.F("example client secret"), + })), + Interval: cloudflare.F("10m"), + Name: cloudflare.F("My Workspace One Integration"), + Type: cloudflare.F(zero_trust.DevicePostureIntegrationNewParamsTypeWorkspaceOne), + }) + 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 TestDevicePostureIntegrationList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Postures.Integrations.List(context.TODO(), zero_trust.DevicePostureIntegrationListParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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 TestDevicePostureIntegrationDelete(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Postures.Integrations.Delete( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DevicePostureIntegrationDeleteParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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 TestDevicePostureIntegrationEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Postures.Integrations.Edit( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DevicePostureIntegrationEditParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Config: cloudflare.F[zero_trust.DevicePostureIntegrationEditParamsConfig](zero_trust.DevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRequest(zero_trust.DevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRequest{ + APIURL: cloudflare.F("https://as123.awmdm.com/API"), + AuthURL: cloudflare.F("https://na.uemauth.vmwservices.com/connect/token"), + ClientID: cloudflare.F("example client id"), + ClientSecret: cloudflare.F("example client secret"), + })), + Interval: cloudflare.F("10m"), + Name: cloudflare.F("My Workspace One Integration"), + Type: cloudflare.F(zero_trust.DevicePostureIntegrationEditParamsTypeWorkspaceOne), + }, + ) + 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 TestDevicePostureIntegrationGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Postures.Integrations.Get( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DevicePostureIntegrationGetParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/devicerevoke.go b/zero_trust/devicerevoke.go new file mode 100644 index 00000000000..3f7beeea660 --- /dev/null +++ b/zero_trust/devicerevoke.go @@ -0,0 +1,156 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// DeviceRevokeService 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 [NewDeviceRevokeService] method +// instead. +type DeviceRevokeService struct { + Options []option.RequestOption +} + +// NewDeviceRevokeService 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 NewDeviceRevokeService(opts ...option.RequestOption) (r *DeviceRevokeService) { + r = &DeviceRevokeService{} + r.Options = opts + return +} + +// Revokes a list of devices. +func (r *DeviceRevokeService) New(ctx context.Context, params DeviceRevokeNewParams, opts ...option.RequestOption) (res *DeviceRevokeNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env DeviceRevokeNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/revoke", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [zero_trust.DeviceRevokeNewResponseUnknown] or +// [shared.UnionString]. +type DeviceRevokeNewResponse interface { + ImplementsZeroTrustDeviceRevokeNewResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DeviceRevokeNewResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type DeviceRevokeNewParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // A list of device ids to revoke. + Body param.Field[[]string] `json:"body,required"` +} + +func (r DeviceRevokeNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type DeviceRevokeNewResponseEnvelope struct { + Errors []DeviceRevokeNewResponseEnvelopeErrors `json:"errors,required"` + Messages []DeviceRevokeNewResponseEnvelopeMessages `json:"messages,required"` + Result DeviceRevokeNewResponse `json:"result,required,nullable"` + // Whether the API call was successful. + Success DeviceRevokeNewResponseEnvelopeSuccess `json:"success,required"` + JSON deviceRevokeNewResponseEnvelopeJSON `json:"-"` +} + +// deviceRevokeNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [DeviceRevokeNewResponseEnvelope] +type deviceRevokeNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceRevokeNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceRevokeNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeviceRevokeNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceRevokeNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// deviceRevokeNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DeviceRevokeNewResponseEnvelopeErrors] +type deviceRevokeNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceRevokeNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceRevokeNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeviceRevokeNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceRevokeNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// deviceRevokeNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DeviceRevokeNewResponseEnvelopeMessages] +type deviceRevokeNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceRevokeNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceRevokeNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DeviceRevokeNewResponseEnvelopeSuccess bool + +const ( + DeviceRevokeNewResponseEnvelopeSuccessTrue DeviceRevokeNewResponseEnvelopeSuccess = true +) diff --git a/zero_trust/devicerevoke_test.go b/zero_trust/devicerevoke_test.go new file mode 100644 index 00000000000..4546355d704 --- /dev/null +++ b/zero_trust/devicerevoke_test.go @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDeviceRevokeNew(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Revokes.New(context.TODO(), zero_trust.DeviceRevokeNewParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Body: cloudflare.F([]string{"f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415"}), + }) + 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/zero_trust/devicesetting.go b/zero_trust/devicesetting.go new file mode 100644 index 00000000000..a6a52fa6d06 --- /dev/null +++ b/zero_trust/devicesetting.go @@ -0,0 +1,271 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DeviceSettingService 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 [NewDeviceSettingService] method +// instead. +type DeviceSettingService struct { + Options []option.RequestOption +} + +// NewDeviceSettingService 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 NewDeviceSettingService(opts ...option.RequestOption) (r *DeviceSettingService) { + r = &DeviceSettingService{} + r.Options = opts + return +} + +// Updates the current device settings for a Zero Trust account. +func (r *DeviceSettingService) Update(ctx context.Context, params DeviceSettingUpdateParams, opts ...option.RequestOption) (res *TeamsDevicesZeroTrustAccountDeviceSettings, err error) { + opts = append(r.Options[:], opts...) + var env DeviceSettingUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/settings", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Describes the current device settings for a Zero Trust account. +func (r *DeviceSettingService) List(ctx context.Context, query DeviceSettingListParams, opts ...option.RequestOption) (res *TeamsDevicesZeroTrustAccountDeviceSettings, err error) { + opts = append(r.Options[:], opts...) + var env DeviceSettingListResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/settings", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TeamsDevicesZeroTrustAccountDeviceSettings struct { + // Enable gateway proxy filtering on TCP. + GatewayProxyEnabled bool `json:"gateway_proxy_enabled"` + // Enable gateway proxy filtering on UDP. + GatewayUdpProxyEnabled bool `json:"gateway_udp_proxy_enabled"` + // Enable installation of cloudflare managed root certificate. + RootCertificateInstallationEnabled bool `json:"root_certificate_installation_enabled"` + // Enable using CGNAT virtual IPv4. + UseZtVirtualIP bool `json:"use_zt_virtual_ip"` + JSON teamsDevicesZeroTrustAccountDeviceSettingsJSON `json:"-"` +} + +// teamsDevicesZeroTrustAccountDeviceSettingsJSON contains the JSON metadata for +// the struct [TeamsDevicesZeroTrustAccountDeviceSettings] +type teamsDevicesZeroTrustAccountDeviceSettingsJSON struct { + GatewayProxyEnabled apijson.Field + GatewayUdpProxyEnabled apijson.Field + RootCertificateInstallationEnabled apijson.Field + UseZtVirtualIP apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TeamsDevicesZeroTrustAccountDeviceSettings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r teamsDevicesZeroTrustAccountDeviceSettingsJSON) RawJSON() string { + return r.raw +} + +type DeviceSettingUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // Enable gateway proxy filtering on TCP. + GatewayProxyEnabled param.Field[bool] `json:"gateway_proxy_enabled"` + // Enable gateway proxy filtering on UDP. + GatewayUdpProxyEnabled param.Field[bool] `json:"gateway_udp_proxy_enabled"` + // Enable installation of cloudflare managed root certificate. + RootCertificateInstallationEnabled param.Field[bool] `json:"root_certificate_installation_enabled"` + // Enable using CGNAT virtual IPv4. + UseZtVirtualIP param.Field[bool] `json:"use_zt_virtual_ip"` +} + +func (r DeviceSettingUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DeviceSettingUpdateResponseEnvelope struct { + Errors []DeviceSettingUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []DeviceSettingUpdateResponseEnvelopeMessages `json:"messages,required"` + Result TeamsDevicesZeroTrustAccountDeviceSettings `json:"result,required,nullable"` + // Whether the API call was successful. + Success DeviceSettingUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON deviceSettingUpdateResponseEnvelopeJSON `json:"-"` +} + +// deviceSettingUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [DeviceSettingUpdateResponseEnvelope] +type deviceSettingUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceSettingUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceSettingUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeviceSettingUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceSettingUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// deviceSettingUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DeviceSettingUpdateResponseEnvelopeErrors] +type deviceSettingUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceSettingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceSettingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeviceSettingUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceSettingUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// deviceSettingUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [DeviceSettingUpdateResponseEnvelopeMessages] +type deviceSettingUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceSettingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceSettingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DeviceSettingUpdateResponseEnvelopeSuccess bool + +const ( + DeviceSettingUpdateResponseEnvelopeSuccessTrue DeviceSettingUpdateResponseEnvelopeSuccess = true +) + +type DeviceSettingListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type DeviceSettingListResponseEnvelope struct { + Errors []DeviceSettingListResponseEnvelopeErrors `json:"errors,required"` + Messages []DeviceSettingListResponseEnvelopeMessages `json:"messages,required"` + Result TeamsDevicesZeroTrustAccountDeviceSettings `json:"result,required,nullable"` + // Whether the API call was successful. + Success DeviceSettingListResponseEnvelopeSuccess `json:"success,required"` + JSON deviceSettingListResponseEnvelopeJSON `json:"-"` +} + +// deviceSettingListResponseEnvelopeJSON contains the JSON metadata for the struct +// [DeviceSettingListResponseEnvelope] +type deviceSettingListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceSettingListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceSettingListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeviceSettingListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceSettingListResponseEnvelopeErrorsJSON `json:"-"` +} + +// deviceSettingListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DeviceSettingListResponseEnvelopeErrors] +type deviceSettingListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceSettingListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceSettingListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeviceSettingListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceSettingListResponseEnvelopeMessagesJSON `json:"-"` +} + +// deviceSettingListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DeviceSettingListResponseEnvelopeMessages] +type deviceSettingListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceSettingListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceSettingListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DeviceSettingListResponseEnvelopeSuccess bool + +const ( + DeviceSettingListResponseEnvelopeSuccessTrue DeviceSettingListResponseEnvelopeSuccess = true +) diff --git a/zero_trust/devicesetting_test.go b/zero_trust/devicesetting_test.go new file mode 100644 index 00000000000..c0dfd2e9cd9 --- /dev/null +++ b/zero_trust/devicesetting_test.go @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDeviceSettingUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Settings.Update(context.TODO(), zero_trust.DeviceSettingUpdateParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + GatewayProxyEnabled: cloudflare.F(true), + GatewayUdpProxyEnabled: cloudflare.F(true), + RootCertificateInstallationEnabled: cloudflare.F(true), + UseZtVirtualIP: cloudflare.F(true), + }) + 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 TestDeviceSettingList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Settings.List(context.TODO(), zero_trust.DeviceSettingListParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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/zero_trust/deviceunrevoke.go b/zero_trust/deviceunrevoke.go new file mode 100644 index 00000000000..ae149dfcbdd --- /dev/null +++ b/zero_trust/deviceunrevoke.go @@ -0,0 +1,156 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// DeviceUnrevokeService 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 [NewDeviceUnrevokeService] method +// instead. +type DeviceUnrevokeService struct { + Options []option.RequestOption +} + +// NewDeviceUnrevokeService 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 NewDeviceUnrevokeService(opts ...option.RequestOption) (r *DeviceUnrevokeService) { + r = &DeviceUnrevokeService{} + r.Options = opts + return +} + +// Unrevokes a list of devices. +func (r *DeviceUnrevokeService) New(ctx context.Context, params DeviceUnrevokeNewParams, opts ...option.RequestOption) (res *DeviceUnrevokeNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env DeviceUnrevokeNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/devices/unrevoke", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [zero_trust.DeviceUnrevokeNewResponseUnknown] or +// [shared.UnionString]. +type DeviceUnrevokeNewResponse interface { + ImplementsZeroTrustDeviceUnrevokeNewResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DeviceUnrevokeNewResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type DeviceUnrevokeNewParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // A list of device ids to unrevoke. + Body param.Field[[]string] `json:"body,required"` +} + +func (r DeviceUnrevokeNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type DeviceUnrevokeNewResponseEnvelope struct { + Errors []DeviceUnrevokeNewResponseEnvelopeErrors `json:"errors,required"` + Messages []DeviceUnrevokeNewResponseEnvelopeMessages `json:"messages,required"` + Result DeviceUnrevokeNewResponse `json:"result,required,nullable"` + // Whether the API call was successful. + Success DeviceUnrevokeNewResponseEnvelopeSuccess `json:"success,required"` + JSON deviceUnrevokeNewResponseEnvelopeJSON `json:"-"` +} + +// deviceUnrevokeNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [DeviceUnrevokeNewResponseEnvelope] +type deviceUnrevokeNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceUnrevokeNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceUnrevokeNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DeviceUnrevokeNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceUnrevokeNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// deviceUnrevokeNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DeviceUnrevokeNewResponseEnvelopeErrors] +type deviceUnrevokeNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceUnrevokeNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceUnrevokeNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DeviceUnrevokeNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON deviceUnrevokeNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// deviceUnrevokeNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DeviceUnrevokeNewResponseEnvelopeMessages] +type deviceUnrevokeNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DeviceUnrevokeNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r deviceUnrevokeNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful. +type DeviceUnrevokeNewResponseEnvelopeSuccess bool + +const ( + DeviceUnrevokeNewResponseEnvelopeSuccessTrue DeviceUnrevokeNewResponseEnvelopeSuccess = true +) diff --git a/zero_trust/deviceunrevoke_test.go b/zero_trust/deviceunrevoke_test.go new file mode 100644 index 00000000000..27d07f67983 --- /dev/null +++ b/zero_trust/deviceunrevoke_test.go @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDeviceUnrevokeNew(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("user@example.com"), + ) + _, err := client.ZeroTrust.Devices.Unrevokes.New(context.TODO(), zero_trust.DeviceUnrevokeNewParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Body: cloudflare.F([]string{"f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415"}), + }) + 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/zero_trust/dex.go b/zero_trust/dex.go new file mode 100644 index 00000000000..e9fa73185e7 --- /dev/null +++ b/zero_trust/dex.go @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// DEXService 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 [NewDEXService] method instead. +type DEXService struct { + Options []option.RequestOption + Colos *DEXColoService + FleetStatus *DEXFleetStatusService + HTTPTests *DEXHTTPTestService + Tests *DEXTestService + TracerouteTestResults *DEXTracerouteTestResultService + TracerouteTests *DEXTracerouteTestService +} + +// NewDEXService 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 NewDEXService(opts ...option.RequestOption) (r *DEXService) { + r = &DEXService{} + r.Options = opts + r.Colos = NewDEXColoService(opts...) + r.FleetStatus = NewDEXFleetStatusService(opts...) + r.HTTPTests = NewDEXHTTPTestService(opts...) + r.Tests = NewDEXTestService(opts...) + r.TracerouteTestResults = NewDEXTracerouteTestResultService(opts...) + r.TracerouteTests = NewDEXTracerouteTestService(opts...) + return +} diff --git a/zero_trust/dexcolo.go b/zero_trust/dexcolo.go new file mode 100644 index 00000000000..dfc596d9039 --- /dev/null +++ b/zero_trust/dexcolo.go @@ -0,0 +1,193 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DEXColoService 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 [NewDEXColoService] method instead. +type DEXColoService struct { + Options []option.RequestOption +} + +// NewDEXColoService 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 NewDEXColoService(opts ...option.RequestOption) (r *DEXColoService) { + r = &DEXColoService{} + r.Options = opts + return +} + +// List Cloudflare colos that account's devices were connected to during a time +// period, sorted by usage starting from the most used colo. Colos without traffic +// are also returned and sorted alphabetically. +func (r *DEXColoService) List(ctx context.Context, params DEXColoListParams, opts ...option.RequestOption) (res *[]DEXColoListResponse, err error) { + opts = append(r.Options[:], opts...) + var env DEXColoListResponseEnvelope + path := fmt.Sprintf("accounts/%s/dex/colos", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DEXColoListResponse = interface{} + +type DEXColoListParams struct { + AccountID param.Field[string] `path:"account_id,required"` + // End time for connection period in RFC3339 (ISO 8601) format. + TimeEnd param.Field[string] `query:"timeEnd,required"` + // Start time for connection period in RFC3339 (ISO 8601) format. + TimeStart param.Field[string] `query:"timeStart,required"` + // Type of usage that colos should be sorted by. If unspecified, returns all + // Cloudflare colos sorted alphabetically. + SortBy param.Field[DEXColoListParamsSortBy] `query:"sortBy"` +} + +// URLQuery serializes [DEXColoListParams]'s query parameters as `url.Values`. +func (r DEXColoListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Type of usage that colos should be sorted by. If unspecified, returns all +// Cloudflare colos sorted alphabetically. +type DEXColoListParamsSortBy string + +const ( + DEXColoListParamsSortByFleetStatusUsage DEXColoListParamsSortBy = "fleet-status-usage" + DEXColoListParamsSortByApplicationTestsUsage DEXColoListParamsSortBy = "application-tests-usage" +) + +type DEXColoListResponseEnvelope struct { + Errors []DEXColoListResponseEnvelopeErrors `json:"errors,required"` + Messages []DEXColoListResponseEnvelopeMessages `json:"messages,required"` + // array of colos. + Result []DEXColoListResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success DEXColoListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DEXColoListResponseEnvelopeResultInfo `json:"result_info"` + JSON dexColoListResponseEnvelopeJSON `json:"-"` +} + +// dexColoListResponseEnvelopeJSON contains the JSON metadata for the struct +// [DEXColoListResponseEnvelope] +type dexColoListResponseEnvelopeJSON 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 *DEXColoListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexColoListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DEXColoListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexColoListResponseEnvelopeErrorsJSON `json:"-"` +} + +// dexColoListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [DEXColoListResponseEnvelopeErrors] +type dexColoListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXColoListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexColoListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DEXColoListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexColoListResponseEnvelopeMessagesJSON `json:"-"` +} + +// dexColoListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DEXColoListResponseEnvelopeMessages] +type dexColoListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXColoListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexColoListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DEXColoListResponseEnvelopeSuccess bool + +const ( + DEXColoListResponseEnvelopeSuccessTrue DEXColoListResponseEnvelopeSuccess = true +) + +type DEXColoListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON dexColoListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// dexColoListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [DEXColoListResponseEnvelopeResultInfo] +type dexColoListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXColoListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexColoListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/dexcolo_test.go b/zero_trust/dexcolo_test.go new file mode 100644 index 00000000000..7a1973b30aa --- /dev/null +++ b/zero_trust/dexcolo_test.go @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDEXColoListWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.DEX.Colos.List(context.TODO(), zero_trust.DEXColoListParams{ + AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), + TimeEnd: cloudflare.F("2023-08-24T20:45:00Z"), + TimeStart: cloudflare.F("2023-08-20T20:45:00Z"), + SortBy: cloudflare.F(zero_trust.DEXColoListParamsSortByFleetStatusUsage), + }) + 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/zero_trust/dexfleetstatus.go b/zero_trust/dexfleetstatus.go new file mode 100644 index 00000000000..2a29ad13029 --- /dev/null +++ b/zero_trust/dexfleetstatus.go @@ -0,0 +1,31 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// DEXFleetStatusService 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 [NewDEXFleetStatusService] method +// instead. +type DEXFleetStatusService struct { + Options []option.RequestOption + Devices *DEXFleetStatusDeviceService + Live *DEXFleetStatusLiveService + OverTime *DEXFleetStatusOverTimeService +} + +// NewDEXFleetStatusService 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 NewDEXFleetStatusService(opts ...option.RequestOption) (r *DEXFleetStatusService) { + r = &DEXFleetStatusService{} + r.Options = opts + r.Devices = NewDEXFleetStatusDeviceService(opts...) + r.Live = NewDEXFleetStatusLiveService(opts...) + r.OverTime = NewDEXFleetStatusOverTimeService(opts...) + return +} diff --git a/zero_trust/dexfleetstatusdevice.go b/zero_trust/dexfleetstatusdevice.go new file mode 100644 index 00000000000..b8c25476ade --- /dev/null +++ b/zero_trust/dexfleetstatusdevice.go @@ -0,0 +1,146 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" +) + +// DEXFleetStatusDeviceService 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 [NewDEXFleetStatusDeviceService] +// method instead. +type DEXFleetStatusDeviceService struct { + Options []option.RequestOption +} + +// NewDEXFleetStatusDeviceService 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 NewDEXFleetStatusDeviceService(opts ...option.RequestOption) (r *DEXFleetStatusDeviceService) { + r = &DEXFleetStatusDeviceService{} + r.Options = opts + return +} + +// List details for devices using WARP +func (r *DEXFleetStatusDeviceService) List(ctx context.Context, params DEXFleetStatusDeviceListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[DigitalExperienceMonitoringDevice], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("accounts/%s/dex/fleet-status/devices", params.AccountID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// List details for devices using WARP +func (r *DEXFleetStatusDeviceService) ListAutoPaging(ctx context.Context, params DEXFleetStatusDeviceListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[DigitalExperienceMonitoringDevice] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) +} + +type DigitalExperienceMonitoringDevice struct { + // Cloudflare colo + Colo string `json:"colo,required"` + // Device identifier (UUID v4) + DeviceID string `json:"deviceId,required"` + // Operating system + Platform string `json:"platform,required"` + // Network status + Status string `json:"status,required"` + // WARP client version + Version string `json:"version,required"` + // Device identifier (human readable) + DeviceName string `json:"deviceName"` + // User contact email address + PersonEmail string `json:"personEmail"` + JSON digitalExperienceMonitoringDeviceJSON `json:"-"` +} + +// digitalExperienceMonitoringDeviceJSON contains the JSON metadata for the struct +// [DigitalExperienceMonitoringDevice] +type digitalExperienceMonitoringDeviceJSON struct { + Colo apijson.Field + DeviceID apijson.Field + Platform apijson.Field + Status apijson.Field + Version apijson.Field + DeviceName apijson.Field + PersonEmail apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringDevice) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringDeviceJSON) RawJSON() string { + return r.raw +} + +type DEXFleetStatusDeviceListParams struct { + AccountID param.Field[string] `path:"account_id,required"` + // Page number of paginated results + Page param.Field[float64] `query:"page,required"` + // Number of items per page + PerPage param.Field[float64] `query:"per_page,required"` + // Timestamp in ISO format + TimeEnd param.Field[string] `query:"time_end,required"` + // Timestamp in ISO format + TimeStart param.Field[string] `query:"time_start,required"` + // Cloudflare colo + Colo param.Field[string] `query:"colo"` + // Device-specific ID, given as UUID v4 + DeviceID param.Field[string] `query:"device_id"` + // The mode under which the WARP client is run + Mode param.Field[string] `query:"mode"` + // Operating system + Platform param.Field[string] `query:"platform"` + // Dimension to sort results by + SortBy param.Field[DEXFleetStatusDeviceListParamsSortBy] `query:"sort_by"` + // Network status + Status param.Field[string] `query:"status"` + // WARP client version + Version param.Field[string] `query:"version"` +} + +// URLQuery serializes [DEXFleetStatusDeviceListParams]'s query parameters as +// `url.Values`. +func (r DEXFleetStatusDeviceListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Dimension to sort results by +type DEXFleetStatusDeviceListParamsSortBy string + +const ( + DEXFleetStatusDeviceListParamsSortByColo DEXFleetStatusDeviceListParamsSortBy = "colo" + DEXFleetStatusDeviceListParamsSortByDeviceID DEXFleetStatusDeviceListParamsSortBy = "device_id" + DEXFleetStatusDeviceListParamsSortByMode DEXFleetStatusDeviceListParamsSortBy = "mode" + DEXFleetStatusDeviceListParamsSortByPlatform DEXFleetStatusDeviceListParamsSortBy = "platform" + DEXFleetStatusDeviceListParamsSortByStatus DEXFleetStatusDeviceListParamsSortBy = "status" + DEXFleetStatusDeviceListParamsSortByTimestamp DEXFleetStatusDeviceListParamsSortBy = "timestamp" + DEXFleetStatusDeviceListParamsSortByVersion DEXFleetStatusDeviceListParamsSortBy = "version" +) diff --git a/zero_trust/dexfleetstatusdevice_test.go b/zero_trust/dexfleetstatusdevice_test.go new file mode 100644 index 00000000000..516ba34ebd7 --- /dev/null +++ b/zero_trust/dexfleetstatusdevice_test.go @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDEXFleetStatusDeviceListWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.DEX.FleetStatus.Devices.List(context.TODO(), zero_trust.DEXFleetStatusDeviceListParams{ + AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(10.000000), + TimeEnd: cloudflare.F("2023-10-11T00:00:00Z"), + TimeStart: cloudflare.F("2023-10-11T00:00:00Z"), + Colo: cloudflare.F("SJC"), + DeviceID: cloudflare.F("cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7"), + Mode: cloudflare.F("proxy"), + Platform: cloudflare.F("windows"), + SortBy: cloudflare.F(zero_trust.DEXFleetStatusDeviceListParamsSortByColo), + Status: cloudflare.F("connected"), + Version: cloudflare.F("1.0.0"), + }) + 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/zero_trust/dexfleetstatuslive.go b/zero_trust/dexfleetstatuslive.go new file mode 100644 index 00000000000..d7cbf6e3c6b --- /dev/null +++ b/zero_trust/dexfleetstatuslive.go @@ -0,0 +1,316 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DEXFleetStatusLiveService 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 [NewDEXFleetStatusLiveService] method +// instead. +type DEXFleetStatusLiveService struct { + Options []option.RequestOption +} + +// NewDEXFleetStatusLiveService 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 NewDEXFleetStatusLiveService(opts ...option.RequestOption) (r *DEXFleetStatusLiveService) { + r = &DEXFleetStatusLiveService{} + r.Options = opts + return +} + +// List details for live (up to 60 minutes) devices using WARP +func (r *DEXFleetStatusLiveService) List(ctx context.Context, params DEXFleetStatusLiveListParams, opts ...option.RequestOption) (res *DEXFleetStatusLiveListResponse, err error) { + opts = append(r.Options[:], opts...) + var env DEXFleetStatusLiveListResponseEnvelope + path := fmt.Sprintf("accounts/%s/dex/fleet-status/live", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DEXFleetStatusLiveListResponse struct { + DeviceStats DEXFleetStatusLiveListResponseDeviceStats `json:"deviceStats"` + JSON dexFleetStatusLiveListResponseJSON `json:"-"` +} + +// dexFleetStatusLiveListResponseJSON contains the JSON metadata for the struct +// [DEXFleetStatusLiveListResponse] +type dexFleetStatusLiveListResponseJSON struct { + DeviceStats apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXFleetStatusLiveListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexFleetStatusLiveListResponseJSON) RawJSON() string { + return r.raw +} + +type DEXFleetStatusLiveListResponseDeviceStats struct { + ByColo []DEXFleetStatusLiveListResponseDeviceStatsByColo `json:"byColo,nullable"` + ByMode []DEXFleetStatusLiveListResponseDeviceStatsByMode `json:"byMode,nullable"` + ByPlatform []DEXFleetStatusLiveListResponseDeviceStatsByPlatform `json:"byPlatform,nullable"` + ByStatus []DEXFleetStatusLiveListResponseDeviceStatsByStatus `json:"byStatus,nullable"` + ByVersion []DEXFleetStatusLiveListResponseDeviceStatsByVersion `json:"byVersion,nullable"` + // Number of unique devices + UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` + JSON dexFleetStatusLiveListResponseDeviceStatsJSON `json:"-"` +} + +// dexFleetStatusLiveListResponseDeviceStatsJSON contains the JSON metadata for the +// struct [DEXFleetStatusLiveListResponseDeviceStats] +type dexFleetStatusLiveListResponseDeviceStatsJSON struct { + ByColo apijson.Field + ByMode apijson.Field + ByPlatform apijson.Field + ByStatus apijson.Field + ByVersion apijson.Field + UniqueDevicesTotal apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXFleetStatusLiveListResponseDeviceStats) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexFleetStatusLiveListResponseDeviceStatsJSON) RawJSON() string { + return r.raw +} + +type DEXFleetStatusLiveListResponseDeviceStatsByColo struct { + // Number of unique devices + UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` + Value string `json:"value"` + JSON dexFleetStatusLiveListResponseDeviceStatsByColoJSON `json:"-"` +} + +// dexFleetStatusLiveListResponseDeviceStatsByColoJSON contains the JSON metadata +// for the struct [DEXFleetStatusLiveListResponseDeviceStatsByColo] +type dexFleetStatusLiveListResponseDeviceStatsByColoJSON struct { + UniqueDevicesTotal apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXFleetStatusLiveListResponseDeviceStatsByColo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexFleetStatusLiveListResponseDeviceStatsByColoJSON) RawJSON() string { + return r.raw +} + +type DEXFleetStatusLiveListResponseDeviceStatsByMode struct { + // Number of unique devices + UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` + Value string `json:"value"` + JSON dexFleetStatusLiveListResponseDeviceStatsByModeJSON `json:"-"` +} + +// dexFleetStatusLiveListResponseDeviceStatsByModeJSON contains the JSON metadata +// for the struct [DEXFleetStatusLiveListResponseDeviceStatsByMode] +type dexFleetStatusLiveListResponseDeviceStatsByModeJSON struct { + UniqueDevicesTotal apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXFleetStatusLiveListResponseDeviceStatsByMode) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexFleetStatusLiveListResponseDeviceStatsByModeJSON) RawJSON() string { + return r.raw +} + +type DEXFleetStatusLiveListResponseDeviceStatsByPlatform struct { + // Number of unique devices + UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` + Value string `json:"value"` + JSON dexFleetStatusLiveListResponseDeviceStatsByPlatformJSON `json:"-"` +} + +// dexFleetStatusLiveListResponseDeviceStatsByPlatformJSON contains the JSON +// metadata for the struct [DEXFleetStatusLiveListResponseDeviceStatsByPlatform] +type dexFleetStatusLiveListResponseDeviceStatsByPlatformJSON struct { + UniqueDevicesTotal apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXFleetStatusLiveListResponseDeviceStatsByPlatform) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexFleetStatusLiveListResponseDeviceStatsByPlatformJSON) RawJSON() string { + return r.raw +} + +type DEXFleetStatusLiveListResponseDeviceStatsByStatus struct { + // Number of unique devices + UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` + Value string `json:"value"` + JSON dexFleetStatusLiveListResponseDeviceStatsByStatusJSON `json:"-"` +} + +// dexFleetStatusLiveListResponseDeviceStatsByStatusJSON contains the JSON metadata +// for the struct [DEXFleetStatusLiveListResponseDeviceStatsByStatus] +type dexFleetStatusLiveListResponseDeviceStatsByStatusJSON struct { + UniqueDevicesTotal apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXFleetStatusLiveListResponseDeviceStatsByStatus) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexFleetStatusLiveListResponseDeviceStatsByStatusJSON) RawJSON() string { + return r.raw +} + +type DEXFleetStatusLiveListResponseDeviceStatsByVersion struct { + // Number of unique devices + UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` + Value string `json:"value"` + JSON dexFleetStatusLiveListResponseDeviceStatsByVersionJSON `json:"-"` +} + +// dexFleetStatusLiveListResponseDeviceStatsByVersionJSON contains the JSON +// metadata for the struct [DEXFleetStatusLiveListResponseDeviceStatsByVersion] +type dexFleetStatusLiveListResponseDeviceStatsByVersionJSON struct { + UniqueDevicesTotal apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXFleetStatusLiveListResponseDeviceStatsByVersion) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexFleetStatusLiveListResponseDeviceStatsByVersionJSON) RawJSON() string { + return r.raw +} + +type DEXFleetStatusLiveListParams struct { + AccountID param.Field[string] `path:"account_id,required"` + // Number of minutes before current time + SinceMinutes param.Field[float64] `query:"since_minutes,required"` +} + +// URLQuery serializes [DEXFleetStatusLiveListParams]'s query parameters as +// `url.Values`. +func (r DEXFleetStatusLiveListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type DEXFleetStatusLiveListResponseEnvelope struct { + Errors []DEXFleetStatusLiveListResponseEnvelopeErrors `json:"errors,required"` + Messages []DEXFleetStatusLiveListResponseEnvelopeMessages `json:"messages,required"` + Result DEXFleetStatusLiveListResponse `json:"result,required"` + // Whether the API call was successful + Success DEXFleetStatusLiveListResponseEnvelopeSuccess `json:"success,required"` + JSON dexFleetStatusLiveListResponseEnvelopeJSON `json:"-"` +} + +// dexFleetStatusLiveListResponseEnvelopeJSON contains the JSON metadata for the +// struct [DEXFleetStatusLiveListResponseEnvelope] +type dexFleetStatusLiveListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXFleetStatusLiveListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexFleetStatusLiveListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DEXFleetStatusLiveListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexFleetStatusLiveListResponseEnvelopeErrorsJSON `json:"-"` +} + +// dexFleetStatusLiveListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [DEXFleetStatusLiveListResponseEnvelopeErrors] +type dexFleetStatusLiveListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXFleetStatusLiveListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexFleetStatusLiveListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DEXFleetStatusLiveListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexFleetStatusLiveListResponseEnvelopeMessagesJSON `json:"-"` +} + +// dexFleetStatusLiveListResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [DEXFleetStatusLiveListResponseEnvelopeMessages] +type dexFleetStatusLiveListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXFleetStatusLiveListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexFleetStatusLiveListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DEXFleetStatusLiveListResponseEnvelopeSuccess bool + +const ( + DEXFleetStatusLiveListResponseEnvelopeSuccessTrue DEXFleetStatusLiveListResponseEnvelopeSuccess = true +) diff --git a/zero_trust/dexfleetstatuslive_test.go b/zero_trust/dexfleetstatuslive_test.go new file mode 100644 index 00000000000..9f8e10b30be --- /dev/null +++ b/zero_trust/dexfleetstatuslive_test.go @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDEXFleetStatusLiveList(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("user@example.com"), + ) + _, err := client.ZeroTrust.DEX.FleetStatus.Live.List(context.TODO(), zero_trust.DEXFleetStatusLiveListParams{ + AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), + SinceMinutes: cloudflare.F(10.000000), + }) + 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/zero_trust/dexfleetstatusovertime.go b/zero_trust/dexfleetstatusovertime.go new file mode 100644 index 00000000000..c58bbcac801 --- /dev/null +++ b/zero_trust/dexfleetstatusovertime.go @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DEXFleetStatusOverTimeService 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 [NewDEXFleetStatusOverTimeService] +// method instead. +type DEXFleetStatusOverTimeService struct { + Options []option.RequestOption +} + +// NewDEXFleetStatusOverTimeService 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 NewDEXFleetStatusOverTimeService(opts ...option.RequestOption) (r *DEXFleetStatusOverTimeService) { + r = &DEXFleetStatusOverTimeService{} + r.Options = opts + return +} + +// List details for devices using WARP, up to 7 days +func (r *DEXFleetStatusOverTimeService) List(ctx context.Context, params DEXFleetStatusOverTimeListParams, opts ...option.RequestOption) (err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + path := fmt.Sprintf("accounts/%s/dex/fleet-status/over-time", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, nil, opts...) + return +} + +type DEXFleetStatusOverTimeListParams struct { + AccountID param.Field[string] `path:"account_id,required"` + // Timestamp in ISO format + TimeEnd param.Field[string] `query:"time_end,required"` + // Timestamp in ISO format + TimeStart param.Field[string] `query:"time_start,required"` + // Cloudflare colo + Colo param.Field[string] `query:"colo"` + // Device-specific ID, given as UUID v4 + DeviceID param.Field[string] `query:"device_id"` +} + +// URLQuery serializes [DEXFleetStatusOverTimeListParams]'s query parameters as +// `url.Values`. +func (r DEXFleetStatusOverTimeListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/zero_trust/dexfleetstatusovertime_test.go b/zero_trust/dexfleetstatusovertime_test.go new file mode 100644 index 00000000000..e63ee60f9cc --- /dev/null +++ b/zero_trust/dexfleetstatusovertime_test.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDEXFleetStatusOverTimeListWithOptionalParams(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("user@example.com"), + ) + err := client.ZeroTrust.DEX.FleetStatus.OverTime.List(context.TODO(), zero_trust.DEXFleetStatusOverTimeListParams{ + AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), + TimeEnd: cloudflare.F("2023-10-11T00:00:00Z"), + TimeStart: cloudflare.F("2023-10-11T00:00:00Z"), + Colo: cloudflare.F("SJC"), + DeviceID: cloudflare.F("cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7"), + }) + 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/zero_trust/dexhttptest.go b/zero_trust/dexhttptest.go new file mode 100644 index 00000000000..e9c6758089d --- /dev/null +++ b/zero_trust/dexhttptest.go @@ -0,0 +1,658 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DEXHTTPTestService 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 [NewDEXHTTPTestService] method +// instead. +type DEXHTTPTestService struct { + Options []option.RequestOption + Percentiles *DEXHTTPTestPercentileService +} + +// NewDEXHTTPTestService 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 NewDEXHTTPTestService(opts ...option.RequestOption) (r *DEXHTTPTestService) { + r = &DEXHTTPTestService{} + r.Options = opts + r.Percentiles = NewDEXHTTPTestPercentileService(opts...) + return +} + +// Get test details and aggregate performance metrics for an http test for a given +// time period between 1 hour and 7 days. +func (r *DEXHTTPTestService) Get(ctx context.Context, testID string, params DEXHTTPTestGetParams, opts ...option.RequestOption) (res *DigitalExperienceMonitoringHTTPDetails, err error) { + opts = append(r.Options[:], opts...) + var env DexhttpTestGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/dex/http-tests/%s", params.AccountID, testID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DigitalExperienceMonitoringHTTPDetails struct { + // The url of the HTTP synthetic application test + Host string `json:"host"` + HTTPStats DigitalExperienceMonitoringHTTPDetailsHTTPStats `json:"httpStats,nullable"` + HTTPStatsByColo []DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColo `json:"httpStatsByColo"` + // The interval at which the HTTP synthetic application test is set to run. + Interval string `json:"interval"` + Kind DigitalExperienceMonitoringHTTPDetailsKind `json:"kind"` + // The HTTP method to use when running the test + Method string `json:"method"` + // The name of the HTTP synthetic application test + Name string `json:"name"` + JSON digitalExperienceMonitoringHTTPDetailsJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsJSON contains the JSON metadata for the +// struct [DigitalExperienceMonitoringHTTPDetails] +type digitalExperienceMonitoringHTTPDetailsJSON struct { + Host apijson.Field + HTTPStats apijson.Field + HTTPStatsByColo apijson.Field + Interval apijson.Field + Kind apijson.Field + Method apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetails) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsHTTPStats struct { + DNSResponseTimeMs DigitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMs `json:"dnsResponseTimeMs,required"` + HTTPStatusCode []DigitalExperienceMonitoringHTTPDetailsHTTPStatsHTTPStatusCode `json:"httpStatusCode,required"` + ResourceFetchTimeMs DigitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMs `json:"resourceFetchTimeMs,required"` + ServerResponseTimeMs DigitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMs `json:"serverResponseTimeMs,required"` + // Count of unique devices that have run this test in the given time period + UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` + JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsHTTPStatsJSON contains the JSON metadata +// for the struct [DigitalExperienceMonitoringHTTPDetailsHTTPStats] +type digitalExperienceMonitoringHTTPDetailsHTTPStatsJSON struct { + DNSResponseTimeMs apijson.Field + HTTPStatusCode apijson.Field + ResourceFetchTimeMs apijson.Field + ServerResponseTimeMs apijson.Field + UniqueDevicesTotal apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStats) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMs struct { + Slots []DigitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsSlot `json:"slots,required"` + // average observed in the time period + Avg int64 `json:"avg,nullable"` + // highest observed in the time period + Max int64 `json:"max,nullable"` + // lowest observed in the time period + Min int64 `json:"min,nullable"` + JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsJSON contains +// the JSON metadata for the struct +// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMs] +type digitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsJSON struct { + Slots apijson.Field + Avg apijson.Field + Max apijson.Field + Min apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsSlot struct { + Timestamp string `json:"timestamp,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsSlotJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsSlotJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsSlot] +type digitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsSlotJSON struct { + Timestamp apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsSlot) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsDNSResponseTimeMsSlotJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsHTTPStatsHTTPStatusCode struct { + Status200 int64 `json:"status200,required"` + Status300 int64 `json:"status300,required"` + Status400 int64 `json:"status400,required"` + Status500 int64 `json:"status500,required"` + Timestamp string `json:"timestamp,required"` + JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsHTTPStatusCodeJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsHTTPStatsHTTPStatusCodeJSON contains the +// JSON metadata for the struct +// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsHTTPStatusCode] +type digitalExperienceMonitoringHTTPDetailsHTTPStatsHTTPStatusCodeJSON struct { + Status200 apijson.Field + Status300 apijson.Field + Status400 apijson.Field + Status500 apijson.Field + Timestamp apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsHTTPStatusCode) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsHTTPStatusCodeJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMs struct { + Slots []DigitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsSlot `json:"slots,required"` + // average observed in the time period + Avg int64 `json:"avg,nullable"` + // highest observed in the time period + Max int64 `json:"max,nullable"` + // lowest observed in the time period + Min int64 `json:"min,nullable"` + JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsJSON contains +// the JSON metadata for the struct +// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMs] +type digitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsJSON struct { + Slots apijson.Field + Avg apijson.Field + Max apijson.Field + Min apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsSlot struct { + Timestamp string `json:"timestamp,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsSlotJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsSlotJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsSlot] +type digitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsSlotJSON struct { + Timestamp apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsSlot) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsResourceFetchTimeMsSlotJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMs struct { + Slots []DigitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsSlot `json:"slots,required"` + // average observed in the time period + Avg int64 `json:"avg,nullable"` + // highest observed in the time period + Max int64 `json:"max,nullable"` + // lowest observed in the time period + Min int64 `json:"min,nullable"` + JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsJSON contains +// the JSON metadata for the struct +// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMs] +type digitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsJSON struct { + Slots apijson.Field + Avg apijson.Field + Max apijson.Field + Min apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsSlot struct { + Timestamp string `json:"timestamp,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsSlotJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsSlotJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsSlot] +type digitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsSlotJSON struct { + Timestamp apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsSlot) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsServerResponseTimeMsSlotJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColo struct { + Colo string `json:"colo,required"` + DNSResponseTimeMs DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMs `json:"dnsResponseTimeMs,required"` + HTTPStatusCode []DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoHTTPStatusCode `json:"httpStatusCode,required"` + ResourceFetchTimeMs DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMs `json:"resourceFetchTimeMs,required"` + ServerResponseTimeMs DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMs `json:"serverResponseTimeMs,required"` + // Count of unique devices that have run this test in the given time period + UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` + JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoJSON contains the JSON +// metadata for the struct [DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColo] +type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoJSON struct { + Colo apijson.Field + DNSResponseTimeMs apijson.Field + HTTPStatusCode apijson.Field + ResourceFetchTimeMs apijson.Field + ServerResponseTimeMs apijson.Field + UniqueDevicesTotal apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMs struct { + Slots []DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsSlot `json:"slots,required"` + // average observed in the time period + Avg int64 `json:"avg,nullable"` + // highest observed in the time period + Max int64 `json:"max,nullable"` + // lowest observed in the time period + Min int64 `json:"min,nullable"` + JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMs] +type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsJSON struct { + Slots apijson.Field + Avg apijson.Field + Max apijson.Field + Min apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsSlot struct { + Timestamp string `json:"timestamp,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsSlotJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsSlotJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsSlot] +type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsSlotJSON struct { + Timestamp apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsSlot) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoDNSResponseTimeMsSlotJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoHTTPStatusCode struct { + Status200 int64 `json:"status200,required"` + Status300 int64 `json:"status300,required"` + Status400 int64 `json:"status400,required"` + Status500 int64 `json:"status500,required"` + Timestamp string `json:"timestamp,required"` + JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoHTTPStatusCodeJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoHTTPStatusCodeJSON contains +// the JSON metadata for the struct +// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoHTTPStatusCode] +type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoHTTPStatusCodeJSON struct { + Status200 apijson.Field + Status300 apijson.Field + Status400 apijson.Field + Status500 apijson.Field + Timestamp apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoHTTPStatusCode) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoHTTPStatusCodeJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMs struct { + Slots []DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsSlot `json:"slots,required"` + // average observed in the time period + Avg int64 `json:"avg,nullable"` + // highest observed in the time period + Max int64 `json:"max,nullable"` + // lowest observed in the time period + Min int64 `json:"min,nullable"` + JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMs] +type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsJSON struct { + Slots apijson.Field + Avg apijson.Field + Max apijson.Field + Min apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsSlot struct { + Timestamp string `json:"timestamp,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsSlotJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsSlotJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsSlot] +type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsSlotJSON struct { + Timestamp apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsSlot) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoResourceFetchTimeMsSlotJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMs struct { + Slots []DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsSlot `json:"slots,required"` + // average observed in the time period + Avg int64 `json:"avg,nullable"` + // highest observed in the time period + Max int64 `json:"max,nullable"` + // lowest observed in the time period + Min int64 `json:"min,nullable"` + JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMs] +type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsJSON struct { + Slots apijson.Field + Avg apijson.Field + Max apijson.Field + Min apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsSlot struct { + Timestamp string `json:"timestamp,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsSlotJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsSlotJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsSlot] +type digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsSlotJSON struct { + Timestamp apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsSlot) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsHTTPStatsByColoServerResponseTimeMsSlotJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsKind string + +const ( + DigitalExperienceMonitoringHTTPDetailsKindHTTP DigitalExperienceMonitoringHTTPDetailsKind = "http" +) + +type DEXHTTPTestGetParams struct { + AccountID param.Field[string] `path:"account_id,required"` + // Time interval for aggregate time slots. + Interval param.Field[DexhttpTestGetParamsInterval] `query:"interval,required"` + // End time for aggregate metrics in ISO ms + TimeEnd param.Field[string] `query:"timeEnd,required"` + // Start time for aggregate metrics in ISO ms + TimeStart param.Field[string] `query:"timeStart,required"` + // Optionally filter result stats to a Cloudflare colo. Cannot be used in + // combination with deviceId param. + Colo param.Field[string] `query:"colo"` + // Optionally filter result stats to a specific device(s). Cannot be used in + // combination with colo param. + DeviceID param.Field[[]string] `query:"deviceId"` +} + +// URLQuery serializes [DEXHTTPTestGetParams]'s query parameters as `url.Values`. +func (r DEXHTTPTestGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Time interval for aggregate time slots. +type DexhttpTestGetParamsInterval string + +const ( + DexhttpTestGetParamsIntervalMinute DexhttpTestGetParamsInterval = "minute" + DexhttpTestGetParamsIntervalHour DexhttpTestGetParamsInterval = "hour" +) + +type DexhttpTestGetResponseEnvelope struct { + Errors []DexhttpTestGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DexhttpTestGetResponseEnvelopeMessages `json:"messages,required"` + Result DigitalExperienceMonitoringHTTPDetails `json:"result,required"` + // Whether the API call was successful + Success DexhttpTestGetResponseEnvelopeSuccess `json:"success,required"` + JSON dexhttpTestGetResponseEnvelopeJSON `json:"-"` +} + +// dexhttpTestGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DexhttpTestGetResponseEnvelope] +type dexhttpTestGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DexhttpTestGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexhttpTestGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DexhttpTestGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexhttpTestGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// dexhttpTestGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DexhttpTestGetResponseEnvelopeErrors] +type dexhttpTestGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DexhttpTestGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexhttpTestGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DexhttpTestGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexhttpTestGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// dexhttpTestGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DexhttpTestGetResponseEnvelopeMessages] +type dexhttpTestGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DexhttpTestGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexhttpTestGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DexhttpTestGetResponseEnvelopeSuccess bool + +const ( + DexhttpTestGetResponseEnvelopeSuccessTrue DexhttpTestGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/dexhttptest_test.go b/zero_trust/dexhttptest_test.go new file mode 100644 index 00000000000..3a19ee8a412 --- /dev/null +++ b/zero_trust/dexhttptest_test.go @@ -0,0 +1,50 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDEXHTTPTestGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.DEX.HTTPTests.Get( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DEXHTTPTestGetParams{ + AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), + Interval: cloudflare.F(zero_trust.DexhttpTestGetParamsIntervalMinute), + TimeEnd: cloudflare.F("string"), + TimeStart: cloudflare.F("string"), + Colo: cloudflare.F("string"), + DeviceID: cloudflare.F([]string{"string", "string", "string"}), + }, + ) + 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/zero_trust/dexhttptestpercentile.go b/zero_trust/dexhttptestpercentile.go new file mode 100644 index 00000000000..fbc629e0c56 --- /dev/null +++ b/zero_trust/dexhttptestpercentile.go @@ -0,0 +1,273 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DEXHTTPTestPercentileService 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 [NewDEXHTTPTestPercentileService] +// method instead. +type DEXHTTPTestPercentileService struct { + Options []option.RequestOption +} + +// NewDEXHTTPTestPercentileService 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 NewDEXHTTPTestPercentileService(opts ...option.RequestOption) (r *DEXHTTPTestPercentileService) { + r = &DEXHTTPTestPercentileService{} + r.Options = opts + return +} + +// Get percentiles for an http test for a given time period between 1 hour and 7 +// days. +func (r *DEXHTTPTestPercentileService) List(ctx context.Context, testID string, params DEXHTTPTestPercentileListParams, opts ...option.RequestOption) (res *DigitalExperienceMonitoringHTTPDetailsPercentiles, err error) { + opts = append(r.Options[:], opts...) + var env DexhttpTestPercentileListResponseEnvelope + path := fmt.Sprintf("accounts/%s/dex/http-tests/%s/percentiles", params.AccountID, testID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DigitalExperienceMonitoringHTTPDetailsPercentiles struct { + DNSResponseTimeMs DigitalExperienceMonitoringHTTPDetailsPercentilesDNSResponseTimeMs `json:"dnsResponseTimeMs"` + ResourceFetchTimeMs DigitalExperienceMonitoringHTTPDetailsPercentilesResourceFetchTimeMs `json:"resourceFetchTimeMs"` + ServerResponseTimeMs DigitalExperienceMonitoringHTTPDetailsPercentilesServerResponseTimeMs `json:"serverResponseTimeMs"` + JSON digitalExperienceMonitoringHTTPDetailsPercentilesJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsPercentilesJSON contains the JSON metadata +// for the struct [DigitalExperienceMonitoringHTTPDetailsPercentiles] +type digitalExperienceMonitoringHTTPDetailsPercentilesJSON struct { + DNSResponseTimeMs apijson.Field + ResourceFetchTimeMs apijson.Field + ServerResponseTimeMs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsPercentiles) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsPercentilesJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsPercentilesDNSResponseTimeMs struct { + // p50 observed in the time period + P50 float64 `json:"p50,nullable"` + // p90 observed in the time period + P90 float64 `json:"p90,nullable"` + // p95 observed in the time period + P95 float64 `json:"p95,nullable"` + // p99 observed in the time period + P99 float64 `json:"p99,nullable"` + JSON digitalExperienceMonitoringHTTPDetailsPercentilesDNSResponseTimeMsJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsPercentilesDNSResponseTimeMsJSON contains +// the JSON metadata for the struct +// [DigitalExperienceMonitoringHTTPDetailsPercentilesDNSResponseTimeMs] +type digitalExperienceMonitoringHTTPDetailsPercentilesDNSResponseTimeMsJSON struct { + P50 apijson.Field + P90 apijson.Field + P95 apijson.Field + P99 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsPercentilesDNSResponseTimeMs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsPercentilesDNSResponseTimeMsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsPercentilesResourceFetchTimeMs struct { + // p50 observed in the time period + P50 float64 `json:"p50,nullable"` + // p90 observed in the time period + P90 float64 `json:"p90,nullable"` + // p95 observed in the time period + P95 float64 `json:"p95,nullable"` + // p99 observed in the time period + P99 float64 `json:"p99,nullable"` + JSON digitalExperienceMonitoringHTTPDetailsPercentilesResourceFetchTimeMsJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsPercentilesResourceFetchTimeMsJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringHTTPDetailsPercentilesResourceFetchTimeMs] +type digitalExperienceMonitoringHTTPDetailsPercentilesResourceFetchTimeMsJSON struct { + P50 apijson.Field + P90 apijson.Field + P95 apijson.Field + P99 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsPercentilesResourceFetchTimeMs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsPercentilesResourceFetchTimeMsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringHTTPDetailsPercentilesServerResponseTimeMs struct { + // p50 observed in the time period + P50 float64 `json:"p50,nullable"` + // p90 observed in the time period + P90 float64 `json:"p90,nullable"` + // p95 observed in the time period + P95 float64 `json:"p95,nullable"` + // p99 observed in the time period + P99 float64 `json:"p99,nullable"` + JSON digitalExperienceMonitoringHTTPDetailsPercentilesServerResponseTimeMsJSON `json:"-"` +} + +// digitalExperienceMonitoringHTTPDetailsPercentilesServerResponseTimeMsJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringHTTPDetailsPercentilesServerResponseTimeMs] +type digitalExperienceMonitoringHTTPDetailsPercentilesServerResponseTimeMsJSON struct { + P50 apijson.Field + P90 apijson.Field + P95 apijson.Field + P99 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringHTTPDetailsPercentilesServerResponseTimeMs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringHTTPDetailsPercentilesServerResponseTimeMsJSON) RawJSON() string { + return r.raw +} + +type DEXHTTPTestPercentileListParams struct { + AccountID param.Field[string] `path:"account_id,required"` + // End time for aggregate metrics in ISO format + TimeEnd param.Field[string] `query:"timeEnd,required"` + // Start time for aggregate metrics in ISO format + TimeStart param.Field[string] `query:"timeStart,required"` + // Optionally filter result stats to a Cloudflare colo. Cannot be used in + // combination with deviceId param. + Colo param.Field[string] `query:"colo"` + // Optionally filter result stats to a specific device(s). Cannot be used in + // combination with colo param. + DeviceID param.Field[[]string] `query:"deviceId"` +} + +// URLQuery serializes [DEXHTTPTestPercentileListParams]'s query parameters as +// `url.Values`. +func (r DEXHTTPTestPercentileListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type DexhttpTestPercentileListResponseEnvelope struct { + Errors []DexhttpTestPercentileListResponseEnvelopeErrors `json:"errors,required"` + Messages []DexhttpTestPercentileListResponseEnvelopeMessages `json:"messages,required"` + Result DigitalExperienceMonitoringHTTPDetailsPercentiles `json:"result,required"` + // Whether the API call was successful + Success DexhttpTestPercentileListResponseEnvelopeSuccess `json:"success,required"` + JSON dexhttpTestPercentileListResponseEnvelopeJSON `json:"-"` +} + +// dexhttpTestPercentileListResponseEnvelopeJSON contains the JSON metadata for the +// struct [DexhttpTestPercentileListResponseEnvelope] +type dexhttpTestPercentileListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DexhttpTestPercentileListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexhttpTestPercentileListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DexhttpTestPercentileListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexhttpTestPercentileListResponseEnvelopeErrorsJSON `json:"-"` +} + +// dexhttpTestPercentileListResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [DexhttpTestPercentileListResponseEnvelopeErrors] +type dexhttpTestPercentileListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DexhttpTestPercentileListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexhttpTestPercentileListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DexhttpTestPercentileListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexhttpTestPercentileListResponseEnvelopeMessagesJSON `json:"-"` +} + +// dexhttpTestPercentileListResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [DexhttpTestPercentileListResponseEnvelopeMessages] +type dexhttpTestPercentileListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DexhttpTestPercentileListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexhttpTestPercentileListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DexhttpTestPercentileListResponseEnvelopeSuccess bool + +const ( + DexhttpTestPercentileListResponseEnvelopeSuccessTrue DexhttpTestPercentileListResponseEnvelopeSuccess = true +) diff --git a/zero_trust/dexhttptestpercentile_test.go b/zero_trust/dexhttptestpercentile_test.go new file mode 100644 index 00000000000..5dda02a6336 --- /dev/null +++ b/zero_trust/dexhttptestpercentile_test.go @@ -0,0 +1,49 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDEXHTTPTestPercentileListWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.DEX.HTTPTests.Percentiles.List( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DEXHTTPTestPercentileListParams{ + AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), + TimeEnd: cloudflare.F("2023-09-20T17:00:00Z"), + TimeStart: cloudflare.F("2023-09-20T17:00:00Z"), + Colo: cloudflare.F("string"), + DeviceID: cloudflare.F([]string{"string", "string", "string"}), + }, + ) + 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/zero_trust/dextest.go b/zero_trust/dextest.go new file mode 100644 index 00000000000..cb2d1c7ee4c --- /dev/null +++ b/zero_trust/dextest.go @@ -0,0 +1,1057 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" +) + +// DEXTestService 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 [NewDEXTestService] method instead. +type DEXTestService struct { + Options []option.RequestOption + UniqueDevices *DEXTestUniqueDeviceService +} + +// NewDEXTestService 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 NewDEXTestService(opts ...option.RequestOption) (r *DEXTestService) { + r = &DEXTestService{} + r.Options = opts + r.UniqueDevices = NewDEXTestUniqueDeviceService(opts...) + return +} + +// List DEX tests +func (r *DEXTestService) List(ctx context.Context, params DEXTestListParams, opts ...option.RequestOption) (res *shared.V4PagePagination[DEXTestListResponse], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("accounts/%s/dex/tests", params.AccountID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// List DEX tests +func (r *DEXTestService) ListAutoPaging(ctx context.Context, params DEXTestListParams, opts ...option.RequestOption) *shared.V4PagePaginationAutoPager[DEXTestListResponse] { + return shared.NewV4PagePaginationAutoPager(r.List(ctx, params, opts...)) +} + +type DigitalExperienceMonitoringTests struct { + OverviewMetrics DigitalExperienceMonitoringTestsOverviewMetrics `json:"overviewMetrics,required"` + // array of test results objects. + Tests []DigitalExperienceMonitoringTestsTest `json:"tests,required"` + JSON digitalExperienceMonitoringTestsJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsJSON contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTests] +type digitalExperienceMonitoringTestsJSON struct { + OverviewMetrics apijson.Field + Tests apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTests) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsOverviewMetrics struct { + // number of tests. + TestsTotal int64 `json:"testsTotal,required"` + // percentage availability for all traceroutes results in response + AvgTracerouteAvailabilityPct float64 `json:"avgTracerouteAvailabilityPct,nullable"` + JSON digitalExperienceMonitoringTestsOverviewMetricsJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsOverviewMetricsJSON contains the JSON metadata +// for the struct [DigitalExperienceMonitoringTestsOverviewMetrics] +type digitalExperienceMonitoringTestsOverviewMetricsJSON struct { + TestsTotal apijson.Field + AvgTracerouteAvailabilityPct apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsOverviewMetrics) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsOverviewMetricsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTest struct { + // API Resource UUID tag. + ID string `json:"id,required"` + // date the test was created. + Created string `json:"created,required"` + // the test description defined during configuration + Description string `json:"description,required"` + // if true, then the test will run on targeted devices. Else, the test will not + // run. + Enabled bool `json:"enabled,required"` + Host string `json:"host,required"` + // The interval at which the synthetic application test is set to run. + Interval string `json:"interval,required"` + // test type, http or traceroute + Kind DigitalExperienceMonitoringTestsTestsKind `json:"kind,required"` + // name given to this test + Name string `json:"name,required"` + Updated string `json:"updated,required"` + HTTPResults DigitalExperienceMonitoringTestsTestsHTTPResults `json:"httpResults,nullable"` + HTTPResultsByColo []DigitalExperienceMonitoringTestsTestsHTTPResultsByColo `json:"httpResultsByColo"` + // for HTTP, the method to use when running the test + Method string `json:"method"` + TracerouteResults DigitalExperienceMonitoringTestsTestsTracerouteResults `json:"tracerouteResults,nullable"` + TracerouteResultsByColo []DigitalExperienceMonitoringTestsTestsTracerouteResultsByColo `json:"tracerouteResultsByColo"` + JSON digitalExperienceMonitoringTestsTestJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestJSON contains the JSON metadata for the +// struct [DigitalExperienceMonitoringTestsTest] +type digitalExperienceMonitoringTestsTestJSON struct { + ID apijson.Field + Created apijson.Field + Description apijson.Field + Enabled apijson.Field + Host apijson.Field + Interval apijson.Field + Kind apijson.Field + Name apijson.Field + Updated apijson.Field + HTTPResults apijson.Field + HTTPResultsByColo apijson.Field + Method apijson.Field + TracerouteResults apijson.Field + TracerouteResultsByColo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTest) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestJSON) RawJSON() string { + return r.raw +} + +// test type, http or traceroute +type DigitalExperienceMonitoringTestsTestsKind string + +const ( + DigitalExperienceMonitoringTestsTestsKindHTTP DigitalExperienceMonitoringTestsTestsKind = "http" + DigitalExperienceMonitoringTestsTestsKindTraceroute DigitalExperienceMonitoringTestsTestsKind = "traceroute" +) + +type DigitalExperienceMonitoringTestsTestsHTTPResults struct { + ResourceFetchTime DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTime `json:"resourceFetchTime,required"` + JSON digitalExperienceMonitoringTestsTestsHTTPResultsJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsHTTPResultsJSON contains the JSON metadata +// for the struct [DigitalExperienceMonitoringTestsTestsHTTPResults] +type digitalExperienceMonitoringTestsTestsHTTPResultsJSON struct { + ResourceFetchTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsHTTPResults) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsHTTPResultsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTime struct { + History []DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistory `json:"history,required"` + AvgMs int64 `json:"avgMs,nullable"` + OverTime DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTime `json:"overTime,nullable"` + JSON digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeJSON contains +// the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTime] +type digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeJSON struct { + History apijson.Field + AvgMs apijson.Field + OverTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTime) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistory struct { + TimePeriod DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriod `json:"timePeriod,required"` + AvgMs int64 `json:"avgMs,nullable"` + DeltaPct float64 `json:"deltaPct,nullable"` + JSON digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistory] +type digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryJSON struct { + TimePeriod apijson.Field + AvgMs apijson.Field + DeltaPct apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistory) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriod struct { + Units DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnits `json:"units,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriod] +type digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodJSON struct { + Units apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriod) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnits string + +const ( + DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnitsHours DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnits = "hours" + DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnitsDays DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnits = "days" + DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnitsTestRuns DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnits = "testRuns" +) + +type DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTime struct { + TimePeriod DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriod `json:"timePeriod,required"` + Values []DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeValue `json:"values,required"` + JSON digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTime] +type digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeJSON struct { + TimePeriod apijson.Field + Values apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTime) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriod struct { + Units DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnits `json:"units,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriod] +type digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodJSON struct { + Units apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriod) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnits string + +const ( + DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnitsHours DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnits = "hours" + DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnitsDays DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnits = "days" + DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnitsTestRuns DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnits = "testRuns" +) + +type DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeValue struct { + AvgMs int64 `json:"avgMs,required"` + Timestamp string `json:"timestamp,required"` + JSON digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeValueJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeValueJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeValue] +type digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeValueJSON struct { + AvgMs apijson.Field + Timestamp apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeValue) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsHTTPResultsResourceFetchTimeOverTimeValueJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsHTTPResultsByColo struct { + // Cloudflare colo + Colo string `json:"colo,required"` + ResourceFetchTime DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTime `json:"resourceFetchTime,required"` + JSON digitalExperienceMonitoringTestsTestsHTTPResultsByColoJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsHTTPResultsByColoJSON contains the JSON +// metadata for the struct [DigitalExperienceMonitoringTestsTestsHTTPResultsByColo] +type digitalExperienceMonitoringTestsTestsHTTPResultsByColoJSON struct { + Colo apijson.Field + ResourceFetchTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsByColo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsHTTPResultsByColoJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTime struct { + History []DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistory `json:"history,required"` + AvgMs int64 `json:"avgMs,nullable"` + OverTime DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTime `json:"overTime,nullable"` + JSON digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTime] +type digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeJSON struct { + History apijson.Field + AvgMs apijson.Field + OverTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTime) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistory struct { + TimePeriod DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriod `json:"timePeriod,required"` + AvgMs int64 `json:"avgMs,nullable"` + DeltaPct float64 `json:"deltaPct,nullable"` + JSON digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistory] +type digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryJSON struct { + TimePeriod apijson.Field + AvgMs apijson.Field + DeltaPct apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistory) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriod struct { + Units DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnits `json:"units,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriod] +type digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodJSON struct { + Units apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriod) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnits string + +const ( + DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnitsHours DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnits = "hours" + DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnitsDays DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnits = "days" + DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnitsTestRuns DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnits = "testRuns" +) + +type DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTime struct { + TimePeriod DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriod `json:"timePeriod,required"` + Values []DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValue `json:"values,required"` + JSON digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTime] +type digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeJSON struct { + TimePeriod apijson.Field + Values apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTime) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriod struct { + Units DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnits `json:"units,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriod] +type digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodJSON struct { + Units apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriod) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnits string + +const ( + DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnitsHours DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnits = "hours" + DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnitsDays DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnits = "days" + DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnitsTestRuns DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnits = "testRuns" +) + +type DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValue struct { + AvgMs int64 `json:"avgMs,required"` + Timestamp string `json:"timestamp,required"` + JSON digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValueJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValueJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValue] +type digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValueJSON struct { + AvgMs apijson.Field + Timestamp apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValue) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsHTTPResultsByColoResourceFetchTimeOverTimeValueJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsTracerouteResults struct { + RoundTripTime DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTime `json:"roundTripTime,required"` + JSON digitalExperienceMonitoringTestsTestsTracerouteResultsJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsTracerouteResultsJSON contains the JSON +// metadata for the struct [DigitalExperienceMonitoringTestsTestsTracerouteResults] +type digitalExperienceMonitoringTestsTestsTracerouteResultsJSON struct { + RoundTripTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsTracerouteResults) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsTracerouteResultsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTime struct { + History []DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistory `json:"history,required"` + AvgMs int64 `json:"avgMs,nullable"` + OverTime DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTime `json:"overTime,nullable"` + JSON digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeJSON contains +// the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTime] +type digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeJSON struct { + History apijson.Field + AvgMs apijson.Field + OverTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTime) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistory struct { + TimePeriod DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriod `json:"timePeriod,required"` + AvgMs int64 `json:"avgMs,nullable"` + DeltaPct float64 `json:"deltaPct,nullable"` + JSON digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistory] +type digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryJSON struct { + TimePeriod apijson.Field + AvgMs apijson.Field + DeltaPct apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistory) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriod struct { + Units DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnits `json:"units,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriod] +type digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodJSON struct { + Units apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriod) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnits string + +const ( + DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnitsHours DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnits = "hours" + DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnitsDays DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnits = "days" + DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnitsTestRuns DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnits = "testRuns" +) + +type DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTime struct { + TimePeriod DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriod `json:"timePeriod,required"` + Values []DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeValue `json:"values,required"` + JSON digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTime] +type digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeJSON struct { + TimePeriod apijson.Field + Values apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTime) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriod struct { + Units DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnits `json:"units,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriod] +type digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodJSON struct { + Units apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriod) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnits string + +const ( + DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnitsHours DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnits = "hours" + DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnitsDays DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnits = "days" + DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnitsTestRuns DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnits = "testRuns" +) + +type DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeValue struct { + AvgMs int64 `json:"avgMs,required"` + Timestamp string `json:"timestamp,required"` + JSON digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeValueJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeValueJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeValue] +type digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeValueJSON struct { + AvgMs apijson.Field + Timestamp apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeValue) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsTracerouteResultsRoundTripTimeOverTimeValueJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsTracerouteResultsByColo struct { + // Cloudflare colo + Colo string `json:"colo,required"` + RoundTripTime DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTime `json:"roundTripTime,required"` + JSON digitalExperienceMonitoringTestsTestsTracerouteResultsByColoJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsTracerouteResultsByColoJSON contains the +// JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsTracerouteResultsByColo] +type digitalExperienceMonitoringTestsTestsTracerouteResultsByColoJSON struct { + Colo apijson.Field + RoundTripTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsByColo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsTracerouteResultsByColoJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTime struct { + History []DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistory `json:"history,required"` + AvgMs int64 `json:"avgMs,nullable"` + OverTime DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTime `json:"overTime,nullable"` + JSON digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTime] +type digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeJSON struct { + History apijson.Field + AvgMs apijson.Field + OverTime apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTime) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistory struct { + TimePeriod DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriod `json:"timePeriod,required"` + AvgMs int64 `json:"avgMs,nullable"` + DeltaPct float64 `json:"deltaPct,nullable"` + JSON digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistory] +type digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryJSON struct { + TimePeriod apijson.Field + AvgMs apijson.Field + DeltaPct apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistory) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriod struct { + Units DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnits `json:"units,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriod] +type digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodJSON struct { + Units apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriod) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnits string + +const ( + DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnitsHours DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnits = "hours" + DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnitsDays DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnits = "days" + DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnitsTestRuns DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnits = "testRuns" +) + +type DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTime struct { + TimePeriod DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriod `json:"timePeriod,required"` + Values []DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValue `json:"values,required"` + JSON digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTime] +type digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeJSON struct { + TimePeriod apijson.Field + Values apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTime) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriod struct { + Units DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnits `json:"units,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriod] +type digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodJSON struct { + Units apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriod) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnits string + +const ( + DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnitsHours DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnits = "hours" + DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnitsDays DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnits = "days" + DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnitsTestRuns DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnits = "testRuns" +) + +type DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValue struct { + AvgMs int64 `json:"avgMs,required"` + Timestamp string `json:"timestamp,required"` + JSON digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValueJSON `json:"-"` +} + +// digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValueJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValue] +type digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValueJSON struct { + AvgMs apijson.Field + Timestamp apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValue) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTestsTestsTracerouteResultsByColoRoundTripTimeOverTimeValueJSON) RawJSON() string { + return r.raw +} + +type DEXTestListResponse struct { + Errors []DEXTestListResponseError `json:"errors,required"` + Messages []DEXTestListResponseMessage `json:"messages,required"` + Result DigitalExperienceMonitoringTests `json:"result,required"` + // Whether the API call was successful + Success DEXTestListResponseSuccess `json:"success,required"` + ResultInfo DEXTestListResponseResultInfo `json:"result_info"` + JSON dexTestListResponseJSON `json:"-"` +} + +// dexTestListResponseJSON contains the JSON metadata for the struct +// [DEXTestListResponse] +type dexTestListResponseJSON 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 *DEXTestListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTestListResponseJSON) RawJSON() string { + return r.raw +} + +type DEXTestListResponseError struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexTestListResponseErrorJSON `json:"-"` +} + +// dexTestListResponseErrorJSON contains the JSON metadata for the struct +// [DEXTestListResponseError] +type dexTestListResponseErrorJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXTestListResponseError) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTestListResponseErrorJSON) RawJSON() string { + return r.raw +} + +type DEXTestListResponseMessage struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexTestListResponseMessageJSON `json:"-"` +} + +// dexTestListResponseMessageJSON contains the JSON metadata for the struct +// [DEXTestListResponseMessage] +type dexTestListResponseMessageJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXTestListResponseMessage) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTestListResponseMessageJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DEXTestListResponseSuccess bool + +const ( + DEXTestListResponseSuccessTrue DEXTestListResponseSuccess = true +) + +type DEXTestListResponseResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON dexTestListResponseResultInfoJSON `json:"-"` +} + +// dexTestListResponseResultInfoJSON contains the JSON metadata for the struct +// [DEXTestListResponseResultInfo] +type dexTestListResponseResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXTestListResponseResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTestListResponseResultInfoJSON) RawJSON() string { + return r.raw +} + +type DEXTestListParams struct { + AccountID param.Field[string] `path:"account_id,required"` + // Optionally filter result stats to a Cloudflare colo. Cannot be used in + // combination with deviceId param. + Colo param.Field[string] `query:"colo"` + // Optionally filter result stats to a specific device(s). Cannot be used in + // combination with colo param. + DeviceID param.Field[[]string] `query:"deviceId"` + // Page number of paginated results + Page param.Field[float64] `query:"page"` + // Number of items per page + PerPage param.Field[float64] `query:"per_page"` + // Optionally filter results by test name + TestName param.Field[string] `query:"testName"` +} + +// URLQuery serializes [DEXTestListParams]'s query parameters as `url.Values`. +func (r DEXTestListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} diff --git a/zero_trust/dextest_test.go b/zero_trust/dextest_test.go new file mode 100644 index 00000000000..e4a84100c38 --- /dev/null +++ b/zero_trust/dextest_test.go @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDEXTestListWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.DEX.Tests.List(context.TODO(), zero_trust.DEXTestListParams{ + AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), + Colo: cloudflare.F("string"), + DeviceID: cloudflare.F([]string{"string", "string", "string"}), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(1.000000), + TestName: cloudflare.F("string"), + }) + 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/zero_trust/dextestuniquedevice.go b/zero_trust/dextestuniquedevice.go new file mode 100644 index 00000000000..344b24a8c6c --- /dev/null +++ b/zero_trust/dextestuniquedevice.go @@ -0,0 +1,169 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DEXTestUniqueDeviceService 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 [NewDEXTestUniqueDeviceService] +// method instead. +type DEXTestUniqueDeviceService struct { + Options []option.RequestOption +} + +// NewDEXTestUniqueDeviceService 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 NewDEXTestUniqueDeviceService(opts ...option.RequestOption) (r *DEXTestUniqueDeviceService) { + r = &DEXTestUniqueDeviceService{} + r.Options = opts + return +} + +// Returns unique count of devices that have run synthetic application monitoring +// tests in the past 7 days. +func (r *DEXTestUniqueDeviceService) List(ctx context.Context, params DEXTestUniqueDeviceListParams, opts ...option.RequestOption) (res *DigitalExperienceMonitoringUniqueDevices, err error) { + opts = append(r.Options[:], opts...) + var env DEXTestUniqueDeviceListResponseEnvelope + path := fmt.Sprintf("accounts/%s/dex/tests/unique-devices", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DigitalExperienceMonitoringUniqueDevices struct { + // total number of unique devices + UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` + JSON digitalExperienceMonitoringUniqueDevicesJSON `json:"-"` +} + +// digitalExperienceMonitoringUniqueDevicesJSON contains the JSON metadata for the +// struct [DigitalExperienceMonitoringUniqueDevices] +type digitalExperienceMonitoringUniqueDevicesJSON struct { + UniqueDevicesTotal apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringUniqueDevices) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringUniqueDevicesJSON) RawJSON() string { + return r.raw +} + +type DEXTestUniqueDeviceListParams struct { + AccountID param.Field[string] `path:"account_id,required"` + // Optionally filter result stats to a specific device(s). Cannot be used in + // combination with colo param. + DeviceID param.Field[[]string] `query:"deviceId"` + // Optionally filter results by test name + TestName param.Field[string] `query:"testName"` +} + +// URLQuery serializes [DEXTestUniqueDeviceListParams]'s query parameters as +// `url.Values`. +func (r DEXTestUniqueDeviceListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type DEXTestUniqueDeviceListResponseEnvelope struct { + Errors []DEXTestUniqueDeviceListResponseEnvelopeErrors `json:"errors,required"` + Messages []DEXTestUniqueDeviceListResponseEnvelopeMessages `json:"messages,required"` + Result DigitalExperienceMonitoringUniqueDevices `json:"result,required"` + // Whether the API call was successful + Success DEXTestUniqueDeviceListResponseEnvelopeSuccess `json:"success,required"` + JSON dexTestUniqueDeviceListResponseEnvelopeJSON `json:"-"` +} + +// dexTestUniqueDeviceListResponseEnvelopeJSON contains the JSON metadata for the +// struct [DEXTestUniqueDeviceListResponseEnvelope] +type dexTestUniqueDeviceListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXTestUniqueDeviceListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTestUniqueDeviceListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DEXTestUniqueDeviceListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexTestUniqueDeviceListResponseEnvelopeErrorsJSON `json:"-"` +} + +// dexTestUniqueDeviceListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [DEXTestUniqueDeviceListResponseEnvelopeErrors] +type dexTestUniqueDeviceListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXTestUniqueDeviceListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTestUniqueDeviceListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DEXTestUniqueDeviceListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexTestUniqueDeviceListResponseEnvelopeMessagesJSON `json:"-"` +} + +// dexTestUniqueDeviceListResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [DEXTestUniqueDeviceListResponseEnvelopeMessages] +type dexTestUniqueDeviceListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXTestUniqueDeviceListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTestUniqueDeviceListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DEXTestUniqueDeviceListResponseEnvelopeSuccess bool + +const ( + DEXTestUniqueDeviceListResponseEnvelopeSuccessTrue DEXTestUniqueDeviceListResponseEnvelopeSuccess = true +) diff --git a/zero_trust/dextestuniquedevice_test.go b/zero_trust/dextestuniquedevice_test.go new file mode 100644 index 00000000000..80571f39057 --- /dev/null +++ b/zero_trust/dextestuniquedevice_test.go @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDEXTestUniqueDeviceListWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.DEX.Tests.UniqueDevices.List(context.TODO(), zero_trust.DEXTestUniqueDeviceListParams{ + AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), + DeviceID: cloudflare.F([]string{"string", "string", "string"}), + TestName: cloudflare.F("string"), + }) + 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/zero_trust/dextraceroutetest.go b/zero_trust/dextraceroutetest.go new file mode 100644 index 00000000000..6f213d7922c --- /dev/null +++ b/zero_trust/dextraceroutetest.go @@ -0,0 +1,1208 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DEXTracerouteTestService 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 [NewDEXTracerouteTestService] method +// instead. +type DEXTracerouteTestService struct { + Options []option.RequestOption +} + +// NewDEXTracerouteTestService 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 NewDEXTracerouteTestService(opts ...option.RequestOption) (r *DEXTracerouteTestService) { + r = &DEXTracerouteTestService{} + r.Options = opts + return +} + +// Get test details and aggregate performance metrics for an traceroute test for a +// given time period between 1 hour and 7 days. +func (r *DEXTracerouteTestService) Get(ctx context.Context, testID string, params DEXTracerouteTestGetParams, opts ...option.RequestOption) (res *DigitalExperienceMonitoringTracerouteDetails, err error) { + opts = append(r.Options[:], opts...) + var env DEXTracerouteTestGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/dex/traceroute-tests/%s", params.AccountID, testID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get a breakdown of metrics by hop for individual traceroute test runs +func (r *DEXTracerouteTestService) NetworkPath(ctx context.Context, testID string, params DEXTracerouteTestNetworkPathParams, opts ...option.RequestOption) (res *DigitalExperienceMonitoringTracerouteTestNetworkPath, err error) { + opts = append(r.Options[:], opts...) + var env DEXTracerouteTestNetworkPathResponseEnvelope + path := fmt.Sprintf("accounts/%s/dex/traceroute-tests/%s/network-path", params.AccountID, testID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get percentiles for a traceroute test for a given time period between 1 hour and +// 7 days. +func (r *DEXTracerouteTestService) Percentiles(ctx context.Context, testID string, params DEXTracerouteTestPercentilesParams, opts ...option.RequestOption) (res *DigitalExperienceMonitoringTracerouteDetailsPercentiles, err error) { + opts = append(r.Options[:], opts...) + var env DEXTracerouteTestPercentilesResponseEnvelope + path := fmt.Sprintf("accounts/%s/dex/traceroute-tests/%s/percentiles", params.AccountID, testID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DigitalExperienceMonitoringTracerouteDetails struct { + // The host of the Traceroute synthetic application test + Host string `json:"host,required"` + // The interval at which the Traceroute synthetic application test is set to run. + Interval string `json:"interval,required"` + Kind DigitalExperienceMonitoringTracerouteDetailsKind `json:"kind,required"` + // The name of the Traceroute synthetic application test + Name string `json:"name,required"` + TracerouteStats DigitalExperienceMonitoringTracerouteDetailsTracerouteStats `json:"tracerouteStats,nullable"` + TracerouteStatsByColo []DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColo `json:"tracerouteStatsByColo"` + JSON digitalExperienceMonitoringTracerouteDetailsJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsJSON contains the JSON metadata for +// the struct [DigitalExperienceMonitoringTracerouteDetails] +type digitalExperienceMonitoringTracerouteDetailsJSON struct { + Host apijson.Field + Interval apijson.Field + Kind apijson.Field + Name apijson.Field + TracerouteStats apijson.Field + TracerouteStatsByColo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetails) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsKind string + +const ( + DigitalExperienceMonitoringTracerouteDetailsKindTraceroute DigitalExperienceMonitoringTracerouteDetailsKind = "traceroute" +) + +type DigitalExperienceMonitoringTracerouteDetailsTracerouteStats struct { + AvailabilityPct DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPct `json:"availabilityPct,required"` + HopsCount DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCount `json:"hopsCount,required"` + PacketLossPct DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPct `json:"packetLossPct,required"` + RoundTripTimeMs DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMs `json:"roundTripTimeMs,required"` + // Count of unique devices that have run this test in the given time period + UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` + JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsJSON contains the +// JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStats] +type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsJSON struct { + AvailabilityPct apijson.Field + HopsCount apijson.Field + PacketLossPct apijson.Field + RoundTripTimeMs apijson.Field + UniqueDevicesTotal apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStats) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPct struct { + Slots []DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctSlot `json:"slots,required"` + // average observed in the time period + Avg float64 `json:"avg,nullable"` + // highest observed in the time period + Max float64 `json:"max,nullable"` + // lowest observed in the time period + Min float64 `json:"min,nullable"` + JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPct] +type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctJSON struct { + Slots apijson.Field + Avg apijson.Field + Max apijson.Field + Min apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPct) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctSlot struct { + Timestamp string `json:"timestamp,required"` + Value float64 `json:"value,required"` + JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctSlotJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctSlotJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctSlot] +type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctSlotJSON struct { + Timestamp apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctSlot) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsAvailabilityPctSlotJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCount struct { + Slots []DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountSlot `json:"slots,required"` + // average observed in the time period + Avg int64 `json:"avg,nullable"` + // highest observed in the time period + Max int64 `json:"max,nullable"` + // lowest observed in the time period + Min int64 `json:"min,nullable"` + JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCount] +type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountJSON struct { + Slots apijson.Field + Avg apijson.Field + Max apijson.Field + Min apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCount) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountSlot struct { + Timestamp string `json:"timestamp,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountSlotJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountSlotJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountSlot] +type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountSlotJSON struct { + Timestamp apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountSlot) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsHopsCountSlotJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPct struct { + Slots []DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctSlot `json:"slots,required"` + // average observed in the time period + Avg float64 `json:"avg,nullable"` + // highest observed in the time period + Max float64 `json:"max,nullable"` + // lowest observed in the time period + Min float64 `json:"min,nullable"` + JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPct] +type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctJSON struct { + Slots apijson.Field + Avg apijson.Field + Max apijson.Field + Min apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPct) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctSlot struct { + Timestamp string `json:"timestamp,required"` + Value float64 `json:"value,required"` + JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctSlotJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctSlotJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctSlot] +type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctSlotJSON struct { + Timestamp apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctSlot) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsPacketLossPctSlotJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMs struct { + Slots []DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsSlot `json:"slots,required"` + // average observed in the time period + Avg int64 `json:"avg,nullable"` + // highest observed in the time period + Max int64 `json:"max,nullable"` + // lowest observed in the time period + Min int64 `json:"min,nullable"` + JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMs] +type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsJSON struct { + Slots apijson.Field + Avg apijson.Field + Max apijson.Field + Min apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsSlot struct { + Timestamp string `json:"timestamp,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsSlotJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsSlotJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsSlot] +type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsSlotJSON struct { + Timestamp apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsSlot) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsRoundTripTimeMsSlotJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColo struct { + AvailabilityPct DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPct `json:"availabilityPct,required"` + Colo string `json:"colo,required"` + HopsCount DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCount `json:"hopsCount,required"` + PacketLossPct DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPct `json:"packetLossPct,required"` + RoundTripTimeMs DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMs `json:"roundTripTimeMs,required"` + // Count of unique devices that have run this test in the given time period + UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` + JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoJSON contains +// the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColo] +type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoJSON struct { + AvailabilityPct apijson.Field + Colo apijson.Field + HopsCount apijson.Field + PacketLossPct apijson.Field + RoundTripTimeMs apijson.Field + UniqueDevicesTotal apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPct struct { + Slots []DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctSlot `json:"slots,required"` + // average observed in the time period + Avg float64 `json:"avg,nullable"` + // highest observed in the time period + Max float64 `json:"max,nullable"` + // lowest observed in the time period + Min float64 `json:"min,nullable"` + JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPct] +type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctJSON struct { + Slots apijson.Field + Avg apijson.Field + Max apijson.Field + Min apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPct) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctSlot struct { + Timestamp string `json:"timestamp,required"` + Value float64 `json:"value,required"` + JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctSlotJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctSlotJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctSlot] +type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctSlotJSON struct { + Timestamp apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctSlot) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoAvailabilityPctSlotJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCount struct { + Slots []DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountSlot `json:"slots,required"` + // average observed in the time period + Avg int64 `json:"avg,nullable"` + // highest observed in the time period + Max int64 `json:"max,nullable"` + // lowest observed in the time period + Min int64 `json:"min,nullable"` + JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCount] +type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountJSON struct { + Slots apijson.Field + Avg apijson.Field + Max apijson.Field + Min apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCount) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountSlot struct { + Timestamp string `json:"timestamp,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountSlotJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountSlotJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountSlot] +type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountSlotJSON struct { + Timestamp apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountSlot) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoHopsCountSlotJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPct struct { + Slots []DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctSlot `json:"slots,required"` + // average observed in the time period + Avg float64 `json:"avg,nullable"` + // highest observed in the time period + Max float64 `json:"max,nullable"` + // lowest observed in the time period + Min float64 `json:"min,nullable"` + JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPct] +type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctJSON struct { + Slots apijson.Field + Avg apijson.Field + Max apijson.Field + Min apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPct) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctSlot struct { + Timestamp string `json:"timestamp,required"` + Value float64 `json:"value,required"` + JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctSlotJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctSlotJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctSlot] +type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctSlotJSON struct { + Timestamp apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctSlot) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoPacketLossPctSlotJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMs struct { + Slots []DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsSlot `json:"slots,required"` + // average observed in the time period + Avg int64 `json:"avg,nullable"` + // highest observed in the time period + Max int64 `json:"max,nullable"` + // lowest observed in the time period + Min int64 `json:"min,nullable"` + JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMs] +type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsJSON struct { + Slots apijson.Field + Avg apijson.Field + Max apijson.Field + Min apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsSlot struct { + Timestamp string `json:"timestamp,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsSlotJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsSlotJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsSlot] +type digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsSlotJSON struct { + Timestamp apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsSlot) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsTracerouteStatsByColoRoundTripTimeMsSlotJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsPercentiles struct { + HopsCount DigitalExperienceMonitoringTracerouteDetailsPercentilesHopsCount `json:"hopsCount"` + PacketLossPct DigitalExperienceMonitoringTracerouteDetailsPercentilesPacketLossPct `json:"packetLossPct"` + RoundTripTimeMs DigitalExperienceMonitoringTracerouteDetailsPercentilesRoundTripTimeMs `json:"roundTripTimeMs"` + JSON digitalExperienceMonitoringTracerouteDetailsPercentilesJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsPercentilesJSON contains the JSON +// metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsPercentiles] +type digitalExperienceMonitoringTracerouteDetailsPercentilesJSON struct { + HopsCount apijson.Field + PacketLossPct apijson.Field + RoundTripTimeMs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsPercentiles) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsPercentilesJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsPercentilesHopsCount struct { + // p50 observed in the time period + P50 float64 `json:"p50,nullable"` + // p90 observed in the time period + P90 float64 `json:"p90,nullable"` + // p95 observed in the time period + P95 float64 `json:"p95,nullable"` + // p99 observed in the time period + P99 float64 `json:"p99,nullable"` + JSON digitalExperienceMonitoringTracerouteDetailsPercentilesHopsCountJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsPercentilesHopsCountJSON contains +// the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsPercentilesHopsCount] +type digitalExperienceMonitoringTracerouteDetailsPercentilesHopsCountJSON struct { + P50 apijson.Field + P90 apijson.Field + P95 apijson.Field + P99 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsPercentilesHopsCount) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsPercentilesHopsCountJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsPercentilesPacketLossPct struct { + // p50 observed in the time period + P50 float64 `json:"p50,nullable"` + // p90 observed in the time period + P90 float64 `json:"p90,nullable"` + // p95 observed in the time period + P95 float64 `json:"p95,nullable"` + // p99 observed in the time period + P99 float64 `json:"p99,nullable"` + JSON digitalExperienceMonitoringTracerouteDetailsPercentilesPacketLossPctJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsPercentilesPacketLossPctJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsPercentilesPacketLossPct] +type digitalExperienceMonitoringTracerouteDetailsPercentilesPacketLossPctJSON struct { + P50 apijson.Field + P90 apijson.Field + P95 apijson.Field + P99 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsPercentilesPacketLossPct) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsPercentilesPacketLossPctJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteDetailsPercentilesRoundTripTimeMs struct { + // p50 observed in the time period + P50 float64 `json:"p50,nullable"` + // p90 observed in the time period + P90 float64 `json:"p90,nullable"` + // p95 observed in the time period + P95 float64 `json:"p95,nullable"` + // p99 observed in the time period + P99 float64 `json:"p99,nullable"` + JSON digitalExperienceMonitoringTracerouteDetailsPercentilesRoundTripTimeMsJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteDetailsPercentilesRoundTripTimeMsJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteDetailsPercentilesRoundTripTimeMs] +type digitalExperienceMonitoringTracerouteDetailsPercentilesRoundTripTimeMsJSON struct { + P50 apijson.Field + P90 apijson.Field + P95 apijson.Field + P99 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteDetailsPercentilesRoundTripTimeMs) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteDetailsPercentilesRoundTripTimeMsJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteTestNetworkPath struct { + // API Resource UUID tag. + ID string `json:"id,required"` + DeviceName string `json:"deviceName"` + // The interval at which the Traceroute synthetic application test is set to run. + Interval string `json:"interval"` + Kind DigitalExperienceMonitoringTracerouteTestNetworkPathKind `json:"kind"` + Name string `json:"name"` + NetworkPath DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPath `json:"networkPath,nullable"` + // The host of the Traceroute synthetic application test + URL string `json:"url"` + JSON digitalExperienceMonitoringTracerouteTestNetworkPathJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteTestNetworkPathJSON contains the JSON +// metadata for the struct [DigitalExperienceMonitoringTracerouteTestNetworkPath] +type digitalExperienceMonitoringTracerouteTestNetworkPathJSON struct { + ID apijson.Field + DeviceName apijson.Field + Interval apijson.Field + Kind apijson.Field + Name apijson.Field + NetworkPath apijson.Field + URL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteTestNetworkPath) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteTestNetworkPathJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteTestNetworkPathKind string + +const ( + DigitalExperienceMonitoringTracerouteTestNetworkPathKindTraceroute DigitalExperienceMonitoringTracerouteTestNetworkPathKind = "traceroute" +) + +type DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPath struct { + Slots []DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSlot `json:"slots,required"` + // Specifies the sampling applied, if any, to the slots response. When sampled, + // results shown represent the first test run to the start of each sampling + // interval. + Sampling DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSampling `json:"sampling,nullable"` + JSON digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathJSON contains the +// JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPath] +type digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathJSON struct { + Slots apijson.Field + Sampling apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPath) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSlot struct { + // API Resource UUID tag. + ID string `json:"id,required"` + // Round trip time in ms of the client to app mile + ClientToAppRTTMs int64 `json:"clientToAppRttMs,required,nullable"` + // Round trip time in ms of the client to Cloudflare egress mile + ClientToCfEgressRTTMs int64 `json:"clientToCfEgressRttMs,required,nullable"` + // Round trip time in ms of the client to Cloudflare ingress mile + ClientToCfIngressRTTMs int64 `json:"clientToCfIngressRttMs,required,nullable"` + Timestamp string `json:"timestamp,required"` + // Round trip time in ms of the client to ISP mile + ClientToIspRTTMs int64 `json:"clientToIspRttMs,nullable"` + JSON digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSlotJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSlotJSON contains +// the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSlot] +type digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSlotJSON struct { + ID apijson.Field + ClientToAppRTTMs apijson.Field + ClientToCfEgressRTTMs apijson.Field + ClientToCfIngressRTTMs apijson.Field + Timestamp apijson.Field + ClientToIspRTTMs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSlot) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSlotJSON) RawJSON() string { + return r.raw +} + +// Specifies the sampling applied, if any, to the slots response. When sampled, +// results shown represent the first test run to the start of each sampling +// interval. +type DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSampling struct { + Unit DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSamplingUnit `json:"unit,required"` + Value int64 `json:"value,required"` + JSON digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSamplingJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSamplingJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSampling] +type digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSamplingJSON struct { + Unit apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSampling) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSamplingJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSamplingUnit string + +const ( + DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSamplingUnitHours DigitalExperienceMonitoringTracerouteTestNetworkPathNetworkPathSamplingUnit = "hours" +) + +type DEXTracerouteTestGetParams struct { + AccountID param.Field[string] `path:"account_id,required"` + // Time interval for aggregate time slots. + Interval param.Field[DEXTracerouteTestGetParamsInterval] `query:"interval,required"` + // End time for aggregate metrics in ISO ms + TimeEnd param.Field[string] `query:"timeEnd,required"` + // Start time for aggregate metrics in ISO ms + TimeStart param.Field[string] `query:"timeStart,required"` + // Optionally filter result stats to a Cloudflare colo. Cannot be used in + // combination with deviceId param. + Colo param.Field[string] `query:"colo"` + // Optionally filter result stats to a specific device(s). Cannot be used in + // combination with colo param. + DeviceID param.Field[[]string] `query:"deviceId"` +} + +// URLQuery serializes [DEXTracerouteTestGetParams]'s query parameters as +// `url.Values`. +func (r DEXTracerouteTestGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Time interval for aggregate time slots. +type DEXTracerouteTestGetParamsInterval string + +const ( + DEXTracerouteTestGetParamsIntervalMinute DEXTracerouteTestGetParamsInterval = "minute" + DEXTracerouteTestGetParamsIntervalHour DEXTracerouteTestGetParamsInterval = "hour" +) + +type DEXTracerouteTestGetResponseEnvelope struct { + Errors []DEXTracerouteTestGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DEXTracerouteTestGetResponseEnvelopeMessages `json:"messages,required"` + Result DigitalExperienceMonitoringTracerouteDetails `json:"result,required"` + // Whether the API call was successful + Success DEXTracerouteTestGetResponseEnvelopeSuccess `json:"success,required"` + JSON dexTracerouteTestGetResponseEnvelopeJSON `json:"-"` +} + +// dexTracerouteTestGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [DEXTracerouteTestGetResponseEnvelope] +type dexTracerouteTestGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXTracerouteTestGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTracerouteTestGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DEXTracerouteTestGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexTracerouteTestGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// dexTracerouteTestGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [DEXTracerouteTestGetResponseEnvelopeErrors] +type dexTracerouteTestGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXTracerouteTestGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTracerouteTestGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DEXTracerouteTestGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexTracerouteTestGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// dexTracerouteTestGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [DEXTracerouteTestGetResponseEnvelopeMessages] +type dexTracerouteTestGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXTracerouteTestGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTracerouteTestGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DEXTracerouteTestGetResponseEnvelopeSuccess bool + +const ( + DEXTracerouteTestGetResponseEnvelopeSuccessTrue DEXTracerouteTestGetResponseEnvelopeSuccess = true +) + +type DEXTracerouteTestNetworkPathParams struct { + AccountID param.Field[string] `path:"account_id,required"` + // Device to filter tracroute result runs to + DeviceID param.Field[string] `query:"deviceId,required"` + // Time interval for aggregate time slots. + Interval param.Field[DEXTracerouteTestNetworkPathParamsInterval] `query:"interval,required"` + // End time for aggregate metrics in ISO ms + TimeEnd param.Field[string] `query:"timeEnd,required"` + // Start time for aggregate metrics in ISO ms + TimeStart param.Field[string] `query:"timeStart,required"` +} + +// URLQuery serializes [DEXTracerouteTestNetworkPathParams]'s query parameters as +// `url.Values`. +func (r DEXTracerouteTestNetworkPathParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// Time interval for aggregate time slots. +type DEXTracerouteTestNetworkPathParamsInterval string + +const ( + DEXTracerouteTestNetworkPathParamsIntervalMinute DEXTracerouteTestNetworkPathParamsInterval = "minute" + DEXTracerouteTestNetworkPathParamsIntervalHour DEXTracerouteTestNetworkPathParamsInterval = "hour" +) + +type DEXTracerouteTestNetworkPathResponseEnvelope struct { + Errors []DEXTracerouteTestNetworkPathResponseEnvelopeErrors `json:"errors,required"` + Messages []DEXTracerouteTestNetworkPathResponseEnvelopeMessages `json:"messages,required"` + Result DigitalExperienceMonitoringTracerouteTestNetworkPath `json:"result,required"` + // Whether the API call was successful + Success DEXTracerouteTestNetworkPathResponseEnvelopeSuccess `json:"success,required"` + JSON dexTracerouteTestNetworkPathResponseEnvelopeJSON `json:"-"` +} + +// dexTracerouteTestNetworkPathResponseEnvelopeJSON contains the JSON metadata for +// the struct [DEXTracerouteTestNetworkPathResponseEnvelope] +type dexTracerouteTestNetworkPathResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXTracerouteTestNetworkPathResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTracerouteTestNetworkPathResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DEXTracerouteTestNetworkPathResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexTracerouteTestNetworkPathResponseEnvelopeErrorsJSON `json:"-"` +} + +// dexTracerouteTestNetworkPathResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [DEXTracerouteTestNetworkPathResponseEnvelopeErrors] +type dexTracerouteTestNetworkPathResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXTracerouteTestNetworkPathResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTracerouteTestNetworkPathResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DEXTracerouteTestNetworkPathResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexTracerouteTestNetworkPathResponseEnvelopeMessagesJSON `json:"-"` +} + +// dexTracerouteTestNetworkPathResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [DEXTracerouteTestNetworkPathResponseEnvelopeMessages] +type dexTracerouteTestNetworkPathResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXTracerouteTestNetworkPathResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTracerouteTestNetworkPathResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DEXTracerouteTestNetworkPathResponseEnvelopeSuccess bool + +const ( + DEXTracerouteTestNetworkPathResponseEnvelopeSuccessTrue DEXTracerouteTestNetworkPathResponseEnvelopeSuccess = true +) + +type DEXTracerouteTestPercentilesParams struct { + AccountID param.Field[string] `path:"account_id,required"` + // End time for aggregate metrics in ISO format + TimeEnd param.Field[string] `query:"timeEnd,required"` + // Start time for aggregate metrics in ISO format + TimeStart param.Field[string] `query:"timeStart,required"` + // Optionally filter result stats to a Cloudflare colo. Cannot be used in + // combination with deviceId param. + Colo param.Field[string] `query:"colo"` + // Optionally filter result stats to a specific device(s). Cannot be used in + // combination with colo param. + DeviceID param.Field[[]string] `query:"deviceId"` +} + +// URLQuery serializes [DEXTracerouteTestPercentilesParams]'s query parameters as +// `url.Values`. +func (r DEXTracerouteTestPercentilesParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type DEXTracerouteTestPercentilesResponseEnvelope struct { + Errors []DEXTracerouteTestPercentilesResponseEnvelopeErrors `json:"errors,required"` + Messages []DEXTracerouteTestPercentilesResponseEnvelopeMessages `json:"messages,required"` + Result DigitalExperienceMonitoringTracerouteDetailsPercentiles `json:"result,required"` + // Whether the API call was successful + Success DEXTracerouteTestPercentilesResponseEnvelopeSuccess `json:"success,required"` + JSON dexTracerouteTestPercentilesResponseEnvelopeJSON `json:"-"` +} + +// dexTracerouteTestPercentilesResponseEnvelopeJSON contains the JSON metadata for +// the struct [DEXTracerouteTestPercentilesResponseEnvelope] +type dexTracerouteTestPercentilesResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXTracerouteTestPercentilesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTracerouteTestPercentilesResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DEXTracerouteTestPercentilesResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexTracerouteTestPercentilesResponseEnvelopeErrorsJSON `json:"-"` +} + +// dexTracerouteTestPercentilesResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [DEXTracerouteTestPercentilesResponseEnvelopeErrors] +type dexTracerouteTestPercentilesResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXTracerouteTestPercentilesResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTracerouteTestPercentilesResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DEXTracerouteTestPercentilesResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexTracerouteTestPercentilesResponseEnvelopeMessagesJSON `json:"-"` +} + +// dexTracerouteTestPercentilesResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [DEXTracerouteTestPercentilesResponseEnvelopeMessages] +type dexTracerouteTestPercentilesResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXTracerouteTestPercentilesResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTracerouteTestPercentilesResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DEXTracerouteTestPercentilesResponseEnvelopeSuccess bool + +const ( + DEXTracerouteTestPercentilesResponseEnvelopeSuccessTrue DEXTracerouteTestPercentilesResponseEnvelopeSuccess = true +) diff --git a/zero_trust/dextraceroutetest_test.go b/zero_trust/dextraceroutetest_test.go new file mode 100644 index 00000000000..898740cd678 --- /dev/null +++ b/zero_trust/dextraceroutetest_test.go @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDEXTracerouteTestGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.DEX.TracerouteTests.Get( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DEXTracerouteTestGetParams{ + AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), + Interval: cloudflare.F(zero_trust.DEXTracerouteTestGetParamsIntervalMinute), + TimeEnd: cloudflare.F("string"), + TimeStart: cloudflare.F("string"), + Colo: cloudflare.F("string"), + DeviceID: cloudflare.F([]string{"string", "string", "string"}), + }, + ) + 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 TestDEXTracerouteTestNetworkPath(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("user@example.com"), + ) + _, err := client.ZeroTrust.DEX.TracerouteTests.NetworkPath( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DEXTracerouteTestNetworkPathParams{ + AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), + DeviceID: cloudflare.F("string"), + Interval: cloudflare.F(zero_trust.DEXTracerouteTestNetworkPathParamsIntervalMinute), + TimeEnd: cloudflare.F("string"), + TimeStart: cloudflare.F("string"), + }, + ) + 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 TestDEXTracerouteTestPercentilesWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.DEX.TracerouteTests.Percentiles( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DEXTracerouteTestPercentilesParams{ + AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), + TimeEnd: cloudflare.F("2023-09-20T17:00:00Z"), + TimeStart: cloudflare.F("2023-09-20T17:00:00Z"), + Colo: cloudflare.F("string"), + DeviceID: cloudflare.F([]string{"string", "string", "string"}), + }, + ) + 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/zero_trust/dextraceroutetestresult.go b/zero_trust/dextraceroutetestresult.go new file mode 100644 index 00000000000..a2008086bd7 --- /dev/null +++ b/zero_trust/dextraceroutetestresult.go @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// DEXTracerouteTestResultService 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 +// [NewDEXTracerouteTestResultService] method instead. +type DEXTracerouteTestResultService struct { + Options []option.RequestOption + NetworkPath *DEXTracerouteTestResultNetworkPathService +} + +// NewDEXTracerouteTestResultService 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 NewDEXTracerouteTestResultService(opts ...option.RequestOption) (r *DEXTracerouteTestResultService) { + r = &DEXTracerouteTestResultService{} + r.Options = opts + r.NetworkPath = NewDEXTracerouteTestResultNetworkPathService(opts...) + return +} diff --git a/zero_trust/dextraceroutetestresultnetworkpath.go b/zero_trust/dextraceroutetestresultnetworkpath.go new file mode 100644 index 00000000000..eba8cb7a21e --- /dev/null +++ b/zero_trust/dextraceroutetestresultnetworkpath.go @@ -0,0 +1,245 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DEXTracerouteTestResultNetworkPathService 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 +// [NewDEXTracerouteTestResultNetworkPathService] method instead. +type DEXTracerouteTestResultNetworkPathService struct { + Options []option.RequestOption +} + +// NewDEXTracerouteTestResultNetworkPathService 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 NewDEXTracerouteTestResultNetworkPathService(opts ...option.RequestOption) (r *DEXTracerouteTestResultNetworkPathService) { + r = &DEXTracerouteTestResultNetworkPathService{} + r.Options = opts + return +} + +// Get a breakdown of hops and performance metrics for a specific traceroute test +// run +func (r *DEXTracerouteTestResultNetworkPathService) List(ctx context.Context, testResultID string, query DEXTracerouteTestResultNetworkPathListParams, opts ...option.RequestOption) (res *DigitalExperienceMonitoringTracerouteTestResultNetworkPath, err error) { + opts = append(r.Options[:], opts...) + var env DEXTracerouteTestResultNetworkPathListResponseEnvelope + path := fmt.Sprintf("accounts/%s/dex/traceroute-test-results/%s/network-path", query.AccountID, testResultID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DigitalExperienceMonitoringTracerouteTestResultNetworkPath struct { + // an array of the hops taken by the device to reach the end destination + Hops []DigitalExperienceMonitoringTracerouteTestResultNetworkPathHop `json:"hops,required"` + // API Resource UUID tag. + ResultID string `json:"resultId,required"` + // date time of this traceroute test + TimeStart string `json:"time_start,required"` + // name of the device associated with this network path response + DeviceName string `json:"deviceName"` + // API Resource UUID tag. + TestID string `json:"testId"` + // name of the tracroute test + TestName string `json:"testName"` + JSON digitalExperienceMonitoringTracerouteTestResultNetworkPathJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteTestResultNetworkPathJSON contains the JSON +// metadata for the struct +// [DigitalExperienceMonitoringTracerouteTestResultNetworkPath] +type digitalExperienceMonitoringTracerouteTestResultNetworkPathJSON struct { + Hops apijson.Field + ResultID apijson.Field + TimeStart apijson.Field + DeviceName apijson.Field + TestID apijson.Field + TestName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteTestResultNetworkPath) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteTestResultNetworkPathJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteTestResultNetworkPathHop struct { + TTL int64 `json:"ttl,required"` + ASN int64 `json:"asn,nullable"` + Aso string `json:"aso,nullable"` + IPAddress string `json:"ipAddress,nullable"` + Location DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsLocation `json:"location,nullable"` + Mile DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMile `json:"mile,nullable"` + Name string `json:"name,nullable"` + PacketLossPct float64 `json:"packetLossPct,nullable"` + RTTMs int64 `json:"rttMs,nullable"` + JSON digitalExperienceMonitoringTracerouteTestResultNetworkPathHopJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteTestResultNetworkPathHopJSON contains the +// JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteTestResultNetworkPathHop] +type digitalExperienceMonitoringTracerouteTestResultNetworkPathHopJSON struct { + TTL apijson.Field + ASN apijson.Field + Aso apijson.Field + IPAddress apijson.Field + Location apijson.Field + Mile apijson.Field + Name apijson.Field + PacketLossPct apijson.Field + RTTMs apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteTestResultNetworkPathHop) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteTestResultNetworkPathHopJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsLocation struct { + City string `json:"city,nullable"` + State string `json:"state,nullable"` + Zip string `json:"zip,nullable"` + JSON digitalExperienceMonitoringTracerouteTestResultNetworkPathHopsLocationJSON `json:"-"` +} + +// digitalExperienceMonitoringTracerouteTestResultNetworkPathHopsLocationJSON +// contains the JSON metadata for the struct +// [DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsLocation] +type digitalExperienceMonitoringTracerouteTestResultNetworkPathHopsLocationJSON struct { + City apijson.Field + State apijson.Field + Zip apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsLocation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r digitalExperienceMonitoringTracerouteTestResultNetworkPathHopsLocationJSON) RawJSON() string { + return r.raw +} + +type DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMile string + +const ( + DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMileClientToApp DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMile = "client-to-app" + DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMileClientToCfEgress DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMile = "client-to-cf-egress" + DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMileClientToCfIngress DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMile = "client-to-cf-ingress" + DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMileClientToIsp DigitalExperienceMonitoringTracerouteTestResultNetworkPathHopsMile = "client-to-isp" +) + +type DEXTracerouteTestResultNetworkPathListParams struct { + AccountID param.Field[string] `path:"account_id,required"` +} + +type DEXTracerouteTestResultNetworkPathListResponseEnvelope struct { + Errors []DEXTracerouteTestResultNetworkPathListResponseEnvelopeErrors `json:"errors,required"` + Messages []DEXTracerouteTestResultNetworkPathListResponseEnvelopeMessages `json:"messages,required"` + Result DigitalExperienceMonitoringTracerouteTestResultNetworkPath `json:"result,required"` + // Whether the API call was successful + Success DEXTracerouteTestResultNetworkPathListResponseEnvelopeSuccess `json:"success,required"` + JSON dexTracerouteTestResultNetworkPathListResponseEnvelopeJSON `json:"-"` +} + +// dexTracerouteTestResultNetworkPathListResponseEnvelopeJSON contains the JSON +// metadata for the struct [DEXTracerouteTestResultNetworkPathListResponseEnvelope] +type dexTracerouteTestResultNetworkPathListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXTracerouteTestResultNetworkPathListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTracerouteTestResultNetworkPathListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DEXTracerouteTestResultNetworkPathListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexTracerouteTestResultNetworkPathListResponseEnvelopeErrorsJSON `json:"-"` +} + +// dexTracerouteTestResultNetworkPathListResponseEnvelopeErrorsJSON contains the +// JSON metadata for the struct +// [DEXTracerouteTestResultNetworkPathListResponseEnvelopeErrors] +type dexTracerouteTestResultNetworkPathListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXTracerouteTestResultNetworkPathListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTracerouteTestResultNetworkPathListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DEXTracerouteTestResultNetworkPathListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dexTracerouteTestResultNetworkPathListResponseEnvelopeMessagesJSON `json:"-"` +} + +// dexTracerouteTestResultNetworkPathListResponseEnvelopeMessagesJSON contains the +// JSON metadata for the struct +// [DEXTracerouteTestResultNetworkPathListResponseEnvelopeMessages] +type dexTracerouteTestResultNetworkPathListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DEXTracerouteTestResultNetworkPathListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dexTracerouteTestResultNetworkPathListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DEXTracerouteTestResultNetworkPathListResponseEnvelopeSuccess bool + +const ( + DEXTracerouteTestResultNetworkPathListResponseEnvelopeSuccessTrue DEXTracerouteTestResultNetworkPathListResponseEnvelopeSuccess = true +) diff --git a/zero_trust/dextraceroutetestresultnetworkpath_test.go b/zero_trust/dextraceroutetestresultnetworkpath_test.go new file mode 100644 index 00000000000..59e6475680c --- /dev/null +++ b/zero_trust/dextraceroutetestresultnetworkpath_test.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDEXTracerouteTestResultNetworkPathList(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("user@example.com"), + ) + _, err := client.ZeroTrust.DEX.TracerouteTestResults.NetworkPath.List( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.DEXTracerouteTestResultNetworkPathListParams{ + AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), + }, + ) + 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/zero_trust/dlp.go b/zero_trust/dlp.go new file mode 100644 index 00000000000..30442502726 --- /dev/null +++ b/zero_trust/dlp.go @@ -0,0 +1,32 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// DLPService 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 [NewDLPService] method instead. +type DLPService struct { + Options []option.RequestOption + Datasets *DLPDatasetService + Patterns *DLPPatternService + PayloadLogs *DLPPayloadLogService + Profiles *DLPProfileService +} + +// NewDLPService 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 NewDLPService(opts ...option.RequestOption) (r *DLPService) { + r = &DLPService{} + r.Options = opts + r.Datasets = NewDLPDatasetService(opts...) + r.Patterns = NewDLPPatternService(opts...) + r.PayloadLogs = NewDLPPayloadLogService(opts...) + r.Profiles = NewDLPProfileService(opts...) + return +} diff --git a/zero_trust/dlpdataset.go b/zero_trust/dlpdataset.go new file mode 100644 index 00000000000..2cbb2bcefef --- /dev/null +++ b/zero_trust/dlpdataset.go @@ -0,0 +1,669 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DLPDatasetService 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 [NewDLPDatasetService] method instead. +type DLPDatasetService struct { + Options []option.RequestOption + Upload *DLPDatasetUploadService +} + +// NewDLPDatasetService 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 NewDLPDatasetService(opts ...option.RequestOption) (r *DLPDatasetService) { + r = &DLPDatasetService{} + r.Options = opts + r.Upload = NewDLPDatasetUploadService(opts...) + return +} + +// Create a new dataset. +func (r *DLPDatasetService) New(ctx context.Context, params DLPDatasetNewParams, opts ...option.RequestOption) (res *DLPDatasetCreation, err error) { + opts = append(r.Options[:], opts...) + var env DLPDatasetNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/dlp/datasets", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Update details about a dataset. +func (r *DLPDatasetService) Update(ctx context.Context, datasetID string, params DLPDatasetUpdateParams, opts ...option.RequestOption) (res *DLPDataset, err error) { + opts = append(r.Options[:], opts...) + var env DLPDatasetUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/dlp/datasets/%s", params.AccountID, datasetID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetch all datasets with information about available versions. +func (r *DLPDatasetService) List(ctx context.Context, query DLPDatasetListParams, opts ...option.RequestOption) (res *DLPDatasetArray, err error) { + opts = append(r.Options[:], opts...) + var env DLPDatasetListResponseEnvelope + path := fmt.Sprintf("accounts/%s/dlp/datasets", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete a dataset. +// +// This deletes all versions of the dataset. +func (r *DLPDatasetService) Delete(ctx context.Context, datasetID string, body DLPDatasetDeleteParams, opts ...option.RequestOption) (err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + path := fmt.Sprintf("accounts/%s/dlp/datasets/%s", body.AccountID, datasetID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) + return +} + +// Fetch a specific dataset with information about available versions. +func (r *DLPDatasetService) Get(ctx context.Context, datasetID string, query DLPDatasetGetParams, opts ...option.RequestOption) (res *DLPDataset, err error) { + opts = append(r.Options[:], opts...) + var env DLPDatasetGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/dlp/datasets/%s", query.AccountID, datasetID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DLPDataset struct { + ID string `json:"id,required" format:"uuid"` + CreatedAt time.Time `json:"created_at,required" format:"date-time"` + Name string `json:"name,required"` + NumCells int64 `json:"num_cells,required"` + Secret bool `json:"secret,required"` + Status DLPDatasetStatus `json:"status,required"` + UpdatedAt time.Time `json:"updated_at,required" format:"date-time"` + Uploads []DLPDatasetUpload `json:"uploads,required"` + Description string `json:"description,nullable"` + JSON dlpDatasetJSON `json:"-"` +} + +// dlpDatasetJSON contains the JSON metadata for the struct [DLPDataset] +type dlpDatasetJSON struct { + ID apijson.Field + CreatedAt apijson.Field + Name apijson.Field + NumCells apijson.Field + Secret apijson.Field + Status apijson.Field + UpdatedAt apijson.Field + Uploads apijson.Field + Description apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDataset) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetStatus string + +const ( + DLPDatasetStatusEmpty DLPDatasetStatus = "empty" + DLPDatasetStatusUploading DLPDatasetStatus = "uploading" + DLPDatasetStatusFailed DLPDatasetStatus = "failed" + DLPDatasetStatusComplete DLPDatasetStatus = "complete" +) + +type DLPDatasetUpload struct { + NumCells int64 `json:"num_cells,required"` + Status DLPDatasetUploadsStatus `json:"status,required"` + Version int64 `json:"version,required"` + JSON dlpDatasetUploadJSON `json:"-"` +} + +// dlpDatasetUploadJSON contains the JSON metadata for the struct +// [DLPDatasetUpload] +type dlpDatasetUploadJSON struct { + NumCells apijson.Field + Status apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetUpload) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetUploadJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetUploadsStatus string + +const ( + DLPDatasetUploadsStatusEmpty DLPDatasetUploadsStatus = "empty" + DLPDatasetUploadsStatusUploading DLPDatasetUploadsStatus = "uploading" + DLPDatasetUploadsStatusFailed DLPDatasetUploadsStatus = "failed" + DLPDatasetUploadsStatusComplete DLPDatasetUploadsStatus = "complete" +) + +type DLPDatasetArray []DLPDataset + +type DLPDatasetCreation struct { + Dataset DLPDataset `json:"dataset,required"` + MaxCells int64 `json:"max_cells,required"` + // The version to use when uploading the dataset. + Version int64 `json:"version,required"` + // The secret to use for Exact Data Match datasets. This is not present in Custom + // Wordlists. + Secret string `json:"secret" format:"password"` + JSON dlpDatasetCreationJSON `json:"-"` +} + +// dlpDatasetCreationJSON contains the JSON metadata for the struct +// [DLPDatasetCreation] +type dlpDatasetCreationJSON struct { + Dataset apijson.Field + MaxCells apijson.Field + Version apijson.Field + Secret apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetCreation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetCreationJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetNewParams struct { + AccountID param.Field[string] `path:"account_id,required"` + Name param.Field[string] `json:"name,required"` + Description param.Field[string] `json:"description"` + // Generate a secret dataset. + // + // If true, the response will include a secret to use with the EDM encoder. If + // false, the response has no secret and the dataset is uploaded in plaintext. + Secret param.Field[bool] `json:"secret"` +} + +func (r DLPDatasetNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DLPDatasetNewResponseEnvelope struct { + Errors []DLPDatasetNewResponseEnvelopeErrors `json:"errors,required"` + Messages []DLPDatasetNewResponseEnvelopeMessages `json:"messages,required"` + Success bool `json:"success,required"` + Result DLPDatasetCreation `json:"result"` + ResultInfo DLPDatasetNewResponseEnvelopeResultInfo `json:"result_info"` + JSON dlpDatasetNewResponseEnvelopeJSON `json:"-"` +} + +// dlpDatasetNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [DLPDatasetNewResponseEnvelope] +type dlpDatasetNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + ResultInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpDatasetNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// dlpDatasetNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DLPDatasetNewResponseEnvelopeErrors] +type dlpDatasetNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpDatasetNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// dlpDatasetNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DLPDatasetNewResponseEnvelopeMessages] +type dlpDatasetNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetNewResponseEnvelopeResultInfo struct { + // total number of pages + Count int64 `json:"count,required"` + // current page + Page int64 `json:"page,required"` + // number of items per page + PerPage int64 `json:"per_page,required"` + // total number of items + TotalCount int64 `json:"total_count,required"` + JSON dlpDatasetNewResponseEnvelopeResultInfoJSON `json:"-"` +} + +// dlpDatasetNewResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [DLPDatasetNewResponseEnvelopeResultInfo] +type dlpDatasetNewResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetNewResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetUpdateParams struct { + AccountID param.Field[string] `path:"account_id,required"` + Description param.Field[string] `json:"description"` + Name param.Field[string] `json:"name"` +} + +func (r DLPDatasetUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DLPDatasetUpdateResponseEnvelope struct { + Errors []DLPDatasetUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []DLPDatasetUpdateResponseEnvelopeMessages `json:"messages,required"` + Success bool `json:"success,required"` + Result DLPDataset `json:"result"` + ResultInfo DLPDatasetUpdateResponseEnvelopeResultInfo `json:"result_info"` + JSON dlpDatasetUpdateResponseEnvelopeJSON `json:"-"` +} + +// dlpDatasetUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [DLPDatasetUpdateResponseEnvelope] +type dlpDatasetUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + ResultInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpDatasetUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// dlpDatasetUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DLPDatasetUpdateResponseEnvelopeErrors] +type dlpDatasetUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpDatasetUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// dlpDatasetUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DLPDatasetUpdateResponseEnvelopeMessages] +type dlpDatasetUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetUpdateResponseEnvelopeResultInfo struct { + // total number of pages + Count int64 `json:"count,required"` + // current page + Page int64 `json:"page,required"` + // number of items per page + PerPage int64 `json:"per_page,required"` + // total number of items + TotalCount int64 `json:"total_count,required"` + JSON dlpDatasetUpdateResponseEnvelopeResultInfoJSON `json:"-"` +} + +// dlpDatasetUpdateResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [DLPDatasetUpdateResponseEnvelopeResultInfo] +type dlpDatasetUpdateResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetListParams struct { + AccountID param.Field[string] `path:"account_id,required"` +} + +type DLPDatasetListResponseEnvelope struct { + Errors []DLPDatasetListResponseEnvelopeErrors `json:"errors,required"` + Messages []DLPDatasetListResponseEnvelopeMessages `json:"messages,required"` + Success bool `json:"success,required"` + Result DLPDatasetArray `json:"result"` + ResultInfo DLPDatasetListResponseEnvelopeResultInfo `json:"result_info"` + JSON dlpDatasetListResponseEnvelopeJSON `json:"-"` +} + +// dlpDatasetListResponseEnvelopeJSON contains the JSON metadata for the struct +// [DLPDatasetListResponseEnvelope] +type dlpDatasetListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + ResultInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpDatasetListResponseEnvelopeErrorsJSON `json:"-"` +} + +// dlpDatasetListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DLPDatasetListResponseEnvelopeErrors] +type dlpDatasetListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpDatasetListResponseEnvelopeMessagesJSON `json:"-"` +} + +// dlpDatasetListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DLPDatasetListResponseEnvelopeMessages] +type dlpDatasetListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetListResponseEnvelopeResultInfo struct { + // total number of pages + Count int64 `json:"count,required"` + // current page + Page int64 `json:"page,required"` + // number of items per page + PerPage int64 `json:"per_page,required"` + // total number of items + TotalCount int64 `json:"total_count,required"` + JSON dlpDatasetListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// dlpDatasetListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [DLPDatasetListResponseEnvelopeResultInfo] +type dlpDatasetListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetDeleteParams struct { + AccountID param.Field[string] `path:"account_id,required"` +} + +type DLPDatasetGetParams struct { + AccountID param.Field[string] `path:"account_id,required"` +} + +type DLPDatasetGetResponseEnvelope struct { + Errors []DLPDatasetGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DLPDatasetGetResponseEnvelopeMessages `json:"messages,required"` + Success bool `json:"success,required"` + Result DLPDataset `json:"result"` + ResultInfo DLPDatasetGetResponseEnvelopeResultInfo `json:"result_info"` + JSON dlpDatasetGetResponseEnvelopeJSON `json:"-"` +} + +// dlpDatasetGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DLPDatasetGetResponseEnvelope] +type dlpDatasetGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + ResultInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpDatasetGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// dlpDatasetGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DLPDatasetGetResponseEnvelopeErrors] +type dlpDatasetGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpDatasetGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// dlpDatasetGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DLPDatasetGetResponseEnvelopeMessages] +type dlpDatasetGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetGetResponseEnvelopeResultInfo struct { + // total number of pages + Count int64 `json:"count,required"` + // current page + Page int64 `json:"page,required"` + // number of items per page + PerPage int64 `json:"per_page,required"` + // total number of items + TotalCount int64 `json:"total_count,required"` + JSON dlpDatasetGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// dlpDatasetGetResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [DLPDatasetGetResponseEnvelopeResultInfo] +type dlpDatasetGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/dlpdataset_test.go b/zero_trust/dlpdataset_test.go new file mode 100644 index 00000000000..a6b3ad957da --- /dev/null +++ b/zero_trust/dlpdataset_test.go @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDLPDatasetNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.DLP.Datasets.New(context.TODO(), zero_trust.DLPDatasetNewParams{ + AccountID: cloudflare.F("string"), + Name: cloudflare.F("string"), + Description: cloudflare.F("string"), + Secret: cloudflare.F(true), + }) + 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 TestDLPDatasetUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.DLP.Datasets.Update( + context.TODO(), + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zero_trust.DLPDatasetUpdateParams{ + AccountID: cloudflare.F("string"), + Description: cloudflare.F("string"), + Name: cloudflare.F("string"), + }, + ) + 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 TestDLPDatasetList(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("user@example.com"), + ) + _, err := client.ZeroTrust.DLP.Datasets.List(context.TODO(), zero_trust.DLPDatasetListParams{ + AccountID: cloudflare.F("string"), + }) + 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 TestDLPDatasetDelete(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("user@example.com"), + ) + err := client.ZeroTrust.DLP.Datasets.Delete( + context.TODO(), + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zero_trust.DLPDatasetDeleteParams{ + AccountID: cloudflare.F("string"), + }, + ) + 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 TestDLPDatasetGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.DLP.Datasets.Get( + context.TODO(), + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zero_trust.DLPDatasetGetParams{ + AccountID: cloudflare.F("string"), + }, + ) + 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/zero_trust/dlpdatasetupload.go b/zero_trust/dlpdatasetupload.go new file mode 100644 index 00000000000..eb1f5dd1278 --- /dev/null +++ b/zero_trust/dlpdatasetupload.go @@ -0,0 +1,303 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DLPDatasetUploadService 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 [NewDLPDatasetUploadService] method +// instead. +type DLPDatasetUploadService struct { + Options []option.RequestOption +} + +// NewDLPDatasetUploadService 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 NewDLPDatasetUploadService(opts ...option.RequestOption) (r *DLPDatasetUploadService) { + r = &DLPDatasetUploadService{} + r.Options = opts + return +} + +// Prepare to upload a new version of a dataset. +func (r *DLPDatasetUploadService) New(ctx context.Context, datasetID string, body DLPDatasetUploadNewParams, opts ...option.RequestOption) (res *DLPDatasetNewVersion, err error) { + opts = append(r.Options[:], opts...) + var env DLPDatasetUploadNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/dlp/datasets/%s/upload", body.AccountID, datasetID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Upload a new version of a dataset. +func (r *DLPDatasetUploadService) Edit(ctx context.Context, datasetID string, version int64, body DLPDatasetUploadEditParams, opts ...option.RequestOption) (res *DLPDataset, err error) { + opts = append(r.Options[:], opts...) + var env DLPDatasetUploadEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/dlp/datasets/%s/upload/%v", body.AccountID, datasetID, version) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DLPDatasetNewVersion struct { + MaxCells int64 `json:"max_cells,required"` + Version int64 `json:"version,required"` + Secret string `json:"secret" format:"password"` + JSON dlpDatasetNewVersionJSON `json:"-"` +} + +// dlpDatasetNewVersionJSON contains the JSON metadata for the struct +// [DLPDatasetNewVersion] +type dlpDatasetNewVersionJSON struct { + MaxCells apijson.Field + Version apijson.Field + Secret apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetNewVersion) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetNewVersionJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetUploadNewParams struct { + AccountID param.Field[string] `path:"account_id,required"` +} + +type DLPDatasetUploadNewResponseEnvelope struct { + Errors []DLPDatasetUploadNewResponseEnvelopeErrors `json:"errors,required"` + Messages []DLPDatasetUploadNewResponseEnvelopeMessages `json:"messages,required"` + Success bool `json:"success,required"` + Result DLPDatasetNewVersion `json:"result"` + ResultInfo DLPDatasetUploadNewResponseEnvelopeResultInfo `json:"result_info"` + JSON dlpDatasetUploadNewResponseEnvelopeJSON `json:"-"` +} + +// dlpDatasetUploadNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [DLPDatasetUploadNewResponseEnvelope] +type dlpDatasetUploadNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + ResultInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetUploadNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetUploadNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetUploadNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpDatasetUploadNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// dlpDatasetUploadNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DLPDatasetUploadNewResponseEnvelopeErrors] +type dlpDatasetUploadNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetUploadNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetUploadNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetUploadNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpDatasetUploadNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// dlpDatasetUploadNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [DLPDatasetUploadNewResponseEnvelopeMessages] +type dlpDatasetUploadNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetUploadNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetUploadNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetUploadNewResponseEnvelopeResultInfo struct { + // total number of pages + Count int64 `json:"count,required"` + // current page + Page int64 `json:"page,required"` + // number of items per page + PerPage int64 `json:"per_page,required"` + // total number of items + TotalCount int64 `json:"total_count,required"` + JSON dlpDatasetUploadNewResponseEnvelopeResultInfoJSON `json:"-"` +} + +// dlpDatasetUploadNewResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [DLPDatasetUploadNewResponseEnvelopeResultInfo] +type dlpDatasetUploadNewResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetUploadNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetUploadNewResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetUploadEditParams struct { + AccountID param.Field[string] `path:"account_id,required"` +} + +type DLPDatasetUploadEditResponseEnvelope struct { + Errors []DLPDatasetUploadEditResponseEnvelopeErrors `json:"errors,required"` + Messages []DLPDatasetUploadEditResponseEnvelopeMessages `json:"messages,required"` + Success bool `json:"success,required"` + Result DLPDataset `json:"result"` + ResultInfo DLPDatasetUploadEditResponseEnvelopeResultInfo `json:"result_info"` + JSON dlpDatasetUploadEditResponseEnvelopeJSON `json:"-"` +} + +// dlpDatasetUploadEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [DLPDatasetUploadEditResponseEnvelope] +type dlpDatasetUploadEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + ResultInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetUploadEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetUploadEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetUploadEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpDatasetUploadEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// dlpDatasetUploadEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [DLPDatasetUploadEditResponseEnvelopeErrors] +type dlpDatasetUploadEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetUploadEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetUploadEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetUploadEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpDatasetUploadEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// dlpDatasetUploadEditResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [DLPDatasetUploadEditResponseEnvelopeMessages] +type dlpDatasetUploadEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetUploadEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetUploadEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type DLPDatasetUploadEditResponseEnvelopeResultInfo struct { + // total number of pages + Count int64 `json:"count,required"` + // current page + Page int64 `json:"page,required"` + // number of items per page + PerPage int64 `json:"per_page,required"` + // total number of items + TotalCount int64 `json:"total_count,required"` + JSON dlpDatasetUploadEditResponseEnvelopeResultInfoJSON `json:"-"` +} + +// dlpDatasetUploadEditResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [DLPDatasetUploadEditResponseEnvelopeResultInfo] +type dlpDatasetUploadEditResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPDatasetUploadEditResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpDatasetUploadEditResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/dlpdatasetupload_test.go b/zero_trust/dlpdatasetupload_test.go new file mode 100644 index 00000000000..19f05e99b62 --- /dev/null +++ b/zero_trust/dlpdatasetupload_test.go @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDLPDatasetUploadNew(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("user@example.com"), + ) + _, err := client.ZeroTrust.DLP.Datasets.Upload.New( + context.TODO(), + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + zero_trust.DLPDatasetUploadNewParams{ + AccountID: cloudflare.F("string"), + }, + ) + 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 TestDLPDatasetUploadEdit(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("user@example.com"), + ) + _, err := client.ZeroTrust.DLP.Datasets.Upload.Edit( + context.TODO(), + "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", + int64(0), + zero_trust.DLPDatasetUploadEditParams{ + AccountID: cloudflare.F("string"), + }, + ) + 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/zero_trust/dlppattern.go b/zero_trust/dlppattern.go new file mode 100644 index 00000000000..9abce8c9ddd --- /dev/null +++ b/zero_trust/dlppattern.go @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DLPPatternService 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 [NewDLPPatternService] method instead. +type DLPPatternService struct { + Options []option.RequestOption +} + +// NewDLPPatternService 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 NewDLPPatternService(opts ...option.RequestOption) (r *DLPPatternService) { + r = &DLPPatternService{} + r.Options = opts + return +} + +// Validates whether this pattern is a valid regular expression. Rejects it if the +// regular expression is too complex or can match an unbounded-length string. Your +// regex will be rejected if it uses the Kleene Star -- be sure to bound the +// maximum number of characters that can be matched. +func (r *DLPPatternService) Validate(ctx context.Context, params DLPPatternValidateParams, opts ...option.RequestOption) (res *DLPPatternValidateResponse, err error) { + opts = append(r.Options[:], opts...) + var env DLPPatternValidateResponseEnvelope + path := fmt.Sprintf("accounts/%s/dlp/patterns/validate", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DLPPatternValidateResponse struct { + Valid bool `json:"valid"` + JSON dlpPatternValidateResponseJSON `json:"-"` +} + +// dlpPatternValidateResponseJSON contains the JSON metadata for the struct +// [DLPPatternValidateResponse] +type dlpPatternValidateResponseJSON struct { + Valid apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPPatternValidateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpPatternValidateResponseJSON) RawJSON() string { + return r.raw +} + +type DLPPatternValidateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The regex pattern. + Regex param.Field[string] `json:"regex,required"` +} + +func (r DLPPatternValidateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DLPPatternValidateResponseEnvelope struct { + Errors []DLPPatternValidateResponseEnvelopeErrors `json:"errors,required"` + Messages []DLPPatternValidateResponseEnvelopeMessages `json:"messages,required"` + Result DLPPatternValidateResponse `json:"result,required"` + // Whether the API call was successful + Success DLPPatternValidateResponseEnvelopeSuccess `json:"success,required"` + JSON dlpPatternValidateResponseEnvelopeJSON `json:"-"` +} + +// dlpPatternValidateResponseEnvelopeJSON contains the JSON metadata for the struct +// [DLPPatternValidateResponseEnvelope] +type dlpPatternValidateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPPatternValidateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpPatternValidateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DLPPatternValidateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpPatternValidateResponseEnvelopeErrorsJSON `json:"-"` +} + +// dlpPatternValidateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DLPPatternValidateResponseEnvelopeErrors] +type dlpPatternValidateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPPatternValidateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpPatternValidateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DLPPatternValidateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpPatternValidateResponseEnvelopeMessagesJSON `json:"-"` +} + +// dlpPatternValidateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [DLPPatternValidateResponseEnvelopeMessages] +type dlpPatternValidateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPPatternValidateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpPatternValidateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DLPPatternValidateResponseEnvelopeSuccess bool + +const ( + DLPPatternValidateResponseEnvelopeSuccessTrue DLPPatternValidateResponseEnvelopeSuccess = true +) diff --git a/zero_trust/dlppattern_test.go b/zero_trust/dlppattern_test.go new file mode 100644 index 00000000000..4a26cec2a5e --- /dev/null +++ b/zero_trust/dlppattern_test.go @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDLPPatternValidate(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("user@example.com"), + ) + _, err := client.ZeroTrust.DLP.Patterns.Validate(context.TODO(), zero_trust.DLPPatternValidateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Regex: cloudflare.F("^4[0-9]{6,}$"), + }) + 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/zero_trust/dlppayloadlog.go b/zero_trust/dlppayloadlog.go new file mode 100644 index 00000000000..3df28602550 --- /dev/null +++ b/zero_trust/dlppayloadlog.go @@ -0,0 +1,278 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DLPPayloadLogService 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 [NewDLPPayloadLogService] method +// instead. +type DLPPayloadLogService struct { + Options []option.RequestOption +} + +// NewDLPPayloadLogService 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 NewDLPPayloadLogService(opts ...option.RequestOption) (r *DLPPayloadLogService) { + r = &DLPPayloadLogService{} + r.Options = opts + return +} + +// Updates the DLP payload log settings for this account. +func (r *DLPPayloadLogService) Update(ctx context.Context, params DLPPayloadLogUpdateParams, opts ...option.RequestOption) (res *DLPPayloadLogUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env DLPPayloadLogUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/dlp/payload_log", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets the current DLP payload log settings for this account. +func (r *DLPPayloadLogService) Get(ctx context.Context, query DLPPayloadLogGetParams, opts ...option.RequestOption) (res *DLPPayloadLogGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env DLPPayloadLogGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/dlp/payload_log", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DLPPayloadLogUpdateResponse struct { + PublicKey string `json:"public_key,required,nullable"` + JSON dlpPayloadLogUpdateResponseJSON `json:"-"` +} + +// dlpPayloadLogUpdateResponseJSON contains the JSON metadata for the struct +// [DLPPayloadLogUpdateResponse] +type dlpPayloadLogUpdateResponseJSON struct { + PublicKey apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPPayloadLogUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpPayloadLogUpdateResponseJSON) RawJSON() string { + return r.raw +} + +type DLPPayloadLogGetResponse struct { + PublicKey string `json:"public_key,required,nullable"` + JSON dlpPayloadLogGetResponseJSON `json:"-"` +} + +// dlpPayloadLogGetResponseJSON contains the JSON metadata for the struct +// [DLPPayloadLogGetResponse] +type dlpPayloadLogGetResponseJSON struct { + PublicKey apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPPayloadLogGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpPayloadLogGetResponseJSON) RawJSON() string { + return r.raw +} + +type DLPPayloadLogUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The public key to use when encrypting extracted payloads, as a base64 string + PublicKey param.Field[string] `json:"public_key,required"` +} + +func (r DLPPayloadLogUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DLPPayloadLogUpdateResponseEnvelope struct { + Errors []DLPPayloadLogUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []DLPPayloadLogUpdateResponseEnvelopeMessages `json:"messages,required"` + Result DLPPayloadLogUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success DLPPayloadLogUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON dlpPayloadLogUpdateResponseEnvelopeJSON `json:"-"` +} + +// dlpPayloadLogUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [DLPPayloadLogUpdateResponseEnvelope] +type dlpPayloadLogUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPPayloadLogUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpPayloadLogUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DLPPayloadLogUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpPayloadLogUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// dlpPayloadLogUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DLPPayloadLogUpdateResponseEnvelopeErrors] +type dlpPayloadLogUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPPayloadLogUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpPayloadLogUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DLPPayloadLogUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpPayloadLogUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// dlpPayloadLogUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [DLPPayloadLogUpdateResponseEnvelopeMessages] +type dlpPayloadLogUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPPayloadLogUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpPayloadLogUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DLPPayloadLogUpdateResponseEnvelopeSuccess bool + +const ( + DLPPayloadLogUpdateResponseEnvelopeSuccessTrue DLPPayloadLogUpdateResponseEnvelopeSuccess = true +) + +type DLPPayloadLogGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type DLPPayloadLogGetResponseEnvelope struct { + Errors []DLPPayloadLogGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DLPPayloadLogGetResponseEnvelopeMessages `json:"messages,required"` + Result DLPPayloadLogGetResponse `json:"result,required"` + // Whether the API call was successful + Success DLPPayloadLogGetResponseEnvelopeSuccess `json:"success,required"` + JSON dlpPayloadLogGetResponseEnvelopeJSON `json:"-"` +} + +// dlpPayloadLogGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DLPPayloadLogGetResponseEnvelope] +type dlpPayloadLogGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPPayloadLogGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpPayloadLogGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DLPPayloadLogGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpPayloadLogGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// dlpPayloadLogGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DLPPayloadLogGetResponseEnvelopeErrors] +type dlpPayloadLogGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPPayloadLogGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpPayloadLogGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DLPPayloadLogGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpPayloadLogGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// dlpPayloadLogGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DLPPayloadLogGetResponseEnvelopeMessages] +type dlpPayloadLogGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPPayloadLogGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpPayloadLogGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DLPPayloadLogGetResponseEnvelopeSuccess bool + +const ( + DLPPayloadLogGetResponseEnvelopeSuccessTrue DLPPayloadLogGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/dlppayloadlog_test.go b/zero_trust/dlppayloadlog_test.go new file mode 100644 index 00000000000..c2b7aa239a7 --- /dev/null +++ b/zero_trust/dlppayloadlog_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDLPPayloadLogUpdate(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("user@example.com"), + ) + _, err := client.ZeroTrust.DLP.PayloadLogs.Update(context.TODO(), zero_trust.DLPPayloadLogUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + PublicKey: cloudflare.F("EmpOvSXw8BfbrGCi0fhGiD/3yXk2SiV1Nzg2lru3oj0="), + }) + 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 TestDLPPayloadLogGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.DLP.PayloadLogs.Get(context.TODO(), zero_trust.DLPPayloadLogGetParams{ + AccountID: cloudflare.F("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/zero_trust/dlpprofile.go b/zero_trust/dlpprofile.go new file mode 100644 index 00000000000..5d9f8db70cc --- /dev/null +++ b/zero_trust/dlpprofile.go @@ -0,0 +1,486 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// DLPProfileService 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 [NewDLPProfileService] method instead. +type DLPProfileService struct { + Options []option.RequestOption + Customs *DLPProfileCustomService + Predefineds *DLPProfilePredefinedService +} + +// NewDLPProfileService 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 NewDLPProfileService(opts ...option.RequestOption) (r *DLPProfileService) { + r = &DLPProfileService{} + r.Options = opts + r.Customs = NewDLPProfileCustomService(opts...) + r.Predefineds = NewDLPProfilePredefinedService(opts...) + return +} + +// Lists all DLP profiles in an account. +func (r *DLPProfileService) List(ctx context.Context, query DLPProfileListParams, opts ...option.RequestOption) (res *[]DLPProfiles, err error) { + opts = append(r.Options[:], opts...) + var env DLPProfileListResponseEnvelope + path := fmt.Sprintf("accounts/%s/dlp/profiles", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a DLP profile by ID. Supports both predefined and custom profiles +func (r *DLPProfileService) Get(ctx context.Context, profileID string, query DLPProfileGetParams, opts ...option.RequestOption) (res *DLPProfileGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env DLPProfileGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/dlp/profiles/%s", query.AccountID, profileID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [zero_trust.DLPPredefinedProfile], +// [zero_trust.DLPCustomProfile] or [zero_trust.DLPProfilesDLPIntegrationProfile]. +type DLPProfiles interface { + implementsZeroTrustDLPProfiles() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DLPProfiles)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DLPPredefinedProfile{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DLPCustomProfile{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DLPProfilesDLPIntegrationProfile{}), + }, + ) +} + +type DLPProfilesDLPIntegrationProfile struct { + // The ID for this profile + ID string `json:"id"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The description of the profile. + Description string `json:"description"` + // The entries for this profile. + Entries []DLPProfilesDLPIntegrationProfileEntry `json:"entries"` + // The name of the profile. + Name string `json:"name"` + // The type of the profile. + Type DLPProfilesDLPIntegrationProfileType `json:"type"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON dlpProfilesDLPIntegrationProfileJSON `json:"-"` +} + +// dlpProfilesDLPIntegrationProfileJSON contains the JSON metadata for the struct +// [DLPProfilesDLPIntegrationProfile] +type dlpProfilesDLPIntegrationProfileJSON struct { + ID apijson.Field + CreatedAt apijson.Field + Description apijson.Field + Entries apijson.Field + Name apijson.Field + Type apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfilesDLPIntegrationProfile) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfilesDLPIntegrationProfileJSON) RawJSON() string { + return r.raw +} + +func (r DLPProfilesDLPIntegrationProfile) implementsZeroTrustDLPProfiles() {} + +// An entry derived from an integration +type DLPProfilesDLPIntegrationProfileEntry struct { + // The ID for this entry + ID string `json:"id"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // Whether the entry is enabled or not. + Enabled bool `json:"enabled"` + // The name of the entry. + Name string `json:"name"` + // ID of the parent profile + ProfileID interface{} `json:"profile_id"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON dlpProfilesDLPIntegrationProfileEntryJSON `json:"-"` +} + +// dlpProfilesDLPIntegrationProfileEntryJSON contains the JSON metadata for the +// struct [DLPProfilesDLPIntegrationProfileEntry] +type dlpProfilesDLPIntegrationProfileEntryJSON struct { + ID apijson.Field + CreatedAt apijson.Field + Enabled apijson.Field + Name apijson.Field + ProfileID apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfilesDLPIntegrationProfileEntry) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfilesDLPIntegrationProfileEntryJSON) RawJSON() string { + return r.raw +} + +// The type of the profile. +type DLPProfilesDLPIntegrationProfileType string + +const ( + DLPProfilesDLPIntegrationProfileTypeIntegration DLPProfilesDLPIntegrationProfileType = "integration" +) + +// Union satisfied by [zero_trust.DLPPredefinedProfile], +// [zero_trust.DLPCustomProfile] or +// [zero_trust.DLPProfileGetResponseDLPIntegrationProfile]. +type DLPProfileGetResponse interface { + implementsZeroTrustDLPProfileGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DLPProfileGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DLPPredefinedProfile{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DLPCustomProfile{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(DLPProfileGetResponseDLPIntegrationProfile{}), + }, + ) +} + +type DLPProfileGetResponseDLPIntegrationProfile struct { + // The ID for this profile + ID string `json:"id"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The description of the profile. + Description string `json:"description"` + // The entries for this profile. + Entries []DLPProfileGetResponseDLPIntegrationProfileEntry `json:"entries"` + // The name of the profile. + Name string `json:"name"` + // The type of the profile. + Type DLPProfileGetResponseDLPIntegrationProfileType `json:"type"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON dlpProfileGetResponseDLPIntegrationProfileJSON `json:"-"` +} + +// dlpProfileGetResponseDLPIntegrationProfileJSON contains the JSON metadata for +// the struct [DLPProfileGetResponseDLPIntegrationProfile] +type dlpProfileGetResponseDLPIntegrationProfileJSON struct { + ID apijson.Field + CreatedAt apijson.Field + Description apijson.Field + Entries apijson.Field + Name apijson.Field + Type apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfileGetResponseDLPIntegrationProfile) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileGetResponseDLPIntegrationProfileJSON) RawJSON() string { + return r.raw +} + +func (r DLPProfileGetResponseDLPIntegrationProfile) implementsZeroTrustDLPProfileGetResponse() {} + +// An entry derived from an integration +type DLPProfileGetResponseDLPIntegrationProfileEntry struct { + // The ID for this entry + ID string `json:"id"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // Whether the entry is enabled or not. + Enabled bool `json:"enabled"` + // The name of the entry. + Name string `json:"name"` + // ID of the parent profile + ProfileID interface{} `json:"profile_id"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON dlpProfileGetResponseDLPIntegrationProfileEntryJSON `json:"-"` +} + +// dlpProfileGetResponseDLPIntegrationProfileEntryJSON contains the JSON metadata +// for the struct [DLPProfileGetResponseDLPIntegrationProfileEntry] +type dlpProfileGetResponseDLPIntegrationProfileEntryJSON struct { + ID apijson.Field + CreatedAt apijson.Field + Enabled apijson.Field + Name apijson.Field + ProfileID apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfileGetResponseDLPIntegrationProfileEntry) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileGetResponseDLPIntegrationProfileEntryJSON) RawJSON() string { + return r.raw +} + +// The type of the profile. +type DLPProfileGetResponseDLPIntegrationProfileType string + +const ( + DLPProfileGetResponseDLPIntegrationProfileTypeIntegration DLPProfileGetResponseDLPIntegrationProfileType = "integration" +) + +type DLPProfileListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type DLPProfileListResponseEnvelope struct { + Errors []DLPProfileListResponseEnvelopeErrors `json:"errors,required"` + Messages []DLPProfileListResponseEnvelopeMessages `json:"messages,required"` + Result []DLPProfiles `json:"result,required,nullable"` + // Whether the API call was successful + Success DLPProfileListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DLPProfileListResponseEnvelopeResultInfo `json:"result_info"` + JSON dlpProfileListResponseEnvelopeJSON `json:"-"` +} + +// dlpProfileListResponseEnvelopeJSON contains the JSON metadata for the struct +// [DLPProfileListResponseEnvelope] +type dlpProfileListResponseEnvelopeJSON 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 *DLPProfileListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DLPProfileListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpProfileListResponseEnvelopeErrorsJSON `json:"-"` +} + +// dlpProfileListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DLPProfileListResponseEnvelopeErrors] +type dlpProfileListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfileListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DLPProfileListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpProfileListResponseEnvelopeMessagesJSON `json:"-"` +} + +// dlpProfileListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DLPProfileListResponseEnvelopeMessages] +type dlpProfileListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfileListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DLPProfileListResponseEnvelopeSuccess bool + +const ( + DLPProfileListResponseEnvelopeSuccessTrue DLPProfileListResponseEnvelopeSuccess = true +) + +type DLPProfileListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON dlpProfileListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// dlpProfileListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [DLPProfileListResponseEnvelopeResultInfo] +type dlpProfileListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfileListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DLPProfileGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type DLPProfileGetResponseEnvelope struct { + Errors []DLPProfileGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DLPProfileGetResponseEnvelopeMessages `json:"messages,required"` + Result DLPProfileGetResponse `json:"result,required"` + // Whether the API call was successful + Success DLPProfileGetResponseEnvelopeSuccess `json:"success,required"` + JSON dlpProfileGetResponseEnvelopeJSON `json:"-"` +} + +// dlpProfileGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [DLPProfileGetResponseEnvelope] +type dlpProfileGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfileGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DLPProfileGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpProfileGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// dlpProfileGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DLPProfileGetResponseEnvelopeErrors] +type dlpProfileGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfileGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DLPProfileGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpProfileGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// dlpProfileGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [DLPProfileGetResponseEnvelopeMessages] +type dlpProfileGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfileGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DLPProfileGetResponseEnvelopeSuccess bool + +const ( + DLPProfileGetResponseEnvelopeSuccessTrue DLPProfileGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/dlpprofile_test.go b/zero_trust/dlpprofile_test.go new file mode 100644 index 00000000000..a6c9a04235b --- /dev/null +++ b/zero_trust/dlpprofile_test.go @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDLPProfileList(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("user@example.com"), + ) + _, err := client.ZeroTrust.DLP.Profiles.List(context.TODO(), zero_trust.DLPProfileListParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestDLPProfileGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.DLP.Profiles.Get( + context.TODO(), + "384e129d-25bd-403c-8019-bc19eb7a8a5f", + zero_trust.DLPProfileGetParams{ + AccountID: cloudflare.F("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/zero_trust/dlpprofilecustom.go b/zero_trust/dlpprofilecustom.go new file mode 100644 index 00000000000..58f18a54ce0 --- /dev/null +++ b/zero_trust/dlpprofilecustom.go @@ -0,0 +1,775 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// DLPProfileCustomService 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 [NewDLPProfileCustomService] method +// instead. +type DLPProfileCustomService struct { + Options []option.RequestOption +} + +// NewDLPProfileCustomService 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 NewDLPProfileCustomService(opts ...option.RequestOption) (r *DLPProfileCustomService) { + r = &DLPProfileCustomService{} + r.Options = opts + return +} + +// Creates a set of DLP custom profiles. +func (r *DLPProfileCustomService) New(ctx context.Context, params DLPProfileCustomNewParams, opts ...option.RequestOption) (res *[]DLPCustomProfile, err error) { + opts = append(r.Options[:], opts...) + var env DLPProfileCustomNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/dlp/profiles/custom", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a DLP custom profile. +func (r *DLPProfileCustomService) Update(ctx context.Context, profileID string, params DLPProfileCustomUpdateParams, opts ...option.RequestOption) (res *DLPCustomProfile, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("accounts/%s/dlp/profiles/custom/%s", params.AccountID, profileID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &res, opts...) + return +} + +// Deletes a DLP custom profile. +func (r *DLPProfileCustomService) Delete(ctx context.Context, profileID string, body DLPProfileCustomDeleteParams, opts ...option.RequestOption) (res *DLPProfileCustomDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env DLPProfileCustomDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/dlp/profiles/custom/%s", body.AccountID, profileID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a custom DLP profile. +func (r *DLPProfileCustomService) Get(ctx context.Context, profileID string, query DLPProfileCustomGetParams, opts ...option.RequestOption) (res *DLPCustomProfile, err error) { + opts = append(r.Options[:], opts...) + var env DLPProfileCustomGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/dlp/profiles/custom/%s", query.AccountID, profileID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DLPCustomProfile struct { + // The ID for this profile + ID string `json:"id"` + // Related DLP policies will trigger when the match count exceeds the number set. + AllowedMatchCount float64 `json:"allowed_match_count"` + // Scan the context of predefined entries to only return matches surrounded by + // keywords. + ContextAwareness DLPCustomProfileContextAwareness `json:"context_awareness"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The description of the profile. + Description string `json:"description"` + // The entries for this profile. + Entries []DLPCustomProfileEntry `json:"entries"` + // The name of the profile. + Name string `json:"name"` + // The type of the profile. + Type DLPCustomProfileType `json:"type"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON dlpCustomProfileJSON `json:"-"` +} + +// dlpCustomProfileJSON contains the JSON metadata for the struct +// [DLPCustomProfile] +type dlpCustomProfileJSON struct { + ID apijson.Field + AllowedMatchCount apijson.Field + ContextAwareness apijson.Field + CreatedAt apijson.Field + Description apijson.Field + Entries apijson.Field + Name apijson.Field + Type apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPCustomProfile) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpCustomProfileJSON) RawJSON() string { + return r.raw +} + +func (r DLPCustomProfile) implementsZeroTrustDLPProfiles() {} + +func (r DLPCustomProfile) implementsZeroTrustDLPProfileGetResponse() {} + +// Scan the context of predefined entries to only return matches surrounded by +// keywords. +type DLPCustomProfileContextAwareness struct { + // If true, scan the context of predefined entries to only return matches + // surrounded by keywords. + Enabled bool `json:"enabled,required"` + // Content types to exclude from context analysis and return all matches. + Skip DLPCustomProfileContextAwarenessSkip `json:"skip,required"` + JSON dlpCustomProfileContextAwarenessJSON `json:"-"` +} + +// dlpCustomProfileContextAwarenessJSON contains the JSON metadata for the struct +// [DLPCustomProfileContextAwareness] +type dlpCustomProfileContextAwarenessJSON struct { + Enabled apijson.Field + Skip apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPCustomProfileContextAwareness) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpCustomProfileContextAwarenessJSON) RawJSON() string { + return r.raw +} + +// Content types to exclude from context analysis and return all matches. +type DLPCustomProfileContextAwarenessSkip struct { + // If the content type is a file, skip context analysis and return all matches. + Files bool `json:"files,required"` + JSON dlpCustomProfileContextAwarenessSkipJSON `json:"-"` +} + +// dlpCustomProfileContextAwarenessSkipJSON contains the JSON metadata for the +// struct [DLPCustomProfileContextAwarenessSkip] +type dlpCustomProfileContextAwarenessSkipJSON struct { + Files apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPCustomProfileContextAwarenessSkip) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpCustomProfileContextAwarenessSkipJSON) RawJSON() string { + return r.raw +} + +// A custom entry that matches a profile +type DLPCustomProfileEntry struct { + // The ID for this entry + ID string `json:"id"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // Whether the entry is enabled or not. + Enabled bool `json:"enabled"` + // The name of the entry. + Name string `json:"name"` + // A pattern that matches an entry + Pattern DLPCustomProfileEntriesPattern `json:"pattern"` + // ID of the parent profile + ProfileID interface{} `json:"profile_id"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON dlpCustomProfileEntryJSON `json:"-"` +} + +// dlpCustomProfileEntryJSON contains the JSON metadata for the struct +// [DLPCustomProfileEntry] +type dlpCustomProfileEntryJSON struct { + ID apijson.Field + CreatedAt apijson.Field + Enabled apijson.Field + Name apijson.Field + Pattern apijson.Field + ProfileID apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPCustomProfileEntry) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpCustomProfileEntryJSON) RawJSON() string { + return r.raw +} + +// A pattern that matches an entry +type DLPCustomProfileEntriesPattern struct { + // The regex pattern. + Regex string `json:"regex,required"` + // Validation algorithm for the pattern. This algorithm will get run on potential + // matches, and if it returns false, the entry will not be matched. + Validation DLPCustomProfileEntriesPatternValidation `json:"validation"` + JSON dlpCustomProfileEntriesPatternJSON `json:"-"` +} + +// dlpCustomProfileEntriesPatternJSON contains the JSON metadata for the struct +// [DLPCustomProfileEntriesPattern] +type dlpCustomProfileEntriesPatternJSON struct { + Regex apijson.Field + Validation apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPCustomProfileEntriesPattern) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpCustomProfileEntriesPatternJSON) RawJSON() string { + return r.raw +} + +// Validation algorithm for the pattern. This algorithm will get run on potential +// matches, and if it returns false, the entry will not be matched. +type DLPCustomProfileEntriesPatternValidation string + +const ( + DLPCustomProfileEntriesPatternValidationLuhn DLPCustomProfileEntriesPatternValidation = "luhn" +) + +// The type of the profile. +type DLPCustomProfileType string + +const ( + DLPCustomProfileTypeCustom DLPCustomProfileType = "custom" +) + +// Union satisfied by [zero_trust.DLPProfileCustomDeleteResponseUnknown] or +// [shared.UnionString]. +type DLPProfileCustomDeleteResponse interface { + ImplementsZeroTrustDLPProfileCustomDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*DLPProfileCustomDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type DLPProfileCustomNewParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + Profiles param.Field[[]DLPProfileCustomNewParamsProfile] `json:"profiles,required"` +} + +func (r DLPProfileCustomNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DLPProfileCustomNewParamsProfile struct { + // Related DLP policies will trigger when the match count exceeds the number set. + AllowedMatchCount param.Field[float64] `json:"allowed_match_count"` + // Scan the context of predefined entries to only return matches surrounded by + // keywords. + ContextAwareness param.Field[DLPProfileCustomNewParamsProfilesContextAwareness] `json:"context_awareness"` + // The description of the profile. + Description param.Field[string] `json:"description"` + // The entries for this profile. + Entries param.Field[[]DLPProfileCustomNewParamsProfilesEntry] `json:"entries"` + // The name of the profile. + Name param.Field[string] `json:"name"` +} + +func (r DLPProfileCustomNewParamsProfile) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Scan the context of predefined entries to only return matches surrounded by +// keywords. +type DLPProfileCustomNewParamsProfilesContextAwareness struct { + // If true, scan the context of predefined entries to only return matches + // surrounded by keywords. + Enabled param.Field[bool] `json:"enabled,required"` + // Content types to exclude from context analysis and return all matches. + Skip param.Field[DLPProfileCustomNewParamsProfilesContextAwarenessSkip] `json:"skip,required"` +} + +func (r DLPProfileCustomNewParamsProfilesContextAwareness) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Content types to exclude from context analysis and return all matches. +type DLPProfileCustomNewParamsProfilesContextAwarenessSkip struct { + // If the content type is a file, skip context analysis and return all matches. + Files param.Field[bool] `json:"files,required"` +} + +func (r DLPProfileCustomNewParamsProfilesContextAwarenessSkip) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A custom entry create payload +type DLPProfileCustomNewParamsProfilesEntry struct { + // Whether the entry is enabled or not. + Enabled param.Field[bool] `json:"enabled,required"` + // The name of the entry. + Name param.Field[string] `json:"name,required"` + // A pattern that matches an entry + Pattern param.Field[DLPProfileCustomNewParamsProfilesEntriesPattern] `json:"pattern,required"` +} + +func (r DLPProfileCustomNewParamsProfilesEntry) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A pattern that matches an entry +type DLPProfileCustomNewParamsProfilesEntriesPattern struct { + // The regex pattern. + Regex param.Field[string] `json:"regex,required"` + // Validation algorithm for the pattern. This algorithm will get run on potential + // matches, and if it returns false, the entry will not be matched. + Validation param.Field[DLPProfileCustomNewParamsProfilesEntriesPatternValidation] `json:"validation"` +} + +func (r DLPProfileCustomNewParamsProfilesEntriesPattern) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Validation algorithm for the pattern. This algorithm will get run on potential +// matches, and if it returns false, the entry will not be matched. +type DLPProfileCustomNewParamsProfilesEntriesPatternValidation string + +const ( + DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn DLPProfileCustomNewParamsProfilesEntriesPatternValidation = "luhn" +) + +type DLPProfileCustomNewResponseEnvelope struct { + Errors []DLPProfileCustomNewResponseEnvelopeErrors `json:"errors,required"` + Messages []DLPProfileCustomNewResponseEnvelopeMessages `json:"messages,required"` + Result []DLPCustomProfile `json:"result,required,nullable"` + // Whether the API call was successful + Success DLPProfileCustomNewResponseEnvelopeSuccess `json:"success,required"` + ResultInfo DLPProfileCustomNewResponseEnvelopeResultInfo `json:"result_info"` + JSON dlpProfileCustomNewResponseEnvelopeJSON `json:"-"` +} + +// dlpProfileCustomNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [DLPProfileCustomNewResponseEnvelope] +type dlpProfileCustomNewResponseEnvelopeJSON 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 *DLPProfileCustomNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileCustomNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DLPProfileCustomNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpProfileCustomNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// dlpProfileCustomNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DLPProfileCustomNewResponseEnvelopeErrors] +type dlpProfileCustomNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfileCustomNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileCustomNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DLPProfileCustomNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpProfileCustomNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// dlpProfileCustomNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [DLPProfileCustomNewResponseEnvelopeMessages] +type dlpProfileCustomNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfileCustomNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileCustomNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DLPProfileCustomNewResponseEnvelopeSuccess bool + +const ( + DLPProfileCustomNewResponseEnvelopeSuccessTrue DLPProfileCustomNewResponseEnvelopeSuccess = true +) + +type DLPProfileCustomNewResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON dlpProfileCustomNewResponseEnvelopeResultInfoJSON `json:"-"` +} + +// dlpProfileCustomNewResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [DLPProfileCustomNewResponseEnvelopeResultInfo] +type dlpProfileCustomNewResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfileCustomNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileCustomNewResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type DLPProfileCustomUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Related DLP policies will trigger when the match count exceeds the number set. + AllowedMatchCount param.Field[float64] `json:"allowed_match_count"` + // Scan the context of predefined entries to only return matches surrounded by + // keywords. + ContextAwareness param.Field[DLPProfileCustomUpdateParamsContextAwareness] `json:"context_awareness"` + // The description of the profile. + Description param.Field[string] `json:"description"` + // The custom entries for this profile. Array elements with IDs are modifying the + // existing entry with that ID. Elements without ID will create new entries. Any + // entry not in the list will be deleted. + Entries param.Field[[]DLPProfileCustomUpdateParamsEntry] `json:"entries"` + // The name of the profile. + Name param.Field[string] `json:"name"` + // Entries from other profiles (e.g. pre-defined Cloudflare profiles, or your + // Microsoft Information Protection profiles). + SharedEntries param.Field[[]DLPProfileCustomUpdateParamsSharedEntry] `json:"shared_entries"` +} + +func (r DLPProfileCustomUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Scan the context of predefined entries to only return matches surrounded by +// keywords. +type DLPProfileCustomUpdateParamsContextAwareness struct { + // If true, scan the context of predefined entries to only return matches + // surrounded by keywords. + Enabled param.Field[bool] `json:"enabled,required"` + // Content types to exclude from context analysis and return all matches. + Skip param.Field[DLPProfileCustomUpdateParamsContextAwarenessSkip] `json:"skip,required"` +} + +func (r DLPProfileCustomUpdateParamsContextAwareness) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Content types to exclude from context analysis and return all matches. +type DLPProfileCustomUpdateParamsContextAwarenessSkip struct { + // If the content type is a file, skip context analysis and return all matches. + Files param.Field[bool] `json:"files,required"` +} + +func (r DLPProfileCustomUpdateParamsContextAwarenessSkip) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A custom entry that matches a profile +type DLPProfileCustomUpdateParamsEntry struct { + // Whether the entry is enabled or not. + Enabled param.Field[bool] `json:"enabled"` + // The name of the entry. + Name param.Field[string] `json:"name"` + // A pattern that matches an entry + Pattern param.Field[DLPProfileCustomUpdateParamsEntriesPattern] `json:"pattern"` + // ID of the parent profile + ProfileID param.Field[interface{}] `json:"profile_id"` +} + +func (r DLPProfileCustomUpdateParamsEntry) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A pattern that matches an entry +type DLPProfileCustomUpdateParamsEntriesPattern struct { + // The regex pattern. + Regex param.Field[string] `json:"regex,required"` + // Validation algorithm for the pattern. This algorithm will get run on potential + // matches, and if it returns false, the entry will not be matched. + Validation param.Field[DLPProfileCustomUpdateParamsEntriesPatternValidation] `json:"validation"` +} + +func (r DLPProfileCustomUpdateParamsEntriesPattern) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Validation algorithm for the pattern. This algorithm will get run on potential +// matches, and if it returns false, the entry will not be matched. +type DLPProfileCustomUpdateParamsEntriesPatternValidation string + +const ( + DLPProfileCustomUpdateParamsEntriesPatternValidationLuhn DLPProfileCustomUpdateParamsEntriesPatternValidation = "luhn" +) + +// Properties of a predefined entry in a custom profile +// +// Satisfied by +// [zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined], +// [zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdateIntegration]. +type DLPProfileCustomUpdateParamsSharedEntry interface { + implementsZeroTrustDLPProfileCustomUpdateParamsSharedEntry() +} + +// Properties of a predefined entry in a custom profile +type DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined struct { + // Whether the entry is enabled or not. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined) implementsZeroTrustDLPProfileCustomUpdateParamsSharedEntry() { +} + +// Properties of an integration entry in a custom profile +type DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdateIntegration struct { + // Whether the entry is enabled or not. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdateIntegration) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdateIntegration) implementsZeroTrustDLPProfileCustomUpdateParamsSharedEntry() { +} + +type DLPProfileCustomDeleteParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type DLPProfileCustomDeleteResponseEnvelope struct { + Errors []DLPProfileCustomDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []DLPProfileCustomDeleteResponseEnvelopeMessages `json:"messages,required"` + Result DLPProfileCustomDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success DLPProfileCustomDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON dlpProfileCustomDeleteResponseEnvelopeJSON `json:"-"` +} + +// dlpProfileCustomDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [DLPProfileCustomDeleteResponseEnvelope] +type dlpProfileCustomDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfileCustomDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileCustomDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DLPProfileCustomDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpProfileCustomDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// dlpProfileCustomDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [DLPProfileCustomDeleteResponseEnvelopeErrors] +type dlpProfileCustomDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfileCustomDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileCustomDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DLPProfileCustomDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpProfileCustomDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// dlpProfileCustomDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [DLPProfileCustomDeleteResponseEnvelopeMessages] +type dlpProfileCustomDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfileCustomDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileCustomDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DLPProfileCustomDeleteResponseEnvelopeSuccess bool + +const ( + DLPProfileCustomDeleteResponseEnvelopeSuccessTrue DLPProfileCustomDeleteResponseEnvelopeSuccess = true +) + +type DLPProfileCustomGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type DLPProfileCustomGetResponseEnvelope struct { + Errors []DLPProfileCustomGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DLPProfileCustomGetResponseEnvelopeMessages `json:"messages,required"` + Result DLPCustomProfile `json:"result,required"` + // Whether the API call was successful + Success DLPProfileCustomGetResponseEnvelopeSuccess `json:"success,required"` + JSON dlpProfileCustomGetResponseEnvelopeJSON `json:"-"` +} + +// dlpProfileCustomGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [DLPProfileCustomGetResponseEnvelope] +type dlpProfileCustomGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfileCustomGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileCustomGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DLPProfileCustomGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpProfileCustomGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// dlpProfileCustomGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [DLPProfileCustomGetResponseEnvelopeErrors] +type dlpProfileCustomGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfileCustomGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileCustomGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DLPProfileCustomGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpProfileCustomGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// dlpProfileCustomGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [DLPProfileCustomGetResponseEnvelopeMessages] +type dlpProfileCustomGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfileCustomGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfileCustomGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DLPProfileCustomGetResponseEnvelopeSuccess bool + +const ( + DLPProfileCustomGetResponseEnvelopeSuccessTrue DLPProfileCustomGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/dlpprofilecustom_test.go b/zero_trust/dlpprofilecustom_test.go new file mode 100644 index 00000000000..070ecd95ce8 --- /dev/null +++ b/zero_trust/dlpprofilecustom_test.go @@ -0,0 +1,269 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDLPProfileCustomNew(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("user@example.com"), + ) + _, err := client.ZeroTrust.DLP.Profiles.Customs.New(context.TODO(), zero_trust.DLPProfileCustomNewParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Profiles: cloudflare.F([]zero_trust.DLPProfileCustomNewParamsProfile{{ + AllowedMatchCount: cloudflare.F(5.000000), + ContextAwareness: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesContextAwareness{ + Enabled: cloudflare.F(true), + Skip: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesContextAwarenessSkip{ + Files: cloudflare.F(true), + }), + }), + Description: cloudflare.F("A standard CVV card number"), + Entries: cloudflare.F([]zero_trust.DLPProfileCustomNewParamsProfilesEntry{{ + Enabled: cloudflare.F(true), + Name: cloudflare.F("Credit card (Visa)"), + Pattern: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPattern{ + Regex: cloudflare.F("^4[0-9]{6,14}$"), + Validation: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), + }), + }, { + Enabled: cloudflare.F(true), + Name: cloudflare.F("Credit card (Visa)"), + Pattern: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPattern{ + Regex: cloudflare.F("^4[0-9]{6,14}$"), + Validation: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), + }), + }, { + Enabled: cloudflare.F(true), + Name: cloudflare.F("Credit card (Visa)"), + Pattern: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPattern{ + Regex: cloudflare.F("^4[0-9]{6,14}$"), + Validation: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), + }), + }}), + Name: cloudflare.F("Generic CVV Card Number"), + }, { + AllowedMatchCount: cloudflare.F(5.000000), + ContextAwareness: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesContextAwareness{ + Enabled: cloudflare.F(true), + Skip: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesContextAwarenessSkip{ + Files: cloudflare.F(true), + }), + }), + Description: cloudflare.F("A standard CVV card number"), + Entries: cloudflare.F([]zero_trust.DLPProfileCustomNewParamsProfilesEntry{{ + Enabled: cloudflare.F(true), + Name: cloudflare.F("Credit card (Visa)"), + Pattern: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPattern{ + Regex: cloudflare.F("^4[0-9]{6,14}$"), + Validation: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), + }), + }, { + Enabled: cloudflare.F(true), + Name: cloudflare.F("Credit card (Visa)"), + Pattern: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPattern{ + Regex: cloudflare.F("^4[0-9]{6,14}$"), + Validation: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), + }), + }, { + Enabled: cloudflare.F(true), + Name: cloudflare.F("Credit card (Visa)"), + Pattern: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPattern{ + Regex: cloudflare.F("^4[0-9]{6,14}$"), + Validation: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), + }), + }}), + Name: cloudflare.F("Generic CVV Card Number"), + }, { + AllowedMatchCount: cloudflare.F(5.000000), + ContextAwareness: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesContextAwareness{ + Enabled: cloudflare.F(true), + Skip: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesContextAwarenessSkip{ + Files: cloudflare.F(true), + }), + }), + Description: cloudflare.F("A standard CVV card number"), + Entries: cloudflare.F([]zero_trust.DLPProfileCustomNewParamsProfilesEntry{{ + Enabled: cloudflare.F(true), + Name: cloudflare.F("Credit card (Visa)"), + Pattern: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPattern{ + Regex: cloudflare.F("^4[0-9]{6,14}$"), + Validation: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), + }), + }, { + Enabled: cloudflare.F(true), + Name: cloudflare.F("Credit card (Visa)"), + Pattern: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPattern{ + Regex: cloudflare.F("^4[0-9]{6,14}$"), + Validation: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), + }), + }, { + Enabled: cloudflare.F(true), + Name: cloudflare.F("Credit card (Visa)"), + Pattern: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPattern{ + Regex: cloudflare.F("^4[0-9]{6,14}$"), + Validation: cloudflare.F(zero_trust.DLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), + }), + }}), + Name: cloudflare.F("Generic CVV Card Number"), + }}), + }) + 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 TestDLPProfileCustomUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.DLP.Profiles.Customs.Update( + context.TODO(), + "384e129d-25bd-403c-8019-bc19eb7a8a5f", + zero_trust.DLPProfileCustomUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + AllowedMatchCount: cloudflare.F(5.000000), + ContextAwareness: cloudflare.F(zero_trust.DLPProfileCustomUpdateParamsContextAwareness{ + Enabled: cloudflare.F(true), + Skip: cloudflare.F(zero_trust.DLPProfileCustomUpdateParamsContextAwarenessSkip{ + Files: cloudflare.F(true), + }), + }), + Description: cloudflare.F("A standard CVV card number"), + Entries: cloudflare.F([]zero_trust.DLPProfileCustomUpdateParamsEntry{{ + Enabled: cloudflare.F(true), + Name: cloudflare.F("Credit card (Visa)"), + Pattern: cloudflare.F(zero_trust.DLPProfileCustomUpdateParamsEntriesPattern{ + Regex: cloudflare.F("^4[0-9]{6,14}$"), + Validation: cloudflare.F(zero_trust.DLPProfileCustomUpdateParamsEntriesPatternValidationLuhn), + }), + ProfileID: cloudflare.F[any](map[string]interface{}{}), + }, { + Enabled: cloudflare.F(true), + Name: cloudflare.F("Credit card (Visa)"), + Pattern: cloudflare.F(zero_trust.DLPProfileCustomUpdateParamsEntriesPattern{ + Regex: cloudflare.F("^4[0-9]{6,14}$"), + Validation: cloudflare.F(zero_trust.DLPProfileCustomUpdateParamsEntriesPatternValidationLuhn), + }), + ProfileID: cloudflare.F[any](map[string]interface{}{}), + }, { + Enabled: cloudflare.F(true), + Name: cloudflare.F("Credit card (Visa)"), + Pattern: cloudflare.F(zero_trust.DLPProfileCustomUpdateParamsEntriesPattern{ + Regex: cloudflare.F("^4[0-9]{6,14}$"), + Validation: cloudflare.F(zero_trust.DLPProfileCustomUpdateParamsEntriesPatternValidationLuhn), + }), + ProfileID: cloudflare.F[any](map[string]interface{}{}), + }}), + Name: cloudflare.F("Generic CVV Card Number"), + SharedEntries: cloudflare.F([]zero_trust.DLPProfileCustomUpdateParamsSharedEntry{zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined(zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined{ + Enabled: cloudflare.F(true), + }), zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined(zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined{ + Enabled: cloudflare.F(true), + }), zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined(zero_trust.DLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined{ + Enabled: cloudflare.F(true), + })}), + }, + ) + 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 TestDLPProfileCustomDelete(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("user@example.com"), + ) + _, err := client.ZeroTrust.DLP.Profiles.Customs.Delete( + context.TODO(), + "384e129d-25bd-403c-8019-bc19eb7a8a5f", + zero_trust.DLPProfileCustomDeleteParams{ + AccountID: cloudflare.F("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()) + } +} + +func TestDLPProfileCustomGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.DLP.Profiles.Customs.Get( + context.TODO(), + "384e129d-25bd-403c-8019-bc19eb7a8a5f", + zero_trust.DLPProfileCustomGetParams{ + AccountID: cloudflare.F("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/zero_trust/dlpprofilepredefined.go b/zero_trust/dlpprofilepredefined.go new file mode 100644 index 00000000000..de2ff260751 --- /dev/null +++ b/zero_trust/dlpprofilepredefined.go @@ -0,0 +1,320 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// DLPProfilePredefinedService 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 [NewDLPProfilePredefinedService] +// method instead. +type DLPProfilePredefinedService struct { + Options []option.RequestOption +} + +// NewDLPProfilePredefinedService 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 NewDLPProfilePredefinedService(opts ...option.RequestOption) (r *DLPProfilePredefinedService) { + r = &DLPProfilePredefinedService{} + r.Options = opts + return +} + +// Updates a DLP predefined profile. Only supports enabling/disabling entries. +func (r *DLPProfilePredefinedService) Update(ctx context.Context, profileID string, params DLPProfilePredefinedUpdateParams, opts ...option.RequestOption) (res *DLPPredefinedProfile, err error) { + opts = append(r.Options[:], opts...) + path := fmt.Sprintf("accounts/%s/dlp/profiles/predefined/%s", params.AccountID, profileID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &res, opts...) + return +} + +// Fetches a predefined DLP profile. +func (r *DLPProfilePredefinedService) Get(ctx context.Context, profileID string, query DLPProfilePredefinedGetParams, opts ...option.RequestOption) (res *DLPPredefinedProfile, err error) { + opts = append(r.Options[:], opts...) + var env DLPProfilePredefinedGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/dlp/profiles/predefined/%s", query.AccountID, profileID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type DLPPredefinedProfile struct { + // The ID for this profile + ID string `json:"id"` + // Related DLP policies will trigger when the match count exceeds the number set. + AllowedMatchCount float64 `json:"allowed_match_count"` + // Scan the context of predefined entries to only return matches surrounded by + // keywords. + ContextAwareness DLPPredefinedProfileContextAwareness `json:"context_awareness"` + // The entries for this profile. + Entries []DLPPredefinedProfileEntry `json:"entries"` + // The name of the profile. + Name string `json:"name"` + // The type of the profile. + Type DLPPredefinedProfileType `json:"type"` + JSON dlpPredefinedProfileJSON `json:"-"` +} + +// dlpPredefinedProfileJSON contains the JSON metadata for the struct +// [DLPPredefinedProfile] +type dlpPredefinedProfileJSON struct { + ID apijson.Field + AllowedMatchCount apijson.Field + ContextAwareness apijson.Field + Entries apijson.Field + Name apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPPredefinedProfile) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpPredefinedProfileJSON) RawJSON() string { + return r.raw +} + +func (r DLPPredefinedProfile) implementsZeroTrustDLPProfiles() {} + +func (r DLPPredefinedProfile) implementsZeroTrustDLPProfileGetResponse() {} + +// Scan the context of predefined entries to only return matches surrounded by +// keywords. +type DLPPredefinedProfileContextAwareness struct { + // If true, scan the context of predefined entries to only return matches + // surrounded by keywords. + Enabled bool `json:"enabled,required"` + // Content types to exclude from context analysis and return all matches. + Skip DLPPredefinedProfileContextAwarenessSkip `json:"skip,required"` + JSON dlpPredefinedProfileContextAwarenessJSON `json:"-"` +} + +// dlpPredefinedProfileContextAwarenessJSON contains the JSON metadata for the +// struct [DLPPredefinedProfileContextAwareness] +type dlpPredefinedProfileContextAwarenessJSON struct { + Enabled apijson.Field + Skip apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPPredefinedProfileContextAwareness) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpPredefinedProfileContextAwarenessJSON) RawJSON() string { + return r.raw +} + +// Content types to exclude from context analysis and return all matches. +type DLPPredefinedProfileContextAwarenessSkip struct { + // If the content type is a file, skip context analysis and return all matches. + Files bool `json:"files,required"` + JSON dlpPredefinedProfileContextAwarenessSkipJSON `json:"-"` +} + +// dlpPredefinedProfileContextAwarenessSkipJSON contains the JSON metadata for the +// struct [DLPPredefinedProfileContextAwarenessSkip] +type dlpPredefinedProfileContextAwarenessSkipJSON struct { + Files apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPPredefinedProfileContextAwarenessSkip) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpPredefinedProfileContextAwarenessSkipJSON) RawJSON() string { + return r.raw +} + +// A predefined entry that matches a profile +type DLPPredefinedProfileEntry struct { + // The ID for this entry + ID string `json:"id"` + // Whether the entry is enabled or not. + Enabled bool `json:"enabled"` + // The name of the entry. + Name string `json:"name"` + // ID of the parent profile + ProfileID interface{} `json:"profile_id"` + JSON dlpPredefinedProfileEntryJSON `json:"-"` +} + +// dlpPredefinedProfileEntryJSON contains the JSON metadata for the struct +// [DLPPredefinedProfileEntry] +type dlpPredefinedProfileEntryJSON struct { + ID apijson.Field + Enabled apijson.Field + Name apijson.Field + ProfileID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPPredefinedProfileEntry) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpPredefinedProfileEntryJSON) RawJSON() string { + return r.raw +} + +// The type of the profile. +type DLPPredefinedProfileType string + +const ( + DLPPredefinedProfileTypePredefined DLPPredefinedProfileType = "predefined" +) + +type DLPProfilePredefinedUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // Related DLP policies will trigger when the match count exceeds the number set. + AllowedMatchCount param.Field[float64] `json:"allowed_match_count"` + // Scan the context of predefined entries to only return matches surrounded by + // keywords. + ContextAwareness param.Field[DLPProfilePredefinedUpdateParamsContextAwareness] `json:"context_awareness"` + // The entries for this profile. + Entries param.Field[[]DLPProfilePredefinedUpdateParamsEntry] `json:"entries"` +} + +func (r DLPProfilePredefinedUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Scan the context of predefined entries to only return matches surrounded by +// keywords. +type DLPProfilePredefinedUpdateParamsContextAwareness struct { + // If true, scan the context of predefined entries to only return matches + // surrounded by keywords. + Enabled param.Field[bool] `json:"enabled,required"` + // Content types to exclude from context analysis and return all matches. + Skip param.Field[DLPProfilePredefinedUpdateParamsContextAwarenessSkip] `json:"skip,required"` +} + +func (r DLPProfilePredefinedUpdateParamsContextAwareness) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Content types to exclude from context analysis and return all matches. +type DLPProfilePredefinedUpdateParamsContextAwarenessSkip struct { + // If the content type is a file, skip context analysis and return all matches. + Files param.Field[bool] `json:"files,required"` +} + +func (r DLPProfilePredefinedUpdateParamsContextAwarenessSkip) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DLPProfilePredefinedUpdateParamsEntry struct { + // Whether the entry is enabled or not. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r DLPProfilePredefinedUpdateParamsEntry) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type DLPProfilePredefinedGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type DLPProfilePredefinedGetResponseEnvelope struct { + Errors []DLPProfilePredefinedGetResponseEnvelopeErrors `json:"errors,required"` + Messages []DLPProfilePredefinedGetResponseEnvelopeMessages `json:"messages,required"` + Result DLPPredefinedProfile `json:"result,required"` + // Whether the API call was successful + Success DLPProfilePredefinedGetResponseEnvelopeSuccess `json:"success,required"` + JSON dlpProfilePredefinedGetResponseEnvelopeJSON `json:"-"` +} + +// dlpProfilePredefinedGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [DLPProfilePredefinedGetResponseEnvelope] +type dlpProfilePredefinedGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfilePredefinedGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfilePredefinedGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type DLPProfilePredefinedGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpProfilePredefinedGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// dlpProfilePredefinedGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [DLPProfilePredefinedGetResponseEnvelopeErrors] +type dlpProfilePredefinedGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfilePredefinedGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfilePredefinedGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type DLPProfilePredefinedGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON dlpProfilePredefinedGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// dlpProfilePredefinedGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [DLPProfilePredefinedGetResponseEnvelopeMessages] +type dlpProfilePredefinedGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *DLPProfilePredefinedGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r dlpProfilePredefinedGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type DLPProfilePredefinedGetResponseEnvelopeSuccess bool + +const ( + DLPProfilePredefinedGetResponseEnvelopeSuccessTrue DLPProfilePredefinedGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/dlpprofilepredefined_test.go b/zero_trust/dlpprofilepredefined_test.go new file mode 100644 index 00000000000..f24fe6e0b68 --- /dev/null +++ b/zero_trust/dlpprofilepredefined_test.go @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestDLPProfilePredefinedUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.DLP.Profiles.Predefineds.Update( + context.TODO(), + "384e129d-25bd-403c-8019-bc19eb7a8a5f", + zero_trust.DLPProfilePredefinedUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + AllowedMatchCount: cloudflare.F(5.000000), + ContextAwareness: cloudflare.F(zero_trust.DLPProfilePredefinedUpdateParamsContextAwareness{ + Enabled: cloudflare.F(true), + Skip: cloudflare.F(zero_trust.DLPProfilePredefinedUpdateParamsContextAwarenessSkip{ + Files: cloudflare.F(true), + }), + }), + Entries: cloudflare.F([]zero_trust.DLPProfilePredefinedUpdateParamsEntry{{ + Enabled: cloudflare.F(true), + }, { + Enabled: cloudflare.F(true), + }, { + Enabled: cloudflare.F(true), + }}), + }, + ) + 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 TestDLPProfilePredefinedGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.DLP.Profiles.Predefineds.Get( + context.TODO(), + "384e129d-25bd-403c-8019-bc19eb7a8a5f", + zero_trust.DLPProfilePredefinedGetParams{ + AccountID: cloudflare.F("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/zero_trust/gateway.go b/zero_trust/gateway.go new file mode 100644 index 00000000000..38a34d3bb79 --- /dev/null +++ b/zero_trust/gateway.go @@ -0,0 +1,301 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// GatewayService 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 [NewGatewayService] method instead. +type GatewayService struct { + Options []option.RequestOption + AuditSSHSettings *GatewayAuditSSHSettingService + Categories *GatewayCategoryService + AppTypes *GatewayAppTypeService + Configurations *GatewayConfigurationService + Lists *GatewayListService + Locations *GatewayLocationService + Loggings *GatewayLoggingService + ProxyEndpoints *GatewayProxyEndpointService + Rules *GatewayRuleService +} + +// NewGatewayService 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 NewGatewayService(opts ...option.RequestOption) (r *GatewayService) { + r = &GatewayService{} + r.Options = opts + r.AuditSSHSettings = NewGatewayAuditSSHSettingService(opts...) + r.Categories = NewGatewayCategoryService(opts...) + r.AppTypes = NewGatewayAppTypeService(opts...) + r.Configurations = NewGatewayConfigurationService(opts...) + r.Lists = NewGatewayListService(opts...) + r.Locations = NewGatewayLocationService(opts...) + r.Loggings = NewGatewayLoggingService(opts...) + r.ProxyEndpoints = NewGatewayProxyEndpointService(opts...) + r.Rules = NewGatewayRuleService(opts...) + return +} + +// Creates a Zero Trust account with an existing Cloudflare account. +func (r *GatewayService) New(ctx context.Context, body GatewayNewParams, opts ...option.RequestOption) (res *GatewayNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env GatewayNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway", body.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets information about the current Zero Trust account. +func (r *GatewayService) List(ctx context.Context, query GatewayListParams, opts ...option.RequestOption) (res *GatewayListResponse, err error) { + opts = append(r.Options[:], opts...) + var env GatewayListResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type GatewayNewResponse struct { + // Cloudflare account ID. + ID string `json:"id"` + // Gateway internal ID. + GatewayTag string `json:"gateway_tag"` + // The name of the provider. Usually Cloudflare. + ProviderName string `json:"provider_name"` + JSON gatewayNewResponseJSON `json:"-"` +} + +// gatewayNewResponseJSON contains the JSON metadata for the struct +// [GatewayNewResponse] +type gatewayNewResponseJSON struct { + ID apijson.Field + GatewayTag apijson.Field + ProviderName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayNewResponseJSON) RawJSON() string { + return r.raw +} + +type GatewayListResponse struct { + // Cloudflare account ID. + ID string `json:"id"` + // Gateway internal ID. + GatewayTag string `json:"gateway_tag"` + // The name of the provider. Usually Cloudflare. + ProviderName string `json:"provider_name"` + JSON gatewayListResponseJSON `json:"-"` +} + +// gatewayListResponseJSON contains the JSON metadata for the struct +// [GatewayListResponse] +type gatewayListResponseJSON struct { + ID apijson.Field + GatewayTag apijson.Field + ProviderName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListResponseJSON) RawJSON() string { + return r.raw +} + +type GatewayNewParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type GatewayNewResponseEnvelope struct { + Errors []GatewayNewResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayNewResponseEnvelopeMessages `json:"messages,required"` + Result GatewayNewResponse `json:"result,required"` + // Whether the API call was successful + Success GatewayNewResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayNewResponseEnvelopeJSON `json:"-"` +} + +// gatewayNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayNewResponseEnvelope] +type gatewayNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [GatewayNewResponseEnvelopeErrors] +type gatewayNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [GatewayNewResponseEnvelopeMessages] +type gatewayNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayNewResponseEnvelopeSuccess bool + +const ( + GatewayNewResponseEnvelopeSuccessTrue GatewayNewResponseEnvelopeSuccess = true +) + +type GatewayListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type GatewayListResponseEnvelope struct { + Errors []GatewayListResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayListResponseEnvelopeMessages `json:"messages,required"` + Result GatewayListResponse `json:"result,required"` + // Whether the API call was successful + Success GatewayListResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayListResponseEnvelopeJSON `json:"-"` +} + +// gatewayListResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayListResponseEnvelope] +type gatewayListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayListResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayListResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [GatewayListResponseEnvelopeErrors] +type gatewayListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayListResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [GatewayListResponseEnvelopeMessages] +type gatewayListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayListResponseEnvelopeSuccess bool + +const ( + GatewayListResponseEnvelopeSuccessTrue GatewayListResponseEnvelopeSuccess = true +) diff --git a/zero_trust/gateway_test.go b/zero_trust/gateway_test.go new file mode 100644 index 00000000000..5e52b401dad --- /dev/null +++ b/zero_trust/gateway_test.go @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestGatewayNew(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.New(context.TODO(), zero_trust.GatewayNewParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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 TestGatewayList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.List(context.TODO(), zero_trust.GatewayListParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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/zero_trust/gatewayapptype.go b/zero_trust/gatewayapptype.go new file mode 100644 index 00000000000..d058159a7e8 --- /dev/null +++ b/zero_trust/gatewayapptype.go @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// GatewayAppTypeService 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 [NewGatewayAppTypeService] method +// instead. +type GatewayAppTypeService struct { + Options []option.RequestOption +} + +// NewGatewayAppTypeService 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 NewGatewayAppTypeService(opts ...option.RequestOption) (r *GatewayAppTypeService) { + r = &GatewayAppTypeService{} + r.Options = opts + return +} + +// Fetches all application and application type mappings. +func (r *GatewayAppTypeService) List(ctx context.Context, query GatewayAppTypeListParams, opts ...option.RequestOption) (res *[]ZeroTrustGatewayAppTypes, err error) { + opts = append(r.Options[:], opts...) + var env GatewayAppTypeListResponseEnvelope + path := fmt.Sprintf("accounts/%s/gateway/app_types", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by +// [zero_trust.ZeroTrustGatewayAppTypesZeroTrustGatewayApplication] or +// [zero_trust.ZeroTrustGatewayAppTypesZeroTrustGatewayApplicationType]. +type ZeroTrustGatewayAppTypes interface { + implementsZeroTrustZeroTrustGatewayAppTypes() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*ZeroTrustGatewayAppTypes)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZeroTrustGatewayAppTypesZeroTrustGatewayApplication{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZeroTrustGatewayAppTypesZeroTrustGatewayApplicationType{}), + }, + ) +} + +type ZeroTrustGatewayAppTypesZeroTrustGatewayApplication struct { + // The identifier for this application. There is only one application per ID. + ID int64 `json:"id"` + // The identifier for the type of this application. There can be many applications + // with the same type. This refers to the `id` of a returned application type. + ApplicationTypeID int64 `json:"application_type_id"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The name of the application or application type. + Name string `json:"name"` + JSON zeroTrustGatewayAppTypesZeroTrustGatewayApplicationJSON `json:"-"` +} + +// zeroTrustGatewayAppTypesZeroTrustGatewayApplicationJSON contains the JSON +// metadata for the struct [ZeroTrustGatewayAppTypesZeroTrustGatewayApplication] +type zeroTrustGatewayAppTypesZeroTrustGatewayApplicationJSON struct { + ID apijson.Field + ApplicationTypeID apijson.Field + CreatedAt apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayAppTypesZeroTrustGatewayApplication) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayAppTypesZeroTrustGatewayApplicationJSON) RawJSON() string { + return r.raw +} + +func (r ZeroTrustGatewayAppTypesZeroTrustGatewayApplication) implementsZeroTrustZeroTrustGatewayAppTypes() { +} + +type ZeroTrustGatewayAppTypesZeroTrustGatewayApplicationType struct { + // The identifier for the type of this application. There can be many applications + // with the same type. This refers to the `id` of a returned application type. + ID int64 `json:"id"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // A short summary of applications with this type. + Description string `json:"description"` + // The name of the application or application type. + Name string `json:"name"` + JSON zeroTrustGatewayAppTypesZeroTrustGatewayApplicationTypeJSON `json:"-"` +} + +// zeroTrustGatewayAppTypesZeroTrustGatewayApplicationTypeJSON contains the JSON +// metadata for the struct +// [ZeroTrustGatewayAppTypesZeroTrustGatewayApplicationType] +type zeroTrustGatewayAppTypesZeroTrustGatewayApplicationTypeJSON struct { + ID apijson.Field + CreatedAt apijson.Field + Description apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayAppTypesZeroTrustGatewayApplicationType) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayAppTypesZeroTrustGatewayApplicationTypeJSON) RawJSON() string { + return r.raw +} + +func (r ZeroTrustGatewayAppTypesZeroTrustGatewayApplicationType) implementsZeroTrustZeroTrustGatewayAppTypes() { +} + +type GatewayAppTypeListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type GatewayAppTypeListResponseEnvelope struct { + Errors []GatewayAppTypeListResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayAppTypeListResponseEnvelopeMessages `json:"messages,required"` + Result []ZeroTrustGatewayAppTypes `json:"result,required,nullable"` + // Whether the API call was successful + Success GatewayAppTypeListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo GatewayAppTypeListResponseEnvelopeResultInfo `json:"result_info"` + JSON gatewayAppTypeListResponseEnvelopeJSON `json:"-"` +} + +// gatewayAppTypeListResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayAppTypeListResponseEnvelope] +type gatewayAppTypeListResponseEnvelopeJSON 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 *GatewayAppTypeListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayAppTypeListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayAppTypeListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayAppTypeListResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayAppTypeListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GatewayAppTypeListResponseEnvelopeErrors] +type gatewayAppTypeListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayAppTypeListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayAppTypeListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayAppTypeListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayAppTypeListResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayAppTypeListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [GatewayAppTypeListResponseEnvelopeMessages] +type gatewayAppTypeListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayAppTypeListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayAppTypeListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayAppTypeListResponseEnvelopeSuccess bool + +const ( + GatewayAppTypeListResponseEnvelopeSuccessTrue GatewayAppTypeListResponseEnvelopeSuccess = true +) + +type GatewayAppTypeListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON gatewayAppTypeListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// gatewayAppTypeListResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [GatewayAppTypeListResponseEnvelopeResultInfo] +type gatewayAppTypeListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayAppTypeListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayAppTypeListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/gatewayapptype_test.go b/zero_trust/gatewayapptype_test.go new file mode 100644 index 00000000000..f38bf433dc5 --- /dev/null +++ b/zero_trust/gatewayapptype_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestGatewayAppTypeList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.AppTypes.List(context.TODO(), zero_trust.GatewayAppTypeListParams{ + AccountID: cloudflare.F("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/zero_trust/gatewayauditsshsetting.go b/zero_trust/gatewayauditsshsetting.go new file mode 100644 index 00000000000..d779ebebc40 --- /dev/null +++ b/zero_trust/gatewayauditsshsetting.go @@ -0,0 +1,266 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// GatewayAuditSSHSettingService 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 [NewGatewayAuditSSHSettingService] +// method instead. +type GatewayAuditSSHSettingService struct { + Options []option.RequestOption +} + +// NewGatewayAuditSSHSettingService 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 NewGatewayAuditSSHSettingService(opts ...option.RequestOption) (r *GatewayAuditSSHSettingService) { + r = &GatewayAuditSSHSettingService{} + r.Options = opts + return +} + +// Updates Zero Trust Audit SSH settings. +func (r *GatewayAuditSSHSettingService) Update(ctx context.Context, params GatewayAuditSSHSettingUpdateParams, opts ...option.RequestOption) (res *ZeroTrustGatewaySettings, err error) { + opts = append(r.Options[:], opts...) + var env GatewayAuditSSHSettingUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/audit_ssh_settings", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get all Zero Trust Audit SSH settings for an account. +func (r *GatewayAuditSSHSettingService) Get(ctx context.Context, query GatewayAuditSSHSettingGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewaySettings, err error) { + opts = append(r.Options[:], opts...) + var env GatewayAuditSSHSettingGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/audit_ssh_settings", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ZeroTrustGatewaySettings struct { + CreatedAt time.Time `json:"created_at" format:"date-time"` + // SSH encryption public key + PublicKey string `json:"public_key"` + // Seed ID + SeedID string `json:"seed_id"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON zeroTrustGatewaySettingsJSON `json:"-"` +} + +// zeroTrustGatewaySettingsJSON contains the JSON metadata for the struct +// [ZeroTrustGatewaySettings] +type zeroTrustGatewaySettingsJSON struct { + CreatedAt apijson.Field + PublicKey apijson.Field + SeedID apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewaySettings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewaySettingsJSON) RawJSON() string { + return r.raw +} + +type GatewayAuditSSHSettingUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // SSH encryption public key + PublicKey param.Field[string] `json:"public_key,required"` + // Seed ID + SeedID param.Field[string] `json:"seed_id"` +} + +func (r GatewayAuditSSHSettingUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayAuditSSHSettingUpdateResponseEnvelope struct { + Errors []GatewayAuditSSHSettingUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayAuditSSHSettingUpdateResponseEnvelopeMessages `json:"messages,required"` + Result ZeroTrustGatewaySettings `json:"result,required"` + // Whether the API call was successful + Success GatewayAuditSSHSettingUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayAuditSSHSettingUpdateResponseEnvelopeJSON `json:"-"` +} + +// gatewayAuditSSHSettingUpdateResponseEnvelopeJSON contains the JSON metadata for +// the struct [GatewayAuditSSHSettingUpdateResponseEnvelope] +type gatewayAuditSSHSettingUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayAuditSSHSettingUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayAuditSSHSettingUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayAuditSSHSettingUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayAuditSSHSettingUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayAuditSSHSettingUpdateResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [GatewayAuditSSHSettingUpdateResponseEnvelopeErrors] +type gatewayAuditSSHSettingUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayAuditSSHSettingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayAuditSSHSettingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayAuditSSHSettingUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayAuditSSHSettingUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayAuditSSHSettingUpdateResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [GatewayAuditSSHSettingUpdateResponseEnvelopeMessages] +type gatewayAuditSSHSettingUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayAuditSSHSettingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayAuditSSHSettingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayAuditSSHSettingUpdateResponseEnvelopeSuccess bool + +const ( + GatewayAuditSSHSettingUpdateResponseEnvelopeSuccessTrue GatewayAuditSSHSettingUpdateResponseEnvelopeSuccess = true +) + +type GatewayAuditSSHSettingGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type GatewayAuditSSHSettingGetResponseEnvelope struct { + Errors []GatewayAuditSSHSettingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayAuditSSHSettingGetResponseEnvelopeMessages `json:"messages,required"` + Result ZeroTrustGatewaySettings `json:"result,required"` + // Whether the API call was successful + Success GatewayAuditSSHSettingGetResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayAuditSSHSettingGetResponseEnvelopeJSON `json:"-"` +} + +// gatewayAuditSSHSettingGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [GatewayAuditSSHSettingGetResponseEnvelope] +type gatewayAuditSSHSettingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayAuditSSHSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayAuditSSHSettingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayAuditSSHSettingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayAuditSSHSettingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayAuditSSHSettingGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [GatewayAuditSSHSettingGetResponseEnvelopeErrors] +type gatewayAuditSSHSettingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayAuditSSHSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayAuditSSHSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayAuditSSHSettingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayAuditSSHSettingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayAuditSSHSettingGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [GatewayAuditSSHSettingGetResponseEnvelopeMessages] +type gatewayAuditSSHSettingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayAuditSSHSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayAuditSSHSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayAuditSSHSettingGetResponseEnvelopeSuccess bool + +const ( + GatewayAuditSSHSettingGetResponseEnvelopeSuccessTrue GatewayAuditSSHSettingGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/gatewayauditsshsetting_test.go b/zero_trust/gatewayauditsshsetting_test.go new file mode 100644 index 00000000000..8b82a72308e --- /dev/null +++ b/zero_trust/gatewayauditsshsetting_test.go @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestGatewayAuditSSHSettingUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.AuditSSHSettings.Update(context.TODO(), zero_trust.GatewayAuditSSHSettingUpdateParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + PublicKey: cloudflare.F("1pyl6I1tL7xfJuFYVzXlUW8uXXlpxegHXBzGCBKaSFA="), + SeedID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), + }) + 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 TestGatewayAuditSSHSettingGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.AuditSSHSettings.Get(context.TODO(), zero_trust.GatewayAuditSSHSettingGetParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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/zero_trust/gatewaycategory.go b/zero_trust/gatewaycategory.go new file mode 100644 index 00000000000..7f85526a1f7 --- /dev/null +++ b/zero_trust/gatewaycategory.go @@ -0,0 +1,269 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// GatewayCategoryService 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 [NewGatewayCategoryService] method +// instead. +type GatewayCategoryService struct { + Options []option.RequestOption +} + +// NewGatewayCategoryService 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 NewGatewayCategoryService(opts ...option.RequestOption) (r *GatewayCategoryService) { + r = &GatewayCategoryService{} + r.Options = opts + return +} + +// Fetches a list of all categories. +func (r *GatewayCategoryService) List(ctx context.Context, query GatewayCategoryListParams, opts ...option.RequestOption) (res *[]ZeroTrustGatewayCategories, err error) { + opts = append(r.Options[:], opts...) + var env GatewayCategoryListResponseEnvelope + path := fmt.Sprintf("accounts/%s/gateway/categories", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ZeroTrustGatewayCategories struct { + // The identifier for this category. There is only one category per ID. + ID int64 `json:"id"` + // True if the category is in beta and subject to change. + Beta bool `json:"beta"` + // Which account types are allowed to create policies based on this category. + // `blocked` categories are blocked unconditionally for all accounts. + // `removalPending` categories can be removed from policies but not added. + // `noBlock` categories cannot be blocked. + Class ZeroTrustGatewayCategoriesClass `json:"class"` + // A short summary of domains in the category. + Description string `json:"description"` + // The name of the category. + Name string `json:"name"` + // All subcategories for this category. + Subcategories []ZeroTrustGatewayCategoriesSubcategory `json:"subcategories"` + JSON zeroTrustGatewayCategoriesJSON `json:"-"` +} + +// zeroTrustGatewayCategoriesJSON contains the JSON metadata for the struct +// [ZeroTrustGatewayCategories] +type zeroTrustGatewayCategoriesJSON struct { + ID apijson.Field + Beta apijson.Field + Class apijson.Field + Description apijson.Field + Name apijson.Field + Subcategories apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayCategories) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayCategoriesJSON) RawJSON() string { + return r.raw +} + +// Which account types are allowed to create policies based on this category. +// `blocked` categories are blocked unconditionally for all accounts. +// `removalPending` categories can be removed from policies but not added. +// `noBlock` categories cannot be blocked. +type ZeroTrustGatewayCategoriesClass string + +const ( + ZeroTrustGatewayCategoriesClassFree ZeroTrustGatewayCategoriesClass = "free" + ZeroTrustGatewayCategoriesClassPremium ZeroTrustGatewayCategoriesClass = "premium" + ZeroTrustGatewayCategoriesClassBlocked ZeroTrustGatewayCategoriesClass = "blocked" + ZeroTrustGatewayCategoriesClassRemovalPending ZeroTrustGatewayCategoriesClass = "removalPending" + ZeroTrustGatewayCategoriesClassNoBlock ZeroTrustGatewayCategoriesClass = "noBlock" +) + +type ZeroTrustGatewayCategoriesSubcategory struct { + // The identifier for this category. There is only one category per ID. + ID int64 `json:"id"` + // True if the category is in beta and subject to change. + Beta bool `json:"beta"` + // Which account types are allowed to create policies based on this category. + // `blocked` categories are blocked unconditionally for all accounts. + // `removalPending` categories can be removed from policies but not added. + // `noBlock` categories cannot be blocked. + Class ZeroTrustGatewayCategoriesSubcategoriesClass `json:"class"` + // A short summary of domains in the category. + Description string `json:"description"` + // The name of the category. + Name string `json:"name"` + JSON zeroTrustGatewayCategoriesSubcategoryJSON `json:"-"` +} + +// zeroTrustGatewayCategoriesSubcategoryJSON contains the JSON metadata for the +// struct [ZeroTrustGatewayCategoriesSubcategory] +type zeroTrustGatewayCategoriesSubcategoryJSON struct { + ID apijson.Field + Beta apijson.Field + Class apijson.Field + Description apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayCategoriesSubcategory) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayCategoriesSubcategoryJSON) RawJSON() string { + return r.raw +} + +// Which account types are allowed to create policies based on this category. +// `blocked` categories are blocked unconditionally for all accounts. +// `removalPending` categories can be removed from policies but not added. +// `noBlock` categories cannot be blocked. +type ZeroTrustGatewayCategoriesSubcategoriesClass string + +const ( + ZeroTrustGatewayCategoriesSubcategoriesClassFree ZeroTrustGatewayCategoriesSubcategoriesClass = "free" + ZeroTrustGatewayCategoriesSubcategoriesClassPremium ZeroTrustGatewayCategoriesSubcategoriesClass = "premium" + ZeroTrustGatewayCategoriesSubcategoriesClassBlocked ZeroTrustGatewayCategoriesSubcategoriesClass = "blocked" + ZeroTrustGatewayCategoriesSubcategoriesClassRemovalPending ZeroTrustGatewayCategoriesSubcategoriesClass = "removalPending" + ZeroTrustGatewayCategoriesSubcategoriesClassNoBlock ZeroTrustGatewayCategoriesSubcategoriesClass = "noBlock" +) + +type GatewayCategoryListParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type GatewayCategoryListResponseEnvelope struct { + Errors []GatewayCategoryListResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayCategoryListResponseEnvelopeMessages `json:"messages,required"` + Result []ZeroTrustGatewayCategories `json:"result,required,nullable"` + // Whether the API call was successful + Success GatewayCategoryListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo GatewayCategoryListResponseEnvelopeResultInfo `json:"result_info"` + JSON gatewayCategoryListResponseEnvelopeJSON `json:"-"` +} + +// gatewayCategoryListResponseEnvelopeJSON contains the JSON metadata for the +// struct [GatewayCategoryListResponseEnvelope] +type gatewayCategoryListResponseEnvelopeJSON 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 *GatewayCategoryListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayCategoryListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayCategoryListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayCategoryListResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayCategoryListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GatewayCategoryListResponseEnvelopeErrors] +type gatewayCategoryListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayCategoryListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayCategoryListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayCategoryListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayCategoryListResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayCategoryListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [GatewayCategoryListResponseEnvelopeMessages] +type gatewayCategoryListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayCategoryListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayCategoryListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayCategoryListResponseEnvelopeSuccess bool + +const ( + GatewayCategoryListResponseEnvelopeSuccessTrue GatewayCategoryListResponseEnvelopeSuccess = true +) + +type GatewayCategoryListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON gatewayCategoryListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// gatewayCategoryListResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [GatewayCategoryListResponseEnvelopeResultInfo] +type gatewayCategoryListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayCategoryListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayCategoryListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/gatewaycategory_test.go b/zero_trust/gatewaycategory_test.go new file mode 100644 index 00000000000..c3a978493dd --- /dev/null +++ b/zero_trust/gatewaycategory_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestGatewayCategoryList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Categories.List(context.TODO(), zero_trust.GatewayCategoryListParams{ + AccountID: cloudflare.F("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/zero_trust/gatewayconfiguration.go b/zero_trust/gatewayconfiguration.go new file mode 100644 index 00000000000..ba07396e04e --- /dev/null +++ b/zero_trust/gatewayconfiguration.go @@ -0,0 +1,1857 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// GatewayConfigurationService 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 [NewGatewayConfigurationService] +// method instead. +type GatewayConfigurationService struct { + Options []option.RequestOption +} + +// NewGatewayConfigurationService 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 NewGatewayConfigurationService(opts ...option.RequestOption) (r *GatewayConfigurationService) { + r = &GatewayConfigurationService{} + r.Options = opts + return +} + +// Updates the current Zero Trust account configuration. +func (r *GatewayConfigurationService) Update(ctx context.Context, params GatewayConfigurationUpdateParams, opts ...option.RequestOption) (res *GatewayConfigurationUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env GatewayConfigurationUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/configuration", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Patches the current Zero Trust account configuration. This endpoint can update a +// single subcollection of settings such as `antivirus`, `tls_decrypt`, +// `activity_log`, `block_page`, `browser_isolation`, `fips`, `body_scanning`, or +// `custom_certificate`, without updating the entire configuration object. Returns +// an error if any collection of settings is not properly configured. +func (r *GatewayConfigurationService) Edit(ctx context.Context, params GatewayConfigurationEditParams, opts ...option.RequestOption) (res *GatewayConfigurationEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env GatewayConfigurationEditResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/configuration", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the current Zero Trust account configuration. +func (r *GatewayConfigurationService) Get(ctx context.Context, query GatewayConfigurationGetParams, opts ...option.RequestOption) (res *GatewayConfigurationGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env GatewayConfigurationGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/configuration", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// account settings. +type GatewayConfigurationUpdateResponse struct { + CreatedAt time.Time `json:"created_at" format:"date-time"` + // account settings. + Settings GatewayConfigurationUpdateResponseSettings `json:"settings"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON gatewayConfigurationUpdateResponseJSON `json:"-"` +} + +// gatewayConfigurationUpdateResponseJSON contains the JSON metadata for the struct +// [GatewayConfigurationUpdateResponse] +type gatewayConfigurationUpdateResponseJSON struct { + CreatedAt apijson.Field + Settings apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationUpdateResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationUpdateResponseJSON) RawJSON() string { + return r.raw +} + +// account settings. +type GatewayConfigurationUpdateResponseSettings struct { + // Activity log settings. + ActivityLog GatewayConfigurationUpdateResponseSettingsActivityLog `json:"activity_log"` + // Anti-virus settings. + Antivirus GatewayConfigurationUpdateResponseSettingsAntivirus `json:"antivirus"` + // Block page layout settings. + BlockPage GatewayConfigurationUpdateResponseSettingsBlockPage `json:"block_page"` + // DLP body scanning settings. + BodyScanning GatewayConfigurationUpdateResponseSettingsBodyScanning `json:"body_scanning"` + // Browser isolation settings. + BrowserIsolation GatewayConfigurationUpdateResponseSettingsBrowserIsolation `json:"browser_isolation"` + // Custom certificate settings for BYO-PKI. + CustomCertificate GatewayConfigurationUpdateResponseSettingsCustomCertificate `json:"custom_certificate"` + // Extended e-mail matching settings. + ExtendedEmailMatching GatewayConfigurationUpdateResponseSettingsExtendedEmailMatching `json:"extended_email_matching"` + // FIPS settings. + Fips GatewayConfigurationUpdateResponseSettingsFips `json:"fips"` + // Protocol Detection settings. + ProtocolDetection GatewayConfigurationUpdateResponseSettingsProtocolDetection `json:"protocol_detection"` + // TLS interception settings. + TLSDecrypt GatewayConfigurationUpdateResponseSettingsTLSDecrypt `json:"tls_decrypt"` + JSON gatewayConfigurationUpdateResponseSettingsJSON `json:"-"` +} + +// gatewayConfigurationUpdateResponseSettingsJSON contains the JSON metadata for +// the struct [GatewayConfigurationUpdateResponseSettings] +type gatewayConfigurationUpdateResponseSettingsJSON struct { + ActivityLog apijson.Field + Antivirus apijson.Field + BlockPage apijson.Field + BodyScanning apijson.Field + BrowserIsolation apijson.Field + CustomCertificate apijson.Field + ExtendedEmailMatching apijson.Field + Fips apijson.Field + ProtocolDetection apijson.Field + TLSDecrypt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationUpdateResponseSettings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationUpdateResponseSettingsJSON) RawJSON() string { + return r.raw +} + +// Activity log settings. +type GatewayConfigurationUpdateResponseSettingsActivityLog struct { + // Enable activity logging. + Enabled bool `json:"enabled"` + JSON gatewayConfigurationUpdateResponseSettingsActivityLogJSON `json:"-"` +} + +// gatewayConfigurationUpdateResponseSettingsActivityLogJSON contains the JSON +// metadata for the struct [GatewayConfigurationUpdateResponseSettingsActivityLog] +type gatewayConfigurationUpdateResponseSettingsActivityLogJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationUpdateResponseSettingsActivityLog) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationUpdateResponseSettingsActivityLogJSON) RawJSON() string { + return r.raw +} + +// Anti-virus settings. +type GatewayConfigurationUpdateResponseSettingsAntivirus struct { + // Enable anti-virus scanning on downloads. + EnabledDownloadPhase bool `json:"enabled_download_phase"` + // Enable anti-virus scanning on uploads. + EnabledUploadPhase bool `json:"enabled_upload_phase"` + // Block requests for files that cannot be scanned. + FailClosed bool `json:"fail_closed"` + // Configure a message to display on the user's device when an antivirus search is + // performed. + NotificationSettings GatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettings `json:"notification_settings"` + JSON gatewayConfigurationUpdateResponseSettingsAntivirusJSON `json:"-"` +} + +// gatewayConfigurationUpdateResponseSettingsAntivirusJSON contains the JSON +// metadata for the struct [GatewayConfigurationUpdateResponseSettingsAntivirus] +type gatewayConfigurationUpdateResponseSettingsAntivirusJSON struct { + EnabledDownloadPhase apijson.Field + EnabledUploadPhase apijson.Field + FailClosed apijson.Field + NotificationSettings apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationUpdateResponseSettingsAntivirus) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationUpdateResponseSettingsAntivirusJSON) RawJSON() string { + return r.raw +} + +// Configure a message to display on the user's device when an antivirus search is +// performed. +type GatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettings struct { + // Set notification on + Enabled bool `json:"enabled"` + // Customize the message shown in the notification. + Msg string `json:"msg"` + // Optional URL to direct users to additional information. If not set, the + // notification will open a block page. + SupportURL string `json:"support_url"` + JSON gatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettingsJSON `json:"-"` +} + +// gatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettingsJSON +// contains the JSON metadata for the struct +// [GatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettings] +type gatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettingsJSON struct { + Enabled apijson.Field + Msg apijson.Field + SupportURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettingsJSON) RawJSON() string { + return r.raw +} + +// Block page layout settings. +type GatewayConfigurationUpdateResponseSettingsBlockPage struct { + // Block page background color in #rrggbb format. + BackgroundColor string `json:"background_color"` + // Enable only cipher suites and TLS versions compliant with FIPS 140-2. + Enabled bool `json:"enabled"` + // Block page footer text. + FooterText string `json:"footer_text"` + // Block page header text. + HeaderText string `json:"header_text"` + // Full URL to the logo file. + LogoPath string `json:"logo_path"` + // Admin email for users to contact. + MailtoAddress string `json:"mailto_address"` + // Subject line for emails created from block page. + MailtoSubject string `json:"mailto_subject"` + // Block page title. + Name string `json:"name"` + // Suppress detailed info at the bottom of the block page. + SuppressFooter bool `json:"suppress_footer"` + JSON gatewayConfigurationUpdateResponseSettingsBlockPageJSON `json:"-"` +} + +// gatewayConfigurationUpdateResponseSettingsBlockPageJSON contains the JSON +// metadata for the struct [GatewayConfigurationUpdateResponseSettingsBlockPage] +type gatewayConfigurationUpdateResponseSettingsBlockPageJSON struct { + BackgroundColor apijson.Field + Enabled apijson.Field + FooterText apijson.Field + HeaderText apijson.Field + LogoPath apijson.Field + MailtoAddress apijson.Field + MailtoSubject apijson.Field + Name apijson.Field + SuppressFooter apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationUpdateResponseSettingsBlockPage) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationUpdateResponseSettingsBlockPageJSON) RawJSON() string { + return r.raw +} + +// DLP body scanning settings. +type GatewayConfigurationUpdateResponseSettingsBodyScanning struct { + // Set the inspection mode to either `deep` or `shallow`. + InspectionMode string `json:"inspection_mode"` + JSON gatewayConfigurationUpdateResponseSettingsBodyScanningJSON `json:"-"` +} + +// gatewayConfigurationUpdateResponseSettingsBodyScanningJSON contains the JSON +// metadata for the struct [GatewayConfigurationUpdateResponseSettingsBodyScanning] +type gatewayConfigurationUpdateResponseSettingsBodyScanningJSON struct { + InspectionMode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationUpdateResponseSettingsBodyScanning) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationUpdateResponseSettingsBodyScanningJSON) RawJSON() string { + return r.raw +} + +// Browser isolation settings. +type GatewayConfigurationUpdateResponseSettingsBrowserIsolation struct { + // Enable non-identity onramp support for Browser Isolation. + NonIdentityEnabled bool `json:"non_identity_enabled"` + // Enable Clientless Browser Isolation. + URLBrowserIsolationEnabled bool `json:"url_browser_isolation_enabled"` + JSON gatewayConfigurationUpdateResponseSettingsBrowserIsolationJSON `json:"-"` +} + +// gatewayConfigurationUpdateResponseSettingsBrowserIsolationJSON contains the JSON +// metadata for the struct +// [GatewayConfigurationUpdateResponseSettingsBrowserIsolation] +type gatewayConfigurationUpdateResponseSettingsBrowserIsolationJSON struct { + NonIdentityEnabled apijson.Field + URLBrowserIsolationEnabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationUpdateResponseSettingsBrowserIsolation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationUpdateResponseSettingsBrowserIsolationJSON) RawJSON() string { + return r.raw +} + +// Custom certificate settings for BYO-PKI. +type GatewayConfigurationUpdateResponseSettingsCustomCertificate struct { + // Enable use of custom certificate authority for signing Gateway traffic. + Enabled bool `json:"enabled,required"` + // UUID of certificate (ID from MTLS certificate store). + ID string `json:"id"` + // Certificate status (internal). + BindingStatus string `json:"binding_status"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON gatewayConfigurationUpdateResponseSettingsCustomCertificateJSON `json:"-"` +} + +// gatewayConfigurationUpdateResponseSettingsCustomCertificateJSON contains the +// JSON metadata for the struct +// [GatewayConfigurationUpdateResponseSettingsCustomCertificate] +type gatewayConfigurationUpdateResponseSettingsCustomCertificateJSON struct { + Enabled apijson.Field + ID apijson.Field + BindingStatus apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationUpdateResponseSettingsCustomCertificate) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationUpdateResponseSettingsCustomCertificateJSON) RawJSON() string { + return r.raw +} + +// Extended e-mail matching settings. +type GatewayConfigurationUpdateResponseSettingsExtendedEmailMatching struct { + // Enable matching all variants of user emails (with + or . modifiers) used as + // criteria in Firewall policies. + Enabled bool `json:"enabled"` + JSON gatewayConfigurationUpdateResponseSettingsExtendedEmailMatchingJSON `json:"-"` +} + +// gatewayConfigurationUpdateResponseSettingsExtendedEmailMatchingJSON contains the +// JSON metadata for the struct +// [GatewayConfigurationUpdateResponseSettingsExtendedEmailMatching] +type gatewayConfigurationUpdateResponseSettingsExtendedEmailMatchingJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationUpdateResponseSettingsExtendedEmailMatching) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationUpdateResponseSettingsExtendedEmailMatchingJSON) RawJSON() string { + return r.raw +} + +// FIPS settings. +type GatewayConfigurationUpdateResponseSettingsFips struct { + // Enable only cipher suites and TLS versions compliant with FIPS 140-2. + TLS bool `json:"tls"` + JSON gatewayConfigurationUpdateResponseSettingsFipsJSON `json:"-"` +} + +// gatewayConfigurationUpdateResponseSettingsFipsJSON contains the JSON metadata +// for the struct [GatewayConfigurationUpdateResponseSettingsFips] +type gatewayConfigurationUpdateResponseSettingsFipsJSON struct { + TLS apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationUpdateResponseSettingsFips) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationUpdateResponseSettingsFipsJSON) RawJSON() string { + return r.raw +} + +// Protocol Detection settings. +type GatewayConfigurationUpdateResponseSettingsProtocolDetection struct { + // Enable detecting protocol on initial bytes of client traffic. + Enabled bool `json:"enabled"` + JSON gatewayConfigurationUpdateResponseSettingsProtocolDetectionJSON `json:"-"` +} + +// gatewayConfigurationUpdateResponseSettingsProtocolDetectionJSON contains the +// JSON metadata for the struct +// [GatewayConfigurationUpdateResponseSettingsProtocolDetection] +type gatewayConfigurationUpdateResponseSettingsProtocolDetectionJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationUpdateResponseSettingsProtocolDetection) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationUpdateResponseSettingsProtocolDetectionJSON) RawJSON() string { + return r.raw +} + +// TLS interception settings. +type GatewayConfigurationUpdateResponseSettingsTLSDecrypt struct { + // Enable inspecting encrypted HTTP traffic. + Enabled bool `json:"enabled"` + JSON gatewayConfigurationUpdateResponseSettingsTLSDecryptJSON `json:"-"` +} + +// gatewayConfigurationUpdateResponseSettingsTLSDecryptJSON contains the JSON +// metadata for the struct [GatewayConfigurationUpdateResponseSettingsTLSDecrypt] +type gatewayConfigurationUpdateResponseSettingsTLSDecryptJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationUpdateResponseSettingsTLSDecrypt) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationUpdateResponseSettingsTLSDecryptJSON) RawJSON() string { + return r.raw +} + +// account settings. +type GatewayConfigurationEditResponse struct { + CreatedAt time.Time `json:"created_at" format:"date-time"` + // account settings. + Settings GatewayConfigurationEditResponseSettings `json:"settings"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON gatewayConfigurationEditResponseJSON `json:"-"` +} + +// gatewayConfigurationEditResponseJSON contains the JSON metadata for the struct +// [GatewayConfigurationEditResponse] +type gatewayConfigurationEditResponseJSON struct { + CreatedAt apijson.Field + Settings apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationEditResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationEditResponseJSON) RawJSON() string { + return r.raw +} + +// account settings. +type GatewayConfigurationEditResponseSettings struct { + // Activity log settings. + ActivityLog GatewayConfigurationEditResponseSettingsActivityLog `json:"activity_log"` + // Anti-virus settings. + Antivirus GatewayConfigurationEditResponseSettingsAntivirus `json:"antivirus"` + // Block page layout settings. + BlockPage GatewayConfigurationEditResponseSettingsBlockPage `json:"block_page"` + // DLP body scanning settings. + BodyScanning GatewayConfigurationEditResponseSettingsBodyScanning `json:"body_scanning"` + // Browser isolation settings. + BrowserIsolation GatewayConfigurationEditResponseSettingsBrowserIsolation `json:"browser_isolation"` + // Custom certificate settings for BYO-PKI. + CustomCertificate GatewayConfigurationEditResponseSettingsCustomCertificate `json:"custom_certificate"` + // Extended e-mail matching settings. + ExtendedEmailMatching GatewayConfigurationEditResponseSettingsExtendedEmailMatching `json:"extended_email_matching"` + // FIPS settings. + Fips GatewayConfigurationEditResponseSettingsFips `json:"fips"` + // Protocol Detection settings. + ProtocolDetection GatewayConfigurationEditResponseSettingsProtocolDetection `json:"protocol_detection"` + // TLS interception settings. + TLSDecrypt GatewayConfigurationEditResponseSettingsTLSDecrypt `json:"tls_decrypt"` + JSON gatewayConfigurationEditResponseSettingsJSON `json:"-"` +} + +// gatewayConfigurationEditResponseSettingsJSON contains the JSON metadata for the +// struct [GatewayConfigurationEditResponseSettings] +type gatewayConfigurationEditResponseSettingsJSON struct { + ActivityLog apijson.Field + Antivirus apijson.Field + BlockPage apijson.Field + BodyScanning apijson.Field + BrowserIsolation apijson.Field + CustomCertificate apijson.Field + ExtendedEmailMatching apijson.Field + Fips apijson.Field + ProtocolDetection apijson.Field + TLSDecrypt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationEditResponseSettings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationEditResponseSettingsJSON) RawJSON() string { + return r.raw +} + +// Activity log settings. +type GatewayConfigurationEditResponseSettingsActivityLog struct { + // Enable activity logging. + Enabled bool `json:"enabled"` + JSON gatewayConfigurationEditResponseSettingsActivityLogJSON `json:"-"` +} + +// gatewayConfigurationEditResponseSettingsActivityLogJSON contains the JSON +// metadata for the struct [GatewayConfigurationEditResponseSettingsActivityLog] +type gatewayConfigurationEditResponseSettingsActivityLogJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationEditResponseSettingsActivityLog) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationEditResponseSettingsActivityLogJSON) RawJSON() string { + return r.raw +} + +// Anti-virus settings. +type GatewayConfigurationEditResponseSettingsAntivirus struct { + // Enable anti-virus scanning on downloads. + EnabledDownloadPhase bool `json:"enabled_download_phase"` + // Enable anti-virus scanning on uploads. + EnabledUploadPhase bool `json:"enabled_upload_phase"` + // Block requests for files that cannot be scanned. + FailClosed bool `json:"fail_closed"` + // Configure a message to display on the user's device when an antivirus search is + // performed. + NotificationSettings GatewayConfigurationEditResponseSettingsAntivirusNotificationSettings `json:"notification_settings"` + JSON gatewayConfigurationEditResponseSettingsAntivirusJSON `json:"-"` +} + +// gatewayConfigurationEditResponseSettingsAntivirusJSON contains the JSON metadata +// for the struct [GatewayConfigurationEditResponseSettingsAntivirus] +type gatewayConfigurationEditResponseSettingsAntivirusJSON struct { + EnabledDownloadPhase apijson.Field + EnabledUploadPhase apijson.Field + FailClosed apijson.Field + NotificationSettings apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationEditResponseSettingsAntivirus) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationEditResponseSettingsAntivirusJSON) RawJSON() string { + return r.raw +} + +// Configure a message to display on the user's device when an antivirus search is +// performed. +type GatewayConfigurationEditResponseSettingsAntivirusNotificationSettings struct { + // Set notification on + Enabled bool `json:"enabled"` + // Customize the message shown in the notification. + Msg string `json:"msg"` + // Optional URL to direct users to additional information. If not set, the + // notification will open a block page. + SupportURL string `json:"support_url"` + JSON gatewayConfigurationEditResponseSettingsAntivirusNotificationSettingsJSON `json:"-"` +} + +// gatewayConfigurationEditResponseSettingsAntivirusNotificationSettingsJSON +// contains the JSON metadata for the struct +// [GatewayConfigurationEditResponseSettingsAntivirusNotificationSettings] +type gatewayConfigurationEditResponseSettingsAntivirusNotificationSettingsJSON struct { + Enabled apijson.Field + Msg apijson.Field + SupportURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationEditResponseSettingsAntivirusNotificationSettings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationEditResponseSettingsAntivirusNotificationSettingsJSON) RawJSON() string { + return r.raw +} + +// Block page layout settings. +type GatewayConfigurationEditResponseSettingsBlockPage struct { + // Block page background color in #rrggbb format. + BackgroundColor string `json:"background_color"` + // Enable only cipher suites and TLS versions compliant with FIPS 140-2. + Enabled bool `json:"enabled"` + // Block page footer text. + FooterText string `json:"footer_text"` + // Block page header text. + HeaderText string `json:"header_text"` + // Full URL to the logo file. + LogoPath string `json:"logo_path"` + // Admin email for users to contact. + MailtoAddress string `json:"mailto_address"` + // Subject line for emails created from block page. + MailtoSubject string `json:"mailto_subject"` + // Block page title. + Name string `json:"name"` + // Suppress detailed info at the bottom of the block page. + SuppressFooter bool `json:"suppress_footer"` + JSON gatewayConfigurationEditResponseSettingsBlockPageJSON `json:"-"` +} + +// gatewayConfigurationEditResponseSettingsBlockPageJSON contains the JSON metadata +// for the struct [GatewayConfigurationEditResponseSettingsBlockPage] +type gatewayConfigurationEditResponseSettingsBlockPageJSON struct { + BackgroundColor apijson.Field + Enabled apijson.Field + FooterText apijson.Field + HeaderText apijson.Field + LogoPath apijson.Field + MailtoAddress apijson.Field + MailtoSubject apijson.Field + Name apijson.Field + SuppressFooter apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationEditResponseSettingsBlockPage) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationEditResponseSettingsBlockPageJSON) RawJSON() string { + return r.raw +} + +// DLP body scanning settings. +type GatewayConfigurationEditResponseSettingsBodyScanning struct { + // Set the inspection mode to either `deep` or `shallow`. + InspectionMode string `json:"inspection_mode"` + JSON gatewayConfigurationEditResponseSettingsBodyScanningJSON `json:"-"` +} + +// gatewayConfigurationEditResponseSettingsBodyScanningJSON contains the JSON +// metadata for the struct [GatewayConfigurationEditResponseSettingsBodyScanning] +type gatewayConfigurationEditResponseSettingsBodyScanningJSON struct { + InspectionMode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationEditResponseSettingsBodyScanning) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationEditResponseSettingsBodyScanningJSON) RawJSON() string { + return r.raw +} + +// Browser isolation settings. +type GatewayConfigurationEditResponseSettingsBrowserIsolation struct { + // Enable non-identity onramp support for Browser Isolation. + NonIdentityEnabled bool `json:"non_identity_enabled"` + // Enable Clientless Browser Isolation. + URLBrowserIsolationEnabled bool `json:"url_browser_isolation_enabled"` + JSON gatewayConfigurationEditResponseSettingsBrowserIsolationJSON `json:"-"` +} + +// gatewayConfigurationEditResponseSettingsBrowserIsolationJSON contains the JSON +// metadata for the struct +// [GatewayConfigurationEditResponseSettingsBrowserIsolation] +type gatewayConfigurationEditResponseSettingsBrowserIsolationJSON struct { + NonIdentityEnabled apijson.Field + URLBrowserIsolationEnabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationEditResponseSettingsBrowserIsolation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationEditResponseSettingsBrowserIsolationJSON) RawJSON() string { + return r.raw +} + +// Custom certificate settings for BYO-PKI. +type GatewayConfigurationEditResponseSettingsCustomCertificate struct { + // Enable use of custom certificate authority for signing Gateway traffic. + Enabled bool `json:"enabled,required"` + // UUID of certificate (ID from MTLS certificate store). + ID string `json:"id"` + // Certificate status (internal). + BindingStatus string `json:"binding_status"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON gatewayConfigurationEditResponseSettingsCustomCertificateJSON `json:"-"` +} + +// gatewayConfigurationEditResponseSettingsCustomCertificateJSON contains the JSON +// metadata for the struct +// [GatewayConfigurationEditResponseSettingsCustomCertificate] +type gatewayConfigurationEditResponseSettingsCustomCertificateJSON struct { + Enabled apijson.Field + ID apijson.Field + BindingStatus apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationEditResponseSettingsCustomCertificate) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationEditResponseSettingsCustomCertificateJSON) RawJSON() string { + return r.raw +} + +// Extended e-mail matching settings. +type GatewayConfigurationEditResponseSettingsExtendedEmailMatching struct { + // Enable matching all variants of user emails (with + or . modifiers) used as + // criteria in Firewall policies. + Enabled bool `json:"enabled"` + JSON gatewayConfigurationEditResponseSettingsExtendedEmailMatchingJSON `json:"-"` +} + +// gatewayConfigurationEditResponseSettingsExtendedEmailMatchingJSON contains the +// JSON metadata for the struct +// [GatewayConfigurationEditResponseSettingsExtendedEmailMatching] +type gatewayConfigurationEditResponseSettingsExtendedEmailMatchingJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationEditResponseSettingsExtendedEmailMatching) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationEditResponseSettingsExtendedEmailMatchingJSON) RawJSON() string { + return r.raw +} + +// FIPS settings. +type GatewayConfigurationEditResponseSettingsFips struct { + // Enable only cipher suites and TLS versions compliant with FIPS 140-2. + TLS bool `json:"tls"` + JSON gatewayConfigurationEditResponseSettingsFipsJSON `json:"-"` +} + +// gatewayConfigurationEditResponseSettingsFipsJSON contains the JSON metadata for +// the struct [GatewayConfigurationEditResponseSettingsFips] +type gatewayConfigurationEditResponseSettingsFipsJSON struct { + TLS apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationEditResponseSettingsFips) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationEditResponseSettingsFipsJSON) RawJSON() string { + return r.raw +} + +// Protocol Detection settings. +type GatewayConfigurationEditResponseSettingsProtocolDetection struct { + // Enable detecting protocol on initial bytes of client traffic. + Enabled bool `json:"enabled"` + JSON gatewayConfigurationEditResponseSettingsProtocolDetectionJSON `json:"-"` +} + +// gatewayConfigurationEditResponseSettingsProtocolDetectionJSON contains the JSON +// metadata for the struct +// [GatewayConfigurationEditResponseSettingsProtocolDetection] +type gatewayConfigurationEditResponseSettingsProtocolDetectionJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationEditResponseSettingsProtocolDetection) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationEditResponseSettingsProtocolDetectionJSON) RawJSON() string { + return r.raw +} + +// TLS interception settings. +type GatewayConfigurationEditResponseSettingsTLSDecrypt struct { + // Enable inspecting encrypted HTTP traffic. + Enabled bool `json:"enabled"` + JSON gatewayConfigurationEditResponseSettingsTLSDecryptJSON `json:"-"` +} + +// gatewayConfigurationEditResponseSettingsTLSDecryptJSON contains the JSON +// metadata for the struct [GatewayConfigurationEditResponseSettingsTLSDecrypt] +type gatewayConfigurationEditResponseSettingsTLSDecryptJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationEditResponseSettingsTLSDecrypt) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationEditResponseSettingsTLSDecryptJSON) RawJSON() string { + return r.raw +} + +// account settings. +type GatewayConfigurationGetResponse struct { + CreatedAt time.Time `json:"created_at" format:"date-time"` + // account settings. + Settings GatewayConfigurationGetResponseSettings `json:"settings"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON gatewayConfigurationGetResponseJSON `json:"-"` +} + +// gatewayConfigurationGetResponseJSON contains the JSON metadata for the struct +// [GatewayConfigurationGetResponse] +type gatewayConfigurationGetResponseJSON struct { + CreatedAt apijson.Field + Settings apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationGetResponseJSON) RawJSON() string { + return r.raw +} + +// account settings. +type GatewayConfigurationGetResponseSettings struct { + // Activity log settings. + ActivityLog GatewayConfigurationGetResponseSettingsActivityLog `json:"activity_log"` + // Anti-virus settings. + Antivirus GatewayConfigurationGetResponseSettingsAntivirus `json:"antivirus"` + // Block page layout settings. + BlockPage GatewayConfigurationGetResponseSettingsBlockPage `json:"block_page"` + // DLP body scanning settings. + BodyScanning GatewayConfigurationGetResponseSettingsBodyScanning `json:"body_scanning"` + // Browser isolation settings. + BrowserIsolation GatewayConfigurationGetResponseSettingsBrowserIsolation `json:"browser_isolation"` + // Custom certificate settings for BYO-PKI. + CustomCertificate GatewayConfigurationGetResponseSettingsCustomCertificate `json:"custom_certificate"` + // Extended e-mail matching settings. + ExtendedEmailMatching GatewayConfigurationGetResponseSettingsExtendedEmailMatching `json:"extended_email_matching"` + // FIPS settings. + Fips GatewayConfigurationGetResponseSettingsFips `json:"fips"` + // Protocol Detection settings. + ProtocolDetection GatewayConfigurationGetResponseSettingsProtocolDetection `json:"protocol_detection"` + // TLS interception settings. + TLSDecrypt GatewayConfigurationGetResponseSettingsTLSDecrypt `json:"tls_decrypt"` + JSON gatewayConfigurationGetResponseSettingsJSON `json:"-"` +} + +// gatewayConfigurationGetResponseSettingsJSON contains the JSON metadata for the +// struct [GatewayConfigurationGetResponseSettings] +type gatewayConfigurationGetResponseSettingsJSON struct { + ActivityLog apijson.Field + Antivirus apijson.Field + BlockPage apijson.Field + BodyScanning apijson.Field + BrowserIsolation apijson.Field + CustomCertificate apijson.Field + ExtendedEmailMatching apijson.Field + Fips apijson.Field + ProtocolDetection apijson.Field + TLSDecrypt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationGetResponseSettings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationGetResponseSettingsJSON) RawJSON() string { + return r.raw +} + +// Activity log settings. +type GatewayConfigurationGetResponseSettingsActivityLog struct { + // Enable activity logging. + Enabled bool `json:"enabled"` + JSON gatewayConfigurationGetResponseSettingsActivityLogJSON `json:"-"` +} + +// gatewayConfigurationGetResponseSettingsActivityLogJSON contains the JSON +// metadata for the struct [GatewayConfigurationGetResponseSettingsActivityLog] +type gatewayConfigurationGetResponseSettingsActivityLogJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationGetResponseSettingsActivityLog) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationGetResponseSettingsActivityLogJSON) RawJSON() string { + return r.raw +} + +// Anti-virus settings. +type GatewayConfigurationGetResponseSettingsAntivirus struct { + // Enable anti-virus scanning on downloads. + EnabledDownloadPhase bool `json:"enabled_download_phase"` + // Enable anti-virus scanning on uploads. + EnabledUploadPhase bool `json:"enabled_upload_phase"` + // Block requests for files that cannot be scanned. + FailClosed bool `json:"fail_closed"` + // Configure a message to display on the user's device when an antivirus search is + // performed. + NotificationSettings GatewayConfigurationGetResponseSettingsAntivirusNotificationSettings `json:"notification_settings"` + JSON gatewayConfigurationGetResponseSettingsAntivirusJSON `json:"-"` +} + +// gatewayConfigurationGetResponseSettingsAntivirusJSON contains the JSON metadata +// for the struct [GatewayConfigurationGetResponseSettingsAntivirus] +type gatewayConfigurationGetResponseSettingsAntivirusJSON struct { + EnabledDownloadPhase apijson.Field + EnabledUploadPhase apijson.Field + FailClosed apijson.Field + NotificationSettings apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationGetResponseSettingsAntivirus) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationGetResponseSettingsAntivirusJSON) RawJSON() string { + return r.raw +} + +// Configure a message to display on the user's device when an antivirus search is +// performed. +type GatewayConfigurationGetResponseSettingsAntivirusNotificationSettings struct { + // Set notification on + Enabled bool `json:"enabled"` + // Customize the message shown in the notification. + Msg string `json:"msg"` + // Optional URL to direct users to additional information. If not set, the + // notification will open a block page. + SupportURL string `json:"support_url"` + JSON gatewayConfigurationGetResponseSettingsAntivirusNotificationSettingsJSON `json:"-"` +} + +// gatewayConfigurationGetResponseSettingsAntivirusNotificationSettingsJSON +// contains the JSON metadata for the struct +// [GatewayConfigurationGetResponseSettingsAntivirusNotificationSettings] +type gatewayConfigurationGetResponseSettingsAntivirusNotificationSettingsJSON struct { + Enabled apijson.Field + Msg apijson.Field + SupportURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationGetResponseSettingsAntivirusNotificationSettings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationGetResponseSettingsAntivirusNotificationSettingsJSON) RawJSON() string { + return r.raw +} + +// Block page layout settings. +type GatewayConfigurationGetResponseSettingsBlockPage struct { + // Block page background color in #rrggbb format. + BackgroundColor string `json:"background_color"` + // Enable only cipher suites and TLS versions compliant with FIPS 140-2. + Enabled bool `json:"enabled"` + // Block page footer text. + FooterText string `json:"footer_text"` + // Block page header text. + HeaderText string `json:"header_text"` + // Full URL to the logo file. + LogoPath string `json:"logo_path"` + // Admin email for users to contact. + MailtoAddress string `json:"mailto_address"` + // Subject line for emails created from block page. + MailtoSubject string `json:"mailto_subject"` + // Block page title. + Name string `json:"name"` + // Suppress detailed info at the bottom of the block page. + SuppressFooter bool `json:"suppress_footer"` + JSON gatewayConfigurationGetResponseSettingsBlockPageJSON `json:"-"` +} + +// gatewayConfigurationGetResponseSettingsBlockPageJSON contains the JSON metadata +// for the struct [GatewayConfigurationGetResponseSettingsBlockPage] +type gatewayConfigurationGetResponseSettingsBlockPageJSON struct { + BackgroundColor apijson.Field + Enabled apijson.Field + FooterText apijson.Field + HeaderText apijson.Field + LogoPath apijson.Field + MailtoAddress apijson.Field + MailtoSubject apijson.Field + Name apijson.Field + SuppressFooter apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationGetResponseSettingsBlockPage) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationGetResponseSettingsBlockPageJSON) RawJSON() string { + return r.raw +} + +// DLP body scanning settings. +type GatewayConfigurationGetResponseSettingsBodyScanning struct { + // Set the inspection mode to either `deep` or `shallow`. + InspectionMode string `json:"inspection_mode"` + JSON gatewayConfigurationGetResponseSettingsBodyScanningJSON `json:"-"` +} + +// gatewayConfigurationGetResponseSettingsBodyScanningJSON contains the JSON +// metadata for the struct [GatewayConfigurationGetResponseSettingsBodyScanning] +type gatewayConfigurationGetResponseSettingsBodyScanningJSON struct { + InspectionMode apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationGetResponseSettingsBodyScanning) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationGetResponseSettingsBodyScanningJSON) RawJSON() string { + return r.raw +} + +// Browser isolation settings. +type GatewayConfigurationGetResponseSettingsBrowserIsolation struct { + // Enable non-identity onramp support for Browser Isolation. + NonIdentityEnabled bool `json:"non_identity_enabled"` + // Enable Clientless Browser Isolation. + URLBrowserIsolationEnabled bool `json:"url_browser_isolation_enabled"` + JSON gatewayConfigurationGetResponseSettingsBrowserIsolationJSON `json:"-"` +} + +// gatewayConfigurationGetResponseSettingsBrowserIsolationJSON contains the JSON +// metadata for the struct +// [GatewayConfigurationGetResponseSettingsBrowserIsolation] +type gatewayConfigurationGetResponseSettingsBrowserIsolationJSON struct { + NonIdentityEnabled apijson.Field + URLBrowserIsolationEnabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationGetResponseSettingsBrowserIsolation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationGetResponseSettingsBrowserIsolationJSON) RawJSON() string { + return r.raw +} + +// Custom certificate settings for BYO-PKI. +type GatewayConfigurationGetResponseSettingsCustomCertificate struct { + // Enable use of custom certificate authority for signing Gateway traffic. + Enabled bool `json:"enabled,required"` + // UUID of certificate (ID from MTLS certificate store). + ID string `json:"id"` + // Certificate status (internal). + BindingStatus string `json:"binding_status"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON gatewayConfigurationGetResponseSettingsCustomCertificateJSON `json:"-"` +} + +// gatewayConfigurationGetResponseSettingsCustomCertificateJSON contains the JSON +// metadata for the struct +// [GatewayConfigurationGetResponseSettingsCustomCertificate] +type gatewayConfigurationGetResponseSettingsCustomCertificateJSON struct { + Enabled apijson.Field + ID apijson.Field + BindingStatus apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationGetResponseSettingsCustomCertificate) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationGetResponseSettingsCustomCertificateJSON) RawJSON() string { + return r.raw +} + +// Extended e-mail matching settings. +type GatewayConfigurationGetResponseSettingsExtendedEmailMatching struct { + // Enable matching all variants of user emails (with + or . modifiers) used as + // criteria in Firewall policies. + Enabled bool `json:"enabled"` + JSON gatewayConfigurationGetResponseSettingsExtendedEmailMatchingJSON `json:"-"` +} + +// gatewayConfigurationGetResponseSettingsExtendedEmailMatchingJSON contains the +// JSON metadata for the struct +// [GatewayConfigurationGetResponseSettingsExtendedEmailMatching] +type gatewayConfigurationGetResponseSettingsExtendedEmailMatchingJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationGetResponseSettingsExtendedEmailMatching) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationGetResponseSettingsExtendedEmailMatchingJSON) RawJSON() string { + return r.raw +} + +// FIPS settings. +type GatewayConfigurationGetResponseSettingsFips struct { + // Enable only cipher suites and TLS versions compliant with FIPS 140-2. + TLS bool `json:"tls"` + JSON gatewayConfigurationGetResponseSettingsFipsJSON `json:"-"` +} + +// gatewayConfigurationGetResponseSettingsFipsJSON contains the JSON metadata for +// the struct [GatewayConfigurationGetResponseSettingsFips] +type gatewayConfigurationGetResponseSettingsFipsJSON struct { + TLS apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationGetResponseSettingsFips) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationGetResponseSettingsFipsJSON) RawJSON() string { + return r.raw +} + +// Protocol Detection settings. +type GatewayConfigurationGetResponseSettingsProtocolDetection struct { + // Enable detecting protocol on initial bytes of client traffic. + Enabled bool `json:"enabled"` + JSON gatewayConfigurationGetResponseSettingsProtocolDetectionJSON `json:"-"` +} + +// gatewayConfigurationGetResponseSettingsProtocolDetectionJSON contains the JSON +// metadata for the struct +// [GatewayConfigurationGetResponseSettingsProtocolDetection] +type gatewayConfigurationGetResponseSettingsProtocolDetectionJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationGetResponseSettingsProtocolDetection) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationGetResponseSettingsProtocolDetectionJSON) RawJSON() string { + return r.raw +} + +// TLS interception settings. +type GatewayConfigurationGetResponseSettingsTLSDecrypt struct { + // Enable inspecting encrypted HTTP traffic. + Enabled bool `json:"enabled"` + JSON gatewayConfigurationGetResponseSettingsTLSDecryptJSON `json:"-"` +} + +// gatewayConfigurationGetResponseSettingsTLSDecryptJSON contains the JSON metadata +// for the struct [GatewayConfigurationGetResponseSettingsTLSDecrypt] +type gatewayConfigurationGetResponseSettingsTLSDecryptJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationGetResponseSettingsTLSDecrypt) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationGetResponseSettingsTLSDecryptJSON) RawJSON() string { + return r.raw +} + +type GatewayConfigurationUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // account settings. + Settings param.Field[GatewayConfigurationUpdateParamsSettings] `json:"settings"` +} + +func (r GatewayConfigurationUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// account settings. +type GatewayConfigurationUpdateParamsSettings struct { + // Activity log settings. + ActivityLog param.Field[GatewayConfigurationUpdateParamsSettingsActivityLog] `json:"activity_log"` + // Anti-virus settings. + Antivirus param.Field[GatewayConfigurationUpdateParamsSettingsAntivirus] `json:"antivirus"` + // Block page layout settings. + BlockPage param.Field[GatewayConfigurationUpdateParamsSettingsBlockPage] `json:"block_page"` + // DLP body scanning settings. + BodyScanning param.Field[GatewayConfigurationUpdateParamsSettingsBodyScanning] `json:"body_scanning"` + // Browser isolation settings. + BrowserIsolation param.Field[GatewayConfigurationUpdateParamsSettingsBrowserIsolation] `json:"browser_isolation"` + // Custom certificate settings for BYO-PKI. + CustomCertificate param.Field[GatewayConfigurationUpdateParamsSettingsCustomCertificate] `json:"custom_certificate"` + // Extended e-mail matching settings. + ExtendedEmailMatching param.Field[GatewayConfigurationUpdateParamsSettingsExtendedEmailMatching] `json:"extended_email_matching"` + // FIPS settings. + Fips param.Field[GatewayConfigurationUpdateParamsSettingsFips] `json:"fips"` + // Protocol Detection settings. + ProtocolDetection param.Field[GatewayConfigurationUpdateParamsSettingsProtocolDetection] `json:"protocol_detection"` + // TLS interception settings. + TLSDecrypt param.Field[GatewayConfigurationUpdateParamsSettingsTLSDecrypt] `json:"tls_decrypt"` +} + +func (r GatewayConfigurationUpdateParamsSettings) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Activity log settings. +type GatewayConfigurationUpdateParamsSettingsActivityLog struct { + // Enable activity logging. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r GatewayConfigurationUpdateParamsSettingsActivityLog) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Anti-virus settings. +type GatewayConfigurationUpdateParamsSettingsAntivirus struct { + // Enable anti-virus scanning on downloads. + EnabledDownloadPhase param.Field[bool] `json:"enabled_download_phase"` + // Enable anti-virus scanning on uploads. + EnabledUploadPhase param.Field[bool] `json:"enabled_upload_phase"` + // Block requests for files that cannot be scanned. + FailClosed param.Field[bool] `json:"fail_closed"` + // Configure a message to display on the user's device when an antivirus search is + // performed. + NotificationSettings param.Field[GatewayConfigurationUpdateParamsSettingsAntivirusNotificationSettings] `json:"notification_settings"` +} + +func (r GatewayConfigurationUpdateParamsSettingsAntivirus) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configure a message to display on the user's device when an antivirus search is +// performed. +type GatewayConfigurationUpdateParamsSettingsAntivirusNotificationSettings struct { + // Set notification on + Enabled param.Field[bool] `json:"enabled"` + // Customize the message shown in the notification. + Msg param.Field[string] `json:"msg"` + // Optional URL to direct users to additional information. If not set, the + // notification will open a block page. + SupportURL param.Field[string] `json:"support_url"` +} + +func (r GatewayConfigurationUpdateParamsSettingsAntivirusNotificationSettings) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Block page layout settings. +type GatewayConfigurationUpdateParamsSettingsBlockPage struct { + // Block page background color in #rrggbb format. + BackgroundColor param.Field[string] `json:"background_color"` + // Enable only cipher suites and TLS versions compliant with FIPS 140-2. + Enabled param.Field[bool] `json:"enabled"` + // Block page footer text. + FooterText param.Field[string] `json:"footer_text"` + // Block page header text. + HeaderText param.Field[string] `json:"header_text"` + // Full URL to the logo file. + LogoPath param.Field[string] `json:"logo_path"` + // Admin email for users to contact. + MailtoAddress param.Field[string] `json:"mailto_address"` + // Subject line for emails created from block page. + MailtoSubject param.Field[string] `json:"mailto_subject"` + // Block page title. + Name param.Field[string] `json:"name"` + // Suppress detailed info at the bottom of the block page. + SuppressFooter param.Field[bool] `json:"suppress_footer"` +} + +func (r GatewayConfigurationUpdateParamsSettingsBlockPage) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// DLP body scanning settings. +type GatewayConfigurationUpdateParamsSettingsBodyScanning struct { + // Set the inspection mode to either `deep` or `shallow`. + InspectionMode param.Field[string] `json:"inspection_mode"` +} + +func (r GatewayConfigurationUpdateParamsSettingsBodyScanning) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Browser isolation settings. +type GatewayConfigurationUpdateParamsSettingsBrowserIsolation struct { + // Enable non-identity onramp support for Browser Isolation. + NonIdentityEnabled param.Field[bool] `json:"non_identity_enabled"` + // Enable Clientless Browser Isolation. + URLBrowserIsolationEnabled param.Field[bool] `json:"url_browser_isolation_enabled"` +} + +func (r GatewayConfigurationUpdateParamsSettingsBrowserIsolation) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Custom certificate settings for BYO-PKI. +type GatewayConfigurationUpdateParamsSettingsCustomCertificate struct { + // Enable use of custom certificate authority for signing Gateway traffic. + Enabled param.Field[bool] `json:"enabled,required"` + // UUID of certificate (ID from MTLS certificate store). + ID param.Field[string] `json:"id"` +} + +func (r GatewayConfigurationUpdateParamsSettingsCustomCertificate) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Extended e-mail matching settings. +type GatewayConfigurationUpdateParamsSettingsExtendedEmailMatching struct { + // Enable matching all variants of user emails (with + or . modifiers) used as + // criteria in Firewall policies. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r GatewayConfigurationUpdateParamsSettingsExtendedEmailMatching) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// FIPS settings. +type GatewayConfigurationUpdateParamsSettingsFips struct { + // Enable only cipher suites and TLS versions compliant with FIPS 140-2. + TLS param.Field[bool] `json:"tls"` +} + +func (r GatewayConfigurationUpdateParamsSettingsFips) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Protocol Detection settings. +type GatewayConfigurationUpdateParamsSettingsProtocolDetection struct { + // Enable detecting protocol on initial bytes of client traffic. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r GatewayConfigurationUpdateParamsSettingsProtocolDetection) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// TLS interception settings. +type GatewayConfigurationUpdateParamsSettingsTLSDecrypt struct { + // Enable inspecting encrypted HTTP traffic. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r GatewayConfigurationUpdateParamsSettingsTLSDecrypt) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayConfigurationUpdateResponseEnvelope struct { + Errors []GatewayConfigurationUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayConfigurationUpdateResponseEnvelopeMessages `json:"messages,required"` + // account settings. + Result GatewayConfigurationUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success GatewayConfigurationUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayConfigurationUpdateResponseEnvelopeJSON `json:"-"` +} + +// gatewayConfigurationUpdateResponseEnvelopeJSON contains the JSON metadata for +// the struct [GatewayConfigurationUpdateResponseEnvelope] +type gatewayConfigurationUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayConfigurationUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayConfigurationUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayConfigurationUpdateResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [GatewayConfigurationUpdateResponseEnvelopeErrors] +type gatewayConfigurationUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayConfigurationUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayConfigurationUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayConfigurationUpdateResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [GatewayConfigurationUpdateResponseEnvelopeMessages] +type gatewayConfigurationUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayConfigurationUpdateResponseEnvelopeSuccess bool + +const ( + GatewayConfigurationUpdateResponseEnvelopeSuccessTrue GatewayConfigurationUpdateResponseEnvelopeSuccess = true +) + +type GatewayConfigurationEditParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // account settings. + Settings param.Field[GatewayConfigurationEditParamsSettings] `json:"settings"` +} + +func (r GatewayConfigurationEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// account settings. +type GatewayConfigurationEditParamsSettings struct { + // Activity log settings. + ActivityLog param.Field[GatewayConfigurationEditParamsSettingsActivityLog] `json:"activity_log"` + // Anti-virus settings. + Antivirus param.Field[GatewayConfigurationEditParamsSettingsAntivirus] `json:"antivirus"` + // Block page layout settings. + BlockPage param.Field[GatewayConfigurationEditParamsSettingsBlockPage] `json:"block_page"` + // DLP body scanning settings. + BodyScanning param.Field[GatewayConfigurationEditParamsSettingsBodyScanning] `json:"body_scanning"` + // Browser isolation settings. + BrowserIsolation param.Field[GatewayConfigurationEditParamsSettingsBrowserIsolation] `json:"browser_isolation"` + // Custom certificate settings for BYO-PKI. + CustomCertificate param.Field[GatewayConfigurationEditParamsSettingsCustomCertificate] `json:"custom_certificate"` + // Extended e-mail matching settings. + ExtendedEmailMatching param.Field[GatewayConfigurationEditParamsSettingsExtendedEmailMatching] `json:"extended_email_matching"` + // FIPS settings. + Fips param.Field[GatewayConfigurationEditParamsSettingsFips] `json:"fips"` + // Protocol Detection settings. + ProtocolDetection param.Field[GatewayConfigurationEditParamsSettingsProtocolDetection] `json:"protocol_detection"` + // TLS interception settings. + TLSDecrypt param.Field[GatewayConfigurationEditParamsSettingsTLSDecrypt] `json:"tls_decrypt"` +} + +func (r GatewayConfigurationEditParamsSettings) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Activity log settings. +type GatewayConfigurationEditParamsSettingsActivityLog struct { + // Enable activity logging. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r GatewayConfigurationEditParamsSettingsActivityLog) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Anti-virus settings. +type GatewayConfigurationEditParamsSettingsAntivirus struct { + // Enable anti-virus scanning on downloads. + EnabledDownloadPhase param.Field[bool] `json:"enabled_download_phase"` + // Enable anti-virus scanning on uploads. + EnabledUploadPhase param.Field[bool] `json:"enabled_upload_phase"` + // Block requests for files that cannot be scanned. + FailClosed param.Field[bool] `json:"fail_closed"` + // Configure a message to display on the user's device when an antivirus search is + // performed. + NotificationSettings param.Field[GatewayConfigurationEditParamsSettingsAntivirusNotificationSettings] `json:"notification_settings"` +} + +func (r GatewayConfigurationEditParamsSettingsAntivirus) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configure a message to display on the user's device when an antivirus search is +// performed. +type GatewayConfigurationEditParamsSettingsAntivirusNotificationSettings struct { + // Set notification on + Enabled param.Field[bool] `json:"enabled"` + // Customize the message shown in the notification. + Msg param.Field[string] `json:"msg"` + // Optional URL to direct users to additional information. If not set, the + // notification will open a block page. + SupportURL param.Field[string] `json:"support_url"` +} + +func (r GatewayConfigurationEditParamsSettingsAntivirusNotificationSettings) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Block page layout settings. +type GatewayConfigurationEditParamsSettingsBlockPage struct { + // Block page background color in #rrggbb format. + BackgroundColor param.Field[string] `json:"background_color"` + // Enable only cipher suites and TLS versions compliant with FIPS 140-2. + Enabled param.Field[bool] `json:"enabled"` + // Block page footer text. + FooterText param.Field[string] `json:"footer_text"` + // Block page header text. + HeaderText param.Field[string] `json:"header_text"` + // Full URL to the logo file. + LogoPath param.Field[string] `json:"logo_path"` + // Admin email for users to contact. + MailtoAddress param.Field[string] `json:"mailto_address"` + // Subject line for emails created from block page. + MailtoSubject param.Field[string] `json:"mailto_subject"` + // Block page title. + Name param.Field[string] `json:"name"` + // Suppress detailed info at the bottom of the block page. + SuppressFooter param.Field[bool] `json:"suppress_footer"` +} + +func (r GatewayConfigurationEditParamsSettingsBlockPage) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// DLP body scanning settings. +type GatewayConfigurationEditParamsSettingsBodyScanning struct { + // Set the inspection mode to either `deep` or `shallow`. + InspectionMode param.Field[string] `json:"inspection_mode"` +} + +func (r GatewayConfigurationEditParamsSettingsBodyScanning) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Browser isolation settings. +type GatewayConfigurationEditParamsSettingsBrowserIsolation struct { + // Enable non-identity onramp support for Browser Isolation. + NonIdentityEnabled param.Field[bool] `json:"non_identity_enabled"` + // Enable Clientless Browser Isolation. + URLBrowserIsolationEnabled param.Field[bool] `json:"url_browser_isolation_enabled"` +} + +func (r GatewayConfigurationEditParamsSettingsBrowserIsolation) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Custom certificate settings for BYO-PKI. +type GatewayConfigurationEditParamsSettingsCustomCertificate struct { + // Enable use of custom certificate authority for signing Gateway traffic. + Enabled param.Field[bool] `json:"enabled,required"` + // UUID of certificate (ID from MTLS certificate store). + ID param.Field[string] `json:"id"` +} + +func (r GatewayConfigurationEditParamsSettingsCustomCertificate) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Extended e-mail matching settings. +type GatewayConfigurationEditParamsSettingsExtendedEmailMatching struct { + // Enable matching all variants of user emails (with + or . modifiers) used as + // criteria in Firewall policies. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r GatewayConfigurationEditParamsSettingsExtendedEmailMatching) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// FIPS settings. +type GatewayConfigurationEditParamsSettingsFips struct { + // Enable only cipher suites and TLS versions compliant with FIPS 140-2. + TLS param.Field[bool] `json:"tls"` +} + +func (r GatewayConfigurationEditParamsSettingsFips) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Protocol Detection settings. +type GatewayConfigurationEditParamsSettingsProtocolDetection struct { + // Enable detecting protocol on initial bytes of client traffic. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r GatewayConfigurationEditParamsSettingsProtocolDetection) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// TLS interception settings. +type GatewayConfigurationEditParamsSettingsTLSDecrypt struct { + // Enable inspecting encrypted HTTP traffic. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r GatewayConfigurationEditParamsSettingsTLSDecrypt) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayConfigurationEditResponseEnvelope struct { + Errors []GatewayConfigurationEditResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayConfigurationEditResponseEnvelopeMessages `json:"messages,required"` + // account settings. + Result GatewayConfigurationEditResponse `json:"result,required"` + // Whether the API call was successful + Success GatewayConfigurationEditResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayConfigurationEditResponseEnvelopeJSON `json:"-"` +} + +// gatewayConfigurationEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [GatewayConfigurationEditResponseEnvelope] +type gatewayConfigurationEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayConfigurationEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayConfigurationEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayConfigurationEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [GatewayConfigurationEditResponseEnvelopeErrors] +type gatewayConfigurationEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayConfigurationEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayConfigurationEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayConfigurationEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [GatewayConfigurationEditResponseEnvelopeMessages] +type gatewayConfigurationEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayConfigurationEditResponseEnvelopeSuccess bool + +const ( + GatewayConfigurationEditResponseEnvelopeSuccessTrue GatewayConfigurationEditResponseEnvelopeSuccess = true +) + +type GatewayConfigurationGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type GatewayConfigurationGetResponseEnvelope struct { + Errors []GatewayConfigurationGetResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayConfigurationGetResponseEnvelopeMessages `json:"messages,required"` + // account settings. + Result GatewayConfigurationGetResponse `json:"result,required"` + // Whether the API call was successful + Success GatewayConfigurationGetResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayConfigurationGetResponseEnvelopeJSON `json:"-"` +} + +// gatewayConfigurationGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [GatewayConfigurationGetResponseEnvelope] +type gatewayConfigurationGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayConfigurationGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayConfigurationGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayConfigurationGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [GatewayConfigurationGetResponseEnvelopeErrors] +type gatewayConfigurationGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayConfigurationGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayConfigurationGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayConfigurationGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [GatewayConfigurationGetResponseEnvelopeMessages] +type gatewayConfigurationGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayConfigurationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayConfigurationGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayConfigurationGetResponseEnvelopeSuccess bool + +const ( + GatewayConfigurationGetResponseEnvelopeSuccessTrue GatewayConfigurationGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/gatewayconfiguration_test.go b/zero_trust/gatewayconfiguration_test.go new file mode 100644 index 00000000000..afcb76300e3 --- /dev/null +++ b/zero_trust/gatewayconfiguration_test.go @@ -0,0 +1,191 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestGatewayConfigurationUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Configurations.Update(context.TODO(), zero_trust.GatewayConfigurationUpdateParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Settings: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettings{ + ActivityLog: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsActivityLog{ + Enabled: cloudflare.F(true), + }), + Antivirus: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsAntivirus{ + EnabledDownloadPhase: cloudflare.F(false), + EnabledUploadPhase: cloudflare.F(false), + FailClosed: cloudflare.F(false), + NotificationSettings: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsAntivirusNotificationSettings{ + Enabled: cloudflare.F(true), + Msg: cloudflare.F("string"), + SupportURL: cloudflare.F("string"), + }), + }), + BlockPage: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsBlockPage{ + BackgroundColor: cloudflare.F("string"), + Enabled: cloudflare.F(true), + FooterText: cloudflare.F("--footer--"), + HeaderText: cloudflare.F("--header--"), + LogoPath: cloudflare.F("https://logos.com/a.png"), + MailtoAddress: cloudflare.F("admin@example.com"), + MailtoSubject: cloudflare.F("Blocked User Inquiry"), + Name: cloudflare.F("Cloudflare"), + SuppressFooter: cloudflare.F(false), + }), + BodyScanning: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsBodyScanning{ + InspectionMode: cloudflare.F("deep"), + }), + BrowserIsolation: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsBrowserIsolation{ + NonIdentityEnabled: cloudflare.F(true), + URLBrowserIsolationEnabled: cloudflare.F(true), + }), + CustomCertificate: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsCustomCertificate{ + Enabled: cloudflare.F(true), + ID: cloudflare.F("d1b364c5-1311-466e-a194-f0e943e0799f"), + }), + ExtendedEmailMatching: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsExtendedEmailMatching{ + Enabled: cloudflare.F(true), + }), + Fips: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsFips{ + TLS: cloudflare.F(true), + }), + ProtocolDetection: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsProtocolDetection{ + Enabled: cloudflare.F(true), + }), + TLSDecrypt: cloudflare.F(zero_trust.GatewayConfigurationUpdateParamsSettingsTLSDecrypt{ + Enabled: cloudflare.F(true), + }), + }), + }) + 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 TestGatewayConfigurationEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Configurations.Edit(context.TODO(), zero_trust.GatewayConfigurationEditParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Settings: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettings{ + ActivityLog: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsActivityLog{ + Enabled: cloudflare.F(true), + }), + Antivirus: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsAntivirus{ + EnabledDownloadPhase: cloudflare.F(false), + EnabledUploadPhase: cloudflare.F(false), + FailClosed: cloudflare.F(false), + NotificationSettings: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsAntivirusNotificationSettings{ + Enabled: cloudflare.F(true), + Msg: cloudflare.F("string"), + SupportURL: cloudflare.F("string"), + }), + }), + BlockPage: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsBlockPage{ + BackgroundColor: cloudflare.F("string"), + Enabled: cloudflare.F(true), + FooterText: cloudflare.F("--footer--"), + HeaderText: cloudflare.F("--header--"), + LogoPath: cloudflare.F("https://logos.com/a.png"), + MailtoAddress: cloudflare.F("admin@example.com"), + MailtoSubject: cloudflare.F("Blocked User Inquiry"), + Name: cloudflare.F("Cloudflare"), + SuppressFooter: cloudflare.F(false), + }), + BodyScanning: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsBodyScanning{ + InspectionMode: cloudflare.F("deep"), + }), + BrowserIsolation: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsBrowserIsolation{ + NonIdentityEnabled: cloudflare.F(true), + URLBrowserIsolationEnabled: cloudflare.F(true), + }), + CustomCertificate: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsCustomCertificate{ + Enabled: cloudflare.F(true), + ID: cloudflare.F("d1b364c5-1311-466e-a194-f0e943e0799f"), + }), + ExtendedEmailMatching: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsExtendedEmailMatching{ + Enabled: cloudflare.F(true), + }), + Fips: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsFips{ + TLS: cloudflare.F(true), + }), + ProtocolDetection: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsProtocolDetection{ + Enabled: cloudflare.F(true), + }), + TLSDecrypt: cloudflare.F(zero_trust.GatewayConfigurationEditParamsSettingsTLSDecrypt{ + Enabled: cloudflare.F(true), + }), + }), + }) + 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 TestGatewayConfigurationGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Configurations.Get(context.TODO(), zero_trust.GatewayConfigurationGetParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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/zero_trust/gatewaylist.go b/zero_trust/gatewaylist.go new file mode 100644 index 00000000000..4e7156e0de7 --- /dev/null +++ b/zero_trust/gatewaylist.go @@ -0,0 +1,855 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// GatewayListService 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 [NewGatewayListService] method +// instead. +type GatewayListService struct { + Options []option.RequestOption + Items *GatewayListItemService +} + +// NewGatewayListService 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 NewGatewayListService(opts ...option.RequestOption) (r *GatewayListService) { + r = &GatewayListService{} + r.Options = opts + r.Items = NewGatewayListItemService(opts...) + return +} + +// Creates a new Zero Trust list. +func (r *GatewayListService) New(ctx context.Context, params GatewayListNewParams, opts ...option.RequestOption) (res *GatewayListNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env GatewayListNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/lists", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a configured Zero Trust list. +func (r *GatewayListService) Update(ctx context.Context, listID string, params GatewayListUpdateParams, opts ...option.RequestOption) (res *ZeroTrustGatewayLists, err error) { + opts = append(r.Options[:], opts...) + var env GatewayListUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/lists/%s", params.AccountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches all Zero Trust lists for an account. +func (r *GatewayListService) List(ctx context.Context, query GatewayListListParams, opts ...option.RequestOption) (res *[]ZeroTrustGatewayLists, err error) { + opts = append(r.Options[:], opts...) + var env GatewayListListResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/lists", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a Zero Trust list. +func (r *GatewayListService) Delete(ctx context.Context, listID string, body GatewayListDeleteParams, opts ...option.RequestOption) (res *GatewayListDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env GatewayListDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/lists/%s", body.AccountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Appends or removes an item from a configured Zero Trust list. +func (r *GatewayListService) Edit(ctx context.Context, listID string, params GatewayListEditParams, opts ...option.RequestOption) (res *ZeroTrustGatewayLists, err error) { + opts = append(r.Options[:], opts...) + var env GatewayListEditResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/lists/%s", params.AccountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a single Zero Trust list. +func (r *GatewayListService) Get(ctx context.Context, listID string, query GatewayListGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewayLists, err error) { + opts = append(r.Options[:], opts...) + var env GatewayListGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/lists/%s", query.AccountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ZeroTrustGatewayLists struct { + // API Resource UUID tag. + ID string `json:"id"` + // The number of items in the list. + Count float64 `json:"count"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The description of the list. + Description string `json:"description"` + // The name of the list. + Name string `json:"name"` + // The type of list. + Type ZeroTrustGatewayListsType `json:"type"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON zeroTrustGatewayListsJSON `json:"-"` +} + +// zeroTrustGatewayListsJSON contains the JSON metadata for the struct +// [ZeroTrustGatewayLists] +type zeroTrustGatewayListsJSON struct { + ID apijson.Field + Count apijson.Field + CreatedAt apijson.Field + Description apijson.Field + Name apijson.Field + Type apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayLists) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayListsJSON) RawJSON() string { + return r.raw +} + +// The type of list. +type ZeroTrustGatewayListsType string + +const ( + ZeroTrustGatewayListsTypeSerial ZeroTrustGatewayListsType = "SERIAL" + ZeroTrustGatewayListsTypeURL ZeroTrustGatewayListsType = "URL" + ZeroTrustGatewayListsTypeDomain ZeroTrustGatewayListsType = "DOMAIN" + ZeroTrustGatewayListsTypeEmail ZeroTrustGatewayListsType = "EMAIL" + ZeroTrustGatewayListsTypeIP ZeroTrustGatewayListsType = "IP" +) + +type GatewayListNewResponse struct { + // API Resource UUID tag. + ID string `json:"id"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The description of the list. + Description string `json:"description"` + // The items in the list. + Items []GatewayListNewResponseItem `json:"items"` + // The name of the list. + Name string `json:"name"` + // The type of list. + Type GatewayListNewResponseType `json:"type"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON gatewayListNewResponseJSON `json:"-"` +} + +// gatewayListNewResponseJSON contains the JSON metadata for the struct +// [GatewayListNewResponse] +type gatewayListNewResponseJSON struct { + ID apijson.Field + CreatedAt apijson.Field + Description apijson.Field + Items apijson.Field + Name apijson.Field + Type apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListNewResponseJSON) RawJSON() string { + return r.raw +} + +type GatewayListNewResponseItem struct { + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The value of the item in a list. + Value string `json:"value"` + JSON gatewayListNewResponseItemJSON `json:"-"` +} + +// gatewayListNewResponseItemJSON contains the JSON metadata for the struct +// [GatewayListNewResponseItem] +type gatewayListNewResponseItemJSON struct { + CreatedAt apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListNewResponseItem) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListNewResponseItemJSON) RawJSON() string { + return r.raw +} + +// The type of list. +type GatewayListNewResponseType string + +const ( + GatewayListNewResponseTypeSerial GatewayListNewResponseType = "SERIAL" + GatewayListNewResponseTypeURL GatewayListNewResponseType = "URL" + GatewayListNewResponseTypeDomain GatewayListNewResponseType = "DOMAIN" + GatewayListNewResponseTypeEmail GatewayListNewResponseType = "EMAIL" + GatewayListNewResponseTypeIP GatewayListNewResponseType = "IP" +) + +// Union satisfied by [zero_trust.GatewayListDeleteResponseUnknown] or +// [shared.UnionString]. +type GatewayListDeleteResponse interface { + ImplementsZeroTrustGatewayListDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*GatewayListDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type GatewayListNewParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // The name of the list. + Name param.Field[string] `json:"name,required"` + // The type of list. + Type param.Field[GatewayListNewParamsType] `json:"type,required"` + // The description of the list. + Description param.Field[string] `json:"description"` + // The items in the list. + Items param.Field[[]GatewayListNewParamsItem] `json:"items"` +} + +func (r GatewayListNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of list. +type GatewayListNewParamsType string + +const ( + GatewayListNewParamsTypeSerial GatewayListNewParamsType = "SERIAL" + GatewayListNewParamsTypeURL GatewayListNewParamsType = "URL" + GatewayListNewParamsTypeDomain GatewayListNewParamsType = "DOMAIN" + GatewayListNewParamsTypeEmail GatewayListNewParamsType = "EMAIL" + GatewayListNewParamsTypeIP GatewayListNewParamsType = "IP" +) + +type GatewayListNewParamsItem struct { + // The value of the item in a list. + Value param.Field[string] `json:"value"` +} + +func (r GatewayListNewParamsItem) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayListNewResponseEnvelope struct { + Errors []GatewayListNewResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayListNewResponseEnvelopeMessages `json:"messages,required"` + Result GatewayListNewResponse `json:"result,required"` + // Whether the API call was successful + Success GatewayListNewResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayListNewResponseEnvelopeJSON `json:"-"` +} + +// gatewayListNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayListNewResponseEnvelope] +type gatewayListNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayListNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayListNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayListNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GatewayListNewResponseEnvelopeErrors] +type gatewayListNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayListNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayListNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayListNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [GatewayListNewResponseEnvelopeMessages] +type gatewayListNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayListNewResponseEnvelopeSuccess bool + +const ( + GatewayListNewResponseEnvelopeSuccessTrue GatewayListNewResponseEnvelopeSuccess = true +) + +type GatewayListUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // The name of the list. + Name param.Field[string] `json:"name,required"` + // The description of the list. + Description param.Field[string] `json:"description"` +} + +func (r GatewayListUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayListUpdateResponseEnvelope struct { + Errors []GatewayListUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayListUpdateResponseEnvelopeMessages `json:"messages,required"` + Result ZeroTrustGatewayLists `json:"result,required"` + // Whether the API call was successful + Success GatewayListUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayListUpdateResponseEnvelopeJSON `json:"-"` +} + +// gatewayListUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayListUpdateResponseEnvelope] +type gatewayListUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayListUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayListUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayListUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GatewayListUpdateResponseEnvelopeErrors] +type gatewayListUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayListUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayListUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayListUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [GatewayListUpdateResponseEnvelopeMessages] +type gatewayListUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayListUpdateResponseEnvelopeSuccess bool + +const ( + GatewayListUpdateResponseEnvelopeSuccessTrue GatewayListUpdateResponseEnvelopeSuccess = true +) + +type GatewayListListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type GatewayListListResponseEnvelope struct { + Errors []GatewayListListResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayListListResponseEnvelopeMessages `json:"messages,required"` + Result []ZeroTrustGatewayLists `json:"result,required,nullable"` + // Whether the API call was successful + Success GatewayListListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo GatewayListListResponseEnvelopeResultInfo `json:"result_info"` + JSON gatewayListListResponseEnvelopeJSON `json:"-"` +} + +// gatewayListListResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayListListResponseEnvelope] +type gatewayListListResponseEnvelopeJSON 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 *GatewayListListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayListListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayListListResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayListListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GatewayListListResponseEnvelopeErrors] +type gatewayListListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayListListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayListListResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayListListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [GatewayListListResponseEnvelopeMessages] +type gatewayListListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayListListResponseEnvelopeSuccess bool + +const ( + GatewayListListResponseEnvelopeSuccessTrue GatewayListListResponseEnvelopeSuccess = true +) + +type GatewayListListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON gatewayListListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// gatewayListListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [GatewayListListResponseEnvelopeResultInfo] +type gatewayListListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type GatewayListDeleteParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type GatewayListDeleteResponseEnvelope struct { + Errors []GatewayListDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayListDeleteResponseEnvelopeMessages `json:"messages,required"` + Result GatewayListDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success GatewayListDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayListDeleteResponseEnvelopeJSON `json:"-"` +} + +// gatewayListDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayListDeleteResponseEnvelope] +type gatewayListDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayListDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayListDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayListDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GatewayListDeleteResponseEnvelopeErrors] +type gatewayListDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayListDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayListDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayListDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [GatewayListDeleteResponseEnvelopeMessages] +type gatewayListDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayListDeleteResponseEnvelopeSuccess bool + +const ( + GatewayListDeleteResponseEnvelopeSuccessTrue GatewayListDeleteResponseEnvelopeSuccess = true +) + +type GatewayListEditParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // The items in the list. + Append param.Field[[]GatewayListEditParamsAppend] `json:"append"` + // A list of the item values you want to remove. + Remove param.Field[[]string] `json:"remove"` +} + +func (r GatewayListEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayListEditParamsAppend struct { + // The value of the item in a list. + Value param.Field[string] `json:"value"` +} + +func (r GatewayListEditParamsAppend) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayListEditResponseEnvelope struct { + Errors []GatewayListEditResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayListEditResponseEnvelopeMessages `json:"messages,required"` + Result ZeroTrustGatewayLists `json:"result,required"` + // Whether the API call was successful + Success GatewayListEditResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayListEditResponseEnvelopeJSON `json:"-"` +} + +// gatewayListEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayListEditResponseEnvelope] +type gatewayListEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayListEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayListEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayListEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GatewayListEditResponseEnvelopeErrors] +type gatewayListEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayListEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayListEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayListEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [GatewayListEditResponseEnvelopeMessages] +type gatewayListEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayListEditResponseEnvelopeSuccess bool + +const ( + GatewayListEditResponseEnvelopeSuccessTrue GatewayListEditResponseEnvelopeSuccess = true +) + +type GatewayListGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type GatewayListGetResponseEnvelope struct { + Errors []GatewayListGetResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayListGetResponseEnvelopeMessages `json:"messages,required"` + Result ZeroTrustGatewayLists `json:"result,required"` + // Whether the API call was successful + Success GatewayListGetResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayListGetResponseEnvelopeJSON `json:"-"` +} + +// gatewayListGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayListGetResponseEnvelope] +type gatewayListGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayListGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayListGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayListGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GatewayListGetResponseEnvelopeErrors] +type gatewayListGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayListGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayListGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayListGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [GatewayListGetResponseEnvelopeMessages] +type gatewayListGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayListGetResponseEnvelopeSuccess bool + +const ( + GatewayListGetResponseEnvelopeSuccessTrue GatewayListGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/gatewaylist_test.go b/zero_trust/gatewaylist_test.go new file mode 100644 index 00000000000..6c215232b67 --- /dev/null +++ b/zero_trust/gatewaylist_test.go @@ -0,0 +1,207 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestGatewayListNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Lists.New(context.TODO(), zero_trust.GatewayListNewParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Name: cloudflare.F("Admin Serial Numbers"), + Type: cloudflare.F(zero_trust.GatewayListNewParamsTypeSerial), + Description: cloudflare.F("The serial numbers for administrators"), + Items: cloudflare.F([]zero_trust.GatewayListNewParamsItem{{ + Value: cloudflare.F("8GE8721REF"), + }, { + Value: cloudflare.F("8GE8721REF"), + }, { + Value: cloudflare.F("8GE8721REF"), + }}), + }) + 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 TestGatewayListUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Lists.Update( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.GatewayListUpdateParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Name: cloudflare.F("Admin Serial Numbers"), + Description: cloudflare.F("The serial numbers for administrators"), + }, + ) + 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 TestGatewayListList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Lists.List(context.TODO(), zero_trust.GatewayListListParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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 TestGatewayListDelete(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Lists.Delete( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.GatewayListDeleteParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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 TestGatewayListEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Lists.Edit( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.GatewayListEditParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Append: cloudflare.F([]zero_trust.GatewayListEditParamsAppend{{ + Value: cloudflare.F("8GE8721REF"), + }, { + Value: cloudflare.F("8GE8721REF"), + }, { + Value: cloudflare.F("8GE8721REF"), + }}), + Remove: cloudflare.F([]string{"8GE8721REF", "8GE8721REF", "8GE8721REF"}), + }, + ) + 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 TestGatewayListGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Lists.Get( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.GatewayListGetParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/gatewaylistitem.go b/zero_trust/gatewaylistitem.go new file mode 100644 index 00000000000..f7a005fcc0a --- /dev/null +++ b/zero_trust/gatewaylistitem.go @@ -0,0 +1,188 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// GatewayListItemService 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 [NewGatewayListItemService] method +// instead. +type GatewayListItemService struct { + Options []option.RequestOption +} + +// NewGatewayListItemService 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 NewGatewayListItemService(opts ...option.RequestOption) (r *GatewayListItemService) { + r = &GatewayListItemService{} + r.Options = opts + return +} + +// Fetches all items in a single Zero Trust list. +func (r *GatewayListItemService) List(ctx context.Context, listID string, query GatewayListItemListParams, opts ...option.RequestOption) (res *[][]GatewayListItemListResponse, err error) { + opts = append(r.Options[:], opts...) + var env GatewayListItemListResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/lists/%s/items", query.AccountID, listID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type GatewayListItemListResponse struct { + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The value of the item in a list. + Value string `json:"value"` + JSON gatewayListItemListResponseJSON `json:"-"` +} + +// gatewayListItemListResponseJSON contains the JSON metadata for the struct +// [GatewayListItemListResponse] +type gatewayListItemListResponseJSON struct { + CreatedAt apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListItemListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListItemListResponseJSON) RawJSON() string { + return r.raw +} + +type GatewayListItemListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type GatewayListItemListResponseEnvelope struct { + Errors []GatewayListItemListResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayListItemListResponseEnvelopeMessages `json:"messages,required"` + Result [][]GatewayListItemListResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success GatewayListItemListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo GatewayListItemListResponseEnvelopeResultInfo `json:"result_info"` + JSON gatewayListItemListResponseEnvelopeJSON `json:"-"` +} + +// gatewayListItemListResponseEnvelopeJSON contains the JSON metadata for the +// struct [GatewayListItemListResponseEnvelope] +type gatewayListItemListResponseEnvelopeJSON 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 *GatewayListItemListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListItemListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayListItemListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayListItemListResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayListItemListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GatewayListItemListResponseEnvelopeErrors] +type gatewayListItemListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListItemListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListItemListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayListItemListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayListItemListResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayListItemListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [GatewayListItemListResponseEnvelopeMessages] +type gatewayListItemListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListItemListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListItemListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayListItemListResponseEnvelopeSuccess bool + +const ( + GatewayListItemListResponseEnvelopeSuccessTrue GatewayListItemListResponseEnvelopeSuccess = true +) + +type GatewayListItemListResponseEnvelopeResultInfo struct { + // Total results returned based on your search parameters. + Count float64 `json:"count"` + // Current page within paginated list of results. + Page float64 `json:"page"` + // Number of results per page of results. + PerPage float64 `json:"per_page"` + // Total results available without any search parameters. + TotalCount float64 `json:"total_count"` + JSON gatewayListItemListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// gatewayListItemListResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [GatewayListItemListResponseEnvelopeResultInfo] +type gatewayListItemListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayListItemListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayListItemListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/gatewaylistitem_test.go b/zero_trust/gatewaylistitem_test.go new file mode 100644 index 00000000000..50d056c1981 --- /dev/null +++ b/zero_trust/gatewaylistitem_test.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestGatewayListItemList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Lists.Items.List( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.GatewayListItemListParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/gatewaylocation.go b/zero_trust/gatewaylocation.go new file mode 100644 index 00000000000..948bcfd85f1 --- /dev/null +++ b/zero_trust/gatewaylocation.go @@ -0,0 +1,686 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// GatewayLocationService 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 [NewGatewayLocationService] method +// instead. +type GatewayLocationService struct { + Options []option.RequestOption +} + +// NewGatewayLocationService 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 NewGatewayLocationService(opts ...option.RequestOption) (r *GatewayLocationService) { + r = &GatewayLocationService{} + r.Options = opts + return +} + +// Creates a new Zero Trust Gateway location. +func (r *GatewayLocationService) New(ctx context.Context, params GatewayLocationNewParams, opts ...option.RequestOption) (res *ZeroTrustGatewayLocations, err error) { + opts = append(r.Options[:], opts...) + var env GatewayLocationNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/locations", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a configured Zero Trust Gateway location. +func (r *GatewayLocationService) Update(ctx context.Context, locationID interface{}, params GatewayLocationUpdateParams, opts ...option.RequestOption) (res *ZeroTrustGatewayLocations, err error) { + opts = append(r.Options[:], opts...) + var env GatewayLocationUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/locations/%v", params.AccountID, locationID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches Zero Trust Gateway locations for an account. +func (r *GatewayLocationService) List(ctx context.Context, query GatewayLocationListParams, opts ...option.RequestOption) (res *[]ZeroTrustGatewayLocations, err error) { + opts = append(r.Options[:], opts...) + var env GatewayLocationListResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/locations", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a configured Zero Trust Gateway location. +func (r *GatewayLocationService) Delete(ctx context.Context, locationID interface{}, body GatewayLocationDeleteParams, opts ...option.RequestOption) (res *GatewayLocationDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env GatewayLocationDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/locations/%v", body.AccountID, locationID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a single Zero Trust Gateway location. +func (r *GatewayLocationService) Get(ctx context.Context, locationID interface{}, query GatewayLocationGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewayLocations, err error) { + opts = append(r.Options[:], opts...) + var env GatewayLocationGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/locations/%v", query.AccountID, locationID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ZeroTrustGatewayLocations struct { + ID interface{} `json:"id"` + // True if the location is the default location. + ClientDefault bool `json:"client_default"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // The DNS over HTTPS domain to send DNS requests to. This field is auto-generated + // by Gateway. + DohSubdomain string `json:"doh_subdomain"` + // True if the location needs to resolve EDNS queries. + EcsSupport bool `json:"ecs_support"` + // IPV6 destination ip assigned to this location. DNS requests sent to this IP will + // counted as the request under this location. This field is auto-generated by + // Gateway. + IP string `json:"ip"` + // The name of the location. + Name string `json:"name"` + // A list of network ranges that requests from this location would originate from. + Networks []ZeroTrustGatewayLocationsNetwork `json:"networks"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON zeroTrustGatewayLocationsJSON `json:"-"` +} + +// zeroTrustGatewayLocationsJSON contains the JSON metadata for the struct +// [ZeroTrustGatewayLocations] +type zeroTrustGatewayLocationsJSON struct { + ID apijson.Field + ClientDefault apijson.Field + CreatedAt apijson.Field + DohSubdomain apijson.Field + EcsSupport apijson.Field + IP apijson.Field + Name apijson.Field + Networks apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayLocations) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayLocationsJSON) RawJSON() string { + return r.raw +} + +type ZeroTrustGatewayLocationsNetwork struct { + // The IPv4 address or IPv4 CIDR. IPv4 CIDRs are limited to a maximum of /24. + Network string `json:"network,required"` + JSON zeroTrustGatewayLocationsNetworkJSON `json:"-"` +} + +// zeroTrustGatewayLocationsNetworkJSON contains the JSON metadata for the struct +// [ZeroTrustGatewayLocationsNetwork] +type zeroTrustGatewayLocationsNetworkJSON struct { + Network apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayLocationsNetwork) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayLocationsNetworkJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [zero_trust.GatewayLocationDeleteResponseUnknown] or +// [shared.UnionString]. +type GatewayLocationDeleteResponse interface { + ImplementsZeroTrustGatewayLocationDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*GatewayLocationDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type GatewayLocationNewParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // The name of the location. + Name param.Field[string] `json:"name,required"` + // True if the location is the default location. + ClientDefault param.Field[bool] `json:"client_default"` + // True if the location needs to resolve EDNS queries. + EcsSupport param.Field[bool] `json:"ecs_support"` + // A list of network ranges that requests from this location would originate from. + Networks param.Field[[]GatewayLocationNewParamsNetwork] `json:"networks"` +} + +func (r GatewayLocationNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayLocationNewParamsNetwork struct { + // The IPv4 address or IPv4 CIDR. IPv4 CIDRs are limited to a maximum of /24. + Network param.Field[string] `json:"network,required"` +} + +func (r GatewayLocationNewParamsNetwork) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayLocationNewResponseEnvelope struct { + Errors []GatewayLocationNewResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayLocationNewResponseEnvelopeMessages `json:"messages,required"` + Result ZeroTrustGatewayLocations `json:"result,required"` + // Whether the API call was successful + Success GatewayLocationNewResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayLocationNewResponseEnvelopeJSON `json:"-"` +} + +// gatewayLocationNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayLocationNewResponseEnvelope] +type gatewayLocationNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLocationNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLocationNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayLocationNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayLocationNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayLocationNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GatewayLocationNewResponseEnvelopeErrors] +type gatewayLocationNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLocationNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLocationNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayLocationNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayLocationNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayLocationNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [GatewayLocationNewResponseEnvelopeMessages] +type gatewayLocationNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLocationNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLocationNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayLocationNewResponseEnvelopeSuccess bool + +const ( + GatewayLocationNewResponseEnvelopeSuccessTrue GatewayLocationNewResponseEnvelopeSuccess = true +) + +type GatewayLocationUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // The name of the location. + Name param.Field[string] `json:"name,required"` + // True if the location is the default location. + ClientDefault param.Field[bool] `json:"client_default"` + // True if the location needs to resolve EDNS queries. + EcsSupport param.Field[bool] `json:"ecs_support"` + // A list of network ranges that requests from this location would originate from. + Networks param.Field[[]GatewayLocationUpdateParamsNetwork] `json:"networks"` +} + +func (r GatewayLocationUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayLocationUpdateParamsNetwork struct { + // The IPv4 address or IPv4 CIDR. IPv4 CIDRs are limited to a maximum of /24. + Network param.Field[string] `json:"network,required"` +} + +func (r GatewayLocationUpdateParamsNetwork) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayLocationUpdateResponseEnvelope struct { + Errors []GatewayLocationUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayLocationUpdateResponseEnvelopeMessages `json:"messages,required"` + Result ZeroTrustGatewayLocations `json:"result,required"` + // Whether the API call was successful + Success GatewayLocationUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayLocationUpdateResponseEnvelopeJSON `json:"-"` +} + +// gatewayLocationUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [GatewayLocationUpdateResponseEnvelope] +type gatewayLocationUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLocationUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLocationUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayLocationUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayLocationUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayLocationUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [GatewayLocationUpdateResponseEnvelopeErrors] +type gatewayLocationUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLocationUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLocationUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayLocationUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayLocationUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayLocationUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [GatewayLocationUpdateResponseEnvelopeMessages] +type gatewayLocationUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLocationUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLocationUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayLocationUpdateResponseEnvelopeSuccess bool + +const ( + GatewayLocationUpdateResponseEnvelopeSuccessTrue GatewayLocationUpdateResponseEnvelopeSuccess = true +) + +type GatewayLocationListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type GatewayLocationListResponseEnvelope struct { + Errors []GatewayLocationListResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayLocationListResponseEnvelopeMessages `json:"messages,required"` + Result []ZeroTrustGatewayLocations `json:"result,required,nullable"` + // Whether the API call was successful + Success GatewayLocationListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo GatewayLocationListResponseEnvelopeResultInfo `json:"result_info"` + JSON gatewayLocationListResponseEnvelopeJSON `json:"-"` +} + +// gatewayLocationListResponseEnvelopeJSON contains the JSON metadata for the +// struct [GatewayLocationListResponseEnvelope] +type gatewayLocationListResponseEnvelopeJSON 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 *GatewayLocationListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLocationListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayLocationListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayLocationListResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayLocationListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GatewayLocationListResponseEnvelopeErrors] +type gatewayLocationListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLocationListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLocationListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayLocationListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayLocationListResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayLocationListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [GatewayLocationListResponseEnvelopeMessages] +type gatewayLocationListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLocationListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLocationListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayLocationListResponseEnvelopeSuccess bool + +const ( + GatewayLocationListResponseEnvelopeSuccessTrue GatewayLocationListResponseEnvelopeSuccess = true +) + +type GatewayLocationListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON gatewayLocationListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// gatewayLocationListResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [GatewayLocationListResponseEnvelopeResultInfo] +type gatewayLocationListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLocationListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLocationListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type GatewayLocationDeleteParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type GatewayLocationDeleteResponseEnvelope struct { + Errors []GatewayLocationDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayLocationDeleteResponseEnvelopeMessages `json:"messages,required"` + Result GatewayLocationDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success GatewayLocationDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayLocationDeleteResponseEnvelopeJSON `json:"-"` +} + +// gatewayLocationDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [GatewayLocationDeleteResponseEnvelope] +type gatewayLocationDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLocationDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLocationDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayLocationDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayLocationDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayLocationDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [GatewayLocationDeleteResponseEnvelopeErrors] +type gatewayLocationDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLocationDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLocationDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayLocationDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayLocationDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayLocationDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [GatewayLocationDeleteResponseEnvelopeMessages] +type gatewayLocationDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLocationDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLocationDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayLocationDeleteResponseEnvelopeSuccess bool + +const ( + GatewayLocationDeleteResponseEnvelopeSuccessTrue GatewayLocationDeleteResponseEnvelopeSuccess = true +) + +type GatewayLocationGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type GatewayLocationGetResponseEnvelope struct { + Errors []GatewayLocationGetResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayLocationGetResponseEnvelopeMessages `json:"messages,required"` + Result ZeroTrustGatewayLocations `json:"result,required"` + // Whether the API call was successful + Success GatewayLocationGetResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayLocationGetResponseEnvelopeJSON `json:"-"` +} + +// gatewayLocationGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayLocationGetResponseEnvelope] +type gatewayLocationGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLocationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLocationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayLocationGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayLocationGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayLocationGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GatewayLocationGetResponseEnvelopeErrors] +type gatewayLocationGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLocationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLocationGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayLocationGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayLocationGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayLocationGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [GatewayLocationGetResponseEnvelopeMessages] +type gatewayLocationGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLocationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLocationGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayLocationGetResponseEnvelopeSuccess bool + +const ( + GatewayLocationGetResponseEnvelopeSuccessTrue GatewayLocationGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/gatewaylocation_test.go b/zero_trust/gatewaylocation_test.go new file mode 100644 index 00000000000..c370ead099d --- /dev/null +++ b/zero_trust/gatewaylocation_test.go @@ -0,0 +1,177 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestGatewayLocationNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Locations.New(context.TODO(), zero_trust.GatewayLocationNewParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Name: cloudflare.F("Austin Office Location"), + ClientDefault: cloudflare.F(false), + EcsSupport: cloudflare.F(false), + Networks: cloudflare.F([]zero_trust.GatewayLocationNewParamsNetwork{{ + Network: cloudflare.F("192.0.2.1/32"), + }, { + Network: cloudflare.F("192.0.2.1/32"), + }, { + Network: cloudflare.F("192.0.2.1/32"), + }}), + }) + 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 TestGatewayLocationUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Locations.Update( + context.TODO(), + "ed35569b41ce4d1facfe683550f54086", + zero_trust.GatewayLocationUpdateParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Name: cloudflare.F("Austin Office Location"), + ClientDefault: cloudflare.F(false), + EcsSupport: cloudflare.F(false), + Networks: cloudflare.F([]zero_trust.GatewayLocationUpdateParamsNetwork{{ + Network: cloudflare.F("192.0.2.1/32"), + }, { + Network: cloudflare.F("192.0.2.1/32"), + }, { + Network: cloudflare.F("192.0.2.1/32"), + }}), + }, + ) + 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 TestGatewayLocationList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Locations.List(context.TODO(), zero_trust.GatewayLocationListParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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 TestGatewayLocationDelete(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Locations.Delete( + context.TODO(), + "ed35569b41ce4d1facfe683550f54086", + zero_trust.GatewayLocationDeleteParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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 TestGatewayLocationGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Locations.Get( + context.TODO(), + "ed35569b41ce4d1facfe683550f54086", + zero_trust.GatewayLocationGetParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/gatewaylogging.go b/zero_trust/gatewaylogging.go new file mode 100644 index 00000000000..375f635961e --- /dev/null +++ b/zero_trust/gatewaylogging.go @@ -0,0 +1,307 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// GatewayLoggingService 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 [NewGatewayLoggingService] method +// instead. +type GatewayLoggingService struct { + Options []option.RequestOption +} + +// NewGatewayLoggingService 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 NewGatewayLoggingService(opts ...option.RequestOption) (r *GatewayLoggingService) { + r = &GatewayLoggingService{} + r.Options = opts + return +} + +// Updates logging settings for the current Zero Trust account. +func (r *GatewayLoggingService) Update(ctx context.Context, params GatewayLoggingUpdateParams, opts ...option.RequestOption) (res *ZeroTrustGatewayGatewayAccountLoggingSettings, err error) { + opts = append(r.Options[:], opts...) + var env GatewayLoggingUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/logging", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the current logging settings for Zero Trust account. +func (r *GatewayLoggingService) Get(ctx context.Context, query GatewayLoggingGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewayGatewayAccountLoggingSettings, err error) { + opts = append(r.Options[:], opts...) + var env GatewayLoggingGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/logging", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ZeroTrustGatewayGatewayAccountLoggingSettings struct { + // Redact personally identifiable information from activity logging (PII fields + // are: source IP, user email, user ID, device ID, URL, referrer, user agent). + RedactPii bool `json:"redact_pii"` + // Logging settings by rule type. + SettingsByRuleType ZeroTrustGatewayGatewayAccountLoggingSettingsSettingsByRuleType `json:"settings_by_rule_type"` + JSON zeroTrustGatewayGatewayAccountLoggingSettingsJSON `json:"-"` +} + +// zeroTrustGatewayGatewayAccountLoggingSettingsJSON contains the JSON metadata for +// the struct [ZeroTrustGatewayGatewayAccountLoggingSettings] +type zeroTrustGatewayGatewayAccountLoggingSettingsJSON struct { + RedactPii apijson.Field + SettingsByRuleType apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayGatewayAccountLoggingSettings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayGatewayAccountLoggingSettingsJSON) RawJSON() string { + return r.raw +} + +// Logging settings by rule type. +type ZeroTrustGatewayGatewayAccountLoggingSettingsSettingsByRuleType struct { + // Logging settings for DNS firewall. + DNS interface{} `json:"dns"` + // Logging settings for HTTP/HTTPS firewall. + HTTP interface{} `json:"http"` + // Logging settings for Network firewall. + L4 interface{} `json:"l4"` + JSON zeroTrustGatewayGatewayAccountLoggingSettingsSettingsByRuleTypeJSON `json:"-"` +} + +// zeroTrustGatewayGatewayAccountLoggingSettingsSettingsByRuleTypeJSON contains the +// JSON metadata for the struct +// [ZeroTrustGatewayGatewayAccountLoggingSettingsSettingsByRuleType] +type zeroTrustGatewayGatewayAccountLoggingSettingsSettingsByRuleTypeJSON struct { + DNS apijson.Field + HTTP apijson.Field + L4 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayGatewayAccountLoggingSettingsSettingsByRuleType) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayGatewayAccountLoggingSettingsSettingsByRuleTypeJSON) RawJSON() string { + return r.raw +} + +type GatewayLoggingUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // Redact personally identifiable information from activity logging (PII fields + // are: source IP, user email, user ID, device ID, URL, referrer, user agent). + RedactPii param.Field[bool] `json:"redact_pii"` + // Logging settings by rule type. + SettingsByRuleType param.Field[GatewayLoggingUpdateParamsSettingsByRuleType] `json:"settings_by_rule_type"` +} + +func (r GatewayLoggingUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Logging settings by rule type. +type GatewayLoggingUpdateParamsSettingsByRuleType struct { + // Logging settings for DNS firewall. + DNS param.Field[interface{}] `json:"dns"` + // Logging settings for HTTP/HTTPS firewall. + HTTP param.Field[interface{}] `json:"http"` + // Logging settings for Network firewall. + L4 param.Field[interface{}] `json:"l4"` +} + +func (r GatewayLoggingUpdateParamsSettingsByRuleType) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayLoggingUpdateResponseEnvelope struct { + Errors []GatewayLoggingUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayLoggingUpdateResponseEnvelopeMessages `json:"messages,required"` + Result ZeroTrustGatewayGatewayAccountLoggingSettings `json:"result,required"` + // Whether the API call was successful + Success GatewayLoggingUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayLoggingUpdateResponseEnvelopeJSON `json:"-"` +} + +// gatewayLoggingUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [GatewayLoggingUpdateResponseEnvelope] +type gatewayLoggingUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLoggingUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLoggingUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayLoggingUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayLoggingUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayLoggingUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [GatewayLoggingUpdateResponseEnvelopeErrors] +type gatewayLoggingUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLoggingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLoggingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayLoggingUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayLoggingUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayLoggingUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [GatewayLoggingUpdateResponseEnvelopeMessages] +type gatewayLoggingUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLoggingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLoggingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayLoggingUpdateResponseEnvelopeSuccess bool + +const ( + GatewayLoggingUpdateResponseEnvelopeSuccessTrue GatewayLoggingUpdateResponseEnvelopeSuccess = true +) + +type GatewayLoggingGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type GatewayLoggingGetResponseEnvelope struct { + Errors []GatewayLoggingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayLoggingGetResponseEnvelopeMessages `json:"messages,required"` + Result ZeroTrustGatewayGatewayAccountLoggingSettings `json:"result,required"` + // Whether the API call was successful + Success GatewayLoggingGetResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayLoggingGetResponseEnvelopeJSON `json:"-"` +} + +// gatewayLoggingGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayLoggingGetResponseEnvelope] +type gatewayLoggingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLoggingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLoggingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayLoggingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayLoggingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayLoggingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GatewayLoggingGetResponseEnvelopeErrors] +type gatewayLoggingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLoggingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLoggingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayLoggingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayLoggingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayLoggingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [GatewayLoggingGetResponseEnvelopeMessages] +type gatewayLoggingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayLoggingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayLoggingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayLoggingGetResponseEnvelopeSuccess bool + +const ( + GatewayLoggingGetResponseEnvelopeSuccessTrue GatewayLoggingGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/gatewaylogging_test.go b/zero_trust/gatewaylogging_test.go new file mode 100644 index 00000000000..2c355ca7485 --- /dev/null +++ b/zero_trust/gatewaylogging_test.go @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestGatewayLoggingUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Loggings.Update(context.TODO(), zero_trust.GatewayLoggingUpdateParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + RedactPii: cloudflare.F(true), + SettingsByRuleType: cloudflare.F(zero_trust.GatewayLoggingUpdateParamsSettingsByRuleType{ + DNS: cloudflare.F[any](map[string]interface{}{}), + HTTP: cloudflare.F[any](map[string]interface{}{}), + L4: cloudflare.F[any](map[string]interface{}{}), + }), + }) + 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 TestGatewayLoggingGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Loggings.Get(context.TODO(), zero_trust.GatewayLoggingGetParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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/zero_trust/gatewayproxyendpoint.go b/zero_trust/gatewayproxyendpoint.go new file mode 100644 index 00000000000..89b1ea3b192 --- /dev/null +++ b/zero_trust/gatewayproxyendpoint.go @@ -0,0 +1,630 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// GatewayProxyEndpointService 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 [NewGatewayProxyEndpointService] +// method instead. +type GatewayProxyEndpointService struct { + Options []option.RequestOption +} + +// NewGatewayProxyEndpointService 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 NewGatewayProxyEndpointService(opts ...option.RequestOption) (r *GatewayProxyEndpointService) { + r = &GatewayProxyEndpointService{} + r.Options = opts + return +} + +// Creates a new Zero Trust Gateway proxy endpoint. +func (r *GatewayProxyEndpointService) New(ctx context.Context, params GatewayProxyEndpointNewParams, opts ...option.RequestOption) (res *ZeroTrustGatewayProxyEndpoints, err error) { + opts = append(r.Options[:], opts...) + var env GatewayProxyEndpointNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/proxy_endpoints", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a single Zero Trust Gateway proxy endpoint. +func (r *GatewayProxyEndpointService) List(ctx context.Context, query GatewayProxyEndpointListParams, opts ...option.RequestOption) (res *[]ZeroTrustGatewayProxyEndpoints, err error) { + opts = append(r.Options[:], opts...) + var env GatewayProxyEndpointListResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/proxy_endpoints", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a configured Zero Trust Gateway proxy endpoint. +func (r *GatewayProxyEndpointService) Delete(ctx context.Context, proxyEndpointID interface{}, body GatewayProxyEndpointDeleteParams, opts ...option.RequestOption) (res *GatewayProxyEndpointDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env GatewayProxyEndpointDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/proxy_endpoints/%v", body.AccountID, proxyEndpointID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a configured Zero Trust Gateway proxy endpoint. +func (r *GatewayProxyEndpointService) Edit(ctx context.Context, proxyEndpointID interface{}, params GatewayProxyEndpointEditParams, opts ...option.RequestOption) (res *ZeroTrustGatewayProxyEndpoints, err error) { + opts = append(r.Options[:], opts...) + var env GatewayProxyEndpointEditResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/proxy_endpoints/%v", params.AccountID, proxyEndpointID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches all Zero Trust Gateway proxy endpoints for an account. +func (r *GatewayProxyEndpointService) Get(ctx context.Context, proxyEndpointID interface{}, query GatewayProxyEndpointGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewayProxyEndpoints, err error) { + opts = append(r.Options[:], opts...) + var env GatewayProxyEndpointGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/proxy_endpoints/%v", query.AccountID, proxyEndpointID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ZeroTrustGatewayProxyEndpoints struct { + ID interface{} `json:"id"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // A list of CIDRs to restrict ingress connections. + IPs []string `json:"ips"` + // The name of the proxy endpoint. + Name string `json:"name"` + // The subdomain to be used as the destination in the proxy client. + Subdomain string `json:"subdomain"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON zeroTrustGatewayProxyEndpointsJSON `json:"-"` +} + +// zeroTrustGatewayProxyEndpointsJSON contains the JSON metadata for the struct +// [ZeroTrustGatewayProxyEndpoints] +type zeroTrustGatewayProxyEndpointsJSON struct { + ID apijson.Field + CreatedAt apijson.Field + IPs apijson.Field + Name apijson.Field + Subdomain apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayProxyEndpoints) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayProxyEndpointsJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [zero_trust.GatewayProxyEndpointDeleteResponseUnknown] or +// [shared.UnionString]. +type GatewayProxyEndpointDeleteResponse interface { + ImplementsZeroTrustGatewayProxyEndpointDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*GatewayProxyEndpointDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type GatewayProxyEndpointNewParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // A list of CIDRs to restrict ingress connections. + IPs param.Field[[]string] `json:"ips,required"` + // The name of the proxy endpoint. + Name param.Field[string] `json:"name,required"` + // The subdomain to be used as the destination in the proxy client. + Subdomain param.Field[string] `json:"subdomain"` +} + +func (r GatewayProxyEndpointNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayProxyEndpointNewResponseEnvelope struct { + Errors []GatewayProxyEndpointNewResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayProxyEndpointNewResponseEnvelopeMessages `json:"messages,required"` + Result ZeroTrustGatewayProxyEndpoints `json:"result,required"` + // Whether the API call was successful + Success GatewayProxyEndpointNewResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayProxyEndpointNewResponseEnvelopeJSON `json:"-"` +} + +// gatewayProxyEndpointNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [GatewayProxyEndpointNewResponseEnvelope] +type gatewayProxyEndpointNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayProxyEndpointNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayProxyEndpointNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayProxyEndpointNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayProxyEndpointNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayProxyEndpointNewResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [GatewayProxyEndpointNewResponseEnvelopeErrors] +type gatewayProxyEndpointNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayProxyEndpointNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayProxyEndpointNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayProxyEndpointNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayProxyEndpointNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayProxyEndpointNewResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [GatewayProxyEndpointNewResponseEnvelopeMessages] +type gatewayProxyEndpointNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayProxyEndpointNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayProxyEndpointNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayProxyEndpointNewResponseEnvelopeSuccess bool + +const ( + GatewayProxyEndpointNewResponseEnvelopeSuccessTrue GatewayProxyEndpointNewResponseEnvelopeSuccess = true +) + +type GatewayProxyEndpointListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type GatewayProxyEndpointListResponseEnvelope struct { + Errors []GatewayProxyEndpointListResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayProxyEndpointListResponseEnvelopeMessages `json:"messages,required"` + Result []ZeroTrustGatewayProxyEndpoints `json:"result,required,nullable"` + // Whether the API call was successful + Success GatewayProxyEndpointListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo GatewayProxyEndpointListResponseEnvelopeResultInfo `json:"result_info"` + JSON gatewayProxyEndpointListResponseEnvelopeJSON `json:"-"` +} + +// gatewayProxyEndpointListResponseEnvelopeJSON contains the JSON metadata for the +// struct [GatewayProxyEndpointListResponseEnvelope] +type gatewayProxyEndpointListResponseEnvelopeJSON 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 *GatewayProxyEndpointListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayProxyEndpointListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayProxyEndpointListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayProxyEndpointListResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayProxyEndpointListResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [GatewayProxyEndpointListResponseEnvelopeErrors] +type gatewayProxyEndpointListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayProxyEndpointListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayProxyEndpointListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayProxyEndpointListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayProxyEndpointListResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayProxyEndpointListResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [GatewayProxyEndpointListResponseEnvelopeMessages] +type gatewayProxyEndpointListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayProxyEndpointListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayProxyEndpointListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayProxyEndpointListResponseEnvelopeSuccess bool + +const ( + GatewayProxyEndpointListResponseEnvelopeSuccessTrue GatewayProxyEndpointListResponseEnvelopeSuccess = true +) + +type GatewayProxyEndpointListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON gatewayProxyEndpointListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// gatewayProxyEndpointListResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [GatewayProxyEndpointListResponseEnvelopeResultInfo] +type gatewayProxyEndpointListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayProxyEndpointListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayProxyEndpointListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type GatewayProxyEndpointDeleteParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type GatewayProxyEndpointDeleteResponseEnvelope struct { + Errors []GatewayProxyEndpointDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayProxyEndpointDeleteResponseEnvelopeMessages `json:"messages,required"` + Result GatewayProxyEndpointDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success GatewayProxyEndpointDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayProxyEndpointDeleteResponseEnvelopeJSON `json:"-"` +} + +// gatewayProxyEndpointDeleteResponseEnvelopeJSON contains the JSON metadata for +// the struct [GatewayProxyEndpointDeleteResponseEnvelope] +type gatewayProxyEndpointDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayProxyEndpointDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayProxyEndpointDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayProxyEndpointDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayProxyEndpointDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayProxyEndpointDeleteResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [GatewayProxyEndpointDeleteResponseEnvelopeErrors] +type gatewayProxyEndpointDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayProxyEndpointDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayProxyEndpointDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayProxyEndpointDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayProxyEndpointDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayProxyEndpointDeleteResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [GatewayProxyEndpointDeleteResponseEnvelopeMessages] +type gatewayProxyEndpointDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayProxyEndpointDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayProxyEndpointDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayProxyEndpointDeleteResponseEnvelopeSuccess bool + +const ( + GatewayProxyEndpointDeleteResponseEnvelopeSuccessTrue GatewayProxyEndpointDeleteResponseEnvelopeSuccess = true +) + +type GatewayProxyEndpointEditParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // A list of CIDRs to restrict ingress connections. + IPs param.Field[[]string] `json:"ips"` + // The name of the proxy endpoint. + Name param.Field[string] `json:"name"` + // The subdomain to be used as the destination in the proxy client. + Subdomain param.Field[string] `json:"subdomain"` +} + +func (r GatewayProxyEndpointEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayProxyEndpointEditResponseEnvelope struct { + Errors []GatewayProxyEndpointEditResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayProxyEndpointEditResponseEnvelopeMessages `json:"messages,required"` + Result ZeroTrustGatewayProxyEndpoints `json:"result,required"` + // Whether the API call was successful + Success GatewayProxyEndpointEditResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayProxyEndpointEditResponseEnvelopeJSON `json:"-"` +} + +// gatewayProxyEndpointEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [GatewayProxyEndpointEditResponseEnvelope] +type gatewayProxyEndpointEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayProxyEndpointEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayProxyEndpointEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayProxyEndpointEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayProxyEndpointEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayProxyEndpointEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [GatewayProxyEndpointEditResponseEnvelopeErrors] +type gatewayProxyEndpointEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayProxyEndpointEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayProxyEndpointEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayProxyEndpointEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayProxyEndpointEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayProxyEndpointEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [GatewayProxyEndpointEditResponseEnvelopeMessages] +type gatewayProxyEndpointEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayProxyEndpointEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayProxyEndpointEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayProxyEndpointEditResponseEnvelopeSuccess bool + +const ( + GatewayProxyEndpointEditResponseEnvelopeSuccessTrue GatewayProxyEndpointEditResponseEnvelopeSuccess = true +) + +type GatewayProxyEndpointGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type GatewayProxyEndpointGetResponseEnvelope struct { + Errors []GatewayProxyEndpointGetResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayProxyEndpointGetResponseEnvelopeMessages `json:"messages,required"` + Result ZeroTrustGatewayProxyEndpoints `json:"result,required"` + // Whether the API call was successful + Success GatewayProxyEndpointGetResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayProxyEndpointGetResponseEnvelopeJSON `json:"-"` +} + +// gatewayProxyEndpointGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [GatewayProxyEndpointGetResponseEnvelope] +type gatewayProxyEndpointGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayProxyEndpointGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayProxyEndpointGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayProxyEndpointGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayProxyEndpointGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayProxyEndpointGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [GatewayProxyEndpointGetResponseEnvelopeErrors] +type gatewayProxyEndpointGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayProxyEndpointGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayProxyEndpointGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayProxyEndpointGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayProxyEndpointGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayProxyEndpointGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [GatewayProxyEndpointGetResponseEnvelopeMessages] +type gatewayProxyEndpointGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayProxyEndpointGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayProxyEndpointGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayProxyEndpointGetResponseEnvelopeSuccess bool + +const ( + GatewayProxyEndpointGetResponseEnvelopeSuccessTrue GatewayProxyEndpointGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/gatewayproxyendpoint_test.go b/zero_trust/gatewayproxyendpoint_test.go new file mode 100644 index 00000000000..569cea6050a --- /dev/null +++ b/zero_trust/gatewayproxyendpoint_test.go @@ -0,0 +1,163 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestGatewayProxyEndpointNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.ProxyEndpoints.New(context.TODO(), zero_trust.GatewayProxyEndpointNewParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + IPs: cloudflare.F([]string{"192.0.2.1/32", "192.0.2.1/32", "192.0.2.1/32"}), + Name: cloudflare.F("Devops team"), + Subdomain: cloudflare.F("oli3n9zkz5.proxy.cloudflare-gateway.com"), + }) + 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 TestGatewayProxyEndpointList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.ProxyEndpoints.List(context.TODO(), zero_trust.GatewayProxyEndpointListParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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 TestGatewayProxyEndpointDelete(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.ProxyEndpoints.Delete( + context.TODO(), + "ed35569b41ce4d1facfe683550f54086", + zero_trust.GatewayProxyEndpointDeleteParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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 TestGatewayProxyEndpointEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.ProxyEndpoints.Edit( + context.TODO(), + "ed35569b41ce4d1facfe683550f54086", + zero_trust.GatewayProxyEndpointEditParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + IPs: cloudflare.F([]string{"192.0.2.1/32", "192.0.2.1/32", "192.0.2.1/32"}), + Name: cloudflare.F("Devops team"), + Subdomain: cloudflare.F("oli3n9zkz5.proxy.cloudflare-gateway.com"), + }, + ) + 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 TestGatewayProxyEndpointGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.ProxyEndpoints.Get( + context.TODO(), + "ed35569b41ce4d1facfe683550f54086", + zero_trust.GatewayProxyEndpointGetParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/gatewayrule.go b/zero_trust/gatewayrule.go new file mode 100644 index 00000000000..81aa3d68651 --- /dev/null +++ b/zero_trust/gatewayrule.go @@ -0,0 +1,1808 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// GatewayRuleService 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 [NewGatewayRuleService] method +// instead. +type GatewayRuleService struct { + Options []option.RequestOption +} + +// NewGatewayRuleService 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 NewGatewayRuleService(opts ...option.RequestOption) (r *GatewayRuleService) { + r = &GatewayRuleService{} + r.Options = opts + return +} + +// Creates a new Zero Trust Gateway rule. +func (r *GatewayRuleService) New(ctx context.Context, params GatewayRuleNewParams, opts ...option.RequestOption) (res *ZeroTrustGatewayRules, err error) { + opts = append(r.Options[:], opts...) + var env GatewayRuleNewResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/rules", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a configured Zero Trust Gateway rule. +func (r *GatewayRuleService) Update(ctx context.Context, ruleID string, params GatewayRuleUpdateParams, opts ...option.RequestOption) (res *ZeroTrustGatewayRules, err error) { + opts = append(r.Options[:], opts...) + var env GatewayRuleUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/rules/%s", params.AccountID, ruleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches the Zero Trust Gateway rules for an account. +func (r *GatewayRuleService) List(ctx context.Context, query GatewayRuleListParams, opts ...option.RequestOption) (res *[]ZeroTrustGatewayRules, err error) { + opts = append(r.Options[:], opts...) + var env GatewayRuleListResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/rules", query.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a Zero Trust Gateway rule. +func (r *GatewayRuleService) Delete(ctx context.Context, ruleID string, body GatewayRuleDeleteParams, opts ...option.RequestOption) (res *GatewayRuleDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env GatewayRuleDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/rules/%s", body.AccountID, ruleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a single Zero Trust Gateway rule. +func (r *GatewayRuleService) Get(ctx context.Context, ruleID string, query GatewayRuleGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewayRules, err error) { + opts = append(r.Options[:], opts...) + var env GatewayRuleGetResponseEnvelope + path := fmt.Sprintf("accounts/%v/gateway/rules/%s", query.AccountID, ruleID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ZeroTrustGatewayRules struct { + // The API resource UUID. + ID string `json:"id"` + // The action to preform when the associated traffic, identity, and device posture + // expressions are either absent or evaluate to `true`. + Action ZeroTrustGatewayRulesAction `json:"action"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // Date of deletion, if any. + DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` + // The description of the rule. + Description string `json:"description"` + // The wirefilter expression used for device posture check matching. + DevicePosture string `json:"device_posture"` + // True if the rule is enabled. + Enabled bool `json:"enabled"` + // The protocol or layer to evaluate the traffic, identity, and device posture + // expressions. + Filters []ZeroTrustGatewayRulesFilter `json:"filters"` + // The wirefilter expression used for identity matching. + Identity string `json:"identity"` + // The name of the rule. + Name string `json:"name"` + // Precedence sets the order of your rules. Lower values indicate higher + // precedence. At each processing phase, applicable rules are evaluated in + // ascending order of this value. + Precedence int64 `json:"precedence"` + // Additional settings that modify the rule's action. + RuleSettings ZeroTrustGatewayRulesRuleSettings `json:"rule_settings"` + // The schedule for activating DNS policies. This does not apply to HTTP or network + // policies. + Schedule ZeroTrustGatewayRulesSchedule `json:"schedule"` + // The wirefilter expression used for traffic matching. + Traffic string `json:"traffic"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON zeroTrustGatewayRulesJSON `json:"-"` +} + +// zeroTrustGatewayRulesJSON contains the JSON metadata for the struct +// [ZeroTrustGatewayRules] +type zeroTrustGatewayRulesJSON struct { + ID apijson.Field + Action apijson.Field + CreatedAt apijson.Field + DeletedAt apijson.Field + Description apijson.Field + DevicePosture apijson.Field + Enabled apijson.Field + Filters apijson.Field + Identity apijson.Field + Name apijson.Field + Precedence apijson.Field + RuleSettings apijson.Field + Schedule apijson.Field + Traffic apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayRules) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayRulesJSON) RawJSON() string { + return r.raw +} + +// The action to preform when the associated traffic, identity, and device posture +// expressions are either absent or evaluate to `true`. +type ZeroTrustGatewayRulesAction string + +const ( + ZeroTrustGatewayRulesActionOn ZeroTrustGatewayRulesAction = "on" + ZeroTrustGatewayRulesActionOff ZeroTrustGatewayRulesAction = "off" + ZeroTrustGatewayRulesActionAllow ZeroTrustGatewayRulesAction = "allow" + ZeroTrustGatewayRulesActionBlock ZeroTrustGatewayRulesAction = "block" + ZeroTrustGatewayRulesActionScan ZeroTrustGatewayRulesAction = "scan" + ZeroTrustGatewayRulesActionNoscan ZeroTrustGatewayRulesAction = "noscan" + ZeroTrustGatewayRulesActionSafesearch ZeroTrustGatewayRulesAction = "safesearch" + ZeroTrustGatewayRulesActionYtrestricted ZeroTrustGatewayRulesAction = "ytrestricted" + ZeroTrustGatewayRulesActionIsolate ZeroTrustGatewayRulesAction = "isolate" + ZeroTrustGatewayRulesActionNoisolate ZeroTrustGatewayRulesAction = "noisolate" + ZeroTrustGatewayRulesActionOverride ZeroTrustGatewayRulesAction = "override" + ZeroTrustGatewayRulesActionL4Override ZeroTrustGatewayRulesAction = "l4_override" + ZeroTrustGatewayRulesActionEgress ZeroTrustGatewayRulesAction = "egress" + ZeroTrustGatewayRulesActionAuditSSH ZeroTrustGatewayRulesAction = "audit_ssh" +) + +// The protocol or layer to use. +type ZeroTrustGatewayRulesFilter string + +const ( + ZeroTrustGatewayRulesFilterHTTP ZeroTrustGatewayRulesFilter = "http" + ZeroTrustGatewayRulesFilterDNS ZeroTrustGatewayRulesFilter = "dns" + ZeroTrustGatewayRulesFilterL4 ZeroTrustGatewayRulesFilter = "l4" + ZeroTrustGatewayRulesFilterEgress ZeroTrustGatewayRulesFilter = "egress" +) + +// Additional settings that modify the rule's action. +type ZeroTrustGatewayRulesRuleSettings struct { + // Add custom headers to allowed requests, in the form of key-value pairs. Keys are + // header names, pointing to an array with its header value(s). + AddHeaders interface{} `json:"add_headers"` + // Set by parent MSP accounts to enable their children to bypass this rule. + AllowChildBypass bool `json:"allow_child_bypass"` + // Settings for the Audit SSH action. + AuditSSH ZeroTrustGatewayRulesRuleSettingsAuditSSH `json:"audit_ssh"` + // Configure how browser isolation behaves. + BisoAdminControls ZeroTrustGatewayRulesRuleSettingsBisoAdminControls `json:"biso_admin_controls"` + // Enable the custom block page. + BlockPageEnabled bool `json:"block_page_enabled"` + // The text describing why this block occurred, displayed on the custom block page + // (if enabled). + BlockReason string `json:"block_reason"` + // Set by children MSP accounts to bypass their parent's rules. + BypassParentRule bool `json:"bypass_parent_rule"` + // Configure how session check behaves. + CheckSession ZeroTrustGatewayRulesRuleSettingsCheckSession `json:"check_session"` + // Add your own custom resolvers to route queries that match the resolver policy. + // Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will + // route to the address closest to their origin. + DNSResolvers ZeroTrustGatewayRulesRuleSettingsDNSResolvers `json:"dns_resolvers"` + // Configure how Gateway Proxy traffic egresses. You can enable this setting for + // rules with Egress actions and filters, or omit it to indicate local egress via + // WARP IPs. + Egress ZeroTrustGatewayRulesRuleSettingsEgress `json:"egress"` + // INSECURE - disable DNSSEC validation (for Allow actions). + InsecureDisableDNSSECValidation bool `json:"insecure_disable_dnssec_validation"` + // Set to true to enable IPs in DNS resolver category blocks. By default categories + // only block based on domain names. + IPCategories bool `json:"ip_categories"` + // Set to true to include IPs in DNS resolver indicator feed blocks. By default + // indicator feeds only block based on domain names. + IPIndicatorFeeds bool `json:"ip_indicator_feeds"` + // Send matching traffic to the supplied destination IP address and port. + L4override ZeroTrustGatewayRulesRuleSettingsL4override `json:"l4override"` + // Configure a notification to display on the user's device when this rule is + // matched. + NotificationSettings ZeroTrustGatewayRulesRuleSettingsNotificationSettings `json:"notification_settings"` + // Override matching DNS queries with a hostname. + OverrideHost string `json:"override_host"` + // Override matching DNS queries with an IP or set of IPs. + OverrideIPs []string `json:"override_ips"` + // Configure DLP payload logging. + PayloadLog ZeroTrustGatewayRulesRuleSettingsPayloadLog `json:"payload_log"` + // Enable to send queries that match the policy to Cloudflare's default 1.1.1.1 DNS + // resolver. Cannot be set when dns_resolvers are specified. + ResolveDNSThroughCloudflare bool `json:"resolve_dns_through_cloudflare"` + // Configure behavior when an upstream cert is invalid or an SSL error occurs. + UntrustedCert ZeroTrustGatewayRulesRuleSettingsUntrustedCert `json:"untrusted_cert"` + JSON zeroTrustGatewayRulesRuleSettingsJSON `json:"-"` +} + +// zeroTrustGatewayRulesRuleSettingsJSON contains the JSON metadata for the struct +// [ZeroTrustGatewayRulesRuleSettings] +type zeroTrustGatewayRulesRuleSettingsJSON struct { + AddHeaders apijson.Field + AllowChildBypass apijson.Field + AuditSSH apijson.Field + BisoAdminControls apijson.Field + BlockPageEnabled apijson.Field + BlockReason apijson.Field + BypassParentRule apijson.Field + CheckSession apijson.Field + DNSResolvers apijson.Field + Egress apijson.Field + InsecureDisableDNSSECValidation apijson.Field + IPCategories apijson.Field + IPIndicatorFeeds apijson.Field + L4override apijson.Field + NotificationSettings apijson.Field + OverrideHost apijson.Field + OverrideIPs apijson.Field + PayloadLog apijson.Field + ResolveDNSThroughCloudflare apijson.Field + UntrustedCert apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayRulesRuleSettings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayRulesRuleSettingsJSON) RawJSON() string { + return r.raw +} + +// Settings for the Audit SSH action. +type ZeroTrustGatewayRulesRuleSettingsAuditSSH struct { + // Enable to turn on SSH command logging. + CommandLogging bool `json:"command_logging"` + JSON zeroTrustGatewayRulesRuleSettingsAuditSSHJSON `json:"-"` +} + +// zeroTrustGatewayRulesRuleSettingsAuditSSHJSON contains the JSON metadata for the +// struct [ZeroTrustGatewayRulesRuleSettingsAuditSSH] +type zeroTrustGatewayRulesRuleSettingsAuditSSHJSON struct { + CommandLogging apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayRulesRuleSettingsAuditSSH) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayRulesRuleSettingsAuditSSHJSON) RawJSON() string { + return r.raw +} + +// Configure how browser isolation behaves. +type ZeroTrustGatewayRulesRuleSettingsBisoAdminControls struct { + // Set to true to enable copy-pasting. + Dcp bool `json:"dcp"` + // Set to true to enable downloading. + Dd bool `json:"dd"` + // Set to true to enable keyboard usage. + Dk bool `json:"dk"` + // Set to true to enable printing. + Dp bool `json:"dp"` + // Set to true to enable uploading. + Du bool `json:"du"` + JSON zeroTrustGatewayRulesRuleSettingsBisoAdminControlsJSON `json:"-"` +} + +// zeroTrustGatewayRulesRuleSettingsBisoAdminControlsJSON contains the JSON +// metadata for the struct [ZeroTrustGatewayRulesRuleSettingsBisoAdminControls] +type zeroTrustGatewayRulesRuleSettingsBisoAdminControlsJSON struct { + Dcp apijson.Field + Dd apijson.Field + Dk apijson.Field + Dp apijson.Field + Du apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayRulesRuleSettingsBisoAdminControls) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayRulesRuleSettingsBisoAdminControlsJSON) RawJSON() string { + return r.raw +} + +// Configure how session check behaves. +type ZeroTrustGatewayRulesRuleSettingsCheckSession struct { + // Configure how fresh the session needs to be to be considered valid. + Duration string `json:"duration"` + // Set to true to enable session enforcement. + Enforce bool `json:"enforce"` + JSON zeroTrustGatewayRulesRuleSettingsCheckSessionJSON `json:"-"` +} + +// zeroTrustGatewayRulesRuleSettingsCheckSessionJSON contains the JSON metadata for +// the struct [ZeroTrustGatewayRulesRuleSettingsCheckSession] +type zeroTrustGatewayRulesRuleSettingsCheckSessionJSON struct { + Duration apijson.Field + Enforce apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayRulesRuleSettingsCheckSession) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayRulesRuleSettingsCheckSessionJSON) RawJSON() string { + return r.raw +} + +// Add your own custom resolvers to route queries that match the resolver policy. +// Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will +// route to the address closest to their origin. +type ZeroTrustGatewayRulesRuleSettingsDNSResolvers struct { + IPV4 []ZeroTrustGatewayRulesRuleSettingsDNSResolversIPV4 `json:"ipv4"` + IPV6 []ZeroTrustGatewayRulesRuleSettingsDNSResolversIPV6 `json:"ipv6"` + JSON zeroTrustGatewayRulesRuleSettingsDNSResolversJSON `json:"-"` +} + +// zeroTrustGatewayRulesRuleSettingsDNSResolversJSON contains the JSON metadata for +// the struct [ZeroTrustGatewayRulesRuleSettingsDNSResolvers] +type zeroTrustGatewayRulesRuleSettingsDNSResolversJSON struct { + IPV4 apijson.Field + IPV6 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayRulesRuleSettingsDNSResolvers) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayRulesRuleSettingsDNSResolversJSON) RawJSON() string { + return r.raw +} + +type ZeroTrustGatewayRulesRuleSettingsDNSResolversIPV4 struct { + // IP address of upstream resolver. + IP string `json:"ip,required"` + // A port number to use for upstream resolver. + Port int64 `json:"port"` + // Whether to connect to this resolver over a private network. Must be set when + // vnet_id is set. + RouteThroughPrivateNetwork bool `json:"route_through_private_network"` + // Optionally specify a virtual network for this resolver. Uses default virtual + // network id if omitted. + VnetID string `json:"vnet_id"` + JSON zeroTrustGatewayRulesRuleSettingsDNSResolversIPV4JSON `json:"-"` +} + +// zeroTrustGatewayRulesRuleSettingsDNSResolversIPV4JSON contains the JSON metadata +// for the struct [ZeroTrustGatewayRulesRuleSettingsDNSResolversIPV4] +type zeroTrustGatewayRulesRuleSettingsDNSResolversIPV4JSON struct { + IP apijson.Field + Port apijson.Field + RouteThroughPrivateNetwork apijson.Field + VnetID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayRulesRuleSettingsDNSResolversIPV4) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayRulesRuleSettingsDNSResolversIPV4JSON) RawJSON() string { + return r.raw +} + +type ZeroTrustGatewayRulesRuleSettingsDNSResolversIPV6 struct { + // IP address of upstream resolver. + IP string `json:"ip,required"` + // A port number to use for upstream resolver. + Port int64 `json:"port"` + // Whether to connect to this resolver over a private network. Must be set when + // vnet_id is set. + RouteThroughPrivateNetwork bool `json:"route_through_private_network"` + // Optionally specify a virtual network for this resolver. Uses default virtual + // network id if omitted. + VnetID string `json:"vnet_id"` + JSON zeroTrustGatewayRulesRuleSettingsDNSResolversIPV6JSON `json:"-"` +} + +// zeroTrustGatewayRulesRuleSettingsDNSResolversIPV6JSON contains the JSON metadata +// for the struct [ZeroTrustGatewayRulesRuleSettingsDNSResolversIPV6] +type zeroTrustGatewayRulesRuleSettingsDNSResolversIPV6JSON struct { + IP apijson.Field + Port apijson.Field + RouteThroughPrivateNetwork apijson.Field + VnetID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayRulesRuleSettingsDNSResolversIPV6) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayRulesRuleSettingsDNSResolversIPV6JSON) RawJSON() string { + return r.raw +} + +// Configure how Gateway Proxy traffic egresses. You can enable this setting for +// rules with Egress actions and filters, or omit it to indicate local egress via +// WARP IPs. +type ZeroTrustGatewayRulesRuleSettingsEgress struct { + // The IPv4 address to be used for egress. + IPV4 string `json:"ipv4"` + // The fallback IPv4 address to be used for egress in the event of an error + // egressing with the primary IPv4. Can be '0.0.0.0' to indicate local egress via + // WARP IPs. + IPV4Fallback string `json:"ipv4_fallback"` + // The IPv6 range to be used for egress. + IPV6 string `json:"ipv6"` + JSON zeroTrustGatewayRulesRuleSettingsEgressJSON `json:"-"` +} + +// zeroTrustGatewayRulesRuleSettingsEgressJSON contains the JSON metadata for the +// struct [ZeroTrustGatewayRulesRuleSettingsEgress] +type zeroTrustGatewayRulesRuleSettingsEgressJSON struct { + IPV4 apijson.Field + IPV4Fallback apijson.Field + IPV6 apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayRulesRuleSettingsEgress) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayRulesRuleSettingsEgressJSON) RawJSON() string { + return r.raw +} + +// Send matching traffic to the supplied destination IP address and port. +type ZeroTrustGatewayRulesRuleSettingsL4override struct { + // IPv4 or IPv6 address. + IP string `json:"ip"` + // A port number to use for TCP/UDP overrides. + Port int64 `json:"port"` + JSON zeroTrustGatewayRulesRuleSettingsL4overrideJSON `json:"-"` +} + +// zeroTrustGatewayRulesRuleSettingsL4overrideJSON contains the JSON metadata for +// the struct [ZeroTrustGatewayRulesRuleSettingsL4override] +type zeroTrustGatewayRulesRuleSettingsL4overrideJSON struct { + IP apijson.Field + Port apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayRulesRuleSettingsL4override) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayRulesRuleSettingsL4overrideJSON) RawJSON() string { + return r.raw +} + +// Configure a notification to display on the user's device when this rule is +// matched. +type ZeroTrustGatewayRulesRuleSettingsNotificationSettings struct { + // Set notification on + Enabled bool `json:"enabled"` + // Customize the message shown in the notification. + Msg string `json:"msg"` + // Optional URL to direct users to additional information. If not set, the + // notification will open a block page. + SupportURL string `json:"support_url"` + JSON zeroTrustGatewayRulesRuleSettingsNotificationSettingsJSON `json:"-"` +} + +// zeroTrustGatewayRulesRuleSettingsNotificationSettingsJSON contains the JSON +// metadata for the struct [ZeroTrustGatewayRulesRuleSettingsNotificationSettings] +type zeroTrustGatewayRulesRuleSettingsNotificationSettingsJSON struct { + Enabled apijson.Field + Msg apijson.Field + SupportURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayRulesRuleSettingsNotificationSettings) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayRulesRuleSettingsNotificationSettingsJSON) RawJSON() string { + return r.raw +} + +// Configure DLP payload logging. +type ZeroTrustGatewayRulesRuleSettingsPayloadLog struct { + // Set to true to enable DLP payload logging for this rule. + Enabled bool `json:"enabled"` + JSON zeroTrustGatewayRulesRuleSettingsPayloadLogJSON `json:"-"` +} + +// zeroTrustGatewayRulesRuleSettingsPayloadLogJSON contains the JSON metadata for +// the struct [ZeroTrustGatewayRulesRuleSettingsPayloadLog] +type zeroTrustGatewayRulesRuleSettingsPayloadLogJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayRulesRuleSettingsPayloadLog) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayRulesRuleSettingsPayloadLogJSON) RawJSON() string { + return r.raw +} + +// Configure behavior when an upstream cert is invalid or an SSL error occurs. +type ZeroTrustGatewayRulesRuleSettingsUntrustedCert struct { + // The action performed when an untrusted certificate is seen. The default action + // is an error with HTTP code 526. + Action ZeroTrustGatewayRulesRuleSettingsUntrustedCertAction `json:"action"` + JSON zeroTrustGatewayRulesRuleSettingsUntrustedCertJSON `json:"-"` +} + +// zeroTrustGatewayRulesRuleSettingsUntrustedCertJSON contains the JSON metadata +// for the struct [ZeroTrustGatewayRulesRuleSettingsUntrustedCert] +type zeroTrustGatewayRulesRuleSettingsUntrustedCertJSON struct { + Action apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayRulesRuleSettingsUntrustedCert) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayRulesRuleSettingsUntrustedCertJSON) RawJSON() string { + return r.raw +} + +// The action performed when an untrusted certificate is seen. The default action +// is an error with HTTP code 526. +type ZeroTrustGatewayRulesRuleSettingsUntrustedCertAction string + +const ( + ZeroTrustGatewayRulesRuleSettingsUntrustedCertActionPassThrough ZeroTrustGatewayRulesRuleSettingsUntrustedCertAction = "pass_through" + ZeroTrustGatewayRulesRuleSettingsUntrustedCertActionBlock ZeroTrustGatewayRulesRuleSettingsUntrustedCertAction = "block" + ZeroTrustGatewayRulesRuleSettingsUntrustedCertActionError ZeroTrustGatewayRulesRuleSettingsUntrustedCertAction = "error" +) + +// The schedule for activating DNS policies. This does not apply to HTTP or network +// policies. +type ZeroTrustGatewayRulesSchedule struct { + // The time intervals when the rule will be active on Fridays, in increasing order + // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on + // Fridays. + Fri string `json:"fri"` + // The time intervals when the rule will be active on Mondays, in increasing order + // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on + // Mondays. + Mon string `json:"mon"` + // The time intervals when the rule will be active on Saturdays, in increasing + // order from 00:00-24:00. If this parameter is omitted, the rule will be + // deactivated on Saturdays. + Sat string `json:"sat"` + // The time intervals when the rule will be active on Sundays, in increasing order + // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on + // Sundays. + Sun string `json:"sun"` + // The time intervals when the rule will be active on Thursdays, in increasing + // order from 00:00-24:00. If this parameter is omitted, the rule will be + // deactivated on Thursdays. + Thu string `json:"thu"` + // The time zone the rule will be evaluated against. If a + // [valid time zone city name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) + // is provided, Gateway will always use the current time at that time zone. If this + // parameter is omitted, then Gateway will use the time zone inferred from the + // user's source IP to evaluate the rule. If Gateway cannot determine the time zone + // from the IP, we will fall back to the time zone of the user's connected data + // center. + TimeZone string `json:"time_zone"` + // The time intervals when the rule will be active on Tuesdays, in increasing order + // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on + // Tuesdays. + Tue string `json:"tue"` + // The time intervals when the rule will be active on Wednesdays, in increasing + // order from 00:00-24:00. If this parameter is omitted, the rule will be + // deactivated on Wednesdays. + Wed string `json:"wed"` + JSON zeroTrustGatewayRulesScheduleJSON `json:"-"` +} + +// zeroTrustGatewayRulesScheduleJSON contains the JSON metadata for the struct +// [ZeroTrustGatewayRulesSchedule] +type zeroTrustGatewayRulesScheduleJSON struct { + Fri apijson.Field + Mon apijson.Field + Sat apijson.Field + Sun apijson.Field + Thu apijson.Field + TimeZone apijson.Field + Tue apijson.Field + Wed apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZeroTrustGatewayRulesSchedule) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zeroTrustGatewayRulesScheduleJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [zero_trust.GatewayRuleDeleteResponseUnknown] or +// [shared.UnionString]. +type GatewayRuleDeleteResponse interface { + ImplementsZeroTrustGatewayRuleDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*GatewayRuleDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type GatewayRuleNewParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // The action to preform when the associated traffic, identity, and device posture + // expressions are either absent or evaluate to `true`. + Action param.Field[GatewayRuleNewParamsAction] `json:"action,required"` + // The name of the rule. + Name param.Field[string] `json:"name,required"` + // The description of the rule. + Description param.Field[string] `json:"description"` + // The wirefilter expression used for device posture check matching. + DevicePosture param.Field[string] `json:"device_posture"` + // True if the rule is enabled. + Enabled param.Field[bool] `json:"enabled"` + // The protocol or layer to evaluate the traffic, identity, and device posture + // expressions. + Filters param.Field[[]GatewayRuleNewParamsFilter] `json:"filters"` + // The wirefilter expression used for identity matching. + Identity param.Field[string] `json:"identity"` + // Precedence sets the order of your rules. Lower values indicate higher + // precedence. At each processing phase, applicable rules are evaluated in + // ascending order of this value. + Precedence param.Field[int64] `json:"precedence"` + // Additional settings that modify the rule's action. + RuleSettings param.Field[GatewayRuleNewParamsRuleSettings] `json:"rule_settings"` + // The schedule for activating DNS policies. This does not apply to HTTP or network + // policies. + Schedule param.Field[GatewayRuleNewParamsSchedule] `json:"schedule"` + // The wirefilter expression used for traffic matching. + Traffic param.Field[string] `json:"traffic"` +} + +func (r GatewayRuleNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The action to preform when the associated traffic, identity, and device posture +// expressions are either absent or evaluate to `true`. +type GatewayRuleNewParamsAction string + +const ( + GatewayRuleNewParamsActionOn GatewayRuleNewParamsAction = "on" + GatewayRuleNewParamsActionOff GatewayRuleNewParamsAction = "off" + GatewayRuleNewParamsActionAllow GatewayRuleNewParamsAction = "allow" + GatewayRuleNewParamsActionBlock GatewayRuleNewParamsAction = "block" + GatewayRuleNewParamsActionScan GatewayRuleNewParamsAction = "scan" + GatewayRuleNewParamsActionNoscan GatewayRuleNewParamsAction = "noscan" + GatewayRuleNewParamsActionSafesearch GatewayRuleNewParamsAction = "safesearch" + GatewayRuleNewParamsActionYtrestricted GatewayRuleNewParamsAction = "ytrestricted" + GatewayRuleNewParamsActionIsolate GatewayRuleNewParamsAction = "isolate" + GatewayRuleNewParamsActionNoisolate GatewayRuleNewParamsAction = "noisolate" + GatewayRuleNewParamsActionOverride GatewayRuleNewParamsAction = "override" + GatewayRuleNewParamsActionL4Override GatewayRuleNewParamsAction = "l4_override" + GatewayRuleNewParamsActionEgress GatewayRuleNewParamsAction = "egress" + GatewayRuleNewParamsActionAuditSSH GatewayRuleNewParamsAction = "audit_ssh" +) + +// The protocol or layer to use. +type GatewayRuleNewParamsFilter string + +const ( + GatewayRuleNewParamsFilterHTTP GatewayRuleNewParamsFilter = "http" + GatewayRuleNewParamsFilterDNS GatewayRuleNewParamsFilter = "dns" + GatewayRuleNewParamsFilterL4 GatewayRuleNewParamsFilter = "l4" + GatewayRuleNewParamsFilterEgress GatewayRuleNewParamsFilter = "egress" +) + +// Additional settings that modify the rule's action. +type GatewayRuleNewParamsRuleSettings struct { + // Add custom headers to allowed requests, in the form of key-value pairs. Keys are + // header names, pointing to an array with its header value(s). + AddHeaders param.Field[interface{}] `json:"add_headers"` + // Set by parent MSP accounts to enable their children to bypass this rule. + AllowChildBypass param.Field[bool] `json:"allow_child_bypass"` + // Settings for the Audit SSH action. + AuditSSH param.Field[GatewayRuleNewParamsRuleSettingsAuditSSH] `json:"audit_ssh"` + // Configure how browser isolation behaves. + BisoAdminControls param.Field[GatewayRuleNewParamsRuleSettingsBisoAdminControls] `json:"biso_admin_controls"` + // Enable the custom block page. + BlockPageEnabled param.Field[bool] `json:"block_page_enabled"` + // The text describing why this block occurred, displayed on the custom block page + // (if enabled). + BlockReason param.Field[string] `json:"block_reason"` + // Set by children MSP accounts to bypass their parent's rules. + BypassParentRule param.Field[bool] `json:"bypass_parent_rule"` + // Configure how session check behaves. + CheckSession param.Field[GatewayRuleNewParamsRuleSettingsCheckSession] `json:"check_session"` + // Add your own custom resolvers to route queries that match the resolver policy. + // Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will + // route to the address closest to their origin. + DNSResolvers param.Field[GatewayRuleNewParamsRuleSettingsDNSResolvers] `json:"dns_resolvers"` + // Configure how Gateway Proxy traffic egresses. You can enable this setting for + // rules with Egress actions and filters, or omit it to indicate local egress via + // WARP IPs. + Egress param.Field[GatewayRuleNewParamsRuleSettingsEgress] `json:"egress"` + // INSECURE - disable DNSSEC validation (for Allow actions). + InsecureDisableDNSSECValidation param.Field[bool] `json:"insecure_disable_dnssec_validation"` + // Set to true to enable IPs in DNS resolver category blocks. By default categories + // only block based on domain names. + IPCategories param.Field[bool] `json:"ip_categories"` + // Set to true to include IPs in DNS resolver indicator feed blocks. By default + // indicator feeds only block based on domain names. + IPIndicatorFeeds param.Field[bool] `json:"ip_indicator_feeds"` + // Send matching traffic to the supplied destination IP address and port. + L4override param.Field[GatewayRuleNewParamsRuleSettingsL4override] `json:"l4override"` + // Configure a notification to display on the user's device when this rule is + // matched. + NotificationSettings param.Field[GatewayRuleNewParamsRuleSettingsNotificationSettings] `json:"notification_settings"` + // Override matching DNS queries with a hostname. + OverrideHost param.Field[string] `json:"override_host"` + // Override matching DNS queries with an IP or set of IPs. + OverrideIPs param.Field[[]string] `json:"override_ips"` + // Configure DLP payload logging. + PayloadLog param.Field[GatewayRuleNewParamsRuleSettingsPayloadLog] `json:"payload_log"` + // Enable to send queries that match the policy to Cloudflare's default 1.1.1.1 DNS + // resolver. Cannot be set when dns_resolvers are specified. + ResolveDNSThroughCloudflare param.Field[bool] `json:"resolve_dns_through_cloudflare"` + // Configure behavior when an upstream cert is invalid or an SSL error occurs. + UntrustedCert param.Field[GatewayRuleNewParamsRuleSettingsUntrustedCert] `json:"untrusted_cert"` +} + +func (r GatewayRuleNewParamsRuleSettings) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Settings for the Audit SSH action. +type GatewayRuleNewParamsRuleSettingsAuditSSH struct { + // Enable to turn on SSH command logging. + CommandLogging param.Field[bool] `json:"command_logging"` +} + +func (r GatewayRuleNewParamsRuleSettingsAuditSSH) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configure how browser isolation behaves. +type GatewayRuleNewParamsRuleSettingsBisoAdminControls struct { + // Set to true to enable copy-pasting. + Dcp param.Field[bool] `json:"dcp"` + // Set to true to enable downloading. + Dd param.Field[bool] `json:"dd"` + // Set to true to enable keyboard usage. + Dk param.Field[bool] `json:"dk"` + // Set to true to enable printing. + Dp param.Field[bool] `json:"dp"` + // Set to true to enable uploading. + Du param.Field[bool] `json:"du"` +} + +func (r GatewayRuleNewParamsRuleSettingsBisoAdminControls) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configure how session check behaves. +type GatewayRuleNewParamsRuleSettingsCheckSession struct { + // Configure how fresh the session needs to be to be considered valid. + Duration param.Field[string] `json:"duration"` + // Set to true to enable session enforcement. + Enforce param.Field[bool] `json:"enforce"` +} + +func (r GatewayRuleNewParamsRuleSettingsCheckSession) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Add your own custom resolvers to route queries that match the resolver policy. +// Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will +// route to the address closest to their origin. +type GatewayRuleNewParamsRuleSettingsDNSResolvers struct { + IPV4 param.Field[[]GatewayRuleNewParamsRuleSettingsDNSResolversIPV4] `json:"ipv4"` + IPV6 param.Field[[]GatewayRuleNewParamsRuleSettingsDNSResolversIPV6] `json:"ipv6"` +} + +func (r GatewayRuleNewParamsRuleSettingsDNSResolvers) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayRuleNewParamsRuleSettingsDNSResolversIPV4 struct { + // IP address of upstream resolver. + IP param.Field[string] `json:"ip,required"` + // A port number to use for upstream resolver. + Port param.Field[int64] `json:"port"` + // Whether to connect to this resolver over a private network. Must be set when + // vnet_id is set. + RouteThroughPrivateNetwork param.Field[bool] `json:"route_through_private_network"` + // Optionally specify a virtual network for this resolver. Uses default virtual + // network id if omitted. + VnetID param.Field[string] `json:"vnet_id"` +} + +func (r GatewayRuleNewParamsRuleSettingsDNSResolversIPV4) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayRuleNewParamsRuleSettingsDNSResolversIPV6 struct { + // IP address of upstream resolver. + IP param.Field[string] `json:"ip,required"` + // A port number to use for upstream resolver. + Port param.Field[int64] `json:"port"` + // Whether to connect to this resolver over a private network. Must be set when + // vnet_id is set. + RouteThroughPrivateNetwork param.Field[bool] `json:"route_through_private_network"` + // Optionally specify a virtual network for this resolver. Uses default virtual + // network id if omitted. + VnetID param.Field[string] `json:"vnet_id"` +} + +func (r GatewayRuleNewParamsRuleSettingsDNSResolversIPV6) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configure how Gateway Proxy traffic egresses. You can enable this setting for +// rules with Egress actions and filters, or omit it to indicate local egress via +// WARP IPs. +type GatewayRuleNewParamsRuleSettingsEgress struct { + // The IPv4 address to be used for egress. + IPV4 param.Field[string] `json:"ipv4"` + // The fallback IPv4 address to be used for egress in the event of an error + // egressing with the primary IPv4. Can be '0.0.0.0' to indicate local egress via + // WARP IPs. + IPV4Fallback param.Field[string] `json:"ipv4_fallback"` + // The IPv6 range to be used for egress. + IPV6 param.Field[string] `json:"ipv6"` +} + +func (r GatewayRuleNewParamsRuleSettingsEgress) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Send matching traffic to the supplied destination IP address and port. +type GatewayRuleNewParamsRuleSettingsL4override struct { + // IPv4 or IPv6 address. + IP param.Field[string] `json:"ip"` + // A port number to use for TCP/UDP overrides. + Port param.Field[int64] `json:"port"` +} + +func (r GatewayRuleNewParamsRuleSettingsL4override) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configure a notification to display on the user's device when this rule is +// matched. +type GatewayRuleNewParamsRuleSettingsNotificationSettings struct { + // Set notification on + Enabled param.Field[bool] `json:"enabled"` + // Customize the message shown in the notification. + Msg param.Field[string] `json:"msg"` + // Optional URL to direct users to additional information. If not set, the + // notification will open a block page. + SupportURL param.Field[string] `json:"support_url"` +} + +func (r GatewayRuleNewParamsRuleSettingsNotificationSettings) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configure DLP payload logging. +type GatewayRuleNewParamsRuleSettingsPayloadLog struct { + // Set to true to enable DLP payload logging for this rule. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r GatewayRuleNewParamsRuleSettingsPayloadLog) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configure behavior when an upstream cert is invalid or an SSL error occurs. +type GatewayRuleNewParamsRuleSettingsUntrustedCert struct { + // The action performed when an untrusted certificate is seen. The default action + // is an error with HTTP code 526. + Action param.Field[GatewayRuleNewParamsRuleSettingsUntrustedCertAction] `json:"action"` +} + +func (r GatewayRuleNewParamsRuleSettingsUntrustedCert) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The action performed when an untrusted certificate is seen. The default action +// is an error with HTTP code 526. +type GatewayRuleNewParamsRuleSettingsUntrustedCertAction string + +const ( + GatewayRuleNewParamsRuleSettingsUntrustedCertActionPassThrough GatewayRuleNewParamsRuleSettingsUntrustedCertAction = "pass_through" + GatewayRuleNewParamsRuleSettingsUntrustedCertActionBlock GatewayRuleNewParamsRuleSettingsUntrustedCertAction = "block" + GatewayRuleNewParamsRuleSettingsUntrustedCertActionError GatewayRuleNewParamsRuleSettingsUntrustedCertAction = "error" +) + +// The schedule for activating DNS policies. This does not apply to HTTP or network +// policies. +type GatewayRuleNewParamsSchedule struct { + // The time intervals when the rule will be active on Fridays, in increasing order + // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on + // Fridays. + Fri param.Field[string] `json:"fri"` + // The time intervals when the rule will be active on Mondays, in increasing order + // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on + // Mondays. + Mon param.Field[string] `json:"mon"` + // The time intervals when the rule will be active on Saturdays, in increasing + // order from 00:00-24:00. If this parameter is omitted, the rule will be + // deactivated on Saturdays. + Sat param.Field[string] `json:"sat"` + // The time intervals when the rule will be active on Sundays, in increasing order + // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on + // Sundays. + Sun param.Field[string] `json:"sun"` + // The time intervals when the rule will be active on Thursdays, in increasing + // order from 00:00-24:00. If this parameter is omitted, the rule will be + // deactivated on Thursdays. + Thu param.Field[string] `json:"thu"` + // The time zone the rule will be evaluated against. If a + // [valid time zone city name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) + // is provided, Gateway will always use the current time at that time zone. If this + // parameter is omitted, then Gateway will use the time zone inferred from the + // user's source IP to evaluate the rule. If Gateway cannot determine the time zone + // from the IP, we will fall back to the time zone of the user's connected data + // center. + TimeZone param.Field[string] `json:"time_zone"` + // The time intervals when the rule will be active on Tuesdays, in increasing order + // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on + // Tuesdays. + Tue param.Field[string] `json:"tue"` + // The time intervals when the rule will be active on Wednesdays, in increasing + // order from 00:00-24:00. If this parameter is omitted, the rule will be + // deactivated on Wednesdays. + Wed param.Field[string] `json:"wed"` +} + +func (r GatewayRuleNewParamsSchedule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayRuleNewResponseEnvelope struct { + Errors []GatewayRuleNewResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayRuleNewResponseEnvelopeMessages `json:"messages,required"` + Result ZeroTrustGatewayRules `json:"result,required"` + // Whether the API call was successful + Success GatewayRuleNewResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayRuleNewResponseEnvelopeJSON `json:"-"` +} + +// gatewayRuleNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayRuleNewResponseEnvelope] +type gatewayRuleNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayRuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayRuleNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayRuleNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayRuleNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayRuleNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GatewayRuleNewResponseEnvelopeErrors] +type gatewayRuleNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayRuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayRuleNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayRuleNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayRuleNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayRuleNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [GatewayRuleNewResponseEnvelopeMessages] +type gatewayRuleNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayRuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayRuleNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayRuleNewResponseEnvelopeSuccess bool + +const ( + GatewayRuleNewResponseEnvelopeSuccessTrue GatewayRuleNewResponseEnvelopeSuccess = true +) + +type GatewayRuleUpdateParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` + // The action to preform when the associated traffic, identity, and device posture + // expressions are either absent or evaluate to `true`. + Action param.Field[GatewayRuleUpdateParamsAction] `json:"action,required"` + // The name of the rule. + Name param.Field[string] `json:"name,required"` + // The description of the rule. + Description param.Field[string] `json:"description"` + // The wirefilter expression used for device posture check matching. + DevicePosture param.Field[string] `json:"device_posture"` + // True if the rule is enabled. + Enabled param.Field[bool] `json:"enabled"` + // The protocol or layer to evaluate the traffic, identity, and device posture + // expressions. + Filters param.Field[[]GatewayRuleUpdateParamsFilter] `json:"filters"` + // The wirefilter expression used for identity matching. + Identity param.Field[string] `json:"identity"` + // Precedence sets the order of your rules. Lower values indicate higher + // precedence. At each processing phase, applicable rules are evaluated in + // ascending order of this value. + Precedence param.Field[int64] `json:"precedence"` + // Additional settings that modify the rule's action. + RuleSettings param.Field[GatewayRuleUpdateParamsRuleSettings] `json:"rule_settings"` + // The schedule for activating DNS policies. This does not apply to HTTP or network + // policies. + Schedule param.Field[GatewayRuleUpdateParamsSchedule] `json:"schedule"` + // The wirefilter expression used for traffic matching. + Traffic param.Field[string] `json:"traffic"` +} + +func (r GatewayRuleUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The action to preform when the associated traffic, identity, and device posture +// expressions are either absent or evaluate to `true`. +type GatewayRuleUpdateParamsAction string + +const ( + GatewayRuleUpdateParamsActionOn GatewayRuleUpdateParamsAction = "on" + GatewayRuleUpdateParamsActionOff GatewayRuleUpdateParamsAction = "off" + GatewayRuleUpdateParamsActionAllow GatewayRuleUpdateParamsAction = "allow" + GatewayRuleUpdateParamsActionBlock GatewayRuleUpdateParamsAction = "block" + GatewayRuleUpdateParamsActionScan GatewayRuleUpdateParamsAction = "scan" + GatewayRuleUpdateParamsActionNoscan GatewayRuleUpdateParamsAction = "noscan" + GatewayRuleUpdateParamsActionSafesearch GatewayRuleUpdateParamsAction = "safesearch" + GatewayRuleUpdateParamsActionYtrestricted GatewayRuleUpdateParamsAction = "ytrestricted" + GatewayRuleUpdateParamsActionIsolate GatewayRuleUpdateParamsAction = "isolate" + GatewayRuleUpdateParamsActionNoisolate GatewayRuleUpdateParamsAction = "noisolate" + GatewayRuleUpdateParamsActionOverride GatewayRuleUpdateParamsAction = "override" + GatewayRuleUpdateParamsActionL4Override GatewayRuleUpdateParamsAction = "l4_override" + GatewayRuleUpdateParamsActionEgress GatewayRuleUpdateParamsAction = "egress" + GatewayRuleUpdateParamsActionAuditSSH GatewayRuleUpdateParamsAction = "audit_ssh" +) + +// The protocol or layer to use. +type GatewayRuleUpdateParamsFilter string + +const ( + GatewayRuleUpdateParamsFilterHTTP GatewayRuleUpdateParamsFilter = "http" + GatewayRuleUpdateParamsFilterDNS GatewayRuleUpdateParamsFilter = "dns" + GatewayRuleUpdateParamsFilterL4 GatewayRuleUpdateParamsFilter = "l4" + GatewayRuleUpdateParamsFilterEgress GatewayRuleUpdateParamsFilter = "egress" +) + +// Additional settings that modify the rule's action. +type GatewayRuleUpdateParamsRuleSettings struct { + // Add custom headers to allowed requests, in the form of key-value pairs. Keys are + // header names, pointing to an array with its header value(s). + AddHeaders param.Field[interface{}] `json:"add_headers"` + // Set by parent MSP accounts to enable their children to bypass this rule. + AllowChildBypass param.Field[bool] `json:"allow_child_bypass"` + // Settings for the Audit SSH action. + AuditSSH param.Field[GatewayRuleUpdateParamsRuleSettingsAuditSSH] `json:"audit_ssh"` + // Configure how browser isolation behaves. + BisoAdminControls param.Field[GatewayRuleUpdateParamsRuleSettingsBisoAdminControls] `json:"biso_admin_controls"` + // Enable the custom block page. + BlockPageEnabled param.Field[bool] `json:"block_page_enabled"` + // The text describing why this block occurred, displayed on the custom block page + // (if enabled). + BlockReason param.Field[string] `json:"block_reason"` + // Set by children MSP accounts to bypass their parent's rules. + BypassParentRule param.Field[bool] `json:"bypass_parent_rule"` + // Configure how session check behaves. + CheckSession param.Field[GatewayRuleUpdateParamsRuleSettingsCheckSession] `json:"check_session"` + // Add your own custom resolvers to route queries that match the resolver policy. + // Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will + // route to the address closest to their origin. + DNSResolvers param.Field[GatewayRuleUpdateParamsRuleSettingsDNSResolvers] `json:"dns_resolvers"` + // Configure how Gateway Proxy traffic egresses. You can enable this setting for + // rules with Egress actions and filters, or omit it to indicate local egress via + // WARP IPs. + Egress param.Field[GatewayRuleUpdateParamsRuleSettingsEgress] `json:"egress"` + // INSECURE - disable DNSSEC validation (for Allow actions). + InsecureDisableDNSSECValidation param.Field[bool] `json:"insecure_disable_dnssec_validation"` + // Set to true to enable IPs in DNS resolver category blocks. By default categories + // only block based on domain names. + IPCategories param.Field[bool] `json:"ip_categories"` + // Set to true to include IPs in DNS resolver indicator feed blocks. By default + // indicator feeds only block based on domain names. + IPIndicatorFeeds param.Field[bool] `json:"ip_indicator_feeds"` + // Send matching traffic to the supplied destination IP address and port. + L4override param.Field[GatewayRuleUpdateParamsRuleSettingsL4override] `json:"l4override"` + // Configure a notification to display on the user's device when this rule is + // matched. + NotificationSettings param.Field[GatewayRuleUpdateParamsRuleSettingsNotificationSettings] `json:"notification_settings"` + // Override matching DNS queries with a hostname. + OverrideHost param.Field[string] `json:"override_host"` + // Override matching DNS queries with an IP or set of IPs. + OverrideIPs param.Field[[]string] `json:"override_ips"` + // Configure DLP payload logging. + PayloadLog param.Field[GatewayRuleUpdateParamsRuleSettingsPayloadLog] `json:"payload_log"` + // Enable to send queries that match the policy to Cloudflare's default 1.1.1.1 DNS + // resolver. Cannot be set when dns_resolvers are specified. + ResolveDNSThroughCloudflare param.Field[bool] `json:"resolve_dns_through_cloudflare"` + // Configure behavior when an upstream cert is invalid or an SSL error occurs. + UntrustedCert param.Field[GatewayRuleUpdateParamsRuleSettingsUntrustedCert] `json:"untrusted_cert"` +} + +func (r GatewayRuleUpdateParamsRuleSettings) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Settings for the Audit SSH action. +type GatewayRuleUpdateParamsRuleSettingsAuditSSH struct { + // Enable to turn on SSH command logging. + CommandLogging param.Field[bool] `json:"command_logging"` +} + +func (r GatewayRuleUpdateParamsRuleSettingsAuditSSH) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configure how browser isolation behaves. +type GatewayRuleUpdateParamsRuleSettingsBisoAdminControls struct { + // Set to true to enable copy-pasting. + Dcp param.Field[bool] `json:"dcp"` + // Set to true to enable downloading. + Dd param.Field[bool] `json:"dd"` + // Set to true to enable keyboard usage. + Dk param.Field[bool] `json:"dk"` + // Set to true to enable printing. + Dp param.Field[bool] `json:"dp"` + // Set to true to enable uploading. + Du param.Field[bool] `json:"du"` +} + +func (r GatewayRuleUpdateParamsRuleSettingsBisoAdminControls) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configure how session check behaves. +type GatewayRuleUpdateParamsRuleSettingsCheckSession struct { + // Configure how fresh the session needs to be to be considered valid. + Duration param.Field[string] `json:"duration"` + // Set to true to enable session enforcement. + Enforce param.Field[bool] `json:"enforce"` +} + +func (r GatewayRuleUpdateParamsRuleSettingsCheckSession) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Add your own custom resolvers to route queries that match the resolver policy. +// Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will +// route to the address closest to their origin. +type GatewayRuleUpdateParamsRuleSettingsDNSResolvers struct { + IPV4 param.Field[[]GatewayRuleUpdateParamsRuleSettingsDNSResolversIPV4] `json:"ipv4"` + IPV6 param.Field[[]GatewayRuleUpdateParamsRuleSettingsDNSResolversIPV6] `json:"ipv6"` +} + +func (r GatewayRuleUpdateParamsRuleSettingsDNSResolvers) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayRuleUpdateParamsRuleSettingsDNSResolversIPV4 struct { + // IP address of upstream resolver. + IP param.Field[string] `json:"ip,required"` + // A port number to use for upstream resolver. + Port param.Field[int64] `json:"port"` + // Whether to connect to this resolver over a private network. Must be set when + // vnet_id is set. + RouteThroughPrivateNetwork param.Field[bool] `json:"route_through_private_network"` + // Optionally specify a virtual network for this resolver. Uses default virtual + // network id if omitted. + VnetID param.Field[string] `json:"vnet_id"` +} + +func (r GatewayRuleUpdateParamsRuleSettingsDNSResolversIPV4) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayRuleUpdateParamsRuleSettingsDNSResolversIPV6 struct { + // IP address of upstream resolver. + IP param.Field[string] `json:"ip,required"` + // A port number to use for upstream resolver. + Port param.Field[int64] `json:"port"` + // Whether to connect to this resolver over a private network. Must be set when + // vnet_id is set. + RouteThroughPrivateNetwork param.Field[bool] `json:"route_through_private_network"` + // Optionally specify a virtual network for this resolver. Uses default virtual + // network id if omitted. + VnetID param.Field[string] `json:"vnet_id"` +} + +func (r GatewayRuleUpdateParamsRuleSettingsDNSResolversIPV6) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configure how Gateway Proxy traffic egresses. You can enable this setting for +// rules with Egress actions and filters, or omit it to indicate local egress via +// WARP IPs. +type GatewayRuleUpdateParamsRuleSettingsEgress struct { + // The IPv4 address to be used for egress. + IPV4 param.Field[string] `json:"ipv4"` + // The fallback IPv4 address to be used for egress in the event of an error + // egressing with the primary IPv4. Can be '0.0.0.0' to indicate local egress via + // WARP IPs. + IPV4Fallback param.Field[string] `json:"ipv4_fallback"` + // The IPv6 range to be used for egress. + IPV6 param.Field[string] `json:"ipv6"` +} + +func (r GatewayRuleUpdateParamsRuleSettingsEgress) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Send matching traffic to the supplied destination IP address and port. +type GatewayRuleUpdateParamsRuleSettingsL4override struct { + // IPv4 or IPv6 address. + IP param.Field[string] `json:"ip"` + // A port number to use for TCP/UDP overrides. + Port param.Field[int64] `json:"port"` +} + +func (r GatewayRuleUpdateParamsRuleSettingsL4override) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configure a notification to display on the user's device when this rule is +// matched. +type GatewayRuleUpdateParamsRuleSettingsNotificationSettings struct { + // Set notification on + Enabled param.Field[bool] `json:"enabled"` + // Customize the message shown in the notification. + Msg param.Field[string] `json:"msg"` + // Optional URL to direct users to additional information. If not set, the + // notification will open a block page. + SupportURL param.Field[string] `json:"support_url"` +} + +func (r GatewayRuleUpdateParamsRuleSettingsNotificationSettings) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configure DLP payload logging. +type GatewayRuleUpdateParamsRuleSettingsPayloadLog struct { + // Set to true to enable DLP payload logging for this rule. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r GatewayRuleUpdateParamsRuleSettingsPayloadLog) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configure behavior when an upstream cert is invalid or an SSL error occurs. +type GatewayRuleUpdateParamsRuleSettingsUntrustedCert struct { + // The action performed when an untrusted certificate is seen. The default action + // is an error with HTTP code 526. + Action param.Field[GatewayRuleUpdateParamsRuleSettingsUntrustedCertAction] `json:"action"` +} + +func (r GatewayRuleUpdateParamsRuleSettingsUntrustedCert) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The action performed when an untrusted certificate is seen. The default action +// is an error with HTTP code 526. +type GatewayRuleUpdateParamsRuleSettingsUntrustedCertAction string + +const ( + GatewayRuleUpdateParamsRuleSettingsUntrustedCertActionPassThrough GatewayRuleUpdateParamsRuleSettingsUntrustedCertAction = "pass_through" + GatewayRuleUpdateParamsRuleSettingsUntrustedCertActionBlock GatewayRuleUpdateParamsRuleSettingsUntrustedCertAction = "block" + GatewayRuleUpdateParamsRuleSettingsUntrustedCertActionError GatewayRuleUpdateParamsRuleSettingsUntrustedCertAction = "error" +) + +// The schedule for activating DNS policies. This does not apply to HTTP or network +// policies. +type GatewayRuleUpdateParamsSchedule struct { + // The time intervals when the rule will be active on Fridays, in increasing order + // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on + // Fridays. + Fri param.Field[string] `json:"fri"` + // The time intervals when the rule will be active on Mondays, in increasing order + // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on + // Mondays. + Mon param.Field[string] `json:"mon"` + // The time intervals when the rule will be active on Saturdays, in increasing + // order from 00:00-24:00. If this parameter is omitted, the rule will be + // deactivated on Saturdays. + Sat param.Field[string] `json:"sat"` + // The time intervals when the rule will be active on Sundays, in increasing order + // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on + // Sundays. + Sun param.Field[string] `json:"sun"` + // The time intervals when the rule will be active on Thursdays, in increasing + // order from 00:00-24:00. If this parameter is omitted, the rule will be + // deactivated on Thursdays. + Thu param.Field[string] `json:"thu"` + // The time zone the rule will be evaluated against. If a + // [valid time zone city name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) + // is provided, Gateway will always use the current time at that time zone. If this + // parameter is omitted, then Gateway will use the time zone inferred from the + // user's source IP to evaluate the rule. If Gateway cannot determine the time zone + // from the IP, we will fall back to the time zone of the user's connected data + // center. + TimeZone param.Field[string] `json:"time_zone"` + // The time intervals when the rule will be active on Tuesdays, in increasing order + // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on + // Tuesdays. + Tue param.Field[string] `json:"tue"` + // The time intervals when the rule will be active on Wednesdays, in increasing + // order from 00:00-24:00. If this parameter is omitted, the rule will be + // deactivated on Wednesdays. + Wed param.Field[string] `json:"wed"` +} + +func (r GatewayRuleUpdateParamsSchedule) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type GatewayRuleUpdateResponseEnvelope struct { + Errors []GatewayRuleUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayRuleUpdateResponseEnvelopeMessages `json:"messages,required"` + Result ZeroTrustGatewayRules `json:"result,required"` + // Whether the API call was successful + Success GatewayRuleUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayRuleUpdateResponseEnvelopeJSON `json:"-"` +} + +// gatewayRuleUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayRuleUpdateResponseEnvelope] +type gatewayRuleUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayRuleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayRuleUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayRuleUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayRuleUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayRuleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GatewayRuleUpdateResponseEnvelopeErrors] +type gatewayRuleUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayRuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayRuleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayRuleUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayRuleUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayRuleUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [GatewayRuleUpdateResponseEnvelopeMessages] +type gatewayRuleUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayRuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayRuleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayRuleUpdateResponseEnvelopeSuccess bool + +const ( + GatewayRuleUpdateResponseEnvelopeSuccessTrue GatewayRuleUpdateResponseEnvelopeSuccess = true +) + +type GatewayRuleListParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type GatewayRuleListResponseEnvelope struct { + Errors []GatewayRuleListResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayRuleListResponseEnvelopeMessages `json:"messages,required"` + Result []ZeroTrustGatewayRules `json:"result,required,nullable"` + // Whether the API call was successful + Success GatewayRuleListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo GatewayRuleListResponseEnvelopeResultInfo `json:"result_info"` + JSON gatewayRuleListResponseEnvelopeJSON `json:"-"` +} + +// gatewayRuleListResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayRuleListResponseEnvelope] +type gatewayRuleListResponseEnvelopeJSON 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 *GatewayRuleListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayRuleListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayRuleListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayRuleListResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayRuleListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GatewayRuleListResponseEnvelopeErrors] +type gatewayRuleListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayRuleListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayRuleListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayRuleListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayRuleListResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayRuleListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [GatewayRuleListResponseEnvelopeMessages] +type gatewayRuleListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayRuleListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayRuleListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayRuleListResponseEnvelopeSuccess bool + +const ( + GatewayRuleListResponseEnvelopeSuccessTrue GatewayRuleListResponseEnvelopeSuccess = true +) + +type GatewayRuleListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON gatewayRuleListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// gatewayRuleListResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [GatewayRuleListResponseEnvelopeResultInfo] +type gatewayRuleListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayRuleListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayRuleListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type GatewayRuleDeleteParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type GatewayRuleDeleteResponseEnvelope struct { + Errors []GatewayRuleDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayRuleDeleteResponseEnvelopeMessages `json:"messages,required"` + Result GatewayRuleDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success GatewayRuleDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayRuleDeleteResponseEnvelopeJSON `json:"-"` +} + +// gatewayRuleDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayRuleDeleteResponseEnvelope] +type gatewayRuleDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayRuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayRuleDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayRuleDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayRuleDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayRuleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GatewayRuleDeleteResponseEnvelopeErrors] +type gatewayRuleDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayRuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayRuleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayRuleDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayRuleDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayRuleDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [GatewayRuleDeleteResponseEnvelopeMessages] +type gatewayRuleDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayRuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayRuleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayRuleDeleteResponseEnvelopeSuccess bool + +const ( + GatewayRuleDeleteResponseEnvelopeSuccessTrue GatewayRuleDeleteResponseEnvelopeSuccess = true +) + +type GatewayRuleGetParams struct { + AccountID param.Field[interface{}] `path:"account_id,required"` +} + +type GatewayRuleGetResponseEnvelope struct { + Errors []GatewayRuleGetResponseEnvelopeErrors `json:"errors,required"` + Messages []GatewayRuleGetResponseEnvelopeMessages `json:"messages,required"` + Result ZeroTrustGatewayRules `json:"result,required"` + // Whether the API call was successful + Success GatewayRuleGetResponseEnvelopeSuccess `json:"success,required"` + JSON gatewayRuleGetResponseEnvelopeJSON `json:"-"` +} + +// gatewayRuleGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [GatewayRuleGetResponseEnvelope] +type gatewayRuleGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayRuleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayRuleGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type GatewayRuleGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayRuleGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// gatewayRuleGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [GatewayRuleGetResponseEnvelopeErrors] +type gatewayRuleGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayRuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayRuleGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type GatewayRuleGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON gatewayRuleGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// gatewayRuleGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [GatewayRuleGetResponseEnvelopeMessages] +type gatewayRuleGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *GatewayRuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r gatewayRuleGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type GatewayRuleGetResponseEnvelopeSuccess bool + +const ( + GatewayRuleGetResponseEnvelopeSuccessTrue GatewayRuleGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/gatewayrule_test.go b/zero_trust/gatewayrule_test.go new file mode 100644 index 00000000000..74189f1e1c8 --- /dev/null +++ b/zero_trust/gatewayrule_test.go @@ -0,0 +1,373 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestGatewayRuleNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Rules.New(context.TODO(), zero_trust.GatewayRuleNewParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Action: cloudflare.F(zero_trust.GatewayRuleNewParamsActionAllow), + Name: cloudflare.F("block bad websites"), + Description: cloudflare.F("Block bad websites based on their host name."), + DevicePosture: cloudflare.F("any(device_posture.checks.passed[*] in {\"1308749e-fcfb-4ebc-b051-fe022b632644\"})"), + Enabled: cloudflare.F(true), + Filters: cloudflare.F([]zero_trust.GatewayRuleNewParamsFilter{zero_trust.GatewayRuleNewParamsFilterHTTP}), + Identity: cloudflare.F("any(identity.groups.name[*] in {\"finance\"})"), + Precedence: cloudflare.F(int64(0)), + RuleSettings: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettings{ + AddHeaders: cloudflare.F[any](map[string]interface{}{ + "My-Next-Header": map[string]interface{}{ + "0": "foo", + "1": "bar", + }, + "X-Custom-Header-Name": map[string]interface{}{ + "0": "somecustomvalue", + }, + }), + AllowChildBypass: cloudflare.F(false), + AuditSSH: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsAuditSSH{ + CommandLogging: cloudflare.F(false), + }), + BisoAdminControls: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsBisoAdminControls{ + Dcp: cloudflare.F(false), + Dd: cloudflare.F(false), + Dk: cloudflare.F(false), + Dp: cloudflare.F(false), + Du: cloudflare.F(false), + }), + BlockPageEnabled: cloudflare.F(true), + BlockReason: cloudflare.F("This website is a security risk"), + BypassParentRule: cloudflare.F(false), + CheckSession: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsCheckSession{ + Duration: cloudflare.F("300s"), + Enforce: cloudflare.F(true), + }), + DNSResolvers: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsDNSResolvers{ + IPV4: cloudflare.F([]zero_trust.GatewayRuleNewParamsRuleSettingsDNSResolversIPV4{{ + IP: cloudflare.F("2001:DB8::/64"), + Port: cloudflare.F(int64(5053)), + RouteThroughPrivateNetwork: cloudflare.F(true), + VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), + }, { + IP: cloudflare.F("2001:DB8::/64"), + Port: cloudflare.F(int64(5053)), + RouteThroughPrivateNetwork: cloudflare.F(true), + VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), + }, { + IP: cloudflare.F("2001:DB8::/64"), + Port: cloudflare.F(int64(5053)), + RouteThroughPrivateNetwork: cloudflare.F(true), + VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), + }}), + IPV6: cloudflare.F([]zero_trust.GatewayRuleNewParamsRuleSettingsDNSResolversIPV6{{ + IP: cloudflare.F("2001:DB8::/64"), + Port: cloudflare.F(int64(5053)), + RouteThroughPrivateNetwork: cloudflare.F(true), + VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), + }, { + IP: cloudflare.F("2001:DB8::/64"), + Port: cloudflare.F(int64(5053)), + RouteThroughPrivateNetwork: cloudflare.F(true), + VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), + }, { + IP: cloudflare.F("2001:DB8::/64"), + Port: cloudflare.F(int64(5053)), + RouteThroughPrivateNetwork: cloudflare.F(true), + VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), + }}), + }), + Egress: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsEgress{ + IPV4: cloudflare.F("192.0.2.2"), + IPV4Fallback: cloudflare.F("192.0.2.3"), + IPV6: cloudflare.F("2001:DB8::/64"), + }), + InsecureDisableDNSSECValidation: cloudflare.F(false), + IPCategories: cloudflare.F(true), + IPIndicatorFeeds: cloudflare.F(true), + L4override: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsL4override{ + IP: cloudflare.F("1.1.1.1"), + Port: cloudflare.F(int64(0)), + }), + NotificationSettings: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsNotificationSettings{ + Enabled: cloudflare.F(true), + Msg: cloudflare.F("string"), + SupportURL: cloudflare.F("string"), + }), + OverrideHost: cloudflare.F("example.com"), + OverrideIPs: cloudflare.F([]string{"1.1.1.1", "2.2.2.2"}), + PayloadLog: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsPayloadLog{ + Enabled: cloudflare.F(true), + }), + ResolveDNSThroughCloudflare: cloudflare.F(true), + UntrustedCert: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsUntrustedCert{ + Action: cloudflare.F(zero_trust.GatewayRuleNewParamsRuleSettingsUntrustedCertActionError), + }), + }), + Schedule: cloudflare.F(zero_trust.GatewayRuleNewParamsSchedule{ + Fri: cloudflare.F("08:00-12:30,13:30-17:00"), + Mon: cloudflare.F("08:00-12:30,13:30-17:00"), + Sat: cloudflare.F("08:00-12:30,13:30-17:00"), + Sun: cloudflare.F("08:00-12:30,13:30-17:00"), + Thu: cloudflare.F("08:00-12:30,13:30-17:00"), + TimeZone: cloudflare.F("America/New York"), + Tue: cloudflare.F("08:00-12:30,13:30-17:00"), + Wed: cloudflare.F("08:00-12:30,13:30-17:00"), + }), + Traffic: cloudflare.F("http.request.uri matches \".*a/partial/uri.*\" and http.request.host in $01302951-49f9-47c9-a400-0297e60b6a10"), + }) + 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 TestGatewayRuleUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Rules.Update( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.GatewayRuleUpdateParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + Action: cloudflare.F(zero_trust.GatewayRuleUpdateParamsActionAllow), + Name: cloudflare.F("block bad websites"), + Description: cloudflare.F("Block bad websites based on their host name."), + DevicePosture: cloudflare.F("any(device_posture.checks.passed[*] in {\"1308749e-fcfb-4ebc-b051-fe022b632644\"})"), + Enabled: cloudflare.F(true), + Filters: cloudflare.F([]zero_trust.GatewayRuleUpdateParamsFilter{zero_trust.GatewayRuleUpdateParamsFilterHTTP}), + Identity: cloudflare.F("any(identity.groups.name[*] in {\"finance\"})"), + Precedence: cloudflare.F(int64(0)), + RuleSettings: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettings{ + AddHeaders: cloudflare.F[any](map[string]interface{}{ + "My-Next-Header": map[string]interface{}{ + "0": "foo", + "1": "bar", + }, + "X-Custom-Header-Name": map[string]interface{}{ + "0": "somecustomvalue", + }, + }), + AllowChildBypass: cloudflare.F(false), + AuditSSH: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsAuditSSH{ + CommandLogging: cloudflare.F(false), + }), + BisoAdminControls: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsBisoAdminControls{ + Dcp: cloudflare.F(false), + Dd: cloudflare.F(false), + Dk: cloudflare.F(false), + Dp: cloudflare.F(false), + Du: cloudflare.F(false), + }), + BlockPageEnabled: cloudflare.F(true), + BlockReason: cloudflare.F("This website is a security risk"), + BypassParentRule: cloudflare.F(false), + CheckSession: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsCheckSession{ + Duration: cloudflare.F("300s"), + Enforce: cloudflare.F(true), + }), + DNSResolvers: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsDNSResolvers{ + IPV4: cloudflare.F([]zero_trust.GatewayRuleUpdateParamsRuleSettingsDNSResolversIPV4{{ + IP: cloudflare.F("2001:DB8::/64"), + Port: cloudflare.F(int64(5053)), + RouteThroughPrivateNetwork: cloudflare.F(true), + VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), + }, { + IP: cloudflare.F("2001:DB8::/64"), + Port: cloudflare.F(int64(5053)), + RouteThroughPrivateNetwork: cloudflare.F(true), + VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), + }, { + IP: cloudflare.F("2001:DB8::/64"), + Port: cloudflare.F(int64(5053)), + RouteThroughPrivateNetwork: cloudflare.F(true), + VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), + }}), + IPV6: cloudflare.F([]zero_trust.GatewayRuleUpdateParamsRuleSettingsDNSResolversIPV6{{ + IP: cloudflare.F("2001:DB8::/64"), + Port: cloudflare.F(int64(5053)), + RouteThroughPrivateNetwork: cloudflare.F(true), + VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), + }, { + IP: cloudflare.F("2001:DB8::/64"), + Port: cloudflare.F(int64(5053)), + RouteThroughPrivateNetwork: cloudflare.F(true), + VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), + }, { + IP: cloudflare.F("2001:DB8::/64"), + Port: cloudflare.F(int64(5053)), + RouteThroughPrivateNetwork: cloudflare.F(true), + VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), + }}), + }), + Egress: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsEgress{ + IPV4: cloudflare.F("192.0.2.2"), + IPV4Fallback: cloudflare.F("192.0.2.3"), + IPV6: cloudflare.F("2001:DB8::/64"), + }), + InsecureDisableDNSSECValidation: cloudflare.F(false), + IPCategories: cloudflare.F(true), + IPIndicatorFeeds: cloudflare.F(true), + L4override: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsL4override{ + IP: cloudflare.F("1.1.1.1"), + Port: cloudflare.F(int64(0)), + }), + NotificationSettings: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsNotificationSettings{ + Enabled: cloudflare.F(true), + Msg: cloudflare.F("string"), + SupportURL: cloudflare.F("string"), + }), + OverrideHost: cloudflare.F("example.com"), + OverrideIPs: cloudflare.F([]string{"1.1.1.1", "2.2.2.2"}), + PayloadLog: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsPayloadLog{ + Enabled: cloudflare.F(true), + }), + ResolveDNSThroughCloudflare: cloudflare.F(true), + UntrustedCert: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsUntrustedCert{ + Action: cloudflare.F(zero_trust.GatewayRuleUpdateParamsRuleSettingsUntrustedCertActionError), + }), + }), + Schedule: cloudflare.F(zero_trust.GatewayRuleUpdateParamsSchedule{ + Fri: cloudflare.F("08:00-12:30,13:30-17:00"), + Mon: cloudflare.F("08:00-12:30,13:30-17:00"), + Sat: cloudflare.F("08:00-12:30,13:30-17:00"), + Sun: cloudflare.F("08:00-12:30,13:30-17:00"), + Thu: cloudflare.F("08:00-12:30,13:30-17:00"), + TimeZone: cloudflare.F("America/New York"), + Tue: cloudflare.F("08:00-12:30,13:30-17:00"), + Wed: cloudflare.F("08:00-12:30,13:30-17:00"), + }), + Traffic: cloudflare.F("http.request.uri matches \".*a/partial/uri.*\" and http.request.host in $01302951-49f9-47c9-a400-0297e60b6a10"), + }, + ) + 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 TestGatewayRuleList(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Rules.List(context.TODO(), zero_trust.GatewayRuleListParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }) + 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 TestGatewayRuleDelete(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Rules.Delete( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.GatewayRuleDeleteParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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 TestGatewayRuleGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Gateway.Rules.Get( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.GatewayRuleGetParams{ + AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/identityprovider.go b/zero_trust/identityprovider.go new file mode 100644 index 00000000000..5421e2ad5f2 --- /dev/null +++ b/zero_trust/identityprovider.go @@ -0,0 +1,4918 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// IdentityProviderService 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 [NewIdentityProviderService] method +// instead. +type IdentityProviderService struct { + Options []option.RequestOption +} + +// NewIdentityProviderService 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 NewIdentityProviderService(opts ...option.RequestOption) (r *IdentityProviderService) { + r = &IdentityProviderService{} + r.Options = opts + return +} + +// Adds a new identity provider to Access. +func (r *IdentityProviderService) New(ctx context.Context, params IdentityProviderNewParams, opts ...option.RequestOption) (res *AccessIdentityProviders, err error) { + opts = append(r.Options[:], opts...) + var env IdentityProviderNewResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/access/identity_providers", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates a configured identity provider. +func (r *IdentityProviderService) Update(ctx context.Context, uuid string, params IdentityProviderUpdateParams, opts ...option.RequestOption) (res *AccessIdentityProviders, err error) { + opts = append(r.Options[:], opts...) + var env IdentityProviderUpdateResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/access/identity_providers/%s", accountOrZone, accountOrZoneID, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists all configured identity providers. +func (r *IdentityProviderService) List(ctx context.Context, query IdentityProviderListParams, opts ...option.RequestOption) (res *[]IdentityProviderListResponse, err error) { + opts = append(r.Options[:], opts...) + var env IdentityProviderListResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/access/identity_providers", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes an identity provider from Access. +func (r *IdentityProviderService) Delete(ctx context.Context, uuid string, body IdentityProviderDeleteParams, opts ...option.RequestOption) (res *IdentityProviderDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env IdentityProviderDeleteResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if body.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = body.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = body.ZoneID + } + path := fmt.Sprintf("%s/%s/access/identity_providers/%s", accountOrZone, accountOrZoneID, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a configured identity provider. +func (r *IdentityProviderService) Get(ctx context.Context, uuid string, query IdentityProviderGetParams, opts ...option.RequestOption) (res *AccessIdentityProviders, err error) { + opts = append(r.Options[:], opts...) + var env IdentityProviderGetResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/access/identity_providers/%s", accountOrZone, accountOrZoneID, uuid) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [zero_trust.AccessIdentityProvidersAccessAzureAd], +// [zero_trust.AccessIdentityProvidersAccessCentrify], +// [zero_trust.AccessIdentityProvidersAccessFacebook], +// [zero_trust.AccessIdentityProvidersAccessGitHub], +// [zero_trust.AccessIdentityProvidersAccessGoogle], +// [zero_trust.AccessIdentityProvidersAccessGoogleApps], +// [zero_trust.AccessIdentityProvidersAccessLinkedin], +// [zero_trust.AccessIdentityProvidersAccessOidc], +// [zero_trust.AccessIdentityProvidersAccessOkta], +// [zero_trust.AccessIdentityProvidersAccessOnelogin], +// [zero_trust.AccessIdentityProvidersAccessPingone], +// [zero_trust.AccessIdentityProvidersAccessSaml], +// [zero_trust.AccessIdentityProvidersAccessYandex] or +// [zero_trust.AccessIdentityProvidersAccessOnetimepin]. +type AccessIdentityProviders interface { + implementsZeroTrustAccessIdentityProviders() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessIdentityProviders)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessIdentityProvidersAccessAzureAd{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessIdentityProvidersAccessCentrify{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessIdentityProvidersAccessFacebook{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessIdentityProvidersAccessGitHub{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessIdentityProvidersAccessGoogle{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessIdentityProvidersAccessGoogleApps{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessIdentityProvidersAccessLinkedin{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessIdentityProvidersAccessOidc{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessIdentityProvidersAccessOkta{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessIdentityProvidersAccessOnelogin{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessIdentityProvidersAccessPingone{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessIdentityProvidersAccessSaml{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessIdentityProvidersAccessYandex{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(AccessIdentityProvidersAccessOnetimepin{}), + }, + ) +} + +type AccessIdentityProvidersAccessAzureAd struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config AccessIdentityProvidersAccessAzureAdConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type AccessIdentityProvidersAccessAzureAdType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig AccessIdentityProvidersAccessAzureAdScimConfig `json:"scim_config"` + JSON accessIdentityProvidersAccessAzureAdJSON `json:"-"` +} + +// accessIdentityProvidersAccessAzureAdJSON contains the JSON metadata for the +// struct [AccessIdentityProvidersAccessAzureAd] +type accessIdentityProvidersAccessAzureAdJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessAzureAd) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessAzureAdJSON) RawJSON() string { + return r.raw +} + +func (r AccessIdentityProvidersAccessAzureAd) implementsZeroTrustAccessIdentityProviders() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessAzureAdConfig struct { + // Custom claims + Claims []string `json:"claims"` + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + // Should Cloudflare try to load authentication contexts from your account + ConditionalAccessEnabled bool `json:"conditional_access_enabled"` + // Your Azure directory uuid + DirectoryID string `json:"directory_id"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + // Should Cloudflare try to load groups from your account + SupportGroups bool `json:"support_groups"` + JSON accessIdentityProvidersAccessAzureAdConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessAzureAdConfigJSON contains the JSON metadata for +// the struct [AccessIdentityProvidersAccessAzureAdConfig] +type accessIdentityProvidersAccessAzureAdConfigJSON struct { + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + ConditionalAccessEnabled apijson.Field + DirectoryID apijson.Field + EmailClaimName apijson.Field + SupportGroups apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessAzureAdConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessAzureAdConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessAzureAdType string + +const ( + AccessIdentityProvidersAccessAzureAdTypeOnetimepin AccessIdentityProvidersAccessAzureAdType = "onetimepin" + AccessIdentityProvidersAccessAzureAdTypeAzureAd AccessIdentityProvidersAccessAzureAdType = "azureAD" + AccessIdentityProvidersAccessAzureAdTypeSaml AccessIdentityProvidersAccessAzureAdType = "saml" + AccessIdentityProvidersAccessAzureAdTypeCentrify AccessIdentityProvidersAccessAzureAdType = "centrify" + AccessIdentityProvidersAccessAzureAdTypeFacebook AccessIdentityProvidersAccessAzureAdType = "facebook" + AccessIdentityProvidersAccessAzureAdTypeGitHub AccessIdentityProvidersAccessAzureAdType = "github" + AccessIdentityProvidersAccessAzureAdTypeGoogleApps AccessIdentityProvidersAccessAzureAdType = "google-apps" + AccessIdentityProvidersAccessAzureAdTypeGoogle AccessIdentityProvidersAccessAzureAdType = "google" + AccessIdentityProvidersAccessAzureAdTypeLinkedin AccessIdentityProvidersAccessAzureAdType = "linkedin" + AccessIdentityProvidersAccessAzureAdTypeOidc AccessIdentityProvidersAccessAzureAdType = "oidc" + AccessIdentityProvidersAccessAzureAdTypeOkta AccessIdentityProvidersAccessAzureAdType = "okta" + AccessIdentityProvidersAccessAzureAdTypeOnelogin AccessIdentityProvidersAccessAzureAdType = "onelogin" + AccessIdentityProvidersAccessAzureAdTypePingone AccessIdentityProvidersAccessAzureAdType = "pingone" + AccessIdentityProvidersAccessAzureAdTypeYandex AccessIdentityProvidersAccessAzureAdType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type AccessIdentityProvidersAccessAzureAdScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON accessIdentityProvidersAccessAzureAdScimConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessAzureAdScimConfigJSON contains the JSON metadata +// for the struct [AccessIdentityProvidersAccessAzureAdScimConfig] +type accessIdentityProvidersAccessAzureAdScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessAzureAdScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessAzureAdScimConfigJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityProvidersAccessCentrify struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config AccessIdentityProvidersAccessCentrifyConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type AccessIdentityProvidersAccessCentrifyType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig AccessIdentityProvidersAccessCentrifyScimConfig `json:"scim_config"` + JSON accessIdentityProvidersAccessCentrifyJSON `json:"-"` +} + +// accessIdentityProvidersAccessCentrifyJSON contains the JSON metadata for the +// struct [AccessIdentityProvidersAccessCentrify] +type accessIdentityProvidersAccessCentrifyJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessCentrify) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessCentrifyJSON) RawJSON() string { + return r.raw +} + +func (r AccessIdentityProvidersAccessCentrify) implementsZeroTrustAccessIdentityProviders() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessCentrifyConfig struct { + // Your centrify account url + CentrifyAccount string `json:"centrify_account"` + // Your centrify app id + CentrifyAppID string `json:"centrify_app_id"` + // Custom claims + Claims []string `json:"claims"` + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + JSON accessIdentityProvidersAccessCentrifyConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessCentrifyConfigJSON contains the JSON metadata for +// the struct [AccessIdentityProvidersAccessCentrifyConfig] +type accessIdentityProvidersAccessCentrifyConfigJSON struct { + CentrifyAccount apijson.Field + CentrifyAppID apijson.Field + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessCentrifyConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessCentrifyConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessCentrifyType string + +const ( + AccessIdentityProvidersAccessCentrifyTypeOnetimepin AccessIdentityProvidersAccessCentrifyType = "onetimepin" + AccessIdentityProvidersAccessCentrifyTypeAzureAd AccessIdentityProvidersAccessCentrifyType = "azureAD" + AccessIdentityProvidersAccessCentrifyTypeSaml AccessIdentityProvidersAccessCentrifyType = "saml" + AccessIdentityProvidersAccessCentrifyTypeCentrify AccessIdentityProvidersAccessCentrifyType = "centrify" + AccessIdentityProvidersAccessCentrifyTypeFacebook AccessIdentityProvidersAccessCentrifyType = "facebook" + AccessIdentityProvidersAccessCentrifyTypeGitHub AccessIdentityProvidersAccessCentrifyType = "github" + AccessIdentityProvidersAccessCentrifyTypeGoogleApps AccessIdentityProvidersAccessCentrifyType = "google-apps" + AccessIdentityProvidersAccessCentrifyTypeGoogle AccessIdentityProvidersAccessCentrifyType = "google" + AccessIdentityProvidersAccessCentrifyTypeLinkedin AccessIdentityProvidersAccessCentrifyType = "linkedin" + AccessIdentityProvidersAccessCentrifyTypeOidc AccessIdentityProvidersAccessCentrifyType = "oidc" + AccessIdentityProvidersAccessCentrifyTypeOkta AccessIdentityProvidersAccessCentrifyType = "okta" + AccessIdentityProvidersAccessCentrifyTypeOnelogin AccessIdentityProvidersAccessCentrifyType = "onelogin" + AccessIdentityProvidersAccessCentrifyTypePingone AccessIdentityProvidersAccessCentrifyType = "pingone" + AccessIdentityProvidersAccessCentrifyTypeYandex AccessIdentityProvidersAccessCentrifyType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type AccessIdentityProvidersAccessCentrifyScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON accessIdentityProvidersAccessCentrifyScimConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessCentrifyScimConfigJSON contains the JSON metadata +// for the struct [AccessIdentityProvidersAccessCentrifyScimConfig] +type accessIdentityProvidersAccessCentrifyScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessCentrifyScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessCentrifyScimConfigJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityProvidersAccessFacebook struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config AccessIdentityProvidersAccessFacebookConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type AccessIdentityProvidersAccessFacebookType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig AccessIdentityProvidersAccessFacebookScimConfig `json:"scim_config"` + JSON accessIdentityProvidersAccessFacebookJSON `json:"-"` +} + +// accessIdentityProvidersAccessFacebookJSON contains the JSON metadata for the +// struct [AccessIdentityProvidersAccessFacebook] +type accessIdentityProvidersAccessFacebookJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessFacebook) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessFacebookJSON) RawJSON() string { + return r.raw +} + +func (r AccessIdentityProvidersAccessFacebook) implementsZeroTrustAccessIdentityProviders() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessFacebookConfig struct { + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + JSON accessIdentityProvidersAccessFacebookConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessFacebookConfigJSON contains the JSON metadata for +// the struct [AccessIdentityProvidersAccessFacebookConfig] +type accessIdentityProvidersAccessFacebookConfigJSON struct { + ClientID apijson.Field + ClientSecret apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessFacebookConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessFacebookConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessFacebookType string + +const ( + AccessIdentityProvidersAccessFacebookTypeOnetimepin AccessIdentityProvidersAccessFacebookType = "onetimepin" + AccessIdentityProvidersAccessFacebookTypeAzureAd AccessIdentityProvidersAccessFacebookType = "azureAD" + AccessIdentityProvidersAccessFacebookTypeSaml AccessIdentityProvidersAccessFacebookType = "saml" + AccessIdentityProvidersAccessFacebookTypeCentrify AccessIdentityProvidersAccessFacebookType = "centrify" + AccessIdentityProvidersAccessFacebookTypeFacebook AccessIdentityProvidersAccessFacebookType = "facebook" + AccessIdentityProvidersAccessFacebookTypeGitHub AccessIdentityProvidersAccessFacebookType = "github" + AccessIdentityProvidersAccessFacebookTypeGoogleApps AccessIdentityProvidersAccessFacebookType = "google-apps" + AccessIdentityProvidersAccessFacebookTypeGoogle AccessIdentityProvidersAccessFacebookType = "google" + AccessIdentityProvidersAccessFacebookTypeLinkedin AccessIdentityProvidersAccessFacebookType = "linkedin" + AccessIdentityProvidersAccessFacebookTypeOidc AccessIdentityProvidersAccessFacebookType = "oidc" + AccessIdentityProvidersAccessFacebookTypeOkta AccessIdentityProvidersAccessFacebookType = "okta" + AccessIdentityProvidersAccessFacebookTypeOnelogin AccessIdentityProvidersAccessFacebookType = "onelogin" + AccessIdentityProvidersAccessFacebookTypePingone AccessIdentityProvidersAccessFacebookType = "pingone" + AccessIdentityProvidersAccessFacebookTypeYandex AccessIdentityProvidersAccessFacebookType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type AccessIdentityProvidersAccessFacebookScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON accessIdentityProvidersAccessFacebookScimConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessFacebookScimConfigJSON contains the JSON metadata +// for the struct [AccessIdentityProvidersAccessFacebookScimConfig] +type accessIdentityProvidersAccessFacebookScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessFacebookScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessFacebookScimConfigJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityProvidersAccessGitHub struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config AccessIdentityProvidersAccessGitHubConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type AccessIdentityProvidersAccessGitHubType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig AccessIdentityProvidersAccessGitHubScimConfig `json:"scim_config"` + JSON accessIdentityProvidersAccessGitHubJSON `json:"-"` +} + +// accessIdentityProvidersAccessGitHubJSON contains the JSON metadata for the +// struct [AccessIdentityProvidersAccessGitHub] +type accessIdentityProvidersAccessGitHubJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessGitHub) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessGitHubJSON) RawJSON() string { + return r.raw +} + +func (r AccessIdentityProvidersAccessGitHub) implementsZeroTrustAccessIdentityProviders() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessGitHubConfig struct { + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + JSON accessIdentityProvidersAccessGitHubConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessGitHubConfigJSON contains the JSON metadata for the +// struct [AccessIdentityProvidersAccessGitHubConfig] +type accessIdentityProvidersAccessGitHubConfigJSON struct { + ClientID apijson.Field + ClientSecret apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessGitHubConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessGitHubConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessGitHubType string + +const ( + AccessIdentityProvidersAccessGitHubTypeOnetimepin AccessIdentityProvidersAccessGitHubType = "onetimepin" + AccessIdentityProvidersAccessGitHubTypeAzureAd AccessIdentityProvidersAccessGitHubType = "azureAD" + AccessIdentityProvidersAccessGitHubTypeSaml AccessIdentityProvidersAccessGitHubType = "saml" + AccessIdentityProvidersAccessGitHubTypeCentrify AccessIdentityProvidersAccessGitHubType = "centrify" + AccessIdentityProvidersAccessGitHubTypeFacebook AccessIdentityProvidersAccessGitHubType = "facebook" + AccessIdentityProvidersAccessGitHubTypeGitHub AccessIdentityProvidersAccessGitHubType = "github" + AccessIdentityProvidersAccessGitHubTypeGoogleApps AccessIdentityProvidersAccessGitHubType = "google-apps" + AccessIdentityProvidersAccessGitHubTypeGoogle AccessIdentityProvidersAccessGitHubType = "google" + AccessIdentityProvidersAccessGitHubTypeLinkedin AccessIdentityProvidersAccessGitHubType = "linkedin" + AccessIdentityProvidersAccessGitHubTypeOidc AccessIdentityProvidersAccessGitHubType = "oidc" + AccessIdentityProvidersAccessGitHubTypeOkta AccessIdentityProvidersAccessGitHubType = "okta" + AccessIdentityProvidersAccessGitHubTypeOnelogin AccessIdentityProvidersAccessGitHubType = "onelogin" + AccessIdentityProvidersAccessGitHubTypePingone AccessIdentityProvidersAccessGitHubType = "pingone" + AccessIdentityProvidersAccessGitHubTypeYandex AccessIdentityProvidersAccessGitHubType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type AccessIdentityProvidersAccessGitHubScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON accessIdentityProvidersAccessGitHubScimConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessGitHubScimConfigJSON contains the JSON metadata for +// the struct [AccessIdentityProvidersAccessGitHubScimConfig] +type accessIdentityProvidersAccessGitHubScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessGitHubScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessGitHubScimConfigJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityProvidersAccessGoogle struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config AccessIdentityProvidersAccessGoogleConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type AccessIdentityProvidersAccessGoogleType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig AccessIdentityProvidersAccessGoogleScimConfig `json:"scim_config"` + JSON accessIdentityProvidersAccessGoogleJSON `json:"-"` +} + +// accessIdentityProvidersAccessGoogleJSON contains the JSON metadata for the +// struct [AccessIdentityProvidersAccessGoogle] +type accessIdentityProvidersAccessGoogleJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessGoogle) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessGoogleJSON) RawJSON() string { + return r.raw +} + +func (r AccessIdentityProvidersAccessGoogle) implementsZeroTrustAccessIdentityProviders() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessGoogleConfig struct { + // Custom claims + Claims []string `json:"claims"` + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + JSON accessIdentityProvidersAccessGoogleConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessGoogleConfigJSON contains the JSON metadata for the +// struct [AccessIdentityProvidersAccessGoogleConfig] +type accessIdentityProvidersAccessGoogleConfigJSON struct { + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessGoogleConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessGoogleConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessGoogleType string + +const ( + AccessIdentityProvidersAccessGoogleTypeOnetimepin AccessIdentityProvidersAccessGoogleType = "onetimepin" + AccessIdentityProvidersAccessGoogleTypeAzureAd AccessIdentityProvidersAccessGoogleType = "azureAD" + AccessIdentityProvidersAccessGoogleTypeSaml AccessIdentityProvidersAccessGoogleType = "saml" + AccessIdentityProvidersAccessGoogleTypeCentrify AccessIdentityProvidersAccessGoogleType = "centrify" + AccessIdentityProvidersAccessGoogleTypeFacebook AccessIdentityProvidersAccessGoogleType = "facebook" + AccessIdentityProvidersAccessGoogleTypeGitHub AccessIdentityProvidersAccessGoogleType = "github" + AccessIdentityProvidersAccessGoogleTypeGoogleApps AccessIdentityProvidersAccessGoogleType = "google-apps" + AccessIdentityProvidersAccessGoogleTypeGoogle AccessIdentityProvidersAccessGoogleType = "google" + AccessIdentityProvidersAccessGoogleTypeLinkedin AccessIdentityProvidersAccessGoogleType = "linkedin" + AccessIdentityProvidersAccessGoogleTypeOidc AccessIdentityProvidersAccessGoogleType = "oidc" + AccessIdentityProvidersAccessGoogleTypeOkta AccessIdentityProvidersAccessGoogleType = "okta" + AccessIdentityProvidersAccessGoogleTypeOnelogin AccessIdentityProvidersAccessGoogleType = "onelogin" + AccessIdentityProvidersAccessGoogleTypePingone AccessIdentityProvidersAccessGoogleType = "pingone" + AccessIdentityProvidersAccessGoogleTypeYandex AccessIdentityProvidersAccessGoogleType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type AccessIdentityProvidersAccessGoogleScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON accessIdentityProvidersAccessGoogleScimConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessGoogleScimConfigJSON contains the JSON metadata for +// the struct [AccessIdentityProvidersAccessGoogleScimConfig] +type accessIdentityProvidersAccessGoogleScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessGoogleScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessGoogleScimConfigJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityProvidersAccessGoogleApps struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config AccessIdentityProvidersAccessGoogleAppsConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type AccessIdentityProvidersAccessGoogleAppsType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig AccessIdentityProvidersAccessGoogleAppsScimConfig `json:"scim_config"` + JSON accessIdentityProvidersAccessGoogleAppsJSON `json:"-"` +} + +// accessIdentityProvidersAccessGoogleAppsJSON contains the JSON metadata for the +// struct [AccessIdentityProvidersAccessGoogleApps] +type accessIdentityProvidersAccessGoogleAppsJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessGoogleApps) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessGoogleAppsJSON) RawJSON() string { + return r.raw +} + +func (r AccessIdentityProvidersAccessGoogleApps) implementsZeroTrustAccessIdentityProviders() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessGoogleAppsConfig struct { + // Your companies TLD + AppsDomain string `json:"apps_domain"` + // Custom claims + Claims []string `json:"claims"` + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + JSON accessIdentityProvidersAccessGoogleAppsConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessGoogleAppsConfigJSON contains the JSON metadata for +// the struct [AccessIdentityProvidersAccessGoogleAppsConfig] +type accessIdentityProvidersAccessGoogleAppsConfigJSON struct { + AppsDomain apijson.Field + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessGoogleAppsConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessGoogleAppsConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessGoogleAppsType string + +const ( + AccessIdentityProvidersAccessGoogleAppsTypeOnetimepin AccessIdentityProvidersAccessGoogleAppsType = "onetimepin" + AccessIdentityProvidersAccessGoogleAppsTypeAzureAd AccessIdentityProvidersAccessGoogleAppsType = "azureAD" + AccessIdentityProvidersAccessGoogleAppsTypeSaml AccessIdentityProvidersAccessGoogleAppsType = "saml" + AccessIdentityProvidersAccessGoogleAppsTypeCentrify AccessIdentityProvidersAccessGoogleAppsType = "centrify" + AccessIdentityProvidersAccessGoogleAppsTypeFacebook AccessIdentityProvidersAccessGoogleAppsType = "facebook" + AccessIdentityProvidersAccessGoogleAppsTypeGitHub AccessIdentityProvidersAccessGoogleAppsType = "github" + AccessIdentityProvidersAccessGoogleAppsTypeGoogleApps AccessIdentityProvidersAccessGoogleAppsType = "google-apps" + AccessIdentityProvidersAccessGoogleAppsTypeGoogle AccessIdentityProvidersAccessGoogleAppsType = "google" + AccessIdentityProvidersAccessGoogleAppsTypeLinkedin AccessIdentityProvidersAccessGoogleAppsType = "linkedin" + AccessIdentityProvidersAccessGoogleAppsTypeOidc AccessIdentityProvidersAccessGoogleAppsType = "oidc" + AccessIdentityProvidersAccessGoogleAppsTypeOkta AccessIdentityProvidersAccessGoogleAppsType = "okta" + AccessIdentityProvidersAccessGoogleAppsTypeOnelogin AccessIdentityProvidersAccessGoogleAppsType = "onelogin" + AccessIdentityProvidersAccessGoogleAppsTypePingone AccessIdentityProvidersAccessGoogleAppsType = "pingone" + AccessIdentityProvidersAccessGoogleAppsTypeYandex AccessIdentityProvidersAccessGoogleAppsType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type AccessIdentityProvidersAccessGoogleAppsScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON accessIdentityProvidersAccessGoogleAppsScimConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessGoogleAppsScimConfigJSON contains the JSON metadata +// for the struct [AccessIdentityProvidersAccessGoogleAppsScimConfig] +type accessIdentityProvidersAccessGoogleAppsScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessGoogleAppsScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessGoogleAppsScimConfigJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityProvidersAccessLinkedin struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config AccessIdentityProvidersAccessLinkedinConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type AccessIdentityProvidersAccessLinkedinType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig AccessIdentityProvidersAccessLinkedinScimConfig `json:"scim_config"` + JSON accessIdentityProvidersAccessLinkedinJSON `json:"-"` +} + +// accessIdentityProvidersAccessLinkedinJSON contains the JSON metadata for the +// struct [AccessIdentityProvidersAccessLinkedin] +type accessIdentityProvidersAccessLinkedinJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessLinkedin) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessLinkedinJSON) RawJSON() string { + return r.raw +} + +func (r AccessIdentityProvidersAccessLinkedin) implementsZeroTrustAccessIdentityProviders() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessLinkedinConfig struct { + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + JSON accessIdentityProvidersAccessLinkedinConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessLinkedinConfigJSON contains the JSON metadata for +// the struct [AccessIdentityProvidersAccessLinkedinConfig] +type accessIdentityProvidersAccessLinkedinConfigJSON struct { + ClientID apijson.Field + ClientSecret apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessLinkedinConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessLinkedinConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessLinkedinType string + +const ( + AccessIdentityProvidersAccessLinkedinTypeOnetimepin AccessIdentityProvidersAccessLinkedinType = "onetimepin" + AccessIdentityProvidersAccessLinkedinTypeAzureAd AccessIdentityProvidersAccessLinkedinType = "azureAD" + AccessIdentityProvidersAccessLinkedinTypeSaml AccessIdentityProvidersAccessLinkedinType = "saml" + AccessIdentityProvidersAccessLinkedinTypeCentrify AccessIdentityProvidersAccessLinkedinType = "centrify" + AccessIdentityProvidersAccessLinkedinTypeFacebook AccessIdentityProvidersAccessLinkedinType = "facebook" + AccessIdentityProvidersAccessLinkedinTypeGitHub AccessIdentityProvidersAccessLinkedinType = "github" + AccessIdentityProvidersAccessLinkedinTypeGoogleApps AccessIdentityProvidersAccessLinkedinType = "google-apps" + AccessIdentityProvidersAccessLinkedinTypeGoogle AccessIdentityProvidersAccessLinkedinType = "google" + AccessIdentityProvidersAccessLinkedinTypeLinkedin AccessIdentityProvidersAccessLinkedinType = "linkedin" + AccessIdentityProvidersAccessLinkedinTypeOidc AccessIdentityProvidersAccessLinkedinType = "oidc" + AccessIdentityProvidersAccessLinkedinTypeOkta AccessIdentityProvidersAccessLinkedinType = "okta" + AccessIdentityProvidersAccessLinkedinTypeOnelogin AccessIdentityProvidersAccessLinkedinType = "onelogin" + AccessIdentityProvidersAccessLinkedinTypePingone AccessIdentityProvidersAccessLinkedinType = "pingone" + AccessIdentityProvidersAccessLinkedinTypeYandex AccessIdentityProvidersAccessLinkedinType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type AccessIdentityProvidersAccessLinkedinScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON accessIdentityProvidersAccessLinkedinScimConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessLinkedinScimConfigJSON contains the JSON metadata +// for the struct [AccessIdentityProvidersAccessLinkedinScimConfig] +type accessIdentityProvidersAccessLinkedinScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessLinkedinScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessLinkedinScimConfigJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityProvidersAccessOidc struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config AccessIdentityProvidersAccessOidcConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type AccessIdentityProvidersAccessOidcType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig AccessIdentityProvidersAccessOidcScimConfig `json:"scim_config"` + JSON accessIdentityProvidersAccessOidcJSON `json:"-"` +} + +// accessIdentityProvidersAccessOidcJSON contains the JSON metadata for the struct +// [AccessIdentityProvidersAccessOidc] +type accessIdentityProvidersAccessOidcJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessOidc) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessOidcJSON) RawJSON() string { + return r.raw +} + +func (r AccessIdentityProvidersAccessOidc) implementsZeroTrustAccessIdentityProviders() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessOidcConfig struct { + // The authorization_endpoint URL of your IdP + AuthURL string `json:"auth_url"` + // The jwks_uri endpoint of your IdP to allow the IdP keys to sign the tokens + CertsURL string `json:"certs_url"` + // Custom claims + Claims []string `json:"claims"` + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + // OAuth scopes + Scopes []string `json:"scopes"` + // The token_endpoint URL of your IdP + TokenURL string `json:"token_url"` + JSON accessIdentityProvidersAccessOidcConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessOidcConfigJSON contains the JSON metadata for the +// struct [AccessIdentityProvidersAccessOidcConfig] +type accessIdentityProvidersAccessOidcConfigJSON struct { + AuthURL apijson.Field + CertsURL apijson.Field + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + Scopes apijson.Field + TokenURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessOidcConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessOidcConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessOidcType string + +const ( + AccessIdentityProvidersAccessOidcTypeOnetimepin AccessIdentityProvidersAccessOidcType = "onetimepin" + AccessIdentityProvidersAccessOidcTypeAzureAd AccessIdentityProvidersAccessOidcType = "azureAD" + AccessIdentityProvidersAccessOidcTypeSaml AccessIdentityProvidersAccessOidcType = "saml" + AccessIdentityProvidersAccessOidcTypeCentrify AccessIdentityProvidersAccessOidcType = "centrify" + AccessIdentityProvidersAccessOidcTypeFacebook AccessIdentityProvidersAccessOidcType = "facebook" + AccessIdentityProvidersAccessOidcTypeGitHub AccessIdentityProvidersAccessOidcType = "github" + AccessIdentityProvidersAccessOidcTypeGoogleApps AccessIdentityProvidersAccessOidcType = "google-apps" + AccessIdentityProvidersAccessOidcTypeGoogle AccessIdentityProvidersAccessOidcType = "google" + AccessIdentityProvidersAccessOidcTypeLinkedin AccessIdentityProvidersAccessOidcType = "linkedin" + AccessIdentityProvidersAccessOidcTypeOidc AccessIdentityProvidersAccessOidcType = "oidc" + AccessIdentityProvidersAccessOidcTypeOkta AccessIdentityProvidersAccessOidcType = "okta" + AccessIdentityProvidersAccessOidcTypeOnelogin AccessIdentityProvidersAccessOidcType = "onelogin" + AccessIdentityProvidersAccessOidcTypePingone AccessIdentityProvidersAccessOidcType = "pingone" + AccessIdentityProvidersAccessOidcTypeYandex AccessIdentityProvidersAccessOidcType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type AccessIdentityProvidersAccessOidcScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON accessIdentityProvidersAccessOidcScimConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessOidcScimConfigJSON contains the JSON metadata for +// the struct [AccessIdentityProvidersAccessOidcScimConfig] +type accessIdentityProvidersAccessOidcScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessOidcScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessOidcScimConfigJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityProvidersAccessOkta struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config AccessIdentityProvidersAccessOktaConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type AccessIdentityProvidersAccessOktaType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig AccessIdentityProvidersAccessOktaScimConfig `json:"scim_config"` + JSON accessIdentityProvidersAccessOktaJSON `json:"-"` +} + +// accessIdentityProvidersAccessOktaJSON contains the JSON metadata for the struct +// [AccessIdentityProvidersAccessOkta] +type accessIdentityProvidersAccessOktaJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessOkta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessOktaJSON) RawJSON() string { + return r.raw +} + +func (r AccessIdentityProvidersAccessOkta) implementsZeroTrustAccessIdentityProviders() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessOktaConfig struct { + // Your okta authorization server id + AuthorizationServerID string `json:"authorization_server_id"` + // Custom claims + Claims []string `json:"claims"` + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + // Your okta account url + OktaAccount string `json:"okta_account"` + JSON accessIdentityProvidersAccessOktaConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessOktaConfigJSON contains the JSON metadata for the +// struct [AccessIdentityProvidersAccessOktaConfig] +type accessIdentityProvidersAccessOktaConfigJSON struct { + AuthorizationServerID apijson.Field + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + OktaAccount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessOktaConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessOktaConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessOktaType string + +const ( + AccessIdentityProvidersAccessOktaTypeOnetimepin AccessIdentityProvidersAccessOktaType = "onetimepin" + AccessIdentityProvidersAccessOktaTypeAzureAd AccessIdentityProvidersAccessOktaType = "azureAD" + AccessIdentityProvidersAccessOktaTypeSaml AccessIdentityProvidersAccessOktaType = "saml" + AccessIdentityProvidersAccessOktaTypeCentrify AccessIdentityProvidersAccessOktaType = "centrify" + AccessIdentityProvidersAccessOktaTypeFacebook AccessIdentityProvidersAccessOktaType = "facebook" + AccessIdentityProvidersAccessOktaTypeGitHub AccessIdentityProvidersAccessOktaType = "github" + AccessIdentityProvidersAccessOktaTypeGoogleApps AccessIdentityProvidersAccessOktaType = "google-apps" + AccessIdentityProvidersAccessOktaTypeGoogle AccessIdentityProvidersAccessOktaType = "google" + AccessIdentityProvidersAccessOktaTypeLinkedin AccessIdentityProvidersAccessOktaType = "linkedin" + AccessIdentityProvidersAccessOktaTypeOidc AccessIdentityProvidersAccessOktaType = "oidc" + AccessIdentityProvidersAccessOktaTypeOkta AccessIdentityProvidersAccessOktaType = "okta" + AccessIdentityProvidersAccessOktaTypeOnelogin AccessIdentityProvidersAccessOktaType = "onelogin" + AccessIdentityProvidersAccessOktaTypePingone AccessIdentityProvidersAccessOktaType = "pingone" + AccessIdentityProvidersAccessOktaTypeYandex AccessIdentityProvidersAccessOktaType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type AccessIdentityProvidersAccessOktaScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON accessIdentityProvidersAccessOktaScimConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessOktaScimConfigJSON contains the JSON metadata for +// the struct [AccessIdentityProvidersAccessOktaScimConfig] +type accessIdentityProvidersAccessOktaScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessOktaScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessOktaScimConfigJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityProvidersAccessOnelogin struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config AccessIdentityProvidersAccessOneloginConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type AccessIdentityProvidersAccessOneloginType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig AccessIdentityProvidersAccessOneloginScimConfig `json:"scim_config"` + JSON accessIdentityProvidersAccessOneloginJSON `json:"-"` +} + +// accessIdentityProvidersAccessOneloginJSON contains the JSON metadata for the +// struct [AccessIdentityProvidersAccessOnelogin] +type accessIdentityProvidersAccessOneloginJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessOnelogin) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessOneloginJSON) RawJSON() string { + return r.raw +} + +func (r AccessIdentityProvidersAccessOnelogin) implementsZeroTrustAccessIdentityProviders() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessOneloginConfig struct { + // Custom claims + Claims []string `json:"claims"` + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + // Your OneLogin account url + OneloginAccount string `json:"onelogin_account"` + JSON accessIdentityProvidersAccessOneloginConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessOneloginConfigJSON contains the JSON metadata for +// the struct [AccessIdentityProvidersAccessOneloginConfig] +type accessIdentityProvidersAccessOneloginConfigJSON struct { + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + OneloginAccount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessOneloginConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessOneloginConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessOneloginType string + +const ( + AccessIdentityProvidersAccessOneloginTypeOnetimepin AccessIdentityProvidersAccessOneloginType = "onetimepin" + AccessIdentityProvidersAccessOneloginTypeAzureAd AccessIdentityProvidersAccessOneloginType = "azureAD" + AccessIdentityProvidersAccessOneloginTypeSaml AccessIdentityProvidersAccessOneloginType = "saml" + AccessIdentityProvidersAccessOneloginTypeCentrify AccessIdentityProvidersAccessOneloginType = "centrify" + AccessIdentityProvidersAccessOneloginTypeFacebook AccessIdentityProvidersAccessOneloginType = "facebook" + AccessIdentityProvidersAccessOneloginTypeGitHub AccessIdentityProvidersAccessOneloginType = "github" + AccessIdentityProvidersAccessOneloginTypeGoogleApps AccessIdentityProvidersAccessOneloginType = "google-apps" + AccessIdentityProvidersAccessOneloginTypeGoogle AccessIdentityProvidersAccessOneloginType = "google" + AccessIdentityProvidersAccessOneloginTypeLinkedin AccessIdentityProvidersAccessOneloginType = "linkedin" + AccessIdentityProvidersAccessOneloginTypeOidc AccessIdentityProvidersAccessOneloginType = "oidc" + AccessIdentityProvidersAccessOneloginTypeOkta AccessIdentityProvidersAccessOneloginType = "okta" + AccessIdentityProvidersAccessOneloginTypeOnelogin AccessIdentityProvidersAccessOneloginType = "onelogin" + AccessIdentityProvidersAccessOneloginTypePingone AccessIdentityProvidersAccessOneloginType = "pingone" + AccessIdentityProvidersAccessOneloginTypeYandex AccessIdentityProvidersAccessOneloginType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type AccessIdentityProvidersAccessOneloginScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON accessIdentityProvidersAccessOneloginScimConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessOneloginScimConfigJSON contains the JSON metadata +// for the struct [AccessIdentityProvidersAccessOneloginScimConfig] +type accessIdentityProvidersAccessOneloginScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessOneloginScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessOneloginScimConfigJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityProvidersAccessPingone struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config AccessIdentityProvidersAccessPingoneConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type AccessIdentityProvidersAccessPingoneType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig AccessIdentityProvidersAccessPingoneScimConfig `json:"scim_config"` + JSON accessIdentityProvidersAccessPingoneJSON `json:"-"` +} + +// accessIdentityProvidersAccessPingoneJSON contains the JSON metadata for the +// struct [AccessIdentityProvidersAccessPingone] +type accessIdentityProvidersAccessPingoneJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessPingone) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessPingoneJSON) RawJSON() string { + return r.raw +} + +func (r AccessIdentityProvidersAccessPingone) implementsZeroTrustAccessIdentityProviders() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessPingoneConfig struct { + // Custom claims + Claims []string `json:"claims"` + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + // Your PingOne environment identifier + PingEnvID string `json:"ping_env_id"` + JSON accessIdentityProvidersAccessPingoneConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessPingoneConfigJSON contains the JSON metadata for +// the struct [AccessIdentityProvidersAccessPingoneConfig] +type accessIdentityProvidersAccessPingoneConfigJSON struct { + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + PingEnvID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessPingoneConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessPingoneConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessPingoneType string + +const ( + AccessIdentityProvidersAccessPingoneTypeOnetimepin AccessIdentityProvidersAccessPingoneType = "onetimepin" + AccessIdentityProvidersAccessPingoneTypeAzureAd AccessIdentityProvidersAccessPingoneType = "azureAD" + AccessIdentityProvidersAccessPingoneTypeSaml AccessIdentityProvidersAccessPingoneType = "saml" + AccessIdentityProvidersAccessPingoneTypeCentrify AccessIdentityProvidersAccessPingoneType = "centrify" + AccessIdentityProvidersAccessPingoneTypeFacebook AccessIdentityProvidersAccessPingoneType = "facebook" + AccessIdentityProvidersAccessPingoneTypeGitHub AccessIdentityProvidersAccessPingoneType = "github" + AccessIdentityProvidersAccessPingoneTypeGoogleApps AccessIdentityProvidersAccessPingoneType = "google-apps" + AccessIdentityProvidersAccessPingoneTypeGoogle AccessIdentityProvidersAccessPingoneType = "google" + AccessIdentityProvidersAccessPingoneTypeLinkedin AccessIdentityProvidersAccessPingoneType = "linkedin" + AccessIdentityProvidersAccessPingoneTypeOidc AccessIdentityProvidersAccessPingoneType = "oidc" + AccessIdentityProvidersAccessPingoneTypeOkta AccessIdentityProvidersAccessPingoneType = "okta" + AccessIdentityProvidersAccessPingoneTypeOnelogin AccessIdentityProvidersAccessPingoneType = "onelogin" + AccessIdentityProvidersAccessPingoneTypePingone AccessIdentityProvidersAccessPingoneType = "pingone" + AccessIdentityProvidersAccessPingoneTypeYandex AccessIdentityProvidersAccessPingoneType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type AccessIdentityProvidersAccessPingoneScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON accessIdentityProvidersAccessPingoneScimConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessPingoneScimConfigJSON contains the JSON metadata +// for the struct [AccessIdentityProvidersAccessPingoneScimConfig] +type accessIdentityProvidersAccessPingoneScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessPingoneScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessPingoneScimConfigJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityProvidersAccessSaml struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config AccessIdentityProvidersAccessSamlConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type AccessIdentityProvidersAccessSamlType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig AccessIdentityProvidersAccessSamlScimConfig `json:"scim_config"` + JSON accessIdentityProvidersAccessSamlJSON `json:"-"` +} + +// accessIdentityProvidersAccessSamlJSON contains the JSON metadata for the struct +// [AccessIdentityProvidersAccessSaml] +type accessIdentityProvidersAccessSamlJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessSaml) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessSamlJSON) RawJSON() string { + return r.raw +} + +func (r AccessIdentityProvidersAccessSaml) implementsZeroTrustAccessIdentityProviders() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessSamlConfig struct { + // A list of SAML attribute names that will be added to your signed JWT token and + // can be used in SAML policy rules. + Attributes []string `json:"attributes"` + // The attribute name for email in the SAML response. + EmailAttributeName string `json:"email_attribute_name"` + // Add a list of attribute names that will be returned in the response header from + // the Access callback. + HeaderAttributes []AccessIdentityProvidersAccessSamlConfigHeaderAttribute `json:"header_attributes"` + // X509 certificate to verify the signature in the SAML authentication response + IdpPublicCerts []string `json:"idp_public_certs"` + // IdP Entity ID or Issuer URL + IssuerURL string `json:"issuer_url"` + // Sign the SAML authentication request with Access credentials. To verify the + // signature, use the public key from the Access certs endpoints. + SignRequest bool `json:"sign_request"` + // URL to send the SAML authentication requests to + SSOTargetURL string `json:"sso_target_url"` + JSON accessIdentityProvidersAccessSamlConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessSamlConfigJSON contains the JSON metadata for the +// struct [AccessIdentityProvidersAccessSamlConfig] +type accessIdentityProvidersAccessSamlConfigJSON struct { + Attributes apijson.Field + EmailAttributeName apijson.Field + HeaderAttributes apijson.Field + IdpPublicCerts apijson.Field + IssuerURL apijson.Field + SignRequest apijson.Field + SSOTargetURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessSamlConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessSamlConfigJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityProvidersAccessSamlConfigHeaderAttribute struct { + // attribute name from the IDP + AttributeName string `json:"attribute_name"` + // header that will be added on the request to the origin + HeaderName string `json:"header_name"` + JSON accessIdentityProvidersAccessSamlConfigHeaderAttributeJSON `json:"-"` +} + +// accessIdentityProvidersAccessSamlConfigHeaderAttributeJSON contains the JSON +// metadata for the struct [AccessIdentityProvidersAccessSamlConfigHeaderAttribute] +type accessIdentityProvidersAccessSamlConfigHeaderAttributeJSON struct { + AttributeName apijson.Field + HeaderName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessSamlConfigHeaderAttribute) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessSamlConfigHeaderAttributeJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessSamlType string + +const ( + AccessIdentityProvidersAccessSamlTypeOnetimepin AccessIdentityProvidersAccessSamlType = "onetimepin" + AccessIdentityProvidersAccessSamlTypeAzureAd AccessIdentityProvidersAccessSamlType = "azureAD" + AccessIdentityProvidersAccessSamlTypeSaml AccessIdentityProvidersAccessSamlType = "saml" + AccessIdentityProvidersAccessSamlTypeCentrify AccessIdentityProvidersAccessSamlType = "centrify" + AccessIdentityProvidersAccessSamlTypeFacebook AccessIdentityProvidersAccessSamlType = "facebook" + AccessIdentityProvidersAccessSamlTypeGitHub AccessIdentityProvidersAccessSamlType = "github" + AccessIdentityProvidersAccessSamlTypeGoogleApps AccessIdentityProvidersAccessSamlType = "google-apps" + AccessIdentityProvidersAccessSamlTypeGoogle AccessIdentityProvidersAccessSamlType = "google" + AccessIdentityProvidersAccessSamlTypeLinkedin AccessIdentityProvidersAccessSamlType = "linkedin" + AccessIdentityProvidersAccessSamlTypeOidc AccessIdentityProvidersAccessSamlType = "oidc" + AccessIdentityProvidersAccessSamlTypeOkta AccessIdentityProvidersAccessSamlType = "okta" + AccessIdentityProvidersAccessSamlTypeOnelogin AccessIdentityProvidersAccessSamlType = "onelogin" + AccessIdentityProvidersAccessSamlTypePingone AccessIdentityProvidersAccessSamlType = "pingone" + AccessIdentityProvidersAccessSamlTypeYandex AccessIdentityProvidersAccessSamlType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type AccessIdentityProvidersAccessSamlScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON accessIdentityProvidersAccessSamlScimConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessSamlScimConfigJSON contains the JSON metadata for +// the struct [AccessIdentityProvidersAccessSamlScimConfig] +type accessIdentityProvidersAccessSamlScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessSamlScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessSamlScimConfigJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityProvidersAccessYandex struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config AccessIdentityProvidersAccessYandexConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type AccessIdentityProvidersAccessYandexType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig AccessIdentityProvidersAccessYandexScimConfig `json:"scim_config"` + JSON accessIdentityProvidersAccessYandexJSON `json:"-"` +} + +// accessIdentityProvidersAccessYandexJSON contains the JSON metadata for the +// struct [AccessIdentityProvidersAccessYandex] +type accessIdentityProvidersAccessYandexJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessYandex) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessYandexJSON) RawJSON() string { + return r.raw +} + +func (r AccessIdentityProvidersAccessYandex) implementsZeroTrustAccessIdentityProviders() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessYandexConfig struct { + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + JSON accessIdentityProvidersAccessYandexConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessYandexConfigJSON contains the JSON metadata for the +// struct [AccessIdentityProvidersAccessYandexConfig] +type accessIdentityProvidersAccessYandexConfigJSON struct { + ClientID apijson.Field + ClientSecret apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessYandexConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessYandexConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessYandexType string + +const ( + AccessIdentityProvidersAccessYandexTypeOnetimepin AccessIdentityProvidersAccessYandexType = "onetimepin" + AccessIdentityProvidersAccessYandexTypeAzureAd AccessIdentityProvidersAccessYandexType = "azureAD" + AccessIdentityProvidersAccessYandexTypeSaml AccessIdentityProvidersAccessYandexType = "saml" + AccessIdentityProvidersAccessYandexTypeCentrify AccessIdentityProvidersAccessYandexType = "centrify" + AccessIdentityProvidersAccessYandexTypeFacebook AccessIdentityProvidersAccessYandexType = "facebook" + AccessIdentityProvidersAccessYandexTypeGitHub AccessIdentityProvidersAccessYandexType = "github" + AccessIdentityProvidersAccessYandexTypeGoogleApps AccessIdentityProvidersAccessYandexType = "google-apps" + AccessIdentityProvidersAccessYandexTypeGoogle AccessIdentityProvidersAccessYandexType = "google" + AccessIdentityProvidersAccessYandexTypeLinkedin AccessIdentityProvidersAccessYandexType = "linkedin" + AccessIdentityProvidersAccessYandexTypeOidc AccessIdentityProvidersAccessYandexType = "oidc" + AccessIdentityProvidersAccessYandexTypeOkta AccessIdentityProvidersAccessYandexType = "okta" + AccessIdentityProvidersAccessYandexTypeOnelogin AccessIdentityProvidersAccessYandexType = "onelogin" + AccessIdentityProvidersAccessYandexTypePingone AccessIdentityProvidersAccessYandexType = "pingone" + AccessIdentityProvidersAccessYandexTypeYandex AccessIdentityProvidersAccessYandexType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type AccessIdentityProvidersAccessYandexScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON accessIdentityProvidersAccessYandexScimConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessYandexScimConfigJSON contains the JSON metadata for +// the struct [AccessIdentityProvidersAccessYandexScimConfig] +type accessIdentityProvidersAccessYandexScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessYandexScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessYandexScimConfigJSON) RawJSON() string { + return r.raw +} + +type AccessIdentityProvidersAccessOnetimepin struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config interface{} `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type AccessIdentityProvidersAccessOnetimepinType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig AccessIdentityProvidersAccessOnetimepinScimConfig `json:"scim_config"` + JSON accessIdentityProvidersAccessOnetimepinJSON `json:"-"` +} + +// accessIdentityProvidersAccessOnetimepinJSON contains the JSON metadata for the +// struct [AccessIdentityProvidersAccessOnetimepin] +type accessIdentityProvidersAccessOnetimepinJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessOnetimepin) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessOnetimepinJSON) RawJSON() string { + return r.raw +} + +func (r AccessIdentityProvidersAccessOnetimepin) implementsZeroTrustAccessIdentityProviders() {} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type AccessIdentityProvidersAccessOnetimepinType string + +const ( + AccessIdentityProvidersAccessOnetimepinTypeOnetimepin AccessIdentityProvidersAccessOnetimepinType = "onetimepin" + AccessIdentityProvidersAccessOnetimepinTypeAzureAd AccessIdentityProvidersAccessOnetimepinType = "azureAD" + AccessIdentityProvidersAccessOnetimepinTypeSaml AccessIdentityProvidersAccessOnetimepinType = "saml" + AccessIdentityProvidersAccessOnetimepinTypeCentrify AccessIdentityProvidersAccessOnetimepinType = "centrify" + AccessIdentityProvidersAccessOnetimepinTypeFacebook AccessIdentityProvidersAccessOnetimepinType = "facebook" + AccessIdentityProvidersAccessOnetimepinTypeGitHub AccessIdentityProvidersAccessOnetimepinType = "github" + AccessIdentityProvidersAccessOnetimepinTypeGoogleApps AccessIdentityProvidersAccessOnetimepinType = "google-apps" + AccessIdentityProvidersAccessOnetimepinTypeGoogle AccessIdentityProvidersAccessOnetimepinType = "google" + AccessIdentityProvidersAccessOnetimepinTypeLinkedin AccessIdentityProvidersAccessOnetimepinType = "linkedin" + AccessIdentityProvidersAccessOnetimepinTypeOidc AccessIdentityProvidersAccessOnetimepinType = "oidc" + AccessIdentityProvidersAccessOnetimepinTypeOkta AccessIdentityProvidersAccessOnetimepinType = "okta" + AccessIdentityProvidersAccessOnetimepinTypeOnelogin AccessIdentityProvidersAccessOnetimepinType = "onelogin" + AccessIdentityProvidersAccessOnetimepinTypePingone AccessIdentityProvidersAccessOnetimepinType = "pingone" + AccessIdentityProvidersAccessOnetimepinTypeYandex AccessIdentityProvidersAccessOnetimepinType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type AccessIdentityProvidersAccessOnetimepinScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON accessIdentityProvidersAccessOnetimepinScimConfigJSON `json:"-"` +} + +// accessIdentityProvidersAccessOnetimepinScimConfigJSON contains the JSON metadata +// for the struct [AccessIdentityProvidersAccessOnetimepinScimConfig] +type accessIdentityProvidersAccessOnetimepinScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessIdentityProvidersAccessOnetimepinScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessIdentityProvidersAccessOnetimepinScimConfigJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [zero_trust.IdentityProviderListResponseAccessAzureAd], +// [zero_trust.IdentityProviderListResponseAccessCentrify], +// [zero_trust.IdentityProviderListResponseAccessFacebook], +// [zero_trust.IdentityProviderListResponseAccessGitHub], +// [zero_trust.IdentityProviderListResponseAccessGoogle], +// [zero_trust.IdentityProviderListResponseAccessGoogleApps], +// [zero_trust.IdentityProviderListResponseAccessLinkedin], +// [zero_trust.IdentityProviderListResponseAccessOidc], +// [zero_trust.IdentityProviderListResponseAccessOkta], +// [zero_trust.IdentityProviderListResponseAccessOnelogin], +// [zero_trust.IdentityProviderListResponseAccessPingone], +// [zero_trust.IdentityProviderListResponseAccessSaml] or +// [zero_trust.IdentityProviderListResponseAccessYandex]. +type IdentityProviderListResponse interface { + implementsZeroTrustIdentityProviderListResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*IdentityProviderListResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessAzureAd{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessCentrify{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessFacebook{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessGitHub{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessGoogle{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessGoogleApps{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessLinkedin{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessOidc{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessOkta{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessOnelogin{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessPingone{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessSaml{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(IdentityProviderListResponseAccessYandex{}), + }, + ) +} + +type IdentityProviderListResponseAccessAzureAd struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config IdentityProviderListResponseAccessAzureAdConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderListResponseAccessAzureAdType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig IdentityProviderListResponseAccessAzureAdScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessAzureAdJSON `json:"-"` +} + +// identityProviderListResponseAccessAzureAdJSON contains the JSON metadata for the +// struct [IdentityProviderListResponseAccessAzureAd] +type identityProviderListResponseAccessAzureAdJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessAzureAd) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessAzureAdJSON) RawJSON() string { + return r.raw +} + +func (r IdentityProviderListResponseAccessAzureAd) implementsZeroTrustIdentityProviderListResponse() { +} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessAzureAdConfig struct { + // Custom claims + Claims []string `json:"claims"` + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + // Should Cloudflare try to load authentication contexts from your account + ConditionalAccessEnabled bool `json:"conditional_access_enabled"` + // Your Azure directory uuid + DirectoryID string `json:"directory_id"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + // Should Cloudflare try to load groups from your account + SupportGroups bool `json:"support_groups"` + JSON identityProviderListResponseAccessAzureAdConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessAzureAdConfigJSON contains the JSON metadata +// for the struct [IdentityProviderListResponseAccessAzureAdConfig] +type identityProviderListResponseAccessAzureAdConfigJSON struct { + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + ConditionalAccessEnabled apijson.Field + DirectoryID apijson.Field + EmailClaimName apijson.Field + SupportGroups apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessAzureAdConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessAzureAdConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessAzureAdType string + +const ( + IdentityProviderListResponseAccessAzureAdTypeOnetimepin IdentityProviderListResponseAccessAzureAdType = "onetimepin" + IdentityProviderListResponseAccessAzureAdTypeAzureAd IdentityProviderListResponseAccessAzureAdType = "azureAD" + IdentityProviderListResponseAccessAzureAdTypeSaml IdentityProviderListResponseAccessAzureAdType = "saml" + IdentityProviderListResponseAccessAzureAdTypeCentrify IdentityProviderListResponseAccessAzureAdType = "centrify" + IdentityProviderListResponseAccessAzureAdTypeFacebook IdentityProviderListResponseAccessAzureAdType = "facebook" + IdentityProviderListResponseAccessAzureAdTypeGitHub IdentityProviderListResponseAccessAzureAdType = "github" + IdentityProviderListResponseAccessAzureAdTypeGoogleApps IdentityProviderListResponseAccessAzureAdType = "google-apps" + IdentityProviderListResponseAccessAzureAdTypeGoogle IdentityProviderListResponseAccessAzureAdType = "google" + IdentityProviderListResponseAccessAzureAdTypeLinkedin IdentityProviderListResponseAccessAzureAdType = "linkedin" + IdentityProviderListResponseAccessAzureAdTypeOidc IdentityProviderListResponseAccessAzureAdType = "oidc" + IdentityProviderListResponseAccessAzureAdTypeOkta IdentityProviderListResponseAccessAzureAdType = "okta" + IdentityProviderListResponseAccessAzureAdTypeOnelogin IdentityProviderListResponseAccessAzureAdType = "onelogin" + IdentityProviderListResponseAccessAzureAdTypePingone IdentityProviderListResponseAccessAzureAdType = "pingone" + IdentityProviderListResponseAccessAzureAdTypeYandex IdentityProviderListResponseAccessAzureAdType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type IdentityProviderListResponseAccessAzureAdScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON identityProviderListResponseAccessAzureAdScimConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessAzureAdScimConfigJSON contains the JSON +// metadata for the struct [IdentityProviderListResponseAccessAzureAdScimConfig] +type identityProviderListResponseAccessAzureAdScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessAzureAdScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessAzureAdScimConfigJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderListResponseAccessCentrify struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config IdentityProviderListResponseAccessCentrifyConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderListResponseAccessCentrifyType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig IdentityProviderListResponseAccessCentrifyScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessCentrifyJSON `json:"-"` +} + +// identityProviderListResponseAccessCentrifyJSON contains the JSON metadata for +// the struct [IdentityProviderListResponseAccessCentrify] +type identityProviderListResponseAccessCentrifyJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessCentrify) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessCentrifyJSON) RawJSON() string { + return r.raw +} + +func (r IdentityProviderListResponseAccessCentrify) implementsZeroTrustIdentityProviderListResponse() { +} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessCentrifyConfig struct { + // Your centrify account url + CentrifyAccount string `json:"centrify_account"` + // Your centrify app id + CentrifyAppID string `json:"centrify_app_id"` + // Custom claims + Claims []string `json:"claims"` + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + JSON identityProviderListResponseAccessCentrifyConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessCentrifyConfigJSON contains the JSON metadata +// for the struct [IdentityProviderListResponseAccessCentrifyConfig] +type identityProviderListResponseAccessCentrifyConfigJSON struct { + CentrifyAccount apijson.Field + CentrifyAppID apijson.Field + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessCentrifyConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessCentrifyConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessCentrifyType string + +const ( + IdentityProviderListResponseAccessCentrifyTypeOnetimepin IdentityProviderListResponseAccessCentrifyType = "onetimepin" + IdentityProviderListResponseAccessCentrifyTypeAzureAd IdentityProviderListResponseAccessCentrifyType = "azureAD" + IdentityProviderListResponseAccessCentrifyTypeSaml IdentityProviderListResponseAccessCentrifyType = "saml" + IdentityProviderListResponseAccessCentrifyTypeCentrify IdentityProviderListResponseAccessCentrifyType = "centrify" + IdentityProviderListResponseAccessCentrifyTypeFacebook IdentityProviderListResponseAccessCentrifyType = "facebook" + IdentityProviderListResponseAccessCentrifyTypeGitHub IdentityProviderListResponseAccessCentrifyType = "github" + IdentityProviderListResponseAccessCentrifyTypeGoogleApps IdentityProviderListResponseAccessCentrifyType = "google-apps" + IdentityProviderListResponseAccessCentrifyTypeGoogle IdentityProviderListResponseAccessCentrifyType = "google" + IdentityProviderListResponseAccessCentrifyTypeLinkedin IdentityProviderListResponseAccessCentrifyType = "linkedin" + IdentityProviderListResponseAccessCentrifyTypeOidc IdentityProviderListResponseAccessCentrifyType = "oidc" + IdentityProviderListResponseAccessCentrifyTypeOkta IdentityProviderListResponseAccessCentrifyType = "okta" + IdentityProviderListResponseAccessCentrifyTypeOnelogin IdentityProviderListResponseAccessCentrifyType = "onelogin" + IdentityProviderListResponseAccessCentrifyTypePingone IdentityProviderListResponseAccessCentrifyType = "pingone" + IdentityProviderListResponseAccessCentrifyTypeYandex IdentityProviderListResponseAccessCentrifyType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type IdentityProviderListResponseAccessCentrifyScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON identityProviderListResponseAccessCentrifyScimConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessCentrifyScimConfigJSON contains the JSON +// metadata for the struct [IdentityProviderListResponseAccessCentrifyScimConfig] +type identityProviderListResponseAccessCentrifyScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessCentrifyScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessCentrifyScimConfigJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderListResponseAccessFacebook struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config IdentityProviderListResponseAccessFacebookConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderListResponseAccessFacebookType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig IdentityProviderListResponseAccessFacebookScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessFacebookJSON `json:"-"` +} + +// identityProviderListResponseAccessFacebookJSON contains the JSON metadata for +// the struct [IdentityProviderListResponseAccessFacebook] +type identityProviderListResponseAccessFacebookJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessFacebook) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessFacebookJSON) RawJSON() string { + return r.raw +} + +func (r IdentityProviderListResponseAccessFacebook) implementsZeroTrustIdentityProviderListResponse() { +} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessFacebookConfig struct { + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + JSON identityProviderListResponseAccessFacebookConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessFacebookConfigJSON contains the JSON metadata +// for the struct [IdentityProviderListResponseAccessFacebookConfig] +type identityProviderListResponseAccessFacebookConfigJSON struct { + ClientID apijson.Field + ClientSecret apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessFacebookConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessFacebookConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessFacebookType string + +const ( + IdentityProviderListResponseAccessFacebookTypeOnetimepin IdentityProviderListResponseAccessFacebookType = "onetimepin" + IdentityProviderListResponseAccessFacebookTypeAzureAd IdentityProviderListResponseAccessFacebookType = "azureAD" + IdentityProviderListResponseAccessFacebookTypeSaml IdentityProviderListResponseAccessFacebookType = "saml" + IdentityProviderListResponseAccessFacebookTypeCentrify IdentityProviderListResponseAccessFacebookType = "centrify" + IdentityProviderListResponseAccessFacebookTypeFacebook IdentityProviderListResponseAccessFacebookType = "facebook" + IdentityProviderListResponseAccessFacebookTypeGitHub IdentityProviderListResponseAccessFacebookType = "github" + IdentityProviderListResponseAccessFacebookTypeGoogleApps IdentityProviderListResponseAccessFacebookType = "google-apps" + IdentityProviderListResponseAccessFacebookTypeGoogle IdentityProviderListResponseAccessFacebookType = "google" + IdentityProviderListResponseAccessFacebookTypeLinkedin IdentityProviderListResponseAccessFacebookType = "linkedin" + IdentityProviderListResponseAccessFacebookTypeOidc IdentityProviderListResponseAccessFacebookType = "oidc" + IdentityProviderListResponseAccessFacebookTypeOkta IdentityProviderListResponseAccessFacebookType = "okta" + IdentityProviderListResponseAccessFacebookTypeOnelogin IdentityProviderListResponseAccessFacebookType = "onelogin" + IdentityProviderListResponseAccessFacebookTypePingone IdentityProviderListResponseAccessFacebookType = "pingone" + IdentityProviderListResponseAccessFacebookTypeYandex IdentityProviderListResponseAccessFacebookType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type IdentityProviderListResponseAccessFacebookScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON identityProviderListResponseAccessFacebookScimConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessFacebookScimConfigJSON contains the JSON +// metadata for the struct [IdentityProviderListResponseAccessFacebookScimConfig] +type identityProviderListResponseAccessFacebookScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessFacebookScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessFacebookScimConfigJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderListResponseAccessGitHub struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config IdentityProviderListResponseAccessGitHubConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderListResponseAccessGitHubType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig IdentityProviderListResponseAccessGitHubScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessGitHubJSON `json:"-"` +} + +// identityProviderListResponseAccessGitHubJSON contains the JSON metadata for the +// struct [IdentityProviderListResponseAccessGitHub] +type identityProviderListResponseAccessGitHubJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessGitHub) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessGitHubJSON) RawJSON() string { + return r.raw +} + +func (r IdentityProviderListResponseAccessGitHub) implementsZeroTrustIdentityProviderListResponse() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessGitHubConfig struct { + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + JSON identityProviderListResponseAccessGitHubConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessGitHubConfigJSON contains the JSON metadata +// for the struct [IdentityProviderListResponseAccessGitHubConfig] +type identityProviderListResponseAccessGitHubConfigJSON struct { + ClientID apijson.Field + ClientSecret apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessGitHubConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessGitHubConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessGitHubType string + +const ( + IdentityProviderListResponseAccessGitHubTypeOnetimepin IdentityProviderListResponseAccessGitHubType = "onetimepin" + IdentityProviderListResponseAccessGitHubTypeAzureAd IdentityProviderListResponseAccessGitHubType = "azureAD" + IdentityProviderListResponseAccessGitHubTypeSaml IdentityProviderListResponseAccessGitHubType = "saml" + IdentityProviderListResponseAccessGitHubTypeCentrify IdentityProviderListResponseAccessGitHubType = "centrify" + IdentityProviderListResponseAccessGitHubTypeFacebook IdentityProviderListResponseAccessGitHubType = "facebook" + IdentityProviderListResponseAccessGitHubTypeGitHub IdentityProviderListResponseAccessGitHubType = "github" + IdentityProviderListResponseAccessGitHubTypeGoogleApps IdentityProviderListResponseAccessGitHubType = "google-apps" + IdentityProviderListResponseAccessGitHubTypeGoogle IdentityProviderListResponseAccessGitHubType = "google" + IdentityProviderListResponseAccessGitHubTypeLinkedin IdentityProviderListResponseAccessGitHubType = "linkedin" + IdentityProviderListResponseAccessGitHubTypeOidc IdentityProviderListResponseAccessGitHubType = "oidc" + IdentityProviderListResponseAccessGitHubTypeOkta IdentityProviderListResponseAccessGitHubType = "okta" + IdentityProviderListResponseAccessGitHubTypeOnelogin IdentityProviderListResponseAccessGitHubType = "onelogin" + IdentityProviderListResponseAccessGitHubTypePingone IdentityProviderListResponseAccessGitHubType = "pingone" + IdentityProviderListResponseAccessGitHubTypeYandex IdentityProviderListResponseAccessGitHubType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type IdentityProviderListResponseAccessGitHubScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON identityProviderListResponseAccessGitHubScimConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessGitHubScimConfigJSON contains the JSON +// metadata for the struct [IdentityProviderListResponseAccessGitHubScimConfig] +type identityProviderListResponseAccessGitHubScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessGitHubScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessGitHubScimConfigJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderListResponseAccessGoogle struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config IdentityProviderListResponseAccessGoogleConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderListResponseAccessGoogleType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig IdentityProviderListResponseAccessGoogleScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessGoogleJSON `json:"-"` +} + +// identityProviderListResponseAccessGoogleJSON contains the JSON metadata for the +// struct [IdentityProviderListResponseAccessGoogle] +type identityProviderListResponseAccessGoogleJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessGoogle) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessGoogleJSON) RawJSON() string { + return r.raw +} + +func (r IdentityProviderListResponseAccessGoogle) implementsZeroTrustIdentityProviderListResponse() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessGoogleConfig struct { + // Custom claims + Claims []string `json:"claims"` + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + JSON identityProviderListResponseAccessGoogleConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessGoogleConfigJSON contains the JSON metadata +// for the struct [IdentityProviderListResponseAccessGoogleConfig] +type identityProviderListResponseAccessGoogleConfigJSON struct { + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessGoogleConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessGoogleConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessGoogleType string + +const ( + IdentityProviderListResponseAccessGoogleTypeOnetimepin IdentityProviderListResponseAccessGoogleType = "onetimepin" + IdentityProviderListResponseAccessGoogleTypeAzureAd IdentityProviderListResponseAccessGoogleType = "azureAD" + IdentityProviderListResponseAccessGoogleTypeSaml IdentityProviderListResponseAccessGoogleType = "saml" + IdentityProviderListResponseAccessGoogleTypeCentrify IdentityProviderListResponseAccessGoogleType = "centrify" + IdentityProviderListResponseAccessGoogleTypeFacebook IdentityProviderListResponseAccessGoogleType = "facebook" + IdentityProviderListResponseAccessGoogleTypeGitHub IdentityProviderListResponseAccessGoogleType = "github" + IdentityProviderListResponseAccessGoogleTypeGoogleApps IdentityProviderListResponseAccessGoogleType = "google-apps" + IdentityProviderListResponseAccessGoogleTypeGoogle IdentityProviderListResponseAccessGoogleType = "google" + IdentityProviderListResponseAccessGoogleTypeLinkedin IdentityProviderListResponseAccessGoogleType = "linkedin" + IdentityProviderListResponseAccessGoogleTypeOidc IdentityProviderListResponseAccessGoogleType = "oidc" + IdentityProviderListResponseAccessGoogleTypeOkta IdentityProviderListResponseAccessGoogleType = "okta" + IdentityProviderListResponseAccessGoogleTypeOnelogin IdentityProviderListResponseAccessGoogleType = "onelogin" + IdentityProviderListResponseAccessGoogleTypePingone IdentityProviderListResponseAccessGoogleType = "pingone" + IdentityProviderListResponseAccessGoogleTypeYandex IdentityProviderListResponseAccessGoogleType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type IdentityProviderListResponseAccessGoogleScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON identityProviderListResponseAccessGoogleScimConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessGoogleScimConfigJSON contains the JSON +// metadata for the struct [IdentityProviderListResponseAccessGoogleScimConfig] +type identityProviderListResponseAccessGoogleScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessGoogleScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessGoogleScimConfigJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderListResponseAccessGoogleApps struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config IdentityProviderListResponseAccessGoogleAppsConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderListResponseAccessGoogleAppsType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig IdentityProviderListResponseAccessGoogleAppsScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessGoogleAppsJSON `json:"-"` +} + +// identityProviderListResponseAccessGoogleAppsJSON contains the JSON metadata for +// the struct [IdentityProviderListResponseAccessGoogleApps] +type identityProviderListResponseAccessGoogleAppsJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessGoogleApps) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessGoogleAppsJSON) RawJSON() string { + return r.raw +} + +func (r IdentityProviderListResponseAccessGoogleApps) implementsZeroTrustIdentityProviderListResponse() { +} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessGoogleAppsConfig struct { + // Your companies TLD + AppsDomain string `json:"apps_domain"` + // Custom claims + Claims []string `json:"claims"` + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + JSON identityProviderListResponseAccessGoogleAppsConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessGoogleAppsConfigJSON contains the JSON +// metadata for the struct [IdentityProviderListResponseAccessGoogleAppsConfig] +type identityProviderListResponseAccessGoogleAppsConfigJSON struct { + AppsDomain apijson.Field + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessGoogleAppsConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessGoogleAppsConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessGoogleAppsType string + +const ( + IdentityProviderListResponseAccessGoogleAppsTypeOnetimepin IdentityProviderListResponseAccessGoogleAppsType = "onetimepin" + IdentityProviderListResponseAccessGoogleAppsTypeAzureAd IdentityProviderListResponseAccessGoogleAppsType = "azureAD" + IdentityProviderListResponseAccessGoogleAppsTypeSaml IdentityProviderListResponseAccessGoogleAppsType = "saml" + IdentityProviderListResponseAccessGoogleAppsTypeCentrify IdentityProviderListResponseAccessGoogleAppsType = "centrify" + IdentityProviderListResponseAccessGoogleAppsTypeFacebook IdentityProviderListResponseAccessGoogleAppsType = "facebook" + IdentityProviderListResponseAccessGoogleAppsTypeGitHub IdentityProviderListResponseAccessGoogleAppsType = "github" + IdentityProviderListResponseAccessGoogleAppsTypeGoogleApps IdentityProviderListResponseAccessGoogleAppsType = "google-apps" + IdentityProviderListResponseAccessGoogleAppsTypeGoogle IdentityProviderListResponseAccessGoogleAppsType = "google" + IdentityProviderListResponseAccessGoogleAppsTypeLinkedin IdentityProviderListResponseAccessGoogleAppsType = "linkedin" + IdentityProviderListResponseAccessGoogleAppsTypeOidc IdentityProviderListResponseAccessGoogleAppsType = "oidc" + IdentityProviderListResponseAccessGoogleAppsTypeOkta IdentityProviderListResponseAccessGoogleAppsType = "okta" + IdentityProviderListResponseAccessGoogleAppsTypeOnelogin IdentityProviderListResponseAccessGoogleAppsType = "onelogin" + IdentityProviderListResponseAccessGoogleAppsTypePingone IdentityProviderListResponseAccessGoogleAppsType = "pingone" + IdentityProviderListResponseAccessGoogleAppsTypeYandex IdentityProviderListResponseAccessGoogleAppsType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type IdentityProviderListResponseAccessGoogleAppsScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON identityProviderListResponseAccessGoogleAppsScimConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessGoogleAppsScimConfigJSON contains the JSON +// metadata for the struct [IdentityProviderListResponseAccessGoogleAppsScimConfig] +type identityProviderListResponseAccessGoogleAppsScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessGoogleAppsScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessGoogleAppsScimConfigJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderListResponseAccessLinkedin struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config IdentityProviderListResponseAccessLinkedinConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderListResponseAccessLinkedinType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig IdentityProviderListResponseAccessLinkedinScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessLinkedinJSON `json:"-"` +} + +// identityProviderListResponseAccessLinkedinJSON contains the JSON metadata for +// the struct [IdentityProviderListResponseAccessLinkedin] +type identityProviderListResponseAccessLinkedinJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessLinkedin) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessLinkedinJSON) RawJSON() string { + return r.raw +} + +func (r IdentityProviderListResponseAccessLinkedin) implementsZeroTrustIdentityProviderListResponse() { +} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessLinkedinConfig struct { + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + JSON identityProviderListResponseAccessLinkedinConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessLinkedinConfigJSON contains the JSON metadata +// for the struct [IdentityProviderListResponseAccessLinkedinConfig] +type identityProviderListResponseAccessLinkedinConfigJSON struct { + ClientID apijson.Field + ClientSecret apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessLinkedinConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessLinkedinConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessLinkedinType string + +const ( + IdentityProviderListResponseAccessLinkedinTypeOnetimepin IdentityProviderListResponseAccessLinkedinType = "onetimepin" + IdentityProviderListResponseAccessLinkedinTypeAzureAd IdentityProviderListResponseAccessLinkedinType = "azureAD" + IdentityProviderListResponseAccessLinkedinTypeSaml IdentityProviderListResponseAccessLinkedinType = "saml" + IdentityProviderListResponseAccessLinkedinTypeCentrify IdentityProviderListResponseAccessLinkedinType = "centrify" + IdentityProviderListResponseAccessLinkedinTypeFacebook IdentityProviderListResponseAccessLinkedinType = "facebook" + IdentityProviderListResponseAccessLinkedinTypeGitHub IdentityProviderListResponseAccessLinkedinType = "github" + IdentityProviderListResponseAccessLinkedinTypeGoogleApps IdentityProviderListResponseAccessLinkedinType = "google-apps" + IdentityProviderListResponseAccessLinkedinTypeGoogle IdentityProviderListResponseAccessLinkedinType = "google" + IdentityProviderListResponseAccessLinkedinTypeLinkedin IdentityProviderListResponseAccessLinkedinType = "linkedin" + IdentityProviderListResponseAccessLinkedinTypeOidc IdentityProviderListResponseAccessLinkedinType = "oidc" + IdentityProviderListResponseAccessLinkedinTypeOkta IdentityProviderListResponseAccessLinkedinType = "okta" + IdentityProviderListResponseAccessLinkedinTypeOnelogin IdentityProviderListResponseAccessLinkedinType = "onelogin" + IdentityProviderListResponseAccessLinkedinTypePingone IdentityProviderListResponseAccessLinkedinType = "pingone" + IdentityProviderListResponseAccessLinkedinTypeYandex IdentityProviderListResponseAccessLinkedinType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type IdentityProviderListResponseAccessLinkedinScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON identityProviderListResponseAccessLinkedinScimConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessLinkedinScimConfigJSON contains the JSON +// metadata for the struct [IdentityProviderListResponseAccessLinkedinScimConfig] +type identityProviderListResponseAccessLinkedinScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessLinkedinScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessLinkedinScimConfigJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderListResponseAccessOidc struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config IdentityProviderListResponseAccessOidcConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderListResponseAccessOidcType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig IdentityProviderListResponseAccessOidcScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessOidcJSON `json:"-"` +} + +// identityProviderListResponseAccessOidcJSON contains the JSON metadata for the +// struct [IdentityProviderListResponseAccessOidc] +type identityProviderListResponseAccessOidcJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessOidc) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessOidcJSON) RawJSON() string { + return r.raw +} + +func (r IdentityProviderListResponseAccessOidc) implementsZeroTrustIdentityProviderListResponse() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessOidcConfig struct { + // The authorization_endpoint URL of your IdP + AuthURL string `json:"auth_url"` + // The jwks_uri endpoint of your IdP to allow the IdP keys to sign the tokens + CertsURL string `json:"certs_url"` + // Custom claims + Claims []string `json:"claims"` + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + // OAuth scopes + Scopes []string `json:"scopes"` + // The token_endpoint URL of your IdP + TokenURL string `json:"token_url"` + JSON identityProviderListResponseAccessOidcConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessOidcConfigJSON contains the JSON metadata for +// the struct [IdentityProviderListResponseAccessOidcConfig] +type identityProviderListResponseAccessOidcConfigJSON struct { + AuthURL apijson.Field + CertsURL apijson.Field + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + Scopes apijson.Field + TokenURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessOidcConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessOidcConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessOidcType string + +const ( + IdentityProviderListResponseAccessOidcTypeOnetimepin IdentityProviderListResponseAccessOidcType = "onetimepin" + IdentityProviderListResponseAccessOidcTypeAzureAd IdentityProviderListResponseAccessOidcType = "azureAD" + IdentityProviderListResponseAccessOidcTypeSaml IdentityProviderListResponseAccessOidcType = "saml" + IdentityProviderListResponseAccessOidcTypeCentrify IdentityProviderListResponseAccessOidcType = "centrify" + IdentityProviderListResponseAccessOidcTypeFacebook IdentityProviderListResponseAccessOidcType = "facebook" + IdentityProviderListResponseAccessOidcTypeGitHub IdentityProviderListResponseAccessOidcType = "github" + IdentityProviderListResponseAccessOidcTypeGoogleApps IdentityProviderListResponseAccessOidcType = "google-apps" + IdentityProviderListResponseAccessOidcTypeGoogle IdentityProviderListResponseAccessOidcType = "google" + IdentityProviderListResponseAccessOidcTypeLinkedin IdentityProviderListResponseAccessOidcType = "linkedin" + IdentityProviderListResponseAccessOidcTypeOidc IdentityProviderListResponseAccessOidcType = "oidc" + IdentityProviderListResponseAccessOidcTypeOkta IdentityProviderListResponseAccessOidcType = "okta" + IdentityProviderListResponseAccessOidcTypeOnelogin IdentityProviderListResponseAccessOidcType = "onelogin" + IdentityProviderListResponseAccessOidcTypePingone IdentityProviderListResponseAccessOidcType = "pingone" + IdentityProviderListResponseAccessOidcTypeYandex IdentityProviderListResponseAccessOidcType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type IdentityProviderListResponseAccessOidcScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON identityProviderListResponseAccessOidcScimConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessOidcScimConfigJSON contains the JSON metadata +// for the struct [IdentityProviderListResponseAccessOidcScimConfig] +type identityProviderListResponseAccessOidcScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessOidcScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessOidcScimConfigJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderListResponseAccessOkta struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config IdentityProviderListResponseAccessOktaConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderListResponseAccessOktaType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig IdentityProviderListResponseAccessOktaScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessOktaJSON `json:"-"` +} + +// identityProviderListResponseAccessOktaJSON contains the JSON metadata for the +// struct [IdentityProviderListResponseAccessOkta] +type identityProviderListResponseAccessOktaJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessOkta) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessOktaJSON) RawJSON() string { + return r.raw +} + +func (r IdentityProviderListResponseAccessOkta) implementsZeroTrustIdentityProviderListResponse() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessOktaConfig struct { + // Your okta authorization server id + AuthorizationServerID string `json:"authorization_server_id"` + // Custom claims + Claims []string `json:"claims"` + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + // Your okta account url + OktaAccount string `json:"okta_account"` + JSON identityProviderListResponseAccessOktaConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessOktaConfigJSON contains the JSON metadata for +// the struct [IdentityProviderListResponseAccessOktaConfig] +type identityProviderListResponseAccessOktaConfigJSON struct { + AuthorizationServerID apijson.Field + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + OktaAccount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessOktaConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessOktaConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessOktaType string + +const ( + IdentityProviderListResponseAccessOktaTypeOnetimepin IdentityProviderListResponseAccessOktaType = "onetimepin" + IdentityProviderListResponseAccessOktaTypeAzureAd IdentityProviderListResponseAccessOktaType = "azureAD" + IdentityProviderListResponseAccessOktaTypeSaml IdentityProviderListResponseAccessOktaType = "saml" + IdentityProviderListResponseAccessOktaTypeCentrify IdentityProviderListResponseAccessOktaType = "centrify" + IdentityProviderListResponseAccessOktaTypeFacebook IdentityProviderListResponseAccessOktaType = "facebook" + IdentityProviderListResponseAccessOktaTypeGitHub IdentityProviderListResponseAccessOktaType = "github" + IdentityProviderListResponseAccessOktaTypeGoogleApps IdentityProviderListResponseAccessOktaType = "google-apps" + IdentityProviderListResponseAccessOktaTypeGoogle IdentityProviderListResponseAccessOktaType = "google" + IdentityProviderListResponseAccessOktaTypeLinkedin IdentityProviderListResponseAccessOktaType = "linkedin" + IdentityProviderListResponseAccessOktaTypeOidc IdentityProviderListResponseAccessOktaType = "oidc" + IdentityProviderListResponseAccessOktaTypeOkta IdentityProviderListResponseAccessOktaType = "okta" + IdentityProviderListResponseAccessOktaTypeOnelogin IdentityProviderListResponseAccessOktaType = "onelogin" + IdentityProviderListResponseAccessOktaTypePingone IdentityProviderListResponseAccessOktaType = "pingone" + IdentityProviderListResponseAccessOktaTypeYandex IdentityProviderListResponseAccessOktaType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type IdentityProviderListResponseAccessOktaScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON identityProviderListResponseAccessOktaScimConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessOktaScimConfigJSON contains the JSON metadata +// for the struct [IdentityProviderListResponseAccessOktaScimConfig] +type identityProviderListResponseAccessOktaScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessOktaScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessOktaScimConfigJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderListResponseAccessOnelogin struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config IdentityProviderListResponseAccessOneloginConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderListResponseAccessOneloginType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig IdentityProviderListResponseAccessOneloginScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessOneloginJSON `json:"-"` +} + +// identityProviderListResponseAccessOneloginJSON contains the JSON metadata for +// the struct [IdentityProviderListResponseAccessOnelogin] +type identityProviderListResponseAccessOneloginJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessOnelogin) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessOneloginJSON) RawJSON() string { + return r.raw +} + +func (r IdentityProviderListResponseAccessOnelogin) implementsZeroTrustIdentityProviderListResponse() { +} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessOneloginConfig struct { + // Custom claims + Claims []string `json:"claims"` + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + // Your OneLogin account url + OneloginAccount string `json:"onelogin_account"` + JSON identityProviderListResponseAccessOneloginConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessOneloginConfigJSON contains the JSON metadata +// for the struct [IdentityProviderListResponseAccessOneloginConfig] +type identityProviderListResponseAccessOneloginConfigJSON struct { + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + OneloginAccount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessOneloginConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessOneloginConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessOneloginType string + +const ( + IdentityProviderListResponseAccessOneloginTypeOnetimepin IdentityProviderListResponseAccessOneloginType = "onetimepin" + IdentityProviderListResponseAccessOneloginTypeAzureAd IdentityProviderListResponseAccessOneloginType = "azureAD" + IdentityProviderListResponseAccessOneloginTypeSaml IdentityProviderListResponseAccessOneloginType = "saml" + IdentityProviderListResponseAccessOneloginTypeCentrify IdentityProviderListResponseAccessOneloginType = "centrify" + IdentityProviderListResponseAccessOneloginTypeFacebook IdentityProviderListResponseAccessOneloginType = "facebook" + IdentityProviderListResponseAccessOneloginTypeGitHub IdentityProviderListResponseAccessOneloginType = "github" + IdentityProviderListResponseAccessOneloginTypeGoogleApps IdentityProviderListResponseAccessOneloginType = "google-apps" + IdentityProviderListResponseAccessOneloginTypeGoogle IdentityProviderListResponseAccessOneloginType = "google" + IdentityProviderListResponseAccessOneloginTypeLinkedin IdentityProviderListResponseAccessOneloginType = "linkedin" + IdentityProviderListResponseAccessOneloginTypeOidc IdentityProviderListResponseAccessOneloginType = "oidc" + IdentityProviderListResponseAccessOneloginTypeOkta IdentityProviderListResponseAccessOneloginType = "okta" + IdentityProviderListResponseAccessOneloginTypeOnelogin IdentityProviderListResponseAccessOneloginType = "onelogin" + IdentityProviderListResponseAccessOneloginTypePingone IdentityProviderListResponseAccessOneloginType = "pingone" + IdentityProviderListResponseAccessOneloginTypeYandex IdentityProviderListResponseAccessOneloginType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type IdentityProviderListResponseAccessOneloginScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON identityProviderListResponseAccessOneloginScimConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessOneloginScimConfigJSON contains the JSON +// metadata for the struct [IdentityProviderListResponseAccessOneloginScimConfig] +type identityProviderListResponseAccessOneloginScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessOneloginScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessOneloginScimConfigJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderListResponseAccessPingone struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config IdentityProviderListResponseAccessPingoneConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderListResponseAccessPingoneType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig IdentityProviderListResponseAccessPingoneScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessPingoneJSON `json:"-"` +} + +// identityProviderListResponseAccessPingoneJSON contains the JSON metadata for the +// struct [IdentityProviderListResponseAccessPingone] +type identityProviderListResponseAccessPingoneJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessPingone) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessPingoneJSON) RawJSON() string { + return r.raw +} + +func (r IdentityProviderListResponseAccessPingone) implementsZeroTrustIdentityProviderListResponse() { +} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessPingoneConfig struct { + // Custom claims + Claims []string `json:"claims"` + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + // The claim name for email in the id_token response. + EmailClaimName string `json:"email_claim_name"` + // Your PingOne environment identifier + PingEnvID string `json:"ping_env_id"` + JSON identityProviderListResponseAccessPingoneConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessPingoneConfigJSON contains the JSON metadata +// for the struct [IdentityProviderListResponseAccessPingoneConfig] +type identityProviderListResponseAccessPingoneConfigJSON struct { + Claims apijson.Field + ClientID apijson.Field + ClientSecret apijson.Field + EmailClaimName apijson.Field + PingEnvID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessPingoneConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessPingoneConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessPingoneType string + +const ( + IdentityProviderListResponseAccessPingoneTypeOnetimepin IdentityProviderListResponseAccessPingoneType = "onetimepin" + IdentityProviderListResponseAccessPingoneTypeAzureAd IdentityProviderListResponseAccessPingoneType = "azureAD" + IdentityProviderListResponseAccessPingoneTypeSaml IdentityProviderListResponseAccessPingoneType = "saml" + IdentityProviderListResponseAccessPingoneTypeCentrify IdentityProviderListResponseAccessPingoneType = "centrify" + IdentityProviderListResponseAccessPingoneTypeFacebook IdentityProviderListResponseAccessPingoneType = "facebook" + IdentityProviderListResponseAccessPingoneTypeGitHub IdentityProviderListResponseAccessPingoneType = "github" + IdentityProviderListResponseAccessPingoneTypeGoogleApps IdentityProviderListResponseAccessPingoneType = "google-apps" + IdentityProviderListResponseAccessPingoneTypeGoogle IdentityProviderListResponseAccessPingoneType = "google" + IdentityProviderListResponseAccessPingoneTypeLinkedin IdentityProviderListResponseAccessPingoneType = "linkedin" + IdentityProviderListResponseAccessPingoneTypeOidc IdentityProviderListResponseAccessPingoneType = "oidc" + IdentityProviderListResponseAccessPingoneTypeOkta IdentityProviderListResponseAccessPingoneType = "okta" + IdentityProviderListResponseAccessPingoneTypeOnelogin IdentityProviderListResponseAccessPingoneType = "onelogin" + IdentityProviderListResponseAccessPingoneTypePingone IdentityProviderListResponseAccessPingoneType = "pingone" + IdentityProviderListResponseAccessPingoneTypeYandex IdentityProviderListResponseAccessPingoneType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type IdentityProviderListResponseAccessPingoneScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON identityProviderListResponseAccessPingoneScimConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessPingoneScimConfigJSON contains the JSON +// metadata for the struct [IdentityProviderListResponseAccessPingoneScimConfig] +type identityProviderListResponseAccessPingoneScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessPingoneScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessPingoneScimConfigJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderListResponseAccessSaml struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config IdentityProviderListResponseAccessSamlConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderListResponseAccessSamlType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig IdentityProviderListResponseAccessSamlScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessSamlJSON `json:"-"` +} + +// identityProviderListResponseAccessSamlJSON contains the JSON metadata for the +// struct [IdentityProviderListResponseAccessSaml] +type identityProviderListResponseAccessSamlJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessSaml) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessSamlJSON) RawJSON() string { + return r.raw +} + +func (r IdentityProviderListResponseAccessSaml) implementsZeroTrustIdentityProviderListResponse() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessSamlConfig struct { + // A list of SAML attribute names that will be added to your signed JWT token and + // can be used in SAML policy rules. + Attributes []string `json:"attributes"` + // The attribute name for email in the SAML response. + EmailAttributeName string `json:"email_attribute_name"` + // Add a list of attribute names that will be returned in the response header from + // the Access callback. + HeaderAttributes []IdentityProviderListResponseAccessSamlConfigHeaderAttribute `json:"header_attributes"` + // X509 certificate to verify the signature in the SAML authentication response + IdpPublicCerts []string `json:"idp_public_certs"` + // IdP Entity ID or Issuer URL + IssuerURL string `json:"issuer_url"` + // Sign the SAML authentication request with Access credentials. To verify the + // signature, use the public key from the Access certs endpoints. + SignRequest bool `json:"sign_request"` + // URL to send the SAML authentication requests to + SSOTargetURL string `json:"sso_target_url"` + JSON identityProviderListResponseAccessSamlConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessSamlConfigJSON contains the JSON metadata for +// the struct [IdentityProviderListResponseAccessSamlConfig] +type identityProviderListResponseAccessSamlConfigJSON struct { + Attributes apijson.Field + EmailAttributeName apijson.Field + HeaderAttributes apijson.Field + IdpPublicCerts apijson.Field + IssuerURL apijson.Field + SignRequest apijson.Field + SSOTargetURL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessSamlConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessSamlConfigJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderListResponseAccessSamlConfigHeaderAttribute struct { + // attribute name from the IDP + AttributeName string `json:"attribute_name"` + // header that will be added on the request to the origin + HeaderName string `json:"header_name"` + JSON identityProviderListResponseAccessSamlConfigHeaderAttributeJSON `json:"-"` +} + +// identityProviderListResponseAccessSamlConfigHeaderAttributeJSON contains the +// JSON metadata for the struct +// [IdentityProviderListResponseAccessSamlConfigHeaderAttribute] +type identityProviderListResponseAccessSamlConfigHeaderAttributeJSON struct { + AttributeName apijson.Field + HeaderName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessSamlConfigHeaderAttribute) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessSamlConfigHeaderAttributeJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessSamlType string + +const ( + IdentityProviderListResponseAccessSamlTypeOnetimepin IdentityProviderListResponseAccessSamlType = "onetimepin" + IdentityProviderListResponseAccessSamlTypeAzureAd IdentityProviderListResponseAccessSamlType = "azureAD" + IdentityProviderListResponseAccessSamlTypeSaml IdentityProviderListResponseAccessSamlType = "saml" + IdentityProviderListResponseAccessSamlTypeCentrify IdentityProviderListResponseAccessSamlType = "centrify" + IdentityProviderListResponseAccessSamlTypeFacebook IdentityProviderListResponseAccessSamlType = "facebook" + IdentityProviderListResponseAccessSamlTypeGitHub IdentityProviderListResponseAccessSamlType = "github" + IdentityProviderListResponseAccessSamlTypeGoogleApps IdentityProviderListResponseAccessSamlType = "google-apps" + IdentityProviderListResponseAccessSamlTypeGoogle IdentityProviderListResponseAccessSamlType = "google" + IdentityProviderListResponseAccessSamlTypeLinkedin IdentityProviderListResponseAccessSamlType = "linkedin" + IdentityProviderListResponseAccessSamlTypeOidc IdentityProviderListResponseAccessSamlType = "oidc" + IdentityProviderListResponseAccessSamlTypeOkta IdentityProviderListResponseAccessSamlType = "okta" + IdentityProviderListResponseAccessSamlTypeOnelogin IdentityProviderListResponseAccessSamlType = "onelogin" + IdentityProviderListResponseAccessSamlTypePingone IdentityProviderListResponseAccessSamlType = "pingone" + IdentityProviderListResponseAccessSamlTypeYandex IdentityProviderListResponseAccessSamlType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type IdentityProviderListResponseAccessSamlScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON identityProviderListResponseAccessSamlScimConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessSamlScimConfigJSON contains the JSON metadata +// for the struct [IdentityProviderListResponseAccessSamlScimConfig] +type identityProviderListResponseAccessSamlScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessSamlScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessSamlScimConfigJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderListResponseAccessYandex struct { + // The configuration parameters for the identity provider. To view the required + // parameters for a specific provider, refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Config IdentityProviderListResponseAccessYandexConfig `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name string `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type IdentityProviderListResponseAccessYandexType `json:"type,required"` + // UUID + ID string `json:"id"` + // The configuration settings for enabling a System for Cross-Domain Identity + // Management (SCIM) with the identity provider. + ScimConfig IdentityProviderListResponseAccessYandexScimConfig `json:"scim_config"` + JSON identityProviderListResponseAccessYandexJSON `json:"-"` +} + +// identityProviderListResponseAccessYandexJSON contains the JSON metadata for the +// struct [IdentityProviderListResponseAccessYandex] +type identityProviderListResponseAccessYandexJSON struct { + Config apijson.Field + Name apijson.Field + Type apijson.Field + ID apijson.Field + ScimConfig apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessYandex) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessYandexJSON) RawJSON() string { + return r.raw +} + +func (r IdentityProviderListResponseAccessYandex) implementsZeroTrustIdentityProviderListResponse() {} + +// The configuration parameters for the identity provider. To view the required +// parameters for a specific provider, refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessYandexConfig struct { + // Your OAuth Client ID + ClientID string `json:"client_id"` + // Your OAuth Client Secret + ClientSecret string `json:"client_secret"` + JSON identityProviderListResponseAccessYandexConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessYandexConfigJSON contains the JSON metadata +// for the struct [IdentityProviderListResponseAccessYandexConfig] +type identityProviderListResponseAccessYandexConfigJSON struct { + ClientID apijson.Field + ClientSecret apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessYandexConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessYandexConfigJSON) RawJSON() string { + return r.raw +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderListResponseAccessYandexType string + +const ( + IdentityProviderListResponseAccessYandexTypeOnetimepin IdentityProviderListResponseAccessYandexType = "onetimepin" + IdentityProviderListResponseAccessYandexTypeAzureAd IdentityProviderListResponseAccessYandexType = "azureAD" + IdentityProviderListResponseAccessYandexTypeSaml IdentityProviderListResponseAccessYandexType = "saml" + IdentityProviderListResponseAccessYandexTypeCentrify IdentityProviderListResponseAccessYandexType = "centrify" + IdentityProviderListResponseAccessYandexTypeFacebook IdentityProviderListResponseAccessYandexType = "facebook" + IdentityProviderListResponseAccessYandexTypeGitHub IdentityProviderListResponseAccessYandexType = "github" + IdentityProviderListResponseAccessYandexTypeGoogleApps IdentityProviderListResponseAccessYandexType = "google-apps" + IdentityProviderListResponseAccessYandexTypeGoogle IdentityProviderListResponseAccessYandexType = "google" + IdentityProviderListResponseAccessYandexTypeLinkedin IdentityProviderListResponseAccessYandexType = "linkedin" + IdentityProviderListResponseAccessYandexTypeOidc IdentityProviderListResponseAccessYandexType = "oidc" + IdentityProviderListResponseAccessYandexTypeOkta IdentityProviderListResponseAccessYandexType = "okta" + IdentityProviderListResponseAccessYandexTypeOnelogin IdentityProviderListResponseAccessYandexType = "onelogin" + IdentityProviderListResponseAccessYandexTypePingone IdentityProviderListResponseAccessYandexType = "pingone" + IdentityProviderListResponseAccessYandexTypeYandex IdentityProviderListResponseAccessYandexType = "yandex" +) + +// The configuration settings for enabling a System for Cross-Domain Identity +// Management (SCIM) with the identity provider. +type IdentityProviderListResponseAccessYandexScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled bool `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision bool `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision bool `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret string `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision bool `json:"user_deprovision"` + JSON identityProviderListResponseAccessYandexScimConfigJSON `json:"-"` +} + +// identityProviderListResponseAccessYandexScimConfigJSON contains the JSON +// metadata for the struct [IdentityProviderListResponseAccessYandexScimConfig] +type identityProviderListResponseAccessYandexScimConfigJSON struct { + Enabled apijson.Field + GroupMemberDeprovision apijson.Field + SeatDeprovision apijson.Field + Secret apijson.Field + UserDeprovision apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseAccessYandexScimConfig) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseAccessYandexScimConfigJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderDeleteResponse struct { + // UUID + ID string `json:"id"` + JSON identityProviderDeleteResponseJSON `json:"-"` +} + +// identityProviderDeleteResponseJSON contains the JSON metadata for the struct +// [IdentityProviderDeleteResponse] +type identityProviderDeleteResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderNewParams struct { + Config param.Field[IdentityProviderNewParamsConfig] `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name param.Field[string] `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type param.Field[IdentityProviderNewParamsType] `json:"type,required"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + ScimConfig param.Field[IdentityProviderNewParamsScimConfig] `json:"scim_config"` +} + +func (r IdentityProviderNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IdentityProviderNewParamsConfig struct { + // Your companies TLD + AppsDomain param.Field[string] `json:"apps_domain"` + // A list of SAML attribute names that will be added to your signed JWT token and + // can be used in SAML policy rules. + Attributes param.Field[[]string] `json:"attributes"` + // The authorization_endpoint URL of your IdP + AuthURL param.Field[string] `json:"auth_url"` + // Your okta authorization server id + AuthorizationServerID param.Field[string] `json:"authorization_server_id"` + // Your centrify account url + CentrifyAccount param.Field[string] `json:"centrify_account"` + // Your centrify app id + CentrifyAppID param.Field[string] `json:"centrify_app_id"` + // The jwks_uri endpoint of your IdP to allow the IdP keys to sign the tokens + CertsURL param.Field[string] `json:"certs_url"` + // Custom claims + Claims param.Field[[]string] `json:"claims"` + // Your OAuth Client ID + ClientID param.Field[string] `json:"client_id"` + // Your OAuth Client Secret + ClientSecret param.Field[string] `json:"client_secret"` + // Should Cloudflare try to load authentication contexts from your account + ConditionalAccessEnabled param.Field[bool] `json:"conditional_access_enabled"` + // Your Azure directory uuid + DirectoryID param.Field[string] `json:"directory_id"` + // The attribute name for email in the SAML response. + EmailAttributeName param.Field[string] `json:"email_attribute_name"` + // The claim name for email in the id_token response. + EmailClaimName param.Field[string] `json:"email_claim_name"` + // Add a list of attribute names that will be returned in the response header from + // the Access callback. + HeaderAttributes param.Field[[]IdentityProviderNewParamsConfigHeaderAttribute] `json:"header_attributes"` + // X509 certificate to verify the signature in the SAML authentication response + IdpPublicCerts param.Field[[]string] `json:"idp_public_certs"` + // IdP Entity ID or Issuer URL + IssuerURL param.Field[string] `json:"issuer_url"` + // Your okta account url + OktaAccount param.Field[string] `json:"okta_account"` + // Your OneLogin account url + OneloginAccount param.Field[string] `json:"onelogin_account"` + // Your PingOne environment identifier + PingEnvID param.Field[string] `json:"ping_env_id"` + // OAuth scopes + Scopes param.Field[[]string] `json:"scopes"` + // Sign the SAML authentication request with Access credentials. To verify the + // signature, use the public key from the Access certs endpoints. + SignRequest param.Field[bool] `json:"sign_request"` + // URL to send the SAML authentication requests to + SSOTargetURL param.Field[string] `json:"sso_target_url"` + // Should Cloudflare try to load groups from your account + SupportGroups param.Field[bool] `json:"support_groups"` + // The token_endpoint URL of your IdP + TokenURL param.Field[string] `json:"token_url"` +} + +func (r IdentityProviderNewParamsConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IdentityProviderNewParamsConfigHeaderAttribute struct { + // attribute name from the IDP + AttributeName param.Field[string] `json:"attribute_name"` + // header that will be added on the request to the origin + HeaderName param.Field[string] `json:"header_name"` +} + +func (r IdentityProviderNewParamsConfigHeaderAttribute) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderNewParamsType string + +const ( + IdentityProviderNewParamsTypeOnetimepin IdentityProviderNewParamsType = "onetimepin" + IdentityProviderNewParamsTypeAzureAd IdentityProviderNewParamsType = "azureAD" + IdentityProviderNewParamsTypeSaml IdentityProviderNewParamsType = "saml" + IdentityProviderNewParamsTypeCentrify IdentityProviderNewParamsType = "centrify" + IdentityProviderNewParamsTypeFacebook IdentityProviderNewParamsType = "facebook" + IdentityProviderNewParamsTypeGitHub IdentityProviderNewParamsType = "github" + IdentityProviderNewParamsTypeGoogleApps IdentityProviderNewParamsType = "google-apps" + IdentityProviderNewParamsTypeGoogle IdentityProviderNewParamsType = "google" + IdentityProviderNewParamsTypeLinkedin IdentityProviderNewParamsType = "linkedin" + IdentityProviderNewParamsTypeOidc IdentityProviderNewParamsType = "oidc" + IdentityProviderNewParamsTypeOkta IdentityProviderNewParamsType = "okta" + IdentityProviderNewParamsTypeOnelogin IdentityProviderNewParamsType = "onelogin" + IdentityProviderNewParamsTypePingone IdentityProviderNewParamsType = "pingone" + IdentityProviderNewParamsTypeYandex IdentityProviderNewParamsType = "yandex" +) + +type IdentityProviderNewParamsScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled param.Field[bool] `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision param.Field[bool] `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret param.Field[string] `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision param.Field[bool] `json:"user_deprovision"` +} + +func (r IdentityProviderNewParamsScimConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IdentityProviderNewResponseEnvelope struct { + Errors []IdentityProviderNewResponseEnvelopeErrors `json:"errors,required"` + Messages []IdentityProviderNewResponseEnvelopeMessages `json:"messages,required"` + Result AccessIdentityProviders `json:"result,required"` + // Whether the API call was successful + Success IdentityProviderNewResponseEnvelopeSuccess `json:"success,required"` + JSON identityProviderNewResponseEnvelopeJSON `json:"-"` +} + +// identityProviderNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [IdentityProviderNewResponseEnvelope] +type identityProviderNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON identityProviderNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// identityProviderNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [IdentityProviderNewResponseEnvelopeErrors] +type identityProviderNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON identityProviderNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// identityProviderNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [IdentityProviderNewResponseEnvelopeMessages] +type identityProviderNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IdentityProviderNewResponseEnvelopeSuccess bool + +const ( + IdentityProviderNewResponseEnvelopeSuccessTrue IdentityProviderNewResponseEnvelopeSuccess = true +) + +type IdentityProviderUpdateParams struct { + Config param.Field[IdentityProviderUpdateParamsConfig] `json:"config,required"` + // The name of the identity provider, shown to users on the login page. + Name param.Field[string] `json:"name,required"` + // The type of identity provider. To determine the value for a specific provider, + // refer to our + // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). + Type param.Field[IdentityProviderUpdateParamsType] `json:"type,required"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + ScimConfig param.Field[IdentityProviderUpdateParamsScimConfig] `json:"scim_config"` +} + +func (r IdentityProviderUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IdentityProviderUpdateParamsConfig struct { + // Your companies TLD + AppsDomain param.Field[string] `json:"apps_domain"` + // A list of SAML attribute names that will be added to your signed JWT token and + // can be used in SAML policy rules. + Attributes param.Field[[]string] `json:"attributes"` + // The authorization_endpoint URL of your IdP + AuthURL param.Field[string] `json:"auth_url"` + // Your okta authorization server id + AuthorizationServerID param.Field[string] `json:"authorization_server_id"` + // Your centrify account url + CentrifyAccount param.Field[string] `json:"centrify_account"` + // Your centrify app id + CentrifyAppID param.Field[string] `json:"centrify_app_id"` + // The jwks_uri endpoint of your IdP to allow the IdP keys to sign the tokens + CertsURL param.Field[string] `json:"certs_url"` + // Custom claims + Claims param.Field[[]string] `json:"claims"` + // Your OAuth Client ID + ClientID param.Field[string] `json:"client_id"` + // Your OAuth Client Secret + ClientSecret param.Field[string] `json:"client_secret"` + // Should Cloudflare try to load authentication contexts from your account + ConditionalAccessEnabled param.Field[bool] `json:"conditional_access_enabled"` + // Your Azure directory uuid + DirectoryID param.Field[string] `json:"directory_id"` + // The attribute name for email in the SAML response. + EmailAttributeName param.Field[string] `json:"email_attribute_name"` + // The claim name for email in the id_token response. + EmailClaimName param.Field[string] `json:"email_claim_name"` + // Add a list of attribute names that will be returned in the response header from + // the Access callback. + HeaderAttributes param.Field[[]IdentityProviderUpdateParamsConfigHeaderAttribute] `json:"header_attributes"` + // X509 certificate to verify the signature in the SAML authentication response + IdpPublicCerts param.Field[[]string] `json:"idp_public_certs"` + // IdP Entity ID or Issuer URL + IssuerURL param.Field[string] `json:"issuer_url"` + // Your okta account url + OktaAccount param.Field[string] `json:"okta_account"` + // Your OneLogin account url + OneloginAccount param.Field[string] `json:"onelogin_account"` + // Your PingOne environment identifier + PingEnvID param.Field[string] `json:"ping_env_id"` + // OAuth scopes + Scopes param.Field[[]string] `json:"scopes"` + // Sign the SAML authentication request with Access credentials. To verify the + // signature, use the public key from the Access certs endpoints. + SignRequest param.Field[bool] `json:"sign_request"` + // URL to send the SAML authentication requests to + SSOTargetURL param.Field[string] `json:"sso_target_url"` + // Should Cloudflare try to load groups from your account + SupportGroups param.Field[bool] `json:"support_groups"` + // The token_endpoint URL of your IdP + TokenURL param.Field[string] `json:"token_url"` +} + +func (r IdentityProviderUpdateParamsConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IdentityProviderUpdateParamsConfigHeaderAttribute struct { + // attribute name from the IDP + AttributeName param.Field[string] `json:"attribute_name"` + // header that will be added on the request to the origin + HeaderName param.Field[string] `json:"header_name"` +} + +func (r IdentityProviderUpdateParamsConfigHeaderAttribute) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of identity provider. To determine the value for a specific provider, +// refer to our +// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). +type IdentityProviderUpdateParamsType string + +const ( + IdentityProviderUpdateParamsTypeOnetimepin IdentityProviderUpdateParamsType = "onetimepin" + IdentityProviderUpdateParamsTypeAzureAd IdentityProviderUpdateParamsType = "azureAD" + IdentityProviderUpdateParamsTypeSaml IdentityProviderUpdateParamsType = "saml" + IdentityProviderUpdateParamsTypeCentrify IdentityProviderUpdateParamsType = "centrify" + IdentityProviderUpdateParamsTypeFacebook IdentityProviderUpdateParamsType = "facebook" + IdentityProviderUpdateParamsTypeGitHub IdentityProviderUpdateParamsType = "github" + IdentityProviderUpdateParamsTypeGoogleApps IdentityProviderUpdateParamsType = "google-apps" + IdentityProviderUpdateParamsTypeGoogle IdentityProviderUpdateParamsType = "google" + IdentityProviderUpdateParamsTypeLinkedin IdentityProviderUpdateParamsType = "linkedin" + IdentityProviderUpdateParamsTypeOidc IdentityProviderUpdateParamsType = "oidc" + IdentityProviderUpdateParamsTypeOkta IdentityProviderUpdateParamsType = "okta" + IdentityProviderUpdateParamsTypeOnelogin IdentityProviderUpdateParamsType = "onelogin" + IdentityProviderUpdateParamsTypePingone IdentityProviderUpdateParamsType = "pingone" + IdentityProviderUpdateParamsTypeYandex IdentityProviderUpdateParamsType = "yandex" +) + +type IdentityProviderUpdateParamsScimConfig struct { + // A flag to enable or disable SCIM for the identity provider. + Enabled param.Field[bool] `json:"enabled"` + // A flag to revoke a user's session in Access and force a reauthentication on the + // user's Gateway session when they have been added or removed from a group in the + // Identity Provider. + GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` + // A flag to remove a user's seat in Zero Trust when they have been deprovisioned + // in the Identity Provider. This cannot be enabled unless user_deprovision is also + // enabled. + SeatDeprovision param.Field[bool] `json:"seat_deprovision"` + // A read-only token generated when the SCIM integration is enabled for the first + // time. It is redacted on subsequent requests. If you lose this you will need to + // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. + Secret param.Field[string] `json:"secret"` + // A flag to enable revoking a user's session in Access and Gateway when they have + // been deprovisioned in the Identity Provider. + UserDeprovision param.Field[bool] `json:"user_deprovision"` +} + +func (r IdentityProviderUpdateParamsScimConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type IdentityProviderUpdateResponseEnvelope struct { + Errors []IdentityProviderUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []IdentityProviderUpdateResponseEnvelopeMessages `json:"messages,required"` + Result AccessIdentityProviders `json:"result,required"` + // Whether the API call was successful + Success IdentityProviderUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON identityProviderUpdateResponseEnvelopeJSON `json:"-"` +} + +// identityProviderUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [IdentityProviderUpdateResponseEnvelope] +type identityProviderUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON identityProviderUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// identityProviderUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [IdentityProviderUpdateResponseEnvelopeErrors] +type identityProviderUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON identityProviderUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// identityProviderUpdateResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [IdentityProviderUpdateResponseEnvelopeMessages] +type identityProviderUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IdentityProviderUpdateResponseEnvelopeSuccess bool + +const ( + IdentityProviderUpdateResponseEnvelopeSuccessTrue IdentityProviderUpdateResponseEnvelopeSuccess = true +) + +type IdentityProviderListParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type IdentityProviderListResponseEnvelope struct { + Errors []IdentityProviderListResponseEnvelopeErrors `json:"errors,required"` + Messages []IdentityProviderListResponseEnvelopeMessages `json:"messages,required"` + Result []IdentityProviderListResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success IdentityProviderListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo IdentityProviderListResponseEnvelopeResultInfo `json:"result_info"` + JSON identityProviderListResponseEnvelopeJSON `json:"-"` +} + +// identityProviderListResponseEnvelopeJSON contains the JSON metadata for the +// struct [IdentityProviderListResponseEnvelope] +type identityProviderListResponseEnvelopeJSON 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 *IdentityProviderListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON identityProviderListResponseEnvelopeErrorsJSON `json:"-"` +} + +// identityProviderListResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [IdentityProviderListResponseEnvelopeErrors] +type identityProviderListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON identityProviderListResponseEnvelopeMessagesJSON `json:"-"` +} + +// identityProviderListResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [IdentityProviderListResponseEnvelopeMessages] +type identityProviderListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IdentityProviderListResponseEnvelopeSuccess bool + +const ( + IdentityProviderListResponseEnvelopeSuccessTrue IdentityProviderListResponseEnvelopeSuccess = true +) + +type IdentityProviderListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON identityProviderListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// identityProviderListResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [IdentityProviderListResponseEnvelopeResultInfo] +type identityProviderListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderDeleteParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type IdentityProviderDeleteResponseEnvelope struct { + Errors []IdentityProviderDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []IdentityProviderDeleteResponseEnvelopeMessages `json:"messages,required"` + Result IdentityProviderDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success IdentityProviderDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON identityProviderDeleteResponseEnvelopeJSON `json:"-"` +} + +// identityProviderDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [IdentityProviderDeleteResponseEnvelope] +type identityProviderDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON identityProviderDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// identityProviderDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [IdentityProviderDeleteResponseEnvelopeErrors] +type identityProviderDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON identityProviderDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// identityProviderDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [IdentityProviderDeleteResponseEnvelopeMessages] +type identityProviderDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IdentityProviderDeleteResponseEnvelopeSuccess bool + +const ( + IdentityProviderDeleteResponseEnvelopeSuccessTrue IdentityProviderDeleteResponseEnvelopeSuccess = true +) + +type IdentityProviderGetParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type IdentityProviderGetResponseEnvelope struct { + Errors []IdentityProviderGetResponseEnvelopeErrors `json:"errors,required"` + Messages []IdentityProviderGetResponseEnvelopeMessages `json:"messages,required"` + Result AccessIdentityProviders `json:"result,required"` + // Whether the API call was successful + Success IdentityProviderGetResponseEnvelopeSuccess `json:"success,required"` + JSON identityProviderGetResponseEnvelopeJSON `json:"-"` +} + +// identityProviderGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [IdentityProviderGetResponseEnvelope] +type identityProviderGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON identityProviderGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// identityProviderGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [IdentityProviderGetResponseEnvelopeErrors] +type identityProviderGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type IdentityProviderGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON identityProviderGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// identityProviderGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [IdentityProviderGetResponseEnvelopeMessages] +type identityProviderGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *IdentityProviderGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r identityProviderGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type IdentityProviderGetResponseEnvelopeSuccess bool + +const ( + IdentityProviderGetResponseEnvelopeSuccessTrue IdentityProviderGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/identityprovider_test.go b/zero_trust/identityprovider_test.go new file mode 100644 index 00000000000..1d608733df3 --- /dev/null +++ b/zero_trust/identityprovider_test.go @@ -0,0 +1,252 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestIdentityProviderNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.IdentityProviders.New(context.TODO(), zero_trust.IdentityProviderNewParams{ + Config: cloudflare.F(zero_trust.IdentityProviderNewParamsConfig{ + ClientID: cloudflare.F(""), + ClientSecret: cloudflare.F(""), + Claims: cloudflare.F([]string{"email_verified", "preferred_username", "custom_claim_name"}), + EmailClaimName: cloudflare.F("custom_claim_name"), + ConditionalAccessEnabled: cloudflare.F(true), + DirectoryID: cloudflare.F(""), + SupportGroups: cloudflare.F(true), + CentrifyAccount: cloudflare.F("https://abc123.my.centrify.com/"), + CentrifyAppID: cloudflare.F("exampleapp"), + AppsDomain: cloudflare.F("mycompany.com"), + AuthURL: cloudflare.F("https://accounts.google.com/o/oauth2/auth"), + CertsURL: cloudflare.F("https://www.googleapis.com/oauth2/v3/certs"), + Scopes: cloudflare.F([]string{"openid", "email", "profile"}), + TokenURL: cloudflare.F("https://accounts.google.com/o/oauth2/token"), + AuthorizationServerID: cloudflare.F("aus9o8wzkhckw9TLa0h7z"), + OktaAccount: cloudflare.F("https://dev-abc123.oktapreview.com"), + OneloginAccount: cloudflare.F("https://mycompany.onelogin.com"), + PingEnvID: cloudflare.F("342b5660-0c32-4936-a5a4-ce21fae57b0a"), + Attributes: cloudflare.F([]string{"group", "department_code", "divison"}), + EmailAttributeName: cloudflare.F("Email"), + HeaderAttributes: cloudflare.F([]zero_trust.IdentityProviderNewParamsConfigHeaderAttribute{{ + AttributeName: cloudflare.F("string"), + HeaderName: cloudflare.F("string"), + }, { + AttributeName: cloudflare.F("string"), + HeaderName: cloudflare.F("string"), + }, { + AttributeName: cloudflare.F("string"), + HeaderName: cloudflare.F("string"), + }}), + IdpPublicCerts: cloudflare.F([]string{"string", "string", "string"}), + IssuerURL: cloudflare.F("https://whoami.com"), + SignRequest: cloudflare.F(true), + SSOTargetURL: cloudflare.F("https://edgeaccess.org/idp/saml/login"), + }), + Name: cloudflare.F("Widget Corps IDP"), + Type: cloudflare.F(zero_trust.IdentityProviderNewParamsTypeOnetimepin), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + ScimConfig: cloudflare.F(zero_trust.IdentityProviderNewParamsScimConfig{ + Enabled: cloudflare.F(true), + GroupMemberDeprovision: cloudflare.F(true), + SeatDeprovision: cloudflare.F(true), + Secret: cloudflare.F("string"), + UserDeprovision: cloudflare.F(true), + }), + }) + 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 TestIdentityProviderUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.IdentityProviders.Update( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.IdentityProviderUpdateParams{ + Config: cloudflare.F(zero_trust.IdentityProviderUpdateParamsConfig{ + ClientID: cloudflare.F(""), + ClientSecret: cloudflare.F(""), + Claims: cloudflare.F([]string{"email_verified", "preferred_username", "custom_claim_name"}), + EmailClaimName: cloudflare.F("custom_claim_name"), + ConditionalAccessEnabled: cloudflare.F(true), + DirectoryID: cloudflare.F(""), + SupportGroups: cloudflare.F(true), + CentrifyAccount: cloudflare.F("https://abc123.my.centrify.com/"), + CentrifyAppID: cloudflare.F("exampleapp"), + AppsDomain: cloudflare.F("mycompany.com"), + AuthURL: cloudflare.F("https://accounts.google.com/o/oauth2/auth"), + CertsURL: cloudflare.F("https://www.googleapis.com/oauth2/v3/certs"), + Scopes: cloudflare.F([]string{"openid", "email", "profile"}), + TokenURL: cloudflare.F("https://accounts.google.com/o/oauth2/token"), + AuthorizationServerID: cloudflare.F("aus9o8wzkhckw9TLa0h7z"), + OktaAccount: cloudflare.F("https://dev-abc123.oktapreview.com"), + OneloginAccount: cloudflare.F("https://mycompany.onelogin.com"), + PingEnvID: cloudflare.F("342b5660-0c32-4936-a5a4-ce21fae57b0a"), + Attributes: cloudflare.F([]string{"group", "department_code", "divison"}), + EmailAttributeName: cloudflare.F("Email"), + HeaderAttributes: cloudflare.F([]zero_trust.IdentityProviderUpdateParamsConfigHeaderAttribute{{ + AttributeName: cloudflare.F("string"), + HeaderName: cloudflare.F("string"), + }, { + AttributeName: cloudflare.F("string"), + HeaderName: cloudflare.F("string"), + }, { + AttributeName: cloudflare.F("string"), + HeaderName: cloudflare.F("string"), + }}), + IdpPublicCerts: cloudflare.F([]string{"string", "string", "string"}), + IssuerURL: cloudflare.F("https://whoami.com"), + SignRequest: cloudflare.F(true), + SSOTargetURL: cloudflare.F("https://edgeaccess.org/idp/saml/login"), + }), + Name: cloudflare.F("Widget Corps IDP"), + Type: cloudflare.F(zero_trust.IdentityProviderUpdateParamsTypeOnetimepin), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + ScimConfig: cloudflare.F(zero_trust.IdentityProviderUpdateParamsScimConfig{ + Enabled: cloudflare.F(true), + GroupMemberDeprovision: cloudflare.F(true), + SeatDeprovision: cloudflare.F(true), + Secret: cloudflare.F("string"), + UserDeprovision: cloudflare.F(true), + }), + }, + ) + 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 TestIdentityProviderListWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.IdentityProviders.List(context.TODO(), zero_trust.IdentityProviderListParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }) + 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 TestIdentityProviderDeleteWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.IdentityProviders.Delete( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.IdentityProviderDeleteParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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 TestIdentityProviderGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.IdentityProviders.Get( + context.TODO(), + "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", + zero_trust.IdentityProviderGetParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }, + ) + 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/zero_trust/network.go b/zero_trust/network.go new file mode 100644 index 00000000000..d4eb0da9a8a --- /dev/null +++ b/zero_trust/network.go @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// NetworkService 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 [NewNetworkService] method instead. +type NetworkService struct { + Options []option.RequestOption + Routes *NetworkRouteService + VirtualNetworks *NetworkVirtualNetworkService +} + +// NewNetworkService 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 NewNetworkService(opts ...option.RequestOption) (r *NetworkService) { + r = &NetworkService{} + r.Options = opts + r.Routes = NewNetworkRouteService(opts...) + r.VirtualNetworks = NewNetworkVirtualNetworkService(opts...) + return +} diff --git a/zero_trust/networkroute.go b/zero_trust/networkroute.go new file mode 100644 index 00000000000..90eb36d8f24 --- /dev/null +++ b/zero_trust/networkroute.go @@ -0,0 +1,541 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "net/url" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" +) + +// NetworkRouteService 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 [NewNetworkRouteService] method +// instead. +type NetworkRouteService struct { + Options []option.RequestOption + IPs *NetworkRouteIPService + Networks *NetworkRouteNetworkService +} + +// NewNetworkRouteService 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 NewNetworkRouteService(opts ...option.RequestOption) (r *NetworkRouteService) { + r = &NetworkRouteService{} + r.Options = opts + r.IPs = NewNetworkRouteIPService(opts...) + r.Networks = NewNetworkRouteNetworkService(opts...) + return +} + +// Routes a private network through a Cloudflare Tunnel. +func (r *NetworkRouteService) New(ctx context.Context, params NetworkRouteNewParams, opts ...option.RequestOption) (res *TunnelRoute, err error) { + opts = append(r.Options[:], opts...) + var env NetworkRouteNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/teamnet/routes", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists and filters private network routes in an account. +func (r *NetworkRouteService) List(ctx context.Context, params NetworkRouteListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[TunnelTeamnet], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("accounts/%s/teamnet/routes", params.AccountID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists and filters private network routes in an account. +func (r *NetworkRouteService) ListAutoPaging(ctx context.Context, params NetworkRouteListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[TunnelTeamnet] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) +} + +// Deletes a private network route from an account. +func (r *NetworkRouteService) Delete(ctx context.Context, routeID string, body NetworkRouteDeleteParams, opts ...option.RequestOption) (res *TunnelRoute, err error) { + opts = append(r.Options[:], opts...) + var env NetworkRouteDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/teamnet/routes/%s", body.AccountID, routeID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates an existing private network route in an account. The fields that are +// meant to be updated should be provided in the body of the request. +func (r *NetworkRouteService) Edit(ctx context.Context, routeID string, params NetworkRouteEditParams, opts ...option.RequestOption) (res *TunnelRoute, err error) { + opts = append(r.Options[:], opts...) + var env NetworkRouteEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/teamnet/routes/%s", params.AccountID, routeID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TunnelRoute struct { + // UUID of the route. + ID string `json:"id"` + // Optional remark describing the route. + Comment string `json:"comment"` + // Timestamp of when the route was created. + CreatedAt interface{} `json:"created_at"` + // Timestamp of when the route was deleted. If `null`, the route has not been + // deleted. + DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` + // The private IPv4 or IPv6 range connected by the route, in CIDR notation. + Network string `json:"network"` + // UUID of the Cloudflare Tunnel serving the route. + TunnelID interface{} `json:"tunnel_id"` + // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks + // are configured, the route is assigned to the default virtual network of the + // account. + VirtualNetworkID interface{} `json:"virtual_network_id"` + JSON tunnelRouteJSON `json:"-"` +} + +// tunnelRouteJSON contains the JSON metadata for the struct [TunnelRoute] +type tunnelRouteJSON struct { + ID apijson.Field + Comment apijson.Field + CreatedAt apijson.Field + DeletedAt apijson.Field + Network apijson.Field + TunnelID apijson.Field + VirtualNetworkID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelRoute) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelRouteJSON) RawJSON() string { + return r.raw +} + +type TunnelTeamnet struct { + // UUID of the route. + ID string `json:"id"` + // Optional remark describing the route. + Comment string `json:"comment"` + // Timestamp of when the route was created. + CreatedAt interface{} `json:"created_at"` + // Timestamp of when the route was deleted. If `null`, the route has not been + // deleted. + DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` + // The private IPv4 or IPv6 range connected by the route, in CIDR notation. + Network string `json:"network"` + // The type of tunnel. + TunType TunnelTeamnetTunType `json:"tun_type"` + // UUID of the Cloudflare Tunnel serving the route. + TunnelID interface{} `json:"tunnel_id"` + // The user-friendly name of the Cloudflare Tunnel serving the route. + TunnelName interface{} `json:"tunnel_name"` + // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks + // are configured, the route is assigned to the default virtual network of the + // account. + VirtualNetworkID interface{} `json:"virtual_network_id"` + // A user-friendly name for the virtual network. + VirtualNetworkName string `json:"virtual_network_name"` + JSON tunnelTeamnetJSON `json:"-"` +} + +// tunnelTeamnetJSON contains the JSON metadata for the struct [TunnelTeamnet] +type tunnelTeamnetJSON struct { + ID apijson.Field + Comment apijson.Field + CreatedAt apijson.Field + DeletedAt apijson.Field + Network apijson.Field + TunType apijson.Field + TunnelID apijson.Field + TunnelName apijson.Field + VirtualNetworkID apijson.Field + VirtualNetworkName apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelTeamnet) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelTeamnetJSON) RawJSON() string { + return r.raw +} + +// The type of tunnel. +type TunnelTeamnetTunType string + +const ( + TunnelTeamnetTunTypeCfdTunnel TunnelTeamnetTunType = "cfd_tunnel" + TunnelTeamnetTunTypeWARPConnector TunnelTeamnetTunType = "warp_connector" + TunnelTeamnetTunTypeIPSec TunnelTeamnetTunType = "ip_sec" + TunnelTeamnetTunTypeGRE TunnelTeamnetTunType = "gre" + TunnelTeamnetTunTypeCni TunnelTeamnetTunType = "cni" +) + +type NetworkRouteNewParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` + // The private IPv4 or IPv6 range connected by the route, in CIDR notation. + IPNetwork param.Field[string] `json:"ip_network,required"` + // Optional remark describing the route. + Comment param.Field[string] `json:"comment"` + // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks + // are configured, the route is assigned to the default virtual network of the + // account. + VirtualNetworkID param.Field[interface{}] `json:"virtual_network_id"` +} + +func (r NetworkRouteNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type NetworkRouteNewResponseEnvelope struct { + Errors []NetworkRouteNewResponseEnvelopeErrors `json:"errors,required"` + Messages []NetworkRouteNewResponseEnvelopeMessages `json:"messages,required"` + Result TunnelRoute `json:"result,required"` + // Whether the API call was successful + Success NetworkRouteNewResponseEnvelopeSuccess `json:"success,required"` + JSON networkRouteNewResponseEnvelopeJSON `json:"-"` +} + +// networkRouteNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [NetworkRouteNewResponseEnvelope] +type networkRouteNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NetworkRouteNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkRouteNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// networkRouteNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [NetworkRouteNewResponseEnvelopeErrors] +type networkRouteNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NetworkRouteNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkRouteNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// networkRouteNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [NetworkRouteNewResponseEnvelopeMessages] +type networkRouteNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NetworkRouteNewResponseEnvelopeSuccess bool + +const ( + NetworkRouteNewResponseEnvelopeSuccessTrue NetworkRouteNewResponseEnvelopeSuccess = true +) + +type NetworkRouteListParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` + // Optional remark describing the route. + Comment param.Field[string] `query:"comment"` + // If provided, include only routes that were created (and not deleted) before this + // time. + ExistedAt param.Field[interface{}] `query:"existed_at"` + // If `true`, only include deleted routes. If `false`, exclude deleted routes. If + // empty, all routes will be included. + IsDeleted param.Field[interface{}] `query:"is_deleted"` + // If set, only list routes that are contained within this IP range. + NetworkSubset param.Field[interface{}] `query:"network_subset"` + // If set, only list routes that contain this IP range. + NetworkSuperset param.Field[interface{}] `query:"network_superset"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // Number of results to display. + PerPage param.Field[float64] `query:"per_page"` + // The types of tunnels to filter separated by a comma. + TunTypes param.Field[string] `query:"tun_types"` + // UUID of the Cloudflare Tunnel serving the route. + TunnelID param.Field[interface{}] `query:"tunnel_id"` + // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks + // are configured, the route is assigned to the default virtual network of the + // account. + VirtualNetworkID param.Field[interface{}] `query:"virtual_network_id"` +} + +// URLQuery serializes [NetworkRouteListParams]'s query parameters as `url.Values`. +func (r NetworkRouteListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type NetworkRouteDeleteParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` +} + +type NetworkRouteDeleteResponseEnvelope struct { + Errors []NetworkRouteDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []NetworkRouteDeleteResponseEnvelopeMessages `json:"messages,required"` + Result TunnelRoute `json:"result,required"` + // Whether the API call was successful + Success NetworkRouteDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON networkRouteDeleteResponseEnvelopeJSON `json:"-"` +} + +// networkRouteDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [NetworkRouteDeleteResponseEnvelope] +type networkRouteDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NetworkRouteDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkRouteDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// networkRouteDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [NetworkRouteDeleteResponseEnvelopeErrors] +type networkRouteDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NetworkRouteDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkRouteDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// networkRouteDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [NetworkRouteDeleteResponseEnvelopeMessages] +type networkRouteDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NetworkRouteDeleteResponseEnvelopeSuccess bool + +const ( + NetworkRouteDeleteResponseEnvelopeSuccessTrue NetworkRouteDeleteResponseEnvelopeSuccess = true +) + +type NetworkRouteEditParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` + // Optional remark describing the route. + Comment param.Field[string] `json:"comment"` + // The private IPv4 or IPv6 range connected by the route, in CIDR notation. + Network param.Field[string] `json:"network"` + // The type of tunnel. + TunType param.Field[NetworkRouteEditParamsTunType] `json:"tun_type"` + // UUID of the Cloudflare Tunnel serving the route. + TunnelID param.Field[interface{}] `json:"tunnel_id"` + // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks + // are configured, the route is assigned to the default virtual network of the + // account. + VirtualNetworkID param.Field[interface{}] `json:"virtual_network_id"` +} + +func (r NetworkRouteEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The type of tunnel. +type NetworkRouteEditParamsTunType string + +const ( + NetworkRouteEditParamsTunTypeCfdTunnel NetworkRouteEditParamsTunType = "cfd_tunnel" + NetworkRouteEditParamsTunTypeWARPConnector NetworkRouteEditParamsTunType = "warp_connector" + NetworkRouteEditParamsTunTypeIPSec NetworkRouteEditParamsTunType = "ip_sec" + NetworkRouteEditParamsTunTypeGRE NetworkRouteEditParamsTunType = "gre" + NetworkRouteEditParamsTunTypeCni NetworkRouteEditParamsTunType = "cni" +) + +type NetworkRouteEditResponseEnvelope struct { + Errors []NetworkRouteEditResponseEnvelopeErrors `json:"errors,required"` + Messages []NetworkRouteEditResponseEnvelopeMessages `json:"messages,required"` + Result TunnelRoute `json:"result,required"` + // Whether the API call was successful + Success NetworkRouteEditResponseEnvelopeSuccess `json:"success,required"` + JSON networkRouteEditResponseEnvelopeJSON `json:"-"` +} + +// networkRouteEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [NetworkRouteEditResponseEnvelope] +type networkRouteEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NetworkRouteEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkRouteEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// networkRouteEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [NetworkRouteEditResponseEnvelopeErrors] +type networkRouteEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NetworkRouteEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkRouteEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// networkRouteEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [NetworkRouteEditResponseEnvelopeMessages] +type networkRouteEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NetworkRouteEditResponseEnvelopeSuccess bool + +const ( + NetworkRouteEditResponseEnvelopeSuccessTrue NetworkRouteEditResponseEnvelopeSuccess = true +) diff --git a/zero_trust/networkroute_test.go b/zero_trust/networkroute_test.go new file mode 100644 index 00000000000..7908d2f8631 --- /dev/null +++ b/zero_trust/networkroute_test.go @@ -0,0 +1,145 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestNetworkRouteNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Networks.Routes.New(context.TODO(), zero_trust.NetworkRouteNewParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + IPNetwork: cloudflare.F("172.16.0.0/16"), + Comment: cloudflare.F("Example comment for this route."), + VirtualNetworkID: cloudflare.F[any](map[string]interface{}{}), + }) + 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 TestNetworkRouteListWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Networks.Routes.List(context.TODO(), zero_trust.NetworkRouteListParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Comment: cloudflare.F("Example comment for this route."), + ExistedAt: cloudflare.F[any](map[string]interface{}{}), + IsDeleted: cloudflare.F[any](map[string]interface{}{}), + NetworkSubset: cloudflare.F[any](map[string]interface{}{}), + NetworkSuperset: cloudflare.F[any](map[string]interface{}{}), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(1.000000), + TunTypes: cloudflare.F("cfd_tunnel,warp_connector"), + TunnelID: cloudflare.F[any](map[string]interface{}{}), + VirtualNetworkID: cloudflare.F[any](map[string]interface{}{}), + }) + 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 TestNetworkRouteDelete(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("user@example.com"), + ) + _, err := client.ZeroTrust.Networks.Routes.Delete( + context.TODO(), + "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + zero_trust.NetworkRouteDeleteParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + }, + ) + 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 TestNetworkRouteEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Networks.Routes.Edit( + context.TODO(), + "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + zero_trust.NetworkRouteEditParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Comment: cloudflare.F("Example comment for this route."), + Network: cloudflare.F("172.16.0.0/16"), + TunType: cloudflare.F(zero_trust.NetworkRouteEditParamsTunTypeCfdTunnel), + TunnelID: cloudflare.F[any](map[string]interface{}{}), + VirtualNetworkID: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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/zero_trust/networkrouteip.go b/zero_trust/networkrouteip.go new file mode 100644 index 00000000000..d2c482264f5 --- /dev/null +++ b/zero_trust/networkrouteip.go @@ -0,0 +1,146 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// NetworkRouteIPService 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 [NewNetworkRouteIPService] method +// instead. +type NetworkRouteIPService struct { + Options []option.RequestOption +} + +// NewNetworkRouteIPService 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 NewNetworkRouteIPService(opts ...option.RequestOption) (r *NetworkRouteIPService) { + r = &NetworkRouteIPService{} + r.Options = opts + return +} + +// Fetches routes that contain the given IP address. +func (r *NetworkRouteIPService) Get(ctx context.Context, ip string, params NetworkRouteIPGetParams, opts ...option.RequestOption) (res *TunnelTeamnet, err error) { + opts = append(r.Options[:], opts...) + var env NetworkRouteIPGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/teamnet/routes/ip/%s", params.AccountID, ip) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type NetworkRouteIPGetParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` + // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks + // are configured, the route is assigned to the default virtual network of the + // account. + VirtualNetworkID param.Field[interface{}] `query:"virtual_network_id"` +} + +// URLQuery serializes [NetworkRouteIPGetParams]'s query parameters as +// `url.Values`. +func (r NetworkRouteIPGetParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type NetworkRouteIPGetResponseEnvelope struct { + Errors []NetworkRouteIPGetResponseEnvelopeErrors `json:"errors,required"` + Messages []NetworkRouteIPGetResponseEnvelopeMessages `json:"messages,required"` + Result TunnelTeamnet `json:"result,required"` + // Whether the API call was successful + Success NetworkRouteIPGetResponseEnvelopeSuccess `json:"success,required"` + JSON networkRouteIPGetResponseEnvelopeJSON `json:"-"` +} + +// networkRouteIPGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [NetworkRouteIPGetResponseEnvelope] +type networkRouteIPGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteIPGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteIPGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NetworkRouteIPGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkRouteIPGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// networkRouteIPGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [NetworkRouteIPGetResponseEnvelopeErrors] +type networkRouteIPGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteIPGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteIPGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NetworkRouteIPGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkRouteIPGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// networkRouteIPGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [NetworkRouteIPGetResponseEnvelopeMessages] +type networkRouteIPGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteIPGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteIPGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NetworkRouteIPGetResponseEnvelopeSuccess bool + +const ( + NetworkRouteIPGetResponseEnvelopeSuccessTrue NetworkRouteIPGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/networkrouteip_test.go b/zero_trust/networkrouteip_test.go new file mode 100644 index 00000000000..90217875c1e --- /dev/null +++ b/zero_trust/networkrouteip_test.go @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestNetworkRouteIPGetWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Networks.Routes.IPs.Get( + context.TODO(), + "10.1.0.137", + zero_trust.NetworkRouteIPGetParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + VirtualNetworkID: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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/zero_trust/networkroutenetwork.go b/zero_trust/networkroutenetwork.go new file mode 100644 index 00000000000..651f1170d47 --- /dev/null +++ b/zero_trust/networkroutenetwork.go @@ -0,0 +1,371 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// NetworkRouteNetworkService 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 [NewNetworkRouteNetworkService] +// method instead. +type NetworkRouteNetworkService struct { + Options []option.RequestOption +} + +// NewNetworkRouteNetworkService 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 NewNetworkRouteNetworkService(opts ...option.RequestOption) (r *NetworkRouteNetworkService) { + r = &NetworkRouteNetworkService{} + r.Options = opts + return +} + +// Routes a private network through a Cloudflare Tunnel. The CIDR in +// `ip_network_encoded` must be written in URL-encoded format. +func (r *NetworkRouteNetworkService) New(ctx context.Context, ipNetworkEncoded string, params NetworkRouteNetworkNewParams, opts ...option.RequestOption) (res *TunnelRoute, err error) { + opts = append(r.Options[:], opts...) + var env NetworkRouteNetworkNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/teamnet/routes/network/%s", params.AccountID, ipNetworkEncoded) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes a private network route from an account. The CIDR in +// `ip_network_encoded` must be written in URL-encoded format. If no +// virtual_network_id is provided it will delete the route from the default vnet. +// If no tun_type is provided it will fetch the type from the tunnel_id or if that +// is missing it will assume Cloudflare Tunnel as default. If tunnel_id is provided +// it will delete the route from that tunnel, otherwise it will delete the route +// based on the vnet and tun_type. +func (r *NetworkRouteNetworkService) Delete(ctx context.Context, ipNetworkEncoded string, params NetworkRouteNetworkDeleteParams, opts ...option.RequestOption) (res *TunnelRoute, err error) { + opts = append(r.Options[:], opts...) + var env NetworkRouteNetworkDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/teamnet/routes/network/%s", params.AccountID, ipNetworkEncoded) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates an existing private network route in an account. The CIDR in +// `ip_network_encoded` must be written in URL-encoded format. +func (r *NetworkRouteNetworkService) Edit(ctx context.Context, ipNetworkEncoded string, body NetworkRouteNetworkEditParams, opts ...option.RequestOption) (res *TunnelRoute, err error) { + opts = append(r.Options[:], opts...) + var env NetworkRouteNetworkEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/teamnet/routes/network/%s", body.AccountID, ipNetworkEncoded) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type NetworkRouteNetworkNewParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` + // Optional remark describing the route. + Comment param.Field[string] `json:"comment"` + // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks + // are configured, the route is assigned to the default virtual network of the + // account. + VirtualNetworkID param.Field[interface{}] `json:"virtual_network_id"` +} + +func (r NetworkRouteNetworkNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type NetworkRouteNetworkNewResponseEnvelope struct { + Errors []NetworkRouteNetworkNewResponseEnvelopeErrors `json:"errors,required"` + Messages []NetworkRouteNetworkNewResponseEnvelopeMessages `json:"messages,required"` + Result TunnelRoute `json:"result,required"` + // Whether the API call was successful + Success NetworkRouteNetworkNewResponseEnvelopeSuccess `json:"success,required"` + JSON networkRouteNetworkNewResponseEnvelopeJSON `json:"-"` +} + +// networkRouteNetworkNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [NetworkRouteNetworkNewResponseEnvelope] +type networkRouteNetworkNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteNetworkNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteNetworkNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NetworkRouteNetworkNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkRouteNetworkNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// networkRouteNetworkNewResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [NetworkRouteNetworkNewResponseEnvelopeErrors] +type networkRouteNetworkNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteNetworkNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteNetworkNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NetworkRouteNetworkNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkRouteNetworkNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// networkRouteNetworkNewResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [NetworkRouteNetworkNewResponseEnvelopeMessages] +type networkRouteNetworkNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteNetworkNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteNetworkNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NetworkRouteNetworkNewResponseEnvelopeSuccess bool + +const ( + NetworkRouteNetworkNewResponseEnvelopeSuccessTrue NetworkRouteNetworkNewResponseEnvelopeSuccess = true +) + +type NetworkRouteNetworkDeleteParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` + // The type of tunnel. + TunType param.Field[NetworkRouteNetworkDeleteParamsTunType] `query:"tun_type"` +} + +// URLQuery serializes [NetworkRouteNetworkDeleteParams]'s query parameters as +// `url.Values`. +func (r NetworkRouteNetworkDeleteParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +// The type of tunnel. +type NetworkRouteNetworkDeleteParamsTunType string + +const ( + NetworkRouteNetworkDeleteParamsTunTypeCfdTunnel NetworkRouteNetworkDeleteParamsTunType = "cfd_tunnel" + NetworkRouteNetworkDeleteParamsTunTypeWARPConnector NetworkRouteNetworkDeleteParamsTunType = "warp_connector" + NetworkRouteNetworkDeleteParamsTunTypeIPSec NetworkRouteNetworkDeleteParamsTunType = "ip_sec" + NetworkRouteNetworkDeleteParamsTunTypeGRE NetworkRouteNetworkDeleteParamsTunType = "gre" + NetworkRouteNetworkDeleteParamsTunTypeCni NetworkRouteNetworkDeleteParamsTunType = "cni" +) + +type NetworkRouteNetworkDeleteResponseEnvelope struct { + Errors []NetworkRouteNetworkDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []NetworkRouteNetworkDeleteResponseEnvelopeMessages `json:"messages,required"` + Result TunnelRoute `json:"result,required"` + // Whether the API call was successful + Success NetworkRouteNetworkDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON networkRouteNetworkDeleteResponseEnvelopeJSON `json:"-"` +} + +// networkRouteNetworkDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [NetworkRouteNetworkDeleteResponseEnvelope] +type networkRouteNetworkDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteNetworkDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteNetworkDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NetworkRouteNetworkDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkRouteNetworkDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// networkRouteNetworkDeleteResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [NetworkRouteNetworkDeleteResponseEnvelopeErrors] +type networkRouteNetworkDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteNetworkDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteNetworkDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NetworkRouteNetworkDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkRouteNetworkDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// networkRouteNetworkDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [NetworkRouteNetworkDeleteResponseEnvelopeMessages] +type networkRouteNetworkDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteNetworkDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteNetworkDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NetworkRouteNetworkDeleteResponseEnvelopeSuccess bool + +const ( + NetworkRouteNetworkDeleteResponseEnvelopeSuccessTrue NetworkRouteNetworkDeleteResponseEnvelopeSuccess = true +) + +type NetworkRouteNetworkEditParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` +} + +type NetworkRouteNetworkEditResponseEnvelope struct { + Errors []NetworkRouteNetworkEditResponseEnvelopeErrors `json:"errors,required"` + Messages []NetworkRouteNetworkEditResponseEnvelopeMessages `json:"messages,required"` + Result TunnelRoute `json:"result,required"` + // Whether the API call was successful + Success NetworkRouteNetworkEditResponseEnvelopeSuccess `json:"success,required"` + JSON networkRouteNetworkEditResponseEnvelopeJSON `json:"-"` +} + +// networkRouteNetworkEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [NetworkRouteNetworkEditResponseEnvelope] +type networkRouteNetworkEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteNetworkEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteNetworkEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NetworkRouteNetworkEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkRouteNetworkEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// networkRouteNetworkEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [NetworkRouteNetworkEditResponseEnvelopeErrors] +type networkRouteNetworkEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteNetworkEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteNetworkEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NetworkRouteNetworkEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkRouteNetworkEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// networkRouteNetworkEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [NetworkRouteNetworkEditResponseEnvelopeMessages] +type networkRouteNetworkEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkRouteNetworkEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkRouteNetworkEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NetworkRouteNetworkEditResponseEnvelopeSuccess bool + +const ( + NetworkRouteNetworkEditResponseEnvelopeSuccessTrue NetworkRouteNetworkEditResponseEnvelopeSuccess = true +) diff --git a/zero_trust/networkroutenetwork_test.go b/zero_trust/networkroutenetwork_test.go new file mode 100644 index 00000000000..3be5c7fe1ba --- /dev/null +++ b/zero_trust/networkroutenetwork_test.go @@ -0,0 +1,108 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestNetworkRouteNetworkNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Networks.Routes.Networks.New( + context.TODO(), + "172.16.0.0%2F16", + zero_trust.NetworkRouteNetworkNewParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Comment: cloudflare.F("Example comment for this route."), + VirtualNetworkID: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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 TestNetworkRouteNetworkDeleteWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Networks.Routes.Networks.Delete( + context.TODO(), + "172.16.0.0%2F16", + zero_trust.NetworkRouteNetworkDeleteParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + TunType: cloudflare.F(zero_trust.NetworkRouteNetworkDeleteParamsTunTypeCfdTunnel), + }, + ) + 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 TestNetworkRouteNetworkEdit(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("user@example.com"), + ) + _, err := client.ZeroTrust.Networks.Routes.Networks.Edit( + context.TODO(), + "172.16.0.0%2F16", + zero_trust.NetworkRouteNetworkEditParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/networkvirtualnetwork.go b/zero_trust/networkvirtualnetwork.go new file mode 100644 index 00000000000..4bdab3208d9 --- /dev/null +++ b/zero_trust/networkvirtualnetwork.go @@ -0,0 +1,621 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// NetworkVirtualNetworkService 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 [NewNetworkVirtualNetworkService] +// method instead. +type NetworkVirtualNetworkService struct { + Options []option.RequestOption +} + +// NewNetworkVirtualNetworkService 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 NewNetworkVirtualNetworkService(opts ...option.RequestOption) (r *NetworkVirtualNetworkService) { + r = &NetworkVirtualNetworkService{} + r.Options = opts + return +} + +// Adds a new virtual network to an account. +func (r *NetworkVirtualNetworkService) New(ctx context.Context, params NetworkVirtualNetworkNewParams, opts ...option.RequestOption) (res *NetworkVirtualNetworkNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env NetworkVirtualNetworkNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/teamnet/virtual_networks", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists and filters virtual networks in an account. +func (r *NetworkVirtualNetworkService) List(ctx context.Context, params NetworkVirtualNetworkListParams, opts ...option.RequestOption) (res *[]TunnelVirtualNetwork, err error) { + opts = append(r.Options[:], opts...) + var env NetworkVirtualNetworkListResponseEnvelope + path := fmt.Sprintf("accounts/%s/teamnet/virtual_networks", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Deletes an existing virtual network. +func (r *NetworkVirtualNetworkService) Delete(ctx context.Context, virtualNetworkID string, body NetworkVirtualNetworkDeleteParams, opts ...option.RequestOption) (res *NetworkVirtualNetworkDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env NetworkVirtualNetworkDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/teamnet/virtual_networks/%s", body.AccountID, virtualNetworkID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates an existing virtual network. +func (r *NetworkVirtualNetworkService) Edit(ctx context.Context, virtualNetworkID string, params NetworkVirtualNetworkEditParams, opts ...option.RequestOption) (res *NetworkVirtualNetworkEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env NetworkVirtualNetworkEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/teamnet/virtual_networks/%s", params.AccountID, virtualNetworkID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TunnelVirtualNetwork struct { + // UUID of the virtual network. + ID string `json:"id,required"` + // Optional remark describing the virtual network. + Comment string `json:"comment,required"` + // Timestamp of when the virtual network was created. + CreatedAt interface{} `json:"created_at,required"` + // If `true`, this virtual network is the default for the account. + IsDefaultNetwork bool `json:"is_default_network,required"` + // A user-friendly name for the virtual network. + Name string `json:"name,required"` + // Timestamp of when the virtual network was deleted. If `null`, the virtual + // network has not been deleted. + DeletedAt interface{} `json:"deleted_at"` + JSON tunnelVirtualNetworkJSON `json:"-"` +} + +// tunnelVirtualNetworkJSON contains the JSON metadata for the struct +// [TunnelVirtualNetwork] +type tunnelVirtualNetworkJSON struct { + ID apijson.Field + Comment apijson.Field + CreatedAt apijson.Field + IsDefaultNetwork apijson.Field + Name apijson.Field + DeletedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelVirtualNetwork) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelVirtualNetworkJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [zero_trust.NetworkVirtualNetworkNewResponseUnknown], +// [zero_trust.NetworkVirtualNetworkNewResponseArray] or [shared.UnionString]. +type NetworkVirtualNetworkNewResponse interface { + ImplementsZeroTrustNetworkVirtualNetworkNewResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*NetworkVirtualNetworkNewResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(NetworkVirtualNetworkNewResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type NetworkVirtualNetworkNewResponseArray []interface{} + +func (r NetworkVirtualNetworkNewResponseArray) ImplementsZeroTrustNetworkVirtualNetworkNewResponse() { +} + +// Union satisfied by [zero_trust.NetworkVirtualNetworkDeleteResponseUnknown], +// [zero_trust.NetworkVirtualNetworkDeleteResponseArray] or [shared.UnionString]. +type NetworkVirtualNetworkDeleteResponse interface { + ImplementsZeroTrustNetworkVirtualNetworkDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*NetworkVirtualNetworkDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(NetworkVirtualNetworkDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type NetworkVirtualNetworkDeleteResponseArray []interface{} + +func (r NetworkVirtualNetworkDeleteResponseArray) ImplementsZeroTrustNetworkVirtualNetworkDeleteResponse() { +} + +// Union satisfied by [zero_trust.NetworkVirtualNetworkEditResponseUnknown], +// [zero_trust.NetworkVirtualNetworkEditResponseArray] or [shared.UnionString]. +type NetworkVirtualNetworkEditResponse interface { + ImplementsZeroTrustNetworkVirtualNetworkEditResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*NetworkVirtualNetworkEditResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(NetworkVirtualNetworkEditResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type NetworkVirtualNetworkEditResponseArray []interface{} + +func (r NetworkVirtualNetworkEditResponseArray) ImplementsZeroTrustNetworkVirtualNetworkEditResponse() { +} + +type NetworkVirtualNetworkNewParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` + // A user-friendly name for the virtual network. + Name param.Field[string] `json:"name,required"` + // Optional remark describing the virtual network. + Comment param.Field[string] `json:"comment"` + // If `true`, this virtual network is the default for the account. + IsDefault param.Field[bool] `json:"is_default"` +} + +func (r NetworkVirtualNetworkNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type NetworkVirtualNetworkNewResponseEnvelope struct { + Errors []NetworkVirtualNetworkNewResponseEnvelopeErrors `json:"errors,required"` + Messages []NetworkVirtualNetworkNewResponseEnvelopeMessages `json:"messages,required"` + Result NetworkVirtualNetworkNewResponse `json:"result,required"` + // Whether the API call was successful + Success NetworkVirtualNetworkNewResponseEnvelopeSuccess `json:"success,required"` + JSON networkVirtualNetworkNewResponseEnvelopeJSON `json:"-"` +} + +// networkVirtualNetworkNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [NetworkVirtualNetworkNewResponseEnvelope] +type networkVirtualNetworkNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkVirtualNetworkNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkVirtualNetworkNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NetworkVirtualNetworkNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkVirtualNetworkNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// networkVirtualNetworkNewResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [NetworkVirtualNetworkNewResponseEnvelopeErrors] +type networkVirtualNetworkNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkVirtualNetworkNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkVirtualNetworkNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NetworkVirtualNetworkNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkVirtualNetworkNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// networkVirtualNetworkNewResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [NetworkVirtualNetworkNewResponseEnvelopeMessages] +type networkVirtualNetworkNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkVirtualNetworkNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkVirtualNetworkNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NetworkVirtualNetworkNewResponseEnvelopeSuccess bool + +const ( + NetworkVirtualNetworkNewResponseEnvelopeSuccessTrue NetworkVirtualNetworkNewResponseEnvelopeSuccess = true +) + +type NetworkVirtualNetworkListParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` + // If `true`, only include the default virtual network. If `false`, exclude the + // default virtual network. If empty, all virtual networks will be included. + IsDefault param.Field[interface{}] `query:"is_default"` + // If `true`, only include deleted virtual networks. If `false`, exclude deleted + // virtual networks. If empty, all virtual networks will be included. + IsDeleted param.Field[interface{}] `query:"is_deleted"` + // A user-friendly name for the virtual network. + Name param.Field[string] `query:"name"` + // A user-friendly name for the virtual network. + VnetName param.Field[string] `query:"vnet_name"` +} + +// URLQuery serializes [NetworkVirtualNetworkListParams]'s query parameters as +// `url.Values`. +func (r NetworkVirtualNetworkListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type NetworkVirtualNetworkListResponseEnvelope struct { + Errors []NetworkVirtualNetworkListResponseEnvelopeErrors `json:"errors,required"` + Messages []NetworkVirtualNetworkListResponseEnvelopeMessages `json:"messages,required"` + Result []TunnelVirtualNetwork `json:"result,required,nullable"` + // Whether the API call was successful + Success NetworkVirtualNetworkListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo NetworkVirtualNetworkListResponseEnvelopeResultInfo `json:"result_info"` + JSON networkVirtualNetworkListResponseEnvelopeJSON `json:"-"` +} + +// networkVirtualNetworkListResponseEnvelopeJSON contains the JSON metadata for the +// struct [NetworkVirtualNetworkListResponseEnvelope] +type networkVirtualNetworkListResponseEnvelopeJSON 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 *NetworkVirtualNetworkListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkVirtualNetworkListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NetworkVirtualNetworkListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkVirtualNetworkListResponseEnvelopeErrorsJSON `json:"-"` +} + +// networkVirtualNetworkListResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [NetworkVirtualNetworkListResponseEnvelopeErrors] +type networkVirtualNetworkListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkVirtualNetworkListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkVirtualNetworkListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NetworkVirtualNetworkListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkVirtualNetworkListResponseEnvelopeMessagesJSON `json:"-"` +} + +// networkVirtualNetworkListResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [NetworkVirtualNetworkListResponseEnvelopeMessages] +type networkVirtualNetworkListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkVirtualNetworkListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkVirtualNetworkListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NetworkVirtualNetworkListResponseEnvelopeSuccess bool + +const ( + NetworkVirtualNetworkListResponseEnvelopeSuccessTrue NetworkVirtualNetworkListResponseEnvelopeSuccess = true +) + +type NetworkVirtualNetworkListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON networkVirtualNetworkListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// networkVirtualNetworkListResponseEnvelopeResultInfoJSON contains the JSON +// metadata for the struct [NetworkVirtualNetworkListResponseEnvelopeResultInfo] +type networkVirtualNetworkListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkVirtualNetworkListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkVirtualNetworkListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type NetworkVirtualNetworkDeleteParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` +} + +type NetworkVirtualNetworkDeleteResponseEnvelope struct { + Errors []NetworkVirtualNetworkDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []NetworkVirtualNetworkDeleteResponseEnvelopeMessages `json:"messages,required"` + Result NetworkVirtualNetworkDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success NetworkVirtualNetworkDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON networkVirtualNetworkDeleteResponseEnvelopeJSON `json:"-"` +} + +// networkVirtualNetworkDeleteResponseEnvelopeJSON contains the JSON metadata for +// the struct [NetworkVirtualNetworkDeleteResponseEnvelope] +type networkVirtualNetworkDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkVirtualNetworkDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkVirtualNetworkDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NetworkVirtualNetworkDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkVirtualNetworkDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// networkVirtualNetworkDeleteResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [NetworkVirtualNetworkDeleteResponseEnvelopeErrors] +type networkVirtualNetworkDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkVirtualNetworkDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkVirtualNetworkDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NetworkVirtualNetworkDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkVirtualNetworkDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// networkVirtualNetworkDeleteResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [NetworkVirtualNetworkDeleteResponseEnvelopeMessages] +type networkVirtualNetworkDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkVirtualNetworkDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkVirtualNetworkDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NetworkVirtualNetworkDeleteResponseEnvelopeSuccess bool + +const ( + NetworkVirtualNetworkDeleteResponseEnvelopeSuccessTrue NetworkVirtualNetworkDeleteResponseEnvelopeSuccess = true +) + +type NetworkVirtualNetworkEditParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` + // Optional remark describing the virtual network. + Comment param.Field[string] `json:"comment"` + // If `true`, this virtual network is the default for the account. + IsDefaultNetwork param.Field[bool] `json:"is_default_network"` + // A user-friendly name for the virtual network. + Name param.Field[string] `json:"name"` +} + +func (r NetworkVirtualNetworkEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type NetworkVirtualNetworkEditResponseEnvelope struct { + Errors []NetworkVirtualNetworkEditResponseEnvelopeErrors `json:"errors,required"` + Messages []NetworkVirtualNetworkEditResponseEnvelopeMessages `json:"messages,required"` + Result NetworkVirtualNetworkEditResponse `json:"result,required"` + // Whether the API call was successful + Success NetworkVirtualNetworkEditResponseEnvelopeSuccess `json:"success,required"` + JSON networkVirtualNetworkEditResponseEnvelopeJSON `json:"-"` +} + +// networkVirtualNetworkEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [NetworkVirtualNetworkEditResponseEnvelope] +type networkVirtualNetworkEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkVirtualNetworkEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkVirtualNetworkEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type NetworkVirtualNetworkEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkVirtualNetworkEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// networkVirtualNetworkEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [NetworkVirtualNetworkEditResponseEnvelopeErrors] +type networkVirtualNetworkEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkVirtualNetworkEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkVirtualNetworkEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type NetworkVirtualNetworkEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON networkVirtualNetworkEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// networkVirtualNetworkEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [NetworkVirtualNetworkEditResponseEnvelopeMessages] +type networkVirtualNetworkEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NetworkVirtualNetworkEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r networkVirtualNetworkEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type NetworkVirtualNetworkEditResponseEnvelopeSuccess bool + +const ( + NetworkVirtualNetworkEditResponseEnvelopeSuccessTrue NetworkVirtualNetworkEditResponseEnvelopeSuccess = true +) diff --git a/zero_trust/networkvirtualnetwork_test.go b/zero_trust/networkvirtualnetwork_test.go new file mode 100644 index 00000000000..104afd8156e --- /dev/null +++ b/zero_trust/networkvirtualnetwork_test.go @@ -0,0 +1,137 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestNetworkVirtualNetworkNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Networks.VirtualNetworks.New(context.TODO(), zero_trust.NetworkVirtualNetworkNewParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Name: cloudflare.F("us-east-1-vpc"), + Comment: cloudflare.F("Staging VPC for data science"), + IsDefault: cloudflare.F(true), + }) + 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 TestNetworkVirtualNetworkListWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Networks.VirtualNetworks.List(context.TODO(), zero_trust.NetworkVirtualNetworkListParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + IsDefault: cloudflare.F[any](map[string]interface{}{}), + IsDeleted: cloudflare.F[any](map[string]interface{}{}), + Name: cloudflare.F("us-east-1-vpc"), + VnetName: cloudflare.F("us-east-1-vpc"), + }) + 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 TestNetworkVirtualNetworkDelete(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("user@example.com"), + ) + _, err := client.ZeroTrust.Networks.VirtualNetworks.Delete( + context.TODO(), + "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + zero_trust.NetworkVirtualNetworkDeleteParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + }, + ) + 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 TestNetworkVirtualNetworkEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Networks.VirtualNetworks.Edit( + context.TODO(), + "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + zero_trust.NetworkVirtualNetworkEditParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Comment: cloudflare.F("Staging VPC for data science"), + IsDefaultNetwork: cloudflare.F(true), + Name: cloudflare.F("us-east-1-vpc"), + }, + ) + 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/zero_trust/organization.go b/zero_trust/organization.go new file mode 100644 index 00000000000..c26db3f58ed --- /dev/null +++ b/zero_trust/organization.go @@ -0,0 +1,669 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// OrganizationService 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 [NewOrganizationService] method +// instead. +type OrganizationService struct { + Options []option.RequestOption +} + +// NewOrganizationService 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 NewOrganizationService(opts ...option.RequestOption) (r *OrganizationService) { + r = &OrganizationService{} + r.Options = opts + return +} + +// Sets up a Zero Trust organization for your account or zone. +func (r *OrganizationService) New(ctx context.Context, params OrganizationNewParams, opts ...option.RequestOption) (res *AccessOrganizations, err error) { + opts = append(r.Options[:], opts...) + var env OrganizationNewResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/access/organizations", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates the configuration for your Zero Trust organization. +func (r *OrganizationService) Update(ctx context.Context, params OrganizationUpdateParams, opts ...option.RequestOption) (res *AccessOrganizations, err error) { + opts = append(r.Options[:], opts...) + var env OrganizationUpdateResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/access/organizations", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Returns the configuration for your Zero Trust organization. +func (r *OrganizationService) List(ctx context.Context, query OrganizationListParams, opts ...option.RequestOption) (res *AccessOrganizations, err error) { + opts = append(r.Options[:], opts...) + var env OrganizationListResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if query.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = query.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = query.ZoneID + } + path := fmt.Sprintf("%s/%s/access/organizations", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Revokes a user's access across all applications. +func (r *OrganizationService) RevokeUsers(ctx context.Context, params OrganizationRevokeUsersParams, opts ...option.RequestOption) (res *OrganizationRevokeUsersResponse, err error) { + opts = append(r.Options[:], opts...) + var env OrganizationRevokeUsersResponseEnvelope + var accountOrZone string + var accountOrZoneID param.Field[string] + if params.AccountID.Present { + accountOrZone = "accounts" + accountOrZoneID = params.AccountID + } else { + accountOrZone = "zones" + accountOrZoneID = params.ZoneID + } + path := fmt.Sprintf("%s/%s/access/organizations/revoke_user", accountOrZone, accountOrZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AccessOrganizations struct { + // When set to true, users can authenticate via WARP for any application in your + // organization. Application settings will take precedence over this value. + AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` + // The unique subdomain assigned to your Zero Trust organization. + AuthDomain string `json:"auth_domain"` + // When set to `true`, users skip the identity provider selection step during + // login. + AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + CustomPages AccessOrganizationsCustomPages `json:"custom_pages"` + // Lock all settings as Read-Only in the Dashboard, regardless of user permission. + // Updates may only be made via the API or Terraform for this account when enabled. + IsUiReadOnly bool `json:"is_ui_read_only"` + LoginDesign AccessOrganizationsLoginDesign `json:"login_design"` + // The name of your Zero Trust organization. + Name string `json:"name"` + // The amount of time that tokens issued for applications will be valid. Must be in + // the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, + // h. + SessionDuration string `json:"session_duration"` + // A description of the reason why the UI read only field is being toggled. + UiReadOnlyToggleReason string `json:"ui_read_only_toggle_reason"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + // The amount of time a user seat is inactive before it expires. When the user seat + // exceeds the set time of inactivity, the user is removed as an active seat and no + // longer counts against your Teams seat count. Must be in the format `300ms` or + // `2h45m`. Valid time units are: `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. + UserSeatExpirationInactiveTime string `json:"user_seat_expiration_inactive_time"` + // The amount of time that tokens issued for applications will be valid. Must be in + // the format `30m` or `2h45m`. Valid time units are: m, h. + WARPAuthSessionDuration string `json:"warp_auth_session_duration"` + JSON accessOrganizationsJSON `json:"-"` +} + +// accessOrganizationsJSON contains the JSON metadata for the struct +// [AccessOrganizations] +type accessOrganizationsJSON struct { + AllowAuthenticateViaWARP apijson.Field + AuthDomain apijson.Field + AutoRedirectToIdentity apijson.Field + CreatedAt apijson.Field + CustomPages apijson.Field + IsUiReadOnly apijson.Field + LoginDesign apijson.Field + Name apijson.Field + SessionDuration apijson.Field + UiReadOnlyToggleReason apijson.Field + UpdatedAt apijson.Field + UserSeatExpirationInactiveTime apijson.Field + WARPAuthSessionDuration apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessOrganizations) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessOrganizationsJSON) RawJSON() string { + return r.raw +} + +type AccessOrganizationsCustomPages struct { + // The uid of the custom page to use when a user is denied access after failing a + // non-identity rule. + Forbidden string `json:"forbidden"` + // The uid of the custom page to use when a user is denied access. + IdentityDenied string `json:"identity_denied"` + JSON accessOrganizationsCustomPagesJSON `json:"-"` +} + +// accessOrganizationsCustomPagesJSON contains the JSON metadata for the struct +// [AccessOrganizationsCustomPages] +type accessOrganizationsCustomPagesJSON struct { + Forbidden apijson.Field + IdentityDenied apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessOrganizationsCustomPages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessOrganizationsCustomPagesJSON) RawJSON() string { + return r.raw +} + +type AccessOrganizationsLoginDesign struct { + // The background color on your login page. + BackgroundColor string `json:"background_color"` + // The text at the bottom of your login page. + FooterText string `json:"footer_text"` + // The text at the top of your login page. + HeaderText string `json:"header_text"` + // The URL of the logo on your login page. + LogoPath string `json:"logo_path"` + // The text color on your login page. + TextColor string `json:"text_color"` + JSON accessOrganizationsLoginDesignJSON `json:"-"` +} + +// accessOrganizationsLoginDesignJSON contains the JSON metadata for the struct +// [AccessOrganizationsLoginDesign] +type accessOrganizationsLoginDesignJSON struct { + BackgroundColor apijson.Field + FooterText apijson.Field + HeaderText apijson.Field + LogoPath apijson.Field + TextColor apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessOrganizationsLoginDesign) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessOrganizationsLoginDesignJSON) RawJSON() string { + return r.raw +} + +type OrganizationRevokeUsersResponse bool + +const ( + OrganizationRevokeUsersResponseTrue OrganizationRevokeUsersResponse = true + OrganizationRevokeUsersResponseFalse OrganizationRevokeUsersResponse = false +) + +type OrganizationNewParams struct { + // The unique subdomain assigned to your Zero Trust organization. + AuthDomain param.Field[string] `json:"auth_domain,required"` + // The name of your Zero Trust organization. + Name param.Field[string] `json:"name,required"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // When set to true, users can authenticate via WARP for any application in your + // organization. Application settings will take precedence over this value. + AllowAuthenticateViaWARP param.Field[bool] `json:"allow_authenticate_via_warp"` + // When set to `true`, users skip the identity provider selection step during + // login. + AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` + // Lock all settings as Read-Only in the Dashboard, regardless of user permission. + // Updates may only be made via the API or Terraform for this account when enabled. + IsUiReadOnly param.Field[bool] `json:"is_ui_read_only"` + LoginDesign param.Field[OrganizationNewParamsLoginDesign] `json:"login_design"` + // The amount of time that tokens issued for applications will be valid. Must be in + // the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, + // h. + SessionDuration param.Field[string] `json:"session_duration"` + // A description of the reason why the UI read only field is being toggled. + UiReadOnlyToggleReason param.Field[string] `json:"ui_read_only_toggle_reason"` + // The amount of time a user seat is inactive before it expires. When the user seat + // exceeds the set time of inactivity, the user is removed as an active seat and no + // longer counts against your Teams seat count. Must be in the format `300ms` or + // `2h45m`. Valid time units are: `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. + UserSeatExpirationInactiveTime param.Field[string] `json:"user_seat_expiration_inactive_time"` + // The amount of time that tokens issued for applications will be valid. Must be in + // the format `30m` or `2h45m`. Valid time units are: m, h. + WARPAuthSessionDuration param.Field[string] `json:"warp_auth_session_duration"` +} + +func (r OrganizationNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type OrganizationNewParamsLoginDesign struct { + // The background color on your login page. + BackgroundColor param.Field[string] `json:"background_color"` + // The text at the bottom of your login page. + FooterText param.Field[string] `json:"footer_text"` + // The text at the top of your login page. + HeaderText param.Field[string] `json:"header_text"` + // The URL of the logo on your login page. + LogoPath param.Field[string] `json:"logo_path"` + // The text color on your login page. + TextColor param.Field[string] `json:"text_color"` +} + +func (r OrganizationNewParamsLoginDesign) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type OrganizationNewResponseEnvelope struct { + Errors []OrganizationNewResponseEnvelopeErrors `json:"errors,required"` + Messages []OrganizationNewResponseEnvelopeMessages `json:"messages,required"` + Result AccessOrganizations `json:"result,required"` + // Whether the API call was successful + Success OrganizationNewResponseEnvelopeSuccess `json:"success,required"` + JSON organizationNewResponseEnvelopeJSON `json:"-"` +} + +// organizationNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [OrganizationNewResponseEnvelope] +type organizationNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OrganizationNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r organizationNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type OrganizationNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON organizationNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// organizationNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [OrganizationNewResponseEnvelopeErrors] +type organizationNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OrganizationNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r organizationNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type OrganizationNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON organizationNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// organizationNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [OrganizationNewResponseEnvelopeMessages] +type organizationNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OrganizationNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r organizationNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type OrganizationNewResponseEnvelopeSuccess bool + +const ( + OrganizationNewResponseEnvelopeSuccessTrue OrganizationNewResponseEnvelopeSuccess = true +) + +type OrganizationUpdateParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` + // When set to true, users can authenticate via WARP for any application in your + // organization. Application settings will take precedence over this value. + AllowAuthenticateViaWARP param.Field[bool] `json:"allow_authenticate_via_warp"` + // The unique subdomain assigned to your Zero Trust organization. + AuthDomain param.Field[string] `json:"auth_domain"` + // When set to `true`, users skip the identity provider selection step during + // login. + AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` + CustomPages param.Field[OrganizationUpdateParamsCustomPages] `json:"custom_pages"` + // Lock all settings as Read-Only in the Dashboard, regardless of user permission. + // Updates may only be made via the API or Terraform for this account when enabled. + IsUiReadOnly param.Field[bool] `json:"is_ui_read_only"` + LoginDesign param.Field[OrganizationUpdateParamsLoginDesign] `json:"login_design"` + // The name of your Zero Trust organization. + Name param.Field[string] `json:"name"` + // The amount of time that tokens issued for applications will be valid. Must be in + // the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, + // h. + SessionDuration param.Field[string] `json:"session_duration"` + // A description of the reason why the UI read only field is being toggled. + UiReadOnlyToggleReason param.Field[string] `json:"ui_read_only_toggle_reason"` + // The amount of time a user seat is inactive before it expires. When the user seat + // exceeds the set time of inactivity, the user is removed as an active seat and no + // longer counts against your Teams seat count. Must be in the format `300ms` or + // `2h45m`. Valid time units are: `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. + UserSeatExpirationInactiveTime param.Field[string] `json:"user_seat_expiration_inactive_time"` + // The amount of time that tokens issued for applications will be valid. Must be in + // the format `30m` or `2h45m`. Valid time units are: m, h. + WARPAuthSessionDuration param.Field[string] `json:"warp_auth_session_duration"` +} + +func (r OrganizationUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type OrganizationUpdateParamsCustomPages struct { + // The uid of the custom page to use when a user is denied access after failing a + // non-identity rule. + Forbidden param.Field[string] `json:"forbidden"` + // The uid of the custom page to use when a user is denied access. + IdentityDenied param.Field[string] `json:"identity_denied"` +} + +func (r OrganizationUpdateParamsCustomPages) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type OrganizationUpdateParamsLoginDesign struct { + // The background color on your login page. + BackgroundColor param.Field[string] `json:"background_color"` + // The text at the bottom of your login page. + FooterText param.Field[string] `json:"footer_text"` + // The text at the top of your login page. + HeaderText param.Field[string] `json:"header_text"` + // The URL of the logo on your login page. + LogoPath param.Field[string] `json:"logo_path"` + // The text color on your login page. + TextColor param.Field[string] `json:"text_color"` +} + +func (r OrganizationUpdateParamsLoginDesign) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type OrganizationUpdateResponseEnvelope struct { + Errors []OrganizationUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []OrganizationUpdateResponseEnvelopeMessages `json:"messages,required"` + Result AccessOrganizations `json:"result,required"` + // Whether the API call was successful + Success OrganizationUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON organizationUpdateResponseEnvelopeJSON `json:"-"` +} + +// organizationUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [OrganizationUpdateResponseEnvelope] +type organizationUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OrganizationUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r organizationUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type OrganizationUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON organizationUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// organizationUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [OrganizationUpdateResponseEnvelopeErrors] +type organizationUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OrganizationUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r organizationUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type OrganizationUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON organizationUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// organizationUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [OrganizationUpdateResponseEnvelopeMessages] +type organizationUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OrganizationUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r organizationUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type OrganizationUpdateResponseEnvelopeSuccess bool + +const ( + OrganizationUpdateResponseEnvelopeSuccessTrue OrganizationUpdateResponseEnvelopeSuccess = true +) + +type OrganizationListParams struct { + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +type OrganizationListResponseEnvelope struct { + Errors []OrganizationListResponseEnvelopeErrors `json:"errors,required"` + Messages []OrganizationListResponseEnvelopeMessages `json:"messages,required"` + Result AccessOrganizations `json:"result,required"` + // Whether the API call was successful + Success OrganizationListResponseEnvelopeSuccess `json:"success,required"` + JSON organizationListResponseEnvelopeJSON `json:"-"` +} + +// organizationListResponseEnvelopeJSON contains the JSON metadata for the struct +// [OrganizationListResponseEnvelope] +type organizationListResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OrganizationListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r organizationListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type OrganizationListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON organizationListResponseEnvelopeErrorsJSON `json:"-"` +} + +// organizationListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [OrganizationListResponseEnvelopeErrors] +type organizationListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OrganizationListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r organizationListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type OrganizationListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON organizationListResponseEnvelopeMessagesJSON `json:"-"` +} + +// organizationListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [OrganizationListResponseEnvelopeMessages] +type organizationListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OrganizationListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r organizationListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type OrganizationListResponseEnvelopeSuccess bool + +const ( + OrganizationListResponseEnvelopeSuccessTrue OrganizationListResponseEnvelopeSuccess = true +) + +type OrganizationRevokeUsersParams struct { + // The email of the user to revoke. + Email param.Field[string] `json:"email,required"` + // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. + AccountID param.Field[string] `path:"account_id"` + // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. + ZoneID param.Field[string] `path:"zone_id"` +} + +func (r OrganizationRevokeUsersParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type OrganizationRevokeUsersResponseEnvelope struct { + Result OrganizationRevokeUsersResponse `json:"result"` + Success OrganizationRevokeUsersResponseEnvelopeSuccess `json:"success"` + JSON organizationRevokeUsersResponseEnvelopeJSON `json:"-"` +} + +// organizationRevokeUsersResponseEnvelopeJSON contains the JSON metadata for the +// struct [OrganizationRevokeUsersResponseEnvelope] +type organizationRevokeUsersResponseEnvelopeJSON struct { + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OrganizationRevokeUsersResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r organizationRevokeUsersResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type OrganizationRevokeUsersResponseEnvelopeSuccess bool + +const ( + OrganizationRevokeUsersResponseEnvelopeSuccessTrue OrganizationRevokeUsersResponseEnvelopeSuccess = true + OrganizationRevokeUsersResponseEnvelopeSuccessFalse OrganizationRevokeUsersResponseEnvelopeSuccess = false +) diff --git a/zero_trust/organization_test.go b/zero_trust/organization_test.go new file mode 100644 index 00000000000..166ce007da2 --- /dev/null +++ b/zero_trust/organization_test.go @@ -0,0 +1,160 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestOrganizationNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Organizations.New(context.TODO(), zero_trust.OrganizationNewParams{ + AuthDomain: cloudflare.F("test.cloudflareaccess.com"), + Name: cloudflare.F("Widget Corps Internal Applications"), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + AllowAuthenticateViaWARP: cloudflare.F(true), + AutoRedirectToIdentity: cloudflare.F(true), + IsUiReadOnly: cloudflare.F(true), + LoginDesign: cloudflare.F(zero_trust.OrganizationNewParamsLoginDesign{ + BackgroundColor: cloudflare.F("#c5ed1b"), + FooterText: cloudflare.F("This is an example description."), + HeaderText: cloudflare.F("This is an example description."), + LogoPath: cloudflare.F("https://example.com/logo.png"), + TextColor: cloudflare.F("#c5ed1b"), + }), + SessionDuration: cloudflare.F("24h"), + UiReadOnlyToggleReason: cloudflare.F("Temporarily turn off the UI read only lock to make a change via the UI"), + UserSeatExpirationInactiveTime: cloudflare.F("720h"), + WARPAuthSessionDuration: cloudflare.F("24h"), + }) + 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 TestOrganizationUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Organizations.Update(context.TODO(), zero_trust.OrganizationUpdateParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + AllowAuthenticateViaWARP: cloudflare.F(true), + AuthDomain: cloudflare.F("test.cloudflareaccess.com"), + AutoRedirectToIdentity: cloudflare.F(true), + CustomPages: cloudflare.F(zero_trust.OrganizationUpdateParamsCustomPages{ + Forbidden: cloudflare.F("699d98642c564d2e855e9661899b7252"), + IdentityDenied: cloudflare.F("699d98642c564d2e855e9661899b7252"), + }), + IsUiReadOnly: cloudflare.F(true), + LoginDesign: cloudflare.F(zero_trust.OrganizationUpdateParamsLoginDesign{ + BackgroundColor: cloudflare.F("#c5ed1b"), + FooterText: cloudflare.F("This is an example description."), + HeaderText: cloudflare.F("This is an example description."), + LogoPath: cloudflare.F("https://example.com/logo.png"), + TextColor: cloudflare.F("#c5ed1b"), + }), + Name: cloudflare.F("Widget Corps Internal Applications"), + SessionDuration: cloudflare.F("24h"), + UiReadOnlyToggleReason: cloudflare.F("Temporarily turn off the UI read only lock to make a change via the UI"), + UserSeatExpirationInactiveTime: cloudflare.F("720h"), + WARPAuthSessionDuration: cloudflare.F("24h"), + }) + 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 TestOrganizationListWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Organizations.List(context.TODO(), zero_trust.OrganizationListParams{ + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }) + 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 TestOrganizationRevokeUsersWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Organizations.RevokeUsers(context.TODO(), zero_trust.OrganizationRevokeUsersParams{ + Email: cloudflare.F("test@example.com"), + AccountID: cloudflare.F("string"), + ZoneID: cloudflare.F("string"), + }) + 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/zero_trust/seat.go b/zero_trust/seat.go new file mode 100644 index 00000000000..cefd0c943ad --- /dev/null +++ b/zero_trust/seat.go @@ -0,0 +1,210 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SeatService 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 [NewSeatService] method instead. +type SeatService struct { + Options []option.RequestOption +} + +// NewSeatService 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 NewSeatService(opts ...option.RequestOption) (r *SeatService) { + r = &SeatService{} + r.Options = opts + return +} + +// Removes a user from a Zero Trust seat when both `access_seat` and `gateway_seat` +// are set to false. +func (r *SeatService) Edit(ctx context.Context, identifier string, body SeatEditParams, opts ...option.RequestOption) (res *[]AccessSeats, err error) { + opts = append(r.Options[:], opts...) + var env SeatEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/access/seats", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type AccessSeats struct { + // True if the seat is part of Access. + AccessSeat bool `json:"access_seat"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + // True if the seat is part of Gateway. + GatewaySeat bool `json:"gateway_seat"` + // Identifier + SeatUid string `json:"seat_uid"` + UpdatedAt time.Time `json:"updated_at" format:"date-time"` + JSON accessSeatsJSON `json:"-"` +} + +// accessSeatsJSON contains the JSON metadata for the struct [AccessSeats] +type accessSeatsJSON struct { + AccessSeat apijson.Field + CreatedAt apijson.Field + GatewaySeat apijson.Field + SeatUid apijson.Field + UpdatedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessSeats) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessSeatsJSON) RawJSON() string { + return r.raw +} + +type SeatEditParams struct { + Body param.Field[[]SeatEditParamsBody] `json:"body,required"` +} + +func (r SeatEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type SeatEditParamsBody struct { + // True if the seat is part of Access. + AccessSeat param.Field[bool] `json:"access_seat,required"` + // True if the seat is part of Gateway. + GatewaySeat param.Field[bool] `json:"gateway_seat,required"` +} + +func (r SeatEditParamsBody) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SeatEditResponseEnvelope struct { + Errors []SeatEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SeatEditResponseEnvelopeMessages `json:"messages,required"` + Result []AccessSeats `json:"result,required,nullable"` + // Whether the API call was successful + Success SeatEditResponseEnvelopeSuccess `json:"success,required"` + ResultInfo SeatEditResponseEnvelopeResultInfo `json:"result_info"` + JSON seatEditResponseEnvelopeJSON `json:"-"` +} + +// seatEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SeatEditResponseEnvelope] +type seatEditResponseEnvelopeJSON 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 *SeatEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r seatEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SeatEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON seatEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// seatEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [SeatEditResponseEnvelopeErrors] +type seatEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SeatEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r seatEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SeatEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON seatEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// seatEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [SeatEditResponseEnvelopeMessages] +type seatEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SeatEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r seatEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SeatEditResponseEnvelopeSuccess bool + +const ( + SeatEditResponseEnvelopeSuccessTrue SeatEditResponseEnvelopeSuccess = true +) + +type SeatEditResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON seatEditResponseEnvelopeResultInfoJSON `json:"-"` +} + +// seatEditResponseEnvelopeResultInfoJSON contains the JSON metadata for the struct +// [SeatEditResponseEnvelopeResultInfo] +type seatEditResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SeatEditResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r seatEditResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/seat_test.go b/zero_trust/seat_test.go new file mode 100644 index 00000000000..81620575962 --- /dev/null +++ b/zero_trust/seat_test.go @@ -0,0 +1,54 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestSeatEdit(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("user@example.com"), + ) + _, err := client.ZeroTrust.Seats.Edit( + context.TODO(), + "023e105f4ecef8ad9ca31a8372d0c353", + zero_trust.SeatEditParams{ + Body: cloudflare.F([]zero_trust.SeatEditParamsBody{{ + AccessSeat: cloudflare.F(false), + GatewaySeat: cloudflare.F(false), + }, { + AccessSeat: cloudflare.F(false), + GatewaySeat: cloudflare.F(false), + }, { + AccessSeat: cloudflare.F(false), + GatewaySeat: cloudflare.F(false), + }}), + }, + ) + 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/zero_trust/tunnel.go b/zero_trust/tunnel.go new file mode 100644 index 00000000000..1d8f747152f --- /dev/null +++ b/zero_trust/tunnel.go @@ -0,0 +1,1113 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "net/url" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// TunnelService 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 [NewTunnelService] method instead. +type TunnelService struct { + Options []option.RequestOption + Configurations *TunnelConfigurationService + Connections *TunnelConnectionService + Token *TunnelTokenService + Connectors *TunnelConnectorService + Management *TunnelManagementService +} + +// NewTunnelService 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 NewTunnelService(opts ...option.RequestOption) (r *TunnelService) { + r = &TunnelService{} + r.Options = opts + r.Configurations = NewTunnelConfigurationService(opts...) + r.Connections = NewTunnelConnectionService(opts...) + r.Token = NewTunnelTokenService(opts...) + r.Connectors = NewTunnelConnectorService(opts...) + r.Management = NewTunnelManagementService(opts...) + return +} + +// Creates a new Argo Tunnel in an account. +func (r *TunnelService) New(ctx context.Context, params TunnelNewParams, opts ...option.RequestOption) (res *TunnelArgoTunnel, err error) { + opts = append(r.Options[:], opts...) + var env TunnelNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/tunnels", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists and filters all types of Tunnels in an account. +func (r *TunnelService) List(ctx context.Context, params TunnelListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[TunnelListResponse], err error) { + var raw *http.Response + opts = append(r.Options, opts...) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + path := fmt.Sprintf("accounts/%s/tunnels", params.AccountID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists and filters all types of Tunnels in an account. +func (r *TunnelService) ListAutoPaging(ctx context.Context, params TunnelListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[TunnelListResponse] { + return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) +} + +// Deletes an Argo Tunnel from an account. +func (r *TunnelService) Delete(ctx context.Context, tunnelID string, params TunnelDeleteParams, opts ...option.RequestOption) (res *TunnelArgoTunnel, err error) { + opts = append(r.Options[:], opts...) + var env TunnelDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/tunnels/%s", params.AccountID, tunnelID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Updates an existing Cloudflare Tunnel. +func (r *TunnelService) Edit(ctx context.Context, tunnelID string, params TunnelEditParams, opts ...option.RequestOption) (res *TunnelEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env TunnelEditResponseEnvelope + path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s", params.AccountID, tunnelID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches a single Argo Tunnel. +func (r *TunnelService) Get(ctx context.Context, tunnelID string, query TunnelGetParams, opts ...option.RequestOption) (res *TunnelArgoTunnel, err error) { + opts = append(r.Options[:], opts...) + var env TunnelGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/tunnels/%s", query.AccountID, tunnelID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TunnelArgoTunnel struct { + // UUID of the tunnel. + ID string `json:"id,required"` + // The tunnel connections between your origin and Cloudflare's edge. + Connections []TunnelArgoTunnelConnection `json:"connections,required"` + // Timestamp of when the tunnel was created. + CreatedAt time.Time `json:"created_at,required" format:"date-time"` + // A user-friendly name for the tunnel. + Name string `json:"name,required"` + // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been + // deleted. + DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` + JSON tunnelArgoTunnelJSON `json:"-"` +} + +// tunnelArgoTunnelJSON contains the JSON metadata for the struct +// [TunnelArgoTunnel] +type tunnelArgoTunnelJSON struct { + ID apijson.Field + Connections apijson.Field + CreatedAt apijson.Field + Name apijson.Field + DeletedAt apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelArgoTunnel) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelArgoTunnelJSON) RawJSON() string { + return r.raw +} + +type TunnelArgoTunnelConnection struct { + // The Cloudflare data center used for this connection. + ColoName string `json:"colo_name"` + // Cloudflare continues to track connections for several minutes after they + // disconnect. This is an optimization to improve latency and reliability of + // reconnecting. If `true`, the connection has disconnected but is still being + // tracked. If `false`, the connection is actively serving traffic. + IsPendingReconnect bool `json:"is_pending_reconnect"` + // UUID of the Cloudflare Tunnel connection. + UUID string `json:"uuid"` + JSON tunnelArgoTunnelConnectionJSON `json:"-"` +} + +// tunnelArgoTunnelConnectionJSON contains the JSON metadata for the struct +// [TunnelArgoTunnelConnection] +type tunnelArgoTunnelConnectionJSON struct { + ColoName apijson.Field + IsPendingReconnect apijson.Field + UUID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelArgoTunnelConnection) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelArgoTunnelConnectionJSON) RawJSON() string { + return r.raw +} + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// Union satisfied by [zero_trust.TunnelListResponseTunnelCfdTunnel] or +// [zero_trust.TunnelListResponseTunnelWARPConnectorTunnel]. +type TunnelListResponse interface { + implementsZeroTrustTunnelListResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*TunnelListResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TunnelListResponseTunnelCfdTunnel{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TunnelListResponseTunnelWARPConnectorTunnel{}), + }, + ) +} + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +type TunnelListResponseTunnelCfdTunnel struct { + // UUID of the tunnel. + ID string `json:"id"` + // Cloudflare account ID + AccountTag string `json:"account_tag"` + // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. + Connections []TunnelListResponseTunnelCfdTunnelConnection `json:"connections"` + // Timestamp of when the tunnel established at least one connection to Cloudflare's + // edge. If `null`, the tunnel is inactive. + ConnsActiveAt time.Time `json:"conns_active_at,nullable" format:"date-time"` + // Timestamp of when the tunnel became inactive (no connections to Cloudflare's + // edge). If `null`, the tunnel is active. + ConnsInactiveAt time.Time `json:"conns_inactive_at,nullable" format:"date-time"` + // Timestamp of when the tunnel was created. + CreatedAt time.Time `json:"created_at" format:"date-time"` + // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been + // deleted. + DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` + // Metadata associated with the tunnel. + Metadata interface{} `json:"metadata"` + // A user-friendly name for the tunnel. + Name string `json:"name"` + // If `true`, the tunnel can be configured remotely from the Zero Trust dashboard. + // If `false`, the tunnel must be configured locally on the origin machine. + RemoteConfig bool `json:"remote_config"` + // The status of the tunnel. Valid values are `inactive` (tunnel has never been + // run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy + // state), `healthy` (tunnel is active and able to serve traffic), or `down` + // (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). + Status string `json:"status"` + // The type of tunnel. + TunType TunnelListResponseTunnelCfdTunnelTunType `json:"tun_type"` + JSON tunnelListResponseTunnelCfdTunnelJSON `json:"-"` +} + +// tunnelListResponseTunnelCfdTunnelJSON contains the JSON metadata for the struct +// [TunnelListResponseTunnelCfdTunnel] +type tunnelListResponseTunnelCfdTunnelJSON struct { + ID apijson.Field + AccountTag apijson.Field + Connections apijson.Field + ConnsActiveAt apijson.Field + ConnsInactiveAt apijson.Field + CreatedAt apijson.Field + DeletedAt apijson.Field + Metadata apijson.Field + Name apijson.Field + RemoteConfig apijson.Field + Status apijson.Field + TunType apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelListResponseTunnelCfdTunnel) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelListResponseTunnelCfdTunnelJSON) RawJSON() string { + return r.raw +} + +func (r TunnelListResponseTunnelCfdTunnel) implementsZeroTrustTunnelListResponse() {} + +type TunnelListResponseTunnelCfdTunnelConnection struct { + // UUID of the Cloudflare Tunnel connection. + ID string `json:"id"` + // UUID of the cloudflared instance. + ClientID interface{} `json:"client_id"` + // The cloudflared version used to establish this connection. + ClientVersion string `json:"client_version"` + // The Cloudflare data center used for this connection. + ColoName string `json:"colo_name"` + // Cloudflare continues to track connections for several minutes after they + // disconnect. This is an optimization to improve latency and reliability of + // reconnecting. If `true`, the connection has disconnected but is still being + // tracked. If `false`, the connection is actively serving traffic. + IsPendingReconnect bool `json:"is_pending_reconnect"` + // Timestamp of when the connection was established. + OpenedAt time.Time `json:"opened_at" format:"date-time"` + // The public IP address of the host running cloudflared. + OriginIP string `json:"origin_ip"` + // UUID of the Cloudflare Tunnel connection. + UUID string `json:"uuid"` + JSON tunnelListResponseTunnelCfdTunnelConnectionJSON `json:"-"` +} + +// tunnelListResponseTunnelCfdTunnelConnectionJSON contains the JSON metadata for +// the struct [TunnelListResponseTunnelCfdTunnelConnection] +type tunnelListResponseTunnelCfdTunnelConnectionJSON struct { + ID apijson.Field + ClientID apijson.Field + ClientVersion apijson.Field + ColoName apijson.Field + IsPendingReconnect apijson.Field + OpenedAt apijson.Field + OriginIP apijson.Field + UUID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelListResponseTunnelCfdTunnelConnection) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelListResponseTunnelCfdTunnelConnectionJSON) RawJSON() string { + return r.raw +} + +// The type of tunnel. +type TunnelListResponseTunnelCfdTunnelTunType string + +const ( + TunnelListResponseTunnelCfdTunnelTunTypeCfdTunnel TunnelListResponseTunnelCfdTunnelTunType = "cfd_tunnel" + TunnelListResponseTunnelCfdTunnelTunTypeWARPConnector TunnelListResponseTunnelCfdTunnelTunType = "warp_connector" + TunnelListResponseTunnelCfdTunnelTunTypeIPSec TunnelListResponseTunnelCfdTunnelTunType = "ip_sec" + TunnelListResponseTunnelCfdTunnelTunTypeGRE TunnelListResponseTunnelCfdTunnelTunType = "gre" + TunnelListResponseTunnelCfdTunnelTunTypeCni TunnelListResponseTunnelCfdTunnelTunType = "cni" +) + +// A Warp Connector Tunnel that connects your origin to Cloudflare's edge. +type TunnelListResponseTunnelWARPConnectorTunnel struct { + // UUID of the tunnel. + ID string `json:"id"` + // Cloudflare account ID + AccountTag string `json:"account_tag"` + // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. + Connections []TunnelListResponseTunnelWARPConnectorTunnelConnection `json:"connections"` + // Timestamp of when the tunnel established at least one connection to Cloudflare's + // edge. If `null`, the tunnel is inactive. + ConnsActiveAt time.Time `json:"conns_active_at,nullable" format:"date-time"` + // Timestamp of when the tunnel became inactive (no connections to Cloudflare's + // edge). If `null`, the tunnel is active. + ConnsInactiveAt time.Time `json:"conns_inactive_at,nullable" format:"date-time"` + // Timestamp of when the tunnel was created. + CreatedAt time.Time `json:"created_at" format:"date-time"` + // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been + // deleted. + DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` + // Metadata associated with the tunnel. + Metadata interface{} `json:"metadata"` + // A user-friendly name for the tunnel. + Name string `json:"name"` + // The status of the tunnel. Valid values are `inactive` (tunnel has never been + // run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy + // state), `healthy` (tunnel is active and able to serve traffic), or `down` + // (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). + Status string `json:"status"` + // The type of tunnel. + TunType TunnelListResponseTunnelWARPConnectorTunnelTunType `json:"tun_type"` + JSON tunnelListResponseTunnelWARPConnectorTunnelJSON `json:"-"` +} + +// tunnelListResponseTunnelWARPConnectorTunnelJSON contains the JSON metadata for +// the struct [TunnelListResponseTunnelWARPConnectorTunnel] +type tunnelListResponseTunnelWARPConnectorTunnelJSON struct { + ID apijson.Field + AccountTag apijson.Field + Connections apijson.Field + ConnsActiveAt apijson.Field + ConnsInactiveAt apijson.Field + CreatedAt apijson.Field + DeletedAt apijson.Field + Metadata apijson.Field + Name apijson.Field + Status apijson.Field + TunType apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelListResponseTunnelWARPConnectorTunnel) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelListResponseTunnelWARPConnectorTunnelJSON) RawJSON() string { + return r.raw +} + +func (r TunnelListResponseTunnelWARPConnectorTunnel) implementsZeroTrustTunnelListResponse() {} + +type TunnelListResponseTunnelWARPConnectorTunnelConnection struct { + // UUID of the Cloudflare Tunnel connection. + ID string `json:"id"` + // UUID of the cloudflared instance. + ClientID interface{} `json:"client_id"` + // The cloudflared version used to establish this connection. + ClientVersion string `json:"client_version"` + // The Cloudflare data center used for this connection. + ColoName string `json:"colo_name"` + // Cloudflare continues to track connections for several minutes after they + // disconnect. This is an optimization to improve latency and reliability of + // reconnecting. If `true`, the connection has disconnected but is still being + // tracked. If `false`, the connection is actively serving traffic. + IsPendingReconnect bool `json:"is_pending_reconnect"` + // Timestamp of when the connection was established. + OpenedAt time.Time `json:"opened_at" format:"date-time"` + // The public IP address of the host running cloudflared. + OriginIP string `json:"origin_ip"` + // UUID of the Cloudflare Tunnel connection. + UUID string `json:"uuid"` + JSON tunnelListResponseTunnelWARPConnectorTunnelConnectionJSON `json:"-"` +} + +// tunnelListResponseTunnelWARPConnectorTunnelConnectionJSON contains the JSON +// metadata for the struct [TunnelListResponseTunnelWARPConnectorTunnelConnection] +type tunnelListResponseTunnelWARPConnectorTunnelConnectionJSON struct { + ID apijson.Field + ClientID apijson.Field + ClientVersion apijson.Field + ColoName apijson.Field + IsPendingReconnect apijson.Field + OpenedAt apijson.Field + OriginIP apijson.Field + UUID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelListResponseTunnelWARPConnectorTunnelConnection) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelListResponseTunnelWARPConnectorTunnelConnectionJSON) RawJSON() string { + return r.raw +} + +// The type of tunnel. +type TunnelListResponseTunnelWARPConnectorTunnelTunType string + +const ( + TunnelListResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel TunnelListResponseTunnelWARPConnectorTunnelTunType = "cfd_tunnel" + TunnelListResponseTunnelWARPConnectorTunnelTunTypeWARPConnector TunnelListResponseTunnelWARPConnectorTunnelTunType = "warp_connector" + TunnelListResponseTunnelWARPConnectorTunnelTunTypeIPSec TunnelListResponseTunnelWARPConnectorTunnelTunType = "ip_sec" + TunnelListResponseTunnelWARPConnectorTunnelTunTypeGRE TunnelListResponseTunnelWARPConnectorTunnelTunType = "gre" + TunnelListResponseTunnelWARPConnectorTunnelTunTypeCni TunnelListResponseTunnelWARPConnectorTunnelTunType = "cni" +) + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +// +// Union satisfied by [zero_trust.TunnelEditResponseTunnelCfdTunnel] or +// [zero_trust.TunnelEditResponseTunnelWARPConnectorTunnel]. +type TunnelEditResponse interface { + implementsZeroTrustTunnelEditResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*TunnelEditResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TunnelEditResponseTunnelCfdTunnel{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TunnelEditResponseTunnelWARPConnectorTunnel{}), + }, + ) +} + +// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. +type TunnelEditResponseTunnelCfdTunnel struct { + // UUID of the tunnel. + ID string `json:"id"` + // Cloudflare account ID + AccountTag string `json:"account_tag"` + // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. + Connections []TunnelEditResponseTunnelCfdTunnelConnection `json:"connections"` + // Timestamp of when the tunnel established at least one connection to Cloudflare's + // edge. If `null`, the tunnel is inactive. + ConnsActiveAt time.Time `json:"conns_active_at,nullable" format:"date-time"` + // Timestamp of when the tunnel became inactive (no connections to Cloudflare's + // edge). If `null`, the tunnel is active. + ConnsInactiveAt time.Time `json:"conns_inactive_at,nullable" format:"date-time"` + // Timestamp of when the tunnel was created. + CreatedAt time.Time `json:"created_at" format:"date-time"` + // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been + // deleted. + DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` + // Metadata associated with the tunnel. + Metadata interface{} `json:"metadata"` + // A user-friendly name for the tunnel. + Name string `json:"name"` + // If `true`, the tunnel can be configured remotely from the Zero Trust dashboard. + // If `false`, the tunnel must be configured locally on the origin machine. + RemoteConfig bool `json:"remote_config"` + // The status of the tunnel. Valid values are `inactive` (tunnel has never been + // run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy + // state), `healthy` (tunnel is active and able to serve traffic), or `down` + // (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). + Status string `json:"status"` + // The type of tunnel. + TunType TunnelEditResponseTunnelCfdTunnelTunType `json:"tun_type"` + JSON tunnelEditResponseTunnelCfdTunnelJSON `json:"-"` +} + +// tunnelEditResponseTunnelCfdTunnelJSON contains the JSON metadata for the struct +// [TunnelEditResponseTunnelCfdTunnel] +type tunnelEditResponseTunnelCfdTunnelJSON struct { + ID apijson.Field + AccountTag apijson.Field + Connections apijson.Field + ConnsActiveAt apijson.Field + ConnsInactiveAt apijson.Field + CreatedAt apijson.Field + DeletedAt apijson.Field + Metadata apijson.Field + Name apijson.Field + RemoteConfig apijson.Field + Status apijson.Field + TunType apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelEditResponseTunnelCfdTunnel) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelEditResponseTunnelCfdTunnelJSON) RawJSON() string { + return r.raw +} + +func (r TunnelEditResponseTunnelCfdTunnel) implementsZeroTrustTunnelEditResponse() {} + +type TunnelEditResponseTunnelCfdTunnelConnection struct { + // UUID of the Cloudflare Tunnel connection. + ID string `json:"id"` + // UUID of the cloudflared instance. + ClientID interface{} `json:"client_id"` + // The cloudflared version used to establish this connection. + ClientVersion string `json:"client_version"` + // The Cloudflare data center used for this connection. + ColoName string `json:"colo_name"` + // Cloudflare continues to track connections for several minutes after they + // disconnect. This is an optimization to improve latency and reliability of + // reconnecting. If `true`, the connection has disconnected but is still being + // tracked. If `false`, the connection is actively serving traffic. + IsPendingReconnect bool `json:"is_pending_reconnect"` + // Timestamp of when the connection was established. + OpenedAt time.Time `json:"opened_at" format:"date-time"` + // The public IP address of the host running cloudflared. + OriginIP string `json:"origin_ip"` + // UUID of the Cloudflare Tunnel connection. + UUID string `json:"uuid"` + JSON tunnelEditResponseTunnelCfdTunnelConnectionJSON `json:"-"` +} + +// tunnelEditResponseTunnelCfdTunnelConnectionJSON contains the JSON metadata for +// the struct [TunnelEditResponseTunnelCfdTunnelConnection] +type tunnelEditResponseTunnelCfdTunnelConnectionJSON struct { + ID apijson.Field + ClientID apijson.Field + ClientVersion apijson.Field + ColoName apijson.Field + IsPendingReconnect apijson.Field + OpenedAt apijson.Field + OriginIP apijson.Field + UUID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelEditResponseTunnelCfdTunnelConnection) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelEditResponseTunnelCfdTunnelConnectionJSON) RawJSON() string { + return r.raw +} + +// The type of tunnel. +type TunnelEditResponseTunnelCfdTunnelTunType string + +const ( + TunnelEditResponseTunnelCfdTunnelTunTypeCfdTunnel TunnelEditResponseTunnelCfdTunnelTunType = "cfd_tunnel" + TunnelEditResponseTunnelCfdTunnelTunTypeWARPConnector TunnelEditResponseTunnelCfdTunnelTunType = "warp_connector" + TunnelEditResponseTunnelCfdTunnelTunTypeIPSec TunnelEditResponseTunnelCfdTunnelTunType = "ip_sec" + TunnelEditResponseTunnelCfdTunnelTunTypeGRE TunnelEditResponseTunnelCfdTunnelTunType = "gre" + TunnelEditResponseTunnelCfdTunnelTunTypeCni TunnelEditResponseTunnelCfdTunnelTunType = "cni" +) + +// A Warp Connector Tunnel that connects your origin to Cloudflare's edge. +type TunnelEditResponseTunnelWARPConnectorTunnel struct { + // UUID of the tunnel. + ID string `json:"id"` + // Cloudflare account ID + AccountTag string `json:"account_tag"` + // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. + Connections []TunnelEditResponseTunnelWARPConnectorTunnelConnection `json:"connections"` + // Timestamp of when the tunnel established at least one connection to Cloudflare's + // edge. If `null`, the tunnel is inactive. + ConnsActiveAt time.Time `json:"conns_active_at,nullable" format:"date-time"` + // Timestamp of when the tunnel became inactive (no connections to Cloudflare's + // edge). If `null`, the tunnel is active. + ConnsInactiveAt time.Time `json:"conns_inactive_at,nullable" format:"date-time"` + // Timestamp of when the tunnel was created. + CreatedAt time.Time `json:"created_at" format:"date-time"` + // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been + // deleted. + DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` + // Metadata associated with the tunnel. + Metadata interface{} `json:"metadata"` + // A user-friendly name for the tunnel. + Name string `json:"name"` + // The status of the tunnel. Valid values are `inactive` (tunnel has never been + // run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy + // state), `healthy` (tunnel is active and able to serve traffic), or `down` + // (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). + Status string `json:"status"` + // The type of tunnel. + TunType TunnelEditResponseTunnelWARPConnectorTunnelTunType `json:"tun_type"` + JSON tunnelEditResponseTunnelWARPConnectorTunnelJSON `json:"-"` +} + +// tunnelEditResponseTunnelWARPConnectorTunnelJSON contains the JSON metadata for +// the struct [TunnelEditResponseTunnelWARPConnectorTunnel] +type tunnelEditResponseTunnelWARPConnectorTunnelJSON struct { + ID apijson.Field + AccountTag apijson.Field + Connections apijson.Field + ConnsActiveAt apijson.Field + ConnsInactiveAt apijson.Field + CreatedAt apijson.Field + DeletedAt apijson.Field + Metadata apijson.Field + Name apijson.Field + Status apijson.Field + TunType apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelEditResponseTunnelWARPConnectorTunnel) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelEditResponseTunnelWARPConnectorTunnelJSON) RawJSON() string { + return r.raw +} + +func (r TunnelEditResponseTunnelWARPConnectorTunnel) implementsZeroTrustTunnelEditResponse() {} + +type TunnelEditResponseTunnelWARPConnectorTunnelConnection struct { + // UUID of the Cloudflare Tunnel connection. + ID string `json:"id"` + // UUID of the cloudflared instance. + ClientID interface{} `json:"client_id"` + // The cloudflared version used to establish this connection. + ClientVersion string `json:"client_version"` + // The Cloudflare data center used for this connection. + ColoName string `json:"colo_name"` + // Cloudflare continues to track connections for several minutes after they + // disconnect. This is an optimization to improve latency and reliability of + // reconnecting. If `true`, the connection has disconnected but is still being + // tracked. If `false`, the connection is actively serving traffic. + IsPendingReconnect bool `json:"is_pending_reconnect"` + // Timestamp of when the connection was established. + OpenedAt time.Time `json:"opened_at" format:"date-time"` + // The public IP address of the host running cloudflared. + OriginIP string `json:"origin_ip"` + // UUID of the Cloudflare Tunnel connection. + UUID string `json:"uuid"` + JSON tunnelEditResponseTunnelWARPConnectorTunnelConnectionJSON `json:"-"` +} + +// tunnelEditResponseTunnelWARPConnectorTunnelConnectionJSON contains the JSON +// metadata for the struct [TunnelEditResponseTunnelWARPConnectorTunnelConnection] +type tunnelEditResponseTunnelWARPConnectorTunnelConnectionJSON struct { + ID apijson.Field + ClientID apijson.Field + ClientVersion apijson.Field + ColoName apijson.Field + IsPendingReconnect apijson.Field + OpenedAt apijson.Field + OriginIP apijson.Field + UUID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelEditResponseTunnelWARPConnectorTunnelConnection) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelEditResponseTunnelWARPConnectorTunnelConnectionJSON) RawJSON() string { + return r.raw +} + +// The type of tunnel. +type TunnelEditResponseTunnelWARPConnectorTunnelTunType string + +const ( + TunnelEditResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel TunnelEditResponseTunnelWARPConnectorTunnelTunType = "cfd_tunnel" + TunnelEditResponseTunnelWARPConnectorTunnelTunTypeWARPConnector TunnelEditResponseTunnelWARPConnectorTunnelTunType = "warp_connector" + TunnelEditResponseTunnelWARPConnectorTunnelTunTypeIPSec TunnelEditResponseTunnelWARPConnectorTunnelTunType = "ip_sec" + TunnelEditResponseTunnelWARPConnectorTunnelTunTypeGRE TunnelEditResponseTunnelWARPConnectorTunnelTunType = "gre" + TunnelEditResponseTunnelWARPConnectorTunnelTunTypeCni TunnelEditResponseTunnelWARPConnectorTunnelTunType = "cni" +) + +type TunnelNewParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` + // A user-friendly name for the tunnel. + Name param.Field[string] `json:"name,required"` + // Sets the password required to run the tunnel. Must be at least 32 bytes and + // encoded as a base64 string. + TunnelSecret param.Field[interface{}] `json:"tunnel_secret,required"` +} + +func (r TunnelNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type TunnelNewResponseEnvelope struct { + Errors []TunnelNewResponseEnvelopeErrors `json:"errors,required"` + Messages []TunnelNewResponseEnvelopeMessages `json:"messages,required"` + Result TunnelArgoTunnel `json:"result,required"` + // Whether the API call was successful + Success TunnelNewResponseEnvelopeSuccess `json:"success,required"` + JSON tunnelNewResponseEnvelopeJSON `json:"-"` +} + +// tunnelNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [TunnelNewResponseEnvelope] +type tunnelNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TunnelNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// tunnelNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [TunnelNewResponseEnvelopeErrors] +type tunnelNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TunnelNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// tunnelNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [TunnelNewResponseEnvelopeMessages] +type tunnelNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TunnelNewResponseEnvelopeSuccess bool + +const ( + TunnelNewResponseEnvelopeSuccessTrue TunnelNewResponseEnvelopeSuccess = true +) + +type TunnelListParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` + ExcludePrefix param.Field[string] `query:"exclude_prefix"` + // If provided, include only tunnels that were created (and not deleted) before + // this time. + ExistedAt param.Field[time.Time] `query:"existed_at" format:"date-time"` + IncludePrefix param.Field[string] `query:"include_prefix"` + // If `true`, only include deleted tunnels. If `false`, exclude deleted tunnels. If + // empty, all tunnels will be included. + IsDeleted param.Field[bool] `query:"is_deleted"` + // A user-friendly name for the tunnel. + Name param.Field[string] `query:"name"` + // Page number of paginated results. + Page param.Field[float64] `query:"page"` + // Number of results to display. + PerPage param.Field[float64] `query:"per_page"` + // The types of tunnels to filter separated by a comma. + TunTypes param.Field[string] `query:"tun_types"` + WasActiveAt param.Field[time.Time] `query:"was_active_at" format:"date-time"` + WasInactiveAt param.Field[time.Time] `query:"was_inactive_at" format:"date-time"` +} + +// URLQuery serializes [TunnelListParams]'s query parameters as `url.Values`. +func (r TunnelListParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type TunnelDeleteParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` + Body param.Field[interface{}] `json:"body,required"` +} + +func (r TunnelDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type TunnelDeleteResponseEnvelope struct { + Errors []TunnelDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []TunnelDeleteResponseEnvelopeMessages `json:"messages,required"` + Result TunnelArgoTunnel `json:"result,required"` + // Whether the API call was successful + Success TunnelDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON tunnelDeleteResponseEnvelopeJSON `json:"-"` +} + +// tunnelDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [TunnelDeleteResponseEnvelope] +type tunnelDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TunnelDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// tunnelDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [TunnelDeleteResponseEnvelopeErrors] +type tunnelDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TunnelDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// tunnelDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [TunnelDeleteResponseEnvelopeMessages] +type tunnelDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TunnelDeleteResponseEnvelopeSuccess bool + +const ( + TunnelDeleteResponseEnvelopeSuccessTrue TunnelDeleteResponseEnvelopeSuccess = true +) + +type TunnelEditParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` + // A user-friendly name for the tunnel. + Name param.Field[string] `json:"name"` + // Sets the password required to run a locally-managed tunnel. Must be at least 32 + // bytes and encoded as a base64 string. + TunnelSecret param.Field[string] `json:"tunnel_secret"` +} + +func (r TunnelEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type TunnelEditResponseEnvelope struct { + Errors []TunnelEditResponseEnvelopeErrors `json:"errors,required"` + Messages []TunnelEditResponseEnvelopeMessages `json:"messages,required"` + // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. + Result TunnelEditResponse `json:"result,required"` + // Whether the API call was successful + Success TunnelEditResponseEnvelopeSuccess `json:"success,required"` + JSON tunnelEditResponseEnvelopeJSON `json:"-"` +} + +// tunnelEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [TunnelEditResponseEnvelope] +type tunnelEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TunnelEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// tunnelEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [TunnelEditResponseEnvelopeErrors] +type tunnelEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TunnelEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// tunnelEditResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [TunnelEditResponseEnvelopeMessages] +type tunnelEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TunnelEditResponseEnvelopeSuccess bool + +const ( + TunnelEditResponseEnvelopeSuccessTrue TunnelEditResponseEnvelopeSuccess = true +) + +type TunnelGetParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` +} + +type TunnelGetResponseEnvelope struct { + Errors []TunnelGetResponseEnvelopeErrors `json:"errors,required"` + Messages []TunnelGetResponseEnvelopeMessages `json:"messages,required"` + Result TunnelArgoTunnel `json:"result,required"` + // Whether the API call was successful + Success TunnelGetResponseEnvelopeSuccess `json:"success,required"` + JSON tunnelGetResponseEnvelopeJSON `json:"-"` +} + +// tunnelGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [TunnelGetResponseEnvelope] +type tunnelGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TunnelGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// tunnelGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [TunnelGetResponseEnvelopeErrors] +type tunnelGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TunnelGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// tunnelGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [TunnelGetResponseEnvelopeMessages] +type tunnelGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TunnelGetResponseEnvelopeSuccess bool + +const ( + TunnelGetResponseEnvelopeSuccessTrue TunnelGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/tunnel_test.go b/zero_trust/tunnel_test.go new file mode 100644 index 00000000000..79b212d8c30 --- /dev/null +++ b/zero_trust/tunnel_test.go @@ -0,0 +1,173 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + "time" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestTunnelNew(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("user@example.com"), + ) + _, err := client.ZeroTrust.Tunnels.New(context.TODO(), zero_trust.TunnelNewParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Name: cloudflare.F("blog"), + TunnelSecret: cloudflare.F[any](map[string]interface{}{}), + }) + 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 TestTunnelListWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Tunnels.List(context.TODO(), zero_trust.TunnelListParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + ExcludePrefix: cloudflare.F("vpc1-"), + ExistedAt: cloudflare.F(time.Now()), + IncludePrefix: cloudflare.F("vpc1-"), + IsDeleted: cloudflare.F(true), + Name: cloudflare.F("blog"), + Page: cloudflare.F(1.000000), + PerPage: cloudflare.F(1.000000), + TunTypes: cloudflare.F("cfd_tunnel,warp_connector"), + WasActiveAt: cloudflare.F(time.Now()), + WasInactiveAt: cloudflare.F(time.Now()), + }) + 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 TestTunnelDelete(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("user@example.com"), + ) + _, err := client.ZeroTrust.Tunnels.Delete( + context.TODO(), + "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + zero_trust.TunnelDeleteParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Body: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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 TestTunnelEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Tunnels.Edit( + context.TODO(), + "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + zero_trust.TunnelEditParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Name: cloudflare.F("blog"), + TunnelSecret: cloudflare.F("AQIDBAUGBwgBAgMEBQYHCAECAwQFBgcIAQIDBAUGBwg="), + }, + ) + 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 TestTunnelGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Tunnels.Get( + context.TODO(), + "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + zero_trust.TunnelGetParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/tunnelconfiguration.go b/zero_trust/tunnelconfiguration.go new file mode 100644 index 00000000000..e106620c444 --- /dev/null +++ b/zero_trust/tunnelconfiguration.go @@ -0,0 +1,457 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// TunnelConfigurationService 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 [NewTunnelConfigurationService] +// method instead. +type TunnelConfigurationService struct { + Options []option.RequestOption +} + +// NewTunnelConfigurationService 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 NewTunnelConfigurationService(opts ...option.RequestOption) (r *TunnelConfigurationService) { + r = &TunnelConfigurationService{} + r.Options = opts + return +} + +// Adds or updates the configuration for a remotely-managed tunnel. +func (r *TunnelConfigurationService) Update(ctx context.Context, tunnelID string, params TunnelConfigurationUpdateParams, opts ...option.RequestOption) (res *TunnelConfigurationUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env TunnelConfigurationUpdateResponseEnvelope + path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s/configurations", params.AccountID, tunnelID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets the configuration for a remotely-managed tunnel +func (r *TunnelConfigurationService) Get(ctx context.Context, tunnelID string, query TunnelConfigurationGetParams, opts ...option.RequestOption) (res *TunnelConfigurationGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env TunnelConfigurationGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s/configurations", query.AccountID, tunnelID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [zero_trust.TunnelConfigurationUpdateResponseUnknown], +// [zero_trust.TunnelConfigurationUpdateResponseArray] or [shared.UnionString]. +type TunnelConfigurationUpdateResponse interface { + ImplementsZeroTrustTunnelConfigurationUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*TunnelConfigurationUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TunnelConfigurationUpdateResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type TunnelConfigurationUpdateResponseArray []interface{} + +func (r TunnelConfigurationUpdateResponseArray) ImplementsZeroTrustTunnelConfigurationUpdateResponse() { +} + +// Union satisfied by [zero_trust.TunnelConfigurationGetResponseUnknown], +// [zero_trust.TunnelConfigurationGetResponseArray] or [shared.UnionString]. +type TunnelConfigurationGetResponse interface { + ImplementsZeroTrustTunnelConfigurationGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*TunnelConfigurationGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TunnelConfigurationGetResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type TunnelConfigurationGetResponseArray []interface{} + +func (r TunnelConfigurationGetResponseArray) ImplementsZeroTrustTunnelConfigurationGetResponse() {} + +type TunnelConfigurationUpdateParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` + // The tunnel configuration and ingress rules. + Config param.Field[TunnelConfigurationUpdateParamsConfig] `json:"config"` +} + +func (r TunnelConfigurationUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The tunnel configuration and ingress rules. +type TunnelConfigurationUpdateParamsConfig struct { + // List of public hostname definitions + Ingress param.Field[[]TunnelConfigurationUpdateParamsConfigIngress] `json:"ingress"` + // Configuration parameters of connection between cloudflared and origin server. + OriginRequest param.Field[TunnelConfigurationUpdateParamsConfigOriginRequest] `json:"originRequest"` + // Enable private network access from WARP users to private network routes + WARPRouting param.Field[TunnelConfigurationUpdateParamsConfigWARPRouting] `json:"warp-routing"` +} + +func (r TunnelConfigurationUpdateParamsConfig) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Public hostname +type TunnelConfigurationUpdateParamsConfigIngress struct { + // Public hostname for this service. + Hostname param.Field[string] `json:"hostname,required"` + // Protocol and address of destination server. Supported protocols: http://, + // https://, unix://, tcp://, ssh://, rdp://, unix+tls://, smb://. Alternatively + // can return a HTTP status code http_status:[code] e.g. 'http_status:404'. + Service param.Field[string] `json:"service,required"` + // Configuration parameters of connection between cloudflared and origin server. + OriginRequest param.Field[TunnelConfigurationUpdateParamsConfigIngressOriginRequest] `json:"originRequest"` + // Requests with this path route to this public hostname. + Path param.Field[string] `json:"path"` +} + +func (r TunnelConfigurationUpdateParamsConfigIngress) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configuration parameters of connection between cloudflared and origin server. +type TunnelConfigurationUpdateParamsConfigIngressOriginRequest struct { + // For all L7 requests to this hostname, cloudflared will validate each request's + // Cf-Access-Jwt-Assertion request header. + Access param.Field[TunnelConfigurationUpdateParamsConfigIngressOriginRequestAccess] `json:"access"` + // Path to the certificate authority (CA) for the certificate of your origin. This + // option should be used only if your certificate is not signed by Cloudflare. + CAPool param.Field[string] `json:"caPool"` + // Timeout for establishing a new TCP connection to your origin server. This + // excludes the time taken to establish TLS, which is controlled by tlsTimeout. + ConnectTimeout param.Field[int64] `json:"connectTimeout"` + // Disables chunked transfer encoding. Useful if you are running a WSGI server. + DisableChunkedEncoding param.Field[bool] `json:"disableChunkedEncoding"` + // Attempt to connect to origin using HTTP2. Origin must be configured as https. + HTTP2Origin param.Field[bool] `json:"http2Origin"` + // Sets the HTTP Host header on requests sent to the local service. + HTTPHostHeader param.Field[string] `json:"httpHostHeader"` + // Maximum number of idle keepalive connections between Tunnel and your origin. + // This does not restrict the total number of concurrent connections. + KeepAliveConnections param.Field[int64] `json:"keepAliveConnections"` + // Timeout after which an idle keepalive connection can be discarded. + KeepAliveTimeout param.Field[int64] `json:"keepAliveTimeout"` + // Disable the “happy eyeballs” algorithm for IPv4/IPv6 fallback if your local + // network has misconfigured one of the protocols. + NoHappyEyeballs param.Field[bool] `json:"noHappyEyeballs"` + // Disables TLS verification of the certificate presented by your origin. Will + // allow any certificate from the origin to be accepted. + NoTLSVerify param.Field[bool] `json:"noTLSVerify"` + // Hostname that cloudflared should expect from your origin server certificate. + OriginServerName param.Field[string] `json:"originServerName"` + // cloudflared starts a proxy server to translate HTTP traffic into TCP when + // proxying, for example, SSH or RDP. This configures what type of proxy will be + // started. Valid options are: "" for the regular proxy and "socks" for a SOCKS5 + // proxy. + ProxyType param.Field[string] `json:"proxyType"` + // The timeout after which a TCP keepalive packet is sent on a connection between + // Tunnel and the origin server. + TcpKeepAlive param.Field[int64] `json:"tcpKeepAlive"` + // Timeout for completing a TLS handshake to your origin server, if you have chosen + // to connect Tunnel to an HTTPS server. + TLSTimeout param.Field[int64] `json:"tlsTimeout"` +} + +func (r TunnelConfigurationUpdateParamsConfigIngressOriginRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// For all L7 requests to this hostname, cloudflared will validate each request's +// Cf-Access-Jwt-Assertion request header. +type TunnelConfigurationUpdateParamsConfigIngressOriginRequestAccess struct { + // Access applications that are allowed to reach this hostname for this Tunnel. + // Audience tags can be identified in the dashboard or via the List Access policies + // API. + AudTag param.Field[[]string] `json:"audTag,required"` + TeamName param.Field[string] `json:"teamName,required"` + // Deny traffic that has not fulfilled Access authorization. + Required param.Field[bool] `json:"required"` +} + +func (r TunnelConfigurationUpdateParamsConfigIngressOriginRequestAccess) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configuration parameters of connection between cloudflared and origin server. +type TunnelConfigurationUpdateParamsConfigOriginRequest struct { + // For all L7 requests to this hostname, cloudflared will validate each request's + // Cf-Access-Jwt-Assertion request header. + Access param.Field[TunnelConfigurationUpdateParamsConfigOriginRequestAccess] `json:"access"` + // Path to the certificate authority (CA) for the certificate of your origin. This + // option should be used only if your certificate is not signed by Cloudflare. + CAPool param.Field[string] `json:"caPool"` + // Timeout for establishing a new TCP connection to your origin server. This + // excludes the time taken to establish TLS, which is controlled by tlsTimeout. + ConnectTimeout param.Field[int64] `json:"connectTimeout"` + // Disables chunked transfer encoding. Useful if you are running a WSGI server. + DisableChunkedEncoding param.Field[bool] `json:"disableChunkedEncoding"` + // Attempt to connect to origin using HTTP2. Origin must be configured as https. + HTTP2Origin param.Field[bool] `json:"http2Origin"` + // Sets the HTTP Host header on requests sent to the local service. + HTTPHostHeader param.Field[string] `json:"httpHostHeader"` + // Maximum number of idle keepalive connections between Tunnel and your origin. + // This does not restrict the total number of concurrent connections. + KeepAliveConnections param.Field[int64] `json:"keepAliveConnections"` + // Timeout after which an idle keepalive connection can be discarded. + KeepAliveTimeout param.Field[int64] `json:"keepAliveTimeout"` + // Disable the “happy eyeballs” algorithm for IPv4/IPv6 fallback if your local + // network has misconfigured one of the protocols. + NoHappyEyeballs param.Field[bool] `json:"noHappyEyeballs"` + // Disables TLS verification of the certificate presented by your origin. Will + // allow any certificate from the origin to be accepted. + NoTLSVerify param.Field[bool] `json:"noTLSVerify"` + // Hostname that cloudflared should expect from your origin server certificate. + OriginServerName param.Field[string] `json:"originServerName"` + // cloudflared starts a proxy server to translate HTTP traffic into TCP when + // proxying, for example, SSH or RDP. This configures what type of proxy will be + // started. Valid options are: "" for the regular proxy and "socks" for a SOCKS5 + // proxy. + ProxyType param.Field[string] `json:"proxyType"` + // The timeout after which a TCP keepalive packet is sent on a connection between + // Tunnel and the origin server. + TcpKeepAlive param.Field[int64] `json:"tcpKeepAlive"` + // Timeout for completing a TLS handshake to your origin server, if you have chosen + // to connect Tunnel to an HTTPS server. + TLSTimeout param.Field[int64] `json:"tlsTimeout"` +} + +func (r TunnelConfigurationUpdateParamsConfigOriginRequest) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// For all L7 requests to this hostname, cloudflared will validate each request's +// Cf-Access-Jwt-Assertion request header. +type TunnelConfigurationUpdateParamsConfigOriginRequestAccess struct { + // Access applications that are allowed to reach this hostname for this Tunnel. + // Audience tags can be identified in the dashboard or via the List Access policies + // API. + AudTag param.Field[[]string] `json:"audTag,required"` + TeamName param.Field[string] `json:"teamName,required"` + // Deny traffic that has not fulfilled Access authorization. + Required param.Field[bool] `json:"required"` +} + +func (r TunnelConfigurationUpdateParamsConfigOriginRequestAccess) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Enable private network access from WARP users to private network routes +type TunnelConfigurationUpdateParamsConfigWARPRouting struct { + Enabled param.Field[bool] `json:"enabled"` +} + +func (r TunnelConfigurationUpdateParamsConfigWARPRouting) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type TunnelConfigurationUpdateResponseEnvelope struct { + Errors []TunnelConfigurationUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []TunnelConfigurationUpdateResponseEnvelopeMessages `json:"messages,required"` + Result TunnelConfigurationUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success TunnelConfigurationUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON tunnelConfigurationUpdateResponseEnvelopeJSON `json:"-"` +} + +// tunnelConfigurationUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [TunnelConfigurationUpdateResponseEnvelope] +type tunnelConfigurationUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelConfigurationUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelConfigurationUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TunnelConfigurationUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelConfigurationUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// tunnelConfigurationUpdateResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [TunnelConfigurationUpdateResponseEnvelopeErrors] +type tunnelConfigurationUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelConfigurationUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelConfigurationUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TunnelConfigurationUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelConfigurationUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// tunnelConfigurationUpdateResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [TunnelConfigurationUpdateResponseEnvelopeMessages] +type tunnelConfigurationUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelConfigurationUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelConfigurationUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TunnelConfigurationUpdateResponseEnvelopeSuccess bool + +const ( + TunnelConfigurationUpdateResponseEnvelopeSuccessTrue TunnelConfigurationUpdateResponseEnvelopeSuccess = true +) + +type TunnelConfigurationGetParams struct { + // Identifier + AccountID param.Field[string] `path:"account_id,required"` +} + +type TunnelConfigurationGetResponseEnvelope struct { + Errors []TunnelConfigurationGetResponseEnvelopeErrors `json:"errors,required"` + Messages []TunnelConfigurationGetResponseEnvelopeMessages `json:"messages,required"` + Result TunnelConfigurationGetResponse `json:"result,required"` + // Whether the API call was successful + Success TunnelConfigurationGetResponseEnvelopeSuccess `json:"success,required"` + JSON tunnelConfigurationGetResponseEnvelopeJSON `json:"-"` +} + +// tunnelConfigurationGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [TunnelConfigurationGetResponseEnvelope] +type tunnelConfigurationGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelConfigurationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelConfigurationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TunnelConfigurationGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelConfigurationGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// tunnelConfigurationGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [TunnelConfigurationGetResponseEnvelopeErrors] +type tunnelConfigurationGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelConfigurationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelConfigurationGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TunnelConfigurationGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelConfigurationGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// tunnelConfigurationGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [TunnelConfigurationGetResponseEnvelopeMessages] +type tunnelConfigurationGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelConfigurationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelConfigurationGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TunnelConfigurationGetResponseEnvelopeSuccess bool + +const ( + TunnelConfigurationGetResponseEnvelopeSuccessTrue TunnelConfigurationGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/tunnelconfiguration_test.go b/zero_trust/tunnelconfiguration_test.go new file mode 100644 index 00000000000..8783d61dbab --- /dev/null +++ b/zero_trust/tunnelconfiguration_test.go @@ -0,0 +1,173 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestTunnelConfigurationUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.ZeroTrust.Tunnels.Configurations.Update( + context.TODO(), + "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + zero_trust.TunnelConfigurationUpdateParams{ + AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Config: cloudflare.F(zero_trust.TunnelConfigurationUpdateParamsConfig{ + Ingress: cloudflare.F([]zero_trust.TunnelConfigurationUpdateParamsConfigIngress{{ + Hostname: cloudflare.F("tunnel.example.com"), + OriginRequest: cloudflare.F(zero_trust.TunnelConfigurationUpdateParamsConfigIngressOriginRequest{ + Access: cloudflare.F(zero_trust.TunnelConfigurationUpdateParamsConfigIngressOriginRequestAccess{ + AudTag: cloudflare.F([]string{"string", "string", "string"}), + Required: cloudflare.F(true), + TeamName: cloudflare.F("string"), + }), + CAPool: cloudflare.F("string"), + ConnectTimeout: cloudflare.F(int64(0)), + DisableChunkedEncoding: cloudflare.F(true), + HTTP2Origin: cloudflare.F(true), + HTTPHostHeader: cloudflare.F("string"), + KeepAliveConnections: cloudflare.F(int64(0)), + KeepAliveTimeout: cloudflare.F(int64(0)), + NoHappyEyeballs: cloudflare.F(true), + NoTLSVerify: cloudflare.F(true), + OriginServerName: cloudflare.F("string"), + ProxyType: cloudflare.F("string"), + TcpKeepAlive: cloudflare.F(int64(0)), + TLSTimeout: cloudflare.F(int64(0)), + }), + Path: cloudflare.F("subpath"), + Service: cloudflare.F("https://localhost:8001"), + }, { + Hostname: cloudflare.F("tunnel.example.com"), + OriginRequest: cloudflare.F(zero_trust.TunnelConfigurationUpdateParamsConfigIngressOriginRequest{ + Access: cloudflare.F(zero_trust.TunnelConfigurationUpdateParamsConfigIngressOriginRequestAccess{ + AudTag: cloudflare.F([]string{"string", "string", "string"}), + Required: cloudflare.F(true), + TeamName: cloudflare.F("string"), + }), + CAPool: cloudflare.F("string"), + ConnectTimeout: cloudflare.F(int64(0)), + DisableChunkedEncoding: cloudflare.F(true), + HTTP2Origin: cloudflare.F(true), + HTTPHostHeader: cloudflare.F("string"), + KeepAliveConnections: cloudflare.F(int64(0)), + KeepAliveTimeout: cloudflare.F(int64(0)), + NoHappyEyeballs: cloudflare.F(true), + NoTLSVerify: cloudflare.F(true), + OriginServerName: cloudflare.F("string"), + ProxyType: cloudflare.F("string"), + TcpKeepAlive: cloudflare.F(int64(0)), + TLSTimeout: cloudflare.F(int64(0)), + }), + Path: cloudflare.F("subpath"), + Service: cloudflare.F("https://localhost:8001"), + }, { + Hostname: cloudflare.F("tunnel.example.com"), + OriginRequest: cloudflare.F(zero_trust.TunnelConfigurationUpdateParamsConfigIngressOriginRequest{ + Access: cloudflare.F(zero_trust.TunnelConfigurationUpdateParamsConfigIngressOriginRequestAccess{ + AudTag: cloudflare.F([]string{"string", "string", "string"}), + Required: cloudflare.F(true), + TeamName: cloudflare.F("string"), + }), + CAPool: cloudflare.F("string"), + ConnectTimeout: cloudflare.F(int64(0)), + DisableChunkedEncoding: cloudflare.F(true), + HTTP2Origin: cloudflare.F(true), + HTTPHostHeader: cloudflare.F("string"), + KeepAliveConnections: cloudflare.F(int64(0)), + KeepAliveTimeout: cloudflare.F(int64(0)), + NoHappyEyeballs: cloudflare.F(true), + NoTLSVerify: cloudflare.F(true), + OriginServerName: cloudflare.F("string"), + ProxyType: cloudflare.F("string"), + TcpKeepAlive: cloudflare.F(int64(0)), + TLSTimeout: cloudflare.F(int64(0)), + }), + Path: cloudflare.F("subpath"), + Service: cloudflare.F("https://localhost:8001"), + }}), + OriginRequest: cloudflare.F(zero_trust.TunnelConfigurationUpdateParamsConfigOriginRequest{ + Access: cloudflare.F(zero_trust.TunnelConfigurationUpdateParamsConfigOriginRequestAccess{ + AudTag: cloudflare.F([]string{"string", "string", "string"}), + Required: cloudflare.F(true), + TeamName: cloudflare.F("string"), + }), + CAPool: cloudflare.F("string"), + ConnectTimeout: cloudflare.F(int64(0)), + DisableChunkedEncoding: cloudflare.F(true), + HTTP2Origin: cloudflare.F(true), + HTTPHostHeader: cloudflare.F("string"), + KeepAliveConnections: cloudflare.F(int64(0)), + KeepAliveTimeout: cloudflare.F(int64(0)), + NoHappyEyeballs: cloudflare.F(true), + NoTLSVerify: cloudflare.F(true), + OriginServerName: cloudflare.F("string"), + ProxyType: cloudflare.F("string"), + TcpKeepAlive: cloudflare.F(int64(0)), + TLSTimeout: cloudflare.F(int64(0)), + }), + WARPRouting: cloudflare.F(zero_trust.TunnelConfigurationUpdateParamsConfigWARPRouting{ + Enabled: cloudflare.F(true), + }), + }), + }, + ) + 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 TestTunnelConfigurationGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Tunnels.Configurations.Get( + context.TODO(), + "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + zero_trust.TunnelConfigurationGetParams{ + AccountID: cloudflare.F("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/zero_trust/tunnelconnection.go b/zero_trust/tunnelconnection.go new file mode 100644 index 00000000000..67b63e18786 --- /dev/null +++ b/zero_trust/tunnelconnection.go @@ -0,0 +1,387 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// TunnelConnectionService 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 [NewTunnelConnectionService] method +// instead. +type TunnelConnectionService struct { + Options []option.RequestOption +} + +// NewTunnelConnectionService 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 NewTunnelConnectionService(opts ...option.RequestOption) (r *TunnelConnectionService) { + r = &TunnelConnectionService{} + r.Options = opts + return +} + +// Removes connections that are in a disconnected or pending reconnect state. We +// recommend running this command after shutting down a tunnel. +func (r *TunnelConnectionService) Delete(ctx context.Context, tunnelID string, params TunnelConnectionDeleteParams, opts ...option.RequestOption) (res *TunnelConnectionDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env TunnelConnectionDeleteResponseEnvelope + path := fmt.Sprintf("accounts/%s/tunnels/%s/connections", params.AccountID, tunnelID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Fetches connection details for a Cloudflare Tunnel. +func (r *TunnelConnectionService) Get(ctx context.Context, tunnelID string, query TunnelConnectionGetParams, opts ...option.RequestOption) (res *[]TunnelTunnelClient, err error) { + opts = append(r.Options[:], opts...) + var env TunnelConnectionGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s/connections", query.AccountID, tunnelID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// A client (typically cloudflared) that maintains connections to a Cloudflare data +// center. +type TunnelTunnelClient struct { + // UUID of the Cloudflare Tunnel connection. + ID string `json:"id"` + // The cloudflared OS architecture used to establish this connection. + Arch string `json:"arch"` + // The version of the remote tunnel configuration. Used internally to sync + // cloudflared with the Zero Trust dashboard. + ConfigVersion int64 `json:"config_version"` + // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. + Conns []TunnelTunnelClientConn `json:"conns"` + // Features enabled for the Cloudflare Tunnel. + Features []string `json:"features"` + // Timestamp of when the tunnel connection was started. + RunAt time.Time `json:"run_at" format:"date-time"` + // The cloudflared version used to establish this connection. + Version string `json:"version"` + JSON tunnelTunnelClientJSON `json:"-"` +} + +// tunnelTunnelClientJSON contains the JSON metadata for the struct +// [TunnelTunnelClient] +type tunnelTunnelClientJSON struct { + ID apijson.Field + Arch apijson.Field + ConfigVersion apijson.Field + Conns apijson.Field + Features apijson.Field + RunAt apijson.Field + Version apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelTunnelClient) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelTunnelClientJSON) RawJSON() string { + return r.raw +} + +type TunnelTunnelClientConn struct { + // UUID of the Cloudflare Tunnel connection. + ID string `json:"id"` + // UUID of the cloudflared instance. + ClientID interface{} `json:"client_id"` + // The cloudflared version used to establish this connection. + ClientVersion string `json:"client_version"` + // The Cloudflare data center used for this connection. + ColoName string `json:"colo_name"` + // Cloudflare continues to track connections for several minutes after they + // disconnect. This is an optimization to improve latency and reliability of + // reconnecting. If `true`, the connection has disconnected but is still being + // tracked. If `false`, the connection is actively serving traffic. + IsPendingReconnect bool `json:"is_pending_reconnect"` + // Timestamp of when the connection was established. + OpenedAt time.Time `json:"opened_at" format:"date-time"` + // The public IP address of the host running cloudflared. + OriginIP string `json:"origin_ip"` + // UUID of the Cloudflare Tunnel connection. + UUID string `json:"uuid"` + JSON tunnelTunnelClientConnJSON `json:"-"` +} + +// tunnelTunnelClientConnJSON contains the JSON metadata for the struct +// [TunnelTunnelClientConn] +type tunnelTunnelClientConnJSON struct { + ID apijson.Field + ClientID apijson.Field + ClientVersion apijson.Field + ColoName apijson.Field + IsPendingReconnect apijson.Field + OpenedAt apijson.Field + OriginIP apijson.Field + UUID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelTunnelClientConn) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelTunnelClientConnJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [zero_trust.TunnelConnectionDeleteResponseUnknown], +// [zero_trust.TunnelConnectionDeleteResponseArray] or [shared.UnionString]. +type TunnelConnectionDeleteResponse interface { + ImplementsZeroTrustTunnelConnectionDeleteResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*TunnelConnectionDeleteResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TunnelConnectionDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type TunnelConnectionDeleteResponseArray []interface{} + +func (r TunnelConnectionDeleteResponseArray) ImplementsZeroTrustTunnelConnectionDeleteResponse() {} + +type TunnelConnectionDeleteParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` + Body param.Field[interface{}] `json:"body,required"` +} + +func (r TunnelConnectionDeleteParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +type TunnelConnectionDeleteResponseEnvelope struct { + Errors []TunnelConnectionDeleteResponseEnvelopeErrors `json:"errors,required"` + Messages []TunnelConnectionDeleteResponseEnvelopeMessages `json:"messages,required"` + Result TunnelConnectionDeleteResponse `json:"result,required"` + // Whether the API call was successful + Success TunnelConnectionDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON tunnelConnectionDeleteResponseEnvelopeJSON `json:"-"` +} + +// tunnelConnectionDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [TunnelConnectionDeleteResponseEnvelope] +type tunnelConnectionDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelConnectionDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelConnectionDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TunnelConnectionDeleteResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelConnectionDeleteResponseEnvelopeErrorsJSON `json:"-"` +} + +// tunnelConnectionDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [TunnelConnectionDeleteResponseEnvelopeErrors] +type tunnelConnectionDeleteResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelConnectionDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelConnectionDeleteResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TunnelConnectionDeleteResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelConnectionDeleteResponseEnvelopeMessagesJSON `json:"-"` +} + +// tunnelConnectionDeleteResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [TunnelConnectionDeleteResponseEnvelopeMessages] +type tunnelConnectionDeleteResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelConnectionDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelConnectionDeleteResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TunnelConnectionDeleteResponseEnvelopeSuccess bool + +const ( + TunnelConnectionDeleteResponseEnvelopeSuccessTrue TunnelConnectionDeleteResponseEnvelopeSuccess = true +) + +type TunnelConnectionGetParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` +} + +type TunnelConnectionGetResponseEnvelope struct { + Errors []TunnelConnectionGetResponseEnvelopeErrors `json:"errors,required"` + Messages []TunnelConnectionGetResponseEnvelopeMessages `json:"messages,required"` + Result []TunnelTunnelClient `json:"result,required,nullable"` + // Whether the API call was successful + Success TunnelConnectionGetResponseEnvelopeSuccess `json:"success,required"` + ResultInfo TunnelConnectionGetResponseEnvelopeResultInfo `json:"result_info"` + JSON tunnelConnectionGetResponseEnvelopeJSON `json:"-"` +} + +// tunnelConnectionGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [TunnelConnectionGetResponseEnvelope] +type tunnelConnectionGetResponseEnvelopeJSON 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 *TunnelConnectionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelConnectionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TunnelConnectionGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelConnectionGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// tunnelConnectionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [TunnelConnectionGetResponseEnvelopeErrors] +type tunnelConnectionGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelConnectionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelConnectionGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TunnelConnectionGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelConnectionGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// tunnelConnectionGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [TunnelConnectionGetResponseEnvelopeMessages] +type tunnelConnectionGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelConnectionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelConnectionGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TunnelConnectionGetResponseEnvelopeSuccess bool + +const ( + TunnelConnectionGetResponseEnvelopeSuccessTrue TunnelConnectionGetResponseEnvelopeSuccess = true +) + +type TunnelConnectionGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON tunnelConnectionGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// tunnelConnectionGetResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [TunnelConnectionGetResponseEnvelopeResultInfo] +type tunnelConnectionGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelConnectionGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelConnectionGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zero_trust/tunnelconnection_test.go b/zero_trust/tunnelconnection_test.go new file mode 100644 index 00000000000..78f3a7672f9 --- /dev/null +++ b/zero_trust/tunnelconnection_test.go @@ -0,0 +1,76 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestTunnelConnectionDelete(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("user@example.com"), + ) + _, err := client.ZeroTrust.Tunnels.Connections.Delete( + context.TODO(), + "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + zero_trust.TunnelConnectionDeleteParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Body: cloudflare.F[any](map[string]interface{}{}), + }, + ) + 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 TestTunnelConnectionGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Tunnels.Connections.Get( + context.TODO(), + "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + zero_trust.TunnelConnectionGetParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/tunnelconnector.go b/zero_trust/tunnelconnector.go new file mode 100644 index 00000000000..2943370402a --- /dev/null +++ b/zero_trust/tunnelconnector.go @@ -0,0 +1,133 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// TunnelConnectorService 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 [NewTunnelConnectorService] method +// instead. +type TunnelConnectorService struct { + Options []option.RequestOption +} + +// NewTunnelConnectorService 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 NewTunnelConnectorService(opts ...option.RequestOption) (r *TunnelConnectorService) { + r = &TunnelConnectorService{} + r.Options = opts + return +} + +// Fetches connector and connection details for a Cloudflare Tunnel. +func (r *TunnelConnectorService) Get(ctx context.Context, tunnelID string, connectorID string, query TunnelConnectorGetParams, opts ...option.RequestOption) (res *TunnelTunnelClient, err error) { + opts = append(r.Options[:], opts...) + var env TunnelConnectorGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s/connectors/%s", query.AccountID, tunnelID, connectorID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type TunnelConnectorGetParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` +} + +type TunnelConnectorGetResponseEnvelope struct { + Errors []TunnelConnectorGetResponseEnvelopeErrors `json:"errors,required"` + Messages []TunnelConnectorGetResponseEnvelopeMessages `json:"messages,required"` + // A client (typically cloudflared) that maintains connections to a Cloudflare data + // center. + Result TunnelTunnelClient `json:"result,required"` + // Whether the API call was successful + Success TunnelConnectorGetResponseEnvelopeSuccess `json:"success,required"` + JSON tunnelConnectorGetResponseEnvelopeJSON `json:"-"` +} + +// tunnelConnectorGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [TunnelConnectorGetResponseEnvelope] +type tunnelConnectorGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelConnectorGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelConnectorGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TunnelConnectorGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelConnectorGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// tunnelConnectorGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [TunnelConnectorGetResponseEnvelopeErrors] +type tunnelConnectorGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelConnectorGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelConnectorGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TunnelConnectorGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelConnectorGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// tunnelConnectorGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [TunnelConnectorGetResponseEnvelopeMessages] +type tunnelConnectorGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelConnectorGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelConnectorGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TunnelConnectorGetResponseEnvelopeSuccess bool + +const ( + TunnelConnectorGetResponseEnvelopeSuccessTrue TunnelConnectorGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/tunnelconnector_test.go b/zero_trust/tunnelconnector_test.go new file mode 100644 index 00000000000..cfe38049453 --- /dev/null +++ b/zero_trust/tunnelconnector_test.go @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestTunnelConnectorGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Tunnels.Connectors.Get( + context.TODO(), + "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + "1bedc50d-42b3-473c-b108-ff3d10c0d925", + zero_trust.TunnelConnectorGetParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/tunnelmanagement.go b/zero_trust/tunnelmanagement.go new file mode 100644 index 00000000000..4cc6b65bd2a --- /dev/null +++ b/zero_trust/tunnelmanagement.go @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// TunnelManagementService 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 [NewTunnelManagementService] method +// instead. +type TunnelManagementService struct { + Options []option.RequestOption +} + +// NewTunnelManagementService 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 NewTunnelManagementService(opts ...option.RequestOption) (r *TunnelManagementService) { + r = &TunnelManagementService{} + r.Options = opts + return +} + +// Gets a management token used to access the management resources (i.e. Streaming +// Logs) of a tunnel. +func (r *TunnelManagementService) New(ctx context.Context, tunnelID string, params TunnelManagementNewParams, opts ...option.RequestOption) (res *TunnelManagementNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env TunnelManagementNewResponseEnvelope + path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s/management", params.AccountID, tunnelID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [zero_trust.TunnelManagementNewResponseUnknown], +// [zero_trust.TunnelManagementNewResponseArray] or [shared.UnionString]. +type TunnelManagementNewResponse interface { + ImplementsZeroTrustTunnelManagementNewResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*TunnelManagementNewResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TunnelManagementNewResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type TunnelManagementNewResponseArray []interface{} + +func (r TunnelManagementNewResponseArray) ImplementsZeroTrustTunnelManagementNewResponse() {} + +type TunnelManagementNewParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` + Resources param.Field[[]TunnelManagementNewParamsResource] `json:"resources,required"` +} + +func (r TunnelManagementNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Management resources the token will have access to. +type TunnelManagementNewParamsResource string + +const ( + TunnelManagementNewParamsResourceLogs TunnelManagementNewParamsResource = "logs" +) + +type TunnelManagementNewResponseEnvelope struct { + Errors []TunnelManagementNewResponseEnvelopeErrors `json:"errors,required"` + Messages []TunnelManagementNewResponseEnvelopeMessages `json:"messages,required"` + Result TunnelManagementNewResponse `json:"result,required"` + // Whether the API call was successful + Success TunnelManagementNewResponseEnvelopeSuccess `json:"success,required"` + JSON tunnelManagementNewResponseEnvelopeJSON `json:"-"` +} + +// tunnelManagementNewResponseEnvelopeJSON contains the JSON metadata for the +// struct [TunnelManagementNewResponseEnvelope] +type tunnelManagementNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelManagementNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelManagementNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TunnelManagementNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelManagementNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// tunnelManagementNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [TunnelManagementNewResponseEnvelopeErrors] +type tunnelManagementNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelManagementNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelManagementNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TunnelManagementNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelManagementNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// tunnelManagementNewResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [TunnelManagementNewResponseEnvelopeMessages] +type tunnelManagementNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelManagementNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelManagementNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TunnelManagementNewResponseEnvelopeSuccess bool + +const ( + TunnelManagementNewResponseEnvelopeSuccessTrue TunnelManagementNewResponseEnvelopeSuccess = true +) diff --git a/zero_trust/tunnelmanagement_test.go b/zero_trust/tunnelmanagement_test.go new file mode 100644 index 00000000000..3a1a7631528 --- /dev/null +++ b/zero_trust/tunnelmanagement_test.go @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestTunnelManagementNew(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("user@example.com"), + ) + _, err := client.ZeroTrust.Tunnels.Management.New( + context.TODO(), + "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + zero_trust.TunnelManagementNewParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + Resources: cloudflare.F([]zero_trust.TunnelManagementNewParamsResource{zero_trust.TunnelManagementNewParamsResourceLogs}), + }, + ) + 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/zero_trust/tunneltoken.go b/zero_trust/tunneltoken.go new file mode 100644 index 00000000000..78ccda3a596 --- /dev/null +++ b/zero_trust/tunneltoken.go @@ -0,0 +1,159 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// TunnelTokenService 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 [NewTunnelTokenService] method +// instead. +type TunnelTokenService struct { + Options []option.RequestOption +} + +// NewTunnelTokenService 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 NewTunnelTokenService(opts ...option.RequestOption) (r *TunnelTokenService) { + r = &TunnelTokenService{} + r.Options = opts + return +} + +// Gets the token used to associate cloudflared with a specific tunnel. +func (r *TunnelTokenService) Get(ctx context.Context, tunnelID string, query TunnelTokenGetParams, opts ...option.RequestOption) (res *TunnelTokenGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env TunnelTokenGetResponseEnvelope + path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s/token", query.AccountID, tunnelID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [zero_trust.TunnelTokenGetResponseUnknown], +// [zero_trust.TunnelTokenGetResponseArray] or [shared.UnionString]. +type TunnelTokenGetResponse interface { + ImplementsZeroTrustTunnelTokenGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*TunnelTokenGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(TunnelTokenGetResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type TunnelTokenGetResponseArray []interface{} + +func (r TunnelTokenGetResponseArray) ImplementsZeroTrustTunnelTokenGetResponse() {} + +type TunnelTokenGetParams struct { + // Cloudflare account ID + AccountID param.Field[string] `path:"account_id,required"` +} + +type TunnelTokenGetResponseEnvelope struct { + Errors []TunnelTokenGetResponseEnvelopeErrors `json:"errors,required"` + Messages []TunnelTokenGetResponseEnvelopeMessages `json:"messages,required"` + Result TunnelTokenGetResponse `json:"result,required"` + // Whether the API call was successful + Success TunnelTokenGetResponseEnvelopeSuccess `json:"success,required"` + JSON tunnelTokenGetResponseEnvelopeJSON `json:"-"` +} + +// tunnelTokenGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [TunnelTokenGetResponseEnvelope] +type tunnelTokenGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelTokenGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelTokenGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type TunnelTokenGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelTokenGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// tunnelTokenGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [TunnelTokenGetResponseEnvelopeErrors] +type tunnelTokenGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelTokenGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelTokenGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type TunnelTokenGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON tunnelTokenGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// tunnelTokenGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [TunnelTokenGetResponseEnvelopeMessages] +type tunnelTokenGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *TunnelTokenGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r tunnelTokenGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type TunnelTokenGetResponseEnvelopeSuccess bool + +const ( + TunnelTokenGetResponseEnvelopeSuccessTrue TunnelTokenGetResponseEnvelopeSuccess = true +) diff --git a/zero_trust/tunneltoken_test.go b/zero_trust/tunneltoken_test.go new file mode 100644 index 00000000000..a9f1ece6277 --- /dev/null +++ b/zero_trust/tunneltoken_test.go @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zero_trust" +) + +func TestTunnelTokenGet(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("user@example.com"), + ) + _, err := client.ZeroTrust.Tunnels.Token.Get( + context.TODO(), + "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", + zero_trust.TunnelTokenGetParams{ + AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), + }, + ) + 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/zero_trust/zerotrust.go b/zero_trust/zerotrust.go new file mode 100644 index 00000000000..99067e6cadc --- /dev/null +++ b/zero_trust/zerotrust.go @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package zero_trust + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// ZeroTrustService 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 [NewZeroTrustService] method instead. +type ZeroTrustService struct { + Options []option.RequestOption + Devices *DeviceService + IdentityProviders *IdentityProviderService + Organizations *OrganizationService + Seats *SeatService + Access *AccessService + DEX *DEXService + Tunnels *TunnelService + ConnectivitySettings *ConnectivitySettingService + DLP *DLPService + Gateway *GatewayService + Networks *NetworkService +} + +// NewZeroTrustService 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 NewZeroTrustService(opts ...option.RequestOption) (r *ZeroTrustService) { + r = &ZeroTrustService{} + r.Options = opts + r.Devices = NewDeviceService(opts...) + r.IdentityProviders = NewIdentityProviderService(opts...) + r.Organizations = NewOrganizationService(opts...) + r.Seats = NewSeatService(opts...) + r.Access = NewAccessService(opts...) + r.DEX = NewDEXService(opts...) + r.Tunnels = NewTunnelService(opts...) + r.ConnectivitySettings = NewConnectivitySettingService(opts...) + r.DLP = NewDLPService(opts...) + r.Gateway = NewGatewayService(opts...) + r.Networks = NewNetworkService(opts...) + return +} diff --git a/zerotrust.go b/zerotrust.go deleted file mode 100644 index 139489ae389..00000000000 --- a/zerotrust.go +++ /dev/null @@ -1,46 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustService 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 [NewZeroTrustService] method instead. -type ZeroTrustService struct { - Options []option.RequestOption - Devices *ZeroTrustDeviceService - IdentityProviders *ZeroTrustIdentityProviderService - Organizations *ZeroTrustOrganizationService - Seats *ZeroTrustSeatService - Access *ZeroTrustAccessService - DEX *ZeroTrustDEXService - Tunnels *ZeroTrustTunnelService - ConnectivitySettings *ZeroTrustConnectivitySettingService - DLP *ZeroTrustDLPService - Gateway *ZeroTrustGatewayService - Networks *ZeroTrustNetworkService -} - -// NewZeroTrustService 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 NewZeroTrustService(opts ...option.RequestOption) (r *ZeroTrustService) { - r = &ZeroTrustService{} - r.Options = opts - r.Devices = NewZeroTrustDeviceService(opts...) - r.IdentityProviders = NewZeroTrustIdentityProviderService(opts...) - r.Organizations = NewZeroTrustOrganizationService(opts...) - r.Seats = NewZeroTrustSeatService(opts...) - r.Access = NewZeroTrustAccessService(opts...) - r.DEX = NewZeroTrustDEXService(opts...) - r.Tunnels = NewZeroTrustTunnelService(opts...) - r.ConnectivitySettings = NewZeroTrustConnectivitySettingService(opts...) - r.DLP = NewZeroTrustDLPService(opts...) - r.Gateway = NewZeroTrustGatewayService(opts...) - r.Networks = NewZeroTrustNetworkService(opts...) - return -} diff --git a/zerotrustaccess.go b/zerotrustaccess.go deleted file mode 100644 index 8da5479b53e..00000000000 --- a/zerotrustaccess.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustAccessService 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 [NewZeroTrustAccessService] method -// instead. -type ZeroTrustAccessService struct { - Options []option.RequestOption - Applications *ZeroTrustAccessApplicationService - Certificates *ZeroTrustAccessCertificateService - Groups *ZeroTrustAccessGroupService - ServiceTokens *ZeroTrustAccessServiceTokenService - Bookmarks *ZeroTrustAccessBookmarkService - Keys *ZeroTrustAccessKeyService - Logs *ZeroTrustAccessLogService - Users *ZeroTrustAccessUserService - CustomPages *ZeroTrustAccessCustomPageService - Tags *ZeroTrustAccessTagService -} - -// NewZeroTrustAccessService 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 NewZeroTrustAccessService(opts ...option.RequestOption) (r *ZeroTrustAccessService) { - r = &ZeroTrustAccessService{} - r.Options = opts - r.Applications = NewZeroTrustAccessApplicationService(opts...) - r.Certificates = NewZeroTrustAccessCertificateService(opts...) - r.Groups = NewZeroTrustAccessGroupService(opts...) - r.ServiceTokens = NewZeroTrustAccessServiceTokenService(opts...) - r.Bookmarks = NewZeroTrustAccessBookmarkService(opts...) - r.Keys = NewZeroTrustAccessKeyService(opts...) - r.Logs = NewZeroTrustAccessLogService(opts...) - r.Users = NewZeroTrustAccessUserService(opts...) - r.CustomPages = NewZeroTrustAccessCustomPageService(opts...) - r.Tags = NewZeroTrustAccessTagService(opts...) - return -} diff --git a/zerotrustaccessapplication.go b/zerotrustaccessapplication.go deleted file mode 100644 index cee5c771cb6..00000000000 --- a/zerotrustaccessapplication.go +++ /dev/null @@ -1,5779 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustAccessApplicationService 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 -// [NewZeroTrustAccessApplicationService] method instead. -type ZeroTrustAccessApplicationService struct { - Options []option.RequestOption - CAs *ZeroTrustAccessApplicationCAService - UserPolicyChecks *ZeroTrustAccessApplicationUserPolicyCheckService - Policies *ZeroTrustAccessApplicationPolicyService -} - -// NewZeroTrustAccessApplicationService 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 NewZeroTrustAccessApplicationService(opts ...option.RequestOption) (r *ZeroTrustAccessApplicationService) { - r = &ZeroTrustAccessApplicationService{} - r.Options = opts - r.CAs = NewZeroTrustAccessApplicationCAService(opts...) - r.UserPolicyChecks = NewZeroTrustAccessApplicationUserPolicyCheckService(opts...) - r.Policies = NewZeroTrustAccessApplicationPolicyService(opts...) - return -} - -// Adds a new application to Access. -func (r *ZeroTrustAccessApplicationService) New(ctx context.Context, params ZeroTrustAccessApplicationNewParams, opts ...option.RequestOption) (res *ZeroTrustAccessApplicationNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessApplicationNewResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/access/apps", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates an Access application. -func (r *ZeroTrustAccessApplicationService) Update(ctx context.Context, appID ZeroTrustAccessApplicationUpdateParamsAppID, params ZeroTrustAccessApplicationUpdateParams, opts ...option.RequestOption) (res *ZeroTrustAccessApplicationUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessApplicationUpdateResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/access/apps/%v", accountOrZone, accountOrZoneID, appID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists all Access applications in an account or zone. -func (r *ZeroTrustAccessApplicationService) List(ctx context.Context, query ZeroTrustAccessApplicationListParams, opts ...option.RequestOption) (res *[]ZeroTrustAccessApplicationListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessApplicationListResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/access/apps", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes an application from Access. -func (r *ZeroTrustAccessApplicationService) Delete(ctx context.Context, appID ZeroTrustAccessApplicationDeleteParamsAppID, body ZeroTrustAccessApplicationDeleteParams, opts ...option.RequestOption) (res *ZeroTrustAccessApplicationDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessApplicationDeleteResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if body.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = body.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = body.ZoneID - } - path := fmt.Sprintf("%s/%s/access/apps/%v", accountOrZone, accountOrZoneID, appID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches information about an Access application. -func (r *ZeroTrustAccessApplicationService) Get(ctx context.Context, appID ZeroTrustAccessApplicationGetParamsAppID, query ZeroTrustAccessApplicationGetParams, opts ...option.RequestOption) (res *ZeroTrustAccessApplicationGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessApplicationGetResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/access/apps/%v", accountOrZone, accountOrZoneID, appID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Revokes all tokens issued for an application. -func (r *ZeroTrustAccessApplicationService) RevokeTokens(ctx context.Context, appID ZeroTrustAccessApplicationRevokeTokensParamsAppID, body ZeroTrustAccessApplicationRevokeTokensParams, opts ...option.RequestOption) (res *ZeroTrustAccessApplicationRevokeTokensResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessApplicationRevokeTokensResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if body.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = body.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = body.ZoneID - } - path := fmt.Sprintf("%s/%s/access/apps/%v/revoke_tokens", accountOrZone, accountOrZoneID, appID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [ZeroTrustAccessApplicationNewResponseSelfHostedApplication], -// [ZeroTrustAccessApplicationNewResponseSaaSApplication], -// [ZeroTrustAccessApplicationNewResponseBrowserSSHApplication], -// [ZeroTrustAccessApplicationNewResponseBrowserVncApplication], -// [ZeroTrustAccessApplicationNewResponseAppLauncherApplication], -// [ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplication], -// [ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplication] or -// [ZeroTrustAccessApplicationNewResponseBookmarkApplication]. -type ZeroTrustAccessApplicationNewResponse interface { - implementsZeroTrustAccessApplicationNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationNewResponseSelfHostedApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationNewResponseSaaSApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationNewResponseBrowserSSHApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationNewResponseBrowserVncApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationNewResponseAppLauncherApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationNewResponseBookmarkApplication{}), - }, - ) -} - -type ZeroTrustAccessApplicationNewResponseSelfHostedApplication struct { - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain,required"` - // The application type. - Type string `json:"type,required"` - // UUID - ID string `json:"id"` - // When set to true, users can authenticate to this application using their WARP - // session. When set to false this application will always require direct IdP - // authentication. This setting always overrides the organization setting for WARP - // authentication. - AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CorsHeaders ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeaders `json:"cors_headers"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The custom error message shown to a user when they are denied access to the - // application. - CustomDenyMessage string `json:"custom_deny_message"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing identity-based rules. - CustomDenyURL string `json:"custom_deny_url"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing non-identity rules. - CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` - // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` - // Enables the binding cookie, which increases security against compromised - // authorization tokens and CSRF attacks. - EnableBindingCookie bool `json:"enable_binding_cookie"` - // Enables the HttpOnly cookie attribute, which increases security against XSS - // attacks. - HTTPOnlyCookieAttribute bool `json:"http_only_cookie_attribute"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - // Enables cookie paths to scope an application's JWT to the application path. If - // disabled, the JWT will scope to the hostname by default - PathCookieAttribute bool `json:"path_cookie_attribute"` - // Sets the SameSite cookie setting, which provides increased security against CSRF - // attacks. - SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` - // List of domains that Access will secure. - SelfHostedDomains []string `json:"self_hosted_domains"` - // Returns a 401 status code when the request is blocked by a Service Auth policy. - ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - // Enables automatic authentication through cloudflared. - SkipInterstitial bool `json:"skip_interstitial"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationNewResponseSelfHostedApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationNewResponseSelfHostedApplicationJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationNewResponseSelfHostedApplication] -type zeroTrustAccessApplicationNewResponseSelfHostedApplicationJSON struct { - Domain apijson.Field - Type apijson.Field - ID apijson.Field - AllowAuthenticateViaWARP apijson.Field - AllowedIdps apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CorsHeaders apijson.Field - CreatedAt apijson.Field - CustomDenyMessage apijson.Field - CustomDenyURL apijson.Field - CustomNonIdentityDenyURL apijson.Field - CustomPages apijson.Field - EnableBindingCookie apijson.Field - HTTPOnlyCookieAttribute apijson.Field - LogoURL apijson.Field - Name apijson.Field - PathCookieAttribute apijson.Field - SameSiteCookieAttribute apijson.Field - SelfHostedDomains apijson.Field - ServiceAuth401Redirect apijson.Field - SessionDuration apijson.Field - SkipInterstitial apijson.Field - Tags apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationNewResponseSelfHostedApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationNewResponseSelfHostedApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationNewResponseSelfHostedApplication) implementsZeroTrustAccessApplicationNewResponse() { -} - -type ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders bool `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods bool `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins bool `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials bool `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders []interface{} `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods []ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethod `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins []interface{} `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge float64 `json:"max_age"` - JSON zeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersJSON `json:"-"` -} - -// zeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeaders] -type zeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersJSON struct { - AllowAllHeaders apijson.Field - AllowAllMethods apijson.Field - AllowAllOrigins apijson.Field - AllowCredentials apijson.Field - AllowedHeaders apijson.Field - AllowedMethods apijson.Field - AllowedOrigins apijson.Field - MaxAge apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeaders) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethod string - -const ( - ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethodGet ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethod = "GET" - ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethodPost ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethod = "POST" - ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethodHead ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethod = "HEAD" - ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethodPut ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethod = "PUT" - ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethodDelete ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethod = "DELETE" - ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethodConnect ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethod = "CONNECT" - ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethodOptions ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethod = "OPTIONS" - ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethodTrace ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethod = "TRACE" - ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethodPatch ZeroTrustAccessApplicationNewResponseSelfHostedApplicationCorsHeadersAllowedMethod = "PATCH" -) - -type ZeroTrustAccessApplicationNewResponseSaaSApplication struct { - // UUID - ID string `json:"id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - SaasApp ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasApp `json:"saas_app"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - // The application type. - Type string `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationNewResponseSaaSApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationNewResponseSaaSApplicationJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationNewResponseSaaSApplication] -type zeroTrustAccessApplicationNewResponseSaaSApplicationJSON struct { - ID apijson.Field - AllowedIdps apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - CustomPages apijson.Field - LogoURL apijson.Field - Name apijson.Field - SaasApp apijson.Field - Tags apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationNewResponseSaaSApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationNewResponseSaaSApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationNewResponseSaaSApplication) implementsZeroTrustAccessApplicationNewResponse() { -} - -// Union satisfied by -// [ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasApp] -// or -// [ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasApp]. -type ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasApp interface { - implementsZeroTrustAccessApplicationNewResponseSaaSApplicationSaasApp() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasApp)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasApp{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasApp{}), - }, - ) -} - -type ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasApp struct { - // Optional identifier indicating the authentication protocol used for the saas - // app. Required for OIDC. Default if unset is "saml" - AuthType ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthType `json:"auth_type"` - // The service provider's endpoint that is responsible for receiving and parsing a - // SAML assertion. - ConsumerServiceURL string `json:"consumer_service_url"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - CustomAttributes ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes `json:"custom_attributes"` - // The URL that the user will be redirected to after a successful login for IDP - // initiated logins. - DefaultRelayState string `json:"default_relay_state"` - // The unique identifier for your SaaS application. - IdpEntityID string `json:"idp_entity_id"` - // The format of the name identifier sent to the SaaS application. - NameIDFormat ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat `json:"name_id_format"` - // A [JSONata](https://jsonata.org/) expression that transforms an application's - // user identities into a NameID value for its SAML assertion. This expression - // should evaluate to a singular string. The output of this expression can override - // the `name_id_format` setting. - NameIDTransformJsonata string `json:"name_id_transform_jsonata"` - // The Access public certificate that will be used to verify your identity. - PublicKey string `json:"public_key"` - // A globally unique name for an identity or service provider. - SpEntityID string `json:"sp_entity_id"` - // The endpoint where your SaaS application will send login requests. - SSOEndpoint string `json:"sso_endpoint"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppJSON `json:"-"` -} - -// zeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasApp] -type zeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppJSON struct { - AuthType apijson.Field - ConsumerServiceURL apijson.Field - CreatedAt apijson.Field - CustomAttributes apijson.Field - DefaultRelayState apijson.Field - IdpEntityID apijson.Field - NameIDFormat apijson.Field - NameIDTransformJsonata apijson.Field - PublicKey apijson.Field - SpEntityID apijson.Field - SSOEndpoint apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasApp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasApp) implementsZeroTrustAccessApplicationNewResponseSaaSApplicationSaasApp() { -} - -// Optional identifier indicating the authentication protocol used for the saas -// app. Required for OIDC. Default if unset is "saml" -type ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthType string - -const ( - ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeSaml ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthType = "saml" - ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeOidc ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthType = "oidc" -) - -type ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes struct { - // The name of the attribute. - Name string `json:"name"` - // A globally unique name for an identity or service provider. - NameFormat ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat `json:"name_format"` - Source ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource `json:"source"` - JSON zeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON `json:"-"` -} - -// zeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes] -type zeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON struct { - Name apijson.Field - NameFormat apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON) RawJSON() string { - return r.raw -} - -// A globally unique name for an identity or service provider. -type ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat string - -const ( - ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatUnspecified ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" - ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic" - ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatURI ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" -) - -type ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource struct { - // The name of the IdP attribute. - Name string `json:"name"` - JSON zeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON `json:"-"` -} - -// zeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource] -type zeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON struct { - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON) RawJSON() string { - return r.raw -} - -// The format of the name identifier sent to the SaaS application. -type ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat string - -const ( - ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatID ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat = "id" - ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatEmail ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat = "email" -) - -type ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasApp struct { - // The URL where this applications tile redirects users - AppLauncherURL string `json:"app_launcher_url"` - // Identifier of the authentication protocol used for the saas app. Required for - // OIDC. - AuthType ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthType `json:"auth_type"` - // The application client id - ClientID string `json:"client_id"` - // The application client secret, only returned on POST request. - ClientSecret string `json:"client_secret"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The OIDC flows supported by this application - GrantTypes []ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantType `json:"grant_types"` - // A regex to filter Cloudflare groups returned in ID token and userinfo endpoint - GroupFilterRegex string `json:"group_filter_regex"` - // The Access public certificate that will be used to verify your identity. - PublicKey string `json:"public_key"` - // The permitted URL's for Cloudflare to return Authorization codes and Access/ID - // tokens - RedirectURIs []string `json:"redirect_uris"` - // Define the user information shared with access - Scopes []ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppScope `json:"scopes"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppJSON `json:"-"` -} - -// zeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasApp] -type zeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppJSON struct { - AppLauncherURL apijson.Field - AuthType apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - CreatedAt apijson.Field - GrantTypes apijson.Field - GroupFilterRegex apijson.Field - PublicKey apijson.Field - RedirectURIs apijson.Field - Scopes apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasApp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasApp) implementsZeroTrustAccessApplicationNewResponseSaaSApplicationSaasApp() { -} - -// Identifier of the authentication protocol used for the saas app. Required for -// OIDC. -type ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthType string - -const ( - ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeSaml ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthType = "saml" - ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeOidc ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthType = "oidc" -) - -type ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantType string - -const ( - ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCode ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantType = "authorization_code" - ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCodeWithPkce ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantType = "authorization_code_with_pkce" -) - -type ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppScope string - -const ( - ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppScopeOpenid ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppScope = "openid" - ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppScopeGroups ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppScope = "groups" - ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppScopeEmail ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppScope = "email" - ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppScopeProfile ZeroTrustAccessApplicationNewResponseSaaSApplicationSaasAppAccessOidcSaasAppScope = "profile" -) - -type ZeroTrustAccessApplicationNewResponseBrowserSSHApplication struct { - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain,required"` - // The application type. - Type string `json:"type,required"` - // UUID - ID string `json:"id"` - // When set to true, users can authenticate to this application using their WARP - // session. When set to false this application will always require direct IdP - // authentication. This setting always overrides the organization setting for WARP - // authentication. - AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CorsHeaders ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeaders `json:"cors_headers"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The custom error message shown to a user when they are denied access to the - // application. - CustomDenyMessage string `json:"custom_deny_message"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing identity-based rules. - CustomDenyURL string `json:"custom_deny_url"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing non-identity rules. - CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` - // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` - // Enables the binding cookie, which increases security against compromised - // authorization tokens and CSRF attacks. - EnableBindingCookie bool `json:"enable_binding_cookie"` - // Enables the HttpOnly cookie attribute, which increases security against XSS - // attacks. - HTTPOnlyCookieAttribute bool `json:"http_only_cookie_attribute"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - // Enables cookie paths to scope an application's JWT to the application path. If - // disabled, the JWT will scope to the hostname by default - PathCookieAttribute bool `json:"path_cookie_attribute"` - // Sets the SameSite cookie setting, which provides increased security against CSRF - // attacks. - SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` - // List of domains that Access will secure. - SelfHostedDomains []string `json:"self_hosted_domains"` - // Returns a 401 status code when the request is blocked by a Service Auth policy. - ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - // Enables automatic authentication through cloudflared. - SkipInterstitial bool `json:"skip_interstitial"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationNewResponseBrowserSSHApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationNewResponseBrowserSSHApplicationJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationNewResponseBrowserSSHApplication] -type zeroTrustAccessApplicationNewResponseBrowserSSHApplicationJSON struct { - Domain apijson.Field - Type apijson.Field - ID apijson.Field - AllowAuthenticateViaWARP apijson.Field - AllowedIdps apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CorsHeaders apijson.Field - CreatedAt apijson.Field - CustomDenyMessage apijson.Field - CustomDenyURL apijson.Field - CustomNonIdentityDenyURL apijson.Field - CustomPages apijson.Field - EnableBindingCookie apijson.Field - HTTPOnlyCookieAttribute apijson.Field - LogoURL apijson.Field - Name apijson.Field - PathCookieAttribute apijson.Field - SameSiteCookieAttribute apijson.Field - SelfHostedDomains apijson.Field - ServiceAuth401Redirect apijson.Field - SessionDuration apijson.Field - SkipInterstitial apijson.Field - Tags apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationNewResponseBrowserSSHApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationNewResponseBrowserSSHApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationNewResponseBrowserSSHApplication) implementsZeroTrustAccessApplicationNewResponse() { -} - -type ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders bool `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods bool `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins bool `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials bool `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders []interface{} `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods []ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethod `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins []interface{} `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge float64 `json:"max_age"` - JSON zeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersJSON `json:"-"` -} - -// zeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeaders] -type zeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersJSON struct { - AllowAllHeaders apijson.Field - AllowAllMethods apijson.Field - AllowAllOrigins apijson.Field - AllowCredentials apijson.Field - AllowedHeaders apijson.Field - AllowedMethods apijson.Field - AllowedOrigins apijson.Field - MaxAge apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeaders) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethod string - -const ( - ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethodGet ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "GET" - ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethodPost ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "POST" - ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethodHead ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "HEAD" - ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethodPut ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "PUT" - ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethodDelete ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "DELETE" - ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethodConnect ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "CONNECT" - ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethodOptions ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "OPTIONS" - ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethodTrace ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "TRACE" - ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethodPatch ZeroTrustAccessApplicationNewResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "PATCH" -) - -type ZeroTrustAccessApplicationNewResponseBrowserVncApplication struct { - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain,required"` - // The application type. - Type string `json:"type,required"` - // UUID - ID string `json:"id"` - // When set to true, users can authenticate to this application using their WARP - // session. When set to false this application will always require direct IdP - // authentication. This setting always overrides the organization setting for WARP - // authentication. - AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CorsHeaders ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeaders `json:"cors_headers"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The custom error message shown to a user when they are denied access to the - // application. - CustomDenyMessage string `json:"custom_deny_message"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing identity-based rules. - CustomDenyURL string `json:"custom_deny_url"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing non-identity rules. - CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` - // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` - // Enables the binding cookie, which increases security against compromised - // authorization tokens and CSRF attacks. - EnableBindingCookie bool `json:"enable_binding_cookie"` - // Enables the HttpOnly cookie attribute, which increases security against XSS - // attacks. - HTTPOnlyCookieAttribute bool `json:"http_only_cookie_attribute"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - // Enables cookie paths to scope an application's JWT to the application path. If - // disabled, the JWT will scope to the hostname by default - PathCookieAttribute bool `json:"path_cookie_attribute"` - // Sets the SameSite cookie setting, which provides increased security against CSRF - // attacks. - SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` - // List of domains that Access will secure. - SelfHostedDomains []string `json:"self_hosted_domains"` - // Returns a 401 status code when the request is blocked by a Service Auth policy. - ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - // Enables automatic authentication through cloudflared. - SkipInterstitial bool `json:"skip_interstitial"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationNewResponseBrowserVncApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationNewResponseBrowserVncApplicationJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationNewResponseBrowserVncApplication] -type zeroTrustAccessApplicationNewResponseBrowserVncApplicationJSON struct { - Domain apijson.Field - Type apijson.Field - ID apijson.Field - AllowAuthenticateViaWARP apijson.Field - AllowedIdps apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CorsHeaders apijson.Field - CreatedAt apijson.Field - CustomDenyMessage apijson.Field - CustomDenyURL apijson.Field - CustomNonIdentityDenyURL apijson.Field - CustomPages apijson.Field - EnableBindingCookie apijson.Field - HTTPOnlyCookieAttribute apijson.Field - LogoURL apijson.Field - Name apijson.Field - PathCookieAttribute apijson.Field - SameSiteCookieAttribute apijson.Field - SelfHostedDomains apijson.Field - ServiceAuth401Redirect apijson.Field - SessionDuration apijson.Field - SkipInterstitial apijson.Field - Tags apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationNewResponseBrowserVncApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationNewResponseBrowserVncApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationNewResponseBrowserVncApplication) implementsZeroTrustAccessApplicationNewResponse() { -} - -type ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders bool `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods bool `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins bool `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials bool `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders []interface{} `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods []ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethod `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins []interface{} `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge float64 `json:"max_age"` - JSON zeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersJSON `json:"-"` -} - -// zeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeaders] -type zeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersJSON struct { - AllowAllHeaders apijson.Field - AllowAllMethods apijson.Field - AllowAllOrigins apijson.Field - AllowCredentials apijson.Field - AllowedHeaders apijson.Field - AllowedMethods apijson.Field - AllowedOrigins apijson.Field - MaxAge apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeaders) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethod string - -const ( - ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethodGet ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethod = "GET" - ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethodPost ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethod = "POST" - ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethodHead ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethod = "HEAD" - ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethodPut ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethod = "PUT" - ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethodDelete ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethod = "DELETE" - ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethodConnect ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethod = "CONNECT" - ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethodOptions ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethod = "OPTIONS" - ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethodTrace ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethod = "TRACE" - ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethodPatch ZeroTrustAccessApplicationNewResponseBrowserVncApplicationCorsHeadersAllowedMethod = "PATCH" -) - -type ZeroTrustAccessApplicationNewResponseAppLauncherApplication struct { - // The application type. - Type ZeroTrustAccessApplicationNewResponseAppLauncherApplicationType `json:"type,required"` - // UUID - ID string `json:"id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain"` - // The name of the application. - Name string `json:"name"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationNewResponseAppLauncherApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationNewResponseAppLauncherApplicationJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationNewResponseAppLauncherApplication] -type zeroTrustAccessApplicationNewResponseAppLauncherApplicationJSON struct { - Type apijson.Field - ID apijson.Field - AllowedIdps apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - Name apijson.Field - SessionDuration apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationNewResponseAppLauncherApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationNewResponseAppLauncherApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationNewResponseAppLauncherApplication) implementsZeroTrustAccessApplicationNewResponse() { -} - -// The application type. -type ZeroTrustAccessApplicationNewResponseAppLauncherApplicationType string - -const ( - ZeroTrustAccessApplicationNewResponseAppLauncherApplicationTypeSelfHosted ZeroTrustAccessApplicationNewResponseAppLauncherApplicationType = "self_hosted" - ZeroTrustAccessApplicationNewResponseAppLauncherApplicationTypeSaas ZeroTrustAccessApplicationNewResponseAppLauncherApplicationType = "saas" - ZeroTrustAccessApplicationNewResponseAppLauncherApplicationTypeSSH ZeroTrustAccessApplicationNewResponseAppLauncherApplicationType = "ssh" - ZeroTrustAccessApplicationNewResponseAppLauncherApplicationTypeVnc ZeroTrustAccessApplicationNewResponseAppLauncherApplicationType = "vnc" - ZeroTrustAccessApplicationNewResponseAppLauncherApplicationTypeAppLauncher ZeroTrustAccessApplicationNewResponseAppLauncherApplicationType = "app_launcher" - ZeroTrustAccessApplicationNewResponseAppLauncherApplicationTypeWARP ZeroTrustAccessApplicationNewResponseAppLauncherApplicationType = "warp" - ZeroTrustAccessApplicationNewResponseAppLauncherApplicationTypeBiso ZeroTrustAccessApplicationNewResponseAppLauncherApplicationType = "biso" - ZeroTrustAccessApplicationNewResponseAppLauncherApplicationTypeBookmark ZeroTrustAccessApplicationNewResponseAppLauncherApplicationType = "bookmark" - ZeroTrustAccessApplicationNewResponseAppLauncherApplicationTypeDashSSO ZeroTrustAccessApplicationNewResponseAppLauncherApplicationType = "dash_sso" -) - -type ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplication struct { - // The application type. - Type ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationType `json:"type,required"` - // UUID - ID string `json:"id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain"` - // The name of the application. - Name string `json:"name"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplication] -type zeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationJSON struct { - Type apijson.Field - ID apijson.Field - AllowedIdps apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - Name apijson.Field - SessionDuration apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplication) implementsZeroTrustAccessApplicationNewResponse() { -} - -// The application type. -type ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationType string - -const ( - ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationTypeSelfHosted ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationType = "self_hosted" - ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationTypeSaas ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationType = "saas" - ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationTypeSSH ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationType = "ssh" - ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationTypeVnc ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationType = "vnc" - ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationTypeAppLauncher ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationType = "app_launcher" - ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationTypeWARP ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationType = "warp" - ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationTypeBiso ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationType = "biso" - ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationTypeBookmark ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationType = "bookmark" - ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationTypeDashSSO ZeroTrustAccessApplicationNewResponseDeviceEnrollmentPermissionsApplicationType = "dash_sso" -) - -type ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplication struct { - // The application type. - Type ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationType `json:"type,required"` - // UUID - ID string `json:"id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain"` - // The name of the application. - Name string `json:"name"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplication] -type zeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationJSON struct { - Type apijson.Field - ID apijson.Field - AllowedIdps apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - Name apijson.Field - SessionDuration apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplication) implementsZeroTrustAccessApplicationNewResponse() { -} - -// The application type. -type ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationType string - -const ( - ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationTypeSelfHosted ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationType = "self_hosted" - ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationTypeSaas ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationType = "saas" - ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationTypeSSH ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationType = "ssh" - ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationTypeVnc ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationType = "vnc" - ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationTypeAppLauncher ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationType = "app_launcher" - ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationTypeWARP ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationType = "warp" - ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationTypeBiso ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationType = "biso" - ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationTypeBookmark ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationType = "bookmark" - ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationTypeDashSSO ZeroTrustAccessApplicationNewResponseBrowserIsolationPermissionsApplicationType = "dash_sso" -) - -type ZeroTrustAccessApplicationNewResponseBookmarkApplication struct { - // UUID - ID string `json:"id"` - AppLauncherVisible interface{} `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The URL or domain of the bookmark. - Domain interface{} `json:"domain"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - // The application type. - Type string `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationNewResponseBookmarkApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationNewResponseBookmarkApplicationJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationNewResponseBookmarkApplication] -type zeroTrustAccessApplicationNewResponseBookmarkApplicationJSON struct { - ID apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - LogoURL apijson.Field - Name apijson.Field - Tags apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationNewResponseBookmarkApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationNewResponseBookmarkApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationNewResponseBookmarkApplication) implementsZeroTrustAccessApplicationNewResponse() { -} - -// Union satisfied by -// [ZeroTrustAccessApplicationUpdateResponseSelfHostedApplication], -// [ZeroTrustAccessApplicationUpdateResponseSaaSApplication], -// [ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplication], -// [ZeroTrustAccessApplicationUpdateResponseBrowserVncApplication], -// [ZeroTrustAccessApplicationUpdateResponseAppLauncherApplication], -// [ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplication], -// [ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplication] -// or [ZeroTrustAccessApplicationUpdateResponseBookmarkApplication]. -type ZeroTrustAccessApplicationUpdateResponse interface { - implementsZeroTrustAccessApplicationUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationUpdateResponseSelfHostedApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationUpdateResponseSaaSApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationUpdateResponseBrowserVncApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationUpdateResponseAppLauncherApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationUpdateResponseBookmarkApplication{}), - }, - ) -} - -type ZeroTrustAccessApplicationUpdateResponseSelfHostedApplication struct { - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain,required"` - // The application type. - Type string `json:"type,required"` - // UUID - ID string `json:"id"` - // When set to true, users can authenticate to this application using their WARP - // session. When set to false this application will always require direct IdP - // authentication. This setting always overrides the organization setting for WARP - // authentication. - AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CorsHeaders ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeaders `json:"cors_headers"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The custom error message shown to a user when they are denied access to the - // application. - CustomDenyMessage string `json:"custom_deny_message"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing identity-based rules. - CustomDenyURL string `json:"custom_deny_url"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing non-identity rules. - CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` - // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` - // Enables the binding cookie, which increases security against compromised - // authorization tokens and CSRF attacks. - EnableBindingCookie bool `json:"enable_binding_cookie"` - // Enables the HttpOnly cookie attribute, which increases security against XSS - // attacks. - HTTPOnlyCookieAttribute bool `json:"http_only_cookie_attribute"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - // Enables cookie paths to scope an application's JWT to the application path. If - // disabled, the JWT will scope to the hostname by default - PathCookieAttribute bool `json:"path_cookie_attribute"` - // Sets the SameSite cookie setting, which provides increased security against CSRF - // attacks. - SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` - // List of domains that Access will secure. - SelfHostedDomains []string `json:"self_hosted_domains"` - // Returns a 401 status code when the request is blocked by a Service Auth policy. - ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - // Enables automatic authentication through cloudflared. - SkipInterstitial bool `json:"skip_interstitial"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationUpdateResponseSelfHostedApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationUpdateResponseSelfHostedApplicationJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationUpdateResponseSelfHostedApplication] -type zeroTrustAccessApplicationUpdateResponseSelfHostedApplicationJSON struct { - Domain apijson.Field - Type apijson.Field - ID apijson.Field - AllowAuthenticateViaWARP apijson.Field - AllowedIdps apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CorsHeaders apijson.Field - CreatedAt apijson.Field - CustomDenyMessage apijson.Field - CustomDenyURL apijson.Field - CustomNonIdentityDenyURL apijson.Field - CustomPages apijson.Field - EnableBindingCookie apijson.Field - HTTPOnlyCookieAttribute apijson.Field - LogoURL apijson.Field - Name apijson.Field - PathCookieAttribute apijson.Field - SameSiteCookieAttribute apijson.Field - SelfHostedDomains apijson.Field - ServiceAuth401Redirect apijson.Field - SessionDuration apijson.Field - SkipInterstitial apijson.Field - Tags apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUpdateResponseSelfHostedApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUpdateResponseSelfHostedApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationUpdateResponseSelfHostedApplication) implementsZeroTrustAccessApplicationUpdateResponse() { -} - -type ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders bool `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods bool `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins bool `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials bool `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders []interface{} `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods []ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethod `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins []interface{} `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge float64 `json:"max_age"` - JSON zeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersJSON `json:"-"` -} - -// zeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeaders] -type zeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersJSON struct { - AllowAllHeaders apijson.Field - AllowAllMethods apijson.Field - AllowAllOrigins apijson.Field - AllowCredentials apijson.Field - AllowedHeaders apijson.Field - AllowedMethods apijson.Field - AllowedOrigins apijson.Field - MaxAge apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeaders) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethod string - -const ( - ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethodGet ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethod = "GET" - ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethodPost ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethod = "POST" - ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethodHead ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethod = "HEAD" - ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethodPut ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethod = "PUT" - ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethodDelete ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethod = "DELETE" - ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethodConnect ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethod = "CONNECT" - ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethodOptions ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethod = "OPTIONS" - ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethodTrace ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethod = "TRACE" - ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethodPatch ZeroTrustAccessApplicationUpdateResponseSelfHostedApplicationCorsHeadersAllowedMethod = "PATCH" -) - -type ZeroTrustAccessApplicationUpdateResponseSaaSApplication struct { - // UUID - ID string `json:"id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - SaasApp ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasApp `json:"saas_app"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - // The application type. - Type string `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationUpdateResponseSaaSApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationUpdateResponseSaaSApplicationJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationUpdateResponseSaaSApplication] -type zeroTrustAccessApplicationUpdateResponseSaaSApplicationJSON struct { - ID apijson.Field - AllowedIdps apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - CustomPages apijson.Field - LogoURL apijson.Field - Name apijson.Field - SaasApp apijson.Field - Tags apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUpdateResponseSaaSApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUpdateResponseSaaSApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationUpdateResponseSaaSApplication) implementsZeroTrustAccessApplicationUpdateResponse() { -} - -// Union satisfied by -// [ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasApp] -// or -// [ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasApp]. -type ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasApp interface { - implementsZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasApp() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasApp)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasApp{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasApp{}), - }, - ) -} - -type ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasApp struct { - // Optional identifier indicating the authentication protocol used for the saas - // app. Required for OIDC. Default if unset is "saml" - AuthType ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthType `json:"auth_type"` - // The service provider's endpoint that is responsible for receiving and parsing a - // SAML assertion. - ConsumerServiceURL string `json:"consumer_service_url"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - CustomAttributes ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes `json:"custom_attributes"` - // The URL that the user will be redirected to after a successful login for IDP - // initiated logins. - DefaultRelayState string `json:"default_relay_state"` - // The unique identifier for your SaaS application. - IdpEntityID string `json:"idp_entity_id"` - // The format of the name identifier sent to the SaaS application. - NameIDFormat ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat `json:"name_id_format"` - // A [JSONata](https://jsonata.org/) expression that transforms an application's - // user identities into a NameID value for its SAML assertion. This expression - // should evaluate to a singular string. The output of this expression can override - // the `name_id_format` setting. - NameIDTransformJsonata string `json:"name_id_transform_jsonata"` - // The Access public certificate that will be used to verify your identity. - PublicKey string `json:"public_key"` - // A globally unique name for an identity or service provider. - SpEntityID string `json:"sp_entity_id"` - // The endpoint where your SaaS application will send login requests. - SSOEndpoint string `json:"sso_endpoint"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppJSON `json:"-"` -} - -// zeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasApp] -type zeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppJSON struct { - AuthType apijson.Field - ConsumerServiceURL apijson.Field - CreatedAt apijson.Field - CustomAttributes apijson.Field - DefaultRelayState apijson.Field - IdpEntityID apijson.Field - NameIDFormat apijson.Field - NameIDTransformJsonata apijson.Field - PublicKey apijson.Field - SpEntityID apijson.Field - SSOEndpoint apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasApp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasApp) implementsZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasApp() { -} - -// Optional identifier indicating the authentication protocol used for the saas -// app. Required for OIDC. Default if unset is "saml" -type ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthType string - -const ( - ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeSaml ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthType = "saml" - ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeOidc ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthType = "oidc" -) - -type ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes struct { - // The name of the attribute. - Name string `json:"name"` - // A globally unique name for an identity or service provider. - NameFormat ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat `json:"name_format"` - Source ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource `json:"source"` - JSON zeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON `json:"-"` -} - -// zeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes] -type zeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON struct { - Name apijson.Field - NameFormat apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON) RawJSON() string { - return r.raw -} - -// A globally unique name for an identity or service provider. -type ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat string - -const ( - ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatUnspecified ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" - ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic" - ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatURI ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" -) - -type ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource struct { - // The name of the IdP attribute. - Name string `json:"name"` - JSON zeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON `json:"-"` -} - -// zeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource] -type zeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON struct { - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON) RawJSON() string { - return r.raw -} - -// The format of the name identifier sent to the SaaS application. -type ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat string - -const ( - ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatID ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat = "id" - ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatEmail ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat = "email" -) - -type ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasApp struct { - // The URL where this applications tile redirects users - AppLauncherURL string `json:"app_launcher_url"` - // Identifier of the authentication protocol used for the saas app. Required for - // OIDC. - AuthType ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthType `json:"auth_type"` - // The application client id - ClientID string `json:"client_id"` - // The application client secret, only returned on POST request. - ClientSecret string `json:"client_secret"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The OIDC flows supported by this application - GrantTypes []ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantType `json:"grant_types"` - // A regex to filter Cloudflare groups returned in ID token and userinfo endpoint - GroupFilterRegex string `json:"group_filter_regex"` - // The Access public certificate that will be used to verify your identity. - PublicKey string `json:"public_key"` - // The permitted URL's for Cloudflare to return Authorization codes and Access/ID - // tokens - RedirectURIs []string `json:"redirect_uris"` - // Define the user information shared with access - Scopes []ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppScope `json:"scopes"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppJSON `json:"-"` -} - -// zeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasApp] -type zeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppJSON struct { - AppLauncherURL apijson.Field - AuthType apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - CreatedAt apijson.Field - GrantTypes apijson.Field - GroupFilterRegex apijson.Field - PublicKey apijson.Field - RedirectURIs apijson.Field - Scopes apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasApp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasApp) implementsZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasApp() { -} - -// Identifier of the authentication protocol used for the saas app. Required for -// OIDC. -type ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthType string - -const ( - ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeSaml ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthType = "saml" - ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeOidc ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthType = "oidc" -) - -type ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantType string - -const ( - ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCode ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantType = "authorization_code" - ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCodeWithPkce ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantType = "authorization_code_with_pkce" -) - -type ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppScope string - -const ( - ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppScopeOpenid ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppScope = "openid" - ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppScopeGroups ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppScope = "groups" - ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppScopeEmail ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppScope = "email" - ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppScopeProfile ZeroTrustAccessApplicationUpdateResponseSaaSApplicationSaasAppAccessOidcSaasAppScope = "profile" -) - -type ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplication struct { - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain,required"` - // The application type. - Type string `json:"type,required"` - // UUID - ID string `json:"id"` - // When set to true, users can authenticate to this application using their WARP - // session. When set to false this application will always require direct IdP - // authentication. This setting always overrides the organization setting for WARP - // authentication. - AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CorsHeaders ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeaders `json:"cors_headers"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The custom error message shown to a user when they are denied access to the - // application. - CustomDenyMessage string `json:"custom_deny_message"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing identity-based rules. - CustomDenyURL string `json:"custom_deny_url"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing non-identity rules. - CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` - // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` - // Enables the binding cookie, which increases security against compromised - // authorization tokens and CSRF attacks. - EnableBindingCookie bool `json:"enable_binding_cookie"` - // Enables the HttpOnly cookie attribute, which increases security against XSS - // attacks. - HTTPOnlyCookieAttribute bool `json:"http_only_cookie_attribute"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - // Enables cookie paths to scope an application's JWT to the application path. If - // disabled, the JWT will scope to the hostname by default - PathCookieAttribute bool `json:"path_cookie_attribute"` - // Sets the SameSite cookie setting, which provides increased security against CSRF - // attacks. - SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` - // List of domains that Access will secure. - SelfHostedDomains []string `json:"self_hosted_domains"` - // Returns a 401 status code when the request is blocked by a Service Auth policy. - ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - // Enables automatic authentication through cloudflared. - SkipInterstitial bool `json:"skip_interstitial"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplication] -type zeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationJSON struct { - Domain apijson.Field - Type apijson.Field - ID apijson.Field - AllowAuthenticateViaWARP apijson.Field - AllowedIdps apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CorsHeaders apijson.Field - CreatedAt apijson.Field - CustomDenyMessage apijson.Field - CustomDenyURL apijson.Field - CustomNonIdentityDenyURL apijson.Field - CustomPages apijson.Field - EnableBindingCookie apijson.Field - HTTPOnlyCookieAttribute apijson.Field - LogoURL apijson.Field - Name apijson.Field - PathCookieAttribute apijson.Field - SameSiteCookieAttribute apijson.Field - SelfHostedDomains apijson.Field - ServiceAuth401Redirect apijson.Field - SessionDuration apijson.Field - SkipInterstitial apijson.Field - Tags apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplication) implementsZeroTrustAccessApplicationUpdateResponse() { -} - -type ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders bool `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods bool `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins bool `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials bool `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders []interface{} `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods []ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethod `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins []interface{} `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge float64 `json:"max_age"` - JSON zeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersJSON `json:"-"` -} - -// zeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeaders] -type zeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersJSON struct { - AllowAllHeaders apijson.Field - AllowAllMethods apijson.Field - AllowAllOrigins apijson.Field - AllowCredentials apijson.Field - AllowedHeaders apijson.Field - AllowedMethods apijson.Field - AllowedOrigins apijson.Field - MaxAge apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeaders) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethod string - -const ( - ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethodGet ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "GET" - ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethodPost ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "POST" - ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethodHead ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "HEAD" - ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethodPut ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "PUT" - ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethodDelete ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "DELETE" - ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethodConnect ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "CONNECT" - ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethodOptions ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "OPTIONS" - ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethodTrace ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "TRACE" - ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethodPatch ZeroTrustAccessApplicationUpdateResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "PATCH" -) - -type ZeroTrustAccessApplicationUpdateResponseBrowserVncApplication struct { - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain,required"` - // The application type. - Type string `json:"type,required"` - // UUID - ID string `json:"id"` - // When set to true, users can authenticate to this application using their WARP - // session. When set to false this application will always require direct IdP - // authentication. This setting always overrides the organization setting for WARP - // authentication. - AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CorsHeaders ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeaders `json:"cors_headers"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The custom error message shown to a user when they are denied access to the - // application. - CustomDenyMessage string `json:"custom_deny_message"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing identity-based rules. - CustomDenyURL string `json:"custom_deny_url"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing non-identity rules. - CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` - // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` - // Enables the binding cookie, which increases security against compromised - // authorization tokens and CSRF attacks. - EnableBindingCookie bool `json:"enable_binding_cookie"` - // Enables the HttpOnly cookie attribute, which increases security against XSS - // attacks. - HTTPOnlyCookieAttribute bool `json:"http_only_cookie_attribute"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - // Enables cookie paths to scope an application's JWT to the application path. If - // disabled, the JWT will scope to the hostname by default - PathCookieAttribute bool `json:"path_cookie_attribute"` - // Sets the SameSite cookie setting, which provides increased security against CSRF - // attacks. - SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` - // List of domains that Access will secure. - SelfHostedDomains []string `json:"self_hosted_domains"` - // Returns a 401 status code when the request is blocked by a Service Auth policy. - ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - // Enables automatic authentication through cloudflared. - SkipInterstitial bool `json:"skip_interstitial"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationUpdateResponseBrowserVncApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationUpdateResponseBrowserVncApplicationJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationUpdateResponseBrowserVncApplication] -type zeroTrustAccessApplicationUpdateResponseBrowserVncApplicationJSON struct { - Domain apijson.Field - Type apijson.Field - ID apijson.Field - AllowAuthenticateViaWARP apijson.Field - AllowedIdps apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CorsHeaders apijson.Field - CreatedAt apijson.Field - CustomDenyMessage apijson.Field - CustomDenyURL apijson.Field - CustomNonIdentityDenyURL apijson.Field - CustomPages apijson.Field - EnableBindingCookie apijson.Field - HTTPOnlyCookieAttribute apijson.Field - LogoURL apijson.Field - Name apijson.Field - PathCookieAttribute apijson.Field - SameSiteCookieAttribute apijson.Field - SelfHostedDomains apijson.Field - ServiceAuth401Redirect apijson.Field - SessionDuration apijson.Field - SkipInterstitial apijson.Field - Tags apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUpdateResponseBrowserVncApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUpdateResponseBrowserVncApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationUpdateResponseBrowserVncApplication) implementsZeroTrustAccessApplicationUpdateResponse() { -} - -type ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders bool `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods bool `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins bool `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials bool `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders []interface{} `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods []ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethod `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins []interface{} `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge float64 `json:"max_age"` - JSON zeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersJSON `json:"-"` -} - -// zeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeaders] -type zeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersJSON struct { - AllowAllHeaders apijson.Field - AllowAllMethods apijson.Field - AllowAllOrigins apijson.Field - AllowCredentials apijson.Field - AllowedHeaders apijson.Field - AllowedMethods apijson.Field - AllowedOrigins apijson.Field - MaxAge apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeaders) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethod string - -const ( - ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethodGet ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethod = "GET" - ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethodPost ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethod = "POST" - ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethodHead ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethod = "HEAD" - ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethodPut ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethod = "PUT" - ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethodDelete ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethod = "DELETE" - ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethodConnect ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethod = "CONNECT" - ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethodOptions ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethod = "OPTIONS" - ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethodTrace ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethod = "TRACE" - ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethodPatch ZeroTrustAccessApplicationUpdateResponseBrowserVncApplicationCorsHeadersAllowedMethod = "PATCH" -) - -type ZeroTrustAccessApplicationUpdateResponseAppLauncherApplication struct { - // The application type. - Type ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationType `json:"type,required"` - // UUID - ID string `json:"id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain"` - // The name of the application. - Name string `json:"name"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationUpdateResponseAppLauncherApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationUpdateResponseAppLauncherApplicationJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationUpdateResponseAppLauncherApplication] -type zeroTrustAccessApplicationUpdateResponseAppLauncherApplicationJSON struct { - Type apijson.Field - ID apijson.Field - AllowedIdps apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - Name apijson.Field - SessionDuration apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUpdateResponseAppLauncherApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUpdateResponseAppLauncherApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationUpdateResponseAppLauncherApplication) implementsZeroTrustAccessApplicationUpdateResponse() { -} - -// The application type. -type ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationType string - -const ( - ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationTypeSelfHosted ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationType = "self_hosted" - ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationTypeSaas ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationType = "saas" - ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationTypeSSH ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationType = "ssh" - ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationTypeVnc ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationType = "vnc" - ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationTypeAppLauncher ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationType = "app_launcher" - ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationTypeWARP ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationType = "warp" - ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationTypeBiso ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationType = "biso" - ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationTypeBookmark ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationType = "bookmark" - ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationTypeDashSSO ZeroTrustAccessApplicationUpdateResponseAppLauncherApplicationType = "dash_sso" -) - -type ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplication struct { - // The application type. - Type ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationType `json:"type,required"` - // UUID - ID string `json:"id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain"` - // The name of the application. - Name string `json:"name"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplication] -type zeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationJSON struct { - Type apijson.Field - ID apijson.Field - AllowedIdps apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - Name apijson.Field - SessionDuration apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplication) implementsZeroTrustAccessApplicationUpdateResponse() { -} - -// The application type. -type ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationType string - -const ( - ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationTypeSelfHosted ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationType = "self_hosted" - ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationTypeSaas ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationType = "saas" - ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationTypeSSH ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationType = "ssh" - ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationTypeVnc ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationType = "vnc" - ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationTypeAppLauncher ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationType = "app_launcher" - ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationTypeWARP ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationType = "warp" - ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationTypeBiso ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationType = "biso" - ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationTypeBookmark ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationType = "bookmark" - ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationTypeDashSSO ZeroTrustAccessApplicationUpdateResponseDeviceEnrollmentPermissionsApplicationType = "dash_sso" -) - -type ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplication struct { - // The application type. - Type ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationType `json:"type,required"` - // UUID - ID string `json:"id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain"` - // The name of the application. - Name string `json:"name"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplication] -type zeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationJSON struct { - Type apijson.Field - ID apijson.Field - AllowedIdps apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - Name apijson.Field - SessionDuration apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplication) implementsZeroTrustAccessApplicationUpdateResponse() { -} - -// The application type. -type ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationType string - -const ( - ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationTypeSelfHosted ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationType = "self_hosted" - ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationTypeSaas ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationType = "saas" - ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationTypeSSH ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationType = "ssh" - ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationTypeVnc ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationType = "vnc" - ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationTypeAppLauncher ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationType = "app_launcher" - ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationTypeWARP ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationType = "warp" - ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationTypeBiso ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationType = "biso" - ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationTypeBookmark ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationType = "bookmark" - ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationTypeDashSSO ZeroTrustAccessApplicationUpdateResponseBrowserIsolationPermissionsApplicationType = "dash_sso" -) - -type ZeroTrustAccessApplicationUpdateResponseBookmarkApplication struct { - // UUID - ID string `json:"id"` - AppLauncherVisible interface{} `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The URL or domain of the bookmark. - Domain interface{} `json:"domain"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - // The application type. - Type string `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationUpdateResponseBookmarkApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationUpdateResponseBookmarkApplicationJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationUpdateResponseBookmarkApplication] -type zeroTrustAccessApplicationUpdateResponseBookmarkApplicationJSON struct { - ID apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - LogoURL apijson.Field - Name apijson.Field - Tags apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUpdateResponseBookmarkApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUpdateResponseBookmarkApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationUpdateResponseBookmarkApplication) implementsZeroTrustAccessApplicationUpdateResponse() { -} - -// Union satisfied by -// [ZeroTrustAccessApplicationListResponseSelfHostedApplication], -// [ZeroTrustAccessApplicationListResponseSaaSApplication], -// [ZeroTrustAccessApplicationListResponseBrowserSSHApplication], -// [ZeroTrustAccessApplicationListResponseBrowserVncApplication], -// [ZeroTrustAccessApplicationListResponseAppLauncherApplication], -// [ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplication], -// [ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplication] -// or [ZeroTrustAccessApplicationListResponseBookmarkApplication]. -type ZeroTrustAccessApplicationListResponse interface { - implementsZeroTrustAccessApplicationListResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationListResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationListResponseSelfHostedApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationListResponseSaaSApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationListResponseBrowserSSHApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationListResponseBrowserVncApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationListResponseAppLauncherApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationListResponseBookmarkApplication{}), - }, - ) -} - -type ZeroTrustAccessApplicationListResponseSelfHostedApplication struct { - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain,required"` - // The application type. - Type string `json:"type,required"` - // UUID - ID string `json:"id"` - // When set to true, users can authenticate to this application using their WARP - // session. When set to false this application will always require direct IdP - // authentication. This setting always overrides the organization setting for WARP - // authentication. - AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CorsHeaders ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeaders `json:"cors_headers"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The custom error message shown to a user when they are denied access to the - // application. - CustomDenyMessage string `json:"custom_deny_message"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing identity-based rules. - CustomDenyURL string `json:"custom_deny_url"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing non-identity rules. - CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` - // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` - // Enables the binding cookie, which increases security against compromised - // authorization tokens and CSRF attacks. - EnableBindingCookie bool `json:"enable_binding_cookie"` - // Enables the HttpOnly cookie attribute, which increases security against XSS - // attacks. - HTTPOnlyCookieAttribute bool `json:"http_only_cookie_attribute"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - // Enables cookie paths to scope an application's JWT to the application path. If - // disabled, the JWT will scope to the hostname by default - PathCookieAttribute bool `json:"path_cookie_attribute"` - // Sets the SameSite cookie setting, which provides increased security against CSRF - // attacks. - SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` - // List of domains that Access will secure. - SelfHostedDomains []string `json:"self_hosted_domains"` - // Returns a 401 status code when the request is blocked by a Service Auth policy. - ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - // Enables automatic authentication through cloudflared. - SkipInterstitial bool `json:"skip_interstitial"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationListResponseSelfHostedApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseSelfHostedApplicationJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationListResponseSelfHostedApplication] -type zeroTrustAccessApplicationListResponseSelfHostedApplicationJSON struct { - Domain apijson.Field - Type apijson.Field - ID apijson.Field - AllowAuthenticateViaWARP apijson.Field - AllowedIdps apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CorsHeaders apijson.Field - CreatedAt apijson.Field - CustomDenyMessage apijson.Field - CustomDenyURL apijson.Field - CustomNonIdentityDenyURL apijson.Field - CustomPages apijson.Field - EnableBindingCookie apijson.Field - HTTPOnlyCookieAttribute apijson.Field - LogoURL apijson.Field - Name apijson.Field - PathCookieAttribute apijson.Field - SameSiteCookieAttribute apijson.Field - SelfHostedDomains apijson.Field - ServiceAuth401Redirect apijson.Field - SessionDuration apijson.Field - SkipInterstitial apijson.Field - Tags apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationListResponseSelfHostedApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseSelfHostedApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationListResponseSelfHostedApplication) implementsZeroTrustAccessApplicationListResponse() { -} - -type ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders bool `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods bool `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins bool `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials bool `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders []interface{} `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods []ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethod `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins []interface{} `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge float64 `json:"max_age"` - JSON zeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeaders] -type zeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersJSON struct { - AllowAllHeaders apijson.Field - AllowAllMethods apijson.Field - AllowAllOrigins apijson.Field - AllowCredentials apijson.Field - AllowedHeaders apijson.Field - AllowedMethods apijson.Field - AllowedOrigins apijson.Field - MaxAge apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeaders) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethod string - -const ( - ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethodGet ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethod = "GET" - ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethodPost ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethod = "POST" - ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethodHead ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethod = "HEAD" - ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethodPut ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethod = "PUT" - ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethodDelete ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethod = "DELETE" - ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethodConnect ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethod = "CONNECT" - ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethodOptions ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethod = "OPTIONS" - ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethodTrace ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethod = "TRACE" - ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethodPatch ZeroTrustAccessApplicationListResponseSelfHostedApplicationCorsHeadersAllowedMethod = "PATCH" -) - -type ZeroTrustAccessApplicationListResponseSaaSApplication struct { - // UUID - ID string `json:"id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - SaasApp ZeroTrustAccessApplicationListResponseSaaSApplicationSaasApp `json:"saas_app"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - // The application type. - Type string `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationListResponseSaaSApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseSaaSApplicationJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationListResponseSaaSApplication] -type zeroTrustAccessApplicationListResponseSaaSApplicationJSON struct { - ID apijson.Field - AllowedIdps apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - CustomPages apijson.Field - LogoURL apijson.Field - Name apijson.Field - SaasApp apijson.Field - Tags apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationListResponseSaaSApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseSaaSApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationListResponseSaaSApplication) implementsZeroTrustAccessApplicationListResponse() { -} - -// Union satisfied by -// [ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasApp] -// or -// [ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasApp]. -type ZeroTrustAccessApplicationListResponseSaaSApplicationSaasApp interface { - implementsZeroTrustAccessApplicationListResponseSaaSApplicationSaasApp() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationListResponseSaaSApplicationSaasApp)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasApp{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasApp{}), - }, - ) -} - -type ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasApp struct { - // Optional identifier indicating the authentication protocol used for the saas - // app. Required for OIDC. Default if unset is "saml" - AuthType ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthType `json:"auth_type"` - // The service provider's endpoint that is responsible for receiving and parsing a - // SAML assertion. - ConsumerServiceURL string `json:"consumer_service_url"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - CustomAttributes ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes `json:"custom_attributes"` - // The URL that the user will be redirected to after a successful login for IDP - // initiated logins. - DefaultRelayState string `json:"default_relay_state"` - // The unique identifier for your SaaS application. - IdpEntityID string `json:"idp_entity_id"` - // The format of the name identifier sent to the SaaS application. - NameIDFormat ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat `json:"name_id_format"` - // A [JSONata](https://jsonata.org/) expression that transforms an application's - // user identities into a NameID value for its SAML assertion. This expression - // should evaluate to a singular string. The output of this expression can override - // the `name_id_format` setting. - NameIDTransformJsonata string `json:"name_id_transform_jsonata"` - // The Access public certificate that will be used to verify your identity. - PublicKey string `json:"public_key"` - // A globally unique name for an identity or service provider. - SpEntityID string `json:"sp_entity_id"` - // The endpoint where your SaaS application will send login requests. - SSOEndpoint string `json:"sso_endpoint"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasApp] -type zeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppJSON struct { - AuthType apijson.Field - ConsumerServiceURL apijson.Field - CreatedAt apijson.Field - CustomAttributes apijson.Field - DefaultRelayState apijson.Field - IdpEntityID apijson.Field - NameIDFormat apijson.Field - NameIDTransformJsonata apijson.Field - PublicKey apijson.Field - SpEntityID apijson.Field - SSOEndpoint apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasApp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasApp) implementsZeroTrustAccessApplicationListResponseSaaSApplicationSaasApp() { -} - -// Optional identifier indicating the authentication protocol used for the saas -// app. Required for OIDC. Default if unset is "saml" -type ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthType string - -const ( - ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeSaml ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthType = "saml" - ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeOidc ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthType = "oidc" -) - -type ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes struct { - // The name of the attribute. - Name string `json:"name"` - // A globally unique name for an identity or service provider. - NameFormat ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat `json:"name_format"` - Source ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource `json:"source"` - JSON zeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes] -type zeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON struct { - Name apijson.Field - NameFormat apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON) RawJSON() string { - return r.raw -} - -// A globally unique name for an identity or service provider. -type ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat string - -const ( - ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatUnspecified ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" - ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic" - ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatURI ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" -) - -type ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource struct { - // The name of the IdP attribute. - Name string `json:"name"` - JSON zeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource] -type zeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON struct { - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON) RawJSON() string { - return r.raw -} - -// The format of the name identifier sent to the SaaS application. -type ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat string - -const ( - ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatID ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat = "id" - ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatEmail ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat = "email" -) - -type ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasApp struct { - // The URL where this applications tile redirects users - AppLauncherURL string `json:"app_launcher_url"` - // Identifier of the authentication protocol used for the saas app. Required for - // OIDC. - AuthType ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthType `json:"auth_type"` - // The application client id - ClientID string `json:"client_id"` - // The application client secret, only returned on POST request. - ClientSecret string `json:"client_secret"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The OIDC flows supported by this application - GrantTypes []ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantType `json:"grant_types"` - // A regex to filter Cloudflare groups returned in ID token and userinfo endpoint - GroupFilterRegex string `json:"group_filter_regex"` - // The Access public certificate that will be used to verify your identity. - PublicKey string `json:"public_key"` - // The permitted URL's for Cloudflare to return Authorization codes and Access/ID - // tokens - RedirectURIs []string `json:"redirect_uris"` - // Define the user information shared with access - Scopes []ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppScope `json:"scopes"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasApp] -type zeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppJSON struct { - AppLauncherURL apijson.Field - AuthType apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - CreatedAt apijson.Field - GrantTypes apijson.Field - GroupFilterRegex apijson.Field - PublicKey apijson.Field - RedirectURIs apijson.Field - Scopes apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasApp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasApp) implementsZeroTrustAccessApplicationListResponseSaaSApplicationSaasApp() { -} - -// Identifier of the authentication protocol used for the saas app. Required for -// OIDC. -type ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthType string - -const ( - ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeSaml ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthType = "saml" - ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeOidc ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthType = "oidc" -) - -type ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantType string - -const ( - ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCode ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantType = "authorization_code" - ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCodeWithPkce ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantType = "authorization_code_with_pkce" -) - -type ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppScope string - -const ( - ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppScopeOpenid ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppScope = "openid" - ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppScopeGroups ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppScope = "groups" - ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppScopeEmail ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppScope = "email" - ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppScopeProfile ZeroTrustAccessApplicationListResponseSaaSApplicationSaasAppAccessOidcSaasAppScope = "profile" -) - -type ZeroTrustAccessApplicationListResponseBrowserSSHApplication struct { - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain,required"` - // The application type. - Type string `json:"type,required"` - // UUID - ID string `json:"id"` - // When set to true, users can authenticate to this application using their WARP - // session. When set to false this application will always require direct IdP - // authentication. This setting always overrides the organization setting for WARP - // authentication. - AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CorsHeaders ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeaders `json:"cors_headers"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The custom error message shown to a user when they are denied access to the - // application. - CustomDenyMessage string `json:"custom_deny_message"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing identity-based rules. - CustomDenyURL string `json:"custom_deny_url"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing non-identity rules. - CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` - // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` - // Enables the binding cookie, which increases security against compromised - // authorization tokens and CSRF attacks. - EnableBindingCookie bool `json:"enable_binding_cookie"` - // Enables the HttpOnly cookie attribute, which increases security against XSS - // attacks. - HTTPOnlyCookieAttribute bool `json:"http_only_cookie_attribute"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - // Enables cookie paths to scope an application's JWT to the application path. If - // disabled, the JWT will scope to the hostname by default - PathCookieAttribute bool `json:"path_cookie_attribute"` - // Sets the SameSite cookie setting, which provides increased security against CSRF - // attacks. - SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` - // List of domains that Access will secure. - SelfHostedDomains []string `json:"self_hosted_domains"` - // Returns a 401 status code when the request is blocked by a Service Auth policy. - ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - // Enables automatic authentication through cloudflared. - SkipInterstitial bool `json:"skip_interstitial"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationListResponseBrowserSSHApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseBrowserSSHApplicationJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationListResponseBrowserSSHApplication] -type zeroTrustAccessApplicationListResponseBrowserSSHApplicationJSON struct { - Domain apijson.Field - Type apijson.Field - ID apijson.Field - AllowAuthenticateViaWARP apijson.Field - AllowedIdps apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CorsHeaders apijson.Field - CreatedAt apijson.Field - CustomDenyMessage apijson.Field - CustomDenyURL apijson.Field - CustomNonIdentityDenyURL apijson.Field - CustomPages apijson.Field - EnableBindingCookie apijson.Field - HTTPOnlyCookieAttribute apijson.Field - LogoURL apijson.Field - Name apijson.Field - PathCookieAttribute apijson.Field - SameSiteCookieAttribute apijson.Field - SelfHostedDomains apijson.Field - ServiceAuth401Redirect apijson.Field - SessionDuration apijson.Field - SkipInterstitial apijson.Field - Tags apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationListResponseBrowserSSHApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseBrowserSSHApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationListResponseBrowserSSHApplication) implementsZeroTrustAccessApplicationListResponse() { -} - -type ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders bool `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods bool `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins bool `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials bool `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders []interface{} `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods []ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethod `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins []interface{} `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge float64 `json:"max_age"` - JSON zeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeaders] -type zeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersJSON struct { - AllowAllHeaders apijson.Field - AllowAllMethods apijson.Field - AllowAllOrigins apijson.Field - AllowCredentials apijson.Field - AllowedHeaders apijson.Field - AllowedMethods apijson.Field - AllowedOrigins apijson.Field - MaxAge apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeaders) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethod string - -const ( - ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethodGet ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "GET" - ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethodPost ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "POST" - ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethodHead ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "HEAD" - ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethodPut ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "PUT" - ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethodDelete ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "DELETE" - ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethodConnect ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "CONNECT" - ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethodOptions ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "OPTIONS" - ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethodTrace ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "TRACE" - ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethodPatch ZeroTrustAccessApplicationListResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "PATCH" -) - -type ZeroTrustAccessApplicationListResponseBrowserVncApplication struct { - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain,required"` - // The application type. - Type string `json:"type,required"` - // UUID - ID string `json:"id"` - // When set to true, users can authenticate to this application using their WARP - // session. When set to false this application will always require direct IdP - // authentication. This setting always overrides the organization setting for WARP - // authentication. - AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CorsHeaders ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeaders `json:"cors_headers"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The custom error message shown to a user when they are denied access to the - // application. - CustomDenyMessage string `json:"custom_deny_message"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing identity-based rules. - CustomDenyURL string `json:"custom_deny_url"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing non-identity rules. - CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` - // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` - // Enables the binding cookie, which increases security against compromised - // authorization tokens and CSRF attacks. - EnableBindingCookie bool `json:"enable_binding_cookie"` - // Enables the HttpOnly cookie attribute, which increases security against XSS - // attacks. - HTTPOnlyCookieAttribute bool `json:"http_only_cookie_attribute"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - // Enables cookie paths to scope an application's JWT to the application path. If - // disabled, the JWT will scope to the hostname by default - PathCookieAttribute bool `json:"path_cookie_attribute"` - // Sets the SameSite cookie setting, which provides increased security against CSRF - // attacks. - SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` - // List of domains that Access will secure. - SelfHostedDomains []string `json:"self_hosted_domains"` - // Returns a 401 status code when the request is blocked by a Service Auth policy. - ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - // Enables automatic authentication through cloudflared. - SkipInterstitial bool `json:"skip_interstitial"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationListResponseBrowserVncApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseBrowserVncApplicationJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationListResponseBrowserVncApplication] -type zeroTrustAccessApplicationListResponseBrowserVncApplicationJSON struct { - Domain apijson.Field - Type apijson.Field - ID apijson.Field - AllowAuthenticateViaWARP apijson.Field - AllowedIdps apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CorsHeaders apijson.Field - CreatedAt apijson.Field - CustomDenyMessage apijson.Field - CustomDenyURL apijson.Field - CustomNonIdentityDenyURL apijson.Field - CustomPages apijson.Field - EnableBindingCookie apijson.Field - HTTPOnlyCookieAttribute apijson.Field - LogoURL apijson.Field - Name apijson.Field - PathCookieAttribute apijson.Field - SameSiteCookieAttribute apijson.Field - SelfHostedDomains apijson.Field - ServiceAuth401Redirect apijson.Field - SessionDuration apijson.Field - SkipInterstitial apijson.Field - Tags apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationListResponseBrowserVncApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseBrowserVncApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationListResponseBrowserVncApplication) implementsZeroTrustAccessApplicationListResponse() { -} - -type ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders bool `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods bool `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins bool `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials bool `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders []interface{} `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods []ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethod `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins []interface{} `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge float64 `json:"max_age"` - JSON zeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeaders] -type zeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersJSON struct { - AllowAllHeaders apijson.Field - AllowAllMethods apijson.Field - AllowAllOrigins apijson.Field - AllowCredentials apijson.Field - AllowedHeaders apijson.Field - AllowedMethods apijson.Field - AllowedOrigins apijson.Field - MaxAge apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeaders) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethod string - -const ( - ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethodGet ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethod = "GET" - ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethodPost ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethod = "POST" - ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethodHead ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethod = "HEAD" - ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethodPut ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethod = "PUT" - ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethodDelete ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethod = "DELETE" - ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethodConnect ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethod = "CONNECT" - ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethodOptions ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethod = "OPTIONS" - ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethodTrace ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethod = "TRACE" - ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethodPatch ZeroTrustAccessApplicationListResponseBrowserVncApplicationCorsHeadersAllowedMethod = "PATCH" -) - -type ZeroTrustAccessApplicationListResponseAppLauncherApplication struct { - // The application type. - Type ZeroTrustAccessApplicationListResponseAppLauncherApplicationType `json:"type,required"` - // UUID - ID string `json:"id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain"` - // The name of the application. - Name string `json:"name"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationListResponseAppLauncherApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseAppLauncherApplicationJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationListResponseAppLauncherApplication] -type zeroTrustAccessApplicationListResponseAppLauncherApplicationJSON struct { - Type apijson.Field - ID apijson.Field - AllowedIdps apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - Name apijson.Field - SessionDuration apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationListResponseAppLauncherApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseAppLauncherApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationListResponseAppLauncherApplication) implementsZeroTrustAccessApplicationListResponse() { -} - -// The application type. -type ZeroTrustAccessApplicationListResponseAppLauncherApplicationType string - -const ( - ZeroTrustAccessApplicationListResponseAppLauncherApplicationTypeSelfHosted ZeroTrustAccessApplicationListResponseAppLauncherApplicationType = "self_hosted" - ZeroTrustAccessApplicationListResponseAppLauncherApplicationTypeSaas ZeroTrustAccessApplicationListResponseAppLauncherApplicationType = "saas" - ZeroTrustAccessApplicationListResponseAppLauncherApplicationTypeSSH ZeroTrustAccessApplicationListResponseAppLauncherApplicationType = "ssh" - ZeroTrustAccessApplicationListResponseAppLauncherApplicationTypeVnc ZeroTrustAccessApplicationListResponseAppLauncherApplicationType = "vnc" - ZeroTrustAccessApplicationListResponseAppLauncherApplicationTypeAppLauncher ZeroTrustAccessApplicationListResponseAppLauncherApplicationType = "app_launcher" - ZeroTrustAccessApplicationListResponseAppLauncherApplicationTypeWARP ZeroTrustAccessApplicationListResponseAppLauncherApplicationType = "warp" - ZeroTrustAccessApplicationListResponseAppLauncherApplicationTypeBiso ZeroTrustAccessApplicationListResponseAppLauncherApplicationType = "biso" - ZeroTrustAccessApplicationListResponseAppLauncherApplicationTypeBookmark ZeroTrustAccessApplicationListResponseAppLauncherApplicationType = "bookmark" - ZeroTrustAccessApplicationListResponseAppLauncherApplicationTypeDashSSO ZeroTrustAccessApplicationListResponseAppLauncherApplicationType = "dash_sso" -) - -type ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplication struct { - // The application type. - Type ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationType `json:"type,required"` - // UUID - ID string `json:"id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain"` - // The name of the application. - Name string `json:"name"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplication] -type zeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationJSON struct { - Type apijson.Field - ID apijson.Field - AllowedIdps apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - Name apijson.Field - SessionDuration apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplication) implementsZeroTrustAccessApplicationListResponse() { -} - -// The application type. -type ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationType string - -const ( - ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationTypeSelfHosted ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationType = "self_hosted" - ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationTypeSaas ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationType = "saas" - ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationTypeSSH ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationType = "ssh" - ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationTypeVnc ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationType = "vnc" - ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationTypeAppLauncher ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationType = "app_launcher" - ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationTypeWARP ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationType = "warp" - ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationTypeBiso ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationType = "biso" - ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationTypeBookmark ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationType = "bookmark" - ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationTypeDashSSO ZeroTrustAccessApplicationListResponseDeviceEnrollmentPermissionsApplicationType = "dash_sso" -) - -type ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplication struct { - // The application type. - Type ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationType `json:"type,required"` - // UUID - ID string `json:"id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain"` - // The name of the application. - Name string `json:"name"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplication] -type zeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationJSON struct { - Type apijson.Field - ID apijson.Field - AllowedIdps apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - Name apijson.Field - SessionDuration apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplication) implementsZeroTrustAccessApplicationListResponse() { -} - -// The application type. -type ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationType string - -const ( - ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationTypeSelfHosted ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationType = "self_hosted" - ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationTypeSaas ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationType = "saas" - ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationTypeSSH ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationType = "ssh" - ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationTypeVnc ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationType = "vnc" - ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationTypeAppLauncher ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationType = "app_launcher" - ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationTypeWARP ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationType = "warp" - ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationTypeBiso ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationType = "biso" - ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationTypeBookmark ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationType = "bookmark" - ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationTypeDashSSO ZeroTrustAccessApplicationListResponseBrowserIsolationPermissionsApplicationType = "dash_sso" -) - -type ZeroTrustAccessApplicationListResponseBookmarkApplication struct { - // UUID - ID string `json:"id"` - AppLauncherVisible interface{} `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The URL or domain of the bookmark. - Domain interface{} `json:"domain"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - // The application type. - Type string `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationListResponseBookmarkApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseBookmarkApplicationJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationListResponseBookmarkApplication] -type zeroTrustAccessApplicationListResponseBookmarkApplicationJSON struct { - ID apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - LogoURL apijson.Field - Name apijson.Field - Tags apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationListResponseBookmarkApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseBookmarkApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationListResponseBookmarkApplication) implementsZeroTrustAccessApplicationListResponse() { -} - -type ZeroTrustAccessApplicationDeleteResponse struct { - // UUID - ID string `json:"id"` - JSON zeroTrustAccessApplicationDeleteResponseJSON `json:"-"` -} - -// zeroTrustAccessApplicationDeleteResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessApplicationDeleteResponse] -type zeroTrustAccessApplicationDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [ZeroTrustAccessApplicationGetResponseSelfHostedApplication], -// [ZeroTrustAccessApplicationGetResponseSaaSApplication], -// [ZeroTrustAccessApplicationGetResponseBrowserSSHApplication], -// [ZeroTrustAccessApplicationGetResponseBrowserVncApplication], -// [ZeroTrustAccessApplicationGetResponseAppLauncherApplication], -// [ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplication], -// [ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplication] or -// [ZeroTrustAccessApplicationGetResponseBookmarkApplication]. -type ZeroTrustAccessApplicationGetResponse interface { - implementsZeroTrustAccessApplicationGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationGetResponseSelfHostedApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationGetResponseSaaSApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationGetResponseBrowserSSHApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationGetResponseBrowserVncApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationGetResponseAppLauncherApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationGetResponseBookmarkApplication{}), - }, - ) -} - -type ZeroTrustAccessApplicationGetResponseSelfHostedApplication struct { - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain,required"` - // The application type. - Type string `json:"type,required"` - // UUID - ID string `json:"id"` - // When set to true, users can authenticate to this application using their WARP - // session. When set to false this application will always require direct IdP - // authentication. This setting always overrides the organization setting for WARP - // authentication. - AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CorsHeaders ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeaders `json:"cors_headers"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The custom error message shown to a user when they are denied access to the - // application. - CustomDenyMessage string `json:"custom_deny_message"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing identity-based rules. - CustomDenyURL string `json:"custom_deny_url"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing non-identity rules. - CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` - // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` - // Enables the binding cookie, which increases security against compromised - // authorization tokens and CSRF attacks. - EnableBindingCookie bool `json:"enable_binding_cookie"` - // Enables the HttpOnly cookie attribute, which increases security against XSS - // attacks. - HTTPOnlyCookieAttribute bool `json:"http_only_cookie_attribute"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - // Enables cookie paths to scope an application's JWT to the application path. If - // disabled, the JWT will scope to the hostname by default - PathCookieAttribute bool `json:"path_cookie_attribute"` - // Sets the SameSite cookie setting, which provides increased security against CSRF - // attacks. - SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` - // List of domains that Access will secure. - SelfHostedDomains []string `json:"self_hosted_domains"` - // Returns a 401 status code when the request is blocked by a Service Auth policy. - ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - // Enables automatic authentication through cloudflared. - SkipInterstitial bool `json:"skip_interstitial"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationGetResponseSelfHostedApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationGetResponseSelfHostedApplicationJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationGetResponseSelfHostedApplication] -type zeroTrustAccessApplicationGetResponseSelfHostedApplicationJSON struct { - Domain apijson.Field - Type apijson.Field - ID apijson.Field - AllowAuthenticateViaWARP apijson.Field - AllowedIdps apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CorsHeaders apijson.Field - CreatedAt apijson.Field - CustomDenyMessage apijson.Field - CustomDenyURL apijson.Field - CustomNonIdentityDenyURL apijson.Field - CustomPages apijson.Field - EnableBindingCookie apijson.Field - HTTPOnlyCookieAttribute apijson.Field - LogoURL apijson.Field - Name apijson.Field - PathCookieAttribute apijson.Field - SameSiteCookieAttribute apijson.Field - SelfHostedDomains apijson.Field - ServiceAuth401Redirect apijson.Field - SessionDuration apijson.Field - SkipInterstitial apijson.Field - Tags apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationGetResponseSelfHostedApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationGetResponseSelfHostedApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationGetResponseSelfHostedApplication) implementsZeroTrustAccessApplicationGetResponse() { -} - -type ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders bool `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods bool `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins bool `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials bool `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders []interface{} `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods []ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethod `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins []interface{} `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge float64 `json:"max_age"` - JSON zeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersJSON `json:"-"` -} - -// zeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeaders] -type zeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersJSON struct { - AllowAllHeaders apijson.Field - AllowAllMethods apijson.Field - AllowAllOrigins apijson.Field - AllowCredentials apijson.Field - AllowedHeaders apijson.Field - AllowedMethods apijson.Field - AllowedOrigins apijson.Field - MaxAge apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeaders) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethod string - -const ( - ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethodGet ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethod = "GET" - ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethodPost ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethod = "POST" - ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethodHead ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethod = "HEAD" - ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethodPut ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethod = "PUT" - ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethodDelete ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethod = "DELETE" - ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethodConnect ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethod = "CONNECT" - ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethodOptions ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethod = "OPTIONS" - ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethodTrace ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethod = "TRACE" - ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethodPatch ZeroTrustAccessApplicationGetResponseSelfHostedApplicationCorsHeadersAllowedMethod = "PATCH" -) - -type ZeroTrustAccessApplicationGetResponseSaaSApplication struct { - // UUID - ID string `json:"id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - SaasApp ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasApp `json:"saas_app"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - // The application type. - Type string `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationGetResponseSaaSApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationGetResponseSaaSApplicationJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationGetResponseSaaSApplication] -type zeroTrustAccessApplicationGetResponseSaaSApplicationJSON struct { - ID apijson.Field - AllowedIdps apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - CustomPages apijson.Field - LogoURL apijson.Field - Name apijson.Field - SaasApp apijson.Field - Tags apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationGetResponseSaaSApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationGetResponseSaaSApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationGetResponseSaaSApplication) implementsZeroTrustAccessApplicationGetResponse() { -} - -// Union satisfied by -// [ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasApp] -// or -// [ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasApp]. -type ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasApp interface { - implementsZeroTrustAccessApplicationGetResponseSaaSApplicationSaasApp() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasApp)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasApp{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasApp{}), - }, - ) -} - -type ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasApp struct { - // Optional identifier indicating the authentication protocol used for the saas - // app. Required for OIDC. Default if unset is "saml" - AuthType ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthType `json:"auth_type"` - // The service provider's endpoint that is responsible for receiving and parsing a - // SAML assertion. - ConsumerServiceURL string `json:"consumer_service_url"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - CustomAttributes ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes `json:"custom_attributes"` - // The URL that the user will be redirected to after a successful login for IDP - // initiated logins. - DefaultRelayState string `json:"default_relay_state"` - // The unique identifier for your SaaS application. - IdpEntityID string `json:"idp_entity_id"` - // The format of the name identifier sent to the SaaS application. - NameIDFormat ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat `json:"name_id_format"` - // A [JSONata](https://jsonata.org/) expression that transforms an application's - // user identities into a NameID value for its SAML assertion. This expression - // should evaluate to a singular string. The output of this expression can override - // the `name_id_format` setting. - NameIDTransformJsonata string `json:"name_id_transform_jsonata"` - // The Access public certificate that will be used to verify your identity. - PublicKey string `json:"public_key"` - // A globally unique name for an identity or service provider. - SpEntityID string `json:"sp_entity_id"` - // The endpoint where your SaaS application will send login requests. - SSOEndpoint string `json:"sso_endpoint"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppJSON `json:"-"` -} - -// zeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasApp] -type zeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppJSON struct { - AuthType apijson.Field - ConsumerServiceURL apijson.Field - CreatedAt apijson.Field - CustomAttributes apijson.Field - DefaultRelayState apijson.Field - IdpEntityID apijson.Field - NameIDFormat apijson.Field - NameIDTransformJsonata apijson.Field - PublicKey apijson.Field - SpEntityID apijson.Field - SSOEndpoint apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasApp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasApp) implementsZeroTrustAccessApplicationGetResponseSaaSApplicationSaasApp() { -} - -// Optional identifier indicating the authentication protocol used for the saas -// app. Required for OIDC. Default if unset is "saml" -type ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthType string - -const ( - ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeSaml ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthType = "saml" - ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthTypeOidc ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppAuthType = "oidc" -) - -type ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes struct { - // The name of the attribute. - Name string `json:"name"` - // A globally unique name for an identity or service provider. - NameFormat ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat `json:"name_format"` - Source ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource `json:"source"` - JSON zeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON `json:"-"` -} - -// zeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes] -type zeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON struct { - Name apijson.Field - NameFormat apijson.Field - Source apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributes) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesJSON) RawJSON() string { - return r.raw -} - -// A globally unique name for an identity or service provider. -type ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat string - -const ( - ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatUnspecified ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" - ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic" - ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatURI ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" -) - -type ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource struct { - // The name of the IdP attribute. - Name string `json:"name"` - JSON zeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON `json:"-"` -} - -// zeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource] -type zeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON struct { - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSource) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppCustomAttributesSourceJSON) RawJSON() string { - return r.raw -} - -// The format of the name identifier sent to the SaaS application. -type ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat string - -const ( - ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatID ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat = "id" - ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormatEmail ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessSamlSaasAppNameIDFormat = "email" -) - -type ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasApp struct { - // The URL where this applications tile redirects users - AppLauncherURL string `json:"app_launcher_url"` - // Identifier of the authentication protocol used for the saas app. Required for - // OIDC. - AuthType ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthType `json:"auth_type"` - // The application client id - ClientID string `json:"client_id"` - // The application client secret, only returned on POST request. - ClientSecret string `json:"client_secret"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The OIDC flows supported by this application - GrantTypes []ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantType `json:"grant_types"` - // A regex to filter Cloudflare groups returned in ID token and userinfo endpoint - GroupFilterRegex string `json:"group_filter_regex"` - // The Access public certificate that will be used to verify your identity. - PublicKey string `json:"public_key"` - // The permitted URL's for Cloudflare to return Authorization codes and Access/ID - // tokens - RedirectURIs []string `json:"redirect_uris"` - // Define the user information shared with access - Scopes []ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppScope `json:"scopes"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppJSON `json:"-"` -} - -// zeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasApp] -type zeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppJSON struct { - AppLauncherURL apijson.Field - AuthType apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - CreatedAt apijson.Field - GrantTypes apijson.Field - GroupFilterRegex apijson.Field - PublicKey apijson.Field - RedirectURIs apijson.Field - Scopes apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasApp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasApp) implementsZeroTrustAccessApplicationGetResponseSaaSApplicationSaasApp() { -} - -// Identifier of the authentication protocol used for the saas app. Required for -// OIDC. -type ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthType string - -const ( - ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeSaml ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthType = "saml" - ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthTypeOidc ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppAuthType = "oidc" -) - -type ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantType string - -const ( - ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCode ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantType = "authorization_code" - ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantTypeAuthorizationCodeWithPkce ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppGrantType = "authorization_code_with_pkce" -) - -type ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppScope string - -const ( - ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppScopeOpenid ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppScope = "openid" - ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppScopeGroups ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppScope = "groups" - ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppScopeEmail ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppScope = "email" - ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppScopeProfile ZeroTrustAccessApplicationGetResponseSaaSApplicationSaasAppAccessOidcSaasAppScope = "profile" -) - -type ZeroTrustAccessApplicationGetResponseBrowserSSHApplication struct { - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain,required"` - // The application type. - Type string `json:"type,required"` - // UUID - ID string `json:"id"` - // When set to true, users can authenticate to this application using their WARP - // session. When set to false this application will always require direct IdP - // authentication. This setting always overrides the organization setting for WARP - // authentication. - AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CorsHeaders ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeaders `json:"cors_headers"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The custom error message shown to a user when they are denied access to the - // application. - CustomDenyMessage string `json:"custom_deny_message"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing identity-based rules. - CustomDenyURL string `json:"custom_deny_url"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing non-identity rules. - CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` - // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` - // Enables the binding cookie, which increases security against compromised - // authorization tokens and CSRF attacks. - EnableBindingCookie bool `json:"enable_binding_cookie"` - // Enables the HttpOnly cookie attribute, which increases security against XSS - // attacks. - HTTPOnlyCookieAttribute bool `json:"http_only_cookie_attribute"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - // Enables cookie paths to scope an application's JWT to the application path. If - // disabled, the JWT will scope to the hostname by default - PathCookieAttribute bool `json:"path_cookie_attribute"` - // Sets the SameSite cookie setting, which provides increased security against CSRF - // attacks. - SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` - // List of domains that Access will secure. - SelfHostedDomains []string `json:"self_hosted_domains"` - // Returns a 401 status code when the request is blocked by a Service Auth policy. - ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - // Enables automatic authentication through cloudflared. - SkipInterstitial bool `json:"skip_interstitial"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationGetResponseBrowserSSHApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationGetResponseBrowserSSHApplicationJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationGetResponseBrowserSSHApplication] -type zeroTrustAccessApplicationGetResponseBrowserSSHApplicationJSON struct { - Domain apijson.Field - Type apijson.Field - ID apijson.Field - AllowAuthenticateViaWARP apijson.Field - AllowedIdps apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CorsHeaders apijson.Field - CreatedAt apijson.Field - CustomDenyMessage apijson.Field - CustomDenyURL apijson.Field - CustomNonIdentityDenyURL apijson.Field - CustomPages apijson.Field - EnableBindingCookie apijson.Field - HTTPOnlyCookieAttribute apijson.Field - LogoURL apijson.Field - Name apijson.Field - PathCookieAttribute apijson.Field - SameSiteCookieAttribute apijson.Field - SelfHostedDomains apijson.Field - ServiceAuth401Redirect apijson.Field - SessionDuration apijson.Field - SkipInterstitial apijson.Field - Tags apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationGetResponseBrowserSSHApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationGetResponseBrowserSSHApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationGetResponseBrowserSSHApplication) implementsZeroTrustAccessApplicationGetResponse() { -} - -type ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders bool `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods bool `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins bool `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials bool `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders []interface{} `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods []ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethod `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins []interface{} `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge float64 `json:"max_age"` - JSON zeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersJSON `json:"-"` -} - -// zeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeaders] -type zeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersJSON struct { - AllowAllHeaders apijson.Field - AllowAllMethods apijson.Field - AllowAllOrigins apijson.Field - AllowCredentials apijson.Field - AllowedHeaders apijson.Field - AllowedMethods apijson.Field - AllowedOrigins apijson.Field - MaxAge apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeaders) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethod string - -const ( - ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethodGet ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "GET" - ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethodPost ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "POST" - ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethodHead ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "HEAD" - ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethodPut ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "PUT" - ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethodDelete ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "DELETE" - ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethodConnect ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "CONNECT" - ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethodOptions ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "OPTIONS" - ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethodTrace ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "TRACE" - ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethodPatch ZeroTrustAccessApplicationGetResponseBrowserSSHApplicationCorsHeadersAllowedMethod = "PATCH" -) - -type ZeroTrustAccessApplicationGetResponseBrowserVncApplication struct { - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain,required"` - // The application type. - Type string `json:"type,required"` - // UUID - ID string `json:"id"` - // When set to true, users can authenticate to this application using their WARP - // session. When set to false this application will always require direct IdP - // authentication. This setting always overrides the organization setting for WARP - // authentication. - AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CorsHeaders ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeaders `json:"cors_headers"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The custom error message shown to a user when they are denied access to the - // application. - CustomDenyMessage string `json:"custom_deny_message"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing identity-based rules. - CustomDenyURL string `json:"custom_deny_url"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing non-identity rules. - CustomNonIdentityDenyURL string `json:"custom_non_identity_deny_url"` - // The custom pages that will be displayed when applicable for this application - CustomPages []string `json:"custom_pages"` - // Enables the binding cookie, which increases security against compromised - // authorization tokens and CSRF attacks. - EnableBindingCookie bool `json:"enable_binding_cookie"` - // Enables the HttpOnly cookie attribute, which increases security against XSS - // attacks. - HTTPOnlyCookieAttribute bool `json:"http_only_cookie_attribute"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - // Enables cookie paths to scope an application's JWT to the application path. If - // disabled, the JWT will scope to the hostname by default - PathCookieAttribute bool `json:"path_cookie_attribute"` - // Sets the SameSite cookie setting, which provides increased security against CSRF - // attacks. - SameSiteCookieAttribute string `json:"same_site_cookie_attribute"` - // List of domains that Access will secure. - SelfHostedDomains []string `json:"self_hosted_domains"` - // Returns a 401 status code when the request is blocked by a Service Auth policy. - ServiceAuth401Redirect bool `json:"service_auth_401_redirect"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - // Enables automatic authentication through cloudflared. - SkipInterstitial bool `json:"skip_interstitial"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationGetResponseBrowserVncApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationGetResponseBrowserVncApplicationJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationGetResponseBrowserVncApplication] -type zeroTrustAccessApplicationGetResponseBrowserVncApplicationJSON struct { - Domain apijson.Field - Type apijson.Field - ID apijson.Field - AllowAuthenticateViaWARP apijson.Field - AllowedIdps apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CorsHeaders apijson.Field - CreatedAt apijson.Field - CustomDenyMessage apijson.Field - CustomDenyURL apijson.Field - CustomNonIdentityDenyURL apijson.Field - CustomPages apijson.Field - EnableBindingCookie apijson.Field - HTTPOnlyCookieAttribute apijson.Field - LogoURL apijson.Field - Name apijson.Field - PathCookieAttribute apijson.Field - SameSiteCookieAttribute apijson.Field - SelfHostedDomains apijson.Field - ServiceAuth401Redirect apijson.Field - SessionDuration apijson.Field - SkipInterstitial apijson.Field - Tags apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationGetResponseBrowserVncApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationGetResponseBrowserVncApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationGetResponseBrowserVncApplication) implementsZeroTrustAccessApplicationGetResponse() { -} - -type ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders bool `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods bool `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins bool `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials bool `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders []interface{} `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods []ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethod `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins []interface{} `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge float64 `json:"max_age"` - JSON zeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersJSON `json:"-"` -} - -// zeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeaders] -type zeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersJSON struct { - AllowAllHeaders apijson.Field - AllowAllMethods apijson.Field - AllowAllOrigins apijson.Field - AllowCredentials apijson.Field - AllowedHeaders apijson.Field - AllowedMethods apijson.Field - AllowedOrigins apijson.Field - MaxAge apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeaders) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethod string - -const ( - ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethodGet ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethod = "GET" - ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethodPost ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethod = "POST" - ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethodHead ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethod = "HEAD" - ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethodPut ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethod = "PUT" - ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethodDelete ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethod = "DELETE" - ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethodConnect ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethod = "CONNECT" - ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethodOptions ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethod = "OPTIONS" - ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethodTrace ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethod = "TRACE" - ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethodPatch ZeroTrustAccessApplicationGetResponseBrowserVncApplicationCorsHeadersAllowedMethod = "PATCH" -) - -type ZeroTrustAccessApplicationGetResponseAppLauncherApplication struct { - // The application type. - Type ZeroTrustAccessApplicationGetResponseAppLauncherApplicationType `json:"type,required"` - // UUID - ID string `json:"id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain"` - // The name of the application. - Name string `json:"name"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationGetResponseAppLauncherApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationGetResponseAppLauncherApplicationJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationGetResponseAppLauncherApplication] -type zeroTrustAccessApplicationGetResponseAppLauncherApplicationJSON struct { - Type apijson.Field - ID apijson.Field - AllowedIdps apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - Name apijson.Field - SessionDuration apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationGetResponseAppLauncherApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationGetResponseAppLauncherApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationGetResponseAppLauncherApplication) implementsZeroTrustAccessApplicationGetResponse() { -} - -// The application type. -type ZeroTrustAccessApplicationGetResponseAppLauncherApplicationType string - -const ( - ZeroTrustAccessApplicationGetResponseAppLauncherApplicationTypeSelfHosted ZeroTrustAccessApplicationGetResponseAppLauncherApplicationType = "self_hosted" - ZeroTrustAccessApplicationGetResponseAppLauncherApplicationTypeSaas ZeroTrustAccessApplicationGetResponseAppLauncherApplicationType = "saas" - ZeroTrustAccessApplicationGetResponseAppLauncherApplicationTypeSSH ZeroTrustAccessApplicationGetResponseAppLauncherApplicationType = "ssh" - ZeroTrustAccessApplicationGetResponseAppLauncherApplicationTypeVnc ZeroTrustAccessApplicationGetResponseAppLauncherApplicationType = "vnc" - ZeroTrustAccessApplicationGetResponseAppLauncherApplicationTypeAppLauncher ZeroTrustAccessApplicationGetResponseAppLauncherApplicationType = "app_launcher" - ZeroTrustAccessApplicationGetResponseAppLauncherApplicationTypeWARP ZeroTrustAccessApplicationGetResponseAppLauncherApplicationType = "warp" - ZeroTrustAccessApplicationGetResponseAppLauncherApplicationTypeBiso ZeroTrustAccessApplicationGetResponseAppLauncherApplicationType = "biso" - ZeroTrustAccessApplicationGetResponseAppLauncherApplicationTypeBookmark ZeroTrustAccessApplicationGetResponseAppLauncherApplicationType = "bookmark" - ZeroTrustAccessApplicationGetResponseAppLauncherApplicationTypeDashSSO ZeroTrustAccessApplicationGetResponseAppLauncherApplicationType = "dash_sso" -) - -type ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplication struct { - // The application type. - Type ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationType `json:"type,required"` - // UUID - ID string `json:"id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain"` - // The name of the application. - Name string `json:"name"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplication] -type zeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationJSON struct { - Type apijson.Field - ID apijson.Field - AllowedIdps apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - Name apijson.Field - SessionDuration apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplication) implementsZeroTrustAccessApplicationGetResponse() { -} - -// The application type. -type ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationType string - -const ( - ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationTypeSelfHosted ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationType = "self_hosted" - ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationTypeSaas ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationType = "saas" - ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationTypeSSH ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationType = "ssh" - ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationTypeVnc ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationType = "vnc" - ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationTypeAppLauncher ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationType = "app_launcher" - ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationTypeWARP ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationType = "warp" - ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationTypeBiso ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationType = "biso" - ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationTypeBookmark ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationType = "bookmark" - ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationTypeDashSSO ZeroTrustAccessApplicationGetResponseDeviceEnrollmentPermissionsApplicationType = "dash_sso" -) - -type ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplication struct { - // The application type. - Type ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationType `json:"type,required"` - // UUID - ID string `json:"id"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps []string `json:"allowed_idps"` - // Audience tag. - Aud string `json:"aud"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The primary hostname and path that Access will secure. If the app is visible in - // the App Launcher dashboard, this is the domain that will be displayed. - Domain string `json:"domain"` - // The name of the application. - Name string `json:"name"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplication] -type zeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationJSON struct { - Type apijson.Field - ID apijson.Field - AllowedIdps apijson.Field - Aud apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - Name apijson.Field - SessionDuration apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplication) implementsZeroTrustAccessApplicationGetResponse() { -} - -// The application type. -type ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationType string - -const ( - ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationTypeSelfHosted ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationType = "self_hosted" - ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationTypeSaas ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationType = "saas" - ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationTypeSSH ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationType = "ssh" - ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationTypeVnc ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationType = "vnc" - ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationTypeAppLauncher ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationType = "app_launcher" - ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationTypeWARP ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationType = "warp" - ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationTypeBiso ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationType = "biso" - ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationTypeBookmark ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationType = "bookmark" - ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationTypeDashSSO ZeroTrustAccessApplicationGetResponseBrowserIsolationPermissionsApplicationType = "dash_sso" -) - -type ZeroTrustAccessApplicationGetResponseBookmarkApplication struct { - // UUID - ID string `json:"id"` - AppLauncherVisible interface{} `json:"app_launcher_visible"` - // Audience tag. - Aud string `json:"aud"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The URL or domain of the bookmark. - Domain interface{} `json:"domain"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the application. - Name string `json:"name"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags []string `json:"tags"` - // The application type. - Type string `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationGetResponseBookmarkApplicationJSON `json:"-"` -} - -// zeroTrustAccessApplicationGetResponseBookmarkApplicationJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationGetResponseBookmarkApplication] -type zeroTrustAccessApplicationGetResponseBookmarkApplicationJSON struct { - ID apijson.Field - AppLauncherVisible apijson.Field - Aud apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - LogoURL apijson.Field - Name apijson.Field - Tags apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationGetResponseBookmarkApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationGetResponseBookmarkApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationGetResponseBookmarkApplication) implementsZeroTrustAccessApplicationGetResponse() { -} - -type ZeroTrustAccessApplicationRevokeTokensResponse = interface{} - -type ZeroTrustAccessApplicationNewParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // When set to true, users can authenticate to this application using their WARP - // session. When set to false this application will always require direct IdP - // authentication. This setting always overrides the organization setting for WARP - // authentication. - AllowAuthenticateViaWARP param.Field[bool] `json:"allow_authenticate_via_warp"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps param.Field[[]string] `json:"allowed_idps"` - AppLauncherVisible param.Field[interface{}] `json:"app_launcher_visible"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` - CorsHeaders param.Field[ZeroTrustAccessApplicationNewParamsCorsHeaders] `json:"cors_headers"` - // The custom error message shown to a user when they are denied access to the - // application. - CustomDenyMessage param.Field[string] `json:"custom_deny_message"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing identity-based rules. - CustomDenyURL param.Field[string] `json:"custom_deny_url"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing non-identity rules. - CustomNonIdentityDenyURL param.Field[string] `json:"custom_non_identity_deny_url"` - // The custom pages that will be displayed when applicable for this application - CustomPages param.Field[[]string] `json:"custom_pages"` - // The URL or domain of the bookmark. - Domain param.Field[interface{}] `json:"domain"` - // Enables the binding cookie, which increases security against compromised - // authorization tokens and CSRF attacks. - EnableBindingCookie param.Field[bool] `json:"enable_binding_cookie"` - // Enables the HttpOnly cookie attribute, which increases security against XSS - // attacks. - HTTPOnlyCookieAttribute param.Field[bool] `json:"http_only_cookie_attribute"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL param.Field[string] `json:"logo_url"` - // The name of the application. - Name param.Field[string] `json:"name"` - // Enables cookie paths to scope an application's JWT to the application path. If - // disabled, the JWT will scope to the hostname by default - PathCookieAttribute param.Field[bool] `json:"path_cookie_attribute"` - SaasApp param.Field[ZeroTrustAccessApplicationNewParamsSaasApp] `json:"saas_app"` - // Sets the SameSite cookie setting, which provides increased security against CSRF - // attacks. - SameSiteCookieAttribute param.Field[string] `json:"same_site_cookie_attribute"` - // List of domains that Access will secure. - SelfHostedDomains param.Field[[]string] `json:"self_hosted_domains"` - // Returns a 401 status code when the request is blocked by a Service Auth policy. - ServiceAuth401Redirect param.Field[bool] `json:"service_auth_401_redirect"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration param.Field[string] `json:"session_duration"` - // Enables automatic authentication through cloudflared. - SkipInterstitial param.Field[bool] `json:"skip_interstitial"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags param.Field[[]string] `json:"tags"` - // The application type. - Type param.Field[string] `json:"type"` -} - -func (r ZeroTrustAccessApplicationNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustAccessApplicationNewParamsCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders param.Field[bool] `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods param.Field[bool] `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins param.Field[bool] `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials param.Field[bool] `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders param.Field[[]interface{}] `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods param.Field[[]ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethod] `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins param.Field[[]interface{}] `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge param.Field[float64] `json:"max_age"` -} - -func (r ZeroTrustAccessApplicationNewParamsCorsHeaders) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethod string - -const ( - ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethodGet ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethod = "GET" - ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethodPost ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethod = "POST" - ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethodHead ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethod = "HEAD" - ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethodPut ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethod = "PUT" - ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethodDelete ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethod = "DELETE" - ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethodConnect ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethod = "CONNECT" - ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethodOptions ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethod = "OPTIONS" - ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethodTrace ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethod = "TRACE" - ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethodPatch ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethod = "PATCH" -) - -// Satisfied by [ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasApp], -// [ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasApp]. -type ZeroTrustAccessApplicationNewParamsSaasApp interface { - implementsZeroTrustAccessApplicationNewParamsSaasApp() -} - -type ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasApp struct { - // Optional identifier indicating the authentication protocol used for the saas - // app. Required for OIDC. Default if unset is "saml" - AuthType param.Field[ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppAuthType] `json:"auth_type"` - // The service provider's endpoint that is responsible for receiving and parsing a - // SAML assertion. - ConsumerServiceURL param.Field[string] `json:"consumer_service_url"` - CustomAttributes param.Field[ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributes] `json:"custom_attributes"` - // The URL that the user will be redirected to after a successful login for IDP - // initiated logins. - DefaultRelayState param.Field[string] `json:"default_relay_state"` - // The unique identifier for your SaaS application. - IdpEntityID param.Field[string] `json:"idp_entity_id"` - // The format of the name identifier sent to the SaaS application. - NameIDFormat param.Field[ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppNameIDFormat] `json:"name_id_format"` - // A [JSONata](https://jsonata.org/) expression that transforms an application's - // user identities into a NameID value for its SAML assertion. This expression - // should evaluate to a singular string. The output of this expression can override - // the `name_id_format` setting. - NameIDTransformJsonata param.Field[string] `json:"name_id_transform_jsonata"` - // The Access public certificate that will be used to verify your identity. - PublicKey param.Field[string] `json:"public_key"` - // A globally unique name for an identity or service provider. - SpEntityID param.Field[string] `json:"sp_entity_id"` - // The endpoint where your SaaS application will send login requests. - SSOEndpoint param.Field[string] `json:"sso_endpoint"` -} - -func (r ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasApp) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasApp) implementsZeroTrustAccessApplicationNewParamsSaasApp() { -} - -// Optional identifier indicating the authentication protocol used for the saas -// app. Required for OIDC. Default if unset is "saml" -type ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppAuthType string - -const ( - ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppAuthTypeSaml ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppAuthType = "saml" - ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppAuthTypeOidc ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppAuthType = "oidc" -) - -type ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributes struct { - // The name of the attribute. - Name param.Field[string] `json:"name"` - // A globally unique name for an identity or service provider. - NameFormat param.Field[ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat] `json:"name_format"` - Source param.Field[ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesSource] `json:"source"` -} - -func (r ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A globally unique name for an identity or service provider. -type ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat string - -const ( - ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatUnspecified ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" - ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic" - ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatURI ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" -) - -type ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesSource struct { - // The name of the IdP attribute. - Name param.Field[string] `json:"name"` -} - -func (r ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesSource) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The format of the name identifier sent to the SaaS application. -type ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppNameIDFormat string - -const ( - ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppNameIDFormatID ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppNameIDFormat = "id" - ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppNameIDFormatEmail ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppNameIDFormat = "email" -) - -type ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasApp struct { - // The URL where this applications tile redirects users - AppLauncherURL param.Field[string] `json:"app_launcher_url"` - // Identifier of the authentication protocol used for the saas app. Required for - // OIDC. - AuthType param.Field[ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppAuthType] `json:"auth_type"` - // The application client id - ClientID param.Field[string] `json:"client_id"` - // The application client secret, only returned on POST request. - ClientSecret param.Field[string] `json:"client_secret"` - // The OIDC flows supported by this application - GrantTypes param.Field[[]ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppGrantType] `json:"grant_types"` - // A regex to filter Cloudflare groups returned in ID token and userinfo endpoint - GroupFilterRegex param.Field[string] `json:"group_filter_regex"` - // The Access public certificate that will be used to verify your identity. - PublicKey param.Field[string] `json:"public_key"` - // The permitted URL's for Cloudflare to return Authorization codes and Access/ID - // tokens - RedirectURIs param.Field[[]string] `json:"redirect_uris"` - // Define the user information shared with access - Scopes param.Field[[]ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppScope] `json:"scopes"` -} - -func (r ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasApp) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasApp) implementsZeroTrustAccessApplicationNewParamsSaasApp() { -} - -// Identifier of the authentication protocol used for the saas app. Required for -// OIDC. -type ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppAuthType string - -const ( - ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppAuthTypeSaml ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppAuthType = "saml" - ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppAuthTypeOidc ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppAuthType = "oidc" -) - -type ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppGrantType string - -const ( - ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppGrantTypeAuthorizationCode ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppGrantType = "authorization_code" - ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppGrantTypeAuthorizationCodeWithPkce ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppGrantType = "authorization_code_with_pkce" -) - -type ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppScope string - -const ( - ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppScopeOpenid ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppScope = "openid" - ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppScopeGroups ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppScope = "groups" - ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppScopeEmail ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppScope = "email" - ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppScopeProfile ZeroTrustAccessApplicationNewParamsSaasAppAccessOidcSaasAppScope = "profile" -) - -type ZeroTrustAccessApplicationNewResponseEnvelope struct { - Errors []ZeroTrustAccessApplicationNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessApplicationNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessApplicationNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessApplicationNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessApplicationNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessApplicationNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustAccessApplicationNewResponseEnvelope] -type zeroTrustAccessApplicationNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessApplicationNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationNewResponseEnvelopeErrors] -type zeroTrustAccessApplicationNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessApplicationNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationNewResponseEnvelopeMessages] -type zeroTrustAccessApplicationNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessApplicationNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessApplicationNewResponseEnvelopeSuccessTrue ZeroTrustAccessApplicationNewResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessApplicationUpdateParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // When set to true, users can authenticate to this application using their WARP - // session. When set to false this application will always require direct IdP - // authentication. This setting always overrides the organization setting for WARP - // authentication. - AllowAuthenticateViaWARP param.Field[bool] `json:"allow_authenticate_via_warp"` - // The identity providers your users can select when connecting to this - // application. Defaults to all IdPs configured in your account. - AllowedIdps param.Field[[]string] `json:"allowed_idps"` - AppLauncherVisible param.Field[interface{}] `json:"app_launcher_visible"` - // When set to `true`, users skip the identity provider selection step during - // login. You must specify only one identity provider in allowed_idps. - AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` - CorsHeaders param.Field[ZeroTrustAccessApplicationUpdateParamsCorsHeaders] `json:"cors_headers"` - // The custom error message shown to a user when they are denied access to the - // application. - CustomDenyMessage param.Field[string] `json:"custom_deny_message"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing identity-based rules. - CustomDenyURL param.Field[string] `json:"custom_deny_url"` - // The custom URL a user is redirected to when they are denied access to the - // application when failing non-identity rules. - CustomNonIdentityDenyURL param.Field[string] `json:"custom_non_identity_deny_url"` - // The custom pages that will be displayed when applicable for this application - CustomPages param.Field[[]string] `json:"custom_pages"` - // The URL or domain of the bookmark. - Domain param.Field[interface{}] `json:"domain"` - // Enables the binding cookie, which increases security against compromised - // authorization tokens and CSRF attacks. - EnableBindingCookie param.Field[bool] `json:"enable_binding_cookie"` - // Enables the HttpOnly cookie attribute, which increases security against XSS - // attacks. - HTTPOnlyCookieAttribute param.Field[bool] `json:"http_only_cookie_attribute"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL param.Field[string] `json:"logo_url"` - // The name of the application. - Name param.Field[string] `json:"name"` - // Enables cookie paths to scope an application's JWT to the application path. If - // disabled, the JWT will scope to the hostname by default - PathCookieAttribute param.Field[bool] `json:"path_cookie_attribute"` - SaasApp param.Field[ZeroTrustAccessApplicationUpdateParamsSaasApp] `json:"saas_app"` - // Sets the SameSite cookie setting, which provides increased security against CSRF - // attacks. - SameSiteCookieAttribute param.Field[string] `json:"same_site_cookie_attribute"` - // List of domains that Access will secure. - SelfHostedDomains param.Field[[]string] `json:"self_hosted_domains"` - // Returns a 401 status code when the request is blocked by a Service Auth policy. - ServiceAuth401Redirect param.Field[bool] `json:"service_auth_401_redirect"` - // The amount of time that tokens issued for this application will be valid. Must - // be in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, - // s, m, h. - SessionDuration param.Field[string] `json:"session_duration"` - // Enables automatic authentication through cloudflared. - SkipInterstitial param.Field[bool] `json:"skip_interstitial"` - // The tags you want assigned to an application. Tags are used to filter - // applications in the App Launcher dashboard. - Tags param.Field[[]string] `json:"tags"` - // The application type. - Type param.Field[string] `json:"type"` -} - -func (r ZeroTrustAccessApplicationUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Identifier -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type ZeroTrustAccessApplicationUpdateParamsAppID interface { - ImplementsZeroTrustAccessApplicationUpdateParamsAppID() -} - -type ZeroTrustAccessApplicationUpdateParamsCorsHeaders struct { - // Allows all HTTP request headers. - AllowAllHeaders param.Field[bool] `json:"allow_all_headers"` - // Allows all HTTP request methods. - AllowAllMethods param.Field[bool] `json:"allow_all_methods"` - // Allows all origins. - AllowAllOrigins param.Field[bool] `json:"allow_all_origins"` - // When set to `true`, includes credentials (cookies, authorization headers, or TLS - // client certificates) with requests. - AllowCredentials param.Field[bool] `json:"allow_credentials"` - // Allowed HTTP request headers. - AllowedHeaders param.Field[[]interface{}] `json:"allowed_headers"` - // Allowed HTTP request methods. - AllowedMethods param.Field[[]ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethod] `json:"allowed_methods"` - // Allowed origins. - AllowedOrigins param.Field[[]interface{}] `json:"allowed_origins"` - // The maximum number of seconds the results of a preflight request can be cached. - MaxAge param.Field[float64] `json:"max_age"` -} - -func (r ZeroTrustAccessApplicationUpdateParamsCorsHeaders) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethod string - -const ( - ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethodGet ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethod = "GET" - ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethodPost ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethod = "POST" - ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethodHead ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethod = "HEAD" - ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethodPut ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethod = "PUT" - ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethodDelete ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethod = "DELETE" - ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethodConnect ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethod = "CONNECT" - ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethodOptions ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethod = "OPTIONS" - ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethodTrace ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethod = "TRACE" - ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethodPatch ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethod = "PATCH" -) - -// Satisfied by [ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasApp], -// [ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasApp]. -type ZeroTrustAccessApplicationUpdateParamsSaasApp interface { - implementsZeroTrustAccessApplicationUpdateParamsSaasApp() -} - -type ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasApp struct { - // Optional identifier indicating the authentication protocol used for the saas - // app. Required for OIDC. Default if unset is "saml" - AuthType param.Field[ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppAuthType] `json:"auth_type"` - // The service provider's endpoint that is responsible for receiving and parsing a - // SAML assertion. - ConsumerServiceURL param.Field[string] `json:"consumer_service_url"` - CustomAttributes param.Field[ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributes] `json:"custom_attributes"` - // The URL that the user will be redirected to after a successful login for IDP - // initiated logins. - DefaultRelayState param.Field[string] `json:"default_relay_state"` - // The unique identifier for your SaaS application. - IdpEntityID param.Field[string] `json:"idp_entity_id"` - // The format of the name identifier sent to the SaaS application. - NameIDFormat param.Field[ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppNameIDFormat] `json:"name_id_format"` - // A [JSONata](https://jsonata.org/) expression that transforms an application's - // user identities into a NameID value for its SAML assertion. This expression - // should evaluate to a singular string. The output of this expression can override - // the `name_id_format` setting. - NameIDTransformJsonata param.Field[string] `json:"name_id_transform_jsonata"` - // The Access public certificate that will be used to verify your identity. - PublicKey param.Field[string] `json:"public_key"` - // A globally unique name for an identity or service provider. - SpEntityID param.Field[string] `json:"sp_entity_id"` - // The endpoint where your SaaS application will send login requests. - SSOEndpoint param.Field[string] `json:"sso_endpoint"` -} - -func (r ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasApp) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasApp) implementsZeroTrustAccessApplicationUpdateParamsSaasApp() { -} - -// Optional identifier indicating the authentication protocol used for the saas -// app. Required for OIDC. Default if unset is "saml" -type ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppAuthType string - -const ( - ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppAuthTypeSaml ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppAuthType = "saml" - ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppAuthTypeOidc ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppAuthType = "oidc" -) - -type ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributes struct { - // The name of the attribute. - Name param.Field[string] `json:"name"` - // A globally unique name for an identity or service provider. - NameFormat param.Field[ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat] `json:"name_format"` - Source param.Field[ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesSource] `json:"source"` -} - -func (r ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributes) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A globally unique name for an identity or service provider. -type ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat string - -const ( - ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatUnspecified ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified" - ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic" - ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatURI ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri" -) - -type ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesSource struct { - // The name of the IdP attribute. - Name param.Field[string] `json:"name"` -} - -func (r ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesSource) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The format of the name identifier sent to the SaaS application. -type ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppNameIDFormat string - -const ( - ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppNameIDFormatID ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppNameIDFormat = "id" - ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppNameIDFormatEmail ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppNameIDFormat = "email" -) - -type ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasApp struct { - // The URL where this applications tile redirects users - AppLauncherURL param.Field[string] `json:"app_launcher_url"` - // Identifier of the authentication protocol used for the saas app. Required for - // OIDC. - AuthType param.Field[ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppAuthType] `json:"auth_type"` - // The application client id - ClientID param.Field[string] `json:"client_id"` - // The application client secret, only returned on POST request. - ClientSecret param.Field[string] `json:"client_secret"` - // The OIDC flows supported by this application - GrantTypes param.Field[[]ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppGrantType] `json:"grant_types"` - // A regex to filter Cloudflare groups returned in ID token and userinfo endpoint - GroupFilterRegex param.Field[string] `json:"group_filter_regex"` - // The Access public certificate that will be used to verify your identity. - PublicKey param.Field[string] `json:"public_key"` - // The permitted URL's for Cloudflare to return Authorization codes and Access/ID - // tokens - RedirectURIs param.Field[[]string] `json:"redirect_uris"` - // Define the user information shared with access - Scopes param.Field[[]ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScope] `json:"scopes"` -} - -func (r ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasApp) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasApp) implementsZeroTrustAccessApplicationUpdateParamsSaasApp() { -} - -// Identifier of the authentication protocol used for the saas app. Required for -// OIDC. -type ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppAuthType string - -const ( - ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppAuthTypeSaml ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppAuthType = "saml" - ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppAuthTypeOidc ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppAuthType = "oidc" -) - -type ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppGrantType string - -const ( - ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppGrantTypeAuthorizationCode ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppGrantType = "authorization_code" - ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppGrantTypeAuthorizationCodeWithPkce ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppGrantType = "authorization_code_with_pkce" -) - -type ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScope string - -const ( - ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScopeOpenid ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScope = "openid" - ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScopeGroups ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScope = "groups" - ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScopeEmail ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScope = "email" - ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScopeProfile ZeroTrustAccessApplicationUpdateParamsSaasAppAccessOidcSaasAppScope = "profile" -) - -type ZeroTrustAccessApplicationUpdateResponseEnvelope struct { - Errors []ZeroTrustAccessApplicationUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessApplicationUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessApplicationUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessApplicationUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessApplicationUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessApplicationUpdateResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustAccessApplicationUpdateResponseEnvelope] -type zeroTrustAccessApplicationUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessApplicationUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationUpdateResponseEnvelopeErrors] -type zeroTrustAccessApplicationUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessApplicationUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationUpdateResponseEnvelopeMessages] -type zeroTrustAccessApplicationUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessApplicationUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessApplicationUpdateResponseEnvelopeSuccessTrue ZeroTrustAccessApplicationUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessApplicationListParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustAccessApplicationListResponseEnvelope struct { - Errors []ZeroTrustAccessApplicationListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessApplicationListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustAccessApplicationListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustAccessApplicationListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustAccessApplicationListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustAccessApplicationListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustAccessApplicationListResponseEnvelope] -type zeroTrustAccessApplicationListResponseEnvelopeJSON 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 *ZeroTrustAccessApplicationListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationListResponseEnvelopeErrors] -type zeroTrustAccessApplicationListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationListResponseEnvelopeMessages] -type zeroTrustAccessApplicationListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessApplicationListResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessApplicationListResponseEnvelopeSuccessTrue ZeroTrustAccessApplicationListResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessApplicationListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustAccessApplicationListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustAccessApplicationListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationListResponseEnvelopeResultInfo] -type zeroTrustAccessApplicationListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationDeleteParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -// Identifier -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type ZeroTrustAccessApplicationDeleteParamsAppID interface { - ImplementsZeroTrustAccessApplicationDeleteParamsAppID() -} - -type ZeroTrustAccessApplicationDeleteResponseEnvelope struct { - Errors []ZeroTrustAccessApplicationDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessApplicationDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessApplicationDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessApplicationDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessApplicationDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessApplicationDeleteResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustAccessApplicationDeleteResponseEnvelope] -type zeroTrustAccessApplicationDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessApplicationDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationDeleteResponseEnvelopeErrors] -type zeroTrustAccessApplicationDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessApplicationDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationDeleteResponseEnvelopeMessages] -type zeroTrustAccessApplicationDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessApplicationDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessApplicationDeleteResponseEnvelopeSuccessTrue ZeroTrustAccessApplicationDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessApplicationGetParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -// Identifier -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type ZeroTrustAccessApplicationGetParamsAppID interface { - ImplementsZeroTrustAccessApplicationGetParamsAppID() -} - -type ZeroTrustAccessApplicationGetResponseEnvelope struct { - Errors []ZeroTrustAccessApplicationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessApplicationGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessApplicationGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessApplicationGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessApplicationGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessApplicationGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustAccessApplicationGetResponseEnvelope] -type zeroTrustAccessApplicationGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessApplicationGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationGetResponseEnvelopeErrors] -type zeroTrustAccessApplicationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessApplicationGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationGetResponseEnvelopeMessages] -type zeroTrustAccessApplicationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessApplicationGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessApplicationGetResponseEnvelopeSuccessTrue ZeroTrustAccessApplicationGetResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessApplicationRevokeTokensParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -// Identifier -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type ZeroTrustAccessApplicationRevokeTokensParamsAppID interface { - ImplementsZeroTrustAccessApplicationRevokeTokensParamsAppID() -} - -type ZeroTrustAccessApplicationRevokeTokensResponseEnvelope struct { - Result ZeroTrustAccessApplicationRevokeTokensResponse `json:"result,nullable"` - Success ZeroTrustAccessApplicationRevokeTokensResponseEnvelopeSuccess `json:"success"` - JSON zeroTrustAccessApplicationRevokeTokensResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessApplicationRevokeTokensResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationRevokeTokensResponseEnvelope] -type zeroTrustAccessApplicationRevokeTokensResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationRevokeTokensResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationRevokeTokensResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationRevokeTokensResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessApplicationRevokeTokensResponseEnvelopeSuccessTrue ZeroTrustAccessApplicationRevokeTokensResponseEnvelopeSuccess = true - ZeroTrustAccessApplicationRevokeTokensResponseEnvelopeSuccessFalse ZeroTrustAccessApplicationRevokeTokensResponseEnvelopeSuccess = false -) diff --git a/zerotrustaccessapplication_test.go b/zerotrustaccessapplication_test.go deleted file mode 100644 index d3cad3df3b2..00000000000 --- a/zerotrustaccessapplication_test.go +++ /dev/null @@ -1,291 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustAccessApplicationNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Applications.New(context.TODO(), cloudflare.ZeroTrustAccessApplicationNewParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - AllowAuthenticateViaWARP: cloudflare.F(true), - AllowedIdps: cloudflare.F([]string{"699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252"}), - AppLauncherVisible: cloudflare.F[any](map[string]interface{}{}), - AutoRedirectToIdentity: cloudflare.F(true), - CorsHeaders: cloudflare.F(cloudflare.ZeroTrustAccessApplicationNewParamsCorsHeaders{ - AllowAllHeaders: cloudflare.F(true), - AllowAllMethods: cloudflare.F(true), - AllowAllOrigins: cloudflare.F(true), - AllowCredentials: cloudflare.F(true), - AllowedHeaders: cloudflare.F([]interface{}{map[string]interface{}{}, map[string]interface{}{}, map[string]interface{}{}}), - AllowedMethods: cloudflare.F([]cloudflare.ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethod{cloudflare.ZeroTrustAccessApplicationNewParamsCorsHeadersAllowedMethodGet}), - AllowedOrigins: cloudflare.F([]interface{}{"https://example.com"}), - MaxAge: cloudflare.F(-1.000000), - }), - CustomDenyMessage: cloudflare.F("string"), - CustomDenyURL: cloudflare.F("string"), - CustomNonIdentityDenyURL: cloudflare.F("string"), - CustomPages: cloudflare.F([]string{"699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252"}), - Domain: cloudflare.F[any]("https://mybookmark.com"), - EnableBindingCookie: cloudflare.F(true), - HTTPOnlyCookieAttribute: cloudflare.F(true), - LogoURL: cloudflare.F("https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg"), - Name: cloudflare.F("Admin Site"), - PathCookieAttribute: cloudflare.F(true), - SaasApp: cloudflare.F[cloudflare.ZeroTrustAccessApplicationNewParamsSaasApp](cloudflare.ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasApp(cloudflare.ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasApp{ - AuthType: cloudflare.F(cloudflare.ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppAuthTypeSaml), - ConsumerServiceURL: cloudflare.F("https://example.com"), - CustomAttributes: cloudflare.F(cloudflare.ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributes{ - Name: cloudflare.F("family_name"), - NameFormat: cloudflare.F(cloudflare.ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic), - Source: cloudflare.F(cloudflare.ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppCustomAttributesSource{ - Name: cloudflare.F("last_name"), - }), - }), - DefaultRelayState: cloudflare.F("https://example.com"), - IdpEntityID: cloudflare.F("https://example.cloudflareaccess.com"), - NameIDFormat: cloudflare.F(cloudflare.ZeroTrustAccessApplicationNewParamsSaasAppAccessSamlSaasAppNameIDFormatID), - NameIDTransformJsonata: cloudflare.F("$substringBefore(email, '@') & '+sandbox@' & $substringAfter(email, '@')"), - PublicKey: cloudflare.F("example unique name"), - SpEntityID: cloudflare.F("example unique name"), - SSOEndpoint: cloudflare.F("https://example.cloudflareaccess.com/cdn-cgi/access/sso/saml/b3f58a2b414e0b51d45c8c2af26fccca0e27c63763c426fa52f98dcf0b3b3bfd"), - })), - SameSiteCookieAttribute: cloudflare.F("strict"), - SelfHostedDomains: cloudflare.F([]string{"test.example.com/admin", "test.anotherexample.com/staff"}), - ServiceAuth401Redirect: cloudflare.F(true), - SessionDuration: cloudflare.F("24h"), - SkipInterstitial: cloudflare.F(true), - Tags: cloudflare.F([]string{"engineers", "engineers", "engineers"}), - Type: cloudflare.F("bookmark"), - }) - 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 TestZeroTrustAccessApplicationUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Applications.Update( - context.TODO(), - shared.UnionString("023e105f4ecef8ad9ca31a8372d0c353"), - cloudflare.ZeroTrustAccessApplicationUpdateParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - AllowAuthenticateViaWARP: cloudflare.F(true), - AllowedIdps: cloudflare.F([]string{"699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252"}), - AppLauncherVisible: cloudflare.F[any](map[string]interface{}{}), - AutoRedirectToIdentity: cloudflare.F(true), - CorsHeaders: cloudflare.F(cloudflare.ZeroTrustAccessApplicationUpdateParamsCorsHeaders{ - AllowAllHeaders: cloudflare.F(true), - AllowAllMethods: cloudflare.F(true), - AllowAllOrigins: cloudflare.F(true), - AllowCredentials: cloudflare.F(true), - AllowedHeaders: cloudflare.F([]interface{}{map[string]interface{}{}, map[string]interface{}{}, map[string]interface{}{}}), - AllowedMethods: cloudflare.F([]cloudflare.ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethod{cloudflare.ZeroTrustAccessApplicationUpdateParamsCorsHeadersAllowedMethodGet}), - AllowedOrigins: cloudflare.F([]interface{}{"https://example.com"}), - MaxAge: cloudflare.F(-1.000000), - }), - CustomDenyMessage: cloudflare.F("string"), - CustomDenyURL: cloudflare.F("string"), - CustomNonIdentityDenyURL: cloudflare.F("string"), - CustomPages: cloudflare.F([]string{"699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252", "699d98642c564d2e855e9661899b7252"}), - Domain: cloudflare.F[any]("https://mybookmark.com"), - EnableBindingCookie: cloudflare.F(true), - HTTPOnlyCookieAttribute: cloudflare.F(true), - LogoURL: cloudflare.F("https://www.cloudflare.com/img/logo-web-badges/cf-logo-on-white-bg.svg"), - Name: cloudflare.F("Admin Site"), - PathCookieAttribute: cloudflare.F(true), - SaasApp: cloudflare.F[cloudflare.ZeroTrustAccessApplicationUpdateParamsSaasApp](cloudflare.ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasApp(cloudflare.ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasApp{ - AuthType: cloudflare.F(cloudflare.ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppAuthTypeSaml), - ConsumerServiceURL: cloudflare.F("https://example.com"), - CustomAttributes: cloudflare.F(cloudflare.ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributes{ - Name: cloudflare.F("family_name"), - NameFormat: cloudflare.F(cloudflare.ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesNameFormatUrnOasisNamesTcSaml2_0AttrnameFormatBasic), - Source: cloudflare.F(cloudflare.ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppCustomAttributesSource{ - Name: cloudflare.F("last_name"), - }), - }), - DefaultRelayState: cloudflare.F("https://example.com"), - IdpEntityID: cloudflare.F("https://example.cloudflareaccess.com"), - NameIDFormat: cloudflare.F(cloudflare.ZeroTrustAccessApplicationUpdateParamsSaasAppAccessSamlSaasAppNameIDFormatID), - NameIDTransformJsonata: cloudflare.F("$substringBefore(email, '@') & '+sandbox@' & $substringAfter(email, '@')"), - PublicKey: cloudflare.F("example unique name"), - SpEntityID: cloudflare.F("example unique name"), - SSOEndpoint: cloudflare.F("https://example.cloudflareaccess.com/cdn-cgi/access/sso/saml/b3f58a2b414e0b51d45c8c2af26fccca0e27c63763c426fa52f98dcf0b3b3bfd"), - })), - SameSiteCookieAttribute: cloudflare.F("strict"), - SelfHostedDomains: cloudflare.F([]string{"test.example.com/admin", "test.anotherexample.com/staff"}), - ServiceAuth401Redirect: cloudflare.F(true), - SessionDuration: cloudflare.F("24h"), - SkipInterstitial: cloudflare.F(true), - Tags: cloudflare.F([]string{"engineers", "engineers", "engineers"}), - Type: cloudflare.F("bookmark"), - }, - ) - 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 TestZeroTrustAccessApplicationListWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Applications.List(context.TODO(), cloudflare.ZeroTrustAccessApplicationListParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }) - 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 TestZeroTrustAccessApplicationDeleteWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Applications.Delete( - context.TODO(), - shared.UnionString("023e105f4ecef8ad9ca31a8372d0c353"), - cloudflare.ZeroTrustAccessApplicationDeleteParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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 TestZeroTrustAccessApplicationGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Applications.Get( - context.TODO(), - shared.UnionString("023e105f4ecef8ad9ca31a8372d0c353"), - cloudflare.ZeroTrustAccessApplicationGetParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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 TestZeroTrustAccessApplicationRevokeTokensWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Applications.RevokeTokens( - context.TODO(), - shared.UnionString("023e105f4ecef8ad9ca31a8372d0c353"), - cloudflare.ZeroTrustAccessApplicationRevokeTokensParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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/zerotrustaccessapplicationca.go b/zerotrustaccessapplicationca.go deleted file mode 100644 index e19362b52c3..00000000000 --- a/zerotrustaccessapplicationca.go +++ /dev/null @@ -1,599 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustAccessApplicationCAService 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 -// [NewZeroTrustAccessApplicationCAService] method instead. -type ZeroTrustAccessApplicationCAService struct { - Options []option.RequestOption -} - -// NewZeroTrustAccessApplicationCAService 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 NewZeroTrustAccessApplicationCAService(opts ...option.RequestOption) (r *ZeroTrustAccessApplicationCAService) { - r = &ZeroTrustAccessApplicationCAService{} - r.Options = opts - return -} - -// Generates a new short-lived certificate CA and public key. -func (r *ZeroTrustAccessApplicationCAService) New(ctx context.Context, uuid string, body ZeroTrustAccessApplicationCANewParams, opts ...option.RequestOption) (res *ZeroTrustAccessApplicationCANewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessApplicationCANewResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if body.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = body.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = body.ZoneID - } - path := fmt.Sprintf("%s/%s/access/apps/%s/ca", accountOrZone, accountOrZoneID, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists short-lived certificate CAs and their public keys. -func (r *ZeroTrustAccessApplicationCAService) List(ctx context.Context, query ZeroTrustAccessApplicationCAListParams, opts ...option.RequestOption) (res *[]ZeroTrustAccessApplicationCAListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessApplicationCAListResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/access/apps/ca", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a short-lived certificate CA. -func (r *ZeroTrustAccessApplicationCAService) Delete(ctx context.Context, uuid string, body ZeroTrustAccessApplicationCADeleteParams, opts ...option.RequestOption) (res *ZeroTrustAccessApplicationCADeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessApplicationCADeleteResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if body.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = body.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = body.ZoneID - } - path := fmt.Sprintf("%s/%s/access/apps/%s/ca", accountOrZone, accountOrZoneID, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a short-lived certificate CA and its public key. -func (r *ZeroTrustAccessApplicationCAService) Get(ctx context.Context, uuid string, query ZeroTrustAccessApplicationCAGetParams, opts ...option.RequestOption) (res *ZeroTrustAccessApplicationCAGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessApplicationCAGetResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/access/apps/%s/ca", accountOrZone, accountOrZoneID, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [ZeroTrustAccessApplicationCANewResponseUnknown] or -// [shared.UnionString]. -type ZeroTrustAccessApplicationCANewResponse interface { - ImplementsZeroTrustAccessApplicationCANewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationCANewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustAccessApplicationCAListResponse struct { - // The ID of the CA. - ID string `json:"id"` - // The Application Audience (AUD) tag. Identifies the application associated with - // the CA. - Aud string `json:"aud"` - // The public key to add to your SSH server configuration. - PublicKey string `json:"public_key"` - JSON zeroTrustAccessApplicationCAListResponseJSON `json:"-"` -} - -// zeroTrustAccessApplicationCAListResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessApplicationCAListResponse] -type zeroTrustAccessApplicationCAListResponseJSON struct { - ID apijson.Field - Aud apijson.Field - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationCAListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationCAListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationCADeleteResponse struct { - // The ID of the CA. - ID string `json:"id"` - JSON zeroTrustAccessApplicationCADeleteResponseJSON `json:"-"` -} - -// zeroTrustAccessApplicationCADeleteResponseJSON contains the JSON metadata for -// the struct [ZeroTrustAccessApplicationCADeleteResponse] -type zeroTrustAccessApplicationCADeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationCADeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationCADeleteResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [ZeroTrustAccessApplicationCAGetResponseUnknown] or -// [shared.UnionString]. -type ZeroTrustAccessApplicationCAGetResponse interface { - ImplementsZeroTrustAccessApplicationCAGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationCAGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustAccessApplicationCANewParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustAccessApplicationCANewResponseEnvelope struct { - Errors []ZeroTrustAccessApplicationCANewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessApplicationCANewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessApplicationCANewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessApplicationCANewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessApplicationCANewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessApplicationCANewResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustAccessApplicationCANewResponseEnvelope] -type zeroTrustAccessApplicationCANewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationCANewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationCANewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationCANewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationCANewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessApplicationCANewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationCANewResponseEnvelopeErrors] -type zeroTrustAccessApplicationCANewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationCANewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationCANewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationCANewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationCANewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessApplicationCANewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationCANewResponseEnvelopeMessages] -type zeroTrustAccessApplicationCANewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationCANewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationCANewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessApplicationCANewResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessApplicationCANewResponseEnvelopeSuccessTrue ZeroTrustAccessApplicationCANewResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessApplicationCAListParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustAccessApplicationCAListResponseEnvelope struct { - Errors []ZeroTrustAccessApplicationCAListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessApplicationCAListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustAccessApplicationCAListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustAccessApplicationCAListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustAccessApplicationCAListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustAccessApplicationCAListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessApplicationCAListResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustAccessApplicationCAListResponseEnvelope] -type zeroTrustAccessApplicationCAListResponseEnvelopeJSON 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 *ZeroTrustAccessApplicationCAListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationCAListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationCAListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationCAListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessApplicationCAListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationCAListResponseEnvelopeErrors] -type zeroTrustAccessApplicationCAListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationCAListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationCAListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationCAListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationCAListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessApplicationCAListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationCAListResponseEnvelopeMessages] -type zeroTrustAccessApplicationCAListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationCAListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationCAListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessApplicationCAListResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessApplicationCAListResponseEnvelopeSuccessTrue ZeroTrustAccessApplicationCAListResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessApplicationCAListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustAccessApplicationCAListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustAccessApplicationCAListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationCAListResponseEnvelopeResultInfo] -type zeroTrustAccessApplicationCAListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationCAListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationCAListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationCADeleteParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustAccessApplicationCADeleteResponseEnvelope struct { - Errors []ZeroTrustAccessApplicationCADeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessApplicationCADeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessApplicationCADeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessApplicationCADeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessApplicationCADeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessApplicationCADeleteResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationCADeleteResponseEnvelope] -type zeroTrustAccessApplicationCADeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationCADeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationCADeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationCADeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationCADeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessApplicationCADeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationCADeleteResponseEnvelopeErrors] -type zeroTrustAccessApplicationCADeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationCADeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationCADeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationCADeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationCADeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessApplicationCADeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationCADeleteResponseEnvelopeMessages] -type zeroTrustAccessApplicationCADeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationCADeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationCADeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessApplicationCADeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessApplicationCADeleteResponseEnvelopeSuccessTrue ZeroTrustAccessApplicationCADeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessApplicationCAGetParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustAccessApplicationCAGetResponseEnvelope struct { - Errors []ZeroTrustAccessApplicationCAGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessApplicationCAGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessApplicationCAGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessApplicationCAGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessApplicationCAGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessApplicationCAGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustAccessApplicationCAGetResponseEnvelope] -type zeroTrustAccessApplicationCAGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationCAGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationCAGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationCAGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationCAGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessApplicationCAGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationCAGetResponseEnvelopeErrors] -type zeroTrustAccessApplicationCAGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationCAGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationCAGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationCAGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationCAGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessApplicationCAGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationCAGetResponseEnvelopeMessages] -type zeroTrustAccessApplicationCAGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationCAGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationCAGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessApplicationCAGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessApplicationCAGetResponseEnvelopeSuccessTrue ZeroTrustAccessApplicationCAGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustaccessapplicationca_test.go b/zerotrustaccessapplicationca_test.go deleted file mode 100644 index 250d4774850..00000000000 --- a/zerotrustaccessapplicationca_test.go +++ /dev/null @@ -1,134 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustAccessApplicationCANewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Applications.CAs.New( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustAccessApplicationCANewParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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 TestZeroTrustAccessApplicationCAListWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Applications.CAs.List(context.TODO(), cloudflare.ZeroTrustAccessApplicationCAListParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }) - 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 TestZeroTrustAccessApplicationCADeleteWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Applications.CAs.Delete( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustAccessApplicationCADeleteParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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 TestZeroTrustAccessApplicationCAGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Applications.CAs.Get( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustAccessApplicationCAGetParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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/zerotrustaccessapplicationpolicy.go b/zerotrustaccessapplicationpolicy.go deleted file mode 100644 index 8fa9407aa16..00000000000 --- a/zerotrustaccessapplicationpolicy.go +++ /dev/null @@ -1,15611 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustAccessApplicationPolicyService 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 -// [NewZeroTrustAccessApplicationPolicyService] method instead. -type ZeroTrustAccessApplicationPolicyService struct { - Options []option.RequestOption -} - -// NewZeroTrustAccessApplicationPolicyService 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 NewZeroTrustAccessApplicationPolicyService(opts ...option.RequestOption) (r *ZeroTrustAccessApplicationPolicyService) { - r = &ZeroTrustAccessApplicationPolicyService{} - r.Options = opts - return -} - -// Create a new Access policy for an application. -func (r *ZeroTrustAccessApplicationPolicyService) New(ctx context.Context, uuid string, params ZeroTrustAccessApplicationPolicyNewParams, opts ...option.RequestOption) (res *ZeroTrustAccessApplicationPolicyNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessApplicationPolicyNewResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/access/apps/%s/policies", accountOrZone, accountOrZoneID, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update a configured Access policy. -func (r *ZeroTrustAccessApplicationPolicyService) Update(ctx context.Context, uuid1 string, uuid string, params ZeroTrustAccessApplicationPolicyUpdateParams, opts ...option.RequestOption) (res *ZeroTrustAccessApplicationPolicyUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessApplicationPolicyUpdateResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/access/apps/%s/policies/%s", accountOrZone, accountOrZoneID, uuid1, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists Access policies configured for an application. -func (r *ZeroTrustAccessApplicationPolicyService) List(ctx context.Context, uuid string, query ZeroTrustAccessApplicationPolicyListParams, opts ...option.RequestOption) (res *[]ZeroTrustAccessApplicationPolicyListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessApplicationPolicyListResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/access/apps/%s/policies", accountOrZone, accountOrZoneID, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete an Access policy. -func (r *ZeroTrustAccessApplicationPolicyService) Delete(ctx context.Context, uuid1 string, uuid string, body ZeroTrustAccessApplicationPolicyDeleteParams, opts ...option.RequestOption) (res *ZeroTrustAccessApplicationPolicyDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessApplicationPolicyDeleteResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if body.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = body.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = body.ZoneID - } - path := fmt.Sprintf("%s/%s/access/apps/%s/policies/%s", accountOrZone, accountOrZoneID, uuid1, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a single Access policy. -func (r *ZeroTrustAccessApplicationPolicyService) Get(ctx context.Context, uuid1 string, uuid string, query ZeroTrustAccessApplicationPolicyGetParams, opts ...option.RequestOption) (res *ZeroTrustAccessApplicationPolicyGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessApplicationPolicyGetResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/access/apps/%s/policies/%s", accountOrZone, accountOrZoneID, uuid1, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustAccessApplicationPolicyNewResponse struct { - // UUID - ID string `json:"id"` - // Administrators who can approve a temporary authentication request. - ApprovalGroups []ZeroTrustAccessApplicationPolicyNewResponseApprovalGroup `json:"approval_groups"` - // Requires the user to request access from an administrator at the start of each - // session. - ApprovalRequired bool `json:"approval_required"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The action Access will take if a user matches this policy. - Decision ZeroTrustAccessApplicationPolicyNewResponseDecision `json:"decision"` - // Rules evaluated with a NOT logical operator. To match the policy, a user cannot - // meet any of the Exclude rules. - Exclude []ZeroTrustAccessApplicationPolicyNewResponseExclude `json:"exclude"` - // Rules evaluated with an OR logical operator. A user needs to meet only one of - // the Include rules. - Include []ZeroTrustAccessApplicationPolicyNewResponseInclude `json:"include"` - // Require this application to be served in an isolated browser for users matching - // this policy. 'Client Web Isolation' must be on for the account in order to use - // this feature. - IsolationRequired bool `json:"isolation_required"` - // The name of the Access policy. - Name string `json:"name"` - // The order of execution for this policy. Must be unique for each policy. - Precedence int64 `json:"precedence"` - // A custom message that will appear on the purpose justification screen. - PurposeJustificationPrompt string `json:"purpose_justification_prompt"` - // Require users to enter a justification when they log in to the application. - PurposeJustificationRequired bool `json:"purpose_justification_required"` - // Rules evaluated with an AND logical operator. To match the policy, a user must - // meet all of the Require rules. - Require []ZeroTrustAccessApplicationPolicyNewResponseRequire `json:"require"` - // The amount of time that tokens issued for the application will be valid. Must be - // in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, - // m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationPolicyNewResponseJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseJSON contains the JSON metadata for -// the struct [ZeroTrustAccessApplicationPolicyNewResponse] -type zeroTrustAccessApplicationPolicyNewResponseJSON struct { - ID apijson.Field - ApprovalGroups apijson.Field - ApprovalRequired apijson.Field - CreatedAt apijson.Field - Decision apijson.Field - Exclude apijson.Field - Include apijson.Field - IsolationRequired apijson.Field - Name apijson.Field - Precedence apijson.Field - PurposeJustificationPrompt apijson.Field - PurposeJustificationRequired apijson.Field - Require apijson.Field - SessionDuration apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseJSON) RawJSON() string { - return r.raw -} - -// A group of email addresses that can approve a temporary authentication request. -type ZeroTrustAccessApplicationPolicyNewResponseApprovalGroup struct { - // The number of approvals needed to obtain access. - ApprovalsNeeded float64 `json:"approvals_needed,required"` - // A list of emails that can approve the access request. - EmailAddresses []interface{} `json:"email_addresses"` - // The UUID of an re-usable email list. - EmailListUUID string `json:"email_list_uuid"` - JSON zeroTrustAccessApplicationPolicyNewResponseApprovalGroupJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseApprovalGroupJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseApprovalGroup] -type zeroTrustAccessApplicationPolicyNewResponseApprovalGroupJSON struct { - ApprovalsNeeded apijson.Field - EmailAddresses apijson.Field - EmailListUUID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseApprovalGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseApprovalGroupJSON) RawJSON() string { - return r.raw -} - -// The action Access will take if a user matches this policy. -type ZeroTrustAccessApplicationPolicyNewResponseDecision string - -const ( - ZeroTrustAccessApplicationPolicyNewResponseDecisionAllow ZeroTrustAccessApplicationPolicyNewResponseDecision = "allow" - ZeroTrustAccessApplicationPolicyNewResponseDecisionDeny ZeroTrustAccessApplicationPolicyNewResponseDecision = "deny" - ZeroTrustAccessApplicationPolicyNewResponseDecisionNonIdentity ZeroTrustAccessApplicationPolicyNewResponseDecision = "non_identity" - ZeroTrustAccessApplicationPolicyNewResponseDecisionBypass ZeroTrustAccessApplicationPolicyNewResponseDecision = "bypass" -) - -// Matches a specific email. -// -// Union satisfied by -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailRule], -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailListRule], -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDomainRule], -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEveryoneRule], -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPRule], -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPListRule], -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessCertificateRule], -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAccessGroupRule], -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAzureGroupRule], -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGsuiteGroupRule], -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessOktaGroupRule], -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessSamlGroupRule], -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessExternalEvaluationRule], -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessCountryRule], -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAuthenticationMethodRule] -// or [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDevicePostureRule]. -type ZeroTrustAccessApplicationPolicyNewResponseExclude interface { - implementsZeroTrustAccessApplicationPolicyNewResponseExclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationPolicyNewResponseExclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailRule struct { - Email ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailRuleEmailJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailRuleEmail] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailListRule struct { - EmailList ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailListRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailListRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailListRuleEmailList] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDomainRule struct { - EmailDomain ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessDomainRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDomainRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessDomainRuleEmailDomainJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDomainRuleEmailDomain] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEveryoneRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEveryoneRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPRule struct { - IP ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPRuleIPJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPRuleIP] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPListRule struct { - IPList ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPListRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPListRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPListRuleIPListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPListRuleIPList] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessCertificateRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessCertificateRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -// Matches an Access group. -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAccessGroupRule struct { - Group ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAccessGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAccessGroupRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAccessGroupRuleGroupJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAccessGroupRuleGroup] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAzureGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAzureGroupRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAzureGroupRuleAzureAdJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAzureGroupRuleAzureAd] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGitHubOrganizationRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessGsuiteGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGsuiteGroupRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessGsuiteGroupRuleGsuiteJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessOktaGroupRule struct { - Okta ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessOktaGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessOktaGroupRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessOktaGroupRuleOktaJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessOktaGroupRuleOkta] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessSamlGroupRule struct { - Saml ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessSamlGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessSamlGroupRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessSamlGroupRuleSamlJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessSamlGroupRuleSaml] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessServiceTokenRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessServiceTokenRuleServiceToken] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAnyValidServiceTokenRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessExternalEvaluationRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessCountryRule struct { - Geo ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessCountryRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessCountryRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessCountryRuleGeoJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessCountryRuleGeo] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAuthenticationMethodRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessDevicePostureRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDevicePostureRule] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyNewResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseExcludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseExcludeAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessApplicationPolicyNewResponseExcludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseExcludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseExcludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailRule], -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailListRule], -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDomainRule], -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEveryoneRule], -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPRule], -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPListRule], -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessCertificateRule], -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAccessGroupRule], -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAzureGroupRule], -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGsuiteGroupRule], -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessOktaGroupRule], -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessSamlGroupRule], -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessExternalEvaluationRule], -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessCountryRule], -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAuthenticationMethodRule] -// or [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDevicePostureRule]. -type ZeroTrustAccessApplicationPolicyNewResponseInclude interface { - implementsZeroTrustAccessApplicationPolicyNewResponseInclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationPolicyNewResponseInclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailRule struct { - Email ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailRuleEmailJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailRuleEmail] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailListRule struct { - EmailList ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailListRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailListRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailListRuleEmailList] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDomainRule struct { - EmailDomain ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessDomainRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDomainRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessDomainRuleEmailDomainJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDomainRuleEmailDomain] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEveryoneRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEveryoneRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPRule struct { - IP ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPRuleIPJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPRuleIP] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPListRule struct { - IPList ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPListRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPListRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPListRuleIPListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPListRuleIPList] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessCertificateRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessCertificateRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -// Matches an Access group. -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAccessGroupRule struct { - Group ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAccessGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAccessGroupRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAccessGroupRuleGroupJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAccessGroupRuleGroup] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAzureGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAzureGroupRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAzureGroupRuleAzureAdJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAzureGroupRuleAzureAd] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGitHubOrganizationRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessGsuiteGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGsuiteGroupRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessGsuiteGroupRuleGsuiteJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessOktaGroupRule struct { - Okta ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessOktaGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessOktaGroupRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessOktaGroupRuleOktaJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessOktaGroupRuleOkta] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessSamlGroupRule struct { - Saml ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessSamlGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessSamlGroupRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessSamlGroupRuleSamlJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessSamlGroupRuleSaml] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessServiceTokenRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessServiceTokenRuleServiceToken] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAnyValidServiceTokenRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessExternalEvaluationRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessCountryRule struct { - Geo ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessCountryRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessCountryRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessCountryRuleGeoJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessCountryRuleGeo] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAuthenticationMethodRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessDevicePostureRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDevicePostureRule] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyNewResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseIncludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseIncludeAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessApplicationPolicyNewResponseIncludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseIncludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseIncludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailRule], -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailListRule], -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDomainRule], -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEveryoneRule], -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPRule], -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPListRule], -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessCertificateRule], -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAccessGroupRule], -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAzureGroupRule], -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGitHubOrganizationRule], -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGsuiteGroupRule], -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessOktaGroupRule], -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessSamlGroupRule], -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessExternalEvaluationRule], -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessCountryRule], -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAuthenticationMethodRule] -// or [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDevicePostureRule]. -type ZeroTrustAccessApplicationPolicyNewResponseRequire interface { - implementsZeroTrustAccessApplicationPolicyNewResponseRequire() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationPolicyNewResponseRequire)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailRule struct { - Email ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailRuleEmailJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailRuleEmail] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailListRule struct { - EmailList ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailListRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailListRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailListRuleEmailList] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDomainRule struct { - EmailDomain ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessDomainRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDomainRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDomainRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessDomainRuleEmailDomainJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDomainRuleEmailDomain] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessEveryoneRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEveryoneRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -// Matches an IP address block. -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPRule struct { - IP ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessIPRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessIPRuleIPJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPRuleIP] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPListRule struct { - IPList ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessIPListRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPListRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPListRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessIPListRuleIPListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPListRuleIPList] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessCertificateRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessCertificateRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -// Matches an Access group. -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAccessGroupRule struct { - Group ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessAccessGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAccessGroupRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessAccessGroupRuleGroupJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAccessGroupRuleGroup] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessAzureGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAzureGroupRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessAzureGroupRuleAzureAdJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAzureGroupRuleAzureAd] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGitHubOrganizationRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessGsuiteGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGsuiteGroupRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessGsuiteGroupRuleGsuiteJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessOktaGroupRule struct { - Okta ZeroTrustAccessApplicationPolicyNewResponseRequireAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessOktaGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessOktaGroupRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessOktaGroupRuleOktaJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessOktaGroupRuleOkta] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessSamlGroupRule struct { - Saml ZeroTrustAccessApplicationPolicyNewResponseRequireAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessSamlGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessSamlGroupRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessSamlGroupRuleSamlJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessSamlGroupRuleSaml] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessApplicationPolicyNewResponseRequireAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessServiceTokenRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessServiceTokenRuleServiceToken] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAnyValidServiceTokenRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessApplicationPolicyNewResponseRequireAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessExternalEvaluationRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessCountryRule struct { - Geo ZeroTrustAccessApplicationPolicyNewResponseRequireAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessCountryRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessCountryRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessCountryRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessCountryRuleGeoJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessCountryRuleGeo] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAuthenticationMethodRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessDevicePostureRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDevicePostureRule] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyNewResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseRequireAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseRequireAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessApplicationPolicyNewResponseRequireAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseRequireAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseRequireAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationPolicyUpdateResponse struct { - // UUID - ID string `json:"id"` - // Administrators who can approve a temporary authentication request. - ApprovalGroups []ZeroTrustAccessApplicationPolicyUpdateResponseApprovalGroup `json:"approval_groups"` - // Requires the user to request access from an administrator at the start of each - // session. - ApprovalRequired bool `json:"approval_required"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The action Access will take if a user matches this policy. - Decision ZeroTrustAccessApplicationPolicyUpdateResponseDecision `json:"decision"` - // Rules evaluated with a NOT logical operator. To match the policy, a user cannot - // meet any of the Exclude rules. - Exclude []ZeroTrustAccessApplicationPolicyUpdateResponseExclude `json:"exclude"` - // Rules evaluated with an OR logical operator. A user needs to meet only one of - // the Include rules. - Include []ZeroTrustAccessApplicationPolicyUpdateResponseInclude `json:"include"` - // Require this application to be served in an isolated browser for users matching - // this policy. 'Client Web Isolation' must be on for the account in order to use - // this feature. - IsolationRequired bool `json:"isolation_required"` - // The name of the Access policy. - Name string `json:"name"` - // The order of execution for this policy. Must be unique for each policy. - Precedence int64 `json:"precedence"` - // A custom message that will appear on the purpose justification screen. - PurposeJustificationPrompt string `json:"purpose_justification_prompt"` - // Require users to enter a justification when they log in to the application. - PurposeJustificationRequired bool `json:"purpose_justification_required"` - // Rules evaluated with an AND logical operator. To match the policy, a user must - // meet all of the Require rules. - Require []ZeroTrustAccessApplicationPolicyUpdateResponseRequire `json:"require"` - // The amount of time that tokens issued for the application will be valid. Must be - // in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, - // m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseJSON contains the JSON metadata -// for the struct [ZeroTrustAccessApplicationPolicyUpdateResponse] -type zeroTrustAccessApplicationPolicyUpdateResponseJSON struct { - ID apijson.Field - ApprovalGroups apijson.Field - ApprovalRequired apijson.Field - CreatedAt apijson.Field - Decision apijson.Field - Exclude apijson.Field - Include apijson.Field - IsolationRequired apijson.Field - Name apijson.Field - Precedence apijson.Field - PurposeJustificationPrompt apijson.Field - PurposeJustificationRequired apijson.Field - Require apijson.Field - SessionDuration apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// A group of email addresses that can approve a temporary authentication request. -type ZeroTrustAccessApplicationPolicyUpdateResponseApprovalGroup struct { - // The number of approvals needed to obtain access. - ApprovalsNeeded float64 `json:"approvals_needed,required"` - // A list of emails that can approve the access request. - EmailAddresses []interface{} `json:"email_addresses"` - // The UUID of an re-usable email list. - EmailListUUID string `json:"email_list_uuid"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseApprovalGroupJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseApprovalGroupJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseApprovalGroup] -type zeroTrustAccessApplicationPolicyUpdateResponseApprovalGroupJSON struct { - ApprovalsNeeded apijson.Field - EmailAddresses apijson.Field - EmailListUUID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseApprovalGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseApprovalGroupJSON) RawJSON() string { - return r.raw -} - -// The action Access will take if a user matches this policy. -type ZeroTrustAccessApplicationPolicyUpdateResponseDecision string - -const ( - ZeroTrustAccessApplicationPolicyUpdateResponseDecisionAllow ZeroTrustAccessApplicationPolicyUpdateResponseDecision = "allow" - ZeroTrustAccessApplicationPolicyUpdateResponseDecisionDeny ZeroTrustAccessApplicationPolicyUpdateResponseDecision = "deny" - ZeroTrustAccessApplicationPolicyUpdateResponseDecisionNonIdentity ZeroTrustAccessApplicationPolicyUpdateResponseDecision = "non_identity" - ZeroTrustAccessApplicationPolicyUpdateResponseDecisionBypass ZeroTrustAccessApplicationPolicyUpdateResponseDecision = "bypass" -) - -// Matches a specific email. -// -// Union satisfied by -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailListRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDomainRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEveryoneRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPListRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCertificateRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAccessGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAzureGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGsuiteGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessOktaGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessSamlGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessExternalEvaluationRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCountryRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAuthenticationMethodRule] -// or -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDevicePostureRule]. -type ZeroTrustAccessApplicationPolicyUpdateResponseExclude interface { - implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationPolicyUpdateResponseExclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailRule struct { - Email ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailRuleEmailJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailRuleEmail] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailListRule struct { - EmailList ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailListRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailListRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailListRuleEmailList] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDomainRule struct { - EmailDomain ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDomainRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDomainRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDomainRuleEmailDomainJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDomainRuleEmailDomain] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEveryoneRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEveryoneRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPRule struct { - IP ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPRuleIPJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPRuleIP] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPListRule struct { - IPList ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPListRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPListRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPListRuleIPListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPListRuleIPList] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCertificateRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCertificateRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -// Matches an Access group. -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAccessGroupRule struct { - Group ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAccessGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAccessGroupRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAccessGroupRuleGroupJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAccessGroupRuleGroup] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAzureGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAzureGroupRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAzureGroupRuleAzureAdJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAzureGroupRuleAzureAd] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGitHubOrganizationRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGsuiteGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGsuiteGroupRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGsuiteGroupRuleGsuiteJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessOktaGroupRule struct { - Okta ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessOktaGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessOktaGroupRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessOktaGroupRuleOktaJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessOktaGroupRuleOkta] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessSamlGroupRule struct { - Saml ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessSamlGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessSamlGroupRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessSamlGroupRuleSamlJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessSamlGroupRuleSaml] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessServiceTokenRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessServiceTokenRuleServiceToken] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAnyValidServiceTokenRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessExternalEvaluationRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCountryRule struct { - Geo ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCountryRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCountryRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCountryRuleGeoJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCountryRuleGeo] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAuthenticationMethodRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDevicePostureRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDevicePostureRule] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseExcludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailListRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDomainRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEveryoneRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPListRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCertificateRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAccessGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAzureGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGsuiteGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessOktaGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessSamlGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessExternalEvaluationRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCountryRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAuthenticationMethodRule] -// or -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDevicePostureRule]. -type ZeroTrustAccessApplicationPolicyUpdateResponseInclude interface { - implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationPolicyUpdateResponseInclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailRule struct { - Email ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailRuleEmailJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailRuleEmail] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailListRule struct { - EmailList ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailListRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailListRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailListRuleEmailList] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDomainRule struct { - EmailDomain ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDomainRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDomainRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDomainRuleEmailDomainJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDomainRuleEmailDomain] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEveryoneRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEveryoneRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPRule struct { - IP ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPRuleIPJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPRuleIP] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPListRule struct { - IPList ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPListRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPListRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPListRuleIPListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPListRuleIPList] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCertificateRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCertificateRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -// Matches an Access group. -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAccessGroupRule struct { - Group ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAccessGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAccessGroupRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAccessGroupRuleGroupJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAccessGroupRuleGroup] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAzureGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAzureGroupRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAzureGroupRuleAzureAdJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAzureGroupRuleAzureAd] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGitHubOrganizationRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGsuiteGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGsuiteGroupRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGsuiteGroupRuleGsuiteJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessOktaGroupRule struct { - Okta ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessOktaGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessOktaGroupRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessOktaGroupRuleOktaJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessOktaGroupRuleOkta] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessSamlGroupRule struct { - Saml ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessSamlGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessSamlGroupRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessSamlGroupRuleSamlJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessSamlGroupRuleSaml] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessServiceTokenRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessServiceTokenRuleServiceToken] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAnyValidServiceTokenRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessExternalEvaluationRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCountryRule struct { - Geo ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCountryRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCountryRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCountryRuleGeoJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCountryRuleGeo] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAuthenticationMethodRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDevicePostureRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDevicePostureRule] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseIncludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailListRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDomainRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEveryoneRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPListRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCertificateRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAccessGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAzureGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGitHubOrganizationRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGsuiteGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessOktaGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessSamlGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessExternalEvaluationRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCountryRule], -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAuthenticationMethodRule] -// or -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDevicePostureRule]. -type ZeroTrustAccessApplicationPolicyUpdateResponseRequire interface { - implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationPolicyUpdateResponseRequire)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailRule struct { - Email ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailRuleEmailJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailRuleEmail] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailListRule struct { - EmailList ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailListRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailListRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailListRuleEmailList] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDomainRule struct { - EmailDomain ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDomainRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDomainRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDomainRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDomainRuleEmailDomainJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDomainRuleEmailDomain] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEveryoneRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEveryoneRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -// Matches an IP address block. -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPRule struct { - IP ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPRuleIPJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPRuleIP] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPListRule struct { - IPList ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPListRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPListRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPListRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPListRuleIPListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPListRuleIPList] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCertificateRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCertificateRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -// Matches an Access group. -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAccessGroupRule struct { - Group ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAccessGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAccessGroupRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAccessGroupRuleGroupJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAccessGroupRuleGroup] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAzureGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAzureGroupRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAzureGroupRuleAzureAdJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAzureGroupRuleAzureAd] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGitHubOrganizationRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGsuiteGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGsuiteGroupRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGsuiteGroupRuleGsuiteJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessOktaGroupRule struct { - Okta ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessOktaGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessOktaGroupRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessOktaGroupRuleOktaJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessOktaGroupRuleOkta] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessSamlGroupRule struct { - Saml ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessSamlGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessSamlGroupRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessSamlGroupRuleSamlJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessSamlGroupRuleSaml] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessServiceTokenRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessServiceTokenRuleServiceToken] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAnyValidServiceTokenRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessExternalEvaluationRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCountryRule struct { - Geo ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCountryRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCountryRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCountryRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCountryRuleGeoJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCountryRuleGeo] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAuthenticationMethodRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDevicePostureRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDevicePostureRule] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyUpdateResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseRequireAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationPolicyListResponse struct { - // UUID - ID string `json:"id"` - // Administrators who can approve a temporary authentication request. - ApprovalGroups []ZeroTrustAccessApplicationPolicyListResponseApprovalGroup `json:"approval_groups"` - // Requires the user to request access from an administrator at the start of each - // session. - ApprovalRequired bool `json:"approval_required"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The action Access will take if a user matches this policy. - Decision ZeroTrustAccessApplicationPolicyListResponseDecision `json:"decision"` - // Rules evaluated with a NOT logical operator. To match the policy, a user cannot - // meet any of the Exclude rules. - Exclude []ZeroTrustAccessApplicationPolicyListResponseExclude `json:"exclude"` - // Rules evaluated with an OR logical operator. A user needs to meet only one of - // the Include rules. - Include []ZeroTrustAccessApplicationPolicyListResponseInclude `json:"include"` - // Require this application to be served in an isolated browser for users matching - // this policy. 'Client Web Isolation' must be on for the account in order to use - // this feature. - IsolationRequired bool `json:"isolation_required"` - // The name of the Access policy. - Name string `json:"name"` - // The order of execution for this policy. Must be unique for each policy. - Precedence int64 `json:"precedence"` - // A custom message that will appear on the purpose justification screen. - PurposeJustificationPrompt string `json:"purpose_justification_prompt"` - // Require users to enter a justification when they log in to the application. - PurposeJustificationRequired bool `json:"purpose_justification_required"` - // Rules evaluated with an AND logical operator. To match the policy, a user must - // meet all of the Require rules. - Require []ZeroTrustAccessApplicationPolicyListResponseRequire `json:"require"` - // The amount of time that tokens issued for the application will be valid. Must be - // in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, - // m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationPolicyListResponseJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseJSON contains the JSON metadata for -// the struct [ZeroTrustAccessApplicationPolicyListResponse] -type zeroTrustAccessApplicationPolicyListResponseJSON struct { - ID apijson.Field - ApprovalGroups apijson.Field - ApprovalRequired apijson.Field - CreatedAt apijson.Field - Decision apijson.Field - Exclude apijson.Field - Include apijson.Field - IsolationRequired apijson.Field - Name apijson.Field - Precedence apijson.Field - PurposeJustificationPrompt apijson.Field - PurposeJustificationRequired apijson.Field - Require apijson.Field - SessionDuration apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseJSON) RawJSON() string { - return r.raw -} - -// A group of email addresses that can approve a temporary authentication request. -type ZeroTrustAccessApplicationPolicyListResponseApprovalGroup struct { - // The number of approvals needed to obtain access. - ApprovalsNeeded float64 `json:"approvals_needed,required"` - // A list of emails that can approve the access request. - EmailAddresses []interface{} `json:"email_addresses"` - // The UUID of an re-usable email list. - EmailListUUID string `json:"email_list_uuid"` - JSON zeroTrustAccessApplicationPolicyListResponseApprovalGroupJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseApprovalGroupJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseApprovalGroup] -type zeroTrustAccessApplicationPolicyListResponseApprovalGroupJSON struct { - ApprovalsNeeded apijson.Field - EmailAddresses apijson.Field - EmailListUUID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseApprovalGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseApprovalGroupJSON) RawJSON() string { - return r.raw -} - -// The action Access will take if a user matches this policy. -type ZeroTrustAccessApplicationPolicyListResponseDecision string - -const ( - ZeroTrustAccessApplicationPolicyListResponseDecisionAllow ZeroTrustAccessApplicationPolicyListResponseDecision = "allow" - ZeroTrustAccessApplicationPolicyListResponseDecisionDeny ZeroTrustAccessApplicationPolicyListResponseDecision = "deny" - ZeroTrustAccessApplicationPolicyListResponseDecisionNonIdentity ZeroTrustAccessApplicationPolicyListResponseDecision = "non_identity" - ZeroTrustAccessApplicationPolicyListResponseDecisionBypass ZeroTrustAccessApplicationPolicyListResponseDecision = "bypass" -) - -// Matches a specific email. -// -// Union satisfied by -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailRule], -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailListRule], -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDomainRule], -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEveryoneRule], -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPRule], -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPListRule], -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessCertificateRule], -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAccessGroupRule], -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAzureGroupRule], -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGsuiteGroupRule], -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessOktaGroupRule], -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessSamlGroupRule], -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessExternalEvaluationRule], -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessCountryRule], -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAuthenticationMethodRule] -// or [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDevicePostureRule]. -type ZeroTrustAccessApplicationPolicyListResponseExclude interface { - implementsZeroTrustAccessApplicationPolicyListResponseExclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationPolicyListResponseExclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailRule struct { - Email ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailRuleEmailJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailRuleEmail] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailListRule struct { - EmailList ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailListRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailListRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailListRuleEmailList] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDomainRule struct { - EmailDomain ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessDomainRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDomainRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessDomainRuleEmailDomainJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDomainRuleEmailDomain] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessEveryoneRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEveryoneRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPRule struct { - IP ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessIPRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessIPRuleIPJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPRuleIP] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPListRule struct { - IPList ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessIPListRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPListRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessIPListRuleIPListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPListRuleIPList] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessCertificateRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessCertificateRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -// Matches an Access group. -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAccessGroupRule struct { - Group ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessAccessGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAccessGroupRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessAccessGroupRuleGroupJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAccessGroupRuleGroup] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessAzureGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAzureGroupRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessAzureGroupRuleAzureAdJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAzureGroupRuleAzureAd] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGitHubOrganizationRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessGsuiteGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGsuiteGroupRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessGsuiteGroupRuleGsuiteJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessOktaGroupRule struct { - Okta ZeroTrustAccessApplicationPolicyListResponseExcludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessOktaGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessOktaGroupRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessOktaGroupRuleOktaJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessOktaGroupRuleOkta] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessSamlGroupRule struct { - Saml ZeroTrustAccessApplicationPolicyListResponseExcludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessSamlGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessSamlGroupRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessSamlGroupRuleSamlJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessSamlGroupRuleSaml] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessApplicationPolicyListResponseExcludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessServiceTokenRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessServiceTokenRuleServiceToken] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAnyValidServiceTokenRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessApplicationPolicyListResponseExcludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessExternalEvaluationRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessCountryRule struct { - Geo ZeroTrustAccessApplicationPolicyListResponseExcludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessCountryRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessCountryRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessCountryRuleGeoJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessCountryRuleGeo] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAuthenticationMethodRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessDevicePostureRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDevicePostureRule] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyListResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessApplicationPolicyListResponseExcludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseExcludeAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessApplicationPolicyListResponseExcludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseExcludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseExcludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailRule], -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailListRule], -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDomainRule], -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEveryoneRule], -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPRule], -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPListRule], -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessCertificateRule], -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAccessGroupRule], -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAzureGroupRule], -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGsuiteGroupRule], -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessOktaGroupRule], -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessSamlGroupRule], -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessExternalEvaluationRule], -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessCountryRule], -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAuthenticationMethodRule] -// or [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDevicePostureRule]. -type ZeroTrustAccessApplicationPolicyListResponseInclude interface { - implementsZeroTrustAccessApplicationPolicyListResponseInclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationPolicyListResponseInclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailRule struct { - Email ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailRuleEmailJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailRuleEmail] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailListRule struct { - EmailList ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailListRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailListRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailListRuleEmailList] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDomainRule struct { - EmailDomain ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessDomainRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDomainRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessDomainRuleEmailDomainJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDomainRuleEmailDomain] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessEveryoneRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEveryoneRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPRule struct { - IP ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessIPRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessIPRuleIPJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPRuleIP] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPListRule struct { - IPList ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessIPListRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPListRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessIPListRuleIPListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPListRuleIPList] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessCertificateRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessCertificateRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -// Matches an Access group. -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAccessGroupRule struct { - Group ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessAccessGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAccessGroupRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessAccessGroupRuleGroupJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAccessGroupRuleGroup] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessAzureGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAzureGroupRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessAzureGroupRuleAzureAdJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAzureGroupRuleAzureAd] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGitHubOrganizationRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessGsuiteGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGsuiteGroupRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessGsuiteGroupRuleGsuiteJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessOktaGroupRule struct { - Okta ZeroTrustAccessApplicationPolicyListResponseIncludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessOktaGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessOktaGroupRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessOktaGroupRuleOktaJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessOktaGroupRuleOkta] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessSamlGroupRule struct { - Saml ZeroTrustAccessApplicationPolicyListResponseIncludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessSamlGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessSamlGroupRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessSamlGroupRuleSamlJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessSamlGroupRuleSaml] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessApplicationPolicyListResponseIncludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessServiceTokenRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessServiceTokenRuleServiceToken] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAnyValidServiceTokenRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessApplicationPolicyListResponseIncludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessExternalEvaluationRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessCountryRule struct { - Geo ZeroTrustAccessApplicationPolicyListResponseIncludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessCountryRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessCountryRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessCountryRuleGeoJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessCountryRuleGeo] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAuthenticationMethodRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessDevicePostureRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDevicePostureRule] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyListResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessApplicationPolicyListResponseIncludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseIncludeAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessApplicationPolicyListResponseIncludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseIncludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseIncludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailRule], -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailListRule], -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessDomainRule], -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessEveryoneRule], -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPRule], -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPListRule], -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessCertificateRule], -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessAccessGroupRule], -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessAzureGroupRule], -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessGitHubOrganizationRule], -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessGsuiteGroupRule], -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessOktaGroupRule], -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessSamlGroupRule], -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessExternalEvaluationRule], -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessCountryRule], -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessAuthenticationMethodRule] -// or [ZeroTrustAccessApplicationPolicyListResponseRequireAccessDevicePostureRule]. -type ZeroTrustAccessApplicationPolicyListResponseRequire interface { - implementsZeroTrustAccessApplicationPolicyListResponseRequire() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationPolicyListResponseRequire)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyListResponseRequireAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailRule struct { - Email ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessEmailRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessEmailRuleEmailJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailRuleEmail] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailListRule struct { - EmailList ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessEmailListRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailListRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailListRuleEmailList] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessDomainRule struct { - EmailDomain ZeroTrustAccessApplicationPolicyListResponseRequireAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessDomainRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessDomainRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessDomainRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessDomainRuleEmailDomainJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessDomainRuleEmailDomain] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessEveryoneRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessEveryoneRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -// Matches an IP address block. -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPRule struct { - IP ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessIPRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessIPRuleIPJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPRuleIP] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPListRule struct { - IPList ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessIPListRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPListRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPListRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessIPListRuleIPListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPListRuleIPList] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessCertificateRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessCertificateRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -// Matches an Access group. -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessAccessGroupRule struct { - Group ZeroTrustAccessApplicationPolicyListResponseRequireAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessAccessGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessAccessGroupRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessAccessGroupRuleGroupJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessAccessGroupRuleGroup] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessApplicationPolicyListResponseRequireAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessAzureGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessAzureGroupRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessAzureGroupRuleAzureAdJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessAzureGroupRuleAzureAd] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessApplicationPolicyListResponseRequireAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessGitHubOrganizationRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessApplicationPolicyListResponseRequireAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessGsuiteGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessGsuiteGroupRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessGsuiteGroupRuleGsuiteJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessOktaGroupRule struct { - Okta ZeroTrustAccessApplicationPolicyListResponseRequireAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessOktaGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessOktaGroupRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessOktaGroupRuleOktaJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessOktaGroupRuleOkta] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessSamlGroupRule struct { - Saml ZeroTrustAccessApplicationPolicyListResponseRequireAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessSamlGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessSamlGroupRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessSamlGroupRuleSamlJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessSamlGroupRuleSaml] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessApplicationPolicyListResponseRequireAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessServiceTokenRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessServiceTokenRuleServiceToken] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessAnyValidServiceTokenRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessApplicationPolicyListResponseRequireAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessExternalEvaluationRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessCountryRule struct { - Geo ZeroTrustAccessApplicationPolicyListResponseRequireAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessCountryRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessCountryRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessCountryRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessCountryRuleGeoJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessCountryRuleGeo] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessApplicationPolicyListResponseRequireAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessAuthenticationMethodRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessApplicationPolicyListResponseRequireAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessDevicePostureRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessDevicePostureRule] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyListResponseRequireAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyListResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyListResponseRequireAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessApplicationPolicyListResponseRequireAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseRequireAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseRequireAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessApplicationPolicyListResponseRequireAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseRequireAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseRequireAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationPolicyDeleteResponse struct { - // UUID - ID string `json:"id"` - JSON zeroTrustAccessApplicationPolicyDeleteResponseJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyDeleteResponseJSON contains the JSON metadata -// for the struct [ZeroTrustAccessApplicationPolicyDeleteResponse] -type zeroTrustAccessApplicationPolicyDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationPolicyGetResponse struct { - // UUID - ID string `json:"id"` - // Administrators who can approve a temporary authentication request. - ApprovalGroups []ZeroTrustAccessApplicationPolicyGetResponseApprovalGroup `json:"approval_groups"` - // Requires the user to request access from an administrator at the start of each - // session. - ApprovalRequired bool `json:"approval_required"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The action Access will take if a user matches this policy. - Decision ZeroTrustAccessApplicationPolicyGetResponseDecision `json:"decision"` - // Rules evaluated with a NOT logical operator. To match the policy, a user cannot - // meet any of the Exclude rules. - Exclude []ZeroTrustAccessApplicationPolicyGetResponseExclude `json:"exclude"` - // Rules evaluated with an OR logical operator. A user needs to meet only one of - // the Include rules. - Include []ZeroTrustAccessApplicationPolicyGetResponseInclude `json:"include"` - // Require this application to be served in an isolated browser for users matching - // this policy. 'Client Web Isolation' must be on for the account in order to use - // this feature. - IsolationRequired bool `json:"isolation_required"` - // The name of the Access policy. - Name string `json:"name"` - // The order of execution for this policy. Must be unique for each policy. - Precedence int64 `json:"precedence"` - // A custom message that will appear on the purpose justification screen. - PurposeJustificationPrompt string `json:"purpose_justification_prompt"` - // Require users to enter a justification when they log in to the application. - PurposeJustificationRequired bool `json:"purpose_justification_required"` - // Rules evaluated with an AND logical operator. To match the policy, a user must - // meet all of the Require rules. - Require []ZeroTrustAccessApplicationPolicyGetResponseRequire `json:"require"` - // The amount of time that tokens issued for the application will be valid. Must be - // in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, - // m, h. - SessionDuration string `json:"session_duration"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessApplicationPolicyGetResponseJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseJSON contains the JSON metadata for -// the struct [ZeroTrustAccessApplicationPolicyGetResponse] -type zeroTrustAccessApplicationPolicyGetResponseJSON struct { - ID apijson.Field - ApprovalGroups apijson.Field - ApprovalRequired apijson.Field - CreatedAt apijson.Field - Decision apijson.Field - Exclude apijson.Field - Include apijson.Field - IsolationRequired apijson.Field - Name apijson.Field - Precedence apijson.Field - PurposeJustificationPrompt apijson.Field - PurposeJustificationRequired apijson.Field - Require apijson.Field - SessionDuration apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseJSON) RawJSON() string { - return r.raw -} - -// A group of email addresses that can approve a temporary authentication request. -type ZeroTrustAccessApplicationPolicyGetResponseApprovalGroup struct { - // The number of approvals needed to obtain access. - ApprovalsNeeded float64 `json:"approvals_needed,required"` - // A list of emails that can approve the access request. - EmailAddresses []interface{} `json:"email_addresses"` - // The UUID of an re-usable email list. - EmailListUUID string `json:"email_list_uuid"` - JSON zeroTrustAccessApplicationPolicyGetResponseApprovalGroupJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseApprovalGroupJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseApprovalGroup] -type zeroTrustAccessApplicationPolicyGetResponseApprovalGroupJSON struct { - ApprovalsNeeded apijson.Field - EmailAddresses apijson.Field - EmailListUUID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseApprovalGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseApprovalGroupJSON) RawJSON() string { - return r.raw -} - -// The action Access will take if a user matches this policy. -type ZeroTrustAccessApplicationPolicyGetResponseDecision string - -const ( - ZeroTrustAccessApplicationPolicyGetResponseDecisionAllow ZeroTrustAccessApplicationPolicyGetResponseDecision = "allow" - ZeroTrustAccessApplicationPolicyGetResponseDecisionDeny ZeroTrustAccessApplicationPolicyGetResponseDecision = "deny" - ZeroTrustAccessApplicationPolicyGetResponseDecisionNonIdentity ZeroTrustAccessApplicationPolicyGetResponseDecision = "non_identity" - ZeroTrustAccessApplicationPolicyGetResponseDecisionBypass ZeroTrustAccessApplicationPolicyGetResponseDecision = "bypass" -) - -// Matches a specific email. -// -// Union satisfied by -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailRule], -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailListRule], -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDomainRule], -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEveryoneRule], -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPRule], -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPListRule], -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessCertificateRule], -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAccessGroupRule], -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAzureGroupRule], -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGsuiteGroupRule], -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessOktaGroupRule], -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessSamlGroupRule], -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessExternalEvaluationRule], -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessCountryRule], -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAuthenticationMethodRule] -// or [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDevicePostureRule]. -type ZeroTrustAccessApplicationPolicyGetResponseExclude interface { - implementsZeroTrustAccessApplicationPolicyGetResponseExclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationPolicyGetResponseExclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailRule struct { - Email ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailRuleEmailJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailRuleEmail] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailListRule struct { - EmailList ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailListRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailListRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailListRuleEmailList] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDomainRule struct { - EmailDomain ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessDomainRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDomainRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessDomainRuleEmailDomainJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDomainRuleEmailDomain] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEveryoneRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEveryoneRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPRule struct { - IP ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPRuleIPJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPRuleIP] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPListRule struct { - IPList ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPListRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPListRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPListRuleIPListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPListRuleIPList] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessCertificateRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessCertificateRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -// Matches an Access group. -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAccessGroupRule struct { - Group ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAccessGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAccessGroupRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAccessGroupRuleGroupJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAccessGroupRuleGroup] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAzureGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAzureGroupRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAzureGroupRuleAzureAdJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAzureGroupRuleAzureAd] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGitHubOrganizationRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessGsuiteGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGsuiteGroupRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessGsuiteGroupRuleGsuiteJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessOktaGroupRule struct { - Okta ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessOktaGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessOktaGroupRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessOktaGroupRuleOktaJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessOktaGroupRuleOkta] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessSamlGroupRule struct { - Saml ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessSamlGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessSamlGroupRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessSamlGroupRuleSamlJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessSamlGroupRuleSaml] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessServiceTokenRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessServiceTokenRuleServiceToken] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAnyValidServiceTokenRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessExternalEvaluationRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessCountryRule struct { - Geo ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessCountryRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessCountryRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessCountryRuleGeoJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessCountryRuleGeo] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAuthenticationMethodRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessDevicePostureRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDevicePostureRule] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyGetResponseExclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseExcludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseExcludeAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessApplicationPolicyGetResponseExcludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseExcludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseExcludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailRule], -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailListRule], -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDomainRule], -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEveryoneRule], -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPRule], -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPListRule], -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessCertificateRule], -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAccessGroupRule], -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAzureGroupRule], -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGsuiteGroupRule], -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessOktaGroupRule], -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessSamlGroupRule], -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessExternalEvaluationRule], -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessCountryRule], -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAuthenticationMethodRule] -// or [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDevicePostureRule]. -type ZeroTrustAccessApplicationPolicyGetResponseInclude interface { - implementsZeroTrustAccessApplicationPolicyGetResponseInclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationPolicyGetResponseInclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailRule struct { - Email ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailRuleEmailJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailRuleEmail] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailListRule struct { - EmailList ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailListRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailListRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailListRuleEmailList] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDomainRule struct { - EmailDomain ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessDomainRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDomainRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessDomainRuleEmailDomainJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDomainRuleEmailDomain] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEveryoneRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEveryoneRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPRule struct { - IP ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPRuleIPJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPRuleIP] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPListRule struct { - IPList ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPListRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPListRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPListRuleIPListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPListRuleIPList] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessCertificateRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessCertificateRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -// Matches an Access group. -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAccessGroupRule struct { - Group ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAccessGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAccessGroupRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAccessGroupRuleGroupJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAccessGroupRuleGroup] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAzureGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAzureGroupRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAzureGroupRuleAzureAdJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAzureGroupRuleAzureAd] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGitHubOrganizationRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessGsuiteGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGsuiteGroupRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessGsuiteGroupRuleGsuiteJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessOktaGroupRule struct { - Okta ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessOktaGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessOktaGroupRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessOktaGroupRuleOktaJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessOktaGroupRuleOkta] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessSamlGroupRule struct { - Saml ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessSamlGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessSamlGroupRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessSamlGroupRuleSamlJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessSamlGroupRuleSaml] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessServiceTokenRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessServiceTokenRuleServiceToken] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAnyValidServiceTokenRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessExternalEvaluationRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessCountryRule struct { - Geo ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessCountryRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessCountryRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessCountryRuleGeoJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessCountryRuleGeo] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAuthenticationMethodRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessDevicePostureRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDevicePostureRule] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyGetResponseInclude() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseIncludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseIncludeAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessApplicationPolicyGetResponseIncludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseIncludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseIncludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailRule], -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailListRule], -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDomainRule], -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEveryoneRule], -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPRule], -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPListRule], -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessCertificateRule], -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAccessGroupRule], -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAzureGroupRule], -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGitHubOrganizationRule], -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGsuiteGroupRule], -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessOktaGroupRule], -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessSamlGroupRule], -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessExternalEvaluationRule], -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessCountryRule], -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAuthenticationMethodRule] -// or [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDevicePostureRule]. -type ZeroTrustAccessApplicationPolicyGetResponseRequire interface { - implementsZeroTrustAccessApplicationPolicyGetResponseRequire() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessApplicationPolicyGetResponseRequire)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailRule struct { - Email ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailRuleEmailJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailRuleEmail] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailListRule struct { - EmailList ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailListRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailListRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailListRuleEmailList] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDomainRule struct { - EmailDomain ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessDomainRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDomainRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDomainRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessDomainRuleEmailDomainJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDomainRuleEmailDomain] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessEveryoneRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEveryoneRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -// Matches an IP address block. -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPRule struct { - IP ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessIPRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessIPRuleIPJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPRuleIP] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPListRule struct { - IPList ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessIPListRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPListRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPListRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessIPListRuleIPListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPListRuleIPList] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessCertificateRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessCertificateRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -// Matches an Access group. -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAccessGroupRule struct { - Group ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessAccessGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAccessGroupRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessAccessGroupRuleGroupJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAccessGroupRuleGroup] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessAzureGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAzureGroupRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessAzureGroupRuleAzureAdJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAzureGroupRuleAzureAd] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGitHubOrganizationRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessGsuiteGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGsuiteGroupRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessGsuiteGroupRuleGsuiteJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessOktaGroupRule struct { - Okta ZeroTrustAccessApplicationPolicyGetResponseRequireAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessOktaGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessOktaGroupRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessOktaGroupRuleOktaJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessOktaGroupRuleOkta] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessSamlGroupRule struct { - Saml ZeroTrustAccessApplicationPolicyGetResponseRequireAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessSamlGroupRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessSamlGroupRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessSamlGroupRuleSamlJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessSamlGroupRuleSaml] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessApplicationPolicyGetResponseRequireAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessServiceTokenRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessServiceTokenRuleServiceToken] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAnyValidServiceTokenRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessApplicationPolicyGetResponseRequireAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessExternalEvaluationRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessCountryRule struct { - Geo ZeroTrustAccessApplicationPolicyGetResponseRequireAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessCountryRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessCountryRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessCountryRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessCountryRuleGeoJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessCountryRuleGeo] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAuthenticationMethodRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessDevicePostureRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDevicePostureRule] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyGetResponseRequire() { -} - -type ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseRequireAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseRequireAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessApplicationPolicyGetResponseRequireAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseRequireAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseRequireAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationPolicyNewParams struct { - // The action Access will take if a user matches this policy. - Decision param.Field[ZeroTrustAccessApplicationPolicyNewParamsDecision] `json:"decision,required"` - // Rules evaluated with an OR logical operator. A user needs to meet only one of - // the Include rules. - Include param.Field[[]ZeroTrustAccessApplicationPolicyNewParamsInclude] `json:"include,required"` - // The name of the Access policy. - Name param.Field[string] `json:"name,required"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // Administrators who can approve a temporary authentication request. - ApprovalGroups param.Field[[]ZeroTrustAccessApplicationPolicyNewParamsApprovalGroup] `json:"approval_groups"` - // Requires the user to request access from an administrator at the start of each - // session. - ApprovalRequired param.Field[bool] `json:"approval_required"` - // Rules evaluated with a NOT logical operator. To match the policy, a user cannot - // meet any of the Exclude rules. - Exclude param.Field[[]ZeroTrustAccessApplicationPolicyNewParamsExclude] `json:"exclude"` - // Require this application to be served in an isolated browser for users matching - // this policy. 'Client Web Isolation' must be on for the account in order to use - // this feature. - IsolationRequired param.Field[bool] `json:"isolation_required"` - // The order of execution for this policy. Must be unique for each policy. - Precedence param.Field[int64] `json:"precedence"` - // A custom message that will appear on the purpose justification screen. - PurposeJustificationPrompt param.Field[string] `json:"purpose_justification_prompt"` - // Require users to enter a justification when they log in to the application. - PurposeJustificationRequired param.Field[bool] `json:"purpose_justification_required"` - // Rules evaluated with an AND logical operator. To match the policy, a user must - // meet all of the Require rules. - Require param.Field[[]ZeroTrustAccessApplicationPolicyNewParamsRequire] `json:"require"` - // The amount of time that tokens issued for the application will be valid. Must be - // in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, - // m, h. - SessionDuration param.Field[string] `json:"session_duration"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The action Access will take if a user matches this policy. -type ZeroTrustAccessApplicationPolicyNewParamsDecision string - -const ( - ZeroTrustAccessApplicationPolicyNewParamsDecisionAllow ZeroTrustAccessApplicationPolicyNewParamsDecision = "allow" - ZeroTrustAccessApplicationPolicyNewParamsDecisionDeny ZeroTrustAccessApplicationPolicyNewParamsDecision = "deny" - ZeroTrustAccessApplicationPolicyNewParamsDecisionNonIdentity ZeroTrustAccessApplicationPolicyNewParamsDecision = "non_identity" - ZeroTrustAccessApplicationPolicyNewParamsDecisionBypass ZeroTrustAccessApplicationPolicyNewParamsDecision = "bypass" -) - -// Matches a specific email. -// -// Satisfied by [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailRule], -// [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailListRule], -// [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessDomainRule], -// [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEveryoneRule], -// [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessIPRule], -// [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessIPListRule], -// [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessCertificateRule], -// [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAccessGroupRule], -// [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAzureGroupRule], -// [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRule], -// [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessOktaGroupRule], -// [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessSamlGroupRule], -// [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRule], -// [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessCountryRule], -// [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRule], -// [ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessDevicePostureRule]. -type ZeroTrustAccessApplicationPolicyNewParamsInclude interface { - implementsZeroTrustAccessApplicationPolicyNewParamsInclude() -} - -// Matches a specific email. -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailRule struct { - Email param.Field[ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailRuleEmail] `json:"email,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailListRule struct { - EmailList param.Field[ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessDomainRule struct { - EmailDomain param.Field[ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessIPRule struct { - IP param.Field[ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessIPRuleIP] `json:"ip,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessIPListRule struct { - IPList param.Field[ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -// Matches an Access group. -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAccessGroupRule struct { - Group param.Field[ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAzureGroupRule struct { - AzureAd param.Field[ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRule struct { - Gsuite param.Field[ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessOktaGroupRule struct { - Okta param.Field[ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessSamlGroupRule struct { - Saml param.Field[ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessServiceTokenRule struct { - ServiceToken param.Field[ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessCountryRule struct { - Geo param.Field[ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRule struct { - AuthMethod param.Field[ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessDevicePostureRule struct { - DevicePosture param.Field[ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyNewParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A group of email addresses that can approve a temporary authentication request. -type ZeroTrustAccessApplicationPolicyNewParamsApprovalGroup struct { - // The number of approvals needed to obtain access. - ApprovalsNeeded param.Field[float64] `json:"approvals_needed,required"` - // A list of emails that can approve the access request. - EmailAddresses param.Field[[]interface{}] `json:"email_addresses"` - // The UUID of an re-usable email list. - EmailListUUID param.Field[string] `json:"email_list_uuid"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsApprovalGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailRule], -// [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailListRule], -// [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessDomainRule], -// [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEveryoneRule], -// [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessIPRule], -// [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessIPListRule], -// [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessCertificateRule], -// [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAccessGroupRule], -// [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAzureGroupRule], -// [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRule], -// [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessOktaGroupRule], -// [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessSamlGroupRule], -// [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRule], -// [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessCountryRule], -// [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRule], -// [ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessDevicePostureRule]. -type ZeroTrustAccessApplicationPolicyNewParamsExclude interface { - implementsZeroTrustAccessApplicationPolicyNewParamsExclude() -} - -// Matches a specific email. -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailRule struct { - Email param.Field[ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailRuleEmail] `json:"email,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailListRule struct { - EmailList param.Field[ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessDomainRule struct { - EmailDomain param.Field[ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessIPRule struct { - IP param.Field[ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessIPRuleIP] `json:"ip,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessIPListRule struct { - IPList param.Field[ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -// Matches an Access group. -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAccessGroupRule struct { - Group param.Field[ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAzureGroupRule struct { - AzureAd param.Field[ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRule struct { - Gsuite param.Field[ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessOktaGroupRule struct { - Okta param.Field[ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessSamlGroupRule struct { - Saml param.Field[ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessServiceTokenRule struct { - ServiceToken param.Field[ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessCountryRule struct { - Geo param.Field[ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRule struct { - AuthMethod param.Field[ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessDevicePostureRule struct { - DevicePosture param.Field[ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyNewParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailRule], -// [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailListRule], -// [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessDomainRule], -// [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEveryoneRule], -// [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessIPRule], -// [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessIPListRule], -// [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessCertificateRule], -// [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAccessGroupRule], -// [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAzureGroupRule], -// [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRule], -// [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRule], -// [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessOktaGroupRule], -// [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessSamlGroupRule], -// [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRule], -// [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessCountryRule], -// [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRule], -// [ZeroTrustAccessApplicationPolicyNewParamsRequireAccessDevicePostureRule]. -type ZeroTrustAccessApplicationPolicyNewParamsRequire interface { - implementsZeroTrustAccessApplicationPolicyNewParamsRequire() -} - -// Matches a specific email. -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailRule struct { - Email param.Field[ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailRuleEmail] `json:"email,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailListRule struct { - EmailList param.Field[ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessDomainRule struct { - EmailDomain param.Field[ZeroTrustAccessApplicationPolicyNewParamsRequireAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessDomainRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -// Matches an IP address block. -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessIPRule struct { - IP param.Field[ZeroTrustAccessApplicationPolicyNewParamsRequireAccessIPRuleIP] `json:"ip,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessIPRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessIPListRule struct { - IPList param.Field[ZeroTrustAccessApplicationPolicyNewParamsRequireAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessIPListRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -// Matches an Access group. -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAccessGroupRule struct { - Group param.Field[ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAzureGroupRule struct { - AzureAd param.Field[ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[ZeroTrustAccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRule struct { - Gsuite param.Field[ZeroTrustAccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessOktaGroupRule struct { - Okta param.Field[ZeroTrustAccessApplicationPolicyNewParamsRequireAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessSamlGroupRule struct { - Saml param.Field[ZeroTrustAccessApplicationPolicyNewParamsRequireAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessServiceTokenRule struct { - ServiceToken param.Field[ZeroTrustAccessApplicationPolicyNewParamsRequireAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[ZeroTrustAccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessCountryRule struct { - Geo param.Field[ZeroTrustAccessApplicationPolicyNewParamsRequireAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessCountryRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRule struct { - AuthMethod param.Field[ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessDevicePostureRule struct { - DevicePosture param.Field[ZeroTrustAccessApplicationPolicyNewParamsRequireAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyNewParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyNewParamsRequireAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r ZeroTrustAccessApplicationPolicyNewParamsRequireAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustAccessApplicationPolicyNewResponseEnvelope struct { - Errors []ZeroTrustAccessApplicationPolicyNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessApplicationPolicyNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessApplicationPolicyNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessApplicationPolicyNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationPolicyNewResponseEnvelope] -type zeroTrustAccessApplicationPolicyNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationPolicyNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseEnvelopeErrors] -type zeroTrustAccessApplicationPolicyNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationPolicyNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationPolicyNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyNewResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyNewResponseEnvelopeMessages] -type zeroTrustAccessApplicationPolicyNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessApplicationPolicyNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessApplicationPolicyNewResponseEnvelopeSuccessTrue ZeroTrustAccessApplicationPolicyNewResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessApplicationPolicyUpdateParams struct { - // The action Access will take if a user matches this policy. - Decision param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsDecision] `json:"decision,required"` - // Rules evaluated with an OR logical operator. A user needs to meet only one of - // the Include rules. - Include param.Field[[]ZeroTrustAccessApplicationPolicyUpdateParamsInclude] `json:"include,required"` - // The name of the Access policy. - Name param.Field[string] `json:"name,required"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // Administrators who can approve a temporary authentication request. - ApprovalGroups param.Field[[]ZeroTrustAccessApplicationPolicyUpdateParamsApprovalGroup] `json:"approval_groups"` - // Requires the user to request access from an administrator at the start of each - // session. - ApprovalRequired param.Field[bool] `json:"approval_required"` - // Rules evaluated with a NOT logical operator. To match the policy, a user cannot - // meet any of the Exclude rules. - Exclude param.Field[[]ZeroTrustAccessApplicationPolicyUpdateParamsExclude] `json:"exclude"` - // Require this application to be served in an isolated browser for users matching - // this policy. 'Client Web Isolation' must be on for the account in order to use - // this feature. - IsolationRequired param.Field[bool] `json:"isolation_required"` - // The order of execution for this policy. Must be unique for each policy. - Precedence param.Field[int64] `json:"precedence"` - // A custom message that will appear on the purpose justification screen. - PurposeJustificationPrompt param.Field[string] `json:"purpose_justification_prompt"` - // Require users to enter a justification when they log in to the application. - PurposeJustificationRequired param.Field[bool] `json:"purpose_justification_required"` - // Rules evaluated with an AND logical operator. To match the policy, a user must - // meet all of the Require rules. - Require param.Field[[]ZeroTrustAccessApplicationPolicyUpdateParamsRequire] `json:"require"` - // The amount of time that tokens issued for the application will be valid. Must be - // in the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, - // m, h. - SessionDuration param.Field[string] `json:"session_duration"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The action Access will take if a user matches this policy. -type ZeroTrustAccessApplicationPolicyUpdateParamsDecision string - -const ( - ZeroTrustAccessApplicationPolicyUpdateParamsDecisionAllow ZeroTrustAccessApplicationPolicyUpdateParamsDecision = "allow" - ZeroTrustAccessApplicationPolicyUpdateParamsDecisionDeny ZeroTrustAccessApplicationPolicyUpdateParamsDecision = "deny" - ZeroTrustAccessApplicationPolicyUpdateParamsDecisionNonIdentity ZeroTrustAccessApplicationPolicyUpdateParamsDecision = "non_identity" - ZeroTrustAccessApplicationPolicyUpdateParamsDecisionBypass ZeroTrustAccessApplicationPolicyUpdateParamsDecision = "bypass" -) - -// Matches a specific email. -// -// Satisfied by -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailListRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessDomainRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEveryoneRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessIPRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessIPListRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessCertificateRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessCountryRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRule]. -type ZeroTrustAccessApplicationPolicyUpdateParamsInclude interface { - implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() -} - -// Matches a specific email. -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailRule struct { - Email param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailRuleEmail] `json:"email,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailListRule struct { - EmailList param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessDomainRule struct { - EmailDomain param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessIPRule struct { - IP param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessIPRuleIP] `json:"ip,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessIPListRule struct { - IPList param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -// Matches an Access group. -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRule struct { - Group param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRule struct { - AzureAd param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRule struct { - Gsuite param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRule struct { - Okta param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRule struct { - Saml param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRule struct { - ServiceToken param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessCountryRule struct { - Geo param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRule struct { - AuthMethod param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRule struct { - DevicePosture param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsInclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A group of email addresses that can approve a temporary authentication request. -type ZeroTrustAccessApplicationPolicyUpdateParamsApprovalGroup struct { - // The number of approvals needed to obtain access. - ApprovalsNeeded param.Field[float64] `json:"approvals_needed,required"` - // A list of emails that can approve the access request. - EmailAddresses param.Field[[]interface{}] `json:"email_addresses"` - // The UUID of an re-usable email list. - EmailListUUID param.Field[string] `json:"email_list_uuid"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsApprovalGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailListRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessDomainRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEveryoneRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessIPRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessIPListRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessCertificateRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessCountryRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRule]. -type ZeroTrustAccessApplicationPolicyUpdateParamsExclude interface { - implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() -} - -// Matches a specific email. -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailRule struct { - Email param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailRuleEmail] `json:"email,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailListRule struct { - EmailList param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessDomainRule struct { - EmailDomain param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessDomainRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessIPRule struct { - IP param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessIPRuleIP] `json:"ip,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessIPRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessIPListRule struct { - IPList param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessIPListRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -// Matches an Access group. -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRule struct { - Group param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRule struct { - AzureAd param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRule struct { - Gsuite param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRule struct { - Okta param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRule struct { - Saml param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRule struct { - ServiceToken param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessCountryRule struct { - Geo param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessCountryRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRule struct { - AuthMethod param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRule struct { - DevicePosture param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsExclude() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailListRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessDomainRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEveryoneRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessIPRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessIPListRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessCertificateRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessCountryRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRule], -// [ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRule]. -type ZeroTrustAccessApplicationPolicyUpdateParamsRequire interface { - implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() -} - -// Matches a specific email. -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailRule struct { - Email param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailRuleEmail] `json:"email,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailListRule struct { - EmailList param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailListRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessDomainRule struct { - EmailDomain param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessDomainRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEveryoneRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -// Matches an IP address block. -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessIPRule struct { - IP param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessIPRuleIP] `json:"ip,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessIPRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessIPListRule struct { - IPList param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessIPListRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessCertificateRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -// Matches an Access group. -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRule struct { - Group param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRule struct { - AzureAd param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRule struct { - Gsuite param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRule struct { - Okta param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRule struct { - Saml param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRule struct { - ServiceToken param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessCountryRule struct { - Geo param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessCountryRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRule struct { - AuthMethod param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRule struct { - DevicePosture param.Field[ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRule) implementsZeroTrustAccessApplicationPolicyUpdateParamsRequire() { -} - -type ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseEnvelope struct { - Errors []ZeroTrustAccessApplicationPolicyUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessApplicationPolicyUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessApplicationPolicyUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessApplicationPolicyUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationPolicyUpdateResponseEnvelope] -type zeroTrustAccessApplicationPolicyUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseEnvelopeErrors] -type zeroTrustAccessApplicationPolicyUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationPolicyUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationPolicyUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyUpdateResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyUpdateResponseEnvelopeMessages] -type zeroTrustAccessApplicationPolicyUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessApplicationPolicyUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessApplicationPolicyUpdateResponseEnvelopeSuccessTrue ZeroTrustAccessApplicationPolicyUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessApplicationPolicyListParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustAccessApplicationPolicyListResponseEnvelope struct { - Errors []ZeroTrustAccessApplicationPolicyListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessApplicationPolicyListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustAccessApplicationPolicyListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustAccessApplicationPolicyListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustAccessApplicationPolicyListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustAccessApplicationPolicyListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationPolicyListResponseEnvelope] -type zeroTrustAccessApplicationPolicyListResponseEnvelopeJSON 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 *ZeroTrustAccessApplicationPolicyListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationPolicyListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationPolicyListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseEnvelopeErrors] -type zeroTrustAccessApplicationPolicyListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationPolicyListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationPolicyListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseEnvelopeMessages] -type zeroTrustAccessApplicationPolicyListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessApplicationPolicyListResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessApplicationPolicyListResponseEnvelopeSuccessTrue ZeroTrustAccessApplicationPolicyListResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessApplicationPolicyListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustAccessApplicationPolicyListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyListResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyListResponseEnvelopeResultInfo] -type zeroTrustAccessApplicationPolicyListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationPolicyDeleteParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustAccessApplicationPolicyDeleteResponseEnvelope struct { - Errors []ZeroTrustAccessApplicationPolicyDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessApplicationPolicyDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessApplicationPolicyDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessApplicationPolicyDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessApplicationPolicyDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyDeleteResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationPolicyDeleteResponseEnvelope] -type zeroTrustAccessApplicationPolicyDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationPolicyDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationPolicyDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyDeleteResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyDeleteResponseEnvelopeErrors] -type zeroTrustAccessApplicationPolicyDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationPolicyDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationPolicyDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyDeleteResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyDeleteResponseEnvelopeMessages] -type zeroTrustAccessApplicationPolicyDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessApplicationPolicyDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessApplicationPolicyDeleteResponseEnvelopeSuccessTrue ZeroTrustAccessApplicationPolicyDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessApplicationPolicyGetParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustAccessApplicationPolicyGetResponseEnvelope struct { - Errors []ZeroTrustAccessApplicationPolicyGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessApplicationPolicyGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessApplicationPolicyGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessApplicationPolicyGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationPolicyGetResponseEnvelope] -type zeroTrustAccessApplicationPolicyGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationPolicyGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseEnvelopeErrors] -type zeroTrustAccessApplicationPolicyGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationPolicyGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationPolicyGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessApplicationPolicyGetResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationPolicyGetResponseEnvelopeMessages] -type zeroTrustAccessApplicationPolicyGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationPolicyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationPolicyGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessApplicationPolicyGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessApplicationPolicyGetResponseEnvelopeSuccessTrue ZeroTrustAccessApplicationPolicyGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustaccessapplicationpolicy_test.go b/zerotrustaccessapplicationpolicy_test.go deleted file mode 100644 index 94ca08afe01..00000000000 --- a/zerotrustaccessapplicationpolicy_test.go +++ /dev/null @@ -1,284 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustAccessApplicationPolicyNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Applications.Policies.New( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustAccessApplicationPolicyNewParams{ - Decision: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsDecisionAllow), - Include: cloudflare.F([]cloudflare.ZeroTrustAccessApplicationPolicyNewParamsInclude{cloudflare.ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailRule(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailRule(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailRule(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsIncludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - })}), - Name: cloudflare.F("Allow devs"), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - ApprovalGroups: cloudflare.F([]cloudflare.ZeroTrustAccessApplicationPolicyNewParamsApprovalGroup{{ - ApprovalsNeeded: cloudflare.F(1.000000), - EmailAddresses: cloudflare.F([]interface{}{"test1@cloudflare.com", "test2@cloudflare.com"}), - EmailListUUID: cloudflare.F("string"), - }, { - ApprovalsNeeded: cloudflare.F(3.000000), - EmailAddresses: cloudflare.F([]interface{}{"test@cloudflare.com", "test2@cloudflare.com"}), - EmailListUUID: cloudflare.F("597147a1-976b-4ef2-9af0-81d5d007fc34"), - }}), - ApprovalRequired: cloudflare.F(true), - Exclude: cloudflare.F([]cloudflare.ZeroTrustAccessApplicationPolicyNewParamsExclude{cloudflare.ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailRule(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailRule(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailRule(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsExcludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - })}), - IsolationRequired: cloudflare.F(false), - Precedence: cloudflare.F(int64(0)), - PurposeJustificationPrompt: cloudflare.F("Please enter a justification for entering this protected domain."), - PurposeJustificationRequired: cloudflare.F(true), - Require: cloudflare.F([]cloudflare.ZeroTrustAccessApplicationPolicyNewParamsRequire{cloudflare.ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailRule(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailRule(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailRule(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyNewParamsRequireAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - })}), - SessionDuration: cloudflare.F("24h"), - }, - ) - 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 TestZeroTrustAccessApplicationPolicyUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Applications.Policies.Update( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustAccessApplicationPolicyUpdateParams{ - Decision: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsDecisionAllow), - Include: cloudflare.F([]cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsInclude{cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailRule(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailRule(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailRule(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsIncludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - })}), - Name: cloudflare.F("Allow devs"), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - ApprovalGroups: cloudflare.F([]cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsApprovalGroup{{ - ApprovalsNeeded: cloudflare.F(1.000000), - EmailAddresses: cloudflare.F([]interface{}{"test1@cloudflare.com", "test2@cloudflare.com"}), - EmailListUUID: cloudflare.F("string"), - }, { - ApprovalsNeeded: cloudflare.F(3.000000), - EmailAddresses: cloudflare.F([]interface{}{"test@cloudflare.com", "test2@cloudflare.com"}), - EmailListUUID: cloudflare.F("597147a1-976b-4ef2-9af0-81d5d007fc34"), - }}), - ApprovalRequired: cloudflare.F(true), - Exclude: cloudflare.F([]cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsExclude{cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailRule(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailRule(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailRule(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsExcludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - })}), - IsolationRequired: cloudflare.F(false), - Precedence: cloudflare.F(int64(0)), - PurposeJustificationPrompt: cloudflare.F("Please enter a justification for entering this protected domain."), - PurposeJustificationRequired: cloudflare.F(true), - Require: cloudflare.F([]cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsRequire{cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailRule(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailRule(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailRule(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessApplicationPolicyUpdateParamsRequireAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - })}), - SessionDuration: cloudflare.F("24h"), - }, - ) - 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 TestZeroTrustAccessApplicationPolicyListWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Applications.Policies.List( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustAccessApplicationPolicyListParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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 TestZeroTrustAccessApplicationPolicyDeleteWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Applications.Policies.Delete( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustAccessApplicationPolicyDeleteParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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 TestZeroTrustAccessApplicationPolicyGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Applications.Policies.Get( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustAccessApplicationPolicyGetParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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/zerotrustaccessapplicationuserpolicycheck.go b/zerotrustaccessapplicationuserpolicycheck.go deleted file mode 100644 index ef25ab53883..00000000000 --- a/zerotrustaccessapplicationuserpolicycheck.go +++ /dev/null @@ -1,274 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustAccessApplicationUserPolicyCheckService 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 [NewZeroTrustAccessApplicationUserPolicyCheckService] method instead. -type ZeroTrustAccessApplicationUserPolicyCheckService struct { - Options []option.RequestOption -} - -// NewZeroTrustAccessApplicationUserPolicyCheckService 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 NewZeroTrustAccessApplicationUserPolicyCheckService(opts ...option.RequestOption) (r *ZeroTrustAccessApplicationUserPolicyCheckService) { - r = &ZeroTrustAccessApplicationUserPolicyCheckService{} - r.Options = opts - return -} - -// Tests if a specific user has permission to access an application. -func (r *ZeroTrustAccessApplicationUserPolicyCheckService) List(ctx context.Context, appID ZeroTrustAccessApplicationUserPolicyCheckListParamsAppID, query ZeroTrustAccessApplicationUserPolicyCheckListParams, opts ...option.RequestOption) (res *ZeroTrustAccessApplicationUserPolicyCheckListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessApplicationUserPolicyCheckListResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/access/apps/%v/user_policy_checks", accountOrZone, accountOrZoneID, appID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustAccessApplicationUserPolicyCheckListResponse struct { - AppState ZeroTrustAccessApplicationUserPolicyCheckListResponseAppState `json:"app_state"` - UserIdentity ZeroTrustAccessApplicationUserPolicyCheckListResponseUserIdentity `json:"user_identity"` - JSON zeroTrustAccessApplicationUserPolicyCheckListResponseJSON `json:"-"` -} - -// zeroTrustAccessApplicationUserPolicyCheckListResponseJSON contains the JSON -// metadata for the struct [ZeroTrustAccessApplicationUserPolicyCheckListResponse] -type zeroTrustAccessApplicationUserPolicyCheckListResponseJSON struct { - AppState apijson.Field - UserIdentity apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUserPolicyCheckListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUserPolicyCheckListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationUserPolicyCheckListResponseAppState struct { - // UUID - AppUid string `json:"app_uid"` - Aud string `json:"aud"` - Hostname string `json:"hostname"` - Name string `json:"name"` - Policies []interface{} `json:"policies"` - Status string `json:"status"` - JSON zeroTrustAccessApplicationUserPolicyCheckListResponseAppStateJSON `json:"-"` -} - -// zeroTrustAccessApplicationUserPolicyCheckListResponseAppStateJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationUserPolicyCheckListResponseAppState] -type zeroTrustAccessApplicationUserPolicyCheckListResponseAppStateJSON struct { - AppUid apijson.Field - Aud apijson.Field - Hostname apijson.Field - Name apijson.Field - Policies apijson.Field - Status apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUserPolicyCheckListResponseAppState) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUserPolicyCheckListResponseAppStateJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationUserPolicyCheckListResponseUserIdentity struct { - ID string `json:"id"` - AccountID string `json:"account_id"` - DeviceSessions interface{} `json:"device_sessions"` - Email string `json:"email"` - Geo ZeroTrustAccessApplicationUserPolicyCheckListResponseUserIdentityGeo `json:"geo"` - Iat int64 `json:"iat"` - IsGateway bool `json:"is_gateway"` - IsWARP bool `json:"is_warp"` - Name string `json:"name"` - // UUID - UserUUID string `json:"user_uuid"` - Version int64 `json:"version"` - JSON zeroTrustAccessApplicationUserPolicyCheckListResponseUserIdentityJSON `json:"-"` -} - -// zeroTrustAccessApplicationUserPolicyCheckListResponseUserIdentityJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationUserPolicyCheckListResponseUserIdentity] -type zeroTrustAccessApplicationUserPolicyCheckListResponseUserIdentityJSON struct { - ID apijson.Field - AccountID apijson.Field - DeviceSessions apijson.Field - Email apijson.Field - Geo apijson.Field - Iat apijson.Field - IsGateway apijson.Field - IsWARP apijson.Field - Name apijson.Field - UserUUID apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUserPolicyCheckListResponseUserIdentity) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUserPolicyCheckListResponseUserIdentityJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationUserPolicyCheckListResponseUserIdentityGeo struct { - Country string `json:"country"` - JSON zeroTrustAccessApplicationUserPolicyCheckListResponseUserIdentityGeoJSON `json:"-"` -} - -// zeroTrustAccessApplicationUserPolicyCheckListResponseUserIdentityGeoJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationUserPolicyCheckListResponseUserIdentityGeo] -type zeroTrustAccessApplicationUserPolicyCheckListResponseUserIdentityGeoJSON struct { - Country apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUserPolicyCheckListResponseUserIdentityGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUserPolicyCheckListResponseUserIdentityGeoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationUserPolicyCheckListParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -// Identifier -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type ZeroTrustAccessApplicationUserPolicyCheckListParamsAppID interface { - ImplementsZeroTrustAccessApplicationUserPolicyCheckListParamsAppID() -} - -type ZeroTrustAccessApplicationUserPolicyCheckListResponseEnvelope struct { - Errors []ZeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessApplicationUserPolicyCheckListResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessApplicationUserPolicyCheckListResponseEnvelope] -type zeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUserPolicyCheckListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeErrorsJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeErrors] -type zeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeMessages] -type zeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeSuccessTrue ZeroTrustAccessApplicationUserPolicyCheckListResponseEnvelopeSuccess = true -) diff --git a/zerotrustaccessapplicationuserpolicycheck_test.go b/zerotrustaccessapplicationuserpolicycheck_test.go deleted file mode 100644 index ebcb38a5c8c..00000000000 --- a/zerotrustaccessapplicationuserpolicycheck_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustAccessApplicationUserPolicyCheckListWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Applications.UserPolicyChecks.List( - context.TODO(), - shared.UnionString("023e105f4ecef8ad9ca31a8372d0c353"), - cloudflare.ZeroTrustAccessApplicationUserPolicyCheckListParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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/zerotrustaccessbookmark.go b/zerotrustaccessbookmark.go deleted file mode 100644 index f7da55f09b1..00000000000 --- a/zerotrustaccessbookmark.go +++ /dev/null @@ -1,709 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustAccessBookmarkService 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 -// [NewZeroTrustAccessBookmarkService] method instead. -type ZeroTrustAccessBookmarkService struct { - Options []option.RequestOption -} - -// NewZeroTrustAccessBookmarkService 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 NewZeroTrustAccessBookmarkService(opts ...option.RequestOption) (r *ZeroTrustAccessBookmarkService) { - r = &ZeroTrustAccessBookmarkService{} - r.Options = opts - return -} - -// Create a new Bookmark application. -func (r *ZeroTrustAccessBookmarkService) New(ctx context.Context, identifier interface{}, uuid string, opts ...option.RequestOption) (res *ZeroTrustAccessBookmarkNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessBookmarkNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/access/bookmarks/%s", identifier, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a configured Bookmark application. -func (r *ZeroTrustAccessBookmarkService) Update(ctx context.Context, identifier interface{}, uuid string, opts ...option.RequestOption) (res *ZeroTrustAccessBookmarkUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessBookmarkUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/access/bookmarks/%s", identifier, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists Bookmark applications. -func (r *ZeroTrustAccessBookmarkService) List(ctx context.Context, identifier interface{}, opts ...option.RequestOption) (res *[]ZeroTrustAccessBookmarkListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessBookmarkListResponseEnvelope - path := fmt.Sprintf("accounts/%v/access/bookmarks", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a Bookmark application. -func (r *ZeroTrustAccessBookmarkService) Delete(ctx context.Context, identifier interface{}, uuid string, opts ...option.RequestOption) (res *ZeroTrustAccessBookmarkDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessBookmarkDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%v/access/bookmarks/%s", identifier, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a single Bookmark application. -func (r *ZeroTrustAccessBookmarkService) Get(ctx context.Context, identifier interface{}, uuid string, opts ...option.RequestOption) (res *ZeroTrustAccessBookmarkGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessBookmarkGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/access/bookmarks/%s", identifier, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustAccessBookmarkNewResponse struct { - // The unique identifier for the Bookmark application. - ID interface{} `json:"id"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The domain of the Bookmark application. - Domain string `json:"domain"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the Bookmark application. - Name string `json:"name"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessBookmarkNewResponseJSON `json:"-"` -} - -// zeroTrustAccessBookmarkNewResponseJSON contains the JSON metadata for the struct -// [ZeroTrustAccessBookmarkNewResponse] -type zeroTrustAccessBookmarkNewResponseJSON struct { - ID apijson.Field - AppLauncherVisible apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - LogoURL apijson.Field - Name apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkNewResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessBookmarkUpdateResponse struct { - // The unique identifier for the Bookmark application. - ID interface{} `json:"id"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The domain of the Bookmark application. - Domain string `json:"domain"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the Bookmark application. - Name string `json:"name"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessBookmarkUpdateResponseJSON `json:"-"` -} - -// zeroTrustAccessBookmarkUpdateResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessBookmarkUpdateResponse] -type zeroTrustAccessBookmarkUpdateResponseJSON struct { - ID apijson.Field - AppLauncherVisible apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - LogoURL apijson.Field - Name apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessBookmarkListResponse struct { - // The unique identifier for the Bookmark application. - ID interface{} `json:"id"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The domain of the Bookmark application. - Domain string `json:"domain"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the Bookmark application. - Name string `json:"name"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessBookmarkListResponseJSON `json:"-"` -} - -// zeroTrustAccessBookmarkListResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessBookmarkListResponse] -type zeroTrustAccessBookmarkListResponseJSON struct { - ID apijson.Field - AppLauncherVisible apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - LogoURL apijson.Field - Name apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessBookmarkDeleteResponse struct { - // UUID - ID string `json:"id"` - JSON zeroTrustAccessBookmarkDeleteResponseJSON `json:"-"` -} - -// zeroTrustAccessBookmarkDeleteResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessBookmarkDeleteResponse] -type zeroTrustAccessBookmarkDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessBookmarkGetResponse struct { - // The unique identifier for the Bookmark application. - ID interface{} `json:"id"` - // Displays the application in the App Launcher. - AppLauncherVisible bool `json:"app_launcher_visible"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The domain of the Bookmark application. - Domain string `json:"domain"` - // The image URL for the logo shown in the App Launcher dashboard. - LogoURL string `json:"logo_url"` - // The name of the Bookmark application. - Name string `json:"name"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessBookmarkGetResponseJSON `json:"-"` -} - -// zeroTrustAccessBookmarkGetResponseJSON contains the JSON metadata for the struct -// [ZeroTrustAccessBookmarkGetResponse] -type zeroTrustAccessBookmarkGetResponseJSON struct { - ID apijson.Field - AppLauncherVisible apijson.Field - CreatedAt apijson.Field - Domain apijson.Field - LogoURL apijson.Field - Name apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessBookmarkNewResponseEnvelope struct { - Errors []ZeroTrustAccessBookmarkNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessBookmarkNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessBookmarkNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessBookmarkNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessBookmarkNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessBookmarkNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustAccessBookmarkNewResponseEnvelope] -type zeroTrustAccessBookmarkNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessBookmarkNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessBookmarkNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessBookmarkNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustAccessBookmarkNewResponseEnvelopeErrors] -type zeroTrustAccessBookmarkNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessBookmarkNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessBookmarkNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessBookmarkNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustAccessBookmarkNewResponseEnvelopeMessages] -type zeroTrustAccessBookmarkNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessBookmarkNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessBookmarkNewResponseEnvelopeSuccessTrue ZeroTrustAccessBookmarkNewResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessBookmarkUpdateResponseEnvelope struct { - Errors []ZeroTrustAccessBookmarkUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessBookmarkUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessBookmarkUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessBookmarkUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessBookmarkUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessBookmarkUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustAccessBookmarkUpdateResponseEnvelope] -type zeroTrustAccessBookmarkUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessBookmarkUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessBookmarkUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessBookmarkUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessBookmarkUpdateResponseEnvelopeErrors] -type zeroTrustAccessBookmarkUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessBookmarkUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessBookmarkUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessBookmarkUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustAccessBookmarkUpdateResponseEnvelopeMessages] -type zeroTrustAccessBookmarkUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessBookmarkUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessBookmarkUpdateResponseEnvelopeSuccessTrue ZeroTrustAccessBookmarkUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessBookmarkListResponseEnvelope struct { - Errors []ZeroTrustAccessBookmarkListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessBookmarkListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustAccessBookmarkListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustAccessBookmarkListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustAccessBookmarkListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustAccessBookmarkListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessBookmarkListResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustAccessBookmarkListResponseEnvelope] -type zeroTrustAccessBookmarkListResponseEnvelopeJSON 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 *ZeroTrustAccessBookmarkListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessBookmarkListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessBookmarkListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessBookmarkListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustAccessBookmarkListResponseEnvelopeErrors] -type zeroTrustAccessBookmarkListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessBookmarkListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessBookmarkListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessBookmarkListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustAccessBookmarkListResponseEnvelopeMessages] -type zeroTrustAccessBookmarkListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessBookmarkListResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessBookmarkListResponseEnvelopeSuccessTrue ZeroTrustAccessBookmarkListResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessBookmarkListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustAccessBookmarkListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustAccessBookmarkListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustAccessBookmarkListResponseEnvelopeResultInfo] -type zeroTrustAccessBookmarkListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessBookmarkDeleteResponseEnvelope struct { - Errors []ZeroTrustAccessBookmarkDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessBookmarkDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessBookmarkDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessBookmarkDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessBookmarkDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessBookmarkDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustAccessBookmarkDeleteResponseEnvelope] -type zeroTrustAccessBookmarkDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessBookmarkDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessBookmarkDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessBookmarkDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessBookmarkDeleteResponseEnvelopeErrors] -type zeroTrustAccessBookmarkDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessBookmarkDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessBookmarkDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessBookmarkDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustAccessBookmarkDeleteResponseEnvelopeMessages] -type zeroTrustAccessBookmarkDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessBookmarkDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessBookmarkDeleteResponseEnvelopeSuccessTrue ZeroTrustAccessBookmarkDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessBookmarkGetResponseEnvelope struct { - Errors []ZeroTrustAccessBookmarkGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessBookmarkGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessBookmarkGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessBookmarkGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessBookmarkGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessBookmarkGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustAccessBookmarkGetResponseEnvelope] -type zeroTrustAccessBookmarkGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessBookmarkGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessBookmarkGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessBookmarkGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustAccessBookmarkGetResponseEnvelopeErrors] -type zeroTrustAccessBookmarkGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessBookmarkGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessBookmarkGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessBookmarkGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustAccessBookmarkGetResponseEnvelopeMessages] -type zeroTrustAccessBookmarkGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessBookmarkGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessBookmarkGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessBookmarkGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessBookmarkGetResponseEnvelopeSuccessTrue ZeroTrustAccessBookmarkGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustaccessbookmark_test.go b/zerotrustaccessbookmark_test.go deleted file mode 100644 index 49f587c4a2c..00000000000 --- a/zerotrustaccessbookmark_test.go +++ /dev/null @@ -1,150 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustAccessBookmarkNew(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Bookmarks.New( - context.TODO(), - "699d98642c564d2e855e9661899b7252", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - 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 TestZeroTrustAccessBookmarkUpdate(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Bookmarks.Update( - context.TODO(), - "699d98642c564d2e855e9661899b7252", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - 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 TestZeroTrustAccessBookmarkList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Bookmarks.List(context.TODO(), "699d98642c564d2e855e9661899b7252") - 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 TestZeroTrustAccessBookmarkDelete(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Bookmarks.Delete( - context.TODO(), - "699d98642c564d2e855e9661899b7252", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - 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 TestZeroTrustAccessBookmarkGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Bookmarks.Get( - context.TODO(), - "699d98642c564d2e855e9661899b7252", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - 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/zerotrustaccesscertificate.go b/zerotrustaccesscertificate.go deleted file mode 100644 index 54ff9c5ef64..00000000000 --- a/zerotrustaccesscertificate.go +++ /dev/null @@ -1,809 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustAccessCertificateService 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 -// [NewZeroTrustAccessCertificateService] method instead. -type ZeroTrustAccessCertificateService struct { - Options []option.RequestOption - Settings *ZeroTrustAccessCertificateSettingService -} - -// NewZeroTrustAccessCertificateService 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 NewZeroTrustAccessCertificateService(opts ...option.RequestOption) (r *ZeroTrustAccessCertificateService) { - r = &ZeroTrustAccessCertificateService{} - r.Options = opts - r.Settings = NewZeroTrustAccessCertificateSettingService(opts...) - return -} - -// Adds a new mTLS root certificate to Access. -func (r *ZeroTrustAccessCertificateService) New(ctx context.Context, params ZeroTrustAccessCertificateNewParams, opts ...option.RequestOption) (res *ZeroTrustAccessCertificateNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessCertificateNewResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/access/certificates", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a configured mTLS certificate. -func (r *ZeroTrustAccessCertificateService) Update(ctx context.Context, uuid string, params ZeroTrustAccessCertificateUpdateParams, opts ...option.RequestOption) (res *ZeroTrustAccessCertificateUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessCertificateUpdateResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/access/certificates/%s", accountOrZone, accountOrZoneID, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists all mTLS root certificates. -func (r *ZeroTrustAccessCertificateService) List(ctx context.Context, query ZeroTrustAccessCertificateListParams, opts ...option.RequestOption) (res *[]ZeroTrustAccessCertificateListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessCertificateListResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/access/certificates", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes an mTLS certificate. -func (r *ZeroTrustAccessCertificateService) Delete(ctx context.Context, uuid string, body ZeroTrustAccessCertificateDeleteParams, opts ...option.RequestOption) (res *ZeroTrustAccessCertificateDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessCertificateDeleteResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if body.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = body.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = body.ZoneID - } - path := fmt.Sprintf("%s/%s/access/certificates/%s", accountOrZone, accountOrZoneID, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a single mTLS certificate. -func (r *ZeroTrustAccessCertificateService) Get(ctx context.Context, uuid string, query ZeroTrustAccessCertificateGetParams, opts ...option.RequestOption) (res *ZeroTrustAccessCertificateGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessCertificateGetResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/access/certificates/%s", accountOrZone, accountOrZoneID, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustAccessCertificateNewResponse struct { - // The ID of the application that will use this certificate. - ID interface{} `json:"id"` - // The hostnames of the applications that will use this certificate. - AssociatedHostnames []string `json:"associated_hostnames"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - ExpiresOn time.Time `json:"expires_on" format:"date-time"` - // The MD5 fingerprint of the certificate. - Fingerprint string `json:"fingerprint"` - // The name of the certificate. - Name string `json:"name"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessCertificateNewResponseJSON `json:"-"` -} - -// zeroTrustAccessCertificateNewResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessCertificateNewResponse] -type zeroTrustAccessCertificateNewResponseJSON struct { - ID apijson.Field - AssociatedHostnames apijson.Field - CreatedAt apijson.Field - ExpiresOn apijson.Field - Fingerprint apijson.Field - Name apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateNewResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateUpdateResponse struct { - // The ID of the application that will use this certificate. - ID interface{} `json:"id"` - // The hostnames of the applications that will use this certificate. - AssociatedHostnames []string `json:"associated_hostnames"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - ExpiresOn time.Time `json:"expires_on" format:"date-time"` - // The MD5 fingerprint of the certificate. - Fingerprint string `json:"fingerprint"` - // The name of the certificate. - Name string `json:"name"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessCertificateUpdateResponseJSON `json:"-"` -} - -// zeroTrustAccessCertificateUpdateResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessCertificateUpdateResponse] -type zeroTrustAccessCertificateUpdateResponseJSON struct { - ID apijson.Field - AssociatedHostnames apijson.Field - CreatedAt apijson.Field - ExpiresOn apijson.Field - Fingerprint apijson.Field - Name apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateListResponse struct { - // The ID of the application that will use this certificate. - ID interface{} `json:"id"` - // The hostnames of the applications that will use this certificate. - AssociatedHostnames []string `json:"associated_hostnames"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - ExpiresOn time.Time `json:"expires_on" format:"date-time"` - // The MD5 fingerprint of the certificate. - Fingerprint string `json:"fingerprint"` - // The name of the certificate. - Name string `json:"name"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessCertificateListResponseJSON `json:"-"` -} - -// zeroTrustAccessCertificateListResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessCertificateListResponse] -type zeroTrustAccessCertificateListResponseJSON struct { - ID apijson.Field - AssociatedHostnames apijson.Field - CreatedAt apijson.Field - ExpiresOn apijson.Field - Fingerprint apijson.Field - Name apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateDeleteResponse struct { - // UUID - ID string `json:"id"` - JSON zeroTrustAccessCertificateDeleteResponseJSON `json:"-"` -} - -// zeroTrustAccessCertificateDeleteResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessCertificateDeleteResponse] -type zeroTrustAccessCertificateDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateGetResponse struct { - // The ID of the application that will use this certificate. - ID interface{} `json:"id"` - // The hostnames of the applications that will use this certificate. - AssociatedHostnames []string `json:"associated_hostnames"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - ExpiresOn time.Time `json:"expires_on" format:"date-time"` - // The MD5 fingerprint of the certificate. - Fingerprint string `json:"fingerprint"` - // The name of the certificate. - Name string `json:"name"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessCertificateGetResponseJSON `json:"-"` -} - -// zeroTrustAccessCertificateGetResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessCertificateGetResponse] -type zeroTrustAccessCertificateGetResponseJSON struct { - ID apijson.Field - AssociatedHostnames apijson.Field - CreatedAt apijson.Field - ExpiresOn apijson.Field - Fingerprint apijson.Field - Name apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateNewParams struct { - // The certificate content. - Certificate param.Field[string] `json:"certificate,required"` - // The name of the certificate. - Name param.Field[string] `json:"name,required"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // The hostnames of the applications that will use this certificate. - AssociatedHostnames param.Field[[]string] `json:"associated_hostnames"` -} - -func (r ZeroTrustAccessCertificateNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustAccessCertificateNewResponseEnvelope struct { - Errors []ZeroTrustAccessCertificateNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessCertificateNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessCertificateNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessCertificateNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessCertificateNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessCertificateNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustAccessCertificateNewResponseEnvelope] -type zeroTrustAccessCertificateNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCertificateNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessCertificateNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessCertificateNewResponseEnvelopeErrors] -type zeroTrustAccessCertificateNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCertificateNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessCertificateNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustAccessCertificateNewResponseEnvelopeMessages] -type zeroTrustAccessCertificateNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessCertificateNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessCertificateNewResponseEnvelopeSuccessTrue ZeroTrustAccessCertificateNewResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessCertificateUpdateParams struct { - // The hostnames of the applications that will use this certificate. - AssociatedHostnames param.Field[[]string] `json:"associated_hostnames,required"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // The name of the certificate. - Name param.Field[string] `json:"name"` -} - -func (r ZeroTrustAccessCertificateUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustAccessCertificateUpdateResponseEnvelope struct { - Errors []ZeroTrustAccessCertificateUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessCertificateUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessCertificateUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessCertificateUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessCertificateUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessCertificateUpdateResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustAccessCertificateUpdateResponseEnvelope] -type zeroTrustAccessCertificateUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCertificateUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessCertificateUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessCertificateUpdateResponseEnvelopeErrors] -type zeroTrustAccessCertificateUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCertificateUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessCertificateUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessCertificateUpdateResponseEnvelopeMessages] -type zeroTrustAccessCertificateUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessCertificateUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessCertificateUpdateResponseEnvelopeSuccessTrue ZeroTrustAccessCertificateUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessCertificateListParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustAccessCertificateListResponseEnvelope struct { - Errors []ZeroTrustAccessCertificateListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessCertificateListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustAccessCertificateListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustAccessCertificateListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustAccessCertificateListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustAccessCertificateListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessCertificateListResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustAccessCertificateListResponseEnvelope] -type zeroTrustAccessCertificateListResponseEnvelopeJSON 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 *ZeroTrustAccessCertificateListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCertificateListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessCertificateListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessCertificateListResponseEnvelopeErrors] -type zeroTrustAccessCertificateListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCertificateListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessCertificateListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustAccessCertificateListResponseEnvelopeMessages] -type zeroTrustAccessCertificateListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessCertificateListResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessCertificateListResponseEnvelopeSuccessTrue ZeroTrustAccessCertificateListResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessCertificateListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustAccessCertificateListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustAccessCertificateListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessCertificateListResponseEnvelopeResultInfo] -type zeroTrustAccessCertificateListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateDeleteParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustAccessCertificateDeleteResponseEnvelope struct { - Errors []ZeroTrustAccessCertificateDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessCertificateDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessCertificateDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessCertificateDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessCertificateDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessCertificateDeleteResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustAccessCertificateDeleteResponseEnvelope] -type zeroTrustAccessCertificateDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCertificateDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessCertificateDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessCertificateDeleteResponseEnvelopeErrors] -type zeroTrustAccessCertificateDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCertificateDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessCertificateDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessCertificateDeleteResponseEnvelopeMessages] -type zeroTrustAccessCertificateDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessCertificateDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessCertificateDeleteResponseEnvelopeSuccessTrue ZeroTrustAccessCertificateDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessCertificateGetParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustAccessCertificateGetResponseEnvelope struct { - Errors []ZeroTrustAccessCertificateGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessCertificateGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessCertificateGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessCertificateGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessCertificateGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessCertificateGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustAccessCertificateGetResponseEnvelope] -type zeroTrustAccessCertificateGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCertificateGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessCertificateGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessCertificateGetResponseEnvelopeErrors] -type zeroTrustAccessCertificateGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCertificateGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessCertificateGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustAccessCertificateGetResponseEnvelopeMessages] -type zeroTrustAccessCertificateGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessCertificateGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessCertificateGetResponseEnvelopeSuccessTrue ZeroTrustAccessCertificateGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustaccesscertificate_test.go b/zerotrustaccesscertificate_test.go deleted file mode 100644 index b79d114a481..00000000000 --- a/zerotrustaccesscertificate_test.go +++ /dev/null @@ -1,166 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustAccessCertificateNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Certificates.New(context.TODO(), cloudflare.ZeroTrustAccessCertificateNewParams{ - Certificate: cloudflare.F("-----BEGIN CERTIFICATE-----\nMIIGAjCCA+qgAwIBAgIJAI7kymlF7CWT...N4RI7KKB7nikiuUf8vhULKy5IX10\nDrUtmu/B\n-----END CERTIFICATE-----"), - Name: cloudflare.F("Allow devs"), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - AssociatedHostnames: cloudflare.F([]string{"admin.example.com", "admin.example.com", "admin.example.com"}), - }) - 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 TestZeroTrustAccessCertificateUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Certificates.Update( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustAccessCertificateUpdateParams{ - AssociatedHostnames: cloudflare.F([]string{"admin.example.com", "admin.example.com", "admin.example.com"}), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - Name: cloudflare.F("Allow devs"), - }, - ) - 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 TestZeroTrustAccessCertificateListWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Certificates.List(context.TODO(), cloudflare.ZeroTrustAccessCertificateListParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }) - 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 TestZeroTrustAccessCertificateDeleteWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Certificates.Delete( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustAccessCertificateDeleteParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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 TestZeroTrustAccessCertificateGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Certificates.Get( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustAccessCertificateGetParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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/zerotrustaccesscertificatesetting.go b/zerotrustaccesscertificatesetting.go deleted file mode 100644 index 3aeeb68acc0..00000000000 --- a/zerotrustaccesscertificatesetting.go +++ /dev/null @@ -1,408 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustAccessCertificateSettingService 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 -// [NewZeroTrustAccessCertificateSettingService] method instead. -type ZeroTrustAccessCertificateSettingService struct { - Options []option.RequestOption -} - -// NewZeroTrustAccessCertificateSettingService 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 NewZeroTrustAccessCertificateSettingService(opts ...option.RequestOption) (r *ZeroTrustAccessCertificateSettingService) { - r = &ZeroTrustAccessCertificateSettingService{} - r.Options = opts - return -} - -// Updates an mTLS certificate's hostname settings. -func (r *ZeroTrustAccessCertificateSettingService) Update(ctx context.Context, params ZeroTrustAccessCertificateSettingUpdateParams, opts ...option.RequestOption) (res *[]ZeroTrustAccessCertificateSettingUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessCertificateSettingUpdateResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/access/certificates/settings", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List all mTLS hostname settings for this account or zone. -func (r *ZeroTrustAccessCertificateSettingService) List(ctx context.Context, query ZeroTrustAccessCertificateSettingListParams, opts ...option.RequestOption) (res *[]ZeroTrustAccessCertificateSettingListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessCertificateSettingListResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/access/certificates/settings", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustAccessCertificateSettingUpdateResponse struct { - // Request client certificates for this hostname in China. Can only be set to true - // if this zone is china network enabled. - ChinaNetwork bool `json:"china_network,required"` - // Client Certificate Forwarding is a feature that takes the client cert provided - // by the eyeball to the edge, and forwards it to the origin as a HTTP header to - // allow logging on the origin. - ClientCertificateForwarding bool `json:"client_certificate_forwarding,required"` - // The hostname that these settings apply to. - Hostname string `json:"hostname,required"` - JSON zeroTrustAccessCertificateSettingUpdateResponseJSON `json:"-"` -} - -// zeroTrustAccessCertificateSettingUpdateResponseJSON contains the JSON metadata -// for the struct [ZeroTrustAccessCertificateSettingUpdateResponse] -type zeroTrustAccessCertificateSettingUpdateResponseJSON struct { - ChinaNetwork apijson.Field - ClientCertificateForwarding apijson.Field - Hostname apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateSettingUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateSettingUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateSettingListResponse struct { - // Request client certificates for this hostname in China. Can only be set to true - // if this zone is china network enabled. - ChinaNetwork bool `json:"china_network,required"` - // Client Certificate Forwarding is a feature that takes the client cert provided - // by the eyeball to the edge, and forwards it to the origin as a HTTP header to - // allow logging on the origin. - ClientCertificateForwarding bool `json:"client_certificate_forwarding,required"` - // The hostname that these settings apply to. - Hostname string `json:"hostname,required"` - JSON zeroTrustAccessCertificateSettingListResponseJSON `json:"-"` -} - -// zeroTrustAccessCertificateSettingListResponseJSON contains the JSON metadata for -// the struct [ZeroTrustAccessCertificateSettingListResponse] -type zeroTrustAccessCertificateSettingListResponseJSON struct { - ChinaNetwork apijson.Field - ClientCertificateForwarding apijson.Field - Hostname apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateSettingListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateSettingListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateSettingUpdateParams struct { - Settings param.Field[[]ZeroTrustAccessCertificateSettingUpdateParamsSetting] `json:"settings,required"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -func (r ZeroTrustAccessCertificateSettingUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustAccessCertificateSettingUpdateParamsSetting struct { - // Request client certificates for this hostname in China. Can only be set to true - // if this zone is china network enabled. - ChinaNetwork param.Field[bool] `json:"china_network,required"` - // Client Certificate Forwarding is a feature that takes the client cert provided - // by the eyeball to the edge, and forwards it to the origin as a HTTP header to - // allow logging on the origin. - ClientCertificateForwarding param.Field[bool] `json:"client_certificate_forwarding,required"` - // The hostname that these settings apply to. - Hostname param.Field[string] `json:"hostname,required"` -} - -func (r ZeroTrustAccessCertificateSettingUpdateParamsSetting) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustAccessCertificateSettingUpdateResponseEnvelope struct { - Errors []ZeroTrustAccessCertificateSettingUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessCertificateSettingUpdateResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustAccessCertificateSettingUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustAccessCertificateSettingUpdateResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustAccessCertificateSettingUpdateResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustAccessCertificateSettingUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessCertificateSettingUpdateResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessCertificateSettingUpdateResponseEnvelope] -type zeroTrustAccessCertificateSettingUpdateResponseEnvelopeJSON 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 *ZeroTrustAccessCertificateSettingUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateSettingUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateSettingUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCertificateSettingUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessCertificateSettingUpdateResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessCertificateSettingUpdateResponseEnvelopeErrors] -type zeroTrustAccessCertificateSettingUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateSettingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateSettingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateSettingUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCertificateSettingUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessCertificateSettingUpdateResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessCertificateSettingUpdateResponseEnvelopeMessages] -type zeroTrustAccessCertificateSettingUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateSettingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateSettingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessCertificateSettingUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessCertificateSettingUpdateResponseEnvelopeSuccessTrue ZeroTrustAccessCertificateSettingUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessCertificateSettingUpdateResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustAccessCertificateSettingUpdateResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustAccessCertificateSettingUpdateResponseEnvelopeResultInfoJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessCertificateSettingUpdateResponseEnvelopeResultInfo] -type zeroTrustAccessCertificateSettingUpdateResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateSettingUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateSettingUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateSettingListParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustAccessCertificateSettingListResponseEnvelope struct { - Errors []ZeroTrustAccessCertificateSettingListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessCertificateSettingListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustAccessCertificateSettingListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustAccessCertificateSettingListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustAccessCertificateSettingListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustAccessCertificateSettingListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessCertificateSettingListResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustAccessCertificateSettingListResponseEnvelope] -type zeroTrustAccessCertificateSettingListResponseEnvelopeJSON 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 *ZeroTrustAccessCertificateSettingListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateSettingListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateSettingListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCertificateSettingListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessCertificateSettingListResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessCertificateSettingListResponseEnvelopeErrors] -type zeroTrustAccessCertificateSettingListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateSettingListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateSettingListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCertificateSettingListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCertificateSettingListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessCertificateSettingListResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessCertificateSettingListResponseEnvelopeMessages] -type zeroTrustAccessCertificateSettingListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateSettingListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateSettingListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessCertificateSettingListResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessCertificateSettingListResponseEnvelopeSuccessTrue ZeroTrustAccessCertificateSettingListResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessCertificateSettingListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustAccessCertificateSettingListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustAccessCertificateSettingListResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessCertificateSettingListResponseEnvelopeResultInfo] -type zeroTrustAccessCertificateSettingListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCertificateSettingListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCertificateSettingListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zerotrustaccesscertificatesetting_test.go b/zerotrustaccesscertificatesetting_test.go deleted file mode 100644 index 11ab8e37aaf..00000000000 --- a/zerotrustaccesscertificatesetting_test.go +++ /dev/null @@ -1,81 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustAccessCertificateSettingUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Certificates.Settings.Update(context.TODO(), cloudflare.ZeroTrustAccessCertificateSettingUpdateParams{ - Settings: cloudflare.F([]cloudflare.ZeroTrustAccessCertificateSettingUpdateParamsSetting{{ - ChinaNetwork: cloudflare.F(false), - ClientCertificateForwarding: cloudflare.F(true), - Hostname: cloudflare.F("admin.example.com"), - }, { - ChinaNetwork: cloudflare.F(false), - ClientCertificateForwarding: cloudflare.F(true), - Hostname: cloudflare.F("admin.example.com"), - }, { - ChinaNetwork: cloudflare.F(false), - ClientCertificateForwarding: cloudflare.F(true), - Hostname: cloudflare.F("admin.example.com"), - }}), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }) - 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 TestZeroTrustAccessCertificateSettingListWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Certificates.Settings.List(context.TODO(), cloudflare.ZeroTrustAccessCertificateSettingListParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }) - 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/zerotrustaccesscustompage.go b/zerotrustaccesscustompage.go deleted file mode 100644 index ce2a2cced84..00000000000 --- a/zerotrustaccesscustompage.go +++ /dev/null @@ -1,782 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustAccessCustomPageService 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 -// [NewZeroTrustAccessCustomPageService] method instead. -type ZeroTrustAccessCustomPageService struct { - Options []option.RequestOption -} - -// NewZeroTrustAccessCustomPageService 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 NewZeroTrustAccessCustomPageService(opts ...option.RequestOption) (r *ZeroTrustAccessCustomPageService) { - r = &ZeroTrustAccessCustomPageService{} - r.Options = opts - return -} - -// Create a custom page -func (r *ZeroTrustAccessCustomPageService) New(ctx context.Context, identifier string, body ZeroTrustAccessCustomPageNewParams, opts ...option.RequestOption) (res *ZeroTrustAccessCustomPageNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessCustomPageNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/custom_pages", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update a custom page -func (r *ZeroTrustAccessCustomPageService) Update(ctx context.Context, identifier string, uuid string, body ZeroTrustAccessCustomPageUpdateParams, opts ...option.RequestOption) (res *ZeroTrustAccessCustomPageUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessCustomPageUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/custom_pages/%s", identifier, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List custom pages -func (r *ZeroTrustAccessCustomPageService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *[]ZeroTrustAccessCustomPageListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessCustomPageListResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/custom_pages", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a custom page -func (r *ZeroTrustAccessCustomPageService) Delete(ctx context.Context, identifier string, uuid string, opts ...option.RequestOption) (res *ZeroTrustAccessCustomPageDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessCustomPageDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/custom_pages/%s", identifier, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a custom page and also returns its HTML. -func (r *ZeroTrustAccessCustomPageService) Get(ctx context.Context, identifier string, uuid string, opts ...option.RequestOption) (res *ZeroTrustAccessCustomPageGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessCustomPageGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/custom_pages/%s", identifier, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustAccessCustomPageNewResponse struct { - // Custom page name. - Name string `json:"name,required"` - // Custom page type. - Type ZeroTrustAccessCustomPageNewResponseType `json:"type,required"` - // Number of apps the custom page is assigned to. - AppCount int64 `json:"app_count"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // UUID - Uid string `json:"uid"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessCustomPageNewResponseJSON `json:"-"` -} - -// zeroTrustAccessCustomPageNewResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessCustomPageNewResponse] -type zeroTrustAccessCustomPageNewResponseJSON struct { - Name apijson.Field - Type apijson.Field - AppCount apijson.Field - CreatedAt apijson.Field - Uid apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageNewResponseJSON) RawJSON() string { - return r.raw -} - -// Custom page type. -type ZeroTrustAccessCustomPageNewResponseType string - -const ( - ZeroTrustAccessCustomPageNewResponseTypeIdentityDenied ZeroTrustAccessCustomPageNewResponseType = "identity_denied" - ZeroTrustAccessCustomPageNewResponseTypeForbidden ZeroTrustAccessCustomPageNewResponseType = "forbidden" -) - -type ZeroTrustAccessCustomPageUpdateResponse struct { - // Custom page name. - Name string `json:"name,required"` - // Custom page type. - Type ZeroTrustAccessCustomPageUpdateResponseType `json:"type,required"` - // Number of apps the custom page is assigned to. - AppCount int64 `json:"app_count"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // UUID - Uid string `json:"uid"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessCustomPageUpdateResponseJSON `json:"-"` -} - -// zeroTrustAccessCustomPageUpdateResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessCustomPageUpdateResponse] -type zeroTrustAccessCustomPageUpdateResponseJSON struct { - Name apijson.Field - Type apijson.Field - AppCount apijson.Field - CreatedAt apijson.Field - Uid apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// Custom page type. -type ZeroTrustAccessCustomPageUpdateResponseType string - -const ( - ZeroTrustAccessCustomPageUpdateResponseTypeIdentityDenied ZeroTrustAccessCustomPageUpdateResponseType = "identity_denied" - ZeroTrustAccessCustomPageUpdateResponseTypeForbidden ZeroTrustAccessCustomPageUpdateResponseType = "forbidden" -) - -type ZeroTrustAccessCustomPageListResponse struct { - // Custom page name. - Name string `json:"name,required"` - // Custom page type. - Type ZeroTrustAccessCustomPageListResponseType `json:"type,required"` - // Number of apps the custom page is assigned to. - AppCount int64 `json:"app_count"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // UUID - Uid string `json:"uid"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessCustomPageListResponseJSON `json:"-"` -} - -// zeroTrustAccessCustomPageListResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessCustomPageListResponse] -type zeroTrustAccessCustomPageListResponseJSON struct { - Name apijson.Field - Type apijson.Field - AppCount apijson.Field - CreatedAt apijson.Field - Uid apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageListResponseJSON) RawJSON() string { - return r.raw -} - -// Custom page type. -type ZeroTrustAccessCustomPageListResponseType string - -const ( - ZeroTrustAccessCustomPageListResponseTypeIdentityDenied ZeroTrustAccessCustomPageListResponseType = "identity_denied" - ZeroTrustAccessCustomPageListResponseTypeForbidden ZeroTrustAccessCustomPageListResponseType = "forbidden" -) - -type ZeroTrustAccessCustomPageDeleteResponse struct { - // UUID - ID string `json:"id"` - JSON zeroTrustAccessCustomPageDeleteResponseJSON `json:"-"` -} - -// zeroTrustAccessCustomPageDeleteResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessCustomPageDeleteResponse] -type zeroTrustAccessCustomPageDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCustomPageGetResponse struct { - // Custom page HTML. - CustomHTML string `json:"custom_html,required"` - // Custom page name. - Name string `json:"name,required"` - // Custom page type. - Type ZeroTrustAccessCustomPageGetResponseType `json:"type,required"` - // Number of apps the custom page is assigned to. - AppCount int64 `json:"app_count"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // UUID - Uid string `json:"uid"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessCustomPageGetResponseJSON `json:"-"` -} - -// zeroTrustAccessCustomPageGetResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessCustomPageGetResponse] -type zeroTrustAccessCustomPageGetResponseJSON struct { - CustomHTML apijson.Field - Name apijson.Field - Type apijson.Field - AppCount apijson.Field - CreatedAt apijson.Field - Uid apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageGetResponseJSON) RawJSON() string { - return r.raw -} - -// Custom page type. -type ZeroTrustAccessCustomPageGetResponseType string - -const ( - ZeroTrustAccessCustomPageGetResponseTypeIdentityDenied ZeroTrustAccessCustomPageGetResponseType = "identity_denied" - ZeroTrustAccessCustomPageGetResponseTypeForbidden ZeroTrustAccessCustomPageGetResponseType = "forbidden" -) - -type ZeroTrustAccessCustomPageNewParams struct { - // Custom page HTML. - CustomHTML param.Field[string] `json:"custom_html,required"` - // Custom page name. - Name param.Field[string] `json:"name,required"` - // Custom page type. - Type param.Field[ZeroTrustAccessCustomPageNewParamsType] `json:"type,required"` - // Number of apps the custom page is assigned to. - AppCount param.Field[int64] `json:"app_count"` -} - -func (r ZeroTrustAccessCustomPageNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Custom page type. -type ZeroTrustAccessCustomPageNewParamsType string - -const ( - ZeroTrustAccessCustomPageNewParamsTypeIdentityDenied ZeroTrustAccessCustomPageNewParamsType = "identity_denied" - ZeroTrustAccessCustomPageNewParamsTypeForbidden ZeroTrustAccessCustomPageNewParamsType = "forbidden" -) - -type ZeroTrustAccessCustomPageNewResponseEnvelope struct { - Errors []ZeroTrustAccessCustomPageNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessCustomPageNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessCustomPageNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessCustomPageNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessCustomPageNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessCustomPageNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustAccessCustomPageNewResponseEnvelope] -type zeroTrustAccessCustomPageNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCustomPageNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCustomPageNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessCustomPageNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessCustomPageNewResponseEnvelopeErrors] -type zeroTrustAccessCustomPageNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCustomPageNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCustomPageNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessCustomPageNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustAccessCustomPageNewResponseEnvelopeMessages] -type zeroTrustAccessCustomPageNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessCustomPageNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessCustomPageNewResponseEnvelopeSuccessTrue ZeroTrustAccessCustomPageNewResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessCustomPageUpdateParams struct { - // Custom page HTML. - CustomHTML param.Field[string] `json:"custom_html,required"` - // Custom page name. - Name param.Field[string] `json:"name,required"` - // Custom page type. - Type param.Field[ZeroTrustAccessCustomPageUpdateParamsType] `json:"type,required"` - // Number of apps the custom page is assigned to. - AppCount param.Field[int64] `json:"app_count"` -} - -func (r ZeroTrustAccessCustomPageUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Custom page type. -type ZeroTrustAccessCustomPageUpdateParamsType string - -const ( - ZeroTrustAccessCustomPageUpdateParamsTypeIdentityDenied ZeroTrustAccessCustomPageUpdateParamsType = "identity_denied" - ZeroTrustAccessCustomPageUpdateParamsTypeForbidden ZeroTrustAccessCustomPageUpdateParamsType = "forbidden" -) - -type ZeroTrustAccessCustomPageUpdateResponseEnvelope struct { - Errors []ZeroTrustAccessCustomPageUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessCustomPageUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessCustomPageUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessCustomPageUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessCustomPageUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessCustomPageUpdateResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustAccessCustomPageUpdateResponseEnvelope] -type zeroTrustAccessCustomPageUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCustomPageUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCustomPageUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessCustomPageUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessCustomPageUpdateResponseEnvelopeErrors] -type zeroTrustAccessCustomPageUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCustomPageUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCustomPageUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessCustomPageUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessCustomPageUpdateResponseEnvelopeMessages] -type zeroTrustAccessCustomPageUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessCustomPageUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessCustomPageUpdateResponseEnvelopeSuccessTrue ZeroTrustAccessCustomPageUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessCustomPageListResponseEnvelope struct { - Errors []ZeroTrustAccessCustomPageListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessCustomPageListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustAccessCustomPageListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustAccessCustomPageListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustAccessCustomPageListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustAccessCustomPageListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessCustomPageListResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustAccessCustomPageListResponseEnvelope] -type zeroTrustAccessCustomPageListResponseEnvelopeJSON 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 *ZeroTrustAccessCustomPageListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCustomPageListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCustomPageListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessCustomPageListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessCustomPageListResponseEnvelopeErrors] -type zeroTrustAccessCustomPageListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCustomPageListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCustomPageListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessCustomPageListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustAccessCustomPageListResponseEnvelopeMessages] -type zeroTrustAccessCustomPageListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessCustomPageListResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessCustomPageListResponseEnvelopeSuccessTrue ZeroTrustAccessCustomPageListResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessCustomPageListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustAccessCustomPageListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustAccessCustomPageListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessCustomPageListResponseEnvelopeResultInfo] -type zeroTrustAccessCustomPageListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCustomPageDeleteResponseEnvelope struct { - Errors []ZeroTrustAccessCustomPageDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessCustomPageDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessCustomPageDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessCustomPageDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessCustomPageDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessCustomPageDeleteResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustAccessCustomPageDeleteResponseEnvelope] -type zeroTrustAccessCustomPageDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCustomPageDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCustomPageDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessCustomPageDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessCustomPageDeleteResponseEnvelopeErrors] -type zeroTrustAccessCustomPageDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCustomPageDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCustomPageDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessCustomPageDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessCustomPageDeleteResponseEnvelopeMessages] -type zeroTrustAccessCustomPageDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessCustomPageDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessCustomPageDeleteResponseEnvelopeSuccessTrue ZeroTrustAccessCustomPageDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessCustomPageGetResponseEnvelope struct { - Errors []ZeroTrustAccessCustomPageGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessCustomPageGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessCustomPageGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessCustomPageGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessCustomPageGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessCustomPageGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustAccessCustomPageGetResponseEnvelope] -type zeroTrustAccessCustomPageGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCustomPageGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCustomPageGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessCustomPageGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessCustomPageGetResponseEnvelopeErrors] -type zeroTrustAccessCustomPageGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessCustomPageGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessCustomPageGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessCustomPageGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustAccessCustomPageGetResponseEnvelopeMessages] -type zeroTrustAccessCustomPageGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessCustomPageGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessCustomPageGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessCustomPageGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessCustomPageGetResponseEnvelopeSuccessTrue ZeroTrustAccessCustomPageGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustaccesscustompage_test.go b/zerotrustaccesscustompage_test.go deleted file mode 100644 index 61183516b8c..00000000000 --- a/zerotrustaccesscustompage_test.go +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustAccessCustomPageNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.CustomPages.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.ZeroTrustAccessCustomPageNewParams{ - CustomHTML: cloudflare.F("

Access Denied

"), - Name: cloudflare.F("string"), - Type: cloudflare.F(cloudflare.ZeroTrustAccessCustomPageNewParamsTypeIdentityDenied), - AppCount: cloudflare.F(int64(0)), - }, - ) - 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 TestZeroTrustAccessCustomPageUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.CustomPages.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustAccessCustomPageUpdateParams{ - CustomHTML: cloudflare.F("

Access Denied

"), - Name: cloudflare.F("string"), - Type: cloudflare.F(cloudflare.ZeroTrustAccessCustomPageUpdateParamsTypeIdentityDenied), - AppCount: cloudflare.F(int64(0)), - }, - ) - 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 TestZeroTrustAccessCustomPageList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.CustomPages.List(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()) - } -} - -func TestZeroTrustAccessCustomPageDelete(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.CustomPages.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - 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 TestZeroTrustAccessCustomPageGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.CustomPages.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - 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/zerotrustaccessgroup.go b/zerotrustaccessgroup.go deleted file mode 100644 index 0db25a9b849..00000000000 --- a/zerotrustaccessgroup.go +++ /dev/null @@ -1,19157 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustAccessGroupService 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 [NewZeroTrustAccessGroupService] -// method instead. -type ZeroTrustAccessGroupService struct { - Options []option.RequestOption -} - -// NewZeroTrustAccessGroupService 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 NewZeroTrustAccessGroupService(opts ...option.RequestOption) (r *ZeroTrustAccessGroupService) { - r = &ZeroTrustAccessGroupService{} - r.Options = opts - return -} - -// Creates a new Access group. -func (r *ZeroTrustAccessGroupService) New(ctx context.Context, params ZeroTrustAccessGroupNewParams, opts ...option.RequestOption) (res *ZeroTrustAccessGroupNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessGroupNewResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/access/groups", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a configured Access group. -func (r *ZeroTrustAccessGroupService) Update(ctx context.Context, uuid string, params ZeroTrustAccessGroupUpdateParams, opts ...option.RequestOption) (res *ZeroTrustAccessGroupUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessGroupUpdateResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/access/groups/%s", accountOrZone, accountOrZoneID, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists all Access groups. -func (r *ZeroTrustAccessGroupService) List(ctx context.Context, query ZeroTrustAccessGroupListParams, opts ...option.RequestOption) (res *[]ZeroTrustAccessGroupListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessGroupListResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/access/groups", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes an Access group. -func (r *ZeroTrustAccessGroupService) Delete(ctx context.Context, uuid string, body ZeroTrustAccessGroupDeleteParams, opts ...option.RequestOption) (res *ZeroTrustAccessGroupDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessGroupDeleteResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if body.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = body.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = body.ZoneID - } - path := fmt.Sprintf("%s/%s/access/groups/%s", accountOrZone, accountOrZoneID, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a single Access group. -func (r *ZeroTrustAccessGroupService) Get(ctx context.Context, uuid string, query ZeroTrustAccessGroupGetParams, opts ...option.RequestOption) (res *ZeroTrustAccessGroupGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessGroupGetResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/access/groups/%s", accountOrZone, accountOrZoneID, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustAccessGroupNewResponse struct { - // UUID - ID string `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Rules evaluated with a NOT logical operator. To match a policy, a user cannot - // meet any of the Exclude rules. - Exclude []ZeroTrustAccessGroupNewResponseExclude `json:"exclude"` - // Rules evaluated with an OR logical operator. A user needs to meet only one of - // the Include rules. - Include []ZeroTrustAccessGroupNewResponseInclude `json:"include"` - // Rules evaluated with an AND logical operator. To match a policy, a user must - // meet all of the Require rules. - IsDefault []ZeroTrustAccessGroupNewResponseIsDefault `json:"is_default"` - // The name of the Access group. - Name string `json:"name"` - // Rules evaluated with an AND logical operator. To match a policy, a user must - // meet all of the Require rules. - Require []ZeroTrustAccessGroupNewResponseRequire `json:"require"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessGroupNewResponseJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseJSON contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponse] -type zeroTrustAccessGroupNewResponseJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Exclude apijson.Field - Include apijson.Field - IsDefault apijson.Field - Name apijson.Field - Require apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [ZeroTrustAccessGroupNewResponseExcludeAccessEmailRule], -// [ZeroTrustAccessGroupNewResponseExcludeAccessEmailListRule], -// [ZeroTrustAccessGroupNewResponseExcludeAccessDomainRule], -// [ZeroTrustAccessGroupNewResponseExcludeAccessEveryoneRule], -// [ZeroTrustAccessGroupNewResponseExcludeAccessIPRule], -// [ZeroTrustAccessGroupNewResponseExcludeAccessIPListRule], -// [ZeroTrustAccessGroupNewResponseExcludeAccessCertificateRule], -// [ZeroTrustAccessGroupNewResponseExcludeAccessAccessGroupRule], -// [ZeroTrustAccessGroupNewResponseExcludeAccessAzureGroupRule], -// [ZeroTrustAccessGroupNewResponseExcludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupNewResponseExcludeAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupNewResponseExcludeAccessOktaGroupRule], -// [ZeroTrustAccessGroupNewResponseExcludeAccessSamlGroupRule], -// [ZeroTrustAccessGroupNewResponseExcludeAccessServiceTokenRule], -// [ZeroTrustAccessGroupNewResponseExcludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupNewResponseExcludeAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupNewResponseExcludeAccessCountryRule], -// [ZeroTrustAccessGroupNewResponseExcludeAccessAuthenticationMethodRule] or -// [ZeroTrustAccessGroupNewResponseExcludeAccessDevicePostureRule]. -type ZeroTrustAccessGroupNewResponseExclude interface { - implementsZeroTrustAccessGroupNewResponseExclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessGroupNewResponseExclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseExcludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessGroupNewResponseExcludeAccessEmailRule struct { - Email ZeroTrustAccessGroupNewResponseExcludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessEmailRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupNewResponseExcludeAccessEmailRule] -type zeroTrustAccessGroupNewResponseExcludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessEmailRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -type ZeroTrustAccessGroupNewResponseExcludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessEmailRuleEmailJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessEmailRuleEmail] -type zeroTrustAccessGroupNewResponseExcludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupNewResponseExcludeAccessEmailListRule struct { - EmailList ZeroTrustAccessGroupNewResponseExcludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessEmailListRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessEmailListRule] -type zeroTrustAccessGroupNewResponseExcludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessEmailListRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -type ZeroTrustAccessGroupNewResponseExcludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessEmailListRuleEmailListJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessEmailListRuleEmailList] -type zeroTrustAccessGroupNewResponseExcludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessGroupNewResponseExcludeAccessDomainRule struct { - EmailDomain ZeroTrustAccessGroupNewResponseExcludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessDomainRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupNewResponseExcludeAccessDomainRule] -type zeroTrustAccessGroupNewResponseExcludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessDomainRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -type ZeroTrustAccessGroupNewResponseExcludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessDomainRuleEmailDomainJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessDomainRuleEmailDomain] -type zeroTrustAccessGroupNewResponseExcludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessGroupNewResponseExcludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessEveryoneRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessEveryoneRule] -type zeroTrustAccessGroupNewResponseExcludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessEveryoneRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupNewResponseExcludeAccessIPRule struct { - IP ZeroTrustAccessGroupNewResponseExcludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessIPRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupNewResponseExcludeAccessIPRule] -type zeroTrustAccessGroupNewResponseExcludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessIPRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -type ZeroTrustAccessGroupNewResponseExcludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessIPRuleIPJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupNewResponseExcludeAccessIPRuleIP] -type zeroTrustAccessGroupNewResponseExcludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupNewResponseExcludeAccessIPListRule struct { - IPList ZeroTrustAccessGroupNewResponseExcludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessIPListRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupNewResponseExcludeAccessIPListRule] -type zeroTrustAccessGroupNewResponseExcludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessIPListRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -type ZeroTrustAccessGroupNewResponseExcludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessIPListRuleIPListJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessIPListRuleIPList] -type zeroTrustAccessGroupNewResponseExcludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupNewResponseExcludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessCertificateRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessCertificateRule] -type zeroTrustAccessGroupNewResponseExcludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessCertificateRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupNewResponseExcludeAccessAccessGroupRule struct { - Group ZeroTrustAccessGroupNewResponseExcludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessAccessGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessAccessGroupRule] -type zeroTrustAccessGroupNewResponseExcludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessAccessGroupRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -type ZeroTrustAccessGroupNewResponseExcludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessAccessGroupRuleGroupJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessAccessGroupRuleGroup] -type zeroTrustAccessGroupNewResponseExcludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupNewResponseExcludeAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessGroupNewResponseExcludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessAzureGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessAzureGroupRule] -type zeroTrustAccessGroupNewResponseExcludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessAzureGroupRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -type ZeroTrustAccessGroupNewResponseExcludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessAzureGroupRuleAzureAdJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessAzureGroupRuleAzureAd] -type zeroTrustAccessGroupNewResponseExcludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupNewResponseExcludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessGroupNewResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessGitHubOrganizationRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessGitHubOrganizationRule] -type zeroTrustAccessGroupNewResponseExcludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -type ZeroTrustAccessGroupNewResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessGroupNewResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupNewResponseExcludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessGroupNewResponseExcludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessGsuiteGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessGsuiteGroupRule] -type zeroTrustAccessGroupNewResponseExcludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -type ZeroTrustAccessGroupNewResponseExcludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessGsuiteGroupRuleGsuiteJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessGroupNewResponseExcludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupNewResponseExcludeAccessOktaGroupRule struct { - Okta ZeroTrustAccessGroupNewResponseExcludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessOktaGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessOktaGroupRule] -type zeroTrustAccessGroupNewResponseExcludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessOktaGroupRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -type ZeroTrustAccessGroupNewResponseExcludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessOktaGroupRuleOktaJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessOktaGroupRuleOkta] -type zeroTrustAccessGroupNewResponseExcludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupNewResponseExcludeAccessSamlGroupRule struct { - Saml ZeroTrustAccessGroupNewResponseExcludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessSamlGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessSamlGroupRule] -type zeroTrustAccessGroupNewResponseExcludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessSamlGroupRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -type ZeroTrustAccessGroupNewResponseExcludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessSamlGroupRuleSamlJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessSamlGroupRuleSaml] -type zeroTrustAccessGroupNewResponseExcludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupNewResponseExcludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessGroupNewResponseExcludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessServiceTokenRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessServiceTokenRule] -type zeroTrustAccessGroupNewResponseExcludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessServiceTokenRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -type ZeroTrustAccessGroupNewResponseExcludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessServiceTokenRuleServiceToken] -type zeroTrustAccessGroupNewResponseExcludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupNewResponseExcludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessAnyValidServiceTokenRule] -type zeroTrustAccessGroupNewResponseExcludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupNewResponseExcludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessGroupNewResponseExcludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessExternalEvaluationRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessExternalEvaluationRule] -type zeroTrustAccessGroupNewResponseExcludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -type ZeroTrustAccessGroupNewResponseExcludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessGroupNewResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessGroupNewResponseExcludeAccessCountryRule struct { - Geo ZeroTrustAccessGroupNewResponseExcludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessCountryRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessCountryRule] -type zeroTrustAccessGroupNewResponseExcludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessCountryRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -type ZeroTrustAccessGroupNewResponseExcludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessCountryRuleGeoJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessCountryRuleGeo] -type zeroTrustAccessGroupNewResponseExcludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessGroupNewResponseExcludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessGroupNewResponseExcludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessAuthenticationMethodRule] -type zeroTrustAccessGroupNewResponseExcludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -type ZeroTrustAccessGroupNewResponseExcludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessGroupNewResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupNewResponseExcludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessGroupNewResponseExcludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessDevicePostureRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessDevicePostureRule] -type zeroTrustAccessGroupNewResponseExcludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseExcludeAccessDevicePostureRule) implementsZeroTrustAccessGroupNewResponseExclude() { -} - -type ZeroTrustAccessGroupNewResponseExcludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessGroupNewResponseExcludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseExcludeAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseExcludeAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessGroupNewResponseExcludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseExcludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseExcludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [ZeroTrustAccessGroupNewResponseIncludeAccessEmailRule], -// [ZeroTrustAccessGroupNewResponseIncludeAccessEmailListRule], -// [ZeroTrustAccessGroupNewResponseIncludeAccessDomainRule], -// [ZeroTrustAccessGroupNewResponseIncludeAccessEveryoneRule], -// [ZeroTrustAccessGroupNewResponseIncludeAccessIPRule], -// [ZeroTrustAccessGroupNewResponseIncludeAccessIPListRule], -// [ZeroTrustAccessGroupNewResponseIncludeAccessCertificateRule], -// [ZeroTrustAccessGroupNewResponseIncludeAccessAccessGroupRule], -// [ZeroTrustAccessGroupNewResponseIncludeAccessAzureGroupRule], -// [ZeroTrustAccessGroupNewResponseIncludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupNewResponseIncludeAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupNewResponseIncludeAccessOktaGroupRule], -// [ZeroTrustAccessGroupNewResponseIncludeAccessSamlGroupRule], -// [ZeroTrustAccessGroupNewResponseIncludeAccessServiceTokenRule], -// [ZeroTrustAccessGroupNewResponseIncludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupNewResponseIncludeAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupNewResponseIncludeAccessCountryRule], -// [ZeroTrustAccessGroupNewResponseIncludeAccessAuthenticationMethodRule] or -// [ZeroTrustAccessGroupNewResponseIncludeAccessDevicePostureRule]. -type ZeroTrustAccessGroupNewResponseInclude interface { - implementsZeroTrustAccessGroupNewResponseInclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessGroupNewResponseInclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIncludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessGroupNewResponseIncludeAccessEmailRule struct { - Email ZeroTrustAccessGroupNewResponseIncludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessEmailRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupNewResponseIncludeAccessEmailRule] -type zeroTrustAccessGroupNewResponseIncludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessEmailRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -type ZeroTrustAccessGroupNewResponseIncludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessEmailRuleEmailJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessEmailRuleEmail] -type zeroTrustAccessGroupNewResponseIncludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupNewResponseIncludeAccessEmailListRule struct { - EmailList ZeroTrustAccessGroupNewResponseIncludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessEmailListRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessEmailListRule] -type zeroTrustAccessGroupNewResponseIncludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessEmailListRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -type ZeroTrustAccessGroupNewResponseIncludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessEmailListRuleEmailListJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessEmailListRuleEmailList] -type zeroTrustAccessGroupNewResponseIncludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessGroupNewResponseIncludeAccessDomainRule struct { - EmailDomain ZeroTrustAccessGroupNewResponseIncludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessDomainRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupNewResponseIncludeAccessDomainRule] -type zeroTrustAccessGroupNewResponseIncludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessDomainRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -type ZeroTrustAccessGroupNewResponseIncludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessDomainRuleEmailDomainJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessDomainRuleEmailDomain] -type zeroTrustAccessGroupNewResponseIncludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessGroupNewResponseIncludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessEveryoneRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessEveryoneRule] -type zeroTrustAccessGroupNewResponseIncludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessEveryoneRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupNewResponseIncludeAccessIPRule struct { - IP ZeroTrustAccessGroupNewResponseIncludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessIPRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupNewResponseIncludeAccessIPRule] -type zeroTrustAccessGroupNewResponseIncludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessIPRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -type ZeroTrustAccessGroupNewResponseIncludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessIPRuleIPJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupNewResponseIncludeAccessIPRuleIP] -type zeroTrustAccessGroupNewResponseIncludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupNewResponseIncludeAccessIPListRule struct { - IPList ZeroTrustAccessGroupNewResponseIncludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessIPListRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupNewResponseIncludeAccessIPListRule] -type zeroTrustAccessGroupNewResponseIncludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessIPListRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -type ZeroTrustAccessGroupNewResponseIncludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessIPListRuleIPListJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessIPListRuleIPList] -type zeroTrustAccessGroupNewResponseIncludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupNewResponseIncludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessCertificateRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessCertificateRule] -type zeroTrustAccessGroupNewResponseIncludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessCertificateRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupNewResponseIncludeAccessAccessGroupRule struct { - Group ZeroTrustAccessGroupNewResponseIncludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessAccessGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessAccessGroupRule] -type zeroTrustAccessGroupNewResponseIncludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessAccessGroupRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -type ZeroTrustAccessGroupNewResponseIncludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessAccessGroupRuleGroupJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessAccessGroupRuleGroup] -type zeroTrustAccessGroupNewResponseIncludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupNewResponseIncludeAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessGroupNewResponseIncludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessAzureGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessAzureGroupRule] -type zeroTrustAccessGroupNewResponseIncludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessAzureGroupRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -type ZeroTrustAccessGroupNewResponseIncludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessAzureGroupRuleAzureAdJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessAzureGroupRuleAzureAd] -type zeroTrustAccessGroupNewResponseIncludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupNewResponseIncludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessGroupNewResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessGitHubOrganizationRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessGitHubOrganizationRule] -type zeroTrustAccessGroupNewResponseIncludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -type ZeroTrustAccessGroupNewResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessGroupNewResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupNewResponseIncludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessGroupNewResponseIncludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessGsuiteGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessGsuiteGroupRule] -type zeroTrustAccessGroupNewResponseIncludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -type ZeroTrustAccessGroupNewResponseIncludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessGsuiteGroupRuleGsuiteJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessGroupNewResponseIncludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupNewResponseIncludeAccessOktaGroupRule struct { - Okta ZeroTrustAccessGroupNewResponseIncludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessOktaGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessOktaGroupRule] -type zeroTrustAccessGroupNewResponseIncludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessOktaGroupRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -type ZeroTrustAccessGroupNewResponseIncludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessOktaGroupRuleOktaJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessOktaGroupRuleOkta] -type zeroTrustAccessGroupNewResponseIncludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupNewResponseIncludeAccessSamlGroupRule struct { - Saml ZeroTrustAccessGroupNewResponseIncludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessSamlGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessSamlGroupRule] -type zeroTrustAccessGroupNewResponseIncludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessSamlGroupRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -type ZeroTrustAccessGroupNewResponseIncludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessSamlGroupRuleSamlJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessSamlGroupRuleSaml] -type zeroTrustAccessGroupNewResponseIncludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupNewResponseIncludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessGroupNewResponseIncludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessServiceTokenRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessServiceTokenRule] -type zeroTrustAccessGroupNewResponseIncludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessServiceTokenRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -type ZeroTrustAccessGroupNewResponseIncludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessServiceTokenRuleServiceToken] -type zeroTrustAccessGroupNewResponseIncludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupNewResponseIncludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessAnyValidServiceTokenRule] -type zeroTrustAccessGroupNewResponseIncludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupNewResponseIncludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessGroupNewResponseIncludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessExternalEvaluationRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessExternalEvaluationRule] -type zeroTrustAccessGroupNewResponseIncludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -type ZeroTrustAccessGroupNewResponseIncludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessGroupNewResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessGroupNewResponseIncludeAccessCountryRule struct { - Geo ZeroTrustAccessGroupNewResponseIncludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessCountryRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessCountryRule] -type zeroTrustAccessGroupNewResponseIncludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessCountryRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -type ZeroTrustAccessGroupNewResponseIncludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessCountryRuleGeoJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessCountryRuleGeo] -type zeroTrustAccessGroupNewResponseIncludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessGroupNewResponseIncludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessGroupNewResponseIncludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessAuthenticationMethodRule] -type zeroTrustAccessGroupNewResponseIncludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -type ZeroTrustAccessGroupNewResponseIncludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessGroupNewResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupNewResponseIncludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessGroupNewResponseIncludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessDevicePostureRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessDevicePostureRule] -type zeroTrustAccessGroupNewResponseIncludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIncludeAccessDevicePostureRule) implementsZeroTrustAccessGroupNewResponseInclude() { -} - -type ZeroTrustAccessGroupNewResponseIncludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessGroupNewResponseIncludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIncludeAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIncludeAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessGroupNewResponseIncludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIncludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIncludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailRule], -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailListRule], -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessDomainRule], -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessEveryoneRule], -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessIPRule], -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessIPListRule], -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessCertificateRule], -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessAccessGroupRule], -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessAzureGroupRule], -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessOktaGroupRule], -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessSamlGroupRule], -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessServiceTokenRule], -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessCountryRule], -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessAuthenticationMethodRule] or -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessDevicePostureRule]. -type ZeroTrustAccessGroupNewResponseIsDefault interface { - implementsZeroTrustAccessGroupNewResponseIsDefault() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessGroupNewResponseIsDefault)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseIsDefaultAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailRule struct { - Email ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessEmailRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -type ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessEmailRuleEmailJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailRuleEmail] -type zeroTrustAccessGroupNewResponseIsDefaultAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailListRule struct { - EmailList ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessEmailListRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailListRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailListRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -type ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailListRuleEmailList] -type zeroTrustAccessGroupNewResponseIsDefaultAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessGroupNewResponseIsDefaultAccessDomainRule struct { - EmailDomain ZeroTrustAccessGroupNewResponseIsDefaultAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessDomainRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessDomainRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessDomainRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -type ZeroTrustAccessGroupNewResponseIsDefaultAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessDomainRuleEmailDomainJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessDomainRuleEmailDomain] -type zeroTrustAccessGroupNewResponseIsDefaultAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessGroupNewResponseIsDefaultAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessEveryoneRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessEveryoneRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessEveryoneRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupNewResponseIsDefaultAccessIPRule struct { - IP ZeroTrustAccessGroupNewResponseIsDefaultAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessIPRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupNewResponseIsDefaultAccessIPRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessIPRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -type ZeroTrustAccessGroupNewResponseIsDefaultAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessIPRuleIPJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupNewResponseIsDefaultAccessIPRuleIP] -type zeroTrustAccessGroupNewResponseIsDefaultAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupNewResponseIsDefaultAccessIPListRule struct { - IPList ZeroTrustAccessGroupNewResponseIsDefaultAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessIPListRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessIPListRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessIPListRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -type ZeroTrustAccessGroupNewResponseIsDefaultAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessIPListRuleIPListJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessIPListRuleIPList] -type zeroTrustAccessGroupNewResponseIsDefaultAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupNewResponseIsDefaultAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessCertificateRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessCertificateRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessCertificateRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupNewResponseIsDefaultAccessAccessGroupRule struct { - Group ZeroTrustAccessGroupNewResponseIsDefaultAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessAccessGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessAccessGroupRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessAccessGroupRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -type ZeroTrustAccessGroupNewResponseIsDefaultAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessAccessGroupRuleGroupJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessAccessGroupRuleGroup] -type zeroTrustAccessGroupNewResponseIsDefaultAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupNewResponseIsDefaultAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessGroupNewResponseIsDefaultAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessAzureGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessAzureGroupRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessAzureGroupRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -type ZeroTrustAccessGroupNewResponseIsDefaultAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessAzureGroupRuleAzureAdJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessAzureGroupRuleAzureAd] -type zeroTrustAccessGroupNewResponseIsDefaultAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupNewResponseIsDefaultAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessGroupNewResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessGitHubOrganizationRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -type ZeroTrustAccessGroupNewResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessGroupNewResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupNewResponseIsDefaultAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessGroupNewResponseIsDefaultAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessGsuiteGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessGsuiteGroupRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessGsuiteGroupRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -type ZeroTrustAccessGroupNewResponseIsDefaultAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessGsuiteGroupRuleGsuiteJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessGroupNewResponseIsDefaultAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupNewResponseIsDefaultAccessOktaGroupRule struct { - Okta ZeroTrustAccessGroupNewResponseIsDefaultAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessOktaGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessOktaGroupRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessOktaGroupRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -type ZeroTrustAccessGroupNewResponseIsDefaultAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessOktaGroupRuleOktaJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessOktaGroupRuleOkta] -type zeroTrustAccessGroupNewResponseIsDefaultAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupNewResponseIsDefaultAccessSamlGroupRule struct { - Saml ZeroTrustAccessGroupNewResponseIsDefaultAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessSamlGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessSamlGroupRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessSamlGroupRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -type ZeroTrustAccessGroupNewResponseIsDefaultAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessSamlGroupRuleSamlJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessSamlGroupRuleSaml] -type zeroTrustAccessGroupNewResponseIsDefaultAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupNewResponseIsDefaultAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessGroupNewResponseIsDefaultAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessServiceTokenRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessServiceTokenRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessServiceTokenRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -type ZeroTrustAccessGroupNewResponseIsDefaultAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessServiceTokenRuleServiceToken] -type zeroTrustAccessGroupNewResponseIsDefaultAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupNewResponseIsDefaultAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessAnyValidServiceTokenRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupNewResponseIsDefaultAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessGroupNewResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessExternalEvaluationRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessExternalEvaluationRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -type ZeroTrustAccessGroupNewResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessGroupNewResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessGroupNewResponseIsDefaultAccessCountryRule struct { - Geo ZeroTrustAccessGroupNewResponseIsDefaultAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessCountryRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessCountryRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessCountryRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -type ZeroTrustAccessGroupNewResponseIsDefaultAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessCountryRuleGeoJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessCountryRuleGeo] -type zeroTrustAccessGroupNewResponseIsDefaultAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessGroupNewResponseIsDefaultAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessGroupNewResponseIsDefaultAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessAuthenticationMethodRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -type ZeroTrustAccessGroupNewResponseIsDefaultAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessGroupNewResponseIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupNewResponseIsDefaultAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessGroupNewResponseIsDefaultAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessDevicePostureRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessDevicePostureRule] -type zeroTrustAccessGroupNewResponseIsDefaultAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseIsDefaultAccessDevicePostureRule) implementsZeroTrustAccessGroupNewResponseIsDefault() { -} - -type ZeroTrustAccessGroupNewResponseIsDefaultAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessGroupNewResponseIsDefaultAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseIsDefaultAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseIsDefaultAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessGroupNewResponseIsDefaultAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseIsDefaultAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseIsDefaultAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [ZeroTrustAccessGroupNewResponseRequireAccessEmailRule], -// [ZeroTrustAccessGroupNewResponseRequireAccessEmailListRule], -// [ZeroTrustAccessGroupNewResponseRequireAccessDomainRule], -// [ZeroTrustAccessGroupNewResponseRequireAccessEveryoneRule], -// [ZeroTrustAccessGroupNewResponseRequireAccessIPRule], -// [ZeroTrustAccessGroupNewResponseRequireAccessIPListRule], -// [ZeroTrustAccessGroupNewResponseRequireAccessCertificateRule], -// [ZeroTrustAccessGroupNewResponseRequireAccessAccessGroupRule], -// [ZeroTrustAccessGroupNewResponseRequireAccessAzureGroupRule], -// [ZeroTrustAccessGroupNewResponseRequireAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupNewResponseRequireAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupNewResponseRequireAccessOktaGroupRule], -// [ZeroTrustAccessGroupNewResponseRequireAccessSamlGroupRule], -// [ZeroTrustAccessGroupNewResponseRequireAccessServiceTokenRule], -// [ZeroTrustAccessGroupNewResponseRequireAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupNewResponseRequireAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupNewResponseRequireAccessCountryRule], -// [ZeroTrustAccessGroupNewResponseRequireAccessAuthenticationMethodRule] or -// [ZeroTrustAccessGroupNewResponseRequireAccessDevicePostureRule]. -type ZeroTrustAccessGroupNewResponseRequire interface { - implementsZeroTrustAccessGroupNewResponseRequire() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessGroupNewResponseRequire)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupNewResponseRequireAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessGroupNewResponseRequireAccessEmailRule struct { - Email ZeroTrustAccessGroupNewResponseRequireAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessEmailRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupNewResponseRequireAccessEmailRule] -type zeroTrustAccessGroupNewResponseRequireAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessEmailRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -type ZeroTrustAccessGroupNewResponseRequireAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessGroupNewResponseRequireAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessEmailRuleEmailJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessEmailRuleEmail] -type zeroTrustAccessGroupNewResponseRequireAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupNewResponseRequireAccessEmailListRule struct { - EmailList ZeroTrustAccessGroupNewResponseRequireAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessEmailListRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessEmailListRule] -type zeroTrustAccessGroupNewResponseRequireAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessEmailListRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -type ZeroTrustAccessGroupNewResponseRequireAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessEmailListRuleEmailListJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessEmailListRuleEmailList] -type zeroTrustAccessGroupNewResponseRequireAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessGroupNewResponseRequireAccessDomainRule struct { - EmailDomain ZeroTrustAccessGroupNewResponseRequireAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessDomainRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupNewResponseRequireAccessDomainRule] -type zeroTrustAccessGroupNewResponseRequireAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessDomainRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -type ZeroTrustAccessGroupNewResponseRequireAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessDomainRuleEmailDomainJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessDomainRuleEmailDomain] -type zeroTrustAccessGroupNewResponseRequireAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessGroupNewResponseRequireAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessEveryoneRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessEveryoneRule] -type zeroTrustAccessGroupNewResponseRequireAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessEveryoneRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupNewResponseRequireAccessIPRule struct { - IP ZeroTrustAccessGroupNewResponseRequireAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessIPRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupNewResponseRequireAccessIPRule] -type zeroTrustAccessGroupNewResponseRequireAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessIPRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -type ZeroTrustAccessGroupNewResponseRequireAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessIPRuleIPJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupNewResponseRequireAccessIPRuleIP] -type zeroTrustAccessGroupNewResponseRequireAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupNewResponseRequireAccessIPListRule struct { - IPList ZeroTrustAccessGroupNewResponseRequireAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessIPListRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupNewResponseRequireAccessIPListRule] -type zeroTrustAccessGroupNewResponseRequireAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessIPListRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -type ZeroTrustAccessGroupNewResponseRequireAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessIPListRuleIPListJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessIPListRuleIPList] -type zeroTrustAccessGroupNewResponseRequireAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupNewResponseRequireAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessCertificateRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessCertificateRule] -type zeroTrustAccessGroupNewResponseRequireAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessCertificateRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupNewResponseRequireAccessAccessGroupRule struct { - Group ZeroTrustAccessGroupNewResponseRequireAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessAccessGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessAccessGroupRule] -type zeroTrustAccessGroupNewResponseRequireAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessAccessGroupRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -type ZeroTrustAccessGroupNewResponseRequireAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessAccessGroupRuleGroupJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessAccessGroupRuleGroup] -type zeroTrustAccessGroupNewResponseRequireAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupNewResponseRequireAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessGroupNewResponseRequireAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessAzureGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessAzureGroupRule] -type zeroTrustAccessGroupNewResponseRequireAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessAzureGroupRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -type ZeroTrustAccessGroupNewResponseRequireAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessAzureGroupRuleAzureAdJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessAzureGroupRuleAzureAd] -type zeroTrustAccessGroupNewResponseRequireAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupNewResponseRequireAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessGroupNewResponseRequireAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessGitHubOrganizationRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessGitHubOrganizationRule] -type zeroTrustAccessGroupNewResponseRequireAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -type ZeroTrustAccessGroupNewResponseRequireAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessGroupNewResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupNewResponseRequireAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessGroupNewResponseRequireAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessGsuiteGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessGsuiteGroupRule] -type zeroTrustAccessGroupNewResponseRequireAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessGsuiteGroupRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -type ZeroTrustAccessGroupNewResponseRequireAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessGsuiteGroupRuleGsuiteJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessGroupNewResponseRequireAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupNewResponseRequireAccessOktaGroupRule struct { - Okta ZeroTrustAccessGroupNewResponseRequireAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessOktaGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessOktaGroupRule] -type zeroTrustAccessGroupNewResponseRequireAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessOktaGroupRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -type ZeroTrustAccessGroupNewResponseRequireAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessOktaGroupRuleOktaJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessOktaGroupRuleOkta] -type zeroTrustAccessGroupNewResponseRequireAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupNewResponseRequireAccessSamlGroupRule struct { - Saml ZeroTrustAccessGroupNewResponseRequireAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessSamlGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessSamlGroupRule] -type zeroTrustAccessGroupNewResponseRequireAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessSamlGroupRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -type ZeroTrustAccessGroupNewResponseRequireAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessSamlGroupRuleSamlJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessSamlGroupRuleSaml] -type zeroTrustAccessGroupNewResponseRequireAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupNewResponseRequireAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessGroupNewResponseRequireAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessServiceTokenRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessServiceTokenRule] -type zeroTrustAccessGroupNewResponseRequireAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessServiceTokenRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -type ZeroTrustAccessGroupNewResponseRequireAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessServiceTokenRuleServiceToken] -type zeroTrustAccessGroupNewResponseRequireAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupNewResponseRequireAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessAnyValidServiceTokenRule] -type zeroTrustAccessGroupNewResponseRequireAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupNewResponseRequireAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessGroupNewResponseRequireAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessExternalEvaluationRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessExternalEvaluationRule] -type zeroTrustAccessGroupNewResponseRequireAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessExternalEvaluationRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -type ZeroTrustAccessGroupNewResponseRequireAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessGroupNewResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessGroupNewResponseRequireAccessCountryRule struct { - Geo ZeroTrustAccessGroupNewResponseRequireAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessCountryRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessCountryRule] -type zeroTrustAccessGroupNewResponseRequireAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessCountryRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -type ZeroTrustAccessGroupNewResponseRequireAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessCountryRuleGeoJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessCountryRuleGeo] -type zeroTrustAccessGroupNewResponseRequireAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessGroupNewResponseRequireAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessGroupNewResponseRequireAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessAuthenticationMethodRule] -type zeroTrustAccessGroupNewResponseRequireAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -type ZeroTrustAccessGroupNewResponseRequireAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessGroupNewResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupNewResponseRequireAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessGroupNewResponseRequireAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessDevicePostureRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessDevicePostureRule] -type zeroTrustAccessGroupNewResponseRequireAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupNewResponseRequireAccessDevicePostureRule) implementsZeroTrustAccessGroupNewResponseRequire() { -} - -type ZeroTrustAccessGroupNewResponseRequireAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessGroupNewResponseRequireAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseRequireAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupNewResponseRequireAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessGroupNewResponseRequireAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseRequireAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseRequireAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessGroupUpdateResponse struct { - // UUID - ID string `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Rules evaluated with a NOT logical operator. To match a policy, a user cannot - // meet any of the Exclude rules. - Exclude []ZeroTrustAccessGroupUpdateResponseExclude `json:"exclude"` - // Rules evaluated with an OR logical operator. A user needs to meet only one of - // the Include rules. - Include []ZeroTrustAccessGroupUpdateResponseInclude `json:"include"` - // Rules evaluated with an AND logical operator. To match a policy, a user must - // meet all of the Require rules. - IsDefault []ZeroTrustAccessGroupUpdateResponseIsDefault `json:"is_default"` - // The name of the Access group. - Name string `json:"name"` - // Rules evaluated with an AND logical operator. To match a policy, a user must - // meet all of the Require rules. - Require []ZeroTrustAccessGroupUpdateResponseRequire `json:"require"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessGroupUpdateResponseJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseJSON contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponse] -type zeroTrustAccessGroupUpdateResponseJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Exclude apijson.Field - Include apijson.Field - IsDefault apijson.Field - Name apijson.Field - Require apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailRule], -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailListRule], -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessDomainRule], -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessEveryoneRule], -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessIPRule], -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessIPListRule], -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessCertificateRule], -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessAccessGroupRule], -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessAzureGroupRule], -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessOktaGroupRule], -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessSamlGroupRule], -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessServiceTokenRule], -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessCountryRule], -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessAuthenticationMethodRule] or -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessDevicePostureRule]. -type ZeroTrustAccessGroupUpdateResponseExclude interface { - implementsZeroTrustAccessGroupUpdateResponseExclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessGroupUpdateResponseExclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseExcludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailRule struct { - Email ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessEmailRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -type ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessEmailRuleEmailJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailRuleEmail] -type zeroTrustAccessGroupUpdateResponseExcludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailListRule struct { - EmailList ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessEmailListRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailListRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailListRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -type ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailListRuleEmailList] -type zeroTrustAccessGroupUpdateResponseExcludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessGroupUpdateResponseExcludeAccessDomainRule struct { - EmailDomain ZeroTrustAccessGroupUpdateResponseExcludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessDomainRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessDomainRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessDomainRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -type ZeroTrustAccessGroupUpdateResponseExcludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessDomainRuleEmailDomainJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessDomainRuleEmailDomain] -type zeroTrustAccessGroupUpdateResponseExcludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessGroupUpdateResponseExcludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessEveryoneRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessEveryoneRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessEveryoneRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupUpdateResponseExcludeAccessIPRule struct { - IP ZeroTrustAccessGroupUpdateResponseExcludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessIPRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupUpdateResponseExcludeAccessIPRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessIPRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -type ZeroTrustAccessGroupUpdateResponseExcludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessIPRuleIPJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessIPRuleIP] -type zeroTrustAccessGroupUpdateResponseExcludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupUpdateResponseExcludeAccessIPListRule struct { - IPList ZeroTrustAccessGroupUpdateResponseExcludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessIPListRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessIPListRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessIPListRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -type ZeroTrustAccessGroupUpdateResponseExcludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessIPListRuleIPListJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessIPListRuleIPList] -type zeroTrustAccessGroupUpdateResponseExcludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupUpdateResponseExcludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessCertificateRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessCertificateRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessCertificateRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupUpdateResponseExcludeAccessAccessGroupRule struct { - Group ZeroTrustAccessGroupUpdateResponseExcludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessAccessGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessAccessGroupRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessAccessGroupRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -type ZeroTrustAccessGroupUpdateResponseExcludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessAccessGroupRuleGroupJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessAccessGroupRuleGroup] -type zeroTrustAccessGroupUpdateResponseExcludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupUpdateResponseExcludeAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessGroupUpdateResponseExcludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessAzureGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessAzureGroupRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessAzureGroupRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -type ZeroTrustAccessGroupUpdateResponseExcludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessAzureGroupRuleAzureAdJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessAzureGroupRuleAzureAd] -type zeroTrustAccessGroupUpdateResponseExcludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupUpdateResponseExcludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessGroupUpdateResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessGitHubOrganizationRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -type ZeroTrustAccessGroupUpdateResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessGroupUpdateResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupUpdateResponseExcludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessGroupUpdateResponseExcludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessGsuiteGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessGsuiteGroupRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -type ZeroTrustAccessGroupUpdateResponseExcludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessGsuiteGroupRuleGsuiteJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessGroupUpdateResponseExcludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupUpdateResponseExcludeAccessOktaGroupRule struct { - Okta ZeroTrustAccessGroupUpdateResponseExcludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessOktaGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessOktaGroupRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessOktaGroupRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -type ZeroTrustAccessGroupUpdateResponseExcludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessOktaGroupRuleOktaJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessOktaGroupRuleOkta] -type zeroTrustAccessGroupUpdateResponseExcludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupUpdateResponseExcludeAccessSamlGroupRule struct { - Saml ZeroTrustAccessGroupUpdateResponseExcludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessSamlGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessSamlGroupRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessSamlGroupRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -type ZeroTrustAccessGroupUpdateResponseExcludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessSamlGroupRuleSamlJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessSamlGroupRuleSaml] -type zeroTrustAccessGroupUpdateResponseExcludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupUpdateResponseExcludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessGroupUpdateResponseExcludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessServiceTokenRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessServiceTokenRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessServiceTokenRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -type ZeroTrustAccessGroupUpdateResponseExcludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessServiceTokenRuleServiceToken] -type zeroTrustAccessGroupUpdateResponseExcludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupUpdateResponseExcludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessAnyValidServiceTokenRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupUpdateResponseExcludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessGroupUpdateResponseExcludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessExternalEvaluationRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -type ZeroTrustAccessGroupUpdateResponseExcludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessGroupUpdateResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessGroupUpdateResponseExcludeAccessCountryRule struct { - Geo ZeroTrustAccessGroupUpdateResponseExcludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessCountryRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessCountryRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessCountryRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -type ZeroTrustAccessGroupUpdateResponseExcludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessCountryRuleGeoJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessCountryRuleGeo] -type zeroTrustAccessGroupUpdateResponseExcludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessGroupUpdateResponseExcludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessGroupUpdateResponseExcludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessAuthenticationMethodRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -type ZeroTrustAccessGroupUpdateResponseExcludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessGroupUpdateResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupUpdateResponseExcludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessGroupUpdateResponseExcludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessDevicePostureRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessDevicePostureRule] -type zeroTrustAccessGroupUpdateResponseExcludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseExcludeAccessDevicePostureRule) implementsZeroTrustAccessGroupUpdateResponseExclude() { -} - -type ZeroTrustAccessGroupUpdateResponseExcludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessGroupUpdateResponseExcludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseExcludeAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseExcludeAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessGroupUpdateResponseExcludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseExcludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseExcludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailRule], -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailListRule], -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessDomainRule], -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessEveryoneRule], -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessIPRule], -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessIPListRule], -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessCertificateRule], -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessAccessGroupRule], -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessAzureGroupRule], -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessOktaGroupRule], -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessSamlGroupRule], -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessServiceTokenRule], -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessCountryRule], -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessAuthenticationMethodRule] or -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessDevicePostureRule]. -type ZeroTrustAccessGroupUpdateResponseInclude interface { - implementsZeroTrustAccessGroupUpdateResponseInclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessGroupUpdateResponseInclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIncludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailRule struct { - Email ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessEmailRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -type ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessEmailRuleEmailJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailRuleEmail] -type zeroTrustAccessGroupUpdateResponseIncludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailListRule struct { - EmailList ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessEmailListRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailListRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailListRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -type ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailListRuleEmailList] -type zeroTrustAccessGroupUpdateResponseIncludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessGroupUpdateResponseIncludeAccessDomainRule struct { - EmailDomain ZeroTrustAccessGroupUpdateResponseIncludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessDomainRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessDomainRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessDomainRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -type ZeroTrustAccessGroupUpdateResponseIncludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessDomainRuleEmailDomainJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessDomainRuleEmailDomain] -type zeroTrustAccessGroupUpdateResponseIncludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessGroupUpdateResponseIncludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessEveryoneRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessEveryoneRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessEveryoneRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupUpdateResponseIncludeAccessIPRule struct { - IP ZeroTrustAccessGroupUpdateResponseIncludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessIPRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupUpdateResponseIncludeAccessIPRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessIPRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -type ZeroTrustAccessGroupUpdateResponseIncludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessIPRuleIPJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessIPRuleIP] -type zeroTrustAccessGroupUpdateResponseIncludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupUpdateResponseIncludeAccessIPListRule struct { - IPList ZeroTrustAccessGroupUpdateResponseIncludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessIPListRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessIPListRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessIPListRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -type ZeroTrustAccessGroupUpdateResponseIncludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessIPListRuleIPListJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessIPListRuleIPList] -type zeroTrustAccessGroupUpdateResponseIncludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupUpdateResponseIncludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessCertificateRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessCertificateRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessCertificateRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupUpdateResponseIncludeAccessAccessGroupRule struct { - Group ZeroTrustAccessGroupUpdateResponseIncludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessAccessGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessAccessGroupRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessAccessGroupRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -type ZeroTrustAccessGroupUpdateResponseIncludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessAccessGroupRuleGroupJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessAccessGroupRuleGroup] -type zeroTrustAccessGroupUpdateResponseIncludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupUpdateResponseIncludeAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessGroupUpdateResponseIncludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessAzureGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessAzureGroupRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessAzureGroupRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -type ZeroTrustAccessGroupUpdateResponseIncludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessAzureGroupRuleAzureAdJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessAzureGroupRuleAzureAd] -type zeroTrustAccessGroupUpdateResponseIncludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupUpdateResponseIncludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessGroupUpdateResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessGitHubOrganizationRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -type ZeroTrustAccessGroupUpdateResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessGroupUpdateResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupUpdateResponseIncludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessGroupUpdateResponseIncludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessGsuiteGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessGsuiteGroupRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -type ZeroTrustAccessGroupUpdateResponseIncludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessGsuiteGroupRuleGsuiteJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessGroupUpdateResponseIncludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupUpdateResponseIncludeAccessOktaGroupRule struct { - Okta ZeroTrustAccessGroupUpdateResponseIncludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessOktaGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessOktaGroupRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessOktaGroupRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -type ZeroTrustAccessGroupUpdateResponseIncludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessOktaGroupRuleOktaJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessOktaGroupRuleOkta] -type zeroTrustAccessGroupUpdateResponseIncludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupUpdateResponseIncludeAccessSamlGroupRule struct { - Saml ZeroTrustAccessGroupUpdateResponseIncludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessSamlGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessSamlGroupRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessSamlGroupRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -type ZeroTrustAccessGroupUpdateResponseIncludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessSamlGroupRuleSamlJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessSamlGroupRuleSaml] -type zeroTrustAccessGroupUpdateResponseIncludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupUpdateResponseIncludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessGroupUpdateResponseIncludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessServiceTokenRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessServiceTokenRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessServiceTokenRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -type ZeroTrustAccessGroupUpdateResponseIncludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessServiceTokenRuleServiceToken] -type zeroTrustAccessGroupUpdateResponseIncludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupUpdateResponseIncludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessAnyValidServiceTokenRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupUpdateResponseIncludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessGroupUpdateResponseIncludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessExternalEvaluationRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -type ZeroTrustAccessGroupUpdateResponseIncludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessGroupUpdateResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessGroupUpdateResponseIncludeAccessCountryRule struct { - Geo ZeroTrustAccessGroupUpdateResponseIncludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessCountryRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessCountryRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessCountryRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -type ZeroTrustAccessGroupUpdateResponseIncludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessCountryRuleGeoJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessCountryRuleGeo] -type zeroTrustAccessGroupUpdateResponseIncludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessGroupUpdateResponseIncludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessGroupUpdateResponseIncludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessAuthenticationMethodRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -type ZeroTrustAccessGroupUpdateResponseIncludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessGroupUpdateResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupUpdateResponseIncludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessGroupUpdateResponseIncludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessDevicePostureRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessDevicePostureRule] -type zeroTrustAccessGroupUpdateResponseIncludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIncludeAccessDevicePostureRule) implementsZeroTrustAccessGroupUpdateResponseInclude() { -} - -type ZeroTrustAccessGroupUpdateResponseIncludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessGroupUpdateResponseIncludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIncludeAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIncludeAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessGroupUpdateResponseIncludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIncludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIncludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailRule], -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailListRule], -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDomainRule], -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEveryoneRule], -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPRule], -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPListRule], -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessCertificateRule], -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAccessGroupRule], -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAzureGroupRule], -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessOktaGroupRule], -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessSamlGroupRule], -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessServiceTokenRule], -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessCountryRule], -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAuthenticationMethodRule] or -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDevicePostureRule]. -type ZeroTrustAccessGroupUpdateResponseIsDefault interface { - implementsZeroTrustAccessGroupUpdateResponseIsDefault() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessGroupUpdateResponseIsDefault)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailRule struct { - Email ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailRuleEmailJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailRuleEmail] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailListRule struct { - EmailList ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailListRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailListRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailListRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailListRuleEmailList] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDomainRule struct { - EmailDomain ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessDomainRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDomainRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDomainRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessDomainRuleEmailDomainJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDomainRuleEmailDomain] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessEveryoneRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEveryoneRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessEveryoneRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPRule struct { - IP ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessIPRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessIPRuleIPJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPRuleIP] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPListRule struct { - IPList ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessIPListRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPListRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPListRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessIPListRuleIPListJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPListRuleIPList] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessCertificateRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessCertificateRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessCertificateRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAccessGroupRule struct { - Group ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessAccessGroupRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAccessGroupRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAccessGroupRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessAccessGroupRuleGroupJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAccessGroupRuleGroup] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessAzureGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAzureGroupRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAzureGroupRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessAzureGroupRuleAzureAdJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAzureGroupRuleAzureAd] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGitHubOrganizationRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessGsuiteGroupRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGsuiteGroupRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGsuiteGroupRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessGsuiteGroupRuleGsuiteJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessOktaGroupRule struct { - Okta ZeroTrustAccessGroupUpdateResponseIsDefaultAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessOktaGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessOktaGroupRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessOktaGroupRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessOktaGroupRuleOktaJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessOktaGroupRuleOkta] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessSamlGroupRule struct { - Saml ZeroTrustAccessGroupUpdateResponseIsDefaultAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessSamlGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessSamlGroupRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessSamlGroupRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessSamlGroupRuleSamlJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessSamlGroupRuleSaml] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessGroupUpdateResponseIsDefaultAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessServiceTokenRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessServiceTokenRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessServiceTokenRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessServiceTokenRuleServiceToken] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAnyValidServiceTokenRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessGroupUpdateResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessExternalEvaluationRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessExternalEvaluationRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessCountryRule struct { - Geo ZeroTrustAccessGroupUpdateResponseIsDefaultAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessCountryRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessCountryRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessCountryRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessCountryRuleGeoJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessCountryRuleGeo] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAuthenticationMethodRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessDevicePostureRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDevicePostureRule] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDevicePostureRule) implementsZeroTrustAccessGroupUpdateResponseIsDefault() { -} - -type ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessGroupUpdateResponseIsDefaultAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseIsDefaultAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessGroupUpdateResponseIsDefaultAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseIsDefaultAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseIsDefaultAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [ZeroTrustAccessGroupUpdateResponseRequireAccessEmailRule], -// [ZeroTrustAccessGroupUpdateResponseRequireAccessEmailListRule], -// [ZeroTrustAccessGroupUpdateResponseRequireAccessDomainRule], -// [ZeroTrustAccessGroupUpdateResponseRequireAccessEveryoneRule], -// [ZeroTrustAccessGroupUpdateResponseRequireAccessIPRule], -// [ZeroTrustAccessGroupUpdateResponseRequireAccessIPListRule], -// [ZeroTrustAccessGroupUpdateResponseRequireAccessCertificateRule], -// [ZeroTrustAccessGroupUpdateResponseRequireAccessAccessGroupRule], -// [ZeroTrustAccessGroupUpdateResponseRequireAccessAzureGroupRule], -// [ZeroTrustAccessGroupUpdateResponseRequireAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupUpdateResponseRequireAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupUpdateResponseRequireAccessOktaGroupRule], -// [ZeroTrustAccessGroupUpdateResponseRequireAccessSamlGroupRule], -// [ZeroTrustAccessGroupUpdateResponseRequireAccessServiceTokenRule], -// [ZeroTrustAccessGroupUpdateResponseRequireAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupUpdateResponseRequireAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupUpdateResponseRequireAccessCountryRule], -// [ZeroTrustAccessGroupUpdateResponseRequireAccessAuthenticationMethodRule] or -// [ZeroTrustAccessGroupUpdateResponseRequireAccessDevicePostureRule]. -type ZeroTrustAccessGroupUpdateResponseRequire interface { - implementsZeroTrustAccessGroupUpdateResponseRequire() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessGroupUpdateResponseRequire)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupUpdateResponseRequireAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessGroupUpdateResponseRequireAccessEmailRule struct { - Email ZeroTrustAccessGroupUpdateResponseRequireAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessEmailRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessEmailRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessEmailRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -type ZeroTrustAccessGroupUpdateResponseRequireAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessEmailRuleEmailJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessEmailRuleEmail] -type zeroTrustAccessGroupUpdateResponseRequireAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupUpdateResponseRequireAccessEmailListRule struct { - EmailList ZeroTrustAccessGroupUpdateResponseRequireAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessEmailListRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessEmailListRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessEmailListRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -type ZeroTrustAccessGroupUpdateResponseRequireAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessEmailListRuleEmailList] -type zeroTrustAccessGroupUpdateResponseRequireAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessGroupUpdateResponseRequireAccessDomainRule struct { - EmailDomain ZeroTrustAccessGroupUpdateResponseRequireAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessDomainRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessDomainRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessDomainRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -type ZeroTrustAccessGroupUpdateResponseRequireAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessDomainRuleEmailDomainJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessDomainRuleEmailDomain] -type zeroTrustAccessGroupUpdateResponseRequireAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessGroupUpdateResponseRequireAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessEveryoneRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessEveryoneRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessEveryoneRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupUpdateResponseRequireAccessIPRule struct { - IP ZeroTrustAccessGroupUpdateResponseRequireAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessIPRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupUpdateResponseRequireAccessIPRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessIPRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -type ZeroTrustAccessGroupUpdateResponseRequireAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessIPRuleIPJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessIPRuleIP] -type zeroTrustAccessGroupUpdateResponseRequireAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupUpdateResponseRequireAccessIPListRule struct { - IPList ZeroTrustAccessGroupUpdateResponseRequireAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessIPListRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessIPListRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessIPListRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -type ZeroTrustAccessGroupUpdateResponseRequireAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessIPListRuleIPListJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessIPListRuleIPList] -type zeroTrustAccessGroupUpdateResponseRequireAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupUpdateResponseRequireAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessCertificateRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessCertificateRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessCertificateRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupUpdateResponseRequireAccessAccessGroupRule struct { - Group ZeroTrustAccessGroupUpdateResponseRequireAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessAccessGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessAccessGroupRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessAccessGroupRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -type ZeroTrustAccessGroupUpdateResponseRequireAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessAccessGroupRuleGroupJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessAccessGroupRuleGroup] -type zeroTrustAccessGroupUpdateResponseRequireAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupUpdateResponseRequireAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessGroupUpdateResponseRequireAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessAzureGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessAzureGroupRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessAzureGroupRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -type ZeroTrustAccessGroupUpdateResponseRequireAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessAzureGroupRuleAzureAdJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessAzureGroupRuleAzureAd] -type zeroTrustAccessGroupUpdateResponseRequireAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupUpdateResponseRequireAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessGroupUpdateResponseRequireAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessGitHubOrganizationRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -type ZeroTrustAccessGroupUpdateResponseRequireAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessGroupUpdateResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupUpdateResponseRequireAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessGroupUpdateResponseRequireAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessGsuiteGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessGsuiteGroupRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessGsuiteGroupRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -type ZeroTrustAccessGroupUpdateResponseRequireAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessGsuiteGroupRuleGsuiteJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessGroupUpdateResponseRequireAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupUpdateResponseRequireAccessOktaGroupRule struct { - Okta ZeroTrustAccessGroupUpdateResponseRequireAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessOktaGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessOktaGroupRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessOktaGroupRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -type ZeroTrustAccessGroupUpdateResponseRequireAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessOktaGroupRuleOktaJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessOktaGroupRuleOkta] -type zeroTrustAccessGroupUpdateResponseRequireAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupUpdateResponseRequireAccessSamlGroupRule struct { - Saml ZeroTrustAccessGroupUpdateResponseRequireAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessSamlGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessSamlGroupRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessSamlGroupRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -type ZeroTrustAccessGroupUpdateResponseRequireAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessSamlGroupRuleSamlJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessSamlGroupRuleSaml] -type zeroTrustAccessGroupUpdateResponseRequireAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupUpdateResponseRequireAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessGroupUpdateResponseRequireAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessServiceTokenRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessServiceTokenRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessServiceTokenRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -type ZeroTrustAccessGroupUpdateResponseRequireAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessServiceTokenRuleServiceToken] -type zeroTrustAccessGroupUpdateResponseRequireAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupUpdateResponseRequireAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessAnyValidServiceTokenRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupUpdateResponseRequireAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessGroupUpdateResponseRequireAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessExternalEvaluationRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessExternalEvaluationRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -type ZeroTrustAccessGroupUpdateResponseRequireAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessGroupUpdateResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessGroupUpdateResponseRequireAccessCountryRule struct { - Geo ZeroTrustAccessGroupUpdateResponseRequireAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessCountryRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessCountryRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessCountryRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -type ZeroTrustAccessGroupUpdateResponseRequireAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessCountryRuleGeoJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessCountryRuleGeo] -type zeroTrustAccessGroupUpdateResponseRequireAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessGroupUpdateResponseRequireAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessGroupUpdateResponseRequireAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessAuthenticationMethodRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -type ZeroTrustAccessGroupUpdateResponseRequireAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessGroupUpdateResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupUpdateResponseRequireAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessGroupUpdateResponseRequireAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessDevicePostureRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessDevicePostureRule] -type zeroTrustAccessGroupUpdateResponseRequireAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupUpdateResponseRequireAccessDevicePostureRule) implementsZeroTrustAccessGroupUpdateResponseRequire() { -} - -type ZeroTrustAccessGroupUpdateResponseRequireAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessGroupUpdateResponseRequireAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseRequireAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupUpdateResponseRequireAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessGroupUpdateResponseRequireAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseRequireAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseRequireAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessGroupListResponse struct { - // UUID - ID string `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Rules evaluated with a NOT logical operator. To match a policy, a user cannot - // meet any of the Exclude rules. - Exclude []ZeroTrustAccessGroupListResponseExclude `json:"exclude"` - // Rules evaluated with an OR logical operator. A user needs to meet only one of - // the Include rules. - Include []ZeroTrustAccessGroupListResponseInclude `json:"include"` - // Rules evaluated with an AND logical operator. To match a policy, a user must - // meet all of the Require rules. - IsDefault []ZeroTrustAccessGroupListResponseIsDefault `json:"is_default"` - // The name of the Access group. - Name string `json:"name"` - // Rules evaluated with an AND logical operator. To match a policy, a user must - // meet all of the Require rules. - Require []ZeroTrustAccessGroupListResponseRequire `json:"require"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessGroupListResponseJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseJSON contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponse] -type zeroTrustAccessGroupListResponseJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Exclude apijson.Field - Include apijson.Field - IsDefault apijson.Field - Name apijson.Field - Require apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [ZeroTrustAccessGroupListResponseExcludeAccessEmailRule], -// [ZeroTrustAccessGroupListResponseExcludeAccessEmailListRule], -// [ZeroTrustAccessGroupListResponseExcludeAccessDomainRule], -// [ZeroTrustAccessGroupListResponseExcludeAccessEveryoneRule], -// [ZeroTrustAccessGroupListResponseExcludeAccessIPRule], -// [ZeroTrustAccessGroupListResponseExcludeAccessIPListRule], -// [ZeroTrustAccessGroupListResponseExcludeAccessCertificateRule], -// [ZeroTrustAccessGroupListResponseExcludeAccessAccessGroupRule], -// [ZeroTrustAccessGroupListResponseExcludeAccessAzureGroupRule], -// [ZeroTrustAccessGroupListResponseExcludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupListResponseExcludeAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupListResponseExcludeAccessOktaGroupRule], -// [ZeroTrustAccessGroupListResponseExcludeAccessSamlGroupRule], -// [ZeroTrustAccessGroupListResponseExcludeAccessServiceTokenRule], -// [ZeroTrustAccessGroupListResponseExcludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupListResponseExcludeAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupListResponseExcludeAccessCountryRule], -// [ZeroTrustAccessGroupListResponseExcludeAccessAuthenticationMethodRule] or -// [ZeroTrustAccessGroupListResponseExcludeAccessDevicePostureRule]. -type ZeroTrustAccessGroupListResponseExclude interface { - implementsZeroTrustAccessGroupListResponseExclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessGroupListResponseExclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseExcludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessGroupListResponseExcludeAccessEmailRule struct { - Email ZeroTrustAccessGroupListResponseExcludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessEmailRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupListResponseExcludeAccessEmailRule] -type zeroTrustAccessGroupListResponseExcludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessEmailRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -type ZeroTrustAccessGroupListResponseExcludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessGroupListResponseExcludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessEmailRuleEmailJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessEmailRuleEmail] -type zeroTrustAccessGroupListResponseExcludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupListResponseExcludeAccessEmailListRule struct { - EmailList ZeroTrustAccessGroupListResponseExcludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessEmailListRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessEmailListRule] -type zeroTrustAccessGroupListResponseExcludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessEmailListRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -type ZeroTrustAccessGroupListResponseExcludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessEmailListRuleEmailListJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessEmailListRuleEmailList] -type zeroTrustAccessGroupListResponseExcludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessGroupListResponseExcludeAccessDomainRule struct { - EmailDomain ZeroTrustAccessGroupListResponseExcludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessDomainRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessDomainRule] -type zeroTrustAccessGroupListResponseExcludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessDomainRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -type ZeroTrustAccessGroupListResponseExcludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessDomainRuleEmailDomainJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessDomainRuleEmailDomain] -type zeroTrustAccessGroupListResponseExcludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessGroupListResponseExcludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessEveryoneRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessEveryoneRule] -type zeroTrustAccessGroupListResponseExcludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessEveryoneRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupListResponseExcludeAccessIPRule struct { - IP ZeroTrustAccessGroupListResponseExcludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessIPRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupListResponseExcludeAccessIPRule] -type zeroTrustAccessGroupListResponseExcludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessIPRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -type ZeroTrustAccessGroupListResponseExcludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessIPRuleIPJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupListResponseExcludeAccessIPRuleIP] -type zeroTrustAccessGroupListResponseExcludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupListResponseExcludeAccessIPListRule struct { - IPList ZeroTrustAccessGroupListResponseExcludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessIPListRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessIPListRule] -type zeroTrustAccessGroupListResponseExcludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessIPListRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -type ZeroTrustAccessGroupListResponseExcludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessIPListRuleIPListJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessIPListRuleIPList] -type zeroTrustAccessGroupListResponseExcludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupListResponseExcludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessCertificateRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessCertificateRule] -type zeroTrustAccessGroupListResponseExcludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessCertificateRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupListResponseExcludeAccessAccessGroupRule struct { - Group ZeroTrustAccessGroupListResponseExcludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessAccessGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessAccessGroupRule] -type zeroTrustAccessGroupListResponseExcludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessAccessGroupRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -type ZeroTrustAccessGroupListResponseExcludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessAccessGroupRuleGroupJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessAccessGroupRuleGroup] -type zeroTrustAccessGroupListResponseExcludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupListResponseExcludeAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessGroupListResponseExcludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessAzureGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessAzureGroupRule] -type zeroTrustAccessGroupListResponseExcludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessAzureGroupRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -type ZeroTrustAccessGroupListResponseExcludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessAzureGroupRuleAzureAdJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessAzureGroupRuleAzureAd] -type zeroTrustAccessGroupListResponseExcludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupListResponseExcludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessGroupListResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessGitHubOrganizationRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessGitHubOrganizationRule] -type zeroTrustAccessGroupListResponseExcludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -type ZeroTrustAccessGroupListResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessGroupListResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupListResponseExcludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessGroupListResponseExcludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessGsuiteGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessGsuiteGroupRule] -type zeroTrustAccessGroupListResponseExcludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -type ZeroTrustAccessGroupListResponseExcludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessGsuiteGroupRuleGsuiteJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessGroupListResponseExcludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupListResponseExcludeAccessOktaGroupRule struct { - Okta ZeroTrustAccessGroupListResponseExcludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessOktaGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessOktaGroupRule] -type zeroTrustAccessGroupListResponseExcludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessOktaGroupRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -type ZeroTrustAccessGroupListResponseExcludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessOktaGroupRuleOktaJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessOktaGroupRuleOkta] -type zeroTrustAccessGroupListResponseExcludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupListResponseExcludeAccessSamlGroupRule struct { - Saml ZeroTrustAccessGroupListResponseExcludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessSamlGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessSamlGroupRule] -type zeroTrustAccessGroupListResponseExcludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessSamlGroupRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -type ZeroTrustAccessGroupListResponseExcludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessSamlGroupRuleSamlJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessSamlGroupRuleSaml] -type zeroTrustAccessGroupListResponseExcludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupListResponseExcludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessGroupListResponseExcludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessServiceTokenRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessServiceTokenRule] -type zeroTrustAccessGroupListResponseExcludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessServiceTokenRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -type ZeroTrustAccessGroupListResponseExcludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessServiceTokenRuleServiceToken] -type zeroTrustAccessGroupListResponseExcludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupListResponseExcludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessAnyValidServiceTokenRule] -type zeroTrustAccessGroupListResponseExcludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupListResponseExcludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessGroupListResponseExcludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessExternalEvaluationRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessExternalEvaluationRule] -type zeroTrustAccessGroupListResponseExcludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -type ZeroTrustAccessGroupListResponseExcludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessGroupListResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessGroupListResponseExcludeAccessCountryRule struct { - Geo ZeroTrustAccessGroupListResponseExcludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessCountryRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessCountryRule] -type zeroTrustAccessGroupListResponseExcludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessCountryRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -type ZeroTrustAccessGroupListResponseExcludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessCountryRuleGeoJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessCountryRuleGeo] -type zeroTrustAccessGroupListResponseExcludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessGroupListResponseExcludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessGroupListResponseExcludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessAuthenticationMethodRule] -type zeroTrustAccessGroupListResponseExcludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -type ZeroTrustAccessGroupListResponseExcludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessGroupListResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupListResponseExcludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessGroupListResponseExcludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessDevicePostureRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessDevicePostureRule] -type zeroTrustAccessGroupListResponseExcludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseExcludeAccessDevicePostureRule) implementsZeroTrustAccessGroupListResponseExclude() { -} - -type ZeroTrustAccessGroupListResponseExcludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessGroupListResponseExcludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseExcludeAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseExcludeAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessGroupListResponseExcludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseExcludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseExcludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [ZeroTrustAccessGroupListResponseIncludeAccessEmailRule], -// [ZeroTrustAccessGroupListResponseIncludeAccessEmailListRule], -// [ZeroTrustAccessGroupListResponseIncludeAccessDomainRule], -// [ZeroTrustAccessGroupListResponseIncludeAccessEveryoneRule], -// [ZeroTrustAccessGroupListResponseIncludeAccessIPRule], -// [ZeroTrustAccessGroupListResponseIncludeAccessIPListRule], -// [ZeroTrustAccessGroupListResponseIncludeAccessCertificateRule], -// [ZeroTrustAccessGroupListResponseIncludeAccessAccessGroupRule], -// [ZeroTrustAccessGroupListResponseIncludeAccessAzureGroupRule], -// [ZeroTrustAccessGroupListResponseIncludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupListResponseIncludeAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupListResponseIncludeAccessOktaGroupRule], -// [ZeroTrustAccessGroupListResponseIncludeAccessSamlGroupRule], -// [ZeroTrustAccessGroupListResponseIncludeAccessServiceTokenRule], -// [ZeroTrustAccessGroupListResponseIncludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupListResponseIncludeAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupListResponseIncludeAccessCountryRule], -// [ZeroTrustAccessGroupListResponseIncludeAccessAuthenticationMethodRule] or -// [ZeroTrustAccessGroupListResponseIncludeAccessDevicePostureRule]. -type ZeroTrustAccessGroupListResponseInclude interface { - implementsZeroTrustAccessGroupListResponseInclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessGroupListResponseInclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIncludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessGroupListResponseIncludeAccessEmailRule struct { - Email ZeroTrustAccessGroupListResponseIncludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessEmailRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupListResponseIncludeAccessEmailRule] -type zeroTrustAccessGroupListResponseIncludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessEmailRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -type ZeroTrustAccessGroupListResponseIncludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessGroupListResponseIncludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessEmailRuleEmailJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessEmailRuleEmail] -type zeroTrustAccessGroupListResponseIncludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupListResponseIncludeAccessEmailListRule struct { - EmailList ZeroTrustAccessGroupListResponseIncludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessEmailListRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessEmailListRule] -type zeroTrustAccessGroupListResponseIncludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessEmailListRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -type ZeroTrustAccessGroupListResponseIncludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessEmailListRuleEmailListJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessEmailListRuleEmailList] -type zeroTrustAccessGroupListResponseIncludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessGroupListResponseIncludeAccessDomainRule struct { - EmailDomain ZeroTrustAccessGroupListResponseIncludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessDomainRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessDomainRule] -type zeroTrustAccessGroupListResponseIncludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessDomainRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -type ZeroTrustAccessGroupListResponseIncludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessDomainRuleEmailDomainJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessDomainRuleEmailDomain] -type zeroTrustAccessGroupListResponseIncludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessGroupListResponseIncludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessEveryoneRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessEveryoneRule] -type zeroTrustAccessGroupListResponseIncludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessEveryoneRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupListResponseIncludeAccessIPRule struct { - IP ZeroTrustAccessGroupListResponseIncludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessIPRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupListResponseIncludeAccessIPRule] -type zeroTrustAccessGroupListResponseIncludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessIPRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -type ZeroTrustAccessGroupListResponseIncludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessIPRuleIPJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupListResponseIncludeAccessIPRuleIP] -type zeroTrustAccessGroupListResponseIncludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupListResponseIncludeAccessIPListRule struct { - IPList ZeroTrustAccessGroupListResponseIncludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessIPListRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessIPListRule] -type zeroTrustAccessGroupListResponseIncludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessIPListRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -type ZeroTrustAccessGroupListResponseIncludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessIPListRuleIPListJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessIPListRuleIPList] -type zeroTrustAccessGroupListResponseIncludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupListResponseIncludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessCertificateRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessCertificateRule] -type zeroTrustAccessGroupListResponseIncludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessCertificateRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupListResponseIncludeAccessAccessGroupRule struct { - Group ZeroTrustAccessGroupListResponseIncludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessAccessGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessAccessGroupRule] -type zeroTrustAccessGroupListResponseIncludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessAccessGroupRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -type ZeroTrustAccessGroupListResponseIncludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessAccessGroupRuleGroupJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessAccessGroupRuleGroup] -type zeroTrustAccessGroupListResponseIncludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupListResponseIncludeAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessGroupListResponseIncludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessAzureGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessAzureGroupRule] -type zeroTrustAccessGroupListResponseIncludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessAzureGroupRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -type ZeroTrustAccessGroupListResponseIncludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessAzureGroupRuleAzureAdJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessAzureGroupRuleAzureAd] -type zeroTrustAccessGroupListResponseIncludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupListResponseIncludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessGroupListResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessGitHubOrganizationRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessGitHubOrganizationRule] -type zeroTrustAccessGroupListResponseIncludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -type ZeroTrustAccessGroupListResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessGroupListResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupListResponseIncludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessGroupListResponseIncludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessGsuiteGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessGsuiteGroupRule] -type zeroTrustAccessGroupListResponseIncludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -type ZeroTrustAccessGroupListResponseIncludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessGsuiteGroupRuleGsuiteJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessGroupListResponseIncludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupListResponseIncludeAccessOktaGroupRule struct { - Okta ZeroTrustAccessGroupListResponseIncludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessOktaGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessOktaGroupRule] -type zeroTrustAccessGroupListResponseIncludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessOktaGroupRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -type ZeroTrustAccessGroupListResponseIncludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessOktaGroupRuleOktaJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessOktaGroupRuleOkta] -type zeroTrustAccessGroupListResponseIncludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupListResponseIncludeAccessSamlGroupRule struct { - Saml ZeroTrustAccessGroupListResponseIncludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessSamlGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessSamlGroupRule] -type zeroTrustAccessGroupListResponseIncludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessSamlGroupRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -type ZeroTrustAccessGroupListResponseIncludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessSamlGroupRuleSamlJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessSamlGroupRuleSaml] -type zeroTrustAccessGroupListResponseIncludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupListResponseIncludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessGroupListResponseIncludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessServiceTokenRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessServiceTokenRule] -type zeroTrustAccessGroupListResponseIncludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessServiceTokenRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -type ZeroTrustAccessGroupListResponseIncludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessServiceTokenRuleServiceToken] -type zeroTrustAccessGroupListResponseIncludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupListResponseIncludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessAnyValidServiceTokenRule] -type zeroTrustAccessGroupListResponseIncludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupListResponseIncludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessGroupListResponseIncludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessExternalEvaluationRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessExternalEvaluationRule] -type zeroTrustAccessGroupListResponseIncludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -type ZeroTrustAccessGroupListResponseIncludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessGroupListResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessGroupListResponseIncludeAccessCountryRule struct { - Geo ZeroTrustAccessGroupListResponseIncludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessCountryRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessCountryRule] -type zeroTrustAccessGroupListResponseIncludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessCountryRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -type ZeroTrustAccessGroupListResponseIncludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessCountryRuleGeoJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessCountryRuleGeo] -type zeroTrustAccessGroupListResponseIncludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessGroupListResponseIncludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessGroupListResponseIncludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessAuthenticationMethodRule] -type zeroTrustAccessGroupListResponseIncludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -type ZeroTrustAccessGroupListResponseIncludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessGroupListResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupListResponseIncludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessGroupListResponseIncludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessDevicePostureRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessDevicePostureRule] -type zeroTrustAccessGroupListResponseIncludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIncludeAccessDevicePostureRule) implementsZeroTrustAccessGroupListResponseInclude() { -} - -type ZeroTrustAccessGroupListResponseIncludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessGroupListResponseIncludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIncludeAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIncludeAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessGroupListResponseIncludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIncludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIncludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [ZeroTrustAccessGroupListResponseIsDefaultAccessEmailRule], -// [ZeroTrustAccessGroupListResponseIsDefaultAccessEmailListRule], -// [ZeroTrustAccessGroupListResponseIsDefaultAccessDomainRule], -// [ZeroTrustAccessGroupListResponseIsDefaultAccessEveryoneRule], -// [ZeroTrustAccessGroupListResponseIsDefaultAccessIPRule], -// [ZeroTrustAccessGroupListResponseIsDefaultAccessIPListRule], -// [ZeroTrustAccessGroupListResponseIsDefaultAccessCertificateRule], -// [ZeroTrustAccessGroupListResponseIsDefaultAccessAccessGroupRule], -// [ZeroTrustAccessGroupListResponseIsDefaultAccessAzureGroupRule], -// [ZeroTrustAccessGroupListResponseIsDefaultAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupListResponseIsDefaultAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupListResponseIsDefaultAccessOktaGroupRule], -// [ZeroTrustAccessGroupListResponseIsDefaultAccessSamlGroupRule], -// [ZeroTrustAccessGroupListResponseIsDefaultAccessServiceTokenRule], -// [ZeroTrustAccessGroupListResponseIsDefaultAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupListResponseIsDefaultAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupListResponseIsDefaultAccessCountryRule], -// [ZeroTrustAccessGroupListResponseIsDefaultAccessAuthenticationMethodRule] or -// [ZeroTrustAccessGroupListResponseIsDefaultAccessDevicePostureRule]. -type ZeroTrustAccessGroupListResponseIsDefault interface { - implementsZeroTrustAccessGroupListResponseIsDefault() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessGroupListResponseIsDefault)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseIsDefaultAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessGroupListResponseIsDefaultAccessEmailRule struct { - Email ZeroTrustAccessGroupListResponseIsDefaultAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessEmailRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessEmailRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessEmailRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -type ZeroTrustAccessGroupListResponseIsDefaultAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessEmailRuleEmailJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessEmailRuleEmail] -type zeroTrustAccessGroupListResponseIsDefaultAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupListResponseIsDefaultAccessEmailListRule struct { - EmailList ZeroTrustAccessGroupListResponseIsDefaultAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessEmailListRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessEmailListRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessEmailListRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -type ZeroTrustAccessGroupListResponseIsDefaultAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessEmailListRuleEmailList] -type zeroTrustAccessGroupListResponseIsDefaultAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessGroupListResponseIsDefaultAccessDomainRule struct { - EmailDomain ZeroTrustAccessGroupListResponseIsDefaultAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessDomainRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessDomainRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessDomainRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -type ZeroTrustAccessGroupListResponseIsDefaultAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessDomainRuleEmailDomainJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessDomainRuleEmailDomain] -type zeroTrustAccessGroupListResponseIsDefaultAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessGroupListResponseIsDefaultAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessEveryoneRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessEveryoneRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessEveryoneRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupListResponseIsDefaultAccessIPRule struct { - IP ZeroTrustAccessGroupListResponseIsDefaultAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessIPRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupListResponseIsDefaultAccessIPRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessIPRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -type ZeroTrustAccessGroupListResponseIsDefaultAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessIPRuleIPJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessIPRuleIP] -type zeroTrustAccessGroupListResponseIsDefaultAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupListResponseIsDefaultAccessIPListRule struct { - IPList ZeroTrustAccessGroupListResponseIsDefaultAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessIPListRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessIPListRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessIPListRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -type ZeroTrustAccessGroupListResponseIsDefaultAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessIPListRuleIPListJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessIPListRuleIPList] -type zeroTrustAccessGroupListResponseIsDefaultAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupListResponseIsDefaultAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessCertificateRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessCertificateRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessCertificateRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupListResponseIsDefaultAccessAccessGroupRule struct { - Group ZeroTrustAccessGroupListResponseIsDefaultAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessAccessGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessAccessGroupRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessAccessGroupRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -type ZeroTrustAccessGroupListResponseIsDefaultAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessAccessGroupRuleGroupJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessAccessGroupRuleGroup] -type zeroTrustAccessGroupListResponseIsDefaultAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupListResponseIsDefaultAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessGroupListResponseIsDefaultAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessAzureGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessAzureGroupRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessAzureGroupRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -type ZeroTrustAccessGroupListResponseIsDefaultAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessAzureGroupRuleAzureAdJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessAzureGroupRuleAzureAd] -type zeroTrustAccessGroupListResponseIsDefaultAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupListResponseIsDefaultAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessGroupListResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessGitHubOrganizationRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -type ZeroTrustAccessGroupListResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessGroupListResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupListResponseIsDefaultAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessGroupListResponseIsDefaultAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessGsuiteGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessGsuiteGroupRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessGsuiteGroupRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -type ZeroTrustAccessGroupListResponseIsDefaultAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessGsuiteGroupRuleGsuiteJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessGroupListResponseIsDefaultAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupListResponseIsDefaultAccessOktaGroupRule struct { - Okta ZeroTrustAccessGroupListResponseIsDefaultAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessOktaGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessOktaGroupRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessOktaGroupRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -type ZeroTrustAccessGroupListResponseIsDefaultAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessOktaGroupRuleOktaJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessOktaGroupRuleOkta] -type zeroTrustAccessGroupListResponseIsDefaultAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupListResponseIsDefaultAccessSamlGroupRule struct { - Saml ZeroTrustAccessGroupListResponseIsDefaultAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessSamlGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessSamlGroupRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessSamlGroupRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -type ZeroTrustAccessGroupListResponseIsDefaultAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessSamlGroupRuleSamlJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessSamlGroupRuleSaml] -type zeroTrustAccessGroupListResponseIsDefaultAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupListResponseIsDefaultAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessGroupListResponseIsDefaultAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessServiceTokenRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessServiceTokenRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessServiceTokenRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -type ZeroTrustAccessGroupListResponseIsDefaultAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessServiceTokenRuleServiceToken] -type zeroTrustAccessGroupListResponseIsDefaultAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupListResponseIsDefaultAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessAnyValidServiceTokenRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupListResponseIsDefaultAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessGroupListResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessExternalEvaluationRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessExternalEvaluationRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -type ZeroTrustAccessGroupListResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessGroupListResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessGroupListResponseIsDefaultAccessCountryRule struct { - Geo ZeroTrustAccessGroupListResponseIsDefaultAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessCountryRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessCountryRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessCountryRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -type ZeroTrustAccessGroupListResponseIsDefaultAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessCountryRuleGeoJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessCountryRuleGeo] -type zeroTrustAccessGroupListResponseIsDefaultAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessGroupListResponseIsDefaultAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessGroupListResponseIsDefaultAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessAuthenticationMethodRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -type ZeroTrustAccessGroupListResponseIsDefaultAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessGroupListResponseIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupListResponseIsDefaultAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessGroupListResponseIsDefaultAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessDevicePostureRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessDevicePostureRule] -type zeroTrustAccessGroupListResponseIsDefaultAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseIsDefaultAccessDevicePostureRule) implementsZeroTrustAccessGroupListResponseIsDefault() { -} - -type ZeroTrustAccessGroupListResponseIsDefaultAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessGroupListResponseIsDefaultAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseIsDefaultAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseIsDefaultAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessGroupListResponseIsDefaultAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseIsDefaultAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseIsDefaultAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [ZeroTrustAccessGroupListResponseRequireAccessEmailRule], -// [ZeroTrustAccessGroupListResponseRequireAccessEmailListRule], -// [ZeroTrustAccessGroupListResponseRequireAccessDomainRule], -// [ZeroTrustAccessGroupListResponseRequireAccessEveryoneRule], -// [ZeroTrustAccessGroupListResponseRequireAccessIPRule], -// [ZeroTrustAccessGroupListResponseRequireAccessIPListRule], -// [ZeroTrustAccessGroupListResponseRequireAccessCertificateRule], -// [ZeroTrustAccessGroupListResponseRequireAccessAccessGroupRule], -// [ZeroTrustAccessGroupListResponseRequireAccessAzureGroupRule], -// [ZeroTrustAccessGroupListResponseRequireAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupListResponseRequireAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupListResponseRequireAccessOktaGroupRule], -// [ZeroTrustAccessGroupListResponseRequireAccessSamlGroupRule], -// [ZeroTrustAccessGroupListResponseRequireAccessServiceTokenRule], -// [ZeroTrustAccessGroupListResponseRequireAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupListResponseRequireAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupListResponseRequireAccessCountryRule], -// [ZeroTrustAccessGroupListResponseRequireAccessAuthenticationMethodRule] or -// [ZeroTrustAccessGroupListResponseRequireAccessDevicePostureRule]. -type ZeroTrustAccessGroupListResponseRequire interface { - implementsZeroTrustAccessGroupListResponseRequire() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessGroupListResponseRequire)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupListResponseRequireAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessGroupListResponseRequireAccessEmailRule struct { - Email ZeroTrustAccessGroupListResponseRequireAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessEmailRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupListResponseRequireAccessEmailRule] -type zeroTrustAccessGroupListResponseRequireAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessEmailRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -type ZeroTrustAccessGroupListResponseRequireAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessGroupListResponseRequireAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessEmailRuleEmailJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessEmailRuleEmail] -type zeroTrustAccessGroupListResponseRequireAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupListResponseRequireAccessEmailListRule struct { - EmailList ZeroTrustAccessGroupListResponseRequireAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessEmailListRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessEmailListRule] -type zeroTrustAccessGroupListResponseRequireAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessEmailListRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -type ZeroTrustAccessGroupListResponseRequireAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessEmailListRuleEmailListJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessEmailListRuleEmailList] -type zeroTrustAccessGroupListResponseRequireAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessGroupListResponseRequireAccessDomainRule struct { - EmailDomain ZeroTrustAccessGroupListResponseRequireAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessDomainRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessDomainRule] -type zeroTrustAccessGroupListResponseRequireAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessDomainRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -type ZeroTrustAccessGroupListResponseRequireAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessDomainRuleEmailDomainJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessDomainRuleEmailDomain] -type zeroTrustAccessGroupListResponseRequireAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessGroupListResponseRequireAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessEveryoneRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessEveryoneRule] -type zeroTrustAccessGroupListResponseRequireAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessEveryoneRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupListResponseRequireAccessIPRule struct { - IP ZeroTrustAccessGroupListResponseRequireAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessIPRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupListResponseRequireAccessIPRule] -type zeroTrustAccessGroupListResponseRequireAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessIPRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -type ZeroTrustAccessGroupListResponseRequireAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessIPRuleIPJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupListResponseRequireAccessIPRuleIP] -type zeroTrustAccessGroupListResponseRequireAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupListResponseRequireAccessIPListRule struct { - IPList ZeroTrustAccessGroupListResponseRequireAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessIPListRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessIPListRule] -type zeroTrustAccessGroupListResponseRequireAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessIPListRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -type ZeroTrustAccessGroupListResponseRequireAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessIPListRuleIPListJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessIPListRuleIPList] -type zeroTrustAccessGroupListResponseRequireAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupListResponseRequireAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessCertificateRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessCertificateRule] -type zeroTrustAccessGroupListResponseRequireAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessCertificateRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupListResponseRequireAccessAccessGroupRule struct { - Group ZeroTrustAccessGroupListResponseRequireAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessAccessGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessAccessGroupRule] -type zeroTrustAccessGroupListResponseRequireAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessAccessGroupRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -type ZeroTrustAccessGroupListResponseRequireAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessAccessGroupRuleGroupJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessAccessGroupRuleGroup] -type zeroTrustAccessGroupListResponseRequireAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupListResponseRequireAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessGroupListResponseRequireAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessAzureGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessAzureGroupRule] -type zeroTrustAccessGroupListResponseRequireAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessAzureGroupRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -type ZeroTrustAccessGroupListResponseRequireAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessAzureGroupRuleAzureAdJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessAzureGroupRuleAzureAd] -type zeroTrustAccessGroupListResponseRequireAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupListResponseRequireAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessGroupListResponseRequireAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessGitHubOrganizationRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessGitHubOrganizationRule] -type zeroTrustAccessGroupListResponseRequireAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -type ZeroTrustAccessGroupListResponseRequireAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessGroupListResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupListResponseRequireAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessGroupListResponseRequireAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessGsuiteGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessGsuiteGroupRule] -type zeroTrustAccessGroupListResponseRequireAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessGsuiteGroupRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -type ZeroTrustAccessGroupListResponseRequireAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessGsuiteGroupRuleGsuiteJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessGroupListResponseRequireAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupListResponseRequireAccessOktaGroupRule struct { - Okta ZeroTrustAccessGroupListResponseRequireAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessOktaGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessOktaGroupRule] -type zeroTrustAccessGroupListResponseRequireAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessOktaGroupRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -type ZeroTrustAccessGroupListResponseRequireAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessOktaGroupRuleOktaJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessOktaGroupRuleOkta] -type zeroTrustAccessGroupListResponseRequireAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupListResponseRequireAccessSamlGroupRule struct { - Saml ZeroTrustAccessGroupListResponseRequireAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessSamlGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessSamlGroupRule] -type zeroTrustAccessGroupListResponseRequireAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessSamlGroupRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -type ZeroTrustAccessGroupListResponseRequireAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessSamlGroupRuleSamlJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessSamlGroupRuleSaml] -type zeroTrustAccessGroupListResponseRequireAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupListResponseRequireAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessGroupListResponseRequireAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessServiceTokenRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessServiceTokenRule] -type zeroTrustAccessGroupListResponseRequireAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessServiceTokenRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -type ZeroTrustAccessGroupListResponseRequireAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessServiceTokenRuleServiceToken] -type zeroTrustAccessGroupListResponseRequireAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupListResponseRequireAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessAnyValidServiceTokenRule] -type zeroTrustAccessGroupListResponseRequireAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupListResponseRequireAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessGroupListResponseRequireAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessExternalEvaluationRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessExternalEvaluationRule] -type zeroTrustAccessGroupListResponseRequireAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessExternalEvaluationRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -type ZeroTrustAccessGroupListResponseRequireAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessGroupListResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessGroupListResponseRequireAccessCountryRule struct { - Geo ZeroTrustAccessGroupListResponseRequireAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessCountryRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessCountryRule] -type zeroTrustAccessGroupListResponseRequireAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessCountryRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -type ZeroTrustAccessGroupListResponseRequireAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessCountryRuleGeoJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessCountryRuleGeo] -type zeroTrustAccessGroupListResponseRequireAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessGroupListResponseRequireAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessGroupListResponseRequireAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessAuthenticationMethodRule] -type zeroTrustAccessGroupListResponseRequireAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -type ZeroTrustAccessGroupListResponseRequireAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessGroupListResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupListResponseRequireAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessGroupListResponseRequireAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessDevicePostureRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessDevicePostureRule] -type zeroTrustAccessGroupListResponseRequireAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupListResponseRequireAccessDevicePostureRule) implementsZeroTrustAccessGroupListResponseRequire() { -} - -type ZeroTrustAccessGroupListResponseRequireAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessGroupListResponseRequireAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseRequireAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupListResponseRequireAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessGroupListResponseRequireAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseRequireAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseRequireAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessGroupDeleteResponse struct { - // UUID - ID string `json:"id"` - JSON zeroTrustAccessGroupDeleteResponseJSON `json:"-"` -} - -// zeroTrustAccessGroupDeleteResponseJSON contains the JSON metadata for the struct -// [ZeroTrustAccessGroupDeleteResponse] -type zeroTrustAccessGroupDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessGroupGetResponse struct { - // UUID - ID string `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Rules evaluated with a NOT logical operator. To match a policy, a user cannot - // meet any of the Exclude rules. - Exclude []ZeroTrustAccessGroupGetResponseExclude `json:"exclude"` - // Rules evaluated with an OR logical operator. A user needs to meet only one of - // the Include rules. - Include []ZeroTrustAccessGroupGetResponseInclude `json:"include"` - // Rules evaluated with an AND logical operator. To match a policy, a user must - // meet all of the Require rules. - IsDefault []ZeroTrustAccessGroupGetResponseIsDefault `json:"is_default"` - // The name of the Access group. - Name string `json:"name"` - // Rules evaluated with an AND logical operator. To match a policy, a user must - // meet all of the Require rules. - Require []ZeroTrustAccessGroupGetResponseRequire `json:"require"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessGroupGetResponseJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseJSON contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponse] -type zeroTrustAccessGroupGetResponseJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Exclude apijson.Field - Include apijson.Field - IsDefault apijson.Field - Name apijson.Field - Require apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [ZeroTrustAccessGroupGetResponseExcludeAccessEmailRule], -// [ZeroTrustAccessGroupGetResponseExcludeAccessEmailListRule], -// [ZeroTrustAccessGroupGetResponseExcludeAccessDomainRule], -// [ZeroTrustAccessGroupGetResponseExcludeAccessEveryoneRule], -// [ZeroTrustAccessGroupGetResponseExcludeAccessIPRule], -// [ZeroTrustAccessGroupGetResponseExcludeAccessIPListRule], -// [ZeroTrustAccessGroupGetResponseExcludeAccessCertificateRule], -// [ZeroTrustAccessGroupGetResponseExcludeAccessAccessGroupRule], -// [ZeroTrustAccessGroupGetResponseExcludeAccessAzureGroupRule], -// [ZeroTrustAccessGroupGetResponseExcludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupGetResponseExcludeAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupGetResponseExcludeAccessOktaGroupRule], -// [ZeroTrustAccessGroupGetResponseExcludeAccessSamlGroupRule], -// [ZeroTrustAccessGroupGetResponseExcludeAccessServiceTokenRule], -// [ZeroTrustAccessGroupGetResponseExcludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupGetResponseExcludeAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupGetResponseExcludeAccessCountryRule], -// [ZeroTrustAccessGroupGetResponseExcludeAccessAuthenticationMethodRule] or -// [ZeroTrustAccessGroupGetResponseExcludeAccessDevicePostureRule]. -type ZeroTrustAccessGroupGetResponseExclude interface { - implementsZeroTrustAccessGroupGetResponseExclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessGroupGetResponseExclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseExcludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessGroupGetResponseExcludeAccessEmailRule struct { - Email ZeroTrustAccessGroupGetResponseExcludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessEmailRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupGetResponseExcludeAccessEmailRule] -type zeroTrustAccessGroupGetResponseExcludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessEmailRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -type ZeroTrustAccessGroupGetResponseExcludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessEmailRuleEmailJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessEmailRuleEmail] -type zeroTrustAccessGroupGetResponseExcludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupGetResponseExcludeAccessEmailListRule struct { - EmailList ZeroTrustAccessGroupGetResponseExcludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessEmailListRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessEmailListRule] -type zeroTrustAccessGroupGetResponseExcludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessEmailListRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -type ZeroTrustAccessGroupGetResponseExcludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessEmailListRuleEmailListJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessEmailListRuleEmailList] -type zeroTrustAccessGroupGetResponseExcludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessGroupGetResponseExcludeAccessDomainRule struct { - EmailDomain ZeroTrustAccessGroupGetResponseExcludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessDomainRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupGetResponseExcludeAccessDomainRule] -type zeroTrustAccessGroupGetResponseExcludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessDomainRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -type ZeroTrustAccessGroupGetResponseExcludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessDomainRuleEmailDomainJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessDomainRuleEmailDomain] -type zeroTrustAccessGroupGetResponseExcludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessGroupGetResponseExcludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessEveryoneRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessEveryoneRule] -type zeroTrustAccessGroupGetResponseExcludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessEveryoneRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupGetResponseExcludeAccessIPRule struct { - IP ZeroTrustAccessGroupGetResponseExcludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessIPRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupGetResponseExcludeAccessIPRule] -type zeroTrustAccessGroupGetResponseExcludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessIPRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -type ZeroTrustAccessGroupGetResponseExcludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessIPRuleIPJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupGetResponseExcludeAccessIPRuleIP] -type zeroTrustAccessGroupGetResponseExcludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupGetResponseExcludeAccessIPListRule struct { - IPList ZeroTrustAccessGroupGetResponseExcludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessIPListRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupGetResponseExcludeAccessIPListRule] -type zeroTrustAccessGroupGetResponseExcludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessIPListRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -type ZeroTrustAccessGroupGetResponseExcludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessIPListRuleIPListJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessIPListRuleIPList] -type zeroTrustAccessGroupGetResponseExcludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupGetResponseExcludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessCertificateRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessCertificateRule] -type zeroTrustAccessGroupGetResponseExcludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessCertificateRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupGetResponseExcludeAccessAccessGroupRule struct { - Group ZeroTrustAccessGroupGetResponseExcludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessAccessGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessAccessGroupRule] -type zeroTrustAccessGroupGetResponseExcludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessAccessGroupRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -type ZeroTrustAccessGroupGetResponseExcludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessAccessGroupRuleGroupJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessAccessGroupRuleGroup] -type zeroTrustAccessGroupGetResponseExcludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupGetResponseExcludeAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessGroupGetResponseExcludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessAzureGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessAzureGroupRule] -type zeroTrustAccessGroupGetResponseExcludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessAzureGroupRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -type ZeroTrustAccessGroupGetResponseExcludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessAzureGroupRuleAzureAdJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessAzureGroupRuleAzureAd] -type zeroTrustAccessGroupGetResponseExcludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupGetResponseExcludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessGroupGetResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessGitHubOrganizationRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessGitHubOrganizationRule] -type zeroTrustAccessGroupGetResponseExcludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -type ZeroTrustAccessGroupGetResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessGroupGetResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupGetResponseExcludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessGroupGetResponseExcludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessGsuiteGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessGsuiteGroupRule] -type zeroTrustAccessGroupGetResponseExcludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -type ZeroTrustAccessGroupGetResponseExcludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessGsuiteGroupRuleGsuiteJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessGroupGetResponseExcludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupGetResponseExcludeAccessOktaGroupRule struct { - Okta ZeroTrustAccessGroupGetResponseExcludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessOktaGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessOktaGroupRule] -type zeroTrustAccessGroupGetResponseExcludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessOktaGroupRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -type ZeroTrustAccessGroupGetResponseExcludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessOktaGroupRuleOktaJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessOktaGroupRuleOkta] -type zeroTrustAccessGroupGetResponseExcludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupGetResponseExcludeAccessSamlGroupRule struct { - Saml ZeroTrustAccessGroupGetResponseExcludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessSamlGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessSamlGroupRule] -type zeroTrustAccessGroupGetResponseExcludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessSamlGroupRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -type ZeroTrustAccessGroupGetResponseExcludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessSamlGroupRuleSamlJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessSamlGroupRuleSaml] -type zeroTrustAccessGroupGetResponseExcludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupGetResponseExcludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessGroupGetResponseExcludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessServiceTokenRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessServiceTokenRule] -type zeroTrustAccessGroupGetResponseExcludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessServiceTokenRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -type ZeroTrustAccessGroupGetResponseExcludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessServiceTokenRuleServiceToken] -type zeroTrustAccessGroupGetResponseExcludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupGetResponseExcludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessAnyValidServiceTokenRule] -type zeroTrustAccessGroupGetResponseExcludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupGetResponseExcludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessGroupGetResponseExcludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessExternalEvaluationRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessExternalEvaluationRule] -type zeroTrustAccessGroupGetResponseExcludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -type ZeroTrustAccessGroupGetResponseExcludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessGroupGetResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessGroupGetResponseExcludeAccessCountryRule struct { - Geo ZeroTrustAccessGroupGetResponseExcludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessCountryRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessCountryRule] -type zeroTrustAccessGroupGetResponseExcludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessCountryRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -type ZeroTrustAccessGroupGetResponseExcludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessCountryRuleGeoJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessCountryRuleGeo] -type zeroTrustAccessGroupGetResponseExcludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessGroupGetResponseExcludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessGroupGetResponseExcludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessAuthenticationMethodRule] -type zeroTrustAccessGroupGetResponseExcludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -type ZeroTrustAccessGroupGetResponseExcludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessGroupGetResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupGetResponseExcludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessGroupGetResponseExcludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessDevicePostureRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessDevicePostureRule] -type zeroTrustAccessGroupGetResponseExcludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseExcludeAccessDevicePostureRule) implementsZeroTrustAccessGroupGetResponseExclude() { -} - -type ZeroTrustAccessGroupGetResponseExcludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessGroupGetResponseExcludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseExcludeAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseExcludeAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessGroupGetResponseExcludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseExcludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseExcludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [ZeroTrustAccessGroupGetResponseIncludeAccessEmailRule], -// [ZeroTrustAccessGroupGetResponseIncludeAccessEmailListRule], -// [ZeroTrustAccessGroupGetResponseIncludeAccessDomainRule], -// [ZeroTrustAccessGroupGetResponseIncludeAccessEveryoneRule], -// [ZeroTrustAccessGroupGetResponseIncludeAccessIPRule], -// [ZeroTrustAccessGroupGetResponseIncludeAccessIPListRule], -// [ZeroTrustAccessGroupGetResponseIncludeAccessCertificateRule], -// [ZeroTrustAccessGroupGetResponseIncludeAccessAccessGroupRule], -// [ZeroTrustAccessGroupGetResponseIncludeAccessAzureGroupRule], -// [ZeroTrustAccessGroupGetResponseIncludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupGetResponseIncludeAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupGetResponseIncludeAccessOktaGroupRule], -// [ZeroTrustAccessGroupGetResponseIncludeAccessSamlGroupRule], -// [ZeroTrustAccessGroupGetResponseIncludeAccessServiceTokenRule], -// [ZeroTrustAccessGroupGetResponseIncludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupGetResponseIncludeAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupGetResponseIncludeAccessCountryRule], -// [ZeroTrustAccessGroupGetResponseIncludeAccessAuthenticationMethodRule] or -// [ZeroTrustAccessGroupGetResponseIncludeAccessDevicePostureRule]. -type ZeroTrustAccessGroupGetResponseInclude interface { - implementsZeroTrustAccessGroupGetResponseInclude() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessGroupGetResponseInclude)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIncludeAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessGroupGetResponseIncludeAccessEmailRule struct { - Email ZeroTrustAccessGroupGetResponseIncludeAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessEmailRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupGetResponseIncludeAccessEmailRule] -type zeroTrustAccessGroupGetResponseIncludeAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessEmailRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -type ZeroTrustAccessGroupGetResponseIncludeAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessEmailRuleEmailJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessEmailRuleEmail] -type zeroTrustAccessGroupGetResponseIncludeAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupGetResponseIncludeAccessEmailListRule struct { - EmailList ZeroTrustAccessGroupGetResponseIncludeAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessEmailListRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessEmailListRule] -type zeroTrustAccessGroupGetResponseIncludeAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessEmailListRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -type ZeroTrustAccessGroupGetResponseIncludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessEmailListRuleEmailListJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessEmailListRuleEmailList] -type zeroTrustAccessGroupGetResponseIncludeAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessGroupGetResponseIncludeAccessDomainRule struct { - EmailDomain ZeroTrustAccessGroupGetResponseIncludeAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessDomainRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupGetResponseIncludeAccessDomainRule] -type zeroTrustAccessGroupGetResponseIncludeAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessDomainRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -type ZeroTrustAccessGroupGetResponseIncludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessDomainRuleEmailDomainJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessDomainRuleEmailDomain] -type zeroTrustAccessGroupGetResponseIncludeAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessGroupGetResponseIncludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessEveryoneRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessEveryoneRule] -type zeroTrustAccessGroupGetResponseIncludeAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessEveryoneRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupGetResponseIncludeAccessIPRule struct { - IP ZeroTrustAccessGroupGetResponseIncludeAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessIPRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupGetResponseIncludeAccessIPRule] -type zeroTrustAccessGroupGetResponseIncludeAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessIPRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -type ZeroTrustAccessGroupGetResponseIncludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessIPRuleIPJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupGetResponseIncludeAccessIPRuleIP] -type zeroTrustAccessGroupGetResponseIncludeAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupGetResponseIncludeAccessIPListRule struct { - IPList ZeroTrustAccessGroupGetResponseIncludeAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessIPListRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupGetResponseIncludeAccessIPListRule] -type zeroTrustAccessGroupGetResponseIncludeAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessIPListRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -type ZeroTrustAccessGroupGetResponseIncludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessIPListRuleIPListJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessIPListRuleIPList] -type zeroTrustAccessGroupGetResponseIncludeAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupGetResponseIncludeAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessCertificateRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessCertificateRule] -type zeroTrustAccessGroupGetResponseIncludeAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessCertificateRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupGetResponseIncludeAccessAccessGroupRule struct { - Group ZeroTrustAccessGroupGetResponseIncludeAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessAccessGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessAccessGroupRule] -type zeroTrustAccessGroupGetResponseIncludeAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessAccessGroupRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -type ZeroTrustAccessGroupGetResponseIncludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessAccessGroupRuleGroupJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessAccessGroupRuleGroup] -type zeroTrustAccessGroupGetResponseIncludeAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupGetResponseIncludeAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessGroupGetResponseIncludeAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessAzureGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessAzureGroupRule] -type zeroTrustAccessGroupGetResponseIncludeAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessAzureGroupRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -type ZeroTrustAccessGroupGetResponseIncludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessAzureGroupRuleAzureAdJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessAzureGroupRuleAzureAd] -type zeroTrustAccessGroupGetResponseIncludeAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupGetResponseIncludeAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessGroupGetResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessGitHubOrganizationRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessGitHubOrganizationRule] -type zeroTrustAccessGroupGetResponseIncludeAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -type ZeroTrustAccessGroupGetResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessGroupGetResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupGetResponseIncludeAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessGroupGetResponseIncludeAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessGsuiteGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessGsuiteGroupRule] -type zeroTrustAccessGroupGetResponseIncludeAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -type ZeroTrustAccessGroupGetResponseIncludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessGsuiteGroupRuleGsuiteJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessGroupGetResponseIncludeAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupGetResponseIncludeAccessOktaGroupRule struct { - Okta ZeroTrustAccessGroupGetResponseIncludeAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessOktaGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessOktaGroupRule] -type zeroTrustAccessGroupGetResponseIncludeAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessOktaGroupRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -type ZeroTrustAccessGroupGetResponseIncludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessOktaGroupRuleOktaJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessOktaGroupRuleOkta] -type zeroTrustAccessGroupGetResponseIncludeAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupGetResponseIncludeAccessSamlGroupRule struct { - Saml ZeroTrustAccessGroupGetResponseIncludeAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessSamlGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessSamlGroupRule] -type zeroTrustAccessGroupGetResponseIncludeAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessSamlGroupRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -type ZeroTrustAccessGroupGetResponseIncludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessSamlGroupRuleSamlJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessSamlGroupRuleSaml] -type zeroTrustAccessGroupGetResponseIncludeAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupGetResponseIncludeAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessGroupGetResponseIncludeAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessServiceTokenRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessServiceTokenRule] -type zeroTrustAccessGroupGetResponseIncludeAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessServiceTokenRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -type ZeroTrustAccessGroupGetResponseIncludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessServiceTokenRuleServiceToken] -type zeroTrustAccessGroupGetResponseIncludeAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupGetResponseIncludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessAnyValidServiceTokenRule] -type zeroTrustAccessGroupGetResponseIncludeAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupGetResponseIncludeAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessGroupGetResponseIncludeAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessExternalEvaluationRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessExternalEvaluationRule] -type zeroTrustAccessGroupGetResponseIncludeAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -type ZeroTrustAccessGroupGetResponseIncludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessGroupGetResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessGroupGetResponseIncludeAccessCountryRule struct { - Geo ZeroTrustAccessGroupGetResponseIncludeAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessCountryRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessCountryRule] -type zeroTrustAccessGroupGetResponseIncludeAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessCountryRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -type ZeroTrustAccessGroupGetResponseIncludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessCountryRuleGeoJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessCountryRuleGeo] -type zeroTrustAccessGroupGetResponseIncludeAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessGroupGetResponseIncludeAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessGroupGetResponseIncludeAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessAuthenticationMethodRule] -type zeroTrustAccessGroupGetResponseIncludeAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -type ZeroTrustAccessGroupGetResponseIncludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessGroupGetResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupGetResponseIncludeAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessGroupGetResponseIncludeAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessDevicePostureRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessDevicePostureRule] -type zeroTrustAccessGroupGetResponseIncludeAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIncludeAccessDevicePostureRule) implementsZeroTrustAccessGroupGetResponseInclude() { -} - -type ZeroTrustAccessGroupGetResponseIncludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessGroupGetResponseIncludeAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIncludeAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIncludeAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessGroupGetResponseIncludeAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIncludeAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIncludeAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailRule], -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailListRule], -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessDomainRule], -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessEveryoneRule], -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessIPRule], -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessIPListRule], -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessCertificateRule], -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessAccessGroupRule], -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessAzureGroupRule], -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessOktaGroupRule], -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessSamlGroupRule], -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessServiceTokenRule], -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessCountryRule], -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessAuthenticationMethodRule] or -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessDevicePostureRule]. -type ZeroTrustAccessGroupGetResponseIsDefault interface { - implementsZeroTrustAccessGroupGetResponseIsDefault() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessGroupGetResponseIsDefault)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseIsDefaultAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailRule struct { - Email ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessEmailRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -type ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessEmailRuleEmailJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailRuleEmail] -type zeroTrustAccessGroupGetResponseIsDefaultAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailListRule struct { - EmailList ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessEmailListRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailListRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailListRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -type ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessEmailListRuleEmailListJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailListRuleEmailList] -type zeroTrustAccessGroupGetResponseIsDefaultAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessGroupGetResponseIsDefaultAccessDomainRule struct { - EmailDomain ZeroTrustAccessGroupGetResponseIsDefaultAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessDomainRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessDomainRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessDomainRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -type ZeroTrustAccessGroupGetResponseIsDefaultAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessDomainRuleEmailDomainJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessDomainRuleEmailDomain] -type zeroTrustAccessGroupGetResponseIsDefaultAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessGroupGetResponseIsDefaultAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessEveryoneRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessEveryoneRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessEveryoneRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupGetResponseIsDefaultAccessIPRule struct { - IP ZeroTrustAccessGroupGetResponseIsDefaultAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessIPRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupGetResponseIsDefaultAccessIPRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessIPRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -type ZeroTrustAccessGroupGetResponseIsDefaultAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessIPRuleIPJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupGetResponseIsDefaultAccessIPRuleIP] -type zeroTrustAccessGroupGetResponseIsDefaultAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupGetResponseIsDefaultAccessIPListRule struct { - IPList ZeroTrustAccessGroupGetResponseIsDefaultAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessIPListRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessIPListRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessIPListRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -type ZeroTrustAccessGroupGetResponseIsDefaultAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessIPListRuleIPListJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessIPListRuleIPList] -type zeroTrustAccessGroupGetResponseIsDefaultAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupGetResponseIsDefaultAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessCertificateRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessCertificateRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessCertificateRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupGetResponseIsDefaultAccessAccessGroupRule struct { - Group ZeroTrustAccessGroupGetResponseIsDefaultAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessAccessGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessAccessGroupRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessAccessGroupRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -type ZeroTrustAccessGroupGetResponseIsDefaultAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessAccessGroupRuleGroupJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessAccessGroupRuleGroup] -type zeroTrustAccessGroupGetResponseIsDefaultAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupGetResponseIsDefaultAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessGroupGetResponseIsDefaultAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessAzureGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessAzureGroupRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessAzureGroupRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -type ZeroTrustAccessGroupGetResponseIsDefaultAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessAzureGroupRuleAzureAdJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessAzureGroupRuleAzureAd] -type zeroTrustAccessGroupGetResponseIsDefaultAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupGetResponseIsDefaultAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessGroupGetResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessGitHubOrganizationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessGitHubOrganizationRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -type ZeroTrustAccessGroupGetResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessGroupGetResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupGetResponseIsDefaultAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessGroupGetResponseIsDefaultAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessGsuiteGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessGsuiteGroupRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessGsuiteGroupRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -type ZeroTrustAccessGroupGetResponseIsDefaultAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessGsuiteGroupRuleGsuiteJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessGroupGetResponseIsDefaultAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupGetResponseIsDefaultAccessOktaGroupRule struct { - Okta ZeroTrustAccessGroupGetResponseIsDefaultAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessOktaGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessOktaGroupRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessOktaGroupRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -type ZeroTrustAccessGroupGetResponseIsDefaultAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessOktaGroupRuleOktaJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessOktaGroupRuleOkta] -type zeroTrustAccessGroupGetResponseIsDefaultAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupGetResponseIsDefaultAccessSamlGroupRule struct { - Saml ZeroTrustAccessGroupGetResponseIsDefaultAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessSamlGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessSamlGroupRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessSamlGroupRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -type ZeroTrustAccessGroupGetResponseIsDefaultAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessSamlGroupRuleSamlJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessSamlGroupRuleSaml] -type zeroTrustAccessGroupGetResponseIsDefaultAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupGetResponseIsDefaultAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessGroupGetResponseIsDefaultAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessServiceTokenRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessServiceTokenRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessServiceTokenRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -type ZeroTrustAccessGroupGetResponseIsDefaultAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessServiceTokenRuleServiceToken] -type zeroTrustAccessGroupGetResponseIsDefaultAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupGetResponseIsDefaultAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessAnyValidServiceTokenRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupGetResponseIsDefaultAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessGroupGetResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessExternalEvaluationRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessExternalEvaluationRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessExternalEvaluationRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -type ZeroTrustAccessGroupGetResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessGroupGetResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessGroupGetResponseIsDefaultAccessCountryRule struct { - Geo ZeroTrustAccessGroupGetResponseIsDefaultAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessCountryRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessCountryRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessCountryRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -type ZeroTrustAccessGroupGetResponseIsDefaultAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessCountryRuleGeoJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessCountryRuleGeo] -type zeroTrustAccessGroupGetResponseIsDefaultAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessGroupGetResponseIsDefaultAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessGroupGetResponseIsDefaultAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessAuthenticationMethodRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -type ZeroTrustAccessGroupGetResponseIsDefaultAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessGroupGetResponseIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupGetResponseIsDefaultAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessGroupGetResponseIsDefaultAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessDevicePostureRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessDevicePostureRule] -type zeroTrustAccessGroupGetResponseIsDefaultAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseIsDefaultAccessDevicePostureRule) implementsZeroTrustAccessGroupGetResponseIsDefault() { -} - -type ZeroTrustAccessGroupGetResponseIsDefaultAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessGroupGetResponseIsDefaultAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseIsDefaultAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseIsDefaultAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessGroupGetResponseIsDefaultAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseIsDefaultAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseIsDefaultAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -// Matches a specific email. -// -// Union satisfied by [ZeroTrustAccessGroupGetResponseRequireAccessEmailRule], -// [ZeroTrustAccessGroupGetResponseRequireAccessEmailListRule], -// [ZeroTrustAccessGroupGetResponseRequireAccessDomainRule], -// [ZeroTrustAccessGroupGetResponseRequireAccessEveryoneRule], -// [ZeroTrustAccessGroupGetResponseRequireAccessIPRule], -// [ZeroTrustAccessGroupGetResponseRequireAccessIPListRule], -// [ZeroTrustAccessGroupGetResponseRequireAccessCertificateRule], -// [ZeroTrustAccessGroupGetResponseRequireAccessAccessGroupRule], -// [ZeroTrustAccessGroupGetResponseRequireAccessAzureGroupRule], -// [ZeroTrustAccessGroupGetResponseRequireAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupGetResponseRequireAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupGetResponseRequireAccessOktaGroupRule], -// [ZeroTrustAccessGroupGetResponseRequireAccessSamlGroupRule], -// [ZeroTrustAccessGroupGetResponseRequireAccessServiceTokenRule], -// [ZeroTrustAccessGroupGetResponseRequireAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupGetResponseRequireAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupGetResponseRequireAccessCountryRule], -// [ZeroTrustAccessGroupGetResponseRequireAccessAuthenticationMethodRule] or -// [ZeroTrustAccessGroupGetResponseRequireAccessDevicePostureRule]. -type ZeroTrustAccessGroupGetResponseRequire interface { - implementsZeroTrustAccessGroupGetResponseRequire() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessGroupGetResponseRequire)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessEmailRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessEmailListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessDomainRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessEveryoneRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessIPRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessIPListRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessCertificateRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessAccessGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessAzureGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessGitHubOrganizationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessGsuiteGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessOktaGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessSamlGroupRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessAnyValidServiceTokenRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessExternalEvaluationRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessCountryRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessAuthenticationMethodRule{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustAccessGroupGetResponseRequireAccessDevicePostureRule{}), - }, - ) -} - -// Matches a specific email. -type ZeroTrustAccessGroupGetResponseRequireAccessEmailRule struct { - Email ZeroTrustAccessGroupGetResponseRequireAccessEmailRuleEmail `json:"email,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessEmailRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessEmailRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupGetResponseRequireAccessEmailRule] -type zeroTrustAccessGroupGetResponseRequireAccessEmailRuleJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessEmailRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessEmailRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessEmailRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -type ZeroTrustAccessGroupGetResponseRequireAccessEmailRuleEmail struct { - // The email of the user. - Email string `json:"email,required" format:"email"` - JSON zeroTrustAccessGroupGetResponseRequireAccessEmailRuleEmailJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessEmailRuleEmailJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessEmailRuleEmail] -type zeroTrustAccessGroupGetResponseRequireAccessEmailRuleEmailJSON struct { - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessEmailRuleEmail) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessEmailRuleEmailJSON) RawJSON() string { - return r.raw -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupGetResponseRequireAccessEmailListRule struct { - EmailList ZeroTrustAccessGroupGetResponseRequireAccessEmailListRuleEmailList `json:"email_list,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessEmailListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessEmailListRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessEmailListRule] -type zeroTrustAccessGroupGetResponseRequireAccessEmailListRuleJSON struct { - EmailList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessEmailListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessEmailListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessEmailListRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -type ZeroTrustAccessGroupGetResponseRequireAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessEmailListRuleEmailListJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessEmailListRuleEmailListJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessEmailListRuleEmailList] -type zeroTrustAccessGroupGetResponseRequireAccessEmailListRuleEmailListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessEmailListRuleEmailList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessEmailListRuleEmailListJSON) RawJSON() string { - return r.raw -} - -// Match an entire email domain. -type ZeroTrustAccessGroupGetResponseRequireAccessDomainRule struct { - EmailDomain ZeroTrustAccessGroupGetResponseRequireAccessDomainRuleEmailDomain `json:"email_domain,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessDomainRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessDomainRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupGetResponseRequireAccessDomainRule] -type zeroTrustAccessGroupGetResponseRequireAccessDomainRuleJSON struct { - EmailDomain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessDomainRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessDomainRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessDomainRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -type ZeroTrustAccessGroupGetResponseRequireAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain string `json:"domain,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessDomainRuleEmailDomainJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessDomainRuleEmailDomainJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessDomainRuleEmailDomain] -type zeroTrustAccessGroupGetResponseRequireAccessDomainRuleEmailDomainJSON struct { - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessDomainRuleEmailDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessDomainRuleEmailDomainJSON) RawJSON() string { - return r.raw -} - -// Matches everyone. -type ZeroTrustAccessGroupGetResponseRequireAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone interface{} `json:"everyone,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessEveryoneRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessEveryoneRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessEveryoneRule] -type zeroTrustAccessGroupGetResponseRequireAccessEveryoneRuleJSON struct { - Everyone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessEveryoneRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessEveryoneRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessEveryoneRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupGetResponseRequireAccessIPRule struct { - IP ZeroTrustAccessGroupGetResponseRequireAccessIPRuleIP `json:"ip,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessIPRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessIPRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupGetResponseRequireAccessIPRule] -type zeroTrustAccessGroupGetResponseRequireAccessIPRuleJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessIPRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessIPRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessIPRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -type ZeroTrustAccessGroupGetResponseRequireAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP string `json:"ip,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessIPRuleIPJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessIPRuleIPJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupGetResponseRequireAccessIPRuleIP] -type zeroTrustAccessGroupGetResponseRequireAccessIPRuleIPJSON struct { - IP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessIPRuleIP) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessIPRuleIPJSON) RawJSON() string { - return r.raw -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupGetResponseRequireAccessIPListRule struct { - IPList ZeroTrustAccessGroupGetResponseRequireAccessIPListRuleIPList `json:"ip_list,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessIPListRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessIPListRuleJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupGetResponseRequireAccessIPListRule] -type zeroTrustAccessGroupGetResponseRequireAccessIPListRuleJSON struct { - IPList apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessIPListRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessIPListRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessIPListRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -type ZeroTrustAccessGroupGetResponseRequireAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessIPListRuleIPListJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessIPListRuleIPListJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessIPListRuleIPList] -type zeroTrustAccessGroupGetResponseRequireAccessIPListRuleIPListJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessIPListRuleIPList) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessIPListRuleIPListJSON) RawJSON() string { - return r.raw -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupGetResponseRequireAccessCertificateRule struct { - Certificate interface{} `json:"certificate,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessCertificateRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessCertificateRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessCertificateRule] -type zeroTrustAccessGroupGetResponseRequireAccessCertificateRuleJSON struct { - Certificate apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessCertificateRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessCertificateRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessCertificateRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupGetResponseRequireAccessAccessGroupRule struct { - Group ZeroTrustAccessGroupGetResponseRequireAccessAccessGroupRuleGroup `json:"group,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessAccessGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessAccessGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessAccessGroupRule] -type zeroTrustAccessGroupGetResponseRequireAccessAccessGroupRuleJSON struct { - Group apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessAccessGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessAccessGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessAccessGroupRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -type ZeroTrustAccessGroupGetResponseRequireAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID string `json:"id,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessAccessGroupRuleGroupJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessAccessGroupRuleGroupJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessAccessGroupRuleGroup] -type zeroTrustAccessGroupGetResponseRequireAccessAccessGroupRuleGroupJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessAccessGroupRuleGroup) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessAccessGroupRuleGroupJSON) RawJSON() string { - return r.raw -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupGetResponseRequireAccessAzureGroupRule struct { - AzureAd ZeroTrustAccessGroupGetResponseRequireAccessAzureGroupRuleAzureAd `json:"azureAD,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessAzureGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessAzureGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessAzureGroupRule] -type zeroTrustAccessGroupGetResponseRequireAccessAzureGroupRuleJSON struct { - AzureAd apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessAzureGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessAzureGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessAzureGroupRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -type ZeroTrustAccessGroupGetResponseRequireAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID string `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessAzureGroupRuleAzureAdJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessAzureGroupRuleAzureAdJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessAzureGroupRuleAzureAd] -type zeroTrustAccessGroupGetResponseRequireAccessAzureGroupRuleAzureAdJSON struct { - ID apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessAzureGroupRuleAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessAzureGroupRuleAzureAdJSON) RawJSON() string { - return r.raw -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupGetResponseRequireAccessGitHubOrganizationRule struct { - GitHubOrganization ZeroTrustAccessGroupGetResponseRequireAccessGitHubOrganizationRuleGitHubOrganization `json:"github-organization,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessGitHubOrganizationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessGitHubOrganizationRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessGitHubOrganizationRule] -type zeroTrustAccessGroupGetResponseRequireAccessGitHubOrganizationRuleJSON struct { - GitHubOrganization apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessGitHubOrganizationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessGitHubOrganizationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -type ZeroTrustAccessGroupGetResponseRequireAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID string `json:"connection_id,required"` - // The name of the organization. - Name string `json:"name,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessGitHubOrganizationRuleGitHubOrganization] -type zeroTrustAccessGroupGetResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON struct { - ConnectionID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessGitHubOrganizationRuleGitHubOrganization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessGitHubOrganizationRuleGitHubOrganizationJSON) RawJSON() string { - return r.raw -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupGetResponseRequireAccessGsuiteGroupRule struct { - Gsuite ZeroTrustAccessGroupGetResponseRequireAccessGsuiteGroupRuleGsuite `json:"gsuite,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessGsuiteGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessGsuiteGroupRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessGsuiteGroupRule] -type zeroTrustAccessGroupGetResponseRequireAccessGsuiteGroupRuleJSON struct { - Gsuite apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessGsuiteGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessGsuiteGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessGsuiteGroupRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -type ZeroTrustAccessGroupGetResponseRequireAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Google Workspace group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessGsuiteGroupRuleGsuiteJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessGsuiteGroupRuleGsuiteJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessGsuiteGroupRuleGsuite] -type zeroTrustAccessGroupGetResponseRequireAccessGsuiteGroupRuleGsuiteJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessGsuiteGroupRuleGsuite) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessGsuiteGroupRuleGsuiteJSON) RawJSON() string { - return r.raw -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupGetResponseRequireAccessOktaGroupRule struct { - Okta ZeroTrustAccessGroupGetResponseRequireAccessOktaGroupRuleOkta `json:"okta,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessOktaGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessOktaGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessOktaGroupRule] -type zeroTrustAccessGroupGetResponseRequireAccessOktaGroupRuleJSON struct { - Okta apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessOktaGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessOktaGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessOktaGroupRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -type ZeroTrustAccessGroupGetResponseRequireAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID string `json:"connection_id,required"` - // The email of the Okta group. - Email string `json:"email,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessOktaGroupRuleOktaJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessOktaGroupRuleOktaJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessOktaGroupRuleOkta] -type zeroTrustAccessGroupGetResponseRequireAccessOktaGroupRuleOktaJSON struct { - ConnectionID apijson.Field - Email apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessOktaGroupRuleOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessOktaGroupRuleOktaJSON) RawJSON() string { - return r.raw -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupGetResponseRequireAccessSamlGroupRule struct { - Saml ZeroTrustAccessGroupGetResponseRequireAccessSamlGroupRuleSaml `json:"saml,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessSamlGroupRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessSamlGroupRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessSamlGroupRule] -type zeroTrustAccessGroupGetResponseRequireAccessSamlGroupRuleJSON struct { - Saml apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessSamlGroupRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessSamlGroupRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessSamlGroupRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -type ZeroTrustAccessGroupGetResponseRequireAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName string `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue string `json:"attribute_value,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessSamlGroupRuleSamlJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessSamlGroupRuleSamlJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessSamlGroupRuleSaml] -type zeroTrustAccessGroupGetResponseRequireAccessSamlGroupRuleSamlJSON struct { - AttributeName apijson.Field - AttributeValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessSamlGroupRuleSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessSamlGroupRuleSamlJSON) RawJSON() string { - return r.raw -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupGetResponseRequireAccessServiceTokenRule struct { - ServiceToken ZeroTrustAccessGroupGetResponseRequireAccessServiceTokenRuleServiceToken `json:"service_token,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessServiceTokenRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessServiceTokenRule] -type zeroTrustAccessGroupGetResponseRequireAccessServiceTokenRuleJSON struct { - ServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessServiceTokenRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -type ZeroTrustAccessGroupGetResponseRequireAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID string `json:"token_id,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessServiceTokenRuleServiceTokenJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessServiceTokenRuleServiceTokenJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessServiceTokenRuleServiceToken] -type zeroTrustAccessGroupGetResponseRequireAccessServiceTokenRuleServiceTokenJSON struct { - TokenID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessServiceTokenRuleServiceToken) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessServiceTokenRuleServiceTokenJSON) RawJSON() string { - return r.raw -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupGetResponseRequireAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken interface{} `json:"any_valid_service_token,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessAnyValidServiceTokenRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessAnyValidServiceTokenRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessAnyValidServiceTokenRule] -type zeroTrustAccessGroupGetResponseRequireAccessAnyValidServiceTokenRuleJSON struct { - AnyValidServiceToken apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessAnyValidServiceTokenRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessAnyValidServiceTokenRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupGetResponseRequireAccessExternalEvaluationRule struct { - ExternalEvaluation ZeroTrustAccessGroupGetResponseRequireAccessExternalEvaluationRuleExternalEvaluation `json:"external_evaluation,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessExternalEvaluationRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessExternalEvaluationRuleJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessExternalEvaluationRule] -type zeroTrustAccessGroupGetResponseRequireAccessExternalEvaluationRuleJSON struct { - ExternalEvaluation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessExternalEvaluationRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessExternalEvaluationRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessExternalEvaluationRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -type ZeroTrustAccessGroupGetResponseRequireAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL string `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL string `json:"keys_url,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessExternalEvaluationRuleExternalEvaluation] -type zeroTrustAccessGroupGetResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON struct { - EvaluateURL apijson.Field - KeysURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessExternalEvaluationRuleExternalEvaluation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessExternalEvaluationRuleExternalEvaluationJSON) RawJSON() string { - return r.raw -} - -// Matches a specific country -type ZeroTrustAccessGroupGetResponseRequireAccessCountryRule struct { - Geo ZeroTrustAccessGroupGetResponseRequireAccessCountryRuleGeo `json:"geo,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessCountryRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessCountryRuleJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessCountryRule] -type zeroTrustAccessGroupGetResponseRequireAccessCountryRuleJSON struct { - Geo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessCountryRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessCountryRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessCountryRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -type ZeroTrustAccessGroupGetResponseRequireAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode string `json:"country_code,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessCountryRuleGeoJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessCountryRuleGeoJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessCountryRuleGeo] -type zeroTrustAccessGroupGetResponseRequireAccessCountryRuleGeoJSON struct { - CountryCode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessCountryRuleGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessCountryRuleGeoJSON) RawJSON() string { - return r.raw -} - -// Enforce different MFA options -type ZeroTrustAccessGroupGetResponseRequireAccessAuthenticationMethodRule struct { - AuthMethod ZeroTrustAccessGroupGetResponseRequireAccessAuthenticationMethodRuleAuthMethod `json:"auth_method,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessAuthenticationMethodRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessAuthenticationMethodRuleJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessAuthenticationMethodRule] -type zeroTrustAccessGroupGetResponseRequireAccessAuthenticationMethodRuleJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessAuthenticationMethodRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessAuthenticationMethodRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -type ZeroTrustAccessGroupGetResponseRequireAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod string `json:"auth_method,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessAuthenticationMethodRuleAuthMethod] -type zeroTrustAccessGroupGetResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON struct { - AuthMethod apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessAuthenticationMethodRuleAuthMethod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessAuthenticationMethodRuleAuthMethodJSON) RawJSON() string { - return r.raw -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupGetResponseRequireAccessDevicePostureRule struct { - DevicePosture ZeroTrustAccessGroupGetResponseRequireAccessDevicePostureRuleDevicePosture `json:"device_posture,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessDevicePostureRuleJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessDevicePostureRuleJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessDevicePostureRule] -type zeroTrustAccessGroupGetResponseRequireAccessDevicePostureRuleJSON struct { - DevicePosture apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessDevicePostureRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessDevicePostureRuleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustAccessGroupGetResponseRequireAccessDevicePostureRule) implementsZeroTrustAccessGroupGetResponseRequire() { -} - -type ZeroTrustAccessGroupGetResponseRequireAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid string `json:"integration_uid,required"` - JSON zeroTrustAccessGroupGetResponseRequireAccessDevicePostureRuleDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseRequireAccessDevicePostureRuleDevicePostureJSON -// contains the JSON metadata for the struct -// [ZeroTrustAccessGroupGetResponseRequireAccessDevicePostureRuleDevicePosture] -type zeroTrustAccessGroupGetResponseRequireAccessDevicePostureRuleDevicePostureJSON struct { - IntegrationUid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseRequireAccessDevicePostureRuleDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseRequireAccessDevicePostureRuleDevicePostureJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessGroupNewParams struct { - // Rules evaluated with an OR logical operator. A user needs to meet only one of - // the Include rules. - Include param.Field[[]ZeroTrustAccessGroupNewParamsInclude] `json:"include,required"` - // The name of the Access group. - Name param.Field[string] `json:"name,required"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // Rules evaluated with a NOT logical operator. To match a policy, a user cannot - // meet any of the Exclude rules. - Exclude param.Field[[]ZeroTrustAccessGroupNewParamsExclude] `json:"exclude"` - // Whether this is the default group - IsDefault param.Field[bool] `json:"is_default"` - // Rules evaluated with an AND logical operator. To match a policy, a user must - // meet all of the Require rules. - Require param.Field[[]ZeroTrustAccessGroupNewParamsRequire] `json:"require"` -} - -func (r ZeroTrustAccessGroupNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by [ZeroTrustAccessGroupNewParamsIncludeAccessEmailRule], -// [ZeroTrustAccessGroupNewParamsIncludeAccessEmailListRule], -// [ZeroTrustAccessGroupNewParamsIncludeAccessDomainRule], -// [ZeroTrustAccessGroupNewParamsIncludeAccessEveryoneRule], -// [ZeroTrustAccessGroupNewParamsIncludeAccessIPRule], -// [ZeroTrustAccessGroupNewParamsIncludeAccessIPListRule], -// [ZeroTrustAccessGroupNewParamsIncludeAccessCertificateRule], -// [ZeroTrustAccessGroupNewParamsIncludeAccessAccessGroupRule], -// [ZeroTrustAccessGroupNewParamsIncludeAccessAzureGroupRule], -// [ZeroTrustAccessGroupNewParamsIncludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupNewParamsIncludeAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupNewParamsIncludeAccessOktaGroupRule], -// [ZeroTrustAccessGroupNewParamsIncludeAccessSamlGroupRule], -// [ZeroTrustAccessGroupNewParamsIncludeAccessServiceTokenRule], -// [ZeroTrustAccessGroupNewParamsIncludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupNewParamsIncludeAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupNewParamsIncludeAccessCountryRule], -// [ZeroTrustAccessGroupNewParamsIncludeAccessAuthenticationMethodRule], -// [ZeroTrustAccessGroupNewParamsIncludeAccessDevicePostureRule]. -type ZeroTrustAccessGroupNewParamsInclude interface { - implementsZeroTrustAccessGroupNewParamsInclude() -} - -// Matches a specific email. -type ZeroTrustAccessGroupNewParamsIncludeAccessEmailRule struct { - Email param.Field[ZeroTrustAccessGroupNewParamsIncludeAccessEmailRuleEmail] `json:"email,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessEmailRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type ZeroTrustAccessGroupNewParamsIncludeAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupNewParamsIncludeAccessEmailListRule struct { - EmailList param.Field[ZeroTrustAccessGroupNewParamsIncludeAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessEmailListRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type ZeroTrustAccessGroupNewParamsIncludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type ZeroTrustAccessGroupNewParamsIncludeAccessDomainRule struct { - EmailDomain param.Field[ZeroTrustAccessGroupNewParamsIncludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessDomainRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type ZeroTrustAccessGroupNewParamsIncludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type ZeroTrustAccessGroupNewParamsIncludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessEveryoneRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupNewParamsIncludeAccessIPRule struct { - IP param.Field[ZeroTrustAccessGroupNewParamsIncludeAccessIPRuleIP] `json:"ip,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessIPRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type ZeroTrustAccessGroupNewParamsIncludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupNewParamsIncludeAccessIPListRule struct { - IPList param.Field[ZeroTrustAccessGroupNewParamsIncludeAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessIPListRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type ZeroTrustAccessGroupNewParamsIncludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupNewParamsIncludeAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessCertificateRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupNewParamsIncludeAccessAccessGroupRule struct { - Group param.Field[ZeroTrustAccessGroupNewParamsIncludeAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessAccessGroupRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type ZeroTrustAccessGroupNewParamsIncludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupNewParamsIncludeAccessAzureGroupRule struct { - AzureAd param.Field[ZeroTrustAccessGroupNewParamsIncludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessAzureGroupRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type ZeroTrustAccessGroupNewParamsIncludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupNewParamsIncludeAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[ZeroTrustAccessGroupNewParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type ZeroTrustAccessGroupNewParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupNewParamsIncludeAccessGsuiteGroupRule struct { - Gsuite param.Field[ZeroTrustAccessGroupNewParamsIncludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type ZeroTrustAccessGroupNewParamsIncludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupNewParamsIncludeAccessOktaGroupRule struct { - Okta param.Field[ZeroTrustAccessGroupNewParamsIncludeAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessOktaGroupRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type ZeroTrustAccessGroupNewParamsIncludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupNewParamsIncludeAccessSamlGroupRule struct { - Saml param.Field[ZeroTrustAccessGroupNewParamsIncludeAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessSamlGroupRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type ZeroTrustAccessGroupNewParamsIncludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupNewParamsIncludeAccessServiceTokenRule struct { - ServiceToken param.Field[ZeroTrustAccessGroupNewParamsIncludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessServiceTokenRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type ZeroTrustAccessGroupNewParamsIncludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupNewParamsIncludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupNewParamsIncludeAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[ZeroTrustAccessGroupNewParamsIncludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type ZeroTrustAccessGroupNewParamsIncludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type ZeroTrustAccessGroupNewParamsIncludeAccessCountryRule struct { - Geo param.Field[ZeroTrustAccessGroupNewParamsIncludeAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessCountryRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type ZeroTrustAccessGroupNewParamsIncludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type ZeroTrustAccessGroupNewParamsIncludeAccessAuthenticationMethodRule struct { - AuthMethod param.Field[ZeroTrustAccessGroupNewParamsIncludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type ZeroTrustAccessGroupNewParamsIncludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupNewParamsIncludeAccessDevicePostureRule struct { - DevicePosture param.Field[ZeroTrustAccessGroupNewParamsIncludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessDevicePostureRule) implementsZeroTrustAccessGroupNewParamsInclude() { -} - -type ZeroTrustAccessGroupNewParamsIncludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r ZeroTrustAccessGroupNewParamsIncludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by [ZeroTrustAccessGroupNewParamsExcludeAccessEmailRule], -// [ZeroTrustAccessGroupNewParamsExcludeAccessEmailListRule], -// [ZeroTrustAccessGroupNewParamsExcludeAccessDomainRule], -// [ZeroTrustAccessGroupNewParamsExcludeAccessEveryoneRule], -// [ZeroTrustAccessGroupNewParamsExcludeAccessIPRule], -// [ZeroTrustAccessGroupNewParamsExcludeAccessIPListRule], -// [ZeroTrustAccessGroupNewParamsExcludeAccessCertificateRule], -// [ZeroTrustAccessGroupNewParamsExcludeAccessAccessGroupRule], -// [ZeroTrustAccessGroupNewParamsExcludeAccessAzureGroupRule], -// [ZeroTrustAccessGroupNewParamsExcludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupNewParamsExcludeAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupNewParamsExcludeAccessOktaGroupRule], -// [ZeroTrustAccessGroupNewParamsExcludeAccessSamlGroupRule], -// [ZeroTrustAccessGroupNewParamsExcludeAccessServiceTokenRule], -// [ZeroTrustAccessGroupNewParamsExcludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupNewParamsExcludeAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupNewParamsExcludeAccessCountryRule], -// [ZeroTrustAccessGroupNewParamsExcludeAccessAuthenticationMethodRule], -// [ZeroTrustAccessGroupNewParamsExcludeAccessDevicePostureRule]. -type ZeroTrustAccessGroupNewParamsExclude interface { - implementsZeroTrustAccessGroupNewParamsExclude() -} - -// Matches a specific email. -type ZeroTrustAccessGroupNewParamsExcludeAccessEmailRule struct { - Email param.Field[ZeroTrustAccessGroupNewParamsExcludeAccessEmailRuleEmail] `json:"email,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessEmailRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type ZeroTrustAccessGroupNewParamsExcludeAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupNewParamsExcludeAccessEmailListRule struct { - EmailList param.Field[ZeroTrustAccessGroupNewParamsExcludeAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessEmailListRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type ZeroTrustAccessGroupNewParamsExcludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type ZeroTrustAccessGroupNewParamsExcludeAccessDomainRule struct { - EmailDomain param.Field[ZeroTrustAccessGroupNewParamsExcludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessDomainRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type ZeroTrustAccessGroupNewParamsExcludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type ZeroTrustAccessGroupNewParamsExcludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessEveryoneRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupNewParamsExcludeAccessIPRule struct { - IP param.Field[ZeroTrustAccessGroupNewParamsExcludeAccessIPRuleIP] `json:"ip,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessIPRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type ZeroTrustAccessGroupNewParamsExcludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupNewParamsExcludeAccessIPListRule struct { - IPList param.Field[ZeroTrustAccessGroupNewParamsExcludeAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessIPListRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type ZeroTrustAccessGroupNewParamsExcludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupNewParamsExcludeAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessCertificateRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupNewParamsExcludeAccessAccessGroupRule struct { - Group param.Field[ZeroTrustAccessGroupNewParamsExcludeAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessAccessGroupRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type ZeroTrustAccessGroupNewParamsExcludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupNewParamsExcludeAccessAzureGroupRule struct { - AzureAd param.Field[ZeroTrustAccessGroupNewParamsExcludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessAzureGroupRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type ZeroTrustAccessGroupNewParamsExcludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupNewParamsExcludeAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[ZeroTrustAccessGroupNewParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type ZeroTrustAccessGroupNewParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupNewParamsExcludeAccessGsuiteGroupRule struct { - Gsuite param.Field[ZeroTrustAccessGroupNewParamsExcludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type ZeroTrustAccessGroupNewParamsExcludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupNewParamsExcludeAccessOktaGroupRule struct { - Okta param.Field[ZeroTrustAccessGroupNewParamsExcludeAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessOktaGroupRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type ZeroTrustAccessGroupNewParamsExcludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupNewParamsExcludeAccessSamlGroupRule struct { - Saml param.Field[ZeroTrustAccessGroupNewParamsExcludeAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessSamlGroupRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type ZeroTrustAccessGroupNewParamsExcludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupNewParamsExcludeAccessServiceTokenRule struct { - ServiceToken param.Field[ZeroTrustAccessGroupNewParamsExcludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessServiceTokenRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type ZeroTrustAccessGroupNewParamsExcludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupNewParamsExcludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupNewParamsExcludeAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[ZeroTrustAccessGroupNewParamsExcludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type ZeroTrustAccessGroupNewParamsExcludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type ZeroTrustAccessGroupNewParamsExcludeAccessCountryRule struct { - Geo param.Field[ZeroTrustAccessGroupNewParamsExcludeAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessCountryRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type ZeroTrustAccessGroupNewParamsExcludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type ZeroTrustAccessGroupNewParamsExcludeAccessAuthenticationMethodRule struct { - AuthMethod param.Field[ZeroTrustAccessGroupNewParamsExcludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type ZeroTrustAccessGroupNewParamsExcludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupNewParamsExcludeAccessDevicePostureRule struct { - DevicePosture param.Field[ZeroTrustAccessGroupNewParamsExcludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessDevicePostureRule) implementsZeroTrustAccessGroupNewParamsExclude() { -} - -type ZeroTrustAccessGroupNewParamsExcludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r ZeroTrustAccessGroupNewParamsExcludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by [ZeroTrustAccessGroupNewParamsRequireAccessEmailRule], -// [ZeroTrustAccessGroupNewParamsRequireAccessEmailListRule], -// [ZeroTrustAccessGroupNewParamsRequireAccessDomainRule], -// [ZeroTrustAccessGroupNewParamsRequireAccessEveryoneRule], -// [ZeroTrustAccessGroupNewParamsRequireAccessIPRule], -// [ZeroTrustAccessGroupNewParamsRequireAccessIPListRule], -// [ZeroTrustAccessGroupNewParamsRequireAccessCertificateRule], -// [ZeroTrustAccessGroupNewParamsRequireAccessAccessGroupRule], -// [ZeroTrustAccessGroupNewParamsRequireAccessAzureGroupRule], -// [ZeroTrustAccessGroupNewParamsRequireAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupNewParamsRequireAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupNewParamsRequireAccessOktaGroupRule], -// [ZeroTrustAccessGroupNewParamsRequireAccessSamlGroupRule], -// [ZeroTrustAccessGroupNewParamsRequireAccessServiceTokenRule], -// [ZeroTrustAccessGroupNewParamsRequireAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupNewParamsRequireAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupNewParamsRequireAccessCountryRule], -// [ZeroTrustAccessGroupNewParamsRequireAccessAuthenticationMethodRule], -// [ZeroTrustAccessGroupNewParamsRequireAccessDevicePostureRule]. -type ZeroTrustAccessGroupNewParamsRequire interface { - implementsZeroTrustAccessGroupNewParamsRequire() -} - -// Matches a specific email. -type ZeroTrustAccessGroupNewParamsRequireAccessEmailRule struct { - Email param.Field[ZeroTrustAccessGroupNewParamsRequireAccessEmailRuleEmail] `json:"email,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessEmailRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type ZeroTrustAccessGroupNewParamsRequireAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupNewParamsRequireAccessEmailListRule struct { - EmailList param.Field[ZeroTrustAccessGroupNewParamsRequireAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessEmailListRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type ZeroTrustAccessGroupNewParamsRequireAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type ZeroTrustAccessGroupNewParamsRequireAccessDomainRule struct { - EmailDomain param.Field[ZeroTrustAccessGroupNewParamsRequireAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessDomainRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type ZeroTrustAccessGroupNewParamsRequireAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type ZeroTrustAccessGroupNewParamsRequireAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessEveryoneRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupNewParamsRequireAccessIPRule struct { - IP param.Field[ZeroTrustAccessGroupNewParamsRequireAccessIPRuleIP] `json:"ip,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessIPRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type ZeroTrustAccessGroupNewParamsRequireAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupNewParamsRequireAccessIPListRule struct { - IPList param.Field[ZeroTrustAccessGroupNewParamsRequireAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessIPListRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type ZeroTrustAccessGroupNewParamsRequireAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupNewParamsRequireAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessCertificateRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupNewParamsRequireAccessAccessGroupRule struct { - Group param.Field[ZeroTrustAccessGroupNewParamsRequireAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessAccessGroupRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type ZeroTrustAccessGroupNewParamsRequireAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupNewParamsRequireAccessAzureGroupRule struct { - AzureAd param.Field[ZeroTrustAccessGroupNewParamsRequireAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessAzureGroupRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type ZeroTrustAccessGroupNewParamsRequireAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupNewParamsRequireAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[ZeroTrustAccessGroupNewParamsRequireAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type ZeroTrustAccessGroupNewParamsRequireAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupNewParamsRequireAccessGsuiteGroupRule struct { - Gsuite param.Field[ZeroTrustAccessGroupNewParamsRequireAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessGsuiteGroupRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type ZeroTrustAccessGroupNewParamsRequireAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupNewParamsRequireAccessOktaGroupRule struct { - Okta param.Field[ZeroTrustAccessGroupNewParamsRequireAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessOktaGroupRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type ZeroTrustAccessGroupNewParamsRequireAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupNewParamsRequireAccessSamlGroupRule struct { - Saml param.Field[ZeroTrustAccessGroupNewParamsRequireAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessSamlGroupRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type ZeroTrustAccessGroupNewParamsRequireAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupNewParamsRequireAccessServiceTokenRule struct { - ServiceToken param.Field[ZeroTrustAccessGroupNewParamsRequireAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessServiceTokenRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type ZeroTrustAccessGroupNewParamsRequireAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupNewParamsRequireAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupNewParamsRequireAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[ZeroTrustAccessGroupNewParamsRequireAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessExternalEvaluationRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type ZeroTrustAccessGroupNewParamsRequireAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type ZeroTrustAccessGroupNewParamsRequireAccessCountryRule struct { - Geo param.Field[ZeroTrustAccessGroupNewParamsRequireAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessCountryRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type ZeroTrustAccessGroupNewParamsRequireAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type ZeroTrustAccessGroupNewParamsRequireAccessAuthenticationMethodRule struct { - AuthMethod param.Field[ZeroTrustAccessGroupNewParamsRequireAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type ZeroTrustAccessGroupNewParamsRequireAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupNewParamsRequireAccessDevicePostureRule struct { - DevicePosture param.Field[ZeroTrustAccessGroupNewParamsRequireAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessDevicePostureRule) implementsZeroTrustAccessGroupNewParamsRequire() { -} - -type ZeroTrustAccessGroupNewParamsRequireAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r ZeroTrustAccessGroupNewParamsRequireAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustAccessGroupNewResponseEnvelope struct { - Errors []ZeroTrustAccessGroupNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessGroupNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessGroupNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessGroupNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessGroupNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustAccessGroupNewResponseEnvelope] -type zeroTrustAccessGroupNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessGroupNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessGroupNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustAccessGroupNewResponseEnvelopeErrors] -type zeroTrustAccessGroupNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessGroupNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessGroupNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessGroupNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustAccessGroupNewResponseEnvelopeMessages] -type zeroTrustAccessGroupNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessGroupNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessGroupNewResponseEnvelopeSuccessTrue ZeroTrustAccessGroupNewResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessGroupUpdateParams struct { - // Rules evaluated with an OR logical operator. A user needs to meet only one of - // the Include rules. - Include param.Field[[]ZeroTrustAccessGroupUpdateParamsInclude] `json:"include,required"` - // The name of the Access group. - Name param.Field[string] `json:"name,required"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // Rules evaluated with a NOT logical operator. To match a policy, a user cannot - // meet any of the Exclude rules. - Exclude param.Field[[]ZeroTrustAccessGroupUpdateParamsExclude] `json:"exclude"` - // Whether this is the default group - IsDefault param.Field[bool] `json:"is_default"` - // Rules evaluated with an AND logical operator. To match a policy, a user must - // meet all of the Require rules. - Require param.Field[[]ZeroTrustAccessGroupUpdateParamsRequire] `json:"require"` -} - -func (r ZeroTrustAccessGroupUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by [ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailRule], -// [ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailListRule], -// [ZeroTrustAccessGroupUpdateParamsIncludeAccessDomainRule], -// [ZeroTrustAccessGroupUpdateParamsIncludeAccessEveryoneRule], -// [ZeroTrustAccessGroupUpdateParamsIncludeAccessIPRule], -// [ZeroTrustAccessGroupUpdateParamsIncludeAccessIPListRule], -// [ZeroTrustAccessGroupUpdateParamsIncludeAccessCertificateRule], -// [ZeroTrustAccessGroupUpdateParamsIncludeAccessAccessGroupRule], -// [ZeroTrustAccessGroupUpdateParamsIncludeAccessAzureGroupRule], -// [ZeroTrustAccessGroupUpdateParamsIncludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupUpdateParamsIncludeAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupUpdateParamsIncludeAccessOktaGroupRule], -// [ZeroTrustAccessGroupUpdateParamsIncludeAccessSamlGroupRule], -// [ZeroTrustAccessGroupUpdateParamsIncludeAccessServiceTokenRule], -// [ZeroTrustAccessGroupUpdateParamsIncludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupUpdateParamsIncludeAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupUpdateParamsIncludeAccessCountryRule], -// [ZeroTrustAccessGroupUpdateParamsIncludeAccessAuthenticationMethodRule], -// [ZeroTrustAccessGroupUpdateParamsIncludeAccessDevicePostureRule]. -type ZeroTrustAccessGroupUpdateParamsInclude interface { - implementsZeroTrustAccessGroupUpdateParamsInclude() -} - -// Matches a specific email. -type ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailRule struct { - Email param.Field[ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailRuleEmail] `json:"email,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailListRule struct { - EmailList param.Field[ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailListRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type ZeroTrustAccessGroupUpdateParamsIncludeAccessDomainRule struct { - EmailDomain param.Field[ZeroTrustAccessGroupUpdateParamsIncludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessDomainRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type ZeroTrustAccessGroupUpdateParamsIncludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type ZeroTrustAccessGroupUpdateParamsIncludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessEveryoneRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupUpdateParamsIncludeAccessIPRule struct { - IP param.Field[ZeroTrustAccessGroupUpdateParamsIncludeAccessIPRuleIP] `json:"ip,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessIPRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type ZeroTrustAccessGroupUpdateParamsIncludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupUpdateParamsIncludeAccessIPListRule struct { - IPList param.Field[ZeroTrustAccessGroupUpdateParamsIncludeAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessIPListRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type ZeroTrustAccessGroupUpdateParamsIncludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupUpdateParamsIncludeAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessCertificateRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupUpdateParamsIncludeAccessAccessGroupRule struct { - Group param.Field[ZeroTrustAccessGroupUpdateParamsIncludeAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessAccessGroupRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type ZeroTrustAccessGroupUpdateParamsIncludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupUpdateParamsIncludeAccessAzureGroupRule struct { - AzureAd param.Field[ZeroTrustAccessGroupUpdateParamsIncludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessAzureGroupRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type ZeroTrustAccessGroupUpdateParamsIncludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupUpdateParamsIncludeAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[ZeroTrustAccessGroupUpdateParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type ZeroTrustAccessGroupUpdateParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupUpdateParamsIncludeAccessGsuiteGroupRule struct { - Gsuite param.Field[ZeroTrustAccessGroupUpdateParamsIncludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type ZeroTrustAccessGroupUpdateParamsIncludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupUpdateParamsIncludeAccessOktaGroupRule struct { - Okta param.Field[ZeroTrustAccessGroupUpdateParamsIncludeAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessOktaGroupRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type ZeroTrustAccessGroupUpdateParamsIncludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupUpdateParamsIncludeAccessSamlGroupRule struct { - Saml param.Field[ZeroTrustAccessGroupUpdateParamsIncludeAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessSamlGroupRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type ZeroTrustAccessGroupUpdateParamsIncludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupUpdateParamsIncludeAccessServiceTokenRule struct { - ServiceToken param.Field[ZeroTrustAccessGroupUpdateParamsIncludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessServiceTokenRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type ZeroTrustAccessGroupUpdateParamsIncludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupUpdateParamsIncludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupUpdateParamsIncludeAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[ZeroTrustAccessGroupUpdateParamsIncludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type ZeroTrustAccessGroupUpdateParamsIncludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type ZeroTrustAccessGroupUpdateParamsIncludeAccessCountryRule struct { - Geo param.Field[ZeroTrustAccessGroupUpdateParamsIncludeAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessCountryRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type ZeroTrustAccessGroupUpdateParamsIncludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type ZeroTrustAccessGroupUpdateParamsIncludeAccessAuthenticationMethodRule struct { - AuthMethod param.Field[ZeroTrustAccessGroupUpdateParamsIncludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type ZeroTrustAccessGroupUpdateParamsIncludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupUpdateParamsIncludeAccessDevicePostureRule struct { - DevicePosture param.Field[ZeroTrustAccessGroupUpdateParamsIncludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessDevicePostureRule) implementsZeroTrustAccessGroupUpdateParamsInclude() { -} - -type ZeroTrustAccessGroupUpdateParamsIncludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsIncludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by [ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailRule], -// [ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailListRule], -// [ZeroTrustAccessGroupUpdateParamsExcludeAccessDomainRule], -// [ZeroTrustAccessGroupUpdateParamsExcludeAccessEveryoneRule], -// [ZeroTrustAccessGroupUpdateParamsExcludeAccessIPRule], -// [ZeroTrustAccessGroupUpdateParamsExcludeAccessIPListRule], -// [ZeroTrustAccessGroupUpdateParamsExcludeAccessCertificateRule], -// [ZeroTrustAccessGroupUpdateParamsExcludeAccessAccessGroupRule], -// [ZeroTrustAccessGroupUpdateParamsExcludeAccessAzureGroupRule], -// [ZeroTrustAccessGroupUpdateParamsExcludeAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupUpdateParamsExcludeAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupUpdateParamsExcludeAccessOktaGroupRule], -// [ZeroTrustAccessGroupUpdateParamsExcludeAccessSamlGroupRule], -// [ZeroTrustAccessGroupUpdateParamsExcludeAccessServiceTokenRule], -// [ZeroTrustAccessGroupUpdateParamsExcludeAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupUpdateParamsExcludeAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupUpdateParamsExcludeAccessCountryRule], -// [ZeroTrustAccessGroupUpdateParamsExcludeAccessAuthenticationMethodRule], -// [ZeroTrustAccessGroupUpdateParamsExcludeAccessDevicePostureRule]. -type ZeroTrustAccessGroupUpdateParamsExclude interface { - implementsZeroTrustAccessGroupUpdateParamsExclude() -} - -// Matches a specific email. -type ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailRule struct { - Email param.Field[ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailRuleEmail] `json:"email,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailListRule struct { - EmailList param.Field[ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailListRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type ZeroTrustAccessGroupUpdateParamsExcludeAccessDomainRule struct { - EmailDomain param.Field[ZeroTrustAccessGroupUpdateParamsExcludeAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessDomainRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type ZeroTrustAccessGroupUpdateParamsExcludeAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type ZeroTrustAccessGroupUpdateParamsExcludeAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessEveryoneRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupUpdateParamsExcludeAccessIPRule struct { - IP param.Field[ZeroTrustAccessGroupUpdateParamsExcludeAccessIPRuleIP] `json:"ip,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessIPRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type ZeroTrustAccessGroupUpdateParamsExcludeAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupUpdateParamsExcludeAccessIPListRule struct { - IPList param.Field[ZeroTrustAccessGroupUpdateParamsExcludeAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessIPListRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type ZeroTrustAccessGroupUpdateParamsExcludeAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupUpdateParamsExcludeAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessCertificateRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupUpdateParamsExcludeAccessAccessGroupRule struct { - Group param.Field[ZeroTrustAccessGroupUpdateParamsExcludeAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessAccessGroupRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type ZeroTrustAccessGroupUpdateParamsExcludeAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupUpdateParamsExcludeAccessAzureGroupRule struct { - AzureAd param.Field[ZeroTrustAccessGroupUpdateParamsExcludeAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessAzureGroupRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type ZeroTrustAccessGroupUpdateParamsExcludeAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupUpdateParamsExcludeAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[ZeroTrustAccessGroupUpdateParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type ZeroTrustAccessGroupUpdateParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupUpdateParamsExcludeAccessGsuiteGroupRule struct { - Gsuite param.Field[ZeroTrustAccessGroupUpdateParamsExcludeAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessGsuiteGroupRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type ZeroTrustAccessGroupUpdateParamsExcludeAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupUpdateParamsExcludeAccessOktaGroupRule struct { - Okta param.Field[ZeroTrustAccessGroupUpdateParamsExcludeAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessOktaGroupRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type ZeroTrustAccessGroupUpdateParamsExcludeAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupUpdateParamsExcludeAccessSamlGroupRule struct { - Saml param.Field[ZeroTrustAccessGroupUpdateParamsExcludeAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessSamlGroupRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type ZeroTrustAccessGroupUpdateParamsExcludeAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupUpdateParamsExcludeAccessServiceTokenRule struct { - ServiceToken param.Field[ZeroTrustAccessGroupUpdateParamsExcludeAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessServiceTokenRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type ZeroTrustAccessGroupUpdateParamsExcludeAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupUpdateParamsExcludeAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupUpdateParamsExcludeAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[ZeroTrustAccessGroupUpdateParamsExcludeAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessExternalEvaluationRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type ZeroTrustAccessGroupUpdateParamsExcludeAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type ZeroTrustAccessGroupUpdateParamsExcludeAccessCountryRule struct { - Geo param.Field[ZeroTrustAccessGroupUpdateParamsExcludeAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessCountryRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type ZeroTrustAccessGroupUpdateParamsExcludeAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type ZeroTrustAccessGroupUpdateParamsExcludeAccessAuthenticationMethodRule struct { - AuthMethod param.Field[ZeroTrustAccessGroupUpdateParamsExcludeAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type ZeroTrustAccessGroupUpdateParamsExcludeAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupUpdateParamsExcludeAccessDevicePostureRule struct { - DevicePosture param.Field[ZeroTrustAccessGroupUpdateParamsExcludeAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessDevicePostureRule) implementsZeroTrustAccessGroupUpdateParamsExclude() { -} - -type ZeroTrustAccessGroupUpdateParamsExcludeAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsExcludeAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific email. -// -// Satisfied by [ZeroTrustAccessGroupUpdateParamsRequireAccessEmailRule], -// [ZeroTrustAccessGroupUpdateParamsRequireAccessEmailListRule], -// [ZeroTrustAccessGroupUpdateParamsRequireAccessDomainRule], -// [ZeroTrustAccessGroupUpdateParamsRequireAccessEveryoneRule], -// [ZeroTrustAccessGroupUpdateParamsRequireAccessIPRule], -// [ZeroTrustAccessGroupUpdateParamsRequireAccessIPListRule], -// [ZeroTrustAccessGroupUpdateParamsRequireAccessCertificateRule], -// [ZeroTrustAccessGroupUpdateParamsRequireAccessAccessGroupRule], -// [ZeroTrustAccessGroupUpdateParamsRequireAccessAzureGroupRule], -// [ZeroTrustAccessGroupUpdateParamsRequireAccessGitHubOrganizationRule], -// [ZeroTrustAccessGroupUpdateParamsRequireAccessGsuiteGroupRule], -// [ZeroTrustAccessGroupUpdateParamsRequireAccessOktaGroupRule], -// [ZeroTrustAccessGroupUpdateParamsRequireAccessSamlGroupRule], -// [ZeroTrustAccessGroupUpdateParamsRequireAccessServiceTokenRule], -// [ZeroTrustAccessGroupUpdateParamsRequireAccessAnyValidServiceTokenRule], -// [ZeroTrustAccessGroupUpdateParamsRequireAccessExternalEvaluationRule], -// [ZeroTrustAccessGroupUpdateParamsRequireAccessCountryRule], -// [ZeroTrustAccessGroupUpdateParamsRequireAccessAuthenticationMethodRule], -// [ZeroTrustAccessGroupUpdateParamsRequireAccessDevicePostureRule]. -type ZeroTrustAccessGroupUpdateParamsRequire interface { - implementsZeroTrustAccessGroupUpdateParamsRequire() -} - -// Matches a specific email. -type ZeroTrustAccessGroupUpdateParamsRequireAccessEmailRule struct { - Email param.Field[ZeroTrustAccessGroupUpdateParamsRequireAccessEmailRuleEmail] `json:"email,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessEmailRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessEmailRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type ZeroTrustAccessGroupUpdateParamsRequireAccessEmailRuleEmail struct { - // The email of the user. - Email param.Field[string] `json:"email,required" format:"email"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessEmailRuleEmail) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an email address from a list. -type ZeroTrustAccessGroupUpdateParamsRequireAccessEmailListRule struct { - EmailList param.Field[ZeroTrustAccessGroupUpdateParamsRequireAccessEmailListRuleEmailList] `json:"email_list,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessEmailListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessEmailListRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type ZeroTrustAccessGroupUpdateParamsRequireAccessEmailListRuleEmailList struct { - // The ID of a previously created email list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessEmailListRuleEmailList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Match an entire email domain. -type ZeroTrustAccessGroupUpdateParamsRequireAccessDomainRule struct { - EmailDomain param.Field[ZeroTrustAccessGroupUpdateParamsRequireAccessDomainRuleEmailDomain] `json:"email_domain,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessDomainRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessDomainRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type ZeroTrustAccessGroupUpdateParamsRequireAccessDomainRuleEmailDomain struct { - // The email domain to match. - Domain param.Field[string] `json:"domain,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessDomainRuleEmailDomain) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches everyone. -type ZeroTrustAccessGroupUpdateParamsRequireAccessEveryoneRule struct { - // An empty object which matches on all users. - Everyone param.Field[interface{}] `json:"everyone,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessEveryoneRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessEveryoneRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -// Matches an IP address block. -type ZeroTrustAccessGroupUpdateParamsRequireAccessIPRule struct { - IP param.Field[ZeroTrustAccessGroupUpdateParamsRequireAccessIPRuleIP] `json:"ip,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessIPRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessIPRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type ZeroTrustAccessGroupUpdateParamsRequireAccessIPRuleIP struct { - // An IPv4 or IPv6 CIDR block. - IP param.Field[string] `json:"ip,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessIPRuleIP) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an IP address from a list. -type ZeroTrustAccessGroupUpdateParamsRequireAccessIPListRule struct { - IPList param.Field[ZeroTrustAccessGroupUpdateParamsRequireAccessIPListRuleIPList] `json:"ip_list,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessIPListRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessIPListRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type ZeroTrustAccessGroupUpdateParamsRequireAccessIPListRuleIPList struct { - // The ID of a previously created IP list. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessIPListRuleIPList) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid client certificate. -type ZeroTrustAccessGroupUpdateParamsRequireAccessCertificateRule struct { - Certificate param.Field[interface{}] `json:"certificate,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessCertificateRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessCertificateRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -// Matches an Access group. -type ZeroTrustAccessGroupUpdateParamsRequireAccessAccessGroupRule struct { - Group param.Field[ZeroTrustAccessGroupUpdateParamsRequireAccessAccessGroupRuleGroup] `json:"group,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessAccessGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessAccessGroupRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type ZeroTrustAccessGroupUpdateParamsRequireAccessAccessGroupRuleGroup struct { - // The ID of a previously created Access group. - ID param.Field[string] `json:"id,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessAccessGroupRuleGroup) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Azure group. Requires an Azure identity provider. -type ZeroTrustAccessGroupUpdateParamsRequireAccessAzureGroupRule struct { - AzureAd param.Field[ZeroTrustAccessGroupUpdateParamsRequireAccessAzureGroupRuleAzureAd] `json:"azureAD,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessAzureGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessAzureGroupRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type ZeroTrustAccessGroupUpdateParamsRequireAccessAzureGroupRuleAzureAd struct { - // The ID of an Azure group. - ID param.Field[string] `json:"id,required"` - // The ID of your Azure identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessAzureGroupRuleAzureAd) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a Github organization. Requires a Github identity provider. -type ZeroTrustAccessGroupUpdateParamsRequireAccessGitHubOrganizationRule struct { - GitHubOrganization param.Field[ZeroTrustAccessGroupUpdateParamsRequireAccessGitHubOrganizationRuleGitHubOrganization] `json:"github-organization,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessGitHubOrganizationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessGitHubOrganizationRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type ZeroTrustAccessGroupUpdateParamsRequireAccessGitHubOrganizationRuleGitHubOrganization struct { - // The ID of your Github identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The name of the organization. - Name param.Field[string] `json:"name,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessGitHubOrganizationRuleGitHubOrganization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a group in Google Workspace. Requires a Google Workspace identity -// provider. -type ZeroTrustAccessGroupUpdateParamsRequireAccessGsuiteGroupRule struct { - Gsuite param.Field[ZeroTrustAccessGroupUpdateParamsRequireAccessGsuiteGroupRuleGsuite] `json:"gsuite,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessGsuiteGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessGsuiteGroupRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type ZeroTrustAccessGroupUpdateParamsRequireAccessGsuiteGroupRuleGsuite struct { - // The ID of your Google Workspace identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Google Workspace group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessGsuiteGroupRuleGsuite) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches an Okta group. Requires an Okta identity provider. -type ZeroTrustAccessGroupUpdateParamsRequireAccessOktaGroupRule struct { - Okta param.Field[ZeroTrustAccessGroupUpdateParamsRequireAccessOktaGroupRuleOkta] `json:"okta,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessOktaGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessOktaGroupRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type ZeroTrustAccessGroupUpdateParamsRequireAccessOktaGroupRuleOkta struct { - // The ID of your Okta identity provider. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The email of the Okta group. - Email param.Field[string] `json:"email,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessOktaGroupRuleOkta) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a SAML group. Requires a SAML identity provider. -type ZeroTrustAccessGroupUpdateParamsRequireAccessSamlGroupRule struct { - Saml param.Field[ZeroTrustAccessGroupUpdateParamsRequireAccessSamlGroupRuleSaml] `json:"saml,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessSamlGroupRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessSamlGroupRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type ZeroTrustAccessGroupUpdateParamsRequireAccessSamlGroupRuleSaml struct { - // The name of the SAML attribute. - AttributeName param.Field[string] `json:"attribute_name,required"` - // The SAML attribute value to look for. - AttributeValue param.Field[string] `json:"attribute_value,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessSamlGroupRuleSaml) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific Access Service Token -type ZeroTrustAccessGroupUpdateParamsRequireAccessServiceTokenRule struct { - ServiceToken param.Field[ZeroTrustAccessGroupUpdateParamsRequireAccessServiceTokenRuleServiceToken] `json:"service_token,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessServiceTokenRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type ZeroTrustAccessGroupUpdateParamsRequireAccessServiceTokenRuleServiceToken struct { - // The ID of a Service Token. - TokenID param.Field[string] `json:"token_id,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessServiceTokenRuleServiceToken) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches any valid Access Service Token -type ZeroTrustAccessGroupUpdateParamsRequireAccessAnyValidServiceTokenRule struct { - // An empty object which matches on all service tokens. - AnyValidServiceToken param.Field[interface{}] `json:"any_valid_service_token,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessAnyValidServiceTokenRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessAnyValidServiceTokenRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -// Create Allow or Block policies which evaluate the user based on custom criteria. -type ZeroTrustAccessGroupUpdateParamsRequireAccessExternalEvaluationRule struct { - ExternalEvaluation param.Field[ZeroTrustAccessGroupUpdateParamsRequireAccessExternalEvaluationRuleExternalEvaluation] `json:"external_evaluation,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessExternalEvaluationRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessExternalEvaluationRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type ZeroTrustAccessGroupUpdateParamsRequireAccessExternalEvaluationRuleExternalEvaluation struct { - // The API endpoint containing your business logic. - EvaluateURL param.Field[string] `json:"evaluate_url,required"` - // The API endpoint containing the key that Access uses to verify that the response - // came from your API. - KeysURL param.Field[string] `json:"keys_url,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessExternalEvaluationRuleExternalEvaluation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Matches a specific country -type ZeroTrustAccessGroupUpdateParamsRequireAccessCountryRule struct { - Geo param.Field[ZeroTrustAccessGroupUpdateParamsRequireAccessCountryRuleGeo] `json:"geo,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessCountryRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessCountryRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type ZeroTrustAccessGroupUpdateParamsRequireAccessCountryRuleGeo struct { - // The country code that should be matched. - CountryCode param.Field[string] `json:"country_code,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessCountryRuleGeo) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforce different MFA options -type ZeroTrustAccessGroupUpdateParamsRequireAccessAuthenticationMethodRule struct { - AuthMethod param.Field[ZeroTrustAccessGroupUpdateParamsRequireAccessAuthenticationMethodRuleAuthMethod] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessAuthenticationMethodRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessAuthenticationMethodRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type ZeroTrustAccessGroupUpdateParamsRequireAccessAuthenticationMethodRuleAuthMethod struct { - // The type of authentication method https://datatracker.ietf.org/doc/html/rfc8176. - AuthMethod param.Field[string] `json:"auth_method,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessAuthenticationMethodRuleAuthMethod) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enforces a device posture rule has run successfully -type ZeroTrustAccessGroupUpdateParamsRequireAccessDevicePostureRule struct { - DevicePosture param.Field[ZeroTrustAccessGroupUpdateParamsRequireAccessDevicePostureRuleDevicePosture] `json:"device_posture,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessDevicePostureRule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessDevicePostureRule) implementsZeroTrustAccessGroupUpdateParamsRequire() { -} - -type ZeroTrustAccessGroupUpdateParamsRequireAccessDevicePostureRuleDevicePosture struct { - // The ID of a device posture integration. - IntegrationUid param.Field[string] `json:"integration_uid,required"` -} - -func (r ZeroTrustAccessGroupUpdateParamsRequireAccessDevicePostureRuleDevicePosture) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustAccessGroupUpdateResponseEnvelope struct { - Errors []ZeroTrustAccessGroupUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessGroupUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessGroupUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessGroupUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessGroupUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustAccessGroupUpdateResponseEnvelope] -type zeroTrustAccessGroupUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessGroupUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessGroupUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustAccessGroupUpdateResponseEnvelopeErrors] -type zeroTrustAccessGroupUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessGroupUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessGroupUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessGroupUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupUpdateResponseEnvelopeMessages] -type zeroTrustAccessGroupUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessGroupUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessGroupUpdateResponseEnvelopeSuccessTrue ZeroTrustAccessGroupUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessGroupListParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustAccessGroupListResponseEnvelope struct { - Errors []ZeroTrustAccessGroupListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessGroupListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustAccessGroupListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustAccessGroupListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustAccessGroupListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustAccessGroupListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustAccessGroupListResponseEnvelope] -type zeroTrustAccessGroupListResponseEnvelopeJSON 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 *ZeroTrustAccessGroupListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessGroupListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessGroupListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustAccessGroupListResponseEnvelopeErrors] -type zeroTrustAccessGroupListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessGroupListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessGroupListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustAccessGroupListResponseEnvelopeMessages] -type zeroTrustAccessGroupListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessGroupListResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessGroupListResponseEnvelopeSuccessTrue ZeroTrustAccessGroupListResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessGroupListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustAccessGroupListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustAccessGroupListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupListResponseEnvelopeResultInfo] -type zeroTrustAccessGroupListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessGroupDeleteParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustAccessGroupDeleteResponseEnvelope struct { - Errors []ZeroTrustAccessGroupDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessGroupDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessGroupDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessGroupDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessGroupDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessGroupDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustAccessGroupDeleteResponseEnvelope] -type zeroTrustAccessGroupDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessGroupDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessGroupDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessGroupDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustAccessGroupDeleteResponseEnvelopeErrors] -type zeroTrustAccessGroupDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessGroupDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessGroupDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessGroupDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustAccessGroupDeleteResponseEnvelopeMessages] -type zeroTrustAccessGroupDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessGroupDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessGroupDeleteResponseEnvelopeSuccessTrue ZeroTrustAccessGroupDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessGroupGetParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustAccessGroupGetResponseEnvelope struct { - Errors []ZeroTrustAccessGroupGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessGroupGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessGroupGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessGroupGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessGroupGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustAccessGroupGetResponseEnvelope] -type zeroTrustAccessGroupGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessGroupGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessGroupGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustAccessGroupGetResponseEnvelopeErrors] -type zeroTrustAccessGroupGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessGroupGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessGroupGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessGroupGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustAccessGroupGetResponseEnvelopeMessages] -type zeroTrustAccessGroupGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessGroupGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessGroupGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessGroupGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessGroupGetResponseEnvelopeSuccessTrue ZeroTrustAccessGroupGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustaccessgroup_test.go b/zerotrustaccessgroup_test.go deleted file mode 100644 index cead7aa4b7c..00000000000 --- a/zerotrustaccessgroup_test.go +++ /dev/null @@ -1,243 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustAccessGroupNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Groups.New(context.TODO(), cloudflare.ZeroTrustAccessGroupNewParams{ - Include: cloudflare.F([]cloudflare.ZeroTrustAccessGroupNewParamsInclude{cloudflare.ZeroTrustAccessGroupNewParamsIncludeAccessEmailRule(cloudflare.ZeroTrustAccessGroupNewParamsIncludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessGroupNewParamsIncludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessGroupNewParamsIncludeAccessEmailRule(cloudflare.ZeroTrustAccessGroupNewParamsIncludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessGroupNewParamsIncludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessGroupNewParamsIncludeAccessEmailRule(cloudflare.ZeroTrustAccessGroupNewParamsIncludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessGroupNewParamsIncludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - })}), - Name: cloudflare.F("Allow devs"), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - Exclude: cloudflare.F([]cloudflare.ZeroTrustAccessGroupNewParamsExclude{cloudflare.ZeroTrustAccessGroupNewParamsExcludeAccessEmailRule(cloudflare.ZeroTrustAccessGroupNewParamsExcludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessGroupNewParamsExcludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessGroupNewParamsExcludeAccessEmailRule(cloudflare.ZeroTrustAccessGroupNewParamsExcludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessGroupNewParamsExcludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessGroupNewParamsExcludeAccessEmailRule(cloudflare.ZeroTrustAccessGroupNewParamsExcludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessGroupNewParamsExcludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - })}), - IsDefault: cloudflare.F(true), - Require: cloudflare.F([]cloudflare.ZeroTrustAccessGroupNewParamsRequire{cloudflare.ZeroTrustAccessGroupNewParamsRequireAccessEmailRule(cloudflare.ZeroTrustAccessGroupNewParamsRequireAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessGroupNewParamsRequireAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessGroupNewParamsRequireAccessEmailRule(cloudflare.ZeroTrustAccessGroupNewParamsRequireAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessGroupNewParamsRequireAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessGroupNewParamsRequireAccessEmailRule(cloudflare.ZeroTrustAccessGroupNewParamsRequireAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessGroupNewParamsRequireAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - })}), - }) - 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 TestZeroTrustAccessGroupUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Groups.Update( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustAccessGroupUpdateParams{ - Include: cloudflare.F([]cloudflare.ZeroTrustAccessGroupUpdateParamsInclude{cloudflare.ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailRule(cloudflare.ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailRule(cloudflare.ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailRule(cloudflare.ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessGroupUpdateParamsIncludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - })}), - Name: cloudflare.F("Allow devs"), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - Exclude: cloudflare.F([]cloudflare.ZeroTrustAccessGroupUpdateParamsExclude{cloudflare.ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailRule(cloudflare.ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailRule(cloudflare.ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailRule(cloudflare.ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessGroupUpdateParamsExcludeAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - })}), - IsDefault: cloudflare.F(true), - Require: cloudflare.F([]cloudflare.ZeroTrustAccessGroupUpdateParamsRequire{cloudflare.ZeroTrustAccessGroupUpdateParamsRequireAccessEmailRule(cloudflare.ZeroTrustAccessGroupUpdateParamsRequireAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessGroupUpdateParamsRequireAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessGroupUpdateParamsRequireAccessEmailRule(cloudflare.ZeroTrustAccessGroupUpdateParamsRequireAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessGroupUpdateParamsRequireAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - }), cloudflare.ZeroTrustAccessGroupUpdateParamsRequireAccessEmailRule(cloudflare.ZeroTrustAccessGroupUpdateParamsRequireAccessEmailRule{ - Email: cloudflare.F(cloudflare.ZeroTrustAccessGroupUpdateParamsRequireAccessEmailRuleEmail{ - Email: cloudflare.F("test@example.com"), - }), - })}), - }, - ) - 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 TestZeroTrustAccessGroupListWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Groups.List(context.TODO(), cloudflare.ZeroTrustAccessGroupListParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }) - 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 TestZeroTrustAccessGroupDeleteWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Groups.Delete( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustAccessGroupDeleteParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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 TestZeroTrustAccessGroupGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Groups.Get( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustAccessGroupGetParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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/zerotrustaccesskey.go b/zerotrustaccesskey.go deleted file mode 100644 index 28ed4284f96..00000000000 --- a/zerotrustaccesskey.go +++ /dev/null @@ -1,405 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustAccessKeyService 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 [NewZeroTrustAccessKeyService] method -// instead. -type ZeroTrustAccessKeyService struct { - Options []option.RequestOption -} - -// NewZeroTrustAccessKeyService 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 NewZeroTrustAccessKeyService(opts ...option.RequestOption) (r *ZeroTrustAccessKeyService) { - r = &ZeroTrustAccessKeyService{} - r.Options = opts - return -} - -// Updates the Access key rotation settings for an account. -func (r *ZeroTrustAccessKeyService) Update(ctx context.Context, identifier string, body ZeroTrustAccessKeyUpdateParams, opts ...option.RequestOption) (res *ZeroTrustAccessKeyUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessKeyUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/keys", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets the Access key rotation settings for an account. -func (r *ZeroTrustAccessKeyService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *ZeroTrustAccessKeyListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessKeyListResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/keys", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Perfoms a key rotation for an account. -func (r *ZeroTrustAccessKeyService) Rotate(ctx context.Context, identifier string, opts ...option.RequestOption) (res *ZeroTrustAccessKeyRotateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessKeyRotateResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/keys/rotate", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [ZeroTrustAccessKeyUpdateResponseUnknown] or -// [shared.UnionString]. -type ZeroTrustAccessKeyUpdateResponse interface { - ImplementsZeroTrustAccessKeyUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessKeyUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [ZeroTrustAccessKeyListResponseUnknown] or -// [shared.UnionString]. -type ZeroTrustAccessKeyListResponse interface { - ImplementsZeroTrustAccessKeyListResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessKeyListResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -// Union satisfied by [ZeroTrustAccessKeyRotateResponseUnknown] or -// [shared.UnionString]. -type ZeroTrustAccessKeyRotateResponse interface { - ImplementsZeroTrustAccessKeyRotateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustAccessKeyRotateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustAccessKeyUpdateParams struct { - // The number of days between key rotations. - KeyRotationIntervalDays param.Field[float64] `json:"key_rotation_interval_days,required"` -} - -func (r ZeroTrustAccessKeyUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustAccessKeyUpdateResponseEnvelope struct { - Errors []ZeroTrustAccessKeyUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessKeyUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessKeyUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessKeyUpdateResponseEnvelopeSuccess `json:"success,required"` - // The number of days until the next key rotation. - DaysUntilNextRotation float64 `json:"days_until_next_rotation"` - // The number of days between key rotations. - KeyRotationIntervalDays float64 `json:"key_rotation_interval_days"` - // The timestamp of the previous key rotation. - LastKeyRotationAt time.Time `json:"last_key_rotation_at" format:"date-time"` - JSON zeroTrustAccessKeyUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessKeyUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustAccessKeyUpdateResponseEnvelope] -type zeroTrustAccessKeyUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - DaysUntilNextRotation apijson.Field - KeyRotationIntervalDays apijson.Field - LastKeyRotationAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessKeyUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessKeyUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessKeyUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessKeyUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessKeyUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustAccessKeyUpdateResponseEnvelopeErrors] -type zeroTrustAccessKeyUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessKeyUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessKeyUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessKeyUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessKeyUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessKeyUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustAccessKeyUpdateResponseEnvelopeMessages] -type zeroTrustAccessKeyUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessKeyUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessKeyUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessKeyUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessKeyUpdateResponseEnvelopeSuccessTrue ZeroTrustAccessKeyUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessKeyListResponseEnvelope struct { - Errors []ZeroTrustAccessKeyListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessKeyListResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessKeyListResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessKeyListResponseEnvelopeSuccess `json:"success,required"` - // The number of days until the next key rotation. - DaysUntilNextRotation float64 `json:"days_until_next_rotation"` - // The number of days between key rotations. - KeyRotationIntervalDays float64 `json:"key_rotation_interval_days"` - // The timestamp of the previous key rotation. - LastKeyRotationAt time.Time `json:"last_key_rotation_at" format:"date-time"` - JSON zeroTrustAccessKeyListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessKeyListResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustAccessKeyListResponseEnvelope] -type zeroTrustAccessKeyListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - DaysUntilNextRotation apijson.Field - KeyRotationIntervalDays apijson.Field - LastKeyRotationAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessKeyListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessKeyListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessKeyListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessKeyListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessKeyListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustAccessKeyListResponseEnvelopeErrors] -type zeroTrustAccessKeyListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessKeyListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessKeyListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessKeyListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessKeyListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessKeyListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustAccessKeyListResponseEnvelopeMessages] -type zeroTrustAccessKeyListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessKeyListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessKeyListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessKeyListResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessKeyListResponseEnvelopeSuccessTrue ZeroTrustAccessKeyListResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessKeyRotateResponseEnvelope struct { - Errors []ZeroTrustAccessKeyRotateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessKeyRotateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessKeyRotateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessKeyRotateResponseEnvelopeSuccess `json:"success,required"` - // The number of days until the next key rotation. - DaysUntilNextRotation float64 `json:"days_until_next_rotation"` - // The number of days between key rotations. - KeyRotationIntervalDays float64 `json:"key_rotation_interval_days"` - // The timestamp of the previous key rotation. - LastKeyRotationAt time.Time `json:"last_key_rotation_at" format:"date-time"` - JSON zeroTrustAccessKeyRotateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessKeyRotateResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustAccessKeyRotateResponseEnvelope] -type zeroTrustAccessKeyRotateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - DaysUntilNextRotation apijson.Field - KeyRotationIntervalDays apijson.Field - LastKeyRotationAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessKeyRotateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessKeyRotateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessKeyRotateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessKeyRotateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessKeyRotateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustAccessKeyRotateResponseEnvelopeErrors] -type zeroTrustAccessKeyRotateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessKeyRotateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessKeyRotateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessKeyRotateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessKeyRotateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessKeyRotateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustAccessKeyRotateResponseEnvelopeMessages] -type zeroTrustAccessKeyRotateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessKeyRotateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessKeyRotateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessKeyRotateResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessKeyRotateResponseEnvelopeSuccessTrue ZeroTrustAccessKeyRotateResponseEnvelopeSuccess = true -) diff --git a/zerotrustaccesskey_test.go b/zerotrustaccesskey_test.go deleted file mode 100644 index d374a7bba5e..00000000000 --- a/zerotrustaccesskey_test.go +++ /dev/null @@ -1,92 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustAccessKeyUpdate(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Keys.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.ZeroTrustAccessKeyUpdateParams{ - KeyRotationIntervalDays: cloudflare.F(30.000000), - }, - ) - 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 TestZeroTrustAccessKeyList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Keys.List(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()) - } -} - -func TestZeroTrustAccessKeyRotate(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Keys.Rotate(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/zerotrustaccesslog.go b/zerotrustaccesslog.go deleted file mode 100644 index 1463978c534..00000000000 --- a/zerotrustaccesslog.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustAccessLogService 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 [NewZeroTrustAccessLogService] method -// instead. -type ZeroTrustAccessLogService struct { - Options []option.RequestOption - AccessRequests *ZeroTrustAccessLogAccessRequestService -} - -// NewZeroTrustAccessLogService 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 NewZeroTrustAccessLogService(opts ...option.RequestOption) (r *ZeroTrustAccessLogService) { - r = &ZeroTrustAccessLogService{} - r.Options = opts - r.AccessRequests = NewZeroTrustAccessLogAccessRequestService(opts...) - return -} diff --git a/zerotrustaccesslogaccessrequest.go b/zerotrustaccesslogaccessrequest.go deleted file mode 100644 index c58a486940c..00000000000 --- a/zerotrustaccesslogaccessrequest.go +++ /dev/null @@ -1,207 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustAccessLogAccessRequestService 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 -// [NewZeroTrustAccessLogAccessRequestService] method instead. -type ZeroTrustAccessLogAccessRequestService struct { - Options []option.RequestOption -} - -// NewZeroTrustAccessLogAccessRequestService 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 NewZeroTrustAccessLogAccessRequestService(opts ...option.RequestOption) (r *ZeroTrustAccessLogAccessRequestService) { - r = &ZeroTrustAccessLogAccessRequestService{} - r.Options = opts - return -} - -// Gets a list of Access authentication audit logs for an account. -func (r *ZeroTrustAccessLogAccessRequestService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *[]ZeroTrustAccessLogAccessRequestListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessLogAccessRequestListResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/logs/access_requests", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustAccessLogAccessRequestListResponse struct { - // The event that occurred, such as a login attempt. - Action string `json:"action"` - // The result of the authentication event. - Allowed bool `json:"allowed"` - // The URL of the Access application. - AppDomain string `json:"app_domain"` - // The unique identifier for the Access application. - AppUid interface{} `json:"app_uid"` - // The IdP used to authenticate. - Connection string `json:"connection"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The IP address of the authenticating user. - IPAddress string `json:"ip_address"` - // The unique identifier for the request to Cloudflare. - RayID string `json:"ray_id"` - // The email address of the authenticating user. - UserEmail string `json:"user_email" format:"email"` - JSON zeroTrustAccessLogAccessRequestListResponseJSON `json:"-"` -} - -// zeroTrustAccessLogAccessRequestListResponseJSON contains the JSON metadata for -// the struct [ZeroTrustAccessLogAccessRequestListResponse] -type zeroTrustAccessLogAccessRequestListResponseJSON struct { - Action apijson.Field - Allowed apijson.Field - AppDomain apijson.Field - AppUid apijson.Field - Connection apijson.Field - CreatedAt apijson.Field - IPAddress apijson.Field - RayID apijson.Field - UserEmail apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessLogAccessRequestListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessLogAccessRequestListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessLogAccessRequestListResponseEnvelope struct { - Errors []ZeroTrustAccessLogAccessRequestListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessLogAccessRequestListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustAccessLogAccessRequestListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustAccessLogAccessRequestListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustAccessLogAccessRequestListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustAccessLogAccessRequestListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessLogAccessRequestListResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustAccessLogAccessRequestListResponseEnvelope] -type zeroTrustAccessLogAccessRequestListResponseEnvelopeJSON 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 *ZeroTrustAccessLogAccessRequestListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessLogAccessRequestListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessLogAccessRequestListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessLogAccessRequestListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessLogAccessRequestListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessLogAccessRequestListResponseEnvelopeErrors] -type zeroTrustAccessLogAccessRequestListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessLogAccessRequestListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessLogAccessRequestListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessLogAccessRequestListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessLogAccessRequestListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessLogAccessRequestListResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessLogAccessRequestListResponseEnvelopeMessages] -type zeroTrustAccessLogAccessRequestListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessLogAccessRequestListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessLogAccessRequestListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessLogAccessRequestListResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessLogAccessRequestListResponseEnvelopeSuccessTrue ZeroTrustAccessLogAccessRequestListResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessLogAccessRequestListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustAccessLogAccessRequestListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustAccessLogAccessRequestListResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessLogAccessRequestListResponseEnvelopeResultInfo] -type zeroTrustAccessLogAccessRequestListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessLogAccessRequestListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessLogAccessRequestListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zerotrustaccesslogaccessrequest_test.go b/zerotrustaccesslogaccessrequest_test.go deleted file mode 100644 index a4e898318a8..00000000000 --- a/zerotrustaccesslogaccessrequest_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustAccessLogAccessRequestList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Logs.AccessRequests.List(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/zerotrustaccessservicetoken.go b/zerotrustaccessservicetoken.go deleted file mode 100644 index 608236ce5f1..00000000000 --- a/zerotrustaccessservicetoken.go +++ /dev/null @@ -1,962 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustAccessServiceTokenService 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 -// [NewZeroTrustAccessServiceTokenService] method instead. -type ZeroTrustAccessServiceTokenService struct { - Options []option.RequestOption -} - -// NewZeroTrustAccessServiceTokenService 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 NewZeroTrustAccessServiceTokenService(opts ...option.RequestOption) (r *ZeroTrustAccessServiceTokenService) { - r = &ZeroTrustAccessServiceTokenService{} - r.Options = opts - return -} - -// Generates a new service token. **Note:** This is the only time you can get the -// Client Secret. If you lose the Client Secret, you will have to rotate the Client -// Secret or create a new service token. -func (r *ZeroTrustAccessServiceTokenService) New(ctx context.Context, params ZeroTrustAccessServiceTokenNewParams, opts ...option.RequestOption) (res *ZeroTrustAccessServiceTokenNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessServiceTokenNewResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/access/service_tokens", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a configured service token. -func (r *ZeroTrustAccessServiceTokenService) Update(ctx context.Context, uuid string, params ZeroTrustAccessServiceTokenUpdateParams, opts ...option.RequestOption) (res *ZeroTrustAccessServiceTokenUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessServiceTokenUpdateResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/access/service_tokens/%s", accountOrZone, accountOrZoneID, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists all service tokens. -func (r *ZeroTrustAccessServiceTokenService) List(ctx context.Context, query ZeroTrustAccessServiceTokenListParams, opts ...option.RequestOption) (res *[]ZeroTrustAccessServiceTokenListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessServiceTokenListResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/access/service_tokens", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a service token. -func (r *ZeroTrustAccessServiceTokenService) Delete(ctx context.Context, uuid string, body ZeroTrustAccessServiceTokenDeleteParams, opts ...option.RequestOption) (res *ZeroTrustAccessServiceTokenDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessServiceTokenDeleteResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if body.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = body.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = body.ZoneID - } - path := fmt.Sprintf("%s/%s/access/service_tokens/%s", accountOrZone, accountOrZoneID, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Refreshes the expiration of a service token. -func (r *ZeroTrustAccessServiceTokenService) Refresh(ctx context.Context, identifier string, uuid string, opts ...option.RequestOption) (res *ZeroTrustAccessServiceTokenRefreshResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessServiceTokenRefreshResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/service_tokens/%s/refresh", identifier, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Generates a new Client Secret for a service token and revokes the old one. -func (r *ZeroTrustAccessServiceTokenService) Rotate(ctx context.Context, identifier string, uuid string, opts ...option.RequestOption) (res *ZeroTrustAccessServiceTokenRotateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessServiceTokenRotateResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/service_tokens/%s/rotate", identifier, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustAccessServiceTokenNewResponse struct { - // The ID of the service token. - ID interface{} `json:"id"` - // The Client ID for the service token. Access will check for this value in the - // `CF-Access-Client-ID` request header. - ClientID string `json:"client_id"` - // The Client Secret for the service token. Access will check for this value in the - // `CF-Access-Client-Secret` request header. - ClientSecret string `json:"client_secret"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The duration for how long the service token will be valid. Must be in the format - // `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. The - // default is 1 year in hours (8760h). - Duration string `json:"duration"` - // The name of the service token. - Name string `json:"name"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessServiceTokenNewResponseJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenNewResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessServiceTokenNewResponse] -type zeroTrustAccessServiceTokenNewResponseJSON struct { - ID apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - CreatedAt apijson.Field - Duration apijson.Field - Name apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenNewResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenUpdateResponse struct { - // The ID of the service token. - ID interface{} `json:"id"` - // The Client ID for the service token. Access will check for this value in the - // `CF-Access-Client-ID` request header. - ClientID string `json:"client_id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The duration for how long the service token will be valid. Must be in the format - // `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. The - // default is 1 year in hours (8760h). - Duration string `json:"duration"` - // The name of the service token. - Name string `json:"name"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessServiceTokenUpdateResponseJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenUpdateResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessServiceTokenUpdateResponse] -type zeroTrustAccessServiceTokenUpdateResponseJSON struct { - ID apijson.Field - ClientID apijson.Field - CreatedAt apijson.Field - Duration apijson.Field - Name apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenListResponse struct { - // The ID of the service token. - ID interface{} `json:"id"` - // The Client ID for the service token. Access will check for this value in the - // `CF-Access-Client-ID` request header. - ClientID string `json:"client_id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The duration for how long the service token will be valid. Must be in the format - // `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. The - // default is 1 year in hours (8760h). - Duration string `json:"duration"` - // The name of the service token. - Name string `json:"name"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessServiceTokenListResponseJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenListResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessServiceTokenListResponse] -type zeroTrustAccessServiceTokenListResponseJSON struct { - ID apijson.Field - ClientID apijson.Field - CreatedAt apijson.Field - Duration apijson.Field - Name apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenDeleteResponse struct { - // The ID of the service token. - ID interface{} `json:"id"` - // The Client ID for the service token. Access will check for this value in the - // `CF-Access-Client-ID` request header. - ClientID string `json:"client_id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The duration for how long the service token will be valid. Must be in the format - // `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. The - // default is 1 year in hours (8760h). - Duration string `json:"duration"` - // The name of the service token. - Name string `json:"name"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessServiceTokenDeleteResponseJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenDeleteResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessServiceTokenDeleteResponse] -type zeroTrustAccessServiceTokenDeleteResponseJSON struct { - ID apijson.Field - ClientID apijson.Field - CreatedAt apijson.Field - Duration apijson.Field - Name apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenRefreshResponse struct { - // The ID of the service token. - ID interface{} `json:"id"` - // The Client ID for the service token. Access will check for this value in the - // `CF-Access-Client-ID` request header. - ClientID string `json:"client_id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The duration for how long the service token will be valid. Must be in the format - // `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. The - // default is 1 year in hours (8760h). - Duration string `json:"duration"` - // The name of the service token. - Name string `json:"name"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessServiceTokenRefreshResponseJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenRefreshResponseJSON contains the JSON metadata for -// the struct [ZeroTrustAccessServiceTokenRefreshResponse] -type zeroTrustAccessServiceTokenRefreshResponseJSON struct { - ID apijson.Field - ClientID apijson.Field - CreatedAt apijson.Field - Duration apijson.Field - Name apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenRefreshResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenRefreshResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenRotateResponse struct { - // The ID of the service token. - ID interface{} `json:"id"` - // The Client ID for the service token. Access will check for this value in the - // `CF-Access-Client-ID` request header. - ClientID string `json:"client_id"` - // The Client Secret for the service token. Access will check for this value in the - // `CF-Access-Client-Secret` request header. - ClientSecret string `json:"client_secret"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The duration for how long the service token will be valid. Must be in the format - // `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. The - // default is 1 year in hours (8760h). - Duration string `json:"duration"` - // The name of the service token. - Name string `json:"name"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessServiceTokenRotateResponseJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenRotateResponseJSON contains the JSON metadata for the -// struct [ZeroTrustAccessServiceTokenRotateResponse] -type zeroTrustAccessServiceTokenRotateResponseJSON struct { - ID apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - CreatedAt apijson.Field - Duration apijson.Field - Name apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenRotateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenRotateResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenNewParams struct { - // The name of the service token. - Name param.Field[string] `json:"name,required"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // The duration for how long the service token will be valid. Must be in the format - // `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. The - // default is 1 year in hours (8760h). - Duration param.Field[string] `json:"duration"` -} - -func (r ZeroTrustAccessServiceTokenNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustAccessServiceTokenNewResponseEnvelope struct { - Errors []ZeroTrustAccessServiceTokenNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessServiceTokenNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessServiceTokenNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessServiceTokenNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessServiceTokenNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenNewResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustAccessServiceTokenNewResponseEnvelope] -type zeroTrustAccessServiceTokenNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessServiceTokenNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessServiceTokenNewResponseEnvelopeErrors] -type zeroTrustAccessServiceTokenNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessServiceTokenNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustAccessServiceTokenNewResponseEnvelopeMessages] -type zeroTrustAccessServiceTokenNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessServiceTokenNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessServiceTokenNewResponseEnvelopeSuccessTrue ZeroTrustAccessServiceTokenNewResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessServiceTokenUpdateParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // The duration for how long the service token will be valid. Must be in the format - // `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, h. The - // default is 1 year in hours (8760h). - Duration param.Field[string] `json:"duration"` - // The name of the service token. - Name param.Field[string] `json:"name"` -} - -func (r ZeroTrustAccessServiceTokenUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustAccessServiceTokenUpdateResponseEnvelope struct { - Errors []ZeroTrustAccessServiceTokenUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessServiceTokenUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessServiceTokenUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessServiceTokenUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessServiceTokenUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenUpdateResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustAccessServiceTokenUpdateResponseEnvelope] -type zeroTrustAccessServiceTokenUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessServiceTokenUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessServiceTokenUpdateResponseEnvelopeErrors] -type zeroTrustAccessServiceTokenUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessServiceTokenUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessServiceTokenUpdateResponseEnvelopeMessages] -type zeroTrustAccessServiceTokenUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessServiceTokenUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessServiceTokenUpdateResponseEnvelopeSuccessTrue ZeroTrustAccessServiceTokenUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessServiceTokenListParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustAccessServiceTokenListResponseEnvelope struct { - Errors []ZeroTrustAccessServiceTokenListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessServiceTokenListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustAccessServiceTokenListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustAccessServiceTokenListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustAccessServiceTokenListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustAccessServiceTokenListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenListResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustAccessServiceTokenListResponseEnvelope] -type zeroTrustAccessServiceTokenListResponseEnvelopeJSON 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 *ZeroTrustAccessServiceTokenListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessServiceTokenListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustAccessServiceTokenListResponseEnvelopeErrors] -type zeroTrustAccessServiceTokenListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessServiceTokenListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessServiceTokenListResponseEnvelopeMessages] -type zeroTrustAccessServiceTokenListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessServiceTokenListResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessServiceTokenListResponseEnvelopeSuccessTrue ZeroTrustAccessServiceTokenListResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessServiceTokenListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustAccessServiceTokenListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessServiceTokenListResponseEnvelopeResultInfo] -type zeroTrustAccessServiceTokenListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenDeleteParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustAccessServiceTokenDeleteResponseEnvelope struct { - Errors []ZeroTrustAccessServiceTokenDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessServiceTokenDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessServiceTokenDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessServiceTokenDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessServiceTokenDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenDeleteResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustAccessServiceTokenDeleteResponseEnvelope] -type zeroTrustAccessServiceTokenDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessServiceTokenDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessServiceTokenDeleteResponseEnvelopeErrors] -type zeroTrustAccessServiceTokenDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessServiceTokenDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessServiceTokenDeleteResponseEnvelopeMessages] -type zeroTrustAccessServiceTokenDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessServiceTokenDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessServiceTokenDeleteResponseEnvelopeSuccessTrue ZeroTrustAccessServiceTokenDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessServiceTokenRefreshResponseEnvelope struct { - Errors []ZeroTrustAccessServiceTokenRefreshResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessServiceTokenRefreshResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessServiceTokenRefreshResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessServiceTokenRefreshResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessServiceTokenRefreshResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenRefreshResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustAccessServiceTokenRefreshResponseEnvelope] -type zeroTrustAccessServiceTokenRefreshResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenRefreshResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenRefreshResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenRefreshResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessServiceTokenRefreshResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenRefreshResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessServiceTokenRefreshResponseEnvelopeErrors] -type zeroTrustAccessServiceTokenRefreshResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenRefreshResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenRefreshResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenRefreshResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessServiceTokenRefreshResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenRefreshResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessServiceTokenRefreshResponseEnvelopeMessages] -type zeroTrustAccessServiceTokenRefreshResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenRefreshResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenRefreshResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessServiceTokenRefreshResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessServiceTokenRefreshResponseEnvelopeSuccessTrue ZeroTrustAccessServiceTokenRefreshResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessServiceTokenRotateResponseEnvelope struct { - Errors []ZeroTrustAccessServiceTokenRotateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessServiceTokenRotateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessServiceTokenRotateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessServiceTokenRotateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessServiceTokenRotateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenRotateResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustAccessServiceTokenRotateResponseEnvelope] -type zeroTrustAccessServiceTokenRotateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenRotateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenRotateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenRotateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessServiceTokenRotateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenRotateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessServiceTokenRotateResponseEnvelopeErrors] -type zeroTrustAccessServiceTokenRotateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenRotateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenRotateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessServiceTokenRotateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessServiceTokenRotateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessServiceTokenRotateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessServiceTokenRotateResponseEnvelopeMessages] -type zeroTrustAccessServiceTokenRotateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessServiceTokenRotateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessServiceTokenRotateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessServiceTokenRotateResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessServiceTokenRotateResponseEnvelopeSuccessTrue ZeroTrustAccessServiceTokenRotateResponseEnvelopeSuccess = true -) diff --git a/zerotrustaccessservicetoken_test.go b/zerotrustaccessservicetoken_test.go deleted file mode 100644 index dc92d86d6b3..00000000000 --- a/zerotrustaccessservicetoken_test.go +++ /dev/null @@ -1,190 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustAccessServiceTokenNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.ServiceTokens.New(context.TODO(), cloudflare.ZeroTrustAccessServiceTokenNewParams{ - Name: cloudflare.F("CI/CD token"), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - Duration: cloudflare.F("60m"), - }) - 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 TestZeroTrustAccessServiceTokenUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.ServiceTokens.Update( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustAccessServiceTokenUpdateParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - Duration: cloudflare.F("60m"), - Name: cloudflare.F("CI/CD token"), - }, - ) - 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 TestZeroTrustAccessServiceTokenListWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.ServiceTokens.List(context.TODO(), cloudflare.ZeroTrustAccessServiceTokenListParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }) - 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 TestZeroTrustAccessServiceTokenDeleteWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.ServiceTokens.Delete( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustAccessServiceTokenDeleteParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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 TestZeroTrustAccessServiceTokenRefresh(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.ServiceTokens.Refresh( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - 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 TestZeroTrustAccessServiceTokenRotate(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.ServiceTokens.Rotate( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - 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/zerotrustaccesstag.go b/zerotrustaccesstag.go deleted file mode 100644 index 444761ad8b9..00000000000 --- a/zerotrustaccesstag.go +++ /dev/null @@ -1,699 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustAccessTagService 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 [NewZeroTrustAccessTagService] method -// instead. -type ZeroTrustAccessTagService struct { - Options []option.RequestOption -} - -// NewZeroTrustAccessTagService 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 NewZeroTrustAccessTagService(opts ...option.RequestOption) (r *ZeroTrustAccessTagService) { - r = &ZeroTrustAccessTagService{} - r.Options = opts - return -} - -// Create a tag -func (r *ZeroTrustAccessTagService) New(ctx context.Context, identifier string, body ZeroTrustAccessTagNewParams, opts ...option.RequestOption) (res *ZeroTrustAccessTagNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessTagNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/tags", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update a tag -func (r *ZeroTrustAccessTagService) Update(ctx context.Context, identifier string, tagName string, body ZeroTrustAccessTagUpdateParams, opts ...option.RequestOption) (res *ZeroTrustAccessTagUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessTagUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/tags/%s", identifier, tagName) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List tags -func (r *ZeroTrustAccessTagService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *[]ZeroTrustAccessTagListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessTagListResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/tags", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a tag -func (r *ZeroTrustAccessTagService) Delete(ctx context.Context, identifier string, name string, opts ...option.RequestOption) (res *ZeroTrustAccessTagDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessTagDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/tags/%s", identifier, name) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a tag -func (r *ZeroTrustAccessTagService) Get(ctx context.Context, identifier string, name string, opts ...option.RequestOption) (res *ZeroTrustAccessTagGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessTagGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/tags/%s", identifier, name) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// A tag -type ZeroTrustAccessTagNewResponse struct { - // The name of the tag - Name string `json:"name,required"` - // The number of applications that have this tag - AppCount int64 `json:"app_count"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessTagNewResponseJSON `json:"-"` -} - -// zeroTrustAccessTagNewResponseJSON contains the JSON metadata for the struct -// [ZeroTrustAccessTagNewResponse] -type zeroTrustAccessTagNewResponseJSON struct { - Name apijson.Field - AppCount apijson.Field - CreatedAt apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagNewResponseJSON) RawJSON() string { - return r.raw -} - -// A tag -type ZeroTrustAccessTagUpdateResponse struct { - // The name of the tag - Name string `json:"name,required"` - // The number of applications that have this tag - AppCount int64 `json:"app_count"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessTagUpdateResponseJSON `json:"-"` -} - -// zeroTrustAccessTagUpdateResponseJSON contains the JSON metadata for the struct -// [ZeroTrustAccessTagUpdateResponse] -type zeroTrustAccessTagUpdateResponseJSON struct { - Name apijson.Field - AppCount apijson.Field - CreatedAt apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// A tag -type ZeroTrustAccessTagListResponse struct { - // The name of the tag - Name string `json:"name,required"` - // The number of applications that have this tag - AppCount int64 `json:"app_count"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessTagListResponseJSON `json:"-"` -} - -// zeroTrustAccessTagListResponseJSON contains the JSON metadata for the struct -// [ZeroTrustAccessTagListResponse] -type zeroTrustAccessTagListResponseJSON struct { - Name apijson.Field - AppCount apijson.Field - CreatedAt apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessTagDeleteResponse struct { - // The name of the tag - Name string `json:"name"` - JSON zeroTrustAccessTagDeleteResponseJSON `json:"-"` -} - -// zeroTrustAccessTagDeleteResponseJSON contains the JSON metadata for the struct -// [ZeroTrustAccessTagDeleteResponse] -type zeroTrustAccessTagDeleteResponseJSON struct { - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// A tag -type ZeroTrustAccessTagGetResponse struct { - // The name of the tag - Name string `json:"name,required"` - // The number of applications that have this tag - AppCount int64 `json:"app_count"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessTagGetResponseJSON `json:"-"` -} - -// zeroTrustAccessTagGetResponseJSON contains the JSON metadata for the struct -// [ZeroTrustAccessTagGetResponse] -type zeroTrustAccessTagGetResponseJSON struct { - Name apijson.Field - AppCount apijson.Field - CreatedAt apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessTagNewParams struct { - // The name of the tag - Name param.Field[string] `json:"name,required"` -} - -func (r ZeroTrustAccessTagNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustAccessTagNewResponseEnvelope struct { - Errors []ZeroTrustAccessTagNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessTagNewResponseEnvelopeMessages `json:"messages,required"` - // A tag - Result ZeroTrustAccessTagNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessTagNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessTagNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessTagNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustAccessTagNewResponseEnvelope] -type zeroTrustAccessTagNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessTagNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessTagNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessTagNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustAccessTagNewResponseEnvelopeErrors] -type zeroTrustAccessTagNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessTagNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessTagNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessTagNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZeroTrustAccessTagNewResponseEnvelopeMessages] -type zeroTrustAccessTagNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessTagNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessTagNewResponseEnvelopeSuccessTrue ZeroTrustAccessTagNewResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessTagUpdateParams struct { - // The name of the tag - Name param.Field[string] `json:"name,required"` -} - -func (r ZeroTrustAccessTagUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustAccessTagUpdateResponseEnvelope struct { - Errors []ZeroTrustAccessTagUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessTagUpdateResponseEnvelopeMessages `json:"messages,required"` - // A tag - Result ZeroTrustAccessTagUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessTagUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessTagUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessTagUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustAccessTagUpdateResponseEnvelope] -type zeroTrustAccessTagUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessTagUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessTagUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessTagUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustAccessTagUpdateResponseEnvelopeErrors] -type zeroTrustAccessTagUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessTagUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessTagUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessTagUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustAccessTagUpdateResponseEnvelopeMessages] -type zeroTrustAccessTagUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessTagUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessTagUpdateResponseEnvelopeSuccessTrue ZeroTrustAccessTagUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessTagListResponseEnvelope struct { - Errors []ZeroTrustAccessTagListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessTagListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustAccessTagListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustAccessTagListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustAccessTagListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustAccessTagListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessTagListResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustAccessTagListResponseEnvelope] -type zeroTrustAccessTagListResponseEnvelopeJSON 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 *ZeroTrustAccessTagListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessTagListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessTagListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessTagListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustAccessTagListResponseEnvelopeErrors] -type zeroTrustAccessTagListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessTagListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessTagListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessTagListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustAccessTagListResponseEnvelopeMessages] -type zeroTrustAccessTagListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessTagListResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessTagListResponseEnvelopeSuccessTrue ZeroTrustAccessTagListResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessTagListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustAccessTagListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustAccessTagListResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [ZeroTrustAccessTagListResponseEnvelopeResultInfo] -type zeroTrustAccessTagListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessTagDeleteResponseEnvelope struct { - Errors []ZeroTrustAccessTagDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessTagDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessTagDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessTagDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessTagDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessTagDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustAccessTagDeleteResponseEnvelope] -type zeroTrustAccessTagDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessTagDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessTagDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessTagDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustAccessTagDeleteResponseEnvelopeErrors] -type zeroTrustAccessTagDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessTagDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessTagDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessTagDeleteResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustAccessTagDeleteResponseEnvelopeMessages] -type zeroTrustAccessTagDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessTagDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessTagDeleteResponseEnvelopeSuccessTrue ZeroTrustAccessTagDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessTagGetResponseEnvelope struct { - Errors []ZeroTrustAccessTagGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessTagGetResponseEnvelopeMessages `json:"messages,required"` - // A tag - Result ZeroTrustAccessTagGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessTagGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessTagGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessTagGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustAccessTagGetResponseEnvelope] -type zeroTrustAccessTagGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessTagGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessTagGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessTagGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustAccessTagGetResponseEnvelopeErrors] -type zeroTrustAccessTagGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessTagGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessTagGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessTagGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZeroTrustAccessTagGetResponseEnvelopeMessages] -type zeroTrustAccessTagGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessTagGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessTagGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessTagGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessTagGetResponseEnvelopeSuccessTrue ZeroTrustAccessTagGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustaccesstag_test.go b/zerotrustaccesstag_test.go deleted file mode 100644 index 6c2b15d09ac..00000000000 --- a/zerotrustaccesstag_test.go +++ /dev/null @@ -1,155 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustAccessTagNew(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Tags.New( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.ZeroTrustAccessTagNewParams{ - Name: cloudflare.F("engineers"), - }, - ) - 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 TestZeroTrustAccessTagUpdate(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Tags.Update( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "engineers", - cloudflare.ZeroTrustAccessTagUpdateParams{ - Name: cloudflare.F("engineers"), - }, - ) - 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 TestZeroTrustAccessTagList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Tags.List(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()) - } -} - -func TestZeroTrustAccessTagDelete(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Tags.Delete( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "engineers", - ) - 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 TestZeroTrustAccessTagGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Tags.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "engineers", - ) - 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/zerotrustaccessuser.go b/zerotrustaccessuser.go deleted file mode 100644 index 3f9a3d754eb..00000000000 --- a/zerotrustaccessuser.go +++ /dev/null @@ -1,215 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustAccessUserService 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 [NewZeroTrustAccessUserService] -// method instead. -type ZeroTrustAccessUserService struct { - Options []option.RequestOption - ActiveSessions *ZeroTrustAccessUserActiveSessionService - LastSeenIdentity *ZeroTrustAccessUserLastSeenIdentityService - FailedLogins *ZeroTrustAccessUserFailedLoginService -} - -// NewZeroTrustAccessUserService 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 NewZeroTrustAccessUserService(opts ...option.RequestOption) (r *ZeroTrustAccessUserService) { - r = &ZeroTrustAccessUserService{} - r.Options = opts - r.ActiveSessions = NewZeroTrustAccessUserActiveSessionService(opts...) - r.LastSeenIdentity = NewZeroTrustAccessUserLastSeenIdentityService(opts...) - r.FailedLogins = NewZeroTrustAccessUserFailedLoginService(opts...) - return -} - -// Gets a list of users for an account. -func (r *ZeroTrustAccessUserService) List(ctx context.Context, identifier string, opts ...option.RequestOption) (res *[]ZeroTrustAccessUserListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessUserListResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/users", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustAccessUserListResponse struct { - // UUID - ID string `json:"id"` - // True if the user has authenticated with Cloudflare Access. - AccessSeat bool `json:"access_seat"` - // The number of active devices registered to the user. - ActiveDeviceCount float64 `json:"active_device_count"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The email of the user. - Email string `json:"email" format:"email"` - // True if the user has logged into the WARP client. - GatewaySeat bool `json:"gateway_seat"` - // The time at which the user last successfully logged in. - LastSuccessfulLogin time.Time `json:"last_successful_login" format:"date-time"` - // The name of the user. - Name string `json:"name"` - // The unique API identifier for the Zero Trust seat. - SeatUid interface{} `json:"seat_uid"` - // The unique API identifier for the user. - Uid interface{} `json:"uid"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustAccessUserListResponseJSON `json:"-"` -} - -// zeroTrustAccessUserListResponseJSON contains the JSON metadata for the struct -// [ZeroTrustAccessUserListResponse] -type zeroTrustAccessUserListResponseJSON struct { - ID apijson.Field - AccessSeat apijson.Field - ActiveDeviceCount apijson.Field - CreatedAt apijson.Field - Email apijson.Field - GatewaySeat apijson.Field - LastSuccessfulLogin apijson.Field - Name apijson.Field - SeatUid apijson.Field - Uid apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserListResponseEnvelope struct { - Errors []ZeroTrustAccessUserListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessUserListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustAccessUserListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustAccessUserListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustAccessUserListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustAccessUserListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessUserListResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustAccessUserListResponseEnvelope] -type zeroTrustAccessUserListResponseEnvelopeJSON 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 *ZeroTrustAccessUserListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessUserListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessUserListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustAccessUserListResponseEnvelopeErrors] -type zeroTrustAccessUserListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessUserListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessUserListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustAccessUserListResponseEnvelopeMessages] -type zeroTrustAccessUserListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessUserListResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessUserListResponseEnvelopeSuccessTrue ZeroTrustAccessUserListResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessUserListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustAccessUserListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustAccessUserListResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [ZeroTrustAccessUserListResponseEnvelopeResultInfo] -type zeroTrustAccessUserListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zerotrustaccessuser_test.go b/zerotrustaccessuser_test.go deleted file mode 100644 index ce070482fd2..00000000000 --- a/zerotrustaccessuser_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustAccessUserList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Users.List(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/zerotrustaccessuseractivesession.go b/zerotrustaccessuseractivesession.go deleted file mode 100644 index f797efee367..00000000000 --- a/zerotrustaccessuseractivesession.go +++ /dev/null @@ -1,553 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustAccessUserActiveSessionService 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 -// [NewZeroTrustAccessUserActiveSessionService] method instead. -type ZeroTrustAccessUserActiveSessionService struct { - Options []option.RequestOption -} - -// NewZeroTrustAccessUserActiveSessionService 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 NewZeroTrustAccessUserActiveSessionService(opts ...option.RequestOption) (r *ZeroTrustAccessUserActiveSessionService) { - r = &ZeroTrustAccessUserActiveSessionService{} - r.Options = opts - return -} - -// Get active sessions for a single user. -func (r *ZeroTrustAccessUserActiveSessionService) List(ctx context.Context, identifier string, id string, opts ...option.RequestOption) (res *[]ZeroTrustAccessUserActiveSessionListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessUserActiveSessionListResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/users/%s/active_sessions", identifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get an active session for a single user. -func (r *ZeroTrustAccessUserActiveSessionService) Get(ctx context.Context, identifier string, id string, nonce string, opts ...option.RequestOption) (res *ZeroTrustAccessUserActiveSessionGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessUserActiveSessionGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/users/%s/active_sessions/%s", identifier, id, nonce) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustAccessUserActiveSessionListResponse struct { - Expiration int64 `json:"expiration"` - Metadata ZeroTrustAccessUserActiveSessionListResponseMetadata `json:"metadata"` - Name string `json:"name"` - JSON zeroTrustAccessUserActiveSessionListResponseJSON `json:"-"` -} - -// zeroTrustAccessUserActiveSessionListResponseJSON contains the JSON metadata for -// the struct [ZeroTrustAccessUserActiveSessionListResponse] -type zeroTrustAccessUserActiveSessionListResponseJSON struct { - Expiration apijson.Field - Metadata apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserActiveSessionListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserActiveSessionListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserActiveSessionListResponseMetadata struct { - Apps map[string]ZeroTrustAccessUserActiveSessionListResponseMetadataApp `json:"apps"` - Expires int64 `json:"expires"` - Iat int64 `json:"iat"` - Nonce string `json:"nonce"` - TTL int64 `json:"ttl"` - JSON zeroTrustAccessUserActiveSessionListResponseMetadataJSON `json:"-"` -} - -// zeroTrustAccessUserActiveSessionListResponseMetadataJSON contains the JSON -// metadata for the struct [ZeroTrustAccessUserActiveSessionListResponseMetadata] -type zeroTrustAccessUserActiveSessionListResponseMetadataJSON struct { - Apps apijson.Field - Expires apijson.Field - Iat apijson.Field - Nonce apijson.Field - TTL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserActiveSessionListResponseMetadata) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserActiveSessionListResponseMetadataJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserActiveSessionListResponseMetadataApp struct { - Hostname string `json:"hostname"` - Name string `json:"name"` - Type string `json:"type"` - Uid string `json:"uid"` - JSON zeroTrustAccessUserActiveSessionListResponseMetadataAppJSON `json:"-"` -} - -// zeroTrustAccessUserActiveSessionListResponseMetadataAppJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessUserActiveSessionListResponseMetadataApp] -type zeroTrustAccessUserActiveSessionListResponseMetadataAppJSON struct { - Hostname apijson.Field - Name apijson.Field - Type apijson.Field - Uid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserActiveSessionListResponseMetadataApp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserActiveSessionListResponseMetadataAppJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserActiveSessionGetResponse struct { - AccountID string `json:"account_id"` - AuthStatus string `json:"auth_status"` - CommonName string `json:"common_name"` - DeviceID string `json:"device_id"` - DeviceSessions map[string]ZeroTrustAccessUserActiveSessionGetResponseDeviceSession `json:"device_sessions"` - DevicePosture map[string]ZeroTrustAccessUserActiveSessionGetResponseDevicePosture `json:"devicePosture"` - Email string `json:"email"` - Geo ZeroTrustAccessUserActiveSessionGetResponseGeo `json:"geo"` - Iat float64 `json:"iat"` - Idp ZeroTrustAccessUserActiveSessionGetResponseIdp `json:"idp"` - IP string `json:"ip"` - IsGateway bool `json:"is_gateway"` - IsWARP bool `json:"is_warp"` - IsActive bool `json:"isActive"` - MTLSAuth ZeroTrustAccessUserActiveSessionGetResponseMTLSAuth `json:"mtls_auth"` - ServiceTokenID string `json:"service_token_id"` - ServiceTokenStatus bool `json:"service_token_status"` - UserUUID string `json:"user_uuid"` - Version float64 `json:"version"` - JSON zeroTrustAccessUserActiveSessionGetResponseJSON `json:"-"` -} - -// zeroTrustAccessUserActiveSessionGetResponseJSON contains the JSON metadata for -// the struct [ZeroTrustAccessUserActiveSessionGetResponse] -type zeroTrustAccessUserActiveSessionGetResponseJSON struct { - AccountID apijson.Field - AuthStatus apijson.Field - CommonName apijson.Field - DeviceID apijson.Field - DeviceSessions apijson.Field - DevicePosture apijson.Field - Email apijson.Field - Geo apijson.Field - Iat apijson.Field - Idp apijson.Field - IP apijson.Field - IsGateway apijson.Field - IsWARP apijson.Field - IsActive apijson.Field - MTLSAuth apijson.Field - ServiceTokenID apijson.Field - ServiceTokenStatus apijson.Field - UserUUID apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserActiveSessionGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserActiveSessionGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserActiveSessionGetResponseDeviceSession struct { - LastAuthenticated float64 `json:"last_authenticated"` - JSON zeroTrustAccessUserActiveSessionGetResponseDeviceSessionJSON `json:"-"` -} - -// zeroTrustAccessUserActiveSessionGetResponseDeviceSessionJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessUserActiveSessionGetResponseDeviceSession] -type zeroTrustAccessUserActiveSessionGetResponseDeviceSessionJSON struct { - LastAuthenticated apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserActiveSessionGetResponseDeviceSession) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserActiveSessionGetResponseDeviceSessionJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserActiveSessionGetResponseDevicePosture struct { - ID string `json:"id"` - Check ZeroTrustAccessUserActiveSessionGetResponseDevicePostureCheck `json:"check"` - Data interface{} `json:"data"` - Description string `json:"description"` - Error string `json:"error"` - RuleName string `json:"rule_name"` - Success bool `json:"success"` - Timestamp string `json:"timestamp"` - Type string `json:"type"` - JSON zeroTrustAccessUserActiveSessionGetResponseDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessUserActiveSessionGetResponseDevicePostureJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessUserActiveSessionGetResponseDevicePosture] -type zeroTrustAccessUserActiveSessionGetResponseDevicePostureJSON struct { - ID apijson.Field - Check apijson.Field - Data apijson.Field - Description apijson.Field - Error apijson.Field - RuleName apijson.Field - Success apijson.Field - Timestamp apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserActiveSessionGetResponseDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserActiveSessionGetResponseDevicePostureJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserActiveSessionGetResponseDevicePostureCheck struct { - Exists bool `json:"exists"` - Path string `json:"path"` - JSON zeroTrustAccessUserActiveSessionGetResponseDevicePostureCheckJSON `json:"-"` -} - -// zeroTrustAccessUserActiveSessionGetResponseDevicePostureCheckJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessUserActiveSessionGetResponseDevicePostureCheck] -type zeroTrustAccessUserActiveSessionGetResponseDevicePostureCheckJSON struct { - Exists apijson.Field - Path apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserActiveSessionGetResponseDevicePostureCheck) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserActiveSessionGetResponseDevicePostureCheckJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserActiveSessionGetResponseGeo struct { - Country string `json:"country"` - JSON zeroTrustAccessUserActiveSessionGetResponseGeoJSON `json:"-"` -} - -// zeroTrustAccessUserActiveSessionGetResponseGeoJSON contains the JSON metadata -// for the struct [ZeroTrustAccessUserActiveSessionGetResponseGeo] -type zeroTrustAccessUserActiveSessionGetResponseGeoJSON struct { - Country apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserActiveSessionGetResponseGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserActiveSessionGetResponseGeoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserActiveSessionGetResponseIdp struct { - ID string `json:"id"` - Type string `json:"type"` - JSON zeroTrustAccessUserActiveSessionGetResponseIdpJSON `json:"-"` -} - -// zeroTrustAccessUserActiveSessionGetResponseIdpJSON contains the JSON metadata -// for the struct [ZeroTrustAccessUserActiveSessionGetResponseIdp] -type zeroTrustAccessUserActiveSessionGetResponseIdpJSON struct { - ID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserActiveSessionGetResponseIdp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserActiveSessionGetResponseIdpJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserActiveSessionGetResponseMTLSAuth struct { - AuthStatus string `json:"auth_status"` - CertIssuerDn string `json:"cert_issuer_dn"` - CertIssuerSki string `json:"cert_issuer_ski"` - CertPresented bool `json:"cert_presented"` - CertSerial string `json:"cert_serial"` - JSON zeroTrustAccessUserActiveSessionGetResponseMTLSAuthJSON `json:"-"` -} - -// zeroTrustAccessUserActiveSessionGetResponseMTLSAuthJSON contains the JSON -// metadata for the struct [ZeroTrustAccessUserActiveSessionGetResponseMTLSAuth] -type zeroTrustAccessUserActiveSessionGetResponseMTLSAuthJSON struct { - AuthStatus apijson.Field - CertIssuerDn apijson.Field - CertIssuerSki apijson.Field - CertPresented apijson.Field - CertSerial apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserActiveSessionGetResponseMTLSAuth) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserActiveSessionGetResponseMTLSAuthJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserActiveSessionListResponseEnvelope struct { - Errors []ZeroTrustAccessUserActiveSessionListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessUserActiveSessionListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustAccessUserActiveSessionListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustAccessUserActiveSessionListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustAccessUserActiveSessionListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustAccessUserActiveSessionListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessUserActiveSessionListResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustAccessUserActiveSessionListResponseEnvelope] -type zeroTrustAccessUserActiveSessionListResponseEnvelopeJSON 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 *ZeroTrustAccessUserActiveSessionListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserActiveSessionListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserActiveSessionListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessUserActiveSessionListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessUserActiveSessionListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessUserActiveSessionListResponseEnvelopeErrors] -type zeroTrustAccessUserActiveSessionListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserActiveSessionListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserActiveSessionListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserActiveSessionListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessUserActiveSessionListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessUserActiveSessionListResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessUserActiveSessionListResponseEnvelopeMessages] -type zeroTrustAccessUserActiveSessionListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserActiveSessionListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserActiveSessionListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessUserActiveSessionListResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessUserActiveSessionListResponseEnvelopeSuccessTrue ZeroTrustAccessUserActiveSessionListResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessUserActiveSessionListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustAccessUserActiveSessionListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustAccessUserActiveSessionListResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessUserActiveSessionListResponseEnvelopeResultInfo] -type zeroTrustAccessUserActiveSessionListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserActiveSessionListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserActiveSessionListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserActiveSessionGetResponseEnvelope struct { - Errors []ZeroTrustAccessUserActiveSessionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessUserActiveSessionGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessUserActiveSessionGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessUserActiveSessionGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessUserActiveSessionGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessUserActiveSessionGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustAccessUserActiveSessionGetResponseEnvelope] -type zeroTrustAccessUserActiveSessionGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserActiveSessionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserActiveSessionGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserActiveSessionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessUserActiveSessionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessUserActiveSessionGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessUserActiveSessionGetResponseEnvelopeErrors] -type zeroTrustAccessUserActiveSessionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserActiveSessionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserActiveSessionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserActiveSessionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessUserActiveSessionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessUserActiveSessionGetResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessUserActiveSessionGetResponseEnvelopeMessages] -type zeroTrustAccessUserActiveSessionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserActiveSessionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserActiveSessionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessUserActiveSessionGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessUserActiveSessionGetResponseEnvelopeSuccessTrue ZeroTrustAccessUserActiveSessionGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustaccessuseractivesession_test.go b/zerotrustaccessuseractivesession_test.go deleted file mode 100644 index 87b4deb9a21..00000000000 --- a/zerotrustaccessuseractivesession_test.go +++ /dev/null @@ -1,71 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustAccessUserActiveSessionList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Users.ActiveSessions.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - 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 TestZeroTrustAccessUserActiveSessionGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Users.ActiveSessions.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - "X1aXj1lFVcqqyoXF", - ) - 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/zerotrustaccessuserfailedlogin.go b/zerotrustaccessuserfailedlogin.go deleted file mode 100644 index 368157ef08e..00000000000 --- a/zerotrustaccessuserfailedlogin.go +++ /dev/null @@ -1,184 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustAccessUserFailedLoginService 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 -// [NewZeroTrustAccessUserFailedLoginService] method instead. -type ZeroTrustAccessUserFailedLoginService struct { - Options []option.RequestOption -} - -// NewZeroTrustAccessUserFailedLoginService 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 NewZeroTrustAccessUserFailedLoginService(opts ...option.RequestOption) (r *ZeroTrustAccessUserFailedLoginService) { - r = &ZeroTrustAccessUserFailedLoginService{} - r.Options = opts - return -} - -// Get all failed login attempts for a single user. -func (r *ZeroTrustAccessUserFailedLoginService) List(ctx context.Context, identifier string, id string, opts ...option.RequestOption) (res *[]ZeroTrustAccessUserFailedLoginListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessUserFailedLoginListResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/users/%s/failed_logins", identifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustAccessUserFailedLoginListResponse struct { - Expiration int64 `json:"expiration"` - Metadata interface{} `json:"metadata"` - JSON zeroTrustAccessUserFailedLoginListResponseJSON `json:"-"` -} - -// zeroTrustAccessUserFailedLoginListResponseJSON contains the JSON metadata for -// the struct [ZeroTrustAccessUserFailedLoginListResponse] -type zeroTrustAccessUserFailedLoginListResponseJSON struct { - Expiration apijson.Field - Metadata apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserFailedLoginListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserFailedLoginListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserFailedLoginListResponseEnvelope struct { - Errors []ZeroTrustAccessUserFailedLoginListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessUserFailedLoginListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustAccessUserFailedLoginListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustAccessUserFailedLoginListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustAccessUserFailedLoginListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustAccessUserFailedLoginListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessUserFailedLoginListResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustAccessUserFailedLoginListResponseEnvelope] -type zeroTrustAccessUserFailedLoginListResponseEnvelopeJSON 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 *ZeroTrustAccessUserFailedLoginListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserFailedLoginListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserFailedLoginListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessUserFailedLoginListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessUserFailedLoginListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessUserFailedLoginListResponseEnvelopeErrors] -type zeroTrustAccessUserFailedLoginListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserFailedLoginListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserFailedLoginListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserFailedLoginListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessUserFailedLoginListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessUserFailedLoginListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustAccessUserFailedLoginListResponseEnvelopeMessages] -type zeroTrustAccessUserFailedLoginListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserFailedLoginListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserFailedLoginListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessUserFailedLoginListResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessUserFailedLoginListResponseEnvelopeSuccessTrue ZeroTrustAccessUserFailedLoginListResponseEnvelopeSuccess = true -) - -type ZeroTrustAccessUserFailedLoginListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustAccessUserFailedLoginListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustAccessUserFailedLoginListResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessUserFailedLoginListResponseEnvelopeResultInfo] -type zeroTrustAccessUserFailedLoginListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserFailedLoginListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserFailedLoginListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zerotrustaccessuserfailedlogin_test.go b/zerotrustaccessuserfailedlogin_test.go deleted file mode 100644 index 359bad2a953..00000000000 --- a/zerotrustaccessuserfailedlogin_test.go +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustAccessUserFailedLoginList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Users.FailedLogins.List( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - 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/zerotrustaccessuserlastseenidentity.go b/zerotrustaccessuserlastseenidentity.go deleted file mode 100644 index f91d1b1d67f..00000000000 --- a/zerotrustaccessuserlastseenidentity.go +++ /dev/null @@ -1,340 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustAccessUserLastSeenIdentityService 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 -// [NewZeroTrustAccessUserLastSeenIdentityService] method instead. -type ZeroTrustAccessUserLastSeenIdentityService struct { - Options []option.RequestOption -} - -// NewZeroTrustAccessUserLastSeenIdentityService 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 NewZeroTrustAccessUserLastSeenIdentityService(opts ...option.RequestOption) (r *ZeroTrustAccessUserLastSeenIdentityService) { - r = &ZeroTrustAccessUserLastSeenIdentityService{} - r.Options = opts - return -} - -// Get last seen identity for a single user. -func (r *ZeroTrustAccessUserLastSeenIdentityService) Get(ctx context.Context, identifier string, id string, opts ...option.RequestOption) (res *ZeroTrustAccessUserLastSeenIdentityGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustAccessUserLastSeenIdentityGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/users/%s/last_seen_identity", identifier, id) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustAccessUserLastSeenIdentityGetResponse struct { - AccountID string `json:"account_id"` - AuthStatus string `json:"auth_status"` - CommonName string `json:"common_name"` - DeviceID string `json:"device_id"` - DeviceSessions map[string]ZeroTrustAccessUserLastSeenIdentityGetResponseDeviceSession `json:"device_sessions"` - DevicePosture map[string]ZeroTrustAccessUserLastSeenIdentityGetResponseDevicePosture `json:"devicePosture"` - Email string `json:"email"` - Geo ZeroTrustAccessUserLastSeenIdentityGetResponseGeo `json:"geo"` - Iat float64 `json:"iat"` - Idp ZeroTrustAccessUserLastSeenIdentityGetResponseIdp `json:"idp"` - IP string `json:"ip"` - IsGateway bool `json:"is_gateway"` - IsWARP bool `json:"is_warp"` - MTLSAuth ZeroTrustAccessUserLastSeenIdentityGetResponseMTLSAuth `json:"mtls_auth"` - ServiceTokenID string `json:"service_token_id"` - ServiceTokenStatus bool `json:"service_token_status"` - UserUUID string `json:"user_uuid"` - Version float64 `json:"version"` - JSON zeroTrustAccessUserLastSeenIdentityGetResponseJSON `json:"-"` -} - -// zeroTrustAccessUserLastSeenIdentityGetResponseJSON contains the JSON metadata -// for the struct [ZeroTrustAccessUserLastSeenIdentityGetResponse] -type zeroTrustAccessUserLastSeenIdentityGetResponseJSON struct { - AccountID apijson.Field - AuthStatus apijson.Field - CommonName apijson.Field - DeviceID apijson.Field - DeviceSessions apijson.Field - DevicePosture apijson.Field - Email apijson.Field - Geo apijson.Field - Iat apijson.Field - Idp apijson.Field - IP apijson.Field - IsGateway apijson.Field - IsWARP apijson.Field - MTLSAuth apijson.Field - ServiceTokenID apijson.Field - ServiceTokenStatus apijson.Field - UserUUID apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserLastSeenIdentityGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserLastSeenIdentityGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserLastSeenIdentityGetResponseDeviceSession struct { - LastAuthenticated float64 `json:"last_authenticated"` - JSON zeroTrustAccessUserLastSeenIdentityGetResponseDeviceSessionJSON `json:"-"` -} - -// zeroTrustAccessUserLastSeenIdentityGetResponseDeviceSessionJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessUserLastSeenIdentityGetResponseDeviceSession] -type zeroTrustAccessUserLastSeenIdentityGetResponseDeviceSessionJSON struct { - LastAuthenticated apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserLastSeenIdentityGetResponseDeviceSession) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserLastSeenIdentityGetResponseDeviceSessionJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserLastSeenIdentityGetResponseDevicePosture struct { - ID string `json:"id"` - Check ZeroTrustAccessUserLastSeenIdentityGetResponseDevicePostureCheck `json:"check"` - Data interface{} `json:"data"` - Description string `json:"description"` - Error string `json:"error"` - RuleName string `json:"rule_name"` - Success bool `json:"success"` - Timestamp string `json:"timestamp"` - Type string `json:"type"` - JSON zeroTrustAccessUserLastSeenIdentityGetResponseDevicePostureJSON `json:"-"` -} - -// zeroTrustAccessUserLastSeenIdentityGetResponseDevicePostureJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessUserLastSeenIdentityGetResponseDevicePosture] -type zeroTrustAccessUserLastSeenIdentityGetResponseDevicePostureJSON struct { - ID apijson.Field - Check apijson.Field - Data apijson.Field - Description apijson.Field - Error apijson.Field - RuleName apijson.Field - Success apijson.Field - Timestamp apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserLastSeenIdentityGetResponseDevicePosture) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserLastSeenIdentityGetResponseDevicePostureJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserLastSeenIdentityGetResponseDevicePostureCheck struct { - Exists bool `json:"exists"` - Path string `json:"path"` - JSON zeroTrustAccessUserLastSeenIdentityGetResponseDevicePostureCheckJSON `json:"-"` -} - -// zeroTrustAccessUserLastSeenIdentityGetResponseDevicePostureCheckJSON contains -// the JSON metadata for the struct -// [ZeroTrustAccessUserLastSeenIdentityGetResponseDevicePostureCheck] -type zeroTrustAccessUserLastSeenIdentityGetResponseDevicePostureCheckJSON struct { - Exists apijson.Field - Path apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserLastSeenIdentityGetResponseDevicePostureCheck) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserLastSeenIdentityGetResponseDevicePostureCheckJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserLastSeenIdentityGetResponseGeo struct { - Country string `json:"country"` - JSON zeroTrustAccessUserLastSeenIdentityGetResponseGeoJSON `json:"-"` -} - -// zeroTrustAccessUserLastSeenIdentityGetResponseGeoJSON contains the JSON metadata -// for the struct [ZeroTrustAccessUserLastSeenIdentityGetResponseGeo] -type zeroTrustAccessUserLastSeenIdentityGetResponseGeoJSON struct { - Country apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserLastSeenIdentityGetResponseGeo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserLastSeenIdentityGetResponseGeoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserLastSeenIdentityGetResponseIdp struct { - ID string `json:"id"` - Type string `json:"type"` - JSON zeroTrustAccessUserLastSeenIdentityGetResponseIdpJSON `json:"-"` -} - -// zeroTrustAccessUserLastSeenIdentityGetResponseIdpJSON contains the JSON metadata -// for the struct [ZeroTrustAccessUserLastSeenIdentityGetResponseIdp] -type zeroTrustAccessUserLastSeenIdentityGetResponseIdpJSON struct { - ID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserLastSeenIdentityGetResponseIdp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserLastSeenIdentityGetResponseIdpJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserLastSeenIdentityGetResponseMTLSAuth struct { - AuthStatus string `json:"auth_status"` - CertIssuerDn string `json:"cert_issuer_dn"` - CertIssuerSki string `json:"cert_issuer_ski"` - CertPresented bool `json:"cert_presented"` - CertSerial string `json:"cert_serial"` - JSON zeroTrustAccessUserLastSeenIdentityGetResponseMTLSAuthJSON `json:"-"` -} - -// zeroTrustAccessUserLastSeenIdentityGetResponseMTLSAuthJSON contains the JSON -// metadata for the struct [ZeroTrustAccessUserLastSeenIdentityGetResponseMTLSAuth] -type zeroTrustAccessUserLastSeenIdentityGetResponseMTLSAuthJSON struct { - AuthStatus apijson.Field - CertIssuerDn apijson.Field - CertIssuerSki apijson.Field - CertPresented apijson.Field - CertSerial apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserLastSeenIdentityGetResponseMTLSAuth) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserLastSeenIdentityGetResponseMTLSAuthJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserLastSeenIdentityGetResponseEnvelope struct { - Errors []ZeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustAccessUserLastSeenIdentityGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustAccessUserLastSeenIdentityGetResponseEnvelope] -type zeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserLastSeenIdentityGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeErrors] -type zeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeMessages] -type zeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeSuccessTrue ZeroTrustAccessUserLastSeenIdentityGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustaccessuserlastseenidentity_test.go b/zerotrustaccessuserlastseenidentity_test.go deleted file mode 100644 index a5bd6de128c..00000000000 --- a/zerotrustaccessuserlastseenidentity_test.go +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustAccessUserLastSeenIdentityGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Access.Users.LastSeenIdentity.Get( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - ) - 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/zerotrustconnectivitysetting.go b/zerotrustconnectivitysetting.go deleted file mode 100644 index 321d82c34ad..00000000000 --- a/zerotrustconnectivitysetting.go +++ /dev/null @@ -1,290 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustConnectivitySettingService 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 -// [NewZeroTrustConnectivitySettingService] method instead. -type ZeroTrustConnectivitySettingService struct { - Options []option.RequestOption -} - -// NewZeroTrustConnectivitySettingService 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 NewZeroTrustConnectivitySettingService(opts ...option.RequestOption) (r *ZeroTrustConnectivitySettingService) { - r = &ZeroTrustConnectivitySettingService{} - r.Options = opts - return -} - -// Updates the Zero Trust Connectivity Settings for the given account. -func (r *ZeroTrustConnectivitySettingService) Edit(ctx context.Context, params ZeroTrustConnectivitySettingEditParams, opts ...option.RequestOption) (res *ZeroTrustConnectivitySettingEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustConnectivitySettingEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/zerotrust/connectivity_settings", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets the Zero Trust Connectivity Settings for the given account. -func (r *ZeroTrustConnectivitySettingService) Get(ctx context.Context, query ZeroTrustConnectivitySettingGetParams, opts ...option.RequestOption) (res *ZeroTrustConnectivitySettingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustConnectivitySettingGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/zerotrust/connectivity_settings", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustConnectivitySettingEditResponse struct { - // A flag to enable the ICMP proxy for the account network. - IcmpProxyEnabled bool `json:"icmp_proxy_enabled"` - // A flag to enable WARP to WARP traffic. - OfframpWARPEnabled bool `json:"offramp_warp_enabled"` - JSON zeroTrustConnectivitySettingEditResponseJSON `json:"-"` -} - -// zeroTrustConnectivitySettingEditResponseJSON contains the JSON metadata for the -// struct [ZeroTrustConnectivitySettingEditResponse] -type zeroTrustConnectivitySettingEditResponseJSON struct { - IcmpProxyEnabled apijson.Field - OfframpWARPEnabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustConnectivitySettingEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustConnectivitySettingEditResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustConnectivitySettingGetResponse struct { - // A flag to enable the ICMP proxy for the account network. - IcmpProxyEnabled bool `json:"icmp_proxy_enabled"` - // A flag to enable WARP to WARP traffic. - OfframpWARPEnabled bool `json:"offramp_warp_enabled"` - JSON zeroTrustConnectivitySettingGetResponseJSON `json:"-"` -} - -// zeroTrustConnectivitySettingGetResponseJSON contains the JSON metadata for the -// struct [ZeroTrustConnectivitySettingGetResponse] -type zeroTrustConnectivitySettingGetResponseJSON struct { - IcmpProxyEnabled apijson.Field - OfframpWARPEnabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustConnectivitySettingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustConnectivitySettingGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustConnectivitySettingEditParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - // A flag to enable the ICMP proxy for the account network. - IcmpProxyEnabled param.Field[bool] `json:"icmp_proxy_enabled"` - // A flag to enable WARP to WARP traffic. - OfframpWARPEnabled param.Field[bool] `json:"offramp_warp_enabled"` -} - -func (r ZeroTrustConnectivitySettingEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustConnectivitySettingEditResponseEnvelope struct { - Errors []ZeroTrustConnectivitySettingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustConnectivitySettingEditResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustConnectivitySettingEditResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustConnectivitySettingEditResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustConnectivitySettingEditResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustConnectivitySettingEditResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustConnectivitySettingEditResponseEnvelope] -type zeroTrustConnectivitySettingEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustConnectivitySettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustConnectivitySettingEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustConnectivitySettingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustConnectivitySettingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustConnectivitySettingEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustConnectivitySettingEditResponseEnvelopeErrors] -type zeroTrustConnectivitySettingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustConnectivitySettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustConnectivitySettingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustConnectivitySettingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustConnectivitySettingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustConnectivitySettingEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustConnectivitySettingEditResponseEnvelopeMessages] -type zeroTrustConnectivitySettingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustConnectivitySettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustConnectivitySettingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustConnectivitySettingEditResponseEnvelopeSuccess bool - -const ( - ZeroTrustConnectivitySettingEditResponseEnvelopeSuccessTrue ZeroTrustConnectivitySettingEditResponseEnvelopeSuccess = true -) - -type ZeroTrustConnectivitySettingGetParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustConnectivitySettingGetResponseEnvelope struct { - Errors []ZeroTrustConnectivitySettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustConnectivitySettingGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustConnectivitySettingGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustConnectivitySettingGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustConnectivitySettingGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustConnectivitySettingGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustConnectivitySettingGetResponseEnvelope] -type zeroTrustConnectivitySettingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustConnectivitySettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustConnectivitySettingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustConnectivitySettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustConnectivitySettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustConnectivitySettingGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustConnectivitySettingGetResponseEnvelopeErrors] -type zeroTrustConnectivitySettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustConnectivitySettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustConnectivitySettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustConnectivitySettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustConnectivitySettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustConnectivitySettingGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustConnectivitySettingGetResponseEnvelopeMessages] -type zeroTrustConnectivitySettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustConnectivitySettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustConnectivitySettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustConnectivitySettingGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustConnectivitySettingGetResponseEnvelopeSuccessTrue ZeroTrustConnectivitySettingGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustconnectivitysetting_test.go b/zerotrustconnectivitysetting_test.go deleted file mode 100644 index bf1d5b11b96..00000000000 --- a/zerotrustconnectivitysetting_test.go +++ /dev/null @@ -1,68 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustConnectivitySettingEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.ConnectivitySettings.Edit(context.TODO(), cloudflare.ZeroTrustConnectivitySettingEditParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - IcmpProxyEnabled: cloudflare.F(true), - OfframpWARPEnabled: cloudflare.F(true), - }) - 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 TestZeroTrustConnectivitySettingGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.ConnectivitySettings.Get(context.TODO(), cloudflare.ZeroTrustConnectivitySettingGetParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - }) - 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/zerotrustdevice.go b/zerotrustdevice.go deleted file mode 100644 index 87e1d5027d8..00000000000 --- a/zerotrustdevice.go +++ /dev/null @@ -1,412 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustDeviceService 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 [NewZeroTrustDeviceService] method -// instead. -type ZeroTrustDeviceService struct { - Options []option.RequestOption - DEXTests *ZeroTrustDeviceDEXTestService - Networks *ZeroTrustDeviceNetworkService - Policies *ZeroTrustDevicePolicyService - Postures *ZeroTrustDevicePostureService - Revokes *ZeroTrustDeviceRevokeService - Settings *ZeroTrustDeviceSettingService - Unrevokes *ZeroTrustDeviceUnrevokeService - OverrideCodes *ZeroTrustDeviceOverrideCodeService -} - -// NewZeroTrustDeviceService 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 NewZeroTrustDeviceService(opts ...option.RequestOption) (r *ZeroTrustDeviceService) { - r = &ZeroTrustDeviceService{} - r.Options = opts - r.DEXTests = NewZeroTrustDeviceDEXTestService(opts...) - r.Networks = NewZeroTrustDeviceNetworkService(opts...) - r.Policies = NewZeroTrustDevicePolicyService(opts...) - r.Postures = NewZeroTrustDevicePostureService(opts...) - r.Revokes = NewZeroTrustDeviceRevokeService(opts...) - r.Settings = NewZeroTrustDeviceSettingService(opts...) - r.Unrevokes = NewZeroTrustDeviceUnrevokeService(opts...) - r.OverrideCodes = NewZeroTrustDeviceOverrideCodeService(opts...) - return -} - -// Fetches a list of enrolled devices. -func (r *ZeroTrustDeviceService) List(ctx context.Context, query ZeroTrustDeviceListParams, opts ...option.RequestOption) (res *[]ZeroTrustDeviceListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDeviceListResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches details for a single device. -func (r *ZeroTrustDeviceService) Get(ctx context.Context, deviceID string, query ZeroTrustDeviceGetParams, opts ...option.RequestOption) (res *ZeroTrustDeviceGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDeviceGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/%s", query.AccountID, deviceID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDeviceListResponse struct { - // Device ID. - ID string `json:"id"` - // When the device was created. - Created time.Time `json:"created" format:"date-time"` - // True if the device was deleted. - Deleted bool `json:"deleted"` - DeviceType ZeroTrustDeviceListResponseDeviceType `json:"device_type"` - // IPv4 or IPv6 address. - IP string `json:"ip"` - // The device's public key. - Key string `json:"key"` - // When the device last connected to Cloudflare services. - LastSeen time.Time `json:"last_seen" format:"date-time"` - // The device mac address. - MacAddress string `json:"mac_address"` - // The device manufacturer name. - Manufacturer string `json:"manufacturer"` - // The device model name. - Model string `json:"model"` - // The device name. - Name string `json:"name"` - // The Linux distro name. - OSDistroName string `json:"os_distro_name"` - // The Linux distro revision. - OSDistroRevision string `json:"os_distro_revision"` - // The operating system version. - OSVersion string `json:"os_version"` - // The operating system version extra parameter. - OSVersionExtra string `json:"os_version_extra"` - // When the device was revoked. - RevokedAt time.Time `json:"revoked_at" format:"date-time"` - // The device serial number. - SerialNumber string `json:"serial_number"` - // When the device was updated. - Updated time.Time `json:"updated" format:"date-time"` - User ZeroTrustDeviceListResponseUser `json:"user"` - // The WARP client version. - Version string `json:"version"` - JSON zeroTrustDeviceListResponseJSON `json:"-"` -} - -// zeroTrustDeviceListResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDeviceListResponse] -type zeroTrustDeviceListResponseJSON struct { - ID apijson.Field - Created apijson.Field - Deleted apijson.Field - DeviceType apijson.Field - IP apijson.Field - Key apijson.Field - LastSeen apijson.Field - MacAddress apijson.Field - Manufacturer apijson.Field - Model apijson.Field - Name apijson.Field - OSDistroName apijson.Field - OSDistroRevision apijson.Field - OSVersion apijson.Field - OSVersionExtra apijson.Field - RevokedAt apijson.Field - SerialNumber apijson.Field - Updated apijson.Field - User apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceListResponseDeviceType string - -const ( - ZeroTrustDeviceListResponseDeviceTypeWindows ZeroTrustDeviceListResponseDeviceType = "windows" - ZeroTrustDeviceListResponseDeviceTypeMac ZeroTrustDeviceListResponseDeviceType = "mac" - ZeroTrustDeviceListResponseDeviceTypeLinux ZeroTrustDeviceListResponseDeviceType = "linux" - ZeroTrustDeviceListResponseDeviceTypeAndroid ZeroTrustDeviceListResponseDeviceType = "android" - ZeroTrustDeviceListResponseDeviceTypeIos ZeroTrustDeviceListResponseDeviceType = "ios" -) - -type ZeroTrustDeviceListResponseUser struct { - // UUID - ID string `json:"id"` - // The contact email address of the user. - Email string `json:"email"` - // The enrolled device user's name. - Name string `json:"name"` - JSON zeroTrustDeviceListResponseUserJSON `json:"-"` -} - -// zeroTrustDeviceListResponseUserJSON contains the JSON metadata for the struct -// [ZeroTrustDeviceListResponseUser] -type zeroTrustDeviceListResponseUserJSON struct { - ID apijson.Field - Email apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceListResponseUser) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceListResponseUserJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [ZeroTrustDeviceGetResponseUnknown] or [shared.UnionString]. -type ZeroTrustDeviceGetResponse interface { - ImplementsZeroTrustDeviceGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustDeviceGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustDeviceListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDeviceListResponseEnvelope struct { - Errors []ZeroTrustDeviceListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDeviceListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDeviceListResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDeviceListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDeviceListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDeviceListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDeviceListResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceListResponseEnvelope] -type zeroTrustDeviceListResponseEnvelopeJSON 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 *ZeroTrustDeviceListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDeviceListResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceListResponseEnvelopeErrors] -type zeroTrustDeviceListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDeviceListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZeroTrustDeviceListResponseEnvelopeMessages] -type zeroTrustDeviceListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDeviceListResponseEnvelopeSuccess bool - -const ( - ZeroTrustDeviceListResponseEnvelopeSuccessTrue ZeroTrustDeviceListResponseEnvelopeSuccess = true -) - -type ZeroTrustDeviceListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDeviceListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDeviceListResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [ZeroTrustDeviceListResponseEnvelopeResultInfo] -type zeroTrustDeviceListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDeviceGetResponseEnvelope struct { - Errors []ZeroTrustDeviceGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDeviceGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDeviceGetResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDeviceGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDeviceGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDeviceGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [ZeroTrustDeviceGetResponseEnvelope] -type zeroTrustDeviceGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDeviceGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceGetResponseEnvelopeErrors] -type zeroTrustDeviceGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDeviceGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZeroTrustDeviceGetResponseEnvelopeMessages] -type zeroTrustDeviceGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDeviceGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustDeviceGetResponseEnvelopeSuccessTrue ZeroTrustDeviceGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustdevice_test.go b/zerotrustdevice_test.go deleted file mode 100644 index 83db9b2383a..00000000000 --- a/zerotrustdevice_test.go +++ /dev/null @@ -1,70 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDeviceList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.List(context.TODO(), cloudflare.ZeroTrustDeviceListParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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 TestZeroTrustDeviceGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Get( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDeviceGetParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrustdevicedextest.go b/zerotrustdevicedextest.go deleted file mode 100644 index 2299d04b8f9..00000000000 --- a/zerotrustdevicedextest.go +++ /dev/null @@ -1,908 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDeviceDEXTestService 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 [NewZeroTrustDeviceDEXTestService] -// method instead. -type ZeroTrustDeviceDEXTestService struct { - Options []option.RequestOption -} - -// NewZeroTrustDeviceDEXTestService 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 NewZeroTrustDeviceDEXTestService(opts ...option.RequestOption) (r *ZeroTrustDeviceDEXTestService) { - r = &ZeroTrustDeviceDEXTestService{} - r.Options = opts - return -} - -// Create a DEX test. -func (r *ZeroTrustDeviceDEXTestService) New(ctx context.Context, params ZeroTrustDeviceDEXTestNewParams, opts ...option.RequestOption) (res *ZeroTrustDeviceDEXTestNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDeviceDEXTestNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/dex_tests", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update a DEX test. -func (r *ZeroTrustDeviceDEXTestService) Update(ctx context.Context, dexTestID string, params ZeroTrustDeviceDEXTestUpdateParams, opts ...option.RequestOption) (res *ZeroTrustDeviceDEXTestUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDeviceDEXTestUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/dex_tests/%s", params.AccountID, dexTestID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch all DEX tests. -func (r *ZeroTrustDeviceDEXTestService) List(ctx context.Context, query ZeroTrustDeviceDEXTestListParams, opts ...option.RequestOption) (res *[]ZeroTrustDeviceDEXTestListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDeviceDEXTestListResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/dex_tests", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a Device DEX test. Returns the remaining device dex tests for the -// account. -func (r *ZeroTrustDeviceDEXTestService) Delete(ctx context.Context, dexTestID string, body ZeroTrustDeviceDEXTestDeleteParams, opts ...option.RequestOption) (res *[]ZeroTrustDeviceDEXTestDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDeviceDEXTestDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/dex_tests/%s", body.AccountID, dexTestID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch a single DEX test. -func (r *ZeroTrustDeviceDEXTestService) Get(ctx context.Context, dexTestID string, query ZeroTrustDeviceDEXTestGetParams, opts ...option.RequestOption) (res *ZeroTrustDeviceDEXTestGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDeviceDEXTestGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/dex_tests/%s", query.AccountID, dexTestID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDeviceDEXTestNewResponse struct { - // The configuration object which contains the details for the WARP client to - // conduct the test. - Data ZeroTrustDeviceDEXTestNewResponseData `json:"data,required"` - // Determines whether or not the test is active. - Enabled bool `json:"enabled,required"` - // How often the test will run. - Interval string `json:"interval,required"` - // The name of the DEX test. Must be unique. - Name string `json:"name,required"` - // Additional details about the test. - Description string `json:"description"` - JSON zeroTrustDeviceDEXTestNewResponseJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestNewResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDeviceDEXTestNewResponse] -type zeroTrustDeviceDEXTestNewResponseJSON struct { - Data apijson.Field - Enabled apijson.Field - Interval apijson.Field - Name apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestNewResponseJSON) RawJSON() string { - return r.raw -} - -// The configuration object which contains the details for the WARP client to -// conduct the test. -type ZeroTrustDeviceDEXTestNewResponseData struct { - // The desired endpoint to test. - Host string `json:"host"` - // The type of test. - Kind string `json:"kind"` - // The HTTP request method type. - Method string `json:"method"` - JSON zeroTrustDeviceDEXTestNewResponseDataJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestNewResponseDataJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceDEXTestNewResponseData] -type zeroTrustDeviceDEXTestNewResponseDataJSON struct { - Host apijson.Field - Kind apijson.Field - Method apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestNewResponseData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestNewResponseDataJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceDEXTestUpdateResponse struct { - // The configuration object which contains the details for the WARP client to - // conduct the test. - Data ZeroTrustDeviceDEXTestUpdateResponseData `json:"data,required"` - // Determines whether or not the test is active. - Enabled bool `json:"enabled,required"` - // How often the test will run. - Interval string `json:"interval,required"` - // The name of the DEX test. Must be unique. - Name string `json:"name,required"` - // Additional details about the test. - Description string `json:"description"` - JSON zeroTrustDeviceDEXTestUpdateResponseJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestUpdateResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceDEXTestUpdateResponse] -type zeroTrustDeviceDEXTestUpdateResponseJSON struct { - Data apijson.Field - Enabled apijson.Field - Interval apijson.Field - Name apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// The configuration object which contains the details for the WARP client to -// conduct the test. -type ZeroTrustDeviceDEXTestUpdateResponseData struct { - // The desired endpoint to test. - Host string `json:"host"` - // The type of test. - Kind string `json:"kind"` - // The HTTP request method type. - Method string `json:"method"` - JSON zeroTrustDeviceDEXTestUpdateResponseDataJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestUpdateResponseDataJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceDEXTestUpdateResponseData] -type zeroTrustDeviceDEXTestUpdateResponseDataJSON struct { - Host apijson.Field - Kind apijson.Field - Method apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestUpdateResponseData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestUpdateResponseDataJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceDEXTestListResponse struct { - // The configuration object which contains the details for the WARP client to - // conduct the test. - Data ZeroTrustDeviceDEXTestListResponseData `json:"data,required"` - // Determines whether or not the test is active. - Enabled bool `json:"enabled,required"` - // How often the test will run. - Interval string `json:"interval,required"` - // The name of the DEX test. Must be unique. - Name string `json:"name,required"` - // Additional details about the test. - Description string `json:"description"` - JSON zeroTrustDeviceDEXTestListResponseJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestListResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDeviceDEXTestListResponse] -type zeroTrustDeviceDEXTestListResponseJSON struct { - Data apijson.Field - Enabled apijson.Field - Interval apijson.Field - Name apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestListResponseJSON) RawJSON() string { - return r.raw -} - -// The configuration object which contains the details for the WARP client to -// conduct the test. -type ZeroTrustDeviceDEXTestListResponseData struct { - // The desired endpoint to test. - Host string `json:"host"` - // The type of test. - Kind string `json:"kind"` - // The HTTP request method type. - Method string `json:"method"` - JSON zeroTrustDeviceDEXTestListResponseDataJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestListResponseDataJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceDEXTestListResponseData] -type zeroTrustDeviceDEXTestListResponseDataJSON struct { - Host apijson.Field - Kind apijson.Field - Method apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestListResponseData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestListResponseDataJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceDEXTestDeleteResponse struct { - // The configuration object which contains the details for the WARP client to - // conduct the test. - Data ZeroTrustDeviceDEXTestDeleteResponseData `json:"data,required"` - // Determines whether or not the test is active. - Enabled bool `json:"enabled,required"` - // How often the test will run. - Interval string `json:"interval,required"` - // The name of the DEX test. Must be unique. - Name string `json:"name,required"` - // Additional details about the test. - Description string `json:"description"` - JSON zeroTrustDeviceDEXTestDeleteResponseJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestDeleteResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceDEXTestDeleteResponse] -type zeroTrustDeviceDEXTestDeleteResponseJSON struct { - Data apijson.Field - Enabled apijson.Field - Interval apijson.Field - Name apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// The configuration object which contains the details for the WARP client to -// conduct the test. -type ZeroTrustDeviceDEXTestDeleteResponseData struct { - // The desired endpoint to test. - Host string `json:"host"` - // The type of test. - Kind string `json:"kind"` - // The HTTP request method type. - Method string `json:"method"` - JSON zeroTrustDeviceDEXTestDeleteResponseDataJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestDeleteResponseDataJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceDEXTestDeleteResponseData] -type zeroTrustDeviceDEXTestDeleteResponseDataJSON struct { - Host apijson.Field - Kind apijson.Field - Method apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestDeleteResponseData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestDeleteResponseDataJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceDEXTestGetResponse struct { - // The configuration object which contains the details for the WARP client to - // conduct the test. - Data ZeroTrustDeviceDEXTestGetResponseData `json:"data,required"` - // Determines whether or not the test is active. - Enabled bool `json:"enabled,required"` - // How often the test will run. - Interval string `json:"interval,required"` - // The name of the DEX test. Must be unique. - Name string `json:"name,required"` - // Additional details about the test. - Description string `json:"description"` - JSON zeroTrustDeviceDEXTestGetResponseJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestGetResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDeviceDEXTestGetResponse] -type zeroTrustDeviceDEXTestGetResponseJSON struct { - Data apijson.Field - Enabled apijson.Field - Interval apijson.Field - Name apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestGetResponseJSON) RawJSON() string { - return r.raw -} - -// The configuration object which contains the details for the WARP client to -// conduct the test. -type ZeroTrustDeviceDEXTestGetResponseData struct { - // The desired endpoint to test. - Host string `json:"host"` - // The type of test. - Kind string `json:"kind"` - // The HTTP request method type. - Method string `json:"method"` - JSON zeroTrustDeviceDEXTestGetResponseDataJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestGetResponseDataJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceDEXTestGetResponseData] -type zeroTrustDeviceDEXTestGetResponseDataJSON struct { - Host apijson.Field - Kind apijson.Field - Method apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestGetResponseData) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestGetResponseDataJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceDEXTestNewParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // The configuration object which contains the details for the WARP client to - // conduct the test. - Data param.Field[ZeroTrustDeviceDEXTestNewParamsData] `json:"data,required"` - // Determines whether or not the test is active. - Enabled param.Field[bool] `json:"enabled,required"` - // How often the test will run. - Interval param.Field[string] `json:"interval,required"` - // The name of the DEX test. Must be unique. - Name param.Field[string] `json:"name,required"` - // Additional details about the test. - Description param.Field[string] `json:"description"` -} - -func (r ZeroTrustDeviceDEXTestNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The configuration object which contains the details for the WARP client to -// conduct the test. -type ZeroTrustDeviceDEXTestNewParamsData struct { - // The desired endpoint to test. - Host param.Field[string] `json:"host"` - // The type of test. - Kind param.Field[string] `json:"kind"` - // The HTTP request method type. - Method param.Field[string] `json:"method"` -} - -func (r ZeroTrustDeviceDEXTestNewParamsData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDeviceDEXTestNewResponseEnvelope struct { - Errors []ZeroTrustDeviceDEXTestNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDeviceDEXTestNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDeviceDEXTestNewResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDeviceDEXTestNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDeviceDEXTestNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceDEXTestNewResponseEnvelope] -type zeroTrustDeviceDEXTestNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceDEXTestNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceDEXTestNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDeviceDEXTestNewResponseEnvelopeErrors] -type zeroTrustDeviceDEXTestNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceDEXTestNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceDEXTestNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDeviceDEXTestNewResponseEnvelopeMessages] -type zeroTrustDeviceDEXTestNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDeviceDEXTestNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustDeviceDEXTestNewResponseEnvelopeSuccessTrue ZeroTrustDeviceDEXTestNewResponseEnvelopeSuccess = true -) - -type ZeroTrustDeviceDEXTestUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // The configuration object which contains the details for the WARP client to - // conduct the test. - Data param.Field[ZeroTrustDeviceDEXTestUpdateParamsData] `json:"data,required"` - // Determines whether or not the test is active. - Enabled param.Field[bool] `json:"enabled,required"` - // How often the test will run. - Interval param.Field[string] `json:"interval,required"` - // The name of the DEX test. Must be unique. - Name param.Field[string] `json:"name,required"` - // Additional details about the test. - Description param.Field[string] `json:"description"` -} - -func (r ZeroTrustDeviceDEXTestUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The configuration object which contains the details for the WARP client to -// conduct the test. -type ZeroTrustDeviceDEXTestUpdateParamsData struct { - // The desired endpoint to test. - Host param.Field[string] `json:"host"` - // The type of test. - Kind param.Field[string] `json:"kind"` - // The HTTP request method type. - Method param.Field[string] `json:"method"` -} - -func (r ZeroTrustDeviceDEXTestUpdateParamsData) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDeviceDEXTestUpdateResponseEnvelope struct { - Errors []ZeroTrustDeviceDEXTestUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDeviceDEXTestUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDeviceDEXTestUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDeviceDEXTestUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDeviceDEXTestUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDeviceDEXTestUpdateResponseEnvelope] -type zeroTrustDeviceDEXTestUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceDEXTestUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceDEXTestUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDeviceDEXTestUpdateResponseEnvelopeErrors] -type zeroTrustDeviceDEXTestUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceDEXTestUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceDEXTestUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDeviceDEXTestUpdateResponseEnvelopeMessages] -type zeroTrustDeviceDEXTestUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDeviceDEXTestUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustDeviceDEXTestUpdateResponseEnvelopeSuccessTrue ZeroTrustDeviceDEXTestUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustDeviceDEXTestListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDeviceDEXTestListResponseEnvelope struct { - Errors []ZeroTrustDeviceDEXTestListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDeviceDEXTestListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDeviceDEXTestListResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDeviceDEXTestListResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDeviceDEXTestListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestListResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDeviceDEXTestListResponseEnvelope] -type zeroTrustDeviceDEXTestListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceDEXTestListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceDEXTestListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDeviceDEXTestListResponseEnvelopeErrors] -type zeroTrustDeviceDEXTestListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceDEXTestListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceDEXTestListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDeviceDEXTestListResponseEnvelopeMessages] -type zeroTrustDeviceDEXTestListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDeviceDEXTestListResponseEnvelopeSuccess bool - -const ( - ZeroTrustDeviceDEXTestListResponseEnvelopeSuccessTrue ZeroTrustDeviceDEXTestListResponseEnvelopeSuccess = true -) - -type ZeroTrustDeviceDEXTestDeleteParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDeviceDEXTestDeleteResponseEnvelope struct { - Errors []ZeroTrustDeviceDEXTestDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDeviceDEXTestDeleteResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDeviceDEXTestDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDeviceDEXTestDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDeviceDEXTestDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDeviceDEXTestDeleteResponseEnvelope] -type zeroTrustDeviceDEXTestDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceDEXTestDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceDEXTestDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDeviceDEXTestDeleteResponseEnvelopeErrors] -type zeroTrustDeviceDEXTestDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceDEXTestDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceDEXTestDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDeviceDEXTestDeleteResponseEnvelopeMessages] -type zeroTrustDeviceDEXTestDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDeviceDEXTestDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustDeviceDEXTestDeleteResponseEnvelopeSuccessTrue ZeroTrustDeviceDEXTestDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustDeviceDEXTestGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDeviceDEXTestGetResponseEnvelope struct { - Errors []ZeroTrustDeviceDEXTestGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDeviceDEXTestGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDeviceDEXTestGetResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDeviceDEXTestGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDeviceDEXTestGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceDEXTestGetResponseEnvelope] -type zeroTrustDeviceDEXTestGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceDEXTestGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceDEXTestGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDeviceDEXTestGetResponseEnvelopeErrors] -type zeroTrustDeviceDEXTestGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceDEXTestGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceDEXTestGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDeviceDEXTestGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDeviceDEXTestGetResponseEnvelopeMessages] -type zeroTrustDeviceDEXTestGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceDEXTestGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceDEXTestGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDeviceDEXTestGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustDeviceDEXTestGetResponseEnvelopeSuccessTrue ZeroTrustDeviceDEXTestGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustdevicedextest_test.go b/zerotrustdevicedextest_test.go deleted file mode 100644 index 77ac9763b0b..00000000000 --- a/zerotrustdevicedextest_test.go +++ /dev/null @@ -1,174 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDeviceDEXTestNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.DEXTests.New(context.TODO(), cloudflare.ZeroTrustDeviceDEXTestNewParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Data: cloudflare.F(cloudflare.ZeroTrustDeviceDEXTestNewParamsData{ - Host: cloudflare.F("https://dash.cloudflare.com"), - Kind: cloudflare.F("http"), - Method: cloudflare.F("GET"), - }), - Enabled: cloudflare.F(true), - Interval: cloudflare.F("30m"), - Name: cloudflare.F("HTTP dash health check"), - Description: cloudflare.F("Checks the dash endpoint every 30 minutes"), - }) - 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 TestZeroTrustDeviceDEXTestUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.DEXTests.Update( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDeviceDEXTestUpdateParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Data: cloudflare.F(cloudflare.ZeroTrustDeviceDEXTestUpdateParamsData{ - Host: cloudflare.F("https://dash.cloudflare.com"), - Kind: cloudflare.F("http"), - Method: cloudflare.F("GET"), - }), - Enabled: cloudflare.F(true), - Interval: cloudflare.F("30m"), - Name: cloudflare.F("HTTP dash health check"), - Description: cloudflare.F("Checks the dash endpoint every 30 minutes"), - }, - ) - 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 TestZeroTrustDeviceDEXTestList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.DEXTests.List(context.TODO(), cloudflare.ZeroTrustDeviceDEXTestListParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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 TestZeroTrustDeviceDEXTestDelete(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.DEXTests.Delete( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDeviceDEXTestDeleteParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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 TestZeroTrustDeviceDEXTestGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.DEXTests.Get( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDeviceDEXTestGetParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrustdevicenetwork.go b/zerotrustdevicenetwork.go deleted file mode 100644 index bb6d453c630..00000000000 --- a/zerotrustdevicenetwork.go +++ /dev/null @@ -1,1002 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDeviceNetworkService 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 [NewZeroTrustDeviceNetworkService] -// method instead. -type ZeroTrustDeviceNetworkService struct { - Options []option.RequestOption -} - -// NewZeroTrustDeviceNetworkService 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 NewZeroTrustDeviceNetworkService(opts ...option.RequestOption) (r *ZeroTrustDeviceNetworkService) { - r = &ZeroTrustDeviceNetworkService{} - r.Options = opts - return -} - -// Creates a new device managed network. -func (r *ZeroTrustDeviceNetworkService) New(ctx context.Context, params ZeroTrustDeviceNetworkNewParams, opts ...option.RequestOption) (res *ZeroTrustDeviceNetworkNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDeviceNetworkNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/networks", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a configured device managed network. -func (r *ZeroTrustDeviceNetworkService) Update(ctx context.Context, networkID string, params ZeroTrustDeviceNetworkUpdateParams, opts ...option.RequestOption) (res *ZeroTrustDeviceNetworkUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDeviceNetworkUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/networks/%s", params.AccountID, networkID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a list of managed networks for an account. -func (r *ZeroTrustDeviceNetworkService) List(ctx context.Context, query ZeroTrustDeviceNetworkListParams, opts ...option.RequestOption) (res *[]ZeroTrustDeviceNetworkListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDeviceNetworkListResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/networks", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a device managed network and fetches a list of the remaining device -// managed networks for an account. -func (r *ZeroTrustDeviceNetworkService) Delete(ctx context.Context, networkID string, body ZeroTrustDeviceNetworkDeleteParams, opts ...option.RequestOption) (res *[]ZeroTrustDeviceNetworkDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDeviceNetworkDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/networks/%s", body.AccountID, networkID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches details for a single managed network. -func (r *ZeroTrustDeviceNetworkService) Get(ctx context.Context, networkID string, query ZeroTrustDeviceNetworkGetParams, opts ...option.RequestOption) (res *ZeroTrustDeviceNetworkGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDeviceNetworkGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/networks/%s", query.AccountID, networkID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDeviceNetworkNewResponse struct { - // The configuration object containing information for the WARP client to detect - // the managed network. - Config ZeroTrustDeviceNetworkNewResponseConfig `json:"config"` - // The name of the device managed network. This name must be unique. - Name string `json:"name"` - // API UUID. - NetworkID string `json:"network_id"` - // The type of device managed network. - Type ZeroTrustDeviceNetworkNewResponseType `json:"type"` - JSON zeroTrustDeviceNetworkNewResponseJSON `json:"-"` -} - -// zeroTrustDeviceNetworkNewResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDeviceNetworkNewResponse] -type zeroTrustDeviceNetworkNewResponseJSON struct { - Config apijson.Field - Name apijson.Field - NetworkID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkNewResponseJSON) RawJSON() string { - return r.raw -} - -// The configuration object containing information for the WARP client to detect -// the managed network. -type ZeroTrustDeviceNetworkNewResponseConfig struct { - // A network address of the form "host:port" that the WARP client will use to - // detect the presence of a TLS host. - TLSSockaddr string `json:"tls_sockaddr,required"` - // The SHA-256 hash of the TLS certificate presented by the host found at - // tls_sockaddr. If absent, regular certificate verification (trusted roots, valid - // timestamp, etc) will be used to validate the certificate. - Sha256 string `json:"sha256"` - JSON zeroTrustDeviceNetworkNewResponseConfigJSON `json:"-"` -} - -// zeroTrustDeviceNetworkNewResponseConfigJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceNetworkNewResponseConfig] -type zeroTrustDeviceNetworkNewResponseConfigJSON struct { - TLSSockaddr apijson.Field - Sha256 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkNewResponseConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkNewResponseConfigJSON) RawJSON() string { - return r.raw -} - -// The type of device managed network. -type ZeroTrustDeviceNetworkNewResponseType string - -const ( - ZeroTrustDeviceNetworkNewResponseTypeTLS ZeroTrustDeviceNetworkNewResponseType = "tls" -) - -type ZeroTrustDeviceNetworkUpdateResponse struct { - // The configuration object containing information for the WARP client to detect - // the managed network. - Config ZeroTrustDeviceNetworkUpdateResponseConfig `json:"config"` - // The name of the device managed network. This name must be unique. - Name string `json:"name"` - // API UUID. - NetworkID string `json:"network_id"` - // The type of device managed network. - Type ZeroTrustDeviceNetworkUpdateResponseType `json:"type"` - JSON zeroTrustDeviceNetworkUpdateResponseJSON `json:"-"` -} - -// zeroTrustDeviceNetworkUpdateResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceNetworkUpdateResponse] -type zeroTrustDeviceNetworkUpdateResponseJSON struct { - Config apijson.Field - Name apijson.Field - NetworkID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// The configuration object containing information for the WARP client to detect -// the managed network. -type ZeroTrustDeviceNetworkUpdateResponseConfig struct { - // A network address of the form "host:port" that the WARP client will use to - // detect the presence of a TLS host. - TLSSockaddr string `json:"tls_sockaddr,required"` - // The SHA-256 hash of the TLS certificate presented by the host found at - // tls_sockaddr. If absent, regular certificate verification (trusted roots, valid - // timestamp, etc) will be used to validate the certificate. - Sha256 string `json:"sha256"` - JSON zeroTrustDeviceNetworkUpdateResponseConfigJSON `json:"-"` -} - -// zeroTrustDeviceNetworkUpdateResponseConfigJSON contains the JSON metadata for -// the struct [ZeroTrustDeviceNetworkUpdateResponseConfig] -type zeroTrustDeviceNetworkUpdateResponseConfigJSON struct { - TLSSockaddr apijson.Field - Sha256 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkUpdateResponseConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkUpdateResponseConfigJSON) RawJSON() string { - return r.raw -} - -// The type of device managed network. -type ZeroTrustDeviceNetworkUpdateResponseType string - -const ( - ZeroTrustDeviceNetworkUpdateResponseTypeTLS ZeroTrustDeviceNetworkUpdateResponseType = "tls" -) - -type ZeroTrustDeviceNetworkListResponse struct { - // The configuration object containing information for the WARP client to detect - // the managed network. - Config ZeroTrustDeviceNetworkListResponseConfig `json:"config"` - // The name of the device managed network. This name must be unique. - Name string `json:"name"` - // API UUID. - NetworkID string `json:"network_id"` - // The type of device managed network. - Type ZeroTrustDeviceNetworkListResponseType `json:"type"` - JSON zeroTrustDeviceNetworkListResponseJSON `json:"-"` -} - -// zeroTrustDeviceNetworkListResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDeviceNetworkListResponse] -type zeroTrustDeviceNetworkListResponseJSON struct { - Config apijson.Field - Name apijson.Field - NetworkID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkListResponseJSON) RawJSON() string { - return r.raw -} - -// The configuration object containing information for the WARP client to detect -// the managed network. -type ZeroTrustDeviceNetworkListResponseConfig struct { - // A network address of the form "host:port" that the WARP client will use to - // detect the presence of a TLS host. - TLSSockaddr string `json:"tls_sockaddr,required"` - // The SHA-256 hash of the TLS certificate presented by the host found at - // tls_sockaddr. If absent, regular certificate verification (trusted roots, valid - // timestamp, etc) will be used to validate the certificate. - Sha256 string `json:"sha256"` - JSON zeroTrustDeviceNetworkListResponseConfigJSON `json:"-"` -} - -// zeroTrustDeviceNetworkListResponseConfigJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceNetworkListResponseConfig] -type zeroTrustDeviceNetworkListResponseConfigJSON struct { - TLSSockaddr apijson.Field - Sha256 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkListResponseConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkListResponseConfigJSON) RawJSON() string { - return r.raw -} - -// The type of device managed network. -type ZeroTrustDeviceNetworkListResponseType string - -const ( - ZeroTrustDeviceNetworkListResponseTypeTLS ZeroTrustDeviceNetworkListResponseType = "tls" -) - -type ZeroTrustDeviceNetworkDeleteResponse struct { - // The configuration object containing information for the WARP client to detect - // the managed network. - Config ZeroTrustDeviceNetworkDeleteResponseConfig `json:"config"` - // The name of the device managed network. This name must be unique. - Name string `json:"name"` - // API UUID. - NetworkID string `json:"network_id"` - // The type of device managed network. - Type ZeroTrustDeviceNetworkDeleteResponseType `json:"type"` - JSON zeroTrustDeviceNetworkDeleteResponseJSON `json:"-"` -} - -// zeroTrustDeviceNetworkDeleteResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceNetworkDeleteResponse] -type zeroTrustDeviceNetworkDeleteResponseJSON struct { - Config apijson.Field - Name apijson.Field - NetworkID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// The configuration object containing information for the WARP client to detect -// the managed network. -type ZeroTrustDeviceNetworkDeleteResponseConfig struct { - // A network address of the form "host:port" that the WARP client will use to - // detect the presence of a TLS host. - TLSSockaddr string `json:"tls_sockaddr,required"` - // The SHA-256 hash of the TLS certificate presented by the host found at - // tls_sockaddr. If absent, regular certificate verification (trusted roots, valid - // timestamp, etc) will be used to validate the certificate. - Sha256 string `json:"sha256"` - JSON zeroTrustDeviceNetworkDeleteResponseConfigJSON `json:"-"` -} - -// zeroTrustDeviceNetworkDeleteResponseConfigJSON contains the JSON metadata for -// the struct [ZeroTrustDeviceNetworkDeleteResponseConfig] -type zeroTrustDeviceNetworkDeleteResponseConfigJSON struct { - TLSSockaddr apijson.Field - Sha256 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkDeleteResponseConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkDeleteResponseConfigJSON) RawJSON() string { - return r.raw -} - -// The type of device managed network. -type ZeroTrustDeviceNetworkDeleteResponseType string - -const ( - ZeroTrustDeviceNetworkDeleteResponseTypeTLS ZeroTrustDeviceNetworkDeleteResponseType = "tls" -) - -type ZeroTrustDeviceNetworkGetResponse struct { - // The configuration object containing information for the WARP client to detect - // the managed network. - Config ZeroTrustDeviceNetworkGetResponseConfig `json:"config"` - // The name of the device managed network. This name must be unique. - Name string `json:"name"` - // API UUID. - NetworkID string `json:"network_id"` - // The type of device managed network. - Type ZeroTrustDeviceNetworkGetResponseType `json:"type"` - JSON zeroTrustDeviceNetworkGetResponseJSON `json:"-"` -} - -// zeroTrustDeviceNetworkGetResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDeviceNetworkGetResponse] -type zeroTrustDeviceNetworkGetResponseJSON struct { - Config apijson.Field - Name apijson.Field - NetworkID apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkGetResponseJSON) RawJSON() string { - return r.raw -} - -// The configuration object containing information for the WARP client to detect -// the managed network. -type ZeroTrustDeviceNetworkGetResponseConfig struct { - // A network address of the form "host:port" that the WARP client will use to - // detect the presence of a TLS host. - TLSSockaddr string `json:"tls_sockaddr,required"` - // The SHA-256 hash of the TLS certificate presented by the host found at - // tls_sockaddr. If absent, regular certificate verification (trusted roots, valid - // timestamp, etc) will be used to validate the certificate. - Sha256 string `json:"sha256"` - JSON zeroTrustDeviceNetworkGetResponseConfigJSON `json:"-"` -} - -// zeroTrustDeviceNetworkGetResponseConfigJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceNetworkGetResponseConfig] -type zeroTrustDeviceNetworkGetResponseConfigJSON struct { - TLSSockaddr apijson.Field - Sha256 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkGetResponseConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkGetResponseConfigJSON) RawJSON() string { - return r.raw -} - -// The type of device managed network. -type ZeroTrustDeviceNetworkGetResponseType string - -const ( - ZeroTrustDeviceNetworkGetResponseTypeTLS ZeroTrustDeviceNetworkGetResponseType = "tls" -) - -type ZeroTrustDeviceNetworkNewParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // The configuration object containing information for the WARP client to detect - // the managed network. - Config param.Field[ZeroTrustDeviceNetworkNewParamsConfig] `json:"config,required"` - // The name of the device managed network. This name must be unique. - Name param.Field[string] `json:"name,required"` - // The type of device managed network. - Type param.Field[ZeroTrustDeviceNetworkNewParamsType] `json:"type,required"` -} - -func (r ZeroTrustDeviceNetworkNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The configuration object containing information for the WARP client to detect -// the managed network. -type ZeroTrustDeviceNetworkNewParamsConfig struct { - // A network address of the form "host:port" that the WARP client will use to - // detect the presence of a TLS host. - TLSSockaddr param.Field[string] `json:"tls_sockaddr,required"` - // The SHA-256 hash of the TLS certificate presented by the host found at - // tls_sockaddr. If absent, regular certificate verification (trusted roots, valid - // timestamp, etc) will be used to validate the certificate. - Sha256 param.Field[string] `json:"sha256"` -} - -func (r ZeroTrustDeviceNetworkNewParamsConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of device managed network. -type ZeroTrustDeviceNetworkNewParamsType string - -const ( - ZeroTrustDeviceNetworkNewParamsTypeTLS ZeroTrustDeviceNetworkNewParamsType = "tls" -) - -type ZeroTrustDeviceNetworkNewResponseEnvelope struct { - Errors []ZeroTrustDeviceNetworkNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDeviceNetworkNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDeviceNetworkNewResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDeviceNetworkNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDeviceNetworkNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDeviceNetworkNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceNetworkNewResponseEnvelope] -type zeroTrustDeviceNetworkNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceNetworkNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceNetworkNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDeviceNetworkNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDeviceNetworkNewResponseEnvelopeErrors] -type zeroTrustDeviceNetworkNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceNetworkNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceNetworkNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDeviceNetworkNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDeviceNetworkNewResponseEnvelopeMessages] -type zeroTrustDeviceNetworkNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDeviceNetworkNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustDeviceNetworkNewResponseEnvelopeSuccessTrue ZeroTrustDeviceNetworkNewResponseEnvelopeSuccess = true -) - -type ZeroTrustDeviceNetworkUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // The configuration object containing information for the WARP client to detect - // the managed network. - Config param.Field[ZeroTrustDeviceNetworkUpdateParamsConfig] `json:"config"` - // The name of the device managed network. This name must be unique. - Name param.Field[string] `json:"name"` - // The type of device managed network. - Type param.Field[ZeroTrustDeviceNetworkUpdateParamsType] `json:"type"` -} - -func (r ZeroTrustDeviceNetworkUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The configuration object containing information for the WARP client to detect -// the managed network. -type ZeroTrustDeviceNetworkUpdateParamsConfig struct { - // A network address of the form "host:port" that the WARP client will use to - // detect the presence of a TLS host. - TLSSockaddr param.Field[string] `json:"tls_sockaddr,required"` - // The SHA-256 hash of the TLS certificate presented by the host found at - // tls_sockaddr. If absent, regular certificate verification (trusted roots, valid - // timestamp, etc) will be used to validate the certificate. - Sha256 param.Field[string] `json:"sha256"` -} - -func (r ZeroTrustDeviceNetworkUpdateParamsConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of device managed network. -type ZeroTrustDeviceNetworkUpdateParamsType string - -const ( - ZeroTrustDeviceNetworkUpdateParamsTypeTLS ZeroTrustDeviceNetworkUpdateParamsType = "tls" -) - -type ZeroTrustDeviceNetworkUpdateResponseEnvelope struct { - Errors []ZeroTrustDeviceNetworkUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDeviceNetworkUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDeviceNetworkUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDeviceNetworkUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDeviceNetworkUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDeviceNetworkUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDeviceNetworkUpdateResponseEnvelope] -type zeroTrustDeviceNetworkUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceNetworkUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceNetworkUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDeviceNetworkUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDeviceNetworkUpdateResponseEnvelopeErrors] -type zeroTrustDeviceNetworkUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceNetworkUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceNetworkUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDeviceNetworkUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDeviceNetworkUpdateResponseEnvelopeMessages] -type zeroTrustDeviceNetworkUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDeviceNetworkUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustDeviceNetworkUpdateResponseEnvelopeSuccessTrue ZeroTrustDeviceNetworkUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustDeviceNetworkListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDeviceNetworkListResponseEnvelope struct { - Errors []ZeroTrustDeviceNetworkListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDeviceNetworkListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDeviceNetworkListResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDeviceNetworkListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDeviceNetworkListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDeviceNetworkListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDeviceNetworkListResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDeviceNetworkListResponseEnvelope] -type zeroTrustDeviceNetworkListResponseEnvelopeJSON 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 *ZeroTrustDeviceNetworkListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceNetworkListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceNetworkListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDeviceNetworkListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDeviceNetworkListResponseEnvelopeErrors] -type zeroTrustDeviceNetworkListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceNetworkListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceNetworkListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDeviceNetworkListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDeviceNetworkListResponseEnvelopeMessages] -type zeroTrustDeviceNetworkListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDeviceNetworkListResponseEnvelopeSuccess bool - -const ( - ZeroTrustDeviceNetworkListResponseEnvelopeSuccessTrue ZeroTrustDeviceNetworkListResponseEnvelopeSuccess = true -) - -type ZeroTrustDeviceNetworkListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDeviceNetworkListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDeviceNetworkListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustDeviceNetworkListResponseEnvelopeResultInfo] -type zeroTrustDeviceNetworkListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceNetworkDeleteParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDeviceNetworkDeleteResponseEnvelope struct { - Errors []ZeroTrustDeviceNetworkDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDeviceNetworkDeleteResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDeviceNetworkDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDeviceNetworkDeleteResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDeviceNetworkDeleteResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDeviceNetworkDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDeviceNetworkDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDeviceNetworkDeleteResponseEnvelope] -type zeroTrustDeviceNetworkDeleteResponseEnvelopeJSON 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 *ZeroTrustDeviceNetworkDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceNetworkDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceNetworkDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDeviceNetworkDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDeviceNetworkDeleteResponseEnvelopeErrors] -type zeroTrustDeviceNetworkDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceNetworkDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceNetworkDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDeviceNetworkDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDeviceNetworkDeleteResponseEnvelopeMessages] -type zeroTrustDeviceNetworkDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDeviceNetworkDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustDeviceNetworkDeleteResponseEnvelopeSuccessTrue ZeroTrustDeviceNetworkDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustDeviceNetworkDeleteResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDeviceNetworkDeleteResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDeviceNetworkDeleteResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustDeviceNetworkDeleteResponseEnvelopeResultInfo] -type zeroTrustDeviceNetworkDeleteResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceNetworkGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDeviceNetworkGetResponseEnvelope struct { - Errors []ZeroTrustDeviceNetworkGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDeviceNetworkGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDeviceNetworkGetResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDeviceNetworkGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDeviceNetworkGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDeviceNetworkGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceNetworkGetResponseEnvelope] -type zeroTrustDeviceNetworkGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceNetworkGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceNetworkGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDeviceNetworkGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDeviceNetworkGetResponseEnvelopeErrors] -type zeroTrustDeviceNetworkGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceNetworkGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceNetworkGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDeviceNetworkGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDeviceNetworkGetResponseEnvelopeMessages] -type zeroTrustDeviceNetworkGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceNetworkGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceNetworkGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDeviceNetworkGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustDeviceNetworkGetResponseEnvelopeSuccessTrue ZeroTrustDeviceNetworkGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustdevicenetwork_test.go b/zerotrustdevicenetwork_test.go deleted file mode 100644 index 40adacc5729..00000000000 --- a/zerotrustdevicenetwork_test.go +++ /dev/null @@ -1,168 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDeviceNetworkNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Networks.New(context.TODO(), cloudflare.ZeroTrustDeviceNetworkNewParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Config: cloudflare.F(cloudflare.ZeroTrustDeviceNetworkNewParamsConfig{ - Sha256: cloudflare.F("b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c"), - TLSSockaddr: cloudflare.F("foo.bar:1234"), - }), - Name: cloudflare.F("managed-network-1"), - Type: cloudflare.F(cloudflare.ZeroTrustDeviceNetworkNewParamsTypeTLS), - }) - 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 TestZeroTrustDeviceNetworkUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Networks.Update( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDeviceNetworkUpdateParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Config: cloudflare.F(cloudflare.ZeroTrustDeviceNetworkUpdateParamsConfig{ - Sha256: cloudflare.F("b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c"), - TLSSockaddr: cloudflare.F("foo.bar:1234"), - }), - Name: cloudflare.F("managed-network-1"), - Type: cloudflare.F(cloudflare.ZeroTrustDeviceNetworkUpdateParamsTypeTLS), - }, - ) - 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 TestZeroTrustDeviceNetworkList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Networks.List(context.TODO(), cloudflare.ZeroTrustDeviceNetworkListParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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 TestZeroTrustDeviceNetworkDelete(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Networks.Delete( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDeviceNetworkDeleteParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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 TestZeroTrustDeviceNetworkGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Networks.Get( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDeviceNetworkGetParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrustdeviceoverridecode.go b/zerotrustdeviceoverridecode.go deleted file mode 100644 index 7955d5578ce..00000000000 --- a/zerotrustdeviceoverridecode.go +++ /dev/null @@ -1,221 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDeviceOverrideCodeService 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 -// [NewZeroTrustDeviceOverrideCodeService] method instead. -type ZeroTrustDeviceOverrideCodeService struct { - Options []option.RequestOption -} - -// NewZeroTrustDeviceOverrideCodeService 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 NewZeroTrustDeviceOverrideCodeService(opts ...option.RequestOption) (r *ZeroTrustDeviceOverrideCodeService) { - r = &ZeroTrustDeviceOverrideCodeService{} - r.Options = opts - return -} - -// Fetches a one-time use admin override code for a device. This relies on the -// **Admin Override** setting being enabled in your device configuration. -func (r *ZeroTrustDeviceOverrideCodeService) List(ctx context.Context, deviceID string, query ZeroTrustDeviceOverrideCodeListParams, opts ...option.RequestOption) (res *ZeroTrustDeviceOverrideCodeListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDeviceOverrideCodeListResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/%s/override_codes", query.AccountID, deviceID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDeviceOverrideCodeListResponse struct { - DisableForTime ZeroTrustDeviceOverrideCodeListResponseDisableForTime `json:"disable_for_time"` - JSON zeroTrustDeviceOverrideCodeListResponseJSON `json:"-"` -} - -// zeroTrustDeviceOverrideCodeListResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceOverrideCodeListResponse] -type zeroTrustDeviceOverrideCodeListResponseJSON struct { - DisableForTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceOverrideCodeListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceOverrideCodeListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceOverrideCodeListResponseDisableForTime struct { - // Override code that is valid for 1 hour. - Number1 interface{} `json:"1"` - // Override code that is valid for 12 hour2. - Number12 interface{} `json:"12"` - // Override code that is valid for 24 hour.2. - Number24 interface{} `json:"24"` - // Override code that is valid for 3 hours. - Number3 interface{} `json:"3"` - // Override code that is valid for 6 hours. - Number6 interface{} `json:"6"` - JSON zeroTrustDeviceOverrideCodeListResponseDisableForTimeJSON `json:"-"` -} - -// zeroTrustDeviceOverrideCodeListResponseDisableForTimeJSON contains the JSON -// metadata for the struct [ZeroTrustDeviceOverrideCodeListResponseDisableForTime] -type zeroTrustDeviceOverrideCodeListResponseDisableForTimeJSON struct { - Number1 apijson.Field - Number12 apijson.Field - Number24 apijson.Field - Number3 apijson.Field - Number6 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceOverrideCodeListResponseDisableForTime) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceOverrideCodeListResponseDisableForTimeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceOverrideCodeListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDeviceOverrideCodeListResponseEnvelope struct { - Errors []ZeroTrustDeviceOverrideCodeListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDeviceOverrideCodeListResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDeviceOverrideCodeListResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDeviceOverrideCodeListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDeviceOverrideCodeListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDeviceOverrideCodeListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDeviceOverrideCodeListResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustDeviceOverrideCodeListResponseEnvelope] -type zeroTrustDeviceOverrideCodeListResponseEnvelopeJSON 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 *ZeroTrustDeviceOverrideCodeListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceOverrideCodeListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceOverrideCodeListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceOverrideCodeListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDeviceOverrideCodeListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDeviceOverrideCodeListResponseEnvelopeErrors] -type zeroTrustDeviceOverrideCodeListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceOverrideCodeListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceOverrideCodeListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceOverrideCodeListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceOverrideCodeListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDeviceOverrideCodeListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustDeviceOverrideCodeListResponseEnvelopeMessages] -type zeroTrustDeviceOverrideCodeListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceOverrideCodeListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceOverrideCodeListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDeviceOverrideCodeListResponseEnvelopeSuccess bool - -const ( - ZeroTrustDeviceOverrideCodeListResponseEnvelopeSuccessTrue ZeroTrustDeviceOverrideCodeListResponseEnvelopeSuccess = true -) - -type ZeroTrustDeviceOverrideCodeListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDeviceOverrideCodeListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDeviceOverrideCodeListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [ZeroTrustDeviceOverrideCodeListResponseEnvelopeResultInfo] -type zeroTrustDeviceOverrideCodeListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceOverrideCodeListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceOverrideCodeListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zerotrustdeviceoverridecode_test.go b/zerotrustdeviceoverridecode_test.go deleted file mode 100644 index e2b9f24864a..00000000000 --- a/zerotrustdeviceoverridecode_test.go +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDeviceOverrideCodeList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.OverrideCodes.List( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDeviceOverrideCodeListParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrustdevicepolicy.go b/zerotrustdevicepolicy.go deleted file mode 100644 index 878f38b1db0..00000000000 --- a/zerotrustdevicepolicy.go +++ /dev/null @@ -1,1215 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDevicePolicyService 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 [NewZeroTrustDevicePolicyService] -// method instead. -type ZeroTrustDevicePolicyService struct { - Options []option.RequestOption - DefaultPolicy *ZeroTrustDevicePolicyDefaultPolicyService - Excludes *ZeroTrustDevicePolicyExcludeService - FallbackDomains *ZeroTrustDevicePolicyFallbackDomainService - Includes *ZeroTrustDevicePolicyIncludeService -} - -// NewZeroTrustDevicePolicyService 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 NewZeroTrustDevicePolicyService(opts ...option.RequestOption) (r *ZeroTrustDevicePolicyService) { - r = &ZeroTrustDevicePolicyService{} - r.Options = opts - r.DefaultPolicy = NewZeroTrustDevicePolicyDefaultPolicyService(opts...) - r.Excludes = NewZeroTrustDevicePolicyExcludeService(opts...) - r.FallbackDomains = NewZeroTrustDevicePolicyFallbackDomainService(opts...) - r.Includes = NewZeroTrustDevicePolicyIncludeService(opts...) - return -} - -// Creates a device settings profile to be applied to certain devices matching the -// criteria. -func (r *ZeroTrustDevicePolicyService) New(ctx context.Context, params ZeroTrustDevicePolicyNewParams, opts ...option.RequestOption) (res *[]ZeroTrustDevicePolicyNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePolicyNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/policy", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a list of the device settings profiles for an account. -func (r *ZeroTrustDevicePolicyService) List(ctx context.Context, query ZeroTrustDevicePolicyListParams, opts ...option.RequestOption) (res *[]ZeroTrustDevicePolicyListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePolicyListResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/policies", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a device settings profile and fetches a list of the remaining profiles -// for an account. -func (r *ZeroTrustDevicePolicyService) Delete(ctx context.Context, policyID string, body ZeroTrustDevicePolicyDeleteParams, opts ...option.RequestOption) (res *[]ZeroTrustDevicePolicyDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePolicyDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/policy/%s", body.AccountID, policyID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a configured device settings profile. -func (r *ZeroTrustDevicePolicyService) Edit(ctx context.Context, policyID string, params ZeroTrustDevicePolicyEditParams, opts ...option.RequestOption) (res *[]ZeroTrustDevicePolicyEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePolicyEditResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/policy/%s", params.AccountID, policyID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a device settings profile by ID. -func (r *ZeroTrustDevicePolicyService) Get(ctx context.Context, policyID string, query ZeroTrustDevicePolicyGetParams, opts ...option.RequestOption) (res *[]ZeroTrustDevicePolicyGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePolicyGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/policy/%s", query.AccountID, policyID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDevicePolicyNewResponse = interface{} - -type ZeroTrustDevicePolicyListResponse struct { - // Whether to allow the user to switch WARP between modes. - AllowModeSwitch bool `json:"allow_mode_switch"` - // Whether to receive update notifications when a new version of the client is - // available. - AllowUpdates bool `json:"allow_updates"` - // Whether to allow devices to leave the organization. - AllowedToLeave bool `json:"allowed_to_leave"` - // The amount of time in minutes to reconnect after having been disabled. - AutoConnect float64 `json:"auto_connect"` - // Turn on the captive portal after the specified amount of time. - CaptivePortal float64 `json:"captive_portal"` - // Whether the policy is the default policy for an account. - Default bool `json:"default"` - // A description of the policy. - Description string `json:"description"` - // If the `dns_server` field of a fallback domain is not present, the client will - // fall back to a best guess of the default/system DNS resolvers unless this policy - // option is set to `true`. - DisableAutoFallback bool `json:"disable_auto_fallback"` - // Whether the policy will be applied to matching devices. - Enabled bool `json:"enabled"` - Exclude []ZeroTrustDevicePolicyListResponseExclude `json:"exclude"` - // Whether to add Microsoft IPs to Split Tunnel exclusions. - ExcludeOfficeIPs bool `json:"exclude_office_ips"` - FallbackDomains []ZeroTrustDevicePolicyListResponseFallbackDomain `json:"fallback_domains"` - GatewayUniqueID string `json:"gateway_unique_id"` - Include []ZeroTrustDevicePolicyListResponseInclude `json:"include"` - // The amount of time in minutes a user is allowed access to their LAN. A value of - // 0 will allow LAN access until the next WARP reconnection, such as a reboot or a - // laptop waking from sleep. Note that this field is omitted from the response if - // null or unset. - LanAllowMinutes float64 `json:"lan_allow_minutes"` - // The size of the subnet for the local access network. Note that this field is - // omitted from the response if null or unset. - LanAllowSubnetSize float64 `json:"lan_allow_subnet_size"` - // The wirefilter expression to match devices. - Match string `json:"match"` - // The name of the device settings profile. - Name string `json:"name"` - // Device ID. - PolicyID string `json:"policy_id"` - // The precedence of the policy. Lower values indicate higher precedence. Policies - // will be evaluated in ascending order of this field. - Precedence float64 `json:"precedence"` - ServiceModeV2 ZeroTrustDevicePolicyListResponseServiceModeV2 `json:"service_mode_v2"` - // The URL to launch when the Send Feedback button is clicked. - SupportURL string `json:"support_url"` - // Whether to allow the user to turn off the WARP switch and disconnect the client. - SwitchLocked bool `json:"switch_locked"` - JSON zeroTrustDevicePolicyListResponseJSON `json:"-"` -} - -// zeroTrustDevicePolicyListResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDevicePolicyListResponse] -type zeroTrustDevicePolicyListResponseJSON struct { - AllowModeSwitch apijson.Field - AllowUpdates apijson.Field - AllowedToLeave apijson.Field - AutoConnect apijson.Field - CaptivePortal apijson.Field - Default apijson.Field - Description apijson.Field - DisableAutoFallback apijson.Field - Enabled apijson.Field - Exclude apijson.Field - ExcludeOfficeIPs apijson.Field - FallbackDomains apijson.Field - GatewayUniqueID apijson.Field - Include apijson.Field - LanAllowMinutes apijson.Field - LanAllowSubnetSize apijson.Field - Match apijson.Field - Name apijson.Field - PolicyID apijson.Field - Precedence apijson.Field - ServiceModeV2 apijson.Field - SupportURL apijson.Field - SwitchLocked apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyListResponseExclude struct { - // The address in CIDR format to exclude from the tunnel. If `address` is present, - // `host` must not be present. - Address string `json:"address,required"` - // A description of the Split Tunnel item, displayed in the client UI. - Description string `json:"description,required"` - // The domain name to exclude from the tunnel. If `host` is present, `address` must - // not be present. - Host string `json:"host"` - JSON zeroTrustDevicePolicyListResponseExcludeJSON `json:"-"` -} - -// zeroTrustDevicePolicyListResponseExcludeJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePolicyListResponseExclude] -type zeroTrustDevicePolicyListResponseExcludeJSON struct { - Address apijson.Field - Description apijson.Field - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyListResponseExclude) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyListResponseExcludeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyListResponseFallbackDomain struct { - // The domain suffix to match when resolving locally. - Suffix string `json:"suffix,required"` - // A description of the fallback domain, displayed in the client UI. - Description string `json:"description"` - // A list of IP addresses to handle domain resolution. - DNSServer []interface{} `json:"dns_server"` - JSON zeroTrustDevicePolicyListResponseFallbackDomainJSON `json:"-"` -} - -// zeroTrustDevicePolicyListResponseFallbackDomainJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyListResponseFallbackDomain] -type zeroTrustDevicePolicyListResponseFallbackDomainJSON struct { - Suffix apijson.Field - Description apijson.Field - DNSServer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyListResponseFallbackDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyListResponseFallbackDomainJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyListResponseInclude struct { - // The address in CIDR format to include in the tunnel. If address is present, host - // must not be present. - Address string `json:"address,required"` - // A description of the split tunnel item, displayed in the client UI. - Description string `json:"description,required"` - // The domain name to include in the tunnel. If host is present, address must not - // be present. - Host string `json:"host"` - JSON zeroTrustDevicePolicyListResponseIncludeJSON `json:"-"` -} - -// zeroTrustDevicePolicyListResponseIncludeJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePolicyListResponseInclude] -type zeroTrustDevicePolicyListResponseIncludeJSON struct { - Address apijson.Field - Description apijson.Field - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyListResponseInclude) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyListResponseIncludeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyListResponseServiceModeV2 struct { - // The mode to run the WARP client under. - Mode string `json:"mode"` - // The port number when used with proxy mode. - Port float64 `json:"port"` - JSON zeroTrustDevicePolicyListResponseServiceModeV2JSON `json:"-"` -} - -// zeroTrustDevicePolicyListResponseServiceModeV2JSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyListResponseServiceModeV2] -type zeroTrustDevicePolicyListResponseServiceModeV2JSON struct { - Mode apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyListResponseServiceModeV2) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyListResponseServiceModeV2JSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyDeleteResponse struct { - // Whether to allow the user to switch WARP between modes. - AllowModeSwitch bool `json:"allow_mode_switch"` - // Whether to receive update notifications when a new version of the client is - // available. - AllowUpdates bool `json:"allow_updates"` - // Whether to allow devices to leave the organization. - AllowedToLeave bool `json:"allowed_to_leave"` - // The amount of time in minutes to reconnect after having been disabled. - AutoConnect float64 `json:"auto_connect"` - // Turn on the captive portal after the specified amount of time. - CaptivePortal float64 `json:"captive_portal"` - // Whether the policy is the default policy for an account. - Default bool `json:"default"` - // A description of the policy. - Description string `json:"description"` - // If the `dns_server` field of a fallback domain is not present, the client will - // fall back to a best guess of the default/system DNS resolvers unless this policy - // option is set to `true`. - DisableAutoFallback bool `json:"disable_auto_fallback"` - // Whether the policy will be applied to matching devices. - Enabled bool `json:"enabled"` - Exclude []ZeroTrustDevicePolicyDeleteResponseExclude `json:"exclude"` - // Whether to add Microsoft IPs to Split Tunnel exclusions. - ExcludeOfficeIPs bool `json:"exclude_office_ips"` - FallbackDomains []ZeroTrustDevicePolicyDeleteResponseFallbackDomain `json:"fallback_domains"` - GatewayUniqueID string `json:"gateway_unique_id"` - Include []ZeroTrustDevicePolicyDeleteResponseInclude `json:"include"` - // The amount of time in minutes a user is allowed access to their LAN. A value of - // 0 will allow LAN access until the next WARP reconnection, such as a reboot or a - // laptop waking from sleep. Note that this field is omitted from the response if - // null or unset. - LanAllowMinutes float64 `json:"lan_allow_minutes"` - // The size of the subnet for the local access network. Note that this field is - // omitted from the response if null or unset. - LanAllowSubnetSize float64 `json:"lan_allow_subnet_size"` - // The wirefilter expression to match devices. - Match string `json:"match"` - // The name of the device settings profile. - Name string `json:"name"` - // Device ID. - PolicyID string `json:"policy_id"` - // The precedence of the policy. Lower values indicate higher precedence. Policies - // will be evaluated in ascending order of this field. - Precedence float64 `json:"precedence"` - ServiceModeV2 ZeroTrustDevicePolicyDeleteResponseServiceModeV2 `json:"service_mode_v2"` - // The URL to launch when the Send Feedback button is clicked. - SupportURL string `json:"support_url"` - // Whether to allow the user to turn off the WARP switch and disconnect the client. - SwitchLocked bool `json:"switch_locked"` - JSON zeroTrustDevicePolicyDeleteResponseJSON `json:"-"` -} - -// zeroTrustDevicePolicyDeleteResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePolicyDeleteResponse] -type zeroTrustDevicePolicyDeleteResponseJSON struct { - AllowModeSwitch apijson.Field - AllowUpdates apijson.Field - AllowedToLeave apijson.Field - AutoConnect apijson.Field - CaptivePortal apijson.Field - Default apijson.Field - Description apijson.Field - DisableAutoFallback apijson.Field - Enabled apijson.Field - Exclude apijson.Field - ExcludeOfficeIPs apijson.Field - FallbackDomains apijson.Field - GatewayUniqueID apijson.Field - Include apijson.Field - LanAllowMinutes apijson.Field - LanAllowSubnetSize apijson.Field - Match apijson.Field - Name apijson.Field - PolicyID apijson.Field - Precedence apijson.Field - ServiceModeV2 apijson.Field - SupportURL apijson.Field - SwitchLocked apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyDeleteResponseExclude struct { - // The address in CIDR format to exclude from the tunnel. If `address` is present, - // `host` must not be present. - Address string `json:"address,required"` - // A description of the Split Tunnel item, displayed in the client UI. - Description string `json:"description,required"` - // The domain name to exclude from the tunnel. If `host` is present, `address` must - // not be present. - Host string `json:"host"` - JSON zeroTrustDevicePolicyDeleteResponseExcludeJSON `json:"-"` -} - -// zeroTrustDevicePolicyDeleteResponseExcludeJSON contains the JSON metadata for -// the struct [ZeroTrustDevicePolicyDeleteResponseExclude] -type zeroTrustDevicePolicyDeleteResponseExcludeJSON struct { - Address apijson.Field - Description apijson.Field - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyDeleteResponseExclude) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyDeleteResponseExcludeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyDeleteResponseFallbackDomain struct { - // The domain suffix to match when resolving locally. - Suffix string `json:"suffix,required"` - // A description of the fallback domain, displayed in the client UI. - Description string `json:"description"` - // A list of IP addresses to handle domain resolution. - DNSServer []interface{} `json:"dns_server"` - JSON zeroTrustDevicePolicyDeleteResponseFallbackDomainJSON `json:"-"` -} - -// zeroTrustDevicePolicyDeleteResponseFallbackDomainJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyDeleteResponseFallbackDomain] -type zeroTrustDevicePolicyDeleteResponseFallbackDomainJSON struct { - Suffix apijson.Field - Description apijson.Field - DNSServer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyDeleteResponseFallbackDomain) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyDeleteResponseFallbackDomainJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyDeleteResponseInclude struct { - // The address in CIDR format to include in the tunnel. If address is present, host - // must not be present. - Address string `json:"address,required"` - // A description of the split tunnel item, displayed in the client UI. - Description string `json:"description,required"` - // The domain name to include in the tunnel. If host is present, address must not - // be present. - Host string `json:"host"` - JSON zeroTrustDevicePolicyDeleteResponseIncludeJSON `json:"-"` -} - -// zeroTrustDevicePolicyDeleteResponseIncludeJSON contains the JSON metadata for -// the struct [ZeroTrustDevicePolicyDeleteResponseInclude] -type zeroTrustDevicePolicyDeleteResponseIncludeJSON struct { - Address apijson.Field - Description apijson.Field - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyDeleteResponseInclude) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyDeleteResponseIncludeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyDeleteResponseServiceModeV2 struct { - // The mode to run the WARP client under. - Mode string `json:"mode"` - // The port number when used with proxy mode. - Port float64 `json:"port"` - JSON zeroTrustDevicePolicyDeleteResponseServiceModeV2JSON `json:"-"` -} - -// zeroTrustDevicePolicyDeleteResponseServiceModeV2JSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyDeleteResponseServiceModeV2] -type zeroTrustDevicePolicyDeleteResponseServiceModeV2JSON struct { - Mode apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyDeleteResponseServiceModeV2) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyDeleteResponseServiceModeV2JSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyEditResponse = interface{} - -type ZeroTrustDevicePolicyGetResponse = interface{} - -type ZeroTrustDevicePolicyNewParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // The wirefilter expression to match devices. - Match param.Field[string] `json:"match,required"` - // The name of the device settings profile. - Name param.Field[string] `json:"name,required"` - // The precedence of the policy. Lower values indicate higher precedence. Policies - // will be evaluated in ascending order of this field. - Precedence param.Field[float64] `json:"precedence,required"` - // Whether to allow the user to switch WARP between modes. - AllowModeSwitch param.Field[bool] `json:"allow_mode_switch"` - // Whether to receive update notifications when a new version of the client is - // available. - AllowUpdates param.Field[bool] `json:"allow_updates"` - // Whether to allow devices to leave the organization. - AllowedToLeave param.Field[bool] `json:"allowed_to_leave"` - // The amount of time in minutes to reconnect after having been disabled. - AutoConnect param.Field[float64] `json:"auto_connect"` - // Turn on the captive portal after the specified amount of time. - CaptivePortal param.Field[float64] `json:"captive_portal"` - // A description of the policy. - Description param.Field[string] `json:"description"` - // If the `dns_server` field of a fallback domain is not present, the client will - // fall back to a best guess of the default/system DNS resolvers unless this policy - // option is set to `true`. - DisableAutoFallback param.Field[bool] `json:"disable_auto_fallback"` - // Whether the policy will be applied to matching devices. - Enabled param.Field[bool] `json:"enabled"` - // Whether to add Microsoft IPs to Split Tunnel exclusions. - ExcludeOfficeIPs param.Field[bool] `json:"exclude_office_ips"` - // The amount of time in minutes a user is allowed access to their LAN. A value of - // 0 will allow LAN access until the next WARP reconnection, such as a reboot or a - // laptop waking from sleep. Note that this field is omitted from the response if - // null or unset. - LanAllowMinutes param.Field[float64] `json:"lan_allow_minutes"` - // The size of the subnet for the local access network. Note that this field is - // omitted from the response if null or unset. - LanAllowSubnetSize param.Field[float64] `json:"lan_allow_subnet_size"` - ServiceModeV2 param.Field[ZeroTrustDevicePolicyNewParamsServiceModeV2] `json:"service_mode_v2"` - // The URL to launch when the Send Feedback button is clicked. - SupportURL param.Field[string] `json:"support_url"` - // Whether to allow the user to turn off the WARP switch and disconnect the client. - SwitchLocked param.Field[bool] `json:"switch_locked"` -} - -func (r ZeroTrustDevicePolicyNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDevicePolicyNewParamsServiceModeV2 struct { - // The mode to run the WARP client under. - Mode param.Field[string] `json:"mode"` - // The port number when used with proxy mode. - Port param.Field[float64] `json:"port"` -} - -func (r ZeroTrustDevicePolicyNewParamsServiceModeV2) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDevicePolicyNewResponseEnvelope struct { - Errors []ZeroTrustDevicePolicyNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePolicyNewResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDevicePolicyNewResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePolicyNewResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDevicePolicyNewResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDevicePolicyNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePolicyNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePolicyNewResponseEnvelope] -type zeroTrustDevicePolicyNewResponseEnvelopeJSON 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 *ZeroTrustDevicePolicyNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePolicyNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyNewResponseEnvelopeErrors] -type zeroTrustDevicePolicyNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePolicyNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyNewResponseEnvelopeMessages] -type zeroTrustDevicePolicyNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePolicyNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePolicyNewResponseEnvelopeSuccessTrue ZeroTrustDevicePolicyNewResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePolicyNewResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDevicePolicyNewResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDevicePolicyNewResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePolicyNewResponseEnvelopeResultInfo] -type zeroTrustDevicePolicyNewResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyNewResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDevicePolicyListResponseEnvelope struct { - Errors []ZeroTrustDevicePolicyListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePolicyListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDevicePolicyListResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePolicyListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDevicePolicyListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDevicePolicyListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePolicyListResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePolicyListResponseEnvelope] -type zeroTrustDevicePolicyListResponseEnvelopeJSON 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 *ZeroTrustDevicePolicyListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePolicyListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyListResponseEnvelopeErrors] -type zeroTrustDevicePolicyListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePolicyListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyListResponseEnvelopeMessages] -type zeroTrustDevicePolicyListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePolicyListResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePolicyListResponseEnvelopeSuccessTrue ZeroTrustDevicePolicyListResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePolicyListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDevicePolicyListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDevicePolicyListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePolicyListResponseEnvelopeResultInfo] -type zeroTrustDevicePolicyListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyDeleteParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDevicePolicyDeleteResponseEnvelope struct { - Errors []ZeroTrustDevicePolicyDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePolicyDeleteResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDevicePolicyDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePolicyDeleteResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDevicePolicyDeleteResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDevicePolicyDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePolicyDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDevicePolicyDeleteResponseEnvelope] -type zeroTrustDevicePolicyDeleteResponseEnvelopeJSON 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 *ZeroTrustDevicePolicyDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePolicyDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyDeleteResponseEnvelopeErrors] -type zeroTrustDevicePolicyDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePolicyDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePolicyDeleteResponseEnvelopeMessages] -type zeroTrustDevicePolicyDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePolicyDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePolicyDeleteResponseEnvelopeSuccessTrue ZeroTrustDevicePolicyDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePolicyDeleteResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDevicePolicyDeleteResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDevicePolicyDeleteResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePolicyDeleteResponseEnvelopeResultInfo] -type zeroTrustDevicePolicyDeleteResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyDeleteResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyDeleteResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyEditParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // Whether to allow the user to switch WARP between modes. - AllowModeSwitch param.Field[bool] `json:"allow_mode_switch"` - // Whether to receive update notifications when a new version of the client is - // available. - AllowUpdates param.Field[bool] `json:"allow_updates"` - // Whether to allow devices to leave the organization. - AllowedToLeave param.Field[bool] `json:"allowed_to_leave"` - // The amount of time in minutes to reconnect after having been disabled. - AutoConnect param.Field[float64] `json:"auto_connect"` - // Turn on the captive portal after the specified amount of time. - CaptivePortal param.Field[float64] `json:"captive_portal"` - // A description of the policy. - Description param.Field[string] `json:"description"` - // If the `dns_server` field of a fallback domain is not present, the client will - // fall back to a best guess of the default/system DNS resolvers unless this policy - // option is set to `true`. - DisableAutoFallback param.Field[bool] `json:"disable_auto_fallback"` - // Whether the policy will be applied to matching devices. - Enabled param.Field[bool] `json:"enabled"` - // Whether to add Microsoft IPs to Split Tunnel exclusions. - ExcludeOfficeIPs param.Field[bool] `json:"exclude_office_ips"` - // The wirefilter expression to match devices. - Match param.Field[string] `json:"match"` - // The name of the device settings profile. - Name param.Field[string] `json:"name"` - // The precedence of the policy. Lower values indicate higher precedence. Policies - // will be evaluated in ascending order of this field. - Precedence param.Field[float64] `json:"precedence"` - ServiceModeV2 param.Field[ZeroTrustDevicePolicyEditParamsServiceModeV2] `json:"service_mode_v2"` - // The URL to launch when the Send Feedback button is clicked. - SupportURL param.Field[string] `json:"support_url"` - // Whether to allow the user to turn off the WARP switch and disconnect the client. - SwitchLocked param.Field[bool] `json:"switch_locked"` -} - -func (r ZeroTrustDevicePolicyEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDevicePolicyEditParamsServiceModeV2 struct { - // The mode to run the WARP client under. - Mode param.Field[string] `json:"mode"` - // The port number when used with proxy mode. - Port param.Field[float64] `json:"port"` -} - -func (r ZeroTrustDevicePolicyEditParamsServiceModeV2) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDevicePolicyEditResponseEnvelope struct { - Errors []ZeroTrustDevicePolicyEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePolicyEditResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDevicePolicyEditResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePolicyEditResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDevicePolicyEditResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDevicePolicyEditResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePolicyEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePolicyEditResponseEnvelope] -type zeroTrustDevicePolicyEditResponseEnvelopeJSON 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 *ZeroTrustDevicePolicyEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePolicyEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyEditResponseEnvelopeErrors] -type zeroTrustDevicePolicyEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePolicyEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyEditResponseEnvelopeMessages] -type zeroTrustDevicePolicyEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePolicyEditResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePolicyEditResponseEnvelopeSuccessTrue ZeroTrustDevicePolicyEditResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePolicyEditResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDevicePolicyEditResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDevicePolicyEditResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePolicyEditResponseEnvelopeResultInfo] -type zeroTrustDevicePolicyEditResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyEditResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyEditResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDevicePolicyGetResponseEnvelope struct { - Errors []ZeroTrustDevicePolicyGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePolicyGetResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDevicePolicyGetResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePolicyGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDevicePolicyGetResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDevicePolicyGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePolicyGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePolicyGetResponseEnvelope] -type zeroTrustDevicePolicyGetResponseEnvelopeJSON 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 *ZeroTrustDevicePolicyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePolicyGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyGetResponseEnvelopeErrors] -type zeroTrustDevicePolicyGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePolicyGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyGetResponseEnvelopeMessages] -type zeroTrustDevicePolicyGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePolicyGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePolicyGetResponseEnvelopeSuccessTrue ZeroTrustDevicePolicyGetResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePolicyGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDevicePolicyGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDevicePolicyGetResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePolicyGetResponseEnvelopeResultInfo] -type zeroTrustDevicePolicyGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zerotrustdevicepolicy_test.go b/zerotrustdevicepolicy_test.go deleted file mode 100644 index a3f84489a15..00000000000 --- a/zerotrustdevicepolicy_test.go +++ /dev/null @@ -1,194 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDevicePolicyNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Policies.New(context.TODO(), cloudflare.ZeroTrustDevicePolicyNewParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Match: cloudflare.F("user.identity == \"test@cloudflare.com\""), - Name: cloudflare.F("Allow Developers"), - Precedence: cloudflare.F(100.000000), - AllowModeSwitch: cloudflare.F(true), - AllowUpdates: cloudflare.F(true), - AllowedToLeave: cloudflare.F(true), - AutoConnect: cloudflare.F(0.000000), - CaptivePortal: cloudflare.F(180.000000), - Description: cloudflare.F("Policy for test teams."), - DisableAutoFallback: cloudflare.F(true), - Enabled: cloudflare.F(true), - ExcludeOfficeIPs: cloudflare.F(true), - LanAllowMinutes: cloudflare.F(30.000000), - LanAllowSubnetSize: cloudflare.F(24.000000), - ServiceModeV2: cloudflare.F(cloudflare.ZeroTrustDevicePolicyNewParamsServiceModeV2{ - Mode: cloudflare.F("proxy"), - Port: cloudflare.F(3000.000000), - }), - SupportURL: cloudflare.F("https://1.1.1.1/help"), - SwitchLocked: cloudflare.F(true), - }) - 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 TestZeroTrustDevicePolicyList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Policies.List(context.TODO(), cloudflare.ZeroTrustDevicePolicyListParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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 TestZeroTrustDevicePolicyDelete(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Policies.Delete( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDevicePolicyDeleteParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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 TestZeroTrustDevicePolicyEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Policies.Edit( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDevicePolicyEditParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - AllowModeSwitch: cloudflare.F(true), - AllowUpdates: cloudflare.F(true), - AllowedToLeave: cloudflare.F(true), - AutoConnect: cloudflare.F(0.000000), - CaptivePortal: cloudflare.F(180.000000), - Description: cloudflare.F("Policy for test teams."), - DisableAutoFallback: cloudflare.F(true), - Enabled: cloudflare.F(true), - ExcludeOfficeIPs: cloudflare.F(true), - Match: cloudflare.F("user.identity == \"test@cloudflare.com\""), - Name: cloudflare.F("Allow Developers"), - Precedence: cloudflare.F(100.000000), - ServiceModeV2: cloudflare.F(cloudflare.ZeroTrustDevicePolicyEditParamsServiceModeV2{ - Mode: cloudflare.F("proxy"), - Port: cloudflare.F(3000.000000), - }), - SupportURL: cloudflare.F("https://1.1.1.1/help"), - SwitchLocked: cloudflare.F(true), - }, - ) - 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 TestZeroTrustDevicePolicyGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Policies.Get( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDevicePolicyGetParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrustdevicepolicydefaultpolicy.go b/zerotrustdevicepolicydefaultpolicy.go deleted file mode 100644 index fb83b8bbc13..00000000000 --- a/zerotrustdevicepolicydefaultpolicy.go +++ /dev/null @@ -1,169 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDevicePolicyDefaultPolicyService 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 -// [NewZeroTrustDevicePolicyDefaultPolicyService] method instead. -type ZeroTrustDevicePolicyDefaultPolicyService struct { - Options []option.RequestOption -} - -// NewZeroTrustDevicePolicyDefaultPolicyService 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 NewZeroTrustDevicePolicyDefaultPolicyService(opts ...option.RequestOption) (r *ZeroTrustDevicePolicyDefaultPolicyService) { - r = &ZeroTrustDevicePolicyDefaultPolicyService{} - r.Options = opts - return -} - -// Fetches the default device settings profile for an account. -func (r *ZeroTrustDevicePolicyDefaultPolicyService) Get(ctx context.Context, query ZeroTrustDevicePolicyDefaultPolicyGetParams, opts ...option.RequestOption) (res *[]ZeroTrustDevicePolicyDefaultPolicyGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/policy", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDevicePolicyDefaultPolicyGetResponse = interface{} - -type ZeroTrustDevicePolicyDefaultPolicyGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelope struct { - Errors []ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDevicePolicyDefaultPolicyGetResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelope] -type zeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeJSON 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 *ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeErrors] -type zeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeMessages] -type zeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeSuccessTrue ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeResultInfo] -type zeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyDefaultPolicyGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zerotrustdevicepolicydefaultpolicy_test.go b/zerotrustdevicepolicydefaultpolicy_test.go deleted file mode 100644 index 5786cdf7df7..00000000000 --- a/zerotrustdevicepolicydefaultpolicy_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDevicePolicyDefaultPolicyGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Policies.DefaultPolicy.Get(context.TODO(), cloudflare.ZeroTrustDevicePolicyDefaultPolicyGetParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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/zerotrustdevicepolicyexclude.go b/zerotrustdevicepolicyexclude.go deleted file mode 100644 index f30405415d8..00000000000 --- a/zerotrustdevicepolicyexclude.go +++ /dev/null @@ -1,543 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDevicePolicyExcludeService 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 -// [NewZeroTrustDevicePolicyExcludeService] method instead. -type ZeroTrustDevicePolicyExcludeService struct { - Options []option.RequestOption -} - -// NewZeroTrustDevicePolicyExcludeService 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 NewZeroTrustDevicePolicyExcludeService(opts ...option.RequestOption) (r *ZeroTrustDevicePolicyExcludeService) { - r = &ZeroTrustDevicePolicyExcludeService{} - r.Options = opts - return -} - -// Sets the list of routes excluded from the WARP client's tunnel. -func (r *ZeroTrustDevicePolicyExcludeService) Update(ctx context.Context, params ZeroTrustDevicePolicyExcludeUpdateParams, opts ...option.RequestOption) (res *[]ZeroTrustDevicePolicyExcludeUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePolicyExcludeUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/policy/exclude", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the list of routes excluded from the WARP client's tunnel. -func (r *ZeroTrustDevicePolicyExcludeService) List(ctx context.Context, query ZeroTrustDevicePolicyExcludeListParams, opts ...option.RequestOption) (res *[]ZeroTrustDevicePolicyExcludeListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePolicyExcludeListResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/policy/exclude", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the list of routes excluded from the WARP client's tunnel for a specific -// device settings profile. -func (r *ZeroTrustDevicePolicyExcludeService) Get(ctx context.Context, policyID string, query ZeroTrustDevicePolicyExcludeGetParams, opts ...option.RequestOption) (res *[]ZeroTrustDevicePolicyExcludeGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePolicyExcludeGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/policy/%s/exclude", query.AccountID, policyID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDevicePolicyExcludeUpdateResponse struct { - // The address in CIDR format to exclude from the tunnel. If `address` is present, - // `host` must not be present. - Address string `json:"address,required"` - // A description of the Split Tunnel item, displayed in the client UI. - Description string `json:"description,required"` - // The domain name to exclude from the tunnel. If `host` is present, `address` must - // not be present. - Host string `json:"host"` - JSON zeroTrustDevicePolicyExcludeUpdateResponseJSON `json:"-"` -} - -// zeroTrustDevicePolicyExcludeUpdateResponseJSON contains the JSON metadata for -// the struct [ZeroTrustDevicePolicyExcludeUpdateResponse] -type zeroTrustDevicePolicyExcludeUpdateResponseJSON struct { - Address apijson.Field - Description apijson.Field - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyExcludeUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyExcludeUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyExcludeListResponse struct { - // The address in CIDR format to exclude from the tunnel. If `address` is present, - // `host` must not be present. - Address string `json:"address,required"` - // A description of the Split Tunnel item, displayed in the client UI. - Description string `json:"description,required"` - // The domain name to exclude from the tunnel. If `host` is present, `address` must - // not be present. - Host string `json:"host"` - JSON zeroTrustDevicePolicyExcludeListResponseJSON `json:"-"` -} - -// zeroTrustDevicePolicyExcludeListResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePolicyExcludeListResponse] -type zeroTrustDevicePolicyExcludeListResponseJSON struct { - Address apijson.Field - Description apijson.Field - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyExcludeListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyExcludeListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyExcludeGetResponse struct { - // The address in CIDR format to exclude from the tunnel. If `address` is present, - // `host` must not be present. - Address string `json:"address,required"` - // A description of the Split Tunnel item, displayed in the client UI. - Description string `json:"description,required"` - // The domain name to exclude from the tunnel. If `host` is present, `address` must - // not be present. - Host string `json:"host"` - JSON zeroTrustDevicePolicyExcludeGetResponseJSON `json:"-"` -} - -// zeroTrustDevicePolicyExcludeGetResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePolicyExcludeGetResponse] -type zeroTrustDevicePolicyExcludeGetResponseJSON struct { - Address apijson.Field - Description apijson.Field - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyExcludeGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyExcludeGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyExcludeUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - Body param.Field[[]ZeroTrustDevicePolicyExcludeUpdateParamsBody] `json:"body,required"` -} - -func (r ZeroTrustDevicePolicyExcludeUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type ZeroTrustDevicePolicyExcludeUpdateParamsBody struct { - // The address in CIDR format to exclude from the tunnel. If `address` is present, - // `host` must not be present. - Address param.Field[string] `json:"address,required"` - // A description of the Split Tunnel item, displayed in the client UI. - Description param.Field[string] `json:"description,required"` - // The domain name to exclude from the tunnel. If `host` is present, `address` must - // not be present. - Host param.Field[string] `json:"host"` -} - -func (r ZeroTrustDevicePolicyExcludeUpdateParamsBody) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDevicePolicyExcludeUpdateResponseEnvelope struct { - Errors []ZeroTrustDevicePolicyExcludeUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePolicyExcludeUpdateResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDevicePolicyExcludeUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePolicyExcludeUpdateResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDevicePolicyExcludeUpdateResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDevicePolicyExcludeUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePolicyExcludeUpdateResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePolicyExcludeUpdateResponseEnvelope] -type zeroTrustDevicePolicyExcludeUpdateResponseEnvelopeJSON 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 *ZeroTrustDevicePolicyExcludeUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyExcludeUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyExcludeUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyExcludeUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePolicyExcludeUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustDevicePolicyExcludeUpdateResponseEnvelopeErrors] -type zeroTrustDevicePolicyExcludeUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyExcludeUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyExcludeUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyExcludeUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyExcludeUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePolicyExcludeUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustDevicePolicyExcludeUpdateResponseEnvelopeMessages] -type zeroTrustDevicePolicyExcludeUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyExcludeUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyExcludeUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePolicyExcludeUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePolicyExcludeUpdateResponseEnvelopeSuccessTrue ZeroTrustDevicePolicyExcludeUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePolicyExcludeUpdateResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDevicePolicyExcludeUpdateResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDevicePolicyExcludeUpdateResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePolicyExcludeUpdateResponseEnvelopeResultInfo] -type zeroTrustDevicePolicyExcludeUpdateResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyExcludeUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyExcludeUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyExcludeListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDevicePolicyExcludeListResponseEnvelope struct { - Errors []ZeroTrustDevicePolicyExcludeListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePolicyExcludeListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDevicePolicyExcludeListResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePolicyExcludeListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDevicePolicyExcludeListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDevicePolicyExcludeListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePolicyExcludeListResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyExcludeListResponseEnvelope] -type zeroTrustDevicePolicyExcludeListResponseEnvelopeJSON 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 *ZeroTrustDevicePolicyExcludeListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyExcludeListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyExcludeListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyExcludeListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePolicyExcludeListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePolicyExcludeListResponseEnvelopeErrors] -type zeroTrustDevicePolicyExcludeListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyExcludeListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyExcludeListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyExcludeListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyExcludeListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePolicyExcludeListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustDevicePolicyExcludeListResponseEnvelopeMessages] -type zeroTrustDevicePolicyExcludeListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyExcludeListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyExcludeListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePolicyExcludeListResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePolicyExcludeListResponseEnvelopeSuccessTrue ZeroTrustDevicePolicyExcludeListResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePolicyExcludeListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDevicePolicyExcludeListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDevicePolicyExcludeListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [ZeroTrustDevicePolicyExcludeListResponseEnvelopeResultInfo] -type zeroTrustDevicePolicyExcludeListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyExcludeListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyExcludeListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyExcludeGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDevicePolicyExcludeGetResponseEnvelope struct { - Errors []ZeroTrustDevicePolicyExcludeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePolicyExcludeGetResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDevicePolicyExcludeGetResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePolicyExcludeGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDevicePolicyExcludeGetResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDevicePolicyExcludeGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePolicyExcludeGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyExcludeGetResponseEnvelope] -type zeroTrustDevicePolicyExcludeGetResponseEnvelopeJSON 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 *ZeroTrustDevicePolicyExcludeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyExcludeGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyExcludeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyExcludeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePolicyExcludeGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePolicyExcludeGetResponseEnvelopeErrors] -type zeroTrustDevicePolicyExcludeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyExcludeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyExcludeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyExcludeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyExcludeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePolicyExcludeGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustDevicePolicyExcludeGetResponseEnvelopeMessages] -type zeroTrustDevicePolicyExcludeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyExcludeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyExcludeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePolicyExcludeGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePolicyExcludeGetResponseEnvelopeSuccessTrue ZeroTrustDevicePolicyExcludeGetResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePolicyExcludeGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDevicePolicyExcludeGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDevicePolicyExcludeGetResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [ZeroTrustDevicePolicyExcludeGetResponseEnvelopeResultInfo] -type zeroTrustDevicePolicyExcludeGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyExcludeGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyExcludeGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zerotrustdevicepolicyexclude_test.go b/zerotrustdevicepolicyexclude_test.go deleted file mode 100644 index bfc558c7d97..00000000000 --- a/zerotrustdevicepolicyexclude_test.go +++ /dev/null @@ -1,109 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDevicePolicyExcludeUpdate(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Policies.Excludes.Update(context.TODO(), cloudflare.ZeroTrustDevicePolicyExcludeUpdateParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Body: cloudflare.F([]cloudflare.ZeroTrustDevicePolicyExcludeUpdateParamsBody{{ - Address: cloudflare.F("192.0.2.0/24"), - Description: cloudflare.F("Exclude testing domains from the tunnel"), - Host: cloudflare.F("*.example.com"), - }, { - Address: cloudflare.F("192.0.2.0/24"), - Description: cloudflare.F("Exclude testing domains from the tunnel"), - Host: cloudflare.F("*.example.com"), - }, { - Address: cloudflare.F("192.0.2.0/24"), - Description: cloudflare.F("Exclude testing domains from the tunnel"), - Host: cloudflare.F("*.example.com"), - }}), - }) - 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 TestZeroTrustDevicePolicyExcludeList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Policies.Excludes.List(context.TODO(), cloudflare.ZeroTrustDevicePolicyExcludeListParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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 TestZeroTrustDevicePolicyExcludeGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Policies.Excludes.Get( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDevicePolicyExcludeGetParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrustdevicepolicyfallbackdomain.go b/zerotrustdevicepolicyfallbackdomain.go deleted file mode 100644 index 88dc576a603..00000000000 --- a/zerotrustdevicepolicyfallbackdomain.go +++ /dev/null @@ -1,544 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDevicePolicyFallbackDomainService 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 -// [NewZeroTrustDevicePolicyFallbackDomainService] method instead. -type ZeroTrustDevicePolicyFallbackDomainService struct { - Options []option.RequestOption -} - -// NewZeroTrustDevicePolicyFallbackDomainService 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 NewZeroTrustDevicePolicyFallbackDomainService(opts ...option.RequestOption) (r *ZeroTrustDevicePolicyFallbackDomainService) { - r = &ZeroTrustDevicePolicyFallbackDomainService{} - r.Options = opts - return -} - -// Sets the list of domains to bypass Gateway DNS resolution. These domains will -// use the specified local DNS resolver instead. This will only apply to the -// specified device settings profile. -func (r *ZeroTrustDevicePolicyFallbackDomainService) Update(ctx context.Context, policyID string, params ZeroTrustDevicePolicyFallbackDomainUpdateParams, opts ...option.RequestOption) (res *[]ZeroTrustDevicePolicyFallbackDomainUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/policy/%s/fallback_domains", params.AccountID, policyID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a list of domains to bypass Gateway DNS resolution. These domains will -// use the specified local DNS resolver instead. -func (r *ZeroTrustDevicePolicyFallbackDomainService) List(ctx context.Context, query ZeroTrustDevicePolicyFallbackDomainListParams, opts ...option.RequestOption) (res *[]ZeroTrustDevicePolicyFallbackDomainListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePolicyFallbackDomainListResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/policy/fallback_domains", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the list of domains to bypass Gateway DNS resolution from a specified -// device settings profile. These domains will use the specified local DNS resolver -// instead. -func (r *ZeroTrustDevicePolicyFallbackDomainService) Get(ctx context.Context, policyID string, query ZeroTrustDevicePolicyFallbackDomainGetParams, opts ...option.RequestOption) (res *[]ZeroTrustDevicePolicyFallbackDomainGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/policy/%s/fallback_domains", query.AccountID, policyID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDevicePolicyFallbackDomainUpdateResponse struct { - // The domain suffix to match when resolving locally. - Suffix string `json:"suffix,required"` - // A description of the fallback domain, displayed in the client UI. - Description string `json:"description"` - // A list of IP addresses to handle domain resolution. - DNSServer []interface{} `json:"dns_server"` - JSON zeroTrustDevicePolicyFallbackDomainUpdateResponseJSON `json:"-"` -} - -// zeroTrustDevicePolicyFallbackDomainUpdateResponseJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyFallbackDomainUpdateResponse] -type zeroTrustDevicePolicyFallbackDomainUpdateResponseJSON struct { - Suffix apijson.Field - Description apijson.Field - DNSServer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyFallbackDomainUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyFallbackDomainUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyFallbackDomainListResponse struct { - // The domain suffix to match when resolving locally. - Suffix string `json:"suffix,required"` - // A description of the fallback domain, displayed in the client UI. - Description string `json:"description"` - // A list of IP addresses to handle domain resolution. - DNSServer []interface{} `json:"dns_server"` - JSON zeroTrustDevicePolicyFallbackDomainListResponseJSON `json:"-"` -} - -// zeroTrustDevicePolicyFallbackDomainListResponseJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyFallbackDomainListResponse] -type zeroTrustDevicePolicyFallbackDomainListResponseJSON struct { - Suffix apijson.Field - Description apijson.Field - DNSServer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyFallbackDomainListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyFallbackDomainListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyFallbackDomainGetResponse struct { - // The domain suffix to match when resolving locally. - Suffix string `json:"suffix,required"` - // A description of the fallback domain, displayed in the client UI. - Description string `json:"description"` - // A list of IP addresses to handle domain resolution. - DNSServer []interface{} `json:"dns_server"` - JSON zeroTrustDevicePolicyFallbackDomainGetResponseJSON `json:"-"` -} - -// zeroTrustDevicePolicyFallbackDomainGetResponseJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyFallbackDomainGetResponse] -type zeroTrustDevicePolicyFallbackDomainGetResponseJSON struct { - Suffix apijson.Field - Description apijson.Field - DNSServer apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyFallbackDomainGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyFallbackDomainGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyFallbackDomainUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - Body param.Field[[]ZeroTrustDevicePolicyFallbackDomainUpdateParamsBody] `json:"body,required"` -} - -func (r ZeroTrustDevicePolicyFallbackDomainUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type ZeroTrustDevicePolicyFallbackDomainUpdateParamsBody struct { - // The domain suffix to match when resolving locally. - Suffix param.Field[string] `json:"suffix,required"` - // A description of the fallback domain, displayed in the client UI. - Description param.Field[string] `json:"description"` - // A list of IP addresses to handle domain resolution. - DNSServer param.Field[[]interface{}] `json:"dns_server"` -} - -func (r ZeroTrustDevicePolicyFallbackDomainUpdateParamsBody) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelope struct { - Errors []ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDevicePolicyFallbackDomainUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelope] -type zeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeJSON 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 *ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeErrors] -type zeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeMessagesJSON contains -// the JSON metadata for the struct -// [ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeMessages] -type zeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeSuccessTrue ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeResultInfoJSON contains -// the JSON metadata for the struct -// [ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeResultInfo] -type zeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyFallbackDomainUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyFallbackDomainListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDevicePolicyFallbackDomainListResponseEnvelope struct { - Errors []ZeroTrustDevicePolicyFallbackDomainListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePolicyFallbackDomainListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDevicePolicyFallbackDomainListResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePolicyFallbackDomainListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDevicePolicyFallbackDomainListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDevicePolicyFallbackDomainListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePolicyFallbackDomainListResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [ZeroTrustDevicePolicyFallbackDomainListResponseEnvelope] -type zeroTrustDevicePolicyFallbackDomainListResponseEnvelopeJSON 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 *ZeroTrustDevicePolicyFallbackDomainListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyFallbackDomainListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyFallbackDomainListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyFallbackDomainListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePolicyFallbackDomainListResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePolicyFallbackDomainListResponseEnvelopeErrors] -type zeroTrustDevicePolicyFallbackDomainListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyFallbackDomainListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyFallbackDomainListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyFallbackDomainListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyFallbackDomainListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePolicyFallbackDomainListResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePolicyFallbackDomainListResponseEnvelopeMessages] -type zeroTrustDevicePolicyFallbackDomainListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyFallbackDomainListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyFallbackDomainListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePolicyFallbackDomainListResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePolicyFallbackDomainListResponseEnvelopeSuccessTrue ZeroTrustDevicePolicyFallbackDomainListResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePolicyFallbackDomainListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDevicePolicyFallbackDomainListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDevicePolicyFallbackDomainListResponseEnvelopeResultInfoJSON contains -// the JSON metadata for the struct -// [ZeroTrustDevicePolicyFallbackDomainListResponseEnvelopeResultInfo] -type zeroTrustDevicePolicyFallbackDomainListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyFallbackDomainListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyFallbackDomainListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyFallbackDomainGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelope struct { - Errors []ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDevicePolicyFallbackDomainGetResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelope] -type zeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeJSON 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 *ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeErrors] -type zeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeMessages] -type zeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeSuccessTrue ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeResultInfoJSON contains -// the JSON metadata for the struct -// [ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeResultInfo] -type zeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyFallbackDomainGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zerotrustdevicepolicyfallbackdomain_test.go b/zerotrustdevicepolicyfallbackdomain_test.go deleted file mode 100644 index fde039d5339..00000000000 --- a/zerotrustdevicepolicyfallbackdomain_test.go +++ /dev/null @@ -1,113 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDevicePolicyFallbackDomainUpdate(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Policies.FallbackDomains.Update( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDevicePolicyFallbackDomainUpdateParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Body: cloudflare.F([]cloudflare.ZeroTrustDevicePolicyFallbackDomainUpdateParamsBody{{ - Description: cloudflare.F("Domain bypass for local development"), - DNSServer: cloudflare.F([]interface{}{map[string]interface{}{}, map[string]interface{}{}, map[string]interface{}{}}), - Suffix: cloudflare.F("example.com"), - }, { - Description: cloudflare.F("Domain bypass for local development"), - DNSServer: cloudflare.F([]interface{}{map[string]interface{}{}, map[string]interface{}{}, map[string]interface{}{}}), - Suffix: cloudflare.F("example.com"), - }, { - Description: cloudflare.F("Domain bypass for local development"), - DNSServer: cloudflare.F([]interface{}{map[string]interface{}{}, map[string]interface{}{}, map[string]interface{}{}}), - Suffix: cloudflare.F("example.com"), - }}), - }, - ) - 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 TestZeroTrustDevicePolicyFallbackDomainList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Policies.FallbackDomains.List(context.TODO(), cloudflare.ZeroTrustDevicePolicyFallbackDomainListParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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 TestZeroTrustDevicePolicyFallbackDomainGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Policies.FallbackDomains.Get( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDevicePolicyFallbackDomainGetParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrustdevicepolicyinclude.go b/zerotrustdevicepolicyinclude.go deleted file mode 100644 index 3a75aa59400..00000000000 --- a/zerotrustdevicepolicyinclude.go +++ /dev/null @@ -1,543 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDevicePolicyIncludeService 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 -// [NewZeroTrustDevicePolicyIncludeService] method instead. -type ZeroTrustDevicePolicyIncludeService struct { - Options []option.RequestOption -} - -// NewZeroTrustDevicePolicyIncludeService 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 NewZeroTrustDevicePolicyIncludeService(opts ...option.RequestOption) (r *ZeroTrustDevicePolicyIncludeService) { - r = &ZeroTrustDevicePolicyIncludeService{} - r.Options = opts - return -} - -// Sets the list of routes included in the WARP client's tunnel. -func (r *ZeroTrustDevicePolicyIncludeService) Update(ctx context.Context, params ZeroTrustDevicePolicyIncludeUpdateParams, opts ...option.RequestOption) (res *[]ZeroTrustDevicePolicyIncludeUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePolicyIncludeUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/policy/include", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the list of routes included in the WARP client's tunnel. -func (r *ZeroTrustDevicePolicyIncludeService) List(ctx context.Context, query ZeroTrustDevicePolicyIncludeListParams, opts ...option.RequestOption) (res *[]ZeroTrustDevicePolicyIncludeListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePolicyIncludeListResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/policy/include", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the list of routes included in the WARP client's tunnel for a specific -// device settings profile. -func (r *ZeroTrustDevicePolicyIncludeService) Get(ctx context.Context, policyID string, query ZeroTrustDevicePolicyIncludeGetParams, opts ...option.RequestOption) (res *[]ZeroTrustDevicePolicyIncludeGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePolicyIncludeGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/policy/%s/include", query.AccountID, policyID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDevicePolicyIncludeUpdateResponse struct { - // The address in CIDR format to include in the tunnel. If address is present, host - // must not be present. - Address string `json:"address,required"` - // A description of the split tunnel item, displayed in the client UI. - Description string `json:"description,required"` - // The domain name to include in the tunnel. If host is present, address must not - // be present. - Host string `json:"host"` - JSON zeroTrustDevicePolicyIncludeUpdateResponseJSON `json:"-"` -} - -// zeroTrustDevicePolicyIncludeUpdateResponseJSON contains the JSON metadata for -// the struct [ZeroTrustDevicePolicyIncludeUpdateResponse] -type zeroTrustDevicePolicyIncludeUpdateResponseJSON struct { - Address apijson.Field - Description apijson.Field - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyIncludeUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyIncludeUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyIncludeListResponse struct { - // The address in CIDR format to include in the tunnel. If address is present, host - // must not be present. - Address string `json:"address,required"` - // A description of the split tunnel item, displayed in the client UI. - Description string `json:"description,required"` - // The domain name to include in the tunnel. If host is present, address must not - // be present. - Host string `json:"host"` - JSON zeroTrustDevicePolicyIncludeListResponseJSON `json:"-"` -} - -// zeroTrustDevicePolicyIncludeListResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePolicyIncludeListResponse] -type zeroTrustDevicePolicyIncludeListResponseJSON struct { - Address apijson.Field - Description apijson.Field - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyIncludeListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyIncludeListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyIncludeGetResponse struct { - // The address in CIDR format to include in the tunnel. If address is present, host - // must not be present. - Address string `json:"address,required"` - // A description of the split tunnel item, displayed in the client UI. - Description string `json:"description,required"` - // The domain name to include in the tunnel. If host is present, address must not - // be present. - Host string `json:"host"` - JSON zeroTrustDevicePolicyIncludeGetResponseJSON `json:"-"` -} - -// zeroTrustDevicePolicyIncludeGetResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePolicyIncludeGetResponse] -type zeroTrustDevicePolicyIncludeGetResponseJSON struct { - Address apijson.Field - Description apijson.Field - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyIncludeGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyIncludeGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyIncludeUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - Body param.Field[[]ZeroTrustDevicePolicyIncludeUpdateParamsBody] `json:"body,required"` -} - -func (r ZeroTrustDevicePolicyIncludeUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type ZeroTrustDevicePolicyIncludeUpdateParamsBody struct { - // The address in CIDR format to include in the tunnel. If address is present, host - // must not be present. - Address param.Field[string] `json:"address,required"` - // A description of the split tunnel item, displayed in the client UI. - Description param.Field[string] `json:"description,required"` - // The domain name to include in the tunnel. If host is present, address must not - // be present. - Host param.Field[string] `json:"host"` -} - -func (r ZeroTrustDevicePolicyIncludeUpdateParamsBody) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDevicePolicyIncludeUpdateResponseEnvelope struct { - Errors []ZeroTrustDevicePolicyIncludeUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePolicyIncludeUpdateResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDevicePolicyIncludeUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePolicyIncludeUpdateResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDevicePolicyIncludeUpdateResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDevicePolicyIncludeUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePolicyIncludeUpdateResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePolicyIncludeUpdateResponseEnvelope] -type zeroTrustDevicePolicyIncludeUpdateResponseEnvelopeJSON 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 *ZeroTrustDevicePolicyIncludeUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyIncludeUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyIncludeUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyIncludeUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePolicyIncludeUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustDevicePolicyIncludeUpdateResponseEnvelopeErrors] -type zeroTrustDevicePolicyIncludeUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyIncludeUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyIncludeUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyIncludeUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyIncludeUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePolicyIncludeUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustDevicePolicyIncludeUpdateResponseEnvelopeMessages] -type zeroTrustDevicePolicyIncludeUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyIncludeUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyIncludeUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePolicyIncludeUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePolicyIncludeUpdateResponseEnvelopeSuccessTrue ZeroTrustDevicePolicyIncludeUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePolicyIncludeUpdateResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDevicePolicyIncludeUpdateResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDevicePolicyIncludeUpdateResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePolicyIncludeUpdateResponseEnvelopeResultInfo] -type zeroTrustDevicePolicyIncludeUpdateResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyIncludeUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyIncludeUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyIncludeListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDevicePolicyIncludeListResponseEnvelope struct { - Errors []ZeroTrustDevicePolicyIncludeListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePolicyIncludeListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDevicePolicyIncludeListResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePolicyIncludeListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDevicePolicyIncludeListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDevicePolicyIncludeListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePolicyIncludeListResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyIncludeListResponseEnvelope] -type zeroTrustDevicePolicyIncludeListResponseEnvelopeJSON 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 *ZeroTrustDevicePolicyIncludeListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyIncludeListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyIncludeListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyIncludeListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePolicyIncludeListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePolicyIncludeListResponseEnvelopeErrors] -type zeroTrustDevicePolicyIncludeListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyIncludeListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyIncludeListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyIncludeListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyIncludeListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePolicyIncludeListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustDevicePolicyIncludeListResponseEnvelopeMessages] -type zeroTrustDevicePolicyIncludeListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyIncludeListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyIncludeListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePolicyIncludeListResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePolicyIncludeListResponseEnvelopeSuccessTrue ZeroTrustDevicePolicyIncludeListResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePolicyIncludeListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDevicePolicyIncludeListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDevicePolicyIncludeListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [ZeroTrustDevicePolicyIncludeListResponseEnvelopeResultInfo] -type zeroTrustDevicePolicyIncludeListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyIncludeListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyIncludeListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyIncludeGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDevicePolicyIncludeGetResponseEnvelope struct { - Errors []ZeroTrustDevicePolicyIncludeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePolicyIncludeGetResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDevicePolicyIncludeGetResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePolicyIncludeGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDevicePolicyIncludeGetResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDevicePolicyIncludeGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePolicyIncludeGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePolicyIncludeGetResponseEnvelope] -type zeroTrustDevicePolicyIncludeGetResponseEnvelopeJSON 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 *ZeroTrustDevicePolicyIncludeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyIncludeGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyIncludeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyIncludeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePolicyIncludeGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePolicyIncludeGetResponseEnvelopeErrors] -type zeroTrustDevicePolicyIncludeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyIncludeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyIncludeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePolicyIncludeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePolicyIncludeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePolicyIncludeGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustDevicePolicyIncludeGetResponseEnvelopeMessages] -type zeroTrustDevicePolicyIncludeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyIncludeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyIncludeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePolicyIncludeGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePolicyIncludeGetResponseEnvelopeSuccessTrue ZeroTrustDevicePolicyIncludeGetResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePolicyIncludeGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDevicePolicyIncludeGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDevicePolicyIncludeGetResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [ZeroTrustDevicePolicyIncludeGetResponseEnvelopeResultInfo] -type zeroTrustDevicePolicyIncludeGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePolicyIncludeGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePolicyIncludeGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zerotrustdevicepolicyinclude_test.go b/zerotrustdevicepolicyinclude_test.go deleted file mode 100644 index 188563e7ff7..00000000000 --- a/zerotrustdevicepolicyinclude_test.go +++ /dev/null @@ -1,109 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDevicePolicyIncludeUpdate(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Policies.Includes.Update(context.TODO(), cloudflare.ZeroTrustDevicePolicyIncludeUpdateParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Body: cloudflare.F([]cloudflare.ZeroTrustDevicePolicyIncludeUpdateParamsBody{{ - Address: cloudflare.F("192.0.2.0/24"), - Description: cloudflare.F("Include testing domains from the tunnel"), - Host: cloudflare.F("*.example.com"), - }, { - Address: cloudflare.F("192.0.2.0/24"), - Description: cloudflare.F("Include testing domains from the tunnel"), - Host: cloudflare.F("*.example.com"), - }, { - Address: cloudflare.F("192.0.2.0/24"), - Description: cloudflare.F("Include testing domains from the tunnel"), - Host: cloudflare.F("*.example.com"), - }}), - }) - 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 TestZeroTrustDevicePolicyIncludeList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Policies.Includes.List(context.TODO(), cloudflare.ZeroTrustDevicePolicyIncludeListParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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 TestZeroTrustDevicePolicyIncludeGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Policies.Includes.Get( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDevicePolicyIncludeGetParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrustdeviceposture.go b/zerotrustdeviceposture.go deleted file mode 100644 index 200ed79fb4d..00000000000 --- a/zerotrustdeviceposture.go +++ /dev/null @@ -1,5470 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustDevicePostureService 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 [NewZeroTrustDevicePostureService] -// method instead. -type ZeroTrustDevicePostureService struct { - Options []option.RequestOption - Integrations *ZeroTrustDevicePostureIntegrationService -} - -// NewZeroTrustDevicePostureService 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 NewZeroTrustDevicePostureService(opts ...option.RequestOption) (r *ZeroTrustDevicePostureService) { - r = &ZeroTrustDevicePostureService{} - r.Options = opts - r.Integrations = NewZeroTrustDevicePostureIntegrationService(opts...) - return -} - -// Creates a new device posture rule. -func (r *ZeroTrustDevicePostureService) New(ctx context.Context, params ZeroTrustDevicePostureNewParams, opts ...option.RequestOption) (res *ZeroTrustDevicePostureNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePostureNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/posture", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a device posture rule. -func (r *ZeroTrustDevicePostureService) Update(ctx context.Context, ruleID string, params ZeroTrustDevicePostureUpdateParams, opts ...option.RequestOption) (res *ZeroTrustDevicePostureUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePostureUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/posture/%s", params.AccountID, ruleID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches device posture rules for a Zero Trust account. -func (r *ZeroTrustDevicePostureService) List(ctx context.Context, query ZeroTrustDevicePostureListParams, opts ...option.RequestOption) (res *[]ZeroTrustDevicePostureListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePostureListResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/posture", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a device posture rule. -func (r *ZeroTrustDevicePostureService) Delete(ctx context.Context, ruleID string, body ZeroTrustDevicePostureDeleteParams, opts ...option.RequestOption) (res *ZeroTrustDevicePostureDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePostureDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/posture/%s", body.AccountID, ruleID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a single device posture rule. -func (r *ZeroTrustDevicePostureService) Get(ctx context.Context, ruleID string, query ZeroTrustDevicePostureGetParams, opts ...option.RequestOption) (res *ZeroTrustDevicePostureGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePostureGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/posture/%s", query.AccountID, ruleID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDevicePostureNewResponse struct { - // API UUID. - ID string `json:"id"` - // The description of the device posture rule. - Description string `json:"description"` - // Sets the expiration time for a posture check result. If empty, the result - // remains valid until it is overwritten by new data from the WARP client. - Expiration string `json:"expiration"` - // The value to be checked against. - Input ZeroTrustDevicePostureNewResponseInput `json:"input"` - // The conditions that the client must match to run the rule. - Match []ZeroTrustDevicePostureNewResponseMatch `json:"match"` - // The name of the device posture rule. - Name string `json:"name"` - // Polling frequency for the WARP client posture check. Default: `5m` (poll every - // five minutes). Minimum: `1m`. - Schedule string `json:"schedule"` - // The type of device posture rule. - Type ZeroTrustDevicePostureNewResponseType `json:"type"` - JSON zeroTrustDevicePostureNewResponseJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDevicePostureNewResponse] -type zeroTrustDevicePostureNewResponseJSON struct { - ID apijson.Field - Description apijson.Field - Expiration apijson.Field - Input apijson.Field - Match apijson.Field - Name apijson.Field - Schedule apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseJSON) RawJSON() string { - return r.raw -} - -// The value to be checked against. -// -// Union satisfied by -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesFileInputRequest], -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesUniqueClientIDInputRequest], -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesDomainJoinedInputRequest], -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequest], -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesFirewallInputRequest], -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneInputRequest], -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesCarbonblackInputRequest], -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesDiskEncryptionInputRequest], -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesApplicationInputRequest], -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesClientCertificateInputRequest], -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesWorkspaceOneInputRequest], -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequest], -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequest], -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequest], -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequest] or -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequest]. -type ZeroTrustDevicePostureNewResponseInput interface { - implementsZeroTrustDevicePostureNewResponseInput() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustDevicePostureNewResponseInput)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureNewResponseInputTeamsDevicesFileInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureNewResponseInputTeamsDevicesUniqueClientIDInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureNewResponseInputTeamsDevicesDomainJoinedInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureNewResponseInputTeamsDevicesFirewallInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureNewResponseInputTeamsDevicesCarbonblackInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureNewResponseInputTeamsDevicesDiskEncryptionInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureNewResponseInputTeamsDevicesApplicationInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureNewResponseInputTeamsDevicesClientCertificateInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureNewResponseInputTeamsDevicesWorkspaceOneInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequest{}), - }, - ) -} - -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesFileInputRequest struct { - // Operating system - OperatingSystem ZeroTrustDevicePostureNewResponseInputTeamsDevicesFileInputRequestOperatingSystem `json:"operating_system,required"` - // File path. - Path string `json:"path,required"` - // Whether or not file exists - Exists bool `json:"exists"` - // SHA-256. - Sha256 string `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON zeroTrustDevicePostureNewResponseInputTeamsDevicesFileInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseInputTeamsDevicesFileInputRequestJSON contains -// the JSON metadata for the struct -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesFileInputRequest] -type zeroTrustDevicePostureNewResponseInputTeamsDevicesFileInputRequestJSON struct { - OperatingSystem apijson.Field - Path apijson.Field - Exists apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseInputTeamsDevicesFileInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseInputTeamsDevicesFileInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureNewResponseInputTeamsDevicesFileInputRequest) implementsZeroTrustDevicePostureNewResponseInput() { -} - -// Operating system -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesFileInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesFileInputRequestOperatingSystemWindows ZeroTrustDevicePostureNewResponseInputTeamsDevicesFileInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesFileInputRequestOperatingSystemLinux ZeroTrustDevicePostureNewResponseInputTeamsDevicesFileInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesFileInputRequestOperatingSystemMac ZeroTrustDevicePostureNewResponseInputTeamsDevicesFileInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesUniqueClientIDInputRequest struct { - // List ID. - ID string `json:"id,required"` - // Operating System - OperatingSystem ZeroTrustDevicePostureNewResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem `json:"operating_system,required"` - JSON zeroTrustDevicePostureNewResponseInputTeamsDevicesUniqueClientIDInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseInputTeamsDevicesUniqueClientIDInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesUniqueClientIDInputRequest] -type zeroTrustDevicePostureNewResponseInputTeamsDevicesUniqueClientIDInputRequestJSON struct { - ID apijson.Field - OperatingSystem apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseInputTeamsDevicesUniqueClientIDInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseInputTeamsDevicesUniqueClientIDInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureNewResponseInputTeamsDevicesUniqueClientIDInputRequest) implementsZeroTrustDevicePostureNewResponseInput() { -} - -// Operating System -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemAndroid ZeroTrustDevicePostureNewResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "android" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemIos ZeroTrustDevicePostureNewResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "ios" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemChromeos ZeroTrustDevicePostureNewResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "chromeos" -) - -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesDomainJoinedInputRequest struct { - // Operating System - OperatingSystem ZeroTrustDevicePostureNewResponseInputTeamsDevicesDomainJoinedInputRequestOperatingSystem `json:"operating_system,required"` - // Domain - Domain string `json:"domain"` - JSON zeroTrustDevicePostureNewResponseInputTeamsDevicesDomainJoinedInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseInputTeamsDevicesDomainJoinedInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesDomainJoinedInputRequest] -type zeroTrustDevicePostureNewResponseInputTeamsDevicesDomainJoinedInputRequestJSON struct { - OperatingSystem apijson.Field - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseInputTeamsDevicesDomainJoinedInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseInputTeamsDevicesDomainJoinedInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureNewResponseInputTeamsDevicesDomainJoinedInputRequest) implementsZeroTrustDevicePostureNewResponseInput() { -} - -// Operating System -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesDomainJoinedInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesDomainJoinedInputRequestOperatingSystemWindows ZeroTrustDevicePostureNewResponseInputTeamsDevicesDomainJoinedInputRequestOperatingSystem = "windows" -) - -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequest struct { - // Operating System - OperatingSystem ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestOperatingSystem `json:"operating_system,required"` - // Operator - Operator ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestOperator `json:"operator,required"` - // Version of OS - Version string `json:"version,required"` - // Operating System Distribution Name (linux only) - OSDistroName string `json:"os_distro_name"` - // Version of OS Distribution (linux only) - OSDistroRevision string `json:"os_distro_revision"` - // Additional version data. For Mac or iOS, the Product Verison Extra. For Linux, - // the kernel release version. (Mac, iOS, and Linux only) - OSVersionExtra string `json:"os_version_extra"` - JSON zeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequest] -type zeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestJSON struct { - OperatingSystem apijson.Field - Operator apijson.Field - Version apijson.Field - OSDistroName apijson.Field - OSDistroRevision apijson.Field - OSVersionExtra apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequest) implementsZeroTrustDevicePostureNewResponseInput() { -} - -// Operating System -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestOperatingSystemWindows ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestOperatingSystem = "windows" -) - -// Operator -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestOperator string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown5 ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestOperator = "<" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown6 ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestOperator = "<=" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown7 ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestOperator = ">" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown8 ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestOperator = ">=" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown9 ZeroTrustDevicePostureNewResponseInputTeamsDevicesOSVersionInputRequestOperator = "==" -) - -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesFirewallInputRequest struct { - // Enabled - Enabled bool `json:"enabled,required"` - // Operating System - OperatingSystem ZeroTrustDevicePostureNewResponseInputTeamsDevicesFirewallInputRequestOperatingSystem `json:"operating_system,required"` - JSON zeroTrustDevicePostureNewResponseInputTeamsDevicesFirewallInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseInputTeamsDevicesFirewallInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesFirewallInputRequest] -type zeroTrustDevicePostureNewResponseInputTeamsDevicesFirewallInputRequestJSON struct { - Enabled apijson.Field - OperatingSystem apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseInputTeamsDevicesFirewallInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseInputTeamsDevicesFirewallInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureNewResponseInputTeamsDevicesFirewallInputRequest) implementsZeroTrustDevicePostureNewResponseInput() { -} - -// Operating System -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesFirewallInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesFirewallInputRequestOperatingSystemWindows ZeroTrustDevicePostureNewResponseInputTeamsDevicesFirewallInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesFirewallInputRequestOperatingSystemMac ZeroTrustDevicePostureNewResponseInputTeamsDevicesFirewallInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneInputRequest struct { - // Operating system - OperatingSystem ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem `json:"operating_system,required"` - // File path. - Path string `json:"path,required"` - // SHA-256. - Sha256 string `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON zeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneInputRequest] -type zeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneInputRequestJSON struct { - OperatingSystem apijson.Field - Path apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneInputRequest) implementsZeroTrustDevicePostureNewResponseInput() { -} - -// Operating system -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneInputRequestOperatingSystemWindows ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneInputRequestOperatingSystemLinux ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneInputRequestOperatingSystemMac ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesCarbonblackInputRequest struct { - // Operating system - OperatingSystem ZeroTrustDevicePostureNewResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem `json:"operating_system,required"` - // File path. - Path string `json:"path,required"` - // SHA-256. - Sha256 string `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON zeroTrustDevicePostureNewResponseInputTeamsDevicesCarbonblackInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseInputTeamsDevicesCarbonblackInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesCarbonblackInputRequest] -type zeroTrustDevicePostureNewResponseInputTeamsDevicesCarbonblackInputRequestJSON struct { - OperatingSystem apijson.Field - Path apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseInputTeamsDevicesCarbonblackInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseInputTeamsDevicesCarbonblackInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureNewResponseInputTeamsDevicesCarbonblackInputRequest) implementsZeroTrustDevicePostureNewResponseInput() { -} - -// Operating system -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystemWindows ZeroTrustDevicePostureNewResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystemLinux ZeroTrustDevicePostureNewResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystemMac ZeroTrustDevicePostureNewResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesDiskEncryptionInputRequest struct { - // List of volume names to be checked for encryption. - CheckDisks []string `json:"checkDisks"` - // Whether to check all disks for encryption. - RequireAll bool `json:"requireAll"` - JSON zeroTrustDevicePostureNewResponseInputTeamsDevicesDiskEncryptionInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseInputTeamsDevicesDiskEncryptionInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesDiskEncryptionInputRequest] -type zeroTrustDevicePostureNewResponseInputTeamsDevicesDiskEncryptionInputRequestJSON struct { - CheckDisks apijson.Field - RequireAll apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseInputTeamsDevicesDiskEncryptionInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseInputTeamsDevicesDiskEncryptionInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureNewResponseInputTeamsDevicesDiskEncryptionInputRequest) implementsZeroTrustDevicePostureNewResponseInput() { -} - -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesApplicationInputRequest struct { - // Operating system - OperatingSystem ZeroTrustDevicePostureNewResponseInputTeamsDevicesApplicationInputRequestOperatingSystem `json:"operating_system,required"` - // Path for the application. - Path string `json:"path,required"` - // SHA-256. - Sha256 string `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON zeroTrustDevicePostureNewResponseInputTeamsDevicesApplicationInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseInputTeamsDevicesApplicationInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesApplicationInputRequest] -type zeroTrustDevicePostureNewResponseInputTeamsDevicesApplicationInputRequestJSON struct { - OperatingSystem apijson.Field - Path apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseInputTeamsDevicesApplicationInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseInputTeamsDevicesApplicationInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureNewResponseInputTeamsDevicesApplicationInputRequest) implementsZeroTrustDevicePostureNewResponseInput() { -} - -// Operating system -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesApplicationInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesApplicationInputRequestOperatingSystemWindows ZeroTrustDevicePostureNewResponseInputTeamsDevicesApplicationInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesApplicationInputRequestOperatingSystemLinux ZeroTrustDevicePostureNewResponseInputTeamsDevicesApplicationInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesApplicationInputRequestOperatingSystemMac ZeroTrustDevicePostureNewResponseInputTeamsDevicesApplicationInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesClientCertificateInputRequest struct { - // UUID of Cloudflare managed certificate. - CertificateID string `json:"certificate_id,required"` - // Common Name that is protected by the certificate - Cn string `json:"cn,required"` - JSON zeroTrustDevicePostureNewResponseInputTeamsDevicesClientCertificateInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseInputTeamsDevicesClientCertificateInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesClientCertificateInputRequest] -type zeroTrustDevicePostureNewResponseInputTeamsDevicesClientCertificateInputRequestJSON struct { - CertificateID apijson.Field - Cn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseInputTeamsDevicesClientCertificateInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseInputTeamsDevicesClientCertificateInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureNewResponseInputTeamsDevicesClientCertificateInputRequest) implementsZeroTrustDevicePostureNewResponseInput() { -} - -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesWorkspaceOneInputRequest struct { - // Compliance Status - ComplianceStatus ZeroTrustDevicePostureNewResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus `json:"compliance_status,required"` - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustDevicePostureNewResponseInputTeamsDevicesWorkspaceOneInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseInputTeamsDevicesWorkspaceOneInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesWorkspaceOneInputRequest] -type zeroTrustDevicePostureNewResponseInputTeamsDevicesWorkspaceOneInputRequestJSON struct { - ComplianceStatus apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseInputTeamsDevicesWorkspaceOneInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseInputTeamsDevicesWorkspaceOneInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureNewResponseInputTeamsDevicesWorkspaceOneInputRequest) implementsZeroTrustDevicePostureNewResponseInput() { -} - -// Compliance Status -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusCompliant ZeroTrustDevicePostureNewResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "compliant" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusNoncompliant ZeroTrustDevicePostureNewResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "noncompliant" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusUnknown ZeroTrustDevicePostureNewResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "unknown" -) - -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequest struct { - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // For more details on last seen, please refer to the Crowdstrike documentation. - LastSeen string `json:"last_seen"` - // Operator - Operator ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestOperator `json:"operator"` - // Os Version - OS string `json:"os"` - // overall - Overall string `json:"overall"` - // SensorConfig - SensorConfig string `json:"sensor_config"` - // For more details on state, please refer to the Crowdstrike documentation. - State ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestState `json:"state"` - // Version - Version string `json:"version"` - // Version Operator - VersionOperator ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator `json:"versionOperator"` - JSON zeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequest] -type zeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestJSON struct { - ConnectionID apijson.Field - LastSeen apijson.Field - Operator apijson.Field - OS apijson.Field - Overall apijson.Field - SensorConfig apijson.Field - State apijson.Field - Version apijson.Field - VersionOperator apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequest) implementsZeroTrustDevicePostureNewResponseInput() { -} - -// Operator -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestOperator string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown15 ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = "<" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown16 ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = "<=" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown17 ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = ">" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown18 ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = ">=" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown19 ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = "==" -) - -// For more details on state, please refer to the Crowdstrike documentation. -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestState string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestStateOnline ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestState = "online" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestStateOffline ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestState = "offline" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestStateUnknown ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestState = "unknown" -) - -// Version Operator -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown25 ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown26 ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<=" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown27 ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown28 ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">=" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown29 ZeroTrustDevicePostureNewResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "==" -) - -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequest struct { - // Compliance Status - ComplianceStatus ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequestComplianceStatus `json:"compliance_status,required"` - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequest] -type zeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequestJSON struct { - ComplianceStatus apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequest) implementsZeroTrustDevicePostureNewResponseInput() { -} - -// Compliance Status -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequestComplianceStatus string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequestComplianceStatusCompliant ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "compliant" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequestComplianceStatusNoncompliant ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "noncompliant" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequestComplianceStatusUnknown ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "unknown" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequestComplianceStatusNotapplicable ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "notapplicable" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequestComplianceStatusIngraceperiod ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "ingraceperiod" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequestComplianceStatusError ZeroTrustDevicePostureNewResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "error" -) - -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequest struct { - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // Count Operator - CountOperator ZeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequestCountOperator `json:"countOperator,required"` - // The Number of Issues. - IssueCount string `json:"issue_count,required"` - JSON zeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequest] -type zeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequestJSON struct { - ConnectionID apijson.Field - CountOperator apijson.Field - IssueCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequest) implementsZeroTrustDevicePostureNewResponseInput() { -} - -// Count Operator -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequestCountOperator string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown35 ZeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequestCountOperator = "<" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown36 ZeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequestCountOperator = "<=" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown37 ZeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequestCountOperator = ">" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown38 ZeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequestCountOperator = ">=" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown39 ZeroTrustDevicePostureNewResponseInputTeamsDevicesKolideInputRequestCountOperator = "==" -) - -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequest struct { - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // For more details on eid last seen, refer to the Tanium documentation. - EidLastSeen string `json:"eid_last_seen"` - // Operator to evaluate risk_level or eid_last_seen. - Operator ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestOperator `json:"operator"` - // For more details on risk level, refer to the Tanium documentation. - RiskLevel ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestRiskLevel `json:"risk_level"` - // Score Operator - ScoreOperator ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestScoreOperator `json:"scoreOperator"` - // For more details on total score, refer to the Tanium documentation. - TotalScore float64 `json:"total_score"` - JSON zeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequest] -type zeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestJSON struct { - ConnectionID apijson.Field - EidLastSeen apijson.Field - Operator apijson.Field - RiskLevel apijson.Field - ScoreOperator apijson.Field - TotalScore apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequest) implementsZeroTrustDevicePostureNewResponseInput() { -} - -// Operator to evaluate risk_level or eid_last_seen. -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestOperator string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown45 ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestOperator = "<" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown46 ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestOperator = "<=" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown47 ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestOperator = ">" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown48 ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestOperator = ">=" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown49 ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestOperator = "==" -) - -// For more details on risk level, refer to the Tanium documentation. -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestRiskLevel string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestRiskLevelLow ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestRiskLevel = "low" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestRiskLevelMedium ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestRiskLevel = "medium" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestRiskLevelHigh ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestRiskLevel = "high" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestRiskLevelCritical ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestRiskLevel = "critical" -) - -// Score Operator -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestScoreOperator string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown55 ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestScoreOperator = "<" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown56 ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestScoreOperator = "<=" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown57 ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestScoreOperator = ">" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown58 ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestScoreOperator = ">=" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown59 ZeroTrustDevicePostureNewResponseInputTeamsDevicesTaniumInputRequestScoreOperator = "==" -) - -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequest struct { - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // The Number of active threats. - ActiveThreats float64 `json:"active_threats"` - // Whether device is infected. - Infected bool `json:"infected"` - // Whether device is active. - IsActive bool `json:"is_active"` - // Network status of device. - NetworkStatus ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus `json:"network_status"` - // operator - Operator ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestOperator `json:"operator"` - JSON zeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequest] -type zeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestJSON struct { - ConnectionID apijson.Field - ActiveThreats apijson.Field - Infected apijson.Field - IsActive apijson.Field - NetworkStatus apijson.Field - Operator apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequest) implementsZeroTrustDevicePostureNewResponseInput() { -} - -// Network status of device. -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnected ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connected" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnected ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnected" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnecting ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnecting" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnecting ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connecting" -) - -// operator -type ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestOperator string - -const ( - ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown65 ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = "<" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown66 ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = "<=" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown67 ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = ">" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown68 ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = ">=" - ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown69 ZeroTrustDevicePostureNewResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = "==" -) - -type ZeroTrustDevicePostureNewResponseMatch struct { - Platform ZeroTrustDevicePostureNewResponseMatchPlatform `json:"platform"` - JSON zeroTrustDevicePostureNewResponseMatchJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseMatchJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePostureNewResponseMatch] -type zeroTrustDevicePostureNewResponseMatchJSON struct { - Platform apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseMatch) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseMatchJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureNewResponseMatchPlatform string - -const ( - ZeroTrustDevicePostureNewResponseMatchPlatformWindows ZeroTrustDevicePostureNewResponseMatchPlatform = "windows" - ZeroTrustDevicePostureNewResponseMatchPlatformMac ZeroTrustDevicePostureNewResponseMatchPlatform = "mac" - ZeroTrustDevicePostureNewResponseMatchPlatformLinux ZeroTrustDevicePostureNewResponseMatchPlatform = "linux" - ZeroTrustDevicePostureNewResponseMatchPlatformAndroid ZeroTrustDevicePostureNewResponseMatchPlatform = "android" - ZeroTrustDevicePostureNewResponseMatchPlatformIos ZeroTrustDevicePostureNewResponseMatchPlatform = "ios" -) - -// The type of device posture rule. -type ZeroTrustDevicePostureNewResponseType string - -const ( - ZeroTrustDevicePostureNewResponseTypeFile ZeroTrustDevicePostureNewResponseType = "file" - ZeroTrustDevicePostureNewResponseTypeApplication ZeroTrustDevicePostureNewResponseType = "application" - ZeroTrustDevicePostureNewResponseTypeTanium ZeroTrustDevicePostureNewResponseType = "tanium" - ZeroTrustDevicePostureNewResponseTypeGateway ZeroTrustDevicePostureNewResponseType = "gateway" - ZeroTrustDevicePostureNewResponseTypeWARP ZeroTrustDevicePostureNewResponseType = "warp" - ZeroTrustDevicePostureNewResponseTypeDiskEncryption ZeroTrustDevicePostureNewResponseType = "disk_encryption" - ZeroTrustDevicePostureNewResponseTypeSentinelone ZeroTrustDevicePostureNewResponseType = "sentinelone" - ZeroTrustDevicePostureNewResponseTypeCarbonblack ZeroTrustDevicePostureNewResponseType = "carbonblack" - ZeroTrustDevicePostureNewResponseTypeFirewall ZeroTrustDevicePostureNewResponseType = "firewall" - ZeroTrustDevicePostureNewResponseTypeOSVersion ZeroTrustDevicePostureNewResponseType = "os_version" - ZeroTrustDevicePostureNewResponseTypeDomainJoined ZeroTrustDevicePostureNewResponseType = "domain_joined" - ZeroTrustDevicePostureNewResponseTypeClientCertificate ZeroTrustDevicePostureNewResponseType = "client_certificate" - ZeroTrustDevicePostureNewResponseTypeUniqueClientID ZeroTrustDevicePostureNewResponseType = "unique_client_id" - ZeroTrustDevicePostureNewResponseTypeKolide ZeroTrustDevicePostureNewResponseType = "kolide" - ZeroTrustDevicePostureNewResponseTypeTaniumS2s ZeroTrustDevicePostureNewResponseType = "tanium_s2s" - ZeroTrustDevicePostureNewResponseTypeCrowdstrikeS2s ZeroTrustDevicePostureNewResponseType = "crowdstrike_s2s" - ZeroTrustDevicePostureNewResponseTypeIntune ZeroTrustDevicePostureNewResponseType = "intune" - ZeroTrustDevicePostureNewResponseTypeWorkspaceOne ZeroTrustDevicePostureNewResponseType = "workspace_one" - ZeroTrustDevicePostureNewResponseTypeSentineloneS2s ZeroTrustDevicePostureNewResponseType = "sentinelone_s2s" -) - -type ZeroTrustDevicePostureUpdateResponse struct { - // API UUID. - ID string `json:"id"` - // The description of the device posture rule. - Description string `json:"description"` - // Sets the expiration time for a posture check result. If empty, the result - // remains valid until it is overwritten by new data from the WARP client. - Expiration string `json:"expiration"` - // The value to be checked against. - Input ZeroTrustDevicePostureUpdateResponseInput `json:"input"` - // The conditions that the client must match to run the rule. - Match []ZeroTrustDevicePostureUpdateResponseMatch `json:"match"` - // The name of the device posture rule. - Name string `json:"name"` - // Polling frequency for the WARP client posture check. Default: `5m` (poll every - // five minutes). Minimum: `1m`. - Schedule string `json:"schedule"` - // The type of device posture rule. - Type ZeroTrustDevicePostureUpdateResponseType `json:"type"` - JSON zeroTrustDevicePostureUpdateResponseJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePostureUpdateResponse] -type zeroTrustDevicePostureUpdateResponseJSON struct { - ID apijson.Field - Description apijson.Field - Expiration apijson.Field - Input apijson.Field - Match apijson.Field - Name apijson.Field - Schedule apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// The value to be checked against. -// -// Union satisfied by -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFileInputRequest], -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesUniqueClientIDInputRequest], -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesDomainJoinedInputRequest], -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequest], -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFirewallInputRequest], -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneInputRequest], -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCarbonblackInputRequest], -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesDiskEncryptionInputRequest], -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesApplicationInputRequest], -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesClientCertificateInputRequest], -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesWorkspaceOneInputRequest], -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequest], -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequest], -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequest], -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequest] or -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequest]. -type ZeroTrustDevicePostureUpdateResponseInput interface { - implementsZeroTrustDevicePostureUpdateResponseInput() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustDevicePostureUpdateResponseInput)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFileInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesUniqueClientIDInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesDomainJoinedInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFirewallInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCarbonblackInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesDiskEncryptionInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesApplicationInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesClientCertificateInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesWorkspaceOneInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequest{}), - }, - ) -} - -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFileInputRequest struct { - // Operating system - OperatingSystem ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFileInputRequestOperatingSystem `json:"operating_system,required"` - // File path. - Path string `json:"path,required"` - // Whether or not file exists - Exists bool `json:"exists"` - // SHA-256. - Sha256 string `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON zeroTrustDevicePostureUpdateResponseInputTeamsDevicesFileInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseInputTeamsDevicesFileInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFileInputRequest] -type zeroTrustDevicePostureUpdateResponseInputTeamsDevicesFileInputRequestJSON struct { - OperatingSystem apijson.Field - Path apijson.Field - Exists apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFileInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseInputTeamsDevicesFileInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFileInputRequest) implementsZeroTrustDevicePostureUpdateResponseInput() { -} - -// Operating system -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFileInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFileInputRequestOperatingSystemWindows ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFileInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFileInputRequestOperatingSystemLinux ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFileInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFileInputRequestOperatingSystemMac ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFileInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesUniqueClientIDInputRequest struct { - // List ID. - ID string `json:"id,required"` - // Operating System - OperatingSystem ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem `json:"operating_system,required"` - JSON zeroTrustDevicePostureUpdateResponseInputTeamsDevicesUniqueClientIDInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseInputTeamsDevicesUniqueClientIDInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesUniqueClientIDInputRequest] -type zeroTrustDevicePostureUpdateResponseInputTeamsDevicesUniqueClientIDInputRequestJSON struct { - ID apijson.Field - OperatingSystem apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesUniqueClientIDInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseInputTeamsDevicesUniqueClientIDInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesUniqueClientIDInputRequest) implementsZeroTrustDevicePostureUpdateResponseInput() { -} - -// Operating System -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemAndroid ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "android" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemIos ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "ios" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemChromeos ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "chromeos" -) - -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesDomainJoinedInputRequest struct { - // Operating System - OperatingSystem ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesDomainJoinedInputRequestOperatingSystem `json:"operating_system,required"` - // Domain - Domain string `json:"domain"` - JSON zeroTrustDevicePostureUpdateResponseInputTeamsDevicesDomainJoinedInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseInputTeamsDevicesDomainJoinedInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesDomainJoinedInputRequest] -type zeroTrustDevicePostureUpdateResponseInputTeamsDevicesDomainJoinedInputRequestJSON struct { - OperatingSystem apijson.Field - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesDomainJoinedInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseInputTeamsDevicesDomainJoinedInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesDomainJoinedInputRequest) implementsZeroTrustDevicePostureUpdateResponseInput() { -} - -// Operating System -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesDomainJoinedInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesDomainJoinedInputRequestOperatingSystemWindows ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesDomainJoinedInputRequestOperatingSystem = "windows" -) - -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequest struct { - // Operating System - OperatingSystem ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestOperatingSystem `json:"operating_system,required"` - // Operator - Operator ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestOperator `json:"operator,required"` - // Version of OS - Version string `json:"version,required"` - // Operating System Distribution Name (linux only) - OSDistroName string `json:"os_distro_name"` - // Version of OS Distribution (linux only) - OSDistroRevision string `json:"os_distro_revision"` - // Additional version data. For Mac or iOS, the Product Verison Extra. For Linux, - // the kernel release version. (Mac, iOS, and Linux only) - OSVersionExtra string `json:"os_version_extra"` - JSON zeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequest] -type zeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestJSON struct { - OperatingSystem apijson.Field - Operator apijson.Field - Version apijson.Field - OSDistroName apijson.Field - OSDistroRevision apijson.Field - OSVersionExtra apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequest) implementsZeroTrustDevicePostureUpdateResponseInput() { -} - -// Operating System -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestOperatingSystemWindows ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestOperatingSystem = "windows" -) - -// Operator -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestOperator string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown75 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestOperator = "<" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown76 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestOperator = "<=" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown77 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestOperator = ">" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown78 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestOperator = ">=" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown79 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesOSVersionInputRequestOperator = "==" -) - -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFirewallInputRequest struct { - // Enabled - Enabled bool `json:"enabled,required"` - // Operating System - OperatingSystem ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFirewallInputRequestOperatingSystem `json:"operating_system,required"` - JSON zeroTrustDevicePostureUpdateResponseInputTeamsDevicesFirewallInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseInputTeamsDevicesFirewallInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFirewallInputRequest] -type zeroTrustDevicePostureUpdateResponseInputTeamsDevicesFirewallInputRequestJSON struct { - Enabled apijson.Field - OperatingSystem apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFirewallInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseInputTeamsDevicesFirewallInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFirewallInputRequest) implementsZeroTrustDevicePostureUpdateResponseInput() { -} - -// Operating System -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFirewallInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFirewallInputRequestOperatingSystemWindows ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFirewallInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFirewallInputRequestOperatingSystemMac ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesFirewallInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneInputRequest struct { - // Operating system - OperatingSystem ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem `json:"operating_system,required"` - // File path. - Path string `json:"path,required"` - // SHA-256. - Sha256 string `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON zeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneInputRequest] -type zeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneInputRequestJSON struct { - OperatingSystem apijson.Field - Path apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneInputRequest) implementsZeroTrustDevicePostureUpdateResponseInput() { -} - -// Operating system -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneInputRequestOperatingSystemWindows ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneInputRequestOperatingSystemLinux ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneInputRequestOperatingSystemMac ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCarbonblackInputRequest struct { - // Operating system - OperatingSystem ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem `json:"operating_system,required"` - // File path. - Path string `json:"path,required"` - // SHA-256. - Sha256 string `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON zeroTrustDevicePostureUpdateResponseInputTeamsDevicesCarbonblackInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseInputTeamsDevicesCarbonblackInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCarbonblackInputRequest] -type zeroTrustDevicePostureUpdateResponseInputTeamsDevicesCarbonblackInputRequestJSON struct { - OperatingSystem apijson.Field - Path apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCarbonblackInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseInputTeamsDevicesCarbonblackInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCarbonblackInputRequest) implementsZeroTrustDevicePostureUpdateResponseInput() { -} - -// Operating system -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystemWindows ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystemLinux ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystemMac ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesDiskEncryptionInputRequest struct { - // List of volume names to be checked for encryption. - CheckDisks []string `json:"checkDisks"` - // Whether to check all disks for encryption. - RequireAll bool `json:"requireAll"` - JSON zeroTrustDevicePostureUpdateResponseInputTeamsDevicesDiskEncryptionInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseInputTeamsDevicesDiskEncryptionInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesDiskEncryptionInputRequest] -type zeroTrustDevicePostureUpdateResponseInputTeamsDevicesDiskEncryptionInputRequestJSON struct { - CheckDisks apijson.Field - RequireAll apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesDiskEncryptionInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseInputTeamsDevicesDiskEncryptionInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesDiskEncryptionInputRequest) implementsZeroTrustDevicePostureUpdateResponseInput() { -} - -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesApplicationInputRequest struct { - // Operating system - OperatingSystem ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesApplicationInputRequestOperatingSystem `json:"operating_system,required"` - // Path for the application. - Path string `json:"path,required"` - // SHA-256. - Sha256 string `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON zeroTrustDevicePostureUpdateResponseInputTeamsDevicesApplicationInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseInputTeamsDevicesApplicationInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesApplicationInputRequest] -type zeroTrustDevicePostureUpdateResponseInputTeamsDevicesApplicationInputRequestJSON struct { - OperatingSystem apijson.Field - Path apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesApplicationInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseInputTeamsDevicesApplicationInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesApplicationInputRequest) implementsZeroTrustDevicePostureUpdateResponseInput() { -} - -// Operating system -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesApplicationInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesApplicationInputRequestOperatingSystemWindows ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesApplicationInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesApplicationInputRequestOperatingSystemLinux ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesApplicationInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesApplicationInputRequestOperatingSystemMac ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesApplicationInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesClientCertificateInputRequest struct { - // UUID of Cloudflare managed certificate. - CertificateID string `json:"certificate_id,required"` - // Common Name that is protected by the certificate - Cn string `json:"cn,required"` - JSON zeroTrustDevicePostureUpdateResponseInputTeamsDevicesClientCertificateInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseInputTeamsDevicesClientCertificateInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesClientCertificateInputRequest] -type zeroTrustDevicePostureUpdateResponseInputTeamsDevicesClientCertificateInputRequestJSON struct { - CertificateID apijson.Field - Cn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesClientCertificateInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseInputTeamsDevicesClientCertificateInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesClientCertificateInputRequest) implementsZeroTrustDevicePostureUpdateResponseInput() { -} - -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesWorkspaceOneInputRequest struct { - // Compliance Status - ComplianceStatus ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus `json:"compliance_status,required"` - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustDevicePostureUpdateResponseInputTeamsDevicesWorkspaceOneInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseInputTeamsDevicesWorkspaceOneInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesWorkspaceOneInputRequest] -type zeroTrustDevicePostureUpdateResponseInputTeamsDevicesWorkspaceOneInputRequestJSON struct { - ComplianceStatus apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesWorkspaceOneInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseInputTeamsDevicesWorkspaceOneInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesWorkspaceOneInputRequest) implementsZeroTrustDevicePostureUpdateResponseInput() { -} - -// Compliance Status -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusCompliant ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "compliant" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusNoncompliant ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "noncompliant" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusUnknown ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "unknown" -) - -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequest struct { - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // For more details on last seen, please refer to the Crowdstrike documentation. - LastSeen string `json:"last_seen"` - // Operator - Operator ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestOperator `json:"operator"` - // Os Version - OS string `json:"os"` - // overall - Overall string `json:"overall"` - // SensorConfig - SensorConfig string `json:"sensor_config"` - // For more details on state, please refer to the Crowdstrike documentation. - State ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestState `json:"state"` - // Version - Version string `json:"version"` - // Version Operator - VersionOperator ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator `json:"versionOperator"` - JSON zeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequest] -type zeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestJSON struct { - ConnectionID apijson.Field - LastSeen apijson.Field - Operator apijson.Field - OS apijson.Field - Overall apijson.Field - SensorConfig apijson.Field - State apijson.Field - Version apijson.Field - VersionOperator apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequest) implementsZeroTrustDevicePostureUpdateResponseInput() { -} - -// Operator -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestOperator string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown85 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = "<" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown86 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = "<=" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown87 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = ">" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown88 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = ">=" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown89 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = "==" -) - -// For more details on state, please refer to the Crowdstrike documentation. -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestState string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestStateOnline ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestState = "online" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestStateOffline ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestState = "offline" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestStateUnknown ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestState = "unknown" -) - -// Version Operator -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown95 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown96 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<=" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown97 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown98 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">=" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown99 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "==" -) - -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequest struct { - // Compliance Status - ComplianceStatus ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequestComplianceStatus `json:"compliance_status,required"` - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequest] -type zeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequestJSON struct { - ComplianceStatus apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequest) implementsZeroTrustDevicePostureUpdateResponseInput() { -} - -// Compliance Status -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequestComplianceStatus string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequestComplianceStatusCompliant ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "compliant" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequestComplianceStatusNoncompliant ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "noncompliant" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequestComplianceStatusUnknown ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "unknown" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequestComplianceStatusNotapplicable ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "notapplicable" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequestComplianceStatusIngraceperiod ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "ingraceperiod" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequestComplianceStatusError ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "error" -) - -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequest struct { - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // Count Operator - CountOperator ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequestCountOperator `json:"countOperator,required"` - // The Number of Issues. - IssueCount string `json:"issue_count,required"` - JSON zeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequest] -type zeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequestJSON struct { - ConnectionID apijson.Field - CountOperator apijson.Field - IssueCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequest) implementsZeroTrustDevicePostureUpdateResponseInput() { -} - -// Count Operator -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequestCountOperator string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown105 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequestCountOperator = "<" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown106 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequestCountOperator = "<=" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown107 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequestCountOperator = ">" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown108 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequestCountOperator = ">=" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown109 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesKolideInputRequestCountOperator = "==" -) - -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequest struct { - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // For more details on eid last seen, refer to the Tanium documentation. - EidLastSeen string `json:"eid_last_seen"` - // Operator to evaluate risk_level or eid_last_seen. - Operator ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestOperator `json:"operator"` - // For more details on risk level, refer to the Tanium documentation. - RiskLevel ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestRiskLevel `json:"risk_level"` - // Score Operator - ScoreOperator ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestScoreOperator `json:"scoreOperator"` - // For more details on total score, refer to the Tanium documentation. - TotalScore float64 `json:"total_score"` - JSON zeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequest] -type zeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestJSON struct { - ConnectionID apijson.Field - EidLastSeen apijson.Field - Operator apijson.Field - RiskLevel apijson.Field - ScoreOperator apijson.Field - TotalScore apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequest) implementsZeroTrustDevicePostureUpdateResponseInput() { -} - -// Operator to evaluate risk_level or eid_last_seen. -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestOperator string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown115 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestOperator = "<" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown116 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestOperator = "<=" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown117 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestOperator = ">" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown118 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestOperator = ">=" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown119 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestOperator = "==" -) - -// For more details on risk level, refer to the Tanium documentation. -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestRiskLevel string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestRiskLevelLow ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestRiskLevel = "low" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestRiskLevelMedium ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestRiskLevel = "medium" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestRiskLevelHigh ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestRiskLevel = "high" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestRiskLevelCritical ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestRiskLevel = "critical" -) - -// Score Operator -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestScoreOperator string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown125 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestScoreOperator = "<" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown126 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestScoreOperator = "<=" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown127 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestScoreOperator = ">" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown128 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestScoreOperator = ">=" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown129 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesTaniumInputRequestScoreOperator = "==" -) - -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequest struct { - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // The Number of active threats. - ActiveThreats float64 `json:"active_threats"` - // Whether device is infected. - Infected bool `json:"infected"` - // Whether device is active. - IsActive bool `json:"is_active"` - // Network status of device. - NetworkStatus ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus `json:"network_status"` - // operator - Operator ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestOperator `json:"operator"` - JSON zeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequest] -type zeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestJSON struct { - ConnectionID apijson.Field - ActiveThreats apijson.Field - Infected apijson.Field - IsActive apijson.Field - NetworkStatus apijson.Field - Operator apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequest) implementsZeroTrustDevicePostureUpdateResponseInput() { -} - -// Network status of device. -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnected ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connected" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnected ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnected" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnecting ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnecting" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnecting ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connecting" -) - -// operator -type ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestOperator string - -const ( - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown135 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = "<" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown136 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = "<=" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown137 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = ">" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown138 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = ">=" - ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown139 ZeroTrustDevicePostureUpdateResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = "==" -) - -type ZeroTrustDevicePostureUpdateResponseMatch struct { - Platform ZeroTrustDevicePostureUpdateResponseMatchPlatform `json:"platform"` - JSON zeroTrustDevicePostureUpdateResponseMatchJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseMatchJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePostureUpdateResponseMatch] -type zeroTrustDevicePostureUpdateResponseMatchJSON struct { - Platform apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseMatch) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseMatchJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureUpdateResponseMatchPlatform string - -const ( - ZeroTrustDevicePostureUpdateResponseMatchPlatformWindows ZeroTrustDevicePostureUpdateResponseMatchPlatform = "windows" - ZeroTrustDevicePostureUpdateResponseMatchPlatformMac ZeroTrustDevicePostureUpdateResponseMatchPlatform = "mac" - ZeroTrustDevicePostureUpdateResponseMatchPlatformLinux ZeroTrustDevicePostureUpdateResponseMatchPlatform = "linux" - ZeroTrustDevicePostureUpdateResponseMatchPlatformAndroid ZeroTrustDevicePostureUpdateResponseMatchPlatform = "android" - ZeroTrustDevicePostureUpdateResponseMatchPlatformIos ZeroTrustDevicePostureUpdateResponseMatchPlatform = "ios" -) - -// The type of device posture rule. -type ZeroTrustDevicePostureUpdateResponseType string - -const ( - ZeroTrustDevicePostureUpdateResponseTypeFile ZeroTrustDevicePostureUpdateResponseType = "file" - ZeroTrustDevicePostureUpdateResponseTypeApplication ZeroTrustDevicePostureUpdateResponseType = "application" - ZeroTrustDevicePostureUpdateResponseTypeTanium ZeroTrustDevicePostureUpdateResponseType = "tanium" - ZeroTrustDevicePostureUpdateResponseTypeGateway ZeroTrustDevicePostureUpdateResponseType = "gateway" - ZeroTrustDevicePostureUpdateResponseTypeWARP ZeroTrustDevicePostureUpdateResponseType = "warp" - ZeroTrustDevicePostureUpdateResponseTypeDiskEncryption ZeroTrustDevicePostureUpdateResponseType = "disk_encryption" - ZeroTrustDevicePostureUpdateResponseTypeSentinelone ZeroTrustDevicePostureUpdateResponseType = "sentinelone" - ZeroTrustDevicePostureUpdateResponseTypeCarbonblack ZeroTrustDevicePostureUpdateResponseType = "carbonblack" - ZeroTrustDevicePostureUpdateResponseTypeFirewall ZeroTrustDevicePostureUpdateResponseType = "firewall" - ZeroTrustDevicePostureUpdateResponseTypeOSVersion ZeroTrustDevicePostureUpdateResponseType = "os_version" - ZeroTrustDevicePostureUpdateResponseTypeDomainJoined ZeroTrustDevicePostureUpdateResponseType = "domain_joined" - ZeroTrustDevicePostureUpdateResponseTypeClientCertificate ZeroTrustDevicePostureUpdateResponseType = "client_certificate" - ZeroTrustDevicePostureUpdateResponseTypeUniqueClientID ZeroTrustDevicePostureUpdateResponseType = "unique_client_id" - ZeroTrustDevicePostureUpdateResponseTypeKolide ZeroTrustDevicePostureUpdateResponseType = "kolide" - ZeroTrustDevicePostureUpdateResponseTypeTaniumS2s ZeroTrustDevicePostureUpdateResponseType = "tanium_s2s" - ZeroTrustDevicePostureUpdateResponseTypeCrowdstrikeS2s ZeroTrustDevicePostureUpdateResponseType = "crowdstrike_s2s" - ZeroTrustDevicePostureUpdateResponseTypeIntune ZeroTrustDevicePostureUpdateResponseType = "intune" - ZeroTrustDevicePostureUpdateResponseTypeWorkspaceOne ZeroTrustDevicePostureUpdateResponseType = "workspace_one" - ZeroTrustDevicePostureUpdateResponseTypeSentineloneS2s ZeroTrustDevicePostureUpdateResponseType = "sentinelone_s2s" -) - -type ZeroTrustDevicePostureListResponse struct { - // API UUID. - ID string `json:"id"` - // The description of the device posture rule. - Description string `json:"description"` - // Sets the expiration time for a posture check result. If empty, the result - // remains valid until it is overwritten by new data from the WARP client. - Expiration string `json:"expiration"` - // The value to be checked against. - Input ZeroTrustDevicePostureListResponseInput `json:"input"` - // The conditions that the client must match to run the rule. - Match []ZeroTrustDevicePostureListResponseMatch `json:"match"` - // The name of the device posture rule. - Name string `json:"name"` - // Polling frequency for the WARP client posture check. Default: `5m` (poll every - // five minutes). Minimum: `1m`. - Schedule string `json:"schedule"` - // The type of device posture rule. - Type ZeroTrustDevicePostureListResponseType `json:"type"` - JSON zeroTrustDevicePostureListResponseJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDevicePostureListResponse] -type zeroTrustDevicePostureListResponseJSON struct { - ID apijson.Field - Description apijson.Field - Expiration apijson.Field - Input apijson.Field - Match apijson.Field - Name apijson.Field - Schedule apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseJSON) RawJSON() string { - return r.raw -} - -// The value to be checked against. -// -// Union satisfied by -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesFileInputRequest], -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesUniqueClientIDInputRequest], -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesDomainJoinedInputRequest], -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequest], -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesFirewallInputRequest], -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneInputRequest], -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesCarbonblackInputRequest], -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesDiskEncryptionInputRequest], -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesApplicationInputRequest], -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesClientCertificateInputRequest], -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesWorkspaceOneInputRequest], -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequest], -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequest], -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequest], -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequest] or -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequest]. -type ZeroTrustDevicePostureListResponseInput interface { - implementsZeroTrustDevicePostureListResponseInput() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustDevicePostureListResponseInput)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureListResponseInputTeamsDevicesFileInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureListResponseInputTeamsDevicesUniqueClientIDInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureListResponseInputTeamsDevicesDomainJoinedInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureListResponseInputTeamsDevicesFirewallInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureListResponseInputTeamsDevicesCarbonblackInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureListResponseInputTeamsDevicesDiskEncryptionInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureListResponseInputTeamsDevicesApplicationInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureListResponseInputTeamsDevicesClientCertificateInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureListResponseInputTeamsDevicesWorkspaceOneInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequest{}), - }, - ) -} - -type ZeroTrustDevicePostureListResponseInputTeamsDevicesFileInputRequest struct { - // Operating system - OperatingSystem ZeroTrustDevicePostureListResponseInputTeamsDevicesFileInputRequestOperatingSystem `json:"operating_system,required"` - // File path. - Path string `json:"path,required"` - // Whether or not file exists - Exists bool `json:"exists"` - // SHA-256. - Sha256 string `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON zeroTrustDevicePostureListResponseInputTeamsDevicesFileInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseInputTeamsDevicesFileInputRequestJSON contains -// the JSON metadata for the struct -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesFileInputRequest] -type zeroTrustDevicePostureListResponseInputTeamsDevicesFileInputRequestJSON struct { - OperatingSystem apijson.Field - Path apijson.Field - Exists apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseInputTeamsDevicesFileInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseInputTeamsDevicesFileInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureListResponseInputTeamsDevicesFileInputRequest) implementsZeroTrustDevicePostureListResponseInput() { -} - -// Operating system -type ZeroTrustDevicePostureListResponseInputTeamsDevicesFileInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesFileInputRequestOperatingSystemWindows ZeroTrustDevicePostureListResponseInputTeamsDevicesFileInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureListResponseInputTeamsDevicesFileInputRequestOperatingSystemLinux ZeroTrustDevicePostureListResponseInputTeamsDevicesFileInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureListResponseInputTeamsDevicesFileInputRequestOperatingSystemMac ZeroTrustDevicePostureListResponseInputTeamsDevicesFileInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureListResponseInputTeamsDevicesUniqueClientIDInputRequest struct { - // List ID. - ID string `json:"id,required"` - // Operating System - OperatingSystem ZeroTrustDevicePostureListResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem `json:"operating_system,required"` - JSON zeroTrustDevicePostureListResponseInputTeamsDevicesUniqueClientIDInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseInputTeamsDevicesUniqueClientIDInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesUniqueClientIDInputRequest] -type zeroTrustDevicePostureListResponseInputTeamsDevicesUniqueClientIDInputRequestJSON struct { - ID apijson.Field - OperatingSystem apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseInputTeamsDevicesUniqueClientIDInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseInputTeamsDevicesUniqueClientIDInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureListResponseInputTeamsDevicesUniqueClientIDInputRequest) implementsZeroTrustDevicePostureListResponseInput() { -} - -// Operating System -type ZeroTrustDevicePostureListResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemAndroid ZeroTrustDevicePostureListResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "android" - ZeroTrustDevicePostureListResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemIos ZeroTrustDevicePostureListResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "ios" - ZeroTrustDevicePostureListResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemChromeos ZeroTrustDevicePostureListResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "chromeos" -) - -type ZeroTrustDevicePostureListResponseInputTeamsDevicesDomainJoinedInputRequest struct { - // Operating System - OperatingSystem ZeroTrustDevicePostureListResponseInputTeamsDevicesDomainJoinedInputRequestOperatingSystem `json:"operating_system,required"` - // Domain - Domain string `json:"domain"` - JSON zeroTrustDevicePostureListResponseInputTeamsDevicesDomainJoinedInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseInputTeamsDevicesDomainJoinedInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesDomainJoinedInputRequest] -type zeroTrustDevicePostureListResponseInputTeamsDevicesDomainJoinedInputRequestJSON struct { - OperatingSystem apijson.Field - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseInputTeamsDevicesDomainJoinedInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseInputTeamsDevicesDomainJoinedInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureListResponseInputTeamsDevicesDomainJoinedInputRequest) implementsZeroTrustDevicePostureListResponseInput() { -} - -// Operating System -type ZeroTrustDevicePostureListResponseInputTeamsDevicesDomainJoinedInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesDomainJoinedInputRequestOperatingSystemWindows ZeroTrustDevicePostureListResponseInputTeamsDevicesDomainJoinedInputRequestOperatingSystem = "windows" -) - -type ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequest struct { - // Operating System - OperatingSystem ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestOperatingSystem `json:"operating_system,required"` - // Operator - Operator ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestOperator `json:"operator,required"` - // Version of OS - Version string `json:"version,required"` - // Operating System Distribution Name (linux only) - OSDistroName string `json:"os_distro_name"` - // Version of OS Distribution (linux only) - OSDistroRevision string `json:"os_distro_revision"` - // Additional version data. For Mac or iOS, the Product Verison Extra. For Linux, - // the kernel release version. (Mac, iOS, and Linux only) - OSVersionExtra string `json:"os_version_extra"` - JSON zeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequest] -type zeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestJSON struct { - OperatingSystem apijson.Field - Operator apijson.Field - Version apijson.Field - OSDistroName apijson.Field - OSDistroRevision apijson.Field - OSVersionExtra apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequest) implementsZeroTrustDevicePostureListResponseInput() { -} - -// Operating System -type ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestOperatingSystemWindows ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestOperatingSystem = "windows" -) - -// Operator -type ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestOperator string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown145 ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestOperator = "<" - ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown146 ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestOperator = "<=" - ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown147 ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestOperator = ">" - ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown148 ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestOperator = ">=" - ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown149 ZeroTrustDevicePostureListResponseInputTeamsDevicesOSVersionInputRequestOperator = "==" -) - -type ZeroTrustDevicePostureListResponseInputTeamsDevicesFirewallInputRequest struct { - // Enabled - Enabled bool `json:"enabled,required"` - // Operating System - OperatingSystem ZeroTrustDevicePostureListResponseInputTeamsDevicesFirewallInputRequestOperatingSystem `json:"operating_system,required"` - JSON zeroTrustDevicePostureListResponseInputTeamsDevicesFirewallInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseInputTeamsDevicesFirewallInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesFirewallInputRequest] -type zeroTrustDevicePostureListResponseInputTeamsDevicesFirewallInputRequestJSON struct { - Enabled apijson.Field - OperatingSystem apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseInputTeamsDevicesFirewallInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseInputTeamsDevicesFirewallInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureListResponseInputTeamsDevicesFirewallInputRequest) implementsZeroTrustDevicePostureListResponseInput() { -} - -// Operating System -type ZeroTrustDevicePostureListResponseInputTeamsDevicesFirewallInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesFirewallInputRequestOperatingSystemWindows ZeroTrustDevicePostureListResponseInputTeamsDevicesFirewallInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureListResponseInputTeamsDevicesFirewallInputRequestOperatingSystemMac ZeroTrustDevicePostureListResponseInputTeamsDevicesFirewallInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneInputRequest struct { - // Operating system - OperatingSystem ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem `json:"operating_system,required"` - // File path. - Path string `json:"path,required"` - // SHA-256. - Sha256 string `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON zeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneInputRequest] -type zeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneInputRequestJSON struct { - OperatingSystem apijson.Field - Path apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneInputRequest) implementsZeroTrustDevicePostureListResponseInput() { -} - -// Operating system -type ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneInputRequestOperatingSystemWindows ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneInputRequestOperatingSystemLinux ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneInputRequestOperatingSystemMac ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureListResponseInputTeamsDevicesCarbonblackInputRequest struct { - // Operating system - OperatingSystem ZeroTrustDevicePostureListResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem `json:"operating_system,required"` - // File path. - Path string `json:"path,required"` - // SHA-256. - Sha256 string `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON zeroTrustDevicePostureListResponseInputTeamsDevicesCarbonblackInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseInputTeamsDevicesCarbonblackInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesCarbonblackInputRequest] -type zeroTrustDevicePostureListResponseInputTeamsDevicesCarbonblackInputRequestJSON struct { - OperatingSystem apijson.Field - Path apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseInputTeamsDevicesCarbonblackInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseInputTeamsDevicesCarbonblackInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureListResponseInputTeamsDevicesCarbonblackInputRequest) implementsZeroTrustDevicePostureListResponseInput() { -} - -// Operating system -type ZeroTrustDevicePostureListResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystemWindows ZeroTrustDevicePostureListResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureListResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystemLinux ZeroTrustDevicePostureListResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureListResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystemMac ZeroTrustDevicePostureListResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureListResponseInputTeamsDevicesDiskEncryptionInputRequest struct { - // List of volume names to be checked for encryption. - CheckDisks []string `json:"checkDisks"` - // Whether to check all disks for encryption. - RequireAll bool `json:"requireAll"` - JSON zeroTrustDevicePostureListResponseInputTeamsDevicesDiskEncryptionInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseInputTeamsDevicesDiskEncryptionInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesDiskEncryptionInputRequest] -type zeroTrustDevicePostureListResponseInputTeamsDevicesDiskEncryptionInputRequestJSON struct { - CheckDisks apijson.Field - RequireAll apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseInputTeamsDevicesDiskEncryptionInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseInputTeamsDevicesDiskEncryptionInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureListResponseInputTeamsDevicesDiskEncryptionInputRequest) implementsZeroTrustDevicePostureListResponseInput() { -} - -type ZeroTrustDevicePostureListResponseInputTeamsDevicesApplicationInputRequest struct { - // Operating system - OperatingSystem ZeroTrustDevicePostureListResponseInputTeamsDevicesApplicationInputRequestOperatingSystem `json:"operating_system,required"` - // Path for the application. - Path string `json:"path,required"` - // SHA-256. - Sha256 string `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON zeroTrustDevicePostureListResponseInputTeamsDevicesApplicationInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseInputTeamsDevicesApplicationInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesApplicationInputRequest] -type zeroTrustDevicePostureListResponseInputTeamsDevicesApplicationInputRequestJSON struct { - OperatingSystem apijson.Field - Path apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseInputTeamsDevicesApplicationInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseInputTeamsDevicesApplicationInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureListResponseInputTeamsDevicesApplicationInputRequest) implementsZeroTrustDevicePostureListResponseInput() { -} - -// Operating system -type ZeroTrustDevicePostureListResponseInputTeamsDevicesApplicationInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesApplicationInputRequestOperatingSystemWindows ZeroTrustDevicePostureListResponseInputTeamsDevicesApplicationInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureListResponseInputTeamsDevicesApplicationInputRequestOperatingSystemLinux ZeroTrustDevicePostureListResponseInputTeamsDevicesApplicationInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureListResponseInputTeamsDevicesApplicationInputRequestOperatingSystemMac ZeroTrustDevicePostureListResponseInputTeamsDevicesApplicationInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureListResponseInputTeamsDevicesClientCertificateInputRequest struct { - // UUID of Cloudflare managed certificate. - CertificateID string `json:"certificate_id,required"` - // Common Name that is protected by the certificate - Cn string `json:"cn,required"` - JSON zeroTrustDevicePostureListResponseInputTeamsDevicesClientCertificateInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseInputTeamsDevicesClientCertificateInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesClientCertificateInputRequest] -type zeroTrustDevicePostureListResponseInputTeamsDevicesClientCertificateInputRequestJSON struct { - CertificateID apijson.Field - Cn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseInputTeamsDevicesClientCertificateInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseInputTeamsDevicesClientCertificateInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureListResponseInputTeamsDevicesClientCertificateInputRequest) implementsZeroTrustDevicePostureListResponseInput() { -} - -type ZeroTrustDevicePostureListResponseInputTeamsDevicesWorkspaceOneInputRequest struct { - // Compliance Status - ComplianceStatus ZeroTrustDevicePostureListResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus `json:"compliance_status,required"` - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustDevicePostureListResponseInputTeamsDevicesWorkspaceOneInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseInputTeamsDevicesWorkspaceOneInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesWorkspaceOneInputRequest] -type zeroTrustDevicePostureListResponseInputTeamsDevicesWorkspaceOneInputRequestJSON struct { - ComplianceStatus apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseInputTeamsDevicesWorkspaceOneInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseInputTeamsDevicesWorkspaceOneInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureListResponseInputTeamsDevicesWorkspaceOneInputRequest) implementsZeroTrustDevicePostureListResponseInput() { -} - -// Compliance Status -type ZeroTrustDevicePostureListResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusCompliant ZeroTrustDevicePostureListResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "compliant" - ZeroTrustDevicePostureListResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusNoncompliant ZeroTrustDevicePostureListResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "noncompliant" - ZeroTrustDevicePostureListResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusUnknown ZeroTrustDevicePostureListResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "unknown" -) - -type ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequest struct { - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // For more details on last seen, please refer to the Crowdstrike documentation. - LastSeen string `json:"last_seen"` - // Operator - Operator ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestOperator `json:"operator"` - // Os Version - OS string `json:"os"` - // overall - Overall string `json:"overall"` - // SensorConfig - SensorConfig string `json:"sensor_config"` - // For more details on state, please refer to the Crowdstrike documentation. - State ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestState `json:"state"` - // Version - Version string `json:"version"` - // Version Operator - VersionOperator ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator `json:"versionOperator"` - JSON zeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequest] -type zeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestJSON struct { - ConnectionID apijson.Field - LastSeen apijson.Field - Operator apijson.Field - OS apijson.Field - Overall apijson.Field - SensorConfig apijson.Field - State apijson.Field - Version apijson.Field - VersionOperator apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequest) implementsZeroTrustDevicePostureListResponseInput() { -} - -// Operator -type ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestOperator string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown155 ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = "<" - ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown156 ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = "<=" - ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown157 ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = ">" - ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown158 ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = ">=" - ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown159 ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = "==" -) - -// For more details on state, please refer to the Crowdstrike documentation. -type ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestState string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestStateOnline ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestState = "online" - ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestStateOffline ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestState = "offline" - ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestStateUnknown ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestState = "unknown" -) - -// Version Operator -type ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown165 ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<" - ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown166 ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<=" - ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown167 ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">" - ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown168 ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">=" - ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown169 ZeroTrustDevicePostureListResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "==" -) - -type ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequest struct { - // Compliance Status - ComplianceStatus ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequestComplianceStatus `json:"compliance_status,required"` - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequest] -type zeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequestJSON struct { - ComplianceStatus apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequest) implementsZeroTrustDevicePostureListResponseInput() { -} - -// Compliance Status -type ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequestComplianceStatus string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequestComplianceStatusCompliant ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "compliant" - ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequestComplianceStatusNoncompliant ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "noncompliant" - ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequestComplianceStatusUnknown ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "unknown" - ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequestComplianceStatusNotapplicable ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "notapplicable" - ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequestComplianceStatusIngraceperiod ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "ingraceperiod" - ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequestComplianceStatusError ZeroTrustDevicePostureListResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "error" -) - -type ZeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequest struct { - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // Count Operator - CountOperator ZeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequestCountOperator `json:"countOperator,required"` - // The Number of Issues. - IssueCount string `json:"issue_count,required"` - JSON zeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequest] -type zeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequestJSON struct { - ConnectionID apijson.Field - CountOperator apijson.Field - IssueCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequest) implementsZeroTrustDevicePostureListResponseInput() { -} - -// Count Operator -type ZeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequestCountOperator string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown175 ZeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequestCountOperator = "<" - ZeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown176 ZeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequestCountOperator = "<=" - ZeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown177 ZeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequestCountOperator = ">" - ZeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown178 ZeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequestCountOperator = ">=" - ZeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown179 ZeroTrustDevicePostureListResponseInputTeamsDevicesKolideInputRequestCountOperator = "==" -) - -type ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequest struct { - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // For more details on eid last seen, refer to the Tanium documentation. - EidLastSeen string `json:"eid_last_seen"` - // Operator to evaluate risk_level or eid_last_seen. - Operator ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestOperator `json:"operator"` - // For more details on risk level, refer to the Tanium documentation. - RiskLevel ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestRiskLevel `json:"risk_level"` - // Score Operator - ScoreOperator ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestScoreOperator `json:"scoreOperator"` - // For more details on total score, refer to the Tanium documentation. - TotalScore float64 `json:"total_score"` - JSON zeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequest] -type zeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestJSON struct { - ConnectionID apijson.Field - EidLastSeen apijson.Field - Operator apijson.Field - RiskLevel apijson.Field - ScoreOperator apijson.Field - TotalScore apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequest) implementsZeroTrustDevicePostureListResponseInput() { -} - -// Operator to evaluate risk_level or eid_last_seen. -type ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestOperator string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown185 ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestOperator = "<" - ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown186 ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestOperator = "<=" - ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown187 ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestOperator = ">" - ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown188 ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestOperator = ">=" - ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown189 ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestOperator = "==" -) - -// For more details on risk level, refer to the Tanium documentation. -type ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestRiskLevel string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestRiskLevelLow ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestRiskLevel = "low" - ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestRiskLevelMedium ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestRiskLevel = "medium" - ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestRiskLevelHigh ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestRiskLevel = "high" - ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestRiskLevelCritical ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestRiskLevel = "critical" -) - -// Score Operator -type ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestScoreOperator string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown195 ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestScoreOperator = "<" - ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown196 ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestScoreOperator = "<=" - ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown197 ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestScoreOperator = ">" - ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown198 ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestScoreOperator = ">=" - ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown199 ZeroTrustDevicePostureListResponseInputTeamsDevicesTaniumInputRequestScoreOperator = "==" -) - -type ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequest struct { - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // The Number of active threats. - ActiveThreats float64 `json:"active_threats"` - // Whether device is infected. - Infected bool `json:"infected"` - // Whether device is active. - IsActive bool `json:"is_active"` - // Network status of device. - NetworkStatus ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus `json:"network_status"` - // operator - Operator ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestOperator `json:"operator"` - JSON zeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequest] -type zeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestJSON struct { - ConnectionID apijson.Field - ActiveThreats apijson.Field - Infected apijson.Field - IsActive apijson.Field - NetworkStatus apijson.Field - Operator apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequest) implementsZeroTrustDevicePostureListResponseInput() { -} - -// Network status of device. -type ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnected ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connected" - ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnected ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnected" - ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnecting ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnecting" - ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnecting ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connecting" -) - -// operator -type ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestOperator string - -const ( - ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown205 ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = "<" - ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown206 ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = "<=" - ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown207 ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = ">" - ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown208 ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = ">=" - ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown209 ZeroTrustDevicePostureListResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = "==" -) - -type ZeroTrustDevicePostureListResponseMatch struct { - Platform ZeroTrustDevicePostureListResponseMatchPlatform `json:"platform"` - JSON zeroTrustDevicePostureListResponseMatchJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseMatchJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePostureListResponseMatch] -type zeroTrustDevicePostureListResponseMatchJSON struct { - Platform apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseMatch) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseMatchJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureListResponseMatchPlatform string - -const ( - ZeroTrustDevicePostureListResponseMatchPlatformWindows ZeroTrustDevicePostureListResponseMatchPlatform = "windows" - ZeroTrustDevicePostureListResponseMatchPlatformMac ZeroTrustDevicePostureListResponseMatchPlatform = "mac" - ZeroTrustDevicePostureListResponseMatchPlatformLinux ZeroTrustDevicePostureListResponseMatchPlatform = "linux" - ZeroTrustDevicePostureListResponseMatchPlatformAndroid ZeroTrustDevicePostureListResponseMatchPlatform = "android" - ZeroTrustDevicePostureListResponseMatchPlatformIos ZeroTrustDevicePostureListResponseMatchPlatform = "ios" -) - -// The type of device posture rule. -type ZeroTrustDevicePostureListResponseType string - -const ( - ZeroTrustDevicePostureListResponseTypeFile ZeroTrustDevicePostureListResponseType = "file" - ZeroTrustDevicePostureListResponseTypeApplication ZeroTrustDevicePostureListResponseType = "application" - ZeroTrustDevicePostureListResponseTypeTanium ZeroTrustDevicePostureListResponseType = "tanium" - ZeroTrustDevicePostureListResponseTypeGateway ZeroTrustDevicePostureListResponseType = "gateway" - ZeroTrustDevicePostureListResponseTypeWARP ZeroTrustDevicePostureListResponseType = "warp" - ZeroTrustDevicePostureListResponseTypeDiskEncryption ZeroTrustDevicePostureListResponseType = "disk_encryption" - ZeroTrustDevicePostureListResponseTypeSentinelone ZeroTrustDevicePostureListResponseType = "sentinelone" - ZeroTrustDevicePostureListResponseTypeCarbonblack ZeroTrustDevicePostureListResponseType = "carbonblack" - ZeroTrustDevicePostureListResponseTypeFirewall ZeroTrustDevicePostureListResponseType = "firewall" - ZeroTrustDevicePostureListResponseTypeOSVersion ZeroTrustDevicePostureListResponseType = "os_version" - ZeroTrustDevicePostureListResponseTypeDomainJoined ZeroTrustDevicePostureListResponseType = "domain_joined" - ZeroTrustDevicePostureListResponseTypeClientCertificate ZeroTrustDevicePostureListResponseType = "client_certificate" - ZeroTrustDevicePostureListResponseTypeUniqueClientID ZeroTrustDevicePostureListResponseType = "unique_client_id" - ZeroTrustDevicePostureListResponseTypeKolide ZeroTrustDevicePostureListResponseType = "kolide" - ZeroTrustDevicePostureListResponseTypeTaniumS2s ZeroTrustDevicePostureListResponseType = "tanium_s2s" - ZeroTrustDevicePostureListResponseTypeCrowdstrikeS2s ZeroTrustDevicePostureListResponseType = "crowdstrike_s2s" - ZeroTrustDevicePostureListResponseTypeIntune ZeroTrustDevicePostureListResponseType = "intune" - ZeroTrustDevicePostureListResponseTypeWorkspaceOne ZeroTrustDevicePostureListResponseType = "workspace_one" - ZeroTrustDevicePostureListResponseTypeSentineloneS2s ZeroTrustDevicePostureListResponseType = "sentinelone_s2s" -) - -type ZeroTrustDevicePostureDeleteResponse struct { - // API UUID. - ID string `json:"id"` - JSON zeroTrustDevicePostureDeleteResponseJSON `json:"-"` -} - -// zeroTrustDevicePostureDeleteResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePostureDeleteResponse] -type zeroTrustDevicePostureDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureGetResponse struct { - // API UUID. - ID string `json:"id"` - // The description of the device posture rule. - Description string `json:"description"` - // Sets the expiration time for a posture check result. If empty, the result - // remains valid until it is overwritten by new data from the WARP client. - Expiration string `json:"expiration"` - // The value to be checked against. - Input ZeroTrustDevicePostureGetResponseInput `json:"input"` - // The conditions that the client must match to run the rule. - Match []ZeroTrustDevicePostureGetResponseMatch `json:"match"` - // The name of the device posture rule. - Name string `json:"name"` - // Polling frequency for the WARP client posture check. Default: `5m` (poll every - // five minutes). Minimum: `1m`. - Schedule string `json:"schedule"` - // The type of device posture rule. - Type ZeroTrustDevicePostureGetResponseType `json:"type"` - JSON zeroTrustDevicePostureGetResponseJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDevicePostureGetResponse] -type zeroTrustDevicePostureGetResponseJSON struct { - ID apijson.Field - Description apijson.Field - Expiration apijson.Field - Input apijson.Field - Match apijson.Field - Name apijson.Field - Schedule apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseJSON) RawJSON() string { - return r.raw -} - -// The value to be checked against. -// -// Union satisfied by -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesFileInputRequest], -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesUniqueClientIDInputRequest], -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesDomainJoinedInputRequest], -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequest], -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesFirewallInputRequest], -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneInputRequest], -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesCarbonblackInputRequest], -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesDiskEncryptionInputRequest], -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesApplicationInputRequest], -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesClientCertificateInputRequest], -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesWorkspaceOneInputRequest], -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequest], -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequest], -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequest], -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequest] or -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequest]. -type ZeroTrustDevicePostureGetResponseInput interface { - implementsZeroTrustDevicePostureGetResponseInput() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustDevicePostureGetResponseInput)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureGetResponseInputTeamsDevicesFileInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureGetResponseInputTeamsDevicesUniqueClientIDInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureGetResponseInputTeamsDevicesDomainJoinedInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureGetResponseInputTeamsDevicesFirewallInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureGetResponseInputTeamsDevicesCarbonblackInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureGetResponseInputTeamsDevicesDiskEncryptionInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureGetResponseInputTeamsDevicesApplicationInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureGetResponseInputTeamsDevicesClientCertificateInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureGetResponseInputTeamsDevicesWorkspaceOneInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequest{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequest{}), - }, - ) -} - -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesFileInputRequest struct { - // Operating system - OperatingSystem ZeroTrustDevicePostureGetResponseInputTeamsDevicesFileInputRequestOperatingSystem `json:"operating_system,required"` - // File path. - Path string `json:"path,required"` - // Whether or not file exists - Exists bool `json:"exists"` - // SHA-256. - Sha256 string `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON zeroTrustDevicePostureGetResponseInputTeamsDevicesFileInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseInputTeamsDevicesFileInputRequestJSON contains -// the JSON metadata for the struct -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesFileInputRequest] -type zeroTrustDevicePostureGetResponseInputTeamsDevicesFileInputRequestJSON struct { - OperatingSystem apijson.Field - Path apijson.Field - Exists apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseInputTeamsDevicesFileInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseInputTeamsDevicesFileInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureGetResponseInputTeamsDevicesFileInputRequest) implementsZeroTrustDevicePostureGetResponseInput() { -} - -// Operating system -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesFileInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesFileInputRequestOperatingSystemWindows ZeroTrustDevicePostureGetResponseInputTeamsDevicesFileInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesFileInputRequestOperatingSystemLinux ZeroTrustDevicePostureGetResponseInputTeamsDevicesFileInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesFileInputRequestOperatingSystemMac ZeroTrustDevicePostureGetResponseInputTeamsDevicesFileInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesUniqueClientIDInputRequest struct { - // List ID. - ID string `json:"id,required"` - // Operating System - OperatingSystem ZeroTrustDevicePostureGetResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem `json:"operating_system,required"` - JSON zeroTrustDevicePostureGetResponseInputTeamsDevicesUniqueClientIDInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseInputTeamsDevicesUniqueClientIDInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesUniqueClientIDInputRequest] -type zeroTrustDevicePostureGetResponseInputTeamsDevicesUniqueClientIDInputRequestJSON struct { - ID apijson.Field - OperatingSystem apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseInputTeamsDevicesUniqueClientIDInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseInputTeamsDevicesUniqueClientIDInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureGetResponseInputTeamsDevicesUniqueClientIDInputRequest) implementsZeroTrustDevicePostureGetResponseInput() { -} - -// Operating System -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemAndroid ZeroTrustDevicePostureGetResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "android" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemIos ZeroTrustDevicePostureGetResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "ios" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemChromeos ZeroTrustDevicePostureGetResponseInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "chromeos" -) - -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesDomainJoinedInputRequest struct { - // Operating System - OperatingSystem ZeroTrustDevicePostureGetResponseInputTeamsDevicesDomainJoinedInputRequestOperatingSystem `json:"operating_system,required"` - // Domain - Domain string `json:"domain"` - JSON zeroTrustDevicePostureGetResponseInputTeamsDevicesDomainJoinedInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseInputTeamsDevicesDomainJoinedInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesDomainJoinedInputRequest] -type zeroTrustDevicePostureGetResponseInputTeamsDevicesDomainJoinedInputRequestJSON struct { - OperatingSystem apijson.Field - Domain apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseInputTeamsDevicesDomainJoinedInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseInputTeamsDevicesDomainJoinedInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureGetResponseInputTeamsDevicesDomainJoinedInputRequest) implementsZeroTrustDevicePostureGetResponseInput() { -} - -// Operating System -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesDomainJoinedInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesDomainJoinedInputRequestOperatingSystemWindows ZeroTrustDevicePostureGetResponseInputTeamsDevicesDomainJoinedInputRequestOperatingSystem = "windows" -) - -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequest struct { - // Operating System - OperatingSystem ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestOperatingSystem `json:"operating_system,required"` - // Operator - Operator ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestOperator `json:"operator,required"` - // Version of OS - Version string `json:"version,required"` - // Operating System Distribution Name (linux only) - OSDistroName string `json:"os_distro_name"` - // Version of OS Distribution (linux only) - OSDistroRevision string `json:"os_distro_revision"` - // Additional version data. For Mac or iOS, the Product Verison Extra. For Linux, - // the kernel release version. (Mac, iOS, and Linux only) - OSVersionExtra string `json:"os_version_extra"` - JSON zeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequest] -type zeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestJSON struct { - OperatingSystem apijson.Field - Operator apijson.Field - Version apijson.Field - OSDistroName apijson.Field - OSDistroRevision apijson.Field - OSVersionExtra apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequest) implementsZeroTrustDevicePostureGetResponseInput() { -} - -// Operating System -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestOperatingSystemWindows ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestOperatingSystem = "windows" -) - -// Operator -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestOperator string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown215 ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestOperator = "<" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown216 ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestOperator = "<=" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown217 ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestOperator = ">" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown218 ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestOperator = ">=" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestOperatorUnknown219 ZeroTrustDevicePostureGetResponseInputTeamsDevicesOSVersionInputRequestOperator = "==" -) - -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesFirewallInputRequest struct { - // Enabled - Enabled bool `json:"enabled,required"` - // Operating System - OperatingSystem ZeroTrustDevicePostureGetResponseInputTeamsDevicesFirewallInputRequestOperatingSystem `json:"operating_system,required"` - JSON zeroTrustDevicePostureGetResponseInputTeamsDevicesFirewallInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseInputTeamsDevicesFirewallInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesFirewallInputRequest] -type zeroTrustDevicePostureGetResponseInputTeamsDevicesFirewallInputRequestJSON struct { - Enabled apijson.Field - OperatingSystem apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseInputTeamsDevicesFirewallInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseInputTeamsDevicesFirewallInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureGetResponseInputTeamsDevicesFirewallInputRequest) implementsZeroTrustDevicePostureGetResponseInput() { -} - -// Operating System -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesFirewallInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesFirewallInputRequestOperatingSystemWindows ZeroTrustDevicePostureGetResponseInputTeamsDevicesFirewallInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesFirewallInputRequestOperatingSystemMac ZeroTrustDevicePostureGetResponseInputTeamsDevicesFirewallInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneInputRequest struct { - // Operating system - OperatingSystem ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem `json:"operating_system,required"` - // File path. - Path string `json:"path,required"` - // SHA-256. - Sha256 string `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON zeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneInputRequest] -type zeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneInputRequestJSON struct { - OperatingSystem apijson.Field - Path apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneInputRequest) implementsZeroTrustDevicePostureGetResponseInput() { -} - -// Operating system -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneInputRequestOperatingSystemWindows ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneInputRequestOperatingSystemLinux ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneInputRequestOperatingSystemMac ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesCarbonblackInputRequest struct { - // Operating system - OperatingSystem ZeroTrustDevicePostureGetResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem `json:"operating_system,required"` - // File path. - Path string `json:"path,required"` - // SHA-256. - Sha256 string `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON zeroTrustDevicePostureGetResponseInputTeamsDevicesCarbonblackInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseInputTeamsDevicesCarbonblackInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesCarbonblackInputRequest] -type zeroTrustDevicePostureGetResponseInputTeamsDevicesCarbonblackInputRequestJSON struct { - OperatingSystem apijson.Field - Path apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseInputTeamsDevicesCarbonblackInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseInputTeamsDevicesCarbonblackInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureGetResponseInputTeamsDevicesCarbonblackInputRequest) implementsZeroTrustDevicePostureGetResponseInput() { -} - -// Operating system -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystemWindows ZeroTrustDevicePostureGetResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystemLinux ZeroTrustDevicePostureGetResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystemMac ZeroTrustDevicePostureGetResponseInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesDiskEncryptionInputRequest struct { - // List of volume names to be checked for encryption. - CheckDisks []string `json:"checkDisks"` - // Whether to check all disks for encryption. - RequireAll bool `json:"requireAll"` - JSON zeroTrustDevicePostureGetResponseInputTeamsDevicesDiskEncryptionInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseInputTeamsDevicesDiskEncryptionInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesDiskEncryptionInputRequest] -type zeroTrustDevicePostureGetResponseInputTeamsDevicesDiskEncryptionInputRequestJSON struct { - CheckDisks apijson.Field - RequireAll apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseInputTeamsDevicesDiskEncryptionInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseInputTeamsDevicesDiskEncryptionInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureGetResponseInputTeamsDevicesDiskEncryptionInputRequest) implementsZeroTrustDevicePostureGetResponseInput() { -} - -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesApplicationInputRequest struct { - // Operating system - OperatingSystem ZeroTrustDevicePostureGetResponseInputTeamsDevicesApplicationInputRequestOperatingSystem `json:"operating_system,required"` - // Path for the application. - Path string `json:"path,required"` - // SHA-256. - Sha256 string `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint string `json:"thumbprint"` - JSON zeroTrustDevicePostureGetResponseInputTeamsDevicesApplicationInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseInputTeamsDevicesApplicationInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesApplicationInputRequest] -type zeroTrustDevicePostureGetResponseInputTeamsDevicesApplicationInputRequestJSON struct { - OperatingSystem apijson.Field - Path apijson.Field - Sha256 apijson.Field - Thumbprint apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseInputTeamsDevicesApplicationInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseInputTeamsDevicesApplicationInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureGetResponseInputTeamsDevicesApplicationInputRequest) implementsZeroTrustDevicePostureGetResponseInput() { -} - -// Operating system -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesApplicationInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesApplicationInputRequestOperatingSystemWindows ZeroTrustDevicePostureGetResponseInputTeamsDevicesApplicationInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesApplicationInputRequestOperatingSystemLinux ZeroTrustDevicePostureGetResponseInputTeamsDevicesApplicationInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesApplicationInputRequestOperatingSystemMac ZeroTrustDevicePostureGetResponseInputTeamsDevicesApplicationInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesClientCertificateInputRequest struct { - // UUID of Cloudflare managed certificate. - CertificateID string `json:"certificate_id,required"` - // Common Name that is protected by the certificate - Cn string `json:"cn,required"` - JSON zeroTrustDevicePostureGetResponseInputTeamsDevicesClientCertificateInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseInputTeamsDevicesClientCertificateInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesClientCertificateInputRequest] -type zeroTrustDevicePostureGetResponseInputTeamsDevicesClientCertificateInputRequestJSON struct { - CertificateID apijson.Field - Cn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseInputTeamsDevicesClientCertificateInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseInputTeamsDevicesClientCertificateInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureGetResponseInputTeamsDevicesClientCertificateInputRequest) implementsZeroTrustDevicePostureGetResponseInput() { -} - -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesWorkspaceOneInputRequest struct { - // Compliance Status - ComplianceStatus ZeroTrustDevicePostureGetResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus `json:"compliance_status,required"` - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustDevicePostureGetResponseInputTeamsDevicesWorkspaceOneInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseInputTeamsDevicesWorkspaceOneInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesWorkspaceOneInputRequest] -type zeroTrustDevicePostureGetResponseInputTeamsDevicesWorkspaceOneInputRequestJSON struct { - ComplianceStatus apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseInputTeamsDevicesWorkspaceOneInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseInputTeamsDevicesWorkspaceOneInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureGetResponseInputTeamsDevicesWorkspaceOneInputRequest) implementsZeroTrustDevicePostureGetResponseInput() { -} - -// Compliance Status -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusCompliant ZeroTrustDevicePostureGetResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "compliant" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusNoncompliant ZeroTrustDevicePostureGetResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "noncompliant" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusUnknown ZeroTrustDevicePostureGetResponseInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "unknown" -) - -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequest struct { - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // For more details on last seen, please refer to the Crowdstrike documentation. - LastSeen string `json:"last_seen"` - // Operator - Operator ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestOperator `json:"operator"` - // Os Version - OS string `json:"os"` - // overall - Overall string `json:"overall"` - // SensorConfig - SensorConfig string `json:"sensor_config"` - // For more details on state, please refer to the Crowdstrike documentation. - State ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestState `json:"state"` - // Version - Version string `json:"version"` - // Version Operator - VersionOperator ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator `json:"versionOperator"` - JSON zeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequest] -type zeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestJSON struct { - ConnectionID apijson.Field - LastSeen apijson.Field - Operator apijson.Field - OS apijson.Field - Overall apijson.Field - SensorConfig apijson.Field - State apijson.Field - Version apijson.Field - VersionOperator apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequest) implementsZeroTrustDevicePostureGetResponseInput() { -} - -// Operator -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestOperator string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown225 ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = "<" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown226 ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = "<=" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown227 ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = ">" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown228 ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = ">=" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown229 ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestOperator = "==" -) - -// For more details on state, please refer to the Crowdstrike documentation. -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestState string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestStateOnline ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestState = "online" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestStateOffline ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestState = "offline" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestStateUnknown ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestState = "unknown" -) - -// Version Operator -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown235 ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown236 ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<=" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown237 ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown238 ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">=" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown239 ZeroTrustDevicePostureGetResponseInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "==" -) - -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequest struct { - // Compliance Status - ComplianceStatus ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequestComplianceStatus `json:"compliance_status,required"` - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - JSON zeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequest] -type zeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequestJSON struct { - ComplianceStatus apijson.Field - ConnectionID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequest) implementsZeroTrustDevicePostureGetResponseInput() { -} - -// Compliance Status -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequestComplianceStatus string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequestComplianceStatusCompliant ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "compliant" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequestComplianceStatusNoncompliant ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "noncompliant" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequestComplianceStatusUnknown ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "unknown" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequestComplianceStatusNotapplicable ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "notapplicable" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequestComplianceStatusIngraceperiod ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "ingraceperiod" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequestComplianceStatusError ZeroTrustDevicePostureGetResponseInputTeamsDevicesIntuneInputRequestComplianceStatus = "error" -) - -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequest struct { - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // Count Operator - CountOperator ZeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequestCountOperator `json:"countOperator,required"` - // The Number of Issues. - IssueCount string `json:"issue_count,required"` - JSON zeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequest] -type zeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequestJSON struct { - ConnectionID apijson.Field - CountOperator apijson.Field - IssueCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequest) implementsZeroTrustDevicePostureGetResponseInput() { -} - -// Count Operator -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequestCountOperator string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown245 ZeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequestCountOperator = "<" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown246 ZeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequestCountOperator = "<=" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown247 ZeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequestCountOperator = ">" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown248 ZeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequestCountOperator = ">=" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequestCountOperatorUnknown249 ZeroTrustDevicePostureGetResponseInputTeamsDevicesKolideInputRequestCountOperator = "==" -) - -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequest struct { - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // For more details on eid last seen, refer to the Tanium documentation. - EidLastSeen string `json:"eid_last_seen"` - // Operator to evaluate risk_level or eid_last_seen. - Operator ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestOperator `json:"operator"` - // For more details on risk level, refer to the Tanium documentation. - RiskLevel ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestRiskLevel `json:"risk_level"` - // Score Operator - ScoreOperator ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestScoreOperator `json:"scoreOperator"` - // For more details on total score, refer to the Tanium documentation. - TotalScore float64 `json:"total_score"` - JSON zeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequest] -type zeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestJSON struct { - ConnectionID apijson.Field - EidLastSeen apijson.Field - Operator apijson.Field - RiskLevel apijson.Field - ScoreOperator apijson.Field - TotalScore apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequest) implementsZeroTrustDevicePostureGetResponseInput() { -} - -// Operator to evaluate risk_level or eid_last_seen. -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestOperator string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown255 ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestOperator = "<" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown256 ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestOperator = "<=" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown257 ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestOperator = ">" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown258 ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestOperator = ">=" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestOperatorUnknown259 ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestOperator = "==" -) - -// For more details on risk level, refer to the Tanium documentation. -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestRiskLevel string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestRiskLevelLow ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestRiskLevel = "low" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestRiskLevelMedium ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestRiskLevel = "medium" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestRiskLevelHigh ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestRiskLevel = "high" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestRiskLevelCritical ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestRiskLevel = "critical" -) - -// Score Operator -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestScoreOperator string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown265 ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestScoreOperator = "<" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown266 ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestScoreOperator = "<=" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown267 ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestScoreOperator = ">" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown268 ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestScoreOperator = ">=" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown269 ZeroTrustDevicePostureGetResponseInputTeamsDevicesTaniumInputRequestScoreOperator = "==" -) - -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequest struct { - // Posture Integration ID. - ConnectionID string `json:"connection_id,required"` - // The Number of active threats. - ActiveThreats float64 `json:"active_threats"` - // Whether device is infected. - Infected bool `json:"infected"` - // Whether device is active. - IsActive bool `json:"is_active"` - // Network status of device. - NetworkStatus ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus `json:"network_status"` - // operator - Operator ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestOperator `json:"operator"` - JSON zeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestJSON -// contains the JSON metadata for the struct -// [ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequest] -type zeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestJSON struct { - ConnectionID apijson.Field - ActiveThreats apijson.Field - Infected apijson.Field - IsActive apijson.Field - NetworkStatus apijson.Field - Operator apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequest) implementsZeroTrustDevicePostureGetResponseInput() { -} - -// Network status of device. -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnected ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connected" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnected ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnected" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnecting ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnecting" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnecting ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connecting" -) - -// operator -type ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestOperator string - -const ( - ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown275 ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = "<" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown276 ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = "<=" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown277 ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = ">" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown278 ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = ">=" - ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown279 ZeroTrustDevicePostureGetResponseInputTeamsDevicesSentineloneS2sInputRequestOperator = "==" -) - -type ZeroTrustDevicePostureGetResponseMatch struct { - Platform ZeroTrustDevicePostureGetResponseMatchPlatform `json:"platform"` - JSON zeroTrustDevicePostureGetResponseMatchJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseMatchJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePostureGetResponseMatch] -type zeroTrustDevicePostureGetResponseMatchJSON struct { - Platform apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseMatch) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseMatchJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureGetResponseMatchPlatform string - -const ( - ZeroTrustDevicePostureGetResponseMatchPlatformWindows ZeroTrustDevicePostureGetResponseMatchPlatform = "windows" - ZeroTrustDevicePostureGetResponseMatchPlatformMac ZeroTrustDevicePostureGetResponseMatchPlatform = "mac" - ZeroTrustDevicePostureGetResponseMatchPlatformLinux ZeroTrustDevicePostureGetResponseMatchPlatform = "linux" - ZeroTrustDevicePostureGetResponseMatchPlatformAndroid ZeroTrustDevicePostureGetResponseMatchPlatform = "android" - ZeroTrustDevicePostureGetResponseMatchPlatformIos ZeroTrustDevicePostureGetResponseMatchPlatform = "ios" -) - -// The type of device posture rule. -type ZeroTrustDevicePostureGetResponseType string - -const ( - ZeroTrustDevicePostureGetResponseTypeFile ZeroTrustDevicePostureGetResponseType = "file" - ZeroTrustDevicePostureGetResponseTypeApplication ZeroTrustDevicePostureGetResponseType = "application" - ZeroTrustDevicePostureGetResponseTypeTanium ZeroTrustDevicePostureGetResponseType = "tanium" - ZeroTrustDevicePostureGetResponseTypeGateway ZeroTrustDevicePostureGetResponseType = "gateway" - ZeroTrustDevicePostureGetResponseTypeWARP ZeroTrustDevicePostureGetResponseType = "warp" - ZeroTrustDevicePostureGetResponseTypeDiskEncryption ZeroTrustDevicePostureGetResponseType = "disk_encryption" - ZeroTrustDevicePostureGetResponseTypeSentinelone ZeroTrustDevicePostureGetResponseType = "sentinelone" - ZeroTrustDevicePostureGetResponseTypeCarbonblack ZeroTrustDevicePostureGetResponseType = "carbonblack" - ZeroTrustDevicePostureGetResponseTypeFirewall ZeroTrustDevicePostureGetResponseType = "firewall" - ZeroTrustDevicePostureGetResponseTypeOSVersion ZeroTrustDevicePostureGetResponseType = "os_version" - ZeroTrustDevicePostureGetResponseTypeDomainJoined ZeroTrustDevicePostureGetResponseType = "domain_joined" - ZeroTrustDevicePostureGetResponseTypeClientCertificate ZeroTrustDevicePostureGetResponseType = "client_certificate" - ZeroTrustDevicePostureGetResponseTypeUniqueClientID ZeroTrustDevicePostureGetResponseType = "unique_client_id" - ZeroTrustDevicePostureGetResponseTypeKolide ZeroTrustDevicePostureGetResponseType = "kolide" - ZeroTrustDevicePostureGetResponseTypeTaniumS2s ZeroTrustDevicePostureGetResponseType = "tanium_s2s" - ZeroTrustDevicePostureGetResponseTypeCrowdstrikeS2s ZeroTrustDevicePostureGetResponseType = "crowdstrike_s2s" - ZeroTrustDevicePostureGetResponseTypeIntune ZeroTrustDevicePostureGetResponseType = "intune" - ZeroTrustDevicePostureGetResponseTypeWorkspaceOne ZeroTrustDevicePostureGetResponseType = "workspace_one" - ZeroTrustDevicePostureGetResponseTypeSentineloneS2s ZeroTrustDevicePostureGetResponseType = "sentinelone_s2s" -) - -type ZeroTrustDevicePostureNewParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // The name of the device posture rule. - Name param.Field[string] `json:"name,required"` - // The type of device posture rule. - Type param.Field[ZeroTrustDevicePostureNewParamsType] `json:"type,required"` - // The description of the device posture rule. - Description param.Field[string] `json:"description"` - // Sets the expiration time for a posture check result. If empty, the result - // remains valid until it is overwritten by new data from the WARP client. - Expiration param.Field[string] `json:"expiration"` - // The value to be checked against. - Input param.Field[ZeroTrustDevicePostureNewParamsInput] `json:"input"` - // The conditions that the client must match to run the rule. - Match param.Field[[]ZeroTrustDevicePostureNewParamsMatch] `json:"match"` - // Polling frequency for the WARP client posture check. Default: `5m` (poll every - // five minutes). Minimum: `1m`. - Schedule param.Field[string] `json:"schedule"` -} - -func (r ZeroTrustDevicePostureNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of device posture rule. -type ZeroTrustDevicePostureNewParamsType string - -const ( - ZeroTrustDevicePostureNewParamsTypeFile ZeroTrustDevicePostureNewParamsType = "file" - ZeroTrustDevicePostureNewParamsTypeApplication ZeroTrustDevicePostureNewParamsType = "application" - ZeroTrustDevicePostureNewParamsTypeTanium ZeroTrustDevicePostureNewParamsType = "tanium" - ZeroTrustDevicePostureNewParamsTypeGateway ZeroTrustDevicePostureNewParamsType = "gateway" - ZeroTrustDevicePostureNewParamsTypeWARP ZeroTrustDevicePostureNewParamsType = "warp" - ZeroTrustDevicePostureNewParamsTypeDiskEncryption ZeroTrustDevicePostureNewParamsType = "disk_encryption" - ZeroTrustDevicePostureNewParamsTypeSentinelone ZeroTrustDevicePostureNewParamsType = "sentinelone" - ZeroTrustDevicePostureNewParamsTypeCarbonblack ZeroTrustDevicePostureNewParamsType = "carbonblack" - ZeroTrustDevicePostureNewParamsTypeFirewall ZeroTrustDevicePostureNewParamsType = "firewall" - ZeroTrustDevicePostureNewParamsTypeOSVersion ZeroTrustDevicePostureNewParamsType = "os_version" - ZeroTrustDevicePostureNewParamsTypeDomainJoined ZeroTrustDevicePostureNewParamsType = "domain_joined" - ZeroTrustDevicePostureNewParamsTypeClientCertificate ZeroTrustDevicePostureNewParamsType = "client_certificate" - ZeroTrustDevicePostureNewParamsTypeUniqueClientID ZeroTrustDevicePostureNewParamsType = "unique_client_id" - ZeroTrustDevicePostureNewParamsTypeKolide ZeroTrustDevicePostureNewParamsType = "kolide" - ZeroTrustDevicePostureNewParamsTypeTaniumS2s ZeroTrustDevicePostureNewParamsType = "tanium_s2s" - ZeroTrustDevicePostureNewParamsTypeCrowdstrikeS2s ZeroTrustDevicePostureNewParamsType = "crowdstrike_s2s" - ZeroTrustDevicePostureNewParamsTypeIntune ZeroTrustDevicePostureNewParamsType = "intune" - ZeroTrustDevicePostureNewParamsTypeWorkspaceOne ZeroTrustDevicePostureNewParamsType = "workspace_one" - ZeroTrustDevicePostureNewParamsTypeSentineloneS2s ZeroTrustDevicePostureNewParamsType = "sentinelone_s2s" -) - -// The value to be checked against. -// -// Satisfied by [ZeroTrustDevicePostureNewParamsInputTeamsDevicesFileInputRequest], -// [ZeroTrustDevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequest], -// [ZeroTrustDevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequest], -// [ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequest], -// [ZeroTrustDevicePostureNewParamsInputTeamsDevicesFirewallInputRequest], -// [ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneInputRequest], -// [ZeroTrustDevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequest], -// [ZeroTrustDevicePostureNewParamsInputTeamsDevicesDiskEncryptionInputRequest], -// [ZeroTrustDevicePostureNewParamsInputTeamsDevicesApplicationInputRequest], -// [ZeroTrustDevicePostureNewParamsInputTeamsDevicesClientCertificateInputRequest], -// [ZeroTrustDevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequest], -// [ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequest], -// [ZeroTrustDevicePostureNewParamsInputTeamsDevicesIntuneInputRequest], -// [ZeroTrustDevicePostureNewParamsInputTeamsDevicesKolideInputRequest], -// [ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequest], -// [ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequest]. -type ZeroTrustDevicePostureNewParamsInput interface { - implementsZeroTrustDevicePostureNewParamsInput() -} - -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesFileInputRequest struct { - // Operating system - OperatingSystem param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystem] `json:"operating_system,required"` - // File path. - Path param.Field[string] `json:"path,required"` - // Whether or not file exists - Exists param.Field[bool] `json:"exists"` - // SHA-256. - Sha256 param.Field[string] `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint param.Field[string] `json:"thumbprint"` -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesFileInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesFileInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operating system -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystemWindows ZeroTrustDevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystemLinux ZeroTrustDevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystemMac ZeroTrustDevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequest struct { - // List ID. - ID param.Field[string] `json:"id,required"` - // Operating System - OperatingSystem param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem] `json:"operating_system,required"` -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operating System -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemAndroid ZeroTrustDevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "android" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemIos ZeroTrustDevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "ios" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemChromeos ZeroTrustDevicePostureNewParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "chromeos" -) - -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequest struct { - // Operating System - OperatingSystem param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem] `json:"operating_system,required"` - // Domain - Domain param.Field[string] `json:"domain"` -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operating System -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystemWindows ZeroTrustDevicePostureNewParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem = "windows" -) - -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequest struct { - // Operating System - OperatingSystem param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem] `json:"operating_system,required"` - // Operator - Operator param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator] `json:"operator,required"` - // Version of OS - Version param.Field[string] `json:"version,required"` - // Operating System Distribution Name (linux only) - OSDistroName param.Field[string] `json:"os_distro_name"` - // Version of OS Distribution (linux only) - OSDistroRevision param.Field[string] `json:"os_distro_revision"` - // Additional version data. For Mac or iOS, the Product Verison Extra. For Linux, - // the kernel release version. (Mac, iOS, and Linux only) - OSVersionExtra param.Field[string] `json:"os_version_extra"` -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operating System -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatingSystemWindows ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem = "windows" -) - -// Operator -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown285 ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator = "<" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown286 ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator = "<=" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown287 ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator = ">" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown288 ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator = ">=" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown289 ZeroTrustDevicePostureNewParamsInputTeamsDevicesOSVersionInputRequestOperator = "==" -) - -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesFirewallInputRequest struct { - // Enabled - Enabled param.Field[bool] `json:"enabled,required"` - // Operating System - OperatingSystem param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystem] `json:"operating_system,required"` -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesFirewallInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesFirewallInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operating System -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystemWindows ZeroTrustDevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystemMac ZeroTrustDevicePostureNewParamsInputTeamsDevicesFirewallInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneInputRequest struct { - // Operating system - OperatingSystem param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem] `json:"operating_system,required"` - // File path. - Path param.Field[string] `json:"path,required"` - // SHA-256. - Sha256 param.Field[string] `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint param.Field[string] `json:"thumbprint"` -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operating system -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemWindows ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemLinux ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemMac ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequest struct { - // Operating system - OperatingSystem param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem] `json:"operating_system,required"` - // File path. - Path param.Field[string] `json:"path,required"` - // SHA-256. - Sha256 param.Field[string] `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint param.Field[string] `json:"thumbprint"` -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operating system -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemWindows ZeroTrustDevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemLinux ZeroTrustDevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemMac ZeroTrustDevicePostureNewParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesDiskEncryptionInputRequest struct { - // List of volume names to be checked for encryption. - CheckDisks param.Field[[]string] `json:"checkDisks"` - // Whether to check all disks for encryption. - RequireAll param.Field[bool] `json:"requireAll"` -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesDiskEncryptionInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesDiskEncryptionInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesApplicationInputRequest struct { - // Operating system - OperatingSystem param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystem] `json:"operating_system,required"` - // Path for the application. - Path param.Field[string] `json:"path,required"` - // SHA-256. - Sha256 param.Field[string] `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint param.Field[string] `json:"thumbprint"` -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesApplicationInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesApplicationInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operating system -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystemWindows ZeroTrustDevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystemLinux ZeroTrustDevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystemMac ZeroTrustDevicePostureNewParamsInputTeamsDevicesApplicationInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesClientCertificateInputRequest struct { - // UUID of Cloudflare managed certificate. - CertificateID param.Field[string] `json:"certificate_id,required"` - // Common Name that is protected by the certificate - Cn param.Field[string] `json:"cn,required"` -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesClientCertificateInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesClientCertificateInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequest struct { - // Compliance Status - ComplianceStatus param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus] `json:"compliance_status,required"` - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Compliance Status -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusCompliant ZeroTrustDevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "compliant" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusNoncompliant ZeroTrustDevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "noncompliant" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusUnknown ZeroTrustDevicePostureNewParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "unknown" -) - -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequest struct { - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` - // For more details on last seen, please refer to the Crowdstrike documentation. - LastSeen param.Field[string] `json:"last_seen"` - // Operator - Operator param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator] `json:"operator"` - // Os Version - OS param.Field[string] `json:"os"` - // overall - Overall param.Field[string] `json:"overall"` - // SensorConfig - SensorConfig param.Field[string] `json:"sensor_config"` - // For more details on state, please refer to the Crowdstrike documentation. - State param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestState] `json:"state"` - // Version - Version param.Field[string] `json:"version"` - // Version Operator - VersionOperator param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator] `json:"versionOperator"` -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operator -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown295 ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = "<" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown296 ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = "<=" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown297 ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = ">" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown298 ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = ">=" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown299 ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = "==" -) - -// For more details on state, please refer to the Crowdstrike documentation. -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestState string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestStateOnline ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestState = "online" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestStateOffline ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestState = "offline" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestStateUnknown ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestState = "unknown" -) - -// Version Operator -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown305 ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown306 ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<=" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown307 ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown308 ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">=" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown309 ZeroTrustDevicePostureNewParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "==" -) - -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesIntuneInputRequest struct { - // Compliance Status - ComplianceStatus param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus] `json:"compliance_status,required"` - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesIntuneInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesIntuneInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Compliance Status -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusCompliant ZeroTrustDevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "compliant" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusNoncompliant ZeroTrustDevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "noncompliant" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusUnknown ZeroTrustDevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "unknown" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusNotapplicable ZeroTrustDevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "notapplicable" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusIngraceperiod ZeroTrustDevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "ingraceperiod" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatusError ZeroTrustDevicePostureNewParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "error" -) - -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesKolideInputRequest struct { - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` - // Count Operator - CountOperator param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator] `json:"countOperator,required"` - // The Number of Issues. - IssueCount param.Field[string] `json:"issue_count,required"` -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesKolideInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesKolideInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Count Operator -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown315 ZeroTrustDevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator = "<" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown316 ZeroTrustDevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator = "<=" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown317 ZeroTrustDevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator = ">" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown318 ZeroTrustDevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator = ">=" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown319 ZeroTrustDevicePostureNewParamsInputTeamsDevicesKolideInputRequestCountOperator = "==" -) - -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequest struct { - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` - // For more details on eid last seen, refer to the Tanium documentation. - EidLastSeen param.Field[string] `json:"eid_last_seen"` - // Operator to evaluate risk_level or eid_last_seen. - Operator param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator] `json:"operator"` - // For more details on risk level, refer to the Tanium documentation. - RiskLevel param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel] `json:"risk_level"` - // Score Operator - ScoreOperator param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator] `json:"scoreOperator"` - // For more details on total score, refer to the Tanium documentation. - TotalScore param.Field[float64] `json:"total_score"` -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Operator to evaluate risk_level or eid_last_seen. -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown325 ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator = "<" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown326 ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator = "<=" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown327 ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator = ">" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown328 ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator = ">=" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown329 ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestOperator = "==" -) - -// For more details on risk level, refer to the Tanium documentation. -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevelLow ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "low" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevelMedium ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "medium" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevelHigh ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "high" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevelCritical ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "critical" -) - -// Score Operator -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown335 ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator = "<" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown336 ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator = "<=" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown337 ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator = ">" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown338 ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator = ">=" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown339 ZeroTrustDevicePostureNewParamsInputTeamsDevicesTaniumInputRequestScoreOperator = "==" -) - -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequest struct { - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The Number of active threats. - ActiveThreats param.Field[float64] `json:"active_threats"` - // Whether device is infected. - Infected param.Field[bool] `json:"infected"` - // Whether device is active. - IsActive param.Field[bool] `json:"is_active"` - // Network status of device. - NetworkStatus param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus] `json:"network_status"` - // operator - Operator param.Field[ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator] `json:"operator"` -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequest) implementsZeroTrustDevicePostureNewParamsInput() { -} - -// Network status of device. -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnected ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connected" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnected ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnected" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnecting ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnecting" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnecting ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connecting" -) - -// operator -type ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator string - -const ( - ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown345 ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = "<" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown346 ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = "<=" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown347 ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = ">" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown348 ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = ">=" - ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown349 ZeroTrustDevicePostureNewParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = "==" -) - -type ZeroTrustDevicePostureNewParamsMatch struct { - Platform param.Field[ZeroTrustDevicePostureNewParamsMatchPlatform] `json:"platform"` -} - -func (r ZeroTrustDevicePostureNewParamsMatch) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDevicePostureNewParamsMatchPlatform string - -const ( - ZeroTrustDevicePostureNewParamsMatchPlatformWindows ZeroTrustDevicePostureNewParamsMatchPlatform = "windows" - ZeroTrustDevicePostureNewParamsMatchPlatformMac ZeroTrustDevicePostureNewParamsMatchPlatform = "mac" - ZeroTrustDevicePostureNewParamsMatchPlatformLinux ZeroTrustDevicePostureNewParamsMatchPlatform = "linux" - ZeroTrustDevicePostureNewParamsMatchPlatformAndroid ZeroTrustDevicePostureNewParamsMatchPlatform = "android" - ZeroTrustDevicePostureNewParamsMatchPlatformIos ZeroTrustDevicePostureNewParamsMatchPlatform = "ios" -) - -type ZeroTrustDevicePostureNewResponseEnvelope struct { - Errors []ZeroTrustDevicePostureNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePostureNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDevicePostureNewResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePostureNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDevicePostureNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePostureNewResponseEnvelope] -type zeroTrustDevicePostureNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePostureNewResponseEnvelopeErrors] -type zeroTrustDevicePostureNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePostureNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePostureNewResponseEnvelopeMessages] -type zeroTrustDevicePostureNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePostureNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePostureNewResponseEnvelopeSuccessTrue ZeroTrustDevicePostureNewResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePostureUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // The name of the device posture rule. - Name param.Field[string] `json:"name,required"` - // The type of device posture rule. - Type param.Field[ZeroTrustDevicePostureUpdateParamsType] `json:"type,required"` - // The description of the device posture rule. - Description param.Field[string] `json:"description"` - // Sets the expiration time for a posture check result. If empty, the result - // remains valid until it is overwritten by new data from the WARP client. - Expiration param.Field[string] `json:"expiration"` - // The value to be checked against. - Input param.Field[ZeroTrustDevicePostureUpdateParamsInput] `json:"input"` - // The conditions that the client must match to run the rule. - Match param.Field[[]ZeroTrustDevicePostureUpdateParamsMatch] `json:"match"` - // Polling frequency for the WARP client posture check. Default: `5m` (poll every - // five minutes). Minimum: `1m`. - Schedule param.Field[string] `json:"schedule"` -} - -func (r ZeroTrustDevicePostureUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of device posture rule. -type ZeroTrustDevicePostureUpdateParamsType string - -const ( - ZeroTrustDevicePostureUpdateParamsTypeFile ZeroTrustDevicePostureUpdateParamsType = "file" - ZeroTrustDevicePostureUpdateParamsTypeApplication ZeroTrustDevicePostureUpdateParamsType = "application" - ZeroTrustDevicePostureUpdateParamsTypeTanium ZeroTrustDevicePostureUpdateParamsType = "tanium" - ZeroTrustDevicePostureUpdateParamsTypeGateway ZeroTrustDevicePostureUpdateParamsType = "gateway" - ZeroTrustDevicePostureUpdateParamsTypeWARP ZeroTrustDevicePostureUpdateParamsType = "warp" - ZeroTrustDevicePostureUpdateParamsTypeDiskEncryption ZeroTrustDevicePostureUpdateParamsType = "disk_encryption" - ZeroTrustDevicePostureUpdateParamsTypeSentinelone ZeroTrustDevicePostureUpdateParamsType = "sentinelone" - ZeroTrustDevicePostureUpdateParamsTypeCarbonblack ZeroTrustDevicePostureUpdateParamsType = "carbonblack" - ZeroTrustDevicePostureUpdateParamsTypeFirewall ZeroTrustDevicePostureUpdateParamsType = "firewall" - ZeroTrustDevicePostureUpdateParamsTypeOSVersion ZeroTrustDevicePostureUpdateParamsType = "os_version" - ZeroTrustDevicePostureUpdateParamsTypeDomainJoined ZeroTrustDevicePostureUpdateParamsType = "domain_joined" - ZeroTrustDevicePostureUpdateParamsTypeClientCertificate ZeroTrustDevicePostureUpdateParamsType = "client_certificate" - ZeroTrustDevicePostureUpdateParamsTypeUniqueClientID ZeroTrustDevicePostureUpdateParamsType = "unique_client_id" - ZeroTrustDevicePostureUpdateParamsTypeKolide ZeroTrustDevicePostureUpdateParamsType = "kolide" - ZeroTrustDevicePostureUpdateParamsTypeTaniumS2s ZeroTrustDevicePostureUpdateParamsType = "tanium_s2s" - ZeroTrustDevicePostureUpdateParamsTypeCrowdstrikeS2s ZeroTrustDevicePostureUpdateParamsType = "crowdstrike_s2s" - ZeroTrustDevicePostureUpdateParamsTypeIntune ZeroTrustDevicePostureUpdateParamsType = "intune" - ZeroTrustDevicePostureUpdateParamsTypeWorkspaceOne ZeroTrustDevicePostureUpdateParamsType = "workspace_one" - ZeroTrustDevicePostureUpdateParamsTypeSentineloneS2s ZeroTrustDevicePostureUpdateParamsType = "sentinelone_s2s" -) - -// The value to be checked against. -// -// Satisfied by -// [ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFileInputRequest], -// [ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequest], -// [ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequest], -// [ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequest], -// [ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequest], -// [ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequest], -// [ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequest], -// [ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesDiskEncryptionInputRequest], -// [ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequest], -// [ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesClientCertificateInputRequest], -// [ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequest], -// [ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequest], -// [ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequest], -// [ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesKolideInputRequest], -// [ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequest], -// [ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequest]. -type ZeroTrustDevicePostureUpdateParamsInput interface { - implementsZeroTrustDevicePostureUpdateParamsInput() -} - -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFileInputRequest struct { - // Operating system - OperatingSystem param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystem] `json:"operating_system,required"` - // File path. - Path param.Field[string] `json:"path,required"` - // Whether or not file exists - Exists param.Field[bool] `json:"exists"` - // SHA-256. - Sha256 param.Field[string] `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint param.Field[string] `json:"thumbprint"` -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFileInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFileInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Operating system -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystemWindows ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystemLinux ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystemMac ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequest struct { - // List ID. - ID param.Field[string] `json:"id,required"` - // Operating System - OperatingSystem param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem] `json:"operating_system,required"` -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Operating System -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemAndroid ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "android" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemIos ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "ios" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystemChromeos ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesUniqueClientIDInputRequestOperatingSystem = "chromeos" -) - -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequest struct { - // Operating System - OperatingSystem param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem] `json:"operating_system,required"` - // Domain - Domain param.Field[string] `json:"domain"` -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Operating System -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystemWindows ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesDomainJoinedInputRequestOperatingSystem = "windows" -) - -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequest struct { - // Operating System - OperatingSystem param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem] `json:"operating_system,required"` - // Operator - Operator param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator] `json:"operator,required"` - // Version of OS - Version param.Field[string] `json:"version,required"` - // Operating System Distribution Name (linux only) - OSDistroName param.Field[string] `json:"os_distro_name"` - // Version of OS Distribution (linux only) - OSDistroRevision param.Field[string] `json:"os_distro_revision"` - // Additional version data. For Mac or iOS, the Product Verison Extra. For Linux, - // the kernel release version. (Mac, iOS, and Linux only) - OSVersionExtra param.Field[string] `json:"os_version_extra"` -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Operating System -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatingSystemWindows ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatingSystem = "windows" -) - -// Operator -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown355 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator = "<" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown356 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator = "<=" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown357 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator = ">" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown358 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator = ">=" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperatorUnknown359 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesOSVersionInputRequestOperator = "==" -) - -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequest struct { - // Enabled - Enabled param.Field[bool] `json:"enabled,required"` - // Operating System - OperatingSystem param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystem] `json:"operating_system,required"` -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Operating System -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystemWindows ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystemMac ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFirewallInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequest struct { - // Operating system - OperatingSystem param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem] `json:"operating_system,required"` - // File path. - Path param.Field[string] `json:"path,required"` - // SHA-256. - Sha256 param.Field[string] `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint param.Field[string] `json:"thumbprint"` -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Operating system -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemWindows ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemLinux ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystemMac ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequest struct { - // Operating system - OperatingSystem param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem] `json:"operating_system,required"` - // File path. - Path param.Field[string] `json:"path,required"` - // SHA-256. - Sha256 param.Field[string] `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint param.Field[string] `json:"thumbprint"` -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Operating system -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemWindows ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemLinux ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystemMac ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCarbonblackInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesDiskEncryptionInputRequest struct { - // List of volume names to be checked for encryption. - CheckDisks param.Field[[]string] `json:"checkDisks"` - // Whether to check all disks for encryption. - RequireAll param.Field[bool] `json:"requireAll"` -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesDiskEncryptionInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesDiskEncryptionInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequest struct { - // Operating system - OperatingSystem param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystem] `json:"operating_system,required"` - // Path for the application. - Path param.Field[string] `json:"path,required"` - // SHA-256. - Sha256 param.Field[string] `json:"sha256"` - // Signing certificate thumbprint. - Thumbprint param.Field[string] `json:"thumbprint"` -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Operating system -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystem string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystemWindows ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystem = "windows" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystemLinux ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystem = "linux" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystemMac ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesApplicationInputRequestOperatingSystem = "mac" -) - -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesClientCertificateInputRequest struct { - // UUID of Cloudflare managed certificate. - CertificateID param.Field[string] `json:"certificate_id,required"` - // Common Name that is protected by the certificate - Cn param.Field[string] `json:"cn,required"` -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesClientCertificateInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesClientCertificateInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequest struct { - // Compliance Status - ComplianceStatus param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus] `json:"compliance_status,required"` - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Compliance Status -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusCompliant ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "compliant" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusNoncompliant ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "noncompliant" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatusUnknown ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesWorkspaceOneInputRequestComplianceStatus = "unknown" -) - -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequest struct { - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` - // For more details on last seen, please refer to the Crowdstrike documentation. - LastSeen param.Field[string] `json:"last_seen"` - // Operator - Operator param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator] `json:"operator"` - // Os Version - OS param.Field[string] `json:"os"` - // overall - Overall param.Field[string] `json:"overall"` - // SensorConfig - SensorConfig param.Field[string] `json:"sensor_config"` - // For more details on state, please refer to the Crowdstrike documentation. - State param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestState] `json:"state"` - // Version - Version param.Field[string] `json:"version"` - // Version Operator - VersionOperator param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator] `json:"versionOperator"` -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Operator -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown365 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = "<" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown366 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = "<=" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown367 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = ">" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown368 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = ">=" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperatorUnknown369 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestOperator = "==" -) - -// For more details on state, please refer to the Crowdstrike documentation. -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestState string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestStateOnline ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestState = "online" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestStateOffline ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestState = "offline" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestStateUnknown ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestState = "unknown" -) - -// Version Operator -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown375 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown376 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "<=" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown377 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown378 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = ">=" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperatorUnknown379 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesCrowdstrikeInputRequestVersionOperator = "==" -) - -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequest struct { - // Compliance Status - ComplianceStatus param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus] `json:"compliance_status,required"` - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Compliance Status -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusCompliant ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "compliant" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusNoncompliant ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "noncompliant" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusUnknown ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "unknown" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusNotapplicable ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "notapplicable" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusIngraceperiod ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "ingraceperiod" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatusError ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesIntuneInputRequestComplianceStatus = "error" -) - -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesKolideInputRequest struct { - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` - // Count Operator - CountOperator param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator] `json:"countOperator,required"` - // The Number of Issues. - IssueCount param.Field[string] `json:"issue_count,required"` -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesKolideInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesKolideInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Count Operator -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown385 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator = "<" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown386 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator = "<=" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown387 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator = ">" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown388 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator = ">=" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperatorUnknown389 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesKolideInputRequestCountOperator = "==" -) - -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequest struct { - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` - // For more details on eid last seen, refer to the Tanium documentation. - EidLastSeen param.Field[string] `json:"eid_last_seen"` - // Operator to evaluate risk_level or eid_last_seen. - Operator param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator] `json:"operator"` - // For more details on risk level, refer to the Tanium documentation. - RiskLevel param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel] `json:"risk_level"` - // Score Operator - ScoreOperator param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator] `json:"scoreOperator"` - // For more details on total score, refer to the Tanium documentation. - TotalScore param.Field[float64] `json:"total_score"` -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Operator to evaluate risk_level or eid_last_seen. -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown395 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator = "<" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown396 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator = "<=" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown397 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator = ">" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown398 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator = ">=" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperatorUnknown399 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestOperator = "==" -) - -// For more details on risk level, refer to the Tanium documentation. -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevelLow ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "low" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevelMedium ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "medium" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevelHigh ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "high" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevelCritical ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestRiskLevel = "critical" -) - -// Score Operator -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown405 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator = "<" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown406 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator = "<=" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown407 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator = ">" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown408 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator = ">=" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperatorUnknown409 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesTaniumInputRequestScoreOperator = "==" -) - -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequest struct { - // Posture Integration ID. - ConnectionID param.Field[string] `json:"connection_id,required"` - // The Number of active threats. - ActiveThreats param.Field[float64] `json:"active_threats"` - // Whether device is infected. - Infected param.Field[bool] `json:"infected"` - // Whether device is active. - IsActive param.Field[bool] `json:"is_active"` - // Network status of device. - NetworkStatus param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus] `json:"network_status"` - // operator - Operator param.Field[ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator] `json:"operator"` -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequest) implementsZeroTrustDevicePostureUpdateParamsInput() { -} - -// Network status of device. -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnected ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connected" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnected ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnected" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusDisconnecting ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "disconnecting" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatusConnecting ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestNetworkStatus = "connecting" -) - -// operator -type ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator string - -const ( - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown415 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = "<" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown416 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = "<=" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown417 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = ">" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown418 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = ">=" - ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperatorUnknown419 ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesSentineloneS2sInputRequestOperator = "==" -) - -type ZeroTrustDevicePostureUpdateParamsMatch struct { - Platform param.Field[ZeroTrustDevicePostureUpdateParamsMatchPlatform] `json:"platform"` -} - -func (r ZeroTrustDevicePostureUpdateParamsMatch) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDevicePostureUpdateParamsMatchPlatform string - -const ( - ZeroTrustDevicePostureUpdateParamsMatchPlatformWindows ZeroTrustDevicePostureUpdateParamsMatchPlatform = "windows" - ZeroTrustDevicePostureUpdateParamsMatchPlatformMac ZeroTrustDevicePostureUpdateParamsMatchPlatform = "mac" - ZeroTrustDevicePostureUpdateParamsMatchPlatformLinux ZeroTrustDevicePostureUpdateParamsMatchPlatform = "linux" - ZeroTrustDevicePostureUpdateParamsMatchPlatformAndroid ZeroTrustDevicePostureUpdateParamsMatchPlatform = "android" - ZeroTrustDevicePostureUpdateParamsMatchPlatformIos ZeroTrustDevicePostureUpdateParamsMatchPlatform = "ios" -) - -type ZeroTrustDevicePostureUpdateResponseEnvelope struct { - Errors []ZeroTrustDevicePostureUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePostureUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDevicePostureUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePostureUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDevicePostureUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDevicePostureUpdateResponseEnvelope] -type zeroTrustDevicePostureUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePostureUpdateResponseEnvelopeErrors] -type zeroTrustDevicePostureUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePostureUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePostureUpdateResponseEnvelopeMessages] -type zeroTrustDevicePostureUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePostureUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePostureUpdateResponseEnvelopeSuccessTrue ZeroTrustDevicePostureUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePostureListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDevicePostureListResponseEnvelope struct { - Errors []ZeroTrustDevicePostureListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePostureListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDevicePostureListResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePostureListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDevicePostureListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDevicePostureListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDevicePostureListResponseEnvelope] -type zeroTrustDevicePostureListResponseEnvelopeJSON 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 *ZeroTrustDevicePostureListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePostureListResponseEnvelopeErrors] -type zeroTrustDevicePostureListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePostureListResponseEnvelopeMessages] -type zeroTrustDevicePostureListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePostureListResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePostureListResponseEnvelopeSuccessTrue ZeroTrustDevicePostureListResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePostureListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDevicePostureListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDevicePostureListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePostureListResponseEnvelopeResultInfo] -type zeroTrustDevicePostureListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureDeleteParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDevicePostureDeleteResponseEnvelope struct { - Errors []ZeroTrustDevicePostureDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePostureDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDevicePostureDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePostureDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDevicePostureDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePostureDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDevicePostureDeleteResponseEnvelope] -type zeroTrustDevicePostureDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePostureDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePostureDeleteResponseEnvelopeErrors] -type zeroTrustDevicePostureDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePostureDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePostureDeleteResponseEnvelopeMessages] -type zeroTrustDevicePostureDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePostureDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePostureDeleteResponseEnvelopeSuccessTrue ZeroTrustDevicePostureDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePostureGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDevicePostureGetResponseEnvelope struct { - Errors []ZeroTrustDevicePostureGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePostureGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDevicePostureGetResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePostureGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDevicePostureGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDevicePostureGetResponseEnvelope] -type zeroTrustDevicePostureGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePostureGetResponseEnvelopeErrors] -type zeroTrustDevicePostureGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePostureGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDevicePostureGetResponseEnvelopeMessages] -type zeroTrustDevicePostureGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePostureGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePostureGetResponseEnvelopeSuccessTrue ZeroTrustDevicePostureGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustdeviceposture_test.go b/zerotrustdeviceposture_test.go deleted file mode 100644 index 4f7c817c7a5..00000000000 --- a/zerotrustdeviceposture_test.go +++ /dev/null @@ -1,194 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDevicePostureNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Postures.New(context.TODO(), cloudflare.ZeroTrustDevicePostureNewParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Name: cloudflare.F("Admin Serial Numbers"), - Type: cloudflare.F(cloudflare.ZeroTrustDevicePostureNewParamsTypeFile), - Description: cloudflare.F("The rule for admin serial numbers"), - Expiration: cloudflare.F("1h"), - Input: cloudflare.F[cloudflare.ZeroTrustDevicePostureNewParamsInput](cloudflare.ZeroTrustDevicePostureNewParamsInputTeamsDevicesFileInputRequest(cloudflare.ZeroTrustDevicePostureNewParamsInputTeamsDevicesFileInputRequest{ - Exists: cloudflare.F(true), - OperatingSystem: cloudflare.F(cloudflare.ZeroTrustDevicePostureNewParamsInputTeamsDevicesFileInputRequestOperatingSystemLinux), - Path: cloudflare.F("/bin/cat"), - Sha256: cloudflare.F("https://api.us-2.crowdstrike.com"), - Thumbprint: cloudflare.F("0aabab210bdb998e9cf45da2c9ce352977ab531c681b74cf1e487be1bbe9fe6e"), - })), - Match: cloudflare.F([]cloudflare.ZeroTrustDevicePostureNewParamsMatch{{ - Platform: cloudflare.F(cloudflare.ZeroTrustDevicePostureNewParamsMatchPlatformWindows), - }, { - Platform: cloudflare.F(cloudflare.ZeroTrustDevicePostureNewParamsMatchPlatformWindows), - }, { - Platform: cloudflare.F(cloudflare.ZeroTrustDevicePostureNewParamsMatchPlatformWindows), - }}), - Schedule: cloudflare.F("1h"), - }) - 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 TestZeroTrustDevicePostureUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Postures.Update( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDevicePostureUpdateParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Name: cloudflare.F("Admin Serial Numbers"), - Type: cloudflare.F(cloudflare.ZeroTrustDevicePostureUpdateParamsTypeFile), - Description: cloudflare.F("The rule for admin serial numbers"), - Expiration: cloudflare.F("1h"), - Input: cloudflare.F[cloudflare.ZeroTrustDevicePostureUpdateParamsInput](cloudflare.ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFileInputRequest(cloudflare.ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFileInputRequest{ - Exists: cloudflare.F(true), - OperatingSystem: cloudflare.F(cloudflare.ZeroTrustDevicePostureUpdateParamsInputTeamsDevicesFileInputRequestOperatingSystemLinux), - Path: cloudflare.F("/bin/cat"), - Sha256: cloudflare.F("https://api.us-2.crowdstrike.com"), - Thumbprint: cloudflare.F("0aabab210bdb998e9cf45da2c9ce352977ab531c681b74cf1e487be1bbe9fe6e"), - })), - Match: cloudflare.F([]cloudflare.ZeroTrustDevicePostureUpdateParamsMatch{{ - Platform: cloudflare.F(cloudflare.ZeroTrustDevicePostureUpdateParamsMatchPlatformWindows), - }, { - Platform: cloudflare.F(cloudflare.ZeroTrustDevicePostureUpdateParamsMatchPlatformWindows), - }, { - Platform: cloudflare.F(cloudflare.ZeroTrustDevicePostureUpdateParamsMatchPlatformWindows), - }}), - Schedule: cloudflare.F("1h"), - }, - ) - 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 TestZeroTrustDevicePostureList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Postures.List(context.TODO(), cloudflare.ZeroTrustDevicePostureListParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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 TestZeroTrustDevicePostureDelete(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Postures.Delete( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDevicePostureDeleteParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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 TestZeroTrustDevicePostureGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Postures.Get( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDevicePostureGetParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrustdevicepostureintegration.go b/zerotrustdevicepostureintegration.go deleted file mode 100644 index b56fd3f14ac..00000000000 --- a/zerotrustdevicepostureintegration.go +++ /dev/null @@ -1,1211 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustDevicePostureIntegrationService 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 -// [NewZeroTrustDevicePostureIntegrationService] method instead. -type ZeroTrustDevicePostureIntegrationService struct { - Options []option.RequestOption -} - -// NewZeroTrustDevicePostureIntegrationService 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 NewZeroTrustDevicePostureIntegrationService(opts ...option.RequestOption) (r *ZeroTrustDevicePostureIntegrationService) { - r = &ZeroTrustDevicePostureIntegrationService{} - r.Options = opts - return -} - -// Create a new device posture integration. -func (r *ZeroTrustDevicePostureIntegrationService) New(ctx context.Context, params ZeroTrustDevicePostureIntegrationNewParams, opts ...option.RequestOption) (res *ZeroTrustDevicePostureIntegrationNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePostureIntegrationNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/posture/integration", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the list of device posture integrations for an account. -func (r *ZeroTrustDevicePostureIntegrationService) List(ctx context.Context, query ZeroTrustDevicePostureIntegrationListParams, opts ...option.RequestOption) (res *[]ZeroTrustDevicePostureIntegrationListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePostureIntegrationListResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/posture/integration", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a configured device posture integration. -func (r *ZeroTrustDevicePostureIntegrationService) Delete(ctx context.Context, integrationID string, body ZeroTrustDevicePostureIntegrationDeleteParams, opts ...option.RequestOption) (res *ZeroTrustDevicePostureIntegrationDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePostureIntegrationDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/posture/integration/%s", body.AccountID, integrationID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a configured device posture integration. -func (r *ZeroTrustDevicePostureIntegrationService) Edit(ctx context.Context, integrationID string, params ZeroTrustDevicePostureIntegrationEditParams, opts ...option.RequestOption) (res *ZeroTrustDevicePostureIntegrationEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePostureIntegrationEditResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/posture/integration/%s", params.AccountID, integrationID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches details for a single device posture integration. -func (r *ZeroTrustDevicePostureIntegrationService) Get(ctx context.Context, integrationID string, query ZeroTrustDevicePostureIntegrationGetParams, opts ...option.RequestOption) (res *ZeroTrustDevicePostureIntegrationGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDevicePostureIntegrationGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/posture/integration/%s", query.AccountID, integrationID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDevicePostureIntegrationNewResponse struct { - // API UUID. - ID string `json:"id"` - // The configuration object containing third-party integration information. - Config ZeroTrustDevicePostureIntegrationNewResponseConfig `json:"config"` - // The interval between each posture check with the third-party API. Use `m` for - // minutes (e.g. `5m`) and `h` for hours (e.g. `12h`). - Interval string `json:"interval"` - // The name of the device posture integration. - Name string `json:"name"` - // The type of device posture integration. - Type ZeroTrustDevicePostureIntegrationNewResponseType `json:"type"` - JSON zeroTrustDevicePostureIntegrationNewResponseJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationNewResponseJSON contains the JSON metadata for -// the struct [ZeroTrustDevicePostureIntegrationNewResponse] -type zeroTrustDevicePostureIntegrationNewResponseJSON struct { - ID apijson.Field - Config apijson.Field - Interval apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationNewResponseJSON) RawJSON() string { - return r.raw -} - -// The configuration object containing third-party integration information. -type ZeroTrustDevicePostureIntegrationNewResponseConfig struct { - // The Workspace One API URL provided in the Workspace One Admin Dashboard. - APIURL string `json:"api_url,required"` - // The Workspace One Authorization URL depending on your region. - AuthURL string `json:"auth_url,required"` - // The Workspace One client ID provided in the Workspace One Admin Dashboard. - ClientID string `json:"client_id,required"` - JSON zeroTrustDevicePostureIntegrationNewResponseConfigJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationNewResponseConfigJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePostureIntegrationNewResponseConfig] -type zeroTrustDevicePostureIntegrationNewResponseConfigJSON struct { - APIURL apijson.Field - AuthURL apijson.Field - ClientID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationNewResponseConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationNewResponseConfigJSON) RawJSON() string { - return r.raw -} - -// The type of device posture integration. -type ZeroTrustDevicePostureIntegrationNewResponseType string - -const ( - ZeroTrustDevicePostureIntegrationNewResponseTypeWorkspaceOne ZeroTrustDevicePostureIntegrationNewResponseType = "workspace_one" - ZeroTrustDevicePostureIntegrationNewResponseTypeCrowdstrikeS2s ZeroTrustDevicePostureIntegrationNewResponseType = "crowdstrike_s2s" - ZeroTrustDevicePostureIntegrationNewResponseTypeUptycs ZeroTrustDevicePostureIntegrationNewResponseType = "uptycs" - ZeroTrustDevicePostureIntegrationNewResponseTypeIntune ZeroTrustDevicePostureIntegrationNewResponseType = "intune" - ZeroTrustDevicePostureIntegrationNewResponseTypeKolide ZeroTrustDevicePostureIntegrationNewResponseType = "kolide" - ZeroTrustDevicePostureIntegrationNewResponseTypeTanium ZeroTrustDevicePostureIntegrationNewResponseType = "tanium" - ZeroTrustDevicePostureIntegrationNewResponseTypeSentineloneS2s ZeroTrustDevicePostureIntegrationNewResponseType = "sentinelone_s2s" -) - -type ZeroTrustDevicePostureIntegrationListResponse struct { - // API UUID. - ID string `json:"id"` - // The configuration object containing third-party integration information. - Config ZeroTrustDevicePostureIntegrationListResponseConfig `json:"config"` - // The interval between each posture check with the third-party API. Use `m` for - // minutes (e.g. `5m`) and `h` for hours (e.g. `12h`). - Interval string `json:"interval"` - // The name of the device posture integration. - Name string `json:"name"` - // The type of device posture integration. - Type ZeroTrustDevicePostureIntegrationListResponseType `json:"type"` - JSON zeroTrustDevicePostureIntegrationListResponseJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationListResponseJSON contains the JSON metadata for -// the struct [ZeroTrustDevicePostureIntegrationListResponse] -type zeroTrustDevicePostureIntegrationListResponseJSON struct { - ID apijson.Field - Config apijson.Field - Interval apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationListResponseJSON) RawJSON() string { - return r.raw -} - -// The configuration object containing third-party integration information. -type ZeroTrustDevicePostureIntegrationListResponseConfig struct { - // The Workspace One API URL provided in the Workspace One Admin Dashboard. - APIURL string `json:"api_url,required"` - // The Workspace One Authorization URL depending on your region. - AuthURL string `json:"auth_url,required"` - // The Workspace One client ID provided in the Workspace One Admin Dashboard. - ClientID string `json:"client_id,required"` - JSON zeroTrustDevicePostureIntegrationListResponseConfigJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationListResponseConfigJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePostureIntegrationListResponseConfig] -type zeroTrustDevicePostureIntegrationListResponseConfigJSON struct { - APIURL apijson.Field - AuthURL apijson.Field - ClientID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationListResponseConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationListResponseConfigJSON) RawJSON() string { - return r.raw -} - -// The type of device posture integration. -type ZeroTrustDevicePostureIntegrationListResponseType string - -const ( - ZeroTrustDevicePostureIntegrationListResponseTypeWorkspaceOne ZeroTrustDevicePostureIntegrationListResponseType = "workspace_one" - ZeroTrustDevicePostureIntegrationListResponseTypeCrowdstrikeS2s ZeroTrustDevicePostureIntegrationListResponseType = "crowdstrike_s2s" - ZeroTrustDevicePostureIntegrationListResponseTypeUptycs ZeroTrustDevicePostureIntegrationListResponseType = "uptycs" - ZeroTrustDevicePostureIntegrationListResponseTypeIntune ZeroTrustDevicePostureIntegrationListResponseType = "intune" - ZeroTrustDevicePostureIntegrationListResponseTypeKolide ZeroTrustDevicePostureIntegrationListResponseType = "kolide" - ZeroTrustDevicePostureIntegrationListResponseTypeTanium ZeroTrustDevicePostureIntegrationListResponseType = "tanium" - ZeroTrustDevicePostureIntegrationListResponseTypeSentineloneS2s ZeroTrustDevicePostureIntegrationListResponseType = "sentinelone_s2s" -) - -// Union satisfied by [ZeroTrustDevicePostureIntegrationDeleteResponseUnknown] or -// [shared.UnionString]. -type ZeroTrustDevicePostureIntegrationDeleteResponse interface { - ImplementsZeroTrustDevicePostureIntegrationDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustDevicePostureIntegrationDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustDevicePostureIntegrationEditResponse struct { - // API UUID. - ID string `json:"id"` - // The configuration object containing third-party integration information. - Config ZeroTrustDevicePostureIntegrationEditResponseConfig `json:"config"` - // The interval between each posture check with the third-party API. Use `m` for - // minutes (e.g. `5m`) and `h` for hours (e.g. `12h`). - Interval string `json:"interval"` - // The name of the device posture integration. - Name string `json:"name"` - // The type of device posture integration. - Type ZeroTrustDevicePostureIntegrationEditResponseType `json:"type"` - JSON zeroTrustDevicePostureIntegrationEditResponseJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationEditResponseJSON contains the JSON metadata for -// the struct [ZeroTrustDevicePostureIntegrationEditResponse] -type zeroTrustDevicePostureIntegrationEditResponseJSON struct { - ID apijson.Field - Config apijson.Field - Interval apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationEditResponseJSON) RawJSON() string { - return r.raw -} - -// The configuration object containing third-party integration information. -type ZeroTrustDevicePostureIntegrationEditResponseConfig struct { - // The Workspace One API URL provided in the Workspace One Admin Dashboard. - APIURL string `json:"api_url,required"` - // The Workspace One Authorization URL depending on your region. - AuthURL string `json:"auth_url,required"` - // The Workspace One client ID provided in the Workspace One Admin Dashboard. - ClientID string `json:"client_id,required"` - JSON zeroTrustDevicePostureIntegrationEditResponseConfigJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationEditResponseConfigJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePostureIntegrationEditResponseConfig] -type zeroTrustDevicePostureIntegrationEditResponseConfigJSON struct { - APIURL apijson.Field - AuthURL apijson.Field - ClientID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationEditResponseConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationEditResponseConfigJSON) RawJSON() string { - return r.raw -} - -// The type of device posture integration. -type ZeroTrustDevicePostureIntegrationEditResponseType string - -const ( - ZeroTrustDevicePostureIntegrationEditResponseTypeWorkspaceOne ZeroTrustDevicePostureIntegrationEditResponseType = "workspace_one" - ZeroTrustDevicePostureIntegrationEditResponseTypeCrowdstrikeS2s ZeroTrustDevicePostureIntegrationEditResponseType = "crowdstrike_s2s" - ZeroTrustDevicePostureIntegrationEditResponseTypeUptycs ZeroTrustDevicePostureIntegrationEditResponseType = "uptycs" - ZeroTrustDevicePostureIntegrationEditResponseTypeIntune ZeroTrustDevicePostureIntegrationEditResponseType = "intune" - ZeroTrustDevicePostureIntegrationEditResponseTypeKolide ZeroTrustDevicePostureIntegrationEditResponseType = "kolide" - ZeroTrustDevicePostureIntegrationEditResponseTypeTanium ZeroTrustDevicePostureIntegrationEditResponseType = "tanium" - ZeroTrustDevicePostureIntegrationEditResponseTypeSentineloneS2s ZeroTrustDevicePostureIntegrationEditResponseType = "sentinelone_s2s" -) - -type ZeroTrustDevicePostureIntegrationGetResponse struct { - // API UUID. - ID string `json:"id"` - // The configuration object containing third-party integration information. - Config ZeroTrustDevicePostureIntegrationGetResponseConfig `json:"config"` - // The interval between each posture check with the third-party API. Use `m` for - // minutes (e.g. `5m`) and `h` for hours (e.g. `12h`). - Interval string `json:"interval"` - // The name of the device posture integration. - Name string `json:"name"` - // The type of device posture integration. - Type ZeroTrustDevicePostureIntegrationGetResponseType `json:"type"` - JSON zeroTrustDevicePostureIntegrationGetResponseJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationGetResponseJSON contains the JSON metadata for -// the struct [ZeroTrustDevicePostureIntegrationGetResponse] -type zeroTrustDevicePostureIntegrationGetResponseJSON struct { - ID apijson.Field - Config apijson.Field - Interval apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationGetResponseJSON) RawJSON() string { - return r.raw -} - -// The configuration object containing third-party integration information. -type ZeroTrustDevicePostureIntegrationGetResponseConfig struct { - // The Workspace One API URL provided in the Workspace One Admin Dashboard. - APIURL string `json:"api_url,required"` - // The Workspace One Authorization URL depending on your region. - AuthURL string `json:"auth_url,required"` - // The Workspace One client ID provided in the Workspace One Admin Dashboard. - ClientID string `json:"client_id,required"` - JSON zeroTrustDevicePostureIntegrationGetResponseConfigJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationGetResponseConfigJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePostureIntegrationGetResponseConfig] -type zeroTrustDevicePostureIntegrationGetResponseConfigJSON struct { - APIURL apijson.Field - AuthURL apijson.Field - ClientID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationGetResponseConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationGetResponseConfigJSON) RawJSON() string { - return r.raw -} - -// The type of device posture integration. -type ZeroTrustDevicePostureIntegrationGetResponseType string - -const ( - ZeroTrustDevicePostureIntegrationGetResponseTypeWorkspaceOne ZeroTrustDevicePostureIntegrationGetResponseType = "workspace_one" - ZeroTrustDevicePostureIntegrationGetResponseTypeCrowdstrikeS2s ZeroTrustDevicePostureIntegrationGetResponseType = "crowdstrike_s2s" - ZeroTrustDevicePostureIntegrationGetResponseTypeUptycs ZeroTrustDevicePostureIntegrationGetResponseType = "uptycs" - ZeroTrustDevicePostureIntegrationGetResponseTypeIntune ZeroTrustDevicePostureIntegrationGetResponseType = "intune" - ZeroTrustDevicePostureIntegrationGetResponseTypeKolide ZeroTrustDevicePostureIntegrationGetResponseType = "kolide" - ZeroTrustDevicePostureIntegrationGetResponseTypeTanium ZeroTrustDevicePostureIntegrationGetResponseType = "tanium" - ZeroTrustDevicePostureIntegrationGetResponseTypeSentineloneS2s ZeroTrustDevicePostureIntegrationGetResponseType = "sentinelone_s2s" -) - -type ZeroTrustDevicePostureIntegrationNewParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // The configuration object containing third-party integration information. - Config param.Field[ZeroTrustDevicePostureIntegrationNewParamsConfig] `json:"config,required"` - // The interval between each posture check with the third-party API. Use `m` for - // minutes (e.g. `5m`) and `h` for hours (e.g. `12h`). - Interval param.Field[string] `json:"interval,required"` - // The name of the device posture integration. - Name param.Field[string] `json:"name,required"` - // The type of device posture integration. - Type param.Field[ZeroTrustDevicePostureIntegrationNewParamsType] `json:"type,required"` -} - -func (r ZeroTrustDevicePostureIntegrationNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The configuration object containing third-party integration information. -// -// Satisfied by -// [ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigRequest], -// [ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesCrowdstrikeConfigRequest], -// [ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesUptycsConfigRequest], -// [ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesIntuneConfigRequest], -// [ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesKolideConfigRequest], -// [ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesTaniumConfigRequest], -// [ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesSentineloneS2sConfigRequest]. -type ZeroTrustDevicePostureIntegrationNewParamsConfig interface { - implementsZeroTrustDevicePostureIntegrationNewParamsConfig() -} - -type ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigRequest struct { - // The Workspace One API URL provided in the Workspace One Admin Dashboard. - APIURL param.Field[string] `json:"api_url,required"` - // The Workspace One Authorization URL depending on your region. - AuthURL param.Field[string] `json:"auth_url,required"` - // The Workspace One client ID provided in the Workspace One Admin Dashboard. - ClientID param.Field[string] `json:"client_id,required"` - // The Workspace One client secret provided in the Workspace One Admin Dashboard. - ClientSecret param.Field[string] `json:"client_secret,required"` -} - -func (r ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { -} - -type ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesCrowdstrikeConfigRequest struct { - // The Crowdstrike API URL. - APIURL param.Field[string] `json:"api_url,required"` - // The Crowdstrike client ID. - ClientID param.Field[string] `json:"client_id,required"` - // The Crowdstrike client secret. - ClientSecret param.Field[string] `json:"client_secret,required"` - // The Crowdstrike customer ID. - CustomerID param.Field[string] `json:"customer_id,required"` -} - -func (r ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesCrowdstrikeConfigRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesCrowdstrikeConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { -} - -type ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesUptycsConfigRequest struct { - // The Uptycs API URL. - APIURL param.Field[string] `json:"api_url,required"` - // The Uptycs client secret. - ClientKey param.Field[string] `json:"client_key,required"` - // The Uptycs client secret. - ClientSecret param.Field[string] `json:"client_secret,required"` - // The Uptycs customer ID. - CustomerID param.Field[string] `json:"customer_id,required"` -} - -func (r ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesUptycsConfigRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesUptycsConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { -} - -type ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesIntuneConfigRequest struct { - // The Intune client ID. - ClientID param.Field[string] `json:"client_id,required"` - // The Intune client secret. - ClientSecret param.Field[string] `json:"client_secret,required"` - // The Intune customer ID. - CustomerID param.Field[string] `json:"customer_id,required"` -} - -func (r ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesIntuneConfigRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesIntuneConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { -} - -type ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesKolideConfigRequest struct { - // The Kolide client ID. - ClientID param.Field[string] `json:"client_id,required"` - // The Kolide client secret. - ClientSecret param.Field[string] `json:"client_secret,required"` -} - -func (r ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesKolideConfigRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesKolideConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { -} - -type ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesTaniumConfigRequest struct { - // The Tanium API URL. - APIURL param.Field[string] `json:"api_url,required"` - // The Tanium client secret. - ClientSecret param.Field[string] `json:"client_secret,required"` - // If present, this id will be passed in the `CF-Access-Client-ID` header when - // hitting the `api_url` - AccessClientID param.Field[string] `json:"access_client_id"` - // If present, this secret will be passed in the `CF-Access-Client-Secret` header - // when hitting the `api_url` - AccessClientSecret param.Field[string] `json:"access_client_secret"` -} - -func (r ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesTaniumConfigRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesTaniumConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { -} - -type ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesSentineloneS2sConfigRequest struct { - // The SentinelOne S2S API URL. - APIURL param.Field[string] `json:"api_url,required"` - // The SentinelOne S2S client secret. - ClientSecret param.Field[string] `json:"client_secret,required"` -} - -func (r ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesSentineloneS2sConfigRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesSentineloneS2sConfigRequest) implementsZeroTrustDevicePostureIntegrationNewParamsConfig() { -} - -// The type of device posture integration. -type ZeroTrustDevicePostureIntegrationNewParamsType string - -const ( - ZeroTrustDevicePostureIntegrationNewParamsTypeWorkspaceOne ZeroTrustDevicePostureIntegrationNewParamsType = "workspace_one" - ZeroTrustDevicePostureIntegrationNewParamsTypeCrowdstrikeS2s ZeroTrustDevicePostureIntegrationNewParamsType = "crowdstrike_s2s" - ZeroTrustDevicePostureIntegrationNewParamsTypeUptycs ZeroTrustDevicePostureIntegrationNewParamsType = "uptycs" - ZeroTrustDevicePostureIntegrationNewParamsTypeIntune ZeroTrustDevicePostureIntegrationNewParamsType = "intune" - ZeroTrustDevicePostureIntegrationNewParamsTypeKolide ZeroTrustDevicePostureIntegrationNewParamsType = "kolide" - ZeroTrustDevicePostureIntegrationNewParamsTypeTanium ZeroTrustDevicePostureIntegrationNewParamsType = "tanium" - ZeroTrustDevicePostureIntegrationNewParamsTypeSentineloneS2s ZeroTrustDevicePostureIntegrationNewParamsType = "sentinelone_s2s" -) - -type ZeroTrustDevicePostureIntegrationNewResponseEnvelope struct { - Errors []ZeroTrustDevicePostureIntegrationNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePostureIntegrationNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDevicePostureIntegrationNewResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePostureIntegrationNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDevicePostureIntegrationNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationNewResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePostureIntegrationNewResponseEnvelope] -type zeroTrustDevicePostureIntegrationNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureIntegrationNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureIntegrationNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustDevicePostureIntegrationNewResponseEnvelopeErrors] -type zeroTrustDevicePostureIntegrationNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureIntegrationNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureIntegrationNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationNewResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePostureIntegrationNewResponseEnvelopeMessages] -type zeroTrustDevicePostureIntegrationNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePostureIntegrationNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePostureIntegrationNewResponseEnvelopeSuccessTrue ZeroTrustDevicePostureIntegrationNewResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePostureIntegrationListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDevicePostureIntegrationListResponseEnvelope struct { - Errors []ZeroTrustDevicePostureIntegrationListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePostureIntegrationListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDevicePostureIntegrationListResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePostureIntegrationListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDevicePostureIntegrationListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDevicePostureIntegrationListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationListResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePostureIntegrationListResponseEnvelope] -type zeroTrustDevicePostureIntegrationListResponseEnvelopeJSON 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 *ZeroTrustDevicePostureIntegrationListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureIntegrationListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureIntegrationListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationListResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePostureIntegrationListResponseEnvelopeErrors] -type zeroTrustDevicePostureIntegrationListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureIntegrationListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureIntegrationListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationListResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePostureIntegrationListResponseEnvelopeMessages] -type zeroTrustDevicePostureIntegrationListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePostureIntegrationListResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePostureIntegrationListResponseEnvelopeSuccessTrue ZeroTrustDevicePostureIntegrationListResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePostureIntegrationListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDevicePostureIntegrationListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationListResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePostureIntegrationListResponseEnvelopeResultInfo] -type zeroTrustDevicePostureIntegrationListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureIntegrationDeleteParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDevicePostureIntegrationDeleteResponseEnvelope struct { - Errors []ZeroTrustDevicePostureIntegrationDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePostureIntegrationDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDevicePostureIntegrationDeleteResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePostureIntegrationDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDevicePostureIntegrationDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationDeleteResponseEnvelopeJSON contains the JSON -// metadata for the struct -// [ZeroTrustDevicePostureIntegrationDeleteResponseEnvelope] -type zeroTrustDevicePostureIntegrationDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureIntegrationDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureIntegrationDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationDeleteResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePostureIntegrationDeleteResponseEnvelopeErrors] -type zeroTrustDevicePostureIntegrationDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureIntegrationDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureIntegrationDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationDeleteResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePostureIntegrationDeleteResponseEnvelopeMessages] -type zeroTrustDevicePostureIntegrationDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePostureIntegrationDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePostureIntegrationDeleteResponseEnvelopeSuccessTrue ZeroTrustDevicePostureIntegrationDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePostureIntegrationEditParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // The configuration object containing third-party integration information. - Config param.Field[ZeroTrustDevicePostureIntegrationEditParamsConfig] `json:"config"` - // The interval between each posture check with the third-party API. Use `m` for - // minutes (e.g. `5m`) and `h` for hours (e.g. `12h`). - Interval param.Field[string] `json:"interval"` - // The name of the device posture integration. - Name param.Field[string] `json:"name"` - // The type of device posture integration. - Type param.Field[ZeroTrustDevicePostureIntegrationEditParamsType] `json:"type"` -} - -func (r ZeroTrustDevicePostureIntegrationEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The configuration object containing third-party integration information. -// -// Satisfied by -// [ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRequest], -// [ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesCrowdstrikeConfigRequest], -// [ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesUptycsConfigRequest], -// [ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesIntuneConfigRequest], -// [ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesKolideConfigRequest], -// [ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesTaniumConfigRequest], -// [ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesSentineloneS2sConfigRequest]. -type ZeroTrustDevicePostureIntegrationEditParamsConfig interface { - implementsZeroTrustDevicePostureIntegrationEditParamsConfig() -} - -type ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRequest struct { - // The Workspace One API URL provided in the Workspace One Admin Dashboard. - APIURL param.Field[string] `json:"api_url,required"` - // The Workspace One Authorization URL depending on your region. - AuthURL param.Field[string] `json:"auth_url,required"` - // The Workspace One client ID provided in the Workspace One Admin Dashboard. - ClientID param.Field[string] `json:"client_id,required"` - // The Workspace One client secret provided in the Workspace One Admin Dashboard. - ClientSecret param.Field[string] `json:"client_secret,required"` -} - -func (r ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { -} - -type ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesCrowdstrikeConfigRequest struct { - // The Crowdstrike API URL. - APIURL param.Field[string] `json:"api_url,required"` - // The Crowdstrike client ID. - ClientID param.Field[string] `json:"client_id,required"` - // The Crowdstrike client secret. - ClientSecret param.Field[string] `json:"client_secret,required"` - // The Crowdstrike customer ID. - CustomerID param.Field[string] `json:"customer_id,required"` -} - -func (r ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesCrowdstrikeConfigRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesCrowdstrikeConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { -} - -type ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesUptycsConfigRequest struct { - // The Uptycs API URL. - APIURL param.Field[string] `json:"api_url,required"` - // The Uptycs client secret. - ClientKey param.Field[string] `json:"client_key,required"` - // The Uptycs client secret. - ClientSecret param.Field[string] `json:"client_secret,required"` - // The Uptycs customer ID. - CustomerID param.Field[string] `json:"customer_id,required"` -} - -func (r ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesUptycsConfigRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesUptycsConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { -} - -type ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesIntuneConfigRequest struct { - // The Intune client ID. - ClientID param.Field[string] `json:"client_id,required"` - // The Intune client secret. - ClientSecret param.Field[string] `json:"client_secret,required"` - // The Intune customer ID. - CustomerID param.Field[string] `json:"customer_id,required"` -} - -func (r ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesIntuneConfigRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesIntuneConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { -} - -type ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesKolideConfigRequest struct { - // The Kolide client ID. - ClientID param.Field[string] `json:"client_id,required"` - // The Kolide client secret. - ClientSecret param.Field[string] `json:"client_secret,required"` -} - -func (r ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesKolideConfigRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesKolideConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { -} - -type ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesTaniumConfigRequest struct { - // The Tanium API URL. - APIURL param.Field[string] `json:"api_url,required"` - // The Tanium client secret. - ClientSecret param.Field[string] `json:"client_secret,required"` - // If present, this id will be passed in the `CF-Access-Client-ID` header when - // hitting the `api_url` - AccessClientID param.Field[string] `json:"access_client_id"` - // If present, this secret will be passed in the `CF-Access-Client-Secret` header - // when hitting the `api_url` - AccessClientSecret param.Field[string] `json:"access_client_secret"` -} - -func (r ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesTaniumConfigRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesTaniumConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { -} - -type ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesSentineloneS2sConfigRequest struct { - // The SentinelOne S2S API URL. - APIURL param.Field[string] `json:"api_url,required"` - // The SentinelOne S2S client secret. - ClientSecret param.Field[string] `json:"client_secret,required"` -} - -func (r ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesSentineloneS2sConfigRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesSentineloneS2sConfigRequest) implementsZeroTrustDevicePostureIntegrationEditParamsConfig() { -} - -// The type of device posture integration. -type ZeroTrustDevicePostureIntegrationEditParamsType string - -const ( - ZeroTrustDevicePostureIntegrationEditParamsTypeWorkspaceOne ZeroTrustDevicePostureIntegrationEditParamsType = "workspace_one" - ZeroTrustDevicePostureIntegrationEditParamsTypeCrowdstrikeS2s ZeroTrustDevicePostureIntegrationEditParamsType = "crowdstrike_s2s" - ZeroTrustDevicePostureIntegrationEditParamsTypeUptycs ZeroTrustDevicePostureIntegrationEditParamsType = "uptycs" - ZeroTrustDevicePostureIntegrationEditParamsTypeIntune ZeroTrustDevicePostureIntegrationEditParamsType = "intune" - ZeroTrustDevicePostureIntegrationEditParamsTypeKolide ZeroTrustDevicePostureIntegrationEditParamsType = "kolide" - ZeroTrustDevicePostureIntegrationEditParamsTypeTanium ZeroTrustDevicePostureIntegrationEditParamsType = "tanium" - ZeroTrustDevicePostureIntegrationEditParamsTypeSentineloneS2s ZeroTrustDevicePostureIntegrationEditParamsType = "sentinelone_s2s" -) - -type ZeroTrustDevicePostureIntegrationEditResponseEnvelope struct { - Errors []ZeroTrustDevicePostureIntegrationEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePostureIntegrationEditResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDevicePostureIntegrationEditResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePostureIntegrationEditResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDevicePostureIntegrationEditResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationEditResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePostureIntegrationEditResponseEnvelope] -type zeroTrustDevicePostureIntegrationEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureIntegrationEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureIntegrationEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationEditResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePostureIntegrationEditResponseEnvelopeErrors] -type zeroTrustDevicePostureIntegrationEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureIntegrationEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureIntegrationEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationEditResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePostureIntegrationEditResponseEnvelopeMessages] -type zeroTrustDevicePostureIntegrationEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePostureIntegrationEditResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePostureIntegrationEditResponseEnvelopeSuccessTrue ZeroTrustDevicePostureIntegrationEditResponseEnvelopeSuccess = true -) - -type ZeroTrustDevicePostureIntegrationGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDevicePostureIntegrationGetResponseEnvelope struct { - Errors []ZeroTrustDevicePostureIntegrationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDevicePostureIntegrationGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDevicePostureIntegrationGetResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDevicePostureIntegrationGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDevicePostureIntegrationGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustDevicePostureIntegrationGetResponseEnvelope] -type zeroTrustDevicePostureIntegrationGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureIntegrationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureIntegrationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustDevicePostureIntegrationGetResponseEnvelopeErrors] -type zeroTrustDevicePostureIntegrationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDevicePostureIntegrationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDevicePostureIntegrationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDevicePostureIntegrationGetResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustDevicePostureIntegrationGetResponseEnvelopeMessages] -type zeroTrustDevicePostureIntegrationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDevicePostureIntegrationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDevicePostureIntegrationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDevicePostureIntegrationGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustDevicePostureIntegrationGetResponseEnvelopeSuccessTrue ZeroTrustDevicePostureIntegrationGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustdevicepostureintegration_test.go b/zerotrustdevicepostureintegration_test.go deleted file mode 100644 index 6abc8fb17f6..00000000000 --- a/zerotrustdevicepostureintegration_test.go +++ /dev/null @@ -1,174 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDevicePostureIntegrationNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Postures.Integrations.New(context.TODO(), cloudflare.ZeroTrustDevicePostureIntegrationNewParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Config: cloudflare.F[cloudflare.ZeroTrustDevicePostureIntegrationNewParamsConfig](cloudflare.ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigRequest(cloudflare.ZeroTrustDevicePostureIntegrationNewParamsConfigTeamsDevicesWorkspaceOneConfigRequest{ - APIURL: cloudflare.F("https://as123.awmdm.com/API"), - AuthURL: cloudflare.F("https://na.uemauth.vmwservices.com/connect/token"), - ClientID: cloudflare.F("example client id"), - ClientSecret: cloudflare.F("example client secret"), - })), - Interval: cloudflare.F("10m"), - Name: cloudflare.F("My Workspace One Integration"), - Type: cloudflare.F(cloudflare.ZeroTrustDevicePostureIntegrationNewParamsTypeWorkspaceOne), - }) - 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 TestZeroTrustDevicePostureIntegrationList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Postures.Integrations.List(context.TODO(), cloudflare.ZeroTrustDevicePostureIntegrationListParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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 TestZeroTrustDevicePostureIntegrationDelete(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Postures.Integrations.Delete( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDevicePostureIntegrationDeleteParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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 TestZeroTrustDevicePostureIntegrationEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Postures.Integrations.Edit( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDevicePostureIntegrationEditParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Config: cloudflare.F[cloudflare.ZeroTrustDevicePostureIntegrationEditParamsConfig](cloudflare.ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRequest(cloudflare.ZeroTrustDevicePostureIntegrationEditParamsConfigTeamsDevicesWorkspaceOneConfigRequest{ - APIURL: cloudflare.F("https://as123.awmdm.com/API"), - AuthURL: cloudflare.F("https://na.uemauth.vmwservices.com/connect/token"), - ClientID: cloudflare.F("example client id"), - ClientSecret: cloudflare.F("example client secret"), - })), - Interval: cloudflare.F("10m"), - Name: cloudflare.F("My Workspace One Integration"), - Type: cloudflare.F(cloudflare.ZeroTrustDevicePostureIntegrationEditParamsTypeWorkspaceOne), - }, - ) - 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 TestZeroTrustDevicePostureIntegrationGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Postures.Integrations.Get( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDevicePostureIntegrationGetParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrustdevicerevoke.go b/zerotrustdevicerevoke.go deleted file mode 100644 index ab9a2386d08..00000000000 --- a/zerotrustdevicerevoke.go +++ /dev/null @@ -1,156 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustDeviceRevokeService 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 [NewZeroTrustDeviceRevokeService] -// method instead. -type ZeroTrustDeviceRevokeService struct { - Options []option.RequestOption -} - -// NewZeroTrustDeviceRevokeService 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 NewZeroTrustDeviceRevokeService(opts ...option.RequestOption) (r *ZeroTrustDeviceRevokeService) { - r = &ZeroTrustDeviceRevokeService{} - r.Options = opts - return -} - -// Revokes a list of devices. -func (r *ZeroTrustDeviceRevokeService) New(ctx context.Context, params ZeroTrustDeviceRevokeNewParams, opts ...option.RequestOption) (res *ZeroTrustDeviceRevokeNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDeviceRevokeNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/revoke", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [ZeroTrustDeviceRevokeNewResponseUnknown] or -// [shared.UnionString]. -type ZeroTrustDeviceRevokeNewResponse interface { - ImplementsZeroTrustDeviceRevokeNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustDeviceRevokeNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustDeviceRevokeNewParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // A list of device ids to revoke. - Body param.Field[[]string] `json:"body,required"` -} - -func (r ZeroTrustDeviceRevokeNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type ZeroTrustDeviceRevokeNewResponseEnvelope struct { - Errors []ZeroTrustDeviceRevokeNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDeviceRevokeNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDeviceRevokeNewResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDeviceRevokeNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDeviceRevokeNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDeviceRevokeNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceRevokeNewResponseEnvelope] -type zeroTrustDeviceRevokeNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceRevokeNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceRevokeNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceRevokeNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceRevokeNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDeviceRevokeNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDeviceRevokeNewResponseEnvelopeErrors] -type zeroTrustDeviceRevokeNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceRevokeNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceRevokeNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceRevokeNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceRevokeNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDeviceRevokeNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDeviceRevokeNewResponseEnvelopeMessages] -type zeroTrustDeviceRevokeNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceRevokeNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceRevokeNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDeviceRevokeNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustDeviceRevokeNewResponseEnvelopeSuccessTrue ZeroTrustDeviceRevokeNewResponseEnvelopeSuccess = true -) diff --git a/zerotrustdevicerevoke_test.go b/zerotrustdevicerevoke_test.go deleted file mode 100644 index e6bf3d4cb6b..00000000000 --- a/zerotrustdevicerevoke_test.go +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDeviceRevokeNew(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Revokes.New(context.TODO(), cloudflare.ZeroTrustDeviceRevokeNewParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Body: cloudflare.F([]string{"f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415"}), - }) - 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/zerotrustdevicesetting.go b/zerotrustdevicesetting.go deleted file mode 100644 index 186f00948df..00000000000 --- a/zerotrustdevicesetting.go +++ /dev/null @@ -1,302 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDeviceSettingService 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 [NewZeroTrustDeviceSettingService] -// method instead. -type ZeroTrustDeviceSettingService struct { - Options []option.RequestOption -} - -// NewZeroTrustDeviceSettingService 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 NewZeroTrustDeviceSettingService(opts ...option.RequestOption) (r *ZeroTrustDeviceSettingService) { - r = &ZeroTrustDeviceSettingService{} - r.Options = opts - return -} - -// Updates the current device settings for a Zero Trust account. -func (r *ZeroTrustDeviceSettingService) Update(ctx context.Context, params ZeroTrustDeviceSettingUpdateParams, opts ...option.RequestOption) (res *ZeroTrustDeviceSettingUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDeviceSettingUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/settings", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Describes the current device settings for a Zero Trust account. -func (r *ZeroTrustDeviceSettingService) List(ctx context.Context, query ZeroTrustDeviceSettingListParams, opts ...option.RequestOption) (res *ZeroTrustDeviceSettingListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDeviceSettingListResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/settings", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDeviceSettingUpdateResponse struct { - // Enable gateway proxy filtering on TCP. - GatewayProxyEnabled bool `json:"gateway_proxy_enabled"` - // Enable gateway proxy filtering on UDP. - GatewayUdpProxyEnabled bool `json:"gateway_udp_proxy_enabled"` - // Enable installation of cloudflare managed root certificate. - RootCertificateInstallationEnabled bool `json:"root_certificate_installation_enabled"` - // Enable using CGNAT virtual IPv4. - UseZtVirtualIP bool `json:"use_zt_virtual_ip"` - JSON zeroTrustDeviceSettingUpdateResponseJSON `json:"-"` -} - -// zeroTrustDeviceSettingUpdateResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDeviceSettingUpdateResponse] -type zeroTrustDeviceSettingUpdateResponseJSON struct { - GatewayProxyEnabled apijson.Field - GatewayUdpProxyEnabled apijson.Field - RootCertificateInstallationEnabled apijson.Field - UseZtVirtualIP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceSettingUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceSettingUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceSettingListResponse struct { - // Enable gateway proxy filtering on TCP. - GatewayProxyEnabled bool `json:"gateway_proxy_enabled"` - // Enable gateway proxy filtering on UDP. - GatewayUdpProxyEnabled bool `json:"gateway_udp_proxy_enabled"` - // Enable installation of cloudflare managed root certificate. - RootCertificateInstallationEnabled bool `json:"root_certificate_installation_enabled"` - // Enable using CGNAT virtual IPv4. - UseZtVirtualIP bool `json:"use_zt_virtual_ip"` - JSON zeroTrustDeviceSettingListResponseJSON `json:"-"` -} - -// zeroTrustDeviceSettingListResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDeviceSettingListResponse] -type zeroTrustDeviceSettingListResponseJSON struct { - GatewayProxyEnabled apijson.Field - GatewayUdpProxyEnabled apijson.Field - RootCertificateInstallationEnabled apijson.Field - UseZtVirtualIP apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceSettingListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceSettingListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceSettingUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // Enable gateway proxy filtering on TCP. - GatewayProxyEnabled param.Field[bool] `json:"gateway_proxy_enabled"` - // Enable gateway proxy filtering on UDP. - GatewayUdpProxyEnabled param.Field[bool] `json:"gateway_udp_proxy_enabled"` - // Enable installation of cloudflare managed root certificate. - RootCertificateInstallationEnabled param.Field[bool] `json:"root_certificate_installation_enabled"` - // Enable using CGNAT virtual IPv4. - UseZtVirtualIP param.Field[bool] `json:"use_zt_virtual_ip"` -} - -func (r ZeroTrustDeviceSettingUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDeviceSettingUpdateResponseEnvelope struct { - Errors []ZeroTrustDeviceSettingUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDeviceSettingUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDeviceSettingUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDeviceSettingUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDeviceSettingUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDeviceSettingUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDeviceSettingUpdateResponseEnvelope] -type zeroTrustDeviceSettingUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceSettingUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceSettingUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceSettingUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceSettingUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDeviceSettingUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDeviceSettingUpdateResponseEnvelopeErrors] -type zeroTrustDeviceSettingUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceSettingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceSettingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceSettingUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceSettingUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDeviceSettingUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDeviceSettingUpdateResponseEnvelopeMessages] -type zeroTrustDeviceSettingUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceSettingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceSettingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDeviceSettingUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustDeviceSettingUpdateResponseEnvelopeSuccessTrue ZeroTrustDeviceSettingUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustDeviceSettingListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustDeviceSettingListResponseEnvelope struct { - Errors []ZeroTrustDeviceSettingListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDeviceSettingListResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDeviceSettingListResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDeviceSettingListResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDeviceSettingListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDeviceSettingListResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDeviceSettingListResponseEnvelope] -type zeroTrustDeviceSettingListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceSettingListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceSettingListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceSettingListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceSettingListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDeviceSettingListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDeviceSettingListResponseEnvelopeErrors] -type zeroTrustDeviceSettingListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceSettingListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceSettingListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceSettingListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceSettingListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDeviceSettingListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDeviceSettingListResponseEnvelopeMessages] -type zeroTrustDeviceSettingListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceSettingListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceSettingListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDeviceSettingListResponseEnvelopeSuccess bool - -const ( - ZeroTrustDeviceSettingListResponseEnvelopeSuccessTrue ZeroTrustDeviceSettingListResponseEnvelopeSuccess = true -) diff --git a/zerotrustdevicesetting_test.go b/zerotrustdevicesetting_test.go deleted file mode 100644 index bbea980fddf..00000000000 --- a/zerotrustdevicesetting_test.go +++ /dev/null @@ -1,70 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDeviceSettingUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Settings.Update(context.TODO(), cloudflare.ZeroTrustDeviceSettingUpdateParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - GatewayProxyEnabled: cloudflare.F(true), - GatewayUdpProxyEnabled: cloudflare.F(true), - RootCertificateInstallationEnabled: cloudflare.F(true), - UseZtVirtualIP: cloudflare.F(true), - }) - 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 TestZeroTrustDeviceSettingList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Settings.List(context.TODO(), cloudflare.ZeroTrustDeviceSettingListParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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/zerotrustdeviceunrevoke.go b/zerotrustdeviceunrevoke.go deleted file mode 100644 index eb89d99ccb8..00000000000 --- a/zerotrustdeviceunrevoke.go +++ /dev/null @@ -1,156 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustDeviceUnrevokeService 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 -// [NewZeroTrustDeviceUnrevokeService] method instead. -type ZeroTrustDeviceUnrevokeService struct { - Options []option.RequestOption -} - -// NewZeroTrustDeviceUnrevokeService 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 NewZeroTrustDeviceUnrevokeService(opts ...option.RequestOption) (r *ZeroTrustDeviceUnrevokeService) { - r = &ZeroTrustDeviceUnrevokeService{} - r.Options = opts - return -} - -// Unrevokes a list of devices. -func (r *ZeroTrustDeviceUnrevokeService) New(ctx context.Context, params ZeroTrustDeviceUnrevokeNewParams, opts ...option.RequestOption) (res *ZeroTrustDeviceUnrevokeNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDeviceUnrevokeNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/devices/unrevoke", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [ZeroTrustDeviceUnrevokeNewResponseUnknown] or -// [shared.UnionString]. -type ZeroTrustDeviceUnrevokeNewResponse interface { - ImplementsZeroTrustDeviceUnrevokeNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustDeviceUnrevokeNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustDeviceUnrevokeNewParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // A list of device ids to unrevoke. - Body param.Field[[]string] `json:"body,required"` -} - -func (r ZeroTrustDeviceUnrevokeNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type ZeroTrustDeviceUnrevokeNewResponseEnvelope struct { - Errors []ZeroTrustDeviceUnrevokeNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDeviceUnrevokeNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDeviceUnrevokeNewResponse `json:"result,required,nullable"` - // Whether the API call was successful. - Success ZeroTrustDeviceUnrevokeNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDeviceUnrevokeNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDeviceUnrevokeNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDeviceUnrevokeNewResponseEnvelope] -type zeroTrustDeviceUnrevokeNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceUnrevokeNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceUnrevokeNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceUnrevokeNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceUnrevokeNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDeviceUnrevokeNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDeviceUnrevokeNewResponseEnvelopeErrors] -type zeroTrustDeviceUnrevokeNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceUnrevokeNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceUnrevokeNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDeviceUnrevokeNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDeviceUnrevokeNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDeviceUnrevokeNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDeviceUnrevokeNewResponseEnvelopeMessages] -type zeroTrustDeviceUnrevokeNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDeviceUnrevokeNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDeviceUnrevokeNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful. -type ZeroTrustDeviceUnrevokeNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustDeviceUnrevokeNewResponseEnvelopeSuccessTrue ZeroTrustDeviceUnrevokeNewResponseEnvelopeSuccess = true -) diff --git a/zerotrustdeviceunrevoke_test.go b/zerotrustdeviceunrevoke_test.go deleted file mode 100644 index 3a7f0f54f50..00000000000 --- a/zerotrustdeviceunrevoke_test.go +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDeviceUnrevokeNew(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("user@example.com"), - ) - _, err := client.ZeroTrust.Devices.Unrevokes.New(context.TODO(), cloudflare.ZeroTrustDeviceUnrevokeNewParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Body: cloudflare.F([]string{"f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415"}), - }) - 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/zerotrustdex.go b/zerotrustdex.go deleted file mode 100644 index ce2ab707a44..00000000000 --- a/zerotrustdex.go +++ /dev/null @@ -1,37 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDEXService 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 [NewZeroTrustDEXService] method -// instead. -type ZeroTrustDEXService struct { - Options []option.RequestOption - Colos *ZeroTrustDEXColoService - FleetStatus *ZeroTrustDEXFleetStatusService - HTTPTests *ZeroTrustDEXHTTPTestService - Tests *ZeroTrustDEXTestService - TracerouteTestResults *ZeroTrustDEXTracerouteTestResultService - TracerouteTests *ZeroTrustDEXTracerouteTestService -} - -// NewZeroTrustDEXService 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 NewZeroTrustDEXService(opts ...option.RequestOption) (r *ZeroTrustDEXService) { - r = &ZeroTrustDEXService{} - r.Options = opts - r.Colos = NewZeroTrustDEXColoService(opts...) - r.FleetStatus = NewZeroTrustDEXFleetStatusService(opts...) - r.HTTPTests = NewZeroTrustDEXHTTPTestService(opts...) - r.Tests = NewZeroTrustDEXTestService(opts...) - r.TracerouteTestResults = NewZeroTrustDEXTracerouteTestResultService(opts...) - r.TracerouteTests = NewZeroTrustDEXTracerouteTestService(opts...) - return -} diff --git a/zerotrustdexcolo.go b/zerotrustdexcolo.go deleted file mode 100644 index de2a8bb2af1..00000000000 --- a/zerotrustdexcolo.go +++ /dev/null @@ -1,195 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDEXColoService 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 [NewZeroTrustDEXColoService] method -// instead. -type ZeroTrustDEXColoService struct { - Options []option.RequestOption -} - -// NewZeroTrustDEXColoService 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 NewZeroTrustDEXColoService(opts ...option.RequestOption) (r *ZeroTrustDEXColoService) { - r = &ZeroTrustDEXColoService{} - r.Options = opts - return -} - -// List Cloudflare colos that account's devices were connected to during a time -// period, sorted by usage starting from the most used colo. Colos without traffic -// are also returned and sorted alphabetically. -func (r *ZeroTrustDEXColoService) List(ctx context.Context, params ZeroTrustDEXColoListParams, opts ...option.RequestOption) (res *[]ZeroTrustDEXColoListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDEXColoListResponseEnvelope - path := fmt.Sprintf("accounts/%s/dex/colos", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDEXColoListResponse = interface{} - -type ZeroTrustDEXColoListParams struct { - AccountID param.Field[string] `path:"account_id,required"` - // End time for connection period in RFC3339 (ISO 8601) format. - TimeEnd param.Field[string] `query:"timeEnd,required"` - // Start time for connection period in RFC3339 (ISO 8601) format. - TimeStart param.Field[string] `query:"timeStart,required"` - // Type of usage that colos should be sorted by. If unspecified, returns all - // Cloudflare colos sorted alphabetically. - SortBy param.Field[ZeroTrustDEXColoListParamsSortBy] `query:"sortBy"` -} - -// URLQuery serializes [ZeroTrustDEXColoListParams]'s query parameters as -// `url.Values`. -func (r ZeroTrustDEXColoListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Type of usage that colos should be sorted by. If unspecified, returns all -// Cloudflare colos sorted alphabetically. -type ZeroTrustDEXColoListParamsSortBy string - -const ( - ZeroTrustDEXColoListParamsSortByFleetStatusUsage ZeroTrustDEXColoListParamsSortBy = "fleet-status-usage" - ZeroTrustDEXColoListParamsSortByApplicationTestsUsage ZeroTrustDEXColoListParamsSortBy = "application-tests-usage" -) - -type ZeroTrustDEXColoListResponseEnvelope struct { - Errors []ZeroTrustDEXColoListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDEXColoListResponseEnvelopeMessages `json:"messages,required"` - // array of colos. - Result []ZeroTrustDEXColoListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustDEXColoListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDEXColoListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDEXColoListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDEXColoListResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDEXColoListResponseEnvelope] -type zeroTrustDEXColoListResponseEnvelopeJSON 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 *ZeroTrustDEXColoListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXColoListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXColoListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDEXColoListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDEXColoListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustDEXColoListResponseEnvelopeErrors] -type zeroTrustDEXColoListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXColoListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXColoListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXColoListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDEXColoListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDEXColoListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZeroTrustDEXColoListResponseEnvelopeMessages] -type zeroTrustDEXColoListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXColoListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXColoListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDEXColoListResponseEnvelopeSuccess bool - -const ( - ZeroTrustDEXColoListResponseEnvelopeSuccessTrue ZeroTrustDEXColoListResponseEnvelopeSuccess = true -) - -type ZeroTrustDEXColoListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDEXColoListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDEXColoListResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [ZeroTrustDEXColoListResponseEnvelopeResultInfo] -type zeroTrustDEXColoListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXColoListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXColoListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zerotrustdexcolo_test.go b/zerotrustdexcolo_test.go deleted file mode 100644 index ac6462edbcd..00000000000 --- a/zerotrustdexcolo_test.go +++ /dev/null @@ -1,43 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDEXColoListWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.DEX.Colos.List(context.TODO(), cloudflare.ZeroTrustDEXColoListParams{ - AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), - TimeEnd: cloudflare.F("2023-08-24T20:45:00Z"), - TimeStart: cloudflare.F("2023-08-20T20:45:00Z"), - SortBy: cloudflare.F(cloudflare.ZeroTrustDEXColoListParamsSortByFleetStatusUsage), - }) - 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/zerotrustdexfleetstatus.go b/zerotrustdexfleetstatus.go deleted file mode 100644 index 0fb3f3ab5b3..00000000000 --- a/zerotrustdexfleetstatus.go +++ /dev/null @@ -1,31 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDEXFleetStatusService 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 -// [NewZeroTrustDEXFleetStatusService] method instead. -type ZeroTrustDEXFleetStatusService struct { - Options []option.RequestOption - Devices *ZeroTrustDEXFleetStatusDeviceService - Live *ZeroTrustDEXFleetStatusLiveService - OverTime *ZeroTrustDEXFleetStatusOverTimeService -} - -// NewZeroTrustDEXFleetStatusService 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 NewZeroTrustDEXFleetStatusService(opts ...option.RequestOption) (r *ZeroTrustDEXFleetStatusService) { - r = &ZeroTrustDEXFleetStatusService{} - r.Options = opts - r.Devices = NewZeroTrustDEXFleetStatusDeviceService(opts...) - r.Live = NewZeroTrustDEXFleetStatusLiveService(opts...) - r.OverTime = NewZeroTrustDEXFleetStatusOverTimeService(opts...) - return -} diff --git a/zerotrustdexfleetstatusdevice.go b/zerotrustdexfleetstatusdevice.go deleted file mode 100644 index 119246dafdc..00000000000 --- a/zerotrustdexfleetstatusdevice.go +++ /dev/null @@ -1,146 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDEXFleetStatusDeviceService 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 -// [NewZeroTrustDEXFleetStatusDeviceService] method instead. -type ZeroTrustDEXFleetStatusDeviceService struct { - Options []option.RequestOption -} - -// NewZeroTrustDEXFleetStatusDeviceService 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 NewZeroTrustDEXFleetStatusDeviceService(opts ...option.RequestOption) (r *ZeroTrustDEXFleetStatusDeviceService) { - r = &ZeroTrustDEXFleetStatusDeviceService{} - r.Options = opts - return -} - -// List details for devices using WARP -func (r *ZeroTrustDEXFleetStatusDeviceService) List(ctx context.Context, params ZeroTrustDEXFleetStatusDeviceListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[ZeroTrustDEXFleetStatusDeviceListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("accounts/%s/dex/fleet-status/devices", params.AccountID) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// List details for devices using WARP -func (r *ZeroTrustDEXFleetStatusDeviceService) ListAutoPaging(ctx context.Context, params ZeroTrustDEXFleetStatusDeviceListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[ZeroTrustDEXFleetStatusDeviceListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) -} - -type ZeroTrustDEXFleetStatusDeviceListResponse struct { - // Cloudflare colo - Colo string `json:"colo,required"` - // Device identifier (UUID v4) - DeviceID string `json:"deviceId,required"` - // Operating system - Platform string `json:"platform,required"` - // Network status - Status string `json:"status,required"` - // WARP client version - Version string `json:"version,required"` - // Device identifier (human readable) - DeviceName string `json:"deviceName"` - // User contact email address - PersonEmail string `json:"personEmail"` - JSON zeroTrustDEXFleetStatusDeviceListResponseJSON `json:"-"` -} - -// zeroTrustDEXFleetStatusDeviceListResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDEXFleetStatusDeviceListResponse] -type zeroTrustDEXFleetStatusDeviceListResponseJSON struct { - Colo apijson.Field - DeviceID apijson.Field - Platform apijson.Field - Status apijson.Field - Version apijson.Field - DeviceName apijson.Field - PersonEmail apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXFleetStatusDeviceListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXFleetStatusDeviceListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXFleetStatusDeviceListParams struct { - AccountID param.Field[string] `path:"account_id,required"` - // Page number of paginated results - Page param.Field[float64] `query:"page,required"` - // Number of items per page - PerPage param.Field[float64] `query:"per_page,required"` - // Timestamp in ISO format - TimeEnd param.Field[string] `query:"time_end,required"` - // Timestamp in ISO format - TimeStart param.Field[string] `query:"time_start,required"` - // Cloudflare colo - Colo param.Field[string] `query:"colo"` - // Device-specific ID, given as UUID v4 - DeviceID param.Field[string] `query:"device_id"` - // The mode under which the WARP client is run - Mode param.Field[string] `query:"mode"` - // Operating system - Platform param.Field[string] `query:"platform"` - // Dimension to sort results by - SortBy param.Field[ZeroTrustDEXFleetStatusDeviceListParamsSortBy] `query:"sort_by"` - // Network status - Status param.Field[string] `query:"status"` - // WARP client version - Version param.Field[string] `query:"version"` -} - -// URLQuery serializes [ZeroTrustDEXFleetStatusDeviceListParams]'s query parameters -// as `url.Values`. -func (r ZeroTrustDEXFleetStatusDeviceListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Dimension to sort results by -type ZeroTrustDEXFleetStatusDeviceListParamsSortBy string - -const ( - ZeroTrustDEXFleetStatusDeviceListParamsSortByColo ZeroTrustDEXFleetStatusDeviceListParamsSortBy = "colo" - ZeroTrustDEXFleetStatusDeviceListParamsSortByDeviceID ZeroTrustDEXFleetStatusDeviceListParamsSortBy = "device_id" - ZeroTrustDEXFleetStatusDeviceListParamsSortByMode ZeroTrustDEXFleetStatusDeviceListParamsSortBy = "mode" - ZeroTrustDEXFleetStatusDeviceListParamsSortByPlatform ZeroTrustDEXFleetStatusDeviceListParamsSortBy = "platform" - ZeroTrustDEXFleetStatusDeviceListParamsSortByStatus ZeroTrustDEXFleetStatusDeviceListParamsSortBy = "status" - ZeroTrustDEXFleetStatusDeviceListParamsSortByTimestamp ZeroTrustDEXFleetStatusDeviceListParamsSortBy = "timestamp" - ZeroTrustDEXFleetStatusDeviceListParamsSortByVersion ZeroTrustDEXFleetStatusDeviceListParamsSortBy = "version" -) diff --git a/zerotrustdexfleetstatusdevice_test.go b/zerotrustdexfleetstatusdevice_test.go deleted file mode 100644 index 1a83e292e58..00000000000 --- a/zerotrustdexfleetstatusdevice_test.go +++ /dev/null @@ -1,51 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDEXFleetStatusDeviceListWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.DEX.FleetStatus.Devices.List(context.TODO(), cloudflare.ZeroTrustDEXFleetStatusDeviceListParams{ - AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(10.000000), - TimeEnd: cloudflare.F("2023-10-11T00:00:00Z"), - TimeStart: cloudflare.F("2023-10-11T00:00:00Z"), - Colo: cloudflare.F("SJC"), - DeviceID: cloudflare.F("cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7"), - Mode: cloudflare.F("proxy"), - Platform: cloudflare.F("windows"), - SortBy: cloudflare.F(cloudflare.ZeroTrustDEXFleetStatusDeviceListParamsSortByColo), - Status: cloudflare.F("connected"), - Version: cloudflare.F("1.0.0"), - }) - 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/zerotrustdexfleetstatuslive.go b/zerotrustdexfleetstatuslive.go deleted file mode 100644 index 4d6cd369229..00000000000 --- a/zerotrustdexfleetstatuslive.go +++ /dev/null @@ -1,322 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDEXFleetStatusLiveService 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 -// [NewZeroTrustDEXFleetStatusLiveService] method instead. -type ZeroTrustDEXFleetStatusLiveService struct { - Options []option.RequestOption -} - -// NewZeroTrustDEXFleetStatusLiveService 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 NewZeroTrustDEXFleetStatusLiveService(opts ...option.RequestOption) (r *ZeroTrustDEXFleetStatusLiveService) { - r = &ZeroTrustDEXFleetStatusLiveService{} - r.Options = opts - return -} - -// List details for live (up to 60 minutes) devices using WARP -func (r *ZeroTrustDEXFleetStatusLiveService) List(ctx context.Context, params ZeroTrustDEXFleetStatusLiveListParams, opts ...option.RequestOption) (res *ZeroTrustDEXFleetStatusLiveListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDEXFleetStatusLiveListResponseEnvelope - path := fmt.Sprintf("accounts/%s/dex/fleet-status/live", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDEXFleetStatusLiveListResponse struct { - DeviceStats ZeroTrustDEXFleetStatusLiveListResponseDeviceStats `json:"deviceStats"` - JSON zeroTrustDEXFleetStatusLiveListResponseJSON `json:"-"` -} - -// zeroTrustDEXFleetStatusLiveListResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDEXFleetStatusLiveListResponse] -type zeroTrustDEXFleetStatusLiveListResponseJSON struct { - DeviceStats apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXFleetStatusLiveListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXFleetStatusLiveListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXFleetStatusLiveListResponseDeviceStats struct { - ByColo []ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByColo `json:"byColo,nullable"` - ByMode []ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByMode `json:"byMode,nullable"` - ByPlatform []ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByPlatform `json:"byPlatform,nullable"` - ByStatus []ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByStatus `json:"byStatus,nullable"` - ByVersion []ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByVersion `json:"byVersion,nullable"` - // Number of unique devices - UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` - JSON zeroTrustDEXFleetStatusLiveListResponseDeviceStatsJSON `json:"-"` -} - -// zeroTrustDEXFleetStatusLiveListResponseDeviceStatsJSON contains the JSON -// metadata for the struct [ZeroTrustDEXFleetStatusLiveListResponseDeviceStats] -type zeroTrustDEXFleetStatusLiveListResponseDeviceStatsJSON struct { - ByColo apijson.Field - ByMode apijson.Field - ByPlatform apijson.Field - ByStatus apijson.Field - ByVersion apijson.Field - UniqueDevicesTotal apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXFleetStatusLiveListResponseDeviceStats) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXFleetStatusLiveListResponseDeviceStatsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByColo struct { - // Number of unique devices - UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` - Value string `json:"value"` - JSON zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByColoJSON `json:"-"` -} - -// zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByColoJSON contains the JSON -// metadata for the struct -// [ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByColo] -type zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByColoJSON struct { - UniqueDevicesTotal apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByColo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByColoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByMode struct { - // Number of unique devices - UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` - Value string `json:"value"` - JSON zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByModeJSON `json:"-"` -} - -// zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByModeJSON contains the JSON -// metadata for the struct -// [ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByMode] -type zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByModeJSON struct { - UniqueDevicesTotal apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByMode) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByModeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByPlatform struct { - // Number of unique devices - UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` - Value string `json:"value"` - JSON zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByPlatformJSON `json:"-"` -} - -// zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByPlatformJSON contains the -// JSON metadata for the struct -// [ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByPlatform] -type zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByPlatformJSON struct { - UniqueDevicesTotal apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByPlatform) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByPlatformJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByStatus struct { - // Number of unique devices - UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` - Value string `json:"value"` - JSON zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByStatusJSON `json:"-"` -} - -// zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByStatusJSON contains the JSON -// metadata for the struct -// [ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByStatus] -type zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByStatusJSON struct { - UniqueDevicesTotal apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByStatus) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByStatusJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByVersion struct { - // Number of unique devices - UniqueDevicesTotal float64 `json:"uniqueDevicesTotal"` - Value string `json:"value"` - JSON zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByVersionJSON `json:"-"` -} - -// zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByVersionJSON contains the -// JSON metadata for the struct -// [ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByVersion] -type zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByVersionJSON struct { - UniqueDevicesTotal apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXFleetStatusLiveListResponseDeviceStatsByVersion) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXFleetStatusLiveListResponseDeviceStatsByVersionJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXFleetStatusLiveListParams struct { - AccountID param.Field[string] `path:"account_id,required"` - // Number of minutes before current time - SinceMinutes param.Field[float64] `query:"since_minutes,required"` -} - -// URLQuery serializes [ZeroTrustDEXFleetStatusLiveListParams]'s query parameters -// as `url.Values`. -func (r ZeroTrustDEXFleetStatusLiveListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type ZeroTrustDEXFleetStatusLiveListResponseEnvelope struct { - Errors []ZeroTrustDEXFleetStatusLiveListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDEXFleetStatusLiveListResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDEXFleetStatusLiveListResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustDEXFleetStatusLiveListResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDEXFleetStatusLiveListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDEXFleetStatusLiveListResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustDEXFleetStatusLiveListResponseEnvelope] -type zeroTrustDEXFleetStatusLiveListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXFleetStatusLiveListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXFleetStatusLiveListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXFleetStatusLiveListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDEXFleetStatusLiveListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDEXFleetStatusLiveListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDEXFleetStatusLiveListResponseEnvelopeErrors] -type zeroTrustDEXFleetStatusLiveListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXFleetStatusLiveListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXFleetStatusLiveListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXFleetStatusLiveListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDEXFleetStatusLiveListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDEXFleetStatusLiveListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustDEXFleetStatusLiveListResponseEnvelopeMessages] -type zeroTrustDEXFleetStatusLiveListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXFleetStatusLiveListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXFleetStatusLiveListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDEXFleetStatusLiveListResponseEnvelopeSuccess bool - -const ( - ZeroTrustDEXFleetStatusLiveListResponseEnvelopeSuccessTrue ZeroTrustDEXFleetStatusLiveListResponseEnvelopeSuccess = true -) diff --git a/zerotrustdexfleetstatuslive_test.go b/zerotrustdexfleetstatuslive_test.go deleted file mode 100644 index 3e3c49da379..00000000000 --- a/zerotrustdexfleetstatuslive_test.go +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDEXFleetStatusLiveList(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("user@example.com"), - ) - _, err := client.ZeroTrust.DEX.FleetStatus.Live.List(context.TODO(), cloudflare.ZeroTrustDEXFleetStatusLiveListParams{ - AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), - SinceMinutes: cloudflare.F(10.000000), - }) - 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/zerotrustdexfleetstatusovertime.go b/zerotrustdexfleetstatusovertime.go deleted file mode 100644 index f09c358e723..00000000000 --- a/zerotrustdexfleetstatusovertime.go +++ /dev/null @@ -1,63 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDEXFleetStatusOverTimeService 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 -// [NewZeroTrustDEXFleetStatusOverTimeService] method instead. -type ZeroTrustDEXFleetStatusOverTimeService struct { - Options []option.RequestOption -} - -// NewZeroTrustDEXFleetStatusOverTimeService 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 NewZeroTrustDEXFleetStatusOverTimeService(opts ...option.RequestOption) (r *ZeroTrustDEXFleetStatusOverTimeService) { - r = &ZeroTrustDEXFleetStatusOverTimeService{} - r.Options = opts - return -} - -// List details for devices using WARP, up to 7 days -func (r *ZeroTrustDEXFleetStatusOverTimeService) List(ctx context.Context, params ZeroTrustDEXFleetStatusOverTimeListParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := fmt.Sprintf("accounts/%s/dex/fleet-status/over-time", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, nil, opts...) - return -} - -type ZeroTrustDEXFleetStatusOverTimeListParams struct { - AccountID param.Field[string] `path:"account_id,required"` - // Timestamp in ISO format - TimeEnd param.Field[string] `query:"time_end,required"` - // Timestamp in ISO format - TimeStart param.Field[string] `query:"time_start,required"` - // Cloudflare colo - Colo param.Field[string] `query:"colo"` - // Device-specific ID, given as UUID v4 - DeviceID param.Field[string] `query:"device_id"` -} - -// URLQuery serializes [ZeroTrustDEXFleetStatusOverTimeListParams]'s query -// parameters as `url.Values`. -func (r ZeroTrustDEXFleetStatusOverTimeListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} diff --git a/zerotrustdexfleetstatusovertime_test.go b/zerotrustdexfleetstatusovertime_test.go deleted file mode 100644 index 978e69bdd1f..00000000000 --- a/zerotrustdexfleetstatusovertime_test.go +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDEXFleetStatusOverTimeListWithOptionalParams(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("user@example.com"), - ) - err := client.ZeroTrust.DEX.FleetStatus.OverTime.List(context.TODO(), cloudflare.ZeroTrustDEXFleetStatusOverTimeListParams{ - AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), - TimeEnd: cloudflare.F("2023-10-11T00:00:00Z"), - TimeStart: cloudflare.F("2023-10-11T00:00:00Z"), - Colo: cloudflare.F("SJC"), - DeviceID: cloudflare.F("cb49c27f-7f97-49c5-b6f3-f7c01ead0fd7"), - }) - 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/zerotrustdexhttptest.go b/zerotrustdexhttptest.go deleted file mode 100644 index accb1d230f0..00000000000 --- a/zerotrustdexhttptest.go +++ /dev/null @@ -1,658 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDEXHTTPTestService 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 [NewZeroTrustDEXHTTPTestService] -// method instead. -type ZeroTrustDEXHTTPTestService struct { - Options []option.RequestOption - Percentiles *ZeroTrustDEXHTTPTestPercentileService -} - -// NewZeroTrustDEXHTTPTestService 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 NewZeroTrustDEXHTTPTestService(opts ...option.RequestOption) (r *ZeroTrustDEXHTTPTestService) { - r = &ZeroTrustDEXHTTPTestService{} - r.Options = opts - r.Percentiles = NewZeroTrustDEXHTTPTestPercentileService(opts...) - return -} - -// Get test details and aggregate performance metrics for an http test for a given -// time period between 1 hour and 7 days. -func (r *ZeroTrustDEXHTTPTestService) Get(ctx context.Context, testID string, params ZeroTrustDEXHTTPTestGetParams, opts ...option.RequestOption) (res *ZeroTrustDexhttpTestGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDexhttpTestGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/dex/http-tests/%s", params.AccountID, testID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDexhttpTestGetResponse struct { - // The url of the HTTP synthetic application test - Host string `json:"host"` - HTTPStats ZeroTrustDexhttpTestGetResponseHTTPStats `json:"httpStats,nullable"` - HTTPStatsByColo []ZeroTrustDexhttpTestGetResponseHTTPStatsByColo `json:"httpStatsByColo"` - // The interval at which the HTTP synthetic application test is set to run. - Interval string `json:"interval"` - Kind ZeroTrustDexhttpTestGetResponseKind `json:"kind"` - // The HTTP method to use when running the test - Method string `json:"method"` - // The name of the HTTP synthetic application test - Name string `json:"name"` - JSON zeroTrustDexhttpTestGetResponseJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDexhttpTestGetResponse] -type zeroTrustDexhttpTestGetResponseJSON struct { - Host apijson.Field - HTTPStats apijson.Field - HTTPStatsByColo apijson.Field - Interval apijson.Field - Kind apijson.Field - Method apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseHTTPStats struct { - DNSResponseTimeMs ZeroTrustDexhttpTestGetResponseHTTPStatsDNSResponseTimeMs `json:"dnsResponseTimeMs,required"` - HTTPStatusCode []ZeroTrustDexhttpTestGetResponseHTTPStatsHTTPStatusCode `json:"httpStatusCode,required"` - ResourceFetchTimeMs ZeroTrustDexhttpTestGetResponseHTTPStatsResourceFetchTimeMs `json:"resourceFetchTimeMs,required"` - ServerResponseTimeMs ZeroTrustDexhttpTestGetResponseHTTPStatsServerResponseTimeMs `json:"serverResponseTimeMs,required"` - // Count of unique devices that have run this test in the given time period - UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` - JSON zeroTrustDexhttpTestGetResponseHTTPStatsJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseHTTPStatsJSON contains the JSON metadata for the -// struct [ZeroTrustDexhttpTestGetResponseHTTPStats] -type zeroTrustDexhttpTestGetResponseHTTPStatsJSON struct { - DNSResponseTimeMs apijson.Field - HTTPStatusCode apijson.Field - ResourceFetchTimeMs apijson.Field - ServerResponseTimeMs apijson.Field - UniqueDevicesTotal apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseHTTPStats) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseHTTPStatsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseHTTPStatsDNSResponseTimeMs struct { - Slots []ZeroTrustDexhttpTestGetResponseHTTPStatsDNSResponseTimeMsSlot `json:"slots,required"` - // average observed in the time period - Avg int64 `json:"avg,nullable"` - // highest observed in the time period - Max int64 `json:"max,nullable"` - // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON zeroTrustDexhttpTestGetResponseHTTPStatsDNSResponseTimeMsJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseHTTPStatsDNSResponseTimeMsJSON contains the JSON -// metadata for the struct -// [ZeroTrustDexhttpTestGetResponseHTTPStatsDNSResponseTimeMs] -type zeroTrustDexhttpTestGetResponseHTTPStatsDNSResponseTimeMsJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseHTTPStatsDNSResponseTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseHTTPStatsDNSResponseTimeMsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseHTTPStatsDNSResponseTimeMsSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDexhttpTestGetResponseHTTPStatsDNSResponseTimeMsSlotJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseHTTPStatsDNSResponseTimeMsSlotJSON contains the -// JSON metadata for the struct -// [ZeroTrustDexhttpTestGetResponseHTTPStatsDNSResponseTimeMsSlot] -type zeroTrustDexhttpTestGetResponseHTTPStatsDNSResponseTimeMsSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseHTTPStatsDNSResponseTimeMsSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseHTTPStatsDNSResponseTimeMsSlotJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseHTTPStatsHTTPStatusCode struct { - Status200 int64 `json:"status200,required"` - Status300 int64 `json:"status300,required"` - Status400 int64 `json:"status400,required"` - Status500 int64 `json:"status500,required"` - Timestamp string `json:"timestamp,required"` - JSON zeroTrustDexhttpTestGetResponseHTTPStatsHTTPStatusCodeJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseHTTPStatsHTTPStatusCodeJSON contains the JSON -// metadata for the struct [ZeroTrustDexhttpTestGetResponseHTTPStatsHTTPStatusCode] -type zeroTrustDexhttpTestGetResponseHTTPStatsHTTPStatusCodeJSON struct { - Status200 apijson.Field - Status300 apijson.Field - Status400 apijson.Field - Status500 apijson.Field - Timestamp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseHTTPStatsHTTPStatusCode) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseHTTPStatsHTTPStatusCodeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseHTTPStatsResourceFetchTimeMs struct { - Slots []ZeroTrustDexhttpTestGetResponseHTTPStatsResourceFetchTimeMsSlot `json:"slots,required"` - // average observed in the time period - Avg int64 `json:"avg,nullable"` - // highest observed in the time period - Max int64 `json:"max,nullable"` - // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON zeroTrustDexhttpTestGetResponseHTTPStatsResourceFetchTimeMsJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseHTTPStatsResourceFetchTimeMsJSON contains the -// JSON metadata for the struct -// [ZeroTrustDexhttpTestGetResponseHTTPStatsResourceFetchTimeMs] -type zeroTrustDexhttpTestGetResponseHTTPStatsResourceFetchTimeMsJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseHTTPStatsResourceFetchTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseHTTPStatsResourceFetchTimeMsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseHTTPStatsResourceFetchTimeMsSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDexhttpTestGetResponseHTTPStatsResourceFetchTimeMsSlotJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseHTTPStatsResourceFetchTimeMsSlotJSON contains the -// JSON metadata for the struct -// [ZeroTrustDexhttpTestGetResponseHTTPStatsResourceFetchTimeMsSlot] -type zeroTrustDexhttpTestGetResponseHTTPStatsResourceFetchTimeMsSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseHTTPStatsResourceFetchTimeMsSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseHTTPStatsResourceFetchTimeMsSlotJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseHTTPStatsServerResponseTimeMs struct { - Slots []ZeroTrustDexhttpTestGetResponseHTTPStatsServerResponseTimeMsSlot `json:"slots,required"` - // average observed in the time period - Avg int64 `json:"avg,nullable"` - // highest observed in the time period - Max int64 `json:"max,nullable"` - // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON zeroTrustDexhttpTestGetResponseHTTPStatsServerResponseTimeMsJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseHTTPStatsServerResponseTimeMsJSON contains the -// JSON metadata for the struct -// [ZeroTrustDexhttpTestGetResponseHTTPStatsServerResponseTimeMs] -type zeroTrustDexhttpTestGetResponseHTTPStatsServerResponseTimeMsJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseHTTPStatsServerResponseTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseHTTPStatsServerResponseTimeMsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseHTTPStatsServerResponseTimeMsSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDexhttpTestGetResponseHTTPStatsServerResponseTimeMsSlotJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseHTTPStatsServerResponseTimeMsSlotJSON contains -// the JSON metadata for the struct -// [ZeroTrustDexhttpTestGetResponseHTTPStatsServerResponseTimeMsSlot] -type zeroTrustDexhttpTestGetResponseHTTPStatsServerResponseTimeMsSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseHTTPStatsServerResponseTimeMsSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseHTTPStatsServerResponseTimeMsSlotJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseHTTPStatsByColo struct { - Colo string `json:"colo,required"` - DNSResponseTimeMs ZeroTrustDexhttpTestGetResponseHTTPStatsByColoDNSResponseTimeMs `json:"dnsResponseTimeMs,required"` - HTTPStatusCode []ZeroTrustDexhttpTestGetResponseHTTPStatsByColoHTTPStatusCode `json:"httpStatusCode,required"` - ResourceFetchTimeMs ZeroTrustDexhttpTestGetResponseHTTPStatsByColoResourceFetchTimeMs `json:"resourceFetchTimeMs,required"` - ServerResponseTimeMs ZeroTrustDexhttpTestGetResponseHTTPStatsByColoServerResponseTimeMs `json:"serverResponseTimeMs,required"` - // Count of unique devices that have run this test in the given time period - UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` - JSON zeroTrustDexhttpTestGetResponseHTTPStatsByColoJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseHTTPStatsByColoJSON contains the JSON metadata -// for the struct [ZeroTrustDexhttpTestGetResponseHTTPStatsByColo] -type zeroTrustDexhttpTestGetResponseHTTPStatsByColoJSON struct { - Colo apijson.Field - DNSResponseTimeMs apijson.Field - HTTPStatusCode apijson.Field - ResourceFetchTimeMs apijson.Field - ServerResponseTimeMs apijson.Field - UniqueDevicesTotal apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseHTTPStatsByColo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseHTTPStatsByColoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseHTTPStatsByColoDNSResponseTimeMs struct { - Slots []ZeroTrustDexhttpTestGetResponseHTTPStatsByColoDNSResponseTimeMsSlot `json:"slots,required"` - // average observed in the time period - Avg int64 `json:"avg,nullable"` - // highest observed in the time period - Max int64 `json:"max,nullable"` - // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON zeroTrustDexhttpTestGetResponseHTTPStatsByColoDNSResponseTimeMsJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseHTTPStatsByColoDNSResponseTimeMsJSON contains the -// JSON metadata for the struct -// [ZeroTrustDexhttpTestGetResponseHTTPStatsByColoDNSResponseTimeMs] -type zeroTrustDexhttpTestGetResponseHTTPStatsByColoDNSResponseTimeMsJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseHTTPStatsByColoDNSResponseTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseHTTPStatsByColoDNSResponseTimeMsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseHTTPStatsByColoDNSResponseTimeMsSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDexhttpTestGetResponseHTTPStatsByColoDNSResponseTimeMsSlotJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseHTTPStatsByColoDNSResponseTimeMsSlotJSON contains -// the JSON metadata for the struct -// [ZeroTrustDexhttpTestGetResponseHTTPStatsByColoDNSResponseTimeMsSlot] -type zeroTrustDexhttpTestGetResponseHTTPStatsByColoDNSResponseTimeMsSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseHTTPStatsByColoDNSResponseTimeMsSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseHTTPStatsByColoDNSResponseTimeMsSlotJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseHTTPStatsByColoHTTPStatusCode struct { - Status200 int64 `json:"status200,required"` - Status300 int64 `json:"status300,required"` - Status400 int64 `json:"status400,required"` - Status500 int64 `json:"status500,required"` - Timestamp string `json:"timestamp,required"` - JSON zeroTrustDexhttpTestGetResponseHTTPStatsByColoHTTPStatusCodeJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseHTTPStatsByColoHTTPStatusCodeJSON contains the -// JSON metadata for the struct -// [ZeroTrustDexhttpTestGetResponseHTTPStatsByColoHTTPStatusCode] -type zeroTrustDexhttpTestGetResponseHTTPStatsByColoHTTPStatusCodeJSON struct { - Status200 apijson.Field - Status300 apijson.Field - Status400 apijson.Field - Status500 apijson.Field - Timestamp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseHTTPStatsByColoHTTPStatusCode) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseHTTPStatsByColoHTTPStatusCodeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseHTTPStatsByColoResourceFetchTimeMs struct { - Slots []ZeroTrustDexhttpTestGetResponseHTTPStatsByColoResourceFetchTimeMsSlot `json:"slots,required"` - // average observed in the time period - Avg int64 `json:"avg,nullable"` - // highest observed in the time period - Max int64 `json:"max,nullable"` - // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON zeroTrustDexhttpTestGetResponseHTTPStatsByColoResourceFetchTimeMsJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseHTTPStatsByColoResourceFetchTimeMsJSON contains -// the JSON metadata for the struct -// [ZeroTrustDexhttpTestGetResponseHTTPStatsByColoResourceFetchTimeMs] -type zeroTrustDexhttpTestGetResponseHTTPStatsByColoResourceFetchTimeMsJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseHTTPStatsByColoResourceFetchTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseHTTPStatsByColoResourceFetchTimeMsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseHTTPStatsByColoResourceFetchTimeMsSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDexhttpTestGetResponseHTTPStatsByColoResourceFetchTimeMsSlotJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseHTTPStatsByColoResourceFetchTimeMsSlotJSON -// contains the JSON metadata for the struct -// [ZeroTrustDexhttpTestGetResponseHTTPStatsByColoResourceFetchTimeMsSlot] -type zeroTrustDexhttpTestGetResponseHTTPStatsByColoResourceFetchTimeMsSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseHTTPStatsByColoResourceFetchTimeMsSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseHTTPStatsByColoResourceFetchTimeMsSlotJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseHTTPStatsByColoServerResponseTimeMs struct { - Slots []ZeroTrustDexhttpTestGetResponseHTTPStatsByColoServerResponseTimeMsSlot `json:"slots,required"` - // average observed in the time period - Avg int64 `json:"avg,nullable"` - // highest observed in the time period - Max int64 `json:"max,nullable"` - // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON zeroTrustDexhttpTestGetResponseHTTPStatsByColoServerResponseTimeMsJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseHTTPStatsByColoServerResponseTimeMsJSON contains -// the JSON metadata for the struct -// [ZeroTrustDexhttpTestGetResponseHTTPStatsByColoServerResponseTimeMs] -type zeroTrustDexhttpTestGetResponseHTTPStatsByColoServerResponseTimeMsJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseHTTPStatsByColoServerResponseTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseHTTPStatsByColoServerResponseTimeMsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseHTTPStatsByColoServerResponseTimeMsSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDexhttpTestGetResponseHTTPStatsByColoServerResponseTimeMsSlotJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseHTTPStatsByColoServerResponseTimeMsSlotJSON -// contains the JSON metadata for the struct -// [ZeroTrustDexhttpTestGetResponseHTTPStatsByColoServerResponseTimeMsSlot] -type zeroTrustDexhttpTestGetResponseHTTPStatsByColoServerResponseTimeMsSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseHTTPStatsByColoServerResponseTimeMsSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseHTTPStatsByColoServerResponseTimeMsSlotJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseKind string - -const ( - ZeroTrustDexhttpTestGetResponseKindHTTP ZeroTrustDexhttpTestGetResponseKind = "http" -) - -type ZeroTrustDEXHTTPTestGetParams struct { - AccountID param.Field[string] `path:"account_id,required"` - // Time interval for aggregate time slots. - Interval param.Field[ZeroTrustDexhttpTestGetParamsInterval] `query:"interval,required"` - // End time for aggregate metrics in ISO ms - TimeEnd param.Field[string] `query:"timeEnd,required"` - // Start time for aggregate metrics in ISO ms - TimeStart param.Field[string] `query:"timeStart,required"` - // Optionally filter result stats to a Cloudflare colo. Cannot be used in - // combination with deviceId param. - Colo param.Field[string] `query:"colo"` - // Optionally filter result stats to a specific device(s). Cannot be used in - // combination with colo param. - DeviceID param.Field[[]string] `query:"deviceId"` -} - -// URLQuery serializes [ZeroTrustDEXHTTPTestGetParams]'s query parameters as -// `url.Values`. -func (r ZeroTrustDEXHTTPTestGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Time interval for aggregate time slots. -type ZeroTrustDexhttpTestGetParamsInterval string - -const ( - ZeroTrustDexhttpTestGetParamsIntervalMinute ZeroTrustDexhttpTestGetParamsInterval = "minute" - ZeroTrustDexhttpTestGetParamsIntervalHour ZeroTrustDexhttpTestGetParamsInterval = "hour" -) - -type ZeroTrustDexhttpTestGetResponseEnvelope struct { - Errors []ZeroTrustDexhttpTestGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDexhttpTestGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDexhttpTestGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustDexhttpTestGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDexhttpTestGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDexhttpTestGetResponseEnvelope] -type zeroTrustDexhttpTestGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDexhttpTestGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustDexhttpTestGetResponseEnvelopeErrors] -type zeroTrustDexhttpTestGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDexhttpTestGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDexhttpTestGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDexhttpTestGetResponseEnvelopeMessages] -type zeroTrustDexhttpTestGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDexhttpTestGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustDexhttpTestGetResponseEnvelopeSuccessTrue ZeroTrustDexhttpTestGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustdexhttptest_test.go b/zerotrustdexhttptest_test.go deleted file mode 100644 index ba4b69b045a..00000000000 --- a/zerotrustdexhttptest_test.go +++ /dev/null @@ -1,49 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDEXHTTPTestGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.DEX.HTTPTests.Get( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDEXHTTPTestGetParams{ - AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), - Interval: cloudflare.F(cloudflare.ZeroTrustDexhttpTestGetParamsIntervalMinute), - TimeEnd: cloudflare.F("string"), - TimeStart: cloudflare.F("string"), - Colo: cloudflare.F("string"), - DeviceID: cloudflare.F([]string{"string", "string", "string"}), - }, - ) - 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/zerotrustdexhttptestpercentile.go b/zerotrustdexhttptestpercentile.go deleted file mode 100644 index aea36cff0ae..00000000000 --- a/zerotrustdexhttptestpercentile.go +++ /dev/null @@ -1,275 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDEXHTTPTestPercentileService 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 -// [NewZeroTrustDEXHTTPTestPercentileService] method instead. -type ZeroTrustDEXHTTPTestPercentileService struct { - Options []option.RequestOption -} - -// NewZeroTrustDEXHTTPTestPercentileService 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 NewZeroTrustDEXHTTPTestPercentileService(opts ...option.RequestOption) (r *ZeroTrustDEXHTTPTestPercentileService) { - r = &ZeroTrustDEXHTTPTestPercentileService{} - r.Options = opts - return -} - -// Get percentiles for an http test for a given time period between 1 hour and 7 -// days. -func (r *ZeroTrustDEXHTTPTestPercentileService) List(ctx context.Context, testID string, params ZeroTrustDEXHTTPTestPercentileListParams, opts ...option.RequestOption) (res *ZeroTrustDexhttpTestPercentileListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDexhttpTestPercentileListResponseEnvelope - path := fmt.Sprintf("accounts/%s/dex/http-tests/%s/percentiles", params.AccountID, testID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDexhttpTestPercentileListResponse struct { - DNSResponseTimeMs ZeroTrustDexhttpTestPercentileListResponseDNSResponseTimeMs `json:"dnsResponseTimeMs"` - ResourceFetchTimeMs ZeroTrustDexhttpTestPercentileListResponseResourceFetchTimeMs `json:"resourceFetchTimeMs"` - ServerResponseTimeMs ZeroTrustDexhttpTestPercentileListResponseServerResponseTimeMs `json:"serverResponseTimeMs"` - JSON zeroTrustDexhttpTestPercentileListResponseJSON `json:"-"` -} - -// zeroTrustDexhttpTestPercentileListResponseJSON contains the JSON metadata for -// the struct [ZeroTrustDexhttpTestPercentileListResponse] -type zeroTrustDexhttpTestPercentileListResponseJSON struct { - DNSResponseTimeMs apijson.Field - ResourceFetchTimeMs apijson.Field - ServerResponseTimeMs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestPercentileListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestPercentileListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestPercentileListResponseDNSResponseTimeMs struct { - // p50 observed in the time period - P50 float64 `json:"p50,nullable"` - // p90 observed in the time period - P90 float64 `json:"p90,nullable"` - // p95 observed in the time period - P95 float64 `json:"p95,nullable"` - // p99 observed in the time period - P99 float64 `json:"p99,nullable"` - JSON zeroTrustDexhttpTestPercentileListResponseDNSResponseTimeMsJSON `json:"-"` -} - -// zeroTrustDexhttpTestPercentileListResponseDNSResponseTimeMsJSON contains the -// JSON metadata for the struct -// [ZeroTrustDexhttpTestPercentileListResponseDNSResponseTimeMs] -type zeroTrustDexhttpTestPercentileListResponseDNSResponseTimeMsJSON struct { - P50 apijson.Field - P90 apijson.Field - P95 apijson.Field - P99 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestPercentileListResponseDNSResponseTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestPercentileListResponseDNSResponseTimeMsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestPercentileListResponseResourceFetchTimeMs struct { - // p50 observed in the time period - P50 float64 `json:"p50,nullable"` - // p90 observed in the time period - P90 float64 `json:"p90,nullable"` - // p95 observed in the time period - P95 float64 `json:"p95,nullable"` - // p99 observed in the time period - P99 float64 `json:"p99,nullable"` - JSON zeroTrustDexhttpTestPercentileListResponseResourceFetchTimeMsJSON `json:"-"` -} - -// zeroTrustDexhttpTestPercentileListResponseResourceFetchTimeMsJSON contains the -// JSON metadata for the struct -// [ZeroTrustDexhttpTestPercentileListResponseResourceFetchTimeMs] -type zeroTrustDexhttpTestPercentileListResponseResourceFetchTimeMsJSON struct { - P50 apijson.Field - P90 apijson.Field - P95 apijson.Field - P99 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestPercentileListResponseResourceFetchTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestPercentileListResponseResourceFetchTimeMsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestPercentileListResponseServerResponseTimeMs struct { - // p50 observed in the time period - P50 float64 `json:"p50,nullable"` - // p90 observed in the time period - P90 float64 `json:"p90,nullable"` - // p95 observed in the time period - P95 float64 `json:"p95,nullable"` - // p99 observed in the time period - P99 float64 `json:"p99,nullable"` - JSON zeroTrustDexhttpTestPercentileListResponseServerResponseTimeMsJSON `json:"-"` -} - -// zeroTrustDexhttpTestPercentileListResponseServerResponseTimeMsJSON contains the -// JSON metadata for the struct -// [ZeroTrustDexhttpTestPercentileListResponseServerResponseTimeMs] -type zeroTrustDexhttpTestPercentileListResponseServerResponseTimeMsJSON struct { - P50 apijson.Field - P90 apijson.Field - P95 apijson.Field - P99 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestPercentileListResponseServerResponseTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestPercentileListResponseServerResponseTimeMsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXHTTPTestPercentileListParams struct { - AccountID param.Field[string] `path:"account_id,required"` - // End time for aggregate metrics in ISO format - TimeEnd param.Field[string] `query:"timeEnd,required"` - // Start time for aggregate metrics in ISO format - TimeStart param.Field[string] `query:"timeStart,required"` - // Optionally filter result stats to a Cloudflare colo. Cannot be used in - // combination with deviceId param. - Colo param.Field[string] `query:"colo"` - // Optionally filter result stats to a specific device(s). Cannot be used in - // combination with colo param. - DeviceID param.Field[[]string] `query:"deviceId"` -} - -// URLQuery serializes [ZeroTrustDEXHTTPTestPercentileListParams]'s query -// parameters as `url.Values`. -func (r ZeroTrustDEXHTTPTestPercentileListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type ZeroTrustDexhttpTestPercentileListResponseEnvelope struct { - Errors []ZeroTrustDexhttpTestPercentileListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDexhttpTestPercentileListResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDexhttpTestPercentileListResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustDexhttpTestPercentileListResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDexhttpTestPercentileListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDexhttpTestPercentileListResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustDexhttpTestPercentileListResponseEnvelope] -type zeroTrustDexhttpTestPercentileListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestPercentileListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestPercentileListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestPercentileListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDexhttpTestPercentileListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDexhttpTestPercentileListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustDexhttpTestPercentileListResponseEnvelopeErrors] -type zeroTrustDexhttpTestPercentileListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestPercentileListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestPercentileListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDexhttpTestPercentileListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDexhttpTestPercentileListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDexhttpTestPercentileListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustDexhttpTestPercentileListResponseEnvelopeMessages] -type zeroTrustDexhttpTestPercentileListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDexhttpTestPercentileListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDexhttpTestPercentileListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDexhttpTestPercentileListResponseEnvelopeSuccess bool - -const ( - ZeroTrustDexhttpTestPercentileListResponseEnvelopeSuccessTrue ZeroTrustDexhttpTestPercentileListResponseEnvelopeSuccess = true -) diff --git a/zerotrustdexhttptestpercentile_test.go b/zerotrustdexhttptestpercentile_test.go deleted file mode 100644 index 65fe811bbf5..00000000000 --- a/zerotrustdexhttptestpercentile_test.go +++ /dev/null @@ -1,48 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDEXHTTPTestPercentileListWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.DEX.HTTPTests.Percentiles.List( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDEXHTTPTestPercentileListParams{ - AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), - TimeEnd: cloudflare.F("2023-09-20T17:00:00Z"), - TimeStart: cloudflare.F("2023-09-20T17:00:00Z"), - Colo: cloudflare.F("string"), - DeviceID: cloudflare.F([]string{"string", "string", "string"}), - }, - ) - 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/zerotrustdextest.go b/zerotrustdextest.go deleted file mode 100644 index f032995b530..00000000000 --- a/zerotrustdextest.go +++ /dev/null @@ -1,1061 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDEXTestService 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 [NewZeroTrustDEXTestService] method -// instead. -type ZeroTrustDEXTestService struct { - Options []option.RequestOption - UniqueDevices *ZeroTrustDEXTestUniqueDeviceService -} - -// NewZeroTrustDEXTestService 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 NewZeroTrustDEXTestService(opts ...option.RequestOption) (r *ZeroTrustDEXTestService) { - r = &ZeroTrustDEXTestService{} - r.Options = opts - r.UniqueDevices = NewZeroTrustDEXTestUniqueDeviceService(opts...) - return -} - -// List DEX tests -func (r *ZeroTrustDEXTestService) List(ctx context.Context, params ZeroTrustDEXTestListParams, opts ...option.RequestOption) (res *shared.V4PagePagination[ZeroTrustDEXTestListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("accounts/%s/dex/tests", params.AccountID) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// List DEX tests -func (r *ZeroTrustDEXTestService) ListAutoPaging(ctx context.Context, params ZeroTrustDEXTestListParams, opts ...option.RequestOption) *shared.V4PagePaginationAutoPager[ZeroTrustDEXTestListResponse] { - return shared.NewV4PagePaginationAutoPager(r.List(ctx, params, opts...)) -} - -type ZeroTrustDEXTestListResponse struct { - Errors []ZeroTrustDEXTestListResponseError `json:"errors,required"` - Messages []ZeroTrustDEXTestListResponseMessage `json:"messages,required"` - Result ZeroTrustDEXTestListResponseResult `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustDEXTestListResponseSuccess `json:"success,required"` - ResultInfo ZeroTrustDEXTestListResponseResultInfo `json:"result_info"` - JSON zeroTrustDEXTestListResponseJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponse] -type zeroTrustDEXTestListResponseJSON 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 *ZeroTrustDEXTestListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseError struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDEXTestListResponseErrorJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseErrorJSON contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseError] -type zeroTrustDEXTestListResponseErrorJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseErrorJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseMessage struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDEXTestListResponseMessageJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseMessageJSON contains the JSON metadata for the -// struct [ZeroTrustDEXTestListResponseMessage] -type zeroTrustDEXTestListResponseMessageJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseMessage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseMessageJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResult struct { - OverviewMetrics ZeroTrustDEXTestListResponseResultOverviewMetrics `json:"overviewMetrics,required"` - // array of test results objects. - Tests []ZeroTrustDEXTestListResponseResultTest `json:"tests,required"` - JSON zeroTrustDEXTestListResponseResultJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultJSON contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResult] -type zeroTrustDEXTestListResponseResultJSON struct { - OverviewMetrics apijson.Field - Tests apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResult) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultOverviewMetrics struct { - // number of tests. - TestsTotal int64 `json:"testsTotal,required"` - // percentage availability for all traceroutes results in response - AvgTracerouteAvailabilityPct float64 `json:"avgTracerouteAvailabilityPct,nullable"` - JSON zeroTrustDEXTestListResponseResultOverviewMetricsJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultOverviewMetricsJSON contains the JSON metadata -// for the struct [ZeroTrustDEXTestListResponseResultOverviewMetrics] -type zeroTrustDEXTestListResponseResultOverviewMetricsJSON struct { - TestsTotal apijson.Field - AvgTracerouteAvailabilityPct apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultOverviewMetrics) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultOverviewMetricsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTest struct { - // API Resource UUID tag. - ID string `json:"id,required"` - // date the test was created. - Created string `json:"created,required"` - // the test description defined during configuration - Description string `json:"description,required"` - // if true, then the test will run on targeted devices. Else, the test will not - // run. - Enabled bool `json:"enabled,required"` - Host string `json:"host,required"` - // The interval at which the synthetic application test is set to run. - Interval string `json:"interval,required"` - // test type, http or traceroute - Kind ZeroTrustDEXTestListResponseResultTestsKind `json:"kind,required"` - // name given to this test - Name string `json:"name,required"` - Updated string `json:"updated,required"` - HTTPResults ZeroTrustDEXTestListResponseResultTestsHTTPResults `json:"httpResults,nullable"` - HTTPResultsByColo []ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColo `json:"httpResultsByColo"` - // for HTTP, the method to use when running the test - Method string `json:"method"` - TracerouteResults ZeroTrustDEXTestListResponseResultTestsTracerouteResults `json:"tracerouteResults,nullable"` - TracerouteResultsByColo []ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColo `json:"tracerouteResultsByColo"` - JSON zeroTrustDEXTestListResponseResultTestJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestJSON contains the JSON metadata for the -// struct [ZeroTrustDEXTestListResponseResultTest] -type zeroTrustDEXTestListResponseResultTestJSON struct { - ID apijson.Field - Created apijson.Field - Description apijson.Field - Enabled apijson.Field - Host apijson.Field - Interval apijson.Field - Kind apijson.Field - Name apijson.Field - Updated apijson.Field - HTTPResults apijson.Field - HTTPResultsByColo apijson.Field - Method apijson.Field - TracerouteResults apijson.Field - TracerouteResultsByColo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTest) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestJSON) RawJSON() string { - return r.raw -} - -// test type, http or traceroute -type ZeroTrustDEXTestListResponseResultTestsKind string - -const ( - ZeroTrustDEXTestListResponseResultTestsKindHTTP ZeroTrustDEXTestListResponseResultTestsKind = "http" - ZeroTrustDEXTestListResponseResultTestsKindTraceroute ZeroTrustDEXTestListResponseResultTestsKind = "traceroute" -) - -type ZeroTrustDEXTestListResponseResultTestsHTTPResults struct { - ResourceFetchTime ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTime `json:"resourceFetchTime,required"` - JSON zeroTrustDEXTestListResponseResultTestsHTTPResultsJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsHTTPResultsJSON contains the JSON -// metadata for the struct [ZeroTrustDEXTestListResponseResultTestsHTTPResults] -type zeroTrustDEXTestListResponseResultTestsHTTPResultsJSON struct { - ResourceFetchTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsHTTPResults) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsHTTPResultsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTime struct { - History []ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistory `json:"history,required"` - AvgMs int64 `json:"avgMs,nullable"` - OverTime ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTime `json:"overTime,nullable"` - JSON zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeJSON contains -// the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTime] -type zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeJSON struct { - History apijson.Field - AvgMs apijson.Field - OverTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTime) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistory struct { - TimePeriod ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryTimePeriod `json:"timePeriod,required"` - AvgMs int64 `json:"avgMs,nullable"` - DeltaPct float64 `json:"deltaPct,nullable"` - JSON zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistory] -type zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryJSON struct { - TimePeriod apijson.Field - AvgMs apijson.Field - DeltaPct apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryTimePeriod struct { - Units ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnits `json:"units,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryTimePeriodJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryTimePeriodJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryTimePeriod] -type zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryTimePeriodJSON struct { - Units apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryTimePeriod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryTimePeriodJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnits string - -const ( - ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnitsHours ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnits = "hours" - ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnitsDays ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnits = "days" - ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnitsTestRuns ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeHistoryTimePeriodUnits = "testRuns" -) - -type ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTime struct { - TimePeriod ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeTimePeriod `json:"timePeriod,required"` - Values []ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeValue `json:"values,required"` - JSON zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTime] -type zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeJSON struct { - TimePeriod apijson.Field - Values apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTime) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeTimePeriod struct { - Units ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnits `json:"units,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeTimePeriod] -type zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodJSON struct { - Units apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeTimePeriod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnits string - -const ( - ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnitsHours ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnits = "hours" - ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnitsDays ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnits = "days" - ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnitsTestRuns ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeTimePeriodUnits = "testRuns" -) - -type ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeValue struct { - AvgMs int64 `json:"avgMs,required"` - Timestamp string `json:"timestamp,required"` - JSON zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeValueJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeValueJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeValue] -type zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeValueJSON struct { - AvgMs apijson.Field - Timestamp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsHTTPResultsResourceFetchTimeOverTimeValueJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColo struct { - // Cloudflare colo - Colo string `json:"colo,required"` - ResourceFetchTime ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTime `json:"resourceFetchTime,required"` - JSON zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoJSON contains the JSON -// metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColo] -type zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoJSON struct { - Colo apijson.Field - ResourceFetchTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTime struct { - History []ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistory `json:"history,required"` - AvgMs int64 `json:"avgMs,nullable"` - OverTime ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTime `json:"overTime,nullable"` - JSON zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTime] -type zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeJSON struct { - History apijson.Field - AvgMs apijson.Field - OverTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTime) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistory struct { - TimePeriod ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriod `json:"timePeriod,required"` - AvgMs int64 `json:"avgMs,nullable"` - DeltaPct float64 `json:"deltaPct,nullable"` - JSON zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistory] -type zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryJSON struct { - TimePeriod apijson.Field - AvgMs apijson.Field - DeltaPct apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriod struct { - Units ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnits `json:"units,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriod] -type zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodJSON struct { - Units apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnits string - -const ( - ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnitsHours ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnits = "hours" - ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnitsDays ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnits = "days" - ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnitsTestRuns ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeHistoryTimePeriodUnits = "testRuns" -) - -type ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTime struct { - TimePeriod ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriod `json:"timePeriod,required"` - Values []ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeValue `json:"values,required"` - JSON zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTime] -type zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeJSON struct { - TimePeriod apijson.Field - Values apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTime) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriod struct { - Units ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnits `json:"units,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriod] -type zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodJSON struct { - Units apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnits string - -const ( - ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnitsHours ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnits = "hours" - ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnitsDays ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnits = "days" - ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnitsTestRuns ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeTimePeriodUnits = "testRuns" -) - -type ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeValue struct { - AvgMs int64 `json:"avgMs,required"` - Timestamp string `json:"timestamp,required"` - JSON zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeValueJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeValueJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeValue] -type zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeValueJSON struct { - AvgMs apijson.Field - Timestamp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsHTTPResultsByColoResourceFetchTimeOverTimeValueJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsTracerouteResults struct { - RoundTripTime ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTime `json:"roundTripTime,required"` - JSON zeroTrustDEXTestListResponseResultTestsTracerouteResultsJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsTracerouteResultsJSON contains the JSON -// metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsTracerouteResults] -type zeroTrustDEXTestListResponseResultTestsTracerouteResultsJSON struct { - RoundTripTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsTracerouteResults) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsTracerouteResultsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTime struct { - History []ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistory `json:"history,required"` - AvgMs int64 `json:"avgMs,nullable"` - OverTime ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTime `json:"overTime,nullable"` - JSON zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTime] -type zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeJSON struct { - History apijson.Field - AvgMs apijson.Field - OverTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTime) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistory struct { - TimePeriod ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryTimePeriod `json:"timePeriod,required"` - AvgMs int64 `json:"avgMs,nullable"` - DeltaPct float64 `json:"deltaPct,nullable"` - JSON zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistory] -type zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryJSON struct { - TimePeriod apijson.Field - AvgMs apijson.Field - DeltaPct apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryTimePeriod struct { - Units ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnits `json:"units,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryTimePeriodJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryTimePeriodJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryTimePeriod] -type zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryTimePeriodJSON struct { - Units apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryTimePeriod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryTimePeriodJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnits string - -const ( - ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnitsHours ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnits = "hours" - ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnitsDays ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnits = "days" - ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnitsTestRuns ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeHistoryTimePeriodUnits = "testRuns" -) - -type ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTime struct { - TimePeriod ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeTimePeriod `json:"timePeriod,required"` - Values []ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeValue `json:"values,required"` - JSON zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTime] -type zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeJSON struct { - TimePeriod apijson.Field - Values apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTime) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeTimePeriod struct { - Units ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnits `json:"units,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeTimePeriod] -type zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodJSON struct { - Units apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeTimePeriod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnits string - -const ( - ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnitsHours ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnits = "hours" - ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnitsDays ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnits = "days" - ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnitsTestRuns ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeTimePeriodUnits = "testRuns" -) - -type ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeValue struct { - AvgMs int64 `json:"avgMs,required"` - Timestamp string `json:"timestamp,required"` - JSON zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeValueJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeValueJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeValue] -type zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeValueJSON struct { - AvgMs apijson.Field - Timestamp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsTracerouteResultsRoundTripTimeOverTimeValueJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColo struct { - // Cloudflare colo - Colo string `json:"colo,required"` - RoundTripTime ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTime `json:"roundTripTime,required"` - JSON zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoJSON contains the -// JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColo] -type zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoJSON struct { - Colo apijson.Field - RoundTripTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTime struct { - History []ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistory `json:"history,required"` - AvgMs int64 `json:"avgMs,nullable"` - OverTime ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTime `json:"overTime,nullable"` - JSON zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTime] -type zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeJSON struct { - History apijson.Field - AvgMs apijson.Field - OverTime apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTime) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistory struct { - TimePeriod ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriod `json:"timePeriod,required"` - AvgMs int64 `json:"avgMs,nullable"` - DeltaPct float64 `json:"deltaPct,nullable"` - JSON zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistory] -type zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryJSON struct { - TimePeriod apijson.Field - AvgMs apijson.Field - DeltaPct apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriod struct { - Units ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnits `json:"units,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriod] -type zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodJSON struct { - Units apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnits string - -const ( - ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnitsHours ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnits = "hours" - ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnitsDays ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnits = "days" - ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnitsTestRuns ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeHistoryTimePeriodUnits = "testRuns" -) - -type ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTime struct { - TimePeriod ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriod `json:"timePeriod,required"` - Values []ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeValue `json:"values,required"` - JSON zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTime] -type zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeJSON struct { - TimePeriod apijson.Field - Values apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTime) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriod struct { - Units ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnits `json:"units,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriod] -type zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodJSON struct { - Units apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriod) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnits string - -const ( - ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnitsHours ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnits = "hours" - ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnitsDays ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnits = "days" - ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnitsTestRuns ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeTimePeriodUnits = "testRuns" -) - -type ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeValue struct { - AvgMs int64 `json:"avgMs,required"` - Timestamp string `json:"timestamp,required"` - JSON zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeValueJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeValueJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeValue] -type zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeValueJSON struct { - AvgMs apijson.Field - Timestamp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultTestsTracerouteResultsByColoRoundTripTimeOverTimeValueJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDEXTestListResponseSuccess bool - -const ( - ZeroTrustDEXTestListResponseSuccessTrue ZeroTrustDEXTestListResponseSuccess = true -) - -type ZeroTrustDEXTestListResponseResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDEXTestListResponseResultInfoJSON `json:"-"` -} - -// zeroTrustDEXTestListResponseResultInfoJSON contains the JSON metadata for the -// struct [ZeroTrustDEXTestListResponseResultInfo] -type zeroTrustDEXTestListResponseResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestListResponseResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestListResponseResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestListParams struct { - AccountID param.Field[string] `path:"account_id,required"` - // Optionally filter result stats to a Cloudflare colo. Cannot be used in - // combination with deviceId param. - Colo param.Field[string] `query:"colo"` - // Optionally filter result stats to a specific device(s). Cannot be used in - // combination with colo param. - DeviceID param.Field[[]string] `query:"deviceId"` - // Page number of paginated results - Page param.Field[float64] `query:"page"` - // Number of items per page - PerPage param.Field[float64] `query:"per_page"` - // Optionally filter results by test name - TestName param.Field[string] `query:"testName"` -} - -// URLQuery serializes [ZeroTrustDEXTestListParams]'s query parameters as -// `url.Values`. -func (r ZeroTrustDEXTestListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} diff --git a/zerotrustdextest_test.go b/zerotrustdextest_test.go deleted file mode 100644 index 4c4916e981a..00000000000 --- a/zerotrustdextest_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDEXTestListWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.DEX.Tests.List(context.TODO(), cloudflare.ZeroTrustDEXTestListParams{ - AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), - Colo: cloudflare.F("string"), - DeviceID: cloudflare.F([]string{"string", "string", "string"}), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(1.000000), - TestName: cloudflare.F("string"), - }) - 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/zerotrustdextestuniquedevice.go b/zerotrustdextestuniquedevice.go deleted file mode 100644 index 53d86af82a4..00000000000 --- a/zerotrustdextestuniquedevice.go +++ /dev/null @@ -1,170 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDEXTestUniqueDeviceService 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 -// [NewZeroTrustDEXTestUniqueDeviceService] method instead. -type ZeroTrustDEXTestUniqueDeviceService struct { - Options []option.RequestOption -} - -// NewZeroTrustDEXTestUniqueDeviceService 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 NewZeroTrustDEXTestUniqueDeviceService(opts ...option.RequestOption) (r *ZeroTrustDEXTestUniqueDeviceService) { - r = &ZeroTrustDEXTestUniqueDeviceService{} - r.Options = opts - return -} - -// Returns unique count of devices that have run synthetic application monitoring -// tests in the past 7 days. -func (r *ZeroTrustDEXTestUniqueDeviceService) List(ctx context.Context, params ZeroTrustDEXTestUniqueDeviceListParams, opts ...option.RequestOption) (res *ZeroTrustDEXTestUniqueDeviceListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDEXTestUniqueDeviceListResponseEnvelope - path := fmt.Sprintf("accounts/%s/dex/tests/unique-devices", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDEXTestUniqueDeviceListResponse struct { - // total number of unique devices - UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` - JSON zeroTrustDEXTestUniqueDeviceListResponseJSON `json:"-"` -} - -// zeroTrustDEXTestUniqueDeviceListResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDEXTestUniqueDeviceListResponse] -type zeroTrustDEXTestUniqueDeviceListResponseJSON struct { - UniqueDevicesTotal apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestUniqueDeviceListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestUniqueDeviceListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestUniqueDeviceListParams struct { - AccountID param.Field[string] `path:"account_id,required"` - // Optionally filter result stats to a specific device(s). Cannot be used in - // combination with colo param. - DeviceID param.Field[[]string] `query:"deviceId"` - // Optionally filter results by test name - TestName param.Field[string] `query:"testName"` -} - -// URLQuery serializes [ZeroTrustDEXTestUniqueDeviceListParams]'s query parameters -// as `url.Values`. -func (r ZeroTrustDEXTestUniqueDeviceListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type ZeroTrustDEXTestUniqueDeviceListResponseEnvelope struct { - Errors []ZeroTrustDEXTestUniqueDeviceListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDEXTestUniqueDeviceListResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDEXTestUniqueDeviceListResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustDEXTestUniqueDeviceListResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDEXTestUniqueDeviceListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDEXTestUniqueDeviceListResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustDEXTestUniqueDeviceListResponseEnvelope] -type zeroTrustDEXTestUniqueDeviceListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestUniqueDeviceListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestUniqueDeviceListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestUniqueDeviceListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDEXTestUniqueDeviceListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDEXTestUniqueDeviceListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDEXTestUniqueDeviceListResponseEnvelopeErrors] -type zeroTrustDEXTestUniqueDeviceListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestUniqueDeviceListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestUniqueDeviceListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTestUniqueDeviceListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDEXTestUniqueDeviceListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDEXTestUniqueDeviceListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustDEXTestUniqueDeviceListResponseEnvelopeMessages] -type zeroTrustDEXTestUniqueDeviceListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTestUniqueDeviceListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTestUniqueDeviceListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDEXTestUniqueDeviceListResponseEnvelopeSuccess bool - -const ( - ZeroTrustDEXTestUniqueDeviceListResponseEnvelopeSuccessTrue ZeroTrustDEXTestUniqueDeviceListResponseEnvelopeSuccess = true -) diff --git a/zerotrustdextestuniquedevice_test.go b/zerotrustdextestuniquedevice_test.go deleted file mode 100644 index fdb31950053..00000000000 --- a/zerotrustdextestuniquedevice_test.go +++ /dev/null @@ -1,42 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDEXTestUniqueDeviceListWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.DEX.Tests.UniqueDevices.List(context.TODO(), cloudflare.ZeroTrustDEXTestUniqueDeviceListParams{ - AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), - DeviceID: cloudflare.F([]string{"string", "string", "string"}), - TestName: cloudflare.F("string"), - }) - 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/zerotrustdextraceroutetest.go b/zerotrustdextraceroutetest.go deleted file mode 100644 index a39f566eefd..00000000000 --- a/zerotrustdextraceroutetest.go +++ /dev/null @@ -1,1209 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDEXTracerouteTestService 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 -// [NewZeroTrustDEXTracerouteTestService] method instead. -type ZeroTrustDEXTracerouteTestService struct { - Options []option.RequestOption -} - -// NewZeroTrustDEXTracerouteTestService 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 NewZeroTrustDEXTracerouteTestService(opts ...option.RequestOption) (r *ZeroTrustDEXTracerouteTestService) { - r = &ZeroTrustDEXTracerouteTestService{} - r.Options = opts - return -} - -// Get test details and aggregate performance metrics for an traceroute test for a -// given time period between 1 hour and 7 days. -func (r *ZeroTrustDEXTracerouteTestService) Get(ctx context.Context, testID string, params ZeroTrustDEXTracerouteTestGetParams, opts ...option.RequestOption) (res *ZeroTrustDEXTracerouteTestGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDEXTracerouteTestGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/dex/traceroute-tests/%s", params.AccountID, testID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get a breakdown of metrics by hop for individual traceroute test runs -func (r *ZeroTrustDEXTracerouteTestService) NetworkPath(ctx context.Context, testID string, params ZeroTrustDEXTracerouteTestNetworkPathParams, opts ...option.RequestOption) (res *ZeroTrustDEXTracerouteTestNetworkPathResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDEXTracerouteTestNetworkPathResponseEnvelope - path := fmt.Sprintf("accounts/%s/dex/traceroute-tests/%s/network-path", params.AccountID, testID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get percentiles for a traceroute test for a given time period between 1 hour and -// 7 days. -func (r *ZeroTrustDEXTracerouteTestService) Percentiles(ctx context.Context, testID string, params ZeroTrustDEXTracerouteTestPercentilesParams, opts ...option.RequestOption) (res *ZeroTrustDEXTracerouteTestPercentilesResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDEXTracerouteTestPercentilesResponseEnvelope - path := fmt.Sprintf("accounts/%s/dex/traceroute-tests/%s/percentiles", params.AccountID, testID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDEXTracerouteTestGetResponse struct { - // The host of the Traceroute synthetic application test - Host string `json:"host,required"` - // The interval at which the Traceroute synthetic application test is set to run. - Interval string `json:"interval,required"` - Kind ZeroTrustDEXTracerouteTestGetResponseKind `json:"kind,required"` - // The name of the Traceroute synthetic application test - Name string `json:"name,required"` - TracerouteStats ZeroTrustDEXTracerouteTestGetResponseTracerouteStats `json:"tracerouteStats,nullable"` - TracerouteStatsByColo []ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColo `json:"tracerouteStatsByColo"` - JSON zeroTrustDEXTracerouteTestGetResponseJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDEXTracerouteTestGetResponse] -type zeroTrustDEXTracerouteTestGetResponseJSON struct { - Host apijson.Field - Interval apijson.Field - Kind apijson.Field - Name apijson.Field - TracerouteStats apijson.Field - TracerouteStatsByColo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseKind string - -const ( - ZeroTrustDEXTracerouteTestGetResponseKindTraceroute ZeroTrustDEXTracerouteTestGetResponseKind = "traceroute" -) - -type ZeroTrustDEXTracerouteTestGetResponseTracerouteStats struct { - AvailabilityPct ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsAvailabilityPct `json:"availabilityPct,required"` - HopsCount ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsHopsCount `json:"hopsCount,required"` - PacketLossPct ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsPacketLossPct `json:"packetLossPct,required"` - RoundTripTimeMs ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsRoundTripTimeMs `json:"roundTripTimeMs,required"` - // Count of unique devices that have run this test in the given time period - UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` - JSON zeroTrustDEXTracerouteTestGetResponseTracerouteStatsJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseTracerouteStatsJSON contains the JSON -// metadata for the struct [ZeroTrustDEXTracerouteTestGetResponseTracerouteStats] -type zeroTrustDEXTracerouteTestGetResponseTracerouteStatsJSON struct { - AvailabilityPct apijson.Field - HopsCount apijson.Field - PacketLossPct apijson.Field - RoundTripTimeMs apijson.Field - UniqueDevicesTotal apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseTracerouteStats) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseTracerouteStatsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsAvailabilityPct struct { - Slots []ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsAvailabilityPctSlot `json:"slots,required"` - // average observed in the time period - Avg float64 `json:"avg,nullable"` - // highest observed in the time period - Max float64 `json:"max,nullable"` - // lowest observed in the time period - Min float64 `json:"min,nullable"` - JSON zeroTrustDEXTracerouteTestGetResponseTracerouteStatsAvailabilityPctJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseTracerouteStatsAvailabilityPctJSON contains -// the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsAvailabilityPct] -type zeroTrustDEXTracerouteTestGetResponseTracerouteStatsAvailabilityPctJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsAvailabilityPct) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseTracerouteStatsAvailabilityPctJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsAvailabilityPctSlot struct { - Timestamp string `json:"timestamp,required"` - Value float64 `json:"value,required"` - JSON zeroTrustDEXTracerouteTestGetResponseTracerouteStatsAvailabilityPctSlotJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseTracerouteStatsAvailabilityPctSlotJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsAvailabilityPctSlot] -type zeroTrustDEXTracerouteTestGetResponseTracerouteStatsAvailabilityPctSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsAvailabilityPctSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseTracerouteStatsAvailabilityPctSlotJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsHopsCount struct { - Slots []ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsHopsCountSlot `json:"slots,required"` - // average observed in the time period - Avg int64 `json:"avg,nullable"` - // highest observed in the time period - Max int64 `json:"max,nullable"` - // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON zeroTrustDEXTracerouteTestGetResponseTracerouteStatsHopsCountJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseTracerouteStatsHopsCountJSON contains the -// JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsHopsCount] -type zeroTrustDEXTracerouteTestGetResponseTracerouteStatsHopsCountJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsHopsCount) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseTracerouteStatsHopsCountJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsHopsCountSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDEXTracerouteTestGetResponseTracerouteStatsHopsCountSlotJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseTracerouteStatsHopsCountSlotJSON contains -// the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsHopsCountSlot] -type zeroTrustDEXTracerouteTestGetResponseTracerouteStatsHopsCountSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsHopsCountSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseTracerouteStatsHopsCountSlotJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsPacketLossPct struct { - Slots []ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsPacketLossPctSlot `json:"slots,required"` - // average observed in the time period - Avg float64 `json:"avg,nullable"` - // highest observed in the time period - Max float64 `json:"max,nullable"` - // lowest observed in the time period - Min float64 `json:"min,nullable"` - JSON zeroTrustDEXTracerouteTestGetResponseTracerouteStatsPacketLossPctJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseTracerouteStatsPacketLossPctJSON contains -// the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsPacketLossPct] -type zeroTrustDEXTracerouteTestGetResponseTracerouteStatsPacketLossPctJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsPacketLossPct) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseTracerouteStatsPacketLossPctJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsPacketLossPctSlot struct { - Timestamp string `json:"timestamp,required"` - Value float64 `json:"value,required"` - JSON zeroTrustDEXTracerouteTestGetResponseTracerouteStatsPacketLossPctSlotJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseTracerouteStatsPacketLossPctSlotJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsPacketLossPctSlot] -type zeroTrustDEXTracerouteTestGetResponseTracerouteStatsPacketLossPctSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsPacketLossPctSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseTracerouteStatsPacketLossPctSlotJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsRoundTripTimeMs struct { - Slots []ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsRoundTripTimeMsSlot `json:"slots,required"` - // average observed in the time period - Avg int64 `json:"avg,nullable"` - // highest observed in the time period - Max int64 `json:"max,nullable"` - // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON zeroTrustDEXTracerouteTestGetResponseTracerouteStatsRoundTripTimeMsJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseTracerouteStatsRoundTripTimeMsJSON contains -// the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsRoundTripTimeMs] -type zeroTrustDEXTracerouteTestGetResponseTracerouteStatsRoundTripTimeMsJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsRoundTripTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseTracerouteStatsRoundTripTimeMsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsRoundTripTimeMsSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDEXTracerouteTestGetResponseTracerouteStatsRoundTripTimeMsSlotJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseTracerouteStatsRoundTripTimeMsSlotJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsRoundTripTimeMsSlot] -type zeroTrustDEXTracerouteTestGetResponseTracerouteStatsRoundTripTimeMsSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsRoundTripTimeMsSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseTracerouteStatsRoundTripTimeMsSlotJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColo struct { - AvailabilityPct ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoAvailabilityPct `json:"availabilityPct,required"` - Colo string `json:"colo,required"` - HopsCount ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoHopsCount `json:"hopsCount,required"` - PacketLossPct ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoPacketLossPct `json:"packetLossPct,required"` - RoundTripTimeMs ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoRoundTripTimeMs `json:"roundTripTimeMs,required"` - // Count of unique devices that have run this test in the given time period - UniqueDevicesTotal int64 `json:"uniqueDevicesTotal,required"` - JSON zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoJSON contains the JSON -// metadata for the struct -// [ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColo] -type zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoJSON struct { - AvailabilityPct apijson.Field - Colo apijson.Field - HopsCount apijson.Field - PacketLossPct apijson.Field - RoundTripTimeMs apijson.Field - UniqueDevicesTotal apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoAvailabilityPct struct { - Slots []ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoAvailabilityPctSlot `json:"slots,required"` - // average observed in the time period - Avg float64 `json:"avg,nullable"` - // highest observed in the time period - Max float64 `json:"max,nullable"` - // lowest observed in the time period - Min float64 `json:"min,nullable"` - JSON zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoAvailabilityPctJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoAvailabilityPctJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoAvailabilityPct] -type zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoAvailabilityPctJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoAvailabilityPct) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoAvailabilityPctJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoAvailabilityPctSlot struct { - Timestamp string `json:"timestamp,required"` - Value float64 `json:"value,required"` - JSON zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoAvailabilityPctSlotJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoAvailabilityPctSlotJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoAvailabilityPctSlot] -type zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoAvailabilityPctSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoAvailabilityPctSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoAvailabilityPctSlotJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoHopsCount struct { - Slots []ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoHopsCountSlot `json:"slots,required"` - // average observed in the time period - Avg int64 `json:"avg,nullable"` - // highest observed in the time period - Max int64 `json:"max,nullable"` - // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoHopsCountJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoHopsCountJSON contains -// the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoHopsCount] -type zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoHopsCountJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoHopsCount) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoHopsCountJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoHopsCountSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoHopsCountSlotJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoHopsCountSlotJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoHopsCountSlot] -type zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoHopsCountSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoHopsCountSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoHopsCountSlotJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoPacketLossPct struct { - Slots []ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoPacketLossPctSlot `json:"slots,required"` - // average observed in the time period - Avg float64 `json:"avg,nullable"` - // highest observed in the time period - Max float64 `json:"max,nullable"` - // lowest observed in the time period - Min float64 `json:"min,nullable"` - JSON zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoPacketLossPctJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoPacketLossPctJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoPacketLossPct] -type zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoPacketLossPctJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoPacketLossPct) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoPacketLossPctJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoPacketLossPctSlot struct { - Timestamp string `json:"timestamp,required"` - Value float64 `json:"value,required"` - JSON zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoPacketLossPctSlotJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoPacketLossPctSlotJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoPacketLossPctSlot] -type zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoPacketLossPctSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoPacketLossPctSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoPacketLossPctSlotJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoRoundTripTimeMs struct { - Slots []ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoRoundTripTimeMsSlot `json:"slots,required"` - // average observed in the time period - Avg int64 `json:"avg,nullable"` - // highest observed in the time period - Max int64 `json:"max,nullable"` - // lowest observed in the time period - Min int64 `json:"min,nullable"` - JSON zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoRoundTripTimeMsJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoRoundTripTimeMsJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoRoundTripTimeMs] -type zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoRoundTripTimeMsJSON struct { - Slots apijson.Field - Avg apijson.Field - Max apijson.Field - Min apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoRoundTripTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoRoundTripTimeMsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoRoundTripTimeMsSlot struct { - Timestamp string `json:"timestamp,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoRoundTripTimeMsSlotJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoRoundTripTimeMsSlotJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoRoundTripTimeMsSlot] -type zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoRoundTripTimeMsSlotJSON struct { - Timestamp apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoRoundTripTimeMsSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseTracerouteStatsByColoRoundTripTimeMsSlotJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestNetworkPathResponse struct { - // API Resource UUID tag. - ID string `json:"id,required"` - DeviceName string `json:"deviceName"` - // The interval at which the Traceroute synthetic application test is set to run. - Interval string `json:"interval"` - Kind ZeroTrustDEXTracerouteTestNetworkPathResponseKind `json:"kind"` - Name string `json:"name"` - NetworkPath ZeroTrustDEXTracerouteTestNetworkPathResponseNetworkPath `json:"networkPath,nullable"` - // The host of the Traceroute synthetic application test - URL string `json:"url"` - JSON zeroTrustDEXTracerouteTestNetworkPathResponseJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestNetworkPathResponseJSON contains the JSON metadata for -// the struct [ZeroTrustDEXTracerouteTestNetworkPathResponse] -type zeroTrustDEXTracerouteTestNetworkPathResponseJSON struct { - ID apijson.Field - DeviceName apijson.Field - Interval apijson.Field - Kind apijson.Field - Name apijson.Field - NetworkPath apijson.Field - URL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestNetworkPathResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestNetworkPathResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestNetworkPathResponseKind string - -const ( - ZeroTrustDEXTracerouteTestNetworkPathResponseKindTraceroute ZeroTrustDEXTracerouteTestNetworkPathResponseKind = "traceroute" -) - -type ZeroTrustDEXTracerouteTestNetworkPathResponseNetworkPath struct { - Slots []ZeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSlot `json:"slots,required"` - // Specifies the sampling applied, if any, to the slots response. When sampled, - // results shown represent the first test run to the start of each sampling - // interval. - Sampling ZeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSampling `json:"sampling,nullable"` - JSON zeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathJSON contains the JSON -// metadata for the struct -// [ZeroTrustDEXTracerouteTestNetworkPathResponseNetworkPath] -type zeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathJSON struct { - Slots apijson.Field - Sampling apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestNetworkPathResponseNetworkPath) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSlot struct { - // API Resource UUID tag. - ID string `json:"id,required"` - // Round trip time in ms of the client to app mile - ClientToAppRTTMs int64 `json:"clientToAppRttMs,required,nullable"` - // Round trip time in ms of the client to Cloudflare egress mile - ClientToCfEgressRTTMs int64 `json:"clientToCfEgressRttMs,required,nullable"` - // Round trip time in ms of the client to Cloudflare ingress mile - ClientToCfIngressRTTMs int64 `json:"clientToCfIngressRttMs,required,nullable"` - Timestamp string `json:"timestamp,required"` - // Round trip time in ms of the client to ISP mile - ClientToIspRTTMs int64 `json:"clientToIspRttMs,nullable"` - JSON zeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSlotJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSlotJSON contains the -// JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSlot] -type zeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSlotJSON struct { - ID apijson.Field - ClientToAppRTTMs apijson.Field - ClientToCfEgressRTTMs apijson.Field - ClientToCfIngressRTTMs apijson.Field - Timestamp apijson.Field - ClientToIspRTTMs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSlot) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSlotJSON) RawJSON() string { - return r.raw -} - -// Specifies the sampling applied, if any, to the slots response. When sampled, -// results shown represent the first test run to the start of each sampling -// interval. -type ZeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSampling struct { - Unit ZeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSamplingUnit `json:"unit,required"` - Value int64 `json:"value,required"` - JSON zeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSamplingJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSamplingJSON contains -// the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSampling] -type zeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSamplingJSON struct { - Unit apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSampling) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSamplingJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSamplingUnit string - -const ( - ZeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSamplingUnitHours ZeroTrustDEXTracerouteTestNetworkPathResponseNetworkPathSamplingUnit = "hours" -) - -type ZeroTrustDEXTracerouteTestPercentilesResponse struct { - HopsCount ZeroTrustDEXTracerouteTestPercentilesResponseHopsCount `json:"hopsCount"` - PacketLossPct ZeroTrustDEXTracerouteTestPercentilesResponsePacketLossPct `json:"packetLossPct"` - RoundTripTimeMs ZeroTrustDEXTracerouteTestPercentilesResponseRoundTripTimeMs `json:"roundTripTimeMs"` - JSON zeroTrustDEXTracerouteTestPercentilesResponseJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestPercentilesResponseJSON contains the JSON metadata for -// the struct [ZeroTrustDEXTracerouteTestPercentilesResponse] -type zeroTrustDEXTracerouteTestPercentilesResponseJSON struct { - HopsCount apijson.Field - PacketLossPct apijson.Field - RoundTripTimeMs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestPercentilesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestPercentilesResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestPercentilesResponseHopsCount struct { - // p50 observed in the time period - P50 float64 `json:"p50,nullable"` - // p90 observed in the time period - P90 float64 `json:"p90,nullable"` - // p95 observed in the time period - P95 float64 `json:"p95,nullable"` - // p99 observed in the time period - P99 float64 `json:"p99,nullable"` - JSON zeroTrustDEXTracerouteTestPercentilesResponseHopsCountJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestPercentilesResponseHopsCountJSON contains the JSON -// metadata for the struct [ZeroTrustDEXTracerouteTestPercentilesResponseHopsCount] -type zeroTrustDEXTracerouteTestPercentilesResponseHopsCountJSON struct { - P50 apijson.Field - P90 apijson.Field - P95 apijson.Field - P99 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestPercentilesResponseHopsCount) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestPercentilesResponseHopsCountJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestPercentilesResponsePacketLossPct struct { - // p50 observed in the time period - P50 float64 `json:"p50,nullable"` - // p90 observed in the time period - P90 float64 `json:"p90,nullable"` - // p95 observed in the time period - P95 float64 `json:"p95,nullable"` - // p99 observed in the time period - P99 float64 `json:"p99,nullable"` - JSON zeroTrustDEXTracerouteTestPercentilesResponsePacketLossPctJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestPercentilesResponsePacketLossPctJSON contains the JSON -// metadata for the struct -// [ZeroTrustDEXTracerouteTestPercentilesResponsePacketLossPct] -type zeroTrustDEXTracerouteTestPercentilesResponsePacketLossPctJSON struct { - P50 apijson.Field - P90 apijson.Field - P95 apijson.Field - P99 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestPercentilesResponsePacketLossPct) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestPercentilesResponsePacketLossPctJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestPercentilesResponseRoundTripTimeMs struct { - // p50 observed in the time period - P50 float64 `json:"p50,nullable"` - // p90 observed in the time period - P90 float64 `json:"p90,nullable"` - // p95 observed in the time period - P95 float64 `json:"p95,nullable"` - // p99 observed in the time period - P99 float64 `json:"p99,nullable"` - JSON zeroTrustDEXTracerouteTestPercentilesResponseRoundTripTimeMsJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestPercentilesResponseRoundTripTimeMsJSON contains the -// JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestPercentilesResponseRoundTripTimeMs] -type zeroTrustDEXTracerouteTestPercentilesResponseRoundTripTimeMsJSON struct { - P50 apijson.Field - P90 apijson.Field - P95 apijson.Field - P99 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestPercentilesResponseRoundTripTimeMs) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestPercentilesResponseRoundTripTimeMsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetParams struct { - AccountID param.Field[string] `path:"account_id,required"` - // Time interval for aggregate time slots. - Interval param.Field[ZeroTrustDEXTracerouteTestGetParamsInterval] `query:"interval,required"` - // End time for aggregate metrics in ISO ms - TimeEnd param.Field[string] `query:"timeEnd,required"` - // Start time for aggregate metrics in ISO ms - TimeStart param.Field[string] `query:"timeStart,required"` - // Optionally filter result stats to a Cloudflare colo. Cannot be used in - // combination with deviceId param. - Colo param.Field[string] `query:"colo"` - // Optionally filter result stats to a specific device(s). Cannot be used in - // combination with colo param. - DeviceID param.Field[[]string] `query:"deviceId"` -} - -// URLQuery serializes [ZeroTrustDEXTracerouteTestGetParams]'s query parameters as -// `url.Values`. -func (r ZeroTrustDEXTracerouteTestGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Time interval for aggregate time slots. -type ZeroTrustDEXTracerouteTestGetParamsInterval string - -const ( - ZeroTrustDEXTracerouteTestGetParamsIntervalMinute ZeroTrustDEXTracerouteTestGetParamsInterval = "minute" - ZeroTrustDEXTracerouteTestGetParamsIntervalHour ZeroTrustDEXTracerouteTestGetParamsInterval = "hour" -) - -type ZeroTrustDEXTracerouteTestGetResponseEnvelope struct { - Errors []ZeroTrustDEXTracerouteTestGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDEXTracerouteTestGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDEXTracerouteTestGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustDEXTracerouteTestGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDEXTracerouteTestGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDEXTracerouteTestGetResponseEnvelope] -type zeroTrustDEXTracerouteTestGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDEXTracerouteTestGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDEXTracerouteTestGetResponseEnvelopeErrors] -type zeroTrustDEXTracerouteTestGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDEXTracerouteTestGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDEXTracerouteTestGetResponseEnvelopeMessages] -type zeroTrustDEXTracerouteTestGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDEXTracerouteTestGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustDEXTracerouteTestGetResponseEnvelopeSuccessTrue ZeroTrustDEXTracerouteTestGetResponseEnvelopeSuccess = true -) - -type ZeroTrustDEXTracerouteTestNetworkPathParams struct { - AccountID param.Field[string] `path:"account_id,required"` - // Device to filter tracroute result runs to - DeviceID param.Field[string] `query:"deviceId,required"` - // Time interval for aggregate time slots. - Interval param.Field[ZeroTrustDEXTracerouteTestNetworkPathParamsInterval] `query:"interval,required"` - // End time for aggregate metrics in ISO ms - TimeEnd param.Field[string] `query:"timeEnd,required"` - // Start time for aggregate metrics in ISO ms - TimeStart param.Field[string] `query:"timeStart,required"` -} - -// URLQuery serializes [ZeroTrustDEXTracerouteTestNetworkPathParams]'s query -// parameters as `url.Values`. -func (r ZeroTrustDEXTracerouteTestNetworkPathParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// Time interval for aggregate time slots. -type ZeroTrustDEXTracerouteTestNetworkPathParamsInterval string - -const ( - ZeroTrustDEXTracerouteTestNetworkPathParamsIntervalMinute ZeroTrustDEXTracerouteTestNetworkPathParamsInterval = "minute" - ZeroTrustDEXTracerouteTestNetworkPathParamsIntervalHour ZeroTrustDEXTracerouteTestNetworkPathParamsInterval = "hour" -) - -type ZeroTrustDEXTracerouteTestNetworkPathResponseEnvelope struct { - Errors []ZeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDEXTracerouteTestNetworkPathResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustDEXTracerouteTestNetworkPathResponseEnvelope] -type zeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestNetworkPathResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeErrors] -type zeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeMessages] -type zeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeSuccess bool - -const ( - ZeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeSuccessTrue ZeroTrustDEXTracerouteTestNetworkPathResponseEnvelopeSuccess = true -) - -type ZeroTrustDEXTracerouteTestPercentilesParams struct { - AccountID param.Field[string] `path:"account_id,required"` - // End time for aggregate metrics in ISO format - TimeEnd param.Field[string] `query:"timeEnd,required"` - // Start time for aggregate metrics in ISO format - TimeStart param.Field[string] `query:"timeStart,required"` - // Optionally filter result stats to a Cloudflare colo. Cannot be used in - // combination with deviceId param. - Colo param.Field[string] `query:"colo"` - // Optionally filter result stats to a specific device(s). Cannot be used in - // combination with colo param. - DeviceID param.Field[[]string] `query:"deviceId"` -} - -// URLQuery serializes [ZeroTrustDEXTracerouteTestPercentilesParams]'s query -// parameters as `url.Values`. -func (r ZeroTrustDEXTracerouteTestPercentilesParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type ZeroTrustDEXTracerouteTestPercentilesResponseEnvelope struct { - Errors []ZeroTrustDEXTracerouteTestPercentilesResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDEXTracerouteTestPercentilesResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDEXTracerouteTestPercentilesResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustDEXTracerouteTestPercentilesResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDEXTracerouteTestPercentilesResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestPercentilesResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustDEXTracerouteTestPercentilesResponseEnvelope] -type zeroTrustDEXTracerouteTestPercentilesResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestPercentilesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestPercentilesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestPercentilesResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDEXTracerouteTestPercentilesResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestPercentilesResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestPercentilesResponseEnvelopeErrors] -type zeroTrustDEXTracerouteTestPercentilesResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestPercentilesResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestPercentilesResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestPercentilesResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDEXTracerouteTestPercentilesResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestPercentilesResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestPercentilesResponseEnvelopeMessages] -type zeroTrustDEXTracerouteTestPercentilesResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestPercentilesResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestPercentilesResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDEXTracerouteTestPercentilesResponseEnvelopeSuccess bool - -const ( - ZeroTrustDEXTracerouteTestPercentilesResponseEnvelopeSuccessTrue ZeroTrustDEXTracerouteTestPercentilesResponseEnvelopeSuccess = true -) diff --git a/zerotrustdextraceroutetest_test.go b/zerotrustdextraceroutetest_test.go deleted file mode 100644 index 049832864a6..00000000000 --- a/zerotrustdextraceroutetest_test.go +++ /dev/null @@ -1,117 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDEXTracerouteTestGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.DEX.TracerouteTests.Get( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDEXTracerouteTestGetParams{ - AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), - Interval: cloudflare.F(cloudflare.ZeroTrustDEXTracerouteTestGetParamsIntervalMinute), - TimeEnd: cloudflare.F("string"), - TimeStart: cloudflare.F("string"), - Colo: cloudflare.F("string"), - DeviceID: cloudflare.F([]string{"string", "string", "string"}), - }, - ) - 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 TestZeroTrustDEXTracerouteTestNetworkPath(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("user@example.com"), - ) - _, err := client.ZeroTrust.DEX.TracerouteTests.NetworkPath( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDEXTracerouteTestNetworkPathParams{ - AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), - DeviceID: cloudflare.F("string"), - Interval: cloudflare.F(cloudflare.ZeroTrustDEXTracerouteTestNetworkPathParamsIntervalMinute), - TimeEnd: cloudflare.F("string"), - TimeStart: cloudflare.F("string"), - }, - ) - 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 TestZeroTrustDEXTracerouteTestPercentilesWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.DEX.TracerouteTests.Percentiles( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDEXTracerouteTestPercentilesParams{ - AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), - TimeEnd: cloudflare.F("2023-09-20T17:00:00Z"), - TimeStart: cloudflare.F("2023-09-20T17:00:00Z"), - Colo: cloudflare.F("string"), - DeviceID: cloudflare.F([]string{"string", "string", "string"}), - }, - ) - 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/zerotrustdextraceroutetestresult.go b/zerotrustdextraceroutetestresult.go deleted file mode 100644 index 0db3f2aeb88..00000000000 --- a/zerotrustdextraceroutetestresult.go +++ /dev/null @@ -1,27 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDEXTracerouteTestResultService 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 -// [NewZeroTrustDEXTracerouteTestResultService] method instead. -type ZeroTrustDEXTracerouteTestResultService struct { - Options []option.RequestOption - NetworkPath *ZeroTrustDEXTracerouteTestResultNetworkPathService -} - -// NewZeroTrustDEXTracerouteTestResultService 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 NewZeroTrustDEXTracerouteTestResultService(opts ...option.RequestOption) (r *ZeroTrustDEXTracerouteTestResultService) { - r = &ZeroTrustDEXTracerouteTestResultService{} - r.Options = opts - r.NetworkPath = NewZeroTrustDEXTracerouteTestResultNetworkPathService(opts...) - return -} diff --git a/zerotrustdextraceroutetestresultnetworkpath.go b/zerotrustdextraceroutetestresultnetworkpath.go deleted file mode 100644 index 3f80c407452..00000000000 --- a/zerotrustdextraceroutetestresultnetworkpath.go +++ /dev/null @@ -1,246 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDEXTracerouteTestResultNetworkPathService 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 [NewZeroTrustDEXTracerouteTestResultNetworkPathService] method instead. -type ZeroTrustDEXTracerouteTestResultNetworkPathService struct { - Options []option.RequestOption -} - -// NewZeroTrustDEXTracerouteTestResultNetworkPathService 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 NewZeroTrustDEXTracerouteTestResultNetworkPathService(opts ...option.RequestOption) (r *ZeroTrustDEXTracerouteTestResultNetworkPathService) { - r = &ZeroTrustDEXTracerouteTestResultNetworkPathService{} - r.Options = opts - return -} - -// Get a breakdown of hops and performance metrics for a specific traceroute test -// run -func (r *ZeroTrustDEXTracerouteTestResultNetworkPathService) List(ctx context.Context, testResultID string, query ZeroTrustDEXTracerouteTestResultNetworkPathListParams, opts ...option.RequestOption) (res *ZeroTrustDEXTracerouteTestResultNetworkPathListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelope - path := fmt.Sprintf("accounts/%s/dex/traceroute-test-results/%s/network-path", query.AccountID, testResultID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDEXTracerouteTestResultNetworkPathListResponse struct { - // an array of the hops taken by the device to reach the end destination - Hops []ZeroTrustDEXTracerouteTestResultNetworkPathListResponseHop `json:"hops,required"` - // API Resource UUID tag. - ResultID string `json:"resultId,required"` - // date time of this traceroute test - TimeStart string `json:"time_start,required"` - // name of the device associated with this network path response - DeviceName string `json:"deviceName"` - // API Resource UUID tag. - TestID string `json:"testId"` - // name of the tracroute test - TestName string `json:"testName"` - JSON zeroTrustDEXTracerouteTestResultNetworkPathListResponseJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestResultNetworkPathListResponseJSON contains the JSON -// metadata for the struct -// [ZeroTrustDEXTracerouteTestResultNetworkPathListResponse] -type zeroTrustDEXTracerouteTestResultNetworkPathListResponseJSON struct { - Hops apijson.Field - ResultID apijson.Field - TimeStart apijson.Field - DeviceName apijson.Field - TestID apijson.Field - TestName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestResultNetworkPathListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestResultNetworkPathListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestResultNetworkPathListResponseHop struct { - TTL int64 `json:"ttl,required"` - ASN int64 `json:"asn,nullable"` - Aso string `json:"aso,nullable"` - IPAddress string `json:"ipAddress,nullable"` - Location ZeroTrustDEXTracerouteTestResultNetworkPathListResponseHopsLocation `json:"location,nullable"` - Mile ZeroTrustDEXTracerouteTestResultNetworkPathListResponseHopsMile `json:"mile,nullable"` - Name string `json:"name,nullable"` - PacketLossPct float64 `json:"packetLossPct,nullable"` - RTTMs int64 `json:"rttMs,nullable"` - JSON zeroTrustDEXTracerouteTestResultNetworkPathListResponseHopJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestResultNetworkPathListResponseHopJSON contains the JSON -// metadata for the struct -// [ZeroTrustDEXTracerouteTestResultNetworkPathListResponseHop] -type zeroTrustDEXTracerouteTestResultNetworkPathListResponseHopJSON struct { - TTL apijson.Field - ASN apijson.Field - Aso apijson.Field - IPAddress apijson.Field - Location apijson.Field - Mile apijson.Field - Name apijson.Field - PacketLossPct apijson.Field - RTTMs apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestResultNetworkPathListResponseHop) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestResultNetworkPathListResponseHopJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestResultNetworkPathListResponseHopsLocation struct { - City string `json:"city,nullable"` - State string `json:"state,nullable"` - Zip string `json:"zip,nullable"` - JSON zeroTrustDEXTracerouteTestResultNetworkPathListResponseHopsLocationJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestResultNetworkPathListResponseHopsLocationJSON contains -// the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestResultNetworkPathListResponseHopsLocation] -type zeroTrustDEXTracerouteTestResultNetworkPathListResponseHopsLocationJSON struct { - City apijson.Field - State apijson.Field - Zip apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestResultNetworkPathListResponseHopsLocation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestResultNetworkPathListResponseHopsLocationJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestResultNetworkPathListResponseHopsMile string - -const ( - ZeroTrustDEXTracerouteTestResultNetworkPathListResponseHopsMileClientToApp ZeroTrustDEXTracerouteTestResultNetworkPathListResponseHopsMile = "client-to-app" - ZeroTrustDEXTracerouteTestResultNetworkPathListResponseHopsMileClientToCfEgress ZeroTrustDEXTracerouteTestResultNetworkPathListResponseHopsMile = "client-to-cf-egress" - ZeroTrustDEXTracerouteTestResultNetworkPathListResponseHopsMileClientToCfIngress ZeroTrustDEXTracerouteTestResultNetworkPathListResponseHopsMile = "client-to-cf-ingress" - ZeroTrustDEXTracerouteTestResultNetworkPathListResponseHopsMileClientToIsp ZeroTrustDEXTracerouteTestResultNetworkPathListResponseHopsMile = "client-to-isp" -) - -type ZeroTrustDEXTracerouteTestResultNetworkPathListParams struct { - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelope struct { - Errors []ZeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDEXTracerouteTestResultNetworkPathListResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeJSON contains the -// JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelope] -type zeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeErrorsJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeErrors] -type zeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [ZeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeMessages] -type zeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeSuccess bool - -const ( - ZeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeSuccessTrue ZeroTrustDEXTracerouteTestResultNetworkPathListResponseEnvelopeSuccess = true -) diff --git a/zerotrustdextraceroutetestresultnetworkpath_test.go b/zerotrustdextraceroutetestresultnetworkpath_test.go deleted file mode 100644 index 5b6c982502b..00000000000 --- a/zerotrustdextraceroutetestresultnetworkpath_test.go +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDEXTracerouteTestResultNetworkPathList(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("user@example.com"), - ) - _, err := client.ZeroTrust.DEX.TracerouteTestResults.NetworkPath.List( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustDEXTracerouteTestResultNetworkPathListParams{ - AccountID: cloudflare.F("01a7362d577a6c3019a474fd6f485823"), - }, - ) - 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/zerotrustdlp.go b/zerotrustdlp.go deleted file mode 100644 index 745d0e98806..00000000000 --- a/zerotrustdlp.go +++ /dev/null @@ -1,33 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDLPService 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 [NewZeroTrustDLPService] method -// instead. -type ZeroTrustDLPService struct { - Options []option.RequestOption - Datasets *ZeroTrustDLPDatasetService - Patterns *ZeroTrustDLPPatternService - PayloadLogs *ZeroTrustDLPPayloadLogService - Profiles *ZeroTrustDLPProfileService -} - -// NewZeroTrustDLPService 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 NewZeroTrustDLPService(opts ...option.RequestOption) (r *ZeroTrustDLPService) { - r = &ZeroTrustDLPService{} - r.Options = opts - r.Datasets = NewZeroTrustDLPDatasetService(opts...) - r.Patterns = NewZeroTrustDLPPatternService(opts...) - r.PayloadLogs = NewZeroTrustDLPPayloadLogService(opts...) - r.Profiles = NewZeroTrustDLPProfileService(opts...) - return -} diff --git a/zerotrustdlpdataset.go b/zerotrustdlpdataset.go deleted file mode 100644 index a642eace3fe..00000000000 --- a/zerotrustdlpdataset.go +++ /dev/null @@ -1,909 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDLPDatasetService 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 [NewZeroTrustDLPDatasetService] -// method instead. -type ZeroTrustDLPDatasetService struct { - Options []option.RequestOption - Upload *ZeroTrustDLPDatasetUploadService -} - -// NewZeroTrustDLPDatasetService 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 NewZeroTrustDLPDatasetService(opts ...option.RequestOption) (r *ZeroTrustDLPDatasetService) { - r = &ZeroTrustDLPDatasetService{} - r.Options = opts - r.Upload = NewZeroTrustDLPDatasetUploadService(opts...) - return -} - -// Create a new dataset. -func (r *ZeroTrustDLPDatasetService) New(ctx context.Context, params ZeroTrustDLPDatasetNewParams, opts ...option.RequestOption) (res *ZeroTrustDLPDatasetNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDLPDatasetNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/dlp/datasets", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Update details about a dataset. -func (r *ZeroTrustDLPDatasetService) Update(ctx context.Context, datasetID string, params ZeroTrustDLPDatasetUpdateParams, opts ...option.RequestOption) (res *ZeroTrustDLPDatasetUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDLPDatasetUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/dlp/datasets/%s", params.AccountID, datasetID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch all datasets with information about available versions. -func (r *ZeroTrustDLPDatasetService) List(ctx context.Context, query ZeroTrustDLPDatasetListParams, opts ...option.RequestOption) (res *[]ZeroTrustDLPDatasetListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDLPDatasetListResponseEnvelope - path := fmt.Sprintf("accounts/%s/dlp/datasets", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete a dataset. -// -// This deletes all versions of the dataset. -func (r *ZeroTrustDLPDatasetService) Delete(ctx context.Context, datasetID string, body ZeroTrustDLPDatasetDeleteParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := fmt.Sprintf("accounts/%s/dlp/datasets/%s", body.AccountID, datasetID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) - return -} - -// Fetch a specific dataset with information about available versions. -func (r *ZeroTrustDLPDatasetService) Get(ctx context.Context, datasetID string, query ZeroTrustDLPDatasetGetParams, opts ...option.RequestOption) (res *ZeroTrustDLPDatasetGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDLPDatasetGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/dlp/datasets/%s", query.AccountID, datasetID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDLPDatasetNewResponse struct { - Dataset ZeroTrustDLPDatasetNewResponseDataset `json:"dataset,required"` - MaxCells int64 `json:"max_cells,required"` - // The version to use when uploading the dataset. - Version int64 `json:"version,required"` - // The secret to use for Exact Data Match datasets. This is not present in Custom - // Wordlists. - Secret string `json:"secret" format:"password"` - JSON zeroTrustDLPDatasetNewResponseJSON `json:"-"` -} - -// zeroTrustDLPDatasetNewResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDLPDatasetNewResponse] -type zeroTrustDLPDatasetNewResponseJSON struct { - Dataset apijson.Field - MaxCells apijson.Field - Version apijson.Field - Secret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetNewResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetNewResponseDataset struct { - ID string `json:"id,required" format:"uuid"` - CreatedAt time.Time `json:"created_at,required" format:"date-time"` - Name string `json:"name,required"` - NumCells int64 `json:"num_cells,required"` - Secret bool `json:"secret,required"` - Status ZeroTrustDLPDatasetNewResponseDatasetStatus `json:"status,required"` - UpdatedAt time.Time `json:"updated_at,required" format:"date-time"` - Uploads []ZeroTrustDLPDatasetNewResponseDatasetUpload `json:"uploads,required"` - Description string `json:"description,nullable"` - JSON zeroTrustDLPDatasetNewResponseDatasetJSON `json:"-"` -} - -// zeroTrustDLPDatasetNewResponseDatasetJSON contains the JSON metadata for the -// struct [ZeroTrustDLPDatasetNewResponseDataset] -type zeroTrustDLPDatasetNewResponseDatasetJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Name apijson.Field - NumCells apijson.Field - Secret apijson.Field - Status apijson.Field - UpdatedAt apijson.Field - Uploads apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetNewResponseDataset) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetNewResponseDatasetJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetNewResponseDatasetStatus string - -const ( - ZeroTrustDLPDatasetNewResponseDatasetStatusEmpty ZeroTrustDLPDatasetNewResponseDatasetStatus = "empty" - ZeroTrustDLPDatasetNewResponseDatasetStatusUploading ZeroTrustDLPDatasetNewResponseDatasetStatus = "uploading" - ZeroTrustDLPDatasetNewResponseDatasetStatusFailed ZeroTrustDLPDatasetNewResponseDatasetStatus = "failed" - ZeroTrustDLPDatasetNewResponseDatasetStatusComplete ZeroTrustDLPDatasetNewResponseDatasetStatus = "complete" -) - -type ZeroTrustDLPDatasetNewResponseDatasetUpload struct { - NumCells int64 `json:"num_cells,required"` - Status ZeroTrustDLPDatasetNewResponseDatasetUploadsStatus `json:"status,required"` - Version int64 `json:"version,required"` - JSON zeroTrustDLPDatasetNewResponseDatasetUploadJSON `json:"-"` -} - -// zeroTrustDLPDatasetNewResponseDatasetUploadJSON contains the JSON metadata for -// the struct [ZeroTrustDLPDatasetNewResponseDatasetUpload] -type zeroTrustDLPDatasetNewResponseDatasetUploadJSON struct { - NumCells apijson.Field - Status apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetNewResponseDatasetUpload) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetNewResponseDatasetUploadJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetNewResponseDatasetUploadsStatus string - -const ( - ZeroTrustDLPDatasetNewResponseDatasetUploadsStatusEmpty ZeroTrustDLPDatasetNewResponseDatasetUploadsStatus = "empty" - ZeroTrustDLPDatasetNewResponseDatasetUploadsStatusUploading ZeroTrustDLPDatasetNewResponseDatasetUploadsStatus = "uploading" - ZeroTrustDLPDatasetNewResponseDatasetUploadsStatusFailed ZeroTrustDLPDatasetNewResponseDatasetUploadsStatus = "failed" - ZeroTrustDLPDatasetNewResponseDatasetUploadsStatusComplete ZeroTrustDLPDatasetNewResponseDatasetUploadsStatus = "complete" -) - -type ZeroTrustDLPDatasetUpdateResponse struct { - ID string `json:"id,required" format:"uuid"` - CreatedAt time.Time `json:"created_at,required" format:"date-time"` - Name string `json:"name,required"` - NumCells int64 `json:"num_cells,required"` - Secret bool `json:"secret,required"` - Status ZeroTrustDLPDatasetUpdateResponseStatus `json:"status,required"` - UpdatedAt time.Time `json:"updated_at,required" format:"date-time"` - Uploads []ZeroTrustDLPDatasetUpdateResponseUpload `json:"uploads,required"` - Description string `json:"description,nullable"` - JSON zeroTrustDLPDatasetUpdateResponseJSON `json:"-"` -} - -// zeroTrustDLPDatasetUpdateResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDLPDatasetUpdateResponse] -type zeroTrustDLPDatasetUpdateResponseJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Name apijson.Field - NumCells apijson.Field - Secret apijson.Field - Status apijson.Field - UpdatedAt apijson.Field - Uploads apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetUpdateResponseStatus string - -const ( - ZeroTrustDLPDatasetUpdateResponseStatusEmpty ZeroTrustDLPDatasetUpdateResponseStatus = "empty" - ZeroTrustDLPDatasetUpdateResponseStatusUploading ZeroTrustDLPDatasetUpdateResponseStatus = "uploading" - ZeroTrustDLPDatasetUpdateResponseStatusFailed ZeroTrustDLPDatasetUpdateResponseStatus = "failed" - ZeroTrustDLPDatasetUpdateResponseStatusComplete ZeroTrustDLPDatasetUpdateResponseStatus = "complete" -) - -type ZeroTrustDLPDatasetUpdateResponseUpload struct { - NumCells int64 `json:"num_cells,required"` - Status ZeroTrustDLPDatasetUpdateResponseUploadsStatus `json:"status,required"` - Version int64 `json:"version,required"` - JSON zeroTrustDLPDatasetUpdateResponseUploadJSON `json:"-"` -} - -// zeroTrustDLPDatasetUpdateResponseUploadJSON contains the JSON metadata for the -// struct [ZeroTrustDLPDatasetUpdateResponseUpload] -type zeroTrustDLPDatasetUpdateResponseUploadJSON struct { - NumCells apijson.Field - Status apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetUpdateResponseUpload) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetUpdateResponseUploadJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetUpdateResponseUploadsStatus string - -const ( - ZeroTrustDLPDatasetUpdateResponseUploadsStatusEmpty ZeroTrustDLPDatasetUpdateResponseUploadsStatus = "empty" - ZeroTrustDLPDatasetUpdateResponseUploadsStatusUploading ZeroTrustDLPDatasetUpdateResponseUploadsStatus = "uploading" - ZeroTrustDLPDatasetUpdateResponseUploadsStatusFailed ZeroTrustDLPDatasetUpdateResponseUploadsStatus = "failed" - ZeroTrustDLPDatasetUpdateResponseUploadsStatusComplete ZeroTrustDLPDatasetUpdateResponseUploadsStatus = "complete" -) - -type ZeroTrustDLPDatasetListResponse struct { - ID string `json:"id,required" format:"uuid"` - CreatedAt time.Time `json:"created_at,required" format:"date-time"` - Name string `json:"name,required"` - NumCells int64 `json:"num_cells,required"` - Secret bool `json:"secret,required"` - Status ZeroTrustDLPDatasetListResponseStatus `json:"status,required"` - UpdatedAt time.Time `json:"updated_at,required" format:"date-time"` - Uploads []ZeroTrustDLPDatasetListResponseUpload `json:"uploads,required"` - Description string `json:"description,nullable"` - JSON zeroTrustDLPDatasetListResponseJSON `json:"-"` -} - -// zeroTrustDLPDatasetListResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDLPDatasetListResponse] -type zeroTrustDLPDatasetListResponseJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Name apijson.Field - NumCells apijson.Field - Secret apijson.Field - Status apijson.Field - UpdatedAt apijson.Field - Uploads apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetListResponseStatus string - -const ( - ZeroTrustDLPDatasetListResponseStatusEmpty ZeroTrustDLPDatasetListResponseStatus = "empty" - ZeroTrustDLPDatasetListResponseStatusUploading ZeroTrustDLPDatasetListResponseStatus = "uploading" - ZeroTrustDLPDatasetListResponseStatusFailed ZeroTrustDLPDatasetListResponseStatus = "failed" - ZeroTrustDLPDatasetListResponseStatusComplete ZeroTrustDLPDatasetListResponseStatus = "complete" -) - -type ZeroTrustDLPDatasetListResponseUpload struct { - NumCells int64 `json:"num_cells,required"` - Status ZeroTrustDLPDatasetListResponseUploadsStatus `json:"status,required"` - Version int64 `json:"version,required"` - JSON zeroTrustDLPDatasetListResponseUploadJSON `json:"-"` -} - -// zeroTrustDLPDatasetListResponseUploadJSON contains the JSON metadata for the -// struct [ZeroTrustDLPDatasetListResponseUpload] -type zeroTrustDLPDatasetListResponseUploadJSON struct { - NumCells apijson.Field - Status apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetListResponseUpload) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetListResponseUploadJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetListResponseUploadsStatus string - -const ( - ZeroTrustDLPDatasetListResponseUploadsStatusEmpty ZeroTrustDLPDatasetListResponseUploadsStatus = "empty" - ZeroTrustDLPDatasetListResponseUploadsStatusUploading ZeroTrustDLPDatasetListResponseUploadsStatus = "uploading" - ZeroTrustDLPDatasetListResponseUploadsStatusFailed ZeroTrustDLPDatasetListResponseUploadsStatus = "failed" - ZeroTrustDLPDatasetListResponseUploadsStatusComplete ZeroTrustDLPDatasetListResponseUploadsStatus = "complete" -) - -type ZeroTrustDLPDatasetGetResponse struct { - ID string `json:"id,required" format:"uuid"` - CreatedAt time.Time `json:"created_at,required" format:"date-time"` - Name string `json:"name,required"` - NumCells int64 `json:"num_cells,required"` - Secret bool `json:"secret,required"` - Status ZeroTrustDLPDatasetGetResponseStatus `json:"status,required"` - UpdatedAt time.Time `json:"updated_at,required" format:"date-time"` - Uploads []ZeroTrustDLPDatasetGetResponseUpload `json:"uploads,required"` - Description string `json:"description,nullable"` - JSON zeroTrustDLPDatasetGetResponseJSON `json:"-"` -} - -// zeroTrustDLPDatasetGetResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDLPDatasetGetResponse] -type zeroTrustDLPDatasetGetResponseJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Name apijson.Field - NumCells apijson.Field - Secret apijson.Field - Status apijson.Field - UpdatedAt apijson.Field - Uploads apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetGetResponseStatus string - -const ( - ZeroTrustDLPDatasetGetResponseStatusEmpty ZeroTrustDLPDatasetGetResponseStatus = "empty" - ZeroTrustDLPDatasetGetResponseStatusUploading ZeroTrustDLPDatasetGetResponseStatus = "uploading" - ZeroTrustDLPDatasetGetResponseStatusFailed ZeroTrustDLPDatasetGetResponseStatus = "failed" - ZeroTrustDLPDatasetGetResponseStatusComplete ZeroTrustDLPDatasetGetResponseStatus = "complete" -) - -type ZeroTrustDLPDatasetGetResponseUpload struct { - NumCells int64 `json:"num_cells,required"` - Status ZeroTrustDLPDatasetGetResponseUploadsStatus `json:"status,required"` - Version int64 `json:"version,required"` - JSON zeroTrustDLPDatasetGetResponseUploadJSON `json:"-"` -} - -// zeroTrustDLPDatasetGetResponseUploadJSON contains the JSON metadata for the -// struct [ZeroTrustDLPDatasetGetResponseUpload] -type zeroTrustDLPDatasetGetResponseUploadJSON struct { - NumCells apijson.Field - Status apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetGetResponseUpload) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetGetResponseUploadJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetGetResponseUploadsStatus string - -const ( - ZeroTrustDLPDatasetGetResponseUploadsStatusEmpty ZeroTrustDLPDatasetGetResponseUploadsStatus = "empty" - ZeroTrustDLPDatasetGetResponseUploadsStatusUploading ZeroTrustDLPDatasetGetResponseUploadsStatus = "uploading" - ZeroTrustDLPDatasetGetResponseUploadsStatusFailed ZeroTrustDLPDatasetGetResponseUploadsStatus = "failed" - ZeroTrustDLPDatasetGetResponseUploadsStatusComplete ZeroTrustDLPDatasetGetResponseUploadsStatus = "complete" -) - -type ZeroTrustDLPDatasetNewParams struct { - AccountID param.Field[string] `path:"account_id,required"` - Name param.Field[string] `json:"name,required"` - Description param.Field[string] `json:"description"` - // Generate a secret dataset. - // - // If true, the response will include a secret to use with the EDM encoder. If - // false, the response has no secret and the dataset is uploaded in plaintext. - Secret param.Field[bool] `json:"secret"` -} - -func (r ZeroTrustDLPDatasetNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDLPDatasetNewResponseEnvelope struct { - Errors []ZeroTrustDLPDatasetNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDLPDatasetNewResponseEnvelopeMessages `json:"messages,required"` - Success bool `json:"success,required"` - Result ZeroTrustDLPDatasetNewResponse `json:"result"` - ResultInfo ZeroTrustDLPDatasetNewResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDLPDatasetNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDLPDatasetNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDLPDatasetNewResponseEnvelope] -type zeroTrustDLPDatasetNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - ResultInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPDatasetNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDLPDatasetNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustDLPDatasetNewResponseEnvelopeErrors] -type zeroTrustDLPDatasetNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPDatasetNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDLPDatasetNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDLPDatasetNewResponseEnvelopeMessages] -type zeroTrustDLPDatasetNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetNewResponseEnvelopeResultInfo struct { - // total number of pages - Count int64 `json:"count,required"` - // current page - Page int64 `json:"page,required"` - // number of items per page - PerPage int64 `json:"per_page,required"` - // total number of items - TotalCount int64 `json:"total_count,required"` - JSON zeroTrustDLPDatasetNewResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDLPDatasetNewResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [ZeroTrustDLPDatasetNewResponseEnvelopeResultInfo] -type zeroTrustDLPDatasetNewResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetNewResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetUpdateParams struct { - AccountID param.Field[string] `path:"account_id,required"` - Description param.Field[string] `json:"description"` - Name param.Field[string] `json:"name"` -} - -func (r ZeroTrustDLPDatasetUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDLPDatasetUpdateResponseEnvelope struct { - Errors []ZeroTrustDLPDatasetUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDLPDatasetUpdateResponseEnvelopeMessages `json:"messages,required"` - Success bool `json:"success,required"` - Result ZeroTrustDLPDatasetUpdateResponse `json:"result"` - ResultInfo ZeroTrustDLPDatasetUpdateResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDLPDatasetUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDLPDatasetUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDLPDatasetUpdateResponseEnvelope] -type zeroTrustDLPDatasetUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - ResultInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPDatasetUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDLPDatasetUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDLPDatasetUpdateResponseEnvelopeErrors] -type zeroTrustDLPDatasetUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPDatasetUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDLPDatasetUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDLPDatasetUpdateResponseEnvelopeMessages] -type zeroTrustDLPDatasetUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetUpdateResponseEnvelopeResultInfo struct { - // total number of pages - Count int64 `json:"count,required"` - // current page - Page int64 `json:"page,required"` - // number of items per page - PerPage int64 `json:"per_page,required"` - // total number of items - TotalCount int64 `json:"total_count,required"` - JSON zeroTrustDLPDatasetUpdateResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDLPDatasetUpdateResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustDLPDatasetUpdateResponseEnvelopeResultInfo] -type zeroTrustDLPDatasetUpdateResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetListParams struct { - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustDLPDatasetListResponseEnvelope struct { - Errors []ZeroTrustDLPDatasetListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDLPDatasetListResponseEnvelopeMessages `json:"messages,required"` - Success bool `json:"success,required"` - Result []ZeroTrustDLPDatasetListResponse `json:"result"` - ResultInfo ZeroTrustDLPDatasetListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDLPDatasetListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDLPDatasetListResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDLPDatasetListResponseEnvelope] -type zeroTrustDLPDatasetListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - ResultInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPDatasetListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDLPDatasetListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustDLPDatasetListResponseEnvelopeErrors] -type zeroTrustDLPDatasetListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPDatasetListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDLPDatasetListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDLPDatasetListResponseEnvelopeMessages] -type zeroTrustDLPDatasetListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetListResponseEnvelopeResultInfo struct { - // total number of pages - Count int64 `json:"count,required"` - // current page - Page int64 `json:"page,required"` - // number of items per page - PerPage int64 `json:"per_page,required"` - // total number of items - TotalCount int64 `json:"total_count,required"` - JSON zeroTrustDLPDatasetListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDLPDatasetListResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [ZeroTrustDLPDatasetListResponseEnvelopeResultInfo] -type zeroTrustDLPDatasetListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetDeleteParams struct { - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustDLPDatasetGetParams struct { - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustDLPDatasetGetResponseEnvelope struct { - Errors []ZeroTrustDLPDatasetGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDLPDatasetGetResponseEnvelopeMessages `json:"messages,required"` - Success bool `json:"success,required"` - Result ZeroTrustDLPDatasetGetResponse `json:"result"` - ResultInfo ZeroTrustDLPDatasetGetResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDLPDatasetGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDLPDatasetGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDLPDatasetGetResponseEnvelope] -type zeroTrustDLPDatasetGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - ResultInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPDatasetGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDLPDatasetGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustDLPDatasetGetResponseEnvelopeErrors] -type zeroTrustDLPDatasetGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPDatasetGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDLPDatasetGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDLPDatasetGetResponseEnvelopeMessages] -type zeroTrustDLPDatasetGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetGetResponseEnvelopeResultInfo struct { - // total number of pages - Count int64 `json:"count,required"` - // current page - Page int64 `json:"page,required"` - // number of items per page - PerPage int64 `json:"per_page,required"` - // total number of items - TotalCount int64 `json:"total_count,required"` - JSON zeroTrustDLPDatasetGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDLPDatasetGetResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [ZeroTrustDLPDatasetGetResponseEnvelopeResultInfo] -type zeroTrustDLPDatasetGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zerotrustdlpdataset_test.go b/zerotrustdlpdataset_test.go deleted file mode 100644 index e249630c0c2..00000000000 --- a/zerotrustdlpdataset_test.go +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDLPDatasetNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.DLP.Datasets.New(context.TODO(), cloudflare.ZeroTrustDLPDatasetNewParams{ - AccountID: cloudflare.F("string"), - Name: cloudflare.F("string"), - Description: cloudflare.F("string"), - Secret: cloudflare.F(true), - }) - 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 TestZeroTrustDLPDatasetUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.DLP.Datasets.Update( - context.TODO(), - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - cloudflare.ZeroTrustDLPDatasetUpdateParams{ - AccountID: cloudflare.F("string"), - Description: cloudflare.F("string"), - Name: cloudflare.F("string"), - }, - ) - 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 TestZeroTrustDLPDatasetList(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("user@example.com"), - ) - _, err := client.ZeroTrust.DLP.Datasets.List(context.TODO(), cloudflare.ZeroTrustDLPDatasetListParams{ - AccountID: cloudflare.F("string"), - }) - 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 TestZeroTrustDLPDatasetDelete(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("user@example.com"), - ) - err := client.ZeroTrust.DLP.Datasets.Delete( - context.TODO(), - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - cloudflare.ZeroTrustDLPDatasetDeleteParams{ - AccountID: cloudflare.F("string"), - }, - ) - 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 TestZeroTrustDLPDatasetGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.DLP.Datasets.Get( - context.TODO(), - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - cloudflare.ZeroTrustDLPDatasetGetParams{ - AccountID: cloudflare.F("string"), - }, - ) - 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/zerotrustdlpdatasetupload.go b/zerotrustdlpdatasetupload.go deleted file mode 100644 index 413bae7ad2a..00000000000 --- a/zerotrustdlpdatasetupload.go +++ /dev/null @@ -1,385 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDLPDatasetUploadService 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 -// [NewZeroTrustDLPDatasetUploadService] method instead. -type ZeroTrustDLPDatasetUploadService struct { - Options []option.RequestOption -} - -// NewZeroTrustDLPDatasetUploadService 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 NewZeroTrustDLPDatasetUploadService(opts ...option.RequestOption) (r *ZeroTrustDLPDatasetUploadService) { - r = &ZeroTrustDLPDatasetUploadService{} - r.Options = opts - return -} - -// Prepare to upload a new version of a dataset. -func (r *ZeroTrustDLPDatasetUploadService) New(ctx context.Context, datasetID string, body ZeroTrustDLPDatasetUploadNewParams, opts ...option.RequestOption) (res *ZeroTrustDLPDatasetUploadNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDLPDatasetUploadNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/dlp/datasets/%s/upload", body.AccountID, datasetID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Upload a new version of a dataset. -func (r *ZeroTrustDLPDatasetUploadService) Edit(ctx context.Context, datasetID string, version int64, body ZeroTrustDLPDatasetUploadEditParams, opts ...option.RequestOption) (res *ZeroTrustDLPDatasetUploadEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDLPDatasetUploadEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/dlp/datasets/%s/upload/%v", body.AccountID, datasetID, version) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDLPDatasetUploadNewResponse struct { - MaxCells int64 `json:"max_cells,required"` - Version int64 `json:"version,required"` - Secret string `json:"secret" format:"password"` - JSON zeroTrustDLPDatasetUploadNewResponseJSON `json:"-"` -} - -// zeroTrustDLPDatasetUploadNewResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDLPDatasetUploadNewResponse] -type zeroTrustDLPDatasetUploadNewResponseJSON struct { - MaxCells apijson.Field - Version apijson.Field - Secret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetUploadNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetUploadNewResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetUploadEditResponse struct { - ID string `json:"id,required" format:"uuid"` - CreatedAt time.Time `json:"created_at,required" format:"date-time"` - Name string `json:"name,required"` - NumCells int64 `json:"num_cells,required"` - Secret bool `json:"secret,required"` - Status ZeroTrustDLPDatasetUploadEditResponseStatus `json:"status,required"` - UpdatedAt time.Time `json:"updated_at,required" format:"date-time"` - Uploads []ZeroTrustDLPDatasetUploadEditResponseUpload `json:"uploads,required"` - Description string `json:"description,nullable"` - JSON zeroTrustDLPDatasetUploadEditResponseJSON `json:"-"` -} - -// zeroTrustDLPDatasetUploadEditResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDLPDatasetUploadEditResponse] -type zeroTrustDLPDatasetUploadEditResponseJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Name apijson.Field - NumCells apijson.Field - Secret apijson.Field - Status apijson.Field - UpdatedAt apijson.Field - Uploads apijson.Field - Description apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetUploadEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetUploadEditResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetUploadEditResponseStatus string - -const ( - ZeroTrustDLPDatasetUploadEditResponseStatusEmpty ZeroTrustDLPDatasetUploadEditResponseStatus = "empty" - ZeroTrustDLPDatasetUploadEditResponseStatusUploading ZeroTrustDLPDatasetUploadEditResponseStatus = "uploading" - ZeroTrustDLPDatasetUploadEditResponseStatusFailed ZeroTrustDLPDatasetUploadEditResponseStatus = "failed" - ZeroTrustDLPDatasetUploadEditResponseStatusComplete ZeroTrustDLPDatasetUploadEditResponseStatus = "complete" -) - -type ZeroTrustDLPDatasetUploadEditResponseUpload struct { - NumCells int64 `json:"num_cells,required"` - Status ZeroTrustDLPDatasetUploadEditResponseUploadsStatus `json:"status,required"` - Version int64 `json:"version,required"` - JSON zeroTrustDLPDatasetUploadEditResponseUploadJSON `json:"-"` -} - -// zeroTrustDLPDatasetUploadEditResponseUploadJSON contains the JSON metadata for -// the struct [ZeroTrustDLPDatasetUploadEditResponseUpload] -type zeroTrustDLPDatasetUploadEditResponseUploadJSON struct { - NumCells apijson.Field - Status apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetUploadEditResponseUpload) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetUploadEditResponseUploadJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetUploadEditResponseUploadsStatus string - -const ( - ZeroTrustDLPDatasetUploadEditResponseUploadsStatusEmpty ZeroTrustDLPDatasetUploadEditResponseUploadsStatus = "empty" - ZeroTrustDLPDatasetUploadEditResponseUploadsStatusUploading ZeroTrustDLPDatasetUploadEditResponseUploadsStatus = "uploading" - ZeroTrustDLPDatasetUploadEditResponseUploadsStatusFailed ZeroTrustDLPDatasetUploadEditResponseUploadsStatus = "failed" - ZeroTrustDLPDatasetUploadEditResponseUploadsStatusComplete ZeroTrustDLPDatasetUploadEditResponseUploadsStatus = "complete" -) - -type ZeroTrustDLPDatasetUploadNewParams struct { - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustDLPDatasetUploadNewResponseEnvelope struct { - Errors []ZeroTrustDLPDatasetUploadNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDLPDatasetUploadNewResponseEnvelopeMessages `json:"messages,required"` - Success bool `json:"success,required"` - Result ZeroTrustDLPDatasetUploadNewResponse `json:"result"` - ResultInfo ZeroTrustDLPDatasetUploadNewResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDLPDatasetUploadNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDLPDatasetUploadNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDLPDatasetUploadNewResponseEnvelope] -type zeroTrustDLPDatasetUploadNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - ResultInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetUploadNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetUploadNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetUploadNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPDatasetUploadNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDLPDatasetUploadNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDLPDatasetUploadNewResponseEnvelopeErrors] -type zeroTrustDLPDatasetUploadNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetUploadNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetUploadNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetUploadNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPDatasetUploadNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDLPDatasetUploadNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDLPDatasetUploadNewResponseEnvelopeMessages] -type zeroTrustDLPDatasetUploadNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetUploadNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetUploadNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetUploadNewResponseEnvelopeResultInfo struct { - // total number of pages - Count int64 `json:"count,required"` - // current page - Page int64 `json:"page,required"` - // number of items per page - PerPage int64 `json:"per_page,required"` - // total number of items - TotalCount int64 `json:"total_count,required"` - JSON zeroTrustDLPDatasetUploadNewResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDLPDatasetUploadNewResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustDLPDatasetUploadNewResponseEnvelopeResultInfo] -type zeroTrustDLPDatasetUploadNewResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetUploadNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetUploadNewResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetUploadEditParams struct { - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustDLPDatasetUploadEditResponseEnvelope struct { - Errors []ZeroTrustDLPDatasetUploadEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDLPDatasetUploadEditResponseEnvelopeMessages `json:"messages,required"` - Success bool `json:"success,required"` - Result ZeroTrustDLPDatasetUploadEditResponse `json:"result"` - ResultInfo ZeroTrustDLPDatasetUploadEditResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDLPDatasetUploadEditResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDLPDatasetUploadEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDLPDatasetUploadEditResponseEnvelope] -type zeroTrustDLPDatasetUploadEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - ResultInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetUploadEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetUploadEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetUploadEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPDatasetUploadEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDLPDatasetUploadEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDLPDatasetUploadEditResponseEnvelopeErrors] -type zeroTrustDLPDatasetUploadEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetUploadEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetUploadEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetUploadEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPDatasetUploadEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDLPDatasetUploadEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDLPDatasetUploadEditResponseEnvelopeMessages] -type zeroTrustDLPDatasetUploadEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetUploadEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetUploadEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPDatasetUploadEditResponseEnvelopeResultInfo struct { - // total number of pages - Count int64 `json:"count,required"` - // current page - Page int64 `json:"page,required"` - // number of items per page - PerPage int64 `json:"per_page,required"` - // total number of items - TotalCount int64 `json:"total_count,required"` - JSON zeroTrustDLPDatasetUploadEditResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDLPDatasetUploadEditResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [ZeroTrustDLPDatasetUploadEditResponseEnvelopeResultInfo] -type zeroTrustDLPDatasetUploadEditResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPDatasetUploadEditResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPDatasetUploadEditResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zerotrustdlpdatasetupload_test.go b/zerotrustdlpdatasetupload_test.go deleted file mode 100644 index 6f85c07c444..00000000000 --- a/zerotrustdlpdatasetupload_test.go +++ /dev/null @@ -1,75 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDLPDatasetUploadNew(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("user@example.com"), - ) - _, err := client.ZeroTrust.DLP.Datasets.Upload.New( - context.TODO(), - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - cloudflare.ZeroTrustDLPDatasetUploadNewParams{ - AccountID: cloudflare.F("string"), - }, - ) - 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 TestZeroTrustDLPDatasetUploadEdit(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("user@example.com"), - ) - _, err := client.ZeroTrust.DLP.Datasets.Upload.Edit( - context.TODO(), - "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", - int64(0), - cloudflare.ZeroTrustDLPDatasetUploadEditParams{ - AccountID: cloudflare.F("string"), - }, - ) - 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/zerotrustdlppattern.go b/zerotrustdlppattern.go deleted file mode 100644 index 660cba91ea9..00000000000 --- a/zerotrustdlppattern.go +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDLPPatternService 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 [NewZeroTrustDLPPatternService] -// method instead. -type ZeroTrustDLPPatternService struct { - Options []option.RequestOption -} - -// NewZeroTrustDLPPatternService 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 NewZeroTrustDLPPatternService(opts ...option.RequestOption) (r *ZeroTrustDLPPatternService) { - r = &ZeroTrustDLPPatternService{} - r.Options = opts - return -} - -// Validates whether this pattern is a valid regular expression. Rejects it if the -// regular expression is too complex or can match an unbounded-length string. Your -// regex will be rejected if it uses the Kleene Star -- be sure to bound the -// maximum number of characters that can be matched. -func (r *ZeroTrustDLPPatternService) Validate(ctx context.Context, params ZeroTrustDLPPatternValidateParams, opts ...option.RequestOption) (res *ZeroTrustDLPPatternValidateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDLPPatternValidateResponseEnvelope - path := fmt.Sprintf("accounts/%s/dlp/patterns/validate", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDLPPatternValidateResponse struct { - Valid bool `json:"valid"` - JSON zeroTrustDLPPatternValidateResponseJSON `json:"-"` -} - -// zeroTrustDLPPatternValidateResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDLPPatternValidateResponse] -type zeroTrustDLPPatternValidateResponseJSON struct { - Valid apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPPatternValidateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPPatternValidateResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPPatternValidateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The regex pattern. - Regex param.Field[string] `json:"regex,required"` -} - -func (r ZeroTrustDLPPatternValidateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDLPPatternValidateResponseEnvelope struct { - Errors []ZeroTrustDLPPatternValidateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDLPPatternValidateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDLPPatternValidateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustDLPPatternValidateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDLPPatternValidateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDLPPatternValidateResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDLPPatternValidateResponseEnvelope] -type zeroTrustDLPPatternValidateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPPatternValidateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPPatternValidateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPPatternValidateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPPatternValidateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDLPPatternValidateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDLPPatternValidateResponseEnvelopeErrors] -type zeroTrustDLPPatternValidateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPPatternValidateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPPatternValidateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPPatternValidateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPPatternValidateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDLPPatternValidateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDLPPatternValidateResponseEnvelopeMessages] -type zeroTrustDLPPatternValidateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPPatternValidateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPPatternValidateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDLPPatternValidateResponseEnvelopeSuccess bool - -const ( - ZeroTrustDLPPatternValidateResponseEnvelopeSuccessTrue ZeroTrustDLPPatternValidateResponseEnvelopeSuccess = true -) diff --git a/zerotrustdlppattern_test.go b/zerotrustdlppattern_test.go deleted file mode 100644 index d7a3c4ce47b..00000000000 --- a/zerotrustdlppattern_test.go +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDLPPatternValidate(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("user@example.com"), - ) - _, err := client.ZeroTrust.DLP.Patterns.Validate(context.TODO(), cloudflare.ZeroTrustDLPPatternValidateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Regex: cloudflare.F("^4[0-9]{6,}$"), - }) - 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/zerotrustdlppayloadlog.go b/zerotrustdlppayloadlog.go deleted file mode 100644 index 1a47b008ca5..00000000000 --- a/zerotrustdlppayloadlog.go +++ /dev/null @@ -1,278 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDLPPayloadLogService 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 [NewZeroTrustDLPPayloadLogService] -// method instead. -type ZeroTrustDLPPayloadLogService struct { - Options []option.RequestOption -} - -// NewZeroTrustDLPPayloadLogService 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 NewZeroTrustDLPPayloadLogService(opts ...option.RequestOption) (r *ZeroTrustDLPPayloadLogService) { - r = &ZeroTrustDLPPayloadLogService{} - r.Options = opts - return -} - -// Updates the DLP payload log settings for this account. -func (r *ZeroTrustDLPPayloadLogService) Update(ctx context.Context, params ZeroTrustDLPPayloadLogUpdateParams, opts ...option.RequestOption) (res *ZeroTrustDLPPayloadLogUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDLPPayloadLogUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/dlp/payload_log", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets the current DLP payload log settings for this account. -func (r *ZeroTrustDLPPayloadLogService) Get(ctx context.Context, query ZeroTrustDLPPayloadLogGetParams, opts ...option.RequestOption) (res *ZeroTrustDLPPayloadLogGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDLPPayloadLogGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/dlp/payload_log", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDLPPayloadLogUpdateResponse struct { - PublicKey string `json:"public_key,required,nullable"` - JSON zeroTrustDLPPayloadLogUpdateResponseJSON `json:"-"` -} - -// zeroTrustDLPPayloadLogUpdateResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDLPPayloadLogUpdateResponse] -type zeroTrustDLPPayloadLogUpdateResponseJSON struct { - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPPayloadLogUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPPayloadLogUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPPayloadLogGetResponse struct { - PublicKey string `json:"public_key,required,nullable"` - JSON zeroTrustDLPPayloadLogGetResponseJSON `json:"-"` -} - -// zeroTrustDLPPayloadLogGetResponseJSON contains the JSON metadata for the struct -// [ZeroTrustDLPPayloadLogGetResponse] -type zeroTrustDLPPayloadLogGetResponseJSON struct { - PublicKey apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPPayloadLogGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPPayloadLogGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPPayloadLogUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The public key to use when encrypting extracted payloads, as a base64 string - PublicKey param.Field[string] `json:"public_key,required"` -} - -func (r ZeroTrustDLPPayloadLogUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDLPPayloadLogUpdateResponseEnvelope struct { - Errors []ZeroTrustDLPPayloadLogUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDLPPayloadLogUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDLPPayloadLogUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustDLPPayloadLogUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDLPPayloadLogUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDLPPayloadLogUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDLPPayloadLogUpdateResponseEnvelope] -type zeroTrustDLPPayloadLogUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPPayloadLogUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPPayloadLogUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPPayloadLogUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPPayloadLogUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDLPPayloadLogUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDLPPayloadLogUpdateResponseEnvelopeErrors] -type zeroTrustDLPPayloadLogUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPPayloadLogUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPPayloadLogUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPPayloadLogUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPPayloadLogUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDLPPayloadLogUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDLPPayloadLogUpdateResponseEnvelopeMessages] -type zeroTrustDLPPayloadLogUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPPayloadLogUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPPayloadLogUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDLPPayloadLogUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustDLPPayloadLogUpdateResponseEnvelopeSuccessTrue ZeroTrustDLPPayloadLogUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustDLPPayloadLogGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustDLPPayloadLogGetResponseEnvelope struct { - Errors []ZeroTrustDLPPayloadLogGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDLPPayloadLogGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDLPPayloadLogGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustDLPPayloadLogGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDLPPayloadLogGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDLPPayloadLogGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDLPPayloadLogGetResponseEnvelope] -type zeroTrustDLPPayloadLogGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPPayloadLogGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPPayloadLogGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPPayloadLogGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPPayloadLogGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDLPPayloadLogGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustDLPPayloadLogGetResponseEnvelopeErrors] -type zeroTrustDLPPayloadLogGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPPayloadLogGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPPayloadLogGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPPayloadLogGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPPayloadLogGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDLPPayloadLogGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDLPPayloadLogGetResponseEnvelopeMessages] -type zeroTrustDLPPayloadLogGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPPayloadLogGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPPayloadLogGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDLPPayloadLogGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustDLPPayloadLogGetResponseEnvelopeSuccessTrue ZeroTrustDLPPayloadLogGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustdlppayloadlog_test.go b/zerotrustdlppayloadlog_test.go deleted file mode 100644 index 248bae789d9..00000000000 --- a/zerotrustdlppayloadlog_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDLPPayloadLogUpdate(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("user@example.com"), - ) - _, err := client.ZeroTrust.DLP.PayloadLogs.Update(context.TODO(), cloudflare.ZeroTrustDLPPayloadLogUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - PublicKey: cloudflare.F("EmpOvSXw8BfbrGCi0fhGiD/3yXk2SiV1Nzg2lru3oj0="), - }) - 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 TestZeroTrustDLPPayloadLogGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.DLP.PayloadLogs.Get(context.TODO(), cloudflare.ZeroTrustDLPPayloadLogGetParams{ - AccountID: cloudflare.F("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/zerotrustdlpprofile.go b/zerotrustdlpprofile.go deleted file mode 100644 index a41441f6725..00000000000 --- a/zerotrustdlpprofile.go +++ /dev/null @@ -1,1125 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustDLPProfileService 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 [NewZeroTrustDLPProfileService] -// method instead. -type ZeroTrustDLPProfileService struct { - Options []option.RequestOption - Customs *ZeroTrustDLPProfileCustomService - Predefineds *ZeroTrustDLPProfilePredefinedService -} - -// NewZeroTrustDLPProfileService 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 NewZeroTrustDLPProfileService(opts ...option.RequestOption) (r *ZeroTrustDLPProfileService) { - r = &ZeroTrustDLPProfileService{} - r.Options = opts - r.Customs = NewZeroTrustDLPProfileCustomService(opts...) - r.Predefineds = NewZeroTrustDLPProfilePredefinedService(opts...) - return -} - -// Lists all DLP profiles in an account. -func (r *ZeroTrustDLPProfileService) List(ctx context.Context, query ZeroTrustDLPProfileListParams, opts ...option.RequestOption) (res *[]ZeroTrustDLPProfileListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDLPProfileListResponseEnvelope - path := fmt.Sprintf("accounts/%s/dlp/profiles", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a DLP profile by ID. Supports both predefined and custom profiles -func (r *ZeroTrustDLPProfileService) Get(ctx context.Context, profileID string, query ZeroTrustDLPProfileGetParams, opts ...option.RequestOption) (res *ZeroTrustDLPProfileGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDLPProfileGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/dlp/profiles/%s", query.AccountID, profileID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [ZeroTrustDLPProfileListResponseDLPPredefinedProfile], -// [ZeroTrustDLPProfileListResponseDLPCustomProfile] or -// [ZeroTrustDLPProfileListResponseDLPIntegrationProfile]. -type ZeroTrustDLPProfileListResponse interface { - implementsZeroTrustDLPProfileListResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustDLPProfileListResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDLPProfileListResponseDLPPredefinedProfile{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDLPProfileListResponseDLPCustomProfile{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDLPProfileListResponseDLPIntegrationProfile{}), - }, - ) -} - -type ZeroTrustDLPProfileListResponseDLPPredefinedProfile struct { - // The ID for this profile - ID string `json:"id"` - // Related DLP policies will trigger when the match count exceeds the number set. - AllowedMatchCount float64 `json:"allowed_match_count"` - // Scan the context of predefined entries to only return matches surrounded by - // keywords. - ContextAwareness ZeroTrustDLPProfileListResponseDLPPredefinedProfileContextAwareness `json:"context_awareness"` - // The entries for this profile. - Entries []ZeroTrustDLPProfileListResponseDLPPredefinedProfileEntry `json:"entries"` - // The name of the profile. - Name string `json:"name"` - // The type of the profile. - Type ZeroTrustDLPProfileListResponseDLPPredefinedProfileType `json:"type"` - JSON zeroTrustDLPProfileListResponseDLPPredefinedProfileJSON `json:"-"` -} - -// zeroTrustDLPProfileListResponseDLPPredefinedProfileJSON contains the JSON -// metadata for the struct [ZeroTrustDLPProfileListResponseDLPPredefinedProfile] -type zeroTrustDLPProfileListResponseDLPPredefinedProfileJSON struct { - ID apijson.Field - AllowedMatchCount apijson.Field - ContextAwareness apijson.Field - Entries apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileListResponseDLPPredefinedProfile) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileListResponseDLPPredefinedProfileJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDLPProfileListResponseDLPPredefinedProfile) implementsZeroTrustDLPProfileListResponse() { -} - -// Scan the context of predefined entries to only return matches surrounded by -// keywords. -type ZeroTrustDLPProfileListResponseDLPPredefinedProfileContextAwareness struct { - // If true, scan the context of predefined entries to only return matches - // surrounded by keywords. - Enabled bool `json:"enabled,required"` - // Content types to exclude from context analysis and return all matches. - Skip ZeroTrustDLPProfileListResponseDLPPredefinedProfileContextAwarenessSkip `json:"skip,required"` - JSON zeroTrustDLPProfileListResponseDLPPredefinedProfileContextAwarenessJSON `json:"-"` -} - -// zeroTrustDLPProfileListResponseDLPPredefinedProfileContextAwarenessJSON contains -// the JSON metadata for the struct -// [ZeroTrustDLPProfileListResponseDLPPredefinedProfileContextAwareness] -type zeroTrustDLPProfileListResponseDLPPredefinedProfileContextAwarenessJSON struct { - Enabled apijson.Field - Skip apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileListResponseDLPPredefinedProfileContextAwareness) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileListResponseDLPPredefinedProfileContextAwarenessJSON) RawJSON() string { - return r.raw -} - -// Content types to exclude from context analysis and return all matches. -type ZeroTrustDLPProfileListResponseDLPPredefinedProfileContextAwarenessSkip struct { - // If the content type is a file, skip context analysis and return all matches. - Files bool `json:"files,required"` - JSON zeroTrustDLPProfileListResponseDLPPredefinedProfileContextAwarenessSkipJSON `json:"-"` -} - -// zeroTrustDLPProfileListResponseDLPPredefinedProfileContextAwarenessSkipJSON -// contains the JSON metadata for the struct -// [ZeroTrustDLPProfileListResponseDLPPredefinedProfileContextAwarenessSkip] -type zeroTrustDLPProfileListResponseDLPPredefinedProfileContextAwarenessSkipJSON struct { - Files apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileListResponseDLPPredefinedProfileContextAwarenessSkip) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileListResponseDLPPredefinedProfileContextAwarenessSkipJSON) RawJSON() string { - return r.raw -} - -// A predefined entry that matches a profile -type ZeroTrustDLPProfileListResponseDLPPredefinedProfileEntry struct { - // The ID for this entry - ID string `json:"id"` - // Whether the entry is enabled or not. - Enabled bool `json:"enabled"` - // The name of the entry. - Name string `json:"name"` - // ID of the parent profile - ProfileID interface{} `json:"profile_id"` - JSON zeroTrustDLPProfileListResponseDLPPredefinedProfileEntryJSON `json:"-"` -} - -// zeroTrustDLPProfileListResponseDLPPredefinedProfileEntryJSON contains the JSON -// metadata for the struct -// [ZeroTrustDLPProfileListResponseDLPPredefinedProfileEntry] -type zeroTrustDLPProfileListResponseDLPPredefinedProfileEntryJSON struct { - ID apijson.Field - Enabled apijson.Field - Name apijson.Field - ProfileID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileListResponseDLPPredefinedProfileEntry) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileListResponseDLPPredefinedProfileEntryJSON) RawJSON() string { - return r.raw -} - -// The type of the profile. -type ZeroTrustDLPProfileListResponseDLPPredefinedProfileType string - -const ( - ZeroTrustDLPProfileListResponseDLPPredefinedProfileTypePredefined ZeroTrustDLPProfileListResponseDLPPredefinedProfileType = "predefined" -) - -type ZeroTrustDLPProfileListResponseDLPCustomProfile struct { - // The ID for this profile - ID string `json:"id"` - // Related DLP policies will trigger when the match count exceeds the number set. - AllowedMatchCount float64 `json:"allowed_match_count"` - // Scan the context of predefined entries to only return matches surrounded by - // keywords. - ContextAwareness ZeroTrustDLPProfileListResponseDLPCustomProfileContextAwareness `json:"context_awareness"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The description of the profile. - Description string `json:"description"` - // The entries for this profile. - Entries []ZeroTrustDLPProfileListResponseDLPCustomProfileEntry `json:"entries"` - // The name of the profile. - Name string `json:"name"` - // The type of the profile. - Type ZeroTrustDLPProfileListResponseDLPCustomProfileType `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustDLPProfileListResponseDLPCustomProfileJSON `json:"-"` -} - -// zeroTrustDLPProfileListResponseDLPCustomProfileJSON contains the JSON metadata -// for the struct [ZeroTrustDLPProfileListResponseDLPCustomProfile] -type zeroTrustDLPProfileListResponseDLPCustomProfileJSON struct { - ID apijson.Field - AllowedMatchCount apijson.Field - ContextAwareness apijson.Field - CreatedAt apijson.Field - Description apijson.Field - Entries apijson.Field - Name apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileListResponseDLPCustomProfile) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileListResponseDLPCustomProfileJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDLPProfileListResponseDLPCustomProfile) implementsZeroTrustDLPProfileListResponse() { -} - -// Scan the context of predefined entries to only return matches surrounded by -// keywords. -type ZeroTrustDLPProfileListResponseDLPCustomProfileContextAwareness struct { - // If true, scan the context of predefined entries to only return matches - // surrounded by keywords. - Enabled bool `json:"enabled,required"` - // Content types to exclude from context analysis and return all matches. - Skip ZeroTrustDLPProfileListResponseDLPCustomProfileContextAwarenessSkip `json:"skip,required"` - JSON zeroTrustDLPProfileListResponseDLPCustomProfileContextAwarenessJSON `json:"-"` -} - -// zeroTrustDLPProfileListResponseDLPCustomProfileContextAwarenessJSON contains the -// JSON metadata for the struct -// [ZeroTrustDLPProfileListResponseDLPCustomProfileContextAwareness] -type zeroTrustDLPProfileListResponseDLPCustomProfileContextAwarenessJSON struct { - Enabled apijson.Field - Skip apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileListResponseDLPCustomProfileContextAwareness) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileListResponseDLPCustomProfileContextAwarenessJSON) RawJSON() string { - return r.raw -} - -// Content types to exclude from context analysis and return all matches. -type ZeroTrustDLPProfileListResponseDLPCustomProfileContextAwarenessSkip struct { - // If the content type is a file, skip context analysis and return all matches. - Files bool `json:"files,required"` - JSON zeroTrustDLPProfileListResponseDLPCustomProfileContextAwarenessSkipJSON `json:"-"` -} - -// zeroTrustDLPProfileListResponseDLPCustomProfileContextAwarenessSkipJSON contains -// the JSON metadata for the struct -// [ZeroTrustDLPProfileListResponseDLPCustomProfileContextAwarenessSkip] -type zeroTrustDLPProfileListResponseDLPCustomProfileContextAwarenessSkipJSON struct { - Files apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileListResponseDLPCustomProfileContextAwarenessSkip) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileListResponseDLPCustomProfileContextAwarenessSkipJSON) RawJSON() string { - return r.raw -} - -// A custom entry that matches a profile -type ZeroTrustDLPProfileListResponseDLPCustomProfileEntry struct { - // The ID for this entry - ID string `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Whether the entry is enabled or not. - Enabled bool `json:"enabled"` - // The name of the entry. - Name string `json:"name"` - // A pattern that matches an entry - Pattern ZeroTrustDLPProfileListResponseDLPCustomProfileEntriesPattern `json:"pattern"` - // ID of the parent profile - ProfileID interface{} `json:"profile_id"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustDLPProfileListResponseDLPCustomProfileEntryJSON `json:"-"` -} - -// zeroTrustDLPProfileListResponseDLPCustomProfileEntryJSON contains the JSON -// metadata for the struct [ZeroTrustDLPProfileListResponseDLPCustomProfileEntry] -type zeroTrustDLPProfileListResponseDLPCustomProfileEntryJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Enabled apijson.Field - Name apijson.Field - Pattern apijson.Field - ProfileID apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileListResponseDLPCustomProfileEntry) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileListResponseDLPCustomProfileEntryJSON) RawJSON() string { - return r.raw -} - -// A pattern that matches an entry -type ZeroTrustDLPProfileListResponseDLPCustomProfileEntriesPattern struct { - // The regex pattern. - Regex string `json:"regex,required"` - // Validation algorithm for the pattern. This algorithm will get run on potential - // matches, and if it returns false, the entry will not be matched. - Validation ZeroTrustDLPProfileListResponseDLPCustomProfileEntriesPatternValidation `json:"validation"` - JSON zeroTrustDLPProfileListResponseDLPCustomProfileEntriesPatternJSON `json:"-"` -} - -// zeroTrustDLPProfileListResponseDLPCustomProfileEntriesPatternJSON contains the -// JSON metadata for the struct -// [ZeroTrustDLPProfileListResponseDLPCustomProfileEntriesPattern] -type zeroTrustDLPProfileListResponseDLPCustomProfileEntriesPatternJSON struct { - Regex apijson.Field - Validation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileListResponseDLPCustomProfileEntriesPattern) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileListResponseDLPCustomProfileEntriesPatternJSON) RawJSON() string { - return r.raw -} - -// Validation algorithm for the pattern. This algorithm will get run on potential -// matches, and if it returns false, the entry will not be matched. -type ZeroTrustDLPProfileListResponseDLPCustomProfileEntriesPatternValidation string - -const ( - ZeroTrustDLPProfileListResponseDLPCustomProfileEntriesPatternValidationLuhn ZeroTrustDLPProfileListResponseDLPCustomProfileEntriesPatternValidation = "luhn" -) - -// The type of the profile. -type ZeroTrustDLPProfileListResponseDLPCustomProfileType string - -const ( - ZeroTrustDLPProfileListResponseDLPCustomProfileTypeCustom ZeroTrustDLPProfileListResponseDLPCustomProfileType = "custom" -) - -type ZeroTrustDLPProfileListResponseDLPIntegrationProfile struct { - // The ID for this profile - ID string `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The description of the profile. - Description string `json:"description"` - // The entries for this profile. - Entries []ZeroTrustDLPProfileListResponseDLPIntegrationProfileEntry `json:"entries"` - // The name of the profile. - Name string `json:"name"` - // The type of the profile. - Type ZeroTrustDLPProfileListResponseDLPIntegrationProfileType `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustDLPProfileListResponseDLPIntegrationProfileJSON `json:"-"` -} - -// zeroTrustDLPProfileListResponseDLPIntegrationProfileJSON contains the JSON -// metadata for the struct [ZeroTrustDLPProfileListResponseDLPIntegrationProfile] -type zeroTrustDLPProfileListResponseDLPIntegrationProfileJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Description apijson.Field - Entries apijson.Field - Name apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileListResponseDLPIntegrationProfile) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileListResponseDLPIntegrationProfileJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDLPProfileListResponseDLPIntegrationProfile) implementsZeroTrustDLPProfileListResponse() { -} - -// An entry derived from an integration -type ZeroTrustDLPProfileListResponseDLPIntegrationProfileEntry struct { - // The ID for this entry - ID string `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Whether the entry is enabled or not. - Enabled bool `json:"enabled"` - // The name of the entry. - Name string `json:"name"` - // ID of the parent profile - ProfileID interface{} `json:"profile_id"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustDLPProfileListResponseDLPIntegrationProfileEntryJSON `json:"-"` -} - -// zeroTrustDLPProfileListResponseDLPIntegrationProfileEntryJSON contains the JSON -// metadata for the struct -// [ZeroTrustDLPProfileListResponseDLPIntegrationProfileEntry] -type zeroTrustDLPProfileListResponseDLPIntegrationProfileEntryJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Enabled apijson.Field - Name apijson.Field - ProfileID apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileListResponseDLPIntegrationProfileEntry) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileListResponseDLPIntegrationProfileEntryJSON) RawJSON() string { - return r.raw -} - -// The type of the profile. -type ZeroTrustDLPProfileListResponseDLPIntegrationProfileType string - -const ( - ZeroTrustDLPProfileListResponseDLPIntegrationProfileTypeIntegration ZeroTrustDLPProfileListResponseDLPIntegrationProfileType = "integration" -) - -// Union satisfied by [ZeroTrustDLPProfileGetResponseDLPPredefinedProfile], -// [ZeroTrustDLPProfileGetResponseDLPCustomProfile] or -// [ZeroTrustDLPProfileGetResponseDLPIntegrationProfile]. -type ZeroTrustDLPProfileGetResponse interface { - implementsZeroTrustDLPProfileGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustDLPProfileGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDLPProfileGetResponseDLPPredefinedProfile{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDLPProfileGetResponseDLPCustomProfile{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustDLPProfileGetResponseDLPIntegrationProfile{}), - }, - ) -} - -type ZeroTrustDLPProfileGetResponseDLPPredefinedProfile struct { - // The ID for this profile - ID string `json:"id"` - // Related DLP policies will trigger when the match count exceeds the number set. - AllowedMatchCount float64 `json:"allowed_match_count"` - // Scan the context of predefined entries to only return matches surrounded by - // keywords. - ContextAwareness ZeroTrustDLPProfileGetResponseDLPPredefinedProfileContextAwareness `json:"context_awareness"` - // The entries for this profile. - Entries []ZeroTrustDLPProfileGetResponseDLPPredefinedProfileEntry `json:"entries"` - // The name of the profile. - Name string `json:"name"` - // The type of the profile. - Type ZeroTrustDLPProfileGetResponseDLPPredefinedProfileType `json:"type"` - JSON zeroTrustDLPProfileGetResponseDLPPredefinedProfileJSON `json:"-"` -} - -// zeroTrustDLPProfileGetResponseDLPPredefinedProfileJSON contains the JSON -// metadata for the struct [ZeroTrustDLPProfileGetResponseDLPPredefinedProfile] -type zeroTrustDLPProfileGetResponseDLPPredefinedProfileJSON struct { - ID apijson.Field - AllowedMatchCount apijson.Field - ContextAwareness apijson.Field - Entries apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileGetResponseDLPPredefinedProfile) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileGetResponseDLPPredefinedProfileJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDLPProfileGetResponseDLPPredefinedProfile) implementsZeroTrustDLPProfileGetResponse() { -} - -// Scan the context of predefined entries to only return matches surrounded by -// keywords. -type ZeroTrustDLPProfileGetResponseDLPPredefinedProfileContextAwareness struct { - // If true, scan the context of predefined entries to only return matches - // surrounded by keywords. - Enabled bool `json:"enabled,required"` - // Content types to exclude from context analysis and return all matches. - Skip ZeroTrustDLPProfileGetResponseDLPPredefinedProfileContextAwarenessSkip `json:"skip,required"` - JSON zeroTrustDLPProfileGetResponseDLPPredefinedProfileContextAwarenessJSON `json:"-"` -} - -// zeroTrustDLPProfileGetResponseDLPPredefinedProfileContextAwarenessJSON contains -// the JSON metadata for the struct -// [ZeroTrustDLPProfileGetResponseDLPPredefinedProfileContextAwareness] -type zeroTrustDLPProfileGetResponseDLPPredefinedProfileContextAwarenessJSON struct { - Enabled apijson.Field - Skip apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileGetResponseDLPPredefinedProfileContextAwareness) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileGetResponseDLPPredefinedProfileContextAwarenessJSON) RawJSON() string { - return r.raw -} - -// Content types to exclude from context analysis and return all matches. -type ZeroTrustDLPProfileGetResponseDLPPredefinedProfileContextAwarenessSkip struct { - // If the content type is a file, skip context analysis and return all matches. - Files bool `json:"files,required"` - JSON zeroTrustDLPProfileGetResponseDLPPredefinedProfileContextAwarenessSkipJSON `json:"-"` -} - -// zeroTrustDLPProfileGetResponseDLPPredefinedProfileContextAwarenessSkipJSON -// contains the JSON metadata for the struct -// [ZeroTrustDLPProfileGetResponseDLPPredefinedProfileContextAwarenessSkip] -type zeroTrustDLPProfileGetResponseDLPPredefinedProfileContextAwarenessSkipJSON struct { - Files apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileGetResponseDLPPredefinedProfileContextAwarenessSkip) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileGetResponseDLPPredefinedProfileContextAwarenessSkipJSON) RawJSON() string { - return r.raw -} - -// A predefined entry that matches a profile -type ZeroTrustDLPProfileGetResponseDLPPredefinedProfileEntry struct { - // The ID for this entry - ID string `json:"id"` - // Whether the entry is enabled or not. - Enabled bool `json:"enabled"` - // The name of the entry. - Name string `json:"name"` - // ID of the parent profile - ProfileID interface{} `json:"profile_id"` - JSON zeroTrustDLPProfileGetResponseDLPPredefinedProfileEntryJSON `json:"-"` -} - -// zeroTrustDLPProfileGetResponseDLPPredefinedProfileEntryJSON contains the JSON -// metadata for the struct -// [ZeroTrustDLPProfileGetResponseDLPPredefinedProfileEntry] -type zeroTrustDLPProfileGetResponseDLPPredefinedProfileEntryJSON struct { - ID apijson.Field - Enabled apijson.Field - Name apijson.Field - ProfileID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileGetResponseDLPPredefinedProfileEntry) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileGetResponseDLPPredefinedProfileEntryJSON) RawJSON() string { - return r.raw -} - -// The type of the profile. -type ZeroTrustDLPProfileGetResponseDLPPredefinedProfileType string - -const ( - ZeroTrustDLPProfileGetResponseDLPPredefinedProfileTypePredefined ZeroTrustDLPProfileGetResponseDLPPredefinedProfileType = "predefined" -) - -type ZeroTrustDLPProfileGetResponseDLPCustomProfile struct { - // The ID for this profile - ID string `json:"id"` - // Related DLP policies will trigger when the match count exceeds the number set. - AllowedMatchCount float64 `json:"allowed_match_count"` - // Scan the context of predefined entries to only return matches surrounded by - // keywords. - ContextAwareness ZeroTrustDLPProfileGetResponseDLPCustomProfileContextAwareness `json:"context_awareness"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The description of the profile. - Description string `json:"description"` - // The entries for this profile. - Entries []ZeroTrustDLPProfileGetResponseDLPCustomProfileEntry `json:"entries"` - // The name of the profile. - Name string `json:"name"` - // The type of the profile. - Type ZeroTrustDLPProfileGetResponseDLPCustomProfileType `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustDLPProfileGetResponseDLPCustomProfileJSON `json:"-"` -} - -// zeroTrustDLPProfileGetResponseDLPCustomProfileJSON contains the JSON metadata -// for the struct [ZeroTrustDLPProfileGetResponseDLPCustomProfile] -type zeroTrustDLPProfileGetResponseDLPCustomProfileJSON struct { - ID apijson.Field - AllowedMatchCount apijson.Field - ContextAwareness apijson.Field - CreatedAt apijson.Field - Description apijson.Field - Entries apijson.Field - Name apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileGetResponseDLPCustomProfile) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileGetResponseDLPCustomProfileJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDLPProfileGetResponseDLPCustomProfile) implementsZeroTrustDLPProfileGetResponse() {} - -// Scan the context of predefined entries to only return matches surrounded by -// keywords. -type ZeroTrustDLPProfileGetResponseDLPCustomProfileContextAwareness struct { - // If true, scan the context of predefined entries to only return matches - // surrounded by keywords. - Enabled bool `json:"enabled,required"` - // Content types to exclude from context analysis and return all matches. - Skip ZeroTrustDLPProfileGetResponseDLPCustomProfileContextAwarenessSkip `json:"skip,required"` - JSON zeroTrustDLPProfileGetResponseDLPCustomProfileContextAwarenessJSON `json:"-"` -} - -// zeroTrustDLPProfileGetResponseDLPCustomProfileContextAwarenessJSON contains the -// JSON metadata for the struct -// [ZeroTrustDLPProfileGetResponseDLPCustomProfileContextAwareness] -type zeroTrustDLPProfileGetResponseDLPCustomProfileContextAwarenessJSON struct { - Enabled apijson.Field - Skip apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileGetResponseDLPCustomProfileContextAwareness) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileGetResponseDLPCustomProfileContextAwarenessJSON) RawJSON() string { - return r.raw -} - -// Content types to exclude from context analysis and return all matches. -type ZeroTrustDLPProfileGetResponseDLPCustomProfileContextAwarenessSkip struct { - // If the content type is a file, skip context analysis and return all matches. - Files bool `json:"files,required"` - JSON zeroTrustDLPProfileGetResponseDLPCustomProfileContextAwarenessSkipJSON `json:"-"` -} - -// zeroTrustDLPProfileGetResponseDLPCustomProfileContextAwarenessSkipJSON contains -// the JSON metadata for the struct -// [ZeroTrustDLPProfileGetResponseDLPCustomProfileContextAwarenessSkip] -type zeroTrustDLPProfileGetResponseDLPCustomProfileContextAwarenessSkipJSON struct { - Files apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileGetResponseDLPCustomProfileContextAwarenessSkip) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileGetResponseDLPCustomProfileContextAwarenessSkipJSON) RawJSON() string { - return r.raw -} - -// A custom entry that matches a profile -type ZeroTrustDLPProfileGetResponseDLPCustomProfileEntry struct { - // The ID for this entry - ID string `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Whether the entry is enabled or not. - Enabled bool `json:"enabled"` - // The name of the entry. - Name string `json:"name"` - // A pattern that matches an entry - Pattern ZeroTrustDLPProfileGetResponseDLPCustomProfileEntriesPattern `json:"pattern"` - // ID of the parent profile - ProfileID interface{} `json:"profile_id"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustDLPProfileGetResponseDLPCustomProfileEntryJSON `json:"-"` -} - -// zeroTrustDLPProfileGetResponseDLPCustomProfileEntryJSON contains the JSON -// metadata for the struct [ZeroTrustDLPProfileGetResponseDLPCustomProfileEntry] -type zeroTrustDLPProfileGetResponseDLPCustomProfileEntryJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Enabled apijson.Field - Name apijson.Field - Pattern apijson.Field - ProfileID apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileGetResponseDLPCustomProfileEntry) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileGetResponseDLPCustomProfileEntryJSON) RawJSON() string { - return r.raw -} - -// A pattern that matches an entry -type ZeroTrustDLPProfileGetResponseDLPCustomProfileEntriesPattern struct { - // The regex pattern. - Regex string `json:"regex,required"` - // Validation algorithm for the pattern. This algorithm will get run on potential - // matches, and if it returns false, the entry will not be matched. - Validation ZeroTrustDLPProfileGetResponseDLPCustomProfileEntriesPatternValidation `json:"validation"` - JSON zeroTrustDLPProfileGetResponseDLPCustomProfileEntriesPatternJSON `json:"-"` -} - -// zeroTrustDLPProfileGetResponseDLPCustomProfileEntriesPatternJSON contains the -// JSON metadata for the struct -// [ZeroTrustDLPProfileGetResponseDLPCustomProfileEntriesPattern] -type zeroTrustDLPProfileGetResponseDLPCustomProfileEntriesPatternJSON struct { - Regex apijson.Field - Validation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileGetResponseDLPCustomProfileEntriesPattern) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileGetResponseDLPCustomProfileEntriesPatternJSON) RawJSON() string { - return r.raw -} - -// Validation algorithm for the pattern. This algorithm will get run on potential -// matches, and if it returns false, the entry will not be matched. -type ZeroTrustDLPProfileGetResponseDLPCustomProfileEntriesPatternValidation string - -const ( - ZeroTrustDLPProfileGetResponseDLPCustomProfileEntriesPatternValidationLuhn ZeroTrustDLPProfileGetResponseDLPCustomProfileEntriesPatternValidation = "luhn" -) - -// The type of the profile. -type ZeroTrustDLPProfileGetResponseDLPCustomProfileType string - -const ( - ZeroTrustDLPProfileGetResponseDLPCustomProfileTypeCustom ZeroTrustDLPProfileGetResponseDLPCustomProfileType = "custom" -) - -type ZeroTrustDLPProfileGetResponseDLPIntegrationProfile struct { - // The ID for this profile - ID string `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The description of the profile. - Description string `json:"description"` - // The entries for this profile. - Entries []ZeroTrustDLPProfileGetResponseDLPIntegrationProfileEntry `json:"entries"` - // The name of the profile. - Name string `json:"name"` - // The type of the profile. - Type ZeroTrustDLPProfileGetResponseDLPIntegrationProfileType `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustDLPProfileGetResponseDLPIntegrationProfileJSON `json:"-"` -} - -// zeroTrustDLPProfileGetResponseDLPIntegrationProfileJSON contains the JSON -// metadata for the struct [ZeroTrustDLPProfileGetResponseDLPIntegrationProfile] -type zeroTrustDLPProfileGetResponseDLPIntegrationProfileJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Description apijson.Field - Entries apijson.Field - Name apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileGetResponseDLPIntegrationProfile) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileGetResponseDLPIntegrationProfileJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustDLPProfileGetResponseDLPIntegrationProfile) implementsZeroTrustDLPProfileGetResponse() { -} - -// An entry derived from an integration -type ZeroTrustDLPProfileGetResponseDLPIntegrationProfileEntry struct { - // The ID for this entry - ID string `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Whether the entry is enabled or not. - Enabled bool `json:"enabled"` - // The name of the entry. - Name string `json:"name"` - // ID of the parent profile - ProfileID interface{} `json:"profile_id"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustDLPProfileGetResponseDLPIntegrationProfileEntryJSON `json:"-"` -} - -// zeroTrustDLPProfileGetResponseDLPIntegrationProfileEntryJSON contains the JSON -// metadata for the struct -// [ZeroTrustDLPProfileGetResponseDLPIntegrationProfileEntry] -type zeroTrustDLPProfileGetResponseDLPIntegrationProfileEntryJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Enabled apijson.Field - Name apijson.Field - ProfileID apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileGetResponseDLPIntegrationProfileEntry) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileGetResponseDLPIntegrationProfileEntryJSON) RawJSON() string { - return r.raw -} - -// The type of the profile. -type ZeroTrustDLPProfileGetResponseDLPIntegrationProfileType string - -const ( - ZeroTrustDLPProfileGetResponseDLPIntegrationProfileTypeIntegration ZeroTrustDLPProfileGetResponseDLPIntegrationProfileType = "integration" -) - -type ZeroTrustDLPProfileListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustDLPProfileListResponseEnvelope struct { - Errors []ZeroTrustDLPProfileListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDLPProfileListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDLPProfileListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustDLPProfileListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDLPProfileListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDLPProfileListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDLPProfileListResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDLPProfileListResponseEnvelope] -type zeroTrustDLPProfileListResponseEnvelopeJSON 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 *ZeroTrustDLPProfileListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPProfileListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPProfileListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDLPProfileListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustDLPProfileListResponseEnvelopeErrors] -type zeroTrustDLPProfileListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPProfileListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPProfileListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDLPProfileListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDLPProfileListResponseEnvelopeMessages] -type zeroTrustDLPProfileListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDLPProfileListResponseEnvelopeSuccess bool - -const ( - ZeroTrustDLPProfileListResponseEnvelopeSuccessTrue ZeroTrustDLPProfileListResponseEnvelopeSuccess = true -) - -type ZeroTrustDLPProfileListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDLPProfileListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDLPProfileListResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [ZeroTrustDLPProfileListResponseEnvelopeResultInfo] -type zeroTrustDLPProfileListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPProfileGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustDLPProfileGetResponseEnvelope struct { - Errors []ZeroTrustDLPProfileGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDLPProfileGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDLPProfileGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustDLPProfileGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDLPProfileGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDLPProfileGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustDLPProfileGetResponseEnvelope] -type zeroTrustDLPProfileGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPProfileGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPProfileGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDLPProfileGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustDLPProfileGetResponseEnvelopeErrors] -type zeroTrustDLPProfileGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPProfileGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPProfileGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDLPProfileGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustDLPProfileGetResponseEnvelopeMessages] -type zeroTrustDLPProfileGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDLPProfileGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustDLPProfileGetResponseEnvelopeSuccessTrue ZeroTrustDLPProfileGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustdlpprofile_test.go b/zerotrustdlpprofile_test.go deleted file mode 100644 index d66c8ac2d20..00000000000 --- a/zerotrustdlpprofile_test.go +++ /dev/null @@ -1,70 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDLPProfileList(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("user@example.com"), - ) - _, err := client.ZeroTrust.DLP.Profiles.List(context.TODO(), cloudflare.ZeroTrustDLPProfileListParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestZeroTrustDLPProfileGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.DLP.Profiles.Get( - context.TODO(), - "384e129d-25bd-403c-8019-bc19eb7a8a5f", - cloudflare.ZeroTrustDLPProfileGetParams{ - AccountID: cloudflare.F("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/zerotrustdlpprofilecustom.go b/zerotrustdlpprofilecustom.go deleted file mode 100644 index 97e5a24e113..00000000000 --- a/zerotrustdlpprofilecustom.go +++ /dev/null @@ -1,1130 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustDLPProfileCustomService 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 -// [NewZeroTrustDLPProfileCustomService] method instead. -type ZeroTrustDLPProfileCustomService struct { - Options []option.RequestOption -} - -// NewZeroTrustDLPProfileCustomService 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 NewZeroTrustDLPProfileCustomService(opts ...option.RequestOption) (r *ZeroTrustDLPProfileCustomService) { - r = &ZeroTrustDLPProfileCustomService{} - r.Options = opts - return -} - -// Creates a set of DLP custom profiles. -func (r *ZeroTrustDLPProfileCustomService) New(ctx context.Context, params ZeroTrustDLPProfileCustomNewParams, opts ...option.RequestOption) (res *[]ZeroTrustDLPProfileCustomNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDLPProfileCustomNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/dlp/profiles/custom", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a DLP custom profile. -func (r *ZeroTrustDLPProfileCustomService) Update(ctx context.Context, profileID string, params ZeroTrustDLPProfileCustomUpdateParams, opts ...option.RequestOption) (res *ZeroTrustDLPProfileCustomUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("accounts/%s/dlp/profiles/custom/%s", params.AccountID, profileID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &res, opts...) - return -} - -// Deletes a DLP custom profile. -func (r *ZeroTrustDLPProfileCustomService) Delete(ctx context.Context, profileID string, body ZeroTrustDLPProfileCustomDeleteParams, opts ...option.RequestOption) (res *ZeroTrustDLPProfileCustomDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDLPProfileCustomDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/dlp/profiles/custom/%s", body.AccountID, profileID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a custom DLP profile. -func (r *ZeroTrustDLPProfileCustomService) Get(ctx context.Context, profileID string, query ZeroTrustDLPProfileCustomGetParams, opts ...option.RequestOption) (res *ZeroTrustDLPProfileCustomGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDLPProfileCustomGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/dlp/profiles/custom/%s", query.AccountID, profileID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDLPProfileCustomNewResponse struct { - // The ID for this profile - ID string `json:"id"` - // Related DLP policies will trigger when the match count exceeds the number set. - AllowedMatchCount float64 `json:"allowed_match_count"` - // Scan the context of predefined entries to only return matches surrounded by - // keywords. - ContextAwareness ZeroTrustDLPProfileCustomNewResponseContextAwareness `json:"context_awareness"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The description of the profile. - Description string `json:"description"` - // The entries for this profile. - Entries []ZeroTrustDLPProfileCustomNewResponseEntry `json:"entries"` - // The name of the profile. - Name string `json:"name"` - // The type of the profile. - Type ZeroTrustDLPProfileCustomNewResponseType `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustDLPProfileCustomNewResponseJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomNewResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDLPProfileCustomNewResponse] -type zeroTrustDLPProfileCustomNewResponseJSON struct { - ID apijson.Field - AllowedMatchCount apijson.Field - ContextAwareness apijson.Field - CreatedAt apijson.Field - Description apijson.Field - Entries apijson.Field - Name apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomNewResponseJSON) RawJSON() string { - return r.raw -} - -// Scan the context of predefined entries to only return matches surrounded by -// keywords. -type ZeroTrustDLPProfileCustomNewResponseContextAwareness struct { - // If true, scan the context of predefined entries to only return matches - // surrounded by keywords. - Enabled bool `json:"enabled,required"` - // Content types to exclude from context analysis and return all matches. - Skip ZeroTrustDLPProfileCustomNewResponseContextAwarenessSkip `json:"skip,required"` - JSON zeroTrustDLPProfileCustomNewResponseContextAwarenessJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomNewResponseContextAwarenessJSON contains the JSON -// metadata for the struct [ZeroTrustDLPProfileCustomNewResponseContextAwareness] -type zeroTrustDLPProfileCustomNewResponseContextAwarenessJSON struct { - Enabled apijson.Field - Skip apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomNewResponseContextAwareness) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomNewResponseContextAwarenessJSON) RawJSON() string { - return r.raw -} - -// Content types to exclude from context analysis and return all matches. -type ZeroTrustDLPProfileCustomNewResponseContextAwarenessSkip struct { - // If the content type is a file, skip context analysis and return all matches. - Files bool `json:"files,required"` - JSON zeroTrustDLPProfileCustomNewResponseContextAwarenessSkipJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomNewResponseContextAwarenessSkipJSON contains the JSON -// metadata for the struct -// [ZeroTrustDLPProfileCustomNewResponseContextAwarenessSkip] -type zeroTrustDLPProfileCustomNewResponseContextAwarenessSkipJSON struct { - Files apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomNewResponseContextAwarenessSkip) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomNewResponseContextAwarenessSkipJSON) RawJSON() string { - return r.raw -} - -// A custom entry that matches a profile -type ZeroTrustDLPProfileCustomNewResponseEntry struct { - // The ID for this entry - ID string `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Whether the entry is enabled or not. - Enabled bool `json:"enabled"` - // The name of the entry. - Name string `json:"name"` - // A pattern that matches an entry - Pattern ZeroTrustDLPProfileCustomNewResponseEntriesPattern `json:"pattern"` - // ID of the parent profile - ProfileID interface{} `json:"profile_id"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustDLPProfileCustomNewResponseEntryJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomNewResponseEntryJSON contains the JSON metadata for the -// struct [ZeroTrustDLPProfileCustomNewResponseEntry] -type zeroTrustDLPProfileCustomNewResponseEntryJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Enabled apijson.Field - Name apijson.Field - Pattern apijson.Field - ProfileID apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomNewResponseEntry) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomNewResponseEntryJSON) RawJSON() string { - return r.raw -} - -// A pattern that matches an entry -type ZeroTrustDLPProfileCustomNewResponseEntriesPattern struct { - // The regex pattern. - Regex string `json:"regex,required"` - // Validation algorithm for the pattern. This algorithm will get run on potential - // matches, and if it returns false, the entry will not be matched. - Validation ZeroTrustDLPProfileCustomNewResponseEntriesPatternValidation `json:"validation"` - JSON zeroTrustDLPProfileCustomNewResponseEntriesPatternJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomNewResponseEntriesPatternJSON contains the JSON -// metadata for the struct [ZeroTrustDLPProfileCustomNewResponseEntriesPattern] -type zeroTrustDLPProfileCustomNewResponseEntriesPatternJSON struct { - Regex apijson.Field - Validation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomNewResponseEntriesPattern) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomNewResponseEntriesPatternJSON) RawJSON() string { - return r.raw -} - -// Validation algorithm for the pattern. This algorithm will get run on potential -// matches, and if it returns false, the entry will not be matched. -type ZeroTrustDLPProfileCustomNewResponseEntriesPatternValidation string - -const ( - ZeroTrustDLPProfileCustomNewResponseEntriesPatternValidationLuhn ZeroTrustDLPProfileCustomNewResponseEntriesPatternValidation = "luhn" -) - -// The type of the profile. -type ZeroTrustDLPProfileCustomNewResponseType string - -const ( - ZeroTrustDLPProfileCustomNewResponseTypeCustom ZeroTrustDLPProfileCustomNewResponseType = "custom" -) - -type ZeroTrustDLPProfileCustomUpdateResponse struct { - // The ID for this profile - ID string `json:"id"` - // Related DLP policies will trigger when the match count exceeds the number set. - AllowedMatchCount float64 `json:"allowed_match_count"` - // Scan the context of predefined entries to only return matches surrounded by - // keywords. - ContextAwareness ZeroTrustDLPProfileCustomUpdateResponseContextAwareness `json:"context_awareness"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The description of the profile. - Description string `json:"description"` - // The entries for this profile. - Entries []ZeroTrustDLPProfileCustomUpdateResponseEntry `json:"entries"` - // The name of the profile. - Name string `json:"name"` - // The type of the profile. - Type ZeroTrustDLPProfileCustomUpdateResponseType `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustDLPProfileCustomUpdateResponseJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomUpdateResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDLPProfileCustomUpdateResponse] -type zeroTrustDLPProfileCustomUpdateResponseJSON struct { - ID apijson.Field - AllowedMatchCount apijson.Field - ContextAwareness apijson.Field - CreatedAt apijson.Field - Description apijson.Field - Entries apijson.Field - Name apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// Scan the context of predefined entries to only return matches surrounded by -// keywords. -type ZeroTrustDLPProfileCustomUpdateResponseContextAwareness struct { - // If true, scan the context of predefined entries to only return matches - // surrounded by keywords. - Enabled bool `json:"enabled,required"` - // Content types to exclude from context analysis and return all matches. - Skip ZeroTrustDLPProfileCustomUpdateResponseContextAwarenessSkip `json:"skip,required"` - JSON zeroTrustDLPProfileCustomUpdateResponseContextAwarenessJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomUpdateResponseContextAwarenessJSON contains the JSON -// metadata for the struct -// [ZeroTrustDLPProfileCustomUpdateResponseContextAwareness] -type zeroTrustDLPProfileCustomUpdateResponseContextAwarenessJSON struct { - Enabled apijson.Field - Skip apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomUpdateResponseContextAwareness) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomUpdateResponseContextAwarenessJSON) RawJSON() string { - return r.raw -} - -// Content types to exclude from context analysis and return all matches. -type ZeroTrustDLPProfileCustomUpdateResponseContextAwarenessSkip struct { - // If the content type is a file, skip context analysis and return all matches. - Files bool `json:"files,required"` - JSON zeroTrustDLPProfileCustomUpdateResponseContextAwarenessSkipJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomUpdateResponseContextAwarenessSkipJSON contains the -// JSON metadata for the struct -// [ZeroTrustDLPProfileCustomUpdateResponseContextAwarenessSkip] -type zeroTrustDLPProfileCustomUpdateResponseContextAwarenessSkipJSON struct { - Files apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomUpdateResponseContextAwarenessSkip) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomUpdateResponseContextAwarenessSkipJSON) RawJSON() string { - return r.raw -} - -// A custom entry that matches a profile -type ZeroTrustDLPProfileCustomUpdateResponseEntry struct { - // The ID for this entry - ID string `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Whether the entry is enabled or not. - Enabled bool `json:"enabled"` - // The name of the entry. - Name string `json:"name"` - // A pattern that matches an entry - Pattern ZeroTrustDLPProfileCustomUpdateResponseEntriesPattern `json:"pattern"` - // ID of the parent profile - ProfileID interface{} `json:"profile_id"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustDLPProfileCustomUpdateResponseEntryJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomUpdateResponseEntryJSON contains the JSON metadata for -// the struct [ZeroTrustDLPProfileCustomUpdateResponseEntry] -type zeroTrustDLPProfileCustomUpdateResponseEntryJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Enabled apijson.Field - Name apijson.Field - Pattern apijson.Field - ProfileID apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomUpdateResponseEntry) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomUpdateResponseEntryJSON) RawJSON() string { - return r.raw -} - -// A pattern that matches an entry -type ZeroTrustDLPProfileCustomUpdateResponseEntriesPattern struct { - // The regex pattern. - Regex string `json:"regex,required"` - // Validation algorithm for the pattern. This algorithm will get run on potential - // matches, and if it returns false, the entry will not be matched. - Validation ZeroTrustDLPProfileCustomUpdateResponseEntriesPatternValidation `json:"validation"` - JSON zeroTrustDLPProfileCustomUpdateResponseEntriesPatternJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomUpdateResponseEntriesPatternJSON contains the JSON -// metadata for the struct [ZeroTrustDLPProfileCustomUpdateResponseEntriesPattern] -type zeroTrustDLPProfileCustomUpdateResponseEntriesPatternJSON struct { - Regex apijson.Field - Validation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomUpdateResponseEntriesPattern) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomUpdateResponseEntriesPatternJSON) RawJSON() string { - return r.raw -} - -// Validation algorithm for the pattern. This algorithm will get run on potential -// matches, and if it returns false, the entry will not be matched. -type ZeroTrustDLPProfileCustomUpdateResponseEntriesPatternValidation string - -const ( - ZeroTrustDLPProfileCustomUpdateResponseEntriesPatternValidationLuhn ZeroTrustDLPProfileCustomUpdateResponseEntriesPatternValidation = "luhn" -) - -// The type of the profile. -type ZeroTrustDLPProfileCustomUpdateResponseType string - -const ( - ZeroTrustDLPProfileCustomUpdateResponseTypeCustom ZeroTrustDLPProfileCustomUpdateResponseType = "custom" -) - -// Union satisfied by [ZeroTrustDLPProfileCustomDeleteResponseUnknown] or -// [shared.UnionString]. -type ZeroTrustDLPProfileCustomDeleteResponse interface { - ImplementsZeroTrustDLPProfileCustomDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustDLPProfileCustomDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustDLPProfileCustomGetResponse struct { - // The ID for this profile - ID string `json:"id"` - // Related DLP policies will trigger when the match count exceeds the number set. - AllowedMatchCount float64 `json:"allowed_match_count"` - // Scan the context of predefined entries to only return matches surrounded by - // keywords. - ContextAwareness ZeroTrustDLPProfileCustomGetResponseContextAwareness `json:"context_awareness"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The description of the profile. - Description string `json:"description"` - // The entries for this profile. - Entries []ZeroTrustDLPProfileCustomGetResponseEntry `json:"entries"` - // The name of the profile. - Name string `json:"name"` - // The type of the profile. - Type ZeroTrustDLPProfileCustomGetResponseType `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustDLPProfileCustomGetResponseJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomGetResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDLPProfileCustomGetResponse] -type zeroTrustDLPProfileCustomGetResponseJSON struct { - ID apijson.Field - AllowedMatchCount apijson.Field - ContextAwareness apijson.Field - CreatedAt apijson.Field - Description apijson.Field - Entries apijson.Field - Name apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomGetResponseJSON) RawJSON() string { - return r.raw -} - -// Scan the context of predefined entries to only return matches surrounded by -// keywords. -type ZeroTrustDLPProfileCustomGetResponseContextAwareness struct { - // If true, scan the context of predefined entries to only return matches - // surrounded by keywords. - Enabled bool `json:"enabled,required"` - // Content types to exclude from context analysis and return all matches. - Skip ZeroTrustDLPProfileCustomGetResponseContextAwarenessSkip `json:"skip,required"` - JSON zeroTrustDLPProfileCustomGetResponseContextAwarenessJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomGetResponseContextAwarenessJSON contains the JSON -// metadata for the struct [ZeroTrustDLPProfileCustomGetResponseContextAwareness] -type zeroTrustDLPProfileCustomGetResponseContextAwarenessJSON struct { - Enabled apijson.Field - Skip apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomGetResponseContextAwareness) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomGetResponseContextAwarenessJSON) RawJSON() string { - return r.raw -} - -// Content types to exclude from context analysis and return all matches. -type ZeroTrustDLPProfileCustomGetResponseContextAwarenessSkip struct { - // If the content type is a file, skip context analysis and return all matches. - Files bool `json:"files,required"` - JSON zeroTrustDLPProfileCustomGetResponseContextAwarenessSkipJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomGetResponseContextAwarenessSkipJSON contains the JSON -// metadata for the struct -// [ZeroTrustDLPProfileCustomGetResponseContextAwarenessSkip] -type zeroTrustDLPProfileCustomGetResponseContextAwarenessSkipJSON struct { - Files apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomGetResponseContextAwarenessSkip) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomGetResponseContextAwarenessSkipJSON) RawJSON() string { - return r.raw -} - -// A custom entry that matches a profile -type ZeroTrustDLPProfileCustomGetResponseEntry struct { - // The ID for this entry - ID string `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Whether the entry is enabled or not. - Enabled bool `json:"enabled"` - // The name of the entry. - Name string `json:"name"` - // A pattern that matches an entry - Pattern ZeroTrustDLPProfileCustomGetResponseEntriesPattern `json:"pattern"` - // ID of the parent profile - ProfileID interface{} `json:"profile_id"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustDLPProfileCustomGetResponseEntryJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomGetResponseEntryJSON contains the JSON metadata for the -// struct [ZeroTrustDLPProfileCustomGetResponseEntry] -type zeroTrustDLPProfileCustomGetResponseEntryJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Enabled apijson.Field - Name apijson.Field - Pattern apijson.Field - ProfileID apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomGetResponseEntry) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomGetResponseEntryJSON) RawJSON() string { - return r.raw -} - -// A pattern that matches an entry -type ZeroTrustDLPProfileCustomGetResponseEntriesPattern struct { - // The regex pattern. - Regex string `json:"regex,required"` - // Validation algorithm for the pattern. This algorithm will get run on potential - // matches, and if it returns false, the entry will not be matched. - Validation ZeroTrustDLPProfileCustomGetResponseEntriesPatternValidation `json:"validation"` - JSON zeroTrustDLPProfileCustomGetResponseEntriesPatternJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomGetResponseEntriesPatternJSON contains the JSON -// metadata for the struct [ZeroTrustDLPProfileCustomGetResponseEntriesPattern] -type zeroTrustDLPProfileCustomGetResponseEntriesPatternJSON struct { - Regex apijson.Field - Validation apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomGetResponseEntriesPattern) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomGetResponseEntriesPatternJSON) RawJSON() string { - return r.raw -} - -// Validation algorithm for the pattern. This algorithm will get run on potential -// matches, and if it returns false, the entry will not be matched. -type ZeroTrustDLPProfileCustomGetResponseEntriesPatternValidation string - -const ( - ZeroTrustDLPProfileCustomGetResponseEntriesPatternValidationLuhn ZeroTrustDLPProfileCustomGetResponseEntriesPatternValidation = "luhn" -) - -// The type of the profile. -type ZeroTrustDLPProfileCustomGetResponseType string - -const ( - ZeroTrustDLPProfileCustomGetResponseTypeCustom ZeroTrustDLPProfileCustomGetResponseType = "custom" -) - -type ZeroTrustDLPProfileCustomNewParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Profiles param.Field[[]ZeroTrustDLPProfileCustomNewParamsProfile] `json:"profiles,required"` -} - -func (r ZeroTrustDLPProfileCustomNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDLPProfileCustomNewParamsProfile struct { - // Related DLP policies will trigger when the match count exceeds the number set. - AllowedMatchCount param.Field[float64] `json:"allowed_match_count"` - // Scan the context of predefined entries to only return matches surrounded by - // keywords. - ContextAwareness param.Field[ZeroTrustDLPProfileCustomNewParamsProfilesContextAwareness] `json:"context_awareness"` - // The description of the profile. - Description param.Field[string] `json:"description"` - // The entries for this profile. - Entries param.Field[[]ZeroTrustDLPProfileCustomNewParamsProfilesEntry] `json:"entries"` - // The name of the profile. - Name param.Field[string] `json:"name"` -} - -func (r ZeroTrustDLPProfileCustomNewParamsProfile) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Scan the context of predefined entries to only return matches surrounded by -// keywords. -type ZeroTrustDLPProfileCustomNewParamsProfilesContextAwareness struct { - // If true, scan the context of predefined entries to only return matches - // surrounded by keywords. - Enabled param.Field[bool] `json:"enabled,required"` - // Content types to exclude from context analysis and return all matches. - Skip param.Field[ZeroTrustDLPProfileCustomNewParamsProfilesContextAwarenessSkip] `json:"skip,required"` -} - -func (r ZeroTrustDLPProfileCustomNewParamsProfilesContextAwareness) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Content types to exclude from context analysis and return all matches. -type ZeroTrustDLPProfileCustomNewParamsProfilesContextAwarenessSkip struct { - // If the content type is a file, skip context analysis and return all matches. - Files param.Field[bool] `json:"files,required"` -} - -func (r ZeroTrustDLPProfileCustomNewParamsProfilesContextAwarenessSkip) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A custom entry create payload -type ZeroTrustDLPProfileCustomNewParamsProfilesEntry struct { - // Whether the entry is enabled or not. - Enabled param.Field[bool] `json:"enabled,required"` - // The name of the entry. - Name param.Field[string] `json:"name,required"` - // A pattern that matches an entry - Pattern param.Field[ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPattern] `json:"pattern,required"` -} - -func (r ZeroTrustDLPProfileCustomNewParamsProfilesEntry) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A pattern that matches an entry -type ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPattern struct { - // The regex pattern. - Regex param.Field[string] `json:"regex,required"` - // Validation algorithm for the pattern. This algorithm will get run on potential - // matches, and if it returns false, the entry will not be matched. - Validation param.Field[ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPatternValidation] `json:"validation"` -} - -func (r ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPattern) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Validation algorithm for the pattern. This algorithm will get run on potential -// matches, and if it returns false, the entry will not be matched. -type ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPatternValidation string - -const ( - ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPatternValidation = "luhn" -) - -type ZeroTrustDLPProfileCustomNewResponseEnvelope struct { - Errors []ZeroTrustDLPProfileCustomNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDLPProfileCustomNewResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustDLPProfileCustomNewResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustDLPProfileCustomNewResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustDLPProfileCustomNewResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustDLPProfileCustomNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDLPProfileCustomNewResponseEnvelope] -type zeroTrustDLPProfileCustomNewResponseEnvelopeJSON 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 *ZeroTrustDLPProfileCustomNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPProfileCustomNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPProfileCustomNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDLPProfileCustomNewResponseEnvelopeErrors] -type zeroTrustDLPProfileCustomNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPProfileCustomNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPProfileCustomNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDLPProfileCustomNewResponseEnvelopeMessages] -type zeroTrustDLPProfileCustomNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDLPProfileCustomNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustDLPProfileCustomNewResponseEnvelopeSuccessTrue ZeroTrustDLPProfileCustomNewResponseEnvelopeSuccess = true -) - -type ZeroTrustDLPProfileCustomNewResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustDLPProfileCustomNewResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomNewResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustDLPProfileCustomNewResponseEnvelopeResultInfo] -type zeroTrustDLPProfileCustomNewResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomNewResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomNewResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPProfileCustomUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Related DLP policies will trigger when the match count exceeds the number set. - AllowedMatchCount param.Field[float64] `json:"allowed_match_count"` - // Scan the context of predefined entries to only return matches surrounded by - // keywords. - ContextAwareness param.Field[ZeroTrustDLPProfileCustomUpdateParamsContextAwareness] `json:"context_awareness"` - // The description of the profile. - Description param.Field[string] `json:"description"` - // The custom entries for this profile. Array elements with IDs are modifying the - // existing entry with that ID. Elements without ID will create new entries. Any - // entry not in the list will be deleted. - Entries param.Field[[]ZeroTrustDLPProfileCustomUpdateParamsEntry] `json:"entries"` - // The name of the profile. - Name param.Field[string] `json:"name"` - // Entries from other profiles (e.g. pre-defined Cloudflare profiles, or your - // Microsoft Information Protection profiles). - SharedEntries param.Field[[]ZeroTrustDLPProfileCustomUpdateParamsSharedEntry] `json:"shared_entries"` -} - -func (r ZeroTrustDLPProfileCustomUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Scan the context of predefined entries to only return matches surrounded by -// keywords. -type ZeroTrustDLPProfileCustomUpdateParamsContextAwareness struct { - // If true, scan the context of predefined entries to only return matches - // surrounded by keywords. - Enabled param.Field[bool] `json:"enabled,required"` - // Content types to exclude from context analysis and return all matches. - Skip param.Field[ZeroTrustDLPProfileCustomUpdateParamsContextAwarenessSkip] `json:"skip,required"` -} - -func (r ZeroTrustDLPProfileCustomUpdateParamsContextAwareness) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Content types to exclude from context analysis and return all matches. -type ZeroTrustDLPProfileCustomUpdateParamsContextAwarenessSkip struct { - // If the content type is a file, skip context analysis and return all matches. - Files param.Field[bool] `json:"files,required"` -} - -func (r ZeroTrustDLPProfileCustomUpdateParamsContextAwarenessSkip) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A custom entry that matches a profile -type ZeroTrustDLPProfileCustomUpdateParamsEntry struct { - // Whether the entry is enabled or not. - Enabled param.Field[bool] `json:"enabled"` - // The name of the entry. - Name param.Field[string] `json:"name"` - // A pattern that matches an entry - Pattern param.Field[ZeroTrustDLPProfileCustomUpdateParamsEntriesPattern] `json:"pattern"` - // ID of the parent profile - ProfileID param.Field[interface{}] `json:"profile_id"` -} - -func (r ZeroTrustDLPProfileCustomUpdateParamsEntry) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A pattern that matches an entry -type ZeroTrustDLPProfileCustomUpdateParamsEntriesPattern struct { - // The regex pattern. - Regex param.Field[string] `json:"regex,required"` - // Validation algorithm for the pattern. This algorithm will get run on potential - // matches, and if it returns false, the entry will not be matched. - Validation param.Field[ZeroTrustDLPProfileCustomUpdateParamsEntriesPatternValidation] `json:"validation"` -} - -func (r ZeroTrustDLPProfileCustomUpdateParamsEntriesPattern) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Validation algorithm for the pattern. This algorithm will get run on potential -// matches, and if it returns false, the entry will not be matched. -type ZeroTrustDLPProfileCustomUpdateParamsEntriesPatternValidation string - -const ( - ZeroTrustDLPProfileCustomUpdateParamsEntriesPatternValidationLuhn ZeroTrustDLPProfileCustomUpdateParamsEntriesPatternValidation = "luhn" -) - -// Properties of a predefined entry in a custom profile -// -// Satisfied by -// [ZeroTrustDLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined], -// [ZeroTrustDLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdateIntegration]. -type ZeroTrustDLPProfileCustomUpdateParamsSharedEntry interface { - implementsZeroTrustDLPProfileCustomUpdateParamsSharedEntry() -} - -// Properties of a predefined entry in a custom profile -type ZeroTrustDLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined struct { - // Whether the entry is enabled or not. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ZeroTrustDLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined) implementsZeroTrustDLPProfileCustomUpdateParamsSharedEntry() { -} - -// Properties of an integration entry in a custom profile -type ZeroTrustDLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdateIntegration struct { - // Whether the entry is enabled or not. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ZeroTrustDLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdateIntegration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZeroTrustDLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdateIntegration) implementsZeroTrustDLPProfileCustomUpdateParamsSharedEntry() { -} - -type ZeroTrustDLPProfileCustomDeleteParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustDLPProfileCustomDeleteResponseEnvelope struct { - Errors []ZeroTrustDLPProfileCustomDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDLPProfileCustomDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDLPProfileCustomDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustDLPProfileCustomDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDLPProfileCustomDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomDeleteResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustDLPProfileCustomDeleteResponseEnvelope] -type zeroTrustDLPProfileCustomDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPProfileCustomDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPProfileCustomDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDLPProfileCustomDeleteResponseEnvelopeErrors] -type zeroTrustDLPProfileCustomDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPProfileCustomDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPProfileCustomDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustDLPProfileCustomDeleteResponseEnvelopeMessages] -type zeroTrustDLPProfileCustomDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDLPProfileCustomDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustDLPProfileCustomDeleteResponseEnvelopeSuccessTrue ZeroTrustDLPProfileCustomDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustDLPProfileCustomGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustDLPProfileCustomGetResponseEnvelope struct { - Errors []ZeroTrustDLPProfileCustomGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDLPProfileCustomGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDLPProfileCustomGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustDLPProfileCustomGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDLPProfileCustomGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustDLPProfileCustomGetResponseEnvelope] -type zeroTrustDLPProfileCustomGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPProfileCustomGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPProfileCustomGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDLPProfileCustomGetResponseEnvelopeErrors] -type zeroTrustDLPProfileCustomGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPProfileCustomGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPProfileCustomGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDLPProfileCustomGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustDLPProfileCustomGetResponseEnvelopeMessages] -type zeroTrustDLPProfileCustomGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfileCustomGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfileCustomGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDLPProfileCustomGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustDLPProfileCustomGetResponseEnvelopeSuccessTrue ZeroTrustDLPProfileCustomGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustdlpprofilecustom_test.go b/zerotrustdlpprofilecustom_test.go deleted file mode 100644 index c26238146bc..00000000000 --- a/zerotrustdlpprofilecustom_test.go +++ /dev/null @@ -1,268 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDLPProfileCustomNew(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("user@example.com"), - ) - _, err := client.ZeroTrust.DLP.Profiles.Customs.New(context.TODO(), cloudflare.ZeroTrustDLPProfileCustomNewParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Profiles: cloudflare.F([]cloudflare.ZeroTrustDLPProfileCustomNewParamsProfile{{ - AllowedMatchCount: cloudflare.F(5.000000), - ContextAwareness: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesContextAwareness{ - Enabled: cloudflare.F(true), - Skip: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesContextAwarenessSkip{ - Files: cloudflare.F(true), - }), - }), - Description: cloudflare.F("A standard CVV card number"), - Entries: cloudflare.F([]cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntry{{ - Enabled: cloudflare.F(true), - Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPattern{ - Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), - }), - }, { - Enabled: cloudflare.F(true), - Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPattern{ - Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), - }), - }, { - Enabled: cloudflare.F(true), - Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPattern{ - Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), - }), - }}), - Name: cloudflare.F("Generic CVV Card Number"), - }, { - AllowedMatchCount: cloudflare.F(5.000000), - ContextAwareness: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesContextAwareness{ - Enabled: cloudflare.F(true), - Skip: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesContextAwarenessSkip{ - Files: cloudflare.F(true), - }), - }), - Description: cloudflare.F("A standard CVV card number"), - Entries: cloudflare.F([]cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntry{{ - Enabled: cloudflare.F(true), - Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPattern{ - Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), - }), - }, { - Enabled: cloudflare.F(true), - Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPattern{ - Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), - }), - }, { - Enabled: cloudflare.F(true), - Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPattern{ - Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), - }), - }}), - Name: cloudflare.F("Generic CVV Card Number"), - }, { - AllowedMatchCount: cloudflare.F(5.000000), - ContextAwareness: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesContextAwareness{ - Enabled: cloudflare.F(true), - Skip: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesContextAwarenessSkip{ - Files: cloudflare.F(true), - }), - }), - Description: cloudflare.F("A standard CVV card number"), - Entries: cloudflare.F([]cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntry{{ - Enabled: cloudflare.F(true), - Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPattern{ - Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), - }), - }, { - Enabled: cloudflare.F(true), - Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPattern{ - Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), - }), - }, { - Enabled: cloudflare.F(true), - Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPattern{ - Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomNewParamsProfilesEntriesPatternValidationLuhn), - }), - }}), - Name: cloudflare.F("Generic CVV Card Number"), - }}), - }) - 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 TestZeroTrustDLPProfileCustomUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.DLP.Profiles.Customs.Update( - context.TODO(), - "384e129d-25bd-403c-8019-bc19eb7a8a5f", - cloudflare.ZeroTrustDLPProfileCustomUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - AllowedMatchCount: cloudflare.F(5.000000), - ContextAwareness: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomUpdateParamsContextAwareness{ - Enabled: cloudflare.F(true), - Skip: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomUpdateParamsContextAwarenessSkip{ - Files: cloudflare.F(true), - }), - }), - Description: cloudflare.F("A standard CVV card number"), - Entries: cloudflare.F([]cloudflare.ZeroTrustDLPProfileCustomUpdateParamsEntry{{ - Enabled: cloudflare.F(true), - Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomUpdateParamsEntriesPattern{ - Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomUpdateParamsEntriesPatternValidationLuhn), - }), - ProfileID: cloudflare.F[any](map[string]interface{}{}), - }, { - Enabled: cloudflare.F(true), - Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomUpdateParamsEntriesPattern{ - Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomUpdateParamsEntriesPatternValidationLuhn), - }), - ProfileID: cloudflare.F[any](map[string]interface{}{}), - }, { - Enabled: cloudflare.F(true), - Name: cloudflare.F("Credit card (Visa)"), - Pattern: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomUpdateParamsEntriesPattern{ - Regex: cloudflare.F("^4[0-9]{6,14}$"), - Validation: cloudflare.F(cloudflare.ZeroTrustDLPProfileCustomUpdateParamsEntriesPatternValidationLuhn), - }), - ProfileID: cloudflare.F[any](map[string]interface{}{}), - }}), - Name: cloudflare.F("Generic CVV Card Number"), - SharedEntries: cloudflare.F([]cloudflare.ZeroTrustDLPProfileCustomUpdateParamsSharedEntry{cloudflare.ZeroTrustDLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined(cloudflare.ZeroTrustDLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined{ - Enabled: cloudflare.F(true), - }), cloudflare.ZeroTrustDLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined(cloudflare.ZeroTrustDLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined{ - Enabled: cloudflare.F(true), - }), cloudflare.ZeroTrustDLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined(cloudflare.ZeroTrustDLPProfileCustomUpdateParamsSharedEntriesDLPSharedEntryUpdatePredefined{ - Enabled: cloudflare.F(true), - })}), - }, - ) - 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 TestZeroTrustDLPProfileCustomDelete(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("user@example.com"), - ) - _, err := client.ZeroTrust.DLP.Profiles.Customs.Delete( - context.TODO(), - "384e129d-25bd-403c-8019-bc19eb7a8a5f", - cloudflare.ZeroTrustDLPProfileCustomDeleteParams{ - AccountID: cloudflare.F("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()) - } -} - -func TestZeroTrustDLPProfileCustomGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.DLP.Profiles.Customs.Get( - context.TODO(), - "384e129d-25bd-403c-8019-bc19eb7a8a5f", - cloudflare.ZeroTrustDLPProfileCustomGetParams{ - AccountID: cloudflare.F("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/zerotrustdlpprofilepredefined.go b/zerotrustdlpprofilepredefined.go deleted file mode 100644 index 07057200f51..00000000000 --- a/zerotrustdlpprofilepredefined.go +++ /dev/null @@ -1,449 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustDLPProfilePredefinedService 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 -// [NewZeroTrustDLPProfilePredefinedService] method instead. -type ZeroTrustDLPProfilePredefinedService struct { - Options []option.RequestOption -} - -// NewZeroTrustDLPProfilePredefinedService 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 NewZeroTrustDLPProfilePredefinedService(opts ...option.RequestOption) (r *ZeroTrustDLPProfilePredefinedService) { - r = &ZeroTrustDLPProfilePredefinedService{} - r.Options = opts - return -} - -// Updates a DLP predefined profile. Only supports enabling/disabling entries. -func (r *ZeroTrustDLPProfilePredefinedService) Update(ctx context.Context, profileID string, params ZeroTrustDLPProfilePredefinedUpdateParams, opts ...option.RequestOption) (res *ZeroTrustDLPProfilePredefinedUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - path := fmt.Sprintf("accounts/%s/dlp/profiles/predefined/%s", params.AccountID, profileID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &res, opts...) - return -} - -// Fetches a predefined DLP profile. -func (r *ZeroTrustDLPProfilePredefinedService) Get(ctx context.Context, profileID string, query ZeroTrustDLPProfilePredefinedGetParams, opts ...option.RequestOption) (res *ZeroTrustDLPProfilePredefinedGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustDLPProfilePredefinedGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/dlp/profiles/predefined/%s", query.AccountID, profileID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustDLPProfilePredefinedUpdateResponse struct { - // The ID for this profile - ID string `json:"id"` - // Related DLP policies will trigger when the match count exceeds the number set. - AllowedMatchCount float64 `json:"allowed_match_count"` - // Scan the context of predefined entries to only return matches surrounded by - // keywords. - ContextAwareness ZeroTrustDLPProfilePredefinedUpdateResponseContextAwareness `json:"context_awareness"` - // The entries for this profile. - Entries []ZeroTrustDLPProfilePredefinedUpdateResponseEntry `json:"entries"` - // The name of the profile. - Name string `json:"name"` - // The type of the profile. - Type ZeroTrustDLPProfilePredefinedUpdateResponseType `json:"type"` - JSON zeroTrustDLPProfilePredefinedUpdateResponseJSON `json:"-"` -} - -// zeroTrustDLPProfilePredefinedUpdateResponseJSON contains the JSON metadata for -// the struct [ZeroTrustDLPProfilePredefinedUpdateResponse] -type zeroTrustDLPProfilePredefinedUpdateResponseJSON struct { - ID apijson.Field - AllowedMatchCount apijson.Field - ContextAwareness apijson.Field - Entries apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfilePredefinedUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfilePredefinedUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// Scan the context of predefined entries to only return matches surrounded by -// keywords. -type ZeroTrustDLPProfilePredefinedUpdateResponseContextAwareness struct { - // If true, scan the context of predefined entries to only return matches - // surrounded by keywords. - Enabled bool `json:"enabled,required"` - // Content types to exclude from context analysis and return all matches. - Skip ZeroTrustDLPProfilePredefinedUpdateResponseContextAwarenessSkip `json:"skip,required"` - JSON zeroTrustDLPProfilePredefinedUpdateResponseContextAwarenessJSON `json:"-"` -} - -// zeroTrustDLPProfilePredefinedUpdateResponseContextAwarenessJSON contains the -// JSON metadata for the struct -// [ZeroTrustDLPProfilePredefinedUpdateResponseContextAwareness] -type zeroTrustDLPProfilePredefinedUpdateResponseContextAwarenessJSON struct { - Enabled apijson.Field - Skip apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfilePredefinedUpdateResponseContextAwareness) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfilePredefinedUpdateResponseContextAwarenessJSON) RawJSON() string { - return r.raw -} - -// Content types to exclude from context analysis and return all matches. -type ZeroTrustDLPProfilePredefinedUpdateResponseContextAwarenessSkip struct { - // If the content type is a file, skip context analysis and return all matches. - Files bool `json:"files,required"` - JSON zeroTrustDLPProfilePredefinedUpdateResponseContextAwarenessSkipJSON `json:"-"` -} - -// zeroTrustDLPProfilePredefinedUpdateResponseContextAwarenessSkipJSON contains the -// JSON metadata for the struct -// [ZeroTrustDLPProfilePredefinedUpdateResponseContextAwarenessSkip] -type zeroTrustDLPProfilePredefinedUpdateResponseContextAwarenessSkipJSON struct { - Files apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfilePredefinedUpdateResponseContextAwarenessSkip) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfilePredefinedUpdateResponseContextAwarenessSkipJSON) RawJSON() string { - return r.raw -} - -// A predefined entry that matches a profile -type ZeroTrustDLPProfilePredefinedUpdateResponseEntry struct { - // The ID for this entry - ID string `json:"id"` - // Whether the entry is enabled or not. - Enabled bool `json:"enabled"` - // The name of the entry. - Name string `json:"name"` - // ID of the parent profile - ProfileID interface{} `json:"profile_id"` - JSON zeroTrustDLPProfilePredefinedUpdateResponseEntryJSON `json:"-"` -} - -// zeroTrustDLPProfilePredefinedUpdateResponseEntryJSON contains the JSON metadata -// for the struct [ZeroTrustDLPProfilePredefinedUpdateResponseEntry] -type zeroTrustDLPProfilePredefinedUpdateResponseEntryJSON struct { - ID apijson.Field - Enabled apijson.Field - Name apijson.Field - ProfileID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfilePredefinedUpdateResponseEntry) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfilePredefinedUpdateResponseEntryJSON) RawJSON() string { - return r.raw -} - -// The type of the profile. -type ZeroTrustDLPProfilePredefinedUpdateResponseType string - -const ( - ZeroTrustDLPProfilePredefinedUpdateResponseTypePredefined ZeroTrustDLPProfilePredefinedUpdateResponseType = "predefined" -) - -type ZeroTrustDLPProfilePredefinedGetResponse struct { - // The ID for this profile - ID string `json:"id"` - // Related DLP policies will trigger when the match count exceeds the number set. - AllowedMatchCount float64 `json:"allowed_match_count"` - // Scan the context of predefined entries to only return matches surrounded by - // keywords. - ContextAwareness ZeroTrustDLPProfilePredefinedGetResponseContextAwareness `json:"context_awareness"` - // The entries for this profile. - Entries []ZeroTrustDLPProfilePredefinedGetResponseEntry `json:"entries"` - // The name of the profile. - Name string `json:"name"` - // The type of the profile. - Type ZeroTrustDLPProfilePredefinedGetResponseType `json:"type"` - JSON zeroTrustDLPProfilePredefinedGetResponseJSON `json:"-"` -} - -// zeroTrustDLPProfilePredefinedGetResponseJSON contains the JSON metadata for the -// struct [ZeroTrustDLPProfilePredefinedGetResponse] -type zeroTrustDLPProfilePredefinedGetResponseJSON struct { - ID apijson.Field - AllowedMatchCount apijson.Field - ContextAwareness apijson.Field - Entries apijson.Field - Name apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfilePredefinedGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfilePredefinedGetResponseJSON) RawJSON() string { - return r.raw -} - -// Scan the context of predefined entries to only return matches surrounded by -// keywords. -type ZeroTrustDLPProfilePredefinedGetResponseContextAwareness struct { - // If true, scan the context of predefined entries to only return matches - // surrounded by keywords. - Enabled bool `json:"enabled,required"` - // Content types to exclude from context analysis and return all matches. - Skip ZeroTrustDLPProfilePredefinedGetResponseContextAwarenessSkip `json:"skip,required"` - JSON zeroTrustDLPProfilePredefinedGetResponseContextAwarenessJSON `json:"-"` -} - -// zeroTrustDLPProfilePredefinedGetResponseContextAwarenessJSON contains the JSON -// metadata for the struct -// [ZeroTrustDLPProfilePredefinedGetResponseContextAwareness] -type zeroTrustDLPProfilePredefinedGetResponseContextAwarenessJSON struct { - Enabled apijson.Field - Skip apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfilePredefinedGetResponseContextAwareness) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfilePredefinedGetResponseContextAwarenessJSON) RawJSON() string { - return r.raw -} - -// Content types to exclude from context analysis and return all matches. -type ZeroTrustDLPProfilePredefinedGetResponseContextAwarenessSkip struct { - // If the content type is a file, skip context analysis and return all matches. - Files bool `json:"files,required"` - JSON zeroTrustDLPProfilePredefinedGetResponseContextAwarenessSkipJSON `json:"-"` -} - -// zeroTrustDLPProfilePredefinedGetResponseContextAwarenessSkipJSON contains the -// JSON metadata for the struct -// [ZeroTrustDLPProfilePredefinedGetResponseContextAwarenessSkip] -type zeroTrustDLPProfilePredefinedGetResponseContextAwarenessSkipJSON struct { - Files apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfilePredefinedGetResponseContextAwarenessSkip) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfilePredefinedGetResponseContextAwarenessSkipJSON) RawJSON() string { - return r.raw -} - -// A predefined entry that matches a profile -type ZeroTrustDLPProfilePredefinedGetResponseEntry struct { - // The ID for this entry - ID string `json:"id"` - // Whether the entry is enabled or not. - Enabled bool `json:"enabled"` - // The name of the entry. - Name string `json:"name"` - // ID of the parent profile - ProfileID interface{} `json:"profile_id"` - JSON zeroTrustDLPProfilePredefinedGetResponseEntryJSON `json:"-"` -} - -// zeroTrustDLPProfilePredefinedGetResponseEntryJSON contains the JSON metadata for -// the struct [ZeroTrustDLPProfilePredefinedGetResponseEntry] -type zeroTrustDLPProfilePredefinedGetResponseEntryJSON struct { - ID apijson.Field - Enabled apijson.Field - Name apijson.Field - ProfileID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfilePredefinedGetResponseEntry) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfilePredefinedGetResponseEntryJSON) RawJSON() string { - return r.raw -} - -// The type of the profile. -type ZeroTrustDLPProfilePredefinedGetResponseType string - -const ( - ZeroTrustDLPProfilePredefinedGetResponseTypePredefined ZeroTrustDLPProfilePredefinedGetResponseType = "predefined" -) - -type ZeroTrustDLPProfilePredefinedUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // Related DLP policies will trigger when the match count exceeds the number set. - AllowedMatchCount param.Field[float64] `json:"allowed_match_count"` - // Scan the context of predefined entries to only return matches surrounded by - // keywords. - ContextAwareness param.Field[ZeroTrustDLPProfilePredefinedUpdateParamsContextAwareness] `json:"context_awareness"` - // The entries for this profile. - Entries param.Field[[]ZeroTrustDLPProfilePredefinedUpdateParamsEntry] `json:"entries"` -} - -func (r ZeroTrustDLPProfilePredefinedUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Scan the context of predefined entries to only return matches surrounded by -// keywords. -type ZeroTrustDLPProfilePredefinedUpdateParamsContextAwareness struct { - // If true, scan the context of predefined entries to only return matches - // surrounded by keywords. - Enabled param.Field[bool] `json:"enabled,required"` - // Content types to exclude from context analysis and return all matches. - Skip param.Field[ZeroTrustDLPProfilePredefinedUpdateParamsContextAwarenessSkip] `json:"skip,required"` -} - -func (r ZeroTrustDLPProfilePredefinedUpdateParamsContextAwareness) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Content types to exclude from context analysis and return all matches. -type ZeroTrustDLPProfilePredefinedUpdateParamsContextAwarenessSkip struct { - // If the content type is a file, skip context analysis and return all matches. - Files param.Field[bool] `json:"files,required"` -} - -func (r ZeroTrustDLPProfilePredefinedUpdateParamsContextAwarenessSkip) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDLPProfilePredefinedUpdateParamsEntry struct { - // Whether the entry is enabled or not. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ZeroTrustDLPProfilePredefinedUpdateParamsEntry) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustDLPProfilePredefinedGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustDLPProfilePredefinedGetResponseEnvelope struct { - Errors []ZeroTrustDLPProfilePredefinedGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustDLPProfilePredefinedGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustDLPProfilePredefinedGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustDLPProfilePredefinedGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustDLPProfilePredefinedGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustDLPProfilePredefinedGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustDLPProfilePredefinedGetResponseEnvelope] -type zeroTrustDLPProfilePredefinedGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfilePredefinedGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfilePredefinedGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPProfilePredefinedGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPProfilePredefinedGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustDLPProfilePredefinedGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustDLPProfilePredefinedGetResponseEnvelopeErrors] -type zeroTrustDLPProfilePredefinedGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfilePredefinedGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfilePredefinedGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustDLPProfilePredefinedGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustDLPProfilePredefinedGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustDLPProfilePredefinedGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustDLPProfilePredefinedGetResponseEnvelopeMessages] -type zeroTrustDLPProfilePredefinedGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustDLPProfilePredefinedGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustDLPProfilePredefinedGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustDLPProfilePredefinedGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustDLPProfilePredefinedGetResponseEnvelopeSuccessTrue ZeroTrustDLPProfilePredefinedGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustdlpprofilepredefined_test.go b/zerotrustdlpprofilepredefined_test.go deleted file mode 100644 index 22de370fd33..00000000000 --- a/zerotrustdlpprofilepredefined_test.go +++ /dev/null @@ -1,88 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustDLPProfilePredefinedUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.DLP.Profiles.Predefineds.Update( - context.TODO(), - "384e129d-25bd-403c-8019-bc19eb7a8a5f", - cloudflare.ZeroTrustDLPProfilePredefinedUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - AllowedMatchCount: cloudflare.F(5.000000), - ContextAwareness: cloudflare.F(cloudflare.ZeroTrustDLPProfilePredefinedUpdateParamsContextAwareness{ - Enabled: cloudflare.F(true), - Skip: cloudflare.F(cloudflare.ZeroTrustDLPProfilePredefinedUpdateParamsContextAwarenessSkip{ - Files: cloudflare.F(true), - }), - }), - Entries: cloudflare.F([]cloudflare.ZeroTrustDLPProfilePredefinedUpdateParamsEntry{{ - Enabled: cloudflare.F(true), - }, { - Enabled: cloudflare.F(true), - }, { - Enabled: cloudflare.F(true), - }}), - }, - ) - 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 TestZeroTrustDLPProfilePredefinedGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.DLP.Profiles.Predefineds.Get( - context.TODO(), - "384e129d-25bd-403c-8019-bc19eb7a8a5f", - cloudflare.ZeroTrustDLPProfilePredefinedGetParams{ - AccountID: cloudflare.F("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/zerotrustgateway.go b/zerotrustgateway.go deleted file mode 100644 index b4c446f0b45..00000000000 --- a/zerotrustgateway.go +++ /dev/null @@ -1,302 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustGatewayService 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 [NewZeroTrustGatewayService] method -// instead. -type ZeroTrustGatewayService struct { - Options []option.RequestOption - AuditSSHSettings *ZeroTrustGatewayAuditSSHSettingService - Categories *ZeroTrustGatewayCategoryService - AppTypes *ZeroTrustGatewayAppTypeService - Configurations *ZeroTrustGatewayConfigurationService - Lists *ZeroTrustGatewayListService - Locations *ZeroTrustGatewayLocationService - Loggings *ZeroTrustGatewayLoggingService - ProxyEndpoints *ZeroTrustGatewayProxyEndpointService - Rules *ZeroTrustGatewayRuleService -} - -// NewZeroTrustGatewayService 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 NewZeroTrustGatewayService(opts ...option.RequestOption) (r *ZeroTrustGatewayService) { - r = &ZeroTrustGatewayService{} - r.Options = opts - r.AuditSSHSettings = NewZeroTrustGatewayAuditSSHSettingService(opts...) - r.Categories = NewZeroTrustGatewayCategoryService(opts...) - r.AppTypes = NewZeroTrustGatewayAppTypeService(opts...) - r.Configurations = NewZeroTrustGatewayConfigurationService(opts...) - r.Lists = NewZeroTrustGatewayListService(opts...) - r.Locations = NewZeroTrustGatewayLocationService(opts...) - r.Loggings = NewZeroTrustGatewayLoggingService(opts...) - r.ProxyEndpoints = NewZeroTrustGatewayProxyEndpointService(opts...) - r.Rules = NewZeroTrustGatewayRuleService(opts...) - return -} - -// Creates a Zero Trust account with an existing Cloudflare account. -func (r *ZeroTrustGatewayService) New(ctx context.Context, body ZeroTrustGatewayNewParams, opts ...option.RequestOption) (res *ZeroTrustGatewayNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway", body.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets information about the current Zero Trust account. -func (r *ZeroTrustGatewayService) List(ctx context.Context, query ZeroTrustGatewayListParams, opts ...option.RequestOption) (res *ZeroTrustGatewayListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayListResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustGatewayNewResponse struct { - // Cloudflare account ID. - ID string `json:"id"` - // Gateway internal ID. - GatewayTag string `json:"gateway_tag"` - // The name of the provider. Usually Cloudflare. - ProviderName string `json:"provider_name"` - JSON zeroTrustGatewayNewResponseJSON `json:"-"` -} - -// zeroTrustGatewayNewResponseJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayNewResponse] -type zeroTrustGatewayNewResponseJSON struct { - ID apijson.Field - GatewayTag apijson.Field - ProviderName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayNewResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListResponse struct { - // Cloudflare account ID. - ID string `json:"id"` - // Gateway internal ID. - GatewayTag string `json:"gateway_tag"` - // The name of the provider. Usually Cloudflare. - ProviderName string `json:"provider_name"` - JSON zeroTrustGatewayListResponseJSON `json:"-"` -} - -// zeroTrustGatewayListResponseJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayListResponse] -type zeroTrustGatewayListResponseJSON struct { - ID apijson.Field - GatewayTag apijson.Field - ProviderName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayNewParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustGatewayNewResponseEnvelope struct { - Errors []ZeroTrustGatewayNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayNewResponseEnvelope] -type zeroTrustGatewayNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayNewResponseEnvelopeErrors] -type zeroTrustGatewayNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayNewResponseEnvelopeMessages] -type zeroTrustGatewayNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayNewResponseEnvelopeSuccessTrue ZeroTrustGatewayNewResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustGatewayListResponseEnvelope struct { - Errors []ZeroTrustGatewayListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayListResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayListResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayListResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayListResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayListResponseEnvelope] -type zeroTrustGatewayListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayListResponseEnvelopeErrors] -type zeroTrustGatewayListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayListResponseEnvelopeMessages] -type zeroTrustGatewayListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayListResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayListResponseEnvelopeSuccessTrue ZeroTrustGatewayListResponseEnvelopeSuccess = true -) diff --git a/zerotrustgateway_test.go b/zerotrustgateway_test.go deleted file mode 100644 index 8109d2ad158..00000000000 --- a/zerotrustgateway_test.go +++ /dev/null @@ -1,66 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustGatewayNew(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.New(context.TODO(), cloudflare.ZeroTrustGatewayNewParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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 TestZeroTrustGatewayList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.List(context.TODO(), cloudflare.ZeroTrustGatewayListParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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/zerotrustgatewayapptype.go b/zerotrustgatewayapptype.go deleted file mode 100644 index 4f04d7632f4..00000000000 --- a/zerotrustgatewayapptype.go +++ /dev/null @@ -1,259 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustGatewayAppTypeService 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 -// [NewZeroTrustGatewayAppTypeService] method instead. -type ZeroTrustGatewayAppTypeService struct { - Options []option.RequestOption -} - -// NewZeroTrustGatewayAppTypeService 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 NewZeroTrustGatewayAppTypeService(opts ...option.RequestOption) (r *ZeroTrustGatewayAppTypeService) { - r = &ZeroTrustGatewayAppTypeService{} - r.Options = opts - return -} - -// Fetches all application and application type mappings. -func (r *ZeroTrustGatewayAppTypeService) List(ctx context.Context, query ZeroTrustGatewayAppTypeListParams, opts ...option.RequestOption) (res *[]ZeroTrustGatewayAppTypeListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayAppTypeListResponseEnvelope - path := fmt.Sprintf("accounts/%s/gateway/app_types", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by -// [ZeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplication] or -// [ZeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplicationType]. -type ZeroTrustGatewayAppTypeListResponse interface { - implementsZeroTrustGatewayAppTypeListResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustGatewayAppTypeListResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplication{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplicationType{}), - }, - ) -} - -type ZeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplication struct { - // The identifier for this application. There is only one application per ID. - ID int64 `json:"id"` - // The identifier for the type of this application. There can be many applications - // with the same type. This refers to the `id` of a returned application type. - ApplicationTypeID int64 `json:"application_type_id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The name of the application or application type. - Name string `json:"name"` - JSON zeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplicationJSON `json:"-"` -} - -// zeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplicationJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplication] -type zeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplicationJSON struct { - ID apijson.Field - ApplicationTypeID apijson.Field - CreatedAt apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplication) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplicationJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplication) implementsZeroTrustGatewayAppTypeListResponse() { -} - -type ZeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplicationType struct { - // The identifier for the type of this application. There can be many applications - // with the same type. This refers to the `id` of a returned application type. - ID int64 `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // A short summary of applications with this type. - Description string `json:"description"` - // The name of the application or application type. - Name string `json:"name"` - JSON zeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplicationTypeJSON `json:"-"` -} - -// zeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplicationTypeJSON contains -// the JSON metadata for the struct -// [ZeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplicationType] -type zeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplicationTypeJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Description apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplicationType) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplicationTypeJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustGatewayAppTypeListResponseZeroTrustGatewayApplicationType) implementsZeroTrustGatewayAppTypeListResponse() { -} - -type ZeroTrustGatewayAppTypeListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustGatewayAppTypeListResponseEnvelope struct { - Errors []ZeroTrustGatewayAppTypeListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayAppTypeListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustGatewayAppTypeListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustGatewayAppTypeListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustGatewayAppTypeListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustGatewayAppTypeListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayAppTypeListResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayAppTypeListResponseEnvelope] -type zeroTrustGatewayAppTypeListResponseEnvelopeJSON 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 *ZeroTrustGatewayAppTypeListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayAppTypeListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayAppTypeListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayAppTypeListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayAppTypeListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayAppTypeListResponseEnvelopeErrors] -type zeroTrustGatewayAppTypeListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayAppTypeListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayAppTypeListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayAppTypeListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayAppTypeListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayAppTypeListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayAppTypeListResponseEnvelopeMessages] -type zeroTrustGatewayAppTypeListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayAppTypeListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayAppTypeListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayAppTypeListResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayAppTypeListResponseEnvelopeSuccessTrue ZeroTrustGatewayAppTypeListResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayAppTypeListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustGatewayAppTypeListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustGatewayAppTypeListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayAppTypeListResponseEnvelopeResultInfo] -type zeroTrustGatewayAppTypeListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayAppTypeListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayAppTypeListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zerotrustgatewayapptype_test.go b/zerotrustgatewayapptype_test.go deleted file mode 100644 index 9c48814d61e..00000000000 --- a/zerotrustgatewayapptype_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustGatewayAppTypeList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.AppTypes.List(context.TODO(), cloudflare.ZeroTrustGatewayAppTypeListParams{ - AccountID: cloudflare.F("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/zerotrustgatewayauditsshsetting.go b/zerotrustgatewayauditsshsetting.go deleted file mode 100644 index 2479494028c..00000000000 --- a/zerotrustgatewayauditsshsetting.go +++ /dev/null @@ -1,299 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustGatewayAuditSSHSettingService 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 -// [NewZeroTrustGatewayAuditSSHSettingService] method instead. -type ZeroTrustGatewayAuditSSHSettingService struct { - Options []option.RequestOption -} - -// NewZeroTrustGatewayAuditSSHSettingService 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 NewZeroTrustGatewayAuditSSHSettingService(opts ...option.RequestOption) (r *ZeroTrustGatewayAuditSSHSettingService) { - r = &ZeroTrustGatewayAuditSSHSettingService{} - r.Options = opts - return -} - -// Updates Zero Trust Audit SSH settings. -func (r *ZeroTrustGatewayAuditSSHSettingService) Update(ctx context.Context, params ZeroTrustGatewayAuditSSHSettingUpdateParams, opts ...option.RequestOption) (res *ZeroTrustGatewayAuditSSHSettingUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayAuditSSHSettingUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/audit_ssh_settings", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get all Zero Trust Audit SSH settings for an account. -func (r *ZeroTrustGatewayAuditSSHSettingService) Get(ctx context.Context, query ZeroTrustGatewayAuditSSHSettingGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewayAuditSSHSettingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayAuditSSHSettingGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/audit_ssh_settings", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustGatewayAuditSSHSettingUpdateResponse struct { - CreatedAt time.Time `json:"created_at" format:"date-time"` - // SSH encryption public key - PublicKey string `json:"public_key"` - // Seed ID - SeedID string `json:"seed_id"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayAuditSSHSettingUpdateResponseJSON `json:"-"` -} - -// zeroTrustGatewayAuditSSHSettingUpdateResponseJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayAuditSSHSettingUpdateResponse] -type zeroTrustGatewayAuditSSHSettingUpdateResponseJSON struct { - CreatedAt apijson.Field - PublicKey apijson.Field - SeedID apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayAuditSSHSettingUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayAuditSSHSettingUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayAuditSSHSettingGetResponse struct { - CreatedAt time.Time `json:"created_at" format:"date-time"` - // SSH encryption public key - PublicKey string `json:"public_key"` - // Seed ID - SeedID string `json:"seed_id"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayAuditSSHSettingGetResponseJSON `json:"-"` -} - -// zeroTrustGatewayAuditSSHSettingGetResponseJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayAuditSSHSettingGetResponse] -type zeroTrustGatewayAuditSSHSettingGetResponseJSON struct { - CreatedAt apijson.Field - PublicKey apijson.Field - SeedID apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayAuditSSHSettingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayAuditSSHSettingGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayAuditSSHSettingUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // SSH encryption public key - PublicKey param.Field[string] `json:"public_key,required"` - // Seed ID - SeedID param.Field[string] `json:"seed_id"` -} - -func (r ZeroTrustGatewayAuditSSHSettingUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayAuditSSHSettingUpdateResponseEnvelope struct { - Errors []ZeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayAuditSSHSettingUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayAuditSSHSettingUpdateResponseEnvelope] -type zeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayAuditSSHSettingUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeErrors] -type zeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeMessages] -type zeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeSuccessTrue ZeroTrustGatewayAuditSSHSettingUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayAuditSSHSettingGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustGatewayAuditSSHSettingGetResponseEnvelope struct { - Errors []ZeroTrustGatewayAuditSSHSettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayAuditSSHSettingGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayAuditSSHSettingGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayAuditSSHSettingGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayAuditSSHSettingGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayAuditSSHSettingGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayAuditSSHSettingGetResponseEnvelope] -type zeroTrustGatewayAuditSSHSettingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayAuditSSHSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayAuditSSHSettingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayAuditSSHSettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayAuditSSHSettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayAuditSSHSettingGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayAuditSSHSettingGetResponseEnvelopeErrors] -type zeroTrustGatewayAuditSSHSettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayAuditSSHSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayAuditSSHSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayAuditSSHSettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayAuditSSHSettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayAuditSSHSettingGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayAuditSSHSettingGetResponseEnvelopeMessages] -type zeroTrustGatewayAuditSSHSettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayAuditSSHSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayAuditSSHSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayAuditSSHSettingGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayAuditSSHSettingGetResponseEnvelopeSuccessTrue ZeroTrustGatewayAuditSSHSettingGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustgatewayauditsshsetting_test.go b/zerotrustgatewayauditsshsetting_test.go deleted file mode 100644 index ed1e3c13304..00000000000 --- a/zerotrustgatewayauditsshsetting_test.go +++ /dev/null @@ -1,68 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustGatewayAuditSSHSettingUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.AuditSSHSettings.Update(context.TODO(), cloudflare.ZeroTrustGatewayAuditSSHSettingUpdateParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - PublicKey: cloudflare.F("1pyl6I1tL7xfJuFYVzXlUW8uXXlpxegHXBzGCBKaSFA="), - SeedID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), - }) - 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 TestZeroTrustGatewayAuditSSHSettingGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.AuditSSHSettings.Get(context.TODO(), cloudflare.ZeroTrustGatewayAuditSSHSettingGetParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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/zerotrustgatewaycategory.go b/zerotrustgatewaycategory.go deleted file mode 100644 index 49d264431f8..00000000000 --- a/zerotrustgatewaycategory.go +++ /dev/null @@ -1,269 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustGatewayCategoryService 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 -// [NewZeroTrustGatewayCategoryService] method instead. -type ZeroTrustGatewayCategoryService struct { - Options []option.RequestOption -} - -// NewZeroTrustGatewayCategoryService 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 NewZeroTrustGatewayCategoryService(opts ...option.RequestOption) (r *ZeroTrustGatewayCategoryService) { - r = &ZeroTrustGatewayCategoryService{} - r.Options = opts - return -} - -// Fetches a list of all categories. -func (r *ZeroTrustGatewayCategoryService) List(ctx context.Context, query ZeroTrustGatewayCategoryListParams, opts ...option.RequestOption) (res *[]ZeroTrustGatewayCategoryListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayCategoryListResponseEnvelope - path := fmt.Sprintf("accounts/%s/gateway/categories", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustGatewayCategoryListResponse struct { - // The identifier for this category. There is only one category per ID. - ID int64 `json:"id"` - // True if the category is in beta and subject to change. - Beta bool `json:"beta"` - // Which account types are allowed to create policies based on this category. - // `blocked` categories are blocked unconditionally for all accounts. - // `removalPending` categories can be removed from policies but not added. - // `noBlock` categories cannot be blocked. - Class ZeroTrustGatewayCategoryListResponseClass `json:"class"` - // A short summary of domains in the category. - Description string `json:"description"` - // The name of the category. - Name string `json:"name"` - // All subcategories for this category. - Subcategories []ZeroTrustGatewayCategoryListResponseSubcategory `json:"subcategories"` - JSON zeroTrustGatewayCategoryListResponseJSON `json:"-"` -} - -// zeroTrustGatewayCategoryListResponseJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayCategoryListResponse] -type zeroTrustGatewayCategoryListResponseJSON struct { - ID apijson.Field - Beta apijson.Field - Class apijson.Field - Description apijson.Field - Name apijson.Field - Subcategories apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayCategoryListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayCategoryListResponseJSON) RawJSON() string { - return r.raw -} - -// Which account types are allowed to create policies based on this category. -// `blocked` categories are blocked unconditionally for all accounts. -// `removalPending` categories can be removed from policies but not added. -// `noBlock` categories cannot be blocked. -type ZeroTrustGatewayCategoryListResponseClass string - -const ( - ZeroTrustGatewayCategoryListResponseClassFree ZeroTrustGatewayCategoryListResponseClass = "free" - ZeroTrustGatewayCategoryListResponseClassPremium ZeroTrustGatewayCategoryListResponseClass = "premium" - ZeroTrustGatewayCategoryListResponseClassBlocked ZeroTrustGatewayCategoryListResponseClass = "blocked" - ZeroTrustGatewayCategoryListResponseClassRemovalPending ZeroTrustGatewayCategoryListResponseClass = "removalPending" - ZeroTrustGatewayCategoryListResponseClassNoBlock ZeroTrustGatewayCategoryListResponseClass = "noBlock" -) - -type ZeroTrustGatewayCategoryListResponseSubcategory struct { - // The identifier for this category. There is only one category per ID. - ID int64 `json:"id"` - // True if the category is in beta and subject to change. - Beta bool `json:"beta"` - // Which account types are allowed to create policies based on this category. - // `blocked` categories are blocked unconditionally for all accounts. - // `removalPending` categories can be removed from policies but not added. - // `noBlock` categories cannot be blocked. - Class ZeroTrustGatewayCategoryListResponseSubcategoriesClass `json:"class"` - // A short summary of domains in the category. - Description string `json:"description"` - // The name of the category. - Name string `json:"name"` - JSON zeroTrustGatewayCategoryListResponseSubcategoryJSON `json:"-"` -} - -// zeroTrustGatewayCategoryListResponseSubcategoryJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayCategoryListResponseSubcategory] -type zeroTrustGatewayCategoryListResponseSubcategoryJSON struct { - ID apijson.Field - Beta apijson.Field - Class apijson.Field - Description apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayCategoryListResponseSubcategory) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayCategoryListResponseSubcategoryJSON) RawJSON() string { - return r.raw -} - -// Which account types are allowed to create policies based on this category. -// `blocked` categories are blocked unconditionally for all accounts. -// `removalPending` categories can be removed from policies but not added. -// `noBlock` categories cannot be blocked. -type ZeroTrustGatewayCategoryListResponseSubcategoriesClass string - -const ( - ZeroTrustGatewayCategoryListResponseSubcategoriesClassFree ZeroTrustGatewayCategoryListResponseSubcategoriesClass = "free" - ZeroTrustGatewayCategoryListResponseSubcategoriesClassPremium ZeroTrustGatewayCategoryListResponseSubcategoriesClass = "premium" - ZeroTrustGatewayCategoryListResponseSubcategoriesClassBlocked ZeroTrustGatewayCategoryListResponseSubcategoriesClass = "blocked" - ZeroTrustGatewayCategoryListResponseSubcategoriesClassRemovalPending ZeroTrustGatewayCategoryListResponseSubcategoriesClass = "removalPending" - ZeroTrustGatewayCategoryListResponseSubcategoriesClassNoBlock ZeroTrustGatewayCategoryListResponseSubcategoriesClass = "noBlock" -) - -type ZeroTrustGatewayCategoryListParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustGatewayCategoryListResponseEnvelope struct { - Errors []ZeroTrustGatewayCategoryListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayCategoryListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustGatewayCategoryListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustGatewayCategoryListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustGatewayCategoryListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustGatewayCategoryListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayCategoryListResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayCategoryListResponseEnvelope] -type zeroTrustGatewayCategoryListResponseEnvelopeJSON 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 *ZeroTrustGatewayCategoryListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayCategoryListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayCategoryListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayCategoryListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayCategoryListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayCategoryListResponseEnvelopeErrors] -type zeroTrustGatewayCategoryListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayCategoryListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayCategoryListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayCategoryListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayCategoryListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayCategoryListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayCategoryListResponseEnvelopeMessages] -type zeroTrustGatewayCategoryListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayCategoryListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayCategoryListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayCategoryListResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayCategoryListResponseEnvelopeSuccessTrue ZeroTrustGatewayCategoryListResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayCategoryListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustGatewayCategoryListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustGatewayCategoryListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayCategoryListResponseEnvelopeResultInfo] -type zeroTrustGatewayCategoryListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayCategoryListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayCategoryListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zerotrustgatewaycategory_test.go b/zerotrustgatewaycategory_test.go deleted file mode 100644 index 165514ab245..00000000000 --- a/zerotrustgatewaycategory_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustGatewayCategoryList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Categories.List(context.TODO(), cloudflare.ZeroTrustGatewayCategoryListParams{ - AccountID: cloudflare.F("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/zerotrustgatewayconfiguration.go b/zerotrustgatewayconfiguration.go deleted file mode 100644 index bf02d7e971e..00000000000 --- a/zerotrustgatewayconfiguration.go +++ /dev/null @@ -1,1878 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustGatewayConfigurationService 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 -// [NewZeroTrustGatewayConfigurationService] method instead. -type ZeroTrustGatewayConfigurationService struct { - Options []option.RequestOption -} - -// NewZeroTrustGatewayConfigurationService 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 NewZeroTrustGatewayConfigurationService(opts ...option.RequestOption) (r *ZeroTrustGatewayConfigurationService) { - r = &ZeroTrustGatewayConfigurationService{} - r.Options = opts - return -} - -// Updates the current Zero Trust account configuration. -func (r *ZeroTrustGatewayConfigurationService) Update(ctx context.Context, params ZeroTrustGatewayConfigurationUpdateParams, opts ...option.RequestOption) (res *ZeroTrustGatewayConfigurationUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayConfigurationUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/configuration", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Patches the current Zero Trust account configuration. This endpoint can update a -// single subcollection of settings such as `antivirus`, `tls_decrypt`, -// `activity_log`, `block_page`, `browser_isolation`, `fips`, `body_scanning`, or -// `custom_certificate`, without updating the entire configuration object. Returns -// an error if any collection of settings is not properly configured. -func (r *ZeroTrustGatewayConfigurationService) Edit(ctx context.Context, params ZeroTrustGatewayConfigurationEditParams, opts ...option.RequestOption) (res *ZeroTrustGatewayConfigurationEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayConfigurationEditResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/configuration", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the current Zero Trust account configuration. -func (r *ZeroTrustGatewayConfigurationService) Get(ctx context.Context, query ZeroTrustGatewayConfigurationGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewayConfigurationGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayConfigurationGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/configuration", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// account settings. -type ZeroTrustGatewayConfigurationUpdateResponse struct { - CreatedAt time.Time `json:"created_at" format:"date-time"` - // account settings. - Settings ZeroTrustGatewayConfigurationUpdateResponseSettings `json:"settings"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayConfigurationUpdateResponseJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationUpdateResponseJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayConfigurationUpdateResponse] -type zeroTrustGatewayConfigurationUpdateResponseJSON struct { - CreatedAt apijson.Field - Settings apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// account settings. -type ZeroTrustGatewayConfigurationUpdateResponseSettings struct { - // Activity log settings. - ActivityLog ZeroTrustGatewayConfigurationUpdateResponseSettingsActivityLog `json:"activity_log"` - // Anti-virus settings. - Antivirus ZeroTrustGatewayConfigurationUpdateResponseSettingsAntivirus `json:"antivirus"` - // Block page layout settings. - BlockPage ZeroTrustGatewayConfigurationUpdateResponseSettingsBlockPage `json:"block_page"` - // DLP body scanning settings. - BodyScanning ZeroTrustGatewayConfigurationUpdateResponseSettingsBodyScanning `json:"body_scanning"` - // Browser isolation settings. - BrowserIsolation ZeroTrustGatewayConfigurationUpdateResponseSettingsBrowserIsolation `json:"browser_isolation"` - // Custom certificate settings for BYO-PKI. - CustomCertificate ZeroTrustGatewayConfigurationUpdateResponseSettingsCustomCertificate `json:"custom_certificate"` - // Extended e-mail matching settings. - ExtendedEmailMatching ZeroTrustGatewayConfigurationUpdateResponseSettingsExtendedEmailMatching `json:"extended_email_matching"` - // FIPS settings. - Fips ZeroTrustGatewayConfigurationUpdateResponseSettingsFips `json:"fips"` - // Protocol Detection settings. - ProtocolDetection ZeroTrustGatewayConfigurationUpdateResponseSettingsProtocolDetection `json:"protocol_detection"` - // TLS interception settings. - TLSDecrypt ZeroTrustGatewayConfigurationUpdateResponseSettingsTLSDecrypt `json:"tls_decrypt"` - JSON zeroTrustGatewayConfigurationUpdateResponseSettingsJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationUpdateResponseSettingsJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayConfigurationUpdateResponseSettings] -type zeroTrustGatewayConfigurationUpdateResponseSettingsJSON struct { - ActivityLog apijson.Field - Antivirus apijson.Field - BlockPage apijson.Field - BodyScanning apijson.Field - BrowserIsolation apijson.Field - CustomCertificate apijson.Field - ExtendedEmailMatching apijson.Field - Fips apijson.Field - ProtocolDetection apijson.Field - TLSDecrypt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationUpdateResponseSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationUpdateResponseSettingsJSON) RawJSON() string { - return r.raw -} - -// Activity log settings. -type ZeroTrustGatewayConfigurationUpdateResponseSettingsActivityLog struct { - // Enable activity logging. - Enabled bool `json:"enabled"` - JSON zeroTrustGatewayConfigurationUpdateResponseSettingsActivityLogJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationUpdateResponseSettingsActivityLogJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayConfigurationUpdateResponseSettingsActivityLog] -type zeroTrustGatewayConfigurationUpdateResponseSettingsActivityLogJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationUpdateResponseSettingsActivityLog) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationUpdateResponseSettingsActivityLogJSON) RawJSON() string { - return r.raw -} - -// Anti-virus settings. -type ZeroTrustGatewayConfigurationUpdateResponseSettingsAntivirus struct { - // Enable anti-virus scanning on downloads. - EnabledDownloadPhase bool `json:"enabled_download_phase"` - // Enable anti-virus scanning on uploads. - EnabledUploadPhase bool `json:"enabled_upload_phase"` - // Block requests for files that cannot be scanned. - FailClosed bool `json:"fail_closed"` - // Configure a message to display on the user's device when an antivirus search is - // performed. - NotificationSettings ZeroTrustGatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettings `json:"notification_settings"` - JSON zeroTrustGatewayConfigurationUpdateResponseSettingsAntivirusJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationUpdateResponseSettingsAntivirusJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayConfigurationUpdateResponseSettingsAntivirus] -type zeroTrustGatewayConfigurationUpdateResponseSettingsAntivirusJSON struct { - EnabledDownloadPhase apijson.Field - EnabledUploadPhase apijson.Field - FailClosed apijson.Field - NotificationSettings apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationUpdateResponseSettingsAntivirus) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationUpdateResponseSettingsAntivirusJSON) RawJSON() string { - return r.raw -} - -// Configure a message to display on the user's device when an antivirus search is -// performed. -type ZeroTrustGatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettings struct { - // Set notification on - Enabled bool `json:"enabled"` - // Customize the message shown in the notification. - Msg string `json:"msg"` - // Optional URL to direct users to additional information. If not set, the - // notification will open a block page. - SupportURL string `json:"support_url"` - JSON zeroTrustGatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettingsJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettingsJSON -// contains the JSON metadata for the struct -// [ZeroTrustGatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettings] -type zeroTrustGatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettingsJSON struct { - Enabled apijson.Field - Msg apijson.Field - SupportURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationUpdateResponseSettingsAntivirusNotificationSettingsJSON) RawJSON() string { - return r.raw -} - -// Block page layout settings. -type ZeroTrustGatewayConfigurationUpdateResponseSettingsBlockPage struct { - // Block page background color in #rrggbb format. - BackgroundColor string `json:"background_color"` - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - Enabled bool `json:"enabled"` - // Block page footer text. - FooterText string `json:"footer_text"` - // Block page header text. - HeaderText string `json:"header_text"` - // Full URL to the logo file. - LogoPath string `json:"logo_path"` - // Admin email for users to contact. - MailtoAddress string `json:"mailto_address"` - // Subject line for emails created from block page. - MailtoSubject string `json:"mailto_subject"` - // Block page title. - Name string `json:"name"` - // Suppress detailed info at the bottom of the block page. - SuppressFooter bool `json:"suppress_footer"` - JSON zeroTrustGatewayConfigurationUpdateResponseSettingsBlockPageJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationUpdateResponseSettingsBlockPageJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayConfigurationUpdateResponseSettingsBlockPage] -type zeroTrustGatewayConfigurationUpdateResponseSettingsBlockPageJSON struct { - BackgroundColor apijson.Field - Enabled apijson.Field - FooterText apijson.Field - HeaderText apijson.Field - LogoPath apijson.Field - MailtoAddress apijson.Field - MailtoSubject apijson.Field - Name apijson.Field - SuppressFooter apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationUpdateResponseSettingsBlockPage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationUpdateResponseSettingsBlockPageJSON) RawJSON() string { - return r.raw -} - -// DLP body scanning settings. -type ZeroTrustGatewayConfigurationUpdateResponseSettingsBodyScanning struct { - // Set the inspection mode to either `deep` or `shallow`. - InspectionMode string `json:"inspection_mode"` - JSON zeroTrustGatewayConfigurationUpdateResponseSettingsBodyScanningJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationUpdateResponseSettingsBodyScanningJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayConfigurationUpdateResponseSettingsBodyScanning] -type zeroTrustGatewayConfigurationUpdateResponseSettingsBodyScanningJSON struct { - InspectionMode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationUpdateResponseSettingsBodyScanning) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationUpdateResponseSettingsBodyScanningJSON) RawJSON() string { - return r.raw -} - -// Browser isolation settings. -type ZeroTrustGatewayConfigurationUpdateResponseSettingsBrowserIsolation struct { - // Enable non-identity onramp support for Browser Isolation. - NonIdentityEnabled bool `json:"non_identity_enabled"` - // Enable Clientless Browser Isolation. - URLBrowserIsolationEnabled bool `json:"url_browser_isolation_enabled"` - JSON zeroTrustGatewayConfigurationUpdateResponseSettingsBrowserIsolationJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationUpdateResponseSettingsBrowserIsolationJSON contains -// the JSON metadata for the struct -// [ZeroTrustGatewayConfigurationUpdateResponseSettingsBrowserIsolation] -type zeroTrustGatewayConfigurationUpdateResponseSettingsBrowserIsolationJSON struct { - NonIdentityEnabled apijson.Field - URLBrowserIsolationEnabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationUpdateResponseSettingsBrowserIsolation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationUpdateResponseSettingsBrowserIsolationJSON) RawJSON() string { - return r.raw -} - -// Custom certificate settings for BYO-PKI. -type ZeroTrustGatewayConfigurationUpdateResponseSettingsCustomCertificate struct { - // Enable use of custom certificate authority for signing Gateway traffic. - Enabled bool `json:"enabled,required"` - // UUID of certificate (ID from MTLS certificate store). - ID string `json:"id"` - // Certificate status (internal). - BindingStatus string `json:"binding_status"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayConfigurationUpdateResponseSettingsCustomCertificateJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationUpdateResponseSettingsCustomCertificateJSON -// contains the JSON metadata for the struct -// [ZeroTrustGatewayConfigurationUpdateResponseSettingsCustomCertificate] -type zeroTrustGatewayConfigurationUpdateResponseSettingsCustomCertificateJSON struct { - Enabled apijson.Field - ID apijson.Field - BindingStatus apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationUpdateResponseSettingsCustomCertificate) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationUpdateResponseSettingsCustomCertificateJSON) RawJSON() string { - return r.raw -} - -// Extended e-mail matching settings. -type ZeroTrustGatewayConfigurationUpdateResponseSettingsExtendedEmailMatching struct { - // Enable matching all variants of user emails (with + or . modifiers) used as - // criteria in Firewall policies. - Enabled bool `json:"enabled"` - JSON zeroTrustGatewayConfigurationUpdateResponseSettingsExtendedEmailMatchingJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationUpdateResponseSettingsExtendedEmailMatchingJSON -// contains the JSON metadata for the struct -// [ZeroTrustGatewayConfigurationUpdateResponseSettingsExtendedEmailMatching] -type zeroTrustGatewayConfigurationUpdateResponseSettingsExtendedEmailMatchingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationUpdateResponseSettingsExtendedEmailMatching) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationUpdateResponseSettingsExtendedEmailMatchingJSON) RawJSON() string { - return r.raw -} - -// FIPS settings. -type ZeroTrustGatewayConfigurationUpdateResponseSettingsFips struct { - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - TLS bool `json:"tls"` - JSON zeroTrustGatewayConfigurationUpdateResponseSettingsFipsJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationUpdateResponseSettingsFipsJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayConfigurationUpdateResponseSettingsFips] -type zeroTrustGatewayConfigurationUpdateResponseSettingsFipsJSON struct { - TLS apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationUpdateResponseSettingsFips) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationUpdateResponseSettingsFipsJSON) RawJSON() string { - return r.raw -} - -// Protocol Detection settings. -type ZeroTrustGatewayConfigurationUpdateResponseSettingsProtocolDetection struct { - // Enable detecting protocol on initial bytes of client traffic. - Enabled bool `json:"enabled"` - JSON zeroTrustGatewayConfigurationUpdateResponseSettingsProtocolDetectionJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationUpdateResponseSettingsProtocolDetectionJSON -// contains the JSON metadata for the struct -// [ZeroTrustGatewayConfigurationUpdateResponseSettingsProtocolDetection] -type zeroTrustGatewayConfigurationUpdateResponseSettingsProtocolDetectionJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationUpdateResponseSettingsProtocolDetection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationUpdateResponseSettingsProtocolDetectionJSON) RawJSON() string { - return r.raw -} - -// TLS interception settings. -type ZeroTrustGatewayConfigurationUpdateResponseSettingsTLSDecrypt struct { - // Enable inspecting encrypted HTTP traffic. - Enabled bool `json:"enabled"` - JSON zeroTrustGatewayConfigurationUpdateResponseSettingsTLSDecryptJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationUpdateResponseSettingsTLSDecryptJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayConfigurationUpdateResponseSettingsTLSDecrypt] -type zeroTrustGatewayConfigurationUpdateResponseSettingsTLSDecryptJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationUpdateResponseSettingsTLSDecrypt) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationUpdateResponseSettingsTLSDecryptJSON) RawJSON() string { - return r.raw -} - -// account settings. -type ZeroTrustGatewayConfigurationEditResponse struct { - CreatedAt time.Time `json:"created_at" format:"date-time"` - // account settings. - Settings ZeroTrustGatewayConfigurationEditResponseSettings `json:"settings"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayConfigurationEditResponseJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationEditResponseJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayConfigurationEditResponse] -type zeroTrustGatewayConfigurationEditResponseJSON struct { - CreatedAt apijson.Field - Settings apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationEditResponseJSON) RawJSON() string { - return r.raw -} - -// account settings. -type ZeroTrustGatewayConfigurationEditResponseSettings struct { - // Activity log settings. - ActivityLog ZeroTrustGatewayConfigurationEditResponseSettingsActivityLog `json:"activity_log"` - // Anti-virus settings. - Antivirus ZeroTrustGatewayConfigurationEditResponseSettingsAntivirus `json:"antivirus"` - // Block page layout settings. - BlockPage ZeroTrustGatewayConfigurationEditResponseSettingsBlockPage `json:"block_page"` - // DLP body scanning settings. - BodyScanning ZeroTrustGatewayConfigurationEditResponseSettingsBodyScanning `json:"body_scanning"` - // Browser isolation settings. - BrowserIsolation ZeroTrustGatewayConfigurationEditResponseSettingsBrowserIsolation `json:"browser_isolation"` - // Custom certificate settings for BYO-PKI. - CustomCertificate ZeroTrustGatewayConfigurationEditResponseSettingsCustomCertificate `json:"custom_certificate"` - // Extended e-mail matching settings. - ExtendedEmailMatching ZeroTrustGatewayConfigurationEditResponseSettingsExtendedEmailMatching `json:"extended_email_matching"` - // FIPS settings. - Fips ZeroTrustGatewayConfigurationEditResponseSettingsFips `json:"fips"` - // Protocol Detection settings. - ProtocolDetection ZeroTrustGatewayConfigurationEditResponseSettingsProtocolDetection `json:"protocol_detection"` - // TLS interception settings. - TLSDecrypt ZeroTrustGatewayConfigurationEditResponseSettingsTLSDecrypt `json:"tls_decrypt"` - JSON zeroTrustGatewayConfigurationEditResponseSettingsJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationEditResponseSettingsJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayConfigurationEditResponseSettings] -type zeroTrustGatewayConfigurationEditResponseSettingsJSON struct { - ActivityLog apijson.Field - Antivirus apijson.Field - BlockPage apijson.Field - BodyScanning apijson.Field - BrowserIsolation apijson.Field - CustomCertificate apijson.Field - ExtendedEmailMatching apijson.Field - Fips apijson.Field - ProtocolDetection apijson.Field - TLSDecrypt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationEditResponseSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationEditResponseSettingsJSON) RawJSON() string { - return r.raw -} - -// Activity log settings. -type ZeroTrustGatewayConfigurationEditResponseSettingsActivityLog struct { - // Enable activity logging. - Enabled bool `json:"enabled"` - JSON zeroTrustGatewayConfigurationEditResponseSettingsActivityLogJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationEditResponseSettingsActivityLogJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayConfigurationEditResponseSettingsActivityLog] -type zeroTrustGatewayConfigurationEditResponseSettingsActivityLogJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationEditResponseSettingsActivityLog) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationEditResponseSettingsActivityLogJSON) RawJSON() string { - return r.raw -} - -// Anti-virus settings. -type ZeroTrustGatewayConfigurationEditResponseSettingsAntivirus struct { - // Enable anti-virus scanning on downloads. - EnabledDownloadPhase bool `json:"enabled_download_phase"` - // Enable anti-virus scanning on uploads. - EnabledUploadPhase bool `json:"enabled_upload_phase"` - // Block requests for files that cannot be scanned. - FailClosed bool `json:"fail_closed"` - // Configure a message to display on the user's device when an antivirus search is - // performed. - NotificationSettings ZeroTrustGatewayConfigurationEditResponseSettingsAntivirusNotificationSettings `json:"notification_settings"` - JSON zeroTrustGatewayConfigurationEditResponseSettingsAntivirusJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationEditResponseSettingsAntivirusJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayConfigurationEditResponseSettingsAntivirus] -type zeroTrustGatewayConfigurationEditResponseSettingsAntivirusJSON struct { - EnabledDownloadPhase apijson.Field - EnabledUploadPhase apijson.Field - FailClosed apijson.Field - NotificationSettings apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationEditResponseSettingsAntivirus) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationEditResponseSettingsAntivirusJSON) RawJSON() string { - return r.raw -} - -// Configure a message to display on the user's device when an antivirus search is -// performed. -type ZeroTrustGatewayConfigurationEditResponseSettingsAntivirusNotificationSettings struct { - // Set notification on - Enabled bool `json:"enabled"` - // Customize the message shown in the notification. - Msg string `json:"msg"` - // Optional URL to direct users to additional information. If not set, the - // notification will open a block page. - SupportURL string `json:"support_url"` - JSON zeroTrustGatewayConfigurationEditResponseSettingsAntivirusNotificationSettingsJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationEditResponseSettingsAntivirusNotificationSettingsJSON -// contains the JSON metadata for the struct -// [ZeroTrustGatewayConfigurationEditResponseSettingsAntivirusNotificationSettings] -type zeroTrustGatewayConfigurationEditResponseSettingsAntivirusNotificationSettingsJSON struct { - Enabled apijson.Field - Msg apijson.Field - SupportURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationEditResponseSettingsAntivirusNotificationSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationEditResponseSettingsAntivirusNotificationSettingsJSON) RawJSON() string { - return r.raw -} - -// Block page layout settings. -type ZeroTrustGatewayConfigurationEditResponseSettingsBlockPage struct { - // Block page background color in #rrggbb format. - BackgroundColor string `json:"background_color"` - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - Enabled bool `json:"enabled"` - // Block page footer text. - FooterText string `json:"footer_text"` - // Block page header text. - HeaderText string `json:"header_text"` - // Full URL to the logo file. - LogoPath string `json:"logo_path"` - // Admin email for users to contact. - MailtoAddress string `json:"mailto_address"` - // Subject line for emails created from block page. - MailtoSubject string `json:"mailto_subject"` - // Block page title. - Name string `json:"name"` - // Suppress detailed info at the bottom of the block page. - SuppressFooter bool `json:"suppress_footer"` - JSON zeroTrustGatewayConfigurationEditResponseSettingsBlockPageJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationEditResponseSettingsBlockPageJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayConfigurationEditResponseSettingsBlockPage] -type zeroTrustGatewayConfigurationEditResponseSettingsBlockPageJSON struct { - BackgroundColor apijson.Field - Enabled apijson.Field - FooterText apijson.Field - HeaderText apijson.Field - LogoPath apijson.Field - MailtoAddress apijson.Field - MailtoSubject apijson.Field - Name apijson.Field - SuppressFooter apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationEditResponseSettingsBlockPage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationEditResponseSettingsBlockPageJSON) RawJSON() string { - return r.raw -} - -// DLP body scanning settings. -type ZeroTrustGatewayConfigurationEditResponseSettingsBodyScanning struct { - // Set the inspection mode to either `deep` or `shallow`. - InspectionMode string `json:"inspection_mode"` - JSON zeroTrustGatewayConfigurationEditResponseSettingsBodyScanningJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationEditResponseSettingsBodyScanningJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayConfigurationEditResponseSettingsBodyScanning] -type zeroTrustGatewayConfigurationEditResponseSettingsBodyScanningJSON struct { - InspectionMode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationEditResponseSettingsBodyScanning) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationEditResponseSettingsBodyScanningJSON) RawJSON() string { - return r.raw -} - -// Browser isolation settings. -type ZeroTrustGatewayConfigurationEditResponseSettingsBrowserIsolation struct { - // Enable non-identity onramp support for Browser Isolation. - NonIdentityEnabled bool `json:"non_identity_enabled"` - // Enable Clientless Browser Isolation. - URLBrowserIsolationEnabled bool `json:"url_browser_isolation_enabled"` - JSON zeroTrustGatewayConfigurationEditResponseSettingsBrowserIsolationJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationEditResponseSettingsBrowserIsolationJSON contains -// the JSON metadata for the struct -// [ZeroTrustGatewayConfigurationEditResponseSettingsBrowserIsolation] -type zeroTrustGatewayConfigurationEditResponseSettingsBrowserIsolationJSON struct { - NonIdentityEnabled apijson.Field - URLBrowserIsolationEnabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationEditResponseSettingsBrowserIsolation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationEditResponseSettingsBrowserIsolationJSON) RawJSON() string { - return r.raw -} - -// Custom certificate settings for BYO-PKI. -type ZeroTrustGatewayConfigurationEditResponseSettingsCustomCertificate struct { - // Enable use of custom certificate authority for signing Gateway traffic. - Enabled bool `json:"enabled,required"` - // UUID of certificate (ID from MTLS certificate store). - ID string `json:"id"` - // Certificate status (internal). - BindingStatus string `json:"binding_status"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayConfigurationEditResponseSettingsCustomCertificateJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationEditResponseSettingsCustomCertificateJSON contains -// the JSON metadata for the struct -// [ZeroTrustGatewayConfigurationEditResponseSettingsCustomCertificate] -type zeroTrustGatewayConfigurationEditResponseSettingsCustomCertificateJSON struct { - Enabled apijson.Field - ID apijson.Field - BindingStatus apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationEditResponseSettingsCustomCertificate) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationEditResponseSettingsCustomCertificateJSON) RawJSON() string { - return r.raw -} - -// Extended e-mail matching settings. -type ZeroTrustGatewayConfigurationEditResponseSettingsExtendedEmailMatching struct { - // Enable matching all variants of user emails (with + or . modifiers) used as - // criteria in Firewall policies. - Enabled bool `json:"enabled"` - JSON zeroTrustGatewayConfigurationEditResponseSettingsExtendedEmailMatchingJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationEditResponseSettingsExtendedEmailMatchingJSON -// contains the JSON metadata for the struct -// [ZeroTrustGatewayConfigurationEditResponseSettingsExtendedEmailMatching] -type zeroTrustGatewayConfigurationEditResponseSettingsExtendedEmailMatchingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationEditResponseSettingsExtendedEmailMatching) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationEditResponseSettingsExtendedEmailMatchingJSON) RawJSON() string { - return r.raw -} - -// FIPS settings. -type ZeroTrustGatewayConfigurationEditResponseSettingsFips struct { - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - TLS bool `json:"tls"` - JSON zeroTrustGatewayConfigurationEditResponseSettingsFipsJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationEditResponseSettingsFipsJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayConfigurationEditResponseSettingsFips] -type zeroTrustGatewayConfigurationEditResponseSettingsFipsJSON struct { - TLS apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationEditResponseSettingsFips) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationEditResponseSettingsFipsJSON) RawJSON() string { - return r.raw -} - -// Protocol Detection settings. -type ZeroTrustGatewayConfigurationEditResponseSettingsProtocolDetection struct { - // Enable detecting protocol on initial bytes of client traffic. - Enabled bool `json:"enabled"` - JSON zeroTrustGatewayConfigurationEditResponseSettingsProtocolDetectionJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationEditResponseSettingsProtocolDetectionJSON contains -// the JSON metadata for the struct -// [ZeroTrustGatewayConfigurationEditResponseSettingsProtocolDetection] -type zeroTrustGatewayConfigurationEditResponseSettingsProtocolDetectionJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationEditResponseSettingsProtocolDetection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationEditResponseSettingsProtocolDetectionJSON) RawJSON() string { - return r.raw -} - -// TLS interception settings. -type ZeroTrustGatewayConfigurationEditResponseSettingsTLSDecrypt struct { - // Enable inspecting encrypted HTTP traffic. - Enabled bool `json:"enabled"` - JSON zeroTrustGatewayConfigurationEditResponseSettingsTLSDecryptJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationEditResponseSettingsTLSDecryptJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayConfigurationEditResponseSettingsTLSDecrypt] -type zeroTrustGatewayConfigurationEditResponseSettingsTLSDecryptJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationEditResponseSettingsTLSDecrypt) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationEditResponseSettingsTLSDecryptJSON) RawJSON() string { - return r.raw -} - -// account settings. -type ZeroTrustGatewayConfigurationGetResponse struct { - CreatedAt time.Time `json:"created_at" format:"date-time"` - // account settings. - Settings ZeroTrustGatewayConfigurationGetResponseSettings `json:"settings"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayConfigurationGetResponseJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationGetResponseJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayConfigurationGetResponse] -type zeroTrustGatewayConfigurationGetResponseJSON struct { - CreatedAt apijson.Field - Settings apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationGetResponseJSON) RawJSON() string { - return r.raw -} - -// account settings. -type ZeroTrustGatewayConfigurationGetResponseSettings struct { - // Activity log settings. - ActivityLog ZeroTrustGatewayConfigurationGetResponseSettingsActivityLog `json:"activity_log"` - // Anti-virus settings. - Antivirus ZeroTrustGatewayConfigurationGetResponseSettingsAntivirus `json:"antivirus"` - // Block page layout settings. - BlockPage ZeroTrustGatewayConfigurationGetResponseSettingsBlockPage `json:"block_page"` - // DLP body scanning settings. - BodyScanning ZeroTrustGatewayConfigurationGetResponseSettingsBodyScanning `json:"body_scanning"` - // Browser isolation settings. - BrowserIsolation ZeroTrustGatewayConfigurationGetResponseSettingsBrowserIsolation `json:"browser_isolation"` - // Custom certificate settings for BYO-PKI. - CustomCertificate ZeroTrustGatewayConfigurationGetResponseSettingsCustomCertificate `json:"custom_certificate"` - // Extended e-mail matching settings. - ExtendedEmailMatching ZeroTrustGatewayConfigurationGetResponseSettingsExtendedEmailMatching `json:"extended_email_matching"` - // FIPS settings. - Fips ZeroTrustGatewayConfigurationGetResponseSettingsFips `json:"fips"` - // Protocol Detection settings. - ProtocolDetection ZeroTrustGatewayConfigurationGetResponseSettingsProtocolDetection `json:"protocol_detection"` - // TLS interception settings. - TLSDecrypt ZeroTrustGatewayConfigurationGetResponseSettingsTLSDecrypt `json:"tls_decrypt"` - JSON zeroTrustGatewayConfigurationGetResponseSettingsJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationGetResponseSettingsJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayConfigurationGetResponseSettings] -type zeroTrustGatewayConfigurationGetResponseSettingsJSON struct { - ActivityLog apijson.Field - Antivirus apijson.Field - BlockPage apijson.Field - BodyScanning apijson.Field - BrowserIsolation apijson.Field - CustomCertificate apijson.Field - ExtendedEmailMatching apijson.Field - Fips apijson.Field - ProtocolDetection apijson.Field - TLSDecrypt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationGetResponseSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationGetResponseSettingsJSON) RawJSON() string { - return r.raw -} - -// Activity log settings. -type ZeroTrustGatewayConfigurationGetResponseSettingsActivityLog struct { - // Enable activity logging. - Enabled bool `json:"enabled"` - JSON zeroTrustGatewayConfigurationGetResponseSettingsActivityLogJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationGetResponseSettingsActivityLogJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayConfigurationGetResponseSettingsActivityLog] -type zeroTrustGatewayConfigurationGetResponseSettingsActivityLogJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationGetResponseSettingsActivityLog) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationGetResponseSettingsActivityLogJSON) RawJSON() string { - return r.raw -} - -// Anti-virus settings. -type ZeroTrustGatewayConfigurationGetResponseSettingsAntivirus struct { - // Enable anti-virus scanning on downloads. - EnabledDownloadPhase bool `json:"enabled_download_phase"` - // Enable anti-virus scanning on uploads. - EnabledUploadPhase bool `json:"enabled_upload_phase"` - // Block requests for files that cannot be scanned. - FailClosed bool `json:"fail_closed"` - // Configure a message to display on the user's device when an antivirus search is - // performed. - NotificationSettings ZeroTrustGatewayConfigurationGetResponseSettingsAntivirusNotificationSettings `json:"notification_settings"` - JSON zeroTrustGatewayConfigurationGetResponseSettingsAntivirusJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationGetResponseSettingsAntivirusJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayConfigurationGetResponseSettingsAntivirus] -type zeroTrustGatewayConfigurationGetResponseSettingsAntivirusJSON struct { - EnabledDownloadPhase apijson.Field - EnabledUploadPhase apijson.Field - FailClosed apijson.Field - NotificationSettings apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationGetResponseSettingsAntivirus) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationGetResponseSettingsAntivirusJSON) RawJSON() string { - return r.raw -} - -// Configure a message to display on the user's device when an antivirus search is -// performed. -type ZeroTrustGatewayConfigurationGetResponseSettingsAntivirusNotificationSettings struct { - // Set notification on - Enabled bool `json:"enabled"` - // Customize the message shown in the notification. - Msg string `json:"msg"` - // Optional URL to direct users to additional information. If not set, the - // notification will open a block page. - SupportURL string `json:"support_url"` - JSON zeroTrustGatewayConfigurationGetResponseSettingsAntivirusNotificationSettingsJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationGetResponseSettingsAntivirusNotificationSettingsJSON -// contains the JSON metadata for the struct -// [ZeroTrustGatewayConfigurationGetResponseSettingsAntivirusNotificationSettings] -type zeroTrustGatewayConfigurationGetResponseSettingsAntivirusNotificationSettingsJSON struct { - Enabled apijson.Field - Msg apijson.Field - SupportURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationGetResponseSettingsAntivirusNotificationSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationGetResponseSettingsAntivirusNotificationSettingsJSON) RawJSON() string { - return r.raw -} - -// Block page layout settings. -type ZeroTrustGatewayConfigurationGetResponseSettingsBlockPage struct { - // Block page background color in #rrggbb format. - BackgroundColor string `json:"background_color"` - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - Enabled bool `json:"enabled"` - // Block page footer text. - FooterText string `json:"footer_text"` - // Block page header text. - HeaderText string `json:"header_text"` - // Full URL to the logo file. - LogoPath string `json:"logo_path"` - // Admin email for users to contact. - MailtoAddress string `json:"mailto_address"` - // Subject line for emails created from block page. - MailtoSubject string `json:"mailto_subject"` - // Block page title. - Name string `json:"name"` - // Suppress detailed info at the bottom of the block page. - SuppressFooter bool `json:"suppress_footer"` - JSON zeroTrustGatewayConfigurationGetResponseSettingsBlockPageJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationGetResponseSettingsBlockPageJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayConfigurationGetResponseSettingsBlockPage] -type zeroTrustGatewayConfigurationGetResponseSettingsBlockPageJSON struct { - BackgroundColor apijson.Field - Enabled apijson.Field - FooterText apijson.Field - HeaderText apijson.Field - LogoPath apijson.Field - MailtoAddress apijson.Field - MailtoSubject apijson.Field - Name apijson.Field - SuppressFooter apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationGetResponseSettingsBlockPage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationGetResponseSettingsBlockPageJSON) RawJSON() string { - return r.raw -} - -// DLP body scanning settings. -type ZeroTrustGatewayConfigurationGetResponseSettingsBodyScanning struct { - // Set the inspection mode to either `deep` or `shallow`. - InspectionMode string `json:"inspection_mode"` - JSON zeroTrustGatewayConfigurationGetResponseSettingsBodyScanningJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationGetResponseSettingsBodyScanningJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayConfigurationGetResponseSettingsBodyScanning] -type zeroTrustGatewayConfigurationGetResponseSettingsBodyScanningJSON struct { - InspectionMode apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationGetResponseSettingsBodyScanning) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationGetResponseSettingsBodyScanningJSON) RawJSON() string { - return r.raw -} - -// Browser isolation settings. -type ZeroTrustGatewayConfigurationGetResponseSettingsBrowserIsolation struct { - // Enable non-identity onramp support for Browser Isolation. - NonIdentityEnabled bool `json:"non_identity_enabled"` - // Enable Clientless Browser Isolation. - URLBrowserIsolationEnabled bool `json:"url_browser_isolation_enabled"` - JSON zeroTrustGatewayConfigurationGetResponseSettingsBrowserIsolationJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationGetResponseSettingsBrowserIsolationJSON contains -// the JSON metadata for the struct -// [ZeroTrustGatewayConfigurationGetResponseSettingsBrowserIsolation] -type zeroTrustGatewayConfigurationGetResponseSettingsBrowserIsolationJSON struct { - NonIdentityEnabled apijson.Field - URLBrowserIsolationEnabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationGetResponseSettingsBrowserIsolation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationGetResponseSettingsBrowserIsolationJSON) RawJSON() string { - return r.raw -} - -// Custom certificate settings for BYO-PKI. -type ZeroTrustGatewayConfigurationGetResponseSettingsCustomCertificate struct { - // Enable use of custom certificate authority for signing Gateway traffic. - Enabled bool `json:"enabled,required"` - // UUID of certificate (ID from MTLS certificate store). - ID string `json:"id"` - // Certificate status (internal). - BindingStatus string `json:"binding_status"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayConfigurationGetResponseSettingsCustomCertificateJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationGetResponseSettingsCustomCertificateJSON contains -// the JSON metadata for the struct -// [ZeroTrustGatewayConfigurationGetResponseSettingsCustomCertificate] -type zeroTrustGatewayConfigurationGetResponseSettingsCustomCertificateJSON struct { - Enabled apijson.Field - ID apijson.Field - BindingStatus apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationGetResponseSettingsCustomCertificate) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationGetResponseSettingsCustomCertificateJSON) RawJSON() string { - return r.raw -} - -// Extended e-mail matching settings. -type ZeroTrustGatewayConfigurationGetResponseSettingsExtendedEmailMatching struct { - // Enable matching all variants of user emails (with + or . modifiers) used as - // criteria in Firewall policies. - Enabled bool `json:"enabled"` - JSON zeroTrustGatewayConfigurationGetResponseSettingsExtendedEmailMatchingJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationGetResponseSettingsExtendedEmailMatchingJSON -// contains the JSON metadata for the struct -// [ZeroTrustGatewayConfigurationGetResponseSettingsExtendedEmailMatching] -type zeroTrustGatewayConfigurationGetResponseSettingsExtendedEmailMatchingJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationGetResponseSettingsExtendedEmailMatching) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationGetResponseSettingsExtendedEmailMatchingJSON) RawJSON() string { - return r.raw -} - -// FIPS settings. -type ZeroTrustGatewayConfigurationGetResponseSettingsFips struct { - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - TLS bool `json:"tls"` - JSON zeroTrustGatewayConfigurationGetResponseSettingsFipsJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationGetResponseSettingsFipsJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayConfigurationGetResponseSettingsFips] -type zeroTrustGatewayConfigurationGetResponseSettingsFipsJSON struct { - TLS apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationGetResponseSettingsFips) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationGetResponseSettingsFipsJSON) RawJSON() string { - return r.raw -} - -// Protocol Detection settings. -type ZeroTrustGatewayConfigurationGetResponseSettingsProtocolDetection struct { - // Enable detecting protocol on initial bytes of client traffic. - Enabled bool `json:"enabled"` - JSON zeroTrustGatewayConfigurationGetResponseSettingsProtocolDetectionJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationGetResponseSettingsProtocolDetectionJSON contains -// the JSON metadata for the struct -// [ZeroTrustGatewayConfigurationGetResponseSettingsProtocolDetection] -type zeroTrustGatewayConfigurationGetResponseSettingsProtocolDetectionJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationGetResponseSettingsProtocolDetection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationGetResponseSettingsProtocolDetectionJSON) RawJSON() string { - return r.raw -} - -// TLS interception settings. -type ZeroTrustGatewayConfigurationGetResponseSettingsTLSDecrypt struct { - // Enable inspecting encrypted HTTP traffic. - Enabled bool `json:"enabled"` - JSON zeroTrustGatewayConfigurationGetResponseSettingsTLSDecryptJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationGetResponseSettingsTLSDecryptJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayConfigurationGetResponseSettingsTLSDecrypt] -type zeroTrustGatewayConfigurationGetResponseSettingsTLSDecryptJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationGetResponseSettingsTLSDecrypt) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationGetResponseSettingsTLSDecryptJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayConfigurationUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // account settings. - Settings param.Field[ZeroTrustGatewayConfigurationUpdateParamsSettings] `json:"settings"` -} - -func (r ZeroTrustGatewayConfigurationUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// account settings. -type ZeroTrustGatewayConfigurationUpdateParamsSettings struct { - // Activity log settings. - ActivityLog param.Field[ZeroTrustGatewayConfigurationUpdateParamsSettingsActivityLog] `json:"activity_log"` - // Anti-virus settings. - Antivirus param.Field[ZeroTrustGatewayConfigurationUpdateParamsSettingsAntivirus] `json:"antivirus"` - // Block page layout settings. - BlockPage param.Field[ZeroTrustGatewayConfigurationUpdateParamsSettingsBlockPage] `json:"block_page"` - // DLP body scanning settings. - BodyScanning param.Field[ZeroTrustGatewayConfigurationUpdateParamsSettingsBodyScanning] `json:"body_scanning"` - // Browser isolation settings. - BrowserIsolation param.Field[ZeroTrustGatewayConfigurationUpdateParamsSettingsBrowserIsolation] `json:"browser_isolation"` - // Custom certificate settings for BYO-PKI. - CustomCertificate param.Field[ZeroTrustGatewayConfigurationUpdateParamsSettingsCustomCertificate] `json:"custom_certificate"` - // Extended e-mail matching settings. - ExtendedEmailMatching param.Field[ZeroTrustGatewayConfigurationUpdateParamsSettingsExtendedEmailMatching] `json:"extended_email_matching"` - // FIPS settings. - Fips param.Field[ZeroTrustGatewayConfigurationUpdateParamsSettingsFips] `json:"fips"` - // Protocol Detection settings. - ProtocolDetection param.Field[ZeroTrustGatewayConfigurationUpdateParamsSettingsProtocolDetection] `json:"protocol_detection"` - // TLS interception settings. - TLSDecrypt param.Field[ZeroTrustGatewayConfigurationUpdateParamsSettingsTLSDecrypt] `json:"tls_decrypt"` -} - -func (r ZeroTrustGatewayConfigurationUpdateParamsSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Activity log settings. -type ZeroTrustGatewayConfigurationUpdateParamsSettingsActivityLog struct { - // Enable activity logging. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ZeroTrustGatewayConfigurationUpdateParamsSettingsActivityLog) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Anti-virus settings. -type ZeroTrustGatewayConfigurationUpdateParamsSettingsAntivirus struct { - // Enable anti-virus scanning on downloads. - EnabledDownloadPhase param.Field[bool] `json:"enabled_download_phase"` - // Enable anti-virus scanning on uploads. - EnabledUploadPhase param.Field[bool] `json:"enabled_upload_phase"` - // Block requests for files that cannot be scanned. - FailClosed param.Field[bool] `json:"fail_closed"` - // Configure a message to display on the user's device when an antivirus search is - // performed. - NotificationSettings param.Field[ZeroTrustGatewayConfigurationUpdateParamsSettingsAntivirusNotificationSettings] `json:"notification_settings"` -} - -func (r ZeroTrustGatewayConfigurationUpdateParamsSettingsAntivirus) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure a message to display on the user's device when an antivirus search is -// performed. -type ZeroTrustGatewayConfigurationUpdateParamsSettingsAntivirusNotificationSettings struct { - // Set notification on - Enabled param.Field[bool] `json:"enabled"` - // Customize the message shown in the notification. - Msg param.Field[string] `json:"msg"` - // Optional URL to direct users to additional information. If not set, the - // notification will open a block page. - SupportURL param.Field[string] `json:"support_url"` -} - -func (r ZeroTrustGatewayConfigurationUpdateParamsSettingsAntivirusNotificationSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Block page layout settings. -type ZeroTrustGatewayConfigurationUpdateParamsSettingsBlockPage struct { - // Block page background color in #rrggbb format. - BackgroundColor param.Field[string] `json:"background_color"` - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - Enabled param.Field[bool] `json:"enabled"` - // Block page footer text. - FooterText param.Field[string] `json:"footer_text"` - // Block page header text. - HeaderText param.Field[string] `json:"header_text"` - // Full URL to the logo file. - LogoPath param.Field[string] `json:"logo_path"` - // Admin email for users to contact. - MailtoAddress param.Field[string] `json:"mailto_address"` - // Subject line for emails created from block page. - MailtoSubject param.Field[string] `json:"mailto_subject"` - // Block page title. - Name param.Field[string] `json:"name"` - // Suppress detailed info at the bottom of the block page. - SuppressFooter param.Field[bool] `json:"suppress_footer"` -} - -func (r ZeroTrustGatewayConfigurationUpdateParamsSettingsBlockPage) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// DLP body scanning settings. -type ZeroTrustGatewayConfigurationUpdateParamsSettingsBodyScanning struct { - // Set the inspection mode to either `deep` or `shallow`. - InspectionMode param.Field[string] `json:"inspection_mode"` -} - -func (r ZeroTrustGatewayConfigurationUpdateParamsSettingsBodyScanning) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Browser isolation settings. -type ZeroTrustGatewayConfigurationUpdateParamsSettingsBrowserIsolation struct { - // Enable non-identity onramp support for Browser Isolation. - NonIdentityEnabled param.Field[bool] `json:"non_identity_enabled"` - // Enable Clientless Browser Isolation. - URLBrowserIsolationEnabled param.Field[bool] `json:"url_browser_isolation_enabled"` -} - -func (r ZeroTrustGatewayConfigurationUpdateParamsSettingsBrowserIsolation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Custom certificate settings for BYO-PKI. -type ZeroTrustGatewayConfigurationUpdateParamsSettingsCustomCertificate struct { - // Enable use of custom certificate authority for signing Gateway traffic. - Enabled param.Field[bool] `json:"enabled,required"` - // UUID of certificate (ID from MTLS certificate store). - ID param.Field[string] `json:"id"` -} - -func (r ZeroTrustGatewayConfigurationUpdateParamsSettingsCustomCertificate) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Extended e-mail matching settings. -type ZeroTrustGatewayConfigurationUpdateParamsSettingsExtendedEmailMatching struct { - // Enable matching all variants of user emails (with + or . modifiers) used as - // criteria in Firewall policies. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ZeroTrustGatewayConfigurationUpdateParamsSettingsExtendedEmailMatching) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// FIPS settings. -type ZeroTrustGatewayConfigurationUpdateParamsSettingsFips struct { - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - TLS param.Field[bool] `json:"tls"` -} - -func (r ZeroTrustGatewayConfigurationUpdateParamsSettingsFips) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Protocol Detection settings. -type ZeroTrustGatewayConfigurationUpdateParamsSettingsProtocolDetection struct { - // Enable detecting protocol on initial bytes of client traffic. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ZeroTrustGatewayConfigurationUpdateParamsSettingsProtocolDetection) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// TLS interception settings. -type ZeroTrustGatewayConfigurationUpdateParamsSettingsTLSDecrypt struct { - // Enable inspecting encrypted HTTP traffic. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ZeroTrustGatewayConfigurationUpdateParamsSettingsTLSDecrypt) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayConfigurationUpdateResponseEnvelope struct { - Errors []ZeroTrustGatewayConfigurationUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayConfigurationUpdateResponseEnvelopeMessages `json:"messages,required"` - // account settings. - Result ZeroTrustGatewayConfigurationUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayConfigurationUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayConfigurationUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationUpdateResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayConfigurationUpdateResponseEnvelope] -type zeroTrustGatewayConfigurationUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayConfigurationUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayConfigurationUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayConfigurationUpdateResponseEnvelopeErrors] -type zeroTrustGatewayConfigurationUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayConfigurationUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayConfigurationUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationUpdateResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayConfigurationUpdateResponseEnvelopeMessages] -type zeroTrustGatewayConfigurationUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayConfigurationUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayConfigurationUpdateResponseEnvelopeSuccessTrue ZeroTrustGatewayConfigurationUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayConfigurationEditParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // account settings. - Settings param.Field[ZeroTrustGatewayConfigurationEditParamsSettings] `json:"settings"` -} - -func (r ZeroTrustGatewayConfigurationEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// account settings. -type ZeroTrustGatewayConfigurationEditParamsSettings struct { - // Activity log settings. - ActivityLog param.Field[ZeroTrustGatewayConfigurationEditParamsSettingsActivityLog] `json:"activity_log"` - // Anti-virus settings. - Antivirus param.Field[ZeroTrustGatewayConfigurationEditParamsSettingsAntivirus] `json:"antivirus"` - // Block page layout settings. - BlockPage param.Field[ZeroTrustGatewayConfigurationEditParamsSettingsBlockPage] `json:"block_page"` - // DLP body scanning settings. - BodyScanning param.Field[ZeroTrustGatewayConfigurationEditParamsSettingsBodyScanning] `json:"body_scanning"` - // Browser isolation settings. - BrowserIsolation param.Field[ZeroTrustGatewayConfigurationEditParamsSettingsBrowserIsolation] `json:"browser_isolation"` - // Custom certificate settings for BYO-PKI. - CustomCertificate param.Field[ZeroTrustGatewayConfigurationEditParamsSettingsCustomCertificate] `json:"custom_certificate"` - // Extended e-mail matching settings. - ExtendedEmailMatching param.Field[ZeroTrustGatewayConfigurationEditParamsSettingsExtendedEmailMatching] `json:"extended_email_matching"` - // FIPS settings. - Fips param.Field[ZeroTrustGatewayConfigurationEditParamsSettingsFips] `json:"fips"` - // Protocol Detection settings. - ProtocolDetection param.Field[ZeroTrustGatewayConfigurationEditParamsSettingsProtocolDetection] `json:"protocol_detection"` - // TLS interception settings. - TLSDecrypt param.Field[ZeroTrustGatewayConfigurationEditParamsSettingsTLSDecrypt] `json:"tls_decrypt"` -} - -func (r ZeroTrustGatewayConfigurationEditParamsSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Activity log settings. -type ZeroTrustGatewayConfigurationEditParamsSettingsActivityLog struct { - // Enable activity logging. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ZeroTrustGatewayConfigurationEditParamsSettingsActivityLog) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Anti-virus settings. -type ZeroTrustGatewayConfigurationEditParamsSettingsAntivirus struct { - // Enable anti-virus scanning on downloads. - EnabledDownloadPhase param.Field[bool] `json:"enabled_download_phase"` - // Enable anti-virus scanning on uploads. - EnabledUploadPhase param.Field[bool] `json:"enabled_upload_phase"` - // Block requests for files that cannot be scanned. - FailClosed param.Field[bool] `json:"fail_closed"` - // Configure a message to display on the user's device when an antivirus search is - // performed. - NotificationSettings param.Field[ZeroTrustGatewayConfigurationEditParamsSettingsAntivirusNotificationSettings] `json:"notification_settings"` -} - -func (r ZeroTrustGatewayConfigurationEditParamsSettingsAntivirus) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure a message to display on the user's device when an antivirus search is -// performed. -type ZeroTrustGatewayConfigurationEditParamsSettingsAntivirusNotificationSettings struct { - // Set notification on - Enabled param.Field[bool] `json:"enabled"` - // Customize the message shown in the notification. - Msg param.Field[string] `json:"msg"` - // Optional URL to direct users to additional information. If not set, the - // notification will open a block page. - SupportURL param.Field[string] `json:"support_url"` -} - -func (r ZeroTrustGatewayConfigurationEditParamsSettingsAntivirusNotificationSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Block page layout settings. -type ZeroTrustGatewayConfigurationEditParamsSettingsBlockPage struct { - // Block page background color in #rrggbb format. - BackgroundColor param.Field[string] `json:"background_color"` - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - Enabled param.Field[bool] `json:"enabled"` - // Block page footer text. - FooterText param.Field[string] `json:"footer_text"` - // Block page header text. - HeaderText param.Field[string] `json:"header_text"` - // Full URL to the logo file. - LogoPath param.Field[string] `json:"logo_path"` - // Admin email for users to contact. - MailtoAddress param.Field[string] `json:"mailto_address"` - // Subject line for emails created from block page. - MailtoSubject param.Field[string] `json:"mailto_subject"` - // Block page title. - Name param.Field[string] `json:"name"` - // Suppress detailed info at the bottom of the block page. - SuppressFooter param.Field[bool] `json:"suppress_footer"` -} - -func (r ZeroTrustGatewayConfigurationEditParamsSettingsBlockPage) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// DLP body scanning settings. -type ZeroTrustGatewayConfigurationEditParamsSettingsBodyScanning struct { - // Set the inspection mode to either `deep` or `shallow`. - InspectionMode param.Field[string] `json:"inspection_mode"` -} - -func (r ZeroTrustGatewayConfigurationEditParamsSettingsBodyScanning) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Browser isolation settings. -type ZeroTrustGatewayConfigurationEditParamsSettingsBrowserIsolation struct { - // Enable non-identity onramp support for Browser Isolation. - NonIdentityEnabled param.Field[bool] `json:"non_identity_enabled"` - // Enable Clientless Browser Isolation. - URLBrowserIsolationEnabled param.Field[bool] `json:"url_browser_isolation_enabled"` -} - -func (r ZeroTrustGatewayConfigurationEditParamsSettingsBrowserIsolation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Custom certificate settings for BYO-PKI. -type ZeroTrustGatewayConfigurationEditParamsSettingsCustomCertificate struct { - // Enable use of custom certificate authority for signing Gateway traffic. - Enabled param.Field[bool] `json:"enabled,required"` - // UUID of certificate (ID from MTLS certificate store). - ID param.Field[string] `json:"id"` -} - -func (r ZeroTrustGatewayConfigurationEditParamsSettingsCustomCertificate) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Extended e-mail matching settings. -type ZeroTrustGatewayConfigurationEditParamsSettingsExtendedEmailMatching struct { - // Enable matching all variants of user emails (with + or . modifiers) used as - // criteria in Firewall policies. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ZeroTrustGatewayConfigurationEditParamsSettingsExtendedEmailMatching) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// FIPS settings. -type ZeroTrustGatewayConfigurationEditParamsSettingsFips struct { - // Enable only cipher suites and TLS versions compliant with FIPS 140-2. - TLS param.Field[bool] `json:"tls"` -} - -func (r ZeroTrustGatewayConfigurationEditParamsSettingsFips) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Protocol Detection settings. -type ZeroTrustGatewayConfigurationEditParamsSettingsProtocolDetection struct { - // Enable detecting protocol on initial bytes of client traffic. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ZeroTrustGatewayConfigurationEditParamsSettingsProtocolDetection) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// TLS interception settings. -type ZeroTrustGatewayConfigurationEditParamsSettingsTLSDecrypt struct { - // Enable inspecting encrypted HTTP traffic. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ZeroTrustGatewayConfigurationEditParamsSettingsTLSDecrypt) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayConfigurationEditResponseEnvelope struct { - Errors []ZeroTrustGatewayConfigurationEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayConfigurationEditResponseEnvelopeMessages `json:"messages,required"` - // account settings. - Result ZeroTrustGatewayConfigurationEditResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayConfigurationEditResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayConfigurationEditResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationEditResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayConfigurationEditResponseEnvelope] -type zeroTrustGatewayConfigurationEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayConfigurationEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayConfigurationEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayConfigurationEditResponseEnvelopeErrors] -type zeroTrustGatewayConfigurationEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayConfigurationEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayConfigurationEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayConfigurationEditResponseEnvelopeMessages] -type zeroTrustGatewayConfigurationEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayConfigurationEditResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayConfigurationEditResponseEnvelopeSuccessTrue ZeroTrustGatewayConfigurationEditResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayConfigurationGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustGatewayConfigurationGetResponseEnvelope struct { - Errors []ZeroTrustGatewayConfigurationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayConfigurationGetResponseEnvelopeMessages `json:"messages,required"` - // account settings. - Result ZeroTrustGatewayConfigurationGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayConfigurationGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayConfigurationGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayConfigurationGetResponseEnvelope] -type zeroTrustGatewayConfigurationGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayConfigurationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayConfigurationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayConfigurationGetResponseEnvelopeErrors] -type zeroTrustGatewayConfigurationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayConfigurationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayConfigurationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayConfigurationGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayConfigurationGetResponseEnvelopeMessages] -type zeroTrustGatewayConfigurationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayConfigurationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayConfigurationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayConfigurationGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayConfigurationGetResponseEnvelopeSuccessTrue ZeroTrustGatewayConfigurationGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustgatewayconfiguration_test.go b/zerotrustgatewayconfiguration_test.go deleted file mode 100644 index f96917c0da9..00000000000 --- a/zerotrustgatewayconfiguration_test.go +++ /dev/null @@ -1,190 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustGatewayConfigurationUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Configurations.Update(context.TODO(), cloudflare.ZeroTrustGatewayConfigurationUpdateParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Settings: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationUpdateParamsSettings{ - ActivityLog: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationUpdateParamsSettingsActivityLog{ - Enabled: cloudflare.F(true), - }), - Antivirus: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationUpdateParamsSettingsAntivirus{ - EnabledDownloadPhase: cloudflare.F(false), - EnabledUploadPhase: cloudflare.F(false), - FailClosed: cloudflare.F(false), - NotificationSettings: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationUpdateParamsSettingsAntivirusNotificationSettings{ - Enabled: cloudflare.F(true), - Msg: cloudflare.F("string"), - SupportURL: cloudflare.F("string"), - }), - }), - BlockPage: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationUpdateParamsSettingsBlockPage{ - BackgroundColor: cloudflare.F("string"), - Enabled: cloudflare.F(true), - FooterText: cloudflare.F("--footer--"), - HeaderText: cloudflare.F("--header--"), - LogoPath: cloudflare.F("https://logos.com/a.png"), - MailtoAddress: cloudflare.F("admin@example.com"), - MailtoSubject: cloudflare.F("Blocked User Inquiry"), - Name: cloudflare.F("Cloudflare"), - SuppressFooter: cloudflare.F(false), - }), - BodyScanning: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationUpdateParamsSettingsBodyScanning{ - InspectionMode: cloudflare.F("deep"), - }), - BrowserIsolation: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationUpdateParamsSettingsBrowserIsolation{ - NonIdentityEnabled: cloudflare.F(true), - URLBrowserIsolationEnabled: cloudflare.F(true), - }), - CustomCertificate: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationUpdateParamsSettingsCustomCertificate{ - Enabled: cloudflare.F(true), - ID: cloudflare.F("d1b364c5-1311-466e-a194-f0e943e0799f"), - }), - ExtendedEmailMatching: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationUpdateParamsSettingsExtendedEmailMatching{ - Enabled: cloudflare.F(true), - }), - Fips: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationUpdateParamsSettingsFips{ - TLS: cloudflare.F(true), - }), - ProtocolDetection: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationUpdateParamsSettingsProtocolDetection{ - Enabled: cloudflare.F(true), - }), - TLSDecrypt: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationUpdateParamsSettingsTLSDecrypt{ - Enabled: cloudflare.F(true), - }), - }), - }) - 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 TestZeroTrustGatewayConfigurationEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Configurations.Edit(context.TODO(), cloudflare.ZeroTrustGatewayConfigurationEditParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Settings: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationEditParamsSettings{ - ActivityLog: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationEditParamsSettingsActivityLog{ - Enabled: cloudflare.F(true), - }), - Antivirus: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationEditParamsSettingsAntivirus{ - EnabledDownloadPhase: cloudflare.F(false), - EnabledUploadPhase: cloudflare.F(false), - FailClosed: cloudflare.F(false), - NotificationSettings: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationEditParamsSettingsAntivirusNotificationSettings{ - Enabled: cloudflare.F(true), - Msg: cloudflare.F("string"), - SupportURL: cloudflare.F("string"), - }), - }), - BlockPage: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationEditParamsSettingsBlockPage{ - BackgroundColor: cloudflare.F("string"), - Enabled: cloudflare.F(true), - FooterText: cloudflare.F("--footer--"), - HeaderText: cloudflare.F("--header--"), - LogoPath: cloudflare.F("https://logos.com/a.png"), - MailtoAddress: cloudflare.F("admin@example.com"), - MailtoSubject: cloudflare.F("Blocked User Inquiry"), - Name: cloudflare.F("Cloudflare"), - SuppressFooter: cloudflare.F(false), - }), - BodyScanning: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationEditParamsSettingsBodyScanning{ - InspectionMode: cloudflare.F("deep"), - }), - BrowserIsolation: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationEditParamsSettingsBrowserIsolation{ - NonIdentityEnabled: cloudflare.F(true), - URLBrowserIsolationEnabled: cloudflare.F(true), - }), - CustomCertificate: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationEditParamsSettingsCustomCertificate{ - Enabled: cloudflare.F(true), - ID: cloudflare.F("d1b364c5-1311-466e-a194-f0e943e0799f"), - }), - ExtendedEmailMatching: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationEditParamsSettingsExtendedEmailMatching{ - Enabled: cloudflare.F(true), - }), - Fips: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationEditParamsSettingsFips{ - TLS: cloudflare.F(true), - }), - ProtocolDetection: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationEditParamsSettingsProtocolDetection{ - Enabled: cloudflare.F(true), - }), - TLSDecrypt: cloudflare.F(cloudflare.ZeroTrustGatewayConfigurationEditParamsSettingsTLSDecrypt{ - Enabled: cloudflare.F(true), - }), - }), - }) - 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 TestZeroTrustGatewayConfigurationGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Configurations.Get(context.TODO(), cloudflare.ZeroTrustGatewayConfigurationGetParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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/zerotrustgatewaylist.go b/zerotrustgatewaylist.go deleted file mode 100644 index e896c4240ac..00000000000 --- a/zerotrustgatewaylist.go +++ /dev/null @@ -1,1002 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustGatewayListService 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 [NewZeroTrustGatewayListService] -// method instead. -type ZeroTrustGatewayListService struct { - Options []option.RequestOption - Items *ZeroTrustGatewayListItemService -} - -// NewZeroTrustGatewayListService 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 NewZeroTrustGatewayListService(opts ...option.RequestOption) (r *ZeroTrustGatewayListService) { - r = &ZeroTrustGatewayListService{} - r.Options = opts - r.Items = NewZeroTrustGatewayListItemService(opts...) - return -} - -// Creates a new Zero Trust list. -func (r *ZeroTrustGatewayListService) New(ctx context.Context, params ZeroTrustGatewayListNewParams, opts ...option.RequestOption) (res *ZeroTrustGatewayListNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayListNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/lists", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a configured Zero Trust list. -func (r *ZeroTrustGatewayListService) Update(ctx context.Context, listID string, params ZeroTrustGatewayListUpdateParams, opts ...option.RequestOption) (res *ZeroTrustGatewayListUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayListUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/lists/%s", params.AccountID, listID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches all Zero Trust lists for an account. -func (r *ZeroTrustGatewayListService) List(ctx context.Context, query ZeroTrustGatewayListListParams, opts ...option.RequestOption) (res *[]ZeroTrustGatewayListListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayListListResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/lists", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a Zero Trust list. -func (r *ZeroTrustGatewayListService) Delete(ctx context.Context, listID string, body ZeroTrustGatewayListDeleteParams, opts ...option.RequestOption) (res *ZeroTrustGatewayListDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayListDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/lists/%s", body.AccountID, listID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Appends or removes an item from a configured Zero Trust list. -func (r *ZeroTrustGatewayListService) Edit(ctx context.Context, listID string, params ZeroTrustGatewayListEditParams, opts ...option.RequestOption) (res *ZeroTrustGatewayListEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayListEditResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/lists/%s", params.AccountID, listID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a single Zero Trust list. -func (r *ZeroTrustGatewayListService) Get(ctx context.Context, listID string, query ZeroTrustGatewayListGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewayListGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayListGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/lists/%s", query.AccountID, listID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustGatewayListNewResponse struct { - // API Resource UUID tag. - ID string `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The description of the list. - Description string `json:"description"` - // The items in the list. - Items []ZeroTrustGatewayListNewResponseItem `json:"items"` - // The name of the list. - Name string `json:"name"` - // The type of list. - Type ZeroTrustGatewayListNewResponseType `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayListNewResponseJSON `json:"-"` -} - -// zeroTrustGatewayListNewResponseJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayListNewResponse] -type zeroTrustGatewayListNewResponseJSON struct { - ID apijson.Field - CreatedAt apijson.Field - Description apijson.Field - Items apijson.Field - Name apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListNewResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListNewResponseItem struct { - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The value of the item in a list. - Value string `json:"value"` - JSON zeroTrustGatewayListNewResponseItemJSON `json:"-"` -} - -// zeroTrustGatewayListNewResponseItemJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayListNewResponseItem] -type zeroTrustGatewayListNewResponseItemJSON struct { - CreatedAt apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListNewResponseItem) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListNewResponseItemJSON) RawJSON() string { - return r.raw -} - -// The type of list. -type ZeroTrustGatewayListNewResponseType string - -const ( - ZeroTrustGatewayListNewResponseTypeSerial ZeroTrustGatewayListNewResponseType = "SERIAL" - ZeroTrustGatewayListNewResponseTypeURL ZeroTrustGatewayListNewResponseType = "URL" - ZeroTrustGatewayListNewResponseTypeDomain ZeroTrustGatewayListNewResponseType = "DOMAIN" - ZeroTrustGatewayListNewResponseTypeEmail ZeroTrustGatewayListNewResponseType = "EMAIL" - ZeroTrustGatewayListNewResponseTypeIP ZeroTrustGatewayListNewResponseType = "IP" -) - -type ZeroTrustGatewayListUpdateResponse struct { - // API Resource UUID tag. - ID string `json:"id"` - // The number of items in the list. - Count float64 `json:"count"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The description of the list. - Description string `json:"description"` - // The name of the list. - Name string `json:"name"` - // The type of list. - Type ZeroTrustGatewayListUpdateResponseType `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayListUpdateResponseJSON `json:"-"` -} - -// zeroTrustGatewayListUpdateResponseJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayListUpdateResponse] -type zeroTrustGatewayListUpdateResponseJSON struct { - ID apijson.Field - Count apijson.Field - CreatedAt apijson.Field - Description apijson.Field - Name apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// The type of list. -type ZeroTrustGatewayListUpdateResponseType string - -const ( - ZeroTrustGatewayListUpdateResponseTypeSerial ZeroTrustGatewayListUpdateResponseType = "SERIAL" - ZeroTrustGatewayListUpdateResponseTypeURL ZeroTrustGatewayListUpdateResponseType = "URL" - ZeroTrustGatewayListUpdateResponseTypeDomain ZeroTrustGatewayListUpdateResponseType = "DOMAIN" - ZeroTrustGatewayListUpdateResponseTypeEmail ZeroTrustGatewayListUpdateResponseType = "EMAIL" - ZeroTrustGatewayListUpdateResponseTypeIP ZeroTrustGatewayListUpdateResponseType = "IP" -) - -type ZeroTrustGatewayListListResponse struct { - // API Resource UUID tag. - ID string `json:"id"` - // The number of items in the list. - Count float64 `json:"count"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The description of the list. - Description string `json:"description"` - // The name of the list. - Name string `json:"name"` - // The type of list. - Type ZeroTrustGatewayListListResponseType `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayListListResponseJSON `json:"-"` -} - -// zeroTrustGatewayListListResponseJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayListListResponse] -type zeroTrustGatewayListListResponseJSON struct { - ID apijson.Field - Count apijson.Field - CreatedAt apijson.Field - Description apijson.Field - Name apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListListResponseJSON) RawJSON() string { - return r.raw -} - -// The type of list. -type ZeroTrustGatewayListListResponseType string - -const ( - ZeroTrustGatewayListListResponseTypeSerial ZeroTrustGatewayListListResponseType = "SERIAL" - ZeroTrustGatewayListListResponseTypeURL ZeroTrustGatewayListListResponseType = "URL" - ZeroTrustGatewayListListResponseTypeDomain ZeroTrustGatewayListListResponseType = "DOMAIN" - ZeroTrustGatewayListListResponseTypeEmail ZeroTrustGatewayListListResponseType = "EMAIL" - ZeroTrustGatewayListListResponseTypeIP ZeroTrustGatewayListListResponseType = "IP" -) - -// Union satisfied by [ZeroTrustGatewayListDeleteResponseUnknown] or -// [shared.UnionString]. -type ZeroTrustGatewayListDeleteResponse interface { - ImplementsZeroTrustGatewayListDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustGatewayListDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustGatewayListEditResponse struct { - // API Resource UUID tag. - ID string `json:"id"` - // The number of items in the list. - Count float64 `json:"count"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The description of the list. - Description string `json:"description"` - // The name of the list. - Name string `json:"name"` - // The type of list. - Type ZeroTrustGatewayListEditResponseType `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayListEditResponseJSON `json:"-"` -} - -// zeroTrustGatewayListEditResponseJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayListEditResponse] -type zeroTrustGatewayListEditResponseJSON struct { - ID apijson.Field - Count apijson.Field - CreatedAt apijson.Field - Description apijson.Field - Name apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListEditResponseJSON) RawJSON() string { - return r.raw -} - -// The type of list. -type ZeroTrustGatewayListEditResponseType string - -const ( - ZeroTrustGatewayListEditResponseTypeSerial ZeroTrustGatewayListEditResponseType = "SERIAL" - ZeroTrustGatewayListEditResponseTypeURL ZeroTrustGatewayListEditResponseType = "URL" - ZeroTrustGatewayListEditResponseTypeDomain ZeroTrustGatewayListEditResponseType = "DOMAIN" - ZeroTrustGatewayListEditResponseTypeEmail ZeroTrustGatewayListEditResponseType = "EMAIL" - ZeroTrustGatewayListEditResponseTypeIP ZeroTrustGatewayListEditResponseType = "IP" -) - -type ZeroTrustGatewayListGetResponse struct { - // API Resource UUID tag. - ID string `json:"id"` - // The number of items in the list. - Count float64 `json:"count"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The description of the list. - Description string `json:"description"` - // The name of the list. - Name string `json:"name"` - // The type of list. - Type ZeroTrustGatewayListGetResponseType `json:"type"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayListGetResponseJSON `json:"-"` -} - -// zeroTrustGatewayListGetResponseJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayListGetResponse] -type zeroTrustGatewayListGetResponseJSON struct { - ID apijson.Field - Count apijson.Field - CreatedAt apijson.Field - Description apijson.Field - Name apijson.Field - Type apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListGetResponseJSON) RawJSON() string { - return r.raw -} - -// The type of list. -type ZeroTrustGatewayListGetResponseType string - -const ( - ZeroTrustGatewayListGetResponseTypeSerial ZeroTrustGatewayListGetResponseType = "SERIAL" - ZeroTrustGatewayListGetResponseTypeURL ZeroTrustGatewayListGetResponseType = "URL" - ZeroTrustGatewayListGetResponseTypeDomain ZeroTrustGatewayListGetResponseType = "DOMAIN" - ZeroTrustGatewayListGetResponseTypeEmail ZeroTrustGatewayListGetResponseType = "EMAIL" - ZeroTrustGatewayListGetResponseTypeIP ZeroTrustGatewayListGetResponseType = "IP" -) - -type ZeroTrustGatewayListNewParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // The name of the list. - Name param.Field[string] `json:"name,required"` - // The type of list. - Type param.Field[ZeroTrustGatewayListNewParamsType] `json:"type,required"` - // The description of the list. - Description param.Field[string] `json:"description"` - // The items in the list. - Items param.Field[[]ZeroTrustGatewayListNewParamsItem] `json:"items"` -} - -func (r ZeroTrustGatewayListNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of list. -type ZeroTrustGatewayListNewParamsType string - -const ( - ZeroTrustGatewayListNewParamsTypeSerial ZeroTrustGatewayListNewParamsType = "SERIAL" - ZeroTrustGatewayListNewParamsTypeURL ZeroTrustGatewayListNewParamsType = "URL" - ZeroTrustGatewayListNewParamsTypeDomain ZeroTrustGatewayListNewParamsType = "DOMAIN" - ZeroTrustGatewayListNewParamsTypeEmail ZeroTrustGatewayListNewParamsType = "EMAIL" - ZeroTrustGatewayListNewParamsTypeIP ZeroTrustGatewayListNewParamsType = "IP" -) - -type ZeroTrustGatewayListNewParamsItem struct { - // The value of the item in a list. - Value param.Field[string] `json:"value"` -} - -func (r ZeroTrustGatewayListNewParamsItem) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayListNewResponseEnvelope struct { - Errors []ZeroTrustGatewayListNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayListNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayListNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayListNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayListNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayListNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayListNewResponseEnvelope] -type zeroTrustGatewayListNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayListNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayListNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayListNewResponseEnvelopeErrors] -type zeroTrustGatewayListNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayListNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayListNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayListNewResponseEnvelopeMessages] -type zeroTrustGatewayListNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayListNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayListNewResponseEnvelopeSuccessTrue ZeroTrustGatewayListNewResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayListUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // The name of the list. - Name param.Field[string] `json:"name,required"` - // The description of the list. - Description param.Field[string] `json:"description"` -} - -func (r ZeroTrustGatewayListUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayListUpdateResponseEnvelope struct { - Errors []ZeroTrustGatewayListUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayListUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayListUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayListUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayListUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayListUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayListUpdateResponseEnvelope] -type zeroTrustGatewayListUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayListUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayListUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayListUpdateResponseEnvelopeErrors] -type zeroTrustGatewayListUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayListUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayListUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayListUpdateResponseEnvelopeMessages] -type zeroTrustGatewayListUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayListUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayListUpdateResponseEnvelopeSuccessTrue ZeroTrustGatewayListUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayListListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustGatewayListListResponseEnvelope struct { - Errors []ZeroTrustGatewayListListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayListListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustGatewayListListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustGatewayListListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustGatewayListListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustGatewayListListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayListListResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayListListResponseEnvelope] -type zeroTrustGatewayListListResponseEnvelopeJSON 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 *ZeroTrustGatewayListListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayListListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayListListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayListListResponseEnvelopeErrors] -type zeroTrustGatewayListListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayListListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayListListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayListListResponseEnvelopeMessages] -type zeroTrustGatewayListListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayListListResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayListListResponseEnvelopeSuccessTrue ZeroTrustGatewayListListResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayListListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustGatewayListListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustGatewayListListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayListListResponseEnvelopeResultInfo] -type zeroTrustGatewayListListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListDeleteParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustGatewayListDeleteResponseEnvelope struct { - Errors []ZeroTrustGatewayListDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayListDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayListDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayListDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayListDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayListDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayListDeleteResponseEnvelope] -type zeroTrustGatewayListDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayListDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayListDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayListDeleteResponseEnvelopeErrors] -type zeroTrustGatewayListDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayListDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayListDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayListDeleteResponseEnvelopeMessages] -type zeroTrustGatewayListDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayListDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayListDeleteResponseEnvelopeSuccessTrue ZeroTrustGatewayListDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayListEditParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // The items in the list. - Append param.Field[[]ZeroTrustGatewayListEditParamsAppend] `json:"append"` - // A list of the item values you want to remove. - Remove param.Field[[]string] `json:"remove"` -} - -func (r ZeroTrustGatewayListEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayListEditParamsAppend struct { - // The value of the item in a list. - Value param.Field[string] `json:"value"` -} - -func (r ZeroTrustGatewayListEditParamsAppend) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayListEditResponseEnvelope struct { - Errors []ZeroTrustGatewayListEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayListEditResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayListEditResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayListEditResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayListEditResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayListEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayListEditResponseEnvelope] -type zeroTrustGatewayListEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayListEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayListEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayListEditResponseEnvelopeErrors] -type zeroTrustGatewayListEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayListEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayListEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayListEditResponseEnvelopeMessages] -type zeroTrustGatewayListEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayListEditResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayListEditResponseEnvelopeSuccessTrue ZeroTrustGatewayListEditResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayListGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustGatewayListGetResponseEnvelope struct { - Errors []ZeroTrustGatewayListGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayListGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayListGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayListGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayListGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayListGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayListGetResponseEnvelope] -type zeroTrustGatewayListGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayListGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayListGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayListGetResponseEnvelopeErrors] -type zeroTrustGatewayListGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayListGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayListGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayListGetResponseEnvelopeMessages] -type zeroTrustGatewayListGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayListGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayListGetResponseEnvelopeSuccessTrue ZeroTrustGatewayListGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustgatewaylist_test.go b/zerotrustgatewaylist_test.go deleted file mode 100644 index b40970b6c92..00000000000 --- a/zerotrustgatewaylist_test.go +++ /dev/null @@ -1,206 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustGatewayListNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Lists.New(context.TODO(), cloudflare.ZeroTrustGatewayListNewParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Name: cloudflare.F("Admin Serial Numbers"), - Type: cloudflare.F(cloudflare.ZeroTrustGatewayListNewParamsTypeSerial), - Description: cloudflare.F("The serial numbers for administrators"), - Items: cloudflare.F([]cloudflare.ZeroTrustGatewayListNewParamsItem{{ - Value: cloudflare.F("8GE8721REF"), - }, { - Value: cloudflare.F("8GE8721REF"), - }, { - Value: cloudflare.F("8GE8721REF"), - }}), - }) - 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 TestZeroTrustGatewayListUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Lists.Update( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustGatewayListUpdateParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Name: cloudflare.F("Admin Serial Numbers"), - Description: cloudflare.F("The serial numbers for administrators"), - }, - ) - 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 TestZeroTrustGatewayListList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Lists.List(context.TODO(), cloudflare.ZeroTrustGatewayListListParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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 TestZeroTrustGatewayListDelete(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Lists.Delete( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustGatewayListDeleteParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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 TestZeroTrustGatewayListEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Lists.Edit( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustGatewayListEditParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Append: cloudflare.F([]cloudflare.ZeroTrustGatewayListEditParamsAppend{{ - Value: cloudflare.F("8GE8721REF"), - }, { - Value: cloudflare.F("8GE8721REF"), - }, { - Value: cloudflare.F("8GE8721REF"), - }}), - Remove: cloudflare.F([]string{"8GE8721REF", "8GE8721REF", "8GE8721REF"}), - }, - ) - 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 TestZeroTrustGatewayListGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Lists.Get( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustGatewayListGetParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrustgatewaylistitem.go b/zerotrustgatewaylistitem.go deleted file mode 100644 index 234f293abf7..00000000000 --- a/zerotrustgatewaylistitem.go +++ /dev/null @@ -1,188 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustGatewayListItemService 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 -// [NewZeroTrustGatewayListItemService] method instead. -type ZeroTrustGatewayListItemService struct { - Options []option.RequestOption -} - -// NewZeroTrustGatewayListItemService 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 NewZeroTrustGatewayListItemService(opts ...option.RequestOption) (r *ZeroTrustGatewayListItemService) { - r = &ZeroTrustGatewayListItemService{} - r.Options = opts - return -} - -// Fetches all items in a single Zero Trust list. -func (r *ZeroTrustGatewayListItemService) List(ctx context.Context, listID string, query ZeroTrustGatewayListItemListParams, opts ...option.RequestOption) (res *[][]ZeroTrustGatewayListItemListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayListItemListResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/lists/%s/items", query.AccountID, listID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustGatewayListItemListResponse struct { - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The value of the item in a list. - Value string `json:"value"` - JSON zeroTrustGatewayListItemListResponseJSON `json:"-"` -} - -// zeroTrustGatewayListItemListResponseJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayListItemListResponse] -type zeroTrustGatewayListItemListResponseJSON struct { - CreatedAt apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListItemListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListItemListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListItemListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustGatewayListItemListResponseEnvelope struct { - Errors []ZeroTrustGatewayListItemListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayListItemListResponseEnvelopeMessages `json:"messages,required"` - Result [][]ZeroTrustGatewayListItemListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustGatewayListItemListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustGatewayListItemListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustGatewayListItemListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayListItemListResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayListItemListResponseEnvelope] -type zeroTrustGatewayListItemListResponseEnvelopeJSON 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 *ZeroTrustGatewayListItemListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListItemListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListItemListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayListItemListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayListItemListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayListItemListResponseEnvelopeErrors] -type zeroTrustGatewayListItemListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListItemListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListItemListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayListItemListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayListItemListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayListItemListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayListItemListResponseEnvelopeMessages] -type zeroTrustGatewayListItemListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListItemListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListItemListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayListItemListResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayListItemListResponseEnvelopeSuccessTrue ZeroTrustGatewayListItemListResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayListItemListResponseEnvelopeResultInfo struct { - // Total results returned based on your search parameters. - Count float64 `json:"count"` - // Current page within paginated list of results. - Page float64 `json:"page"` - // Number of results per page of results. - PerPage float64 `json:"per_page"` - // Total results available without any search parameters. - TotalCount float64 `json:"total_count"` - JSON zeroTrustGatewayListItemListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustGatewayListItemListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayListItemListResponseEnvelopeResultInfo] -type zeroTrustGatewayListItemListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayListItemListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayListItemListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zerotrustgatewaylistitem_test.go b/zerotrustgatewaylistitem_test.go deleted file mode 100644 index 5b3157bb718..00000000000 --- a/zerotrustgatewaylistitem_test.go +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustGatewayListItemList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Lists.Items.List( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustGatewayListItemListParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrustgatewaylocation.go b/zerotrustgatewaylocation.go deleted file mode 100644 index 589fd4c9aa1..00000000000 --- a/zerotrustgatewaylocation.go +++ /dev/null @@ -1,890 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustGatewayLocationService 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 -// [NewZeroTrustGatewayLocationService] method instead. -type ZeroTrustGatewayLocationService struct { - Options []option.RequestOption -} - -// NewZeroTrustGatewayLocationService 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 NewZeroTrustGatewayLocationService(opts ...option.RequestOption) (r *ZeroTrustGatewayLocationService) { - r = &ZeroTrustGatewayLocationService{} - r.Options = opts - return -} - -// Creates a new Zero Trust Gateway location. -func (r *ZeroTrustGatewayLocationService) New(ctx context.Context, params ZeroTrustGatewayLocationNewParams, opts ...option.RequestOption) (res *ZeroTrustGatewayLocationNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayLocationNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/locations", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a configured Zero Trust Gateway location. -func (r *ZeroTrustGatewayLocationService) Update(ctx context.Context, locationID interface{}, params ZeroTrustGatewayLocationUpdateParams, opts ...option.RequestOption) (res *ZeroTrustGatewayLocationUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayLocationUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/locations/%v", params.AccountID, locationID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches Zero Trust Gateway locations for an account. -func (r *ZeroTrustGatewayLocationService) List(ctx context.Context, query ZeroTrustGatewayLocationListParams, opts ...option.RequestOption) (res *[]ZeroTrustGatewayLocationListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayLocationListResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/locations", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a configured Zero Trust Gateway location. -func (r *ZeroTrustGatewayLocationService) Delete(ctx context.Context, locationID interface{}, body ZeroTrustGatewayLocationDeleteParams, opts ...option.RequestOption) (res *ZeroTrustGatewayLocationDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayLocationDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/locations/%v", body.AccountID, locationID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a single Zero Trust Gateway location. -func (r *ZeroTrustGatewayLocationService) Get(ctx context.Context, locationID interface{}, query ZeroTrustGatewayLocationGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewayLocationGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayLocationGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/locations/%v", query.AccountID, locationID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustGatewayLocationNewResponse struct { - ID interface{} `json:"id"` - // True if the location is the default location. - ClientDefault bool `json:"client_default"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The DNS over HTTPS domain to send DNS requests to. This field is auto-generated - // by Gateway. - DohSubdomain string `json:"doh_subdomain"` - // True if the location needs to resolve EDNS queries. - EcsSupport bool `json:"ecs_support"` - // IPV6 destination ip assigned to this location. DNS requests sent to this IP will - // counted as the request under this location. This field is auto-generated by - // Gateway. - IP string `json:"ip"` - // The name of the location. - Name string `json:"name"` - // A list of network ranges that requests from this location would originate from. - Networks []ZeroTrustGatewayLocationNewResponseNetwork `json:"networks"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayLocationNewResponseJSON `json:"-"` -} - -// zeroTrustGatewayLocationNewResponseJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayLocationNewResponse] -type zeroTrustGatewayLocationNewResponseJSON struct { - ID apijson.Field - ClientDefault apijson.Field - CreatedAt apijson.Field - DohSubdomain apijson.Field - EcsSupport apijson.Field - IP apijson.Field - Name apijson.Field - Networks apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationNewResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLocationNewResponseNetwork struct { - // The IPv4 address or IPv4 CIDR. IPv4 CIDRs are limited to a maximum of /24. - Network string `json:"network,required"` - JSON zeroTrustGatewayLocationNewResponseNetworkJSON `json:"-"` -} - -// zeroTrustGatewayLocationNewResponseNetworkJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayLocationNewResponseNetwork] -type zeroTrustGatewayLocationNewResponseNetworkJSON struct { - Network apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationNewResponseNetwork) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationNewResponseNetworkJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLocationUpdateResponse struct { - ID interface{} `json:"id"` - // True if the location is the default location. - ClientDefault bool `json:"client_default"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The DNS over HTTPS domain to send DNS requests to. This field is auto-generated - // by Gateway. - DohSubdomain string `json:"doh_subdomain"` - // True if the location needs to resolve EDNS queries. - EcsSupport bool `json:"ecs_support"` - // IPV6 destination ip assigned to this location. DNS requests sent to this IP will - // counted as the request under this location. This field is auto-generated by - // Gateway. - IP string `json:"ip"` - // The name of the location. - Name string `json:"name"` - // A list of network ranges that requests from this location would originate from. - Networks []ZeroTrustGatewayLocationUpdateResponseNetwork `json:"networks"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayLocationUpdateResponseJSON `json:"-"` -} - -// zeroTrustGatewayLocationUpdateResponseJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayLocationUpdateResponse] -type zeroTrustGatewayLocationUpdateResponseJSON struct { - ID apijson.Field - ClientDefault apijson.Field - CreatedAt apijson.Field - DohSubdomain apijson.Field - EcsSupport apijson.Field - IP apijson.Field - Name apijson.Field - Networks apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLocationUpdateResponseNetwork struct { - // The IPv4 address or IPv4 CIDR. IPv4 CIDRs are limited to a maximum of /24. - Network string `json:"network,required"` - JSON zeroTrustGatewayLocationUpdateResponseNetworkJSON `json:"-"` -} - -// zeroTrustGatewayLocationUpdateResponseNetworkJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayLocationUpdateResponseNetwork] -type zeroTrustGatewayLocationUpdateResponseNetworkJSON struct { - Network apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationUpdateResponseNetwork) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationUpdateResponseNetworkJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLocationListResponse struct { - ID interface{} `json:"id"` - // True if the location is the default location. - ClientDefault bool `json:"client_default"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The DNS over HTTPS domain to send DNS requests to. This field is auto-generated - // by Gateway. - DohSubdomain string `json:"doh_subdomain"` - // True if the location needs to resolve EDNS queries. - EcsSupport bool `json:"ecs_support"` - // IPV6 destination ip assigned to this location. DNS requests sent to this IP will - // counted as the request under this location. This field is auto-generated by - // Gateway. - IP string `json:"ip"` - // The name of the location. - Name string `json:"name"` - // A list of network ranges that requests from this location would originate from. - Networks []ZeroTrustGatewayLocationListResponseNetwork `json:"networks"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayLocationListResponseJSON `json:"-"` -} - -// zeroTrustGatewayLocationListResponseJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayLocationListResponse] -type zeroTrustGatewayLocationListResponseJSON struct { - ID apijson.Field - ClientDefault apijson.Field - CreatedAt apijson.Field - DohSubdomain apijson.Field - EcsSupport apijson.Field - IP apijson.Field - Name apijson.Field - Networks apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLocationListResponseNetwork struct { - // The IPv4 address or IPv4 CIDR. IPv4 CIDRs are limited to a maximum of /24. - Network string `json:"network,required"` - JSON zeroTrustGatewayLocationListResponseNetworkJSON `json:"-"` -} - -// zeroTrustGatewayLocationListResponseNetworkJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayLocationListResponseNetwork] -type zeroTrustGatewayLocationListResponseNetworkJSON struct { - Network apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationListResponseNetwork) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationListResponseNetworkJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [ZeroTrustGatewayLocationDeleteResponseUnknown] or -// [shared.UnionString]. -type ZeroTrustGatewayLocationDeleteResponse interface { - ImplementsZeroTrustGatewayLocationDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustGatewayLocationDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustGatewayLocationGetResponse struct { - ID interface{} `json:"id"` - // True if the location is the default location. - ClientDefault bool `json:"client_default"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // The DNS over HTTPS domain to send DNS requests to. This field is auto-generated - // by Gateway. - DohSubdomain string `json:"doh_subdomain"` - // True if the location needs to resolve EDNS queries. - EcsSupport bool `json:"ecs_support"` - // IPV6 destination ip assigned to this location. DNS requests sent to this IP will - // counted as the request under this location. This field is auto-generated by - // Gateway. - IP string `json:"ip"` - // The name of the location. - Name string `json:"name"` - // A list of network ranges that requests from this location would originate from. - Networks []ZeroTrustGatewayLocationGetResponseNetwork `json:"networks"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayLocationGetResponseJSON `json:"-"` -} - -// zeroTrustGatewayLocationGetResponseJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayLocationGetResponse] -type zeroTrustGatewayLocationGetResponseJSON struct { - ID apijson.Field - ClientDefault apijson.Field - CreatedAt apijson.Field - DohSubdomain apijson.Field - EcsSupport apijson.Field - IP apijson.Field - Name apijson.Field - Networks apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLocationGetResponseNetwork struct { - // The IPv4 address or IPv4 CIDR. IPv4 CIDRs are limited to a maximum of /24. - Network string `json:"network,required"` - JSON zeroTrustGatewayLocationGetResponseNetworkJSON `json:"-"` -} - -// zeroTrustGatewayLocationGetResponseNetworkJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayLocationGetResponseNetwork] -type zeroTrustGatewayLocationGetResponseNetworkJSON struct { - Network apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationGetResponseNetwork) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationGetResponseNetworkJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLocationNewParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // The name of the location. - Name param.Field[string] `json:"name,required"` - // True if the location is the default location. - ClientDefault param.Field[bool] `json:"client_default"` - // True if the location needs to resolve EDNS queries. - EcsSupport param.Field[bool] `json:"ecs_support"` - // A list of network ranges that requests from this location would originate from. - Networks param.Field[[]ZeroTrustGatewayLocationNewParamsNetwork] `json:"networks"` -} - -func (r ZeroTrustGatewayLocationNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayLocationNewParamsNetwork struct { - // The IPv4 address or IPv4 CIDR. IPv4 CIDRs are limited to a maximum of /24. - Network param.Field[string] `json:"network,required"` -} - -func (r ZeroTrustGatewayLocationNewParamsNetwork) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayLocationNewResponseEnvelope struct { - Errors []ZeroTrustGatewayLocationNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayLocationNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayLocationNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayLocationNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayLocationNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayLocationNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayLocationNewResponseEnvelope] -type zeroTrustGatewayLocationNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLocationNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayLocationNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayLocationNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayLocationNewResponseEnvelopeErrors] -type zeroTrustGatewayLocationNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLocationNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayLocationNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayLocationNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayLocationNewResponseEnvelopeMessages] -type zeroTrustGatewayLocationNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayLocationNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayLocationNewResponseEnvelopeSuccessTrue ZeroTrustGatewayLocationNewResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayLocationUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // The name of the location. - Name param.Field[string] `json:"name,required"` - // True if the location is the default location. - ClientDefault param.Field[bool] `json:"client_default"` - // True if the location needs to resolve EDNS queries. - EcsSupport param.Field[bool] `json:"ecs_support"` - // A list of network ranges that requests from this location would originate from. - Networks param.Field[[]ZeroTrustGatewayLocationUpdateParamsNetwork] `json:"networks"` -} - -func (r ZeroTrustGatewayLocationUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayLocationUpdateParamsNetwork struct { - // The IPv4 address or IPv4 CIDR. IPv4 CIDRs are limited to a maximum of /24. - Network param.Field[string] `json:"network,required"` -} - -func (r ZeroTrustGatewayLocationUpdateParamsNetwork) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayLocationUpdateResponseEnvelope struct { - Errors []ZeroTrustGatewayLocationUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayLocationUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayLocationUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayLocationUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayLocationUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayLocationUpdateResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayLocationUpdateResponseEnvelope] -type zeroTrustGatewayLocationUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLocationUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayLocationUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayLocationUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayLocationUpdateResponseEnvelopeErrors] -type zeroTrustGatewayLocationUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLocationUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayLocationUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayLocationUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayLocationUpdateResponseEnvelopeMessages] -type zeroTrustGatewayLocationUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayLocationUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayLocationUpdateResponseEnvelopeSuccessTrue ZeroTrustGatewayLocationUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayLocationListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustGatewayLocationListResponseEnvelope struct { - Errors []ZeroTrustGatewayLocationListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayLocationListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustGatewayLocationListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustGatewayLocationListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustGatewayLocationListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustGatewayLocationListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayLocationListResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayLocationListResponseEnvelope] -type zeroTrustGatewayLocationListResponseEnvelopeJSON 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 *ZeroTrustGatewayLocationListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLocationListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayLocationListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayLocationListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayLocationListResponseEnvelopeErrors] -type zeroTrustGatewayLocationListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLocationListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayLocationListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayLocationListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayLocationListResponseEnvelopeMessages] -type zeroTrustGatewayLocationListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayLocationListResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayLocationListResponseEnvelopeSuccessTrue ZeroTrustGatewayLocationListResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayLocationListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustGatewayLocationListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustGatewayLocationListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayLocationListResponseEnvelopeResultInfo] -type zeroTrustGatewayLocationListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLocationDeleteParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustGatewayLocationDeleteResponseEnvelope struct { - Errors []ZeroTrustGatewayLocationDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayLocationDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayLocationDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayLocationDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayLocationDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayLocationDeleteResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayLocationDeleteResponseEnvelope] -type zeroTrustGatewayLocationDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLocationDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayLocationDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayLocationDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayLocationDeleteResponseEnvelopeErrors] -type zeroTrustGatewayLocationDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLocationDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayLocationDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayLocationDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayLocationDeleteResponseEnvelopeMessages] -type zeroTrustGatewayLocationDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayLocationDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayLocationDeleteResponseEnvelopeSuccessTrue ZeroTrustGatewayLocationDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayLocationGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustGatewayLocationGetResponseEnvelope struct { - Errors []ZeroTrustGatewayLocationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayLocationGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayLocationGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayLocationGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayLocationGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayLocationGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayLocationGetResponseEnvelope] -type zeroTrustGatewayLocationGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLocationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayLocationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayLocationGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayLocationGetResponseEnvelopeErrors] -type zeroTrustGatewayLocationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLocationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayLocationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayLocationGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayLocationGetResponseEnvelopeMessages] -type zeroTrustGatewayLocationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLocationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLocationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayLocationGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayLocationGetResponseEnvelopeSuccessTrue ZeroTrustGatewayLocationGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustgatewaylocation_test.go b/zerotrustgatewaylocation_test.go deleted file mode 100644 index 02cdd224b0d..00000000000 --- a/zerotrustgatewaylocation_test.go +++ /dev/null @@ -1,176 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustGatewayLocationNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Locations.New(context.TODO(), cloudflare.ZeroTrustGatewayLocationNewParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Name: cloudflare.F("Austin Office Location"), - ClientDefault: cloudflare.F(false), - EcsSupport: cloudflare.F(false), - Networks: cloudflare.F([]cloudflare.ZeroTrustGatewayLocationNewParamsNetwork{{ - Network: cloudflare.F("192.0.2.1/32"), - }, { - Network: cloudflare.F("192.0.2.1/32"), - }, { - Network: cloudflare.F("192.0.2.1/32"), - }}), - }) - 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 TestZeroTrustGatewayLocationUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Locations.Update( - context.TODO(), - "ed35569b41ce4d1facfe683550f54086", - cloudflare.ZeroTrustGatewayLocationUpdateParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Name: cloudflare.F("Austin Office Location"), - ClientDefault: cloudflare.F(false), - EcsSupport: cloudflare.F(false), - Networks: cloudflare.F([]cloudflare.ZeroTrustGatewayLocationUpdateParamsNetwork{{ - Network: cloudflare.F("192.0.2.1/32"), - }, { - Network: cloudflare.F("192.0.2.1/32"), - }, { - Network: cloudflare.F("192.0.2.1/32"), - }}), - }, - ) - 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 TestZeroTrustGatewayLocationList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Locations.List(context.TODO(), cloudflare.ZeroTrustGatewayLocationListParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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 TestZeroTrustGatewayLocationDelete(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Locations.Delete( - context.TODO(), - "ed35569b41ce4d1facfe683550f54086", - cloudflare.ZeroTrustGatewayLocationDeleteParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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 TestZeroTrustGatewayLocationGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Locations.Get( - context.TODO(), - "ed35569b41ce4d1facfe683550f54086", - cloudflare.ZeroTrustGatewayLocationGetParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrustgatewaylogging.go b/zerotrustgatewaylogging.go deleted file mode 100644 index 27f9f3607c1..00000000000 --- a/zerotrustgatewaylogging.go +++ /dev/null @@ -1,362 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustGatewayLoggingService 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 -// [NewZeroTrustGatewayLoggingService] method instead. -type ZeroTrustGatewayLoggingService struct { - Options []option.RequestOption -} - -// NewZeroTrustGatewayLoggingService 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 NewZeroTrustGatewayLoggingService(opts ...option.RequestOption) (r *ZeroTrustGatewayLoggingService) { - r = &ZeroTrustGatewayLoggingService{} - r.Options = opts - return -} - -// Updates logging settings for the current Zero Trust account. -func (r *ZeroTrustGatewayLoggingService) Update(ctx context.Context, params ZeroTrustGatewayLoggingUpdateParams, opts ...option.RequestOption) (res *ZeroTrustGatewayLoggingUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayLoggingUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/logging", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the current logging settings for Zero Trust account. -func (r *ZeroTrustGatewayLoggingService) Get(ctx context.Context, query ZeroTrustGatewayLoggingGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewayLoggingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayLoggingGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/logging", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustGatewayLoggingUpdateResponse struct { - // Redact personally identifiable information from activity logging (PII fields - // are: source IP, user email, user ID, device ID, URL, referrer, user agent). - RedactPii bool `json:"redact_pii"` - // Logging settings by rule type. - SettingsByRuleType ZeroTrustGatewayLoggingUpdateResponseSettingsByRuleType `json:"settings_by_rule_type"` - JSON zeroTrustGatewayLoggingUpdateResponseJSON `json:"-"` -} - -// zeroTrustGatewayLoggingUpdateResponseJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayLoggingUpdateResponse] -type zeroTrustGatewayLoggingUpdateResponseJSON struct { - RedactPii apijson.Field - SettingsByRuleType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLoggingUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLoggingUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// Logging settings by rule type. -type ZeroTrustGatewayLoggingUpdateResponseSettingsByRuleType struct { - // Logging settings for DNS firewall. - DNS interface{} `json:"dns"` - // Logging settings for HTTP/HTTPS firewall. - HTTP interface{} `json:"http"` - // Logging settings for Network firewall. - L4 interface{} `json:"l4"` - JSON zeroTrustGatewayLoggingUpdateResponseSettingsByRuleTypeJSON `json:"-"` -} - -// zeroTrustGatewayLoggingUpdateResponseSettingsByRuleTypeJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayLoggingUpdateResponseSettingsByRuleType] -type zeroTrustGatewayLoggingUpdateResponseSettingsByRuleTypeJSON struct { - DNS apijson.Field - HTTP apijson.Field - L4 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLoggingUpdateResponseSettingsByRuleType) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLoggingUpdateResponseSettingsByRuleTypeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLoggingGetResponse struct { - // Redact personally identifiable information from activity logging (PII fields - // are: source IP, user email, user ID, device ID, URL, referrer, user agent). - RedactPii bool `json:"redact_pii"` - // Logging settings by rule type. - SettingsByRuleType ZeroTrustGatewayLoggingGetResponseSettingsByRuleType `json:"settings_by_rule_type"` - JSON zeroTrustGatewayLoggingGetResponseJSON `json:"-"` -} - -// zeroTrustGatewayLoggingGetResponseJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayLoggingGetResponse] -type zeroTrustGatewayLoggingGetResponseJSON struct { - RedactPii apijson.Field - SettingsByRuleType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLoggingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLoggingGetResponseJSON) RawJSON() string { - return r.raw -} - -// Logging settings by rule type. -type ZeroTrustGatewayLoggingGetResponseSettingsByRuleType struct { - // Logging settings for DNS firewall. - DNS interface{} `json:"dns"` - // Logging settings for HTTP/HTTPS firewall. - HTTP interface{} `json:"http"` - // Logging settings for Network firewall. - L4 interface{} `json:"l4"` - JSON zeroTrustGatewayLoggingGetResponseSettingsByRuleTypeJSON `json:"-"` -} - -// zeroTrustGatewayLoggingGetResponseSettingsByRuleTypeJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayLoggingGetResponseSettingsByRuleType] -type zeroTrustGatewayLoggingGetResponseSettingsByRuleTypeJSON struct { - DNS apijson.Field - HTTP apijson.Field - L4 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLoggingGetResponseSettingsByRuleType) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLoggingGetResponseSettingsByRuleTypeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLoggingUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // Redact personally identifiable information from activity logging (PII fields - // are: source IP, user email, user ID, device ID, URL, referrer, user agent). - RedactPii param.Field[bool] `json:"redact_pii"` - // Logging settings by rule type. - SettingsByRuleType param.Field[ZeroTrustGatewayLoggingUpdateParamsSettingsByRuleType] `json:"settings_by_rule_type"` -} - -func (r ZeroTrustGatewayLoggingUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Logging settings by rule type. -type ZeroTrustGatewayLoggingUpdateParamsSettingsByRuleType struct { - // Logging settings for DNS firewall. - DNS param.Field[interface{}] `json:"dns"` - // Logging settings for HTTP/HTTPS firewall. - HTTP param.Field[interface{}] `json:"http"` - // Logging settings for Network firewall. - L4 param.Field[interface{}] `json:"l4"` -} - -func (r ZeroTrustGatewayLoggingUpdateParamsSettingsByRuleType) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayLoggingUpdateResponseEnvelope struct { - Errors []ZeroTrustGatewayLoggingUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayLoggingUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayLoggingUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayLoggingUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayLoggingUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayLoggingUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayLoggingUpdateResponseEnvelope] -type zeroTrustGatewayLoggingUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLoggingUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLoggingUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLoggingUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayLoggingUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayLoggingUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayLoggingUpdateResponseEnvelopeErrors] -type zeroTrustGatewayLoggingUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLoggingUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLoggingUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLoggingUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayLoggingUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayLoggingUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayLoggingUpdateResponseEnvelopeMessages] -type zeroTrustGatewayLoggingUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLoggingUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLoggingUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayLoggingUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayLoggingUpdateResponseEnvelopeSuccessTrue ZeroTrustGatewayLoggingUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayLoggingGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustGatewayLoggingGetResponseEnvelope struct { - Errors []ZeroTrustGatewayLoggingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayLoggingGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayLoggingGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayLoggingGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayLoggingGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayLoggingGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayLoggingGetResponseEnvelope] -type zeroTrustGatewayLoggingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLoggingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLoggingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLoggingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayLoggingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayLoggingGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayLoggingGetResponseEnvelopeErrors] -type zeroTrustGatewayLoggingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLoggingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLoggingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayLoggingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayLoggingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayLoggingGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayLoggingGetResponseEnvelopeMessages] -type zeroTrustGatewayLoggingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayLoggingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayLoggingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayLoggingGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayLoggingGetResponseEnvelopeSuccessTrue ZeroTrustGatewayLoggingGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustgatewaylogging_test.go b/zerotrustgatewaylogging_test.go deleted file mode 100644 index 2b579b3d388..00000000000 --- a/zerotrustgatewaylogging_test.go +++ /dev/null @@ -1,72 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustGatewayLoggingUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Loggings.Update(context.TODO(), cloudflare.ZeroTrustGatewayLoggingUpdateParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - RedactPii: cloudflare.F(true), - SettingsByRuleType: cloudflare.F(cloudflare.ZeroTrustGatewayLoggingUpdateParamsSettingsByRuleType{ - DNS: cloudflare.F[any](map[string]interface{}{}), - HTTP: cloudflare.F[any](map[string]interface{}{}), - L4: cloudflare.F[any](map[string]interface{}{}), - }), - }) - 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 TestZeroTrustGatewayLoggingGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Loggings.Get(context.TODO(), cloudflare.ZeroTrustGatewayLoggingGetParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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/zerotrustgatewayproxyendpoint.go b/zerotrustgatewayproxyendpoint.go deleted file mode 100644 index 19bbdf6c40d..00000000000 --- a/zerotrustgatewayproxyendpoint.go +++ /dev/null @@ -1,741 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustGatewayProxyEndpointService 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 -// [NewZeroTrustGatewayProxyEndpointService] method instead. -type ZeroTrustGatewayProxyEndpointService struct { - Options []option.RequestOption -} - -// NewZeroTrustGatewayProxyEndpointService 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 NewZeroTrustGatewayProxyEndpointService(opts ...option.RequestOption) (r *ZeroTrustGatewayProxyEndpointService) { - r = &ZeroTrustGatewayProxyEndpointService{} - r.Options = opts - return -} - -// Creates a new Zero Trust Gateway proxy endpoint. -func (r *ZeroTrustGatewayProxyEndpointService) New(ctx context.Context, params ZeroTrustGatewayProxyEndpointNewParams, opts ...option.RequestOption) (res *ZeroTrustGatewayProxyEndpointNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayProxyEndpointNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/proxy_endpoints", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a single Zero Trust Gateway proxy endpoint. -func (r *ZeroTrustGatewayProxyEndpointService) List(ctx context.Context, query ZeroTrustGatewayProxyEndpointListParams, opts ...option.RequestOption) (res *[]ZeroTrustGatewayProxyEndpointListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayProxyEndpointListResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/proxy_endpoints", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a configured Zero Trust Gateway proxy endpoint. -func (r *ZeroTrustGatewayProxyEndpointService) Delete(ctx context.Context, proxyEndpointID interface{}, body ZeroTrustGatewayProxyEndpointDeleteParams, opts ...option.RequestOption) (res *ZeroTrustGatewayProxyEndpointDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayProxyEndpointDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/proxy_endpoints/%v", body.AccountID, proxyEndpointID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a configured Zero Trust Gateway proxy endpoint. -func (r *ZeroTrustGatewayProxyEndpointService) Edit(ctx context.Context, proxyEndpointID interface{}, params ZeroTrustGatewayProxyEndpointEditParams, opts ...option.RequestOption) (res *ZeroTrustGatewayProxyEndpointEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayProxyEndpointEditResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/proxy_endpoints/%v", params.AccountID, proxyEndpointID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches all Zero Trust Gateway proxy endpoints for an account. -func (r *ZeroTrustGatewayProxyEndpointService) Get(ctx context.Context, proxyEndpointID interface{}, query ZeroTrustGatewayProxyEndpointGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewayProxyEndpointGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayProxyEndpointGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/proxy_endpoints/%v", query.AccountID, proxyEndpointID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustGatewayProxyEndpointNewResponse struct { - ID interface{} `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // A list of CIDRs to restrict ingress connections. - IPs []string `json:"ips"` - // The name of the proxy endpoint. - Name string `json:"name"` - // The subdomain to be used as the destination in the proxy client. - Subdomain string `json:"subdomain"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayProxyEndpointNewResponseJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointNewResponseJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayProxyEndpointNewResponse] -type zeroTrustGatewayProxyEndpointNewResponseJSON struct { - ID apijson.Field - CreatedAt apijson.Field - IPs apijson.Field - Name apijson.Field - Subdomain apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointNewResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayProxyEndpointListResponse struct { - ID interface{} `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // A list of CIDRs to restrict ingress connections. - IPs []string `json:"ips"` - // The name of the proxy endpoint. - Name string `json:"name"` - // The subdomain to be used as the destination in the proxy client. - Subdomain string `json:"subdomain"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayProxyEndpointListResponseJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointListResponseJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayProxyEndpointListResponse] -type zeroTrustGatewayProxyEndpointListResponseJSON struct { - ID apijson.Field - CreatedAt apijson.Field - IPs apijson.Field - Name apijson.Field - Subdomain apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointListResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [ZeroTrustGatewayProxyEndpointDeleteResponseUnknown] or -// [shared.UnionString]. -type ZeroTrustGatewayProxyEndpointDeleteResponse interface { - ImplementsZeroTrustGatewayProxyEndpointDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustGatewayProxyEndpointDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustGatewayProxyEndpointEditResponse struct { - ID interface{} `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // A list of CIDRs to restrict ingress connections. - IPs []string `json:"ips"` - // The name of the proxy endpoint. - Name string `json:"name"` - // The subdomain to be used as the destination in the proxy client. - Subdomain string `json:"subdomain"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayProxyEndpointEditResponseJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointEditResponseJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayProxyEndpointEditResponse] -type zeroTrustGatewayProxyEndpointEditResponseJSON struct { - ID apijson.Field - CreatedAt apijson.Field - IPs apijson.Field - Name apijson.Field - Subdomain apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointEditResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayProxyEndpointGetResponse struct { - ID interface{} `json:"id"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // A list of CIDRs to restrict ingress connections. - IPs []string `json:"ips"` - // The name of the proxy endpoint. - Name string `json:"name"` - // The subdomain to be used as the destination in the proxy client. - Subdomain string `json:"subdomain"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayProxyEndpointGetResponseJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointGetResponseJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayProxyEndpointGetResponse] -type zeroTrustGatewayProxyEndpointGetResponseJSON struct { - ID apijson.Field - CreatedAt apijson.Field - IPs apijson.Field - Name apijson.Field - Subdomain apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayProxyEndpointNewParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // A list of CIDRs to restrict ingress connections. - IPs param.Field[[]string] `json:"ips,required"` - // The name of the proxy endpoint. - Name param.Field[string] `json:"name,required"` - // The subdomain to be used as the destination in the proxy client. - Subdomain param.Field[string] `json:"subdomain"` -} - -func (r ZeroTrustGatewayProxyEndpointNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayProxyEndpointNewResponseEnvelope struct { - Errors []ZeroTrustGatewayProxyEndpointNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayProxyEndpointNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayProxyEndpointNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayProxyEndpointNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayProxyEndpointNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointNewResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayProxyEndpointNewResponseEnvelope] -type zeroTrustGatewayProxyEndpointNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayProxyEndpointNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayProxyEndpointNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayProxyEndpointNewResponseEnvelopeErrors] -type zeroTrustGatewayProxyEndpointNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayProxyEndpointNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayProxyEndpointNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayProxyEndpointNewResponseEnvelopeMessages] -type zeroTrustGatewayProxyEndpointNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayProxyEndpointNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayProxyEndpointNewResponseEnvelopeSuccessTrue ZeroTrustGatewayProxyEndpointNewResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayProxyEndpointListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustGatewayProxyEndpointListResponseEnvelope struct { - Errors []ZeroTrustGatewayProxyEndpointListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayProxyEndpointListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustGatewayProxyEndpointListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustGatewayProxyEndpointListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustGatewayProxyEndpointListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustGatewayProxyEndpointListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointListResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayProxyEndpointListResponseEnvelope] -type zeroTrustGatewayProxyEndpointListResponseEnvelopeJSON 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 *ZeroTrustGatewayProxyEndpointListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayProxyEndpointListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayProxyEndpointListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayProxyEndpointListResponseEnvelopeErrors] -type zeroTrustGatewayProxyEndpointListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayProxyEndpointListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayProxyEndpointListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayProxyEndpointListResponseEnvelopeMessages] -type zeroTrustGatewayProxyEndpointListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayProxyEndpointListResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayProxyEndpointListResponseEnvelopeSuccessTrue ZeroTrustGatewayProxyEndpointListResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayProxyEndpointListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustGatewayProxyEndpointListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointListResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayProxyEndpointListResponseEnvelopeResultInfo] -type zeroTrustGatewayProxyEndpointListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayProxyEndpointDeleteParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustGatewayProxyEndpointDeleteResponseEnvelope struct { - Errors []ZeroTrustGatewayProxyEndpointDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayProxyEndpointDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayProxyEndpointDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayProxyEndpointDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayProxyEndpointDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointDeleteResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayProxyEndpointDeleteResponseEnvelope] -type zeroTrustGatewayProxyEndpointDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayProxyEndpointDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayProxyEndpointDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayProxyEndpointDeleteResponseEnvelopeErrors] -type zeroTrustGatewayProxyEndpointDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayProxyEndpointDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayProxyEndpointDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointDeleteResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayProxyEndpointDeleteResponseEnvelopeMessages] -type zeroTrustGatewayProxyEndpointDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayProxyEndpointDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayProxyEndpointDeleteResponseEnvelopeSuccessTrue ZeroTrustGatewayProxyEndpointDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayProxyEndpointEditParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // A list of CIDRs to restrict ingress connections. - IPs param.Field[[]string] `json:"ips"` - // The name of the proxy endpoint. - Name param.Field[string] `json:"name"` - // The subdomain to be used as the destination in the proxy client. - Subdomain param.Field[string] `json:"subdomain"` -} - -func (r ZeroTrustGatewayProxyEndpointEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayProxyEndpointEditResponseEnvelope struct { - Errors []ZeroTrustGatewayProxyEndpointEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayProxyEndpointEditResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayProxyEndpointEditResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayProxyEndpointEditResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayProxyEndpointEditResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointEditResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayProxyEndpointEditResponseEnvelope] -type zeroTrustGatewayProxyEndpointEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayProxyEndpointEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayProxyEndpointEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayProxyEndpointEditResponseEnvelopeErrors] -type zeroTrustGatewayProxyEndpointEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayProxyEndpointEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayProxyEndpointEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayProxyEndpointEditResponseEnvelopeMessages] -type zeroTrustGatewayProxyEndpointEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayProxyEndpointEditResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayProxyEndpointEditResponseEnvelopeSuccessTrue ZeroTrustGatewayProxyEndpointEditResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayProxyEndpointGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustGatewayProxyEndpointGetResponseEnvelope struct { - Errors []ZeroTrustGatewayProxyEndpointGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayProxyEndpointGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayProxyEndpointGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayProxyEndpointGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayProxyEndpointGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayProxyEndpointGetResponseEnvelope] -type zeroTrustGatewayProxyEndpointGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayProxyEndpointGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayProxyEndpointGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayProxyEndpointGetResponseEnvelopeErrors] -type zeroTrustGatewayProxyEndpointGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayProxyEndpointGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayProxyEndpointGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayProxyEndpointGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayProxyEndpointGetResponseEnvelopeMessages] -type zeroTrustGatewayProxyEndpointGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayProxyEndpointGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayProxyEndpointGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayProxyEndpointGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayProxyEndpointGetResponseEnvelopeSuccessTrue ZeroTrustGatewayProxyEndpointGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustgatewayproxyendpoint_test.go b/zerotrustgatewayproxyendpoint_test.go deleted file mode 100644 index b66b6da601b..00000000000 --- a/zerotrustgatewayproxyendpoint_test.go +++ /dev/null @@ -1,162 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustGatewayProxyEndpointNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.ProxyEndpoints.New(context.TODO(), cloudflare.ZeroTrustGatewayProxyEndpointNewParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - IPs: cloudflare.F([]string{"192.0.2.1/32", "192.0.2.1/32", "192.0.2.1/32"}), - Name: cloudflare.F("Devops team"), - Subdomain: cloudflare.F("oli3n9zkz5.proxy.cloudflare-gateway.com"), - }) - 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 TestZeroTrustGatewayProxyEndpointList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.ProxyEndpoints.List(context.TODO(), cloudflare.ZeroTrustGatewayProxyEndpointListParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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 TestZeroTrustGatewayProxyEndpointDelete(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.ProxyEndpoints.Delete( - context.TODO(), - "ed35569b41ce4d1facfe683550f54086", - cloudflare.ZeroTrustGatewayProxyEndpointDeleteParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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 TestZeroTrustGatewayProxyEndpointEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.ProxyEndpoints.Edit( - context.TODO(), - "ed35569b41ce4d1facfe683550f54086", - cloudflare.ZeroTrustGatewayProxyEndpointEditParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - IPs: cloudflare.F([]string{"192.0.2.1/32", "192.0.2.1/32", "192.0.2.1/32"}), - Name: cloudflare.F("Devops team"), - Subdomain: cloudflare.F("oli3n9zkz5.proxy.cloudflare-gateway.com"), - }, - ) - 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 TestZeroTrustGatewayProxyEndpointGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.ProxyEndpoints.Get( - context.TODO(), - "ed35569b41ce4d1facfe683550f54086", - cloudflare.ZeroTrustGatewayProxyEndpointGetParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrustgatewayrule.go b/zerotrustgatewayrule.go deleted file mode 100644 index 9556fca58bb..00000000000 --- a/zerotrustgatewayrule.go +++ /dev/null @@ -1,3566 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustGatewayRuleService 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 [NewZeroTrustGatewayRuleService] -// method instead. -type ZeroTrustGatewayRuleService struct { - Options []option.RequestOption -} - -// NewZeroTrustGatewayRuleService 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 NewZeroTrustGatewayRuleService(opts ...option.RequestOption) (r *ZeroTrustGatewayRuleService) { - r = &ZeroTrustGatewayRuleService{} - r.Options = opts - return -} - -// Creates a new Zero Trust Gateway rule. -func (r *ZeroTrustGatewayRuleService) New(ctx context.Context, params ZeroTrustGatewayRuleNewParams, opts ...option.RequestOption) (res *ZeroTrustGatewayRuleNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayRuleNewResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/rules", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a configured Zero Trust Gateway rule. -func (r *ZeroTrustGatewayRuleService) Update(ctx context.Context, ruleID string, params ZeroTrustGatewayRuleUpdateParams, opts ...option.RequestOption) (res *ZeroTrustGatewayRuleUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayRuleUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/rules/%s", params.AccountID, ruleID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches the Zero Trust Gateway rules for an account. -func (r *ZeroTrustGatewayRuleService) List(ctx context.Context, query ZeroTrustGatewayRuleListParams, opts ...option.RequestOption) (res *[]ZeroTrustGatewayRuleListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayRuleListResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/rules", query.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a Zero Trust Gateway rule. -func (r *ZeroTrustGatewayRuleService) Delete(ctx context.Context, ruleID string, body ZeroTrustGatewayRuleDeleteParams, opts ...option.RequestOption) (res *ZeroTrustGatewayRuleDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayRuleDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/rules/%s", body.AccountID, ruleID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a single Zero Trust Gateway rule. -func (r *ZeroTrustGatewayRuleService) Get(ctx context.Context, ruleID string, query ZeroTrustGatewayRuleGetParams, opts ...option.RequestOption) (res *ZeroTrustGatewayRuleGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustGatewayRuleGetResponseEnvelope - path := fmt.Sprintf("accounts/%v/gateway/rules/%s", query.AccountID, ruleID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustGatewayRuleNewResponse struct { - // The API resource UUID. - ID string `json:"id"` - // The action to preform when the associated traffic, identity, and device posture - // expressions are either absent or evaluate to `true`. - Action ZeroTrustGatewayRuleNewResponseAction `json:"action"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Date of deletion, if any. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // The description of the rule. - Description string `json:"description"` - // The wirefilter expression used for device posture check matching. - DevicePosture string `json:"device_posture"` - // True if the rule is enabled. - Enabled bool `json:"enabled"` - // The protocol or layer to evaluate the traffic, identity, and device posture - // expressions. - Filters []ZeroTrustGatewayRuleNewResponseFilter `json:"filters"` - // The wirefilter expression used for identity matching. - Identity string `json:"identity"` - // The name of the rule. - Name string `json:"name"` - // Precedence sets the order of your rules. Lower values indicate higher - // precedence. At each processing phase, applicable rules are evaluated in - // ascending order of this value. - Precedence int64 `json:"precedence"` - // Additional settings that modify the rule's action. - RuleSettings ZeroTrustGatewayRuleNewResponseRuleSettings `json:"rule_settings"` - // The schedule for activating DNS policies. This does not apply to HTTP or network - // policies. - Schedule ZeroTrustGatewayRuleNewResponseSchedule `json:"schedule"` - // The wirefilter expression used for traffic matching. - Traffic string `json:"traffic"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayRuleNewResponseJSON `json:"-"` -} - -// zeroTrustGatewayRuleNewResponseJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayRuleNewResponse] -type zeroTrustGatewayRuleNewResponseJSON struct { - ID apijson.Field - Action apijson.Field - CreatedAt apijson.Field - DeletedAt apijson.Field - Description apijson.Field - DevicePosture apijson.Field - Enabled apijson.Field - Filters apijson.Field - Identity apijson.Field - Name apijson.Field - Precedence apijson.Field - RuleSettings apijson.Field - Schedule apijson.Field - Traffic apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleNewResponseJSON) RawJSON() string { - return r.raw -} - -// The action to preform when the associated traffic, identity, and device posture -// expressions are either absent or evaluate to `true`. -type ZeroTrustGatewayRuleNewResponseAction string - -const ( - ZeroTrustGatewayRuleNewResponseActionOn ZeroTrustGatewayRuleNewResponseAction = "on" - ZeroTrustGatewayRuleNewResponseActionOff ZeroTrustGatewayRuleNewResponseAction = "off" - ZeroTrustGatewayRuleNewResponseActionAllow ZeroTrustGatewayRuleNewResponseAction = "allow" - ZeroTrustGatewayRuleNewResponseActionBlock ZeroTrustGatewayRuleNewResponseAction = "block" - ZeroTrustGatewayRuleNewResponseActionScan ZeroTrustGatewayRuleNewResponseAction = "scan" - ZeroTrustGatewayRuleNewResponseActionNoscan ZeroTrustGatewayRuleNewResponseAction = "noscan" - ZeroTrustGatewayRuleNewResponseActionSafesearch ZeroTrustGatewayRuleNewResponseAction = "safesearch" - ZeroTrustGatewayRuleNewResponseActionYtrestricted ZeroTrustGatewayRuleNewResponseAction = "ytrestricted" - ZeroTrustGatewayRuleNewResponseActionIsolate ZeroTrustGatewayRuleNewResponseAction = "isolate" - ZeroTrustGatewayRuleNewResponseActionNoisolate ZeroTrustGatewayRuleNewResponseAction = "noisolate" - ZeroTrustGatewayRuleNewResponseActionOverride ZeroTrustGatewayRuleNewResponseAction = "override" - ZeroTrustGatewayRuleNewResponseActionL4Override ZeroTrustGatewayRuleNewResponseAction = "l4_override" - ZeroTrustGatewayRuleNewResponseActionEgress ZeroTrustGatewayRuleNewResponseAction = "egress" - ZeroTrustGatewayRuleNewResponseActionAuditSSH ZeroTrustGatewayRuleNewResponseAction = "audit_ssh" -) - -// The protocol or layer to use. -type ZeroTrustGatewayRuleNewResponseFilter string - -const ( - ZeroTrustGatewayRuleNewResponseFilterHTTP ZeroTrustGatewayRuleNewResponseFilter = "http" - ZeroTrustGatewayRuleNewResponseFilterDNS ZeroTrustGatewayRuleNewResponseFilter = "dns" - ZeroTrustGatewayRuleNewResponseFilterL4 ZeroTrustGatewayRuleNewResponseFilter = "l4" - ZeroTrustGatewayRuleNewResponseFilterEgress ZeroTrustGatewayRuleNewResponseFilter = "egress" -) - -// Additional settings that modify the rule's action. -type ZeroTrustGatewayRuleNewResponseRuleSettings struct { - // Add custom headers to allowed requests, in the form of key-value pairs. Keys are - // header names, pointing to an array with its header value(s). - AddHeaders interface{} `json:"add_headers"` - // Set by parent MSP accounts to enable their children to bypass this rule. - AllowChildBypass bool `json:"allow_child_bypass"` - // Settings for the Audit SSH action. - AuditSSH ZeroTrustGatewayRuleNewResponseRuleSettingsAuditSSH `json:"audit_ssh"` - // Configure how browser isolation behaves. - BisoAdminControls ZeroTrustGatewayRuleNewResponseRuleSettingsBisoAdminControls `json:"biso_admin_controls"` - // Enable the custom block page. - BlockPageEnabled bool `json:"block_page_enabled"` - // The text describing why this block occurred, displayed on the custom block page - // (if enabled). - BlockReason string `json:"block_reason"` - // Set by children MSP accounts to bypass their parent's rules. - BypassParentRule bool `json:"bypass_parent_rule"` - // Configure how session check behaves. - CheckSession ZeroTrustGatewayRuleNewResponseRuleSettingsCheckSession `json:"check_session"` - // Add your own custom resolvers to route queries that match the resolver policy. - // Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will - // route to the address closest to their origin. - DNSResolvers ZeroTrustGatewayRuleNewResponseRuleSettingsDNSResolvers `json:"dns_resolvers"` - // Configure how Gateway Proxy traffic egresses. You can enable this setting for - // rules with Egress actions and filters, or omit it to indicate local egress via - // WARP IPs. - Egress ZeroTrustGatewayRuleNewResponseRuleSettingsEgress `json:"egress"` - // INSECURE - disable DNSSEC validation (for Allow actions). - InsecureDisableDNSSECValidation bool `json:"insecure_disable_dnssec_validation"` - // Set to true to enable IPs in DNS resolver category blocks. By default categories - // only block based on domain names. - IPCategories bool `json:"ip_categories"` - // Set to true to include IPs in DNS resolver indicator feed blocks. By default - // indicator feeds only block based on domain names. - IPIndicatorFeeds bool `json:"ip_indicator_feeds"` - // Send matching traffic to the supplied destination IP address and port. - L4override ZeroTrustGatewayRuleNewResponseRuleSettingsL4override `json:"l4override"` - // Configure a notification to display on the user's device when this rule is - // matched. - NotificationSettings ZeroTrustGatewayRuleNewResponseRuleSettingsNotificationSettings `json:"notification_settings"` - // Override matching DNS queries with a hostname. - OverrideHost string `json:"override_host"` - // Override matching DNS queries with an IP or set of IPs. - OverrideIPs []string `json:"override_ips"` - // Configure DLP payload logging. - PayloadLog ZeroTrustGatewayRuleNewResponseRuleSettingsPayloadLog `json:"payload_log"` - // Enable to send queries that match the policy to Cloudflare's default 1.1.1.1 DNS - // resolver. Cannot be set when dns_resolvers are specified. - ResolveDNSThroughCloudflare bool `json:"resolve_dns_through_cloudflare"` - // Configure behavior when an upstream cert is invalid or an SSL error occurs. - UntrustedCert ZeroTrustGatewayRuleNewResponseRuleSettingsUntrustedCert `json:"untrusted_cert"` - JSON zeroTrustGatewayRuleNewResponseRuleSettingsJSON `json:"-"` -} - -// zeroTrustGatewayRuleNewResponseRuleSettingsJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayRuleNewResponseRuleSettings] -type zeroTrustGatewayRuleNewResponseRuleSettingsJSON struct { - AddHeaders apijson.Field - AllowChildBypass apijson.Field - AuditSSH apijson.Field - BisoAdminControls apijson.Field - BlockPageEnabled apijson.Field - BlockReason apijson.Field - BypassParentRule apijson.Field - CheckSession apijson.Field - DNSResolvers apijson.Field - Egress apijson.Field - InsecureDisableDNSSECValidation apijson.Field - IPCategories apijson.Field - IPIndicatorFeeds apijson.Field - L4override apijson.Field - NotificationSettings apijson.Field - OverrideHost apijson.Field - OverrideIPs apijson.Field - PayloadLog apijson.Field - ResolveDNSThroughCloudflare apijson.Field - UntrustedCert apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleNewResponseRuleSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleNewResponseRuleSettingsJSON) RawJSON() string { - return r.raw -} - -// Settings for the Audit SSH action. -type ZeroTrustGatewayRuleNewResponseRuleSettingsAuditSSH struct { - // Enable to turn on SSH command logging. - CommandLogging bool `json:"command_logging"` - JSON zeroTrustGatewayRuleNewResponseRuleSettingsAuditSSHJSON `json:"-"` -} - -// zeroTrustGatewayRuleNewResponseRuleSettingsAuditSSHJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayRuleNewResponseRuleSettingsAuditSSH] -type zeroTrustGatewayRuleNewResponseRuleSettingsAuditSSHJSON struct { - CommandLogging apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleNewResponseRuleSettingsAuditSSH) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleNewResponseRuleSettingsAuditSSHJSON) RawJSON() string { - return r.raw -} - -// Configure how browser isolation behaves. -type ZeroTrustGatewayRuleNewResponseRuleSettingsBisoAdminControls struct { - // Set to true to enable copy-pasting. - Dcp bool `json:"dcp"` - // Set to true to enable downloading. - Dd bool `json:"dd"` - // Set to true to enable keyboard usage. - Dk bool `json:"dk"` - // Set to true to enable printing. - Dp bool `json:"dp"` - // Set to true to enable uploading. - Du bool `json:"du"` - JSON zeroTrustGatewayRuleNewResponseRuleSettingsBisoAdminControlsJSON `json:"-"` -} - -// zeroTrustGatewayRuleNewResponseRuleSettingsBisoAdminControlsJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayRuleNewResponseRuleSettingsBisoAdminControls] -type zeroTrustGatewayRuleNewResponseRuleSettingsBisoAdminControlsJSON struct { - Dcp apijson.Field - Dd apijson.Field - Dk apijson.Field - Dp apijson.Field - Du apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleNewResponseRuleSettingsBisoAdminControls) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleNewResponseRuleSettingsBisoAdminControlsJSON) RawJSON() string { - return r.raw -} - -// Configure how session check behaves. -type ZeroTrustGatewayRuleNewResponseRuleSettingsCheckSession struct { - // Configure how fresh the session needs to be to be considered valid. - Duration string `json:"duration"` - // Set to true to enable session enforcement. - Enforce bool `json:"enforce"` - JSON zeroTrustGatewayRuleNewResponseRuleSettingsCheckSessionJSON `json:"-"` -} - -// zeroTrustGatewayRuleNewResponseRuleSettingsCheckSessionJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayRuleNewResponseRuleSettingsCheckSession] -type zeroTrustGatewayRuleNewResponseRuleSettingsCheckSessionJSON struct { - Duration apijson.Field - Enforce apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleNewResponseRuleSettingsCheckSession) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleNewResponseRuleSettingsCheckSessionJSON) RawJSON() string { - return r.raw -} - -// Add your own custom resolvers to route queries that match the resolver policy. -// Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will -// route to the address closest to their origin. -type ZeroTrustGatewayRuleNewResponseRuleSettingsDNSResolvers struct { - IPV4 []ZeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversIPV4 `json:"ipv4"` - IPV6 []ZeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversIPV6 `json:"ipv6"` - JSON zeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversJSON `json:"-"` -} - -// zeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayRuleNewResponseRuleSettingsDNSResolvers] -type zeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversJSON struct { - IPV4 apijson.Field - IPV6 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleNewResponseRuleSettingsDNSResolvers) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversIPV4 struct { - // IP address of upstream resolver. - IP string `json:"ip,required"` - // A port number to use for upstream resolver. - Port int64 `json:"port"` - // Whether to connect to this resolver over a private network. Must be set when - // vnet_id is set. - RouteThroughPrivateNetwork bool `json:"route_through_private_network"` - // Optionally specify a virtual network for this resolver. Uses default virtual - // network id if omitted. - VnetID string `json:"vnet_id"` - JSON zeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversIPV4JSON `json:"-"` -} - -// zeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversIPV4JSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversIPV4] -type zeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversIPV4JSON struct { - IP apijson.Field - Port apijson.Field - RouteThroughPrivateNetwork apijson.Field - VnetID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversIPV4) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversIPV4JSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversIPV6 struct { - // IP address of upstream resolver. - IP string `json:"ip,required"` - // A port number to use for upstream resolver. - Port int64 `json:"port"` - // Whether to connect to this resolver over a private network. Must be set when - // vnet_id is set. - RouteThroughPrivateNetwork bool `json:"route_through_private_network"` - // Optionally specify a virtual network for this resolver. Uses default virtual - // network id if omitted. - VnetID string `json:"vnet_id"` - JSON zeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversIPV6JSON `json:"-"` -} - -// zeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversIPV6JSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversIPV6] -type zeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversIPV6JSON struct { - IP apijson.Field - Port apijson.Field - RouteThroughPrivateNetwork apijson.Field - VnetID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversIPV6) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleNewResponseRuleSettingsDNSResolversIPV6JSON) RawJSON() string { - return r.raw -} - -// Configure how Gateway Proxy traffic egresses. You can enable this setting for -// rules with Egress actions and filters, or omit it to indicate local egress via -// WARP IPs. -type ZeroTrustGatewayRuleNewResponseRuleSettingsEgress struct { - // The IPv4 address to be used for egress. - IPV4 string `json:"ipv4"` - // The fallback IPv4 address to be used for egress in the event of an error - // egressing with the primary IPv4. Can be '0.0.0.0' to indicate local egress via - // WARP IPs. - IPV4Fallback string `json:"ipv4_fallback"` - // The IPv6 range to be used for egress. - IPV6 string `json:"ipv6"` - JSON zeroTrustGatewayRuleNewResponseRuleSettingsEgressJSON `json:"-"` -} - -// zeroTrustGatewayRuleNewResponseRuleSettingsEgressJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayRuleNewResponseRuleSettingsEgress] -type zeroTrustGatewayRuleNewResponseRuleSettingsEgressJSON struct { - IPV4 apijson.Field - IPV4Fallback apijson.Field - IPV6 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleNewResponseRuleSettingsEgress) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleNewResponseRuleSettingsEgressJSON) RawJSON() string { - return r.raw -} - -// Send matching traffic to the supplied destination IP address and port. -type ZeroTrustGatewayRuleNewResponseRuleSettingsL4override struct { - // IPv4 or IPv6 address. - IP string `json:"ip"` - // A port number to use for TCP/UDP overrides. - Port int64 `json:"port"` - JSON zeroTrustGatewayRuleNewResponseRuleSettingsL4overrideJSON `json:"-"` -} - -// zeroTrustGatewayRuleNewResponseRuleSettingsL4overrideJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayRuleNewResponseRuleSettingsL4override] -type zeroTrustGatewayRuleNewResponseRuleSettingsL4overrideJSON struct { - IP apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleNewResponseRuleSettingsL4override) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleNewResponseRuleSettingsL4overrideJSON) RawJSON() string { - return r.raw -} - -// Configure a notification to display on the user's device when this rule is -// matched. -type ZeroTrustGatewayRuleNewResponseRuleSettingsNotificationSettings struct { - // Set notification on - Enabled bool `json:"enabled"` - // Customize the message shown in the notification. - Msg string `json:"msg"` - // Optional URL to direct users to additional information. If not set, the - // notification will open a block page. - SupportURL string `json:"support_url"` - JSON zeroTrustGatewayRuleNewResponseRuleSettingsNotificationSettingsJSON `json:"-"` -} - -// zeroTrustGatewayRuleNewResponseRuleSettingsNotificationSettingsJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayRuleNewResponseRuleSettingsNotificationSettings] -type zeroTrustGatewayRuleNewResponseRuleSettingsNotificationSettingsJSON struct { - Enabled apijson.Field - Msg apijson.Field - SupportURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleNewResponseRuleSettingsNotificationSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleNewResponseRuleSettingsNotificationSettingsJSON) RawJSON() string { - return r.raw -} - -// Configure DLP payload logging. -type ZeroTrustGatewayRuleNewResponseRuleSettingsPayloadLog struct { - // Set to true to enable DLP payload logging for this rule. - Enabled bool `json:"enabled"` - JSON zeroTrustGatewayRuleNewResponseRuleSettingsPayloadLogJSON `json:"-"` -} - -// zeroTrustGatewayRuleNewResponseRuleSettingsPayloadLogJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayRuleNewResponseRuleSettingsPayloadLog] -type zeroTrustGatewayRuleNewResponseRuleSettingsPayloadLogJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleNewResponseRuleSettingsPayloadLog) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleNewResponseRuleSettingsPayloadLogJSON) RawJSON() string { - return r.raw -} - -// Configure behavior when an upstream cert is invalid or an SSL error occurs. -type ZeroTrustGatewayRuleNewResponseRuleSettingsUntrustedCert struct { - // The action performed when an untrusted certificate is seen. The default action - // is an error with HTTP code 526. - Action ZeroTrustGatewayRuleNewResponseRuleSettingsUntrustedCertAction `json:"action"` - JSON zeroTrustGatewayRuleNewResponseRuleSettingsUntrustedCertJSON `json:"-"` -} - -// zeroTrustGatewayRuleNewResponseRuleSettingsUntrustedCertJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayRuleNewResponseRuleSettingsUntrustedCert] -type zeroTrustGatewayRuleNewResponseRuleSettingsUntrustedCertJSON struct { - Action apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleNewResponseRuleSettingsUntrustedCert) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleNewResponseRuleSettingsUntrustedCertJSON) RawJSON() string { - return r.raw -} - -// The action performed when an untrusted certificate is seen. The default action -// is an error with HTTP code 526. -type ZeroTrustGatewayRuleNewResponseRuleSettingsUntrustedCertAction string - -const ( - ZeroTrustGatewayRuleNewResponseRuleSettingsUntrustedCertActionPassThrough ZeroTrustGatewayRuleNewResponseRuleSettingsUntrustedCertAction = "pass_through" - ZeroTrustGatewayRuleNewResponseRuleSettingsUntrustedCertActionBlock ZeroTrustGatewayRuleNewResponseRuleSettingsUntrustedCertAction = "block" - ZeroTrustGatewayRuleNewResponseRuleSettingsUntrustedCertActionError ZeroTrustGatewayRuleNewResponseRuleSettingsUntrustedCertAction = "error" -) - -// The schedule for activating DNS policies. This does not apply to HTTP or network -// policies. -type ZeroTrustGatewayRuleNewResponseSchedule struct { - // The time intervals when the rule will be active on Fridays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Fridays. - Fri string `json:"fri"` - // The time intervals when the rule will be active on Mondays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Mondays. - Mon string `json:"mon"` - // The time intervals when the rule will be active on Saturdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Saturdays. - Sat string `json:"sat"` - // The time intervals when the rule will be active on Sundays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Sundays. - Sun string `json:"sun"` - // The time intervals when the rule will be active on Thursdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Thursdays. - Thu string `json:"thu"` - // The time zone the rule will be evaluated against. If a - // [valid time zone city name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) - // is provided, Gateway will always use the current time at that time zone. If this - // parameter is omitted, then Gateway will use the time zone inferred from the - // user's source IP to evaluate the rule. If Gateway cannot determine the time zone - // from the IP, we will fall back to the time zone of the user's connected data - // center. - TimeZone string `json:"time_zone"` - // The time intervals when the rule will be active on Tuesdays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Tuesdays. - Tue string `json:"tue"` - // The time intervals when the rule will be active on Wednesdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Wednesdays. - Wed string `json:"wed"` - JSON zeroTrustGatewayRuleNewResponseScheduleJSON `json:"-"` -} - -// zeroTrustGatewayRuleNewResponseScheduleJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayRuleNewResponseSchedule] -type zeroTrustGatewayRuleNewResponseScheduleJSON struct { - Fri apijson.Field - Mon apijson.Field - Sat apijson.Field - Sun apijson.Field - Thu apijson.Field - TimeZone apijson.Field - Tue apijson.Field - Wed apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleNewResponseSchedule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleNewResponseScheduleJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleUpdateResponse struct { - // The API resource UUID. - ID string `json:"id"` - // The action to preform when the associated traffic, identity, and device posture - // expressions are either absent or evaluate to `true`. - Action ZeroTrustGatewayRuleUpdateResponseAction `json:"action"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Date of deletion, if any. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // The description of the rule. - Description string `json:"description"` - // The wirefilter expression used for device posture check matching. - DevicePosture string `json:"device_posture"` - // True if the rule is enabled. - Enabled bool `json:"enabled"` - // The protocol or layer to evaluate the traffic, identity, and device posture - // expressions. - Filters []ZeroTrustGatewayRuleUpdateResponseFilter `json:"filters"` - // The wirefilter expression used for identity matching. - Identity string `json:"identity"` - // The name of the rule. - Name string `json:"name"` - // Precedence sets the order of your rules. Lower values indicate higher - // precedence. At each processing phase, applicable rules are evaluated in - // ascending order of this value. - Precedence int64 `json:"precedence"` - // Additional settings that modify the rule's action. - RuleSettings ZeroTrustGatewayRuleUpdateResponseRuleSettings `json:"rule_settings"` - // The schedule for activating DNS policies. This does not apply to HTTP or network - // policies. - Schedule ZeroTrustGatewayRuleUpdateResponseSchedule `json:"schedule"` - // The wirefilter expression used for traffic matching. - Traffic string `json:"traffic"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayRuleUpdateResponseJSON `json:"-"` -} - -// zeroTrustGatewayRuleUpdateResponseJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayRuleUpdateResponse] -type zeroTrustGatewayRuleUpdateResponseJSON struct { - ID apijson.Field - Action apijson.Field - CreatedAt apijson.Field - DeletedAt apijson.Field - Description apijson.Field - DevicePosture apijson.Field - Enabled apijson.Field - Filters apijson.Field - Identity apijson.Field - Name apijson.Field - Precedence apijson.Field - RuleSettings apijson.Field - Schedule apijson.Field - Traffic apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// The action to preform when the associated traffic, identity, and device posture -// expressions are either absent or evaluate to `true`. -type ZeroTrustGatewayRuleUpdateResponseAction string - -const ( - ZeroTrustGatewayRuleUpdateResponseActionOn ZeroTrustGatewayRuleUpdateResponseAction = "on" - ZeroTrustGatewayRuleUpdateResponseActionOff ZeroTrustGatewayRuleUpdateResponseAction = "off" - ZeroTrustGatewayRuleUpdateResponseActionAllow ZeroTrustGatewayRuleUpdateResponseAction = "allow" - ZeroTrustGatewayRuleUpdateResponseActionBlock ZeroTrustGatewayRuleUpdateResponseAction = "block" - ZeroTrustGatewayRuleUpdateResponseActionScan ZeroTrustGatewayRuleUpdateResponseAction = "scan" - ZeroTrustGatewayRuleUpdateResponseActionNoscan ZeroTrustGatewayRuleUpdateResponseAction = "noscan" - ZeroTrustGatewayRuleUpdateResponseActionSafesearch ZeroTrustGatewayRuleUpdateResponseAction = "safesearch" - ZeroTrustGatewayRuleUpdateResponseActionYtrestricted ZeroTrustGatewayRuleUpdateResponseAction = "ytrestricted" - ZeroTrustGatewayRuleUpdateResponseActionIsolate ZeroTrustGatewayRuleUpdateResponseAction = "isolate" - ZeroTrustGatewayRuleUpdateResponseActionNoisolate ZeroTrustGatewayRuleUpdateResponseAction = "noisolate" - ZeroTrustGatewayRuleUpdateResponseActionOverride ZeroTrustGatewayRuleUpdateResponseAction = "override" - ZeroTrustGatewayRuleUpdateResponseActionL4Override ZeroTrustGatewayRuleUpdateResponseAction = "l4_override" - ZeroTrustGatewayRuleUpdateResponseActionEgress ZeroTrustGatewayRuleUpdateResponseAction = "egress" - ZeroTrustGatewayRuleUpdateResponseActionAuditSSH ZeroTrustGatewayRuleUpdateResponseAction = "audit_ssh" -) - -// The protocol or layer to use. -type ZeroTrustGatewayRuleUpdateResponseFilter string - -const ( - ZeroTrustGatewayRuleUpdateResponseFilterHTTP ZeroTrustGatewayRuleUpdateResponseFilter = "http" - ZeroTrustGatewayRuleUpdateResponseFilterDNS ZeroTrustGatewayRuleUpdateResponseFilter = "dns" - ZeroTrustGatewayRuleUpdateResponseFilterL4 ZeroTrustGatewayRuleUpdateResponseFilter = "l4" - ZeroTrustGatewayRuleUpdateResponseFilterEgress ZeroTrustGatewayRuleUpdateResponseFilter = "egress" -) - -// Additional settings that modify the rule's action. -type ZeroTrustGatewayRuleUpdateResponseRuleSettings struct { - // Add custom headers to allowed requests, in the form of key-value pairs. Keys are - // header names, pointing to an array with its header value(s). - AddHeaders interface{} `json:"add_headers"` - // Set by parent MSP accounts to enable their children to bypass this rule. - AllowChildBypass bool `json:"allow_child_bypass"` - // Settings for the Audit SSH action. - AuditSSH ZeroTrustGatewayRuleUpdateResponseRuleSettingsAuditSSH `json:"audit_ssh"` - // Configure how browser isolation behaves. - BisoAdminControls ZeroTrustGatewayRuleUpdateResponseRuleSettingsBisoAdminControls `json:"biso_admin_controls"` - // Enable the custom block page. - BlockPageEnabled bool `json:"block_page_enabled"` - // The text describing why this block occurred, displayed on the custom block page - // (if enabled). - BlockReason string `json:"block_reason"` - // Set by children MSP accounts to bypass their parent's rules. - BypassParentRule bool `json:"bypass_parent_rule"` - // Configure how session check behaves. - CheckSession ZeroTrustGatewayRuleUpdateResponseRuleSettingsCheckSession `json:"check_session"` - // Add your own custom resolvers to route queries that match the resolver policy. - // Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will - // route to the address closest to their origin. - DNSResolvers ZeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolvers `json:"dns_resolvers"` - // Configure how Gateway Proxy traffic egresses. You can enable this setting for - // rules with Egress actions and filters, or omit it to indicate local egress via - // WARP IPs. - Egress ZeroTrustGatewayRuleUpdateResponseRuleSettingsEgress `json:"egress"` - // INSECURE - disable DNSSEC validation (for Allow actions). - InsecureDisableDNSSECValidation bool `json:"insecure_disable_dnssec_validation"` - // Set to true to enable IPs in DNS resolver category blocks. By default categories - // only block based on domain names. - IPCategories bool `json:"ip_categories"` - // Set to true to include IPs in DNS resolver indicator feed blocks. By default - // indicator feeds only block based on domain names. - IPIndicatorFeeds bool `json:"ip_indicator_feeds"` - // Send matching traffic to the supplied destination IP address and port. - L4override ZeroTrustGatewayRuleUpdateResponseRuleSettingsL4override `json:"l4override"` - // Configure a notification to display on the user's device when this rule is - // matched. - NotificationSettings ZeroTrustGatewayRuleUpdateResponseRuleSettingsNotificationSettings `json:"notification_settings"` - // Override matching DNS queries with a hostname. - OverrideHost string `json:"override_host"` - // Override matching DNS queries with an IP or set of IPs. - OverrideIPs []string `json:"override_ips"` - // Configure DLP payload logging. - PayloadLog ZeroTrustGatewayRuleUpdateResponseRuleSettingsPayloadLog `json:"payload_log"` - // Enable to send queries that match the policy to Cloudflare's default 1.1.1.1 DNS - // resolver. Cannot be set when dns_resolvers are specified. - ResolveDNSThroughCloudflare bool `json:"resolve_dns_through_cloudflare"` - // Configure behavior when an upstream cert is invalid or an SSL error occurs. - UntrustedCert ZeroTrustGatewayRuleUpdateResponseRuleSettingsUntrustedCert `json:"untrusted_cert"` - JSON zeroTrustGatewayRuleUpdateResponseRuleSettingsJSON `json:"-"` -} - -// zeroTrustGatewayRuleUpdateResponseRuleSettingsJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayRuleUpdateResponseRuleSettings] -type zeroTrustGatewayRuleUpdateResponseRuleSettingsJSON struct { - AddHeaders apijson.Field - AllowChildBypass apijson.Field - AuditSSH apijson.Field - BisoAdminControls apijson.Field - BlockPageEnabled apijson.Field - BlockReason apijson.Field - BypassParentRule apijson.Field - CheckSession apijson.Field - DNSResolvers apijson.Field - Egress apijson.Field - InsecureDisableDNSSECValidation apijson.Field - IPCategories apijson.Field - IPIndicatorFeeds apijson.Field - L4override apijson.Field - NotificationSettings apijson.Field - OverrideHost apijson.Field - OverrideIPs apijson.Field - PayloadLog apijson.Field - ResolveDNSThroughCloudflare apijson.Field - UntrustedCert apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleUpdateResponseRuleSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleUpdateResponseRuleSettingsJSON) RawJSON() string { - return r.raw -} - -// Settings for the Audit SSH action. -type ZeroTrustGatewayRuleUpdateResponseRuleSettingsAuditSSH struct { - // Enable to turn on SSH command logging. - CommandLogging bool `json:"command_logging"` - JSON zeroTrustGatewayRuleUpdateResponseRuleSettingsAuditSSHJSON `json:"-"` -} - -// zeroTrustGatewayRuleUpdateResponseRuleSettingsAuditSSHJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayRuleUpdateResponseRuleSettingsAuditSSH] -type zeroTrustGatewayRuleUpdateResponseRuleSettingsAuditSSHJSON struct { - CommandLogging apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleUpdateResponseRuleSettingsAuditSSH) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleUpdateResponseRuleSettingsAuditSSHJSON) RawJSON() string { - return r.raw -} - -// Configure how browser isolation behaves. -type ZeroTrustGatewayRuleUpdateResponseRuleSettingsBisoAdminControls struct { - // Set to true to enable copy-pasting. - Dcp bool `json:"dcp"` - // Set to true to enable downloading. - Dd bool `json:"dd"` - // Set to true to enable keyboard usage. - Dk bool `json:"dk"` - // Set to true to enable printing. - Dp bool `json:"dp"` - // Set to true to enable uploading. - Du bool `json:"du"` - JSON zeroTrustGatewayRuleUpdateResponseRuleSettingsBisoAdminControlsJSON `json:"-"` -} - -// zeroTrustGatewayRuleUpdateResponseRuleSettingsBisoAdminControlsJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayRuleUpdateResponseRuleSettingsBisoAdminControls] -type zeroTrustGatewayRuleUpdateResponseRuleSettingsBisoAdminControlsJSON struct { - Dcp apijson.Field - Dd apijson.Field - Dk apijson.Field - Dp apijson.Field - Du apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleUpdateResponseRuleSettingsBisoAdminControls) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleUpdateResponseRuleSettingsBisoAdminControlsJSON) RawJSON() string { - return r.raw -} - -// Configure how session check behaves. -type ZeroTrustGatewayRuleUpdateResponseRuleSettingsCheckSession struct { - // Configure how fresh the session needs to be to be considered valid. - Duration string `json:"duration"` - // Set to true to enable session enforcement. - Enforce bool `json:"enforce"` - JSON zeroTrustGatewayRuleUpdateResponseRuleSettingsCheckSessionJSON `json:"-"` -} - -// zeroTrustGatewayRuleUpdateResponseRuleSettingsCheckSessionJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayRuleUpdateResponseRuleSettingsCheckSession] -type zeroTrustGatewayRuleUpdateResponseRuleSettingsCheckSessionJSON struct { - Duration apijson.Field - Enforce apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleUpdateResponseRuleSettingsCheckSession) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleUpdateResponseRuleSettingsCheckSessionJSON) RawJSON() string { - return r.raw -} - -// Add your own custom resolvers to route queries that match the resolver policy. -// Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will -// route to the address closest to their origin. -type ZeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolvers struct { - IPV4 []ZeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversIPV4 `json:"ipv4"` - IPV6 []ZeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversIPV6 `json:"ipv6"` - JSON zeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversJSON `json:"-"` -} - -// zeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolvers] -type zeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversJSON struct { - IPV4 apijson.Field - IPV6 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolvers) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversIPV4 struct { - // IP address of upstream resolver. - IP string `json:"ip,required"` - // A port number to use for upstream resolver. - Port int64 `json:"port"` - // Whether to connect to this resolver over a private network. Must be set when - // vnet_id is set. - RouteThroughPrivateNetwork bool `json:"route_through_private_network"` - // Optionally specify a virtual network for this resolver. Uses default virtual - // network id if omitted. - VnetID string `json:"vnet_id"` - JSON zeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversIPV4JSON `json:"-"` -} - -// zeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversIPV4JSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversIPV4] -type zeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversIPV4JSON struct { - IP apijson.Field - Port apijson.Field - RouteThroughPrivateNetwork apijson.Field - VnetID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversIPV4) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversIPV4JSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversIPV6 struct { - // IP address of upstream resolver. - IP string `json:"ip,required"` - // A port number to use for upstream resolver. - Port int64 `json:"port"` - // Whether to connect to this resolver over a private network. Must be set when - // vnet_id is set. - RouteThroughPrivateNetwork bool `json:"route_through_private_network"` - // Optionally specify a virtual network for this resolver. Uses default virtual - // network id if omitted. - VnetID string `json:"vnet_id"` - JSON zeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversIPV6JSON `json:"-"` -} - -// zeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversIPV6JSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversIPV6] -type zeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversIPV6JSON struct { - IP apijson.Field - Port apijson.Field - RouteThroughPrivateNetwork apijson.Field - VnetID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversIPV6) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleUpdateResponseRuleSettingsDNSResolversIPV6JSON) RawJSON() string { - return r.raw -} - -// Configure how Gateway Proxy traffic egresses. You can enable this setting for -// rules with Egress actions and filters, or omit it to indicate local egress via -// WARP IPs. -type ZeroTrustGatewayRuleUpdateResponseRuleSettingsEgress struct { - // The IPv4 address to be used for egress. - IPV4 string `json:"ipv4"` - // The fallback IPv4 address to be used for egress in the event of an error - // egressing with the primary IPv4. Can be '0.0.0.0' to indicate local egress via - // WARP IPs. - IPV4Fallback string `json:"ipv4_fallback"` - // The IPv6 range to be used for egress. - IPV6 string `json:"ipv6"` - JSON zeroTrustGatewayRuleUpdateResponseRuleSettingsEgressJSON `json:"-"` -} - -// zeroTrustGatewayRuleUpdateResponseRuleSettingsEgressJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayRuleUpdateResponseRuleSettingsEgress] -type zeroTrustGatewayRuleUpdateResponseRuleSettingsEgressJSON struct { - IPV4 apijson.Field - IPV4Fallback apijson.Field - IPV6 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleUpdateResponseRuleSettingsEgress) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleUpdateResponseRuleSettingsEgressJSON) RawJSON() string { - return r.raw -} - -// Send matching traffic to the supplied destination IP address and port. -type ZeroTrustGatewayRuleUpdateResponseRuleSettingsL4override struct { - // IPv4 or IPv6 address. - IP string `json:"ip"` - // A port number to use for TCP/UDP overrides. - Port int64 `json:"port"` - JSON zeroTrustGatewayRuleUpdateResponseRuleSettingsL4overrideJSON `json:"-"` -} - -// zeroTrustGatewayRuleUpdateResponseRuleSettingsL4overrideJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayRuleUpdateResponseRuleSettingsL4override] -type zeroTrustGatewayRuleUpdateResponseRuleSettingsL4overrideJSON struct { - IP apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleUpdateResponseRuleSettingsL4override) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleUpdateResponseRuleSettingsL4overrideJSON) RawJSON() string { - return r.raw -} - -// Configure a notification to display on the user's device when this rule is -// matched. -type ZeroTrustGatewayRuleUpdateResponseRuleSettingsNotificationSettings struct { - // Set notification on - Enabled bool `json:"enabled"` - // Customize the message shown in the notification. - Msg string `json:"msg"` - // Optional URL to direct users to additional information. If not set, the - // notification will open a block page. - SupportURL string `json:"support_url"` - JSON zeroTrustGatewayRuleUpdateResponseRuleSettingsNotificationSettingsJSON `json:"-"` -} - -// zeroTrustGatewayRuleUpdateResponseRuleSettingsNotificationSettingsJSON contains -// the JSON metadata for the struct -// [ZeroTrustGatewayRuleUpdateResponseRuleSettingsNotificationSettings] -type zeroTrustGatewayRuleUpdateResponseRuleSettingsNotificationSettingsJSON struct { - Enabled apijson.Field - Msg apijson.Field - SupportURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleUpdateResponseRuleSettingsNotificationSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleUpdateResponseRuleSettingsNotificationSettingsJSON) RawJSON() string { - return r.raw -} - -// Configure DLP payload logging. -type ZeroTrustGatewayRuleUpdateResponseRuleSettingsPayloadLog struct { - // Set to true to enable DLP payload logging for this rule. - Enabled bool `json:"enabled"` - JSON zeroTrustGatewayRuleUpdateResponseRuleSettingsPayloadLogJSON `json:"-"` -} - -// zeroTrustGatewayRuleUpdateResponseRuleSettingsPayloadLogJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayRuleUpdateResponseRuleSettingsPayloadLog] -type zeroTrustGatewayRuleUpdateResponseRuleSettingsPayloadLogJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleUpdateResponseRuleSettingsPayloadLog) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleUpdateResponseRuleSettingsPayloadLogJSON) RawJSON() string { - return r.raw -} - -// Configure behavior when an upstream cert is invalid or an SSL error occurs. -type ZeroTrustGatewayRuleUpdateResponseRuleSettingsUntrustedCert struct { - // The action performed when an untrusted certificate is seen. The default action - // is an error with HTTP code 526. - Action ZeroTrustGatewayRuleUpdateResponseRuleSettingsUntrustedCertAction `json:"action"` - JSON zeroTrustGatewayRuleUpdateResponseRuleSettingsUntrustedCertJSON `json:"-"` -} - -// zeroTrustGatewayRuleUpdateResponseRuleSettingsUntrustedCertJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayRuleUpdateResponseRuleSettingsUntrustedCert] -type zeroTrustGatewayRuleUpdateResponseRuleSettingsUntrustedCertJSON struct { - Action apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleUpdateResponseRuleSettingsUntrustedCert) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleUpdateResponseRuleSettingsUntrustedCertJSON) RawJSON() string { - return r.raw -} - -// The action performed when an untrusted certificate is seen. The default action -// is an error with HTTP code 526. -type ZeroTrustGatewayRuleUpdateResponseRuleSettingsUntrustedCertAction string - -const ( - ZeroTrustGatewayRuleUpdateResponseRuleSettingsUntrustedCertActionPassThrough ZeroTrustGatewayRuleUpdateResponseRuleSettingsUntrustedCertAction = "pass_through" - ZeroTrustGatewayRuleUpdateResponseRuleSettingsUntrustedCertActionBlock ZeroTrustGatewayRuleUpdateResponseRuleSettingsUntrustedCertAction = "block" - ZeroTrustGatewayRuleUpdateResponseRuleSettingsUntrustedCertActionError ZeroTrustGatewayRuleUpdateResponseRuleSettingsUntrustedCertAction = "error" -) - -// The schedule for activating DNS policies. This does not apply to HTTP or network -// policies. -type ZeroTrustGatewayRuleUpdateResponseSchedule struct { - // The time intervals when the rule will be active on Fridays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Fridays. - Fri string `json:"fri"` - // The time intervals when the rule will be active on Mondays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Mondays. - Mon string `json:"mon"` - // The time intervals when the rule will be active on Saturdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Saturdays. - Sat string `json:"sat"` - // The time intervals when the rule will be active on Sundays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Sundays. - Sun string `json:"sun"` - // The time intervals when the rule will be active on Thursdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Thursdays. - Thu string `json:"thu"` - // The time zone the rule will be evaluated against. If a - // [valid time zone city name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) - // is provided, Gateway will always use the current time at that time zone. If this - // parameter is omitted, then Gateway will use the time zone inferred from the - // user's source IP to evaluate the rule. If Gateway cannot determine the time zone - // from the IP, we will fall back to the time zone of the user's connected data - // center. - TimeZone string `json:"time_zone"` - // The time intervals when the rule will be active on Tuesdays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Tuesdays. - Tue string `json:"tue"` - // The time intervals when the rule will be active on Wednesdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Wednesdays. - Wed string `json:"wed"` - JSON zeroTrustGatewayRuleUpdateResponseScheduleJSON `json:"-"` -} - -// zeroTrustGatewayRuleUpdateResponseScheduleJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayRuleUpdateResponseSchedule] -type zeroTrustGatewayRuleUpdateResponseScheduleJSON struct { - Fri apijson.Field - Mon apijson.Field - Sat apijson.Field - Sun apijson.Field - Thu apijson.Field - TimeZone apijson.Field - Tue apijson.Field - Wed apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleUpdateResponseSchedule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleUpdateResponseScheduleJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleListResponse struct { - // The API resource UUID. - ID string `json:"id"` - // The action to preform when the associated traffic, identity, and device posture - // expressions are either absent or evaluate to `true`. - Action ZeroTrustGatewayRuleListResponseAction `json:"action"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Date of deletion, if any. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // The description of the rule. - Description string `json:"description"` - // The wirefilter expression used for device posture check matching. - DevicePosture string `json:"device_posture"` - // True if the rule is enabled. - Enabled bool `json:"enabled"` - // The protocol or layer to evaluate the traffic, identity, and device posture - // expressions. - Filters []ZeroTrustGatewayRuleListResponseFilter `json:"filters"` - // The wirefilter expression used for identity matching. - Identity string `json:"identity"` - // The name of the rule. - Name string `json:"name"` - // Precedence sets the order of your rules. Lower values indicate higher - // precedence. At each processing phase, applicable rules are evaluated in - // ascending order of this value. - Precedence int64 `json:"precedence"` - // Additional settings that modify the rule's action. - RuleSettings ZeroTrustGatewayRuleListResponseRuleSettings `json:"rule_settings"` - // The schedule for activating DNS policies. This does not apply to HTTP or network - // policies. - Schedule ZeroTrustGatewayRuleListResponseSchedule `json:"schedule"` - // The wirefilter expression used for traffic matching. - Traffic string `json:"traffic"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayRuleListResponseJSON `json:"-"` -} - -// zeroTrustGatewayRuleListResponseJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayRuleListResponse] -type zeroTrustGatewayRuleListResponseJSON struct { - ID apijson.Field - Action apijson.Field - CreatedAt apijson.Field - DeletedAt apijson.Field - Description apijson.Field - DevicePosture apijson.Field - Enabled apijson.Field - Filters apijson.Field - Identity apijson.Field - Name apijson.Field - Precedence apijson.Field - RuleSettings apijson.Field - Schedule apijson.Field - Traffic apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleListResponseJSON) RawJSON() string { - return r.raw -} - -// The action to preform when the associated traffic, identity, and device posture -// expressions are either absent or evaluate to `true`. -type ZeroTrustGatewayRuleListResponseAction string - -const ( - ZeroTrustGatewayRuleListResponseActionOn ZeroTrustGatewayRuleListResponseAction = "on" - ZeroTrustGatewayRuleListResponseActionOff ZeroTrustGatewayRuleListResponseAction = "off" - ZeroTrustGatewayRuleListResponseActionAllow ZeroTrustGatewayRuleListResponseAction = "allow" - ZeroTrustGatewayRuleListResponseActionBlock ZeroTrustGatewayRuleListResponseAction = "block" - ZeroTrustGatewayRuleListResponseActionScan ZeroTrustGatewayRuleListResponseAction = "scan" - ZeroTrustGatewayRuleListResponseActionNoscan ZeroTrustGatewayRuleListResponseAction = "noscan" - ZeroTrustGatewayRuleListResponseActionSafesearch ZeroTrustGatewayRuleListResponseAction = "safesearch" - ZeroTrustGatewayRuleListResponseActionYtrestricted ZeroTrustGatewayRuleListResponseAction = "ytrestricted" - ZeroTrustGatewayRuleListResponseActionIsolate ZeroTrustGatewayRuleListResponseAction = "isolate" - ZeroTrustGatewayRuleListResponseActionNoisolate ZeroTrustGatewayRuleListResponseAction = "noisolate" - ZeroTrustGatewayRuleListResponseActionOverride ZeroTrustGatewayRuleListResponseAction = "override" - ZeroTrustGatewayRuleListResponseActionL4Override ZeroTrustGatewayRuleListResponseAction = "l4_override" - ZeroTrustGatewayRuleListResponseActionEgress ZeroTrustGatewayRuleListResponseAction = "egress" - ZeroTrustGatewayRuleListResponseActionAuditSSH ZeroTrustGatewayRuleListResponseAction = "audit_ssh" -) - -// The protocol or layer to use. -type ZeroTrustGatewayRuleListResponseFilter string - -const ( - ZeroTrustGatewayRuleListResponseFilterHTTP ZeroTrustGatewayRuleListResponseFilter = "http" - ZeroTrustGatewayRuleListResponseFilterDNS ZeroTrustGatewayRuleListResponseFilter = "dns" - ZeroTrustGatewayRuleListResponseFilterL4 ZeroTrustGatewayRuleListResponseFilter = "l4" - ZeroTrustGatewayRuleListResponseFilterEgress ZeroTrustGatewayRuleListResponseFilter = "egress" -) - -// Additional settings that modify the rule's action. -type ZeroTrustGatewayRuleListResponseRuleSettings struct { - // Add custom headers to allowed requests, in the form of key-value pairs. Keys are - // header names, pointing to an array with its header value(s). - AddHeaders interface{} `json:"add_headers"` - // Set by parent MSP accounts to enable their children to bypass this rule. - AllowChildBypass bool `json:"allow_child_bypass"` - // Settings for the Audit SSH action. - AuditSSH ZeroTrustGatewayRuleListResponseRuleSettingsAuditSSH `json:"audit_ssh"` - // Configure how browser isolation behaves. - BisoAdminControls ZeroTrustGatewayRuleListResponseRuleSettingsBisoAdminControls `json:"biso_admin_controls"` - // Enable the custom block page. - BlockPageEnabled bool `json:"block_page_enabled"` - // The text describing why this block occurred, displayed on the custom block page - // (if enabled). - BlockReason string `json:"block_reason"` - // Set by children MSP accounts to bypass their parent's rules. - BypassParentRule bool `json:"bypass_parent_rule"` - // Configure how session check behaves. - CheckSession ZeroTrustGatewayRuleListResponseRuleSettingsCheckSession `json:"check_session"` - // Add your own custom resolvers to route queries that match the resolver policy. - // Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will - // route to the address closest to their origin. - DNSResolvers ZeroTrustGatewayRuleListResponseRuleSettingsDNSResolvers `json:"dns_resolvers"` - // Configure how Gateway Proxy traffic egresses. You can enable this setting for - // rules with Egress actions and filters, or omit it to indicate local egress via - // WARP IPs. - Egress ZeroTrustGatewayRuleListResponseRuleSettingsEgress `json:"egress"` - // INSECURE - disable DNSSEC validation (for Allow actions). - InsecureDisableDNSSECValidation bool `json:"insecure_disable_dnssec_validation"` - // Set to true to enable IPs in DNS resolver category blocks. By default categories - // only block based on domain names. - IPCategories bool `json:"ip_categories"` - // Set to true to include IPs in DNS resolver indicator feed blocks. By default - // indicator feeds only block based on domain names. - IPIndicatorFeeds bool `json:"ip_indicator_feeds"` - // Send matching traffic to the supplied destination IP address and port. - L4override ZeroTrustGatewayRuleListResponseRuleSettingsL4override `json:"l4override"` - // Configure a notification to display on the user's device when this rule is - // matched. - NotificationSettings ZeroTrustGatewayRuleListResponseRuleSettingsNotificationSettings `json:"notification_settings"` - // Override matching DNS queries with a hostname. - OverrideHost string `json:"override_host"` - // Override matching DNS queries with an IP or set of IPs. - OverrideIPs []string `json:"override_ips"` - // Configure DLP payload logging. - PayloadLog ZeroTrustGatewayRuleListResponseRuleSettingsPayloadLog `json:"payload_log"` - // Enable to send queries that match the policy to Cloudflare's default 1.1.1.1 DNS - // resolver. Cannot be set when dns_resolvers are specified. - ResolveDNSThroughCloudflare bool `json:"resolve_dns_through_cloudflare"` - // Configure behavior when an upstream cert is invalid or an SSL error occurs. - UntrustedCert ZeroTrustGatewayRuleListResponseRuleSettingsUntrustedCert `json:"untrusted_cert"` - JSON zeroTrustGatewayRuleListResponseRuleSettingsJSON `json:"-"` -} - -// zeroTrustGatewayRuleListResponseRuleSettingsJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayRuleListResponseRuleSettings] -type zeroTrustGatewayRuleListResponseRuleSettingsJSON struct { - AddHeaders apijson.Field - AllowChildBypass apijson.Field - AuditSSH apijson.Field - BisoAdminControls apijson.Field - BlockPageEnabled apijson.Field - BlockReason apijson.Field - BypassParentRule apijson.Field - CheckSession apijson.Field - DNSResolvers apijson.Field - Egress apijson.Field - InsecureDisableDNSSECValidation apijson.Field - IPCategories apijson.Field - IPIndicatorFeeds apijson.Field - L4override apijson.Field - NotificationSettings apijson.Field - OverrideHost apijson.Field - OverrideIPs apijson.Field - PayloadLog apijson.Field - ResolveDNSThroughCloudflare apijson.Field - UntrustedCert apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleListResponseRuleSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleListResponseRuleSettingsJSON) RawJSON() string { - return r.raw -} - -// Settings for the Audit SSH action. -type ZeroTrustGatewayRuleListResponseRuleSettingsAuditSSH struct { - // Enable to turn on SSH command logging. - CommandLogging bool `json:"command_logging"` - JSON zeroTrustGatewayRuleListResponseRuleSettingsAuditSSHJSON `json:"-"` -} - -// zeroTrustGatewayRuleListResponseRuleSettingsAuditSSHJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayRuleListResponseRuleSettingsAuditSSH] -type zeroTrustGatewayRuleListResponseRuleSettingsAuditSSHJSON struct { - CommandLogging apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleListResponseRuleSettingsAuditSSH) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleListResponseRuleSettingsAuditSSHJSON) RawJSON() string { - return r.raw -} - -// Configure how browser isolation behaves. -type ZeroTrustGatewayRuleListResponseRuleSettingsBisoAdminControls struct { - // Set to true to enable copy-pasting. - Dcp bool `json:"dcp"` - // Set to true to enable downloading. - Dd bool `json:"dd"` - // Set to true to enable keyboard usage. - Dk bool `json:"dk"` - // Set to true to enable printing. - Dp bool `json:"dp"` - // Set to true to enable uploading. - Du bool `json:"du"` - JSON zeroTrustGatewayRuleListResponseRuleSettingsBisoAdminControlsJSON `json:"-"` -} - -// zeroTrustGatewayRuleListResponseRuleSettingsBisoAdminControlsJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayRuleListResponseRuleSettingsBisoAdminControls] -type zeroTrustGatewayRuleListResponseRuleSettingsBisoAdminControlsJSON struct { - Dcp apijson.Field - Dd apijson.Field - Dk apijson.Field - Dp apijson.Field - Du apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleListResponseRuleSettingsBisoAdminControls) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleListResponseRuleSettingsBisoAdminControlsJSON) RawJSON() string { - return r.raw -} - -// Configure how session check behaves. -type ZeroTrustGatewayRuleListResponseRuleSettingsCheckSession struct { - // Configure how fresh the session needs to be to be considered valid. - Duration string `json:"duration"` - // Set to true to enable session enforcement. - Enforce bool `json:"enforce"` - JSON zeroTrustGatewayRuleListResponseRuleSettingsCheckSessionJSON `json:"-"` -} - -// zeroTrustGatewayRuleListResponseRuleSettingsCheckSessionJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayRuleListResponseRuleSettingsCheckSession] -type zeroTrustGatewayRuleListResponseRuleSettingsCheckSessionJSON struct { - Duration apijson.Field - Enforce apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleListResponseRuleSettingsCheckSession) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleListResponseRuleSettingsCheckSessionJSON) RawJSON() string { - return r.raw -} - -// Add your own custom resolvers to route queries that match the resolver policy. -// Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will -// route to the address closest to their origin. -type ZeroTrustGatewayRuleListResponseRuleSettingsDNSResolvers struct { - IPV4 []ZeroTrustGatewayRuleListResponseRuleSettingsDNSResolversIPV4 `json:"ipv4"` - IPV6 []ZeroTrustGatewayRuleListResponseRuleSettingsDNSResolversIPV6 `json:"ipv6"` - JSON zeroTrustGatewayRuleListResponseRuleSettingsDNSResolversJSON `json:"-"` -} - -// zeroTrustGatewayRuleListResponseRuleSettingsDNSResolversJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayRuleListResponseRuleSettingsDNSResolvers] -type zeroTrustGatewayRuleListResponseRuleSettingsDNSResolversJSON struct { - IPV4 apijson.Field - IPV6 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleListResponseRuleSettingsDNSResolvers) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleListResponseRuleSettingsDNSResolversJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleListResponseRuleSettingsDNSResolversIPV4 struct { - // IP address of upstream resolver. - IP string `json:"ip,required"` - // A port number to use for upstream resolver. - Port int64 `json:"port"` - // Whether to connect to this resolver over a private network. Must be set when - // vnet_id is set. - RouteThroughPrivateNetwork bool `json:"route_through_private_network"` - // Optionally specify a virtual network for this resolver. Uses default virtual - // network id if omitted. - VnetID string `json:"vnet_id"` - JSON zeroTrustGatewayRuleListResponseRuleSettingsDNSResolversIPV4JSON `json:"-"` -} - -// zeroTrustGatewayRuleListResponseRuleSettingsDNSResolversIPV4JSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayRuleListResponseRuleSettingsDNSResolversIPV4] -type zeroTrustGatewayRuleListResponseRuleSettingsDNSResolversIPV4JSON struct { - IP apijson.Field - Port apijson.Field - RouteThroughPrivateNetwork apijson.Field - VnetID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleListResponseRuleSettingsDNSResolversIPV4) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleListResponseRuleSettingsDNSResolversIPV4JSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleListResponseRuleSettingsDNSResolversIPV6 struct { - // IP address of upstream resolver. - IP string `json:"ip,required"` - // A port number to use for upstream resolver. - Port int64 `json:"port"` - // Whether to connect to this resolver over a private network. Must be set when - // vnet_id is set. - RouteThroughPrivateNetwork bool `json:"route_through_private_network"` - // Optionally specify a virtual network for this resolver. Uses default virtual - // network id if omitted. - VnetID string `json:"vnet_id"` - JSON zeroTrustGatewayRuleListResponseRuleSettingsDNSResolversIPV6JSON `json:"-"` -} - -// zeroTrustGatewayRuleListResponseRuleSettingsDNSResolversIPV6JSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayRuleListResponseRuleSettingsDNSResolversIPV6] -type zeroTrustGatewayRuleListResponseRuleSettingsDNSResolversIPV6JSON struct { - IP apijson.Field - Port apijson.Field - RouteThroughPrivateNetwork apijson.Field - VnetID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleListResponseRuleSettingsDNSResolversIPV6) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleListResponseRuleSettingsDNSResolversIPV6JSON) RawJSON() string { - return r.raw -} - -// Configure how Gateway Proxy traffic egresses. You can enable this setting for -// rules with Egress actions and filters, or omit it to indicate local egress via -// WARP IPs. -type ZeroTrustGatewayRuleListResponseRuleSettingsEgress struct { - // The IPv4 address to be used for egress. - IPV4 string `json:"ipv4"` - // The fallback IPv4 address to be used for egress in the event of an error - // egressing with the primary IPv4. Can be '0.0.0.0' to indicate local egress via - // WARP IPs. - IPV4Fallback string `json:"ipv4_fallback"` - // The IPv6 range to be used for egress. - IPV6 string `json:"ipv6"` - JSON zeroTrustGatewayRuleListResponseRuleSettingsEgressJSON `json:"-"` -} - -// zeroTrustGatewayRuleListResponseRuleSettingsEgressJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayRuleListResponseRuleSettingsEgress] -type zeroTrustGatewayRuleListResponseRuleSettingsEgressJSON struct { - IPV4 apijson.Field - IPV4Fallback apijson.Field - IPV6 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleListResponseRuleSettingsEgress) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleListResponseRuleSettingsEgressJSON) RawJSON() string { - return r.raw -} - -// Send matching traffic to the supplied destination IP address and port. -type ZeroTrustGatewayRuleListResponseRuleSettingsL4override struct { - // IPv4 or IPv6 address. - IP string `json:"ip"` - // A port number to use for TCP/UDP overrides. - Port int64 `json:"port"` - JSON zeroTrustGatewayRuleListResponseRuleSettingsL4overrideJSON `json:"-"` -} - -// zeroTrustGatewayRuleListResponseRuleSettingsL4overrideJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayRuleListResponseRuleSettingsL4override] -type zeroTrustGatewayRuleListResponseRuleSettingsL4overrideJSON struct { - IP apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleListResponseRuleSettingsL4override) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleListResponseRuleSettingsL4overrideJSON) RawJSON() string { - return r.raw -} - -// Configure a notification to display on the user's device when this rule is -// matched. -type ZeroTrustGatewayRuleListResponseRuleSettingsNotificationSettings struct { - // Set notification on - Enabled bool `json:"enabled"` - // Customize the message shown in the notification. - Msg string `json:"msg"` - // Optional URL to direct users to additional information. If not set, the - // notification will open a block page. - SupportURL string `json:"support_url"` - JSON zeroTrustGatewayRuleListResponseRuleSettingsNotificationSettingsJSON `json:"-"` -} - -// zeroTrustGatewayRuleListResponseRuleSettingsNotificationSettingsJSON contains -// the JSON metadata for the struct -// [ZeroTrustGatewayRuleListResponseRuleSettingsNotificationSettings] -type zeroTrustGatewayRuleListResponseRuleSettingsNotificationSettingsJSON struct { - Enabled apijson.Field - Msg apijson.Field - SupportURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleListResponseRuleSettingsNotificationSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleListResponseRuleSettingsNotificationSettingsJSON) RawJSON() string { - return r.raw -} - -// Configure DLP payload logging. -type ZeroTrustGatewayRuleListResponseRuleSettingsPayloadLog struct { - // Set to true to enable DLP payload logging for this rule. - Enabled bool `json:"enabled"` - JSON zeroTrustGatewayRuleListResponseRuleSettingsPayloadLogJSON `json:"-"` -} - -// zeroTrustGatewayRuleListResponseRuleSettingsPayloadLogJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayRuleListResponseRuleSettingsPayloadLog] -type zeroTrustGatewayRuleListResponseRuleSettingsPayloadLogJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleListResponseRuleSettingsPayloadLog) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleListResponseRuleSettingsPayloadLogJSON) RawJSON() string { - return r.raw -} - -// Configure behavior when an upstream cert is invalid or an SSL error occurs. -type ZeroTrustGatewayRuleListResponseRuleSettingsUntrustedCert struct { - // The action performed when an untrusted certificate is seen. The default action - // is an error with HTTP code 526. - Action ZeroTrustGatewayRuleListResponseRuleSettingsUntrustedCertAction `json:"action"` - JSON zeroTrustGatewayRuleListResponseRuleSettingsUntrustedCertJSON `json:"-"` -} - -// zeroTrustGatewayRuleListResponseRuleSettingsUntrustedCertJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayRuleListResponseRuleSettingsUntrustedCert] -type zeroTrustGatewayRuleListResponseRuleSettingsUntrustedCertJSON struct { - Action apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleListResponseRuleSettingsUntrustedCert) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleListResponseRuleSettingsUntrustedCertJSON) RawJSON() string { - return r.raw -} - -// The action performed when an untrusted certificate is seen. The default action -// is an error with HTTP code 526. -type ZeroTrustGatewayRuleListResponseRuleSettingsUntrustedCertAction string - -const ( - ZeroTrustGatewayRuleListResponseRuleSettingsUntrustedCertActionPassThrough ZeroTrustGatewayRuleListResponseRuleSettingsUntrustedCertAction = "pass_through" - ZeroTrustGatewayRuleListResponseRuleSettingsUntrustedCertActionBlock ZeroTrustGatewayRuleListResponseRuleSettingsUntrustedCertAction = "block" - ZeroTrustGatewayRuleListResponseRuleSettingsUntrustedCertActionError ZeroTrustGatewayRuleListResponseRuleSettingsUntrustedCertAction = "error" -) - -// The schedule for activating DNS policies. This does not apply to HTTP or network -// policies. -type ZeroTrustGatewayRuleListResponseSchedule struct { - // The time intervals when the rule will be active on Fridays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Fridays. - Fri string `json:"fri"` - // The time intervals when the rule will be active on Mondays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Mondays. - Mon string `json:"mon"` - // The time intervals when the rule will be active on Saturdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Saturdays. - Sat string `json:"sat"` - // The time intervals when the rule will be active on Sundays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Sundays. - Sun string `json:"sun"` - // The time intervals when the rule will be active on Thursdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Thursdays. - Thu string `json:"thu"` - // The time zone the rule will be evaluated against. If a - // [valid time zone city name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) - // is provided, Gateway will always use the current time at that time zone. If this - // parameter is omitted, then Gateway will use the time zone inferred from the - // user's source IP to evaluate the rule. If Gateway cannot determine the time zone - // from the IP, we will fall back to the time zone of the user's connected data - // center. - TimeZone string `json:"time_zone"` - // The time intervals when the rule will be active on Tuesdays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Tuesdays. - Tue string `json:"tue"` - // The time intervals when the rule will be active on Wednesdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Wednesdays. - Wed string `json:"wed"` - JSON zeroTrustGatewayRuleListResponseScheduleJSON `json:"-"` -} - -// zeroTrustGatewayRuleListResponseScheduleJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayRuleListResponseSchedule] -type zeroTrustGatewayRuleListResponseScheduleJSON struct { - Fri apijson.Field - Mon apijson.Field - Sat apijson.Field - Sun apijson.Field - Thu apijson.Field - TimeZone apijson.Field - Tue apijson.Field - Wed apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleListResponseSchedule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleListResponseScheduleJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [ZeroTrustGatewayRuleDeleteResponseUnknown] or -// [shared.UnionString]. -type ZeroTrustGatewayRuleDeleteResponse interface { - ImplementsZeroTrustGatewayRuleDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustGatewayRuleDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustGatewayRuleGetResponse struct { - // The API resource UUID. - ID string `json:"id"` - // The action to preform when the associated traffic, identity, and device posture - // expressions are either absent or evaluate to `true`. - Action ZeroTrustGatewayRuleGetResponseAction `json:"action"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Date of deletion, if any. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // The description of the rule. - Description string `json:"description"` - // The wirefilter expression used for device posture check matching. - DevicePosture string `json:"device_posture"` - // True if the rule is enabled. - Enabled bool `json:"enabled"` - // The protocol or layer to evaluate the traffic, identity, and device posture - // expressions. - Filters []ZeroTrustGatewayRuleGetResponseFilter `json:"filters"` - // The wirefilter expression used for identity matching. - Identity string `json:"identity"` - // The name of the rule. - Name string `json:"name"` - // Precedence sets the order of your rules. Lower values indicate higher - // precedence. At each processing phase, applicable rules are evaluated in - // ascending order of this value. - Precedence int64 `json:"precedence"` - // Additional settings that modify the rule's action. - RuleSettings ZeroTrustGatewayRuleGetResponseRuleSettings `json:"rule_settings"` - // The schedule for activating DNS policies. This does not apply to HTTP or network - // policies. - Schedule ZeroTrustGatewayRuleGetResponseSchedule `json:"schedule"` - // The wirefilter expression used for traffic matching. - Traffic string `json:"traffic"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustGatewayRuleGetResponseJSON `json:"-"` -} - -// zeroTrustGatewayRuleGetResponseJSON contains the JSON metadata for the struct -// [ZeroTrustGatewayRuleGetResponse] -type zeroTrustGatewayRuleGetResponseJSON struct { - ID apijson.Field - Action apijson.Field - CreatedAt apijson.Field - DeletedAt apijson.Field - Description apijson.Field - DevicePosture apijson.Field - Enabled apijson.Field - Filters apijson.Field - Identity apijson.Field - Name apijson.Field - Precedence apijson.Field - RuleSettings apijson.Field - Schedule apijson.Field - Traffic apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleGetResponseJSON) RawJSON() string { - return r.raw -} - -// The action to preform when the associated traffic, identity, and device posture -// expressions are either absent or evaluate to `true`. -type ZeroTrustGatewayRuleGetResponseAction string - -const ( - ZeroTrustGatewayRuleGetResponseActionOn ZeroTrustGatewayRuleGetResponseAction = "on" - ZeroTrustGatewayRuleGetResponseActionOff ZeroTrustGatewayRuleGetResponseAction = "off" - ZeroTrustGatewayRuleGetResponseActionAllow ZeroTrustGatewayRuleGetResponseAction = "allow" - ZeroTrustGatewayRuleGetResponseActionBlock ZeroTrustGatewayRuleGetResponseAction = "block" - ZeroTrustGatewayRuleGetResponseActionScan ZeroTrustGatewayRuleGetResponseAction = "scan" - ZeroTrustGatewayRuleGetResponseActionNoscan ZeroTrustGatewayRuleGetResponseAction = "noscan" - ZeroTrustGatewayRuleGetResponseActionSafesearch ZeroTrustGatewayRuleGetResponseAction = "safesearch" - ZeroTrustGatewayRuleGetResponseActionYtrestricted ZeroTrustGatewayRuleGetResponseAction = "ytrestricted" - ZeroTrustGatewayRuleGetResponseActionIsolate ZeroTrustGatewayRuleGetResponseAction = "isolate" - ZeroTrustGatewayRuleGetResponseActionNoisolate ZeroTrustGatewayRuleGetResponseAction = "noisolate" - ZeroTrustGatewayRuleGetResponseActionOverride ZeroTrustGatewayRuleGetResponseAction = "override" - ZeroTrustGatewayRuleGetResponseActionL4Override ZeroTrustGatewayRuleGetResponseAction = "l4_override" - ZeroTrustGatewayRuleGetResponseActionEgress ZeroTrustGatewayRuleGetResponseAction = "egress" - ZeroTrustGatewayRuleGetResponseActionAuditSSH ZeroTrustGatewayRuleGetResponseAction = "audit_ssh" -) - -// The protocol or layer to use. -type ZeroTrustGatewayRuleGetResponseFilter string - -const ( - ZeroTrustGatewayRuleGetResponseFilterHTTP ZeroTrustGatewayRuleGetResponseFilter = "http" - ZeroTrustGatewayRuleGetResponseFilterDNS ZeroTrustGatewayRuleGetResponseFilter = "dns" - ZeroTrustGatewayRuleGetResponseFilterL4 ZeroTrustGatewayRuleGetResponseFilter = "l4" - ZeroTrustGatewayRuleGetResponseFilterEgress ZeroTrustGatewayRuleGetResponseFilter = "egress" -) - -// Additional settings that modify the rule's action. -type ZeroTrustGatewayRuleGetResponseRuleSettings struct { - // Add custom headers to allowed requests, in the form of key-value pairs. Keys are - // header names, pointing to an array with its header value(s). - AddHeaders interface{} `json:"add_headers"` - // Set by parent MSP accounts to enable their children to bypass this rule. - AllowChildBypass bool `json:"allow_child_bypass"` - // Settings for the Audit SSH action. - AuditSSH ZeroTrustGatewayRuleGetResponseRuleSettingsAuditSSH `json:"audit_ssh"` - // Configure how browser isolation behaves. - BisoAdminControls ZeroTrustGatewayRuleGetResponseRuleSettingsBisoAdminControls `json:"biso_admin_controls"` - // Enable the custom block page. - BlockPageEnabled bool `json:"block_page_enabled"` - // The text describing why this block occurred, displayed on the custom block page - // (if enabled). - BlockReason string `json:"block_reason"` - // Set by children MSP accounts to bypass their parent's rules. - BypassParentRule bool `json:"bypass_parent_rule"` - // Configure how session check behaves. - CheckSession ZeroTrustGatewayRuleGetResponseRuleSettingsCheckSession `json:"check_session"` - // Add your own custom resolvers to route queries that match the resolver policy. - // Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will - // route to the address closest to their origin. - DNSResolvers ZeroTrustGatewayRuleGetResponseRuleSettingsDNSResolvers `json:"dns_resolvers"` - // Configure how Gateway Proxy traffic egresses. You can enable this setting for - // rules with Egress actions and filters, or omit it to indicate local egress via - // WARP IPs. - Egress ZeroTrustGatewayRuleGetResponseRuleSettingsEgress `json:"egress"` - // INSECURE - disable DNSSEC validation (for Allow actions). - InsecureDisableDNSSECValidation bool `json:"insecure_disable_dnssec_validation"` - // Set to true to enable IPs in DNS resolver category blocks. By default categories - // only block based on domain names. - IPCategories bool `json:"ip_categories"` - // Set to true to include IPs in DNS resolver indicator feed blocks. By default - // indicator feeds only block based on domain names. - IPIndicatorFeeds bool `json:"ip_indicator_feeds"` - // Send matching traffic to the supplied destination IP address and port. - L4override ZeroTrustGatewayRuleGetResponseRuleSettingsL4override `json:"l4override"` - // Configure a notification to display on the user's device when this rule is - // matched. - NotificationSettings ZeroTrustGatewayRuleGetResponseRuleSettingsNotificationSettings `json:"notification_settings"` - // Override matching DNS queries with a hostname. - OverrideHost string `json:"override_host"` - // Override matching DNS queries with an IP or set of IPs. - OverrideIPs []string `json:"override_ips"` - // Configure DLP payload logging. - PayloadLog ZeroTrustGatewayRuleGetResponseRuleSettingsPayloadLog `json:"payload_log"` - // Enable to send queries that match the policy to Cloudflare's default 1.1.1.1 DNS - // resolver. Cannot be set when dns_resolvers are specified. - ResolveDNSThroughCloudflare bool `json:"resolve_dns_through_cloudflare"` - // Configure behavior when an upstream cert is invalid or an SSL error occurs. - UntrustedCert ZeroTrustGatewayRuleGetResponseRuleSettingsUntrustedCert `json:"untrusted_cert"` - JSON zeroTrustGatewayRuleGetResponseRuleSettingsJSON `json:"-"` -} - -// zeroTrustGatewayRuleGetResponseRuleSettingsJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayRuleGetResponseRuleSettings] -type zeroTrustGatewayRuleGetResponseRuleSettingsJSON struct { - AddHeaders apijson.Field - AllowChildBypass apijson.Field - AuditSSH apijson.Field - BisoAdminControls apijson.Field - BlockPageEnabled apijson.Field - BlockReason apijson.Field - BypassParentRule apijson.Field - CheckSession apijson.Field - DNSResolvers apijson.Field - Egress apijson.Field - InsecureDisableDNSSECValidation apijson.Field - IPCategories apijson.Field - IPIndicatorFeeds apijson.Field - L4override apijson.Field - NotificationSettings apijson.Field - OverrideHost apijson.Field - OverrideIPs apijson.Field - PayloadLog apijson.Field - ResolveDNSThroughCloudflare apijson.Field - UntrustedCert apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleGetResponseRuleSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleGetResponseRuleSettingsJSON) RawJSON() string { - return r.raw -} - -// Settings for the Audit SSH action. -type ZeroTrustGatewayRuleGetResponseRuleSettingsAuditSSH struct { - // Enable to turn on SSH command logging. - CommandLogging bool `json:"command_logging"` - JSON zeroTrustGatewayRuleGetResponseRuleSettingsAuditSSHJSON `json:"-"` -} - -// zeroTrustGatewayRuleGetResponseRuleSettingsAuditSSHJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayRuleGetResponseRuleSettingsAuditSSH] -type zeroTrustGatewayRuleGetResponseRuleSettingsAuditSSHJSON struct { - CommandLogging apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleGetResponseRuleSettingsAuditSSH) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleGetResponseRuleSettingsAuditSSHJSON) RawJSON() string { - return r.raw -} - -// Configure how browser isolation behaves. -type ZeroTrustGatewayRuleGetResponseRuleSettingsBisoAdminControls struct { - // Set to true to enable copy-pasting. - Dcp bool `json:"dcp"` - // Set to true to enable downloading. - Dd bool `json:"dd"` - // Set to true to enable keyboard usage. - Dk bool `json:"dk"` - // Set to true to enable printing. - Dp bool `json:"dp"` - // Set to true to enable uploading. - Du bool `json:"du"` - JSON zeroTrustGatewayRuleGetResponseRuleSettingsBisoAdminControlsJSON `json:"-"` -} - -// zeroTrustGatewayRuleGetResponseRuleSettingsBisoAdminControlsJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayRuleGetResponseRuleSettingsBisoAdminControls] -type zeroTrustGatewayRuleGetResponseRuleSettingsBisoAdminControlsJSON struct { - Dcp apijson.Field - Dd apijson.Field - Dk apijson.Field - Dp apijson.Field - Du apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleGetResponseRuleSettingsBisoAdminControls) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleGetResponseRuleSettingsBisoAdminControlsJSON) RawJSON() string { - return r.raw -} - -// Configure how session check behaves. -type ZeroTrustGatewayRuleGetResponseRuleSettingsCheckSession struct { - // Configure how fresh the session needs to be to be considered valid. - Duration string `json:"duration"` - // Set to true to enable session enforcement. - Enforce bool `json:"enforce"` - JSON zeroTrustGatewayRuleGetResponseRuleSettingsCheckSessionJSON `json:"-"` -} - -// zeroTrustGatewayRuleGetResponseRuleSettingsCheckSessionJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayRuleGetResponseRuleSettingsCheckSession] -type zeroTrustGatewayRuleGetResponseRuleSettingsCheckSessionJSON struct { - Duration apijson.Field - Enforce apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleGetResponseRuleSettingsCheckSession) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleGetResponseRuleSettingsCheckSessionJSON) RawJSON() string { - return r.raw -} - -// Add your own custom resolvers to route queries that match the resolver policy. -// Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will -// route to the address closest to their origin. -type ZeroTrustGatewayRuleGetResponseRuleSettingsDNSResolvers struct { - IPV4 []ZeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversIPV4 `json:"ipv4"` - IPV6 []ZeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversIPV6 `json:"ipv6"` - JSON zeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversJSON `json:"-"` -} - -// zeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayRuleGetResponseRuleSettingsDNSResolvers] -type zeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversJSON struct { - IPV4 apijson.Field - IPV6 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleGetResponseRuleSettingsDNSResolvers) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversIPV4 struct { - // IP address of upstream resolver. - IP string `json:"ip,required"` - // A port number to use for upstream resolver. - Port int64 `json:"port"` - // Whether to connect to this resolver over a private network. Must be set when - // vnet_id is set. - RouteThroughPrivateNetwork bool `json:"route_through_private_network"` - // Optionally specify a virtual network for this resolver. Uses default virtual - // network id if omitted. - VnetID string `json:"vnet_id"` - JSON zeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversIPV4JSON `json:"-"` -} - -// zeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversIPV4JSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversIPV4] -type zeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversIPV4JSON struct { - IP apijson.Field - Port apijson.Field - RouteThroughPrivateNetwork apijson.Field - VnetID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversIPV4) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversIPV4JSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversIPV6 struct { - // IP address of upstream resolver. - IP string `json:"ip,required"` - // A port number to use for upstream resolver. - Port int64 `json:"port"` - // Whether to connect to this resolver over a private network. Must be set when - // vnet_id is set. - RouteThroughPrivateNetwork bool `json:"route_through_private_network"` - // Optionally specify a virtual network for this resolver. Uses default virtual - // network id if omitted. - VnetID string `json:"vnet_id"` - JSON zeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversIPV6JSON `json:"-"` -} - -// zeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversIPV6JSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversIPV6] -type zeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversIPV6JSON struct { - IP apijson.Field - Port apijson.Field - RouteThroughPrivateNetwork apijson.Field - VnetID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversIPV6) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleGetResponseRuleSettingsDNSResolversIPV6JSON) RawJSON() string { - return r.raw -} - -// Configure how Gateway Proxy traffic egresses. You can enable this setting for -// rules with Egress actions and filters, or omit it to indicate local egress via -// WARP IPs. -type ZeroTrustGatewayRuleGetResponseRuleSettingsEgress struct { - // The IPv4 address to be used for egress. - IPV4 string `json:"ipv4"` - // The fallback IPv4 address to be used for egress in the event of an error - // egressing with the primary IPv4. Can be '0.0.0.0' to indicate local egress via - // WARP IPs. - IPV4Fallback string `json:"ipv4_fallback"` - // The IPv6 range to be used for egress. - IPV6 string `json:"ipv6"` - JSON zeroTrustGatewayRuleGetResponseRuleSettingsEgressJSON `json:"-"` -} - -// zeroTrustGatewayRuleGetResponseRuleSettingsEgressJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayRuleGetResponseRuleSettingsEgress] -type zeroTrustGatewayRuleGetResponseRuleSettingsEgressJSON struct { - IPV4 apijson.Field - IPV4Fallback apijson.Field - IPV6 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleGetResponseRuleSettingsEgress) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleGetResponseRuleSettingsEgressJSON) RawJSON() string { - return r.raw -} - -// Send matching traffic to the supplied destination IP address and port. -type ZeroTrustGatewayRuleGetResponseRuleSettingsL4override struct { - // IPv4 or IPv6 address. - IP string `json:"ip"` - // A port number to use for TCP/UDP overrides. - Port int64 `json:"port"` - JSON zeroTrustGatewayRuleGetResponseRuleSettingsL4overrideJSON `json:"-"` -} - -// zeroTrustGatewayRuleGetResponseRuleSettingsL4overrideJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayRuleGetResponseRuleSettingsL4override] -type zeroTrustGatewayRuleGetResponseRuleSettingsL4overrideJSON struct { - IP apijson.Field - Port apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleGetResponseRuleSettingsL4override) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleGetResponseRuleSettingsL4overrideJSON) RawJSON() string { - return r.raw -} - -// Configure a notification to display on the user's device when this rule is -// matched. -type ZeroTrustGatewayRuleGetResponseRuleSettingsNotificationSettings struct { - // Set notification on - Enabled bool `json:"enabled"` - // Customize the message shown in the notification. - Msg string `json:"msg"` - // Optional URL to direct users to additional information. If not set, the - // notification will open a block page. - SupportURL string `json:"support_url"` - JSON zeroTrustGatewayRuleGetResponseRuleSettingsNotificationSettingsJSON `json:"-"` -} - -// zeroTrustGatewayRuleGetResponseRuleSettingsNotificationSettingsJSON contains the -// JSON metadata for the struct -// [ZeroTrustGatewayRuleGetResponseRuleSettingsNotificationSettings] -type zeroTrustGatewayRuleGetResponseRuleSettingsNotificationSettingsJSON struct { - Enabled apijson.Field - Msg apijson.Field - SupportURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleGetResponseRuleSettingsNotificationSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleGetResponseRuleSettingsNotificationSettingsJSON) RawJSON() string { - return r.raw -} - -// Configure DLP payload logging. -type ZeroTrustGatewayRuleGetResponseRuleSettingsPayloadLog struct { - // Set to true to enable DLP payload logging for this rule. - Enabled bool `json:"enabled"` - JSON zeroTrustGatewayRuleGetResponseRuleSettingsPayloadLogJSON `json:"-"` -} - -// zeroTrustGatewayRuleGetResponseRuleSettingsPayloadLogJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayRuleGetResponseRuleSettingsPayloadLog] -type zeroTrustGatewayRuleGetResponseRuleSettingsPayloadLogJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleGetResponseRuleSettingsPayloadLog) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleGetResponseRuleSettingsPayloadLogJSON) RawJSON() string { - return r.raw -} - -// Configure behavior when an upstream cert is invalid or an SSL error occurs. -type ZeroTrustGatewayRuleGetResponseRuleSettingsUntrustedCert struct { - // The action performed when an untrusted certificate is seen. The default action - // is an error with HTTP code 526. - Action ZeroTrustGatewayRuleGetResponseRuleSettingsUntrustedCertAction `json:"action"` - JSON zeroTrustGatewayRuleGetResponseRuleSettingsUntrustedCertJSON `json:"-"` -} - -// zeroTrustGatewayRuleGetResponseRuleSettingsUntrustedCertJSON contains the JSON -// metadata for the struct -// [ZeroTrustGatewayRuleGetResponseRuleSettingsUntrustedCert] -type zeroTrustGatewayRuleGetResponseRuleSettingsUntrustedCertJSON struct { - Action apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleGetResponseRuleSettingsUntrustedCert) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleGetResponseRuleSettingsUntrustedCertJSON) RawJSON() string { - return r.raw -} - -// The action performed when an untrusted certificate is seen. The default action -// is an error with HTTP code 526. -type ZeroTrustGatewayRuleGetResponseRuleSettingsUntrustedCertAction string - -const ( - ZeroTrustGatewayRuleGetResponseRuleSettingsUntrustedCertActionPassThrough ZeroTrustGatewayRuleGetResponseRuleSettingsUntrustedCertAction = "pass_through" - ZeroTrustGatewayRuleGetResponseRuleSettingsUntrustedCertActionBlock ZeroTrustGatewayRuleGetResponseRuleSettingsUntrustedCertAction = "block" - ZeroTrustGatewayRuleGetResponseRuleSettingsUntrustedCertActionError ZeroTrustGatewayRuleGetResponseRuleSettingsUntrustedCertAction = "error" -) - -// The schedule for activating DNS policies. This does not apply to HTTP or network -// policies. -type ZeroTrustGatewayRuleGetResponseSchedule struct { - // The time intervals when the rule will be active on Fridays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Fridays. - Fri string `json:"fri"` - // The time intervals when the rule will be active on Mondays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Mondays. - Mon string `json:"mon"` - // The time intervals when the rule will be active on Saturdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Saturdays. - Sat string `json:"sat"` - // The time intervals when the rule will be active on Sundays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Sundays. - Sun string `json:"sun"` - // The time intervals when the rule will be active on Thursdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Thursdays. - Thu string `json:"thu"` - // The time zone the rule will be evaluated against. If a - // [valid time zone city name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) - // is provided, Gateway will always use the current time at that time zone. If this - // parameter is omitted, then Gateway will use the time zone inferred from the - // user's source IP to evaluate the rule. If Gateway cannot determine the time zone - // from the IP, we will fall back to the time zone of the user's connected data - // center. - TimeZone string `json:"time_zone"` - // The time intervals when the rule will be active on Tuesdays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Tuesdays. - Tue string `json:"tue"` - // The time intervals when the rule will be active on Wednesdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Wednesdays. - Wed string `json:"wed"` - JSON zeroTrustGatewayRuleGetResponseScheduleJSON `json:"-"` -} - -// zeroTrustGatewayRuleGetResponseScheduleJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayRuleGetResponseSchedule] -type zeroTrustGatewayRuleGetResponseScheduleJSON struct { - Fri apijson.Field - Mon apijson.Field - Sat apijson.Field - Sun apijson.Field - Thu apijson.Field - TimeZone apijson.Field - Tue apijson.Field - Wed apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleGetResponseSchedule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleGetResponseScheduleJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleNewParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // The action to preform when the associated traffic, identity, and device posture - // expressions are either absent or evaluate to `true`. - Action param.Field[ZeroTrustGatewayRuleNewParamsAction] `json:"action,required"` - // The name of the rule. - Name param.Field[string] `json:"name,required"` - // The description of the rule. - Description param.Field[string] `json:"description"` - // The wirefilter expression used for device posture check matching. - DevicePosture param.Field[string] `json:"device_posture"` - // True if the rule is enabled. - Enabled param.Field[bool] `json:"enabled"` - // The protocol or layer to evaluate the traffic, identity, and device posture - // expressions. - Filters param.Field[[]ZeroTrustGatewayRuleNewParamsFilter] `json:"filters"` - // The wirefilter expression used for identity matching. - Identity param.Field[string] `json:"identity"` - // Precedence sets the order of your rules. Lower values indicate higher - // precedence. At each processing phase, applicable rules are evaluated in - // ascending order of this value. - Precedence param.Field[int64] `json:"precedence"` - // Additional settings that modify the rule's action. - RuleSettings param.Field[ZeroTrustGatewayRuleNewParamsRuleSettings] `json:"rule_settings"` - // The schedule for activating DNS policies. This does not apply to HTTP or network - // policies. - Schedule param.Field[ZeroTrustGatewayRuleNewParamsSchedule] `json:"schedule"` - // The wirefilter expression used for traffic matching. - Traffic param.Field[string] `json:"traffic"` -} - -func (r ZeroTrustGatewayRuleNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The action to preform when the associated traffic, identity, and device posture -// expressions are either absent or evaluate to `true`. -type ZeroTrustGatewayRuleNewParamsAction string - -const ( - ZeroTrustGatewayRuleNewParamsActionOn ZeroTrustGatewayRuleNewParamsAction = "on" - ZeroTrustGatewayRuleNewParamsActionOff ZeroTrustGatewayRuleNewParamsAction = "off" - ZeroTrustGatewayRuleNewParamsActionAllow ZeroTrustGatewayRuleNewParamsAction = "allow" - ZeroTrustGatewayRuleNewParamsActionBlock ZeroTrustGatewayRuleNewParamsAction = "block" - ZeroTrustGatewayRuleNewParamsActionScan ZeroTrustGatewayRuleNewParamsAction = "scan" - ZeroTrustGatewayRuleNewParamsActionNoscan ZeroTrustGatewayRuleNewParamsAction = "noscan" - ZeroTrustGatewayRuleNewParamsActionSafesearch ZeroTrustGatewayRuleNewParamsAction = "safesearch" - ZeroTrustGatewayRuleNewParamsActionYtrestricted ZeroTrustGatewayRuleNewParamsAction = "ytrestricted" - ZeroTrustGatewayRuleNewParamsActionIsolate ZeroTrustGatewayRuleNewParamsAction = "isolate" - ZeroTrustGatewayRuleNewParamsActionNoisolate ZeroTrustGatewayRuleNewParamsAction = "noisolate" - ZeroTrustGatewayRuleNewParamsActionOverride ZeroTrustGatewayRuleNewParamsAction = "override" - ZeroTrustGatewayRuleNewParamsActionL4Override ZeroTrustGatewayRuleNewParamsAction = "l4_override" - ZeroTrustGatewayRuleNewParamsActionEgress ZeroTrustGatewayRuleNewParamsAction = "egress" - ZeroTrustGatewayRuleNewParamsActionAuditSSH ZeroTrustGatewayRuleNewParamsAction = "audit_ssh" -) - -// The protocol or layer to use. -type ZeroTrustGatewayRuleNewParamsFilter string - -const ( - ZeroTrustGatewayRuleNewParamsFilterHTTP ZeroTrustGatewayRuleNewParamsFilter = "http" - ZeroTrustGatewayRuleNewParamsFilterDNS ZeroTrustGatewayRuleNewParamsFilter = "dns" - ZeroTrustGatewayRuleNewParamsFilterL4 ZeroTrustGatewayRuleNewParamsFilter = "l4" - ZeroTrustGatewayRuleNewParamsFilterEgress ZeroTrustGatewayRuleNewParamsFilter = "egress" -) - -// Additional settings that modify the rule's action. -type ZeroTrustGatewayRuleNewParamsRuleSettings struct { - // Add custom headers to allowed requests, in the form of key-value pairs. Keys are - // header names, pointing to an array with its header value(s). - AddHeaders param.Field[interface{}] `json:"add_headers"` - // Set by parent MSP accounts to enable their children to bypass this rule. - AllowChildBypass param.Field[bool] `json:"allow_child_bypass"` - // Settings for the Audit SSH action. - AuditSSH param.Field[ZeroTrustGatewayRuleNewParamsRuleSettingsAuditSSH] `json:"audit_ssh"` - // Configure how browser isolation behaves. - BisoAdminControls param.Field[ZeroTrustGatewayRuleNewParamsRuleSettingsBisoAdminControls] `json:"biso_admin_controls"` - // Enable the custom block page. - BlockPageEnabled param.Field[bool] `json:"block_page_enabled"` - // The text describing why this block occurred, displayed on the custom block page - // (if enabled). - BlockReason param.Field[string] `json:"block_reason"` - // Set by children MSP accounts to bypass their parent's rules. - BypassParentRule param.Field[bool] `json:"bypass_parent_rule"` - // Configure how session check behaves. - CheckSession param.Field[ZeroTrustGatewayRuleNewParamsRuleSettingsCheckSession] `json:"check_session"` - // Add your own custom resolvers to route queries that match the resolver policy. - // Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will - // route to the address closest to their origin. - DNSResolvers param.Field[ZeroTrustGatewayRuleNewParamsRuleSettingsDNSResolvers] `json:"dns_resolvers"` - // Configure how Gateway Proxy traffic egresses. You can enable this setting for - // rules with Egress actions and filters, or omit it to indicate local egress via - // WARP IPs. - Egress param.Field[ZeroTrustGatewayRuleNewParamsRuleSettingsEgress] `json:"egress"` - // INSECURE - disable DNSSEC validation (for Allow actions). - InsecureDisableDNSSECValidation param.Field[bool] `json:"insecure_disable_dnssec_validation"` - // Set to true to enable IPs in DNS resolver category blocks. By default categories - // only block based on domain names. - IPCategories param.Field[bool] `json:"ip_categories"` - // Set to true to include IPs in DNS resolver indicator feed blocks. By default - // indicator feeds only block based on domain names. - IPIndicatorFeeds param.Field[bool] `json:"ip_indicator_feeds"` - // Send matching traffic to the supplied destination IP address and port. - L4override param.Field[ZeroTrustGatewayRuleNewParamsRuleSettingsL4override] `json:"l4override"` - // Configure a notification to display on the user's device when this rule is - // matched. - NotificationSettings param.Field[ZeroTrustGatewayRuleNewParamsRuleSettingsNotificationSettings] `json:"notification_settings"` - // Override matching DNS queries with a hostname. - OverrideHost param.Field[string] `json:"override_host"` - // Override matching DNS queries with an IP or set of IPs. - OverrideIPs param.Field[[]string] `json:"override_ips"` - // Configure DLP payload logging. - PayloadLog param.Field[ZeroTrustGatewayRuleNewParamsRuleSettingsPayloadLog] `json:"payload_log"` - // Enable to send queries that match the policy to Cloudflare's default 1.1.1.1 DNS - // resolver. Cannot be set when dns_resolvers are specified. - ResolveDNSThroughCloudflare param.Field[bool] `json:"resolve_dns_through_cloudflare"` - // Configure behavior when an upstream cert is invalid or an SSL error occurs. - UntrustedCert param.Field[ZeroTrustGatewayRuleNewParamsRuleSettingsUntrustedCert] `json:"untrusted_cert"` -} - -func (r ZeroTrustGatewayRuleNewParamsRuleSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Settings for the Audit SSH action. -type ZeroTrustGatewayRuleNewParamsRuleSettingsAuditSSH struct { - // Enable to turn on SSH command logging. - CommandLogging param.Field[bool] `json:"command_logging"` -} - -func (r ZeroTrustGatewayRuleNewParamsRuleSettingsAuditSSH) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure how browser isolation behaves. -type ZeroTrustGatewayRuleNewParamsRuleSettingsBisoAdminControls struct { - // Set to true to enable copy-pasting. - Dcp param.Field[bool] `json:"dcp"` - // Set to true to enable downloading. - Dd param.Field[bool] `json:"dd"` - // Set to true to enable keyboard usage. - Dk param.Field[bool] `json:"dk"` - // Set to true to enable printing. - Dp param.Field[bool] `json:"dp"` - // Set to true to enable uploading. - Du param.Field[bool] `json:"du"` -} - -func (r ZeroTrustGatewayRuleNewParamsRuleSettingsBisoAdminControls) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure how session check behaves. -type ZeroTrustGatewayRuleNewParamsRuleSettingsCheckSession struct { - // Configure how fresh the session needs to be to be considered valid. - Duration param.Field[string] `json:"duration"` - // Set to true to enable session enforcement. - Enforce param.Field[bool] `json:"enforce"` -} - -func (r ZeroTrustGatewayRuleNewParamsRuleSettingsCheckSession) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Add your own custom resolvers to route queries that match the resolver policy. -// Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will -// route to the address closest to their origin. -type ZeroTrustGatewayRuleNewParamsRuleSettingsDNSResolvers struct { - IPV4 param.Field[[]ZeroTrustGatewayRuleNewParamsRuleSettingsDNSResolversIPV4] `json:"ipv4"` - IPV6 param.Field[[]ZeroTrustGatewayRuleNewParamsRuleSettingsDNSResolversIPV6] `json:"ipv6"` -} - -func (r ZeroTrustGatewayRuleNewParamsRuleSettingsDNSResolvers) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayRuleNewParamsRuleSettingsDNSResolversIPV4 struct { - // IP address of upstream resolver. - IP param.Field[string] `json:"ip,required"` - // A port number to use for upstream resolver. - Port param.Field[int64] `json:"port"` - // Whether to connect to this resolver over a private network. Must be set when - // vnet_id is set. - RouteThroughPrivateNetwork param.Field[bool] `json:"route_through_private_network"` - // Optionally specify a virtual network for this resolver. Uses default virtual - // network id if omitted. - VnetID param.Field[string] `json:"vnet_id"` -} - -func (r ZeroTrustGatewayRuleNewParamsRuleSettingsDNSResolversIPV4) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayRuleNewParamsRuleSettingsDNSResolversIPV6 struct { - // IP address of upstream resolver. - IP param.Field[string] `json:"ip,required"` - // A port number to use for upstream resolver. - Port param.Field[int64] `json:"port"` - // Whether to connect to this resolver over a private network. Must be set when - // vnet_id is set. - RouteThroughPrivateNetwork param.Field[bool] `json:"route_through_private_network"` - // Optionally specify a virtual network for this resolver. Uses default virtual - // network id if omitted. - VnetID param.Field[string] `json:"vnet_id"` -} - -func (r ZeroTrustGatewayRuleNewParamsRuleSettingsDNSResolversIPV6) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure how Gateway Proxy traffic egresses. You can enable this setting for -// rules with Egress actions and filters, or omit it to indicate local egress via -// WARP IPs. -type ZeroTrustGatewayRuleNewParamsRuleSettingsEgress struct { - // The IPv4 address to be used for egress. - IPV4 param.Field[string] `json:"ipv4"` - // The fallback IPv4 address to be used for egress in the event of an error - // egressing with the primary IPv4. Can be '0.0.0.0' to indicate local egress via - // WARP IPs. - IPV4Fallback param.Field[string] `json:"ipv4_fallback"` - // The IPv6 range to be used for egress. - IPV6 param.Field[string] `json:"ipv6"` -} - -func (r ZeroTrustGatewayRuleNewParamsRuleSettingsEgress) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Send matching traffic to the supplied destination IP address and port. -type ZeroTrustGatewayRuleNewParamsRuleSettingsL4override struct { - // IPv4 or IPv6 address. - IP param.Field[string] `json:"ip"` - // A port number to use for TCP/UDP overrides. - Port param.Field[int64] `json:"port"` -} - -func (r ZeroTrustGatewayRuleNewParamsRuleSettingsL4override) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure a notification to display on the user's device when this rule is -// matched. -type ZeroTrustGatewayRuleNewParamsRuleSettingsNotificationSettings struct { - // Set notification on - Enabled param.Field[bool] `json:"enabled"` - // Customize the message shown in the notification. - Msg param.Field[string] `json:"msg"` - // Optional URL to direct users to additional information. If not set, the - // notification will open a block page. - SupportURL param.Field[string] `json:"support_url"` -} - -func (r ZeroTrustGatewayRuleNewParamsRuleSettingsNotificationSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure DLP payload logging. -type ZeroTrustGatewayRuleNewParamsRuleSettingsPayloadLog struct { - // Set to true to enable DLP payload logging for this rule. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ZeroTrustGatewayRuleNewParamsRuleSettingsPayloadLog) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure behavior when an upstream cert is invalid or an SSL error occurs. -type ZeroTrustGatewayRuleNewParamsRuleSettingsUntrustedCert struct { - // The action performed when an untrusted certificate is seen. The default action - // is an error with HTTP code 526. - Action param.Field[ZeroTrustGatewayRuleNewParamsRuleSettingsUntrustedCertAction] `json:"action"` -} - -func (r ZeroTrustGatewayRuleNewParamsRuleSettingsUntrustedCert) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The action performed when an untrusted certificate is seen. The default action -// is an error with HTTP code 526. -type ZeroTrustGatewayRuleNewParamsRuleSettingsUntrustedCertAction string - -const ( - ZeroTrustGatewayRuleNewParamsRuleSettingsUntrustedCertActionPassThrough ZeroTrustGatewayRuleNewParamsRuleSettingsUntrustedCertAction = "pass_through" - ZeroTrustGatewayRuleNewParamsRuleSettingsUntrustedCertActionBlock ZeroTrustGatewayRuleNewParamsRuleSettingsUntrustedCertAction = "block" - ZeroTrustGatewayRuleNewParamsRuleSettingsUntrustedCertActionError ZeroTrustGatewayRuleNewParamsRuleSettingsUntrustedCertAction = "error" -) - -// The schedule for activating DNS policies. This does not apply to HTTP or network -// policies. -type ZeroTrustGatewayRuleNewParamsSchedule struct { - // The time intervals when the rule will be active on Fridays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Fridays. - Fri param.Field[string] `json:"fri"` - // The time intervals when the rule will be active on Mondays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Mondays. - Mon param.Field[string] `json:"mon"` - // The time intervals when the rule will be active on Saturdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Saturdays. - Sat param.Field[string] `json:"sat"` - // The time intervals when the rule will be active on Sundays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Sundays. - Sun param.Field[string] `json:"sun"` - // The time intervals when the rule will be active on Thursdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Thursdays. - Thu param.Field[string] `json:"thu"` - // The time zone the rule will be evaluated against. If a - // [valid time zone city name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) - // is provided, Gateway will always use the current time at that time zone. If this - // parameter is omitted, then Gateway will use the time zone inferred from the - // user's source IP to evaluate the rule. If Gateway cannot determine the time zone - // from the IP, we will fall back to the time zone of the user's connected data - // center. - TimeZone param.Field[string] `json:"time_zone"` - // The time intervals when the rule will be active on Tuesdays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Tuesdays. - Tue param.Field[string] `json:"tue"` - // The time intervals when the rule will be active on Wednesdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Wednesdays. - Wed param.Field[string] `json:"wed"` -} - -func (r ZeroTrustGatewayRuleNewParamsSchedule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayRuleNewResponseEnvelope struct { - Errors []ZeroTrustGatewayRuleNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayRuleNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayRuleNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayRuleNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayRuleNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayRuleNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayRuleNewResponseEnvelope] -type zeroTrustGatewayRuleNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayRuleNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayRuleNewResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayRuleNewResponseEnvelopeErrors] -type zeroTrustGatewayRuleNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayRuleNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayRuleNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayRuleNewResponseEnvelopeMessages] -type zeroTrustGatewayRuleNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayRuleNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayRuleNewResponseEnvelopeSuccessTrue ZeroTrustGatewayRuleNewResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayRuleUpdateParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` - // The action to preform when the associated traffic, identity, and device posture - // expressions are either absent or evaluate to `true`. - Action param.Field[ZeroTrustGatewayRuleUpdateParamsAction] `json:"action,required"` - // The name of the rule. - Name param.Field[string] `json:"name,required"` - // The description of the rule. - Description param.Field[string] `json:"description"` - // The wirefilter expression used for device posture check matching. - DevicePosture param.Field[string] `json:"device_posture"` - // True if the rule is enabled. - Enabled param.Field[bool] `json:"enabled"` - // The protocol or layer to evaluate the traffic, identity, and device posture - // expressions. - Filters param.Field[[]ZeroTrustGatewayRuleUpdateParamsFilter] `json:"filters"` - // The wirefilter expression used for identity matching. - Identity param.Field[string] `json:"identity"` - // Precedence sets the order of your rules. Lower values indicate higher - // precedence. At each processing phase, applicable rules are evaluated in - // ascending order of this value. - Precedence param.Field[int64] `json:"precedence"` - // Additional settings that modify the rule's action. - RuleSettings param.Field[ZeroTrustGatewayRuleUpdateParamsRuleSettings] `json:"rule_settings"` - // The schedule for activating DNS policies. This does not apply to HTTP or network - // policies. - Schedule param.Field[ZeroTrustGatewayRuleUpdateParamsSchedule] `json:"schedule"` - // The wirefilter expression used for traffic matching. - Traffic param.Field[string] `json:"traffic"` -} - -func (r ZeroTrustGatewayRuleUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The action to preform when the associated traffic, identity, and device posture -// expressions are either absent or evaluate to `true`. -type ZeroTrustGatewayRuleUpdateParamsAction string - -const ( - ZeroTrustGatewayRuleUpdateParamsActionOn ZeroTrustGatewayRuleUpdateParamsAction = "on" - ZeroTrustGatewayRuleUpdateParamsActionOff ZeroTrustGatewayRuleUpdateParamsAction = "off" - ZeroTrustGatewayRuleUpdateParamsActionAllow ZeroTrustGatewayRuleUpdateParamsAction = "allow" - ZeroTrustGatewayRuleUpdateParamsActionBlock ZeroTrustGatewayRuleUpdateParamsAction = "block" - ZeroTrustGatewayRuleUpdateParamsActionScan ZeroTrustGatewayRuleUpdateParamsAction = "scan" - ZeroTrustGatewayRuleUpdateParamsActionNoscan ZeroTrustGatewayRuleUpdateParamsAction = "noscan" - ZeroTrustGatewayRuleUpdateParamsActionSafesearch ZeroTrustGatewayRuleUpdateParamsAction = "safesearch" - ZeroTrustGatewayRuleUpdateParamsActionYtrestricted ZeroTrustGatewayRuleUpdateParamsAction = "ytrestricted" - ZeroTrustGatewayRuleUpdateParamsActionIsolate ZeroTrustGatewayRuleUpdateParamsAction = "isolate" - ZeroTrustGatewayRuleUpdateParamsActionNoisolate ZeroTrustGatewayRuleUpdateParamsAction = "noisolate" - ZeroTrustGatewayRuleUpdateParamsActionOverride ZeroTrustGatewayRuleUpdateParamsAction = "override" - ZeroTrustGatewayRuleUpdateParamsActionL4Override ZeroTrustGatewayRuleUpdateParamsAction = "l4_override" - ZeroTrustGatewayRuleUpdateParamsActionEgress ZeroTrustGatewayRuleUpdateParamsAction = "egress" - ZeroTrustGatewayRuleUpdateParamsActionAuditSSH ZeroTrustGatewayRuleUpdateParamsAction = "audit_ssh" -) - -// The protocol or layer to use. -type ZeroTrustGatewayRuleUpdateParamsFilter string - -const ( - ZeroTrustGatewayRuleUpdateParamsFilterHTTP ZeroTrustGatewayRuleUpdateParamsFilter = "http" - ZeroTrustGatewayRuleUpdateParamsFilterDNS ZeroTrustGatewayRuleUpdateParamsFilter = "dns" - ZeroTrustGatewayRuleUpdateParamsFilterL4 ZeroTrustGatewayRuleUpdateParamsFilter = "l4" - ZeroTrustGatewayRuleUpdateParamsFilterEgress ZeroTrustGatewayRuleUpdateParamsFilter = "egress" -) - -// Additional settings that modify the rule's action. -type ZeroTrustGatewayRuleUpdateParamsRuleSettings struct { - // Add custom headers to allowed requests, in the form of key-value pairs. Keys are - // header names, pointing to an array with its header value(s). - AddHeaders param.Field[interface{}] `json:"add_headers"` - // Set by parent MSP accounts to enable their children to bypass this rule. - AllowChildBypass param.Field[bool] `json:"allow_child_bypass"` - // Settings for the Audit SSH action. - AuditSSH param.Field[ZeroTrustGatewayRuleUpdateParamsRuleSettingsAuditSSH] `json:"audit_ssh"` - // Configure how browser isolation behaves. - BisoAdminControls param.Field[ZeroTrustGatewayRuleUpdateParamsRuleSettingsBisoAdminControls] `json:"biso_admin_controls"` - // Enable the custom block page. - BlockPageEnabled param.Field[bool] `json:"block_page_enabled"` - // The text describing why this block occurred, displayed on the custom block page - // (if enabled). - BlockReason param.Field[string] `json:"block_reason"` - // Set by children MSP accounts to bypass their parent's rules. - BypassParentRule param.Field[bool] `json:"bypass_parent_rule"` - // Configure how session check behaves. - CheckSession param.Field[ZeroTrustGatewayRuleUpdateParamsRuleSettingsCheckSession] `json:"check_session"` - // Add your own custom resolvers to route queries that match the resolver policy. - // Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will - // route to the address closest to their origin. - DNSResolvers param.Field[ZeroTrustGatewayRuleUpdateParamsRuleSettingsDNSResolvers] `json:"dns_resolvers"` - // Configure how Gateway Proxy traffic egresses. You can enable this setting for - // rules with Egress actions and filters, or omit it to indicate local egress via - // WARP IPs. - Egress param.Field[ZeroTrustGatewayRuleUpdateParamsRuleSettingsEgress] `json:"egress"` - // INSECURE - disable DNSSEC validation (for Allow actions). - InsecureDisableDNSSECValidation param.Field[bool] `json:"insecure_disable_dnssec_validation"` - // Set to true to enable IPs in DNS resolver category blocks. By default categories - // only block based on domain names. - IPCategories param.Field[bool] `json:"ip_categories"` - // Set to true to include IPs in DNS resolver indicator feed blocks. By default - // indicator feeds only block based on domain names. - IPIndicatorFeeds param.Field[bool] `json:"ip_indicator_feeds"` - // Send matching traffic to the supplied destination IP address and port. - L4override param.Field[ZeroTrustGatewayRuleUpdateParamsRuleSettingsL4override] `json:"l4override"` - // Configure a notification to display on the user's device when this rule is - // matched. - NotificationSettings param.Field[ZeroTrustGatewayRuleUpdateParamsRuleSettingsNotificationSettings] `json:"notification_settings"` - // Override matching DNS queries with a hostname. - OverrideHost param.Field[string] `json:"override_host"` - // Override matching DNS queries with an IP or set of IPs. - OverrideIPs param.Field[[]string] `json:"override_ips"` - // Configure DLP payload logging. - PayloadLog param.Field[ZeroTrustGatewayRuleUpdateParamsRuleSettingsPayloadLog] `json:"payload_log"` - // Enable to send queries that match the policy to Cloudflare's default 1.1.1.1 DNS - // resolver. Cannot be set when dns_resolvers are specified. - ResolveDNSThroughCloudflare param.Field[bool] `json:"resolve_dns_through_cloudflare"` - // Configure behavior when an upstream cert is invalid or an SSL error occurs. - UntrustedCert param.Field[ZeroTrustGatewayRuleUpdateParamsRuleSettingsUntrustedCert] `json:"untrusted_cert"` -} - -func (r ZeroTrustGatewayRuleUpdateParamsRuleSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Settings for the Audit SSH action. -type ZeroTrustGatewayRuleUpdateParamsRuleSettingsAuditSSH struct { - // Enable to turn on SSH command logging. - CommandLogging param.Field[bool] `json:"command_logging"` -} - -func (r ZeroTrustGatewayRuleUpdateParamsRuleSettingsAuditSSH) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure how browser isolation behaves. -type ZeroTrustGatewayRuleUpdateParamsRuleSettingsBisoAdminControls struct { - // Set to true to enable copy-pasting. - Dcp param.Field[bool] `json:"dcp"` - // Set to true to enable downloading. - Dd param.Field[bool] `json:"dd"` - // Set to true to enable keyboard usage. - Dk param.Field[bool] `json:"dk"` - // Set to true to enable printing. - Dp param.Field[bool] `json:"dp"` - // Set to true to enable uploading. - Du param.Field[bool] `json:"du"` -} - -func (r ZeroTrustGatewayRuleUpdateParamsRuleSettingsBisoAdminControls) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure how session check behaves. -type ZeroTrustGatewayRuleUpdateParamsRuleSettingsCheckSession struct { - // Configure how fresh the session needs to be to be considered valid. - Duration param.Field[string] `json:"duration"` - // Set to true to enable session enforcement. - Enforce param.Field[bool] `json:"enforce"` -} - -func (r ZeroTrustGatewayRuleUpdateParamsRuleSettingsCheckSession) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Add your own custom resolvers to route queries that match the resolver policy. -// Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will -// route to the address closest to their origin. -type ZeroTrustGatewayRuleUpdateParamsRuleSettingsDNSResolvers struct { - IPV4 param.Field[[]ZeroTrustGatewayRuleUpdateParamsRuleSettingsDNSResolversIPV4] `json:"ipv4"` - IPV6 param.Field[[]ZeroTrustGatewayRuleUpdateParamsRuleSettingsDNSResolversIPV6] `json:"ipv6"` -} - -func (r ZeroTrustGatewayRuleUpdateParamsRuleSettingsDNSResolvers) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayRuleUpdateParamsRuleSettingsDNSResolversIPV4 struct { - // IP address of upstream resolver. - IP param.Field[string] `json:"ip,required"` - // A port number to use for upstream resolver. - Port param.Field[int64] `json:"port"` - // Whether to connect to this resolver over a private network. Must be set when - // vnet_id is set. - RouteThroughPrivateNetwork param.Field[bool] `json:"route_through_private_network"` - // Optionally specify a virtual network for this resolver. Uses default virtual - // network id if omitted. - VnetID param.Field[string] `json:"vnet_id"` -} - -func (r ZeroTrustGatewayRuleUpdateParamsRuleSettingsDNSResolversIPV4) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayRuleUpdateParamsRuleSettingsDNSResolversIPV6 struct { - // IP address of upstream resolver. - IP param.Field[string] `json:"ip,required"` - // A port number to use for upstream resolver. - Port param.Field[int64] `json:"port"` - // Whether to connect to this resolver over a private network. Must be set when - // vnet_id is set. - RouteThroughPrivateNetwork param.Field[bool] `json:"route_through_private_network"` - // Optionally specify a virtual network for this resolver. Uses default virtual - // network id if omitted. - VnetID param.Field[string] `json:"vnet_id"` -} - -func (r ZeroTrustGatewayRuleUpdateParamsRuleSettingsDNSResolversIPV6) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure how Gateway Proxy traffic egresses. You can enable this setting for -// rules with Egress actions and filters, or omit it to indicate local egress via -// WARP IPs. -type ZeroTrustGatewayRuleUpdateParamsRuleSettingsEgress struct { - // The IPv4 address to be used for egress. - IPV4 param.Field[string] `json:"ipv4"` - // The fallback IPv4 address to be used for egress in the event of an error - // egressing with the primary IPv4. Can be '0.0.0.0' to indicate local egress via - // WARP IPs. - IPV4Fallback param.Field[string] `json:"ipv4_fallback"` - // The IPv6 range to be used for egress. - IPV6 param.Field[string] `json:"ipv6"` -} - -func (r ZeroTrustGatewayRuleUpdateParamsRuleSettingsEgress) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Send matching traffic to the supplied destination IP address and port. -type ZeroTrustGatewayRuleUpdateParamsRuleSettingsL4override struct { - // IPv4 or IPv6 address. - IP param.Field[string] `json:"ip"` - // A port number to use for TCP/UDP overrides. - Port param.Field[int64] `json:"port"` -} - -func (r ZeroTrustGatewayRuleUpdateParamsRuleSettingsL4override) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure a notification to display on the user's device when this rule is -// matched. -type ZeroTrustGatewayRuleUpdateParamsRuleSettingsNotificationSettings struct { - // Set notification on - Enabled param.Field[bool] `json:"enabled"` - // Customize the message shown in the notification. - Msg param.Field[string] `json:"msg"` - // Optional URL to direct users to additional information. If not set, the - // notification will open a block page. - SupportURL param.Field[string] `json:"support_url"` -} - -func (r ZeroTrustGatewayRuleUpdateParamsRuleSettingsNotificationSettings) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure DLP payload logging. -type ZeroTrustGatewayRuleUpdateParamsRuleSettingsPayloadLog struct { - // Set to true to enable DLP payload logging for this rule. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ZeroTrustGatewayRuleUpdateParamsRuleSettingsPayloadLog) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configure behavior when an upstream cert is invalid or an SSL error occurs. -type ZeroTrustGatewayRuleUpdateParamsRuleSettingsUntrustedCert struct { - // The action performed when an untrusted certificate is seen. The default action - // is an error with HTTP code 526. - Action param.Field[ZeroTrustGatewayRuleUpdateParamsRuleSettingsUntrustedCertAction] `json:"action"` -} - -func (r ZeroTrustGatewayRuleUpdateParamsRuleSettingsUntrustedCert) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The action performed when an untrusted certificate is seen. The default action -// is an error with HTTP code 526. -type ZeroTrustGatewayRuleUpdateParamsRuleSettingsUntrustedCertAction string - -const ( - ZeroTrustGatewayRuleUpdateParamsRuleSettingsUntrustedCertActionPassThrough ZeroTrustGatewayRuleUpdateParamsRuleSettingsUntrustedCertAction = "pass_through" - ZeroTrustGatewayRuleUpdateParamsRuleSettingsUntrustedCertActionBlock ZeroTrustGatewayRuleUpdateParamsRuleSettingsUntrustedCertAction = "block" - ZeroTrustGatewayRuleUpdateParamsRuleSettingsUntrustedCertActionError ZeroTrustGatewayRuleUpdateParamsRuleSettingsUntrustedCertAction = "error" -) - -// The schedule for activating DNS policies. This does not apply to HTTP or network -// policies. -type ZeroTrustGatewayRuleUpdateParamsSchedule struct { - // The time intervals when the rule will be active on Fridays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Fridays. - Fri param.Field[string] `json:"fri"` - // The time intervals when the rule will be active on Mondays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Mondays. - Mon param.Field[string] `json:"mon"` - // The time intervals when the rule will be active on Saturdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Saturdays. - Sat param.Field[string] `json:"sat"` - // The time intervals when the rule will be active on Sundays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Sundays. - Sun param.Field[string] `json:"sun"` - // The time intervals when the rule will be active on Thursdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Thursdays. - Thu param.Field[string] `json:"thu"` - // The time zone the rule will be evaluated against. If a - // [valid time zone city name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) - // is provided, Gateway will always use the current time at that time zone. If this - // parameter is omitted, then Gateway will use the time zone inferred from the - // user's source IP to evaluate the rule. If Gateway cannot determine the time zone - // from the IP, we will fall back to the time zone of the user's connected data - // center. - TimeZone param.Field[string] `json:"time_zone"` - // The time intervals when the rule will be active on Tuesdays, in increasing order - // from 00:00-24:00. If this parameter is omitted, the rule will be deactivated on - // Tuesdays. - Tue param.Field[string] `json:"tue"` - // The time intervals when the rule will be active on Wednesdays, in increasing - // order from 00:00-24:00. If this parameter is omitted, the rule will be - // deactivated on Wednesdays. - Wed param.Field[string] `json:"wed"` -} - -func (r ZeroTrustGatewayRuleUpdateParamsSchedule) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustGatewayRuleUpdateResponseEnvelope struct { - Errors []ZeroTrustGatewayRuleUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayRuleUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayRuleUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayRuleUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayRuleUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayRuleUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayRuleUpdateResponseEnvelope] -type zeroTrustGatewayRuleUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayRuleUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayRuleUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayRuleUpdateResponseEnvelopeErrors] -type zeroTrustGatewayRuleUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayRuleUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayRuleUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayRuleUpdateResponseEnvelopeMessages] -type zeroTrustGatewayRuleUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayRuleUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayRuleUpdateResponseEnvelopeSuccessTrue ZeroTrustGatewayRuleUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayRuleListParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustGatewayRuleListResponseEnvelope struct { - Errors []ZeroTrustGatewayRuleListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayRuleListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustGatewayRuleListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustGatewayRuleListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustGatewayRuleListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustGatewayRuleListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayRuleListResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayRuleListResponseEnvelope] -type zeroTrustGatewayRuleListResponseEnvelopeJSON 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 *ZeroTrustGatewayRuleListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayRuleListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayRuleListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayRuleListResponseEnvelopeErrors] -type zeroTrustGatewayRuleListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayRuleListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayRuleListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayRuleListResponseEnvelopeMessages] -type zeroTrustGatewayRuleListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayRuleListResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayRuleListResponseEnvelopeSuccessTrue ZeroTrustGatewayRuleListResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayRuleListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustGatewayRuleListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustGatewayRuleListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayRuleListResponseEnvelopeResultInfo] -type zeroTrustGatewayRuleListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleDeleteParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustGatewayRuleDeleteResponseEnvelope struct { - Errors []ZeroTrustGatewayRuleDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayRuleDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayRuleDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayRuleDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayRuleDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayRuleDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayRuleDeleteResponseEnvelope] -type zeroTrustGatewayRuleDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayRuleDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayRuleDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayRuleDeleteResponseEnvelopeErrors] -type zeroTrustGatewayRuleDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayRuleDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayRuleDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustGatewayRuleDeleteResponseEnvelopeMessages] -type zeroTrustGatewayRuleDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayRuleDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayRuleDeleteResponseEnvelopeSuccessTrue ZeroTrustGatewayRuleDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustGatewayRuleGetParams struct { - AccountID param.Field[interface{}] `path:"account_id,required"` -} - -type ZeroTrustGatewayRuleGetResponseEnvelope struct { - Errors []ZeroTrustGatewayRuleGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustGatewayRuleGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustGatewayRuleGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustGatewayRuleGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustGatewayRuleGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustGatewayRuleGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustGatewayRuleGetResponseEnvelope] -type zeroTrustGatewayRuleGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayRuleGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustGatewayRuleGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustGatewayRuleGetResponseEnvelopeErrors] -type zeroTrustGatewayRuleGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustGatewayRuleGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustGatewayRuleGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustGatewayRuleGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustGatewayRuleGetResponseEnvelopeMessages] -type zeroTrustGatewayRuleGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustGatewayRuleGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustGatewayRuleGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustGatewayRuleGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustGatewayRuleGetResponseEnvelopeSuccessTrue ZeroTrustGatewayRuleGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustgatewayrule_test.go b/zerotrustgatewayrule_test.go deleted file mode 100644 index bd8c2297c3e..00000000000 --- a/zerotrustgatewayrule_test.go +++ /dev/null @@ -1,372 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustGatewayRuleNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Rules.New(context.TODO(), cloudflare.ZeroTrustGatewayRuleNewParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Action: cloudflare.F(cloudflare.ZeroTrustGatewayRuleNewParamsActionAllow), - Name: cloudflare.F("block bad websites"), - Description: cloudflare.F("Block bad websites based on their host name."), - DevicePosture: cloudflare.F("any(device_posture.checks.passed[*] in {\"1308749e-fcfb-4ebc-b051-fe022b632644\"})"), - Enabled: cloudflare.F(true), - Filters: cloudflare.F([]cloudflare.ZeroTrustGatewayRuleNewParamsFilter{cloudflare.ZeroTrustGatewayRuleNewParamsFilterHTTP}), - Identity: cloudflare.F("any(identity.groups.name[*] in {\"finance\"})"), - Precedence: cloudflare.F(int64(0)), - RuleSettings: cloudflare.F(cloudflare.ZeroTrustGatewayRuleNewParamsRuleSettings{ - AddHeaders: cloudflare.F[any](map[string]interface{}{ - "My-Next-Header": map[string]interface{}{ - "0": "foo", - "1": "bar", - }, - "X-Custom-Header-Name": map[string]interface{}{ - "0": "somecustomvalue", - }, - }), - AllowChildBypass: cloudflare.F(false), - AuditSSH: cloudflare.F(cloudflare.ZeroTrustGatewayRuleNewParamsRuleSettingsAuditSSH{ - CommandLogging: cloudflare.F(false), - }), - BisoAdminControls: cloudflare.F(cloudflare.ZeroTrustGatewayRuleNewParamsRuleSettingsBisoAdminControls{ - Dcp: cloudflare.F(false), - Dd: cloudflare.F(false), - Dk: cloudflare.F(false), - Dp: cloudflare.F(false), - Du: cloudflare.F(false), - }), - BlockPageEnabled: cloudflare.F(true), - BlockReason: cloudflare.F("This website is a security risk"), - BypassParentRule: cloudflare.F(false), - CheckSession: cloudflare.F(cloudflare.ZeroTrustGatewayRuleNewParamsRuleSettingsCheckSession{ - Duration: cloudflare.F("300s"), - Enforce: cloudflare.F(true), - }), - DNSResolvers: cloudflare.F(cloudflare.ZeroTrustGatewayRuleNewParamsRuleSettingsDNSResolvers{ - IPV4: cloudflare.F([]cloudflare.ZeroTrustGatewayRuleNewParamsRuleSettingsDNSResolversIPV4{{ - IP: cloudflare.F("2001:DB8::/64"), - Port: cloudflare.F(int64(5053)), - RouteThroughPrivateNetwork: cloudflare.F(true), - VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), - }, { - IP: cloudflare.F("2001:DB8::/64"), - Port: cloudflare.F(int64(5053)), - RouteThroughPrivateNetwork: cloudflare.F(true), - VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), - }, { - IP: cloudflare.F("2001:DB8::/64"), - Port: cloudflare.F(int64(5053)), - RouteThroughPrivateNetwork: cloudflare.F(true), - VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), - }}), - IPV6: cloudflare.F([]cloudflare.ZeroTrustGatewayRuleNewParamsRuleSettingsDNSResolversIPV6{{ - IP: cloudflare.F("2001:DB8::/64"), - Port: cloudflare.F(int64(5053)), - RouteThroughPrivateNetwork: cloudflare.F(true), - VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), - }, { - IP: cloudflare.F("2001:DB8::/64"), - Port: cloudflare.F(int64(5053)), - RouteThroughPrivateNetwork: cloudflare.F(true), - VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), - }, { - IP: cloudflare.F("2001:DB8::/64"), - Port: cloudflare.F(int64(5053)), - RouteThroughPrivateNetwork: cloudflare.F(true), - VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), - }}), - }), - Egress: cloudflare.F(cloudflare.ZeroTrustGatewayRuleNewParamsRuleSettingsEgress{ - IPV4: cloudflare.F("192.0.2.2"), - IPV4Fallback: cloudflare.F("192.0.2.3"), - IPV6: cloudflare.F("2001:DB8::/64"), - }), - InsecureDisableDNSSECValidation: cloudflare.F(false), - IPCategories: cloudflare.F(true), - IPIndicatorFeeds: cloudflare.F(true), - L4override: cloudflare.F(cloudflare.ZeroTrustGatewayRuleNewParamsRuleSettingsL4override{ - IP: cloudflare.F("1.1.1.1"), - Port: cloudflare.F(int64(0)), - }), - NotificationSettings: cloudflare.F(cloudflare.ZeroTrustGatewayRuleNewParamsRuleSettingsNotificationSettings{ - Enabled: cloudflare.F(true), - Msg: cloudflare.F("string"), - SupportURL: cloudflare.F("string"), - }), - OverrideHost: cloudflare.F("example.com"), - OverrideIPs: cloudflare.F([]string{"1.1.1.1", "2.2.2.2"}), - PayloadLog: cloudflare.F(cloudflare.ZeroTrustGatewayRuleNewParamsRuleSettingsPayloadLog{ - Enabled: cloudflare.F(true), - }), - ResolveDNSThroughCloudflare: cloudflare.F(true), - UntrustedCert: cloudflare.F(cloudflare.ZeroTrustGatewayRuleNewParamsRuleSettingsUntrustedCert{ - Action: cloudflare.F(cloudflare.ZeroTrustGatewayRuleNewParamsRuleSettingsUntrustedCertActionError), - }), - }), - Schedule: cloudflare.F(cloudflare.ZeroTrustGatewayRuleNewParamsSchedule{ - Fri: cloudflare.F("08:00-12:30,13:30-17:00"), - Mon: cloudflare.F("08:00-12:30,13:30-17:00"), - Sat: cloudflare.F("08:00-12:30,13:30-17:00"), - Sun: cloudflare.F("08:00-12:30,13:30-17:00"), - Thu: cloudflare.F("08:00-12:30,13:30-17:00"), - TimeZone: cloudflare.F("America/New York"), - Tue: cloudflare.F("08:00-12:30,13:30-17:00"), - Wed: cloudflare.F("08:00-12:30,13:30-17:00"), - }), - Traffic: cloudflare.F("http.request.uri matches \".*a/partial/uri.*\" and http.request.host in $01302951-49f9-47c9-a400-0297e60b6a10"), - }) - 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 TestZeroTrustGatewayRuleUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Rules.Update( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustGatewayRuleUpdateParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - Action: cloudflare.F(cloudflare.ZeroTrustGatewayRuleUpdateParamsActionAllow), - Name: cloudflare.F("block bad websites"), - Description: cloudflare.F("Block bad websites based on their host name."), - DevicePosture: cloudflare.F("any(device_posture.checks.passed[*] in {\"1308749e-fcfb-4ebc-b051-fe022b632644\"})"), - Enabled: cloudflare.F(true), - Filters: cloudflare.F([]cloudflare.ZeroTrustGatewayRuleUpdateParamsFilter{cloudflare.ZeroTrustGatewayRuleUpdateParamsFilterHTTP}), - Identity: cloudflare.F("any(identity.groups.name[*] in {\"finance\"})"), - Precedence: cloudflare.F(int64(0)), - RuleSettings: cloudflare.F(cloudflare.ZeroTrustGatewayRuleUpdateParamsRuleSettings{ - AddHeaders: cloudflare.F[any](map[string]interface{}{ - "My-Next-Header": map[string]interface{}{ - "0": "foo", - "1": "bar", - }, - "X-Custom-Header-Name": map[string]interface{}{ - "0": "somecustomvalue", - }, - }), - AllowChildBypass: cloudflare.F(false), - AuditSSH: cloudflare.F(cloudflare.ZeroTrustGatewayRuleUpdateParamsRuleSettingsAuditSSH{ - CommandLogging: cloudflare.F(false), - }), - BisoAdminControls: cloudflare.F(cloudflare.ZeroTrustGatewayRuleUpdateParamsRuleSettingsBisoAdminControls{ - Dcp: cloudflare.F(false), - Dd: cloudflare.F(false), - Dk: cloudflare.F(false), - Dp: cloudflare.F(false), - Du: cloudflare.F(false), - }), - BlockPageEnabled: cloudflare.F(true), - BlockReason: cloudflare.F("This website is a security risk"), - BypassParentRule: cloudflare.F(false), - CheckSession: cloudflare.F(cloudflare.ZeroTrustGatewayRuleUpdateParamsRuleSettingsCheckSession{ - Duration: cloudflare.F("300s"), - Enforce: cloudflare.F(true), - }), - DNSResolvers: cloudflare.F(cloudflare.ZeroTrustGatewayRuleUpdateParamsRuleSettingsDNSResolvers{ - IPV4: cloudflare.F([]cloudflare.ZeroTrustGatewayRuleUpdateParamsRuleSettingsDNSResolversIPV4{{ - IP: cloudflare.F("2001:DB8::/64"), - Port: cloudflare.F(int64(5053)), - RouteThroughPrivateNetwork: cloudflare.F(true), - VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), - }, { - IP: cloudflare.F("2001:DB8::/64"), - Port: cloudflare.F(int64(5053)), - RouteThroughPrivateNetwork: cloudflare.F(true), - VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), - }, { - IP: cloudflare.F("2001:DB8::/64"), - Port: cloudflare.F(int64(5053)), - RouteThroughPrivateNetwork: cloudflare.F(true), - VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), - }}), - IPV6: cloudflare.F([]cloudflare.ZeroTrustGatewayRuleUpdateParamsRuleSettingsDNSResolversIPV6{{ - IP: cloudflare.F("2001:DB8::/64"), - Port: cloudflare.F(int64(5053)), - RouteThroughPrivateNetwork: cloudflare.F(true), - VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), - }, { - IP: cloudflare.F("2001:DB8::/64"), - Port: cloudflare.F(int64(5053)), - RouteThroughPrivateNetwork: cloudflare.F(true), - VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), - }, { - IP: cloudflare.F("2001:DB8::/64"), - Port: cloudflare.F(int64(5053)), - RouteThroughPrivateNetwork: cloudflare.F(true), - VnetID: cloudflare.F("f174e90a-fafe-4643-bbbc-4a0ed4fc8415"), - }}), - }), - Egress: cloudflare.F(cloudflare.ZeroTrustGatewayRuleUpdateParamsRuleSettingsEgress{ - IPV4: cloudflare.F("192.0.2.2"), - IPV4Fallback: cloudflare.F("192.0.2.3"), - IPV6: cloudflare.F("2001:DB8::/64"), - }), - InsecureDisableDNSSECValidation: cloudflare.F(false), - IPCategories: cloudflare.F(true), - IPIndicatorFeeds: cloudflare.F(true), - L4override: cloudflare.F(cloudflare.ZeroTrustGatewayRuleUpdateParamsRuleSettingsL4override{ - IP: cloudflare.F("1.1.1.1"), - Port: cloudflare.F(int64(0)), - }), - NotificationSettings: cloudflare.F(cloudflare.ZeroTrustGatewayRuleUpdateParamsRuleSettingsNotificationSettings{ - Enabled: cloudflare.F(true), - Msg: cloudflare.F("string"), - SupportURL: cloudflare.F("string"), - }), - OverrideHost: cloudflare.F("example.com"), - OverrideIPs: cloudflare.F([]string{"1.1.1.1", "2.2.2.2"}), - PayloadLog: cloudflare.F(cloudflare.ZeroTrustGatewayRuleUpdateParamsRuleSettingsPayloadLog{ - Enabled: cloudflare.F(true), - }), - ResolveDNSThroughCloudflare: cloudflare.F(true), - UntrustedCert: cloudflare.F(cloudflare.ZeroTrustGatewayRuleUpdateParamsRuleSettingsUntrustedCert{ - Action: cloudflare.F(cloudflare.ZeroTrustGatewayRuleUpdateParamsRuleSettingsUntrustedCertActionError), - }), - }), - Schedule: cloudflare.F(cloudflare.ZeroTrustGatewayRuleUpdateParamsSchedule{ - Fri: cloudflare.F("08:00-12:30,13:30-17:00"), - Mon: cloudflare.F("08:00-12:30,13:30-17:00"), - Sat: cloudflare.F("08:00-12:30,13:30-17:00"), - Sun: cloudflare.F("08:00-12:30,13:30-17:00"), - Thu: cloudflare.F("08:00-12:30,13:30-17:00"), - TimeZone: cloudflare.F("America/New York"), - Tue: cloudflare.F("08:00-12:30,13:30-17:00"), - Wed: cloudflare.F("08:00-12:30,13:30-17:00"), - }), - Traffic: cloudflare.F("http.request.uri matches \".*a/partial/uri.*\" and http.request.host in $01302951-49f9-47c9-a400-0297e60b6a10"), - }, - ) - 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 TestZeroTrustGatewayRuleList(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Rules.List(context.TODO(), cloudflare.ZeroTrustGatewayRuleListParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }) - 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 TestZeroTrustGatewayRuleDelete(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Rules.Delete( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustGatewayRuleDeleteParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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 TestZeroTrustGatewayRuleGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Gateway.Rules.Get( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustGatewayRuleGetParams{ - AccountID: cloudflare.F[any]("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrustidentityprovider.go b/zerotrustidentityprovider.go deleted file mode 100644 index e34101c1658..00000000000 --- a/zerotrustidentityprovider.go +++ /dev/null @@ -1,9190 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustIdentityProviderService 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 -// [NewZeroTrustIdentityProviderService] method instead. -type ZeroTrustIdentityProviderService struct { - Options []option.RequestOption -} - -// NewZeroTrustIdentityProviderService 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 NewZeroTrustIdentityProviderService(opts ...option.RequestOption) (r *ZeroTrustIdentityProviderService) { - r = &ZeroTrustIdentityProviderService{} - r.Options = opts - return -} - -// Adds a new identity provider to Access. -func (r *ZeroTrustIdentityProviderService) New(ctx context.Context, params ZeroTrustIdentityProviderNewParams, opts ...option.RequestOption) (res *ZeroTrustIdentityProviderNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustIdentityProviderNewResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/access/identity_providers", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates a configured identity provider. -func (r *ZeroTrustIdentityProviderService) Update(ctx context.Context, uuid string, params ZeroTrustIdentityProviderUpdateParams, opts ...option.RequestOption) (res *ZeroTrustIdentityProviderUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustIdentityProviderUpdateResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/access/identity_providers/%s", accountOrZone, accountOrZoneID, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists all configured identity providers. -func (r *ZeroTrustIdentityProviderService) List(ctx context.Context, query ZeroTrustIdentityProviderListParams, opts ...option.RequestOption) (res *[]ZeroTrustIdentityProviderListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustIdentityProviderListResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/access/identity_providers", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes an identity provider from Access. -func (r *ZeroTrustIdentityProviderService) Delete(ctx context.Context, uuid string, body ZeroTrustIdentityProviderDeleteParams, opts ...option.RequestOption) (res *ZeroTrustIdentityProviderDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustIdentityProviderDeleteResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if body.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = body.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = body.ZoneID - } - path := fmt.Sprintf("%s/%s/access/identity_providers/%s", accountOrZone, accountOrZoneID, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a configured identity provider. -func (r *ZeroTrustIdentityProviderService) Get(ctx context.Context, uuid string, query ZeroTrustIdentityProviderGetParams, opts ...option.RequestOption) (res *ZeroTrustIdentityProviderGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustIdentityProviderGetResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/access/identity_providers/%s", accountOrZone, accountOrZoneID, uuid) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [ZeroTrustIdentityProviderNewResponseAccessAzureAd], -// [ZeroTrustIdentityProviderNewResponseAccessCentrify], -// [ZeroTrustIdentityProviderNewResponseAccessFacebook], -// [ZeroTrustIdentityProviderNewResponseAccessGitHub], -// [ZeroTrustIdentityProviderNewResponseAccessGoogle], -// [ZeroTrustIdentityProviderNewResponseAccessGoogleApps], -// [ZeroTrustIdentityProviderNewResponseAccessLinkedin], -// [ZeroTrustIdentityProviderNewResponseAccessOidc], -// [ZeroTrustIdentityProviderNewResponseAccessOkta], -// [ZeroTrustIdentityProviderNewResponseAccessOnelogin], -// [ZeroTrustIdentityProviderNewResponseAccessPingone], -// [ZeroTrustIdentityProviderNewResponseAccessSaml], -// [ZeroTrustIdentityProviderNewResponseAccessYandex] or -// [ZeroTrustIdentityProviderNewResponseAccessOnetimepin]. -type ZeroTrustIdentityProviderNewResponse interface { - implementsZeroTrustIdentityProviderNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustIdentityProviderNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderNewResponseAccessAzureAd{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderNewResponseAccessCentrify{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderNewResponseAccessFacebook{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderNewResponseAccessGitHub{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderNewResponseAccessGoogle{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderNewResponseAccessGoogleApps{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderNewResponseAccessLinkedin{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderNewResponseAccessOidc{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderNewResponseAccessOkta{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderNewResponseAccessOnelogin{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderNewResponseAccessPingone{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderNewResponseAccessSaml{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderNewResponseAccessYandex{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderNewResponseAccessOnetimepin{}), - }, - ) -} - -type ZeroTrustIdentityProviderNewResponseAccessAzureAd struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderNewResponseAccessAzureAdConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderNewResponseAccessAzureAdType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderNewResponseAccessAzureAdScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderNewResponseAccessAzureAdJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessAzureAdJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderNewResponseAccessAzureAd] -type zeroTrustIdentityProviderNewResponseAccessAzureAdJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessAzureAdJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderNewResponseAccessAzureAd) implementsZeroTrustIdentityProviderNewResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessAzureAdConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // Should Cloudflare try to load authentication contexts from your account - ConditionalAccessEnabled bool `json:"conditional_access_enabled"` - // Your Azure directory uuid - DirectoryID string `json:"directory_id"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Should Cloudflare try to load groups from your account - SupportGroups bool `json:"support_groups"` - JSON zeroTrustIdentityProviderNewResponseAccessAzureAdConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessAzureAdConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessAzureAdConfig] -type zeroTrustIdentityProviderNewResponseAccessAzureAdConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - ConditionalAccessEnabled apijson.Field - DirectoryID apijson.Field - EmailClaimName apijson.Field - SupportGroups apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessAzureAdConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessAzureAdConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessAzureAdType string - -const ( - ZeroTrustIdentityProviderNewResponseAccessAzureAdTypeOnetimepin ZeroTrustIdentityProviderNewResponseAccessAzureAdType = "onetimepin" - ZeroTrustIdentityProviderNewResponseAccessAzureAdTypeAzureAd ZeroTrustIdentityProviderNewResponseAccessAzureAdType = "azureAD" - ZeroTrustIdentityProviderNewResponseAccessAzureAdTypeSaml ZeroTrustIdentityProviderNewResponseAccessAzureAdType = "saml" - ZeroTrustIdentityProviderNewResponseAccessAzureAdTypeCentrify ZeroTrustIdentityProviderNewResponseAccessAzureAdType = "centrify" - ZeroTrustIdentityProviderNewResponseAccessAzureAdTypeFacebook ZeroTrustIdentityProviderNewResponseAccessAzureAdType = "facebook" - ZeroTrustIdentityProviderNewResponseAccessAzureAdTypeGitHub ZeroTrustIdentityProviderNewResponseAccessAzureAdType = "github" - ZeroTrustIdentityProviderNewResponseAccessAzureAdTypeGoogleApps ZeroTrustIdentityProviderNewResponseAccessAzureAdType = "google-apps" - ZeroTrustIdentityProviderNewResponseAccessAzureAdTypeGoogle ZeroTrustIdentityProviderNewResponseAccessAzureAdType = "google" - ZeroTrustIdentityProviderNewResponseAccessAzureAdTypeLinkedin ZeroTrustIdentityProviderNewResponseAccessAzureAdType = "linkedin" - ZeroTrustIdentityProviderNewResponseAccessAzureAdTypeOidc ZeroTrustIdentityProviderNewResponseAccessAzureAdType = "oidc" - ZeroTrustIdentityProviderNewResponseAccessAzureAdTypeOkta ZeroTrustIdentityProviderNewResponseAccessAzureAdType = "okta" - ZeroTrustIdentityProviderNewResponseAccessAzureAdTypeOnelogin ZeroTrustIdentityProviderNewResponseAccessAzureAdType = "onelogin" - ZeroTrustIdentityProviderNewResponseAccessAzureAdTypePingone ZeroTrustIdentityProviderNewResponseAccessAzureAdType = "pingone" - ZeroTrustIdentityProviderNewResponseAccessAzureAdTypeYandex ZeroTrustIdentityProviderNewResponseAccessAzureAdType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderNewResponseAccessAzureAdScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderNewResponseAccessAzureAdScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessAzureAdScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessAzureAdScimConfig] -type zeroTrustIdentityProviderNewResponseAccessAzureAdScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessAzureAdScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessAzureAdScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderNewResponseAccessCentrify struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderNewResponseAccessCentrifyConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderNewResponseAccessCentrifyType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderNewResponseAccessCentrifyScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderNewResponseAccessCentrifyJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessCentrifyJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderNewResponseAccessCentrify] -type zeroTrustIdentityProviderNewResponseAccessCentrifyJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessCentrify) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessCentrifyJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderNewResponseAccessCentrify) implementsZeroTrustIdentityProviderNewResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessCentrifyConfig struct { - // Your centrify account url - CentrifyAccount string `json:"centrify_account"` - // Your centrify app id - CentrifyAppID string `json:"centrify_app_id"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - JSON zeroTrustIdentityProviderNewResponseAccessCentrifyConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessCentrifyConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessCentrifyConfig] -type zeroTrustIdentityProviderNewResponseAccessCentrifyConfigJSON struct { - CentrifyAccount apijson.Field - CentrifyAppID apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessCentrifyConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessCentrifyConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessCentrifyType string - -const ( - ZeroTrustIdentityProviderNewResponseAccessCentrifyTypeOnetimepin ZeroTrustIdentityProviderNewResponseAccessCentrifyType = "onetimepin" - ZeroTrustIdentityProviderNewResponseAccessCentrifyTypeAzureAd ZeroTrustIdentityProviderNewResponseAccessCentrifyType = "azureAD" - ZeroTrustIdentityProviderNewResponseAccessCentrifyTypeSaml ZeroTrustIdentityProviderNewResponseAccessCentrifyType = "saml" - ZeroTrustIdentityProviderNewResponseAccessCentrifyTypeCentrify ZeroTrustIdentityProviderNewResponseAccessCentrifyType = "centrify" - ZeroTrustIdentityProviderNewResponseAccessCentrifyTypeFacebook ZeroTrustIdentityProviderNewResponseAccessCentrifyType = "facebook" - ZeroTrustIdentityProviderNewResponseAccessCentrifyTypeGitHub ZeroTrustIdentityProviderNewResponseAccessCentrifyType = "github" - ZeroTrustIdentityProviderNewResponseAccessCentrifyTypeGoogleApps ZeroTrustIdentityProviderNewResponseAccessCentrifyType = "google-apps" - ZeroTrustIdentityProviderNewResponseAccessCentrifyTypeGoogle ZeroTrustIdentityProviderNewResponseAccessCentrifyType = "google" - ZeroTrustIdentityProviderNewResponseAccessCentrifyTypeLinkedin ZeroTrustIdentityProviderNewResponseAccessCentrifyType = "linkedin" - ZeroTrustIdentityProviderNewResponseAccessCentrifyTypeOidc ZeroTrustIdentityProviderNewResponseAccessCentrifyType = "oidc" - ZeroTrustIdentityProviderNewResponseAccessCentrifyTypeOkta ZeroTrustIdentityProviderNewResponseAccessCentrifyType = "okta" - ZeroTrustIdentityProviderNewResponseAccessCentrifyTypeOnelogin ZeroTrustIdentityProviderNewResponseAccessCentrifyType = "onelogin" - ZeroTrustIdentityProviderNewResponseAccessCentrifyTypePingone ZeroTrustIdentityProviderNewResponseAccessCentrifyType = "pingone" - ZeroTrustIdentityProviderNewResponseAccessCentrifyTypeYandex ZeroTrustIdentityProviderNewResponseAccessCentrifyType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderNewResponseAccessCentrifyScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderNewResponseAccessCentrifyScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessCentrifyScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessCentrifyScimConfig] -type zeroTrustIdentityProviderNewResponseAccessCentrifyScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessCentrifyScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessCentrifyScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderNewResponseAccessFacebook struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderNewResponseAccessFacebookConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderNewResponseAccessFacebookType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderNewResponseAccessFacebookScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderNewResponseAccessFacebookJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessFacebookJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderNewResponseAccessFacebook] -type zeroTrustIdentityProviderNewResponseAccessFacebookJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessFacebook) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessFacebookJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderNewResponseAccessFacebook) implementsZeroTrustIdentityProviderNewResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessFacebookConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProviderNewResponseAccessFacebookConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessFacebookConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessFacebookConfig] -type zeroTrustIdentityProviderNewResponseAccessFacebookConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessFacebookConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessFacebookConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessFacebookType string - -const ( - ZeroTrustIdentityProviderNewResponseAccessFacebookTypeOnetimepin ZeroTrustIdentityProviderNewResponseAccessFacebookType = "onetimepin" - ZeroTrustIdentityProviderNewResponseAccessFacebookTypeAzureAd ZeroTrustIdentityProviderNewResponseAccessFacebookType = "azureAD" - ZeroTrustIdentityProviderNewResponseAccessFacebookTypeSaml ZeroTrustIdentityProviderNewResponseAccessFacebookType = "saml" - ZeroTrustIdentityProviderNewResponseAccessFacebookTypeCentrify ZeroTrustIdentityProviderNewResponseAccessFacebookType = "centrify" - ZeroTrustIdentityProviderNewResponseAccessFacebookTypeFacebook ZeroTrustIdentityProviderNewResponseAccessFacebookType = "facebook" - ZeroTrustIdentityProviderNewResponseAccessFacebookTypeGitHub ZeroTrustIdentityProviderNewResponseAccessFacebookType = "github" - ZeroTrustIdentityProviderNewResponseAccessFacebookTypeGoogleApps ZeroTrustIdentityProviderNewResponseAccessFacebookType = "google-apps" - ZeroTrustIdentityProviderNewResponseAccessFacebookTypeGoogle ZeroTrustIdentityProviderNewResponseAccessFacebookType = "google" - ZeroTrustIdentityProviderNewResponseAccessFacebookTypeLinkedin ZeroTrustIdentityProviderNewResponseAccessFacebookType = "linkedin" - ZeroTrustIdentityProviderNewResponseAccessFacebookTypeOidc ZeroTrustIdentityProviderNewResponseAccessFacebookType = "oidc" - ZeroTrustIdentityProviderNewResponseAccessFacebookTypeOkta ZeroTrustIdentityProviderNewResponseAccessFacebookType = "okta" - ZeroTrustIdentityProviderNewResponseAccessFacebookTypeOnelogin ZeroTrustIdentityProviderNewResponseAccessFacebookType = "onelogin" - ZeroTrustIdentityProviderNewResponseAccessFacebookTypePingone ZeroTrustIdentityProviderNewResponseAccessFacebookType = "pingone" - ZeroTrustIdentityProviderNewResponseAccessFacebookTypeYandex ZeroTrustIdentityProviderNewResponseAccessFacebookType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderNewResponseAccessFacebookScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderNewResponseAccessFacebookScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessFacebookScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessFacebookScimConfig] -type zeroTrustIdentityProviderNewResponseAccessFacebookScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessFacebookScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessFacebookScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderNewResponseAccessGitHub struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderNewResponseAccessGitHubConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderNewResponseAccessGitHubType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderNewResponseAccessGitHubScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderNewResponseAccessGitHubJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessGitHubJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderNewResponseAccessGitHub] -type zeroTrustIdentityProviderNewResponseAccessGitHubJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessGitHub) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessGitHubJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderNewResponseAccessGitHub) implementsZeroTrustIdentityProviderNewResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessGitHubConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProviderNewResponseAccessGitHubConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessGitHubConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderNewResponseAccessGitHubConfig] -type zeroTrustIdentityProviderNewResponseAccessGitHubConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessGitHubConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessGitHubConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessGitHubType string - -const ( - ZeroTrustIdentityProviderNewResponseAccessGitHubTypeOnetimepin ZeroTrustIdentityProviderNewResponseAccessGitHubType = "onetimepin" - ZeroTrustIdentityProviderNewResponseAccessGitHubTypeAzureAd ZeroTrustIdentityProviderNewResponseAccessGitHubType = "azureAD" - ZeroTrustIdentityProviderNewResponseAccessGitHubTypeSaml ZeroTrustIdentityProviderNewResponseAccessGitHubType = "saml" - ZeroTrustIdentityProviderNewResponseAccessGitHubTypeCentrify ZeroTrustIdentityProviderNewResponseAccessGitHubType = "centrify" - ZeroTrustIdentityProviderNewResponseAccessGitHubTypeFacebook ZeroTrustIdentityProviderNewResponseAccessGitHubType = "facebook" - ZeroTrustIdentityProviderNewResponseAccessGitHubTypeGitHub ZeroTrustIdentityProviderNewResponseAccessGitHubType = "github" - ZeroTrustIdentityProviderNewResponseAccessGitHubTypeGoogleApps ZeroTrustIdentityProviderNewResponseAccessGitHubType = "google-apps" - ZeroTrustIdentityProviderNewResponseAccessGitHubTypeGoogle ZeroTrustIdentityProviderNewResponseAccessGitHubType = "google" - ZeroTrustIdentityProviderNewResponseAccessGitHubTypeLinkedin ZeroTrustIdentityProviderNewResponseAccessGitHubType = "linkedin" - ZeroTrustIdentityProviderNewResponseAccessGitHubTypeOidc ZeroTrustIdentityProviderNewResponseAccessGitHubType = "oidc" - ZeroTrustIdentityProviderNewResponseAccessGitHubTypeOkta ZeroTrustIdentityProviderNewResponseAccessGitHubType = "okta" - ZeroTrustIdentityProviderNewResponseAccessGitHubTypeOnelogin ZeroTrustIdentityProviderNewResponseAccessGitHubType = "onelogin" - ZeroTrustIdentityProviderNewResponseAccessGitHubTypePingone ZeroTrustIdentityProviderNewResponseAccessGitHubType = "pingone" - ZeroTrustIdentityProviderNewResponseAccessGitHubTypeYandex ZeroTrustIdentityProviderNewResponseAccessGitHubType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderNewResponseAccessGitHubScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderNewResponseAccessGitHubScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessGitHubScimConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessGitHubScimConfig] -type zeroTrustIdentityProviderNewResponseAccessGitHubScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessGitHubScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessGitHubScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderNewResponseAccessGoogle struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderNewResponseAccessGoogleConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderNewResponseAccessGoogleType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderNewResponseAccessGoogleScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderNewResponseAccessGoogleJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessGoogleJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderNewResponseAccessGoogle] -type zeroTrustIdentityProviderNewResponseAccessGoogleJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessGoogle) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessGoogleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderNewResponseAccessGoogle) implementsZeroTrustIdentityProviderNewResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessGoogleConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - JSON zeroTrustIdentityProviderNewResponseAccessGoogleConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessGoogleConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderNewResponseAccessGoogleConfig] -type zeroTrustIdentityProviderNewResponseAccessGoogleConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessGoogleConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessGoogleConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessGoogleType string - -const ( - ZeroTrustIdentityProviderNewResponseAccessGoogleTypeOnetimepin ZeroTrustIdentityProviderNewResponseAccessGoogleType = "onetimepin" - ZeroTrustIdentityProviderNewResponseAccessGoogleTypeAzureAd ZeroTrustIdentityProviderNewResponseAccessGoogleType = "azureAD" - ZeroTrustIdentityProviderNewResponseAccessGoogleTypeSaml ZeroTrustIdentityProviderNewResponseAccessGoogleType = "saml" - ZeroTrustIdentityProviderNewResponseAccessGoogleTypeCentrify ZeroTrustIdentityProviderNewResponseAccessGoogleType = "centrify" - ZeroTrustIdentityProviderNewResponseAccessGoogleTypeFacebook ZeroTrustIdentityProviderNewResponseAccessGoogleType = "facebook" - ZeroTrustIdentityProviderNewResponseAccessGoogleTypeGitHub ZeroTrustIdentityProviderNewResponseAccessGoogleType = "github" - ZeroTrustIdentityProviderNewResponseAccessGoogleTypeGoogleApps ZeroTrustIdentityProviderNewResponseAccessGoogleType = "google-apps" - ZeroTrustIdentityProviderNewResponseAccessGoogleTypeGoogle ZeroTrustIdentityProviderNewResponseAccessGoogleType = "google" - ZeroTrustIdentityProviderNewResponseAccessGoogleTypeLinkedin ZeroTrustIdentityProviderNewResponseAccessGoogleType = "linkedin" - ZeroTrustIdentityProviderNewResponseAccessGoogleTypeOidc ZeroTrustIdentityProviderNewResponseAccessGoogleType = "oidc" - ZeroTrustIdentityProviderNewResponseAccessGoogleTypeOkta ZeroTrustIdentityProviderNewResponseAccessGoogleType = "okta" - ZeroTrustIdentityProviderNewResponseAccessGoogleTypeOnelogin ZeroTrustIdentityProviderNewResponseAccessGoogleType = "onelogin" - ZeroTrustIdentityProviderNewResponseAccessGoogleTypePingone ZeroTrustIdentityProviderNewResponseAccessGoogleType = "pingone" - ZeroTrustIdentityProviderNewResponseAccessGoogleTypeYandex ZeroTrustIdentityProviderNewResponseAccessGoogleType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderNewResponseAccessGoogleScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderNewResponseAccessGoogleScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessGoogleScimConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessGoogleScimConfig] -type zeroTrustIdentityProviderNewResponseAccessGoogleScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessGoogleScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessGoogleScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderNewResponseAccessGoogleApps struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderNewResponseAccessGoogleAppsConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderNewResponseAccessGoogleAppsType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderNewResponseAccessGoogleAppsScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderNewResponseAccessGoogleAppsJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessGoogleAppsJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderNewResponseAccessGoogleApps] -type zeroTrustIdentityProviderNewResponseAccessGoogleAppsJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessGoogleApps) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessGoogleAppsJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderNewResponseAccessGoogleApps) implementsZeroTrustIdentityProviderNewResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessGoogleAppsConfig struct { - // Your companies TLD - AppsDomain string `json:"apps_domain"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - JSON zeroTrustIdentityProviderNewResponseAccessGoogleAppsConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessGoogleAppsConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessGoogleAppsConfig] -type zeroTrustIdentityProviderNewResponseAccessGoogleAppsConfigJSON struct { - AppsDomain apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessGoogleAppsConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessGoogleAppsConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessGoogleAppsType string - -const ( - ZeroTrustIdentityProviderNewResponseAccessGoogleAppsTypeOnetimepin ZeroTrustIdentityProviderNewResponseAccessGoogleAppsType = "onetimepin" - ZeroTrustIdentityProviderNewResponseAccessGoogleAppsTypeAzureAd ZeroTrustIdentityProviderNewResponseAccessGoogleAppsType = "azureAD" - ZeroTrustIdentityProviderNewResponseAccessGoogleAppsTypeSaml ZeroTrustIdentityProviderNewResponseAccessGoogleAppsType = "saml" - ZeroTrustIdentityProviderNewResponseAccessGoogleAppsTypeCentrify ZeroTrustIdentityProviderNewResponseAccessGoogleAppsType = "centrify" - ZeroTrustIdentityProviderNewResponseAccessGoogleAppsTypeFacebook ZeroTrustIdentityProviderNewResponseAccessGoogleAppsType = "facebook" - ZeroTrustIdentityProviderNewResponseAccessGoogleAppsTypeGitHub ZeroTrustIdentityProviderNewResponseAccessGoogleAppsType = "github" - ZeroTrustIdentityProviderNewResponseAccessGoogleAppsTypeGoogleApps ZeroTrustIdentityProviderNewResponseAccessGoogleAppsType = "google-apps" - ZeroTrustIdentityProviderNewResponseAccessGoogleAppsTypeGoogle ZeroTrustIdentityProviderNewResponseAccessGoogleAppsType = "google" - ZeroTrustIdentityProviderNewResponseAccessGoogleAppsTypeLinkedin ZeroTrustIdentityProviderNewResponseAccessGoogleAppsType = "linkedin" - ZeroTrustIdentityProviderNewResponseAccessGoogleAppsTypeOidc ZeroTrustIdentityProviderNewResponseAccessGoogleAppsType = "oidc" - ZeroTrustIdentityProviderNewResponseAccessGoogleAppsTypeOkta ZeroTrustIdentityProviderNewResponseAccessGoogleAppsType = "okta" - ZeroTrustIdentityProviderNewResponseAccessGoogleAppsTypeOnelogin ZeroTrustIdentityProviderNewResponseAccessGoogleAppsType = "onelogin" - ZeroTrustIdentityProviderNewResponseAccessGoogleAppsTypePingone ZeroTrustIdentityProviderNewResponseAccessGoogleAppsType = "pingone" - ZeroTrustIdentityProviderNewResponseAccessGoogleAppsTypeYandex ZeroTrustIdentityProviderNewResponseAccessGoogleAppsType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderNewResponseAccessGoogleAppsScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderNewResponseAccessGoogleAppsScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessGoogleAppsScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessGoogleAppsScimConfig] -type zeroTrustIdentityProviderNewResponseAccessGoogleAppsScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessGoogleAppsScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessGoogleAppsScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderNewResponseAccessLinkedin struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderNewResponseAccessLinkedinConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderNewResponseAccessLinkedinType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderNewResponseAccessLinkedinScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderNewResponseAccessLinkedinJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessLinkedinJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderNewResponseAccessLinkedin] -type zeroTrustIdentityProviderNewResponseAccessLinkedinJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessLinkedin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessLinkedinJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderNewResponseAccessLinkedin) implementsZeroTrustIdentityProviderNewResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessLinkedinConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProviderNewResponseAccessLinkedinConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessLinkedinConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessLinkedinConfig] -type zeroTrustIdentityProviderNewResponseAccessLinkedinConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessLinkedinConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessLinkedinConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessLinkedinType string - -const ( - ZeroTrustIdentityProviderNewResponseAccessLinkedinTypeOnetimepin ZeroTrustIdentityProviderNewResponseAccessLinkedinType = "onetimepin" - ZeroTrustIdentityProviderNewResponseAccessLinkedinTypeAzureAd ZeroTrustIdentityProviderNewResponseAccessLinkedinType = "azureAD" - ZeroTrustIdentityProviderNewResponseAccessLinkedinTypeSaml ZeroTrustIdentityProviderNewResponseAccessLinkedinType = "saml" - ZeroTrustIdentityProviderNewResponseAccessLinkedinTypeCentrify ZeroTrustIdentityProviderNewResponseAccessLinkedinType = "centrify" - ZeroTrustIdentityProviderNewResponseAccessLinkedinTypeFacebook ZeroTrustIdentityProviderNewResponseAccessLinkedinType = "facebook" - ZeroTrustIdentityProviderNewResponseAccessLinkedinTypeGitHub ZeroTrustIdentityProviderNewResponseAccessLinkedinType = "github" - ZeroTrustIdentityProviderNewResponseAccessLinkedinTypeGoogleApps ZeroTrustIdentityProviderNewResponseAccessLinkedinType = "google-apps" - ZeroTrustIdentityProviderNewResponseAccessLinkedinTypeGoogle ZeroTrustIdentityProviderNewResponseAccessLinkedinType = "google" - ZeroTrustIdentityProviderNewResponseAccessLinkedinTypeLinkedin ZeroTrustIdentityProviderNewResponseAccessLinkedinType = "linkedin" - ZeroTrustIdentityProviderNewResponseAccessLinkedinTypeOidc ZeroTrustIdentityProviderNewResponseAccessLinkedinType = "oidc" - ZeroTrustIdentityProviderNewResponseAccessLinkedinTypeOkta ZeroTrustIdentityProviderNewResponseAccessLinkedinType = "okta" - ZeroTrustIdentityProviderNewResponseAccessLinkedinTypeOnelogin ZeroTrustIdentityProviderNewResponseAccessLinkedinType = "onelogin" - ZeroTrustIdentityProviderNewResponseAccessLinkedinTypePingone ZeroTrustIdentityProviderNewResponseAccessLinkedinType = "pingone" - ZeroTrustIdentityProviderNewResponseAccessLinkedinTypeYandex ZeroTrustIdentityProviderNewResponseAccessLinkedinType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderNewResponseAccessLinkedinScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderNewResponseAccessLinkedinScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessLinkedinScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessLinkedinScimConfig] -type zeroTrustIdentityProviderNewResponseAccessLinkedinScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessLinkedinScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessLinkedinScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderNewResponseAccessOidc struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderNewResponseAccessOidcConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderNewResponseAccessOidcType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderNewResponseAccessOidcScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderNewResponseAccessOidcJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessOidcJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderNewResponseAccessOidc] -type zeroTrustIdentityProviderNewResponseAccessOidcJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessOidc) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessOidcJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderNewResponseAccessOidc) implementsZeroTrustIdentityProviderNewResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessOidcConfig struct { - // The authorization_endpoint URL of your IdP - AuthURL string `json:"auth_url"` - // The jwks_uri endpoint of your IdP to allow the IdP keys to sign the tokens - CertsURL string `json:"certs_url"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // OAuth scopes - Scopes []string `json:"scopes"` - // The token_endpoint URL of your IdP - TokenURL string `json:"token_url"` - JSON zeroTrustIdentityProviderNewResponseAccessOidcConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessOidcConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderNewResponseAccessOidcConfig] -type zeroTrustIdentityProviderNewResponseAccessOidcConfigJSON struct { - AuthURL apijson.Field - CertsURL apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - Scopes apijson.Field - TokenURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessOidcConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessOidcConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessOidcType string - -const ( - ZeroTrustIdentityProviderNewResponseAccessOidcTypeOnetimepin ZeroTrustIdentityProviderNewResponseAccessOidcType = "onetimepin" - ZeroTrustIdentityProviderNewResponseAccessOidcTypeAzureAd ZeroTrustIdentityProviderNewResponseAccessOidcType = "azureAD" - ZeroTrustIdentityProviderNewResponseAccessOidcTypeSaml ZeroTrustIdentityProviderNewResponseAccessOidcType = "saml" - ZeroTrustIdentityProviderNewResponseAccessOidcTypeCentrify ZeroTrustIdentityProviderNewResponseAccessOidcType = "centrify" - ZeroTrustIdentityProviderNewResponseAccessOidcTypeFacebook ZeroTrustIdentityProviderNewResponseAccessOidcType = "facebook" - ZeroTrustIdentityProviderNewResponseAccessOidcTypeGitHub ZeroTrustIdentityProviderNewResponseAccessOidcType = "github" - ZeroTrustIdentityProviderNewResponseAccessOidcTypeGoogleApps ZeroTrustIdentityProviderNewResponseAccessOidcType = "google-apps" - ZeroTrustIdentityProviderNewResponseAccessOidcTypeGoogle ZeroTrustIdentityProviderNewResponseAccessOidcType = "google" - ZeroTrustIdentityProviderNewResponseAccessOidcTypeLinkedin ZeroTrustIdentityProviderNewResponseAccessOidcType = "linkedin" - ZeroTrustIdentityProviderNewResponseAccessOidcTypeOidc ZeroTrustIdentityProviderNewResponseAccessOidcType = "oidc" - ZeroTrustIdentityProviderNewResponseAccessOidcTypeOkta ZeroTrustIdentityProviderNewResponseAccessOidcType = "okta" - ZeroTrustIdentityProviderNewResponseAccessOidcTypeOnelogin ZeroTrustIdentityProviderNewResponseAccessOidcType = "onelogin" - ZeroTrustIdentityProviderNewResponseAccessOidcTypePingone ZeroTrustIdentityProviderNewResponseAccessOidcType = "pingone" - ZeroTrustIdentityProviderNewResponseAccessOidcTypeYandex ZeroTrustIdentityProviderNewResponseAccessOidcType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderNewResponseAccessOidcScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderNewResponseAccessOidcScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessOidcScimConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessOidcScimConfig] -type zeroTrustIdentityProviderNewResponseAccessOidcScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessOidcScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessOidcScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderNewResponseAccessOkta struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderNewResponseAccessOktaConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderNewResponseAccessOktaType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderNewResponseAccessOktaScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderNewResponseAccessOktaJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessOktaJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderNewResponseAccessOkta] -type zeroTrustIdentityProviderNewResponseAccessOktaJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessOktaJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderNewResponseAccessOkta) implementsZeroTrustIdentityProviderNewResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessOktaConfig struct { - // Your okta authorization server id - AuthorizationServerID string `json:"authorization_server_id"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Your okta account url - OktaAccount string `json:"okta_account"` - JSON zeroTrustIdentityProviderNewResponseAccessOktaConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessOktaConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderNewResponseAccessOktaConfig] -type zeroTrustIdentityProviderNewResponseAccessOktaConfigJSON struct { - AuthorizationServerID apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - OktaAccount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessOktaConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessOktaConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessOktaType string - -const ( - ZeroTrustIdentityProviderNewResponseAccessOktaTypeOnetimepin ZeroTrustIdentityProviderNewResponseAccessOktaType = "onetimepin" - ZeroTrustIdentityProviderNewResponseAccessOktaTypeAzureAd ZeroTrustIdentityProviderNewResponseAccessOktaType = "azureAD" - ZeroTrustIdentityProviderNewResponseAccessOktaTypeSaml ZeroTrustIdentityProviderNewResponseAccessOktaType = "saml" - ZeroTrustIdentityProviderNewResponseAccessOktaTypeCentrify ZeroTrustIdentityProviderNewResponseAccessOktaType = "centrify" - ZeroTrustIdentityProviderNewResponseAccessOktaTypeFacebook ZeroTrustIdentityProviderNewResponseAccessOktaType = "facebook" - ZeroTrustIdentityProviderNewResponseAccessOktaTypeGitHub ZeroTrustIdentityProviderNewResponseAccessOktaType = "github" - ZeroTrustIdentityProviderNewResponseAccessOktaTypeGoogleApps ZeroTrustIdentityProviderNewResponseAccessOktaType = "google-apps" - ZeroTrustIdentityProviderNewResponseAccessOktaTypeGoogle ZeroTrustIdentityProviderNewResponseAccessOktaType = "google" - ZeroTrustIdentityProviderNewResponseAccessOktaTypeLinkedin ZeroTrustIdentityProviderNewResponseAccessOktaType = "linkedin" - ZeroTrustIdentityProviderNewResponseAccessOktaTypeOidc ZeroTrustIdentityProviderNewResponseAccessOktaType = "oidc" - ZeroTrustIdentityProviderNewResponseAccessOktaTypeOkta ZeroTrustIdentityProviderNewResponseAccessOktaType = "okta" - ZeroTrustIdentityProviderNewResponseAccessOktaTypeOnelogin ZeroTrustIdentityProviderNewResponseAccessOktaType = "onelogin" - ZeroTrustIdentityProviderNewResponseAccessOktaTypePingone ZeroTrustIdentityProviderNewResponseAccessOktaType = "pingone" - ZeroTrustIdentityProviderNewResponseAccessOktaTypeYandex ZeroTrustIdentityProviderNewResponseAccessOktaType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderNewResponseAccessOktaScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderNewResponseAccessOktaScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessOktaScimConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessOktaScimConfig] -type zeroTrustIdentityProviderNewResponseAccessOktaScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessOktaScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessOktaScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderNewResponseAccessOnelogin struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderNewResponseAccessOneloginConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderNewResponseAccessOneloginType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderNewResponseAccessOneloginScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderNewResponseAccessOneloginJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessOneloginJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderNewResponseAccessOnelogin] -type zeroTrustIdentityProviderNewResponseAccessOneloginJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessOnelogin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessOneloginJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderNewResponseAccessOnelogin) implementsZeroTrustIdentityProviderNewResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessOneloginConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Your OneLogin account url - OneloginAccount string `json:"onelogin_account"` - JSON zeroTrustIdentityProviderNewResponseAccessOneloginConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessOneloginConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessOneloginConfig] -type zeroTrustIdentityProviderNewResponseAccessOneloginConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - OneloginAccount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessOneloginConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessOneloginConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessOneloginType string - -const ( - ZeroTrustIdentityProviderNewResponseAccessOneloginTypeOnetimepin ZeroTrustIdentityProviderNewResponseAccessOneloginType = "onetimepin" - ZeroTrustIdentityProviderNewResponseAccessOneloginTypeAzureAd ZeroTrustIdentityProviderNewResponseAccessOneloginType = "azureAD" - ZeroTrustIdentityProviderNewResponseAccessOneloginTypeSaml ZeroTrustIdentityProviderNewResponseAccessOneloginType = "saml" - ZeroTrustIdentityProviderNewResponseAccessOneloginTypeCentrify ZeroTrustIdentityProviderNewResponseAccessOneloginType = "centrify" - ZeroTrustIdentityProviderNewResponseAccessOneloginTypeFacebook ZeroTrustIdentityProviderNewResponseAccessOneloginType = "facebook" - ZeroTrustIdentityProviderNewResponseAccessOneloginTypeGitHub ZeroTrustIdentityProviderNewResponseAccessOneloginType = "github" - ZeroTrustIdentityProviderNewResponseAccessOneloginTypeGoogleApps ZeroTrustIdentityProviderNewResponseAccessOneloginType = "google-apps" - ZeroTrustIdentityProviderNewResponseAccessOneloginTypeGoogle ZeroTrustIdentityProviderNewResponseAccessOneloginType = "google" - ZeroTrustIdentityProviderNewResponseAccessOneloginTypeLinkedin ZeroTrustIdentityProviderNewResponseAccessOneloginType = "linkedin" - ZeroTrustIdentityProviderNewResponseAccessOneloginTypeOidc ZeroTrustIdentityProviderNewResponseAccessOneloginType = "oidc" - ZeroTrustIdentityProviderNewResponseAccessOneloginTypeOkta ZeroTrustIdentityProviderNewResponseAccessOneloginType = "okta" - ZeroTrustIdentityProviderNewResponseAccessOneloginTypeOnelogin ZeroTrustIdentityProviderNewResponseAccessOneloginType = "onelogin" - ZeroTrustIdentityProviderNewResponseAccessOneloginTypePingone ZeroTrustIdentityProviderNewResponseAccessOneloginType = "pingone" - ZeroTrustIdentityProviderNewResponseAccessOneloginTypeYandex ZeroTrustIdentityProviderNewResponseAccessOneloginType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderNewResponseAccessOneloginScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderNewResponseAccessOneloginScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessOneloginScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessOneloginScimConfig] -type zeroTrustIdentityProviderNewResponseAccessOneloginScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessOneloginScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessOneloginScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderNewResponseAccessPingone struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderNewResponseAccessPingoneConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderNewResponseAccessPingoneType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderNewResponseAccessPingoneScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderNewResponseAccessPingoneJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessPingoneJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderNewResponseAccessPingone] -type zeroTrustIdentityProviderNewResponseAccessPingoneJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessPingone) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessPingoneJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderNewResponseAccessPingone) implementsZeroTrustIdentityProviderNewResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessPingoneConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Your PingOne environment identifier - PingEnvID string `json:"ping_env_id"` - JSON zeroTrustIdentityProviderNewResponseAccessPingoneConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessPingoneConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessPingoneConfig] -type zeroTrustIdentityProviderNewResponseAccessPingoneConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - PingEnvID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessPingoneConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessPingoneConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessPingoneType string - -const ( - ZeroTrustIdentityProviderNewResponseAccessPingoneTypeOnetimepin ZeroTrustIdentityProviderNewResponseAccessPingoneType = "onetimepin" - ZeroTrustIdentityProviderNewResponseAccessPingoneTypeAzureAd ZeroTrustIdentityProviderNewResponseAccessPingoneType = "azureAD" - ZeroTrustIdentityProviderNewResponseAccessPingoneTypeSaml ZeroTrustIdentityProviderNewResponseAccessPingoneType = "saml" - ZeroTrustIdentityProviderNewResponseAccessPingoneTypeCentrify ZeroTrustIdentityProviderNewResponseAccessPingoneType = "centrify" - ZeroTrustIdentityProviderNewResponseAccessPingoneTypeFacebook ZeroTrustIdentityProviderNewResponseAccessPingoneType = "facebook" - ZeroTrustIdentityProviderNewResponseAccessPingoneTypeGitHub ZeroTrustIdentityProviderNewResponseAccessPingoneType = "github" - ZeroTrustIdentityProviderNewResponseAccessPingoneTypeGoogleApps ZeroTrustIdentityProviderNewResponseAccessPingoneType = "google-apps" - ZeroTrustIdentityProviderNewResponseAccessPingoneTypeGoogle ZeroTrustIdentityProviderNewResponseAccessPingoneType = "google" - ZeroTrustIdentityProviderNewResponseAccessPingoneTypeLinkedin ZeroTrustIdentityProviderNewResponseAccessPingoneType = "linkedin" - ZeroTrustIdentityProviderNewResponseAccessPingoneTypeOidc ZeroTrustIdentityProviderNewResponseAccessPingoneType = "oidc" - ZeroTrustIdentityProviderNewResponseAccessPingoneTypeOkta ZeroTrustIdentityProviderNewResponseAccessPingoneType = "okta" - ZeroTrustIdentityProviderNewResponseAccessPingoneTypeOnelogin ZeroTrustIdentityProviderNewResponseAccessPingoneType = "onelogin" - ZeroTrustIdentityProviderNewResponseAccessPingoneTypePingone ZeroTrustIdentityProviderNewResponseAccessPingoneType = "pingone" - ZeroTrustIdentityProviderNewResponseAccessPingoneTypeYandex ZeroTrustIdentityProviderNewResponseAccessPingoneType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderNewResponseAccessPingoneScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderNewResponseAccessPingoneScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessPingoneScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessPingoneScimConfig] -type zeroTrustIdentityProviderNewResponseAccessPingoneScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessPingoneScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessPingoneScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderNewResponseAccessSaml struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderNewResponseAccessSamlConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderNewResponseAccessSamlType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderNewResponseAccessSamlScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderNewResponseAccessSamlJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessSamlJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderNewResponseAccessSaml] -type zeroTrustIdentityProviderNewResponseAccessSamlJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessSamlJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderNewResponseAccessSaml) implementsZeroTrustIdentityProviderNewResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessSamlConfig struct { - // A list of SAML attribute names that will be added to your signed JWT token and - // can be used in SAML policy rules. - Attributes []string `json:"attributes"` - // The attribute name for email in the SAML response. - EmailAttributeName string `json:"email_attribute_name"` - // Add a list of attribute names that will be returned in the response header from - // the Access callback. - HeaderAttributes []ZeroTrustIdentityProviderNewResponseAccessSamlConfigHeaderAttribute `json:"header_attributes"` - // X509 certificate to verify the signature in the SAML authentication response - IdpPublicCerts []string `json:"idp_public_certs"` - // IdP Entity ID or Issuer URL - IssuerURL string `json:"issuer_url"` - // Sign the SAML authentication request with Access credentials. To verify the - // signature, use the public key from the Access certs endpoints. - SignRequest bool `json:"sign_request"` - // URL to send the SAML authentication requests to - SSOTargetURL string `json:"sso_target_url"` - JSON zeroTrustIdentityProviderNewResponseAccessSamlConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessSamlConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderNewResponseAccessSamlConfig] -type zeroTrustIdentityProviderNewResponseAccessSamlConfigJSON struct { - Attributes apijson.Field - EmailAttributeName apijson.Field - HeaderAttributes apijson.Field - IdpPublicCerts apijson.Field - IssuerURL apijson.Field - SignRequest apijson.Field - SSOTargetURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessSamlConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessSamlConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderNewResponseAccessSamlConfigHeaderAttribute struct { - // attribute name from the IDP - AttributeName string `json:"attribute_name"` - // header that will be added on the request to the origin - HeaderName string `json:"header_name"` - JSON zeroTrustIdentityProviderNewResponseAccessSamlConfigHeaderAttributeJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessSamlConfigHeaderAttributeJSON contains -// the JSON metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessSamlConfigHeaderAttribute] -type zeroTrustIdentityProviderNewResponseAccessSamlConfigHeaderAttributeJSON struct { - AttributeName apijson.Field - HeaderName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessSamlConfigHeaderAttribute) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessSamlConfigHeaderAttributeJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessSamlType string - -const ( - ZeroTrustIdentityProviderNewResponseAccessSamlTypeOnetimepin ZeroTrustIdentityProviderNewResponseAccessSamlType = "onetimepin" - ZeroTrustIdentityProviderNewResponseAccessSamlTypeAzureAd ZeroTrustIdentityProviderNewResponseAccessSamlType = "azureAD" - ZeroTrustIdentityProviderNewResponseAccessSamlTypeSaml ZeroTrustIdentityProviderNewResponseAccessSamlType = "saml" - ZeroTrustIdentityProviderNewResponseAccessSamlTypeCentrify ZeroTrustIdentityProviderNewResponseAccessSamlType = "centrify" - ZeroTrustIdentityProviderNewResponseAccessSamlTypeFacebook ZeroTrustIdentityProviderNewResponseAccessSamlType = "facebook" - ZeroTrustIdentityProviderNewResponseAccessSamlTypeGitHub ZeroTrustIdentityProviderNewResponseAccessSamlType = "github" - ZeroTrustIdentityProviderNewResponseAccessSamlTypeGoogleApps ZeroTrustIdentityProviderNewResponseAccessSamlType = "google-apps" - ZeroTrustIdentityProviderNewResponseAccessSamlTypeGoogle ZeroTrustIdentityProviderNewResponseAccessSamlType = "google" - ZeroTrustIdentityProviderNewResponseAccessSamlTypeLinkedin ZeroTrustIdentityProviderNewResponseAccessSamlType = "linkedin" - ZeroTrustIdentityProviderNewResponseAccessSamlTypeOidc ZeroTrustIdentityProviderNewResponseAccessSamlType = "oidc" - ZeroTrustIdentityProviderNewResponseAccessSamlTypeOkta ZeroTrustIdentityProviderNewResponseAccessSamlType = "okta" - ZeroTrustIdentityProviderNewResponseAccessSamlTypeOnelogin ZeroTrustIdentityProviderNewResponseAccessSamlType = "onelogin" - ZeroTrustIdentityProviderNewResponseAccessSamlTypePingone ZeroTrustIdentityProviderNewResponseAccessSamlType = "pingone" - ZeroTrustIdentityProviderNewResponseAccessSamlTypeYandex ZeroTrustIdentityProviderNewResponseAccessSamlType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderNewResponseAccessSamlScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderNewResponseAccessSamlScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessSamlScimConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessSamlScimConfig] -type zeroTrustIdentityProviderNewResponseAccessSamlScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessSamlScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessSamlScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderNewResponseAccessYandex struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderNewResponseAccessYandexConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderNewResponseAccessYandexType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderNewResponseAccessYandexScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderNewResponseAccessYandexJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessYandexJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderNewResponseAccessYandex] -type zeroTrustIdentityProviderNewResponseAccessYandexJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessYandex) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessYandexJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderNewResponseAccessYandex) implementsZeroTrustIdentityProviderNewResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessYandexConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProviderNewResponseAccessYandexConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessYandexConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderNewResponseAccessYandexConfig] -type zeroTrustIdentityProviderNewResponseAccessYandexConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessYandexConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessYandexConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessYandexType string - -const ( - ZeroTrustIdentityProviderNewResponseAccessYandexTypeOnetimepin ZeroTrustIdentityProviderNewResponseAccessYandexType = "onetimepin" - ZeroTrustIdentityProviderNewResponseAccessYandexTypeAzureAd ZeroTrustIdentityProviderNewResponseAccessYandexType = "azureAD" - ZeroTrustIdentityProviderNewResponseAccessYandexTypeSaml ZeroTrustIdentityProviderNewResponseAccessYandexType = "saml" - ZeroTrustIdentityProviderNewResponseAccessYandexTypeCentrify ZeroTrustIdentityProviderNewResponseAccessYandexType = "centrify" - ZeroTrustIdentityProviderNewResponseAccessYandexTypeFacebook ZeroTrustIdentityProviderNewResponseAccessYandexType = "facebook" - ZeroTrustIdentityProviderNewResponseAccessYandexTypeGitHub ZeroTrustIdentityProviderNewResponseAccessYandexType = "github" - ZeroTrustIdentityProviderNewResponseAccessYandexTypeGoogleApps ZeroTrustIdentityProviderNewResponseAccessYandexType = "google-apps" - ZeroTrustIdentityProviderNewResponseAccessYandexTypeGoogle ZeroTrustIdentityProviderNewResponseAccessYandexType = "google" - ZeroTrustIdentityProviderNewResponseAccessYandexTypeLinkedin ZeroTrustIdentityProviderNewResponseAccessYandexType = "linkedin" - ZeroTrustIdentityProviderNewResponseAccessYandexTypeOidc ZeroTrustIdentityProviderNewResponseAccessYandexType = "oidc" - ZeroTrustIdentityProviderNewResponseAccessYandexTypeOkta ZeroTrustIdentityProviderNewResponseAccessYandexType = "okta" - ZeroTrustIdentityProviderNewResponseAccessYandexTypeOnelogin ZeroTrustIdentityProviderNewResponseAccessYandexType = "onelogin" - ZeroTrustIdentityProviderNewResponseAccessYandexTypePingone ZeroTrustIdentityProviderNewResponseAccessYandexType = "pingone" - ZeroTrustIdentityProviderNewResponseAccessYandexTypeYandex ZeroTrustIdentityProviderNewResponseAccessYandexType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderNewResponseAccessYandexScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderNewResponseAccessYandexScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessYandexScimConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessYandexScimConfig] -type zeroTrustIdentityProviderNewResponseAccessYandexScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessYandexScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessYandexScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderNewResponseAccessOnetimepin struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config interface{} `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderNewResponseAccessOnetimepinType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderNewResponseAccessOnetimepinScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderNewResponseAccessOnetimepinJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessOnetimepinJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderNewResponseAccessOnetimepin] -type zeroTrustIdentityProviderNewResponseAccessOnetimepinJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessOnetimepin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessOnetimepinJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderNewResponseAccessOnetimepin) implementsZeroTrustIdentityProviderNewResponse() { -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewResponseAccessOnetimepinType string - -const ( - ZeroTrustIdentityProviderNewResponseAccessOnetimepinTypeOnetimepin ZeroTrustIdentityProviderNewResponseAccessOnetimepinType = "onetimepin" - ZeroTrustIdentityProviderNewResponseAccessOnetimepinTypeAzureAd ZeroTrustIdentityProviderNewResponseAccessOnetimepinType = "azureAD" - ZeroTrustIdentityProviderNewResponseAccessOnetimepinTypeSaml ZeroTrustIdentityProviderNewResponseAccessOnetimepinType = "saml" - ZeroTrustIdentityProviderNewResponseAccessOnetimepinTypeCentrify ZeroTrustIdentityProviderNewResponseAccessOnetimepinType = "centrify" - ZeroTrustIdentityProviderNewResponseAccessOnetimepinTypeFacebook ZeroTrustIdentityProviderNewResponseAccessOnetimepinType = "facebook" - ZeroTrustIdentityProviderNewResponseAccessOnetimepinTypeGitHub ZeroTrustIdentityProviderNewResponseAccessOnetimepinType = "github" - ZeroTrustIdentityProviderNewResponseAccessOnetimepinTypeGoogleApps ZeroTrustIdentityProviderNewResponseAccessOnetimepinType = "google-apps" - ZeroTrustIdentityProviderNewResponseAccessOnetimepinTypeGoogle ZeroTrustIdentityProviderNewResponseAccessOnetimepinType = "google" - ZeroTrustIdentityProviderNewResponseAccessOnetimepinTypeLinkedin ZeroTrustIdentityProviderNewResponseAccessOnetimepinType = "linkedin" - ZeroTrustIdentityProviderNewResponseAccessOnetimepinTypeOidc ZeroTrustIdentityProviderNewResponseAccessOnetimepinType = "oidc" - ZeroTrustIdentityProviderNewResponseAccessOnetimepinTypeOkta ZeroTrustIdentityProviderNewResponseAccessOnetimepinType = "okta" - ZeroTrustIdentityProviderNewResponseAccessOnetimepinTypeOnelogin ZeroTrustIdentityProviderNewResponseAccessOnetimepinType = "onelogin" - ZeroTrustIdentityProviderNewResponseAccessOnetimepinTypePingone ZeroTrustIdentityProviderNewResponseAccessOnetimepinType = "pingone" - ZeroTrustIdentityProviderNewResponseAccessOnetimepinTypeYandex ZeroTrustIdentityProviderNewResponseAccessOnetimepinType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderNewResponseAccessOnetimepinScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderNewResponseAccessOnetimepinScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseAccessOnetimepinScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderNewResponseAccessOnetimepinScimConfig] -type zeroTrustIdentityProviderNewResponseAccessOnetimepinScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseAccessOnetimepinScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseAccessOnetimepinScimConfigJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [ZeroTrustIdentityProviderUpdateResponseAccessAzureAd], -// [ZeroTrustIdentityProviderUpdateResponseAccessCentrify], -// [ZeroTrustIdentityProviderUpdateResponseAccessFacebook], -// [ZeroTrustIdentityProviderUpdateResponseAccessGitHub], -// [ZeroTrustIdentityProviderUpdateResponseAccessGoogle], -// [ZeroTrustIdentityProviderUpdateResponseAccessGoogleApps], -// [ZeroTrustIdentityProviderUpdateResponseAccessLinkedin], -// [ZeroTrustIdentityProviderUpdateResponseAccessOidc], -// [ZeroTrustIdentityProviderUpdateResponseAccessOkta], -// [ZeroTrustIdentityProviderUpdateResponseAccessOnelogin], -// [ZeroTrustIdentityProviderUpdateResponseAccessPingone], -// [ZeroTrustIdentityProviderUpdateResponseAccessSaml], -// [ZeroTrustIdentityProviderUpdateResponseAccessYandex] or -// [ZeroTrustIdentityProviderUpdateResponseAccessOnetimepin]. -type ZeroTrustIdentityProviderUpdateResponse interface { - implementsZeroTrustIdentityProviderUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustIdentityProviderUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderUpdateResponseAccessAzureAd{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderUpdateResponseAccessCentrify{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderUpdateResponseAccessFacebook{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderUpdateResponseAccessGitHub{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderUpdateResponseAccessGoogle{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderUpdateResponseAccessGoogleApps{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderUpdateResponseAccessLinkedin{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderUpdateResponseAccessOidc{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderUpdateResponseAccessOkta{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderUpdateResponseAccessOnelogin{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderUpdateResponseAccessPingone{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderUpdateResponseAccessSaml{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderUpdateResponseAccessYandex{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderUpdateResponseAccessOnetimepin{}), - }, - ) -} - -type ZeroTrustIdentityProviderUpdateResponseAccessAzureAd struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderUpdateResponseAccessAzureAdConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderUpdateResponseAccessAzureAdType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderUpdateResponseAccessAzureAdScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderUpdateResponseAccessAzureAdJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessAzureAdJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderUpdateResponseAccessAzureAd] -type zeroTrustIdentityProviderUpdateResponseAccessAzureAdJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessAzureAdJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderUpdateResponseAccessAzureAd) implementsZeroTrustIdentityProviderUpdateResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessAzureAdConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // Should Cloudflare try to load authentication contexts from your account - ConditionalAccessEnabled bool `json:"conditional_access_enabled"` - // Your Azure directory uuid - DirectoryID string `json:"directory_id"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Should Cloudflare try to load groups from your account - SupportGroups bool `json:"support_groups"` - JSON zeroTrustIdentityProviderUpdateResponseAccessAzureAdConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessAzureAdConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessAzureAdConfig] -type zeroTrustIdentityProviderUpdateResponseAccessAzureAdConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - ConditionalAccessEnabled apijson.Field - DirectoryID apijson.Field - EmailClaimName apijson.Field - SupportGroups apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessAzureAdConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessAzureAdConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessAzureAdType string - -const ( - ZeroTrustIdentityProviderUpdateResponseAccessAzureAdTypeOnetimepin ZeroTrustIdentityProviderUpdateResponseAccessAzureAdType = "onetimepin" - ZeroTrustIdentityProviderUpdateResponseAccessAzureAdTypeAzureAd ZeroTrustIdentityProviderUpdateResponseAccessAzureAdType = "azureAD" - ZeroTrustIdentityProviderUpdateResponseAccessAzureAdTypeSaml ZeroTrustIdentityProviderUpdateResponseAccessAzureAdType = "saml" - ZeroTrustIdentityProviderUpdateResponseAccessAzureAdTypeCentrify ZeroTrustIdentityProviderUpdateResponseAccessAzureAdType = "centrify" - ZeroTrustIdentityProviderUpdateResponseAccessAzureAdTypeFacebook ZeroTrustIdentityProviderUpdateResponseAccessAzureAdType = "facebook" - ZeroTrustIdentityProviderUpdateResponseAccessAzureAdTypeGitHub ZeroTrustIdentityProviderUpdateResponseAccessAzureAdType = "github" - ZeroTrustIdentityProviderUpdateResponseAccessAzureAdTypeGoogleApps ZeroTrustIdentityProviderUpdateResponseAccessAzureAdType = "google-apps" - ZeroTrustIdentityProviderUpdateResponseAccessAzureAdTypeGoogle ZeroTrustIdentityProviderUpdateResponseAccessAzureAdType = "google" - ZeroTrustIdentityProviderUpdateResponseAccessAzureAdTypeLinkedin ZeroTrustIdentityProviderUpdateResponseAccessAzureAdType = "linkedin" - ZeroTrustIdentityProviderUpdateResponseAccessAzureAdTypeOidc ZeroTrustIdentityProviderUpdateResponseAccessAzureAdType = "oidc" - ZeroTrustIdentityProviderUpdateResponseAccessAzureAdTypeOkta ZeroTrustIdentityProviderUpdateResponseAccessAzureAdType = "okta" - ZeroTrustIdentityProviderUpdateResponseAccessAzureAdTypeOnelogin ZeroTrustIdentityProviderUpdateResponseAccessAzureAdType = "onelogin" - ZeroTrustIdentityProviderUpdateResponseAccessAzureAdTypePingone ZeroTrustIdentityProviderUpdateResponseAccessAzureAdType = "pingone" - ZeroTrustIdentityProviderUpdateResponseAccessAzureAdTypeYandex ZeroTrustIdentityProviderUpdateResponseAccessAzureAdType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderUpdateResponseAccessAzureAdScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderUpdateResponseAccessAzureAdScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessAzureAdScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessAzureAdScimConfig] -type zeroTrustIdentityProviderUpdateResponseAccessAzureAdScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessAzureAdScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessAzureAdScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderUpdateResponseAccessCentrify struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderUpdateResponseAccessCentrifyConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderUpdateResponseAccessCentrifyType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderUpdateResponseAccessCentrifyScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderUpdateResponseAccessCentrifyJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessCentrifyJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderUpdateResponseAccessCentrify] -type zeroTrustIdentityProviderUpdateResponseAccessCentrifyJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessCentrify) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessCentrifyJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderUpdateResponseAccessCentrify) implementsZeroTrustIdentityProviderUpdateResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessCentrifyConfig struct { - // Your centrify account url - CentrifyAccount string `json:"centrify_account"` - // Your centrify app id - CentrifyAppID string `json:"centrify_app_id"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - JSON zeroTrustIdentityProviderUpdateResponseAccessCentrifyConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessCentrifyConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessCentrifyConfig] -type zeroTrustIdentityProviderUpdateResponseAccessCentrifyConfigJSON struct { - CentrifyAccount apijson.Field - CentrifyAppID apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessCentrifyConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessCentrifyConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessCentrifyType string - -const ( - ZeroTrustIdentityProviderUpdateResponseAccessCentrifyTypeOnetimepin ZeroTrustIdentityProviderUpdateResponseAccessCentrifyType = "onetimepin" - ZeroTrustIdentityProviderUpdateResponseAccessCentrifyTypeAzureAd ZeroTrustIdentityProviderUpdateResponseAccessCentrifyType = "azureAD" - ZeroTrustIdentityProviderUpdateResponseAccessCentrifyTypeSaml ZeroTrustIdentityProviderUpdateResponseAccessCentrifyType = "saml" - ZeroTrustIdentityProviderUpdateResponseAccessCentrifyTypeCentrify ZeroTrustIdentityProviderUpdateResponseAccessCentrifyType = "centrify" - ZeroTrustIdentityProviderUpdateResponseAccessCentrifyTypeFacebook ZeroTrustIdentityProviderUpdateResponseAccessCentrifyType = "facebook" - ZeroTrustIdentityProviderUpdateResponseAccessCentrifyTypeGitHub ZeroTrustIdentityProviderUpdateResponseAccessCentrifyType = "github" - ZeroTrustIdentityProviderUpdateResponseAccessCentrifyTypeGoogleApps ZeroTrustIdentityProviderUpdateResponseAccessCentrifyType = "google-apps" - ZeroTrustIdentityProviderUpdateResponseAccessCentrifyTypeGoogle ZeroTrustIdentityProviderUpdateResponseAccessCentrifyType = "google" - ZeroTrustIdentityProviderUpdateResponseAccessCentrifyTypeLinkedin ZeroTrustIdentityProviderUpdateResponseAccessCentrifyType = "linkedin" - ZeroTrustIdentityProviderUpdateResponseAccessCentrifyTypeOidc ZeroTrustIdentityProviderUpdateResponseAccessCentrifyType = "oidc" - ZeroTrustIdentityProviderUpdateResponseAccessCentrifyTypeOkta ZeroTrustIdentityProviderUpdateResponseAccessCentrifyType = "okta" - ZeroTrustIdentityProviderUpdateResponseAccessCentrifyTypeOnelogin ZeroTrustIdentityProviderUpdateResponseAccessCentrifyType = "onelogin" - ZeroTrustIdentityProviderUpdateResponseAccessCentrifyTypePingone ZeroTrustIdentityProviderUpdateResponseAccessCentrifyType = "pingone" - ZeroTrustIdentityProviderUpdateResponseAccessCentrifyTypeYandex ZeroTrustIdentityProviderUpdateResponseAccessCentrifyType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderUpdateResponseAccessCentrifyScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderUpdateResponseAccessCentrifyScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessCentrifyScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessCentrifyScimConfig] -type zeroTrustIdentityProviderUpdateResponseAccessCentrifyScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessCentrifyScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessCentrifyScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderUpdateResponseAccessFacebook struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderUpdateResponseAccessFacebookConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderUpdateResponseAccessFacebookType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderUpdateResponseAccessFacebookScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderUpdateResponseAccessFacebookJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessFacebookJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderUpdateResponseAccessFacebook] -type zeroTrustIdentityProviderUpdateResponseAccessFacebookJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessFacebook) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessFacebookJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderUpdateResponseAccessFacebook) implementsZeroTrustIdentityProviderUpdateResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessFacebookConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProviderUpdateResponseAccessFacebookConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessFacebookConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessFacebookConfig] -type zeroTrustIdentityProviderUpdateResponseAccessFacebookConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessFacebookConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessFacebookConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessFacebookType string - -const ( - ZeroTrustIdentityProviderUpdateResponseAccessFacebookTypeOnetimepin ZeroTrustIdentityProviderUpdateResponseAccessFacebookType = "onetimepin" - ZeroTrustIdentityProviderUpdateResponseAccessFacebookTypeAzureAd ZeroTrustIdentityProviderUpdateResponseAccessFacebookType = "azureAD" - ZeroTrustIdentityProviderUpdateResponseAccessFacebookTypeSaml ZeroTrustIdentityProviderUpdateResponseAccessFacebookType = "saml" - ZeroTrustIdentityProviderUpdateResponseAccessFacebookTypeCentrify ZeroTrustIdentityProviderUpdateResponseAccessFacebookType = "centrify" - ZeroTrustIdentityProviderUpdateResponseAccessFacebookTypeFacebook ZeroTrustIdentityProviderUpdateResponseAccessFacebookType = "facebook" - ZeroTrustIdentityProviderUpdateResponseAccessFacebookTypeGitHub ZeroTrustIdentityProviderUpdateResponseAccessFacebookType = "github" - ZeroTrustIdentityProviderUpdateResponseAccessFacebookTypeGoogleApps ZeroTrustIdentityProviderUpdateResponseAccessFacebookType = "google-apps" - ZeroTrustIdentityProviderUpdateResponseAccessFacebookTypeGoogle ZeroTrustIdentityProviderUpdateResponseAccessFacebookType = "google" - ZeroTrustIdentityProviderUpdateResponseAccessFacebookTypeLinkedin ZeroTrustIdentityProviderUpdateResponseAccessFacebookType = "linkedin" - ZeroTrustIdentityProviderUpdateResponseAccessFacebookTypeOidc ZeroTrustIdentityProviderUpdateResponseAccessFacebookType = "oidc" - ZeroTrustIdentityProviderUpdateResponseAccessFacebookTypeOkta ZeroTrustIdentityProviderUpdateResponseAccessFacebookType = "okta" - ZeroTrustIdentityProviderUpdateResponseAccessFacebookTypeOnelogin ZeroTrustIdentityProviderUpdateResponseAccessFacebookType = "onelogin" - ZeroTrustIdentityProviderUpdateResponseAccessFacebookTypePingone ZeroTrustIdentityProviderUpdateResponseAccessFacebookType = "pingone" - ZeroTrustIdentityProviderUpdateResponseAccessFacebookTypeYandex ZeroTrustIdentityProviderUpdateResponseAccessFacebookType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderUpdateResponseAccessFacebookScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderUpdateResponseAccessFacebookScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessFacebookScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessFacebookScimConfig] -type zeroTrustIdentityProviderUpdateResponseAccessFacebookScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessFacebookScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessFacebookScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderUpdateResponseAccessGitHub struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderUpdateResponseAccessGitHubConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderUpdateResponseAccessGitHubType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderUpdateResponseAccessGitHubScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderUpdateResponseAccessGitHubJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessGitHubJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderUpdateResponseAccessGitHub] -type zeroTrustIdentityProviderUpdateResponseAccessGitHubJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessGitHub) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessGitHubJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderUpdateResponseAccessGitHub) implementsZeroTrustIdentityProviderUpdateResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessGitHubConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProviderUpdateResponseAccessGitHubConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessGitHubConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessGitHubConfig] -type zeroTrustIdentityProviderUpdateResponseAccessGitHubConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessGitHubConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessGitHubConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessGitHubType string - -const ( - ZeroTrustIdentityProviderUpdateResponseAccessGitHubTypeOnetimepin ZeroTrustIdentityProviderUpdateResponseAccessGitHubType = "onetimepin" - ZeroTrustIdentityProviderUpdateResponseAccessGitHubTypeAzureAd ZeroTrustIdentityProviderUpdateResponseAccessGitHubType = "azureAD" - ZeroTrustIdentityProviderUpdateResponseAccessGitHubTypeSaml ZeroTrustIdentityProviderUpdateResponseAccessGitHubType = "saml" - ZeroTrustIdentityProviderUpdateResponseAccessGitHubTypeCentrify ZeroTrustIdentityProviderUpdateResponseAccessGitHubType = "centrify" - ZeroTrustIdentityProviderUpdateResponseAccessGitHubTypeFacebook ZeroTrustIdentityProviderUpdateResponseAccessGitHubType = "facebook" - ZeroTrustIdentityProviderUpdateResponseAccessGitHubTypeGitHub ZeroTrustIdentityProviderUpdateResponseAccessGitHubType = "github" - ZeroTrustIdentityProviderUpdateResponseAccessGitHubTypeGoogleApps ZeroTrustIdentityProviderUpdateResponseAccessGitHubType = "google-apps" - ZeroTrustIdentityProviderUpdateResponseAccessGitHubTypeGoogle ZeroTrustIdentityProviderUpdateResponseAccessGitHubType = "google" - ZeroTrustIdentityProviderUpdateResponseAccessGitHubTypeLinkedin ZeroTrustIdentityProviderUpdateResponseAccessGitHubType = "linkedin" - ZeroTrustIdentityProviderUpdateResponseAccessGitHubTypeOidc ZeroTrustIdentityProviderUpdateResponseAccessGitHubType = "oidc" - ZeroTrustIdentityProviderUpdateResponseAccessGitHubTypeOkta ZeroTrustIdentityProviderUpdateResponseAccessGitHubType = "okta" - ZeroTrustIdentityProviderUpdateResponseAccessGitHubTypeOnelogin ZeroTrustIdentityProviderUpdateResponseAccessGitHubType = "onelogin" - ZeroTrustIdentityProviderUpdateResponseAccessGitHubTypePingone ZeroTrustIdentityProviderUpdateResponseAccessGitHubType = "pingone" - ZeroTrustIdentityProviderUpdateResponseAccessGitHubTypeYandex ZeroTrustIdentityProviderUpdateResponseAccessGitHubType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderUpdateResponseAccessGitHubScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderUpdateResponseAccessGitHubScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessGitHubScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessGitHubScimConfig] -type zeroTrustIdentityProviderUpdateResponseAccessGitHubScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessGitHubScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessGitHubScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderUpdateResponseAccessGoogle struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderUpdateResponseAccessGoogleConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderUpdateResponseAccessGoogleType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderUpdateResponseAccessGoogleScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderUpdateResponseAccessGoogleJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessGoogleJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderUpdateResponseAccessGoogle] -type zeroTrustIdentityProviderUpdateResponseAccessGoogleJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessGoogle) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessGoogleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderUpdateResponseAccessGoogle) implementsZeroTrustIdentityProviderUpdateResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessGoogleConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - JSON zeroTrustIdentityProviderUpdateResponseAccessGoogleConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessGoogleConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessGoogleConfig] -type zeroTrustIdentityProviderUpdateResponseAccessGoogleConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessGoogleConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessGoogleConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessGoogleType string - -const ( - ZeroTrustIdentityProviderUpdateResponseAccessGoogleTypeOnetimepin ZeroTrustIdentityProviderUpdateResponseAccessGoogleType = "onetimepin" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleTypeAzureAd ZeroTrustIdentityProviderUpdateResponseAccessGoogleType = "azureAD" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleTypeSaml ZeroTrustIdentityProviderUpdateResponseAccessGoogleType = "saml" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleTypeCentrify ZeroTrustIdentityProviderUpdateResponseAccessGoogleType = "centrify" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleTypeFacebook ZeroTrustIdentityProviderUpdateResponseAccessGoogleType = "facebook" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleTypeGitHub ZeroTrustIdentityProviderUpdateResponseAccessGoogleType = "github" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleTypeGoogleApps ZeroTrustIdentityProviderUpdateResponseAccessGoogleType = "google-apps" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleTypeGoogle ZeroTrustIdentityProviderUpdateResponseAccessGoogleType = "google" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleTypeLinkedin ZeroTrustIdentityProviderUpdateResponseAccessGoogleType = "linkedin" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleTypeOidc ZeroTrustIdentityProviderUpdateResponseAccessGoogleType = "oidc" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleTypeOkta ZeroTrustIdentityProviderUpdateResponseAccessGoogleType = "okta" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleTypeOnelogin ZeroTrustIdentityProviderUpdateResponseAccessGoogleType = "onelogin" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleTypePingone ZeroTrustIdentityProviderUpdateResponseAccessGoogleType = "pingone" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleTypeYandex ZeroTrustIdentityProviderUpdateResponseAccessGoogleType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderUpdateResponseAccessGoogleScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderUpdateResponseAccessGoogleScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessGoogleScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessGoogleScimConfig] -type zeroTrustIdentityProviderUpdateResponseAccessGoogleScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessGoogleScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessGoogleScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderUpdateResponseAccessGoogleApps struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderUpdateResponseAccessGoogleAppsJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessGoogleAppsJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessGoogleApps] -type zeroTrustIdentityProviderUpdateResponseAccessGoogleAppsJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessGoogleApps) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessGoogleAppsJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderUpdateResponseAccessGoogleApps) implementsZeroTrustIdentityProviderUpdateResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsConfig struct { - // Your companies TLD - AppsDomain string `json:"apps_domain"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - JSON zeroTrustIdentityProviderUpdateResponseAccessGoogleAppsConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessGoogleAppsConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsConfig] -type zeroTrustIdentityProviderUpdateResponseAccessGoogleAppsConfigJSON struct { - AppsDomain apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessGoogleAppsConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsType string - -const ( - ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsTypeOnetimepin ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsType = "onetimepin" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsTypeAzureAd ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsType = "azureAD" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsTypeSaml ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsType = "saml" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsTypeCentrify ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsType = "centrify" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsTypeFacebook ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsType = "facebook" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsTypeGitHub ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsType = "github" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsTypeGoogleApps ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsType = "google-apps" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsTypeGoogle ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsType = "google" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsTypeLinkedin ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsType = "linkedin" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsTypeOidc ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsType = "oidc" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsTypeOkta ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsType = "okta" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsTypeOnelogin ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsType = "onelogin" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsTypePingone ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsType = "pingone" - ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsTypeYandex ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderUpdateResponseAccessGoogleAppsScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessGoogleAppsScimConfigJSON contains -// the JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsScimConfig] -type zeroTrustIdentityProviderUpdateResponseAccessGoogleAppsScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessGoogleAppsScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessGoogleAppsScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderUpdateResponseAccessLinkedin struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderUpdateResponseAccessLinkedinConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderUpdateResponseAccessLinkedinType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderUpdateResponseAccessLinkedinScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderUpdateResponseAccessLinkedinJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessLinkedinJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderUpdateResponseAccessLinkedin] -type zeroTrustIdentityProviderUpdateResponseAccessLinkedinJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessLinkedin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessLinkedinJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderUpdateResponseAccessLinkedin) implementsZeroTrustIdentityProviderUpdateResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessLinkedinConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProviderUpdateResponseAccessLinkedinConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessLinkedinConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessLinkedinConfig] -type zeroTrustIdentityProviderUpdateResponseAccessLinkedinConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessLinkedinConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessLinkedinConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessLinkedinType string - -const ( - ZeroTrustIdentityProviderUpdateResponseAccessLinkedinTypeOnetimepin ZeroTrustIdentityProviderUpdateResponseAccessLinkedinType = "onetimepin" - ZeroTrustIdentityProviderUpdateResponseAccessLinkedinTypeAzureAd ZeroTrustIdentityProviderUpdateResponseAccessLinkedinType = "azureAD" - ZeroTrustIdentityProviderUpdateResponseAccessLinkedinTypeSaml ZeroTrustIdentityProviderUpdateResponseAccessLinkedinType = "saml" - ZeroTrustIdentityProviderUpdateResponseAccessLinkedinTypeCentrify ZeroTrustIdentityProviderUpdateResponseAccessLinkedinType = "centrify" - ZeroTrustIdentityProviderUpdateResponseAccessLinkedinTypeFacebook ZeroTrustIdentityProviderUpdateResponseAccessLinkedinType = "facebook" - ZeroTrustIdentityProviderUpdateResponseAccessLinkedinTypeGitHub ZeroTrustIdentityProviderUpdateResponseAccessLinkedinType = "github" - ZeroTrustIdentityProviderUpdateResponseAccessLinkedinTypeGoogleApps ZeroTrustIdentityProviderUpdateResponseAccessLinkedinType = "google-apps" - ZeroTrustIdentityProviderUpdateResponseAccessLinkedinTypeGoogle ZeroTrustIdentityProviderUpdateResponseAccessLinkedinType = "google" - ZeroTrustIdentityProviderUpdateResponseAccessLinkedinTypeLinkedin ZeroTrustIdentityProviderUpdateResponseAccessLinkedinType = "linkedin" - ZeroTrustIdentityProviderUpdateResponseAccessLinkedinTypeOidc ZeroTrustIdentityProviderUpdateResponseAccessLinkedinType = "oidc" - ZeroTrustIdentityProviderUpdateResponseAccessLinkedinTypeOkta ZeroTrustIdentityProviderUpdateResponseAccessLinkedinType = "okta" - ZeroTrustIdentityProviderUpdateResponseAccessLinkedinTypeOnelogin ZeroTrustIdentityProviderUpdateResponseAccessLinkedinType = "onelogin" - ZeroTrustIdentityProviderUpdateResponseAccessLinkedinTypePingone ZeroTrustIdentityProviderUpdateResponseAccessLinkedinType = "pingone" - ZeroTrustIdentityProviderUpdateResponseAccessLinkedinTypeYandex ZeroTrustIdentityProviderUpdateResponseAccessLinkedinType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderUpdateResponseAccessLinkedinScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderUpdateResponseAccessLinkedinScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessLinkedinScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessLinkedinScimConfig] -type zeroTrustIdentityProviderUpdateResponseAccessLinkedinScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessLinkedinScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessLinkedinScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderUpdateResponseAccessOidc struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderUpdateResponseAccessOidcConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderUpdateResponseAccessOidcType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderUpdateResponseAccessOidcScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderUpdateResponseAccessOidcJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessOidcJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderUpdateResponseAccessOidc] -type zeroTrustIdentityProviderUpdateResponseAccessOidcJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessOidc) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessOidcJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderUpdateResponseAccessOidc) implementsZeroTrustIdentityProviderUpdateResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessOidcConfig struct { - // The authorization_endpoint URL of your IdP - AuthURL string `json:"auth_url"` - // The jwks_uri endpoint of your IdP to allow the IdP keys to sign the tokens - CertsURL string `json:"certs_url"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // OAuth scopes - Scopes []string `json:"scopes"` - // The token_endpoint URL of your IdP - TokenURL string `json:"token_url"` - JSON zeroTrustIdentityProviderUpdateResponseAccessOidcConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessOidcConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessOidcConfig] -type zeroTrustIdentityProviderUpdateResponseAccessOidcConfigJSON struct { - AuthURL apijson.Field - CertsURL apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - Scopes apijson.Field - TokenURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessOidcConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessOidcConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessOidcType string - -const ( - ZeroTrustIdentityProviderUpdateResponseAccessOidcTypeOnetimepin ZeroTrustIdentityProviderUpdateResponseAccessOidcType = "onetimepin" - ZeroTrustIdentityProviderUpdateResponseAccessOidcTypeAzureAd ZeroTrustIdentityProviderUpdateResponseAccessOidcType = "azureAD" - ZeroTrustIdentityProviderUpdateResponseAccessOidcTypeSaml ZeroTrustIdentityProviderUpdateResponseAccessOidcType = "saml" - ZeroTrustIdentityProviderUpdateResponseAccessOidcTypeCentrify ZeroTrustIdentityProviderUpdateResponseAccessOidcType = "centrify" - ZeroTrustIdentityProviderUpdateResponseAccessOidcTypeFacebook ZeroTrustIdentityProviderUpdateResponseAccessOidcType = "facebook" - ZeroTrustIdentityProviderUpdateResponseAccessOidcTypeGitHub ZeroTrustIdentityProviderUpdateResponseAccessOidcType = "github" - ZeroTrustIdentityProviderUpdateResponseAccessOidcTypeGoogleApps ZeroTrustIdentityProviderUpdateResponseAccessOidcType = "google-apps" - ZeroTrustIdentityProviderUpdateResponseAccessOidcTypeGoogle ZeroTrustIdentityProviderUpdateResponseAccessOidcType = "google" - ZeroTrustIdentityProviderUpdateResponseAccessOidcTypeLinkedin ZeroTrustIdentityProviderUpdateResponseAccessOidcType = "linkedin" - ZeroTrustIdentityProviderUpdateResponseAccessOidcTypeOidc ZeroTrustIdentityProviderUpdateResponseAccessOidcType = "oidc" - ZeroTrustIdentityProviderUpdateResponseAccessOidcTypeOkta ZeroTrustIdentityProviderUpdateResponseAccessOidcType = "okta" - ZeroTrustIdentityProviderUpdateResponseAccessOidcTypeOnelogin ZeroTrustIdentityProviderUpdateResponseAccessOidcType = "onelogin" - ZeroTrustIdentityProviderUpdateResponseAccessOidcTypePingone ZeroTrustIdentityProviderUpdateResponseAccessOidcType = "pingone" - ZeroTrustIdentityProviderUpdateResponseAccessOidcTypeYandex ZeroTrustIdentityProviderUpdateResponseAccessOidcType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderUpdateResponseAccessOidcScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderUpdateResponseAccessOidcScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessOidcScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessOidcScimConfig] -type zeroTrustIdentityProviderUpdateResponseAccessOidcScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessOidcScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessOidcScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderUpdateResponseAccessOkta struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderUpdateResponseAccessOktaConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderUpdateResponseAccessOktaType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderUpdateResponseAccessOktaScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderUpdateResponseAccessOktaJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessOktaJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderUpdateResponseAccessOkta] -type zeroTrustIdentityProviderUpdateResponseAccessOktaJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessOktaJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderUpdateResponseAccessOkta) implementsZeroTrustIdentityProviderUpdateResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessOktaConfig struct { - // Your okta authorization server id - AuthorizationServerID string `json:"authorization_server_id"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Your okta account url - OktaAccount string `json:"okta_account"` - JSON zeroTrustIdentityProviderUpdateResponseAccessOktaConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessOktaConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessOktaConfig] -type zeroTrustIdentityProviderUpdateResponseAccessOktaConfigJSON struct { - AuthorizationServerID apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - OktaAccount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessOktaConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessOktaConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessOktaType string - -const ( - ZeroTrustIdentityProviderUpdateResponseAccessOktaTypeOnetimepin ZeroTrustIdentityProviderUpdateResponseAccessOktaType = "onetimepin" - ZeroTrustIdentityProviderUpdateResponseAccessOktaTypeAzureAd ZeroTrustIdentityProviderUpdateResponseAccessOktaType = "azureAD" - ZeroTrustIdentityProviderUpdateResponseAccessOktaTypeSaml ZeroTrustIdentityProviderUpdateResponseAccessOktaType = "saml" - ZeroTrustIdentityProviderUpdateResponseAccessOktaTypeCentrify ZeroTrustIdentityProviderUpdateResponseAccessOktaType = "centrify" - ZeroTrustIdentityProviderUpdateResponseAccessOktaTypeFacebook ZeroTrustIdentityProviderUpdateResponseAccessOktaType = "facebook" - ZeroTrustIdentityProviderUpdateResponseAccessOktaTypeGitHub ZeroTrustIdentityProviderUpdateResponseAccessOktaType = "github" - ZeroTrustIdentityProviderUpdateResponseAccessOktaTypeGoogleApps ZeroTrustIdentityProviderUpdateResponseAccessOktaType = "google-apps" - ZeroTrustIdentityProviderUpdateResponseAccessOktaTypeGoogle ZeroTrustIdentityProviderUpdateResponseAccessOktaType = "google" - ZeroTrustIdentityProviderUpdateResponseAccessOktaTypeLinkedin ZeroTrustIdentityProviderUpdateResponseAccessOktaType = "linkedin" - ZeroTrustIdentityProviderUpdateResponseAccessOktaTypeOidc ZeroTrustIdentityProviderUpdateResponseAccessOktaType = "oidc" - ZeroTrustIdentityProviderUpdateResponseAccessOktaTypeOkta ZeroTrustIdentityProviderUpdateResponseAccessOktaType = "okta" - ZeroTrustIdentityProviderUpdateResponseAccessOktaTypeOnelogin ZeroTrustIdentityProviderUpdateResponseAccessOktaType = "onelogin" - ZeroTrustIdentityProviderUpdateResponseAccessOktaTypePingone ZeroTrustIdentityProviderUpdateResponseAccessOktaType = "pingone" - ZeroTrustIdentityProviderUpdateResponseAccessOktaTypeYandex ZeroTrustIdentityProviderUpdateResponseAccessOktaType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderUpdateResponseAccessOktaScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderUpdateResponseAccessOktaScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessOktaScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessOktaScimConfig] -type zeroTrustIdentityProviderUpdateResponseAccessOktaScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessOktaScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessOktaScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderUpdateResponseAccessOnelogin struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderUpdateResponseAccessOneloginConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderUpdateResponseAccessOneloginType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderUpdateResponseAccessOneloginScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderUpdateResponseAccessOneloginJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessOneloginJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderUpdateResponseAccessOnelogin] -type zeroTrustIdentityProviderUpdateResponseAccessOneloginJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessOnelogin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessOneloginJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderUpdateResponseAccessOnelogin) implementsZeroTrustIdentityProviderUpdateResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessOneloginConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Your OneLogin account url - OneloginAccount string `json:"onelogin_account"` - JSON zeroTrustIdentityProviderUpdateResponseAccessOneloginConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessOneloginConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessOneloginConfig] -type zeroTrustIdentityProviderUpdateResponseAccessOneloginConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - OneloginAccount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessOneloginConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessOneloginConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessOneloginType string - -const ( - ZeroTrustIdentityProviderUpdateResponseAccessOneloginTypeOnetimepin ZeroTrustIdentityProviderUpdateResponseAccessOneloginType = "onetimepin" - ZeroTrustIdentityProviderUpdateResponseAccessOneloginTypeAzureAd ZeroTrustIdentityProviderUpdateResponseAccessOneloginType = "azureAD" - ZeroTrustIdentityProviderUpdateResponseAccessOneloginTypeSaml ZeroTrustIdentityProviderUpdateResponseAccessOneloginType = "saml" - ZeroTrustIdentityProviderUpdateResponseAccessOneloginTypeCentrify ZeroTrustIdentityProviderUpdateResponseAccessOneloginType = "centrify" - ZeroTrustIdentityProviderUpdateResponseAccessOneloginTypeFacebook ZeroTrustIdentityProviderUpdateResponseAccessOneloginType = "facebook" - ZeroTrustIdentityProviderUpdateResponseAccessOneloginTypeGitHub ZeroTrustIdentityProviderUpdateResponseAccessOneloginType = "github" - ZeroTrustIdentityProviderUpdateResponseAccessOneloginTypeGoogleApps ZeroTrustIdentityProviderUpdateResponseAccessOneloginType = "google-apps" - ZeroTrustIdentityProviderUpdateResponseAccessOneloginTypeGoogle ZeroTrustIdentityProviderUpdateResponseAccessOneloginType = "google" - ZeroTrustIdentityProviderUpdateResponseAccessOneloginTypeLinkedin ZeroTrustIdentityProviderUpdateResponseAccessOneloginType = "linkedin" - ZeroTrustIdentityProviderUpdateResponseAccessOneloginTypeOidc ZeroTrustIdentityProviderUpdateResponseAccessOneloginType = "oidc" - ZeroTrustIdentityProviderUpdateResponseAccessOneloginTypeOkta ZeroTrustIdentityProviderUpdateResponseAccessOneloginType = "okta" - ZeroTrustIdentityProviderUpdateResponseAccessOneloginTypeOnelogin ZeroTrustIdentityProviderUpdateResponseAccessOneloginType = "onelogin" - ZeroTrustIdentityProviderUpdateResponseAccessOneloginTypePingone ZeroTrustIdentityProviderUpdateResponseAccessOneloginType = "pingone" - ZeroTrustIdentityProviderUpdateResponseAccessOneloginTypeYandex ZeroTrustIdentityProviderUpdateResponseAccessOneloginType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderUpdateResponseAccessOneloginScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderUpdateResponseAccessOneloginScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessOneloginScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessOneloginScimConfig] -type zeroTrustIdentityProviderUpdateResponseAccessOneloginScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessOneloginScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessOneloginScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderUpdateResponseAccessPingone struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderUpdateResponseAccessPingoneConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderUpdateResponseAccessPingoneType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderUpdateResponseAccessPingoneScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderUpdateResponseAccessPingoneJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessPingoneJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderUpdateResponseAccessPingone] -type zeroTrustIdentityProviderUpdateResponseAccessPingoneJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessPingone) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessPingoneJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderUpdateResponseAccessPingone) implementsZeroTrustIdentityProviderUpdateResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessPingoneConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Your PingOne environment identifier - PingEnvID string `json:"ping_env_id"` - JSON zeroTrustIdentityProviderUpdateResponseAccessPingoneConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessPingoneConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessPingoneConfig] -type zeroTrustIdentityProviderUpdateResponseAccessPingoneConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - PingEnvID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessPingoneConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessPingoneConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessPingoneType string - -const ( - ZeroTrustIdentityProviderUpdateResponseAccessPingoneTypeOnetimepin ZeroTrustIdentityProviderUpdateResponseAccessPingoneType = "onetimepin" - ZeroTrustIdentityProviderUpdateResponseAccessPingoneTypeAzureAd ZeroTrustIdentityProviderUpdateResponseAccessPingoneType = "azureAD" - ZeroTrustIdentityProviderUpdateResponseAccessPingoneTypeSaml ZeroTrustIdentityProviderUpdateResponseAccessPingoneType = "saml" - ZeroTrustIdentityProviderUpdateResponseAccessPingoneTypeCentrify ZeroTrustIdentityProviderUpdateResponseAccessPingoneType = "centrify" - ZeroTrustIdentityProviderUpdateResponseAccessPingoneTypeFacebook ZeroTrustIdentityProviderUpdateResponseAccessPingoneType = "facebook" - ZeroTrustIdentityProviderUpdateResponseAccessPingoneTypeGitHub ZeroTrustIdentityProviderUpdateResponseAccessPingoneType = "github" - ZeroTrustIdentityProviderUpdateResponseAccessPingoneTypeGoogleApps ZeroTrustIdentityProviderUpdateResponseAccessPingoneType = "google-apps" - ZeroTrustIdentityProviderUpdateResponseAccessPingoneTypeGoogle ZeroTrustIdentityProviderUpdateResponseAccessPingoneType = "google" - ZeroTrustIdentityProviderUpdateResponseAccessPingoneTypeLinkedin ZeroTrustIdentityProviderUpdateResponseAccessPingoneType = "linkedin" - ZeroTrustIdentityProviderUpdateResponseAccessPingoneTypeOidc ZeroTrustIdentityProviderUpdateResponseAccessPingoneType = "oidc" - ZeroTrustIdentityProviderUpdateResponseAccessPingoneTypeOkta ZeroTrustIdentityProviderUpdateResponseAccessPingoneType = "okta" - ZeroTrustIdentityProviderUpdateResponseAccessPingoneTypeOnelogin ZeroTrustIdentityProviderUpdateResponseAccessPingoneType = "onelogin" - ZeroTrustIdentityProviderUpdateResponseAccessPingoneTypePingone ZeroTrustIdentityProviderUpdateResponseAccessPingoneType = "pingone" - ZeroTrustIdentityProviderUpdateResponseAccessPingoneTypeYandex ZeroTrustIdentityProviderUpdateResponseAccessPingoneType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderUpdateResponseAccessPingoneScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderUpdateResponseAccessPingoneScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessPingoneScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessPingoneScimConfig] -type zeroTrustIdentityProviderUpdateResponseAccessPingoneScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessPingoneScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessPingoneScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderUpdateResponseAccessSaml struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderUpdateResponseAccessSamlConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderUpdateResponseAccessSamlType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderUpdateResponseAccessSamlScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderUpdateResponseAccessSamlJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessSamlJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderUpdateResponseAccessSaml] -type zeroTrustIdentityProviderUpdateResponseAccessSamlJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessSamlJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderUpdateResponseAccessSaml) implementsZeroTrustIdentityProviderUpdateResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessSamlConfig struct { - // A list of SAML attribute names that will be added to your signed JWT token and - // can be used in SAML policy rules. - Attributes []string `json:"attributes"` - // The attribute name for email in the SAML response. - EmailAttributeName string `json:"email_attribute_name"` - // Add a list of attribute names that will be returned in the response header from - // the Access callback. - HeaderAttributes []ZeroTrustIdentityProviderUpdateResponseAccessSamlConfigHeaderAttribute `json:"header_attributes"` - // X509 certificate to verify the signature in the SAML authentication response - IdpPublicCerts []string `json:"idp_public_certs"` - // IdP Entity ID or Issuer URL - IssuerURL string `json:"issuer_url"` - // Sign the SAML authentication request with Access credentials. To verify the - // signature, use the public key from the Access certs endpoints. - SignRequest bool `json:"sign_request"` - // URL to send the SAML authentication requests to - SSOTargetURL string `json:"sso_target_url"` - JSON zeroTrustIdentityProviderUpdateResponseAccessSamlConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessSamlConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessSamlConfig] -type zeroTrustIdentityProviderUpdateResponseAccessSamlConfigJSON struct { - Attributes apijson.Field - EmailAttributeName apijson.Field - HeaderAttributes apijson.Field - IdpPublicCerts apijson.Field - IssuerURL apijson.Field - SignRequest apijson.Field - SSOTargetURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessSamlConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessSamlConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderUpdateResponseAccessSamlConfigHeaderAttribute struct { - // attribute name from the IDP - AttributeName string `json:"attribute_name"` - // header that will be added on the request to the origin - HeaderName string `json:"header_name"` - JSON zeroTrustIdentityProviderUpdateResponseAccessSamlConfigHeaderAttributeJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessSamlConfigHeaderAttributeJSON -// contains the JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessSamlConfigHeaderAttribute] -type zeroTrustIdentityProviderUpdateResponseAccessSamlConfigHeaderAttributeJSON struct { - AttributeName apijson.Field - HeaderName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessSamlConfigHeaderAttribute) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessSamlConfigHeaderAttributeJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessSamlType string - -const ( - ZeroTrustIdentityProviderUpdateResponseAccessSamlTypeOnetimepin ZeroTrustIdentityProviderUpdateResponseAccessSamlType = "onetimepin" - ZeroTrustIdentityProviderUpdateResponseAccessSamlTypeAzureAd ZeroTrustIdentityProviderUpdateResponseAccessSamlType = "azureAD" - ZeroTrustIdentityProviderUpdateResponseAccessSamlTypeSaml ZeroTrustIdentityProviderUpdateResponseAccessSamlType = "saml" - ZeroTrustIdentityProviderUpdateResponseAccessSamlTypeCentrify ZeroTrustIdentityProviderUpdateResponseAccessSamlType = "centrify" - ZeroTrustIdentityProviderUpdateResponseAccessSamlTypeFacebook ZeroTrustIdentityProviderUpdateResponseAccessSamlType = "facebook" - ZeroTrustIdentityProviderUpdateResponseAccessSamlTypeGitHub ZeroTrustIdentityProviderUpdateResponseAccessSamlType = "github" - ZeroTrustIdentityProviderUpdateResponseAccessSamlTypeGoogleApps ZeroTrustIdentityProviderUpdateResponseAccessSamlType = "google-apps" - ZeroTrustIdentityProviderUpdateResponseAccessSamlTypeGoogle ZeroTrustIdentityProviderUpdateResponseAccessSamlType = "google" - ZeroTrustIdentityProviderUpdateResponseAccessSamlTypeLinkedin ZeroTrustIdentityProviderUpdateResponseAccessSamlType = "linkedin" - ZeroTrustIdentityProviderUpdateResponseAccessSamlTypeOidc ZeroTrustIdentityProviderUpdateResponseAccessSamlType = "oidc" - ZeroTrustIdentityProviderUpdateResponseAccessSamlTypeOkta ZeroTrustIdentityProviderUpdateResponseAccessSamlType = "okta" - ZeroTrustIdentityProviderUpdateResponseAccessSamlTypeOnelogin ZeroTrustIdentityProviderUpdateResponseAccessSamlType = "onelogin" - ZeroTrustIdentityProviderUpdateResponseAccessSamlTypePingone ZeroTrustIdentityProviderUpdateResponseAccessSamlType = "pingone" - ZeroTrustIdentityProviderUpdateResponseAccessSamlTypeYandex ZeroTrustIdentityProviderUpdateResponseAccessSamlType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderUpdateResponseAccessSamlScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderUpdateResponseAccessSamlScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessSamlScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessSamlScimConfig] -type zeroTrustIdentityProviderUpdateResponseAccessSamlScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessSamlScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessSamlScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderUpdateResponseAccessYandex struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderUpdateResponseAccessYandexConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderUpdateResponseAccessYandexType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderUpdateResponseAccessYandexScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderUpdateResponseAccessYandexJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessYandexJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderUpdateResponseAccessYandex] -type zeroTrustIdentityProviderUpdateResponseAccessYandexJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessYandex) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessYandexJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderUpdateResponseAccessYandex) implementsZeroTrustIdentityProviderUpdateResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessYandexConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProviderUpdateResponseAccessYandexConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessYandexConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessYandexConfig] -type zeroTrustIdentityProviderUpdateResponseAccessYandexConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessYandexConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessYandexConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessYandexType string - -const ( - ZeroTrustIdentityProviderUpdateResponseAccessYandexTypeOnetimepin ZeroTrustIdentityProviderUpdateResponseAccessYandexType = "onetimepin" - ZeroTrustIdentityProviderUpdateResponseAccessYandexTypeAzureAd ZeroTrustIdentityProviderUpdateResponseAccessYandexType = "azureAD" - ZeroTrustIdentityProviderUpdateResponseAccessYandexTypeSaml ZeroTrustIdentityProviderUpdateResponseAccessYandexType = "saml" - ZeroTrustIdentityProviderUpdateResponseAccessYandexTypeCentrify ZeroTrustIdentityProviderUpdateResponseAccessYandexType = "centrify" - ZeroTrustIdentityProviderUpdateResponseAccessYandexTypeFacebook ZeroTrustIdentityProviderUpdateResponseAccessYandexType = "facebook" - ZeroTrustIdentityProviderUpdateResponseAccessYandexTypeGitHub ZeroTrustIdentityProviderUpdateResponseAccessYandexType = "github" - ZeroTrustIdentityProviderUpdateResponseAccessYandexTypeGoogleApps ZeroTrustIdentityProviderUpdateResponseAccessYandexType = "google-apps" - ZeroTrustIdentityProviderUpdateResponseAccessYandexTypeGoogle ZeroTrustIdentityProviderUpdateResponseAccessYandexType = "google" - ZeroTrustIdentityProviderUpdateResponseAccessYandexTypeLinkedin ZeroTrustIdentityProviderUpdateResponseAccessYandexType = "linkedin" - ZeroTrustIdentityProviderUpdateResponseAccessYandexTypeOidc ZeroTrustIdentityProviderUpdateResponseAccessYandexType = "oidc" - ZeroTrustIdentityProviderUpdateResponseAccessYandexTypeOkta ZeroTrustIdentityProviderUpdateResponseAccessYandexType = "okta" - ZeroTrustIdentityProviderUpdateResponseAccessYandexTypeOnelogin ZeroTrustIdentityProviderUpdateResponseAccessYandexType = "onelogin" - ZeroTrustIdentityProviderUpdateResponseAccessYandexTypePingone ZeroTrustIdentityProviderUpdateResponseAccessYandexType = "pingone" - ZeroTrustIdentityProviderUpdateResponseAccessYandexTypeYandex ZeroTrustIdentityProviderUpdateResponseAccessYandexType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderUpdateResponseAccessYandexScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderUpdateResponseAccessYandexScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessYandexScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessYandexScimConfig] -type zeroTrustIdentityProviderUpdateResponseAccessYandexScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessYandexScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessYandexScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderUpdateResponseAccessOnetimepin struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config interface{} `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderUpdateResponseAccessOnetimepinJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessOnetimepinJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessOnetimepin] -type zeroTrustIdentityProviderUpdateResponseAccessOnetimepinJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessOnetimepin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessOnetimepinJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderUpdateResponseAccessOnetimepin) implementsZeroTrustIdentityProviderUpdateResponse() { -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinType string - -const ( - ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinTypeOnetimepin ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinType = "onetimepin" - ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinTypeAzureAd ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinType = "azureAD" - ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinTypeSaml ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinType = "saml" - ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinTypeCentrify ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinType = "centrify" - ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinTypeFacebook ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinType = "facebook" - ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinTypeGitHub ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinType = "github" - ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinTypeGoogleApps ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinType = "google-apps" - ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinTypeGoogle ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinType = "google" - ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinTypeLinkedin ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinType = "linkedin" - ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinTypeOidc ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinType = "oidc" - ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinTypeOkta ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinType = "okta" - ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinTypeOnelogin ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinType = "onelogin" - ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinTypePingone ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinType = "pingone" - ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinTypeYandex ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderUpdateResponseAccessOnetimepinScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseAccessOnetimepinScimConfigJSON contains -// the JSON metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinScimConfig] -type zeroTrustIdentityProviderUpdateResponseAccessOnetimepinScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseAccessOnetimepinScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseAccessOnetimepinScimConfigJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [ZeroTrustIdentityProviderListResponseAccessAzureAd], -// [ZeroTrustIdentityProviderListResponseAccessCentrify], -// [ZeroTrustIdentityProviderListResponseAccessFacebook], -// [ZeroTrustIdentityProviderListResponseAccessGitHub], -// [ZeroTrustIdentityProviderListResponseAccessGoogle], -// [ZeroTrustIdentityProviderListResponseAccessGoogleApps], -// [ZeroTrustIdentityProviderListResponseAccessLinkedin], -// [ZeroTrustIdentityProviderListResponseAccessOidc], -// [ZeroTrustIdentityProviderListResponseAccessOkta], -// [ZeroTrustIdentityProviderListResponseAccessOnelogin], -// [ZeroTrustIdentityProviderListResponseAccessPingone], -// [ZeroTrustIdentityProviderListResponseAccessSaml] or -// [ZeroTrustIdentityProviderListResponseAccessYandex]. -type ZeroTrustIdentityProviderListResponse interface { - implementsZeroTrustIdentityProviderListResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustIdentityProviderListResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderListResponseAccessAzureAd{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderListResponseAccessCentrify{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderListResponseAccessFacebook{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderListResponseAccessGitHub{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderListResponseAccessGoogle{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderListResponseAccessGoogleApps{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderListResponseAccessLinkedin{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderListResponseAccessOidc{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderListResponseAccessOkta{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderListResponseAccessOnelogin{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderListResponseAccessPingone{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderListResponseAccessSaml{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderListResponseAccessYandex{}), - }, - ) -} - -type ZeroTrustIdentityProviderListResponseAccessAzureAd struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderListResponseAccessAzureAdConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderListResponseAccessAzureAdType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderListResponseAccessAzureAdScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderListResponseAccessAzureAdJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessAzureAdJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderListResponseAccessAzureAd] -type zeroTrustIdentityProviderListResponseAccessAzureAdJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessAzureAdJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderListResponseAccessAzureAd) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessAzureAdConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // Should Cloudflare try to load authentication contexts from your account - ConditionalAccessEnabled bool `json:"conditional_access_enabled"` - // Your Azure directory uuid - DirectoryID string `json:"directory_id"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Should Cloudflare try to load groups from your account - SupportGroups bool `json:"support_groups"` - JSON zeroTrustIdentityProviderListResponseAccessAzureAdConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessAzureAdConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessAzureAdConfig] -type zeroTrustIdentityProviderListResponseAccessAzureAdConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - ConditionalAccessEnabled apijson.Field - DirectoryID apijson.Field - EmailClaimName apijson.Field - SupportGroups apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessAzureAdConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessAzureAdConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessAzureAdType string - -const ( - ZeroTrustIdentityProviderListResponseAccessAzureAdTypeOnetimepin ZeroTrustIdentityProviderListResponseAccessAzureAdType = "onetimepin" - ZeroTrustIdentityProviderListResponseAccessAzureAdTypeAzureAd ZeroTrustIdentityProviderListResponseAccessAzureAdType = "azureAD" - ZeroTrustIdentityProviderListResponseAccessAzureAdTypeSaml ZeroTrustIdentityProviderListResponseAccessAzureAdType = "saml" - ZeroTrustIdentityProviderListResponseAccessAzureAdTypeCentrify ZeroTrustIdentityProviderListResponseAccessAzureAdType = "centrify" - ZeroTrustIdentityProviderListResponseAccessAzureAdTypeFacebook ZeroTrustIdentityProviderListResponseAccessAzureAdType = "facebook" - ZeroTrustIdentityProviderListResponseAccessAzureAdTypeGitHub ZeroTrustIdentityProviderListResponseAccessAzureAdType = "github" - ZeroTrustIdentityProviderListResponseAccessAzureAdTypeGoogleApps ZeroTrustIdentityProviderListResponseAccessAzureAdType = "google-apps" - ZeroTrustIdentityProviderListResponseAccessAzureAdTypeGoogle ZeroTrustIdentityProviderListResponseAccessAzureAdType = "google" - ZeroTrustIdentityProviderListResponseAccessAzureAdTypeLinkedin ZeroTrustIdentityProviderListResponseAccessAzureAdType = "linkedin" - ZeroTrustIdentityProviderListResponseAccessAzureAdTypeOidc ZeroTrustIdentityProviderListResponseAccessAzureAdType = "oidc" - ZeroTrustIdentityProviderListResponseAccessAzureAdTypeOkta ZeroTrustIdentityProviderListResponseAccessAzureAdType = "okta" - ZeroTrustIdentityProviderListResponseAccessAzureAdTypeOnelogin ZeroTrustIdentityProviderListResponseAccessAzureAdType = "onelogin" - ZeroTrustIdentityProviderListResponseAccessAzureAdTypePingone ZeroTrustIdentityProviderListResponseAccessAzureAdType = "pingone" - ZeroTrustIdentityProviderListResponseAccessAzureAdTypeYandex ZeroTrustIdentityProviderListResponseAccessAzureAdType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderListResponseAccessAzureAdScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderListResponseAccessAzureAdScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessAzureAdScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessAzureAdScimConfig] -type zeroTrustIdentityProviderListResponseAccessAzureAdScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessAzureAdScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessAzureAdScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderListResponseAccessCentrify struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderListResponseAccessCentrifyConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderListResponseAccessCentrifyType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderListResponseAccessCentrifyScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderListResponseAccessCentrifyJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessCentrifyJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderListResponseAccessCentrify] -type zeroTrustIdentityProviderListResponseAccessCentrifyJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessCentrify) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessCentrifyJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderListResponseAccessCentrify) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessCentrifyConfig struct { - // Your centrify account url - CentrifyAccount string `json:"centrify_account"` - // Your centrify app id - CentrifyAppID string `json:"centrify_app_id"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - JSON zeroTrustIdentityProviderListResponseAccessCentrifyConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessCentrifyConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessCentrifyConfig] -type zeroTrustIdentityProviderListResponseAccessCentrifyConfigJSON struct { - CentrifyAccount apijson.Field - CentrifyAppID apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessCentrifyConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessCentrifyConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessCentrifyType string - -const ( - ZeroTrustIdentityProviderListResponseAccessCentrifyTypeOnetimepin ZeroTrustIdentityProviderListResponseAccessCentrifyType = "onetimepin" - ZeroTrustIdentityProviderListResponseAccessCentrifyTypeAzureAd ZeroTrustIdentityProviderListResponseAccessCentrifyType = "azureAD" - ZeroTrustIdentityProviderListResponseAccessCentrifyTypeSaml ZeroTrustIdentityProviderListResponseAccessCentrifyType = "saml" - ZeroTrustIdentityProviderListResponseAccessCentrifyTypeCentrify ZeroTrustIdentityProviderListResponseAccessCentrifyType = "centrify" - ZeroTrustIdentityProviderListResponseAccessCentrifyTypeFacebook ZeroTrustIdentityProviderListResponseAccessCentrifyType = "facebook" - ZeroTrustIdentityProviderListResponseAccessCentrifyTypeGitHub ZeroTrustIdentityProviderListResponseAccessCentrifyType = "github" - ZeroTrustIdentityProviderListResponseAccessCentrifyTypeGoogleApps ZeroTrustIdentityProviderListResponseAccessCentrifyType = "google-apps" - ZeroTrustIdentityProviderListResponseAccessCentrifyTypeGoogle ZeroTrustIdentityProviderListResponseAccessCentrifyType = "google" - ZeroTrustIdentityProviderListResponseAccessCentrifyTypeLinkedin ZeroTrustIdentityProviderListResponseAccessCentrifyType = "linkedin" - ZeroTrustIdentityProviderListResponseAccessCentrifyTypeOidc ZeroTrustIdentityProviderListResponseAccessCentrifyType = "oidc" - ZeroTrustIdentityProviderListResponseAccessCentrifyTypeOkta ZeroTrustIdentityProviderListResponseAccessCentrifyType = "okta" - ZeroTrustIdentityProviderListResponseAccessCentrifyTypeOnelogin ZeroTrustIdentityProviderListResponseAccessCentrifyType = "onelogin" - ZeroTrustIdentityProviderListResponseAccessCentrifyTypePingone ZeroTrustIdentityProviderListResponseAccessCentrifyType = "pingone" - ZeroTrustIdentityProviderListResponseAccessCentrifyTypeYandex ZeroTrustIdentityProviderListResponseAccessCentrifyType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderListResponseAccessCentrifyScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderListResponseAccessCentrifyScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessCentrifyScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessCentrifyScimConfig] -type zeroTrustIdentityProviderListResponseAccessCentrifyScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessCentrifyScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessCentrifyScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderListResponseAccessFacebook struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderListResponseAccessFacebookConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderListResponseAccessFacebookType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderListResponseAccessFacebookScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderListResponseAccessFacebookJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessFacebookJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderListResponseAccessFacebook] -type zeroTrustIdentityProviderListResponseAccessFacebookJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessFacebook) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessFacebookJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderListResponseAccessFacebook) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessFacebookConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProviderListResponseAccessFacebookConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessFacebookConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessFacebookConfig] -type zeroTrustIdentityProviderListResponseAccessFacebookConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessFacebookConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessFacebookConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessFacebookType string - -const ( - ZeroTrustIdentityProviderListResponseAccessFacebookTypeOnetimepin ZeroTrustIdentityProviderListResponseAccessFacebookType = "onetimepin" - ZeroTrustIdentityProviderListResponseAccessFacebookTypeAzureAd ZeroTrustIdentityProviderListResponseAccessFacebookType = "azureAD" - ZeroTrustIdentityProviderListResponseAccessFacebookTypeSaml ZeroTrustIdentityProviderListResponseAccessFacebookType = "saml" - ZeroTrustIdentityProviderListResponseAccessFacebookTypeCentrify ZeroTrustIdentityProviderListResponseAccessFacebookType = "centrify" - ZeroTrustIdentityProviderListResponseAccessFacebookTypeFacebook ZeroTrustIdentityProviderListResponseAccessFacebookType = "facebook" - ZeroTrustIdentityProviderListResponseAccessFacebookTypeGitHub ZeroTrustIdentityProviderListResponseAccessFacebookType = "github" - ZeroTrustIdentityProviderListResponseAccessFacebookTypeGoogleApps ZeroTrustIdentityProviderListResponseAccessFacebookType = "google-apps" - ZeroTrustIdentityProviderListResponseAccessFacebookTypeGoogle ZeroTrustIdentityProviderListResponseAccessFacebookType = "google" - ZeroTrustIdentityProviderListResponseAccessFacebookTypeLinkedin ZeroTrustIdentityProviderListResponseAccessFacebookType = "linkedin" - ZeroTrustIdentityProviderListResponseAccessFacebookTypeOidc ZeroTrustIdentityProviderListResponseAccessFacebookType = "oidc" - ZeroTrustIdentityProviderListResponseAccessFacebookTypeOkta ZeroTrustIdentityProviderListResponseAccessFacebookType = "okta" - ZeroTrustIdentityProviderListResponseAccessFacebookTypeOnelogin ZeroTrustIdentityProviderListResponseAccessFacebookType = "onelogin" - ZeroTrustIdentityProviderListResponseAccessFacebookTypePingone ZeroTrustIdentityProviderListResponseAccessFacebookType = "pingone" - ZeroTrustIdentityProviderListResponseAccessFacebookTypeYandex ZeroTrustIdentityProviderListResponseAccessFacebookType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderListResponseAccessFacebookScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderListResponseAccessFacebookScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessFacebookScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessFacebookScimConfig] -type zeroTrustIdentityProviderListResponseAccessFacebookScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessFacebookScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessFacebookScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderListResponseAccessGitHub struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderListResponseAccessGitHubConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderListResponseAccessGitHubType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderListResponseAccessGitHubScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderListResponseAccessGitHubJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessGitHubJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderListResponseAccessGitHub] -type zeroTrustIdentityProviderListResponseAccessGitHubJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessGitHub) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessGitHubJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderListResponseAccessGitHub) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessGitHubConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProviderListResponseAccessGitHubConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessGitHubConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessGitHubConfig] -type zeroTrustIdentityProviderListResponseAccessGitHubConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessGitHubConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessGitHubConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessGitHubType string - -const ( - ZeroTrustIdentityProviderListResponseAccessGitHubTypeOnetimepin ZeroTrustIdentityProviderListResponseAccessGitHubType = "onetimepin" - ZeroTrustIdentityProviderListResponseAccessGitHubTypeAzureAd ZeroTrustIdentityProviderListResponseAccessGitHubType = "azureAD" - ZeroTrustIdentityProviderListResponseAccessGitHubTypeSaml ZeroTrustIdentityProviderListResponseAccessGitHubType = "saml" - ZeroTrustIdentityProviderListResponseAccessGitHubTypeCentrify ZeroTrustIdentityProviderListResponseAccessGitHubType = "centrify" - ZeroTrustIdentityProviderListResponseAccessGitHubTypeFacebook ZeroTrustIdentityProviderListResponseAccessGitHubType = "facebook" - ZeroTrustIdentityProviderListResponseAccessGitHubTypeGitHub ZeroTrustIdentityProviderListResponseAccessGitHubType = "github" - ZeroTrustIdentityProviderListResponseAccessGitHubTypeGoogleApps ZeroTrustIdentityProviderListResponseAccessGitHubType = "google-apps" - ZeroTrustIdentityProviderListResponseAccessGitHubTypeGoogle ZeroTrustIdentityProviderListResponseAccessGitHubType = "google" - ZeroTrustIdentityProviderListResponseAccessGitHubTypeLinkedin ZeroTrustIdentityProviderListResponseAccessGitHubType = "linkedin" - ZeroTrustIdentityProviderListResponseAccessGitHubTypeOidc ZeroTrustIdentityProviderListResponseAccessGitHubType = "oidc" - ZeroTrustIdentityProviderListResponseAccessGitHubTypeOkta ZeroTrustIdentityProviderListResponseAccessGitHubType = "okta" - ZeroTrustIdentityProviderListResponseAccessGitHubTypeOnelogin ZeroTrustIdentityProviderListResponseAccessGitHubType = "onelogin" - ZeroTrustIdentityProviderListResponseAccessGitHubTypePingone ZeroTrustIdentityProviderListResponseAccessGitHubType = "pingone" - ZeroTrustIdentityProviderListResponseAccessGitHubTypeYandex ZeroTrustIdentityProviderListResponseAccessGitHubType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderListResponseAccessGitHubScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderListResponseAccessGitHubScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessGitHubScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessGitHubScimConfig] -type zeroTrustIdentityProviderListResponseAccessGitHubScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessGitHubScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessGitHubScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderListResponseAccessGoogle struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderListResponseAccessGoogleConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderListResponseAccessGoogleType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderListResponseAccessGoogleScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderListResponseAccessGoogleJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessGoogleJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderListResponseAccessGoogle] -type zeroTrustIdentityProviderListResponseAccessGoogleJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessGoogle) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessGoogleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderListResponseAccessGoogle) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessGoogleConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - JSON zeroTrustIdentityProviderListResponseAccessGoogleConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessGoogleConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessGoogleConfig] -type zeroTrustIdentityProviderListResponseAccessGoogleConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessGoogleConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessGoogleConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessGoogleType string - -const ( - ZeroTrustIdentityProviderListResponseAccessGoogleTypeOnetimepin ZeroTrustIdentityProviderListResponseAccessGoogleType = "onetimepin" - ZeroTrustIdentityProviderListResponseAccessGoogleTypeAzureAd ZeroTrustIdentityProviderListResponseAccessGoogleType = "azureAD" - ZeroTrustIdentityProviderListResponseAccessGoogleTypeSaml ZeroTrustIdentityProviderListResponseAccessGoogleType = "saml" - ZeroTrustIdentityProviderListResponseAccessGoogleTypeCentrify ZeroTrustIdentityProviderListResponseAccessGoogleType = "centrify" - ZeroTrustIdentityProviderListResponseAccessGoogleTypeFacebook ZeroTrustIdentityProviderListResponseAccessGoogleType = "facebook" - ZeroTrustIdentityProviderListResponseAccessGoogleTypeGitHub ZeroTrustIdentityProviderListResponseAccessGoogleType = "github" - ZeroTrustIdentityProviderListResponseAccessGoogleTypeGoogleApps ZeroTrustIdentityProviderListResponseAccessGoogleType = "google-apps" - ZeroTrustIdentityProviderListResponseAccessGoogleTypeGoogle ZeroTrustIdentityProviderListResponseAccessGoogleType = "google" - ZeroTrustIdentityProviderListResponseAccessGoogleTypeLinkedin ZeroTrustIdentityProviderListResponseAccessGoogleType = "linkedin" - ZeroTrustIdentityProviderListResponseAccessGoogleTypeOidc ZeroTrustIdentityProviderListResponseAccessGoogleType = "oidc" - ZeroTrustIdentityProviderListResponseAccessGoogleTypeOkta ZeroTrustIdentityProviderListResponseAccessGoogleType = "okta" - ZeroTrustIdentityProviderListResponseAccessGoogleTypeOnelogin ZeroTrustIdentityProviderListResponseAccessGoogleType = "onelogin" - ZeroTrustIdentityProviderListResponseAccessGoogleTypePingone ZeroTrustIdentityProviderListResponseAccessGoogleType = "pingone" - ZeroTrustIdentityProviderListResponseAccessGoogleTypeYandex ZeroTrustIdentityProviderListResponseAccessGoogleType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderListResponseAccessGoogleScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderListResponseAccessGoogleScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessGoogleScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessGoogleScimConfig] -type zeroTrustIdentityProviderListResponseAccessGoogleScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessGoogleScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessGoogleScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderListResponseAccessGoogleApps struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderListResponseAccessGoogleAppsConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderListResponseAccessGoogleAppsType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderListResponseAccessGoogleAppsScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderListResponseAccessGoogleAppsJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessGoogleAppsJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderListResponseAccessGoogleApps] -type zeroTrustIdentityProviderListResponseAccessGoogleAppsJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessGoogleApps) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessGoogleAppsJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderListResponseAccessGoogleApps) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessGoogleAppsConfig struct { - // Your companies TLD - AppsDomain string `json:"apps_domain"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - JSON zeroTrustIdentityProviderListResponseAccessGoogleAppsConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessGoogleAppsConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessGoogleAppsConfig] -type zeroTrustIdentityProviderListResponseAccessGoogleAppsConfigJSON struct { - AppsDomain apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessGoogleAppsConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessGoogleAppsConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessGoogleAppsType string - -const ( - ZeroTrustIdentityProviderListResponseAccessGoogleAppsTypeOnetimepin ZeroTrustIdentityProviderListResponseAccessGoogleAppsType = "onetimepin" - ZeroTrustIdentityProviderListResponseAccessGoogleAppsTypeAzureAd ZeroTrustIdentityProviderListResponseAccessGoogleAppsType = "azureAD" - ZeroTrustIdentityProviderListResponseAccessGoogleAppsTypeSaml ZeroTrustIdentityProviderListResponseAccessGoogleAppsType = "saml" - ZeroTrustIdentityProviderListResponseAccessGoogleAppsTypeCentrify ZeroTrustIdentityProviderListResponseAccessGoogleAppsType = "centrify" - ZeroTrustIdentityProviderListResponseAccessGoogleAppsTypeFacebook ZeroTrustIdentityProviderListResponseAccessGoogleAppsType = "facebook" - ZeroTrustIdentityProviderListResponseAccessGoogleAppsTypeGitHub ZeroTrustIdentityProviderListResponseAccessGoogleAppsType = "github" - ZeroTrustIdentityProviderListResponseAccessGoogleAppsTypeGoogleApps ZeroTrustIdentityProviderListResponseAccessGoogleAppsType = "google-apps" - ZeroTrustIdentityProviderListResponseAccessGoogleAppsTypeGoogle ZeroTrustIdentityProviderListResponseAccessGoogleAppsType = "google" - ZeroTrustIdentityProviderListResponseAccessGoogleAppsTypeLinkedin ZeroTrustIdentityProviderListResponseAccessGoogleAppsType = "linkedin" - ZeroTrustIdentityProviderListResponseAccessGoogleAppsTypeOidc ZeroTrustIdentityProviderListResponseAccessGoogleAppsType = "oidc" - ZeroTrustIdentityProviderListResponseAccessGoogleAppsTypeOkta ZeroTrustIdentityProviderListResponseAccessGoogleAppsType = "okta" - ZeroTrustIdentityProviderListResponseAccessGoogleAppsTypeOnelogin ZeroTrustIdentityProviderListResponseAccessGoogleAppsType = "onelogin" - ZeroTrustIdentityProviderListResponseAccessGoogleAppsTypePingone ZeroTrustIdentityProviderListResponseAccessGoogleAppsType = "pingone" - ZeroTrustIdentityProviderListResponseAccessGoogleAppsTypeYandex ZeroTrustIdentityProviderListResponseAccessGoogleAppsType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderListResponseAccessGoogleAppsScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderListResponseAccessGoogleAppsScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessGoogleAppsScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessGoogleAppsScimConfig] -type zeroTrustIdentityProviderListResponseAccessGoogleAppsScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessGoogleAppsScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessGoogleAppsScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderListResponseAccessLinkedin struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderListResponseAccessLinkedinConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderListResponseAccessLinkedinType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderListResponseAccessLinkedinScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderListResponseAccessLinkedinJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessLinkedinJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderListResponseAccessLinkedin] -type zeroTrustIdentityProviderListResponseAccessLinkedinJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessLinkedin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessLinkedinJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderListResponseAccessLinkedin) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessLinkedinConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProviderListResponseAccessLinkedinConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessLinkedinConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessLinkedinConfig] -type zeroTrustIdentityProviderListResponseAccessLinkedinConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessLinkedinConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessLinkedinConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessLinkedinType string - -const ( - ZeroTrustIdentityProviderListResponseAccessLinkedinTypeOnetimepin ZeroTrustIdentityProviderListResponseAccessLinkedinType = "onetimepin" - ZeroTrustIdentityProviderListResponseAccessLinkedinTypeAzureAd ZeroTrustIdentityProviderListResponseAccessLinkedinType = "azureAD" - ZeroTrustIdentityProviderListResponseAccessLinkedinTypeSaml ZeroTrustIdentityProviderListResponseAccessLinkedinType = "saml" - ZeroTrustIdentityProviderListResponseAccessLinkedinTypeCentrify ZeroTrustIdentityProviderListResponseAccessLinkedinType = "centrify" - ZeroTrustIdentityProviderListResponseAccessLinkedinTypeFacebook ZeroTrustIdentityProviderListResponseAccessLinkedinType = "facebook" - ZeroTrustIdentityProviderListResponseAccessLinkedinTypeGitHub ZeroTrustIdentityProviderListResponseAccessLinkedinType = "github" - ZeroTrustIdentityProviderListResponseAccessLinkedinTypeGoogleApps ZeroTrustIdentityProviderListResponseAccessLinkedinType = "google-apps" - ZeroTrustIdentityProviderListResponseAccessLinkedinTypeGoogle ZeroTrustIdentityProviderListResponseAccessLinkedinType = "google" - ZeroTrustIdentityProviderListResponseAccessLinkedinTypeLinkedin ZeroTrustIdentityProviderListResponseAccessLinkedinType = "linkedin" - ZeroTrustIdentityProviderListResponseAccessLinkedinTypeOidc ZeroTrustIdentityProviderListResponseAccessLinkedinType = "oidc" - ZeroTrustIdentityProviderListResponseAccessLinkedinTypeOkta ZeroTrustIdentityProviderListResponseAccessLinkedinType = "okta" - ZeroTrustIdentityProviderListResponseAccessLinkedinTypeOnelogin ZeroTrustIdentityProviderListResponseAccessLinkedinType = "onelogin" - ZeroTrustIdentityProviderListResponseAccessLinkedinTypePingone ZeroTrustIdentityProviderListResponseAccessLinkedinType = "pingone" - ZeroTrustIdentityProviderListResponseAccessLinkedinTypeYandex ZeroTrustIdentityProviderListResponseAccessLinkedinType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderListResponseAccessLinkedinScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderListResponseAccessLinkedinScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessLinkedinScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessLinkedinScimConfig] -type zeroTrustIdentityProviderListResponseAccessLinkedinScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessLinkedinScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessLinkedinScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderListResponseAccessOidc struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderListResponseAccessOidcConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderListResponseAccessOidcType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderListResponseAccessOidcScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderListResponseAccessOidcJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessOidcJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderListResponseAccessOidc] -type zeroTrustIdentityProviderListResponseAccessOidcJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessOidc) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessOidcJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderListResponseAccessOidc) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessOidcConfig struct { - // The authorization_endpoint URL of your IdP - AuthURL string `json:"auth_url"` - // The jwks_uri endpoint of your IdP to allow the IdP keys to sign the tokens - CertsURL string `json:"certs_url"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // OAuth scopes - Scopes []string `json:"scopes"` - // The token_endpoint URL of your IdP - TokenURL string `json:"token_url"` - JSON zeroTrustIdentityProviderListResponseAccessOidcConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessOidcConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderListResponseAccessOidcConfig] -type zeroTrustIdentityProviderListResponseAccessOidcConfigJSON struct { - AuthURL apijson.Field - CertsURL apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - Scopes apijson.Field - TokenURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessOidcConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessOidcConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessOidcType string - -const ( - ZeroTrustIdentityProviderListResponseAccessOidcTypeOnetimepin ZeroTrustIdentityProviderListResponseAccessOidcType = "onetimepin" - ZeroTrustIdentityProviderListResponseAccessOidcTypeAzureAd ZeroTrustIdentityProviderListResponseAccessOidcType = "azureAD" - ZeroTrustIdentityProviderListResponseAccessOidcTypeSaml ZeroTrustIdentityProviderListResponseAccessOidcType = "saml" - ZeroTrustIdentityProviderListResponseAccessOidcTypeCentrify ZeroTrustIdentityProviderListResponseAccessOidcType = "centrify" - ZeroTrustIdentityProviderListResponseAccessOidcTypeFacebook ZeroTrustIdentityProviderListResponseAccessOidcType = "facebook" - ZeroTrustIdentityProviderListResponseAccessOidcTypeGitHub ZeroTrustIdentityProviderListResponseAccessOidcType = "github" - ZeroTrustIdentityProviderListResponseAccessOidcTypeGoogleApps ZeroTrustIdentityProviderListResponseAccessOidcType = "google-apps" - ZeroTrustIdentityProviderListResponseAccessOidcTypeGoogle ZeroTrustIdentityProviderListResponseAccessOidcType = "google" - ZeroTrustIdentityProviderListResponseAccessOidcTypeLinkedin ZeroTrustIdentityProviderListResponseAccessOidcType = "linkedin" - ZeroTrustIdentityProviderListResponseAccessOidcTypeOidc ZeroTrustIdentityProviderListResponseAccessOidcType = "oidc" - ZeroTrustIdentityProviderListResponseAccessOidcTypeOkta ZeroTrustIdentityProviderListResponseAccessOidcType = "okta" - ZeroTrustIdentityProviderListResponseAccessOidcTypeOnelogin ZeroTrustIdentityProviderListResponseAccessOidcType = "onelogin" - ZeroTrustIdentityProviderListResponseAccessOidcTypePingone ZeroTrustIdentityProviderListResponseAccessOidcType = "pingone" - ZeroTrustIdentityProviderListResponseAccessOidcTypeYandex ZeroTrustIdentityProviderListResponseAccessOidcType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderListResponseAccessOidcScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderListResponseAccessOidcScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessOidcScimConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessOidcScimConfig] -type zeroTrustIdentityProviderListResponseAccessOidcScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessOidcScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessOidcScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderListResponseAccessOkta struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderListResponseAccessOktaConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderListResponseAccessOktaType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderListResponseAccessOktaScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderListResponseAccessOktaJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessOktaJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderListResponseAccessOkta] -type zeroTrustIdentityProviderListResponseAccessOktaJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessOktaJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderListResponseAccessOkta) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessOktaConfig struct { - // Your okta authorization server id - AuthorizationServerID string `json:"authorization_server_id"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Your okta account url - OktaAccount string `json:"okta_account"` - JSON zeroTrustIdentityProviderListResponseAccessOktaConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessOktaConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderListResponseAccessOktaConfig] -type zeroTrustIdentityProviderListResponseAccessOktaConfigJSON struct { - AuthorizationServerID apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - OktaAccount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessOktaConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessOktaConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessOktaType string - -const ( - ZeroTrustIdentityProviderListResponseAccessOktaTypeOnetimepin ZeroTrustIdentityProviderListResponseAccessOktaType = "onetimepin" - ZeroTrustIdentityProviderListResponseAccessOktaTypeAzureAd ZeroTrustIdentityProviderListResponseAccessOktaType = "azureAD" - ZeroTrustIdentityProviderListResponseAccessOktaTypeSaml ZeroTrustIdentityProviderListResponseAccessOktaType = "saml" - ZeroTrustIdentityProviderListResponseAccessOktaTypeCentrify ZeroTrustIdentityProviderListResponseAccessOktaType = "centrify" - ZeroTrustIdentityProviderListResponseAccessOktaTypeFacebook ZeroTrustIdentityProviderListResponseAccessOktaType = "facebook" - ZeroTrustIdentityProviderListResponseAccessOktaTypeGitHub ZeroTrustIdentityProviderListResponseAccessOktaType = "github" - ZeroTrustIdentityProviderListResponseAccessOktaTypeGoogleApps ZeroTrustIdentityProviderListResponseAccessOktaType = "google-apps" - ZeroTrustIdentityProviderListResponseAccessOktaTypeGoogle ZeroTrustIdentityProviderListResponseAccessOktaType = "google" - ZeroTrustIdentityProviderListResponseAccessOktaTypeLinkedin ZeroTrustIdentityProviderListResponseAccessOktaType = "linkedin" - ZeroTrustIdentityProviderListResponseAccessOktaTypeOidc ZeroTrustIdentityProviderListResponseAccessOktaType = "oidc" - ZeroTrustIdentityProviderListResponseAccessOktaTypeOkta ZeroTrustIdentityProviderListResponseAccessOktaType = "okta" - ZeroTrustIdentityProviderListResponseAccessOktaTypeOnelogin ZeroTrustIdentityProviderListResponseAccessOktaType = "onelogin" - ZeroTrustIdentityProviderListResponseAccessOktaTypePingone ZeroTrustIdentityProviderListResponseAccessOktaType = "pingone" - ZeroTrustIdentityProviderListResponseAccessOktaTypeYandex ZeroTrustIdentityProviderListResponseAccessOktaType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderListResponseAccessOktaScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderListResponseAccessOktaScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessOktaScimConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessOktaScimConfig] -type zeroTrustIdentityProviderListResponseAccessOktaScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessOktaScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessOktaScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderListResponseAccessOnelogin struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderListResponseAccessOneloginConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderListResponseAccessOneloginType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderListResponseAccessOneloginScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderListResponseAccessOneloginJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessOneloginJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderListResponseAccessOnelogin] -type zeroTrustIdentityProviderListResponseAccessOneloginJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessOnelogin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessOneloginJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderListResponseAccessOnelogin) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessOneloginConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Your OneLogin account url - OneloginAccount string `json:"onelogin_account"` - JSON zeroTrustIdentityProviderListResponseAccessOneloginConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessOneloginConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessOneloginConfig] -type zeroTrustIdentityProviderListResponseAccessOneloginConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - OneloginAccount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessOneloginConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessOneloginConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessOneloginType string - -const ( - ZeroTrustIdentityProviderListResponseAccessOneloginTypeOnetimepin ZeroTrustIdentityProviderListResponseAccessOneloginType = "onetimepin" - ZeroTrustIdentityProviderListResponseAccessOneloginTypeAzureAd ZeroTrustIdentityProviderListResponseAccessOneloginType = "azureAD" - ZeroTrustIdentityProviderListResponseAccessOneloginTypeSaml ZeroTrustIdentityProviderListResponseAccessOneloginType = "saml" - ZeroTrustIdentityProviderListResponseAccessOneloginTypeCentrify ZeroTrustIdentityProviderListResponseAccessOneloginType = "centrify" - ZeroTrustIdentityProviderListResponseAccessOneloginTypeFacebook ZeroTrustIdentityProviderListResponseAccessOneloginType = "facebook" - ZeroTrustIdentityProviderListResponseAccessOneloginTypeGitHub ZeroTrustIdentityProviderListResponseAccessOneloginType = "github" - ZeroTrustIdentityProviderListResponseAccessOneloginTypeGoogleApps ZeroTrustIdentityProviderListResponseAccessOneloginType = "google-apps" - ZeroTrustIdentityProviderListResponseAccessOneloginTypeGoogle ZeroTrustIdentityProviderListResponseAccessOneloginType = "google" - ZeroTrustIdentityProviderListResponseAccessOneloginTypeLinkedin ZeroTrustIdentityProviderListResponseAccessOneloginType = "linkedin" - ZeroTrustIdentityProviderListResponseAccessOneloginTypeOidc ZeroTrustIdentityProviderListResponseAccessOneloginType = "oidc" - ZeroTrustIdentityProviderListResponseAccessOneloginTypeOkta ZeroTrustIdentityProviderListResponseAccessOneloginType = "okta" - ZeroTrustIdentityProviderListResponseAccessOneloginTypeOnelogin ZeroTrustIdentityProviderListResponseAccessOneloginType = "onelogin" - ZeroTrustIdentityProviderListResponseAccessOneloginTypePingone ZeroTrustIdentityProviderListResponseAccessOneloginType = "pingone" - ZeroTrustIdentityProviderListResponseAccessOneloginTypeYandex ZeroTrustIdentityProviderListResponseAccessOneloginType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderListResponseAccessOneloginScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderListResponseAccessOneloginScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessOneloginScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessOneloginScimConfig] -type zeroTrustIdentityProviderListResponseAccessOneloginScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessOneloginScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessOneloginScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderListResponseAccessPingone struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderListResponseAccessPingoneConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderListResponseAccessPingoneType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderListResponseAccessPingoneScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderListResponseAccessPingoneJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessPingoneJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderListResponseAccessPingone] -type zeroTrustIdentityProviderListResponseAccessPingoneJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessPingone) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessPingoneJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderListResponseAccessPingone) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessPingoneConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Your PingOne environment identifier - PingEnvID string `json:"ping_env_id"` - JSON zeroTrustIdentityProviderListResponseAccessPingoneConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessPingoneConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessPingoneConfig] -type zeroTrustIdentityProviderListResponseAccessPingoneConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - PingEnvID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessPingoneConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessPingoneConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessPingoneType string - -const ( - ZeroTrustIdentityProviderListResponseAccessPingoneTypeOnetimepin ZeroTrustIdentityProviderListResponseAccessPingoneType = "onetimepin" - ZeroTrustIdentityProviderListResponseAccessPingoneTypeAzureAd ZeroTrustIdentityProviderListResponseAccessPingoneType = "azureAD" - ZeroTrustIdentityProviderListResponseAccessPingoneTypeSaml ZeroTrustIdentityProviderListResponseAccessPingoneType = "saml" - ZeroTrustIdentityProviderListResponseAccessPingoneTypeCentrify ZeroTrustIdentityProviderListResponseAccessPingoneType = "centrify" - ZeroTrustIdentityProviderListResponseAccessPingoneTypeFacebook ZeroTrustIdentityProviderListResponseAccessPingoneType = "facebook" - ZeroTrustIdentityProviderListResponseAccessPingoneTypeGitHub ZeroTrustIdentityProviderListResponseAccessPingoneType = "github" - ZeroTrustIdentityProviderListResponseAccessPingoneTypeGoogleApps ZeroTrustIdentityProviderListResponseAccessPingoneType = "google-apps" - ZeroTrustIdentityProviderListResponseAccessPingoneTypeGoogle ZeroTrustIdentityProviderListResponseAccessPingoneType = "google" - ZeroTrustIdentityProviderListResponseAccessPingoneTypeLinkedin ZeroTrustIdentityProviderListResponseAccessPingoneType = "linkedin" - ZeroTrustIdentityProviderListResponseAccessPingoneTypeOidc ZeroTrustIdentityProviderListResponseAccessPingoneType = "oidc" - ZeroTrustIdentityProviderListResponseAccessPingoneTypeOkta ZeroTrustIdentityProviderListResponseAccessPingoneType = "okta" - ZeroTrustIdentityProviderListResponseAccessPingoneTypeOnelogin ZeroTrustIdentityProviderListResponseAccessPingoneType = "onelogin" - ZeroTrustIdentityProviderListResponseAccessPingoneTypePingone ZeroTrustIdentityProviderListResponseAccessPingoneType = "pingone" - ZeroTrustIdentityProviderListResponseAccessPingoneTypeYandex ZeroTrustIdentityProviderListResponseAccessPingoneType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderListResponseAccessPingoneScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderListResponseAccessPingoneScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessPingoneScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessPingoneScimConfig] -type zeroTrustIdentityProviderListResponseAccessPingoneScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessPingoneScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessPingoneScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderListResponseAccessSaml struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderListResponseAccessSamlConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderListResponseAccessSamlType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderListResponseAccessSamlScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderListResponseAccessSamlJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessSamlJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderListResponseAccessSaml] -type zeroTrustIdentityProviderListResponseAccessSamlJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessSamlJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderListResponseAccessSaml) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessSamlConfig struct { - // A list of SAML attribute names that will be added to your signed JWT token and - // can be used in SAML policy rules. - Attributes []string `json:"attributes"` - // The attribute name for email in the SAML response. - EmailAttributeName string `json:"email_attribute_name"` - // Add a list of attribute names that will be returned in the response header from - // the Access callback. - HeaderAttributes []ZeroTrustIdentityProviderListResponseAccessSamlConfigHeaderAttribute `json:"header_attributes"` - // X509 certificate to verify the signature in the SAML authentication response - IdpPublicCerts []string `json:"idp_public_certs"` - // IdP Entity ID or Issuer URL - IssuerURL string `json:"issuer_url"` - // Sign the SAML authentication request with Access credentials. To verify the - // signature, use the public key from the Access certs endpoints. - SignRequest bool `json:"sign_request"` - // URL to send the SAML authentication requests to - SSOTargetURL string `json:"sso_target_url"` - JSON zeroTrustIdentityProviderListResponseAccessSamlConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessSamlConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderListResponseAccessSamlConfig] -type zeroTrustIdentityProviderListResponseAccessSamlConfigJSON struct { - Attributes apijson.Field - EmailAttributeName apijson.Field - HeaderAttributes apijson.Field - IdpPublicCerts apijson.Field - IssuerURL apijson.Field - SignRequest apijson.Field - SSOTargetURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessSamlConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessSamlConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderListResponseAccessSamlConfigHeaderAttribute struct { - // attribute name from the IDP - AttributeName string `json:"attribute_name"` - // header that will be added on the request to the origin - HeaderName string `json:"header_name"` - JSON zeroTrustIdentityProviderListResponseAccessSamlConfigHeaderAttributeJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessSamlConfigHeaderAttributeJSON -// contains the JSON metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessSamlConfigHeaderAttribute] -type zeroTrustIdentityProviderListResponseAccessSamlConfigHeaderAttributeJSON struct { - AttributeName apijson.Field - HeaderName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessSamlConfigHeaderAttribute) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessSamlConfigHeaderAttributeJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessSamlType string - -const ( - ZeroTrustIdentityProviderListResponseAccessSamlTypeOnetimepin ZeroTrustIdentityProviderListResponseAccessSamlType = "onetimepin" - ZeroTrustIdentityProviderListResponseAccessSamlTypeAzureAd ZeroTrustIdentityProviderListResponseAccessSamlType = "azureAD" - ZeroTrustIdentityProviderListResponseAccessSamlTypeSaml ZeroTrustIdentityProviderListResponseAccessSamlType = "saml" - ZeroTrustIdentityProviderListResponseAccessSamlTypeCentrify ZeroTrustIdentityProviderListResponseAccessSamlType = "centrify" - ZeroTrustIdentityProviderListResponseAccessSamlTypeFacebook ZeroTrustIdentityProviderListResponseAccessSamlType = "facebook" - ZeroTrustIdentityProviderListResponseAccessSamlTypeGitHub ZeroTrustIdentityProviderListResponseAccessSamlType = "github" - ZeroTrustIdentityProviderListResponseAccessSamlTypeGoogleApps ZeroTrustIdentityProviderListResponseAccessSamlType = "google-apps" - ZeroTrustIdentityProviderListResponseAccessSamlTypeGoogle ZeroTrustIdentityProviderListResponseAccessSamlType = "google" - ZeroTrustIdentityProviderListResponseAccessSamlTypeLinkedin ZeroTrustIdentityProviderListResponseAccessSamlType = "linkedin" - ZeroTrustIdentityProviderListResponseAccessSamlTypeOidc ZeroTrustIdentityProviderListResponseAccessSamlType = "oidc" - ZeroTrustIdentityProviderListResponseAccessSamlTypeOkta ZeroTrustIdentityProviderListResponseAccessSamlType = "okta" - ZeroTrustIdentityProviderListResponseAccessSamlTypeOnelogin ZeroTrustIdentityProviderListResponseAccessSamlType = "onelogin" - ZeroTrustIdentityProviderListResponseAccessSamlTypePingone ZeroTrustIdentityProviderListResponseAccessSamlType = "pingone" - ZeroTrustIdentityProviderListResponseAccessSamlTypeYandex ZeroTrustIdentityProviderListResponseAccessSamlType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderListResponseAccessSamlScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderListResponseAccessSamlScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessSamlScimConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessSamlScimConfig] -type zeroTrustIdentityProviderListResponseAccessSamlScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessSamlScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessSamlScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderListResponseAccessYandex struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderListResponseAccessYandexConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderListResponseAccessYandexType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderListResponseAccessYandexScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderListResponseAccessYandexJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessYandexJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderListResponseAccessYandex] -type zeroTrustIdentityProviderListResponseAccessYandexJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessYandex) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessYandexJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderListResponseAccessYandex) implementsZeroTrustIdentityProviderListResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessYandexConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProviderListResponseAccessYandexConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessYandexConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessYandexConfig] -type zeroTrustIdentityProviderListResponseAccessYandexConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessYandexConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessYandexConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderListResponseAccessYandexType string - -const ( - ZeroTrustIdentityProviderListResponseAccessYandexTypeOnetimepin ZeroTrustIdentityProviderListResponseAccessYandexType = "onetimepin" - ZeroTrustIdentityProviderListResponseAccessYandexTypeAzureAd ZeroTrustIdentityProviderListResponseAccessYandexType = "azureAD" - ZeroTrustIdentityProviderListResponseAccessYandexTypeSaml ZeroTrustIdentityProviderListResponseAccessYandexType = "saml" - ZeroTrustIdentityProviderListResponseAccessYandexTypeCentrify ZeroTrustIdentityProviderListResponseAccessYandexType = "centrify" - ZeroTrustIdentityProviderListResponseAccessYandexTypeFacebook ZeroTrustIdentityProviderListResponseAccessYandexType = "facebook" - ZeroTrustIdentityProviderListResponseAccessYandexTypeGitHub ZeroTrustIdentityProviderListResponseAccessYandexType = "github" - ZeroTrustIdentityProviderListResponseAccessYandexTypeGoogleApps ZeroTrustIdentityProviderListResponseAccessYandexType = "google-apps" - ZeroTrustIdentityProviderListResponseAccessYandexTypeGoogle ZeroTrustIdentityProviderListResponseAccessYandexType = "google" - ZeroTrustIdentityProviderListResponseAccessYandexTypeLinkedin ZeroTrustIdentityProviderListResponseAccessYandexType = "linkedin" - ZeroTrustIdentityProviderListResponseAccessYandexTypeOidc ZeroTrustIdentityProviderListResponseAccessYandexType = "oidc" - ZeroTrustIdentityProviderListResponseAccessYandexTypeOkta ZeroTrustIdentityProviderListResponseAccessYandexType = "okta" - ZeroTrustIdentityProviderListResponseAccessYandexTypeOnelogin ZeroTrustIdentityProviderListResponseAccessYandexType = "onelogin" - ZeroTrustIdentityProviderListResponseAccessYandexTypePingone ZeroTrustIdentityProviderListResponseAccessYandexType = "pingone" - ZeroTrustIdentityProviderListResponseAccessYandexTypeYandex ZeroTrustIdentityProviderListResponseAccessYandexType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderListResponseAccessYandexScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderListResponseAccessYandexScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseAccessYandexScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderListResponseAccessYandexScimConfig] -type zeroTrustIdentityProviderListResponseAccessYandexScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseAccessYandexScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseAccessYandexScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderDeleteResponse struct { - // UUID - ID string `json:"id"` - JSON zeroTrustIdentityProviderDeleteResponseJSON `json:"-"` -} - -// zeroTrustIdentityProviderDeleteResponseJSON contains the JSON metadata for the -// struct [ZeroTrustIdentityProviderDeleteResponse] -type zeroTrustIdentityProviderDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [ZeroTrustIdentityProviderGetResponseAccessAzureAd], -// [ZeroTrustIdentityProviderGetResponseAccessCentrify], -// [ZeroTrustIdentityProviderGetResponseAccessFacebook], -// [ZeroTrustIdentityProviderGetResponseAccessGitHub], -// [ZeroTrustIdentityProviderGetResponseAccessGoogle], -// [ZeroTrustIdentityProviderGetResponseAccessGoogleApps], -// [ZeroTrustIdentityProviderGetResponseAccessLinkedin], -// [ZeroTrustIdentityProviderGetResponseAccessOidc], -// [ZeroTrustIdentityProviderGetResponseAccessOkta], -// [ZeroTrustIdentityProviderGetResponseAccessOnelogin], -// [ZeroTrustIdentityProviderGetResponseAccessPingone], -// [ZeroTrustIdentityProviderGetResponseAccessSaml], -// [ZeroTrustIdentityProviderGetResponseAccessYandex] or -// [ZeroTrustIdentityProviderGetResponseAccessOnetimepin]. -type ZeroTrustIdentityProviderGetResponse interface { - implementsZeroTrustIdentityProviderGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustIdentityProviderGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderGetResponseAccessAzureAd{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderGetResponseAccessCentrify{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderGetResponseAccessFacebook{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderGetResponseAccessGitHub{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderGetResponseAccessGoogle{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderGetResponseAccessGoogleApps{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderGetResponseAccessLinkedin{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderGetResponseAccessOidc{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderGetResponseAccessOkta{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderGetResponseAccessOnelogin{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderGetResponseAccessPingone{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderGetResponseAccessSaml{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderGetResponseAccessYandex{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustIdentityProviderGetResponseAccessOnetimepin{}), - }, - ) -} - -type ZeroTrustIdentityProviderGetResponseAccessAzureAd struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderGetResponseAccessAzureAdConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderGetResponseAccessAzureAdType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderGetResponseAccessAzureAdScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderGetResponseAccessAzureAdJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessAzureAdJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderGetResponseAccessAzureAd] -type zeroTrustIdentityProviderGetResponseAccessAzureAdJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessAzureAd) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessAzureAdJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderGetResponseAccessAzureAd) implementsZeroTrustIdentityProviderGetResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessAzureAdConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // Should Cloudflare try to load authentication contexts from your account - ConditionalAccessEnabled bool `json:"conditional_access_enabled"` - // Your Azure directory uuid - DirectoryID string `json:"directory_id"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Should Cloudflare try to load groups from your account - SupportGroups bool `json:"support_groups"` - JSON zeroTrustIdentityProviderGetResponseAccessAzureAdConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessAzureAdConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessAzureAdConfig] -type zeroTrustIdentityProviderGetResponseAccessAzureAdConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - ConditionalAccessEnabled apijson.Field - DirectoryID apijson.Field - EmailClaimName apijson.Field - SupportGroups apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessAzureAdConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessAzureAdConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessAzureAdType string - -const ( - ZeroTrustIdentityProviderGetResponseAccessAzureAdTypeOnetimepin ZeroTrustIdentityProviderGetResponseAccessAzureAdType = "onetimepin" - ZeroTrustIdentityProviderGetResponseAccessAzureAdTypeAzureAd ZeroTrustIdentityProviderGetResponseAccessAzureAdType = "azureAD" - ZeroTrustIdentityProviderGetResponseAccessAzureAdTypeSaml ZeroTrustIdentityProviderGetResponseAccessAzureAdType = "saml" - ZeroTrustIdentityProviderGetResponseAccessAzureAdTypeCentrify ZeroTrustIdentityProviderGetResponseAccessAzureAdType = "centrify" - ZeroTrustIdentityProviderGetResponseAccessAzureAdTypeFacebook ZeroTrustIdentityProviderGetResponseAccessAzureAdType = "facebook" - ZeroTrustIdentityProviderGetResponseAccessAzureAdTypeGitHub ZeroTrustIdentityProviderGetResponseAccessAzureAdType = "github" - ZeroTrustIdentityProviderGetResponseAccessAzureAdTypeGoogleApps ZeroTrustIdentityProviderGetResponseAccessAzureAdType = "google-apps" - ZeroTrustIdentityProviderGetResponseAccessAzureAdTypeGoogle ZeroTrustIdentityProviderGetResponseAccessAzureAdType = "google" - ZeroTrustIdentityProviderGetResponseAccessAzureAdTypeLinkedin ZeroTrustIdentityProviderGetResponseAccessAzureAdType = "linkedin" - ZeroTrustIdentityProviderGetResponseAccessAzureAdTypeOidc ZeroTrustIdentityProviderGetResponseAccessAzureAdType = "oidc" - ZeroTrustIdentityProviderGetResponseAccessAzureAdTypeOkta ZeroTrustIdentityProviderGetResponseAccessAzureAdType = "okta" - ZeroTrustIdentityProviderGetResponseAccessAzureAdTypeOnelogin ZeroTrustIdentityProviderGetResponseAccessAzureAdType = "onelogin" - ZeroTrustIdentityProviderGetResponseAccessAzureAdTypePingone ZeroTrustIdentityProviderGetResponseAccessAzureAdType = "pingone" - ZeroTrustIdentityProviderGetResponseAccessAzureAdTypeYandex ZeroTrustIdentityProviderGetResponseAccessAzureAdType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderGetResponseAccessAzureAdScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderGetResponseAccessAzureAdScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessAzureAdScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessAzureAdScimConfig] -type zeroTrustIdentityProviderGetResponseAccessAzureAdScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessAzureAdScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessAzureAdScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderGetResponseAccessCentrify struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderGetResponseAccessCentrifyConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderGetResponseAccessCentrifyType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderGetResponseAccessCentrifyScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderGetResponseAccessCentrifyJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessCentrifyJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderGetResponseAccessCentrify] -type zeroTrustIdentityProviderGetResponseAccessCentrifyJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessCentrify) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessCentrifyJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderGetResponseAccessCentrify) implementsZeroTrustIdentityProviderGetResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessCentrifyConfig struct { - // Your centrify account url - CentrifyAccount string `json:"centrify_account"` - // Your centrify app id - CentrifyAppID string `json:"centrify_app_id"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - JSON zeroTrustIdentityProviderGetResponseAccessCentrifyConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessCentrifyConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessCentrifyConfig] -type zeroTrustIdentityProviderGetResponseAccessCentrifyConfigJSON struct { - CentrifyAccount apijson.Field - CentrifyAppID apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessCentrifyConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessCentrifyConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessCentrifyType string - -const ( - ZeroTrustIdentityProviderGetResponseAccessCentrifyTypeOnetimepin ZeroTrustIdentityProviderGetResponseAccessCentrifyType = "onetimepin" - ZeroTrustIdentityProviderGetResponseAccessCentrifyTypeAzureAd ZeroTrustIdentityProviderGetResponseAccessCentrifyType = "azureAD" - ZeroTrustIdentityProviderGetResponseAccessCentrifyTypeSaml ZeroTrustIdentityProviderGetResponseAccessCentrifyType = "saml" - ZeroTrustIdentityProviderGetResponseAccessCentrifyTypeCentrify ZeroTrustIdentityProviderGetResponseAccessCentrifyType = "centrify" - ZeroTrustIdentityProviderGetResponseAccessCentrifyTypeFacebook ZeroTrustIdentityProviderGetResponseAccessCentrifyType = "facebook" - ZeroTrustIdentityProviderGetResponseAccessCentrifyTypeGitHub ZeroTrustIdentityProviderGetResponseAccessCentrifyType = "github" - ZeroTrustIdentityProviderGetResponseAccessCentrifyTypeGoogleApps ZeroTrustIdentityProviderGetResponseAccessCentrifyType = "google-apps" - ZeroTrustIdentityProviderGetResponseAccessCentrifyTypeGoogle ZeroTrustIdentityProviderGetResponseAccessCentrifyType = "google" - ZeroTrustIdentityProviderGetResponseAccessCentrifyTypeLinkedin ZeroTrustIdentityProviderGetResponseAccessCentrifyType = "linkedin" - ZeroTrustIdentityProviderGetResponseAccessCentrifyTypeOidc ZeroTrustIdentityProviderGetResponseAccessCentrifyType = "oidc" - ZeroTrustIdentityProviderGetResponseAccessCentrifyTypeOkta ZeroTrustIdentityProviderGetResponseAccessCentrifyType = "okta" - ZeroTrustIdentityProviderGetResponseAccessCentrifyTypeOnelogin ZeroTrustIdentityProviderGetResponseAccessCentrifyType = "onelogin" - ZeroTrustIdentityProviderGetResponseAccessCentrifyTypePingone ZeroTrustIdentityProviderGetResponseAccessCentrifyType = "pingone" - ZeroTrustIdentityProviderGetResponseAccessCentrifyTypeYandex ZeroTrustIdentityProviderGetResponseAccessCentrifyType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderGetResponseAccessCentrifyScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderGetResponseAccessCentrifyScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessCentrifyScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessCentrifyScimConfig] -type zeroTrustIdentityProviderGetResponseAccessCentrifyScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessCentrifyScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessCentrifyScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderGetResponseAccessFacebook struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderGetResponseAccessFacebookConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderGetResponseAccessFacebookType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderGetResponseAccessFacebookScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderGetResponseAccessFacebookJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessFacebookJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderGetResponseAccessFacebook] -type zeroTrustIdentityProviderGetResponseAccessFacebookJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessFacebook) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessFacebookJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderGetResponseAccessFacebook) implementsZeroTrustIdentityProviderGetResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessFacebookConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProviderGetResponseAccessFacebookConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessFacebookConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessFacebookConfig] -type zeroTrustIdentityProviderGetResponseAccessFacebookConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessFacebookConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessFacebookConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessFacebookType string - -const ( - ZeroTrustIdentityProviderGetResponseAccessFacebookTypeOnetimepin ZeroTrustIdentityProviderGetResponseAccessFacebookType = "onetimepin" - ZeroTrustIdentityProviderGetResponseAccessFacebookTypeAzureAd ZeroTrustIdentityProviderGetResponseAccessFacebookType = "azureAD" - ZeroTrustIdentityProviderGetResponseAccessFacebookTypeSaml ZeroTrustIdentityProviderGetResponseAccessFacebookType = "saml" - ZeroTrustIdentityProviderGetResponseAccessFacebookTypeCentrify ZeroTrustIdentityProviderGetResponseAccessFacebookType = "centrify" - ZeroTrustIdentityProviderGetResponseAccessFacebookTypeFacebook ZeroTrustIdentityProviderGetResponseAccessFacebookType = "facebook" - ZeroTrustIdentityProviderGetResponseAccessFacebookTypeGitHub ZeroTrustIdentityProviderGetResponseAccessFacebookType = "github" - ZeroTrustIdentityProviderGetResponseAccessFacebookTypeGoogleApps ZeroTrustIdentityProviderGetResponseAccessFacebookType = "google-apps" - ZeroTrustIdentityProviderGetResponseAccessFacebookTypeGoogle ZeroTrustIdentityProviderGetResponseAccessFacebookType = "google" - ZeroTrustIdentityProviderGetResponseAccessFacebookTypeLinkedin ZeroTrustIdentityProviderGetResponseAccessFacebookType = "linkedin" - ZeroTrustIdentityProviderGetResponseAccessFacebookTypeOidc ZeroTrustIdentityProviderGetResponseAccessFacebookType = "oidc" - ZeroTrustIdentityProviderGetResponseAccessFacebookTypeOkta ZeroTrustIdentityProviderGetResponseAccessFacebookType = "okta" - ZeroTrustIdentityProviderGetResponseAccessFacebookTypeOnelogin ZeroTrustIdentityProviderGetResponseAccessFacebookType = "onelogin" - ZeroTrustIdentityProviderGetResponseAccessFacebookTypePingone ZeroTrustIdentityProviderGetResponseAccessFacebookType = "pingone" - ZeroTrustIdentityProviderGetResponseAccessFacebookTypeYandex ZeroTrustIdentityProviderGetResponseAccessFacebookType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderGetResponseAccessFacebookScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderGetResponseAccessFacebookScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessFacebookScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessFacebookScimConfig] -type zeroTrustIdentityProviderGetResponseAccessFacebookScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessFacebookScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessFacebookScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderGetResponseAccessGitHub struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderGetResponseAccessGitHubConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderGetResponseAccessGitHubType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderGetResponseAccessGitHubScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderGetResponseAccessGitHubJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessGitHubJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderGetResponseAccessGitHub] -type zeroTrustIdentityProviderGetResponseAccessGitHubJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessGitHub) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessGitHubJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderGetResponseAccessGitHub) implementsZeroTrustIdentityProviderGetResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessGitHubConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProviderGetResponseAccessGitHubConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessGitHubConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderGetResponseAccessGitHubConfig] -type zeroTrustIdentityProviderGetResponseAccessGitHubConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessGitHubConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessGitHubConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessGitHubType string - -const ( - ZeroTrustIdentityProviderGetResponseAccessGitHubTypeOnetimepin ZeroTrustIdentityProviderGetResponseAccessGitHubType = "onetimepin" - ZeroTrustIdentityProviderGetResponseAccessGitHubTypeAzureAd ZeroTrustIdentityProviderGetResponseAccessGitHubType = "azureAD" - ZeroTrustIdentityProviderGetResponseAccessGitHubTypeSaml ZeroTrustIdentityProviderGetResponseAccessGitHubType = "saml" - ZeroTrustIdentityProviderGetResponseAccessGitHubTypeCentrify ZeroTrustIdentityProviderGetResponseAccessGitHubType = "centrify" - ZeroTrustIdentityProviderGetResponseAccessGitHubTypeFacebook ZeroTrustIdentityProviderGetResponseAccessGitHubType = "facebook" - ZeroTrustIdentityProviderGetResponseAccessGitHubTypeGitHub ZeroTrustIdentityProviderGetResponseAccessGitHubType = "github" - ZeroTrustIdentityProviderGetResponseAccessGitHubTypeGoogleApps ZeroTrustIdentityProviderGetResponseAccessGitHubType = "google-apps" - ZeroTrustIdentityProviderGetResponseAccessGitHubTypeGoogle ZeroTrustIdentityProviderGetResponseAccessGitHubType = "google" - ZeroTrustIdentityProviderGetResponseAccessGitHubTypeLinkedin ZeroTrustIdentityProviderGetResponseAccessGitHubType = "linkedin" - ZeroTrustIdentityProviderGetResponseAccessGitHubTypeOidc ZeroTrustIdentityProviderGetResponseAccessGitHubType = "oidc" - ZeroTrustIdentityProviderGetResponseAccessGitHubTypeOkta ZeroTrustIdentityProviderGetResponseAccessGitHubType = "okta" - ZeroTrustIdentityProviderGetResponseAccessGitHubTypeOnelogin ZeroTrustIdentityProviderGetResponseAccessGitHubType = "onelogin" - ZeroTrustIdentityProviderGetResponseAccessGitHubTypePingone ZeroTrustIdentityProviderGetResponseAccessGitHubType = "pingone" - ZeroTrustIdentityProviderGetResponseAccessGitHubTypeYandex ZeroTrustIdentityProviderGetResponseAccessGitHubType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderGetResponseAccessGitHubScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderGetResponseAccessGitHubScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessGitHubScimConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessGitHubScimConfig] -type zeroTrustIdentityProviderGetResponseAccessGitHubScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessGitHubScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessGitHubScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderGetResponseAccessGoogle struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderGetResponseAccessGoogleConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderGetResponseAccessGoogleType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderGetResponseAccessGoogleScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderGetResponseAccessGoogleJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessGoogleJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderGetResponseAccessGoogle] -type zeroTrustIdentityProviderGetResponseAccessGoogleJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessGoogle) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessGoogleJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderGetResponseAccessGoogle) implementsZeroTrustIdentityProviderGetResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessGoogleConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - JSON zeroTrustIdentityProviderGetResponseAccessGoogleConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessGoogleConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderGetResponseAccessGoogleConfig] -type zeroTrustIdentityProviderGetResponseAccessGoogleConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessGoogleConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessGoogleConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessGoogleType string - -const ( - ZeroTrustIdentityProviderGetResponseAccessGoogleTypeOnetimepin ZeroTrustIdentityProviderGetResponseAccessGoogleType = "onetimepin" - ZeroTrustIdentityProviderGetResponseAccessGoogleTypeAzureAd ZeroTrustIdentityProviderGetResponseAccessGoogleType = "azureAD" - ZeroTrustIdentityProviderGetResponseAccessGoogleTypeSaml ZeroTrustIdentityProviderGetResponseAccessGoogleType = "saml" - ZeroTrustIdentityProviderGetResponseAccessGoogleTypeCentrify ZeroTrustIdentityProviderGetResponseAccessGoogleType = "centrify" - ZeroTrustIdentityProviderGetResponseAccessGoogleTypeFacebook ZeroTrustIdentityProviderGetResponseAccessGoogleType = "facebook" - ZeroTrustIdentityProviderGetResponseAccessGoogleTypeGitHub ZeroTrustIdentityProviderGetResponseAccessGoogleType = "github" - ZeroTrustIdentityProviderGetResponseAccessGoogleTypeGoogleApps ZeroTrustIdentityProviderGetResponseAccessGoogleType = "google-apps" - ZeroTrustIdentityProviderGetResponseAccessGoogleTypeGoogle ZeroTrustIdentityProviderGetResponseAccessGoogleType = "google" - ZeroTrustIdentityProviderGetResponseAccessGoogleTypeLinkedin ZeroTrustIdentityProviderGetResponseAccessGoogleType = "linkedin" - ZeroTrustIdentityProviderGetResponseAccessGoogleTypeOidc ZeroTrustIdentityProviderGetResponseAccessGoogleType = "oidc" - ZeroTrustIdentityProviderGetResponseAccessGoogleTypeOkta ZeroTrustIdentityProviderGetResponseAccessGoogleType = "okta" - ZeroTrustIdentityProviderGetResponseAccessGoogleTypeOnelogin ZeroTrustIdentityProviderGetResponseAccessGoogleType = "onelogin" - ZeroTrustIdentityProviderGetResponseAccessGoogleTypePingone ZeroTrustIdentityProviderGetResponseAccessGoogleType = "pingone" - ZeroTrustIdentityProviderGetResponseAccessGoogleTypeYandex ZeroTrustIdentityProviderGetResponseAccessGoogleType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderGetResponseAccessGoogleScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderGetResponseAccessGoogleScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessGoogleScimConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessGoogleScimConfig] -type zeroTrustIdentityProviderGetResponseAccessGoogleScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessGoogleScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessGoogleScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderGetResponseAccessGoogleApps struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderGetResponseAccessGoogleAppsConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderGetResponseAccessGoogleAppsType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderGetResponseAccessGoogleAppsScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderGetResponseAccessGoogleAppsJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessGoogleAppsJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderGetResponseAccessGoogleApps] -type zeroTrustIdentityProviderGetResponseAccessGoogleAppsJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessGoogleApps) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessGoogleAppsJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderGetResponseAccessGoogleApps) implementsZeroTrustIdentityProviderGetResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessGoogleAppsConfig struct { - // Your companies TLD - AppsDomain string `json:"apps_domain"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - JSON zeroTrustIdentityProviderGetResponseAccessGoogleAppsConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessGoogleAppsConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessGoogleAppsConfig] -type zeroTrustIdentityProviderGetResponseAccessGoogleAppsConfigJSON struct { - AppsDomain apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessGoogleAppsConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessGoogleAppsConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessGoogleAppsType string - -const ( - ZeroTrustIdentityProviderGetResponseAccessGoogleAppsTypeOnetimepin ZeroTrustIdentityProviderGetResponseAccessGoogleAppsType = "onetimepin" - ZeroTrustIdentityProviderGetResponseAccessGoogleAppsTypeAzureAd ZeroTrustIdentityProviderGetResponseAccessGoogleAppsType = "azureAD" - ZeroTrustIdentityProviderGetResponseAccessGoogleAppsTypeSaml ZeroTrustIdentityProviderGetResponseAccessGoogleAppsType = "saml" - ZeroTrustIdentityProviderGetResponseAccessGoogleAppsTypeCentrify ZeroTrustIdentityProviderGetResponseAccessGoogleAppsType = "centrify" - ZeroTrustIdentityProviderGetResponseAccessGoogleAppsTypeFacebook ZeroTrustIdentityProviderGetResponseAccessGoogleAppsType = "facebook" - ZeroTrustIdentityProviderGetResponseAccessGoogleAppsTypeGitHub ZeroTrustIdentityProviderGetResponseAccessGoogleAppsType = "github" - ZeroTrustIdentityProviderGetResponseAccessGoogleAppsTypeGoogleApps ZeroTrustIdentityProviderGetResponseAccessGoogleAppsType = "google-apps" - ZeroTrustIdentityProviderGetResponseAccessGoogleAppsTypeGoogle ZeroTrustIdentityProviderGetResponseAccessGoogleAppsType = "google" - ZeroTrustIdentityProviderGetResponseAccessGoogleAppsTypeLinkedin ZeroTrustIdentityProviderGetResponseAccessGoogleAppsType = "linkedin" - ZeroTrustIdentityProviderGetResponseAccessGoogleAppsTypeOidc ZeroTrustIdentityProviderGetResponseAccessGoogleAppsType = "oidc" - ZeroTrustIdentityProviderGetResponseAccessGoogleAppsTypeOkta ZeroTrustIdentityProviderGetResponseAccessGoogleAppsType = "okta" - ZeroTrustIdentityProviderGetResponseAccessGoogleAppsTypeOnelogin ZeroTrustIdentityProviderGetResponseAccessGoogleAppsType = "onelogin" - ZeroTrustIdentityProviderGetResponseAccessGoogleAppsTypePingone ZeroTrustIdentityProviderGetResponseAccessGoogleAppsType = "pingone" - ZeroTrustIdentityProviderGetResponseAccessGoogleAppsTypeYandex ZeroTrustIdentityProviderGetResponseAccessGoogleAppsType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderGetResponseAccessGoogleAppsScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderGetResponseAccessGoogleAppsScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessGoogleAppsScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessGoogleAppsScimConfig] -type zeroTrustIdentityProviderGetResponseAccessGoogleAppsScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessGoogleAppsScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessGoogleAppsScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderGetResponseAccessLinkedin struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderGetResponseAccessLinkedinConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderGetResponseAccessLinkedinType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderGetResponseAccessLinkedinScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderGetResponseAccessLinkedinJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessLinkedinJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderGetResponseAccessLinkedin] -type zeroTrustIdentityProviderGetResponseAccessLinkedinJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessLinkedin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessLinkedinJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderGetResponseAccessLinkedin) implementsZeroTrustIdentityProviderGetResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessLinkedinConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProviderGetResponseAccessLinkedinConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessLinkedinConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessLinkedinConfig] -type zeroTrustIdentityProviderGetResponseAccessLinkedinConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessLinkedinConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessLinkedinConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessLinkedinType string - -const ( - ZeroTrustIdentityProviderGetResponseAccessLinkedinTypeOnetimepin ZeroTrustIdentityProviderGetResponseAccessLinkedinType = "onetimepin" - ZeroTrustIdentityProviderGetResponseAccessLinkedinTypeAzureAd ZeroTrustIdentityProviderGetResponseAccessLinkedinType = "azureAD" - ZeroTrustIdentityProviderGetResponseAccessLinkedinTypeSaml ZeroTrustIdentityProviderGetResponseAccessLinkedinType = "saml" - ZeroTrustIdentityProviderGetResponseAccessLinkedinTypeCentrify ZeroTrustIdentityProviderGetResponseAccessLinkedinType = "centrify" - ZeroTrustIdentityProviderGetResponseAccessLinkedinTypeFacebook ZeroTrustIdentityProviderGetResponseAccessLinkedinType = "facebook" - ZeroTrustIdentityProviderGetResponseAccessLinkedinTypeGitHub ZeroTrustIdentityProviderGetResponseAccessLinkedinType = "github" - ZeroTrustIdentityProviderGetResponseAccessLinkedinTypeGoogleApps ZeroTrustIdentityProviderGetResponseAccessLinkedinType = "google-apps" - ZeroTrustIdentityProviderGetResponseAccessLinkedinTypeGoogle ZeroTrustIdentityProviderGetResponseAccessLinkedinType = "google" - ZeroTrustIdentityProviderGetResponseAccessLinkedinTypeLinkedin ZeroTrustIdentityProviderGetResponseAccessLinkedinType = "linkedin" - ZeroTrustIdentityProviderGetResponseAccessLinkedinTypeOidc ZeroTrustIdentityProviderGetResponseAccessLinkedinType = "oidc" - ZeroTrustIdentityProviderGetResponseAccessLinkedinTypeOkta ZeroTrustIdentityProviderGetResponseAccessLinkedinType = "okta" - ZeroTrustIdentityProviderGetResponseAccessLinkedinTypeOnelogin ZeroTrustIdentityProviderGetResponseAccessLinkedinType = "onelogin" - ZeroTrustIdentityProviderGetResponseAccessLinkedinTypePingone ZeroTrustIdentityProviderGetResponseAccessLinkedinType = "pingone" - ZeroTrustIdentityProviderGetResponseAccessLinkedinTypeYandex ZeroTrustIdentityProviderGetResponseAccessLinkedinType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderGetResponseAccessLinkedinScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderGetResponseAccessLinkedinScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessLinkedinScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessLinkedinScimConfig] -type zeroTrustIdentityProviderGetResponseAccessLinkedinScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessLinkedinScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessLinkedinScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderGetResponseAccessOidc struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderGetResponseAccessOidcConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderGetResponseAccessOidcType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderGetResponseAccessOidcScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderGetResponseAccessOidcJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessOidcJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderGetResponseAccessOidc] -type zeroTrustIdentityProviderGetResponseAccessOidcJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessOidc) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessOidcJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderGetResponseAccessOidc) implementsZeroTrustIdentityProviderGetResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessOidcConfig struct { - // The authorization_endpoint URL of your IdP - AuthURL string `json:"auth_url"` - // The jwks_uri endpoint of your IdP to allow the IdP keys to sign the tokens - CertsURL string `json:"certs_url"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // OAuth scopes - Scopes []string `json:"scopes"` - // The token_endpoint URL of your IdP - TokenURL string `json:"token_url"` - JSON zeroTrustIdentityProviderGetResponseAccessOidcConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessOidcConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderGetResponseAccessOidcConfig] -type zeroTrustIdentityProviderGetResponseAccessOidcConfigJSON struct { - AuthURL apijson.Field - CertsURL apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - Scopes apijson.Field - TokenURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessOidcConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessOidcConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessOidcType string - -const ( - ZeroTrustIdentityProviderGetResponseAccessOidcTypeOnetimepin ZeroTrustIdentityProviderGetResponseAccessOidcType = "onetimepin" - ZeroTrustIdentityProviderGetResponseAccessOidcTypeAzureAd ZeroTrustIdentityProviderGetResponseAccessOidcType = "azureAD" - ZeroTrustIdentityProviderGetResponseAccessOidcTypeSaml ZeroTrustIdentityProviderGetResponseAccessOidcType = "saml" - ZeroTrustIdentityProviderGetResponseAccessOidcTypeCentrify ZeroTrustIdentityProviderGetResponseAccessOidcType = "centrify" - ZeroTrustIdentityProviderGetResponseAccessOidcTypeFacebook ZeroTrustIdentityProviderGetResponseAccessOidcType = "facebook" - ZeroTrustIdentityProviderGetResponseAccessOidcTypeGitHub ZeroTrustIdentityProviderGetResponseAccessOidcType = "github" - ZeroTrustIdentityProviderGetResponseAccessOidcTypeGoogleApps ZeroTrustIdentityProviderGetResponseAccessOidcType = "google-apps" - ZeroTrustIdentityProviderGetResponseAccessOidcTypeGoogle ZeroTrustIdentityProviderGetResponseAccessOidcType = "google" - ZeroTrustIdentityProviderGetResponseAccessOidcTypeLinkedin ZeroTrustIdentityProviderGetResponseAccessOidcType = "linkedin" - ZeroTrustIdentityProviderGetResponseAccessOidcTypeOidc ZeroTrustIdentityProviderGetResponseAccessOidcType = "oidc" - ZeroTrustIdentityProviderGetResponseAccessOidcTypeOkta ZeroTrustIdentityProviderGetResponseAccessOidcType = "okta" - ZeroTrustIdentityProviderGetResponseAccessOidcTypeOnelogin ZeroTrustIdentityProviderGetResponseAccessOidcType = "onelogin" - ZeroTrustIdentityProviderGetResponseAccessOidcTypePingone ZeroTrustIdentityProviderGetResponseAccessOidcType = "pingone" - ZeroTrustIdentityProviderGetResponseAccessOidcTypeYandex ZeroTrustIdentityProviderGetResponseAccessOidcType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderGetResponseAccessOidcScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderGetResponseAccessOidcScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessOidcScimConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessOidcScimConfig] -type zeroTrustIdentityProviderGetResponseAccessOidcScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessOidcScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessOidcScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderGetResponseAccessOkta struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderGetResponseAccessOktaConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderGetResponseAccessOktaType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderGetResponseAccessOktaScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderGetResponseAccessOktaJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessOktaJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderGetResponseAccessOkta] -type zeroTrustIdentityProviderGetResponseAccessOktaJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessOkta) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessOktaJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderGetResponseAccessOkta) implementsZeroTrustIdentityProviderGetResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessOktaConfig struct { - // Your okta authorization server id - AuthorizationServerID string `json:"authorization_server_id"` - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Your okta account url - OktaAccount string `json:"okta_account"` - JSON zeroTrustIdentityProviderGetResponseAccessOktaConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessOktaConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderGetResponseAccessOktaConfig] -type zeroTrustIdentityProviderGetResponseAccessOktaConfigJSON struct { - AuthorizationServerID apijson.Field - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - OktaAccount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessOktaConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessOktaConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessOktaType string - -const ( - ZeroTrustIdentityProviderGetResponseAccessOktaTypeOnetimepin ZeroTrustIdentityProviderGetResponseAccessOktaType = "onetimepin" - ZeroTrustIdentityProviderGetResponseAccessOktaTypeAzureAd ZeroTrustIdentityProviderGetResponseAccessOktaType = "azureAD" - ZeroTrustIdentityProviderGetResponseAccessOktaTypeSaml ZeroTrustIdentityProviderGetResponseAccessOktaType = "saml" - ZeroTrustIdentityProviderGetResponseAccessOktaTypeCentrify ZeroTrustIdentityProviderGetResponseAccessOktaType = "centrify" - ZeroTrustIdentityProviderGetResponseAccessOktaTypeFacebook ZeroTrustIdentityProviderGetResponseAccessOktaType = "facebook" - ZeroTrustIdentityProviderGetResponseAccessOktaTypeGitHub ZeroTrustIdentityProviderGetResponseAccessOktaType = "github" - ZeroTrustIdentityProviderGetResponseAccessOktaTypeGoogleApps ZeroTrustIdentityProviderGetResponseAccessOktaType = "google-apps" - ZeroTrustIdentityProviderGetResponseAccessOktaTypeGoogle ZeroTrustIdentityProviderGetResponseAccessOktaType = "google" - ZeroTrustIdentityProviderGetResponseAccessOktaTypeLinkedin ZeroTrustIdentityProviderGetResponseAccessOktaType = "linkedin" - ZeroTrustIdentityProviderGetResponseAccessOktaTypeOidc ZeroTrustIdentityProviderGetResponseAccessOktaType = "oidc" - ZeroTrustIdentityProviderGetResponseAccessOktaTypeOkta ZeroTrustIdentityProviderGetResponseAccessOktaType = "okta" - ZeroTrustIdentityProviderGetResponseAccessOktaTypeOnelogin ZeroTrustIdentityProviderGetResponseAccessOktaType = "onelogin" - ZeroTrustIdentityProviderGetResponseAccessOktaTypePingone ZeroTrustIdentityProviderGetResponseAccessOktaType = "pingone" - ZeroTrustIdentityProviderGetResponseAccessOktaTypeYandex ZeroTrustIdentityProviderGetResponseAccessOktaType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderGetResponseAccessOktaScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderGetResponseAccessOktaScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessOktaScimConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessOktaScimConfig] -type zeroTrustIdentityProviderGetResponseAccessOktaScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessOktaScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessOktaScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderGetResponseAccessOnelogin struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderGetResponseAccessOneloginConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderGetResponseAccessOneloginType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderGetResponseAccessOneloginScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderGetResponseAccessOneloginJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessOneloginJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderGetResponseAccessOnelogin] -type zeroTrustIdentityProviderGetResponseAccessOneloginJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessOnelogin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessOneloginJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderGetResponseAccessOnelogin) implementsZeroTrustIdentityProviderGetResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessOneloginConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Your OneLogin account url - OneloginAccount string `json:"onelogin_account"` - JSON zeroTrustIdentityProviderGetResponseAccessOneloginConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessOneloginConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessOneloginConfig] -type zeroTrustIdentityProviderGetResponseAccessOneloginConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - OneloginAccount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessOneloginConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessOneloginConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessOneloginType string - -const ( - ZeroTrustIdentityProviderGetResponseAccessOneloginTypeOnetimepin ZeroTrustIdentityProviderGetResponseAccessOneloginType = "onetimepin" - ZeroTrustIdentityProviderGetResponseAccessOneloginTypeAzureAd ZeroTrustIdentityProviderGetResponseAccessOneloginType = "azureAD" - ZeroTrustIdentityProviderGetResponseAccessOneloginTypeSaml ZeroTrustIdentityProviderGetResponseAccessOneloginType = "saml" - ZeroTrustIdentityProviderGetResponseAccessOneloginTypeCentrify ZeroTrustIdentityProviderGetResponseAccessOneloginType = "centrify" - ZeroTrustIdentityProviderGetResponseAccessOneloginTypeFacebook ZeroTrustIdentityProviderGetResponseAccessOneloginType = "facebook" - ZeroTrustIdentityProviderGetResponseAccessOneloginTypeGitHub ZeroTrustIdentityProviderGetResponseAccessOneloginType = "github" - ZeroTrustIdentityProviderGetResponseAccessOneloginTypeGoogleApps ZeroTrustIdentityProviderGetResponseAccessOneloginType = "google-apps" - ZeroTrustIdentityProviderGetResponseAccessOneloginTypeGoogle ZeroTrustIdentityProviderGetResponseAccessOneloginType = "google" - ZeroTrustIdentityProviderGetResponseAccessOneloginTypeLinkedin ZeroTrustIdentityProviderGetResponseAccessOneloginType = "linkedin" - ZeroTrustIdentityProviderGetResponseAccessOneloginTypeOidc ZeroTrustIdentityProviderGetResponseAccessOneloginType = "oidc" - ZeroTrustIdentityProviderGetResponseAccessOneloginTypeOkta ZeroTrustIdentityProviderGetResponseAccessOneloginType = "okta" - ZeroTrustIdentityProviderGetResponseAccessOneloginTypeOnelogin ZeroTrustIdentityProviderGetResponseAccessOneloginType = "onelogin" - ZeroTrustIdentityProviderGetResponseAccessOneloginTypePingone ZeroTrustIdentityProviderGetResponseAccessOneloginType = "pingone" - ZeroTrustIdentityProviderGetResponseAccessOneloginTypeYandex ZeroTrustIdentityProviderGetResponseAccessOneloginType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderGetResponseAccessOneloginScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderGetResponseAccessOneloginScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessOneloginScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessOneloginScimConfig] -type zeroTrustIdentityProviderGetResponseAccessOneloginScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessOneloginScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessOneloginScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderGetResponseAccessPingone struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderGetResponseAccessPingoneConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderGetResponseAccessPingoneType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderGetResponseAccessPingoneScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderGetResponseAccessPingoneJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessPingoneJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderGetResponseAccessPingone] -type zeroTrustIdentityProviderGetResponseAccessPingoneJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessPingone) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessPingoneJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderGetResponseAccessPingone) implementsZeroTrustIdentityProviderGetResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessPingoneConfig struct { - // Custom claims - Claims []string `json:"claims"` - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - // The claim name for email in the id_token response. - EmailClaimName string `json:"email_claim_name"` - // Your PingOne environment identifier - PingEnvID string `json:"ping_env_id"` - JSON zeroTrustIdentityProviderGetResponseAccessPingoneConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessPingoneConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessPingoneConfig] -type zeroTrustIdentityProviderGetResponseAccessPingoneConfigJSON struct { - Claims apijson.Field - ClientID apijson.Field - ClientSecret apijson.Field - EmailClaimName apijson.Field - PingEnvID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessPingoneConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessPingoneConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessPingoneType string - -const ( - ZeroTrustIdentityProviderGetResponseAccessPingoneTypeOnetimepin ZeroTrustIdentityProviderGetResponseAccessPingoneType = "onetimepin" - ZeroTrustIdentityProviderGetResponseAccessPingoneTypeAzureAd ZeroTrustIdentityProviderGetResponseAccessPingoneType = "azureAD" - ZeroTrustIdentityProviderGetResponseAccessPingoneTypeSaml ZeroTrustIdentityProviderGetResponseAccessPingoneType = "saml" - ZeroTrustIdentityProviderGetResponseAccessPingoneTypeCentrify ZeroTrustIdentityProviderGetResponseAccessPingoneType = "centrify" - ZeroTrustIdentityProviderGetResponseAccessPingoneTypeFacebook ZeroTrustIdentityProviderGetResponseAccessPingoneType = "facebook" - ZeroTrustIdentityProviderGetResponseAccessPingoneTypeGitHub ZeroTrustIdentityProviderGetResponseAccessPingoneType = "github" - ZeroTrustIdentityProviderGetResponseAccessPingoneTypeGoogleApps ZeroTrustIdentityProviderGetResponseAccessPingoneType = "google-apps" - ZeroTrustIdentityProviderGetResponseAccessPingoneTypeGoogle ZeroTrustIdentityProviderGetResponseAccessPingoneType = "google" - ZeroTrustIdentityProviderGetResponseAccessPingoneTypeLinkedin ZeroTrustIdentityProviderGetResponseAccessPingoneType = "linkedin" - ZeroTrustIdentityProviderGetResponseAccessPingoneTypeOidc ZeroTrustIdentityProviderGetResponseAccessPingoneType = "oidc" - ZeroTrustIdentityProviderGetResponseAccessPingoneTypeOkta ZeroTrustIdentityProviderGetResponseAccessPingoneType = "okta" - ZeroTrustIdentityProviderGetResponseAccessPingoneTypeOnelogin ZeroTrustIdentityProviderGetResponseAccessPingoneType = "onelogin" - ZeroTrustIdentityProviderGetResponseAccessPingoneTypePingone ZeroTrustIdentityProviderGetResponseAccessPingoneType = "pingone" - ZeroTrustIdentityProviderGetResponseAccessPingoneTypeYandex ZeroTrustIdentityProviderGetResponseAccessPingoneType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderGetResponseAccessPingoneScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderGetResponseAccessPingoneScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessPingoneScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessPingoneScimConfig] -type zeroTrustIdentityProviderGetResponseAccessPingoneScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessPingoneScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessPingoneScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderGetResponseAccessSaml struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderGetResponseAccessSamlConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderGetResponseAccessSamlType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderGetResponseAccessSamlScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderGetResponseAccessSamlJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessSamlJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderGetResponseAccessSaml] -type zeroTrustIdentityProviderGetResponseAccessSamlJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessSaml) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessSamlJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderGetResponseAccessSaml) implementsZeroTrustIdentityProviderGetResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessSamlConfig struct { - // A list of SAML attribute names that will be added to your signed JWT token and - // can be used in SAML policy rules. - Attributes []string `json:"attributes"` - // The attribute name for email in the SAML response. - EmailAttributeName string `json:"email_attribute_name"` - // Add a list of attribute names that will be returned in the response header from - // the Access callback. - HeaderAttributes []ZeroTrustIdentityProviderGetResponseAccessSamlConfigHeaderAttribute `json:"header_attributes"` - // X509 certificate to verify the signature in the SAML authentication response - IdpPublicCerts []string `json:"idp_public_certs"` - // IdP Entity ID or Issuer URL - IssuerURL string `json:"issuer_url"` - // Sign the SAML authentication request with Access credentials. To verify the - // signature, use the public key from the Access certs endpoints. - SignRequest bool `json:"sign_request"` - // URL to send the SAML authentication requests to - SSOTargetURL string `json:"sso_target_url"` - JSON zeroTrustIdentityProviderGetResponseAccessSamlConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessSamlConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderGetResponseAccessSamlConfig] -type zeroTrustIdentityProviderGetResponseAccessSamlConfigJSON struct { - Attributes apijson.Field - EmailAttributeName apijson.Field - HeaderAttributes apijson.Field - IdpPublicCerts apijson.Field - IssuerURL apijson.Field - SignRequest apijson.Field - SSOTargetURL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessSamlConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessSamlConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderGetResponseAccessSamlConfigHeaderAttribute struct { - // attribute name from the IDP - AttributeName string `json:"attribute_name"` - // header that will be added on the request to the origin - HeaderName string `json:"header_name"` - JSON zeroTrustIdentityProviderGetResponseAccessSamlConfigHeaderAttributeJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessSamlConfigHeaderAttributeJSON contains -// the JSON metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessSamlConfigHeaderAttribute] -type zeroTrustIdentityProviderGetResponseAccessSamlConfigHeaderAttributeJSON struct { - AttributeName apijson.Field - HeaderName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessSamlConfigHeaderAttribute) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessSamlConfigHeaderAttributeJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessSamlType string - -const ( - ZeroTrustIdentityProviderGetResponseAccessSamlTypeOnetimepin ZeroTrustIdentityProviderGetResponseAccessSamlType = "onetimepin" - ZeroTrustIdentityProviderGetResponseAccessSamlTypeAzureAd ZeroTrustIdentityProviderGetResponseAccessSamlType = "azureAD" - ZeroTrustIdentityProviderGetResponseAccessSamlTypeSaml ZeroTrustIdentityProviderGetResponseAccessSamlType = "saml" - ZeroTrustIdentityProviderGetResponseAccessSamlTypeCentrify ZeroTrustIdentityProviderGetResponseAccessSamlType = "centrify" - ZeroTrustIdentityProviderGetResponseAccessSamlTypeFacebook ZeroTrustIdentityProviderGetResponseAccessSamlType = "facebook" - ZeroTrustIdentityProviderGetResponseAccessSamlTypeGitHub ZeroTrustIdentityProviderGetResponseAccessSamlType = "github" - ZeroTrustIdentityProviderGetResponseAccessSamlTypeGoogleApps ZeroTrustIdentityProviderGetResponseAccessSamlType = "google-apps" - ZeroTrustIdentityProviderGetResponseAccessSamlTypeGoogle ZeroTrustIdentityProviderGetResponseAccessSamlType = "google" - ZeroTrustIdentityProviderGetResponseAccessSamlTypeLinkedin ZeroTrustIdentityProviderGetResponseAccessSamlType = "linkedin" - ZeroTrustIdentityProviderGetResponseAccessSamlTypeOidc ZeroTrustIdentityProviderGetResponseAccessSamlType = "oidc" - ZeroTrustIdentityProviderGetResponseAccessSamlTypeOkta ZeroTrustIdentityProviderGetResponseAccessSamlType = "okta" - ZeroTrustIdentityProviderGetResponseAccessSamlTypeOnelogin ZeroTrustIdentityProviderGetResponseAccessSamlType = "onelogin" - ZeroTrustIdentityProviderGetResponseAccessSamlTypePingone ZeroTrustIdentityProviderGetResponseAccessSamlType = "pingone" - ZeroTrustIdentityProviderGetResponseAccessSamlTypeYandex ZeroTrustIdentityProviderGetResponseAccessSamlType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderGetResponseAccessSamlScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderGetResponseAccessSamlScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessSamlScimConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessSamlScimConfig] -type zeroTrustIdentityProviderGetResponseAccessSamlScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessSamlScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessSamlScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderGetResponseAccessYandex struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config ZeroTrustIdentityProviderGetResponseAccessYandexConfig `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderGetResponseAccessYandexType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderGetResponseAccessYandexScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderGetResponseAccessYandexJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessYandexJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderGetResponseAccessYandex] -type zeroTrustIdentityProviderGetResponseAccessYandexJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessYandex) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessYandexJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderGetResponseAccessYandex) implementsZeroTrustIdentityProviderGetResponse() { -} - -// The configuration parameters for the identity provider. To view the required -// parameters for a specific provider, refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessYandexConfig struct { - // Your OAuth Client ID - ClientID string `json:"client_id"` - // Your OAuth Client Secret - ClientSecret string `json:"client_secret"` - JSON zeroTrustIdentityProviderGetResponseAccessYandexConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessYandexConfigJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderGetResponseAccessYandexConfig] -type zeroTrustIdentityProviderGetResponseAccessYandexConfigJSON struct { - ClientID apijson.Field - ClientSecret apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessYandexConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessYandexConfigJSON) RawJSON() string { - return r.raw -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessYandexType string - -const ( - ZeroTrustIdentityProviderGetResponseAccessYandexTypeOnetimepin ZeroTrustIdentityProviderGetResponseAccessYandexType = "onetimepin" - ZeroTrustIdentityProviderGetResponseAccessYandexTypeAzureAd ZeroTrustIdentityProviderGetResponseAccessYandexType = "azureAD" - ZeroTrustIdentityProviderGetResponseAccessYandexTypeSaml ZeroTrustIdentityProviderGetResponseAccessYandexType = "saml" - ZeroTrustIdentityProviderGetResponseAccessYandexTypeCentrify ZeroTrustIdentityProviderGetResponseAccessYandexType = "centrify" - ZeroTrustIdentityProviderGetResponseAccessYandexTypeFacebook ZeroTrustIdentityProviderGetResponseAccessYandexType = "facebook" - ZeroTrustIdentityProviderGetResponseAccessYandexTypeGitHub ZeroTrustIdentityProviderGetResponseAccessYandexType = "github" - ZeroTrustIdentityProviderGetResponseAccessYandexTypeGoogleApps ZeroTrustIdentityProviderGetResponseAccessYandexType = "google-apps" - ZeroTrustIdentityProviderGetResponseAccessYandexTypeGoogle ZeroTrustIdentityProviderGetResponseAccessYandexType = "google" - ZeroTrustIdentityProviderGetResponseAccessYandexTypeLinkedin ZeroTrustIdentityProviderGetResponseAccessYandexType = "linkedin" - ZeroTrustIdentityProviderGetResponseAccessYandexTypeOidc ZeroTrustIdentityProviderGetResponseAccessYandexType = "oidc" - ZeroTrustIdentityProviderGetResponseAccessYandexTypeOkta ZeroTrustIdentityProviderGetResponseAccessYandexType = "okta" - ZeroTrustIdentityProviderGetResponseAccessYandexTypeOnelogin ZeroTrustIdentityProviderGetResponseAccessYandexType = "onelogin" - ZeroTrustIdentityProviderGetResponseAccessYandexTypePingone ZeroTrustIdentityProviderGetResponseAccessYandexType = "pingone" - ZeroTrustIdentityProviderGetResponseAccessYandexTypeYandex ZeroTrustIdentityProviderGetResponseAccessYandexType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderGetResponseAccessYandexScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderGetResponseAccessYandexScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessYandexScimConfigJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessYandexScimConfig] -type zeroTrustIdentityProviderGetResponseAccessYandexScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessYandexScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessYandexScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderGetResponseAccessOnetimepin struct { - // The configuration parameters for the identity provider. To view the required - // parameters for a specific provider, refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Config interface{} `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name string `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type ZeroTrustIdentityProviderGetResponseAccessOnetimepinType `json:"type,required"` - // UUID - ID string `json:"id"` - // The configuration settings for enabling a System for Cross-Domain Identity - // Management (SCIM) with the identity provider. - ScimConfig ZeroTrustIdentityProviderGetResponseAccessOnetimepinScimConfig `json:"scim_config"` - JSON zeroTrustIdentityProviderGetResponseAccessOnetimepinJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessOnetimepinJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderGetResponseAccessOnetimepin] -type zeroTrustIdentityProviderGetResponseAccessOnetimepinJSON struct { - Config apijson.Field - Name apijson.Field - Type apijson.Field - ID apijson.Field - ScimConfig apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessOnetimepin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessOnetimepinJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustIdentityProviderGetResponseAccessOnetimepin) implementsZeroTrustIdentityProviderGetResponse() { -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderGetResponseAccessOnetimepinType string - -const ( - ZeroTrustIdentityProviderGetResponseAccessOnetimepinTypeOnetimepin ZeroTrustIdentityProviderGetResponseAccessOnetimepinType = "onetimepin" - ZeroTrustIdentityProviderGetResponseAccessOnetimepinTypeAzureAd ZeroTrustIdentityProviderGetResponseAccessOnetimepinType = "azureAD" - ZeroTrustIdentityProviderGetResponseAccessOnetimepinTypeSaml ZeroTrustIdentityProviderGetResponseAccessOnetimepinType = "saml" - ZeroTrustIdentityProviderGetResponseAccessOnetimepinTypeCentrify ZeroTrustIdentityProviderGetResponseAccessOnetimepinType = "centrify" - ZeroTrustIdentityProviderGetResponseAccessOnetimepinTypeFacebook ZeroTrustIdentityProviderGetResponseAccessOnetimepinType = "facebook" - ZeroTrustIdentityProviderGetResponseAccessOnetimepinTypeGitHub ZeroTrustIdentityProviderGetResponseAccessOnetimepinType = "github" - ZeroTrustIdentityProviderGetResponseAccessOnetimepinTypeGoogleApps ZeroTrustIdentityProviderGetResponseAccessOnetimepinType = "google-apps" - ZeroTrustIdentityProviderGetResponseAccessOnetimepinTypeGoogle ZeroTrustIdentityProviderGetResponseAccessOnetimepinType = "google" - ZeroTrustIdentityProviderGetResponseAccessOnetimepinTypeLinkedin ZeroTrustIdentityProviderGetResponseAccessOnetimepinType = "linkedin" - ZeroTrustIdentityProviderGetResponseAccessOnetimepinTypeOidc ZeroTrustIdentityProviderGetResponseAccessOnetimepinType = "oidc" - ZeroTrustIdentityProviderGetResponseAccessOnetimepinTypeOkta ZeroTrustIdentityProviderGetResponseAccessOnetimepinType = "okta" - ZeroTrustIdentityProviderGetResponseAccessOnetimepinTypeOnelogin ZeroTrustIdentityProviderGetResponseAccessOnetimepinType = "onelogin" - ZeroTrustIdentityProviderGetResponseAccessOnetimepinTypePingone ZeroTrustIdentityProviderGetResponseAccessOnetimepinType = "pingone" - ZeroTrustIdentityProviderGetResponseAccessOnetimepinTypeYandex ZeroTrustIdentityProviderGetResponseAccessOnetimepinType = "yandex" -) - -// The configuration settings for enabling a System for Cross-Domain Identity -// Management (SCIM) with the identity provider. -type ZeroTrustIdentityProviderGetResponseAccessOnetimepinScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled bool `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision bool `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision bool `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret string `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision bool `json:"user_deprovision"` - JSON zeroTrustIdentityProviderGetResponseAccessOnetimepinScimConfigJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseAccessOnetimepinScimConfigJSON contains the -// JSON metadata for the struct -// [ZeroTrustIdentityProviderGetResponseAccessOnetimepinScimConfig] -type zeroTrustIdentityProviderGetResponseAccessOnetimepinScimConfigJSON struct { - Enabled apijson.Field - GroupMemberDeprovision apijson.Field - SeatDeprovision apijson.Field - Secret apijson.Field - UserDeprovision apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseAccessOnetimepinScimConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseAccessOnetimepinScimConfigJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderNewParams struct { - Config param.Field[ZeroTrustIdentityProviderNewParamsConfig] `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[ZeroTrustIdentityProviderNewParamsType] `json:"type,required"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - ScimConfig param.Field[ZeroTrustIdentityProviderNewParamsScimConfig] `json:"scim_config"` -} - -func (r ZeroTrustIdentityProviderNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustIdentityProviderNewParamsConfig struct { - // Your companies TLD - AppsDomain param.Field[string] `json:"apps_domain"` - // A list of SAML attribute names that will be added to your signed JWT token and - // can be used in SAML policy rules. - Attributes param.Field[[]string] `json:"attributes"` - // The authorization_endpoint URL of your IdP - AuthURL param.Field[string] `json:"auth_url"` - // Your okta authorization server id - AuthorizationServerID param.Field[string] `json:"authorization_server_id"` - // Your centrify account url - CentrifyAccount param.Field[string] `json:"centrify_account"` - // Your centrify app id - CentrifyAppID param.Field[string] `json:"centrify_app_id"` - // The jwks_uri endpoint of your IdP to allow the IdP keys to sign the tokens - CertsURL param.Field[string] `json:"certs_url"` - // Custom claims - Claims param.Field[[]string] `json:"claims"` - // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` - // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` - // Should Cloudflare try to load authentication contexts from your account - ConditionalAccessEnabled param.Field[bool] `json:"conditional_access_enabled"` - // Your Azure directory uuid - DirectoryID param.Field[string] `json:"directory_id"` - // The attribute name for email in the SAML response. - EmailAttributeName param.Field[string] `json:"email_attribute_name"` - // The claim name for email in the id_token response. - EmailClaimName param.Field[string] `json:"email_claim_name"` - // Add a list of attribute names that will be returned in the response header from - // the Access callback. - HeaderAttributes param.Field[[]ZeroTrustIdentityProviderNewParamsConfigHeaderAttribute] `json:"header_attributes"` - // X509 certificate to verify the signature in the SAML authentication response - IdpPublicCerts param.Field[[]string] `json:"idp_public_certs"` - // IdP Entity ID or Issuer URL - IssuerURL param.Field[string] `json:"issuer_url"` - // Your okta account url - OktaAccount param.Field[string] `json:"okta_account"` - // Your OneLogin account url - OneloginAccount param.Field[string] `json:"onelogin_account"` - // Your PingOne environment identifier - PingEnvID param.Field[string] `json:"ping_env_id"` - // OAuth scopes - Scopes param.Field[[]string] `json:"scopes"` - // Sign the SAML authentication request with Access credentials. To verify the - // signature, use the public key from the Access certs endpoints. - SignRequest param.Field[bool] `json:"sign_request"` - // URL to send the SAML authentication requests to - SSOTargetURL param.Field[string] `json:"sso_target_url"` - // Should Cloudflare try to load groups from your account - SupportGroups param.Field[bool] `json:"support_groups"` - // The token_endpoint URL of your IdP - TokenURL param.Field[string] `json:"token_url"` -} - -func (r ZeroTrustIdentityProviderNewParamsConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustIdentityProviderNewParamsConfigHeaderAttribute struct { - // attribute name from the IDP - AttributeName param.Field[string] `json:"attribute_name"` - // header that will be added on the request to the origin - HeaderName param.Field[string] `json:"header_name"` -} - -func (r ZeroTrustIdentityProviderNewParamsConfigHeaderAttribute) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderNewParamsType string - -const ( - ZeroTrustIdentityProviderNewParamsTypeOnetimepin ZeroTrustIdentityProviderNewParamsType = "onetimepin" - ZeroTrustIdentityProviderNewParamsTypeAzureAd ZeroTrustIdentityProviderNewParamsType = "azureAD" - ZeroTrustIdentityProviderNewParamsTypeSaml ZeroTrustIdentityProviderNewParamsType = "saml" - ZeroTrustIdentityProviderNewParamsTypeCentrify ZeroTrustIdentityProviderNewParamsType = "centrify" - ZeroTrustIdentityProviderNewParamsTypeFacebook ZeroTrustIdentityProviderNewParamsType = "facebook" - ZeroTrustIdentityProviderNewParamsTypeGitHub ZeroTrustIdentityProviderNewParamsType = "github" - ZeroTrustIdentityProviderNewParamsTypeGoogleApps ZeroTrustIdentityProviderNewParamsType = "google-apps" - ZeroTrustIdentityProviderNewParamsTypeGoogle ZeroTrustIdentityProviderNewParamsType = "google" - ZeroTrustIdentityProviderNewParamsTypeLinkedin ZeroTrustIdentityProviderNewParamsType = "linkedin" - ZeroTrustIdentityProviderNewParamsTypeOidc ZeroTrustIdentityProviderNewParamsType = "oidc" - ZeroTrustIdentityProviderNewParamsTypeOkta ZeroTrustIdentityProviderNewParamsType = "okta" - ZeroTrustIdentityProviderNewParamsTypeOnelogin ZeroTrustIdentityProviderNewParamsType = "onelogin" - ZeroTrustIdentityProviderNewParamsTypePingone ZeroTrustIdentityProviderNewParamsType = "pingone" - ZeroTrustIdentityProviderNewParamsTypeYandex ZeroTrustIdentityProviderNewParamsType = "yandex" -) - -type ZeroTrustIdentityProviderNewParamsScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` -} - -func (r ZeroTrustIdentityProviderNewParamsScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustIdentityProviderNewResponseEnvelope struct { - Errors []ZeroTrustIdentityProviderNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustIdentityProviderNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustIdentityProviderNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustIdentityProviderNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustIdentityProviderNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustIdentityProviderNewResponseEnvelope] -type zeroTrustIdentityProviderNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustIdentityProviderNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderNewResponseEnvelopeErrors] -type zeroTrustIdentityProviderNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustIdentityProviderNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustIdentityProviderNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderNewResponseEnvelopeMessages] -type zeroTrustIdentityProviderNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustIdentityProviderNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustIdentityProviderNewResponseEnvelopeSuccessTrue ZeroTrustIdentityProviderNewResponseEnvelopeSuccess = true -) - -type ZeroTrustIdentityProviderUpdateParams struct { - Config param.Field[ZeroTrustIdentityProviderUpdateParamsConfig] `json:"config,required"` - // The name of the identity provider, shown to users on the login page. - Name param.Field[string] `json:"name,required"` - // The type of identity provider. To determine the value for a specific provider, - // refer to our - // [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). - Type param.Field[ZeroTrustIdentityProviderUpdateParamsType] `json:"type,required"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - ScimConfig param.Field[ZeroTrustIdentityProviderUpdateParamsScimConfig] `json:"scim_config"` -} - -func (r ZeroTrustIdentityProviderUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustIdentityProviderUpdateParamsConfig struct { - // Your companies TLD - AppsDomain param.Field[string] `json:"apps_domain"` - // A list of SAML attribute names that will be added to your signed JWT token and - // can be used in SAML policy rules. - Attributes param.Field[[]string] `json:"attributes"` - // The authorization_endpoint URL of your IdP - AuthURL param.Field[string] `json:"auth_url"` - // Your okta authorization server id - AuthorizationServerID param.Field[string] `json:"authorization_server_id"` - // Your centrify account url - CentrifyAccount param.Field[string] `json:"centrify_account"` - // Your centrify app id - CentrifyAppID param.Field[string] `json:"centrify_app_id"` - // The jwks_uri endpoint of your IdP to allow the IdP keys to sign the tokens - CertsURL param.Field[string] `json:"certs_url"` - // Custom claims - Claims param.Field[[]string] `json:"claims"` - // Your OAuth Client ID - ClientID param.Field[string] `json:"client_id"` - // Your OAuth Client Secret - ClientSecret param.Field[string] `json:"client_secret"` - // Should Cloudflare try to load authentication contexts from your account - ConditionalAccessEnabled param.Field[bool] `json:"conditional_access_enabled"` - // Your Azure directory uuid - DirectoryID param.Field[string] `json:"directory_id"` - // The attribute name for email in the SAML response. - EmailAttributeName param.Field[string] `json:"email_attribute_name"` - // The claim name for email in the id_token response. - EmailClaimName param.Field[string] `json:"email_claim_name"` - // Add a list of attribute names that will be returned in the response header from - // the Access callback. - HeaderAttributes param.Field[[]ZeroTrustIdentityProviderUpdateParamsConfigHeaderAttribute] `json:"header_attributes"` - // X509 certificate to verify the signature in the SAML authentication response - IdpPublicCerts param.Field[[]string] `json:"idp_public_certs"` - // IdP Entity ID or Issuer URL - IssuerURL param.Field[string] `json:"issuer_url"` - // Your okta account url - OktaAccount param.Field[string] `json:"okta_account"` - // Your OneLogin account url - OneloginAccount param.Field[string] `json:"onelogin_account"` - // Your PingOne environment identifier - PingEnvID param.Field[string] `json:"ping_env_id"` - // OAuth scopes - Scopes param.Field[[]string] `json:"scopes"` - // Sign the SAML authentication request with Access credentials. To verify the - // signature, use the public key from the Access certs endpoints. - SignRequest param.Field[bool] `json:"sign_request"` - // URL to send the SAML authentication requests to - SSOTargetURL param.Field[string] `json:"sso_target_url"` - // Should Cloudflare try to load groups from your account - SupportGroups param.Field[bool] `json:"support_groups"` - // The token_endpoint URL of your IdP - TokenURL param.Field[string] `json:"token_url"` -} - -func (r ZeroTrustIdentityProviderUpdateParamsConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustIdentityProviderUpdateParamsConfigHeaderAttribute struct { - // attribute name from the IDP - AttributeName param.Field[string] `json:"attribute_name"` - // header that will be added on the request to the origin - HeaderName param.Field[string] `json:"header_name"` -} - -func (r ZeroTrustIdentityProviderUpdateParamsConfigHeaderAttribute) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of identity provider. To determine the value for a specific provider, -// refer to our -// [developer documentation](https://developers.cloudflare.com/cloudflare-one/identity/idp-integration/). -type ZeroTrustIdentityProviderUpdateParamsType string - -const ( - ZeroTrustIdentityProviderUpdateParamsTypeOnetimepin ZeroTrustIdentityProviderUpdateParamsType = "onetimepin" - ZeroTrustIdentityProviderUpdateParamsTypeAzureAd ZeroTrustIdentityProviderUpdateParamsType = "azureAD" - ZeroTrustIdentityProviderUpdateParamsTypeSaml ZeroTrustIdentityProviderUpdateParamsType = "saml" - ZeroTrustIdentityProviderUpdateParamsTypeCentrify ZeroTrustIdentityProviderUpdateParamsType = "centrify" - ZeroTrustIdentityProviderUpdateParamsTypeFacebook ZeroTrustIdentityProviderUpdateParamsType = "facebook" - ZeroTrustIdentityProviderUpdateParamsTypeGitHub ZeroTrustIdentityProviderUpdateParamsType = "github" - ZeroTrustIdentityProviderUpdateParamsTypeGoogleApps ZeroTrustIdentityProviderUpdateParamsType = "google-apps" - ZeroTrustIdentityProviderUpdateParamsTypeGoogle ZeroTrustIdentityProviderUpdateParamsType = "google" - ZeroTrustIdentityProviderUpdateParamsTypeLinkedin ZeroTrustIdentityProviderUpdateParamsType = "linkedin" - ZeroTrustIdentityProviderUpdateParamsTypeOidc ZeroTrustIdentityProviderUpdateParamsType = "oidc" - ZeroTrustIdentityProviderUpdateParamsTypeOkta ZeroTrustIdentityProviderUpdateParamsType = "okta" - ZeroTrustIdentityProviderUpdateParamsTypeOnelogin ZeroTrustIdentityProviderUpdateParamsType = "onelogin" - ZeroTrustIdentityProviderUpdateParamsTypePingone ZeroTrustIdentityProviderUpdateParamsType = "pingone" - ZeroTrustIdentityProviderUpdateParamsTypeYandex ZeroTrustIdentityProviderUpdateParamsType = "yandex" -) - -type ZeroTrustIdentityProviderUpdateParamsScimConfig struct { - // A flag to enable or disable SCIM for the identity provider. - Enabled param.Field[bool] `json:"enabled"` - // A flag to revoke a user's session in Access and force a reauthentication on the - // user's Gateway session when they have been added or removed from a group in the - // Identity Provider. - GroupMemberDeprovision param.Field[bool] `json:"group_member_deprovision"` - // A flag to remove a user's seat in Zero Trust when they have been deprovisioned - // in the Identity Provider. This cannot be enabled unless user_deprovision is also - // enabled. - SeatDeprovision param.Field[bool] `json:"seat_deprovision"` - // A read-only token generated when the SCIM integration is enabled for the first - // time. It is redacted on subsequent requests. If you lose this you will need to - // refresh it token at /access/identity_providers/:idpID/refresh_scim_secret. - Secret param.Field[string] `json:"secret"` - // A flag to enable revoking a user's session in Access and Gateway when they have - // been deprovisioned in the Identity Provider. - UserDeprovision param.Field[bool] `json:"user_deprovision"` -} - -func (r ZeroTrustIdentityProviderUpdateParamsScimConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustIdentityProviderUpdateResponseEnvelope struct { - Errors []ZeroTrustIdentityProviderUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustIdentityProviderUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustIdentityProviderUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustIdentityProviderUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustIdentityProviderUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderUpdateResponseEnvelope] -type zeroTrustIdentityProviderUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustIdentityProviderUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderUpdateResponseEnvelopeErrors] -type zeroTrustIdentityProviderUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustIdentityProviderUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustIdentityProviderUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderUpdateResponseEnvelopeMessages] -type zeroTrustIdentityProviderUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustIdentityProviderUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustIdentityProviderUpdateResponseEnvelopeSuccessTrue ZeroTrustIdentityProviderUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustIdentityProviderListParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustIdentityProviderListResponseEnvelope struct { - Errors []ZeroTrustIdentityProviderListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustIdentityProviderListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustIdentityProviderListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustIdentityProviderListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustIdentityProviderListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustIdentityProviderListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustIdentityProviderListResponseEnvelope] -type zeroTrustIdentityProviderListResponseEnvelopeJSON 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 *ZeroTrustIdentityProviderListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustIdentityProviderListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderListResponseEnvelopeErrors] -type zeroTrustIdentityProviderListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustIdentityProviderListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderListResponseEnvelopeMessages] -type zeroTrustIdentityProviderListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustIdentityProviderListResponseEnvelopeSuccess bool - -const ( - ZeroTrustIdentityProviderListResponseEnvelopeSuccessTrue ZeroTrustIdentityProviderListResponseEnvelopeSuccess = true -) - -type ZeroTrustIdentityProviderListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustIdentityProviderListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustIdentityProviderListResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderListResponseEnvelopeResultInfo] -type zeroTrustIdentityProviderListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderDeleteParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustIdentityProviderDeleteResponseEnvelope struct { - Errors []ZeroTrustIdentityProviderDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustIdentityProviderDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustIdentityProviderDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustIdentityProviderDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustIdentityProviderDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustIdentityProviderDeleteResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustIdentityProviderDeleteResponseEnvelope] -type zeroTrustIdentityProviderDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustIdentityProviderDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustIdentityProviderDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderDeleteResponseEnvelopeErrors] -type zeroTrustIdentityProviderDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustIdentityProviderDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustIdentityProviderDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustIdentityProviderDeleteResponseEnvelopeMessages] -type zeroTrustIdentityProviderDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustIdentityProviderDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustIdentityProviderDeleteResponseEnvelopeSuccessTrue ZeroTrustIdentityProviderDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustIdentityProviderGetParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustIdentityProviderGetResponseEnvelope struct { - Errors []ZeroTrustIdentityProviderGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustIdentityProviderGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustIdentityProviderGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustIdentityProviderGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustIdentityProviderGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustIdentityProviderGetResponseEnvelope] -type zeroTrustIdentityProviderGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustIdentityProviderGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderGetResponseEnvelopeErrors] -type zeroTrustIdentityProviderGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustIdentityProviderGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustIdentityProviderGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustIdentityProviderGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustIdentityProviderGetResponseEnvelopeMessages] -type zeroTrustIdentityProviderGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustIdentityProviderGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustIdentityProviderGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustIdentityProviderGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustIdentityProviderGetResponseEnvelopeSuccessTrue ZeroTrustIdentityProviderGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustidentityprovider_test.go b/zerotrustidentityprovider_test.go deleted file mode 100644 index 9663c1c646b..00000000000 --- a/zerotrustidentityprovider_test.go +++ /dev/null @@ -1,251 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustIdentityProviderNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.IdentityProviders.New(context.TODO(), cloudflare.ZeroTrustIdentityProviderNewParams{ - Config: cloudflare.F(cloudflare.ZeroTrustIdentityProviderNewParamsConfig{ - ClientID: cloudflare.F(""), - ClientSecret: cloudflare.F(""), - Claims: cloudflare.F([]string{"email_verified", "preferred_username", "custom_claim_name"}), - EmailClaimName: cloudflare.F("custom_claim_name"), - ConditionalAccessEnabled: cloudflare.F(true), - DirectoryID: cloudflare.F(""), - SupportGroups: cloudflare.F(true), - CentrifyAccount: cloudflare.F("https://abc123.my.centrify.com/"), - CentrifyAppID: cloudflare.F("exampleapp"), - AppsDomain: cloudflare.F("mycompany.com"), - AuthURL: cloudflare.F("https://accounts.google.com/o/oauth2/auth"), - CertsURL: cloudflare.F("https://www.googleapis.com/oauth2/v3/certs"), - Scopes: cloudflare.F([]string{"openid", "email", "profile"}), - TokenURL: cloudflare.F("https://accounts.google.com/o/oauth2/token"), - AuthorizationServerID: cloudflare.F("aus9o8wzkhckw9TLa0h7z"), - OktaAccount: cloudflare.F("https://dev-abc123.oktapreview.com"), - OneloginAccount: cloudflare.F("https://mycompany.onelogin.com"), - PingEnvID: cloudflare.F("342b5660-0c32-4936-a5a4-ce21fae57b0a"), - Attributes: cloudflare.F([]string{"group", "department_code", "divison"}), - EmailAttributeName: cloudflare.F("Email"), - HeaderAttributes: cloudflare.F([]cloudflare.ZeroTrustIdentityProviderNewParamsConfigHeaderAttribute{{ - AttributeName: cloudflare.F("string"), - HeaderName: cloudflare.F("string"), - }, { - AttributeName: cloudflare.F("string"), - HeaderName: cloudflare.F("string"), - }, { - AttributeName: cloudflare.F("string"), - HeaderName: cloudflare.F("string"), - }}), - IdpPublicCerts: cloudflare.F([]string{"string", "string", "string"}), - IssuerURL: cloudflare.F("https://whoami.com"), - SignRequest: cloudflare.F(true), - SSOTargetURL: cloudflare.F("https://edgeaccess.org/idp/saml/login"), - }), - Name: cloudflare.F("Widget Corps IDP"), - Type: cloudflare.F(cloudflare.ZeroTrustIdentityProviderNewParamsTypeOnetimepin), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - ScimConfig: cloudflare.F(cloudflare.ZeroTrustIdentityProviderNewParamsScimConfig{ - Enabled: cloudflare.F(true), - GroupMemberDeprovision: cloudflare.F(true), - SeatDeprovision: cloudflare.F(true), - Secret: cloudflare.F("string"), - UserDeprovision: cloudflare.F(true), - }), - }) - 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 TestZeroTrustIdentityProviderUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.IdentityProviders.Update( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustIdentityProviderUpdateParams{ - Config: cloudflare.F(cloudflare.ZeroTrustIdentityProviderUpdateParamsConfig{ - ClientID: cloudflare.F(""), - ClientSecret: cloudflare.F(""), - Claims: cloudflare.F([]string{"email_verified", "preferred_username", "custom_claim_name"}), - EmailClaimName: cloudflare.F("custom_claim_name"), - ConditionalAccessEnabled: cloudflare.F(true), - DirectoryID: cloudflare.F(""), - SupportGroups: cloudflare.F(true), - CentrifyAccount: cloudflare.F("https://abc123.my.centrify.com/"), - CentrifyAppID: cloudflare.F("exampleapp"), - AppsDomain: cloudflare.F("mycompany.com"), - AuthURL: cloudflare.F("https://accounts.google.com/o/oauth2/auth"), - CertsURL: cloudflare.F("https://www.googleapis.com/oauth2/v3/certs"), - Scopes: cloudflare.F([]string{"openid", "email", "profile"}), - TokenURL: cloudflare.F("https://accounts.google.com/o/oauth2/token"), - AuthorizationServerID: cloudflare.F("aus9o8wzkhckw9TLa0h7z"), - OktaAccount: cloudflare.F("https://dev-abc123.oktapreview.com"), - OneloginAccount: cloudflare.F("https://mycompany.onelogin.com"), - PingEnvID: cloudflare.F("342b5660-0c32-4936-a5a4-ce21fae57b0a"), - Attributes: cloudflare.F([]string{"group", "department_code", "divison"}), - EmailAttributeName: cloudflare.F("Email"), - HeaderAttributes: cloudflare.F([]cloudflare.ZeroTrustIdentityProviderUpdateParamsConfigHeaderAttribute{{ - AttributeName: cloudflare.F("string"), - HeaderName: cloudflare.F("string"), - }, { - AttributeName: cloudflare.F("string"), - HeaderName: cloudflare.F("string"), - }, { - AttributeName: cloudflare.F("string"), - HeaderName: cloudflare.F("string"), - }}), - IdpPublicCerts: cloudflare.F([]string{"string", "string", "string"}), - IssuerURL: cloudflare.F("https://whoami.com"), - SignRequest: cloudflare.F(true), - SSOTargetURL: cloudflare.F("https://edgeaccess.org/idp/saml/login"), - }), - Name: cloudflare.F("Widget Corps IDP"), - Type: cloudflare.F(cloudflare.ZeroTrustIdentityProviderUpdateParamsTypeOnetimepin), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - ScimConfig: cloudflare.F(cloudflare.ZeroTrustIdentityProviderUpdateParamsScimConfig{ - Enabled: cloudflare.F(true), - GroupMemberDeprovision: cloudflare.F(true), - SeatDeprovision: cloudflare.F(true), - Secret: cloudflare.F("string"), - UserDeprovision: cloudflare.F(true), - }), - }, - ) - 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 TestZeroTrustIdentityProviderListWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.IdentityProviders.List(context.TODO(), cloudflare.ZeroTrustIdentityProviderListParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }) - 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 TestZeroTrustIdentityProviderDeleteWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.IdentityProviders.Delete( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustIdentityProviderDeleteParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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 TestZeroTrustIdentityProviderGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.IdentityProviders.Get( - context.TODO(), - "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustIdentityProviderGetParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }, - ) - 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/zerotrustnetwork.go b/zerotrustnetwork.go deleted file mode 100644 index 5dd4f914c95..00000000000 --- a/zerotrustnetwork.go +++ /dev/null @@ -1,29 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustNetworkService 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 [NewZeroTrustNetworkService] method -// instead. -type ZeroTrustNetworkService struct { - Options []option.RequestOption - Routes *ZeroTrustNetworkRouteService - VirtualNetworks *ZeroTrustNetworkVirtualNetworkService -} - -// NewZeroTrustNetworkService 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 NewZeroTrustNetworkService(opts ...option.RequestOption) (r *ZeroTrustNetworkService) { - r = &ZeroTrustNetworkService{} - r.Options = opts - r.Routes = NewZeroTrustNetworkRouteService(opts...) - r.VirtualNetworks = NewZeroTrustNetworkVirtualNetworkService(opts...) - return -} diff --git a/zerotrustnetworkroute.go b/zerotrustnetworkroute.go deleted file mode 100644 index 056613aab41..00000000000 --- a/zerotrustnetworkroute.go +++ /dev/null @@ -1,630 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustNetworkRouteService 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 [NewZeroTrustNetworkRouteService] -// method instead. -type ZeroTrustNetworkRouteService struct { - Options []option.RequestOption - IPs *ZeroTrustNetworkRouteIPService - Networks *ZeroTrustNetworkRouteNetworkService -} - -// NewZeroTrustNetworkRouteService 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 NewZeroTrustNetworkRouteService(opts ...option.RequestOption) (r *ZeroTrustNetworkRouteService) { - r = &ZeroTrustNetworkRouteService{} - r.Options = opts - r.IPs = NewZeroTrustNetworkRouteIPService(opts...) - r.Networks = NewZeroTrustNetworkRouteNetworkService(opts...) - return -} - -// Routes a private network through a Cloudflare Tunnel. -func (r *ZeroTrustNetworkRouteService) New(ctx context.Context, params ZeroTrustNetworkRouteNewParams, opts ...option.RequestOption) (res *ZeroTrustNetworkRouteNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustNetworkRouteNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/teamnet/routes", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists and filters private network routes in an account. -func (r *ZeroTrustNetworkRouteService) List(ctx context.Context, params ZeroTrustNetworkRouteListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[ZeroTrustNetworkRouteListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("accounts/%s/teamnet/routes", params.AccountID) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Lists and filters private network routes in an account. -func (r *ZeroTrustNetworkRouteService) ListAutoPaging(ctx context.Context, params ZeroTrustNetworkRouteListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[ZeroTrustNetworkRouteListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) -} - -// Deletes a private network route from an account. -func (r *ZeroTrustNetworkRouteService) Delete(ctx context.Context, routeID string, body ZeroTrustNetworkRouteDeleteParams, opts ...option.RequestOption) (res *ZeroTrustNetworkRouteDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustNetworkRouteDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/teamnet/routes/%s", body.AccountID, routeID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates an existing private network route in an account. The fields that are -// meant to be updated should be provided in the body of the request. -func (r *ZeroTrustNetworkRouteService) Edit(ctx context.Context, routeID string, params ZeroTrustNetworkRouteEditParams, opts ...option.RequestOption) (res *ZeroTrustNetworkRouteEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustNetworkRouteEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/teamnet/routes/%s", params.AccountID, routeID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustNetworkRouteNewResponse struct { - // UUID of the route. - ID string `json:"id"` - // Optional remark describing the route. - Comment string `json:"comment"` - // Timestamp of when the route was created. - CreatedAt interface{} `json:"created_at"` - // Timestamp of when the route was deleted. If `null`, the route has not been - // deleted. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // The private IPv4 or IPv6 range connected by the route, in CIDR notation. - Network string `json:"network"` - // UUID of the Cloudflare Tunnel serving the route. - TunnelID interface{} `json:"tunnel_id"` - // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks - // are configured, the route is assigned to the default virtual network of the - // account. - VirtualNetworkID interface{} `json:"virtual_network_id"` - JSON zeroTrustNetworkRouteNewResponseJSON `json:"-"` -} - -// zeroTrustNetworkRouteNewResponseJSON contains the JSON metadata for the struct -// [ZeroTrustNetworkRouteNewResponse] -type zeroTrustNetworkRouteNewResponseJSON struct { - ID apijson.Field - Comment apijson.Field - CreatedAt apijson.Field - DeletedAt apijson.Field - Network apijson.Field - TunnelID apijson.Field - VirtualNetworkID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteNewResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteListResponse struct { - // UUID of the route. - ID string `json:"id"` - // Optional remark describing the route. - Comment string `json:"comment"` - // Timestamp of when the route was created. - CreatedAt interface{} `json:"created_at"` - // Timestamp of when the route was deleted. If `null`, the route has not been - // deleted. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // The private IPv4 or IPv6 range connected by the route, in CIDR notation. - Network string `json:"network"` - // The type of tunnel. - TunType ZeroTrustNetworkRouteListResponseTunType `json:"tun_type"` - // UUID of the Cloudflare Tunnel serving the route. - TunnelID interface{} `json:"tunnel_id"` - // The user-friendly name of the Cloudflare Tunnel serving the route. - TunnelName interface{} `json:"tunnel_name"` - // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks - // are configured, the route is assigned to the default virtual network of the - // account. - VirtualNetworkID interface{} `json:"virtual_network_id"` - // A user-friendly name for the virtual network. - VirtualNetworkName string `json:"virtual_network_name"` - JSON zeroTrustNetworkRouteListResponseJSON `json:"-"` -} - -// zeroTrustNetworkRouteListResponseJSON contains the JSON metadata for the struct -// [ZeroTrustNetworkRouteListResponse] -type zeroTrustNetworkRouteListResponseJSON struct { - ID apijson.Field - Comment apijson.Field - CreatedAt apijson.Field - DeletedAt apijson.Field - Network apijson.Field - TunType apijson.Field - TunnelID apijson.Field - TunnelName apijson.Field - VirtualNetworkID apijson.Field - VirtualNetworkName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteListResponseJSON) RawJSON() string { - return r.raw -} - -// The type of tunnel. -type ZeroTrustNetworkRouteListResponseTunType string - -const ( - ZeroTrustNetworkRouteListResponseTunTypeCfdTunnel ZeroTrustNetworkRouteListResponseTunType = "cfd_tunnel" - ZeroTrustNetworkRouteListResponseTunTypeWARPConnector ZeroTrustNetworkRouteListResponseTunType = "warp_connector" - ZeroTrustNetworkRouteListResponseTunTypeIPSec ZeroTrustNetworkRouteListResponseTunType = "ip_sec" - ZeroTrustNetworkRouteListResponseTunTypeGRE ZeroTrustNetworkRouteListResponseTunType = "gre" - ZeroTrustNetworkRouteListResponseTunTypeCni ZeroTrustNetworkRouteListResponseTunType = "cni" -) - -type ZeroTrustNetworkRouteDeleteResponse struct { - // UUID of the route. - ID string `json:"id"` - // Optional remark describing the route. - Comment string `json:"comment"` - // Timestamp of when the route was created. - CreatedAt interface{} `json:"created_at"` - // Timestamp of when the route was deleted. If `null`, the route has not been - // deleted. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // The private IPv4 or IPv6 range connected by the route, in CIDR notation. - Network string `json:"network"` - // UUID of the Cloudflare Tunnel serving the route. - TunnelID interface{} `json:"tunnel_id"` - // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks - // are configured, the route is assigned to the default virtual network of the - // account. - VirtualNetworkID interface{} `json:"virtual_network_id"` - JSON zeroTrustNetworkRouteDeleteResponseJSON `json:"-"` -} - -// zeroTrustNetworkRouteDeleteResponseJSON contains the JSON metadata for the -// struct [ZeroTrustNetworkRouteDeleteResponse] -type zeroTrustNetworkRouteDeleteResponseJSON struct { - ID apijson.Field - Comment apijson.Field - CreatedAt apijson.Field - DeletedAt apijson.Field - Network apijson.Field - TunnelID apijson.Field - VirtualNetworkID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteEditResponse struct { - // UUID of the route. - ID string `json:"id"` - // Optional remark describing the route. - Comment string `json:"comment"` - // Timestamp of when the route was created. - CreatedAt interface{} `json:"created_at"` - // Timestamp of when the route was deleted. If `null`, the route has not been - // deleted. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // The private IPv4 or IPv6 range connected by the route, in CIDR notation. - Network string `json:"network"` - // UUID of the Cloudflare Tunnel serving the route. - TunnelID interface{} `json:"tunnel_id"` - // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks - // are configured, the route is assigned to the default virtual network of the - // account. - VirtualNetworkID interface{} `json:"virtual_network_id"` - JSON zeroTrustNetworkRouteEditResponseJSON `json:"-"` -} - -// zeroTrustNetworkRouteEditResponseJSON contains the JSON metadata for the struct -// [ZeroTrustNetworkRouteEditResponse] -type zeroTrustNetworkRouteEditResponseJSON struct { - ID apijson.Field - Comment apijson.Field - CreatedAt apijson.Field - DeletedAt apijson.Field - Network apijson.Field - TunnelID apijson.Field - VirtualNetworkID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteEditResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteNewParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - // The private IPv4 or IPv6 range connected by the route, in CIDR notation. - IPNetwork param.Field[string] `json:"ip_network,required"` - // Optional remark describing the route. - Comment param.Field[string] `json:"comment"` - // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks - // are configured, the route is assigned to the default virtual network of the - // account. - VirtualNetworkID param.Field[interface{}] `json:"virtual_network_id"` -} - -func (r ZeroTrustNetworkRouteNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustNetworkRouteNewResponseEnvelope struct { - Errors []ZeroTrustNetworkRouteNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustNetworkRouteNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustNetworkRouteNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustNetworkRouteNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustNetworkRouteNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustNetworkRouteNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustNetworkRouteNewResponseEnvelope] -type zeroTrustNetworkRouteNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkRouteNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustNetworkRouteNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustNetworkRouteNewResponseEnvelopeErrors] -type zeroTrustNetworkRouteNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkRouteNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustNetworkRouteNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustNetworkRouteNewResponseEnvelopeMessages] -type zeroTrustNetworkRouteNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustNetworkRouteNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustNetworkRouteNewResponseEnvelopeSuccessTrue ZeroTrustNetworkRouteNewResponseEnvelopeSuccess = true -) - -type ZeroTrustNetworkRouteListParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - // Optional remark describing the route. - Comment param.Field[string] `query:"comment"` - // If provided, include only routes that were created (and not deleted) before this - // time. - ExistedAt param.Field[interface{}] `query:"existed_at"` - // If `true`, only include deleted routes. If `false`, exclude deleted routes. If - // empty, all routes will be included. - IsDeleted param.Field[interface{}] `query:"is_deleted"` - // If set, only list routes that are contained within this IP range. - NetworkSubset param.Field[interface{}] `query:"network_subset"` - // If set, only list routes that contain this IP range. - NetworkSuperset param.Field[interface{}] `query:"network_superset"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // Number of results to display. - PerPage param.Field[float64] `query:"per_page"` - // The types of tunnels to filter separated by a comma. - TunTypes param.Field[string] `query:"tun_types"` - // UUID of the Cloudflare Tunnel serving the route. - TunnelID param.Field[interface{}] `query:"tunnel_id"` - // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks - // are configured, the route is assigned to the default virtual network of the - // account. - VirtualNetworkID param.Field[interface{}] `query:"virtual_network_id"` -} - -// URLQuery serializes [ZeroTrustNetworkRouteListParams]'s query parameters as -// `url.Values`. -func (r ZeroTrustNetworkRouteListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type ZeroTrustNetworkRouteDeleteParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustNetworkRouteDeleteResponseEnvelope struct { - Errors []ZeroTrustNetworkRouteDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustNetworkRouteDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustNetworkRouteDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustNetworkRouteDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustNetworkRouteDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustNetworkRouteDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustNetworkRouteDeleteResponseEnvelope] -type zeroTrustNetworkRouteDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkRouteDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustNetworkRouteDeleteResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustNetworkRouteDeleteResponseEnvelopeErrors] -type zeroTrustNetworkRouteDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkRouteDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustNetworkRouteDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustNetworkRouteDeleteResponseEnvelopeMessages] -type zeroTrustNetworkRouteDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustNetworkRouteDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustNetworkRouteDeleteResponseEnvelopeSuccessTrue ZeroTrustNetworkRouteDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustNetworkRouteEditParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - // Optional remark describing the route. - Comment param.Field[string] `json:"comment"` - // The private IPv4 or IPv6 range connected by the route, in CIDR notation. - Network param.Field[string] `json:"network"` - // The type of tunnel. - TunType param.Field[ZeroTrustNetworkRouteEditParamsTunType] `json:"tun_type"` - // UUID of the Cloudflare Tunnel serving the route. - TunnelID param.Field[interface{}] `json:"tunnel_id"` - // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks - // are configured, the route is assigned to the default virtual network of the - // account. - VirtualNetworkID param.Field[interface{}] `json:"virtual_network_id"` -} - -func (r ZeroTrustNetworkRouteEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of tunnel. -type ZeroTrustNetworkRouteEditParamsTunType string - -const ( - ZeroTrustNetworkRouteEditParamsTunTypeCfdTunnel ZeroTrustNetworkRouteEditParamsTunType = "cfd_tunnel" - ZeroTrustNetworkRouteEditParamsTunTypeWARPConnector ZeroTrustNetworkRouteEditParamsTunType = "warp_connector" - ZeroTrustNetworkRouteEditParamsTunTypeIPSec ZeroTrustNetworkRouteEditParamsTunType = "ip_sec" - ZeroTrustNetworkRouteEditParamsTunTypeGRE ZeroTrustNetworkRouteEditParamsTunType = "gre" - ZeroTrustNetworkRouteEditParamsTunTypeCni ZeroTrustNetworkRouteEditParamsTunType = "cni" -) - -type ZeroTrustNetworkRouteEditResponseEnvelope struct { - Errors []ZeroTrustNetworkRouteEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustNetworkRouteEditResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustNetworkRouteEditResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustNetworkRouteEditResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustNetworkRouteEditResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustNetworkRouteEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustNetworkRouteEditResponseEnvelope] -type zeroTrustNetworkRouteEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkRouteEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustNetworkRouteEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustNetworkRouteEditResponseEnvelopeErrors] -type zeroTrustNetworkRouteEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkRouteEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustNetworkRouteEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustNetworkRouteEditResponseEnvelopeMessages] -type zeroTrustNetworkRouteEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustNetworkRouteEditResponseEnvelopeSuccess bool - -const ( - ZeroTrustNetworkRouteEditResponseEnvelopeSuccessTrue ZeroTrustNetworkRouteEditResponseEnvelopeSuccess = true -) diff --git a/zerotrustnetworkroute_test.go b/zerotrustnetworkroute_test.go deleted file mode 100644 index fde36c6878e..00000000000 --- a/zerotrustnetworkroute_test.go +++ /dev/null @@ -1,144 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustNetworkRouteNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Networks.Routes.New(context.TODO(), cloudflare.ZeroTrustNetworkRouteNewParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - IPNetwork: cloudflare.F("172.16.0.0/16"), - Comment: cloudflare.F("Example comment for this route."), - VirtualNetworkID: cloudflare.F[any](map[string]interface{}{}), - }) - 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 TestZeroTrustNetworkRouteListWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Networks.Routes.List(context.TODO(), cloudflare.ZeroTrustNetworkRouteListParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Comment: cloudflare.F("Example comment for this route."), - ExistedAt: cloudflare.F[any](map[string]interface{}{}), - IsDeleted: cloudflare.F[any](map[string]interface{}{}), - NetworkSubset: cloudflare.F[any](map[string]interface{}{}), - NetworkSuperset: cloudflare.F[any](map[string]interface{}{}), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(1.000000), - TunTypes: cloudflare.F("cfd_tunnel,warp_connector"), - TunnelID: cloudflare.F[any](map[string]interface{}{}), - VirtualNetworkID: cloudflare.F[any](map[string]interface{}{}), - }) - 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 TestZeroTrustNetworkRouteDelete(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("user@example.com"), - ) - _, err := client.ZeroTrust.Networks.Routes.Delete( - context.TODO(), - "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustNetworkRouteDeleteParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - }, - ) - 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 TestZeroTrustNetworkRouteEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Networks.Routes.Edit( - context.TODO(), - "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustNetworkRouteEditParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Comment: cloudflare.F("Example comment for this route."), - Network: cloudflare.F("172.16.0.0/16"), - TunType: cloudflare.F(cloudflare.ZeroTrustNetworkRouteEditParamsTunTypeCfdTunnel), - TunnelID: cloudflare.F[any](map[string]interface{}{}), - VirtualNetworkID: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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/zerotrustnetworkrouteip.go b/zerotrustnetworkrouteip.go deleted file mode 100644 index f369b4849de..00000000000 --- a/zerotrustnetworkrouteip.go +++ /dev/null @@ -1,210 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustNetworkRouteIPService 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 -// [NewZeroTrustNetworkRouteIPService] method instead. -type ZeroTrustNetworkRouteIPService struct { - Options []option.RequestOption -} - -// NewZeroTrustNetworkRouteIPService 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 NewZeroTrustNetworkRouteIPService(opts ...option.RequestOption) (r *ZeroTrustNetworkRouteIPService) { - r = &ZeroTrustNetworkRouteIPService{} - r.Options = opts - return -} - -// Fetches routes that contain the given IP address. -func (r *ZeroTrustNetworkRouteIPService) Get(ctx context.Context, ip string, params ZeroTrustNetworkRouteIPGetParams, opts ...option.RequestOption) (res *ZeroTrustNetworkRouteIPGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustNetworkRouteIPGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/teamnet/routes/ip/%s", params.AccountID, ip) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustNetworkRouteIPGetResponse struct { - // UUID of the route. - ID string `json:"id"` - // Optional remark describing the route. - Comment string `json:"comment"` - // Timestamp of when the route was created. - CreatedAt interface{} `json:"created_at"` - // Timestamp of when the route was deleted. If `null`, the route has not been - // deleted. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // The private IPv4 or IPv6 range connected by the route, in CIDR notation. - Network string `json:"network"` - // The type of tunnel. - TunType ZeroTrustNetworkRouteIPGetResponseTunType `json:"tun_type"` - // UUID of the Cloudflare Tunnel serving the route. - TunnelID interface{} `json:"tunnel_id"` - // The user-friendly name of the Cloudflare Tunnel serving the route. - TunnelName interface{} `json:"tunnel_name"` - // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks - // are configured, the route is assigned to the default virtual network of the - // account. - VirtualNetworkID interface{} `json:"virtual_network_id"` - // A user-friendly name for the virtual network. - VirtualNetworkName string `json:"virtual_network_name"` - JSON zeroTrustNetworkRouteIPGetResponseJSON `json:"-"` -} - -// zeroTrustNetworkRouteIPGetResponseJSON contains the JSON metadata for the struct -// [ZeroTrustNetworkRouteIPGetResponse] -type zeroTrustNetworkRouteIPGetResponseJSON struct { - ID apijson.Field - Comment apijson.Field - CreatedAt apijson.Field - DeletedAt apijson.Field - Network apijson.Field - TunType apijson.Field - TunnelID apijson.Field - TunnelName apijson.Field - VirtualNetworkID apijson.Field - VirtualNetworkName apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteIPGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteIPGetResponseJSON) RawJSON() string { - return r.raw -} - -// The type of tunnel. -type ZeroTrustNetworkRouteIPGetResponseTunType string - -const ( - ZeroTrustNetworkRouteIPGetResponseTunTypeCfdTunnel ZeroTrustNetworkRouteIPGetResponseTunType = "cfd_tunnel" - ZeroTrustNetworkRouteIPGetResponseTunTypeWARPConnector ZeroTrustNetworkRouteIPGetResponseTunType = "warp_connector" - ZeroTrustNetworkRouteIPGetResponseTunTypeIPSec ZeroTrustNetworkRouteIPGetResponseTunType = "ip_sec" - ZeroTrustNetworkRouteIPGetResponseTunTypeGRE ZeroTrustNetworkRouteIPGetResponseTunType = "gre" - ZeroTrustNetworkRouteIPGetResponseTunTypeCni ZeroTrustNetworkRouteIPGetResponseTunType = "cni" -) - -type ZeroTrustNetworkRouteIPGetParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks - // are configured, the route is assigned to the default virtual network of the - // account. - VirtualNetworkID param.Field[interface{}] `query:"virtual_network_id"` -} - -// URLQuery serializes [ZeroTrustNetworkRouteIPGetParams]'s query parameters as -// `url.Values`. -func (r ZeroTrustNetworkRouteIPGetParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type ZeroTrustNetworkRouteIPGetResponseEnvelope struct { - Errors []ZeroTrustNetworkRouteIPGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustNetworkRouteIPGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustNetworkRouteIPGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustNetworkRouteIPGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustNetworkRouteIPGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustNetworkRouteIPGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustNetworkRouteIPGetResponseEnvelope] -type zeroTrustNetworkRouteIPGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteIPGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteIPGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteIPGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkRouteIPGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustNetworkRouteIPGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustNetworkRouteIPGetResponseEnvelopeErrors] -type zeroTrustNetworkRouteIPGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteIPGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteIPGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteIPGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkRouteIPGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustNetworkRouteIPGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustNetworkRouteIPGetResponseEnvelopeMessages] -type zeroTrustNetworkRouteIPGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteIPGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteIPGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustNetworkRouteIPGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustNetworkRouteIPGetResponseEnvelopeSuccessTrue ZeroTrustNetworkRouteIPGetResponseEnvelopeSuccess = true -) diff --git a/zerotrustnetworkrouteip_test.go b/zerotrustnetworkrouteip_test.go deleted file mode 100644 index 1c35238023b..00000000000 --- a/zerotrustnetworkrouteip_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustNetworkRouteIPGetWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Networks.Routes.IPs.Get( - context.TODO(), - "10.1.0.137", - cloudflare.ZeroTrustNetworkRouteIPGetParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - VirtualNetworkID: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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/zerotrustnetworkroutenetwork.go b/zerotrustnetworkroutenetwork.go deleted file mode 100644 index 012e6842ebd..00000000000 --- a/zerotrustnetworkroutenetwork.go +++ /dev/null @@ -1,505 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustNetworkRouteNetworkService 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 -// [NewZeroTrustNetworkRouteNetworkService] method instead. -type ZeroTrustNetworkRouteNetworkService struct { - Options []option.RequestOption -} - -// NewZeroTrustNetworkRouteNetworkService 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 NewZeroTrustNetworkRouteNetworkService(opts ...option.RequestOption) (r *ZeroTrustNetworkRouteNetworkService) { - r = &ZeroTrustNetworkRouteNetworkService{} - r.Options = opts - return -} - -// Routes a private network through a Cloudflare Tunnel. The CIDR in -// `ip_network_encoded` must be written in URL-encoded format. -func (r *ZeroTrustNetworkRouteNetworkService) New(ctx context.Context, ipNetworkEncoded string, params ZeroTrustNetworkRouteNetworkNewParams, opts ...option.RequestOption) (res *ZeroTrustNetworkRouteNetworkNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustNetworkRouteNetworkNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/teamnet/routes/network/%s", params.AccountID, ipNetworkEncoded) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes a private network route from an account. The CIDR in -// `ip_network_encoded` must be written in URL-encoded format. If no -// virtual_network_id is provided it will delete the route from the default vnet. -// If no tun_type is provided it will fetch the type from the tunnel_id or if that -// is missing it will assume Cloudflare Tunnel as default. If tunnel_id is provided -// it will delete the route from that tunnel, otherwise it will delete the route -// based on the vnet and tun_type. -func (r *ZeroTrustNetworkRouteNetworkService) Delete(ctx context.Context, ipNetworkEncoded string, params ZeroTrustNetworkRouteNetworkDeleteParams, opts ...option.RequestOption) (res *ZeroTrustNetworkRouteNetworkDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustNetworkRouteNetworkDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/teamnet/routes/network/%s", params.AccountID, ipNetworkEncoded) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates an existing private network route in an account. The CIDR in -// `ip_network_encoded` must be written in URL-encoded format. -func (r *ZeroTrustNetworkRouteNetworkService) Edit(ctx context.Context, ipNetworkEncoded string, body ZeroTrustNetworkRouteNetworkEditParams, opts ...option.RequestOption) (res *ZeroTrustNetworkRouteNetworkEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustNetworkRouteNetworkEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/teamnet/routes/network/%s", body.AccountID, ipNetworkEncoded) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustNetworkRouteNetworkNewResponse struct { - // UUID of the route. - ID string `json:"id"` - // Optional remark describing the route. - Comment string `json:"comment"` - // Timestamp of when the route was created. - CreatedAt interface{} `json:"created_at"` - // Timestamp of when the route was deleted. If `null`, the route has not been - // deleted. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // The private IPv4 or IPv6 range connected by the route, in CIDR notation. - Network string `json:"network"` - // UUID of the Cloudflare Tunnel serving the route. - TunnelID interface{} `json:"tunnel_id"` - // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks - // are configured, the route is assigned to the default virtual network of the - // account. - VirtualNetworkID interface{} `json:"virtual_network_id"` - JSON zeroTrustNetworkRouteNetworkNewResponseJSON `json:"-"` -} - -// zeroTrustNetworkRouteNetworkNewResponseJSON contains the JSON metadata for the -// struct [ZeroTrustNetworkRouteNetworkNewResponse] -type zeroTrustNetworkRouteNetworkNewResponseJSON struct { - ID apijson.Field - Comment apijson.Field - CreatedAt apijson.Field - DeletedAt apijson.Field - Network apijson.Field - TunnelID apijson.Field - VirtualNetworkID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteNetworkNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteNetworkNewResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteNetworkDeleteResponse struct { - // UUID of the route. - ID string `json:"id"` - // Optional remark describing the route. - Comment string `json:"comment"` - // Timestamp of when the route was created. - CreatedAt interface{} `json:"created_at"` - // Timestamp of when the route was deleted. If `null`, the route has not been - // deleted. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // The private IPv4 or IPv6 range connected by the route, in CIDR notation. - Network string `json:"network"` - // UUID of the Cloudflare Tunnel serving the route. - TunnelID interface{} `json:"tunnel_id"` - // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks - // are configured, the route is assigned to the default virtual network of the - // account. - VirtualNetworkID interface{} `json:"virtual_network_id"` - JSON zeroTrustNetworkRouteNetworkDeleteResponseJSON `json:"-"` -} - -// zeroTrustNetworkRouteNetworkDeleteResponseJSON contains the JSON metadata for -// the struct [ZeroTrustNetworkRouteNetworkDeleteResponse] -type zeroTrustNetworkRouteNetworkDeleteResponseJSON struct { - ID apijson.Field - Comment apijson.Field - CreatedAt apijson.Field - DeletedAt apijson.Field - Network apijson.Field - TunnelID apijson.Field - VirtualNetworkID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteNetworkDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteNetworkDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteNetworkEditResponse struct { - // UUID of the route. - ID string `json:"id"` - // Optional remark describing the route. - Comment string `json:"comment"` - // Timestamp of when the route was created. - CreatedAt interface{} `json:"created_at"` - // Timestamp of when the route was deleted. If `null`, the route has not been - // deleted. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // The private IPv4 or IPv6 range connected by the route, in CIDR notation. - Network string `json:"network"` - // UUID of the Cloudflare Tunnel serving the route. - TunnelID interface{} `json:"tunnel_id"` - // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks - // are configured, the route is assigned to the default virtual network of the - // account. - VirtualNetworkID interface{} `json:"virtual_network_id"` - JSON zeroTrustNetworkRouteNetworkEditResponseJSON `json:"-"` -} - -// zeroTrustNetworkRouteNetworkEditResponseJSON contains the JSON metadata for the -// struct [ZeroTrustNetworkRouteNetworkEditResponse] -type zeroTrustNetworkRouteNetworkEditResponseJSON struct { - ID apijson.Field - Comment apijson.Field - CreatedAt apijson.Field - DeletedAt apijson.Field - Network apijson.Field - TunnelID apijson.Field - VirtualNetworkID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteNetworkEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteNetworkEditResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteNetworkNewParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - // Optional remark describing the route. - Comment param.Field[string] `json:"comment"` - // UUID of the Tunnel Virtual Network this route belongs to. If no virtual networks - // are configured, the route is assigned to the default virtual network of the - // account. - VirtualNetworkID param.Field[interface{}] `json:"virtual_network_id"` -} - -func (r ZeroTrustNetworkRouteNetworkNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustNetworkRouteNetworkNewResponseEnvelope struct { - Errors []ZeroTrustNetworkRouteNetworkNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustNetworkRouteNetworkNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustNetworkRouteNetworkNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustNetworkRouteNetworkNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustNetworkRouteNetworkNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustNetworkRouteNetworkNewResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustNetworkRouteNetworkNewResponseEnvelope] -type zeroTrustNetworkRouteNetworkNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteNetworkNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteNetworkNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteNetworkNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkRouteNetworkNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustNetworkRouteNetworkNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustNetworkRouteNetworkNewResponseEnvelopeErrors] -type zeroTrustNetworkRouteNetworkNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteNetworkNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteNetworkNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteNetworkNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkRouteNetworkNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustNetworkRouteNetworkNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustNetworkRouteNetworkNewResponseEnvelopeMessages] -type zeroTrustNetworkRouteNetworkNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteNetworkNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteNetworkNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustNetworkRouteNetworkNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustNetworkRouteNetworkNewResponseEnvelopeSuccessTrue ZeroTrustNetworkRouteNetworkNewResponseEnvelopeSuccess = true -) - -type ZeroTrustNetworkRouteNetworkDeleteParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - // The type of tunnel. - TunType param.Field[ZeroTrustNetworkRouteNetworkDeleteParamsTunType] `query:"tun_type"` -} - -// URLQuery serializes [ZeroTrustNetworkRouteNetworkDeleteParams]'s query -// parameters as `url.Values`. -func (r ZeroTrustNetworkRouteNetworkDeleteParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// The type of tunnel. -type ZeroTrustNetworkRouteNetworkDeleteParamsTunType string - -const ( - ZeroTrustNetworkRouteNetworkDeleteParamsTunTypeCfdTunnel ZeroTrustNetworkRouteNetworkDeleteParamsTunType = "cfd_tunnel" - ZeroTrustNetworkRouteNetworkDeleteParamsTunTypeWARPConnector ZeroTrustNetworkRouteNetworkDeleteParamsTunType = "warp_connector" - ZeroTrustNetworkRouteNetworkDeleteParamsTunTypeIPSec ZeroTrustNetworkRouteNetworkDeleteParamsTunType = "ip_sec" - ZeroTrustNetworkRouteNetworkDeleteParamsTunTypeGRE ZeroTrustNetworkRouteNetworkDeleteParamsTunType = "gre" - ZeroTrustNetworkRouteNetworkDeleteParamsTunTypeCni ZeroTrustNetworkRouteNetworkDeleteParamsTunType = "cni" -) - -type ZeroTrustNetworkRouteNetworkDeleteResponseEnvelope struct { - Errors []ZeroTrustNetworkRouteNetworkDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustNetworkRouteNetworkDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustNetworkRouteNetworkDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustNetworkRouteNetworkDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustNetworkRouteNetworkDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustNetworkRouteNetworkDeleteResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustNetworkRouteNetworkDeleteResponseEnvelope] -type zeroTrustNetworkRouteNetworkDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteNetworkDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteNetworkDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteNetworkDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkRouteNetworkDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustNetworkRouteNetworkDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustNetworkRouteNetworkDeleteResponseEnvelopeErrors] -type zeroTrustNetworkRouteNetworkDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteNetworkDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteNetworkDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteNetworkDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkRouteNetworkDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustNetworkRouteNetworkDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustNetworkRouteNetworkDeleteResponseEnvelopeMessages] -type zeroTrustNetworkRouteNetworkDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteNetworkDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteNetworkDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustNetworkRouteNetworkDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustNetworkRouteNetworkDeleteResponseEnvelopeSuccessTrue ZeroTrustNetworkRouteNetworkDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustNetworkRouteNetworkEditParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustNetworkRouteNetworkEditResponseEnvelope struct { - Errors []ZeroTrustNetworkRouteNetworkEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustNetworkRouteNetworkEditResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustNetworkRouteNetworkEditResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustNetworkRouteNetworkEditResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustNetworkRouteNetworkEditResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustNetworkRouteNetworkEditResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustNetworkRouteNetworkEditResponseEnvelope] -type zeroTrustNetworkRouteNetworkEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteNetworkEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteNetworkEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteNetworkEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkRouteNetworkEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustNetworkRouteNetworkEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustNetworkRouteNetworkEditResponseEnvelopeErrors] -type zeroTrustNetworkRouteNetworkEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteNetworkEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteNetworkEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkRouteNetworkEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkRouteNetworkEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustNetworkRouteNetworkEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustNetworkRouteNetworkEditResponseEnvelopeMessages] -type zeroTrustNetworkRouteNetworkEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkRouteNetworkEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkRouteNetworkEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustNetworkRouteNetworkEditResponseEnvelopeSuccess bool - -const ( - ZeroTrustNetworkRouteNetworkEditResponseEnvelopeSuccessTrue ZeroTrustNetworkRouteNetworkEditResponseEnvelopeSuccess = true -) diff --git a/zerotrustnetworkroutenetwork_test.go b/zerotrustnetworkroutenetwork_test.go deleted file mode 100644 index 8b21293c8a4..00000000000 --- a/zerotrustnetworkroutenetwork_test.go +++ /dev/null @@ -1,107 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustNetworkRouteNetworkNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Networks.Routes.Networks.New( - context.TODO(), - "172.16.0.0%2F16", - cloudflare.ZeroTrustNetworkRouteNetworkNewParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Comment: cloudflare.F("Example comment for this route."), - VirtualNetworkID: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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 TestZeroTrustNetworkRouteNetworkDeleteWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Networks.Routes.Networks.Delete( - context.TODO(), - "172.16.0.0%2F16", - cloudflare.ZeroTrustNetworkRouteNetworkDeleteParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - TunType: cloudflare.F(cloudflare.ZeroTrustNetworkRouteNetworkDeleteParamsTunTypeCfdTunnel), - }, - ) - 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 TestZeroTrustNetworkRouteNetworkEdit(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("user@example.com"), - ) - _, err := client.ZeroTrust.Networks.Routes.Networks.Edit( - context.TODO(), - "172.16.0.0%2F16", - cloudflare.ZeroTrustNetworkRouteNetworkEditParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrustnetworkvirtualnetwork.go b/zerotrustnetworkvirtualnetwork.go deleted file mode 100644 index 9fdb5d97edf..00000000000 --- a/zerotrustnetworkvirtualnetwork.go +++ /dev/null @@ -1,630 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustNetworkVirtualNetworkService 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 -// [NewZeroTrustNetworkVirtualNetworkService] method instead. -type ZeroTrustNetworkVirtualNetworkService struct { - Options []option.RequestOption -} - -// NewZeroTrustNetworkVirtualNetworkService 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 NewZeroTrustNetworkVirtualNetworkService(opts ...option.RequestOption) (r *ZeroTrustNetworkVirtualNetworkService) { - r = &ZeroTrustNetworkVirtualNetworkService{} - r.Options = opts - return -} - -// Adds a new virtual network to an account. -func (r *ZeroTrustNetworkVirtualNetworkService) New(ctx context.Context, params ZeroTrustNetworkVirtualNetworkNewParams, opts ...option.RequestOption) (res *ZeroTrustNetworkVirtualNetworkNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustNetworkVirtualNetworkNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/teamnet/virtual_networks", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists and filters virtual networks in an account. -func (r *ZeroTrustNetworkVirtualNetworkService) List(ctx context.Context, params ZeroTrustNetworkVirtualNetworkListParams, opts ...option.RequestOption) (res *[]ZeroTrustNetworkVirtualNetworkListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustNetworkVirtualNetworkListResponseEnvelope - path := fmt.Sprintf("accounts/%s/teamnet/virtual_networks", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Deletes an existing virtual network. -func (r *ZeroTrustNetworkVirtualNetworkService) Delete(ctx context.Context, virtualNetworkID string, body ZeroTrustNetworkVirtualNetworkDeleteParams, opts ...option.RequestOption) (res *ZeroTrustNetworkVirtualNetworkDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustNetworkVirtualNetworkDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/teamnet/virtual_networks/%s", body.AccountID, virtualNetworkID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates an existing virtual network. -func (r *ZeroTrustNetworkVirtualNetworkService) Edit(ctx context.Context, virtualNetworkID string, params ZeroTrustNetworkVirtualNetworkEditParams, opts ...option.RequestOption) (res *ZeroTrustNetworkVirtualNetworkEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustNetworkVirtualNetworkEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/teamnet/virtual_networks/%s", params.AccountID, virtualNetworkID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [ZeroTrustNetworkVirtualNetworkNewResponseUnknown], -// [ZeroTrustNetworkVirtualNetworkNewResponseArray] or [shared.UnionString]. -type ZeroTrustNetworkVirtualNetworkNewResponse interface { - ImplementsZeroTrustNetworkVirtualNetworkNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustNetworkVirtualNetworkNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustNetworkVirtualNetworkNewResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustNetworkVirtualNetworkNewResponseArray []interface{} - -func (r ZeroTrustNetworkVirtualNetworkNewResponseArray) ImplementsZeroTrustNetworkVirtualNetworkNewResponse() { -} - -type ZeroTrustNetworkVirtualNetworkListResponse struct { - // UUID of the virtual network. - ID string `json:"id,required"` - // Optional remark describing the virtual network. - Comment string `json:"comment,required"` - // Timestamp of when the virtual network was created. - CreatedAt interface{} `json:"created_at,required"` - // If `true`, this virtual network is the default for the account. - IsDefaultNetwork bool `json:"is_default_network,required"` - // A user-friendly name for the virtual network. - Name string `json:"name,required"` - // Timestamp of when the virtual network was deleted. If `null`, the virtual - // network has not been deleted. - DeletedAt interface{} `json:"deleted_at"` - JSON zeroTrustNetworkVirtualNetworkListResponseJSON `json:"-"` -} - -// zeroTrustNetworkVirtualNetworkListResponseJSON contains the JSON metadata for -// the struct [ZeroTrustNetworkVirtualNetworkListResponse] -type zeroTrustNetworkVirtualNetworkListResponseJSON struct { - ID apijson.Field - Comment apijson.Field - CreatedAt apijson.Field - IsDefaultNetwork apijson.Field - Name apijson.Field - DeletedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkVirtualNetworkListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkVirtualNetworkListResponseJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [ZeroTrustNetworkVirtualNetworkDeleteResponseUnknown], -// [ZeroTrustNetworkVirtualNetworkDeleteResponseArray] or [shared.UnionString]. -type ZeroTrustNetworkVirtualNetworkDeleteResponse interface { - ImplementsZeroTrustNetworkVirtualNetworkDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustNetworkVirtualNetworkDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustNetworkVirtualNetworkDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustNetworkVirtualNetworkDeleteResponseArray []interface{} - -func (r ZeroTrustNetworkVirtualNetworkDeleteResponseArray) ImplementsZeroTrustNetworkVirtualNetworkDeleteResponse() { -} - -// Union satisfied by [ZeroTrustNetworkVirtualNetworkEditResponseUnknown], -// [ZeroTrustNetworkVirtualNetworkEditResponseArray] or [shared.UnionString]. -type ZeroTrustNetworkVirtualNetworkEditResponse interface { - ImplementsZeroTrustNetworkVirtualNetworkEditResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustNetworkVirtualNetworkEditResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustNetworkVirtualNetworkEditResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustNetworkVirtualNetworkEditResponseArray []interface{} - -func (r ZeroTrustNetworkVirtualNetworkEditResponseArray) ImplementsZeroTrustNetworkVirtualNetworkEditResponse() { -} - -type ZeroTrustNetworkVirtualNetworkNewParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - // A user-friendly name for the virtual network. - Name param.Field[string] `json:"name,required"` - // Optional remark describing the virtual network. - Comment param.Field[string] `json:"comment"` - // If `true`, this virtual network is the default for the account. - IsDefault param.Field[bool] `json:"is_default"` -} - -func (r ZeroTrustNetworkVirtualNetworkNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustNetworkVirtualNetworkNewResponseEnvelope struct { - Errors []ZeroTrustNetworkVirtualNetworkNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustNetworkVirtualNetworkNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustNetworkVirtualNetworkNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustNetworkVirtualNetworkNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustNetworkVirtualNetworkNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustNetworkVirtualNetworkNewResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustNetworkVirtualNetworkNewResponseEnvelope] -type zeroTrustNetworkVirtualNetworkNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkVirtualNetworkNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkVirtualNetworkNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkVirtualNetworkNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkVirtualNetworkNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustNetworkVirtualNetworkNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustNetworkVirtualNetworkNewResponseEnvelopeErrors] -type zeroTrustNetworkVirtualNetworkNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkVirtualNetworkNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkVirtualNetworkNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkVirtualNetworkNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkVirtualNetworkNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustNetworkVirtualNetworkNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustNetworkVirtualNetworkNewResponseEnvelopeMessages] -type zeroTrustNetworkVirtualNetworkNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkVirtualNetworkNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkVirtualNetworkNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustNetworkVirtualNetworkNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustNetworkVirtualNetworkNewResponseEnvelopeSuccessTrue ZeroTrustNetworkVirtualNetworkNewResponseEnvelopeSuccess = true -) - -type ZeroTrustNetworkVirtualNetworkListParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - // If `true`, only include the default virtual network. If `false`, exclude the - // default virtual network. If empty, all virtual networks will be included. - IsDefault param.Field[interface{}] `query:"is_default"` - // If `true`, only include deleted virtual networks. If `false`, exclude deleted - // virtual networks. If empty, all virtual networks will be included. - IsDeleted param.Field[interface{}] `query:"is_deleted"` - // A user-friendly name for the virtual network. - Name param.Field[string] `query:"name"` - // A user-friendly name for the virtual network. - VnetName param.Field[string] `query:"vnet_name"` -} - -// URLQuery serializes [ZeroTrustNetworkVirtualNetworkListParams]'s query -// parameters as `url.Values`. -func (r ZeroTrustNetworkVirtualNetworkListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type ZeroTrustNetworkVirtualNetworkListResponseEnvelope struct { - Errors []ZeroTrustNetworkVirtualNetworkListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustNetworkVirtualNetworkListResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustNetworkVirtualNetworkListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustNetworkVirtualNetworkListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustNetworkVirtualNetworkListResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustNetworkVirtualNetworkListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustNetworkVirtualNetworkListResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustNetworkVirtualNetworkListResponseEnvelope] -type zeroTrustNetworkVirtualNetworkListResponseEnvelopeJSON 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 *ZeroTrustNetworkVirtualNetworkListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkVirtualNetworkListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkVirtualNetworkListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkVirtualNetworkListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustNetworkVirtualNetworkListResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustNetworkVirtualNetworkListResponseEnvelopeErrors] -type zeroTrustNetworkVirtualNetworkListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkVirtualNetworkListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkVirtualNetworkListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkVirtualNetworkListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkVirtualNetworkListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustNetworkVirtualNetworkListResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustNetworkVirtualNetworkListResponseEnvelopeMessages] -type zeroTrustNetworkVirtualNetworkListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkVirtualNetworkListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkVirtualNetworkListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustNetworkVirtualNetworkListResponseEnvelopeSuccess bool - -const ( - ZeroTrustNetworkVirtualNetworkListResponseEnvelopeSuccessTrue ZeroTrustNetworkVirtualNetworkListResponseEnvelopeSuccess = true -) - -type ZeroTrustNetworkVirtualNetworkListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustNetworkVirtualNetworkListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustNetworkVirtualNetworkListResponseEnvelopeResultInfoJSON contains the -// JSON metadata for the struct -// [ZeroTrustNetworkVirtualNetworkListResponseEnvelopeResultInfo] -type zeroTrustNetworkVirtualNetworkListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkVirtualNetworkListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkVirtualNetworkListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkVirtualNetworkDeleteParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustNetworkVirtualNetworkDeleteResponseEnvelope struct { - Errors []ZeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustNetworkVirtualNetworkDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustNetworkVirtualNetworkDeleteResponseEnvelope] -type zeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkVirtualNetworkDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeErrors] -type zeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeMessages] -type zeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeSuccessTrue ZeroTrustNetworkVirtualNetworkDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustNetworkVirtualNetworkEditParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - // Optional remark describing the virtual network. - Comment param.Field[string] `json:"comment"` - // If `true`, this virtual network is the default for the account. - IsDefaultNetwork param.Field[bool] `json:"is_default_network"` - // A user-friendly name for the virtual network. - Name param.Field[string] `json:"name"` -} - -func (r ZeroTrustNetworkVirtualNetworkEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustNetworkVirtualNetworkEditResponseEnvelope struct { - Errors []ZeroTrustNetworkVirtualNetworkEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustNetworkVirtualNetworkEditResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustNetworkVirtualNetworkEditResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustNetworkVirtualNetworkEditResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustNetworkVirtualNetworkEditResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustNetworkVirtualNetworkEditResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustNetworkVirtualNetworkEditResponseEnvelope] -type zeroTrustNetworkVirtualNetworkEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkVirtualNetworkEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkVirtualNetworkEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkVirtualNetworkEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkVirtualNetworkEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustNetworkVirtualNetworkEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustNetworkVirtualNetworkEditResponseEnvelopeErrors] -type zeroTrustNetworkVirtualNetworkEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkVirtualNetworkEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkVirtualNetworkEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustNetworkVirtualNetworkEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustNetworkVirtualNetworkEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustNetworkVirtualNetworkEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustNetworkVirtualNetworkEditResponseEnvelopeMessages] -type zeroTrustNetworkVirtualNetworkEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustNetworkVirtualNetworkEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustNetworkVirtualNetworkEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustNetworkVirtualNetworkEditResponseEnvelopeSuccess bool - -const ( - ZeroTrustNetworkVirtualNetworkEditResponseEnvelopeSuccessTrue ZeroTrustNetworkVirtualNetworkEditResponseEnvelopeSuccess = true -) diff --git a/zerotrustnetworkvirtualnetwork_test.go b/zerotrustnetworkvirtualnetwork_test.go deleted file mode 100644 index 2450a04c62b..00000000000 --- a/zerotrustnetworkvirtualnetwork_test.go +++ /dev/null @@ -1,136 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustNetworkVirtualNetworkNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Networks.VirtualNetworks.New(context.TODO(), cloudflare.ZeroTrustNetworkVirtualNetworkNewParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Name: cloudflare.F("us-east-1-vpc"), - Comment: cloudflare.F("Staging VPC for data science"), - IsDefault: cloudflare.F(true), - }) - 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 TestZeroTrustNetworkVirtualNetworkListWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Networks.VirtualNetworks.List(context.TODO(), cloudflare.ZeroTrustNetworkVirtualNetworkListParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - IsDefault: cloudflare.F[any](map[string]interface{}{}), - IsDeleted: cloudflare.F[any](map[string]interface{}{}), - Name: cloudflare.F("us-east-1-vpc"), - VnetName: cloudflare.F("us-east-1-vpc"), - }) - 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 TestZeroTrustNetworkVirtualNetworkDelete(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("user@example.com"), - ) - _, err := client.ZeroTrust.Networks.VirtualNetworks.Delete( - context.TODO(), - "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustNetworkVirtualNetworkDeleteParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - }, - ) - 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 TestZeroTrustNetworkVirtualNetworkEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Networks.VirtualNetworks.Edit( - context.TODO(), - "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustNetworkVirtualNetworkEditParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Comment: cloudflare.F("Staging VPC for data science"), - IsDefaultNetwork: cloudflare.F(true), - Name: cloudflare.F("us-east-1-vpc"), - }, - ) - 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/zerotrustorganization.go b/zerotrustorganization.go deleted file mode 100644 index cfb731a5102..00000000000 --- a/zerotrustorganization.go +++ /dev/null @@ -1,915 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustOrganizationService 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 [NewZeroTrustOrganizationService] -// method instead. -type ZeroTrustOrganizationService struct { - Options []option.RequestOption -} - -// NewZeroTrustOrganizationService 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 NewZeroTrustOrganizationService(opts ...option.RequestOption) (r *ZeroTrustOrganizationService) { - r = &ZeroTrustOrganizationService{} - r.Options = opts - return -} - -// Sets up a Zero Trust organization for your account or zone. -func (r *ZeroTrustOrganizationService) New(ctx context.Context, params ZeroTrustOrganizationNewParams, opts ...option.RequestOption) (res *ZeroTrustOrganizationNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustOrganizationNewResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/access/organizations", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates the configuration for your Zero Trust organization. -func (r *ZeroTrustOrganizationService) Update(ctx context.Context, params ZeroTrustOrganizationUpdateParams, opts ...option.RequestOption) (res *ZeroTrustOrganizationUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustOrganizationUpdateResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/access/organizations", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Returns the configuration for your Zero Trust organization. -func (r *ZeroTrustOrganizationService) List(ctx context.Context, query ZeroTrustOrganizationListParams, opts ...option.RequestOption) (res *ZeroTrustOrganizationListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustOrganizationListResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if query.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = query.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = query.ZoneID - } - path := fmt.Sprintf("%s/%s/access/organizations", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Revokes a user's access across all applications. -func (r *ZeroTrustOrganizationService) RevokeUsers(ctx context.Context, params ZeroTrustOrganizationRevokeUsersParams, opts ...option.RequestOption) (res *ZeroTrustOrganizationRevokeUsersResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustOrganizationRevokeUsersResponseEnvelope - var accountOrZone string - var accountOrZoneID param.Field[string] - if params.AccountID.Present { - accountOrZone = "accounts" - accountOrZoneID = params.AccountID - } else { - accountOrZone = "zones" - accountOrZoneID = params.ZoneID - } - path := fmt.Sprintf("%s/%s/access/organizations/revoke_user", accountOrZone, accountOrZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustOrganizationNewResponse struct { - // When set to true, users can authenticate via WARP for any application in your - // organization. Application settings will take precedence over this value. - AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` - // The unique subdomain assigned to your Zero Trust organization. - AuthDomain string `json:"auth_domain"` - // When set to `true`, users skip the identity provider selection step during - // login. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - CustomPages ZeroTrustOrganizationNewResponseCustomPages `json:"custom_pages"` - // Lock all settings as Read-Only in the Dashboard, regardless of user permission. - // Updates may only be made via the API or Terraform for this account when enabled. - IsUiReadOnly bool `json:"is_ui_read_only"` - LoginDesign ZeroTrustOrganizationNewResponseLoginDesign `json:"login_design"` - // The name of your Zero Trust organization. - Name string `json:"name"` - // The amount of time that tokens issued for applications will be valid. Must be in - // the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, - // h. - SessionDuration string `json:"session_duration"` - // A description of the reason why the UI read only field is being toggled. - UiReadOnlyToggleReason string `json:"ui_read_only_toggle_reason"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - // The amount of time a user seat is inactive before it expires. When the user seat - // exceeds the set time of inactivity, the user is removed as an active seat and no - // longer counts against your Teams seat count. Must be in the format `300ms` or - // `2h45m`. Valid time units are: `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. - UserSeatExpirationInactiveTime string `json:"user_seat_expiration_inactive_time"` - // The amount of time that tokens issued for applications will be valid. Must be in - // the format `30m` or `2h45m`. Valid time units are: m, h. - WARPAuthSessionDuration string `json:"warp_auth_session_duration"` - JSON zeroTrustOrganizationNewResponseJSON `json:"-"` -} - -// zeroTrustOrganizationNewResponseJSON contains the JSON metadata for the struct -// [ZeroTrustOrganizationNewResponse] -type zeroTrustOrganizationNewResponseJSON struct { - AllowAuthenticateViaWARP apijson.Field - AuthDomain apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - CustomPages apijson.Field - IsUiReadOnly apijson.Field - LoginDesign apijson.Field - Name apijson.Field - SessionDuration apijson.Field - UiReadOnlyToggleReason apijson.Field - UpdatedAt apijson.Field - UserSeatExpirationInactiveTime apijson.Field - WARPAuthSessionDuration apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationNewResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustOrganizationNewResponseCustomPages struct { - // The uid of the custom page to use when a user is denied access after failing a - // non-identity rule. - Forbidden string `json:"forbidden"` - // The uid of the custom page to use when a user is denied access. - IdentityDenied string `json:"identity_denied"` - JSON zeroTrustOrganizationNewResponseCustomPagesJSON `json:"-"` -} - -// zeroTrustOrganizationNewResponseCustomPagesJSON contains the JSON metadata for -// the struct [ZeroTrustOrganizationNewResponseCustomPages] -type zeroTrustOrganizationNewResponseCustomPagesJSON struct { - Forbidden apijson.Field - IdentityDenied apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationNewResponseCustomPages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationNewResponseCustomPagesJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustOrganizationNewResponseLoginDesign struct { - // The background color on your login page. - BackgroundColor string `json:"background_color"` - // The text at the bottom of your login page. - FooterText string `json:"footer_text"` - // The text at the top of your login page. - HeaderText string `json:"header_text"` - // The URL of the logo on your login page. - LogoPath string `json:"logo_path"` - // The text color on your login page. - TextColor string `json:"text_color"` - JSON zeroTrustOrganizationNewResponseLoginDesignJSON `json:"-"` -} - -// zeroTrustOrganizationNewResponseLoginDesignJSON contains the JSON metadata for -// the struct [ZeroTrustOrganizationNewResponseLoginDesign] -type zeroTrustOrganizationNewResponseLoginDesignJSON struct { - BackgroundColor apijson.Field - FooterText apijson.Field - HeaderText apijson.Field - LogoPath apijson.Field - TextColor apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationNewResponseLoginDesign) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationNewResponseLoginDesignJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustOrganizationUpdateResponse struct { - // When set to true, users can authenticate via WARP for any application in your - // organization. Application settings will take precedence over this value. - AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` - // The unique subdomain assigned to your Zero Trust organization. - AuthDomain string `json:"auth_domain"` - // When set to `true`, users skip the identity provider selection step during - // login. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - CustomPages ZeroTrustOrganizationUpdateResponseCustomPages `json:"custom_pages"` - // Lock all settings as Read-Only in the Dashboard, regardless of user permission. - // Updates may only be made via the API or Terraform for this account when enabled. - IsUiReadOnly bool `json:"is_ui_read_only"` - LoginDesign ZeroTrustOrganizationUpdateResponseLoginDesign `json:"login_design"` - // The name of your Zero Trust organization. - Name string `json:"name"` - // The amount of time that tokens issued for applications will be valid. Must be in - // the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, - // h. - SessionDuration string `json:"session_duration"` - // A description of the reason why the UI read only field is being toggled. - UiReadOnlyToggleReason string `json:"ui_read_only_toggle_reason"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - // The amount of time a user seat is inactive before it expires. When the user seat - // exceeds the set time of inactivity, the user is removed as an active seat and no - // longer counts against your Teams seat count. Must be in the format `300ms` or - // `2h45m`. Valid time units are: `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. - UserSeatExpirationInactiveTime string `json:"user_seat_expiration_inactive_time"` - // The amount of time that tokens issued for applications will be valid. Must be in - // the format `30m` or `2h45m`. Valid time units are: m, h. - WARPAuthSessionDuration string `json:"warp_auth_session_duration"` - JSON zeroTrustOrganizationUpdateResponseJSON `json:"-"` -} - -// zeroTrustOrganizationUpdateResponseJSON contains the JSON metadata for the -// struct [ZeroTrustOrganizationUpdateResponse] -type zeroTrustOrganizationUpdateResponseJSON struct { - AllowAuthenticateViaWARP apijson.Field - AuthDomain apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - CustomPages apijson.Field - IsUiReadOnly apijson.Field - LoginDesign apijson.Field - Name apijson.Field - SessionDuration apijson.Field - UiReadOnlyToggleReason apijson.Field - UpdatedAt apijson.Field - UserSeatExpirationInactiveTime apijson.Field - WARPAuthSessionDuration apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationUpdateResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustOrganizationUpdateResponseCustomPages struct { - // The uid of the custom page to use when a user is denied access after failing a - // non-identity rule. - Forbidden string `json:"forbidden"` - // The uid of the custom page to use when a user is denied access. - IdentityDenied string `json:"identity_denied"` - JSON zeroTrustOrganizationUpdateResponseCustomPagesJSON `json:"-"` -} - -// zeroTrustOrganizationUpdateResponseCustomPagesJSON contains the JSON metadata -// for the struct [ZeroTrustOrganizationUpdateResponseCustomPages] -type zeroTrustOrganizationUpdateResponseCustomPagesJSON struct { - Forbidden apijson.Field - IdentityDenied apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationUpdateResponseCustomPages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationUpdateResponseCustomPagesJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustOrganizationUpdateResponseLoginDesign struct { - // The background color on your login page. - BackgroundColor string `json:"background_color"` - // The text at the bottom of your login page. - FooterText string `json:"footer_text"` - // The text at the top of your login page. - HeaderText string `json:"header_text"` - // The URL of the logo on your login page. - LogoPath string `json:"logo_path"` - // The text color on your login page. - TextColor string `json:"text_color"` - JSON zeroTrustOrganizationUpdateResponseLoginDesignJSON `json:"-"` -} - -// zeroTrustOrganizationUpdateResponseLoginDesignJSON contains the JSON metadata -// for the struct [ZeroTrustOrganizationUpdateResponseLoginDesign] -type zeroTrustOrganizationUpdateResponseLoginDesignJSON struct { - BackgroundColor apijson.Field - FooterText apijson.Field - HeaderText apijson.Field - LogoPath apijson.Field - TextColor apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationUpdateResponseLoginDesign) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationUpdateResponseLoginDesignJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustOrganizationListResponse struct { - // When set to true, users can authenticate via WARP for any application in your - // organization. Application settings will take precedence over this value. - AllowAuthenticateViaWARP bool `json:"allow_authenticate_via_warp"` - // The unique subdomain assigned to your Zero Trust organization. - AuthDomain string `json:"auth_domain"` - // When set to `true`, users skip the identity provider selection step during - // login. - AutoRedirectToIdentity bool `json:"auto_redirect_to_identity"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - CustomPages ZeroTrustOrganizationListResponseCustomPages `json:"custom_pages"` - // Lock all settings as Read-Only in the Dashboard, regardless of user permission. - // Updates may only be made via the API or Terraform for this account when enabled. - IsUiReadOnly bool `json:"is_ui_read_only"` - LoginDesign ZeroTrustOrganizationListResponseLoginDesign `json:"login_design"` - // The name of your Zero Trust organization. - Name string `json:"name"` - // The amount of time that tokens issued for applications will be valid. Must be in - // the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, - // h. - SessionDuration string `json:"session_duration"` - // A description of the reason why the UI read only field is being toggled. - UiReadOnlyToggleReason string `json:"ui_read_only_toggle_reason"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - // The amount of time a user seat is inactive before it expires. When the user seat - // exceeds the set time of inactivity, the user is removed as an active seat and no - // longer counts against your Teams seat count. Must be in the format `300ms` or - // `2h45m`. Valid time units are: `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. - UserSeatExpirationInactiveTime string `json:"user_seat_expiration_inactive_time"` - // The amount of time that tokens issued for applications will be valid. Must be in - // the format `30m` or `2h45m`. Valid time units are: m, h. - WARPAuthSessionDuration string `json:"warp_auth_session_duration"` - JSON zeroTrustOrganizationListResponseJSON `json:"-"` -} - -// zeroTrustOrganizationListResponseJSON contains the JSON metadata for the struct -// [ZeroTrustOrganizationListResponse] -type zeroTrustOrganizationListResponseJSON struct { - AllowAuthenticateViaWARP apijson.Field - AuthDomain apijson.Field - AutoRedirectToIdentity apijson.Field - CreatedAt apijson.Field - CustomPages apijson.Field - IsUiReadOnly apijson.Field - LoginDesign apijson.Field - Name apijson.Field - SessionDuration apijson.Field - UiReadOnlyToggleReason apijson.Field - UpdatedAt apijson.Field - UserSeatExpirationInactiveTime apijson.Field - WARPAuthSessionDuration apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationListResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustOrganizationListResponseCustomPages struct { - // The uid of the custom page to use when a user is denied access after failing a - // non-identity rule. - Forbidden string `json:"forbidden"` - // The uid of the custom page to use when a user is denied access. - IdentityDenied string `json:"identity_denied"` - JSON zeroTrustOrganizationListResponseCustomPagesJSON `json:"-"` -} - -// zeroTrustOrganizationListResponseCustomPagesJSON contains the JSON metadata for -// the struct [ZeroTrustOrganizationListResponseCustomPages] -type zeroTrustOrganizationListResponseCustomPagesJSON struct { - Forbidden apijson.Field - IdentityDenied apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationListResponseCustomPages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationListResponseCustomPagesJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustOrganizationListResponseLoginDesign struct { - // The background color on your login page. - BackgroundColor string `json:"background_color"` - // The text at the bottom of your login page. - FooterText string `json:"footer_text"` - // The text at the top of your login page. - HeaderText string `json:"header_text"` - // The URL of the logo on your login page. - LogoPath string `json:"logo_path"` - // The text color on your login page. - TextColor string `json:"text_color"` - JSON zeroTrustOrganizationListResponseLoginDesignJSON `json:"-"` -} - -// zeroTrustOrganizationListResponseLoginDesignJSON contains the JSON metadata for -// the struct [ZeroTrustOrganizationListResponseLoginDesign] -type zeroTrustOrganizationListResponseLoginDesignJSON struct { - BackgroundColor apijson.Field - FooterText apijson.Field - HeaderText apijson.Field - LogoPath apijson.Field - TextColor apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationListResponseLoginDesign) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationListResponseLoginDesignJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustOrganizationRevokeUsersResponse bool - -const ( - ZeroTrustOrganizationRevokeUsersResponseTrue ZeroTrustOrganizationRevokeUsersResponse = true - ZeroTrustOrganizationRevokeUsersResponseFalse ZeroTrustOrganizationRevokeUsersResponse = false -) - -type ZeroTrustOrganizationNewParams struct { - // The unique subdomain assigned to your Zero Trust organization. - AuthDomain param.Field[string] `json:"auth_domain,required"` - // The name of your Zero Trust organization. - Name param.Field[string] `json:"name,required"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // When set to true, users can authenticate via WARP for any application in your - // organization. Application settings will take precedence over this value. - AllowAuthenticateViaWARP param.Field[bool] `json:"allow_authenticate_via_warp"` - // When set to `true`, users skip the identity provider selection step during - // login. - AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` - // Lock all settings as Read-Only in the Dashboard, regardless of user permission. - // Updates may only be made via the API or Terraform for this account when enabled. - IsUiReadOnly param.Field[bool] `json:"is_ui_read_only"` - LoginDesign param.Field[ZeroTrustOrganizationNewParamsLoginDesign] `json:"login_design"` - // The amount of time that tokens issued for applications will be valid. Must be in - // the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, - // h. - SessionDuration param.Field[string] `json:"session_duration"` - // A description of the reason why the UI read only field is being toggled. - UiReadOnlyToggleReason param.Field[string] `json:"ui_read_only_toggle_reason"` - // The amount of time a user seat is inactive before it expires. When the user seat - // exceeds the set time of inactivity, the user is removed as an active seat and no - // longer counts against your Teams seat count. Must be in the format `300ms` or - // `2h45m`. Valid time units are: `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. - UserSeatExpirationInactiveTime param.Field[string] `json:"user_seat_expiration_inactive_time"` - // The amount of time that tokens issued for applications will be valid. Must be in - // the format `30m` or `2h45m`. Valid time units are: m, h. - WARPAuthSessionDuration param.Field[string] `json:"warp_auth_session_duration"` -} - -func (r ZeroTrustOrganizationNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustOrganizationNewParamsLoginDesign struct { - // The background color on your login page. - BackgroundColor param.Field[string] `json:"background_color"` - // The text at the bottom of your login page. - FooterText param.Field[string] `json:"footer_text"` - // The text at the top of your login page. - HeaderText param.Field[string] `json:"header_text"` - // The URL of the logo on your login page. - LogoPath param.Field[string] `json:"logo_path"` - // The text color on your login page. - TextColor param.Field[string] `json:"text_color"` -} - -func (r ZeroTrustOrganizationNewParamsLoginDesign) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustOrganizationNewResponseEnvelope struct { - Errors []ZeroTrustOrganizationNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustOrganizationNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustOrganizationNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustOrganizationNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustOrganizationNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustOrganizationNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustOrganizationNewResponseEnvelope] -type zeroTrustOrganizationNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustOrganizationNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustOrganizationNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustOrganizationNewResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustOrganizationNewResponseEnvelopeErrors] -type zeroTrustOrganizationNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustOrganizationNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustOrganizationNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustOrganizationNewResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustOrganizationNewResponseEnvelopeMessages] -type zeroTrustOrganizationNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustOrganizationNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustOrganizationNewResponseEnvelopeSuccessTrue ZeroTrustOrganizationNewResponseEnvelopeSuccess = true -) - -type ZeroTrustOrganizationUpdateParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` - // When set to true, users can authenticate via WARP for any application in your - // organization. Application settings will take precedence over this value. - AllowAuthenticateViaWARP param.Field[bool] `json:"allow_authenticate_via_warp"` - // The unique subdomain assigned to your Zero Trust organization. - AuthDomain param.Field[string] `json:"auth_domain"` - // When set to `true`, users skip the identity provider selection step during - // login. - AutoRedirectToIdentity param.Field[bool] `json:"auto_redirect_to_identity"` - CustomPages param.Field[ZeroTrustOrganizationUpdateParamsCustomPages] `json:"custom_pages"` - // Lock all settings as Read-Only in the Dashboard, regardless of user permission. - // Updates may only be made via the API or Terraform for this account when enabled. - IsUiReadOnly param.Field[bool] `json:"is_ui_read_only"` - LoginDesign param.Field[ZeroTrustOrganizationUpdateParamsLoginDesign] `json:"login_design"` - // The name of your Zero Trust organization. - Name param.Field[string] `json:"name"` - // The amount of time that tokens issued for applications will be valid. Must be in - // the format `300ms` or `2h45m`. Valid time units are: ns, us (or µs), ms, s, m, - // h. - SessionDuration param.Field[string] `json:"session_duration"` - // A description of the reason why the UI read only field is being toggled. - UiReadOnlyToggleReason param.Field[string] `json:"ui_read_only_toggle_reason"` - // The amount of time a user seat is inactive before it expires. When the user seat - // exceeds the set time of inactivity, the user is removed as an active seat and no - // longer counts against your Teams seat count. Must be in the format `300ms` or - // `2h45m`. Valid time units are: `ns`, `us` (or `µs`), `ms`, `s`, `m`, `h`. - UserSeatExpirationInactiveTime param.Field[string] `json:"user_seat_expiration_inactive_time"` - // The amount of time that tokens issued for applications will be valid. Must be in - // the format `30m` or `2h45m`. Valid time units are: m, h. - WARPAuthSessionDuration param.Field[string] `json:"warp_auth_session_duration"` -} - -func (r ZeroTrustOrganizationUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustOrganizationUpdateParamsCustomPages struct { - // The uid of the custom page to use when a user is denied access after failing a - // non-identity rule. - Forbidden param.Field[string] `json:"forbidden"` - // The uid of the custom page to use when a user is denied access. - IdentityDenied param.Field[string] `json:"identity_denied"` -} - -func (r ZeroTrustOrganizationUpdateParamsCustomPages) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustOrganizationUpdateParamsLoginDesign struct { - // The background color on your login page. - BackgroundColor param.Field[string] `json:"background_color"` - // The text at the bottom of your login page. - FooterText param.Field[string] `json:"footer_text"` - // The text at the top of your login page. - HeaderText param.Field[string] `json:"header_text"` - // The URL of the logo on your login page. - LogoPath param.Field[string] `json:"logo_path"` - // The text color on your login page. - TextColor param.Field[string] `json:"text_color"` -} - -func (r ZeroTrustOrganizationUpdateParamsLoginDesign) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustOrganizationUpdateResponseEnvelope struct { - Errors []ZeroTrustOrganizationUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustOrganizationUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustOrganizationUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustOrganizationUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustOrganizationUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustOrganizationUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustOrganizationUpdateResponseEnvelope] -type zeroTrustOrganizationUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustOrganizationUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustOrganizationUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustOrganizationUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustOrganizationUpdateResponseEnvelopeErrors] -type zeroTrustOrganizationUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustOrganizationUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustOrganizationUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustOrganizationUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustOrganizationUpdateResponseEnvelopeMessages] -type zeroTrustOrganizationUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustOrganizationUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustOrganizationUpdateResponseEnvelopeSuccessTrue ZeroTrustOrganizationUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustOrganizationListParams struct { - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -type ZeroTrustOrganizationListResponseEnvelope struct { - Errors []ZeroTrustOrganizationListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustOrganizationListResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustOrganizationListResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustOrganizationListResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustOrganizationListResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustOrganizationListResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustOrganizationListResponseEnvelope] -type zeroTrustOrganizationListResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustOrganizationListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustOrganizationListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustOrganizationListResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustOrganizationListResponseEnvelopeErrors] -type zeroTrustOrganizationListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustOrganizationListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustOrganizationListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustOrganizationListResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustOrganizationListResponseEnvelopeMessages] -type zeroTrustOrganizationListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustOrganizationListResponseEnvelopeSuccess bool - -const ( - ZeroTrustOrganizationListResponseEnvelopeSuccessTrue ZeroTrustOrganizationListResponseEnvelopeSuccess = true -) - -type ZeroTrustOrganizationRevokeUsersParams struct { - // The email of the user to revoke. - Email param.Field[string] `json:"email,required"` - // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - AccountID param.Field[string] `path:"account_id"` - // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - ZoneID param.Field[string] `path:"zone_id"` -} - -func (r ZeroTrustOrganizationRevokeUsersParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustOrganizationRevokeUsersResponseEnvelope struct { - Result ZeroTrustOrganizationRevokeUsersResponse `json:"result"` - Success ZeroTrustOrganizationRevokeUsersResponseEnvelopeSuccess `json:"success"` - JSON zeroTrustOrganizationRevokeUsersResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustOrganizationRevokeUsersResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustOrganizationRevokeUsersResponseEnvelope] -type zeroTrustOrganizationRevokeUsersResponseEnvelopeJSON struct { - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustOrganizationRevokeUsersResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustOrganizationRevokeUsersResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustOrganizationRevokeUsersResponseEnvelopeSuccess bool - -const ( - ZeroTrustOrganizationRevokeUsersResponseEnvelopeSuccessTrue ZeroTrustOrganizationRevokeUsersResponseEnvelopeSuccess = true - ZeroTrustOrganizationRevokeUsersResponseEnvelopeSuccessFalse ZeroTrustOrganizationRevokeUsersResponseEnvelopeSuccess = false -) diff --git a/zerotrustorganization_test.go b/zerotrustorganization_test.go deleted file mode 100644 index 804c9753a8e..00000000000 --- a/zerotrustorganization_test.go +++ /dev/null @@ -1,159 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustOrganizationNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Organizations.New(context.TODO(), cloudflare.ZeroTrustOrganizationNewParams{ - AuthDomain: cloudflare.F("test.cloudflareaccess.com"), - Name: cloudflare.F("Widget Corps Internal Applications"), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - AllowAuthenticateViaWARP: cloudflare.F(true), - AutoRedirectToIdentity: cloudflare.F(true), - IsUiReadOnly: cloudflare.F(true), - LoginDesign: cloudflare.F(cloudflare.ZeroTrustOrganizationNewParamsLoginDesign{ - BackgroundColor: cloudflare.F("#c5ed1b"), - FooterText: cloudflare.F("This is an example description."), - HeaderText: cloudflare.F("This is an example description."), - LogoPath: cloudflare.F("https://example.com/logo.png"), - TextColor: cloudflare.F("#c5ed1b"), - }), - SessionDuration: cloudflare.F("24h"), - UiReadOnlyToggleReason: cloudflare.F("Temporarily turn off the UI read only lock to make a change via the UI"), - UserSeatExpirationInactiveTime: cloudflare.F("720h"), - WARPAuthSessionDuration: cloudflare.F("24h"), - }) - 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 TestZeroTrustOrganizationUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Organizations.Update(context.TODO(), cloudflare.ZeroTrustOrganizationUpdateParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - AllowAuthenticateViaWARP: cloudflare.F(true), - AuthDomain: cloudflare.F("test.cloudflareaccess.com"), - AutoRedirectToIdentity: cloudflare.F(true), - CustomPages: cloudflare.F(cloudflare.ZeroTrustOrganizationUpdateParamsCustomPages{ - Forbidden: cloudflare.F("699d98642c564d2e855e9661899b7252"), - IdentityDenied: cloudflare.F("699d98642c564d2e855e9661899b7252"), - }), - IsUiReadOnly: cloudflare.F(true), - LoginDesign: cloudflare.F(cloudflare.ZeroTrustOrganizationUpdateParamsLoginDesign{ - BackgroundColor: cloudflare.F("#c5ed1b"), - FooterText: cloudflare.F("This is an example description."), - HeaderText: cloudflare.F("This is an example description."), - LogoPath: cloudflare.F("https://example.com/logo.png"), - TextColor: cloudflare.F("#c5ed1b"), - }), - Name: cloudflare.F("Widget Corps Internal Applications"), - SessionDuration: cloudflare.F("24h"), - UiReadOnlyToggleReason: cloudflare.F("Temporarily turn off the UI read only lock to make a change via the UI"), - UserSeatExpirationInactiveTime: cloudflare.F("720h"), - WARPAuthSessionDuration: cloudflare.F("24h"), - }) - 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 TestZeroTrustOrganizationListWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Organizations.List(context.TODO(), cloudflare.ZeroTrustOrganizationListParams{ - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }) - 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 TestZeroTrustOrganizationRevokeUsersWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Organizations.RevokeUsers(context.TODO(), cloudflare.ZeroTrustOrganizationRevokeUsersParams{ - Email: cloudflare.F("test@example.com"), - AccountID: cloudflare.F("string"), - ZoneID: cloudflare.F("string"), - }) - 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/zerotrustseat.go b/zerotrustseat.go deleted file mode 100644 index 4cca9dd1f52..00000000000 --- a/zerotrustseat.go +++ /dev/null @@ -1,212 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustSeatService 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 [NewZeroTrustSeatService] method -// instead. -type ZeroTrustSeatService struct { - Options []option.RequestOption -} - -// NewZeroTrustSeatService 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 NewZeroTrustSeatService(opts ...option.RequestOption) (r *ZeroTrustSeatService) { - r = &ZeroTrustSeatService{} - r.Options = opts - return -} - -// Removes a user from a Zero Trust seat when both `access_seat` and `gateway_seat` -// are set to false. -func (r *ZeroTrustSeatService) Edit(ctx context.Context, identifier string, body ZeroTrustSeatEditParams, opts ...option.RequestOption) (res *[]ZeroTrustSeatEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustSeatEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/access/seats", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustSeatEditResponse struct { - // True if the seat is part of Access. - AccessSeat bool `json:"access_seat"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - // True if the seat is part of Gateway. - GatewaySeat bool `json:"gateway_seat"` - // Identifier - SeatUid string `json:"seat_uid"` - UpdatedAt time.Time `json:"updated_at" format:"date-time"` - JSON zeroTrustSeatEditResponseJSON `json:"-"` -} - -// zeroTrustSeatEditResponseJSON contains the JSON metadata for the struct -// [ZeroTrustSeatEditResponse] -type zeroTrustSeatEditResponseJSON struct { - AccessSeat apijson.Field - CreatedAt apijson.Field - GatewaySeat apijson.Field - SeatUid apijson.Field - UpdatedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustSeatEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustSeatEditResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustSeatEditParams struct { - Body param.Field[[]ZeroTrustSeatEditParamsBody] `json:"body,required"` -} - -func (r ZeroTrustSeatEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type ZeroTrustSeatEditParamsBody struct { - // True if the seat is part of Access. - AccessSeat param.Field[bool] `json:"access_seat,required"` - // True if the seat is part of Gateway. - GatewaySeat param.Field[bool] `json:"gateway_seat,required"` -} - -func (r ZeroTrustSeatEditParamsBody) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustSeatEditResponseEnvelope struct { - Errors []ZeroTrustSeatEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustSeatEditResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustSeatEditResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustSeatEditResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustSeatEditResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustSeatEditResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustSeatEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [ZeroTrustSeatEditResponseEnvelope] -type zeroTrustSeatEditResponseEnvelopeJSON 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 *ZeroTrustSeatEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustSeatEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustSeatEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustSeatEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustSeatEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZeroTrustSeatEditResponseEnvelopeErrors] -type zeroTrustSeatEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustSeatEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustSeatEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustSeatEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustSeatEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustSeatEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ZeroTrustSeatEditResponseEnvelopeMessages] -type zeroTrustSeatEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustSeatEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustSeatEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustSeatEditResponseEnvelopeSuccess bool - -const ( - ZeroTrustSeatEditResponseEnvelopeSuccessTrue ZeroTrustSeatEditResponseEnvelopeSuccess = true -) - -type ZeroTrustSeatEditResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustSeatEditResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustSeatEditResponseEnvelopeResultInfoJSON contains the JSON metadata for -// the struct [ZeroTrustSeatEditResponseEnvelopeResultInfo] -type zeroTrustSeatEditResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustSeatEditResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustSeatEditResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zerotrustseat_test.go b/zerotrustseat_test.go deleted file mode 100644 index 169c48c16bf..00000000000 --- a/zerotrustseat_test.go +++ /dev/null @@ -1,53 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustSeatEdit(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("user@example.com"), - ) - _, err := client.ZeroTrust.Seats.Edit( - context.TODO(), - "023e105f4ecef8ad9ca31a8372d0c353", - cloudflare.ZeroTrustSeatEditParams{ - Body: cloudflare.F([]cloudflare.ZeroTrustSeatEditParamsBody{{ - AccessSeat: cloudflare.F(false), - GatewaySeat: cloudflare.F(false), - }, { - AccessSeat: cloudflare.F(false), - GatewaySeat: cloudflare.F(false), - }, { - AccessSeat: cloudflare.F(false), - GatewaySeat: cloudflare.F(false), - }}), - }, - ) - 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/zerotrusttunnel.go b/zerotrusttunnel.go deleted file mode 100644 index 53b5703c425..00000000000 --- a/zerotrusttunnel.go +++ /dev/null @@ -1,1251 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustTunnelService 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 [NewZeroTrustTunnelService] method -// instead. -type ZeroTrustTunnelService struct { - Options []option.RequestOption - Configurations *ZeroTrustTunnelConfigurationService - Connections *ZeroTrustTunnelConnectionService - Token *ZeroTrustTunnelTokenService - Connectors *ZeroTrustTunnelConnectorService - Management *ZeroTrustTunnelManagementService -} - -// NewZeroTrustTunnelService 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 NewZeroTrustTunnelService(opts ...option.RequestOption) (r *ZeroTrustTunnelService) { - r = &ZeroTrustTunnelService{} - r.Options = opts - r.Configurations = NewZeroTrustTunnelConfigurationService(opts...) - r.Connections = NewZeroTrustTunnelConnectionService(opts...) - r.Token = NewZeroTrustTunnelTokenService(opts...) - r.Connectors = NewZeroTrustTunnelConnectorService(opts...) - r.Management = NewZeroTrustTunnelManagementService(opts...) - return -} - -// Creates a new Argo Tunnel in an account. -func (r *ZeroTrustTunnelService) New(ctx context.Context, params ZeroTrustTunnelNewParams, opts ...option.RequestOption) (res *ZeroTrustTunnelNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustTunnelNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/tunnels", params.AccountID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists and filters all types of Tunnels in an account. -func (r *ZeroTrustTunnelService) List(ctx context.Context, params ZeroTrustTunnelListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[ZeroTrustTunnelListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := fmt.Sprintf("accounts/%s/tunnels", params.AccountID) - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, params, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Lists and filters all types of Tunnels in an account. -func (r *ZeroTrustTunnelService) ListAutoPaging(ctx context.Context, params ZeroTrustTunnelListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[ZeroTrustTunnelListResponse] { - return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) -} - -// Deletes an Argo Tunnel from an account. -func (r *ZeroTrustTunnelService) Delete(ctx context.Context, tunnelID string, params ZeroTrustTunnelDeleteParams, opts ...option.RequestOption) (res *ZeroTrustTunnelDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustTunnelDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/tunnels/%s", params.AccountID, tunnelID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates an existing Cloudflare Tunnel. -func (r *ZeroTrustTunnelService) Edit(ctx context.Context, tunnelID string, params ZeroTrustTunnelEditParams, opts ...option.RequestOption) (res *ZeroTrustTunnelEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustTunnelEditResponseEnvelope - path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s", params.AccountID, tunnelID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches a single Argo Tunnel. -func (r *ZeroTrustTunnelService) Get(ctx context.Context, tunnelID string, query ZeroTrustTunnelGetParams, opts ...option.RequestOption) (res *ZeroTrustTunnelGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustTunnelGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/tunnels/%s", query.AccountID, tunnelID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZeroTrustTunnelNewResponse struct { - // UUID of the tunnel. - ID string `json:"id,required"` - // The tunnel connections between your origin and Cloudflare's edge. - Connections []ZeroTrustTunnelNewResponseConnection `json:"connections,required"` - // Timestamp of when the tunnel was created. - CreatedAt time.Time `json:"created_at,required" format:"date-time"` - // A user-friendly name for the tunnel. - Name string `json:"name,required"` - // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been - // deleted. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - JSON zeroTrustTunnelNewResponseJSON `json:"-"` -} - -// zeroTrustTunnelNewResponseJSON contains the JSON metadata for the struct -// [ZeroTrustTunnelNewResponse] -type zeroTrustTunnelNewResponseJSON struct { - ID apijson.Field - Connections apijson.Field - CreatedAt apijson.Field - Name apijson.Field - DeletedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelNewResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelNewResponseConnection struct { - // The Cloudflare data center used for this connection. - ColoName string `json:"colo_name"` - // Cloudflare continues to track connections for several minutes after they - // disconnect. This is an optimization to improve latency and reliability of - // reconnecting. If `true`, the connection has disconnected but is still being - // tracked. If `false`, the connection is actively serving traffic. - IsPendingReconnect bool `json:"is_pending_reconnect"` - // UUID of the Cloudflare Tunnel connection. - UUID string `json:"uuid"` - JSON zeroTrustTunnelNewResponseConnectionJSON `json:"-"` -} - -// zeroTrustTunnelNewResponseConnectionJSON contains the JSON metadata for the -// struct [ZeroTrustTunnelNewResponseConnection] -type zeroTrustTunnelNewResponseConnectionJSON struct { - ColoName apijson.Field - IsPendingReconnect apijson.Field - UUID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelNewResponseConnection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelNewResponseConnectionJSON) RawJSON() string { - return r.raw -} - -// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. -// -// Union satisfied by [ZeroTrustTunnelListResponseTunnelCfdTunnel] or -// [ZeroTrustTunnelListResponseTunnelWARPConnectorTunnel]. -type ZeroTrustTunnelListResponse interface { - implementsZeroTrustTunnelListResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustTunnelListResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustTunnelListResponseTunnelCfdTunnel{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustTunnelListResponseTunnelWARPConnectorTunnel{}), - }, - ) -} - -// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. -type ZeroTrustTunnelListResponseTunnelCfdTunnel struct { - // UUID of the tunnel. - ID string `json:"id"` - // Cloudflare account ID - AccountTag string `json:"account_tag"` - // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - Connections []ZeroTrustTunnelListResponseTunnelCfdTunnelConnection `json:"connections"` - // Timestamp of when the tunnel established at least one connection to Cloudflare's - // edge. If `null`, the tunnel is inactive. - ConnsActiveAt time.Time `json:"conns_active_at,nullable" format:"date-time"` - // Timestamp of when the tunnel became inactive (no connections to Cloudflare's - // edge). If `null`, the tunnel is active. - ConnsInactiveAt time.Time `json:"conns_inactive_at,nullable" format:"date-time"` - // Timestamp of when the tunnel was created. - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been - // deleted. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // Metadata associated with the tunnel. - Metadata interface{} `json:"metadata"` - // A user-friendly name for the tunnel. - Name string `json:"name"` - // If `true`, the tunnel can be configured remotely from the Zero Trust dashboard. - // If `false`, the tunnel must be configured locally on the origin machine. - RemoteConfig bool `json:"remote_config"` - // The status of the tunnel. Valid values are `inactive` (tunnel has never been - // run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy - // state), `healthy` (tunnel is active and able to serve traffic), or `down` - // (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - Status string `json:"status"` - // The type of tunnel. - TunType ZeroTrustTunnelListResponseTunnelCfdTunnelTunType `json:"tun_type"` - JSON zeroTrustTunnelListResponseTunnelCfdTunnelJSON `json:"-"` -} - -// zeroTrustTunnelListResponseTunnelCfdTunnelJSON contains the JSON metadata for -// the struct [ZeroTrustTunnelListResponseTunnelCfdTunnel] -type zeroTrustTunnelListResponseTunnelCfdTunnelJSON struct { - ID apijson.Field - AccountTag apijson.Field - Connections apijson.Field - ConnsActiveAt apijson.Field - ConnsInactiveAt apijson.Field - CreatedAt apijson.Field - DeletedAt apijson.Field - Metadata apijson.Field - Name apijson.Field - RemoteConfig apijson.Field - Status apijson.Field - TunType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelListResponseTunnelCfdTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelListResponseTunnelCfdTunnelJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustTunnelListResponseTunnelCfdTunnel) implementsZeroTrustTunnelListResponse() {} - -type ZeroTrustTunnelListResponseTunnelCfdTunnelConnection struct { - // UUID of the Cloudflare Tunnel connection. - ID string `json:"id"` - // UUID of the cloudflared instance. - ClientID interface{} `json:"client_id"` - // The cloudflared version used to establish this connection. - ClientVersion string `json:"client_version"` - // The Cloudflare data center used for this connection. - ColoName string `json:"colo_name"` - // Cloudflare continues to track connections for several minutes after they - // disconnect. This is an optimization to improve latency and reliability of - // reconnecting. If `true`, the connection has disconnected but is still being - // tracked. If `false`, the connection is actively serving traffic. - IsPendingReconnect bool `json:"is_pending_reconnect"` - // Timestamp of when the connection was established. - OpenedAt time.Time `json:"opened_at" format:"date-time"` - // The public IP address of the host running cloudflared. - OriginIP string `json:"origin_ip"` - // UUID of the Cloudflare Tunnel connection. - UUID string `json:"uuid"` - JSON zeroTrustTunnelListResponseTunnelCfdTunnelConnectionJSON `json:"-"` -} - -// zeroTrustTunnelListResponseTunnelCfdTunnelConnectionJSON contains the JSON -// metadata for the struct [ZeroTrustTunnelListResponseTunnelCfdTunnelConnection] -type zeroTrustTunnelListResponseTunnelCfdTunnelConnectionJSON struct { - ID apijson.Field - ClientID apijson.Field - ClientVersion apijson.Field - ColoName apijson.Field - IsPendingReconnect apijson.Field - OpenedAt apijson.Field - OriginIP apijson.Field - UUID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelListResponseTunnelCfdTunnelConnection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelListResponseTunnelCfdTunnelConnectionJSON) RawJSON() string { - return r.raw -} - -// The type of tunnel. -type ZeroTrustTunnelListResponseTunnelCfdTunnelTunType string - -const ( - ZeroTrustTunnelListResponseTunnelCfdTunnelTunTypeCfdTunnel ZeroTrustTunnelListResponseTunnelCfdTunnelTunType = "cfd_tunnel" - ZeroTrustTunnelListResponseTunnelCfdTunnelTunTypeWARPConnector ZeroTrustTunnelListResponseTunnelCfdTunnelTunType = "warp_connector" - ZeroTrustTunnelListResponseTunnelCfdTunnelTunTypeIPSec ZeroTrustTunnelListResponseTunnelCfdTunnelTunType = "ip_sec" - ZeroTrustTunnelListResponseTunnelCfdTunnelTunTypeGRE ZeroTrustTunnelListResponseTunnelCfdTunnelTunType = "gre" - ZeroTrustTunnelListResponseTunnelCfdTunnelTunTypeCni ZeroTrustTunnelListResponseTunnelCfdTunnelTunType = "cni" -) - -// A Warp Connector Tunnel that connects your origin to Cloudflare's edge. -type ZeroTrustTunnelListResponseTunnelWARPConnectorTunnel struct { - // UUID of the tunnel. - ID string `json:"id"` - // Cloudflare account ID - AccountTag string `json:"account_tag"` - // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - Connections []ZeroTrustTunnelListResponseTunnelWARPConnectorTunnelConnection `json:"connections"` - // Timestamp of when the tunnel established at least one connection to Cloudflare's - // edge. If `null`, the tunnel is inactive. - ConnsActiveAt time.Time `json:"conns_active_at,nullable" format:"date-time"` - // Timestamp of when the tunnel became inactive (no connections to Cloudflare's - // edge). If `null`, the tunnel is active. - ConnsInactiveAt time.Time `json:"conns_inactive_at,nullable" format:"date-time"` - // Timestamp of when the tunnel was created. - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been - // deleted. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // Metadata associated with the tunnel. - Metadata interface{} `json:"metadata"` - // A user-friendly name for the tunnel. - Name string `json:"name"` - // The status of the tunnel. Valid values are `inactive` (tunnel has never been - // run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy - // state), `healthy` (tunnel is active and able to serve traffic), or `down` - // (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - Status string `json:"status"` - // The type of tunnel. - TunType ZeroTrustTunnelListResponseTunnelWARPConnectorTunnelTunType `json:"tun_type"` - JSON zeroTrustTunnelListResponseTunnelWARPConnectorTunnelJSON `json:"-"` -} - -// zeroTrustTunnelListResponseTunnelWARPConnectorTunnelJSON contains the JSON -// metadata for the struct [ZeroTrustTunnelListResponseTunnelWARPConnectorTunnel] -type zeroTrustTunnelListResponseTunnelWARPConnectorTunnelJSON struct { - ID apijson.Field - AccountTag apijson.Field - Connections apijson.Field - ConnsActiveAt apijson.Field - ConnsInactiveAt apijson.Field - CreatedAt apijson.Field - DeletedAt apijson.Field - Metadata apijson.Field - Name apijson.Field - Status apijson.Field - TunType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelListResponseTunnelWARPConnectorTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelListResponseTunnelWARPConnectorTunnelJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustTunnelListResponseTunnelWARPConnectorTunnel) implementsZeroTrustTunnelListResponse() { -} - -type ZeroTrustTunnelListResponseTunnelWARPConnectorTunnelConnection struct { - // UUID of the Cloudflare Tunnel connection. - ID string `json:"id"` - // UUID of the cloudflared instance. - ClientID interface{} `json:"client_id"` - // The cloudflared version used to establish this connection. - ClientVersion string `json:"client_version"` - // The Cloudflare data center used for this connection. - ColoName string `json:"colo_name"` - // Cloudflare continues to track connections for several minutes after they - // disconnect. This is an optimization to improve latency and reliability of - // reconnecting. If `true`, the connection has disconnected but is still being - // tracked. If `false`, the connection is actively serving traffic. - IsPendingReconnect bool `json:"is_pending_reconnect"` - // Timestamp of when the connection was established. - OpenedAt time.Time `json:"opened_at" format:"date-time"` - // The public IP address of the host running cloudflared. - OriginIP string `json:"origin_ip"` - // UUID of the Cloudflare Tunnel connection. - UUID string `json:"uuid"` - JSON zeroTrustTunnelListResponseTunnelWARPConnectorTunnelConnectionJSON `json:"-"` -} - -// zeroTrustTunnelListResponseTunnelWARPConnectorTunnelConnectionJSON contains the -// JSON metadata for the struct -// [ZeroTrustTunnelListResponseTunnelWARPConnectorTunnelConnection] -type zeroTrustTunnelListResponseTunnelWARPConnectorTunnelConnectionJSON struct { - ID apijson.Field - ClientID apijson.Field - ClientVersion apijson.Field - ColoName apijson.Field - IsPendingReconnect apijson.Field - OpenedAt apijson.Field - OriginIP apijson.Field - UUID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelListResponseTunnelWARPConnectorTunnelConnection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelListResponseTunnelWARPConnectorTunnelConnectionJSON) RawJSON() string { - return r.raw -} - -// The type of tunnel. -type ZeroTrustTunnelListResponseTunnelWARPConnectorTunnelTunType string - -const ( - ZeroTrustTunnelListResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel ZeroTrustTunnelListResponseTunnelWARPConnectorTunnelTunType = "cfd_tunnel" - ZeroTrustTunnelListResponseTunnelWARPConnectorTunnelTunTypeWARPConnector ZeroTrustTunnelListResponseTunnelWARPConnectorTunnelTunType = "warp_connector" - ZeroTrustTunnelListResponseTunnelWARPConnectorTunnelTunTypeIPSec ZeroTrustTunnelListResponseTunnelWARPConnectorTunnelTunType = "ip_sec" - ZeroTrustTunnelListResponseTunnelWARPConnectorTunnelTunTypeGRE ZeroTrustTunnelListResponseTunnelWARPConnectorTunnelTunType = "gre" - ZeroTrustTunnelListResponseTunnelWARPConnectorTunnelTunTypeCni ZeroTrustTunnelListResponseTunnelWARPConnectorTunnelTunType = "cni" -) - -type ZeroTrustTunnelDeleteResponse struct { - // UUID of the tunnel. - ID string `json:"id,required"` - // The tunnel connections between your origin and Cloudflare's edge. - Connections []ZeroTrustTunnelDeleteResponseConnection `json:"connections,required"` - // Timestamp of when the tunnel was created. - CreatedAt time.Time `json:"created_at,required" format:"date-time"` - // A user-friendly name for the tunnel. - Name string `json:"name,required"` - // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been - // deleted. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - JSON zeroTrustTunnelDeleteResponseJSON `json:"-"` -} - -// zeroTrustTunnelDeleteResponseJSON contains the JSON metadata for the struct -// [ZeroTrustTunnelDeleteResponse] -type zeroTrustTunnelDeleteResponseJSON struct { - ID apijson.Field - Connections apijson.Field - CreatedAt apijson.Field - Name apijson.Field - DeletedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelDeleteResponseConnection struct { - // The Cloudflare data center used for this connection. - ColoName string `json:"colo_name"` - // Cloudflare continues to track connections for several minutes after they - // disconnect. This is an optimization to improve latency and reliability of - // reconnecting. If `true`, the connection has disconnected but is still being - // tracked. If `false`, the connection is actively serving traffic. - IsPendingReconnect bool `json:"is_pending_reconnect"` - // UUID of the Cloudflare Tunnel connection. - UUID string `json:"uuid"` - JSON zeroTrustTunnelDeleteResponseConnectionJSON `json:"-"` -} - -// zeroTrustTunnelDeleteResponseConnectionJSON contains the JSON metadata for the -// struct [ZeroTrustTunnelDeleteResponseConnection] -type zeroTrustTunnelDeleteResponseConnectionJSON struct { - ColoName apijson.Field - IsPendingReconnect apijson.Field - UUID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelDeleteResponseConnection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelDeleteResponseConnectionJSON) RawJSON() string { - return r.raw -} - -// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. -// -// Union satisfied by [ZeroTrustTunnelEditResponseTunnelCfdTunnel] or -// [ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnel]. -type ZeroTrustTunnelEditResponse interface { - implementsZeroTrustTunnelEditResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustTunnelEditResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustTunnelEditResponseTunnelCfdTunnel{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnel{}), - }, - ) -} - -// A Cloudflare Tunnel that connects your origin to Cloudflare's edge. -type ZeroTrustTunnelEditResponseTunnelCfdTunnel struct { - // UUID of the tunnel. - ID string `json:"id"` - // Cloudflare account ID - AccountTag string `json:"account_tag"` - // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - Connections []ZeroTrustTunnelEditResponseTunnelCfdTunnelConnection `json:"connections"` - // Timestamp of when the tunnel established at least one connection to Cloudflare's - // edge. If `null`, the tunnel is inactive. - ConnsActiveAt time.Time `json:"conns_active_at,nullable" format:"date-time"` - // Timestamp of when the tunnel became inactive (no connections to Cloudflare's - // edge). If `null`, the tunnel is active. - ConnsInactiveAt time.Time `json:"conns_inactive_at,nullable" format:"date-time"` - // Timestamp of when the tunnel was created. - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been - // deleted. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // Metadata associated with the tunnel. - Metadata interface{} `json:"metadata"` - // A user-friendly name for the tunnel. - Name string `json:"name"` - // If `true`, the tunnel can be configured remotely from the Zero Trust dashboard. - // If `false`, the tunnel must be configured locally on the origin machine. - RemoteConfig bool `json:"remote_config"` - // The status of the tunnel. Valid values are `inactive` (tunnel has never been - // run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy - // state), `healthy` (tunnel is active and able to serve traffic), or `down` - // (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - Status string `json:"status"` - // The type of tunnel. - TunType ZeroTrustTunnelEditResponseTunnelCfdTunnelTunType `json:"tun_type"` - JSON zeroTrustTunnelEditResponseTunnelCfdTunnelJSON `json:"-"` -} - -// zeroTrustTunnelEditResponseTunnelCfdTunnelJSON contains the JSON metadata for -// the struct [ZeroTrustTunnelEditResponseTunnelCfdTunnel] -type zeroTrustTunnelEditResponseTunnelCfdTunnelJSON struct { - ID apijson.Field - AccountTag apijson.Field - Connections apijson.Field - ConnsActiveAt apijson.Field - ConnsInactiveAt apijson.Field - CreatedAt apijson.Field - DeletedAt apijson.Field - Metadata apijson.Field - Name apijson.Field - RemoteConfig apijson.Field - Status apijson.Field - TunType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelEditResponseTunnelCfdTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelEditResponseTunnelCfdTunnelJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustTunnelEditResponseTunnelCfdTunnel) implementsZeroTrustTunnelEditResponse() {} - -type ZeroTrustTunnelEditResponseTunnelCfdTunnelConnection struct { - // UUID of the Cloudflare Tunnel connection. - ID string `json:"id"` - // UUID of the cloudflared instance. - ClientID interface{} `json:"client_id"` - // The cloudflared version used to establish this connection. - ClientVersion string `json:"client_version"` - // The Cloudflare data center used for this connection. - ColoName string `json:"colo_name"` - // Cloudflare continues to track connections for several minutes after they - // disconnect. This is an optimization to improve latency and reliability of - // reconnecting. If `true`, the connection has disconnected but is still being - // tracked. If `false`, the connection is actively serving traffic. - IsPendingReconnect bool `json:"is_pending_reconnect"` - // Timestamp of when the connection was established. - OpenedAt time.Time `json:"opened_at" format:"date-time"` - // The public IP address of the host running cloudflared. - OriginIP string `json:"origin_ip"` - // UUID of the Cloudflare Tunnel connection. - UUID string `json:"uuid"` - JSON zeroTrustTunnelEditResponseTunnelCfdTunnelConnectionJSON `json:"-"` -} - -// zeroTrustTunnelEditResponseTunnelCfdTunnelConnectionJSON contains the JSON -// metadata for the struct [ZeroTrustTunnelEditResponseTunnelCfdTunnelConnection] -type zeroTrustTunnelEditResponseTunnelCfdTunnelConnectionJSON struct { - ID apijson.Field - ClientID apijson.Field - ClientVersion apijson.Field - ColoName apijson.Field - IsPendingReconnect apijson.Field - OpenedAt apijson.Field - OriginIP apijson.Field - UUID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelEditResponseTunnelCfdTunnelConnection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelEditResponseTunnelCfdTunnelConnectionJSON) RawJSON() string { - return r.raw -} - -// The type of tunnel. -type ZeroTrustTunnelEditResponseTunnelCfdTunnelTunType string - -const ( - ZeroTrustTunnelEditResponseTunnelCfdTunnelTunTypeCfdTunnel ZeroTrustTunnelEditResponseTunnelCfdTunnelTunType = "cfd_tunnel" - ZeroTrustTunnelEditResponseTunnelCfdTunnelTunTypeWARPConnector ZeroTrustTunnelEditResponseTunnelCfdTunnelTunType = "warp_connector" - ZeroTrustTunnelEditResponseTunnelCfdTunnelTunTypeIPSec ZeroTrustTunnelEditResponseTunnelCfdTunnelTunType = "ip_sec" - ZeroTrustTunnelEditResponseTunnelCfdTunnelTunTypeGRE ZeroTrustTunnelEditResponseTunnelCfdTunnelTunType = "gre" - ZeroTrustTunnelEditResponseTunnelCfdTunnelTunTypeCni ZeroTrustTunnelEditResponseTunnelCfdTunnelTunType = "cni" -) - -// A Warp Connector Tunnel that connects your origin to Cloudflare's edge. -type ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnel struct { - // UUID of the tunnel. - ID string `json:"id"` - // Cloudflare account ID - AccountTag string `json:"account_tag"` - // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - Connections []ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnelConnection `json:"connections"` - // Timestamp of when the tunnel established at least one connection to Cloudflare's - // edge. If `null`, the tunnel is inactive. - ConnsActiveAt time.Time `json:"conns_active_at,nullable" format:"date-time"` - // Timestamp of when the tunnel became inactive (no connections to Cloudflare's - // edge). If `null`, the tunnel is active. - ConnsInactiveAt time.Time `json:"conns_inactive_at,nullable" format:"date-time"` - // Timestamp of when the tunnel was created. - CreatedAt time.Time `json:"created_at" format:"date-time"` - // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been - // deleted. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - // Metadata associated with the tunnel. - Metadata interface{} `json:"metadata"` - // A user-friendly name for the tunnel. - Name string `json:"name"` - // The status of the tunnel. Valid values are `inactive` (tunnel has never been - // run), `degraded` (tunnel is active and able to serve traffic but in an unhealthy - // state), `healthy` (tunnel is active and able to serve traffic), or `down` - // (tunnel can not serve traffic as it has no connections to the Cloudflare Edge). - Status string `json:"status"` - // The type of tunnel. - TunType ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnelTunType `json:"tun_type"` - JSON zeroTrustTunnelEditResponseTunnelWARPConnectorTunnelJSON `json:"-"` -} - -// zeroTrustTunnelEditResponseTunnelWARPConnectorTunnelJSON contains the JSON -// metadata for the struct [ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnel] -type zeroTrustTunnelEditResponseTunnelWARPConnectorTunnelJSON struct { - ID apijson.Field - AccountTag apijson.Field - Connections apijson.Field - ConnsActiveAt apijson.Field - ConnsInactiveAt apijson.Field - CreatedAt apijson.Field - DeletedAt apijson.Field - Metadata apijson.Field - Name apijson.Field - Status apijson.Field - TunType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelEditResponseTunnelWARPConnectorTunnelJSON) RawJSON() string { - return r.raw -} - -func (r ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnel) implementsZeroTrustTunnelEditResponse() { -} - -type ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnelConnection struct { - // UUID of the Cloudflare Tunnel connection. - ID string `json:"id"` - // UUID of the cloudflared instance. - ClientID interface{} `json:"client_id"` - // The cloudflared version used to establish this connection. - ClientVersion string `json:"client_version"` - // The Cloudflare data center used for this connection. - ColoName string `json:"colo_name"` - // Cloudflare continues to track connections for several minutes after they - // disconnect. This is an optimization to improve latency and reliability of - // reconnecting. If `true`, the connection has disconnected but is still being - // tracked. If `false`, the connection is actively serving traffic. - IsPendingReconnect bool `json:"is_pending_reconnect"` - // Timestamp of when the connection was established. - OpenedAt time.Time `json:"opened_at" format:"date-time"` - // The public IP address of the host running cloudflared. - OriginIP string `json:"origin_ip"` - // UUID of the Cloudflare Tunnel connection. - UUID string `json:"uuid"` - JSON zeroTrustTunnelEditResponseTunnelWARPConnectorTunnelConnectionJSON `json:"-"` -} - -// zeroTrustTunnelEditResponseTunnelWARPConnectorTunnelConnectionJSON contains the -// JSON metadata for the struct -// [ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnelConnection] -type zeroTrustTunnelEditResponseTunnelWARPConnectorTunnelConnectionJSON struct { - ID apijson.Field - ClientID apijson.Field - ClientVersion apijson.Field - ColoName apijson.Field - IsPendingReconnect apijson.Field - OpenedAt apijson.Field - OriginIP apijson.Field - UUID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnelConnection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelEditResponseTunnelWARPConnectorTunnelConnectionJSON) RawJSON() string { - return r.raw -} - -// The type of tunnel. -type ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnelTunType string - -const ( - ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnelTunTypeCfdTunnel ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnelTunType = "cfd_tunnel" - ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnelTunTypeWARPConnector ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnelTunType = "warp_connector" - ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnelTunTypeIPSec ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnelTunType = "ip_sec" - ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnelTunTypeGRE ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnelTunType = "gre" - ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnelTunTypeCni ZeroTrustTunnelEditResponseTunnelWARPConnectorTunnelTunType = "cni" -) - -type ZeroTrustTunnelGetResponse struct { - // UUID of the tunnel. - ID string `json:"id,required"` - // The tunnel connections between your origin and Cloudflare's edge. - Connections []ZeroTrustTunnelGetResponseConnection `json:"connections,required"` - // Timestamp of when the tunnel was created. - CreatedAt time.Time `json:"created_at,required" format:"date-time"` - // A user-friendly name for the tunnel. - Name string `json:"name,required"` - // Timestamp of when the tunnel was deleted. If `null`, the tunnel has not been - // deleted. - DeletedAt time.Time `json:"deleted_at,nullable" format:"date-time"` - JSON zeroTrustTunnelGetResponseJSON `json:"-"` -} - -// zeroTrustTunnelGetResponseJSON contains the JSON metadata for the struct -// [ZeroTrustTunnelGetResponse] -type zeroTrustTunnelGetResponseJSON struct { - ID apijson.Field - Connections apijson.Field - CreatedAt apijson.Field - Name apijson.Field - DeletedAt apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelGetResponseConnection struct { - // The Cloudflare data center used for this connection. - ColoName string `json:"colo_name"` - // Cloudflare continues to track connections for several minutes after they - // disconnect. This is an optimization to improve latency and reliability of - // reconnecting. If `true`, the connection has disconnected but is still being - // tracked. If `false`, the connection is actively serving traffic. - IsPendingReconnect bool `json:"is_pending_reconnect"` - // UUID of the Cloudflare Tunnel connection. - UUID string `json:"uuid"` - JSON zeroTrustTunnelGetResponseConnectionJSON `json:"-"` -} - -// zeroTrustTunnelGetResponseConnectionJSON contains the JSON metadata for the -// struct [ZeroTrustTunnelGetResponseConnection] -type zeroTrustTunnelGetResponseConnectionJSON struct { - ColoName apijson.Field - IsPendingReconnect apijson.Field - UUID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelGetResponseConnection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelGetResponseConnectionJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelNewParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - // A user-friendly name for the tunnel. - Name param.Field[string] `json:"name,required"` - // Sets the password required to run the tunnel. Must be at least 32 bytes and - // encoded as a base64 string. - TunnelSecret param.Field[interface{}] `json:"tunnel_secret,required"` -} - -func (r ZeroTrustTunnelNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustTunnelNewResponseEnvelope struct { - Errors []ZeroTrustTunnelNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustTunnelNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustTunnelNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustTunnelNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustTunnelNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustTunnelNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [ZeroTrustTunnelNewResponseEnvelope] -type zeroTrustTunnelNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustTunnelNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZeroTrustTunnelNewResponseEnvelopeErrors] -type zeroTrustTunnelNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustTunnelNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZeroTrustTunnelNewResponseEnvelopeMessages] -type zeroTrustTunnelNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustTunnelNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustTunnelNewResponseEnvelopeSuccessTrue ZeroTrustTunnelNewResponseEnvelopeSuccess = true -) - -type ZeroTrustTunnelListParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - ExcludePrefix param.Field[string] `query:"exclude_prefix"` - // If provided, include only tunnels that were created (and not deleted) before - // this time. - ExistedAt param.Field[time.Time] `query:"existed_at" format:"date-time"` - IncludePrefix param.Field[string] `query:"include_prefix"` - // If `true`, only include deleted tunnels. If `false`, exclude deleted tunnels. If - // empty, all tunnels will be included. - IsDeleted param.Field[bool] `query:"is_deleted"` - // A user-friendly name for the tunnel. - Name param.Field[string] `query:"name"` - // Page number of paginated results. - Page param.Field[float64] `query:"page"` - // Number of results to display. - PerPage param.Field[float64] `query:"per_page"` - // The types of tunnels to filter separated by a comma. - TunTypes param.Field[string] `query:"tun_types"` - WasActiveAt param.Field[time.Time] `query:"was_active_at" format:"date-time"` - WasInactiveAt param.Field[time.Time] `query:"was_inactive_at" format:"date-time"` -} - -// URLQuery serializes [ZeroTrustTunnelListParams]'s query parameters as -// `url.Values`. -func (r ZeroTrustTunnelListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type ZeroTrustTunnelDeleteParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` -} - -func (r ZeroTrustTunnelDeleteParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type ZeroTrustTunnelDeleteResponseEnvelope struct { - Errors []ZeroTrustTunnelDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustTunnelDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustTunnelDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustTunnelDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustTunnelDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustTunnelDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustTunnelDeleteResponseEnvelope] -type zeroTrustTunnelDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustTunnelDeleteResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustTunnelDeleteResponseEnvelopeErrors] -type zeroTrustTunnelDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustTunnelDeleteResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZeroTrustTunnelDeleteResponseEnvelopeMessages] -type zeroTrustTunnelDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustTunnelDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustTunnelDeleteResponseEnvelopeSuccessTrue ZeroTrustTunnelDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustTunnelEditParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - // A user-friendly name for the tunnel. - Name param.Field[string] `json:"name"` - // Sets the password required to run a locally-managed tunnel. Must be at least 32 - // bytes and encoded as a base64 string. - TunnelSecret param.Field[string] `json:"tunnel_secret"` -} - -func (r ZeroTrustTunnelEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustTunnelEditResponseEnvelope struct { - Errors []ZeroTrustTunnelEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustTunnelEditResponseEnvelopeMessages `json:"messages,required"` - // A Cloudflare Tunnel that connects your origin to Cloudflare's edge. - Result ZeroTrustTunnelEditResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustTunnelEditResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustTunnelEditResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustTunnelEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustTunnelEditResponseEnvelope] -type zeroTrustTunnelEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustTunnelEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZeroTrustTunnelEditResponseEnvelopeErrors] -type zeroTrustTunnelEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustTunnelEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZeroTrustTunnelEditResponseEnvelopeMessages] -type zeroTrustTunnelEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustTunnelEditResponseEnvelopeSuccess bool - -const ( - ZeroTrustTunnelEditResponseEnvelopeSuccessTrue ZeroTrustTunnelEditResponseEnvelopeSuccess = true -) - -type ZeroTrustTunnelGetParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustTunnelGetResponseEnvelope struct { - Errors []ZeroTrustTunnelGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustTunnelGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustTunnelGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustTunnelGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustTunnelGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustTunnelGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [ZeroTrustTunnelGetResponseEnvelope] -type zeroTrustTunnelGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustTunnelGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZeroTrustTunnelGetResponseEnvelopeErrors] -type zeroTrustTunnelGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustTunnelGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZeroTrustTunnelGetResponseEnvelopeMessages] -type zeroTrustTunnelGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustTunnelGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustTunnelGetResponseEnvelopeSuccessTrue ZeroTrustTunnelGetResponseEnvelopeSuccess = true -) diff --git a/zerotrusttunnel_test.go b/zerotrusttunnel_test.go deleted file mode 100644 index 6130959a6e9..00000000000 --- a/zerotrusttunnel_test.go +++ /dev/null @@ -1,172 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustTunnelNew(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("user@example.com"), - ) - _, err := client.ZeroTrust.Tunnels.New(context.TODO(), cloudflare.ZeroTrustTunnelNewParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Name: cloudflare.F("blog"), - TunnelSecret: cloudflare.F[any](map[string]interface{}{}), - }) - 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 TestZeroTrustTunnelListWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Tunnels.List(context.TODO(), cloudflare.ZeroTrustTunnelListParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - ExcludePrefix: cloudflare.F("vpc1-"), - ExistedAt: cloudflare.F(time.Now()), - IncludePrefix: cloudflare.F("vpc1-"), - IsDeleted: cloudflare.F(true), - Name: cloudflare.F("blog"), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(1.000000), - TunTypes: cloudflare.F("cfd_tunnel,warp_connector"), - WasActiveAt: cloudflare.F(time.Now()), - WasInactiveAt: cloudflare.F(time.Now()), - }) - 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 TestZeroTrustTunnelDelete(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("user@example.com"), - ) - _, err := client.ZeroTrust.Tunnels.Delete( - context.TODO(), - "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustTunnelDeleteParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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 TestZeroTrustTunnelEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Tunnels.Edit( - context.TODO(), - "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustTunnelEditParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Name: cloudflare.F("blog"), - TunnelSecret: cloudflare.F("AQIDBAUGBwgBAgMEBQYHCAECAwQFBgcIAQIDBAUGBwg="), - }, - ) - 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 TestZeroTrustTunnelGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Tunnels.Get( - context.TODO(), - "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustTunnelGetParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrusttunnelconfiguration.go b/zerotrusttunnelconfiguration.go deleted file mode 100644 index 1f999dfac47..00000000000 --- a/zerotrusttunnelconfiguration.go +++ /dev/null @@ -1,461 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustTunnelConfigurationService 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 -// [NewZeroTrustTunnelConfigurationService] method instead. -type ZeroTrustTunnelConfigurationService struct { - Options []option.RequestOption -} - -// NewZeroTrustTunnelConfigurationService 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 NewZeroTrustTunnelConfigurationService(opts ...option.RequestOption) (r *ZeroTrustTunnelConfigurationService) { - r = &ZeroTrustTunnelConfigurationService{} - r.Options = opts - return -} - -// Adds or updates the configuration for a remotely-managed tunnel. -func (r *ZeroTrustTunnelConfigurationService) Update(ctx context.Context, tunnelID string, params ZeroTrustTunnelConfigurationUpdateParams, opts ...option.RequestOption) (res *ZeroTrustTunnelConfigurationUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustTunnelConfigurationUpdateResponseEnvelope - path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s/configurations", params.AccountID, tunnelID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets the configuration for a remotely-managed tunnel -func (r *ZeroTrustTunnelConfigurationService) Get(ctx context.Context, tunnelID string, query ZeroTrustTunnelConfigurationGetParams, opts ...option.RequestOption) (res *ZeroTrustTunnelConfigurationGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustTunnelConfigurationGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s/configurations", query.AccountID, tunnelID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [ZeroTrustTunnelConfigurationUpdateResponseUnknown], -// [ZeroTrustTunnelConfigurationUpdateResponseArray] or [shared.UnionString]. -type ZeroTrustTunnelConfigurationUpdateResponse interface { - ImplementsZeroTrustTunnelConfigurationUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustTunnelConfigurationUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustTunnelConfigurationUpdateResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustTunnelConfigurationUpdateResponseArray []interface{} - -func (r ZeroTrustTunnelConfigurationUpdateResponseArray) ImplementsZeroTrustTunnelConfigurationUpdateResponse() { -} - -// Union satisfied by [ZeroTrustTunnelConfigurationGetResponseUnknown], -// [ZeroTrustTunnelConfigurationGetResponseArray] or [shared.UnionString]. -type ZeroTrustTunnelConfigurationGetResponse interface { - ImplementsZeroTrustTunnelConfigurationGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustTunnelConfigurationGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustTunnelConfigurationGetResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustTunnelConfigurationGetResponseArray []interface{} - -func (r ZeroTrustTunnelConfigurationGetResponseArray) ImplementsZeroTrustTunnelConfigurationGetResponse() { -} - -type ZeroTrustTunnelConfigurationUpdateParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` - // The tunnel configuration and ingress rules. - Config param.Field[ZeroTrustTunnelConfigurationUpdateParamsConfig] `json:"config"` -} - -func (r ZeroTrustTunnelConfigurationUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The tunnel configuration and ingress rules. -type ZeroTrustTunnelConfigurationUpdateParamsConfig struct { - // List of public hostname definitions - Ingress param.Field[[]ZeroTrustTunnelConfigurationUpdateParamsConfigIngress] `json:"ingress"` - // Configuration parameters of connection between cloudflared and origin server. - OriginRequest param.Field[ZeroTrustTunnelConfigurationUpdateParamsConfigOriginRequest] `json:"originRequest"` - // Enable private network access from WARP users to private network routes - WARPRouting param.Field[ZeroTrustTunnelConfigurationUpdateParamsConfigWARPRouting] `json:"warp-routing"` -} - -func (r ZeroTrustTunnelConfigurationUpdateParamsConfig) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Public hostname -type ZeroTrustTunnelConfigurationUpdateParamsConfigIngress struct { - // Public hostname for this service. - Hostname param.Field[string] `json:"hostname,required"` - // Protocol and address of destination server. Supported protocols: http://, - // https://, unix://, tcp://, ssh://, rdp://, unix+tls://, smb://. Alternatively - // can return a HTTP status code http_status:[code] e.g. 'http_status:404'. - Service param.Field[string] `json:"service,required"` - // Configuration parameters of connection between cloudflared and origin server. - OriginRequest param.Field[ZeroTrustTunnelConfigurationUpdateParamsConfigIngressOriginRequest] `json:"originRequest"` - // Requests with this path route to this public hostname. - Path param.Field[string] `json:"path"` -} - -func (r ZeroTrustTunnelConfigurationUpdateParamsConfigIngress) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configuration parameters of connection between cloudflared and origin server. -type ZeroTrustTunnelConfigurationUpdateParamsConfigIngressOriginRequest struct { - // For all L7 requests to this hostname, cloudflared will validate each request's - // Cf-Access-Jwt-Assertion request header. - Access param.Field[ZeroTrustTunnelConfigurationUpdateParamsConfigIngressOriginRequestAccess] `json:"access"` - // Path to the certificate authority (CA) for the certificate of your origin. This - // option should be used only if your certificate is not signed by Cloudflare. - CAPool param.Field[string] `json:"caPool"` - // Timeout for establishing a new TCP connection to your origin server. This - // excludes the time taken to establish TLS, which is controlled by tlsTimeout. - ConnectTimeout param.Field[int64] `json:"connectTimeout"` - // Disables chunked transfer encoding. Useful if you are running a WSGI server. - DisableChunkedEncoding param.Field[bool] `json:"disableChunkedEncoding"` - // Attempt to connect to origin using HTTP2. Origin must be configured as https. - HTTP2Origin param.Field[bool] `json:"http2Origin"` - // Sets the HTTP Host header on requests sent to the local service. - HTTPHostHeader param.Field[string] `json:"httpHostHeader"` - // Maximum number of idle keepalive connections between Tunnel and your origin. - // This does not restrict the total number of concurrent connections. - KeepAliveConnections param.Field[int64] `json:"keepAliveConnections"` - // Timeout after which an idle keepalive connection can be discarded. - KeepAliveTimeout param.Field[int64] `json:"keepAliveTimeout"` - // Disable the “happy eyeballs” algorithm for IPv4/IPv6 fallback if your local - // network has misconfigured one of the protocols. - NoHappyEyeballs param.Field[bool] `json:"noHappyEyeballs"` - // Disables TLS verification of the certificate presented by your origin. Will - // allow any certificate from the origin to be accepted. - NoTLSVerify param.Field[bool] `json:"noTLSVerify"` - // Hostname that cloudflared should expect from your origin server certificate. - OriginServerName param.Field[string] `json:"originServerName"` - // cloudflared starts a proxy server to translate HTTP traffic into TCP when - // proxying, for example, SSH or RDP. This configures what type of proxy will be - // started. Valid options are: "" for the regular proxy and "socks" for a SOCKS5 - // proxy. - ProxyType param.Field[string] `json:"proxyType"` - // The timeout after which a TCP keepalive packet is sent on a connection between - // Tunnel and the origin server. - TcpKeepAlive param.Field[int64] `json:"tcpKeepAlive"` - // Timeout for completing a TLS handshake to your origin server, if you have chosen - // to connect Tunnel to an HTTPS server. - TLSTimeout param.Field[int64] `json:"tlsTimeout"` -} - -func (r ZeroTrustTunnelConfigurationUpdateParamsConfigIngressOriginRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// For all L7 requests to this hostname, cloudflared will validate each request's -// Cf-Access-Jwt-Assertion request header. -type ZeroTrustTunnelConfigurationUpdateParamsConfigIngressOriginRequestAccess struct { - // Access applications that are allowed to reach this hostname for this Tunnel. - // Audience tags can be identified in the dashboard or via the List Access policies - // API. - AudTag param.Field[[]string] `json:"audTag,required"` - TeamName param.Field[string] `json:"teamName,required"` - // Deny traffic that has not fulfilled Access authorization. - Required param.Field[bool] `json:"required"` -} - -func (r ZeroTrustTunnelConfigurationUpdateParamsConfigIngressOriginRequestAccess) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configuration parameters of connection between cloudflared and origin server. -type ZeroTrustTunnelConfigurationUpdateParamsConfigOriginRequest struct { - // For all L7 requests to this hostname, cloudflared will validate each request's - // Cf-Access-Jwt-Assertion request header. - Access param.Field[ZeroTrustTunnelConfigurationUpdateParamsConfigOriginRequestAccess] `json:"access"` - // Path to the certificate authority (CA) for the certificate of your origin. This - // option should be used only if your certificate is not signed by Cloudflare. - CAPool param.Field[string] `json:"caPool"` - // Timeout for establishing a new TCP connection to your origin server. This - // excludes the time taken to establish TLS, which is controlled by tlsTimeout. - ConnectTimeout param.Field[int64] `json:"connectTimeout"` - // Disables chunked transfer encoding. Useful if you are running a WSGI server. - DisableChunkedEncoding param.Field[bool] `json:"disableChunkedEncoding"` - // Attempt to connect to origin using HTTP2. Origin must be configured as https. - HTTP2Origin param.Field[bool] `json:"http2Origin"` - // Sets the HTTP Host header on requests sent to the local service. - HTTPHostHeader param.Field[string] `json:"httpHostHeader"` - // Maximum number of idle keepalive connections between Tunnel and your origin. - // This does not restrict the total number of concurrent connections. - KeepAliveConnections param.Field[int64] `json:"keepAliveConnections"` - // Timeout after which an idle keepalive connection can be discarded. - KeepAliveTimeout param.Field[int64] `json:"keepAliveTimeout"` - // Disable the “happy eyeballs” algorithm for IPv4/IPv6 fallback if your local - // network has misconfigured one of the protocols. - NoHappyEyeballs param.Field[bool] `json:"noHappyEyeballs"` - // Disables TLS verification of the certificate presented by your origin. Will - // allow any certificate from the origin to be accepted. - NoTLSVerify param.Field[bool] `json:"noTLSVerify"` - // Hostname that cloudflared should expect from your origin server certificate. - OriginServerName param.Field[string] `json:"originServerName"` - // cloudflared starts a proxy server to translate HTTP traffic into TCP when - // proxying, for example, SSH or RDP. This configures what type of proxy will be - // started. Valid options are: "" for the regular proxy and "socks" for a SOCKS5 - // proxy. - ProxyType param.Field[string] `json:"proxyType"` - // The timeout after which a TCP keepalive packet is sent on a connection between - // Tunnel and the origin server. - TcpKeepAlive param.Field[int64] `json:"tcpKeepAlive"` - // Timeout for completing a TLS handshake to your origin server, if you have chosen - // to connect Tunnel to an HTTPS server. - TLSTimeout param.Field[int64] `json:"tlsTimeout"` -} - -func (r ZeroTrustTunnelConfigurationUpdateParamsConfigOriginRequest) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// For all L7 requests to this hostname, cloudflared will validate each request's -// Cf-Access-Jwt-Assertion request header. -type ZeroTrustTunnelConfigurationUpdateParamsConfigOriginRequestAccess struct { - // Access applications that are allowed to reach this hostname for this Tunnel. - // Audience tags can be identified in the dashboard or via the List Access policies - // API. - AudTag param.Field[[]string] `json:"audTag,required"` - TeamName param.Field[string] `json:"teamName,required"` - // Deny traffic that has not fulfilled Access authorization. - Required param.Field[bool] `json:"required"` -} - -func (r ZeroTrustTunnelConfigurationUpdateParamsConfigOriginRequestAccess) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enable private network access from WARP users to private network routes -type ZeroTrustTunnelConfigurationUpdateParamsConfigWARPRouting struct { - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ZeroTrustTunnelConfigurationUpdateParamsConfigWARPRouting) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZeroTrustTunnelConfigurationUpdateResponseEnvelope struct { - Errors []ZeroTrustTunnelConfigurationUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustTunnelConfigurationUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustTunnelConfigurationUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustTunnelConfigurationUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustTunnelConfigurationUpdateResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustTunnelConfigurationUpdateResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZeroTrustTunnelConfigurationUpdateResponseEnvelope] -type zeroTrustTunnelConfigurationUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConfigurationUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConfigurationUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelConfigurationUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelConfigurationUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustTunnelConfigurationUpdateResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZeroTrustTunnelConfigurationUpdateResponseEnvelopeErrors] -type zeroTrustTunnelConfigurationUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConfigurationUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConfigurationUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelConfigurationUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelConfigurationUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustTunnelConfigurationUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustTunnelConfigurationUpdateResponseEnvelopeMessages] -type zeroTrustTunnelConfigurationUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConfigurationUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConfigurationUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustTunnelConfigurationUpdateResponseEnvelopeSuccess bool - -const ( - ZeroTrustTunnelConfigurationUpdateResponseEnvelopeSuccessTrue ZeroTrustTunnelConfigurationUpdateResponseEnvelopeSuccess = true -) - -type ZeroTrustTunnelConfigurationGetParams struct { - // Identifier - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustTunnelConfigurationGetResponseEnvelope struct { - Errors []ZeroTrustTunnelConfigurationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustTunnelConfigurationGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustTunnelConfigurationGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustTunnelConfigurationGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustTunnelConfigurationGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustTunnelConfigurationGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustTunnelConfigurationGetResponseEnvelope] -type zeroTrustTunnelConfigurationGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConfigurationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConfigurationGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelConfigurationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelConfigurationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustTunnelConfigurationGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustTunnelConfigurationGetResponseEnvelopeErrors] -type zeroTrustTunnelConfigurationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConfigurationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConfigurationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelConfigurationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelConfigurationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustTunnelConfigurationGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustTunnelConfigurationGetResponseEnvelopeMessages] -type zeroTrustTunnelConfigurationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConfigurationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConfigurationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustTunnelConfigurationGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustTunnelConfigurationGetResponseEnvelopeSuccessTrue ZeroTrustTunnelConfigurationGetResponseEnvelopeSuccess = true -) diff --git a/zerotrusttunnelconfiguration_test.go b/zerotrusttunnelconfiguration_test.go deleted file mode 100644 index 707c5a481a8..00000000000 --- a/zerotrusttunnelconfiguration_test.go +++ /dev/null @@ -1,172 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustTunnelConfigurationUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.ZeroTrust.Tunnels.Configurations.Update( - context.TODO(), - "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustTunnelConfigurationUpdateParams{ - AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Config: cloudflare.F(cloudflare.ZeroTrustTunnelConfigurationUpdateParamsConfig{ - Ingress: cloudflare.F([]cloudflare.ZeroTrustTunnelConfigurationUpdateParamsConfigIngress{{ - Hostname: cloudflare.F("tunnel.example.com"), - OriginRequest: cloudflare.F(cloudflare.ZeroTrustTunnelConfigurationUpdateParamsConfigIngressOriginRequest{ - Access: cloudflare.F(cloudflare.ZeroTrustTunnelConfigurationUpdateParamsConfigIngressOriginRequestAccess{ - AudTag: cloudflare.F([]string{"string", "string", "string"}), - Required: cloudflare.F(true), - TeamName: cloudflare.F("string"), - }), - CAPool: cloudflare.F("string"), - ConnectTimeout: cloudflare.F(int64(0)), - DisableChunkedEncoding: cloudflare.F(true), - HTTP2Origin: cloudflare.F(true), - HTTPHostHeader: cloudflare.F("string"), - KeepAliveConnections: cloudflare.F(int64(0)), - KeepAliveTimeout: cloudflare.F(int64(0)), - NoHappyEyeballs: cloudflare.F(true), - NoTLSVerify: cloudflare.F(true), - OriginServerName: cloudflare.F("string"), - ProxyType: cloudflare.F("string"), - TcpKeepAlive: cloudflare.F(int64(0)), - TLSTimeout: cloudflare.F(int64(0)), - }), - Path: cloudflare.F("subpath"), - Service: cloudflare.F("https://localhost:8001"), - }, { - Hostname: cloudflare.F("tunnel.example.com"), - OriginRequest: cloudflare.F(cloudflare.ZeroTrustTunnelConfigurationUpdateParamsConfigIngressOriginRequest{ - Access: cloudflare.F(cloudflare.ZeroTrustTunnelConfigurationUpdateParamsConfigIngressOriginRequestAccess{ - AudTag: cloudflare.F([]string{"string", "string", "string"}), - Required: cloudflare.F(true), - TeamName: cloudflare.F("string"), - }), - CAPool: cloudflare.F("string"), - ConnectTimeout: cloudflare.F(int64(0)), - DisableChunkedEncoding: cloudflare.F(true), - HTTP2Origin: cloudflare.F(true), - HTTPHostHeader: cloudflare.F("string"), - KeepAliveConnections: cloudflare.F(int64(0)), - KeepAliveTimeout: cloudflare.F(int64(0)), - NoHappyEyeballs: cloudflare.F(true), - NoTLSVerify: cloudflare.F(true), - OriginServerName: cloudflare.F("string"), - ProxyType: cloudflare.F("string"), - TcpKeepAlive: cloudflare.F(int64(0)), - TLSTimeout: cloudflare.F(int64(0)), - }), - Path: cloudflare.F("subpath"), - Service: cloudflare.F("https://localhost:8001"), - }, { - Hostname: cloudflare.F("tunnel.example.com"), - OriginRequest: cloudflare.F(cloudflare.ZeroTrustTunnelConfigurationUpdateParamsConfigIngressOriginRequest{ - Access: cloudflare.F(cloudflare.ZeroTrustTunnelConfigurationUpdateParamsConfigIngressOriginRequestAccess{ - AudTag: cloudflare.F([]string{"string", "string", "string"}), - Required: cloudflare.F(true), - TeamName: cloudflare.F("string"), - }), - CAPool: cloudflare.F("string"), - ConnectTimeout: cloudflare.F(int64(0)), - DisableChunkedEncoding: cloudflare.F(true), - HTTP2Origin: cloudflare.F(true), - HTTPHostHeader: cloudflare.F("string"), - KeepAliveConnections: cloudflare.F(int64(0)), - KeepAliveTimeout: cloudflare.F(int64(0)), - NoHappyEyeballs: cloudflare.F(true), - NoTLSVerify: cloudflare.F(true), - OriginServerName: cloudflare.F("string"), - ProxyType: cloudflare.F("string"), - TcpKeepAlive: cloudflare.F(int64(0)), - TLSTimeout: cloudflare.F(int64(0)), - }), - Path: cloudflare.F("subpath"), - Service: cloudflare.F("https://localhost:8001"), - }}), - OriginRequest: cloudflare.F(cloudflare.ZeroTrustTunnelConfigurationUpdateParamsConfigOriginRequest{ - Access: cloudflare.F(cloudflare.ZeroTrustTunnelConfigurationUpdateParamsConfigOriginRequestAccess{ - AudTag: cloudflare.F([]string{"string", "string", "string"}), - Required: cloudflare.F(true), - TeamName: cloudflare.F("string"), - }), - CAPool: cloudflare.F("string"), - ConnectTimeout: cloudflare.F(int64(0)), - DisableChunkedEncoding: cloudflare.F(true), - HTTP2Origin: cloudflare.F(true), - HTTPHostHeader: cloudflare.F("string"), - KeepAliveConnections: cloudflare.F(int64(0)), - KeepAliveTimeout: cloudflare.F(int64(0)), - NoHappyEyeballs: cloudflare.F(true), - NoTLSVerify: cloudflare.F(true), - OriginServerName: cloudflare.F("string"), - ProxyType: cloudflare.F("string"), - TcpKeepAlive: cloudflare.F(int64(0)), - TLSTimeout: cloudflare.F(int64(0)), - }), - WARPRouting: cloudflare.F(cloudflare.ZeroTrustTunnelConfigurationUpdateParamsConfigWARPRouting{ - Enabled: cloudflare.F(true), - }), - }), - }, - ) - 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 TestZeroTrustTunnelConfigurationGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Tunnels.Configurations.Get( - context.TODO(), - "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustTunnelConfigurationGetParams{ - AccountID: cloudflare.F("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/zerotrusttunnelconnection.go b/zerotrusttunnelconnection.go deleted file mode 100644 index fd6a84a221b..00000000000 --- a/zerotrusttunnelconnection.go +++ /dev/null @@ -1,389 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustTunnelConnectionService 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 -// [NewZeroTrustTunnelConnectionService] method instead. -type ZeroTrustTunnelConnectionService struct { - Options []option.RequestOption -} - -// NewZeroTrustTunnelConnectionService 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 NewZeroTrustTunnelConnectionService(opts ...option.RequestOption) (r *ZeroTrustTunnelConnectionService) { - r = &ZeroTrustTunnelConnectionService{} - r.Options = opts - return -} - -// Removes connections that are in a disconnected or pending reconnect state. We -// recommend running this command after shutting down a tunnel. -func (r *ZeroTrustTunnelConnectionService) Delete(ctx context.Context, tunnelID string, params ZeroTrustTunnelConnectionDeleteParams, opts ...option.RequestOption) (res *ZeroTrustTunnelConnectionDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustTunnelConnectionDeleteResponseEnvelope - path := fmt.Sprintf("accounts/%s/tunnels/%s/connections", params.AccountID, tunnelID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches connection details for a Cloudflare Tunnel. -func (r *ZeroTrustTunnelConnectionService) Get(ctx context.Context, tunnelID string, query ZeroTrustTunnelConnectionGetParams, opts ...option.RequestOption) (res *[]ZeroTrustTunnelConnectionGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustTunnelConnectionGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s/connections", query.AccountID, tunnelID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [ZeroTrustTunnelConnectionDeleteResponseUnknown], -// [ZeroTrustTunnelConnectionDeleteResponseArray] or [shared.UnionString]. -type ZeroTrustTunnelConnectionDeleteResponse interface { - ImplementsZeroTrustTunnelConnectionDeleteResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustTunnelConnectionDeleteResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustTunnelConnectionDeleteResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustTunnelConnectionDeleteResponseArray []interface{} - -func (r ZeroTrustTunnelConnectionDeleteResponseArray) ImplementsZeroTrustTunnelConnectionDeleteResponse() { -} - -// A client (typically cloudflared) that maintains connections to a Cloudflare data -// center. -type ZeroTrustTunnelConnectionGetResponse struct { - // UUID of the Cloudflare Tunnel connection. - ID string `json:"id"` - // The cloudflared OS architecture used to establish this connection. - Arch string `json:"arch"` - // The version of the remote tunnel configuration. Used internally to sync - // cloudflared with the Zero Trust dashboard. - ConfigVersion int64 `json:"config_version"` - // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - Conns []ZeroTrustTunnelConnectionGetResponseConn `json:"conns"` - // Features enabled for the Cloudflare Tunnel. - Features []string `json:"features"` - // Timestamp of when the tunnel connection was started. - RunAt time.Time `json:"run_at" format:"date-time"` - // The cloudflared version used to establish this connection. - Version string `json:"version"` - JSON zeroTrustTunnelConnectionGetResponseJSON `json:"-"` -} - -// zeroTrustTunnelConnectionGetResponseJSON contains the JSON metadata for the -// struct [ZeroTrustTunnelConnectionGetResponse] -type zeroTrustTunnelConnectionGetResponseJSON struct { - ID apijson.Field - Arch apijson.Field - ConfigVersion apijson.Field - Conns apijson.Field - Features apijson.Field - RunAt apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConnectionGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConnectionGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelConnectionGetResponseConn struct { - // UUID of the Cloudflare Tunnel connection. - ID string `json:"id"` - // UUID of the cloudflared instance. - ClientID interface{} `json:"client_id"` - // The cloudflared version used to establish this connection. - ClientVersion string `json:"client_version"` - // The Cloudflare data center used for this connection. - ColoName string `json:"colo_name"` - // Cloudflare continues to track connections for several minutes after they - // disconnect. This is an optimization to improve latency and reliability of - // reconnecting. If `true`, the connection has disconnected but is still being - // tracked. If `false`, the connection is actively serving traffic. - IsPendingReconnect bool `json:"is_pending_reconnect"` - // Timestamp of when the connection was established. - OpenedAt time.Time `json:"opened_at" format:"date-time"` - // The public IP address of the host running cloudflared. - OriginIP string `json:"origin_ip"` - // UUID of the Cloudflare Tunnel connection. - UUID string `json:"uuid"` - JSON zeroTrustTunnelConnectionGetResponseConnJSON `json:"-"` -} - -// zeroTrustTunnelConnectionGetResponseConnJSON contains the JSON metadata for the -// struct [ZeroTrustTunnelConnectionGetResponseConn] -type zeroTrustTunnelConnectionGetResponseConnJSON struct { - ID apijson.Field - ClientID apijson.Field - ClientVersion apijson.Field - ColoName apijson.Field - IsPendingReconnect apijson.Field - OpenedAt apijson.Field - OriginIP apijson.Field - UUID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConnectionGetResponseConn) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConnectionGetResponseConnJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelConnectionDeleteParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - Body param.Field[interface{}] `json:"body,required"` -} - -func (r ZeroTrustTunnelConnectionDeleteParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type ZeroTrustTunnelConnectionDeleteResponseEnvelope struct { - Errors []ZeroTrustTunnelConnectionDeleteResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustTunnelConnectionDeleteResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustTunnelConnectionDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustTunnelConnectionDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustTunnelConnectionDeleteResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustTunnelConnectionDeleteResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZeroTrustTunnelConnectionDeleteResponseEnvelope] -type zeroTrustTunnelConnectionDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConnectionDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConnectionDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelConnectionDeleteResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelConnectionDeleteResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustTunnelConnectionDeleteResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustTunnelConnectionDeleteResponseEnvelopeErrors] -type zeroTrustTunnelConnectionDeleteResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConnectionDeleteResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConnectionDeleteResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelConnectionDeleteResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelConnectionDeleteResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustTunnelConnectionDeleteResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZeroTrustTunnelConnectionDeleteResponseEnvelopeMessages] -type zeroTrustTunnelConnectionDeleteResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConnectionDeleteResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConnectionDeleteResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustTunnelConnectionDeleteResponseEnvelopeSuccess bool - -const ( - ZeroTrustTunnelConnectionDeleteResponseEnvelopeSuccessTrue ZeroTrustTunnelConnectionDeleteResponseEnvelopeSuccess = true -) - -type ZeroTrustTunnelConnectionGetParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustTunnelConnectionGetResponseEnvelope struct { - Errors []ZeroTrustTunnelConnectionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustTunnelConnectionGetResponseEnvelopeMessages `json:"messages,required"` - Result []ZeroTrustTunnelConnectionGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZeroTrustTunnelConnectionGetResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZeroTrustTunnelConnectionGetResponseEnvelopeResultInfo `json:"result_info"` - JSON zeroTrustTunnelConnectionGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustTunnelConnectionGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustTunnelConnectionGetResponseEnvelope] -type zeroTrustTunnelConnectionGetResponseEnvelopeJSON 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 *ZeroTrustTunnelConnectionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConnectionGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelConnectionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelConnectionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustTunnelConnectionGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustTunnelConnectionGetResponseEnvelopeErrors] -type zeroTrustTunnelConnectionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConnectionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConnectionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelConnectionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelConnectionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustTunnelConnectionGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustTunnelConnectionGetResponseEnvelopeMessages] -type zeroTrustTunnelConnectionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConnectionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConnectionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustTunnelConnectionGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustTunnelConnectionGetResponseEnvelopeSuccessTrue ZeroTrustTunnelConnectionGetResponseEnvelopeSuccess = true -) - -type ZeroTrustTunnelConnectionGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zeroTrustTunnelConnectionGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zeroTrustTunnelConnectionGetResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZeroTrustTunnelConnectionGetResponseEnvelopeResultInfo] -type zeroTrustTunnelConnectionGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConnectionGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConnectionGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zerotrusttunnelconnection_test.go b/zerotrusttunnelconnection_test.go deleted file mode 100644 index 4aa4f6f5907..00000000000 --- a/zerotrusttunnelconnection_test.go +++ /dev/null @@ -1,75 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustTunnelConnectionDelete(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("user@example.com"), - ) - _, err := client.ZeroTrust.Tunnels.Connections.Delete( - context.TODO(), - "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustTunnelConnectionDeleteParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - 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 TestZeroTrustTunnelConnectionGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Tunnels.Connections.Get( - context.TODO(), - "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustTunnelConnectionGetParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrusttunnelconnector.go b/zerotrusttunnelconnector.go deleted file mode 100644 index 602eb11b100..00000000000 --- a/zerotrusttunnelconnector.go +++ /dev/null @@ -1,223 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZeroTrustTunnelConnectorService 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 -// [NewZeroTrustTunnelConnectorService] method instead. -type ZeroTrustTunnelConnectorService struct { - Options []option.RequestOption -} - -// NewZeroTrustTunnelConnectorService 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 NewZeroTrustTunnelConnectorService(opts ...option.RequestOption) (r *ZeroTrustTunnelConnectorService) { - r = &ZeroTrustTunnelConnectorService{} - r.Options = opts - return -} - -// Fetches connector and connection details for a Cloudflare Tunnel. -func (r *ZeroTrustTunnelConnectorService) Get(ctx context.Context, tunnelID string, connectorID string, query ZeroTrustTunnelConnectorGetParams, opts ...option.RequestOption) (res *ZeroTrustTunnelConnectorGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustTunnelConnectorGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s/connectors/%s", query.AccountID, tunnelID, connectorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// A client (typically cloudflared) that maintains connections to a Cloudflare data -// center. -type ZeroTrustTunnelConnectorGetResponse struct { - // UUID of the Cloudflare Tunnel connection. - ID string `json:"id"` - // The cloudflared OS architecture used to establish this connection. - Arch string `json:"arch"` - // The version of the remote tunnel configuration. Used internally to sync - // cloudflared with the Zero Trust dashboard. - ConfigVersion int64 `json:"config_version"` - // The Cloudflare Tunnel connections between your origin and Cloudflare's edge. - Conns []ZeroTrustTunnelConnectorGetResponseConn `json:"conns"` - // Features enabled for the Cloudflare Tunnel. - Features []string `json:"features"` - // Timestamp of when the tunnel connection was started. - RunAt time.Time `json:"run_at" format:"date-time"` - // The cloudflared version used to establish this connection. - Version string `json:"version"` - JSON zeroTrustTunnelConnectorGetResponseJSON `json:"-"` -} - -// zeroTrustTunnelConnectorGetResponseJSON contains the JSON metadata for the -// struct [ZeroTrustTunnelConnectorGetResponse] -type zeroTrustTunnelConnectorGetResponseJSON struct { - ID apijson.Field - Arch apijson.Field - ConfigVersion apijson.Field - Conns apijson.Field - Features apijson.Field - RunAt apijson.Field - Version apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConnectorGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConnectorGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelConnectorGetResponseConn struct { - // UUID of the Cloudflare Tunnel connection. - ID string `json:"id"` - // UUID of the cloudflared instance. - ClientID interface{} `json:"client_id"` - // The cloudflared version used to establish this connection. - ClientVersion string `json:"client_version"` - // The Cloudflare data center used for this connection. - ColoName string `json:"colo_name"` - // Cloudflare continues to track connections for several minutes after they - // disconnect. This is an optimization to improve latency and reliability of - // reconnecting. If `true`, the connection has disconnected but is still being - // tracked. If `false`, the connection is actively serving traffic. - IsPendingReconnect bool `json:"is_pending_reconnect"` - // Timestamp of when the connection was established. - OpenedAt time.Time `json:"opened_at" format:"date-time"` - // The public IP address of the host running cloudflared. - OriginIP string `json:"origin_ip"` - // UUID of the Cloudflare Tunnel connection. - UUID string `json:"uuid"` - JSON zeroTrustTunnelConnectorGetResponseConnJSON `json:"-"` -} - -// zeroTrustTunnelConnectorGetResponseConnJSON contains the JSON metadata for the -// struct [ZeroTrustTunnelConnectorGetResponseConn] -type zeroTrustTunnelConnectorGetResponseConnJSON struct { - ID apijson.Field - ClientID apijson.Field - ClientVersion apijson.Field - ColoName apijson.Field - IsPendingReconnect apijson.Field - OpenedAt apijson.Field - OriginIP apijson.Field - UUID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConnectorGetResponseConn) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConnectorGetResponseConnJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelConnectorGetParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustTunnelConnectorGetResponseEnvelope struct { - Errors []ZeroTrustTunnelConnectorGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustTunnelConnectorGetResponseEnvelopeMessages `json:"messages,required"` - // A client (typically cloudflared) that maintains connections to a Cloudflare data - // center. - Result ZeroTrustTunnelConnectorGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustTunnelConnectorGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustTunnelConnectorGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustTunnelConnectorGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustTunnelConnectorGetResponseEnvelope] -type zeroTrustTunnelConnectorGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConnectorGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConnectorGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelConnectorGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelConnectorGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustTunnelConnectorGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZeroTrustTunnelConnectorGetResponseEnvelopeErrors] -type zeroTrustTunnelConnectorGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConnectorGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConnectorGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelConnectorGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelConnectorGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustTunnelConnectorGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustTunnelConnectorGetResponseEnvelopeMessages] -type zeroTrustTunnelConnectorGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelConnectorGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelConnectorGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustTunnelConnectorGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustTunnelConnectorGetResponseEnvelopeSuccessTrue ZeroTrustTunnelConnectorGetResponseEnvelopeSuccess = true -) diff --git a/zerotrusttunnelconnector_test.go b/zerotrusttunnelconnector_test.go deleted file mode 100644 index 2a9dce690ae..00000000000 --- a/zerotrusttunnelconnector_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustTunnelConnectorGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Tunnels.Connectors.Get( - context.TODO(), - "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", - "1bedc50d-42b3-473c-b108-ff3d10c0d925", - cloudflare.ZeroTrustTunnelConnectorGetParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zerotrusttunnelmanagement.go b/zerotrusttunnelmanagement.go deleted file mode 100644 index 96e9d21ee5f..00000000000 --- a/zerotrusttunnelmanagement.go +++ /dev/null @@ -1,172 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustTunnelManagementService 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 -// [NewZeroTrustTunnelManagementService] method instead. -type ZeroTrustTunnelManagementService struct { - Options []option.RequestOption -} - -// NewZeroTrustTunnelManagementService 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 NewZeroTrustTunnelManagementService(opts ...option.RequestOption) (r *ZeroTrustTunnelManagementService) { - r = &ZeroTrustTunnelManagementService{} - r.Options = opts - return -} - -// Gets a management token used to access the management resources (i.e. Streaming -// Logs) of a tunnel. -func (r *ZeroTrustTunnelManagementService) New(ctx context.Context, tunnelID string, params ZeroTrustTunnelManagementNewParams, opts ...option.RequestOption) (res *ZeroTrustTunnelManagementNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustTunnelManagementNewResponseEnvelope - path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s/management", params.AccountID, tunnelID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [ZeroTrustTunnelManagementNewResponseUnknown], -// [ZeroTrustTunnelManagementNewResponseArray] or [shared.UnionString]. -type ZeroTrustTunnelManagementNewResponse interface { - ImplementsZeroTrustTunnelManagementNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustTunnelManagementNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustTunnelManagementNewResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustTunnelManagementNewResponseArray []interface{} - -func (r ZeroTrustTunnelManagementNewResponseArray) ImplementsZeroTrustTunnelManagementNewResponse() {} - -type ZeroTrustTunnelManagementNewParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` - Resources param.Field[[]ZeroTrustTunnelManagementNewParamsResource] `json:"resources,required"` -} - -func (r ZeroTrustTunnelManagementNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Management resources the token will have access to. -type ZeroTrustTunnelManagementNewParamsResource string - -const ( - ZeroTrustTunnelManagementNewParamsResourceLogs ZeroTrustTunnelManagementNewParamsResource = "logs" -) - -type ZeroTrustTunnelManagementNewResponseEnvelope struct { - Errors []ZeroTrustTunnelManagementNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustTunnelManagementNewResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustTunnelManagementNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustTunnelManagementNewResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustTunnelManagementNewResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustTunnelManagementNewResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZeroTrustTunnelManagementNewResponseEnvelope] -type zeroTrustTunnelManagementNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelManagementNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelManagementNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelManagementNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelManagementNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustTunnelManagementNewResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZeroTrustTunnelManagementNewResponseEnvelopeErrors] -type zeroTrustTunnelManagementNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelManagementNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelManagementNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelManagementNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelManagementNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustTunnelManagementNewResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZeroTrustTunnelManagementNewResponseEnvelopeMessages] -type zeroTrustTunnelManagementNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelManagementNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelManagementNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustTunnelManagementNewResponseEnvelopeSuccess bool - -const ( - ZeroTrustTunnelManagementNewResponseEnvelopeSuccessTrue ZeroTrustTunnelManagementNewResponseEnvelopeSuccess = true -) diff --git a/zerotrusttunnelmanagement_test.go b/zerotrusttunnelmanagement_test.go deleted file mode 100644 index 58a59de48f2..00000000000 --- a/zerotrusttunnelmanagement_test.go +++ /dev/null @@ -1,45 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustTunnelManagementNew(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("user@example.com"), - ) - _, err := client.ZeroTrust.Tunnels.Management.New( - context.TODO(), - "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustTunnelManagementNewParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Resources: cloudflare.F([]cloudflare.ZeroTrustTunnelManagementNewParamsResource{cloudflare.ZeroTrustTunnelManagementNewParamsResourceLogs}), - }, - ) - 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/zerotrusttunneltoken.go b/zerotrusttunneltoken.go deleted file mode 100644 index d6df963bb02..00000000000 --- a/zerotrusttunneltoken.go +++ /dev/null @@ -1,159 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZeroTrustTunnelTokenService 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 [NewZeroTrustTunnelTokenService] -// method instead. -type ZeroTrustTunnelTokenService struct { - Options []option.RequestOption -} - -// NewZeroTrustTunnelTokenService 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 NewZeroTrustTunnelTokenService(opts ...option.RequestOption) (r *ZeroTrustTunnelTokenService) { - r = &ZeroTrustTunnelTokenService{} - r.Options = opts - return -} - -// Gets the token used to associate cloudflared with a specific tunnel. -func (r *ZeroTrustTunnelTokenService) Get(ctx context.Context, tunnelID string, query ZeroTrustTunnelTokenGetParams, opts ...option.RequestOption) (res *ZeroTrustTunnelTokenGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZeroTrustTunnelTokenGetResponseEnvelope - path := fmt.Sprintf("accounts/%s/cfd_tunnel/%s/token", query.AccountID, tunnelID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [ZeroTrustTunnelTokenGetResponseUnknown], -// [ZeroTrustTunnelTokenGetResponseArray] or [shared.UnionString]. -type ZeroTrustTunnelTokenGetResponse interface { - ImplementsZeroTrustTunnelTokenGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZeroTrustTunnelTokenGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZeroTrustTunnelTokenGetResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZeroTrustTunnelTokenGetResponseArray []interface{} - -func (r ZeroTrustTunnelTokenGetResponseArray) ImplementsZeroTrustTunnelTokenGetResponse() {} - -type ZeroTrustTunnelTokenGetParams struct { - // Cloudflare account ID - AccountID param.Field[string] `path:"account_id,required"` -} - -type ZeroTrustTunnelTokenGetResponseEnvelope struct { - Errors []ZeroTrustTunnelTokenGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZeroTrustTunnelTokenGetResponseEnvelopeMessages `json:"messages,required"` - Result ZeroTrustTunnelTokenGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZeroTrustTunnelTokenGetResponseEnvelopeSuccess `json:"success,required"` - JSON zeroTrustTunnelTokenGetResponseEnvelopeJSON `json:"-"` -} - -// zeroTrustTunnelTokenGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZeroTrustTunnelTokenGetResponseEnvelope] -type zeroTrustTunnelTokenGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelTokenGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelTokenGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelTokenGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelTokenGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zeroTrustTunnelTokenGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZeroTrustTunnelTokenGetResponseEnvelopeErrors] -type zeroTrustTunnelTokenGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelTokenGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelTokenGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZeroTrustTunnelTokenGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zeroTrustTunnelTokenGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zeroTrustTunnelTokenGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZeroTrustTunnelTokenGetResponseEnvelopeMessages] -type zeroTrustTunnelTokenGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZeroTrustTunnelTokenGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zeroTrustTunnelTokenGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZeroTrustTunnelTokenGetResponseEnvelopeSuccess bool - -const ( - ZeroTrustTunnelTokenGetResponseEnvelopeSuccessTrue ZeroTrustTunnelTokenGetResponseEnvelopeSuccess = true -) diff --git a/zerotrusttunneltoken_test.go b/zerotrusttunneltoken_test.go deleted file mode 100644 index a7213d06631..00000000000 --- a/zerotrusttunneltoken_test.go +++ /dev/null @@ -1,44 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZeroTrustTunnelTokenGet(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("user@example.com"), - ) - _, err := client.ZeroTrust.Tunnels.Token.Get( - context.TODO(), - "f70ff985-a4ef-4643-bbbc-4a0ed4fc8415", - cloudflare.ZeroTrustTunnelTokenGetParams{ - AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - }, - ) - 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/zoneactivationcheck.go b/zoneactivationcheck.go deleted file mode 100644 index dbd47321351..00000000000 --- a/zoneactivationcheck.go +++ /dev/null @@ -1,154 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneActivationCheckService 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 [NewZoneActivationCheckService] -// method instead. -type ZoneActivationCheckService struct { - Options []option.RequestOption -} - -// NewZoneActivationCheckService 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 NewZoneActivationCheckService(opts ...option.RequestOption) (r *ZoneActivationCheckService) { - r = &ZoneActivationCheckService{} - r.Options = opts - return -} - -// Triggeres a new activation check for a PENDING Zone. This can be triggered every -// 5 min for paygo/ent customers, every hour for FREE Zones. -func (r *ZoneActivationCheckService) Trigger(ctx context.Context, body ZoneActivationCheckTriggerParams, opts ...option.RequestOption) (res *ZoneActivationCheckTriggerResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneActivationCheckTriggerResponseEnvelope - path := fmt.Sprintf("zones/%s/activation_check", body.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZoneActivationCheckTriggerResponse struct { - // Identifier - ID string `json:"id"` - JSON zoneActivationCheckTriggerResponseJSON `json:"-"` -} - -// zoneActivationCheckTriggerResponseJSON contains the JSON metadata for the struct -// [ZoneActivationCheckTriggerResponse] -type zoneActivationCheckTriggerResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneActivationCheckTriggerResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneActivationCheckTriggerResponseJSON) RawJSON() string { - return r.raw -} - -type ZoneActivationCheckTriggerParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneActivationCheckTriggerResponseEnvelope struct { - Errors []ZoneActivationCheckTriggerResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneActivationCheckTriggerResponseEnvelopeMessages `json:"messages,required"` - Result ZoneActivationCheckTriggerResponse `json:"result,required"` - // Whether the API call was successful - Success ZoneActivationCheckTriggerResponseEnvelopeSuccess `json:"success,required"` - JSON zoneActivationCheckTriggerResponseEnvelopeJSON `json:"-"` -} - -// zoneActivationCheckTriggerResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneActivationCheckTriggerResponseEnvelope] -type zoneActivationCheckTriggerResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneActivationCheckTriggerResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneActivationCheckTriggerResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneActivationCheckTriggerResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneActivationCheckTriggerResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneActivationCheckTriggerResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneActivationCheckTriggerResponseEnvelopeErrors] -type zoneActivationCheckTriggerResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneActivationCheckTriggerResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneActivationCheckTriggerResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneActivationCheckTriggerResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneActivationCheckTriggerResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneActivationCheckTriggerResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneActivationCheckTriggerResponseEnvelopeMessages] -type zoneActivationCheckTriggerResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneActivationCheckTriggerResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneActivationCheckTriggerResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZoneActivationCheckTriggerResponseEnvelopeSuccess bool - -const ( - ZoneActivationCheckTriggerResponseEnvelopeSuccessTrue ZoneActivationCheckTriggerResponseEnvelopeSuccess = true -) diff --git a/zoneactivationcheck_test.go b/zoneactivationcheck_test.go deleted file mode 100644 index 4092dd7acc7..00000000000 --- a/zoneactivationcheck_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneActivationCheckTrigger(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("user@example.com"), - ) - _, err := client.Zones.ActivationCheck.Trigger(context.TODO(), cloudflare.ZoneActivationCheckTriggerParams{ - ZoneID: cloudflare.F("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/zonecustomnameserver.go b/zonecustomnameserver.go deleted file mode 100644 index d34c4b7584e..00000000000 --- a/zonecustomnameserver.go +++ /dev/null @@ -1,367 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZoneCustomNameserverService 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 [NewZoneCustomNameserverService] -// method instead. -type ZoneCustomNameserverService struct { - Options []option.RequestOption -} - -// NewZoneCustomNameserverService 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 NewZoneCustomNameserverService(opts ...option.RequestOption) (r *ZoneCustomNameserverService) { - r = &ZoneCustomNameserverService{} - r.Options = opts - return -} - -// Set metadata for account-level custom nameservers on a zone. -// -// If you would like new zones in the account to use account custom nameservers by -// default, use PUT /accounts/:identifier to set the account setting -// use_account_custom_ns_by_default to true. -func (r *ZoneCustomNameserverService) Update(ctx context.Context, params ZoneCustomNameserverUpdateParams, opts ...option.RequestOption) (res *ZoneCustomNameserverUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneCustomNameserverUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/custom_ns", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get metadata for account-level custom nameservers on a zone. -func (r *ZoneCustomNameserverService) Get(ctx context.Context, query ZoneCustomNameserverGetParams, opts ...option.RequestOption) (res *ZoneCustomNameserverGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneCustomNameserverGetResponseEnvelope - path := fmt.Sprintf("zones/%s/custom_ns", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [ZoneCustomNameserverUpdateResponseUnknown], -// [ZoneCustomNameserverUpdateResponseArray] or [shared.UnionString]. -type ZoneCustomNameserverUpdateResponse interface { - ImplementsZoneCustomNameserverUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZoneCustomNameserverUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneCustomNameserverUpdateResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZoneCustomNameserverUpdateResponseArray []interface{} - -func (r ZoneCustomNameserverUpdateResponseArray) ImplementsZoneCustomNameserverUpdateResponse() {} - -// Union satisfied by [ZoneCustomNameserverGetResponseUnknown], -// [ZoneCustomNameserverGetResponseArray] or [shared.UnionString]. -type ZoneCustomNameserverGetResponse interface { - ImplementsZoneCustomNameserverGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZoneCustomNameserverGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneCustomNameserverGetResponseArray{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZoneCustomNameserverGetResponseArray []interface{} - -func (r ZoneCustomNameserverGetResponseArray) ImplementsZoneCustomNameserverGetResponse() {} - -type ZoneCustomNameserverUpdateParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Whether zone uses account-level custom nameservers. - Enabled param.Field[bool] `json:"enabled"` - // The number of the name server set to assign to the zone. - NSSet param.Field[float64] `json:"ns_set"` -} - -func (r ZoneCustomNameserverUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZoneCustomNameserverUpdateResponseEnvelope struct { - Errors []ZoneCustomNameserverUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneCustomNameserverUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZoneCustomNameserverUpdateResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZoneCustomNameserverUpdateResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZoneCustomNameserverUpdateResponseEnvelopeResultInfo `json:"result_info"` - JSON zoneCustomNameserverUpdateResponseEnvelopeJSON `json:"-"` -} - -// zoneCustomNameserverUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneCustomNameserverUpdateResponseEnvelope] -type zoneCustomNameserverUpdateResponseEnvelopeJSON 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 *ZoneCustomNameserverUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneCustomNameserverUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneCustomNameserverUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneCustomNameserverUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneCustomNameserverUpdateResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneCustomNameserverUpdateResponseEnvelopeErrors] -type zoneCustomNameserverUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneCustomNameserverUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneCustomNameserverUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneCustomNameserverUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneCustomNameserverUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneCustomNameserverUpdateResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneCustomNameserverUpdateResponseEnvelopeMessages] -type zoneCustomNameserverUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneCustomNameserverUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneCustomNameserverUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZoneCustomNameserverUpdateResponseEnvelopeSuccess bool - -const ( - ZoneCustomNameserverUpdateResponseEnvelopeSuccessTrue ZoneCustomNameserverUpdateResponseEnvelopeSuccess = true -) - -type ZoneCustomNameserverUpdateResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zoneCustomNameserverUpdateResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zoneCustomNameserverUpdateResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [ZoneCustomNameserverUpdateResponseEnvelopeResultInfo] -type zoneCustomNameserverUpdateResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneCustomNameserverUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneCustomNameserverUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZoneCustomNameserverGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneCustomNameserverGetResponseEnvelope struct { - Errors []ZoneCustomNameserverGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneCustomNameserverGetResponseEnvelopeMessages `json:"messages,required"` - Result ZoneCustomNameserverGetResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZoneCustomNameserverGetResponseEnvelopeSuccess `json:"success,required"` - // Whether zone uses account-level custom nameservers. - Enabled bool `json:"enabled"` - // The number of the name server set to assign to the zone. - NSSet float64 `json:"ns_set"` - ResultInfo ZoneCustomNameserverGetResponseEnvelopeResultInfo `json:"result_info"` - JSON zoneCustomNameserverGetResponseEnvelopeJSON `json:"-"` -} - -// zoneCustomNameserverGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneCustomNameserverGetResponseEnvelope] -type zoneCustomNameserverGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - Enabled apijson.Field - NSSet apijson.Field - ResultInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneCustomNameserverGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneCustomNameserverGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneCustomNameserverGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneCustomNameserverGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneCustomNameserverGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneCustomNameserverGetResponseEnvelopeErrors] -type zoneCustomNameserverGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneCustomNameserverGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneCustomNameserverGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneCustomNameserverGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneCustomNameserverGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneCustomNameserverGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZoneCustomNameserverGetResponseEnvelopeMessages] -type zoneCustomNameserverGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneCustomNameserverGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneCustomNameserverGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZoneCustomNameserverGetResponseEnvelopeSuccess bool - -const ( - ZoneCustomNameserverGetResponseEnvelopeSuccessTrue ZoneCustomNameserverGetResponseEnvelopeSuccess = true -) - -type ZoneCustomNameserverGetResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zoneCustomNameserverGetResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zoneCustomNameserverGetResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [ZoneCustomNameserverGetResponseEnvelopeResultInfo] -type zoneCustomNameserverGetResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneCustomNameserverGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneCustomNameserverGetResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/zonecustomnameserver_test.go b/zonecustomnameserver_test.go deleted file mode 100644 index 8e793d938d2..00000000000 --- a/zonecustomnameserver_test.go +++ /dev/null @@ -1,68 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneCustomNameserverUpdateWithOptionalParams(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("user@example.com"), - ) - _, err := client.Zones.CustomNameservers.Update(context.TODO(), cloudflare.ZoneCustomNameserverUpdateParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Enabled: cloudflare.F(true), - NSSet: cloudflare.F(1.000000), - }) - 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 TestZoneCustomNameserverGet(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("user@example.com"), - ) - _, err := client.Zones.CustomNameservers.Get(context.TODO(), cloudflare.ZoneCustomNameserverGetParams{ - ZoneID: cloudflare.F("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/zonehold.go b/zonehold.go deleted file mode 100644 index 9c5969154d3..00000000000 --- a/zonehold.go +++ /dev/null @@ -1,373 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "net/url" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/apiquery" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneHoldService 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 [NewZoneHoldService] method instead. -type ZoneHoldService struct { - Options []option.RequestOption -} - -// NewZoneHoldService 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 NewZoneHoldService(opts ...option.RequestOption) (r *ZoneHoldService) { - r = &ZoneHoldService{} - r.Options = opts - return -} - -// Enforce a zone hold on the zone, blocking the creation and activation of zones -// with this zone's hostname. -func (r *ZoneHoldService) New(ctx context.Context, params ZoneHoldNewParams, opts ...option.RequestOption) (res *ZoneHoldNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneHoldNewResponseEnvelope - path := fmt.Sprintf("zones/%s/hold", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Stop enforcement of a zone hold on the zone, permanently or temporarily, -// allowing the creation and activation of zones with this zone's hostname. -func (r *ZoneHoldService) Delete(ctx context.Context, params ZoneHoldDeleteParams, opts ...option.RequestOption) (res *ZoneHoldDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneHoldDeleteResponseEnvelope - path := fmt.Sprintf("zones/%s/hold", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Retrieve whether the zone is subject to a zone hold, and metadata about the -// hold. -func (r *ZoneHoldService) Get(ctx context.Context, query ZoneHoldGetParams, opts ...option.RequestOption) (res *ZoneHoldGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneHoldGetResponseEnvelope - path := fmt.Sprintf("zones/%s/hold", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZoneHoldNewResponse struct { - Hold bool `json:"hold"` - HoldAfter string `json:"hold_after"` - IncludeSubdomains string `json:"include_subdomains"` - JSON zoneHoldNewResponseJSON `json:"-"` -} - -// zoneHoldNewResponseJSON contains the JSON metadata for the struct -// [ZoneHoldNewResponse] -type zoneHoldNewResponseJSON struct { - Hold apijson.Field - HoldAfter apijson.Field - IncludeSubdomains apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneHoldNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneHoldNewResponseJSON) RawJSON() string { - return r.raw -} - -type ZoneHoldDeleteResponse struct { - Hold bool `json:"hold"` - HoldAfter string `json:"hold_after"` - IncludeSubdomains string `json:"include_subdomains"` - JSON zoneHoldDeleteResponseJSON `json:"-"` -} - -// zoneHoldDeleteResponseJSON contains the JSON metadata for the struct -// [ZoneHoldDeleteResponse] -type zoneHoldDeleteResponseJSON struct { - Hold apijson.Field - HoldAfter apijson.Field - IncludeSubdomains apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneHoldDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneHoldDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type ZoneHoldGetResponse struct { - Hold bool `json:"hold"` - HoldAfter string `json:"hold_after"` - IncludeSubdomains string `json:"include_subdomains"` - JSON zoneHoldGetResponseJSON `json:"-"` -} - -// zoneHoldGetResponseJSON contains the JSON metadata for the struct -// [ZoneHoldGetResponse] -type zoneHoldGetResponseJSON struct { - Hold apijson.Field - HoldAfter apijson.Field - IncludeSubdomains apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneHoldGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneHoldGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZoneHoldNewParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // If provided, the zone hold will extend to block any subdomain of the given zone, - // as well as SSL4SaaS Custom Hostnames. For example, a zone hold on a zone with - // the hostname 'example.com' and include_subdomains=true will block 'example.com', - // 'staging.example.com', 'api.staging.example.com', etc. - IncludeSubdomains param.Field[bool] `query:"include_subdomains"` -} - -// URLQuery serializes [ZoneHoldNewParams]'s query parameters as `url.Values`. -func (r ZoneHoldNewParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type ZoneHoldNewResponseEnvelope struct { - Errors []ZoneHoldNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneHoldNewResponseEnvelopeMessages `json:"messages,required"` - Result ZoneHoldNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZoneHoldNewResponseEnvelopeSuccess `json:"success,required"` - JSON zoneHoldNewResponseEnvelopeJSON `json:"-"` -} - -// zoneHoldNewResponseEnvelopeJSON contains the JSON metadata for the struct -// [ZoneHoldNewResponseEnvelope] -type zoneHoldNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneHoldNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneHoldNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneHoldNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneHoldNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneHoldNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ZoneHoldNewResponseEnvelopeErrors] -type zoneHoldNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneHoldNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneHoldNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneHoldNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneHoldNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneHoldNewResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ZoneHoldNewResponseEnvelopeMessages] -type zoneHoldNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneHoldNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneHoldNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZoneHoldNewResponseEnvelopeSuccess bool - -const ( - ZoneHoldNewResponseEnvelopeSuccessTrue ZoneHoldNewResponseEnvelopeSuccess = true -) - -type ZoneHoldDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // If `hold_after` is provided, the hold will be temporarily disabled, then - // automatically re-enabled by the system at the time specified in this - // RFC3339-formatted timestamp. Otherwise, the hold will be disabled indefinitely. - HoldAfter param.Field[string] `query:"hold_after"` -} - -// URLQuery serializes [ZoneHoldDeleteParams]'s query parameters as `url.Values`. -func (r ZoneHoldDeleteParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatComma, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type ZoneHoldDeleteResponseEnvelope struct { - Result ZoneHoldDeleteResponse `json:"result"` - JSON zoneHoldDeleteResponseEnvelopeJSON `json:"-"` -} - -// zoneHoldDeleteResponseEnvelopeJSON contains the JSON metadata for the struct -// [ZoneHoldDeleteResponseEnvelope] -type zoneHoldDeleteResponseEnvelopeJSON struct { - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneHoldDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneHoldDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneHoldGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneHoldGetResponseEnvelope struct { - Errors []ZoneHoldGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneHoldGetResponseEnvelopeMessages `json:"messages,required"` - Result ZoneHoldGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZoneHoldGetResponseEnvelopeSuccess `json:"success,required"` - JSON zoneHoldGetResponseEnvelopeJSON `json:"-"` -} - -// zoneHoldGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [ZoneHoldGetResponseEnvelope] -type zoneHoldGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneHoldGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneHoldGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneHoldGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneHoldGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneHoldGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct -// [ZoneHoldGetResponseEnvelopeErrors] -type zoneHoldGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneHoldGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneHoldGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneHoldGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneHoldGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneHoldGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ZoneHoldGetResponseEnvelopeMessages] -type zoneHoldGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneHoldGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneHoldGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZoneHoldGetResponseEnvelopeSuccess bool - -const ( - ZoneHoldGetResponseEnvelopeSuccessTrue ZoneHoldGetResponseEnvelopeSuccess = true -) diff --git a/zonehold_test.go b/zonehold_test.go deleted file mode 100644 index 6c586f43d1c..00000000000 --- a/zonehold_test.go +++ /dev/null @@ -1,94 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneHoldNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Zones.Holds.New(context.TODO(), cloudflare.ZoneHoldNewParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - IncludeSubdomains: cloudflare.F(true), - }) - 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 TestZoneHoldDeleteWithOptionalParams(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("user@example.com"), - ) - _, err := client.Zones.Holds.Delete(context.TODO(), cloudflare.ZoneHoldDeleteParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - HoldAfter: cloudflare.F("string"), - }) - 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 TestZoneHoldGet(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("user@example.com"), - ) - _, err := client.Zones.Holds.Get(context.TODO(), cloudflare.ZoneHoldGetParams{ - ZoneID: cloudflare.F("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/zones/activationcheck.go b/zones/activationcheck.go new file mode 100644 index 00000000000..22fb8ca24ec --- /dev/null +++ b/zones/activationcheck.go @@ -0,0 +1,154 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// ActivationCheckService 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 [NewActivationCheckService] method +// instead. +type ActivationCheckService struct { + Options []option.RequestOption +} + +// NewActivationCheckService 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 NewActivationCheckService(opts ...option.RequestOption) (r *ActivationCheckService) { + r = &ActivationCheckService{} + r.Options = opts + return +} + +// Triggeres a new activation check for a PENDING Zone. This can be triggered every +// 5 min for paygo/ent customers, every hour for FREE Zones. +func (r *ActivationCheckService) Trigger(ctx context.Context, body ActivationCheckTriggerParams, opts ...option.RequestOption) (res *ActivationCheckTriggerResponse, err error) { + opts = append(r.Options[:], opts...) + var env ActivationCheckTriggerResponseEnvelope + path := fmt.Sprintf("zones/%s/activation_check", body.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ActivationCheckTriggerResponse struct { + // Identifier + ID string `json:"id"` + JSON activationCheckTriggerResponseJSON `json:"-"` +} + +// activationCheckTriggerResponseJSON contains the JSON metadata for the struct +// [ActivationCheckTriggerResponse] +type activationCheckTriggerResponseJSON struct { + ID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ActivationCheckTriggerResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r activationCheckTriggerResponseJSON) RawJSON() string { + return r.raw +} + +type ActivationCheckTriggerParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type ActivationCheckTriggerResponseEnvelope struct { + Errors []ActivationCheckTriggerResponseEnvelopeErrors `json:"errors,required"` + Messages []ActivationCheckTriggerResponseEnvelopeMessages `json:"messages,required"` + Result ActivationCheckTriggerResponse `json:"result,required"` + // Whether the API call was successful + Success ActivationCheckTriggerResponseEnvelopeSuccess `json:"success,required"` + JSON activationCheckTriggerResponseEnvelopeJSON `json:"-"` +} + +// activationCheckTriggerResponseEnvelopeJSON contains the JSON metadata for the +// struct [ActivationCheckTriggerResponseEnvelope] +type activationCheckTriggerResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ActivationCheckTriggerResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r activationCheckTriggerResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type ActivationCheckTriggerResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON activationCheckTriggerResponseEnvelopeErrorsJSON `json:"-"` +} + +// activationCheckTriggerResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [ActivationCheckTriggerResponseEnvelopeErrors] +type activationCheckTriggerResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ActivationCheckTriggerResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r activationCheckTriggerResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type ActivationCheckTriggerResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON activationCheckTriggerResponseEnvelopeMessagesJSON `json:"-"` +} + +// activationCheckTriggerResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [ActivationCheckTriggerResponseEnvelopeMessages] +type activationCheckTriggerResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ActivationCheckTriggerResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r activationCheckTriggerResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type ActivationCheckTriggerResponseEnvelopeSuccess bool + +const ( + ActivationCheckTriggerResponseEnvelopeSuccessTrue ActivationCheckTriggerResponseEnvelopeSuccess = true +) diff --git a/zones/activationcheck_test.go b/zones/activationcheck_test.go new file mode 100644 index 00000000000..bc84fe8ef11 --- /dev/null +++ b/zones/activationcheck_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestActivationCheckTrigger(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("user@example.com"), + ) + _, err := client.Zones.ActivationCheck.Trigger(context.TODO(), zones.ActivationCheckTriggerParams{ + ZoneID: cloudflare.F("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/zones/aliases.go b/zones/aliases.go new file mode 100644 index 00000000000..19c58906c32 --- /dev/null +++ b/zones/aliases.go @@ -0,0 +1,9 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "github.com/cloudflare/cloudflare-go/internal/apierror" +) + +type Error = apierror.Error diff --git a/zones/customnameserver.go b/zones/customnameserver.go new file mode 100644 index 00000000000..645958451d7 --- /dev/null +++ b/zones/customnameserver.go @@ -0,0 +1,367 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// CustomNameserverService 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 [NewCustomNameserverService] method +// instead. +type CustomNameserverService struct { + Options []option.RequestOption +} + +// NewCustomNameserverService 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 NewCustomNameserverService(opts ...option.RequestOption) (r *CustomNameserverService) { + r = &CustomNameserverService{} + r.Options = opts + return +} + +// Set metadata for account-level custom nameservers on a zone. +// +// If you would like new zones in the account to use account custom nameservers by +// default, use PUT /accounts/:identifier to set the account setting +// use_account_custom_ns_by_default to true. +func (r *CustomNameserverService) Update(ctx context.Context, params CustomNameserverUpdateParams, opts ...option.RequestOption) (res *CustomNameserverUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env CustomNameserverUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/custom_ns", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Get metadata for account-level custom nameservers on a zone. +func (r *CustomNameserverService) Get(ctx context.Context, query CustomNameserverGetParams, opts ...option.RequestOption) (res *CustomNameserverGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env CustomNameserverGetResponseEnvelope + path := fmt.Sprintf("zones/%s/custom_ns", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [zones.CustomNameserverUpdateResponseUnknown], +// [zones.CustomNameserverUpdateResponseArray] or [shared.UnionString]. +type CustomNameserverUpdateResponse interface { + ImplementsZonesCustomNameserverUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*CustomNameserverUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CustomNameserverUpdateResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type CustomNameserverUpdateResponseArray []interface{} + +func (r CustomNameserverUpdateResponseArray) ImplementsZonesCustomNameserverUpdateResponse() {} + +// Union satisfied by [zones.CustomNameserverGetResponseUnknown], +// [zones.CustomNameserverGetResponseArray] or [shared.UnionString]. +type CustomNameserverGetResponse interface { + ImplementsZonesCustomNameserverGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*CustomNameserverGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(CustomNameserverGetResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type CustomNameserverGetResponseArray []interface{} + +func (r CustomNameserverGetResponseArray) ImplementsZonesCustomNameserverGetResponse() {} + +type CustomNameserverUpdateParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Whether zone uses account-level custom nameservers. + Enabled param.Field[bool] `json:"enabled"` + // The number of the name server set to assign to the zone. + NSSet param.Field[float64] `json:"ns_set"` +} + +func (r CustomNameserverUpdateParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type CustomNameserverUpdateResponseEnvelope struct { + Errors []CustomNameserverUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []CustomNameserverUpdateResponseEnvelopeMessages `json:"messages,required"` + Result CustomNameserverUpdateResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success CustomNameserverUpdateResponseEnvelopeSuccess `json:"success,required"` + ResultInfo CustomNameserverUpdateResponseEnvelopeResultInfo `json:"result_info"` + JSON customNameserverUpdateResponseEnvelopeJSON `json:"-"` +} + +// customNameserverUpdateResponseEnvelopeJSON contains the JSON metadata for the +// struct [CustomNameserverUpdateResponseEnvelope] +type customNameserverUpdateResponseEnvelopeJSON 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 *CustomNameserverUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CustomNameserverUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON customNameserverUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// customNameserverUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [CustomNameserverUpdateResponseEnvelopeErrors] +type customNameserverUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CustomNameserverUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON customNameserverUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// customNameserverUpdateResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [CustomNameserverUpdateResponseEnvelopeMessages] +type customNameserverUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CustomNameserverUpdateResponseEnvelopeSuccess bool + +const ( + CustomNameserverUpdateResponseEnvelopeSuccessTrue CustomNameserverUpdateResponseEnvelopeSuccess = true +) + +type CustomNameserverUpdateResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON customNameserverUpdateResponseEnvelopeResultInfoJSON `json:"-"` +} + +// customNameserverUpdateResponseEnvelopeResultInfoJSON contains the JSON metadata +// for the struct [CustomNameserverUpdateResponseEnvelopeResultInfo] +type customNameserverUpdateResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverUpdateResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverUpdateResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type CustomNameserverGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type CustomNameserverGetResponseEnvelope struct { + Errors []CustomNameserverGetResponseEnvelopeErrors `json:"errors,required"` + Messages []CustomNameserverGetResponseEnvelopeMessages `json:"messages,required"` + Result CustomNameserverGetResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success CustomNameserverGetResponseEnvelopeSuccess `json:"success,required"` + // Whether zone uses account-level custom nameservers. + Enabled bool `json:"enabled"` + // The number of the name server set to assign to the zone. + NSSet float64 `json:"ns_set"` + ResultInfo CustomNameserverGetResponseEnvelopeResultInfo `json:"result_info"` + JSON customNameserverGetResponseEnvelopeJSON `json:"-"` +} + +// customNameserverGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [CustomNameserverGetResponseEnvelope] +type customNameserverGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + Enabled apijson.Field + NSSet apijson.Field + ResultInfo apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type CustomNameserverGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON customNameserverGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// customNameserverGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [CustomNameserverGetResponseEnvelopeErrors] +type customNameserverGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type CustomNameserverGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON customNameserverGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// customNameserverGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [CustomNameserverGetResponseEnvelopeMessages] +type customNameserverGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type CustomNameserverGetResponseEnvelopeSuccess bool + +const ( + CustomNameserverGetResponseEnvelopeSuccessTrue CustomNameserverGetResponseEnvelopeSuccess = true +) + +type CustomNameserverGetResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON customNameserverGetResponseEnvelopeResultInfoJSON `json:"-"` +} + +// customNameserverGetResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [CustomNameserverGetResponseEnvelopeResultInfo] +type customNameserverGetResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomNameserverGetResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r customNameserverGetResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} diff --git a/zones/customnameserver_test.go b/zones/customnameserver_test.go new file mode 100644 index 00000000000..63b3a2bae30 --- /dev/null +++ b/zones/customnameserver_test.go @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestCustomNameserverUpdateWithOptionalParams(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("user@example.com"), + ) + _, err := client.Zones.CustomNameservers.Update(context.TODO(), zones.CustomNameserverUpdateParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Enabled: cloudflare.F(true), + NSSet: cloudflare.F(1.000000), + }) + 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 TestCustomNameserverGet(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("user@example.com"), + ) + _, err := client.Zones.CustomNameservers.Get(context.TODO(), zones.CustomNameserverGetParams{ + ZoneID: cloudflare.F("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/zones/hold.go b/zones/hold.go new file mode 100644 index 00000000000..2022d7c9a2d --- /dev/null +++ b/zones/hold.go @@ -0,0 +1,371 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "net/url" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/apiquery" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// HoldService 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 [NewHoldService] method instead. +type HoldService struct { + Options []option.RequestOption +} + +// NewHoldService 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 NewHoldService(opts ...option.RequestOption) (r *HoldService) { + r = &HoldService{} + r.Options = opts + return +} + +// Enforce a zone hold on the zone, blocking the creation and activation of zones +// with this zone's hostname. +func (r *HoldService) New(ctx context.Context, params HoldNewParams, opts ...option.RequestOption) (res *HoldNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env HoldNewResponseEnvelope + path := fmt.Sprintf("zones/%s/hold", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Stop enforcement of a zone hold on the zone, permanently or temporarily, +// allowing the creation and activation of zones with this zone's hostname. +func (r *HoldService) Delete(ctx context.Context, params HoldDeleteParams, opts ...option.RequestOption) (res *HoldDeleteResponse, err error) { + opts = append(r.Options[:], opts...) + var env HoldDeleteResponseEnvelope + path := fmt.Sprintf("zones/%s/hold", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Retrieve whether the zone is subject to a zone hold, and metadata about the +// hold. +func (r *HoldService) Get(ctx context.Context, query HoldGetParams, opts ...option.RequestOption) (res *HoldGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env HoldGetResponseEnvelope + path := fmt.Sprintf("zones/%s/hold", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type HoldNewResponse struct { + Hold bool `json:"hold"` + HoldAfter string `json:"hold_after"` + IncludeSubdomains string `json:"include_subdomains"` + JSON holdNewResponseJSON `json:"-"` +} + +// holdNewResponseJSON contains the JSON metadata for the struct [HoldNewResponse] +type holdNewResponseJSON struct { + Hold apijson.Field + HoldAfter apijson.Field + IncludeSubdomains apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HoldNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r holdNewResponseJSON) RawJSON() string { + return r.raw +} + +type HoldDeleteResponse struct { + Hold bool `json:"hold"` + HoldAfter string `json:"hold_after"` + IncludeSubdomains string `json:"include_subdomains"` + JSON holdDeleteResponseJSON `json:"-"` +} + +// holdDeleteResponseJSON contains the JSON metadata for the struct +// [HoldDeleteResponse] +type holdDeleteResponseJSON struct { + Hold apijson.Field + HoldAfter apijson.Field + IncludeSubdomains apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HoldDeleteResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r holdDeleteResponseJSON) RawJSON() string { + return r.raw +} + +type HoldGetResponse struct { + Hold bool `json:"hold"` + HoldAfter string `json:"hold_after"` + IncludeSubdomains string `json:"include_subdomains"` + JSON holdGetResponseJSON `json:"-"` +} + +// holdGetResponseJSON contains the JSON metadata for the struct [HoldGetResponse] +type holdGetResponseJSON struct { + Hold apijson.Field + HoldAfter apijson.Field + IncludeSubdomains apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HoldGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r holdGetResponseJSON) RawJSON() string { + return r.raw +} + +type HoldNewParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // If provided, the zone hold will extend to block any subdomain of the given zone, + // as well as SSL4SaaS Custom Hostnames. For example, a zone hold on a zone with + // the hostname 'example.com' and include_subdomains=true will block 'example.com', + // 'staging.example.com', 'api.staging.example.com', etc. + IncludeSubdomains param.Field[bool] `query:"include_subdomains"` +} + +// URLQuery serializes [HoldNewParams]'s query parameters as `url.Values`. +func (r HoldNewParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type HoldNewResponseEnvelope struct { + Errors []HoldNewResponseEnvelopeErrors `json:"errors,required"` + Messages []HoldNewResponseEnvelopeMessages `json:"messages,required"` + Result HoldNewResponse `json:"result,required"` + // Whether the API call was successful + Success HoldNewResponseEnvelopeSuccess `json:"success,required"` + JSON holdNewResponseEnvelopeJSON `json:"-"` +} + +// holdNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [HoldNewResponseEnvelope] +type holdNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HoldNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r holdNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HoldNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON holdNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// holdNewResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [HoldNewResponseEnvelopeErrors] +type holdNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HoldNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r holdNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HoldNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON holdNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// holdNewResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [HoldNewResponseEnvelopeMessages] +type holdNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HoldNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r holdNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HoldNewResponseEnvelopeSuccess bool + +const ( + HoldNewResponseEnvelopeSuccessTrue HoldNewResponseEnvelopeSuccess = true +) + +type HoldDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // If `hold_after` is provided, the hold will be temporarily disabled, then + // automatically re-enabled by the system at the time specified in this + // RFC3339-formatted timestamp. Otherwise, the hold will be disabled indefinitely. + HoldAfter param.Field[string] `query:"hold_after"` +} + +// URLQuery serializes [HoldDeleteParams]'s query parameters as `url.Values`. +func (r HoldDeleteParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatComma, + NestedFormat: apiquery.NestedQueryFormatBrackets, + }) +} + +type HoldDeleteResponseEnvelope struct { + Result HoldDeleteResponse `json:"result"` + JSON holdDeleteResponseEnvelopeJSON `json:"-"` +} + +// holdDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [HoldDeleteResponseEnvelope] +type holdDeleteResponseEnvelopeJSON struct { + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HoldDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r holdDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HoldGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type HoldGetResponseEnvelope struct { + Errors []HoldGetResponseEnvelopeErrors `json:"errors,required"` + Messages []HoldGetResponseEnvelopeMessages `json:"messages,required"` + Result HoldGetResponse `json:"result,required"` + // Whether the API call was successful + Success HoldGetResponseEnvelopeSuccess `json:"success,required"` + JSON holdGetResponseEnvelopeJSON `json:"-"` +} + +// holdGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [HoldGetResponseEnvelope] +type holdGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HoldGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r holdGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type HoldGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON holdGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// holdGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [HoldGetResponseEnvelopeErrors] +type holdGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HoldGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r holdGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type HoldGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON holdGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// holdGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [HoldGetResponseEnvelopeMessages] +type holdGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *HoldGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r holdGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type HoldGetResponseEnvelopeSuccess bool + +const ( + HoldGetResponseEnvelopeSuccessTrue HoldGetResponseEnvelopeSuccess = true +) diff --git a/zones/hold_test.go b/zones/hold_test.go new file mode 100644 index 00000000000..a8f77aab504 --- /dev/null +++ b/zones/hold_test.go @@ -0,0 +1,95 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestHoldNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Zones.Holds.New(context.TODO(), zones.HoldNewParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + IncludeSubdomains: cloudflare.F(true), + }) + 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 TestHoldDeleteWithOptionalParams(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("user@example.com"), + ) + _, err := client.Zones.Holds.Delete(context.TODO(), zones.HoldDeleteParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + HoldAfter: cloudflare.F("string"), + }) + 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 TestHoldGet(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("user@example.com"), + ) + _, err := client.Zones.Holds.Get(context.TODO(), zones.HoldGetParams{ + ZoneID: cloudflare.F("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/zones/setting.go b/zones/setting.go new file mode 100644 index 00000000000..bab73c247da --- /dev/null +++ b/zones/setting.go @@ -0,0 +1,1855 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// SettingService 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 [NewSettingService] method instead. +type SettingService struct { + Options []option.RequestOption + ZeroRTT *SettingZeroRTTService + AdvancedDDOS *SettingAdvancedDDOSService + AlwaysOnline *SettingAlwaysOnlineService + AlwaysUseHTTPS *SettingAlwaysUseHTTPSService + AutomaticHTTPSRewrites *SettingAutomaticHTTPSRewriteService + AutomaticPlatformOptimization *SettingAutomaticPlatformOptimizationService + Brotli *SettingBrotliService + BrowserCacheTTL *SettingBrowserCacheTTLService + BrowserCheck *SettingBrowserCheckService + CacheLevel *SettingCacheLevelService + ChallengeTTL *SettingChallengeTTLService + Ciphers *SettingCipherService + DevelopmentMode *SettingDevelopmentModeService + EarlyHints *SettingEarlyHintService + EmailObfuscation *SettingEmailObfuscationService + H2Prioritization *SettingH2PrioritizationService + HotlinkProtection *SettingHotlinkProtectionService + HTTP2 *SettingHTTP2Service + HTTP3 *SettingHTTP3Service + ImageResizing *SettingImageResizingService + IPGeolocation *SettingIPGeolocationService + IPV6 *SettingIPV6Service + MinTLSVersion *SettingMinTLSVersionService + Minify *SettingMinifyService + Mirage *SettingMirageService + MobileRedirect *SettingMobileRedirectService + NEL *SettingNELService + OpportunisticEncryption *SettingOpportunisticEncryptionService + OpportunisticOnion *SettingOpportunisticOnionService + OrangeToOrange *SettingOrangeToOrangeService + OriginErrorPagePassThru *SettingOriginErrorPagePassThruService + OriginMaxHTTPVersion *SettingOriginMaxHTTPVersionService + Polish *SettingPolishService + PrefetchPreload *SettingPrefetchPreloadService + ProxyReadTimeout *SettingProxyReadTimeoutService + PseudoIPV4 *SettingPseudoIPV4Service + ResponseBuffering *SettingResponseBufferingService + RocketLoader *SettingRocketLoaderService + SecurityHeaders *SettingSecurityHeaderService + SecurityLevel *SettingSecurityLevelService + ServerSideExcludes *SettingServerSideExcludeService + SortQueryStringForCache *SettingSortQueryStringForCacheService + SSL *SettingSSLService + SSLRecommender *SettingSSLRecommenderService + TLS1_3 *SettingTLS1_3Service + TLSClientAuth *SettingTLSClientAuthService + TrueClientIPHeader *SettingTrueClientIPHeaderService + WAF *SettingWAFService + Webp *SettingWebpService + Websocket *SettingWebsocketService + FontSettings *SettingFontSettingService +} + +// NewSettingService 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 NewSettingService(opts ...option.RequestOption) (r *SettingService) { + r = &SettingService{} + r.Options = opts + r.ZeroRTT = NewSettingZeroRTTService(opts...) + r.AdvancedDDOS = NewSettingAdvancedDDOSService(opts...) + r.AlwaysOnline = NewSettingAlwaysOnlineService(opts...) + r.AlwaysUseHTTPS = NewSettingAlwaysUseHTTPSService(opts...) + r.AutomaticHTTPSRewrites = NewSettingAutomaticHTTPSRewriteService(opts...) + r.AutomaticPlatformOptimization = NewSettingAutomaticPlatformOptimizationService(opts...) + r.Brotli = NewSettingBrotliService(opts...) + r.BrowserCacheTTL = NewSettingBrowserCacheTTLService(opts...) + r.BrowserCheck = NewSettingBrowserCheckService(opts...) + r.CacheLevel = NewSettingCacheLevelService(opts...) + r.ChallengeTTL = NewSettingChallengeTTLService(opts...) + r.Ciphers = NewSettingCipherService(opts...) + r.DevelopmentMode = NewSettingDevelopmentModeService(opts...) + r.EarlyHints = NewSettingEarlyHintService(opts...) + r.EmailObfuscation = NewSettingEmailObfuscationService(opts...) + r.H2Prioritization = NewSettingH2PrioritizationService(opts...) + r.HotlinkProtection = NewSettingHotlinkProtectionService(opts...) + r.HTTP2 = NewSettingHTTP2Service(opts...) + r.HTTP3 = NewSettingHTTP3Service(opts...) + r.ImageResizing = NewSettingImageResizingService(opts...) + r.IPGeolocation = NewSettingIPGeolocationService(opts...) + r.IPV6 = NewSettingIPV6Service(opts...) + r.MinTLSVersion = NewSettingMinTLSVersionService(opts...) + r.Minify = NewSettingMinifyService(opts...) + r.Mirage = NewSettingMirageService(opts...) + r.MobileRedirect = NewSettingMobileRedirectService(opts...) + r.NEL = NewSettingNELService(opts...) + r.OpportunisticEncryption = NewSettingOpportunisticEncryptionService(opts...) + r.OpportunisticOnion = NewSettingOpportunisticOnionService(opts...) + r.OrangeToOrange = NewSettingOrangeToOrangeService(opts...) + r.OriginErrorPagePassThru = NewSettingOriginErrorPagePassThruService(opts...) + r.OriginMaxHTTPVersion = NewSettingOriginMaxHTTPVersionService(opts...) + r.Polish = NewSettingPolishService(opts...) + r.PrefetchPreload = NewSettingPrefetchPreloadService(opts...) + r.ProxyReadTimeout = NewSettingProxyReadTimeoutService(opts...) + r.PseudoIPV4 = NewSettingPseudoIPV4Service(opts...) + r.ResponseBuffering = NewSettingResponseBufferingService(opts...) + r.RocketLoader = NewSettingRocketLoaderService(opts...) + r.SecurityHeaders = NewSettingSecurityHeaderService(opts...) + r.SecurityLevel = NewSettingSecurityLevelService(opts...) + r.ServerSideExcludes = NewSettingServerSideExcludeService(opts...) + r.SortQueryStringForCache = NewSettingSortQueryStringForCacheService(opts...) + r.SSL = NewSettingSSLService(opts...) + r.SSLRecommender = NewSettingSSLRecommenderService(opts...) + r.TLS1_3 = NewSettingTLS1_3Service(opts...) + r.TLSClientAuth = NewSettingTLSClientAuthService(opts...) + r.TrueClientIPHeader = NewSettingTrueClientIPHeaderService(opts...) + r.WAF = NewSettingWAFService(opts...) + r.Webp = NewSettingWebpService(opts...) + r.Websocket = NewSettingWebsocketService(opts...) + r.FontSettings = NewSettingFontSettingService(opts...) + return +} + +// Edit settings for a zone. +func (r *SettingService) Edit(ctx context.Context, params SettingEditParams, opts ...option.RequestOption) (res *[]SettingEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env SettingEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Available settings for your user in relation to a zone. +func (r *SettingService) Get(ctx context.Context, query SettingGetParams, opts ...option.RequestOption) (res *[]SettingGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env SettingGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// 0-RTT session resumption enabled for this zone. +// +// Union satisfied by [zones.Zones0rtt], [zones.ZonesAdvancedDDOS], +// [zones.ZonesAlwaysOnline], [zones.ZonesAlwaysUseHTTPS], +// [zones.ZonesAutomaticHTTPSRewrites], [zones.ZonesBrotli], +// [zones.ZonesBrowserCacheTTL], [zones.ZonesBrowserCheck], +// [zones.ZonesCacheLevel], [zones.ZonesChallengeTTL], [zones.ZonesCiphers], +// [zones.SettingEditResponseZonesCNAMEFlattening], [zones.ZonesDevelopmentMode], +// [zones.ZonesEarlyHints], [zones.SettingEditResponseZonesEdgeCacheTTL], +// [zones.ZonesEmailObfuscation], [zones.ZonesH2Prioritization], +// [zones.ZonesHotlinkProtection], [zones.ZonesHTTP2], [zones.ZonesHTTP3], +// [zones.ZonesImageResizing], [zones.ZonesIPGeolocation], [zones.ZonesIPV6], +// [zones.SettingEditResponseZonesMaxUpload], [zones.ZonesMinTLSVersion], +// [zones.ZonesMinify], [zones.ZonesMirage], [zones.ZonesMobileRedirect], +// [zones.ZonesNEL], [zones.ZonesOpportunisticEncryption], +// [zones.ZonesOpportunisticOnion], [zones.ZonesOrangeToOrange], +// [zones.ZonesOriginErrorPagePassThru], [zones.ZonesPolish], +// [zones.ZonesPrefetchPreload], [zones.ZonesProxyReadTimeout], +// [zones.ZonesPseudoIPV4], [zones.ZonesBuffering], [zones.ZonesRocketLoader], +// [zones.SettingEditResponseZonesSchemasAutomaticPlatformOptimization], +// [zones.ZonesSecurityHeader], [zones.ZonesSecurityLevel], +// [zones.ZonesServerSideExclude], [zones.SettingEditResponseZonesSha1Support], +// [zones.ZonesSortQueryStringForCache], [zones.ZonesSSL], +// [zones.ZonesSSLRecommender], [zones.SettingEditResponseZonesTLS1_2Only], +// [zones.ZonesTLS1_3], [zones.ZonesTLSClientAuth], +// [zones.ZonesTrueClientIPHeader], [zones.ZonesWAF], [zones.ZonesWebp] or +// [zones.ZonesWebsockets]. +type SettingEditResponse interface { + implementsZonesSettingEditResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*SettingEditResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(Zones0rtt{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesAdvancedDDOS{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesAlwaysOnline{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesAlwaysUseHTTPS{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesAutomaticHTTPSRewrites{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesBrotli{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesBrowserCacheTTL{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesBrowserCheck{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesCacheLevel{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesChallengeTTL{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesCiphers{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SettingEditResponseZonesCNAMEFlattening{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesDevelopmentMode{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesEarlyHints{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SettingEditResponseZonesEdgeCacheTTL{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesEmailObfuscation{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesH2Prioritization{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesHotlinkProtection{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesHTTP2{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesHTTP3{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesImageResizing{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesIPGeolocation{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesIPV6{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SettingEditResponseZonesMaxUpload{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesMinTLSVersion{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesMinify{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesMirage{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesMobileRedirect{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesNEL{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesOpportunisticEncryption{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesOpportunisticOnion{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesOrangeToOrange{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesOriginErrorPagePassThru{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesPolish{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesPrefetchPreload{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesProxyReadTimeout{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesPseudoIPV4{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesBuffering{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesRocketLoader{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SettingEditResponseZonesSchemasAutomaticPlatformOptimization{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesSecurityHeader{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesSecurityLevel{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesServerSideExclude{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SettingEditResponseZonesSha1Support{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesSortQueryStringForCache{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesSSL{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesSSLRecommender{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SettingEditResponseZonesTLS1_2Only{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesTLS1_3{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesTLSClientAuth{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesTrueClientIPHeader{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesWAF{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesWebp{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesWebsockets{}), + }, + ) +} + +// Whether or not cname flattening is on. +type SettingEditResponseZonesCNAMEFlattening struct { + // How to flatten the cname destination. + ID SettingEditResponseZonesCNAMEFlatteningID `json:"id,required"` + // Current value of the zone setting. + Value SettingEditResponseZonesCNAMEFlatteningValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable SettingEditResponseZonesCNAMEFlatteningEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON settingEditResponseZonesCNAMEFlatteningJSON `json:"-"` +} + +// settingEditResponseZonesCNAMEFlatteningJSON contains the JSON metadata for the +// struct [SettingEditResponseZonesCNAMEFlattening] +type settingEditResponseZonesCNAMEFlatteningJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEditResponseZonesCNAMEFlattening) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEditResponseZonesCNAMEFlatteningJSON) RawJSON() string { + return r.raw +} + +func (r SettingEditResponseZonesCNAMEFlattening) implementsZonesSettingEditResponse() {} + +// How to flatten the cname destination. +type SettingEditResponseZonesCNAMEFlatteningID string + +const ( + SettingEditResponseZonesCNAMEFlatteningIDCNAMEFlattening SettingEditResponseZonesCNAMEFlatteningID = "cname_flattening" +) + +// Current value of the zone setting. +type SettingEditResponseZonesCNAMEFlatteningValue string + +const ( + SettingEditResponseZonesCNAMEFlatteningValueFlattenAtRoot SettingEditResponseZonesCNAMEFlatteningValue = "flatten_at_root" + SettingEditResponseZonesCNAMEFlatteningValueFlattenAll SettingEditResponseZonesCNAMEFlatteningValue = "flatten_all" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SettingEditResponseZonesCNAMEFlatteningEditable bool + +const ( + SettingEditResponseZonesCNAMEFlatteningEditableTrue SettingEditResponseZonesCNAMEFlatteningEditable = true + SettingEditResponseZonesCNAMEFlatteningEditableFalse SettingEditResponseZonesCNAMEFlatteningEditable = false +) + +// Time (in seconds) that a resource will be ensured to remain on Cloudflare's +// cache servers. +type SettingEditResponseZonesEdgeCacheTTL struct { + // ID of the zone setting. + ID SettingEditResponseZonesEdgeCacheTTLID `json:"id,required"` + // Current value of the zone setting. + Value SettingEditResponseZonesEdgeCacheTTLValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable SettingEditResponseZonesEdgeCacheTTLEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON settingEditResponseZonesEdgeCacheTTLJSON `json:"-"` +} + +// settingEditResponseZonesEdgeCacheTTLJSON contains the JSON metadata for the +// struct [SettingEditResponseZonesEdgeCacheTTL] +type settingEditResponseZonesEdgeCacheTTLJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEditResponseZonesEdgeCacheTTL) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEditResponseZonesEdgeCacheTTLJSON) RawJSON() string { + return r.raw +} + +func (r SettingEditResponseZonesEdgeCacheTTL) implementsZonesSettingEditResponse() {} + +// ID of the zone setting. +type SettingEditResponseZonesEdgeCacheTTLID string + +const ( + SettingEditResponseZonesEdgeCacheTTLIDEdgeCacheTTL SettingEditResponseZonesEdgeCacheTTLID = "edge_cache_ttl" +) + +// Current value of the zone setting. +type SettingEditResponseZonesEdgeCacheTTLValue float64 + +const ( + SettingEditResponseZonesEdgeCacheTTLValue30 SettingEditResponseZonesEdgeCacheTTLValue = 30 + SettingEditResponseZonesEdgeCacheTTLValue60 SettingEditResponseZonesEdgeCacheTTLValue = 60 + SettingEditResponseZonesEdgeCacheTTLValue300 SettingEditResponseZonesEdgeCacheTTLValue = 300 + SettingEditResponseZonesEdgeCacheTTLValue1200 SettingEditResponseZonesEdgeCacheTTLValue = 1200 + SettingEditResponseZonesEdgeCacheTTLValue1800 SettingEditResponseZonesEdgeCacheTTLValue = 1800 + SettingEditResponseZonesEdgeCacheTTLValue3600 SettingEditResponseZonesEdgeCacheTTLValue = 3600 + SettingEditResponseZonesEdgeCacheTTLValue7200 SettingEditResponseZonesEdgeCacheTTLValue = 7200 + SettingEditResponseZonesEdgeCacheTTLValue10800 SettingEditResponseZonesEdgeCacheTTLValue = 10800 + SettingEditResponseZonesEdgeCacheTTLValue14400 SettingEditResponseZonesEdgeCacheTTLValue = 14400 + SettingEditResponseZonesEdgeCacheTTLValue18000 SettingEditResponseZonesEdgeCacheTTLValue = 18000 + SettingEditResponseZonesEdgeCacheTTLValue28800 SettingEditResponseZonesEdgeCacheTTLValue = 28800 + SettingEditResponseZonesEdgeCacheTTLValue43200 SettingEditResponseZonesEdgeCacheTTLValue = 43200 + SettingEditResponseZonesEdgeCacheTTLValue57600 SettingEditResponseZonesEdgeCacheTTLValue = 57600 + SettingEditResponseZonesEdgeCacheTTLValue72000 SettingEditResponseZonesEdgeCacheTTLValue = 72000 + SettingEditResponseZonesEdgeCacheTTLValue86400 SettingEditResponseZonesEdgeCacheTTLValue = 86400 + SettingEditResponseZonesEdgeCacheTTLValue172800 SettingEditResponseZonesEdgeCacheTTLValue = 172800 + SettingEditResponseZonesEdgeCacheTTLValue259200 SettingEditResponseZonesEdgeCacheTTLValue = 259200 + SettingEditResponseZonesEdgeCacheTTLValue345600 SettingEditResponseZonesEdgeCacheTTLValue = 345600 + SettingEditResponseZonesEdgeCacheTTLValue432000 SettingEditResponseZonesEdgeCacheTTLValue = 432000 + SettingEditResponseZonesEdgeCacheTTLValue518400 SettingEditResponseZonesEdgeCacheTTLValue = 518400 + SettingEditResponseZonesEdgeCacheTTLValue604800 SettingEditResponseZonesEdgeCacheTTLValue = 604800 +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SettingEditResponseZonesEdgeCacheTTLEditable bool + +const ( + SettingEditResponseZonesEdgeCacheTTLEditableTrue SettingEditResponseZonesEdgeCacheTTLEditable = true + SettingEditResponseZonesEdgeCacheTTLEditableFalse SettingEditResponseZonesEdgeCacheTTLEditable = false +) + +// Maximum size of an allowable upload. +type SettingEditResponseZonesMaxUpload struct { + // identifier of the zone setting. + ID SettingEditResponseZonesMaxUploadID `json:"id,required"` + // Current value of the zone setting. + Value SettingEditResponseZonesMaxUploadValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable SettingEditResponseZonesMaxUploadEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON settingEditResponseZonesMaxUploadJSON `json:"-"` +} + +// settingEditResponseZonesMaxUploadJSON contains the JSON metadata for the struct +// [SettingEditResponseZonesMaxUpload] +type settingEditResponseZonesMaxUploadJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEditResponseZonesMaxUpload) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEditResponseZonesMaxUploadJSON) RawJSON() string { + return r.raw +} + +func (r SettingEditResponseZonesMaxUpload) implementsZonesSettingEditResponse() {} + +// identifier of the zone setting. +type SettingEditResponseZonesMaxUploadID string + +const ( + SettingEditResponseZonesMaxUploadIDMaxUpload SettingEditResponseZonesMaxUploadID = "max_upload" +) + +// Current value of the zone setting. +type SettingEditResponseZonesMaxUploadValue float64 + +const ( + SettingEditResponseZonesMaxUploadValue100 SettingEditResponseZonesMaxUploadValue = 100 + SettingEditResponseZonesMaxUploadValue200 SettingEditResponseZonesMaxUploadValue = 200 + SettingEditResponseZonesMaxUploadValue500 SettingEditResponseZonesMaxUploadValue = 500 +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SettingEditResponseZonesMaxUploadEditable bool + +const ( + SettingEditResponseZonesMaxUploadEditableTrue SettingEditResponseZonesMaxUploadEditable = true + SettingEditResponseZonesMaxUploadEditableFalse SettingEditResponseZonesMaxUploadEditable = false +) + +// [Automatic Platform Optimization for WordPress](https://developers.cloudflare.com/automatic-platform-optimization/) +// serves your WordPress site from Cloudflare's edge network and caches third-party +// fonts. +type SettingEditResponseZonesSchemasAutomaticPlatformOptimization struct { + // ID of the zone setting. + ID SettingEditResponseZonesSchemasAutomaticPlatformOptimizationID `json:"id,required"` + // Current value of the zone setting. + Value ZonesAutomaticPlatformOptimization `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable SettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON settingEditResponseZonesSchemasAutomaticPlatformOptimizationJSON `json:"-"` +} + +// settingEditResponseZonesSchemasAutomaticPlatformOptimizationJSON contains the +// JSON metadata for the struct +// [SettingEditResponseZonesSchemasAutomaticPlatformOptimization] +type settingEditResponseZonesSchemasAutomaticPlatformOptimizationJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEditResponseZonesSchemasAutomaticPlatformOptimization) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEditResponseZonesSchemasAutomaticPlatformOptimizationJSON) RawJSON() string { + return r.raw +} + +func (r SettingEditResponseZonesSchemasAutomaticPlatformOptimization) implementsZonesSettingEditResponse() { +} + +// ID of the zone setting. +type SettingEditResponseZonesSchemasAutomaticPlatformOptimizationID string + +const ( + SettingEditResponseZonesSchemasAutomaticPlatformOptimizationIDAutomaticPlatformOptimization SettingEditResponseZonesSchemasAutomaticPlatformOptimizationID = "automatic_platform_optimization" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditable bool + +const ( + SettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditableTrue SettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditable = true + SettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditableFalse SettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditable = false +) + +// Allow SHA1 support. +type SettingEditResponseZonesSha1Support struct { + // Zone setting identifier. + ID SettingEditResponseZonesSha1SupportID `json:"id,required"` + // Current value of the zone setting. + Value SettingEditResponseZonesSha1SupportValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable SettingEditResponseZonesSha1SupportEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON settingEditResponseZonesSha1SupportJSON `json:"-"` +} + +// settingEditResponseZonesSha1SupportJSON contains the JSON metadata for the +// struct [SettingEditResponseZonesSha1Support] +type settingEditResponseZonesSha1SupportJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEditResponseZonesSha1Support) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEditResponseZonesSha1SupportJSON) RawJSON() string { + return r.raw +} + +func (r SettingEditResponseZonesSha1Support) implementsZonesSettingEditResponse() {} + +// Zone setting identifier. +type SettingEditResponseZonesSha1SupportID string + +const ( + SettingEditResponseZonesSha1SupportIDSha1Support SettingEditResponseZonesSha1SupportID = "sha1_support" +) + +// Current value of the zone setting. +type SettingEditResponseZonesSha1SupportValue string + +const ( + SettingEditResponseZonesSha1SupportValueOff SettingEditResponseZonesSha1SupportValue = "off" + SettingEditResponseZonesSha1SupportValueOn SettingEditResponseZonesSha1SupportValue = "on" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SettingEditResponseZonesSha1SupportEditable bool + +const ( + SettingEditResponseZonesSha1SupportEditableTrue SettingEditResponseZonesSha1SupportEditable = true + SettingEditResponseZonesSha1SupportEditableFalse SettingEditResponseZonesSha1SupportEditable = false +) + +// Only allows TLS1.2. +type SettingEditResponseZonesTLS1_2Only struct { + // Zone setting identifier. + ID SettingEditResponseZonesTLS1_2OnlyID `json:"id,required"` + // Current value of the zone setting. + Value SettingEditResponseZonesTLS1_2OnlyValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable SettingEditResponseZonesTLS1_2OnlyEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON settingEditResponseZonesTls1_2OnlyJSON `json:"-"` +} + +// settingEditResponseZonesTls1_2OnlyJSON contains the JSON metadata for the struct +// [SettingEditResponseZonesTLS1_2Only] +type settingEditResponseZonesTls1_2OnlyJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEditResponseZonesTLS1_2Only) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEditResponseZonesTls1_2OnlyJSON) RawJSON() string { + return r.raw +} + +func (r SettingEditResponseZonesTLS1_2Only) implementsZonesSettingEditResponse() {} + +// Zone setting identifier. +type SettingEditResponseZonesTLS1_2OnlyID string + +const ( + SettingEditResponseZonesTLS1_2OnlyIDTLS1_2Only SettingEditResponseZonesTLS1_2OnlyID = "tls_1_2_only" +) + +// Current value of the zone setting. +type SettingEditResponseZonesTLS1_2OnlyValue string + +const ( + SettingEditResponseZonesTLS1_2OnlyValueOff SettingEditResponseZonesTLS1_2OnlyValue = "off" + SettingEditResponseZonesTLS1_2OnlyValueOn SettingEditResponseZonesTLS1_2OnlyValue = "on" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SettingEditResponseZonesTLS1_2OnlyEditable bool + +const ( + SettingEditResponseZonesTLS1_2OnlyEditableTrue SettingEditResponseZonesTLS1_2OnlyEditable = true + SettingEditResponseZonesTLS1_2OnlyEditableFalse SettingEditResponseZonesTLS1_2OnlyEditable = false +) + +// 0-RTT session resumption enabled for this zone. +// +// Union satisfied by [zones.Zones0rtt], [zones.ZonesAdvancedDDOS], +// [zones.ZonesAlwaysOnline], [zones.ZonesAlwaysUseHTTPS], +// [zones.ZonesAutomaticHTTPSRewrites], [zones.ZonesBrotli], +// [zones.ZonesBrowserCacheTTL], [zones.ZonesBrowserCheck], +// [zones.ZonesCacheLevel], [zones.ZonesChallengeTTL], [zones.ZonesCiphers], +// [zones.SettingGetResponseZonesCNAMEFlattening], [zones.ZonesDevelopmentMode], +// [zones.ZonesEarlyHints], [zones.SettingGetResponseZonesEdgeCacheTTL], +// [zones.ZonesEmailObfuscation], [zones.ZonesH2Prioritization], +// [zones.ZonesHotlinkProtection], [zones.ZonesHTTP2], [zones.ZonesHTTP3], +// [zones.ZonesImageResizing], [zones.ZonesIPGeolocation], [zones.ZonesIPV6], +// [zones.SettingGetResponseZonesMaxUpload], [zones.ZonesMinTLSVersion], +// [zones.ZonesMinify], [zones.ZonesMirage], [zones.ZonesMobileRedirect], +// [zones.ZonesNEL], [zones.ZonesOpportunisticEncryption], +// [zones.ZonesOpportunisticOnion], [zones.ZonesOrangeToOrange], +// [zones.ZonesOriginErrorPagePassThru], [zones.ZonesPolish], +// [zones.ZonesPrefetchPreload], [zones.ZonesProxyReadTimeout], +// [zones.ZonesPseudoIPV4], [zones.ZonesBuffering], [zones.ZonesRocketLoader], +// [zones.SettingGetResponseZonesSchemasAutomaticPlatformOptimization], +// [zones.ZonesSecurityHeader], [zones.ZonesSecurityLevel], +// [zones.ZonesServerSideExclude], [zones.SettingGetResponseZonesSha1Support], +// [zones.ZonesSortQueryStringForCache], [zones.ZonesSSL], +// [zones.ZonesSSLRecommender], [zones.SettingGetResponseZonesTLS1_2Only], +// [zones.ZonesTLS1_3], [zones.ZonesTLSClientAuth], +// [zones.ZonesTrueClientIPHeader], [zones.ZonesWAF], [zones.ZonesWebp] or +// [zones.ZonesWebsockets]. +type SettingGetResponse interface { + implementsZonesSettingGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*SettingGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(Zones0rtt{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesAdvancedDDOS{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesAlwaysOnline{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesAlwaysUseHTTPS{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesAutomaticHTTPSRewrites{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesBrotli{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesBrowserCacheTTL{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesBrowserCheck{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesCacheLevel{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesChallengeTTL{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesCiphers{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SettingGetResponseZonesCNAMEFlattening{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesDevelopmentMode{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesEarlyHints{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SettingGetResponseZonesEdgeCacheTTL{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesEmailObfuscation{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesH2Prioritization{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesHotlinkProtection{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesHTTP2{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesHTTP3{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesImageResizing{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesIPGeolocation{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesIPV6{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SettingGetResponseZonesMaxUpload{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesMinTLSVersion{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesMinify{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesMirage{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesMobileRedirect{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesNEL{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesOpportunisticEncryption{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesOpportunisticOnion{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesOrangeToOrange{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesOriginErrorPagePassThru{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesPolish{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesPrefetchPreload{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesProxyReadTimeout{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesPseudoIPV4{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesBuffering{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesRocketLoader{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SettingGetResponseZonesSchemasAutomaticPlatformOptimization{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesSecurityHeader{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesSecurityLevel{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesServerSideExclude{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SettingGetResponseZonesSha1Support{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesSortQueryStringForCache{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesSSL{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesSSLRecommender{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SettingGetResponseZonesTLS1_2Only{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesTLS1_3{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesTLSClientAuth{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesTrueClientIPHeader{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesWAF{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesWebp{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(ZonesWebsockets{}), + }, + ) +} + +// Whether or not cname flattening is on. +type SettingGetResponseZonesCNAMEFlattening struct { + // How to flatten the cname destination. + ID SettingGetResponseZonesCNAMEFlatteningID `json:"id,required"` + // Current value of the zone setting. + Value SettingGetResponseZonesCNAMEFlatteningValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable SettingGetResponseZonesCNAMEFlatteningEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON settingGetResponseZonesCNAMEFlatteningJSON `json:"-"` +} + +// settingGetResponseZonesCNAMEFlatteningJSON contains the JSON metadata for the +// struct [SettingGetResponseZonesCNAMEFlattening] +type settingGetResponseZonesCNAMEFlatteningJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingGetResponseZonesCNAMEFlattening) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingGetResponseZonesCNAMEFlatteningJSON) RawJSON() string { + return r.raw +} + +func (r SettingGetResponseZonesCNAMEFlattening) implementsZonesSettingGetResponse() {} + +// How to flatten the cname destination. +type SettingGetResponseZonesCNAMEFlatteningID string + +const ( + SettingGetResponseZonesCNAMEFlatteningIDCNAMEFlattening SettingGetResponseZonesCNAMEFlatteningID = "cname_flattening" +) + +// Current value of the zone setting. +type SettingGetResponseZonesCNAMEFlatteningValue string + +const ( + SettingGetResponseZonesCNAMEFlatteningValueFlattenAtRoot SettingGetResponseZonesCNAMEFlatteningValue = "flatten_at_root" + SettingGetResponseZonesCNAMEFlatteningValueFlattenAll SettingGetResponseZonesCNAMEFlatteningValue = "flatten_all" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SettingGetResponseZonesCNAMEFlatteningEditable bool + +const ( + SettingGetResponseZonesCNAMEFlatteningEditableTrue SettingGetResponseZonesCNAMEFlatteningEditable = true + SettingGetResponseZonesCNAMEFlatteningEditableFalse SettingGetResponseZonesCNAMEFlatteningEditable = false +) + +// Time (in seconds) that a resource will be ensured to remain on Cloudflare's +// cache servers. +type SettingGetResponseZonesEdgeCacheTTL struct { + // ID of the zone setting. + ID SettingGetResponseZonesEdgeCacheTTLID `json:"id,required"` + // Current value of the zone setting. + Value SettingGetResponseZonesEdgeCacheTTLValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable SettingGetResponseZonesEdgeCacheTTLEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON settingGetResponseZonesEdgeCacheTTLJSON `json:"-"` +} + +// settingGetResponseZonesEdgeCacheTTLJSON contains the JSON metadata for the +// struct [SettingGetResponseZonesEdgeCacheTTL] +type settingGetResponseZonesEdgeCacheTTLJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingGetResponseZonesEdgeCacheTTL) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingGetResponseZonesEdgeCacheTTLJSON) RawJSON() string { + return r.raw +} + +func (r SettingGetResponseZonesEdgeCacheTTL) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type SettingGetResponseZonesEdgeCacheTTLID string + +const ( + SettingGetResponseZonesEdgeCacheTTLIDEdgeCacheTTL SettingGetResponseZonesEdgeCacheTTLID = "edge_cache_ttl" +) + +// Current value of the zone setting. +type SettingGetResponseZonesEdgeCacheTTLValue float64 + +const ( + SettingGetResponseZonesEdgeCacheTTLValue30 SettingGetResponseZonesEdgeCacheTTLValue = 30 + SettingGetResponseZonesEdgeCacheTTLValue60 SettingGetResponseZonesEdgeCacheTTLValue = 60 + SettingGetResponseZonesEdgeCacheTTLValue300 SettingGetResponseZonesEdgeCacheTTLValue = 300 + SettingGetResponseZonesEdgeCacheTTLValue1200 SettingGetResponseZonesEdgeCacheTTLValue = 1200 + SettingGetResponseZonesEdgeCacheTTLValue1800 SettingGetResponseZonesEdgeCacheTTLValue = 1800 + SettingGetResponseZonesEdgeCacheTTLValue3600 SettingGetResponseZonesEdgeCacheTTLValue = 3600 + SettingGetResponseZonesEdgeCacheTTLValue7200 SettingGetResponseZonesEdgeCacheTTLValue = 7200 + SettingGetResponseZonesEdgeCacheTTLValue10800 SettingGetResponseZonesEdgeCacheTTLValue = 10800 + SettingGetResponseZonesEdgeCacheTTLValue14400 SettingGetResponseZonesEdgeCacheTTLValue = 14400 + SettingGetResponseZonesEdgeCacheTTLValue18000 SettingGetResponseZonesEdgeCacheTTLValue = 18000 + SettingGetResponseZonesEdgeCacheTTLValue28800 SettingGetResponseZonesEdgeCacheTTLValue = 28800 + SettingGetResponseZonesEdgeCacheTTLValue43200 SettingGetResponseZonesEdgeCacheTTLValue = 43200 + SettingGetResponseZonesEdgeCacheTTLValue57600 SettingGetResponseZonesEdgeCacheTTLValue = 57600 + SettingGetResponseZonesEdgeCacheTTLValue72000 SettingGetResponseZonesEdgeCacheTTLValue = 72000 + SettingGetResponseZonesEdgeCacheTTLValue86400 SettingGetResponseZonesEdgeCacheTTLValue = 86400 + SettingGetResponseZonesEdgeCacheTTLValue172800 SettingGetResponseZonesEdgeCacheTTLValue = 172800 + SettingGetResponseZonesEdgeCacheTTLValue259200 SettingGetResponseZonesEdgeCacheTTLValue = 259200 + SettingGetResponseZonesEdgeCacheTTLValue345600 SettingGetResponseZonesEdgeCacheTTLValue = 345600 + SettingGetResponseZonesEdgeCacheTTLValue432000 SettingGetResponseZonesEdgeCacheTTLValue = 432000 + SettingGetResponseZonesEdgeCacheTTLValue518400 SettingGetResponseZonesEdgeCacheTTLValue = 518400 + SettingGetResponseZonesEdgeCacheTTLValue604800 SettingGetResponseZonesEdgeCacheTTLValue = 604800 +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SettingGetResponseZonesEdgeCacheTTLEditable bool + +const ( + SettingGetResponseZonesEdgeCacheTTLEditableTrue SettingGetResponseZonesEdgeCacheTTLEditable = true + SettingGetResponseZonesEdgeCacheTTLEditableFalse SettingGetResponseZonesEdgeCacheTTLEditable = false +) + +// Maximum size of an allowable upload. +type SettingGetResponseZonesMaxUpload struct { + // identifier of the zone setting. + ID SettingGetResponseZonesMaxUploadID `json:"id,required"` + // Current value of the zone setting. + Value SettingGetResponseZonesMaxUploadValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable SettingGetResponseZonesMaxUploadEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON settingGetResponseZonesMaxUploadJSON `json:"-"` +} + +// settingGetResponseZonesMaxUploadJSON contains the JSON metadata for the struct +// [SettingGetResponseZonesMaxUpload] +type settingGetResponseZonesMaxUploadJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingGetResponseZonesMaxUpload) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingGetResponseZonesMaxUploadJSON) RawJSON() string { + return r.raw +} + +func (r SettingGetResponseZonesMaxUpload) implementsZonesSettingGetResponse() {} + +// identifier of the zone setting. +type SettingGetResponseZonesMaxUploadID string + +const ( + SettingGetResponseZonesMaxUploadIDMaxUpload SettingGetResponseZonesMaxUploadID = "max_upload" +) + +// Current value of the zone setting. +type SettingGetResponseZonesMaxUploadValue float64 + +const ( + SettingGetResponseZonesMaxUploadValue100 SettingGetResponseZonesMaxUploadValue = 100 + SettingGetResponseZonesMaxUploadValue200 SettingGetResponseZonesMaxUploadValue = 200 + SettingGetResponseZonesMaxUploadValue500 SettingGetResponseZonesMaxUploadValue = 500 +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SettingGetResponseZonesMaxUploadEditable bool + +const ( + SettingGetResponseZonesMaxUploadEditableTrue SettingGetResponseZonesMaxUploadEditable = true + SettingGetResponseZonesMaxUploadEditableFalse SettingGetResponseZonesMaxUploadEditable = false +) + +// [Automatic Platform Optimization for WordPress](https://developers.cloudflare.com/automatic-platform-optimization/) +// serves your WordPress site from Cloudflare's edge network and caches third-party +// fonts. +type SettingGetResponseZonesSchemasAutomaticPlatformOptimization struct { + // ID of the zone setting. + ID SettingGetResponseZonesSchemasAutomaticPlatformOptimizationID `json:"id,required"` + // Current value of the zone setting. + Value ZonesAutomaticPlatformOptimization `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable SettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON settingGetResponseZonesSchemasAutomaticPlatformOptimizationJSON `json:"-"` +} + +// settingGetResponseZonesSchemasAutomaticPlatformOptimizationJSON contains the +// JSON metadata for the struct +// [SettingGetResponseZonesSchemasAutomaticPlatformOptimization] +type settingGetResponseZonesSchemasAutomaticPlatformOptimizationJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingGetResponseZonesSchemasAutomaticPlatformOptimization) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingGetResponseZonesSchemasAutomaticPlatformOptimizationJSON) RawJSON() string { + return r.raw +} + +func (r SettingGetResponseZonesSchemasAutomaticPlatformOptimization) implementsZonesSettingGetResponse() { +} + +// ID of the zone setting. +type SettingGetResponseZonesSchemasAutomaticPlatformOptimizationID string + +const ( + SettingGetResponseZonesSchemasAutomaticPlatformOptimizationIDAutomaticPlatformOptimization SettingGetResponseZonesSchemasAutomaticPlatformOptimizationID = "automatic_platform_optimization" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditable bool + +const ( + SettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditableTrue SettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditable = true + SettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditableFalse SettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditable = false +) + +// Allow SHA1 support. +type SettingGetResponseZonesSha1Support struct { + // Zone setting identifier. + ID SettingGetResponseZonesSha1SupportID `json:"id,required"` + // Current value of the zone setting. + Value SettingGetResponseZonesSha1SupportValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable SettingGetResponseZonesSha1SupportEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON settingGetResponseZonesSha1SupportJSON `json:"-"` +} + +// settingGetResponseZonesSha1SupportJSON contains the JSON metadata for the struct +// [SettingGetResponseZonesSha1Support] +type settingGetResponseZonesSha1SupportJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingGetResponseZonesSha1Support) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingGetResponseZonesSha1SupportJSON) RawJSON() string { + return r.raw +} + +func (r SettingGetResponseZonesSha1Support) implementsZonesSettingGetResponse() {} + +// Zone setting identifier. +type SettingGetResponseZonesSha1SupportID string + +const ( + SettingGetResponseZonesSha1SupportIDSha1Support SettingGetResponseZonesSha1SupportID = "sha1_support" +) + +// Current value of the zone setting. +type SettingGetResponseZonesSha1SupportValue string + +const ( + SettingGetResponseZonesSha1SupportValueOff SettingGetResponseZonesSha1SupportValue = "off" + SettingGetResponseZonesSha1SupportValueOn SettingGetResponseZonesSha1SupportValue = "on" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SettingGetResponseZonesSha1SupportEditable bool + +const ( + SettingGetResponseZonesSha1SupportEditableTrue SettingGetResponseZonesSha1SupportEditable = true + SettingGetResponseZonesSha1SupportEditableFalse SettingGetResponseZonesSha1SupportEditable = false +) + +// Only allows TLS1.2. +type SettingGetResponseZonesTLS1_2Only struct { + // Zone setting identifier. + ID SettingGetResponseZonesTLS1_2OnlyID `json:"id,required"` + // Current value of the zone setting. + Value SettingGetResponseZonesTLS1_2OnlyValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable SettingGetResponseZonesTLS1_2OnlyEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON settingGetResponseZonesTls1_2OnlyJSON `json:"-"` +} + +// settingGetResponseZonesTls1_2OnlyJSON contains the JSON metadata for the struct +// [SettingGetResponseZonesTLS1_2Only] +type settingGetResponseZonesTls1_2OnlyJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingGetResponseZonesTLS1_2Only) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingGetResponseZonesTls1_2OnlyJSON) RawJSON() string { + return r.raw +} + +func (r SettingGetResponseZonesTLS1_2Only) implementsZonesSettingGetResponse() {} + +// Zone setting identifier. +type SettingGetResponseZonesTLS1_2OnlyID string + +const ( + SettingGetResponseZonesTLS1_2OnlyIDTLS1_2Only SettingGetResponseZonesTLS1_2OnlyID = "tls_1_2_only" +) + +// Current value of the zone setting. +type SettingGetResponseZonesTLS1_2OnlyValue string + +const ( + SettingGetResponseZonesTLS1_2OnlyValueOff SettingGetResponseZonesTLS1_2OnlyValue = "off" + SettingGetResponseZonesTLS1_2OnlyValueOn SettingGetResponseZonesTLS1_2OnlyValue = "on" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SettingGetResponseZonesTLS1_2OnlyEditable bool + +const ( + SettingGetResponseZonesTLS1_2OnlyEditableTrue SettingGetResponseZonesTLS1_2OnlyEditable = true + SettingGetResponseZonesTLS1_2OnlyEditableFalse SettingGetResponseZonesTLS1_2OnlyEditable = false +) + +type SettingEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // One or more zone setting objects. Must contain an ID and a value. + Items param.Field[[]SettingEditParamsItem] `json:"items,required"` +} + +func (r SettingEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// 0-RTT session resumption enabled for this zone. +// +// Satisfied by [zones.Zones0rttParam], [zones.ZonesAdvancedDDOSParam], +// [zones.ZonesAlwaysOnlineParam], [zones.ZonesAlwaysUseHTTPSParam], +// [zones.ZonesAutomaticHTTPSRewritesParam], [zones.ZonesBrotliParam], +// [zones.ZonesBrowserCacheTTLParam], [zones.ZonesBrowserCheckParam], +// [zones.ZonesCacheLevelParam], [zones.ZonesChallengeTTLParam], +// [zones.ZonesCiphersParam], [zones.SettingEditParamsItemsZonesCNAMEFlattening], +// [zones.ZonesDevelopmentModeParam], [zones.ZonesEarlyHintsParam], +// [zones.SettingEditParamsItemsZonesEdgeCacheTTL], +// [zones.ZonesEmailObfuscationParam], [zones.ZonesH2PrioritizationParam], +// [zones.ZonesHotlinkProtectionParam], [zones.ZonesHTTP2Param], +// [zones.ZonesHTTP3Param], [zones.ZonesImageResizingParam], +// [zones.ZonesIPGeolocationParam], [zones.ZonesIPV6Param], +// [zones.SettingEditParamsItemsZonesMaxUpload], [zones.ZonesMinTLSVersionParam], +// [zones.ZonesMinifyParam], [zones.ZonesMirageParam], +// [zones.ZonesMobileRedirectParam], [zones.ZonesNELParam], +// [zones.ZonesOpportunisticEncryptionParam], [zones.ZonesOpportunisticOnionParam], +// [zones.ZonesOrangeToOrangeParam], [zones.ZonesOriginErrorPagePassThruParam], +// [zones.ZonesPolishParam], [zones.ZonesPrefetchPreloadParam], +// [zones.ZonesProxyReadTimeoutParam], [zones.ZonesPseudoIPV4Param], +// [zones.ZonesBufferingParam], [zones.ZonesRocketLoaderParam], +// [zones.SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimization], +// [zones.ZonesSecurityHeaderParam], [zones.ZonesSecurityLevelParam], +// [zones.ZonesServerSideExcludeParam], +// [zones.SettingEditParamsItemsZonesSha1Support], +// [zones.ZonesSortQueryStringForCacheParam], [zones.ZonesSSLParam], +// [zones.ZonesSSLRecommenderParam], [zones.SettingEditParamsItemsZonesTLS1_2Only], +// [zones.ZonesTLS1_3Param], [zones.ZonesTLSClientAuthParam], +// [zones.ZonesTrueClientIPHeaderParam], [zones.ZonesWAFParam], +// [zones.ZonesWebpParam], [zones.ZonesWebsocketsParam]. +type SettingEditParamsItem interface { + implementsZonesSettingEditParamsItem() +} + +// Whether or not cname flattening is on. +type SettingEditParamsItemsZonesCNAMEFlattening struct { + // How to flatten the cname destination. + ID param.Field[SettingEditParamsItemsZonesCNAMEFlatteningID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[SettingEditParamsItemsZonesCNAMEFlatteningValue] `json:"value,required"` +} + +func (r SettingEditParamsItemsZonesCNAMEFlattening) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r SettingEditParamsItemsZonesCNAMEFlattening) implementsZonesSettingEditParamsItem() {} + +// How to flatten the cname destination. +type SettingEditParamsItemsZonesCNAMEFlatteningID string + +const ( + SettingEditParamsItemsZonesCNAMEFlatteningIDCNAMEFlattening SettingEditParamsItemsZonesCNAMEFlatteningID = "cname_flattening" +) + +// Current value of the zone setting. +type SettingEditParamsItemsZonesCNAMEFlatteningValue string + +const ( + SettingEditParamsItemsZonesCNAMEFlatteningValueFlattenAtRoot SettingEditParamsItemsZonesCNAMEFlatteningValue = "flatten_at_root" + SettingEditParamsItemsZonesCNAMEFlatteningValueFlattenAll SettingEditParamsItemsZonesCNAMEFlatteningValue = "flatten_all" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SettingEditParamsItemsZonesCNAMEFlatteningEditable bool + +const ( + SettingEditParamsItemsZonesCNAMEFlatteningEditableTrue SettingEditParamsItemsZonesCNAMEFlatteningEditable = true + SettingEditParamsItemsZonesCNAMEFlatteningEditableFalse SettingEditParamsItemsZonesCNAMEFlatteningEditable = false +) + +// Time (in seconds) that a resource will be ensured to remain on Cloudflare's +// cache servers. +type SettingEditParamsItemsZonesEdgeCacheTTL struct { + // ID of the zone setting. + ID param.Field[SettingEditParamsItemsZonesEdgeCacheTTLID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[SettingEditParamsItemsZonesEdgeCacheTTLValue] `json:"value,required"` +} + +func (r SettingEditParamsItemsZonesEdgeCacheTTL) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r SettingEditParamsItemsZonesEdgeCacheTTL) implementsZonesSettingEditParamsItem() {} + +// ID of the zone setting. +type SettingEditParamsItemsZonesEdgeCacheTTLID string + +const ( + SettingEditParamsItemsZonesEdgeCacheTTLIDEdgeCacheTTL SettingEditParamsItemsZonesEdgeCacheTTLID = "edge_cache_ttl" +) + +// Current value of the zone setting. +type SettingEditParamsItemsZonesEdgeCacheTTLValue float64 + +const ( + SettingEditParamsItemsZonesEdgeCacheTTLValue30 SettingEditParamsItemsZonesEdgeCacheTTLValue = 30 + SettingEditParamsItemsZonesEdgeCacheTTLValue60 SettingEditParamsItemsZonesEdgeCacheTTLValue = 60 + SettingEditParamsItemsZonesEdgeCacheTTLValue300 SettingEditParamsItemsZonesEdgeCacheTTLValue = 300 + SettingEditParamsItemsZonesEdgeCacheTTLValue1200 SettingEditParamsItemsZonesEdgeCacheTTLValue = 1200 + SettingEditParamsItemsZonesEdgeCacheTTLValue1800 SettingEditParamsItemsZonesEdgeCacheTTLValue = 1800 + SettingEditParamsItemsZonesEdgeCacheTTLValue3600 SettingEditParamsItemsZonesEdgeCacheTTLValue = 3600 + SettingEditParamsItemsZonesEdgeCacheTTLValue7200 SettingEditParamsItemsZonesEdgeCacheTTLValue = 7200 + SettingEditParamsItemsZonesEdgeCacheTTLValue10800 SettingEditParamsItemsZonesEdgeCacheTTLValue = 10800 + SettingEditParamsItemsZonesEdgeCacheTTLValue14400 SettingEditParamsItemsZonesEdgeCacheTTLValue = 14400 + SettingEditParamsItemsZonesEdgeCacheTTLValue18000 SettingEditParamsItemsZonesEdgeCacheTTLValue = 18000 + SettingEditParamsItemsZonesEdgeCacheTTLValue28800 SettingEditParamsItemsZonesEdgeCacheTTLValue = 28800 + SettingEditParamsItemsZonesEdgeCacheTTLValue43200 SettingEditParamsItemsZonesEdgeCacheTTLValue = 43200 + SettingEditParamsItemsZonesEdgeCacheTTLValue57600 SettingEditParamsItemsZonesEdgeCacheTTLValue = 57600 + SettingEditParamsItemsZonesEdgeCacheTTLValue72000 SettingEditParamsItemsZonesEdgeCacheTTLValue = 72000 + SettingEditParamsItemsZonesEdgeCacheTTLValue86400 SettingEditParamsItemsZonesEdgeCacheTTLValue = 86400 + SettingEditParamsItemsZonesEdgeCacheTTLValue172800 SettingEditParamsItemsZonesEdgeCacheTTLValue = 172800 + SettingEditParamsItemsZonesEdgeCacheTTLValue259200 SettingEditParamsItemsZonesEdgeCacheTTLValue = 259200 + SettingEditParamsItemsZonesEdgeCacheTTLValue345600 SettingEditParamsItemsZonesEdgeCacheTTLValue = 345600 + SettingEditParamsItemsZonesEdgeCacheTTLValue432000 SettingEditParamsItemsZonesEdgeCacheTTLValue = 432000 + SettingEditParamsItemsZonesEdgeCacheTTLValue518400 SettingEditParamsItemsZonesEdgeCacheTTLValue = 518400 + SettingEditParamsItemsZonesEdgeCacheTTLValue604800 SettingEditParamsItemsZonesEdgeCacheTTLValue = 604800 +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SettingEditParamsItemsZonesEdgeCacheTTLEditable bool + +const ( + SettingEditParamsItemsZonesEdgeCacheTTLEditableTrue SettingEditParamsItemsZonesEdgeCacheTTLEditable = true + SettingEditParamsItemsZonesEdgeCacheTTLEditableFalse SettingEditParamsItemsZonesEdgeCacheTTLEditable = false +) + +// Maximum size of an allowable upload. +type SettingEditParamsItemsZonesMaxUpload struct { + // identifier of the zone setting. + ID param.Field[SettingEditParamsItemsZonesMaxUploadID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[SettingEditParamsItemsZonesMaxUploadValue] `json:"value,required"` +} + +func (r SettingEditParamsItemsZonesMaxUpload) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r SettingEditParamsItemsZonesMaxUpload) implementsZonesSettingEditParamsItem() {} + +// identifier of the zone setting. +type SettingEditParamsItemsZonesMaxUploadID string + +const ( + SettingEditParamsItemsZonesMaxUploadIDMaxUpload SettingEditParamsItemsZonesMaxUploadID = "max_upload" +) + +// Current value of the zone setting. +type SettingEditParamsItemsZonesMaxUploadValue float64 + +const ( + SettingEditParamsItemsZonesMaxUploadValue100 SettingEditParamsItemsZonesMaxUploadValue = 100 + SettingEditParamsItemsZonesMaxUploadValue200 SettingEditParamsItemsZonesMaxUploadValue = 200 + SettingEditParamsItemsZonesMaxUploadValue500 SettingEditParamsItemsZonesMaxUploadValue = 500 +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SettingEditParamsItemsZonesMaxUploadEditable bool + +const ( + SettingEditParamsItemsZonesMaxUploadEditableTrue SettingEditParamsItemsZonesMaxUploadEditable = true + SettingEditParamsItemsZonesMaxUploadEditableFalse SettingEditParamsItemsZonesMaxUploadEditable = false +) + +// [Automatic Platform Optimization for WordPress](https://developers.cloudflare.com/automatic-platform-optimization/) +// serves your WordPress site from Cloudflare's edge network and caches third-party +// fonts. +type SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimization struct { + // ID of the zone setting. + ID param.Field[SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesAutomaticPlatformOptimizationParam] `json:"value,required"` +} + +func (r SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimization) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimization) implementsZonesSettingEditParamsItem() { +} + +// ID of the zone setting. +type SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationID string + +const ( + SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationIDAutomaticPlatformOptimization SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationID = "automatic_platform_optimization" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationEditable bool + +const ( + SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationEditableTrue SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationEditable = true + SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationEditableFalse SettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationEditable = false +) + +// Allow SHA1 support. +type SettingEditParamsItemsZonesSha1Support struct { + // Zone setting identifier. + ID param.Field[SettingEditParamsItemsZonesSha1SupportID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[SettingEditParamsItemsZonesSha1SupportValue] `json:"value,required"` +} + +func (r SettingEditParamsItemsZonesSha1Support) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r SettingEditParamsItemsZonesSha1Support) implementsZonesSettingEditParamsItem() {} + +// Zone setting identifier. +type SettingEditParamsItemsZonesSha1SupportID string + +const ( + SettingEditParamsItemsZonesSha1SupportIDSha1Support SettingEditParamsItemsZonesSha1SupportID = "sha1_support" +) + +// Current value of the zone setting. +type SettingEditParamsItemsZonesSha1SupportValue string + +const ( + SettingEditParamsItemsZonesSha1SupportValueOff SettingEditParamsItemsZonesSha1SupportValue = "off" + SettingEditParamsItemsZonesSha1SupportValueOn SettingEditParamsItemsZonesSha1SupportValue = "on" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SettingEditParamsItemsZonesSha1SupportEditable bool + +const ( + SettingEditParamsItemsZonesSha1SupportEditableTrue SettingEditParamsItemsZonesSha1SupportEditable = true + SettingEditParamsItemsZonesSha1SupportEditableFalse SettingEditParamsItemsZonesSha1SupportEditable = false +) + +// Only allows TLS1.2. +type SettingEditParamsItemsZonesTLS1_2Only struct { + // Zone setting identifier. + ID param.Field[SettingEditParamsItemsZonesTLS1_2OnlyID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[SettingEditParamsItemsZonesTLS1_2OnlyValue] `json:"value,required"` +} + +func (r SettingEditParamsItemsZonesTLS1_2Only) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r SettingEditParamsItemsZonesTLS1_2Only) implementsZonesSettingEditParamsItem() {} + +// Zone setting identifier. +type SettingEditParamsItemsZonesTLS1_2OnlyID string + +const ( + SettingEditParamsItemsZonesTLS1_2OnlyIDTLS1_2Only SettingEditParamsItemsZonesTLS1_2OnlyID = "tls_1_2_only" +) + +// Current value of the zone setting. +type SettingEditParamsItemsZonesTLS1_2OnlyValue string + +const ( + SettingEditParamsItemsZonesTLS1_2OnlyValueOff SettingEditParamsItemsZonesTLS1_2OnlyValue = "off" + SettingEditParamsItemsZonesTLS1_2OnlyValueOn SettingEditParamsItemsZonesTLS1_2OnlyValue = "on" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SettingEditParamsItemsZonesTLS1_2OnlyEditable bool + +const ( + SettingEditParamsItemsZonesTLS1_2OnlyEditableTrue SettingEditParamsItemsZonesTLS1_2OnlyEditable = true + SettingEditParamsItemsZonesTLS1_2OnlyEditableFalse SettingEditParamsItemsZonesTLS1_2OnlyEditable = false +) + +type SettingEditResponseEnvelope struct { + Errors []SettingEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + Result []SettingEditResponse `json:"result"` + JSON settingEditResponseEnvelopeJSON `json:"-"` +} + +// settingEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingEditResponseEnvelope] +type settingEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingEditResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [SettingEditResponseEnvelopeErrors] +type settingEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingEditResponseEnvelopeMessages] +type settingEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingGetResponseEnvelope struct { + Errors []SettingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + Result []SettingGetResponse `json:"result"` + JSON settingGetResponseEnvelopeJSON `json:"-"` +} + +// settingGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingGetResponseEnvelope] +type settingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the struct +// [SettingGetResponseEnvelopeErrors] +type settingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the struct +// [SettingGetResponseEnvelopeMessages] +type settingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/setting_test.go b/zones/setting_test.go new file mode 100644 index 00000000000..28638eebfc9 --- /dev/null +++ b/zones/setting_test.go @@ -0,0 +1,77 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingEdit(t *testing.T) { + t.Skip("oneOf doesnt match") + 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("user@example.com"), + ) + _, err := client.Zones.Settings.Edit(context.TODO(), zones.SettingEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Items: cloudflare.F([]zones.SettingEditParamsItem{zones.ZonesAlwaysOnlineParam(zones.ZonesAlwaysOnlineParam{ + ID: cloudflare.F(zones.ZonesAlwaysOnlineIDAlwaysOnline), + Value: cloudflare.F(zones.ZonesAlwaysOnlineValueOn), + }), zones.ZonesBrowserCacheTTLParam(zones.ZonesBrowserCacheTTLParam{ + ID: cloudflare.F(zones.ZonesBrowserCacheTTLIDBrowserCacheTTL), + Value: cloudflare.F(zones.ZonesBrowserCacheTTLValue18000), + }), zones.ZonesIPGeolocationParam(zones.ZonesIPGeolocationParam{ + ID: cloudflare.F(zones.ZonesIPGeolocationIDIPGeolocation), + Value: cloudflare.F(zones.ZonesIPGeolocationValueOff), + })}), + }) + 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 TestSettingGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.Get(context.TODO(), zones.SettingGetParams{ + ZoneID: cloudflare.F("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/zones/settingadvancedddos.go b/zones/settingadvancedddos.go new file mode 100644 index 00000000000..25f06f09b2b --- /dev/null +++ b/zones/settingadvancedddos.go @@ -0,0 +1,209 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingAdvancedDDOSService 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 [NewSettingAdvancedDDOSService] +// method instead. +type SettingAdvancedDDOSService struct { + Options []option.RequestOption +} + +// NewSettingAdvancedDDOSService 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 NewSettingAdvancedDDOSService(opts ...option.RequestOption) (r *SettingAdvancedDDOSService) { + r = &SettingAdvancedDDOSService{} + 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 *SettingAdvancedDDOSService) Get(ctx context.Context, query SettingAdvancedDDOSGetParams, opts ...option.RequestOption) (res *ZonesAdvancedDDOS, err error) { + opts = append(r.Options[:], opts...) + var env SettingAdvancedDDOSGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/advanced_ddos", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + 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. +type ZonesAdvancedDDOS struct { + // ID of the zone setting. + ID ZonesAdvancedDDOSID `json:"id,required"` + // Current value of the zone setting. + Value ZonesAdvancedDDOSValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesAdvancedDDOSEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesAdvancedDDOSJSON `json:"-"` +} + +// zonesAdvancedDDOSJSON contains the JSON metadata for the struct +// [ZonesAdvancedDDOS] +type zonesAdvancedDDOSJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesAdvancedDDOS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesAdvancedDDOSJSON) RawJSON() string { + return r.raw +} + +func (r ZonesAdvancedDDOS) implementsZonesSettingEditResponse() {} + +func (r ZonesAdvancedDDOS) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesAdvancedDDOSID string + +const ( + ZonesAdvancedDDOSIDAdvancedDDOS ZonesAdvancedDDOSID = "advanced_ddos" +) + +// Current value of the zone setting. +type ZonesAdvancedDDOSValue string + +const ( + ZonesAdvancedDDOSValueOn ZonesAdvancedDDOSValue = "on" + ZonesAdvancedDDOSValueOff ZonesAdvancedDDOSValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesAdvancedDDOSEditable bool + +const ( + ZonesAdvancedDDOSEditableTrue ZonesAdvancedDDOSEditable = true + ZonesAdvancedDDOSEditableFalse ZonesAdvancedDDOSEditable = false +) + +// 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. +type ZonesAdvancedDDOSParam struct { + // ID of the zone setting. + ID param.Field[ZonesAdvancedDDOSID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesAdvancedDDOSValue] `json:"value,required"` +} + +func (r ZonesAdvancedDDOSParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesAdvancedDDOSParam) implementsZonesSettingEditParamsItem() {} + +type SettingAdvancedDDOSGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingAdvancedDDOSGetResponseEnvelope struct { + Errors []SettingAdvancedDDOSGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingAdvancedDDOSGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // 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. + Result ZonesAdvancedDDOS `json:"result"` + JSON settingAdvancedDDOSGetResponseEnvelopeJSON `json:"-"` +} + +// settingAdvancedDDOSGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingAdvancedDDOSGetResponseEnvelope] +type settingAdvancedDDOSGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAdvancedDDOSGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAdvancedDDOSGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingAdvancedDDOSGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingAdvancedDDOSGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingAdvancedDDOSGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingAdvancedDDOSGetResponseEnvelopeErrors] +type settingAdvancedDDOSGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAdvancedDDOSGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAdvancedDDOSGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingAdvancedDDOSGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingAdvancedDDOSGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingAdvancedDDOSGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingAdvancedDDOSGetResponseEnvelopeMessages] +type settingAdvancedDDOSGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAdvancedDDOSGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAdvancedDDOSGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingadvancedddos_test.go b/zones/settingadvancedddos_test.go new file mode 100644 index 00000000000..2049e336ca2 --- /dev/null +++ b/zones/settingadvancedddos_test.go @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingAdvancedDDOSGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.AdvancedDDOS.Get(context.TODO(), zones.SettingAdvancedDDOSGetParams{ + ZoneID: cloudflare.F("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/zones/settingalwaysonline.go b/zones/settingalwaysonline.go new file mode 100644 index 00000000000..a079d408324 --- /dev/null +++ b/zones/settingalwaysonline.go @@ -0,0 +1,332 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingAlwaysOnlineService 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 [NewSettingAlwaysOnlineService] +// method instead. +type SettingAlwaysOnlineService struct { + Options []option.RequestOption +} + +// NewSettingAlwaysOnlineService 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 NewSettingAlwaysOnlineService(opts ...option.RequestOption) (r *SettingAlwaysOnlineService) { + r = &SettingAlwaysOnlineService{} + r.Options = opts + return +} + +// When enabled, Cloudflare serves limited copies of web pages available from the +// [Internet Archive's Wayback Machine](https://archive.org/web/) if your server is +// offline. Refer to +// [Always Online](https://developers.cloudflare.com/cache/about/always-online) for +// more information. +func (r *SettingAlwaysOnlineService) Edit(ctx context.Context, params SettingAlwaysOnlineEditParams, opts ...option.RequestOption) (res *ZonesAlwaysOnline, err error) { + opts = append(r.Options[:], opts...) + var env SettingAlwaysOnlineEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/always_online", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// When enabled, Cloudflare serves limited copies of web pages available from the +// [Internet Archive's Wayback Machine](https://archive.org/web/) if your server is +// offline. Refer to +// [Always Online](https://developers.cloudflare.com/cache/about/always-online) for +// more information. +func (r *SettingAlwaysOnlineService) Get(ctx context.Context, query SettingAlwaysOnlineGetParams, opts ...option.RequestOption) (res *ZonesAlwaysOnline, err error) { + opts = append(r.Options[:], opts...) + var env SettingAlwaysOnlineGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/always_online", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// When enabled, Cloudflare serves limited copies of web pages available from the +// [Internet Archive's Wayback Machine](https://archive.org/web/) if your server is +// offline. Refer to +// [Always Online](https://developers.cloudflare.com/cache/about/always-online) for +// more information. +type ZonesAlwaysOnline struct { + // ID of the zone setting. + ID ZonesAlwaysOnlineID `json:"id,required"` + // Current value of the zone setting. + Value ZonesAlwaysOnlineValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesAlwaysOnlineEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesAlwaysOnlineJSON `json:"-"` +} + +// zonesAlwaysOnlineJSON contains the JSON metadata for the struct +// [ZonesAlwaysOnline] +type zonesAlwaysOnlineJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesAlwaysOnline) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesAlwaysOnlineJSON) RawJSON() string { + return r.raw +} + +func (r ZonesAlwaysOnline) implementsZonesSettingEditResponse() {} + +func (r ZonesAlwaysOnline) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesAlwaysOnlineID string + +const ( + ZonesAlwaysOnlineIDAlwaysOnline ZonesAlwaysOnlineID = "always_online" +) + +// Current value of the zone setting. +type ZonesAlwaysOnlineValue string + +const ( + ZonesAlwaysOnlineValueOn ZonesAlwaysOnlineValue = "on" + ZonesAlwaysOnlineValueOff ZonesAlwaysOnlineValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesAlwaysOnlineEditable bool + +const ( + ZonesAlwaysOnlineEditableTrue ZonesAlwaysOnlineEditable = true + ZonesAlwaysOnlineEditableFalse ZonesAlwaysOnlineEditable = false +) + +// When enabled, Cloudflare serves limited copies of web pages available from the +// [Internet Archive's Wayback Machine](https://archive.org/web/) if your server is +// offline. Refer to +// [Always Online](https://developers.cloudflare.com/cache/about/always-online) for +// more information. +type ZonesAlwaysOnlineParam struct { + // ID of the zone setting. + ID param.Field[ZonesAlwaysOnlineID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesAlwaysOnlineValue] `json:"value,required"` +} + +func (r ZonesAlwaysOnlineParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesAlwaysOnlineParam) implementsZonesSettingEditParamsItem() {} + +type SettingAlwaysOnlineEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingAlwaysOnlineEditParamsValue] `json:"value,required"` +} + +func (r SettingAlwaysOnlineEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingAlwaysOnlineEditParamsValue string + +const ( + SettingAlwaysOnlineEditParamsValueOn SettingAlwaysOnlineEditParamsValue = "on" + SettingAlwaysOnlineEditParamsValueOff SettingAlwaysOnlineEditParamsValue = "off" +) + +type SettingAlwaysOnlineEditResponseEnvelope struct { + Errors []SettingAlwaysOnlineEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingAlwaysOnlineEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // When enabled, Cloudflare serves limited copies of web pages available from the + // [Internet Archive's Wayback Machine](https://archive.org/web/) if your server is + // offline. Refer to + // [Always Online](https://developers.cloudflare.com/cache/about/always-online) for + // more information. + Result ZonesAlwaysOnline `json:"result"` + JSON settingAlwaysOnlineEditResponseEnvelopeJSON `json:"-"` +} + +// settingAlwaysOnlineEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingAlwaysOnlineEditResponseEnvelope] +type settingAlwaysOnlineEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAlwaysOnlineEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAlwaysOnlineEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingAlwaysOnlineEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingAlwaysOnlineEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingAlwaysOnlineEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingAlwaysOnlineEditResponseEnvelopeErrors] +type settingAlwaysOnlineEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAlwaysOnlineEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAlwaysOnlineEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingAlwaysOnlineEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingAlwaysOnlineEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingAlwaysOnlineEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingAlwaysOnlineEditResponseEnvelopeMessages] +type settingAlwaysOnlineEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAlwaysOnlineEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAlwaysOnlineEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingAlwaysOnlineGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingAlwaysOnlineGetResponseEnvelope struct { + Errors []SettingAlwaysOnlineGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingAlwaysOnlineGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // When enabled, Cloudflare serves limited copies of web pages available from the + // [Internet Archive's Wayback Machine](https://archive.org/web/) if your server is + // offline. Refer to + // [Always Online](https://developers.cloudflare.com/cache/about/always-online) for + // more information. + Result ZonesAlwaysOnline `json:"result"` + JSON settingAlwaysOnlineGetResponseEnvelopeJSON `json:"-"` +} + +// settingAlwaysOnlineGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingAlwaysOnlineGetResponseEnvelope] +type settingAlwaysOnlineGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAlwaysOnlineGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAlwaysOnlineGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingAlwaysOnlineGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingAlwaysOnlineGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingAlwaysOnlineGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingAlwaysOnlineGetResponseEnvelopeErrors] +type settingAlwaysOnlineGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAlwaysOnlineGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAlwaysOnlineGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingAlwaysOnlineGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingAlwaysOnlineGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingAlwaysOnlineGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingAlwaysOnlineGetResponseEnvelopeMessages] +type settingAlwaysOnlineGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAlwaysOnlineGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAlwaysOnlineGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingalwaysonline_test.go b/zones/settingalwaysonline_test.go new file mode 100644 index 00000000000..6dc0ed25c93 --- /dev/null +++ b/zones/settingalwaysonline_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingAlwaysOnlineEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.AlwaysOnline.Edit(context.TODO(), zones.SettingAlwaysOnlineEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingAlwaysOnlineEditParamsValueOn), + }) + 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 TestSettingAlwaysOnlineGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.AlwaysOnline.Get(context.TODO(), zones.SettingAlwaysOnlineGetParams{ + ZoneID: cloudflare.F("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/zones/settingalwaysusehttps.go b/zones/settingalwaysusehttps.go new file mode 100644 index 00000000000..78c0dda48cd --- /dev/null +++ b/zones/settingalwaysusehttps.go @@ -0,0 +1,320 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingAlwaysUseHTTPSService 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 [NewSettingAlwaysUseHTTPSService] +// method instead. +type SettingAlwaysUseHTTPSService struct { + Options []option.RequestOption +} + +// NewSettingAlwaysUseHTTPSService 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 NewSettingAlwaysUseHTTPSService(opts ...option.RequestOption) (r *SettingAlwaysUseHTTPSService) { + r = &SettingAlwaysUseHTTPSService{} + r.Options = opts + return +} + +// Reply to all requests for URLs that use "http" with a 301 redirect to the +// equivalent "https" URL. If you only want to redirect for a subset of requests, +// consider creating an "Always use HTTPS" page rule. +func (r *SettingAlwaysUseHTTPSService) Edit(ctx context.Context, params SettingAlwaysUseHTTPSEditParams, opts ...option.RequestOption) (res *ZonesAlwaysUseHTTPS, err error) { + opts = append(r.Options[:], opts...) + var env SettingAlwaysUseHTTPSEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/always_use_https", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Reply to all requests for URLs that use "http" with a 301 redirect to the +// equivalent "https" URL. If you only want to redirect for a subset of requests, +// consider creating an "Always use HTTPS" page rule. +func (r *SettingAlwaysUseHTTPSService) Get(ctx context.Context, query SettingAlwaysUseHTTPSGetParams, opts ...option.RequestOption) (res *ZonesAlwaysUseHTTPS, err error) { + opts = append(r.Options[:], opts...) + var env SettingAlwaysUseHTTPSGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/always_use_https", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Reply to all requests for URLs that use "http" with a 301 redirect to the +// equivalent "https" URL. If you only want to redirect for a subset of requests, +// consider creating an "Always use HTTPS" page rule. +type ZonesAlwaysUseHTTPS struct { + // ID of the zone setting. + ID ZonesAlwaysUseHTTPSID `json:"id,required"` + // Current value of the zone setting. + Value ZonesAlwaysUseHTTPSValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesAlwaysUseHTTPSEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesAlwaysUseHTTPSJSON `json:"-"` +} + +// zonesAlwaysUseHTTPSJSON contains the JSON metadata for the struct +// [ZonesAlwaysUseHTTPS] +type zonesAlwaysUseHTTPSJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesAlwaysUseHTTPS) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesAlwaysUseHTTPSJSON) RawJSON() string { + return r.raw +} + +func (r ZonesAlwaysUseHTTPS) implementsZonesSettingEditResponse() {} + +func (r ZonesAlwaysUseHTTPS) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesAlwaysUseHTTPSID string + +const ( + ZonesAlwaysUseHTTPSIDAlwaysUseHTTPS ZonesAlwaysUseHTTPSID = "always_use_https" +) + +// Current value of the zone setting. +type ZonesAlwaysUseHTTPSValue string + +const ( + ZonesAlwaysUseHTTPSValueOn ZonesAlwaysUseHTTPSValue = "on" + ZonesAlwaysUseHTTPSValueOff ZonesAlwaysUseHTTPSValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesAlwaysUseHTTPSEditable bool + +const ( + ZonesAlwaysUseHTTPSEditableTrue ZonesAlwaysUseHTTPSEditable = true + ZonesAlwaysUseHTTPSEditableFalse ZonesAlwaysUseHTTPSEditable = false +) + +// Reply to all requests for URLs that use "http" with a 301 redirect to the +// equivalent "https" URL. If you only want to redirect for a subset of requests, +// consider creating an "Always use HTTPS" page rule. +type ZonesAlwaysUseHTTPSParam struct { + // ID of the zone setting. + ID param.Field[ZonesAlwaysUseHTTPSID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesAlwaysUseHTTPSValue] `json:"value,required"` +} + +func (r ZonesAlwaysUseHTTPSParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesAlwaysUseHTTPSParam) implementsZonesSettingEditParamsItem() {} + +type SettingAlwaysUseHTTPSEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingAlwaysUseHTTPSEditParamsValue] `json:"value,required"` +} + +func (r SettingAlwaysUseHTTPSEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingAlwaysUseHTTPSEditParamsValue string + +const ( + SettingAlwaysUseHTTPSEditParamsValueOn SettingAlwaysUseHTTPSEditParamsValue = "on" + SettingAlwaysUseHTTPSEditParamsValueOff SettingAlwaysUseHTTPSEditParamsValue = "off" +) + +type SettingAlwaysUseHTTPSEditResponseEnvelope struct { + Errors []SettingAlwaysUseHTTPSEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingAlwaysUseHTTPSEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Reply to all requests for URLs that use "http" with a 301 redirect to the + // equivalent "https" URL. If you only want to redirect for a subset of requests, + // consider creating an "Always use HTTPS" page rule. + Result ZonesAlwaysUseHTTPS `json:"result"` + JSON settingAlwaysUseHTTPSEditResponseEnvelopeJSON `json:"-"` +} + +// settingAlwaysUseHTTPSEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingAlwaysUseHTTPSEditResponseEnvelope] +type settingAlwaysUseHTTPSEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAlwaysUseHTTPSEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAlwaysUseHTTPSEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingAlwaysUseHTTPSEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingAlwaysUseHTTPSEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingAlwaysUseHTTPSEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingAlwaysUseHTTPSEditResponseEnvelopeErrors] +type settingAlwaysUseHTTPSEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAlwaysUseHTTPSEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAlwaysUseHTTPSEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingAlwaysUseHTTPSEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingAlwaysUseHTTPSEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingAlwaysUseHTTPSEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingAlwaysUseHTTPSEditResponseEnvelopeMessages] +type settingAlwaysUseHTTPSEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAlwaysUseHTTPSEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAlwaysUseHTTPSEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingAlwaysUseHTTPSGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingAlwaysUseHTTPSGetResponseEnvelope struct { + Errors []SettingAlwaysUseHTTPSGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingAlwaysUseHTTPSGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Reply to all requests for URLs that use "http" with a 301 redirect to the + // equivalent "https" URL. If you only want to redirect for a subset of requests, + // consider creating an "Always use HTTPS" page rule. + Result ZonesAlwaysUseHTTPS `json:"result"` + JSON settingAlwaysUseHTTPSGetResponseEnvelopeJSON `json:"-"` +} + +// settingAlwaysUseHTTPSGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingAlwaysUseHTTPSGetResponseEnvelope] +type settingAlwaysUseHTTPSGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAlwaysUseHTTPSGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAlwaysUseHTTPSGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingAlwaysUseHTTPSGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingAlwaysUseHTTPSGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingAlwaysUseHTTPSGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingAlwaysUseHTTPSGetResponseEnvelopeErrors] +type settingAlwaysUseHTTPSGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAlwaysUseHTTPSGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAlwaysUseHTTPSGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingAlwaysUseHTTPSGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingAlwaysUseHTTPSGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingAlwaysUseHTTPSGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingAlwaysUseHTTPSGetResponseEnvelopeMessages] +type settingAlwaysUseHTTPSGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAlwaysUseHTTPSGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAlwaysUseHTTPSGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingalwaysusehttps_test.go b/zones/settingalwaysusehttps_test.go new file mode 100644 index 00000000000..4cb959ea0bd --- /dev/null +++ b/zones/settingalwaysusehttps_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingAlwaysUseHTTPSEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.AlwaysUseHTTPS.Edit(context.TODO(), zones.SettingAlwaysUseHTTPSEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingAlwaysUseHTTPSEditParamsValueOn), + }) + 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 TestSettingAlwaysUseHTTPSGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.AlwaysUseHTTPS.Get(context.TODO(), zones.SettingAlwaysUseHTTPSGetParams{ + ZoneID: cloudflare.F("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/zones/settingautomatichttpsrewrite.go b/zones/settingautomatichttpsrewrite.go new file mode 100644 index 00000000000..98e8a8b260a --- /dev/null +++ b/zones/settingautomatichttpsrewrite.go @@ -0,0 +1,312 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingAutomaticHTTPSRewriteService 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 +// [NewSettingAutomaticHTTPSRewriteService] method instead. +type SettingAutomaticHTTPSRewriteService struct { + Options []option.RequestOption +} + +// NewSettingAutomaticHTTPSRewriteService 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 NewSettingAutomaticHTTPSRewriteService(opts ...option.RequestOption) (r *SettingAutomaticHTTPSRewriteService) { + r = &SettingAutomaticHTTPSRewriteService{} + r.Options = opts + return +} + +// Enable the Automatic HTTPS Rewrites feature for this zone. +func (r *SettingAutomaticHTTPSRewriteService) Edit(ctx context.Context, params SettingAutomaticHTTPSRewriteEditParams, opts ...option.RequestOption) (res *ZonesAutomaticHTTPSRewrites, err error) { + opts = append(r.Options[:], opts...) + var env SettingAutomaticHTTPSRewriteEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/automatic_https_rewrites", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Enable the Automatic HTTPS Rewrites feature for this zone. +func (r *SettingAutomaticHTTPSRewriteService) Get(ctx context.Context, query SettingAutomaticHTTPSRewriteGetParams, opts ...option.RequestOption) (res *ZonesAutomaticHTTPSRewrites, err error) { + opts = append(r.Options[:], opts...) + var env SettingAutomaticHTTPSRewriteGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/automatic_https_rewrites", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Enable the Automatic HTTPS Rewrites feature for this zone. +type ZonesAutomaticHTTPSRewrites struct { + // ID of the zone setting. + ID ZonesAutomaticHTTPSRewritesID `json:"id,required"` + // Current value of the zone setting. + Value ZonesAutomaticHTTPSRewritesValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesAutomaticHTTPSRewritesEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesAutomaticHTTPSRewritesJSON `json:"-"` +} + +// zonesAutomaticHTTPSRewritesJSON contains the JSON metadata for the struct +// [ZonesAutomaticHTTPSRewrites] +type zonesAutomaticHTTPSRewritesJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesAutomaticHTTPSRewrites) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesAutomaticHTTPSRewritesJSON) RawJSON() string { + return r.raw +} + +func (r ZonesAutomaticHTTPSRewrites) implementsZonesSettingEditResponse() {} + +func (r ZonesAutomaticHTTPSRewrites) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesAutomaticHTTPSRewritesID string + +const ( + ZonesAutomaticHTTPSRewritesIDAutomaticHTTPSRewrites ZonesAutomaticHTTPSRewritesID = "automatic_https_rewrites" +) + +// Current value of the zone setting. +type ZonesAutomaticHTTPSRewritesValue string + +const ( + ZonesAutomaticHTTPSRewritesValueOn ZonesAutomaticHTTPSRewritesValue = "on" + ZonesAutomaticHTTPSRewritesValueOff ZonesAutomaticHTTPSRewritesValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesAutomaticHTTPSRewritesEditable bool + +const ( + ZonesAutomaticHTTPSRewritesEditableTrue ZonesAutomaticHTTPSRewritesEditable = true + ZonesAutomaticHTTPSRewritesEditableFalse ZonesAutomaticHTTPSRewritesEditable = false +) + +// Enable the Automatic HTTPS Rewrites feature for this zone. +type ZonesAutomaticHTTPSRewritesParam struct { + // ID of the zone setting. + ID param.Field[ZonesAutomaticHTTPSRewritesID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesAutomaticHTTPSRewritesValue] `json:"value,required"` +} + +func (r ZonesAutomaticHTTPSRewritesParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesAutomaticHTTPSRewritesParam) implementsZonesSettingEditParamsItem() {} + +type SettingAutomaticHTTPSRewriteEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. Notes: Default value depends on the zone's plan + // level. + Value param.Field[SettingAutomaticHTTPSRewriteEditParamsValue] `json:"value,required"` +} + +func (r SettingAutomaticHTTPSRewriteEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. Notes: Default value depends on the zone's plan +// level. +type SettingAutomaticHTTPSRewriteEditParamsValue string + +const ( + SettingAutomaticHTTPSRewriteEditParamsValueOn SettingAutomaticHTTPSRewriteEditParamsValue = "on" + SettingAutomaticHTTPSRewriteEditParamsValueOff SettingAutomaticHTTPSRewriteEditParamsValue = "off" +) + +type SettingAutomaticHTTPSRewriteEditResponseEnvelope struct { + Errors []SettingAutomaticHTTPSRewriteEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingAutomaticHTTPSRewriteEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Enable the Automatic HTTPS Rewrites feature for this zone. + Result ZonesAutomaticHTTPSRewrites `json:"result"` + JSON settingAutomaticHTTPSRewriteEditResponseEnvelopeJSON `json:"-"` +} + +// settingAutomaticHTTPSRewriteEditResponseEnvelopeJSON contains the JSON metadata +// for the struct [SettingAutomaticHTTPSRewriteEditResponseEnvelope] +type settingAutomaticHTTPSRewriteEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAutomaticHTTPSRewriteEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAutomaticHTTPSRewriteEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingAutomaticHTTPSRewriteEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingAutomaticHTTPSRewriteEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingAutomaticHTTPSRewriteEditResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [SettingAutomaticHTTPSRewriteEditResponseEnvelopeErrors] +type settingAutomaticHTTPSRewriteEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAutomaticHTTPSRewriteEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAutomaticHTTPSRewriteEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingAutomaticHTTPSRewriteEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingAutomaticHTTPSRewriteEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingAutomaticHTTPSRewriteEditResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct +// [SettingAutomaticHTTPSRewriteEditResponseEnvelopeMessages] +type settingAutomaticHTTPSRewriteEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAutomaticHTTPSRewriteEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAutomaticHTTPSRewriteEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingAutomaticHTTPSRewriteGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingAutomaticHTTPSRewriteGetResponseEnvelope struct { + Errors []SettingAutomaticHTTPSRewriteGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingAutomaticHTTPSRewriteGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Enable the Automatic HTTPS Rewrites feature for this zone. + Result ZonesAutomaticHTTPSRewrites `json:"result"` + JSON settingAutomaticHTTPSRewriteGetResponseEnvelopeJSON `json:"-"` +} + +// settingAutomaticHTTPSRewriteGetResponseEnvelopeJSON contains the JSON metadata +// for the struct [SettingAutomaticHTTPSRewriteGetResponseEnvelope] +type settingAutomaticHTTPSRewriteGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAutomaticHTTPSRewriteGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAutomaticHTTPSRewriteGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingAutomaticHTTPSRewriteGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingAutomaticHTTPSRewriteGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingAutomaticHTTPSRewriteGetResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [SettingAutomaticHTTPSRewriteGetResponseEnvelopeErrors] +type settingAutomaticHTTPSRewriteGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAutomaticHTTPSRewriteGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAutomaticHTTPSRewriteGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingAutomaticHTTPSRewriteGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingAutomaticHTTPSRewriteGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingAutomaticHTTPSRewriteGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct +// [SettingAutomaticHTTPSRewriteGetResponseEnvelopeMessages] +type settingAutomaticHTTPSRewriteGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAutomaticHTTPSRewriteGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAutomaticHTTPSRewriteGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingautomatichttpsrewrite_test.go b/zones/settingautomatichttpsrewrite_test.go new file mode 100644 index 00000000000..e214a077370 --- /dev/null +++ b/zones/settingautomatichttpsrewrite_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingAutomaticHTTPSRewriteEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.AutomaticHTTPSRewrites.Edit(context.TODO(), zones.SettingAutomaticHTTPSRewriteEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingAutomaticHTTPSRewriteEditParamsValueOn), + }) + 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 TestSettingAutomaticHTTPSRewriteGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.AutomaticHTTPSRewrites.Get(context.TODO(), zones.SettingAutomaticHTTPSRewriteGetParams{ + ZoneID: cloudflare.F("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/zones/settingautomaticplatformoptimization.go b/zones/settingautomaticplatformoptimization.go new file mode 100644 index 00000000000..71ff223de34 --- /dev/null +++ b/zones/settingautomaticplatformoptimization.go @@ -0,0 +1,298 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingAutomaticPlatformOptimizationService 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 +// [NewSettingAutomaticPlatformOptimizationService] method instead. +type SettingAutomaticPlatformOptimizationService struct { + Options []option.RequestOption +} + +// NewSettingAutomaticPlatformOptimizationService 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 NewSettingAutomaticPlatformOptimizationService(opts ...option.RequestOption) (r *SettingAutomaticPlatformOptimizationService) { + r = &SettingAutomaticPlatformOptimizationService{} + r.Options = opts + return +} + +// [Automatic Platform Optimization for WordPress](https://developers.cloudflare.com/automatic-platform-optimization/) +// serves your WordPress site from Cloudflare's edge network and caches third-party +// fonts. +func (r *SettingAutomaticPlatformOptimizationService) Edit(ctx context.Context, params SettingAutomaticPlatformOptimizationEditParams, opts ...option.RequestOption) (res *ZonesAutomaticPlatformOptimization, err error) { + opts = append(r.Options[:], opts...) + var env SettingAutomaticPlatformOptimizationEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/automatic_platform_optimization", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// [Automatic Platform Optimization for WordPress](https://developers.cloudflare.com/automatic-platform-optimization/) +// serves your WordPress site from Cloudflare's edge network and caches third-party +// fonts. +func (r *SettingAutomaticPlatformOptimizationService) Get(ctx context.Context, query SettingAutomaticPlatformOptimizationGetParams, opts ...option.RequestOption) (res *ZonesAutomaticPlatformOptimization, err error) { + opts = append(r.Options[:], opts...) + var env SettingAutomaticPlatformOptimizationGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/automatic_platform_optimization", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +type ZonesAutomaticPlatformOptimization struct { + // Indicates whether or not + // [cache by device type](https://developers.cloudflare.com/automatic-platform-optimization/reference/cache-device-type/) + // is enabled. + CacheByDeviceType bool `json:"cache_by_device_type,required"` + // Indicates whether or not Cloudflare proxy is enabled. + Cf bool `json:"cf,required"` + // Indicates whether or not Automatic Platform Optimization is enabled. + Enabled bool `json:"enabled,required"` + // An array of hostnames where Automatic Platform Optimization for WordPress is + // activated. + Hostnames []string `json:"hostnames,required" format:"hostname"` + // Indicates whether or not site is powered by WordPress. + Wordpress bool `json:"wordpress,required"` + // Indicates whether or not + // [Cloudflare for WordPress plugin](https://wordpress.org/plugins/cloudflare/) is + // installed. + WpPlugin bool `json:"wp_plugin,required"` + JSON zonesAutomaticPlatformOptimizationJSON `json:"-"` +} + +// zonesAutomaticPlatformOptimizationJSON contains the JSON metadata for the struct +// [ZonesAutomaticPlatformOptimization] +type zonesAutomaticPlatformOptimizationJSON struct { + CacheByDeviceType apijson.Field + Cf apijson.Field + Enabled apijson.Field + Hostnames apijson.Field + Wordpress apijson.Field + WpPlugin apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesAutomaticPlatformOptimization) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesAutomaticPlatformOptimizationJSON) RawJSON() string { + return r.raw +} + +type ZonesAutomaticPlatformOptimizationParam struct { + // Indicates whether or not + // [cache by device type](https://developers.cloudflare.com/automatic-platform-optimization/reference/cache-device-type/) + // is enabled. + CacheByDeviceType param.Field[bool] `json:"cache_by_device_type,required"` + // Indicates whether or not Cloudflare proxy is enabled. + Cf param.Field[bool] `json:"cf,required"` + // Indicates whether or not Automatic Platform Optimization is enabled. + Enabled param.Field[bool] `json:"enabled,required"` + // An array of hostnames where Automatic Platform Optimization for WordPress is + // activated. + Hostnames param.Field[[]string] `json:"hostnames,required" format:"hostname"` + // Indicates whether or not site is powered by WordPress. + Wordpress param.Field[bool] `json:"wordpress,required"` + // Indicates whether or not + // [Cloudflare for WordPress plugin](https://wordpress.org/plugins/cloudflare/) is + // installed. + WpPlugin param.Field[bool] `json:"wp_plugin,required"` +} + +func (r ZonesAutomaticPlatformOptimizationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingAutomaticPlatformOptimizationEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Value param.Field[ZonesAutomaticPlatformOptimizationParam] `json:"value,required"` +} + +func (r SettingAutomaticPlatformOptimizationEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingAutomaticPlatformOptimizationEditResponseEnvelope struct { + Errors []SettingAutomaticPlatformOptimizationEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingAutomaticPlatformOptimizationEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + Result ZonesAutomaticPlatformOptimization `json:"result"` + JSON settingAutomaticPlatformOptimizationEditResponseEnvelopeJSON `json:"-"` +} + +// settingAutomaticPlatformOptimizationEditResponseEnvelopeJSON contains the JSON +// metadata for the struct +// [SettingAutomaticPlatformOptimizationEditResponseEnvelope] +type settingAutomaticPlatformOptimizationEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAutomaticPlatformOptimizationEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAutomaticPlatformOptimizationEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingAutomaticPlatformOptimizationEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingAutomaticPlatformOptimizationEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingAutomaticPlatformOptimizationEditResponseEnvelopeErrorsJSON contains the +// JSON metadata for the struct +// [SettingAutomaticPlatformOptimizationEditResponseEnvelopeErrors] +type settingAutomaticPlatformOptimizationEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAutomaticPlatformOptimizationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAutomaticPlatformOptimizationEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingAutomaticPlatformOptimizationEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingAutomaticPlatformOptimizationEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingAutomaticPlatformOptimizationEditResponseEnvelopeMessagesJSON contains +// the JSON metadata for the struct +// [SettingAutomaticPlatformOptimizationEditResponseEnvelopeMessages] +type settingAutomaticPlatformOptimizationEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAutomaticPlatformOptimizationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAutomaticPlatformOptimizationEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingAutomaticPlatformOptimizationGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingAutomaticPlatformOptimizationGetResponseEnvelope struct { + Errors []SettingAutomaticPlatformOptimizationGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingAutomaticPlatformOptimizationGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + Result ZonesAutomaticPlatformOptimization `json:"result"` + JSON settingAutomaticPlatformOptimizationGetResponseEnvelopeJSON `json:"-"` +} + +// settingAutomaticPlatformOptimizationGetResponseEnvelopeJSON contains the JSON +// metadata for the struct +// [SettingAutomaticPlatformOptimizationGetResponseEnvelope] +type settingAutomaticPlatformOptimizationGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAutomaticPlatformOptimizationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAutomaticPlatformOptimizationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingAutomaticPlatformOptimizationGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingAutomaticPlatformOptimizationGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingAutomaticPlatformOptimizationGetResponseEnvelopeErrorsJSON contains the +// JSON metadata for the struct +// [SettingAutomaticPlatformOptimizationGetResponseEnvelopeErrors] +type settingAutomaticPlatformOptimizationGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAutomaticPlatformOptimizationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAutomaticPlatformOptimizationGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingAutomaticPlatformOptimizationGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingAutomaticPlatformOptimizationGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingAutomaticPlatformOptimizationGetResponseEnvelopeMessagesJSON contains the +// JSON metadata for the struct +// [SettingAutomaticPlatformOptimizationGetResponseEnvelopeMessages] +type settingAutomaticPlatformOptimizationGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingAutomaticPlatformOptimizationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingAutomaticPlatformOptimizationGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingautomaticplatformoptimization_test.go b/zones/settingautomaticplatformoptimization_test.go new file mode 100644 index 00000000000..085dae88791 --- /dev/null +++ b/zones/settingautomaticplatformoptimization_test.go @@ -0,0 +1,75 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingAutomaticPlatformOptimizationEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.AutomaticPlatformOptimization.Edit(context.TODO(), zones.SettingAutomaticPlatformOptimizationEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.ZonesAutomaticPlatformOptimizationParam{ + CacheByDeviceType: cloudflare.F(false), + Cf: cloudflare.F(true), + Enabled: cloudflare.F(true), + Hostnames: cloudflare.F([]string{"www.example.com", "example.com", "shop.example.com"}), + Wordpress: cloudflare.F(true), + WpPlugin: cloudflare.F(true), + }), + }) + 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 TestSettingAutomaticPlatformOptimizationGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.AutomaticPlatformOptimization.Get(context.TODO(), zones.SettingAutomaticPlatformOptimizationGetParams{ + ZoneID: cloudflare.F("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/zones/settingbrotli.go b/zones/settingbrotli.go new file mode 100644 index 00000000000..eb3d97ac0d6 --- /dev/null +++ b/zones/settingbrotli.go @@ -0,0 +1,313 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingBrotliService 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 [NewSettingBrotliService] method +// instead. +type SettingBrotliService struct { + Options []option.RequestOption +} + +// NewSettingBrotliService 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 NewSettingBrotliService(opts ...option.RequestOption) (r *SettingBrotliService) { + r = &SettingBrotliService{} + r.Options = opts + return +} + +// When the client requesting an asset supports the Brotli compression algorithm, +// Cloudflare will serve a Brotli compressed version of the asset. +func (r *SettingBrotliService) Edit(ctx context.Context, params SettingBrotliEditParams, opts ...option.RequestOption) (res *ZonesBrotli, err error) { + opts = append(r.Options[:], opts...) + var env SettingBrotliEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/brotli", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// When the client requesting an asset supports the Brotli compression algorithm, +// Cloudflare will serve a Brotli compressed version of the asset. +func (r *SettingBrotliService) Get(ctx context.Context, query SettingBrotliGetParams, opts ...option.RequestOption) (res *ZonesBrotli, err error) { + opts = append(r.Options[:], opts...) + var env SettingBrotliGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/brotli", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// When the client requesting an asset supports the Brotli compression algorithm, +// Cloudflare will serve a Brotli compressed version of the asset. +type ZonesBrotli struct { + // ID of the zone setting. + ID ZonesBrotliID `json:"id,required"` + // Current value of the zone setting. + Value ZonesBrotliValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesBrotliEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesBrotliJSON `json:"-"` +} + +// zonesBrotliJSON contains the JSON metadata for the struct [ZonesBrotli] +type zonesBrotliJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesBrotli) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesBrotliJSON) RawJSON() string { + return r.raw +} + +func (r ZonesBrotli) implementsZonesSettingEditResponse() {} + +func (r ZonesBrotli) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesBrotliID string + +const ( + ZonesBrotliIDBrotli ZonesBrotliID = "brotli" +) + +// Current value of the zone setting. +type ZonesBrotliValue string + +const ( + ZonesBrotliValueOff ZonesBrotliValue = "off" + ZonesBrotliValueOn ZonesBrotliValue = "on" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesBrotliEditable bool + +const ( + ZonesBrotliEditableTrue ZonesBrotliEditable = true + ZonesBrotliEditableFalse ZonesBrotliEditable = false +) + +// When the client requesting an asset supports the Brotli compression algorithm, +// Cloudflare will serve a Brotli compressed version of the asset. +type ZonesBrotliParam struct { + // ID of the zone setting. + ID param.Field[ZonesBrotliID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesBrotliValue] `json:"value,required"` +} + +func (r ZonesBrotliParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesBrotliParam) implementsZonesSettingEditParamsItem() {} + +type SettingBrotliEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingBrotliEditParamsValue] `json:"value,required"` +} + +func (r SettingBrotliEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingBrotliEditParamsValue string + +const ( + SettingBrotliEditParamsValueOff SettingBrotliEditParamsValue = "off" + SettingBrotliEditParamsValueOn SettingBrotliEditParamsValue = "on" +) + +type SettingBrotliEditResponseEnvelope struct { + Errors []SettingBrotliEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingBrotliEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // When the client requesting an asset supports the Brotli compression algorithm, + // Cloudflare will serve a Brotli compressed version of the asset. + Result ZonesBrotli `json:"result"` + JSON settingBrotliEditResponseEnvelopeJSON `json:"-"` +} + +// settingBrotliEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingBrotliEditResponseEnvelope] +type settingBrotliEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingBrotliEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingBrotliEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingBrotliEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingBrotliEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingBrotliEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingBrotliEditResponseEnvelopeErrors] +type settingBrotliEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingBrotliEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingBrotliEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingBrotliEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingBrotliEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingBrotliEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingBrotliEditResponseEnvelopeMessages] +type settingBrotliEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingBrotliEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingBrotliEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingBrotliGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingBrotliGetResponseEnvelope struct { + Errors []SettingBrotliGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingBrotliGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // When the client requesting an asset supports the Brotli compression algorithm, + // Cloudflare will serve a Brotli compressed version of the asset. + Result ZonesBrotli `json:"result"` + JSON settingBrotliGetResponseEnvelopeJSON `json:"-"` +} + +// settingBrotliGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingBrotliGetResponseEnvelope] +type settingBrotliGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingBrotliGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingBrotliGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingBrotliGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingBrotliGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingBrotliGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingBrotliGetResponseEnvelopeErrors] +type settingBrotliGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingBrotliGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingBrotliGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingBrotliGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingBrotliGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingBrotliGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingBrotliGetResponseEnvelopeMessages] +type settingBrotliGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingBrotliGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingBrotliGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingbrotli_test.go b/zones/settingbrotli_test.go new file mode 100644 index 00000000000..4f8062337ef --- /dev/null +++ b/zones/settingbrotli_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingBrotliEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.Brotli.Edit(context.TODO(), zones.SettingBrotliEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingBrotliEditParamsValueOff), + }) + 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 TestSettingBrotliGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.Brotli.Get(context.TODO(), zones.SettingBrotliGetParams{ + ZoneID: cloudflare.F("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/zones/settingbrowsercachettl.go b/zones/settingbrowsercachettl.go new file mode 100644 index 00000000000..48ad4b4327a --- /dev/null +++ b/zones/settingbrowsercachettl.go @@ -0,0 +1,380 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingBrowserCacheTTLService 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 [NewSettingBrowserCacheTTLService] +// method instead. +type SettingBrowserCacheTTLService struct { + Options []option.RequestOption +} + +// NewSettingBrowserCacheTTLService 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 NewSettingBrowserCacheTTLService(opts ...option.RequestOption) (r *SettingBrowserCacheTTLService) { + r = &SettingBrowserCacheTTLService{} + r.Options = opts + return +} + +// Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources +// will remain on your visitors' computers. Cloudflare will honor any larger times +// specified by your server. +// (https://support.cloudflare.com/hc/en-us/articles/200168276). +func (r *SettingBrowserCacheTTLService) Edit(ctx context.Context, params SettingBrowserCacheTTLEditParams, opts ...option.RequestOption) (res *ZonesBrowserCacheTTL, err error) { + opts = append(r.Options[:], opts...) + var env SettingBrowserCacheTTLEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/browser_cache_ttl", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources +// will remain on your visitors' computers. Cloudflare will honor any larger times +// specified by your server. +// (https://support.cloudflare.com/hc/en-us/articles/200168276). +func (r *SettingBrowserCacheTTLService) Get(ctx context.Context, query SettingBrowserCacheTTLGetParams, opts ...option.RequestOption) (res *ZonesBrowserCacheTTL, err error) { + opts = append(r.Options[:], opts...) + var env SettingBrowserCacheTTLGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/browser_cache_ttl", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources +// will remain on your visitors' computers. Cloudflare will honor any larger times +// specified by your server. +// (https://support.cloudflare.com/hc/en-us/articles/200168276). +type ZonesBrowserCacheTTL struct { + // ID of the zone setting. + ID ZonesBrowserCacheTTLID `json:"id,required"` + // Current value of the zone setting. + Value ZonesBrowserCacheTTLValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesBrowserCacheTTLEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesBrowserCacheTTLJSON `json:"-"` +} + +// zonesBrowserCacheTTLJSON contains the JSON metadata for the struct +// [ZonesBrowserCacheTTL] +type zonesBrowserCacheTTLJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesBrowserCacheTTL) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesBrowserCacheTTLJSON) RawJSON() string { + return r.raw +} + +func (r ZonesBrowserCacheTTL) implementsZonesSettingEditResponse() {} + +func (r ZonesBrowserCacheTTL) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesBrowserCacheTTLID string + +const ( + ZonesBrowserCacheTTLIDBrowserCacheTTL ZonesBrowserCacheTTLID = "browser_cache_ttl" +) + +// Current value of the zone setting. +type ZonesBrowserCacheTTLValue float64 + +const ( + ZonesBrowserCacheTTLValue0 ZonesBrowserCacheTTLValue = 0 + ZonesBrowserCacheTTLValue30 ZonesBrowserCacheTTLValue = 30 + ZonesBrowserCacheTTLValue60 ZonesBrowserCacheTTLValue = 60 + ZonesBrowserCacheTTLValue120 ZonesBrowserCacheTTLValue = 120 + ZonesBrowserCacheTTLValue300 ZonesBrowserCacheTTLValue = 300 + ZonesBrowserCacheTTLValue1200 ZonesBrowserCacheTTLValue = 1200 + ZonesBrowserCacheTTLValue1800 ZonesBrowserCacheTTLValue = 1800 + ZonesBrowserCacheTTLValue3600 ZonesBrowserCacheTTLValue = 3600 + ZonesBrowserCacheTTLValue7200 ZonesBrowserCacheTTLValue = 7200 + ZonesBrowserCacheTTLValue10800 ZonesBrowserCacheTTLValue = 10800 + ZonesBrowserCacheTTLValue14400 ZonesBrowserCacheTTLValue = 14400 + ZonesBrowserCacheTTLValue18000 ZonesBrowserCacheTTLValue = 18000 + ZonesBrowserCacheTTLValue28800 ZonesBrowserCacheTTLValue = 28800 + ZonesBrowserCacheTTLValue43200 ZonesBrowserCacheTTLValue = 43200 + ZonesBrowserCacheTTLValue57600 ZonesBrowserCacheTTLValue = 57600 + ZonesBrowserCacheTTLValue72000 ZonesBrowserCacheTTLValue = 72000 + ZonesBrowserCacheTTLValue86400 ZonesBrowserCacheTTLValue = 86400 + ZonesBrowserCacheTTLValue172800 ZonesBrowserCacheTTLValue = 172800 + ZonesBrowserCacheTTLValue259200 ZonesBrowserCacheTTLValue = 259200 + ZonesBrowserCacheTTLValue345600 ZonesBrowserCacheTTLValue = 345600 + ZonesBrowserCacheTTLValue432000 ZonesBrowserCacheTTLValue = 432000 + ZonesBrowserCacheTTLValue691200 ZonesBrowserCacheTTLValue = 691200 + ZonesBrowserCacheTTLValue1382400 ZonesBrowserCacheTTLValue = 1382400 + ZonesBrowserCacheTTLValue2073600 ZonesBrowserCacheTTLValue = 2073600 + ZonesBrowserCacheTTLValue2678400 ZonesBrowserCacheTTLValue = 2678400 + ZonesBrowserCacheTTLValue5356800 ZonesBrowserCacheTTLValue = 5356800 + ZonesBrowserCacheTTLValue16070400 ZonesBrowserCacheTTLValue = 16070400 + ZonesBrowserCacheTTLValue31536000 ZonesBrowserCacheTTLValue = 31536000 +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesBrowserCacheTTLEditable bool + +const ( + ZonesBrowserCacheTTLEditableTrue ZonesBrowserCacheTTLEditable = true + ZonesBrowserCacheTTLEditableFalse ZonesBrowserCacheTTLEditable = false +) + +// Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources +// will remain on your visitors' computers. Cloudflare will honor any larger times +// specified by your server. +// (https://support.cloudflare.com/hc/en-us/articles/200168276). +type ZonesBrowserCacheTTLParam struct { + // ID of the zone setting. + ID param.Field[ZonesBrowserCacheTTLID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesBrowserCacheTTLValue] `json:"value,required"` +} + +func (r ZonesBrowserCacheTTLParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesBrowserCacheTTLParam) implementsZonesSettingEditParamsItem() {} + +type SettingBrowserCacheTTLEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. Notes: Setting a TTL of 0 is equivalent to selecting + // `Respect Existing Headers` + Value param.Field[SettingBrowserCacheTTLEditParamsValue] `json:"value,required"` +} + +func (r SettingBrowserCacheTTLEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. Notes: Setting a TTL of 0 is equivalent to selecting +// `Respect Existing Headers` +type SettingBrowserCacheTTLEditParamsValue float64 + +const ( + SettingBrowserCacheTTLEditParamsValue0 SettingBrowserCacheTTLEditParamsValue = 0 + SettingBrowserCacheTTLEditParamsValue30 SettingBrowserCacheTTLEditParamsValue = 30 + SettingBrowserCacheTTLEditParamsValue60 SettingBrowserCacheTTLEditParamsValue = 60 + SettingBrowserCacheTTLEditParamsValue120 SettingBrowserCacheTTLEditParamsValue = 120 + SettingBrowserCacheTTLEditParamsValue300 SettingBrowserCacheTTLEditParamsValue = 300 + SettingBrowserCacheTTLEditParamsValue1200 SettingBrowserCacheTTLEditParamsValue = 1200 + SettingBrowserCacheTTLEditParamsValue1800 SettingBrowserCacheTTLEditParamsValue = 1800 + SettingBrowserCacheTTLEditParamsValue3600 SettingBrowserCacheTTLEditParamsValue = 3600 + SettingBrowserCacheTTLEditParamsValue7200 SettingBrowserCacheTTLEditParamsValue = 7200 + SettingBrowserCacheTTLEditParamsValue10800 SettingBrowserCacheTTLEditParamsValue = 10800 + SettingBrowserCacheTTLEditParamsValue14400 SettingBrowserCacheTTLEditParamsValue = 14400 + SettingBrowserCacheTTLEditParamsValue18000 SettingBrowserCacheTTLEditParamsValue = 18000 + SettingBrowserCacheTTLEditParamsValue28800 SettingBrowserCacheTTLEditParamsValue = 28800 + SettingBrowserCacheTTLEditParamsValue43200 SettingBrowserCacheTTLEditParamsValue = 43200 + SettingBrowserCacheTTLEditParamsValue57600 SettingBrowserCacheTTLEditParamsValue = 57600 + SettingBrowserCacheTTLEditParamsValue72000 SettingBrowserCacheTTLEditParamsValue = 72000 + SettingBrowserCacheTTLEditParamsValue86400 SettingBrowserCacheTTLEditParamsValue = 86400 + SettingBrowserCacheTTLEditParamsValue172800 SettingBrowserCacheTTLEditParamsValue = 172800 + SettingBrowserCacheTTLEditParamsValue259200 SettingBrowserCacheTTLEditParamsValue = 259200 + SettingBrowserCacheTTLEditParamsValue345600 SettingBrowserCacheTTLEditParamsValue = 345600 + SettingBrowserCacheTTLEditParamsValue432000 SettingBrowserCacheTTLEditParamsValue = 432000 + SettingBrowserCacheTTLEditParamsValue691200 SettingBrowserCacheTTLEditParamsValue = 691200 + SettingBrowserCacheTTLEditParamsValue1382400 SettingBrowserCacheTTLEditParamsValue = 1382400 + SettingBrowserCacheTTLEditParamsValue2073600 SettingBrowserCacheTTLEditParamsValue = 2073600 + SettingBrowserCacheTTLEditParamsValue2678400 SettingBrowserCacheTTLEditParamsValue = 2678400 + SettingBrowserCacheTTLEditParamsValue5356800 SettingBrowserCacheTTLEditParamsValue = 5356800 + SettingBrowserCacheTTLEditParamsValue16070400 SettingBrowserCacheTTLEditParamsValue = 16070400 + SettingBrowserCacheTTLEditParamsValue31536000 SettingBrowserCacheTTLEditParamsValue = 31536000 +) + +type SettingBrowserCacheTTLEditResponseEnvelope struct { + Errors []SettingBrowserCacheTTLEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingBrowserCacheTTLEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources + // will remain on your visitors' computers. Cloudflare will honor any larger times + // specified by your server. + // (https://support.cloudflare.com/hc/en-us/articles/200168276). + Result ZonesBrowserCacheTTL `json:"result"` + JSON settingBrowserCacheTTLEditResponseEnvelopeJSON `json:"-"` +} + +// settingBrowserCacheTTLEditResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingBrowserCacheTTLEditResponseEnvelope] +type settingBrowserCacheTTLEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingBrowserCacheTTLEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingBrowserCacheTTLEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingBrowserCacheTTLEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingBrowserCacheTTLEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingBrowserCacheTTLEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingBrowserCacheTTLEditResponseEnvelopeErrors] +type settingBrowserCacheTTLEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingBrowserCacheTTLEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingBrowserCacheTTLEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingBrowserCacheTTLEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingBrowserCacheTTLEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingBrowserCacheTTLEditResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingBrowserCacheTTLEditResponseEnvelopeMessages] +type settingBrowserCacheTTLEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingBrowserCacheTTLEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingBrowserCacheTTLEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingBrowserCacheTTLGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingBrowserCacheTTLGetResponseEnvelope struct { + Errors []SettingBrowserCacheTTLGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingBrowserCacheTTLGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources + // will remain on your visitors' computers. Cloudflare will honor any larger times + // specified by your server. + // (https://support.cloudflare.com/hc/en-us/articles/200168276). + Result ZonesBrowserCacheTTL `json:"result"` + JSON settingBrowserCacheTTLGetResponseEnvelopeJSON `json:"-"` +} + +// settingBrowserCacheTTLGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingBrowserCacheTTLGetResponseEnvelope] +type settingBrowserCacheTTLGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingBrowserCacheTTLGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingBrowserCacheTTLGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingBrowserCacheTTLGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingBrowserCacheTTLGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingBrowserCacheTTLGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingBrowserCacheTTLGetResponseEnvelopeErrors] +type settingBrowserCacheTTLGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingBrowserCacheTTLGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingBrowserCacheTTLGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingBrowserCacheTTLGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingBrowserCacheTTLGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingBrowserCacheTTLGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingBrowserCacheTTLGetResponseEnvelopeMessages] +type settingBrowserCacheTTLGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingBrowserCacheTTLGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingBrowserCacheTTLGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingbrowsercachettl_test.go b/zones/settingbrowsercachettl_test.go new file mode 100644 index 00000000000..5855a1d16b7 --- /dev/null +++ b/zones/settingbrowsercachettl_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingBrowserCacheTTLEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.BrowserCacheTTL.Edit(context.TODO(), zones.SettingBrowserCacheTTLEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingBrowserCacheTTLEditParamsValue0), + }) + 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 TestSettingBrowserCacheTTLGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.BrowserCacheTTL.Get(context.TODO(), zones.SettingBrowserCacheTTLGetParams{ + ZoneID: cloudflare.F("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/zones/settingbrowsercheck.go b/zones/settingbrowsercheck.go new file mode 100644 index 00000000000..f0853fceb03 --- /dev/null +++ b/zones/settingbrowsercheck.go @@ -0,0 +1,332 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingBrowserCheckService 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 [NewSettingBrowserCheckService] +// method instead. +type SettingBrowserCheckService struct { + Options []option.RequestOption +} + +// NewSettingBrowserCheckService 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 NewSettingBrowserCheckService(opts ...option.RequestOption) (r *SettingBrowserCheckService) { + r = &SettingBrowserCheckService{} + r.Options = opts + return +} + +// Browser Integrity Check is similar to Bad Behavior and looks for common HTTP +// headers abused most commonly by spammers and denies access to your page. It will +// also challenge visitors that do not have a user agent or a non standard user +// agent (also commonly used by abuse bots, crawlers or visitors). +// (https://support.cloudflare.com/hc/en-us/articles/200170086). +func (r *SettingBrowserCheckService) Edit(ctx context.Context, params SettingBrowserCheckEditParams, opts ...option.RequestOption) (res *ZonesBrowserCheck, err error) { + opts = append(r.Options[:], opts...) + var env SettingBrowserCheckEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/browser_check", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Browser Integrity Check is similar to Bad Behavior and looks for common HTTP +// headers abused most commonly by spammers and denies access to your page. It will +// also challenge visitors that do not have a user agent or a non standard user +// agent (also commonly used by abuse bots, crawlers or visitors). +// (https://support.cloudflare.com/hc/en-us/articles/200170086). +func (r *SettingBrowserCheckService) Get(ctx context.Context, query SettingBrowserCheckGetParams, opts ...option.RequestOption) (res *ZonesBrowserCheck, err error) { + opts = append(r.Options[:], opts...) + var env SettingBrowserCheckGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/browser_check", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Browser Integrity Check is similar to Bad Behavior and looks for common HTTP +// headers abused most commonly by spammers and denies access to your page. It will +// also challenge visitors that do not have a user agent or a non standard user +// agent (also commonly used by abuse bots, crawlers or visitors). +// (https://support.cloudflare.com/hc/en-us/articles/200170086). +type ZonesBrowserCheck struct { + // ID of the zone setting. + ID ZonesBrowserCheckID `json:"id,required"` + // Current value of the zone setting. + Value ZonesBrowserCheckValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesBrowserCheckEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesBrowserCheckJSON `json:"-"` +} + +// zonesBrowserCheckJSON contains the JSON metadata for the struct +// [ZonesBrowserCheck] +type zonesBrowserCheckJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesBrowserCheck) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesBrowserCheckJSON) RawJSON() string { + return r.raw +} + +func (r ZonesBrowserCheck) implementsZonesSettingEditResponse() {} + +func (r ZonesBrowserCheck) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesBrowserCheckID string + +const ( + ZonesBrowserCheckIDBrowserCheck ZonesBrowserCheckID = "browser_check" +) + +// Current value of the zone setting. +type ZonesBrowserCheckValue string + +const ( + ZonesBrowserCheckValueOn ZonesBrowserCheckValue = "on" + ZonesBrowserCheckValueOff ZonesBrowserCheckValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesBrowserCheckEditable bool + +const ( + ZonesBrowserCheckEditableTrue ZonesBrowserCheckEditable = true + ZonesBrowserCheckEditableFalse ZonesBrowserCheckEditable = false +) + +// Browser Integrity Check is similar to Bad Behavior and looks for common HTTP +// headers abused most commonly by spammers and denies access to your page. It will +// also challenge visitors that do not have a user agent or a non standard user +// agent (also commonly used by abuse bots, crawlers or visitors). +// (https://support.cloudflare.com/hc/en-us/articles/200170086). +type ZonesBrowserCheckParam struct { + // ID of the zone setting. + ID param.Field[ZonesBrowserCheckID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesBrowserCheckValue] `json:"value,required"` +} + +func (r ZonesBrowserCheckParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesBrowserCheckParam) implementsZonesSettingEditParamsItem() {} + +type SettingBrowserCheckEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingBrowserCheckEditParamsValue] `json:"value,required"` +} + +func (r SettingBrowserCheckEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingBrowserCheckEditParamsValue string + +const ( + SettingBrowserCheckEditParamsValueOn SettingBrowserCheckEditParamsValue = "on" + SettingBrowserCheckEditParamsValueOff SettingBrowserCheckEditParamsValue = "off" +) + +type SettingBrowserCheckEditResponseEnvelope struct { + Errors []SettingBrowserCheckEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingBrowserCheckEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Browser Integrity Check is similar to Bad Behavior and looks for common HTTP + // headers abused most commonly by spammers and denies access to your page. It will + // also challenge visitors that do not have a user agent or a non standard user + // agent (also commonly used by abuse bots, crawlers or visitors). + // (https://support.cloudflare.com/hc/en-us/articles/200170086). + Result ZonesBrowserCheck `json:"result"` + JSON settingBrowserCheckEditResponseEnvelopeJSON `json:"-"` +} + +// settingBrowserCheckEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingBrowserCheckEditResponseEnvelope] +type settingBrowserCheckEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingBrowserCheckEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingBrowserCheckEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingBrowserCheckEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingBrowserCheckEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingBrowserCheckEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingBrowserCheckEditResponseEnvelopeErrors] +type settingBrowserCheckEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingBrowserCheckEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingBrowserCheckEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingBrowserCheckEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingBrowserCheckEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingBrowserCheckEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingBrowserCheckEditResponseEnvelopeMessages] +type settingBrowserCheckEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingBrowserCheckEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingBrowserCheckEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingBrowserCheckGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingBrowserCheckGetResponseEnvelope struct { + Errors []SettingBrowserCheckGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingBrowserCheckGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Browser Integrity Check is similar to Bad Behavior and looks for common HTTP + // headers abused most commonly by spammers and denies access to your page. It will + // also challenge visitors that do not have a user agent or a non standard user + // agent (also commonly used by abuse bots, crawlers or visitors). + // (https://support.cloudflare.com/hc/en-us/articles/200170086). + Result ZonesBrowserCheck `json:"result"` + JSON settingBrowserCheckGetResponseEnvelopeJSON `json:"-"` +} + +// settingBrowserCheckGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingBrowserCheckGetResponseEnvelope] +type settingBrowserCheckGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingBrowserCheckGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingBrowserCheckGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingBrowserCheckGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingBrowserCheckGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingBrowserCheckGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingBrowserCheckGetResponseEnvelopeErrors] +type settingBrowserCheckGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingBrowserCheckGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingBrowserCheckGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingBrowserCheckGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingBrowserCheckGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingBrowserCheckGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingBrowserCheckGetResponseEnvelopeMessages] +type settingBrowserCheckGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingBrowserCheckGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingBrowserCheckGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingbrowsercheck_test.go b/zones/settingbrowsercheck_test.go new file mode 100644 index 00000000000..b44216d60e6 --- /dev/null +++ b/zones/settingbrowsercheck_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingBrowserCheckEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.BrowserCheck.Edit(context.TODO(), zones.SettingBrowserCheckEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingBrowserCheckEditParamsValueOn), + }) + 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 TestSettingBrowserCheckGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.BrowserCheck.Get(context.TODO(), zones.SettingBrowserCheckGetParams{ + ZoneID: cloudflare.F("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/zones/settingcachelevel.go b/zones/settingcachelevel.go new file mode 100644 index 00000000000..448712b858e --- /dev/null +++ b/zones/settingcachelevel.go @@ -0,0 +1,333 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingCacheLevelService 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 [NewSettingCacheLevelService] method +// instead. +type SettingCacheLevelService struct { + Options []option.RequestOption +} + +// NewSettingCacheLevelService 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 NewSettingCacheLevelService(opts ...option.RequestOption) (r *SettingCacheLevelService) { + r = &SettingCacheLevelService{} + r.Options = opts + return +} + +// Cache Level functions based off the setting level. The basic setting will cache +// most static resources (i.e., css, images, and JavaScript). The simplified +// setting will ignore the query string when delivering a cached resource. The +// aggressive setting will cache all static resources, including ones with a query +// string. (https://support.cloudflare.com/hc/en-us/articles/200168256). +func (r *SettingCacheLevelService) Edit(ctx context.Context, params SettingCacheLevelEditParams, opts ...option.RequestOption) (res *ZonesCacheLevel, err error) { + opts = append(r.Options[:], opts...) + var env SettingCacheLevelEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/cache_level", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Cache Level functions based off the setting level. The basic setting will cache +// most static resources (i.e., css, images, and JavaScript). The simplified +// setting will ignore the query string when delivering a cached resource. The +// aggressive setting will cache all static resources, including ones with a query +// string. (https://support.cloudflare.com/hc/en-us/articles/200168256). +func (r *SettingCacheLevelService) Get(ctx context.Context, query SettingCacheLevelGetParams, opts ...option.RequestOption) (res *ZonesCacheLevel, err error) { + opts = append(r.Options[:], opts...) + var env SettingCacheLevelGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/cache_level", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Cache Level functions based off the setting level. The basic setting will cache +// most static resources (i.e., css, images, and JavaScript). The simplified +// setting will ignore the query string when delivering a cached resource. The +// aggressive setting will cache all static resources, including ones with a query +// string. (https://support.cloudflare.com/hc/en-us/articles/200168256). +type ZonesCacheLevel struct { + // ID of the zone setting. + ID ZonesCacheLevelID `json:"id,required"` + // Current value of the zone setting. + Value ZonesCacheLevelValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesCacheLevelEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesCacheLevelJSON `json:"-"` +} + +// zonesCacheLevelJSON contains the JSON metadata for the struct [ZonesCacheLevel] +type zonesCacheLevelJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesCacheLevel) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesCacheLevelJSON) RawJSON() string { + return r.raw +} + +func (r ZonesCacheLevel) implementsZonesSettingEditResponse() {} + +func (r ZonesCacheLevel) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesCacheLevelID string + +const ( + ZonesCacheLevelIDCacheLevel ZonesCacheLevelID = "cache_level" +) + +// Current value of the zone setting. +type ZonesCacheLevelValue string + +const ( + ZonesCacheLevelValueAggressive ZonesCacheLevelValue = "aggressive" + ZonesCacheLevelValueBasic ZonesCacheLevelValue = "basic" + ZonesCacheLevelValueSimplified ZonesCacheLevelValue = "simplified" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesCacheLevelEditable bool + +const ( + ZonesCacheLevelEditableTrue ZonesCacheLevelEditable = true + ZonesCacheLevelEditableFalse ZonesCacheLevelEditable = false +) + +// Cache Level functions based off the setting level. The basic setting will cache +// most static resources (i.e., css, images, and JavaScript). The simplified +// setting will ignore the query string when delivering a cached resource. The +// aggressive setting will cache all static resources, including ones with a query +// string. (https://support.cloudflare.com/hc/en-us/articles/200168256). +type ZonesCacheLevelParam struct { + // ID of the zone setting. + ID param.Field[ZonesCacheLevelID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesCacheLevelValue] `json:"value,required"` +} + +func (r ZonesCacheLevelParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesCacheLevelParam) implementsZonesSettingEditParamsItem() {} + +type SettingCacheLevelEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingCacheLevelEditParamsValue] `json:"value,required"` +} + +func (r SettingCacheLevelEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingCacheLevelEditParamsValue string + +const ( + SettingCacheLevelEditParamsValueAggressive SettingCacheLevelEditParamsValue = "aggressive" + SettingCacheLevelEditParamsValueBasic SettingCacheLevelEditParamsValue = "basic" + SettingCacheLevelEditParamsValueSimplified SettingCacheLevelEditParamsValue = "simplified" +) + +type SettingCacheLevelEditResponseEnvelope struct { + Errors []SettingCacheLevelEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingCacheLevelEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Cache Level functions based off the setting level. The basic setting will cache + // most static resources (i.e., css, images, and JavaScript). The simplified + // setting will ignore the query string when delivering a cached resource. The + // aggressive setting will cache all static resources, including ones with a query + // string. (https://support.cloudflare.com/hc/en-us/articles/200168256). + Result ZonesCacheLevel `json:"result"` + JSON settingCacheLevelEditResponseEnvelopeJSON `json:"-"` +} + +// settingCacheLevelEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingCacheLevelEditResponseEnvelope] +type settingCacheLevelEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingCacheLevelEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingCacheLevelEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingCacheLevelEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingCacheLevelEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingCacheLevelEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingCacheLevelEditResponseEnvelopeErrors] +type settingCacheLevelEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingCacheLevelEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingCacheLevelEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingCacheLevelEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingCacheLevelEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingCacheLevelEditResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [SettingCacheLevelEditResponseEnvelopeMessages] +type settingCacheLevelEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingCacheLevelEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingCacheLevelEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingCacheLevelGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingCacheLevelGetResponseEnvelope struct { + Errors []SettingCacheLevelGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingCacheLevelGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Cache Level functions based off the setting level. The basic setting will cache + // most static resources (i.e., css, images, and JavaScript). The simplified + // setting will ignore the query string when delivering a cached resource. The + // aggressive setting will cache all static resources, including ones with a query + // string. (https://support.cloudflare.com/hc/en-us/articles/200168256). + Result ZonesCacheLevel `json:"result"` + JSON settingCacheLevelGetResponseEnvelopeJSON `json:"-"` +} + +// settingCacheLevelGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingCacheLevelGetResponseEnvelope] +type settingCacheLevelGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingCacheLevelGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingCacheLevelGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingCacheLevelGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingCacheLevelGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingCacheLevelGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingCacheLevelGetResponseEnvelopeErrors] +type settingCacheLevelGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingCacheLevelGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingCacheLevelGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingCacheLevelGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingCacheLevelGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingCacheLevelGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [SettingCacheLevelGetResponseEnvelopeMessages] +type settingCacheLevelGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingCacheLevelGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingCacheLevelGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingcachelevel_test.go b/zones/settingcachelevel_test.go new file mode 100644 index 00000000000..0d11ab1d4f3 --- /dev/null +++ b/zones/settingcachelevel_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingCacheLevelEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.CacheLevel.Edit(context.TODO(), zones.SettingCacheLevelEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingCacheLevelEditParamsValueAggressive), + }) + 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 TestSettingCacheLevelGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.CacheLevel.Get(context.TODO(), zones.SettingCacheLevelGetParams{ + ZoneID: cloudflare.F("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/zones/settingchallengettl.go b/zones/settingchallengettl.go new file mode 100644 index 00000000000..ebb176e5b03 --- /dev/null +++ b/zones/settingchallengettl.go @@ -0,0 +1,356 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingChallengeTTLService 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 [NewSettingChallengeTTLService] +// method instead. +type SettingChallengeTTLService struct { + Options []option.RequestOption +} + +// NewSettingChallengeTTLService 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 NewSettingChallengeTTLService(opts ...option.RequestOption) (r *SettingChallengeTTLService) { + r = &SettingChallengeTTLService{} + r.Options = opts + return +} + +// Specify how long a visitor is allowed access to your site after successfully +// completing a challenge (such as a CAPTCHA). After the TTL has expired the +// visitor will have to complete a new challenge. We recommend a 15 - 45 minute +// setting and will attempt to honor any setting above 45 minutes. +// (https://support.cloudflare.com/hc/en-us/articles/200170136). +func (r *SettingChallengeTTLService) Edit(ctx context.Context, params SettingChallengeTTLEditParams, opts ...option.RequestOption) (res *ZonesChallengeTTL, err error) { + opts = append(r.Options[:], opts...) + var env SettingChallengeTTLEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/challenge_ttl", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Specify how long a visitor is allowed access to your site after successfully +// completing a challenge (such as a CAPTCHA). After the TTL has expired the +// visitor will have to complete a new challenge. We recommend a 15 - 45 minute +// setting and will attempt to honor any setting above 45 minutes. +// (https://support.cloudflare.com/hc/en-us/articles/200170136). +func (r *SettingChallengeTTLService) Get(ctx context.Context, query SettingChallengeTTLGetParams, opts ...option.RequestOption) (res *ZonesChallengeTTL, err error) { + opts = append(r.Options[:], opts...) + var env SettingChallengeTTLGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/challenge_ttl", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Specify how long a visitor is allowed access to your site after successfully +// completing a challenge (such as a CAPTCHA). After the TTL has expired the +// visitor will have to complete a new challenge. We recommend a 15 - 45 minute +// setting and will attempt to honor any setting above 45 minutes. +// (https://support.cloudflare.com/hc/en-us/articles/200170136). +type ZonesChallengeTTL struct { + // ID of the zone setting. + ID ZonesChallengeTTLID `json:"id,required"` + // Current value of the zone setting. + Value ZonesChallengeTTLValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesChallengeTTLEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesChallengeTTLJSON `json:"-"` +} + +// zonesChallengeTTLJSON contains the JSON metadata for the struct +// [ZonesChallengeTTL] +type zonesChallengeTTLJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesChallengeTTL) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesChallengeTTLJSON) RawJSON() string { + return r.raw +} + +func (r ZonesChallengeTTL) implementsZonesSettingEditResponse() {} + +func (r ZonesChallengeTTL) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesChallengeTTLID string + +const ( + ZonesChallengeTTLIDChallengeTTL ZonesChallengeTTLID = "challenge_ttl" +) + +// Current value of the zone setting. +type ZonesChallengeTTLValue float64 + +const ( + ZonesChallengeTTLValue300 ZonesChallengeTTLValue = 300 + ZonesChallengeTTLValue900 ZonesChallengeTTLValue = 900 + ZonesChallengeTTLValue1800 ZonesChallengeTTLValue = 1800 + ZonesChallengeTTLValue2700 ZonesChallengeTTLValue = 2700 + ZonesChallengeTTLValue3600 ZonesChallengeTTLValue = 3600 + ZonesChallengeTTLValue7200 ZonesChallengeTTLValue = 7200 + ZonesChallengeTTLValue10800 ZonesChallengeTTLValue = 10800 + ZonesChallengeTTLValue14400 ZonesChallengeTTLValue = 14400 + ZonesChallengeTTLValue28800 ZonesChallengeTTLValue = 28800 + ZonesChallengeTTLValue57600 ZonesChallengeTTLValue = 57600 + ZonesChallengeTTLValue86400 ZonesChallengeTTLValue = 86400 + ZonesChallengeTTLValue604800 ZonesChallengeTTLValue = 604800 + ZonesChallengeTTLValue2592000 ZonesChallengeTTLValue = 2592000 + ZonesChallengeTTLValue31536000 ZonesChallengeTTLValue = 31536000 +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesChallengeTTLEditable bool + +const ( + ZonesChallengeTTLEditableTrue ZonesChallengeTTLEditable = true + ZonesChallengeTTLEditableFalse ZonesChallengeTTLEditable = false +) + +// Specify how long a visitor is allowed access to your site after successfully +// completing a challenge (such as a CAPTCHA). After the TTL has expired the +// visitor will have to complete a new challenge. We recommend a 15 - 45 minute +// setting and will attempt to honor any setting above 45 minutes. +// (https://support.cloudflare.com/hc/en-us/articles/200170136). +type ZonesChallengeTTLParam struct { + // ID of the zone setting. + ID param.Field[ZonesChallengeTTLID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesChallengeTTLValue] `json:"value,required"` +} + +func (r ZonesChallengeTTLParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesChallengeTTLParam) implementsZonesSettingEditParamsItem() {} + +type SettingChallengeTTLEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingChallengeTTLEditParamsValue] `json:"value,required"` +} + +func (r SettingChallengeTTLEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingChallengeTTLEditParamsValue float64 + +const ( + SettingChallengeTTLEditParamsValue300 SettingChallengeTTLEditParamsValue = 300 + SettingChallengeTTLEditParamsValue900 SettingChallengeTTLEditParamsValue = 900 + SettingChallengeTTLEditParamsValue1800 SettingChallengeTTLEditParamsValue = 1800 + SettingChallengeTTLEditParamsValue2700 SettingChallengeTTLEditParamsValue = 2700 + SettingChallengeTTLEditParamsValue3600 SettingChallengeTTLEditParamsValue = 3600 + SettingChallengeTTLEditParamsValue7200 SettingChallengeTTLEditParamsValue = 7200 + SettingChallengeTTLEditParamsValue10800 SettingChallengeTTLEditParamsValue = 10800 + SettingChallengeTTLEditParamsValue14400 SettingChallengeTTLEditParamsValue = 14400 + SettingChallengeTTLEditParamsValue28800 SettingChallengeTTLEditParamsValue = 28800 + SettingChallengeTTLEditParamsValue57600 SettingChallengeTTLEditParamsValue = 57600 + SettingChallengeTTLEditParamsValue86400 SettingChallengeTTLEditParamsValue = 86400 + SettingChallengeTTLEditParamsValue604800 SettingChallengeTTLEditParamsValue = 604800 + SettingChallengeTTLEditParamsValue2592000 SettingChallengeTTLEditParamsValue = 2592000 + SettingChallengeTTLEditParamsValue31536000 SettingChallengeTTLEditParamsValue = 31536000 +) + +type SettingChallengeTTLEditResponseEnvelope struct { + Errors []SettingChallengeTTLEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingChallengeTTLEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Specify how long a visitor is allowed access to your site after successfully + // completing a challenge (such as a CAPTCHA). After the TTL has expired the + // visitor will have to complete a new challenge. We recommend a 15 - 45 minute + // setting and will attempt to honor any setting above 45 minutes. + // (https://support.cloudflare.com/hc/en-us/articles/200170136). + Result ZonesChallengeTTL `json:"result"` + JSON settingChallengeTTLEditResponseEnvelopeJSON `json:"-"` +} + +// settingChallengeTTLEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingChallengeTTLEditResponseEnvelope] +type settingChallengeTTLEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingChallengeTTLEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingChallengeTTLEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingChallengeTTLEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingChallengeTTLEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingChallengeTTLEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingChallengeTTLEditResponseEnvelopeErrors] +type settingChallengeTTLEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingChallengeTTLEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingChallengeTTLEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingChallengeTTLEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingChallengeTTLEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingChallengeTTLEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingChallengeTTLEditResponseEnvelopeMessages] +type settingChallengeTTLEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingChallengeTTLEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingChallengeTTLEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingChallengeTTLGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingChallengeTTLGetResponseEnvelope struct { + Errors []SettingChallengeTTLGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingChallengeTTLGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Specify how long a visitor is allowed access to your site after successfully + // completing a challenge (such as a CAPTCHA). After the TTL has expired the + // visitor will have to complete a new challenge. We recommend a 15 - 45 minute + // setting and will attempt to honor any setting above 45 minutes. + // (https://support.cloudflare.com/hc/en-us/articles/200170136). + Result ZonesChallengeTTL `json:"result"` + JSON settingChallengeTTLGetResponseEnvelopeJSON `json:"-"` +} + +// settingChallengeTTLGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingChallengeTTLGetResponseEnvelope] +type settingChallengeTTLGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingChallengeTTLGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingChallengeTTLGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingChallengeTTLGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingChallengeTTLGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingChallengeTTLGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingChallengeTTLGetResponseEnvelopeErrors] +type settingChallengeTTLGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingChallengeTTLGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingChallengeTTLGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingChallengeTTLGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingChallengeTTLGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingChallengeTTLGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingChallengeTTLGetResponseEnvelopeMessages] +type settingChallengeTTLGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingChallengeTTLGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingChallengeTTLGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingchallengettl_test.go b/zones/settingchallengettl_test.go new file mode 100644 index 00000000000..a6eb17c6d68 --- /dev/null +++ b/zones/settingchallengettl_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingChallengeTTLEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.ChallengeTTL.Edit(context.TODO(), zones.SettingChallengeTTLEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingChallengeTTLEditParamsValue300), + }) + 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 TestSettingChallengeTTLGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.ChallengeTTL.Get(context.TODO(), zones.SettingChallengeTTLGetParams{ + ZoneID: cloudflare.F("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/zones/settingcipher.go b/zones/settingcipher.go new file mode 100644 index 00000000000..784ad31f9d2 --- /dev/null +++ b/zones/settingcipher.go @@ -0,0 +1,295 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingCipherService 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 [NewSettingCipherService] method +// instead. +type SettingCipherService struct { + Options []option.RequestOption +} + +// NewSettingCipherService 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 NewSettingCipherService(opts ...option.RequestOption) (r *SettingCipherService) { + r = &SettingCipherService{} + r.Options = opts + return +} + +// Changes ciphers setting. +func (r *SettingCipherService) Edit(ctx context.Context, params SettingCipherEditParams, opts ...option.RequestOption) (res *ZonesCiphers, err error) { + opts = append(r.Options[:], opts...) + var env SettingCipherEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/ciphers", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets ciphers setting. +func (r *SettingCipherService) Get(ctx context.Context, query SettingCipherGetParams, opts ...option.RequestOption) (res *ZonesCiphers, err error) { + opts = append(r.Options[:], opts...) + var env SettingCipherGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/ciphers", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// An allowlist of ciphers for TLS termination. These ciphers must be in the +// BoringSSL format. +type ZonesCiphers struct { + // ID of the zone setting. + ID ZonesCiphersID `json:"id,required"` + // Current value of the zone setting. + Value []string `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesCiphersEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesCiphersJSON `json:"-"` +} + +// zonesCiphersJSON contains the JSON metadata for the struct [ZonesCiphers] +type zonesCiphersJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesCiphers) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesCiphersJSON) RawJSON() string { + return r.raw +} + +func (r ZonesCiphers) implementsZonesSettingEditResponse() {} + +func (r ZonesCiphers) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesCiphersID string + +const ( + ZonesCiphersIDCiphers ZonesCiphersID = "ciphers" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesCiphersEditable bool + +const ( + ZonesCiphersEditableTrue ZonesCiphersEditable = true + ZonesCiphersEditableFalse ZonesCiphersEditable = false +) + +// An allowlist of ciphers for TLS termination. These ciphers must be in the +// BoringSSL format. +type ZonesCiphersParam struct { + // ID of the zone setting. + ID param.Field[ZonesCiphersID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[[]string] `json:"value,required"` +} + +func (r ZonesCiphersParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesCiphersParam) implementsZonesSettingEditParamsItem() {} + +type SettingCipherEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[[]string] `json:"value,required"` +} + +func (r SettingCipherEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingCipherEditResponseEnvelope struct { + Errors []SettingCipherEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingCipherEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // An allowlist of ciphers for TLS termination. These ciphers must be in the + // BoringSSL format. + Result ZonesCiphers `json:"result"` + JSON settingCipherEditResponseEnvelopeJSON `json:"-"` +} + +// settingCipherEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingCipherEditResponseEnvelope] +type settingCipherEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingCipherEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingCipherEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingCipherEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingCipherEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingCipherEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingCipherEditResponseEnvelopeErrors] +type settingCipherEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingCipherEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingCipherEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingCipherEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingCipherEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingCipherEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingCipherEditResponseEnvelopeMessages] +type settingCipherEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingCipherEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingCipherEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingCipherGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingCipherGetResponseEnvelope struct { + Errors []SettingCipherGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingCipherGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // An allowlist of ciphers for TLS termination. These ciphers must be in the + // BoringSSL format. + Result ZonesCiphers `json:"result"` + JSON settingCipherGetResponseEnvelopeJSON `json:"-"` +} + +// settingCipherGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingCipherGetResponseEnvelope] +type settingCipherGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingCipherGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingCipherGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingCipherGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingCipherGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingCipherGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingCipherGetResponseEnvelopeErrors] +type settingCipherGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingCipherGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingCipherGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingCipherGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingCipherGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingCipherGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingCipherGetResponseEnvelopeMessages] +type settingCipherGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingCipherGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingCipherGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingcipher_test.go b/zones/settingcipher_test.go new file mode 100644 index 00000000000..58da39821a3 --- /dev/null +++ b/zones/settingcipher_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingCipherEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.Ciphers.Edit(context.TODO(), zones.SettingCipherEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F([]string{"ECDHE-RSA-AES128-GCM-SHA256", "AES128-SHA"}), + }) + 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 TestSettingCipherGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.Ciphers.Get(context.TODO(), zones.SettingCipherGetParams{ + ZoneID: cloudflare.F("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/zones/settingdevelopmentmode.go b/zones/settingdevelopmentmode.go new file mode 100644 index 00000000000..5e2da8eb777 --- /dev/null +++ b/zones/settingdevelopmentmode.go @@ -0,0 +1,343 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingDevelopmentModeService 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 [NewSettingDevelopmentModeService] +// method instead. +type SettingDevelopmentModeService struct { + Options []option.RequestOption +} + +// NewSettingDevelopmentModeService 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 NewSettingDevelopmentModeService(opts ...option.RequestOption) (r *SettingDevelopmentModeService) { + r = &SettingDevelopmentModeService{} + r.Options = opts + return +} + +// Development Mode temporarily allows you to enter development mode for your +// websites if you need to make changes to your site. This will bypass Cloudflare's +// accelerated cache and slow down your site, but is useful if you are making +// changes to cacheable content (like images, css, or JavaScript) and would like to +// see those changes right away. Once entered, development mode will last for 3 +// hours and then automatically toggle off. +func (r *SettingDevelopmentModeService) Edit(ctx context.Context, params SettingDevelopmentModeEditParams, opts ...option.RequestOption) (res *ZonesDevelopmentMode, err error) { + opts = append(r.Options[:], opts...) + var env SettingDevelopmentModeEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/development_mode", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Development Mode temporarily allows you to enter development mode for your +// websites if you need to make changes to your site. This will bypass Cloudflare's +// accelerated cache and slow down your site, but is useful if you are making +// changes to cacheable content (like images, css, or JavaScript) and would like to +// see those changes right away. Once entered, development mode will last for 3 +// hours and then automatically toggle off. +func (r *SettingDevelopmentModeService) Get(ctx context.Context, query SettingDevelopmentModeGetParams, opts ...option.RequestOption) (res *ZonesDevelopmentMode, err error) { + opts = append(r.Options[:], opts...) + var env SettingDevelopmentModeGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/development_mode", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Development Mode temporarily allows you to enter development mode for your +// websites if you need to make changes to your site. This will bypass Cloudflare's +// accelerated cache and slow down your site, but is useful if you are making +// changes to cacheable content (like images, css, or JavaScript) and would like to +// see those changes right away. Once entered, development mode will last for 3 +// hours and then automatically toggle off. +type ZonesDevelopmentMode struct { + // ID of the zone setting. + ID ZonesDevelopmentModeID `json:"id,required"` + // Current value of the zone setting. + Value ZonesDevelopmentModeValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesDevelopmentModeEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + // Value of the zone setting. Notes: The interval (in seconds) from when + // development mode expires (positive integer) or last expired (negative integer) + // for the domain. If development mode has never been enabled, this value is false. + TimeRemaining float64 `json:"time_remaining"` + JSON zonesDevelopmentModeJSON `json:"-"` +} + +// zonesDevelopmentModeJSON contains the JSON metadata for the struct +// [ZonesDevelopmentMode] +type zonesDevelopmentModeJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + TimeRemaining apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesDevelopmentMode) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesDevelopmentModeJSON) RawJSON() string { + return r.raw +} + +func (r ZonesDevelopmentMode) implementsZonesSettingEditResponse() {} + +func (r ZonesDevelopmentMode) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesDevelopmentModeID string + +const ( + ZonesDevelopmentModeIDDevelopmentMode ZonesDevelopmentModeID = "development_mode" +) + +// Current value of the zone setting. +type ZonesDevelopmentModeValue string + +const ( + ZonesDevelopmentModeValueOn ZonesDevelopmentModeValue = "on" + ZonesDevelopmentModeValueOff ZonesDevelopmentModeValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesDevelopmentModeEditable bool + +const ( + ZonesDevelopmentModeEditableTrue ZonesDevelopmentModeEditable = true + ZonesDevelopmentModeEditableFalse ZonesDevelopmentModeEditable = false +) + +// Development Mode temporarily allows you to enter development mode for your +// websites if you need to make changes to your site. This will bypass Cloudflare's +// accelerated cache and slow down your site, but is useful if you are making +// changes to cacheable content (like images, css, or JavaScript) and would like to +// see those changes right away. Once entered, development mode will last for 3 +// hours and then automatically toggle off. +type ZonesDevelopmentModeParam struct { + // ID of the zone setting. + ID param.Field[ZonesDevelopmentModeID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesDevelopmentModeValue] `json:"value,required"` +} + +func (r ZonesDevelopmentModeParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesDevelopmentModeParam) implementsZonesSettingEditParamsItem() {} + +type SettingDevelopmentModeEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingDevelopmentModeEditParamsValue] `json:"value,required"` +} + +func (r SettingDevelopmentModeEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingDevelopmentModeEditParamsValue string + +const ( + SettingDevelopmentModeEditParamsValueOn SettingDevelopmentModeEditParamsValue = "on" + SettingDevelopmentModeEditParamsValueOff SettingDevelopmentModeEditParamsValue = "off" +) + +type SettingDevelopmentModeEditResponseEnvelope struct { + Errors []SettingDevelopmentModeEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingDevelopmentModeEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Development Mode temporarily allows you to enter development mode for your + // websites if you need to make changes to your site. This will bypass Cloudflare's + // accelerated cache and slow down your site, but is useful if you are making + // changes to cacheable content (like images, css, or JavaScript) and would like to + // see those changes right away. Once entered, development mode will last for 3 + // hours and then automatically toggle off. + Result ZonesDevelopmentMode `json:"result"` + JSON settingDevelopmentModeEditResponseEnvelopeJSON `json:"-"` +} + +// settingDevelopmentModeEditResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingDevelopmentModeEditResponseEnvelope] +type settingDevelopmentModeEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingDevelopmentModeEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingDevelopmentModeEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingDevelopmentModeEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingDevelopmentModeEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingDevelopmentModeEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingDevelopmentModeEditResponseEnvelopeErrors] +type settingDevelopmentModeEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingDevelopmentModeEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingDevelopmentModeEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingDevelopmentModeEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingDevelopmentModeEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingDevelopmentModeEditResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingDevelopmentModeEditResponseEnvelopeMessages] +type settingDevelopmentModeEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingDevelopmentModeEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingDevelopmentModeEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingDevelopmentModeGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingDevelopmentModeGetResponseEnvelope struct { + Errors []SettingDevelopmentModeGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingDevelopmentModeGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Development Mode temporarily allows you to enter development mode for your + // websites if you need to make changes to your site. This will bypass Cloudflare's + // accelerated cache and slow down your site, but is useful if you are making + // changes to cacheable content (like images, css, or JavaScript) and would like to + // see those changes right away. Once entered, development mode will last for 3 + // hours and then automatically toggle off. + Result ZonesDevelopmentMode `json:"result"` + JSON settingDevelopmentModeGetResponseEnvelopeJSON `json:"-"` +} + +// settingDevelopmentModeGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingDevelopmentModeGetResponseEnvelope] +type settingDevelopmentModeGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingDevelopmentModeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingDevelopmentModeGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingDevelopmentModeGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingDevelopmentModeGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingDevelopmentModeGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingDevelopmentModeGetResponseEnvelopeErrors] +type settingDevelopmentModeGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingDevelopmentModeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingDevelopmentModeGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingDevelopmentModeGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingDevelopmentModeGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingDevelopmentModeGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingDevelopmentModeGetResponseEnvelopeMessages] +type settingDevelopmentModeGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingDevelopmentModeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingDevelopmentModeGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingdevelopmentmode_test.go b/zones/settingdevelopmentmode_test.go new file mode 100644 index 00000000000..93f36ec4fb1 --- /dev/null +++ b/zones/settingdevelopmentmode_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingDevelopmentModeEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.DevelopmentMode.Edit(context.TODO(), zones.SettingDevelopmentModeEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingDevelopmentModeEditParamsValueOn), + }) + 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 TestSettingDevelopmentModeGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.DevelopmentMode.Get(context.TODO(), zones.SettingDevelopmentModeGetParams{ + ZoneID: cloudflare.F("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/zones/settingearlyhint.go b/zones/settingearlyhint.go new file mode 100644 index 00000000000..ea6e4c5fb17 --- /dev/null +++ b/zones/settingearlyhint.go @@ -0,0 +1,325 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingEarlyHintService 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 [NewSettingEarlyHintService] method +// instead. +type SettingEarlyHintService struct { + Options []option.RequestOption +} + +// NewSettingEarlyHintService 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 NewSettingEarlyHintService(opts ...option.RequestOption) (r *SettingEarlyHintService) { + r = &SettingEarlyHintService{} + r.Options = opts + return +} + +// When enabled, Cloudflare will attempt to speed up overall page loads by serving +// `103` responses with `Link` headers from the final response. Refer to +// [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for +// more information. +func (r *SettingEarlyHintService) Edit(ctx context.Context, params SettingEarlyHintEditParams, opts ...option.RequestOption) (res *ZonesEarlyHints, err error) { + opts = append(r.Options[:], opts...) + var env SettingEarlyHintEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/early_hints", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// When enabled, Cloudflare will attempt to speed up overall page loads by serving +// `103` responses with `Link` headers from the final response. Refer to +// [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for +// more information. +func (r *SettingEarlyHintService) Get(ctx context.Context, query SettingEarlyHintGetParams, opts ...option.RequestOption) (res *ZonesEarlyHints, err error) { + opts = append(r.Options[:], opts...) + var env SettingEarlyHintGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/early_hints", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// When enabled, Cloudflare will attempt to speed up overall page loads by serving +// `103` responses with `Link` headers from the final response. Refer to +// [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for +// more information. +type ZonesEarlyHints struct { + // ID of the zone setting. + ID ZonesEarlyHintsID `json:"id,required"` + // Current value of the zone setting. + Value ZonesEarlyHintsValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesEarlyHintsEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesEarlyHintsJSON `json:"-"` +} + +// zonesEarlyHintsJSON contains the JSON metadata for the struct [ZonesEarlyHints] +type zonesEarlyHintsJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesEarlyHints) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesEarlyHintsJSON) RawJSON() string { + return r.raw +} + +func (r ZonesEarlyHints) implementsZonesSettingEditResponse() {} + +func (r ZonesEarlyHints) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesEarlyHintsID string + +const ( + ZonesEarlyHintsIDEarlyHints ZonesEarlyHintsID = "early_hints" +) + +// Current value of the zone setting. +type ZonesEarlyHintsValue string + +const ( + ZonesEarlyHintsValueOn ZonesEarlyHintsValue = "on" + ZonesEarlyHintsValueOff ZonesEarlyHintsValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesEarlyHintsEditable bool + +const ( + ZonesEarlyHintsEditableTrue ZonesEarlyHintsEditable = true + ZonesEarlyHintsEditableFalse ZonesEarlyHintsEditable = false +) + +// When enabled, Cloudflare will attempt to speed up overall page loads by serving +// `103` responses with `Link` headers from the final response. Refer to +// [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for +// more information. +type ZonesEarlyHintsParam struct { + // ID of the zone setting. + ID param.Field[ZonesEarlyHintsID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesEarlyHintsValue] `json:"value,required"` +} + +func (r ZonesEarlyHintsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesEarlyHintsParam) implementsZonesSettingEditParamsItem() {} + +type SettingEarlyHintEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingEarlyHintEditParamsValue] `json:"value,required"` +} + +func (r SettingEarlyHintEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingEarlyHintEditParamsValue string + +const ( + SettingEarlyHintEditParamsValueOn SettingEarlyHintEditParamsValue = "on" + SettingEarlyHintEditParamsValueOff SettingEarlyHintEditParamsValue = "off" +) + +type SettingEarlyHintEditResponseEnvelope struct { + Errors []SettingEarlyHintEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingEarlyHintEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // When enabled, Cloudflare will attempt to speed up overall page loads by serving + // `103` responses with `Link` headers from the final response. Refer to + // [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for + // more information. + Result ZonesEarlyHints `json:"result"` + JSON settingEarlyHintEditResponseEnvelopeJSON `json:"-"` +} + +// settingEarlyHintEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingEarlyHintEditResponseEnvelope] +type settingEarlyHintEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEarlyHintEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEarlyHintEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingEarlyHintEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingEarlyHintEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingEarlyHintEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingEarlyHintEditResponseEnvelopeErrors] +type settingEarlyHintEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEarlyHintEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEarlyHintEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingEarlyHintEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingEarlyHintEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingEarlyHintEditResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [SettingEarlyHintEditResponseEnvelopeMessages] +type settingEarlyHintEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEarlyHintEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEarlyHintEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingEarlyHintGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingEarlyHintGetResponseEnvelope struct { + Errors []SettingEarlyHintGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingEarlyHintGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // When enabled, Cloudflare will attempt to speed up overall page loads by serving + // `103` responses with `Link` headers from the final response. Refer to + // [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for + // more information. + Result ZonesEarlyHints `json:"result"` + JSON settingEarlyHintGetResponseEnvelopeJSON `json:"-"` +} + +// settingEarlyHintGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingEarlyHintGetResponseEnvelope] +type settingEarlyHintGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEarlyHintGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEarlyHintGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingEarlyHintGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingEarlyHintGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingEarlyHintGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingEarlyHintGetResponseEnvelopeErrors] +type settingEarlyHintGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEarlyHintGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEarlyHintGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingEarlyHintGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingEarlyHintGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingEarlyHintGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [SettingEarlyHintGetResponseEnvelopeMessages] +type settingEarlyHintGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEarlyHintGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEarlyHintGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingearlyhint_test.go b/zones/settingearlyhint_test.go new file mode 100644 index 00000000000..6834fd4942d --- /dev/null +++ b/zones/settingearlyhint_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingEarlyHintEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.EarlyHints.Edit(context.TODO(), zones.SettingEarlyHintEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingEarlyHintEditParamsValueOn), + }) + 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 TestSettingEarlyHintGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.EarlyHints.Get(context.TODO(), zones.SettingEarlyHintGetParams{ + ZoneID: cloudflare.F("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/zones/settingemailobfuscation.go b/zones/settingemailobfuscation.go new file mode 100644 index 00000000000..c2b77ad9fea --- /dev/null +++ b/zones/settingemailobfuscation.go @@ -0,0 +1,314 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingEmailObfuscationService 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 +// [NewSettingEmailObfuscationService] method instead. +type SettingEmailObfuscationService struct { + Options []option.RequestOption +} + +// NewSettingEmailObfuscationService 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 NewSettingEmailObfuscationService(opts ...option.RequestOption) (r *SettingEmailObfuscationService) { + r = &SettingEmailObfuscationService{} + r.Options = opts + return +} + +// Encrypt email adresses on your web page from bots, while keeping them visible to +// humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). +func (r *SettingEmailObfuscationService) Edit(ctx context.Context, params SettingEmailObfuscationEditParams, opts ...option.RequestOption) (res *ZonesEmailObfuscation, err error) { + opts = append(r.Options[:], opts...) + var env SettingEmailObfuscationEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/email_obfuscation", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Encrypt email adresses on your web page from bots, while keeping them visible to +// humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). +func (r *SettingEmailObfuscationService) Get(ctx context.Context, query SettingEmailObfuscationGetParams, opts ...option.RequestOption) (res *ZonesEmailObfuscation, err error) { + opts = append(r.Options[:], opts...) + var env SettingEmailObfuscationGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/email_obfuscation", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Encrypt email adresses on your web page from bots, while keeping them visible to +// humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). +type ZonesEmailObfuscation struct { + // ID of the zone setting. + ID ZonesEmailObfuscationID `json:"id,required"` + // Current value of the zone setting. + Value ZonesEmailObfuscationValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesEmailObfuscationEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesEmailObfuscationJSON `json:"-"` +} + +// zonesEmailObfuscationJSON contains the JSON metadata for the struct +// [ZonesEmailObfuscation] +type zonesEmailObfuscationJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesEmailObfuscation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesEmailObfuscationJSON) RawJSON() string { + return r.raw +} + +func (r ZonesEmailObfuscation) implementsZonesSettingEditResponse() {} + +func (r ZonesEmailObfuscation) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesEmailObfuscationID string + +const ( + ZonesEmailObfuscationIDEmailObfuscation ZonesEmailObfuscationID = "email_obfuscation" +) + +// Current value of the zone setting. +type ZonesEmailObfuscationValue string + +const ( + ZonesEmailObfuscationValueOn ZonesEmailObfuscationValue = "on" + ZonesEmailObfuscationValueOff ZonesEmailObfuscationValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesEmailObfuscationEditable bool + +const ( + ZonesEmailObfuscationEditableTrue ZonesEmailObfuscationEditable = true + ZonesEmailObfuscationEditableFalse ZonesEmailObfuscationEditable = false +) + +// Encrypt email adresses on your web page from bots, while keeping them visible to +// humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). +type ZonesEmailObfuscationParam struct { + // ID of the zone setting. + ID param.Field[ZonesEmailObfuscationID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesEmailObfuscationValue] `json:"value,required"` +} + +func (r ZonesEmailObfuscationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesEmailObfuscationParam) implementsZonesSettingEditParamsItem() {} + +type SettingEmailObfuscationEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingEmailObfuscationEditParamsValue] `json:"value,required"` +} + +func (r SettingEmailObfuscationEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingEmailObfuscationEditParamsValue string + +const ( + SettingEmailObfuscationEditParamsValueOn SettingEmailObfuscationEditParamsValue = "on" + SettingEmailObfuscationEditParamsValueOff SettingEmailObfuscationEditParamsValue = "off" +) + +type SettingEmailObfuscationEditResponseEnvelope struct { + Errors []SettingEmailObfuscationEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingEmailObfuscationEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Encrypt email adresses on your web page from bots, while keeping them visible to + // humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). + Result ZonesEmailObfuscation `json:"result"` + JSON settingEmailObfuscationEditResponseEnvelopeJSON `json:"-"` +} + +// settingEmailObfuscationEditResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingEmailObfuscationEditResponseEnvelope] +type settingEmailObfuscationEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEmailObfuscationEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEmailObfuscationEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingEmailObfuscationEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingEmailObfuscationEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingEmailObfuscationEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingEmailObfuscationEditResponseEnvelopeErrors] +type settingEmailObfuscationEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEmailObfuscationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEmailObfuscationEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingEmailObfuscationEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingEmailObfuscationEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingEmailObfuscationEditResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingEmailObfuscationEditResponseEnvelopeMessages] +type settingEmailObfuscationEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEmailObfuscationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEmailObfuscationEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingEmailObfuscationGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingEmailObfuscationGetResponseEnvelope struct { + Errors []SettingEmailObfuscationGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingEmailObfuscationGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Encrypt email adresses on your web page from bots, while keeping them visible to + // humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). + Result ZonesEmailObfuscation `json:"result"` + JSON settingEmailObfuscationGetResponseEnvelopeJSON `json:"-"` +} + +// settingEmailObfuscationGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingEmailObfuscationGetResponseEnvelope] +type settingEmailObfuscationGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEmailObfuscationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEmailObfuscationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingEmailObfuscationGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingEmailObfuscationGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingEmailObfuscationGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingEmailObfuscationGetResponseEnvelopeErrors] +type settingEmailObfuscationGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEmailObfuscationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEmailObfuscationGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingEmailObfuscationGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingEmailObfuscationGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingEmailObfuscationGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingEmailObfuscationGetResponseEnvelopeMessages] +type settingEmailObfuscationGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingEmailObfuscationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingEmailObfuscationGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingemailobfuscation_test.go b/zones/settingemailobfuscation_test.go new file mode 100644 index 00000000000..3c79374b400 --- /dev/null +++ b/zones/settingemailobfuscation_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingEmailObfuscationEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.EmailObfuscation.Edit(context.TODO(), zones.SettingEmailObfuscationEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingEmailObfuscationEditParamsValueOn), + }) + 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 TestSettingEmailObfuscationGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.EmailObfuscation.Get(context.TODO(), zones.SettingEmailObfuscationGetParams{ + ZoneID: cloudflare.F("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/zones/settingfontsetting.go b/zones/settingfontsetting.go new file mode 100644 index 00000000000..3adfa5cbcd2 --- /dev/null +++ b/zones/settingfontsetting.go @@ -0,0 +1,300 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingFontSettingService 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 [NewSettingFontSettingService] method +// instead. +type SettingFontSettingService struct { + Options []option.RequestOption +} + +// NewSettingFontSettingService 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 NewSettingFontSettingService(opts ...option.RequestOption) (r *SettingFontSettingService) { + r = &SettingFontSettingService{} + r.Options = opts + return +} + +// Enhance your website's font delivery with Cloudflare Fonts. Deliver Google +// Hosted fonts from your own domain, boost performance, and enhance user privacy. +// Refer to the Cloudflare Fonts documentation for more information. +func (r *SettingFontSettingService) Edit(ctx context.Context, params SettingFontSettingEditParams, opts ...option.RequestOption) (res *SpeedCloudflareFonts, err error) { + opts = append(r.Options[:], opts...) + var env SettingFontSettingEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/fonts", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Enhance your website's font delivery with Cloudflare Fonts. Deliver Google +// Hosted fonts from your own domain, boost performance, and enhance user privacy. +// Refer to the Cloudflare Fonts documentation for more information. +func (r *SettingFontSettingService) Get(ctx context.Context, query SettingFontSettingGetParams, opts ...option.RequestOption) (res *SpeedCloudflareFonts, err error) { + opts = append(r.Options[:], opts...) + var env SettingFontSettingGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/fonts", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Enhance your website's font delivery with Cloudflare Fonts. Deliver Google +// Hosted fonts from your own domain, boost performance, and enhance user privacy. +// Refer to the Cloudflare Fonts documentation for more information. +type SpeedCloudflareFonts struct { + // ID of the zone setting. + ID SpeedCloudflareFontsID `json:"id,required"` + // Current value of the zone setting. + Value SpeedCloudflareFontsValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable SpeedCloudflareFontsEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON speedCloudflareFontsJSON `json:"-"` +} + +// speedCloudflareFontsJSON contains the JSON metadata for the struct +// [SpeedCloudflareFonts] +type speedCloudflareFontsJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SpeedCloudflareFonts) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r speedCloudflareFontsJSON) RawJSON() string { + return r.raw +} + +// ID of the zone setting. +type SpeedCloudflareFontsID string + +const ( + SpeedCloudflareFontsIDFonts SpeedCloudflareFontsID = "fonts" +) + +// Current value of the zone setting. +type SpeedCloudflareFontsValue string + +const ( + SpeedCloudflareFontsValueOn SpeedCloudflareFontsValue = "on" + SpeedCloudflareFontsValueOff SpeedCloudflareFontsValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type SpeedCloudflareFontsEditable bool + +const ( + SpeedCloudflareFontsEditableTrue SpeedCloudflareFontsEditable = true + SpeedCloudflareFontsEditableFalse SpeedCloudflareFontsEditable = false +) + +type SettingFontSettingEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Whether the feature is enabled or disabled. + Value param.Field[SettingFontSettingEditParamsValue] `json:"value,required"` +} + +func (r SettingFontSettingEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Whether the feature is enabled or disabled. +type SettingFontSettingEditParamsValue string + +const ( + SettingFontSettingEditParamsValueOn SettingFontSettingEditParamsValue = "on" + SettingFontSettingEditParamsValueOff SettingFontSettingEditParamsValue = "off" +) + +type SettingFontSettingEditResponseEnvelope struct { + Errors []SettingFontSettingEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingFontSettingEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Enhance your website's font delivery with Cloudflare Fonts. Deliver Google + // Hosted fonts from your own domain, boost performance, and enhance user privacy. + // Refer to the Cloudflare Fonts documentation for more information. + Result SpeedCloudflareFonts `json:"result"` + JSON settingFontSettingEditResponseEnvelopeJSON `json:"-"` +} + +// settingFontSettingEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingFontSettingEditResponseEnvelope] +type settingFontSettingEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingFontSettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingFontSettingEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingFontSettingEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingFontSettingEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingFontSettingEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingFontSettingEditResponseEnvelopeErrors] +type settingFontSettingEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingFontSettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingFontSettingEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingFontSettingEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingFontSettingEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingFontSettingEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingFontSettingEditResponseEnvelopeMessages] +type settingFontSettingEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingFontSettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingFontSettingEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingFontSettingGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingFontSettingGetResponseEnvelope struct { + Errors []SettingFontSettingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingFontSettingGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Enhance your website's font delivery with Cloudflare Fonts. Deliver Google + // Hosted fonts from your own domain, boost performance, and enhance user privacy. + // Refer to the Cloudflare Fonts documentation for more information. + Result SpeedCloudflareFonts `json:"result"` + JSON settingFontSettingGetResponseEnvelopeJSON `json:"-"` +} + +// settingFontSettingGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingFontSettingGetResponseEnvelope] +type settingFontSettingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingFontSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingFontSettingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingFontSettingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingFontSettingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingFontSettingGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingFontSettingGetResponseEnvelopeErrors] +type settingFontSettingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingFontSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingFontSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingFontSettingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingFontSettingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingFontSettingGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [SettingFontSettingGetResponseEnvelopeMessages] +type settingFontSettingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingFontSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingFontSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingfontsetting_test.go b/zones/settingfontsetting_test.go new file mode 100644 index 00000000000..150d2c74b53 --- /dev/null +++ b/zones/settingfontsetting_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingFontSettingEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.FontSettings.Edit(context.TODO(), zones.SettingFontSettingEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingFontSettingEditParamsValueOn), + }) + 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 TestSettingFontSettingGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.FontSettings.Get(context.TODO(), zones.SettingFontSettingGetParams{ + ZoneID: cloudflare.F("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/zones/settingh2prioritization.go b/zones/settingh2prioritization.go new file mode 100644 index 00000000000..0035da84b7b --- /dev/null +++ b/zones/settingh2prioritization.go @@ -0,0 +1,311 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingH2PrioritizationService 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 +// [NewSettingH2PrioritizationService] method instead. +type SettingH2PrioritizationService struct { + Options []option.RequestOption +} + +// NewSettingH2PrioritizationService 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 NewSettingH2PrioritizationService(opts ...option.RequestOption) (r *SettingH2PrioritizationService) { + r = &SettingH2PrioritizationService{} + r.Options = opts + return +} + +// Gets HTTP/2 Edge Prioritization setting. +func (r *SettingH2PrioritizationService) Edit(ctx context.Context, params SettingH2PrioritizationEditParams, opts ...option.RequestOption) (res *ZonesH2Prioritization, err error) { + opts = append(r.Options[:], opts...) + var env SettingH2PrioritizationEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/h2_prioritization", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets HTTP/2 Edge Prioritization setting. +func (r *SettingH2PrioritizationService) Get(ctx context.Context, query SettingH2PrioritizationGetParams, opts ...option.RequestOption) (res *ZonesH2Prioritization, err error) { + opts = append(r.Options[:], opts...) + var env SettingH2PrioritizationGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/h2_prioritization", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// HTTP/2 Edge Prioritization optimises the delivery of resources served through +// HTTP/2 to improve page load performance. It also supports fine control of +// content delivery when used in conjunction with Workers. +type ZonesH2Prioritization struct { + // ID of the zone setting. + ID ZonesH2PrioritizationID `json:"id,required"` + // Current value of the zone setting. + Value ZonesH2PrioritizationValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesH2PrioritizationEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesH2PrioritizationJSON `json:"-"` +} + +// zonesH2PrioritizationJSON contains the JSON metadata for the struct +// [ZonesH2Prioritization] +type zonesH2PrioritizationJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesH2Prioritization) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesH2PrioritizationJSON) RawJSON() string { + return r.raw +} + +func (r ZonesH2Prioritization) implementsZonesSettingEditResponse() {} + +func (r ZonesH2Prioritization) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesH2PrioritizationID string + +const ( + ZonesH2PrioritizationIDH2Prioritization ZonesH2PrioritizationID = "h2_prioritization" +) + +// Current value of the zone setting. +type ZonesH2PrioritizationValue string + +const ( + ZonesH2PrioritizationValueOn ZonesH2PrioritizationValue = "on" + ZonesH2PrioritizationValueOff ZonesH2PrioritizationValue = "off" + ZonesH2PrioritizationValueCustom ZonesH2PrioritizationValue = "custom" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesH2PrioritizationEditable bool + +const ( + ZonesH2PrioritizationEditableTrue ZonesH2PrioritizationEditable = true + ZonesH2PrioritizationEditableFalse ZonesH2PrioritizationEditable = false +) + +// HTTP/2 Edge Prioritization optimises the delivery of resources served through +// HTTP/2 to improve page load performance. It also supports fine control of +// content delivery when used in conjunction with Workers. +type ZonesH2PrioritizationParam struct { + // ID of the zone setting. + ID param.Field[ZonesH2PrioritizationID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesH2PrioritizationValue] `json:"value,required"` +} + +func (r ZonesH2PrioritizationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesH2PrioritizationParam) implementsZonesSettingEditParamsItem() {} + +type SettingH2PrioritizationEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // HTTP/2 Edge Prioritization optimises the delivery of resources served through + // HTTP/2 to improve page load performance. It also supports fine control of + // content delivery when used in conjunction with Workers. + Value param.Field[ZonesH2PrioritizationParam] `json:"value,required"` +} + +func (r SettingH2PrioritizationEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingH2PrioritizationEditResponseEnvelope struct { + Errors []SettingH2PrioritizationEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingH2PrioritizationEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // HTTP/2 Edge Prioritization optimises the delivery of resources served through + // HTTP/2 to improve page load performance. It also supports fine control of + // content delivery when used in conjunction with Workers. + Result ZonesH2Prioritization `json:"result"` + JSON settingH2PrioritizationEditResponseEnvelopeJSON `json:"-"` +} + +// settingH2PrioritizationEditResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingH2PrioritizationEditResponseEnvelope] +type settingH2PrioritizationEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingH2PrioritizationEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingH2PrioritizationEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingH2PrioritizationEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingH2PrioritizationEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingH2PrioritizationEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingH2PrioritizationEditResponseEnvelopeErrors] +type settingH2PrioritizationEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingH2PrioritizationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingH2PrioritizationEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingH2PrioritizationEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingH2PrioritizationEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingH2PrioritizationEditResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingH2PrioritizationEditResponseEnvelopeMessages] +type settingH2PrioritizationEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingH2PrioritizationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingH2PrioritizationEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingH2PrioritizationGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingH2PrioritizationGetResponseEnvelope struct { + Errors []SettingH2PrioritizationGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingH2PrioritizationGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // HTTP/2 Edge Prioritization optimises the delivery of resources served through + // HTTP/2 to improve page load performance. It also supports fine control of + // content delivery when used in conjunction with Workers. + Result ZonesH2Prioritization `json:"result"` + JSON settingH2PrioritizationGetResponseEnvelopeJSON `json:"-"` +} + +// settingH2PrioritizationGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingH2PrioritizationGetResponseEnvelope] +type settingH2PrioritizationGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingH2PrioritizationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingH2PrioritizationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingH2PrioritizationGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingH2PrioritizationGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingH2PrioritizationGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingH2PrioritizationGetResponseEnvelopeErrors] +type settingH2PrioritizationGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingH2PrioritizationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingH2PrioritizationGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingH2PrioritizationGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingH2PrioritizationGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingH2PrioritizationGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingH2PrioritizationGetResponseEnvelopeMessages] +type settingH2PrioritizationGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingH2PrioritizationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingH2PrioritizationGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingh2prioritization_test.go b/zones/settingh2prioritization_test.go new file mode 100644 index 00000000000..be5b2467afa --- /dev/null +++ b/zones/settingh2prioritization_test.go @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingH2PrioritizationEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Zones.Settings.H2Prioritization.Edit(context.TODO(), zones.SettingH2PrioritizationEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.ZonesH2PrioritizationParam{ + ID: cloudflare.F(zones.ZonesH2PrioritizationIDH2Prioritization), + Value: cloudflare.F(zones.ZonesH2PrioritizationValueOn), + }), + }) + 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 TestSettingH2PrioritizationGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.H2Prioritization.Get(context.TODO(), zones.SettingH2PrioritizationGetParams{ + ZoneID: cloudflare.F("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/zones/settinghotlinkprotection.go b/zones/settinghotlinkprotection.go new file mode 100644 index 00000000000..43ab802b65e --- /dev/null +++ b/zones/settinghotlinkprotection.go @@ -0,0 +1,344 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingHotlinkProtectionService 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 +// [NewSettingHotlinkProtectionService] method instead. +type SettingHotlinkProtectionService struct { + Options []option.RequestOption +} + +// NewSettingHotlinkProtectionService 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 NewSettingHotlinkProtectionService(opts ...option.RequestOption) (r *SettingHotlinkProtectionService) { + r = &SettingHotlinkProtectionService{} + r.Options = opts + return +} + +// When enabled, the Hotlink Protection option ensures that other sites cannot suck +// up your bandwidth by building pages that use images hosted on your site. Anytime +// a request for an image on your site hits Cloudflare, we check to ensure that +// it's not another site requesting them. People will still be able to download and +// view images from your page, but other sites won't be able to steal them for use +// on their own pages. +// (https://support.cloudflare.com/hc/en-us/articles/200170026). +func (r *SettingHotlinkProtectionService) Edit(ctx context.Context, params SettingHotlinkProtectionEditParams, opts ...option.RequestOption) (res *ZonesHotlinkProtection, err error) { + opts = append(r.Options[:], opts...) + var env SettingHotlinkProtectionEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/hotlink_protection", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// When enabled, the Hotlink Protection option ensures that other sites cannot suck +// up your bandwidth by building pages that use images hosted on your site. Anytime +// a request for an image on your site hits Cloudflare, we check to ensure that +// it's not another site requesting them. People will still be able to download and +// view images from your page, but other sites won't be able to steal them for use +// on their own pages. +// (https://support.cloudflare.com/hc/en-us/articles/200170026). +func (r *SettingHotlinkProtectionService) Get(ctx context.Context, query SettingHotlinkProtectionGetParams, opts ...option.RequestOption) (res *ZonesHotlinkProtection, err error) { + opts = append(r.Options[:], opts...) + var env SettingHotlinkProtectionGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/hotlink_protection", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// When enabled, the Hotlink Protection option ensures that other sites cannot suck +// up your bandwidth by building pages that use images hosted on your site. Anytime +// a request for an image on your site hits Cloudflare, we check to ensure that +// it's not another site requesting them. People will still be able to download and +// view images from your page, but other sites won't be able to steal them for use +// on their own pages. +// (https://support.cloudflare.com/hc/en-us/articles/200170026). +type ZonesHotlinkProtection struct { + // ID of the zone setting. + ID ZonesHotlinkProtectionID `json:"id,required"` + // Current value of the zone setting. + Value ZonesHotlinkProtectionValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesHotlinkProtectionEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesHotlinkProtectionJSON `json:"-"` +} + +// zonesHotlinkProtectionJSON contains the JSON metadata for the struct +// [ZonesHotlinkProtection] +type zonesHotlinkProtectionJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesHotlinkProtection) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesHotlinkProtectionJSON) RawJSON() string { + return r.raw +} + +func (r ZonesHotlinkProtection) implementsZonesSettingEditResponse() {} + +func (r ZonesHotlinkProtection) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesHotlinkProtectionID string + +const ( + ZonesHotlinkProtectionIDHotlinkProtection ZonesHotlinkProtectionID = "hotlink_protection" +) + +// Current value of the zone setting. +type ZonesHotlinkProtectionValue string + +const ( + ZonesHotlinkProtectionValueOn ZonesHotlinkProtectionValue = "on" + ZonesHotlinkProtectionValueOff ZonesHotlinkProtectionValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesHotlinkProtectionEditable bool + +const ( + ZonesHotlinkProtectionEditableTrue ZonesHotlinkProtectionEditable = true + ZonesHotlinkProtectionEditableFalse ZonesHotlinkProtectionEditable = false +) + +// When enabled, the Hotlink Protection option ensures that other sites cannot suck +// up your bandwidth by building pages that use images hosted on your site. Anytime +// a request for an image on your site hits Cloudflare, we check to ensure that +// it's not another site requesting them. People will still be able to download and +// view images from your page, but other sites won't be able to steal them for use +// on their own pages. +// (https://support.cloudflare.com/hc/en-us/articles/200170026). +type ZonesHotlinkProtectionParam struct { + // ID of the zone setting. + ID param.Field[ZonesHotlinkProtectionID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesHotlinkProtectionValue] `json:"value,required"` +} + +func (r ZonesHotlinkProtectionParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesHotlinkProtectionParam) implementsZonesSettingEditParamsItem() {} + +type SettingHotlinkProtectionEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingHotlinkProtectionEditParamsValue] `json:"value,required"` +} + +func (r SettingHotlinkProtectionEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingHotlinkProtectionEditParamsValue string + +const ( + SettingHotlinkProtectionEditParamsValueOn SettingHotlinkProtectionEditParamsValue = "on" + SettingHotlinkProtectionEditParamsValueOff SettingHotlinkProtectionEditParamsValue = "off" +) + +type SettingHotlinkProtectionEditResponseEnvelope struct { + Errors []SettingHotlinkProtectionEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingHotlinkProtectionEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // When enabled, the Hotlink Protection option ensures that other sites cannot suck + // up your bandwidth by building pages that use images hosted on your site. Anytime + // a request for an image on your site hits Cloudflare, we check to ensure that + // it's not another site requesting them. People will still be able to download and + // view images from your page, but other sites won't be able to steal them for use + // on their own pages. + // (https://support.cloudflare.com/hc/en-us/articles/200170026). + Result ZonesHotlinkProtection `json:"result"` + JSON settingHotlinkProtectionEditResponseEnvelopeJSON `json:"-"` +} + +// settingHotlinkProtectionEditResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingHotlinkProtectionEditResponseEnvelope] +type settingHotlinkProtectionEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingHotlinkProtectionEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingHotlinkProtectionEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingHotlinkProtectionEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingHotlinkProtectionEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingHotlinkProtectionEditResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [SettingHotlinkProtectionEditResponseEnvelopeErrors] +type settingHotlinkProtectionEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingHotlinkProtectionEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingHotlinkProtectionEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingHotlinkProtectionEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingHotlinkProtectionEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingHotlinkProtectionEditResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingHotlinkProtectionEditResponseEnvelopeMessages] +type settingHotlinkProtectionEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingHotlinkProtectionEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingHotlinkProtectionEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingHotlinkProtectionGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingHotlinkProtectionGetResponseEnvelope struct { + Errors []SettingHotlinkProtectionGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingHotlinkProtectionGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // When enabled, the Hotlink Protection option ensures that other sites cannot suck + // up your bandwidth by building pages that use images hosted on your site. Anytime + // a request for an image on your site hits Cloudflare, we check to ensure that + // it's not another site requesting them. People will still be able to download and + // view images from your page, but other sites won't be able to steal them for use + // on their own pages. + // (https://support.cloudflare.com/hc/en-us/articles/200170026). + Result ZonesHotlinkProtection `json:"result"` + JSON settingHotlinkProtectionGetResponseEnvelopeJSON `json:"-"` +} + +// settingHotlinkProtectionGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingHotlinkProtectionGetResponseEnvelope] +type settingHotlinkProtectionGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingHotlinkProtectionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingHotlinkProtectionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingHotlinkProtectionGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingHotlinkProtectionGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingHotlinkProtectionGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingHotlinkProtectionGetResponseEnvelopeErrors] +type settingHotlinkProtectionGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingHotlinkProtectionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingHotlinkProtectionGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingHotlinkProtectionGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingHotlinkProtectionGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingHotlinkProtectionGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingHotlinkProtectionGetResponseEnvelopeMessages] +type settingHotlinkProtectionGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingHotlinkProtectionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingHotlinkProtectionGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settinghotlinkprotection_test.go b/zones/settinghotlinkprotection_test.go new file mode 100644 index 00000000000..7b425d9abd4 --- /dev/null +++ b/zones/settinghotlinkprotection_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingHotlinkProtectionEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.HotlinkProtection.Edit(context.TODO(), zones.SettingHotlinkProtectionEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingHotlinkProtectionEditParamsValueOn), + }) + 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 TestSettingHotlinkProtectionGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.HotlinkProtection.Get(context.TODO(), zones.SettingHotlinkProtectionGetParams{ + ZoneID: cloudflare.F("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/zones/settinghttp2.go b/zones/settinghttp2.go new file mode 100644 index 00000000000..d261cf524cc --- /dev/null +++ b/zones/settinghttp2.go @@ -0,0 +1,307 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingHTTP2Service 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 [NewSettingHTTP2Service] method +// instead. +type SettingHTTP2Service struct { + Options []option.RequestOption +} + +// NewSettingHTTP2Service 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 NewSettingHTTP2Service(opts ...option.RequestOption) (r *SettingHTTP2Service) { + r = &SettingHTTP2Service{} + r.Options = opts + return +} + +// Value of the HTTP2 setting. +func (r *SettingHTTP2Service) Edit(ctx context.Context, params SettingHTTP2EditParams, opts ...option.RequestOption) (res *ZonesHTTP2, err error) { + opts = append(r.Options[:], opts...) + var env SettingHTTP2EditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/http2", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Value of the HTTP2 setting. +func (r *SettingHTTP2Service) Get(ctx context.Context, query SettingHTTP2GetParams, opts ...option.RequestOption) (res *ZonesHTTP2, err error) { + opts = append(r.Options[:], opts...) + var env SettingHTTP2GetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/http2", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// HTTP2 enabled for this zone. +type ZonesHTTP2 struct { + // ID of the zone setting. + ID ZonesHTTP2ID `json:"id,required"` + // Current value of the zone setting. + Value ZonesHTTP2Value `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesHTTP2Editable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesHTTP2JSON `json:"-"` +} + +// zonesHTTP2JSON contains the JSON metadata for the struct [ZonesHTTP2] +type zonesHTTP2JSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesHTTP2) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesHTTP2JSON) RawJSON() string { + return r.raw +} + +func (r ZonesHTTP2) implementsZonesSettingEditResponse() {} + +func (r ZonesHTTP2) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesHTTP2ID string + +const ( + ZonesHTTP2IDHTTP2 ZonesHTTP2ID = "http2" +) + +// Current value of the zone setting. +type ZonesHTTP2Value string + +const ( + ZonesHTTP2ValueOn ZonesHTTP2Value = "on" + ZonesHTTP2ValueOff ZonesHTTP2Value = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesHTTP2Editable bool + +const ( + ZonesHTTP2EditableTrue ZonesHTTP2Editable = true + ZonesHTTP2EditableFalse ZonesHTTP2Editable = false +) + +// HTTP2 enabled for this zone. +type ZonesHTTP2Param struct { + // ID of the zone setting. + ID param.Field[ZonesHTTP2ID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesHTTP2Value] `json:"value,required"` +} + +func (r ZonesHTTP2Param) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesHTTP2Param) implementsZonesSettingEditParamsItem() {} + +type SettingHTTP2EditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the HTTP2 setting. + Value param.Field[SettingHTTP2EditParamsValue] `json:"value,required"` +} + +func (r SettingHTTP2EditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the HTTP2 setting. +type SettingHTTP2EditParamsValue string + +const ( + SettingHTTP2EditParamsValueOn SettingHTTP2EditParamsValue = "on" + SettingHTTP2EditParamsValueOff SettingHTTP2EditParamsValue = "off" +) + +type SettingHTTP2EditResponseEnvelope struct { + Errors []SettingHTTP2EditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingHTTP2EditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // HTTP2 enabled for this zone. + Result ZonesHTTP2 `json:"result"` + JSON settingHTTP2EditResponseEnvelopeJSON `json:"-"` +} + +// settingHTTP2EditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingHTTP2EditResponseEnvelope] +type settingHTTP2EditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingHTTP2EditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingHTTP2EditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingHTTP2EditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingHTTP2EditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingHTTP2EditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingHTTP2EditResponseEnvelopeErrors] +type settingHTTP2EditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingHTTP2EditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingHTTP2EditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingHTTP2EditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingHTTP2EditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingHTTP2EditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingHTTP2EditResponseEnvelopeMessages] +type settingHTTP2EditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingHTTP2EditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingHTTP2EditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingHTTP2GetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingHTTP2GetResponseEnvelope struct { + Errors []SettingHTTP2GetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingHTTP2GetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // HTTP2 enabled for this zone. + Result ZonesHTTP2 `json:"result"` + JSON settingHTTP2GetResponseEnvelopeJSON `json:"-"` +} + +// settingHTTP2GetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingHTTP2GetResponseEnvelope] +type settingHTTP2GetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingHTTP2GetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingHTTP2GetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingHTTP2GetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingHTTP2GetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingHTTP2GetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingHTTP2GetResponseEnvelopeErrors] +type settingHTTP2GetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingHTTP2GetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingHTTP2GetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingHTTP2GetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingHTTP2GetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingHTTP2GetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingHTTP2GetResponseEnvelopeMessages] +type settingHTTP2GetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingHTTP2GetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingHTTP2GetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settinghttp2_test.go b/zones/settinghttp2_test.go new file mode 100644 index 00000000000..fc88043db50 --- /dev/null +++ b/zones/settinghttp2_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingHTTP2Edit(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("user@example.com"), + ) + _, err := client.Zones.Settings.HTTP2.Edit(context.TODO(), zones.SettingHTTP2EditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingHTTP2EditParamsValueOn), + }) + 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 TestSettingHTTP2Get(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("user@example.com"), + ) + _, err := client.Zones.Settings.HTTP2.Get(context.TODO(), zones.SettingHTTP2GetParams{ + ZoneID: cloudflare.F("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/zones/settinghttp3.go b/zones/settinghttp3.go new file mode 100644 index 00000000000..1a3f1f256e6 --- /dev/null +++ b/zones/settinghttp3.go @@ -0,0 +1,307 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingHTTP3Service 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 [NewSettingHTTP3Service] method +// instead. +type SettingHTTP3Service struct { + Options []option.RequestOption +} + +// NewSettingHTTP3Service 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 NewSettingHTTP3Service(opts ...option.RequestOption) (r *SettingHTTP3Service) { + r = &SettingHTTP3Service{} + r.Options = opts + return +} + +// Value of the HTTP3 setting. +func (r *SettingHTTP3Service) Edit(ctx context.Context, params SettingHTTP3EditParams, opts ...option.RequestOption) (res *ZonesHTTP3, err error) { + opts = append(r.Options[:], opts...) + var env SettingHTTP3EditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/http3", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Value of the HTTP3 setting. +func (r *SettingHTTP3Service) Get(ctx context.Context, query SettingHTTP3GetParams, opts ...option.RequestOption) (res *ZonesHTTP3, err error) { + opts = append(r.Options[:], opts...) + var env SettingHTTP3GetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/http3", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// HTTP3 enabled for this zone. +type ZonesHTTP3 struct { + // ID of the zone setting. + ID ZonesHTTP3ID `json:"id,required"` + // Current value of the zone setting. + Value ZonesHTTP3Value `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesHTTP3Editable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesHTTP3JSON `json:"-"` +} + +// zonesHTTP3JSON contains the JSON metadata for the struct [ZonesHTTP3] +type zonesHTTP3JSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesHTTP3) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesHTTP3JSON) RawJSON() string { + return r.raw +} + +func (r ZonesHTTP3) implementsZonesSettingEditResponse() {} + +func (r ZonesHTTP3) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesHTTP3ID string + +const ( + ZonesHTTP3IDHTTP3 ZonesHTTP3ID = "http3" +) + +// Current value of the zone setting. +type ZonesHTTP3Value string + +const ( + ZonesHTTP3ValueOn ZonesHTTP3Value = "on" + ZonesHTTP3ValueOff ZonesHTTP3Value = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesHTTP3Editable bool + +const ( + ZonesHTTP3EditableTrue ZonesHTTP3Editable = true + ZonesHTTP3EditableFalse ZonesHTTP3Editable = false +) + +// HTTP3 enabled for this zone. +type ZonesHTTP3Param struct { + // ID of the zone setting. + ID param.Field[ZonesHTTP3ID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesHTTP3Value] `json:"value,required"` +} + +func (r ZonesHTTP3Param) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesHTTP3Param) implementsZonesSettingEditParamsItem() {} + +type SettingHTTP3EditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the HTTP3 setting. + Value param.Field[SettingHTTP3EditParamsValue] `json:"value,required"` +} + +func (r SettingHTTP3EditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the HTTP3 setting. +type SettingHTTP3EditParamsValue string + +const ( + SettingHTTP3EditParamsValueOn SettingHTTP3EditParamsValue = "on" + SettingHTTP3EditParamsValueOff SettingHTTP3EditParamsValue = "off" +) + +type SettingHTTP3EditResponseEnvelope struct { + Errors []SettingHTTP3EditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingHTTP3EditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // HTTP3 enabled for this zone. + Result ZonesHTTP3 `json:"result"` + JSON settingHTTP3EditResponseEnvelopeJSON `json:"-"` +} + +// settingHTTP3EditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingHTTP3EditResponseEnvelope] +type settingHTTP3EditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingHTTP3EditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingHTTP3EditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingHTTP3EditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingHTTP3EditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingHTTP3EditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingHTTP3EditResponseEnvelopeErrors] +type settingHTTP3EditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingHTTP3EditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingHTTP3EditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingHTTP3EditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingHTTP3EditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingHTTP3EditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingHTTP3EditResponseEnvelopeMessages] +type settingHTTP3EditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingHTTP3EditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingHTTP3EditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingHTTP3GetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingHTTP3GetResponseEnvelope struct { + Errors []SettingHTTP3GetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingHTTP3GetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // HTTP3 enabled for this zone. + Result ZonesHTTP3 `json:"result"` + JSON settingHTTP3GetResponseEnvelopeJSON `json:"-"` +} + +// settingHTTP3GetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingHTTP3GetResponseEnvelope] +type settingHTTP3GetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingHTTP3GetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingHTTP3GetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingHTTP3GetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingHTTP3GetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingHTTP3GetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingHTTP3GetResponseEnvelopeErrors] +type settingHTTP3GetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingHTTP3GetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingHTTP3GetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingHTTP3GetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingHTTP3GetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingHTTP3GetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingHTTP3GetResponseEnvelopeMessages] +type settingHTTP3GetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingHTTP3GetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingHTTP3GetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settinghttp3_test.go b/zones/settinghttp3_test.go new file mode 100644 index 00000000000..e8ceeefb410 --- /dev/null +++ b/zones/settinghttp3_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingHTTP3Edit(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("user@example.com"), + ) + _, err := client.Zones.Settings.HTTP3.Edit(context.TODO(), zones.SettingHTTP3EditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingHTTP3EditParamsValueOn), + }) + 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 TestSettingHTTP3Get(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("user@example.com"), + ) + _, err := client.Zones.Settings.HTTP3.Get(context.TODO(), zones.SettingHTTP3GetParams{ + ZoneID: cloudflare.F("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/zones/settingimageresizing.go b/zones/settingimageresizing.go new file mode 100644 index 00000000000..5d91dd573a2 --- /dev/null +++ b/zones/settingimageresizing.go @@ -0,0 +1,322 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingImageResizingService 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 [NewSettingImageResizingService] +// method instead. +type SettingImageResizingService struct { + Options []option.RequestOption +} + +// NewSettingImageResizingService 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 NewSettingImageResizingService(opts ...option.RequestOption) (r *SettingImageResizingService) { + r = &SettingImageResizingService{} + r.Options = opts + return +} + +// Image Resizing provides on-demand resizing, conversion and optimisation for +// images served through Cloudflare's network. Refer to the +// [Image Resizing documentation](https://developers.cloudflare.com/images/) for +// more information. +func (r *SettingImageResizingService) Edit(ctx context.Context, params SettingImageResizingEditParams, opts ...option.RequestOption) (res *ZonesImageResizing, err error) { + opts = append(r.Options[:], opts...) + var env SettingImageResizingEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/image_resizing", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Image Resizing provides on-demand resizing, conversion and optimisation for +// images served through Cloudflare's network. Refer to the +// [Image Resizing documentation](https://developers.cloudflare.com/images/) for +// more information. +func (r *SettingImageResizingService) Get(ctx context.Context, query SettingImageResizingGetParams, opts ...option.RequestOption) (res *ZonesImageResizing, err error) { + opts = append(r.Options[:], opts...) + var env SettingImageResizingGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/image_resizing", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Image Resizing provides on-demand resizing, conversion and optimisation for +// images served through Cloudflare's network. Refer to the +// [Image Resizing documentation](https://developers.cloudflare.com/images/) for +// more information. +type ZonesImageResizing struct { + // ID of the zone setting. + ID ZonesImageResizingID `json:"id,required"` + // Current value of the zone setting. + Value ZonesImageResizingValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesImageResizingEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesImageResizingJSON `json:"-"` +} + +// zonesImageResizingJSON contains the JSON metadata for the struct +// [ZonesImageResizing] +type zonesImageResizingJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesImageResizing) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesImageResizingJSON) RawJSON() string { + return r.raw +} + +func (r ZonesImageResizing) implementsZonesSettingEditResponse() {} + +func (r ZonesImageResizing) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesImageResizingID string + +const ( + ZonesImageResizingIDImageResizing ZonesImageResizingID = "image_resizing" +) + +// Current value of the zone setting. +type ZonesImageResizingValue string + +const ( + ZonesImageResizingValueOn ZonesImageResizingValue = "on" + ZonesImageResizingValueOff ZonesImageResizingValue = "off" + ZonesImageResizingValueOpen ZonesImageResizingValue = "open" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesImageResizingEditable bool + +const ( + ZonesImageResizingEditableTrue ZonesImageResizingEditable = true + ZonesImageResizingEditableFalse ZonesImageResizingEditable = false +) + +// Image Resizing provides on-demand resizing, conversion and optimisation for +// images served through Cloudflare's network. Refer to the +// [Image Resizing documentation](https://developers.cloudflare.com/images/) for +// more information. +type ZonesImageResizingParam struct { + // ID of the zone setting. + ID param.Field[ZonesImageResizingID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesImageResizingValue] `json:"value,required"` +} + +func (r ZonesImageResizingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesImageResizingParam) implementsZonesSettingEditParamsItem() {} + +type SettingImageResizingEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Image Resizing provides on-demand resizing, conversion and optimisation for + // images served through Cloudflare's network. Refer to the + // [Image Resizing documentation](https://developers.cloudflare.com/images/) for + // more information. + Value param.Field[ZonesImageResizingParam] `json:"value,required"` +} + +func (r SettingImageResizingEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingImageResizingEditResponseEnvelope struct { + Errors []SettingImageResizingEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingImageResizingEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Image Resizing provides on-demand resizing, conversion and optimisation for + // images served through Cloudflare's network. Refer to the + // [Image Resizing documentation](https://developers.cloudflare.com/images/) for + // more information. + Result ZonesImageResizing `json:"result"` + JSON settingImageResizingEditResponseEnvelopeJSON `json:"-"` +} + +// settingImageResizingEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingImageResizingEditResponseEnvelope] +type settingImageResizingEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingImageResizingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingImageResizingEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingImageResizingEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingImageResizingEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingImageResizingEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingImageResizingEditResponseEnvelopeErrors] +type settingImageResizingEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingImageResizingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingImageResizingEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingImageResizingEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingImageResizingEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingImageResizingEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingImageResizingEditResponseEnvelopeMessages] +type settingImageResizingEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingImageResizingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingImageResizingEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingImageResizingGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingImageResizingGetResponseEnvelope struct { + Errors []SettingImageResizingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingImageResizingGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Image Resizing provides on-demand resizing, conversion and optimisation for + // images served through Cloudflare's network. Refer to the + // [Image Resizing documentation](https://developers.cloudflare.com/images/) for + // more information. + Result ZonesImageResizing `json:"result"` + JSON settingImageResizingGetResponseEnvelopeJSON `json:"-"` +} + +// settingImageResizingGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingImageResizingGetResponseEnvelope] +type settingImageResizingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingImageResizingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingImageResizingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingImageResizingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingImageResizingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingImageResizingGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingImageResizingGetResponseEnvelopeErrors] +type settingImageResizingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingImageResizingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingImageResizingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingImageResizingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingImageResizingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingImageResizingGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingImageResizingGetResponseEnvelopeMessages] +type settingImageResizingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingImageResizingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingImageResizingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingimageresizing_test.go b/zones/settingimageresizing_test.go new file mode 100644 index 00000000000..f082af6870b --- /dev/null +++ b/zones/settingimageresizing_test.go @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingImageResizingEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Zones.Settings.ImageResizing.Edit(context.TODO(), zones.SettingImageResizingEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.ZonesImageResizingParam{ + ID: cloudflare.F(zones.ZonesImageResizingIDImageResizing), + Value: cloudflare.F(zones.ZonesImageResizingValueOn), + }), + }) + 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 TestSettingImageResizingGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.ImageResizing.Get(context.TODO(), zones.SettingImageResizingGetParams{ + ZoneID: cloudflare.F("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/zones/settingipgeolocation.go b/zones/settingipgeolocation.go new file mode 100644 index 00000000000..2b26a3af8b9 --- /dev/null +++ b/zones/settingipgeolocation.go @@ -0,0 +1,320 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingIPGeolocationService 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 [NewSettingIPGeolocationService] +// method instead. +type SettingIPGeolocationService struct { + Options []option.RequestOption +} + +// NewSettingIPGeolocationService 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 NewSettingIPGeolocationService(opts ...option.RequestOption) (r *SettingIPGeolocationService) { + r = &SettingIPGeolocationService{} + r.Options = opts + return +} + +// Enable IP Geolocation to have Cloudflare geolocate visitors to your website and +// pass the country code to you. +// (https://support.cloudflare.com/hc/en-us/articles/200168236). +func (r *SettingIPGeolocationService) Edit(ctx context.Context, params SettingIPGeolocationEditParams, opts ...option.RequestOption) (res *ZonesIPGeolocation, err error) { + opts = append(r.Options[:], opts...) + var env SettingIPGeolocationEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/ip_geolocation", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Enable IP Geolocation to have Cloudflare geolocate visitors to your website and +// pass the country code to you. +// (https://support.cloudflare.com/hc/en-us/articles/200168236). +func (r *SettingIPGeolocationService) Get(ctx context.Context, query SettingIPGeolocationGetParams, opts ...option.RequestOption) (res *ZonesIPGeolocation, err error) { + opts = append(r.Options[:], opts...) + var env SettingIPGeolocationGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/ip_geolocation", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Enable IP Geolocation to have Cloudflare geolocate visitors to your website and +// pass the country code to you. +// (https://support.cloudflare.com/hc/en-us/articles/200168236). +type ZonesIPGeolocation struct { + // ID of the zone setting. + ID ZonesIPGeolocationID `json:"id,required"` + // Current value of the zone setting. + Value ZonesIPGeolocationValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesIPGeolocationEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesIPGeolocationJSON `json:"-"` +} + +// zonesIPGeolocationJSON contains the JSON metadata for the struct +// [ZonesIPGeolocation] +type zonesIPGeolocationJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesIPGeolocation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesIPGeolocationJSON) RawJSON() string { + return r.raw +} + +func (r ZonesIPGeolocation) implementsZonesSettingEditResponse() {} + +func (r ZonesIPGeolocation) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesIPGeolocationID string + +const ( + ZonesIPGeolocationIDIPGeolocation ZonesIPGeolocationID = "ip_geolocation" +) + +// Current value of the zone setting. +type ZonesIPGeolocationValue string + +const ( + ZonesIPGeolocationValueOn ZonesIPGeolocationValue = "on" + ZonesIPGeolocationValueOff ZonesIPGeolocationValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesIPGeolocationEditable bool + +const ( + ZonesIPGeolocationEditableTrue ZonesIPGeolocationEditable = true + ZonesIPGeolocationEditableFalse ZonesIPGeolocationEditable = false +) + +// Enable IP Geolocation to have Cloudflare geolocate visitors to your website and +// pass the country code to you. +// (https://support.cloudflare.com/hc/en-us/articles/200168236). +type ZonesIPGeolocationParam struct { + // ID of the zone setting. + ID param.Field[ZonesIPGeolocationID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesIPGeolocationValue] `json:"value,required"` +} + +func (r ZonesIPGeolocationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesIPGeolocationParam) implementsZonesSettingEditParamsItem() {} + +type SettingIPGeolocationEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingIPGeolocationEditParamsValue] `json:"value,required"` +} + +func (r SettingIPGeolocationEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingIPGeolocationEditParamsValue string + +const ( + SettingIPGeolocationEditParamsValueOn SettingIPGeolocationEditParamsValue = "on" + SettingIPGeolocationEditParamsValueOff SettingIPGeolocationEditParamsValue = "off" +) + +type SettingIPGeolocationEditResponseEnvelope struct { + Errors []SettingIPGeolocationEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingIPGeolocationEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Enable IP Geolocation to have Cloudflare geolocate visitors to your website and + // pass the country code to you. + // (https://support.cloudflare.com/hc/en-us/articles/200168236). + Result ZonesIPGeolocation `json:"result"` + JSON settingIPGeolocationEditResponseEnvelopeJSON `json:"-"` +} + +// settingIPGeolocationEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingIPGeolocationEditResponseEnvelope] +type settingIPGeolocationEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingIPGeolocationEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingIPGeolocationEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingIPGeolocationEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingIPGeolocationEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingIPGeolocationEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingIPGeolocationEditResponseEnvelopeErrors] +type settingIPGeolocationEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingIPGeolocationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingIPGeolocationEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingIPGeolocationEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingIPGeolocationEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingIPGeolocationEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingIPGeolocationEditResponseEnvelopeMessages] +type settingIPGeolocationEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingIPGeolocationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingIPGeolocationEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingIPGeolocationGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingIPGeolocationGetResponseEnvelope struct { + Errors []SettingIPGeolocationGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingIPGeolocationGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Enable IP Geolocation to have Cloudflare geolocate visitors to your website and + // pass the country code to you. + // (https://support.cloudflare.com/hc/en-us/articles/200168236). + Result ZonesIPGeolocation `json:"result"` + JSON settingIPGeolocationGetResponseEnvelopeJSON `json:"-"` +} + +// settingIPGeolocationGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingIPGeolocationGetResponseEnvelope] +type settingIPGeolocationGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingIPGeolocationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingIPGeolocationGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingIPGeolocationGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingIPGeolocationGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingIPGeolocationGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingIPGeolocationGetResponseEnvelopeErrors] +type settingIPGeolocationGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingIPGeolocationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingIPGeolocationGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingIPGeolocationGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingIPGeolocationGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingIPGeolocationGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingIPGeolocationGetResponseEnvelopeMessages] +type settingIPGeolocationGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingIPGeolocationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingIPGeolocationGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingipgeolocation_test.go b/zones/settingipgeolocation_test.go new file mode 100644 index 00000000000..84e67e3b7d1 --- /dev/null +++ b/zones/settingipgeolocation_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingIPGeolocationEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.IPGeolocation.Edit(context.TODO(), zones.SettingIPGeolocationEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingIPGeolocationEditParamsValueOn), + }) + 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 TestSettingIPGeolocationGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.IPGeolocation.Get(context.TODO(), zones.SettingIPGeolocationGetParams{ + ZoneID: cloudflare.F("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/zones/settingipv6.go b/zones/settingipv6.go new file mode 100644 index 00000000000..ab6c5c4dab8 --- /dev/null +++ b/zones/settingipv6.go @@ -0,0 +1,313 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingIPV6Service 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 [NewSettingIPV6Service] method +// instead. +type SettingIPV6Service struct { + Options []option.RequestOption +} + +// NewSettingIPV6Service 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 NewSettingIPV6Service(opts ...option.RequestOption) (r *SettingIPV6Service) { + r = &SettingIPV6Service{} + r.Options = opts + return +} + +// Enable IPv6 on all subdomains that are Cloudflare enabled. +// (https://support.cloudflare.com/hc/en-us/articles/200168586). +func (r *SettingIPV6Service) Edit(ctx context.Context, params SettingIPV6EditParams, opts ...option.RequestOption) (res *ZonesIPV6, err error) { + opts = append(r.Options[:], opts...) + var env SettingIPV6EditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/ipv6", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Enable IPv6 on all subdomains that are Cloudflare enabled. +// (https://support.cloudflare.com/hc/en-us/articles/200168586). +func (r *SettingIPV6Service) Get(ctx context.Context, query SettingIPV6GetParams, opts ...option.RequestOption) (res *ZonesIPV6, err error) { + opts = append(r.Options[:], opts...) + var env SettingIPV6GetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/ipv6", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Enable IPv6 on all subdomains that are Cloudflare enabled. +// (https://support.cloudflare.com/hc/en-us/articles/200168586). +type ZonesIPV6 struct { + // ID of the zone setting. + ID ZonesIPV6ID `json:"id,required"` + // Current value of the zone setting. + Value ZonesIPV6Value `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesIPV6Editable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesIPV6JSON `json:"-"` +} + +// zonesIPV6JSON contains the JSON metadata for the struct [ZonesIPV6] +type zonesIPV6JSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesIPV6) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesIPV6JSON) RawJSON() string { + return r.raw +} + +func (r ZonesIPV6) implementsZonesSettingEditResponse() {} + +func (r ZonesIPV6) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesIPV6ID string + +const ( + ZonesIPV6IDIPV6 ZonesIPV6ID = "ipv6" +) + +// Current value of the zone setting. +type ZonesIPV6Value string + +const ( + ZonesIPV6ValueOff ZonesIPV6Value = "off" + ZonesIPV6ValueOn ZonesIPV6Value = "on" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesIPV6Editable bool + +const ( + ZonesIPV6EditableTrue ZonesIPV6Editable = true + ZonesIPV6EditableFalse ZonesIPV6Editable = false +) + +// Enable IPv6 on all subdomains that are Cloudflare enabled. +// (https://support.cloudflare.com/hc/en-us/articles/200168586). +type ZonesIPV6Param struct { + // ID of the zone setting. + ID param.Field[ZonesIPV6ID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesIPV6Value] `json:"value,required"` +} + +func (r ZonesIPV6Param) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesIPV6Param) implementsZonesSettingEditParamsItem() {} + +type SettingIPV6EditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingIPV6EditParamsValue] `json:"value,required"` +} + +func (r SettingIPV6EditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingIPV6EditParamsValue string + +const ( + SettingIPV6EditParamsValueOff SettingIPV6EditParamsValue = "off" + SettingIPV6EditParamsValueOn SettingIPV6EditParamsValue = "on" +) + +type SettingIPV6EditResponseEnvelope struct { + Errors []SettingIPV6EditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingIPV6EditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Enable IPv6 on all subdomains that are Cloudflare enabled. + // (https://support.cloudflare.com/hc/en-us/articles/200168586). + Result ZonesIPV6 `json:"result"` + JSON settingIPV6EditResponseEnvelopeJSON `json:"-"` +} + +// settingIPV6EditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingIPV6EditResponseEnvelope] +type settingIPV6EditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingIPV6EditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingIPV6EditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingIPV6EditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingIPV6EditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingIPV6EditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingIPV6EditResponseEnvelopeErrors] +type settingIPV6EditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingIPV6EditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingIPV6EditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingIPV6EditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingIPV6EditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingIPV6EditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingIPV6EditResponseEnvelopeMessages] +type settingIPV6EditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingIPV6EditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingIPV6EditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingIPV6GetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingIPV6GetResponseEnvelope struct { + Errors []SettingIPV6GetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingIPV6GetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Enable IPv6 on all subdomains that are Cloudflare enabled. + // (https://support.cloudflare.com/hc/en-us/articles/200168586). + Result ZonesIPV6 `json:"result"` + JSON settingIPV6GetResponseEnvelopeJSON `json:"-"` +} + +// settingIPV6GetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingIPV6GetResponseEnvelope] +type settingIPV6GetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingIPV6GetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingIPV6GetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingIPV6GetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingIPV6GetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingIPV6GetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingIPV6GetResponseEnvelopeErrors] +type settingIPV6GetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingIPV6GetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingIPV6GetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingIPV6GetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingIPV6GetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingIPV6GetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingIPV6GetResponseEnvelopeMessages] +type settingIPV6GetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingIPV6GetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingIPV6GetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingipv6_test.go b/zones/settingipv6_test.go new file mode 100644 index 00000000000..155b4556285 --- /dev/null +++ b/zones/settingipv6_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingIPV6Edit(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("user@example.com"), + ) + _, err := client.Zones.Settings.IPV6.Edit(context.TODO(), zones.SettingIPV6EditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingIPV6EditParamsValueOff), + }) + 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 TestSettingIPV6Get(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("user@example.com"), + ) + _, err := client.Zones.Settings.IPV6.Get(context.TODO(), zones.SettingIPV6GetParams{ + ZoneID: cloudflare.F("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/zones/settingminify.go b/zones/settingminify.go new file mode 100644 index 00000000000..efc2b4d6747 --- /dev/null +++ b/zones/settingminify.go @@ -0,0 +1,408 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingMinifyService 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 [NewSettingMinifyService] method +// instead. +type SettingMinifyService struct { + Options []option.RequestOption +} + +// NewSettingMinifyService 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 NewSettingMinifyService(opts ...option.RequestOption) (r *SettingMinifyService) { + r = &SettingMinifyService{} + r.Options = opts + return +} + +// Automatically minify certain assets for your website. Refer to +// [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) +// for more information. +func (r *SettingMinifyService) Edit(ctx context.Context, params SettingMinifyEditParams, opts ...option.RequestOption) (res *ZonesMinify, err error) { + opts = append(r.Options[:], opts...) + var env SettingMinifyEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/minify", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Automatically minify certain assets for your website. Refer to +// [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) +// for more information. +func (r *SettingMinifyService) Get(ctx context.Context, query SettingMinifyGetParams, opts ...option.RequestOption) (res *ZonesMinify, err error) { + opts = append(r.Options[:], opts...) + var env SettingMinifyGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/minify", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Automatically minify certain assets for your website. Refer to +// [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) +// for more information. +type ZonesMinify struct { + // Zone setting identifier. + ID ZonesMinifyID `json:"id,required"` + // Current value of the zone setting. + Value ZonesMinifyValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesMinifyEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesMinifyJSON `json:"-"` +} + +// zonesMinifyJSON contains the JSON metadata for the struct [ZonesMinify] +type zonesMinifyJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesMinify) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesMinifyJSON) RawJSON() string { + return r.raw +} + +func (r ZonesMinify) implementsZonesSettingEditResponse() {} + +func (r ZonesMinify) implementsZonesSettingGetResponse() {} + +// Zone setting identifier. +type ZonesMinifyID string + +const ( + ZonesMinifyIDMinify ZonesMinifyID = "minify" +) + +// Current value of the zone setting. +type ZonesMinifyValue struct { + // Automatically minify all CSS files for your website. + Css ZonesMinifyValueCss `json:"css"` + // Automatically minify all HTML files for your website. + HTML ZonesMinifyValueHTML `json:"html"` + // Automatically minify all JavaScript files for your website. + Js ZonesMinifyValueJs `json:"js"` + JSON zonesMinifyValueJSON `json:"-"` +} + +// zonesMinifyValueJSON contains the JSON metadata for the struct +// [ZonesMinifyValue] +type zonesMinifyValueJSON struct { + Css apijson.Field + HTML apijson.Field + Js apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesMinifyValue) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesMinifyValueJSON) RawJSON() string { + return r.raw +} + +// Automatically minify all CSS files for your website. +type ZonesMinifyValueCss string + +const ( + ZonesMinifyValueCssOn ZonesMinifyValueCss = "on" + ZonesMinifyValueCssOff ZonesMinifyValueCss = "off" +) + +// Automatically minify all HTML files for your website. +type ZonesMinifyValueHTML string + +const ( + ZonesMinifyValueHTMLOn ZonesMinifyValueHTML = "on" + ZonesMinifyValueHTMLOff ZonesMinifyValueHTML = "off" +) + +// Automatically minify all JavaScript files for your website. +type ZonesMinifyValueJs string + +const ( + ZonesMinifyValueJsOn ZonesMinifyValueJs = "on" + ZonesMinifyValueJsOff ZonesMinifyValueJs = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesMinifyEditable bool + +const ( + ZonesMinifyEditableTrue ZonesMinifyEditable = true + ZonesMinifyEditableFalse ZonesMinifyEditable = false +) + +// Automatically minify certain assets for your website. Refer to +// [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) +// for more information. +type ZonesMinifyParam struct { + // Zone setting identifier. + ID param.Field[ZonesMinifyID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesMinifyValueParam] `json:"value,required"` +} + +func (r ZonesMinifyParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesMinifyParam) implementsZonesSettingEditParamsItem() {} + +// Current value of the zone setting. +type ZonesMinifyValueParam struct { + // Automatically minify all CSS files for your website. + Css param.Field[ZonesMinifyValueCss] `json:"css"` + // Automatically minify all HTML files for your website. + HTML param.Field[ZonesMinifyValueHTML] `json:"html"` + // Automatically minify all JavaScript files for your website. + Js param.Field[ZonesMinifyValueJs] `json:"js"` +} + +func (r ZonesMinifyValueParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingMinifyEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingMinifyEditParamsValue] `json:"value,required"` +} + +func (r SettingMinifyEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingMinifyEditParamsValue struct { + // Automatically minify all CSS files for your website. + Css param.Field[SettingMinifyEditParamsValueCss] `json:"css"` + // Automatically minify all HTML files for your website. + HTML param.Field[SettingMinifyEditParamsValueHTML] `json:"html"` + // Automatically minify all JavaScript files for your website. + Js param.Field[SettingMinifyEditParamsValueJs] `json:"js"` +} + +func (r SettingMinifyEditParamsValue) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Automatically minify all CSS files for your website. +type SettingMinifyEditParamsValueCss string + +const ( + SettingMinifyEditParamsValueCssOn SettingMinifyEditParamsValueCss = "on" + SettingMinifyEditParamsValueCssOff SettingMinifyEditParamsValueCss = "off" +) + +// Automatically minify all HTML files for your website. +type SettingMinifyEditParamsValueHTML string + +const ( + SettingMinifyEditParamsValueHTMLOn SettingMinifyEditParamsValueHTML = "on" + SettingMinifyEditParamsValueHTMLOff SettingMinifyEditParamsValueHTML = "off" +) + +// Automatically minify all JavaScript files for your website. +type SettingMinifyEditParamsValueJs string + +const ( + SettingMinifyEditParamsValueJsOn SettingMinifyEditParamsValueJs = "on" + SettingMinifyEditParamsValueJsOff SettingMinifyEditParamsValueJs = "off" +) + +type SettingMinifyEditResponseEnvelope struct { + Errors []SettingMinifyEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingMinifyEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Automatically minify certain assets for your website. Refer to + // [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) + // for more information. + Result ZonesMinify `json:"result"` + JSON settingMinifyEditResponseEnvelopeJSON `json:"-"` +} + +// settingMinifyEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingMinifyEditResponseEnvelope] +type settingMinifyEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMinifyEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMinifyEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingMinifyEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingMinifyEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingMinifyEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingMinifyEditResponseEnvelopeErrors] +type settingMinifyEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMinifyEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMinifyEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingMinifyEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingMinifyEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingMinifyEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingMinifyEditResponseEnvelopeMessages] +type settingMinifyEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMinifyEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMinifyEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingMinifyGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingMinifyGetResponseEnvelope struct { + Errors []SettingMinifyGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingMinifyGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Automatically minify certain assets for your website. Refer to + // [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) + // for more information. + Result ZonesMinify `json:"result"` + JSON settingMinifyGetResponseEnvelopeJSON `json:"-"` +} + +// settingMinifyGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingMinifyGetResponseEnvelope] +type settingMinifyGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMinifyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMinifyGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingMinifyGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingMinifyGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingMinifyGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingMinifyGetResponseEnvelopeErrors] +type settingMinifyGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMinifyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMinifyGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingMinifyGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingMinifyGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingMinifyGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingMinifyGetResponseEnvelopeMessages] +type settingMinifyGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMinifyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMinifyGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingminify_test.go b/zones/settingminify_test.go new file mode 100644 index 00000000000..3cab746932c --- /dev/null +++ b/zones/settingminify_test.go @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingMinifyEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Zones.Settings.Minify.Edit(context.TODO(), zones.SettingMinifyEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingMinifyEditParamsValue{ + Css: cloudflare.F(zones.SettingMinifyEditParamsValueCssOn), + HTML: cloudflare.F(zones.SettingMinifyEditParamsValueHTMLOn), + Js: cloudflare.F(zones.SettingMinifyEditParamsValueJsOn), + }), + }) + 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 TestSettingMinifyGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.Minify.Get(context.TODO(), zones.SettingMinifyGetParams{ + ZoneID: cloudflare.F("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/zones/settingmintlsversion.go b/zones/settingmintlsversion.go new file mode 100644 index 00000000000..d742f8692f9 --- /dev/null +++ b/zones/settingmintlsversion.go @@ -0,0 +1,320 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingMinTLSVersionService 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 [NewSettingMinTLSVersionService] +// method instead. +type SettingMinTLSVersionService struct { + Options []option.RequestOption +} + +// NewSettingMinTLSVersionService 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 NewSettingMinTLSVersionService(opts ...option.RequestOption) (r *SettingMinTLSVersionService) { + r = &SettingMinTLSVersionService{} + r.Options = opts + return +} + +// Changes Minimum TLS Version setting. +func (r *SettingMinTLSVersionService) Edit(ctx context.Context, params SettingMinTLSVersionEditParams, opts ...option.RequestOption) (res *ZonesMinTLSVersion, err error) { + opts = append(r.Options[:], opts...) + var env SettingMinTLSVersionEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/min_tls_version", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets Minimum TLS Version setting. +func (r *SettingMinTLSVersionService) Get(ctx context.Context, query SettingMinTLSVersionGetParams, opts ...option.RequestOption) (res *ZonesMinTLSVersion, err error) { + opts = append(r.Options[:], opts...) + var env SettingMinTLSVersionGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/min_tls_version", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Only accepts HTTPS requests that use at least the TLS protocol version +// specified. For example, if TLS 1.1 is selected, TLS 1.0 connections will be +// rejected, while 1.1, 1.2, and 1.3 (if enabled) will be permitted. +type ZonesMinTLSVersion struct { + // ID of the zone setting. + ID ZonesMinTLSVersionID `json:"id,required"` + // Current value of the zone setting. + Value ZonesMinTLSVersionValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesMinTLSVersionEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesMinTLSVersionJSON `json:"-"` +} + +// zonesMinTLSVersionJSON contains the JSON metadata for the struct +// [ZonesMinTLSVersion] +type zonesMinTLSVersionJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesMinTLSVersion) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesMinTLSVersionJSON) RawJSON() string { + return r.raw +} + +func (r ZonesMinTLSVersion) implementsZonesSettingEditResponse() {} + +func (r ZonesMinTLSVersion) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesMinTLSVersionID string + +const ( + ZonesMinTLSVersionIDMinTLSVersion ZonesMinTLSVersionID = "min_tls_version" +) + +// Current value of the zone setting. +type ZonesMinTLSVersionValue string + +const ( + ZonesMinTLSVersionValue1_0 ZonesMinTLSVersionValue = "1.0" + ZonesMinTLSVersionValue1_1 ZonesMinTLSVersionValue = "1.1" + ZonesMinTLSVersionValue1_2 ZonesMinTLSVersionValue = "1.2" + ZonesMinTLSVersionValue1_3 ZonesMinTLSVersionValue = "1.3" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesMinTLSVersionEditable bool + +const ( + ZonesMinTLSVersionEditableTrue ZonesMinTLSVersionEditable = true + ZonesMinTLSVersionEditableFalse ZonesMinTLSVersionEditable = false +) + +// Only accepts HTTPS requests that use at least the TLS protocol version +// specified. For example, if TLS 1.1 is selected, TLS 1.0 connections will be +// rejected, while 1.1, 1.2, and 1.3 (if enabled) will be permitted. +type ZonesMinTLSVersionParam struct { + // ID of the zone setting. + ID param.Field[ZonesMinTLSVersionID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesMinTLSVersionValue] `json:"value,required"` +} + +func (r ZonesMinTLSVersionParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesMinTLSVersionParam) implementsZonesSettingEditParamsItem() {} + +type SettingMinTLSVersionEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingMinTLSVersionEditParamsValue] `json:"value,required"` +} + +func (r SettingMinTLSVersionEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingMinTLSVersionEditParamsValue string + +const ( + SettingMinTLSVersionEditParamsValue1_0 SettingMinTLSVersionEditParamsValue = "1.0" + SettingMinTLSVersionEditParamsValue1_1 SettingMinTLSVersionEditParamsValue = "1.1" + SettingMinTLSVersionEditParamsValue1_2 SettingMinTLSVersionEditParamsValue = "1.2" + SettingMinTLSVersionEditParamsValue1_3 SettingMinTLSVersionEditParamsValue = "1.3" +) + +type SettingMinTLSVersionEditResponseEnvelope struct { + Errors []SettingMinTLSVersionEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingMinTLSVersionEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Only accepts HTTPS requests that use at least the TLS protocol version + // specified. For example, if TLS 1.1 is selected, TLS 1.0 connections will be + // rejected, while 1.1, 1.2, and 1.3 (if enabled) will be permitted. + Result ZonesMinTLSVersion `json:"result"` + JSON settingMinTLSVersionEditResponseEnvelopeJSON `json:"-"` +} + +// settingMinTLSVersionEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingMinTLSVersionEditResponseEnvelope] +type settingMinTLSVersionEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMinTLSVersionEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMinTLSVersionEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingMinTLSVersionEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingMinTLSVersionEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingMinTLSVersionEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingMinTLSVersionEditResponseEnvelopeErrors] +type settingMinTLSVersionEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMinTLSVersionEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMinTLSVersionEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingMinTLSVersionEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingMinTLSVersionEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingMinTLSVersionEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingMinTLSVersionEditResponseEnvelopeMessages] +type settingMinTLSVersionEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMinTLSVersionEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMinTLSVersionEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingMinTLSVersionGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingMinTLSVersionGetResponseEnvelope struct { + Errors []SettingMinTLSVersionGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingMinTLSVersionGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Only accepts HTTPS requests that use at least the TLS protocol version + // specified. For example, if TLS 1.1 is selected, TLS 1.0 connections will be + // rejected, while 1.1, 1.2, and 1.3 (if enabled) will be permitted. + Result ZonesMinTLSVersion `json:"result"` + JSON settingMinTLSVersionGetResponseEnvelopeJSON `json:"-"` +} + +// settingMinTLSVersionGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingMinTLSVersionGetResponseEnvelope] +type settingMinTLSVersionGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMinTLSVersionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMinTLSVersionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingMinTLSVersionGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingMinTLSVersionGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingMinTLSVersionGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingMinTLSVersionGetResponseEnvelopeErrors] +type settingMinTLSVersionGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMinTLSVersionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMinTLSVersionGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingMinTLSVersionGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingMinTLSVersionGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingMinTLSVersionGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingMinTLSVersionGetResponseEnvelopeMessages] +type settingMinTLSVersionGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMinTLSVersionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMinTLSVersionGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingmintlsversion_test.go b/zones/settingmintlsversion_test.go new file mode 100644 index 00000000000..5253ba06c36 --- /dev/null +++ b/zones/settingmintlsversion_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingMinTLSVersionEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.MinTLSVersion.Edit(context.TODO(), zones.SettingMinTLSVersionEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingMinTLSVersionEditParamsValue1_0), + }) + 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 TestSettingMinTLSVersionGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.MinTLSVersion.Get(context.TODO(), zones.SettingMinTLSVersionGetParams{ + ZoneID: cloudflare.F("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/zones/settingmirage.go b/zones/settingmirage.go new file mode 100644 index 00000000000..61444756463 --- /dev/null +++ b/zones/settingmirage.go @@ -0,0 +1,325 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingMirageService 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 [NewSettingMirageService] method +// instead. +type SettingMirageService struct { + Options []option.RequestOption +} + +// NewSettingMirageService 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 NewSettingMirageService(opts ...option.RequestOption) (r *SettingMirageService) { + r = &SettingMirageService{} + r.Options = opts + return +} + +// Automatically optimize image loading for website visitors on mobile devices. +// Refer to our +// [blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for more +// information. +func (r *SettingMirageService) Edit(ctx context.Context, params SettingMirageEditParams, opts ...option.RequestOption) (res *ZonesMirage, err error) { + opts = append(r.Options[:], opts...) + var env SettingMirageEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/mirage", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Automatically optimize image loading for website visitors on mobile devices. +// Refer to our +// [blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for more +// information. +func (r *SettingMirageService) Get(ctx context.Context, query SettingMirageGetParams, opts ...option.RequestOption) (res *ZonesMirage, err error) { + opts = append(r.Options[:], opts...) + var env SettingMirageGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/mirage", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Automatically optimize image loading for website visitors on mobile devices. +// Refer to +// [our blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for +// more information. +type ZonesMirage struct { + // ID of the zone setting. + ID ZonesMirageID `json:"id,required"` + // Current value of the zone setting. + Value ZonesMirageValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesMirageEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesMirageJSON `json:"-"` +} + +// zonesMirageJSON contains the JSON metadata for the struct [ZonesMirage] +type zonesMirageJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesMirage) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesMirageJSON) RawJSON() string { + return r.raw +} + +func (r ZonesMirage) implementsZonesSettingEditResponse() {} + +func (r ZonesMirage) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesMirageID string + +const ( + ZonesMirageIDMirage ZonesMirageID = "mirage" +) + +// Current value of the zone setting. +type ZonesMirageValue string + +const ( + ZonesMirageValueOn ZonesMirageValue = "on" + ZonesMirageValueOff ZonesMirageValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesMirageEditable bool + +const ( + ZonesMirageEditableTrue ZonesMirageEditable = true + ZonesMirageEditableFalse ZonesMirageEditable = false +) + +// Automatically optimize image loading for website visitors on mobile devices. +// Refer to +// [our blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for +// more information. +type ZonesMirageParam struct { + // ID of the zone setting. + ID param.Field[ZonesMirageID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesMirageValue] `json:"value,required"` +} + +func (r ZonesMirageParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesMirageParam) implementsZonesSettingEditParamsItem() {} + +type SettingMirageEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingMirageEditParamsValue] `json:"value,required"` +} + +func (r SettingMirageEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingMirageEditParamsValue string + +const ( + SettingMirageEditParamsValueOn SettingMirageEditParamsValue = "on" + SettingMirageEditParamsValueOff SettingMirageEditParamsValue = "off" +) + +type SettingMirageEditResponseEnvelope struct { + Errors []SettingMirageEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingMirageEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Automatically optimize image loading for website visitors on mobile devices. + // Refer to + // [our blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for + // more information. + Result ZonesMirage `json:"result"` + JSON settingMirageEditResponseEnvelopeJSON `json:"-"` +} + +// settingMirageEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingMirageEditResponseEnvelope] +type settingMirageEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMirageEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMirageEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingMirageEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingMirageEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingMirageEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingMirageEditResponseEnvelopeErrors] +type settingMirageEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMirageEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMirageEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingMirageEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingMirageEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingMirageEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingMirageEditResponseEnvelopeMessages] +type settingMirageEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMirageEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMirageEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingMirageGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingMirageGetResponseEnvelope struct { + Errors []SettingMirageGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingMirageGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Automatically optimize image loading for website visitors on mobile devices. + // Refer to + // [our blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for + // more information. + Result ZonesMirage `json:"result"` + JSON settingMirageGetResponseEnvelopeJSON `json:"-"` +} + +// settingMirageGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingMirageGetResponseEnvelope] +type settingMirageGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMirageGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMirageGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingMirageGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingMirageGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingMirageGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingMirageGetResponseEnvelopeErrors] +type settingMirageGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMirageGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMirageGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingMirageGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingMirageGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingMirageGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingMirageGetResponseEnvelopeMessages] +type settingMirageGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMirageGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMirageGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingmirage_test.go b/zones/settingmirage_test.go new file mode 100644 index 00000000000..ebc1c2146c3 --- /dev/null +++ b/zones/settingmirage_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingMirageEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.Mirage.Edit(context.TODO(), zones.SettingMirageEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingMirageEditParamsValueOn), + }) + 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 TestSettingMirageGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.Mirage.Get(context.TODO(), zones.SettingMirageGetParams{ + ZoneID: cloudflare.F("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/zones/settingmobileredirect.go b/zones/settingmobileredirect.go new file mode 100644 index 00000000000..b4dda8c4798 --- /dev/null +++ b/zones/settingmobileredirect.go @@ -0,0 +1,389 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingMobileRedirectService 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 [NewSettingMobileRedirectService] +// method instead. +type SettingMobileRedirectService struct { + Options []option.RequestOption +} + +// NewSettingMobileRedirectService 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 NewSettingMobileRedirectService(opts ...option.RequestOption) (r *SettingMobileRedirectService) { + r = &SettingMobileRedirectService{} + r.Options = opts + return +} + +// Automatically redirect visitors on mobile devices to a mobile-optimized +// subdomain. Refer to +// [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) +// for more information. +func (r *SettingMobileRedirectService) Edit(ctx context.Context, params SettingMobileRedirectEditParams, opts ...option.RequestOption) (res *ZonesMobileRedirect, err error) { + opts = append(r.Options[:], opts...) + var env SettingMobileRedirectEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/mobile_redirect", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Automatically redirect visitors on mobile devices to a mobile-optimized +// subdomain. Refer to +// [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) +// for more information. +func (r *SettingMobileRedirectService) Get(ctx context.Context, query SettingMobileRedirectGetParams, opts ...option.RequestOption) (res *ZonesMobileRedirect, err error) { + opts = append(r.Options[:], opts...) + var env SettingMobileRedirectGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/mobile_redirect", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Automatically redirect visitors on mobile devices to a mobile-optimized +// subdomain. Refer to +// [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) +// for more information. +type ZonesMobileRedirect struct { + // Identifier of the zone setting. + ID ZonesMobileRedirectID `json:"id,required"` + // Current value of the zone setting. + Value ZonesMobileRedirectValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesMobileRedirectEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesMobileRedirectJSON `json:"-"` +} + +// zonesMobileRedirectJSON contains the JSON metadata for the struct +// [ZonesMobileRedirect] +type zonesMobileRedirectJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesMobileRedirect) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesMobileRedirectJSON) RawJSON() string { + return r.raw +} + +func (r ZonesMobileRedirect) implementsZonesSettingEditResponse() {} + +func (r ZonesMobileRedirect) implementsZonesSettingGetResponse() {} + +// Identifier of the zone setting. +type ZonesMobileRedirectID string + +const ( + ZonesMobileRedirectIDMobileRedirect ZonesMobileRedirectID = "mobile_redirect" +) + +// Current value of the zone setting. +type ZonesMobileRedirectValue struct { + // Which subdomain prefix you wish to redirect visitors on mobile devices to + // (subdomain must already exist). + MobileSubdomain string `json:"mobile_subdomain,nullable"` + // Whether or not mobile redirect is enabled. + Status ZonesMobileRedirectValueStatus `json:"status"` + // Whether to drop the current page path and redirect to the mobile subdomain URL + // root, or keep the path and redirect to the same page on the mobile subdomain. + StripURI bool `json:"strip_uri"` + JSON zonesMobileRedirectValueJSON `json:"-"` +} + +// zonesMobileRedirectValueJSON contains the JSON metadata for the struct +// [ZonesMobileRedirectValue] +type zonesMobileRedirectValueJSON struct { + MobileSubdomain apijson.Field + Status apijson.Field + StripURI apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesMobileRedirectValue) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesMobileRedirectValueJSON) RawJSON() string { + return r.raw +} + +// Whether or not mobile redirect is enabled. +type ZonesMobileRedirectValueStatus string + +const ( + ZonesMobileRedirectValueStatusOn ZonesMobileRedirectValueStatus = "on" + ZonesMobileRedirectValueStatusOff ZonesMobileRedirectValueStatus = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesMobileRedirectEditable bool + +const ( + ZonesMobileRedirectEditableTrue ZonesMobileRedirectEditable = true + ZonesMobileRedirectEditableFalse ZonesMobileRedirectEditable = false +) + +// Automatically redirect visitors on mobile devices to a mobile-optimized +// subdomain. Refer to +// [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) +// for more information. +type ZonesMobileRedirectParam struct { + // Identifier of the zone setting. + ID param.Field[ZonesMobileRedirectID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesMobileRedirectValueParam] `json:"value,required"` +} + +func (r ZonesMobileRedirectParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesMobileRedirectParam) implementsZonesSettingEditParamsItem() {} + +// Current value of the zone setting. +type ZonesMobileRedirectValueParam struct { + // Which subdomain prefix you wish to redirect visitors on mobile devices to + // (subdomain must already exist). + MobileSubdomain param.Field[string] `json:"mobile_subdomain"` + // Whether or not mobile redirect is enabled. + Status param.Field[ZonesMobileRedirectValueStatus] `json:"status"` + // Whether to drop the current page path and redirect to the mobile subdomain URL + // root, or keep the path and redirect to the same page on the mobile subdomain. + StripURI param.Field[bool] `json:"strip_uri"` +} + +func (r ZonesMobileRedirectValueParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingMobileRedirectEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingMobileRedirectEditParamsValue] `json:"value,required"` +} + +func (r SettingMobileRedirectEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingMobileRedirectEditParamsValue struct { + // Which subdomain prefix you wish to redirect visitors on mobile devices to + // (subdomain must already exist). + MobileSubdomain param.Field[string] `json:"mobile_subdomain"` + // Whether or not mobile redirect is enabled. + Status param.Field[SettingMobileRedirectEditParamsValueStatus] `json:"status"` + // Whether to drop the current page path and redirect to the mobile subdomain URL + // root, or keep the path and redirect to the same page on the mobile subdomain. + StripURI param.Field[bool] `json:"strip_uri"` +} + +func (r SettingMobileRedirectEditParamsValue) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Whether or not mobile redirect is enabled. +type SettingMobileRedirectEditParamsValueStatus string + +const ( + SettingMobileRedirectEditParamsValueStatusOn SettingMobileRedirectEditParamsValueStatus = "on" + SettingMobileRedirectEditParamsValueStatusOff SettingMobileRedirectEditParamsValueStatus = "off" +) + +type SettingMobileRedirectEditResponseEnvelope struct { + Errors []SettingMobileRedirectEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingMobileRedirectEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Automatically redirect visitors on mobile devices to a mobile-optimized + // subdomain. Refer to + // [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) + // for more information. + Result ZonesMobileRedirect `json:"result"` + JSON settingMobileRedirectEditResponseEnvelopeJSON `json:"-"` +} + +// settingMobileRedirectEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingMobileRedirectEditResponseEnvelope] +type settingMobileRedirectEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMobileRedirectEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMobileRedirectEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingMobileRedirectEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingMobileRedirectEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingMobileRedirectEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingMobileRedirectEditResponseEnvelopeErrors] +type settingMobileRedirectEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMobileRedirectEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMobileRedirectEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingMobileRedirectEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingMobileRedirectEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingMobileRedirectEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingMobileRedirectEditResponseEnvelopeMessages] +type settingMobileRedirectEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMobileRedirectEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMobileRedirectEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingMobileRedirectGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingMobileRedirectGetResponseEnvelope struct { + Errors []SettingMobileRedirectGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingMobileRedirectGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Automatically redirect visitors on mobile devices to a mobile-optimized + // subdomain. Refer to + // [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) + // for more information. + Result ZonesMobileRedirect `json:"result"` + JSON settingMobileRedirectGetResponseEnvelopeJSON `json:"-"` +} + +// settingMobileRedirectGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingMobileRedirectGetResponseEnvelope] +type settingMobileRedirectGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMobileRedirectGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMobileRedirectGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingMobileRedirectGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingMobileRedirectGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingMobileRedirectGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingMobileRedirectGetResponseEnvelopeErrors] +type settingMobileRedirectGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMobileRedirectGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMobileRedirectGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingMobileRedirectGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingMobileRedirectGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingMobileRedirectGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingMobileRedirectGetResponseEnvelopeMessages] +type settingMobileRedirectGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingMobileRedirectGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingMobileRedirectGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingmobileredirect_test.go b/zones/settingmobileredirect_test.go new file mode 100644 index 00000000000..614b18b4d47 --- /dev/null +++ b/zones/settingmobileredirect_test.go @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingMobileRedirectEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Zones.Settings.MobileRedirect.Edit(context.TODO(), zones.SettingMobileRedirectEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingMobileRedirectEditParamsValue{ + MobileSubdomain: cloudflare.F("m"), + Status: cloudflare.F(zones.SettingMobileRedirectEditParamsValueStatusOn), + StripURI: cloudflare.F(false), + }), + }) + 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 TestSettingMobileRedirectGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.MobileRedirect.Get(context.TODO(), zones.SettingMobileRedirectGetParams{ + ZoneID: cloudflare.F("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/zones/settingnel.go b/zones/settingnel.go new file mode 100644 index 00000000000..5f2a810c742 --- /dev/null +++ b/zones/settingnel.go @@ -0,0 +1,322 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingNELService 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 [NewSettingNELService] method instead. +type SettingNELService struct { + Options []option.RequestOption +} + +// NewSettingNELService 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 NewSettingNELService(opts ...option.RequestOption) (r *SettingNELService) { + r = &SettingNELService{} + r.Options = opts + return +} + +// Automatically optimize image loading for website visitors on mobile devices. +// Refer to our [blog post](http://blog.cloudflare.com/nel-solving-mobile-speed) +// for more information. +func (r *SettingNELService) Edit(ctx context.Context, params SettingNELEditParams, opts ...option.RequestOption) (res *ZonesNEL, err error) { + opts = append(r.Options[:], opts...) + var env SettingNELEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/nel", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Enable Network Error Logging reporting on your zone. (Beta) +func (r *SettingNELService) Get(ctx context.Context, query SettingNELGetParams, opts ...option.RequestOption) (res *ZonesNEL, err error) { + opts = append(r.Options[:], opts...) + var env SettingNELGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/nel", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Enable Network Error Logging reporting on your zone. (Beta) +type ZonesNEL struct { + // Zone setting identifier. + ID ZonesNELID `json:"id,required"` + // Current value of the zone setting. + Value ZonesNELValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesNELEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesNELJSON `json:"-"` +} + +// zonesNELJSON contains the JSON metadata for the struct [ZonesNEL] +type zonesNELJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesNEL) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesNELJSON) RawJSON() string { + return r.raw +} + +func (r ZonesNEL) implementsZonesSettingEditResponse() {} + +func (r ZonesNEL) implementsZonesSettingGetResponse() {} + +// Zone setting identifier. +type ZonesNELID string + +const ( + ZonesNELIDNEL ZonesNELID = "nel" +) + +// Current value of the zone setting. +type ZonesNELValue struct { + Enabled bool `json:"enabled"` + JSON zonesNELValueJSON `json:"-"` +} + +// zonesNELValueJSON contains the JSON metadata for the struct [ZonesNELValue] +type zonesNELValueJSON struct { + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesNELValue) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesNELValueJSON) RawJSON() string { + return r.raw +} + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesNELEditable bool + +const ( + ZonesNELEditableTrue ZonesNELEditable = true + ZonesNELEditableFalse ZonesNELEditable = false +) + +// Enable Network Error Logging reporting on your zone. (Beta) +type ZonesNELParam struct { + // Zone setting identifier. + ID param.Field[ZonesNELID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesNELValueParam] `json:"value,required"` +} + +func (r ZonesNELParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesNELParam) implementsZonesSettingEditParamsItem() {} + +// Current value of the zone setting. +type ZonesNELValueParam struct { + Enabled param.Field[bool] `json:"enabled"` +} + +func (r ZonesNELValueParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingNELEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Enable Network Error Logging reporting on your zone. (Beta) + Value param.Field[ZonesNELParam] `json:"value,required"` +} + +func (r SettingNELEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingNELEditResponseEnvelope struct { + Errors []SettingNELEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingNELEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Enable Network Error Logging reporting on your zone. (Beta) + Result ZonesNEL `json:"result"` + JSON settingNELEditResponseEnvelopeJSON `json:"-"` +} + +// settingNELEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingNELEditResponseEnvelope] +type settingNELEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingNELEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingNELEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingNELEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingNELEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingNELEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingNELEditResponseEnvelopeErrors] +type settingNELEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingNELEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingNELEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingNELEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingNELEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingNELEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingNELEditResponseEnvelopeMessages] +type settingNELEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingNELEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingNELEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingNELGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingNELGetResponseEnvelope struct { + Errors []SettingNELGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingNELGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Enable Network Error Logging reporting on your zone. (Beta) + Result ZonesNEL `json:"result"` + JSON settingNELGetResponseEnvelopeJSON `json:"-"` +} + +// settingNELGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingNELGetResponseEnvelope] +type settingNELGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingNELGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingNELGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingNELGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingNELGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingNELGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingNELGetResponseEnvelopeErrors] +type settingNELGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingNELGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingNELGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingNELGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingNELGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingNELGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingNELGetResponseEnvelopeMessages] +type settingNELGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingNELGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingNELGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingnel_test.go b/zones/settingnel_test.go new file mode 100644 index 00000000000..1fbc74c530a --- /dev/null +++ b/zones/settingnel_test.go @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingNELEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Zones.Settings.NEL.Edit(context.TODO(), zones.SettingNELEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.ZonesNELParam{ + ID: cloudflare.F(zones.ZonesNELIDNEL), + Value: cloudflare.F(zones.ZonesNELValueParam{ + Enabled: cloudflare.F(false), + }), + }), + }) + 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 TestSettingNELGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.NEL.Get(context.TODO(), zones.SettingNELGetParams{ + ZoneID: cloudflare.F("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/zones/settingopportunisticencryption.go b/zones/settingopportunisticencryption.go new file mode 100644 index 00000000000..804d18ec0b3 --- /dev/null +++ b/zones/settingopportunisticencryption.go @@ -0,0 +1,314 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingOpportunisticEncryptionService 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 +// [NewSettingOpportunisticEncryptionService] method instead. +type SettingOpportunisticEncryptionService struct { + Options []option.RequestOption +} + +// NewSettingOpportunisticEncryptionService 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 NewSettingOpportunisticEncryptionService(opts ...option.RequestOption) (r *SettingOpportunisticEncryptionService) { + r = &SettingOpportunisticEncryptionService{} + r.Options = opts + return +} + +// Changes Opportunistic Encryption setting. +func (r *SettingOpportunisticEncryptionService) Edit(ctx context.Context, params SettingOpportunisticEncryptionEditParams, opts ...option.RequestOption) (res *ZonesOpportunisticEncryption, err error) { + opts = append(r.Options[:], opts...) + var env SettingOpportunisticEncryptionEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/opportunistic_encryption", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets Opportunistic Encryption setting. +func (r *SettingOpportunisticEncryptionService) Get(ctx context.Context, query SettingOpportunisticEncryptionGetParams, opts ...option.RequestOption) (res *ZonesOpportunisticEncryption, err error) { + opts = append(r.Options[:], opts...) + var env SettingOpportunisticEncryptionGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/opportunistic_encryption", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Enables the Opportunistic Encryption feature for a zone. +type ZonesOpportunisticEncryption struct { + // ID of the zone setting. + ID ZonesOpportunisticEncryptionID `json:"id,required"` + // Current value of the zone setting. + Value ZonesOpportunisticEncryptionValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesOpportunisticEncryptionEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesOpportunisticEncryptionJSON `json:"-"` +} + +// zonesOpportunisticEncryptionJSON contains the JSON metadata for the struct +// [ZonesOpportunisticEncryption] +type zonesOpportunisticEncryptionJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesOpportunisticEncryption) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesOpportunisticEncryptionJSON) RawJSON() string { + return r.raw +} + +func (r ZonesOpportunisticEncryption) implementsZonesSettingEditResponse() {} + +func (r ZonesOpportunisticEncryption) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesOpportunisticEncryptionID string + +const ( + ZonesOpportunisticEncryptionIDOpportunisticEncryption ZonesOpportunisticEncryptionID = "opportunistic_encryption" +) + +// Current value of the zone setting. +type ZonesOpportunisticEncryptionValue string + +const ( + ZonesOpportunisticEncryptionValueOn ZonesOpportunisticEncryptionValue = "on" + ZonesOpportunisticEncryptionValueOff ZonesOpportunisticEncryptionValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesOpportunisticEncryptionEditable bool + +const ( + ZonesOpportunisticEncryptionEditableTrue ZonesOpportunisticEncryptionEditable = true + ZonesOpportunisticEncryptionEditableFalse ZonesOpportunisticEncryptionEditable = false +) + +// Enables the Opportunistic Encryption feature for a zone. +type ZonesOpportunisticEncryptionParam struct { + // ID of the zone setting. + ID param.Field[ZonesOpportunisticEncryptionID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesOpportunisticEncryptionValue] `json:"value,required"` +} + +func (r ZonesOpportunisticEncryptionParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesOpportunisticEncryptionParam) implementsZonesSettingEditParamsItem() {} + +type SettingOpportunisticEncryptionEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. Notes: Default value depends on the zone's plan + // level. + Value param.Field[SettingOpportunisticEncryptionEditParamsValue] `json:"value,required"` +} + +func (r SettingOpportunisticEncryptionEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. Notes: Default value depends on the zone's plan +// level. +type SettingOpportunisticEncryptionEditParamsValue string + +const ( + SettingOpportunisticEncryptionEditParamsValueOn SettingOpportunisticEncryptionEditParamsValue = "on" + SettingOpportunisticEncryptionEditParamsValueOff SettingOpportunisticEncryptionEditParamsValue = "off" +) + +type SettingOpportunisticEncryptionEditResponseEnvelope struct { + Errors []SettingOpportunisticEncryptionEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingOpportunisticEncryptionEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Enables the Opportunistic Encryption feature for a zone. + Result ZonesOpportunisticEncryption `json:"result"` + JSON settingOpportunisticEncryptionEditResponseEnvelopeJSON `json:"-"` +} + +// settingOpportunisticEncryptionEditResponseEnvelopeJSON contains the JSON +// metadata for the struct [SettingOpportunisticEncryptionEditResponseEnvelope] +type settingOpportunisticEncryptionEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOpportunisticEncryptionEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOpportunisticEncryptionEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingOpportunisticEncryptionEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOpportunisticEncryptionEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingOpportunisticEncryptionEditResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct +// [SettingOpportunisticEncryptionEditResponseEnvelopeErrors] +type settingOpportunisticEncryptionEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOpportunisticEncryptionEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOpportunisticEncryptionEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingOpportunisticEncryptionEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOpportunisticEncryptionEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingOpportunisticEncryptionEditResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct +// [SettingOpportunisticEncryptionEditResponseEnvelopeMessages] +type settingOpportunisticEncryptionEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOpportunisticEncryptionEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOpportunisticEncryptionEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingOpportunisticEncryptionGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingOpportunisticEncryptionGetResponseEnvelope struct { + Errors []SettingOpportunisticEncryptionGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingOpportunisticEncryptionGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Enables the Opportunistic Encryption feature for a zone. + Result ZonesOpportunisticEncryption `json:"result"` + JSON settingOpportunisticEncryptionGetResponseEnvelopeJSON `json:"-"` +} + +// settingOpportunisticEncryptionGetResponseEnvelopeJSON contains the JSON metadata +// for the struct [SettingOpportunisticEncryptionGetResponseEnvelope] +type settingOpportunisticEncryptionGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOpportunisticEncryptionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOpportunisticEncryptionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingOpportunisticEncryptionGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOpportunisticEncryptionGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingOpportunisticEncryptionGetResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct +// [SettingOpportunisticEncryptionGetResponseEnvelopeErrors] +type settingOpportunisticEncryptionGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOpportunisticEncryptionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOpportunisticEncryptionGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingOpportunisticEncryptionGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOpportunisticEncryptionGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingOpportunisticEncryptionGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct +// [SettingOpportunisticEncryptionGetResponseEnvelopeMessages] +type settingOpportunisticEncryptionGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOpportunisticEncryptionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOpportunisticEncryptionGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingopportunisticencryption_test.go b/zones/settingopportunisticencryption_test.go new file mode 100644 index 00000000000..9f8d0869b2c --- /dev/null +++ b/zones/settingopportunisticencryption_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingOpportunisticEncryptionEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.OpportunisticEncryption.Edit(context.TODO(), zones.SettingOpportunisticEncryptionEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingOpportunisticEncryptionEditParamsValueOn), + }) + 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 TestSettingOpportunisticEncryptionGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.OpportunisticEncryption.Get(context.TODO(), zones.SettingOpportunisticEncryptionGetParams{ + ZoneID: cloudflare.F("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/zones/settingopportunisticonion.go b/zones/settingopportunisticonion.go new file mode 100644 index 00000000000..25dfe9c08cf --- /dev/null +++ b/zones/settingopportunisticonion.go @@ -0,0 +1,316 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingOpportunisticOnionService 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 +// [NewSettingOpportunisticOnionService] method instead. +type SettingOpportunisticOnionService struct { + Options []option.RequestOption +} + +// NewSettingOpportunisticOnionService 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 NewSettingOpportunisticOnionService(opts ...option.RequestOption) (r *SettingOpportunisticOnionService) { + r = &SettingOpportunisticOnionService{} + r.Options = opts + return +} + +// Add an Alt-Svc header to all legitimate requests from Tor, allowing the +// connection to use our onion services instead of exit nodes. +func (r *SettingOpportunisticOnionService) Edit(ctx context.Context, params SettingOpportunisticOnionEditParams, opts ...option.RequestOption) (res *ZonesOpportunisticOnion, err error) { + opts = append(r.Options[:], opts...) + var env SettingOpportunisticOnionEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/opportunistic_onion", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Add an Alt-Svc header to all legitimate requests from Tor, allowing the +// connection to use our onion services instead of exit nodes. +func (r *SettingOpportunisticOnionService) Get(ctx context.Context, query SettingOpportunisticOnionGetParams, opts ...option.RequestOption) (res *ZonesOpportunisticOnion, err error) { + opts = append(r.Options[:], opts...) + var env SettingOpportunisticOnionGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/opportunistic_onion", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Add an Alt-Svc header to all legitimate requests from Tor, allowing the +// connection to use our onion services instead of exit nodes. +type ZonesOpportunisticOnion struct { + // ID of the zone setting. + ID ZonesOpportunisticOnionID `json:"id,required"` + // Current value of the zone setting. + Value ZonesOpportunisticOnionValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesOpportunisticOnionEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesOpportunisticOnionJSON `json:"-"` +} + +// zonesOpportunisticOnionJSON contains the JSON metadata for the struct +// [ZonesOpportunisticOnion] +type zonesOpportunisticOnionJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesOpportunisticOnion) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesOpportunisticOnionJSON) RawJSON() string { + return r.raw +} + +func (r ZonesOpportunisticOnion) implementsZonesSettingEditResponse() {} + +func (r ZonesOpportunisticOnion) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesOpportunisticOnionID string + +const ( + ZonesOpportunisticOnionIDOpportunisticOnion ZonesOpportunisticOnionID = "opportunistic_onion" +) + +// Current value of the zone setting. +type ZonesOpportunisticOnionValue string + +const ( + ZonesOpportunisticOnionValueOn ZonesOpportunisticOnionValue = "on" + ZonesOpportunisticOnionValueOff ZonesOpportunisticOnionValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesOpportunisticOnionEditable bool + +const ( + ZonesOpportunisticOnionEditableTrue ZonesOpportunisticOnionEditable = true + ZonesOpportunisticOnionEditableFalse ZonesOpportunisticOnionEditable = false +) + +// Add an Alt-Svc header to all legitimate requests from Tor, allowing the +// connection to use our onion services instead of exit nodes. +type ZonesOpportunisticOnionParam struct { + // ID of the zone setting. + ID param.Field[ZonesOpportunisticOnionID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesOpportunisticOnionValue] `json:"value,required"` +} + +func (r ZonesOpportunisticOnionParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesOpportunisticOnionParam) implementsZonesSettingEditParamsItem() {} + +type SettingOpportunisticOnionEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. Notes: Default value depends on the zone's plan + // level. + Value param.Field[SettingOpportunisticOnionEditParamsValue] `json:"value,required"` +} + +func (r SettingOpportunisticOnionEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. Notes: Default value depends on the zone's plan +// level. +type SettingOpportunisticOnionEditParamsValue string + +const ( + SettingOpportunisticOnionEditParamsValueOn SettingOpportunisticOnionEditParamsValue = "on" + SettingOpportunisticOnionEditParamsValueOff SettingOpportunisticOnionEditParamsValue = "off" +) + +type SettingOpportunisticOnionEditResponseEnvelope struct { + Errors []SettingOpportunisticOnionEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingOpportunisticOnionEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Add an Alt-Svc header to all legitimate requests from Tor, allowing the + // connection to use our onion services instead of exit nodes. + Result ZonesOpportunisticOnion `json:"result"` + JSON settingOpportunisticOnionEditResponseEnvelopeJSON `json:"-"` +} + +// settingOpportunisticOnionEditResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingOpportunisticOnionEditResponseEnvelope] +type settingOpportunisticOnionEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOpportunisticOnionEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOpportunisticOnionEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingOpportunisticOnionEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOpportunisticOnionEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingOpportunisticOnionEditResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [SettingOpportunisticOnionEditResponseEnvelopeErrors] +type settingOpportunisticOnionEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOpportunisticOnionEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOpportunisticOnionEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingOpportunisticOnionEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOpportunisticOnionEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingOpportunisticOnionEditResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingOpportunisticOnionEditResponseEnvelopeMessages] +type settingOpportunisticOnionEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOpportunisticOnionEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOpportunisticOnionEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingOpportunisticOnionGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingOpportunisticOnionGetResponseEnvelope struct { + Errors []SettingOpportunisticOnionGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingOpportunisticOnionGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Add an Alt-Svc header to all legitimate requests from Tor, allowing the + // connection to use our onion services instead of exit nodes. + Result ZonesOpportunisticOnion `json:"result"` + JSON settingOpportunisticOnionGetResponseEnvelopeJSON `json:"-"` +} + +// settingOpportunisticOnionGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingOpportunisticOnionGetResponseEnvelope] +type settingOpportunisticOnionGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOpportunisticOnionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOpportunisticOnionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingOpportunisticOnionGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOpportunisticOnionGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingOpportunisticOnionGetResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [SettingOpportunisticOnionGetResponseEnvelopeErrors] +type settingOpportunisticOnionGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOpportunisticOnionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOpportunisticOnionGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingOpportunisticOnionGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOpportunisticOnionGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingOpportunisticOnionGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingOpportunisticOnionGetResponseEnvelopeMessages] +type settingOpportunisticOnionGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOpportunisticOnionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOpportunisticOnionGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingopportunisticonion_test.go b/zones/settingopportunisticonion_test.go new file mode 100644 index 00000000000..7889536eeb3 --- /dev/null +++ b/zones/settingopportunisticonion_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingOpportunisticOnionEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.OpportunisticOnion.Edit(context.TODO(), zones.SettingOpportunisticOnionEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingOpportunisticOnionEditParamsValueOn), + }) + 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 TestSettingOpportunisticOnionGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.OpportunisticOnion.Get(context.TODO(), zones.SettingOpportunisticOnionGetParams{ + ZoneID: cloudflare.F("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/zones/settingorangetoorange.go b/zones/settingorangetoorange.go new file mode 100644 index 00000000000..9ecc5be14b5 --- /dev/null +++ b/zones/settingorangetoorange.go @@ -0,0 +1,307 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingOrangeToOrangeService 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 [NewSettingOrangeToOrangeService] +// method instead. +type SettingOrangeToOrangeService struct { + Options []option.RequestOption +} + +// NewSettingOrangeToOrangeService 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 NewSettingOrangeToOrangeService(opts ...option.RequestOption) (r *SettingOrangeToOrangeService) { + r = &SettingOrangeToOrangeService{} + r.Options = opts + return +} + +// Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also +// on Cloudflare. +func (r *SettingOrangeToOrangeService) Edit(ctx context.Context, params SettingOrangeToOrangeEditParams, opts ...option.RequestOption) (res *ZonesOrangeToOrange, err error) { + opts = append(r.Options[:], opts...) + var env SettingOrangeToOrangeEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/orange_to_orange", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also +// on Cloudflare. +func (r *SettingOrangeToOrangeService) Get(ctx context.Context, query SettingOrangeToOrangeGetParams, opts ...option.RequestOption) (res *ZonesOrangeToOrange, err error) { + opts = append(r.Options[:], opts...) + var env SettingOrangeToOrangeGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/orange_to_orange", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also +// on Cloudflare. +type ZonesOrangeToOrange struct { + // ID of the zone setting. + ID ZonesOrangeToOrangeID `json:"id,required"` + // Current value of the zone setting. + Value ZonesOrangeToOrangeValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesOrangeToOrangeEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesOrangeToOrangeJSON `json:"-"` +} + +// zonesOrangeToOrangeJSON contains the JSON metadata for the struct +// [ZonesOrangeToOrange] +type zonesOrangeToOrangeJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesOrangeToOrange) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesOrangeToOrangeJSON) RawJSON() string { + return r.raw +} + +func (r ZonesOrangeToOrange) implementsZonesSettingEditResponse() {} + +func (r ZonesOrangeToOrange) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesOrangeToOrangeID string + +const ( + ZonesOrangeToOrangeIDOrangeToOrange ZonesOrangeToOrangeID = "orange_to_orange" +) + +// Current value of the zone setting. +type ZonesOrangeToOrangeValue string + +const ( + ZonesOrangeToOrangeValueOn ZonesOrangeToOrangeValue = "on" + ZonesOrangeToOrangeValueOff ZonesOrangeToOrangeValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesOrangeToOrangeEditable bool + +const ( + ZonesOrangeToOrangeEditableTrue ZonesOrangeToOrangeEditable = true + ZonesOrangeToOrangeEditableFalse ZonesOrangeToOrangeEditable = false +) + +// Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also +// on Cloudflare. +type ZonesOrangeToOrangeParam struct { + // ID of the zone setting. + ID param.Field[ZonesOrangeToOrangeID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesOrangeToOrangeValue] `json:"value,required"` +} + +func (r ZonesOrangeToOrangeParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesOrangeToOrangeParam) implementsZonesSettingEditParamsItem() {} + +type SettingOrangeToOrangeEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also + // on Cloudflare. + Value param.Field[ZonesOrangeToOrangeParam] `json:"value,required"` +} + +func (r SettingOrangeToOrangeEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingOrangeToOrangeEditResponseEnvelope struct { + Errors []SettingOrangeToOrangeEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingOrangeToOrangeEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also + // on Cloudflare. + Result ZonesOrangeToOrange `json:"result"` + JSON settingOrangeToOrangeEditResponseEnvelopeJSON `json:"-"` +} + +// settingOrangeToOrangeEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingOrangeToOrangeEditResponseEnvelope] +type settingOrangeToOrangeEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOrangeToOrangeEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOrangeToOrangeEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingOrangeToOrangeEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOrangeToOrangeEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingOrangeToOrangeEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingOrangeToOrangeEditResponseEnvelopeErrors] +type settingOrangeToOrangeEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOrangeToOrangeEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOrangeToOrangeEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingOrangeToOrangeEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOrangeToOrangeEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingOrangeToOrangeEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingOrangeToOrangeEditResponseEnvelopeMessages] +type settingOrangeToOrangeEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOrangeToOrangeEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOrangeToOrangeEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingOrangeToOrangeGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingOrangeToOrangeGetResponseEnvelope struct { + Errors []SettingOrangeToOrangeGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingOrangeToOrangeGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also + // on Cloudflare. + Result ZonesOrangeToOrange `json:"result"` + JSON settingOrangeToOrangeGetResponseEnvelopeJSON `json:"-"` +} + +// settingOrangeToOrangeGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingOrangeToOrangeGetResponseEnvelope] +type settingOrangeToOrangeGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOrangeToOrangeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOrangeToOrangeGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingOrangeToOrangeGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOrangeToOrangeGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingOrangeToOrangeGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingOrangeToOrangeGetResponseEnvelopeErrors] +type settingOrangeToOrangeGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOrangeToOrangeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOrangeToOrangeGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingOrangeToOrangeGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOrangeToOrangeGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingOrangeToOrangeGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingOrangeToOrangeGetResponseEnvelopeMessages] +type settingOrangeToOrangeGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOrangeToOrangeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOrangeToOrangeGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingorangetoorange_test.go b/zones/settingorangetoorange_test.go new file mode 100644 index 00000000000..fed9428964b --- /dev/null +++ b/zones/settingorangetoorange_test.go @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingOrangeToOrangeEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Zones.Settings.OrangeToOrange.Edit(context.TODO(), zones.SettingOrangeToOrangeEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.ZonesOrangeToOrangeParam{ + ID: cloudflare.F(zones.ZonesOrangeToOrangeIDOrangeToOrange), + Value: cloudflare.F(zones.ZonesOrangeToOrangeValueOn), + }), + }) + 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 TestSettingOrangeToOrangeGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.OrangeToOrange.Get(context.TODO(), zones.SettingOrangeToOrangeGetParams{ + ZoneID: cloudflare.F("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/zones/settingoriginerrorpagepassthru.go b/zones/settingoriginerrorpagepassthru.go new file mode 100644 index 00000000000..21117d9b52a --- /dev/null +++ b/zones/settingoriginerrorpagepassthru.go @@ -0,0 +1,324 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingOriginErrorPagePassThruService 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 +// [NewSettingOriginErrorPagePassThruService] method instead. +type SettingOriginErrorPagePassThruService struct { + Options []option.RequestOption +} + +// NewSettingOriginErrorPagePassThruService 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 NewSettingOriginErrorPagePassThruService(opts ...option.RequestOption) (r *SettingOriginErrorPagePassThruService) { + r = &SettingOriginErrorPagePassThruService{} + r.Options = opts + return +} + +// Cloudflare will proxy customer error pages on any 502,504 errors on origin +// server instead of showing a default Cloudflare error page. This does not apply +// to 522 errors and is limited to Enterprise Zones. +func (r *SettingOriginErrorPagePassThruService) Edit(ctx context.Context, params SettingOriginErrorPagePassThruEditParams, opts ...option.RequestOption) (res *ZonesOriginErrorPagePassThru, err error) { + opts = append(r.Options[:], opts...) + var env SettingOriginErrorPagePassThruEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/origin_error_page_pass_thru", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Cloudflare will proxy customer error pages on any 502,504 errors on origin +// server instead of showing a default Cloudflare error page. This does not apply +// to 522 errors and is limited to Enterprise Zones. +func (r *SettingOriginErrorPagePassThruService) Get(ctx context.Context, query SettingOriginErrorPagePassThruGetParams, opts ...option.RequestOption) (res *ZonesOriginErrorPagePassThru, err error) { + opts = append(r.Options[:], opts...) + var env SettingOriginErrorPagePassThruGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/origin_error_page_pass_thru", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Cloudflare will proxy customer error pages on any 502,504 errors on origin +// server instead of showing a default Cloudflare error page. This does not apply +// to 522 errors and is limited to Enterprise Zones. +type ZonesOriginErrorPagePassThru struct { + // ID of the zone setting. + ID ZonesOriginErrorPagePassThruID `json:"id,required"` + // Current value of the zone setting. + Value ZonesOriginErrorPagePassThruValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesOriginErrorPagePassThruEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesOriginErrorPagePassThruJSON `json:"-"` +} + +// zonesOriginErrorPagePassThruJSON contains the JSON metadata for the struct +// [ZonesOriginErrorPagePassThru] +type zonesOriginErrorPagePassThruJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesOriginErrorPagePassThru) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesOriginErrorPagePassThruJSON) RawJSON() string { + return r.raw +} + +func (r ZonesOriginErrorPagePassThru) implementsZonesSettingEditResponse() {} + +func (r ZonesOriginErrorPagePassThru) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesOriginErrorPagePassThruID string + +const ( + ZonesOriginErrorPagePassThruIDOriginErrorPagePassThru ZonesOriginErrorPagePassThruID = "origin_error_page_pass_thru" +) + +// Current value of the zone setting. +type ZonesOriginErrorPagePassThruValue string + +const ( + ZonesOriginErrorPagePassThruValueOn ZonesOriginErrorPagePassThruValue = "on" + ZonesOriginErrorPagePassThruValueOff ZonesOriginErrorPagePassThruValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesOriginErrorPagePassThruEditable bool + +const ( + ZonesOriginErrorPagePassThruEditableTrue ZonesOriginErrorPagePassThruEditable = true + ZonesOriginErrorPagePassThruEditableFalse ZonesOriginErrorPagePassThruEditable = false +) + +// Cloudflare will proxy customer error pages on any 502,504 errors on origin +// server instead of showing a default Cloudflare error page. This does not apply +// to 522 errors and is limited to Enterprise Zones. +type ZonesOriginErrorPagePassThruParam struct { + // ID of the zone setting. + ID param.Field[ZonesOriginErrorPagePassThruID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesOriginErrorPagePassThruValue] `json:"value,required"` +} + +func (r ZonesOriginErrorPagePassThruParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesOriginErrorPagePassThruParam) implementsZonesSettingEditParamsItem() {} + +type SettingOriginErrorPagePassThruEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingOriginErrorPagePassThruEditParamsValue] `json:"value,required"` +} + +func (r SettingOriginErrorPagePassThruEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingOriginErrorPagePassThruEditParamsValue string + +const ( + SettingOriginErrorPagePassThruEditParamsValueOn SettingOriginErrorPagePassThruEditParamsValue = "on" + SettingOriginErrorPagePassThruEditParamsValueOff SettingOriginErrorPagePassThruEditParamsValue = "off" +) + +type SettingOriginErrorPagePassThruEditResponseEnvelope struct { + Errors []SettingOriginErrorPagePassThruEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingOriginErrorPagePassThruEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Cloudflare will proxy customer error pages on any 502,504 errors on origin + // server instead of showing a default Cloudflare error page. This does not apply + // to 522 errors and is limited to Enterprise Zones. + Result ZonesOriginErrorPagePassThru `json:"result"` + JSON settingOriginErrorPagePassThruEditResponseEnvelopeJSON `json:"-"` +} + +// settingOriginErrorPagePassThruEditResponseEnvelopeJSON contains the JSON +// metadata for the struct [SettingOriginErrorPagePassThruEditResponseEnvelope] +type settingOriginErrorPagePassThruEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOriginErrorPagePassThruEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOriginErrorPagePassThruEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingOriginErrorPagePassThruEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOriginErrorPagePassThruEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingOriginErrorPagePassThruEditResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct +// [SettingOriginErrorPagePassThruEditResponseEnvelopeErrors] +type settingOriginErrorPagePassThruEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOriginErrorPagePassThruEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOriginErrorPagePassThruEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingOriginErrorPagePassThruEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOriginErrorPagePassThruEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingOriginErrorPagePassThruEditResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct +// [SettingOriginErrorPagePassThruEditResponseEnvelopeMessages] +type settingOriginErrorPagePassThruEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOriginErrorPagePassThruEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOriginErrorPagePassThruEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingOriginErrorPagePassThruGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingOriginErrorPagePassThruGetResponseEnvelope struct { + Errors []SettingOriginErrorPagePassThruGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingOriginErrorPagePassThruGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Cloudflare will proxy customer error pages on any 502,504 errors on origin + // server instead of showing a default Cloudflare error page. This does not apply + // to 522 errors and is limited to Enterprise Zones. + Result ZonesOriginErrorPagePassThru `json:"result"` + JSON settingOriginErrorPagePassThruGetResponseEnvelopeJSON `json:"-"` +} + +// settingOriginErrorPagePassThruGetResponseEnvelopeJSON contains the JSON metadata +// for the struct [SettingOriginErrorPagePassThruGetResponseEnvelope] +type settingOriginErrorPagePassThruGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOriginErrorPagePassThruGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOriginErrorPagePassThruGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingOriginErrorPagePassThruGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOriginErrorPagePassThruGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingOriginErrorPagePassThruGetResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct +// [SettingOriginErrorPagePassThruGetResponseEnvelopeErrors] +type settingOriginErrorPagePassThruGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOriginErrorPagePassThruGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOriginErrorPagePassThruGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingOriginErrorPagePassThruGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOriginErrorPagePassThruGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingOriginErrorPagePassThruGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct +// [SettingOriginErrorPagePassThruGetResponseEnvelopeMessages] +type settingOriginErrorPagePassThruGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOriginErrorPagePassThruGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOriginErrorPagePassThruGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingoriginerrorpagepassthru_test.go b/zones/settingoriginerrorpagepassthru_test.go new file mode 100644 index 00000000000..3a5e0630c01 --- /dev/null +++ b/zones/settingoriginerrorpagepassthru_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingOriginErrorPagePassThruEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.OriginErrorPagePassThru.Edit(context.TODO(), zones.SettingOriginErrorPagePassThruEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingOriginErrorPagePassThruEditParamsValueOn), + }) + 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 TestSettingOriginErrorPagePassThruGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.OriginErrorPagePassThru.Get(context.TODO(), zones.SettingOriginErrorPagePassThruGetParams{ + ZoneID: cloudflare.F("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/zones/settingoriginmaxhttpversion.go b/zones/settingoriginmaxhttpversion.go new file mode 100644 index 00000000000..bf59b4f1f75 --- /dev/null +++ b/zones/settingoriginmaxhttpversion.go @@ -0,0 +1,366 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingOriginMaxHTTPVersionService 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 +// [NewSettingOriginMaxHTTPVersionService] method instead. +type SettingOriginMaxHTTPVersionService struct { + Options []option.RequestOption +} + +// NewSettingOriginMaxHTTPVersionService 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 NewSettingOriginMaxHTTPVersionService(opts ...option.RequestOption) (r *SettingOriginMaxHTTPVersionService) { + r = &SettingOriginMaxHTTPVersionService{} + r.Options = opts + return +} + +// Origin Max HTTP Setting Version sets the highest HTTP version Cloudflare will +// attempt to use with your origin. This setting allows Cloudflare to make HTTP/2 +// requests to your origin. (Refer to +// [Enable HTTP/2 to Origin](https://developers.cloudflare.com/cache/how-to/enable-http2-to-origin/), +// for more information.). The default value is "2" for all plan types except ENT +// where it is "1" +func (r *SettingOriginMaxHTTPVersionService) Edit(ctx context.Context, params SettingOriginMaxHTTPVersionEditParams, opts ...option.RequestOption) (res *SettingOriginMaxHTTPVersionEditResponse, err error) { + opts = append(r.Options[:], opts...) + var env SettingOriginMaxHTTPVersionEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/origin_max_http_version", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Origin Max HTTP Setting Version sets the highest HTTP version Cloudflare will +// attempt to use with your origin. This setting allows Cloudflare to make HTTP/2 +// requests to your origin. (Refer to +// [Enable HTTP/2 to Origin](https://developers.cloudflare.com/cache/how-to/enable-http2-to-origin/), +// for more information.). The default value is "2" for all plan types except ENT +// where it is "1" +func (r *SettingOriginMaxHTTPVersionService) Get(ctx context.Context, query SettingOriginMaxHTTPVersionGetParams, opts ...option.RequestOption) (res *SettingOriginMaxHTTPVersionGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env SettingOriginMaxHTTPVersionGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/origin_max_http_version", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Origin Max HTTP Setting Version sets the highest HTTP version Cloudflare will +// attempt to use with your origin. This setting allows Cloudflare to make HTTP/2 +// requests to your origin. (Refer to +// [Enable HTTP/2 to Origin](https://developers.cloudflare.com/cache/how-to/enable-http2-to-origin/), +// for more information.). The default value is "2" for all plan types except ENT +// where it is "1" +type SettingOriginMaxHTTPVersionEditResponse struct { + // Value of the zone setting. + ID SettingOriginMaxHTTPVersionEditResponseID `json:"id,required"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` + // Value of the Origin Max HTTP Version Setting. + Value SettingOriginMaxHTTPVersionEditResponseValue `json:"value,required"` + JSON settingOriginMaxHTTPVersionEditResponseJSON `json:"-"` +} + +// settingOriginMaxHTTPVersionEditResponseJSON contains the JSON metadata for the +// struct [SettingOriginMaxHTTPVersionEditResponse] +type settingOriginMaxHTTPVersionEditResponseJSON struct { + ID apijson.Field + ModifiedOn apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOriginMaxHTTPVersionEditResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOriginMaxHTTPVersionEditResponseJSON) RawJSON() string { + return r.raw +} + +// Value of the zone setting. +type SettingOriginMaxHTTPVersionEditResponseID string + +const ( + SettingOriginMaxHTTPVersionEditResponseIDOriginMaxHTTPVersion SettingOriginMaxHTTPVersionEditResponseID = "origin_max_http_version" +) + +// Value of the Origin Max HTTP Version Setting. +type SettingOriginMaxHTTPVersionEditResponseValue string + +const ( + SettingOriginMaxHTTPVersionEditResponseValue2 SettingOriginMaxHTTPVersionEditResponseValue = "2" + SettingOriginMaxHTTPVersionEditResponseValue1 SettingOriginMaxHTTPVersionEditResponseValue = "1" +) + +// Origin Max HTTP Setting Version sets the highest HTTP version Cloudflare will +// attempt to use with your origin. This setting allows Cloudflare to make HTTP/2 +// requests to your origin. (Refer to +// [Enable HTTP/2 to Origin](https://developers.cloudflare.com/cache/how-to/enable-http2-to-origin/), +// for more information.). The default value is "2" for all plan types except ENT +// where it is "1" +type SettingOriginMaxHTTPVersionGetResponse struct { + // Value of the zone setting. + ID SettingOriginMaxHTTPVersionGetResponseID `json:"id,required"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` + // Value of the Origin Max HTTP Version Setting. + Value SettingOriginMaxHTTPVersionGetResponseValue `json:"value,required"` + JSON settingOriginMaxHTTPVersionGetResponseJSON `json:"-"` +} + +// settingOriginMaxHTTPVersionGetResponseJSON contains the JSON metadata for the +// struct [SettingOriginMaxHTTPVersionGetResponse] +type settingOriginMaxHTTPVersionGetResponseJSON struct { + ID apijson.Field + ModifiedOn apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOriginMaxHTTPVersionGetResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOriginMaxHTTPVersionGetResponseJSON) RawJSON() string { + return r.raw +} + +// Value of the zone setting. +type SettingOriginMaxHTTPVersionGetResponseID string + +const ( + SettingOriginMaxHTTPVersionGetResponseIDOriginMaxHTTPVersion SettingOriginMaxHTTPVersionGetResponseID = "origin_max_http_version" +) + +// Value of the Origin Max HTTP Version Setting. +type SettingOriginMaxHTTPVersionGetResponseValue string + +const ( + SettingOriginMaxHTTPVersionGetResponseValue2 SettingOriginMaxHTTPVersionGetResponseValue = "2" + SettingOriginMaxHTTPVersionGetResponseValue1 SettingOriginMaxHTTPVersionGetResponseValue = "1" +) + +type SettingOriginMaxHTTPVersionEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the Origin Max HTTP Version Setting. + Value param.Field[SettingOriginMaxHTTPVersionEditParamsValue] `json:"value,required"` +} + +func (r SettingOriginMaxHTTPVersionEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the Origin Max HTTP Version Setting. +type SettingOriginMaxHTTPVersionEditParamsValue string + +const ( + SettingOriginMaxHTTPVersionEditParamsValue2 SettingOriginMaxHTTPVersionEditParamsValue = "2" + SettingOriginMaxHTTPVersionEditParamsValue1 SettingOriginMaxHTTPVersionEditParamsValue = "1" +) + +type SettingOriginMaxHTTPVersionEditResponseEnvelope struct { + Errors []SettingOriginMaxHTTPVersionEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingOriginMaxHTTPVersionEditResponseEnvelopeMessages `json:"messages,required"` + // Origin Max HTTP Setting Version sets the highest HTTP version Cloudflare will + // attempt to use with your origin. This setting allows Cloudflare to make HTTP/2 + // requests to your origin. (Refer to + // [Enable HTTP/2 to Origin](https://developers.cloudflare.com/cache/how-to/enable-http2-to-origin/), + // for more information.). The default value is "2" for all plan types except ENT + // where it is "1" + Result SettingOriginMaxHTTPVersionEditResponse `json:"result,required"` + // Whether the API call was successful + Success SettingOriginMaxHTTPVersionEditResponseEnvelopeSuccess `json:"success,required"` + JSON settingOriginMaxHTTPVersionEditResponseEnvelopeJSON `json:"-"` +} + +// settingOriginMaxHTTPVersionEditResponseEnvelopeJSON contains the JSON metadata +// for the struct [SettingOriginMaxHTTPVersionEditResponseEnvelope] +type settingOriginMaxHTTPVersionEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOriginMaxHTTPVersionEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOriginMaxHTTPVersionEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingOriginMaxHTTPVersionEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOriginMaxHTTPVersionEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingOriginMaxHTTPVersionEditResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [SettingOriginMaxHTTPVersionEditResponseEnvelopeErrors] +type settingOriginMaxHTTPVersionEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOriginMaxHTTPVersionEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOriginMaxHTTPVersionEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingOriginMaxHTTPVersionEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOriginMaxHTTPVersionEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingOriginMaxHTTPVersionEditResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct +// [SettingOriginMaxHTTPVersionEditResponseEnvelopeMessages] +type settingOriginMaxHTTPVersionEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOriginMaxHTTPVersionEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOriginMaxHTTPVersionEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SettingOriginMaxHTTPVersionEditResponseEnvelopeSuccess bool + +const ( + SettingOriginMaxHTTPVersionEditResponseEnvelopeSuccessTrue SettingOriginMaxHTTPVersionEditResponseEnvelopeSuccess = true +) + +type SettingOriginMaxHTTPVersionGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingOriginMaxHTTPVersionGetResponseEnvelope struct { + Errors []SettingOriginMaxHTTPVersionGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingOriginMaxHTTPVersionGetResponseEnvelopeMessages `json:"messages,required"` + // Origin Max HTTP Setting Version sets the highest HTTP version Cloudflare will + // attempt to use with your origin. This setting allows Cloudflare to make HTTP/2 + // requests to your origin. (Refer to + // [Enable HTTP/2 to Origin](https://developers.cloudflare.com/cache/how-to/enable-http2-to-origin/), + // for more information.). The default value is "2" for all plan types except ENT + // where it is "1" + Result SettingOriginMaxHTTPVersionGetResponse `json:"result,required"` + // Whether the API call was successful + Success SettingOriginMaxHTTPVersionGetResponseEnvelopeSuccess `json:"success,required"` + JSON settingOriginMaxHTTPVersionGetResponseEnvelopeJSON `json:"-"` +} + +// settingOriginMaxHTTPVersionGetResponseEnvelopeJSON contains the JSON metadata +// for the struct [SettingOriginMaxHTTPVersionGetResponseEnvelope] +type settingOriginMaxHTTPVersionGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOriginMaxHTTPVersionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOriginMaxHTTPVersionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingOriginMaxHTTPVersionGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOriginMaxHTTPVersionGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingOriginMaxHTTPVersionGetResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [SettingOriginMaxHTTPVersionGetResponseEnvelopeErrors] +type settingOriginMaxHTTPVersionGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOriginMaxHTTPVersionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOriginMaxHTTPVersionGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingOriginMaxHTTPVersionGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingOriginMaxHTTPVersionGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingOriginMaxHTTPVersionGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingOriginMaxHTTPVersionGetResponseEnvelopeMessages] +type settingOriginMaxHTTPVersionGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingOriginMaxHTTPVersionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingOriginMaxHTTPVersionGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SettingOriginMaxHTTPVersionGetResponseEnvelopeSuccess bool + +const ( + SettingOriginMaxHTTPVersionGetResponseEnvelopeSuccessTrue SettingOriginMaxHTTPVersionGetResponseEnvelopeSuccess = true +) diff --git a/zones/settingoriginmaxhttpversion_test.go b/zones/settingoriginmaxhttpversion_test.go new file mode 100644 index 00000000000..fa35cf05d57 --- /dev/null +++ b/zones/settingoriginmaxhttpversion_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingOriginMaxHTTPVersionEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.OriginMaxHTTPVersion.Edit(context.TODO(), zones.SettingOriginMaxHTTPVersionEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingOriginMaxHTTPVersionEditParamsValue2), + }) + 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 TestSettingOriginMaxHTTPVersionGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.OriginMaxHTTPVersion.Get(context.TODO(), zones.SettingOriginMaxHTTPVersionGetParams{ + ZoneID: cloudflare.F("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/zones/settingpolish.go b/zones/settingpolish.go new file mode 100644 index 00000000000..6dd94c18159 --- /dev/null +++ b/zones/settingpolish.go @@ -0,0 +1,329 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingPolishService 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 [NewSettingPolishService] method +// instead. +type SettingPolishService struct { + Options []option.RequestOption +} + +// NewSettingPolishService 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 NewSettingPolishService(opts ...option.RequestOption) (r *SettingPolishService) { + r = &SettingPolishService{} + r.Options = opts + return +} + +// Automatically optimize image loading for website visitors on mobile devices. +// Refer to our [blog post](http://blog.cloudflare.com/polish-solving-mobile-speed) +// for more information. +func (r *SettingPolishService) Edit(ctx context.Context, params SettingPolishEditParams, opts ...option.RequestOption) (res *ZonesPolish, err error) { + opts = append(r.Options[:], opts...) + var env SettingPolishEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/polish", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Automatically optimize image loading for website visitors on mobile devices. +// Refer to our [blog post](http://blog.cloudflare.com/polish-solving-mobile-speed) +// for more information. +func (r *SettingPolishService) Get(ctx context.Context, query SettingPolishGetParams, opts ...option.RequestOption) (res *ZonesPolish, err error) { + opts = append(r.Options[:], opts...) + var env SettingPolishGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/polish", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Removes metadata and compresses your images for faster page load times. Basic +// (Lossless): Reduce the size of PNG, JPEG, and GIF files - no impact on visual +// quality. Basic + JPEG (Lossy): Further reduce the size of JPEG files for faster +// image loading. Larger JPEGs are converted to progressive images, loading a +// lower-resolution image first and ending in a higher-resolution version. Not +// recommended for hi-res photography sites. +type ZonesPolish struct { + // ID of the zone setting. + ID ZonesPolishID `json:"id,required"` + // Current value of the zone setting. + Value ZonesPolishValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesPolishEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesPolishJSON `json:"-"` +} + +// zonesPolishJSON contains the JSON metadata for the struct [ZonesPolish] +type zonesPolishJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesPolish) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesPolishJSON) RawJSON() string { + return r.raw +} + +func (r ZonesPolish) implementsZonesSettingEditResponse() {} + +func (r ZonesPolish) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesPolishID string + +const ( + ZonesPolishIDPolish ZonesPolishID = "polish" +) + +// Current value of the zone setting. +type ZonesPolishValue string + +const ( + ZonesPolishValueOff ZonesPolishValue = "off" + ZonesPolishValueLossless ZonesPolishValue = "lossless" + ZonesPolishValueLossy ZonesPolishValue = "lossy" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesPolishEditable bool + +const ( + ZonesPolishEditableTrue ZonesPolishEditable = true + ZonesPolishEditableFalse ZonesPolishEditable = false +) + +// Removes metadata and compresses your images for faster page load times. Basic +// (Lossless): Reduce the size of PNG, JPEG, and GIF files - no impact on visual +// quality. Basic + JPEG (Lossy): Further reduce the size of JPEG files for faster +// image loading. Larger JPEGs are converted to progressive images, loading a +// lower-resolution image first and ending in a higher-resolution version. Not +// recommended for hi-res photography sites. +type ZonesPolishParam struct { + // ID of the zone setting. + ID param.Field[ZonesPolishID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesPolishValue] `json:"value,required"` +} + +func (r ZonesPolishParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesPolishParam) implementsZonesSettingEditParamsItem() {} + +type SettingPolishEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Removes metadata and compresses your images for faster page load times. Basic + // (Lossless): Reduce the size of PNG, JPEG, and GIF files - no impact on visual + // quality. Basic + JPEG (Lossy): Further reduce the size of JPEG files for faster + // image loading. Larger JPEGs are converted to progressive images, loading a + // lower-resolution image first and ending in a higher-resolution version. Not + // recommended for hi-res photography sites. + Value param.Field[ZonesPolishParam] `json:"value,required"` +} + +func (r SettingPolishEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingPolishEditResponseEnvelope struct { + Errors []SettingPolishEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingPolishEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Removes metadata and compresses your images for faster page load times. Basic + // (Lossless): Reduce the size of PNG, JPEG, and GIF files - no impact on visual + // quality. Basic + JPEG (Lossy): Further reduce the size of JPEG files for faster + // image loading. Larger JPEGs are converted to progressive images, loading a + // lower-resolution image first and ending in a higher-resolution version. Not + // recommended for hi-res photography sites. + Result ZonesPolish `json:"result"` + JSON settingPolishEditResponseEnvelopeJSON `json:"-"` +} + +// settingPolishEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingPolishEditResponseEnvelope] +type settingPolishEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingPolishEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingPolishEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingPolishEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingPolishEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingPolishEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingPolishEditResponseEnvelopeErrors] +type settingPolishEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingPolishEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingPolishEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingPolishEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingPolishEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingPolishEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingPolishEditResponseEnvelopeMessages] +type settingPolishEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingPolishEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingPolishEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingPolishGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingPolishGetResponseEnvelope struct { + Errors []SettingPolishGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingPolishGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Removes metadata and compresses your images for faster page load times. Basic + // (Lossless): Reduce the size of PNG, JPEG, and GIF files - no impact on visual + // quality. Basic + JPEG (Lossy): Further reduce the size of JPEG files for faster + // image loading. Larger JPEGs are converted to progressive images, loading a + // lower-resolution image first and ending in a higher-resolution version. Not + // recommended for hi-res photography sites. + Result ZonesPolish `json:"result"` + JSON settingPolishGetResponseEnvelopeJSON `json:"-"` +} + +// settingPolishGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingPolishGetResponseEnvelope] +type settingPolishGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingPolishGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingPolishGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingPolishGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingPolishGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingPolishGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingPolishGetResponseEnvelopeErrors] +type settingPolishGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingPolishGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingPolishGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingPolishGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingPolishGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingPolishGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingPolishGetResponseEnvelopeMessages] +type settingPolishGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingPolishGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingPolishGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingpolish_test.go b/zones/settingpolish_test.go new file mode 100644 index 00000000000..9a7f030896e --- /dev/null +++ b/zones/settingpolish_test.go @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingPolishEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Zones.Settings.Polish.Edit(context.TODO(), zones.SettingPolishEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.ZonesPolishParam{ + ID: cloudflare.F(zones.ZonesPolishIDPolish), + Value: cloudflare.F(zones.ZonesPolishValueOff), + }), + }) + 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 TestSettingPolishGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.Polish.Get(context.TODO(), zones.SettingPolishGetParams{ + ZoneID: cloudflare.F("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/zones/settingprefetchpreload.go b/zones/settingprefetchpreload.go new file mode 100644 index 00000000000..53773c98f33 --- /dev/null +++ b/zones/settingprefetchpreload.go @@ -0,0 +1,314 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingPrefetchPreloadService 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 [NewSettingPrefetchPreloadService] +// method instead. +type SettingPrefetchPreloadService struct { + Options []option.RequestOption +} + +// NewSettingPrefetchPreloadService 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 NewSettingPrefetchPreloadService(opts ...option.RequestOption) (r *SettingPrefetchPreloadService) { + r = &SettingPrefetchPreloadService{} + r.Options = opts + return +} + +// Cloudflare will prefetch any URLs that are included in the response headers. +// This is limited to Enterprise Zones. +func (r *SettingPrefetchPreloadService) Edit(ctx context.Context, params SettingPrefetchPreloadEditParams, opts ...option.RequestOption) (res *ZonesPrefetchPreload, err error) { + opts = append(r.Options[:], opts...) + var env SettingPrefetchPreloadEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/prefetch_preload", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Cloudflare will prefetch any URLs that are included in the response headers. +// This is limited to Enterprise Zones. +func (r *SettingPrefetchPreloadService) Get(ctx context.Context, query SettingPrefetchPreloadGetParams, opts ...option.RequestOption) (res *ZonesPrefetchPreload, err error) { + opts = append(r.Options[:], opts...) + var env SettingPrefetchPreloadGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/prefetch_preload", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Cloudflare will prefetch any URLs that are included in the response headers. +// This is limited to Enterprise Zones. +type ZonesPrefetchPreload struct { + // ID of the zone setting. + ID ZonesPrefetchPreloadID `json:"id,required"` + // Current value of the zone setting. + Value ZonesPrefetchPreloadValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesPrefetchPreloadEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesPrefetchPreloadJSON `json:"-"` +} + +// zonesPrefetchPreloadJSON contains the JSON metadata for the struct +// [ZonesPrefetchPreload] +type zonesPrefetchPreloadJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesPrefetchPreload) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesPrefetchPreloadJSON) RawJSON() string { + return r.raw +} + +func (r ZonesPrefetchPreload) implementsZonesSettingEditResponse() {} + +func (r ZonesPrefetchPreload) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesPrefetchPreloadID string + +const ( + ZonesPrefetchPreloadIDPrefetchPreload ZonesPrefetchPreloadID = "prefetch_preload" +) + +// Current value of the zone setting. +type ZonesPrefetchPreloadValue string + +const ( + ZonesPrefetchPreloadValueOn ZonesPrefetchPreloadValue = "on" + ZonesPrefetchPreloadValueOff ZonesPrefetchPreloadValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesPrefetchPreloadEditable bool + +const ( + ZonesPrefetchPreloadEditableTrue ZonesPrefetchPreloadEditable = true + ZonesPrefetchPreloadEditableFalse ZonesPrefetchPreloadEditable = false +) + +// Cloudflare will prefetch any URLs that are included in the response headers. +// This is limited to Enterprise Zones. +type ZonesPrefetchPreloadParam struct { + // ID of the zone setting. + ID param.Field[ZonesPrefetchPreloadID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesPrefetchPreloadValue] `json:"value,required"` +} + +func (r ZonesPrefetchPreloadParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesPrefetchPreloadParam) implementsZonesSettingEditParamsItem() {} + +type SettingPrefetchPreloadEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingPrefetchPreloadEditParamsValue] `json:"value,required"` +} + +func (r SettingPrefetchPreloadEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingPrefetchPreloadEditParamsValue string + +const ( + SettingPrefetchPreloadEditParamsValueOn SettingPrefetchPreloadEditParamsValue = "on" + SettingPrefetchPreloadEditParamsValueOff SettingPrefetchPreloadEditParamsValue = "off" +) + +type SettingPrefetchPreloadEditResponseEnvelope struct { + Errors []SettingPrefetchPreloadEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingPrefetchPreloadEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Cloudflare will prefetch any URLs that are included in the response headers. + // This is limited to Enterprise Zones. + Result ZonesPrefetchPreload `json:"result"` + JSON settingPrefetchPreloadEditResponseEnvelopeJSON `json:"-"` +} + +// settingPrefetchPreloadEditResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingPrefetchPreloadEditResponseEnvelope] +type settingPrefetchPreloadEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingPrefetchPreloadEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingPrefetchPreloadEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingPrefetchPreloadEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingPrefetchPreloadEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingPrefetchPreloadEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingPrefetchPreloadEditResponseEnvelopeErrors] +type settingPrefetchPreloadEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingPrefetchPreloadEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingPrefetchPreloadEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingPrefetchPreloadEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingPrefetchPreloadEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingPrefetchPreloadEditResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingPrefetchPreloadEditResponseEnvelopeMessages] +type settingPrefetchPreloadEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingPrefetchPreloadEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingPrefetchPreloadEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingPrefetchPreloadGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingPrefetchPreloadGetResponseEnvelope struct { + Errors []SettingPrefetchPreloadGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingPrefetchPreloadGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Cloudflare will prefetch any URLs that are included in the response headers. + // This is limited to Enterprise Zones. + Result ZonesPrefetchPreload `json:"result"` + JSON settingPrefetchPreloadGetResponseEnvelopeJSON `json:"-"` +} + +// settingPrefetchPreloadGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingPrefetchPreloadGetResponseEnvelope] +type settingPrefetchPreloadGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingPrefetchPreloadGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingPrefetchPreloadGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingPrefetchPreloadGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingPrefetchPreloadGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingPrefetchPreloadGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingPrefetchPreloadGetResponseEnvelopeErrors] +type settingPrefetchPreloadGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingPrefetchPreloadGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingPrefetchPreloadGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingPrefetchPreloadGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingPrefetchPreloadGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingPrefetchPreloadGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingPrefetchPreloadGetResponseEnvelopeMessages] +type settingPrefetchPreloadGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingPrefetchPreloadGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingPrefetchPreloadGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingprefetchpreload_test.go b/zones/settingprefetchpreload_test.go new file mode 100644 index 00000000000..c1adad49daf --- /dev/null +++ b/zones/settingprefetchpreload_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingPrefetchPreloadEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.PrefetchPreload.Edit(context.TODO(), zones.SettingPrefetchPreloadEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingPrefetchPreloadEditParamsValueOn), + }) + 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 TestSettingPrefetchPreloadGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.PrefetchPreload.Get(context.TODO(), zones.SettingPrefetchPreloadGetParams{ + ZoneID: cloudflare.F("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/zones/settingproxyreadtimeout.go b/zones/settingproxyreadtimeout.go new file mode 100644 index 00000000000..0447987e6fb --- /dev/null +++ b/zones/settingproxyreadtimeout.go @@ -0,0 +1,292 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingProxyReadTimeoutService 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 +// [NewSettingProxyReadTimeoutService] method instead. +type SettingProxyReadTimeoutService struct { + Options []option.RequestOption +} + +// NewSettingProxyReadTimeoutService 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 NewSettingProxyReadTimeoutService(opts ...option.RequestOption) (r *SettingProxyReadTimeoutService) { + r = &SettingProxyReadTimeoutService{} + r.Options = opts + return +} + +// Maximum time between two read operations from origin. +func (r *SettingProxyReadTimeoutService) Edit(ctx context.Context, params SettingProxyReadTimeoutEditParams, opts ...option.RequestOption) (res *ZonesProxyReadTimeout, err error) { + opts = append(r.Options[:], opts...) + var env SettingProxyReadTimeoutEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/proxy_read_timeout", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Maximum time between two read operations from origin. +func (r *SettingProxyReadTimeoutService) Get(ctx context.Context, query SettingProxyReadTimeoutGetParams, opts ...option.RequestOption) (res *ZonesProxyReadTimeout, err error) { + opts = append(r.Options[:], opts...) + var env SettingProxyReadTimeoutGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/proxy_read_timeout", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Maximum time between two read operations from origin. +type ZonesProxyReadTimeout struct { + // ID of the zone setting. + ID ZonesProxyReadTimeoutID `json:"id,required"` + // Current value of the zone setting. + Value float64 `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesProxyReadTimeoutEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesProxyReadTimeoutJSON `json:"-"` +} + +// zonesProxyReadTimeoutJSON contains the JSON metadata for the struct +// [ZonesProxyReadTimeout] +type zonesProxyReadTimeoutJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesProxyReadTimeout) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesProxyReadTimeoutJSON) RawJSON() string { + return r.raw +} + +func (r ZonesProxyReadTimeout) implementsZonesSettingEditResponse() {} + +func (r ZonesProxyReadTimeout) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesProxyReadTimeoutID string + +const ( + ZonesProxyReadTimeoutIDProxyReadTimeout ZonesProxyReadTimeoutID = "proxy_read_timeout" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesProxyReadTimeoutEditable bool + +const ( + ZonesProxyReadTimeoutEditableTrue ZonesProxyReadTimeoutEditable = true + ZonesProxyReadTimeoutEditableFalse ZonesProxyReadTimeoutEditable = false +) + +// Maximum time between two read operations from origin. +type ZonesProxyReadTimeoutParam struct { + // ID of the zone setting. + ID param.Field[ZonesProxyReadTimeoutID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[float64] `json:"value,required"` +} + +func (r ZonesProxyReadTimeoutParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesProxyReadTimeoutParam) implementsZonesSettingEditParamsItem() {} + +type SettingProxyReadTimeoutEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Maximum time between two read operations from origin. + Value param.Field[ZonesProxyReadTimeoutParam] `json:"value,required"` +} + +func (r SettingProxyReadTimeoutEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingProxyReadTimeoutEditResponseEnvelope struct { + Errors []SettingProxyReadTimeoutEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingProxyReadTimeoutEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Maximum time between two read operations from origin. + Result ZonesProxyReadTimeout `json:"result"` + JSON settingProxyReadTimeoutEditResponseEnvelopeJSON `json:"-"` +} + +// settingProxyReadTimeoutEditResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingProxyReadTimeoutEditResponseEnvelope] +type settingProxyReadTimeoutEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingProxyReadTimeoutEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingProxyReadTimeoutEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingProxyReadTimeoutEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingProxyReadTimeoutEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingProxyReadTimeoutEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingProxyReadTimeoutEditResponseEnvelopeErrors] +type settingProxyReadTimeoutEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingProxyReadTimeoutEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingProxyReadTimeoutEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingProxyReadTimeoutEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingProxyReadTimeoutEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingProxyReadTimeoutEditResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingProxyReadTimeoutEditResponseEnvelopeMessages] +type settingProxyReadTimeoutEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingProxyReadTimeoutEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingProxyReadTimeoutEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingProxyReadTimeoutGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingProxyReadTimeoutGetResponseEnvelope struct { + Errors []SettingProxyReadTimeoutGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingProxyReadTimeoutGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Maximum time between two read operations from origin. + Result ZonesProxyReadTimeout `json:"result"` + JSON settingProxyReadTimeoutGetResponseEnvelopeJSON `json:"-"` +} + +// settingProxyReadTimeoutGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingProxyReadTimeoutGetResponseEnvelope] +type settingProxyReadTimeoutGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingProxyReadTimeoutGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingProxyReadTimeoutGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingProxyReadTimeoutGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingProxyReadTimeoutGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingProxyReadTimeoutGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingProxyReadTimeoutGetResponseEnvelopeErrors] +type settingProxyReadTimeoutGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingProxyReadTimeoutGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingProxyReadTimeoutGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingProxyReadTimeoutGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingProxyReadTimeoutGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingProxyReadTimeoutGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingProxyReadTimeoutGetResponseEnvelopeMessages] +type settingProxyReadTimeoutGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingProxyReadTimeoutGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingProxyReadTimeoutGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingproxyreadtimeout_test.go b/zones/settingproxyreadtimeout_test.go new file mode 100644 index 00000000000..f409c0c7e61 --- /dev/null +++ b/zones/settingproxyreadtimeout_test.go @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingProxyReadTimeoutEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Zones.Settings.ProxyReadTimeout.Edit(context.TODO(), zones.SettingProxyReadTimeoutEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.ZonesProxyReadTimeoutParam{ + ID: cloudflare.F(zones.ZonesProxyReadTimeoutIDProxyReadTimeout), + Value: cloudflare.F(0.000000), + }), + }) + 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 TestSettingProxyReadTimeoutGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.ProxyReadTimeout.Get(context.TODO(), zones.SettingProxyReadTimeoutGetParams{ + ZoneID: cloudflare.F("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/zones/settingpseudoipv4.go b/zones/settingpseudoipv4.go new file mode 100644 index 00000000000..e9ebc46cde4 --- /dev/null +++ b/zones/settingpseudoipv4.go @@ -0,0 +1,309 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingPseudoIPV4Service 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 [NewSettingPseudoIPV4Service] method +// instead. +type SettingPseudoIPV4Service struct { + Options []option.RequestOption +} + +// NewSettingPseudoIPV4Service 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 NewSettingPseudoIPV4Service(opts ...option.RequestOption) (r *SettingPseudoIPV4Service) { + r = &SettingPseudoIPV4Service{} + r.Options = opts + return +} + +// Value of the Pseudo IPv4 setting. +func (r *SettingPseudoIPV4Service) Edit(ctx context.Context, params SettingPseudoIPV4EditParams, opts ...option.RequestOption) (res *ZonesPseudoIPV4, err error) { + opts = append(r.Options[:], opts...) + var env SettingPseudoIPV4EditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/pseudo_ipv4", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Value of the Pseudo IPv4 setting. +func (r *SettingPseudoIPV4Service) Get(ctx context.Context, query SettingPseudoIPV4GetParams, opts ...option.RequestOption) (res *ZonesPseudoIPV4, err error) { + opts = append(r.Options[:], opts...) + var env SettingPseudoIPV4GetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/pseudo_ipv4", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// The value set for the Pseudo IPv4 setting. +type ZonesPseudoIPV4 struct { + // Value of the Pseudo IPv4 setting. + ID ZonesPseudoIPV4ID `json:"id,required"` + // Current value of the zone setting. + Value ZonesPseudoIPV4Value `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesPseudoIPV4Editable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesPseudoIPV4JSON `json:"-"` +} + +// zonesPseudoIPV4JSON contains the JSON metadata for the struct [ZonesPseudoIPV4] +type zonesPseudoIPV4JSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesPseudoIPV4) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesPseudoIPV4JSON) RawJSON() string { + return r.raw +} + +func (r ZonesPseudoIPV4) implementsZonesSettingEditResponse() {} + +func (r ZonesPseudoIPV4) implementsZonesSettingGetResponse() {} + +// Value of the Pseudo IPv4 setting. +type ZonesPseudoIPV4ID string + +const ( + ZonesPseudoIPV4IDPseudoIPV4 ZonesPseudoIPV4ID = "pseudo_ipv4" +) + +// Current value of the zone setting. +type ZonesPseudoIPV4Value string + +const ( + ZonesPseudoIPV4ValueOff ZonesPseudoIPV4Value = "off" + ZonesPseudoIPV4ValueAddHeader ZonesPseudoIPV4Value = "add_header" + ZonesPseudoIPV4ValueOverwriteHeader ZonesPseudoIPV4Value = "overwrite_header" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesPseudoIPV4Editable bool + +const ( + ZonesPseudoIPV4EditableTrue ZonesPseudoIPV4Editable = true + ZonesPseudoIPV4EditableFalse ZonesPseudoIPV4Editable = false +) + +// The value set for the Pseudo IPv4 setting. +type ZonesPseudoIPV4Param struct { + // Value of the Pseudo IPv4 setting. + ID param.Field[ZonesPseudoIPV4ID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesPseudoIPV4Value] `json:"value,required"` +} + +func (r ZonesPseudoIPV4Param) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesPseudoIPV4Param) implementsZonesSettingEditParamsItem() {} + +type SettingPseudoIPV4EditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the Pseudo IPv4 setting. + Value param.Field[SettingPseudoIPV4EditParamsValue] `json:"value,required"` +} + +func (r SettingPseudoIPV4EditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the Pseudo IPv4 setting. +type SettingPseudoIPV4EditParamsValue string + +const ( + SettingPseudoIPV4EditParamsValueOff SettingPseudoIPV4EditParamsValue = "off" + SettingPseudoIPV4EditParamsValueAddHeader SettingPseudoIPV4EditParamsValue = "add_header" + SettingPseudoIPV4EditParamsValueOverwriteHeader SettingPseudoIPV4EditParamsValue = "overwrite_header" +) + +type SettingPseudoIPV4EditResponseEnvelope struct { + Errors []SettingPseudoIPV4EditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingPseudoIPV4EditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // The value set for the Pseudo IPv4 setting. + Result ZonesPseudoIPV4 `json:"result"` + JSON settingPseudoIPV4EditResponseEnvelopeJSON `json:"-"` +} + +// settingPseudoIPV4EditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingPseudoIPV4EditResponseEnvelope] +type settingPseudoIPV4EditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingPseudoIPV4EditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingPseudoIPV4EditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingPseudoIPV4EditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingPseudoIPV4EditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingPseudoIPV4EditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingPseudoIPV4EditResponseEnvelopeErrors] +type settingPseudoIPV4EditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingPseudoIPV4EditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingPseudoIPV4EditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingPseudoIPV4EditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingPseudoIPV4EditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingPseudoIPV4EditResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [SettingPseudoIPV4EditResponseEnvelopeMessages] +type settingPseudoIPV4EditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingPseudoIPV4EditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingPseudoIPV4EditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingPseudoIPV4GetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingPseudoIPV4GetResponseEnvelope struct { + Errors []SettingPseudoIPV4GetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingPseudoIPV4GetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // The value set for the Pseudo IPv4 setting. + Result ZonesPseudoIPV4 `json:"result"` + JSON settingPseudoIPV4GetResponseEnvelopeJSON `json:"-"` +} + +// settingPseudoIPV4GetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingPseudoIPV4GetResponseEnvelope] +type settingPseudoIPV4GetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingPseudoIPV4GetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingPseudoIPV4GetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingPseudoIPV4GetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingPseudoIPV4GetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingPseudoIPV4GetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingPseudoIPV4GetResponseEnvelopeErrors] +type settingPseudoIPV4GetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingPseudoIPV4GetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingPseudoIPV4GetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingPseudoIPV4GetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingPseudoIPV4GetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingPseudoIPV4GetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [SettingPseudoIPV4GetResponseEnvelopeMessages] +type settingPseudoIPV4GetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingPseudoIPV4GetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingPseudoIPV4GetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingpseudoipv4_test.go b/zones/settingpseudoipv4_test.go new file mode 100644 index 00000000000..36326c43435 --- /dev/null +++ b/zones/settingpseudoipv4_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingPseudoIPV4Edit(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("user@example.com"), + ) + _, err := client.Zones.Settings.PseudoIPV4.Edit(context.TODO(), zones.SettingPseudoIPV4EditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingPseudoIPV4EditParamsValueOff), + }) + 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 TestSettingPseudoIPV4Get(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("user@example.com"), + ) + _, err := client.Zones.Settings.PseudoIPV4.Get(context.TODO(), zones.SettingPseudoIPV4GetParams{ + ZoneID: cloudflare.F("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/zones/settingresponsebuffering.go b/zones/settingresponsebuffering.go new file mode 100644 index 00000000000..72d35163c5d --- /dev/null +++ b/zones/settingresponsebuffering.go @@ -0,0 +1,325 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingResponseBufferingService 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 +// [NewSettingResponseBufferingService] method instead. +type SettingResponseBufferingService struct { + Options []option.RequestOption +} + +// NewSettingResponseBufferingService 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 NewSettingResponseBufferingService(opts ...option.RequestOption) (r *SettingResponseBufferingService) { + r = &SettingResponseBufferingService{} + r.Options = opts + return +} + +// Enables or disables buffering of responses from the proxied server. Cloudflare +// may buffer the whole payload to deliver it at once to the client versus allowing +// it to be delivered in chunks. By default, the proxied server streams directly +// and is not buffered by Cloudflare. This is limited to Enterprise Zones. +func (r *SettingResponseBufferingService) Edit(ctx context.Context, params SettingResponseBufferingEditParams, opts ...option.RequestOption) (res *ZonesBuffering, err error) { + opts = append(r.Options[:], opts...) + var env SettingResponseBufferingEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/response_buffering", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Enables or disables buffering of responses from the proxied server. Cloudflare +// may buffer the whole payload to deliver it at once to the client versus allowing +// it to be delivered in chunks. By default, the proxied server streams directly +// and is not buffered by Cloudflare. This is limited to Enterprise Zones. +func (r *SettingResponseBufferingService) Get(ctx context.Context, query SettingResponseBufferingGetParams, opts ...option.RequestOption) (res *ZonesBuffering, err error) { + opts = append(r.Options[:], opts...) + var env SettingResponseBufferingGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/response_buffering", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Enables or disables buffering of responses from the proxied server. Cloudflare +// may buffer the whole payload to deliver it at once to the client versus allowing +// it to be delivered in chunks. By default, the proxied server streams directly +// and is not buffered by Cloudflare. This is limited to Enterprise Zones. +type ZonesBuffering struct { + // ID of the zone setting. + ID ZonesBufferingID `json:"id,required"` + // Current value of the zone setting. + Value ZonesBufferingValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesBufferingEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesBufferingJSON `json:"-"` +} + +// zonesBufferingJSON contains the JSON metadata for the struct [ZonesBuffering] +type zonesBufferingJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesBuffering) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesBufferingJSON) RawJSON() string { + return r.raw +} + +func (r ZonesBuffering) implementsZonesSettingEditResponse() {} + +func (r ZonesBuffering) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesBufferingID string + +const ( + ZonesBufferingIDResponseBuffering ZonesBufferingID = "response_buffering" +) + +// Current value of the zone setting. +type ZonesBufferingValue string + +const ( + ZonesBufferingValueOn ZonesBufferingValue = "on" + ZonesBufferingValueOff ZonesBufferingValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesBufferingEditable bool + +const ( + ZonesBufferingEditableTrue ZonesBufferingEditable = true + ZonesBufferingEditableFalse ZonesBufferingEditable = false +) + +// Enables or disables buffering of responses from the proxied server. Cloudflare +// may buffer the whole payload to deliver it at once to the client versus allowing +// it to be delivered in chunks. By default, the proxied server streams directly +// and is not buffered by Cloudflare. This is limited to Enterprise Zones. +type ZonesBufferingParam struct { + // ID of the zone setting. + ID param.Field[ZonesBufferingID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesBufferingValue] `json:"value,required"` +} + +func (r ZonesBufferingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesBufferingParam) implementsZonesSettingEditParamsItem() {} + +type SettingResponseBufferingEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingResponseBufferingEditParamsValue] `json:"value,required"` +} + +func (r SettingResponseBufferingEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingResponseBufferingEditParamsValue string + +const ( + SettingResponseBufferingEditParamsValueOn SettingResponseBufferingEditParamsValue = "on" + SettingResponseBufferingEditParamsValueOff SettingResponseBufferingEditParamsValue = "off" +) + +type SettingResponseBufferingEditResponseEnvelope struct { + Errors []SettingResponseBufferingEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingResponseBufferingEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Enables or disables buffering of responses from the proxied server. Cloudflare + // may buffer the whole payload to deliver it at once to the client versus allowing + // it to be delivered in chunks. By default, the proxied server streams directly + // and is not buffered by Cloudflare. This is limited to Enterprise Zones. + Result ZonesBuffering `json:"result"` + JSON settingResponseBufferingEditResponseEnvelopeJSON `json:"-"` +} + +// settingResponseBufferingEditResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingResponseBufferingEditResponseEnvelope] +type settingResponseBufferingEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingResponseBufferingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingResponseBufferingEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingResponseBufferingEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingResponseBufferingEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingResponseBufferingEditResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [SettingResponseBufferingEditResponseEnvelopeErrors] +type settingResponseBufferingEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingResponseBufferingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingResponseBufferingEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingResponseBufferingEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingResponseBufferingEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingResponseBufferingEditResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingResponseBufferingEditResponseEnvelopeMessages] +type settingResponseBufferingEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingResponseBufferingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingResponseBufferingEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingResponseBufferingGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingResponseBufferingGetResponseEnvelope struct { + Errors []SettingResponseBufferingGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingResponseBufferingGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Enables or disables buffering of responses from the proxied server. Cloudflare + // may buffer the whole payload to deliver it at once to the client versus allowing + // it to be delivered in chunks. By default, the proxied server streams directly + // and is not buffered by Cloudflare. This is limited to Enterprise Zones. + Result ZonesBuffering `json:"result"` + JSON settingResponseBufferingGetResponseEnvelopeJSON `json:"-"` +} + +// settingResponseBufferingGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingResponseBufferingGetResponseEnvelope] +type settingResponseBufferingGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingResponseBufferingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingResponseBufferingGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingResponseBufferingGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingResponseBufferingGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingResponseBufferingGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingResponseBufferingGetResponseEnvelopeErrors] +type settingResponseBufferingGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingResponseBufferingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingResponseBufferingGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingResponseBufferingGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingResponseBufferingGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingResponseBufferingGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingResponseBufferingGetResponseEnvelopeMessages] +type settingResponseBufferingGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingResponseBufferingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingResponseBufferingGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingresponsebuffering_test.go b/zones/settingresponsebuffering_test.go new file mode 100644 index 00000000000..c69087fbdd7 --- /dev/null +++ b/zones/settingresponsebuffering_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingResponseBufferingEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.ResponseBuffering.Edit(context.TODO(), zones.SettingResponseBufferingEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingResponseBufferingEditParamsValueOn), + }) + 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 TestSettingResponseBufferingGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.ResponseBuffering.Get(context.TODO(), zones.SettingResponseBufferingGetParams{ + ZoneID: cloudflare.F("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/zones/settingrocketloader.go b/zones/settingrocketloader.go new file mode 100644 index 00000000000..d229e6b4566 --- /dev/null +++ b/zones/settingrocketloader.go @@ -0,0 +1,363 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingRocketLoaderService 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 [NewSettingRocketLoaderService] +// method instead. +type SettingRocketLoaderService struct { + Options []option.RequestOption +} + +// NewSettingRocketLoaderService 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 NewSettingRocketLoaderService(opts ...option.RequestOption) (r *SettingRocketLoaderService) { + r = &SettingRocketLoaderService{} + r.Options = opts + return +} + +// Rocket Loader is a general-purpose asynchronous JavaScript optimisation that +// prioritises rendering your content while loading your site's Javascript +// asynchronously. Turning on Rocket Loader will immediately improve a web page's +// rendering time sometimes measured as Time to First Paint (TTFP), and also the +// `window.onload` time (assuming there is JavaScript on the page). This can have a +// positive impact on your Google search ranking. When turned on, Rocket Loader +// will automatically defer the loading of all Javascript referenced in your HTML, +// with no configuration required. Refer to +// [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) +// for more information. +func (r *SettingRocketLoaderService) Edit(ctx context.Context, params SettingRocketLoaderEditParams, opts ...option.RequestOption) (res *ZonesRocketLoader, err error) { + opts = append(r.Options[:], opts...) + var env SettingRocketLoaderEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/rocket_loader", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Rocket Loader is a general-purpose asynchronous JavaScript optimisation that +// prioritises rendering your content while loading your site's Javascript +// asynchronously. Turning on Rocket Loader will immediately improve a web page's +// rendering time sometimes measured as Time to First Paint (TTFP), and also the +// `window.onload` time (assuming there is JavaScript on the page). This can have a +// positive impact on your Google search ranking. When turned on, Rocket Loader +// will automatically defer the loading of all Javascript referenced in your HTML, +// with no configuration required. Refer to +// [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) +// for more information. +func (r *SettingRocketLoaderService) Get(ctx context.Context, query SettingRocketLoaderGetParams, opts ...option.RequestOption) (res *ZonesRocketLoader, err error) { + opts = append(r.Options[:], opts...) + var env SettingRocketLoaderGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/rocket_loader", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Rocket Loader is a general-purpose asynchronous JavaScript optimisation that +// prioritises rendering your content while loading your site's Javascript +// asynchronously. Turning on Rocket Loader will immediately improve a web page's +// rendering time sometimes measured as Time to First Paint (TTFP), and also the +// `window.onload` time (assuming there is JavaScript on the page). This can have a +// positive impact on your Google search ranking. When turned on, Rocket Loader +// will automatically defer the loading of all Javascript referenced in your HTML, +// with no configuration required. Refer to +// [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) +// for more information. +type ZonesRocketLoader struct { + // ID of the zone setting. + ID ZonesRocketLoaderID `json:"id,required"` + // Current value of the zone setting. + Value ZonesRocketLoaderValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesRocketLoaderEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesRocketLoaderJSON `json:"-"` +} + +// zonesRocketLoaderJSON contains the JSON metadata for the struct +// [ZonesRocketLoader] +type zonesRocketLoaderJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesRocketLoader) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesRocketLoaderJSON) RawJSON() string { + return r.raw +} + +func (r ZonesRocketLoader) implementsZonesSettingEditResponse() {} + +func (r ZonesRocketLoader) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesRocketLoaderID string + +const ( + ZonesRocketLoaderIDRocketLoader ZonesRocketLoaderID = "rocket_loader" +) + +// Current value of the zone setting. +type ZonesRocketLoaderValue string + +const ( + ZonesRocketLoaderValueOn ZonesRocketLoaderValue = "on" + ZonesRocketLoaderValueOff ZonesRocketLoaderValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesRocketLoaderEditable bool + +const ( + ZonesRocketLoaderEditableTrue ZonesRocketLoaderEditable = true + ZonesRocketLoaderEditableFalse ZonesRocketLoaderEditable = false +) + +// Rocket Loader is a general-purpose asynchronous JavaScript optimisation that +// prioritises rendering your content while loading your site's Javascript +// asynchronously. Turning on Rocket Loader will immediately improve a web page's +// rendering time sometimes measured as Time to First Paint (TTFP), and also the +// `window.onload` time (assuming there is JavaScript on the page). This can have a +// positive impact on your Google search ranking. When turned on, Rocket Loader +// will automatically defer the loading of all Javascript referenced in your HTML, +// with no configuration required. Refer to +// [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) +// for more information. +type ZonesRocketLoaderParam struct { + // ID of the zone setting. + ID param.Field[ZonesRocketLoaderID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesRocketLoaderValue] `json:"value,required"` +} + +func (r ZonesRocketLoaderParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesRocketLoaderParam) implementsZonesSettingEditParamsItem() {} + +type SettingRocketLoaderEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Rocket Loader is a general-purpose asynchronous JavaScript optimisation that + // prioritises rendering your content while loading your site's Javascript + // asynchronously. Turning on Rocket Loader will immediately improve a web page's + // rendering time sometimes measured as Time to First Paint (TTFP), and also the + // `window.onload` time (assuming there is JavaScript on the page). This can have a + // positive impact on your Google search ranking. When turned on, Rocket Loader + // will automatically defer the loading of all Javascript referenced in your HTML, + // with no configuration required. Refer to + // [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) + // for more information. + Value param.Field[ZonesRocketLoaderParam] `json:"value,required"` +} + +func (r SettingRocketLoaderEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingRocketLoaderEditResponseEnvelope struct { + Errors []SettingRocketLoaderEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingRocketLoaderEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Rocket Loader is a general-purpose asynchronous JavaScript optimisation that + // prioritises rendering your content while loading your site's Javascript + // asynchronously. Turning on Rocket Loader will immediately improve a web page's + // rendering time sometimes measured as Time to First Paint (TTFP), and also the + // `window.onload` time (assuming there is JavaScript on the page). This can have a + // positive impact on your Google search ranking. When turned on, Rocket Loader + // will automatically defer the loading of all Javascript referenced in your HTML, + // with no configuration required. Refer to + // [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) + // for more information. + Result ZonesRocketLoader `json:"result"` + JSON settingRocketLoaderEditResponseEnvelopeJSON `json:"-"` +} + +// settingRocketLoaderEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingRocketLoaderEditResponseEnvelope] +type settingRocketLoaderEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingRocketLoaderEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingRocketLoaderEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingRocketLoaderEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingRocketLoaderEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingRocketLoaderEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingRocketLoaderEditResponseEnvelopeErrors] +type settingRocketLoaderEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingRocketLoaderEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingRocketLoaderEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingRocketLoaderEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingRocketLoaderEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingRocketLoaderEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingRocketLoaderEditResponseEnvelopeMessages] +type settingRocketLoaderEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingRocketLoaderEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingRocketLoaderEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingRocketLoaderGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingRocketLoaderGetResponseEnvelope struct { + Errors []SettingRocketLoaderGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingRocketLoaderGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Rocket Loader is a general-purpose asynchronous JavaScript optimisation that + // prioritises rendering your content while loading your site's Javascript + // asynchronously. Turning on Rocket Loader will immediately improve a web page's + // rendering time sometimes measured as Time to First Paint (TTFP), and also the + // `window.onload` time (assuming there is JavaScript on the page). This can have a + // positive impact on your Google search ranking. When turned on, Rocket Loader + // will automatically defer the loading of all Javascript referenced in your HTML, + // with no configuration required. Refer to + // [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) + // for more information. + Result ZonesRocketLoader `json:"result"` + JSON settingRocketLoaderGetResponseEnvelopeJSON `json:"-"` +} + +// settingRocketLoaderGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingRocketLoaderGetResponseEnvelope] +type settingRocketLoaderGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingRocketLoaderGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingRocketLoaderGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingRocketLoaderGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingRocketLoaderGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingRocketLoaderGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingRocketLoaderGetResponseEnvelopeErrors] +type settingRocketLoaderGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingRocketLoaderGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingRocketLoaderGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingRocketLoaderGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingRocketLoaderGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingRocketLoaderGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingRocketLoaderGetResponseEnvelopeMessages] +type settingRocketLoaderGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingRocketLoaderGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingRocketLoaderGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingrocketloader_test.go b/zones/settingrocketloader_test.go new file mode 100644 index 00000000000..c4d6cd9d985 --- /dev/null +++ b/zones/settingrocketloader_test.go @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingRocketLoaderEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Zones.Settings.RocketLoader.Edit(context.TODO(), zones.SettingRocketLoaderEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.ZonesRocketLoaderParam{ + ID: cloudflare.F(zones.ZonesRocketLoaderIDRocketLoader), + Value: cloudflare.F(zones.ZonesRocketLoaderValueOn), + }), + }) + 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 TestSettingRocketLoaderGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.RocketLoader.Get(context.TODO(), zones.SettingRocketLoaderGetParams{ + ZoneID: cloudflare.F("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/zones/settingsecurityheader.go b/zones/settingsecurityheader.go new file mode 100644 index 00000000000..aa2cf35ef1f --- /dev/null +++ b/zones/settingsecurityheader.go @@ -0,0 +1,397 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingSecurityHeaderService 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 [NewSettingSecurityHeaderService] +// method instead. +type SettingSecurityHeaderService struct { + Options []option.RequestOption +} + +// NewSettingSecurityHeaderService 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 NewSettingSecurityHeaderService(opts ...option.RequestOption) (r *SettingSecurityHeaderService) { + r = &SettingSecurityHeaderService{} + r.Options = opts + return +} + +// Cloudflare security header for a zone. +func (r *SettingSecurityHeaderService) Edit(ctx context.Context, params SettingSecurityHeaderEditParams, opts ...option.RequestOption) (res *ZonesSecurityHeader, err error) { + opts = append(r.Options[:], opts...) + var env SettingSecurityHeaderEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/security_header", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Cloudflare security header for a zone. +func (r *SettingSecurityHeaderService) Get(ctx context.Context, query SettingSecurityHeaderGetParams, opts ...option.RequestOption) (res *ZonesSecurityHeader, err error) { + opts = append(r.Options[:], opts...) + var env SettingSecurityHeaderGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/security_header", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Cloudflare security header for a zone. +type ZonesSecurityHeader struct { + // ID of the zone's security header. + ID ZonesSecurityHeaderID `json:"id,required"` + // Current value of the zone setting. + Value ZonesSecurityHeaderValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesSecurityHeaderEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesSecurityHeaderJSON `json:"-"` +} + +// zonesSecurityHeaderJSON contains the JSON metadata for the struct +// [ZonesSecurityHeader] +type zonesSecurityHeaderJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesSecurityHeader) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesSecurityHeaderJSON) RawJSON() string { + return r.raw +} + +func (r ZonesSecurityHeader) implementsZonesSettingEditResponse() {} + +func (r ZonesSecurityHeader) implementsZonesSettingGetResponse() {} + +// ID of the zone's security header. +type ZonesSecurityHeaderID string + +const ( + ZonesSecurityHeaderIDSecurityHeader ZonesSecurityHeaderID = "security_header" +) + +// Current value of the zone setting. +type ZonesSecurityHeaderValue struct { + // Strict Transport Security. + StrictTransportSecurity ZonesSecurityHeaderValueStrictTransportSecurity `json:"strict_transport_security"` + JSON zonesSecurityHeaderValueJSON `json:"-"` +} + +// zonesSecurityHeaderValueJSON contains the JSON metadata for the struct +// [ZonesSecurityHeaderValue] +type zonesSecurityHeaderValueJSON struct { + StrictTransportSecurity apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesSecurityHeaderValue) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesSecurityHeaderValueJSON) RawJSON() string { + return r.raw +} + +// Strict Transport Security. +type ZonesSecurityHeaderValueStrictTransportSecurity struct { + // Whether or not strict transport security is enabled. + Enabled bool `json:"enabled"` + // Include all subdomains for strict transport security. + IncludeSubdomains bool `json:"include_subdomains"` + // Max age in seconds of the strict transport security. + MaxAge float64 `json:"max_age"` + // Whether or not to include 'X-Content-Type-Options: nosniff' header. + Nosniff bool `json:"nosniff"` + JSON zonesSecurityHeaderValueStrictTransportSecurityJSON `json:"-"` +} + +// zonesSecurityHeaderValueStrictTransportSecurityJSON contains the JSON metadata +// for the struct [ZonesSecurityHeaderValueStrictTransportSecurity] +type zonesSecurityHeaderValueStrictTransportSecurityJSON struct { + Enabled apijson.Field + IncludeSubdomains apijson.Field + MaxAge apijson.Field + Nosniff apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesSecurityHeaderValueStrictTransportSecurity) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesSecurityHeaderValueStrictTransportSecurityJSON) RawJSON() string { + return r.raw +} + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesSecurityHeaderEditable bool + +const ( + ZonesSecurityHeaderEditableTrue ZonesSecurityHeaderEditable = true + ZonesSecurityHeaderEditableFalse ZonesSecurityHeaderEditable = false +) + +// Cloudflare security header for a zone. +type ZonesSecurityHeaderParam struct { + // ID of the zone's security header. + ID param.Field[ZonesSecurityHeaderID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesSecurityHeaderValueParam] `json:"value,required"` +} + +func (r ZonesSecurityHeaderParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesSecurityHeaderParam) implementsZonesSettingEditParamsItem() {} + +// Current value of the zone setting. +type ZonesSecurityHeaderValueParam struct { + // Strict Transport Security. + StrictTransportSecurity param.Field[ZonesSecurityHeaderValueStrictTransportSecurityParam] `json:"strict_transport_security"` +} + +func (r ZonesSecurityHeaderValueParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Strict Transport Security. +type ZonesSecurityHeaderValueStrictTransportSecurityParam struct { + // Whether or not strict transport security is enabled. + Enabled param.Field[bool] `json:"enabled"` + // Include all subdomains for strict transport security. + IncludeSubdomains param.Field[bool] `json:"include_subdomains"` + // Max age in seconds of the strict transport security. + MaxAge param.Field[float64] `json:"max_age"` + // Whether or not to include 'X-Content-Type-Options: nosniff' header. + Nosniff param.Field[bool] `json:"nosniff"` +} + +func (r ZonesSecurityHeaderValueStrictTransportSecurityParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingSecurityHeaderEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + Value param.Field[SettingSecurityHeaderEditParamsValue] `json:"value,required"` +} + +func (r SettingSecurityHeaderEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingSecurityHeaderEditParamsValue struct { + // Strict Transport Security. + StrictTransportSecurity param.Field[SettingSecurityHeaderEditParamsValueStrictTransportSecurity] `json:"strict_transport_security"` +} + +func (r SettingSecurityHeaderEditParamsValue) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Strict Transport Security. +type SettingSecurityHeaderEditParamsValueStrictTransportSecurity struct { + // Whether or not strict transport security is enabled. + Enabled param.Field[bool] `json:"enabled"` + // Include all subdomains for strict transport security. + IncludeSubdomains param.Field[bool] `json:"include_subdomains"` + // Max age in seconds of the strict transport security. + MaxAge param.Field[float64] `json:"max_age"` + // Whether or not to include 'X-Content-Type-Options: nosniff' header. + Nosniff param.Field[bool] `json:"nosniff"` +} + +func (r SettingSecurityHeaderEditParamsValueStrictTransportSecurity) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingSecurityHeaderEditResponseEnvelope struct { + Errors []SettingSecurityHeaderEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingSecurityHeaderEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Cloudflare security header for a zone. + Result ZonesSecurityHeader `json:"result"` + JSON settingSecurityHeaderEditResponseEnvelopeJSON `json:"-"` +} + +// settingSecurityHeaderEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingSecurityHeaderEditResponseEnvelope] +type settingSecurityHeaderEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSecurityHeaderEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSecurityHeaderEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingSecurityHeaderEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSecurityHeaderEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingSecurityHeaderEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingSecurityHeaderEditResponseEnvelopeErrors] +type settingSecurityHeaderEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSecurityHeaderEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSecurityHeaderEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingSecurityHeaderEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSecurityHeaderEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingSecurityHeaderEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingSecurityHeaderEditResponseEnvelopeMessages] +type settingSecurityHeaderEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSecurityHeaderEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSecurityHeaderEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingSecurityHeaderGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingSecurityHeaderGetResponseEnvelope struct { + Errors []SettingSecurityHeaderGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingSecurityHeaderGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Cloudflare security header for a zone. + Result ZonesSecurityHeader `json:"result"` + JSON settingSecurityHeaderGetResponseEnvelopeJSON `json:"-"` +} + +// settingSecurityHeaderGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingSecurityHeaderGetResponseEnvelope] +type settingSecurityHeaderGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSecurityHeaderGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSecurityHeaderGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingSecurityHeaderGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSecurityHeaderGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingSecurityHeaderGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingSecurityHeaderGetResponseEnvelopeErrors] +type settingSecurityHeaderGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSecurityHeaderGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSecurityHeaderGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingSecurityHeaderGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSecurityHeaderGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingSecurityHeaderGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingSecurityHeaderGetResponseEnvelopeMessages] +type settingSecurityHeaderGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSecurityHeaderGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSecurityHeaderGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingsecurityheader_test.go b/zones/settingsecurityheader_test.go new file mode 100644 index 00000000000..399e28b9837 --- /dev/null +++ b/zones/settingsecurityheader_test.go @@ -0,0 +1,75 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingSecurityHeaderEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Zones.Settings.SecurityHeaders.Edit(context.TODO(), zones.SettingSecurityHeaderEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingSecurityHeaderEditParamsValue{ + StrictTransportSecurity: cloudflare.F(zones.SettingSecurityHeaderEditParamsValueStrictTransportSecurity{ + Enabled: cloudflare.F(true), + IncludeSubdomains: cloudflare.F(true), + MaxAge: cloudflare.F(86400.000000), + Nosniff: cloudflare.F(true), + }), + }), + }) + 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 TestSettingSecurityHeaderGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.SecurityHeaders.Get(context.TODO(), zones.SettingSecurityHeaderGetParams{ + ZoneID: cloudflare.F("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/zones/settingsecuritylevel.go b/zones/settingsecuritylevel.go new file mode 100644 index 00000000000..0f5c51a1533 --- /dev/null +++ b/zones/settingsecuritylevel.go @@ -0,0 +1,334 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingSecurityLevelService 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 [NewSettingSecurityLevelService] +// method instead. +type SettingSecurityLevelService struct { + Options []option.RequestOption +} + +// NewSettingSecurityLevelService 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 NewSettingSecurityLevelService(opts ...option.RequestOption) (r *SettingSecurityLevelService) { + r = &SettingSecurityLevelService{} + r.Options = opts + return +} + +// Choose the appropriate security profile for your website, which will +// automatically adjust each of the security settings. If you choose to customize +// an individual security setting, the profile will become Custom. +// (https://support.cloudflare.com/hc/en-us/articles/200170056). +func (r *SettingSecurityLevelService) Edit(ctx context.Context, params SettingSecurityLevelEditParams, opts ...option.RequestOption) (res *ZonesSecurityLevel, err error) { + opts = append(r.Options[:], opts...) + var env SettingSecurityLevelEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/security_level", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Choose the appropriate security profile for your website, which will +// automatically adjust each of the security settings. If you choose to customize +// an individual security setting, the profile will become Custom. +// (https://support.cloudflare.com/hc/en-us/articles/200170056). +func (r *SettingSecurityLevelService) Get(ctx context.Context, query SettingSecurityLevelGetParams, opts ...option.RequestOption) (res *ZonesSecurityLevel, err error) { + opts = append(r.Options[:], opts...) + var env SettingSecurityLevelGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/security_level", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Choose the appropriate security profile for your website, which will +// automatically adjust each of the security settings. If you choose to customize +// an individual security setting, the profile will become Custom. +// (https://support.cloudflare.com/hc/en-us/articles/200170056). +type ZonesSecurityLevel struct { + // ID of the zone setting. + ID ZonesSecurityLevelID `json:"id,required"` + // Current value of the zone setting. + Value ZonesSecurityLevelValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesSecurityLevelEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesSecurityLevelJSON `json:"-"` +} + +// zonesSecurityLevelJSON contains the JSON metadata for the struct +// [ZonesSecurityLevel] +type zonesSecurityLevelJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesSecurityLevel) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesSecurityLevelJSON) RawJSON() string { + return r.raw +} + +func (r ZonesSecurityLevel) implementsZonesSettingEditResponse() {} + +func (r ZonesSecurityLevel) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesSecurityLevelID string + +const ( + ZonesSecurityLevelIDSecurityLevel ZonesSecurityLevelID = "security_level" +) + +// Current value of the zone setting. +type ZonesSecurityLevelValue string + +const ( + ZonesSecurityLevelValueOff ZonesSecurityLevelValue = "off" + ZonesSecurityLevelValueEssentiallyOff ZonesSecurityLevelValue = "essentially_off" + ZonesSecurityLevelValueLow ZonesSecurityLevelValue = "low" + ZonesSecurityLevelValueMedium ZonesSecurityLevelValue = "medium" + ZonesSecurityLevelValueHigh ZonesSecurityLevelValue = "high" + ZonesSecurityLevelValueUnderAttack ZonesSecurityLevelValue = "under_attack" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesSecurityLevelEditable bool + +const ( + ZonesSecurityLevelEditableTrue ZonesSecurityLevelEditable = true + ZonesSecurityLevelEditableFalse ZonesSecurityLevelEditable = false +) + +// Choose the appropriate security profile for your website, which will +// automatically adjust each of the security settings. If you choose to customize +// an individual security setting, the profile will become Custom. +// (https://support.cloudflare.com/hc/en-us/articles/200170056). +type ZonesSecurityLevelParam struct { + // ID of the zone setting. + ID param.Field[ZonesSecurityLevelID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesSecurityLevelValue] `json:"value,required"` +} + +func (r ZonesSecurityLevelParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesSecurityLevelParam) implementsZonesSettingEditParamsItem() {} + +type SettingSecurityLevelEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingSecurityLevelEditParamsValue] `json:"value,required"` +} + +func (r SettingSecurityLevelEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingSecurityLevelEditParamsValue string + +const ( + SettingSecurityLevelEditParamsValueOff SettingSecurityLevelEditParamsValue = "off" + SettingSecurityLevelEditParamsValueEssentiallyOff SettingSecurityLevelEditParamsValue = "essentially_off" + SettingSecurityLevelEditParamsValueLow SettingSecurityLevelEditParamsValue = "low" + SettingSecurityLevelEditParamsValueMedium SettingSecurityLevelEditParamsValue = "medium" + SettingSecurityLevelEditParamsValueHigh SettingSecurityLevelEditParamsValue = "high" + SettingSecurityLevelEditParamsValueUnderAttack SettingSecurityLevelEditParamsValue = "under_attack" +) + +type SettingSecurityLevelEditResponseEnvelope struct { + Errors []SettingSecurityLevelEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingSecurityLevelEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Choose the appropriate security profile for your website, which will + // automatically adjust each of the security settings. If you choose to customize + // an individual security setting, the profile will become Custom. + // (https://support.cloudflare.com/hc/en-us/articles/200170056). + Result ZonesSecurityLevel `json:"result"` + JSON settingSecurityLevelEditResponseEnvelopeJSON `json:"-"` +} + +// settingSecurityLevelEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingSecurityLevelEditResponseEnvelope] +type settingSecurityLevelEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSecurityLevelEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSecurityLevelEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingSecurityLevelEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSecurityLevelEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingSecurityLevelEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingSecurityLevelEditResponseEnvelopeErrors] +type settingSecurityLevelEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSecurityLevelEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSecurityLevelEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingSecurityLevelEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSecurityLevelEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingSecurityLevelEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingSecurityLevelEditResponseEnvelopeMessages] +type settingSecurityLevelEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSecurityLevelEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSecurityLevelEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingSecurityLevelGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingSecurityLevelGetResponseEnvelope struct { + Errors []SettingSecurityLevelGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingSecurityLevelGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Choose the appropriate security profile for your website, which will + // automatically adjust each of the security settings. If you choose to customize + // an individual security setting, the profile will become Custom. + // (https://support.cloudflare.com/hc/en-us/articles/200170056). + Result ZonesSecurityLevel `json:"result"` + JSON settingSecurityLevelGetResponseEnvelopeJSON `json:"-"` +} + +// settingSecurityLevelGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingSecurityLevelGetResponseEnvelope] +type settingSecurityLevelGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSecurityLevelGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSecurityLevelGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingSecurityLevelGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSecurityLevelGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingSecurityLevelGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingSecurityLevelGetResponseEnvelopeErrors] +type settingSecurityLevelGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSecurityLevelGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSecurityLevelGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingSecurityLevelGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSecurityLevelGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingSecurityLevelGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingSecurityLevelGetResponseEnvelopeMessages] +type settingSecurityLevelGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSecurityLevelGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSecurityLevelGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingsecuritylevel_test.go b/zones/settingsecuritylevel_test.go new file mode 100644 index 00000000000..93f4e185915 --- /dev/null +++ b/zones/settingsecuritylevel_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingSecurityLevelEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.SecurityLevel.Edit(context.TODO(), zones.SettingSecurityLevelEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingSecurityLevelEditParamsValueOff), + }) + 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 TestSettingSecurityLevelGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.SecurityLevel.Get(context.TODO(), zones.SettingSecurityLevelGetParams{ + ZoneID: cloudflare.F("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/zones/settingserversideexclude.go b/zones/settingserversideexclude.go new file mode 100644 index 00000000000..eac5eaf80bd --- /dev/null +++ b/zones/settingserversideexclude.go @@ -0,0 +1,368 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingServerSideExcludeService 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 +// [NewSettingServerSideExcludeService] method instead. +type SettingServerSideExcludeService struct { + Options []option.RequestOption +} + +// NewSettingServerSideExcludeService 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 NewSettingServerSideExcludeService(opts ...option.RequestOption) (r *SettingServerSideExcludeService) { + r = &SettingServerSideExcludeService{} + r.Options = opts + return +} + +// If there is sensitive content on your website that you want visible to real +// visitors, but that you want to hide from suspicious visitors, all you have to do +// is wrap the content with Cloudflare SSE tags. Wrap any content that you want to +// be excluded from suspicious visitors in the following SSE tags: +// . For example: Bad visitors won't see my phone +// number, 555-555-5555 . Note: SSE only will work with HTML. If you +// have HTML minification enabled, you won't see the SSE tags in your HTML source +// when it's served through Cloudflare. SSE will still function in this case, as +// Cloudflare's HTML minification and SSE functionality occur on-the-fly as the +// resource moves through our network to the visitor's computer. +// (https://support.cloudflare.com/hc/en-us/articles/200170036). +func (r *SettingServerSideExcludeService) Edit(ctx context.Context, params SettingServerSideExcludeEditParams, opts ...option.RequestOption) (res *ZonesServerSideExclude, err error) { + opts = append(r.Options[:], opts...) + var env SettingServerSideExcludeEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/server_side_exclude", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// If there is sensitive content on your website that you want visible to real +// visitors, but that you want to hide from suspicious visitors, all you have to do +// is wrap the content with Cloudflare SSE tags. Wrap any content that you want to +// be excluded from suspicious visitors in the following SSE tags: +// . For example: Bad visitors won't see my phone +// number, 555-555-5555 . Note: SSE only will work with HTML. If you +// have HTML minification enabled, you won't see the SSE tags in your HTML source +// when it's served through Cloudflare. SSE will still function in this case, as +// Cloudflare's HTML minification and SSE functionality occur on-the-fly as the +// resource moves through our network to the visitor's computer. +// (https://support.cloudflare.com/hc/en-us/articles/200170036). +func (r *SettingServerSideExcludeService) Get(ctx context.Context, query SettingServerSideExcludeGetParams, opts ...option.RequestOption) (res *ZonesServerSideExclude, err error) { + opts = append(r.Options[:], opts...) + var env SettingServerSideExcludeGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/server_side_exclude", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// If there is sensitive content on your website that you want visible to real +// visitors, but that you want to hide from suspicious visitors, all you have to do +// is wrap the content with Cloudflare SSE tags. Wrap any content that you want to +// be excluded from suspicious visitors in the following SSE tags: +// . For example: Bad visitors won't see my phone +// number, 555-555-5555 . Note: SSE only will work with HTML. If you +// have HTML minification enabled, you won't see the SSE tags in your HTML source +// when it's served through Cloudflare. SSE will still function in this case, as +// Cloudflare's HTML minification and SSE functionality occur on-the-fly as the +// resource moves through our network to the visitor's computer. +// (https://support.cloudflare.com/hc/en-us/articles/200170036). +type ZonesServerSideExclude struct { + // ID of the zone setting. + ID ZonesServerSideExcludeID `json:"id,required"` + // Current value of the zone setting. + Value ZonesServerSideExcludeValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesServerSideExcludeEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesServerSideExcludeJSON `json:"-"` +} + +// zonesServerSideExcludeJSON contains the JSON metadata for the struct +// [ZonesServerSideExclude] +type zonesServerSideExcludeJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesServerSideExclude) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesServerSideExcludeJSON) RawJSON() string { + return r.raw +} + +func (r ZonesServerSideExclude) implementsZonesSettingEditResponse() {} + +func (r ZonesServerSideExclude) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesServerSideExcludeID string + +const ( + ZonesServerSideExcludeIDServerSideExclude ZonesServerSideExcludeID = "server_side_exclude" +) + +// Current value of the zone setting. +type ZonesServerSideExcludeValue string + +const ( + ZonesServerSideExcludeValueOn ZonesServerSideExcludeValue = "on" + ZonesServerSideExcludeValueOff ZonesServerSideExcludeValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesServerSideExcludeEditable bool + +const ( + ZonesServerSideExcludeEditableTrue ZonesServerSideExcludeEditable = true + ZonesServerSideExcludeEditableFalse ZonesServerSideExcludeEditable = false +) + +// If there is sensitive content on your website that you want visible to real +// visitors, but that you want to hide from suspicious visitors, all you have to do +// is wrap the content with Cloudflare SSE tags. Wrap any content that you want to +// be excluded from suspicious visitors in the following SSE tags: +// . For example: Bad visitors won't see my phone +// number, 555-555-5555 . Note: SSE only will work with HTML. If you +// have HTML minification enabled, you won't see the SSE tags in your HTML source +// when it's served through Cloudflare. SSE will still function in this case, as +// Cloudflare's HTML minification and SSE functionality occur on-the-fly as the +// resource moves through our network to the visitor's computer. +// (https://support.cloudflare.com/hc/en-us/articles/200170036). +type ZonesServerSideExcludeParam struct { + // ID of the zone setting. + ID param.Field[ZonesServerSideExcludeID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesServerSideExcludeValue] `json:"value,required"` +} + +func (r ZonesServerSideExcludeParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesServerSideExcludeParam) implementsZonesSettingEditParamsItem() {} + +type SettingServerSideExcludeEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingServerSideExcludeEditParamsValue] `json:"value,required"` +} + +func (r SettingServerSideExcludeEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingServerSideExcludeEditParamsValue string + +const ( + SettingServerSideExcludeEditParamsValueOn SettingServerSideExcludeEditParamsValue = "on" + SettingServerSideExcludeEditParamsValueOff SettingServerSideExcludeEditParamsValue = "off" +) + +type SettingServerSideExcludeEditResponseEnvelope struct { + Errors []SettingServerSideExcludeEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingServerSideExcludeEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // If there is sensitive content on your website that you want visible to real + // visitors, but that you want to hide from suspicious visitors, all you have to do + // is wrap the content with Cloudflare SSE tags. Wrap any content that you want to + // be excluded from suspicious visitors in the following SSE tags: + // . For example: Bad visitors won't see my phone + // number, 555-555-5555 . Note: SSE only will work with HTML. If you + // have HTML minification enabled, you won't see the SSE tags in your HTML source + // when it's served through Cloudflare. SSE will still function in this case, as + // Cloudflare's HTML minification and SSE functionality occur on-the-fly as the + // resource moves through our network to the visitor's computer. + // (https://support.cloudflare.com/hc/en-us/articles/200170036). + Result ZonesServerSideExclude `json:"result"` + JSON settingServerSideExcludeEditResponseEnvelopeJSON `json:"-"` +} + +// settingServerSideExcludeEditResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingServerSideExcludeEditResponseEnvelope] +type settingServerSideExcludeEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingServerSideExcludeEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingServerSideExcludeEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingServerSideExcludeEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingServerSideExcludeEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingServerSideExcludeEditResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [SettingServerSideExcludeEditResponseEnvelopeErrors] +type settingServerSideExcludeEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingServerSideExcludeEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingServerSideExcludeEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingServerSideExcludeEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingServerSideExcludeEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingServerSideExcludeEditResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingServerSideExcludeEditResponseEnvelopeMessages] +type settingServerSideExcludeEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingServerSideExcludeEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingServerSideExcludeEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingServerSideExcludeGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingServerSideExcludeGetResponseEnvelope struct { + Errors []SettingServerSideExcludeGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingServerSideExcludeGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // If there is sensitive content on your website that you want visible to real + // visitors, but that you want to hide from suspicious visitors, all you have to do + // is wrap the content with Cloudflare SSE tags. Wrap any content that you want to + // be excluded from suspicious visitors in the following SSE tags: + // . For example: Bad visitors won't see my phone + // number, 555-555-5555 . Note: SSE only will work with HTML. If you + // have HTML minification enabled, you won't see the SSE tags in your HTML source + // when it's served through Cloudflare. SSE will still function in this case, as + // Cloudflare's HTML minification and SSE functionality occur on-the-fly as the + // resource moves through our network to the visitor's computer. + // (https://support.cloudflare.com/hc/en-us/articles/200170036). + Result ZonesServerSideExclude `json:"result"` + JSON settingServerSideExcludeGetResponseEnvelopeJSON `json:"-"` +} + +// settingServerSideExcludeGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingServerSideExcludeGetResponseEnvelope] +type settingServerSideExcludeGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingServerSideExcludeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingServerSideExcludeGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingServerSideExcludeGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingServerSideExcludeGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingServerSideExcludeGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingServerSideExcludeGetResponseEnvelopeErrors] +type settingServerSideExcludeGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingServerSideExcludeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingServerSideExcludeGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingServerSideExcludeGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingServerSideExcludeGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingServerSideExcludeGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingServerSideExcludeGetResponseEnvelopeMessages] +type settingServerSideExcludeGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingServerSideExcludeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingServerSideExcludeGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingserversideexclude_test.go b/zones/settingserversideexclude_test.go new file mode 100644 index 00000000000..afd3ce0277b --- /dev/null +++ b/zones/settingserversideexclude_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingServerSideExcludeEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.ServerSideExcludes.Edit(context.TODO(), zones.SettingServerSideExcludeEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingServerSideExcludeEditParamsValueOn), + }) + 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 TestSettingServerSideExcludeGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.ServerSideExcludes.Get(context.TODO(), zones.SettingServerSideExcludeGetParams{ + ZoneID: cloudflare.F("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/zones/settingsortquerystringforcache.go b/zones/settingsortquerystringforcache.go new file mode 100644 index 00000000000..45aa8c75228 --- /dev/null +++ b/zones/settingsortquerystringforcache.go @@ -0,0 +1,324 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingSortQueryStringForCacheService 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 +// [NewSettingSortQueryStringForCacheService] method instead. +type SettingSortQueryStringForCacheService struct { + Options []option.RequestOption +} + +// NewSettingSortQueryStringForCacheService 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 NewSettingSortQueryStringForCacheService(opts ...option.RequestOption) (r *SettingSortQueryStringForCacheService) { + r = &SettingSortQueryStringForCacheService{} + r.Options = opts + return +} + +// Cloudflare will treat files with the same query strings as the same file in +// cache, regardless of the order of the query strings. This is limited to +// Enterprise Zones. +func (r *SettingSortQueryStringForCacheService) Edit(ctx context.Context, params SettingSortQueryStringForCacheEditParams, opts ...option.RequestOption) (res *ZonesSortQueryStringForCache, err error) { + opts = append(r.Options[:], opts...) + var env SettingSortQueryStringForCacheEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/sort_query_string_for_cache", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Cloudflare will treat files with the same query strings as the same file in +// cache, regardless of the order of the query strings. This is limited to +// Enterprise Zones. +func (r *SettingSortQueryStringForCacheService) Get(ctx context.Context, query SettingSortQueryStringForCacheGetParams, opts ...option.RequestOption) (res *ZonesSortQueryStringForCache, err error) { + opts = append(r.Options[:], opts...) + var env SettingSortQueryStringForCacheGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/sort_query_string_for_cache", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Cloudflare will treat files with the same query strings as the same file in +// cache, regardless of the order of the query strings. This is limited to +// Enterprise Zones. +type ZonesSortQueryStringForCache struct { + // ID of the zone setting. + ID ZonesSortQueryStringForCacheID `json:"id,required"` + // Current value of the zone setting. + Value ZonesSortQueryStringForCacheValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesSortQueryStringForCacheEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesSortQueryStringForCacheJSON `json:"-"` +} + +// zonesSortQueryStringForCacheJSON contains the JSON metadata for the struct +// [ZonesSortQueryStringForCache] +type zonesSortQueryStringForCacheJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesSortQueryStringForCache) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesSortQueryStringForCacheJSON) RawJSON() string { + return r.raw +} + +func (r ZonesSortQueryStringForCache) implementsZonesSettingEditResponse() {} + +func (r ZonesSortQueryStringForCache) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesSortQueryStringForCacheID string + +const ( + ZonesSortQueryStringForCacheIDSortQueryStringForCache ZonesSortQueryStringForCacheID = "sort_query_string_for_cache" +) + +// Current value of the zone setting. +type ZonesSortQueryStringForCacheValue string + +const ( + ZonesSortQueryStringForCacheValueOn ZonesSortQueryStringForCacheValue = "on" + ZonesSortQueryStringForCacheValueOff ZonesSortQueryStringForCacheValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesSortQueryStringForCacheEditable bool + +const ( + ZonesSortQueryStringForCacheEditableTrue ZonesSortQueryStringForCacheEditable = true + ZonesSortQueryStringForCacheEditableFalse ZonesSortQueryStringForCacheEditable = false +) + +// Cloudflare will treat files with the same query strings as the same file in +// cache, regardless of the order of the query strings. This is limited to +// Enterprise Zones. +type ZonesSortQueryStringForCacheParam struct { + // ID of the zone setting. + ID param.Field[ZonesSortQueryStringForCacheID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesSortQueryStringForCacheValue] `json:"value,required"` +} + +func (r ZonesSortQueryStringForCacheParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesSortQueryStringForCacheParam) implementsZonesSettingEditParamsItem() {} + +type SettingSortQueryStringForCacheEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingSortQueryStringForCacheEditParamsValue] `json:"value,required"` +} + +func (r SettingSortQueryStringForCacheEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingSortQueryStringForCacheEditParamsValue string + +const ( + SettingSortQueryStringForCacheEditParamsValueOn SettingSortQueryStringForCacheEditParamsValue = "on" + SettingSortQueryStringForCacheEditParamsValueOff SettingSortQueryStringForCacheEditParamsValue = "off" +) + +type SettingSortQueryStringForCacheEditResponseEnvelope struct { + Errors []SettingSortQueryStringForCacheEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingSortQueryStringForCacheEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Cloudflare will treat files with the same query strings as the same file in + // cache, regardless of the order of the query strings. This is limited to + // Enterprise Zones. + Result ZonesSortQueryStringForCache `json:"result"` + JSON settingSortQueryStringForCacheEditResponseEnvelopeJSON `json:"-"` +} + +// settingSortQueryStringForCacheEditResponseEnvelopeJSON contains the JSON +// metadata for the struct [SettingSortQueryStringForCacheEditResponseEnvelope] +type settingSortQueryStringForCacheEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSortQueryStringForCacheEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSortQueryStringForCacheEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingSortQueryStringForCacheEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSortQueryStringForCacheEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingSortQueryStringForCacheEditResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct +// [SettingSortQueryStringForCacheEditResponseEnvelopeErrors] +type settingSortQueryStringForCacheEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSortQueryStringForCacheEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSortQueryStringForCacheEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingSortQueryStringForCacheEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSortQueryStringForCacheEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingSortQueryStringForCacheEditResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct +// [SettingSortQueryStringForCacheEditResponseEnvelopeMessages] +type settingSortQueryStringForCacheEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSortQueryStringForCacheEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSortQueryStringForCacheEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingSortQueryStringForCacheGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingSortQueryStringForCacheGetResponseEnvelope struct { + Errors []SettingSortQueryStringForCacheGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingSortQueryStringForCacheGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Cloudflare will treat files with the same query strings as the same file in + // cache, regardless of the order of the query strings. This is limited to + // Enterprise Zones. + Result ZonesSortQueryStringForCache `json:"result"` + JSON settingSortQueryStringForCacheGetResponseEnvelopeJSON `json:"-"` +} + +// settingSortQueryStringForCacheGetResponseEnvelopeJSON contains the JSON metadata +// for the struct [SettingSortQueryStringForCacheGetResponseEnvelope] +type settingSortQueryStringForCacheGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSortQueryStringForCacheGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSortQueryStringForCacheGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingSortQueryStringForCacheGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSortQueryStringForCacheGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingSortQueryStringForCacheGetResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct +// [SettingSortQueryStringForCacheGetResponseEnvelopeErrors] +type settingSortQueryStringForCacheGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSortQueryStringForCacheGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSortQueryStringForCacheGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingSortQueryStringForCacheGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSortQueryStringForCacheGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingSortQueryStringForCacheGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct +// [SettingSortQueryStringForCacheGetResponseEnvelopeMessages] +type settingSortQueryStringForCacheGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSortQueryStringForCacheGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSortQueryStringForCacheGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingsortquerystringforcache_test.go b/zones/settingsortquerystringforcache_test.go new file mode 100644 index 00000000000..05bc26cc53b --- /dev/null +++ b/zones/settingsortquerystringforcache_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingSortQueryStringForCacheEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.SortQueryStringForCache.Edit(context.TODO(), zones.SettingSortQueryStringForCacheEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingSortQueryStringForCacheEditParamsValueOn), + }) + 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 TestSettingSortQueryStringForCacheGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.SortQueryStringForCache.Get(context.TODO(), zones.SettingSortQueryStringForCacheGetParams{ + ZoneID: cloudflare.F("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/zones/settingssl.go b/zones/settingssl.go new file mode 100644 index 00000000000..1e1ec72b8cb --- /dev/null +++ b/zones/settingssl.go @@ -0,0 +1,400 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingSSLService 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 [NewSettingSSLService] method instead. +type SettingSSLService struct { + Options []option.RequestOption +} + +// NewSettingSSLService 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 NewSettingSSLService(opts ...option.RequestOption) (r *SettingSSLService) { + r = &SettingSSLService{} + r.Options = opts + return +} + +// SSL encrypts your visitor's connection and safeguards credit card numbers and +// other personal data to and from your website. SSL can take up to 5 minutes to +// fully activate. Requires Cloudflare active on your root domain or www domain. +// Off: no SSL between the visitor and Cloudflare, and no SSL between Cloudflare +// and your web server (all HTTP traffic). Flexible: SSL between the visitor and +// Cloudflare -- visitor sees HTTPS on your site, but no SSL between Cloudflare and +// your web server. You don't need to have an SSL cert on your web server, but your +// vistors will still see the site as being HTTPS enabled. Full: SSL between the +// visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between +// Cloudflare and your web server. You'll need to have your own SSL cert or +// self-signed cert at the very least. Full (Strict): SSL between the visitor and +// Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and +// your web server. You'll need to have a valid SSL certificate installed on your +// web server. This certificate must be signed by a certificate authority, have an +// expiration date in the future, and respond for the request domain name +// (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). +func (r *SettingSSLService) Edit(ctx context.Context, params SettingSSLEditParams, opts ...option.RequestOption) (res *ZonesSSL, err error) { + opts = append(r.Options[:], opts...) + var env SettingSSLEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/ssl", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// SSL encrypts your visitor's connection and safeguards credit card numbers and +// other personal data to and from your website. SSL can take up to 5 minutes to +// fully activate. Requires Cloudflare active on your root domain or www domain. +// Off: no SSL between the visitor and Cloudflare, and no SSL between Cloudflare +// and your web server (all HTTP traffic). Flexible: SSL between the visitor and +// Cloudflare -- visitor sees HTTPS on your site, but no SSL between Cloudflare and +// your web server. You don't need to have an SSL cert on your web server, but your +// vistors will still see the site as being HTTPS enabled. Full: SSL between the +// visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between +// Cloudflare and your web server. You'll need to have your own SSL cert or +// self-signed cert at the very least. Full (Strict): SSL between the visitor and +// Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and +// your web server. You'll need to have a valid SSL certificate installed on your +// web server. This certificate must be signed by a certificate authority, have an +// expiration date in the future, and respond for the request domain name +// (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). +func (r *SettingSSLService) Get(ctx context.Context, query SettingSSLGetParams, opts ...option.RequestOption) (res *ZonesSSL, err error) { + opts = append(r.Options[:], opts...) + var env SettingSSLGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/ssl", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// SSL encrypts your visitor's connection and safeguards credit card numbers and +// other personal data to and from your website. SSL can take up to 5 minutes to +// fully activate. Requires Cloudflare active on your root domain or www domain. +// Off: no SSL between the visitor and Cloudflare, and no SSL between Cloudflare +// and your web server (all HTTP traffic). Flexible: SSL between the visitor and +// Cloudflare -- visitor sees HTTPS on your site, but no SSL between Cloudflare and +// your web server. You don't need to have an SSL cert on your web server, but your +// vistors will still see the site as being HTTPS enabled. Full: SSL between the +// visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between +// Cloudflare and your web server. You'll need to have your own SSL cert or +// self-signed cert at the very least. Full (Strict): SSL between the visitor and +// Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and +// your web server. You'll need to have a valid SSL certificate installed on your +// web server. This certificate must be signed by a certificate authority, have an +// expiration date in the future, and respond for the request domain name +// (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). +type ZonesSSL struct { + // ID of the zone setting. + ID ZonesSSLID `json:"id,required"` + // Current value of the zone setting. + Value ZonesSSLValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesSSLEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesSSLJSON `json:"-"` +} + +// zonesSSLJSON contains the JSON metadata for the struct [ZonesSSL] +type zonesSSLJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesSSL) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesSSLJSON) RawJSON() string { + return r.raw +} + +func (r ZonesSSL) implementsZonesSettingEditResponse() {} + +func (r ZonesSSL) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesSSLID string + +const ( + ZonesSSLIDSSL ZonesSSLID = "ssl" +) + +// Current value of the zone setting. +type ZonesSSLValue string + +const ( + ZonesSSLValueOff ZonesSSLValue = "off" + ZonesSSLValueFlexible ZonesSSLValue = "flexible" + ZonesSSLValueFull ZonesSSLValue = "full" + ZonesSSLValueStrict ZonesSSLValue = "strict" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesSSLEditable bool + +const ( + ZonesSSLEditableTrue ZonesSSLEditable = true + ZonesSSLEditableFalse ZonesSSLEditable = false +) + +// SSL encrypts your visitor's connection and safeguards credit card numbers and +// other personal data to and from your website. SSL can take up to 5 minutes to +// fully activate. Requires Cloudflare active on your root domain or www domain. +// Off: no SSL between the visitor and Cloudflare, and no SSL between Cloudflare +// and your web server (all HTTP traffic). Flexible: SSL between the visitor and +// Cloudflare -- visitor sees HTTPS on your site, but no SSL between Cloudflare and +// your web server. You don't need to have an SSL cert on your web server, but your +// vistors will still see the site as being HTTPS enabled. Full: SSL between the +// visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between +// Cloudflare and your web server. You'll need to have your own SSL cert or +// self-signed cert at the very least. Full (Strict): SSL between the visitor and +// Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and +// your web server. You'll need to have a valid SSL certificate installed on your +// web server. This certificate must be signed by a certificate authority, have an +// expiration date in the future, and respond for the request domain name +// (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). +type ZonesSSLParam struct { + // ID of the zone setting. + ID param.Field[ZonesSSLID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesSSLValue] `json:"value,required"` +} + +func (r ZonesSSLParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesSSLParam) implementsZonesSettingEditParamsItem() {} + +type SettingSSLEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. Notes: Depends on the zone's plan level + Value param.Field[SettingSSLEditParamsValue] `json:"value,required"` +} + +func (r SettingSSLEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. Notes: Depends on the zone's plan level +type SettingSSLEditParamsValue string + +const ( + SettingSSLEditParamsValueOff SettingSSLEditParamsValue = "off" + SettingSSLEditParamsValueFlexible SettingSSLEditParamsValue = "flexible" + SettingSSLEditParamsValueFull SettingSSLEditParamsValue = "full" + SettingSSLEditParamsValueStrict SettingSSLEditParamsValue = "strict" +) + +type SettingSSLEditResponseEnvelope struct { + Errors []SettingSSLEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingSSLEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // SSL encrypts your visitor's connection and safeguards credit card numbers and + // other personal data to and from your website. SSL can take up to 5 minutes to + // fully activate. Requires Cloudflare active on your root domain or www domain. + // Off: no SSL between the visitor and Cloudflare, and no SSL between Cloudflare + // and your web server (all HTTP traffic). Flexible: SSL between the visitor and + // Cloudflare -- visitor sees HTTPS on your site, but no SSL between Cloudflare and + // your web server. You don't need to have an SSL cert on your web server, but your + // vistors will still see the site as being HTTPS enabled. Full: SSL between the + // visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between + // Cloudflare and your web server. You'll need to have your own SSL cert or + // self-signed cert at the very least. Full (Strict): SSL between the visitor and + // Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and + // your web server. You'll need to have a valid SSL certificate installed on your + // web server. This certificate must be signed by a certificate authority, have an + // expiration date in the future, and respond for the request domain name + // (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). + Result ZonesSSL `json:"result"` + JSON settingSSLEditResponseEnvelopeJSON `json:"-"` +} + +// settingSSLEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingSSLEditResponseEnvelope] +type settingSSLEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSSLEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSSLEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingSSLEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSSLEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingSSLEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingSSLEditResponseEnvelopeErrors] +type settingSSLEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSSLEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSSLEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingSSLEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSSLEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingSSLEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingSSLEditResponseEnvelopeMessages] +type settingSSLEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSSLEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSSLEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingSSLGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingSSLGetResponseEnvelope struct { + Errors []SettingSSLGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingSSLGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // SSL encrypts your visitor's connection and safeguards credit card numbers and + // other personal data to and from your website. SSL can take up to 5 minutes to + // fully activate. Requires Cloudflare active on your root domain or www domain. + // Off: no SSL between the visitor and Cloudflare, and no SSL between Cloudflare + // and your web server (all HTTP traffic). Flexible: SSL between the visitor and + // Cloudflare -- visitor sees HTTPS on your site, but no SSL between Cloudflare and + // your web server. You don't need to have an SSL cert on your web server, but your + // vistors will still see the site as being HTTPS enabled. Full: SSL between the + // visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between + // Cloudflare and your web server. You'll need to have your own SSL cert or + // self-signed cert at the very least. Full (Strict): SSL between the visitor and + // Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and + // your web server. You'll need to have a valid SSL certificate installed on your + // web server. This certificate must be signed by a certificate authority, have an + // expiration date in the future, and respond for the request domain name + // (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). + Result ZonesSSL `json:"result"` + JSON settingSSLGetResponseEnvelopeJSON `json:"-"` +} + +// settingSSLGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingSSLGetResponseEnvelope] +type settingSSLGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSSLGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSSLGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingSSLGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSSLGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingSSLGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingSSLGetResponseEnvelopeErrors] +type settingSSLGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSSLGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSSLGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingSSLGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSSLGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingSSLGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingSSLGetResponseEnvelopeMessages] +type settingSSLGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSSLGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSSLGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingssl_test.go b/zones/settingssl_test.go new file mode 100644 index 00000000000..cc0234ef0bc --- /dev/null +++ b/zones/settingssl_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingSSLEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.SSL.Edit(context.TODO(), zones.SettingSSLEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingSSLEditParamsValueOff), + }) + 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 TestSettingSSLGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.SSL.Get(context.TODO(), zones.SettingSSLGetParams{ + ZoneID: cloudflare.F("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/zones/settingsslrecommender.go b/zones/settingsslrecommender.go new file mode 100644 index 00000000000..4e49ad97b5d --- /dev/null +++ b/zones/settingsslrecommender.go @@ -0,0 +1,289 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingSSLRecommenderService 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 [NewSettingSSLRecommenderService] +// method instead. +type SettingSSLRecommenderService struct { + Options []option.RequestOption +} + +// NewSettingSSLRecommenderService 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 NewSettingSSLRecommenderService(opts ...option.RequestOption) (r *SettingSSLRecommenderService) { + r = &SettingSSLRecommenderService{} + r.Options = opts + return +} + +// Enrollment in the SSL/TLS Recommender service which tries to detect and +// recommend (by sending periodic emails) the most secure SSL/TLS setting your +// origin servers support. +func (r *SettingSSLRecommenderService) Edit(ctx context.Context, params SettingSSLRecommenderEditParams, opts ...option.RequestOption) (res *ZonesSSLRecommender, err error) { + opts = append(r.Options[:], opts...) + var env SettingSSLRecommenderEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/ssl_recommender", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Enrollment in the SSL/TLS Recommender service which tries to detect and +// recommend (by sending periodic emails) the most secure SSL/TLS setting your +// origin servers support. +func (r *SettingSSLRecommenderService) Get(ctx context.Context, query SettingSSLRecommenderGetParams, opts ...option.RequestOption) (res *ZonesSSLRecommender, err error) { + opts = append(r.Options[:], opts...) + var env SettingSSLRecommenderGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/ssl_recommender", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Enrollment in the SSL/TLS Recommender service which tries to detect and +// recommend (by sending periodic emails) the most secure SSL/TLS setting your +// origin servers support. +type ZonesSSLRecommender struct { + // Enrollment value for SSL/TLS Recommender. + ID ZonesSSLRecommenderID `json:"id"` + // ssl-recommender enrollment setting. + Enabled bool `json:"enabled"` + JSON zonesSSLRecommenderJSON `json:"-"` +} + +// zonesSSLRecommenderJSON contains the JSON metadata for the struct +// [ZonesSSLRecommender] +type zonesSSLRecommenderJSON struct { + ID apijson.Field + Enabled apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesSSLRecommender) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesSSLRecommenderJSON) RawJSON() string { + return r.raw +} + +func (r ZonesSSLRecommender) implementsZonesSettingEditResponse() {} + +func (r ZonesSSLRecommender) implementsZonesSettingGetResponse() {} + +// Enrollment value for SSL/TLS Recommender. +type ZonesSSLRecommenderID string + +const ( + ZonesSSLRecommenderIDSSLRecommender ZonesSSLRecommenderID = "ssl_recommender" +) + +// Enrollment in the SSL/TLS Recommender service which tries to detect and +// recommend (by sending periodic emails) the most secure SSL/TLS setting your +// origin servers support. +type ZonesSSLRecommenderParam struct { + // Enrollment value for SSL/TLS Recommender. + ID param.Field[ZonesSSLRecommenderID] `json:"id"` + // ssl-recommender enrollment setting. + Enabled param.Field[bool] `json:"enabled"` +} + +func (r ZonesSSLRecommenderParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesSSLRecommenderParam) implementsZonesSettingEditParamsItem() {} + +type SettingSSLRecommenderEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Enrollment in the SSL/TLS Recommender service which tries to detect and + // recommend (by sending periodic emails) the most secure SSL/TLS setting your + // origin servers support. + Value param.Field[ZonesSSLRecommenderParam] `json:"value,required"` +} + +func (r SettingSSLRecommenderEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SettingSSLRecommenderEditResponseEnvelope struct { + Errors []SettingSSLRecommenderEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingSSLRecommenderEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Enrollment in the SSL/TLS Recommender service which tries to detect and + // recommend (by sending periodic emails) the most secure SSL/TLS setting your + // origin servers support. + Result ZonesSSLRecommender `json:"result"` + JSON settingSSLRecommenderEditResponseEnvelopeJSON `json:"-"` +} + +// settingSSLRecommenderEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingSSLRecommenderEditResponseEnvelope] +type settingSSLRecommenderEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSSLRecommenderEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSSLRecommenderEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingSSLRecommenderEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSSLRecommenderEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingSSLRecommenderEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingSSLRecommenderEditResponseEnvelopeErrors] +type settingSSLRecommenderEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSSLRecommenderEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSSLRecommenderEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingSSLRecommenderEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSSLRecommenderEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingSSLRecommenderEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingSSLRecommenderEditResponseEnvelopeMessages] +type settingSSLRecommenderEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSSLRecommenderEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSSLRecommenderEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingSSLRecommenderGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingSSLRecommenderGetResponseEnvelope struct { + Errors []SettingSSLRecommenderGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingSSLRecommenderGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Enrollment in the SSL/TLS Recommender service which tries to detect and + // recommend (by sending periodic emails) the most secure SSL/TLS setting your + // origin servers support. + Result ZonesSSLRecommender `json:"result"` + JSON settingSSLRecommenderGetResponseEnvelopeJSON `json:"-"` +} + +// settingSSLRecommenderGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingSSLRecommenderGetResponseEnvelope] +type settingSSLRecommenderGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSSLRecommenderGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSSLRecommenderGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingSSLRecommenderGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSSLRecommenderGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingSSLRecommenderGetResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingSSLRecommenderGetResponseEnvelopeErrors] +type settingSSLRecommenderGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSSLRecommenderGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSSLRecommenderGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingSSLRecommenderGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingSSLRecommenderGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingSSLRecommenderGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingSSLRecommenderGetResponseEnvelopeMessages] +type settingSSLRecommenderGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingSSLRecommenderGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingSSLRecommenderGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingsslrecommender_test.go b/zones/settingsslrecommender_test.go new file mode 100644 index 00000000000..28a30a505e5 --- /dev/null +++ b/zones/settingsslrecommender_test.go @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingSSLRecommenderEditWithOptionalParams(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("user@example.com"), + ) + _, err := client.Zones.Settings.SSLRecommender.Edit(context.TODO(), zones.SettingSSLRecommenderEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.ZonesSSLRecommenderParam{ + Enabled: cloudflare.F(true), + ID: cloudflare.F(zones.ZonesSSLRecommenderIDSSLRecommender), + }), + }) + 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 TestSettingSSLRecommenderGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.SSLRecommender.Get(context.TODO(), zones.SettingSSLRecommenderGetParams{ + ZoneID: cloudflare.F("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/zones/settingtls13.go b/zones/settingtls13.go new file mode 100644 index 00000000000..d9ffb88530f --- /dev/null +++ b/zones/settingtls13.go @@ -0,0 +1,311 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingTLS1_3Service 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 [NewSettingTLS1_3Service] method +// instead. +type SettingTLS1_3Service struct { + Options []option.RequestOption +} + +// NewSettingTLS1_3Service 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 NewSettingTLS1_3Service(opts ...option.RequestOption) (r *SettingTLS1_3Service) { + r = &SettingTLS1_3Service{} + r.Options = opts + return +} + +// Changes TLS 1.3 setting. +func (r *SettingTLS1_3Service) Edit(ctx context.Context, params SettingTLS1_3EditParams, opts ...option.RequestOption) (res *ZonesTLS1_3, err error) { + opts = append(r.Options[:], opts...) + var env SettingTls1_3EditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/tls_1_3", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets TLS 1.3 setting enabled for a zone. +func (r *SettingTLS1_3Service) Get(ctx context.Context, query SettingTLS1_3GetParams, opts ...option.RequestOption) (res *ZonesTLS1_3, err error) { + opts = append(r.Options[:], opts...) + var env SettingTls1_3GetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/tls_1_3", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Enables Crypto TLS 1.3 feature for a zone. +type ZonesTLS1_3 struct { + // ID of the zone setting. + ID ZonesTLS1_3ID `json:"id,required"` + // Current value of the zone setting. + Value ZonesTLS1_3Value `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesTLS1_3Editable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesTls1_3JSON `json:"-"` +} + +// zonesTls1_3JSON contains the JSON metadata for the struct [ZonesTLS1_3] +type zonesTls1_3JSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesTLS1_3) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesTls1_3JSON) RawJSON() string { + return r.raw +} + +func (r ZonesTLS1_3) implementsZonesSettingEditResponse() {} + +func (r ZonesTLS1_3) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesTLS1_3ID string + +const ( + ZonesTLS1_3IDTLS1_3 ZonesTLS1_3ID = "tls_1_3" +) + +// Current value of the zone setting. +type ZonesTLS1_3Value string + +const ( + ZonesTLS1_3ValueOn ZonesTLS1_3Value = "on" + ZonesTLS1_3ValueOff ZonesTLS1_3Value = "off" + ZonesTLS1_3ValueZrt ZonesTLS1_3Value = "zrt" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesTLS1_3Editable bool + +const ( + ZonesTLS1_3EditableTrue ZonesTLS1_3Editable = true + ZonesTLS1_3EditableFalse ZonesTLS1_3Editable = false +) + +// Enables Crypto TLS 1.3 feature for a zone. +type ZonesTLS1_3Param struct { + // ID of the zone setting. + ID param.Field[ZonesTLS1_3ID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesTLS1_3Value] `json:"value,required"` +} + +func (r ZonesTLS1_3Param) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesTLS1_3Param) implementsZonesSettingEditParamsItem() {} + +type SettingTLS1_3EditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. Notes: Default value depends on the zone's plan + // level. + Value param.Field[SettingTls1_3EditParamsValue] `json:"value,required"` +} + +func (r SettingTLS1_3EditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. Notes: Default value depends on the zone's plan +// level. +type SettingTls1_3EditParamsValue string + +const ( + SettingTls1_3EditParamsValueOn SettingTls1_3EditParamsValue = "on" + SettingTls1_3EditParamsValueOff SettingTls1_3EditParamsValue = "off" + SettingTls1_3EditParamsValueZrt SettingTls1_3EditParamsValue = "zrt" +) + +type SettingTls1_3EditResponseEnvelope struct { + Errors []SettingTls1_3EditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingTls1_3EditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Enables Crypto TLS 1.3 feature for a zone. + Result ZonesTLS1_3 `json:"result"` + JSON settingTls1_3EditResponseEnvelopeJSON `json:"-"` +} + +// settingTls1_3EditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingTls1_3EditResponseEnvelope] +type settingTls1_3EditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTls1_3EditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTls1_3EditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingTls1_3EditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingTls1_3EditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingTls1_3EditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingTls1_3EditResponseEnvelopeErrors] +type settingTls1_3EditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTls1_3EditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTls1_3EditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingTls1_3EditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingTls1_3EditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingTls1_3EditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingTls1_3EditResponseEnvelopeMessages] +type settingTls1_3EditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTls1_3EditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTls1_3EditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingTLS1_3GetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingTls1_3GetResponseEnvelope struct { + Errors []SettingTls1_3GetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingTls1_3GetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Enables Crypto TLS 1.3 feature for a zone. + Result ZonesTLS1_3 `json:"result"` + JSON settingTls1_3GetResponseEnvelopeJSON `json:"-"` +} + +// settingTls1_3GetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingTls1_3GetResponseEnvelope] +type settingTls1_3GetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTls1_3GetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTls1_3GetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingTls1_3GetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingTls1_3GetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingTls1_3GetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingTls1_3GetResponseEnvelopeErrors] +type settingTls1_3GetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTls1_3GetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTls1_3GetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingTls1_3GetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingTls1_3GetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingTls1_3GetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingTls1_3GetResponseEnvelopeMessages] +type settingTls1_3GetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTls1_3GetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTls1_3GetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingtls13_test.go b/zones/settingtls13_test.go new file mode 100644 index 00000000000..501c2d53261 --- /dev/null +++ b/zones/settingtls13_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingTLS1_3Edit(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("user@example.com"), + ) + _, err := client.Zones.Settings.TLS1_3.Edit(context.TODO(), zones.SettingTLS1_3EditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingTls1_3EditParamsValueOn), + }) + 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 TestSettingTLS1_3Get(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("user@example.com"), + ) + _, err := client.Zones.Settings.TLS1_3.Get(context.TODO(), zones.SettingTLS1_3GetParams{ + ZoneID: cloudflare.F("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/zones/settingtlsclientauth.go b/zones/settingtlsclientauth.go new file mode 100644 index 00000000000..b59208f1909 --- /dev/null +++ b/zones/settingtlsclientauth.go @@ -0,0 +1,314 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingTLSClientAuthService 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 [NewSettingTLSClientAuthService] +// method instead. +type SettingTLSClientAuthService struct { + Options []option.RequestOption +} + +// NewSettingTLSClientAuthService 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 NewSettingTLSClientAuthService(opts ...option.RequestOption) (r *SettingTLSClientAuthService) { + r = &SettingTLSClientAuthService{} + r.Options = opts + return +} + +// TLS Client Auth requires Cloudflare to connect to your origin server using a +// client certificate (Enterprise Only). +func (r *SettingTLSClientAuthService) Edit(ctx context.Context, params SettingTLSClientAuthEditParams, opts ...option.RequestOption) (res *ZonesTLSClientAuth, err error) { + opts = append(r.Options[:], opts...) + var env SettingTLSClientAuthEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/tls_client_auth", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// TLS Client Auth requires Cloudflare to connect to your origin server using a +// client certificate (Enterprise Only). +func (r *SettingTLSClientAuthService) Get(ctx context.Context, query SettingTLSClientAuthGetParams, opts ...option.RequestOption) (res *ZonesTLSClientAuth, err error) { + opts = append(r.Options[:], opts...) + var env SettingTLSClientAuthGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/tls_client_auth", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// TLS Client Auth requires Cloudflare to connect to your origin server using a +// client certificate (Enterprise Only). +type ZonesTLSClientAuth struct { + // ID of the zone setting. + ID ZonesTLSClientAuthID `json:"id,required"` + // Current value of the zone setting. + Value ZonesTLSClientAuthValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesTLSClientAuthEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesTLSClientAuthJSON `json:"-"` +} + +// zonesTLSClientAuthJSON contains the JSON metadata for the struct +// [ZonesTLSClientAuth] +type zonesTLSClientAuthJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesTLSClientAuth) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesTLSClientAuthJSON) RawJSON() string { + return r.raw +} + +func (r ZonesTLSClientAuth) implementsZonesSettingEditResponse() {} + +func (r ZonesTLSClientAuth) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesTLSClientAuthID string + +const ( + ZonesTLSClientAuthIDTLSClientAuth ZonesTLSClientAuthID = "tls_client_auth" +) + +// Current value of the zone setting. +type ZonesTLSClientAuthValue string + +const ( + ZonesTLSClientAuthValueOn ZonesTLSClientAuthValue = "on" + ZonesTLSClientAuthValueOff ZonesTLSClientAuthValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesTLSClientAuthEditable bool + +const ( + ZonesTLSClientAuthEditableTrue ZonesTLSClientAuthEditable = true + ZonesTLSClientAuthEditableFalse ZonesTLSClientAuthEditable = false +) + +// TLS Client Auth requires Cloudflare to connect to your origin server using a +// client certificate (Enterprise Only). +type ZonesTLSClientAuthParam struct { + // ID of the zone setting. + ID param.Field[ZonesTLSClientAuthID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesTLSClientAuthValue] `json:"value,required"` +} + +func (r ZonesTLSClientAuthParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesTLSClientAuthParam) implementsZonesSettingEditParamsItem() {} + +type SettingTLSClientAuthEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // value of the zone setting. + Value param.Field[SettingTLSClientAuthEditParamsValue] `json:"value,required"` +} + +func (r SettingTLSClientAuthEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// value of the zone setting. +type SettingTLSClientAuthEditParamsValue string + +const ( + SettingTLSClientAuthEditParamsValueOn SettingTLSClientAuthEditParamsValue = "on" + SettingTLSClientAuthEditParamsValueOff SettingTLSClientAuthEditParamsValue = "off" +) + +type SettingTLSClientAuthEditResponseEnvelope struct { + Errors []SettingTLSClientAuthEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingTLSClientAuthEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // TLS Client Auth requires Cloudflare to connect to your origin server using a + // client certificate (Enterprise Only). + Result ZonesTLSClientAuth `json:"result"` + JSON settingTLSClientAuthEditResponseEnvelopeJSON `json:"-"` +} + +// settingTLSClientAuthEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingTLSClientAuthEditResponseEnvelope] +type settingTLSClientAuthEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTLSClientAuthEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTLSClientAuthEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingTLSClientAuthEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingTLSClientAuthEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingTLSClientAuthEditResponseEnvelopeErrorsJSON contains the JSON metadata +// for the struct [SettingTLSClientAuthEditResponseEnvelopeErrors] +type settingTLSClientAuthEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTLSClientAuthEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTLSClientAuthEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingTLSClientAuthEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingTLSClientAuthEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingTLSClientAuthEditResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingTLSClientAuthEditResponseEnvelopeMessages] +type settingTLSClientAuthEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTLSClientAuthEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTLSClientAuthEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingTLSClientAuthGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingTLSClientAuthGetResponseEnvelope struct { + Errors []SettingTLSClientAuthGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingTLSClientAuthGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // TLS Client Auth requires Cloudflare to connect to your origin server using a + // client certificate (Enterprise Only). + Result ZonesTLSClientAuth `json:"result"` + JSON settingTLSClientAuthGetResponseEnvelopeJSON `json:"-"` +} + +// settingTLSClientAuthGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingTLSClientAuthGetResponseEnvelope] +type settingTLSClientAuthGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTLSClientAuthGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTLSClientAuthGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingTLSClientAuthGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingTLSClientAuthGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingTLSClientAuthGetResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingTLSClientAuthGetResponseEnvelopeErrors] +type settingTLSClientAuthGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTLSClientAuthGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTLSClientAuthGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingTLSClientAuthGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingTLSClientAuthGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingTLSClientAuthGetResponseEnvelopeMessagesJSON contains the JSON metadata +// for the struct [SettingTLSClientAuthGetResponseEnvelopeMessages] +type settingTLSClientAuthGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTLSClientAuthGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTLSClientAuthGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingtlsclientauth_test.go b/zones/settingtlsclientauth_test.go new file mode 100644 index 00000000000..9dcd781a5de --- /dev/null +++ b/zones/settingtlsclientauth_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingTLSClientAuthEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.TLSClientAuth.Edit(context.TODO(), zones.SettingTLSClientAuthEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingTLSClientAuthEditParamsValueOn), + }) + 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 TestSettingTLSClientAuthGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.TLSClientAuth.Get(context.TODO(), zones.SettingTLSClientAuthGetParams{ + ZoneID: cloudflare.F("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/zones/settingtrueclientipheader.go b/zones/settingtrueclientipheader.go new file mode 100644 index 00000000000..c3b5486585f --- /dev/null +++ b/zones/settingtrueclientipheader.go @@ -0,0 +1,314 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingTrueClientIPHeaderService 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 +// [NewSettingTrueClientIPHeaderService] method instead. +type SettingTrueClientIPHeaderService struct { + Options []option.RequestOption +} + +// NewSettingTrueClientIPHeaderService 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 NewSettingTrueClientIPHeaderService(opts ...option.RequestOption) (r *SettingTrueClientIPHeaderService) { + r = &SettingTrueClientIPHeaderService{} + r.Options = opts + return +} + +// Allows customer to continue to use True Client IP (Akamai feature) in the +// headers we send to the origin. This is limited to Enterprise Zones. +func (r *SettingTrueClientIPHeaderService) Edit(ctx context.Context, params SettingTrueClientIPHeaderEditParams, opts ...option.RequestOption) (res *ZonesTrueClientIPHeader, err error) { + opts = append(r.Options[:], opts...) + var env SettingTrueClientIPHeaderEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/true_client_ip_header", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Allows customer to continue to use True Client IP (Akamai feature) in the +// headers we send to the origin. This is limited to Enterprise Zones. +func (r *SettingTrueClientIPHeaderService) Get(ctx context.Context, query SettingTrueClientIPHeaderGetParams, opts ...option.RequestOption) (res *ZonesTrueClientIPHeader, err error) { + opts = append(r.Options[:], opts...) + var env SettingTrueClientIPHeaderGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/true_client_ip_header", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Allows customer to continue to use True Client IP (Akamai feature) in the +// headers we send to the origin. This is limited to Enterprise Zones. +type ZonesTrueClientIPHeader struct { + // ID of the zone setting. + ID ZonesTrueClientIPHeaderID `json:"id,required"` + // Current value of the zone setting. + Value ZonesTrueClientIPHeaderValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesTrueClientIPHeaderEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesTrueClientIPHeaderJSON `json:"-"` +} + +// zonesTrueClientIPHeaderJSON contains the JSON metadata for the struct +// [ZonesTrueClientIPHeader] +type zonesTrueClientIPHeaderJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesTrueClientIPHeader) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesTrueClientIPHeaderJSON) RawJSON() string { + return r.raw +} + +func (r ZonesTrueClientIPHeader) implementsZonesSettingEditResponse() {} + +func (r ZonesTrueClientIPHeader) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesTrueClientIPHeaderID string + +const ( + ZonesTrueClientIPHeaderIDTrueClientIPHeader ZonesTrueClientIPHeaderID = "true_client_ip_header" +) + +// Current value of the zone setting. +type ZonesTrueClientIPHeaderValue string + +const ( + ZonesTrueClientIPHeaderValueOn ZonesTrueClientIPHeaderValue = "on" + ZonesTrueClientIPHeaderValueOff ZonesTrueClientIPHeaderValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesTrueClientIPHeaderEditable bool + +const ( + ZonesTrueClientIPHeaderEditableTrue ZonesTrueClientIPHeaderEditable = true + ZonesTrueClientIPHeaderEditableFalse ZonesTrueClientIPHeaderEditable = false +) + +// Allows customer to continue to use True Client IP (Akamai feature) in the +// headers we send to the origin. This is limited to Enterprise Zones. +type ZonesTrueClientIPHeaderParam struct { + // ID of the zone setting. + ID param.Field[ZonesTrueClientIPHeaderID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesTrueClientIPHeaderValue] `json:"value,required"` +} + +func (r ZonesTrueClientIPHeaderParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesTrueClientIPHeaderParam) implementsZonesSettingEditParamsItem() {} + +type SettingTrueClientIPHeaderEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingTrueClientIPHeaderEditParamsValue] `json:"value,required"` +} + +func (r SettingTrueClientIPHeaderEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingTrueClientIPHeaderEditParamsValue string + +const ( + SettingTrueClientIPHeaderEditParamsValueOn SettingTrueClientIPHeaderEditParamsValue = "on" + SettingTrueClientIPHeaderEditParamsValueOff SettingTrueClientIPHeaderEditParamsValue = "off" +) + +type SettingTrueClientIPHeaderEditResponseEnvelope struct { + Errors []SettingTrueClientIPHeaderEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingTrueClientIPHeaderEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Allows customer to continue to use True Client IP (Akamai feature) in the + // headers we send to the origin. This is limited to Enterprise Zones. + Result ZonesTrueClientIPHeader `json:"result"` + JSON settingTrueClientIPHeaderEditResponseEnvelopeJSON `json:"-"` +} + +// settingTrueClientIPHeaderEditResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingTrueClientIPHeaderEditResponseEnvelope] +type settingTrueClientIPHeaderEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTrueClientIPHeaderEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTrueClientIPHeaderEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingTrueClientIPHeaderEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingTrueClientIPHeaderEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingTrueClientIPHeaderEditResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [SettingTrueClientIPHeaderEditResponseEnvelopeErrors] +type settingTrueClientIPHeaderEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTrueClientIPHeaderEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTrueClientIPHeaderEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingTrueClientIPHeaderEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingTrueClientIPHeaderEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingTrueClientIPHeaderEditResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingTrueClientIPHeaderEditResponseEnvelopeMessages] +type settingTrueClientIPHeaderEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTrueClientIPHeaderEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTrueClientIPHeaderEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingTrueClientIPHeaderGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingTrueClientIPHeaderGetResponseEnvelope struct { + Errors []SettingTrueClientIPHeaderGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingTrueClientIPHeaderGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // Allows customer to continue to use True Client IP (Akamai feature) in the + // headers we send to the origin. This is limited to Enterprise Zones. + Result ZonesTrueClientIPHeader `json:"result"` + JSON settingTrueClientIPHeaderGetResponseEnvelopeJSON `json:"-"` +} + +// settingTrueClientIPHeaderGetResponseEnvelopeJSON contains the JSON metadata for +// the struct [SettingTrueClientIPHeaderGetResponseEnvelope] +type settingTrueClientIPHeaderGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTrueClientIPHeaderGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTrueClientIPHeaderGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingTrueClientIPHeaderGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingTrueClientIPHeaderGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingTrueClientIPHeaderGetResponseEnvelopeErrorsJSON contains the JSON +// metadata for the struct [SettingTrueClientIPHeaderGetResponseEnvelopeErrors] +type settingTrueClientIPHeaderGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTrueClientIPHeaderGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTrueClientIPHeaderGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingTrueClientIPHeaderGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingTrueClientIPHeaderGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingTrueClientIPHeaderGetResponseEnvelopeMessagesJSON contains the JSON +// metadata for the struct [SettingTrueClientIPHeaderGetResponseEnvelopeMessages] +type settingTrueClientIPHeaderGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingTrueClientIPHeaderGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingTrueClientIPHeaderGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingtrueclientipheader_test.go b/zones/settingtrueclientipheader_test.go new file mode 100644 index 00000000000..96db22cef2b --- /dev/null +++ b/zones/settingtrueclientipheader_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingTrueClientIPHeaderEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.TrueClientIPHeader.Edit(context.TODO(), zones.SettingTrueClientIPHeaderEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingTrueClientIPHeaderEditParamsValueOn), + }) + 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 TestSettingTrueClientIPHeaderGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.TrueClientIPHeader.Get(context.TODO(), zones.SettingTrueClientIPHeaderGetParams{ + ZoneID: cloudflare.F("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/zones/settingwaf.go b/zones/settingwaf.go new file mode 100644 index 00000000000..8e3748261d9 --- /dev/null +++ b/zones/settingwaf.go @@ -0,0 +1,360 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingWAFService 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 [NewSettingWAFService] method instead. +type SettingWAFService struct { + Options []option.RequestOption +} + +// NewSettingWAFService 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 NewSettingWAFService(opts ...option.RequestOption) (r *SettingWAFService) { + r = &SettingWAFService{} + r.Options = opts + return +} + +// The WAF examines HTTP requests to your website. It inspects both GET and POST +// requests and applies rules to help filter out illegitimate traffic from +// legitimate website visitors. The Cloudflare WAF inspects website addresses or +// URLs to detect anything out of the ordinary. If the Cloudflare WAF determines +// suspicious user behavior, then the WAF will 'challenge' the web visitor with a +// page that asks them to submit a CAPTCHA successfully to continue their action. +// If the challenge is failed, the action will be stopped. What this means is that +// Cloudflare's WAF will block any traffic identified as illegitimate before it +// reaches your origin web server. +// (https://support.cloudflare.com/hc/en-us/articles/200172016). +func (r *SettingWAFService) Edit(ctx context.Context, params SettingWAFEditParams, opts ...option.RequestOption) (res *ZonesWAF, err error) { + opts = append(r.Options[:], opts...) + var env SettingWAFEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/waf", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// The WAF examines HTTP requests to your website. It inspects both GET and POST +// requests and applies rules to help filter out illegitimate traffic from +// legitimate website visitors. The Cloudflare WAF inspects website addresses or +// URLs to detect anything out of the ordinary. If the Cloudflare WAF determines +// suspicious user behavior, then the WAF will 'challenge' the web visitor with a +// page that asks them to submit a CAPTCHA successfully to continue their action. +// If the challenge is failed, the action will be stopped. What this means is that +// Cloudflare's WAF will block any traffic identified as illegitimate before it +// reaches your origin web server. +// (https://support.cloudflare.com/hc/en-us/articles/200172016). +func (r *SettingWAFService) Get(ctx context.Context, query SettingWAFGetParams, opts ...option.RequestOption) (res *ZonesWAF, err error) { + opts = append(r.Options[:], opts...) + var env SettingWAFGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/waf", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// The WAF examines HTTP requests to your website. It inspects both GET and POST +// requests and applies rules to help filter out illegitimate traffic from +// legitimate website visitors. The Cloudflare WAF inspects website addresses or +// URLs to detect anything out of the ordinary. If the Cloudflare WAF determines +// suspicious user behavior, then the WAF will 'challenge' the web visitor with a +// page that asks them to submit a CAPTCHA successfully to continue their action. +// If the challenge is failed, the action will be stopped. What this means is that +// Cloudflare's WAF will block any traffic identified as illegitimate before it +// reaches your origin web server. +// (https://support.cloudflare.com/hc/en-us/articles/200172016). +type ZonesWAF struct { + // ID of the zone setting. + ID ZonesWAFID `json:"id,required"` + // Current value of the zone setting. + Value ZonesWAFValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesWAFEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesWAFJSON `json:"-"` +} + +// zonesWAFJSON contains the JSON metadata for the struct [ZonesWAF] +type zonesWAFJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesWAF) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesWAFJSON) RawJSON() string { + return r.raw +} + +func (r ZonesWAF) implementsZonesSettingEditResponse() {} + +func (r ZonesWAF) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesWAFID string + +const ( + ZonesWAFIDWAF ZonesWAFID = "waf" +) + +// Current value of the zone setting. +type ZonesWAFValue string + +const ( + ZonesWAFValueOn ZonesWAFValue = "on" + ZonesWAFValueOff ZonesWAFValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesWAFEditable bool + +const ( + ZonesWAFEditableTrue ZonesWAFEditable = true + ZonesWAFEditableFalse ZonesWAFEditable = false +) + +// The WAF examines HTTP requests to your website. It inspects both GET and POST +// requests and applies rules to help filter out illegitimate traffic from +// legitimate website visitors. The Cloudflare WAF inspects website addresses or +// URLs to detect anything out of the ordinary. If the Cloudflare WAF determines +// suspicious user behavior, then the WAF will 'challenge' the web visitor with a +// page that asks them to submit a CAPTCHA successfully to continue their action. +// If the challenge is failed, the action will be stopped. What this means is that +// Cloudflare's WAF will block any traffic identified as illegitimate before it +// reaches your origin web server. +// (https://support.cloudflare.com/hc/en-us/articles/200172016). +type ZonesWAFParam struct { + // ID of the zone setting. + ID param.Field[ZonesWAFID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesWAFValue] `json:"value,required"` +} + +func (r ZonesWAFParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesWAFParam) implementsZonesSettingEditParamsItem() {} + +type SettingWAFEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingWAFEditParamsValue] `json:"value,required"` +} + +func (r SettingWAFEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingWAFEditParamsValue string + +const ( + SettingWAFEditParamsValueOn SettingWAFEditParamsValue = "on" + SettingWAFEditParamsValueOff SettingWAFEditParamsValue = "off" +) + +type SettingWAFEditResponseEnvelope struct { + Errors []SettingWAFEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingWAFEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // The WAF examines HTTP requests to your website. It inspects both GET and POST + // requests and applies rules to help filter out illegitimate traffic from + // legitimate website visitors. The Cloudflare WAF inspects website addresses or + // URLs to detect anything out of the ordinary. If the Cloudflare WAF determines + // suspicious user behavior, then the WAF will 'challenge' the web visitor with a + // page that asks them to submit a CAPTCHA successfully to continue their action. + // If the challenge is failed, the action will be stopped. What this means is that + // Cloudflare's WAF will block any traffic identified as illegitimate before it + // reaches your origin web server. + // (https://support.cloudflare.com/hc/en-us/articles/200172016). + Result ZonesWAF `json:"result"` + JSON settingWAFEditResponseEnvelopeJSON `json:"-"` +} + +// settingWAFEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingWAFEditResponseEnvelope] +type settingWAFEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingWAFEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingWAFEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingWAFEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingWAFEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingWAFEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingWAFEditResponseEnvelopeErrors] +type settingWAFEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingWAFEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingWAFEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingWAFEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingWAFEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingWAFEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingWAFEditResponseEnvelopeMessages] +type settingWAFEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingWAFEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingWAFEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingWAFGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingWAFGetResponseEnvelope struct { + Errors []SettingWAFGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingWAFGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // The WAF examines HTTP requests to your website. It inspects both GET and POST + // requests and applies rules to help filter out illegitimate traffic from + // legitimate website visitors. The Cloudflare WAF inspects website addresses or + // URLs to detect anything out of the ordinary. If the Cloudflare WAF determines + // suspicious user behavior, then the WAF will 'challenge' the web visitor with a + // page that asks them to submit a CAPTCHA successfully to continue their action. + // If the challenge is failed, the action will be stopped. What this means is that + // Cloudflare's WAF will block any traffic identified as illegitimate before it + // reaches your origin web server. + // (https://support.cloudflare.com/hc/en-us/articles/200172016). + Result ZonesWAF `json:"result"` + JSON settingWAFGetResponseEnvelopeJSON `json:"-"` +} + +// settingWAFGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingWAFGetResponseEnvelope] +type settingWAFGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingWAFGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingWAFGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingWAFGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingWAFGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingWAFGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingWAFGetResponseEnvelopeErrors] +type settingWAFGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingWAFGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingWAFGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingWAFGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingWAFGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingWAFGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingWAFGetResponseEnvelopeMessages] +type settingWAFGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingWAFGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingWAFGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingwaf_test.go b/zones/settingwaf_test.go new file mode 100644 index 00000000000..936d31b9559 --- /dev/null +++ b/zones/settingwaf_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingWAFEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.WAF.Edit(context.TODO(), zones.SettingWAFEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingWAFEditParamsValueOn), + }) + 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 TestSettingWAFGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.WAF.Get(context.TODO(), zones.SettingWAFGetParams{ + ZoneID: cloudflare.F("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/zones/settingwebp.go b/zones/settingwebp.go new file mode 100644 index 00000000000..1cced7fc804 --- /dev/null +++ b/zones/settingwebp.go @@ -0,0 +1,319 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingWebpService 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 [NewSettingWebpService] method +// instead. +type SettingWebpService struct { + Options []option.RequestOption +} + +// NewSettingWebpService 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 NewSettingWebpService(opts ...option.RequestOption) (r *SettingWebpService) { + r = &SettingWebpService{} + r.Options = opts + return +} + +// When the client requesting the image supports the WebP image codec, and WebP +// offers a performance advantage over the original image format, Cloudflare will +// serve a WebP version of the original image. +func (r *SettingWebpService) Edit(ctx context.Context, params SettingWebpEditParams, opts ...option.RequestOption) (res *ZonesWebp, err error) { + opts = append(r.Options[:], opts...) + var env SettingWebpEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/webp", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// When the client requesting the image supports the WebP image codec, and WebP +// offers a performance advantage over the original image format, Cloudflare will +// serve a WebP version of the original image. +func (r *SettingWebpService) Get(ctx context.Context, query SettingWebpGetParams, opts ...option.RequestOption) (res *ZonesWebp, err error) { + opts = append(r.Options[:], opts...) + var env SettingWebpGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/webp", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// When the client requesting the image supports the WebP image codec, and WebP +// offers a performance advantage over the original image format, Cloudflare will +// serve a WebP version of the original image. +type ZonesWebp struct { + // ID of the zone setting. + ID ZonesWebpID `json:"id,required"` + // Current value of the zone setting. + Value ZonesWebpValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesWebpEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesWebpJSON `json:"-"` +} + +// zonesWebpJSON contains the JSON metadata for the struct [ZonesWebp] +type zonesWebpJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesWebp) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesWebpJSON) RawJSON() string { + return r.raw +} + +func (r ZonesWebp) implementsZonesSettingEditResponse() {} + +func (r ZonesWebp) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesWebpID string + +const ( + ZonesWebpIDWebp ZonesWebpID = "webp" +) + +// Current value of the zone setting. +type ZonesWebpValue string + +const ( + ZonesWebpValueOff ZonesWebpValue = "off" + ZonesWebpValueOn ZonesWebpValue = "on" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesWebpEditable bool + +const ( + ZonesWebpEditableTrue ZonesWebpEditable = true + ZonesWebpEditableFalse ZonesWebpEditable = false +) + +// When the client requesting the image supports the WebP image codec, and WebP +// offers a performance advantage over the original image format, Cloudflare will +// serve a WebP version of the original image. +type ZonesWebpParam struct { + // ID of the zone setting. + ID param.Field[ZonesWebpID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesWebpValue] `json:"value,required"` +} + +func (r ZonesWebpParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesWebpParam) implementsZonesSettingEditParamsItem() {} + +type SettingWebpEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingWebpEditParamsValue] `json:"value,required"` +} + +func (r SettingWebpEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingWebpEditParamsValue string + +const ( + SettingWebpEditParamsValueOff SettingWebpEditParamsValue = "off" + SettingWebpEditParamsValueOn SettingWebpEditParamsValue = "on" +) + +type SettingWebpEditResponseEnvelope struct { + Errors []SettingWebpEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingWebpEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // When the client requesting the image supports the WebP image codec, and WebP + // offers a performance advantage over the original image format, Cloudflare will + // serve a WebP version of the original image. + Result ZonesWebp `json:"result"` + JSON settingWebpEditResponseEnvelopeJSON `json:"-"` +} + +// settingWebpEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingWebpEditResponseEnvelope] +type settingWebpEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingWebpEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingWebpEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingWebpEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingWebpEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingWebpEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingWebpEditResponseEnvelopeErrors] +type settingWebpEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingWebpEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingWebpEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingWebpEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingWebpEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingWebpEditResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingWebpEditResponseEnvelopeMessages] +type settingWebpEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingWebpEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingWebpEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingWebpGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingWebpGetResponseEnvelope struct { + Errors []SettingWebpGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingWebpGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // When the client requesting the image supports the WebP image codec, and WebP + // offers a performance advantage over the original image format, Cloudflare will + // serve a WebP version of the original image. + Result ZonesWebp `json:"result"` + JSON settingWebpGetResponseEnvelopeJSON `json:"-"` +} + +// settingWebpGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingWebpGetResponseEnvelope] +type settingWebpGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingWebpGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingWebpGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingWebpGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingWebpGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingWebpGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingWebpGetResponseEnvelopeErrors] +type settingWebpGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingWebpGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingWebpGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingWebpGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingWebpGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingWebpGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingWebpGetResponseEnvelopeMessages] +type settingWebpGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingWebpGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingWebpGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingwebp_test.go b/zones/settingwebp_test.go new file mode 100644 index 00000000000..68b82f61732 --- /dev/null +++ b/zones/settingwebp_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingWebpEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.Webp.Edit(context.TODO(), zones.SettingWebpEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingWebpEditParamsValueOff), + }) + 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 TestSettingWebpGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.Webp.Get(context.TODO(), zones.SettingWebpGetParams{ + ZoneID: cloudflare.F("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/zones/settingwebsocket.go b/zones/settingwebsocket.go new file mode 100644 index 00000000000..a0a535609cf --- /dev/null +++ b/zones/settingwebsocket.go @@ -0,0 +1,334 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingWebsocketService 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 [NewSettingWebsocketService] method +// instead. +type SettingWebsocketService struct { + Options []option.RequestOption +} + +// NewSettingWebsocketService 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 NewSettingWebsocketService(opts ...option.RequestOption) (r *SettingWebsocketService) { + r = &SettingWebsocketService{} + r.Options = opts + return +} + +// Changes Websockets setting. For more information about Websockets, please refer +// to +// [Using Cloudflare with WebSockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Using-Cloudflare-with-WebSockets). +func (r *SettingWebsocketService) Edit(ctx context.Context, params SettingWebsocketEditParams, opts ...option.RequestOption) (res *ZonesWebsockets, err error) { + opts = append(r.Options[:], opts...) + var env SettingWebsocketEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/websockets", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets Websockets setting. For more information about Websockets, please refer to +// [Using Cloudflare with WebSockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Using-Cloudflare-with-WebSockets). +func (r *SettingWebsocketService) Get(ctx context.Context, query SettingWebsocketGetParams, opts ...option.RequestOption) (res *ZonesWebsockets, err error) { + opts = append(r.Options[:], opts...) + var env SettingWebsocketGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/websockets", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// WebSockets are open connections sustained between the client and the origin +// server. Inside a WebSockets connection, the client and the origin can pass data +// back and forth without having to reestablish sessions. This makes exchanging +// data within a WebSockets connection fast. WebSockets are often used for +// real-time applications such as live chat and gaming. For more information refer +// to +// [Can I use Cloudflare with Websockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Can-I-use-Cloudflare-with-WebSockets-). +type ZonesWebsockets struct { + // ID of the zone setting. + ID ZonesWebsocketsID `json:"id,required"` + // Current value of the zone setting. + Value ZonesWebsocketsValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable ZonesWebsocketsEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zonesWebsocketsJSON `json:"-"` +} + +// zonesWebsocketsJSON contains the JSON metadata for the struct [ZonesWebsockets] +type zonesWebsocketsJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *ZonesWebsockets) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zonesWebsocketsJSON) RawJSON() string { + return r.raw +} + +func (r ZonesWebsockets) implementsZonesSettingEditResponse() {} + +func (r ZonesWebsockets) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type ZonesWebsocketsID string + +const ( + ZonesWebsocketsIDWebsockets ZonesWebsocketsID = "websockets" +) + +// Current value of the zone setting. +type ZonesWebsocketsValue string + +const ( + ZonesWebsocketsValueOff ZonesWebsocketsValue = "off" + ZonesWebsocketsValueOn ZonesWebsocketsValue = "on" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type ZonesWebsocketsEditable bool + +const ( + ZonesWebsocketsEditableTrue ZonesWebsocketsEditable = true + ZonesWebsocketsEditableFalse ZonesWebsocketsEditable = false +) + +// WebSockets are open connections sustained between the client and the origin +// server. Inside a WebSockets connection, the client and the origin can pass data +// back and forth without having to reestablish sessions. This makes exchanging +// data within a WebSockets connection fast. WebSockets are often used for +// real-time applications such as live chat and gaming. For more information refer +// to +// [Can I use Cloudflare with Websockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Can-I-use-Cloudflare-with-WebSockets-). +type ZonesWebsocketsParam struct { + // ID of the zone setting. + ID param.Field[ZonesWebsocketsID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[ZonesWebsocketsValue] `json:"value,required"` +} + +func (r ZonesWebsocketsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r ZonesWebsocketsParam) implementsZonesSettingEditParamsItem() {} + +type SettingWebsocketEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the zone setting. + Value param.Field[SettingWebsocketEditParamsValue] `json:"value,required"` +} + +func (r SettingWebsocketEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the zone setting. +type SettingWebsocketEditParamsValue string + +const ( + SettingWebsocketEditParamsValueOff SettingWebsocketEditParamsValue = "off" + SettingWebsocketEditParamsValueOn SettingWebsocketEditParamsValue = "on" +) + +type SettingWebsocketEditResponseEnvelope struct { + Errors []SettingWebsocketEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingWebsocketEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // WebSockets are open connections sustained between the client and the origin + // server. Inside a WebSockets connection, the client and the origin can pass data + // back and forth without having to reestablish sessions. This makes exchanging + // data within a WebSockets connection fast. WebSockets are often used for + // real-time applications such as live chat and gaming. For more information refer + // to + // [Can I use Cloudflare with Websockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Can-I-use-Cloudflare-with-WebSockets-). + Result ZonesWebsockets `json:"result"` + JSON settingWebsocketEditResponseEnvelopeJSON `json:"-"` +} + +// settingWebsocketEditResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingWebsocketEditResponseEnvelope] +type settingWebsocketEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingWebsocketEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingWebsocketEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingWebsocketEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingWebsocketEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingWebsocketEditResponseEnvelopeErrorsJSON contains the JSON metadata for +// the struct [SettingWebsocketEditResponseEnvelopeErrors] +type settingWebsocketEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingWebsocketEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingWebsocketEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingWebsocketEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingWebsocketEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingWebsocketEditResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [SettingWebsocketEditResponseEnvelopeMessages] +type settingWebsocketEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingWebsocketEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingWebsocketEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingWebsocketGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingWebsocketGetResponseEnvelope struct { + Errors []SettingWebsocketGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingWebsocketGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // WebSockets are open connections sustained between the client and the origin + // server. Inside a WebSockets connection, the client and the origin can pass data + // back and forth without having to reestablish sessions. This makes exchanging + // data within a WebSockets connection fast. WebSockets are often used for + // real-time applications such as live chat and gaming. For more information refer + // to + // [Can I use Cloudflare with Websockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Can-I-use-Cloudflare-with-WebSockets-). + Result ZonesWebsockets `json:"result"` + JSON settingWebsocketGetResponseEnvelopeJSON `json:"-"` +} + +// settingWebsocketGetResponseEnvelopeJSON contains the JSON metadata for the +// struct [SettingWebsocketGetResponseEnvelope] +type settingWebsocketGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingWebsocketGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingWebsocketGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingWebsocketGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingWebsocketGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingWebsocketGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingWebsocketGetResponseEnvelopeErrors] +type settingWebsocketGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingWebsocketGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingWebsocketGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingWebsocketGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingWebsocketGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingWebsocketGetResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [SettingWebsocketGetResponseEnvelopeMessages] +type settingWebsocketGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingWebsocketGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingWebsocketGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingwebsocket_test.go b/zones/settingwebsocket_test.go new file mode 100644 index 00000000000..a8e1680b462 --- /dev/null +++ b/zones/settingwebsocket_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingWebsocketEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.Websocket.Edit(context.TODO(), zones.SettingWebsocketEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingWebsocketEditParamsValueOff), + }) + 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 TestSettingWebsocketGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.Websocket.Get(context.TODO(), zones.SettingWebsocketGetParams{ + ZoneID: cloudflare.F("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/zones/settingzerortt.go b/zones/settingzerortt.go new file mode 100644 index 00000000000..de7fca9bab7 --- /dev/null +++ b/zones/settingzerortt.go @@ -0,0 +1,307 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/option" +) + +// SettingZeroRTTService 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 [NewSettingZeroRTTService] method +// instead. +type SettingZeroRTTService struct { + Options []option.RequestOption +} + +// NewSettingZeroRTTService 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 NewSettingZeroRTTService(opts ...option.RequestOption) (r *SettingZeroRTTService) { + r = &SettingZeroRTTService{} + r.Options = opts + return +} + +// Changes the 0-RTT session resumption setting. +func (r *SettingZeroRTTService) Edit(ctx context.Context, params SettingZeroRTTEditParams, opts ...option.RequestOption) (res *Zones0rtt, err error) { + opts = append(r.Options[:], opts...) + var env SettingZeroRTTEditResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/0rtt", params.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Gets 0-RTT session resumption setting. +func (r *SettingZeroRTTService) Get(ctx context.Context, query SettingZeroRTTGetParams, opts ...option.RequestOption) (res *Zones0rtt, err error) { + opts = append(r.Options[:], opts...) + var env SettingZeroRTTGetResponseEnvelope + path := fmt.Sprintf("zones/%s/settings/0rtt", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// 0-RTT session resumption enabled for this zone. +type Zones0rtt struct { + // ID of the zone setting. + ID Zones0rttID `json:"id,required"` + // Current value of the zone setting. + Value Zones0rttValue `json:"value,required"` + // Whether or not this setting can be modified for this zone (based on your + // Cloudflare plan level). + Editable Zones0rttEditable `json:"editable"` + // last time this setting was modified. + ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` + JSON zones0rttJSON `json:"-"` +} + +// zones0rttJSON contains the JSON metadata for the struct [Zones0rtt] +type zones0rttJSON struct { + ID apijson.Field + Value apijson.Field + Editable apijson.Field + ModifiedOn apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Zones0rtt) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r zones0rttJSON) RawJSON() string { + return r.raw +} + +func (r Zones0rtt) implementsZonesSettingEditResponse() {} + +func (r Zones0rtt) implementsZonesSettingGetResponse() {} + +// ID of the zone setting. +type Zones0rttID string + +const ( + Zones0rttID0rtt Zones0rttID = "0rtt" +) + +// Current value of the zone setting. +type Zones0rttValue string + +const ( + Zones0rttValueOn Zones0rttValue = "on" + Zones0rttValueOff Zones0rttValue = "off" +) + +// Whether or not this setting can be modified for this zone (based on your +// Cloudflare plan level). +type Zones0rttEditable bool + +const ( + Zones0rttEditableTrue Zones0rttEditable = true + Zones0rttEditableFalse Zones0rttEditable = false +) + +// 0-RTT session resumption enabled for this zone. +type Zones0rttParam struct { + // ID of the zone setting. + ID param.Field[Zones0rttID] `json:"id,required"` + // Current value of the zone setting. + Value param.Field[Zones0rttValue] `json:"value,required"` +} + +func (r Zones0rttParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r Zones0rttParam) implementsZonesSettingEditParamsItem() {} + +type SettingZeroRTTEditParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` + // Value of the 0-RTT setting. + Value param.Field[SettingZeroRTTEditParamsValue] `json:"value,required"` +} + +func (r SettingZeroRTTEditParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Value of the 0-RTT setting. +type SettingZeroRTTEditParamsValue string + +const ( + SettingZeroRTTEditParamsValueOn SettingZeroRTTEditParamsValue = "on" + SettingZeroRTTEditParamsValueOff SettingZeroRTTEditParamsValue = "off" +) + +type SettingZeroRTTEditResponseEnvelope struct { + Errors []SettingZeroRTTEditResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingZeroRTTEditResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // 0-RTT session resumption enabled for this zone. + Result Zones0rtt `json:"result"` + JSON settingZeroRTTEditResponseEnvelopeJSON `json:"-"` +} + +// settingZeroRTTEditResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingZeroRTTEditResponseEnvelope] +type settingZeroRTTEditResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingZeroRTTEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingZeroRTTEditResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingZeroRTTEditResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingZeroRTTEditResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingZeroRTTEditResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingZeroRTTEditResponseEnvelopeErrors] +type settingZeroRTTEditResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingZeroRTTEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingZeroRTTEditResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingZeroRTTEditResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingZeroRTTEditResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingZeroRTTEditResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [SettingZeroRTTEditResponseEnvelopeMessages] +type settingZeroRTTEditResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingZeroRTTEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingZeroRTTEditResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +type SettingZeroRTTGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type SettingZeroRTTGetResponseEnvelope struct { + Errors []SettingZeroRTTGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SettingZeroRTTGetResponseEnvelopeMessages `json:"messages,required"` + // Whether the API call was successful + Success bool `json:"success,required"` + // 0-RTT session resumption enabled for this zone. + Result Zones0rtt `json:"result"` + JSON settingZeroRTTGetResponseEnvelopeJSON `json:"-"` +} + +// settingZeroRTTGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SettingZeroRTTGetResponseEnvelope] +type settingZeroRTTGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Success apijson.Field + Result apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingZeroRTTGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingZeroRTTGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SettingZeroRTTGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingZeroRTTGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// settingZeroRTTGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SettingZeroRTTGetResponseEnvelopeErrors] +type settingZeroRTTGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingZeroRTTGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingZeroRTTGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SettingZeroRTTGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON settingZeroRTTGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// settingZeroRTTGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SettingZeroRTTGetResponseEnvelopeMessages] +type settingZeroRTTGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SettingZeroRTTGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r settingZeroRTTGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} diff --git a/zones/settingzerortt_test.go b/zones/settingzerortt_test.go new file mode 100644 index 00000000000..538fbe03dc6 --- /dev/null +++ b/zones/settingzerortt_test.go @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSettingZeroRTTEdit(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("user@example.com"), + ) + _, err := client.Zones.Settings.ZeroRTT.Edit(context.TODO(), zones.SettingZeroRTTEditParams{ + ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), + Value: cloudflare.F(zones.SettingZeroRTTEditParamsValueOn), + }) + 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 TestSettingZeroRTTGet(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("user@example.com"), + ) + _, err := client.Zones.Settings.ZeroRTT.Get(context.TODO(), zones.SettingZeroRTTGetParams{ + ZoneID: cloudflare.F("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/zones/subscription.go b/zones/subscription.go new file mode 100644 index 00000000000..6e64260def0 --- /dev/null +++ b/zones/subscription.go @@ -0,0 +1,662 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "reflect" + "time" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// SubscriptionService 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 [NewSubscriptionService] method +// instead. +type SubscriptionService struct { + Options []option.RequestOption +} + +// NewSubscriptionService 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 NewSubscriptionService(opts ...option.RequestOption) (r *SubscriptionService) { + r = &SubscriptionService{} + r.Options = opts + return +} + +// Create a zone subscription, either plan or add-ons. +func (r *SubscriptionService) New(ctx context.Context, identifier string, body SubscriptionNewParams, opts ...option.RequestOption) (res *SubscriptionNewResponse, err error) { + opts = append(r.Options[:], opts...) + var env SubscriptionNewResponseEnvelope + path := fmt.Sprintf("zones/%s/subscription", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists all of an account's subscriptions. +func (r *SubscriptionService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *[]SubscriptionListResponse, err error) { + opts = append(r.Options[:], opts...) + var env SubscriptionListResponseEnvelope + path := fmt.Sprintf("accounts/%s/subscriptions", accountIdentifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Lists zone subscription details. +func (r *SubscriptionService) Get(ctx context.Context, identifier string, opts ...option.RequestOption) (res *SubscriptionGetResponse, err error) { + opts = append(r.Options[:], opts...) + var env SubscriptionGetResponseEnvelope + path := fmt.Sprintf("zones/%s/subscription", identifier) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Union satisfied by [zones.SubscriptionNewResponseUnknown] or +// [shared.UnionString]. +type SubscriptionNewResponse interface { + ImplementsZonesSubscriptionNewResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*SubscriptionNewResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type SubscriptionListResponse struct { + // Subscription identifier tag. + ID string `json:"id"` + App SubscriptionListResponseApp `json:"app"` + // The list of add-ons subscribed to. + ComponentValues []SubscriptionListResponseComponentValue `json:"component_values"` + // The monetary unit in which pricing information is displayed. + Currency string `json:"currency"` + // The end of the current period and also when the next billing is due. + CurrentPeriodEnd time.Time `json:"current_period_end" format:"date-time"` + // When the current billing period started. May match initial_period_start if this + // is the first period. + CurrentPeriodStart time.Time `json:"current_period_start" format:"date-time"` + // How often the subscription is renewed automatically. + Frequency SubscriptionListResponseFrequency `json:"frequency"` + // The price of the subscription that will be billed, in US dollars. + Price float64 `json:"price"` + // The rate plan applied to the subscription. + RatePlan SubscriptionListResponseRatePlan `json:"rate_plan"` + // The state that the subscription is in. + State SubscriptionListResponseState `json:"state"` + // A simple zone object. May have null properties if not a zone subscription. + Zone SubscriptionListResponseZone `json:"zone"` + JSON subscriptionListResponseJSON `json:"-"` +} + +// subscriptionListResponseJSON contains the JSON metadata for the struct +// [SubscriptionListResponse] +type subscriptionListResponseJSON struct { + ID apijson.Field + App apijson.Field + ComponentValues apijson.Field + Currency apijson.Field + CurrentPeriodEnd apijson.Field + CurrentPeriodStart apijson.Field + Frequency apijson.Field + Price apijson.Field + RatePlan apijson.Field + State apijson.Field + Zone apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionListResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionListResponseJSON) RawJSON() string { + return r.raw +} + +type SubscriptionListResponseApp struct { + // app install id. + InstallID string `json:"install_id"` + JSON subscriptionListResponseAppJSON `json:"-"` +} + +// subscriptionListResponseAppJSON contains the JSON metadata for the struct +// [SubscriptionListResponseApp] +type subscriptionListResponseAppJSON struct { + InstallID apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionListResponseApp) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionListResponseAppJSON) RawJSON() string { + return r.raw +} + +// A component value for a subscription. +type SubscriptionListResponseComponentValue struct { + // The default amount assigned. + Default float64 `json:"default"` + // The name of the component value. + Name string `json:"name"` + // The unit price for the component value. + Price float64 `json:"price"` + // The amount of the component value assigned. + Value float64 `json:"value"` + JSON subscriptionListResponseComponentValueJSON `json:"-"` +} + +// subscriptionListResponseComponentValueJSON contains the JSON metadata for the +// struct [SubscriptionListResponseComponentValue] +type subscriptionListResponseComponentValueJSON struct { + Default apijson.Field + Name apijson.Field + Price apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionListResponseComponentValue) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionListResponseComponentValueJSON) RawJSON() string { + return r.raw +} + +// How often the subscription is renewed automatically. +type SubscriptionListResponseFrequency string + +const ( + SubscriptionListResponseFrequencyWeekly SubscriptionListResponseFrequency = "weekly" + SubscriptionListResponseFrequencyMonthly SubscriptionListResponseFrequency = "monthly" + SubscriptionListResponseFrequencyQuarterly SubscriptionListResponseFrequency = "quarterly" + SubscriptionListResponseFrequencyYearly SubscriptionListResponseFrequency = "yearly" +) + +// The rate plan applied to the subscription. +type SubscriptionListResponseRatePlan struct { + // The ID of the rate plan. + ID interface{} `json:"id"` + // The currency applied to the rate plan subscription. + Currency string `json:"currency"` + // Whether this rate plan is managed externally from Cloudflare. + ExternallyManaged bool `json:"externally_managed"` + // Whether a rate plan is enterprise-based (or newly adopted term contract). + IsContract bool `json:"is_contract"` + // The full name of the rate plan. + PublicName string `json:"public_name"` + // The scope that this rate plan applies to. + Scope string `json:"scope"` + // The list of sets this rate plan applies to. + Sets []string `json:"sets"` + JSON subscriptionListResponseRatePlanJSON `json:"-"` +} + +// subscriptionListResponseRatePlanJSON contains the JSON metadata for the struct +// [SubscriptionListResponseRatePlan] +type subscriptionListResponseRatePlanJSON struct { + ID apijson.Field + Currency apijson.Field + ExternallyManaged apijson.Field + IsContract apijson.Field + PublicName apijson.Field + Scope apijson.Field + Sets apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionListResponseRatePlan) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionListResponseRatePlanJSON) RawJSON() string { + return r.raw +} + +// The state that the subscription is in. +type SubscriptionListResponseState string + +const ( + SubscriptionListResponseStateTrial SubscriptionListResponseState = "Trial" + SubscriptionListResponseStateProvisioned SubscriptionListResponseState = "Provisioned" + SubscriptionListResponseStatePaid SubscriptionListResponseState = "Paid" + SubscriptionListResponseStateAwaitingPayment SubscriptionListResponseState = "AwaitingPayment" + SubscriptionListResponseStateCancelled SubscriptionListResponseState = "Cancelled" + SubscriptionListResponseStateFailed SubscriptionListResponseState = "Failed" + SubscriptionListResponseStateExpired SubscriptionListResponseState = "Expired" +) + +// A simple zone object. May have null properties if not a zone subscription. +type SubscriptionListResponseZone struct { + // Identifier + ID string `json:"id"` + // The domain name + Name string `json:"name"` + JSON subscriptionListResponseZoneJSON `json:"-"` +} + +// subscriptionListResponseZoneJSON contains the JSON metadata for the struct +// [SubscriptionListResponseZone] +type subscriptionListResponseZoneJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionListResponseZone) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionListResponseZoneJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [zones.SubscriptionGetResponseUnknown] or +// [shared.UnionString]. +type SubscriptionGetResponse interface { + ImplementsZonesSubscriptionGetResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*SubscriptionGetResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type SubscriptionNewParams struct { + App param.Field[SubscriptionNewParamsApp] `json:"app"` + // The list of add-ons subscribed to. + ComponentValues param.Field[[]SubscriptionNewParamsComponentValue] `json:"component_values"` + // How often the subscription is renewed automatically. + Frequency param.Field[SubscriptionNewParamsFrequency] `json:"frequency"` + // The rate plan applied to the subscription. + RatePlan param.Field[SubscriptionNewParamsRatePlan] `json:"rate_plan"` + // A simple zone object. May have null properties if not a zone subscription. + Zone param.Field[SubscriptionNewParamsZone] `json:"zone"` +} + +func (r SubscriptionNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SubscriptionNewParamsApp struct { + // app install id. + InstallID param.Field[string] `json:"install_id"` +} + +func (r SubscriptionNewParamsApp) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A component value for a subscription. +type SubscriptionNewParamsComponentValue struct { + // The default amount assigned. + Default param.Field[float64] `json:"default"` + // The name of the component value. + Name param.Field[string] `json:"name"` + // The unit price for the component value. + Price param.Field[float64] `json:"price"` + // The amount of the component value assigned. + Value param.Field[float64] `json:"value"` +} + +func (r SubscriptionNewParamsComponentValue) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// How often the subscription is renewed automatically. +type SubscriptionNewParamsFrequency string + +const ( + SubscriptionNewParamsFrequencyWeekly SubscriptionNewParamsFrequency = "weekly" + SubscriptionNewParamsFrequencyMonthly SubscriptionNewParamsFrequency = "monthly" + SubscriptionNewParamsFrequencyQuarterly SubscriptionNewParamsFrequency = "quarterly" + SubscriptionNewParamsFrequencyYearly SubscriptionNewParamsFrequency = "yearly" +) + +// The rate plan applied to the subscription. +type SubscriptionNewParamsRatePlan struct { + // The ID of the rate plan. + ID param.Field[interface{}] `json:"id"` + // The currency applied to the rate plan subscription. + Currency param.Field[string] `json:"currency"` + // Whether this rate plan is managed externally from Cloudflare. + ExternallyManaged param.Field[bool] `json:"externally_managed"` + // Whether a rate plan is enterprise-based (or newly adopted term contract). + IsContract param.Field[bool] `json:"is_contract"` + // The full name of the rate plan. + PublicName param.Field[string] `json:"public_name"` + // The scope that this rate plan applies to. + Scope param.Field[string] `json:"scope"` + // The list of sets this rate plan applies to. + Sets param.Field[[]string] `json:"sets"` +} + +func (r SubscriptionNewParamsRatePlan) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// A simple zone object. May have null properties if not a zone subscription. +type SubscriptionNewParamsZone struct { +} + +func (r SubscriptionNewParamsZone) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type SubscriptionNewResponseEnvelope struct { + Errors []SubscriptionNewResponseEnvelopeErrors `json:"errors,required"` + Messages []SubscriptionNewResponseEnvelopeMessages `json:"messages,required"` + Result SubscriptionNewResponse `json:"result,required"` + // Whether the API call was successful + Success SubscriptionNewResponseEnvelopeSuccess `json:"success,required"` + JSON subscriptionNewResponseEnvelopeJSON `json:"-"` +} + +// subscriptionNewResponseEnvelopeJSON contains the JSON metadata for the struct +// [SubscriptionNewResponseEnvelope] +type subscriptionNewResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionNewResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SubscriptionNewResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionNewResponseEnvelopeErrorsJSON `json:"-"` +} + +// subscriptionNewResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SubscriptionNewResponseEnvelopeErrors] +type subscriptionNewResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionNewResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SubscriptionNewResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionNewResponseEnvelopeMessagesJSON `json:"-"` +} + +// subscriptionNewResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SubscriptionNewResponseEnvelopeMessages] +type subscriptionNewResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionNewResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SubscriptionNewResponseEnvelopeSuccess bool + +const ( + SubscriptionNewResponseEnvelopeSuccessTrue SubscriptionNewResponseEnvelopeSuccess = true +) + +type SubscriptionListResponseEnvelope struct { + Errors []SubscriptionListResponseEnvelopeErrors `json:"errors,required"` + Messages []SubscriptionListResponseEnvelopeMessages `json:"messages,required"` + Result []SubscriptionListResponse `json:"result,required,nullable"` + // Whether the API call was successful + Success SubscriptionListResponseEnvelopeSuccess `json:"success,required"` + ResultInfo SubscriptionListResponseEnvelopeResultInfo `json:"result_info"` + JSON subscriptionListResponseEnvelopeJSON `json:"-"` +} + +// subscriptionListResponseEnvelopeJSON contains the JSON metadata for the struct +// [SubscriptionListResponseEnvelope] +type subscriptionListResponseEnvelopeJSON 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 *SubscriptionListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionListResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SubscriptionListResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionListResponseEnvelopeErrorsJSON `json:"-"` +} + +// subscriptionListResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SubscriptionListResponseEnvelopeErrors] +type subscriptionListResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionListResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SubscriptionListResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionListResponseEnvelopeMessagesJSON `json:"-"` +} + +// subscriptionListResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SubscriptionListResponseEnvelopeMessages] +type subscriptionListResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionListResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SubscriptionListResponseEnvelopeSuccess bool + +const ( + SubscriptionListResponseEnvelopeSuccessTrue SubscriptionListResponseEnvelopeSuccess = true +) + +type SubscriptionListResponseEnvelopeResultInfo struct { + // Total number of results for the requested service + Count float64 `json:"count"` + // Current page within paginated list of results + Page float64 `json:"page"` + // Number of results per page of results + PerPage float64 `json:"per_page"` + // Total results available without any search parameters + TotalCount float64 `json:"total_count"` + JSON subscriptionListResponseEnvelopeResultInfoJSON `json:"-"` +} + +// subscriptionListResponseEnvelopeResultInfoJSON contains the JSON metadata for +// the struct [SubscriptionListResponseEnvelopeResultInfo] +type subscriptionListResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + Page apijson.Field + PerPage apijson.Field + TotalCount apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionListResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +type SubscriptionGetResponseEnvelope struct { + Errors []SubscriptionGetResponseEnvelopeErrors `json:"errors,required"` + Messages []SubscriptionGetResponseEnvelopeMessages `json:"messages,required"` + Result SubscriptionGetResponse `json:"result,required"` + // Whether the API call was successful + Success SubscriptionGetResponseEnvelopeSuccess `json:"success,required"` + JSON subscriptionGetResponseEnvelopeJSON `json:"-"` +} + +// subscriptionGetResponseEnvelopeJSON contains the JSON metadata for the struct +// [SubscriptionGetResponseEnvelope] +type subscriptionGetResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionGetResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type SubscriptionGetResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionGetResponseEnvelopeErrorsJSON `json:"-"` +} + +// subscriptionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [SubscriptionGetResponseEnvelopeErrors] +type subscriptionGetResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionGetResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type SubscriptionGetResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON subscriptionGetResponseEnvelopeMessagesJSON `json:"-"` +} + +// subscriptionGetResponseEnvelopeMessagesJSON contains the JSON metadata for the +// struct [SubscriptionGetResponseEnvelopeMessages] +type subscriptionGetResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *SubscriptionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r subscriptionGetResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type SubscriptionGetResponseEnvelopeSuccess bool + +const ( + SubscriptionGetResponseEnvelopeSuccessTrue SubscriptionGetResponseEnvelopeSuccess = true +) diff --git a/zones/subscription_test.go b/zones/subscription_test.go new file mode 100644 index 00000000000..ba8cfb5c1c2 --- /dev/null +++ b/zones/subscription_test.go @@ -0,0 +1,122 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "context" + "errors" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestSubscriptionNewWithOptionalParams(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("user@example.com"), + ) + _, err := client.Zones.Subscriptions.New( + context.TODO(), + "506e3185e9c882d175a2d0cb0093d9f2", + zones.SubscriptionNewParams{ + App: cloudflare.F(zones.SubscriptionNewParamsApp{ + InstallID: cloudflare.F("string"), + }), + ComponentValues: cloudflare.F([]zones.SubscriptionNewParamsComponentValue{{ + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }, { + Default: cloudflare.F(5.000000), + Name: cloudflare.F("page_rules"), + Price: cloudflare.F(5.000000), + Value: cloudflare.F(20.000000), + }}), + Frequency: cloudflare.F(zones.SubscriptionNewParamsFrequencyMonthly), + RatePlan: cloudflare.F(zones.SubscriptionNewParamsRatePlan{ + Currency: cloudflare.F("USD"), + ExternallyManaged: cloudflare.F(false), + ID: cloudflare.F[any]("free"), + IsContract: cloudflare.F(false), + PublicName: cloudflare.F("Business Plan"), + Scope: cloudflare.F("zone"), + Sets: cloudflare.F([]string{"string", "string", "string"}), + }), + Zone: cloudflare.F(zones.SubscriptionNewParamsZone{}), + }, + ) + 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 TestSubscriptionList(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("user@example.com"), + ) + _, err := client.Zones.Subscriptions.List(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()) + } +} + +func TestSubscriptionGet(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("user@example.com"), + ) + _, err := client.Zones.Subscriptions.Get(context.TODO(), "506e3185e9c882d175a2d0cb0093d9f2") + 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/zones/worker.go b/zones/worker.go new file mode 100644 index 00000000000..e2468ce1f2c --- /dev/null +++ b/zones/worker.go @@ -0,0 +1,26 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "github.com/cloudflare/cloudflare-go/option" +) + +// WorkerService 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 [NewWorkerService] method instead. +type WorkerService struct { + Options []option.RequestOption + Script *WorkerScriptService +} + +// NewWorkerService 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 NewWorkerService(opts ...option.RequestOption) (r *WorkerService) { + r = &WorkerService{} + r.Options = opts + r.Script = NewWorkerScriptService(opts...) + return +} diff --git a/zones/workerscript.go b/zones/workerscript.go new file mode 100644 index 00000000000..50a03b3ce8e --- /dev/null +++ b/zones/workerscript.go @@ -0,0 +1,180 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones + +import ( + "context" + "fmt" + "net/http" + "reflect" + + "github.com/cloudflare/cloudflare-go/internal/apijson" + "github.com/cloudflare/cloudflare-go/internal/param" + "github.com/cloudflare/cloudflare-go/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/internal/shared" + "github.com/cloudflare/cloudflare-go/option" + "github.com/tidwall/gjson" +) + +// WorkerScriptService 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 [NewWorkerScriptService] method +// instead. +type WorkerScriptService struct { + Options []option.RequestOption +} + +// NewWorkerScriptService 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 NewWorkerScriptService(opts ...option.RequestOption) (r *WorkerScriptService) { + r = &WorkerScriptService{} + r.Options = opts + return +} + +// Upload a worker, or a new version of a worker. +func (r *WorkerScriptService) Update(ctx context.Context, body WorkerScriptUpdateParams, opts ...option.RequestOption) (res *WorkerScriptUpdateResponse, err error) { + opts = append(r.Options[:], opts...) + var env WorkerScriptUpdateResponseEnvelope + path := fmt.Sprintf("zones/%s/workers/script", body.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) + if err != nil { + return + } + res = &env.Result + return +} + +// Delete your Worker. This call has no response body on a successful delete. +func (r *WorkerScriptService) Delete(ctx context.Context, body WorkerScriptDeleteParams, opts ...option.RequestOption) (err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) + path := fmt.Sprintf("zones/%s/workers/script", body.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) + return +} + +// Fetch raw script content for your worker. Note this is the original script +// content, not JSON encoded. +func (r *WorkerScriptService) Get(ctx context.Context, query WorkerScriptGetParams, opts ...option.RequestOption) (res *http.Response, err error) { + opts = append(r.Options[:], opts...) + opts = append([]option.RequestOption{option.WithHeader("Accept", "undefined")}, opts...) + path := fmt.Sprintf("zones/%s/workers/script", query.ZoneID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) + return +} + +// Union satisfied by [zones.WorkerScriptUpdateResponseUnknown] or +// [shared.UnionString]. +type WorkerScriptUpdateResponse interface { + ImplementsZonesWorkerScriptUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*WorkerScriptUpdateResponse)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +type WorkerScriptUpdateParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type WorkerScriptUpdateResponseEnvelope struct { + Errors []WorkerScriptUpdateResponseEnvelopeErrors `json:"errors,required"` + Messages []WorkerScriptUpdateResponseEnvelopeMessages `json:"messages,required"` + Result WorkerScriptUpdateResponse `json:"result,required"` + // Whether the API call was successful + Success WorkerScriptUpdateResponseEnvelopeSuccess `json:"success,required"` + JSON workerScriptUpdateResponseEnvelopeJSON `json:"-"` +} + +// workerScriptUpdateResponseEnvelopeJSON contains the JSON metadata for the struct +// [WorkerScriptUpdateResponseEnvelope] +type workerScriptUpdateResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkerScriptUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workerScriptUpdateResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type WorkerScriptUpdateResponseEnvelopeErrors struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON workerScriptUpdateResponseEnvelopeErrorsJSON `json:"-"` +} + +// workerScriptUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [WorkerScriptUpdateResponseEnvelopeErrors] +type workerScriptUpdateResponseEnvelopeErrorsJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkerScriptUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workerScriptUpdateResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +type WorkerScriptUpdateResponseEnvelopeMessages struct { + Code int64 `json:"code,required"` + Message string `json:"message,required"` + JSON workerScriptUpdateResponseEnvelopeMessagesJSON `json:"-"` +} + +// workerScriptUpdateResponseEnvelopeMessagesJSON contains the JSON metadata for +// the struct [WorkerScriptUpdateResponseEnvelopeMessages] +type workerScriptUpdateResponseEnvelopeMessagesJSON struct { + Code apijson.Field + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *WorkerScriptUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r workerScriptUpdateResponseEnvelopeMessagesJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type WorkerScriptUpdateResponseEnvelopeSuccess bool + +const ( + WorkerScriptUpdateResponseEnvelopeSuccessTrue WorkerScriptUpdateResponseEnvelopeSuccess = true +) + +type WorkerScriptDeleteParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} + +type WorkerScriptGetParams struct { + // Identifier + ZoneID param.Field[string] `path:"zone_id,required"` +} diff --git a/zones/workerscript_test.go b/zones/workerscript_test.go new file mode 100644 index 00000000000..0c78a0881a2 --- /dev/null +++ b/zones/workerscript_test.go @@ -0,0 +1,109 @@ +// File generated from our OpenAPI spec by Stainless. + +package zones_test + +import ( + "bytes" + "context" + "errors" + "io" + "net/http" + "net/http/httptest" + "os" + "testing" + + "github.com/cloudflare/cloudflare-go" + "github.com/cloudflare/cloudflare-go/internal/testutil" + "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" +) + +func TestWorkerScriptUpdate(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("user@example.com"), + ) + _, err := client.Zones.Workers.Script.Update(context.TODO(), zones.WorkerScriptUpdateParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestWorkerScriptDelete(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("user@example.com"), + ) + err := client.Zones.Workers.Script.Delete(context.TODO(), zones.WorkerScriptDeleteParams{ + ZoneID: cloudflare.F("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()) + } +} + +func TestWorkerScriptGet(t *testing.T) { + t.Skip("skipped: tests are disabled for the time being") + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(200) + w.Write([]byte("abc")) + })) + defer server.Close() + baseURL := server.URL + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("user@example.com"), + ) + resp, err := client.Zones.Workers.Script.Get(context.TODO(), zones.WorkerScriptGetParams{ + ZoneID: cloudflare.F("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()) + } + defer resp.Body.Close() + + b, err := io.ReadAll(resp.Body) + 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()) + } + if !bytes.Equal(b, []byte("abc")) { + t.Fatalf("return value not %s: %s", "abc", b) + } +} diff --git a/zone.go b/zones/zone.go similarity index 98% rename from zone.go rename to zones/zone.go index 7c8bdbf2d7f..061e77c9726 100644 --- a/zone.go +++ b/zones/zone.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare +package zones import ( "context" @@ -23,12 +23,12 @@ import ( // directly, and instead use the [NewZoneService] method instead. type ZoneService struct { Options []option.RequestOption - ActivationCheck *ZoneActivationCheckService - Settings *ZoneSettingService - CustomNameservers *ZoneCustomNameserverService - Holds *ZoneHoldService - Workers *ZoneWorkerService - Subscriptions *ZoneSubscriptionService + ActivationCheck *ActivationCheckService + Settings *SettingService + CustomNameservers *CustomNameserverService + Holds *HoldService + Workers *WorkerService + Subscriptions *SubscriptionService } // NewZoneService generates a new service that applies the given options to each @@ -37,12 +37,12 @@ type ZoneService struct { func NewZoneService(opts ...option.RequestOption) (r *ZoneService) { r = &ZoneService{} r.Options = opts - r.ActivationCheck = NewZoneActivationCheckService(opts...) - r.Settings = NewZoneSettingService(opts...) - r.CustomNameservers = NewZoneCustomNameserverService(opts...) - r.Holds = NewZoneHoldService(opts...) - r.Workers = NewZoneWorkerService(opts...) - r.Subscriptions = NewZoneSubscriptionService(opts...) + r.ActivationCheck = NewActivationCheckService(opts...) + r.Settings = NewSettingService(opts...) + r.CustomNameservers = NewCustomNameserverService(opts...) + r.Holds = NewHoldService(opts...) + r.Workers = NewWorkerService(opts...) + r.Subscriptions = NewSubscriptionService(opts...) return } diff --git a/zone_test.go b/zones/zone_test.go similarity index 80% rename from zone_test.go rename to zones/zone_test.go index 2148f43897e..dba8f10df7d 100644 --- a/zone_test.go +++ b/zones/zone_test.go @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package cloudflare_test +package zones_test import ( "context" @@ -11,6 +11,7 @@ import ( "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/internal/testutil" "github.com/cloudflare/cloudflare-go/option" + "github.com/cloudflare/cloudflare-go/zones" ) func TestZoneNewWithOptionalParams(t *testing.T) { @@ -27,12 +28,12 @@ func TestZoneNewWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Zones.New(context.TODO(), cloudflare.ZoneNewParams{ - Account: cloudflare.F(cloudflare.ZoneNewParamsAccount{ + _, err := client.Zones.New(context.TODO(), zones.ZoneNewParams{ + Account: cloudflare.F(zones.ZoneNewParamsAccount{ ID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }), Name: cloudflare.F("example.com"), - Type: cloudflare.F(cloudflare.ZoneNewParamsTypeFull), + Type: cloudflare.F(zones.ZoneNewParamsTypeFull), }) if err != nil { var apierr *cloudflare.Error @@ -57,18 +58,18 @@ func TestZoneListWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Zones.List(context.TODO(), cloudflare.ZoneListParams{ - Account: cloudflare.F(cloudflare.ZoneListParamsAccount{ + _, err := client.Zones.List(context.TODO(), zones.ZoneListParams{ + Account: cloudflare.F(zones.ZoneListParamsAccount{ ID: cloudflare.F("string"), Name: cloudflare.F("string"), }), - Direction: cloudflare.F(cloudflare.ZoneListParamsDirectionDesc), - Match: cloudflare.F(cloudflare.ZoneListParamsMatchAny), + Direction: cloudflare.F(zones.ZoneListParamsDirectionDesc), + Match: cloudflare.F(zones.ZoneListParamsMatchAny), Name: cloudflare.F("string"), - Order: cloudflare.F(cloudflare.ZoneListParamsOrderStatus), + Order: cloudflare.F(zones.ZoneListParamsOrderStatus), Page: cloudflare.F(1.000000), PerPage: cloudflare.F(5.000000), - Status: cloudflare.F(cloudflare.ZoneListParamsStatusInitializing), + Status: cloudflare.F(zones.ZoneListParamsStatusInitializing), }) if err != nil { var apierr *cloudflare.Error @@ -93,7 +94,7 @@ func TestZoneDelete(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Zones.Delete(context.TODO(), cloudflare.ZoneDeleteParams{ + _, err := client.Zones.Delete(context.TODO(), zones.ZoneDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { @@ -119,12 +120,12 @@ func TestZoneEditWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Zones.Edit(context.TODO(), cloudflare.ZoneEditParams{ + _, err := client.Zones.Edit(context.TODO(), zones.ZoneEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Plan: cloudflare.F(cloudflare.ZoneEditParamsPlan{ + Plan: cloudflare.F(zones.ZoneEditParamsPlan{ ID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }), - Type: cloudflare.F(cloudflare.ZoneEditParamsTypeFull), + Type: cloudflare.F(zones.ZoneEditParamsTypeFull), VanityNameServers: cloudflare.F([]string{"ns1.example.com", "ns2.example.com"}), }) if err != nil { @@ -150,7 +151,7 @@ func TestZoneGet(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.Zones.Get(context.TODO(), cloudflare.ZoneGetParams{ + _, err := client.Zones.Get(context.TODO(), zones.ZoneGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { diff --git a/zonesetting.go b/zonesetting.go deleted file mode 100644 index 632e41b2cfd..00000000000 --- a/zonesetting.go +++ /dev/null @@ -1,10314 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZoneSettingService 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 [NewZoneSettingService] method -// instead. -type ZoneSettingService struct { - Options []option.RequestOption - ZeroRTT *ZoneSettingZeroRTTService - AdvancedDDOS *ZoneSettingAdvancedDDOSService - AlwaysOnline *ZoneSettingAlwaysOnlineService - AlwaysUseHTTPS *ZoneSettingAlwaysUseHTTPSService - AutomaticHTTPSRewrites *ZoneSettingAutomaticHTTPSRewriteService - AutomaticPlatformOptimization *ZoneSettingAutomaticPlatformOptimizationService - Brotli *ZoneSettingBrotliService - BrowserCacheTTL *ZoneSettingBrowserCacheTTLService - BrowserCheck *ZoneSettingBrowserCheckService - CacheLevel *ZoneSettingCacheLevelService - ChallengeTTL *ZoneSettingChallengeTTLService - Ciphers *ZoneSettingCipherService - DevelopmentMode *ZoneSettingDevelopmentModeService - EarlyHints *ZoneSettingEarlyHintService - EmailObfuscation *ZoneSettingEmailObfuscationService - H2Prioritization *ZoneSettingH2PrioritizationService - HotlinkProtection *ZoneSettingHotlinkProtectionService - HTTP2 *ZoneSettingHTTP2Service - HTTP3 *ZoneSettingHTTP3Service - ImageResizing *ZoneSettingImageResizingService - IPGeolocation *ZoneSettingIPGeolocationService - IPV6 *ZoneSettingIPV6Service - MinTLSVersion *ZoneSettingMinTLSVersionService - Minify *ZoneSettingMinifyService - Mirage *ZoneSettingMirageService - MobileRedirect *ZoneSettingMobileRedirectService - NEL *ZoneSettingNELService - OpportunisticEncryption *ZoneSettingOpportunisticEncryptionService - OpportunisticOnion *ZoneSettingOpportunisticOnionService - OrangeToOrange *ZoneSettingOrangeToOrangeService - OriginErrorPagePassThru *ZoneSettingOriginErrorPagePassThruService - OriginMaxHTTPVersion *ZoneSettingOriginMaxHTTPVersionService - Polish *ZoneSettingPolishService - PrefetchPreload *ZoneSettingPrefetchPreloadService - ProxyReadTimeout *ZoneSettingProxyReadTimeoutService - PseudoIPV4 *ZoneSettingPseudoIPV4Service - ResponseBuffering *ZoneSettingResponseBufferingService - RocketLoader *ZoneSettingRocketLoaderService - SecurityHeaders *ZoneSettingSecurityHeaderService - SecurityLevel *ZoneSettingSecurityLevelService - ServerSideExcludes *ZoneSettingServerSideExcludeService - SortQueryStringForCache *ZoneSettingSortQueryStringForCacheService - SSL *ZoneSettingSSLService - SSLRecommender *ZoneSettingSSLRecommenderService - TLS1_3 *ZoneSettingTLS1_3Service - TLSClientAuth *ZoneSettingTLSClientAuthService - TrueClientIPHeader *ZoneSettingTrueClientIPHeaderService - WAF *ZoneSettingWAFService - Webp *ZoneSettingWebpService - Websocket *ZoneSettingWebsocketService - FontSettings *ZoneSettingFontSettingService -} - -// NewZoneSettingService 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 NewZoneSettingService(opts ...option.RequestOption) (r *ZoneSettingService) { - r = &ZoneSettingService{} - r.Options = opts - r.ZeroRTT = NewZoneSettingZeroRTTService(opts...) - r.AdvancedDDOS = NewZoneSettingAdvancedDDOSService(opts...) - r.AlwaysOnline = NewZoneSettingAlwaysOnlineService(opts...) - r.AlwaysUseHTTPS = NewZoneSettingAlwaysUseHTTPSService(opts...) - r.AutomaticHTTPSRewrites = NewZoneSettingAutomaticHTTPSRewriteService(opts...) - r.AutomaticPlatformOptimization = NewZoneSettingAutomaticPlatformOptimizationService(opts...) - r.Brotli = NewZoneSettingBrotliService(opts...) - r.BrowserCacheTTL = NewZoneSettingBrowserCacheTTLService(opts...) - r.BrowserCheck = NewZoneSettingBrowserCheckService(opts...) - r.CacheLevel = NewZoneSettingCacheLevelService(opts...) - r.ChallengeTTL = NewZoneSettingChallengeTTLService(opts...) - r.Ciphers = NewZoneSettingCipherService(opts...) - r.DevelopmentMode = NewZoneSettingDevelopmentModeService(opts...) - r.EarlyHints = NewZoneSettingEarlyHintService(opts...) - r.EmailObfuscation = NewZoneSettingEmailObfuscationService(opts...) - r.H2Prioritization = NewZoneSettingH2PrioritizationService(opts...) - r.HotlinkProtection = NewZoneSettingHotlinkProtectionService(opts...) - r.HTTP2 = NewZoneSettingHTTP2Service(opts...) - r.HTTP3 = NewZoneSettingHTTP3Service(opts...) - r.ImageResizing = NewZoneSettingImageResizingService(opts...) - r.IPGeolocation = NewZoneSettingIPGeolocationService(opts...) - r.IPV6 = NewZoneSettingIPV6Service(opts...) - r.MinTLSVersion = NewZoneSettingMinTLSVersionService(opts...) - r.Minify = NewZoneSettingMinifyService(opts...) - r.Mirage = NewZoneSettingMirageService(opts...) - r.MobileRedirect = NewZoneSettingMobileRedirectService(opts...) - r.NEL = NewZoneSettingNELService(opts...) - r.OpportunisticEncryption = NewZoneSettingOpportunisticEncryptionService(opts...) - r.OpportunisticOnion = NewZoneSettingOpportunisticOnionService(opts...) - r.OrangeToOrange = NewZoneSettingOrangeToOrangeService(opts...) - r.OriginErrorPagePassThru = NewZoneSettingOriginErrorPagePassThruService(opts...) - r.OriginMaxHTTPVersion = NewZoneSettingOriginMaxHTTPVersionService(opts...) - r.Polish = NewZoneSettingPolishService(opts...) - r.PrefetchPreload = NewZoneSettingPrefetchPreloadService(opts...) - r.ProxyReadTimeout = NewZoneSettingProxyReadTimeoutService(opts...) - r.PseudoIPV4 = NewZoneSettingPseudoIPV4Service(opts...) - r.ResponseBuffering = NewZoneSettingResponseBufferingService(opts...) - r.RocketLoader = NewZoneSettingRocketLoaderService(opts...) - r.SecurityHeaders = NewZoneSettingSecurityHeaderService(opts...) - r.SecurityLevel = NewZoneSettingSecurityLevelService(opts...) - r.ServerSideExcludes = NewZoneSettingServerSideExcludeService(opts...) - r.SortQueryStringForCache = NewZoneSettingSortQueryStringForCacheService(opts...) - r.SSL = NewZoneSettingSSLService(opts...) - r.SSLRecommender = NewZoneSettingSSLRecommenderService(opts...) - r.TLS1_3 = NewZoneSettingTLS1_3Service(opts...) - r.TLSClientAuth = NewZoneSettingTLSClientAuthService(opts...) - r.TrueClientIPHeader = NewZoneSettingTrueClientIPHeaderService(opts...) - r.WAF = NewZoneSettingWAFService(opts...) - r.Webp = NewZoneSettingWebpService(opts...) - r.Websocket = NewZoneSettingWebsocketService(opts...) - r.FontSettings = NewZoneSettingFontSettingService(opts...) - return -} - -// Edit settings for a zone. -func (r *ZoneSettingService) Edit(ctx context.Context, params ZoneSettingEditParams, opts ...option.RequestOption) (res *[]ZoneSettingEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Available settings for your user in relation to a zone. -func (r *ZoneSettingService) Get(ctx context.Context, query ZoneSettingGetParams, opts ...option.RequestOption) (res *[]ZoneSettingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// 0-RTT session resumption enabled for this zone. -// -// Union satisfied by [ZoneSettingEditResponseZones0rtt], -// [ZoneSettingEditResponseZonesAdvancedDDOS], -// [ZoneSettingEditResponseZonesAlwaysOnline], -// [ZoneSettingEditResponseZonesAlwaysUseHTTPS], -// [ZoneSettingEditResponseZonesAutomaticHTTPSRewrites], -// [ZoneSettingEditResponseZonesBrotli], -// [ZoneSettingEditResponseZonesBrowserCacheTTL], -// [ZoneSettingEditResponseZonesBrowserCheck], -// [ZoneSettingEditResponseZonesCacheLevel], -// [ZoneSettingEditResponseZonesChallengeTTL], -// [ZoneSettingEditResponseZonesCiphers], -// [ZoneSettingEditResponseZonesCNAMEFlattening], -// [ZoneSettingEditResponseZonesDevelopmentMode], -// [ZoneSettingEditResponseZonesEarlyHints], -// [ZoneSettingEditResponseZonesEdgeCacheTTL], -// [ZoneSettingEditResponseZonesEmailObfuscation], -// [ZoneSettingEditResponseZonesH2Prioritization], -// [ZoneSettingEditResponseZonesHotlinkProtection], -// [ZoneSettingEditResponseZonesHTTP2], [ZoneSettingEditResponseZonesHTTP3], -// [ZoneSettingEditResponseZonesImageResizing], -// [ZoneSettingEditResponseZonesIPGeolocation], [ZoneSettingEditResponseZonesIPV6], -// [ZoneSettingEditResponseZonesMaxUpload], -// [ZoneSettingEditResponseZonesMinTLSVersion], -// [ZoneSettingEditResponseZonesMinify], [ZoneSettingEditResponseZonesMirage], -// [ZoneSettingEditResponseZonesMobileRedirect], [ZoneSettingEditResponseZonesNEL], -// [ZoneSettingEditResponseZonesOpportunisticEncryption], -// [ZoneSettingEditResponseZonesOpportunisticOnion], -// [ZoneSettingEditResponseZonesOrangeToOrange], -// [ZoneSettingEditResponseZonesOriginErrorPagePassThru], -// [ZoneSettingEditResponseZonesPolish], -// [ZoneSettingEditResponseZonesPrefetchPreload], -// [ZoneSettingEditResponseZonesProxyReadTimeout], -// [ZoneSettingEditResponseZonesPseudoIPV4], -// [ZoneSettingEditResponseZonesResponseBuffering], -// [ZoneSettingEditResponseZonesRocketLoader], -// [ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimization], -// [ZoneSettingEditResponseZonesSecurityHeader], -// [ZoneSettingEditResponseZonesSecurityLevel], -// [ZoneSettingEditResponseZonesServerSideExclude], -// [ZoneSettingEditResponseZonesSha1Support], -// [ZoneSettingEditResponseZonesSortQueryStringForCache], -// [ZoneSettingEditResponseZonesSSL], [ZoneSettingEditResponseZonesSSLRecommender], -// [ZoneSettingEditResponseZonesTLS1_2Only], [ZoneSettingEditResponseZonesTLS1_3], -// [ZoneSettingEditResponseZonesTLSClientAuth], -// [ZoneSettingEditResponseZonesTrueClientIPHeader], -// [ZoneSettingEditResponseZonesWAF], [ZoneSettingEditResponseZonesWebp] or -// [ZoneSettingEditResponseZonesWebsockets]. -type ZoneSettingEditResponse interface { - implementsZoneSettingEditResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZoneSettingEditResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZones0rtt{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesAdvancedDDOS{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesAlwaysOnline{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesAlwaysUseHTTPS{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesAutomaticHTTPSRewrites{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesBrotli{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesBrowserCacheTTL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesBrowserCheck{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesCacheLevel{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesChallengeTTL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesCiphers{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesCNAMEFlattening{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesDevelopmentMode{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesEarlyHints{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesEdgeCacheTTL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesEmailObfuscation{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesH2Prioritization{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesHotlinkProtection{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesHTTP2{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesHTTP3{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesImageResizing{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesIPGeolocation{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesIPV6{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesMaxUpload{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesMinTLSVersion{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesMinify{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesMirage{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesMobileRedirect{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesNEL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesOpportunisticEncryption{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesOpportunisticOnion{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesOrangeToOrange{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesOriginErrorPagePassThru{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesPolish{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesPrefetchPreload{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesProxyReadTimeout{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesPseudoIPV4{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesResponseBuffering{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesRocketLoader{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimization{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesSecurityHeader{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesSecurityLevel{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesServerSideExclude{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesSha1Support{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesSortQueryStringForCache{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesSSL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesSSLRecommender{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesTLS1_2Only{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesTLS1_3{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesTLSClientAuth{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesTrueClientIPHeader{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesWAF{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesWebp{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingEditResponseZonesWebsockets{}), - }, - ) -} - -// 0-RTT session resumption enabled for this zone. -type ZoneSettingEditResponseZones0rtt struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZones0rttID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZones0rttValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZones0rttEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZones0rttJSON `json:"-"` -} - -// zoneSettingEditResponseZones0rttJSON contains the JSON metadata for the struct -// [ZoneSettingEditResponseZones0rtt] -type zoneSettingEditResponseZones0rttJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZones0rtt) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZones0rttJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZones0rtt) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZones0rttID string - -const ( - ZoneSettingEditResponseZones0rttID0rtt ZoneSettingEditResponseZones0rttID = "0rtt" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZones0rttValue string - -const ( - ZoneSettingEditResponseZones0rttValueOn ZoneSettingEditResponseZones0rttValue = "on" - ZoneSettingEditResponseZones0rttValueOff ZoneSettingEditResponseZones0rttValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZones0rttEditable bool - -const ( - ZoneSettingEditResponseZones0rttEditableTrue ZoneSettingEditResponseZones0rttEditable = true - ZoneSettingEditResponseZones0rttEditableFalse ZoneSettingEditResponseZones0rttEditable = false -) - -// 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. -type ZoneSettingEditResponseZonesAdvancedDDOS struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesAdvancedDDOSID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesAdvancedDDOSValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesAdvancedDDOSEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesAdvancedDDOSJSON `json:"-"` -} - -// zoneSettingEditResponseZonesAdvancedDDOSJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesAdvancedDDOS] -type zoneSettingEditResponseZonesAdvancedDDOSJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesAdvancedDDOS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesAdvancedDDOSJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesAdvancedDDOS) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesAdvancedDDOSID string - -const ( - ZoneSettingEditResponseZonesAdvancedDDOSIDAdvancedDDOS ZoneSettingEditResponseZonesAdvancedDDOSID = "advanced_ddos" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesAdvancedDDOSValue string - -const ( - ZoneSettingEditResponseZonesAdvancedDDOSValueOn ZoneSettingEditResponseZonesAdvancedDDOSValue = "on" - ZoneSettingEditResponseZonesAdvancedDDOSValueOff ZoneSettingEditResponseZonesAdvancedDDOSValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesAdvancedDDOSEditable bool - -const ( - ZoneSettingEditResponseZonesAdvancedDDOSEditableTrue ZoneSettingEditResponseZonesAdvancedDDOSEditable = true - ZoneSettingEditResponseZonesAdvancedDDOSEditableFalse ZoneSettingEditResponseZonesAdvancedDDOSEditable = false -) - -// When enabled, Cloudflare serves limited copies of web pages available from the -// [Internet Archive's Wayback Machine](https://archive.org/web/) if your server is -// offline. Refer to -// [Always Online](https://developers.cloudflare.com/cache/about/always-online) for -// more information. -type ZoneSettingEditResponseZonesAlwaysOnline struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesAlwaysOnlineID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesAlwaysOnlineValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesAlwaysOnlineEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesAlwaysOnlineJSON `json:"-"` -} - -// zoneSettingEditResponseZonesAlwaysOnlineJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesAlwaysOnline] -type zoneSettingEditResponseZonesAlwaysOnlineJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesAlwaysOnline) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesAlwaysOnlineJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesAlwaysOnline) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesAlwaysOnlineID string - -const ( - ZoneSettingEditResponseZonesAlwaysOnlineIDAlwaysOnline ZoneSettingEditResponseZonesAlwaysOnlineID = "always_online" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesAlwaysOnlineValue string - -const ( - ZoneSettingEditResponseZonesAlwaysOnlineValueOn ZoneSettingEditResponseZonesAlwaysOnlineValue = "on" - ZoneSettingEditResponseZonesAlwaysOnlineValueOff ZoneSettingEditResponseZonesAlwaysOnlineValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesAlwaysOnlineEditable bool - -const ( - ZoneSettingEditResponseZonesAlwaysOnlineEditableTrue ZoneSettingEditResponseZonesAlwaysOnlineEditable = true - ZoneSettingEditResponseZonesAlwaysOnlineEditableFalse ZoneSettingEditResponseZonesAlwaysOnlineEditable = false -) - -// Reply to all requests for URLs that use "http" with a 301 redirect to the -// equivalent "https" URL. If you only want to redirect for a subset of requests, -// consider creating an "Always use HTTPS" page rule. -type ZoneSettingEditResponseZonesAlwaysUseHTTPS struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesAlwaysUseHTTPSID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesAlwaysUseHTTPSValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesAlwaysUseHTTPSEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesAlwaysUseHTTPSJSON `json:"-"` -} - -// zoneSettingEditResponseZonesAlwaysUseHTTPSJSON contains the JSON metadata for -// the struct [ZoneSettingEditResponseZonesAlwaysUseHTTPS] -type zoneSettingEditResponseZonesAlwaysUseHTTPSJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesAlwaysUseHTTPS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesAlwaysUseHTTPSJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesAlwaysUseHTTPS) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesAlwaysUseHTTPSID string - -const ( - ZoneSettingEditResponseZonesAlwaysUseHTTPSIDAlwaysUseHTTPS ZoneSettingEditResponseZonesAlwaysUseHTTPSID = "always_use_https" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesAlwaysUseHTTPSValue string - -const ( - ZoneSettingEditResponseZonesAlwaysUseHTTPSValueOn ZoneSettingEditResponseZonesAlwaysUseHTTPSValue = "on" - ZoneSettingEditResponseZonesAlwaysUseHTTPSValueOff ZoneSettingEditResponseZonesAlwaysUseHTTPSValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesAlwaysUseHTTPSEditable bool - -const ( - ZoneSettingEditResponseZonesAlwaysUseHTTPSEditableTrue ZoneSettingEditResponseZonesAlwaysUseHTTPSEditable = true - ZoneSettingEditResponseZonesAlwaysUseHTTPSEditableFalse ZoneSettingEditResponseZonesAlwaysUseHTTPSEditable = false -) - -// Enable the Automatic HTTPS Rewrites feature for this zone. -type ZoneSettingEditResponseZonesAutomaticHTTPSRewrites struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesAutomaticHTTPSRewritesID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesAutomaticHTTPSRewritesValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesAutomaticHTTPSRewritesEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesAutomaticHTTPSRewritesJSON `json:"-"` -} - -// zoneSettingEditResponseZonesAutomaticHTTPSRewritesJSON contains the JSON -// metadata for the struct [ZoneSettingEditResponseZonesAutomaticHTTPSRewrites] -type zoneSettingEditResponseZonesAutomaticHTTPSRewritesJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesAutomaticHTTPSRewrites) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesAutomaticHTTPSRewritesJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesAutomaticHTTPSRewrites) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesAutomaticHTTPSRewritesID string - -const ( - ZoneSettingEditResponseZonesAutomaticHTTPSRewritesIDAutomaticHTTPSRewrites ZoneSettingEditResponseZonesAutomaticHTTPSRewritesID = "automatic_https_rewrites" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesAutomaticHTTPSRewritesValue string - -const ( - ZoneSettingEditResponseZonesAutomaticHTTPSRewritesValueOn ZoneSettingEditResponseZonesAutomaticHTTPSRewritesValue = "on" - ZoneSettingEditResponseZonesAutomaticHTTPSRewritesValueOff ZoneSettingEditResponseZonesAutomaticHTTPSRewritesValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesAutomaticHTTPSRewritesEditable bool - -const ( - ZoneSettingEditResponseZonesAutomaticHTTPSRewritesEditableTrue ZoneSettingEditResponseZonesAutomaticHTTPSRewritesEditable = true - ZoneSettingEditResponseZonesAutomaticHTTPSRewritesEditableFalse ZoneSettingEditResponseZonesAutomaticHTTPSRewritesEditable = false -) - -// When the client requesting an asset supports the Brotli compression algorithm, -// Cloudflare will serve a Brotli compressed version of the asset. -type ZoneSettingEditResponseZonesBrotli struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesBrotliID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesBrotliValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesBrotliEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesBrotliJSON `json:"-"` -} - -// zoneSettingEditResponseZonesBrotliJSON contains the JSON metadata for the struct -// [ZoneSettingEditResponseZonesBrotli] -type zoneSettingEditResponseZonesBrotliJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesBrotli) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesBrotliJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesBrotli) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesBrotliID string - -const ( - ZoneSettingEditResponseZonesBrotliIDBrotli ZoneSettingEditResponseZonesBrotliID = "brotli" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesBrotliValue string - -const ( - ZoneSettingEditResponseZonesBrotliValueOff ZoneSettingEditResponseZonesBrotliValue = "off" - ZoneSettingEditResponseZonesBrotliValueOn ZoneSettingEditResponseZonesBrotliValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesBrotliEditable bool - -const ( - ZoneSettingEditResponseZonesBrotliEditableTrue ZoneSettingEditResponseZonesBrotliEditable = true - ZoneSettingEditResponseZonesBrotliEditableFalse ZoneSettingEditResponseZonesBrotliEditable = false -) - -// Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources -// will remain on your visitors' computers. Cloudflare will honor any larger times -// specified by your server. -// (https://support.cloudflare.com/hc/en-us/articles/200168276). -type ZoneSettingEditResponseZonesBrowserCacheTTL struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesBrowserCacheTTLID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesBrowserCacheTTLValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesBrowserCacheTTLEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesBrowserCacheTTLJSON `json:"-"` -} - -// zoneSettingEditResponseZonesBrowserCacheTTLJSON contains the JSON metadata for -// the struct [ZoneSettingEditResponseZonesBrowserCacheTTL] -type zoneSettingEditResponseZonesBrowserCacheTTLJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesBrowserCacheTTL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesBrowserCacheTTLJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesBrowserCacheTTL) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesBrowserCacheTTLID string - -const ( - ZoneSettingEditResponseZonesBrowserCacheTTLIDBrowserCacheTTL ZoneSettingEditResponseZonesBrowserCacheTTLID = "browser_cache_ttl" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesBrowserCacheTTLValue float64 - -const ( - ZoneSettingEditResponseZonesBrowserCacheTTLValue0 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 0 - ZoneSettingEditResponseZonesBrowserCacheTTLValue30 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 30 - ZoneSettingEditResponseZonesBrowserCacheTTLValue60 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 60 - ZoneSettingEditResponseZonesBrowserCacheTTLValue120 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 120 - ZoneSettingEditResponseZonesBrowserCacheTTLValue300 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 300 - ZoneSettingEditResponseZonesBrowserCacheTTLValue1200 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 1200 - ZoneSettingEditResponseZonesBrowserCacheTTLValue1800 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 1800 - ZoneSettingEditResponseZonesBrowserCacheTTLValue3600 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 3600 - ZoneSettingEditResponseZonesBrowserCacheTTLValue7200 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 7200 - ZoneSettingEditResponseZonesBrowserCacheTTLValue10800 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 10800 - ZoneSettingEditResponseZonesBrowserCacheTTLValue14400 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 14400 - ZoneSettingEditResponseZonesBrowserCacheTTLValue18000 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 18000 - ZoneSettingEditResponseZonesBrowserCacheTTLValue28800 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 28800 - ZoneSettingEditResponseZonesBrowserCacheTTLValue43200 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 43200 - ZoneSettingEditResponseZonesBrowserCacheTTLValue57600 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 57600 - ZoneSettingEditResponseZonesBrowserCacheTTLValue72000 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 72000 - ZoneSettingEditResponseZonesBrowserCacheTTLValue86400 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 86400 - ZoneSettingEditResponseZonesBrowserCacheTTLValue172800 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 172800 - ZoneSettingEditResponseZonesBrowserCacheTTLValue259200 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 259200 - ZoneSettingEditResponseZonesBrowserCacheTTLValue345600 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 345600 - ZoneSettingEditResponseZonesBrowserCacheTTLValue432000 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 432000 - ZoneSettingEditResponseZonesBrowserCacheTTLValue691200 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 691200 - ZoneSettingEditResponseZonesBrowserCacheTTLValue1382400 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 1382400 - ZoneSettingEditResponseZonesBrowserCacheTTLValue2073600 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 2073600 - ZoneSettingEditResponseZonesBrowserCacheTTLValue2678400 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 2678400 - ZoneSettingEditResponseZonesBrowserCacheTTLValue5356800 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 5356800 - ZoneSettingEditResponseZonesBrowserCacheTTLValue16070400 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 16070400 - ZoneSettingEditResponseZonesBrowserCacheTTLValue31536000 ZoneSettingEditResponseZonesBrowserCacheTTLValue = 31536000 -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesBrowserCacheTTLEditable bool - -const ( - ZoneSettingEditResponseZonesBrowserCacheTTLEditableTrue ZoneSettingEditResponseZonesBrowserCacheTTLEditable = true - ZoneSettingEditResponseZonesBrowserCacheTTLEditableFalse ZoneSettingEditResponseZonesBrowserCacheTTLEditable = false -) - -// Browser Integrity Check is similar to Bad Behavior and looks for common HTTP -// headers abused most commonly by spammers and denies access to your page. It will -// also challenge visitors that do not have a user agent or a non standard user -// agent (also commonly used by abuse bots, crawlers or visitors). -// (https://support.cloudflare.com/hc/en-us/articles/200170086). -type ZoneSettingEditResponseZonesBrowserCheck struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesBrowserCheckID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesBrowserCheckValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesBrowserCheckEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesBrowserCheckJSON `json:"-"` -} - -// zoneSettingEditResponseZonesBrowserCheckJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesBrowserCheck] -type zoneSettingEditResponseZonesBrowserCheckJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesBrowserCheck) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesBrowserCheckJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesBrowserCheck) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesBrowserCheckID string - -const ( - ZoneSettingEditResponseZonesBrowserCheckIDBrowserCheck ZoneSettingEditResponseZonesBrowserCheckID = "browser_check" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesBrowserCheckValue string - -const ( - ZoneSettingEditResponseZonesBrowserCheckValueOn ZoneSettingEditResponseZonesBrowserCheckValue = "on" - ZoneSettingEditResponseZonesBrowserCheckValueOff ZoneSettingEditResponseZonesBrowserCheckValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesBrowserCheckEditable bool - -const ( - ZoneSettingEditResponseZonesBrowserCheckEditableTrue ZoneSettingEditResponseZonesBrowserCheckEditable = true - ZoneSettingEditResponseZonesBrowserCheckEditableFalse ZoneSettingEditResponseZonesBrowserCheckEditable = false -) - -// Cache Level functions based off the setting level. The basic setting will cache -// most static resources (i.e., css, images, and JavaScript). The simplified -// setting will ignore the query string when delivering a cached resource. The -// aggressive setting will cache all static resources, including ones with a query -// string. (https://support.cloudflare.com/hc/en-us/articles/200168256). -type ZoneSettingEditResponseZonesCacheLevel struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesCacheLevelID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesCacheLevelValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesCacheLevelEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesCacheLevelJSON `json:"-"` -} - -// zoneSettingEditResponseZonesCacheLevelJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesCacheLevel] -type zoneSettingEditResponseZonesCacheLevelJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesCacheLevel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesCacheLevelJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesCacheLevel) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesCacheLevelID string - -const ( - ZoneSettingEditResponseZonesCacheLevelIDCacheLevel ZoneSettingEditResponseZonesCacheLevelID = "cache_level" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesCacheLevelValue string - -const ( - ZoneSettingEditResponseZonesCacheLevelValueAggressive ZoneSettingEditResponseZonesCacheLevelValue = "aggressive" - ZoneSettingEditResponseZonesCacheLevelValueBasic ZoneSettingEditResponseZonesCacheLevelValue = "basic" - ZoneSettingEditResponseZonesCacheLevelValueSimplified ZoneSettingEditResponseZonesCacheLevelValue = "simplified" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesCacheLevelEditable bool - -const ( - ZoneSettingEditResponseZonesCacheLevelEditableTrue ZoneSettingEditResponseZonesCacheLevelEditable = true - ZoneSettingEditResponseZonesCacheLevelEditableFalse ZoneSettingEditResponseZonesCacheLevelEditable = false -) - -// Specify how long a visitor is allowed access to your site after successfully -// completing a challenge (such as a CAPTCHA). After the TTL has expired the -// visitor will have to complete a new challenge. We recommend a 15 - 45 minute -// setting and will attempt to honor any setting above 45 minutes. -// (https://support.cloudflare.com/hc/en-us/articles/200170136). -type ZoneSettingEditResponseZonesChallengeTTL struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesChallengeTTLID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesChallengeTTLValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesChallengeTTLEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesChallengeTTLJSON `json:"-"` -} - -// zoneSettingEditResponseZonesChallengeTTLJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesChallengeTTL] -type zoneSettingEditResponseZonesChallengeTTLJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesChallengeTTL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesChallengeTTLJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesChallengeTTL) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesChallengeTTLID string - -const ( - ZoneSettingEditResponseZonesChallengeTTLIDChallengeTTL ZoneSettingEditResponseZonesChallengeTTLID = "challenge_ttl" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesChallengeTTLValue float64 - -const ( - ZoneSettingEditResponseZonesChallengeTTLValue300 ZoneSettingEditResponseZonesChallengeTTLValue = 300 - ZoneSettingEditResponseZonesChallengeTTLValue900 ZoneSettingEditResponseZonesChallengeTTLValue = 900 - ZoneSettingEditResponseZonesChallengeTTLValue1800 ZoneSettingEditResponseZonesChallengeTTLValue = 1800 - ZoneSettingEditResponseZonesChallengeTTLValue2700 ZoneSettingEditResponseZonesChallengeTTLValue = 2700 - ZoneSettingEditResponseZonesChallengeTTLValue3600 ZoneSettingEditResponseZonesChallengeTTLValue = 3600 - ZoneSettingEditResponseZonesChallengeTTLValue7200 ZoneSettingEditResponseZonesChallengeTTLValue = 7200 - ZoneSettingEditResponseZonesChallengeTTLValue10800 ZoneSettingEditResponseZonesChallengeTTLValue = 10800 - ZoneSettingEditResponseZonesChallengeTTLValue14400 ZoneSettingEditResponseZonesChallengeTTLValue = 14400 - ZoneSettingEditResponseZonesChallengeTTLValue28800 ZoneSettingEditResponseZonesChallengeTTLValue = 28800 - ZoneSettingEditResponseZonesChallengeTTLValue57600 ZoneSettingEditResponseZonesChallengeTTLValue = 57600 - ZoneSettingEditResponseZonesChallengeTTLValue86400 ZoneSettingEditResponseZonesChallengeTTLValue = 86400 - ZoneSettingEditResponseZonesChallengeTTLValue604800 ZoneSettingEditResponseZonesChallengeTTLValue = 604800 - ZoneSettingEditResponseZonesChallengeTTLValue2592000 ZoneSettingEditResponseZonesChallengeTTLValue = 2592000 - ZoneSettingEditResponseZonesChallengeTTLValue31536000 ZoneSettingEditResponseZonesChallengeTTLValue = 31536000 -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesChallengeTTLEditable bool - -const ( - ZoneSettingEditResponseZonesChallengeTTLEditableTrue ZoneSettingEditResponseZonesChallengeTTLEditable = true - ZoneSettingEditResponseZonesChallengeTTLEditableFalse ZoneSettingEditResponseZonesChallengeTTLEditable = false -) - -// An allowlist of ciphers for TLS termination. These ciphers must be in the -// BoringSSL format. -type ZoneSettingEditResponseZonesCiphers struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesCiphersID `json:"id,required"` - // Current value of the zone setting. - Value []string `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesCiphersEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesCiphersJSON `json:"-"` -} - -// zoneSettingEditResponseZonesCiphersJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesCiphers] -type zoneSettingEditResponseZonesCiphersJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesCiphers) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesCiphersJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesCiphers) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesCiphersID string - -const ( - ZoneSettingEditResponseZonesCiphersIDCiphers ZoneSettingEditResponseZonesCiphersID = "ciphers" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesCiphersEditable bool - -const ( - ZoneSettingEditResponseZonesCiphersEditableTrue ZoneSettingEditResponseZonesCiphersEditable = true - ZoneSettingEditResponseZonesCiphersEditableFalse ZoneSettingEditResponseZonesCiphersEditable = false -) - -// Whether or not cname flattening is on. -type ZoneSettingEditResponseZonesCNAMEFlattening struct { - // How to flatten the cname destination. - ID ZoneSettingEditResponseZonesCNAMEFlatteningID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesCNAMEFlatteningValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesCNAMEFlatteningEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesCNAMEFlatteningJSON `json:"-"` -} - -// zoneSettingEditResponseZonesCNAMEFlatteningJSON contains the JSON metadata for -// the struct [ZoneSettingEditResponseZonesCNAMEFlattening] -type zoneSettingEditResponseZonesCNAMEFlatteningJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesCNAMEFlattening) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesCNAMEFlatteningJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesCNAMEFlattening) implementsZoneSettingEditResponse() {} - -// How to flatten the cname destination. -type ZoneSettingEditResponseZonesCNAMEFlatteningID string - -const ( - ZoneSettingEditResponseZonesCNAMEFlatteningIDCNAMEFlattening ZoneSettingEditResponseZonesCNAMEFlatteningID = "cname_flattening" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesCNAMEFlatteningValue string - -const ( - ZoneSettingEditResponseZonesCNAMEFlatteningValueFlattenAtRoot ZoneSettingEditResponseZonesCNAMEFlatteningValue = "flatten_at_root" - ZoneSettingEditResponseZonesCNAMEFlatteningValueFlattenAll ZoneSettingEditResponseZonesCNAMEFlatteningValue = "flatten_all" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesCNAMEFlatteningEditable bool - -const ( - ZoneSettingEditResponseZonesCNAMEFlatteningEditableTrue ZoneSettingEditResponseZonesCNAMEFlatteningEditable = true - ZoneSettingEditResponseZonesCNAMEFlatteningEditableFalse ZoneSettingEditResponseZonesCNAMEFlatteningEditable = false -) - -// Development Mode temporarily allows you to enter development mode for your -// websites if you need to make changes to your site. This will bypass Cloudflare's -// accelerated cache and slow down your site, but is useful if you are making -// changes to cacheable content (like images, css, or JavaScript) and would like to -// see those changes right away. Once entered, development mode will last for 3 -// hours and then automatically toggle off. -type ZoneSettingEditResponseZonesDevelopmentMode struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesDevelopmentModeID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesDevelopmentModeValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesDevelopmentModeEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - // Value of the zone setting. Notes: The interval (in seconds) from when - // development mode expires (positive integer) or last expired (negative integer) - // for the domain. If development mode has never been enabled, this value is false. - TimeRemaining float64 `json:"time_remaining"` - JSON zoneSettingEditResponseZonesDevelopmentModeJSON `json:"-"` -} - -// zoneSettingEditResponseZonesDevelopmentModeJSON contains the JSON metadata for -// the struct [ZoneSettingEditResponseZonesDevelopmentMode] -type zoneSettingEditResponseZonesDevelopmentModeJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - TimeRemaining apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesDevelopmentMode) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesDevelopmentModeJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesDevelopmentMode) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesDevelopmentModeID string - -const ( - ZoneSettingEditResponseZonesDevelopmentModeIDDevelopmentMode ZoneSettingEditResponseZonesDevelopmentModeID = "development_mode" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesDevelopmentModeValue string - -const ( - ZoneSettingEditResponseZonesDevelopmentModeValueOn ZoneSettingEditResponseZonesDevelopmentModeValue = "on" - ZoneSettingEditResponseZonesDevelopmentModeValueOff ZoneSettingEditResponseZonesDevelopmentModeValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesDevelopmentModeEditable bool - -const ( - ZoneSettingEditResponseZonesDevelopmentModeEditableTrue ZoneSettingEditResponseZonesDevelopmentModeEditable = true - ZoneSettingEditResponseZonesDevelopmentModeEditableFalse ZoneSettingEditResponseZonesDevelopmentModeEditable = false -) - -// When enabled, Cloudflare will attempt to speed up overall page loads by serving -// `103` responses with `Link` headers from the final response. Refer to -// [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for -// more information. -type ZoneSettingEditResponseZonesEarlyHints struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesEarlyHintsID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesEarlyHintsValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesEarlyHintsEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesEarlyHintsJSON `json:"-"` -} - -// zoneSettingEditResponseZonesEarlyHintsJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesEarlyHints] -type zoneSettingEditResponseZonesEarlyHintsJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesEarlyHints) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesEarlyHintsJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesEarlyHints) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesEarlyHintsID string - -const ( - ZoneSettingEditResponseZonesEarlyHintsIDEarlyHints ZoneSettingEditResponseZonesEarlyHintsID = "early_hints" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesEarlyHintsValue string - -const ( - ZoneSettingEditResponseZonesEarlyHintsValueOn ZoneSettingEditResponseZonesEarlyHintsValue = "on" - ZoneSettingEditResponseZonesEarlyHintsValueOff ZoneSettingEditResponseZonesEarlyHintsValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesEarlyHintsEditable bool - -const ( - ZoneSettingEditResponseZonesEarlyHintsEditableTrue ZoneSettingEditResponseZonesEarlyHintsEditable = true - ZoneSettingEditResponseZonesEarlyHintsEditableFalse ZoneSettingEditResponseZonesEarlyHintsEditable = false -) - -// Time (in seconds) that a resource will be ensured to remain on Cloudflare's -// cache servers. -type ZoneSettingEditResponseZonesEdgeCacheTTL struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesEdgeCacheTTLID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesEdgeCacheTTLValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesEdgeCacheTTLEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesEdgeCacheTTLJSON `json:"-"` -} - -// zoneSettingEditResponseZonesEdgeCacheTTLJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesEdgeCacheTTL] -type zoneSettingEditResponseZonesEdgeCacheTTLJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesEdgeCacheTTL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesEdgeCacheTTLJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesEdgeCacheTTL) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesEdgeCacheTTLID string - -const ( - ZoneSettingEditResponseZonesEdgeCacheTTLIDEdgeCacheTTL ZoneSettingEditResponseZonesEdgeCacheTTLID = "edge_cache_ttl" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesEdgeCacheTTLValue float64 - -const ( - ZoneSettingEditResponseZonesEdgeCacheTTLValue30 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 30 - ZoneSettingEditResponseZonesEdgeCacheTTLValue60 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 60 - ZoneSettingEditResponseZonesEdgeCacheTTLValue300 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 300 - ZoneSettingEditResponseZonesEdgeCacheTTLValue1200 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 1200 - ZoneSettingEditResponseZonesEdgeCacheTTLValue1800 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 1800 - ZoneSettingEditResponseZonesEdgeCacheTTLValue3600 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 3600 - ZoneSettingEditResponseZonesEdgeCacheTTLValue7200 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 7200 - ZoneSettingEditResponseZonesEdgeCacheTTLValue10800 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 10800 - ZoneSettingEditResponseZonesEdgeCacheTTLValue14400 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 14400 - ZoneSettingEditResponseZonesEdgeCacheTTLValue18000 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 18000 - ZoneSettingEditResponseZonesEdgeCacheTTLValue28800 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 28800 - ZoneSettingEditResponseZonesEdgeCacheTTLValue43200 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 43200 - ZoneSettingEditResponseZonesEdgeCacheTTLValue57600 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 57600 - ZoneSettingEditResponseZonesEdgeCacheTTLValue72000 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 72000 - ZoneSettingEditResponseZonesEdgeCacheTTLValue86400 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 86400 - ZoneSettingEditResponseZonesEdgeCacheTTLValue172800 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 172800 - ZoneSettingEditResponseZonesEdgeCacheTTLValue259200 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 259200 - ZoneSettingEditResponseZonesEdgeCacheTTLValue345600 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 345600 - ZoneSettingEditResponseZonesEdgeCacheTTLValue432000 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 432000 - ZoneSettingEditResponseZonesEdgeCacheTTLValue518400 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 518400 - ZoneSettingEditResponseZonesEdgeCacheTTLValue604800 ZoneSettingEditResponseZonesEdgeCacheTTLValue = 604800 -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesEdgeCacheTTLEditable bool - -const ( - ZoneSettingEditResponseZonesEdgeCacheTTLEditableTrue ZoneSettingEditResponseZonesEdgeCacheTTLEditable = true - ZoneSettingEditResponseZonesEdgeCacheTTLEditableFalse ZoneSettingEditResponseZonesEdgeCacheTTLEditable = false -) - -// Encrypt email adresses on your web page from bots, while keeping them visible to -// humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). -type ZoneSettingEditResponseZonesEmailObfuscation struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesEmailObfuscationID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesEmailObfuscationValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesEmailObfuscationEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesEmailObfuscationJSON `json:"-"` -} - -// zoneSettingEditResponseZonesEmailObfuscationJSON contains the JSON metadata for -// the struct [ZoneSettingEditResponseZonesEmailObfuscation] -type zoneSettingEditResponseZonesEmailObfuscationJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesEmailObfuscation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesEmailObfuscationJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesEmailObfuscation) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesEmailObfuscationID string - -const ( - ZoneSettingEditResponseZonesEmailObfuscationIDEmailObfuscation ZoneSettingEditResponseZonesEmailObfuscationID = "email_obfuscation" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesEmailObfuscationValue string - -const ( - ZoneSettingEditResponseZonesEmailObfuscationValueOn ZoneSettingEditResponseZonesEmailObfuscationValue = "on" - ZoneSettingEditResponseZonesEmailObfuscationValueOff ZoneSettingEditResponseZonesEmailObfuscationValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesEmailObfuscationEditable bool - -const ( - ZoneSettingEditResponseZonesEmailObfuscationEditableTrue ZoneSettingEditResponseZonesEmailObfuscationEditable = true - ZoneSettingEditResponseZonesEmailObfuscationEditableFalse ZoneSettingEditResponseZonesEmailObfuscationEditable = false -) - -// HTTP/2 Edge Prioritization optimises the delivery of resources served through -// HTTP/2 to improve page load performance. It also supports fine control of -// content delivery when used in conjunction with Workers. -type ZoneSettingEditResponseZonesH2Prioritization struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesH2PrioritizationID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesH2PrioritizationValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesH2PrioritizationEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesH2PrioritizationJSON `json:"-"` -} - -// zoneSettingEditResponseZonesH2PrioritizationJSON contains the JSON metadata for -// the struct [ZoneSettingEditResponseZonesH2Prioritization] -type zoneSettingEditResponseZonesH2PrioritizationJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesH2Prioritization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesH2PrioritizationJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesH2Prioritization) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesH2PrioritizationID string - -const ( - ZoneSettingEditResponseZonesH2PrioritizationIDH2Prioritization ZoneSettingEditResponseZonesH2PrioritizationID = "h2_prioritization" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesH2PrioritizationValue string - -const ( - ZoneSettingEditResponseZonesH2PrioritizationValueOn ZoneSettingEditResponseZonesH2PrioritizationValue = "on" - ZoneSettingEditResponseZonesH2PrioritizationValueOff ZoneSettingEditResponseZonesH2PrioritizationValue = "off" - ZoneSettingEditResponseZonesH2PrioritizationValueCustom ZoneSettingEditResponseZonesH2PrioritizationValue = "custom" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesH2PrioritizationEditable bool - -const ( - ZoneSettingEditResponseZonesH2PrioritizationEditableTrue ZoneSettingEditResponseZonesH2PrioritizationEditable = true - ZoneSettingEditResponseZonesH2PrioritizationEditableFalse ZoneSettingEditResponseZonesH2PrioritizationEditable = false -) - -// When enabled, the Hotlink Protection option ensures that other sites cannot suck -// up your bandwidth by building pages that use images hosted on your site. Anytime -// a request for an image on your site hits Cloudflare, we check to ensure that -// it's not another site requesting them. People will still be able to download and -// view images from your page, but other sites won't be able to steal them for use -// on their own pages. -// (https://support.cloudflare.com/hc/en-us/articles/200170026). -type ZoneSettingEditResponseZonesHotlinkProtection struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesHotlinkProtectionID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesHotlinkProtectionValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesHotlinkProtectionEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesHotlinkProtectionJSON `json:"-"` -} - -// zoneSettingEditResponseZonesHotlinkProtectionJSON contains the JSON metadata for -// the struct [ZoneSettingEditResponseZonesHotlinkProtection] -type zoneSettingEditResponseZonesHotlinkProtectionJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesHotlinkProtection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesHotlinkProtectionJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesHotlinkProtection) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesHotlinkProtectionID string - -const ( - ZoneSettingEditResponseZonesHotlinkProtectionIDHotlinkProtection ZoneSettingEditResponseZonesHotlinkProtectionID = "hotlink_protection" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesHotlinkProtectionValue string - -const ( - ZoneSettingEditResponseZonesHotlinkProtectionValueOn ZoneSettingEditResponseZonesHotlinkProtectionValue = "on" - ZoneSettingEditResponseZonesHotlinkProtectionValueOff ZoneSettingEditResponseZonesHotlinkProtectionValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesHotlinkProtectionEditable bool - -const ( - ZoneSettingEditResponseZonesHotlinkProtectionEditableTrue ZoneSettingEditResponseZonesHotlinkProtectionEditable = true - ZoneSettingEditResponseZonesHotlinkProtectionEditableFalse ZoneSettingEditResponseZonesHotlinkProtectionEditable = false -) - -// HTTP2 enabled for this zone. -type ZoneSettingEditResponseZonesHTTP2 struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesHTTP2ID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesHTTP2Value `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesHTTP2Editable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesHTTP2JSON `json:"-"` -} - -// zoneSettingEditResponseZonesHTTP2JSON contains the JSON metadata for the struct -// [ZoneSettingEditResponseZonesHTTP2] -type zoneSettingEditResponseZonesHTTP2JSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesHTTP2) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesHTTP2JSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesHTTP2) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesHTTP2ID string - -const ( - ZoneSettingEditResponseZonesHTTP2IDHTTP2 ZoneSettingEditResponseZonesHTTP2ID = "http2" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesHTTP2Value string - -const ( - ZoneSettingEditResponseZonesHTTP2ValueOn ZoneSettingEditResponseZonesHTTP2Value = "on" - ZoneSettingEditResponseZonesHTTP2ValueOff ZoneSettingEditResponseZonesHTTP2Value = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesHTTP2Editable bool - -const ( - ZoneSettingEditResponseZonesHTTP2EditableTrue ZoneSettingEditResponseZonesHTTP2Editable = true - ZoneSettingEditResponseZonesHTTP2EditableFalse ZoneSettingEditResponseZonesHTTP2Editable = false -) - -// HTTP3 enabled for this zone. -type ZoneSettingEditResponseZonesHTTP3 struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesHTTP3ID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesHTTP3Value `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesHTTP3Editable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesHTTP3JSON `json:"-"` -} - -// zoneSettingEditResponseZonesHTTP3JSON contains the JSON metadata for the struct -// [ZoneSettingEditResponseZonesHTTP3] -type zoneSettingEditResponseZonesHTTP3JSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesHTTP3) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesHTTP3JSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesHTTP3) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesHTTP3ID string - -const ( - ZoneSettingEditResponseZonesHTTP3IDHTTP3 ZoneSettingEditResponseZonesHTTP3ID = "http3" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesHTTP3Value string - -const ( - ZoneSettingEditResponseZonesHTTP3ValueOn ZoneSettingEditResponseZonesHTTP3Value = "on" - ZoneSettingEditResponseZonesHTTP3ValueOff ZoneSettingEditResponseZonesHTTP3Value = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesHTTP3Editable bool - -const ( - ZoneSettingEditResponseZonesHTTP3EditableTrue ZoneSettingEditResponseZonesHTTP3Editable = true - ZoneSettingEditResponseZonesHTTP3EditableFalse ZoneSettingEditResponseZonesHTTP3Editable = false -) - -// Image Resizing provides on-demand resizing, conversion and optimisation for -// images served through Cloudflare's network. Refer to the -// [Image Resizing documentation](https://developers.cloudflare.com/images/) for -// more information. -type ZoneSettingEditResponseZonesImageResizing struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesImageResizingID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesImageResizingValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesImageResizingEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesImageResizingJSON `json:"-"` -} - -// zoneSettingEditResponseZonesImageResizingJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesImageResizing] -type zoneSettingEditResponseZonesImageResizingJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesImageResizing) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesImageResizingJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesImageResizing) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesImageResizingID string - -const ( - ZoneSettingEditResponseZonesImageResizingIDImageResizing ZoneSettingEditResponseZonesImageResizingID = "image_resizing" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesImageResizingValue string - -const ( - ZoneSettingEditResponseZonesImageResizingValueOn ZoneSettingEditResponseZonesImageResizingValue = "on" - ZoneSettingEditResponseZonesImageResizingValueOff ZoneSettingEditResponseZonesImageResizingValue = "off" - ZoneSettingEditResponseZonesImageResizingValueOpen ZoneSettingEditResponseZonesImageResizingValue = "open" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesImageResizingEditable bool - -const ( - ZoneSettingEditResponseZonesImageResizingEditableTrue ZoneSettingEditResponseZonesImageResizingEditable = true - ZoneSettingEditResponseZonesImageResizingEditableFalse ZoneSettingEditResponseZonesImageResizingEditable = false -) - -// Enable IP Geolocation to have Cloudflare geolocate visitors to your website and -// pass the country code to you. -// (https://support.cloudflare.com/hc/en-us/articles/200168236). -type ZoneSettingEditResponseZonesIPGeolocation struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesIPGeolocationID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesIPGeolocationValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesIPGeolocationEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesIPGeolocationJSON `json:"-"` -} - -// zoneSettingEditResponseZonesIPGeolocationJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesIPGeolocation] -type zoneSettingEditResponseZonesIPGeolocationJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesIPGeolocation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesIPGeolocationJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesIPGeolocation) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesIPGeolocationID string - -const ( - ZoneSettingEditResponseZonesIPGeolocationIDIPGeolocation ZoneSettingEditResponseZonesIPGeolocationID = "ip_geolocation" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesIPGeolocationValue string - -const ( - ZoneSettingEditResponseZonesIPGeolocationValueOn ZoneSettingEditResponseZonesIPGeolocationValue = "on" - ZoneSettingEditResponseZonesIPGeolocationValueOff ZoneSettingEditResponseZonesIPGeolocationValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesIPGeolocationEditable bool - -const ( - ZoneSettingEditResponseZonesIPGeolocationEditableTrue ZoneSettingEditResponseZonesIPGeolocationEditable = true - ZoneSettingEditResponseZonesIPGeolocationEditableFalse ZoneSettingEditResponseZonesIPGeolocationEditable = false -) - -// Enable IPv6 on all subdomains that are Cloudflare enabled. -// (https://support.cloudflare.com/hc/en-us/articles/200168586). -type ZoneSettingEditResponseZonesIPV6 struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesIPV6ID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesIPV6Value `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesIPV6Editable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesIPV6JSON `json:"-"` -} - -// zoneSettingEditResponseZonesIPV6JSON contains the JSON metadata for the struct -// [ZoneSettingEditResponseZonesIPV6] -type zoneSettingEditResponseZonesIPV6JSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesIPV6) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesIPV6JSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesIPV6) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesIPV6ID string - -const ( - ZoneSettingEditResponseZonesIPV6IDIPV6 ZoneSettingEditResponseZonesIPV6ID = "ipv6" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesIPV6Value string - -const ( - ZoneSettingEditResponseZonesIPV6ValueOff ZoneSettingEditResponseZonesIPV6Value = "off" - ZoneSettingEditResponseZonesIPV6ValueOn ZoneSettingEditResponseZonesIPV6Value = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesIPV6Editable bool - -const ( - ZoneSettingEditResponseZonesIPV6EditableTrue ZoneSettingEditResponseZonesIPV6Editable = true - ZoneSettingEditResponseZonesIPV6EditableFalse ZoneSettingEditResponseZonesIPV6Editable = false -) - -// Maximum size of an allowable upload. -type ZoneSettingEditResponseZonesMaxUpload struct { - // identifier of the zone setting. - ID ZoneSettingEditResponseZonesMaxUploadID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesMaxUploadValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesMaxUploadEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesMaxUploadJSON `json:"-"` -} - -// zoneSettingEditResponseZonesMaxUploadJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesMaxUpload] -type zoneSettingEditResponseZonesMaxUploadJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesMaxUpload) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesMaxUploadJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesMaxUpload) implementsZoneSettingEditResponse() {} - -// identifier of the zone setting. -type ZoneSettingEditResponseZonesMaxUploadID string - -const ( - ZoneSettingEditResponseZonesMaxUploadIDMaxUpload ZoneSettingEditResponseZonesMaxUploadID = "max_upload" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesMaxUploadValue float64 - -const ( - ZoneSettingEditResponseZonesMaxUploadValue100 ZoneSettingEditResponseZonesMaxUploadValue = 100 - ZoneSettingEditResponseZonesMaxUploadValue200 ZoneSettingEditResponseZonesMaxUploadValue = 200 - ZoneSettingEditResponseZonesMaxUploadValue500 ZoneSettingEditResponseZonesMaxUploadValue = 500 -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesMaxUploadEditable bool - -const ( - ZoneSettingEditResponseZonesMaxUploadEditableTrue ZoneSettingEditResponseZonesMaxUploadEditable = true - ZoneSettingEditResponseZonesMaxUploadEditableFalse ZoneSettingEditResponseZonesMaxUploadEditable = false -) - -// Only accepts HTTPS requests that use at least the TLS protocol version -// specified. For example, if TLS 1.1 is selected, TLS 1.0 connections will be -// rejected, while 1.1, 1.2, and 1.3 (if enabled) will be permitted. -type ZoneSettingEditResponseZonesMinTLSVersion struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesMinTLSVersionID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesMinTLSVersionValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesMinTLSVersionEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesMinTLSVersionJSON `json:"-"` -} - -// zoneSettingEditResponseZonesMinTLSVersionJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesMinTLSVersion] -type zoneSettingEditResponseZonesMinTLSVersionJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesMinTLSVersion) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesMinTLSVersionJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesMinTLSVersion) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesMinTLSVersionID string - -const ( - ZoneSettingEditResponseZonesMinTLSVersionIDMinTLSVersion ZoneSettingEditResponseZonesMinTLSVersionID = "min_tls_version" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesMinTLSVersionValue string - -const ( - ZoneSettingEditResponseZonesMinTLSVersionValue1_0 ZoneSettingEditResponseZonesMinTLSVersionValue = "1.0" - ZoneSettingEditResponseZonesMinTLSVersionValue1_1 ZoneSettingEditResponseZonesMinTLSVersionValue = "1.1" - ZoneSettingEditResponseZonesMinTLSVersionValue1_2 ZoneSettingEditResponseZonesMinTLSVersionValue = "1.2" - ZoneSettingEditResponseZonesMinTLSVersionValue1_3 ZoneSettingEditResponseZonesMinTLSVersionValue = "1.3" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesMinTLSVersionEditable bool - -const ( - ZoneSettingEditResponseZonesMinTLSVersionEditableTrue ZoneSettingEditResponseZonesMinTLSVersionEditable = true - ZoneSettingEditResponseZonesMinTLSVersionEditableFalse ZoneSettingEditResponseZonesMinTLSVersionEditable = false -) - -// Automatically minify certain assets for your website. Refer to -// [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) -// for more information. -type ZoneSettingEditResponseZonesMinify struct { - // Zone setting identifier. - ID ZoneSettingEditResponseZonesMinifyID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesMinifyValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesMinifyEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesMinifyJSON `json:"-"` -} - -// zoneSettingEditResponseZonesMinifyJSON contains the JSON metadata for the struct -// [ZoneSettingEditResponseZonesMinify] -type zoneSettingEditResponseZonesMinifyJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesMinify) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesMinifyJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesMinify) implementsZoneSettingEditResponse() {} - -// Zone setting identifier. -type ZoneSettingEditResponseZonesMinifyID string - -const ( - ZoneSettingEditResponseZonesMinifyIDMinify ZoneSettingEditResponseZonesMinifyID = "minify" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesMinifyValue struct { - // Automatically minify all CSS files for your website. - Css ZoneSettingEditResponseZonesMinifyValueCss `json:"css"` - // Automatically minify all HTML files for your website. - HTML ZoneSettingEditResponseZonesMinifyValueHTML `json:"html"` - // Automatically minify all JavaScript files for your website. - Js ZoneSettingEditResponseZonesMinifyValueJs `json:"js"` - JSON zoneSettingEditResponseZonesMinifyValueJSON `json:"-"` -} - -// zoneSettingEditResponseZonesMinifyValueJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesMinifyValue] -type zoneSettingEditResponseZonesMinifyValueJSON struct { - Css apijson.Field - HTML apijson.Field - Js apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesMinifyValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesMinifyValueJSON) RawJSON() string { - return r.raw -} - -// Automatically minify all CSS files for your website. -type ZoneSettingEditResponseZonesMinifyValueCss string - -const ( - ZoneSettingEditResponseZonesMinifyValueCssOn ZoneSettingEditResponseZonesMinifyValueCss = "on" - ZoneSettingEditResponseZonesMinifyValueCssOff ZoneSettingEditResponseZonesMinifyValueCss = "off" -) - -// Automatically minify all HTML files for your website. -type ZoneSettingEditResponseZonesMinifyValueHTML string - -const ( - ZoneSettingEditResponseZonesMinifyValueHTMLOn ZoneSettingEditResponseZonesMinifyValueHTML = "on" - ZoneSettingEditResponseZonesMinifyValueHTMLOff ZoneSettingEditResponseZonesMinifyValueHTML = "off" -) - -// Automatically minify all JavaScript files for your website. -type ZoneSettingEditResponseZonesMinifyValueJs string - -const ( - ZoneSettingEditResponseZonesMinifyValueJsOn ZoneSettingEditResponseZonesMinifyValueJs = "on" - ZoneSettingEditResponseZonesMinifyValueJsOff ZoneSettingEditResponseZonesMinifyValueJs = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesMinifyEditable bool - -const ( - ZoneSettingEditResponseZonesMinifyEditableTrue ZoneSettingEditResponseZonesMinifyEditable = true - ZoneSettingEditResponseZonesMinifyEditableFalse ZoneSettingEditResponseZonesMinifyEditable = false -) - -// Automatically optimize image loading for website visitors on mobile devices. -// Refer to -// [our blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for -// more information. -type ZoneSettingEditResponseZonesMirage struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesMirageID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesMirageValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesMirageEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesMirageJSON `json:"-"` -} - -// zoneSettingEditResponseZonesMirageJSON contains the JSON metadata for the struct -// [ZoneSettingEditResponseZonesMirage] -type zoneSettingEditResponseZonesMirageJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesMirage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesMirageJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesMirage) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesMirageID string - -const ( - ZoneSettingEditResponseZonesMirageIDMirage ZoneSettingEditResponseZonesMirageID = "mirage" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesMirageValue string - -const ( - ZoneSettingEditResponseZonesMirageValueOn ZoneSettingEditResponseZonesMirageValue = "on" - ZoneSettingEditResponseZonesMirageValueOff ZoneSettingEditResponseZonesMirageValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesMirageEditable bool - -const ( - ZoneSettingEditResponseZonesMirageEditableTrue ZoneSettingEditResponseZonesMirageEditable = true - ZoneSettingEditResponseZonesMirageEditableFalse ZoneSettingEditResponseZonesMirageEditable = false -) - -// Automatically redirect visitors on mobile devices to a mobile-optimized -// subdomain. Refer to -// [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) -// for more information. -type ZoneSettingEditResponseZonesMobileRedirect struct { - // Identifier of the zone setting. - ID ZoneSettingEditResponseZonesMobileRedirectID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesMobileRedirectValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesMobileRedirectEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesMobileRedirectJSON `json:"-"` -} - -// zoneSettingEditResponseZonesMobileRedirectJSON contains the JSON metadata for -// the struct [ZoneSettingEditResponseZonesMobileRedirect] -type zoneSettingEditResponseZonesMobileRedirectJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesMobileRedirect) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesMobileRedirectJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesMobileRedirect) implementsZoneSettingEditResponse() {} - -// Identifier of the zone setting. -type ZoneSettingEditResponseZonesMobileRedirectID string - -const ( - ZoneSettingEditResponseZonesMobileRedirectIDMobileRedirect ZoneSettingEditResponseZonesMobileRedirectID = "mobile_redirect" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesMobileRedirectValue struct { - // Which subdomain prefix you wish to redirect visitors on mobile devices to - // (subdomain must already exist). - MobileSubdomain string `json:"mobile_subdomain,nullable"` - // Whether or not mobile redirect is enabled. - Status ZoneSettingEditResponseZonesMobileRedirectValueStatus `json:"status"` - // Whether to drop the current page path and redirect to the mobile subdomain URL - // root, or keep the path and redirect to the same page on the mobile subdomain. - StripURI bool `json:"strip_uri"` - JSON zoneSettingEditResponseZonesMobileRedirectValueJSON `json:"-"` -} - -// zoneSettingEditResponseZonesMobileRedirectValueJSON contains the JSON metadata -// for the struct [ZoneSettingEditResponseZonesMobileRedirectValue] -type zoneSettingEditResponseZonesMobileRedirectValueJSON struct { - MobileSubdomain apijson.Field - Status apijson.Field - StripURI apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesMobileRedirectValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesMobileRedirectValueJSON) RawJSON() string { - return r.raw -} - -// Whether or not mobile redirect is enabled. -type ZoneSettingEditResponseZonesMobileRedirectValueStatus string - -const ( - ZoneSettingEditResponseZonesMobileRedirectValueStatusOn ZoneSettingEditResponseZonesMobileRedirectValueStatus = "on" - ZoneSettingEditResponseZonesMobileRedirectValueStatusOff ZoneSettingEditResponseZonesMobileRedirectValueStatus = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesMobileRedirectEditable bool - -const ( - ZoneSettingEditResponseZonesMobileRedirectEditableTrue ZoneSettingEditResponseZonesMobileRedirectEditable = true - ZoneSettingEditResponseZonesMobileRedirectEditableFalse ZoneSettingEditResponseZonesMobileRedirectEditable = false -) - -// Enable Network Error Logging reporting on your zone. (Beta) -type ZoneSettingEditResponseZonesNEL struct { - // Zone setting identifier. - ID ZoneSettingEditResponseZonesNELID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesNELValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesNELEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesNELJSON `json:"-"` -} - -// zoneSettingEditResponseZonesNELJSON contains the JSON metadata for the struct -// [ZoneSettingEditResponseZonesNEL] -type zoneSettingEditResponseZonesNELJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesNEL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesNELJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesNEL) implementsZoneSettingEditResponse() {} - -// Zone setting identifier. -type ZoneSettingEditResponseZonesNELID string - -const ( - ZoneSettingEditResponseZonesNELIDNEL ZoneSettingEditResponseZonesNELID = "nel" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesNELValue struct { - Enabled bool `json:"enabled"` - JSON zoneSettingEditResponseZonesNELValueJSON `json:"-"` -} - -// zoneSettingEditResponseZonesNELValueJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesNELValue] -type zoneSettingEditResponseZonesNELValueJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesNELValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesNELValueJSON) RawJSON() string { - return r.raw -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesNELEditable bool - -const ( - ZoneSettingEditResponseZonesNELEditableTrue ZoneSettingEditResponseZonesNELEditable = true - ZoneSettingEditResponseZonesNELEditableFalse ZoneSettingEditResponseZonesNELEditable = false -) - -// Enables the Opportunistic Encryption feature for a zone. -type ZoneSettingEditResponseZonesOpportunisticEncryption struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesOpportunisticEncryptionID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesOpportunisticEncryptionValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesOpportunisticEncryptionEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesOpportunisticEncryptionJSON `json:"-"` -} - -// zoneSettingEditResponseZonesOpportunisticEncryptionJSON contains the JSON -// metadata for the struct [ZoneSettingEditResponseZonesOpportunisticEncryption] -type zoneSettingEditResponseZonesOpportunisticEncryptionJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesOpportunisticEncryption) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesOpportunisticEncryptionJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesOpportunisticEncryption) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesOpportunisticEncryptionID string - -const ( - ZoneSettingEditResponseZonesOpportunisticEncryptionIDOpportunisticEncryption ZoneSettingEditResponseZonesOpportunisticEncryptionID = "opportunistic_encryption" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesOpportunisticEncryptionValue string - -const ( - ZoneSettingEditResponseZonesOpportunisticEncryptionValueOn ZoneSettingEditResponseZonesOpportunisticEncryptionValue = "on" - ZoneSettingEditResponseZonesOpportunisticEncryptionValueOff ZoneSettingEditResponseZonesOpportunisticEncryptionValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesOpportunisticEncryptionEditable bool - -const ( - ZoneSettingEditResponseZonesOpportunisticEncryptionEditableTrue ZoneSettingEditResponseZonesOpportunisticEncryptionEditable = true - ZoneSettingEditResponseZonesOpportunisticEncryptionEditableFalse ZoneSettingEditResponseZonesOpportunisticEncryptionEditable = false -) - -// Add an Alt-Svc header to all legitimate requests from Tor, allowing the -// connection to use our onion services instead of exit nodes. -type ZoneSettingEditResponseZonesOpportunisticOnion struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesOpportunisticOnionID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesOpportunisticOnionValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesOpportunisticOnionEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesOpportunisticOnionJSON `json:"-"` -} - -// zoneSettingEditResponseZonesOpportunisticOnionJSON contains the JSON metadata -// for the struct [ZoneSettingEditResponseZonesOpportunisticOnion] -type zoneSettingEditResponseZonesOpportunisticOnionJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesOpportunisticOnion) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesOpportunisticOnionJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesOpportunisticOnion) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesOpportunisticOnionID string - -const ( - ZoneSettingEditResponseZonesOpportunisticOnionIDOpportunisticOnion ZoneSettingEditResponseZonesOpportunisticOnionID = "opportunistic_onion" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesOpportunisticOnionValue string - -const ( - ZoneSettingEditResponseZonesOpportunisticOnionValueOn ZoneSettingEditResponseZonesOpportunisticOnionValue = "on" - ZoneSettingEditResponseZonesOpportunisticOnionValueOff ZoneSettingEditResponseZonesOpportunisticOnionValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesOpportunisticOnionEditable bool - -const ( - ZoneSettingEditResponseZonesOpportunisticOnionEditableTrue ZoneSettingEditResponseZonesOpportunisticOnionEditable = true - ZoneSettingEditResponseZonesOpportunisticOnionEditableFalse ZoneSettingEditResponseZonesOpportunisticOnionEditable = false -) - -// Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also -// on Cloudflare. -type ZoneSettingEditResponseZonesOrangeToOrange struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesOrangeToOrangeID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesOrangeToOrangeValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesOrangeToOrangeEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesOrangeToOrangeJSON `json:"-"` -} - -// zoneSettingEditResponseZonesOrangeToOrangeJSON contains the JSON metadata for -// the struct [ZoneSettingEditResponseZonesOrangeToOrange] -type zoneSettingEditResponseZonesOrangeToOrangeJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesOrangeToOrange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesOrangeToOrangeJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesOrangeToOrange) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesOrangeToOrangeID string - -const ( - ZoneSettingEditResponseZonesOrangeToOrangeIDOrangeToOrange ZoneSettingEditResponseZonesOrangeToOrangeID = "orange_to_orange" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesOrangeToOrangeValue string - -const ( - ZoneSettingEditResponseZonesOrangeToOrangeValueOn ZoneSettingEditResponseZonesOrangeToOrangeValue = "on" - ZoneSettingEditResponseZonesOrangeToOrangeValueOff ZoneSettingEditResponseZonesOrangeToOrangeValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesOrangeToOrangeEditable bool - -const ( - ZoneSettingEditResponseZonesOrangeToOrangeEditableTrue ZoneSettingEditResponseZonesOrangeToOrangeEditable = true - ZoneSettingEditResponseZonesOrangeToOrangeEditableFalse ZoneSettingEditResponseZonesOrangeToOrangeEditable = false -) - -// Cloudflare will proxy customer error pages on any 502,504 errors on origin -// server instead of showing a default Cloudflare error page. This does not apply -// to 522 errors and is limited to Enterprise Zones. -type ZoneSettingEditResponseZonesOriginErrorPagePassThru struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesOriginErrorPagePassThruID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesOriginErrorPagePassThruValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesOriginErrorPagePassThruEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesOriginErrorPagePassThruJSON `json:"-"` -} - -// zoneSettingEditResponseZonesOriginErrorPagePassThruJSON contains the JSON -// metadata for the struct [ZoneSettingEditResponseZonesOriginErrorPagePassThru] -type zoneSettingEditResponseZonesOriginErrorPagePassThruJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesOriginErrorPagePassThru) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesOriginErrorPagePassThruJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesOriginErrorPagePassThru) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesOriginErrorPagePassThruID string - -const ( - ZoneSettingEditResponseZonesOriginErrorPagePassThruIDOriginErrorPagePassThru ZoneSettingEditResponseZonesOriginErrorPagePassThruID = "origin_error_page_pass_thru" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesOriginErrorPagePassThruValue string - -const ( - ZoneSettingEditResponseZonesOriginErrorPagePassThruValueOn ZoneSettingEditResponseZonesOriginErrorPagePassThruValue = "on" - ZoneSettingEditResponseZonesOriginErrorPagePassThruValueOff ZoneSettingEditResponseZonesOriginErrorPagePassThruValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesOriginErrorPagePassThruEditable bool - -const ( - ZoneSettingEditResponseZonesOriginErrorPagePassThruEditableTrue ZoneSettingEditResponseZonesOriginErrorPagePassThruEditable = true - ZoneSettingEditResponseZonesOriginErrorPagePassThruEditableFalse ZoneSettingEditResponseZonesOriginErrorPagePassThruEditable = false -) - -// Removes metadata and compresses your images for faster page load times. Basic -// (Lossless): Reduce the size of PNG, JPEG, and GIF files - no impact on visual -// quality. Basic + JPEG (Lossy): Further reduce the size of JPEG files for faster -// image loading. Larger JPEGs are converted to progressive images, loading a -// lower-resolution image first and ending in a higher-resolution version. Not -// recommended for hi-res photography sites. -type ZoneSettingEditResponseZonesPolish struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesPolishID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesPolishValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesPolishEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesPolishJSON `json:"-"` -} - -// zoneSettingEditResponseZonesPolishJSON contains the JSON metadata for the struct -// [ZoneSettingEditResponseZonesPolish] -type zoneSettingEditResponseZonesPolishJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesPolish) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesPolishJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesPolish) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesPolishID string - -const ( - ZoneSettingEditResponseZonesPolishIDPolish ZoneSettingEditResponseZonesPolishID = "polish" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesPolishValue string - -const ( - ZoneSettingEditResponseZonesPolishValueOff ZoneSettingEditResponseZonesPolishValue = "off" - ZoneSettingEditResponseZonesPolishValueLossless ZoneSettingEditResponseZonesPolishValue = "lossless" - ZoneSettingEditResponseZonesPolishValueLossy ZoneSettingEditResponseZonesPolishValue = "lossy" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesPolishEditable bool - -const ( - ZoneSettingEditResponseZonesPolishEditableTrue ZoneSettingEditResponseZonesPolishEditable = true - ZoneSettingEditResponseZonesPolishEditableFalse ZoneSettingEditResponseZonesPolishEditable = false -) - -// Cloudflare will prefetch any URLs that are included in the response headers. -// This is limited to Enterprise Zones. -type ZoneSettingEditResponseZonesPrefetchPreload struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesPrefetchPreloadID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesPrefetchPreloadValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesPrefetchPreloadEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesPrefetchPreloadJSON `json:"-"` -} - -// zoneSettingEditResponseZonesPrefetchPreloadJSON contains the JSON metadata for -// the struct [ZoneSettingEditResponseZonesPrefetchPreload] -type zoneSettingEditResponseZonesPrefetchPreloadJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesPrefetchPreload) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesPrefetchPreloadJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesPrefetchPreload) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesPrefetchPreloadID string - -const ( - ZoneSettingEditResponseZonesPrefetchPreloadIDPrefetchPreload ZoneSettingEditResponseZonesPrefetchPreloadID = "prefetch_preload" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesPrefetchPreloadValue string - -const ( - ZoneSettingEditResponseZonesPrefetchPreloadValueOn ZoneSettingEditResponseZonesPrefetchPreloadValue = "on" - ZoneSettingEditResponseZonesPrefetchPreloadValueOff ZoneSettingEditResponseZonesPrefetchPreloadValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesPrefetchPreloadEditable bool - -const ( - ZoneSettingEditResponseZonesPrefetchPreloadEditableTrue ZoneSettingEditResponseZonesPrefetchPreloadEditable = true - ZoneSettingEditResponseZonesPrefetchPreloadEditableFalse ZoneSettingEditResponseZonesPrefetchPreloadEditable = false -) - -// Maximum time between two read operations from origin. -type ZoneSettingEditResponseZonesProxyReadTimeout struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesProxyReadTimeoutID `json:"id,required"` - // Current value of the zone setting. - Value float64 `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesProxyReadTimeoutEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesProxyReadTimeoutJSON `json:"-"` -} - -// zoneSettingEditResponseZonesProxyReadTimeoutJSON contains the JSON metadata for -// the struct [ZoneSettingEditResponseZonesProxyReadTimeout] -type zoneSettingEditResponseZonesProxyReadTimeoutJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesProxyReadTimeout) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesProxyReadTimeoutJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesProxyReadTimeout) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesProxyReadTimeoutID string - -const ( - ZoneSettingEditResponseZonesProxyReadTimeoutIDProxyReadTimeout ZoneSettingEditResponseZonesProxyReadTimeoutID = "proxy_read_timeout" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesProxyReadTimeoutEditable bool - -const ( - ZoneSettingEditResponseZonesProxyReadTimeoutEditableTrue ZoneSettingEditResponseZonesProxyReadTimeoutEditable = true - ZoneSettingEditResponseZonesProxyReadTimeoutEditableFalse ZoneSettingEditResponseZonesProxyReadTimeoutEditable = false -) - -// The value set for the Pseudo IPv4 setting. -type ZoneSettingEditResponseZonesPseudoIPV4 struct { - // Value of the Pseudo IPv4 setting. - ID ZoneSettingEditResponseZonesPseudoIPV4ID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesPseudoIPV4Value `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesPseudoIPV4Editable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesPseudoIPV4JSON `json:"-"` -} - -// zoneSettingEditResponseZonesPseudoIPV4JSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesPseudoIPV4] -type zoneSettingEditResponseZonesPseudoIPV4JSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesPseudoIPV4) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesPseudoIPV4JSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesPseudoIPV4) implementsZoneSettingEditResponse() {} - -// Value of the Pseudo IPv4 setting. -type ZoneSettingEditResponseZonesPseudoIPV4ID string - -const ( - ZoneSettingEditResponseZonesPseudoIPV4IDPseudoIPV4 ZoneSettingEditResponseZonesPseudoIPV4ID = "pseudo_ipv4" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesPseudoIPV4Value string - -const ( - ZoneSettingEditResponseZonesPseudoIPV4ValueOff ZoneSettingEditResponseZonesPseudoIPV4Value = "off" - ZoneSettingEditResponseZonesPseudoIPV4ValueAddHeader ZoneSettingEditResponseZonesPseudoIPV4Value = "add_header" - ZoneSettingEditResponseZonesPseudoIPV4ValueOverwriteHeader ZoneSettingEditResponseZonesPseudoIPV4Value = "overwrite_header" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesPseudoIPV4Editable bool - -const ( - ZoneSettingEditResponseZonesPseudoIPV4EditableTrue ZoneSettingEditResponseZonesPseudoIPV4Editable = true - ZoneSettingEditResponseZonesPseudoIPV4EditableFalse ZoneSettingEditResponseZonesPseudoIPV4Editable = false -) - -// Enables or disables buffering of responses from the proxied server. Cloudflare -// may buffer the whole payload to deliver it at once to the client versus allowing -// it to be delivered in chunks. By default, the proxied server streams directly -// and is not buffered by Cloudflare. This is limited to Enterprise Zones. -type ZoneSettingEditResponseZonesResponseBuffering struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesResponseBufferingID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesResponseBufferingValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesResponseBufferingEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesResponseBufferingJSON `json:"-"` -} - -// zoneSettingEditResponseZonesResponseBufferingJSON contains the JSON metadata for -// the struct [ZoneSettingEditResponseZonesResponseBuffering] -type zoneSettingEditResponseZonesResponseBufferingJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesResponseBuffering) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesResponseBufferingJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesResponseBuffering) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesResponseBufferingID string - -const ( - ZoneSettingEditResponseZonesResponseBufferingIDResponseBuffering ZoneSettingEditResponseZonesResponseBufferingID = "response_buffering" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesResponseBufferingValue string - -const ( - ZoneSettingEditResponseZonesResponseBufferingValueOn ZoneSettingEditResponseZonesResponseBufferingValue = "on" - ZoneSettingEditResponseZonesResponseBufferingValueOff ZoneSettingEditResponseZonesResponseBufferingValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesResponseBufferingEditable bool - -const ( - ZoneSettingEditResponseZonesResponseBufferingEditableTrue ZoneSettingEditResponseZonesResponseBufferingEditable = true - ZoneSettingEditResponseZonesResponseBufferingEditableFalse ZoneSettingEditResponseZonesResponseBufferingEditable = false -) - -// Rocket Loader is a general-purpose asynchronous JavaScript optimisation that -// prioritises rendering your content while loading your site's Javascript -// asynchronously. Turning on Rocket Loader will immediately improve a web page's -// rendering time sometimes measured as Time to First Paint (TTFP), and also the -// `window.onload` time (assuming there is JavaScript on the page). This can have a -// positive impact on your Google search ranking. When turned on, Rocket Loader -// will automatically defer the loading of all Javascript referenced in your HTML, -// with no configuration required. Refer to -// [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) -// for more information. -type ZoneSettingEditResponseZonesRocketLoader struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesRocketLoaderID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesRocketLoaderValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesRocketLoaderEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesRocketLoaderJSON `json:"-"` -} - -// zoneSettingEditResponseZonesRocketLoaderJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesRocketLoader] -type zoneSettingEditResponseZonesRocketLoaderJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesRocketLoader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesRocketLoaderJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesRocketLoader) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesRocketLoaderID string - -const ( - ZoneSettingEditResponseZonesRocketLoaderIDRocketLoader ZoneSettingEditResponseZonesRocketLoaderID = "rocket_loader" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesRocketLoaderValue string - -const ( - ZoneSettingEditResponseZonesRocketLoaderValueOn ZoneSettingEditResponseZonesRocketLoaderValue = "on" - ZoneSettingEditResponseZonesRocketLoaderValueOff ZoneSettingEditResponseZonesRocketLoaderValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesRocketLoaderEditable bool - -const ( - ZoneSettingEditResponseZonesRocketLoaderEditableTrue ZoneSettingEditResponseZonesRocketLoaderEditable = true - ZoneSettingEditResponseZonesRocketLoaderEditableFalse ZoneSettingEditResponseZonesRocketLoaderEditable = false -) - -// [Automatic Platform Optimization for WordPress](https://developers.cloudflare.com/automatic-platform-optimization/) -// serves your WordPress site from Cloudflare's edge network and caches third-party -// fonts. -type ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimization struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationJSON `json:"-"` -} - -// zoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationJSON contains -// the JSON metadata for the struct -// [ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimization] -type zoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimization) implementsZoneSettingEditResponse() { -} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationID string - -const ( - ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationIDAutomaticPlatformOptimization ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationID = "automatic_platform_optimization" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationValue struct { - // Indicates whether or not - // [cache by device type](https://developers.cloudflare.com/automatic-platform-optimization/reference/cache-device-type/) - // is enabled. - CacheByDeviceType bool `json:"cache_by_device_type,required"` - // Indicates whether or not Cloudflare proxy is enabled. - Cf bool `json:"cf,required"` - // Indicates whether or not Automatic Platform Optimization is enabled. - Enabled bool `json:"enabled,required"` - // An array of hostnames where Automatic Platform Optimization for WordPress is - // activated. - Hostnames []string `json:"hostnames,required" format:"hostname"` - // Indicates whether or not site is powered by WordPress. - Wordpress bool `json:"wordpress,required"` - // Indicates whether or not - // [Cloudflare for WordPress plugin](https://wordpress.org/plugins/cloudflare/) is - // installed. - WpPlugin bool `json:"wp_plugin,required"` - JSON zoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationValueJSON `json:"-"` -} - -// zoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationValueJSON -// contains the JSON metadata for the struct -// [ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationValue] -type zoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationValueJSON struct { - CacheByDeviceType apijson.Field - Cf apijson.Field - Enabled apijson.Field - Hostnames apijson.Field - Wordpress apijson.Field - WpPlugin apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationValueJSON) RawJSON() string { - return r.raw -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditable bool - -const ( - ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditableTrue ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditable = true - ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditableFalse ZoneSettingEditResponseZonesSchemasAutomaticPlatformOptimizationEditable = false -) - -// Cloudflare security header for a zone. -type ZoneSettingEditResponseZonesSecurityHeader struct { - // ID of the zone's security header. - ID ZoneSettingEditResponseZonesSecurityHeaderID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesSecurityHeaderValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesSecurityHeaderEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesSecurityHeaderJSON `json:"-"` -} - -// zoneSettingEditResponseZonesSecurityHeaderJSON contains the JSON metadata for -// the struct [ZoneSettingEditResponseZonesSecurityHeader] -type zoneSettingEditResponseZonesSecurityHeaderJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesSecurityHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesSecurityHeaderJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesSecurityHeader) implementsZoneSettingEditResponse() {} - -// ID of the zone's security header. -type ZoneSettingEditResponseZonesSecurityHeaderID string - -const ( - ZoneSettingEditResponseZonesSecurityHeaderIDSecurityHeader ZoneSettingEditResponseZonesSecurityHeaderID = "security_header" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesSecurityHeaderValue struct { - // Strict Transport Security. - StrictTransportSecurity ZoneSettingEditResponseZonesSecurityHeaderValueStrictTransportSecurity `json:"strict_transport_security"` - JSON zoneSettingEditResponseZonesSecurityHeaderValueJSON `json:"-"` -} - -// zoneSettingEditResponseZonesSecurityHeaderValueJSON contains the JSON metadata -// for the struct [ZoneSettingEditResponseZonesSecurityHeaderValue] -type zoneSettingEditResponseZonesSecurityHeaderValueJSON struct { - StrictTransportSecurity apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesSecurityHeaderValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesSecurityHeaderValueJSON) RawJSON() string { - return r.raw -} - -// Strict Transport Security. -type ZoneSettingEditResponseZonesSecurityHeaderValueStrictTransportSecurity struct { - // Whether or not strict transport security is enabled. - Enabled bool `json:"enabled"` - // Include all subdomains for strict transport security. - IncludeSubdomains bool `json:"include_subdomains"` - // Max age in seconds of the strict transport security. - MaxAge float64 `json:"max_age"` - // Whether or not to include 'X-Content-Type-Options: nosniff' header. - Nosniff bool `json:"nosniff"` - JSON zoneSettingEditResponseZonesSecurityHeaderValueStrictTransportSecurityJSON `json:"-"` -} - -// zoneSettingEditResponseZonesSecurityHeaderValueStrictTransportSecurityJSON -// contains the JSON metadata for the struct -// [ZoneSettingEditResponseZonesSecurityHeaderValueStrictTransportSecurity] -type zoneSettingEditResponseZonesSecurityHeaderValueStrictTransportSecurityJSON struct { - Enabled apijson.Field - IncludeSubdomains apijson.Field - MaxAge apijson.Field - Nosniff apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesSecurityHeaderValueStrictTransportSecurity) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesSecurityHeaderValueStrictTransportSecurityJSON) RawJSON() string { - return r.raw -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesSecurityHeaderEditable bool - -const ( - ZoneSettingEditResponseZonesSecurityHeaderEditableTrue ZoneSettingEditResponseZonesSecurityHeaderEditable = true - ZoneSettingEditResponseZonesSecurityHeaderEditableFalse ZoneSettingEditResponseZonesSecurityHeaderEditable = false -) - -// Choose the appropriate security profile for your website, which will -// automatically adjust each of the security settings. If you choose to customize -// an individual security setting, the profile will become Custom. -// (https://support.cloudflare.com/hc/en-us/articles/200170056). -type ZoneSettingEditResponseZonesSecurityLevel struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesSecurityLevelID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesSecurityLevelValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesSecurityLevelEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesSecurityLevelJSON `json:"-"` -} - -// zoneSettingEditResponseZonesSecurityLevelJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesSecurityLevel] -type zoneSettingEditResponseZonesSecurityLevelJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesSecurityLevel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesSecurityLevelJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesSecurityLevel) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesSecurityLevelID string - -const ( - ZoneSettingEditResponseZonesSecurityLevelIDSecurityLevel ZoneSettingEditResponseZonesSecurityLevelID = "security_level" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesSecurityLevelValue string - -const ( - ZoneSettingEditResponseZonesSecurityLevelValueOff ZoneSettingEditResponseZonesSecurityLevelValue = "off" - ZoneSettingEditResponseZonesSecurityLevelValueEssentiallyOff ZoneSettingEditResponseZonesSecurityLevelValue = "essentially_off" - ZoneSettingEditResponseZonesSecurityLevelValueLow ZoneSettingEditResponseZonesSecurityLevelValue = "low" - ZoneSettingEditResponseZonesSecurityLevelValueMedium ZoneSettingEditResponseZonesSecurityLevelValue = "medium" - ZoneSettingEditResponseZonesSecurityLevelValueHigh ZoneSettingEditResponseZonesSecurityLevelValue = "high" - ZoneSettingEditResponseZonesSecurityLevelValueUnderAttack ZoneSettingEditResponseZonesSecurityLevelValue = "under_attack" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesSecurityLevelEditable bool - -const ( - ZoneSettingEditResponseZonesSecurityLevelEditableTrue ZoneSettingEditResponseZonesSecurityLevelEditable = true - ZoneSettingEditResponseZonesSecurityLevelEditableFalse ZoneSettingEditResponseZonesSecurityLevelEditable = false -) - -// If there is sensitive content on your website that you want visible to real -// visitors, but that you want to hide from suspicious visitors, all you have to do -// is wrap the content with Cloudflare SSE tags. Wrap any content that you want to -// be excluded from suspicious visitors in the following SSE tags: -// . For example: Bad visitors won't see my phone -// number, 555-555-5555 . Note: SSE only will work with HTML. If you -// have HTML minification enabled, you won't see the SSE tags in your HTML source -// when it's served through Cloudflare. SSE will still function in this case, as -// Cloudflare's HTML minification and SSE functionality occur on-the-fly as the -// resource moves through our network to the visitor's computer. -// (https://support.cloudflare.com/hc/en-us/articles/200170036). -type ZoneSettingEditResponseZonesServerSideExclude struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesServerSideExcludeID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesServerSideExcludeValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesServerSideExcludeEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesServerSideExcludeJSON `json:"-"` -} - -// zoneSettingEditResponseZonesServerSideExcludeJSON contains the JSON metadata for -// the struct [ZoneSettingEditResponseZonesServerSideExclude] -type zoneSettingEditResponseZonesServerSideExcludeJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesServerSideExclude) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesServerSideExcludeJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesServerSideExclude) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesServerSideExcludeID string - -const ( - ZoneSettingEditResponseZonesServerSideExcludeIDServerSideExclude ZoneSettingEditResponseZonesServerSideExcludeID = "server_side_exclude" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesServerSideExcludeValue string - -const ( - ZoneSettingEditResponseZonesServerSideExcludeValueOn ZoneSettingEditResponseZonesServerSideExcludeValue = "on" - ZoneSettingEditResponseZonesServerSideExcludeValueOff ZoneSettingEditResponseZonesServerSideExcludeValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesServerSideExcludeEditable bool - -const ( - ZoneSettingEditResponseZonesServerSideExcludeEditableTrue ZoneSettingEditResponseZonesServerSideExcludeEditable = true - ZoneSettingEditResponseZonesServerSideExcludeEditableFalse ZoneSettingEditResponseZonesServerSideExcludeEditable = false -) - -// Allow SHA1 support. -type ZoneSettingEditResponseZonesSha1Support struct { - // Zone setting identifier. - ID ZoneSettingEditResponseZonesSha1SupportID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesSha1SupportValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesSha1SupportEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesSha1SupportJSON `json:"-"` -} - -// zoneSettingEditResponseZonesSha1SupportJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesSha1Support] -type zoneSettingEditResponseZonesSha1SupportJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesSha1Support) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesSha1SupportJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesSha1Support) implementsZoneSettingEditResponse() {} - -// Zone setting identifier. -type ZoneSettingEditResponseZonesSha1SupportID string - -const ( - ZoneSettingEditResponseZonesSha1SupportIDSha1Support ZoneSettingEditResponseZonesSha1SupportID = "sha1_support" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesSha1SupportValue string - -const ( - ZoneSettingEditResponseZonesSha1SupportValueOff ZoneSettingEditResponseZonesSha1SupportValue = "off" - ZoneSettingEditResponseZonesSha1SupportValueOn ZoneSettingEditResponseZonesSha1SupportValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesSha1SupportEditable bool - -const ( - ZoneSettingEditResponseZonesSha1SupportEditableTrue ZoneSettingEditResponseZonesSha1SupportEditable = true - ZoneSettingEditResponseZonesSha1SupportEditableFalse ZoneSettingEditResponseZonesSha1SupportEditable = false -) - -// Cloudflare will treat files with the same query strings as the same file in -// cache, regardless of the order of the query strings. This is limited to -// Enterprise Zones. -type ZoneSettingEditResponseZonesSortQueryStringForCache struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesSortQueryStringForCacheID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesSortQueryStringForCacheValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesSortQueryStringForCacheEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesSortQueryStringForCacheJSON `json:"-"` -} - -// zoneSettingEditResponseZonesSortQueryStringForCacheJSON contains the JSON -// metadata for the struct [ZoneSettingEditResponseZonesSortQueryStringForCache] -type zoneSettingEditResponseZonesSortQueryStringForCacheJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesSortQueryStringForCache) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesSortQueryStringForCacheJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesSortQueryStringForCache) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesSortQueryStringForCacheID string - -const ( - ZoneSettingEditResponseZonesSortQueryStringForCacheIDSortQueryStringForCache ZoneSettingEditResponseZonesSortQueryStringForCacheID = "sort_query_string_for_cache" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesSortQueryStringForCacheValue string - -const ( - ZoneSettingEditResponseZonesSortQueryStringForCacheValueOn ZoneSettingEditResponseZonesSortQueryStringForCacheValue = "on" - ZoneSettingEditResponseZonesSortQueryStringForCacheValueOff ZoneSettingEditResponseZonesSortQueryStringForCacheValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesSortQueryStringForCacheEditable bool - -const ( - ZoneSettingEditResponseZonesSortQueryStringForCacheEditableTrue ZoneSettingEditResponseZonesSortQueryStringForCacheEditable = true - ZoneSettingEditResponseZonesSortQueryStringForCacheEditableFalse ZoneSettingEditResponseZonesSortQueryStringForCacheEditable = false -) - -// SSL encrypts your visitor's connection and safeguards credit card numbers and -// other personal data to and from your website. SSL can take up to 5 minutes to -// fully activate. Requires Cloudflare active on your root domain or www domain. -// Off: no SSL between the visitor and Cloudflare, and no SSL between Cloudflare -// and your web server (all HTTP traffic). Flexible: SSL between the visitor and -// Cloudflare -- visitor sees HTTPS on your site, but no SSL between Cloudflare and -// your web server. You don't need to have an SSL cert on your web server, but your -// vistors will still see the site as being HTTPS enabled. Full: SSL between the -// visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between -// Cloudflare and your web server. You'll need to have your own SSL cert or -// self-signed cert at the very least. Full (Strict): SSL between the visitor and -// Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and -// your web server. You'll need to have a valid SSL certificate installed on your -// web server. This certificate must be signed by a certificate authority, have an -// expiration date in the future, and respond for the request domain name -// (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). -type ZoneSettingEditResponseZonesSSL struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesSSLID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesSSLValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesSSLEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesSSLJSON `json:"-"` -} - -// zoneSettingEditResponseZonesSSLJSON contains the JSON metadata for the struct -// [ZoneSettingEditResponseZonesSSL] -type zoneSettingEditResponseZonesSSLJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesSSL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesSSLJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesSSL) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesSSLID string - -const ( - ZoneSettingEditResponseZonesSSLIDSSL ZoneSettingEditResponseZonesSSLID = "ssl" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesSSLValue string - -const ( - ZoneSettingEditResponseZonesSSLValueOff ZoneSettingEditResponseZonesSSLValue = "off" - ZoneSettingEditResponseZonesSSLValueFlexible ZoneSettingEditResponseZonesSSLValue = "flexible" - ZoneSettingEditResponseZonesSSLValueFull ZoneSettingEditResponseZonesSSLValue = "full" - ZoneSettingEditResponseZonesSSLValueStrict ZoneSettingEditResponseZonesSSLValue = "strict" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesSSLEditable bool - -const ( - ZoneSettingEditResponseZonesSSLEditableTrue ZoneSettingEditResponseZonesSSLEditable = true - ZoneSettingEditResponseZonesSSLEditableFalse ZoneSettingEditResponseZonesSSLEditable = false -) - -// Enrollment in the SSL/TLS Recommender service which tries to detect and -// recommend (by sending periodic emails) the most secure SSL/TLS setting your -// origin servers support. -type ZoneSettingEditResponseZonesSSLRecommender struct { - // Enrollment value for SSL/TLS Recommender. - ID ZoneSettingEditResponseZonesSSLRecommenderID `json:"id"` - // ssl-recommender enrollment setting. - Enabled bool `json:"enabled"` - JSON zoneSettingEditResponseZonesSSLRecommenderJSON `json:"-"` -} - -// zoneSettingEditResponseZonesSSLRecommenderJSON contains the JSON metadata for -// the struct [ZoneSettingEditResponseZonesSSLRecommender] -type zoneSettingEditResponseZonesSSLRecommenderJSON struct { - ID apijson.Field - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesSSLRecommender) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesSSLRecommenderJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesSSLRecommender) implementsZoneSettingEditResponse() {} - -// Enrollment value for SSL/TLS Recommender. -type ZoneSettingEditResponseZonesSSLRecommenderID string - -const ( - ZoneSettingEditResponseZonesSSLRecommenderIDSSLRecommender ZoneSettingEditResponseZonesSSLRecommenderID = "ssl_recommender" -) - -// Only allows TLS1.2. -type ZoneSettingEditResponseZonesTLS1_2Only struct { - // Zone setting identifier. - ID ZoneSettingEditResponseZonesTLS1_2OnlyID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesTLS1_2OnlyValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesTLS1_2OnlyEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesTls1_2OnlyJSON `json:"-"` -} - -// zoneSettingEditResponseZonesTls1_2OnlyJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesTLS1_2Only] -type zoneSettingEditResponseZonesTls1_2OnlyJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesTLS1_2Only) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesTls1_2OnlyJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesTLS1_2Only) implementsZoneSettingEditResponse() {} - -// Zone setting identifier. -type ZoneSettingEditResponseZonesTLS1_2OnlyID string - -const ( - ZoneSettingEditResponseZonesTLS1_2OnlyIDTLS1_2Only ZoneSettingEditResponseZonesTLS1_2OnlyID = "tls_1_2_only" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesTLS1_2OnlyValue string - -const ( - ZoneSettingEditResponseZonesTLS1_2OnlyValueOff ZoneSettingEditResponseZonesTLS1_2OnlyValue = "off" - ZoneSettingEditResponseZonesTLS1_2OnlyValueOn ZoneSettingEditResponseZonesTLS1_2OnlyValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesTLS1_2OnlyEditable bool - -const ( - ZoneSettingEditResponseZonesTLS1_2OnlyEditableTrue ZoneSettingEditResponseZonesTLS1_2OnlyEditable = true - ZoneSettingEditResponseZonesTLS1_2OnlyEditableFalse ZoneSettingEditResponseZonesTLS1_2OnlyEditable = false -) - -// Enables Crypto TLS 1.3 feature for a zone. -type ZoneSettingEditResponseZonesTLS1_3 struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesTLS1_3ID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesTLS1_3Value `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesTLS1_3Editable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesTls1_3JSON `json:"-"` -} - -// zoneSettingEditResponseZonesTls1_3JSON contains the JSON metadata for the struct -// [ZoneSettingEditResponseZonesTLS1_3] -type zoneSettingEditResponseZonesTls1_3JSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesTLS1_3) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesTls1_3JSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesTLS1_3) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesTLS1_3ID string - -const ( - ZoneSettingEditResponseZonesTLS1_3IDTLS1_3 ZoneSettingEditResponseZonesTLS1_3ID = "tls_1_3" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesTLS1_3Value string - -const ( - ZoneSettingEditResponseZonesTLS1_3ValueOn ZoneSettingEditResponseZonesTLS1_3Value = "on" - ZoneSettingEditResponseZonesTLS1_3ValueOff ZoneSettingEditResponseZonesTLS1_3Value = "off" - ZoneSettingEditResponseZonesTLS1_3ValueZrt ZoneSettingEditResponseZonesTLS1_3Value = "zrt" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesTLS1_3Editable bool - -const ( - ZoneSettingEditResponseZonesTLS1_3EditableTrue ZoneSettingEditResponseZonesTLS1_3Editable = true - ZoneSettingEditResponseZonesTLS1_3EditableFalse ZoneSettingEditResponseZonesTLS1_3Editable = false -) - -// TLS Client Auth requires Cloudflare to connect to your origin server using a -// client certificate (Enterprise Only). -type ZoneSettingEditResponseZonesTLSClientAuth struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesTLSClientAuthID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesTLSClientAuthValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesTLSClientAuthEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesTLSClientAuthJSON `json:"-"` -} - -// zoneSettingEditResponseZonesTLSClientAuthJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesTLSClientAuth] -type zoneSettingEditResponseZonesTLSClientAuthJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesTLSClientAuth) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesTLSClientAuthJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesTLSClientAuth) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesTLSClientAuthID string - -const ( - ZoneSettingEditResponseZonesTLSClientAuthIDTLSClientAuth ZoneSettingEditResponseZonesTLSClientAuthID = "tls_client_auth" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesTLSClientAuthValue string - -const ( - ZoneSettingEditResponseZonesTLSClientAuthValueOn ZoneSettingEditResponseZonesTLSClientAuthValue = "on" - ZoneSettingEditResponseZonesTLSClientAuthValueOff ZoneSettingEditResponseZonesTLSClientAuthValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesTLSClientAuthEditable bool - -const ( - ZoneSettingEditResponseZonesTLSClientAuthEditableTrue ZoneSettingEditResponseZonesTLSClientAuthEditable = true - ZoneSettingEditResponseZonesTLSClientAuthEditableFalse ZoneSettingEditResponseZonesTLSClientAuthEditable = false -) - -// Allows customer to continue to use True Client IP (Akamai feature) in the -// headers we send to the origin. This is limited to Enterprise Zones. -type ZoneSettingEditResponseZonesTrueClientIPHeader struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesTrueClientIPHeaderID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesTrueClientIPHeaderValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesTrueClientIPHeaderEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesTrueClientIPHeaderJSON `json:"-"` -} - -// zoneSettingEditResponseZonesTrueClientIPHeaderJSON contains the JSON metadata -// for the struct [ZoneSettingEditResponseZonesTrueClientIPHeader] -type zoneSettingEditResponseZonesTrueClientIPHeaderJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesTrueClientIPHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesTrueClientIPHeaderJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesTrueClientIPHeader) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesTrueClientIPHeaderID string - -const ( - ZoneSettingEditResponseZonesTrueClientIPHeaderIDTrueClientIPHeader ZoneSettingEditResponseZonesTrueClientIPHeaderID = "true_client_ip_header" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesTrueClientIPHeaderValue string - -const ( - ZoneSettingEditResponseZonesTrueClientIPHeaderValueOn ZoneSettingEditResponseZonesTrueClientIPHeaderValue = "on" - ZoneSettingEditResponseZonesTrueClientIPHeaderValueOff ZoneSettingEditResponseZonesTrueClientIPHeaderValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesTrueClientIPHeaderEditable bool - -const ( - ZoneSettingEditResponseZonesTrueClientIPHeaderEditableTrue ZoneSettingEditResponseZonesTrueClientIPHeaderEditable = true - ZoneSettingEditResponseZonesTrueClientIPHeaderEditableFalse ZoneSettingEditResponseZonesTrueClientIPHeaderEditable = false -) - -// The WAF examines HTTP requests to your website. It inspects both GET and POST -// requests and applies rules to help filter out illegitimate traffic from -// legitimate website visitors. The Cloudflare WAF inspects website addresses or -// URLs to detect anything out of the ordinary. If the Cloudflare WAF determines -// suspicious user behavior, then the WAF will 'challenge' the web visitor with a -// page that asks them to submit a CAPTCHA successfully to continue their action. -// If the challenge is failed, the action will be stopped. What this means is that -// Cloudflare's WAF will block any traffic identified as illegitimate before it -// reaches your origin web server. -// (https://support.cloudflare.com/hc/en-us/articles/200172016). -type ZoneSettingEditResponseZonesWAF struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesWAFID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesWAFValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesWAFEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesWAFJSON `json:"-"` -} - -// zoneSettingEditResponseZonesWAFJSON contains the JSON metadata for the struct -// [ZoneSettingEditResponseZonesWAF] -type zoneSettingEditResponseZonesWAFJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesWAF) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesWAFJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesWAF) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesWAFID string - -const ( - ZoneSettingEditResponseZonesWAFIDWAF ZoneSettingEditResponseZonesWAFID = "waf" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesWAFValue string - -const ( - ZoneSettingEditResponseZonesWAFValueOn ZoneSettingEditResponseZonesWAFValue = "on" - ZoneSettingEditResponseZonesWAFValueOff ZoneSettingEditResponseZonesWAFValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesWAFEditable bool - -const ( - ZoneSettingEditResponseZonesWAFEditableTrue ZoneSettingEditResponseZonesWAFEditable = true - ZoneSettingEditResponseZonesWAFEditableFalse ZoneSettingEditResponseZonesWAFEditable = false -) - -// When the client requesting the image supports the WebP image codec, and WebP -// offers a performance advantage over the original image format, Cloudflare will -// serve a WebP version of the original image. -type ZoneSettingEditResponseZonesWebp struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesWebpID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesWebpValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesWebpEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesWebpJSON `json:"-"` -} - -// zoneSettingEditResponseZonesWebpJSON contains the JSON metadata for the struct -// [ZoneSettingEditResponseZonesWebp] -type zoneSettingEditResponseZonesWebpJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesWebp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesWebpJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesWebp) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesWebpID string - -const ( - ZoneSettingEditResponseZonesWebpIDWebp ZoneSettingEditResponseZonesWebpID = "webp" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesWebpValue string - -const ( - ZoneSettingEditResponseZonesWebpValueOff ZoneSettingEditResponseZonesWebpValue = "off" - ZoneSettingEditResponseZonesWebpValueOn ZoneSettingEditResponseZonesWebpValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesWebpEditable bool - -const ( - ZoneSettingEditResponseZonesWebpEditableTrue ZoneSettingEditResponseZonesWebpEditable = true - ZoneSettingEditResponseZonesWebpEditableFalse ZoneSettingEditResponseZonesWebpEditable = false -) - -// WebSockets are open connections sustained between the client and the origin -// server. Inside a WebSockets connection, the client and the origin can pass data -// back and forth without having to reestablish sessions. This makes exchanging -// data within a WebSockets connection fast. WebSockets are often used for -// real-time applications such as live chat and gaming. For more information refer -// to -// [Can I use Cloudflare with Websockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Can-I-use-Cloudflare-with-WebSockets-). -type ZoneSettingEditResponseZonesWebsockets struct { - // ID of the zone setting. - ID ZoneSettingEditResponseZonesWebsocketsID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEditResponseZonesWebsocketsValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEditResponseZonesWebsocketsEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEditResponseZonesWebsocketsJSON `json:"-"` -} - -// zoneSettingEditResponseZonesWebsocketsJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseZonesWebsockets] -type zoneSettingEditResponseZonesWebsocketsJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseZonesWebsockets) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseZonesWebsocketsJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingEditResponseZonesWebsockets) implementsZoneSettingEditResponse() {} - -// ID of the zone setting. -type ZoneSettingEditResponseZonesWebsocketsID string - -const ( - ZoneSettingEditResponseZonesWebsocketsIDWebsockets ZoneSettingEditResponseZonesWebsocketsID = "websockets" -) - -// Current value of the zone setting. -type ZoneSettingEditResponseZonesWebsocketsValue string - -const ( - ZoneSettingEditResponseZonesWebsocketsValueOff ZoneSettingEditResponseZonesWebsocketsValue = "off" - ZoneSettingEditResponseZonesWebsocketsValueOn ZoneSettingEditResponseZonesWebsocketsValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditResponseZonesWebsocketsEditable bool - -const ( - ZoneSettingEditResponseZonesWebsocketsEditableTrue ZoneSettingEditResponseZonesWebsocketsEditable = true - ZoneSettingEditResponseZonesWebsocketsEditableFalse ZoneSettingEditResponseZonesWebsocketsEditable = false -) - -// 0-RTT session resumption enabled for this zone. -// -// Union satisfied by [ZoneSettingGetResponseZones0rtt], -// [ZoneSettingGetResponseZonesAdvancedDDOS], -// [ZoneSettingGetResponseZonesAlwaysOnline], -// [ZoneSettingGetResponseZonesAlwaysUseHTTPS], -// [ZoneSettingGetResponseZonesAutomaticHTTPSRewrites], -// [ZoneSettingGetResponseZonesBrotli], -// [ZoneSettingGetResponseZonesBrowserCacheTTL], -// [ZoneSettingGetResponseZonesBrowserCheck], -// [ZoneSettingGetResponseZonesCacheLevel], -// [ZoneSettingGetResponseZonesChallengeTTL], [ZoneSettingGetResponseZonesCiphers], -// [ZoneSettingGetResponseZonesCNAMEFlattening], -// [ZoneSettingGetResponseZonesDevelopmentMode], -// [ZoneSettingGetResponseZonesEarlyHints], -// [ZoneSettingGetResponseZonesEdgeCacheTTL], -// [ZoneSettingGetResponseZonesEmailObfuscation], -// [ZoneSettingGetResponseZonesH2Prioritization], -// [ZoneSettingGetResponseZonesHotlinkProtection], -// [ZoneSettingGetResponseZonesHTTP2], [ZoneSettingGetResponseZonesHTTP3], -// [ZoneSettingGetResponseZonesImageResizing], -// [ZoneSettingGetResponseZonesIPGeolocation], [ZoneSettingGetResponseZonesIPV6], -// [ZoneSettingGetResponseZonesMaxUpload], -// [ZoneSettingGetResponseZonesMinTLSVersion], [ZoneSettingGetResponseZonesMinify], -// [ZoneSettingGetResponseZonesMirage], -// [ZoneSettingGetResponseZonesMobileRedirect], [ZoneSettingGetResponseZonesNEL], -// [ZoneSettingGetResponseZonesOpportunisticEncryption], -// [ZoneSettingGetResponseZonesOpportunisticOnion], -// [ZoneSettingGetResponseZonesOrangeToOrange], -// [ZoneSettingGetResponseZonesOriginErrorPagePassThru], -// [ZoneSettingGetResponseZonesPolish], -// [ZoneSettingGetResponseZonesPrefetchPreload], -// [ZoneSettingGetResponseZonesProxyReadTimeout], -// [ZoneSettingGetResponseZonesPseudoIPV4], -// [ZoneSettingGetResponseZonesResponseBuffering], -// [ZoneSettingGetResponseZonesRocketLoader], -// [ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimization], -// [ZoneSettingGetResponseZonesSecurityHeader], -// [ZoneSettingGetResponseZonesSecurityLevel], -// [ZoneSettingGetResponseZonesServerSideExclude], -// [ZoneSettingGetResponseZonesSha1Support], -// [ZoneSettingGetResponseZonesSortQueryStringForCache], -// [ZoneSettingGetResponseZonesSSL], [ZoneSettingGetResponseZonesSSLRecommender], -// [ZoneSettingGetResponseZonesTLS1_2Only], [ZoneSettingGetResponseZonesTLS1_3], -// [ZoneSettingGetResponseZonesTLSClientAuth], -// [ZoneSettingGetResponseZonesTrueClientIPHeader], -// [ZoneSettingGetResponseZonesWAF], [ZoneSettingGetResponseZonesWebp] or -// [ZoneSettingGetResponseZonesWebsockets]. -type ZoneSettingGetResponse interface { - implementsZoneSettingGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZoneSettingGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZones0rtt{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesAdvancedDDOS{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesAlwaysOnline{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesAlwaysUseHTTPS{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesAutomaticHTTPSRewrites{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesBrotli{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesBrowserCacheTTL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesBrowserCheck{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesCacheLevel{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesChallengeTTL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesCiphers{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesCNAMEFlattening{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesDevelopmentMode{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesEarlyHints{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesEdgeCacheTTL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesEmailObfuscation{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesH2Prioritization{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesHotlinkProtection{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesHTTP2{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesHTTP3{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesImageResizing{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesIPGeolocation{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesIPV6{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesMaxUpload{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesMinTLSVersion{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesMinify{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesMirage{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesMobileRedirect{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesNEL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesOpportunisticEncryption{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesOpportunisticOnion{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesOrangeToOrange{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesOriginErrorPagePassThru{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesPolish{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesPrefetchPreload{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesProxyReadTimeout{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesPseudoIPV4{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesResponseBuffering{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesRocketLoader{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimization{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesSecurityHeader{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesSecurityLevel{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesServerSideExclude{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesSha1Support{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesSortQueryStringForCache{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesSSL{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesSSLRecommender{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesTLS1_2Only{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesTLS1_3{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesTLSClientAuth{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesTrueClientIPHeader{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesWAF{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesWebp{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(ZoneSettingGetResponseZonesWebsockets{}), - }, - ) -} - -// 0-RTT session resumption enabled for this zone. -type ZoneSettingGetResponseZones0rtt struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZones0rttID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZones0rttValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZones0rttEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZones0rttJSON `json:"-"` -} - -// zoneSettingGetResponseZones0rttJSON contains the JSON metadata for the struct -// [ZoneSettingGetResponseZones0rtt] -type zoneSettingGetResponseZones0rttJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZones0rtt) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZones0rttJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZones0rtt) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZones0rttID string - -const ( - ZoneSettingGetResponseZones0rttID0rtt ZoneSettingGetResponseZones0rttID = "0rtt" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZones0rttValue string - -const ( - ZoneSettingGetResponseZones0rttValueOn ZoneSettingGetResponseZones0rttValue = "on" - ZoneSettingGetResponseZones0rttValueOff ZoneSettingGetResponseZones0rttValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZones0rttEditable bool - -const ( - ZoneSettingGetResponseZones0rttEditableTrue ZoneSettingGetResponseZones0rttEditable = true - ZoneSettingGetResponseZones0rttEditableFalse ZoneSettingGetResponseZones0rttEditable = false -) - -// 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. -type ZoneSettingGetResponseZonesAdvancedDDOS struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesAdvancedDDOSID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesAdvancedDDOSValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesAdvancedDDOSEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesAdvancedDDOSJSON `json:"-"` -} - -// zoneSettingGetResponseZonesAdvancedDDOSJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesAdvancedDDOS] -type zoneSettingGetResponseZonesAdvancedDDOSJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesAdvancedDDOS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesAdvancedDDOSJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesAdvancedDDOS) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesAdvancedDDOSID string - -const ( - ZoneSettingGetResponseZonesAdvancedDDOSIDAdvancedDDOS ZoneSettingGetResponseZonesAdvancedDDOSID = "advanced_ddos" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesAdvancedDDOSValue string - -const ( - ZoneSettingGetResponseZonesAdvancedDDOSValueOn ZoneSettingGetResponseZonesAdvancedDDOSValue = "on" - ZoneSettingGetResponseZonesAdvancedDDOSValueOff ZoneSettingGetResponseZonesAdvancedDDOSValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesAdvancedDDOSEditable bool - -const ( - ZoneSettingGetResponseZonesAdvancedDDOSEditableTrue ZoneSettingGetResponseZonesAdvancedDDOSEditable = true - ZoneSettingGetResponseZonesAdvancedDDOSEditableFalse ZoneSettingGetResponseZonesAdvancedDDOSEditable = false -) - -// When enabled, Cloudflare serves limited copies of web pages available from the -// [Internet Archive's Wayback Machine](https://archive.org/web/) if your server is -// offline. Refer to -// [Always Online](https://developers.cloudflare.com/cache/about/always-online) for -// more information. -type ZoneSettingGetResponseZonesAlwaysOnline struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesAlwaysOnlineID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesAlwaysOnlineValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesAlwaysOnlineEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesAlwaysOnlineJSON `json:"-"` -} - -// zoneSettingGetResponseZonesAlwaysOnlineJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesAlwaysOnline] -type zoneSettingGetResponseZonesAlwaysOnlineJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesAlwaysOnline) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesAlwaysOnlineJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesAlwaysOnline) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesAlwaysOnlineID string - -const ( - ZoneSettingGetResponseZonesAlwaysOnlineIDAlwaysOnline ZoneSettingGetResponseZonesAlwaysOnlineID = "always_online" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesAlwaysOnlineValue string - -const ( - ZoneSettingGetResponseZonesAlwaysOnlineValueOn ZoneSettingGetResponseZonesAlwaysOnlineValue = "on" - ZoneSettingGetResponseZonesAlwaysOnlineValueOff ZoneSettingGetResponseZonesAlwaysOnlineValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesAlwaysOnlineEditable bool - -const ( - ZoneSettingGetResponseZonesAlwaysOnlineEditableTrue ZoneSettingGetResponseZonesAlwaysOnlineEditable = true - ZoneSettingGetResponseZonesAlwaysOnlineEditableFalse ZoneSettingGetResponseZonesAlwaysOnlineEditable = false -) - -// Reply to all requests for URLs that use "http" with a 301 redirect to the -// equivalent "https" URL. If you only want to redirect for a subset of requests, -// consider creating an "Always use HTTPS" page rule. -type ZoneSettingGetResponseZonesAlwaysUseHTTPS struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesAlwaysUseHTTPSID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesAlwaysUseHTTPSValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesAlwaysUseHTTPSEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesAlwaysUseHTTPSJSON `json:"-"` -} - -// zoneSettingGetResponseZonesAlwaysUseHTTPSJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesAlwaysUseHTTPS] -type zoneSettingGetResponseZonesAlwaysUseHTTPSJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesAlwaysUseHTTPS) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesAlwaysUseHTTPSJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesAlwaysUseHTTPS) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesAlwaysUseHTTPSID string - -const ( - ZoneSettingGetResponseZonesAlwaysUseHTTPSIDAlwaysUseHTTPS ZoneSettingGetResponseZonesAlwaysUseHTTPSID = "always_use_https" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesAlwaysUseHTTPSValue string - -const ( - ZoneSettingGetResponseZonesAlwaysUseHTTPSValueOn ZoneSettingGetResponseZonesAlwaysUseHTTPSValue = "on" - ZoneSettingGetResponseZonesAlwaysUseHTTPSValueOff ZoneSettingGetResponseZonesAlwaysUseHTTPSValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesAlwaysUseHTTPSEditable bool - -const ( - ZoneSettingGetResponseZonesAlwaysUseHTTPSEditableTrue ZoneSettingGetResponseZonesAlwaysUseHTTPSEditable = true - ZoneSettingGetResponseZonesAlwaysUseHTTPSEditableFalse ZoneSettingGetResponseZonesAlwaysUseHTTPSEditable = false -) - -// Enable the Automatic HTTPS Rewrites feature for this zone. -type ZoneSettingGetResponseZonesAutomaticHTTPSRewrites struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesAutomaticHTTPSRewritesID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesAutomaticHTTPSRewritesValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesAutomaticHTTPSRewritesEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesAutomaticHTTPSRewritesJSON `json:"-"` -} - -// zoneSettingGetResponseZonesAutomaticHTTPSRewritesJSON contains the JSON metadata -// for the struct [ZoneSettingGetResponseZonesAutomaticHTTPSRewrites] -type zoneSettingGetResponseZonesAutomaticHTTPSRewritesJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesAutomaticHTTPSRewrites) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesAutomaticHTTPSRewritesJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesAutomaticHTTPSRewrites) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesAutomaticHTTPSRewritesID string - -const ( - ZoneSettingGetResponseZonesAutomaticHTTPSRewritesIDAutomaticHTTPSRewrites ZoneSettingGetResponseZonesAutomaticHTTPSRewritesID = "automatic_https_rewrites" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesAutomaticHTTPSRewritesValue string - -const ( - ZoneSettingGetResponseZonesAutomaticHTTPSRewritesValueOn ZoneSettingGetResponseZonesAutomaticHTTPSRewritesValue = "on" - ZoneSettingGetResponseZonesAutomaticHTTPSRewritesValueOff ZoneSettingGetResponseZonesAutomaticHTTPSRewritesValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesAutomaticHTTPSRewritesEditable bool - -const ( - ZoneSettingGetResponseZonesAutomaticHTTPSRewritesEditableTrue ZoneSettingGetResponseZonesAutomaticHTTPSRewritesEditable = true - ZoneSettingGetResponseZonesAutomaticHTTPSRewritesEditableFalse ZoneSettingGetResponseZonesAutomaticHTTPSRewritesEditable = false -) - -// When the client requesting an asset supports the Brotli compression algorithm, -// Cloudflare will serve a Brotli compressed version of the asset. -type ZoneSettingGetResponseZonesBrotli struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesBrotliID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesBrotliValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesBrotliEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesBrotliJSON `json:"-"` -} - -// zoneSettingGetResponseZonesBrotliJSON contains the JSON metadata for the struct -// [ZoneSettingGetResponseZonesBrotli] -type zoneSettingGetResponseZonesBrotliJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesBrotli) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesBrotliJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesBrotli) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesBrotliID string - -const ( - ZoneSettingGetResponseZonesBrotliIDBrotli ZoneSettingGetResponseZonesBrotliID = "brotli" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesBrotliValue string - -const ( - ZoneSettingGetResponseZonesBrotliValueOff ZoneSettingGetResponseZonesBrotliValue = "off" - ZoneSettingGetResponseZonesBrotliValueOn ZoneSettingGetResponseZonesBrotliValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesBrotliEditable bool - -const ( - ZoneSettingGetResponseZonesBrotliEditableTrue ZoneSettingGetResponseZonesBrotliEditable = true - ZoneSettingGetResponseZonesBrotliEditableFalse ZoneSettingGetResponseZonesBrotliEditable = false -) - -// Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources -// will remain on your visitors' computers. Cloudflare will honor any larger times -// specified by your server. -// (https://support.cloudflare.com/hc/en-us/articles/200168276). -type ZoneSettingGetResponseZonesBrowserCacheTTL struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesBrowserCacheTTLID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesBrowserCacheTTLValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesBrowserCacheTTLEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesBrowserCacheTTLJSON `json:"-"` -} - -// zoneSettingGetResponseZonesBrowserCacheTTLJSON contains the JSON metadata for -// the struct [ZoneSettingGetResponseZonesBrowserCacheTTL] -type zoneSettingGetResponseZonesBrowserCacheTTLJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesBrowserCacheTTL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesBrowserCacheTTLJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesBrowserCacheTTL) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesBrowserCacheTTLID string - -const ( - ZoneSettingGetResponseZonesBrowserCacheTTLIDBrowserCacheTTL ZoneSettingGetResponseZonesBrowserCacheTTLID = "browser_cache_ttl" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesBrowserCacheTTLValue float64 - -const ( - ZoneSettingGetResponseZonesBrowserCacheTTLValue0 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 0 - ZoneSettingGetResponseZonesBrowserCacheTTLValue30 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 30 - ZoneSettingGetResponseZonesBrowserCacheTTLValue60 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 60 - ZoneSettingGetResponseZonesBrowserCacheTTLValue120 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 120 - ZoneSettingGetResponseZonesBrowserCacheTTLValue300 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 300 - ZoneSettingGetResponseZonesBrowserCacheTTLValue1200 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 1200 - ZoneSettingGetResponseZonesBrowserCacheTTLValue1800 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 1800 - ZoneSettingGetResponseZonesBrowserCacheTTLValue3600 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 3600 - ZoneSettingGetResponseZonesBrowserCacheTTLValue7200 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 7200 - ZoneSettingGetResponseZonesBrowserCacheTTLValue10800 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 10800 - ZoneSettingGetResponseZonesBrowserCacheTTLValue14400 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 14400 - ZoneSettingGetResponseZonesBrowserCacheTTLValue18000 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 18000 - ZoneSettingGetResponseZonesBrowserCacheTTLValue28800 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 28800 - ZoneSettingGetResponseZonesBrowserCacheTTLValue43200 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 43200 - ZoneSettingGetResponseZonesBrowserCacheTTLValue57600 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 57600 - ZoneSettingGetResponseZonesBrowserCacheTTLValue72000 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 72000 - ZoneSettingGetResponseZonesBrowserCacheTTLValue86400 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 86400 - ZoneSettingGetResponseZonesBrowserCacheTTLValue172800 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 172800 - ZoneSettingGetResponseZonesBrowserCacheTTLValue259200 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 259200 - ZoneSettingGetResponseZonesBrowserCacheTTLValue345600 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 345600 - ZoneSettingGetResponseZonesBrowserCacheTTLValue432000 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 432000 - ZoneSettingGetResponseZonesBrowserCacheTTLValue691200 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 691200 - ZoneSettingGetResponseZonesBrowserCacheTTLValue1382400 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 1382400 - ZoneSettingGetResponseZonesBrowserCacheTTLValue2073600 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 2073600 - ZoneSettingGetResponseZonesBrowserCacheTTLValue2678400 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 2678400 - ZoneSettingGetResponseZonesBrowserCacheTTLValue5356800 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 5356800 - ZoneSettingGetResponseZonesBrowserCacheTTLValue16070400 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 16070400 - ZoneSettingGetResponseZonesBrowserCacheTTLValue31536000 ZoneSettingGetResponseZonesBrowserCacheTTLValue = 31536000 -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesBrowserCacheTTLEditable bool - -const ( - ZoneSettingGetResponseZonesBrowserCacheTTLEditableTrue ZoneSettingGetResponseZonesBrowserCacheTTLEditable = true - ZoneSettingGetResponseZonesBrowserCacheTTLEditableFalse ZoneSettingGetResponseZonesBrowserCacheTTLEditable = false -) - -// Browser Integrity Check is similar to Bad Behavior and looks for common HTTP -// headers abused most commonly by spammers and denies access to your page. It will -// also challenge visitors that do not have a user agent or a non standard user -// agent (also commonly used by abuse bots, crawlers or visitors). -// (https://support.cloudflare.com/hc/en-us/articles/200170086). -type ZoneSettingGetResponseZonesBrowserCheck struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesBrowserCheckID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesBrowserCheckValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesBrowserCheckEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesBrowserCheckJSON `json:"-"` -} - -// zoneSettingGetResponseZonesBrowserCheckJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesBrowserCheck] -type zoneSettingGetResponseZonesBrowserCheckJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesBrowserCheck) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesBrowserCheckJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesBrowserCheck) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesBrowserCheckID string - -const ( - ZoneSettingGetResponseZonesBrowserCheckIDBrowserCheck ZoneSettingGetResponseZonesBrowserCheckID = "browser_check" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesBrowserCheckValue string - -const ( - ZoneSettingGetResponseZonesBrowserCheckValueOn ZoneSettingGetResponseZonesBrowserCheckValue = "on" - ZoneSettingGetResponseZonesBrowserCheckValueOff ZoneSettingGetResponseZonesBrowserCheckValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesBrowserCheckEditable bool - -const ( - ZoneSettingGetResponseZonesBrowserCheckEditableTrue ZoneSettingGetResponseZonesBrowserCheckEditable = true - ZoneSettingGetResponseZonesBrowserCheckEditableFalse ZoneSettingGetResponseZonesBrowserCheckEditable = false -) - -// Cache Level functions based off the setting level. The basic setting will cache -// most static resources (i.e., css, images, and JavaScript). The simplified -// setting will ignore the query string when delivering a cached resource. The -// aggressive setting will cache all static resources, including ones with a query -// string. (https://support.cloudflare.com/hc/en-us/articles/200168256). -type ZoneSettingGetResponseZonesCacheLevel struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesCacheLevelID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesCacheLevelValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesCacheLevelEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesCacheLevelJSON `json:"-"` -} - -// zoneSettingGetResponseZonesCacheLevelJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesCacheLevel] -type zoneSettingGetResponseZonesCacheLevelJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesCacheLevel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesCacheLevelJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesCacheLevel) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesCacheLevelID string - -const ( - ZoneSettingGetResponseZonesCacheLevelIDCacheLevel ZoneSettingGetResponseZonesCacheLevelID = "cache_level" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesCacheLevelValue string - -const ( - ZoneSettingGetResponseZonesCacheLevelValueAggressive ZoneSettingGetResponseZonesCacheLevelValue = "aggressive" - ZoneSettingGetResponseZonesCacheLevelValueBasic ZoneSettingGetResponseZonesCacheLevelValue = "basic" - ZoneSettingGetResponseZonesCacheLevelValueSimplified ZoneSettingGetResponseZonesCacheLevelValue = "simplified" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesCacheLevelEditable bool - -const ( - ZoneSettingGetResponseZonesCacheLevelEditableTrue ZoneSettingGetResponseZonesCacheLevelEditable = true - ZoneSettingGetResponseZonesCacheLevelEditableFalse ZoneSettingGetResponseZonesCacheLevelEditable = false -) - -// Specify how long a visitor is allowed access to your site after successfully -// completing a challenge (such as a CAPTCHA). After the TTL has expired the -// visitor will have to complete a new challenge. We recommend a 15 - 45 minute -// setting and will attempt to honor any setting above 45 minutes. -// (https://support.cloudflare.com/hc/en-us/articles/200170136). -type ZoneSettingGetResponseZonesChallengeTTL struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesChallengeTTLID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesChallengeTTLValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesChallengeTTLEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesChallengeTTLJSON `json:"-"` -} - -// zoneSettingGetResponseZonesChallengeTTLJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesChallengeTTL] -type zoneSettingGetResponseZonesChallengeTTLJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesChallengeTTL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesChallengeTTLJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesChallengeTTL) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesChallengeTTLID string - -const ( - ZoneSettingGetResponseZonesChallengeTTLIDChallengeTTL ZoneSettingGetResponseZonesChallengeTTLID = "challenge_ttl" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesChallengeTTLValue float64 - -const ( - ZoneSettingGetResponseZonesChallengeTTLValue300 ZoneSettingGetResponseZonesChallengeTTLValue = 300 - ZoneSettingGetResponseZonesChallengeTTLValue900 ZoneSettingGetResponseZonesChallengeTTLValue = 900 - ZoneSettingGetResponseZonesChallengeTTLValue1800 ZoneSettingGetResponseZonesChallengeTTLValue = 1800 - ZoneSettingGetResponseZonesChallengeTTLValue2700 ZoneSettingGetResponseZonesChallengeTTLValue = 2700 - ZoneSettingGetResponseZonesChallengeTTLValue3600 ZoneSettingGetResponseZonesChallengeTTLValue = 3600 - ZoneSettingGetResponseZonesChallengeTTLValue7200 ZoneSettingGetResponseZonesChallengeTTLValue = 7200 - ZoneSettingGetResponseZonesChallengeTTLValue10800 ZoneSettingGetResponseZonesChallengeTTLValue = 10800 - ZoneSettingGetResponseZonesChallengeTTLValue14400 ZoneSettingGetResponseZonesChallengeTTLValue = 14400 - ZoneSettingGetResponseZonesChallengeTTLValue28800 ZoneSettingGetResponseZonesChallengeTTLValue = 28800 - ZoneSettingGetResponseZonesChallengeTTLValue57600 ZoneSettingGetResponseZonesChallengeTTLValue = 57600 - ZoneSettingGetResponseZonesChallengeTTLValue86400 ZoneSettingGetResponseZonesChallengeTTLValue = 86400 - ZoneSettingGetResponseZonesChallengeTTLValue604800 ZoneSettingGetResponseZonesChallengeTTLValue = 604800 - ZoneSettingGetResponseZonesChallengeTTLValue2592000 ZoneSettingGetResponseZonesChallengeTTLValue = 2592000 - ZoneSettingGetResponseZonesChallengeTTLValue31536000 ZoneSettingGetResponseZonesChallengeTTLValue = 31536000 -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesChallengeTTLEditable bool - -const ( - ZoneSettingGetResponseZonesChallengeTTLEditableTrue ZoneSettingGetResponseZonesChallengeTTLEditable = true - ZoneSettingGetResponseZonesChallengeTTLEditableFalse ZoneSettingGetResponseZonesChallengeTTLEditable = false -) - -// An allowlist of ciphers for TLS termination. These ciphers must be in the -// BoringSSL format. -type ZoneSettingGetResponseZonesCiphers struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesCiphersID `json:"id,required"` - // Current value of the zone setting. - Value []string `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesCiphersEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesCiphersJSON `json:"-"` -} - -// zoneSettingGetResponseZonesCiphersJSON contains the JSON metadata for the struct -// [ZoneSettingGetResponseZonesCiphers] -type zoneSettingGetResponseZonesCiphersJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesCiphers) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesCiphersJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesCiphers) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesCiphersID string - -const ( - ZoneSettingGetResponseZonesCiphersIDCiphers ZoneSettingGetResponseZonesCiphersID = "ciphers" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesCiphersEditable bool - -const ( - ZoneSettingGetResponseZonesCiphersEditableTrue ZoneSettingGetResponseZonesCiphersEditable = true - ZoneSettingGetResponseZonesCiphersEditableFalse ZoneSettingGetResponseZonesCiphersEditable = false -) - -// Whether or not cname flattening is on. -type ZoneSettingGetResponseZonesCNAMEFlattening struct { - // How to flatten the cname destination. - ID ZoneSettingGetResponseZonesCNAMEFlatteningID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesCNAMEFlatteningValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesCNAMEFlatteningEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesCNAMEFlatteningJSON `json:"-"` -} - -// zoneSettingGetResponseZonesCNAMEFlatteningJSON contains the JSON metadata for -// the struct [ZoneSettingGetResponseZonesCNAMEFlattening] -type zoneSettingGetResponseZonesCNAMEFlatteningJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesCNAMEFlattening) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesCNAMEFlatteningJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesCNAMEFlattening) implementsZoneSettingGetResponse() {} - -// How to flatten the cname destination. -type ZoneSettingGetResponseZonesCNAMEFlatteningID string - -const ( - ZoneSettingGetResponseZonesCNAMEFlatteningIDCNAMEFlattening ZoneSettingGetResponseZonesCNAMEFlatteningID = "cname_flattening" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesCNAMEFlatteningValue string - -const ( - ZoneSettingGetResponseZonesCNAMEFlatteningValueFlattenAtRoot ZoneSettingGetResponseZonesCNAMEFlatteningValue = "flatten_at_root" - ZoneSettingGetResponseZonesCNAMEFlatteningValueFlattenAll ZoneSettingGetResponseZonesCNAMEFlatteningValue = "flatten_all" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesCNAMEFlatteningEditable bool - -const ( - ZoneSettingGetResponseZonesCNAMEFlatteningEditableTrue ZoneSettingGetResponseZonesCNAMEFlatteningEditable = true - ZoneSettingGetResponseZonesCNAMEFlatteningEditableFalse ZoneSettingGetResponseZonesCNAMEFlatteningEditable = false -) - -// Development Mode temporarily allows you to enter development mode for your -// websites if you need to make changes to your site. This will bypass Cloudflare's -// accelerated cache and slow down your site, but is useful if you are making -// changes to cacheable content (like images, css, or JavaScript) and would like to -// see those changes right away. Once entered, development mode will last for 3 -// hours and then automatically toggle off. -type ZoneSettingGetResponseZonesDevelopmentMode struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesDevelopmentModeID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesDevelopmentModeValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesDevelopmentModeEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - // Value of the zone setting. Notes: The interval (in seconds) from when - // development mode expires (positive integer) or last expired (negative integer) - // for the domain. If development mode has never been enabled, this value is false. - TimeRemaining float64 `json:"time_remaining"` - JSON zoneSettingGetResponseZonesDevelopmentModeJSON `json:"-"` -} - -// zoneSettingGetResponseZonesDevelopmentModeJSON contains the JSON metadata for -// the struct [ZoneSettingGetResponseZonesDevelopmentMode] -type zoneSettingGetResponseZonesDevelopmentModeJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - TimeRemaining apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesDevelopmentMode) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesDevelopmentModeJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesDevelopmentMode) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesDevelopmentModeID string - -const ( - ZoneSettingGetResponseZonesDevelopmentModeIDDevelopmentMode ZoneSettingGetResponseZonesDevelopmentModeID = "development_mode" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesDevelopmentModeValue string - -const ( - ZoneSettingGetResponseZonesDevelopmentModeValueOn ZoneSettingGetResponseZonesDevelopmentModeValue = "on" - ZoneSettingGetResponseZonesDevelopmentModeValueOff ZoneSettingGetResponseZonesDevelopmentModeValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesDevelopmentModeEditable bool - -const ( - ZoneSettingGetResponseZonesDevelopmentModeEditableTrue ZoneSettingGetResponseZonesDevelopmentModeEditable = true - ZoneSettingGetResponseZonesDevelopmentModeEditableFalse ZoneSettingGetResponseZonesDevelopmentModeEditable = false -) - -// When enabled, Cloudflare will attempt to speed up overall page loads by serving -// `103` responses with `Link` headers from the final response. Refer to -// [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for -// more information. -type ZoneSettingGetResponseZonesEarlyHints struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesEarlyHintsID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesEarlyHintsValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesEarlyHintsEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesEarlyHintsJSON `json:"-"` -} - -// zoneSettingGetResponseZonesEarlyHintsJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesEarlyHints] -type zoneSettingGetResponseZonesEarlyHintsJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesEarlyHints) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesEarlyHintsJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesEarlyHints) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesEarlyHintsID string - -const ( - ZoneSettingGetResponseZonesEarlyHintsIDEarlyHints ZoneSettingGetResponseZonesEarlyHintsID = "early_hints" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesEarlyHintsValue string - -const ( - ZoneSettingGetResponseZonesEarlyHintsValueOn ZoneSettingGetResponseZonesEarlyHintsValue = "on" - ZoneSettingGetResponseZonesEarlyHintsValueOff ZoneSettingGetResponseZonesEarlyHintsValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesEarlyHintsEditable bool - -const ( - ZoneSettingGetResponseZonesEarlyHintsEditableTrue ZoneSettingGetResponseZonesEarlyHintsEditable = true - ZoneSettingGetResponseZonesEarlyHintsEditableFalse ZoneSettingGetResponseZonesEarlyHintsEditable = false -) - -// Time (in seconds) that a resource will be ensured to remain on Cloudflare's -// cache servers. -type ZoneSettingGetResponseZonesEdgeCacheTTL struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesEdgeCacheTTLID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesEdgeCacheTTLValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesEdgeCacheTTLEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesEdgeCacheTTLJSON `json:"-"` -} - -// zoneSettingGetResponseZonesEdgeCacheTTLJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesEdgeCacheTTL] -type zoneSettingGetResponseZonesEdgeCacheTTLJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesEdgeCacheTTL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesEdgeCacheTTLJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesEdgeCacheTTL) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesEdgeCacheTTLID string - -const ( - ZoneSettingGetResponseZonesEdgeCacheTTLIDEdgeCacheTTL ZoneSettingGetResponseZonesEdgeCacheTTLID = "edge_cache_ttl" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesEdgeCacheTTLValue float64 - -const ( - ZoneSettingGetResponseZonesEdgeCacheTTLValue30 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 30 - ZoneSettingGetResponseZonesEdgeCacheTTLValue60 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 60 - ZoneSettingGetResponseZonesEdgeCacheTTLValue300 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 300 - ZoneSettingGetResponseZonesEdgeCacheTTLValue1200 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 1200 - ZoneSettingGetResponseZonesEdgeCacheTTLValue1800 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 1800 - ZoneSettingGetResponseZonesEdgeCacheTTLValue3600 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 3600 - ZoneSettingGetResponseZonesEdgeCacheTTLValue7200 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 7200 - ZoneSettingGetResponseZonesEdgeCacheTTLValue10800 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 10800 - ZoneSettingGetResponseZonesEdgeCacheTTLValue14400 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 14400 - ZoneSettingGetResponseZonesEdgeCacheTTLValue18000 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 18000 - ZoneSettingGetResponseZonesEdgeCacheTTLValue28800 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 28800 - ZoneSettingGetResponseZonesEdgeCacheTTLValue43200 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 43200 - ZoneSettingGetResponseZonesEdgeCacheTTLValue57600 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 57600 - ZoneSettingGetResponseZonesEdgeCacheTTLValue72000 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 72000 - ZoneSettingGetResponseZonesEdgeCacheTTLValue86400 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 86400 - ZoneSettingGetResponseZonesEdgeCacheTTLValue172800 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 172800 - ZoneSettingGetResponseZonesEdgeCacheTTLValue259200 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 259200 - ZoneSettingGetResponseZonesEdgeCacheTTLValue345600 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 345600 - ZoneSettingGetResponseZonesEdgeCacheTTLValue432000 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 432000 - ZoneSettingGetResponseZonesEdgeCacheTTLValue518400 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 518400 - ZoneSettingGetResponseZonesEdgeCacheTTLValue604800 ZoneSettingGetResponseZonesEdgeCacheTTLValue = 604800 -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesEdgeCacheTTLEditable bool - -const ( - ZoneSettingGetResponseZonesEdgeCacheTTLEditableTrue ZoneSettingGetResponseZonesEdgeCacheTTLEditable = true - ZoneSettingGetResponseZonesEdgeCacheTTLEditableFalse ZoneSettingGetResponseZonesEdgeCacheTTLEditable = false -) - -// Encrypt email adresses on your web page from bots, while keeping them visible to -// humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). -type ZoneSettingGetResponseZonesEmailObfuscation struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesEmailObfuscationID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesEmailObfuscationValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesEmailObfuscationEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesEmailObfuscationJSON `json:"-"` -} - -// zoneSettingGetResponseZonesEmailObfuscationJSON contains the JSON metadata for -// the struct [ZoneSettingGetResponseZonesEmailObfuscation] -type zoneSettingGetResponseZonesEmailObfuscationJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesEmailObfuscation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesEmailObfuscationJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesEmailObfuscation) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesEmailObfuscationID string - -const ( - ZoneSettingGetResponseZonesEmailObfuscationIDEmailObfuscation ZoneSettingGetResponseZonesEmailObfuscationID = "email_obfuscation" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesEmailObfuscationValue string - -const ( - ZoneSettingGetResponseZonesEmailObfuscationValueOn ZoneSettingGetResponseZonesEmailObfuscationValue = "on" - ZoneSettingGetResponseZonesEmailObfuscationValueOff ZoneSettingGetResponseZonesEmailObfuscationValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesEmailObfuscationEditable bool - -const ( - ZoneSettingGetResponseZonesEmailObfuscationEditableTrue ZoneSettingGetResponseZonesEmailObfuscationEditable = true - ZoneSettingGetResponseZonesEmailObfuscationEditableFalse ZoneSettingGetResponseZonesEmailObfuscationEditable = false -) - -// HTTP/2 Edge Prioritization optimises the delivery of resources served through -// HTTP/2 to improve page load performance. It also supports fine control of -// content delivery when used in conjunction with Workers. -type ZoneSettingGetResponseZonesH2Prioritization struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesH2PrioritizationID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesH2PrioritizationValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesH2PrioritizationEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesH2PrioritizationJSON `json:"-"` -} - -// zoneSettingGetResponseZonesH2PrioritizationJSON contains the JSON metadata for -// the struct [ZoneSettingGetResponseZonesH2Prioritization] -type zoneSettingGetResponseZonesH2PrioritizationJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesH2Prioritization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesH2PrioritizationJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesH2Prioritization) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesH2PrioritizationID string - -const ( - ZoneSettingGetResponseZonesH2PrioritizationIDH2Prioritization ZoneSettingGetResponseZonesH2PrioritizationID = "h2_prioritization" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesH2PrioritizationValue string - -const ( - ZoneSettingGetResponseZonesH2PrioritizationValueOn ZoneSettingGetResponseZonesH2PrioritizationValue = "on" - ZoneSettingGetResponseZonesH2PrioritizationValueOff ZoneSettingGetResponseZonesH2PrioritizationValue = "off" - ZoneSettingGetResponseZonesH2PrioritizationValueCustom ZoneSettingGetResponseZonesH2PrioritizationValue = "custom" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesH2PrioritizationEditable bool - -const ( - ZoneSettingGetResponseZonesH2PrioritizationEditableTrue ZoneSettingGetResponseZonesH2PrioritizationEditable = true - ZoneSettingGetResponseZonesH2PrioritizationEditableFalse ZoneSettingGetResponseZonesH2PrioritizationEditable = false -) - -// When enabled, the Hotlink Protection option ensures that other sites cannot suck -// up your bandwidth by building pages that use images hosted on your site. Anytime -// a request for an image on your site hits Cloudflare, we check to ensure that -// it's not another site requesting them. People will still be able to download and -// view images from your page, but other sites won't be able to steal them for use -// on their own pages. -// (https://support.cloudflare.com/hc/en-us/articles/200170026). -type ZoneSettingGetResponseZonesHotlinkProtection struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesHotlinkProtectionID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesHotlinkProtectionValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesHotlinkProtectionEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesHotlinkProtectionJSON `json:"-"` -} - -// zoneSettingGetResponseZonesHotlinkProtectionJSON contains the JSON metadata for -// the struct [ZoneSettingGetResponseZonesHotlinkProtection] -type zoneSettingGetResponseZonesHotlinkProtectionJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesHotlinkProtection) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesHotlinkProtectionJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesHotlinkProtection) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesHotlinkProtectionID string - -const ( - ZoneSettingGetResponseZonesHotlinkProtectionIDHotlinkProtection ZoneSettingGetResponseZonesHotlinkProtectionID = "hotlink_protection" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesHotlinkProtectionValue string - -const ( - ZoneSettingGetResponseZonesHotlinkProtectionValueOn ZoneSettingGetResponseZonesHotlinkProtectionValue = "on" - ZoneSettingGetResponseZonesHotlinkProtectionValueOff ZoneSettingGetResponseZonesHotlinkProtectionValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesHotlinkProtectionEditable bool - -const ( - ZoneSettingGetResponseZonesHotlinkProtectionEditableTrue ZoneSettingGetResponseZonesHotlinkProtectionEditable = true - ZoneSettingGetResponseZonesHotlinkProtectionEditableFalse ZoneSettingGetResponseZonesHotlinkProtectionEditable = false -) - -// HTTP2 enabled for this zone. -type ZoneSettingGetResponseZonesHTTP2 struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesHTTP2ID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesHTTP2Value `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesHTTP2Editable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesHTTP2JSON `json:"-"` -} - -// zoneSettingGetResponseZonesHTTP2JSON contains the JSON metadata for the struct -// [ZoneSettingGetResponseZonesHTTP2] -type zoneSettingGetResponseZonesHTTP2JSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesHTTP2) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesHTTP2JSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesHTTP2) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesHTTP2ID string - -const ( - ZoneSettingGetResponseZonesHTTP2IDHTTP2 ZoneSettingGetResponseZonesHTTP2ID = "http2" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesHTTP2Value string - -const ( - ZoneSettingGetResponseZonesHTTP2ValueOn ZoneSettingGetResponseZonesHTTP2Value = "on" - ZoneSettingGetResponseZonesHTTP2ValueOff ZoneSettingGetResponseZonesHTTP2Value = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesHTTP2Editable bool - -const ( - ZoneSettingGetResponseZonesHTTP2EditableTrue ZoneSettingGetResponseZonesHTTP2Editable = true - ZoneSettingGetResponseZonesHTTP2EditableFalse ZoneSettingGetResponseZonesHTTP2Editable = false -) - -// HTTP3 enabled for this zone. -type ZoneSettingGetResponseZonesHTTP3 struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesHTTP3ID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesHTTP3Value `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesHTTP3Editable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesHTTP3JSON `json:"-"` -} - -// zoneSettingGetResponseZonesHTTP3JSON contains the JSON metadata for the struct -// [ZoneSettingGetResponseZonesHTTP3] -type zoneSettingGetResponseZonesHTTP3JSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesHTTP3) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesHTTP3JSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesHTTP3) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesHTTP3ID string - -const ( - ZoneSettingGetResponseZonesHTTP3IDHTTP3 ZoneSettingGetResponseZonesHTTP3ID = "http3" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesHTTP3Value string - -const ( - ZoneSettingGetResponseZonesHTTP3ValueOn ZoneSettingGetResponseZonesHTTP3Value = "on" - ZoneSettingGetResponseZonesHTTP3ValueOff ZoneSettingGetResponseZonesHTTP3Value = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesHTTP3Editable bool - -const ( - ZoneSettingGetResponseZonesHTTP3EditableTrue ZoneSettingGetResponseZonesHTTP3Editable = true - ZoneSettingGetResponseZonesHTTP3EditableFalse ZoneSettingGetResponseZonesHTTP3Editable = false -) - -// Image Resizing provides on-demand resizing, conversion and optimisation for -// images served through Cloudflare's network. Refer to the -// [Image Resizing documentation](https://developers.cloudflare.com/images/) for -// more information. -type ZoneSettingGetResponseZonesImageResizing struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesImageResizingID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesImageResizingValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesImageResizingEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesImageResizingJSON `json:"-"` -} - -// zoneSettingGetResponseZonesImageResizingJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesImageResizing] -type zoneSettingGetResponseZonesImageResizingJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesImageResizing) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesImageResizingJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesImageResizing) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesImageResizingID string - -const ( - ZoneSettingGetResponseZonesImageResizingIDImageResizing ZoneSettingGetResponseZonesImageResizingID = "image_resizing" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesImageResizingValue string - -const ( - ZoneSettingGetResponseZonesImageResizingValueOn ZoneSettingGetResponseZonesImageResizingValue = "on" - ZoneSettingGetResponseZonesImageResizingValueOff ZoneSettingGetResponseZonesImageResizingValue = "off" - ZoneSettingGetResponseZonesImageResizingValueOpen ZoneSettingGetResponseZonesImageResizingValue = "open" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesImageResizingEditable bool - -const ( - ZoneSettingGetResponseZonesImageResizingEditableTrue ZoneSettingGetResponseZonesImageResizingEditable = true - ZoneSettingGetResponseZonesImageResizingEditableFalse ZoneSettingGetResponseZonesImageResizingEditable = false -) - -// Enable IP Geolocation to have Cloudflare geolocate visitors to your website and -// pass the country code to you. -// (https://support.cloudflare.com/hc/en-us/articles/200168236). -type ZoneSettingGetResponseZonesIPGeolocation struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesIPGeolocationID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesIPGeolocationValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesIPGeolocationEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesIPGeolocationJSON `json:"-"` -} - -// zoneSettingGetResponseZonesIPGeolocationJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesIPGeolocation] -type zoneSettingGetResponseZonesIPGeolocationJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesIPGeolocation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesIPGeolocationJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesIPGeolocation) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesIPGeolocationID string - -const ( - ZoneSettingGetResponseZonesIPGeolocationIDIPGeolocation ZoneSettingGetResponseZonesIPGeolocationID = "ip_geolocation" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesIPGeolocationValue string - -const ( - ZoneSettingGetResponseZonesIPGeolocationValueOn ZoneSettingGetResponseZonesIPGeolocationValue = "on" - ZoneSettingGetResponseZonesIPGeolocationValueOff ZoneSettingGetResponseZonesIPGeolocationValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesIPGeolocationEditable bool - -const ( - ZoneSettingGetResponseZonesIPGeolocationEditableTrue ZoneSettingGetResponseZonesIPGeolocationEditable = true - ZoneSettingGetResponseZonesIPGeolocationEditableFalse ZoneSettingGetResponseZonesIPGeolocationEditable = false -) - -// Enable IPv6 on all subdomains that are Cloudflare enabled. -// (https://support.cloudflare.com/hc/en-us/articles/200168586). -type ZoneSettingGetResponseZonesIPV6 struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesIPV6ID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesIPV6Value `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesIPV6Editable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesIPV6JSON `json:"-"` -} - -// zoneSettingGetResponseZonesIPV6JSON contains the JSON metadata for the struct -// [ZoneSettingGetResponseZonesIPV6] -type zoneSettingGetResponseZonesIPV6JSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesIPV6) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesIPV6JSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesIPV6) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesIPV6ID string - -const ( - ZoneSettingGetResponseZonesIPV6IDIPV6 ZoneSettingGetResponseZonesIPV6ID = "ipv6" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesIPV6Value string - -const ( - ZoneSettingGetResponseZonesIPV6ValueOff ZoneSettingGetResponseZonesIPV6Value = "off" - ZoneSettingGetResponseZonesIPV6ValueOn ZoneSettingGetResponseZonesIPV6Value = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesIPV6Editable bool - -const ( - ZoneSettingGetResponseZonesIPV6EditableTrue ZoneSettingGetResponseZonesIPV6Editable = true - ZoneSettingGetResponseZonesIPV6EditableFalse ZoneSettingGetResponseZonesIPV6Editable = false -) - -// Maximum size of an allowable upload. -type ZoneSettingGetResponseZonesMaxUpload struct { - // identifier of the zone setting. - ID ZoneSettingGetResponseZonesMaxUploadID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesMaxUploadValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesMaxUploadEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesMaxUploadJSON `json:"-"` -} - -// zoneSettingGetResponseZonesMaxUploadJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesMaxUpload] -type zoneSettingGetResponseZonesMaxUploadJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesMaxUpload) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesMaxUploadJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesMaxUpload) implementsZoneSettingGetResponse() {} - -// identifier of the zone setting. -type ZoneSettingGetResponseZonesMaxUploadID string - -const ( - ZoneSettingGetResponseZonesMaxUploadIDMaxUpload ZoneSettingGetResponseZonesMaxUploadID = "max_upload" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesMaxUploadValue float64 - -const ( - ZoneSettingGetResponseZonesMaxUploadValue100 ZoneSettingGetResponseZonesMaxUploadValue = 100 - ZoneSettingGetResponseZonesMaxUploadValue200 ZoneSettingGetResponseZonesMaxUploadValue = 200 - ZoneSettingGetResponseZonesMaxUploadValue500 ZoneSettingGetResponseZonesMaxUploadValue = 500 -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesMaxUploadEditable bool - -const ( - ZoneSettingGetResponseZonesMaxUploadEditableTrue ZoneSettingGetResponseZonesMaxUploadEditable = true - ZoneSettingGetResponseZonesMaxUploadEditableFalse ZoneSettingGetResponseZonesMaxUploadEditable = false -) - -// Only accepts HTTPS requests that use at least the TLS protocol version -// specified. For example, if TLS 1.1 is selected, TLS 1.0 connections will be -// rejected, while 1.1, 1.2, and 1.3 (if enabled) will be permitted. -type ZoneSettingGetResponseZonesMinTLSVersion struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesMinTLSVersionID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesMinTLSVersionValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesMinTLSVersionEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesMinTLSVersionJSON `json:"-"` -} - -// zoneSettingGetResponseZonesMinTLSVersionJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesMinTLSVersion] -type zoneSettingGetResponseZonesMinTLSVersionJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesMinTLSVersion) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesMinTLSVersionJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesMinTLSVersion) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesMinTLSVersionID string - -const ( - ZoneSettingGetResponseZonesMinTLSVersionIDMinTLSVersion ZoneSettingGetResponseZonesMinTLSVersionID = "min_tls_version" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesMinTLSVersionValue string - -const ( - ZoneSettingGetResponseZonesMinTLSVersionValue1_0 ZoneSettingGetResponseZonesMinTLSVersionValue = "1.0" - ZoneSettingGetResponseZonesMinTLSVersionValue1_1 ZoneSettingGetResponseZonesMinTLSVersionValue = "1.1" - ZoneSettingGetResponseZonesMinTLSVersionValue1_2 ZoneSettingGetResponseZonesMinTLSVersionValue = "1.2" - ZoneSettingGetResponseZonesMinTLSVersionValue1_3 ZoneSettingGetResponseZonesMinTLSVersionValue = "1.3" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesMinTLSVersionEditable bool - -const ( - ZoneSettingGetResponseZonesMinTLSVersionEditableTrue ZoneSettingGetResponseZonesMinTLSVersionEditable = true - ZoneSettingGetResponseZonesMinTLSVersionEditableFalse ZoneSettingGetResponseZonesMinTLSVersionEditable = false -) - -// Automatically minify certain assets for your website. Refer to -// [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) -// for more information. -type ZoneSettingGetResponseZonesMinify struct { - // Zone setting identifier. - ID ZoneSettingGetResponseZonesMinifyID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesMinifyValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesMinifyEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesMinifyJSON `json:"-"` -} - -// zoneSettingGetResponseZonesMinifyJSON contains the JSON metadata for the struct -// [ZoneSettingGetResponseZonesMinify] -type zoneSettingGetResponseZonesMinifyJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesMinify) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesMinifyJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesMinify) implementsZoneSettingGetResponse() {} - -// Zone setting identifier. -type ZoneSettingGetResponseZonesMinifyID string - -const ( - ZoneSettingGetResponseZonesMinifyIDMinify ZoneSettingGetResponseZonesMinifyID = "minify" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesMinifyValue struct { - // Automatically minify all CSS files for your website. - Css ZoneSettingGetResponseZonesMinifyValueCss `json:"css"` - // Automatically minify all HTML files for your website. - HTML ZoneSettingGetResponseZonesMinifyValueHTML `json:"html"` - // Automatically minify all JavaScript files for your website. - Js ZoneSettingGetResponseZonesMinifyValueJs `json:"js"` - JSON zoneSettingGetResponseZonesMinifyValueJSON `json:"-"` -} - -// zoneSettingGetResponseZonesMinifyValueJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesMinifyValue] -type zoneSettingGetResponseZonesMinifyValueJSON struct { - Css apijson.Field - HTML apijson.Field - Js apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesMinifyValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesMinifyValueJSON) RawJSON() string { - return r.raw -} - -// Automatically minify all CSS files for your website. -type ZoneSettingGetResponseZonesMinifyValueCss string - -const ( - ZoneSettingGetResponseZonesMinifyValueCssOn ZoneSettingGetResponseZonesMinifyValueCss = "on" - ZoneSettingGetResponseZonesMinifyValueCssOff ZoneSettingGetResponseZonesMinifyValueCss = "off" -) - -// Automatically minify all HTML files for your website. -type ZoneSettingGetResponseZonesMinifyValueHTML string - -const ( - ZoneSettingGetResponseZonesMinifyValueHTMLOn ZoneSettingGetResponseZonesMinifyValueHTML = "on" - ZoneSettingGetResponseZonesMinifyValueHTMLOff ZoneSettingGetResponseZonesMinifyValueHTML = "off" -) - -// Automatically minify all JavaScript files for your website. -type ZoneSettingGetResponseZonesMinifyValueJs string - -const ( - ZoneSettingGetResponseZonesMinifyValueJsOn ZoneSettingGetResponseZonesMinifyValueJs = "on" - ZoneSettingGetResponseZonesMinifyValueJsOff ZoneSettingGetResponseZonesMinifyValueJs = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesMinifyEditable bool - -const ( - ZoneSettingGetResponseZonesMinifyEditableTrue ZoneSettingGetResponseZonesMinifyEditable = true - ZoneSettingGetResponseZonesMinifyEditableFalse ZoneSettingGetResponseZonesMinifyEditable = false -) - -// Automatically optimize image loading for website visitors on mobile devices. -// Refer to -// [our blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for -// more information. -type ZoneSettingGetResponseZonesMirage struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesMirageID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesMirageValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesMirageEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesMirageJSON `json:"-"` -} - -// zoneSettingGetResponseZonesMirageJSON contains the JSON metadata for the struct -// [ZoneSettingGetResponseZonesMirage] -type zoneSettingGetResponseZonesMirageJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesMirage) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesMirageJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesMirage) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesMirageID string - -const ( - ZoneSettingGetResponseZonesMirageIDMirage ZoneSettingGetResponseZonesMirageID = "mirage" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesMirageValue string - -const ( - ZoneSettingGetResponseZonesMirageValueOn ZoneSettingGetResponseZonesMirageValue = "on" - ZoneSettingGetResponseZonesMirageValueOff ZoneSettingGetResponseZonesMirageValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesMirageEditable bool - -const ( - ZoneSettingGetResponseZonesMirageEditableTrue ZoneSettingGetResponseZonesMirageEditable = true - ZoneSettingGetResponseZonesMirageEditableFalse ZoneSettingGetResponseZonesMirageEditable = false -) - -// Automatically redirect visitors on mobile devices to a mobile-optimized -// subdomain. Refer to -// [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) -// for more information. -type ZoneSettingGetResponseZonesMobileRedirect struct { - // Identifier of the zone setting. - ID ZoneSettingGetResponseZonesMobileRedirectID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesMobileRedirectValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesMobileRedirectEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesMobileRedirectJSON `json:"-"` -} - -// zoneSettingGetResponseZonesMobileRedirectJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesMobileRedirect] -type zoneSettingGetResponseZonesMobileRedirectJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesMobileRedirect) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesMobileRedirectJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesMobileRedirect) implementsZoneSettingGetResponse() {} - -// Identifier of the zone setting. -type ZoneSettingGetResponseZonesMobileRedirectID string - -const ( - ZoneSettingGetResponseZonesMobileRedirectIDMobileRedirect ZoneSettingGetResponseZonesMobileRedirectID = "mobile_redirect" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesMobileRedirectValue struct { - // Which subdomain prefix you wish to redirect visitors on mobile devices to - // (subdomain must already exist). - MobileSubdomain string `json:"mobile_subdomain,nullable"` - // Whether or not mobile redirect is enabled. - Status ZoneSettingGetResponseZonesMobileRedirectValueStatus `json:"status"` - // Whether to drop the current page path and redirect to the mobile subdomain URL - // root, or keep the path and redirect to the same page on the mobile subdomain. - StripURI bool `json:"strip_uri"` - JSON zoneSettingGetResponseZonesMobileRedirectValueJSON `json:"-"` -} - -// zoneSettingGetResponseZonesMobileRedirectValueJSON contains the JSON metadata -// for the struct [ZoneSettingGetResponseZonesMobileRedirectValue] -type zoneSettingGetResponseZonesMobileRedirectValueJSON struct { - MobileSubdomain apijson.Field - Status apijson.Field - StripURI apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesMobileRedirectValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesMobileRedirectValueJSON) RawJSON() string { - return r.raw -} - -// Whether or not mobile redirect is enabled. -type ZoneSettingGetResponseZonesMobileRedirectValueStatus string - -const ( - ZoneSettingGetResponseZonesMobileRedirectValueStatusOn ZoneSettingGetResponseZonesMobileRedirectValueStatus = "on" - ZoneSettingGetResponseZonesMobileRedirectValueStatusOff ZoneSettingGetResponseZonesMobileRedirectValueStatus = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesMobileRedirectEditable bool - -const ( - ZoneSettingGetResponseZonesMobileRedirectEditableTrue ZoneSettingGetResponseZonesMobileRedirectEditable = true - ZoneSettingGetResponseZonesMobileRedirectEditableFalse ZoneSettingGetResponseZonesMobileRedirectEditable = false -) - -// Enable Network Error Logging reporting on your zone. (Beta) -type ZoneSettingGetResponseZonesNEL struct { - // Zone setting identifier. - ID ZoneSettingGetResponseZonesNELID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesNELValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesNELEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesNELJSON `json:"-"` -} - -// zoneSettingGetResponseZonesNELJSON contains the JSON metadata for the struct -// [ZoneSettingGetResponseZonesNEL] -type zoneSettingGetResponseZonesNELJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesNEL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesNELJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesNEL) implementsZoneSettingGetResponse() {} - -// Zone setting identifier. -type ZoneSettingGetResponseZonesNELID string - -const ( - ZoneSettingGetResponseZonesNELIDNEL ZoneSettingGetResponseZonesNELID = "nel" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesNELValue struct { - Enabled bool `json:"enabled"` - JSON zoneSettingGetResponseZonesNELValueJSON `json:"-"` -} - -// zoneSettingGetResponseZonesNELValueJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesNELValue] -type zoneSettingGetResponseZonesNELValueJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesNELValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesNELValueJSON) RawJSON() string { - return r.raw -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesNELEditable bool - -const ( - ZoneSettingGetResponseZonesNELEditableTrue ZoneSettingGetResponseZonesNELEditable = true - ZoneSettingGetResponseZonesNELEditableFalse ZoneSettingGetResponseZonesNELEditable = false -) - -// Enables the Opportunistic Encryption feature for a zone. -type ZoneSettingGetResponseZonesOpportunisticEncryption struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesOpportunisticEncryptionID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesOpportunisticEncryptionValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesOpportunisticEncryptionEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesOpportunisticEncryptionJSON `json:"-"` -} - -// zoneSettingGetResponseZonesOpportunisticEncryptionJSON contains the JSON -// metadata for the struct [ZoneSettingGetResponseZonesOpportunisticEncryption] -type zoneSettingGetResponseZonesOpportunisticEncryptionJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesOpportunisticEncryption) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesOpportunisticEncryptionJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesOpportunisticEncryption) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesOpportunisticEncryptionID string - -const ( - ZoneSettingGetResponseZonesOpportunisticEncryptionIDOpportunisticEncryption ZoneSettingGetResponseZonesOpportunisticEncryptionID = "opportunistic_encryption" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesOpportunisticEncryptionValue string - -const ( - ZoneSettingGetResponseZonesOpportunisticEncryptionValueOn ZoneSettingGetResponseZonesOpportunisticEncryptionValue = "on" - ZoneSettingGetResponseZonesOpportunisticEncryptionValueOff ZoneSettingGetResponseZonesOpportunisticEncryptionValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesOpportunisticEncryptionEditable bool - -const ( - ZoneSettingGetResponseZonesOpportunisticEncryptionEditableTrue ZoneSettingGetResponseZonesOpportunisticEncryptionEditable = true - ZoneSettingGetResponseZonesOpportunisticEncryptionEditableFalse ZoneSettingGetResponseZonesOpportunisticEncryptionEditable = false -) - -// Add an Alt-Svc header to all legitimate requests from Tor, allowing the -// connection to use our onion services instead of exit nodes. -type ZoneSettingGetResponseZonesOpportunisticOnion struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesOpportunisticOnionID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesOpportunisticOnionValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesOpportunisticOnionEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesOpportunisticOnionJSON `json:"-"` -} - -// zoneSettingGetResponseZonesOpportunisticOnionJSON contains the JSON metadata for -// the struct [ZoneSettingGetResponseZonesOpportunisticOnion] -type zoneSettingGetResponseZonesOpportunisticOnionJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesOpportunisticOnion) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesOpportunisticOnionJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesOpportunisticOnion) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesOpportunisticOnionID string - -const ( - ZoneSettingGetResponseZonesOpportunisticOnionIDOpportunisticOnion ZoneSettingGetResponseZonesOpportunisticOnionID = "opportunistic_onion" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesOpportunisticOnionValue string - -const ( - ZoneSettingGetResponseZonesOpportunisticOnionValueOn ZoneSettingGetResponseZonesOpportunisticOnionValue = "on" - ZoneSettingGetResponseZonesOpportunisticOnionValueOff ZoneSettingGetResponseZonesOpportunisticOnionValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesOpportunisticOnionEditable bool - -const ( - ZoneSettingGetResponseZonesOpportunisticOnionEditableTrue ZoneSettingGetResponseZonesOpportunisticOnionEditable = true - ZoneSettingGetResponseZonesOpportunisticOnionEditableFalse ZoneSettingGetResponseZonesOpportunisticOnionEditable = false -) - -// Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also -// on Cloudflare. -type ZoneSettingGetResponseZonesOrangeToOrange struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesOrangeToOrangeID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesOrangeToOrangeValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesOrangeToOrangeEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesOrangeToOrangeJSON `json:"-"` -} - -// zoneSettingGetResponseZonesOrangeToOrangeJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesOrangeToOrange] -type zoneSettingGetResponseZonesOrangeToOrangeJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesOrangeToOrange) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesOrangeToOrangeJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesOrangeToOrange) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesOrangeToOrangeID string - -const ( - ZoneSettingGetResponseZonesOrangeToOrangeIDOrangeToOrange ZoneSettingGetResponseZonesOrangeToOrangeID = "orange_to_orange" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesOrangeToOrangeValue string - -const ( - ZoneSettingGetResponseZonesOrangeToOrangeValueOn ZoneSettingGetResponseZonesOrangeToOrangeValue = "on" - ZoneSettingGetResponseZonesOrangeToOrangeValueOff ZoneSettingGetResponseZonesOrangeToOrangeValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesOrangeToOrangeEditable bool - -const ( - ZoneSettingGetResponseZonesOrangeToOrangeEditableTrue ZoneSettingGetResponseZonesOrangeToOrangeEditable = true - ZoneSettingGetResponseZonesOrangeToOrangeEditableFalse ZoneSettingGetResponseZonesOrangeToOrangeEditable = false -) - -// Cloudflare will proxy customer error pages on any 502,504 errors on origin -// server instead of showing a default Cloudflare error page. This does not apply -// to 522 errors and is limited to Enterprise Zones. -type ZoneSettingGetResponseZonesOriginErrorPagePassThru struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesOriginErrorPagePassThruID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesOriginErrorPagePassThruValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesOriginErrorPagePassThruEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesOriginErrorPagePassThruJSON `json:"-"` -} - -// zoneSettingGetResponseZonesOriginErrorPagePassThruJSON contains the JSON -// metadata for the struct [ZoneSettingGetResponseZonesOriginErrorPagePassThru] -type zoneSettingGetResponseZonesOriginErrorPagePassThruJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesOriginErrorPagePassThru) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesOriginErrorPagePassThruJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesOriginErrorPagePassThru) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesOriginErrorPagePassThruID string - -const ( - ZoneSettingGetResponseZonesOriginErrorPagePassThruIDOriginErrorPagePassThru ZoneSettingGetResponseZonesOriginErrorPagePassThruID = "origin_error_page_pass_thru" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesOriginErrorPagePassThruValue string - -const ( - ZoneSettingGetResponseZonesOriginErrorPagePassThruValueOn ZoneSettingGetResponseZonesOriginErrorPagePassThruValue = "on" - ZoneSettingGetResponseZonesOriginErrorPagePassThruValueOff ZoneSettingGetResponseZonesOriginErrorPagePassThruValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesOriginErrorPagePassThruEditable bool - -const ( - ZoneSettingGetResponseZonesOriginErrorPagePassThruEditableTrue ZoneSettingGetResponseZonesOriginErrorPagePassThruEditable = true - ZoneSettingGetResponseZonesOriginErrorPagePassThruEditableFalse ZoneSettingGetResponseZonesOriginErrorPagePassThruEditable = false -) - -// Removes metadata and compresses your images for faster page load times. Basic -// (Lossless): Reduce the size of PNG, JPEG, and GIF files - no impact on visual -// quality. Basic + JPEG (Lossy): Further reduce the size of JPEG files for faster -// image loading. Larger JPEGs are converted to progressive images, loading a -// lower-resolution image first and ending in a higher-resolution version. Not -// recommended for hi-res photography sites. -type ZoneSettingGetResponseZonesPolish struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesPolishID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesPolishValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesPolishEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesPolishJSON `json:"-"` -} - -// zoneSettingGetResponseZonesPolishJSON contains the JSON metadata for the struct -// [ZoneSettingGetResponseZonesPolish] -type zoneSettingGetResponseZonesPolishJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesPolish) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesPolishJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesPolish) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesPolishID string - -const ( - ZoneSettingGetResponseZonesPolishIDPolish ZoneSettingGetResponseZonesPolishID = "polish" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesPolishValue string - -const ( - ZoneSettingGetResponseZonesPolishValueOff ZoneSettingGetResponseZonesPolishValue = "off" - ZoneSettingGetResponseZonesPolishValueLossless ZoneSettingGetResponseZonesPolishValue = "lossless" - ZoneSettingGetResponseZonesPolishValueLossy ZoneSettingGetResponseZonesPolishValue = "lossy" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesPolishEditable bool - -const ( - ZoneSettingGetResponseZonesPolishEditableTrue ZoneSettingGetResponseZonesPolishEditable = true - ZoneSettingGetResponseZonesPolishEditableFalse ZoneSettingGetResponseZonesPolishEditable = false -) - -// Cloudflare will prefetch any URLs that are included in the response headers. -// This is limited to Enterprise Zones. -type ZoneSettingGetResponseZonesPrefetchPreload struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesPrefetchPreloadID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesPrefetchPreloadValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesPrefetchPreloadEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesPrefetchPreloadJSON `json:"-"` -} - -// zoneSettingGetResponseZonesPrefetchPreloadJSON contains the JSON metadata for -// the struct [ZoneSettingGetResponseZonesPrefetchPreload] -type zoneSettingGetResponseZonesPrefetchPreloadJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesPrefetchPreload) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesPrefetchPreloadJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesPrefetchPreload) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesPrefetchPreloadID string - -const ( - ZoneSettingGetResponseZonesPrefetchPreloadIDPrefetchPreload ZoneSettingGetResponseZonesPrefetchPreloadID = "prefetch_preload" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesPrefetchPreloadValue string - -const ( - ZoneSettingGetResponseZonesPrefetchPreloadValueOn ZoneSettingGetResponseZonesPrefetchPreloadValue = "on" - ZoneSettingGetResponseZonesPrefetchPreloadValueOff ZoneSettingGetResponseZonesPrefetchPreloadValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesPrefetchPreloadEditable bool - -const ( - ZoneSettingGetResponseZonesPrefetchPreloadEditableTrue ZoneSettingGetResponseZonesPrefetchPreloadEditable = true - ZoneSettingGetResponseZonesPrefetchPreloadEditableFalse ZoneSettingGetResponseZonesPrefetchPreloadEditable = false -) - -// Maximum time between two read operations from origin. -type ZoneSettingGetResponseZonesProxyReadTimeout struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesProxyReadTimeoutID `json:"id,required"` - // Current value of the zone setting. - Value float64 `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesProxyReadTimeoutEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesProxyReadTimeoutJSON `json:"-"` -} - -// zoneSettingGetResponseZonesProxyReadTimeoutJSON contains the JSON metadata for -// the struct [ZoneSettingGetResponseZonesProxyReadTimeout] -type zoneSettingGetResponseZonesProxyReadTimeoutJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesProxyReadTimeout) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesProxyReadTimeoutJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesProxyReadTimeout) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesProxyReadTimeoutID string - -const ( - ZoneSettingGetResponseZonesProxyReadTimeoutIDProxyReadTimeout ZoneSettingGetResponseZonesProxyReadTimeoutID = "proxy_read_timeout" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesProxyReadTimeoutEditable bool - -const ( - ZoneSettingGetResponseZonesProxyReadTimeoutEditableTrue ZoneSettingGetResponseZonesProxyReadTimeoutEditable = true - ZoneSettingGetResponseZonesProxyReadTimeoutEditableFalse ZoneSettingGetResponseZonesProxyReadTimeoutEditable = false -) - -// The value set for the Pseudo IPv4 setting. -type ZoneSettingGetResponseZonesPseudoIPV4 struct { - // Value of the Pseudo IPv4 setting. - ID ZoneSettingGetResponseZonesPseudoIPV4ID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesPseudoIPV4Value `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesPseudoIPV4Editable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesPseudoIPV4JSON `json:"-"` -} - -// zoneSettingGetResponseZonesPseudoIPV4JSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesPseudoIPV4] -type zoneSettingGetResponseZonesPseudoIPV4JSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesPseudoIPV4) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesPseudoIPV4JSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesPseudoIPV4) implementsZoneSettingGetResponse() {} - -// Value of the Pseudo IPv4 setting. -type ZoneSettingGetResponseZonesPseudoIPV4ID string - -const ( - ZoneSettingGetResponseZonesPseudoIPV4IDPseudoIPV4 ZoneSettingGetResponseZonesPseudoIPV4ID = "pseudo_ipv4" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesPseudoIPV4Value string - -const ( - ZoneSettingGetResponseZonesPseudoIPV4ValueOff ZoneSettingGetResponseZonesPseudoIPV4Value = "off" - ZoneSettingGetResponseZonesPseudoIPV4ValueAddHeader ZoneSettingGetResponseZonesPseudoIPV4Value = "add_header" - ZoneSettingGetResponseZonesPseudoIPV4ValueOverwriteHeader ZoneSettingGetResponseZonesPseudoIPV4Value = "overwrite_header" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesPseudoIPV4Editable bool - -const ( - ZoneSettingGetResponseZonesPseudoIPV4EditableTrue ZoneSettingGetResponseZonesPseudoIPV4Editable = true - ZoneSettingGetResponseZonesPseudoIPV4EditableFalse ZoneSettingGetResponseZonesPseudoIPV4Editable = false -) - -// Enables or disables buffering of responses from the proxied server. Cloudflare -// may buffer the whole payload to deliver it at once to the client versus allowing -// it to be delivered in chunks. By default, the proxied server streams directly -// and is not buffered by Cloudflare. This is limited to Enterprise Zones. -type ZoneSettingGetResponseZonesResponseBuffering struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesResponseBufferingID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesResponseBufferingValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesResponseBufferingEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesResponseBufferingJSON `json:"-"` -} - -// zoneSettingGetResponseZonesResponseBufferingJSON contains the JSON metadata for -// the struct [ZoneSettingGetResponseZonesResponseBuffering] -type zoneSettingGetResponseZonesResponseBufferingJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesResponseBuffering) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesResponseBufferingJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesResponseBuffering) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesResponseBufferingID string - -const ( - ZoneSettingGetResponseZonesResponseBufferingIDResponseBuffering ZoneSettingGetResponseZonesResponseBufferingID = "response_buffering" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesResponseBufferingValue string - -const ( - ZoneSettingGetResponseZonesResponseBufferingValueOn ZoneSettingGetResponseZonesResponseBufferingValue = "on" - ZoneSettingGetResponseZonesResponseBufferingValueOff ZoneSettingGetResponseZonesResponseBufferingValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesResponseBufferingEditable bool - -const ( - ZoneSettingGetResponseZonesResponseBufferingEditableTrue ZoneSettingGetResponseZonesResponseBufferingEditable = true - ZoneSettingGetResponseZonesResponseBufferingEditableFalse ZoneSettingGetResponseZonesResponseBufferingEditable = false -) - -// Rocket Loader is a general-purpose asynchronous JavaScript optimisation that -// prioritises rendering your content while loading your site's Javascript -// asynchronously. Turning on Rocket Loader will immediately improve a web page's -// rendering time sometimes measured as Time to First Paint (TTFP), and also the -// `window.onload` time (assuming there is JavaScript on the page). This can have a -// positive impact on your Google search ranking. When turned on, Rocket Loader -// will automatically defer the loading of all Javascript referenced in your HTML, -// with no configuration required. Refer to -// [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) -// for more information. -type ZoneSettingGetResponseZonesRocketLoader struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesRocketLoaderID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesRocketLoaderValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesRocketLoaderEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesRocketLoaderJSON `json:"-"` -} - -// zoneSettingGetResponseZonesRocketLoaderJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesRocketLoader] -type zoneSettingGetResponseZonesRocketLoaderJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesRocketLoader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesRocketLoaderJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesRocketLoader) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesRocketLoaderID string - -const ( - ZoneSettingGetResponseZonesRocketLoaderIDRocketLoader ZoneSettingGetResponseZonesRocketLoaderID = "rocket_loader" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesRocketLoaderValue string - -const ( - ZoneSettingGetResponseZonesRocketLoaderValueOn ZoneSettingGetResponseZonesRocketLoaderValue = "on" - ZoneSettingGetResponseZonesRocketLoaderValueOff ZoneSettingGetResponseZonesRocketLoaderValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesRocketLoaderEditable bool - -const ( - ZoneSettingGetResponseZonesRocketLoaderEditableTrue ZoneSettingGetResponseZonesRocketLoaderEditable = true - ZoneSettingGetResponseZonesRocketLoaderEditableFalse ZoneSettingGetResponseZonesRocketLoaderEditable = false -) - -// [Automatic Platform Optimization for WordPress](https://developers.cloudflare.com/automatic-platform-optimization/) -// serves your WordPress site from Cloudflare's edge network and caches third-party -// fonts. -type ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimization struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationJSON `json:"-"` -} - -// zoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationJSON contains the -// JSON metadata for the struct -// [ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimization] -type zoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimization) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimization) implementsZoneSettingGetResponse() { -} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationID string - -const ( - ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationIDAutomaticPlatformOptimization ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationID = "automatic_platform_optimization" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationValue struct { - // Indicates whether or not - // [cache by device type](https://developers.cloudflare.com/automatic-platform-optimization/reference/cache-device-type/) - // is enabled. - CacheByDeviceType bool `json:"cache_by_device_type,required"` - // Indicates whether or not Cloudflare proxy is enabled. - Cf bool `json:"cf,required"` - // Indicates whether or not Automatic Platform Optimization is enabled. - Enabled bool `json:"enabled,required"` - // An array of hostnames where Automatic Platform Optimization for WordPress is - // activated. - Hostnames []string `json:"hostnames,required" format:"hostname"` - // Indicates whether or not site is powered by WordPress. - Wordpress bool `json:"wordpress,required"` - // Indicates whether or not - // [Cloudflare for WordPress plugin](https://wordpress.org/plugins/cloudflare/) is - // installed. - WpPlugin bool `json:"wp_plugin,required"` - JSON zoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationValueJSON `json:"-"` -} - -// zoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationValueJSON -// contains the JSON metadata for the struct -// [ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationValue] -type zoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationValueJSON struct { - CacheByDeviceType apijson.Field - Cf apijson.Field - Enabled apijson.Field - Hostnames apijson.Field - Wordpress apijson.Field - WpPlugin apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationValueJSON) RawJSON() string { - return r.raw -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditable bool - -const ( - ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditableTrue ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditable = true - ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditableFalse ZoneSettingGetResponseZonesSchemasAutomaticPlatformOptimizationEditable = false -) - -// Cloudflare security header for a zone. -type ZoneSettingGetResponseZonesSecurityHeader struct { - // ID of the zone's security header. - ID ZoneSettingGetResponseZonesSecurityHeaderID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesSecurityHeaderValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesSecurityHeaderEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesSecurityHeaderJSON `json:"-"` -} - -// zoneSettingGetResponseZonesSecurityHeaderJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesSecurityHeader] -type zoneSettingGetResponseZonesSecurityHeaderJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesSecurityHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesSecurityHeaderJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesSecurityHeader) implementsZoneSettingGetResponse() {} - -// ID of the zone's security header. -type ZoneSettingGetResponseZonesSecurityHeaderID string - -const ( - ZoneSettingGetResponseZonesSecurityHeaderIDSecurityHeader ZoneSettingGetResponseZonesSecurityHeaderID = "security_header" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesSecurityHeaderValue struct { - // Strict Transport Security. - StrictTransportSecurity ZoneSettingGetResponseZonesSecurityHeaderValueStrictTransportSecurity `json:"strict_transport_security"` - JSON zoneSettingGetResponseZonesSecurityHeaderValueJSON `json:"-"` -} - -// zoneSettingGetResponseZonesSecurityHeaderValueJSON contains the JSON metadata -// for the struct [ZoneSettingGetResponseZonesSecurityHeaderValue] -type zoneSettingGetResponseZonesSecurityHeaderValueJSON struct { - StrictTransportSecurity apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesSecurityHeaderValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesSecurityHeaderValueJSON) RawJSON() string { - return r.raw -} - -// Strict Transport Security. -type ZoneSettingGetResponseZonesSecurityHeaderValueStrictTransportSecurity struct { - // Whether or not strict transport security is enabled. - Enabled bool `json:"enabled"` - // Include all subdomains for strict transport security. - IncludeSubdomains bool `json:"include_subdomains"` - // Max age in seconds of the strict transport security. - MaxAge float64 `json:"max_age"` - // Whether or not to include 'X-Content-Type-Options: nosniff' header. - Nosniff bool `json:"nosniff"` - JSON zoneSettingGetResponseZonesSecurityHeaderValueStrictTransportSecurityJSON `json:"-"` -} - -// zoneSettingGetResponseZonesSecurityHeaderValueStrictTransportSecurityJSON -// contains the JSON metadata for the struct -// [ZoneSettingGetResponseZonesSecurityHeaderValueStrictTransportSecurity] -type zoneSettingGetResponseZonesSecurityHeaderValueStrictTransportSecurityJSON struct { - Enabled apijson.Field - IncludeSubdomains apijson.Field - MaxAge apijson.Field - Nosniff apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesSecurityHeaderValueStrictTransportSecurity) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesSecurityHeaderValueStrictTransportSecurityJSON) RawJSON() string { - return r.raw -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesSecurityHeaderEditable bool - -const ( - ZoneSettingGetResponseZonesSecurityHeaderEditableTrue ZoneSettingGetResponseZonesSecurityHeaderEditable = true - ZoneSettingGetResponseZonesSecurityHeaderEditableFalse ZoneSettingGetResponseZonesSecurityHeaderEditable = false -) - -// Choose the appropriate security profile for your website, which will -// automatically adjust each of the security settings. If you choose to customize -// an individual security setting, the profile will become Custom. -// (https://support.cloudflare.com/hc/en-us/articles/200170056). -type ZoneSettingGetResponseZonesSecurityLevel struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesSecurityLevelID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesSecurityLevelValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesSecurityLevelEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesSecurityLevelJSON `json:"-"` -} - -// zoneSettingGetResponseZonesSecurityLevelJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesSecurityLevel] -type zoneSettingGetResponseZonesSecurityLevelJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesSecurityLevel) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesSecurityLevelJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesSecurityLevel) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesSecurityLevelID string - -const ( - ZoneSettingGetResponseZonesSecurityLevelIDSecurityLevel ZoneSettingGetResponseZonesSecurityLevelID = "security_level" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesSecurityLevelValue string - -const ( - ZoneSettingGetResponseZonesSecurityLevelValueOff ZoneSettingGetResponseZonesSecurityLevelValue = "off" - ZoneSettingGetResponseZonesSecurityLevelValueEssentiallyOff ZoneSettingGetResponseZonesSecurityLevelValue = "essentially_off" - ZoneSettingGetResponseZonesSecurityLevelValueLow ZoneSettingGetResponseZonesSecurityLevelValue = "low" - ZoneSettingGetResponseZonesSecurityLevelValueMedium ZoneSettingGetResponseZonesSecurityLevelValue = "medium" - ZoneSettingGetResponseZonesSecurityLevelValueHigh ZoneSettingGetResponseZonesSecurityLevelValue = "high" - ZoneSettingGetResponseZonesSecurityLevelValueUnderAttack ZoneSettingGetResponseZonesSecurityLevelValue = "under_attack" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesSecurityLevelEditable bool - -const ( - ZoneSettingGetResponseZonesSecurityLevelEditableTrue ZoneSettingGetResponseZonesSecurityLevelEditable = true - ZoneSettingGetResponseZonesSecurityLevelEditableFalse ZoneSettingGetResponseZonesSecurityLevelEditable = false -) - -// If there is sensitive content on your website that you want visible to real -// visitors, but that you want to hide from suspicious visitors, all you have to do -// is wrap the content with Cloudflare SSE tags. Wrap any content that you want to -// be excluded from suspicious visitors in the following SSE tags: -// . For example: Bad visitors won't see my phone -// number, 555-555-5555 . Note: SSE only will work with HTML. If you -// have HTML minification enabled, you won't see the SSE tags in your HTML source -// when it's served through Cloudflare. SSE will still function in this case, as -// Cloudflare's HTML minification and SSE functionality occur on-the-fly as the -// resource moves through our network to the visitor's computer. -// (https://support.cloudflare.com/hc/en-us/articles/200170036). -type ZoneSettingGetResponseZonesServerSideExclude struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesServerSideExcludeID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesServerSideExcludeValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesServerSideExcludeEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesServerSideExcludeJSON `json:"-"` -} - -// zoneSettingGetResponseZonesServerSideExcludeJSON contains the JSON metadata for -// the struct [ZoneSettingGetResponseZonesServerSideExclude] -type zoneSettingGetResponseZonesServerSideExcludeJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesServerSideExclude) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesServerSideExcludeJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesServerSideExclude) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesServerSideExcludeID string - -const ( - ZoneSettingGetResponseZonesServerSideExcludeIDServerSideExclude ZoneSettingGetResponseZonesServerSideExcludeID = "server_side_exclude" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesServerSideExcludeValue string - -const ( - ZoneSettingGetResponseZonesServerSideExcludeValueOn ZoneSettingGetResponseZonesServerSideExcludeValue = "on" - ZoneSettingGetResponseZonesServerSideExcludeValueOff ZoneSettingGetResponseZonesServerSideExcludeValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesServerSideExcludeEditable bool - -const ( - ZoneSettingGetResponseZonesServerSideExcludeEditableTrue ZoneSettingGetResponseZonesServerSideExcludeEditable = true - ZoneSettingGetResponseZonesServerSideExcludeEditableFalse ZoneSettingGetResponseZonesServerSideExcludeEditable = false -) - -// Allow SHA1 support. -type ZoneSettingGetResponseZonesSha1Support struct { - // Zone setting identifier. - ID ZoneSettingGetResponseZonesSha1SupportID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesSha1SupportValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesSha1SupportEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesSha1SupportJSON `json:"-"` -} - -// zoneSettingGetResponseZonesSha1SupportJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesSha1Support] -type zoneSettingGetResponseZonesSha1SupportJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesSha1Support) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesSha1SupportJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesSha1Support) implementsZoneSettingGetResponse() {} - -// Zone setting identifier. -type ZoneSettingGetResponseZonesSha1SupportID string - -const ( - ZoneSettingGetResponseZonesSha1SupportIDSha1Support ZoneSettingGetResponseZonesSha1SupportID = "sha1_support" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesSha1SupportValue string - -const ( - ZoneSettingGetResponseZonesSha1SupportValueOff ZoneSettingGetResponseZonesSha1SupportValue = "off" - ZoneSettingGetResponseZonesSha1SupportValueOn ZoneSettingGetResponseZonesSha1SupportValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesSha1SupportEditable bool - -const ( - ZoneSettingGetResponseZonesSha1SupportEditableTrue ZoneSettingGetResponseZonesSha1SupportEditable = true - ZoneSettingGetResponseZonesSha1SupportEditableFalse ZoneSettingGetResponseZonesSha1SupportEditable = false -) - -// Cloudflare will treat files with the same query strings as the same file in -// cache, regardless of the order of the query strings. This is limited to -// Enterprise Zones. -type ZoneSettingGetResponseZonesSortQueryStringForCache struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesSortQueryStringForCacheID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesSortQueryStringForCacheValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesSortQueryStringForCacheEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesSortQueryStringForCacheJSON `json:"-"` -} - -// zoneSettingGetResponseZonesSortQueryStringForCacheJSON contains the JSON -// metadata for the struct [ZoneSettingGetResponseZonesSortQueryStringForCache] -type zoneSettingGetResponseZonesSortQueryStringForCacheJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesSortQueryStringForCache) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesSortQueryStringForCacheJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesSortQueryStringForCache) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesSortQueryStringForCacheID string - -const ( - ZoneSettingGetResponseZonesSortQueryStringForCacheIDSortQueryStringForCache ZoneSettingGetResponseZonesSortQueryStringForCacheID = "sort_query_string_for_cache" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesSortQueryStringForCacheValue string - -const ( - ZoneSettingGetResponseZonesSortQueryStringForCacheValueOn ZoneSettingGetResponseZonesSortQueryStringForCacheValue = "on" - ZoneSettingGetResponseZonesSortQueryStringForCacheValueOff ZoneSettingGetResponseZonesSortQueryStringForCacheValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesSortQueryStringForCacheEditable bool - -const ( - ZoneSettingGetResponseZonesSortQueryStringForCacheEditableTrue ZoneSettingGetResponseZonesSortQueryStringForCacheEditable = true - ZoneSettingGetResponseZonesSortQueryStringForCacheEditableFalse ZoneSettingGetResponseZonesSortQueryStringForCacheEditable = false -) - -// SSL encrypts your visitor's connection and safeguards credit card numbers and -// other personal data to and from your website. SSL can take up to 5 minutes to -// fully activate. Requires Cloudflare active on your root domain or www domain. -// Off: no SSL between the visitor and Cloudflare, and no SSL between Cloudflare -// and your web server (all HTTP traffic). Flexible: SSL between the visitor and -// Cloudflare -- visitor sees HTTPS on your site, but no SSL between Cloudflare and -// your web server. You don't need to have an SSL cert on your web server, but your -// vistors will still see the site as being HTTPS enabled. Full: SSL between the -// visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between -// Cloudflare and your web server. You'll need to have your own SSL cert or -// self-signed cert at the very least. Full (Strict): SSL between the visitor and -// Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and -// your web server. You'll need to have a valid SSL certificate installed on your -// web server. This certificate must be signed by a certificate authority, have an -// expiration date in the future, and respond for the request domain name -// (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). -type ZoneSettingGetResponseZonesSSL struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesSSLID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesSSLValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesSSLEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesSSLJSON `json:"-"` -} - -// zoneSettingGetResponseZonesSSLJSON contains the JSON metadata for the struct -// [ZoneSettingGetResponseZonesSSL] -type zoneSettingGetResponseZonesSSLJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesSSL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesSSLJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesSSL) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesSSLID string - -const ( - ZoneSettingGetResponseZonesSSLIDSSL ZoneSettingGetResponseZonesSSLID = "ssl" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesSSLValue string - -const ( - ZoneSettingGetResponseZonesSSLValueOff ZoneSettingGetResponseZonesSSLValue = "off" - ZoneSettingGetResponseZonesSSLValueFlexible ZoneSettingGetResponseZonesSSLValue = "flexible" - ZoneSettingGetResponseZonesSSLValueFull ZoneSettingGetResponseZonesSSLValue = "full" - ZoneSettingGetResponseZonesSSLValueStrict ZoneSettingGetResponseZonesSSLValue = "strict" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesSSLEditable bool - -const ( - ZoneSettingGetResponseZonesSSLEditableTrue ZoneSettingGetResponseZonesSSLEditable = true - ZoneSettingGetResponseZonesSSLEditableFalse ZoneSettingGetResponseZonesSSLEditable = false -) - -// Enrollment in the SSL/TLS Recommender service which tries to detect and -// recommend (by sending periodic emails) the most secure SSL/TLS setting your -// origin servers support. -type ZoneSettingGetResponseZonesSSLRecommender struct { - // Enrollment value for SSL/TLS Recommender. - ID ZoneSettingGetResponseZonesSSLRecommenderID `json:"id"` - // ssl-recommender enrollment setting. - Enabled bool `json:"enabled"` - JSON zoneSettingGetResponseZonesSSLRecommenderJSON `json:"-"` -} - -// zoneSettingGetResponseZonesSSLRecommenderJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesSSLRecommender] -type zoneSettingGetResponseZonesSSLRecommenderJSON struct { - ID apijson.Field - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesSSLRecommender) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesSSLRecommenderJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesSSLRecommender) implementsZoneSettingGetResponse() {} - -// Enrollment value for SSL/TLS Recommender. -type ZoneSettingGetResponseZonesSSLRecommenderID string - -const ( - ZoneSettingGetResponseZonesSSLRecommenderIDSSLRecommender ZoneSettingGetResponseZonesSSLRecommenderID = "ssl_recommender" -) - -// Only allows TLS1.2. -type ZoneSettingGetResponseZonesTLS1_2Only struct { - // Zone setting identifier. - ID ZoneSettingGetResponseZonesTLS1_2OnlyID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesTLS1_2OnlyValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesTLS1_2OnlyEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesTls1_2OnlyJSON `json:"-"` -} - -// zoneSettingGetResponseZonesTls1_2OnlyJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesTLS1_2Only] -type zoneSettingGetResponseZonesTls1_2OnlyJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesTLS1_2Only) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesTls1_2OnlyJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesTLS1_2Only) implementsZoneSettingGetResponse() {} - -// Zone setting identifier. -type ZoneSettingGetResponseZonesTLS1_2OnlyID string - -const ( - ZoneSettingGetResponseZonesTLS1_2OnlyIDTLS1_2Only ZoneSettingGetResponseZonesTLS1_2OnlyID = "tls_1_2_only" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesTLS1_2OnlyValue string - -const ( - ZoneSettingGetResponseZonesTLS1_2OnlyValueOff ZoneSettingGetResponseZonesTLS1_2OnlyValue = "off" - ZoneSettingGetResponseZonesTLS1_2OnlyValueOn ZoneSettingGetResponseZonesTLS1_2OnlyValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesTLS1_2OnlyEditable bool - -const ( - ZoneSettingGetResponseZonesTLS1_2OnlyEditableTrue ZoneSettingGetResponseZonesTLS1_2OnlyEditable = true - ZoneSettingGetResponseZonesTLS1_2OnlyEditableFalse ZoneSettingGetResponseZonesTLS1_2OnlyEditable = false -) - -// Enables Crypto TLS 1.3 feature for a zone. -type ZoneSettingGetResponseZonesTLS1_3 struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesTLS1_3ID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesTLS1_3Value `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesTLS1_3Editable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesTls1_3JSON `json:"-"` -} - -// zoneSettingGetResponseZonesTls1_3JSON contains the JSON metadata for the struct -// [ZoneSettingGetResponseZonesTLS1_3] -type zoneSettingGetResponseZonesTls1_3JSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesTLS1_3) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesTls1_3JSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesTLS1_3) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesTLS1_3ID string - -const ( - ZoneSettingGetResponseZonesTLS1_3IDTLS1_3 ZoneSettingGetResponseZonesTLS1_3ID = "tls_1_3" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesTLS1_3Value string - -const ( - ZoneSettingGetResponseZonesTLS1_3ValueOn ZoneSettingGetResponseZonesTLS1_3Value = "on" - ZoneSettingGetResponseZonesTLS1_3ValueOff ZoneSettingGetResponseZonesTLS1_3Value = "off" - ZoneSettingGetResponseZonesTLS1_3ValueZrt ZoneSettingGetResponseZonesTLS1_3Value = "zrt" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesTLS1_3Editable bool - -const ( - ZoneSettingGetResponseZonesTLS1_3EditableTrue ZoneSettingGetResponseZonesTLS1_3Editable = true - ZoneSettingGetResponseZonesTLS1_3EditableFalse ZoneSettingGetResponseZonesTLS1_3Editable = false -) - -// TLS Client Auth requires Cloudflare to connect to your origin server using a -// client certificate (Enterprise Only). -type ZoneSettingGetResponseZonesTLSClientAuth struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesTLSClientAuthID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesTLSClientAuthValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesTLSClientAuthEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesTLSClientAuthJSON `json:"-"` -} - -// zoneSettingGetResponseZonesTLSClientAuthJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesTLSClientAuth] -type zoneSettingGetResponseZonesTLSClientAuthJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesTLSClientAuth) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesTLSClientAuthJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesTLSClientAuth) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesTLSClientAuthID string - -const ( - ZoneSettingGetResponseZonesTLSClientAuthIDTLSClientAuth ZoneSettingGetResponseZonesTLSClientAuthID = "tls_client_auth" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesTLSClientAuthValue string - -const ( - ZoneSettingGetResponseZonesTLSClientAuthValueOn ZoneSettingGetResponseZonesTLSClientAuthValue = "on" - ZoneSettingGetResponseZonesTLSClientAuthValueOff ZoneSettingGetResponseZonesTLSClientAuthValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesTLSClientAuthEditable bool - -const ( - ZoneSettingGetResponseZonesTLSClientAuthEditableTrue ZoneSettingGetResponseZonesTLSClientAuthEditable = true - ZoneSettingGetResponseZonesTLSClientAuthEditableFalse ZoneSettingGetResponseZonesTLSClientAuthEditable = false -) - -// Allows customer to continue to use True Client IP (Akamai feature) in the -// headers we send to the origin. This is limited to Enterprise Zones. -type ZoneSettingGetResponseZonesTrueClientIPHeader struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesTrueClientIPHeaderID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesTrueClientIPHeaderValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesTrueClientIPHeaderEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesTrueClientIPHeaderJSON `json:"-"` -} - -// zoneSettingGetResponseZonesTrueClientIPHeaderJSON contains the JSON metadata for -// the struct [ZoneSettingGetResponseZonesTrueClientIPHeader] -type zoneSettingGetResponseZonesTrueClientIPHeaderJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesTrueClientIPHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesTrueClientIPHeaderJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesTrueClientIPHeader) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesTrueClientIPHeaderID string - -const ( - ZoneSettingGetResponseZonesTrueClientIPHeaderIDTrueClientIPHeader ZoneSettingGetResponseZonesTrueClientIPHeaderID = "true_client_ip_header" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesTrueClientIPHeaderValue string - -const ( - ZoneSettingGetResponseZonesTrueClientIPHeaderValueOn ZoneSettingGetResponseZonesTrueClientIPHeaderValue = "on" - ZoneSettingGetResponseZonesTrueClientIPHeaderValueOff ZoneSettingGetResponseZonesTrueClientIPHeaderValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesTrueClientIPHeaderEditable bool - -const ( - ZoneSettingGetResponseZonesTrueClientIPHeaderEditableTrue ZoneSettingGetResponseZonesTrueClientIPHeaderEditable = true - ZoneSettingGetResponseZonesTrueClientIPHeaderEditableFalse ZoneSettingGetResponseZonesTrueClientIPHeaderEditable = false -) - -// The WAF examines HTTP requests to your website. It inspects both GET and POST -// requests and applies rules to help filter out illegitimate traffic from -// legitimate website visitors. The Cloudflare WAF inspects website addresses or -// URLs to detect anything out of the ordinary. If the Cloudflare WAF determines -// suspicious user behavior, then the WAF will 'challenge' the web visitor with a -// page that asks them to submit a CAPTCHA successfully to continue their action. -// If the challenge is failed, the action will be stopped. What this means is that -// Cloudflare's WAF will block any traffic identified as illegitimate before it -// reaches your origin web server. -// (https://support.cloudflare.com/hc/en-us/articles/200172016). -type ZoneSettingGetResponseZonesWAF struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesWAFID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesWAFValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesWAFEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesWAFJSON `json:"-"` -} - -// zoneSettingGetResponseZonesWAFJSON contains the JSON metadata for the struct -// [ZoneSettingGetResponseZonesWAF] -type zoneSettingGetResponseZonesWAFJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesWAF) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesWAFJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesWAF) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesWAFID string - -const ( - ZoneSettingGetResponseZonesWAFIDWAF ZoneSettingGetResponseZonesWAFID = "waf" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesWAFValue string - -const ( - ZoneSettingGetResponseZonesWAFValueOn ZoneSettingGetResponseZonesWAFValue = "on" - ZoneSettingGetResponseZonesWAFValueOff ZoneSettingGetResponseZonesWAFValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesWAFEditable bool - -const ( - ZoneSettingGetResponseZonesWAFEditableTrue ZoneSettingGetResponseZonesWAFEditable = true - ZoneSettingGetResponseZonesWAFEditableFalse ZoneSettingGetResponseZonesWAFEditable = false -) - -// When the client requesting the image supports the WebP image codec, and WebP -// offers a performance advantage over the original image format, Cloudflare will -// serve a WebP version of the original image. -type ZoneSettingGetResponseZonesWebp struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesWebpID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesWebpValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesWebpEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesWebpJSON `json:"-"` -} - -// zoneSettingGetResponseZonesWebpJSON contains the JSON metadata for the struct -// [ZoneSettingGetResponseZonesWebp] -type zoneSettingGetResponseZonesWebpJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesWebp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesWebpJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesWebp) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesWebpID string - -const ( - ZoneSettingGetResponseZonesWebpIDWebp ZoneSettingGetResponseZonesWebpID = "webp" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesWebpValue string - -const ( - ZoneSettingGetResponseZonesWebpValueOff ZoneSettingGetResponseZonesWebpValue = "off" - ZoneSettingGetResponseZonesWebpValueOn ZoneSettingGetResponseZonesWebpValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesWebpEditable bool - -const ( - ZoneSettingGetResponseZonesWebpEditableTrue ZoneSettingGetResponseZonesWebpEditable = true - ZoneSettingGetResponseZonesWebpEditableFalse ZoneSettingGetResponseZonesWebpEditable = false -) - -// WebSockets are open connections sustained between the client and the origin -// server. Inside a WebSockets connection, the client and the origin can pass data -// back and forth without having to reestablish sessions. This makes exchanging -// data within a WebSockets connection fast. WebSockets are often used for -// real-time applications such as live chat and gaming. For more information refer -// to -// [Can I use Cloudflare with Websockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Can-I-use-Cloudflare-with-WebSockets-). -type ZoneSettingGetResponseZonesWebsockets struct { - // ID of the zone setting. - ID ZoneSettingGetResponseZonesWebsocketsID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingGetResponseZonesWebsocketsValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingGetResponseZonesWebsocketsEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingGetResponseZonesWebsocketsJSON `json:"-"` -} - -// zoneSettingGetResponseZonesWebsocketsJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseZonesWebsockets] -type zoneSettingGetResponseZonesWebsocketsJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseZonesWebsockets) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseZonesWebsocketsJSON) RawJSON() string { - return r.raw -} - -func (r ZoneSettingGetResponseZonesWebsockets) implementsZoneSettingGetResponse() {} - -// ID of the zone setting. -type ZoneSettingGetResponseZonesWebsocketsID string - -const ( - ZoneSettingGetResponseZonesWebsocketsIDWebsockets ZoneSettingGetResponseZonesWebsocketsID = "websockets" -) - -// Current value of the zone setting. -type ZoneSettingGetResponseZonesWebsocketsValue string - -const ( - ZoneSettingGetResponseZonesWebsocketsValueOff ZoneSettingGetResponseZonesWebsocketsValue = "off" - ZoneSettingGetResponseZonesWebsocketsValueOn ZoneSettingGetResponseZonesWebsocketsValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingGetResponseZonesWebsocketsEditable bool - -const ( - ZoneSettingGetResponseZonesWebsocketsEditableTrue ZoneSettingGetResponseZonesWebsocketsEditable = true - ZoneSettingGetResponseZonesWebsocketsEditableFalse ZoneSettingGetResponseZonesWebsocketsEditable = false -) - -type ZoneSettingEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // One or more zone setting objects. Must contain an ID and a value. - Items param.Field[[]ZoneSettingEditParamsItem] `json:"items,required"` -} - -func (r ZoneSettingEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// 0-RTT session resumption enabled for this zone. -// -// Satisfied by [ZoneSettingEditParamsItemsZones0rtt], -// [ZoneSettingEditParamsItemsZonesAdvancedDDOS], -// [ZoneSettingEditParamsItemsZonesAlwaysOnline], -// [ZoneSettingEditParamsItemsZonesAlwaysUseHTTPS], -// [ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewrites], -// [ZoneSettingEditParamsItemsZonesBrotli], -// [ZoneSettingEditParamsItemsZonesBrowserCacheTTL], -// [ZoneSettingEditParamsItemsZonesBrowserCheck], -// [ZoneSettingEditParamsItemsZonesCacheLevel], -// [ZoneSettingEditParamsItemsZonesChallengeTTL], -// [ZoneSettingEditParamsItemsZonesCiphers], -// [ZoneSettingEditParamsItemsZonesCNAMEFlattening], -// [ZoneSettingEditParamsItemsZonesDevelopmentMode], -// [ZoneSettingEditParamsItemsZonesEarlyHints], -// [ZoneSettingEditParamsItemsZonesEdgeCacheTTL], -// [ZoneSettingEditParamsItemsZonesEmailObfuscation], -// [ZoneSettingEditParamsItemsZonesH2Prioritization], -// [ZoneSettingEditParamsItemsZonesHotlinkProtection], -// [ZoneSettingEditParamsItemsZonesHTTP2], [ZoneSettingEditParamsItemsZonesHTTP3], -// [ZoneSettingEditParamsItemsZonesImageResizing], -// [ZoneSettingEditParamsItemsZonesIPGeolocation], -// [ZoneSettingEditParamsItemsZonesIPV6], -// [ZoneSettingEditParamsItemsZonesMaxUpload], -// [ZoneSettingEditParamsItemsZonesMinTLSVersion], -// [ZoneSettingEditParamsItemsZonesMinify], -// [ZoneSettingEditParamsItemsZonesMirage], -// [ZoneSettingEditParamsItemsZonesMobileRedirect], -// [ZoneSettingEditParamsItemsZonesNEL], -// [ZoneSettingEditParamsItemsZonesOpportunisticEncryption], -// [ZoneSettingEditParamsItemsZonesOpportunisticOnion], -// [ZoneSettingEditParamsItemsZonesOrangeToOrange], -// [ZoneSettingEditParamsItemsZonesOriginErrorPagePassThru], -// [ZoneSettingEditParamsItemsZonesPolish], -// [ZoneSettingEditParamsItemsZonesPrefetchPreload], -// [ZoneSettingEditParamsItemsZonesProxyReadTimeout], -// [ZoneSettingEditParamsItemsZonesPseudoIPV4], -// [ZoneSettingEditParamsItemsZonesResponseBuffering], -// [ZoneSettingEditParamsItemsZonesRocketLoader], -// [ZoneSettingEditParamsItemsZonesSchemasAutomaticPlatformOptimization], -// [ZoneSettingEditParamsItemsZonesSecurityHeader], -// [ZoneSettingEditParamsItemsZonesSecurityLevel], -// [ZoneSettingEditParamsItemsZonesServerSideExclude], -// [ZoneSettingEditParamsItemsZonesSha1Support], -// [ZoneSettingEditParamsItemsZonesSortQueryStringForCache], -// [ZoneSettingEditParamsItemsZonesSSL], -// [ZoneSettingEditParamsItemsZonesSSLRecommender], -// [ZoneSettingEditParamsItemsZonesTLS1_2Only], -// [ZoneSettingEditParamsItemsZonesTLS1_3], -// [ZoneSettingEditParamsItemsZonesTLSClientAuth], -// [ZoneSettingEditParamsItemsZonesTrueClientIPHeader], -// [ZoneSettingEditParamsItemsZonesWAF], [ZoneSettingEditParamsItemsZonesWebp], -// [ZoneSettingEditParamsItemsZonesWebsockets]. -type ZoneSettingEditParamsItem interface { - implementsZoneSettingEditParamsItem() -} - -// 0-RTT session resumption enabled for this zone. -type ZoneSettingEditParamsItemsZones0rtt struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZones0rttID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZones0rttValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZones0rtt) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZones0rtt) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZones0rttID string - -const ( - ZoneSettingEditParamsItemsZones0rttID0rtt ZoneSettingEditParamsItemsZones0rttID = "0rtt" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZones0rttValue string - -const ( - ZoneSettingEditParamsItemsZones0rttValueOn ZoneSettingEditParamsItemsZones0rttValue = "on" - ZoneSettingEditParamsItemsZones0rttValueOff ZoneSettingEditParamsItemsZones0rttValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZones0rttEditable bool - -const ( - ZoneSettingEditParamsItemsZones0rttEditableTrue ZoneSettingEditParamsItemsZones0rttEditable = true - ZoneSettingEditParamsItemsZones0rttEditableFalse ZoneSettingEditParamsItemsZones0rttEditable = false -) - -// 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. -type ZoneSettingEditParamsItemsZonesAdvancedDDOS struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesAdvancedDDOSID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesAdvancedDDOSValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesAdvancedDDOS) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesAdvancedDDOS) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesAdvancedDDOSID string - -const ( - ZoneSettingEditParamsItemsZonesAdvancedDDOSIDAdvancedDDOS ZoneSettingEditParamsItemsZonesAdvancedDDOSID = "advanced_ddos" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesAdvancedDDOSValue string - -const ( - ZoneSettingEditParamsItemsZonesAdvancedDDOSValueOn ZoneSettingEditParamsItemsZonesAdvancedDDOSValue = "on" - ZoneSettingEditParamsItemsZonesAdvancedDDOSValueOff ZoneSettingEditParamsItemsZonesAdvancedDDOSValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesAdvancedDDOSEditable bool - -const ( - ZoneSettingEditParamsItemsZonesAdvancedDDOSEditableTrue ZoneSettingEditParamsItemsZonesAdvancedDDOSEditable = true - ZoneSettingEditParamsItemsZonesAdvancedDDOSEditableFalse ZoneSettingEditParamsItemsZonesAdvancedDDOSEditable = false -) - -// When enabled, Cloudflare serves limited copies of web pages available from the -// [Internet Archive's Wayback Machine](https://archive.org/web/) if your server is -// offline. Refer to -// [Always Online](https://developers.cloudflare.com/cache/about/always-online) for -// more information. -type ZoneSettingEditParamsItemsZonesAlwaysOnline struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesAlwaysOnlineID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesAlwaysOnlineValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesAlwaysOnline) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesAlwaysOnline) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesAlwaysOnlineID string - -const ( - ZoneSettingEditParamsItemsZonesAlwaysOnlineIDAlwaysOnline ZoneSettingEditParamsItemsZonesAlwaysOnlineID = "always_online" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesAlwaysOnlineValue string - -const ( - ZoneSettingEditParamsItemsZonesAlwaysOnlineValueOn ZoneSettingEditParamsItemsZonesAlwaysOnlineValue = "on" - ZoneSettingEditParamsItemsZonesAlwaysOnlineValueOff ZoneSettingEditParamsItemsZonesAlwaysOnlineValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesAlwaysOnlineEditable bool - -const ( - ZoneSettingEditParamsItemsZonesAlwaysOnlineEditableTrue ZoneSettingEditParamsItemsZonesAlwaysOnlineEditable = true - ZoneSettingEditParamsItemsZonesAlwaysOnlineEditableFalse ZoneSettingEditParamsItemsZonesAlwaysOnlineEditable = false -) - -// Reply to all requests for URLs that use "http" with a 301 redirect to the -// equivalent "https" URL. If you only want to redirect for a subset of requests, -// consider creating an "Always use HTTPS" page rule. -type ZoneSettingEditParamsItemsZonesAlwaysUseHTTPS struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesAlwaysUseHTTPSID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesAlwaysUseHTTPSValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesAlwaysUseHTTPS) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesAlwaysUseHTTPS) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesAlwaysUseHTTPSID string - -const ( - ZoneSettingEditParamsItemsZonesAlwaysUseHTTPSIDAlwaysUseHTTPS ZoneSettingEditParamsItemsZonesAlwaysUseHTTPSID = "always_use_https" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesAlwaysUseHTTPSValue string - -const ( - ZoneSettingEditParamsItemsZonesAlwaysUseHTTPSValueOn ZoneSettingEditParamsItemsZonesAlwaysUseHTTPSValue = "on" - ZoneSettingEditParamsItemsZonesAlwaysUseHTTPSValueOff ZoneSettingEditParamsItemsZonesAlwaysUseHTTPSValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesAlwaysUseHTTPSEditable bool - -const ( - ZoneSettingEditParamsItemsZonesAlwaysUseHTTPSEditableTrue ZoneSettingEditParamsItemsZonesAlwaysUseHTTPSEditable = true - ZoneSettingEditParamsItemsZonesAlwaysUseHTTPSEditableFalse ZoneSettingEditParamsItemsZonesAlwaysUseHTTPSEditable = false -) - -// Enable the Automatic HTTPS Rewrites feature for this zone. -type ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewrites struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewritesID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewritesValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewrites) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewrites) implementsZoneSettingEditParamsItem() { -} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewritesID string - -const ( - ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewritesIDAutomaticHTTPSRewrites ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewritesID = "automatic_https_rewrites" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewritesValue string - -const ( - ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewritesValueOn ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewritesValue = "on" - ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewritesValueOff ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewritesValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewritesEditable bool - -const ( - ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewritesEditableTrue ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewritesEditable = true - ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewritesEditableFalse ZoneSettingEditParamsItemsZonesAutomaticHTTPSRewritesEditable = false -) - -// When the client requesting an asset supports the Brotli compression algorithm, -// Cloudflare will serve a Brotli compressed version of the asset. -type ZoneSettingEditParamsItemsZonesBrotli struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesBrotliID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesBrotliValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesBrotli) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesBrotli) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesBrotliID string - -const ( - ZoneSettingEditParamsItemsZonesBrotliIDBrotli ZoneSettingEditParamsItemsZonesBrotliID = "brotli" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesBrotliValue string - -const ( - ZoneSettingEditParamsItemsZonesBrotliValueOff ZoneSettingEditParamsItemsZonesBrotliValue = "off" - ZoneSettingEditParamsItemsZonesBrotliValueOn ZoneSettingEditParamsItemsZonesBrotliValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesBrotliEditable bool - -const ( - ZoneSettingEditParamsItemsZonesBrotliEditableTrue ZoneSettingEditParamsItemsZonesBrotliEditable = true - ZoneSettingEditParamsItemsZonesBrotliEditableFalse ZoneSettingEditParamsItemsZonesBrotliEditable = false -) - -// Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources -// will remain on your visitors' computers. Cloudflare will honor any larger times -// specified by your server. -// (https://support.cloudflare.com/hc/en-us/articles/200168276). -type ZoneSettingEditParamsItemsZonesBrowserCacheTTL struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesBrowserCacheTTLID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesBrowserCacheTTL) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesBrowserCacheTTL) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesBrowserCacheTTLID string - -const ( - ZoneSettingEditParamsItemsZonesBrowserCacheTTLIDBrowserCacheTTL ZoneSettingEditParamsItemsZonesBrowserCacheTTLID = "browser_cache_ttl" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue float64 - -const ( - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue0 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 0 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue30 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 30 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue60 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 60 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue120 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 120 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue300 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 300 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue1200 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 1200 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue1800 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 1800 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue3600 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 3600 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue7200 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 7200 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue10800 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 10800 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue14400 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 14400 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue18000 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 18000 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue28800 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 28800 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue43200 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 43200 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue57600 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 57600 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue72000 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 72000 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue86400 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 86400 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue172800 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 172800 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue259200 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 259200 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue345600 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 345600 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue432000 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 432000 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue691200 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 691200 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue1382400 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 1382400 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue2073600 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 2073600 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue2678400 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 2678400 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue5356800 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 5356800 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue16070400 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 16070400 - ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue31536000 ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue = 31536000 -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesBrowserCacheTTLEditable bool - -const ( - ZoneSettingEditParamsItemsZonesBrowserCacheTTLEditableTrue ZoneSettingEditParamsItemsZonesBrowserCacheTTLEditable = true - ZoneSettingEditParamsItemsZonesBrowserCacheTTLEditableFalse ZoneSettingEditParamsItemsZonesBrowserCacheTTLEditable = false -) - -// Browser Integrity Check is similar to Bad Behavior and looks for common HTTP -// headers abused most commonly by spammers and denies access to your page. It will -// also challenge visitors that do not have a user agent or a non standard user -// agent (also commonly used by abuse bots, crawlers or visitors). -// (https://support.cloudflare.com/hc/en-us/articles/200170086). -type ZoneSettingEditParamsItemsZonesBrowserCheck struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesBrowserCheckID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesBrowserCheckValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesBrowserCheck) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesBrowserCheck) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesBrowserCheckID string - -const ( - ZoneSettingEditParamsItemsZonesBrowserCheckIDBrowserCheck ZoneSettingEditParamsItemsZonesBrowserCheckID = "browser_check" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesBrowserCheckValue string - -const ( - ZoneSettingEditParamsItemsZonesBrowserCheckValueOn ZoneSettingEditParamsItemsZonesBrowserCheckValue = "on" - ZoneSettingEditParamsItemsZonesBrowserCheckValueOff ZoneSettingEditParamsItemsZonesBrowserCheckValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesBrowserCheckEditable bool - -const ( - ZoneSettingEditParamsItemsZonesBrowserCheckEditableTrue ZoneSettingEditParamsItemsZonesBrowserCheckEditable = true - ZoneSettingEditParamsItemsZonesBrowserCheckEditableFalse ZoneSettingEditParamsItemsZonesBrowserCheckEditable = false -) - -// Cache Level functions based off the setting level. The basic setting will cache -// most static resources (i.e., css, images, and JavaScript). The simplified -// setting will ignore the query string when delivering a cached resource. The -// aggressive setting will cache all static resources, including ones with a query -// string. (https://support.cloudflare.com/hc/en-us/articles/200168256). -type ZoneSettingEditParamsItemsZonesCacheLevel struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesCacheLevelID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesCacheLevelValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesCacheLevel) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesCacheLevel) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesCacheLevelID string - -const ( - ZoneSettingEditParamsItemsZonesCacheLevelIDCacheLevel ZoneSettingEditParamsItemsZonesCacheLevelID = "cache_level" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesCacheLevelValue string - -const ( - ZoneSettingEditParamsItemsZonesCacheLevelValueAggressive ZoneSettingEditParamsItemsZonesCacheLevelValue = "aggressive" - ZoneSettingEditParamsItemsZonesCacheLevelValueBasic ZoneSettingEditParamsItemsZonesCacheLevelValue = "basic" - ZoneSettingEditParamsItemsZonesCacheLevelValueSimplified ZoneSettingEditParamsItemsZonesCacheLevelValue = "simplified" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesCacheLevelEditable bool - -const ( - ZoneSettingEditParamsItemsZonesCacheLevelEditableTrue ZoneSettingEditParamsItemsZonesCacheLevelEditable = true - ZoneSettingEditParamsItemsZonesCacheLevelEditableFalse ZoneSettingEditParamsItemsZonesCacheLevelEditable = false -) - -// Specify how long a visitor is allowed access to your site after successfully -// completing a challenge (such as a CAPTCHA). After the TTL has expired the -// visitor will have to complete a new challenge. We recommend a 15 - 45 minute -// setting and will attempt to honor any setting above 45 minutes. -// (https://support.cloudflare.com/hc/en-us/articles/200170136). -type ZoneSettingEditParamsItemsZonesChallengeTTL struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesChallengeTTLID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesChallengeTTLValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesChallengeTTL) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesChallengeTTL) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesChallengeTTLID string - -const ( - ZoneSettingEditParamsItemsZonesChallengeTTLIDChallengeTTL ZoneSettingEditParamsItemsZonesChallengeTTLID = "challenge_ttl" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesChallengeTTLValue float64 - -const ( - ZoneSettingEditParamsItemsZonesChallengeTTLValue300 ZoneSettingEditParamsItemsZonesChallengeTTLValue = 300 - ZoneSettingEditParamsItemsZonesChallengeTTLValue900 ZoneSettingEditParamsItemsZonesChallengeTTLValue = 900 - ZoneSettingEditParamsItemsZonesChallengeTTLValue1800 ZoneSettingEditParamsItemsZonesChallengeTTLValue = 1800 - ZoneSettingEditParamsItemsZonesChallengeTTLValue2700 ZoneSettingEditParamsItemsZonesChallengeTTLValue = 2700 - ZoneSettingEditParamsItemsZonesChallengeTTLValue3600 ZoneSettingEditParamsItemsZonesChallengeTTLValue = 3600 - ZoneSettingEditParamsItemsZonesChallengeTTLValue7200 ZoneSettingEditParamsItemsZonesChallengeTTLValue = 7200 - ZoneSettingEditParamsItemsZonesChallengeTTLValue10800 ZoneSettingEditParamsItemsZonesChallengeTTLValue = 10800 - ZoneSettingEditParamsItemsZonesChallengeTTLValue14400 ZoneSettingEditParamsItemsZonesChallengeTTLValue = 14400 - ZoneSettingEditParamsItemsZonesChallengeTTLValue28800 ZoneSettingEditParamsItemsZonesChallengeTTLValue = 28800 - ZoneSettingEditParamsItemsZonesChallengeTTLValue57600 ZoneSettingEditParamsItemsZonesChallengeTTLValue = 57600 - ZoneSettingEditParamsItemsZonesChallengeTTLValue86400 ZoneSettingEditParamsItemsZonesChallengeTTLValue = 86400 - ZoneSettingEditParamsItemsZonesChallengeTTLValue604800 ZoneSettingEditParamsItemsZonesChallengeTTLValue = 604800 - ZoneSettingEditParamsItemsZonesChallengeTTLValue2592000 ZoneSettingEditParamsItemsZonesChallengeTTLValue = 2592000 - ZoneSettingEditParamsItemsZonesChallengeTTLValue31536000 ZoneSettingEditParamsItemsZonesChallengeTTLValue = 31536000 -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesChallengeTTLEditable bool - -const ( - ZoneSettingEditParamsItemsZonesChallengeTTLEditableTrue ZoneSettingEditParamsItemsZonesChallengeTTLEditable = true - ZoneSettingEditParamsItemsZonesChallengeTTLEditableFalse ZoneSettingEditParamsItemsZonesChallengeTTLEditable = false -) - -// An allowlist of ciphers for TLS termination. These ciphers must be in the -// BoringSSL format. -type ZoneSettingEditParamsItemsZonesCiphers struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesCiphersID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[[]string] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesCiphers) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesCiphers) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesCiphersID string - -const ( - ZoneSettingEditParamsItemsZonesCiphersIDCiphers ZoneSettingEditParamsItemsZonesCiphersID = "ciphers" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesCiphersEditable bool - -const ( - ZoneSettingEditParamsItemsZonesCiphersEditableTrue ZoneSettingEditParamsItemsZonesCiphersEditable = true - ZoneSettingEditParamsItemsZonesCiphersEditableFalse ZoneSettingEditParamsItemsZonesCiphersEditable = false -) - -// Whether or not cname flattening is on. -type ZoneSettingEditParamsItemsZonesCNAMEFlattening struct { - // How to flatten the cname destination. - ID param.Field[ZoneSettingEditParamsItemsZonesCNAMEFlatteningID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesCNAMEFlatteningValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesCNAMEFlattening) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesCNAMEFlattening) implementsZoneSettingEditParamsItem() {} - -// How to flatten the cname destination. -type ZoneSettingEditParamsItemsZonesCNAMEFlatteningID string - -const ( - ZoneSettingEditParamsItemsZonesCNAMEFlatteningIDCNAMEFlattening ZoneSettingEditParamsItemsZonesCNAMEFlatteningID = "cname_flattening" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesCNAMEFlatteningValue string - -const ( - ZoneSettingEditParamsItemsZonesCNAMEFlatteningValueFlattenAtRoot ZoneSettingEditParamsItemsZonesCNAMEFlatteningValue = "flatten_at_root" - ZoneSettingEditParamsItemsZonesCNAMEFlatteningValueFlattenAll ZoneSettingEditParamsItemsZonesCNAMEFlatteningValue = "flatten_all" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesCNAMEFlatteningEditable bool - -const ( - ZoneSettingEditParamsItemsZonesCNAMEFlatteningEditableTrue ZoneSettingEditParamsItemsZonesCNAMEFlatteningEditable = true - ZoneSettingEditParamsItemsZonesCNAMEFlatteningEditableFalse ZoneSettingEditParamsItemsZonesCNAMEFlatteningEditable = false -) - -// Development Mode temporarily allows you to enter development mode for your -// websites if you need to make changes to your site. This will bypass Cloudflare's -// accelerated cache and slow down your site, but is useful if you are making -// changes to cacheable content (like images, css, or JavaScript) and would like to -// see those changes right away. Once entered, development mode will last for 3 -// hours and then automatically toggle off. -type ZoneSettingEditParamsItemsZonesDevelopmentMode struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesDevelopmentModeID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesDevelopmentModeValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesDevelopmentMode) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesDevelopmentMode) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesDevelopmentModeID string - -const ( - ZoneSettingEditParamsItemsZonesDevelopmentModeIDDevelopmentMode ZoneSettingEditParamsItemsZonesDevelopmentModeID = "development_mode" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesDevelopmentModeValue string - -const ( - ZoneSettingEditParamsItemsZonesDevelopmentModeValueOn ZoneSettingEditParamsItemsZonesDevelopmentModeValue = "on" - ZoneSettingEditParamsItemsZonesDevelopmentModeValueOff ZoneSettingEditParamsItemsZonesDevelopmentModeValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesDevelopmentModeEditable bool - -const ( - ZoneSettingEditParamsItemsZonesDevelopmentModeEditableTrue ZoneSettingEditParamsItemsZonesDevelopmentModeEditable = true - ZoneSettingEditParamsItemsZonesDevelopmentModeEditableFalse ZoneSettingEditParamsItemsZonesDevelopmentModeEditable = false -) - -// When enabled, Cloudflare will attempt to speed up overall page loads by serving -// `103` responses with `Link` headers from the final response. Refer to -// [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for -// more information. -type ZoneSettingEditParamsItemsZonesEarlyHints struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesEarlyHintsID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesEarlyHintsValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesEarlyHints) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesEarlyHints) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesEarlyHintsID string - -const ( - ZoneSettingEditParamsItemsZonesEarlyHintsIDEarlyHints ZoneSettingEditParamsItemsZonesEarlyHintsID = "early_hints" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesEarlyHintsValue string - -const ( - ZoneSettingEditParamsItemsZonesEarlyHintsValueOn ZoneSettingEditParamsItemsZonesEarlyHintsValue = "on" - ZoneSettingEditParamsItemsZonesEarlyHintsValueOff ZoneSettingEditParamsItemsZonesEarlyHintsValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesEarlyHintsEditable bool - -const ( - ZoneSettingEditParamsItemsZonesEarlyHintsEditableTrue ZoneSettingEditParamsItemsZonesEarlyHintsEditable = true - ZoneSettingEditParamsItemsZonesEarlyHintsEditableFalse ZoneSettingEditParamsItemsZonesEarlyHintsEditable = false -) - -// Time (in seconds) that a resource will be ensured to remain on Cloudflare's -// cache servers. -type ZoneSettingEditParamsItemsZonesEdgeCacheTTL struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesEdgeCacheTTLID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesEdgeCacheTTL) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesEdgeCacheTTL) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesEdgeCacheTTLID string - -const ( - ZoneSettingEditParamsItemsZonesEdgeCacheTTLIDEdgeCacheTTL ZoneSettingEditParamsItemsZonesEdgeCacheTTLID = "edge_cache_ttl" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue float64 - -const ( - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue30 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 30 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue60 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 60 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue300 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 300 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue1200 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 1200 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue1800 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 1800 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue3600 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 3600 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue7200 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 7200 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue10800 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 10800 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue14400 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 14400 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue18000 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 18000 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue28800 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 28800 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue43200 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 43200 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue57600 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 57600 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue72000 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 72000 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue86400 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 86400 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue172800 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 172800 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue259200 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 259200 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue345600 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 345600 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue432000 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 432000 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue518400 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 518400 - ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue604800 ZoneSettingEditParamsItemsZonesEdgeCacheTTLValue = 604800 -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesEdgeCacheTTLEditable bool - -const ( - ZoneSettingEditParamsItemsZonesEdgeCacheTTLEditableTrue ZoneSettingEditParamsItemsZonesEdgeCacheTTLEditable = true - ZoneSettingEditParamsItemsZonesEdgeCacheTTLEditableFalse ZoneSettingEditParamsItemsZonesEdgeCacheTTLEditable = false -) - -// Encrypt email adresses on your web page from bots, while keeping them visible to -// humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). -type ZoneSettingEditParamsItemsZonesEmailObfuscation struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesEmailObfuscationID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesEmailObfuscationValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesEmailObfuscation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesEmailObfuscation) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesEmailObfuscationID string - -const ( - ZoneSettingEditParamsItemsZonesEmailObfuscationIDEmailObfuscation ZoneSettingEditParamsItemsZonesEmailObfuscationID = "email_obfuscation" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesEmailObfuscationValue string - -const ( - ZoneSettingEditParamsItemsZonesEmailObfuscationValueOn ZoneSettingEditParamsItemsZonesEmailObfuscationValue = "on" - ZoneSettingEditParamsItemsZonesEmailObfuscationValueOff ZoneSettingEditParamsItemsZonesEmailObfuscationValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesEmailObfuscationEditable bool - -const ( - ZoneSettingEditParamsItemsZonesEmailObfuscationEditableTrue ZoneSettingEditParamsItemsZonesEmailObfuscationEditable = true - ZoneSettingEditParamsItemsZonesEmailObfuscationEditableFalse ZoneSettingEditParamsItemsZonesEmailObfuscationEditable = false -) - -// HTTP/2 Edge Prioritization optimises the delivery of resources served through -// HTTP/2 to improve page load performance. It also supports fine control of -// content delivery when used in conjunction with Workers. -type ZoneSettingEditParamsItemsZonesH2Prioritization struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesH2PrioritizationID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesH2PrioritizationValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesH2Prioritization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesH2Prioritization) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesH2PrioritizationID string - -const ( - ZoneSettingEditParamsItemsZonesH2PrioritizationIDH2Prioritization ZoneSettingEditParamsItemsZonesH2PrioritizationID = "h2_prioritization" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesH2PrioritizationValue string - -const ( - ZoneSettingEditParamsItemsZonesH2PrioritizationValueOn ZoneSettingEditParamsItemsZonesH2PrioritizationValue = "on" - ZoneSettingEditParamsItemsZonesH2PrioritizationValueOff ZoneSettingEditParamsItemsZonesH2PrioritizationValue = "off" - ZoneSettingEditParamsItemsZonesH2PrioritizationValueCustom ZoneSettingEditParamsItemsZonesH2PrioritizationValue = "custom" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesH2PrioritizationEditable bool - -const ( - ZoneSettingEditParamsItemsZonesH2PrioritizationEditableTrue ZoneSettingEditParamsItemsZonesH2PrioritizationEditable = true - ZoneSettingEditParamsItemsZonesH2PrioritizationEditableFalse ZoneSettingEditParamsItemsZonesH2PrioritizationEditable = false -) - -// When enabled, the Hotlink Protection option ensures that other sites cannot suck -// up your bandwidth by building pages that use images hosted on your site. Anytime -// a request for an image on your site hits Cloudflare, we check to ensure that -// it's not another site requesting them. People will still be able to download and -// view images from your page, but other sites won't be able to steal them for use -// on their own pages. -// (https://support.cloudflare.com/hc/en-us/articles/200170026). -type ZoneSettingEditParamsItemsZonesHotlinkProtection struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesHotlinkProtectionID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesHotlinkProtectionValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesHotlinkProtection) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesHotlinkProtection) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesHotlinkProtectionID string - -const ( - ZoneSettingEditParamsItemsZonesHotlinkProtectionIDHotlinkProtection ZoneSettingEditParamsItemsZonesHotlinkProtectionID = "hotlink_protection" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesHotlinkProtectionValue string - -const ( - ZoneSettingEditParamsItemsZonesHotlinkProtectionValueOn ZoneSettingEditParamsItemsZonesHotlinkProtectionValue = "on" - ZoneSettingEditParamsItemsZonesHotlinkProtectionValueOff ZoneSettingEditParamsItemsZonesHotlinkProtectionValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesHotlinkProtectionEditable bool - -const ( - ZoneSettingEditParamsItemsZonesHotlinkProtectionEditableTrue ZoneSettingEditParamsItemsZonesHotlinkProtectionEditable = true - ZoneSettingEditParamsItemsZonesHotlinkProtectionEditableFalse ZoneSettingEditParamsItemsZonesHotlinkProtectionEditable = false -) - -// HTTP2 enabled for this zone. -type ZoneSettingEditParamsItemsZonesHTTP2 struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesHTTP2ID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesHTTP2Value] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesHTTP2) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesHTTP2) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesHTTP2ID string - -const ( - ZoneSettingEditParamsItemsZonesHTTP2IDHTTP2 ZoneSettingEditParamsItemsZonesHTTP2ID = "http2" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesHTTP2Value string - -const ( - ZoneSettingEditParamsItemsZonesHTTP2ValueOn ZoneSettingEditParamsItemsZonesHTTP2Value = "on" - ZoneSettingEditParamsItemsZonesHTTP2ValueOff ZoneSettingEditParamsItemsZonesHTTP2Value = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesHTTP2Editable bool - -const ( - ZoneSettingEditParamsItemsZonesHTTP2EditableTrue ZoneSettingEditParamsItemsZonesHTTP2Editable = true - ZoneSettingEditParamsItemsZonesHTTP2EditableFalse ZoneSettingEditParamsItemsZonesHTTP2Editable = false -) - -// HTTP3 enabled for this zone. -type ZoneSettingEditParamsItemsZonesHTTP3 struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesHTTP3ID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesHTTP3Value] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesHTTP3) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesHTTP3) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesHTTP3ID string - -const ( - ZoneSettingEditParamsItemsZonesHTTP3IDHTTP3 ZoneSettingEditParamsItemsZonesHTTP3ID = "http3" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesHTTP3Value string - -const ( - ZoneSettingEditParamsItemsZonesHTTP3ValueOn ZoneSettingEditParamsItemsZonesHTTP3Value = "on" - ZoneSettingEditParamsItemsZonesHTTP3ValueOff ZoneSettingEditParamsItemsZonesHTTP3Value = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesHTTP3Editable bool - -const ( - ZoneSettingEditParamsItemsZonesHTTP3EditableTrue ZoneSettingEditParamsItemsZonesHTTP3Editable = true - ZoneSettingEditParamsItemsZonesHTTP3EditableFalse ZoneSettingEditParamsItemsZonesHTTP3Editable = false -) - -// Image Resizing provides on-demand resizing, conversion and optimisation for -// images served through Cloudflare's network. Refer to the -// [Image Resizing documentation](https://developers.cloudflare.com/images/) for -// more information. -type ZoneSettingEditParamsItemsZonesImageResizing struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesImageResizingID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesImageResizingValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesImageResizing) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesImageResizing) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesImageResizingID string - -const ( - ZoneSettingEditParamsItemsZonesImageResizingIDImageResizing ZoneSettingEditParamsItemsZonesImageResizingID = "image_resizing" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesImageResizingValue string - -const ( - ZoneSettingEditParamsItemsZonesImageResizingValueOn ZoneSettingEditParamsItemsZonesImageResizingValue = "on" - ZoneSettingEditParamsItemsZonesImageResizingValueOff ZoneSettingEditParamsItemsZonesImageResizingValue = "off" - ZoneSettingEditParamsItemsZonesImageResizingValueOpen ZoneSettingEditParamsItemsZonesImageResizingValue = "open" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesImageResizingEditable bool - -const ( - ZoneSettingEditParamsItemsZonesImageResizingEditableTrue ZoneSettingEditParamsItemsZonesImageResizingEditable = true - ZoneSettingEditParamsItemsZonesImageResizingEditableFalse ZoneSettingEditParamsItemsZonesImageResizingEditable = false -) - -// Enable IP Geolocation to have Cloudflare geolocate visitors to your website and -// pass the country code to you. -// (https://support.cloudflare.com/hc/en-us/articles/200168236). -type ZoneSettingEditParamsItemsZonesIPGeolocation struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesIPGeolocationID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesIPGeolocationValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesIPGeolocation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesIPGeolocation) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesIPGeolocationID string - -const ( - ZoneSettingEditParamsItemsZonesIPGeolocationIDIPGeolocation ZoneSettingEditParamsItemsZonesIPGeolocationID = "ip_geolocation" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesIPGeolocationValue string - -const ( - ZoneSettingEditParamsItemsZonesIPGeolocationValueOn ZoneSettingEditParamsItemsZonesIPGeolocationValue = "on" - ZoneSettingEditParamsItemsZonesIPGeolocationValueOff ZoneSettingEditParamsItemsZonesIPGeolocationValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesIPGeolocationEditable bool - -const ( - ZoneSettingEditParamsItemsZonesIPGeolocationEditableTrue ZoneSettingEditParamsItemsZonesIPGeolocationEditable = true - ZoneSettingEditParamsItemsZonesIPGeolocationEditableFalse ZoneSettingEditParamsItemsZonesIPGeolocationEditable = false -) - -// Enable IPv6 on all subdomains that are Cloudflare enabled. -// (https://support.cloudflare.com/hc/en-us/articles/200168586). -type ZoneSettingEditParamsItemsZonesIPV6 struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesIPV6ID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesIPV6Value] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesIPV6) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesIPV6) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesIPV6ID string - -const ( - ZoneSettingEditParamsItemsZonesIPV6IDIPV6 ZoneSettingEditParamsItemsZonesIPV6ID = "ipv6" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesIPV6Value string - -const ( - ZoneSettingEditParamsItemsZonesIPV6ValueOff ZoneSettingEditParamsItemsZonesIPV6Value = "off" - ZoneSettingEditParamsItemsZonesIPV6ValueOn ZoneSettingEditParamsItemsZonesIPV6Value = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesIPV6Editable bool - -const ( - ZoneSettingEditParamsItemsZonesIPV6EditableTrue ZoneSettingEditParamsItemsZonesIPV6Editable = true - ZoneSettingEditParamsItemsZonesIPV6EditableFalse ZoneSettingEditParamsItemsZonesIPV6Editable = false -) - -// Maximum size of an allowable upload. -type ZoneSettingEditParamsItemsZonesMaxUpload struct { - // identifier of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesMaxUploadID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesMaxUploadValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesMaxUpload) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesMaxUpload) implementsZoneSettingEditParamsItem() {} - -// identifier of the zone setting. -type ZoneSettingEditParamsItemsZonesMaxUploadID string - -const ( - ZoneSettingEditParamsItemsZonesMaxUploadIDMaxUpload ZoneSettingEditParamsItemsZonesMaxUploadID = "max_upload" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesMaxUploadValue float64 - -const ( - ZoneSettingEditParamsItemsZonesMaxUploadValue100 ZoneSettingEditParamsItemsZonesMaxUploadValue = 100 - ZoneSettingEditParamsItemsZonesMaxUploadValue200 ZoneSettingEditParamsItemsZonesMaxUploadValue = 200 - ZoneSettingEditParamsItemsZonesMaxUploadValue500 ZoneSettingEditParamsItemsZonesMaxUploadValue = 500 -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesMaxUploadEditable bool - -const ( - ZoneSettingEditParamsItemsZonesMaxUploadEditableTrue ZoneSettingEditParamsItemsZonesMaxUploadEditable = true - ZoneSettingEditParamsItemsZonesMaxUploadEditableFalse ZoneSettingEditParamsItemsZonesMaxUploadEditable = false -) - -// Only accepts HTTPS requests that use at least the TLS protocol version -// specified. For example, if TLS 1.1 is selected, TLS 1.0 connections will be -// rejected, while 1.1, 1.2, and 1.3 (if enabled) will be permitted. -type ZoneSettingEditParamsItemsZonesMinTLSVersion struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesMinTLSVersionID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesMinTLSVersionValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesMinTLSVersion) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesMinTLSVersion) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesMinTLSVersionID string - -const ( - ZoneSettingEditParamsItemsZonesMinTLSVersionIDMinTLSVersion ZoneSettingEditParamsItemsZonesMinTLSVersionID = "min_tls_version" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesMinTLSVersionValue string - -const ( - ZoneSettingEditParamsItemsZonesMinTLSVersionValue1_0 ZoneSettingEditParamsItemsZonesMinTLSVersionValue = "1.0" - ZoneSettingEditParamsItemsZonesMinTLSVersionValue1_1 ZoneSettingEditParamsItemsZonesMinTLSVersionValue = "1.1" - ZoneSettingEditParamsItemsZonesMinTLSVersionValue1_2 ZoneSettingEditParamsItemsZonesMinTLSVersionValue = "1.2" - ZoneSettingEditParamsItemsZonesMinTLSVersionValue1_3 ZoneSettingEditParamsItemsZonesMinTLSVersionValue = "1.3" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesMinTLSVersionEditable bool - -const ( - ZoneSettingEditParamsItemsZonesMinTLSVersionEditableTrue ZoneSettingEditParamsItemsZonesMinTLSVersionEditable = true - ZoneSettingEditParamsItemsZonesMinTLSVersionEditableFalse ZoneSettingEditParamsItemsZonesMinTLSVersionEditable = false -) - -// Automatically minify certain assets for your website. Refer to -// [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) -// for more information. -type ZoneSettingEditParamsItemsZonesMinify struct { - // Zone setting identifier. - ID param.Field[ZoneSettingEditParamsItemsZonesMinifyID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesMinifyValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesMinify) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesMinify) implementsZoneSettingEditParamsItem() {} - -// Zone setting identifier. -type ZoneSettingEditParamsItemsZonesMinifyID string - -const ( - ZoneSettingEditParamsItemsZonesMinifyIDMinify ZoneSettingEditParamsItemsZonesMinifyID = "minify" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesMinifyValue struct { - // Automatically minify all CSS files for your website. - Css param.Field[ZoneSettingEditParamsItemsZonesMinifyValueCss] `json:"css"` - // Automatically minify all HTML files for your website. - HTML param.Field[ZoneSettingEditParamsItemsZonesMinifyValueHTML] `json:"html"` - // Automatically minify all JavaScript files for your website. - Js param.Field[ZoneSettingEditParamsItemsZonesMinifyValueJs] `json:"js"` -} - -func (r ZoneSettingEditParamsItemsZonesMinifyValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Automatically minify all CSS files for your website. -type ZoneSettingEditParamsItemsZonesMinifyValueCss string - -const ( - ZoneSettingEditParamsItemsZonesMinifyValueCssOn ZoneSettingEditParamsItemsZonesMinifyValueCss = "on" - ZoneSettingEditParamsItemsZonesMinifyValueCssOff ZoneSettingEditParamsItemsZonesMinifyValueCss = "off" -) - -// Automatically minify all HTML files for your website. -type ZoneSettingEditParamsItemsZonesMinifyValueHTML string - -const ( - ZoneSettingEditParamsItemsZonesMinifyValueHTMLOn ZoneSettingEditParamsItemsZonesMinifyValueHTML = "on" - ZoneSettingEditParamsItemsZonesMinifyValueHTMLOff ZoneSettingEditParamsItemsZonesMinifyValueHTML = "off" -) - -// Automatically minify all JavaScript files for your website. -type ZoneSettingEditParamsItemsZonesMinifyValueJs string - -const ( - ZoneSettingEditParamsItemsZonesMinifyValueJsOn ZoneSettingEditParamsItemsZonesMinifyValueJs = "on" - ZoneSettingEditParamsItemsZonesMinifyValueJsOff ZoneSettingEditParamsItemsZonesMinifyValueJs = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesMinifyEditable bool - -const ( - ZoneSettingEditParamsItemsZonesMinifyEditableTrue ZoneSettingEditParamsItemsZonesMinifyEditable = true - ZoneSettingEditParamsItemsZonesMinifyEditableFalse ZoneSettingEditParamsItemsZonesMinifyEditable = false -) - -// Automatically optimize image loading for website visitors on mobile devices. -// Refer to -// [our blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for -// more information. -type ZoneSettingEditParamsItemsZonesMirage struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesMirageID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesMirageValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesMirage) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesMirage) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesMirageID string - -const ( - ZoneSettingEditParamsItemsZonesMirageIDMirage ZoneSettingEditParamsItemsZonesMirageID = "mirage" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesMirageValue string - -const ( - ZoneSettingEditParamsItemsZonesMirageValueOn ZoneSettingEditParamsItemsZonesMirageValue = "on" - ZoneSettingEditParamsItemsZonesMirageValueOff ZoneSettingEditParamsItemsZonesMirageValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesMirageEditable bool - -const ( - ZoneSettingEditParamsItemsZonesMirageEditableTrue ZoneSettingEditParamsItemsZonesMirageEditable = true - ZoneSettingEditParamsItemsZonesMirageEditableFalse ZoneSettingEditParamsItemsZonesMirageEditable = false -) - -// Automatically redirect visitors on mobile devices to a mobile-optimized -// subdomain. Refer to -// [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) -// for more information. -type ZoneSettingEditParamsItemsZonesMobileRedirect struct { - // Identifier of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesMobileRedirectID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesMobileRedirectValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesMobileRedirect) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesMobileRedirect) implementsZoneSettingEditParamsItem() {} - -// Identifier of the zone setting. -type ZoneSettingEditParamsItemsZonesMobileRedirectID string - -const ( - ZoneSettingEditParamsItemsZonesMobileRedirectIDMobileRedirect ZoneSettingEditParamsItemsZonesMobileRedirectID = "mobile_redirect" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesMobileRedirectValue struct { - // Which subdomain prefix you wish to redirect visitors on mobile devices to - // (subdomain must already exist). - MobileSubdomain param.Field[string] `json:"mobile_subdomain"` - // Whether or not mobile redirect is enabled. - Status param.Field[ZoneSettingEditParamsItemsZonesMobileRedirectValueStatus] `json:"status"` - // Whether to drop the current page path and redirect to the mobile subdomain URL - // root, or keep the path and redirect to the same page on the mobile subdomain. - StripURI param.Field[bool] `json:"strip_uri"` -} - -func (r ZoneSettingEditParamsItemsZonesMobileRedirectValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Whether or not mobile redirect is enabled. -type ZoneSettingEditParamsItemsZonesMobileRedirectValueStatus string - -const ( - ZoneSettingEditParamsItemsZonesMobileRedirectValueStatusOn ZoneSettingEditParamsItemsZonesMobileRedirectValueStatus = "on" - ZoneSettingEditParamsItemsZonesMobileRedirectValueStatusOff ZoneSettingEditParamsItemsZonesMobileRedirectValueStatus = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesMobileRedirectEditable bool - -const ( - ZoneSettingEditParamsItemsZonesMobileRedirectEditableTrue ZoneSettingEditParamsItemsZonesMobileRedirectEditable = true - ZoneSettingEditParamsItemsZonesMobileRedirectEditableFalse ZoneSettingEditParamsItemsZonesMobileRedirectEditable = false -) - -// Enable Network Error Logging reporting on your zone. (Beta) -type ZoneSettingEditParamsItemsZonesNEL struct { - // Zone setting identifier. - ID param.Field[ZoneSettingEditParamsItemsZonesNELID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesNELValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesNEL) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesNEL) implementsZoneSettingEditParamsItem() {} - -// Zone setting identifier. -type ZoneSettingEditParamsItemsZonesNELID string - -const ( - ZoneSettingEditParamsItemsZonesNELIDNEL ZoneSettingEditParamsItemsZonesNELID = "nel" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesNELValue struct { - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ZoneSettingEditParamsItemsZonesNELValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesNELEditable bool - -const ( - ZoneSettingEditParamsItemsZonesNELEditableTrue ZoneSettingEditParamsItemsZonesNELEditable = true - ZoneSettingEditParamsItemsZonesNELEditableFalse ZoneSettingEditParamsItemsZonesNELEditable = false -) - -// Enables the Opportunistic Encryption feature for a zone. -type ZoneSettingEditParamsItemsZonesOpportunisticEncryption struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesOpportunisticEncryptionID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesOpportunisticEncryptionValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesOpportunisticEncryption) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesOpportunisticEncryption) implementsZoneSettingEditParamsItem() { -} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesOpportunisticEncryptionID string - -const ( - ZoneSettingEditParamsItemsZonesOpportunisticEncryptionIDOpportunisticEncryption ZoneSettingEditParamsItemsZonesOpportunisticEncryptionID = "opportunistic_encryption" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesOpportunisticEncryptionValue string - -const ( - ZoneSettingEditParamsItemsZonesOpportunisticEncryptionValueOn ZoneSettingEditParamsItemsZonesOpportunisticEncryptionValue = "on" - ZoneSettingEditParamsItemsZonesOpportunisticEncryptionValueOff ZoneSettingEditParamsItemsZonesOpportunisticEncryptionValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesOpportunisticEncryptionEditable bool - -const ( - ZoneSettingEditParamsItemsZonesOpportunisticEncryptionEditableTrue ZoneSettingEditParamsItemsZonesOpportunisticEncryptionEditable = true - ZoneSettingEditParamsItemsZonesOpportunisticEncryptionEditableFalse ZoneSettingEditParamsItemsZonesOpportunisticEncryptionEditable = false -) - -// Add an Alt-Svc header to all legitimate requests from Tor, allowing the -// connection to use our onion services instead of exit nodes. -type ZoneSettingEditParamsItemsZonesOpportunisticOnion struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesOpportunisticOnionID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesOpportunisticOnionValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesOpportunisticOnion) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesOpportunisticOnion) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesOpportunisticOnionID string - -const ( - ZoneSettingEditParamsItemsZonesOpportunisticOnionIDOpportunisticOnion ZoneSettingEditParamsItemsZonesOpportunisticOnionID = "opportunistic_onion" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesOpportunisticOnionValue string - -const ( - ZoneSettingEditParamsItemsZonesOpportunisticOnionValueOn ZoneSettingEditParamsItemsZonesOpportunisticOnionValue = "on" - ZoneSettingEditParamsItemsZonesOpportunisticOnionValueOff ZoneSettingEditParamsItemsZonesOpportunisticOnionValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesOpportunisticOnionEditable bool - -const ( - ZoneSettingEditParamsItemsZonesOpportunisticOnionEditableTrue ZoneSettingEditParamsItemsZonesOpportunisticOnionEditable = true - ZoneSettingEditParamsItemsZonesOpportunisticOnionEditableFalse ZoneSettingEditParamsItemsZonesOpportunisticOnionEditable = false -) - -// Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also -// on Cloudflare. -type ZoneSettingEditParamsItemsZonesOrangeToOrange struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesOrangeToOrangeID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesOrangeToOrangeValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesOrangeToOrange) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesOrangeToOrange) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesOrangeToOrangeID string - -const ( - ZoneSettingEditParamsItemsZonesOrangeToOrangeIDOrangeToOrange ZoneSettingEditParamsItemsZonesOrangeToOrangeID = "orange_to_orange" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesOrangeToOrangeValue string - -const ( - ZoneSettingEditParamsItemsZonesOrangeToOrangeValueOn ZoneSettingEditParamsItemsZonesOrangeToOrangeValue = "on" - ZoneSettingEditParamsItemsZonesOrangeToOrangeValueOff ZoneSettingEditParamsItemsZonesOrangeToOrangeValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesOrangeToOrangeEditable bool - -const ( - ZoneSettingEditParamsItemsZonesOrangeToOrangeEditableTrue ZoneSettingEditParamsItemsZonesOrangeToOrangeEditable = true - ZoneSettingEditParamsItemsZonesOrangeToOrangeEditableFalse ZoneSettingEditParamsItemsZonesOrangeToOrangeEditable = false -) - -// Cloudflare will proxy customer error pages on any 502,504 errors on origin -// server instead of showing a default Cloudflare error page. This does not apply -// to 522 errors and is limited to Enterprise Zones. -type ZoneSettingEditParamsItemsZonesOriginErrorPagePassThru struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesOriginErrorPagePassThruID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesOriginErrorPagePassThruValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesOriginErrorPagePassThru) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesOriginErrorPagePassThru) implementsZoneSettingEditParamsItem() { -} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesOriginErrorPagePassThruID string - -const ( - ZoneSettingEditParamsItemsZonesOriginErrorPagePassThruIDOriginErrorPagePassThru ZoneSettingEditParamsItemsZonesOriginErrorPagePassThruID = "origin_error_page_pass_thru" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesOriginErrorPagePassThruValue string - -const ( - ZoneSettingEditParamsItemsZonesOriginErrorPagePassThruValueOn ZoneSettingEditParamsItemsZonesOriginErrorPagePassThruValue = "on" - ZoneSettingEditParamsItemsZonesOriginErrorPagePassThruValueOff ZoneSettingEditParamsItemsZonesOriginErrorPagePassThruValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesOriginErrorPagePassThruEditable bool - -const ( - ZoneSettingEditParamsItemsZonesOriginErrorPagePassThruEditableTrue ZoneSettingEditParamsItemsZonesOriginErrorPagePassThruEditable = true - ZoneSettingEditParamsItemsZonesOriginErrorPagePassThruEditableFalse ZoneSettingEditParamsItemsZonesOriginErrorPagePassThruEditable = false -) - -// Removes metadata and compresses your images for faster page load times. Basic -// (Lossless): Reduce the size of PNG, JPEG, and GIF files - no impact on visual -// quality. Basic + JPEG (Lossy): Further reduce the size of JPEG files for faster -// image loading. Larger JPEGs are converted to progressive images, loading a -// lower-resolution image first and ending in a higher-resolution version. Not -// recommended for hi-res photography sites. -type ZoneSettingEditParamsItemsZonesPolish struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesPolishID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesPolishValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesPolish) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesPolish) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesPolishID string - -const ( - ZoneSettingEditParamsItemsZonesPolishIDPolish ZoneSettingEditParamsItemsZonesPolishID = "polish" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesPolishValue string - -const ( - ZoneSettingEditParamsItemsZonesPolishValueOff ZoneSettingEditParamsItemsZonesPolishValue = "off" - ZoneSettingEditParamsItemsZonesPolishValueLossless ZoneSettingEditParamsItemsZonesPolishValue = "lossless" - ZoneSettingEditParamsItemsZonesPolishValueLossy ZoneSettingEditParamsItemsZonesPolishValue = "lossy" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesPolishEditable bool - -const ( - ZoneSettingEditParamsItemsZonesPolishEditableTrue ZoneSettingEditParamsItemsZonesPolishEditable = true - ZoneSettingEditParamsItemsZonesPolishEditableFalse ZoneSettingEditParamsItemsZonesPolishEditable = false -) - -// Cloudflare will prefetch any URLs that are included in the response headers. -// This is limited to Enterprise Zones. -type ZoneSettingEditParamsItemsZonesPrefetchPreload struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesPrefetchPreloadID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesPrefetchPreloadValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesPrefetchPreload) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesPrefetchPreload) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesPrefetchPreloadID string - -const ( - ZoneSettingEditParamsItemsZonesPrefetchPreloadIDPrefetchPreload ZoneSettingEditParamsItemsZonesPrefetchPreloadID = "prefetch_preload" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesPrefetchPreloadValue string - -const ( - ZoneSettingEditParamsItemsZonesPrefetchPreloadValueOn ZoneSettingEditParamsItemsZonesPrefetchPreloadValue = "on" - ZoneSettingEditParamsItemsZonesPrefetchPreloadValueOff ZoneSettingEditParamsItemsZonesPrefetchPreloadValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesPrefetchPreloadEditable bool - -const ( - ZoneSettingEditParamsItemsZonesPrefetchPreloadEditableTrue ZoneSettingEditParamsItemsZonesPrefetchPreloadEditable = true - ZoneSettingEditParamsItemsZonesPrefetchPreloadEditableFalse ZoneSettingEditParamsItemsZonesPrefetchPreloadEditable = false -) - -// Maximum time between two read operations from origin. -type ZoneSettingEditParamsItemsZonesProxyReadTimeout struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesProxyReadTimeoutID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[float64] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesProxyReadTimeout) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesProxyReadTimeout) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesProxyReadTimeoutID string - -const ( - ZoneSettingEditParamsItemsZonesProxyReadTimeoutIDProxyReadTimeout ZoneSettingEditParamsItemsZonesProxyReadTimeoutID = "proxy_read_timeout" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesProxyReadTimeoutEditable bool - -const ( - ZoneSettingEditParamsItemsZonesProxyReadTimeoutEditableTrue ZoneSettingEditParamsItemsZonesProxyReadTimeoutEditable = true - ZoneSettingEditParamsItemsZonesProxyReadTimeoutEditableFalse ZoneSettingEditParamsItemsZonesProxyReadTimeoutEditable = false -) - -// The value set for the Pseudo IPv4 setting. -type ZoneSettingEditParamsItemsZonesPseudoIPV4 struct { - // Value of the Pseudo IPv4 setting. - ID param.Field[ZoneSettingEditParamsItemsZonesPseudoIPV4ID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesPseudoIPV4Value] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesPseudoIPV4) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesPseudoIPV4) implementsZoneSettingEditParamsItem() {} - -// Value of the Pseudo IPv4 setting. -type ZoneSettingEditParamsItemsZonesPseudoIPV4ID string - -const ( - ZoneSettingEditParamsItemsZonesPseudoIPV4IDPseudoIPV4 ZoneSettingEditParamsItemsZonesPseudoIPV4ID = "pseudo_ipv4" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesPseudoIPV4Value string - -const ( - ZoneSettingEditParamsItemsZonesPseudoIPV4ValueOff ZoneSettingEditParamsItemsZonesPseudoIPV4Value = "off" - ZoneSettingEditParamsItemsZonesPseudoIPV4ValueAddHeader ZoneSettingEditParamsItemsZonesPseudoIPV4Value = "add_header" - ZoneSettingEditParamsItemsZonesPseudoIPV4ValueOverwriteHeader ZoneSettingEditParamsItemsZonesPseudoIPV4Value = "overwrite_header" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesPseudoIPV4Editable bool - -const ( - ZoneSettingEditParamsItemsZonesPseudoIPV4EditableTrue ZoneSettingEditParamsItemsZonesPseudoIPV4Editable = true - ZoneSettingEditParamsItemsZonesPseudoIPV4EditableFalse ZoneSettingEditParamsItemsZonesPseudoIPV4Editable = false -) - -// Enables or disables buffering of responses from the proxied server. Cloudflare -// may buffer the whole payload to deliver it at once to the client versus allowing -// it to be delivered in chunks. By default, the proxied server streams directly -// and is not buffered by Cloudflare. This is limited to Enterprise Zones. -type ZoneSettingEditParamsItemsZonesResponseBuffering struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesResponseBufferingID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesResponseBufferingValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesResponseBuffering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesResponseBuffering) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesResponseBufferingID string - -const ( - ZoneSettingEditParamsItemsZonesResponseBufferingIDResponseBuffering ZoneSettingEditParamsItemsZonesResponseBufferingID = "response_buffering" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesResponseBufferingValue string - -const ( - ZoneSettingEditParamsItemsZonesResponseBufferingValueOn ZoneSettingEditParamsItemsZonesResponseBufferingValue = "on" - ZoneSettingEditParamsItemsZonesResponseBufferingValueOff ZoneSettingEditParamsItemsZonesResponseBufferingValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesResponseBufferingEditable bool - -const ( - ZoneSettingEditParamsItemsZonesResponseBufferingEditableTrue ZoneSettingEditParamsItemsZonesResponseBufferingEditable = true - ZoneSettingEditParamsItemsZonesResponseBufferingEditableFalse ZoneSettingEditParamsItemsZonesResponseBufferingEditable = false -) - -// Rocket Loader is a general-purpose asynchronous JavaScript optimisation that -// prioritises rendering your content while loading your site's Javascript -// asynchronously. Turning on Rocket Loader will immediately improve a web page's -// rendering time sometimes measured as Time to First Paint (TTFP), and also the -// `window.onload` time (assuming there is JavaScript on the page). This can have a -// positive impact on your Google search ranking. When turned on, Rocket Loader -// will automatically defer the loading of all Javascript referenced in your HTML, -// with no configuration required. Refer to -// [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) -// for more information. -type ZoneSettingEditParamsItemsZonesRocketLoader struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesRocketLoaderID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesRocketLoaderValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesRocketLoader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesRocketLoader) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesRocketLoaderID string - -const ( - ZoneSettingEditParamsItemsZonesRocketLoaderIDRocketLoader ZoneSettingEditParamsItemsZonesRocketLoaderID = "rocket_loader" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesRocketLoaderValue string - -const ( - ZoneSettingEditParamsItemsZonesRocketLoaderValueOn ZoneSettingEditParamsItemsZonesRocketLoaderValue = "on" - ZoneSettingEditParamsItemsZonesRocketLoaderValueOff ZoneSettingEditParamsItemsZonesRocketLoaderValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesRocketLoaderEditable bool - -const ( - ZoneSettingEditParamsItemsZonesRocketLoaderEditableTrue ZoneSettingEditParamsItemsZonesRocketLoaderEditable = true - ZoneSettingEditParamsItemsZonesRocketLoaderEditableFalse ZoneSettingEditParamsItemsZonesRocketLoaderEditable = false -) - -// [Automatic Platform Optimization for WordPress](https://developers.cloudflare.com/automatic-platform-optimization/) -// serves your WordPress site from Cloudflare's edge network and caches third-party -// fonts. -type ZoneSettingEditParamsItemsZonesSchemasAutomaticPlatformOptimization struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesSchemasAutomaticPlatformOptimization) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesSchemasAutomaticPlatformOptimization) implementsZoneSettingEditParamsItem() { -} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationID string - -const ( - ZoneSettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationIDAutomaticPlatformOptimization ZoneSettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationID = "automatic_platform_optimization" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationValue struct { - // Indicates whether or not - // [cache by device type](https://developers.cloudflare.com/automatic-platform-optimization/reference/cache-device-type/) - // is enabled. - CacheByDeviceType param.Field[bool] `json:"cache_by_device_type,required"` - // Indicates whether or not Cloudflare proxy is enabled. - Cf param.Field[bool] `json:"cf,required"` - // Indicates whether or not Automatic Platform Optimization is enabled. - Enabled param.Field[bool] `json:"enabled,required"` - // An array of hostnames where Automatic Platform Optimization for WordPress is - // activated. - Hostnames param.Field[[]string] `json:"hostnames,required" format:"hostname"` - // Indicates whether or not site is powered by WordPress. - Wordpress param.Field[bool] `json:"wordpress,required"` - // Indicates whether or not - // [Cloudflare for WordPress plugin](https://wordpress.org/plugins/cloudflare/) is - // installed. - WpPlugin param.Field[bool] `json:"wp_plugin,required"` -} - -func (r ZoneSettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationEditable bool - -const ( - ZoneSettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationEditableTrue ZoneSettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationEditable = true - ZoneSettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationEditableFalse ZoneSettingEditParamsItemsZonesSchemasAutomaticPlatformOptimizationEditable = false -) - -// Cloudflare security header for a zone. -type ZoneSettingEditParamsItemsZonesSecurityHeader struct { - // ID of the zone's security header. - ID param.Field[ZoneSettingEditParamsItemsZonesSecurityHeaderID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesSecurityHeaderValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesSecurityHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesSecurityHeader) implementsZoneSettingEditParamsItem() {} - -// ID of the zone's security header. -type ZoneSettingEditParamsItemsZonesSecurityHeaderID string - -const ( - ZoneSettingEditParamsItemsZonesSecurityHeaderIDSecurityHeader ZoneSettingEditParamsItemsZonesSecurityHeaderID = "security_header" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesSecurityHeaderValue struct { - // Strict Transport Security. - StrictTransportSecurity param.Field[ZoneSettingEditParamsItemsZonesSecurityHeaderValueStrictTransportSecurity] `json:"strict_transport_security"` -} - -func (r ZoneSettingEditParamsItemsZonesSecurityHeaderValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Strict Transport Security. -type ZoneSettingEditParamsItemsZonesSecurityHeaderValueStrictTransportSecurity struct { - // Whether or not strict transport security is enabled. - Enabled param.Field[bool] `json:"enabled"` - // Include all subdomains for strict transport security. - IncludeSubdomains param.Field[bool] `json:"include_subdomains"` - // Max age in seconds of the strict transport security. - MaxAge param.Field[float64] `json:"max_age"` - // Whether or not to include 'X-Content-Type-Options: nosniff' header. - Nosniff param.Field[bool] `json:"nosniff"` -} - -func (r ZoneSettingEditParamsItemsZonesSecurityHeaderValueStrictTransportSecurity) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesSecurityHeaderEditable bool - -const ( - ZoneSettingEditParamsItemsZonesSecurityHeaderEditableTrue ZoneSettingEditParamsItemsZonesSecurityHeaderEditable = true - ZoneSettingEditParamsItemsZonesSecurityHeaderEditableFalse ZoneSettingEditParamsItemsZonesSecurityHeaderEditable = false -) - -// Choose the appropriate security profile for your website, which will -// automatically adjust each of the security settings. If you choose to customize -// an individual security setting, the profile will become Custom. -// (https://support.cloudflare.com/hc/en-us/articles/200170056). -type ZoneSettingEditParamsItemsZonesSecurityLevel struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesSecurityLevelID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesSecurityLevelValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesSecurityLevel) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesSecurityLevel) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesSecurityLevelID string - -const ( - ZoneSettingEditParamsItemsZonesSecurityLevelIDSecurityLevel ZoneSettingEditParamsItemsZonesSecurityLevelID = "security_level" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesSecurityLevelValue string - -const ( - ZoneSettingEditParamsItemsZonesSecurityLevelValueOff ZoneSettingEditParamsItemsZonesSecurityLevelValue = "off" - ZoneSettingEditParamsItemsZonesSecurityLevelValueEssentiallyOff ZoneSettingEditParamsItemsZonesSecurityLevelValue = "essentially_off" - ZoneSettingEditParamsItemsZonesSecurityLevelValueLow ZoneSettingEditParamsItemsZonesSecurityLevelValue = "low" - ZoneSettingEditParamsItemsZonesSecurityLevelValueMedium ZoneSettingEditParamsItemsZonesSecurityLevelValue = "medium" - ZoneSettingEditParamsItemsZonesSecurityLevelValueHigh ZoneSettingEditParamsItemsZonesSecurityLevelValue = "high" - ZoneSettingEditParamsItemsZonesSecurityLevelValueUnderAttack ZoneSettingEditParamsItemsZonesSecurityLevelValue = "under_attack" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesSecurityLevelEditable bool - -const ( - ZoneSettingEditParamsItemsZonesSecurityLevelEditableTrue ZoneSettingEditParamsItemsZonesSecurityLevelEditable = true - ZoneSettingEditParamsItemsZonesSecurityLevelEditableFalse ZoneSettingEditParamsItemsZonesSecurityLevelEditable = false -) - -// If there is sensitive content on your website that you want visible to real -// visitors, but that you want to hide from suspicious visitors, all you have to do -// is wrap the content with Cloudflare SSE tags. Wrap any content that you want to -// be excluded from suspicious visitors in the following SSE tags: -// . For example: Bad visitors won't see my phone -// number, 555-555-5555 . Note: SSE only will work with HTML. If you -// have HTML minification enabled, you won't see the SSE tags in your HTML source -// when it's served through Cloudflare. SSE will still function in this case, as -// Cloudflare's HTML minification and SSE functionality occur on-the-fly as the -// resource moves through our network to the visitor's computer. -// (https://support.cloudflare.com/hc/en-us/articles/200170036). -type ZoneSettingEditParamsItemsZonesServerSideExclude struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesServerSideExcludeID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesServerSideExcludeValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesServerSideExclude) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesServerSideExclude) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesServerSideExcludeID string - -const ( - ZoneSettingEditParamsItemsZonesServerSideExcludeIDServerSideExclude ZoneSettingEditParamsItemsZonesServerSideExcludeID = "server_side_exclude" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesServerSideExcludeValue string - -const ( - ZoneSettingEditParamsItemsZonesServerSideExcludeValueOn ZoneSettingEditParamsItemsZonesServerSideExcludeValue = "on" - ZoneSettingEditParamsItemsZonesServerSideExcludeValueOff ZoneSettingEditParamsItemsZonesServerSideExcludeValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesServerSideExcludeEditable bool - -const ( - ZoneSettingEditParamsItemsZonesServerSideExcludeEditableTrue ZoneSettingEditParamsItemsZonesServerSideExcludeEditable = true - ZoneSettingEditParamsItemsZonesServerSideExcludeEditableFalse ZoneSettingEditParamsItemsZonesServerSideExcludeEditable = false -) - -// Allow SHA1 support. -type ZoneSettingEditParamsItemsZonesSha1Support struct { - // Zone setting identifier. - ID param.Field[ZoneSettingEditParamsItemsZonesSha1SupportID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesSha1SupportValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesSha1Support) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesSha1Support) implementsZoneSettingEditParamsItem() {} - -// Zone setting identifier. -type ZoneSettingEditParamsItemsZonesSha1SupportID string - -const ( - ZoneSettingEditParamsItemsZonesSha1SupportIDSha1Support ZoneSettingEditParamsItemsZonesSha1SupportID = "sha1_support" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesSha1SupportValue string - -const ( - ZoneSettingEditParamsItemsZonesSha1SupportValueOff ZoneSettingEditParamsItemsZonesSha1SupportValue = "off" - ZoneSettingEditParamsItemsZonesSha1SupportValueOn ZoneSettingEditParamsItemsZonesSha1SupportValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesSha1SupportEditable bool - -const ( - ZoneSettingEditParamsItemsZonesSha1SupportEditableTrue ZoneSettingEditParamsItemsZonesSha1SupportEditable = true - ZoneSettingEditParamsItemsZonesSha1SupportEditableFalse ZoneSettingEditParamsItemsZonesSha1SupportEditable = false -) - -// Cloudflare will treat files with the same query strings as the same file in -// cache, regardless of the order of the query strings. This is limited to -// Enterprise Zones. -type ZoneSettingEditParamsItemsZonesSortQueryStringForCache struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesSortQueryStringForCacheID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesSortQueryStringForCacheValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesSortQueryStringForCache) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesSortQueryStringForCache) implementsZoneSettingEditParamsItem() { -} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesSortQueryStringForCacheID string - -const ( - ZoneSettingEditParamsItemsZonesSortQueryStringForCacheIDSortQueryStringForCache ZoneSettingEditParamsItemsZonesSortQueryStringForCacheID = "sort_query_string_for_cache" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesSortQueryStringForCacheValue string - -const ( - ZoneSettingEditParamsItemsZonesSortQueryStringForCacheValueOn ZoneSettingEditParamsItemsZonesSortQueryStringForCacheValue = "on" - ZoneSettingEditParamsItemsZonesSortQueryStringForCacheValueOff ZoneSettingEditParamsItemsZonesSortQueryStringForCacheValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesSortQueryStringForCacheEditable bool - -const ( - ZoneSettingEditParamsItemsZonesSortQueryStringForCacheEditableTrue ZoneSettingEditParamsItemsZonesSortQueryStringForCacheEditable = true - ZoneSettingEditParamsItemsZonesSortQueryStringForCacheEditableFalse ZoneSettingEditParamsItemsZonesSortQueryStringForCacheEditable = false -) - -// SSL encrypts your visitor's connection and safeguards credit card numbers and -// other personal data to and from your website. SSL can take up to 5 minutes to -// fully activate. Requires Cloudflare active on your root domain or www domain. -// Off: no SSL between the visitor and Cloudflare, and no SSL between Cloudflare -// and your web server (all HTTP traffic). Flexible: SSL between the visitor and -// Cloudflare -- visitor sees HTTPS on your site, but no SSL between Cloudflare and -// your web server. You don't need to have an SSL cert on your web server, but your -// vistors will still see the site as being HTTPS enabled. Full: SSL between the -// visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between -// Cloudflare and your web server. You'll need to have your own SSL cert or -// self-signed cert at the very least. Full (Strict): SSL between the visitor and -// Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and -// your web server. You'll need to have a valid SSL certificate installed on your -// web server. This certificate must be signed by a certificate authority, have an -// expiration date in the future, and respond for the request domain name -// (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). -type ZoneSettingEditParamsItemsZonesSSL struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesSSLID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesSSLValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesSSL) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesSSL) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesSSLID string - -const ( - ZoneSettingEditParamsItemsZonesSSLIDSSL ZoneSettingEditParamsItemsZonesSSLID = "ssl" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesSSLValue string - -const ( - ZoneSettingEditParamsItemsZonesSSLValueOff ZoneSettingEditParamsItemsZonesSSLValue = "off" - ZoneSettingEditParamsItemsZonesSSLValueFlexible ZoneSettingEditParamsItemsZonesSSLValue = "flexible" - ZoneSettingEditParamsItemsZonesSSLValueFull ZoneSettingEditParamsItemsZonesSSLValue = "full" - ZoneSettingEditParamsItemsZonesSSLValueStrict ZoneSettingEditParamsItemsZonesSSLValue = "strict" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesSSLEditable bool - -const ( - ZoneSettingEditParamsItemsZonesSSLEditableTrue ZoneSettingEditParamsItemsZonesSSLEditable = true - ZoneSettingEditParamsItemsZonesSSLEditableFalse ZoneSettingEditParamsItemsZonesSSLEditable = false -) - -// Enrollment in the SSL/TLS Recommender service which tries to detect and -// recommend (by sending periodic emails) the most secure SSL/TLS setting your -// origin servers support. -type ZoneSettingEditParamsItemsZonesSSLRecommender struct { - // Enrollment value for SSL/TLS Recommender. - ID param.Field[ZoneSettingEditParamsItemsZonesSSLRecommenderID] `json:"id"` - // ssl-recommender enrollment setting. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ZoneSettingEditParamsItemsZonesSSLRecommender) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesSSLRecommender) implementsZoneSettingEditParamsItem() {} - -// Enrollment value for SSL/TLS Recommender. -type ZoneSettingEditParamsItemsZonesSSLRecommenderID string - -const ( - ZoneSettingEditParamsItemsZonesSSLRecommenderIDSSLRecommender ZoneSettingEditParamsItemsZonesSSLRecommenderID = "ssl_recommender" -) - -// Only allows TLS1.2. -type ZoneSettingEditParamsItemsZonesTLS1_2Only struct { - // Zone setting identifier. - ID param.Field[ZoneSettingEditParamsItemsZonesTLS1_2OnlyID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesTLS1_2OnlyValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesTLS1_2Only) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesTLS1_2Only) implementsZoneSettingEditParamsItem() {} - -// Zone setting identifier. -type ZoneSettingEditParamsItemsZonesTLS1_2OnlyID string - -const ( - ZoneSettingEditParamsItemsZonesTLS1_2OnlyIDTLS1_2Only ZoneSettingEditParamsItemsZonesTLS1_2OnlyID = "tls_1_2_only" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesTLS1_2OnlyValue string - -const ( - ZoneSettingEditParamsItemsZonesTLS1_2OnlyValueOff ZoneSettingEditParamsItemsZonesTLS1_2OnlyValue = "off" - ZoneSettingEditParamsItemsZonesTLS1_2OnlyValueOn ZoneSettingEditParamsItemsZonesTLS1_2OnlyValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesTLS1_2OnlyEditable bool - -const ( - ZoneSettingEditParamsItemsZonesTLS1_2OnlyEditableTrue ZoneSettingEditParamsItemsZonesTLS1_2OnlyEditable = true - ZoneSettingEditParamsItemsZonesTLS1_2OnlyEditableFalse ZoneSettingEditParamsItemsZonesTLS1_2OnlyEditable = false -) - -// Enables Crypto TLS 1.3 feature for a zone. -type ZoneSettingEditParamsItemsZonesTLS1_3 struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesTLS1_3ID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesTLS1_3Value] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesTLS1_3) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesTLS1_3) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesTLS1_3ID string - -const ( - ZoneSettingEditParamsItemsZonesTLS1_3IDTLS1_3 ZoneSettingEditParamsItemsZonesTLS1_3ID = "tls_1_3" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesTLS1_3Value string - -const ( - ZoneSettingEditParamsItemsZonesTLS1_3ValueOn ZoneSettingEditParamsItemsZonesTLS1_3Value = "on" - ZoneSettingEditParamsItemsZonesTLS1_3ValueOff ZoneSettingEditParamsItemsZonesTLS1_3Value = "off" - ZoneSettingEditParamsItemsZonesTLS1_3ValueZrt ZoneSettingEditParamsItemsZonesTLS1_3Value = "zrt" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesTLS1_3Editable bool - -const ( - ZoneSettingEditParamsItemsZonesTLS1_3EditableTrue ZoneSettingEditParamsItemsZonesTLS1_3Editable = true - ZoneSettingEditParamsItemsZonesTLS1_3EditableFalse ZoneSettingEditParamsItemsZonesTLS1_3Editable = false -) - -// TLS Client Auth requires Cloudflare to connect to your origin server using a -// client certificate (Enterprise Only). -type ZoneSettingEditParamsItemsZonesTLSClientAuth struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesTLSClientAuthID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesTLSClientAuthValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesTLSClientAuth) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesTLSClientAuth) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesTLSClientAuthID string - -const ( - ZoneSettingEditParamsItemsZonesTLSClientAuthIDTLSClientAuth ZoneSettingEditParamsItemsZonesTLSClientAuthID = "tls_client_auth" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesTLSClientAuthValue string - -const ( - ZoneSettingEditParamsItemsZonesTLSClientAuthValueOn ZoneSettingEditParamsItemsZonesTLSClientAuthValue = "on" - ZoneSettingEditParamsItemsZonesTLSClientAuthValueOff ZoneSettingEditParamsItemsZonesTLSClientAuthValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesTLSClientAuthEditable bool - -const ( - ZoneSettingEditParamsItemsZonesTLSClientAuthEditableTrue ZoneSettingEditParamsItemsZonesTLSClientAuthEditable = true - ZoneSettingEditParamsItemsZonesTLSClientAuthEditableFalse ZoneSettingEditParamsItemsZonesTLSClientAuthEditable = false -) - -// Allows customer to continue to use True Client IP (Akamai feature) in the -// headers we send to the origin. This is limited to Enterprise Zones. -type ZoneSettingEditParamsItemsZonesTrueClientIPHeader struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesTrueClientIPHeaderID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesTrueClientIPHeaderValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesTrueClientIPHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesTrueClientIPHeader) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesTrueClientIPHeaderID string - -const ( - ZoneSettingEditParamsItemsZonesTrueClientIPHeaderIDTrueClientIPHeader ZoneSettingEditParamsItemsZonesTrueClientIPHeaderID = "true_client_ip_header" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesTrueClientIPHeaderValue string - -const ( - ZoneSettingEditParamsItemsZonesTrueClientIPHeaderValueOn ZoneSettingEditParamsItemsZonesTrueClientIPHeaderValue = "on" - ZoneSettingEditParamsItemsZonesTrueClientIPHeaderValueOff ZoneSettingEditParamsItemsZonesTrueClientIPHeaderValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesTrueClientIPHeaderEditable bool - -const ( - ZoneSettingEditParamsItemsZonesTrueClientIPHeaderEditableTrue ZoneSettingEditParamsItemsZonesTrueClientIPHeaderEditable = true - ZoneSettingEditParamsItemsZonesTrueClientIPHeaderEditableFalse ZoneSettingEditParamsItemsZonesTrueClientIPHeaderEditable = false -) - -// The WAF examines HTTP requests to your website. It inspects both GET and POST -// requests and applies rules to help filter out illegitimate traffic from -// legitimate website visitors. The Cloudflare WAF inspects website addresses or -// URLs to detect anything out of the ordinary. If the Cloudflare WAF determines -// suspicious user behavior, then the WAF will 'challenge' the web visitor with a -// page that asks them to submit a CAPTCHA successfully to continue their action. -// If the challenge is failed, the action will be stopped. What this means is that -// Cloudflare's WAF will block any traffic identified as illegitimate before it -// reaches your origin web server. -// (https://support.cloudflare.com/hc/en-us/articles/200172016). -type ZoneSettingEditParamsItemsZonesWAF struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesWAFID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesWAFValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesWAF) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesWAF) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesWAFID string - -const ( - ZoneSettingEditParamsItemsZonesWAFIDWAF ZoneSettingEditParamsItemsZonesWAFID = "waf" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesWAFValue string - -const ( - ZoneSettingEditParamsItemsZonesWAFValueOn ZoneSettingEditParamsItemsZonesWAFValue = "on" - ZoneSettingEditParamsItemsZonesWAFValueOff ZoneSettingEditParamsItemsZonesWAFValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesWAFEditable bool - -const ( - ZoneSettingEditParamsItemsZonesWAFEditableTrue ZoneSettingEditParamsItemsZonesWAFEditable = true - ZoneSettingEditParamsItemsZonesWAFEditableFalse ZoneSettingEditParamsItemsZonesWAFEditable = false -) - -// When the client requesting the image supports the WebP image codec, and WebP -// offers a performance advantage over the original image format, Cloudflare will -// serve a WebP version of the original image. -type ZoneSettingEditParamsItemsZonesWebp struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesWebpID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesWebpValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesWebp) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesWebp) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesWebpID string - -const ( - ZoneSettingEditParamsItemsZonesWebpIDWebp ZoneSettingEditParamsItemsZonesWebpID = "webp" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesWebpValue string - -const ( - ZoneSettingEditParamsItemsZonesWebpValueOff ZoneSettingEditParamsItemsZonesWebpValue = "off" - ZoneSettingEditParamsItemsZonesWebpValueOn ZoneSettingEditParamsItemsZonesWebpValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesWebpEditable bool - -const ( - ZoneSettingEditParamsItemsZonesWebpEditableTrue ZoneSettingEditParamsItemsZonesWebpEditable = true - ZoneSettingEditParamsItemsZonesWebpEditableFalse ZoneSettingEditParamsItemsZonesWebpEditable = false -) - -// WebSockets are open connections sustained between the client and the origin -// server. Inside a WebSockets connection, the client and the origin can pass data -// back and forth without having to reestablish sessions. This makes exchanging -// data within a WebSockets connection fast. WebSockets are often used for -// real-time applications such as live chat and gaming. For more information refer -// to -// [Can I use Cloudflare with Websockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Can-I-use-Cloudflare-with-WebSockets-). -type ZoneSettingEditParamsItemsZonesWebsockets struct { - // ID of the zone setting. - ID param.Field[ZoneSettingEditParamsItemsZonesWebsocketsID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingEditParamsItemsZonesWebsocketsValue] `json:"value,required"` -} - -func (r ZoneSettingEditParamsItemsZonesWebsockets) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ZoneSettingEditParamsItemsZonesWebsockets) implementsZoneSettingEditParamsItem() {} - -// ID of the zone setting. -type ZoneSettingEditParamsItemsZonesWebsocketsID string - -const ( - ZoneSettingEditParamsItemsZonesWebsocketsIDWebsockets ZoneSettingEditParamsItemsZonesWebsocketsID = "websockets" -) - -// Current value of the zone setting. -type ZoneSettingEditParamsItemsZonesWebsocketsValue string - -const ( - ZoneSettingEditParamsItemsZonesWebsocketsValueOff ZoneSettingEditParamsItemsZonesWebsocketsValue = "off" - ZoneSettingEditParamsItemsZonesWebsocketsValueOn ZoneSettingEditParamsItemsZonesWebsocketsValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEditParamsItemsZonesWebsocketsEditable bool - -const ( - ZoneSettingEditParamsItemsZonesWebsocketsEditableTrue ZoneSettingEditParamsItemsZonesWebsocketsEditable = true - ZoneSettingEditParamsItemsZonesWebsocketsEditableFalse ZoneSettingEditParamsItemsZonesWebsocketsEditable = false -) - -type ZoneSettingEditResponseEnvelope struct { - Errors []ZoneSettingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - Result []ZoneSettingEditResponse `json:"result"` - JSON zoneSettingEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [ZoneSettingEditResponseEnvelope] -type zoneSettingEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseEnvelopeErrors] -type zoneSettingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingEditResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ZoneSettingEditResponseEnvelopeMessages] -type zoneSettingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingGetResponseEnvelope struct { - Errors []ZoneSettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - Result []ZoneSettingGetResponse `json:"result"` - JSON zoneSettingGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [ZoneSettingGetResponseEnvelope] -type zoneSettingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseEnvelopeErrors] -type zoneSettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ZoneSettingGetResponseEnvelopeMessages] -type zoneSettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesetting_test.go b/zonesetting_test.go deleted file mode 100644 index f21e4d385f9..00000000000 --- a/zonesetting_test.go +++ /dev/null @@ -1,76 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingEdit(t *testing.T) { - t.Skip("oneOf doesnt match") - 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("user@example.com"), - ) - _, err := client.Zones.Settings.Edit(context.TODO(), cloudflare.ZoneSettingEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Items: cloudflare.F([]cloudflare.ZoneSettingEditParamsItem{cloudflare.ZoneSettingEditParamsItemsZonesAlwaysOnline(cloudflare.ZoneSettingEditParamsItemsZonesAlwaysOnline{ - ID: cloudflare.F(cloudflare.ZoneSettingEditParamsItemsZonesAlwaysOnlineIDAlwaysOnline), - Value: cloudflare.F(cloudflare.ZoneSettingEditParamsItemsZonesAlwaysOnlineValueOn), - }), cloudflare.ZoneSettingEditParamsItemsZonesBrowserCacheTTL(cloudflare.ZoneSettingEditParamsItemsZonesBrowserCacheTTL{ - ID: cloudflare.F(cloudflare.ZoneSettingEditParamsItemsZonesBrowserCacheTTLIDBrowserCacheTTL), - Value: cloudflare.F(cloudflare.ZoneSettingEditParamsItemsZonesBrowserCacheTTLValue18000), - }), cloudflare.ZoneSettingEditParamsItemsZonesIPGeolocation(cloudflare.ZoneSettingEditParamsItemsZonesIPGeolocation{ - ID: cloudflare.F(cloudflare.ZoneSettingEditParamsItemsZonesIPGeolocationIDIPGeolocation), - Value: cloudflare.F(cloudflare.ZoneSettingEditParamsItemsZonesIPGeolocationValueOff), - })}), - }) - 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 TestZoneSettingGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.Get(context.TODO(), cloudflare.ZoneSettingGetParams{ - ZoneID: cloudflare.F("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/zonesettingadvancedddos.go b/zonesettingadvancedddos.go deleted file mode 100644 index aa5f4b812db..00000000000 --- a/zonesettingadvancedddos.go +++ /dev/null @@ -1,189 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-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) Get(ctx context.Context, query ZoneSettingAdvancedDDOSGetParams, opts ...option.RequestOption) (res *ZoneSettingAdvancedDDOSGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingAdvancedDDOSGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/advanced_ddos", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - 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. -type ZoneSettingAdvancedDDOSGetResponse struct { - // ID of the zone setting. - ID ZoneSettingAdvancedDDOSGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingAdvancedDDOSGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingAdvancedDDOSGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingAdvancedDDOSGetResponseJSON `json:"-"` -} - -// zoneSettingAdvancedDDOSGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingAdvancedDDOSGetResponse] -type zoneSettingAdvancedDDOSGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAdvancedDDOSGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAdvancedDDOSGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingAdvancedDDOSGetResponseID string - -const ( - ZoneSettingAdvancedDDOSGetResponseIDAdvancedDDOS ZoneSettingAdvancedDDOSGetResponseID = "advanced_ddos" -) - -// Current value of the zone setting. -type ZoneSettingAdvancedDDOSGetResponseValue string - -const ( - ZoneSettingAdvancedDDOSGetResponseValueOn ZoneSettingAdvancedDDOSGetResponseValue = "on" - ZoneSettingAdvancedDDOSGetResponseValueOff ZoneSettingAdvancedDDOSGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingAdvancedDDOSGetResponseEditable bool - -const ( - ZoneSettingAdvancedDDOSGetResponseEditableTrue ZoneSettingAdvancedDDOSGetResponseEditable = true - ZoneSettingAdvancedDDOSGetResponseEditableFalse ZoneSettingAdvancedDDOSGetResponseEditable = false -) - -type ZoneSettingAdvancedDDOSGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingAdvancedDDOSGetResponseEnvelope struct { - Errors []ZoneSettingAdvancedDDOSGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingAdvancedDDOSGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // 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. - Result ZoneSettingAdvancedDDOSGetResponse `json:"result"` - JSON zoneSettingAdvancedDDOSGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingAdvancedDDOSGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingAdvancedDDOSGetResponseEnvelope] -type zoneSettingAdvancedDDOSGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAdvancedDDOSGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAdvancedDDOSGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAdvancedDDOSGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAdvancedDDOSGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingAdvancedDDOSGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingAdvancedDDOSGetResponseEnvelopeErrors] -type zoneSettingAdvancedDDOSGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAdvancedDDOSGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAdvancedDDOSGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAdvancedDDOSGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAdvancedDDOSGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingAdvancedDDOSGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingAdvancedDDOSGetResponseEnvelopeMessages] -type zoneSettingAdvancedDDOSGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAdvancedDDOSGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAdvancedDDOSGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingadvancedddos_test.go b/zonesettingadvancedddos_test.go deleted file mode 100644 index 7ac43932c7d..00000000000 --- a/zonesettingadvancedddos_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingAdvancedDDOSGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.AdvancedDDOS.Get(context.TODO(), cloudflare.ZoneSettingAdvancedDDOSGetParams{ - ZoneID: cloudflare.F("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/zonesettingalwaysonline.go b/zonesettingalwaysonline.go deleted file mode 100644 index fadb67c5b3c..00000000000 --- a/zonesettingalwaysonline.go +++ /dev/null @@ -1,371 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingAlwaysOnlineService 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 -// [NewZoneSettingAlwaysOnlineService] method instead. -type ZoneSettingAlwaysOnlineService struct { - Options []option.RequestOption -} - -// NewZoneSettingAlwaysOnlineService 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 NewZoneSettingAlwaysOnlineService(opts ...option.RequestOption) (r *ZoneSettingAlwaysOnlineService) { - r = &ZoneSettingAlwaysOnlineService{} - r.Options = opts - return -} - -// When enabled, Cloudflare serves limited copies of web pages available from the -// [Internet Archive's Wayback Machine](https://archive.org/web/) if your server is -// offline. Refer to -// [Always Online](https://developers.cloudflare.com/cache/about/always-online) for -// more information. -func (r *ZoneSettingAlwaysOnlineService) Edit(ctx context.Context, params ZoneSettingAlwaysOnlineEditParams, opts ...option.RequestOption) (res *ZoneSettingAlwaysOnlineEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingAlwaysOnlineEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/always_online", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// When enabled, Cloudflare serves limited copies of web pages available from the -// [Internet Archive's Wayback Machine](https://archive.org/web/) if your server is -// offline. Refer to -// [Always Online](https://developers.cloudflare.com/cache/about/always-online) for -// more information. -func (r *ZoneSettingAlwaysOnlineService) Get(ctx context.Context, query ZoneSettingAlwaysOnlineGetParams, opts ...option.RequestOption) (res *ZoneSettingAlwaysOnlineGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingAlwaysOnlineGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/always_online", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// When enabled, Cloudflare serves limited copies of web pages available from the -// [Internet Archive's Wayback Machine](https://archive.org/web/) if your server is -// offline. Refer to -// [Always Online](https://developers.cloudflare.com/cache/about/always-online) for -// more information. -type ZoneSettingAlwaysOnlineEditResponse struct { - // ID of the zone setting. - ID ZoneSettingAlwaysOnlineEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingAlwaysOnlineEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingAlwaysOnlineEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingAlwaysOnlineEditResponseJSON `json:"-"` -} - -// zoneSettingAlwaysOnlineEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingAlwaysOnlineEditResponse] -type zoneSettingAlwaysOnlineEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAlwaysOnlineEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAlwaysOnlineEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingAlwaysOnlineEditResponseID string - -const ( - ZoneSettingAlwaysOnlineEditResponseIDAlwaysOnline ZoneSettingAlwaysOnlineEditResponseID = "always_online" -) - -// Current value of the zone setting. -type ZoneSettingAlwaysOnlineEditResponseValue string - -const ( - ZoneSettingAlwaysOnlineEditResponseValueOn ZoneSettingAlwaysOnlineEditResponseValue = "on" - ZoneSettingAlwaysOnlineEditResponseValueOff ZoneSettingAlwaysOnlineEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingAlwaysOnlineEditResponseEditable bool - -const ( - ZoneSettingAlwaysOnlineEditResponseEditableTrue ZoneSettingAlwaysOnlineEditResponseEditable = true - ZoneSettingAlwaysOnlineEditResponseEditableFalse ZoneSettingAlwaysOnlineEditResponseEditable = false -) - -// When enabled, Cloudflare serves limited copies of web pages available from the -// [Internet Archive's Wayback Machine](https://archive.org/web/) if your server is -// offline. Refer to -// [Always Online](https://developers.cloudflare.com/cache/about/always-online) for -// more information. -type ZoneSettingAlwaysOnlineGetResponse struct { - // ID of the zone setting. - ID ZoneSettingAlwaysOnlineGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingAlwaysOnlineGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingAlwaysOnlineGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingAlwaysOnlineGetResponseJSON `json:"-"` -} - -// zoneSettingAlwaysOnlineGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingAlwaysOnlineGetResponse] -type zoneSettingAlwaysOnlineGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAlwaysOnlineGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAlwaysOnlineGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingAlwaysOnlineGetResponseID string - -const ( - ZoneSettingAlwaysOnlineGetResponseIDAlwaysOnline ZoneSettingAlwaysOnlineGetResponseID = "always_online" -) - -// Current value of the zone setting. -type ZoneSettingAlwaysOnlineGetResponseValue string - -const ( - ZoneSettingAlwaysOnlineGetResponseValueOn ZoneSettingAlwaysOnlineGetResponseValue = "on" - ZoneSettingAlwaysOnlineGetResponseValueOff ZoneSettingAlwaysOnlineGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingAlwaysOnlineGetResponseEditable bool - -const ( - ZoneSettingAlwaysOnlineGetResponseEditableTrue ZoneSettingAlwaysOnlineGetResponseEditable = true - ZoneSettingAlwaysOnlineGetResponseEditableFalse ZoneSettingAlwaysOnlineGetResponseEditable = false -) - -type ZoneSettingAlwaysOnlineEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingAlwaysOnlineEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingAlwaysOnlineEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingAlwaysOnlineEditParamsValue string - -const ( - ZoneSettingAlwaysOnlineEditParamsValueOn ZoneSettingAlwaysOnlineEditParamsValue = "on" - ZoneSettingAlwaysOnlineEditParamsValueOff ZoneSettingAlwaysOnlineEditParamsValue = "off" -) - -type ZoneSettingAlwaysOnlineEditResponseEnvelope struct { - Errors []ZoneSettingAlwaysOnlineEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingAlwaysOnlineEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // When enabled, Cloudflare serves limited copies of web pages available from the - // [Internet Archive's Wayback Machine](https://archive.org/web/) if your server is - // offline. Refer to - // [Always Online](https://developers.cloudflare.com/cache/about/always-online) for - // more information. - Result ZoneSettingAlwaysOnlineEditResponse `json:"result"` - JSON zoneSettingAlwaysOnlineEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingAlwaysOnlineEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingAlwaysOnlineEditResponseEnvelope] -type zoneSettingAlwaysOnlineEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAlwaysOnlineEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAlwaysOnlineEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAlwaysOnlineEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAlwaysOnlineEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingAlwaysOnlineEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingAlwaysOnlineEditResponseEnvelopeErrors] -type zoneSettingAlwaysOnlineEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAlwaysOnlineEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAlwaysOnlineEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAlwaysOnlineEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAlwaysOnlineEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingAlwaysOnlineEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingAlwaysOnlineEditResponseEnvelopeMessages] -type zoneSettingAlwaysOnlineEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAlwaysOnlineEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAlwaysOnlineEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAlwaysOnlineGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingAlwaysOnlineGetResponseEnvelope struct { - Errors []ZoneSettingAlwaysOnlineGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingAlwaysOnlineGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // When enabled, Cloudflare serves limited copies of web pages available from the - // [Internet Archive's Wayback Machine](https://archive.org/web/) if your server is - // offline. Refer to - // [Always Online](https://developers.cloudflare.com/cache/about/always-online) for - // more information. - Result ZoneSettingAlwaysOnlineGetResponse `json:"result"` - JSON zoneSettingAlwaysOnlineGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingAlwaysOnlineGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingAlwaysOnlineGetResponseEnvelope] -type zoneSettingAlwaysOnlineGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAlwaysOnlineGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAlwaysOnlineGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAlwaysOnlineGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAlwaysOnlineGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingAlwaysOnlineGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingAlwaysOnlineGetResponseEnvelopeErrors] -type zoneSettingAlwaysOnlineGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAlwaysOnlineGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAlwaysOnlineGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAlwaysOnlineGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAlwaysOnlineGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingAlwaysOnlineGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingAlwaysOnlineGetResponseEnvelopeMessages] -type zoneSettingAlwaysOnlineGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAlwaysOnlineGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAlwaysOnlineGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingalwaysonline_test.go b/zonesettingalwaysonline_test.go deleted file mode 100644 index f6ae98c7dea..00000000000 --- a/zonesettingalwaysonline_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingAlwaysOnlineEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.AlwaysOnline.Edit(context.TODO(), cloudflare.ZoneSettingAlwaysOnlineEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingAlwaysOnlineEditParamsValueOn), - }) - 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 TestZoneSettingAlwaysOnlineGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.AlwaysOnline.Get(context.TODO(), cloudflare.ZoneSettingAlwaysOnlineGetParams{ - ZoneID: cloudflare.F("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/zonesettingalwaysusehttps.go b/zonesettingalwaysusehttps.go deleted file mode 100644 index 58c6d3de7ce..00000000000 --- a/zonesettingalwaysusehttps.go +++ /dev/null @@ -1,359 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingAlwaysUseHTTPSService 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 -// [NewZoneSettingAlwaysUseHTTPSService] method instead. -type ZoneSettingAlwaysUseHTTPSService struct { - Options []option.RequestOption -} - -// NewZoneSettingAlwaysUseHTTPSService 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 NewZoneSettingAlwaysUseHTTPSService(opts ...option.RequestOption) (r *ZoneSettingAlwaysUseHTTPSService) { - r = &ZoneSettingAlwaysUseHTTPSService{} - r.Options = opts - return -} - -// Reply to all requests for URLs that use "http" with a 301 redirect to the -// equivalent "https" URL. If you only want to redirect for a subset of requests, -// consider creating an "Always use HTTPS" page rule. -func (r *ZoneSettingAlwaysUseHTTPSService) Edit(ctx context.Context, params ZoneSettingAlwaysUseHTTPSEditParams, opts ...option.RequestOption) (res *ZoneSettingAlwaysUseHTTPSEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingAlwaysUseHTTPSEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/always_use_https", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Reply to all requests for URLs that use "http" with a 301 redirect to the -// equivalent "https" URL. If you only want to redirect for a subset of requests, -// consider creating an "Always use HTTPS" page rule. -func (r *ZoneSettingAlwaysUseHTTPSService) Get(ctx context.Context, query ZoneSettingAlwaysUseHTTPSGetParams, opts ...option.RequestOption) (res *ZoneSettingAlwaysUseHTTPSGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingAlwaysUseHTTPSGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/always_use_https", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Reply to all requests for URLs that use "http" with a 301 redirect to the -// equivalent "https" URL. If you only want to redirect for a subset of requests, -// consider creating an "Always use HTTPS" page rule. -type ZoneSettingAlwaysUseHTTPSEditResponse struct { - // ID of the zone setting. - ID ZoneSettingAlwaysUseHTTPSEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingAlwaysUseHTTPSEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingAlwaysUseHTTPSEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingAlwaysUseHTTPSEditResponseJSON `json:"-"` -} - -// zoneSettingAlwaysUseHTTPSEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingAlwaysUseHTTPSEditResponse] -type zoneSettingAlwaysUseHTTPSEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAlwaysUseHTTPSEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAlwaysUseHTTPSEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingAlwaysUseHTTPSEditResponseID string - -const ( - ZoneSettingAlwaysUseHTTPSEditResponseIDAlwaysUseHTTPS ZoneSettingAlwaysUseHTTPSEditResponseID = "always_use_https" -) - -// Current value of the zone setting. -type ZoneSettingAlwaysUseHTTPSEditResponseValue string - -const ( - ZoneSettingAlwaysUseHTTPSEditResponseValueOn ZoneSettingAlwaysUseHTTPSEditResponseValue = "on" - ZoneSettingAlwaysUseHTTPSEditResponseValueOff ZoneSettingAlwaysUseHTTPSEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingAlwaysUseHTTPSEditResponseEditable bool - -const ( - ZoneSettingAlwaysUseHTTPSEditResponseEditableTrue ZoneSettingAlwaysUseHTTPSEditResponseEditable = true - ZoneSettingAlwaysUseHTTPSEditResponseEditableFalse ZoneSettingAlwaysUseHTTPSEditResponseEditable = false -) - -// Reply to all requests for URLs that use "http" with a 301 redirect to the -// equivalent "https" URL. If you only want to redirect for a subset of requests, -// consider creating an "Always use HTTPS" page rule. -type ZoneSettingAlwaysUseHTTPSGetResponse struct { - // ID of the zone setting. - ID ZoneSettingAlwaysUseHTTPSGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingAlwaysUseHTTPSGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingAlwaysUseHTTPSGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingAlwaysUseHTTPSGetResponseJSON `json:"-"` -} - -// zoneSettingAlwaysUseHTTPSGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingAlwaysUseHTTPSGetResponse] -type zoneSettingAlwaysUseHTTPSGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAlwaysUseHTTPSGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAlwaysUseHTTPSGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingAlwaysUseHTTPSGetResponseID string - -const ( - ZoneSettingAlwaysUseHTTPSGetResponseIDAlwaysUseHTTPS ZoneSettingAlwaysUseHTTPSGetResponseID = "always_use_https" -) - -// Current value of the zone setting. -type ZoneSettingAlwaysUseHTTPSGetResponseValue string - -const ( - ZoneSettingAlwaysUseHTTPSGetResponseValueOn ZoneSettingAlwaysUseHTTPSGetResponseValue = "on" - ZoneSettingAlwaysUseHTTPSGetResponseValueOff ZoneSettingAlwaysUseHTTPSGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingAlwaysUseHTTPSGetResponseEditable bool - -const ( - ZoneSettingAlwaysUseHTTPSGetResponseEditableTrue ZoneSettingAlwaysUseHTTPSGetResponseEditable = true - ZoneSettingAlwaysUseHTTPSGetResponseEditableFalse ZoneSettingAlwaysUseHTTPSGetResponseEditable = false -) - -type ZoneSettingAlwaysUseHTTPSEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingAlwaysUseHTTPSEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingAlwaysUseHTTPSEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingAlwaysUseHTTPSEditParamsValue string - -const ( - ZoneSettingAlwaysUseHTTPSEditParamsValueOn ZoneSettingAlwaysUseHTTPSEditParamsValue = "on" - ZoneSettingAlwaysUseHTTPSEditParamsValueOff ZoneSettingAlwaysUseHTTPSEditParamsValue = "off" -) - -type ZoneSettingAlwaysUseHTTPSEditResponseEnvelope struct { - Errors []ZoneSettingAlwaysUseHTTPSEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingAlwaysUseHTTPSEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Reply to all requests for URLs that use "http" with a 301 redirect to the - // equivalent "https" URL. If you only want to redirect for a subset of requests, - // consider creating an "Always use HTTPS" page rule. - Result ZoneSettingAlwaysUseHTTPSEditResponse `json:"result"` - JSON zoneSettingAlwaysUseHTTPSEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingAlwaysUseHTTPSEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingAlwaysUseHTTPSEditResponseEnvelope] -type zoneSettingAlwaysUseHTTPSEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAlwaysUseHTTPSEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAlwaysUseHTTPSEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAlwaysUseHTTPSEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAlwaysUseHTTPSEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingAlwaysUseHTTPSEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingAlwaysUseHTTPSEditResponseEnvelopeErrors] -type zoneSettingAlwaysUseHTTPSEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAlwaysUseHTTPSEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAlwaysUseHTTPSEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAlwaysUseHTTPSEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAlwaysUseHTTPSEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingAlwaysUseHTTPSEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingAlwaysUseHTTPSEditResponseEnvelopeMessages] -type zoneSettingAlwaysUseHTTPSEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAlwaysUseHTTPSEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAlwaysUseHTTPSEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAlwaysUseHTTPSGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingAlwaysUseHTTPSGetResponseEnvelope struct { - Errors []ZoneSettingAlwaysUseHTTPSGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingAlwaysUseHTTPSGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Reply to all requests for URLs that use "http" with a 301 redirect to the - // equivalent "https" URL. If you only want to redirect for a subset of requests, - // consider creating an "Always use HTTPS" page rule. - Result ZoneSettingAlwaysUseHTTPSGetResponse `json:"result"` - JSON zoneSettingAlwaysUseHTTPSGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingAlwaysUseHTTPSGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingAlwaysUseHTTPSGetResponseEnvelope] -type zoneSettingAlwaysUseHTTPSGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAlwaysUseHTTPSGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAlwaysUseHTTPSGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAlwaysUseHTTPSGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAlwaysUseHTTPSGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingAlwaysUseHTTPSGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingAlwaysUseHTTPSGetResponseEnvelopeErrors] -type zoneSettingAlwaysUseHTTPSGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAlwaysUseHTTPSGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAlwaysUseHTTPSGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAlwaysUseHTTPSGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAlwaysUseHTTPSGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingAlwaysUseHTTPSGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingAlwaysUseHTTPSGetResponseEnvelopeMessages] -type zoneSettingAlwaysUseHTTPSGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAlwaysUseHTTPSGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAlwaysUseHTTPSGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingalwaysusehttps_test.go b/zonesettingalwaysusehttps_test.go deleted file mode 100644 index c34e80cdc03..00000000000 --- a/zonesettingalwaysusehttps_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingAlwaysUseHTTPSEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.AlwaysUseHTTPS.Edit(context.TODO(), cloudflare.ZoneSettingAlwaysUseHTTPSEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingAlwaysUseHTTPSEditParamsValueOn), - }) - 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 TestZoneSettingAlwaysUseHTTPSGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.AlwaysUseHTTPS.Get(context.TODO(), cloudflare.ZoneSettingAlwaysUseHTTPSGetParams{ - ZoneID: cloudflare.F("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/zonesettingautomatichttpsrewrite.go b/zonesettingautomatichttpsrewrite.go deleted file mode 100644 index d2b1822668d..00000000000 --- a/zonesettingautomatichttpsrewrite.go +++ /dev/null @@ -1,353 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingAutomaticHTTPSRewriteService 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 -// [NewZoneSettingAutomaticHTTPSRewriteService] method instead. -type ZoneSettingAutomaticHTTPSRewriteService struct { - Options []option.RequestOption -} - -// NewZoneSettingAutomaticHTTPSRewriteService 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 NewZoneSettingAutomaticHTTPSRewriteService(opts ...option.RequestOption) (r *ZoneSettingAutomaticHTTPSRewriteService) { - r = &ZoneSettingAutomaticHTTPSRewriteService{} - r.Options = opts - return -} - -// Enable the Automatic HTTPS Rewrites feature for this zone. -func (r *ZoneSettingAutomaticHTTPSRewriteService) Edit(ctx context.Context, params ZoneSettingAutomaticHTTPSRewriteEditParams, opts ...option.RequestOption) (res *ZoneSettingAutomaticHTTPSRewriteEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingAutomaticHTTPSRewriteEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/automatic_https_rewrites", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Enable the Automatic HTTPS Rewrites feature for this zone. -func (r *ZoneSettingAutomaticHTTPSRewriteService) Get(ctx context.Context, query ZoneSettingAutomaticHTTPSRewriteGetParams, opts ...option.RequestOption) (res *ZoneSettingAutomaticHTTPSRewriteGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingAutomaticHTTPSRewriteGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/automatic_https_rewrites", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Enable the Automatic HTTPS Rewrites feature for this zone. -type ZoneSettingAutomaticHTTPSRewriteEditResponse struct { - // ID of the zone setting. - ID ZoneSettingAutomaticHTTPSRewriteEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingAutomaticHTTPSRewriteEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingAutomaticHTTPSRewriteEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingAutomaticHTTPSRewriteEditResponseJSON `json:"-"` -} - -// zoneSettingAutomaticHTTPSRewriteEditResponseJSON contains the JSON metadata for -// the struct [ZoneSettingAutomaticHTTPSRewriteEditResponse] -type zoneSettingAutomaticHTTPSRewriteEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAutomaticHTTPSRewriteEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAutomaticHTTPSRewriteEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingAutomaticHTTPSRewriteEditResponseID string - -const ( - ZoneSettingAutomaticHTTPSRewriteEditResponseIDAutomaticHTTPSRewrites ZoneSettingAutomaticHTTPSRewriteEditResponseID = "automatic_https_rewrites" -) - -// Current value of the zone setting. -type ZoneSettingAutomaticHTTPSRewriteEditResponseValue string - -const ( - ZoneSettingAutomaticHTTPSRewriteEditResponseValueOn ZoneSettingAutomaticHTTPSRewriteEditResponseValue = "on" - ZoneSettingAutomaticHTTPSRewriteEditResponseValueOff ZoneSettingAutomaticHTTPSRewriteEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingAutomaticHTTPSRewriteEditResponseEditable bool - -const ( - ZoneSettingAutomaticHTTPSRewriteEditResponseEditableTrue ZoneSettingAutomaticHTTPSRewriteEditResponseEditable = true - ZoneSettingAutomaticHTTPSRewriteEditResponseEditableFalse ZoneSettingAutomaticHTTPSRewriteEditResponseEditable = false -) - -// Enable the Automatic HTTPS Rewrites feature for this zone. -type ZoneSettingAutomaticHTTPSRewriteGetResponse struct { - // ID of the zone setting. - ID ZoneSettingAutomaticHTTPSRewriteGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingAutomaticHTTPSRewriteGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingAutomaticHTTPSRewriteGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingAutomaticHTTPSRewriteGetResponseJSON `json:"-"` -} - -// zoneSettingAutomaticHTTPSRewriteGetResponseJSON contains the JSON metadata for -// the struct [ZoneSettingAutomaticHTTPSRewriteGetResponse] -type zoneSettingAutomaticHTTPSRewriteGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAutomaticHTTPSRewriteGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAutomaticHTTPSRewriteGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingAutomaticHTTPSRewriteGetResponseID string - -const ( - ZoneSettingAutomaticHTTPSRewriteGetResponseIDAutomaticHTTPSRewrites ZoneSettingAutomaticHTTPSRewriteGetResponseID = "automatic_https_rewrites" -) - -// Current value of the zone setting. -type ZoneSettingAutomaticHTTPSRewriteGetResponseValue string - -const ( - ZoneSettingAutomaticHTTPSRewriteGetResponseValueOn ZoneSettingAutomaticHTTPSRewriteGetResponseValue = "on" - ZoneSettingAutomaticHTTPSRewriteGetResponseValueOff ZoneSettingAutomaticHTTPSRewriteGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingAutomaticHTTPSRewriteGetResponseEditable bool - -const ( - ZoneSettingAutomaticHTTPSRewriteGetResponseEditableTrue ZoneSettingAutomaticHTTPSRewriteGetResponseEditable = true - ZoneSettingAutomaticHTTPSRewriteGetResponseEditableFalse ZoneSettingAutomaticHTTPSRewriteGetResponseEditable = false -) - -type ZoneSettingAutomaticHTTPSRewriteEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. Notes: Default value depends on the zone's plan - // level. - Value param.Field[ZoneSettingAutomaticHTTPSRewriteEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingAutomaticHTTPSRewriteEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. Notes: Default value depends on the zone's plan -// level. -type ZoneSettingAutomaticHTTPSRewriteEditParamsValue string - -const ( - ZoneSettingAutomaticHTTPSRewriteEditParamsValueOn ZoneSettingAutomaticHTTPSRewriteEditParamsValue = "on" - ZoneSettingAutomaticHTTPSRewriteEditParamsValueOff ZoneSettingAutomaticHTTPSRewriteEditParamsValue = "off" -) - -type ZoneSettingAutomaticHTTPSRewriteEditResponseEnvelope struct { - Errors []ZoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Enable the Automatic HTTPS Rewrites feature for this zone. - Result ZoneSettingAutomaticHTTPSRewriteEditResponse `json:"result"` - JSON zoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZoneSettingAutomaticHTTPSRewriteEditResponseEnvelope] -type zoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAutomaticHTTPSRewriteEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeErrors] -type zoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeMessages] -type zoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAutomaticHTTPSRewriteEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAutomaticHTTPSRewriteGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingAutomaticHTTPSRewriteGetResponseEnvelope struct { - Errors []ZoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Enable the Automatic HTTPS Rewrites feature for this zone. - Result ZoneSettingAutomaticHTTPSRewriteGetResponse `json:"result"` - JSON zoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZoneSettingAutomaticHTTPSRewriteGetResponseEnvelope] -type zoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAutomaticHTTPSRewriteGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeErrors] -type zoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeMessages] -type zoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAutomaticHTTPSRewriteGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingautomatichttpsrewrite_test.go b/zonesettingautomatichttpsrewrite_test.go deleted file mode 100644 index 4d9ff7d4555..00000000000 --- a/zonesettingautomatichttpsrewrite_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingAutomaticHTTPSRewriteEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.AutomaticHTTPSRewrites.Edit(context.TODO(), cloudflare.ZoneSettingAutomaticHTTPSRewriteEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingAutomaticHTTPSRewriteEditParamsValueOn), - }) - 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 TestZoneSettingAutomaticHTTPSRewriteGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.AutomaticHTTPSRewrites.Get(context.TODO(), cloudflare.ZoneSettingAutomaticHTTPSRewriteGetParams{ - ZoneID: cloudflare.F("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/zonesettingautomaticplatformoptimization.go b/zonesettingautomaticplatformoptimization.go deleted file mode 100644 index 58dce1ee2c3..00000000000 --- a/zonesettingautomaticplatformoptimization.go +++ /dev/null @@ -1,340 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingAutomaticPlatformOptimizationService 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 [NewZoneSettingAutomaticPlatformOptimizationService] method instead. -type ZoneSettingAutomaticPlatformOptimizationService struct { - Options []option.RequestOption -} - -// NewZoneSettingAutomaticPlatformOptimizationService 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 NewZoneSettingAutomaticPlatformOptimizationService(opts ...option.RequestOption) (r *ZoneSettingAutomaticPlatformOptimizationService) { - r = &ZoneSettingAutomaticPlatformOptimizationService{} - r.Options = opts - return -} - -// [Automatic Platform Optimization for WordPress](https://developers.cloudflare.com/automatic-platform-optimization/) -// serves your WordPress site from Cloudflare's edge network and caches third-party -// fonts. -func (r *ZoneSettingAutomaticPlatformOptimizationService) Edit(ctx context.Context, params ZoneSettingAutomaticPlatformOptimizationEditParams, opts ...option.RequestOption) (res *ZoneSettingAutomaticPlatformOptimizationEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingAutomaticPlatformOptimizationEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/automatic_platform_optimization", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// [Automatic Platform Optimization for WordPress](https://developers.cloudflare.com/automatic-platform-optimization/) -// serves your WordPress site from Cloudflare's edge network and caches third-party -// fonts. -func (r *ZoneSettingAutomaticPlatformOptimizationService) Get(ctx context.Context, query ZoneSettingAutomaticPlatformOptimizationGetParams, opts ...option.RequestOption) (res *ZoneSettingAutomaticPlatformOptimizationGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingAutomaticPlatformOptimizationGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/automatic_platform_optimization", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type ZoneSettingAutomaticPlatformOptimizationEditResponse struct { - // Indicates whether or not - // [cache by device type](https://developers.cloudflare.com/automatic-platform-optimization/reference/cache-device-type/) - // is enabled. - CacheByDeviceType bool `json:"cache_by_device_type,required"` - // Indicates whether or not Cloudflare proxy is enabled. - Cf bool `json:"cf,required"` - // Indicates whether or not Automatic Platform Optimization is enabled. - Enabled bool `json:"enabled,required"` - // An array of hostnames where Automatic Platform Optimization for WordPress is - // activated. - Hostnames []string `json:"hostnames,required" format:"hostname"` - // Indicates whether or not site is powered by WordPress. - Wordpress bool `json:"wordpress,required"` - // Indicates whether or not - // [Cloudflare for WordPress plugin](https://wordpress.org/plugins/cloudflare/) is - // installed. - WpPlugin bool `json:"wp_plugin,required"` - JSON zoneSettingAutomaticPlatformOptimizationEditResponseJSON `json:"-"` -} - -// zoneSettingAutomaticPlatformOptimizationEditResponseJSON contains the JSON -// metadata for the struct [ZoneSettingAutomaticPlatformOptimizationEditResponse] -type zoneSettingAutomaticPlatformOptimizationEditResponseJSON struct { - CacheByDeviceType apijson.Field - Cf apijson.Field - Enabled apijson.Field - Hostnames apijson.Field - Wordpress apijson.Field - WpPlugin apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAutomaticPlatformOptimizationEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAutomaticPlatformOptimizationEditResponseJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAutomaticPlatformOptimizationGetResponse struct { - // Indicates whether or not - // [cache by device type](https://developers.cloudflare.com/automatic-platform-optimization/reference/cache-device-type/) - // is enabled. - CacheByDeviceType bool `json:"cache_by_device_type,required"` - // Indicates whether or not Cloudflare proxy is enabled. - Cf bool `json:"cf,required"` - // Indicates whether or not Automatic Platform Optimization is enabled. - Enabled bool `json:"enabled,required"` - // An array of hostnames where Automatic Platform Optimization for WordPress is - // activated. - Hostnames []string `json:"hostnames,required" format:"hostname"` - // Indicates whether or not site is powered by WordPress. - Wordpress bool `json:"wordpress,required"` - // Indicates whether or not - // [Cloudflare for WordPress plugin](https://wordpress.org/plugins/cloudflare/) is - // installed. - WpPlugin bool `json:"wp_plugin,required"` - JSON zoneSettingAutomaticPlatformOptimizationGetResponseJSON `json:"-"` -} - -// zoneSettingAutomaticPlatformOptimizationGetResponseJSON contains the JSON -// metadata for the struct [ZoneSettingAutomaticPlatformOptimizationGetResponse] -type zoneSettingAutomaticPlatformOptimizationGetResponseJSON struct { - CacheByDeviceType apijson.Field - Cf apijson.Field - Enabled apijson.Field - Hostnames apijson.Field - Wordpress apijson.Field - WpPlugin apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAutomaticPlatformOptimizationGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAutomaticPlatformOptimizationGetResponseJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAutomaticPlatformOptimizationEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Value param.Field[ZoneSettingAutomaticPlatformOptimizationEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingAutomaticPlatformOptimizationEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZoneSettingAutomaticPlatformOptimizationEditParamsValue struct { - // Indicates whether or not - // [cache by device type](https://developers.cloudflare.com/automatic-platform-optimization/reference/cache-device-type/) - // is enabled. - CacheByDeviceType param.Field[bool] `json:"cache_by_device_type,required"` - // Indicates whether or not Cloudflare proxy is enabled. - Cf param.Field[bool] `json:"cf,required"` - // Indicates whether or not Automatic Platform Optimization is enabled. - Enabled param.Field[bool] `json:"enabled,required"` - // An array of hostnames where Automatic Platform Optimization for WordPress is - // activated. - Hostnames param.Field[[]string] `json:"hostnames,required" format:"hostname"` - // Indicates whether or not site is powered by WordPress. - Wordpress param.Field[bool] `json:"wordpress,required"` - // Indicates whether or not - // [Cloudflare for WordPress plugin](https://wordpress.org/plugins/cloudflare/) is - // installed. - WpPlugin param.Field[bool] `json:"wp_plugin,required"` -} - -func (r ZoneSettingAutomaticPlatformOptimizationEditParamsValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZoneSettingAutomaticPlatformOptimizationEditResponseEnvelope struct { - Errors []ZoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - Result ZoneSettingAutomaticPlatformOptimizationEditResponse `json:"result"` - JSON zoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeJSON contains the -// JSON metadata for the struct -// [ZoneSettingAutomaticPlatformOptimizationEditResponseEnvelope] -type zoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAutomaticPlatformOptimizationEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeErrorsJSON contains -// the JSON metadata for the struct -// [ZoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeErrors] -type zoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeMessagesJSON -// contains the JSON metadata for the struct -// [ZoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeMessages] -type zoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAutomaticPlatformOptimizationEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAutomaticPlatformOptimizationGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingAutomaticPlatformOptimizationGetResponseEnvelope struct { - Errors []ZoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - Result ZoneSettingAutomaticPlatformOptimizationGetResponse `json:"result"` - JSON zoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeJSON contains the -// JSON metadata for the struct -// [ZoneSettingAutomaticPlatformOptimizationGetResponseEnvelope] -type zoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAutomaticPlatformOptimizationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeErrorsJSON contains -// the JSON metadata for the struct -// [ZoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeErrors] -type zoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeMessagesJSON contains -// the JSON metadata for the struct -// [ZoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeMessages] -type zoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingAutomaticPlatformOptimizationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingautomaticplatformoptimization_test.go b/zonesettingautomaticplatformoptimization_test.go deleted file mode 100644 index d370a07d692..00000000000 --- a/zonesettingautomaticplatformoptimization_test.go +++ /dev/null @@ -1,74 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingAutomaticPlatformOptimizationEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.AutomaticPlatformOptimization.Edit(context.TODO(), cloudflare.ZoneSettingAutomaticPlatformOptimizationEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingAutomaticPlatformOptimizationEditParamsValue{ - CacheByDeviceType: cloudflare.F(false), - Cf: cloudflare.F(true), - Enabled: cloudflare.F(true), - Hostnames: cloudflare.F([]string{"www.example.com", "example.com", "shop.example.com"}), - Wordpress: cloudflare.F(true), - WpPlugin: cloudflare.F(true), - }), - }) - 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 TestZoneSettingAutomaticPlatformOptimizationGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.AutomaticPlatformOptimization.Get(context.TODO(), cloudflare.ZoneSettingAutomaticPlatformOptimizationGetParams{ - ZoneID: cloudflare.F("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/zonesettingbrotli.go b/zonesettingbrotli.go deleted file mode 100644 index 8cc7162af6e..00000000000 --- a/zonesettingbrotli.go +++ /dev/null @@ -1,353 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingBrotliService 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 [NewZoneSettingBrotliService] method -// instead. -type ZoneSettingBrotliService struct { - Options []option.RequestOption -} - -// NewZoneSettingBrotliService 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 NewZoneSettingBrotliService(opts ...option.RequestOption) (r *ZoneSettingBrotliService) { - r = &ZoneSettingBrotliService{} - r.Options = opts - return -} - -// When the client requesting an asset supports the Brotli compression algorithm, -// Cloudflare will serve a Brotli compressed version of the asset. -func (r *ZoneSettingBrotliService) Edit(ctx context.Context, params ZoneSettingBrotliEditParams, opts ...option.RequestOption) (res *ZoneSettingBrotliEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingBrotliEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/brotli", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// When the client requesting an asset supports the Brotli compression algorithm, -// Cloudflare will serve a Brotli compressed version of the asset. -func (r *ZoneSettingBrotliService) Get(ctx context.Context, query ZoneSettingBrotliGetParams, opts ...option.RequestOption) (res *ZoneSettingBrotliGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingBrotliGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/brotli", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// When the client requesting an asset supports the Brotli compression algorithm, -// Cloudflare will serve a Brotli compressed version of the asset. -type ZoneSettingBrotliEditResponse struct { - // ID of the zone setting. - ID ZoneSettingBrotliEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingBrotliEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingBrotliEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingBrotliEditResponseJSON `json:"-"` -} - -// zoneSettingBrotliEditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingBrotliEditResponse] -type zoneSettingBrotliEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrotliEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrotliEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingBrotliEditResponseID string - -const ( - ZoneSettingBrotliEditResponseIDBrotli ZoneSettingBrotliEditResponseID = "brotli" -) - -// Current value of the zone setting. -type ZoneSettingBrotliEditResponseValue string - -const ( - ZoneSettingBrotliEditResponseValueOff ZoneSettingBrotliEditResponseValue = "off" - ZoneSettingBrotliEditResponseValueOn ZoneSettingBrotliEditResponseValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingBrotliEditResponseEditable bool - -const ( - ZoneSettingBrotliEditResponseEditableTrue ZoneSettingBrotliEditResponseEditable = true - ZoneSettingBrotliEditResponseEditableFalse ZoneSettingBrotliEditResponseEditable = false -) - -// When the client requesting an asset supports the Brotli compression algorithm, -// Cloudflare will serve a Brotli compressed version of the asset. -type ZoneSettingBrotliGetResponse struct { - // ID of the zone setting. - ID ZoneSettingBrotliGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingBrotliGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingBrotliGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingBrotliGetResponseJSON `json:"-"` -} - -// zoneSettingBrotliGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingBrotliGetResponse] -type zoneSettingBrotliGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrotliGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrotliGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingBrotliGetResponseID string - -const ( - ZoneSettingBrotliGetResponseIDBrotli ZoneSettingBrotliGetResponseID = "brotli" -) - -// Current value of the zone setting. -type ZoneSettingBrotliGetResponseValue string - -const ( - ZoneSettingBrotliGetResponseValueOff ZoneSettingBrotliGetResponseValue = "off" - ZoneSettingBrotliGetResponseValueOn ZoneSettingBrotliGetResponseValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingBrotliGetResponseEditable bool - -const ( - ZoneSettingBrotliGetResponseEditableTrue ZoneSettingBrotliGetResponseEditable = true - ZoneSettingBrotliGetResponseEditableFalse ZoneSettingBrotliGetResponseEditable = false -) - -type ZoneSettingBrotliEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingBrotliEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingBrotliEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingBrotliEditParamsValue string - -const ( - ZoneSettingBrotliEditParamsValueOff ZoneSettingBrotliEditParamsValue = "off" - ZoneSettingBrotliEditParamsValueOn ZoneSettingBrotliEditParamsValue = "on" -) - -type ZoneSettingBrotliEditResponseEnvelope struct { - Errors []ZoneSettingBrotliEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingBrotliEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // When the client requesting an asset supports the Brotli compression algorithm, - // Cloudflare will serve a Brotli compressed version of the asset. - Result ZoneSettingBrotliEditResponse `json:"result"` - JSON zoneSettingBrotliEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingBrotliEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingBrotliEditResponseEnvelope] -type zoneSettingBrotliEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrotliEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrotliEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingBrotliEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingBrotliEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingBrotliEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSettingBrotliEditResponseEnvelopeErrors] -type zoneSettingBrotliEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrotliEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrotliEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingBrotliEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingBrotliEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingBrotliEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingBrotliEditResponseEnvelopeMessages] -type zoneSettingBrotliEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrotliEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrotliEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingBrotliGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingBrotliGetResponseEnvelope struct { - Errors []ZoneSettingBrotliGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingBrotliGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // When the client requesting an asset supports the Brotli compression algorithm, - // Cloudflare will serve a Brotli compressed version of the asset. - Result ZoneSettingBrotliGetResponse `json:"result"` - JSON zoneSettingBrotliGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingBrotliGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingBrotliGetResponseEnvelope] -type zoneSettingBrotliGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrotliGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrotliGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingBrotliGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingBrotliGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingBrotliGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSettingBrotliGetResponseEnvelopeErrors] -type zoneSettingBrotliGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrotliGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrotliGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingBrotliGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingBrotliGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingBrotliGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingBrotliGetResponseEnvelopeMessages] -type zoneSettingBrotliGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrotliGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrotliGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingbrotli_test.go b/zonesettingbrotli_test.go deleted file mode 100644 index b01f70fa7b3..00000000000 --- a/zonesettingbrotli_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingBrotliEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.Brotli.Edit(context.TODO(), cloudflare.ZoneSettingBrotliEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingBrotliEditParamsValueOff), - }) - 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 TestZoneSettingBrotliGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.Brotli.Get(context.TODO(), cloudflare.ZoneSettingBrotliGetParams{ - ZoneID: cloudflare.F("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/zonesettingbrowsercachettl.go b/zonesettingbrowsercachettl.go deleted file mode 100644 index c88da219404..00000000000 --- a/zonesettingbrowsercachettl.go +++ /dev/null @@ -1,445 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingBrowserCacheTTLService 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 -// [NewZoneSettingBrowserCacheTTLService] method instead. -type ZoneSettingBrowserCacheTTLService struct { - Options []option.RequestOption -} - -// NewZoneSettingBrowserCacheTTLService 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 NewZoneSettingBrowserCacheTTLService(opts ...option.RequestOption) (r *ZoneSettingBrowserCacheTTLService) { - r = &ZoneSettingBrowserCacheTTLService{} - r.Options = opts - return -} - -// Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources -// will remain on your visitors' computers. Cloudflare will honor any larger times -// specified by your server. -// (https://support.cloudflare.com/hc/en-us/articles/200168276). -func (r *ZoneSettingBrowserCacheTTLService) Edit(ctx context.Context, params ZoneSettingBrowserCacheTTLEditParams, opts ...option.RequestOption) (res *ZoneSettingBrowserCacheTTLEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingBrowserCacheTTLEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/browser_cache_ttl", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources -// will remain on your visitors' computers. Cloudflare will honor any larger times -// specified by your server. -// (https://support.cloudflare.com/hc/en-us/articles/200168276). -func (r *ZoneSettingBrowserCacheTTLService) Get(ctx context.Context, query ZoneSettingBrowserCacheTTLGetParams, opts ...option.RequestOption) (res *ZoneSettingBrowserCacheTTLGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingBrowserCacheTTLGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/browser_cache_ttl", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources -// will remain on your visitors' computers. Cloudflare will honor any larger times -// specified by your server. -// (https://support.cloudflare.com/hc/en-us/articles/200168276). -type ZoneSettingBrowserCacheTTLEditResponse struct { - // ID of the zone setting. - ID ZoneSettingBrowserCacheTTLEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingBrowserCacheTTLEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingBrowserCacheTTLEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingBrowserCacheTTLEditResponseJSON `json:"-"` -} - -// zoneSettingBrowserCacheTTLEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingBrowserCacheTTLEditResponse] -type zoneSettingBrowserCacheTTLEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrowserCacheTTLEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrowserCacheTTLEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingBrowserCacheTTLEditResponseID string - -const ( - ZoneSettingBrowserCacheTTLEditResponseIDBrowserCacheTTL ZoneSettingBrowserCacheTTLEditResponseID = "browser_cache_ttl" -) - -// Current value of the zone setting. -type ZoneSettingBrowserCacheTTLEditResponseValue float64 - -const ( - ZoneSettingBrowserCacheTTLEditResponseValue0 ZoneSettingBrowserCacheTTLEditResponseValue = 0 - ZoneSettingBrowserCacheTTLEditResponseValue30 ZoneSettingBrowserCacheTTLEditResponseValue = 30 - ZoneSettingBrowserCacheTTLEditResponseValue60 ZoneSettingBrowserCacheTTLEditResponseValue = 60 - ZoneSettingBrowserCacheTTLEditResponseValue120 ZoneSettingBrowserCacheTTLEditResponseValue = 120 - ZoneSettingBrowserCacheTTLEditResponseValue300 ZoneSettingBrowserCacheTTLEditResponseValue = 300 - ZoneSettingBrowserCacheTTLEditResponseValue1200 ZoneSettingBrowserCacheTTLEditResponseValue = 1200 - ZoneSettingBrowserCacheTTLEditResponseValue1800 ZoneSettingBrowserCacheTTLEditResponseValue = 1800 - ZoneSettingBrowserCacheTTLEditResponseValue3600 ZoneSettingBrowserCacheTTLEditResponseValue = 3600 - ZoneSettingBrowserCacheTTLEditResponseValue7200 ZoneSettingBrowserCacheTTLEditResponseValue = 7200 - ZoneSettingBrowserCacheTTLEditResponseValue10800 ZoneSettingBrowserCacheTTLEditResponseValue = 10800 - ZoneSettingBrowserCacheTTLEditResponseValue14400 ZoneSettingBrowserCacheTTLEditResponseValue = 14400 - ZoneSettingBrowserCacheTTLEditResponseValue18000 ZoneSettingBrowserCacheTTLEditResponseValue = 18000 - ZoneSettingBrowserCacheTTLEditResponseValue28800 ZoneSettingBrowserCacheTTLEditResponseValue = 28800 - ZoneSettingBrowserCacheTTLEditResponseValue43200 ZoneSettingBrowserCacheTTLEditResponseValue = 43200 - ZoneSettingBrowserCacheTTLEditResponseValue57600 ZoneSettingBrowserCacheTTLEditResponseValue = 57600 - ZoneSettingBrowserCacheTTLEditResponseValue72000 ZoneSettingBrowserCacheTTLEditResponseValue = 72000 - ZoneSettingBrowserCacheTTLEditResponseValue86400 ZoneSettingBrowserCacheTTLEditResponseValue = 86400 - ZoneSettingBrowserCacheTTLEditResponseValue172800 ZoneSettingBrowserCacheTTLEditResponseValue = 172800 - ZoneSettingBrowserCacheTTLEditResponseValue259200 ZoneSettingBrowserCacheTTLEditResponseValue = 259200 - ZoneSettingBrowserCacheTTLEditResponseValue345600 ZoneSettingBrowserCacheTTLEditResponseValue = 345600 - ZoneSettingBrowserCacheTTLEditResponseValue432000 ZoneSettingBrowserCacheTTLEditResponseValue = 432000 - ZoneSettingBrowserCacheTTLEditResponseValue691200 ZoneSettingBrowserCacheTTLEditResponseValue = 691200 - ZoneSettingBrowserCacheTTLEditResponseValue1382400 ZoneSettingBrowserCacheTTLEditResponseValue = 1382400 - ZoneSettingBrowserCacheTTLEditResponseValue2073600 ZoneSettingBrowserCacheTTLEditResponseValue = 2073600 - ZoneSettingBrowserCacheTTLEditResponseValue2678400 ZoneSettingBrowserCacheTTLEditResponseValue = 2678400 - ZoneSettingBrowserCacheTTLEditResponseValue5356800 ZoneSettingBrowserCacheTTLEditResponseValue = 5356800 - ZoneSettingBrowserCacheTTLEditResponseValue16070400 ZoneSettingBrowserCacheTTLEditResponseValue = 16070400 - ZoneSettingBrowserCacheTTLEditResponseValue31536000 ZoneSettingBrowserCacheTTLEditResponseValue = 31536000 -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingBrowserCacheTTLEditResponseEditable bool - -const ( - ZoneSettingBrowserCacheTTLEditResponseEditableTrue ZoneSettingBrowserCacheTTLEditResponseEditable = true - ZoneSettingBrowserCacheTTLEditResponseEditableFalse ZoneSettingBrowserCacheTTLEditResponseEditable = false -) - -// Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources -// will remain on your visitors' computers. Cloudflare will honor any larger times -// specified by your server. -// (https://support.cloudflare.com/hc/en-us/articles/200168276). -type ZoneSettingBrowserCacheTTLGetResponse struct { - // ID of the zone setting. - ID ZoneSettingBrowserCacheTTLGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingBrowserCacheTTLGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingBrowserCacheTTLGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingBrowserCacheTTLGetResponseJSON `json:"-"` -} - -// zoneSettingBrowserCacheTTLGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingBrowserCacheTTLGetResponse] -type zoneSettingBrowserCacheTTLGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrowserCacheTTLGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrowserCacheTTLGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingBrowserCacheTTLGetResponseID string - -const ( - ZoneSettingBrowserCacheTTLGetResponseIDBrowserCacheTTL ZoneSettingBrowserCacheTTLGetResponseID = "browser_cache_ttl" -) - -// Current value of the zone setting. -type ZoneSettingBrowserCacheTTLGetResponseValue float64 - -const ( - ZoneSettingBrowserCacheTTLGetResponseValue0 ZoneSettingBrowserCacheTTLGetResponseValue = 0 - ZoneSettingBrowserCacheTTLGetResponseValue30 ZoneSettingBrowserCacheTTLGetResponseValue = 30 - ZoneSettingBrowserCacheTTLGetResponseValue60 ZoneSettingBrowserCacheTTLGetResponseValue = 60 - ZoneSettingBrowserCacheTTLGetResponseValue120 ZoneSettingBrowserCacheTTLGetResponseValue = 120 - ZoneSettingBrowserCacheTTLGetResponseValue300 ZoneSettingBrowserCacheTTLGetResponseValue = 300 - ZoneSettingBrowserCacheTTLGetResponseValue1200 ZoneSettingBrowserCacheTTLGetResponseValue = 1200 - ZoneSettingBrowserCacheTTLGetResponseValue1800 ZoneSettingBrowserCacheTTLGetResponseValue = 1800 - ZoneSettingBrowserCacheTTLGetResponseValue3600 ZoneSettingBrowserCacheTTLGetResponseValue = 3600 - ZoneSettingBrowserCacheTTLGetResponseValue7200 ZoneSettingBrowserCacheTTLGetResponseValue = 7200 - ZoneSettingBrowserCacheTTLGetResponseValue10800 ZoneSettingBrowserCacheTTLGetResponseValue = 10800 - ZoneSettingBrowserCacheTTLGetResponseValue14400 ZoneSettingBrowserCacheTTLGetResponseValue = 14400 - ZoneSettingBrowserCacheTTLGetResponseValue18000 ZoneSettingBrowserCacheTTLGetResponseValue = 18000 - ZoneSettingBrowserCacheTTLGetResponseValue28800 ZoneSettingBrowserCacheTTLGetResponseValue = 28800 - ZoneSettingBrowserCacheTTLGetResponseValue43200 ZoneSettingBrowserCacheTTLGetResponseValue = 43200 - ZoneSettingBrowserCacheTTLGetResponseValue57600 ZoneSettingBrowserCacheTTLGetResponseValue = 57600 - ZoneSettingBrowserCacheTTLGetResponseValue72000 ZoneSettingBrowserCacheTTLGetResponseValue = 72000 - ZoneSettingBrowserCacheTTLGetResponseValue86400 ZoneSettingBrowserCacheTTLGetResponseValue = 86400 - ZoneSettingBrowserCacheTTLGetResponseValue172800 ZoneSettingBrowserCacheTTLGetResponseValue = 172800 - ZoneSettingBrowserCacheTTLGetResponseValue259200 ZoneSettingBrowserCacheTTLGetResponseValue = 259200 - ZoneSettingBrowserCacheTTLGetResponseValue345600 ZoneSettingBrowserCacheTTLGetResponseValue = 345600 - ZoneSettingBrowserCacheTTLGetResponseValue432000 ZoneSettingBrowserCacheTTLGetResponseValue = 432000 - ZoneSettingBrowserCacheTTLGetResponseValue691200 ZoneSettingBrowserCacheTTLGetResponseValue = 691200 - ZoneSettingBrowserCacheTTLGetResponseValue1382400 ZoneSettingBrowserCacheTTLGetResponseValue = 1382400 - ZoneSettingBrowserCacheTTLGetResponseValue2073600 ZoneSettingBrowserCacheTTLGetResponseValue = 2073600 - ZoneSettingBrowserCacheTTLGetResponseValue2678400 ZoneSettingBrowserCacheTTLGetResponseValue = 2678400 - ZoneSettingBrowserCacheTTLGetResponseValue5356800 ZoneSettingBrowserCacheTTLGetResponseValue = 5356800 - ZoneSettingBrowserCacheTTLGetResponseValue16070400 ZoneSettingBrowserCacheTTLGetResponseValue = 16070400 - ZoneSettingBrowserCacheTTLGetResponseValue31536000 ZoneSettingBrowserCacheTTLGetResponseValue = 31536000 -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingBrowserCacheTTLGetResponseEditable bool - -const ( - ZoneSettingBrowserCacheTTLGetResponseEditableTrue ZoneSettingBrowserCacheTTLGetResponseEditable = true - ZoneSettingBrowserCacheTTLGetResponseEditableFalse ZoneSettingBrowserCacheTTLGetResponseEditable = false -) - -type ZoneSettingBrowserCacheTTLEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. Notes: Setting a TTL of 0 is equivalent to selecting - // `Respect Existing Headers` - Value param.Field[ZoneSettingBrowserCacheTTLEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingBrowserCacheTTLEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. Notes: Setting a TTL of 0 is equivalent to selecting -// `Respect Existing Headers` -type ZoneSettingBrowserCacheTTLEditParamsValue float64 - -const ( - ZoneSettingBrowserCacheTTLEditParamsValue0 ZoneSettingBrowserCacheTTLEditParamsValue = 0 - ZoneSettingBrowserCacheTTLEditParamsValue30 ZoneSettingBrowserCacheTTLEditParamsValue = 30 - ZoneSettingBrowserCacheTTLEditParamsValue60 ZoneSettingBrowserCacheTTLEditParamsValue = 60 - ZoneSettingBrowserCacheTTLEditParamsValue120 ZoneSettingBrowserCacheTTLEditParamsValue = 120 - ZoneSettingBrowserCacheTTLEditParamsValue300 ZoneSettingBrowserCacheTTLEditParamsValue = 300 - ZoneSettingBrowserCacheTTLEditParamsValue1200 ZoneSettingBrowserCacheTTLEditParamsValue = 1200 - ZoneSettingBrowserCacheTTLEditParamsValue1800 ZoneSettingBrowserCacheTTLEditParamsValue = 1800 - ZoneSettingBrowserCacheTTLEditParamsValue3600 ZoneSettingBrowserCacheTTLEditParamsValue = 3600 - ZoneSettingBrowserCacheTTLEditParamsValue7200 ZoneSettingBrowserCacheTTLEditParamsValue = 7200 - ZoneSettingBrowserCacheTTLEditParamsValue10800 ZoneSettingBrowserCacheTTLEditParamsValue = 10800 - ZoneSettingBrowserCacheTTLEditParamsValue14400 ZoneSettingBrowserCacheTTLEditParamsValue = 14400 - ZoneSettingBrowserCacheTTLEditParamsValue18000 ZoneSettingBrowserCacheTTLEditParamsValue = 18000 - ZoneSettingBrowserCacheTTLEditParamsValue28800 ZoneSettingBrowserCacheTTLEditParamsValue = 28800 - ZoneSettingBrowserCacheTTLEditParamsValue43200 ZoneSettingBrowserCacheTTLEditParamsValue = 43200 - ZoneSettingBrowserCacheTTLEditParamsValue57600 ZoneSettingBrowserCacheTTLEditParamsValue = 57600 - ZoneSettingBrowserCacheTTLEditParamsValue72000 ZoneSettingBrowserCacheTTLEditParamsValue = 72000 - ZoneSettingBrowserCacheTTLEditParamsValue86400 ZoneSettingBrowserCacheTTLEditParamsValue = 86400 - ZoneSettingBrowserCacheTTLEditParamsValue172800 ZoneSettingBrowserCacheTTLEditParamsValue = 172800 - ZoneSettingBrowserCacheTTLEditParamsValue259200 ZoneSettingBrowserCacheTTLEditParamsValue = 259200 - ZoneSettingBrowserCacheTTLEditParamsValue345600 ZoneSettingBrowserCacheTTLEditParamsValue = 345600 - ZoneSettingBrowserCacheTTLEditParamsValue432000 ZoneSettingBrowserCacheTTLEditParamsValue = 432000 - ZoneSettingBrowserCacheTTLEditParamsValue691200 ZoneSettingBrowserCacheTTLEditParamsValue = 691200 - ZoneSettingBrowserCacheTTLEditParamsValue1382400 ZoneSettingBrowserCacheTTLEditParamsValue = 1382400 - ZoneSettingBrowserCacheTTLEditParamsValue2073600 ZoneSettingBrowserCacheTTLEditParamsValue = 2073600 - ZoneSettingBrowserCacheTTLEditParamsValue2678400 ZoneSettingBrowserCacheTTLEditParamsValue = 2678400 - ZoneSettingBrowserCacheTTLEditParamsValue5356800 ZoneSettingBrowserCacheTTLEditParamsValue = 5356800 - ZoneSettingBrowserCacheTTLEditParamsValue16070400 ZoneSettingBrowserCacheTTLEditParamsValue = 16070400 - ZoneSettingBrowserCacheTTLEditParamsValue31536000 ZoneSettingBrowserCacheTTLEditParamsValue = 31536000 -) - -type ZoneSettingBrowserCacheTTLEditResponseEnvelope struct { - Errors []ZoneSettingBrowserCacheTTLEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingBrowserCacheTTLEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources - // will remain on your visitors' computers. Cloudflare will honor any larger times - // specified by your server. - // (https://support.cloudflare.com/hc/en-us/articles/200168276). - Result ZoneSettingBrowserCacheTTLEditResponse `json:"result"` - JSON zoneSettingBrowserCacheTTLEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingBrowserCacheTTLEditResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingBrowserCacheTTLEditResponseEnvelope] -type zoneSettingBrowserCacheTTLEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrowserCacheTTLEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrowserCacheTTLEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingBrowserCacheTTLEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingBrowserCacheTTLEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingBrowserCacheTTLEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingBrowserCacheTTLEditResponseEnvelopeErrors] -type zoneSettingBrowserCacheTTLEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrowserCacheTTLEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrowserCacheTTLEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingBrowserCacheTTLEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingBrowserCacheTTLEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingBrowserCacheTTLEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingBrowserCacheTTLEditResponseEnvelopeMessages] -type zoneSettingBrowserCacheTTLEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrowserCacheTTLEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrowserCacheTTLEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingBrowserCacheTTLGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingBrowserCacheTTLGetResponseEnvelope struct { - Errors []ZoneSettingBrowserCacheTTLGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingBrowserCacheTTLGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Browser Cache TTL (in seconds) specifies how long Cloudflare-cached resources - // will remain on your visitors' computers. Cloudflare will honor any larger times - // specified by your server. - // (https://support.cloudflare.com/hc/en-us/articles/200168276). - Result ZoneSettingBrowserCacheTTLGetResponse `json:"result"` - JSON zoneSettingBrowserCacheTTLGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingBrowserCacheTTLGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingBrowserCacheTTLGetResponseEnvelope] -type zoneSettingBrowserCacheTTLGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrowserCacheTTLGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrowserCacheTTLGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingBrowserCacheTTLGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingBrowserCacheTTLGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingBrowserCacheTTLGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingBrowserCacheTTLGetResponseEnvelopeErrors] -type zoneSettingBrowserCacheTTLGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrowserCacheTTLGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrowserCacheTTLGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingBrowserCacheTTLGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingBrowserCacheTTLGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingBrowserCacheTTLGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingBrowserCacheTTLGetResponseEnvelopeMessages] -type zoneSettingBrowserCacheTTLGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrowserCacheTTLGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrowserCacheTTLGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingbrowsercachettl_test.go b/zonesettingbrowsercachettl_test.go deleted file mode 100644 index e50d4c70a74..00000000000 --- a/zonesettingbrowsercachettl_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingBrowserCacheTTLEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.BrowserCacheTTL.Edit(context.TODO(), cloudflare.ZoneSettingBrowserCacheTTLEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingBrowserCacheTTLEditParamsValue0), - }) - 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 TestZoneSettingBrowserCacheTTLGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.BrowserCacheTTL.Get(context.TODO(), cloudflare.ZoneSettingBrowserCacheTTLGetParams{ - ZoneID: cloudflare.F("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/zonesettingbrowsercheck.go b/zonesettingbrowsercheck.go deleted file mode 100644 index 5a847629e75..00000000000 --- a/zonesettingbrowsercheck.go +++ /dev/null @@ -1,371 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingBrowserCheckService 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 -// [NewZoneSettingBrowserCheckService] method instead. -type ZoneSettingBrowserCheckService struct { - Options []option.RequestOption -} - -// NewZoneSettingBrowserCheckService 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 NewZoneSettingBrowserCheckService(opts ...option.RequestOption) (r *ZoneSettingBrowserCheckService) { - r = &ZoneSettingBrowserCheckService{} - r.Options = opts - return -} - -// Browser Integrity Check is similar to Bad Behavior and looks for common HTTP -// headers abused most commonly by spammers and denies access to your page. It will -// also challenge visitors that do not have a user agent or a non standard user -// agent (also commonly used by abuse bots, crawlers or visitors). -// (https://support.cloudflare.com/hc/en-us/articles/200170086). -func (r *ZoneSettingBrowserCheckService) Edit(ctx context.Context, params ZoneSettingBrowserCheckEditParams, opts ...option.RequestOption) (res *ZoneSettingBrowserCheckEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingBrowserCheckEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/browser_check", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Browser Integrity Check is similar to Bad Behavior and looks for common HTTP -// headers abused most commonly by spammers and denies access to your page. It will -// also challenge visitors that do not have a user agent or a non standard user -// agent (also commonly used by abuse bots, crawlers or visitors). -// (https://support.cloudflare.com/hc/en-us/articles/200170086). -func (r *ZoneSettingBrowserCheckService) Get(ctx context.Context, query ZoneSettingBrowserCheckGetParams, opts ...option.RequestOption) (res *ZoneSettingBrowserCheckGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingBrowserCheckGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/browser_check", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Browser Integrity Check is similar to Bad Behavior and looks for common HTTP -// headers abused most commonly by spammers and denies access to your page. It will -// also challenge visitors that do not have a user agent or a non standard user -// agent (also commonly used by abuse bots, crawlers or visitors). -// (https://support.cloudflare.com/hc/en-us/articles/200170086). -type ZoneSettingBrowserCheckEditResponse struct { - // ID of the zone setting. - ID ZoneSettingBrowserCheckEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingBrowserCheckEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingBrowserCheckEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingBrowserCheckEditResponseJSON `json:"-"` -} - -// zoneSettingBrowserCheckEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingBrowserCheckEditResponse] -type zoneSettingBrowserCheckEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrowserCheckEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrowserCheckEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingBrowserCheckEditResponseID string - -const ( - ZoneSettingBrowserCheckEditResponseIDBrowserCheck ZoneSettingBrowserCheckEditResponseID = "browser_check" -) - -// Current value of the zone setting. -type ZoneSettingBrowserCheckEditResponseValue string - -const ( - ZoneSettingBrowserCheckEditResponseValueOn ZoneSettingBrowserCheckEditResponseValue = "on" - ZoneSettingBrowserCheckEditResponseValueOff ZoneSettingBrowserCheckEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingBrowserCheckEditResponseEditable bool - -const ( - ZoneSettingBrowserCheckEditResponseEditableTrue ZoneSettingBrowserCheckEditResponseEditable = true - ZoneSettingBrowserCheckEditResponseEditableFalse ZoneSettingBrowserCheckEditResponseEditable = false -) - -// Browser Integrity Check is similar to Bad Behavior and looks for common HTTP -// headers abused most commonly by spammers and denies access to your page. It will -// also challenge visitors that do not have a user agent or a non standard user -// agent (also commonly used by abuse bots, crawlers or visitors). -// (https://support.cloudflare.com/hc/en-us/articles/200170086). -type ZoneSettingBrowserCheckGetResponse struct { - // ID of the zone setting. - ID ZoneSettingBrowserCheckGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingBrowserCheckGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingBrowserCheckGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingBrowserCheckGetResponseJSON `json:"-"` -} - -// zoneSettingBrowserCheckGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingBrowserCheckGetResponse] -type zoneSettingBrowserCheckGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrowserCheckGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrowserCheckGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingBrowserCheckGetResponseID string - -const ( - ZoneSettingBrowserCheckGetResponseIDBrowserCheck ZoneSettingBrowserCheckGetResponseID = "browser_check" -) - -// Current value of the zone setting. -type ZoneSettingBrowserCheckGetResponseValue string - -const ( - ZoneSettingBrowserCheckGetResponseValueOn ZoneSettingBrowserCheckGetResponseValue = "on" - ZoneSettingBrowserCheckGetResponseValueOff ZoneSettingBrowserCheckGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingBrowserCheckGetResponseEditable bool - -const ( - ZoneSettingBrowserCheckGetResponseEditableTrue ZoneSettingBrowserCheckGetResponseEditable = true - ZoneSettingBrowserCheckGetResponseEditableFalse ZoneSettingBrowserCheckGetResponseEditable = false -) - -type ZoneSettingBrowserCheckEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingBrowserCheckEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingBrowserCheckEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingBrowserCheckEditParamsValue string - -const ( - ZoneSettingBrowserCheckEditParamsValueOn ZoneSettingBrowserCheckEditParamsValue = "on" - ZoneSettingBrowserCheckEditParamsValueOff ZoneSettingBrowserCheckEditParamsValue = "off" -) - -type ZoneSettingBrowserCheckEditResponseEnvelope struct { - Errors []ZoneSettingBrowserCheckEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingBrowserCheckEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Browser Integrity Check is similar to Bad Behavior and looks for common HTTP - // headers abused most commonly by spammers and denies access to your page. It will - // also challenge visitors that do not have a user agent or a non standard user - // agent (also commonly used by abuse bots, crawlers or visitors). - // (https://support.cloudflare.com/hc/en-us/articles/200170086). - Result ZoneSettingBrowserCheckEditResponse `json:"result"` - JSON zoneSettingBrowserCheckEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingBrowserCheckEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingBrowserCheckEditResponseEnvelope] -type zoneSettingBrowserCheckEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrowserCheckEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrowserCheckEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingBrowserCheckEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingBrowserCheckEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingBrowserCheckEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingBrowserCheckEditResponseEnvelopeErrors] -type zoneSettingBrowserCheckEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrowserCheckEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrowserCheckEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingBrowserCheckEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingBrowserCheckEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingBrowserCheckEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingBrowserCheckEditResponseEnvelopeMessages] -type zoneSettingBrowserCheckEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrowserCheckEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrowserCheckEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingBrowserCheckGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingBrowserCheckGetResponseEnvelope struct { - Errors []ZoneSettingBrowserCheckGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingBrowserCheckGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Browser Integrity Check is similar to Bad Behavior and looks for common HTTP - // headers abused most commonly by spammers and denies access to your page. It will - // also challenge visitors that do not have a user agent or a non standard user - // agent (also commonly used by abuse bots, crawlers or visitors). - // (https://support.cloudflare.com/hc/en-us/articles/200170086). - Result ZoneSettingBrowserCheckGetResponse `json:"result"` - JSON zoneSettingBrowserCheckGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingBrowserCheckGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingBrowserCheckGetResponseEnvelope] -type zoneSettingBrowserCheckGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrowserCheckGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrowserCheckGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingBrowserCheckGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingBrowserCheckGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingBrowserCheckGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingBrowserCheckGetResponseEnvelopeErrors] -type zoneSettingBrowserCheckGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrowserCheckGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrowserCheckGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingBrowserCheckGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingBrowserCheckGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingBrowserCheckGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingBrowserCheckGetResponseEnvelopeMessages] -type zoneSettingBrowserCheckGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingBrowserCheckGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingBrowserCheckGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingbrowsercheck_test.go b/zonesettingbrowsercheck_test.go deleted file mode 100644 index 9185d7c3f12..00000000000 --- a/zonesettingbrowsercheck_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingBrowserCheckEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.BrowserCheck.Edit(context.TODO(), cloudflare.ZoneSettingBrowserCheckEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingBrowserCheckEditParamsValueOn), - }) - 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 TestZoneSettingBrowserCheckGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.BrowserCheck.Get(context.TODO(), cloudflare.ZoneSettingBrowserCheckGetParams{ - ZoneID: cloudflare.F("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/zonesettingcachelevel.go b/zonesettingcachelevel.go deleted file mode 100644 index 6d2d0824823..00000000000 --- a/zonesettingcachelevel.go +++ /dev/null @@ -1,374 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingCacheLevelService 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 [NewZoneSettingCacheLevelService] -// method instead. -type ZoneSettingCacheLevelService struct { - Options []option.RequestOption -} - -// NewZoneSettingCacheLevelService 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 NewZoneSettingCacheLevelService(opts ...option.RequestOption) (r *ZoneSettingCacheLevelService) { - r = &ZoneSettingCacheLevelService{} - r.Options = opts - return -} - -// Cache Level functions based off the setting level. The basic setting will cache -// most static resources (i.e., css, images, and JavaScript). The simplified -// setting will ignore the query string when delivering a cached resource. The -// aggressive setting will cache all static resources, including ones with a query -// string. (https://support.cloudflare.com/hc/en-us/articles/200168256). -func (r *ZoneSettingCacheLevelService) Edit(ctx context.Context, params ZoneSettingCacheLevelEditParams, opts ...option.RequestOption) (res *ZoneSettingCacheLevelEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingCacheLevelEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/cache_level", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Cache Level functions based off the setting level. The basic setting will cache -// most static resources (i.e., css, images, and JavaScript). The simplified -// setting will ignore the query string when delivering a cached resource. The -// aggressive setting will cache all static resources, including ones with a query -// string. (https://support.cloudflare.com/hc/en-us/articles/200168256). -func (r *ZoneSettingCacheLevelService) Get(ctx context.Context, query ZoneSettingCacheLevelGetParams, opts ...option.RequestOption) (res *ZoneSettingCacheLevelGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingCacheLevelGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/cache_level", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Cache Level functions based off the setting level. The basic setting will cache -// most static resources (i.e., css, images, and JavaScript). The simplified -// setting will ignore the query string when delivering a cached resource. The -// aggressive setting will cache all static resources, including ones with a query -// string. (https://support.cloudflare.com/hc/en-us/articles/200168256). -type ZoneSettingCacheLevelEditResponse struct { - // ID of the zone setting. - ID ZoneSettingCacheLevelEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingCacheLevelEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingCacheLevelEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingCacheLevelEditResponseJSON `json:"-"` -} - -// zoneSettingCacheLevelEditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingCacheLevelEditResponse] -type zoneSettingCacheLevelEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingCacheLevelEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingCacheLevelEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingCacheLevelEditResponseID string - -const ( - ZoneSettingCacheLevelEditResponseIDCacheLevel ZoneSettingCacheLevelEditResponseID = "cache_level" -) - -// Current value of the zone setting. -type ZoneSettingCacheLevelEditResponseValue string - -const ( - ZoneSettingCacheLevelEditResponseValueAggressive ZoneSettingCacheLevelEditResponseValue = "aggressive" - ZoneSettingCacheLevelEditResponseValueBasic ZoneSettingCacheLevelEditResponseValue = "basic" - ZoneSettingCacheLevelEditResponseValueSimplified ZoneSettingCacheLevelEditResponseValue = "simplified" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingCacheLevelEditResponseEditable bool - -const ( - ZoneSettingCacheLevelEditResponseEditableTrue ZoneSettingCacheLevelEditResponseEditable = true - ZoneSettingCacheLevelEditResponseEditableFalse ZoneSettingCacheLevelEditResponseEditable = false -) - -// Cache Level functions based off the setting level. The basic setting will cache -// most static resources (i.e., css, images, and JavaScript). The simplified -// setting will ignore the query string when delivering a cached resource. The -// aggressive setting will cache all static resources, including ones with a query -// string. (https://support.cloudflare.com/hc/en-us/articles/200168256). -type ZoneSettingCacheLevelGetResponse struct { - // ID of the zone setting. - ID ZoneSettingCacheLevelGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingCacheLevelGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingCacheLevelGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingCacheLevelGetResponseJSON `json:"-"` -} - -// zoneSettingCacheLevelGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingCacheLevelGetResponse] -type zoneSettingCacheLevelGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingCacheLevelGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingCacheLevelGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingCacheLevelGetResponseID string - -const ( - ZoneSettingCacheLevelGetResponseIDCacheLevel ZoneSettingCacheLevelGetResponseID = "cache_level" -) - -// Current value of the zone setting. -type ZoneSettingCacheLevelGetResponseValue string - -const ( - ZoneSettingCacheLevelGetResponseValueAggressive ZoneSettingCacheLevelGetResponseValue = "aggressive" - ZoneSettingCacheLevelGetResponseValueBasic ZoneSettingCacheLevelGetResponseValue = "basic" - ZoneSettingCacheLevelGetResponseValueSimplified ZoneSettingCacheLevelGetResponseValue = "simplified" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingCacheLevelGetResponseEditable bool - -const ( - ZoneSettingCacheLevelGetResponseEditableTrue ZoneSettingCacheLevelGetResponseEditable = true - ZoneSettingCacheLevelGetResponseEditableFalse ZoneSettingCacheLevelGetResponseEditable = false -) - -type ZoneSettingCacheLevelEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingCacheLevelEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingCacheLevelEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingCacheLevelEditParamsValue string - -const ( - ZoneSettingCacheLevelEditParamsValueAggressive ZoneSettingCacheLevelEditParamsValue = "aggressive" - ZoneSettingCacheLevelEditParamsValueBasic ZoneSettingCacheLevelEditParamsValue = "basic" - ZoneSettingCacheLevelEditParamsValueSimplified ZoneSettingCacheLevelEditParamsValue = "simplified" -) - -type ZoneSettingCacheLevelEditResponseEnvelope struct { - Errors []ZoneSettingCacheLevelEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingCacheLevelEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Cache Level functions based off the setting level. The basic setting will cache - // most static resources (i.e., css, images, and JavaScript). The simplified - // setting will ignore the query string when delivering a cached resource. The - // aggressive setting will cache all static resources, including ones with a query - // string. (https://support.cloudflare.com/hc/en-us/articles/200168256). - Result ZoneSettingCacheLevelEditResponse `json:"result"` - JSON zoneSettingCacheLevelEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingCacheLevelEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingCacheLevelEditResponseEnvelope] -type zoneSettingCacheLevelEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingCacheLevelEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingCacheLevelEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingCacheLevelEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingCacheLevelEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingCacheLevelEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingCacheLevelEditResponseEnvelopeErrors] -type zoneSettingCacheLevelEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingCacheLevelEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingCacheLevelEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingCacheLevelEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingCacheLevelEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingCacheLevelEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZoneSettingCacheLevelEditResponseEnvelopeMessages] -type zoneSettingCacheLevelEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingCacheLevelEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingCacheLevelEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingCacheLevelGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingCacheLevelGetResponseEnvelope struct { - Errors []ZoneSettingCacheLevelGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingCacheLevelGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Cache Level functions based off the setting level. The basic setting will cache - // most static resources (i.e., css, images, and JavaScript). The simplified - // setting will ignore the query string when delivering a cached resource. The - // aggressive setting will cache all static resources, including ones with a query - // string. (https://support.cloudflare.com/hc/en-us/articles/200168256). - Result ZoneSettingCacheLevelGetResponse `json:"result"` - JSON zoneSettingCacheLevelGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingCacheLevelGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingCacheLevelGetResponseEnvelope] -type zoneSettingCacheLevelGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingCacheLevelGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingCacheLevelGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingCacheLevelGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingCacheLevelGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingCacheLevelGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingCacheLevelGetResponseEnvelopeErrors] -type zoneSettingCacheLevelGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingCacheLevelGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingCacheLevelGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingCacheLevelGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingCacheLevelGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingCacheLevelGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZoneSettingCacheLevelGetResponseEnvelopeMessages] -type zoneSettingCacheLevelGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingCacheLevelGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingCacheLevelGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingcachelevel_test.go b/zonesettingcachelevel_test.go deleted file mode 100644 index 57aa394e817..00000000000 --- a/zonesettingcachelevel_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingCacheLevelEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.CacheLevel.Edit(context.TODO(), cloudflare.ZoneSettingCacheLevelEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingCacheLevelEditParamsValueAggressive), - }) - 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 TestZoneSettingCacheLevelGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.CacheLevel.Get(context.TODO(), cloudflare.ZoneSettingCacheLevelGetParams{ - ZoneID: cloudflare.F("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/zonesettingchallengettl.go b/zonesettingchallengettl.go deleted file mode 100644 index 0edeaf82acf..00000000000 --- a/zonesettingchallengettl.go +++ /dev/null @@ -1,407 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingChallengeTTLService 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 -// [NewZoneSettingChallengeTTLService] method instead. -type ZoneSettingChallengeTTLService struct { - Options []option.RequestOption -} - -// NewZoneSettingChallengeTTLService 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 NewZoneSettingChallengeTTLService(opts ...option.RequestOption) (r *ZoneSettingChallengeTTLService) { - r = &ZoneSettingChallengeTTLService{} - r.Options = opts - return -} - -// Specify how long a visitor is allowed access to your site after successfully -// completing a challenge (such as a CAPTCHA). After the TTL has expired the -// visitor will have to complete a new challenge. We recommend a 15 - 45 minute -// setting and will attempt to honor any setting above 45 minutes. -// (https://support.cloudflare.com/hc/en-us/articles/200170136). -func (r *ZoneSettingChallengeTTLService) Edit(ctx context.Context, params ZoneSettingChallengeTTLEditParams, opts ...option.RequestOption) (res *ZoneSettingChallengeTTLEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingChallengeTTLEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/challenge_ttl", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Specify how long a visitor is allowed access to your site after successfully -// completing a challenge (such as a CAPTCHA). After the TTL has expired the -// visitor will have to complete a new challenge. We recommend a 15 - 45 minute -// setting and will attempt to honor any setting above 45 minutes. -// (https://support.cloudflare.com/hc/en-us/articles/200170136). -func (r *ZoneSettingChallengeTTLService) Get(ctx context.Context, query ZoneSettingChallengeTTLGetParams, opts ...option.RequestOption) (res *ZoneSettingChallengeTTLGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingChallengeTTLGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/challenge_ttl", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Specify how long a visitor is allowed access to your site after successfully -// completing a challenge (such as a CAPTCHA). After the TTL has expired the -// visitor will have to complete a new challenge. We recommend a 15 - 45 minute -// setting and will attempt to honor any setting above 45 minutes. -// (https://support.cloudflare.com/hc/en-us/articles/200170136). -type ZoneSettingChallengeTTLEditResponse struct { - // ID of the zone setting. - ID ZoneSettingChallengeTTLEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingChallengeTTLEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingChallengeTTLEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingChallengeTTLEditResponseJSON `json:"-"` -} - -// zoneSettingChallengeTTLEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingChallengeTTLEditResponse] -type zoneSettingChallengeTTLEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingChallengeTTLEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingChallengeTTLEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingChallengeTTLEditResponseID string - -const ( - ZoneSettingChallengeTTLEditResponseIDChallengeTTL ZoneSettingChallengeTTLEditResponseID = "challenge_ttl" -) - -// Current value of the zone setting. -type ZoneSettingChallengeTTLEditResponseValue float64 - -const ( - ZoneSettingChallengeTTLEditResponseValue300 ZoneSettingChallengeTTLEditResponseValue = 300 - ZoneSettingChallengeTTLEditResponseValue900 ZoneSettingChallengeTTLEditResponseValue = 900 - ZoneSettingChallengeTTLEditResponseValue1800 ZoneSettingChallengeTTLEditResponseValue = 1800 - ZoneSettingChallengeTTLEditResponseValue2700 ZoneSettingChallengeTTLEditResponseValue = 2700 - ZoneSettingChallengeTTLEditResponseValue3600 ZoneSettingChallengeTTLEditResponseValue = 3600 - ZoneSettingChallengeTTLEditResponseValue7200 ZoneSettingChallengeTTLEditResponseValue = 7200 - ZoneSettingChallengeTTLEditResponseValue10800 ZoneSettingChallengeTTLEditResponseValue = 10800 - ZoneSettingChallengeTTLEditResponseValue14400 ZoneSettingChallengeTTLEditResponseValue = 14400 - ZoneSettingChallengeTTLEditResponseValue28800 ZoneSettingChallengeTTLEditResponseValue = 28800 - ZoneSettingChallengeTTLEditResponseValue57600 ZoneSettingChallengeTTLEditResponseValue = 57600 - ZoneSettingChallengeTTLEditResponseValue86400 ZoneSettingChallengeTTLEditResponseValue = 86400 - ZoneSettingChallengeTTLEditResponseValue604800 ZoneSettingChallengeTTLEditResponseValue = 604800 - ZoneSettingChallengeTTLEditResponseValue2592000 ZoneSettingChallengeTTLEditResponseValue = 2592000 - ZoneSettingChallengeTTLEditResponseValue31536000 ZoneSettingChallengeTTLEditResponseValue = 31536000 -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingChallengeTTLEditResponseEditable bool - -const ( - ZoneSettingChallengeTTLEditResponseEditableTrue ZoneSettingChallengeTTLEditResponseEditable = true - ZoneSettingChallengeTTLEditResponseEditableFalse ZoneSettingChallengeTTLEditResponseEditable = false -) - -// Specify how long a visitor is allowed access to your site after successfully -// completing a challenge (such as a CAPTCHA). After the TTL has expired the -// visitor will have to complete a new challenge. We recommend a 15 - 45 minute -// setting and will attempt to honor any setting above 45 minutes. -// (https://support.cloudflare.com/hc/en-us/articles/200170136). -type ZoneSettingChallengeTTLGetResponse struct { - // ID of the zone setting. - ID ZoneSettingChallengeTTLGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingChallengeTTLGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingChallengeTTLGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingChallengeTTLGetResponseJSON `json:"-"` -} - -// zoneSettingChallengeTTLGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingChallengeTTLGetResponse] -type zoneSettingChallengeTTLGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingChallengeTTLGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingChallengeTTLGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingChallengeTTLGetResponseID string - -const ( - ZoneSettingChallengeTTLGetResponseIDChallengeTTL ZoneSettingChallengeTTLGetResponseID = "challenge_ttl" -) - -// Current value of the zone setting. -type ZoneSettingChallengeTTLGetResponseValue float64 - -const ( - ZoneSettingChallengeTTLGetResponseValue300 ZoneSettingChallengeTTLGetResponseValue = 300 - ZoneSettingChallengeTTLGetResponseValue900 ZoneSettingChallengeTTLGetResponseValue = 900 - ZoneSettingChallengeTTLGetResponseValue1800 ZoneSettingChallengeTTLGetResponseValue = 1800 - ZoneSettingChallengeTTLGetResponseValue2700 ZoneSettingChallengeTTLGetResponseValue = 2700 - ZoneSettingChallengeTTLGetResponseValue3600 ZoneSettingChallengeTTLGetResponseValue = 3600 - ZoneSettingChallengeTTLGetResponseValue7200 ZoneSettingChallengeTTLGetResponseValue = 7200 - ZoneSettingChallengeTTLGetResponseValue10800 ZoneSettingChallengeTTLGetResponseValue = 10800 - ZoneSettingChallengeTTLGetResponseValue14400 ZoneSettingChallengeTTLGetResponseValue = 14400 - ZoneSettingChallengeTTLGetResponseValue28800 ZoneSettingChallengeTTLGetResponseValue = 28800 - ZoneSettingChallengeTTLGetResponseValue57600 ZoneSettingChallengeTTLGetResponseValue = 57600 - ZoneSettingChallengeTTLGetResponseValue86400 ZoneSettingChallengeTTLGetResponseValue = 86400 - ZoneSettingChallengeTTLGetResponseValue604800 ZoneSettingChallengeTTLGetResponseValue = 604800 - ZoneSettingChallengeTTLGetResponseValue2592000 ZoneSettingChallengeTTLGetResponseValue = 2592000 - ZoneSettingChallengeTTLGetResponseValue31536000 ZoneSettingChallengeTTLGetResponseValue = 31536000 -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingChallengeTTLGetResponseEditable bool - -const ( - ZoneSettingChallengeTTLGetResponseEditableTrue ZoneSettingChallengeTTLGetResponseEditable = true - ZoneSettingChallengeTTLGetResponseEditableFalse ZoneSettingChallengeTTLGetResponseEditable = false -) - -type ZoneSettingChallengeTTLEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingChallengeTTLEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingChallengeTTLEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingChallengeTTLEditParamsValue float64 - -const ( - ZoneSettingChallengeTTLEditParamsValue300 ZoneSettingChallengeTTLEditParamsValue = 300 - ZoneSettingChallengeTTLEditParamsValue900 ZoneSettingChallengeTTLEditParamsValue = 900 - ZoneSettingChallengeTTLEditParamsValue1800 ZoneSettingChallengeTTLEditParamsValue = 1800 - ZoneSettingChallengeTTLEditParamsValue2700 ZoneSettingChallengeTTLEditParamsValue = 2700 - ZoneSettingChallengeTTLEditParamsValue3600 ZoneSettingChallengeTTLEditParamsValue = 3600 - ZoneSettingChallengeTTLEditParamsValue7200 ZoneSettingChallengeTTLEditParamsValue = 7200 - ZoneSettingChallengeTTLEditParamsValue10800 ZoneSettingChallengeTTLEditParamsValue = 10800 - ZoneSettingChallengeTTLEditParamsValue14400 ZoneSettingChallengeTTLEditParamsValue = 14400 - ZoneSettingChallengeTTLEditParamsValue28800 ZoneSettingChallengeTTLEditParamsValue = 28800 - ZoneSettingChallengeTTLEditParamsValue57600 ZoneSettingChallengeTTLEditParamsValue = 57600 - ZoneSettingChallengeTTLEditParamsValue86400 ZoneSettingChallengeTTLEditParamsValue = 86400 - ZoneSettingChallengeTTLEditParamsValue604800 ZoneSettingChallengeTTLEditParamsValue = 604800 - ZoneSettingChallengeTTLEditParamsValue2592000 ZoneSettingChallengeTTLEditParamsValue = 2592000 - ZoneSettingChallengeTTLEditParamsValue31536000 ZoneSettingChallengeTTLEditParamsValue = 31536000 -) - -type ZoneSettingChallengeTTLEditResponseEnvelope struct { - Errors []ZoneSettingChallengeTTLEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingChallengeTTLEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Specify how long a visitor is allowed access to your site after successfully - // completing a challenge (such as a CAPTCHA). After the TTL has expired the - // visitor will have to complete a new challenge. We recommend a 15 - 45 minute - // setting and will attempt to honor any setting above 45 minutes. - // (https://support.cloudflare.com/hc/en-us/articles/200170136). - Result ZoneSettingChallengeTTLEditResponse `json:"result"` - JSON zoneSettingChallengeTTLEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingChallengeTTLEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingChallengeTTLEditResponseEnvelope] -type zoneSettingChallengeTTLEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingChallengeTTLEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingChallengeTTLEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingChallengeTTLEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingChallengeTTLEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingChallengeTTLEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingChallengeTTLEditResponseEnvelopeErrors] -type zoneSettingChallengeTTLEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingChallengeTTLEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingChallengeTTLEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingChallengeTTLEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingChallengeTTLEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingChallengeTTLEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingChallengeTTLEditResponseEnvelopeMessages] -type zoneSettingChallengeTTLEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingChallengeTTLEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingChallengeTTLEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingChallengeTTLGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingChallengeTTLGetResponseEnvelope struct { - Errors []ZoneSettingChallengeTTLGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingChallengeTTLGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Specify how long a visitor is allowed access to your site after successfully - // completing a challenge (such as a CAPTCHA). After the TTL has expired the - // visitor will have to complete a new challenge. We recommend a 15 - 45 minute - // setting and will attempt to honor any setting above 45 minutes. - // (https://support.cloudflare.com/hc/en-us/articles/200170136). - Result ZoneSettingChallengeTTLGetResponse `json:"result"` - JSON zoneSettingChallengeTTLGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingChallengeTTLGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingChallengeTTLGetResponseEnvelope] -type zoneSettingChallengeTTLGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingChallengeTTLGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingChallengeTTLGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingChallengeTTLGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingChallengeTTLGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingChallengeTTLGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingChallengeTTLGetResponseEnvelopeErrors] -type zoneSettingChallengeTTLGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingChallengeTTLGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingChallengeTTLGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingChallengeTTLGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingChallengeTTLGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingChallengeTTLGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingChallengeTTLGetResponseEnvelopeMessages] -type zoneSettingChallengeTTLGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingChallengeTTLGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingChallengeTTLGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingchallengettl_test.go b/zonesettingchallengettl_test.go deleted file mode 100644 index a2185622197..00000000000 --- a/zonesettingchallengettl_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingChallengeTTLEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.ChallengeTTL.Edit(context.TODO(), cloudflare.ZoneSettingChallengeTTLEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingChallengeTTLEditParamsValue300), - }) - 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 TestZoneSettingChallengeTTLGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.ChallengeTTL.Get(context.TODO(), cloudflare.ZoneSettingChallengeTTLGetParams{ - ZoneID: cloudflare.F("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/zonesettingcipher.go b/zonesettingcipher.go deleted file mode 100644 index 4baa2240671..00000000000 --- a/zonesettingcipher.go +++ /dev/null @@ -1,327 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingCipherService 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 [NewZoneSettingCipherService] method -// instead. -type ZoneSettingCipherService struct { - Options []option.RequestOption -} - -// NewZoneSettingCipherService 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 NewZoneSettingCipherService(opts ...option.RequestOption) (r *ZoneSettingCipherService) { - r = &ZoneSettingCipherService{} - r.Options = opts - return -} - -// Changes ciphers setting. -func (r *ZoneSettingCipherService) Edit(ctx context.Context, params ZoneSettingCipherEditParams, opts ...option.RequestOption) (res *ZoneSettingCipherEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingCipherEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/ciphers", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets ciphers setting. -func (r *ZoneSettingCipherService) Get(ctx context.Context, query ZoneSettingCipherGetParams, opts ...option.RequestOption) (res *ZoneSettingCipherGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingCipherGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/ciphers", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// An allowlist of ciphers for TLS termination. These ciphers must be in the -// BoringSSL format. -type ZoneSettingCipherEditResponse struct { - // ID of the zone setting. - ID ZoneSettingCipherEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value []string `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingCipherEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingCipherEditResponseJSON `json:"-"` -} - -// zoneSettingCipherEditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingCipherEditResponse] -type zoneSettingCipherEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingCipherEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingCipherEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingCipherEditResponseID string - -const ( - ZoneSettingCipherEditResponseIDCiphers ZoneSettingCipherEditResponseID = "ciphers" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingCipherEditResponseEditable bool - -const ( - ZoneSettingCipherEditResponseEditableTrue ZoneSettingCipherEditResponseEditable = true - ZoneSettingCipherEditResponseEditableFalse ZoneSettingCipherEditResponseEditable = false -) - -// An allowlist of ciphers for TLS termination. These ciphers must be in the -// BoringSSL format. -type ZoneSettingCipherGetResponse struct { - // ID of the zone setting. - ID ZoneSettingCipherGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value []string `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingCipherGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingCipherGetResponseJSON `json:"-"` -} - -// zoneSettingCipherGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingCipherGetResponse] -type zoneSettingCipherGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingCipherGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingCipherGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingCipherGetResponseID string - -const ( - ZoneSettingCipherGetResponseIDCiphers ZoneSettingCipherGetResponseID = "ciphers" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingCipherGetResponseEditable bool - -const ( - ZoneSettingCipherGetResponseEditableTrue ZoneSettingCipherGetResponseEditable = true - ZoneSettingCipherGetResponseEditableFalse ZoneSettingCipherGetResponseEditable = false -) - -type ZoneSettingCipherEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[[]string] `json:"value,required"` -} - -func (r ZoneSettingCipherEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZoneSettingCipherEditResponseEnvelope struct { - Errors []ZoneSettingCipherEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingCipherEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // An allowlist of ciphers for TLS termination. These ciphers must be in the - // BoringSSL format. - Result ZoneSettingCipherEditResponse `json:"result"` - JSON zoneSettingCipherEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingCipherEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingCipherEditResponseEnvelope] -type zoneSettingCipherEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingCipherEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingCipherEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingCipherEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingCipherEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingCipherEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSettingCipherEditResponseEnvelopeErrors] -type zoneSettingCipherEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingCipherEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingCipherEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingCipherEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingCipherEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingCipherEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingCipherEditResponseEnvelopeMessages] -type zoneSettingCipherEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingCipherEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingCipherEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingCipherGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingCipherGetResponseEnvelope struct { - Errors []ZoneSettingCipherGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingCipherGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // An allowlist of ciphers for TLS termination. These ciphers must be in the - // BoringSSL format. - Result ZoneSettingCipherGetResponse `json:"result"` - JSON zoneSettingCipherGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingCipherGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingCipherGetResponseEnvelope] -type zoneSettingCipherGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingCipherGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingCipherGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingCipherGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingCipherGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingCipherGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSettingCipherGetResponseEnvelopeErrors] -type zoneSettingCipherGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingCipherGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingCipherGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingCipherGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingCipherGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingCipherGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingCipherGetResponseEnvelopeMessages] -type zoneSettingCipherGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingCipherGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingCipherGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingcipher_test.go b/zonesettingcipher_test.go deleted file mode 100644 index b1543b53bc8..00000000000 --- a/zonesettingcipher_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingCipherEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.Ciphers.Edit(context.TODO(), cloudflare.ZoneSettingCipherEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F([]string{"ECDHE-RSA-AES128-GCM-SHA256", "AES128-SHA"}), - }) - 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 TestZoneSettingCipherGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.Ciphers.Get(context.TODO(), cloudflare.ZoneSettingCipherGetParams{ - ZoneID: cloudflare.F("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/zonesettingdevelopmentmode.go b/zonesettingdevelopmentmode.go deleted file mode 100644 index 678a2518bee..00000000000 --- a/zonesettingdevelopmentmode.go +++ /dev/null @@ -1,387 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingDevelopmentModeService 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 -// [NewZoneSettingDevelopmentModeService] method instead. -type ZoneSettingDevelopmentModeService struct { - Options []option.RequestOption -} - -// NewZoneSettingDevelopmentModeService 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 NewZoneSettingDevelopmentModeService(opts ...option.RequestOption) (r *ZoneSettingDevelopmentModeService) { - r = &ZoneSettingDevelopmentModeService{} - r.Options = opts - return -} - -// Development Mode temporarily allows you to enter development mode for your -// websites if you need to make changes to your site. This will bypass Cloudflare's -// accelerated cache and slow down your site, but is useful if you are making -// changes to cacheable content (like images, css, or JavaScript) and would like to -// see those changes right away. Once entered, development mode will last for 3 -// hours and then automatically toggle off. -func (r *ZoneSettingDevelopmentModeService) Edit(ctx context.Context, params ZoneSettingDevelopmentModeEditParams, opts ...option.RequestOption) (res *ZoneSettingDevelopmentModeEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingDevelopmentModeEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/development_mode", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Development Mode temporarily allows you to enter development mode for your -// websites if you need to make changes to your site. This will bypass Cloudflare's -// accelerated cache and slow down your site, but is useful if you are making -// changes to cacheable content (like images, css, or JavaScript) and would like to -// see those changes right away. Once entered, development mode will last for 3 -// hours and then automatically toggle off. -func (r *ZoneSettingDevelopmentModeService) Get(ctx context.Context, query ZoneSettingDevelopmentModeGetParams, opts ...option.RequestOption) (res *ZoneSettingDevelopmentModeGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingDevelopmentModeGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/development_mode", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Development Mode temporarily allows you to enter development mode for your -// websites if you need to make changes to your site. This will bypass Cloudflare's -// accelerated cache and slow down your site, but is useful if you are making -// changes to cacheable content (like images, css, or JavaScript) and would like to -// see those changes right away. Once entered, development mode will last for 3 -// hours and then automatically toggle off. -type ZoneSettingDevelopmentModeEditResponse struct { - // ID of the zone setting. - ID ZoneSettingDevelopmentModeEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingDevelopmentModeEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingDevelopmentModeEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - // Value of the zone setting. Notes: The interval (in seconds) from when - // development mode expires (positive integer) or last expired (negative integer) - // for the domain. If development mode has never been enabled, this value is false. - TimeRemaining float64 `json:"time_remaining"` - JSON zoneSettingDevelopmentModeEditResponseJSON `json:"-"` -} - -// zoneSettingDevelopmentModeEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingDevelopmentModeEditResponse] -type zoneSettingDevelopmentModeEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - TimeRemaining apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingDevelopmentModeEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingDevelopmentModeEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingDevelopmentModeEditResponseID string - -const ( - ZoneSettingDevelopmentModeEditResponseIDDevelopmentMode ZoneSettingDevelopmentModeEditResponseID = "development_mode" -) - -// Current value of the zone setting. -type ZoneSettingDevelopmentModeEditResponseValue string - -const ( - ZoneSettingDevelopmentModeEditResponseValueOn ZoneSettingDevelopmentModeEditResponseValue = "on" - ZoneSettingDevelopmentModeEditResponseValueOff ZoneSettingDevelopmentModeEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingDevelopmentModeEditResponseEditable bool - -const ( - ZoneSettingDevelopmentModeEditResponseEditableTrue ZoneSettingDevelopmentModeEditResponseEditable = true - ZoneSettingDevelopmentModeEditResponseEditableFalse ZoneSettingDevelopmentModeEditResponseEditable = false -) - -// Development Mode temporarily allows you to enter development mode for your -// websites if you need to make changes to your site. This will bypass Cloudflare's -// accelerated cache and slow down your site, but is useful if you are making -// changes to cacheable content (like images, css, or JavaScript) and would like to -// see those changes right away. Once entered, development mode will last for 3 -// hours and then automatically toggle off. -type ZoneSettingDevelopmentModeGetResponse struct { - // ID of the zone setting. - ID ZoneSettingDevelopmentModeGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingDevelopmentModeGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingDevelopmentModeGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - // Value of the zone setting. Notes: The interval (in seconds) from when - // development mode expires (positive integer) or last expired (negative integer) - // for the domain. If development mode has never been enabled, this value is false. - TimeRemaining float64 `json:"time_remaining"` - JSON zoneSettingDevelopmentModeGetResponseJSON `json:"-"` -} - -// zoneSettingDevelopmentModeGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingDevelopmentModeGetResponse] -type zoneSettingDevelopmentModeGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - TimeRemaining apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingDevelopmentModeGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingDevelopmentModeGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingDevelopmentModeGetResponseID string - -const ( - ZoneSettingDevelopmentModeGetResponseIDDevelopmentMode ZoneSettingDevelopmentModeGetResponseID = "development_mode" -) - -// Current value of the zone setting. -type ZoneSettingDevelopmentModeGetResponseValue string - -const ( - ZoneSettingDevelopmentModeGetResponseValueOn ZoneSettingDevelopmentModeGetResponseValue = "on" - ZoneSettingDevelopmentModeGetResponseValueOff ZoneSettingDevelopmentModeGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingDevelopmentModeGetResponseEditable bool - -const ( - ZoneSettingDevelopmentModeGetResponseEditableTrue ZoneSettingDevelopmentModeGetResponseEditable = true - ZoneSettingDevelopmentModeGetResponseEditableFalse ZoneSettingDevelopmentModeGetResponseEditable = false -) - -type ZoneSettingDevelopmentModeEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingDevelopmentModeEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingDevelopmentModeEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingDevelopmentModeEditParamsValue string - -const ( - ZoneSettingDevelopmentModeEditParamsValueOn ZoneSettingDevelopmentModeEditParamsValue = "on" - ZoneSettingDevelopmentModeEditParamsValueOff ZoneSettingDevelopmentModeEditParamsValue = "off" -) - -type ZoneSettingDevelopmentModeEditResponseEnvelope struct { - Errors []ZoneSettingDevelopmentModeEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingDevelopmentModeEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Development Mode temporarily allows you to enter development mode for your - // websites if you need to make changes to your site. This will bypass Cloudflare's - // accelerated cache and slow down your site, but is useful if you are making - // changes to cacheable content (like images, css, or JavaScript) and would like to - // see those changes right away. Once entered, development mode will last for 3 - // hours and then automatically toggle off. - Result ZoneSettingDevelopmentModeEditResponse `json:"result"` - JSON zoneSettingDevelopmentModeEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingDevelopmentModeEditResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingDevelopmentModeEditResponseEnvelope] -type zoneSettingDevelopmentModeEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingDevelopmentModeEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingDevelopmentModeEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingDevelopmentModeEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingDevelopmentModeEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingDevelopmentModeEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingDevelopmentModeEditResponseEnvelopeErrors] -type zoneSettingDevelopmentModeEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingDevelopmentModeEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingDevelopmentModeEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingDevelopmentModeEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingDevelopmentModeEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingDevelopmentModeEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingDevelopmentModeEditResponseEnvelopeMessages] -type zoneSettingDevelopmentModeEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingDevelopmentModeEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingDevelopmentModeEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingDevelopmentModeGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingDevelopmentModeGetResponseEnvelope struct { - Errors []ZoneSettingDevelopmentModeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingDevelopmentModeGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Development Mode temporarily allows you to enter development mode for your - // websites if you need to make changes to your site. This will bypass Cloudflare's - // accelerated cache and slow down your site, but is useful if you are making - // changes to cacheable content (like images, css, or JavaScript) and would like to - // see those changes right away. Once entered, development mode will last for 3 - // hours and then automatically toggle off. - Result ZoneSettingDevelopmentModeGetResponse `json:"result"` - JSON zoneSettingDevelopmentModeGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingDevelopmentModeGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingDevelopmentModeGetResponseEnvelope] -type zoneSettingDevelopmentModeGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingDevelopmentModeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingDevelopmentModeGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingDevelopmentModeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingDevelopmentModeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingDevelopmentModeGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingDevelopmentModeGetResponseEnvelopeErrors] -type zoneSettingDevelopmentModeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingDevelopmentModeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingDevelopmentModeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingDevelopmentModeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingDevelopmentModeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingDevelopmentModeGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingDevelopmentModeGetResponseEnvelopeMessages] -type zoneSettingDevelopmentModeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingDevelopmentModeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingDevelopmentModeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingdevelopmentmode_test.go b/zonesettingdevelopmentmode_test.go deleted file mode 100644 index c63a560e973..00000000000 --- a/zonesettingdevelopmentmode_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingDevelopmentModeEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.DevelopmentMode.Edit(context.TODO(), cloudflare.ZoneSettingDevelopmentModeEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingDevelopmentModeEditParamsValueOn), - }) - 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 TestZoneSettingDevelopmentModeGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.DevelopmentMode.Get(context.TODO(), cloudflare.ZoneSettingDevelopmentModeGetParams{ - ZoneID: cloudflare.F("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/zonesettingearlyhint.go b/zonesettingearlyhint.go deleted file mode 100644 index 0d4551229a6..00000000000 --- a/zonesettingearlyhint.go +++ /dev/null @@ -1,365 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingEarlyHintService 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 [NewZoneSettingEarlyHintService] -// method instead. -type ZoneSettingEarlyHintService struct { - Options []option.RequestOption -} - -// NewZoneSettingEarlyHintService 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 NewZoneSettingEarlyHintService(opts ...option.RequestOption) (r *ZoneSettingEarlyHintService) { - r = &ZoneSettingEarlyHintService{} - r.Options = opts - return -} - -// When enabled, Cloudflare will attempt to speed up overall page loads by serving -// `103` responses with `Link` headers from the final response. Refer to -// [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for -// more information. -func (r *ZoneSettingEarlyHintService) Edit(ctx context.Context, params ZoneSettingEarlyHintEditParams, opts ...option.RequestOption) (res *ZoneSettingEarlyHintEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingEarlyHintEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/early_hints", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// When enabled, Cloudflare will attempt to speed up overall page loads by serving -// `103` responses with `Link` headers from the final response. Refer to -// [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for -// more information. -func (r *ZoneSettingEarlyHintService) Get(ctx context.Context, query ZoneSettingEarlyHintGetParams, opts ...option.RequestOption) (res *ZoneSettingEarlyHintGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingEarlyHintGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/early_hints", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// When enabled, Cloudflare will attempt to speed up overall page loads by serving -// `103` responses with `Link` headers from the final response. Refer to -// [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for -// more information. -type ZoneSettingEarlyHintEditResponse struct { - // ID of the zone setting. - ID ZoneSettingEarlyHintEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEarlyHintEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEarlyHintEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEarlyHintEditResponseJSON `json:"-"` -} - -// zoneSettingEarlyHintEditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingEarlyHintEditResponse] -type zoneSettingEarlyHintEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEarlyHintEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEarlyHintEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingEarlyHintEditResponseID string - -const ( - ZoneSettingEarlyHintEditResponseIDEarlyHints ZoneSettingEarlyHintEditResponseID = "early_hints" -) - -// Current value of the zone setting. -type ZoneSettingEarlyHintEditResponseValue string - -const ( - ZoneSettingEarlyHintEditResponseValueOn ZoneSettingEarlyHintEditResponseValue = "on" - ZoneSettingEarlyHintEditResponseValueOff ZoneSettingEarlyHintEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEarlyHintEditResponseEditable bool - -const ( - ZoneSettingEarlyHintEditResponseEditableTrue ZoneSettingEarlyHintEditResponseEditable = true - ZoneSettingEarlyHintEditResponseEditableFalse ZoneSettingEarlyHintEditResponseEditable = false -) - -// When enabled, Cloudflare will attempt to speed up overall page loads by serving -// `103` responses with `Link` headers from the final response. Refer to -// [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for -// more information. -type ZoneSettingEarlyHintGetResponse struct { - // ID of the zone setting. - ID ZoneSettingEarlyHintGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEarlyHintGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEarlyHintGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEarlyHintGetResponseJSON `json:"-"` -} - -// zoneSettingEarlyHintGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingEarlyHintGetResponse] -type zoneSettingEarlyHintGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEarlyHintGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEarlyHintGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingEarlyHintGetResponseID string - -const ( - ZoneSettingEarlyHintGetResponseIDEarlyHints ZoneSettingEarlyHintGetResponseID = "early_hints" -) - -// Current value of the zone setting. -type ZoneSettingEarlyHintGetResponseValue string - -const ( - ZoneSettingEarlyHintGetResponseValueOn ZoneSettingEarlyHintGetResponseValue = "on" - ZoneSettingEarlyHintGetResponseValueOff ZoneSettingEarlyHintGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEarlyHintGetResponseEditable bool - -const ( - ZoneSettingEarlyHintGetResponseEditableTrue ZoneSettingEarlyHintGetResponseEditable = true - ZoneSettingEarlyHintGetResponseEditableFalse ZoneSettingEarlyHintGetResponseEditable = false -) - -type ZoneSettingEarlyHintEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingEarlyHintEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingEarlyHintEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingEarlyHintEditParamsValue string - -const ( - ZoneSettingEarlyHintEditParamsValueOn ZoneSettingEarlyHintEditParamsValue = "on" - ZoneSettingEarlyHintEditParamsValueOff ZoneSettingEarlyHintEditParamsValue = "off" -) - -type ZoneSettingEarlyHintEditResponseEnvelope struct { - Errors []ZoneSettingEarlyHintEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingEarlyHintEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // When enabled, Cloudflare will attempt to speed up overall page loads by serving - // `103` responses with `Link` headers from the final response. Refer to - // [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for - // more information. - Result ZoneSettingEarlyHintEditResponse `json:"result"` - JSON zoneSettingEarlyHintEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingEarlyHintEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingEarlyHintEditResponseEnvelope] -type zoneSettingEarlyHintEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEarlyHintEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEarlyHintEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingEarlyHintEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingEarlyHintEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingEarlyHintEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingEarlyHintEditResponseEnvelopeErrors] -type zoneSettingEarlyHintEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEarlyHintEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEarlyHintEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingEarlyHintEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingEarlyHintEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingEarlyHintEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZoneSettingEarlyHintEditResponseEnvelopeMessages] -type zoneSettingEarlyHintEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEarlyHintEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEarlyHintEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingEarlyHintGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingEarlyHintGetResponseEnvelope struct { - Errors []ZoneSettingEarlyHintGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingEarlyHintGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // When enabled, Cloudflare will attempt to speed up overall page loads by serving - // `103` responses with `Link` headers from the final response. Refer to - // [Early Hints](https://developers.cloudflare.com/cache/about/early-hints) for - // more information. - Result ZoneSettingEarlyHintGetResponse `json:"result"` - JSON zoneSettingEarlyHintGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingEarlyHintGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingEarlyHintGetResponseEnvelope] -type zoneSettingEarlyHintGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEarlyHintGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEarlyHintGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingEarlyHintGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingEarlyHintGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingEarlyHintGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSettingEarlyHintGetResponseEnvelopeErrors] -type zoneSettingEarlyHintGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEarlyHintGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEarlyHintGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingEarlyHintGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingEarlyHintGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingEarlyHintGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZoneSettingEarlyHintGetResponseEnvelopeMessages] -type zoneSettingEarlyHintGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEarlyHintGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEarlyHintGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingearlyhint_test.go b/zonesettingearlyhint_test.go deleted file mode 100644 index 67dbed9c29a..00000000000 --- a/zonesettingearlyhint_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingEarlyHintEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.EarlyHints.Edit(context.TODO(), cloudflare.ZoneSettingEarlyHintEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingEarlyHintEditParamsValueOn), - }) - 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 TestZoneSettingEarlyHintGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.EarlyHints.Get(context.TODO(), cloudflare.ZoneSettingEarlyHintGetParams{ - ZoneID: cloudflare.F("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/zonesettingemailobfuscation.go b/zonesettingemailobfuscation.go deleted file mode 100644 index 5eb4dde7f37..00000000000 --- a/zonesettingemailobfuscation.go +++ /dev/null @@ -1,354 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingEmailObfuscationService 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 -// [NewZoneSettingEmailObfuscationService] method instead. -type ZoneSettingEmailObfuscationService struct { - Options []option.RequestOption -} - -// NewZoneSettingEmailObfuscationService 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 NewZoneSettingEmailObfuscationService(opts ...option.RequestOption) (r *ZoneSettingEmailObfuscationService) { - r = &ZoneSettingEmailObfuscationService{} - r.Options = opts - return -} - -// Encrypt email adresses on your web page from bots, while keeping them visible to -// humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). -func (r *ZoneSettingEmailObfuscationService) Edit(ctx context.Context, params ZoneSettingEmailObfuscationEditParams, opts ...option.RequestOption) (res *ZoneSettingEmailObfuscationEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingEmailObfuscationEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/email_obfuscation", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Encrypt email adresses on your web page from bots, while keeping them visible to -// humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). -func (r *ZoneSettingEmailObfuscationService) Get(ctx context.Context, query ZoneSettingEmailObfuscationGetParams, opts ...option.RequestOption) (res *ZoneSettingEmailObfuscationGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingEmailObfuscationGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/email_obfuscation", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Encrypt email adresses on your web page from bots, while keeping them visible to -// humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). -type ZoneSettingEmailObfuscationEditResponse struct { - // ID of the zone setting. - ID ZoneSettingEmailObfuscationEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEmailObfuscationEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEmailObfuscationEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEmailObfuscationEditResponseJSON `json:"-"` -} - -// zoneSettingEmailObfuscationEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingEmailObfuscationEditResponse] -type zoneSettingEmailObfuscationEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEmailObfuscationEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEmailObfuscationEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingEmailObfuscationEditResponseID string - -const ( - ZoneSettingEmailObfuscationEditResponseIDEmailObfuscation ZoneSettingEmailObfuscationEditResponseID = "email_obfuscation" -) - -// Current value of the zone setting. -type ZoneSettingEmailObfuscationEditResponseValue string - -const ( - ZoneSettingEmailObfuscationEditResponseValueOn ZoneSettingEmailObfuscationEditResponseValue = "on" - ZoneSettingEmailObfuscationEditResponseValueOff ZoneSettingEmailObfuscationEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEmailObfuscationEditResponseEditable bool - -const ( - ZoneSettingEmailObfuscationEditResponseEditableTrue ZoneSettingEmailObfuscationEditResponseEditable = true - ZoneSettingEmailObfuscationEditResponseEditableFalse ZoneSettingEmailObfuscationEditResponseEditable = false -) - -// Encrypt email adresses on your web page from bots, while keeping them visible to -// humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). -type ZoneSettingEmailObfuscationGetResponse struct { - // ID of the zone setting. - ID ZoneSettingEmailObfuscationGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingEmailObfuscationGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingEmailObfuscationGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingEmailObfuscationGetResponseJSON `json:"-"` -} - -// zoneSettingEmailObfuscationGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingEmailObfuscationGetResponse] -type zoneSettingEmailObfuscationGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEmailObfuscationGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEmailObfuscationGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingEmailObfuscationGetResponseID string - -const ( - ZoneSettingEmailObfuscationGetResponseIDEmailObfuscation ZoneSettingEmailObfuscationGetResponseID = "email_obfuscation" -) - -// Current value of the zone setting. -type ZoneSettingEmailObfuscationGetResponseValue string - -const ( - ZoneSettingEmailObfuscationGetResponseValueOn ZoneSettingEmailObfuscationGetResponseValue = "on" - ZoneSettingEmailObfuscationGetResponseValueOff ZoneSettingEmailObfuscationGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingEmailObfuscationGetResponseEditable bool - -const ( - ZoneSettingEmailObfuscationGetResponseEditableTrue ZoneSettingEmailObfuscationGetResponseEditable = true - ZoneSettingEmailObfuscationGetResponseEditableFalse ZoneSettingEmailObfuscationGetResponseEditable = false -) - -type ZoneSettingEmailObfuscationEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingEmailObfuscationEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingEmailObfuscationEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingEmailObfuscationEditParamsValue string - -const ( - ZoneSettingEmailObfuscationEditParamsValueOn ZoneSettingEmailObfuscationEditParamsValue = "on" - ZoneSettingEmailObfuscationEditParamsValueOff ZoneSettingEmailObfuscationEditParamsValue = "off" -) - -type ZoneSettingEmailObfuscationEditResponseEnvelope struct { - Errors []ZoneSettingEmailObfuscationEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingEmailObfuscationEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Encrypt email adresses on your web page from bots, while keeping them visible to - // humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). - Result ZoneSettingEmailObfuscationEditResponse `json:"result"` - JSON zoneSettingEmailObfuscationEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingEmailObfuscationEditResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingEmailObfuscationEditResponseEnvelope] -type zoneSettingEmailObfuscationEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEmailObfuscationEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEmailObfuscationEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingEmailObfuscationEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingEmailObfuscationEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingEmailObfuscationEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingEmailObfuscationEditResponseEnvelopeErrors] -type zoneSettingEmailObfuscationEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEmailObfuscationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEmailObfuscationEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingEmailObfuscationEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingEmailObfuscationEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingEmailObfuscationEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZoneSettingEmailObfuscationEditResponseEnvelopeMessages] -type zoneSettingEmailObfuscationEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEmailObfuscationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEmailObfuscationEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingEmailObfuscationGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingEmailObfuscationGetResponseEnvelope struct { - Errors []ZoneSettingEmailObfuscationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingEmailObfuscationGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Encrypt email adresses on your web page from bots, while keeping them visible to - // humans. (https://support.cloudflare.com/hc/en-us/articles/200170016). - Result ZoneSettingEmailObfuscationGetResponse `json:"result"` - JSON zoneSettingEmailObfuscationGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingEmailObfuscationGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingEmailObfuscationGetResponseEnvelope] -type zoneSettingEmailObfuscationGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEmailObfuscationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEmailObfuscationGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingEmailObfuscationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingEmailObfuscationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingEmailObfuscationGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingEmailObfuscationGetResponseEnvelopeErrors] -type zoneSettingEmailObfuscationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEmailObfuscationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEmailObfuscationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingEmailObfuscationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingEmailObfuscationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingEmailObfuscationGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingEmailObfuscationGetResponseEnvelopeMessages] -type zoneSettingEmailObfuscationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingEmailObfuscationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingEmailObfuscationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingemailobfuscation_test.go b/zonesettingemailobfuscation_test.go deleted file mode 100644 index 611288dc81d..00000000000 --- a/zonesettingemailobfuscation_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingEmailObfuscationEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.EmailObfuscation.Edit(context.TODO(), cloudflare.ZoneSettingEmailObfuscationEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingEmailObfuscationEditParamsValueOn), - }) - 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 TestZoneSettingEmailObfuscationGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.EmailObfuscation.Get(context.TODO(), cloudflare.ZoneSettingEmailObfuscationGetParams{ - ZoneID: cloudflare.F("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/zonesettingfontsetting.go b/zonesettingfontsetting.go deleted file mode 100644 index 2134f948a81..00000000000 --- a/zonesettingfontsetting.go +++ /dev/null @@ -1,359 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingFontSettingService 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 [NewZoneSettingFontSettingService] -// method instead. -type ZoneSettingFontSettingService struct { - Options []option.RequestOption -} - -// NewZoneSettingFontSettingService 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 NewZoneSettingFontSettingService(opts ...option.RequestOption) (r *ZoneSettingFontSettingService) { - r = &ZoneSettingFontSettingService{} - r.Options = opts - return -} - -// Enhance your website's font delivery with Cloudflare Fonts. Deliver Google -// Hosted fonts from your own domain, boost performance, and enhance user privacy. -// Refer to the Cloudflare Fonts documentation for more information. -func (r *ZoneSettingFontSettingService) Edit(ctx context.Context, params ZoneSettingFontSettingEditParams, opts ...option.RequestOption) (res *ZoneSettingFontSettingEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingFontSettingEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/fonts", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Enhance your website's font delivery with Cloudflare Fonts. Deliver Google -// Hosted fonts from your own domain, boost performance, and enhance user privacy. -// Refer to the Cloudflare Fonts documentation for more information. -func (r *ZoneSettingFontSettingService) Get(ctx context.Context, query ZoneSettingFontSettingGetParams, opts ...option.RequestOption) (res *ZoneSettingFontSettingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingFontSettingGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/fonts", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Enhance your website's font delivery with Cloudflare Fonts. Deliver Google -// Hosted fonts from your own domain, boost performance, and enhance user privacy. -// Refer to the Cloudflare Fonts documentation for more information. -type ZoneSettingFontSettingEditResponse struct { - // ID of the zone setting. - ID ZoneSettingFontSettingEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingFontSettingEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingFontSettingEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingFontSettingEditResponseJSON `json:"-"` -} - -// zoneSettingFontSettingEditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingFontSettingEditResponse] -type zoneSettingFontSettingEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingFontSettingEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingFontSettingEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingFontSettingEditResponseID string - -const ( - ZoneSettingFontSettingEditResponseIDFonts ZoneSettingFontSettingEditResponseID = "fonts" -) - -// Current value of the zone setting. -type ZoneSettingFontSettingEditResponseValue string - -const ( - ZoneSettingFontSettingEditResponseValueOn ZoneSettingFontSettingEditResponseValue = "on" - ZoneSettingFontSettingEditResponseValueOff ZoneSettingFontSettingEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingFontSettingEditResponseEditable bool - -const ( - ZoneSettingFontSettingEditResponseEditableTrue ZoneSettingFontSettingEditResponseEditable = true - ZoneSettingFontSettingEditResponseEditableFalse ZoneSettingFontSettingEditResponseEditable = false -) - -// Enhance your website's font delivery with Cloudflare Fonts. Deliver Google -// Hosted fonts from your own domain, boost performance, and enhance user privacy. -// Refer to the Cloudflare Fonts documentation for more information. -type ZoneSettingFontSettingGetResponse struct { - // ID of the zone setting. - ID ZoneSettingFontSettingGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingFontSettingGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingFontSettingGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingFontSettingGetResponseJSON `json:"-"` -} - -// zoneSettingFontSettingGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingFontSettingGetResponse] -type zoneSettingFontSettingGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingFontSettingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingFontSettingGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingFontSettingGetResponseID string - -const ( - ZoneSettingFontSettingGetResponseIDFonts ZoneSettingFontSettingGetResponseID = "fonts" -) - -// Current value of the zone setting. -type ZoneSettingFontSettingGetResponseValue string - -const ( - ZoneSettingFontSettingGetResponseValueOn ZoneSettingFontSettingGetResponseValue = "on" - ZoneSettingFontSettingGetResponseValueOff ZoneSettingFontSettingGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingFontSettingGetResponseEditable bool - -const ( - ZoneSettingFontSettingGetResponseEditableTrue ZoneSettingFontSettingGetResponseEditable = true - ZoneSettingFontSettingGetResponseEditableFalse ZoneSettingFontSettingGetResponseEditable = false -) - -type ZoneSettingFontSettingEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Whether the feature is enabled or disabled. - Value param.Field[ZoneSettingFontSettingEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingFontSettingEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Whether the feature is enabled or disabled. -type ZoneSettingFontSettingEditParamsValue string - -const ( - ZoneSettingFontSettingEditParamsValueOn ZoneSettingFontSettingEditParamsValue = "on" - ZoneSettingFontSettingEditParamsValueOff ZoneSettingFontSettingEditParamsValue = "off" -) - -type ZoneSettingFontSettingEditResponseEnvelope struct { - Errors []ZoneSettingFontSettingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingFontSettingEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Enhance your website's font delivery with Cloudflare Fonts. Deliver Google - // Hosted fonts from your own domain, boost performance, and enhance user privacy. - // Refer to the Cloudflare Fonts documentation for more information. - Result ZoneSettingFontSettingEditResponse `json:"result"` - JSON zoneSettingFontSettingEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingFontSettingEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingFontSettingEditResponseEnvelope] -type zoneSettingFontSettingEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingFontSettingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingFontSettingEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingFontSettingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingFontSettingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingFontSettingEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingFontSettingEditResponseEnvelopeErrors] -type zoneSettingFontSettingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingFontSettingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingFontSettingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingFontSettingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingFontSettingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingFontSettingEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingFontSettingEditResponseEnvelopeMessages] -type zoneSettingFontSettingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingFontSettingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingFontSettingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingFontSettingGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingFontSettingGetResponseEnvelope struct { - Errors []ZoneSettingFontSettingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingFontSettingGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Enhance your website's font delivery with Cloudflare Fonts. Deliver Google - // Hosted fonts from your own domain, boost performance, and enhance user privacy. - // Refer to the Cloudflare Fonts documentation for more information. - Result ZoneSettingFontSettingGetResponse `json:"result"` - JSON zoneSettingFontSettingGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingFontSettingGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingFontSettingGetResponseEnvelope] -type zoneSettingFontSettingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingFontSettingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingFontSettingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingFontSettingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingFontSettingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingFontSettingGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingFontSettingGetResponseEnvelopeErrors] -type zoneSettingFontSettingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingFontSettingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingFontSettingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingFontSettingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingFontSettingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingFontSettingGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZoneSettingFontSettingGetResponseEnvelopeMessages] -type zoneSettingFontSettingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingFontSettingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingFontSettingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingfontsetting_test.go b/zonesettingfontsetting_test.go deleted file mode 100644 index fb98853bd04..00000000000 --- a/zonesettingfontsetting_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingFontSettingEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.FontSettings.Edit(context.TODO(), cloudflare.ZoneSettingFontSettingEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingFontSettingEditParamsValueOn), - }) - 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 TestZoneSettingFontSettingGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.FontSettings.Get(context.TODO(), cloudflare.ZoneSettingFontSettingGetParams{ - ZoneID: cloudflare.F("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/zonesettingh2prioritization.go b/zonesettingh2prioritization.go deleted file mode 100644 index 109677408ac..00000000000 --- a/zonesettingh2prioritization.go +++ /dev/null @@ -1,391 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingH2PrioritizationService 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 -// [NewZoneSettingH2PrioritizationService] method instead. -type ZoneSettingH2PrioritizationService struct { - Options []option.RequestOption -} - -// NewZoneSettingH2PrioritizationService 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 NewZoneSettingH2PrioritizationService(opts ...option.RequestOption) (r *ZoneSettingH2PrioritizationService) { - r = &ZoneSettingH2PrioritizationService{} - r.Options = opts - return -} - -// Gets HTTP/2 Edge Prioritization setting. -func (r *ZoneSettingH2PrioritizationService) Edit(ctx context.Context, params ZoneSettingH2PrioritizationEditParams, opts ...option.RequestOption) (res *ZoneSettingH2PrioritizationEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingH2PrioritizationEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/h2_prioritization", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets HTTP/2 Edge Prioritization setting. -func (r *ZoneSettingH2PrioritizationService) Get(ctx context.Context, query ZoneSettingH2PrioritizationGetParams, opts ...option.RequestOption) (res *ZoneSettingH2PrioritizationGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingH2PrioritizationGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/h2_prioritization", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// HTTP/2 Edge Prioritization optimises the delivery of resources served through -// HTTP/2 to improve page load performance. It also supports fine control of -// content delivery when used in conjunction with Workers. -type ZoneSettingH2PrioritizationEditResponse struct { - // ID of the zone setting. - ID ZoneSettingH2PrioritizationEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingH2PrioritizationEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingH2PrioritizationEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingH2PrioritizationEditResponseJSON `json:"-"` -} - -// zoneSettingH2PrioritizationEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingH2PrioritizationEditResponse] -type zoneSettingH2PrioritizationEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingH2PrioritizationEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingH2PrioritizationEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingH2PrioritizationEditResponseID string - -const ( - ZoneSettingH2PrioritizationEditResponseIDH2Prioritization ZoneSettingH2PrioritizationEditResponseID = "h2_prioritization" -) - -// Current value of the zone setting. -type ZoneSettingH2PrioritizationEditResponseValue string - -const ( - ZoneSettingH2PrioritizationEditResponseValueOn ZoneSettingH2PrioritizationEditResponseValue = "on" - ZoneSettingH2PrioritizationEditResponseValueOff ZoneSettingH2PrioritizationEditResponseValue = "off" - ZoneSettingH2PrioritizationEditResponseValueCustom ZoneSettingH2PrioritizationEditResponseValue = "custom" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingH2PrioritizationEditResponseEditable bool - -const ( - ZoneSettingH2PrioritizationEditResponseEditableTrue ZoneSettingH2PrioritizationEditResponseEditable = true - ZoneSettingH2PrioritizationEditResponseEditableFalse ZoneSettingH2PrioritizationEditResponseEditable = false -) - -// HTTP/2 Edge Prioritization optimises the delivery of resources served through -// HTTP/2 to improve page load performance. It also supports fine control of -// content delivery when used in conjunction with Workers. -type ZoneSettingH2PrioritizationGetResponse struct { - // ID of the zone setting. - ID ZoneSettingH2PrioritizationGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingH2PrioritizationGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingH2PrioritizationGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingH2PrioritizationGetResponseJSON `json:"-"` -} - -// zoneSettingH2PrioritizationGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingH2PrioritizationGetResponse] -type zoneSettingH2PrioritizationGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingH2PrioritizationGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingH2PrioritizationGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingH2PrioritizationGetResponseID string - -const ( - ZoneSettingH2PrioritizationGetResponseIDH2Prioritization ZoneSettingH2PrioritizationGetResponseID = "h2_prioritization" -) - -// Current value of the zone setting. -type ZoneSettingH2PrioritizationGetResponseValue string - -const ( - ZoneSettingH2PrioritizationGetResponseValueOn ZoneSettingH2PrioritizationGetResponseValue = "on" - ZoneSettingH2PrioritizationGetResponseValueOff ZoneSettingH2PrioritizationGetResponseValue = "off" - ZoneSettingH2PrioritizationGetResponseValueCustom ZoneSettingH2PrioritizationGetResponseValue = "custom" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingH2PrioritizationGetResponseEditable bool - -const ( - ZoneSettingH2PrioritizationGetResponseEditableTrue ZoneSettingH2PrioritizationGetResponseEditable = true - ZoneSettingH2PrioritizationGetResponseEditableFalse ZoneSettingH2PrioritizationGetResponseEditable = false -) - -type ZoneSettingH2PrioritizationEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // HTTP/2 Edge Prioritization optimises the delivery of resources served through - // HTTP/2 to improve page load performance. It also supports fine control of - // content delivery when used in conjunction with Workers. - Value param.Field[ZoneSettingH2PrioritizationEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingH2PrioritizationEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// HTTP/2 Edge Prioritization optimises the delivery of resources served through -// HTTP/2 to improve page load performance. It also supports fine control of -// content delivery when used in conjunction with Workers. -type ZoneSettingH2PrioritizationEditParamsValue struct { - // ID of the zone setting. - ID param.Field[ZoneSettingH2PrioritizationEditParamsValueID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingH2PrioritizationEditParamsValueValue] `json:"value,required"` -} - -func (r ZoneSettingH2PrioritizationEditParamsValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// ID of the zone setting. -type ZoneSettingH2PrioritizationEditParamsValueID string - -const ( - ZoneSettingH2PrioritizationEditParamsValueIDH2Prioritization ZoneSettingH2PrioritizationEditParamsValueID = "h2_prioritization" -) - -// Current value of the zone setting. -type ZoneSettingH2PrioritizationEditParamsValueValue string - -const ( - ZoneSettingH2PrioritizationEditParamsValueValueOn ZoneSettingH2PrioritizationEditParamsValueValue = "on" - ZoneSettingH2PrioritizationEditParamsValueValueOff ZoneSettingH2PrioritizationEditParamsValueValue = "off" - ZoneSettingH2PrioritizationEditParamsValueValueCustom ZoneSettingH2PrioritizationEditParamsValueValue = "custom" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingH2PrioritizationEditParamsValueEditable bool - -const ( - ZoneSettingH2PrioritizationEditParamsValueEditableTrue ZoneSettingH2PrioritizationEditParamsValueEditable = true - ZoneSettingH2PrioritizationEditParamsValueEditableFalse ZoneSettingH2PrioritizationEditParamsValueEditable = false -) - -type ZoneSettingH2PrioritizationEditResponseEnvelope struct { - Errors []ZoneSettingH2PrioritizationEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingH2PrioritizationEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // HTTP/2 Edge Prioritization optimises the delivery of resources served through - // HTTP/2 to improve page load performance. It also supports fine control of - // content delivery when used in conjunction with Workers. - Result ZoneSettingH2PrioritizationEditResponse `json:"result"` - JSON zoneSettingH2PrioritizationEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingH2PrioritizationEditResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingH2PrioritizationEditResponseEnvelope] -type zoneSettingH2PrioritizationEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingH2PrioritizationEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingH2PrioritizationEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingH2PrioritizationEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingH2PrioritizationEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingH2PrioritizationEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingH2PrioritizationEditResponseEnvelopeErrors] -type zoneSettingH2PrioritizationEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingH2PrioritizationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingH2PrioritizationEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingH2PrioritizationEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingH2PrioritizationEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingH2PrioritizationEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZoneSettingH2PrioritizationEditResponseEnvelopeMessages] -type zoneSettingH2PrioritizationEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingH2PrioritizationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingH2PrioritizationEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingH2PrioritizationGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingH2PrioritizationGetResponseEnvelope struct { - Errors []ZoneSettingH2PrioritizationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingH2PrioritizationGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // HTTP/2 Edge Prioritization optimises the delivery of resources served through - // HTTP/2 to improve page load performance. It also supports fine control of - // content delivery when used in conjunction with Workers. - Result ZoneSettingH2PrioritizationGetResponse `json:"result"` - JSON zoneSettingH2PrioritizationGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingH2PrioritizationGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingH2PrioritizationGetResponseEnvelope] -type zoneSettingH2PrioritizationGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingH2PrioritizationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingH2PrioritizationGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingH2PrioritizationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingH2PrioritizationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingH2PrioritizationGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingH2PrioritizationGetResponseEnvelopeErrors] -type zoneSettingH2PrioritizationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingH2PrioritizationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingH2PrioritizationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingH2PrioritizationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingH2PrioritizationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingH2PrioritizationGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingH2PrioritizationGetResponseEnvelopeMessages] -type zoneSettingH2PrioritizationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingH2PrioritizationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingH2PrioritizationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingh2prioritization_test.go b/zonesettingh2prioritization_test.go deleted file mode 100644 index 55f925757db..00000000000 --- a/zonesettingh2prioritization_test.go +++ /dev/null @@ -1,70 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingH2PrioritizationEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Zones.Settings.H2Prioritization.Edit(context.TODO(), cloudflare.ZoneSettingH2PrioritizationEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingH2PrioritizationEditParamsValue{ - ID: cloudflare.F(cloudflare.ZoneSettingH2PrioritizationEditParamsValueIDH2Prioritization), - Value: cloudflare.F(cloudflare.ZoneSettingH2PrioritizationEditParamsValueValueOn), - }), - }) - 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 TestZoneSettingH2PrioritizationGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.H2Prioritization.Get(context.TODO(), cloudflare.ZoneSettingH2PrioritizationGetParams{ - ZoneID: cloudflare.F("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/zonesettinghotlinkprotection.go b/zonesettinghotlinkprotection.go deleted file mode 100644 index 738038ae615..00000000000 --- a/zonesettinghotlinkprotection.go +++ /dev/null @@ -1,385 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingHotlinkProtectionService 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 -// [NewZoneSettingHotlinkProtectionService] method instead. -type ZoneSettingHotlinkProtectionService struct { - Options []option.RequestOption -} - -// NewZoneSettingHotlinkProtectionService 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 NewZoneSettingHotlinkProtectionService(opts ...option.RequestOption) (r *ZoneSettingHotlinkProtectionService) { - r = &ZoneSettingHotlinkProtectionService{} - r.Options = opts - return -} - -// When enabled, the Hotlink Protection option ensures that other sites cannot suck -// up your bandwidth by building pages that use images hosted on your site. Anytime -// a request for an image on your site hits Cloudflare, we check to ensure that -// it's not another site requesting them. People will still be able to download and -// view images from your page, but other sites won't be able to steal them for use -// on their own pages. -// (https://support.cloudflare.com/hc/en-us/articles/200170026). -func (r *ZoneSettingHotlinkProtectionService) Edit(ctx context.Context, params ZoneSettingHotlinkProtectionEditParams, opts ...option.RequestOption) (res *ZoneSettingHotlinkProtectionEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingHotlinkProtectionEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/hotlink_protection", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// When enabled, the Hotlink Protection option ensures that other sites cannot suck -// up your bandwidth by building pages that use images hosted on your site. Anytime -// a request for an image on your site hits Cloudflare, we check to ensure that -// it's not another site requesting them. People will still be able to download and -// view images from your page, but other sites won't be able to steal them for use -// on their own pages. -// (https://support.cloudflare.com/hc/en-us/articles/200170026). -func (r *ZoneSettingHotlinkProtectionService) Get(ctx context.Context, query ZoneSettingHotlinkProtectionGetParams, opts ...option.RequestOption) (res *ZoneSettingHotlinkProtectionGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingHotlinkProtectionGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/hotlink_protection", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// When enabled, the Hotlink Protection option ensures that other sites cannot suck -// up your bandwidth by building pages that use images hosted on your site. Anytime -// a request for an image on your site hits Cloudflare, we check to ensure that -// it's not another site requesting them. People will still be able to download and -// view images from your page, but other sites won't be able to steal them for use -// on their own pages. -// (https://support.cloudflare.com/hc/en-us/articles/200170026). -type ZoneSettingHotlinkProtectionEditResponse struct { - // ID of the zone setting. - ID ZoneSettingHotlinkProtectionEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingHotlinkProtectionEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingHotlinkProtectionEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingHotlinkProtectionEditResponseJSON `json:"-"` -} - -// zoneSettingHotlinkProtectionEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingHotlinkProtectionEditResponse] -type zoneSettingHotlinkProtectionEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHotlinkProtectionEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHotlinkProtectionEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingHotlinkProtectionEditResponseID string - -const ( - ZoneSettingHotlinkProtectionEditResponseIDHotlinkProtection ZoneSettingHotlinkProtectionEditResponseID = "hotlink_protection" -) - -// Current value of the zone setting. -type ZoneSettingHotlinkProtectionEditResponseValue string - -const ( - ZoneSettingHotlinkProtectionEditResponseValueOn ZoneSettingHotlinkProtectionEditResponseValue = "on" - ZoneSettingHotlinkProtectionEditResponseValueOff ZoneSettingHotlinkProtectionEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingHotlinkProtectionEditResponseEditable bool - -const ( - ZoneSettingHotlinkProtectionEditResponseEditableTrue ZoneSettingHotlinkProtectionEditResponseEditable = true - ZoneSettingHotlinkProtectionEditResponseEditableFalse ZoneSettingHotlinkProtectionEditResponseEditable = false -) - -// When enabled, the Hotlink Protection option ensures that other sites cannot suck -// up your bandwidth by building pages that use images hosted on your site. Anytime -// a request for an image on your site hits Cloudflare, we check to ensure that -// it's not another site requesting them. People will still be able to download and -// view images from your page, but other sites won't be able to steal them for use -// on their own pages. -// (https://support.cloudflare.com/hc/en-us/articles/200170026). -type ZoneSettingHotlinkProtectionGetResponse struct { - // ID of the zone setting. - ID ZoneSettingHotlinkProtectionGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingHotlinkProtectionGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingHotlinkProtectionGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingHotlinkProtectionGetResponseJSON `json:"-"` -} - -// zoneSettingHotlinkProtectionGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingHotlinkProtectionGetResponse] -type zoneSettingHotlinkProtectionGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHotlinkProtectionGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHotlinkProtectionGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingHotlinkProtectionGetResponseID string - -const ( - ZoneSettingHotlinkProtectionGetResponseIDHotlinkProtection ZoneSettingHotlinkProtectionGetResponseID = "hotlink_protection" -) - -// Current value of the zone setting. -type ZoneSettingHotlinkProtectionGetResponseValue string - -const ( - ZoneSettingHotlinkProtectionGetResponseValueOn ZoneSettingHotlinkProtectionGetResponseValue = "on" - ZoneSettingHotlinkProtectionGetResponseValueOff ZoneSettingHotlinkProtectionGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingHotlinkProtectionGetResponseEditable bool - -const ( - ZoneSettingHotlinkProtectionGetResponseEditableTrue ZoneSettingHotlinkProtectionGetResponseEditable = true - ZoneSettingHotlinkProtectionGetResponseEditableFalse ZoneSettingHotlinkProtectionGetResponseEditable = false -) - -type ZoneSettingHotlinkProtectionEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingHotlinkProtectionEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingHotlinkProtectionEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingHotlinkProtectionEditParamsValue string - -const ( - ZoneSettingHotlinkProtectionEditParamsValueOn ZoneSettingHotlinkProtectionEditParamsValue = "on" - ZoneSettingHotlinkProtectionEditParamsValueOff ZoneSettingHotlinkProtectionEditParamsValue = "off" -) - -type ZoneSettingHotlinkProtectionEditResponseEnvelope struct { - Errors []ZoneSettingHotlinkProtectionEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingHotlinkProtectionEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // When enabled, the Hotlink Protection option ensures that other sites cannot suck - // up your bandwidth by building pages that use images hosted on your site. Anytime - // a request for an image on your site hits Cloudflare, we check to ensure that - // it's not another site requesting them. People will still be able to download and - // view images from your page, but other sites won't be able to steal them for use - // on their own pages. - // (https://support.cloudflare.com/hc/en-us/articles/200170026). - Result ZoneSettingHotlinkProtectionEditResponse `json:"result"` - JSON zoneSettingHotlinkProtectionEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingHotlinkProtectionEditResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingHotlinkProtectionEditResponseEnvelope] -type zoneSettingHotlinkProtectionEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHotlinkProtectionEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHotlinkProtectionEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingHotlinkProtectionEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingHotlinkProtectionEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingHotlinkProtectionEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingHotlinkProtectionEditResponseEnvelopeErrors] -type zoneSettingHotlinkProtectionEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHotlinkProtectionEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHotlinkProtectionEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingHotlinkProtectionEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingHotlinkProtectionEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingHotlinkProtectionEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZoneSettingHotlinkProtectionEditResponseEnvelopeMessages] -type zoneSettingHotlinkProtectionEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHotlinkProtectionEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHotlinkProtectionEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingHotlinkProtectionGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingHotlinkProtectionGetResponseEnvelope struct { - Errors []ZoneSettingHotlinkProtectionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingHotlinkProtectionGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // When enabled, the Hotlink Protection option ensures that other sites cannot suck - // up your bandwidth by building pages that use images hosted on your site. Anytime - // a request for an image on your site hits Cloudflare, we check to ensure that - // it's not another site requesting them. People will still be able to download and - // view images from your page, but other sites won't be able to steal them for use - // on their own pages. - // (https://support.cloudflare.com/hc/en-us/articles/200170026). - Result ZoneSettingHotlinkProtectionGetResponse `json:"result"` - JSON zoneSettingHotlinkProtectionGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingHotlinkProtectionGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingHotlinkProtectionGetResponseEnvelope] -type zoneSettingHotlinkProtectionGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHotlinkProtectionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHotlinkProtectionGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingHotlinkProtectionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingHotlinkProtectionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingHotlinkProtectionGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingHotlinkProtectionGetResponseEnvelopeErrors] -type zoneSettingHotlinkProtectionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHotlinkProtectionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHotlinkProtectionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingHotlinkProtectionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingHotlinkProtectionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingHotlinkProtectionGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZoneSettingHotlinkProtectionGetResponseEnvelopeMessages] -type zoneSettingHotlinkProtectionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHotlinkProtectionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHotlinkProtectionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettinghotlinkprotection_test.go b/zonesettinghotlinkprotection_test.go deleted file mode 100644 index ce5ee972f79..00000000000 --- a/zonesettinghotlinkprotection_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingHotlinkProtectionEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.HotlinkProtection.Edit(context.TODO(), cloudflare.ZoneSettingHotlinkProtectionEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingHotlinkProtectionEditParamsValueOn), - }) - 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 TestZoneSettingHotlinkProtectionGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.HotlinkProtection.Get(context.TODO(), cloudflare.ZoneSettingHotlinkProtectionGetParams{ - ZoneID: cloudflare.F("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/zonesettinghttp2.go b/zonesettinghttp2.go deleted file mode 100644 index 3ec3ac7225b..00000000000 --- a/zonesettinghttp2.go +++ /dev/null @@ -1,347 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingHTTP2Service 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 [NewZoneSettingHTTP2Service] method -// instead. -type ZoneSettingHTTP2Service struct { - Options []option.RequestOption -} - -// NewZoneSettingHTTP2Service 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 NewZoneSettingHTTP2Service(opts ...option.RequestOption) (r *ZoneSettingHTTP2Service) { - r = &ZoneSettingHTTP2Service{} - r.Options = opts - return -} - -// Value of the HTTP2 setting. -func (r *ZoneSettingHTTP2Service) Edit(ctx context.Context, params ZoneSettingHTTP2EditParams, opts ...option.RequestOption) (res *ZoneSettingHTTP2EditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingHTTP2EditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/http2", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Value of the HTTP2 setting. -func (r *ZoneSettingHTTP2Service) Get(ctx context.Context, query ZoneSettingHTTP2GetParams, opts ...option.RequestOption) (res *ZoneSettingHTTP2GetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingHTTP2GetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/http2", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// HTTP2 enabled for this zone. -type ZoneSettingHTTP2EditResponse struct { - // ID of the zone setting. - ID ZoneSettingHTTP2EditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingHTTP2EditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingHTTP2EditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingHTTP2EditResponseJSON `json:"-"` -} - -// zoneSettingHTTP2EditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingHTTP2EditResponse] -type zoneSettingHTTP2EditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHTTP2EditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHTTP2EditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingHTTP2EditResponseID string - -const ( - ZoneSettingHTTP2EditResponseIDHTTP2 ZoneSettingHTTP2EditResponseID = "http2" -) - -// Current value of the zone setting. -type ZoneSettingHTTP2EditResponseValue string - -const ( - ZoneSettingHTTP2EditResponseValueOn ZoneSettingHTTP2EditResponseValue = "on" - ZoneSettingHTTP2EditResponseValueOff ZoneSettingHTTP2EditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingHTTP2EditResponseEditable bool - -const ( - ZoneSettingHTTP2EditResponseEditableTrue ZoneSettingHTTP2EditResponseEditable = true - ZoneSettingHTTP2EditResponseEditableFalse ZoneSettingHTTP2EditResponseEditable = false -) - -// HTTP2 enabled for this zone. -type ZoneSettingHTTP2GetResponse struct { - // ID of the zone setting. - ID ZoneSettingHTTP2GetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingHTTP2GetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingHTTP2GetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingHTTP2GetResponseJSON `json:"-"` -} - -// zoneSettingHTTP2GetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingHTTP2GetResponse] -type zoneSettingHTTP2GetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHTTP2GetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHTTP2GetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingHTTP2GetResponseID string - -const ( - ZoneSettingHTTP2GetResponseIDHTTP2 ZoneSettingHTTP2GetResponseID = "http2" -) - -// Current value of the zone setting. -type ZoneSettingHTTP2GetResponseValue string - -const ( - ZoneSettingHTTP2GetResponseValueOn ZoneSettingHTTP2GetResponseValue = "on" - ZoneSettingHTTP2GetResponseValueOff ZoneSettingHTTP2GetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingHTTP2GetResponseEditable bool - -const ( - ZoneSettingHTTP2GetResponseEditableTrue ZoneSettingHTTP2GetResponseEditable = true - ZoneSettingHTTP2GetResponseEditableFalse ZoneSettingHTTP2GetResponseEditable = false -) - -type ZoneSettingHTTP2EditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the HTTP2 setting. - Value param.Field[ZoneSettingHTTP2EditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingHTTP2EditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the HTTP2 setting. -type ZoneSettingHTTP2EditParamsValue string - -const ( - ZoneSettingHTTP2EditParamsValueOn ZoneSettingHTTP2EditParamsValue = "on" - ZoneSettingHTTP2EditParamsValueOff ZoneSettingHTTP2EditParamsValue = "off" -) - -type ZoneSettingHTTP2EditResponseEnvelope struct { - Errors []ZoneSettingHTTP2EditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingHTTP2EditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // HTTP2 enabled for this zone. - Result ZoneSettingHTTP2EditResponse `json:"result"` - JSON zoneSettingHTTP2EditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingHTTP2EditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingHTTP2EditResponseEnvelope] -type zoneSettingHTTP2EditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHTTP2EditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHTTP2EditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingHTTP2EditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingHTTP2EditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingHTTP2EditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSettingHTTP2EditResponseEnvelopeErrors] -type zoneSettingHTTP2EditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHTTP2EditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHTTP2EditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingHTTP2EditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingHTTP2EditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingHTTP2EditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingHTTP2EditResponseEnvelopeMessages] -type zoneSettingHTTP2EditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHTTP2EditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHTTP2EditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingHTTP2GetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingHTTP2GetResponseEnvelope struct { - Errors []ZoneSettingHTTP2GetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingHTTP2GetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // HTTP2 enabled for this zone. - Result ZoneSettingHTTP2GetResponse `json:"result"` - JSON zoneSettingHTTP2GetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingHTTP2GetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingHTTP2GetResponseEnvelope] -type zoneSettingHTTP2GetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHTTP2GetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHTTP2GetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingHTTP2GetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingHTTP2GetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingHTTP2GetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZoneSettingHTTP2GetResponseEnvelopeErrors] -type zoneSettingHTTP2GetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHTTP2GetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHTTP2GetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingHTTP2GetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingHTTP2GetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingHTTP2GetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingHTTP2GetResponseEnvelopeMessages] -type zoneSettingHTTP2GetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHTTP2GetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHTTP2GetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettinghttp2_test.go b/zonesettinghttp2_test.go deleted file mode 100644 index a89971f6b53..00000000000 --- a/zonesettinghttp2_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingHTTP2Edit(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("user@example.com"), - ) - _, err := client.Zones.Settings.HTTP2.Edit(context.TODO(), cloudflare.ZoneSettingHTTP2EditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingHTTP2EditParamsValueOn), - }) - 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 TestZoneSettingHTTP2Get(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("user@example.com"), - ) - _, err := client.Zones.Settings.HTTP2.Get(context.TODO(), cloudflare.ZoneSettingHTTP2GetParams{ - ZoneID: cloudflare.F("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/zonesettinghttp3.go b/zonesettinghttp3.go deleted file mode 100644 index 72af4e6d16c..00000000000 --- a/zonesettinghttp3.go +++ /dev/null @@ -1,347 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingHTTP3Service 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 [NewZoneSettingHTTP3Service] method -// instead. -type ZoneSettingHTTP3Service struct { - Options []option.RequestOption -} - -// NewZoneSettingHTTP3Service 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 NewZoneSettingHTTP3Service(opts ...option.RequestOption) (r *ZoneSettingHTTP3Service) { - r = &ZoneSettingHTTP3Service{} - r.Options = opts - return -} - -// Value of the HTTP3 setting. -func (r *ZoneSettingHTTP3Service) Edit(ctx context.Context, params ZoneSettingHTTP3EditParams, opts ...option.RequestOption) (res *ZoneSettingHTTP3EditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingHTTP3EditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/http3", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Value of the HTTP3 setting. -func (r *ZoneSettingHTTP3Service) Get(ctx context.Context, query ZoneSettingHTTP3GetParams, opts ...option.RequestOption) (res *ZoneSettingHTTP3GetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingHTTP3GetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/http3", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// HTTP3 enabled for this zone. -type ZoneSettingHTTP3EditResponse struct { - // ID of the zone setting. - ID ZoneSettingHTTP3EditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingHTTP3EditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingHTTP3EditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingHTTP3EditResponseJSON `json:"-"` -} - -// zoneSettingHTTP3EditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingHTTP3EditResponse] -type zoneSettingHTTP3EditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHTTP3EditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHTTP3EditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingHTTP3EditResponseID string - -const ( - ZoneSettingHTTP3EditResponseIDHTTP3 ZoneSettingHTTP3EditResponseID = "http3" -) - -// Current value of the zone setting. -type ZoneSettingHTTP3EditResponseValue string - -const ( - ZoneSettingHTTP3EditResponseValueOn ZoneSettingHTTP3EditResponseValue = "on" - ZoneSettingHTTP3EditResponseValueOff ZoneSettingHTTP3EditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingHTTP3EditResponseEditable bool - -const ( - ZoneSettingHTTP3EditResponseEditableTrue ZoneSettingHTTP3EditResponseEditable = true - ZoneSettingHTTP3EditResponseEditableFalse ZoneSettingHTTP3EditResponseEditable = false -) - -// HTTP3 enabled for this zone. -type ZoneSettingHTTP3GetResponse struct { - // ID of the zone setting. - ID ZoneSettingHTTP3GetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingHTTP3GetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingHTTP3GetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingHTTP3GetResponseJSON `json:"-"` -} - -// zoneSettingHTTP3GetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingHTTP3GetResponse] -type zoneSettingHTTP3GetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHTTP3GetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHTTP3GetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingHTTP3GetResponseID string - -const ( - ZoneSettingHTTP3GetResponseIDHTTP3 ZoneSettingHTTP3GetResponseID = "http3" -) - -// Current value of the zone setting. -type ZoneSettingHTTP3GetResponseValue string - -const ( - ZoneSettingHTTP3GetResponseValueOn ZoneSettingHTTP3GetResponseValue = "on" - ZoneSettingHTTP3GetResponseValueOff ZoneSettingHTTP3GetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingHTTP3GetResponseEditable bool - -const ( - ZoneSettingHTTP3GetResponseEditableTrue ZoneSettingHTTP3GetResponseEditable = true - ZoneSettingHTTP3GetResponseEditableFalse ZoneSettingHTTP3GetResponseEditable = false -) - -type ZoneSettingHTTP3EditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the HTTP3 setting. - Value param.Field[ZoneSettingHTTP3EditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingHTTP3EditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the HTTP3 setting. -type ZoneSettingHTTP3EditParamsValue string - -const ( - ZoneSettingHTTP3EditParamsValueOn ZoneSettingHTTP3EditParamsValue = "on" - ZoneSettingHTTP3EditParamsValueOff ZoneSettingHTTP3EditParamsValue = "off" -) - -type ZoneSettingHTTP3EditResponseEnvelope struct { - Errors []ZoneSettingHTTP3EditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingHTTP3EditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // HTTP3 enabled for this zone. - Result ZoneSettingHTTP3EditResponse `json:"result"` - JSON zoneSettingHTTP3EditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingHTTP3EditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingHTTP3EditResponseEnvelope] -type zoneSettingHTTP3EditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHTTP3EditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHTTP3EditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingHTTP3EditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingHTTP3EditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingHTTP3EditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSettingHTTP3EditResponseEnvelopeErrors] -type zoneSettingHTTP3EditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHTTP3EditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHTTP3EditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingHTTP3EditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingHTTP3EditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingHTTP3EditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingHTTP3EditResponseEnvelopeMessages] -type zoneSettingHTTP3EditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHTTP3EditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHTTP3EditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingHTTP3GetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingHTTP3GetResponseEnvelope struct { - Errors []ZoneSettingHTTP3GetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingHTTP3GetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // HTTP3 enabled for this zone. - Result ZoneSettingHTTP3GetResponse `json:"result"` - JSON zoneSettingHTTP3GetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingHTTP3GetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingHTTP3GetResponseEnvelope] -type zoneSettingHTTP3GetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHTTP3GetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHTTP3GetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingHTTP3GetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingHTTP3GetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingHTTP3GetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZoneSettingHTTP3GetResponseEnvelopeErrors] -type zoneSettingHTTP3GetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHTTP3GetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHTTP3GetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingHTTP3GetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingHTTP3GetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingHTTP3GetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingHTTP3GetResponseEnvelopeMessages] -type zoneSettingHTTP3GetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingHTTP3GetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingHTTP3GetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettinghttp3_test.go b/zonesettinghttp3_test.go deleted file mode 100644 index d6a42f42e4c..00000000000 --- a/zonesettinghttp3_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingHTTP3Edit(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("user@example.com"), - ) - _, err := client.Zones.Settings.HTTP3.Edit(context.TODO(), cloudflare.ZoneSettingHTTP3EditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingHTTP3EditParamsValueOn), - }) - 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 TestZoneSettingHTTP3Get(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("user@example.com"), - ) - _, err := client.Zones.Settings.HTTP3.Get(context.TODO(), cloudflare.ZoneSettingHTTP3GetParams{ - ZoneID: cloudflare.F("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/zonesettingimageresizing.go b/zonesettingimageresizing.go deleted file mode 100644 index 6ea7cee64ac..00000000000 --- a/zonesettingimageresizing.go +++ /dev/null @@ -1,402 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingImageResizingService 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 -// [NewZoneSettingImageResizingService] method instead. -type ZoneSettingImageResizingService struct { - Options []option.RequestOption -} - -// NewZoneSettingImageResizingService 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 NewZoneSettingImageResizingService(opts ...option.RequestOption) (r *ZoneSettingImageResizingService) { - r = &ZoneSettingImageResizingService{} - r.Options = opts - return -} - -// Image Resizing provides on-demand resizing, conversion and optimisation for -// images served through Cloudflare's network. Refer to the -// [Image Resizing documentation](https://developers.cloudflare.com/images/) for -// more information. -func (r *ZoneSettingImageResizingService) Edit(ctx context.Context, params ZoneSettingImageResizingEditParams, opts ...option.RequestOption) (res *ZoneSettingImageResizingEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingImageResizingEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/image_resizing", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Image Resizing provides on-demand resizing, conversion and optimisation for -// images served through Cloudflare's network. Refer to the -// [Image Resizing documentation](https://developers.cloudflare.com/images/) for -// more information. -func (r *ZoneSettingImageResizingService) Get(ctx context.Context, query ZoneSettingImageResizingGetParams, opts ...option.RequestOption) (res *ZoneSettingImageResizingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingImageResizingGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/image_resizing", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Image Resizing provides on-demand resizing, conversion and optimisation for -// images served through Cloudflare's network. Refer to the -// [Image Resizing documentation](https://developers.cloudflare.com/images/) for -// more information. -type ZoneSettingImageResizingEditResponse struct { - // ID of the zone setting. - ID ZoneSettingImageResizingEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingImageResizingEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingImageResizingEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingImageResizingEditResponseJSON `json:"-"` -} - -// zoneSettingImageResizingEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingImageResizingEditResponse] -type zoneSettingImageResizingEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingImageResizingEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingImageResizingEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingImageResizingEditResponseID string - -const ( - ZoneSettingImageResizingEditResponseIDImageResizing ZoneSettingImageResizingEditResponseID = "image_resizing" -) - -// Current value of the zone setting. -type ZoneSettingImageResizingEditResponseValue string - -const ( - ZoneSettingImageResizingEditResponseValueOn ZoneSettingImageResizingEditResponseValue = "on" - ZoneSettingImageResizingEditResponseValueOff ZoneSettingImageResizingEditResponseValue = "off" - ZoneSettingImageResizingEditResponseValueOpen ZoneSettingImageResizingEditResponseValue = "open" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingImageResizingEditResponseEditable bool - -const ( - ZoneSettingImageResizingEditResponseEditableTrue ZoneSettingImageResizingEditResponseEditable = true - ZoneSettingImageResizingEditResponseEditableFalse ZoneSettingImageResizingEditResponseEditable = false -) - -// Image Resizing provides on-demand resizing, conversion and optimisation for -// images served through Cloudflare's network. Refer to the -// [Image Resizing documentation](https://developers.cloudflare.com/images/) for -// more information. -type ZoneSettingImageResizingGetResponse struct { - // ID of the zone setting. - ID ZoneSettingImageResizingGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingImageResizingGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingImageResizingGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingImageResizingGetResponseJSON `json:"-"` -} - -// zoneSettingImageResizingGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingImageResizingGetResponse] -type zoneSettingImageResizingGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingImageResizingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingImageResizingGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingImageResizingGetResponseID string - -const ( - ZoneSettingImageResizingGetResponseIDImageResizing ZoneSettingImageResizingGetResponseID = "image_resizing" -) - -// Current value of the zone setting. -type ZoneSettingImageResizingGetResponseValue string - -const ( - ZoneSettingImageResizingGetResponseValueOn ZoneSettingImageResizingGetResponseValue = "on" - ZoneSettingImageResizingGetResponseValueOff ZoneSettingImageResizingGetResponseValue = "off" - ZoneSettingImageResizingGetResponseValueOpen ZoneSettingImageResizingGetResponseValue = "open" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingImageResizingGetResponseEditable bool - -const ( - ZoneSettingImageResizingGetResponseEditableTrue ZoneSettingImageResizingGetResponseEditable = true - ZoneSettingImageResizingGetResponseEditableFalse ZoneSettingImageResizingGetResponseEditable = false -) - -type ZoneSettingImageResizingEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Image Resizing provides on-demand resizing, conversion and optimisation for - // images served through Cloudflare's network. Refer to the - // [Image Resizing documentation](https://developers.cloudflare.com/images/) for - // more information. - Value param.Field[ZoneSettingImageResizingEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingImageResizingEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Image Resizing provides on-demand resizing, conversion and optimisation for -// images served through Cloudflare's network. Refer to the -// [Image Resizing documentation](https://developers.cloudflare.com/images/) for -// more information. -type ZoneSettingImageResizingEditParamsValue struct { - // ID of the zone setting. - ID param.Field[ZoneSettingImageResizingEditParamsValueID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingImageResizingEditParamsValueValue] `json:"value,required"` -} - -func (r ZoneSettingImageResizingEditParamsValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// ID of the zone setting. -type ZoneSettingImageResizingEditParamsValueID string - -const ( - ZoneSettingImageResizingEditParamsValueIDImageResizing ZoneSettingImageResizingEditParamsValueID = "image_resizing" -) - -// Current value of the zone setting. -type ZoneSettingImageResizingEditParamsValueValue string - -const ( - ZoneSettingImageResizingEditParamsValueValueOn ZoneSettingImageResizingEditParamsValueValue = "on" - ZoneSettingImageResizingEditParamsValueValueOff ZoneSettingImageResizingEditParamsValueValue = "off" - ZoneSettingImageResizingEditParamsValueValueOpen ZoneSettingImageResizingEditParamsValueValue = "open" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingImageResizingEditParamsValueEditable bool - -const ( - ZoneSettingImageResizingEditParamsValueEditableTrue ZoneSettingImageResizingEditParamsValueEditable = true - ZoneSettingImageResizingEditParamsValueEditableFalse ZoneSettingImageResizingEditParamsValueEditable = false -) - -type ZoneSettingImageResizingEditResponseEnvelope struct { - Errors []ZoneSettingImageResizingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingImageResizingEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Image Resizing provides on-demand resizing, conversion and optimisation for - // images served through Cloudflare's network. Refer to the - // [Image Resizing documentation](https://developers.cloudflare.com/images/) for - // more information. - Result ZoneSettingImageResizingEditResponse `json:"result"` - JSON zoneSettingImageResizingEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingImageResizingEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingImageResizingEditResponseEnvelope] -type zoneSettingImageResizingEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingImageResizingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingImageResizingEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingImageResizingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingImageResizingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingImageResizingEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingImageResizingEditResponseEnvelopeErrors] -type zoneSettingImageResizingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingImageResizingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingImageResizingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingImageResizingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingImageResizingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingImageResizingEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingImageResizingEditResponseEnvelopeMessages] -type zoneSettingImageResizingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingImageResizingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingImageResizingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingImageResizingGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingImageResizingGetResponseEnvelope struct { - Errors []ZoneSettingImageResizingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingImageResizingGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Image Resizing provides on-demand resizing, conversion and optimisation for - // images served through Cloudflare's network. Refer to the - // [Image Resizing documentation](https://developers.cloudflare.com/images/) for - // more information. - Result ZoneSettingImageResizingGetResponse `json:"result"` - JSON zoneSettingImageResizingGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingImageResizingGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingImageResizingGetResponseEnvelope] -type zoneSettingImageResizingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingImageResizingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingImageResizingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingImageResizingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingImageResizingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingImageResizingGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingImageResizingGetResponseEnvelopeErrors] -type zoneSettingImageResizingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingImageResizingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingImageResizingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingImageResizingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingImageResizingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingImageResizingGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingImageResizingGetResponseEnvelopeMessages] -type zoneSettingImageResizingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingImageResizingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingImageResizingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingimageresizing_test.go b/zonesettingimageresizing_test.go deleted file mode 100644 index fac97524748..00000000000 --- a/zonesettingimageresizing_test.go +++ /dev/null @@ -1,70 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingImageResizingEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Zones.Settings.ImageResizing.Edit(context.TODO(), cloudflare.ZoneSettingImageResizingEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingImageResizingEditParamsValue{ - ID: cloudflare.F(cloudflare.ZoneSettingImageResizingEditParamsValueIDImageResizing), - Value: cloudflare.F(cloudflare.ZoneSettingImageResizingEditParamsValueValueOn), - }), - }) - 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 TestZoneSettingImageResizingGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.ImageResizing.Get(context.TODO(), cloudflare.ZoneSettingImageResizingGetParams{ - ZoneID: cloudflare.F("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/zonesettingipgeolocation.go b/zonesettingipgeolocation.go deleted file mode 100644 index c6a22ce9699..00000000000 --- a/zonesettingipgeolocation.go +++ /dev/null @@ -1,359 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingIPGeolocationService 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 -// [NewZoneSettingIPGeolocationService] method instead. -type ZoneSettingIPGeolocationService struct { - Options []option.RequestOption -} - -// NewZoneSettingIPGeolocationService 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 NewZoneSettingIPGeolocationService(opts ...option.RequestOption) (r *ZoneSettingIPGeolocationService) { - r = &ZoneSettingIPGeolocationService{} - r.Options = opts - return -} - -// Enable IP Geolocation to have Cloudflare geolocate visitors to your website and -// pass the country code to you. -// (https://support.cloudflare.com/hc/en-us/articles/200168236). -func (r *ZoneSettingIPGeolocationService) Edit(ctx context.Context, params ZoneSettingIPGeolocationEditParams, opts ...option.RequestOption) (res *ZoneSettingIPGeolocationEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingIPGeolocationEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/ip_geolocation", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Enable IP Geolocation to have Cloudflare geolocate visitors to your website and -// pass the country code to you. -// (https://support.cloudflare.com/hc/en-us/articles/200168236). -func (r *ZoneSettingIPGeolocationService) Get(ctx context.Context, query ZoneSettingIPGeolocationGetParams, opts ...option.RequestOption) (res *ZoneSettingIPGeolocationGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingIPGeolocationGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/ip_geolocation", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Enable IP Geolocation to have Cloudflare geolocate visitors to your website and -// pass the country code to you. -// (https://support.cloudflare.com/hc/en-us/articles/200168236). -type ZoneSettingIPGeolocationEditResponse struct { - // ID of the zone setting. - ID ZoneSettingIPGeolocationEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingIPGeolocationEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingIPGeolocationEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingIPGeolocationEditResponseJSON `json:"-"` -} - -// zoneSettingIPGeolocationEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingIPGeolocationEditResponse] -type zoneSettingIPGeolocationEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingIPGeolocationEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingIPGeolocationEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingIPGeolocationEditResponseID string - -const ( - ZoneSettingIPGeolocationEditResponseIDIPGeolocation ZoneSettingIPGeolocationEditResponseID = "ip_geolocation" -) - -// Current value of the zone setting. -type ZoneSettingIPGeolocationEditResponseValue string - -const ( - ZoneSettingIPGeolocationEditResponseValueOn ZoneSettingIPGeolocationEditResponseValue = "on" - ZoneSettingIPGeolocationEditResponseValueOff ZoneSettingIPGeolocationEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingIPGeolocationEditResponseEditable bool - -const ( - ZoneSettingIPGeolocationEditResponseEditableTrue ZoneSettingIPGeolocationEditResponseEditable = true - ZoneSettingIPGeolocationEditResponseEditableFalse ZoneSettingIPGeolocationEditResponseEditable = false -) - -// Enable IP Geolocation to have Cloudflare geolocate visitors to your website and -// pass the country code to you. -// (https://support.cloudflare.com/hc/en-us/articles/200168236). -type ZoneSettingIPGeolocationGetResponse struct { - // ID of the zone setting. - ID ZoneSettingIPGeolocationGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingIPGeolocationGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingIPGeolocationGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingIPGeolocationGetResponseJSON `json:"-"` -} - -// zoneSettingIPGeolocationGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingIPGeolocationGetResponse] -type zoneSettingIPGeolocationGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingIPGeolocationGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingIPGeolocationGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingIPGeolocationGetResponseID string - -const ( - ZoneSettingIPGeolocationGetResponseIDIPGeolocation ZoneSettingIPGeolocationGetResponseID = "ip_geolocation" -) - -// Current value of the zone setting. -type ZoneSettingIPGeolocationGetResponseValue string - -const ( - ZoneSettingIPGeolocationGetResponseValueOn ZoneSettingIPGeolocationGetResponseValue = "on" - ZoneSettingIPGeolocationGetResponseValueOff ZoneSettingIPGeolocationGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingIPGeolocationGetResponseEditable bool - -const ( - ZoneSettingIPGeolocationGetResponseEditableTrue ZoneSettingIPGeolocationGetResponseEditable = true - ZoneSettingIPGeolocationGetResponseEditableFalse ZoneSettingIPGeolocationGetResponseEditable = false -) - -type ZoneSettingIPGeolocationEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingIPGeolocationEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingIPGeolocationEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingIPGeolocationEditParamsValue string - -const ( - ZoneSettingIPGeolocationEditParamsValueOn ZoneSettingIPGeolocationEditParamsValue = "on" - ZoneSettingIPGeolocationEditParamsValueOff ZoneSettingIPGeolocationEditParamsValue = "off" -) - -type ZoneSettingIPGeolocationEditResponseEnvelope struct { - Errors []ZoneSettingIPGeolocationEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingIPGeolocationEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Enable IP Geolocation to have Cloudflare geolocate visitors to your website and - // pass the country code to you. - // (https://support.cloudflare.com/hc/en-us/articles/200168236). - Result ZoneSettingIPGeolocationEditResponse `json:"result"` - JSON zoneSettingIPGeolocationEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingIPGeolocationEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingIPGeolocationEditResponseEnvelope] -type zoneSettingIPGeolocationEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingIPGeolocationEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingIPGeolocationEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingIPGeolocationEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingIPGeolocationEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingIPGeolocationEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingIPGeolocationEditResponseEnvelopeErrors] -type zoneSettingIPGeolocationEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingIPGeolocationEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingIPGeolocationEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingIPGeolocationEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingIPGeolocationEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingIPGeolocationEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingIPGeolocationEditResponseEnvelopeMessages] -type zoneSettingIPGeolocationEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingIPGeolocationEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingIPGeolocationEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingIPGeolocationGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingIPGeolocationGetResponseEnvelope struct { - Errors []ZoneSettingIPGeolocationGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingIPGeolocationGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Enable IP Geolocation to have Cloudflare geolocate visitors to your website and - // pass the country code to you. - // (https://support.cloudflare.com/hc/en-us/articles/200168236). - Result ZoneSettingIPGeolocationGetResponse `json:"result"` - JSON zoneSettingIPGeolocationGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingIPGeolocationGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingIPGeolocationGetResponseEnvelope] -type zoneSettingIPGeolocationGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingIPGeolocationGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingIPGeolocationGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingIPGeolocationGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingIPGeolocationGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingIPGeolocationGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingIPGeolocationGetResponseEnvelopeErrors] -type zoneSettingIPGeolocationGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingIPGeolocationGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingIPGeolocationGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingIPGeolocationGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingIPGeolocationGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingIPGeolocationGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingIPGeolocationGetResponseEnvelopeMessages] -type zoneSettingIPGeolocationGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingIPGeolocationGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingIPGeolocationGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingipgeolocation_test.go b/zonesettingipgeolocation_test.go deleted file mode 100644 index 8e36cd1b110..00000000000 --- a/zonesettingipgeolocation_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingIPGeolocationEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.IPGeolocation.Edit(context.TODO(), cloudflare.ZoneSettingIPGeolocationEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingIPGeolocationEditParamsValueOn), - }) - 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 TestZoneSettingIPGeolocationGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.IPGeolocation.Get(context.TODO(), cloudflare.ZoneSettingIPGeolocationGetParams{ - ZoneID: cloudflare.F("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/zonesettingipv6.go b/zonesettingipv6.go deleted file mode 100644 index c5f7c4ddc34..00000000000 --- a/zonesettingipv6.go +++ /dev/null @@ -1,353 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingIPV6Service 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 [NewZoneSettingIPV6Service] method -// instead. -type ZoneSettingIPV6Service struct { - Options []option.RequestOption -} - -// NewZoneSettingIPV6Service 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 NewZoneSettingIPV6Service(opts ...option.RequestOption) (r *ZoneSettingIPV6Service) { - r = &ZoneSettingIPV6Service{} - r.Options = opts - return -} - -// Enable IPv6 on all subdomains that are Cloudflare enabled. -// (https://support.cloudflare.com/hc/en-us/articles/200168586). -func (r *ZoneSettingIPV6Service) Edit(ctx context.Context, params ZoneSettingIPV6EditParams, opts ...option.RequestOption) (res *ZoneSettingIPV6EditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingIPV6EditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/ipv6", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Enable IPv6 on all subdomains that are Cloudflare enabled. -// (https://support.cloudflare.com/hc/en-us/articles/200168586). -func (r *ZoneSettingIPV6Service) Get(ctx context.Context, query ZoneSettingIPV6GetParams, opts ...option.RequestOption) (res *ZoneSettingIPV6GetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingIPV6GetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/ipv6", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Enable IPv6 on all subdomains that are Cloudflare enabled. -// (https://support.cloudflare.com/hc/en-us/articles/200168586). -type ZoneSettingIPV6EditResponse struct { - // ID of the zone setting. - ID ZoneSettingIPV6EditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingIPV6EditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingIPV6EditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingIPV6EditResponseJSON `json:"-"` -} - -// zoneSettingIPV6EditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingIPV6EditResponse] -type zoneSettingIPV6EditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingIPV6EditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingIPV6EditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingIPV6EditResponseID string - -const ( - ZoneSettingIPV6EditResponseIDIPV6 ZoneSettingIPV6EditResponseID = "ipv6" -) - -// Current value of the zone setting. -type ZoneSettingIPV6EditResponseValue string - -const ( - ZoneSettingIPV6EditResponseValueOff ZoneSettingIPV6EditResponseValue = "off" - ZoneSettingIPV6EditResponseValueOn ZoneSettingIPV6EditResponseValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingIPV6EditResponseEditable bool - -const ( - ZoneSettingIPV6EditResponseEditableTrue ZoneSettingIPV6EditResponseEditable = true - ZoneSettingIPV6EditResponseEditableFalse ZoneSettingIPV6EditResponseEditable = false -) - -// Enable IPv6 on all subdomains that are Cloudflare enabled. -// (https://support.cloudflare.com/hc/en-us/articles/200168586). -type ZoneSettingIPV6GetResponse struct { - // ID of the zone setting. - ID ZoneSettingIPV6GetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingIPV6GetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingIPV6GetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingIPV6GetResponseJSON `json:"-"` -} - -// zoneSettingIPV6GetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingIPV6GetResponse] -type zoneSettingIPV6GetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingIPV6GetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingIPV6GetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingIPV6GetResponseID string - -const ( - ZoneSettingIPV6GetResponseIDIPV6 ZoneSettingIPV6GetResponseID = "ipv6" -) - -// Current value of the zone setting. -type ZoneSettingIPV6GetResponseValue string - -const ( - ZoneSettingIPV6GetResponseValueOff ZoneSettingIPV6GetResponseValue = "off" - ZoneSettingIPV6GetResponseValueOn ZoneSettingIPV6GetResponseValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingIPV6GetResponseEditable bool - -const ( - ZoneSettingIPV6GetResponseEditableTrue ZoneSettingIPV6GetResponseEditable = true - ZoneSettingIPV6GetResponseEditableFalse ZoneSettingIPV6GetResponseEditable = false -) - -type ZoneSettingIPV6EditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingIPV6EditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingIPV6EditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingIPV6EditParamsValue string - -const ( - ZoneSettingIPV6EditParamsValueOff ZoneSettingIPV6EditParamsValue = "off" - ZoneSettingIPV6EditParamsValueOn ZoneSettingIPV6EditParamsValue = "on" -) - -type ZoneSettingIPV6EditResponseEnvelope struct { - Errors []ZoneSettingIPV6EditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingIPV6EditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Enable IPv6 on all subdomains that are Cloudflare enabled. - // (https://support.cloudflare.com/hc/en-us/articles/200168586). - Result ZoneSettingIPV6EditResponse `json:"result"` - JSON zoneSettingIPV6EditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingIPV6EditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingIPV6EditResponseEnvelope] -type zoneSettingIPV6EditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingIPV6EditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingIPV6EditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingIPV6EditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingIPV6EditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingIPV6EditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZoneSettingIPV6EditResponseEnvelopeErrors] -type zoneSettingIPV6EditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingIPV6EditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingIPV6EditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingIPV6EditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingIPV6EditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingIPV6EditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingIPV6EditResponseEnvelopeMessages] -type zoneSettingIPV6EditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingIPV6EditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingIPV6EditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingIPV6GetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingIPV6GetResponseEnvelope struct { - Errors []ZoneSettingIPV6GetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingIPV6GetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Enable IPv6 on all subdomains that are Cloudflare enabled. - // (https://support.cloudflare.com/hc/en-us/articles/200168586). - Result ZoneSettingIPV6GetResponse `json:"result"` - JSON zoneSettingIPV6GetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingIPV6GetResponseEnvelopeJSON contains the JSON metadata for the struct -// [ZoneSettingIPV6GetResponseEnvelope] -type zoneSettingIPV6GetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingIPV6GetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingIPV6GetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingIPV6GetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingIPV6GetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingIPV6GetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZoneSettingIPV6GetResponseEnvelopeErrors] -type zoneSettingIPV6GetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingIPV6GetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingIPV6GetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingIPV6GetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingIPV6GetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingIPV6GetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingIPV6GetResponseEnvelopeMessages] -type zoneSettingIPV6GetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingIPV6GetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingIPV6GetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingipv6_test.go b/zonesettingipv6_test.go deleted file mode 100644 index 2c45dece74b..00000000000 --- a/zonesettingipv6_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingIPV6Edit(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("user@example.com"), - ) - _, err := client.Zones.Settings.IPV6.Edit(context.TODO(), cloudflare.ZoneSettingIPV6EditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingIPV6EditParamsValueOff), - }) - 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 TestZoneSettingIPV6Get(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("user@example.com"), - ) - _, err := client.Zones.Settings.IPV6.Get(context.TODO(), cloudflare.ZoneSettingIPV6GetParams{ - ZoneID: cloudflare.F("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/zonesettingminify.go b/zonesettingminify.go deleted file mode 100644 index 3b2948cbff9..00000000000 --- a/zonesettingminify.go +++ /dev/null @@ -1,479 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingMinifyService 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 [NewZoneSettingMinifyService] method -// instead. -type ZoneSettingMinifyService struct { - Options []option.RequestOption -} - -// NewZoneSettingMinifyService 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 NewZoneSettingMinifyService(opts ...option.RequestOption) (r *ZoneSettingMinifyService) { - r = &ZoneSettingMinifyService{} - r.Options = opts - return -} - -// Automatically minify certain assets for your website. Refer to -// [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) -// for more information. -func (r *ZoneSettingMinifyService) Edit(ctx context.Context, params ZoneSettingMinifyEditParams, opts ...option.RequestOption) (res *ZoneSettingMinifyEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingMinifyEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/minify", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Automatically minify certain assets for your website. Refer to -// [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) -// for more information. -func (r *ZoneSettingMinifyService) Get(ctx context.Context, query ZoneSettingMinifyGetParams, opts ...option.RequestOption) (res *ZoneSettingMinifyGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingMinifyGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/minify", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Automatically minify certain assets for your website. Refer to -// [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) -// for more information. -type ZoneSettingMinifyEditResponse struct { - // Zone setting identifier. - ID ZoneSettingMinifyEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingMinifyEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingMinifyEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingMinifyEditResponseJSON `json:"-"` -} - -// zoneSettingMinifyEditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingMinifyEditResponse] -type zoneSettingMinifyEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMinifyEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMinifyEditResponseJSON) RawJSON() string { - return r.raw -} - -// Zone setting identifier. -type ZoneSettingMinifyEditResponseID string - -const ( - ZoneSettingMinifyEditResponseIDMinify ZoneSettingMinifyEditResponseID = "minify" -) - -// Current value of the zone setting. -type ZoneSettingMinifyEditResponseValue struct { - // Automatically minify all CSS files for your website. - Css ZoneSettingMinifyEditResponseValueCss `json:"css"` - // Automatically minify all HTML files for your website. - HTML ZoneSettingMinifyEditResponseValueHTML `json:"html"` - // Automatically minify all JavaScript files for your website. - Js ZoneSettingMinifyEditResponseValueJs `json:"js"` - JSON zoneSettingMinifyEditResponseValueJSON `json:"-"` -} - -// zoneSettingMinifyEditResponseValueJSON contains the JSON metadata for the struct -// [ZoneSettingMinifyEditResponseValue] -type zoneSettingMinifyEditResponseValueJSON struct { - Css apijson.Field - HTML apijson.Field - Js apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMinifyEditResponseValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMinifyEditResponseValueJSON) RawJSON() string { - return r.raw -} - -// Automatically minify all CSS files for your website. -type ZoneSettingMinifyEditResponseValueCss string - -const ( - ZoneSettingMinifyEditResponseValueCssOn ZoneSettingMinifyEditResponseValueCss = "on" - ZoneSettingMinifyEditResponseValueCssOff ZoneSettingMinifyEditResponseValueCss = "off" -) - -// Automatically minify all HTML files for your website. -type ZoneSettingMinifyEditResponseValueHTML string - -const ( - ZoneSettingMinifyEditResponseValueHTMLOn ZoneSettingMinifyEditResponseValueHTML = "on" - ZoneSettingMinifyEditResponseValueHTMLOff ZoneSettingMinifyEditResponseValueHTML = "off" -) - -// Automatically minify all JavaScript files for your website. -type ZoneSettingMinifyEditResponseValueJs string - -const ( - ZoneSettingMinifyEditResponseValueJsOn ZoneSettingMinifyEditResponseValueJs = "on" - ZoneSettingMinifyEditResponseValueJsOff ZoneSettingMinifyEditResponseValueJs = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingMinifyEditResponseEditable bool - -const ( - ZoneSettingMinifyEditResponseEditableTrue ZoneSettingMinifyEditResponseEditable = true - ZoneSettingMinifyEditResponseEditableFalse ZoneSettingMinifyEditResponseEditable = false -) - -// Automatically minify certain assets for your website. Refer to -// [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) -// for more information. -type ZoneSettingMinifyGetResponse struct { - // Zone setting identifier. - ID ZoneSettingMinifyGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingMinifyGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingMinifyGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingMinifyGetResponseJSON `json:"-"` -} - -// zoneSettingMinifyGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingMinifyGetResponse] -type zoneSettingMinifyGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMinifyGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMinifyGetResponseJSON) RawJSON() string { - return r.raw -} - -// Zone setting identifier. -type ZoneSettingMinifyGetResponseID string - -const ( - ZoneSettingMinifyGetResponseIDMinify ZoneSettingMinifyGetResponseID = "minify" -) - -// Current value of the zone setting. -type ZoneSettingMinifyGetResponseValue struct { - // Automatically minify all CSS files for your website. - Css ZoneSettingMinifyGetResponseValueCss `json:"css"` - // Automatically minify all HTML files for your website. - HTML ZoneSettingMinifyGetResponseValueHTML `json:"html"` - // Automatically minify all JavaScript files for your website. - Js ZoneSettingMinifyGetResponseValueJs `json:"js"` - JSON zoneSettingMinifyGetResponseValueJSON `json:"-"` -} - -// zoneSettingMinifyGetResponseValueJSON contains the JSON metadata for the struct -// [ZoneSettingMinifyGetResponseValue] -type zoneSettingMinifyGetResponseValueJSON struct { - Css apijson.Field - HTML apijson.Field - Js apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMinifyGetResponseValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMinifyGetResponseValueJSON) RawJSON() string { - return r.raw -} - -// Automatically minify all CSS files for your website. -type ZoneSettingMinifyGetResponseValueCss string - -const ( - ZoneSettingMinifyGetResponseValueCssOn ZoneSettingMinifyGetResponseValueCss = "on" - ZoneSettingMinifyGetResponseValueCssOff ZoneSettingMinifyGetResponseValueCss = "off" -) - -// Automatically minify all HTML files for your website. -type ZoneSettingMinifyGetResponseValueHTML string - -const ( - ZoneSettingMinifyGetResponseValueHTMLOn ZoneSettingMinifyGetResponseValueHTML = "on" - ZoneSettingMinifyGetResponseValueHTMLOff ZoneSettingMinifyGetResponseValueHTML = "off" -) - -// Automatically minify all JavaScript files for your website. -type ZoneSettingMinifyGetResponseValueJs string - -const ( - ZoneSettingMinifyGetResponseValueJsOn ZoneSettingMinifyGetResponseValueJs = "on" - ZoneSettingMinifyGetResponseValueJsOff ZoneSettingMinifyGetResponseValueJs = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingMinifyGetResponseEditable bool - -const ( - ZoneSettingMinifyGetResponseEditableTrue ZoneSettingMinifyGetResponseEditable = true - ZoneSettingMinifyGetResponseEditableFalse ZoneSettingMinifyGetResponseEditable = false -) - -type ZoneSettingMinifyEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingMinifyEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingMinifyEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingMinifyEditParamsValue struct { - // Automatically minify all CSS files for your website. - Css param.Field[ZoneSettingMinifyEditParamsValueCss] `json:"css"` - // Automatically minify all HTML files for your website. - HTML param.Field[ZoneSettingMinifyEditParamsValueHTML] `json:"html"` - // Automatically minify all JavaScript files for your website. - Js param.Field[ZoneSettingMinifyEditParamsValueJs] `json:"js"` -} - -func (r ZoneSettingMinifyEditParamsValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Automatically minify all CSS files for your website. -type ZoneSettingMinifyEditParamsValueCss string - -const ( - ZoneSettingMinifyEditParamsValueCssOn ZoneSettingMinifyEditParamsValueCss = "on" - ZoneSettingMinifyEditParamsValueCssOff ZoneSettingMinifyEditParamsValueCss = "off" -) - -// Automatically minify all HTML files for your website. -type ZoneSettingMinifyEditParamsValueHTML string - -const ( - ZoneSettingMinifyEditParamsValueHTMLOn ZoneSettingMinifyEditParamsValueHTML = "on" - ZoneSettingMinifyEditParamsValueHTMLOff ZoneSettingMinifyEditParamsValueHTML = "off" -) - -// Automatically minify all JavaScript files for your website. -type ZoneSettingMinifyEditParamsValueJs string - -const ( - ZoneSettingMinifyEditParamsValueJsOn ZoneSettingMinifyEditParamsValueJs = "on" - ZoneSettingMinifyEditParamsValueJsOff ZoneSettingMinifyEditParamsValueJs = "off" -) - -type ZoneSettingMinifyEditResponseEnvelope struct { - Errors []ZoneSettingMinifyEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingMinifyEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Automatically minify certain assets for your website. Refer to - // [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) - // for more information. - Result ZoneSettingMinifyEditResponse `json:"result"` - JSON zoneSettingMinifyEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingMinifyEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingMinifyEditResponseEnvelope] -type zoneSettingMinifyEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMinifyEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMinifyEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMinifyEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingMinifyEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingMinifyEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSettingMinifyEditResponseEnvelopeErrors] -type zoneSettingMinifyEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMinifyEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMinifyEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMinifyEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingMinifyEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingMinifyEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingMinifyEditResponseEnvelopeMessages] -type zoneSettingMinifyEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMinifyEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMinifyEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMinifyGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingMinifyGetResponseEnvelope struct { - Errors []ZoneSettingMinifyGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingMinifyGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Automatically minify certain assets for your website. Refer to - // [Using Cloudflare Auto Minify](https://support.cloudflare.com/hc/en-us/articles/200168196) - // for more information. - Result ZoneSettingMinifyGetResponse `json:"result"` - JSON zoneSettingMinifyGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingMinifyGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingMinifyGetResponseEnvelope] -type zoneSettingMinifyGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMinifyGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMinifyGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMinifyGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingMinifyGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingMinifyGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSettingMinifyGetResponseEnvelopeErrors] -type zoneSettingMinifyGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMinifyGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMinifyGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMinifyGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingMinifyGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingMinifyGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingMinifyGetResponseEnvelopeMessages] -type zoneSettingMinifyGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMinifyGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMinifyGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingminify_test.go b/zonesettingminify_test.go deleted file mode 100644 index 832a9ee1f34..00000000000 --- a/zonesettingminify_test.go +++ /dev/null @@ -1,71 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingMinifyEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Zones.Settings.Minify.Edit(context.TODO(), cloudflare.ZoneSettingMinifyEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingMinifyEditParamsValue{ - Css: cloudflare.F(cloudflare.ZoneSettingMinifyEditParamsValueCssOn), - HTML: cloudflare.F(cloudflare.ZoneSettingMinifyEditParamsValueHTMLOn), - Js: cloudflare.F(cloudflare.ZoneSettingMinifyEditParamsValueJsOn), - }), - }) - 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 TestZoneSettingMinifyGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.Minify.Get(context.TODO(), cloudflare.ZoneSettingMinifyGetParams{ - ZoneID: cloudflare.F("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/zonesettingmintlsversion.go b/zonesettingmintlsversion.go deleted file mode 100644 index 65b61e84d1c..00000000000 --- a/zonesettingmintlsversion.go +++ /dev/null @@ -1,361 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingMinTLSVersionService 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 -// [NewZoneSettingMinTLSVersionService] method instead. -type ZoneSettingMinTLSVersionService struct { - Options []option.RequestOption -} - -// NewZoneSettingMinTLSVersionService 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 NewZoneSettingMinTLSVersionService(opts ...option.RequestOption) (r *ZoneSettingMinTLSVersionService) { - r = &ZoneSettingMinTLSVersionService{} - r.Options = opts - return -} - -// Changes Minimum TLS Version setting. -func (r *ZoneSettingMinTLSVersionService) Edit(ctx context.Context, params ZoneSettingMinTLSVersionEditParams, opts ...option.RequestOption) (res *ZoneSettingMinTLSVersionEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingMinTLSVersionEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/min_tls_version", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets Minimum TLS Version setting. -func (r *ZoneSettingMinTLSVersionService) Get(ctx context.Context, query ZoneSettingMinTLSVersionGetParams, opts ...option.RequestOption) (res *ZoneSettingMinTLSVersionGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingMinTLSVersionGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/min_tls_version", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Only accepts HTTPS requests that use at least the TLS protocol version -// specified. For example, if TLS 1.1 is selected, TLS 1.0 connections will be -// rejected, while 1.1, 1.2, and 1.3 (if enabled) will be permitted. -type ZoneSettingMinTLSVersionEditResponse struct { - // ID of the zone setting. - ID ZoneSettingMinTLSVersionEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingMinTLSVersionEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingMinTLSVersionEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingMinTLSVersionEditResponseJSON `json:"-"` -} - -// zoneSettingMinTLSVersionEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingMinTLSVersionEditResponse] -type zoneSettingMinTLSVersionEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMinTLSVersionEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMinTLSVersionEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingMinTLSVersionEditResponseID string - -const ( - ZoneSettingMinTLSVersionEditResponseIDMinTLSVersion ZoneSettingMinTLSVersionEditResponseID = "min_tls_version" -) - -// Current value of the zone setting. -type ZoneSettingMinTLSVersionEditResponseValue string - -const ( - ZoneSettingMinTLSVersionEditResponseValue1_0 ZoneSettingMinTLSVersionEditResponseValue = "1.0" - ZoneSettingMinTLSVersionEditResponseValue1_1 ZoneSettingMinTLSVersionEditResponseValue = "1.1" - ZoneSettingMinTLSVersionEditResponseValue1_2 ZoneSettingMinTLSVersionEditResponseValue = "1.2" - ZoneSettingMinTLSVersionEditResponseValue1_3 ZoneSettingMinTLSVersionEditResponseValue = "1.3" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingMinTLSVersionEditResponseEditable bool - -const ( - ZoneSettingMinTLSVersionEditResponseEditableTrue ZoneSettingMinTLSVersionEditResponseEditable = true - ZoneSettingMinTLSVersionEditResponseEditableFalse ZoneSettingMinTLSVersionEditResponseEditable = false -) - -// Only accepts HTTPS requests that use at least the TLS protocol version -// specified. For example, if TLS 1.1 is selected, TLS 1.0 connections will be -// rejected, while 1.1, 1.2, and 1.3 (if enabled) will be permitted. -type ZoneSettingMinTLSVersionGetResponse struct { - // ID of the zone setting. - ID ZoneSettingMinTLSVersionGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingMinTLSVersionGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingMinTLSVersionGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingMinTLSVersionGetResponseJSON `json:"-"` -} - -// zoneSettingMinTLSVersionGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingMinTLSVersionGetResponse] -type zoneSettingMinTLSVersionGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMinTLSVersionGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMinTLSVersionGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingMinTLSVersionGetResponseID string - -const ( - ZoneSettingMinTLSVersionGetResponseIDMinTLSVersion ZoneSettingMinTLSVersionGetResponseID = "min_tls_version" -) - -// Current value of the zone setting. -type ZoneSettingMinTLSVersionGetResponseValue string - -const ( - ZoneSettingMinTLSVersionGetResponseValue1_0 ZoneSettingMinTLSVersionGetResponseValue = "1.0" - ZoneSettingMinTLSVersionGetResponseValue1_1 ZoneSettingMinTLSVersionGetResponseValue = "1.1" - ZoneSettingMinTLSVersionGetResponseValue1_2 ZoneSettingMinTLSVersionGetResponseValue = "1.2" - ZoneSettingMinTLSVersionGetResponseValue1_3 ZoneSettingMinTLSVersionGetResponseValue = "1.3" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingMinTLSVersionGetResponseEditable bool - -const ( - ZoneSettingMinTLSVersionGetResponseEditableTrue ZoneSettingMinTLSVersionGetResponseEditable = true - ZoneSettingMinTLSVersionGetResponseEditableFalse ZoneSettingMinTLSVersionGetResponseEditable = false -) - -type ZoneSettingMinTLSVersionEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingMinTLSVersionEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingMinTLSVersionEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingMinTLSVersionEditParamsValue string - -const ( - ZoneSettingMinTLSVersionEditParamsValue1_0 ZoneSettingMinTLSVersionEditParamsValue = "1.0" - ZoneSettingMinTLSVersionEditParamsValue1_1 ZoneSettingMinTLSVersionEditParamsValue = "1.1" - ZoneSettingMinTLSVersionEditParamsValue1_2 ZoneSettingMinTLSVersionEditParamsValue = "1.2" - ZoneSettingMinTLSVersionEditParamsValue1_3 ZoneSettingMinTLSVersionEditParamsValue = "1.3" -) - -type ZoneSettingMinTLSVersionEditResponseEnvelope struct { - Errors []ZoneSettingMinTLSVersionEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingMinTLSVersionEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Only accepts HTTPS requests that use at least the TLS protocol version - // specified. For example, if TLS 1.1 is selected, TLS 1.0 connections will be - // rejected, while 1.1, 1.2, and 1.3 (if enabled) will be permitted. - Result ZoneSettingMinTLSVersionEditResponse `json:"result"` - JSON zoneSettingMinTLSVersionEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingMinTLSVersionEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingMinTLSVersionEditResponseEnvelope] -type zoneSettingMinTLSVersionEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMinTLSVersionEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMinTLSVersionEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMinTLSVersionEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingMinTLSVersionEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingMinTLSVersionEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingMinTLSVersionEditResponseEnvelopeErrors] -type zoneSettingMinTLSVersionEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMinTLSVersionEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMinTLSVersionEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMinTLSVersionEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingMinTLSVersionEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingMinTLSVersionEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingMinTLSVersionEditResponseEnvelopeMessages] -type zoneSettingMinTLSVersionEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMinTLSVersionEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMinTLSVersionEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMinTLSVersionGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingMinTLSVersionGetResponseEnvelope struct { - Errors []ZoneSettingMinTLSVersionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingMinTLSVersionGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Only accepts HTTPS requests that use at least the TLS protocol version - // specified. For example, if TLS 1.1 is selected, TLS 1.0 connections will be - // rejected, while 1.1, 1.2, and 1.3 (if enabled) will be permitted. - Result ZoneSettingMinTLSVersionGetResponse `json:"result"` - JSON zoneSettingMinTLSVersionGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingMinTLSVersionGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingMinTLSVersionGetResponseEnvelope] -type zoneSettingMinTLSVersionGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMinTLSVersionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMinTLSVersionGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMinTLSVersionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingMinTLSVersionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingMinTLSVersionGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingMinTLSVersionGetResponseEnvelopeErrors] -type zoneSettingMinTLSVersionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMinTLSVersionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMinTLSVersionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMinTLSVersionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingMinTLSVersionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingMinTLSVersionGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingMinTLSVersionGetResponseEnvelopeMessages] -type zoneSettingMinTLSVersionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMinTLSVersionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMinTLSVersionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingmintlsversion_test.go b/zonesettingmintlsversion_test.go deleted file mode 100644 index a6a30292f48..00000000000 --- a/zonesettingmintlsversion_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingMinTLSVersionEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.MinTLSVersion.Edit(context.TODO(), cloudflare.ZoneSettingMinTLSVersionEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingMinTLSVersionEditParamsValue1_0), - }) - 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 TestZoneSettingMinTLSVersionGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.MinTLSVersion.Get(context.TODO(), cloudflare.ZoneSettingMinTLSVersionGetParams{ - ZoneID: cloudflare.F("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/zonesettingmirage.go b/zonesettingmirage.go deleted file mode 100644 index 51dc20314ea..00000000000 --- a/zonesettingmirage.go +++ /dev/null @@ -1,365 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingMirageService 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 [NewZoneSettingMirageService] method -// instead. -type ZoneSettingMirageService struct { - Options []option.RequestOption -} - -// NewZoneSettingMirageService 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 NewZoneSettingMirageService(opts ...option.RequestOption) (r *ZoneSettingMirageService) { - r = &ZoneSettingMirageService{} - r.Options = opts - return -} - -// Automatically optimize image loading for website visitors on mobile devices. -// Refer to our -// [blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for more -// information. -func (r *ZoneSettingMirageService) Edit(ctx context.Context, params ZoneSettingMirageEditParams, opts ...option.RequestOption) (res *ZoneSettingMirageEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingMirageEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/mirage", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Automatically optimize image loading for website visitors on mobile devices. -// Refer to our -// [blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for more -// information. -func (r *ZoneSettingMirageService) Get(ctx context.Context, query ZoneSettingMirageGetParams, opts ...option.RequestOption) (res *ZoneSettingMirageGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingMirageGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/mirage", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Automatically optimize image loading for website visitors on mobile devices. -// Refer to -// [our blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for -// more information. -type ZoneSettingMirageEditResponse struct { - // ID of the zone setting. - ID ZoneSettingMirageEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingMirageEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingMirageEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingMirageEditResponseJSON `json:"-"` -} - -// zoneSettingMirageEditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingMirageEditResponse] -type zoneSettingMirageEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMirageEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMirageEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingMirageEditResponseID string - -const ( - ZoneSettingMirageEditResponseIDMirage ZoneSettingMirageEditResponseID = "mirage" -) - -// Current value of the zone setting. -type ZoneSettingMirageEditResponseValue string - -const ( - ZoneSettingMirageEditResponseValueOn ZoneSettingMirageEditResponseValue = "on" - ZoneSettingMirageEditResponseValueOff ZoneSettingMirageEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingMirageEditResponseEditable bool - -const ( - ZoneSettingMirageEditResponseEditableTrue ZoneSettingMirageEditResponseEditable = true - ZoneSettingMirageEditResponseEditableFalse ZoneSettingMirageEditResponseEditable = false -) - -// Automatically optimize image loading for website visitors on mobile devices. -// Refer to -// [our blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for -// more information. -type ZoneSettingMirageGetResponse struct { - // ID of the zone setting. - ID ZoneSettingMirageGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingMirageGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingMirageGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingMirageGetResponseJSON `json:"-"` -} - -// zoneSettingMirageGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingMirageGetResponse] -type zoneSettingMirageGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMirageGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMirageGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingMirageGetResponseID string - -const ( - ZoneSettingMirageGetResponseIDMirage ZoneSettingMirageGetResponseID = "mirage" -) - -// Current value of the zone setting. -type ZoneSettingMirageGetResponseValue string - -const ( - ZoneSettingMirageGetResponseValueOn ZoneSettingMirageGetResponseValue = "on" - ZoneSettingMirageGetResponseValueOff ZoneSettingMirageGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingMirageGetResponseEditable bool - -const ( - ZoneSettingMirageGetResponseEditableTrue ZoneSettingMirageGetResponseEditable = true - ZoneSettingMirageGetResponseEditableFalse ZoneSettingMirageGetResponseEditable = false -) - -type ZoneSettingMirageEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingMirageEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingMirageEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingMirageEditParamsValue string - -const ( - ZoneSettingMirageEditParamsValueOn ZoneSettingMirageEditParamsValue = "on" - ZoneSettingMirageEditParamsValueOff ZoneSettingMirageEditParamsValue = "off" -) - -type ZoneSettingMirageEditResponseEnvelope struct { - Errors []ZoneSettingMirageEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingMirageEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Automatically optimize image loading for website visitors on mobile devices. - // Refer to - // [our blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for - // more information. - Result ZoneSettingMirageEditResponse `json:"result"` - JSON zoneSettingMirageEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingMirageEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingMirageEditResponseEnvelope] -type zoneSettingMirageEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMirageEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMirageEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMirageEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingMirageEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingMirageEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSettingMirageEditResponseEnvelopeErrors] -type zoneSettingMirageEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMirageEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMirageEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMirageEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingMirageEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingMirageEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingMirageEditResponseEnvelopeMessages] -type zoneSettingMirageEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMirageEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMirageEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMirageGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingMirageGetResponseEnvelope struct { - Errors []ZoneSettingMirageGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingMirageGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Automatically optimize image loading for website visitors on mobile devices. - // Refer to - // [our blog post](http://blog.cloudflare.com/mirage2-solving-mobile-speed) for - // more information. - Result ZoneSettingMirageGetResponse `json:"result"` - JSON zoneSettingMirageGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingMirageGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingMirageGetResponseEnvelope] -type zoneSettingMirageGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMirageGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMirageGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMirageGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingMirageGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingMirageGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSettingMirageGetResponseEnvelopeErrors] -type zoneSettingMirageGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMirageGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMirageGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMirageGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingMirageGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingMirageGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingMirageGetResponseEnvelopeMessages] -type zoneSettingMirageGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMirageGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMirageGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingmirage_test.go b/zonesettingmirage_test.go deleted file mode 100644 index 4177dcc8b7b..00000000000 --- a/zonesettingmirage_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingMirageEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.Mirage.Edit(context.TODO(), cloudflare.ZoneSettingMirageEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingMirageEditParamsValueOn), - }) - 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 TestZoneSettingMirageGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.Mirage.Get(context.TODO(), cloudflare.ZoneSettingMirageGetParams{ - ZoneID: cloudflare.F("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/zonesettingmobileredirect.go b/zonesettingmobileredirect.go deleted file mode 100644 index 6b914a49aac..00000000000 --- a/zonesettingmobileredirect.go +++ /dev/null @@ -1,443 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingMobileRedirectService 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 -// [NewZoneSettingMobileRedirectService] method instead. -type ZoneSettingMobileRedirectService struct { - Options []option.RequestOption -} - -// NewZoneSettingMobileRedirectService 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 NewZoneSettingMobileRedirectService(opts ...option.RequestOption) (r *ZoneSettingMobileRedirectService) { - r = &ZoneSettingMobileRedirectService{} - r.Options = opts - return -} - -// Automatically redirect visitors on mobile devices to a mobile-optimized -// subdomain. Refer to -// [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) -// for more information. -func (r *ZoneSettingMobileRedirectService) Edit(ctx context.Context, params ZoneSettingMobileRedirectEditParams, opts ...option.RequestOption) (res *ZoneSettingMobileRedirectEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingMobileRedirectEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/mobile_redirect", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Automatically redirect visitors on mobile devices to a mobile-optimized -// subdomain. Refer to -// [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) -// for more information. -func (r *ZoneSettingMobileRedirectService) Get(ctx context.Context, query ZoneSettingMobileRedirectGetParams, opts ...option.RequestOption) (res *ZoneSettingMobileRedirectGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingMobileRedirectGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/mobile_redirect", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Automatically redirect visitors on mobile devices to a mobile-optimized -// subdomain. Refer to -// [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) -// for more information. -type ZoneSettingMobileRedirectEditResponse struct { - // Identifier of the zone setting. - ID ZoneSettingMobileRedirectEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingMobileRedirectEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingMobileRedirectEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingMobileRedirectEditResponseJSON `json:"-"` -} - -// zoneSettingMobileRedirectEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingMobileRedirectEditResponse] -type zoneSettingMobileRedirectEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMobileRedirectEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMobileRedirectEditResponseJSON) RawJSON() string { - return r.raw -} - -// Identifier of the zone setting. -type ZoneSettingMobileRedirectEditResponseID string - -const ( - ZoneSettingMobileRedirectEditResponseIDMobileRedirect ZoneSettingMobileRedirectEditResponseID = "mobile_redirect" -) - -// Current value of the zone setting. -type ZoneSettingMobileRedirectEditResponseValue struct { - // Which subdomain prefix you wish to redirect visitors on mobile devices to - // (subdomain must already exist). - MobileSubdomain string `json:"mobile_subdomain,nullable"` - // Whether or not mobile redirect is enabled. - Status ZoneSettingMobileRedirectEditResponseValueStatus `json:"status"` - // Whether to drop the current page path and redirect to the mobile subdomain URL - // root, or keep the path and redirect to the same page on the mobile subdomain. - StripURI bool `json:"strip_uri"` - JSON zoneSettingMobileRedirectEditResponseValueJSON `json:"-"` -} - -// zoneSettingMobileRedirectEditResponseValueJSON contains the JSON metadata for -// the struct [ZoneSettingMobileRedirectEditResponseValue] -type zoneSettingMobileRedirectEditResponseValueJSON struct { - MobileSubdomain apijson.Field - Status apijson.Field - StripURI apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMobileRedirectEditResponseValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMobileRedirectEditResponseValueJSON) RawJSON() string { - return r.raw -} - -// Whether or not mobile redirect is enabled. -type ZoneSettingMobileRedirectEditResponseValueStatus string - -const ( - ZoneSettingMobileRedirectEditResponseValueStatusOn ZoneSettingMobileRedirectEditResponseValueStatus = "on" - ZoneSettingMobileRedirectEditResponseValueStatusOff ZoneSettingMobileRedirectEditResponseValueStatus = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingMobileRedirectEditResponseEditable bool - -const ( - ZoneSettingMobileRedirectEditResponseEditableTrue ZoneSettingMobileRedirectEditResponseEditable = true - ZoneSettingMobileRedirectEditResponseEditableFalse ZoneSettingMobileRedirectEditResponseEditable = false -) - -// Automatically redirect visitors on mobile devices to a mobile-optimized -// subdomain. Refer to -// [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) -// for more information. -type ZoneSettingMobileRedirectGetResponse struct { - // Identifier of the zone setting. - ID ZoneSettingMobileRedirectGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingMobileRedirectGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingMobileRedirectGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingMobileRedirectGetResponseJSON `json:"-"` -} - -// zoneSettingMobileRedirectGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingMobileRedirectGetResponse] -type zoneSettingMobileRedirectGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMobileRedirectGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMobileRedirectGetResponseJSON) RawJSON() string { - return r.raw -} - -// Identifier of the zone setting. -type ZoneSettingMobileRedirectGetResponseID string - -const ( - ZoneSettingMobileRedirectGetResponseIDMobileRedirect ZoneSettingMobileRedirectGetResponseID = "mobile_redirect" -) - -// Current value of the zone setting. -type ZoneSettingMobileRedirectGetResponseValue struct { - // Which subdomain prefix you wish to redirect visitors on mobile devices to - // (subdomain must already exist). - MobileSubdomain string `json:"mobile_subdomain,nullable"` - // Whether or not mobile redirect is enabled. - Status ZoneSettingMobileRedirectGetResponseValueStatus `json:"status"` - // Whether to drop the current page path and redirect to the mobile subdomain URL - // root, or keep the path and redirect to the same page on the mobile subdomain. - StripURI bool `json:"strip_uri"` - JSON zoneSettingMobileRedirectGetResponseValueJSON `json:"-"` -} - -// zoneSettingMobileRedirectGetResponseValueJSON contains the JSON metadata for the -// struct [ZoneSettingMobileRedirectGetResponseValue] -type zoneSettingMobileRedirectGetResponseValueJSON struct { - MobileSubdomain apijson.Field - Status apijson.Field - StripURI apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMobileRedirectGetResponseValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMobileRedirectGetResponseValueJSON) RawJSON() string { - return r.raw -} - -// Whether or not mobile redirect is enabled. -type ZoneSettingMobileRedirectGetResponseValueStatus string - -const ( - ZoneSettingMobileRedirectGetResponseValueStatusOn ZoneSettingMobileRedirectGetResponseValueStatus = "on" - ZoneSettingMobileRedirectGetResponseValueStatusOff ZoneSettingMobileRedirectGetResponseValueStatus = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingMobileRedirectGetResponseEditable bool - -const ( - ZoneSettingMobileRedirectGetResponseEditableTrue ZoneSettingMobileRedirectGetResponseEditable = true - ZoneSettingMobileRedirectGetResponseEditableFalse ZoneSettingMobileRedirectGetResponseEditable = false -) - -type ZoneSettingMobileRedirectEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingMobileRedirectEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingMobileRedirectEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingMobileRedirectEditParamsValue struct { - // Which subdomain prefix you wish to redirect visitors on mobile devices to - // (subdomain must already exist). - MobileSubdomain param.Field[string] `json:"mobile_subdomain"` - // Whether or not mobile redirect is enabled. - Status param.Field[ZoneSettingMobileRedirectEditParamsValueStatus] `json:"status"` - // Whether to drop the current page path and redirect to the mobile subdomain URL - // root, or keep the path and redirect to the same page on the mobile subdomain. - StripURI param.Field[bool] `json:"strip_uri"` -} - -func (r ZoneSettingMobileRedirectEditParamsValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Whether or not mobile redirect is enabled. -type ZoneSettingMobileRedirectEditParamsValueStatus string - -const ( - ZoneSettingMobileRedirectEditParamsValueStatusOn ZoneSettingMobileRedirectEditParamsValueStatus = "on" - ZoneSettingMobileRedirectEditParamsValueStatusOff ZoneSettingMobileRedirectEditParamsValueStatus = "off" -) - -type ZoneSettingMobileRedirectEditResponseEnvelope struct { - Errors []ZoneSettingMobileRedirectEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingMobileRedirectEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Automatically redirect visitors on mobile devices to a mobile-optimized - // subdomain. Refer to - // [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) - // for more information. - Result ZoneSettingMobileRedirectEditResponse `json:"result"` - JSON zoneSettingMobileRedirectEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingMobileRedirectEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingMobileRedirectEditResponseEnvelope] -type zoneSettingMobileRedirectEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMobileRedirectEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMobileRedirectEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMobileRedirectEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingMobileRedirectEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingMobileRedirectEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingMobileRedirectEditResponseEnvelopeErrors] -type zoneSettingMobileRedirectEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMobileRedirectEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMobileRedirectEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMobileRedirectEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingMobileRedirectEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingMobileRedirectEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingMobileRedirectEditResponseEnvelopeMessages] -type zoneSettingMobileRedirectEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMobileRedirectEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMobileRedirectEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMobileRedirectGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingMobileRedirectGetResponseEnvelope struct { - Errors []ZoneSettingMobileRedirectGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingMobileRedirectGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Automatically redirect visitors on mobile devices to a mobile-optimized - // subdomain. Refer to - // [Understanding Cloudflare Mobile Redirect](https://support.cloudflare.com/hc/articles/200168336) - // for more information. - Result ZoneSettingMobileRedirectGetResponse `json:"result"` - JSON zoneSettingMobileRedirectGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingMobileRedirectGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingMobileRedirectGetResponseEnvelope] -type zoneSettingMobileRedirectGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMobileRedirectGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMobileRedirectGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMobileRedirectGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingMobileRedirectGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingMobileRedirectGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingMobileRedirectGetResponseEnvelopeErrors] -type zoneSettingMobileRedirectGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMobileRedirectGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMobileRedirectGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingMobileRedirectGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingMobileRedirectGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingMobileRedirectGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingMobileRedirectGetResponseEnvelopeMessages] -type zoneSettingMobileRedirectGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingMobileRedirectGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingMobileRedirectGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingmobileredirect_test.go b/zonesettingmobileredirect_test.go deleted file mode 100644 index bff30f6a6c1..00000000000 --- a/zonesettingmobileredirect_test.go +++ /dev/null @@ -1,71 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingMobileRedirectEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Zones.Settings.MobileRedirect.Edit(context.TODO(), cloudflare.ZoneSettingMobileRedirectEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingMobileRedirectEditParamsValue{ - MobileSubdomain: cloudflare.F("m"), - Status: cloudflare.F(cloudflare.ZoneSettingMobileRedirectEditParamsValueStatusOn), - StripURI: cloudflare.F(false), - }), - }) - 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 TestZoneSettingMobileRedirectGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.MobileRedirect.Get(context.TODO(), cloudflare.ZoneSettingMobileRedirectGetParams{ - ZoneID: cloudflare.F("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/zonesettingnel.go b/zonesettingnel.go deleted file mode 100644 index dbab4a33e7a..00000000000 --- a/zonesettingnel.go +++ /dev/null @@ -1,406 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingNELService 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 [NewZoneSettingNELService] method -// instead. -type ZoneSettingNELService struct { - Options []option.RequestOption -} - -// NewZoneSettingNELService 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 NewZoneSettingNELService(opts ...option.RequestOption) (r *ZoneSettingNELService) { - r = &ZoneSettingNELService{} - r.Options = opts - return -} - -// Automatically optimize image loading for website visitors on mobile devices. -// Refer to our [blog post](http://blog.cloudflare.com/nel-solving-mobile-speed) -// for more information. -func (r *ZoneSettingNELService) Edit(ctx context.Context, params ZoneSettingNELEditParams, opts ...option.RequestOption) (res *ZoneSettingNELEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingNELEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/nel", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Enable Network Error Logging reporting on your zone. (Beta) -func (r *ZoneSettingNELService) Get(ctx context.Context, query ZoneSettingNELGetParams, opts ...option.RequestOption) (res *ZoneSettingNELGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingNELGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/nel", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Enable Network Error Logging reporting on your zone. (Beta) -type ZoneSettingNELEditResponse struct { - // Zone setting identifier. - ID ZoneSettingNELEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingNELEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingNELEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingNELEditResponseJSON `json:"-"` -} - -// zoneSettingNELEditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingNELEditResponse] -type zoneSettingNELEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingNELEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingNELEditResponseJSON) RawJSON() string { - return r.raw -} - -// Zone setting identifier. -type ZoneSettingNELEditResponseID string - -const ( - ZoneSettingNELEditResponseIDNEL ZoneSettingNELEditResponseID = "nel" -) - -// Current value of the zone setting. -type ZoneSettingNELEditResponseValue struct { - Enabled bool `json:"enabled"` - JSON zoneSettingNELEditResponseValueJSON `json:"-"` -} - -// zoneSettingNELEditResponseValueJSON contains the JSON metadata for the struct -// [ZoneSettingNELEditResponseValue] -type zoneSettingNELEditResponseValueJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingNELEditResponseValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingNELEditResponseValueJSON) RawJSON() string { - return r.raw -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingNELEditResponseEditable bool - -const ( - ZoneSettingNELEditResponseEditableTrue ZoneSettingNELEditResponseEditable = true - ZoneSettingNELEditResponseEditableFalse ZoneSettingNELEditResponseEditable = false -) - -// Enable Network Error Logging reporting on your zone. (Beta) -type ZoneSettingNELGetResponse struct { - // Zone setting identifier. - ID ZoneSettingNELGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingNELGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingNELGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingNELGetResponseJSON `json:"-"` -} - -// zoneSettingNELGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingNELGetResponse] -type zoneSettingNELGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingNELGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingNELGetResponseJSON) RawJSON() string { - return r.raw -} - -// Zone setting identifier. -type ZoneSettingNELGetResponseID string - -const ( - ZoneSettingNELGetResponseIDNEL ZoneSettingNELGetResponseID = "nel" -) - -// Current value of the zone setting. -type ZoneSettingNELGetResponseValue struct { - Enabled bool `json:"enabled"` - JSON zoneSettingNELGetResponseValueJSON `json:"-"` -} - -// zoneSettingNELGetResponseValueJSON contains the JSON metadata for the struct -// [ZoneSettingNELGetResponseValue] -type zoneSettingNELGetResponseValueJSON struct { - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingNELGetResponseValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingNELGetResponseValueJSON) RawJSON() string { - return r.raw -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingNELGetResponseEditable bool - -const ( - ZoneSettingNELGetResponseEditableTrue ZoneSettingNELGetResponseEditable = true - ZoneSettingNELGetResponseEditableFalse ZoneSettingNELGetResponseEditable = false -) - -type ZoneSettingNELEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Enable Network Error Logging reporting on your zone. (Beta) - Value param.Field[ZoneSettingNELEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingNELEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enable Network Error Logging reporting on your zone. (Beta) -type ZoneSettingNELEditParamsValue struct { - // Zone setting identifier. - ID param.Field[ZoneSettingNELEditParamsValueID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingNELEditParamsValueValue] `json:"value,required"` -} - -func (r ZoneSettingNELEditParamsValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Zone setting identifier. -type ZoneSettingNELEditParamsValueID string - -const ( - ZoneSettingNELEditParamsValueIDNEL ZoneSettingNELEditParamsValueID = "nel" -) - -// Current value of the zone setting. -type ZoneSettingNELEditParamsValueValue struct { - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ZoneSettingNELEditParamsValueValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingNELEditParamsValueEditable bool - -const ( - ZoneSettingNELEditParamsValueEditableTrue ZoneSettingNELEditParamsValueEditable = true - ZoneSettingNELEditParamsValueEditableFalse ZoneSettingNELEditParamsValueEditable = false -) - -type ZoneSettingNELEditResponseEnvelope struct { - Errors []ZoneSettingNELEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingNELEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Enable Network Error Logging reporting on your zone. (Beta) - Result ZoneSettingNELEditResponse `json:"result"` - JSON zoneSettingNELEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingNELEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [ZoneSettingNELEditResponseEnvelope] -type zoneSettingNELEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingNELEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingNELEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingNELEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingNELEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingNELEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZoneSettingNELEditResponseEnvelopeErrors] -type zoneSettingNELEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingNELEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingNELEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingNELEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingNELEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingNELEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingNELEditResponseEnvelopeMessages] -type zoneSettingNELEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingNELEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingNELEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingNELGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingNELGetResponseEnvelope struct { - Errors []ZoneSettingNELGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingNELGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Enable Network Error Logging reporting on your zone. (Beta) - Result ZoneSettingNELGetResponse `json:"result"` - JSON zoneSettingNELGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingNELGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [ZoneSettingNELGetResponseEnvelope] -type zoneSettingNELGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingNELGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingNELGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingNELGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingNELGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingNELGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZoneSettingNELGetResponseEnvelopeErrors] -type zoneSettingNELGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingNELGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingNELGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingNELGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingNELGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingNELGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ZoneSettingNELGetResponseEnvelopeMessages] -type zoneSettingNELGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingNELGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingNELGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingnel_test.go b/zonesettingnel_test.go deleted file mode 100644 index 79db766cfb7..00000000000 --- a/zonesettingnel_test.go +++ /dev/null @@ -1,72 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingNELEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Zones.Settings.NEL.Edit(context.TODO(), cloudflare.ZoneSettingNELEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingNELEditParamsValue{ - ID: cloudflare.F(cloudflare.ZoneSettingNELEditParamsValueIDNEL), - Value: cloudflare.F(cloudflare.ZoneSettingNELEditParamsValueValue{ - Enabled: cloudflare.F(false), - }), - }), - }) - 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 TestZoneSettingNELGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.NEL.Get(context.TODO(), cloudflare.ZoneSettingNELGetParams{ - ZoneID: cloudflare.F("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/zonesettingopportunisticencryption.go b/zonesettingopportunisticencryption.go deleted file mode 100644 index b822d8c5ac9..00000000000 --- a/zonesettingopportunisticencryption.go +++ /dev/null @@ -1,354 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingOpportunisticEncryptionService 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 -// [NewZoneSettingOpportunisticEncryptionService] method instead. -type ZoneSettingOpportunisticEncryptionService struct { - Options []option.RequestOption -} - -// NewZoneSettingOpportunisticEncryptionService 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 NewZoneSettingOpportunisticEncryptionService(opts ...option.RequestOption) (r *ZoneSettingOpportunisticEncryptionService) { - r = &ZoneSettingOpportunisticEncryptionService{} - r.Options = opts - return -} - -// Changes Opportunistic Encryption setting. -func (r *ZoneSettingOpportunisticEncryptionService) Edit(ctx context.Context, params ZoneSettingOpportunisticEncryptionEditParams, opts ...option.RequestOption) (res *ZoneSettingOpportunisticEncryptionEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingOpportunisticEncryptionEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/opportunistic_encryption", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets Opportunistic Encryption setting. -func (r *ZoneSettingOpportunisticEncryptionService) Get(ctx context.Context, query ZoneSettingOpportunisticEncryptionGetParams, opts ...option.RequestOption) (res *ZoneSettingOpportunisticEncryptionGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingOpportunisticEncryptionGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/opportunistic_encryption", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Enables the Opportunistic Encryption feature for a zone. -type ZoneSettingOpportunisticEncryptionEditResponse struct { - // ID of the zone setting. - ID ZoneSettingOpportunisticEncryptionEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingOpportunisticEncryptionEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingOpportunisticEncryptionEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingOpportunisticEncryptionEditResponseJSON `json:"-"` -} - -// zoneSettingOpportunisticEncryptionEditResponseJSON contains the JSON metadata -// for the struct [ZoneSettingOpportunisticEncryptionEditResponse] -type zoneSettingOpportunisticEncryptionEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOpportunisticEncryptionEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOpportunisticEncryptionEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingOpportunisticEncryptionEditResponseID string - -const ( - ZoneSettingOpportunisticEncryptionEditResponseIDOpportunisticEncryption ZoneSettingOpportunisticEncryptionEditResponseID = "opportunistic_encryption" -) - -// Current value of the zone setting. -type ZoneSettingOpportunisticEncryptionEditResponseValue string - -const ( - ZoneSettingOpportunisticEncryptionEditResponseValueOn ZoneSettingOpportunisticEncryptionEditResponseValue = "on" - ZoneSettingOpportunisticEncryptionEditResponseValueOff ZoneSettingOpportunisticEncryptionEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingOpportunisticEncryptionEditResponseEditable bool - -const ( - ZoneSettingOpportunisticEncryptionEditResponseEditableTrue ZoneSettingOpportunisticEncryptionEditResponseEditable = true - ZoneSettingOpportunisticEncryptionEditResponseEditableFalse ZoneSettingOpportunisticEncryptionEditResponseEditable = false -) - -// Enables the Opportunistic Encryption feature for a zone. -type ZoneSettingOpportunisticEncryptionGetResponse struct { - // ID of the zone setting. - ID ZoneSettingOpportunisticEncryptionGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingOpportunisticEncryptionGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingOpportunisticEncryptionGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingOpportunisticEncryptionGetResponseJSON `json:"-"` -} - -// zoneSettingOpportunisticEncryptionGetResponseJSON contains the JSON metadata for -// the struct [ZoneSettingOpportunisticEncryptionGetResponse] -type zoneSettingOpportunisticEncryptionGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOpportunisticEncryptionGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOpportunisticEncryptionGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingOpportunisticEncryptionGetResponseID string - -const ( - ZoneSettingOpportunisticEncryptionGetResponseIDOpportunisticEncryption ZoneSettingOpportunisticEncryptionGetResponseID = "opportunistic_encryption" -) - -// Current value of the zone setting. -type ZoneSettingOpportunisticEncryptionGetResponseValue string - -const ( - ZoneSettingOpportunisticEncryptionGetResponseValueOn ZoneSettingOpportunisticEncryptionGetResponseValue = "on" - ZoneSettingOpportunisticEncryptionGetResponseValueOff ZoneSettingOpportunisticEncryptionGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingOpportunisticEncryptionGetResponseEditable bool - -const ( - ZoneSettingOpportunisticEncryptionGetResponseEditableTrue ZoneSettingOpportunisticEncryptionGetResponseEditable = true - ZoneSettingOpportunisticEncryptionGetResponseEditableFalse ZoneSettingOpportunisticEncryptionGetResponseEditable = false -) - -type ZoneSettingOpportunisticEncryptionEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. Notes: Default value depends on the zone's plan - // level. - Value param.Field[ZoneSettingOpportunisticEncryptionEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingOpportunisticEncryptionEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. Notes: Default value depends on the zone's plan -// level. -type ZoneSettingOpportunisticEncryptionEditParamsValue string - -const ( - ZoneSettingOpportunisticEncryptionEditParamsValueOn ZoneSettingOpportunisticEncryptionEditParamsValue = "on" - ZoneSettingOpportunisticEncryptionEditParamsValueOff ZoneSettingOpportunisticEncryptionEditParamsValue = "off" -) - -type ZoneSettingOpportunisticEncryptionEditResponseEnvelope struct { - Errors []ZoneSettingOpportunisticEncryptionEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingOpportunisticEncryptionEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Enables the Opportunistic Encryption feature for a zone. - Result ZoneSettingOpportunisticEncryptionEditResponse `json:"result"` - JSON zoneSettingOpportunisticEncryptionEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingOpportunisticEncryptionEditResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZoneSettingOpportunisticEncryptionEditResponseEnvelope] -type zoneSettingOpportunisticEncryptionEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOpportunisticEncryptionEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOpportunisticEncryptionEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOpportunisticEncryptionEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOpportunisticEncryptionEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingOpportunisticEncryptionEditResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZoneSettingOpportunisticEncryptionEditResponseEnvelopeErrors] -type zoneSettingOpportunisticEncryptionEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOpportunisticEncryptionEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOpportunisticEncryptionEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOpportunisticEncryptionEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOpportunisticEncryptionEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingOpportunisticEncryptionEditResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZoneSettingOpportunisticEncryptionEditResponseEnvelopeMessages] -type zoneSettingOpportunisticEncryptionEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOpportunisticEncryptionEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOpportunisticEncryptionEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOpportunisticEncryptionGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingOpportunisticEncryptionGetResponseEnvelope struct { - Errors []ZoneSettingOpportunisticEncryptionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingOpportunisticEncryptionGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Enables the Opportunistic Encryption feature for a zone. - Result ZoneSettingOpportunisticEncryptionGetResponse `json:"result"` - JSON zoneSettingOpportunisticEncryptionGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingOpportunisticEncryptionGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZoneSettingOpportunisticEncryptionGetResponseEnvelope] -type zoneSettingOpportunisticEncryptionGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOpportunisticEncryptionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOpportunisticEncryptionGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOpportunisticEncryptionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOpportunisticEncryptionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingOpportunisticEncryptionGetResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZoneSettingOpportunisticEncryptionGetResponseEnvelopeErrors] -type zoneSettingOpportunisticEncryptionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOpportunisticEncryptionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOpportunisticEncryptionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOpportunisticEncryptionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOpportunisticEncryptionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingOpportunisticEncryptionGetResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZoneSettingOpportunisticEncryptionGetResponseEnvelopeMessages] -type zoneSettingOpportunisticEncryptionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOpportunisticEncryptionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOpportunisticEncryptionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingopportunisticencryption_test.go b/zonesettingopportunisticencryption_test.go deleted file mode 100644 index 8912b28b463..00000000000 --- a/zonesettingopportunisticencryption_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingOpportunisticEncryptionEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.OpportunisticEncryption.Edit(context.TODO(), cloudflare.ZoneSettingOpportunisticEncryptionEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingOpportunisticEncryptionEditParamsValueOn), - }) - 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 TestZoneSettingOpportunisticEncryptionGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.OpportunisticEncryption.Get(context.TODO(), cloudflare.ZoneSettingOpportunisticEncryptionGetParams{ - ZoneID: cloudflare.F("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/zonesettingopportunisticonion.go b/zonesettingopportunisticonion.go deleted file mode 100644 index 43b32c57e0a..00000000000 --- a/zonesettingopportunisticonion.go +++ /dev/null @@ -1,358 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingOpportunisticOnionService 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 -// [NewZoneSettingOpportunisticOnionService] method instead. -type ZoneSettingOpportunisticOnionService struct { - Options []option.RequestOption -} - -// NewZoneSettingOpportunisticOnionService 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 NewZoneSettingOpportunisticOnionService(opts ...option.RequestOption) (r *ZoneSettingOpportunisticOnionService) { - r = &ZoneSettingOpportunisticOnionService{} - r.Options = opts - return -} - -// Add an Alt-Svc header to all legitimate requests from Tor, allowing the -// connection to use our onion services instead of exit nodes. -func (r *ZoneSettingOpportunisticOnionService) Edit(ctx context.Context, params ZoneSettingOpportunisticOnionEditParams, opts ...option.RequestOption) (res *ZoneSettingOpportunisticOnionEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingOpportunisticOnionEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/opportunistic_onion", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Add an Alt-Svc header to all legitimate requests from Tor, allowing the -// connection to use our onion services instead of exit nodes. -func (r *ZoneSettingOpportunisticOnionService) Get(ctx context.Context, query ZoneSettingOpportunisticOnionGetParams, opts ...option.RequestOption) (res *ZoneSettingOpportunisticOnionGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingOpportunisticOnionGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/opportunistic_onion", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Add an Alt-Svc header to all legitimate requests from Tor, allowing the -// connection to use our onion services instead of exit nodes. -type ZoneSettingOpportunisticOnionEditResponse struct { - // ID of the zone setting. - ID ZoneSettingOpportunisticOnionEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingOpportunisticOnionEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingOpportunisticOnionEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingOpportunisticOnionEditResponseJSON `json:"-"` -} - -// zoneSettingOpportunisticOnionEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingOpportunisticOnionEditResponse] -type zoneSettingOpportunisticOnionEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOpportunisticOnionEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOpportunisticOnionEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingOpportunisticOnionEditResponseID string - -const ( - ZoneSettingOpportunisticOnionEditResponseIDOpportunisticOnion ZoneSettingOpportunisticOnionEditResponseID = "opportunistic_onion" -) - -// Current value of the zone setting. -type ZoneSettingOpportunisticOnionEditResponseValue string - -const ( - ZoneSettingOpportunisticOnionEditResponseValueOn ZoneSettingOpportunisticOnionEditResponseValue = "on" - ZoneSettingOpportunisticOnionEditResponseValueOff ZoneSettingOpportunisticOnionEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingOpportunisticOnionEditResponseEditable bool - -const ( - ZoneSettingOpportunisticOnionEditResponseEditableTrue ZoneSettingOpportunisticOnionEditResponseEditable = true - ZoneSettingOpportunisticOnionEditResponseEditableFalse ZoneSettingOpportunisticOnionEditResponseEditable = false -) - -// Add an Alt-Svc header to all legitimate requests from Tor, allowing the -// connection to use our onion services instead of exit nodes. -type ZoneSettingOpportunisticOnionGetResponse struct { - // ID of the zone setting. - ID ZoneSettingOpportunisticOnionGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingOpportunisticOnionGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingOpportunisticOnionGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingOpportunisticOnionGetResponseJSON `json:"-"` -} - -// zoneSettingOpportunisticOnionGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingOpportunisticOnionGetResponse] -type zoneSettingOpportunisticOnionGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOpportunisticOnionGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOpportunisticOnionGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingOpportunisticOnionGetResponseID string - -const ( - ZoneSettingOpportunisticOnionGetResponseIDOpportunisticOnion ZoneSettingOpportunisticOnionGetResponseID = "opportunistic_onion" -) - -// Current value of the zone setting. -type ZoneSettingOpportunisticOnionGetResponseValue string - -const ( - ZoneSettingOpportunisticOnionGetResponseValueOn ZoneSettingOpportunisticOnionGetResponseValue = "on" - ZoneSettingOpportunisticOnionGetResponseValueOff ZoneSettingOpportunisticOnionGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingOpportunisticOnionGetResponseEditable bool - -const ( - ZoneSettingOpportunisticOnionGetResponseEditableTrue ZoneSettingOpportunisticOnionGetResponseEditable = true - ZoneSettingOpportunisticOnionGetResponseEditableFalse ZoneSettingOpportunisticOnionGetResponseEditable = false -) - -type ZoneSettingOpportunisticOnionEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. Notes: Default value depends on the zone's plan - // level. - Value param.Field[ZoneSettingOpportunisticOnionEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingOpportunisticOnionEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. Notes: Default value depends on the zone's plan -// level. -type ZoneSettingOpportunisticOnionEditParamsValue string - -const ( - ZoneSettingOpportunisticOnionEditParamsValueOn ZoneSettingOpportunisticOnionEditParamsValue = "on" - ZoneSettingOpportunisticOnionEditParamsValueOff ZoneSettingOpportunisticOnionEditParamsValue = "off" -) - -type ZoneSettingOpportunisticOnionEditResponseEnvelope struct { - Errors []ZoneSettingOpportunisticOnionEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingOpportunisticOnionEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Add an Alt-Svc header to all legitimate requests from Tor, allowing the - // connection to use our onion services instead of exit nodes. - Result ZoneSettingOpportunisticOnionEditResponse `json:"result"` - JSON zoneSettingOpportunisticOnionEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingOpportunisticOnionEditResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingOpportunisticOnionEditResponseEnvelope] -type zoneSettingOpportunisticOnionEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOpportunisticOnionEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOpportunisticOnionEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOpportunisticOnionEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOpportunisticOnionEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingOpportunisticOnionEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZoneSettingOpportunisticOnionEditResponseEnvelopeErrors] -type zoneSettingOpportunisticOnionEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOpportunisticOnionEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOpportunisticOnionEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOpportunisticOnionEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOpportunisticOnionEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingOpportunisticOnionEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZoneSettingOpportunisticOnionEditResponseEnvelopeMessages] -type zoneSettingOpportunisticOnionEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOpportunisticOnionEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOpportunisticOnionEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOpportunisticOnionGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingOpportunisticOnionGetResponseEnvelope struct { - Errors []ZoneSettingOpportunisticOnionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingOpportunisticOnionGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Add an Alt-Svc header to all legitimate requests from Tor, allowing the - // connection to use our onion services instead of exit nodes. - Result ZoneSettingOpportunisticOnionGetResponse `json:"result"` - JSON zoneSettingOpportunisticOnionGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingOpportunisticOnionGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingOpportunisticOnionGetResponseEnvelope] -type zoneSettingOpportunisticOnionGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOpportunisticOnionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOpportunisticOnionGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOpportunisticOnionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOpportunisticOnionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingOpportunisticOnionGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingOpportunisticOnionGetResponseEnvelopeErrors] -type zoneSettingOpportunisticOnionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOpportunisticOnionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOpportunisticOnionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOpportunisticOnionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOpportunisticOnionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingOpportunisticOnionGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZoneSettingOpportunisticOnionGetResponseEnvelopeMessages] -type zoneSettingOpportunisticOnionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOpportunisticOnionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOpportunisticOnionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingopportunisticonion_test.go b/zonesettingopportunisticonion_test.go deleted file mode 100644 index 4821dc96635..00000000000 --- a/zonesettingopportunisticonion_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingOpportunisticOnionEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.OpportunisticOnion.Edit(context.TODO(), cloudflare.ZoneSettingOpportunisticOnionEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingOpportunisticOnionEditParamsValueOn), - }) - 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 TestZoneSettingOpportunisticOnionGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.OpportunisticOnion.Get(context.TODO(), cloudflare.ZoneSettingOpportunisticOnionGetParams{ - ZoneID: cloudflare.F("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/zonesettingorangetoorange.go b/zonesettingorangetoorange.go deleted file mode 100644 index 1ab563007ea..00000000000 --- a/zonesettingorangetoorange.go +++ /dev/null @@ -1,383 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingOrangeToOrangeService 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 -// [NewZoneSettingOrangeToOrangeService] method instead. -type ZoneSettingOrangeToOrangeService struct { - Options []option.RequestOption -} - -// NewZoneSettingOrangeToOrangeService 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 NewZoneSettingOrangeToOrangeService(opts ...option.RequestOption) (r *ZoneSettingOrangeToOrangeService) { - r = &ZoneSettingOrangeToOrangeService{} - r.Options = opts - return -} - -// Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also -// on Cloudflare. -func (r *ZoneSettingOrangeToOrangeService) Edit(ctx context.Context, params ZoneSettingOrangeToOrangeEditParams, opts ...option.RequestOption) (res *ZoneSettingOrangeToOrangeEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingOrangeToOrangeEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/orange_to_orange", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also -// on Cloudflare. -func (r *ZoneSettingOrangeToOrangeService) Get(ctx context.Context, query ZoneSettingOrangeToOrangeGetParams, opts ...option.RequestOption) (res *ZoneSettingOrangeToOrangeGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingOrangeToOrangeGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/orange_to_orange", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also -// on Cloudflare. -type ZoneSettingOrangeToOrangeEditResponse struct { - // ID of the zone setting. - ID ZoneSettingOrangeToOrangeEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingOrangeToOrangeEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingOrangeToOrangeEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingOrangeToOrangeEditResponseJSON `json:"-"` -} - -// zoneSettingOrangeToOrangeEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingOrangeToOrangeEditResponse] -type zoneSettingOrangeToOrangeEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOrangeToOrangeEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOrangeToOrangeEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingOrangeToOrangeEditResponseID string - -const ( - ZoneSettingOrangeToOrangeEditResponseIDOrangeToOrange ZoneSettingOrangeToOrangeEditResponseID = "orange_to_orange" -) - -// Current value of the zone setting. -type ZoneSettingOrangeToOrangeEditResponseValue string - -const ( - ZoneSettingOrangeToOrangeEditResponseValueOn ZoneSettingOrangeToOrangeEditResponseValue = "on" - ZoneSettingOrangeToOrangeEditResponseValueOff ZoneSettingOrangeToOrangeEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingOrangeToOrangeEditResponseEditable bool - -const ( - ZoneSettingOrangeToOrangeEditResponseEditableTrue ZoneSettingOrangeToOrangeEditResponseEditable = true - ZoneSettingOrangeToOrangeEditResponseEditableFalse ZoneSettingOrangeToOrangeEditResponseEditable = false -) - -// Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also -// on Cloudflare. -type ZoneSettingOrangeToOrangeGetResponse struct { - // ID of the zone setting. - ID ZoneSettingOrangeToOrangeGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingOrangeToOrangeGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingOrangeToOrangeGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingOrangeToOrangeGetResponseJSON `json:"-"` -} - -// zoneSettingOrangeToOrangeGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingOrangeToOrangeGetResponse] -type zoneSettingOrangeToOrangeGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOrangeToOrangeGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOrangeToOrangeGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingOrangeToOrangeGetResponseID string - -const ( - ZoneSettingOrangeToOrangeGetResponseIDOrangeToOrange ZoneSettingOrangeToOrangeGetResponseID = "orange_to_orange" -) - -// Current value of the zone setting. -type ZoneSettingOrangeToOrangeGetResponseValue string - -const ( - ZoneSettingOrangeToOrangeGetResponseValueOn ZoneSettingOrangeToOrangeGetResponseValue = "on" - ZoneSettingOrangeToOrangeGetResponseValueOff ZoneSettingOrangeToOrangeGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingOrangeToOrangeGetResponseEditable bool - -const ( - ZoneSettingOrangeToOrangeGetResponseEditableTrue ZoneSettingOrangeToOrangeGetResponseEditable = true - ZoneSettingOrangeToOrangeGetResponseEditableFalse ZoneSettingOrangeToOrangeGetResponseEditable = false -) - -type ZoneSettingOrangeToOrangeEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also - // on Cloudflare. - Value param.Field[ZoneSettingOrangeToOrangeEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingOrangeToOrangeEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also -// on Cloudflare. -type ZoneSettingOrangeToOrangeEditParamsValue struct { - // ID of the zone setting. - ID param.Field[ZoneSettingOrangeToOrangeEditParamsValueID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingOrangeToOrangeEditParamsValueValue] `json:"value,required"` -} - -func (r ZoneSettingOrangeToOrangeEditParamsValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// ID of the zone setting. -type ZoneSettingOrangeToOrangeEditParamsValueID string - -const ( - ZoneSettingOrangeToOrangeEditParamsValueIDOrangeToOrange ZoneSettingOrangeToOrangeEditParamsValueID = "orange_to_orange" -) - -// Current value of the zone setting. -type ZoneSettingOrangeToOrangeEditParamsValueValue string - -const ( - ZoneSettingOrangeToOrangeEditParamsValueValueOn ZoneSettingOrangeToOrangeEditParamsValueValue = "on" - ZoneSettingOrangeToOrangeEditParamsValueValueOff ZoneSettingOrangeToOrangeEditParamsValueValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingOrangeToOrangeEditParamsValueEditable bool - -const ( - ZoneSettingOrangeToOrangeEditParamsValueEditableTrue ZoneSettingOrangeToOrangeEditParamsValueEditable = true - ZoneSettingOrangeToOrangeEditParamsValueEditableFalse ZoneSettingOrangeToOrangeEditParamsValueEditable = false -) - -type ZoneSettingOrangeToOrangeEditResponseEnvelope struct { - Errors []ZoneSettingOrangeToOrangeEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingOrangeToOrangeEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also - // on Cloudflare. - Result ZoneSettingOrangeToOrangeEditResponse `json:"result"` - JSON zoneSettingOrangeToOrangeEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingOrangeToOrangeEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingOrangeToOrangeEditResponseEnvelope] -type zoneSettingOrangeToOrangeEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOrangeToOrangeEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOrangeToOrangeEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOrangeToOrangeEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOrangeToOrangeEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingOrangeToOrangeEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingOrangeToOrangeEditResponseEnvelopeErrors] -type zoneSettingOrangeToOrangeEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOrangeToOrangeEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOrangeToOrangeEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOrangeToOrangeEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOrangeToOrangeEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingOrangeToOrangeEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingOrangeToOrangeEditResponseEnvelopeMessages] -type zoneSettingOrangeToOrangeEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOrangeToOrangeEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOrangeToOrangeEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOrangeToOrangeGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingOrangeToOrangeGetResponseEnvelope struct { - Errors []ZoneSettingOrangeToOrangeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingOrangeToOrangeGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Orange to Orange (O2O) allows zones on Cloudflare to CNAME to other zones also - // on Cloudflare. - Result ZoneSettingOrangeToOrangeGetResponse `json:"result"` - JSON zoneSettingOrangeToOrangeGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingOrangeToOrangeGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingOrangeToOrangeGetResponseEnvelope] -type zoneSettingOrangeToOrangeGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOrangeToOrangeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOrangeToOrangeGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOrangeToOrangeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOrangeToOrangeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingOrangeToOrangeGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingOrangeToOrangeGetResponseEnvelopeErrors] -type zoneSettingOrangeToOrangeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOrangeToOrangeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOrangeToOrangeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOrangeToOrangeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOrangeToOrangeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingOrangeToOrangeGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingOrangeToOrangeGetResponseEnvelopeMessages] -type zoneSettingOrangeToOrangeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOrangeToOrangeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOrangeToOrangeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingorangetoorange_test.go b/zonesettingorangetoorange_test.go deleted file mode 100644 index 0e41998b3ce..00000000000 --- a/zonesettingorangetoorange_test.go +++ /dev/null @@ -1,70 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingOrangeToOrangeEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Zones.Settings.OrangeToOrange.Edit(context.TODO(), cloudflare.ZoneSettingOrangeToOrangeEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingOrangeToOrangeEditParamsValue{ - ID: cloudflare.F(cloudflare.ZoneSettingOrangeToOrangeEditParamsValueIDOrangeToOrange), - Value: cloudflare.F(cloudflare.ZoneSettingOrangeToOrangeEditParamsValueValueOn), - }), - }) - 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 TestZoneSettingOrangeToOrangeGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.OrangeToOrange.Get(context.TODO(), cloudflare.ZoneSettingOrangeToOrangeGetParams{ - ZoneID: cloudflare.F("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/zonesettingoriginerrorpagepassthru.go b/zonesettingoriginerrorpagepassthru.go deleted file mode 100644 index 7bea43afe80..00000000000 --- a/zonesettingoriginerrorpagepassthru.go +++ /dev/null @@ -1,364 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingOriginErrorPagePassThruService 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 -// [NewZoneSettingOriginErrorPagePassThruService] method instead. -type ZoneSettingOriginErrorPagePassThruService struct { - Options []option.RequestOption -} - -// NewZoneSettingOriginErrorPagePassThruService 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 NewZoneSettingOriginErrorPagePassThruService(opts ...option.RequestOption) (r *ZoneSettingOriginErrorPagePassThruService) { - r = &ZoneSettingOriginErrorPagePassThruService{} - r.Options = opts - return -} - -// Cloudflare will proxy customer error pages on any 502,504 errors on origin -// server instead of showing a default Cloudflare error page. This does not apply -// to 522 errors and is limited to Enterprise Zones. -func (r *ZoneSettingOriginErrorPagePassThruService) Edit(ctx context.Context, params ZoneSettingOriginErrorPagePassThruEditParams, opts ...option.RequestOption) (res *ZoneSettingOriginErrorPagePassThruEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingOriginErrorPagePassThruEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/origin_error_page_pass_thru", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Cloudflare will proxy customer error pages on any 502,504 errors on origin -// server instead of showing a default Cloudflare error page. This does not apply -// to 522 errors and is limited to Enterprise Zones. -func (r *ZoneSettingOriginErrorPagePassThruService) Get(ctx context.Context, query ZoneSettingOriginErrorPagePassThruGetParams, opts ...option.RequestOption) (res *ZoneSettingOriginErrorPagePassThruGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingOriginErrorPagePassThruGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/origin_error_page_pass_thru", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Cloudflare will proxy customer error pages on any 502,504 errors on origin -// server instead of showing a default Cloudflare error page. This does not apply -// to 522 errors and is limited to Enterprise Zones. -type ZoneSettingOriginErrorPagePassThruEditResponse struct { - // ID of the zone setting. - ID ZoneSettingOriginErrorPagePassThruEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingOriginErrorPagePassThruEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingOriginErrorPagePassThruEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingOriginErrorPagePassThruEditResponseJSON `json:"-"` -} - -// zoneSettingOriginErrorPagePassThruEditResponseJSON contains the JSON metadata -// for the struct [ZoneSettingOriginErrorPagePassThruEditResponse] -type zoneSettingOriginErrorPagePassThruEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOriginErrorPagePassThruEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOriginErrorPagePassThruEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingOriginErrorPagePassThruEditResponseID string - -const ( - ZoneSettingOriginErrorPagePassThruEditResponseIDOriginErrorPagePassThru ZoneSettingOriginErrorPagePassThruEditResponseID = "origin_error_page_pass_thru" -) - -// Current value of the zone setting. -type ZoneSettingOriginErrorPagePassThruEditResponseValue string - -const ( - ZoneSettingOriginErrorPagePassThruEditResponseValueOn ZoneSettingOriginErrorPagePassThruEditResponseValue = "on" - ZoneSettingOriginErrorPagePassThruEditResponseValueOff ZoneSettingOriginErrorPagePassThruEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingOriginErrorPagePassThruEditResponseEditable bool - -const ( - ZoneSettingOriginErrorPagePassThruEditResponseEditableTrue ZoneSettingOriginErrorPagePassThruEditResponseEditable = true - ZoneSettingOriginErrorPagePassThruEditResponseEditableFalse ZoneSettingOriginErrorPagePassThruEditResponseEditable = false -) - -// Cloudflare will proxy customer error pages on any 502,504 errors on origin -// server instead of showing a default Cloudflare error page. This does not apply -// to 522 errors and is limited to Enterprise Zones. -type ZoneSettingOriginErrorPagePassThruGetResponse struct { - // ID of the zone setting. - ID ZoneSettingOriginErrorPagePassThruGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingOriginErrorPagePassThruGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingOriginErrorPagePassThruGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingOriginErrorPagePassThruGetResponseJSON `json:"-"` -} - -// zoneSettingOriginErrorPagePassThruGetResponseJSON contains the JSON metadata for -// the struct [ZoneSettingOriginErrorPagePassThruGetResponse] -type zoneSettingOriginErrorPagePassThruGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOriginErrorPagePassThruGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOriginErrorPagePassThruGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingOriginErrorPagePassThruGetResponseID string - -const ( - ZoneSettingOriginErrorPagePassThruGetResponseIDOriginErrorPagePassThru ZoneSettingOriginErrorPagePassThruGetResponseID = "origin_error_page_pass_thru" -) - -// Current value of the zone setting. -type ZoneSettingOriginErrorPagePassThruGetResponseValue string - -const ( - ZoneSettingOriginErrorPagePassThruGetResponseValueOn ZoneSettingOriginErrorPagePassThruGetResponseValue = "on" - ZoneSettingOriginErrorPagePassThruGetResponseValueOff ZoneSettingOriginErrorPagePassThruGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingOriginErrorPagePassThruGetResponseEditable bool - -const ( - ZoneSettingOriginErrorPagePassThruGetResponseEditableTrue ZoneSettingOriginErrorPagePassThruGetResponseEditable = true - ZoneSettingOriginErrorPagePassThruGetResponseEditableFalse ZoneSettingOriginErrorPagePassThruGetResponseEditable = false -) - -type ZoneSettingOriginErrorPagePassThruEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingOriginErrorPagePassThruEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingOriginErrorPagePassThruEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingOriginErrorPagePassThruEditParamsValue string - -const ( - ZoneSettingOriginErrorPagePassThruEditParamsValueOn ZoneSettingOriginErrorPagePassThruEditParamsValue = "on" - ZoneSettingOriginErrorPagePassThruEditParamsValueOff ZoneSettingOriginErrorPagePassThruEditParamsValue = "off" -) - -type ZoneSettingOriginErrorPagePassThruEditResponseEnvelope struct { - Errors []ZoneSettingOriginErrorPagePassThruEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingOriginErrorPagePassThruEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Cloudflare will proxy customer error pages on any 502,504 errors on origin - // server instead of showing a default Cloudflare error page. This does not apply - // to 522 errors and is limited to Enterprise Zones. - Result ZoneSettingOriginErrorPagePassThruEditResponse `json:"result"` - JSON zoneSettingOriginErrorPagePassThruEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingOriginErrorPagePassThruEditResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZoneSettingOriginErrorPagePassThruEditResponseEnvelope] -type zoneSettingOriginErrorPagePassThruEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOriginErrorPagePassThruEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOriginErrorPagePassThruEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOriginErrorPagePassThruEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOriginErrorPagePassThruEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingOriginErrorPagePassThruEditResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZoneSettingOriginErrorPagePassThruEditResponseEnvelopeErrors] -type zoneSettingOriginErrorPagePassThruEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOriginErrorPagePassThruEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOriginErrorPagePassThruEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOriginErrorPagePassThruEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOriginErrorPagePassThruEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingOriginErrorPagePassThruEditResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZoneSettingOriginErrorPagePassThruEditResponseEnvelopeMessages] -type zoneSettingOriginErrorPagePassThruEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOriginErrorPagePassThruEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOriginErrorPagePassThruEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOriginErrorPagePassThruGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingOriginErrorPagePassThruGetResponseEnvelope struct { - Errors []ZoneSettingOriginErrorPagePassThruGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingOriginErrorPagePassThruGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Cloudflare will proxy customer error pages on any 502,504 errors on origin - // server instead of showing a default Cloudflare error page. This does not apply - // to 522 errors and is limited to Enterprise Zones. - Result ZoneSettingOriginErrorPagePassThruGetResponse `json:"result"` - JSON zoneSettingOriginErrorPagePassThruGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingOriginErrorPagePassThruGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZoneSettingOriginErrorPagePassThruGetResponseEnvelope] -type zoneSettingOriginErrorPagePassThruGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOriginErrorPagePassThruGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOriginErrorPagePassThruGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOriginErrorPagePassThruGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOriginErrorPagePassThruGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingOriginErrorPagePassThruGetResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZoneSettingOriginErrorPagePassThruGetResponseEnvelopeErrors] -type zoneSettingOriginErrorPagePassThruGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOriginErrorPagePassThruGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOriginErrorPagePassThruGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOriginErrorPagePassThruGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOriginErrorPagePassThruGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingOriginErrorPagePassThruGetResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZoneSettingOriginErrorPagePassThruGetResponseEnvelopeMessages] -type zoneSettingOriginErrorPagePassThruGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOriginErrorPagePassThruGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOriginErrorPagePassThruGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingoriginerrorpagepassthru_test.go b/zonesettingoriginerrorpagepassthru_test.go deleted file mode 100644 index 992e2f443b8..00000000000 --- a/zonesettingoriginerrorpagepassthru_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingOriginErrorPagePassThruEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.OriginErrorPagePassThru.Edit(context.TODO(), cloudflare.ZoneSettingOriginErrorPagePassThruEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingOriginErrorPagePassThruEditParamsValueOn), - }) - 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 TestZoneSettingOriginErrorPagePassThruGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.OriginErrorPagePassThru.Get(context.TODO(), cloudflare.ZoneSettingOriginErrorPagePassThruGetParams{ - ZoneID: cloudflare.F("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/zonesettingoriginmaxhttpversion.go b/zonesettingoriginmaxhttpversion.go deleted file mode 100644 index 432e4ca92fe..00000000000 --- a/zonesettingoriginmaxhttpversion.go +++ /dev/null @@ -1,369 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingOriginMaxHTTPVersionService 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 -// [NewZoneSettingOriginMaxHTTPVersionService] method instead. -type ZoneSettingOriginMaxHTTPVersionService struct { - Options []option.RequestOption -} - -// NewZoneSettingOriginMaxHTTPVersionService 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 NewZoneSettingOriginMaxHTTPVersionService(opts ...option.RequestOption) (r *ZoneSettingOriginMaxHTTPVersionService) { - r = &ZoneSettingOriginMaxHTTPVersionService{} - r.Options = opts - return -} - -// Origin Max HTTP Setting Version sets the highest HTTP version Cloudflare will -// attempt to use with your origin. This setting allows Cloudflare to make HTTP/2 -// requests to your origin. (Refer to -// [Enable HTTP/2 to Origin](https://developers.cloudflare.com/cache/how-to/enable-http2-to-origin/), -// for more information.). The default value is "2" for all plan types except ENT -// where it is "1" -func (r *ZoneSettingOriginMaxHTTPVersionService) Edit(ctx context.Context, params ZoneSettingOriginMaxHTTPVersionEditParams, opts ...option.RequestOption) (res *ZoneSettingOriginMaxHTTPVersionEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingOriginMaxHTTPVersionEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/origin_max_http_version", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Origin Max HTTP Setting Version sets the highest HTTP version Cloudflare will -// attempt to use with your origin. This setting allows Cloudflare to make HTTP/2 -// requests to your origin. (Refer to -// [Enable HTTP/2 to Origin](https://developers.cloudflare.com/cache/how-to/enable-http2-to-origin/), -// for more information.). The default value is "2" for all plan types except ENT -// where it is "1" -func (r *ZoneSettingOriginMaxHTTPVersionService) Get(ctx context.Context, query ZoneSettingOriginMaxHTTPVersionGetParams, opts ...option.RequestOption) (res *ZoneSettingOriginMaxHTTPVersionGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingOriginMaxHTTPVersionGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/origin_max_http_version", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Origin Max HTTP Setting Version sets the highest HTTP version Cloudflare will -// attempt to use with your origin. This setting allows Cloudflare to make HTTP/2 -// requests to your origin. (Refer to -// [Enable HTTP/2 to Origin](https://developers.cloudflare.com/cache/how-to/enable-http2-to-origin/), -// for more information.). The default value is "2" for all plan types except ENT -// where it is "1" -type ZoneSettingOriginMaxHTTPVersionEditResponse struct { - // Value of the zone setting. - ID ZoneSettingOriginMaxHTTPVersionEditResponseID `json:"id,required"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` - // Value of the Origin Max HTTP Version Setting. - Value ZoneSettingOriginMaxHTTPVersionEditResponseValue `json:"value,required"` - JSON zoneSettingOriginMaxHTTPVersionEditResponseJSON `json:"-"` -} - -// zoneSettingOriginMaxHTTPVersionEditResponseJSON contains the JSON metadata for -// the struct [ZoneSettingOriginMaxHTTPVersionEditResponse] -type zoneSettingOriginMaxHTTPVersionEditResponseJSON struct { - ID apijson.Field - ModifiedOn apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOriginMaxHTTPVersionEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOriginMaxHTTPVersionEditResponseJSON) RawJSON() string { - return r.raw -} - -// Value of the zone setting. -type ZoneSettingOriginMaxHTTPVersionEditResponseID string - -const ( - ZoneSettingOriginMaxHTTPVersionEditResponseIDOriginMaxHTTPVersion ZoneSettingOriginMaxHTTPVersionEditResponseID = "origin_max_http_version" -) - -// Value of the Origin Max HTTP Version Setting. -type ZoneSettingOriginMaxHTTPVersionEditResponseValue string - -const ( - ZoneSettingOriginMaxHTTPVersionEditResponseValue2 ZoneSettingOriginMaxHTTPVersionEditResponseValue = "2" - ZoneSettingOriginMaxHTTPVersionEditResponseValue1 ZoneSettingOriginMaxHTTPVersionEditResponseValue = "1" -) - -// Origin Max HTTP Setting Version sets the highest HTTP version Cloudflare will -// attempt to use with your origin. This setting allows Cloudflare to make HTTP/2 -// requests to your origin. (Refer to -// [Enable HTTP/2 to Origin](https://developers.cloudflare.com/cache/how-to/enable-http2-to-origin/), -// for more information.). The default value is "2" for all plan types except ENT -// where it is "1" -type ZoneSettingOriginMaxHTTPVersionGetResponse struct { - // Value of the zone setting. - ID ZoneSettingOriginMaxHTTPVersionGetResponseID `json:"id,required"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` - // Value of the Origin Max HTTP Version Setting. - Value ZoneSettingOriginMaxHTTPVersionGetResponseValue `json:"value,required"` - JSON zoneSettingOriginMaxHTTPVersionGetResponseJSON `json:"-"` -} - -// zoneSettingOriginMaxHTTPVersionGetResponseJSON contains the JSON metadata for -// the struct [ZoneSettingOriginMaxHTTPVersionGetResponse] -type zoneSettingOriginMaxHTTPVersionGetResponseJSON struct { - ID apijson.Field - ModifiedOn apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOriginMaxHTTPVersionGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOriginMaxHTTPVersionGetResponseJSON) RawJSON() string { - return r.raw -} - -// Value of the zone setting. -type ZoneSettingOriginMaxHTTPVersionGetResponseID string - -const ( - ZoneSettingOriginMaxHTTPVersionGetResponseIDOriginMaxHTTPVersion ZoneSettingOriginMaxHTTPVersionGetResponseID = "origin_max_http_version" -) - -// Value of the Origin Max HTTP Version Setting. -type ZoneSettingOriginMaxHTTPVersionGetResponseValue string - -const ( - ZoneSettingOriginMaxHTTPVersionGetResponseValue2 ZoneSettingOriginMaxHTTPVersionGetResponseValue = "2" - ZoneSettingOriginMaxHTTPVersionGetResponseValue1 ZoneSettingOriginMaxHTTPVersionGetResponseValue = "1" -) - -type ZoneSettingOriginMaxHTTPVersionEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the Origin Max HTTP Version Setting. - Value param.Field[ZoneSettingOriginMaxHTTPVersionEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingOriginMaxHTTPVersionEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the Origin Max HTTP Version Setting. -type ZoneSettingOriginMaxHTTPVersionEditParamsValue string - -const ( - ZoneSettingOriginMaxHTTPVersionEditParamsValue2 ZoneSettingOriginMaxHTTPVersionEditParamsValue = "2" - ZoneSettingOriginMaxHTTPVersionEditParamsValue1 ZoneSettingOriginMaxHTTPVersionEditParamsValue = "1" -) - -type ZoneSettingOriginMaxHTTPVersionEditResponseEnvelope struct { - Errors []ZoneSettingOriginMaxHTTPVersionEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingOriginMaxHTTPVersionEditResponseEnvelopeMessages `json:"messages,required"` - // Origin Max HTTP Setting Version sets the highest HTTP version Cloudflare will - // attempt to use with your origin. This setting allows Cloudflare to make HTTP/2 - // requests to your origin. (Refer to - // [Enable HTTP/2 to Origin](https://developers.cloudflare.com/cache/how-to/enable-http2-to-origin/), - // for more information.). The default value is "2" for all plan types except ENT - // where it is "1" - Result ZoneSettingOriginMaxHTTPVersionEditResponse `json:"result,required"` - // Whether the API call was successful - Success ZoneSettingOriginMaxHTTPVersionEditResponseEnvelopeSuccess `json:"success,required"` - JSON zoneSettingOriginMaxHTTPVersionEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingOriginMaxHTTPVersionEditResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZoneSettingOriginMaxHTTPVersionEditResponseEnvelope] -type zoneSettingOriginMaxHTTPVersionEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOriginMaxHTTPVersionEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOriginMaxHTTPVersionEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOriginMaxHTTPVersionEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOriginMaxHTTPVersionEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingOriginMaxHTTPVersionEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZoneSettingOriginMaxHTTPVersionEditResponseEnvelopeErrors] -type zoneSettingOriginMaxHTTPVersionEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOriginMaxHTTPVersionEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOriginMaxHTTPVersionEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOriginMaxHTTPVersionEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOriginMaxHTTPVersionEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingOriginMaxHTTPVersionEditResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZoneSettingOriginMaxHTTPVersionEditResponseEnvelopeMessages] -type zoneSettingOriginMaxHTTPVersionEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOriginMaxHTTPVersionEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOriginMaxHTTPVersionEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZoneSettingOriginMaxHTTPVersionEditResponseEnvelopeSuccess bool - -const ( - ZoneSettingOriginMaxHTTPVersionEditResponseEnvelopeSuccessTrue ZoneSettingOriginMaxHTTPVersionEditResponseEnvelopeSuccess = true -) - -type ZoneSettingOriginMaxHTTPVersionGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingOriginMaxHTTPVersionGetResponseEnvelope struct { - Errors []ZoneSettingOriginMaxHTTPVersionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingOriginMaxHTTPVersionGetResponseEnvelopeMessages `json:"messages,required"` - // Origin Max HTTP Setting Version sets the highest HTTP version Cloudflare will - // attempt to use with your origin. This setting allows Cloudflare to make HTTP/2 - // requests to your origin. (Refer to - // [Enable HTTP/2 to Origin](https://developers.cloudflare.com/cache/how-to/enable-http2-to-origin/), - // for more information.). The default value is "2" for all plan types except ENT - // where it is "1" - Result ZoneSettingOriginMaxHTTPVersionGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZoneSettingOriginMaxHTTPVersionGetResponseEnvelopeSuccess `json:"success,required"` - JSON zoneSettingOriginMaxHTTPVersionGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingOriginMaxHTTPVersionGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZoneSettingOriginMaxHTTPVersionGetResponseEnvelope] -type zoneSettingOriginMaxHTTPVersionGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOriginMaxHTTPVersionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOriginMaxHTTPVersionGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOriginMaxHTTPVersionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOriginMaxHTTPVersionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingOriginMaxHTTPVersionGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZoneSettingOriginMaxHTTPVersionGetResponseEnvelopeErrors] -type zoneSettingOriginMaxHTTPVersionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOriginMaxHTTPVersionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOriginMaxHTTPVersionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingOriginMaxHTTPVersionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingOriginMaxHTTPVersionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingOriginMaxHTTPVersionGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZoneSettingOriginMaxHTTPVersionGetResponseEnvelopeMessages] -type zoneSettingOriginMaxHTTPVersionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingOriginMaxHTTPVersionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingOriginMaxHTTPVersionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZoneSettingOriginMaxHTTPVersionGetResponseEnvelopeSuccess bool - -const ( - ZoneSettingOriginMaxHTTPVersionGetResponseEnvelopeSuccessTrue ZoneSettingOriginMaxHTTPVersionGetResponseEnvelopeSuccess = true -) diff --git a/zonesettingoriginmaxhttpversion_test.go b/zonesettingoriginmaxhttpversion_test.go deleted file mode 100644 index 34a104fdef4..00000000000 --- a/zonesettingoriginmaxhttpversion_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingOriginMaxHTTPVersionEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.OriginMaxHTTPVersion.Edit(context.TODO(), cloudflare.ZoneSettingOriginMaxHTTPVersionEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingOriginMaxHTTPVersionEditParamsValue2), - }) - 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 TestZoneSettingOriginMaxHTTPVersionGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.OriginMaxHTTPVersion.Get(context.TODO(), cloudflare.ZoneSettingOriginMaxHTTPVersionGetParams{ - ZoneID: cloudflare.F("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/zonesettingpolish.go b/zonesettingpolish.go deleted file mode 100644 index 859d7d175cf..00000000000 --- a/zonesettingpolish.go +++ /dev/null @@ -1,412 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingPolishService 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 [NewZoneSettingPolishService] method -// instead. -type ZoneSettingPolishService struct { - Options []option.RequestOption -} - -// NewZoneSettingPolishService 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 NewZoneSettingPolishService(opts ...option.RequestOption) (r *ZoneSettingPolishService) { - r = &ZoneSettingPolishService{} - r.Options = opts - return -} - -// Automatically optimize image loading for website visitors on mobile devices. -// Refer to our [blog post](http://blog.cloudflare.com/polish-solving-mobile-speed) -// for more information. -func (r *ZoneSettingPolishService) Edit(ctx context.Context, params ZoneSettingPolishEditParams, opts ...option.RequestOption) (res *ZoneSettingPolishEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingPolishEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/polish", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Automatically optimize image loading for website visitors on mobile devices. -// Refer to our [blog post](http://blog.cloudflare.com/polish-solving-mobile-speed) -// for more information. -func (r *ZoneSettingPolishService) Get(ctx context.Context, query ZoneSettingPolishGetParams, opts ...option.RequestOption) (res *ZoneSettingPolishGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingPolishGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/polish", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Removes metadata and compresses your images for faster page load times. Basic -// (Lossless): Reduce the size of PNG, JPEG, and GIF files - no impact on visual -// quality. Basic + JPEG (Lossy): Further reduce the size of JPEG files for faster -// image loading. Larger JPEGs are converted to progressive images, loading a -// lower-resolution image first and ending in a higher-resolution version. Not -// recommended for hi-res photography sites. -type ZoneSettingPolishEditResponse struct { - // ID of the zone setting. - ID ZoneSettingPolishEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingPolishEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingPolishEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingPolishEditResponseJSON `json:"-"` -} - -// zoneSettingPolishEditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingPolishEditResponse] -type zoneSettingPolishEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPolishEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPolishEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingPolishEditResponseID string - -const ( - ZoneSettingPolishEditResponseIDPolish ZoneSettingPolishEditResponseID = "polish" -) - -// Current value of the zone setting. -type ZoneSettingPolishEditResponseValue string - -const ( - ZoneSettingPolishEditResponseValueOff ZoneSettingPolishEditResponseValue = "off" - ZoneSettingPolishEditResponseValueLossless ZoneSettingPolishEditResponseValue = "lossless" - ZoneSettingPolishEditResponseValueLossy ZoneSettingPolishEditResponseValue = "lossy" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingPolishEditResponseEditable bool - -const ( - ZoneSettingPolishEditResponseEditableTrue ZoneSettingPolishEditResponseEditable = true - ZoneSettingPolishEditResponseEditableFalse ZoneSettingPolishEditResponseEditable = false -) - -// Removes metadata and compresses your images for faster page load times. Basic -// (Lossless): Reduce the size of PNG, JPEG, and GIF files - no impact on visual -// quality. Basic + JPEG (Lossy): Further reduce the size of JPEG files for faster -// image loading. Larger JPEGs are converted to progressive images, loading a -// lower-resolution image first and ending in a higher-resolution version. Not -// recommended for hi-res photography sites. -type ZoneSettingPolishGetResponse struct { - // ID of the zone setting. - ID ZoneSettingPolishGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingPolishGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingPolishGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingPolishGetResponseJSON `json:"-"` -} - -// zoneSettingPolishGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingPolishGetResponse] -type zoneSettingPolishGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPolishGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPolishGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingPolishGetResponseID string - -const ( - ZoneSettingPolishGetResponseIDPolish ZoneSettingPolishGetResponseID = "polish" -) - -// Current value of the zone setting. -type ZoneSettingPolishGetResponseValue string - -const ( - ZoneSettingPolishGetResponseValueOff ZoneSettingPolishGetResponseValue = "off" - ZoneSettingPolishGetResponseValueLossless ZoneSettingPolishGetResponseValue = "lossless" - ZoneSettingPolishGetResponseValueLossy ZoneSettingPolishGetResponseValue = "lossy" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingPolishGetResponseEditable bool - -const ( - ZoneSettingPolishGetResponseEditableTrue ZoneSettingPolishGetResponseEditable = true - ZoneSettingPolishGetResponseEditableFalse ZoneSettingPolishGetResponseEditable = false -) - -type ZoneSettingPolishEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Removes metadata and compresses your images for faster page load times. Basic - // (Lossless): Reduce the size of PNG, JPEG, and GIF files - no impact on visual - // quality. Basic + JPEG (Lossy): Further reduce the size of JPEG files for faster - // image loading. Larger JPEGs are converted to progressive images, loading a - // lower-resolution image first and ending in a higher-resolution version. Not - // recommended for hi-res photography sites. - Value param.Field[ZoneSettingPolishEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingPolishEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Removes metadata and compresses your images for faster page load times. Basic -// (Lossless): Reduce the size of PNG, JPEG, and GIF files - no impact on visual -// quality. Basic + JPEG (Lossy): Further reduce the size of JPEG files for faster -// image loading. Larger JPEGs are converted to progressive images, loading a -// lower-resolution image first and ending in a higher-resolution version. Not -// recommended for hi-res photography sites. -type ZoneSettingPolishEditParamsValue struct { - // ID of the zone setting. - ID param.Field[ZoneSettingPolishEditParamsValueID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingPolishEditParamsValueValue] `json:"value,required"` -} - -func (r ZoneSettingPolishEditParamsValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// ID of the zone setting. -type ZoneSettingPolishEditParamsValueID string - -const ( - ZoneSettingPolishEditParamsValueIDPolish ZoneSettingPolishEditParamsValueID = "polish" -) - -// Current value of the zone setting. -type ZoneSettingPolishEditParamsValueValue string - -const ( - ZoneSettingPolishEditParamsValueValueOff ZoneSettingPolishEditParamsValueValue = "off" - ZoneSettingPolishEditParamsValueValueLossless ZoneSettingPolishEditParamsValueValue = "lossless" - ZoneSettingPolishEditParamsValueValueLossy ZoneSettingPolishEditParamsValueValue = "lossy" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingPolishEditParamsValueEditable bool - -const ( - ZoneSettingPolishEditParamsValueEditableTrue ZoneSettingPolishEditParamsValueEditable = true - ZoneSettingPolishEditParamsValueEditableFalse ZoneSettingPolishEditParamsValueEditable = false -) - -type ZoneSettingPolishEditResponseEnvelope struct { - Errors []ZoneSettingPolishEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingPolishEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Removes metadata and compresses your images for faster page load times. Basic - // (Lossless): Reduce the size of PNG, JPEG, and GIF files - no impact on visual - // quality. Basic + JPEG (Lossy): Further reduce the size of JPEG files for faster - // image loading. Larger JPEGs are converted to progressive images, loading a - // lower-resolution image first and ending in a higher-resolution version. Not - // recommended for hi-res photography sites. - Result ZoneSettingPolishEditResponse `json:"result"` - JSON zoneSettingPolishEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingPolishEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingPolishEditResponseEnvelope] -type zoneSettingPolishEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPolishEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPolishEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingPolishEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingPolishEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingPolishEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSettingPolishEditResponseEnvelopeErrors] -type zoneSettingPolishEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPolishEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPolishEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingPolishEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingPolishEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingPolishEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingPolishEditResponseEnvelopeMessages] -type zoneSettingPolishEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPolishEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPolishEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingPolishGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingPolishGetResponseEnvelope struct { - Errors []ZoneSettingPolishGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingPolishGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Removes metadata and compresses your images for faster page load times. Basic - // (Lossless): Reduce the size of PNG, JPEG, and GIF files - no impact on visual - // quality. Basic + JPEG (Lossy): Further reduce the size of JPEG files for faster - // image loading. Larger JPEGs are converted to progressive images, loading a - // lower-resolution image first and ending in a higher-resolution version. Not - // recommended for hi-res photography sites. - Result ZoneSettingPolishGetResponse `json:"result"` - JSON zoneSettingPolishGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingPolishGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingPolishGetResponseEnvelope] -type zoneSettingPolishGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPolishGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPolishGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingPolishGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingPolishGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingPolishGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSettingPolishGetResponseEnvelopeErrors] -type zoneSettingPolishGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPolishGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPolishGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingPolishGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingPolishGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingPolishGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingPolishGetResponseEnvelopeMessages] -type zoneSettingPolishGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPolishGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPolishGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingpolish_test.go b/zonesettingpolish_test.go deleted file mode 100644 index 0f2c2e995c2..00000000000 --- a/zonesettingpolish_test.go +++ /dev/null @@ -1,70 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingPolishEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Zones.Settings.Polish.Edit(context.TODO(), cloudflare.ZoneSettingPolishEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingPolishEditParamsValue{ - ID: cloudflare.F(cloudflare.ZoneSettingPolishEditParamsValueIDPolish), - Value: cloudflare.F(cloudflare.ZoneSettingPolishEditParamsValueValueOff), - }), - }) - 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 TestZoneSettingPolishGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.Polish.Get(context.TODO(), cloudflare.ZoneSettingPolishGetParams{ - ZoneID: cloudflare.F("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/zonesettingprefetchpreload.go b/zonesettingprefetchpreload.go deleted file mode 100644 index 1a1a869c33b..00000000000 --- a/zonesettingprefetchpreload.go +++ /dev/null @@ -1,353 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingPrefetchPreloadService 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 -// [NewZoneSettingPrefetchPreloadService] method instead. -type ZoneSettingPrefetchPreloadService struct { - Options []option.RequestOption -} - -// NewZoneSettingPrefetchPreloadService 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 NewZoneSettingPrefetchPreloadService(opts ...option.RequestOption) (r *ZoneSettingPrefetchPreloadService) { - r = &ZoneSettingPrefetchPreloadService{} - r.Options = opts - return -} - -// Cloudflare will prefetch any URLs that are included in the response headers. -// This is limited to Enterprise Zones. -func (r *ZoneSettingPrefetchPreloadService) Edit(ctx context.Context, params ZoneSettingPrefetchPreloadEditParams, opts ...option.RequestOption) (res *ZoneSettingPrefetchPreloadEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingPrefetchPreloadEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/prefetch_preload", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Cloudflare will prefetch any URLs that are included in the response headers. -// This is limited to Enterprise Zones. -func (r *ZoneSettingPrefetchPreloadService) Get(ctx context.Context, query ZoneSettingPrefetchPreloadGetParams, opts ...option.RequestOption) (res *ZoneSettingPrefetchPreloadGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingPrefetchPreloadGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/prefetch_preload", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Cloudflare will prefetch any URLs that are included in the response headers. -// This is limited to Enterprise Zones. -type ZoneSettingPrefetchPreloadEditResponse struct { - // ID of the zone setting. - ID ZoneSettingPrefetchPreloadEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingPrefetchPreloadEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingPrefetchPreloadEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingPrefetchPreloadEditResponseJSON `json:"-"` -} - -// zoneSettingPrefetchPreloadEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingPrefetchPreloadEditResponse] -type zoneSettingPrefetchPreloadEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPrefetchPreloadEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPrefetchPreloadEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingPrefetchPreloadEditResponseID string - -const ( - ZoneSettingPrefetchPreloadEditResponseIDPrefetchPreload ZoneSettingPrefetchPreloadEditResponseID = "prefetch_preload" -) - -// Current value of the zone setting. -type ZoneSettingPrefetchPreloadEditResponseValue string - -const ( - ZoneSettingPrefetchPreloadEditResponseValueOn ZoneSettingPrefetchPreloadEditResponseValue = "on" - ZoneSettingPrefetchPreloadEditResponseValueOff ZoneSettingPrefetchPreloadEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingPrefetchPreloadEditResponseEditable bool - -const ( - ZoneSettingPrefetchPreloadEditResponseEditableTrue ZoneSettingPrefetchPreloadEditResponseEditable = true - ZoneSettingPrefetchPreloadEditResponseEditableFalse ZoneSettingPrefetchPreloadEditResponseEditable = false -) - -// Cloudflare will prefetch any URLs that are included in the response headers. -// This is limited to Enterprise Zones. -type ZoneSettingPrefetchPreloadGetResponse struct { - // ID of the zone setting. - ID ZoneSettingPrefetchPreloadGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingPrefetchPreloadGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingPrefetchPreloadGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingPrefetchPreloadGetResponseJSON `json:"-"` -} - -// zoneSettingPrefetchPreloadGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingPrefetchPreloadGetResponse] -type zoneSettingPrefetchPreloadGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPrefetchPreloadGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPrefetchPreloadGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingPrefetchPreloadGetResponseID string - -const ( - ZoneSettingPrefetchPreloadGetResponseIDPrefetchPreload ZoneSettingPrefetchPreloadGetResponseID = "prefetch_preload" -) - -// Current value of the zone setting. -type ZoneSettingPrefetchPreloadGetResponseValue string - -const ( - ZoneSettingPrefetchPreloadGetResponseValueOn ZoneSettingPrefetchPreloadGetResponseValue = "on" - ZoneSettingPrefetchPreloadGetResponseValueOff ZoneSettingPrefetchPreloadGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingPrefetchPreloadGetResponseEditable bool - -const ( - ZoneSettingPrefetchPreloadGetResponseEditableTrue ZoneSettingPrefetchPreloadGetResponseEditable = true - ZoneSettingPrefetchPreloadGetResponseEditableFalse ZoneSettingPrefetchPreloadGetResponseEditable = false -) - -type ZoneSettingPrefetchPreloadEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingPrefetchPreloadEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingPrefetchPreloadEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingPrefetchPreloadEditParamsValue string - -const ( - ZoneSettingPrefetchPreloadEditParamsValueOn ZoneSettingPrefetchPreloadEditParamsValue = "on" - ZoneSettingPrefetchPreloadEditParamsValueOff ZoneSettingPrefetchPreloadEditParamsValue = "off" -) - -type ZoneSettingPrefetchPreloadEditResponseEnvelope struct { - Errors []ZoneSettingPrefetchPreloadEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingPrefetchPreloadEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Cloudflare will prefetch any URLs that are included in the response headers. - // This is limited to Enterprise Zones. - Result ZoneSettingPrefetchPreloadEditResponse `json:"result"` - JSON zoneSettingPrefetchPreloadEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingPrefetchPreloadEditResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingPrefetchPreloadEditResponseEnvelope] -type zoneSettingPrefetchPreloadEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPrefetchPreloadEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPrefetchPreloadEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingPrefetchPreloadEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingPrefetchPreloadEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingPrefetchPreloadEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingPrefetchPreloadEditResponseEnvelopeErrors] -type zoneSettingPrefetchPreloadEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPrefetchPreloadEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPrefetchPreloadEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingPrefetchPreloadEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingPrefetchPreloadEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingPrefetchPreloadEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingPrefetchPreloadEditResponseEnvelopeMessages] -type zoneSettingPrefetchPreloadEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPrefetchPreloadEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPrefetchPreloadEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingPrefetchPreloadGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingPrefetchPreloadGetResponseEnvelope struct { - Errors []ZoneSettingPrefetchPreloadGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingPrefetchPreloadGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Cloudflare will prefetch any URLs that are included in the response headers. - // This is limited to Enterprise Zones. - Result ZoneSettingPrefetchPreloadGetResponse `json:"result"` - JSON zoneSettingPrefetchPreloadGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingPrefetchPreloadGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingPrefetchPreloadGetResponseEnvelope] -type zoneSettingPrefetchPreloadGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPrefetchPreloadGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPrefetchPreloadGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingPrefetchPreloadGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingPrefetchPreloadGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingPrefetchPreloadGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingPrefetchPreloadGetResponseEnvelopeErrors] -type zoneSettingPrefetchPreloadGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPrefetchPreloadGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPrefetchPreloadGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingPrefetchPreloadGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingPrefetchPreloadGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingPrefetchPreloadGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingPrefetchPreloadGetResponseEnvelopeMessages] -type zoneSettingPrefetchPreloadGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPrefetchPreloadGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPrefetchPreloadGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingprefetchpreload_test.go b/zonesettingprefetchpreload_test.go deleted file mode 100644 index f9c54e97449..00000000000 --- a/zonesettingprefetchpreload_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingPrefetchPreloadEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.PrefetchPreload.Edit(context.TODO(), cloudflare.ZoneSettingPrefetchPreloadEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingPrefetchPreloadEditParamsValueOn), - }) - 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 TestZoneSettingPrefetchPreloadGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.PrefetchPreload.Get(context.TODO(), cloudflare.ZoneSettingPrefetchPreloadGetParams{ - ZoneID: cloudflare.F("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/zonesettingproxyreadtimeout.go b/zonesettingproxyreadtimeout.go deleted file mode 100644 index 638c72e13ee..00000000000 --- a/zonesettingproxyreadtimeout.go +++ /dev/null @@ -1,352 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingProxyReadTimeoutService 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 -// [NewZoneSettingProxyReadTimeoutService] method instead. -type ZoneSettingProxyReadTimeoutService struct { - Options []option.RequestOption -} - -// NewZoneSettingProxyReadTimeoutService 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 NewZoneSettingProxyReadTimeoutService(opts ...option.RequestOption) (r *ZoneSettingProxyReadTimeoutService) { - r = &ZoneSettingProxyReadTimeoutService{} - r.Options = opts - return -} - -// Maximum time between two read operations from origin. -func (r *ZoneSettingProxyReadTimeoutService) Edit(ctx context.Context, params ZoneSettingProxyReadTimeoutEditParams, opts ...option.RequestOption) (res *ZoneSettingProxyReadTimeoutEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingProxyReadTimeoutEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/proxy_read_timeout", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Maximum time between two read operations from origin. -func (r *ZoneSettingProxyReadTimeoutService) Get(ctx context.Context, query ZoneSettingProxyReadTimeoutGetParams, opts ...option.RequestOption) (res *ZoneSettingProxyReadTimeoutGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingProxyReadTimeoutGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/proxy_read_timeout", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Maximum time between two read operations from origin. -type ZoneSettingProxyReadTimeoutEditResponse struct { - // ID of the zone setting. - ID ZoneSettingProxyReadTimeoutEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value float64 `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingProxyReadTimeoutEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingProxyReadTimeoutEditResponseJSON `json:"-"` -} - -// zoneSettingProxyReadTimeoutEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingProxyReadTimeoutEditResponse] -type zoneSettingProxyReadTimeoutEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingProxyReadTimeoutEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingProxyReadTimeoutEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingProxyReadTimeoutEditResponseID string - -const ( - ZoneSettingProxyReadTimeoutEditResponseIDProxyReadTimeout ZoneSettingProxyReadTimeoutEditResponseID = "proxy_read_timeout" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingProxyReadTimeoutEditResponseEditable bool - -const ( - ZoneSettingProxyReadTimeoutEditResponseEditableTrue ZoneSettingProxyReadTimeoutEditResponseEditable = true - ZoneSettingProxyReadTimeoutEditResponseEditableFalse ZoneSettingProxyReadTimeoutEditResponseEditable = false -) - -// Maximum time between two read operations from origin. -type ZoneSettingProxyReadTimeoutGetResponse struct { - // ID of the zone setting. - ID ZoneSettingProxyReadTimeoutGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value float64 `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingProxyReadTimeoutGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingProxyReadTimeoutGetResponseJSON `json:"-"` -} - -// zoneSettingProxyReadTimeoutGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingProxyReadTimeoutGetResponse] -type zoneSettingProxyReadTimeoutGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingProxyReadTimeoutGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingProxyReadTimeoutGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingProxyReadTimeoutGetResponseID string - -const ( - ZoneSettingProxyReadTimeoutGetResponseIDProxyReadTimeout ZoneSettingProxyReadTimeoutGetResponseID = "proxy_read_timeout" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingProxyReadTimeoutGetResponseEditable bool - -const ( - ZoneSettingProxyReadTimeoutGetResponseEditableTrue ZoneSettingProxyReadTimeoutGetResponseEditable = true - ZoneSettingProxyReadTimeoutGetResponseEditableFalse ZoneSettingProxyReadTimeoutGetResponseEditable = false -) - -type ZoneSettingProxyReadTimeoutEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Maximum time between two read operations from origin. - Value param.Field[ZoneSettingProxyReadTimeoutEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingProxyReadTimeoutEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Maximum time between two read operations from origin. -type ZoneSettingProxyReadTimeoutEditParamsValue struct { - // ID of the zone setting. - ID param.Field[ZoneSettingProxyReadTimeoutEditParamsValueID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[float64] `json:"value,required"` -} - -func (r ZoneSettingProxyReadTimeoutEditParamsValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// ID of the zone setting. -type ZoneSettingProxyReadTimeoutEditParamsValueID string - -const ( - ZoneSettingProxyReadTimeoutEditParamsValueIDProxyReadTimeout ZoneSettingProxyReadTimeoutEditParamsValueID = "proxy_read_timeout" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingProxyReadTimeoutEditParamsValueEditable bool - -const ( - ZoneSettingProxyReadTimeoutEditParamsValueEditableTrue ZoneSettingProxyReadTimeoutEditParamsValueEditable = true - ZoneSettingProxyReadTimeoutEditParamsValueEditableFalse ZoneSettingProxyReadTimeoutEditParamsValueEditable = false -) - -type ZoneSettingProxyReadTimeoutEditResponseEnvelope struct { - Errors []ZoneSettingProxyReadTimeoutEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingProxyReadTimeoutEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Maximum time between two read operations from origin. - Result ZoneSettingProxyReadTimeoutEditResponse `json:"result"` - JSON zoneSettingProxyReadTimeoutEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingProxyReadTimeoutEditResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingProxyReadTimeoutEditResponseEnvelope] -type zoneSettingProxyReadTimeoutEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingProxyReadTimeoutEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingProxyReadTimeoutEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingProxyReadTimeoutEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingProxyReadTimeoutEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingProxyReadTimeoutEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingProxyReadTimeoutEditResponseEnvelopeErrors] -type zoneSettingProxyReadTimeoutEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingProxyReadTimeoutEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingProxyReadTimeoutEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingProxyReadTimeoutEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingProxyReadTimeoutEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingProxyReadTimeoutEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZoneSettingProxyReadTimeoutEditResponseEnvelopeMessages] -type zoneSettingProxyReadTimeoutEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingProxyReadTimeoutEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingProxyReadTimeoutEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingProxyReadTimeoutGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingProxyReadTimeoutGetResponseEnvelope struct { - Errors []ZoneSettingProxyReadTimeoutGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingProxyReadTimeoutGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Maximum time between two read operations from origin. - Result ZoneSettingProxyReadTimeoutGetResponse `json:"result"` - JSON zoneSettingProxyReadTimeoutGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingProxyReadTimeoutGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingProxyReadTimeoutGetResponseEnvelope] -type zoneSettingProxyReadTimeoutGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingProxyReadTimeoutGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingProxyReadTimeoutGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingProxyReadTimeoutGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingProxyReadTimeoutGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingProxyReadTimeoutGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingProxyReadTimeoutGetResponseEnvelopeErrors] -type zoneSettingProxyReadTimeoutGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingProxyReadTimeoutGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingProxyReadTimeoutGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingProxyReadTimeoutGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingProxyReadTimeoutGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingProxyReadTimeoutGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingProxyReadTimeoutGetResponseEnvelopeMessages] -type zoneSettingProxyReadTimeoutGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingProxyReadTimeoutGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingProxyReadTimeoutGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingproxyreadtimeout_test.go b/zonesettingproxyreadtimeout_test.go deleted file mode 100644 index 7493aeffdb7..00000000000 --- a/zonesettingproxyreadtimeout_test.go +++ /dev/null @@ -1,70 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingProxyReadTimeoutEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Zones.Settings.ProxyReadTimeout.Edit(context.TODO(), cloudflare.ZoneSettingProxyReadTimeoutEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingProxyReadTimeoutEditParamsValue{ - ID: cloudflare.F(cloudflare.ZoneSettingProxyReadTimeoutEditParamsValueIDProxyReadTimeout), - Value: cloudflare.F(0.000000), - }), - }) - 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 TestZoneSettingProxyReadTimeoutGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.ProxyReadTimeout.Get(context.TODO(), cloudflare.ZoneSettingProxyReadTimeoutGetParams{ - ZoneID: cloudflare.F("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/zonesettingpseudoipv4.go b/zonesettingpseudoipv4.go deleted file mode 100644 index b06b68d9ddc..00000000000 --- a/zonesettingpseudoipv4.go +++ /dev/null @@ -1,350 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingPseudoIPV4Service 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 [NewZoneSettingPseudoIPV4Service] -// method instead. -type ZoneSettingPseudoIPV4Service struct { - Options []option.RequestOption -} - -// NewZoneSettingPseudoIPV4Service 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 NewZoneSettingPseudoIPV4Service(opts ...option.RequestOption) (r *ZoneSettingPseudoIPV4Service) { - r = &ZoneSettingPseudoIPV4Service{} - r.Options = opts - return -} - -// Value of the Pseudo IPv4 setting. -func (r *ZoneSettingPseudoIPV4Service) Edit(ctx context.Context, params ZoneSettingPseudoIPV4EditParams, opts ...option.RequestOption) (res *ZoneSettingPseudoIPV4EditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingPseudoIPV4EditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/pseudo_ipv4", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Value of the Pseudo IPv4 setting. -func (r *ZoneSettingPseudoIPV4Service) Get(ctx context.Context, query ZoneSettingPseudoIPV4GetParams, opts ...option.RequestOption) (res *ZoneSettingPseudoIPV4GetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingPseudoIPV4GetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/pseudo_ipv4", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// The value set for the Pseudo IPv4 setting. -type ZoneSettingPseudoIPV4EditResponse struct { - // Value of the Pseudo IPv4 setting. - ID ZoneSettingPseudoIPV4EditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingPseudoIPV4EditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingPseudoIPV4EditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingPseudoIPV4EditResponseJSON `json:"-"` -} - -// zoneSettingPseudoIPV4EditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingPseudoIPV4EditResponse] -type zoneSettingPseudoIPV4EditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPseudoIPV4EditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPseudoIPV4EditResponseJSON) RawJSON() string { - return r.raw -} - -// Value of the Pseudo IPv4 setting. -type ZoneSettingPseudoIPV4EditResponseID string - -const ( - ZoneSettingPseudoIPV4EditResponseIDPseudoIPV4 ZoneSettingPseudoIPV4EditResponseID = "pseudo_ipv4" -) - -// Current value of the zone setting. -type ZoneSettingPseudoIPV4EditResponseValue string - -const ( - ZoneSettingPseudoIPV4EditResponseValueOff ZoneSettingPseudoIPV4EditResponseValue = "off" - ZoneSettingPseudoIPV4EditResponseValueAddHeader ZoneSettingPseudoIPV4EditResponseValue = "add_header" - ZoneSettingPseudoIPV4EditResponseValueOverwriteHeader ZoneSettingPseudoIPV4EditResponseValue = "overwrite_header" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingPseudoIPV4EditResponseEditable bool - -const ( - ZoneSettingPseudoIPV4EditResponseEditableTrue ZoneSettingPseudoIPV4EditResponseEditable = true - ZoneSettingPseudoIPV4EditResponseEditableFalse ZoneSettingPseudoIPV4EditResponseEditable = false -) - -// The value set for the Pseudo IPv4 setting. -type ZoneSettingPseudoIPV4GetResponse struct { - // Value of the Pseudo IPv4 setting. - ID ZoneSettingPseudoIPV4GetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingPseudoIPV4GetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingPseudoIPV4GetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingPseudoIPV4GetResponseJSON `json:"-"` -} - -// zoneSettingPseudoIPV4GetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingPseudoIPV4GetResponse] -type zoneSettingPseudoIPV4GetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPseudoIPV4GetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPseudoIPV4GetResponseJSON) RawJSON() string { - return r.raw -} - -// Value of the Pseudo IPv4 setting. -type ZoneSettingPseudoIPV4GetResponseID string - -const ( - ZoneSettingPseudoIPV4GetResponseIDPseudoIPV4 ZoneSettingPseudoIPV4GetResponseID = "pseudo_ipv4" -) - -// Current value of the zone setting. -type ZoneSettingPseudoIPV4GetResponseValue string - -const ( - ZoneSettingPseudoIPV4GetResponseValueOff ZoneSettingPseudoIPV4GetResponseValue = "off" - ZoneSettingPseudoIPV4GetResponseValueAddHeader ZoneSettingPseudoIPV4GetResponseValue = "add_header" - ZoneSettingPseudoIPV4GetResponseValueOverwriteHeader ZoneSettingPseudoIPV4GetResponseValue = "overwrite_header" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingPseudoIPV4GetResponseEditable bool - -const ( - ZoneSettingPseudoIPV4GetResponseEditableTrue ZoneSettingPseudoIPV4GetResponseEditable = true - ZoneSettingPseudoIPV4GetResponseEditableFalse ZoneSettingPseudoIPV4GetResponseEditable = false -) - -type ZoneSettingPseudoIPV4EditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the Pseudo IPv4 setting. - Value param.Field[ZoneSettingPseudoIPV4EditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingPseudoIPV4EditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the Pseudo IPv4 setting. -type ZoneSettingPseudoIPV4EditParamsValue string - -const ( - ZoneSettingPseudoIPV4EditParamsValueOff ZoneSettingPseudoIPV4EditParamsValue = "off" - ZoneSettingPseudoIPV4EditParamsValueAddHeader ZoneSettingPseudoIPV4EditParamsValue = "add_header" - ZoneSettingPseudoIPV4EditParamsValueOverwriteHeader ZoneSettingPseudoIPV4EditParamsValue = "overwrite_header" -) - -type ZoneSettingPseudoIPV4EditResponseEnvelope struct { - Errors []ZoneSettingPseudoIPV4EditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingPseudoIPV4EditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // The value set for the Pseudo IPv4 setting. - Result ZoneSettingPseudoIPV4EditResponse `json:"result"` - JSON zoneSettingPseudoIPV4EditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingPseudoIPV4EditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingPseudoIPV4EditResponseEnvelope] -type zoneSettingPseudoIPV4EditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPseudoIPV4EditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPseudoIPV4EditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingPseudoIPV4EditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingPseudoIPV4EditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingPseudoIPV4EditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingPseudoIPV4EditResponseEnvelopeErrors] -type zoneSettingPseudoIPV4EditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPseudoIPV4EditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPseudoIPV4EditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingPseudoIPV4EditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingPseudoIPV4EditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingPseudoIPV4EditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZoneSettingPseudoIPV4EditResponseEnvelopeMessages] -type zoneSettingPseudoIPV4EditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPseudoIPV4EditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPseudoIPV4EditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingPseudoIPV4GetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingPseudoIPV4GetResponseEnvelope struct { - Errors []ZoneSettingPseudoIPV4GetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingPseudoIPV4GetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // The value set for the Pseudo IPv4 setting. - Result ZoneSettingPseudoIPV4GetResponse `json:"result"` - JSON zoneSettingPseudoIPV4GetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingPseudoIPV4GetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingPseudoIPV4GetResponseEnvelope] -type zoneSettingPseudoIPV4GetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPseudoIPV4GetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPseudoIPV4GetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingPseudoIPV4GetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingPseudoIPV4GetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingPseudoIPV4GetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingPseudoIPV4GetResponseEnvelopeErrors] -type zoneSettingPseudoIPV4GetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPseudoIPV4GetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPseudoIPV4GetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingPseudoIPV4GetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingPseudoIPV4GetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingPseudoIPV4GetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZoneSettingPseudoIPV4GetResponseEnvelopeMessages] -type zoneSettingPseudoIPV4GetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingPseudoIPV4GetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingPseudoIPV4GetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingpseudoipv4_test.go b/zonesettingpseudoipv4_test.go deleted file mode 100644 index d084244bead..00000000000 --- a/zonesettingpseudoipv4_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingPseudoIPV4Edit(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("user@example.com"), - ) - _, err := client.Zones.Settings.PseudoIPV4.Edit(context.TODO(), cloudflare.ZoneSettingPseudoIPV4EditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingPseudoIPV4EditParamsValueOff), - }) - 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 TestZoneSettingPseudoIPV4Get(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("user@example.com"), - ) - _, err := client.Zones.Settings.PseudoIPV4.Get(context.TODO(), cloudflare.ZoneSettingPseudoIPV4GetParams{ - ZoneID: cloudflare.F("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/zonesettingresponsebuffering.go b/zonesettingresponsebuffering.go deleted file mode 100644 index d142ca94086..00000000000 --- a/zonesettingresponsebuffering.go +++ /dev/null @@ -1,367 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingResponseBufferingService 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 -// [NewZoneSettingResponseBufferingService] method instead. -type ZoneSettingResponseBufferingService struct { - Options []option.RequestOption -} - -// NewZoneSettingResponseBufferingService 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 NewZoneSettingResponseBufferingService(opts ...option.RequestOption) (r *ZoneSettingResponseBufferingService) { - r = &ZoneSettingResponseBufferingService{} - r.Options = opts - return -} - -// Enables or disables buffering of responses from the proxied server. Cloudflare -// may buffer the whole payload to deliver it at once to the client versus allowing -// it to be delivered in chunks. By default, the proxied server streams directly -// and is not buffered by Cloudflare. This is limited to Enterprise Zones. -func (r *ZoneSettingResponseBufferingService) Edit(ctx context.Context, params ZoneSettingResponseBufferingEditParams, opts ...option.RequestOption) (res *ZoneSettingResponseBufferingEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingResponseBufferingEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/response_buffering", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Enables or disables buffering of responses from the proxied server. Cloudflare -// may buffer the whole payload to deliver it at once to the client versus allowing -// it to be delivered in chunks. By default, the proxied server streams directly -// and is not buffered by Cloudflare. This is limited to Enterprise Zones. -func (r *ZoneSettingResponseBufferingService) Get(ctx context.Context, query ZoneSettingResponseBufferingGetParams, opts ...option.RequestOption) (res *ZoneSettingResponseBufferingGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingResponseBufferingGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/response_buffering", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Enables or disables buffering of responses from the proxied server. Cloudflare -// may buffer the whole payload to deliver it at once to the client versus allowing -// it to be delivered in chunks. By default, the proxied server streams directly -// and is not buffered by Cloudflare. This is limited to Enterprise Zones. -type ZoneSettingResponseBufferingEditResponse struct { - // ID of the zone setting. - ID ZoneSettingResponseBufferingEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingResponseBufferingEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingResponseBufferingEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingResponseBufferingEditResponseJSON `json:"-"` -} - -// zoneSettingResponseBufferingEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingResponseBufferingEditResponse] -type zoneSettingResponseBufferingEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingResponseBufferingEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingResponseBufferingEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingResponseBufferingEditResponseID string - -const ( - ZoneSettingResponseBufferingEditResponseIDResponseBuffering ZoneSettingResponseBufferingEditResponseID = "response_buffering" -) - -// Current value of the zone setting. -type ZoneSettingResponseBufferingEditResponseValue string - -const ( - ZoneSettingResponseBufferingEditResponseValueOn ZoneSettingResponseBufferingEditResponseValue = "on" - ZoneSettingResponseBufferingEditResponseValueOff ZoneSettingResponseBufferingEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingResponseBufferingEditResponseEditable bool - -const ( - ZoneSettingResponseBufferingEditResponseEditableTrue ZoneSettingResponseBufferingEditResponseEditable = true - ZoneSettingResponseBufferingEditResponseEditableFalse ZoneSettingResponseBufferingEditResponseEditable = false -) - -// Enables or disables buffering of responses from the proxied server. Cloudflare -// may buffer the whole payload to deliver it at once to the client versus allowing -// it to be delivered in chunks. By default, the proxied server streams directly -// and is not buffered by Cloudflare. This is limited to Enterprise Zones. -type ZoneSettingResponseBufferingGetResponse struct { - // ID of the zone setting. - ID ZoneSettingResponseBufferingGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingResponseBufferingGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingResponseBufferingGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingResponseBufferingGetResponseJSON `json:"-"` -} - -// zoneSettingResponseBufferingGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingResponseBufferingGetResponse] -type zoneSettingResponseBufferingGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingResponseBufferingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingResponseBufferingGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingResponseBufferingGetResponseID string - -const ( - ZoneSettingResponseBufferingGetResponseIDResponseBuffering ZoneSettingResponseBufferingGetResponseID = "response_buffering" -) - -// Current value of the zone setting. -type ZoneSettingResponseBufferingGetResponseValue string - -const ( - ZoneSettingResponseBufferingGetResponseValueOn ZoneSettingResponseBufferingGetResponseValue = "on" - ZoneSettingResponseBufferingGetResponseValueOff ZoneSettingResponseBufferingGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingResponseBufferingGetResponseEditable bool - -const ( - ZoneSettingResponseBufferingGetResponseEditableTrue ZoneSettingResponseBufferingGetResponseEditable = true - ZoneSettingResponseBufferingGetResponseEditableFalse ZoneSettingResponseBufferingGetResponseEditable = false -) - -type ZoneSettingResponseBufferingEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingResponseBufferingEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingResponseBufferingEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingResponseBufferingEditParamsValue string - -const ( - ZoneSettingResponseBufferingEditParamsValueOn ZoneSettingResponseBufferingEditParamsValue = "on" - ZoneSettingResponseBufferingEditParamsValueOff ZoneSettingResponseBufferingEditParamsValue = "off" -) - -type ZoneSettingResponseBufferingEditResponseEnvelope struct { - Errors []ZoneSettingResponseBufferingEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingResponseBufferingEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Enables or disables buffering of responses from the proxied server. Cloudflare - // may buffer the whole payload to deliver it at once to the client versus allowing - // it to be delivered in chunks. By default, the proxied server streams directly - // and is not buffered by Cloudflare. This is limited to Enterprise Zones. - Result ZoneSettingResponseBufferingEditResponse `json:"result"` - JSON zoneSettingResponseBufferingEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingResponseBufferingEditResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingResponseBufferingEditResponseEnvelope] -type zoneSettingResponseBufferingEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingResponseBufferingEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingResponseBufferingEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingResponseBufferingEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingResponseBufferingEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingResponseBufferingEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingResponseBufferingEditResponseEnvelopeErrors] -type zoneSettingResponseBufferingEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingResponseBufferingEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingResponseBufferingEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingResponseBufferingEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingResponseBufferingEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingResponseBufferingEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZoneSettingResponseBufferingEditResponseEnvelopeMessages] -type zoneSettingResponseBufferingEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingResponseBufferingEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingResponseBufferingEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingResponseBufferingGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingResponseBufferingGetResponseEnvelope struct { - Errors []ZoneSettingResponseBufferingGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingResponseBufferingGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Enables or disables buffering of responses from the proxied server. Cloudflare - // may buffer the whole payload to deliver it at once to the client versus allowing - // it to be delivered in chunks. By default, the proxied server streams directly - // and is not buffered by Cloudflare. This is limited to Enterprise Zones. - Result ZoneSettingResponseBufferingGetResponse `json:"result"` - JSON zoneSettingResponseBufferingGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingResponseBufferingGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingResponseBufferingGetResponseEnvelope] -type zoneSettingResponseBufferingGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingResponseBufferingGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingResponseBufferingGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingResponseBufferingGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingResponseBufferingGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingResponseBufferingGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingResponseBufferingGetResponseEnvelopeErrors] -type zoneSettingResponseBufferingGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingResponseBufferingGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingResponseBufferingGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingResponseBufferingGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingResponseBufferingGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingResponseBufferingGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZoneSettingResponseBufferingGetResponseEnvelopeMessages] -type zoneSettingResponseBufferingGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingResponseBufferingGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingResponseBufferingGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingresponsebuffering_test.go b/zonesettingresponsebuffering_test.go deleted file mode 100644 index b03557237a1..00000000000 --- a/zonesettingresponsebuffering_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingResponseBufferingEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.ResponseBuffering.Edit(context.TODO(), cloudflare.ZoneSettingResponseBufferingEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingResponseBufferingEditParamsValueOn), - }) - 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 TestZoneSettingResponseBufferingGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.ResponseBuffering.Get(context.TODO(), cloudflare.ZoneSettingResponseBufferingGetParams{ - ZoneID: cloudflare.F("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/zonesettingrocketloader.go b/zonesettingrocketloader.go deleted file mode 100644 index 4ef551d54a8..00000000000 --- a/zonesettingrocketloader.go +++ /dev/null @@ -1,447 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingRocketLoaderService 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 -// [NewZoneSettingRocketLoaderService] method instead. -type ZoneSettingRocketLoaderService struct { - Options []option.RequestOption -} - -// NewZoneSettingRocketLoaderService 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 NewZoneSettingRocketLoaderService(opts ...option.RequestOption) (r *ZoneSettingRocketLoaderService) { - r = &ZoneSettingRocketLoaderService{} - r.Options = opts - return -} - -// Rocket Loader is a general-purpose asynchronous JavaScript optimisation that -// prioritises rendering your content while loading your site's Javascript -// asynchronously. Turning on Rocket Loader will immediately improve a web page's -// rendering time sometimes measured as Time to First Paint (TTFP), and also the -// `window.onload` time (assuming there is JavaScript on the page). This can have a -// positive impact on your Google search ranking. When turned on, Rocket Loader -// will automatically defer the loading of all Javascript referenced in your HTML, -// with no configuration required. Refer to -// [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) -// for more information. -func (r *ZoneSettingRocketLoaderService) Edit(ctx context.Context, params ZoneSettingRocketLoaderEditParams, opts ...option.RequestOption) (res *ZoneSettingRocketLoaderEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingRocketLoaderEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/rocket_loader", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Rocket Loader is a general-purpose asynchronous JavaScript optimisation that -// prioritises rendering your content while loading your site's Javascript -// asynchronously. Turning on Rocket Loader will immediately improve a web page's -// rendering time sometimes measured as Time to First Paint (TTFP), and also the -// `window.onload` time (assuming there is JavaScript on the page). This can have a -// positive impact on your Google search ranking. When turned on, Rocket Loader -// will automatically defer the loading of all Javascript referenced in your HTML, -// with no configuration required. Refer to -// [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) -// for more information. -func (r *ZoneSettingRocketLoaderService) Get(ctx context.Context, query ZoneSettingRocketLoaderGetParams, opts ...option.RequestOption) (res *ZoneSettingRocketLoaderGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingRocketLoaderGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/rocket_loader", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Rocket Loader is a general-purpose asynchronous JavaScript optimisation that -// prioritises rendering your content while loading your site's Javascript -// asynchronously. Turning on Rocket Loader will immediately improve a web page's -// rendering time sometimes measured as Time to First Paint (TTFP), and also the -// `window.onload` time (assuming there is JavaScript on the page). This can have a -// positive impact on your Google search ranking. When turned on, Rocket Loader -// will automatically defer the loading of all Javascript referenced in your HTML, -// with no configuration required. Refer to -// [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) -// for more information. -type ZoneSettingRocketLoaderEditResponse struct { - // ID of the zone setting. - ID ZoneSettingRocketLoaderEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingRocketLoaderEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingRocketLoaderEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingRocketLoaderEditResponseJSON `json:"-"` -} - -// zoneSettingRocketLoaderEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingRocketLoaderEditResponse] -type zoneSettingRocketLoaderEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingRocketLoaderEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingRocketLoaderEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingRocketLoaderEditResponseID string - -const ( - ZoneSettingRocketLoaderEditResponseIDRocketLoader ZoneSettingRocketLoaderEditResponseID = "rocket_loader" -) - -// Current value of the zone setting. -type ZoneSettingRocketLoaderEditResponseValue string - -const ( - ZoneSettingRocketLoaderEditResponseValueOn ZoneSettingRocketLoaderEditResponseValue = "on" - ZoneSettingRocketLoaderEditResponseValueOff ZoneSettingRocketLoaderEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingRocketLoaderEditResponseEditable bool - -const ( - ZoneSettingRocketLoaderEditResponseEditableTrue ZoneSettingRocketLoaderEditResponseEditable = true - ZoneSettingRocketLoaderEditResponseEditableFalse ZoneSettingRocketLoaderEditResponseEditable = false -) - -// Rocket Loader is a general-purpose asynchronous JavaScript optimisation that -// prioritises rendering your content while loading your site's Javascript -// asynchronously. Turning on Rocket Loader will immediately improve a web page's -// rendering time sometimes measured as Time to First Paint (TTFP), and also the -// `window.onload` time (assuming there is JavaScript on the page). This can have a -// positive impact on your Google search ranking. When turned on, Rocket Loader -// will automatically defer the loading of all Javascript referenced in your HTML, -// with no configuration required. Refer to -// [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) -// for more information. -type ZoneSettingRocketLoaderGetResponse struct { - // ID of the zone setting. - ID ZoneSettingRocketLoaderGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingRocketLoaderGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingRocketLoaderGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingRocketLoaderGetResponseJSON `json:"-"` -} - -// zoneSettingRocketLoaderGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingRocketLoaderGetResponse] -type zoneSettingRocketLoaderGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingRocketLoaderGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingRocketLoaderGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingRocketLoaderGetResponseID string - -const ( - ZoneSettingRocketLoaderGetResponseIDRocketLoader ZoneSettingRocketLoaderGetResponseID = "rocket_loader" -) - -// Current value of the zone setting. -type ZoneSettingRocketLoaderGetResponseValue string - -const ( - ZoneSettingRocketLoaderGetResponseValueOn ZoneSettingRocketLoaderGetResponseValue = "on" - ZoneSettingRocketLoaderGetResponseValueOff ZoneSettingRocketLoaderGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingRocketLoaderGetResponseEditable bool - -const ( - ZoneSettingRocketLoaderGetResponseEditableTrue ZoneSettingRocketLoaderGetResponseEditable = true - ZoneSettingRocketLoaderGetResponseEditableFalse ZoneSettingRocketLoaderGetResponseEditable = false -) - -type ZoneSettingRocketLoaderEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Rocket Loader is a general-purpose asynchronous JavaScript optimisation that - // prioritises rendering your content while loading your site's Javascript - // asynchronously. Turning on Rocket Loader will immediately improve a web page's - // rendering time sometimes measured as Time to First Paint (TTFP), and also the - // `window.onload` time (assuming there is JavaScript on the page). This can have a - // positive impact on your Google search ranking. When turned on, Rocket Loader - // will automatically defer the loading of all Javascript referenced in your HTML, - // with no configuration required. Refer to - // [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) - // for more information. - Value param.Field[ZoneSettingRocketLoaderEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingRocketLoaderEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Rocket Loader is a general-purpose asynchronous JavaScript optimisation that -// prioritises rendering your content while loading your site's Javascript -// asynchronously. Turning on Rocket Loader will immediately improve a web page's -// rendering time sometimes measured as Time to First Paint (TTFP), and also the -// `window.onload` time (assuming there is JavaScript on the page). This can have a -// positive impact on your Google search ranking. When turned on, Rocket Loader -// will automatically defer the loading of all Javascript referenced in your HTML, -// with no configuration required. Refer to -// [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) -// for more information. -type ZoneSettingRocketLoaderEditParamsValue struct { - // ID of the zone setting. - ID param.Field[ZoneSettingRocketLoaderEditParamsValueID] `json:"id,required"` - // Current value of the zone setting. - Value param.Field[ZoneSettingRocketLoaderEditParamsValueValue] `json:"value,required"` -} - -func (r ZoneSettingRocketLoaderEditParamsValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// ID of the zone setting. -type ZoneSettingRocketLoaderEditParamsValueID string - -const ( - ZoneSettingRocketLoaderEditParamsValueIDRocketLoader ZoneSettingRocketLoaderEditParamsValueID = "rocket_loader" -) - -// Current value of the zone setting. -type ZoneSettingRocketLoaderEditParamsValueValue string - -const ( - ZoneSettingRocketLoaderEditParamsValueValueOn ZoneSettingRocketLoaderEditParamsValueValue = "on" - ZoneSettingRocketLoaderEditParamsValueValueOff ZoneSettingRocketLoaderEditParamsValueValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingRocketLoaderEditParamsValueEditable bool - -const ( - ZoneSettingRocketLoaderEditParamsValueEditableTrue ZoneSettingRocketLoaderEditParamsValueEditable = true - ZoneSettingRocketLoaderEditParamsValueEditableFalse ZoneSettingRocketLoaderEditParamsValueEditable = false -) - -type ZoneSettingRocketLoaderEditResponseEnvelope struct { - Errors []ZoneSettingRocketLoaderEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingRocketLoaderEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Rocket Loader is a general-purpose asynchronous JavaScript optimisation that - // prioritises rendering your content while loading your site's Javascript - // asynchronously. Turning on Rocket Loader will immediately improve a web page's - // rendering time sometimes measured as Time to First Paint (TTFP), and also the - // `window.onload` time (assuming there is JavaScript on the page). This can have a - // positive impact on your Google search ranking. When turned on, Rocket Loader - // will automatically defer the loading of all Javascript referenced in your HTML, - // with no configuration required. Refer to - // [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) - // for more information. - Result ZoneSettingRocketLoaderEditResponse `json:"result"` - JSON zoneSettingRocketLoaderEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingRocketLoaderEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingRocketLoaderEditResponseEnvelope] -type zoneSettingRocketLoaderEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingRocketLoaderEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingRocketLoaderEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingRocketLoaderEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingRocketLoaderEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingRocketLoaderEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingRocketLoaderEditResponseEnvelopeErrors] -type zoneSettingRocketLoaderEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingRocketLoaderEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingRocketLoaderEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingRocketLoaderEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingRocketLoaderEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingRocketLoaderEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingRocketLoaderEditResponseEnvelopeMessages] -type zoneSettingRocketLoaderEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingRocketLoaderEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingRocketLoaderEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingRocketLoaderGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingRocketLoaderGetResponseEnvelope struct { - Errors []ZoneSettingRocketLoaderGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingRocketLoaderGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Rocket Loader is a general-purpose asynchronous JavaScript optimisation that - // prioritises rendering your content while loading your site's Javascript - // asynchronously. Turning on Rocket Loader will immediately improve a web page's - // rendering time sometimes measured as Time to First Paint (TTFP), and also the - // `window.onload` time (assuming there is JavaScript on the page). This can have a - // positive impact on your Google search ranking. When turned on, Rocket Loader - // will automatically defer the loading of all Javascript referenced in your HTML, - // with no configuration required. Refer to - // [Understanding Rocket Loader](https://support.cloudflare.com/hc/articles/200168056) - // for more information. - Result ZoneSettingRocketLoaderGetResponse `json:"result"` - JSON zoneSettingRocketLoaderGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingRocketLoaderGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingRocketLoaderGetResponseEnvelope] -type zoneSettingRocketLoaderGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingRocketLoaderGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingRocketLoaderGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingRocketLoaderGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingRocketLoaderGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingRocketLoaderGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingRocketLoaderGetResponseEnvelopeErrors] -type zoneSettingRocketLoaderGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingRocketLoaderGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingRocketLoaderGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingRocketLoaderGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingRocketLoaderGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingRocketLoaderGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingRocketLoaderGetResponseEnvelopeMessages] -type zoneSettingRocketLoaderGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingRocketLoaderGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingRocketLoaderGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingrocketloader_test.go b/zonesettingrocketloader_test.go deleted file mode 100644 index 801480d540b..00000000000 --- a/zonesettingrocketloader_test.go +++ /dev/null @@ -1,70 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingRocketLoaderEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Zones.Settings.RocketLoader.Edit(context.TODO(), cloudflare.ZoneSettingRocketLoaderEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingRocketLoaderEditParamsValue{ - ID: cloudflare.F(cloudflare.ZoneSettingRocketLoaderEditParamsValueIDRocketLoader), - Value: cloudflare.F(cloudflare.ZoneSettingRocketLoaderEditParamsValueValueOn), - }), - }) - 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 TestZoneSettingRocketLoaderGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.RocketLoader.Get(context.TODO(), cloudflare.ZoneSettingRocketLoaderGetParams{ - ZoneID: cloudflare.F("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/zonesettingsecurityheader.go b/zonesettingsecurityheader.go deleted file mode 100644 index 41b1b9567d0..00000000000 --- a/zonesettingsecurityheader.go +++ /dev/null @@ -1,459 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingSecurityHeaderService 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 -// [NewZoneSettingSecurityHeaderService] method instead. -type ZoneSettingSecurityHeaderService struct { - Options []option.RequestOption -} - -// NewZoneSettingSecurityHeaderService 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 NewZoneSettingSecurityHeaderService(opts ...option.RequestOption) (r *ZoneSettingSecurityHeaderService) { - r = &ZoneSettingSecurityHeaderService{} - r.Options = opts - return -} - -// Cloudflare security header for a zone. -func (r *ZoneSettingSecurityHeaderService) Edit(ctx context.Context, params ZoneSettingSecurityHeaderEditParams, opts ...option.RequestOption) (res *ZoneSettingSecurityHeaderEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingSecurityHeaderEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/security_header", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Cloudflare security header for a zone. -func (r *ZoneSettingSecurityHeaderService) Get(ctx context.Context, query ZoneSettingSecurityHeaderGetParams, opts ...option.RequestOption) (res *ZoneSettingSecurityHeaderGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingSecurityHeaderGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/security_header", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Cloudflare security header for a zone. -type ZoneSettingSecurityHeaderEditResponse struct { - // ID of the zone's security header. - ID ZoneSettingSecurityHeaderEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingSecurityHeaderEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingSecurityHeaderEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingSecurityHeaderEditResponseJSON `json:"-"` -} - -// zoneSettingSecurityHeaderEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingSecurityHeaderEditResponse] -type zoneSettingSecurityHeaderEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityHeaderEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityHeaderEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone's security header. -type ZoneSettingSecurityHeaderEditResponseID string - -const ( - ZoneSettingSecurityHeaderEditResponseIDSecurityHeader ZoneSettingSecurityHeaderEditResponseID = "security_header" -) - -// Current value of the zone setting. -type ZoneSettingSecurityHeaderEditResponseValue struct { - // Strict Transport Security. - StrictTransportSecurity ZoneSettingSecurityHeaderEditResponseValueStrictTransportSecurity `json:"strict_transport_security"` - JSON zoneSettingSecurityHeaderEditResponseValueJSON `json:"-"` -} - -// zoneSettingSecurityHeaderEditResponseValueJSON contains the JSON metadata for -// the struct [ZoneSettingSecurityHeaderEditResponseValue] -type zoneSettingSecurityHeaderEditResponseValueJSON struct { - StrictTransportSecurity apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityHeaderEditResponseValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityHeaderEditResponseValueJSON) RawJSON() string { - return r.raw -} - -// Strict Transport Security. -type ZoneSettingSecurityHeaderEditResponseValueStrictTransportSecurity struct { - // Whether or not strict transport security is enabled. - Enabled bool `json:"enabled"` - // Include all subdomains for strict transport security. - IncludeSubdomains bool `json:"include_subdomains"` - // Max age in seconds of the strict transport security. - MaxAge float64 `json:"max_age"` - // Whether or not to include 'X-Content-Type-Options: nosniff' header. - Nosniff bool `json:"nosniff"` - JSON zoneSettingSecurityHeaderEditResponseValueStrictTransportSecurityJSON `json:"-"` -} - -// zoneSettingSecurityHeaderEditResponseValueStrictTransportSecurityJSON contains -// the JSON metadata for the struct -// [ZoneSettingSecurityHeaderEditResponseValueStrictTransportSecurity] -type zoneSettingSecurityHeaderEditResponseValueStrictTransportSecurityJSON struct { - Enabled apijson.Field - IncludeSubdomains apijson.Field - MaxAge apijson.Field - Nosniff apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityHeaderEditResponseValueStrictTransportSecurity) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityHeaderEditResponseValueStrictTransportSecurityJSON) RawJSON() string { - return r.raw -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingSecurityHeaderEditResponseEditable bool - -const ( - ZoneSettingSecurityHeaderEditResponseEditableTrue ZoneSettingSecurityHeaderEditResponseEditable = true - ZoneSettingSecurityHeaderEditResponseEditableFalse ZoneSettingSecurityHeaderEditResponseEditable = false -) - -// Cloudflare security header for a zone. -type ZoneSettingSecurityHeaderGetResponse struct { - // ID of the zone's security header. - ID ZoneSettingSecurityHeaderGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingSecurityHeaderGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingSecurityHeaderGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingSecurityHeaderGetResponseJSON `json:"-"` -} - -// zoneSettingSecurityHeaderGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingSecurityHeaderGetResponse] -type zoneSettingSecurityHeaderGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityHeaderGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityHeaderGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone's security header. -type ZoneSettingSecurityHeaderGetResponseID string - -const ( - ZoneSettingSecurityHeaderGetResponseIDSecurityHeader ZoneSettingSecurityHeaderGetResponseID = "security_header" -) - -// Current value of the zone setting. -type ZoneSettingSecurityHeaderGetResponseValue struct { - // Strict Transport Security. - StrictTransportSecurity ZoneSettingSecurityHeaderGetResponseValueStrictTransportSecurity `json:"strict_transport_security"` - JSON zoneSettingSecurityHeaderGetResponseValueJSON `json:"-"` -} - -// zoneSettingSecurityHeaderGetResponseValueJSON contains the JSON metadata for the -// struct [ZoneSettingSecurityHeaderGetResponseValue] -type zoneSettingSecurityHeaderGetResponseValueJSON struct { - StrictTransportSecurity apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityHeaderGetResponseValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityHeaderGetResponseValueJSON) RawJSON() string { - return r.raw -} - -// Strict Transport Security. -type ZoneSettingSecurityHeaderGetResponseValueStrictTransportSecurity struct { - // Whether or not strict transport security is enabled. - Enabled bool `json:"enabled"` - // Include all subdomains for strict transport security. - IncludeSubdomains bool `json:"include_subdomains"` - // Max age in seconds of the strict transport security. - MaxAge float64 `json:"max_age"` - // Whether or not to include 'X-Content-Type-Options: nosniff' header. - Nosniff bool `json:"nosniff"` - JSON zoneSettingSecurityHeaderGetResponseValueStrictTransportSecurityJSON `json:"-"` -} - -// zoneSettingSecurityHeaderGetResponseValueStrictTransportSecurityJSON contains -// the JSON metadata for the struct -// [ZoneSettingSecurityHeaderGetResponseValueStrictTransportSecurity] -type zoneSettingSecurityHeaderGetResponseValueStrictTransportSecurityJSON struct { - Enabled apijson.Field - IncludeSubdomains apijson.Field - MaxAge apijson.Field - Nosniff apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityHeaderGetResponseValueStrictTransportSecurity) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityHeaderGetResponseValueStrictTransportSecurityJSON) RawJSON() string { - return r.raw -} - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingSecurityHeaderGetResponseEditable bool - -const ( - ZoneSettingSecurityHeaderGetResponseEditableTrue ZoneSettingSecurityHeaderGetResponseEditable = true - ZoneSettingSecurityHeaderGetResponseEditableFalse ZoneSettingSecurityHeaderGetResponseEditable = false -) - -type ZoneSettingSecurityHeaderEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Value param.Field[ZoneSettingSecurityHeaderEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingSecurityHeaderEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZoneSettingSecurityHeaderEditParamsValue struct { - // Strict Transport Security. - StrictTransportSecurity param.Field[ZoneSettingSecurityHeaderEditParamsValueStrictTransportSecurity] `json:"strict_transport_security"` -} - -func (r ZoneSettingSecurityHeaderEditParamsValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Strict Transport Security. -type ZoneSettingSecurityHeaderEditParamsValueStrictTransportSecurity struct { - // Whether or not strict transport security is enabled. - Enabled param.Field[bool] `json:"enabled"` - // Include all subdomains for strict transport security. - IncludeSubdomains param.Field[bool] `json:"include_subdomains"` - // Max age in seconds of the strict transport security. - MaxAge param.Field[float64] `json:"max_age"` - // Whether or not to include 'X-Content-Type-Options: nosniff' header. - Nosniff param.Field[bool] `json:"nosniff"` -} - -func (r ZoneSettingSecurityHeaderEditParamsValueStrictTransportSecurity) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZoneSettingSecurityHeaderEditResponseEnvelope struct { - Errors []ZoneSettingSecurityHeaderEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingSecurityHeaderEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Cloudflare security header for a zone. - Result ZoneSettingSecurityHeaderEditResponse `json:"result"` - JSON zoneSettingSecurityHeaderEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingSecurityHeaderEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingSecurityHeaderEditResponseEnvelope] -type zoneSettingSecurityHeaderEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityHeaderEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityHeaderEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSecurityHeaderEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSecurityHeaderEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingSecurityHeaderEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingSecurityHeaderEditResponseEnvelopeErrors] -type zoneSettingSecurityHeaderEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityHeaderEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityHeaderEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSecurityHeaderEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSecurityHeaderEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingSecurityHeaderEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingSecurityHeaderEditResponseEnvelopeMessages] -type zoneSettingSecurityHeaderEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityHeaderEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityHeaderEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSecurityHeaderGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingSecurityHeaderGetResponseEnvelope struct { - Errors []ZoneSettingSecurityHeaderGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingSecurityHeaderGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Cloudflare security header for a zone. - Result ZoneSettingSecurityHeaderGetResponse `json:"result"` - JSON zoneSettingSecurityHeaderGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingSecurityHeaderGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingSecurityHeaderGetResponseEnvelope] -type zoneSettingSecurityHeaderGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityHeaderGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityHeaderGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSecurityHeaderGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSecurityHeaderGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingSecurityHeaderGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingSecurityHeaderGetResponseEnvelopeErrors] -type zoneSettingSecurityHeaderGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityHeaderGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityHeaderGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSecurityHeaderGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSecurityHeaderGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingSecurityHeaderGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingSecurityHeaderGetResponseEnvelopeMessages] -type zoneSettingSecurityHeaderGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityHeaderGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityHeaderGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingsecurityheader_test.go b/zonesettingsecurityheader_test.go deleted file mode 100644 index ec7305b48b9..00000000000 --- a/zonesettingsecurityheader_test.go +++ /dev/null @@ -1,74 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingSecurityHeaderEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Zones.Settings.SecurityHeaders.Edit(context.TODO(), cloudflare.ZoneSettingSecurityHeaderEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingSecurityHeaderEditParamsValue{ - StrictTransportSecurity: cloudflare.F(cloudflare.ZoneSettingSecurityHeaderEditParamsValueStrictTransportSecurity{ - Enabled: cloudflare.F(true), - IncludeSubdomains: cloudflare.F(true), - MaxAge: cloudflare.F(86400.000000), - Nosniff: cloudflare.F(true), - }), - }), - }) - 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 TestZoneSettingSecurityHeaderGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.SecurityHeaders.Get(context.TODO(), cloudflare.ZoneSettingSecurityHeaderGetParams{ - ZoneID: cloudflare.F("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/zonesettingsecuritylevel.go b/zonesettingsecuritylevel.go deleted file mode 100644 index c9f32c4f2d4..00000000000 --- a/zonesettingsecuritylevel.go +++ /dev/null @@ -1,377 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingSecurityLevelService 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 -// [NewZoneSettingSecurityLevelService] method instead. -type ZoneSettingSecurityLevelService struct { - Options []option.RequestOption -} - -// NewZoneSettingSecurityLevelService 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 NewZoneSettingSecurityLevelService(opts ...option.RequestOption) (r *ZoneSettingSecurityLevelService) { - r = &ZoneSettingSecurityLevelService{} - r.Options = opts - return -} - -// Choose the appropriate security profile for your website, which will -// automatically adjust each of the security settings. If you choose to customize -// an individual security setting, the profile will become Custom. -// (https://support.cloudflare.com/hc/en-us/articles/200170056). -func (r *ZoneSettingSecurityLevelService) Edit(ctx context.Context, params ZoneSettingSecurityLevelEditParams, opts ...option.RequestOption) (res *ZoneSettingSecurityLevelEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingSecurityLevelEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/security_level", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Choose the appropriate security profile for your website, which will -// automatically adjust each of the security settings. If you choose to customize -// an individual security setting, the profile will become Custom. -// (https://support.cloudflare.com/hc/en-us/articles/200170056). -func (r *ZoneSettingSecurityLevelService) Get(ctx context.Context, query ZoneSettingSecurityLevelGetParams, opts ...option.RequestOption) (res *ZoneSettingSecurityLevelGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingSecurityLevelGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/security_level", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Choose the appropriate security profile for your website, which will -// automatically adjust each of the security settings. If you choose to customize -// an individual security setting, the profile will become Custom. -// (https://support.cloudflare.com/hc/en-us/articles/200170056). -type ZoneSettingSecurityLevelEditResponse struct { - // ID of the zone setting. - ID ZoneSettingSecurityLevelEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingSecurityLevelEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingSecurityLevelEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingSecurityLevelEditResponseJSON `json:"-"` -} - -// zoneSettingSecurityLevelEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingSecurityLevelEditResponse] -type zoneSettingSecurityLevelEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityLevelEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityLevelEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingSecurityLevelEditResponseID string - -const ( - ZoneSettingSecurityLevelEditResponseIDSecurityLevel ZoneSettingSecurityLevelEditResponseID = "security_level" -) - -// Current value of the zone setting. -type ZoneSettingSecurityLevelEditResponseValue string - -const ( - ZoneSettingSecurityLevelEditResponseValueOff ZoneSettingSecurityLevelEditResponseValue = "off" - ZoneSettingSecurityLevelEditResponseValueEssentiallyOff ZoneSettingSecurityLevelEditResponseValue = "essentially_off" - ZoneSettingSecurityLevelEditResponseValueLow ZoneSettingSecurityLevelEditResponseValue = "low" - ZoneSettingSecurityLevelEditResponseValueMedium ZoneSettingSecurityLevelEditResponseValue = "medium" - ZoneSettingSecurityLevelEditResponseValueHigh ZoneSettingSecurityLevelEditResponseValue = "high" - ZoneSettingSecurityLevelEditResponseValueUnderAttack ZoneSettingSecurityLevelEditResponseValue = "under_attack" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingSecurityLevelEditResponseEditable bool - -const ( - ZoneSettingSecurityLevelEditResponseEditableTrue ZoneSettingSecurityLevelEditResponseEditable = true - ZoneSettingSecurityLevelEditResponseEditableFalse ZoneSettingSecurityLevelEditResponseEditable = false -) - -// Choose the appropriate security profile for your website, which will -// automatically adjust each of the security settings. If you choose to customize -// an individual security setting, the profile will become Custom. -// (https://support.cloudflare.com/hc/en-us/articles/200170056). -type ZoneSettingSecurityLevelGetResponse struct { - // ID of the zone setting. - ID ZoneSettingSecurityLevelGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingSecurityLevelGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingSecurityLevelGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingSecurityLevelGetResponseJSON `json:"-"` -} - -// zoneSettingSecurityLevelGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingSecurityLevelGetResponse] -type zoneSettingSecurityLevelGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityLevelGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityLevelGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingSecurityLevelGetResponseID string - -const ( - ZoneSettingSecurityLevelGetResponseIDSecurityLevel ZoneSettingSecurityLevelGetResponseID = "security_level" -) - -// Current value of the zone setting. -type ZoneSettingSecurityLevelGetResponseValue string - -const ( - ZoneSettingSecurityLevelGetResponseValueOff ZoneSettingSecurityLevelGetResponseValue = "off" - ZoneSettingSecurityLevelGetResponseValueEssentiallyOff ZoneSettingSecurityLevelGetResponseValue = "essentially_off" - ZoneSettingSecurityLevelGetResponseValueLow ZoneSettingSecurityLevelGetResponseValue = "low" - ZoneSettingSecurityLevelGetResponseValueMedium ZoneSettingSecurityLevelGetResponseValue = "medium" - ZoneSettingSecurityLevelGetResponseValueHigh ZoneSettingSecurityLevelGetResponseValue = "high" - ZoneSettingSecurityLevelGetResponseValueUnderAttack ZoneSettingSecurityLevelGetResponseValue = "under_attack" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingSecurityLevelGetResponseEditable bool - -const ( - ZoneSettingSecurityLevelGetResponseEditableTrue ZoneSettingSecurityLevelGetResponseEditable = true - ZoneSettingSecurityLevelGetResponseEditableFalse ZoneSettingSecurityLevelGetResponseEditable = false -) - -type ZoneSettingSecurityLevelEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingSecurityLevelEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingSecurityLevelEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingSecurityLevelEditParamsValue string - -const ( - ZoneSettingSecurityLevelEditParamsValueOff ZoneSettingSecurityLevelEditParamsValue = "off" - ZoneSettingSecurityLevelEditParamsValueEssentiallyOff ZoneSettingSecurityLevelEditParamsValue = "essentially_off" - ZoneSettingSecurityLevelEditParamsValueLow ZoneSettingSecurityLevelEditParamsValue = "low" - ZoneSettingSecurityLevelEditParamsValueMedium ZoneSettingSecurityLevelEditParamsValue = "medium" - ZoneSettingSecurityLevelEditParamsValueHigh ZoneSettingSecurityLevelEditParamsValue = "high" - ZoneSettingSecurityLevelEditParamsValueUnderAttack ZoneSettingSecurityLevelEditParamsValue = "under_attack" -) - -type ZoneSettingSecurityLevelEditResponseEnvelope struct { - Errors []ZoneSettingSecurityLevelEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingSecurityLevelEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Choose the appropriate security profile for your website, which will - // automatically adjust each of the security settings. If you choose to customize - // an individual security setting, the profile will become Custom. - // (https://support.cloudflare.com/hc/en-us/articles/200170056). - Result ZoneSettingSecurityLevelEditResponse `json:"result"` - JSON zoneSettingSecurityLevelEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingSecurityLevelEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingSecurityLevelEditResponseEnvelope] -type zoneSettingSecurityLevelEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityLevelEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityLevelEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSecurityLevelEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSecurityLevelEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingSecurityLevelEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingSecurityLevelEditResponseEnvelopeErrors] -type zoneSettingSecurityLevelEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityLevelEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityLevelEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSecurityLevelEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSecurityLevelEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingSecurityLevelEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingSecurityLevelEditResponseEnvelopeMessages] -type zoneSettingSecurityLevelEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityLevelEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityLevelEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSecurityLevelGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingSecurityLevelGetResponseEnvelope struct { - Errors []ZoneSettingSecurityLevelGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingSecurityLevelGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Choose the appropriate security profile for your website, which will - // automatically adjust each of the security settings. If you choose to customize - // an individual security setting, the profile will become Custom. - // (https://support.cloudflare.com/hc/en-us/articles/200170056). - Result ZoneSettingSecurityLevelGetResponse `json:"result"` - JSON zoneSettingSecurityLevelGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingSecurityLevelGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingSecurityLevelGetResponseEnvelope] -type zoneSettingSecurityLevelGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityLevelGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityLevelGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSecurityLevelGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSecurityLevelGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingSecurityLevelGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingSecurityLevelGetResponseEnvelopeErrors] -type zoneSettingSecurityLevelGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityLevelGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityLevelGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSecurityLevelGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSecurityLevelGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingSecurityLevelGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingSecurityLevelGetResponseEnvelopeMessages] -type zoneSettingSecurityLevelGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSecurityLevelGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSecurityLevelGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingsecuritylevel_test.go b/zonesettingsecuritylevel_test.go deleted file mode 100644 index 0e343eeeb7b..00000000000 --- a/zonesettingsecuritylevel_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingSecurityLevelEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.SecurityLevel.Edit(context.TODO(), cloudflare.ZoneSettingSecurityLevelEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingSecurityLevelEditParamsValueOff), - }) - 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 TestZoneSettingSecurityLevelGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.SecurityLevel.Get(context.TODO(), cloudflare.ZoneSettingSecurityLevelGetParams{ - ZoneID: cloudflare.F("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/zonesettingserversideexclude.go b/zonesettingserversideexclude.go deleted file mode 100644 index 71b633e7de3..00000000000 --- a/zonesettingserversideexclude.go +++ /dev/null @@ -1,409 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingServerSideExcludeService 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 -// [NewZoneSettingServerSideExcludeService] method instead. -type ZoneSettingServerSideExcludeService struct { - Options []option.RequestOption -} - -// NewZoneSettingServerSideExcludeService 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 NewZoneSettingServerSideExcludeService(opts ...option.RequestOption) (r *ZoneSettingServerSideExcludeService) { - r = &ZoneSettingServerSideExcludeService{} - r.Options = opts - return -} - -// If there is sensitive content on your website that you want visible to real -// visitors, but that you want to hide from suspicious visitors, all you have to do -// is wrap the content with Cloudflare SSE tags. Wrap any content that you want to -// be excluded from suspicious visitors in the following SSE tags: -// . For example: Bad visitors won't see my phone -// number, 555-555-5555 . Note: SSE only will work with HTML. If you -// have HTML minification enabled, you won't see the SSE tags in your HTML source -// when it's served through Cloudflare. SSE will still function in this case, as -// Cloudflare's HTML minification and SSE functionality occur on-the-fly as the -// resource moves through our network to the visitor's computer. -// (https://support.cloudflare.com/hc/en-us/articles/200170036). -func (r *ZoneSettingServerSideExcludeService) Edit(ctx context.Context, params ZoneSettingServerSideExcludeEditParams, opts ...option.RequestOption) (res *ZoneSettingServerSideExcludeEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingServerSideExcludeEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/server_side_exclude", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// If there is sensitive content on your website that you want visible to real -// visitors, but that you want to hide from suspicious visitors, all you have to do -// is wrap the content with Cloudflare SSE tags. Wrap any content that you want to -// be excluded from suspicious visitors in the following SSE tags: -// . For example: Bad visitors won't see my phone -// number, 555-555-5555 . Note: SSE only will work with HTML. If you -// have HTML minification enabled, you won't see the SSE tags in your HTML source -// when it's served through Cloudflare. SSE will still function in this case, as -// Cloudflare's HTML minification and SSE functionality occur on-the-fly as the -// resource moves through our network to the visitor's computer. -// (https://support.cloudflare.com/hc/en-us/articles/200170036). -func (r *ZoneSettingServerSideExcludeService) Get(ctx context.Context, query ZoneSettingServerSideExcludeGetParams, opts ...option.RequestOption) (res *ZoneSettingServerSideExcludeGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingServerSideExcludeGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/server_side_exclude", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// If there is sensitive content on your website that you want visible to real -// visitors, but that you want to hide from suspicious visitors, all you have to do -// is wrap the content with Cloudflare SSE tags. Wrap any content that you want to -// be excluded from suspicious visitors in the following SSE tags: -// . For example: Bad visitors won't see my phone -// number, 555-555-5555 . Note: SSE only will work with HTML. If you -// have HTML minification enabled, you won't see the SSE tags in your HTML source -// when it's served through Cloudflare. SSE will still function in this case, as -// Cloudflare's HTML minification and SSE functionality occur on-the-fly as the -// resource moves through our network to the visitor's computer. -// (https://support.cloudflare.com/hc/en-us/articles/200170036). -type ZoneSettingServerSideExcludeEditResponse struct { - // ID of the zone setting. - ID ZoneSettingServerSideExcludeEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingServerSideExcludeEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingServerSideExcludeEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingServerSideExcludeEditResponseJSON `json:"-"` -} - -// zoneSettingServerSideExcludeEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingServerSideExcludeEditResponse] -type zoneSettingServerSideExcludeEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingServerSideExcludeEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingServerSideExcludeEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingServerSideExcludeEditResponseID string - -const ( - ZoneSettingServerSideExcludeEditResponseIDServerSideExclude ZoneSettingServerSideExcludeEditResponseID = "server_side_exclude" -) - -// Current value of the zone setting. -type ZoneSettingServerSideExcludeEditResponseValue string - -const ( - ZoneSettingServerSideExcludeEditResponseValueOn ZoneSettingServerSideExcludeEditResponseValue = "on" - ZoneSettingServerSideExcludeEditResponseValueOff ZoneSettingServerSideExcludeEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingServerSideExcludeEditResponseEditable bool - -const ( - ZoneSettingServerSideExcludeEditResponseEditableTrue ZoneSettingServerSideExcludeEditResponseEditable = true - ZoneSettingServerSideExcludeEditResponseEditableFalse ZoneSettingServerSideExcludeEditResponseEditable = false -) - -// If there is sensitive content on your website that you want visible to real -// visitors, but that you want to hide from suspicious visitors, all you have to do -// is wrap the content with Cloudflare SSE tags. Wrap any content that you want to -// be excluded from suspicious visitors in the following SSE tags: -// . For example: Bad visitors won't see my phone -// number, 555-555-5555 . Note: SSE only will work with HTML. If you -// have HTML minification enabled, you won't see the SSE tags in your HTML source -// when it's served through Cloudflare. SSE will still function in this case, as -// Cloudflare's HTML minification and SSE functionality occur on-the-fly as the -// resource moves through our network to the visitor's computer. -// (https://support.cloudflare.com/hc/en-us/articles/200170036). -type ZoneSettingServerSideExcludeGetResponse struct { - // ID of the zone setting. - ID ZoneSettingServerSideExcludeGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingServerSideExcludeGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingServerSideExcludeGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingServerSideExcludeGetResponseJSON `json:"-"` -} - -// zoneSettingServerSideExcludeGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingServerSideExcludeGetResponse] -type zoneSettingServerSideExcludeGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingServerSideExcludeGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingServerSideExcludeGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingServerSideExcludeGetResponseID string - -const ( - ZoneSettingServerSideExcludeGetResponseIDServerSideExclude ZoneSettingServerSideExcludeGetResponseID = "server_side_exclude" -) - -// Current value of the zone setting. -type ZoneSettingServerSideExcludeGetResponseValue string - -const ( - ZoneSettingServerSideExcludeGetResponseValueOn ZoneSettingServerSideExcludeGetResponseValue = "on" - ZoneSettingServerSideExcludeGetResponseValueOff ZoneSettingServerSideExcludeGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingServerSideExcludeGetResponseEditable bool - -const ( - ZoneSettingServerSideExcludeGetResponseEditableTrue ZoneSettingServerSideExcludeGetResponseEditable = true - ZoneSettingServerSideExcludeGetResponseEditableFalse ZoneSettingServerSideExcludeGetResponseEditable = false -) - -type ZoneSettingServerSideExcludeEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingServerSideExcludeEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingServerSideExcludeEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingServerSideExcludeEditParamsValue string - -const ( - ZoneSettingServerSideExcludeEditParamsValueOn ZoneSettingServerSideExcludeEditParamsValue = "on" - ZoneSettingServerSideExcludeEditParamsValueOff ZoneSettingServerSideExcludeEditParamsValue = "off" -) - -type ZoneSettingServerSideExcludeEditResponseEnvelope struct { - Errors []ZoneSettingServerSideExcludeEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingServerSideExcludeEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // If there is sensitive content on your website that you want visible to real - // visitors, but that you want to hide from suspicious visitors, all you have to do - // is wrap the content with Cloudflare SSE tags. Wrap any content that you want to - // be excluded from suspicious visitors in the following SSE tags: - // . For example: Bad visitors won't see my phone - // number, 555-555-5555 . Note: SSE only will work with HTML. If you - // have HTML minification enabled, you won't see the SSE tags in your HTML source - // when it's served through Cloudflare. SSE will still function in this case, as - // Cloudflare's HTML minification and SSE functionality occur on-the-fly as the - // resource moves through our network to the visitor's computer. - // (https://support.cloudflare.com/hc/en-us/articles/200170036). - Result ZoneSettingServerSideExcludeEditResponse `json:"result"` - JSON zoneSettingServerSideExcludeEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingServerSideExcludeEditResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingServerSideExcludeEditResponseEnvelope] -type zoneSettingServerSideExcludeEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingServerSideExcludeEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingServerSideExcludeEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingServerSideExcludeEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingServerSideExcludeEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingServerSideExcludeEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingServerSideExcludeEditResponseEnvelopeErrors] -type zoneSettingServerSideExcludeEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingServerSideExcludeEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingServerSideExcludeEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingServerSideExcludeEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingServerSideExcludeEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingServerSideExcludeEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZoneSettingServerSideExcludeEditResponseEnvelopeMessages] -type zoneSettingServerSideExcludeEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingServerSideExcludeEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingServerSideExcludeEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingServerSideExcludeGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingServerSideExcludeGetResponseEnvelope struct { - Errors []ZoneSettingServerSideExcludeGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingServerSideExcludeGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // If there is sensitive content on your website that you want visible to real - // visitors, but that you want to hide from suspicious visitors, all you have to do - // is wrap the content with Cloudflare SSE tags. Wrap any content that you want to - // be excluded from suspicious visitors in the following SSE tags: - // . For example: Bad visitors won't see my phone - // number, 555-555-5555 . Note: SSE only will work with HTML. If you - // have HTML minification enabled, you won't see the SSE tags in your HTML source - // when it's served through Cloudflare. SSE will still function in this case, as - // Cloudflare's HTML minification and SSE functionality occur on-the-fly as the - // resource moves through our network to the visitor's computer. - // (https://support.cloudflare.com/hc/en-us/articles/200170036). - Result ZoneSettingServerSideExcludeGetResponse `json:"result"` - JSON zoneSettingServerSideExcludeGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingServerSideExcludeGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingServerSideExcludeGetResponseEnvelope] -type zoneSettingServerSideExcludeGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingServerSideExcludeGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingServerSideExcludeGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingServerSideExcludeGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingServerSideExcludeGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingServerSideExcludeGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingServerSideExcludeGetResponseEnvelopeErrors] -type zoneSettingServerSideExcludeGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingServerSideExcludeGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingServerSideExcludeGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingServerSideExcludeGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingServerSideExcludeGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingServerSideExcludeGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZoneSettingServerSideExcludeGetResponseEnvelopeMessages] -type zoneSettingServerSideExcludeGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingServerSideExcludeGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingServerSideExcludeGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingserversideexclude_test.go b/zonesettingserversideexclude_test.go deleted file mode 100644 index d06f8a361e5..00000000000 --- a/zonesettingserversideexclude_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingServerSideExcludeEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.ServerSideExcludes.Edit(context.TODO(), cloudflare.ZoneSettingServerSideExcludeEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingServerSideExcludeEditParamsValueOn), - }) - 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 TestZoneSettingServerSideExcludeGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.ServerSideExcludes.Get(context.TODO(), cloudflare.ZoneSettingServerSideExcludeGetParams{ - ZoneID: cloudflare.F("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/zonesettingsortquerystringforcache.go b/zonesettingsortquerystringforcache.go deleted file mode 100644 index 289a41308fe..00000000000 --- a/zonesettingsortquerystringforcache.go +++ /dev/null @@ -1,364 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingSortQueryStringForCacheService 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 -// [NewZoneSettingSortQueryStringForCacheService] method instead. -type ZoneSettingSortQueryStringForCacheService struct { - Options []option.RequestOption -} - -// NewZoneSettingSortQueryStringForCacheService 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 NewZoneSettingSortQueryStringForCacheService(opts ...option.RequestOption) (r *ZoneSettingSortQueryStringForCacheService) { - r = &ZoneSettingSortQueryStringForCacheService{} - r.Options = opts - return -} - -// Cloudflare will treat files with the same query strings as the same file in -// cache, regardless of the order of the query strings. This is limited to -// Enterprise Zones. -func (r *ZoneSettingSortQueryStringForCacheService) Edit(ctx context.Context, params ZoneSettingSortQueryStringForCacheEditParams, opts ...option.RequestOption) (res *ZoneSettingSortQueryStringForCacheEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingSortQueryStringForCacheEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/sort_query_string_for_cache", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Cloudflare will treat files with the same query strings as the same file in -// cache, regardless of the order of the query strings. This is limited to -// Enterprise Zones. -func (r *ZoneSettingSortQueryStringForCacheService) Get(ctx context.Context, query ZoneSettingSortQueryStringForCacheGetParams, opts ...option.RequestOption) (res *ZoneSettingSortQueryStringForCacheGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingSortQueryStringForCacheGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/sort_query_string_for_cache", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Cloudflare will treat files with the same query strings as the same file in -// cache, regardless of the order of the query strings. This is limited to -// Enterprise Zones. -type ZoneSettingSortQueryStringForCacheEditResponse struct { - // ID of the zone setting. - ID ZoneSettingSortQueryStringForCacheEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingSortQueryStringForCacheEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingSortQueryStringForCacheEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingSortQueryStringForCacheEditResponseJSON `json:"-"` -} - -// zoneSettingSortQueryStringForCacheEditResponseJSON contains the JSON metadata -// for the struct [ZoneSettingSortQueryStringForCacheEditResponse] -type zoneSettingSortQueryStringForCacheEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSortQueryStringForCacheEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSortQueryStringForCacheEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingSortQueryStringForCacheEditResponseID string - -const ( - ZoneSettingSortQueryStringForCacheEditResponseIDSortQueryStringForCache ZoneSettingSortQueryStringForCacheEditResponseID = "sort_query_string_for_cache" -) - -// Current value of the zone setting. -type ZoneSettingSortQueryStringForCacheEditResponseValue string - -const ( - ZoneSettingSortQueryStringForCacheEditResponseValueOn ZoneSettingSortQueryStringForCacheEditResponseValue = "on" - ZoneSettingSortQueryStringForCacheEditResponseValueOff ZoneSettingSortQueryStringForCacheEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingSortQueryStringForCacheEditResponseEditable bool - -const ( - ZoneSettingSortQueryStringForCacheEditResponseEditableTrue ZoneSettingSortQueryStringForCacheEditResponseEditable = true - ZoneSettingSortQueryStringForCacheEditResponseEditableFalse ZoneSettingSortQueryStringForCacheEditResponseEditable = false -) - -// Cloudflare will treat files with the same query strings as the same file in -// cache, regardless of the order of the query strings. This is limited to -// Enterprise Zones. -type ZoneSettingSortQueryStringForCacheGetResponse struct { - // ID of the zone setting. - ID ZoneSettingSortQueryStringForCacheGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingSortQueryStringForCacheGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingSortQueryStringForCacheGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingSortQueryStringForCacheGetResponseJSON `json:"-"` -} - -// zoneSettingSortQueryStringForCacheGetResponseJSON contains the JSON metadata for -// the struct [ZoneSettingSortQueryStringForCacheGetResponse] -type zoneSettingSortQueryStringForCacheGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSortQueryStringForCacheGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSortQueryStringForCacheGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingSortQueryStringForCacheGetResponseID string - -const ( - ZoneSettingSortQueryStringForCacheGetResponseIDSortQueryStringForCache ZoneSettingSortQueryStringForCacheGetResponseID = "sort_query_string_for_cache" -) - -// Current value of the zone setting. -type ZoneSettingSortQueryStringForCacheGetResponseValue string - -const ( - ZoneSettingSortQueryStringForCacheGetResponseValueOn ZoneSettingSortQueryStringForCacheGetResponseValue = "on" - ZoneSettingSortQueryStringForCacheGetResponseValueOff ZoneSettingSortQueryStringForCacheGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingSortQueryStringForCacheGetResponseEditable bool - -const ( - ZoneSettingSortQueryStringForCacheGetResponseEditableTrue ZoneSettingSortQueryStringForCacheGetResponseEditable = true - ZoneSettingSortQueryStringForCacheGetResponseEditableFalse ZoneSettingSortQueryStringForCacheGetResponseEditable = false -) - -type ZoneSettingSortQueryStringForCacheEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingSortQueryStringForCacheEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingSortQueryStringForCacheEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingSortQueryStringForCacheEditParamsValue string - -const ( - ZoneSettingSortQueryStringForCacheEditParamsValueOn ZoneSettingSortQueryStringForCacheEditParamsValue = "on" - ZoneSettingSortQueryStringForCacheEditParamsValueOff ZoneSettingSortQueryStringForCacheEditParamsValue = "off" -) - -type ZoneSettingSortQueryStringForCacheEditResponseEnvelope struct { - Errors []ZoneSettingSortQueryStringForCacheEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingSortQueryStringForCacheEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Cloudflare will treat files with the same query strings as the same file in - // cache, regardless of the order of the query strings. This is limited to - // Enterprise Zones. - Result ZoneSettingSortQueryStringForCacheEditResponse `json:"result"` - JSON zoneSettingSortQueryStringForCacheEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingSortQueryStringForCacheEditResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZoneSettingSortQueryStringForCacheEditResponseEnvelope] -type zoneSettingSortQueryStringForCacheEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSortQueryStringForCacheEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSortQueryStringForCacheEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSortQueryStringForCacheEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSortQueryStringForCacheEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingSortQueryStringForCacheEditResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZoneSettingSortQueryStringForCacheEditResponseEnvelopeErrors] -type zoneSettingSortQueryStringForCacheEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSortQueryStringForCacheEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSortQueryStringForCacheEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSortQueryStringForCacheEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSortQueryStringForCacheEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingSortQueryStringForCacheEditResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZoneSettingSortQueryStringForCacheEditResponseEnvelopeMessages] -type zoneSettingSortQueryStringForCacheEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSortQueryStringForCacheEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSortQueryStringForCacheEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSortQueryStringForCacheGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingSortQueryStringForCacheGetResponseEnvelope struct { - Errors []ZoneSettingSortQueryStringForCacheGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingSortQueryStringForCacheGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Cloudflare will treat files with the same query strings as the same file in - // cache, regardless of the order of the query strings. This is limited to - // Enterprise Zones. - Result ZoneSettingSortQueryStringForCacheGetResponse `json:"result"` - JSON zoneSettingSortQueryStringForCacheGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingSortQueryStringForCacheGetResponseEnvelopeJSON contains the JSON -// metadata for the struct [ZoneSettingSortQueryStringForCacheGetResponseEnvelope] -type zoneSettingSortQueryStringForCacheGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSortQueryStringForCacheGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSortQueryStringForCacheGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSortQueryStringForCacheGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSortQueryStringForCacheGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingSortQueryStringForCacheGetResponseEnvelopeErrorsJSON contains the -// JSON metadata for the struct -// [ZoneSettingSortQueryStringForCacheGetResponseEnvelopeErrors] -type zoneSettingSortQueryStringForCacheGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSortQueryStringForCacheGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSortQueryStringForCacheGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSortQueryStringForCacheGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSortQueryStringForCacheGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingSortQueryStringForCacheGetResponseEnvelopeMessagesJSON contains the -// JSON metadata for the struct -// [ZoneSettingSortQueryStringForCacheGetResponseEnvelopeMessages] -type zoneSettingSortQueryStringForCacheGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSortQueryStringForCacheGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSortQueryStringForCacheGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingsortquerystringforcache_test.go b/zonesettingsortquerystringforcache_test.go deleted file mode 100644 index e5b63fb60a9..00000000000 --- a/zonesettingsortquerystringforcache_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingSortQueryStringForCacheEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.SortQueryStringForCache.Edit(context.TODO(), cloudflare.ZoneSettingSortQueryStringForCacheEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingSortQueryStringForCacheEditParamsValueOn), - }) - 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 TestZoneSettingSortQueryStringForCacheGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.SortQueryStringForCache.Get(context.TODO(), cloudflare.ZoneSettingSortQueryStringForCacheGetParams{ - ZoneID: cloudflare.F("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/zonesettingssl.go b/zonesettingssl.go deleted file mode 100644 index 8942f610826..00000000000 --- a/zonesettingssl.go +++ /dev/null @@ -1,443 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingSSLService 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 [NewZoneSettingSSLService] method -// instead. -type ZoneSettingSSLService struct { - Options []option.RequestOption -} - -// NewZoneSettingSSLService 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 NewZoneSettingSSLService(opts ...option.RequestOption) (r *ZoneSettingSSLService) { - r = &ZoneSettingSSLService{} - r.Options = opts - return -} - -// SSL encrypts your visitor's connection and safeguards credit card numbers and -// other personal data to and from your website. SSL can take up to 5 minutes to -// fully activate. Requires Cloudflare active on your root domain or www domain. -// Off: no SSL between the visitor and Cloudflare, and no SSL between Cloudflare -// and your web server (all HTTP traffic). Flexible: SSL between the visitor and -// Cloudflare -- visitor sees HTTPS on your site, but no SSL between Cloudflare and -// your web server. You don't need to have an SSL cert on your web server, but your -// vistors will still see the site as being HTTPS enabled. Full: SSL between the -// visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between -// Cloudflare and your web server. You'll need to have your own SSL cert or -// self-signed cert at the very least. Full (Strict): SSL between the visitor and -// Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and -// your web server. You'll need to have a valid SSL certificate installed on your -// web server. This certificate must be signed by a certificate authority, have an -// expiration date in the future, and respond for the request domain name -// (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). -func (r *ZoneSettingSSLService) Edit(ctx context.Context, params ZoneSettingSSLEditParams, opts ...option.RequestOption) (res *ZoneSettingSSLEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingSSLEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/ssl", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// SSL encrypts your visitor's connection and safeguards credit card numbers and -// other personal data to and from your website. SSL can take up to 5 minutes to -// fully activate. Requires Cloudflare active on your root domain or www domain. -// Off: no SSL between the visitor and Cloudflare, and no SSL between Cloudflare -// and your web server (all HTTP traffic). Flexible: SSL between the visitor and -// Cloudflare -- visitor sees HTTPS on your site, but no SSL between Cloudflare and -// your web server. You don't need to have an SSL cert on your web server, but your -// vistors will still see the site as being HTTPS enabled. Full: SSL between the -// visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between -// Cloudflare and your web server. You'll need to have your own SSL cert or -// self-signed cert at the very least. Full (Strict): SSL between the visitor and -// Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and -// your web server. You'll need to have a valid SSL certificate installed on your -// web server. This certificate must be signed by a certificate authority, have an -// expiration date in the future, and respond for the request domain name -// (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). -func (r *ZoneSettingSSLService) Get(ctx context.Context, query ZoneSettingSSLGetParams, opts ...option.RequestOption) (res *ZoneSettingSSLGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingSSLGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/ssl", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// SSL encrypts your visitor's connection and safeguards credit card numbers and -// other personal data to and from your website. SSL can take up to 5 minutes to -// fully activate. Requires Cloudflare active on your root domain or www domain. -// Off: no SSL between the visitor and Cloudflare, and no SSL between Cloudflare -// and your web server (all HTTP traffic). Flexible: SSL between the visitor and -// Cloudflare -- visitor sees HTTPS on your site, but no SSL between Cloudflare and -// your web server. You don't need to have an SSL cert on your web server, but your -// vistors will still see the site as being HTTPS enabled. Full: SSL between the -// visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between -// Cloudflare and your web server. You'll need to have your own SSL cert or -// self-signed cert at the very least. Full (Strict): SSL between the visitor and -// Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and -// your web server. You'll need to have a valid SSL certificate installed on your -// web server. This certificate must be signed by a certificate authority, have an -// expiration date in the future, and respond for the request domain name -// (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). -type ZoneSettingSSLEditResponse struct { - // ID of the zone setting. - ID ZoneSettingSSLEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingSSLEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingSSLEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingSSLEditResponseJSON `json:"-"` -} - -// zoneSettingSSLEditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingSSLEditResponse] -type zoneSettingSSLEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSSLEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSSLEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingSSLEditResponseID string - -const ( - ZoneSettingSSLEditResponseIDSSL ZoneSettingSSLEditResponseID = "ssl" -) - -// Current value of the zone setting. -type ZoneSettingSSLEditResponseValue string - -const ( - ZoneSettingSSLEditResponseValueOff ZoneSettingSSLEditResponseValue = "off" - ZoneSettingSSLEditResponseValueFlexible ZoneSettingSSLEditResponseValue = "flexible" - ZoneSettingSSLEditResponseValueFull ZoneSettingSSLEditResponseValue = "full" - ZoneSettingSSLEditResponseValueStrict ZoneSettingSSLEditResponseValue = "strict" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingSSLEditResponseEditable bool - -const ( - ZoneSettingSSLEditResponseEditableTrue ZoneSettingSSLEditResponseEditable = true - ZoneSettingSSLEditResponseEditableFalse ZoneSettingSSLEditResponseEditable = false -) - -// SSL encrypts your visitor's connection and safeguards credit card numbers and -// other personal data to and from your website. SSL can take up to 5 minutes to -// fully activate. Requires Cloudflare active on your root domain or www domain. -// Off: no SSL between the visitor and Cloudflare, and no SSL between Cloudflare -// and your web server (all HTTP traffic). Flexible: SSL between the visitor and -// Cloudflare -- visitor sees HTTPS on your site, but no SSL between Cloudflare and -// your web server. You don't need to have an SSL cert on your web server, but your -// vistors will still see the site as being HTTPS enabled. Full: SSL between the -// visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between -// Cloudflare and your web server. You'll need to have your own SSL cert or -// self-signed cert at the very least. Full (Strict): SSL between the visitor and -// Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and -// your web server. You'll need to have a valid SSL certificate installed on your -// web server. This certificate must be signed by a certificate authority, have an -// expiration date in the future, and respond for the request domain name -// (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). -type ZoneSettingSSLGetResponse struct { - // ID of the zone setting. - ID ZoneSettingSSLGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingSSLGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingSSLGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingSSLGetResponseJSON `json:"-"` -} - -// zoneSettingSSLGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingSSLGetResponse] -type zoneSettingSSLGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSSLGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSSLGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingSSLGetResponseID string - -const ( - ZoneSettingSSLGetResponseIDSSL ZoneSettingSSLGetResponseID = "ssl" -) - -// Current value of the zone setting. -type ZoneSettingSSLGetResponseValue string - -const ( - ZoneSettingSSLGetResponseValueOff ZoneSettingSSLGetResponseValue = "off" - ZoneSettingSSLGetResponseValueFlexible ZoneSettingSSLGetResponseValue = "flexible" - ZoneSettingSSLGetResponseValueFull ZoneSettingSSLGetResponseValue = "full" - ZoneSettingSSLGetResponseValueStrict ZoneSettingSSLGetResponseValue = "strict" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingSSLGetResponseEditable bool - -const ( - ZoneSettingSSLGetResponseEditableTrue ZoneSettingSSLGetResponseEditable = true - ZoneSettingSSLGetResponseEditableFalse ZoneSettingSSLGetResponseEditable = false -) - -type ZoneSettingSSLEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. Notes: Depends on the zone's plan level - Value param.Field[ZoneSettingSSLEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingSSLEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. Notes: Depends on the zone's plan level -type ZoneSettingSSLEditParamsValue string - -const ( - ZoneSettingSSLEditParamsValueOff ZoneSettingSSLEditParamsValue = "off" - ZoneSettingSSLEditParamsValueFlexible ZoneSettingSSLEditParamsValue = "flexible" - ZoneSettingSSLEditParamsValueFull ZoneSettingSSLEditParamsValue = "full" - ZoneSettingSSLEditParamsValueStrict ZoneSettingSSLEditParamsValue = "strict" -) - -type ZoneSettingSSLEditResponseEnvelope struct { - Errors []ZoneSettingSSLEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingSSLEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // SSL encrypts your visitor's connection and safeguards credit card numbers and - // other personal data to and from your website. SSL can take up to 5 minutes to - // fully activate. Requires Cloudflare active on your root domain or www domain. - // Off: no SSL between the visitor and Cloudflare, and no SSL between Cloudflare - // and your web server (all HTTP traffic). Flexible: SSL between the visitor and - // Cloudflare -- visitor sees HTTPS on your site, but no SSL between Cloudflare and - // your web server. You don't need to have an SSL cert on your web server, but your - // vistors will still see the site as being HTTPS enabled. Full: SSL between the - // visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between - // Cloudflare and your web server. You'll need to have your own SSL cert or - // self-signed cert at the very least. Full (Strict): SSL between the visitor and - // Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and - // your web server. You'll need to have a valid SSL certificate installed on your - // web server. This certificate must be signed by a certificate authority, have an - // expiration date in the future, and respond for the request domain name - // (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). - Result ZoneSettingSSLEditResponse `json:"result"` - JSON zoneSettingSSLEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingSSLEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [ZoneSettingSSLEditResponseEnvelope] -type zoneSettingSSLEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSSLEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSSLEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSSLEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSSLEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingSSLEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZoneSettingSSLEditResponseEnvelopeErrors] -type zoneSettingSSLEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSSLEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSSLEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSSLEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSSLEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingSSLEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingSSLEditResponseEnvelopeMessages] -type zoneSettingSSLEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSSLEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSSLEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSSLGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingSSLGetResponseEnvelope struct { - Errors []ZoneSettingSSLGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingSSLGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // SSL encrypts your visitor's connection and safeguards credit card numbers and - // other personal data to and from your website. SSL can take up to 5 minutes to - // fully activate. Requires Cloudflare active on your root domain or www domain. - // Off: no SSL between the visitor and Cloudflare, and no SSL between Cloudflare - // and your web server (all HTTP traffic). Flexible: SSL between the visitor and - // Cloudflare -- visitor sees HTTPS on your site, but no SSL between Cloudflare and - // your web server. You don't need to have an SSL cert on your web server, but your - // vistors will still see the site as being HTTPS enabled. Full: SSL between the - // visitor and Cloudflare -- visitor sees HTTPS on your site, and SSL between - // Cloudflare and your web server. You'll need to have your own SSL cert or - // self-signed cert at the very least. Full (Strict): SSL between the visitor and - // Cloudflare -- visitor sees HTTPS on your site, and SSL between Cloudflare and - // your web server. You'll need to have a valid SSL certificate installed on your - // web server. This certificate must be signed by a certificate authority, have an - // expiration date in the future, and respond for the request domain name - // (hostname). (https://support.cloudflare.com/hc/en-us/articles/200170416). - Result ZoneSettingSSLGetResponse `json:"result"` - JSON zoneSettingSSLGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingSSLGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [ZoneSettingSSLGetResponseEnvelope] -type zoneSettingSSLGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSSLGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSSLGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSSLGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSSLGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingSSLGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZoneSettingSSLGetResponseEnvelopeErrors] -type zoneSettingSSLGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSSLGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSSLGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSSLGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSSLGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingSSLGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ZoneSettingSSLGetResponseEnvelopeMessages] -type zoneSettingSSLGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSSLGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSSLGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingssl_test.go b/zonesettingssl_test.go deleted file mode 100644 index 136371b2873..00000000000 --- a/zonesettingssl_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingSSLEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.SSL.Edit(context.TODO(), cloudflare.ZoneSettingSSLEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingSSLEditParamsValueOff), - }) - 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 TestZoneSettingSSLGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.SSL.Get(context.TODO(), cloudflare.ZoneSettingSSLGetParams{ - ZoneID: cloudflare.F("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/zonesettingsslrecommender.go b/zonesettingsslrecommender.go deleted file mode 100644 index c3e2c16b15a..00000000000 --- a/zonesettingsslrecommender.go +++ /dev/null @@ -1,325 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingSSLRecommenderService 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 -// [NewZoneSettingSSLRecommenderService] method instead. -type ZoneSettingSSLRecommenderService struct { - Options []option.RequestOption -} - -// NewZoneSettingSSLRecommenderService 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 NewZoneSettingSSLRecommenderService(opts ...option.RequestOption) (r *ZoneSettingSSLRecommenderService) { - r = &ZoneSettingSSLRecommenderService{} - r.Options = opts - return -} - -// Enrollment in the SSL/TLS Recommender service which tries to detect and -// recommend (by sending periodic emails) the most secure SSL/TLS setting your -// origin servers support. -func (r *ZoneSettingSSLRecommenderService) Edit(ctx context.Context, params ZoneSettingSSLRecommenderEditParams, opts ...option.RequestOption) (res *ZoneSettingSSLRecommenderEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingSSLRecommenderEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/ssl_recommender", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Enrollment in the SSL/TLS Recommender service which tries to detect and -// recommend (by sending periodic emails) the most secure SSL/TLS setting your -// origin servers support. -func (r *ZoneSettingSSLRecommenderService) Get(ctx context.Context, query ZoneSettingSSLRecommenderGetParams, opts ...option.RequestOption) (res *ZoneSettingSSLRecommenderGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingSSLRecommenderGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/ssl_recommender", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Enrollment in the SSL/TLS Recommender service which tries to detect and -// recommend (by sending periodic emails) the most secure SSL/TLS setting your -// origin servers support. -type ZoneSettingSSLRecommenderEditResponse struct { - // Enrollment value for SSL/TLS Recommender. - ID ZoneSettingSSLRecommenderEditResponseID `json:"id"` - // ssl-recommender enrollment setting. - Enabled bool `json:"enabled"` - JSON zoneSettingSSLRecommenderEditResponseJSON `json:"-"` -} - -// zoneSettingSSLRecommenderEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingSSLRecommenderEditResponse] -type zoneSettingSSLRecommenderEditResponseJSON struct { - ID apijson.Field - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSSLRecommenderEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSSLRecommenderEditResponseJSON) RawJSON() string { - return r.raw -} - -// Enrollment value for SSL/TLS Recommender. -type ZoneSettingSSLRecommenderEditResponseID string - -const ( - ZoneSettingSSLRecommenderEditResponseIDSSLRecommender ZoneSettingSSLRecommenderEditResponseID = "ssl_recommender" -) - -// Enrollment in the SSL/TLS Recommender service which tries to detect and -// recommend (by sending periodic emails) the most secure SSL/TLS setting your -// origin servers support. -type ZoneSettingSSLRecommenderGetResponse struct { - // Enrollment value for SSL/TLS Recommender. - ID ZoneSettingSSLRecommenderGetResponseID `json:"id"` - // ssl-recommender enrollment setting. - Enabled bool `json:"enabled"` - JSON zoneSettingSSLRecommenderGetResponseJSON `json:"-"` -} - -// zoneSettingSSLRecommenderGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingSSLRecommenderGetResponse] -type zoneSettingSSLRecommenderGetResponseJSON struct { - ID apijson.Field - Enabled apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSSLRecommenderGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSSLRecommenderGetResponseJSON) RawJSON() string { - return r.raw -} - -// Enrollment value for SSL/TLS Recommender. -type ZoneSettingSSLRecommenderGetResponseID string - -const ( - ZoneSettingSSLRecommenderGetResponseIDSSLRecommender ZoneSettingSSLRecommenderGetResponseID = "ssl_recommender" -) - -type ZoneSettingSSLRecommenderEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Enrollment in the SSL/TLS Recommender service which tries to detect and - // recommend (by sending periodic emails) the most secure SSL/TLS setting your - // origin servers support. - Value param.Field[ZoneSettingSSLRecommenderEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingSSLRecommenderEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enrollment in the SSL/TLS Recommender service which tries to detect and -// recommend (by sending periodic emails) the most secure SSL/TLS setting your -// origin servers support. -type ZoneSettingSSLRecommenderEditParamsValue struct { - // Enrollment value for SSL/TLS Recommender. - ID param.Field[ZoneSettingSSLRecommenderEditParamsValueID] `json:"id"` - // ssl-recommender enrollment setting. - Enabled param.Field[bool] `json:"enabled"` -} - -func (r ZoneSettingSSLRecommenderEditParamsValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Enrollment value for SSL/TLS Recommender. -type ZoneSettingSSLRecommenderEditParamsValueID string - -const ( - ZoneSettingSSLRecommenderEditParamsValueIDSSLRecommender ZoneSettingSSLRecommenderEditParamsValueID = "ssl_recommender" -) - -type ZoneSettingSSLRecommenderEditResponseEnvelope struct { - Errors []ZoneSettingSSLRecommenderEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingSSLRecommenderEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Enrollment in the SSL/TLS Recommender service which tries to detect and - // recommend (by sending periodic emails) the most secure SSL/TLS setting your - // origin servers support. - Result ZoneSettingSSLRecommenderEditResponse `json:"result"` - JSON zoneSettingSSLRecommenderEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingSSLRecommenderEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingSSLRecommenderEditResponseEnvelope] -type zoneSettingSSLRecommenderEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSSLRecommenderEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSSLRecommenderEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSSLRecommenderEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSSLRecommenderEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingSSLRecommenderEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingSSLRecommenderEditResponseEnvelopeErrors] -type zoneSettingSSLRecommenderEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSSLRecommenderEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSSLRecommenderEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSSLRecommenderEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSSLRecommenderEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingSSLRecommenderEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingSSLRecommenderEditResponseEnvelopeMessages] -type zoneSettingSSLRecommenderEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSSLRecommenderEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSSLRecommenderEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSSLRecommenderGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingSSLRecommenderGetResponseEnvelope struct { - Errors []ZoneSettingSSLRecommenderGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingSSLRecommenderGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Enrollment in the SSL/TLS Recommender service which tries to detect and - // recommend (by sending periodic emails) the most secure SSL/TLS setting your - // origin servers support. - Result ZoneSettingSSLRecommenderGetResponse `json:"result"` - JSON zoneSettingSSLRecommenderGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingSSLRecommenderGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingSSLRecommenderGetResponseEnvelope] -type zoneSettingSSLRecommenderGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSSLRecommenderGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSSLRecommenderGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSSLRecommenderGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSSLRecommenderGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingSSLRecommenderGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingSSLRecommenderGetResponseEnvelopeErrors] -type zoneSettingSSLRecommenderGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSSLRecommenderGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSSLRecommenderGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingSSLRecommenderGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingSSLRecommenderGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingSSLRecommenderGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingSSLRecommenderGetResponseEnvelopeMessages] -type zoneSettingSSLRecommenderGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingSSLRecommenderGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingSSLRecommenderGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingsslrecommender_test.go b/zonesettingsslrecommender_test.go deleted file mode 100644 index 9ebe6b80d68..00000000000 --- a/zonesettingsslrecommender_test.go +++ /dev/null @@ -1,70 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingSSLRecommenderEditWithOptionalParams(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("user@example.com"), - ) - _, err := client.Zones.Settings.SSLRecommender.Edit(context.TODO(), cloudflare.ZoneSettingSSLRecommenderEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingSSLRecommenderEditParamsValue{ - Enabled: cloudflare.F(true), - ID: cloudflare.F(cloudflare.ZoneSettingSSLRecommenderEditParamsValueIDSSLRecommender), - }), - }) - 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 TestZoneSettingSSLRecommenderGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.SSLRecommender.Get(context.TODO(), cloudflare.ZoneSettingSSLRecommenderGetParams{ - ZoneID: cloudflare.F("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/zonesettingtls13.go b/zonesettingtls13.go deleted file mode 100644 index 37737859d38..00000000000 --- a/zonesettingtls13.go +++ /dev/null @@ -1,352 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingTLS1_3Service 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 [NewZoneSettingTLS1_3Service] method -// instead. -type ZoneSettingTLS1_3Service struct { - Options []option.RequestOption -} - -// NewZoneSettingTLS1_3Service 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 NewZoneSettingTLS1_3Service(opts ...option.RequestOption) (r *ZoneSettingTLS1_3Service) { - r = &ZoneSettingTLS1_3Service{} - r.Options = opts - return -} - -// Changes TLS 1.3 setting. -func (r *ZoneSettingTLS1_3Service) Edit(ctx context.Context, params ZoneSettingTLS1_3EditParams, opts ...option.RequestOption) (res *ZoneSettingTls1_3EditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingTls1_3EditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/tls_1_3", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets TLS 1.3 setting enabled for a zone. -func (r *ZoneSettingTLS1_3Service) Get(ctx context.Context, query ZoneSettingTLS1_3GetParams, opts ...option.RequestOption) (res *ZoneSettingTls1_3GetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingTls1_3GetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/tls_1_3", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Enables Crypto TLS 1.3 feature for a zone. -type ZoneSettingTls1_3EditResponse struct { - // ID of the zone setting. - ID ZoneSettingTls1_3EditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingTls1_3EditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingTls1_3EditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingTls1_3EditResponseJSON `json:"-"` -} - -// zoneSettingTls1_3EditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingTls1_3EditResponse] -type zoneSettingTls1_3EditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTls1_3EditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTls1_3EditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingTls1_3EditResponseID string - -const ( - ZoneSettingTls1_3EditResponseIDTLS1_3 ZoneSettingTls1_3EditResponseID = "tls_1_3" -) - -// Current value of the zone setting. -type ZoneSettingTls1_3EditResponseValue string - -const ( - ZoneSettingTls1_3EditResponseValueOn ZoneSettingTls1_3EditResponseValue = "on" - ZoneSettingTls1_3EditResponseValueOff ZoneSettingTls1_3EditResponseValue = "off" - ZoneSettingTls1_3EditResponseValueZrt ZoneSettingTls1_3EditResponseValue = "zrt" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingTls1_3EditResponseEditable bool - -const ( - ZoneSettingTls1_3EditResponseEditableTrue ZoneSettingTls1_3EditResponseEditable = true - ZoneSettingTls1_3EditResponseEditableFalse ZoneSettingTls1_3EditResponseEditable = false -) - -// Enables Crypto TLS 1.3 feature for a zone. -type ZoneSettingTls1_3GetResponse struct { - // ID of the zone setting. - ID ZoneSettingTls1_3GetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingTls1_3GetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingTls1_3GetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingTls1_3GetResponseJSON `json:"-"` -} - -// zoneSettingTls1_3GetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingTls1_3GetResponse] -type zoneSettingTls1_3GetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTls1_3GetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTls1_3GetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingTls1_3GetResponseID string - -const ( - ZoneSettingTls1_3GetResponseIDTLS1_3 ZoneSettingTls1_3GetResponseID = "tls_1_3" -) - -// Current value of the zone setting. -type ZoneSettingTls1_3GetResponseValue string - -const ( - ZoneSettingTls1_3GetResponseValueOn ZoneSettingTls1_3GetResponseValue = "on" - ZoneSettingTls1_3GetResponseValueOff ZoneSettingTls1_3GetResponseValue = "off" - ZoneSettingTls1_3GetResponseValueZrt ZoneSettingTls1_3GetResponseValue = "zrt" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingTls1_3GetResponseEditable bool - -const ( - ZoneSettingTls1_3GetResponseEditableTrue ZoneSettingTls1_3GetResponseEditable = true - ZoneSettingTls1_3GetResponseEditableFalse ZoneSettingTls1_3GetResponseEditable = false -) - -type ZoneSettingTLS1_3EditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. Notes: Default value depends on the zone's plan - // level. - Value param.Field[ZoneSettingTls1_3EditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingTLS1_3EditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. Notes: Default value depends on the zone's plan -// level. -type ZoneSettingTls1_3EditParamsValue string - -const ( - ZoneSettingTls1_3EditParamsValueOn ZoneSettingTls1_3EditParamsValue = "on" - ZoneSettingTls1_3EditParamsValueOff ZoneSettingTls1_3EditParamsValue = "off" - ZoneSettingTls1_3EditParamsValueZrt ZoneSettingTls1_3EditParamsValue = "zrt" -) - -type ZoneSettingTls1_3EditResponseEnvelope struct { - Errors []ZoneSettingTls1_3EditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingTls1_3EditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Enables Crypto TLS 1.3 feature for a zone. - Result ZoneSettingTls1_3EditResponse `json:"result"` - JSON zoneSettingTls1_3EditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingTls1_3EditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingTls1_3EditResponseEnvelope] -type zoneSettingTls1_3EditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTls1_3EditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTls1_3EditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingTls1_3EditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingTls1_3EditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingTls1_3EditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSettingTls1_3EditResponseEnvelopeErrors] -type zoneSettingTls1_3EditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTls1_3EditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTls1_3EditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingTls1_3EditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingTls1_3EditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingTls1_3EditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingTls1_3EditResponseEnvelopeMessages] -type zoneSettingTls1_3EditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTls1_3EditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTls1_3EditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingTLS1_3GetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingTls1_3GetResponseEnvelope struct { - Errors []ZoneSettingTls1_3GetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingTls1_3GetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Enables Crypto TLS 1.3 feature for a zone. - Result ZoneSettingTls1_3GetResponse `json:"result"` - JSON zoneSettingTls1_3GetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingTls1_3GetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingTls1_3GetResponseEnvelope] -type zoneSettingTls1_3GetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTls1_3GetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTls1_3GetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingTls1_3GetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingTls1_3GetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingTls1_3GetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSettingTls1_3GetResponseEnvelopeErrors] -type zoneSettingTls1_3GetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTls1_3GetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTls1_3GetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingTls1_3GetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingTls1_3GetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingTls1_3GetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingTls1_3GetResponseEnvelopeMessages] -type zoneSettingTls1_3GetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTls1_3GetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTls1_3GetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingtls13_test.go b/zonesettingtls13_test.go deleted file mode 100644 index c102d1154cb..00000000000 --- a/zonesettingtls13_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingTLS1_3Edit(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("user@example.com"), - ) - _, err := client.Zones.Settings.TLS1_3.Edit(context.TODO(), cloudflare.ZoneSettingTLS1_3EditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingTls1_3EditParamsValueOn), - }) - 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 TestZoneSettingTLS1_3Get(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("user@example.com"), - ) - _, err := client.Zones.Settings.TLS1_3.Get(context.TODO(), cloudflare.ZoneSettingTLS1_3GetParams{ - ZoneID: cloudflare.F("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/zonesettingtlsclientauth.go b/zonesettingtlsclientauth.go deleted file mode 100644 index 0b82eb13830..00000000000 --- a/zonesettingtlsclientauth.go +++ /dev/null @@ -1,353 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingTLSClientAuthService 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 -// [NewZoneSettingTLSClientAuthService] method instead. -type ZoneSettingTLSClientAuthService struct { - Options []option.RequestOption -} - -// NewZoneSettingTLSClientAuthService 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 NewZoneSettingTLSClientAuthService(opts ...option.RequestOption) (r *ZoneSettingTLSClientAuthService) { - r = &ZoneSettingTLSClientAuthService{} - r.Options = opts - return -} - -// TLS Client Auth requires Cloudflare to connect to your origin server using a -// client certificate (Enterprise Only). -func (r *ZoneSettingTLSClientAuthService) Edit(ctx context.Context, params ZoneSettingTLSClientAuthEditParams, opts ...option.RequestOption) (res *ZoneSettingTLSClientAuthEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingTLSClientAuthEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/tls_client_auth", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// TLS Client Auth requires Cloudflare to connect to your origin server using a -// client certificate (Enterprise Only). -func (r *ZoneSettingTLSClientAuthService) Get(ctx context.Context, query ZoneSettingTLSClientAuthGetParams, opts ...option.RequestOption) (res *ZoneSettingTLSClientAuthGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingTLSClientAuthGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/tls_client_auth", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// TLS Client Auth requires Cloudflare to connect to your origin server using a -// client certificate (Enterprise Only). -type ZoneSettingTLSClientAuthEditResponse struct { - // ID of the zone setting. - ID ZoneSettingTLSClientAuthEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingTLSClientAuthEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingTLSClientAuthEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingTLSClientAuthEditResponseJSON `json:"-"` -} - -// zoneSettingTLSClientAuthEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingTLSClientAuthEditResponse] -type zoneSettingTLSClientAuthEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTLSClientAuthEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTLSClientAuthEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingTLSClientAuthEditResponseID string - -const ( - ZoneSettingTLSClientAuthEditResponseIDTLSClientAuth ZoneSettingTLSClientAuthEditResponseID = "tls_client_auth" -) - -// Current value of the zone setting. -type ZoneSettingTLSClientAuthEditResponseValue string - -const ( - ZoneSettingTLSClientAuthEditResponseValueOn ZoneSettingTLSClientAuthEditResponseValue = "on" - ZoneSettingTLSClientAuthEditResponseValueOff ZoneSettingTLSClientAuthEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingTLSClientAuthEditResponseEditable bool - -const ( - ZoneSettingTLSClientAuthEditResponseEditableTrue ZoneSettingTLSClientAuthEditResponseEditable = true - ZoneSettingTLSClientAuthEditResponseEditableFalse ZoneSettingTLSClientAuthEditResponseEditable = false -) - -// TLS Client Auth requires Cloudflare to connect to your origin server using a -// client certificate (Enterprise Only). -type ZoneSettingTLSClientAuthGetResponse struct { - // ID of the zone setting. - ID ZoneSettingTLSClientAuthGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingTLSClientAuthGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingTLSClientAuthGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingTLSClientAuthGetResponseJSON `json:"-"` -} - -// zoneSettingTLSClientAuthGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingTLSClientAuthGetResponse] -type zoneSettingTLSClientAuthGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTLSClientAuthGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTLSClientAuthGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingTLSClientAuthGetResponseID string - -const ( - ZoneSettingTLSClientAuthGetResponseIDTLSClientAuth ZoneSettingTLSClientAuthGetResponseID = "tls_client_auth" -) - -// Current value of the zone setting. -type ZoneSettingTLSClientAuthGetResponseValue string - -const ( - ZoneSettingTLSClientAuthGetResponseValueOn ZoneSettingTLSClientAuthGetResponseValue = "on" - ZoneSettingTLSClientAuthGetResponseValueOff ZoneSettingTLSClientAuthGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingTLSClientAuthGetResponseEditable bool - -const ( - ZoneSettingTLSClientAuthGetResponseEditableTrue ZoneSettingTLSClientAuthGetResponseEditable = true - ZoneSettingTLSClientAuthGetResponseEditableFalse ZoneSettingTLSClientAuthGetResponseEditable = false -) - -type ZoneSettingTLSClientAuthEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // value of the zone setting. - Value param.Field[ZoneSettingTLSClientAuthEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingTLSClientAuthEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// value of the zone setting. -type ZoneSettingTLSClientAuthEditParamsValue string - -const ( - ZoneSettingTLSClientAuthEditParamsValueOn ZoneSettingTLSClientAuthEditParamsValue = "on" - ZoneSettingTLSClientAuthEditParamsValueOff ZoneSettingTLSClientAuthEditParamsValue = "off" -) - -type ZoneSettingTLSClientAuthEditResponseEnvelope struct { - Errors []ZoneSettingTLSClientAuthEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingTLSClientAuthEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // TLS Client Auth requires Cloudflare to connect to your origin server using a - // client certificate (Enterprise Only). - Result ZoneSettingTLSClientAuthEditResponse `json:"result"` - JSON zoneSettingTLSClientAuthEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingTLSClientAuthEditResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingTLSClientAuthEditResponseEnvelope] -type zoneSettingTLSClientAuthEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTLSClientAuthEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTLSClientAuthEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingTLSClientAuthEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingTLSClientAuthEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingTLSClientAuthEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingTLSClientAuthEditResponseEnvelopeErrors] -type zoneSettingTLSClientAuthEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTLSClientAuthEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTLSClientAuthEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingTLSClientAuthEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingTLSClientAuthEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingTLSClientAuthEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingTLSClientAuthEditResponseEnvelopeMessages] -type zoneSettingTLSClientAuthEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTLSClientAuthEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTLSClientAuthEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingTLSClientAuthGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingTLSClientAuthGetResponseEnvelope struct { - Errors []ZoneSettingTLSClientAuthGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingTLSClientAuthGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // TLS Client Auth requires Cloudflare to connect to your origin server using a - // client certificate (Enterprise Only). - Result ZoneSettingTLSClientAuthGetResponse `json:"result"` - JSON zoneSettingTLSClientAuthGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingTLSClientAuthGetResponseEnvelopeJSON contains the JSON metadata for -// the struct [ZoneSettingTLSClientAuthGetResponseEnvelope] -type zoneSettingTLSClientAuthGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTLSClientAuthGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTLSClientAuthGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingTLSClientAuthGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingTLSClientAuthGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingTLSClientAuthGetResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingTLSClientAuthGetResponseEnvelopeErrors] -type zoneSettingTLSClientAuthGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTLSClientAuthGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTLSClientAuthGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingTLSClientAuthGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingTLSClientAuthGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingTLSClientAuthGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct [ZoneSettingTLSClientAuthGetResponseEnvelopeMessages] -type zoneSettingTLSClientAuthGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTLSClientAuthGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTLSClientAuthGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingtlsclientauth_test.go b/zonesettingtlsclientauth_test.go deleted file mode 100644 index 93f0e8b9291..00000000000 --- a/zonesettingtlsclientauth_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingTLSClientAuthEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.TLSClientAuth.Edit(context.TODO(), cloudflare.ZoneSettingTLSClientAuthEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingTLSClientAuthEditParamsValueOn), - }) - 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 TestZoneSettingTLSClientAuthGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.TLSClientAuth.Get(context.TODO(), cloudflare.ZoneSettingTLSClientAuthGetParams{ - ZoneID: cloudflare.F("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/zonesettingtrueclientipheader.go b/zonesettingtrueclientipheader.go deleted file mode 100644 index 0afb5e278ec..00000000000 --- a/zonesettingtrueclientipheader.go +++ /dev/null @@ -1,356 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingTrueClientIPHeaderService 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 -// [NewZoneSettingTrueClientIPHeaderService] method instead. -type ZoneSettingTrueClientIPHeaderService struct { - Options []option.RequestOption -} - -// NewZoneSettingTrueClientIPHeaderService 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 NewZoneSettingTrueClientIPHeaderService(opts ...option.RequestOption) (r *ZoneSettingTrueClientIPHeaderService) { - r = &ZoneSettingTrueClientIPHeaderService{} - r.Options = opts - return -} - -// Allows customer to continue to use True Client IP (Akamai feature) in the -// headers we send to the origin. This is limited to Enterprise Zones. -func (r *ZoneSettingTrueClientIPHeaderService) Edit(ctx context.Context, params ZoneSettingTrueClientIPHeaderEditParams, opts ...option.RequestOption) (res *ZoneSettingTrueClientIPHeaderEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingTrueClientIPHeaderEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/true_client_ip_header", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Allows customer to continue to use True Client IP (Akamai feature) in the -// headers we send to the origin. This is limited to Enterprise Zones. -func (r *ZoneSettingTrueClientIPHeaderService) Get(ctx context.Context, query ZoneSettingTrueClientIPHeaderGetParams, opts ...option.RequestOption) (res *ZoneSettingTrueClientIPHeaderGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingTrueClientIPHeaderGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/true_client_ip_header", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Allows customer to continue to use True Client IP (Akamai feature) in the -// headers we send to the origin. This is limited to Enterprise Zones. -type ZoneSettingTrueClientIPHeaderEditResponse struct { - // ID of the zone setting. - ID ZoneSettingTrueClientIPHeaderEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingTrueClientIPHeaderEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingTrueClientIPHeaderEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingTrueClientIPHeaderEditResponseJSON `json:"-"` -} - -// zoneSettingTrueClientIPHeaderEditResponseJSON contains the JSON metadata for the -// struct [ZoneSettingTrueClientIPHeaderEditResponse] -type zoneSettingTrueClientIPHeaderEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTrueClientIPHeaderEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTrueClientIPHeaderEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingTrueClientIPHeaderEditResponseID string - -const ( - ZoneSettingTrueClientIPHeaderEditResponseIDTrueClientIPHeader ZoneSettingTrueClientIPHeaderEditResponseID = "true_client_ip_header" -) - -// Current value of the zone setting. -type ZoneSettingTrueClientIPHeaderEditResponseValue string - -const ( - ZoneSettingTrueClientIPHeaderEditResponseValueOn ZoneSettingTrueClientIPHeaderEditResponseValue = "on" - ZoneSettingTrueClientIPHeaderEditResponseValueOff ZoneSettingTrueClientIPHeaderEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingTrueClientIPHeaderEditResponseEditable bool - -const ( - ZoneSettingTrueClientIPHeaderEditResponseEditableTrue ZoneSettingTrueClientIPHeaderEditResponseEditable = true - ZoneSettingTrueClientIPHeaderEditResponseEditableFalse ZoneSettingTrueClientIPHeaderEditResponseEditable = false -) - -// Allows customer to continue to use True Client IP (Akamai feature) in the -// headers we send to the origin. This is limited to Enterprise Zones. -type ZoneSettingTrueClientIPHeaderGetResponse struct { - // ID of the zone setting. - ID ZoneSettingTrueClientIPHeaderGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingTrueClientIPHeaderGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingTrueClientIPHeaderGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingTrueClientIPHeaderGetResponseJSON `json:"-"` -} - -// zoneSettingTrueClientIPHeaderGetResponseJSON contains the JSON metadata for the -// struct [ZoneSettingTrueClientIPHeaderGetResponse] -type zoneSettingTrueClientIPHeaderGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTrueClientIPHeaderGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTrueClientIPHeaderGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingTrueClientIPHeaderGetResponseID string - -const ( - ZoneSettingTrueClientIPHeaderGetResponseIDTrueClientIPHeader ZoneSettingTrueClientIPHeaderGetResponseID = "true_client_ip_header" -) - -// Current value of the zone setting. -type ZoneSettingTrueClientIPHeaderGetResponseValue string - -const ( - ZoneSettingTrueClientIPHeaderGetResponseValueOn ZoneSettingTrueClientIPHeaderGetResponseValue = "on" - ZoneSettingTrueClientIPHeaderGetResponseValueOff ZoneSettingTrueClientIPHeaderGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingTrueClientIPHeaderGetResponseEditable bool - -const ( - ZoneSettingTrueClientIPHeaderGetResponseEditableTrue ZoneSettingTrueClientIPHeaderGetResponseEditable = true - ZoneSettingTrueClientIPHeaderGetResponseEditableFalse ZoneSettingTrueClientIPHeaderGetResponseEditable = false -) - -type ZoneSettingTrueClientIPHeaderEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingTrueClientIPHeaderEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingTrueClientIPHeaderEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingTrueClientIPHeaderEditParamsValue string - -const ( - ZoneSettingTrueClientIPHeaderEditParamsValueOn ZoneSettingTrueClientIPHeaderEditParamsValue = "on" - ZoneSettingTrueClientIPHeaderEditParamsValueOff ZoneSettingTrueClientIPHeaderEditParamsValue = "off" -) - -type ZoneSettingTrueClientIPHeaderEditResponseEnvelope struct { - Errors []ZoneSettingTrueClientIPHeaderEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingTrueClientIPHeaderEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Allows customer to continue to use True Client IP (Akamai feature) in the - // headers we send to the origin. This is limited to Enterprise Zones. - Result ZoneSettingTrueClientIPHeaderEditResponse `json:"result"` - JSON zoneSettingTrueClientIPHeaderEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingTrueClientIPHeaderEditResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingTrueClientIPHeaderEditResponseEnvelope] -type zoneSettingTrueClientIPHeaderEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTrueClientIPHeaderEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTrueClientIPHeaderEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingTrueClientIPHeaderEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingTrueClientIPHeaderEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingTrueClientIPHeaderEditResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct -// [ZoneSettingTrueClientIPHeaderEditResponseEnvelopeErrors] -type zoneSettingTrueClientIPHeaderEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTrueClientIPHeaderEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTrueClientIPHeaderEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingTrueClientIPHeaderEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingTrueClientIPHeaderEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingTrueClientIPHeaderEditResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZoneSettingTrueClientIPHeaderEditResponseEnvelopeMessages] -type zoneSettingTrueClientIPHeaderEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTrueClientIPHeaderEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTrueClientIPHeaderEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingTrueClientIPHeaderGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingTrueClientIPHeaderGetResponseEnvelope struct { - Errors []ZoneSettingTrueClientIPHeaderGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingTrueClientIPHeaderGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // Allows customer to continue to use True Client IP (Akamai feature) in the - // headers we send to the origin. This is limited to Enterprise Zones. - Result ZoneSettingTrueClientIPHeaderGetResponse `json:"result"` - JSON zoneSettingTrueClientIPHeaderGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingTrueClientIPHeaderGetResponseEnvelopeJSON contains the JSON metadata -// for the struct [ZoneSettingTrueClientIPHeaderGetResponseEnvelope] -type zoneSettingTrueClientIPHeaderGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTrueClientIPHeaderGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTrueClientIPHeaderGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingTrueClientIPHeaderGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingTrueClientIPHeaderGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingTrueClientIPHeaderGetResponseEnvelopeErrorsJSON contains the JSON -// metadata for the struct [ZoneSettingTrueClientIPHeaderGetResponseEnvelopeErrors] -type zoneSettingTrueClientIPHeaderGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTrueClientIPHeaderGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTrueClientIPHeaderGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingTrueClientIPHeaderGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingTrueClientIPHeaderGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingTrueClientIPHeaderGetResponseEnvelopeMessagesJSON contains the JSON -// metadata for the struct -// [ZoneSettingTrueClientIPHeaderGetResponseEnvelopeMessages] -type zoneSettingTrueClientIPHeaderGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingTrueClientIPHeaderGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingTrueClientIPHeaderGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingtrueclientipheader_test.go b/zonesettingtrueclientipheader_test.go deleted file mode 100644 index 131849c5532..00000000000 --- a/zonesettingtrueclientipheader_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingTrueClientIPHeaderEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.TrueClientIPHeader.Edit(context.TODO(), cloudflare.ZoneSettingTrueClientIPHeaderEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingTrueClientIPHeaderEditParamsValueOn), - }) - 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 TestZoneSettingTrueClientIPHeaderGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.TrueClientIPHeader.Get(context.TODO(), cloudflare.ZoneSettingTrueClientIPHeaderGetParams{ - ZoneID: cloudflare.F("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/zonesettingwaf.go b/zonesettingwaf.go deleted file mode 100644 index bae27063b9a..00000000000 --- a/zonesettingwaf.go +++ /dev/null @@ -1,401 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingWAFService 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 [NewZoneSettingWAFService] method -// instead. -type ZoneSettingWAFService struct { - Options []option.RequestOption -} - -// NewZoneSettingWAFService 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 NewZoneSettingWAFService(opts ...option.RequestOption) (r *ZoneSettingWAFService) { - r = &ZoneSettingWAFService{} - r.Options = opts - return -} - -// The WAF examines HTTP requests to your website. It inspects both GET and POST -// requests and applies rules to help filter out illegitimate traffic from -// legitimate website visitors. The Cloudflare WAF inspects website addresses or -// URLs to detect anything out of the ordinary. If the Cloudflare WAF determines -// suspicious user behavior, then the WAF will 'challenge' the web visitor with a -// page that asks them to submit a CAPTCHA successfully to continue their action. -// If the challenge is failed, the action will be stopped. What this means is that -// Cloudflare's WAF will block any traffic identified as illegitimate before it -// reaches your origin web server. -// (https://support.cloudflare.com/hc/en-us/articles/200172016). -func (r *ZoneSettingWAFService) Edit(ctx context.Context, params ZoneSettingWAFEditParams, opts ...option.RequestOption) (res *ZoneSettingWAFEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingWAFEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/waf", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// The WAF examines HTTP requests to your website. It inspects both GET and POST -// requests and applies rules to help filter out illegitimate traffic from -// legitimate website visitors. The Cloudflare WAF inspects website addresses or -// URLs to detect anything out of the ordinary. If the Cloudflare WAF determines -// suspicious user behavior, then the WAF will 'challenge' the web visitor with a -// page that asks them to submit a CAPTCHA successfully to continue their action. -// If the challenge is failed, the action will be stopped. What this means is that -// Cloudflare's WAF will block any traffic identified as illegitimate before it -// reaches your origin web server. -// (https://support.cloudflare.com/hc/en-us/articles/200172016). -func (r *ZoneSettingWAFService) Get(ctx context.Context, query ZoneSettingWAFGetParams, opts ...option.RequestOption) (res *ZoneSettingWAFGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingWAFGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/waf", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// The WAF examines HTTP requests to your website. It inspects both GET and POST -// requests and applies rules to help filter out illegitimate traffic from -// legitimate website visitors. The Cloudflare WAF inspects website addresses or -// URLs to detect anything out of the ordinary. If the Cloudflare WAF determines -// suspicious user behavior, then the WAF will 'challenge' the web visitor with a -// page that asks them to submit a CAPTCHA successfully to continue their action. -// If the challenge is failed, the action will be stopped. What this means is that -// Cloudflare's WAF will block any traffic identified as illegitimate before it -// reaches your origin web server. -// (https://support.cloudflare.com/hc/en-us/articles/200172016). -type ZoneSettingWAFEditResponse struct { - // ID of the zone setting. - ID ZoneSettingWAFEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingWAFEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingWAFEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingWAFEditResponseJSON `json:"-"` -} - -// zoneSettingWAFEditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingWAFEditResponse] -type zoneSettingWAFEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWAFEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWAFEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingWAFEditResponseID string - -const ( - ZoneSettingWAFEditResponseIDWAF ZoneSettingWAFEditResponseID = "waf" -) - -// Current value of the zone setting. -type ZoneSettingWAFEditResponseValue string - -const ( - ZoneSettingWAFEditResponseValueOn ZoneSettingWAFEditResponseValue = "on" - ZoneSettingWAFEditResponseValueOff ZoneSettingWAFEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingWAFEditResponseEditable bool - -const ( - ZoneSettingWAFEditResponseEditableTrue ZoneSettingWAFEditResponseEditable = true - ZoneSettingWAFEditResponseEditableFalse ZoneSettingWAFEditResponseEditable = false -) - -// The WAF examines HTTP requests to your website. It inspects both GET and POST -// requests and applies rules to help filter out illegitimate traffic from -// legitimate website visitors. The Cloudflare WAF inspects website addresses or -// URLs to detect anything out of the ordinary. If the Cloudflare WAF determines -// suspicious user behavior, then the WAF will 'challenge' the web visitor with a -// page that asks them to submit a CAPTCHA successfully to continue their action. -// If the challenge is failed, the action will be stopped. What this means is that -// Cloudflare's WAF will block any traffic identified as illegitimate before it -// reaches your origin web server. -// (https://support.cloudflare.com/hc/en-us/articles/200172016). -type ZoneSettingWAFGetResponse struct { - // ID of the zone setting. - ID ZoneSettingWAFGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingWAFGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingWAFGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingWAFGetResponseJSON `json:"-"` -} - -// zoneSettingWAFGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingWAFGetResponse] -type zoneSettingWAFGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWAFGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWAFGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingWAFGetResponseID string - -const ( - ZoneSettingWAFGetResponseIDWAF ZoneSettingWAFGetResponseID = "waf" -) - -// Current value of the zone setting. -type ZoneSettingWAFGetResponseValue string - -const ( - ZoneSettingWAFGetResponseValueOn ZoneSettingWAFGetResponseValue = "on" - ZoneSettingWAFGetResponseValueOff ZoneSettingWAFGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingWAFGetResponseEditable bool - -const ( - ZoneSettingWAFGetResponseEditableTrue ZoneSettingWAFGetResponseEditable = true - ZoneSettingWAFGetResponseEditableFalse ZoneSettingWAFGetResponseEditable = false -) - -type ZoneSettingWAFEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingWAFEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingWAFEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingWAFEditParamsValue string - -const ( - ZoneSettingWAFEditParamsValueOn ZoneSettingWAFEditParamsValue = "on" - ZoneSettingWAFEditParamsValueOff ZoneSettingWAFEditParamsValue = "off" -) - -type ZoneSettingWAFEditResponseEnvelope struct { - Errors []ZoneSettingWAFEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingWAFEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // The WAF examines HTTP requests to your website. It inspects both GET and POST - // requests and applies rules to help filter out illegitimate traffic from - // legitimate website visitors. The Cloudflare WAF inspects website addresses or - // URLs to detect anything out of the ordinary. If the Cloudflare WAF determines - // suspicious user behavior, then the WAF will 'challenge' the web visitor with a - // page that asks them to submit a CAPTCHA successfully to continue their action. - // If the challenge is failed, the action will be stopped. What this means is that - // Cloudflare's WAF will block any traffic identified as illegitimate before it - // reaches your origin web server. - // (https://support.cloudflare.com/hc/en-us/articles/200172016). - Result ZoneSettingWAFEditResponse `json:"result"` - JSON zoneSettingWAFEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingWAFEditResponseEnvelopeJSON contains the JSON metadata for the struct -// [ZoneSettingWAFEditResponseEnvelope] -type zoneSettingWAFEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWAFEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWAFEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingWAFEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingWAFEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingWAFEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZoneSettingWAFEditResponseEnvelopeErrors] -type zoneSettingWAFEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWAFEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWAFEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingWAFEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingWAFEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingWAFEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingWAFEditResponseEnvelopeMessages] -type zoneSettingWAFEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWAFEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWAFEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingWAFGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingWAFGetResponseEnvelope struct { - Errors []ZoneSettingWAFGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingWAFGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // The WAF examines HTTP requests to your website. It inspects both GET and POST - // requests and applies rules to help filter out illegitimate traffic from - // legitimate website visitors. The Cloudflare WAF inspects website addresses or - // URLs to detect anything out of the ordinary. If the Cloudflare WAF determines - // suspicious user behavior, then the WAF will 'challenge' the web visitor with a - // page that asks them to submit a CAPTCHA successfully to continue their action. - // If the challenge is failed, the action will be stopped. What this means is that - // Cloudflare's WAF will block any traffic identified as illegitimate before it - // reaches your origin web server. - // (https://support.cloudflare.com/hc/en-us/articles/200172016). - Result ZoneSettingWAFGetResponse `json:"result"` - JSON zoneSettingWAFGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingWAFGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [ZoneSettingWAFGetResponseEnvelope] -type zoneSettingWAFGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWAFGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWAFGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingWAFGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingWAFGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingWAFGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZoneSettingWAFGetResponseEnvelopeErrors] -type zoneSettingWAFGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWAFGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWAFGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingWAFGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingWAFGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingWAFGetResponseEnvelopeMessagesJSON contains the JSON metadata for the -// struct [ZoneSettingWAFGetResponseEnvelopeMessages] -type zoneSettingWAFGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWAFGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWAFGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingwaf_test.go b/zonesettingwaf_test.go deleted file mode 100644 index 1ebaca5bc36..00000000000 --- a/zonesettingwaf_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingWAFEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.WAF.Edit(context.TODO(), cloudflare.ZoneSettingWAFEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingWAFEditParamsValueOn), - }) - 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 TestZoneSettingWAFGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.WAF.Get(context.TODO(), cloudflare.ZoneSettingWAFGetParams{ - ZoneID: cloudflare.F("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/zonesettingwebp.go b/zonesettingwebp.go deleted file mode 100644 index e36a803a6c7..00000000000 --- a/zonesettingwebp.go +++ /dev/null @@ -1,359 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingWebpService 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 [NewZoneSettingWebpService] method -// instead. -type ZoneSettingWebpService struct { - Options []option.RequestOption -} - -// NewZoneSettingWebpService 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 NewZoneSettingWebpService(opts ...option.RequestOption) (r *ZoneSettingWebpService) { - r = &ZoneSettingWebpService{} - r.Options = opts - return -} - -// When the client requesting the image supports the WebP image codec, and WebP -// offers a performance advantage over the original image format, Cloudflare will -// serve a WebP version of the original image. -func (r *ZoneSettingWebpService) Edit(ctx context.Context, params ZoneSettingWebpEditParams, opts ...option.RequestOption) (res *ZoneSettingWebpEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingWebpEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/webp", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// When the client requesting the image supports the WebP image codec, and WebP -// offers a performance advantage over the original image format, Cloudflare will -// serve a WebP version of the original image. -func (r *ZoneSettingWebpService) Get(ctx context.Context, query ZoneSettingWebpGetParams, opts ...option.RequestOption) (res *ZoneSettingWebpGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingWebpGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/webp", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// When the client requesting the image supports the WebP image codec, and WebP -// offers a performance advantage over the original image format, Cloudflare will -// serve a WebP version of the original image. -type ZoneSettingWebpEditResponse struct { - // ID of the zone setting. - ID ZoneSettingWebpEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingWebpEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingWebpEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingWebpEditResponseJSON `json:"-"` -} - -// zoneSettingWebpEditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingWebpEditResponse] -type zoneSettingWebpEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWebpEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWebpEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingWebpEditResponseID string - -const ( - ZoneSettingWebpEditResponseIDWebp ZoneSettingWebpEditResponseID = "webp" -) - -// Current value of the zone setting. -type ZoneSettingWebpEditResponseValue string - -const ( - ZoneSettingWebpEditResponseValueOff ZoneSettingWebpEditResponseValue = "off" - ZoneSettingWebpEditResponseValueOn ZoneSettingWebpEditResponseValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingWebpEditResponseEditable bool - -const ( - ZoneSettingWebpEditResponseEditableTrue ZoneSettingWebpEditResponseEditable = true - ZoneSettingWebpEditResponseEditableFalse ZoneSettingWebpEditResponseEditable = false -) - -// When the client requesting the image supports the WebP image codec, and WebP -// offers a performance advantage over the original image format, Cloudflare will -// serve a WebP version of the original image. -type ZoneSettingWebpGetResponse struct { - // ID of the zone setting. - ID ZoneSettingWebpGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingWebpGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingWebpGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingWebpGetResponseJSON `json:"-"` -} - -// zoneSettingWebpGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingWebpGetResponse] -type zoneSettingWebpGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWebpGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWebpGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingWebpGetResponseID string - -const ( - ZoneSettingWebpGetResponseIDWebp ZoneSettingWebpGetResponseID = "webp" -) - -// Current value of the zone setting. -type ZoneSettingWebpGetResponseValue string - -const ( - ZoneSettingWebpGetResponseValueOff ZoneSettingWebpGetResponseValue = "off" - ZoneSettingWebpGetResponseValueOn ZoneSettingWebpGetResponseValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingWebpGetResponseEditable bool - -const ( - ZoneSettingWebpGetResponseEditableTrue ZoneSettingWebpGetResponseEditable = true - ZoneSettingWebpGetResponseEditableFalse ZoneSettingWebpGetResponseEditable = false -) - -type ZoneSettingWebpEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingWebpEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingWebpEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingWebpEditParamsValue string - -const ( - ZoneSettingWebpEditParamsValueOff ZoneSettingWebpEditParamsValue = "off" - ZoneSettingWebpEditParamsValueOn ZoneSettingWebpEditParamsValue = "on" -) - -type ZoneSettingWebpEditResponseEnvelope struct { - Errors []ZoneSettingWebpEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingWebpEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // When the client requesting the image supports the WebP image codec, and WebP - // offers a performance advantage over the original image format, Cloudflare will - // serve a WebP version of the original image. - Result ZoneSettingWebpEditResponse `json:"result"` - JSON zoneSettingWebpEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingWebpEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingWebpEditResponseEnvelope] -type zoneSettingWebpEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWebpEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWebpEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingWebpEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingWebpEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingWebpEditResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZoneSettingWebpEditResponseEnvelopeErrors] -type zoneSettingWebpEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWebpEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWebpEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingWebpEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingWebpEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingWebpEditResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingWebpEditResponseEnvelopeMessages] -type zoneSettingWebpEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWebpEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWebpEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingWebpGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingWebpGetResponseEnvelope struct { - Errors []ZoneSettingWebpGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingWebpGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // When the client requesting the image supports the WebP image codec, and WebP - // offers a performance advantage over the original image format, Cloudflare will - // serve a WebP version of the original image. - Result ZoneSettingWebpGetResponse `json:"result"` - JSON zoneSettingWebpGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingWebpGetResponseEnvelopeJSON contains the JSON metadata for the struct -// [ZoneSettingWebpGetResponseEnvelope] -type zoneSettingWebpGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWebpGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWebpGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingWebpGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingWebpGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingWebpGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZoneSettingWebpGetResponseEnvelopeErrors] -type zoneSettingWebpGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWebpGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWebpGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingWebpGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingWebpGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingWebpGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingWebpGetResponseEnvelopeMessages] -type zoneSettingWebpGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWebpGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWebpGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingwebp_test.go b/zonesettingwebp_test.go deleted file mode 100644 index d18c6a74c01..00000000000 --- a/zonesettingwebp_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingWebpEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.Webp.Edit(context.TODO(), cloudflare.ZoneSettingWebpEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingWebpEditParamsValueOff), - }) - 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 TestZoneSettingWebpGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.Webp.Get(context.TODO(), cloudflare.ZoneSettingWebpGetParams{ - ZoneID: cloudflare.F("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/zonesettingwebsocket.go b/zonesettingwebsocket.go deleted file mode 100644 index aeacfe65bc1..00000000000 --- a/zonesettingwebsocket.go +++ /dev/null @@ -1,374 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingWebsocketService 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 [NewZoneSettingWebsocketService] -// method instead. -type ZoneSettingWebsocketService struct { - Options []option.RequestOption -} - -// NewZoneSettingWebsocketService 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 NewZoneSettingWebsocketService(opts ...option.RequestOption) (r *ZoneSettingWebsocketService) { - r = &ZoneSettingWebsocketService{} - r.Options = opts - return -} - -// Changes Websockets setting. For more information about Websockets, please refer -// to -// [Using Cloudflare with WebSockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Using-Cloudflare-with-WebSockets). -func (r *ZoneSettingWebsocketService) Edit(ctx context.Context, params ZoneSettingWebsocketEditParams, opts ...option.RequestOption) (res *ZoneSettingWebsocketEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingWebsocketEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/websockets", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets Websockets setting. For more information about Websockets, please refer to -// [Using Cloudflare with WebSockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Using-Cloudflare-with-WebSockets). -func (r *ZoneSettingWebsocketService) Get(ctx context.Context, query ZoneSettingWebsocketGetParams, opts ...option.RequestOption) (res *ZoneSettingWebsocketGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingWebsocketGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/websockets", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// WebSockets are open connections sustained between the client and the origin -// server. Inside a WebSockets connection, the client and the origin can pass data -// back and forth without having to reestablish sessions. This makes exchanging -// data within a WebSockets connection fast. WebSockets are often used for -// real-time applications such as live chat and gaming. For more information refer -// to -// [Can I use Cloudflare with Websockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Can-I-use-Cloudflare-with-WebSockets-). -type ZoneSettingWebsocketEditResponse struct { - // ID of the zone setting. - ID ZoneSettingWebsocketEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingWebsocketEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingWebsocketEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingWebsocketEditResponseJSON `json:"-"` -} - -// zoneSettingWebsocketEditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingWebsocketEditResponse] -type zoneSettingWebsocketEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWebsocketEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWebsocketEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingWebsocketEditResponseID string - -const ( - ZoneSettingWebsocketEditResponseIDWebsockets ZoneSettingWebsocketEditResponseID = "websockets" -) - -// Current value of the zone setting. -type ZoneSettingWebsocketEditResponseValue string - -const ( - ZoneSettingWebsocketEditResponseValueOff ZoneSettingWebsocketEditResponseValue = "off" - ZoneSettingWebsocketEditResponseValueOn ZoneSettingWebsocketEditResponseValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingWebsocketEditResponseEditable bool - -const ( - ZoneSettingWebsocketEditResponseEditableTrue ZoneSettingWebsocketEditResponseEditable = true - ZoneSettingWebsocketEditResponseEditableFalse ZoneSettingWebsocketEditResponseEditable = false -) - -// WebSockets are open connections sustained between the client and the origin -// server. Inside a WebSockets connection, the client and the origin can pass data -// back and forth without having to reestablish sessions. This makes exchanging -// data within a WebSockets connection fast. WebSockets are often used for -// real-time applications such as live chat and gaming. For more information refer -// to -// [Can I use Cloudflare with Websockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Can-I-use-Cloudflare-with-WebSockets-). -type ZoneSettingWebsocketGetResponse struct { - // ID of the zone setting. - ID ZoneSettingWebsocketGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingWebsocketGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingWebsocketGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingWebsocketGetResponseJSON `json:"-"` -} - -// zoneSettingWebsocketGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingWebsocketGetResponse] -type zoneSettingWebsocketGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWebsocketGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWebsocketGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingWebsocketGetResponseID string - -const ( - ZoneSettingWebsocketGetResponseIDWebsockets ZoneSettingWebsocketGetResponseID = "websockets" -) - -// Current value of the zone setting. -type ZoneSettingWebsocketGetResponseValue string - -const ( - ZoneSettingWebsocketGetResponseValueOff ZoneSettingWebsocketGetResponseValue = "off" - ZoneSettingWebsocketGetResponseValueOn ZoneSettingWebsocketGetResponseValue = "on" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingWebsocketGetResponseEditable bool - -const ( - ZoneSettingWebsocketGetResponseEditableTrue ZoneSettingWebsocketGetResponseEditable = true - ZoneSettingWebsocketGetResponseEditableFalse ZoneSettingWebsocketGetResponseEditable = false -) - -type ZoneSettingWebsocketEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the zone setting. - Value param.Field[ZoneSettingWebsocketEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingWebsocketEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the zone setting. -type ZoneSettingWebsocketEditParamsValue string - -const ( - ZoneSettingWebsocketEditParamsValueOff ZoneSettingWebsocketEditParamsValue = "off" - ZoneSettingWebsocketEditParamsValueOn ZoneSettingWebsocketEditParamsValue = "on" -) - -type ZoneSettingWebsocketEditResponseEnvelope struct { - Errors []ZoneSettingWebsocketEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingWebsocketEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // WebSockets are open connections sustained between the client and the origin - // server. Inside a WebSockets connection, the client and the origin can pass data - // back and forth without having to reestablish sessions. This makes exchanging - // data within a WebSockets connection fast. WebSockets are often used for - // real-time applications such as live chat and gaming. For more information refer - // to - // [Can I use Cloudflare with Websockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Can-I-use-Cloudflare-with-WebSockets-). - Result ZoneSettingWebsocketEditResponse `json:"result"` - JSON zoneSettingWebsocketEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingWebsocketEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingWebsocketEditResponseEnvelope] -type zoneSettingWebsocketEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWebsocketEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWebsocketEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingWebsocketEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingWebsocketEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingWebsocketEditResponseEnvelopeErrorsJSON contains the JSON metadata -// for the struct [ZoneSettingWebsocketEditResponseEnvelopeErrors] -type zoneSettingWebsocketEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWebsocketEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWebsocketEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingWebsocketEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingWebsocketEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingWebsocketEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZoneSettingWebsocketEditResponseEnvelopeMessages] -type zoneSettingWebsocketEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWebsocketEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWebsocketEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingWebsocketGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingWebsocketGetResponseEnvelope struct { - Errors []ZoneSettingWebsocketGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingWebsocketGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // WebSockets are open connections sustained between the client and the origin - // server. Inside a WebSockets connection, the client and the origin can pass data - // back and forth without having to reestablish sessions. This makes exchanging - // data within a WebSockets connection fast. WebSockets are often used for - // real-time applications such as live chat and gaming. For more information refer - // to - // [Can I use Cloudflare with Websockets](https://support.cloudflare.com/hc/en-us/articles/200169466-Can-I-use-Cloudflare-with-WebSockets-). - Result ZoneSettingWebsocketGetResponse `json:"result"` - JSON zoneSettingWebsocketGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingWebsocketGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingWebsocketGetResponseEnvelope] -type zoneSettingWebsocketGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWebsocketGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWebsocketGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingWebsocketGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingWebsocketGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingWebsocketGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSettingWebsocketGetResponseEnvelopeErrors] -type zoneSettingWebsocketGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWebsocketGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWebsocketGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingWebsocketGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingWebsocketGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingWebsocketGetResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZoneSettingWebsocketGetResponseEnvelopeMessages] -type zoneSettingWebsocketGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingWebsocketGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingWebsocketGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingwebsocket_test.go b/zonesettingwebsocket_test.go deleted file mode 100644 index a55ca9229c8..00000000000 --- a/zonesettingwebsocket_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingWebsocketEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.Websocket.Edit(context.TODO(), cloudflare.ZoneSettingWebsocketEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingWebsocketEditParamsValueOff), - }) - 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 TestZoneSettingWebsocketGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.Websocket.Get(context.TODO(), cloudflare.ZoneSettingWebsocketGetParams{ - ZoneID: cloudflare.F("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/zonesettingzerortt.go b/zonesettingzerortt.go deleted file mode 100644 index 501c229297e..00000000000 --- a/zonesettingzerortt.go +++ /dev/null @@ -1,347 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneSettingZeroRTTService 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 [NewZoneSettingZeroRTTService] method -// instead. -type ZoneSettingZeroRTTService struct { - Options []option.RequestOption -} - -// NewZoneSettingZeroRTTService 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 NewZoneSettingZeroRTTService(opts ...option.RequestOption) (r *ZoneSettingZeroRTTService) { - r = &ZoneSettingZeroRTTService{} - r.Options = opts - return -} - -// Changes the 0-RTT session resumption setting. -func (r *ZoneSettingZeroRTTService) Edit(ctx context.Context, params ZoneSettingZeroRTTEditParams, opts ...option.RequestOption) (res *ZoneSettingZeroRTTEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingZeroRTTEditResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/0rtt", params.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, params, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Gets 0-RTT session resumption setting. -func (r *ZoneSettingZeroRTTService) Get(ctx context.Context, query ZoneSettingZeroRTTGetParams, opts ...option.RequestOption) (res *ZoneSettingZeroRTTGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSettingZeroRTTGetResponseEnvelope - path := fmt.Sprintf("zones/%s/settings/0rtt", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// 0-RTT session resumption enabled for this zone. -type ZoneSettingZeroRTTEditResponse struct { - // ID of the zone setting. - ID ZoneSettingZeroRTTEditResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingZeroRTTEditResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingZeroRTTEditResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingZeroRTTEditResponseJSON `json:"-"` -} - -// zoneSettingZeroRTTEditResponseJSON contains the JSON metadata for the struct -// [ZoneSettingZeroRTTEditResponse] -type zoneSettingZeroRTTEditResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingZeroRTTEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingZeroRTTEditResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingZeroRTTEditResponseID string - -const ( - ZoneSettingZeroRTTEditResponseID0rtt ZoneSettingZeroRTTEditResponseID = "0rtt" -) - -// Current value of the zone setting. -type ZoneSettingZeroRTTEditResponseValue string - -const ( - ZoneSettingZeroRTTEditResponseValueOn ZoneSettingZeroRTTEditResponseValue = "on" - ZoneSettingZeroRTTEditResponseValueOff ZoneSettingZeroRTTEditResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingZeroRTTEditResponseEditable bool - -const ( - ZoneSettingZeroRTTEditResponseEditableTrue ZoneSettingZeroRTTEditResponseEditable = true - ZoneSettingZeroRTTEditResponseEditableFalse ZoneSettingZeroRTTEditResponseEditable = false -) - -// 0-RTT session resumption enabled for this zone. -type ZoneSettingZeroRTTGetResponse struct { - // ID of the zone setting. - ID ZoneSettingZeroRTTGetResponseID `json:"id,required"` - // Current value of the zone setting. - Value ZoneSettingZeroRTTGetResponseValue `json:"value,required"` - // Whether or not this setting can be modified for this zone (based on your - // Cloudflare plan level). - Editable ZoneSettingZeroRTTGetResponseEditable `json:"editable"` - // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,nullable" format:"date-time"` - JSON zoneSettingZeroRTTGetResponseJSON `json:"-"` -} - -// zoneSettingZeroRTTGetResponseJSON contains the JSON metadata for the struct -// [ZoneSettingZeroRTTGetResponse] -type zoneSettingZeroRTTGetResponseJSON struct { - ID apijson.Field - Value apijson.Field - Editable apijson.Field - ModifiedOn apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingZeroRTTGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingZeroRTTGetResponseJSON) RawJSON() string { - return r.raw -} - -// ID of the zone setting. -type ZoneSettingZeroRTTGetResponseID string - -const ( - ZoneSettingZeroRTTGetResponseID0rtt ZoneSettingZeroRTTGetResponseID = "0rtt" -) - -// Current value of the zone setting. -type ZoneSettingZeroRTTGetResponseValue string - -const ( - ZoneSettingZeroRTTGetResponseValueOn ZoneSettingZeroRTTGetResponseValue = "on" - ZoneSettingZeroRTTGetResponseValueOff ZoneSettingZeroRTTGetResponseValue = "off" -) - -// Whether or not this setting can be modified for this zone (based on your -// Cloudflare plan level). -type ZoneSettingZeroRTTGetResponseEditable bool - -const ( - ZoneSettingZeroRTTGetResponseEditableTrue ZoneSettingZeroRTTGetResponseEditable = true - ZoneSettingZeroRTTGetResponseEditableFalse ZoneSettingZeroRTTGetResponseEditable = false -) - -type ZoneSettingZeroRTTEditParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - // Value of the 0-RTT setting. - Value param.Field[ZoneSettingZeroRTTEditParamsValue] `json:"value,required"` -} - -func (r ZoneSettingZeroRTTEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Value of the 0-RTT setting. -type ZoneSettingZeroRTTEditParamsValue string - -const ( - ZoneSettingZeroRTTEditParamsValueOn ZoneSettingZeroRTTEditParamsValue = "on" - ZoneSettingZeroRTTEditParamsValueOff ZoneSettingZeroRTTEditParamsValue = "off" -) - -type ZoneSettingZeroRTTEditResponseEnvelope struct { - Errors []ZoneSettingZeroRTTEditResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingZeroRTTEditResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // 0-RTT session resumption enabled for this zone. - Result ZoneSettingZeroRTTEditResponse `json:"result"` - JSON zoneSettingZeroRTTEditResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingZeroRTTEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingZeroRTTEditResponseEnvelope] -type zoneSettingZeroRTTEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingZeroRTTEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingZeroRTTEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingZeroRTTEditResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingZeroRTTEditResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingZeroRTTEditResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSettingZeroRTTEditResponseEnvelopeErrors] -type zoneSettingZeroRTTEditResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingZeroRTTEditResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingZeroRTTEditResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingZeroRTTEditResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingZeroRTTEditResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingZeroRTTEditResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZoneSettingZeroRTTEditResponseEnvelopeMessages] -type zoneSettingZeroRTTEditResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingZeroRTTEditResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingZeroRTTEditResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingZeroRTTGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneSettingZeroRTTGetResponseEnvelope struct { - Errors []ZoneSettingZeroRTTGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSettingZeroRTTGetResponseEnvelopeMessages `json:"messages,required"` - // Whether the API call was successful - Success bool `json:"success,required"` - // 0-RTT session resumption enabled for this zone. - Result ZoneSettingZeroRTTGetResponse `json:"result"` - JSON zoneSettingZeroRTTGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSettingZeroRTTGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSettingZeroRTTGetResponseEnvelope] -type zoneSettingZeroRTTGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - Result apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingZeroRTTGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingZeroRTTGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingZeroRTTGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingZeroRTTGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSettingZeroRTTGetResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSettingZeroRTTGetResponseEnvelopeErrors] -type zoneSettingZeroRTTGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingZeroRTTGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingZeroRTTGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSettingZeroRTTGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSettingZeroRTTGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSettingZeroRTTGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSettingZeroRTTGetResponseEnvelopeMessages] -type zoneSettingZeroRTTGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSettingZeroRTTGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSettingZeroRTTGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} diff --git a/zonesettingzerortt_test.go b/zonesettingzerortt_test.go deleted file mode 100644 index 2ebf02a6c2b..00000000000 --- a/zonesettingzerortt_test.go +++ /dev/null @@ -1,67 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSettingZeroRTTEdit(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("user@example.com"), - ) - _, err := client.Zones.Settings.ZeroRTT.Edit(context.TODO(), cloudflare.ZoneSettingZeroRTTEditParams{ - ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Value: cloudflare.F(cloudflare.ZoneSettingZeroRTTEditParamsValueOn), - }) - 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 TestZoneSettingZeroRTTGet(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("user@example.com"), - ) - _, err := client.Zones.Settings.ZeroRTT.Get(context.TODO(), cloudflare.ZoneSettingZeroRTTGetParams{ - ZoneID: cloudflare.F("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/zonesubscription.go b/zonesubscription.go deleted file mode 100644 index 06b7a09b549..00000000000 --- a/zonesubscription.go +++ /dev/null @@ -1,660 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZoneSubscriptionService 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 [NewZoneSubscriptionService] method -// instead. -type ZoneSubscriptionService struct { - Options []option.RequestOption -} - -// NewZoneSubscriptionService 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 NewZoneSubscriptionService(opts ...option.RequestOption) (r *ZoneSubscriptionService) { - r = &ZoneSubscriptionService{} - r.Options = opts - return -} - -// Create a zone subscription, either plan or add-ons. -func (r *ZoneSubscriptionService) New(ctx context.Context, identifier string, body ZoneSubscriptionNewParams, opts ...option.RequestOption) (res *ZoneSubscriptionNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSubscriptionNewResponseEnvelope - path := fmt.Sprintf("zones/%s/subscription", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists all of an account's subscriptions. -func (r *ZoneSubscriptionService) List(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *[]ZoneSubscriptionListResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSubscriptionListResponseEnvelope - path := fmt.Sprintf("accounts/%s/subscriptions", accountIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Lists zone subscription details. -func (r *ZoneSubscriptionService) Get(ctx context.Context, identifier string, opts ...option.RequestOption) (res *ZoneSubscriptionGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneSubscriptionGetResponseEnvelope - path := fmt.Sprintf("zones/%s/subscription", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Union satisfied by [ZoneSubscriptionNewResponseUnknown] or [shared.UnionString]. -type ZoneSubscriptionNewResponse interface { - ImplementsZoneSubscriptionNewResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZoneSubscriptionNewResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZoneSubscriptionListResponse struct { - // Subscription identifier tag. - ID string `json:"id"` - App ZoneSubscriptionListResponseApp `json:"app"` - // The list of add-ons subscribed to. - ComponentValues []ZoneSubscriptionListResponseComponentValue `json:"component_values"` - // The monetary unit in which pricing information is displayed. - Currency string `json:"currency"` - // The end of the current period and also when the next billing is due. - CurrentPeriodEnd time.Time `json:"current_period_end" format:"date-time"` - // When the current billing period started. May match initial_period_start if this - // is the first period. - CurrentPeriodStart time.Time `json:"current_period_start" format:"date-time"` - // How often the subscription is renewed automatically. - Frequency ZoneSubscriptionListResponseFrequency `json:"frequency"` - // The price of the subscription that will be billed, in US dollars. - Price float64 `json:"price"` - // The rate plan applied to the subscription. - RatePlan ZoneSubscriptionListResponseRatePlan `json:"rate_plan"` - // The state that the subscription is in. - State ZoneSubscriptionListResponseState `json:"state"` - // A simple zone object. May have null properties if not a zone subscription. - Zone ZoneSubscriptionListResponseZone `json:"zone"` - JSON zoneSubscriptionListResponseJSON `json:"-"` -} - -// zoneSubscriptionListResponseJSON contains the JSON metadata for the struct -// [ZoneSubscriptionListResponse] -type zoneSubscriptionListResponseJSON struct { - ID apijson.Field - App apijson.Field - ComponentValues apijson.Field - Currency apijson.Field - CurrentPeriodEnd apijson.Field - CurrentPeriodStart apijson.Field - Frequency apijson.Field - Price apijson.Field - RatePlan apijson.Field - State apijson.Field - Zone apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSubscriptionListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSubscriptionListResponseJSON) RawJSON() string { - return r.raw -} - -type ZoneSubscriptionListResponseApp struct { - // app install id. - InstallID string `json:"install_id"` - JSON zoneSubscriptionListResponseAppJSON `json:"-"` -} - -// zoneSubscriptionListResponseAppJSON contains the JSON metadata for the struct -// [ZoneSubscriptionListResponseApp] -type zoneSubscriptionListResponseAppJSON struct { - InstallID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSubscriptionListResponseApp) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSubscriptionListResponseAppJSON) RawJSON() string { - return r.raw -} - -// A component value for a subscription. -type ZoneSubscriptionListResponseComponentValue struct { - // The default amount assigned. - Default float64 `json:"default"` - // The name of the component value. - Name string `json:"name"` - // The unit price for the component value. - Price float64 `json:"price"` - // The amount of the component value assigned. - Value float64 `json:"value"` - JSON zoneSubscriptionListResponseComponentValueJSON `json:"-"` -} - -// zoneSubscriptionListResponseComponentValueJSON contains the JSON metadata for -// the struct [ZoneSubscriptionListResponseComponentValue] -type zoneSubscriptionListResponseComponentValueJSON struct { - Default apijson.Field - Name apijson.Field - Price apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSubscriptionListResponseComponentValue) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSubscriptionListResponseComponentValueJSON) RawJSON() string { - return r.raw -} - -// How often the subscription is renewed automatically. -type ZoneSubscriptionListResponseFrequency string - -const ( - ZoneSubscriptionListResponseFrequencyWeekly ZoneSubscriptionListResponseFrequency = "weekly" - ZoneSubscriptionListResponseFrequencyMonthly ZoneSubscriptionListResponseFrequency = "monthly" - ZoneSubscriptionListResponseFrequencyQuarterly ZoneSubscriptionListResponseFrequency = "quarterly" - ZoneSubscriptionListResponseFrequencyYearly ZoneSubscriptionListResponseFrequency = "yearly" -) - -// The rate plan applied to the subscription. -type ZoneSubscriptionListResponseRatePlan struct { - // The ID of the rate plan. - ID interface{} `json:"id"` - // The currency applied to the rate plan subscription. - Currency string `json:"currency"` - // Whether this rate plan is managed externally from Cloudflare. - ExternallyManaged bool `json:"externally_managed"` - // Whether a rate plan is enterprise-based (or newly adopted term contract). - IsContract bool `json:"is_contract"` - // The full name of the rate plan. - PublicName string `json:"public_name"` - // The scope that this rate plan applies to. - Scope string `json:"scope"` - // The list of sets this rate plan applies to. - Sets []string `json:"sets"` - JSON zoneSubscriptionListResponseRatePlanJSON `json:"-"` -} - -// zoneSubscriptionListResponseRatePlanJSON contains the JSON metadata for the -// struct [ZoneSubscriptionListResponseRatePlan] -type zoneSubscriptionListResponseRatePlanJSON struct { - ID apijson.Field - Currency apijson.Field - ExternallyManaged apijson.Field - IsContract apijson.Field - PublicName apijson.Field - Scope apijson.Field - Sets apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSubscriptionListResponseRatePlan) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSubscriptionListResponseRatePlanJSON) RawJSON() string { - return r.raw -} - -// The state that the subscription is in. -type ZoneSubscriptionListResponseState string - -const ( - ZoneSubscriptionListResponseStateTrial ZoneSubscriptionListResponseState = "Trial" - ZoneSubscriptionListResponseStateProvisioned ZoneSubscriptionListResponseState = "Provisioned" - ZoneSubscriptionListResponseStatePaid ZoneSubscriptionListResponseState = "Paid" - ZoneSubscriptionListResponseStateAwaitingPayment ZoneSubscriptionListResponseState = "AwaitingPayment" - ZoneSubscriptionListResponseStateCancelled ZoneSubscriptionListResponseState = "Cancelled" - ZoneSubscriptionListResponseStateFailed ZoneSubscriptionListResponseState = "Failed" - ZoneSubscriptionListResponseStateExpired ZoneSubscriptionListResponseState = "Expired" -) - -// A simple zone object. May have null properties if not a zone subscription. -type ZoneSubscriptionListResponseZone struct { - // Identifier - ID string `json:"id"` - // The domain name - Name string `json:"name"` - JSON zoneSubscriptionListResponseZoneJSON `json:"-"` -} - -// zoneSubscriptionListResponseZoneJSON contains the JSON metadata for the struct -// [ZoneSubscriptionListResponseZone] -type zoneSubscriptionListResponseZoneJSON struct { - ID apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSubscriptionListResponseZone) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSubscriptionListResponseZoneJSON) RawJSON() string { - return r.raw -} - -// Union satisfied by [ZoneSubscriptionGetResponseUnknown] or [shared.UnionString]. -type ZoneSubscriptionGetResponse interface { - ImplementsZoneSubscriptionGetResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZoneSubscriptionGetResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZoneSubscriptionNewParams struct { - App param.Field[ZoneSubscriptionNewParamsApp] `json:"app"` - // The list of add-ons subscribed to. - ComponentValues param.Field[[]ZoneSubscriptionNewParamsComponentValue] `json:"component_values"` - // How often the subscription is renewed automatically. - Frequency param.Field[ZoneSubscriptionNewParamsFrequency] `json:"frequency"` - // The rate plan applied to the subscription. - RatePlan param.Field[ZoneSubscriptionNewParamsRatePlan] `json:"rate_plan"` - // A simple zone object. May have null properties if not a zone subscription. - Zone param.Field[ZoneSubscriptionNewParamsZone] `json:"zone"` -} - -func (r ZoneSubscriptionNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZoneSubscriptionNewParamsApp struct { - // app install id. - InstallID param.Field[string] `json:"install_id"` -} - -func (r ZoneSubscriptionNewParamsApp) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A component value for a subscription. -type ZoneSubscriptionNewParamsComponentValue struct { - // The default amount assigned. - Default param.Field[float64] `json:"default"` - // The name of the component value. - Name param.Field[string] `json:"name"` - // The unit price for the component value. - Price param.Field[float64] `json:"price"` - // The amount of the component value assigned. - Value param.Field[float64] `json:"value"` -} - -func (r ZoneSubscriptionNewParamsComponentValue) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// How often the subscription is renewed automatically. -type ZoneSubscriptionNewParamsFrequency string - -const ( - ZoneSubscriptionNewParamsFrequencyWeekly ZoneSubscriptionNewParamsFrequency = "weekly" - ZoneSubscriptionNewParamsFrequencyMonthly ZoneSubscriptionNewParamsFrequency = "monthly" - ZoneSubscriptionNewParamsFrequencyQuarterly ZoneSubscriptionNewParamsFrequency = "quarterly" - ZoneSubscriptionNewParamsFrequencyYearly ZoneSubscriptionNewParamsFrequency = "yearly" -) - -// The rate plan applied to the subscription. -type ZoneSubscriptionNewParamsRatePlan struct { - // The ID of the rate plan. - ID param.Field[interface{}] `json:"id"` - // The currency applied to the rate plan subscription. - Currency param.Field[string] `json:"currency"` - // Whether this rate plan is managed externally from Cloudflare. - ExternallyManaged param.Field[bool] `json:"externally_managed"` - // Whether a rate plan is enterprise-based (or newly adopted term contract). - IsContract param.Field[bool] `json:"is_contract"` - // The full name of the rate plan. - PublicName param.Field[string] `json:"public_name"` - // The scope that this rate plan applies to. - Scope param.Field[string] `json:"scope"` - // The list of sets this rate plan applies to. - Sets param.Field[[]string] `json:"sets"` -} - -func (r ZoneSubscriptionNewParamsRatePlan) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// A simple zone object. May have null properties if not a zone subscription. -type ZoneSubscriptionNewParamsZone struct { -} - -func (r ZoneSubscriptionNewParamsZone) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type ZoneSubscriptionNewResponseEnvelope struct { - Errors []ZoneSubscriptionNewResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSubscriptionNewResponseEnvelopeMessages `json:"messages,required"` - Result ZoneSubscriptionNewResponse `json:"result,required"` - // Whether the API call was successful - Success ZoneSubscriptionNewResponseEnvelopeSuccess `json:"success,required"` - JSON zoneSubscriptionNewResponseEnvelopeJSON `json:"-"` -} - -// zoneSubscriptionNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSubscriptionNewResponseEnvelope] -type zoneSubscriptionNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSubscriptionNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSubscriptionNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSubscriptionNewResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSubscriptionNewResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSubscriptionNewResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZoneSubscriptionNewResponseEnvelopeErrors] -type zoneSubscriptionNewResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSubscriptionNewResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSubscriptionNewResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSubscriptionNewResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSubscriptionNewResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSubscriptionNewResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSubscriptionNewResponseEnvelopeMessages] -type zoneSubscriptionNewResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSubscriptionNewResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSubscriptionNewResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZoneSubscriptionNewResponseEnvelopeSuccess bool - -const ( - ZoneSubscriptionNewResponseEnvelopeSuccessTrue ZoneSubscriptionNewResponseEnvelopeSuccess = true -) - -type ZoneSubscriptionListResponseEnvelope struct { - Errors []ZoneSubscriptionListResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSubscriptionListResponseEnvelopeMessages `json:"messages,required"` - Result []ZoneSubscriptionListResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success ZoneSubscriptionListResponseEnvelopeSuccess `json:"success,required"` - ResultInfo ZoneSubscriptionListResponseEnvelopeResultInfo `json:"result_info"` - JSON zoneSubscriptionListResponseEnvelopeJSON `json:"-"` -} - -// zoneSubscriptionListResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSubscriptionListResponseEnvelope] -type zoneSubscriptionListResponseEnvelopeJSON 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 *ZoneSubscriptionListResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSubscriptionListResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSubscriptionListResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSubscriptionListResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSubscriptionListResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneSubscriptionListResponseEnvelopeErrors] -type zoneSubscriptionListResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSubscriptionListResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSubscriptionListResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSubscriptionListResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSubscriptionListResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSubscriptionListResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSubscriptionListResponseEnvelopeMessages] -type zoneSubscriptionListResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSubscriptionListResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSubscriptionListResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZoneSubscriptionListResponseEnvelopeSuccess bool - -const ( - ZoneSubscriptionListResponseEnvelopeSuccessTrue ZoneSubscriptionListResponseEnvelopeSuccess = true -) - -type ZoneSubscriptionListResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON zoneSubscriptionListResponseEnvelopeResultInfoJSON `json:"-"` -} - -// zoneSubscriptionListResponseEnvelopeResultInfoJSON contains the JSON metadata -// for the struct [ZoneSubscriptionListResponseEnvelopeResultInfo] -type zoneSubscriptionListResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSubscriptionListResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSubscriptionListResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} - -type ZoneSubscriptionGetResponseEnvelope struct { - Errors []ZoneSubscriptionGetResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneSubscriptionGetResponseEnvelopeMessages `json:"messages,required"` - Result ZoneSubscriptionGetResponse `json:"result,required"` - // Whether the API call was successful - Success ZoneSubscriptionGetResponseEnvelopeSuccess `json:"success,required"` - JSON zoneSubscriptionGetResponseEnvelopeJSON `json:"-"` -} - -// zoneSubscriptionGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneSubscriptionGetResponseEnvelope] -type zoneSubscriptionGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSubscriptionGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSubscriptionGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneSubscriptionGetResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSubscriptionGetResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneSubscriptionGetResponseEnvelopeErrorsJSON contains the JSON metadata for the -// struct [ZoneSubscriptionGetResponseEnvelopeErrors] -type zoneSubscriptionGetResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSubscriptionGetResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSubscriptionGetResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneSubscriptionGetResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneSubscriptionGetResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneSubscriptionGetResponseEnvelopeMessagesJSON contains the JSON metadata for -// the struct [ZoneSubscriptionGetResponseEnvelopeMessages] -type zoneSubscriptionGetResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneSubscriptionGetResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneSubscriptionGetResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZoneSubscriptionGetResponseEnvelopeSuccess bool - -const ( - ZoneSubscriptionGetResponseEnvelopeSuccessTrue ZoneSubscriptionGetResponseEnvelopeSuccess = true -) diff --git a/zonesubscription_test.go b/zonesubscription_test.go deleted file mode 100644 index 24fe976ef6c..00000000000 --- a/zonesubscription_test.go +++ /dev/null @@ -1,121 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneSubscriptionNewWithOptionalParams(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("user@example.com"), - ) - _, err := client.Zones.Subscriptions.New( - context.TODO(), - "506e3185e9c882d175a2d0cb0093d9f2", - cloudflare.ZoneSubscriptionNewParams{ - App: cloudflare.F(cloudflare.ZoneSubscriptionNewParamsApp{ - InstallID: cloudflare.F("string"), - }), - ComponentValues: cloudflare.F([]cloudflare.ZoneSubscriptionNewParamsComponentValue{{ - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }, { - Default: cloudflare.F(5.000000), - Name: cloudflare.F("page_rules"), - Price: cloudflare.F(5.000000), - Value: cloudflare.F(20.000000), - }}), - Frequency: cloudflare.F(cloudflare.ZoneSubscriptionNewParamsFrequencyMonthly), - RatePlan: cloudflare.F(cloudflare.ZoneSubscriptionNewParamsRatePlan{ - Currency: cloudflare.F("USD"), - ExternallyManaged: cloudflare.F(false), - ID: cloudflare.F[any]("free"), - IsContract: cloudflare.F(false), - PublicName: cloudflare.F("Business Plan"), - Scope: cloudflare.F("zone"), - Sets: cloudflare.F([]string{"string", "string", "string"}), - }), - Zone: cloudflare.F(cloudflare.ZoneSubscriptionNewParamsZone{}), - }, - ) - 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 TestZoneSubscriptionList(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("user@example.com"), - ) - _, err := client.Zones.Subscriptions.List(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()) - } -} - -func TestZoneSubscriptionGet(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("user@example.com"), - ) - _, err := client.Zones.Subscriptions.Get(context.TODO(), "506e3185e9c882d175a2d0cb0093d9f2") - 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/zoneworker.go b/zoneworker.go deleted file mode 100644 index 3133b2ee671..00000000000 --- a/zoneworker.go +++ /dev/null @@ -1,26 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "github.com/cloudflare/cloudflare-go/option" -) - -// ZoneWorkerService 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 [NewZoneWorkerService] method instead. -type ZoneWorkerService struct { - Options []option.RequestOption - Script *ZoneWorkerScriptService -} - -// NewZoneWorkerService 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 NewZoneWorkerService(opts ...option.RequestOption) (r *ZoneWorkerService) { - r = &ZoneWorkerService{} - r.Options = opts - r.Script = NewZoneWorkerScriptService(opts...) - return -} diff --git a/zoneworkerscript.go b/zoneworkerscript.go deleted file mode 100644 index a5f02fdfe9b..00000000000 --- a/zoneworkerscript.go +++ /dev/null @@ -1,180 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare - -import ( - "context" - "fmt" - "net/http" - "reflect" - - "github.com/cloudflare/cloudflare-go/internal/apijson" - "github.com/cloudflare/cloudflare-go/internal/param" - "github.com/cloudflare/cloudflare-go/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/internal/shared" - "github.com/cloudflare/cloudflare-go/option" - "github.com/tidwall/gjson" -) - -// ZoneWorkerScriptService 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 [NewZoneWorkerScriptService] method -// instead. -type ZoneWorkerScriptService struct { - Options []option.RequestOption -} - -// NewZoneWorkerScriptService 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 NewZoneWorkerScriptService(opts ...option.RequestOption) (r *ZoneWorkerScriptService) { - r = &ZoneWorkerScriptService{} - r.Options = opts - return -} - -// Upload a worker, or a new version of a worker. -func (r *ZoneWorkerScriptService) Update(ctx context.Context, body ZoneWorkerScriptUpdateParams, opts ...option.RequestOption) (res *ZoneWorkerScriptUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env ZoneWorkerScriptUpdateResponseEnvelope - path := fmt.Sprintf("zones/%s/workers/script", body.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Delete your Worker. This call has no response body on a successful delete. -func (r *ZoneWorkerScriptService) Delete(ctx context.Context, body ZoneWorkerScriptDeleteParams, opts ...option.RequestOption) (err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "")}, opts...) - path := fmt.Sprintf("zones/%s/workers/script", body.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, body, nil, opts...) - return -} - -// Fetch raw script content for your worker. Note this is the original script -// content, not JSON encoded. -func (r *ZoneWorkerScriptService) Get(ctx context.Context, query ZoneWorkerScriptGetParams, opts ...option.RequestOption) (res *http.Response, err error) { - opts = append(r.Options[:], opts...) - opts = append([]option.RequestOption{option.WithHeader("Accept", "undefined")}, opts...) - path := fmt.Sprintf("zones/%s/workers/script", query.ZoneID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, query, &res, opts...) - return -} - -// Union satisfied by [ZoneWorkerScriptUpdateResponseUnknown] or -// [shared.UnionString]. -type ZoneWorkerScriptUpdateResponse interface { - ImplementsZoneWorkerScriptUpdateResponse() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*ZoneWorkerScriptUpdateResponse)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type ZoneWorkerScriptUpdateParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneWorkerScriptUpdateResponseEnvelope struct { - Errors []ZoneWorkerScriptUpdateResponseEnvelopeErrors `json:"errors,required"` - Messages []ZoneWorkerScriptUpdateResponseEnvelopeMessages `json:"messages,required"` - Result ZoneWorkerScriptUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success ZoneWorkerScriptUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON zoneWorkerScriptUpdateResponseEnvelopeJSON `json:"-"` -} - -// zoneWorkerScriptUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [ZoneWorkerScriptUpdateResponseEnvelope] -type zoneWorkerScriptUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneWorkerScriptUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneWorkerScriptUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -type ZoneWorkerScriptUpdateResponseEnvelopeErrors struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneWorkerScriptUpdateResponseEnvelopeErrorsJSON `json:"-"` -} - -// zoneWorkerScriptUpdateResponseEnvelopeErrorsJSON contains the JSON metadata for -// the struct [ZoneWorkerScriptUpdateResponseEnvelopeErrors] -type zoneWorkerScriptUpdateResponseEnvelopeErrorsJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneWorkerScriptUpdateResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneWorkerScriptUpdateResponseEnvelopeErrorsJSON) RawJSON() string { - return r.raw -} - -type ZoneWorkerScriptUpdateResponseEnvelopeMessages struct { - Code int64 `json:"code,required"` - Message string `json:"message,required"` - JSON zoneWorkerScriptUpdateResponseEnvelopeMessagesJSON `json:"-"` -} - -// zoneWorkerScriptUpdateResponseEnvelopeMessagesJSON contains the JSON metadata -// for the struct [ZoneWorkerScriptUpdateResponseEnvelopeMessages] -type zoneWorkerScriptUpdateResponseEnvelopeMessagesJSON struct { - Code apijson.Field - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *ZoneWorkerScriptUpdateResponseEnvelopeMessages) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r zoneWorkerScriptUpdateResponseEnvelopeMessagesJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type ZoneWorkerScriptUpdateResponseEnvelopeSuccess bool - -const ( - ZoneWorkerScriptUpdateResponseEnvelopeSuccessTrue ZoneWorkerScriptUpdateResponseEnvelopeSuccess = true -) - -type ZoneWorkerScriptDeleteParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} - -type ZoneWorkerScriptGetParams struct { - // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` -} diff --git a/zoneworkerscript_test.go b/zoneworkerscript_test.go deleted file mode 100644 index 5f76355f4bc..00000000000 --- a/zoneworkerscript_test.go +++ /dev/null @@ -1,108 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package cloudflare_test - -import ( - "bytes" - "context" - "errors" - "io" - "net/http" - "net/http/httptest" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go" - "github.com/cloudflare/cloudflare-go/internal/testutil" - "github.com/cloudflare/cloudflare-go/option" -) - -func TestZoneWorkerScriptUpdate(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("user@example.com"), - ) - _, err := client.Zones.Workers.Script.Update(context.TODO(), cloudflare.ZoneWorkerScriptUpdateParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestZoneWorkerScriptDelete(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("user@example.com"), - ) - err := client.Zones.Workers.Script.Delete(context.TODO(), cloudflare.ZoneWorkerScriptDeleteParams{ - ZoneID: cloudflare.F("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()) - } -} - -func TestZoneWorkerScriptGet(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) - w.Write([]byte("abc")) - })) - defer server.Close() - baseURL := server.URL - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - resp, err := client.Zones.Workers.Script.Get(context.TODO(), cloudflare.ZoneWorkerScriptGetParams{ - ZoneID: cloudflare.F("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()) - } - defer resp.Body.Close() - - b, err := io.ReadAll(resp.Body) - 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()) - } - if !bytes.Equal(b, []byte("abc")) { - t.Fatalf("return value not %s: %s", "abc", b) - } -}